<?xml version="1.0" encoding="utf-8"?>
<posts>
  <row Id="1" PostTypeId="1" AcceptedAnswerId="44" CreationDate="2019-05-30T21:23:14.080" Score="12" ViewCount="1834" Body="&lt;p&gt;In a continuous-review &lt;span class=&quot;math-container&quot;&gt;$(r,Q)$&lt;/span&gt; inventory system under a type-1 service level constraint, if the demand per unit time is distributed as &lt;span class=&quot;math-container&quot;&gt;$N(\mu,\sigma^2)$&lt;/span&gt; and the lead time, &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;, is a constant, then the lead-time demand also has a normal distribution. The optimal reorder point (under some simplifying assumptions) is given by&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$r = \mu L + z_\alpha\sigma\sqrt{L}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; are the holding and stockout costs, &lt;span class=&quot;math-container&quot;&gt;$\alpha=p/(p+h)$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z_\alpha$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;th quantile of the standard normal distribution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now suppose the lead time is also stochastic, with distribution &lt;span class=&quot;math-container&quot;&gt;$N(\mu_L,\sigma_L^2)$&lt;/span&gt;. It is well known that the lead-time demand distribution has mean and variance&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\mu_{LTD} = \mu\mu_L$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sigma^2_{LTD} = \mu_L\sigma^2 + \mu^2\sigma_L^2$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe this part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: &lt;em&gt;is the lead-time demand normally distributed&lt;/em&gt;? I do not think it is. But many textbooks (including mine!) give the formula for the optimal reorder point as &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$r = \mu_{LTD} + z_\alpha\sigma_{LTD}. $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This formula is only correct if the lead-time demand is normally distributed. If the LTD is not normally distributed, then this formula is at best an approximation. &lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-04T17:17:42.063" LastActivityDate="2019-12-24T17:03:22.320" Title="Normal demand and normal lead time; is lead-time demand normal?" Tags="|inventory|probability-theory|probability-distributions|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2" PostTypeId="1" AcceptedAnswerId="29" CreationDate="2019-05-30T21:26:49.880" Score="20" ViewCount="3425" Body="&lt;p&gt;It is well known that &lt;em&gt;expectation preserves convexity&lt;/em&gt;: If &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is convex and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is a random variable, then &lt;span class=&quot;math-container&quot;&gt;$\mathbb E[f(x-Y)]$&lt;/span&gt; is convex. This property arises in, for example, inventory theory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not been able to find a good source to cite for this well-known fact. Can anyone suggest one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(For what it's worth, Boyd and Vandenberghe's book proves another well known property, namely, minimization preserves convexity, but I don't think they prove it for expectation.)&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="123" LastEditDate="2019-06-01T13:14:35.900" LastActivityDate="2019-06-01T13:14:35.900" Title="Reference for &quot;expectation preserves convexity&quot;" Tags="|convexity|probability-theory|reference-request|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3" PostTypeId="1" AcceptedAnswerId="10" CreationDate="2019-05-30T21:52:08.990" Score="18" ViewCount="2668" Body="&lt;p&gt;Having all the approaches explained in the blog called &quot;OR in an OB World&quot; (&lt;a href=&quot;https://orinanobworld.blogspot.com/2012/07/modeling-absolute-values.html&quot; rel=&quot;noreferrer&quot;&gt;this address&lt;/a&gt;) in my mind, I would like to ask the following question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best practice to make a constraint linear when for a variable in constraints, there is an absolute value expression which has lower and upper bounds? In other words, if a variable needs to cover two separate symmetric areas around zero (but not zero itself), how should it be enforced in the model? &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="8" LastEditDate="2019-06-02T01:56:37.943" LastActivityDate="2019-06-02T01:56:37.943" Title="Working with absolute values in constraint in a LP or MILP" Tags="|linear-programming|constraint|mixed-integer-programming|absolute-value|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4" PostTypeId="1" AcceptedAnswerId="7" CreationDate="2019-05-30T22:08:24.903" Score="34" ViewCount="1603" Body="&lt;p&gt;I'm familiar with &lt;a href=&quot;https://www.coin-or.org/&quot; rel=&quot;noreferrer&quot;&gt;COIN-OR&lt;/a&gt; and have also used a couple packages in R to solve LPs. Today I found out Google has their own &lt;a href=&quot;https://developers.google.com/optimization/&quot; rel=&quot;noreferrer&quot;&gt;open source optimization software&lt;/a&gt;, and it got me wondering what other open source LP solvers are out there?&lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="123" LastEditDate="2019-09-12T07:45:17.533" LastActivityDate="2019-09-12T07:45:17.533" Title="Where can I find open source LP solvers?" Tags="|linear-programming|solver|online-resources|open-source|" AnswerCount="6" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="5" PostTypeId="2" ParentId="4" CreationDate="2019-05-30T22:19:32.990" Score="12" Body="&lt;p&gt;I believe SCIP is the fastest non-commercial solver. It’s free for academic use. You can check out the benchmarks by Hans Mittelmann for other suggestions.&lt;/p&gt;&#xA;" OwnerUserId="44" LastActivityDate="2019-05-30T22:19:32.990" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6" PostTypeId="1" CreationDate="2019-05-30T22:21:48.770" Score="12" ViewCount="361" Body="&lt;p&gt;There are many naturally multi-stage (i.e., more than two) stochastic programming problems that are approximated by a two-stage stochastic programming model due to the complete intractability of the 'real' model. For example, consider a 10 period location-transportation problem with some dependencies between the periods so that the solution of one of the periods determines possible recourse actions for the period thereafter. With a two-stage approximation I imply that we consider, in terms of location-transportation, a first-stage decision where we determine the locations to be opened in a first-stage decision. Then, we act as  if all information of the 10 periods is presented to the decision-maker, and we make transportation plans for the upcoming 10 periods as a single second-stage decision. The 'real' model here would be a 10-stage stochastic program, but is intractable for many applications (the location-transportation might actually be a problem that is 'relatively' easy, so don't take it to literally)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, we act as if all uncertainty regarding all future states is revealed after the first stage decision, and this first-stage decision is taken for all future periods directly. Then this approximation can be used in a rolling horizon fashion to guide dynamic decision support. I think (am I correct?) this is a generally accepted method to approach such problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any tips and tricks to do so? For example, it feels intuitive to add more weight to nearby decisions than to decisions that are still far away:)&lt;/p&gt;&#xA;" OwnerUserId="48" LastEditorUserId="48" LastEditDate="2019-05-31T11:11:12.500" LastActivityDate="2019-06-14T19:57:39.467" Title="2 stage stochastic programming to approximate many stage problems" Tags="|constraint|stochastic-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7" PostTypeId="2" ParentId="4" CreationDate="2019-05-30T22:23:09.800" Score="20" Body="&lt;p&gt;&lt;a href=&quot;https://opensolver.org/&quot; rel=&quot;noreferrer&quot;&gt;OpenSolver&lt;/a&gt; is an LP/IP/NLP solver that plugs into Microsoft Excel. I used it for some classroom stuff a while back and was quite pleased with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are interested in metaheuristics, there are quite a few open-source contributions floating around (about which I mostly know nothing). I have used the &lt;a href=&quot;https://watchmaker.uncommons.org/&quot; rel=&quot;noreferrer&quot;&gt;Watchmaker Framework for Evolutionary Computation&lt;/a&gt; (i.e., genetic algorithms) successfully in a couple of projects. I don't think it is under active development any more (although the developer might respond to pull requests), but it is quite well documented and works. Not long ago, I looked around and found some other Java-based GA libraries, but have not gotten around to testing any.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-05-30T22:23:09.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8" PostTypeId="2" ParentId="4" CreationDate="2019-05-30T22:26:15.930" Score="19" Body="&lt;p&gt;&lt;a href=&quot;http://plato.asu.edu/ftp/lpsimp.html&quot; rel=&quot;noreferrer&quot;&gt;Mittelmann&lt;/a&gt; benchmarks a number of (LP-)Solvers, some of which are open source. A recent new open source solver is &lt;a href=&quot;https://github.com/ERGO-Code/HiGHS&quot; rel=&quot;noreferrer&quot;&gt;HiGHS&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="47" LastActivityDate="2019-05-30T22:26:15.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9" PostTypeId="2" ParentId="4" CreationDate="2019-05-30T22:34:28.070" Score="16" Body="&lt;p&gt;I compiled &lt;a href=&quot;https://github.com/eltuck/Resources#math-programming-software&quot; rel=&quot;noreferrer&quot;&gt;a list&lt;/a&gt; of solvers I could find last year. Several are COIN-OR-affiliated, but others include Mini-CP, DSP, BiqBin, OSQP, ECOS, and Dakota. (Edit - not all are dedicated LP, see comments below)&lt;/p&gt;&#xA;" OwnerUserId="56" LastEditorUserId="56" LastEditDate="2019-06-01T12:04:38.253" LastActivityDate="2019-06-01T12:04:38.253" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10" PostTypeId="2" ParentId="3" CreationDate="2019-05-30T22:35:23.640" Score="14" Body="&lt;p&gt;You need to model disjunctive constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will assume that variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is constrained to lie in&#xA; &lt;span class=&quot;math-container&quot;&gt;$L_1 \le x \le U_1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$L_2 \le x \le U_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if you have the constraint &lt;span class=&quot;math-container&quot;&gt;$2 \le |x| \le 5$&lt;/span&gt;, then choose &lt;span class=&quot;math-container&quot;&gt;$L_1 = -5$&lt;/span&gt;,  &lt;span class=&quot;math-container&quot;&gt;$U_1 = -2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$L_2 = 2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$U_2 = 5$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My solution handles a more general case than what you require, but includes your situation as a special case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Model this as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b : constrained to be binary (zero or one)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following constraints encode the disjunctive constraints based on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; being in &lt;span class=&quot;math-container&quot;&gt;$[L_1,U_1]$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$b = 0$&lt;/span&gt; and in &lt;span class=&quot;math-container&quot;&gt;$[L_2,U_2]$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$b = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x &amp;lt;= U1 + b*(U2 - U1)&#xA;x &amp;gt;= L1 + b*(L2 - L1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2019-05-31T10:04:06.220" LastActivityDate="2019-05-31T10:04:06.220" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11" PostTypeId="1" AcceptedAnswerId="32" CreationDate="2019-05-30T22:37:03.533" Score="19" ViewCount="1173" Body="&lt;p&gt;Has anyone performed a benchmark of the various stabilisation techniques in column generation? Which ones perform better for set pack/partition/cover problems like VRP? And are there theoretical reasons for their performance (e.g. tighter dual relaxation or less degeneracy)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I’m particularly interested in those that can be implemented in SCIP (e.g. don’t change objective coefficients).&lt;/p&gt;&#xA;" OwnerUserId="44" LastEditorUserId="354" LastEditDate="2021-01-26T14:12:28.000" LastActivityDate="2021-01-26T14:12:28.000" Title="Column generation stabilisation" Tags="|column-generation|benchmark|dual|scip|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="12" PostTypeId="1" CreationDate="2019-05-30T22:41:08.323" Score="26" ViewCount="1374" Body="&lt;p&gt;I am aware that Benders Decomposition is readily available in CPLEX and in SCIP; but are there any (free) solvers that provide off the shelf  stochastic programming MIP algorithms or a nice to work with programming environment ? &lt;/p&gt;&#xA;" OwnerUserId="48" LastEditorUserId="500" LastEditDate="2019-10-16T14:48:08.627" LastActivityDate="2020-05-21T12:05:15.940" Title="Stochastic programming MIP solvers" Tags="|mixed-integer-programming|solver|stochastic-programming|benders-decomposition|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="13" PostTypeId="1" CreationDate="2019-05-30T22:42:30.133" Score="12" ViewCount="1560" Body="&lt;p&gt;I am doing active research in convex maximization w.r.t. linear constraints. There are many cases which can be efficiently approximately solved, e.g., convex quadratic maximization, log-sum-exp maximization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am quite sunk in the theory but want to learn more about the applications. For example, which important applicable problems in STEM fields are formulated as convex maximization (or concave minimization) problems?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can think of Difference of Convex Functions Programming (or DC Programming), and related applications. For example, SVMs with latent variables problem reduces to this kind of optimization problem if I am not wrong. Also, there are some variants of sparse PCA methods which ultimately try to solve concave minimization problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-642-99789-1_13&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; is another source showing in ML, we can use concave minimization on a polyhedron, but this is mainly for absolute value maximization which is not a big deal today, i.e., CPLEX can solve these problems very fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I am here, open for suggestions about new problems where I can benchmark different existing convex maximization techniques!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other examples include MAX-CUT problem, economies of scale, fixed charge network flow, maximal volume sphere inscribed in a polyhedron, 0-1 loss function-based classification methods, misclassification minimization, feature selection, unlabeled data classification. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. I don't accept LP as an answer :)&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="123" LastEditDate="2019-12-01T09:45:55.117" LastActivityDate="2019-12-01T09:45:55.117" Title="Convex Maximization with Linear Constraints" Tags="|optimization|convexity|convex-optimization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="14" PostTypeId="1" CreationDate="2019-05-30T22:46:21.283" Score="8" ViewCount="404" Body="&lt;p&gt;Value iteration is one of the most commonly used methods to solve Markov decision processes. Its convergence rate obviously depends on the number of states and actions. However, the convergence rate also largely varies between different MDPs with a similar number of states/actions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there specific characteristics that imply a slow convergence? And can we re-model such systems to accelerate the convergence of value iteration? For instance, in my experience, systems with sparse transition matrices generally converge considerably slower than systems with dense transition matrices. This holds in particular if there are so-called cycles in the transition matrix.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-05-30T23:52:44.187" LastActivityDate="2019-05-31T06:59:43.073" Title="Convergence rate value iteration" Tags="|markov-decision-process|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15" PostTypeId="2" ParentId="13" CreationDate="2019-05-30T22:46:34.573" Score="7" Body="&lt;p&gt;The &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.37.1.40.12823&quot; rel=&quot;noreferrer&quot;&gt;location-inventory problem by Shen, et al.&lt;/a&gt; and &lt;a href=&quot;https://link.springer.com/article/10.1023/A:1020763400324&quot; rel=&quot;noreferrer&quot;&gt;Daskin, et al.&lt;/a&gt; has a concave minimization objective. It's related to economies of scale (which you list in your PS 2) but not exactly the same.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-05-30T22:49:31.243" LastActivityDate="2019-05-30T22:49:31.243" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16" PostTypeId="2" ParentId="13" CreationDate="2019-05-30T22:58:26.637" Score="4" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I misinterpreted the question as asking about maximization problems which are convex optimization problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a whole class of naturally occurring concave optimization problems, i.e., maximizing a convex function or minimizing a concave function, in both cases  subject to convex constraints  Linear constraints are of course a special case of convex constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider a convex optimization problem: maximize &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; subject to convex constraints, where &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is a concave performance function. The solution provides the best possible performance. For many engineering purposes, we are also concerned as to the worst possible case. That is achieved by solving its (anti-)twin problem, globally minimize &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; subject to those same convex constraints. That worst possible case problem is a concave optimization problem. And for the purpose I just stated, it is important that the global optimum be found, not a non-global local optimum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way of looking at this is if we wish to find the possible range of a convex or concave function &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;, subject to some convex constraints. We obtain lower and upper bounds as the solution to globally minimizing in one case, and globally maximizing in the other case, &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; subject to the convex constraints. The bound on one side is obtained by solving a convex optimization problem, and the bound on the other side is obtained by solving a concave optimization problem, its (anti-)twin, to a global optimum (the convex optimization problem of course has no non-global local optima). As a further special case, if the constraints consist only of lower and upper bound constraints, i.e., box constraints, this approach provides the interval evaluation of the function &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; over the box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the problems mentioned in my original answer below, except those having linear objective functions, have a concave optimization (anti-)twin, as described above. That is one heck of a lot of problems. In the case of linear objective functions, the (anti-)twin problem serves the same purpose, but is also a convex optimization problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original answer for convex optimization:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can start by reading the freely downloadable book &quot;Convex Optimization&quot; by Boyd and Vandenberghe &lt;a href=&quot;https://web.stanford.edu/~boyd/cvxbook/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://web.stanford.edu/~boyd/cvxbook/&lt;/a&gt;, particularly chapter 6-8, but you should really read the earlier chapters as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These two authors were two of the authors on an earlier paper &quot;Applications of second-order cone programming&quot; published in Linear Algebra and its Applications in 1998 &lt;a href=&quot;http://www.seas.ucla.edu/~vandenbe/publications/socp.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.seas.ucla.edu/~vandenbe/publications/socp.pdf&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a problem involving estimation or optimization of a possibly partially known covariance matrix, that leads to a semidefinite optimization problem, because a semidefinite constraint, i.e., that a matrix is symmetric positive semidefinite is the exact same thing (if and only if) as constraining a matrix to be a covariance matrix.  If the objective (minimizing a convex function or maximizing a concave function) and other constraints are convex, and the decision variables appear linearly in the semidefinite constraint, then the problem is a convex optimization problem, which in many cases can be solved efficiently by highly refined semidefinite solvers such as Mosek.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Geometric Programming can be transformed to a convex optimization problem and solved using the convex &quot;exponential cone&quot;.  See &lt;a href=&quot;https://web.stanford.edu/~boyd/papers/pdf/gp_tutorial.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://web.stanford.edu/~boyd/papers/pdf/gp_tutorial.pdf&lt;/a&gt; for some of the modeling possibilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many problems related to log, entropy, and relative entropy can also be handled as convex optimization problems via the exponential cone. Matrix log, matrix entropy, and matrix relative entropy problems can be handled by the matrix (operator) exponential cone, as for instance with CVXQUAD &lt;a href=&quot;https://github.com/hfawzi/cvxquad&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/hfawzi/cvxquad&lt;/a&gt; .  There are applications in quantum mechanics and in Operations Research (for instance, statistical model fitting and approximation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And there's much, much more.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2019-05-31T10:10:03.363" LastActivityDate="2019-05-31T10:10:03.363" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17" PostTypeId="1" CreationDate="2019-05-30T22:59:23.260" Score="17" ViewCount="740" Body="&lt;p&gt;I built my model on Python and am passing it to Gurobi to solve the problem. The presolve phase of Gurobi cuts down ~80% of the integer/binary variables and I am wondering if I should rethink my formulation.&lt;/p&gt;&#xA;" OwnerUserId="75" LastEditorUserId="75" LastEditDate="2019-06-03T20:38:38.197" LastActivityDate="2019-06-14T13:20:21.633" Title="Presolve is cutting down a lot of binary variables. Should I rethink my formulation?" Tags="|linear-programming|mixed-integer-programming|solver|modeling|gurobi|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18" PostTypeId="1" AcceptedAnswerId="22" CreationDate="2019-05-30T23:03:00.067" Score="12" ViewCount="743" Body="&lt;p&gt;A while ago I used Gurobi and I added user cuts from within a callback. However, I got the feeling that my user cuts were not directly added to the model. Is it right that Gurobi can decide to postpone adding my inequalities? If yes, is there a way to force Gurobi to immediately add them? &lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-05-30T23:30:03.313" LastActivityDate="2020-02-10T09:29:52.627" Title="When does Gurobi add cuts from callback" Tags="|gurobi|callback|branch-and-cut|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19" PostTypeId="2" ParentId="2" CreationDate="2019-05-30T23:03:50.723" Score="7" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\newcommand{\E}{\mathbb{E}}\newcommand{\R}{\mathbb{R}}$&lt;/span&gt;Define &lt;span class=&quot;math-container&quot;&gt;$\phi(x) = \E[f(x-Y)]$&lt;/span&gt; and assume that for all &lt;span class=&quot;math-container&quot;&gt;$x\in\R$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f(x-Y)$&lt;/span&gt; is measurable and integrable. Then, for &lt;span class=&quot;math-container&quot;&gt;$x,x'\in\R$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha \in [0,1]$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\phi(\alpha x + (1-\alpha)x') {}={}&amp;amp; \E[f(\alpha x + (1-\alpha)x'-Y)]&#xA;\\&#xA;{}={}&amp;amp; \E\left[f\left(\alpha x + (1-\alpha)x'- \alpha Y - (1-\alpha) Y\right)\right]&#xA;\\&#xA;{}={}&amp;amp;  \E\left[f\left(\alpha (x-Y) + (1-\alpha)(x'- Y)\right)\right]&#xA;\\&#xA;{}\leq{}&amp;amp;&#xA;\E\left[\alpha f(x-Y) + (1-\alpha)f(x'- Y)\right]&#xA;\\&#xA;{}={}&amp;amp; \alpha \E[f(x-Y)] + (1-\alpha)\E[f(x'- Y)]&#xA;\\&#xA;{}={}&amp;amp; \alpha \phi(x) + (1-\alpha)\phi(x'),&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where we have used the linearity of the expectation, the fact that if &lt;span class=&quot;math-container&quot;&gt;$Z\leq Z'$&lt;/span&gt; (a.s.) then &lt;span class=&quot;math-container&quot;&gt;$\E[Z] \leq \E[Z']$&lt;/span&gt;, and the convexity of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;. We have, therefore, shown that &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; is convex.&lt;/p&gt;&#xA;" OwnerUserId="70" LastActivityDate="2019-05-30T23:03:50.723" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20" PostTypeId="2" ParentId="17" CreationDate="2019-05-30T23:06:46.823" Score="8" Body="&lt;p&gt;Removing variables and constraints in presolve is a good thing. It can make the model smaller by reasoning that some variables will never appear in an optimal/feasible solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can think about creating a better model for your problem (e.g. tighter LP relaxation) but I wouldn’t worry that presolve is doing a good job.&lt;/p&gt;&#xA;" OwnerUserId="44" LastActivityDate="2019-05-30T23:06:46.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21" PostTypeId="1" CreationDate="2019-05-30T23:10:44.760" Score="11" ViewCount="181" Body="&lt;p&gt;We're working on a facility location problem in which it is desirable for the facilities to be laid out as close as possible to a grid. In our problem, a lattice is overlaid on the region, and the centers of the resulting cells are potential facility locations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We want the facilities to be in a regular pattern that resembles a grid. So, it is preferable to have a layout like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/foyIpm.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/foyIpm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;rather than one like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/k69N2m.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/k69N2m.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the grid does not have to be the same as the lattice; that is, the following is good too:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DjAsom.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DjAsom.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to evaluate how close a given set of points lies to a grid?&lt;/strong&gt; (i.e., the &quot;griddiness&quot; of the set of points)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, I'm looking for either a simple calculation (something involving sines and cosines...?) or an efficient algorithm that will give a score indicating how &quot;griddy&quot; a set of points is. Most likely we'll be using this within a heuristic (greedy + swap, metaheuristic, something like that), but bonus points if there's a method that could be incorporated into a linear MIP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that we don't know in advance which &quot;grid&quot; the solution will resemble -- the method should be capable of determining that both the first and the third layouts are good, and the second is bad.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-05-31T13:33:54.077" Title="How to quantify the &quot;griddiness&quot; of a set of points?" Tags="|facility-location|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22" PostTypeId="2" ParentId="18" CreationDate="2019-05-30T23:14:12.943" Score="10" Body="&lt;p&gt;Assuming you are using more than a single thread, then Gurobi performs all work you code in the callbacks with a single thread. All remaining threads process the branch and bound nodes (without doing the callbacks). When your user cuts are added is then determined by some  black box magic of Gurobi. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be specific, suppose we have 4 threads. Then, 3 of the threads are processing branch&amp;amp;bound nodes. If a particular branch&amp;amp;bound node is processed and there are valid inequalities (i.e. user cuts) to be separated, it is put in a pool of such nodes. This pool is processed by the 4th thread. Now suppose that some valid inequalities are separated by this thread for some particular branch &amp;amp; bound node. As these processes (of processing callbacks on the one hand and branch&amp;amp;bounding on the other hand) are more or less independent (which is what I presume, but please correct me if I am wrong), it is left to Gurobi to when/how to add the separated inequalities. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Luckily, they are good in that. If you want more control you can use CPLEX or if you want all control I suggest you the nice framework of SCIP :)&lt;/p&gt;&#xA;" OwnerUserId="48" LastEditorUserId="71" LastEditDate="2020-02-10T09:29:52.627" LastActivityDate="2020-02-10T09:29:52.627" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23" PostTypeId="1" AcceptedAnswerId="26" CreationDate="2019-05-30T23:16:45.183" Score="22" ViewCount="2141" Body="&lt;p&gt;When dealing with mixed-integer-programs with many symmetric solutions it can take very long until the branch-and-bound-tree search is finished because symmetric optimal solutions cannot be pruned. &#xA;What techniques can I use for a MIP with symmetries to overcome these difficulties? &lt;/p&gt;&#xA;" OwnerUserId="81" LastEditorUserId="81" LastEditDate="2019-06-04T13:10:57.983" LastActivityDate="2022-08-09T15:27:19.473" Title="How can I best handle symmetries in my MIP?" Tags="|modeling|mixed-integer-programming|symmetry|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24" PostTypeId="2" ParentId="17" CreationDate="2019-05-30T23:21:11.063" Score="15" Body="&lt;p&gt;First of all, the log output of a solver should not change your mind about the formulation you use. Most of the times, one can not imagine how such geometric spaces look like and it is hard to guess the reason for these 'cuts'. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, before formulating a MILP, I guess there are some steps one should follow. Depending on the comments/suggestions I get, I will append this list:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Check if you really need binary/integer variables. I have a feeling that almost half of the IP projects I see around can be carried out with LP. &lt;/li&gt;&#xA;&lt;li&gt;Check if the IP is a totally unimodular problem. This is also a less-known property considering how big the outcomes are after LP reformulation. &lt;a href=&quot;http://www.math.nus.edu.sg/~matsundf/MA4254_Ch2.pdf&quot; rel=&quot;noreferrer&quot;&gt;This&lt;/a&gt; can be a nice source to learn. Moreover thanks to the comments of Ryan Cory-Wright, we can add &lt;a href=&quot;https://en.wikipedia.org/wiki/Balanced_matrix&quot; rel=&quot;noreferrer&quot;&gt;balanced matrix&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Perfect_matrix&quot; rel=&quot;noreferrer&quot;&gt;perfect matrix&lt;/a&gt;. I think this can be generalized as 'perfect formulations', where more details can be found &lt;a href=&quot;https://www.win.tue.nl/~rudi/IP_1.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If you have a non-linear model, there are methods to linearize it. For example, if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are binary variables and if you have &lt;span class=&quot;math-container&quot;&gt;$xy = 0 $&lt;/span&gt;, you can formulate it as &lt;span class=&quot;math-container&quot;&gt;$x+y\leq 1$&lt;/span&gt;. There are numerous tricks, I have found such a list, but I don't see it now. If someone finds it please add it as a comment :)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2019-05-31T13:15:27.063" LastActivityDate="2019-05-31T13:15:27.063" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="25" PostTypeId="2" ParentId="12" CreationDate="2019-05-30T23:21:35.397" Score="19" Body="&lt;p&gt;If you have access to MATLAB, I can recommend &lt;a href=&quot;https://github.com/kul-forbes/risk-averse&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;Marietta&lt;/code&gt;&lt;/a&gt; (I am a developer of this toolbox), with which you can solve general risk-averse optimal control problems (a generalization of both stochastic and minimax problems), and impose risk constraints (which can serve as convex approximations of probabilistic constraints).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Larry commented above, &lt;a href=&quot;https://pyomo.readthedocs.io/en/latest/modeling_extensions/pysp.html&quot; rel=&quot;noreferrer&quot;&gt;PYOMO&lt;/a&gt; is perhaps the most popular software for stochastic programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that, you can also use any solver directly. If you problem is convex, you can use &lt;a href=&quot;http://cvxr.com/cvx/&quot; rel=&quot;noreferrer&quot;&gt;CXV&lt;/a&gt; (in MATLAB) or &lt;a href=&quot;https://www.cvxpy.org/&quot; rel=&quot;noreferrer&quot;&gt;CVXPy&lt;/a&gt; (in Python). Both are very mature software, well documented and with a strong community. CVX is not a solver, though - it is a modelling framework that allows one to interface solvers such as Gurobi (you can obtain an academic licence), &lt;a href=&quot;https://github.com/cvxgrp/scs&quot; rel=&quot;noreferrer&quot;&gt;SCS&lt;/a&gt;, &lt;a href=&quot;https://kul-forbes.github.io/scs/&quot; rel=&quot;noreferrer&quot;&gt;SuperSCS&lt;/a&gt; (free open source), IPOPT, CPLEX and many other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, you can try &lt;a href=&quot;https://yalmip.github.io/&quot; rel=&quot;noreferrer&quot;&gt;YALMIP&lt;/a&gt; in MATLAB, which, like CVX/CVX is a popular and convenient modelling framework.&lt;/p&gt;&#xA;" OwnerUserId="70" LastActivityDate="2019-05-30T23:21:35.397" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="26" PostTypeId="2" ParentId="23" CreationDate="2019-05-30T23:31:41.563" Score="18" Body="&lt;p&gt;You can add symmetry elimination constraints, like saying that the you want solutions with lower index. For example, you can say something like if &lt;span class=&quot;math-container&quot;&gt;$x_{i+1}$&lt;/span&gt; is used, then &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; must also be used. Note that you might not find a feasible solution if you’re timing out because these constraints cut off an otherwise valid solution. Perhaps you can add them after finding a feasible solution as in branch-and-cut.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also trying different branching rules. &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2006/11/1527.pdf&quot; rel=&quot;noreferrer&quot;&gt;Orbital branching&lt;/a&gt; is the one I know of. Some of these are implemented in SCIP; you just have to activate them by setting a higher priority.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best option for completely eliminating symmetry is Dantzig-Wolfe reformulation. You do the convexification and then you end up with multiple &quot;convexity constraints&quot; in the master problem. Then you sum them up, so that there is only one. My colleague Marco Lübbecke is one of the world's authority on this. He has a &lt;a href=&quot;https://pdfs.semanticscholar.org/44a1/3f8acbf28bf701d744e128f2f8b608f11c58.pdf?_ga=2.81991254.1175194910.1559262029-1083473693.1559262029&quot; rel=&quot;noreferrer&quot;&gt;great tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="44" LastEditorUserId="44" LastEditDate="2019-06-02T07:16:43.253" LastActivityDate="2019-06-02T07:16:43.253" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="28" PostTypeId="2" ParentId="18" CreationDate="2019-05-30T23:55:08.713" Score="8" Body="&lt;p&gt;While lazy constraints must be added each time a node is expanded at a branch-and-bound tree, a solver is not obligated to add user cuts at any point in time; it chooses when to add user cuts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want Gurobi to add them immediately, you are better off adding lazy constraints. See here: &lt;a href=&quot;https://orinanobworld.blogspot.com/2012/08/user-cuts-versus-lazy-constraints.html&quot; rel=&quot;noreferrer&quot;&gt;https://orinanobworld.blogspot.com/2012/08/user-cuts-versus-lazy-constraints.html&lt;/a&gt; for more details on the differences between the two approaches (note that CPLEX and Gurobi actually implement callbacks quite differently, so the blog post won't be entirely accurate for Gurobi).&lt;/p&gt;&#xA;" OwnerUserId="43" LastActivityDate="2019-05-30T23:55:08.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="29" PostTypeId="2" ParentId="2" CreationDate="2019-05-30T23:56:04.490" Score="16" Body="&lt;p&gt;Reference &quot;Convex Optimization&quot; by Boyd and Vandenberghe &lt;a href=&quot;https://web.stanford.edu/~boyd/cvxbook/&quot; rel=&quot;noreferrer&quot;&gt;https://web.stanford.edu/~boyd/cvxbook/&lt;/a&gt;, section 3.2.1, p. 79.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;These properties extend to infinite sums and integrals. For example if&#xA;  &lt;span class=&quot;math-container&quot;&gt;$f(x, y)$&lt;/span&gt; is convex in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$y\in A$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$w(y) \ge 0$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$y\in A$&lt;/span&gt;,&#xA;  then the function &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; defined as &lt;span class=&quot;math-container&quot;&gt;$$g(x) = \int_A w(y)f(x, y)\, dy$$&lt;/span&gt; is&#xA;  convex in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; (provided the integral exists).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Of course, this extends to Lebesgue-Stieltjes integrals (not mentioned in the referenced book), so should cover any expectation.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2019-05-31T10:09:26.900" LastActivityDate="2019-05-31T10:09:26.900" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="30" PostTypeId="1" CreationDate="2019-05-31T00:39:16.923" Score="10" ViewCount="596" Body="&lt;p&gt;What are the advantages of using the generic callback compared to the old user/lazy callbacks within a branch-and-cut framework?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IBM states on its website that the major benefit of the new generic callback is that it allows for dynamic search strategies. However, most researchers still solve their MIPs with a branch-and-cut framework and then this dynamic search is not possible anyway (correct me if I am wrong). On top of that, the new callback provides a lower degree of control on the branch-and-bound/branch-and-cut process. IBM rightly states that this low-level control is often not required, however for academic purposes, it is good to have some control, for instance to more fairly test the effectiveness of new valid inequalities or branching rules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This lets me wonder whether the generic callback brings other considerable advantages besides the dynamic search strategy. And are those new features worth the effort to re-implement already working algorithms?&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-05-31T00:44:31.313" LastActivityDate="2019-06-03T21:43:22.257" Title="Advantages generic cplex callback within branch-and-cut" Tags="|cplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="31" PostTypeId="2" ParentId="30" CreationDate="2019-05-31T00:56:11.410" Score="7" Body="&lt;p&gt;Edit: one advantage of generic callbacks is that they can be run without turning off dynamic search, while legacy callbacks (such as the old user/lazy callbacks) cannot be run with dynamic search, and therefore generic callbacks can sometimes (but not always) be faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as you point out, there are two disadvantages to using generic callbacks:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Reduced low-level control.  &lt;/li&gt;&#xA;&lt;li&gt;Generic callbacks need to be thread-safe, which can be challenging to implement.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Sometimes the benefits of multi-threading are worthwhile and sometimes they aren't; it depends on the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more reading on generic vs legacy callbacks, see here: &lt;a href=&quot;https://orinanobworld.blogspot.com/2017/11/cplex-128-generic-callbacks.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://orinanobworld.blogspot.com/2017/11/cplex-128-generic-callbacks.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="43" LastEditorUserId="43" LastEditDate="2019-06-03T21:43:22.257" LastActivityDate="2019-06-03T21:43:22.257" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="32" PostTypeId="2" ParentId="11" CreationDate="2019-05-31T02:18:30.823" Score="17" Body="&lt;p&gt;Stabilization methods are tricky. Dual optimal inequalities are you best chance to obtain significant speed ups. Basically they prevent a bunch of useless dual values by exploiting problem-specific structures to impose constraints on the dual space. They reduce the number of pricing iterations without compromising the complexity. Unfortunately, they are problem specific and cannot be easily generalized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When DOIs are not an option, you can impose artificial constraints in the dual space or penalties for deviation from a sought target (center). For this to converge, you need to assure that the constraints are incrementally relaxed and the penalties reduced. The trade off is not always positive and the impact is very sensitive to the underlying implementation. Typical examples of this type of strategy are bundle methods or bounding box methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a recent paper published in JOC by Pessoa et al, a simpler strategy is proposed that relies at a much lesser extent on specific implementations and parameters fine tuning. You simply use a dual center to compute an average between the current duals and the center. The master problem does not need to be modified and the strategy usually leads to significant gains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My advice would be: try to see if DOIs can be adapted to your specific problem (unlikely for VRPs). Otherwise, use Pessoa et al method (simple and effective). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Pessoa at al 2018 @ JOC =&gt; &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/ijoc.2017.0784&quot; rel=&quot;noreferrer&quot;&gt;https://pubsonline.informs.org/doi/10.1287/ijoc.2017.0784&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2019-05-31T16:12:38.263" LastActivityDate="2019-05-31T16:12:38.263" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="33" PostTypeId="1" AcceptedAnswerId="34" CreationDate="2019-05-31T02:36:30.117" Score="32" ViewCount="18571" Body="&lt;p&gt;Suppose we have a binary or continuous variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, a binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, and a constant &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, and we want to enforce a relationship like &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x \gtreqless b$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$y = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How can we write this using one or more linear constraints?&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-13T16:47:50.457" LastActivityDate="2019-10-14T09:58:51.947" Title="In an integer program, how I can force a binary variable to equal 1 if some condition holds?" Tags="|mixed-integer-programming|linear-programming|constraint|integer-programming|logical-constraints|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="34" PostTypeId="2" ParentId="33" CreationDate="2019-05-31T02:36:30.117" Score="37" Body="&lt;p&gt;&lt;strong&gt;If &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is binary:&lt;/strong&gt; Then the &quot;if&quot; condition really means either &quot;&lt;span class=&quot;math-container&quot;&gt;$x = 0$&lt;/span&gt;&quot; or &quot;&lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt;&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;To enforce &quot;if &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;&quot;&lt;/em&gt;: use&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y \ge 1-x.$$&lt;/span&gt;&#xA;&lt;em&gt;To enforce &quot;if &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;&quot;&lt;/em&gt;: use&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y \ge x.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to require that &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt; &lt;em&gt;if and only if&lt;/em&gt; the condition holds, then replace the &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt;s above with &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is continuous:&lt;/strong&gt; In this case, numerical inaccuracy might produce errors, so be prepared for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; to be set incorrectly if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is &lt;em&gt;close to&lt;/em&gt; but on the “wrong” side of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. To avoid this, you can increase or decrease &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; a little bit to provide some buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;To enforce &quot;if &lt;span class=&quot;math-container&quot;&gt;$x &amp;lt; b$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;&quot;&lt;/em&gt;: &#xA;&lt;span class=&quot;math-container&quot;&gt;$$b - x \le My,$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a large constant. The logic is that if &lt;span class=&quot;math-container&quot;&gt;$b - x &amp;gt; 0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; must equal 1, and otherwise it may equal 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;To enforce &quot;if &lt;span class=&quot;math-container&quot;&gt;$x &amp;gt; b$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;&quot;&lt;/em&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x - b \le My,$$&lt;/span&gt;&#xA;with similar logic as above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;To enforce &quot;if &lt;span class=&quot;math-container&quot;&gt;$x = b$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;&quot;&lt;/em&gt;: This one is tricky. I'm not sure my approach is the easiest. (Anyone have a better solution?) We really can't check for &lt;span class=&quot;math-container&quot;&gt;$x=b$&lt;/span&gt;, but we can check for &lt;span class=&quot;math-container&quot;&gt;$b-\delta \le x \le b+\delta$&lt;/span&gt; for some small &lt;span class=&quot;math-container&quot;&gt;$\delta &amp;gt; 0$&lt;/span&gt;. To do this, we introduce two new binary decision variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; be a binary variable that equals 1 if &lt;span class=&quot;math-container&quot;&gt;$x &amp;gt; b - \delta$&lt;/span&gt;, equals 0 if &lt;span class=&quot;math-container&quot;&gt;$x &amp;lt; b - \delta$&lt;/span&gt;, and could equal either if &lt;span class=&quot;math-container&quot;&gt;$x = b - \delta$&lt;/span&gt;. &#xA;Enforce this definition by adding the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{2}&#xA;Mz_1 &amp;amp; \ge x - b + \delta\tag1 \\&#xA;M(1-z_1) &amp;amp; \ge b - x - \delta\tag2 &#xA;\end{alignat}&lt;/span&gt;&#xA;The logic is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x &amp;gt; b - \delta$&lt;/span&gt;, then (1) forces &lt;span class=&quot;math-container&quot;&gt;$z_1=1$&lt;/span&gt; and (2) has no effect.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x &amp;lt; b - \delta$&lt;/span&gt;, then (2) forces &lt;span class=&quot;math-container&quot;&gt;$z_1=0$&lt;/span&gt; and (1) has no effect.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x = b - \delta$&lt;/span&gt;, then (1) and (2) have no effect; &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; could equal either 0 or 1.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Next, introduce a second binary variable &lt;span class=&quot;math-container&quot;&gt;$z_2$&lt;/span&gt;, which equals 1 if &lt;span class=&quot;math-container&quot;&gt;$x &amp;lt; b + \delta$&lt;/span&gt;, equals 0 if &lt;span class=&quot;math-container&quot;&gt;$x &amp;gt; b + \delta$&lt;/span&gt;, and could equal either if &lt;span class=&quot;math-container&quot;&gt;$x = b + \delta$&lt;/span&gt;. Introduce the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{alignat}{2}&#xA;Mz_2 &amp;amp; \ge b - x + \delta\tag3 \\&#xA;M(1-z_2) &amp;amp; \ge x - b - \delta\tag4&#xA;\end{alignat}$$&lt;/span&gt;&#xA;The logic is similar:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x &amp;lt; b + \delta$&lt;/span&gt;, then (3) forces &lt;span class=&quot;math-container&quot;&gt;$z_2=1$&lt;/span&gt; and (4) has no effect.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x &amp;gt; b + \delta$&lt;/span&gt;, then (4) forces &lt;span class=&quot;math-container&quot;&gt;$z_2=0$&lt;/span&gt; and (3) has no effect.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x = b + \delta$&lt;/span&gt;, then (3) and (4) have no effect; &lt;span class=&quot;math-container&quot;&gt;$z_2$&lt;/span&gt; could equal either 0 or 1.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;From constraints (1)-(4), we can say that if &lt;span class=&quot;math-container&quot;&gt;$z_1=z_2=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$b - \delta \le x \le b + \delta$&lt;/span&gt;. Therefore, we can enforce &quot;if &lt;span class=&quot;math-container&quot;&gt;$b - \delta \le x \le b + \delta$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;&quot; using:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y \ge z_1 + z_2 - 1.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: If your model is relatively large, i.e., it takes a non-negligible amount of time to solve, then you need to be careful with big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;-type formulations. In particular, you want &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to be as small as possible while still enforcing the logic of the constraints above.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="123" LastEditDate="2019-10-14T09:58:51.947" LastActivityDate="2019-10-14T09:58:51.947" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="35" PostTypeId="2" ParentId="33" CreationDate="2019-05-31T04:11:30.587" Score="12" Body="&lt;p&gt;Rather than linearising the logical constraint, I would try the logical constraints built in a solver. Gurobi and SCIP both have indicator constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My colleague works with these a lot and he’s finding the indicator constraints in Gurobi perform worse than big-M. He’s in contact with the Gurobi developers so I might be able to get more info if there’s interest.&lt;/p&gt;&#xA;" OwnerUserId="44" LastActivityDate="2019-05-31T04:11:30.587" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="36" PostTypeId="1" AcceptedAnswerId="54" CreationDate="2019-05-31T05:45:14.817" Score="11" ViewCount="200" Body="&lt;p&gt;I have been trying to implement a variant of LNS on a graph for TSP. One of the ways that I can define a neighborhood for TSP is to find &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-shortest path between two nodes. But the choice of these nodes are random. I have two questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Are there better ways to define neighborhood?&lt;/li&gt;&#xA;&lt;li&gt;Is there a way to find a promising neighborhood?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="115" LastEditorUserId="38" LastEditDate="2019-06-03T19:04:17.153" LastActivityDate="2019-06-03T19:30:13.020" Title="Neigbourhoods in Large Neighbourhood Search (LNS) algorithms" Tags="|heuristics|algorithms|graphs|traveling-salesman|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="37" PostTypeId="1" AcceptedAnswerId="38" CreationDate="2019-05-31T06:14:26.337" Score="37" ViewCount="15789" Body="&lt;p&gt;Suppose we have two binary variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. How can we linearize the product &lt;span class=&quot;math-container&quot;&gt;$xy$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2020-03-28T12:33:17.537" LastActivityDate="2022-07-28T04:09:05.093" Title="How to linearize the product of two binary variables?" Tags="|linear-programming|linearization|binary-variable|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="38" PostTypeId="2" ParentId="37" CreationDate="2019-05-31T06:14:26.337" Score="56" Body="&lt;p&gt;This scenario can be linearized by introducing a new binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; which represents the value of &lt;span class=&quot;math-container&quot;&gt;$x y$&lt;/span&gt;. Notice that the product of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; can only be non-zero if both of them equal one, thus &lt;span class=&quot;math-container&quot;&gt;$x = 0$&lt;/span&gt; and/or &lt;span class=&quot;math-container&quot;&gt;$y = 0$&lt;/span&gt; implies that &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; must equal zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$z \leq x\\z \leq y$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing left is to force &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to equal one if the product of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; equals one, which only happens if both of them equal one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ z \geq x + y - 1. $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The general case with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; binary variables&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method can also directly be applied to the general case where we have the product of multiple binary variables. Suppose we have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; binary variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and we want to linearize the product&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\prod_{i=1}^n x_i.&#xA;$$&lt;/span&gt;&#xA;Then you can introduce a new binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; that represents the value of this product and model it by introducing the following constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;z &amp;amp;\leq x_i \quad \text{ for } i = 1, \ldots, n.\\&#xA;z &amp;amp;\geq \sum_{i=1}^n x_i - (n-1).&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Further reading&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned by &lt;a href=&quot;https://or.stackexchange.com/users/52/4er&quot;&gt;4er&lt;/a&gt; in a &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables/38#comment282_38&quot;&gt;comment&lt;/a&gt; below this answer: &lt;em&gt;&quot;for quadratic functions of many binary variables, you can often do better than to linearize each product of variables separately&quot;&lt;/em&gt;. Some suggested references are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;F. Glover and E. Woolsey (1973). &lt;a href=&quot;https://doi.org/10.1287/opre.21.1.156&quot; rel=&quot;noreferrer&quot;&gt;Further reduction of zero-one polynomial programming problems to zero-one linear programming problems&lt;/a&gt;. &lt;em&gt;Operations Research&lt;/em&gt; 21 156-161. &lt;/li&gt;&#xA;&lt;li&gt;F. Glover (1975). &lt;a href=&quot;https://doi.org/10.1287/mnsc.22.4.455&quot; rel=&quot;noreferrer&quot;&gt;Improved Linear Integer Programming Formulations of Nonlinear Integer Problems&lt;/a&gt;. &lt;em&gt;Management Science&lt;/em&gt; 22 455-460. &lt;/li&gt;&#xA;&lt;li&gt;M. Oral and O. Kettani (1992). &lt;a href=&quot;https://doi.org/10.1287/opre.40.1.S109&quot; rel=&quot;noreferrer&quot;&gt;A linearization procedure for quadratic and cubic mixed-integer problems&lt;/a&gt;. &lt;em&gt;Operations Research&lt;/em&gt; 40 S109-S116. &lt;/li&gt;&#xA;&lt;li&gt;W.P. Adams and R.J. Forrester (2005). &lt;a href=&quot;https://doi.org/10.1016/j.orl.2004.05.001&quot; rel=&quot;noreferrer&quot;&gt;A simple recipe for concise mixed 0-1 linearizations&lt;/a&gt;. &lt;em&gt;Operations Research Letters&lt;/em&gt; 33 55-61.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="71" LastEditorUserId="123" LastEditDate="2019-07-24T06:52:20.810" LastActivityDate="2019-07-24T06:52:20.810" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="39" PostTypeId="1" AcceptedAnswerId="40" CreationDate="2019-05-31T06:37:13.197" Score="36" ViewCount="11174" Body="&lt;p&gt;Suppose we have a binary variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and a non-negative continuous variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.  How can we linearize the product &lt;span class=&quot;math-container&quot;&gt;$x y$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2020-04-01T12:55:25.770" LastActivityDate="2022-12-28T13:03:56.290" Title="How to linearize the product of a binary and a non-negative continuous variable?" Tags="|linear-programming|linearization|binary-variable|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="40" PostTypeId="2" ParentId="39" CreationDate="2019-05-31T06:37:13.197" Score="38" Body="&lt;p&gt;Suppose we can give a finite upper bound for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; called &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. Then this constraint can easily be linearized by using the so-called big &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; method. We introduce a new variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; that should take the same value as the product &lt;span class=&quot;math-container&quot;&gt;$x y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Notice that the product which we model by &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; equals zero if &lt;span class=&quot;math-container&quot;&gt;$x = 0$&lt;/span&gt; but &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; can take any value between &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x = 1$&lt;/span&gt;. We can model this by using &lt;span class=&quot;math-container&quot;&gt;$z \leq x M$&lt;/span&gt;. Next, the product is always non-negative and smaller than &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, thus &lt;span class=&quot;math-container&quot;&gt;$z\geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z \leq y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It is left to force &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to equal &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in case &lt;span class=&quot;math-container&quot;&gt;$x = 1$&lt;/span&gt; which we obtain with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z \geq y - (1 - x)M. $$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2021-01-23T11:11:13.513" LastActivityDate="2021-01-23T11:11:13.513" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="41" PostTypeId="2" ParentId="14" CreationDate="2019-05-31T06:59:43.073" Score="2" Body="&lt;p&gt;I will answer on the basis of one particular case of MDPs. There have been a few recent articles that extensively discuss the issues of the diversification of MDPs and introduce a new model known as the MDP-DIV (Markov Decision Process for Diversifying). For that I refer you to &lt;a href=&quot;http://www.bigdatalab.ac.cn/~junxu/publications/SIGIR2017_MDPDIV.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Xia &lt;em&gt;et al.&lt;/em&gt; (2017)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is identified that the main causes for slow convergence are data scarcity/sparse transition matrices as you have pointed out, and a large action space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two new approaches to accelerate the convergence rate are detailed in &lt;a href=&quot;https://arxiv.org/pdf/1802.08401.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Liu &lt;em&gt;et al.&lt;/em&gt; (2018)&lt;/a&gt;. Here, I will quote the relevant parts of the abstract.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The MDP-DIV-kNN method adopts a&#xA;  &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; nearest neighbor strategy, i.e.,&#xA;  discarding the&#xA;  &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; nearest neighbors of the recently-selected action (document), to reduce the diversification searching space. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The MDP-DIVNTN employs a pre-trained diversification neural tensor network (NTNDIV) as the evaluation model, and combines the results with MDP to&#xA;  produce the final ranking solution. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The experiment results demonstrate&#xA;  that the two proposed methods indeed accelerate the convergence rate of&#xA;  the MDP-DIV, which is 3x faster, while the accuracies produced barely&#xA;  degrade, or even are better.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;References&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&#xA;[1]  Xia, L., Xu, J., Lan, Y., Guo, J., Zeng, W., Cheng, X. (2017). Adapting markov decision&#xA;process for search result diversification. pp. 535–544. SIGIR ’17, ACM, New York,&#xA;NY, USA.&#xA;&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&#xA;[2] Liu, F., Tang, R., Li, X., Ye, Y., Guo, H., He, X. (2018). Novel Approaches to Accelerating the&#xA;Convergence Rate of Markov Decision Process&#xA;for Search Result Diversification. &lt;a href=&quot;https://arxiv.org/pdf/1802.08401.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/1802.08401.pdf&lt;/a&gt;.&#xA;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-05-31T06:59:43.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="42" PostTypeId="2" ParentId="12" CreationDate="2019-05-31T07:18:05.057" Score="13" Body="&lt;p&gt;&lt;strong&gt;&lt;em&gt;Disclaimer&lt;/em&gt;&lt;/strong&gt;: I'm not a researcher in the area of stochastic programming software. But as a researcher in the area of stochastic programming, I've put some time into looking for stochastic programming software. So, the following is my own two cents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Dealing with stochastic programming models, usually, you reformulate the problem as a deterministic equivalent problem (DEP). Then, two scenarios might happen. If your original deterministic problem is not too large and/or you don't have to consider too many scenarios, you can solve the DEP directly using a powerful LP or MIP solver. If that is not the case, you go for stochastic programming algorithms (e.g., L-shaped method, PHA, etc.) that make perfect use of special structures of stochastic programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following the above explanation, generic implementations of stochastic programming algorithms can be classified into two classes of DEP_Generator (i.e., only generates the DEP for a stochastic programming model declaration and then pass it to a general solver without using the special structure of stochastic programs) and DEP_Generator+Algorithms (i.e., generates the DEP and then solves it using a specialized algorithm).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK, these two classes of solvers are usually implemented for stochastic &lt;strong&gt;&lt;em&gt;linear&lt;/em&gt;&lt;/strong&gt; programs. The only three solvers for &quot;stochastic integer programs&quot; of which I'm aware are &lt;a href=&quot;https://www.gams.com/latest/docs/S_DE.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;DE&lt;/a&gt; and &lt;a href=&quot;https://www.gams.com/latest/docs/S_DECIS.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;DECIS&lt;/a&gt; both available in &lt;a href=&quot;https://www.gams.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GAMS&lt;/a&gt; and &lt;a href=&quot;http://www.research-projects.uzh.ch/p70.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;SLP-IOR&lt;/a&gt; (I think SLP-IOR just covers models with simple integer recourse). I think the reason that we don't see &quot;many&quot; generic implementations of stochastic integer programming algorithms is that they are harder-to-solve problems on which generic algorithms do not necessarily perform well. To make these algorithms work, you usually need some knowledge about the problem structure, which is something problem dependent. In addition, the solution of stochastic integer programs usually requires more complex algorithms (e.g., branch and cut or Lagrangian duals).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case you are interested in stochastic &lt;strong&gt;&lt;em&gt;linear&lt;/em&gt;&lt;/strong&gt; programming solver, you might find &lt;a href=&quot;https://projects.coin-or.org/Smi&quot; rel=&quot;nofollow noreferrer&quot;&gt;SMI&lt;/a&gt; as an example of DEP_Generators and &lt;a href=&quot;https://www.mathworks.com/matlabcentral/fileexchange/59212-fast&quot; rel=&quot;nofollow noreferrer&quot;&gt;FAST&lt;/a&gt; and &lt;a href=&quot;https://link.springer.com/article/10.1007/BF01580872&quot; rel=&quot;nofollow noreferrer&quot;&gt;MSLiP&lt;/a&gt; as examples of DEP_Generator+Algorithms.&lt;/p&gt;&#xA;" OwnerUserId="119" LastEditorUserId="279" LastEditDate="2020-05-21T12:05:15.940" LastActivityDate="2020-05-21T12:05:15.940" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="43" PostTypeId="1" CreationDate="2019-05-31T08:18:07.683" Score="17" ViewCount="4823" Body="&lt;p&gt;I am solving two-stage optimization problems in the form of &#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x \in X}\min_{y \in Y} f(x,y),$$&lt;/span&gt;&#xA; where &lt;span class=&quot;math-container&quot;&gt;$f(x,y)$&lt;/span&gt; is the solution of a mixed integer linear program (MIP). As the constraints of the MIP link the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; elements, it is clear that we cannot apply the classic minimax theorem to interchange the minimization and the maximization. (Actually, I am solving a trilevel optimization problem and interchanging the minimization and the maximization will be very helpful). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We all know that the minimax theorem states that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x \in X}\min_{y \in Y} f(x,y) \leq \min_{y \in Y}\max_{x \in X} f(x,y)$$&lt;/span&gt; for any function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; mapping the &lt;span class=&quot;math-container&quot;&gt;$X,Y$&lt;/span&gt; space to a real set (assuming the max and min can be attained).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is the following: In the above sketched case, this equation will not be strict (i.e., it won't hold with equality). However, are there any particular useful results on how large this gap might be, both worst-case as well as numerically? If it is not too big (in general), it might suffice as a bound on the larger (and not relevant for this question) trilevel optimization problem. &lt;/p&gt;&#xA;" OwnerUserId="48" LastEditorUserId="123" LastEditDate="2020-01-18T20:04:07.920" LastActivityDate="2020-04-25T06:25:53.993" Title="The difference between max-min and min-max" Tags="|mixed-integer-programming|optimization|error-bounds|minimax|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="44" PostTypeId="2" ParentId="1" CreationDate="2019-05-31T08:24:52.140" Score="13" Body="&lt;p&gt;I had the same doubt, and I arrived at the conclusion that the formula given in the textbooks is, at best, a practical approximation. The lead-time demand, in fact, is &lt;strong&gt;not&lt;/strong&gt; normally distributed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; denote the lead-time and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; denote the demand per unit of time. Working under the assumption that both of them are normally distributed, then the random variable &lt;span class=&quot;math-container&quot;&gt;$L \cdot d$&lt;/span&gt; can be written as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$L \cdot d = \frac{1}{4} (L + d)^2 - \frac{1}{4} (L - d)^2$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we further assume that &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; are independent (indeed, one could argue that the lead time of a supplier can be independent from the consumption rate of a product), then both &lt;span class=&quot;math-container&quot;&gt;$L + d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L - d$&lt;/span&gt; are normally distributed.&#xA;In this case, then, &lt;span class=&quot;math-container&quot;&gt;$L \cdot d$&lt;/span&gt; is a linear combination of two &lt;span class=&quot;math-container&quot;&gt;$\chi^2$&lt;/span&gt; random variables, and therefore it's &lt;strong&gt;not&lt;/strong&gt; a normal random variable! Furthermore, there is no known closed-formula expression for the distribution of a linear combination of &lt;span class=&quot;math-container&quot;&gt;$\chi^2$&lt;/span&gt; random variables, even though the distribution &lt;a href=&quot;https://arxiv.org/abs/1208.2691&quot; rel=&quot;noreferrer&quot;&gt;can be approximated efficiently&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update after Larry's answer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below should be a Python code to check that &lt;span class=&quot;math-container&quot;&gt;$L \cdot d$&lt;/span&gt; is not normal (assumes that both &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; are continuous):&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;from scipy import stats&#xA;import matplotlib.pyplot as plt&#xA;&#xA;samples = 10000&#xA;lead_times = np.random.normal(10, 2, samples)&#xA;demands = np.random.normal(100, 20, samples)&#xA;ltd = lead_times * demands&#xA;&#xA;stats.normaltest(ltd)&#xA;&#xA;plt.hist(ltd, bins = 100);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get a very low &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-value from &lt;code&gt;normaltest&lt;/code&gt; and, &lt;a href=&quot;https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.normaltest.html&quot; rel=&quot;noreferrer&quot;&gt;according to documentation&lt;/a&gt;, this is a D'Agostino-Pearson test with null hypothesis &quot;The data comes from a normal distribution&quot;, so a low &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-value allows me to &lt;em&gt;reject&lt;/em&gt; the null hypothesis.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2019-06-11T15:15:19.013" LastActivityDate="2019-06-11T15:15:19.013" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="45" PostTypeId="1" CreationDate="2019-05-31T08:38:41.223" Score="23" ViewCount="1035" Body="&lt;p&gt;I want to solve the Asymmetric TSP for a large-scale problem for an industrial application where the company cannot buy a commercial software license. For their applications, it is very important to find good solutions within a short computation time. What are the main algorithms (either approximation, randomized, heuristic, dynamic programming, etc.) that are able to find good solutions as fast as possible? And, the same problem arises for the vehicle routing problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although metaheuristic algorithms are powerful algorithms, they are not guaranteed to find good solutions and they may converge to different solutions in each replication of the algorithm.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="38" LastEditDate="2019-06-01T17:51:33.560" LastActivityDate="2019-12-10T21:01:25.687" Title="Solving ATSP problem for large-scale problem" Tags="|optimization|traveling-salesman|vehicle-routing|" AnswerCount="5" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="46" PostTypeId="2" ParentId="45" CreationDate="2019-05-31T08:44:04.457" Score="19" Body="&lt;p&gt;If you are interested in solving the TSP, the &lt;a href=&quot;http://www.math.uwaterloo.ca/tsp/concorde/downloads/downloads.htm&quot; rel=&quot;noreferrer&quot;&gt;Concorde TSP solver&lt;/a&gt; is a very powerful and easy-to-use tool. I do not know what the licensing options are for commercial applications, but for research purposes it is free and easy to use (if you are familiar with C/C++)&lt;/p&gt;&#xA;" OwnerUserId="48" LastActivityDate="2019-05-31T08:44:04.457" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="47" PostTypeId="2" ParentId="45" CreationDate="2019-05-31T08:59:21.687" Score="17" Body="&lt;p&gt;If you cannot use Concorde as suggested by Albert, I'd suggest you look for an implementation of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Lin%E2%80%93Kernighan_heuristic&quot; rel=&quot;noreferrer&quot;&gt;Lin-Kerninghan-Heuristic&lt;/a&gt; (which is also included in Concorde). It iterates between 2-opt and 3-opt to find a good solution quickly.&#xA;If you are interested in the best solution or need to know a bound on the best possible solution, then Concorde is the way to go. Gurobi also has an example code that solves the problem (but is only free for academic purposes).&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="36" LastEditDate="2019-12-08T19:04:04.830" LastActivityDate="2019-12-08T19:04:04.830" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="48" PostTypeId="1" CreationDate="2019-05-31T09:55:15.800" Score="12" ViewCount="194" Body="&lt;p&gt;Which sources are out there that provide reliable and fast MDP solvers? I prefer that the library is callable from C++ but other languages are fine too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is indeed an abundance of repositories on github that at first seem to be appropriate for this task. However, the ones I found so far were either buggy, super slow, or overly optimized for a too specific model (such as all my own implementations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question is similar as the question&#xA;&lt;a href=&quot;https://or.stackexchange.com/q/4&quot; title=&quot;open source LP solvers&quot;&gt;open source LP solvers&lt;/a&gt; but now for MDP solvers.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="56" LastEditDate="2019-06-01T10:52:02.633" LastActivityDate="2019-06-01T10:52:02.633" Title="Open source Markov decision process solvers" Tags="|markov-decision-process|online-resources|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="49" PostTypeId="1" AcceptedAnswerId="55" CreationDate="2019-05-31T10:07:07.690" Score="16" ViewCount="887" Body="&lt;p&gt;As part of my research in statistics, I recently stumbled upon &lt;a href=&quot;https://iase-web.org/documents/papers/icots7/C341.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; which provides an operational perspective into linear models.&lt;/p&gt;&#xA;&lt;p&gt;In simple linear regression, &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;quadratic programming&lt;/a&gt; can be used to solve the problem where for least squares, the objective is &lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{ll}&#xA;\min &amp;amp; Q(\beta) = (Y-X\beta)'(Y-X\beta)\\&#xA;\text{s.t.} &amp;amp; A\beta\ge C \\&#xA;&amp;amp; \beta \ge 0&#xA;\end{array}$$&lt;/span&gt; The notation should be fairly self-explanatory.&lt;/p&gt;&#xA;&lt;p&gt;However, for &lt;a href=&quot;https://en.wikipedia.org/wiki/Nonlinear_regression&quot; rel=&quot;nofollow noreferrer&quot;&gt;nonlinear regression&lt;/a&gt;, things are more complicated. For example, the Michaelis-Menten model is multivariate, given by &lt;span class=&quot;math-container&quot;&gt;$f(x,\beta)=\beta_1 x/(\beta_2+x)$&lt;/span&gt;. It is possible to transform any nonlinear model to a linear one, but there is an element of risk as the errors are altered.&lt;/p&gt;&#xA;&lt;p&gt;Is there any literature that provides a procedure on how to tackle this type of regression?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Wang, D. Q., Wu, B. (2006). Teaching Linear Models Based on Operations Research in Statistical Education. &lt;em&gt;ICOTS-7&lt;/em&gt;. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2021-07-03T12:34:22.480" LastActivityDate="2021-07-03T12:34:22.480" Title="How to model nonlinear regression?" Tags="|optimization|reference-request|quadratic-programming|regression|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="50" PostTypeId="2" ParentId="21" CreationDate="2019-05-31T10:16:48.227" Score="8" Body="&lt;p&gt;An idea could be to evaluate what is the smallest number of straight lines required to cover your locations. You would expect that aligned points are covered with much fewer straight lines than non-aligned points. Moreover, this metric would work for any type of alignment, not just the one that follows the lattice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://sci-hub.tw/10.1007/11758471_4&quot; rel=&quot;noreferrer&quot;&gt;This paper&lt;/a&gt; (&lt;em&gt;Covering a set of points with a minimum number of lines&lt;/em&gt;, by Grantson and Levcopoulos) seems to suggest that the evaluation of such a term in the objective function should not be too expensive.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2019-05-31T10:16:48.227" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="51" PostTypeId="2" ParentId="49" CreationDate="2019-05-31T10:45:24.697" Score="8" Body="&lt;p&gt;From a pure optimization point of view you can say that it is possible to transform a linear fractional problem into a linear one (see for example &lt;a href=&quot;https://en.wikipedia.org/wiki/Linear-fractional_programming#Transformation_to_a_linear_program&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;). In your case, this seems not feasible, as you have a product of variables in the numerator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nonlinear regression problems are usually solved by employing continuous optimization algorithms such as &lt;a href=&quot;https://en.wikipedia.org/wiki/Gradient_descent&quot; rel=&quot;noreferrer&quot;&gt;gradient descent&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Newton%27s_method_in_optimization&quot; rel=&quot;noreferrer&quot;&gt;Newton's method&lt;/a&gt; and their friends.&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="112" LastEditDate="2019-05-31T14:47:59.513" LastActivityDate="2019-05-31T14:47:59.513" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="52" PostTypeId="1" AcceptedAnswerId="53" CreationDate="2019-05-31T11:33:27.430" Score="16" ViewCount="674" Body="&lt;p&gt;I am working on a branch-and-cut algorithm, and I have spent quite some effort into improving the branching decisions that are made by commercial solvers, such as CPLEX and Gurobi. However, it was never successful: the standard branching by Cplex and Gurobi combined with the slight subtleties you can choose (focus lower bound, focus upper bound etc.) were always better than my own custom-made branching rules. My problem does not inherit any symmetry or whatsoever. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now is that not very surprising, as the folks at CPLEX and Gurobi probably have spend years on researching efficient branching decisions. However, I am quite curious why my custom-made branching rules are never more effective (although they seem very smart!). To that end, I am curious what branching decisions are taken by these commercial solvers. Is there, somewhere, an overview of branching rules used by these solvers? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Main reason for asking this question is to find some justification to spend hours into designing problem-specific branching rules, or even beter, to quickly be able to decide to not spend time into designing problem-specific branching rules as they would probably not lead to a significant improvement of computational performance.&lt;/p&gt;&#xA;" OwnerUserId="48" LastEditorUserId="48" LastEditDate="2019-05-31T11:41:56.393" LastActivityDate="2019-06-03T07:27:41.860" Title="Branching rules in commercial MIP solvers" Tags="|mixed-integer-programming|branch-and-cut|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="53" PostTypeId="2" ParentId="52" CreationDate="2019-05-31T11:37:57.643" Score="16" Body="&lt;p&gt;Tobias Achterberg's &lt;a href=&quot;https://opus4.kobv.de/opus4-zib/frontdoor/index/index/docId/1112&quot; rel=&quot;noreferrer&quot;&gt;thesis&lt;/a&gt; includes a review of MIP solver technology from around 2009, including branching decisions and node selection.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-05-31T11:37:57.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="54" PostTypeId="2" ParentId="36" CreationDate="2019-05-31T12:05:08.087" Score="11" Body="&lt;p&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0305054805003023&quot; rel=&quot;noreferrer&quot;&gt;This&lt;/a&gt; paper by Pisinger and Ropke is particularly useful when working on (A)LNS, and provides great guidance and an overview of operators/neighborhoods. I would suggest &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S037722171300800X&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt; by Vidal et al. for more genetic search inspired aspects.&lt;/p&gt;&#xA;" OwnerUserId="48" LastActivityDate="2019-05-31T12:05:08.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="55" PostTypeId="2" ParentId="49" CreationDate="2019-05-31T12:24:39.797" Score="10" Body="&lt;p&gt;NEOS has &lt;a href=&quot;https://neos-guide.org/content/nonlinear-least-squares&quot; rel=&quot;noreferrer&quot;&gt;a nice web page&lt;/a&gt; on nonlinear least squares. It contains several classic (i.e., not so new, but still good) references for nonlinear least squares.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a very nice introduction to the mathematics of nonlinear least squares, and the algorithms to solve them, &quot;&lt;a href=&quot;https://www8.cs.umu.se/kurser/5DA001/HT07/lectures/lsq-handouts&quot; rel=&quot;noreferrer&quot;&gt;Non-linear least squares problems: The Gauss-Newton method&quot; by Niclas Börlin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are indeed specialized algorithms for nonlinear least squares, such as Levenberg-Marquardt, and Gauss-Newton (a.k.a. Iterative Linear Least Squares), which exploit the special structure in least squares problems Generally, they only provide an advantage vs. more general nonlinear optimization algorithms when the residuals at the optimum are &quot;small&quot;. If the residuals at the optimum are not small, the nonlinear least squares algorithms lose their advantage, and if not implemented well, may even fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the advances in general nonlinear optimization algorithms and software over the last several decades, I think that in most cases, specialized nonlinear least squares algorithms usually don't have much merit, and high quality more general software, which also is more flexible in terms of allowing constraints, can, and should be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, note that (semi-) rigorous global optimizers, such as BARON, can find the globally optimal solution to non-convex (nonlinear regression) problems, at least if the problem isn't too large (in terms of number of parameters to be estimated).&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="112" LastEditDate="2019-05-31T14:28:42.227" LastActivityDate="2019-05-31T14:28:42.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="56" PostTypeId="1" AcceptedAnswerId="80" CreationDate="2019-05-31T13:08:47.647" Score="18" ViewCount="2136" Body="&lt;p&gt;I know that Markov Chains and Markov Decision Processes have been studied in the OR community too. But, I was wondering what is the relationship of Operations Research (OR) and Reinforcement Learning (RL)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does any other sub-field of OR (e.g., integer programming, convex optimization) actually study RL? If so, is there any reference that explains the connection? &lt;/p&gt;&#xA;" OwnerUserId="41" LastEditorUserId="41" LastEditDate="2019-06-02T22:32:03.703" LastActivityDate="2019-06-02T22:32:03.703" Title="What is the connection of Operations Research and Reinforcement Learning?" Tags="|optimization|reinforcement-learning|machine-learning|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="57" PostTypeId="1" CreationDate="2019-05-31T13:19:46.260" Score="14" ViewCount="1648" Body="&lt;p&gt;Is there a single crisp and accessible reference which covers how to generate Mixed Integer Programming formulations to linearize products, handle logical constraints and disjunctive constraints, do Big M, et. in optimization problems?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any pitfalls to beware of when using Big M to accomplish any of these?&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-06-01T15:54:25.303" LastActivityDate="2024-03-19T11:06:37.237" Title="Single reference for Mixed Integer Programming formulations to linearize, handle logical constraints and disjunctive constraints, do Big M, etc?" Tags="|mixed-integer-programming|linearization|reference-request|big-m|logical-constraints|" AnswerCount="4" CommentCount="28" ContentLicense="CC BY-SA 4.0" />
  <row Id="58" PostTypeId="2" ParentId="57" CreationDate="2019-05-31T13:19:46.260" Score="17" Body="&lt;p&gt;Here is a nice, succinct, and easy to understand reference for how to do all this and more. Answers to many future questions can be handled by referencing the appropriate section number in this document and then addressing any particular difficulties or concerns the questioner may have.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;FICO MIP formulations and linearizations Quick reference&lt;/strong&gt; at &lt;a href=&quot;https://www.msi-jp.com/xpress/learning/square/10-mipformref.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.msi-jp.com/xpress/learning/square/10-mipformref.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Introductory references which are more tutorial but less comprehensive&lt;/strong&gt;, which may help people better understand the previously listed reference.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://ocw.mit.edu/courses/sloan-school-of-management/15-053-optimization-methods-in-management-science-spring-2013/lecture-notes/MIT15_053S13_lec11.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ocw.mit.edu/courses/sloan-school-of-management/15-053-optimization-methods-in-management-science-spring-2013/lecture-notes/MIT15_053S13_lec11.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://ocw.mit.edu/courses/sloan-school-of-management/15-053-optimization-methods-in-management-science-spring-2013/tutorials/MIT15_053S13_tut09.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ocw.mit.edu/courses/sloan-school-of-management/15-053-optimization-methods-in-management-science-spring-2013/tutorials/MIT15_053S13_tut09.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://yalmip.github.io/tutorial/logicprogramming/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Logics and integer-programming representations&lt;/a&gt; - &lt;strong&gt;YALMIP&lt;/strong&gt; background on how common mixed-integer representable functions and logic can be modeled, which is helpful even if YALMIP is not used. Includes all the usual stuff, plus general integer, sort, number of non-zeros, and much more.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Many of these formulations can be handled under the hood by modern optimization modeling systems.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;For instance, indicator constraints in CPLEX&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/indicator_constr/01_indicators_title_synopsis.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/indicator_constr/01_indicators_title_synopsis.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/indicator_constr/07_best_prac.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/indicator_constr/07_best_prac.html&lt;/a&gt; ,&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Note that per &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/indicator_constr/06_restrictions.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/indicator_constr/06_restrictions.html&lt;/a&gt; in CPLEX, &amp;quot;The constraint must be linear; a quadratic constraint is not allowed to have an indicator constraint.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Note that per my updated answer at &lt;a href=&quot;https://or.stackexchange.com/questions/231/when-to-use-indicator-constraints-versus-big-m-approaches-in-solving-mixed-int/259#259&quot;&gt;When to use indicator constraints versus big-M approaches in solving (mixed-)integer programs&lt;/a&gt;, &lt;strong&gt;Indicator Constraints in CPLEX are immune from the big M trickle flow&lt;/strong&gt; issue mentioned later in this answer under &amp;quot;Be careful with choice of Big M, and its relation to solver integrality tolerance&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Gurobi General Constraints&lt;/strong&gt;: &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/constraints.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/8.1/refman/constraints.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;YALMIP&lt;/strong&gt; &amp;quot;implies&amp;quot; automates modeling of some logical constraints: &lt;a href=&quot;https://yalmip.github.io/command/implies/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://yalmip.github.io/command/implies/&lt;/a&gt;&#xA;Explicit finite lower and upper bounds on all involved variables are required so that a Big M formulation can be derived under the hood by YALMIP to handle the implies.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Be careful with the choice of Big M, and its relation to solver integrality tolerance.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Keep in mind, as the YALMIP developer Johan Lofberg has stated, that Big M is misnamed. It should be called just big enough M. Excessively large M can result in weak formulations which degrade (slow down) the solution process. In extreme cases (but not uncommon for &amp;quot;amateurs&amp;quot;), as a result of solver constraint satisfaction tolerance, an excessively large value of M can cause the solver to produce a solution that violates the logic constraint as intended. That is because integer (including binary) constraints are only satisfied to within an integrality tolerance, which typically is 1e-5 or 1e-6.&lt;/p&gt;&#xA;&lt;p&gt;Further details are provided by @prubin at &lt;a href=&quot;https://orinanobworld.blogspot.com/2018/04/big-m-and-integrality-tolerance.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://orinanobworld.blogspot.com/2018/04/big-m-and-integrality-tolerance.html&lt;/a&gt;. IBM CPLEX documentation refers to this as &lt;strong&gt;&amp;quot;trickle flow&amp;quot;&lt;/strong&gt; here: &lt;a href=&quot;https://www-01.ibm.com/support/docview.wss?uid=swg21399984&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www-01.ibm.com/support/docview.wss?uid=swg21399984&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If M needs to be so big that it would cause the logic constraint to not be satisfied as intended, the integrality tolerance should be made smaller, and verified to be small enough. Proper scaling of the problem can in many cases ameliorate such difficulties and allow for a not very large M.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="-1" LastEditDate="2024-03-19T11:06:37.237" LastActivityDate="2024-03-19T11:06:37.237" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="59" PostTypeId="5" CreationDate="2019-05-31T13:24:35.387" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-05-31T13:24:35.387" LastActivityDate="2019-05-31T13:24:35.387" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="60" PostTypeId="4" CreationDate="2019-05-31T13:24:35.387" Score="0" Body="For questions related to problems that optimize (i.e., minimize or maximize) a linear objective subject to linear constraints." OwnerUserId="71" LastEditorUserId="38" LastEditDate="2019-06-04T16:13:49.893" LastActivityDate="2019-06-04T16:13:49.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="61" PostTypeId="1" CreationDate="2019-05-31T13:32:52.407" Score="38" ViewCount="1305" Body="&lt;p&gt;In recent years, a huge number of scholars in AI and ML community are using Python to develop their algorithms and then publishing their papers and codes in GitHub. This provides an opportunity for others to work on that paper and develop more efficient algorithms so fast and as we are witnessing, this community is progressing rapidly. However, this is not common in OR/MS community and a student should learn how to code an algorithm from scratch which is too time-consuming. Moreover, I am wondering why there are not video course on OR, coding algorithms and etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am willing to hear others' opinion and if it possible that scholars share the source of their codes (either heuristic, metaheuristic, B&amp;amp;B, B&amp;amp;P, B&amp;amp;C, and etc.).&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="214" LastEditDate="2019-06-13T23:48:29.263" LastActivityDate="2019-10-15T17:54:23.753" Title="Why is the programming code of many algorithms not public in the OR community?" Tags="|optimization|open-source|" AnswerCount="8" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="62" PostTypeId="2" ParentId="56" CreationDate="2019-05-31T13:33:35.667" Score="11" Body="&lt;p&gt;RL (and Machine Learning in general) often use specialized forms of continuous optimization problems that enable one to use elegant solving techniques (e.g. training/learning on the GPU or even special hardware (TPU and friends)). See &lt;a href=&quot;https://arxiv.org/abs/1901.05331&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; for a nice overview of the underlying optimization problems in Machine Learning and Deep Learning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @albert-schroteboer already wrote in the comments, there are some activities to bring ML/DL/RL and combinatorial problems together. There have been some efforts with graph neural nets to tackle some problems traditionally solved via combinatorial algorithms. See &lt;a href=&quot;https://arxiv.org/abs/1811.06128&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; for an overview and some more papers &lt;a href=&quot;https://arxiv.org/abs/1611.09940&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; (TSP, Knapsack), &lt;a href=&quot;https://arxiv.org/abs/1803.08475&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; (VRP variants), &lt;a href=&quot;https://arxiv.org/abs/1704.01665&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; (MaxCut, TSP) or &lt;a href=&quot;https://arxiv.org/abs/1706.07450&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; (Quadratic Assignment). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that ML/DL/RL algorithms usually do not give a guarantee for the solution quality whereas traditional combinatorial algorithms might have this property (sometimes it is inherently in the algorithms, sometimes extra effort is taken to prove optimality). For large problem instances when the traditional algorithms take a long time to produce a solution or cases where a &quot;good&quot; (but not necessary optimal) solution is sufficient, these new approaches might be a good addition to the other algorithms.&lt;/p&gt;&#xA;" OwnerUserId="137" LastActivityDate="2019-05-31T13:33:35.667" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="63" PostTypeId="2" ParentId="21" CreationDate="2019-05-31T13:33:54.077" Score="6" Body="&lt;p&gt;This is interesting. Perhaps you could find the linear transformation to the lattice that has the minimum deviation from integrality. This would &quot;standardize&quot; your grid in some sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That might look something like the following (haven't tried it):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sets: (&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;: locations; &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;: dimension of data)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Variables: (&lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;: transformation multipliers, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;: projected point; &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;: closest integer point, &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;: deviation from integer point)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Data: (&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;: your original points)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Formulation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{ll}&#xA;\min_{a,y,z,\epsilon} &amp;amp; \sum_{m\in M}\sum_{n\in N}\epsilon^{m+}_n+\epsilon^{m-}_n\\&#xA;\text{subject to} &amp;amp; a_nx_n^{m} = y_n^{m}, &amp;amp; \forall m \in M, n\in N\\&#xA;&amp;amp; y_n^{m} + \epsilon_n^{m+}-\epsilon_n^{m-} = z_n^m, &amp;amp; \forall m \in M, n\in N\\&#xA;&amp;amp;z_n^m \in \mathbb{Z}, &amp;amp; \forall m\in M, n \in N\\&#xA;&amp;amp; a_n \in \mathbb{R}, &amp;amp; \forall n \in N\\&#xA;&amp;amp; y_n^m \in \mathbb{R}, &amp;amp;\forall m\in M, n\in N \\&#xA;&amp;amp;\epsilon_n^{m+} ,\epsilon_n^{m-} \geq0, &amp;amp; \forall m\in M, n \in N&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The objective function (OF) of a given set of points (the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;'s) could be compared to the OF with a different set of points (&lt;span class=&quot;math-container&quot;&gt;$x_{alt}$&lt;/span&gt;) as long as the dimensions are the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One downside is that this wouldn't handle &quot;holes&quot; in the grid well - if your data is equally spaced but in an L, this would give the same result as having them all in a square. Not sure if that matters for your application. Similarly, this wouldn't penalize locations that are increasing in distance from each other in constant increments (e.g., in one dimension a spacing of 1 2 4 8 would be the same as 1 2 3 4). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also this is a mixed-integer LP when the points are fixed, but if they're variables as well, this becomes nonlinear.&lt;/p&gt;&#xA;" OwnerUserId="56" LastActivityDate="2019-05-31T13:33:54.077" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="65" PostTypeId="2" ParentId="61" CreationDate="2019-05-31T13:42:18.113" Score="10" Body="&lt;p&gt;Probably because a lot of us are mathematicians and are ashamed of our code quality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have just released the &lt;a href=&quot;https://bitbucket.org/ed-lam/bcp-mapf/&quot; rel=&quot;noreferrer&quot;&gt;code to BCP&lt;/a&gt;, a poorly-named (don't blame me) algorithm for solving the multi-agent pathfinding problem using branch-and-cut-and-price. It is substantially faster than the previous state-of-the-art algorithm CBSH-RM. The paper and experimental results are at my website &lt;a href=&quot;https://ed-lam.com&quot; rel=&quot;noreferrer&quot;&gt;ed-lam.com&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="44" LastEditorUserId="44" LastEditDate="2019-06-03T04:49:06.623" LastActivityDate="2019-06-03T04:49:06.623" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="66" PostTypeId="2" ParentId="61" CreationDate="2019-05-31T13:47:40.377" Score="13" Body="&lt;p&gt;Good question! I would say:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;OR is older, way older than AI and ML&lt;/li&gt;&#xA;&lt;li&gt;OR people don't come from a programming background, and the main focus is usually having efficient maths rather than efficient coding (but I don't deny that OR people also write awesome codes :) )&lt;/li&gt;&#xA;&lt;li&gt;OR is collected around mathematics, if one is convinced with the theorem, there is no reason to implement the code and `observe it'. The fields using OR (financial engineering, industrial engineering, etc) usually share codes with the papers.&lt;/li&gt;&#xA;&lt;li&gt;It is well known that OR is &lt;strong&gt;interpretable&lt;/strong&gt; while AI&amp;amp;ML are effective but black-box. Therefore, in an interpretable field, I don't think the codes make too much sense to share. In AI&amp;amp;ML, you need to convince yourself that an algorithm works very well, and you need to see the results. But in OR papers, theorems are more like &quot;this algorithm gives a &lt;span class=&quot;math-container&quot;&gt;$1+\epsilon$&lt;/span&gt;- approximation, and the proof is here&quot;&lt;/li&gt;&#xA;&lt;li&gt;One of my professors told me: &quot;Codes are for computers, not for humans&quot;. I can not think of any good reason to read a code to understand the theorems. Therefore, the only reason for such a demand would be to use these codes directly.&lt;/li&gt;&#xA;&lt;li&gt;This may be my subjective opinion, but people who use GitHub actively benefit from the version tracking of this software. In AI&amp;amp;ML projects, the efficiency can be improved continuously and GitHub can be used actively. But, in OR one should formulate the mathematical model before coding it. Therefore, the only version is the first working code if you think about the optimization problems. This is why on Git-Hub you can not find too many OR projects.&lt;/li&gt;&#xA;&lt;li&gt;There are &lt;strong&gt;many&lt;/strong&gt; options in solvers. If one shares her code, people will be like &quot;why are you not tuning this option, why are you using for loops when you can define a vector, etc. etc.&quot;. There is peer pressure due to the fact that there are lots of programming environments and many solvers. Also in OR, the same model can be implemented in  Julia-Python-Matlab-C++-R-and so on. However, in CS-related fields, usually, packages are working in specific programming languages. This is again due to the fact that AI-ML fields are centered around computer programming while OR is centered around mathematical programming.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2019-05-31T14:02:42.717" LastActivityDate="2019-05-31T14:02:42.717" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="67" PostTypeId="5" CreationDate="2019-05-31T13:58:01.150" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-05-31T13:58:01.150" LastActivityDate="2019-05-31T13:58:01.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="68" PostTypeId="4" CreationDate="2019-05-31T13:58:01.150" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-05-31T13:58:01.150" LastActivityDate="2019-05-31T13:58:01.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="69" PostTypeId="2" ParentId="61" CreationDate="2019-05-31T14:04:08.430" Score="15" Body="&lt;p&gt;I agree with @independentvariable. &#xA;What might be added is that many researchers actually do publish (and what's maybe even more valuable: maintain) their code, if they think it is useful. Take a look at &lt;a href=&quot;https://www.coin-or.org/&quot; rel=&quot;noreferrer&quot;&gt;COIN-OR&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess one of the differences is that in OR, people tend to publish full-blown general purpose software (often fit for industrial usage) rather than a small piece of code that is just useful to replicate the results of a single paper.&lt;/p&gt;&#xA;" OwnerUserId="47" LastEditorUserId="123" LastEditDate="2019-10-14T10:05:57.430" LastActivityDate="2019-10-14T10:05:57.430" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="70" PostTypeId="2" ParentId="61" CreationDate="2019-05-31T14:14:56.087" Score="34" Body="&lt;p&gt;While it's true that much more O.R. code could - and probably &lt;em&gt;should&lt;/em&gt;, when public money paid for its development - be public, this is changing and nowadays it's increasingly more common to share the sources (e.g., on &lt;a href=&quot;https://github.com&quot; rel=&quot;noreferrer&quot;&gt;GitHub&lt;/a&gt;) and create a corresponding referenceable artefact (e.g., on &lt;a href=&quot;https://zenodo.org&quot; rel=&quot;noreferrer&quot;&gt;Zenodo&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the main reason that hinders sharing is &lt;strong&gt;poor code quality&lt;/strong&gt;.&#xA;Indeed, I had to work with code by colleagues and I wanted to carve my eyes out; surely, this feeling was reciprocated by colleagues who worked with my code.&#xA;It is sometimes easier to just re-implement some algorithm than try to understand, debug, or extend someone else's code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is, then, code quality so low? Why do we have script-like write-only one-use code, rather than more curated libraries, as is the case in the ML community?&#xA;Here are a few plausible reasons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Few OR scientists are computer scientists and even fewer are software engineers. We don't have this training in our curricula. Not everyone collaborates on large software projects; rather, we mostly write for ourselves. We use our own conventions and guidelines, often based in myths and second-hand factoids, rather than in truth and measurable metrics. Worse, we perpetuate these legends teaching them to our students.&lt;/li&gt;&#xA;&lt;li&gt;We see code as a disposable tool, a temporary detour from the interesting scientific juice, a distraction from the publishable goodies, a necessary evil we have to cope with as quickly as possible. For many of us code is just a way to prove that some conjecture was true (&quot;&lt;em&gt;Doing X and Y should produce better results than the current literature&lt;/em&gt;&quot;). We see limited future use for our code, even though we are often proven wrong in this respect.&lt;/li&gt;&#xA;&lt;li&gt;Even if we saw clearly the value of reusable, maintainable, well-documented, publicly-shared code, the &lt;em&gt;publish-or-perish&lt;/em&gt; culture dominant in modern academia gives all the wrong incentives: every hour of time I spend to increase code quality, I could have spent working on one more publication and getting tenure.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I feel the last point is the most important: sharing code or producing widely used software libraries gives almost no benefit, and a lot of costs.&#xA;Until it will be considered as a service to the community and it will be taken into account for promotions and hiring, very few O.R. scientists will devote time to producing maintainable, well-structured, clear, performant, bug-free code which is worth being shared.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2019-05-31T14:14:56.087" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="71" PostTypeId="2" ParentId="4" CreationDate="2019-05-31T14:31:21.150" Score="5" Body="&lt;p&gt;Another open-source software is the &lt;a href=&quot;https://en.wikipedia.org/wiki/GNU_Linear_Programming_Kit&quot; rel=&quot;noreferrer&quot;&gt;GNU Linear Programming Kit (GLPK)&lt;/a&gt; and can be downloaded &lt;a href=&quot;https://sourceforge.net/projects/winglpk/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Description (from Wikipedia):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The GNU Linear Programming Kit is a software package intended for solving large-scale linear programming, mixed integer programming, and other related problems. It is a set of routines written in ANSI C and organized in the form of a callable library.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-05-31T14:31:21.150" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="72" PostTypeId="5" CreationDate="2019-05-31T15:20:45.080" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-05-31T15:20:45.080" LastActivityDate="2019-05-31T15:20:45.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="73" PostTypeId="4" CreationDate="2019-05-31T15:20:45.080" Score="0" Body="For questions about mathematical optimization problems involving binary or general integer variables." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-03T19:03:53.123" LastActivityDate="2019-06-03T19:03:53.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="74" PostTypeId="5" CreationDate="2019-05-31T15:25:51.127" Score="0" Body="&lt;p&gt;Inventory theory concerns the management of the inventory of (usually physical) goods. Typically, inventory problems involve a mathematical description of the expected cost of the system, for given values of the inventory control parameters; and then an attempt to optimize the system by choosing the optimal control parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Common inventory models include the economic order quantity (EOQ) model, the newsvendor model, and the &lt;span class=&quot;math-container&quot;&gt;$(r,Q)$&lt;/span&gt; optimization model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In some cases one seeks an optimal inventory &lt;em&gt;policy&lt;/em&gt;, which is a simple rule that governs the inventory decisions. For example, in a &lt;em&gt;base-stock policy&lt;/em&gt;, one always places an order whose size is sufficient to bring the inventory position up to a fixed number, called the base-stock level.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-03T19:03:06.483" LastActivityDate="2019-06-03T19:03:06.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="75" PostTypeId="4" CreationDate="2019-05-31T15:25:51.127" Score="0" Body="For questions about mathematical models and algorithms for optimizing inventories. " OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-03T19:02:56.023" LastActivityDate="2019-06-03T19:02:56.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="76" PostTypeId="1" AcceptedAnswerId="77" CreationDate="2019-05-31T15:33:03.453" Score="12" ViewCount="3220" Body="&lt;p&gt;Suppose we have the constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_1x_1 + \cdots + a_nx_n \gtreqless b,$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; are constants and &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are decision variables. Suppose also that we want the constraint to hold if &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a binary decision variable), and we don’t care whether it holds if &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can we accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="123" LastEditDate="2019-10-14T10:05:05.857" LastActivityDate="2019-10-14T10:05:05.857" Title="In an integer program, how can I “activate” a constraint only if a decision variable has a certain value?" Tags="|mixed-integer-programming|modeling|integer-programming|constraint|logical-constraints|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="77" PostTypeId="2" ParentId="76" CreationDate="2019-05-31T15:33:03.453" Score="15" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; be a new parameter (constant) that equals a large number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Greater-than-or-equal-to constraints:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The constraint is &lt;span class=&quot;math-container&quot;&gt;$a_1x_1 + \cdots + a_nx_n \ge b$&lt;/span&gt;. Rewrite it as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_1x_1 + \cdots + a_nx_n \ge b - M(1-y).$$&lt;/span&gt;&#xA;Then, if &lt;span class=&quot;math-container&quot;&gt;$y = 1$&lt;/span&gt;, the constraint is active, and if &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, it has no effect since the right-hand side is very negative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If all of the &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; are nonnegative, you can instead use&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_1x_1 + \cdots + a_nx_n \ge b(1-y),$$&lt;/span&gt;&#xA;which is tighter.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Less-than-or-equal-to constraints:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The constraint is  &lt;span class=&quot;math-container&quot;&gt;$a_1x_1 + \cdots + a_nx_n \le b$&lt;/span&gt;. Rewrite it as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_1x_1 + \cdots + a_nx_n \le b + M(1-y).$$&lt;/span&gt;&#xA;Then, if &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;, the constraint is active, and if &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, it has no effect since the RHS is very large.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Equality constraints:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The constraint is   &lt;span class=&quot;math-container&quot;&gt;$a_1x_1 + \cdots + a_nx_n = b$&lt;/span&gt;.. Rewrite it as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align*}&#xA;a_1x_1 + \cdots + a_nx_n &amp;amp; \le b + M(1-y) \\&#xA;a_1x_1 + \cdots + a_nx_n &amp;amp; \ge b - M(1-y)&#xA;\end{align*}$$&lt;/span&gt;&#xA;Then, if &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;, the equality constraint is active, and if &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, the constraints have no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: If your model is relatively large, i.e., it takes a non-negligible amount of time to solve, then you need to be careful with big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;-type formulations. In particular, you want &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to be as small as possible while still enforcing the logic of the constraints above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related: &lt;a href=&quot;https://or.stackexchange.com/questions/33/in-an-integer-program-how-i-can-force-a-binary-variable-to-equal-1-if-some-cond&quot;&gt;In an integer program, how I can force a binary variable to equal 1 if some condition holds?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="123" LastEditDate="2019-10-14T10:04:30.480" LastActivityDate="2019-10-14T10:04:30.480" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="79" PostTypeId="1" CreationDate="2019-05-31T16:50:10.480" Score="11" ViewCount="468" Body="&lt;p&gt;I am looking for (sources of) convex quadratic programming instances with linear constraints. I am open for both continuous and mixed integer problems, but do not want randomly generated instances.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware of &lt;a href=&quot;http://qplib.zib.de/index.html&quot; rel=&quot;noreferrer&quot;&gt;QPLIB&lt;/a&gt;, a collection of various types of convex/noncovex, integer/continuous, linearly constrained/quadratically constrained quadratic programmes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also aware of the &lt;a href=&quot;http://www.cuter.rl.ac.uk/Problems/marmes.shtml&quot; rel=&quot;noreferrer&quot;&gt;Maros and Meszaros test set&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="47" LastEditorUserId="5" LastEditDate="2019-05-31T16:59:30.060" LastActivityDate="2019-05-31T23:01:19.683" Title="Where can I find test instances for convex quadratic programming?" Tags="|quadratic-programming|test-instances|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="80" PostTypeId="2" ParentId="56" CreationDate="2019-05-31T17:02:48.220" Score="17" Body="&lt;p&gt;In the operations research community, many study &lt;em&gt;dynamic programming&lt;/em&gt; models and solution approaches. Since many interesting dynamic programming problems attempt to model information uncertainty over time, the term &lt;em&gt;stochastic dynamic programming&lt;/em&gt; is sometimes used. The &lt;em&gt;Markov decision process&lt;/em&gt; model is an example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finding optimal policies to many dynamic programming models is often very difficult computationally. Therefore, a subfield known as &lt;strong&gt;&lt;em&gt;approximate dynamic programming&lt;/em&gt;&lt;/strong&gt; emerged. The focus of this subfield in general is developing approaches for finding near-optimal policies. From my viewpoint, there is not too much difference between reinforcement learning and ADP. The classic two-volume text on dynamic programming by Bertsekas (1st edition was 1995, currently on 4th edition 2017/2012) is a good first introduction that may help you see the connection. &lt;/p&gt;&#xA;" OwnerUserId="105" LastActivityDate="2019-05-31T17:02:48.220" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="81" PostTypeId="2" ParentId="79" CreationDate="2019-05-31T17:35:31.850" Score="8" Body="&lt;p&gt;You can reformulate Quadratic Programs as Second Order Conic Programs (SOCPs). Therefore, you can use many conic benchmark libraries and filter SOCPs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;a href=&quot;http://cblib.zib.de/&quot; rel=&quot;noreferrer&quot;&gt;Conic Benchmark Library&lt;/a&gt; can be a good start!&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2019-05-31T17:35:31.850" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="82" PostTypeId="5" CreationDate="2019-05-31T18:48:18.553" Score="0" Body="&lt;p&gt;Quadratic programming is the procedure of finding the maxima/minima of a multivariate quadratic function subject to linear constraints. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; constraints, the &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;objective&lt;/a&gt; is find an &lt;span class=&quot;math-container&quot;&gt;$n\times1$&lt;/span&gt; vector &lt;span class=&quot;math-container&quot;&gt;$\bf x$&lt;/span&gt; that minimizes &lt;span class=&quot;math-container&quot;&gt;$\frac12{\bf x}^TQ{\bf x}+{\bf c}^T{\bf x}$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$A{\bf x}\preceq{\bf b}$&lt;/span&gt; where, in the real numbers,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bf c$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$n\times1$&lt;/span&gt; vector&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bf b$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$m\times1$&lt;/span&gt; vector&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$n\times n$&lt;/span&gt; symmetric matrix&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$m\times n$&lt;/span&gt; matrix.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Common methods to solve them include the Augmented Lagrangian and Conjugate Gradients.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-06-03T19:03:45.880" LastActivityDate="2019-06-03T19:03:45.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="83" PostTypeId="4" CreationDate="2019-05-31T18:48:18.553" Score="0" Body="For questions on quadratic programming, methods to solve them and related solvers.  Use this tag along with (optimization)." OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-06-03T19:03:49.573" LastActivityDate="2019-06-03T19:03:49.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="84" PostTypeId="2" ParentId="4" CreationDate="2019-05-31T19:20:53.690" Score="10" Body="&lt;p&gt;Just to add another, easily google-able, resource: Wikipedia, more or less, &quot;maintains&quot; a &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_optimization_software&quot; rel=&quot;noreferrer&quot;&gt;&quot;List of optimization software&quot;&lt;/a&gt; -- which includes the &lt;em&gt;super handy&lt;/em&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Template:Mathematical_optimization_software&quot; rel=&quot;noreferrer&quot;&gt;&quot;Mathematical optimization software&quot;&lt;/a&gt; template I -- disclaimer: shameless self-plug -- started 6 years ago (and never bothered to curate) [the latter also includes references to alternat(iv)e taxonomies in its &lt;a href=&quot;https://en.wikipedia.org/wiki/Template_talk:Mathematical_optimization_software&quot; rel=&quot;noreferrer&quot;&gt;&quot;talk&quot;&lt;/a&gt; section].&lt;/p&gt;&#xA;" OwnerUserId="138" LastEditorUserId="138" LastEditDate="2019-05-31T19:26:50.700" LastActivityDate="2019-05-31T19:26:50.700" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="85" PostTypeId="1" AcceptedAnswerId="100" CreationDate="2019-05-31T19:21:08.097" Score="19" ViewCount="394" Body="&lt;p&gt;Many problem areas (like vehicle routing, hub location, ...) have certain &quot;classic&quot; benchmark instances that are used heavily in the literature to compare the numerical strength of optimisation algorithms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While this increases comparability of different algorithms, it also increases the danger of tailoring the algorithms (subconsciously, often) to the benchmark instances. A read a lot of hub location papers, and most of them test on the Australian post data (besides a few other sets, like the CAB set). This means that you cannot know whether the numerical results would still hold on instances with a different structure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can be done to solve this problem? I am looking for approaches from the literature that try to reduce this &quot;overfitting&quot; problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make this clear: This is not meant as a rant or open discussion, but as a question for concrete, usable approaches.&lt;/p&gt;&#xA;" OwnerUserId="50" LastEditorUserId="50" LastEditDate="2019-06-06T08:43:36.900" LastActivityDate="2019-06-06T08:43:36.900" Title="The curse of the benchmark instances" Tags="|benchmark|experimental-optimization|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="86" PostTypeId="5" CreationDate="2019-05-31T19:35:06.407" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-05-31T19:35:06.407" LastActivityDate="2019-05-31T19:35:06.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="87" PostTypeId="4" CreationDate="2019-05-31T19:35:06.407" Score="0" Body="For questions related to techniques for converting nonlinear expressions in optimization models into equivalent (or approximately equivalent) linear ones." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-03T19:03:37.303" LastActivityDate="2019-06-03T19:03:37.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="88" PostTypeId="5" CreationDate="2019-05-31T19:36:09.280" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-05-31T19:36:09.280" LastActivityDate="2019-05-31T19:36:09.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="89" PostTypeId="4" CreationDate="2019-05-31T19:36:09.280" Score="0" Body="For questions about mathematical optimization problems involving both continuous and binary or general integer variables." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-03T19:03:11.663" LastActivityDate="2019-06-03T19:03:11.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="90" PostTypeId="5" CreationDate="2019-05-31T19:37:05.377" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-05-31T19:37:05.377" LastActivityDate="2019-05-31T19:37:05.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="91" PostTypeId="4" CreationDate="2019-05-31T19:37:05.377" Score="0" Body="For questions related to algorithms expected to produce good solutions, with no guarantee of optimality, in relatively short computation time." OwnerUserId="38" LastEditorUserId="123" LastEditDate="2019-12-08T19:52:02.710" LastActivityDate="2019-12-08T19:52:02.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="92" PostTypeId="5" CreationDate="2019-05-31T19:38:12.757" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-05-31T19:38:12.757" LastActivityDate="2019-05-31T19:38:12.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="93" PostTypeId="4" CreationDate="2019-05-31T19:38:12.757" Score="0" Body="For questions related to the process of converting a real-world problem into a mathematical model. Can include questions related to linearization, logical constraints, tightness of formulations, and so on." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-03T19:03:21.477" LastActivityDate="2019-06-03T19:03:21.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="94" PostTypeId="5" CreationDate="2019-05-31T19:38:54.160" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-05-31T19:38:54.160" LastActivityDate="2019-05-31T19:38:54.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="95" PostTypeId="4" CreationDate="2019-05-31T19:38:54.160" Score="0" Body="For questions related to optimization problems for choosing the optimal locations of facilities such as warehouses, factories, fire stations, etc. " OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-03T19:04:11.730" LastActivityDate="2019-06-03T19:04:11.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="96" PostTypeId="1" AcceptedAnswerId="103" CreationDate="2019-05-31T20:57:56.760" Score="7" ViewCount="4374" Body="&lt;p&gt;What is the difference between the two common optimization models for electricity systems, optimal power flow (OPF) and economic dispatch (ED)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've heard people say that ED is just a multi-period version of OPF. I've also heard people say that OPF includes power flow constraints while ED only includes constraints on the total generation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone clarify?&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="112" LastEditDate="2019-06-01T16:50:07.643" LastActivityDate="2020-05-16T12:01:32.260" Title="Optimal power flow vs. economic dispatch" Tags="|optimization|energy|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="97" PostTypeId="2" ParentId="85" CreationDate="2019-05-31T21:36:57.603" Score="16" Body="&lt;p&gt;There are multiple aspects to this topic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What can be done by testset compilers to prevent finetuning?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For one, testset creators are usually not including many very similar problems into the benchmark. For example, &lt;a href=&quot;https://miplib.zib.de/Selection_Methodology.html&quot; rel=&quot;noreferrer&quot;&gt;MIPLIB2017&lt;/a&gt; was specifically compiled in a way to ensure diversity. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The design paper for the &lt;a href=&quot;https://www.cs.bham.ac.uk/~chengr/CEC_Comp_on_MaOO/2018/CEC2018-MaOO-Tech-Report.pdf&quot; rel=&quot;noreferrer&quot;&gt;CEC2018&lt;/a&gt; benchmarks specifically states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The 15 benchmark problems are with diverse properties which cover a good representation of various real-world scenarios, such as being multimodal, disconnected,degenerate, and/or nonseparable, and having an irregular Pareto front shape, a complex Paretoset or a large number of decision variables [...]. Our aim is to promote the research of many-objective optimization via suggesting a set of benchmark functions with a good representation of various real-world scenarios&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In one or more of the CEC challenges, all benchmark functions had some random components to them (scaling, rotation, ...) to prevent finetuning. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What can be done as a algorithm designer to ensure I am not biased towards certain implicit structure in the testset?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The biggest pitfall in my opinion is NOT relying on testsets: often researchers will create random instances to test their algorithm. These however usually have a lot more structure than one might think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure to select a testset that does not just include one type of instances. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is your software designed to solve general traveling salesman instances? Make sure the testset includes both symmetric and asymmetric instances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are you designing a convex quadratic programming solver? Make sure the testset has both sparse and dense instances, ill-conditioned matrices, non-trivial Eigenvalue structure, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure your algorithm makes no assumption about special cases. &lt;/p&gt;&#xA;" OwnerUserId="47" LastEditorUserId="47" LastEditDate="2019-05-31T22:21:03.730" LastActivityDate="2019-05-31T22:21:03.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="98" PostTypeId="1" AcceptedAnswerId="122" CreationDate="2019-05-31T23:00:19.807" Score="14" ViewCount="237" Body="&lt;p&gt;Often times I have this issue. For example, I need to have a non-negative coefficient, say &lt;span class=&quot;math-container&quot;&gt;$c_0$&lt;/span&gt;, in my optimization problem (otherwise the problem is not convex). Moreover, to obtain this &lt;span class=&quot;math-container&quot;&gt;$c_0$&lt;/span&gt; I analytically solve a problem in MATLAB. This analytic solution also satisfies &lt;span class=&quot;math-container&quot;&gt;$c_0 \geq 0$&lt;/span&gt; but returns &lt;span class=&quot;math-container&quot;&gt;$c_0 = 10^{-5}$&lt;/span&gt; and assumes this is zero. However, the solver I use complains that the problem is not convex, so assumes &lt;span class=&quot;math-container&quot;&gt;$c_0 &amp;lt; 0$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I face many variants of this issue, especially if I re-optimize a problem and do some algebraic operations in between. It is hard to prevent this most of the time. My questions may be too broad, but:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do you, as OR people, have this issue generally? Is this a famous phenomenon, or is it just me?&lt;/li&gt;&#xA;&lt;li&gt;Is there a general way to have the same precision between the programming language (say MATLAB), and the solver (say CPLEX)?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="65" LastEditorUserId="38" LastEditDate="2019-06-01T02:22:41.383" LastActivityDate="2019-06-01T16:30:01.377" Title="Solver rounding precision vs programming language rounding precision" Tags="|solver|matlab|numerical-issues|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="99" PostTypeId="2" ParentId="79" CreationDate="2019-05-31T23:01:19.683" Score="11" Body="&lt;p&gt;There are at least three more problem libraries that you can access.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://people.brunel.ac.uk/~mastjjb/jeb/info.html&quot; rel=&quot;noreferrer&quot;&gt;OR-Lib&lt;/a&gt; has instances of Quadratic Assignment/Knapsack/Minimum spanning tree that you can use.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.minlplib.org/instances.html&quot; rel=&quot;noreferrer&quot;&gt;MINLP-Lib&lt;/a&gt; has several QP, BQP, IQP instances that you can filter by convexity.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://titan.princeton.edu/TestProblems/chapter2.html&quot; rel=&quot;noreferrer&quot;&gt;PrincetonLib&lt;/a&gt; chapter 2 problems.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I think that you can apart of it come up with synthetic instances which are not completely random (you provide certain structure) easily, like Quadratic assignment problems.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2019-05-31T23:01:19.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="100" PostTypeId="2" ParentId="85" CreationDate="2019-05-31T23:19:11.230" Score="11" Body="&lt;p&gt;To complement Michael's answer, which I think made the main points already: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, an obvious strategy is to separate the data set used for testing and tuning, from the data set that are used in validation, which is a common practice in other areas (e.g. machine learning).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, since one can be never sure to avoid a bias, I think it is helpful to state all assumption on the data set and publish as much information as possible on it, to make it possible investigate a possible bias in later research. Here I find the recommendations in &lt;a href=&quot;https://dx.doi.org/10.1057/jors.2015.77&quot; rel=&quot;noreferrer&quot;&gt;Good laboratory practice for optimization research&lt;/a&gt; helpful, in particular&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;R.3: use, when possible, real-world data&lt;/li&gt;&#xA;&lt;li&gt;R.4: publish the data set in a central location&lt;/li&gt;&#xA;&lt;li&gt;R.5: make data set subject to peer review&lt;/li&gt;&#xA;&lt;li&gt;R.9: define statistical procedures for comparisons&lt;/li&gt;&#xA;&lt;li&gt;R.10: state the suggested computation times and number of evaluations&lt;/li&gt;&#xA;&lt;li&gt;R.11: present a range of different benchmark instances, covering different sizes and complexity&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Finally, tuning algorithms for a certain instance structure may not necessarily be bad, portfolio algorithms are an example which exploit this. Indeed, more research, like for example &lt;a href=&quot;https://doi.org/10.1016/j.cor.2013.11.015&quot; rel=&quot;noreferrer&quot;&gt;Kate Smith-Miles&lt;/a&gt; work, into what makes instances hard could be useful. &lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2019-05-31T23:19:11.230" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="101" PostTypeId="2" ParentId="23" CreationDate="2019-06-01T00:36:08.073" Score="13" Body="&lt;p&gt;Here's a simple example of a symmetry-breaking constraint. Consider the &lt;em&gt;bin-packing problem&lt;/em&gt;: We want to pack &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; items into the smallest number of bins (up to &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; bins). Item &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; has size &lt;span class=&quot;math-container&quot;&gt;$a_n$&lt;/span&gt;, and the size of each bin is &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$x_{mn} = 1$&lt;/span&gt; if we put item &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; in bin &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; (0 otherwise), and let &lt;span class=&quot;math-container&quot;&gt;$y_m = 1$&lt;/span&gt; if bin &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is used (0 otherwise).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem can be formulated as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{alignat}{2}&#xA;\text{minimize} \quad &amp;amp; \sum_{m=1}^M y_m &amp;amp;&amp;amp; \\&#xA;\text{subject to} \quad &amp;amp; \sum_{m=1}^M x_{mn} = 1 &amp;amp;\quad&amp;amp; \forall n=1,\ldots,N \\&#xA;&amp;amp; \sum_{n=1}^N a_n x_{mn} \le vy_m &amp;amp;&amp;amp; \forall m=1,\ldots,M \\&#xA;&amp;amp; x_{mn}, y_m \in \{0,1\} &amp;amp;&amp;amp; \forall m=1,\ldots,M, n=1,\ldots,N&#xA;\end{alignat}$$&lt;/span&gt;&#xA;The objective function calculates the total number of bins used; the first constraint says every item must be placed in a bin; and the second constraint says the total size of items placed in bin &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; can't exceed &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, and must be 0 if &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is not used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a lot of symmetry in this problem, because the bins are identical. For any solution, we can just &quot;rotate&quot; the bins and we get a different solution with the same objective function value. For example, suppose there are 3 items, with sizes 7, 3, and 6, respectively; and 4 bins of size 10. The optimal solution uses 2 bins, but there are several such solutions: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[1,2] [3] [] []&lt;/code&gt; (items 1 and 2 in bin 1; item 3 in bin 2; and bins 3 and 4 empty)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[] [1,2] [3] []&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[] [] [1,2] [3]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[] [1,2] [] [3]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This symmetry makes it hard for the solver to prove that the optimal solution is indeed optimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To break the symmetry, we can add constraints that arbitrarily require us to use lower-indexed bins first. For example, the constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{m+1} \le y_m$$&lt;/span&gt;&#xA;says that we can't use bin &lt;span class=&quot;math-container&quot;&gt;$m+1$&lt;/span&gt; if we're not also using bin &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;. So the first solution above is feasible, but all the others are infeasible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We could also add symmetry-breaking constraints that require lower-indexed items to be in lower-indexed bins, so &lt;code&gt;[1,2] [3] [] []&lt;/code&gt; would be feasible but &lt;code&gt;[3] [1,2] [] []&lt;/code&gt; would not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Automatic methods for symmetry-breaking like the ones that @Edward Lam mentioned seem to be getting more and more powerful, but it's also often worth examining your specific problem to see if symmetries can be identified and broken.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-01T00:36:08.073" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="102" PostTypeId="1" AcceptedAnswerId="107" CreationDate="2019-06-01T00:57:34.540" Score="12" ViewCount="5061" Body="&lt;p&gt;For a random variable &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; with pdf &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;, the loss function* is defined as &#xA;&lt;span class=&quot;math-container&quot;&gt;$$n(x) = \mathbb{E}[(X-x)^+] = \int_{x}^\infty (y-x)f(y)dy,$$&lt;/span&gt; &#xA;where &lt;span class=&quot;math-container&quot;&gt;$a^+ = \max\{a,0\}$&lt;/span&gt;. Or, for a discrete distribution,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$n(x) = \mathbb{E}[(X-x)^+] = \sum_{y=x}^\infty (y-x)f(y).$$&lt;/span&gt;&#xA;Loss functions are used frequently in inventory theory and other fields. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;*This is different from the &quot;loss function&quot; used in machine learning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some well known probability distributions, there are explicit forms for the loss function, typically using the pdf/pmf and cdf. For example, if &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; has a standard normal distribution, then&#xA;&lt;span class=&quot;math-container&quot;&gt;$$n(x) = \phi(x) - x(1-\Phi(x)),$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\phi(\cdot)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\Phi(\cdot)$&lt;/span&gt; are the standard normal pdf and cdf. And if &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; has a Poisson(&lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;) distribution, then&#xA;&lt;span class=&quot;math-container&quot;&gt;$$n(x) = -(x-\lambda)(1-F(x)) + \lambda f(x).$$&lt;/span&gt;&#xA;These explicit forms are nice because they can be calculated without performing numerical integration or computing long sums, using pdf/pmf and cdf functions that are built into nearly every programming language and mathematical software package.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen explicit forms for loss functions for a handful of distributions, but typically somewhat scattershot in the appendix of an inventory-theory textbook (e.g., Zipkin 2000). I've never found them nicely collated anywhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Do you know of a resource to find explicit-form loss functions for more probability distributions?&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus points if the resource also has complementary loss functions (&lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[(X-x)^-]$&lt;/span&gt;) and second-order loss functions (&lt;span class=&quot;math-container&quot;&gt;$\frac12\mathbb{E}\left[\left([X-x]^+\right)^2\right]$&lt;/span&gt;)!&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2023-07-30T09:20:14.170" Title="Loss functions for specific probability distributions?" Tags="|inventory|loss-functions|probability-distributions|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="103" PostTypeId="2" ParentId="96" CreationDate="2019-06-01T01:47:52.057" Score="7" Body="&lt;p&gt;The basic power flow (PF) problem calculates how much power should be sent around a transmission or distribution network in one time period (at one snapshot in time). It ignores how that power is produced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Economic dispatch calculates how much power is produced at each power generator, ignoring the transmission network. Economic dispatch is a very simple but fast model. More accurate models use unit commitment in place of economic dispatch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Optimal power flow (OPF) combines the power flow and economic dispatch problems. More advanced versions cover multiple time periods and replace economic dispatch with unit commitment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The book &quot;Power Generation, Operation, and Control&quot; by Wood, Allen J. and Wollenberg, Bruce F. and Sheblé, Gerald B. is a reasonably good but not too formal reference.&lt;/p&gt;&#xA;" OwnerUserId="44" LastEditorUserId="44" LastEditDate="2019-06-02T07:10:26.737" LastActivityDate="2019-06-02T07:10:26.737" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="104" PostTypeId="2" ParentId="85" CreationDate="2019-06-01T01:57:32.460" Score="17" Body="&lt;p&gt;Let me add a couple of things based on my experience.  I created/collated the DIMACS instances for clique and coloring way back in 1992 and they are still used extensively, primarily for graph coloring. I also have kept track of results for a sports scheduling problem, the Traveling Tournament Problem, at &lt;a href=&quot;http://mat.tepper.cmu.edu/TOURN&quot; rel=&quot;noreferrer&quot;&gt;http://mat.tepper.cmu.edu/TOURN&lt;/a&gt; A couple things I learned:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Don't let the literature get hung up on speed.  For the DIMACS Challenge, we had programs to benchmark machines to allow for normalization of speeds, but there is a &lt;em&gt;lot&lt;/em&gt; more to speed of a program than the speed of the underlying machine.  Programmer skill, cache processes, random luck and far more play a role. At the end, I didn't trust any result about speed. It is far more interesting when new bounds are found or instance solutions are proven optimal.  Code fine-tuning really doesn't come into play for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Benchmark libraries need to be alive and changing.  The MIP people do a good job of this by creating new benchmark libraries every few years.  I did that for the Traveling Tournament Problem, and I wish I had done that for the DIMACS instances. Again, fine tuning is less valuable when there are always new, more challenging, instances to solve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would note that &quot;real world&quot; doesn't always mean challenging.  For the clique and coloring problems, practically every &quot;real-world&quot; instance we found had a large, completely obvious, clique that defined both the clique and the coloring.  But it is important to keep checking that by constantly adding instances.&lt;/p&gt;&#xA;" OwnerUserId="214" LastActivityDate="2019-06-01T01:57:32.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="105" PostTypeId="2" ParentId="48" CreationDate="2019-06-01T02:17:47.437" Score="6" Body="&lt;p&gt;You could try MDPtoolbox from &lt;a href=&quot;http://www7.inra.fr/mia/T/MDPtoolbox/Install.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; in which the package is ready to download for Matlab, R, and Python. The functions prepared in a manner that any user can easily modify it for specific problem instances. &lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-06-01T02:17:47.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="106" PostTypeId="2" ParentId="98" CreationDate="2019-06-01T06:44:48.683" Score="6" Body="&lt;p&gt;(1) Numerical stability is a real issue but not so common in my area of discrete optimisation (for obvious reasons). I only get it in two cases. Sometimes I get preprocessed data that has been rounded, resulting in nearly parallel constraints. Other times I badly implement an iterative algorithm like Benders decomposition, which produces more numerical error in each iteration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) I don’t use MATLAB but I would expect it to use double 64-bit precision in outputs and perhaps calculate using 80-bit precision. You can look into bignum libraries that implement infinite precision in software.&lt;/p&gt;&#xA;" OwnerUserId="44" LastActivityDate="2019-06-01T06:44:48.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="107" PostTypeId="2" ParentId="102" CreationDate="2019-06-01T06:56:57.803" Score="12" Body="&lt;p&gt;There is indeed a paper titled &lt;a href=&quot;https://mpra.ub.uni-muenchen.de/22163/2/MPRA_paper_22163.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Loss Distributions&lt;/a&gt; that provides the &lt;em&gt;limited expected value functions&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$L(x)$&lt;/span&gt; for several probability distributions (on page 15). It is directly related to the first-order loss function &lt;span class=&quot;math-container&quot;&gt;$n(x)$&lt;/span&gt; through &lt;span class=&quot;math-container&quot;&gt;$$n(x)=\Bbb E(X)-L(x)\tag1$$&lt;/span&gt; and notice that the loss function can also be written as &lt;span class=&quot;math-container&quot;&gt;$$n(x)=\int_x^\infty yf(y)\,dy-x(1-F(x))\tag2$$&lt;/span&gt; after splitting the term &lt;span class=&quot;math-container&quot;&gt;$(y-x)$&lt;/span&gt;. The expressions for &lt;span class=&quot;math-container&quot;&gt;$L(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\Bbb E(X)$&lt;/span&gt; are tabulated below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{c|c}\small\sf{Distribution}&amp;amp;L(x)&amp;amp;\Bbb E(X)\\\hline\small\sf{Log-Normal}&amp;amp;e^{\mu+\frac{\sigma^2}2}\Phi\left(\frac{\ln x-\mu-\sigma^2}{\sigma}\right)+x\left[1-\Phi\left(\frac{\ln x-\mu}{\sigma}\right)\right]&amp;amp;e^{\mu+\frac{\sigma^2}2}\\\hline\small\sf{Exponential}&amp;amp;\frac1\lambda\left(1-e^{-\lambda x}\right)&amp;amp;\frac1\lambda\\\hline\small\sf{Pareto}&amp;amp;\frac{\beta-\beta^\alpha(x+\beta)^{1-\alpha}}{\alpha-1}&amp;amp;\frac{\alpha\beta}{\alpha-1}\\\hline \small\sf{Burr}&amp;amp;\small\frac{\lambda^{1/\tau}\Gamma\left(\alpha-\frac1\tau\right)\Gamma\left(1+\frac1\tau\right)}{\Gamma(\alpha)}{\rm B}\left(1+\frac1\tau,\alpha-\frac1\tau;\frac{x^\tau}{\lambda+x^\tau}\right)+x\left(\frac\lambda{\lambda+x^\tau}\right)^\alpha&amp;amp;\frac{\lambda^{1/\tau}\Gamma\left(\alpha-\frac1\tau\right)\Gamma\left(1+\frac1\tau\right)}{\Gamma(\alpha)}\\\hline\small\sf{Weibull}&amp;amp;\frac{\Gamma\left(1+\frac1\tau\right)}{\beta^{1/\tau}}\Gamma\left(1+\frac1\tau,\beta x^\alpha\right)+xe^{-\beta x^\alpha}&amp;amp;\frac{\Gamma\left(1+\frac1\tau\right)}{\beta^{1/\tau}}\\\hline\small\sf{Gamma}&amp;amp;\frac\alpha\beta F(x,\alpha+1,\beta)+x(1-F(x,\alpha,\beta))&amp;amp;\frac\alpha\beta\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice how in the majority of cases, &lt;span class=&quot;math-container&quot;&gt;$\Bbb E(X)$&lt;/span&gt; is the same as the starting coefficient of &lt;span class=&quot;math-container&quot;&gt;$L(x)$&lt;/span&gt;. Of course, &lt;span class=&quot;math-container&quot;&gt;$n(x)$&lt;/span&gt; can be found using &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, for extensive details on the first-order loss function (and its complementary function) for the normal distribution, I highly recommend &lt;a href=&quot;https://arxiv.org/pdf/1307.1708.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Piecewise linear approximations of the standard normal first&#xA;order loss function&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a more generic and heuristic approach on any type of distribution, there is a follow-up paper on &lt;a href=&quot;https://gwr3n.github.io/chapters/Rossi_et_al_MAGO_2014_2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Piecewise linearisation of the first order loss function&#xA;for families of arbitrarily distributed random variables&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;References&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;[1] Burnecki, K., Misiorek, A., Weron, R. (2010). Loss Distributions. MPRA Paper No.  22163. Available from: &lt;a href=&quot;https://mpra.ub.uni-muenchen.de/22163/2/MPRA_paper_22163.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://mpra.ub.uni-muenchen.de/22163/2/MPRA_paper_22163.pdf&lt;/a&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;[2] Rossi, R., Tarim, S.A., Prestwich, S., Hnich, B. (2013). Piecewise linear approximations of the standard normal first&#xA;order loss function. Available from: &lt;a href=&quot;https://arxiv.org/pdf/1307.1708.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/1307.1708.pdf&lt;/a&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;[3] Rossi, R., Hendrix, E.M.T. (2014). Piecewise linearisation of the first order loss function&#xA;for families of arbitrarily distributed random variables. &lt;em&gt;Proceedings of MAGO.&lt;/em&gt; pp. 1-4. Available from: &lt;a href=&quot;https://gwr3n.github.io/chapters/Rossi_et_al_MAGO_2014_2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gwr3n.github.io/chapters/Rossi_et_al_MAGO_2014_2.pdf&lt;/a&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-07-31T08:38:50.953" LastActivityDate="2019-07-31T08:38:50.953" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="109" PostTypeId="1" AcceptedAnswerId="110" CreationDate="2019-06-01T10:49:33.677" Score="16" ViewCount="906" Body="&lt;p&gt;Suppose we have three variables, &lt;span class=&quot;math-container&quot;&gt;$x, y, z \in \mathbb R$&lt;/span&gt;. How can we linearize constraints with the following structure?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$z \geq \min(x, y)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z \leq \max(x, y)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="38" LastEditDate="2019-06-02T02:46:06.890" LastActivityDate="2019-06-02T02:46:06.890" Title="How to linearize a constraint with a maximum or minimum in the right-hand-side?" Tags="|linear-programming|linearization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="110" PostTypeId="2" ParentId="109" CreationDate="2019-06-01T11:23:39.533" Score="12" Body="&lt;p&gt;Basically the condition is saying, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; must be between &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, regardless of whether &lt;span class=&quot;math-container&quot;&gt;$x \le y$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$y \le x$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a method that involves a new binary variable and a big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; a binary variable that equals 1 if &lt;span class=&quot;math-container&quot;&gt;$x &amp;lt; y$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;y - x &amp;amp; \le Mw \\&#xA;x - y &amp;amp; \le M(1-w) &#xA;\end{align}$$&lt;/span&gt;&#xA;So, if &lt;span class=&quot;math-container&quot;&gt;$x &amp;lt; y$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; must equal 1; if &lt;span class=&quot;math-container&quot;&gt;$x &amp;gt; y$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; must equal 0; and if &lt;span class=&quot;math-container&quot;&gt;$x=y$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; could be either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now add the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;z &amp;amp; \ge y - Mw \\&#xA;z &amp;amp; \le x + Mw \\&#xA;z &amp;amp; \ge x - M(1-w) \\&#xA;z &amp;amp; \le y + M(1-w)&#xA;\end{align}$$&lt;/span&gt;&#xA;In other words: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x &amp;lt; y$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$w=1$&lt;/span&gt;), then &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; must be &lt;span class=&quot;math-container&quot;&gt;$\ge x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\le y$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x &amp;gt; y$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$w=0$&lt;/span&gt;), then &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; must be &lt;span class=&quot;math-container&quot;&gt;$\ge y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\le x$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x=y$&lt;/span&gt;, then we don't know what &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; equals, but either way, the constraints amount to &lt;span class=&quot;math-container&quot;&gt;$z = x = y$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-01T11:23:39.533" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="111" PostTypeId="1" AcceptedAnswerId="123" CreationDate="2019-06-01T11:44:10.420" Score="9" ViewCount="519" Body="&lt;p&gt;Often, ILP formulations are just too complicated to solve optimally in reasonable time. In those cases, you can still run a solver for some fixed time and simply take the best solution that the solver found. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I want to obtain upper bounds on the optimal solution quality (for maximisation problems, obviously) from an ILP solver after only running for a fixed time. This should be possible in theory, as a solver should maintain such a bound in some form (as far as I'm aware).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this functionality implemented in common solvers such as CPLEX or Gurobi? If so, how is this functionality called? (so that I can find how to do this in a manual of a solver) An example of how to do this in a solver of your choice is also appreciated.&lt;/p&gt;&#xA;" OwnerUserId="232" LastActivityDate="2019-06-01T16:37:35.983" Title="How to get bounds on ILP optimal solution quality" Tags="|linear-programming|integer-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="112" PostTypeId="2" ParentId="23" CreationDate="2019-06-01T12:18:42.543" Score="18" Body="&lt;p&gt;I think that the best survey of symmetry in IP was given by Francois Margot:&#xA;&lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-540-68279-0_17&quot; rel=&quot;noreferrer&quot;&gt;https://link.springer.com/chapter/10.1007/978-3-540-68279-0_17&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="34" LastActivityDate="2019-06-01T12:18:42.543" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="113" PostTypeId="1" AcceptedAnswerId="132" CreationDate="2019-06-01T12:46:41.680" Score="12" ViewCount="831" Body="&lt;p&gt;I have a polyhedral set for constraining &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;: &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\mathcal{P} = \{x \in \mathbb{R}^n_{+} : \ Dx \leq d \}&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$D \in \mathbb{R}^{m \times n}, d \in \mathbb{R}^m$&lt;/span&gt;. I find the Chebyshev center of this polyhedron, by solving: &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{ll}&#xA;\max &amp;amp;\, r\\&#xA;\text{s.t.} &amp;amp; D_i^\top x_c  + r \|D_i^\top\| \leq d_i \ \text{for }i =1,\ldots,m&#xA;\end{array}&lt;/span&gt;&#xA;Now I have this &lt;span class=&quot;math-container&quot;&gt;$x_c$&lt;/span&gt;, Chebyshev center of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}.$&lt;/span&gt; I split this polyhedron by two parts. Let &lt;span class=&quot;math-container&quot;&gt;$r \in \mathbb{R}^n$&lt;/span&gt; be a random vector. I  can divide &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}$&lt;/span&gt; by two halves by adding &lt;span class=&quot;math-container&quot;&gt;$r^\top x_c \leq r^\top x$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$r^\top x_c \geq r^\top x$&lt;/span&gt; to have &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}^\geq, \mathcal{P}^{\leq}$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, in this way, there are definitely new redundant constraints. I have seen some ways to find these redundant constraints, but my case is more specific since I divide based on the center. Therefore, I am wondering if there is an easy way to address this issue...&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="123" LastEditDate="2019-10-14T10:14:05.577" LastActivityDate="2019-10-14T10:14:05.577" Title="Simplest way to eliminate redundant constraints due to a new cut" Tags="|linear-programming|optimization|constraint|polyhedra|linear-algebra|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="114" PostTypeId="1" AcceptedAnswerId="116" CreationDate="2019-06-01T13:22:43.960" Score="22" ViewCount="2006" Body="&lt;p&gt;I want to solve the following optimization problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{ll} \text{minimize} &amp;amp; | c^\top x |\\ \text{subject to} &amp;amp; A x \leq b\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without the absolute value, this a standard form for linear programs. Can such a problem be transformed to an ordinary linear program?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;" OwnerUserId="232" LastEditorUserId="71" LastEditDate="2019-06-03T15:22:08.823" LastActivityDate="2020-01-21T15:39:05.490" Title="How to minimize an absolute value in the objective of an LP?" Tags="|linear-programming|linearization|absolute-value|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="115" PostTypeId="2" ParentId="114" CreationDate="2019-06-01T13:22:43.960" Score="10" Body="&lt;p&gt;This is possible by introducing 2 new variables, &lt;span class=&quot;math-container&quot;&gt;$t_1,t_2$&lt;/span&gt;, and adding a few constraints: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{align}&#xA;\min t_1+t_2 \quad \text{s.t.} \quad t_1-t_2 &amp;amp;= c\cdot x\\&#xA;t_1&amp;amp;\geq 0 \\&#xA;t_2&amp;amp;\geq 0 \\&#xA;Ax&amp;amp;\leq b&#xA;\end{align}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Why does this work? The main idea is that an optimal solution must set at least one of &lt;span class=&quot;math-container&quot;&gt;$t_1,t_2$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. First suppose &lt;span class=&quot;math-container&quot;&gt;$c\cdot x \leq 0$&lt;/span&gt;. This means &lt;span class=&quot;math-container&quot;&gt;$0\leq t_1\leq t_2$&lt;/span&gt;, so the minimum of &lt;span class=&quot;math-container&quot;&gt;$t_1+t_2$&lt;/span&gt; is attained by setting &lt;span class=&quot;math-container&quot;&gt;$t_1=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_2=-c\cdot x$&lt;/span&gt; and so &lt;span class=&quot;math-container&quot;&gt;$t_1+t_2 = -c\cdot x = |c\cdot x|$&lt;/span&gt;. Otherwise, &lt;span class=&quot;math-container&quot;&gt;$c\cdot x&amp;gt;0$&lt;/span&gt; and so &lt;span class=&quot;math-container&quot;&gt;$0\leq t_2 &amp;lt; t_1$&lt;/span&gt;, so the minimum of &lt;span class=&quot;math-container&quot;&gt;$t_1+t_2$&lt;/span&gt; is attained by setting &lt;span class=&quot;math-container&quot;&gt;$t_2=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_1=c\cdot x$&lt;/span&gt; and so &lt;span class=&quot;math-container&quot;&gt;$t_1+t_2 =c\cdot x =|c\cdot x|$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that this does not work for maximization problems. Replacing min by max makes the program above unbounded (suppose there is a feasible solution with &lt;span class=&quot;math-container&quot;&gt;$t_1=a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_2=b$&lt;/span&gt;. Then there is a feasible solution with &lt;span class=&quot;math-container&quot;&gt;$t_1=a+C$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_2=b+C$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$C\geq 0$&lt;/span&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not aware of any similar formulation for LP problems, but this is solvable in ILP problems by maximizing &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; under the disjunctive constraint &lt;span class=&quot;math-container&quot;&gt;$T= c\cdot x \vee T= -c\cdot x$&lt;/span&gt;. (disjunctive constraints can be modeled with a binary decision variable)&lt;/p&gt;&#xA;" OwnerUserId="232" LastActivityDate="2019-06-01T13:22:43.960" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="116" PostTypeId="2" ParentId="114" CreationDate="2019-06-01T13:43:42.150" Score="23" Body="&lt;p&gt;Alternatively, by observing that  &lt;span class=&quot;math-container&quot;&gt;$|c \cdot x|= \max \{c^T x, -c^T x\}$&lt;/span&gt;,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_x |c\cdot x| \text{   subject to    } Ax \le b$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;can be rewritten as &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_x \max \{c^T x, -c^T x\} \text{   subject to    } Ax \le b$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which is equivalent to &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x, z} z$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;subject to &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$z \ge c^Tx$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$z \ge -c^Tx$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Ax \le b$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which is a linear program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works because at the optimal value, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; will take one of the value of &lt;span class=&quot;math-container&quot;&gt;$c^Tx$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$-c^Tx$&lt;/span&gt;, it takes the value that is bigger. &lt;/p&gt;&#xA;" OwnerUserId="85" LastActivityDate="2019-06-01T13:43:42.150" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="117" PostTypeId="1" CreationDate="2019-06-01T14:33:46.750" Score="30" ViewCount="4304" Body="&lt;p&gt;I have a Masters' degree in Mathematics. I've very fair understanding of methods and techniques of Operations Research. I am looking for a good book/material where I can see a lot of examples on Math Model be it Integer Programming or Linear Programming which are being used in especially in Transportation domain or Resource Planning. The idea is to look at large number of Math Models so that I could be able to formulate the optimization model on my own. Currently I am not very good at writing the problem into a math model be it the objective function or the constraints.&lt;/p&gt;&#xA;" OwnerUserId="240" LastEditorUserId="8" LastEditDate="2020-09-04T09:43:10.917" LastActivityDate="2021-08-09T03:31:31.317" Title="Recommended books/materials for practical applications of Operations Research in industry" Tags="|optimization|reference-request|applications|books|industry|" AnswerCount="17" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="118" PostTypeId="2" ParentId="117" CreationDate="2019-06-01T15:05:14.997" Score="15" Body="&lt;p&gt;Since the OP asked for Transportation domain, I recommend the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vehicle Routing: Problems, Methods, and Applications by Toth &amp;amp; Vigo: &lt;a href=&quot;http://bookstore.siam.org/mo18/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;In Pursuit of the Traveling Salesman: Mathematics at the Limits of Computation by William Cook &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0691163529&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-06-01T15:05:14.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="119" PostTypeId="2" ParentId="117" CreationDate="2019-06-01T15:30:34.153" Score="11" Body="&lt;p&gt;Also in the Transportation domain, a good case-by-case analysis book is &lt;a href=&quot;https://www.palgrave.com/gp/book/9780333745489&quot; rel=&quot;noreferrer&quot;&gt;Operational Research in Industry&lt;/a&gt; by Tito Ciriani. It covers problems from airline-fleet scheduling to designs for flexible transit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Resource Planning domain, &lt;a href=&quot;https://www.wiley.com/en-us/Equitable+Resource+Allocation%3A+Models%2C+Algorithms+and+Applications-p-9781118054680&quot; rel=&quot;noreferrer&quot;&gt;Equitable Resource Allocation: Models, Algorithms and Applications&lt;/a&gt; by Hanan Luss provides many examples of resource allocation using mathematical modelling.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-06-01T15:36:07.770" LastActivityDate="2019-06-01T15:36:07.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="120" PostTypeId="1" AcceptedAnswerId="124" CreationDate="2019-06-01T15:52:12.123" Score="13" ViewCount="809" Body="&lt;p&gt;What (deterministic) global optimization packages support trigonometric functions such as &lt;span class=&quot;math-container&quot;&gt;$\sin, \cos, \tan$&lt;/span&gt; in the constraints or objective function? What limitations do they have?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not asking about heuristic or metaheuristic algorithms.&lt;/p&gt;&#xA;" OwnerUserId="47" LastActivityDate="2020-02-20T17:41:07.000" Title="What global MINLP solvers support trigonometric functions?" Tags="|minlp|global-optimization|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="121" PostTypeId="2" ParentId="120" CreationDate="2019-06-01T15:59:37.903" Score="6" Body="&lt;p&gt;From the &lt;a href=&quot;http://co-at-work.zib.de/files/stefan_minlp.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;presentation&lt;/a&gt; given by Vigerske, S. (2015), it is noted that the solvers &lt;a href=&quot;https://en.wikipedia.org/wiki/Couenne&quot; rel=&quot;nofollow noreferrer&quot;&gt;Couenne&lt;/a&gt; by P. Belotti and &lt;a href=&quot;https://www.lindo.com/index.php/products/lindo-api-for-custom-optimization-application&quot; rel=&quot;nofollow noreferrer&quot;&gt;LindoAPI&lt;/a&gt; by Y. Lin and L. Schrage can handle trigonometric expressions. Both are deterministic global optimisation solvers for MINLP.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;[1] Vigerske, S. (2015). MINLP - Global Solvers. Available from: &lt;a href=&quot;http://co-at-work.zib.de/files/stefan_minlp.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://co-at-work.zib.de/files/stefan_minlp.pdf&lt;/a&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-06-16T13:25:32.520" LastActivityDate="2019-06-16T13:25:32.520" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="122" PostTypeId="2" ParentId="98" CreationDate="2019-06-01T16:30:01.377" Score="14" Body="&lt;p&gt;Numerical stability (computations going sideways) and numerical tolerances are related but not identical. Floating point arithmetic being subject to rounding and truncation errors (unavoidably), every solver will need to treat things that are &quot;nearly nonnegative&quot;, &quot;nearly zero&quot; or &quot;nearly integer&quot; as if they are in fact nonnegative / zero / integer. That includes things like claiming a function is nonnegative if a coefficient has the wrong sign (and is not within tolerance of zero).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CPLEX has tolerance settings for constraint satisfaction, integrality and convergence. I don't know if there is a tolerance setting for the convexity check, but if you poke through the parameters manual you may find one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also relevant whether you are using the MATLAB API for CPLEX (preferable) or exporting a file from MATLAB and reading it into CPLEX (less accurate, especially if you use a LP file as opposed to a SAV file). I've seen a number of cases reported where passing a model via an LP format file produced different results (different solution, numerical errors, ...) from passing the exact same model via SAV format. LP format is text, which produces truncation errors in both directions (reading, writing) that SAV format (which is binary) avoids.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trust me, you're not alone in this.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-06-01T16:30:01.377" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="123" PostTypeId="2" ParentId="111" CreationDate="2019-06-01T16:37:35.983" Score="11" Body="&lt;p&gt;I cannot speak for Gurobi, but CPLEX definitely has this capability, and my guess is that any solver library does. For a standalone solver (as opposed to one with an API), you might have to look for the best bound in the output log and do some text scraping to get it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the Java API to CPLEX, the function you want is IloCplex.getBestObjValue(), which gives you the best (LP relaxation) objective value of any node still alive in the search tree.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-06-01T16:37:35.983" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="124" PostTypeId="2" ParentId="120" CreationDate="2019-06-01T17:05:34.410" Score="12" Body="&lt;p&gt;SCIP does not currently support any trigonometric functions as of &lt;a href=&quot;https://github.com/SCIP-Interfaces/CSIP/issues/40&quot; rel=&quot;noreferrer&quot;&gt;this post&lt;/a&gt; from May 2018.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;COUENNE appears to handle &lt;a href=&quot;https://www.coin-or.org/Doxygen/Couenne/_couenne_expr_sin_8hpp.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$\sin$&lt;/span&gt;&lt;/a&gt; and &lt;a href=&quot;https://www.coin-or.org/Doxygen/Couenne/_couenne_expr_cos_8hpp.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$\cos$&lt;/span&gt;&lt;/a&gt; expressions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ANTIGONE &lt;a href=&quot;http://helios.princeton.edu/ANTIGONE/&quot; rel=&quot;noreferrer&quot;&gt;appears&lt;/a&gt; to not support any trigonometric functions as of 2013.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BARON states in the &lt;a href=&quot;https://minlp.com/downloads/docs/baron%20manual.pdf&quot; rel=&quot;noreferrer&quot;&gt;manual&lt;/a&gt; to not support any trigonometric functions in March 2019.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LINDOGLOBAL &lt;a href=&quot;https://www.gams.com/latest/docs/S_LINDO.html#LINDO_SUPPORTED_NONLINEAR_FUNCTIONS&quot; rel=&quot;noreferrer&quot;&gt;supports&lt;/a&gt; cos, sin, tan, cosh, sinh, tanh, arccos, arcsin, arctan.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;COCONUT and MINOTAUR: no information found yet.&lt;/p&gt;&#xA;" OwnerUserId="47" LastEditorUserId="47" LastEditDate="2019-06-03T16:06:04.810" LastActivityDate="2019-06-03T16:06:04.810" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="125" PostTypeId="2" ParentId="120" CreationDate="2019-06-01T17:12:56.517" Score="7" Body="&lt;p&gt;Here is an option for MATLAB users which is not mentioned in any other answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;YALMIP's BMIBNB iI a global branch and bound solver &lt;a href=&quot;https://yalmip.github.io/solver/bmibnb/&quot; rel=&quot;noreferrer&quot;&gt;https://yalmip.github.io/solver/bmibnb/&lt;/a&gt;. It is used in combination with (i.e., calls) a MILP solver (such as CPLEX, GUROBI, SCIP, MOSEK) and a &quot;call back&quot; for evaluation continuous variable local optimization solver (such as FMINCON, KNITRO, IPOPT, SNOPT, FILTERSD) as an upper solver. It can then handle most functions in MATLAB, as well as integer variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be combined with SDP solvers as upper solver, including in principle with a nonlinear SDP solver such as PENLAB as upper solver. That provides a capability not available in any other global solver I am aware of, to globally optimize non-convex nonlinear semidefinite-constrained optimization problems; and may be mixed integer-constrained as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a made up stupid example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sdpvar x; % declare x to be a continuous variable&#xA;intvar y; % declare y to be an integer variable&#xA;Constraints = [x+y &amp;gt;= 2,-5 &amp;lt;= x &amp;lt;= 5,-4 &amp;lt;=y &amp;lt;= 7]; &#xA;Objective = atan(sin(x+y))+x^2-y^2 +4*sin(y^3) % some nonsense with trig functions&#xA;options = sdpsettings('solver','bmibnb','bmibnb.uppersolver','fmincon');&#xA;optimize(Constraints,Objective,options) % solve the problem&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key limitation is that BMIBNB was developed by one person with limited time devoted, as opposed to much larger scale development efforts for other solvers. Also, it may run out of time or memory, and it is only as good as the solvers it calls for subproblems. If used with an unreliable MILP solver, it may give erroneous results. Really badly scaled or ill-conditioned problems can cause screw ups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All variables must be explicitly bounded, i.e., finite box constraints are required.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-06-01T17:34:59.283" LastActivityDate="2019-06-01T17:34:59.283" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="126" PostTypeId="1" CreationDate="2019-06-01T18:28:45.843" Score="13" ViewCount="691" Body="&lt;p&gt;I have a set of linearized constraints that are modelled using big-Ms. Now, it is, of course, common knowledge to make the value of M and small as possible in order to provide tighter LP relaxations of the (e.g.) MIP we are solving. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for some examples where this tightening of the 'M' is really useful from a computational perspective.  As often by my experience, the smallest value of M is so trivial that it does not really influence computational performance (Equal to the cardinality of a set; maximum length of a time horizon etc. )&lt;/p&gt;&#xA;" OwnerUserId="48" LastEditorUserId="38" LastEditDate="2019-06-03T14:51:09.957" LastActivityDate="2019-06-03T14:51:09.957" Title="The effect of choosing big M properly" Tags="|mixed-integer-programming|linearization|big-m|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="127" PostTypeId="2" ParentId="117" CreationDate="2019-06-01T19:38:52.097" Score="29" Body="&lt;p&gt;Not solely dedicated to transportation, but &lt;a href=&quot;https://www.wiley.com/en-ir/Model+Building+in+Mathematical+Programming,+5th+Edition-p-9781118443330&quot; rel=&quot;nofollow noreferrer&quot;&gt;Model Building in Mathematical Programming&lt;/a&gt; by Williams is a very good start for every beginner in modeling as it contains the theories on mathematical programming modeling as well as numerous examples. AFAIK, this is one of the best books on modeling as it does not concern itself with solution methodologies and the (rigorous) maths behind them.&lt;/p&gt;&#xA;" OwnerUserId="119" LastEditorUserId="123" LastEditDate="2020-02-10T14:20:25.473" LastActivityDate="2020-02-10T14:20:25.473" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="128" PostTypeId="2" ParentId="126" CreationDate="2019-06-01T20:36:39.630" Score="5" Body="&lt;p&gt;I've run into issues with this for supply chain problems choosing which facilities to open. In my model, trucks to deliver to customers could only come from open facilities, so big M had to be larger than the total number of trucks leaving the facility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For my real-world problem, there were more than 10,000 trucks (my original choice of M).&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2019-06-01T20:36:39.630" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="130" PostTypeId="2" ParentId="117" CreationDate="2019-06-01T23:58:52.290" Score="12" Body="&lt;p&gt;Just to add a different flavor, there's a very good case study section in &quot;&lt;a href=&quot;https://www.springer.com/us/book/9781402077012&quot; rel=&quot;noreferrer&quot;&gt;The Theory and Practice of Revenue Management&lt;/a&gt;&quot; by Talluri and Van Ryzin. Among other things, you will find some interesting optimization models.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other obvious choice, is not a book, but rather a journal. &lt;a href=&quot;https://www.informs.org/Publications/INFORMS-Journals/INFORMS-Journal-on-Applied-Analytics&quot; rel=&quot;noreferrer&quot;&gt;INFORMS Journal on Applied Analytics&lt;/a&gt; (formerly known as Interfaces) is a cornucopia of applied optimization models that have been successfully deployed across industries. Highly recommended, if you're not aware of it already. Basically every article is a successful case study.&lt;/p&gt;&#xA;" OwnerUserId="253" LastEditorUserId="253" LastEditDate="2019-06-02T14:58:59.510" LastActivityDate="2019-06-02T14:58:59.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="131" PostTypeId="2" ParentId="126" CreationDate="2019-06-02T00:55:01.097" Score="6" Body="&lt;p&gt;The practical study &lt;a href=&quot;https://dx.doi.org/10.4230/OASIcs.ATMOS.2017.10&quot; rel=&quot;noreferrer&quot;&gt;Analysis of Strength and Weaknesses of a MILP Model for Revising Railway Traffic Timetables&lt;/a&gt; includes an analysis of the influence of big M constraints. The conclusion is mixed, though: in their model, knowledge of sharp M-values has a notable effect, but sharp values are obviously hard to find in practice.&lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2019-06-02T00:55:01.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="132" PostTypeId="2" ParentId="113" CreationDate="2019-06-02T01:26:44.980" Score="8" Body="&lt;p&gt;As a partial answer, &lt;a href=&quot;https://ageconsearch.umn.edu/record/272154/files/erasmus091.pdf&quot; rel=&quot;noreferrer&quot;&gt;Telgen (1977)&lt;/a&gt; has shown that eliminating all redundant inequalities is LP-equivalent, i.e. in general not easier than solving linear programs. Clearly, this does not exclude heuristics (e.g. &lt;a href=&quot;https://doi.org/10.1080/00207160601014148&quot; rel=&quot;noreferrer&quot;&gt;A heuristic approach for identification of redundant constraints in linear programming models&lt;/a&gt;) or a better strategy for removing (a subset of) the redundant inequalities in your special case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Telgen, J., &lt;em&gt;On redundancy of systems of linear inequalities&lt;/em&gt;, Rep. 7718, Econometric Institute, Erasmus University Rotterdam, 1977.&lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2019-06-02T01:26:44.980" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="133" PostTypeId="2" ParentId="117" CreationDate="2019-06-02T01:34:47.823" Score="15" Body="&lt;p&gt;Joe Geunes's book &lt;em&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/1482239906&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Operations Planning&lt;/a&gt;&lt;/em&gt; does a nice job of teaching MIP modeling in an operations context (production, distribution, facility location, etc.).&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-02T01:34:47.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="134" PostTypeId="2" ParentId="114" CreationDate="2019-06-02T02:00:19.037" Score="7" Body="&lt;p&gt;I would like to suggest a different angle using the epigraphical relaxation of the absolute value. In particular, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;|z| = \min_{|z|\leq t}t = \min_{-t \leq z \leq t}t&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this observation, the optimization problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\operatorname*{Minimize}_{x, Ax \leq b} |c^\top x|&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is equivalent to &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\operatorname*{Minimize}_{x, Ax \leq b} \min_{-t \leq c^\top x \leq t}t,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;that is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\operatorname*{Minimize}_{x,t \,{}:{}\, Ax \leq b,\ -t \leq c^\top x \leq t} t,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which is an LP.&lt;/p&gt;&#xA;" OwnerUserId="70" LastActivityDate="2019-06-02T02:00:19.037" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="135" PostTypeId="1" AcceptedAnswerId="136" CreationDate="2019-06-02T02:19:31.697" Score="17" ViewCount="4407" Body="&lt;p&gt;I’ve seen the &quot;big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; method&quot; referred to in different ways. What is the &quot;big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; method&quot; and why does it seem to mean two different things?&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-02T02:30:15.547" LastActivityDate="2019-06-02T13:34:28.947" Title="What is the &quot;big-M&quot; method? And are there two of them?" Tags="|linear-programming|mixed-integer-programming|logical-constraints|big-m|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="136" PostTypeId="2" ParentId="135" CreationDate="2019-06-02T02:19:31.697" Score="25" Body="&lt;p&gt;People do use the term &quot;big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; method&quot; to mean two different things. In both cases, the name refers to the use of a large constant, often denoted &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first use of the term refers to a &lt;a href=&quot;https://en.wikipedia.org/wiki/Big_M_method&quot; rel=&quot;noreferrer&quot;&gt;method for finding an initial feasible solution&lt;/a&gt; for the simplex method. (Another common method for doing this is the two-phase method.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes people also use the term &quot;big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; method&quot; to refer to the use of big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; parameters in logical constraints in (mixed-)integer programming problems. For example: if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a continuous variable and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a binary variable, then the constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x \le My$$&lt;/span&gt;&#xA;says that if &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; must equal 0, and if &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;, then the constraint places no restrictions on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Note that in this case, it’s important not to choose a value of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; that is &lt;em&gt;too&lt;/em&gt; large.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Aside&lt;/em&gt;: I highly recommend @prubin's excellent &lt;a href=&quot;https://orinanobworld.blogspot.com/2011/07/perils-of-big-m.html&quot; rel=&quot;noreferrer&quot;&gt;blog post&lt;/a&gt; on big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; in all its forms.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-02T13:34:28.947" LastActivityDate="2019-06-02T13:34:28.947" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="137" PostTypeId="2" ParentId="126" CreationDate="2019-06-02T02:41:09.837" Score="9" Body="&lt;p&gt;I often see people set &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to something like &lt;span class=&quot;math-container&quot;&gt;$10^{12}$&lt;/span&gt;, when the rest of the model is on the order of &lt;span class=&quot;math-container&quot;&gt;$10^2$&lt;/span&gt;, because they got the message that &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; should be &quot;a large constant&quot;. Reducing &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to something several orders of magnitude smaller then &lt;em&gt;does&lt;/em&gt; have a noticeable impact on the run time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My point is: Once you know that you should should be careful about choosing &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, it might not make much difference if you set it to &lt;span class=&quot;math-container&quot;&gt;$10^3$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$10^4$&lt;/span&gt;, and it might not be worth investing too much time to get it just right. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you are still in the frame of mind that says &quot;set &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; as large as you want&quot;, there can be a &lt;em&gt;huge&lt;/em&gt; difference when you bring &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; down from the stratosphere and make it something reasonable.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-02T02:41:09.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="138" PostTypeId="2" ParentId="56" CreationDate="2019-06-02T05:06:39.937" Score="7" Body="&lt;p&gt;Something that I think is becoming more prominent is the use of RL for what would have traditionally been solved using exact solutions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://medium.com/octavian-ai/finding-shortest-paths-with-graph-networks-807c5bbfc9c8&quot; rel=&quot;noreferrer&quot;&gt;https://medium.com/octavian-ai/finding-shortest-paths-with-graph-networks-807c5bbfc9c8&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is something that I'm following and will hopefully try and implement for a Prize Collecting Steiner Tree (PCST) and/or assignment model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The open question is why would you use this method?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It ?may? be possible to get &quot;better&quot; solutions in less compute time given a pre-trained model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is any one else working on this type of approach? Or have references?&lt;/p&gt;&#xA;" OwnerUserId="259" LastActivityDate="2019-06-02T05:06:39.937" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="139" PostTypeId="1" AcceptedAnswerId="152" CreationDate="2019-06-02T06:17:43.833" Score="14" ViewCount="388" Body="&lt;p&gt;The classical constraints to prevent subtours in routing problems (i.e., to make sure every route is connected to a depot), are of the following form,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{(i,j) \in \delta(S)} x_{ij} \leq |S| - 1 \quad \forall S \subset V_C,&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\delta(S)$&lt;/span&gt; denotes all arcs connected to nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; (and &lt;span class=&quot;math-container&quot;&gt;$V_C$&lt;/span&gt; is the set of customer nodes), and &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; is the binary variable indicating whether edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is traversed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, adding a constraint for all &lt;span class=&quot;math-container&quot;&gt;$S \subset V_C$&lt;/span&gt; is not feasible, so one usually separates such constraints/inequalities in a dynamic fashion (i.e, solving LP - separating inequality - resolve LP - separating - .. etc). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, for &lt;span class=&quot;math-container&quot;&gt;$|S| = 2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$|S| = 3$&lt;/span&gt; (i.e., all subsets of size 2, 3) the number of constraints is not too large. My question is the following: Is it worth the effort to enumerate such constraints for small sizes of &lt;span class=&quot;math-container&quot;&gt;$|S|$&lt;/span&gt; and simply add those to the formulation before we start the solving process? &lt;/p&gt;&#xA;" OwnerUserId="48" LastEditorUserId="87" LastEditDate="2019-06-03T15:15:43.520" LastActivityDate="2019-06-03T15:15:43.520" Title="Subtour elimination constraints - enumeration vs dynamically adding" Tags="|traveling-salesman|subtour-elimination|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="140" PostTypeId="2" ParentId="126" CreationDate="2019-06-02T06:40:59.970" Score="10" Body="&lt;p&gt;The bigger the big-M is, more likely the numerical issues will happen with solvers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have right hand sides around &lt;span class=&quot;math-container&quot;&gt;$10^{10}$&lt;/span&gt; and objective function coefficients in the range of &lt;span class=&quot;math-container&quot;&gt;$10^{-2}$&lt;/span&gt;, then solvers will have hard time dealing with such big range of values. And big-M's are the usual suspects in such situations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So smaller the big-M, tighter and more numerically stable the matrix is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One option when dealing with such big bigM values is using indicator constraints. They are great ways to write if-&gt;then type of logic in MIP programming. See examples of indicator constraints for Xpress Mosel &lt;a href=&quot;https://www.fico.com/fico-xpress-optimization/docs/latest/mipform/dhtml/chaplogexp.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="264" LastEditorUserId="123" LastEditDate="2019-06-03T12:24:17.077" LastActivityDate="2019-06-03T12:24:17.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="141" PostTypeId="2" ParentId="139" CreationDate="2019-06-02T06:45:15.323" Score="4" Body="&lt;p&gt;In my experience it is helpful to add the smallest sub tour constraints directly into the model formulation. You should play a bit with the exact size but I commonly add subtour constraints up to 4 customers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also try to exclude some larger subtours that satisfy some conditions. For instance, select a random node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and exclude the shortest cycle that starts/end at customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and visits &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; other customers. &lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-06-02T06:53:54.213" LastActivityDate="2019-06-02T06:53:54.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="142" PostTypeId="1" CreationDate="2019-06-02T12:01:26.460" Score="9" ViewCount="386" Body="&lt;p&gt;I am sending a pretty complex Pyomo MINLP to NEOS using Couenne. I'm getting an error message that the solve time is too long (sorry, I don't have it still in my Python console). Is there a way to set a max time and return the best feasible result? I was able to get solutions back prior to adding my last set of constraints. Current code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# lots of code for model building...&#xA;&#xA;solver_manager = SolverManagerFactory('neos')&#xA;results = solver_manager.solve(model , opt='couenne',load_solutions=True,tee=True)&#xA;model.solutions.store_to(results)&#xA;results.write()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="267" LastActivityDate="2019-10-14T10:10:42.930" Title="pyomo - pass time limit to NEOS" Tags="|pyomo|nonlinear-programming|neos|python|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="143" PostTypeId="1" AcceptedAnswerId="149" CreationDate="2019-06-02T12:02:51.860" Score="33" ViewCount="1174" Body="&lt;p&gt;Problems that have a minimax-type structure are notoriously hard to solve. For example, the &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median problem from facility location (choose &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; facilities to minimize demand-weighted distance to customers) &lt;em&gt;does not&lt;/em&gt; have a minimax structure:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{alignat}{2}&#xA;\text{minimize} \quad &amp;amp; \sum_i \sum_j h_id_{ij}y_{ij} \\&#xA;\text{subject to} \quad &amp;amp; \sum_j y_{ij} = 1 &amp;amp;\quad&amp;amp; \forall i \\&#xA;&amp;amp; y_{ij} \le x_j &amp;amp;&amp;amp; \forall i, j \\&#xA;&amp;amp; \sum_j x_j = p \\&#xA;&amp;amp; x_j, y_{ij} \in \{0,1\} &amp;amp;&amp;amp; \forall i, j&#xA;\end{alignat}$$&lt;/span&gt;&#xA;(&lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt; = demand of customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; = distance from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; = 1 if we open facility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; = 1 if we assign &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.)&#xA;Its cousin, the &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-center problem (minimize the maximum distance from a customer to its assigned facility), &lt;em&gt;does&lt;/em&gt; have a minimax structure:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{alignat}{2}&#xA;\text{minimize} \quad &amp;amp; u \\&#xA;\text{subject to} \quad &amp;amp; \sum_j y_{ij} = 1 &amp;amp;\quad&amp;amp; \forall i \\&#xA;&amp;amp; y_{ij} \le x_j &amp;amp;&amp;amp; \forall i, j \\&#xA;&amp;amp; \sum_j x_j = p \\&#xA;&amp;amp; \sum_j d_{ij}y_{ij} \le u &amp;amp;&amp;amp; \forall i \\&#xA;&amp;amp; x_j, y_{ij} \in \{0,1\} &amp;amp;&amp;amp; \forall i, j&#xA;\end{alignat}$$&lt;/span&gt;&#xA;(&lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; = maximum distance to assigned facility, among all customers.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I solved a benchmark 88-node instance of the &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median problem with &lt;span class=&quot;math-container&quot;&gt;$p=6$&lt;/span&gt; using CPLEX and it took &lt;strong&gt;0.7 seconds.&lt;/strong&gt; I solved the same instance of the &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-center problem and it took CPLEX &lt;strong&gt;1,607 seconds.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar effects happen, e.g., for stochastic facility location (minimize expected cost) vs. robust facility location (minimize maximum cost).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I always tell my students, &quot;these minimax-type problems are just really hard for solvers to solve,&quot; but I don't have a good explanation for &lt;em&gt;why&lt;/em&gt;. (I know their LP relaxations are weak, but again I don't know why this tends to happen.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, &lt;em&gt;why&lt;/em&gt; are minimax problems harder to solve, computationally?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, are there any types of automatically generated cuts that one can turn on in commercial solvers that tend to help with minimax problems?&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="61" LastEditDate="2019-06-02T17:04:07.330" LastActivityDate="2020-02-04T19:47:22.470" Title="Why are integer minimax problems hard?" Tags="|facility-location|minimax|p-median|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="144" PostTypeId="2" ParentId="30" CreationDate="2019-06-02T12:43:45.863" Score="6" Body="&lt;p&gt;If it is worth or not to re-implement existing algorithms is heavily dependent on what kind of algorithms and what bottlenecks the current code is facing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a practitioner I would always try to make a &quot;business case&quot; with pro's and con's. Some very generally remarks (I haven't tried the new dynamic search myself)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some pro's for re-writing:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Faster code (by multi-threading if I understand it correctly)&lt;/li&gt;&#xA;&lt;li&gt;Get experience using the new feature on known code (makes it easier to judge the impact the new feature has)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some con's:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Harder to debug (I think)&lt;/li&gt;&#xA;&lt;li&gt;Time consuming with unknown benefit&lt;/li&gt;&#xA;&lt;li&gt;Reduced low-level control (as mentioned by Ryan Cory-Wright)&lt;/li&gt;&#xA;&lt;li&gt;Needs to be thread-safe&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Ask yourself if this is the best possible way to improve your code. Maybe you have other parts of the code with some low hanging fruits. There is probably not one answer to your stated question.&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2019-06-02T12:43:45.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="145" PostTypeId="2" ParentId="142" CreationDate="2019-06-02T12:56:36.593" Score="7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;complex Pyomo MINLP to NEOS using Couenne.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, I had to Google a bit to understand this part as I am not familiar with the package nor the NEOS service. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be beneficial as to where in the run-time progress you get the error message and what it exactly states. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;https://neos-server.org/neos/help.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;NEOS webpage&lt;/a&gt; I found the following limitations&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Retrieving results&#xA;  If you are having trouble receiving results, you should read the NEOS Server FAQ section on results before contacting support. Jobs that exceed the 8 hour time limit or the 3 GB memory limit will not return results.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I am guessing your model doesn't run for 8 hours, but maybe you are hitting the 3 GB memory limit before a solution has been found? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit below, as a comment shed some new light for the reason to the time limit (or I misunderstood the question).&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you simply want a feasible solution (fast), then I would model the problem as a decision problem (see &lt;a href=&quot;https://cs.stackexchange.com/questions/32624/what-is-the-decision-version-of-integer-programming&quot;&gt;this answer on Comp Sci SE&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shortly put and in general terms, you change the problem from something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} \min&amp;amp;\quad f(x) \\&#xA;\text{s.t.} &amp;amp;\quad Ax = b \\&#xA;&amp;amp;\quad x \in \Bbb R\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} \min&amp;amp;\quad 0 \\&#xA;\text{s.t.} &amp;amp;\quad Ax = b \\&#xA;&amp;amp;\quad f(x)\leq K\\&#xA;&amp;amp;\quad x \in \Bbb R\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is a large constant you are fairly certain a feasible solution has an objective less than (or &lt;code&gt;Integer.MAX_VALUE&lt;/code&gt; or &quot;large enough&quot;). The problem should terminate as soon as a solution has been found.&lt;/p&gt;&#xA;" OwnerUserId="268" LastEditorUserId="123" LastEditDate="2019-10-14T10:10:42.930" LastActivityDate="2019-10-14T10:10:42.930" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="146" PostTypeId="2" ParentId="45" CreationDate="2019-06-02T13:04:51.450" Score="9" Body="&lt;p&gt;You could also give a try to &lt;a href=&quot;https://github.com/VROOM-Project/vroom&quot; rel=&quot;noreferrer&quot;&gt;VROOM&lt;/a&gt;,&#xA;which can be used for commercial use. It can solve TSP and some variants of the VRP such as VRPTW and CVRP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the API documentation : &lt;a href=&quot;https://github.com/VROOM-Project/vroom/blob/master/docs/API.md&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/VROOM-Project/vroom/blob/master/docs/API.md&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can is to start with the demo server to see if it can fit on small instances and then install it to use it as an API or integrate it as a library.&lt;/p&gt;&#xA;" OwnerUserId="272" LastEditorUserId="38" LastEditDate="2019-06-02T13:19:07.237" LastActivityDate="2019-06-02T13:19:07.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="147" PostTypeId="2" ParentId="143" CreationDate="2019-06-02T15:56:27.370" Score="19" Body="&lt;p&gt;This is going to be a hand-waving argument: perhaps this has been formalized in the literature someplace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the issue is that the linear relaxation is in some sense more compatible with the p-median objective than the p-center problem.  Consider the following example (circles are customers; stars are facilities)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fCvxr.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fCvxr.png&quot; alt=&quot;Customer and Facility Locations&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the left hand customers, the distance to the closest facility is 1; for the right hand customer, the closest facility (also on the right) is 3; the distance between the left column and the right column is 6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For p-median, everything gets assigned to their closest facility.  This is true for the linear relaxation as well.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wR85X.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wR85X.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you try to assign the right-hand customer to the left-hand facilities, it will cost 6 no matter how you assign it: it is cheaper to assign it to the right-hand facility at cost 3.  Assigning fractional solutions doesn't &quot;cheat&quot;: a good assignment will be pushed toward value 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For p-center, though, there is an advantage in the linear relaxation to fractionally assign things.  In our example, the best integer assignment for the right-hand-side customer is still to its closest facility at cost 3.  But fractionally, there is a value to assign things to the left hand side:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/muIsF.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/muIsF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you put weight 1/3 on each of the dotted lines, then the p-center cost goes down to 2.  In fact, the optimal thing to do is to is to assign weight .2 to each of the dotted lines, leaving .4 for the right hand facility, for a cost of 1.2.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the nasty fractional solution in this almost trivial example, it is not surprising that branch and bound has to work very hard to get to an integer solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This leads to the possibly-useful but not-tremendously-insightful cut of &#xA;&lt;span class=&quot;math-container&quot;&gt;$u \ge d^*$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$d^*$&lt;/span&gt; is the largest minimum distance among all customers to its closest facility.&lt;/p&gt;&#xA;" OwnerUserId="214" LastActivityDate="2019-06-02T15:56:27.370" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="148" PostTypeId="2" ParentId="143" CreationDate="2019-06-02T16:02:36.283" Score="6" Body="&lt;p&gt;You may find this paper (&lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-1-4613-3557-3_15&quot; rel=&quot;noreferrer&quot;&gt;On the Complexity of Min-Max Optimization Problems and their Approximation&lt;/a&gt; interesting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, only looking at the &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-center examples you shared, I can say that the constraints of &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-center problem (or its space), is equivalent to solving a &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median problem where &lt;span class=&quot;math-container&quot;&gt;$h_i = 1$&lt;/span&gt;. So, &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-center is solving a series of &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median problems. Hopefully, this is not a wrong interpretation!&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-06-02T16:02:36.283" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="149" PostTypeId="2" ParentId="143" CreationDate="2019-06-02T17:40:18.143" Score="19" Body="&lt;p&gt;I can see two reasons why branch-and-bound based solvers can have a hard time solving these problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;the linear relaxation may be bad (as stated above);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;these models have typically (exponentially) many optimal solutions, since the cost only depends on a single variable &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt;. Thus, you can move one customer to many centers without changing the cost of a solution. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For p-center, models that distribute the cost over several variables seem to be much more &lt;em&gt;MIP-solver friendly&lt;/em&gt;. At least their linear relaxations are better (see for example &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/ijoc.1030.0028&quot; rel=&quot;noreferrer&quot;&gt;Elloumi et al., 2004&lt;/a&gt; ).&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2019-06-02T17:40:18.143" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="150" PostTypeId="5" CreationDate="2019-06-02T18:02:00.920" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-02T18:02:00.920" LastActivityDate="2019-06-02T18:02:00.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="151" PostTypeId="4" CreationDate="2019-06-02T18:02:00.920" Score="0" Body="For questions about solving Operations Research problems using the Python programming language. " OwnerUserId="279" LastEditorUserId="38" LastEditDate="2019-06-12T14:04:13.127" LastActivityDate="2019-06-12T14:04:13.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="152" PostTypeId="2" ParentId="139" CreationDate="2019-06-02T18:47:31.560" Score="12" Body="&lt;p&gt;This has to depend on instance size.  For a sports scheduling problem I worked on, it definitely made life easier to simply put in all the &lt;span class=&quot;math-container&quot;&gt;$|S| \le 3$&lt;/span&gt; constraints (not exactly subtour, but very similar).  But &lt;span class=&quot;math-container&quot;&gt;$n=30$&lt;/span&gt; in that case.  If you want to solve TSPs with, say, 1000 nodes, then &lt;span class=&quot;math-container&quot;&gt;$n^3$&lt;/span&gt; is pretty big, and most of them are completely irrelevant.  You will never hit the case where the subtour constraint on 3 widely separate points (with many in between) is relevant.  But putting all of them in for trios that are sufficiently close may well work.&lt;/p&gt;&#xA;" OwnerUserId="214" LastActivityDate="2019-06-02T18:47:31.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="153" PostTypeId="1" AcceptedAnswerId="160" CreationDate="2019-06-03T01:18:11.507" Score="4" ViewCount="364" Body="&lt;p&gt;Suppose I want an AMPL set to contain the integers 1 through 5. How can I declare this &lt;em&gt;in the .dat file&lt;/em&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can do it in the .mod file, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;things.mod:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set THINGS := 1..5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Console:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ampl: model things.mod;&#xA;ampl: display THINGS;&#xA;set THINGS := 1 2 3 4 5;&#xA;&#xA;ampl: display THINGS diff {2};&#xA;set THINGS diff  {2} := 1 3 4 5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But now suppose I do this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;things.mod:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set THINGS;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;things.dat:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set THINGS := 1..5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Console:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ampl: model things.mod;&#xA;ampl: data things.dat;&#xA;ampl: display THINGS;&#xA;set THINGS := 1..5;&#xA;&#xA;ampl: display THINGS diff {2};&#xA;set THINGS diff  {2} := 1..5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;AMPL seems to be treating 1..5 as a string rather than as an sequence of integers. Why, and how do I fix it?&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-03T04:07:21.787" Title="Declare numerical-sequence set in AMPL .dat file" Tags="|ampl|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="154" PostTypeId="5" CreationDate="2019-06-03T01:31:31.140" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-03T01:31:31.140" LastActivityDate="2019-06-03T01:31:31.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="155" PostTypeId="4" CreationDate="2019-06-03T01:31:31.140" Score="0" Body="For questions related to optimization problems for routing vehicles through a set of nodes, especially the vehicle routing problem (VRP) and its variants." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-03T19:03:15.927" LastActivityDate="2019-06-03T19:03:15.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="156" PostTypeId="5" CreationDate="2019-06-03T01:33:03.770" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-03T01:33:03.770" LastActivityDate="2019-06-03T01:33:03.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="157" PostTypeId="4" CreationDate="2019-06-03T01:33:03.770" Score="0" Body="For questions related to the traveling salesman problem (TSP), which seeks, for a given set of nodes, the shortest path that visits every node and returns to the starting node." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-03T19:03:32.970" LastActivityDate="2019-06-03T19:03:32.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="158" PostTypeId="5" CreationDate="2019-06-03T01:57:23.603" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-03T01:57:23.603" LastActivityDate="2019-06-03T01:57:23.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="159" PostTypeId="4" CreationDate="2019-06-03T01:57:23.603" Score="0" Body="For questions related to NEOS, the free internet-based service for solving numerical optimization problems that is hosted by the Wisconsin Institute for Discovery at the University of Wisconsin in Madison." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-03T19:03:03.463" LastActivityDate="2019-06-03T19:03:03.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="160" PostTypeId="2" ParentId="153" CreationDate="2019-06-03T01:58:13.913" Score="4" Body="&lt;p&gt;The &lt;code&gt;..&lt;/code&gt; operator cannot be used in the data section (i.e. it won't be expanded, see &lt;a href=&quot;https://ampl.com/faqs/why-does-set-s-50-70-give-me-a-set-of-only-3-members&quot; rel=&quot;nofollow noreferrer&quot;&gt;the AMPL FAQ&lt;/a&gt;). What you can do is to declare the limits in the model, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;param n;&#xA;set things := 1..n;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and define them in the data file &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;param n := 5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-03T04:07:21.787" LastActivityDate="2019-06-03T04:07:21.787" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="161" PostTypeId="5" CreationDate="2019-06-03T01:58:17.290" Score="0" Body="&lt;p&gt;AMPL, an acronym for &lt;em&gt;A Mathematical Programming Language&lt;/em&gt;, is an algebraic modeling language for describing and solving high-complexity problems for large-scale mathematical computation (i.e. large-scale optimization and scheduling-type problems).&lt;/p&gt;&#xA;&lt;p&gt;AMPL supports a wide range of problems such as linear, quadratic and nonlinear problems in continuous and discrete variables and is connected to dozens of solvers, both open source and commercial, including CBC, CPLEX, FortMP, Gurobi, MINOS, IPOPT, SNOPT and KNITRO.&lt;/p&gt;&#xA;&lt;p&gt;Further information is available at the &lt;a href=&quot;http://www.ampl.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;official AMPL homepage&lt;/a&gt; and the &lt;a href=&quot;http://en.wikipedia.org/wiki/AMPL&quot; rel=&quot;nofollow noreferrer&quot;&gt;AMPL Wikipedia page&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="123" LastEditDate="2020-08-19T13:58:41.050" LastActivityDate="2020-08-19T13:58:41.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="162" PostTypeId="4" CreationDate="2019-06-03T01:58:17.290" Score="0" Body="For questions related to the algebraic modeling language AMPL. " OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-03T19:03:56.860" LastActivityDate="2019-06-03T19:03:56.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="163" PostTypeId="2" ParentId="76" CreationDate="2019-06-03T03:30:15.227" Score="13" Body="&lt;p&gt;These are know as &quot;indicator constraints&quot; or &quot;on/off&quot; constraints. The best formulation is the convex-hull one, it includes the optimal big-M value plus additional non-redundant constraints, here's a &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2014/04/4309.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;note characterizing this formulation&lt;/a&gt;. There's also a generalization for convex nonlinear &quot;on/off&quot; constraints &lt;a href=&quot;https://link.springer.com/article/10.1007/s10589-011-9424-0&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and recent extensions &lt;a href=&quot;https://link.springer.com/article/10.1007/s10589-016-9847-8&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="289" LastEditorUserId="123" LastEditDate="2019-10-14T10:03:34.877" LastActivityDate="2019-10-14T10:03:34.877" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="164" PostTypeId="1" CreationDate="2019-06-03T03:52:16.890" Score="9" ViewCount="222" Body="&lt;p&gt;For an evolutionary &lt;a href=&quot;https://en.wikipedia.org/wiki/Extensive-form_game&quot; rel=&quot;nofollow noreferrer&quot;&gt;extensive form game&lt;/a&gt; is the use of &lt;a href=&quot;https://en.wikipedia.org/wiki/Multi-agent_system&quot; rel=&quot;nofollow noreferrer&quot;&gt;multi-agent systems&lt;/a&gt; a necessity or can more traditional approximate Nash equilibria and mean-field interactions suffice?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Few games can be &lt;a href=&quot;https://plato.stanford.edu/entries/game-theory/#PD&quot; rel=&quot;nofollow noreferrer&quot;&gt;represented completely&lt;/a&gt; by a simple tree and solved exactly from the outset, or even to the point where a direction to the course can be established. Often there are too many players whom don't utilize an expected strategy, usually the &lt;em&gt;rules&lt;/em&gt; are often not completely know or evolving as new things come into play.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example where the rules are simple but there's no strategy is &lt;a href=&quot;https://en.wikipedia.org/wiki/Matching_pennies&quot; rel=&quot;nofollow noreferrer&quot;&gt;matching pennies&lt;/a&gt;, and an example where there are &lt;em&gt;expected&lt;/em&gt; rules which aren't necessarily always followed is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Coordination_game&quot; rel=&quot;nofollow noreferrer&quot;&gt;coordination game&lt;/a&gt;. In more realistic examples nothing is so simple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Realistic games have a long time horizon, partially-observed state, and high-dimensional, continuous action and observational space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This makes choosing a specific &lt;a href=&quot;https://en.wikipedia.org/wiki/Strategy_(game_theory)&quot; rel=&quot;nofollow noreferrer&quot;&gt;strategy&lt;/a&gt; difficult if not impossible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example relevant to this question is: In &lt;a href=&quot;https://openai.com/blog/openai-five/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dota 2&lt;/a&gt; agents were &lt;a href=&quot;https://openai.com/blog/competitive-self-play/&quot; rel=&quot;nofollow noreferrer&quot;&gt;trained to play against themselves&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an interesting Q&amp;amp;A on Stats.SE titled: &quot;&lt;a href=&quot;https://stats.stackexchange.com/q/6/197829&quot;&gt;The Two Cultures: statistics vs. machine learning?&lt;/a&gt;&quot; which contains a few excellent points:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;Methodological Statistics papers are still overwhelmingly formal and deductive, whereas Machine Learning researchers are more tolerant of new approaches even if they don't come with a proof attached.&quot;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;The biggest difference I see between the communities is that statistics emphasizes inference, whereas machine learning emphasized prediction. When you do statistics, you want to infer the process by which data you have was generated. When you do machine learning, you want to know how you can predict what future data will look like w.r.t. some variable.&quot;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Ken_Thompson&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ken Thompson&lt;/a&gt; quote: ''&lt;a href=&quot;https://en.wikiquote.org/wiki/Ken_Thompson#Quotes&quot; rel=&quot;nofollow noreferrer&quot;&gt;When in doubt, use brute force&lt;/a&gt;''.&lt;br&gt;&#xA;In this case, machine learning is a salvation when the assumptions are hard to catch; or at least it is much better than guessing them wrong.&quot;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(Phrased differently) Without asking a new question (the only question asked is in the first sentence), at what point are agents beyond using explicit calculations and their proofs and we are better off letting the program write its own equations (learn the questions to ask, and how to solve them)? There's a couple of examples below where the program &lt;em&gt;knew&lt;/em&gt; nothing, it's only input was the pixels on the screen (and the score), still it was able to decide what the &lt;em&gt;rules&lt;/em&gt; must be and how best to exploit them; beating human players.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Definition: &lt;a href=&quot;https://en.wikipedia.org/wiki/Approximation_theory&quot; rel=&quot;nofollow noreferrer&quot;&gt;Approximation Theory&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://deepmind.com/blog/alphastar-mastering-real-time-strategy-game-starcraft-ii/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AlphaStar: Mastering the Real-Time Strategy Game StarCraft II&lt;/a&gt;&quot;, article by the AlphaStar and DeepMind teams.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;AlphaStar interacted with the StarCraft game engine directly via its raw interface, meaning that it could observe the attributes of its own and its opponent’s visible units on the map directly, without having to move the camera - effectively playing with a zoomed out view of the game. ... its neural network architecture is capable of modelling very long sequences of likely actions - with games often lasting up to an hour with tens of thousands of moves - based on imperfect information. Each frame of StarCraft is used as one step of input, with the neural network predicting the expected sequence of actions for the rest of the game after every frame.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://science.sciencemag.org/content/364/6443/859&quot; rel=&quot;nofollow noreferrer&quot;&gt;Human-level performance in 3D multiplayer games with population-based reinforcement learning&lt;/a&gt;&quot; (May 31 2019), by Max Jaderberg, Wojciech M. Czarnecki, Iain Dunning, Luke Marris, Guy Lever, Antonio Garcia Castañeda, Charles Beattie, Neil C. Rabinowitz, et al.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Conclusion: In this work, we have demonstrated that an artificial agent using only pixels and game points as input can learn to play highly competitively in a rich multiagent environment: a popular multiplayer first-person video game. This was achieved by combining PBT of agents, internal reward optimization, and temporally hierarchical RL with scalable computational architectures. The presented framework of training populations of agents, each with their own learned rewards, makes minimal assumptions about the game structure and therefore could be applicable for scalable and stable learning in a wide variety of multiagent systems.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://deepmind.com/blog/population-based-training-neural-networks/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Population Based Training of Neural Networks&lt;/a&gt;&quot;, (&lt;a href=&quot;https://arxiv.org/abs/1711.09846&quot; rel=&quot;nofollow noreferrer&quot;&gt;arxiv paper&lt;/a&gt;), (Nov 28 2017), by Max Jaderberg, Valentin Dalibard, Simon Osindero, Wojciech M. Czarnecki, Jeff Donahue, Ali Razavi, Oriol Vinyals, Tim Green, Iain Dunning, Karen Simonyan, Chrisantha Fernando, and Koray Kavukcuoglu&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Conclusions: We have presented Population Based Training, which represents a practical way to augment the standard&#xA;  training of neural network models. We have shown consistent improvements in accuracy, training time and stability across a wide range of domains by being able to optimise over weights and hyperparameters jointly. It is important to note that contrary to conventional hyperparameter optimisation techniques, PBT discovers an adaptive schedule rather than a fixed set of hyperparameters. We already observed significant improvements on a wide range of challenging problems including state of the art models on deep reinforcement learning and hierarchical reinforcement learning, machine translation, and GANs. While there are many improvements and extensions to be explored going forward, we believe that the ability of PBT to enhance the optimisation process of new, unfamiliar models, to adapt to non-stationary learning problems, and to incorporate the optimisation of indirect performance metrics and auxiliary tasks, results in a powerful platform to&#xA;  propel future research.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://arxiv.org/abs/1705.02036&quot; rel=&quot;nofollow noreferrer&quot;&gt;Approximate Nash Equilibria in Partially Observed&#xA;Stochastic Games with Mean-Field Interactions&lt;/a&gt;&quot; (June 5 2018), by Naci Saldi, Tamer Basar, and Maxim Raginsky&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Conclusion This paper has considered discrete-time partially observed mean-field games subject to infinite-horizon discounted cost, for Polish state, observation, and action spaces. Under mild conditions, the existence of a Nash equilibrium has been established for this game model using the conversion of partially observed Markov decision processes to fully observed Markov decision processes in the belief space and then using the dynamic programming principle. We have also established that the mean-field equilibrium policy, when used by each agent, constitutes a nearly Nash equilibrium for games with sufficiently many agents.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The single question I ask is in the first sentence.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="123" LastEditDate="2020-01-18T20:11:07.773" LastActivityDate="2020-01-18T20:11:07.773" Title="For the solution of complex gaming are we to leave behind approximation and fixed algorithms in favor of agents?" Tags="|markov-decision-process|nash-equilibrium|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="165" PostTypeId="5" CreationDate="2019-06-03T04:14:27.890" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-03T04:14:27.890" LastActivityDate="2019-06-03T04:14:27.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="166" PostTypeId="4" CreationDate="2019-06-03T04:14:27.890" Score="0" Body="Questions related to p-median problems, i.e. placing $p$ facilities such that the average distance from demand nodes to the nearest facility is minimal." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-03T19:03:41.423" LastActivityDate="2019-06-03T19:03:41.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="167" PostTypeId="1" AcceptedAnswerId="174" CreationDate="2019-06-03T04:56:07.250" Score="14" ViewCount="1032" Body="&lt;p&gt;Some problems call for a &lt;em&gt;count&lt;/em&gt; of the number of integer &quot;lattice&quot; points contained in a feasible region (rather than for locating the minimum or maximum objective function value in that region).  See for example &lt;a href=&quot;https://stackoverflow.com/questions/1970507/counting-solutions-to-linear-inequalities&quot;&gt;the SO Question &quot;Counting solutions to linear inequalities&quot;&lt;/a&gt; or this &lt;a href=&quot;https://math.stackexchange.com/questions/1192537/uniform-lattice-sample-inside-a-particular-convex-polytope&quot;&gt;previous Math.SE Question &quot;Uniform lattice sample inside a particular convex polytope&quot;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a general proposition this counting is difficult (NP-hard as the corresponding decision problem is NP-complete), but it is sometimes possible to count by writing custom code, as I did for this &lt;a href=&quot;https://scicomp.stackexchange.com/questions/19870/python-solvers-for-mixed-integer-nonlinear-constrained-optimization&quot;&gt;previous SciComp.SE Question &quot;Python solvers for mixed-integer nonlinear constrained optimization&quot;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;What solvers or software packages can be used for the purpose of counting (or estimating the count of) feasible integer solutions?&lt;/em&gt;  My understanding is that &lt;a href=&quot;https://orinanobworld.blogspot.com/2013/01/finding-all-mip-optima-cplex-solution.html&quot; rel=&quot;noreferrer&quot;&gt;the MILP solver CPLEX has an option&lt;/a&gt; to &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.1/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/soln_pool/02_soln_pool_defn.html&quot; rel=&quot;noreferrer&quot;&gt;collect a &quot;solution pool&quot; of the integer portion of feasible points it encounters in a run&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I'd also appreciate a basic example of using this feature to count or estimate the number of feasible points of an ILP.&lt;/em&gt;  Links to such examples would be more helpful if accompanied by a discussion of the limitations or difficulties of that task.  As a comment points out, CPLEX will only report the feasible points it locates during a search for optimizing an objective function, but the number of feasible points is independent of the objective function.  Therefore the sampling in such solution pools is biased and incomplete.  Nevertheless it might be possible to collect a representative sample by varying the objective function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might also be that better tools are available for the purpose, as another comment suggests.&lt;/p&gt;&#xA;" OwnerUserId="78" LastEditorUserId="38" LastEditDate="2019-06-03T20:17:08.883" LastActivityDate="2019-10-27T20:46:26.977" Title="Using CPLEX &quot;solution pool&quot; to count feasible points" Tags="|mixed-integer-programming|feasible-points|cplex|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="168" PostTypeId="1" CreationDate="2019-06-03T07:11:25.923" Score="29" ViewCount="431" Body="&lt;p&gt;When designing optimization models for external organizations, I have witnessed the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;We design an optimization model for a given problem.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We fine-tune it based on a portfolio of representative instances.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The model starts being used in production, it behaves well, providing good solutions in a reasonable time.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Over time, the business of the external organization changes, making the portfolio of instances that was used for the fine-tuning no longer representative. The results are now of much lower quality or the optimization takes much too long.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Silently the model stops being used.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Which approaches do you use to avoid having the model no longer fit the problem it is trying to solve?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am mostly interested in approaches that can be applied both to exact solution methods as to heuristic solution methods.&lt;/p&gt;&#xA;" OwnerUserId="124" LastEditorUserId="47" LastEditDate="2019-06-05T12:47:25.953" LastActivityDate="2019-06-05T12:47:25.953" Title="How to avoid having your optimization models rusting?" Tags="|optimization|software|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="169" PostTypeId="2" ParentId="52" CreationDate="2019-06-03T07:27:41.860" Score="12" Body="&lt;p&gt;Since branching rules are crucial for the performance of solvers they are also a very well guarded secret. I can say from experience that some form of reliability branching is sufficient to get a reasonable solver performance (not top of the class though). The devil is in the detail then because there are a ton of different ways of updating the pseudo-costs used in reliability branching (see reference to Tobias Achterbergs thesis and his paper Branching Rule Revisited). I am not aware of an overview paper that really describes all of this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, a problem specific branching strategy should work better (if it is indeed clever) than the generic strategy implemented by the major solvers. Of course this only holds, if the solvers are not already doing great on a class of instances. In a a sense there is a certain minimum number of nodes that need to be processed for some problems, if a solver is already close to that, one can't expect huge improvements. On the other hand, if solvers are doing bad on a class of instances, chances are that a clever specialized strategy can yield huge benefits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example for that is Orbital Branching (Ostrowsky et al.) that identified a class of problems solvers did bad on and found a better strategy to deal with this specific class of problems. And it provided a fairly easy to implement way of doing this that did not disturb too many other parts of the solvers.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2019-06-03T07:27:41.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="170" PostTypeId="2" ParentId="168" CreationDate="2019-06-03T07:37:30.280" Score="5" Body="&lt;ul&gt;&#xA;&lt;li&gt;If you have the optimizer run server-side with a web API, then you can easily track how often a problem is sent. Since you are not actually storing the problem data (which may though be relevant in order to improve performance and stay up to date, but that's another question), this should not raise any flags in that company. In fact, they may themselves want to use this as a KPI to see what's going on.&lt;/li&gt;&#xA;&lt;li&gt;If you have a desktop application, it depends how it is deployed. I write a lot of apps in C# and use &quot;One-Click&quot; applications, which update automatically when a new version is available. You could write a method that, whenever an update is performed, logs that somewhere. So you can see how many people update to the latest version.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To summarize, it depends on how the application is deployed, but in general I would try to find a measurable proxy for usage. Also, coordinate this with the external company, because IMO they should also be interested in knowing this.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-06-03T07:37:30.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="172" PostTypeId="2" ParentId="167" CreationDate="2019-06-03T07:45:51.607" Score="14" Body="&lt;p&gt;The only way (to my knowledge) to get all feasible points for the binary components of a MIP is as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Solve the problem. Let &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; denote the optimal solution&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add the following integer cut to your model:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{j\in J}y_j - \sum_{t\in T}y_t \leq |J|-1&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; is the set of indices where &lt;span class=&quot;math-container&quot;&gt;$y_j = 1$&lt;/span&gt;, i.e. &lt;span class=&quot;math-container&quot;&gt;$J = \{j\mid y_j = 1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is the set of indices where &lt;span class=&quot;math-container&quot;&gt;$y_j = 0$&lt;/span&gt;, i.e. &lt;span class=&quot;math-container&quot;&gt;$T = \{t\mid y_t = 0\}$&lt;/span&gt;. This will  exclude the found solution from the MIP.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Resolve the model, and add another integer cut.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Repeat until the model becomes infeasible. The number of integer cuts added is the number of feasible binaries in your problem.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="133" LastEditorUserId="123" LastEditDate="2019-10-27T13:42:43.357" LastActivityDate="2019-10-27T13:42:43.357" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="173" PostTypeId="2" ParentId="168" CreationDate="2019-06-03T07:46:03.123" Score="21" Body="&lt;p&gt;I am in a similar situation, where we mainly solve this by providing the servers on which the algorithms are running. This allows us to frequently monitor the input data and solutions, as well as the user behavior (is the user frequently optimizing and then re-optimizing with some other parameters). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This applies to both exact methods and heuristics. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior often starts to deteriorate when &quot;a given problem&quot; starts to become &quot;a related problem&quot; (as you note in 4). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we see that clients are almost never running optimization jobs, then we can start to investigate why and maybe even sit down with them and discuss this. It could be that they want simple changes to the problem/algorithm in which case it can be easy to turn a loss into a win. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often the assumptions made when developing the algorithm have changed (business logic, organisational changes, humans), leaving the algorithm to perform poorly/not solving the problem.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To boil it down, we solve it (with some degree of succes) to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Monitor the usage of the algorithm and collect data/statistics&lt;/li&gt;&#xA;&lt;li&gt;Dialogue with the end-users and monthly/quarterly status&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am guessing that a lot of Machine Learning code put into production could suffer the same fate as you describe. It might be a place to get good ideas (mental note for myself as well, as I am not an expert on that part)&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2019-06-03T07:46:03.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="174" PostTypeId="2" ParentId="167" CreationDate="2019-06-03T07:48:34.057" Score="14" Body="&lt;p&gt;@prubin has this neat (possibly slightly dated) series of blog posts, &lt;a href=&quot;https://orinanobworld.blogspot.com/2013/01/finding-all-solutions-or-not.html&quot; rel=&quot;noreferrer&quot;&gt;Finding All Solutions (or Not)&lt;/a&gt;, &lt;a href=&quot;https://orinanobworld.blogspot.com/2013/01/finding-all-mip-optima-cplex-solution.html&quot; rel=&quot;noreferrer&quot;&gt;Finding &quot;All&quot; MIP Optima: The CPLEX Solution Pool&lt;/a&gt; &lt;a href=&quot;https://orinanobworld.blogspot.com/2013/01/solution-pool-all-is-not-all.html&quot; rel=&quot;noreferrer&quot;&gt;Solution Pool: &quot;All&quot; Is Not All&lt;/a&gt;, which deals with the hassle of collection all MIP solutions in CPLEX's solution pool.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While this doesn't exactly answer your question, it still might provide helpful insights where to start -- and which problems to expect.&lt;/p&gt;&#xA;" OwnerUserId="138" LastEditorUserId="138" LastEditDate="2019-06-03T08:16:37.220" LastActivityDate="2019-06-03T08:16:37.220" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="175" PostTypeId="2" ParentId="117" CreationDate="2019-06-03T08:06:55.810" Score="13" Body="&lt;p&gt;The &lt;a href=&quot;https://aimms.com/english/developers/resources/manuals/optimization-modeling&quot; rel=&quot;noreferrer&quot;&gt;AIMMS Optimization Modeling book&lt;/a&gt; is freely available and very accessible. There are lots of worked examples going from problem description to example data and model formulation.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-06-03T08:06:55.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="176" PostTypeId="1" AcceptedAnswerId="178" CreationDate="2019-06-03T08:14:28.870" Score="29" ViewCount="7347" Body="&lt;p&gt;At first glance both approaches appear to be very similar. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the major differences between integer programming and constraint programming?&lt;/p&gt;&#xA;" OwnerUserId="81" LastEditorUserId="491" LastEditDate="2019-12-05T13:17:01.480" LastActivityDate="2019-12-06T21:00:42.577" Title="What is the difference between integer programming and constraint programming?" Tags="|constraint|integer-programming|logical-constraints|constraint-programming|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="178" PostTypeId="2" ParentId="176" CreationDate="2019-06-03T12:57:54.250" Score="19" Body="&lt;p&gt;You have asked a broad question, so I will provide a broad answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Integer programming&lt;/em&gt;&lt;/strong&gt; typically refers to integer linear programming which is a mathematical modeling and solution paradigm. Decisions are modeled as a vector of real numbers, some of which are further constrained to take only integer values. The decision vector is constrained to satisfy a system of linear inequalities. A single objective function is to be minimized which is again linear in the decision vector. Very often certain decision variables are constrained to take &lt;span class=&quot;math-container&quot;&gt;$\{0,1\}$&lt;/span&gt; values to model logical constraints. Linear integer programming optimization models are solved by taking advantage of lower bounds found by solving linear programming problems in &lt;em&gt;branch-and-bound&lt;/em&gt; and &lt;em&gt;branch-and-cut&lt;/em&gt; algorithms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know less about &lt;strong&gt;&lt;em&gt;constraint programming&lt;/em&gt;&lt;/strong&gt; but it is a slightly different modeling and solution paradigm. Again decision variables are defined and each is specified on a domain; the domains used in practice are similar to those used in integer programming models. A set of constraints is defined on the decision variables and these constraints can be more general than those used in integer programming to allow direct modeling of logical constraints. The primary constraint programming problem is to find a decision vector that satisfies all constraints. &lt;em&gt;Constraint propagation&lt;/em&gt; methods are used to identify such solutions (if they exist). Some constraint programming solvers also allow objective functions to be specified, and after feasible solutions are identified they seek those with better objective function values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For many important problems, a natural integer programming formulation can be an excellent model and useful for finding optimal or near-optimal solutions. In other cases, the generality provided by constraint programming modeling may be a better choice and may identify high-quality solutions faster than an equivalent IP model. Knowing when to choose which toolkit for particular problem is an &lt;em&gt;engineering skill&lt;/em&gt; and the right choice may change over time as both fields continue to evolve.&lt;/p&gt;&#xA;" OwnerUserId="105" LastActivityDate="2019-06-03T12:57:54.250" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="179" PostTypeId="1" CreationDate="2019-06-03T13:24:09.083" Score="16" ViewCount="558" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\newcommand{\E}{\mathbb{E}}$&lt;/span&gt;I am working on numerical algorithms for solving convex large-scale multistage scenario-based problems and I am looking for some standard benchmarks problems. I have so far worked with scenario trees generated from data, but I wonder whether there are some standard problems. I would be particularly interested in problems in the general area of economics or some interesting engineering application.&lt;/p&gt;&#xA;&lt;p&gt;I am referring to problems in the general form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_{u_0 \in U_0} \E_{\mid 0} \bigg[\ell_0(x_0, u_0, w_0) +&amp;amp; \inf_{u_1 \in U_1} \E_{\mid 1}\Big[\ell_0(x_1, u_1, w_1) + \ldots  \\&#xA;+&amp;amp;\inf_{u_{N-1}\in U_{N-1}} \E_{\mid N-1}[\ell_{N}(x_N)]\cdots \Big]\bigg],&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to &lt;span class=&quot;math-container&quot;&gt;$x_{t+1} = f(x_t, u_t, w_t)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is linear in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; is convex in its first two arguments, &lt;span class=&quot;math-container&quot;&gt;$(w_t)$&lt;/span&gt; is a random process whose evolution is described by a scenario tree (I will omit a detailed description here) and &lt;span class=&quot;math-container&quot;&gt;$\E_{|t}$&lt;/span&gt; denotes the conditional expectation which is conditioned with the information that is available up to stage (time) &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; [this is properly defined using the natural filtration of &lt;span class=&quot;math-container&quot;&gt;$(w_t)_t$&lt;/span&gt;].&lt;/p&gt;&#xA;&lt;p&gt;I have seen such problems in the area of energy distribution management, but in most cases these involve binary variables (which correspond to the switching of generators), but I'm looking for problems without binaries.&lt;/p&gt;&#xA;" OwnerUserId="70" LastEditorUserId="123" LastEditDate="2022-04-29T12:41:57.660" LastActivityDate="2022-04-29T12:41:57.660" Title="Benchmark problems for scenario-based stochastic optimization" Tags="|optimization|stochastic-programming|online-resources|benchmark|test-instances|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="180" PostTypeId="1" AcceptedAnswerId="181" CreationDate="2019-06-03T14:54:25.090" Score="15" ViewCount="7980" Body="&lt;p&gt;Suppose we have two variables &lt;span class=&quot;math-container&quot;&gt;$x, y \in \mathbb R$&lt;/span&gt;. How can we linearize the product &lt;span class=&quot;math-container&quot;&gt;$xy$&lt;/span&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this cannot be done exactly, is there a way to get an approximate result?&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-06-06T08:50:38.170" LastActivityDate="2019-10-13T13:14:32.140" Title="How to linearize the product of two continuous variables?" Tags="|linear-programming|linearization|nonlinear-programming|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="181" PostTypeId="2" ParentId="180" CreationDate="2019-06-03T15:01:13.250" Score="10" Body="&lt;p&gt;As far as I know, there is no true way to linearize such constraints, as also stated in &lt;a href=&quot;https://or.stackexchange.com/a/187/71&quot;&gt;the answer&lt;/a&gt; given by &lt;a href=&quot;https://or.stackexchange.com/users/214/michael-trick&quot;&gt;Michael Trick&lt;/a&gt;. Let us therefore consider a piecewise linear approximation of the constraint &lt;span class=&quot;math-container&quot;&gt;$x_1 x_2 \geq b$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2 \in \mathbb R$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a given constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The method discussed in this answer is introduced in the &lt;a href=&quot;https://download.aimms.com/aimms/download/manuals/AIMMS3OM_IntegerProgrammingTricks.pdf&quot; rel=&quot;noreferrer&quot;&gt;AIMMS Modelling Guide&lt;/a&gt; in section 7.7 on page 85.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The method introduces two new variables&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;y_1 &amp;amp;= 0.5(x_1 + x_2),\\&#xA;y_2 &amp;amp;= 0.5(x_1 - x_2).&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Now we can rewrite the constraint &lt;span class=&quot;math-container&quot;&gt;$x_1x_2 \geq b$&lt;/span&gt; as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_1^2 - y_2^2 \geq b.$$&lt;/span&gt;&#xA;This is indeed again not a linear constraint, but this constraint can be approximated with piecewise linear approximation techniques (see section 7.6 of the &lt;a href=&quot;https://download.aimms.com/aimms/download/manuals/AIMMS3OM_IntegerProgrammingTricks.pdf&quot; rel=&quot;noreferrer&quot;&gt;AIMMS Modelling Guide&lt;/a&gt;) as the left-hand-side is now a &lt;a href=&quot;https://calculus.subwiki.org/wiki/Additively_separable_function&quot; rel=&quot;noreferrer&quot;&gt;separable function&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-06-05T16:49:23.410" LastActivityDate="2019-06-05T16:49:23.410" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="182" PostTypeId="2" ParentId="143" CreationDate="2019-06-03T15:21:40.407" Score="11" Body="&lt;p&gt;I will give you a little more insight based on my latest experience solving minimax (or maximin) integer programs. Sorry I will be a bit self-citing here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, the main reason that can explain the poor behavior of commercial solvers for solving those types of problems is the strong dependence on a single (or a very few) variable for the solution. In &lt;em&gt;p-centre problems&lt;/em&gt;, it is the distance from the furthest node to its closest center. If you think a little, you will realize that a large number of the nodes are only noise and do not play any role in the optimization. Thus, the linear relaxation tends to behave poorly because the cost will tend to be split among several variables. In addition, the number of symmetries can be unreasonably large (for a given centre, there might be exponentially many possible assignments with the same cost), which is deadly for branch-and-bound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I will argue that your point is not TOTALLY true. While plugging a minimax integer model into CPLEX or Gurobi can be a bad idea, there has been some recent research aiming at exploiting the issues described in the paragraph above and exploit them. Think of the p-centre problem. If you KNOW that a lot of points are only noise, why consider them? Chen &amp;amp; Chen (2009) showed that a decremental relaxation algorithm can be used to discard points that are deemed noisy. One then can solve the noise-free problem (small) and later assess whether this partial solution can be extended to a solution of the whole problem, which can be done very efficiently. Contardo, Iori and Kramer (2019, C&amp;amp;OR) showed that, when implemented correctly, and with the addition of a few acceleration mechanisms, problems containing up to 1M points can be solved to proven optimality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The minimax diameter clustering problem (MMDCP) has a similar structure. In the MMDCP, one is given a set of &lt;em&gt;n&lt;/em&gt; points, a dissimilarity matrix &lt;em&gt;D&lt;/em&gt; and an integer &lt;em&gt;k&lt;/em&gt;. One seeks to determine &lt;em&gt;k&lt;/em&gt; clusters in such a way that the maximum distance between any two points within the same cluster, is minimized. This problem is NP-hard and problems with only a few thousand nodes could be handled by commercial solvers. Aloise and Contardo (2018, JOGO) showed that indeed a similar mechanism to the one used for the p-centre problem can be devised to sample points in an iterative manner. Problems with up to 600k can be solved to proven optimality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few months ago I came up with a similar mechanism for discrete p-dispersion problems (pDP). In the pDP, one is given &lt;em&gt;n&lt;/em&gt; points, a dissimilarity matrix &lt;em&gt;D&lt;/em&gt; and an integer &lt;em&gt;p&lt;/em&gt;. The objective is to select &lt;em&gt;p&lt;/em&gt; points such that the minimum distance between any pair of selected points is maximized. I devised a clustering mechanism to reduce this problem to a series of smaller pDPs. Problems containing up to 100k nodes can be solved to proven optimality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here is my final opinion: If ever faced to a large-scale minimax (or maximin) integer problem, spend your time thinking on how to reduce that problem to the solution of smaller problems, so as to reduce the noise that makes you problem hard and with a high degree of symmetry. Then devise an algorithm to exploit those observations in an iterative manner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Chen &amp;amp; Chen (2009), New relaxation-based algorithms for the optimal solution of the continuous and discrete p-center problems. C&amp;amp;OR. Can be downloaded from &lt;a href=&quot;https://www.tau.ac.il/~chenr&quot; rel=&quot;nofollow noreferrer&quot;&gt;R Chen's website&lt;/a&gt; for free&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Aloise &amp;amp; Contardo (2018), A sampling-based exact algorithm for the solution of the minimax diameter clustering problem, JOGO&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Contardo, Iori &amp;amp; Kramer (2019), A scalable exact algorithm for the vertex p-center problem, C&amp;amp;OR&lt;/li&gt;&#xA;&lt;li&gt;Contardo (2019), Decremental clustering for the solution of p-dispersion problems to proven optimality. &lt;a href=&quot;https://www.gerad.ca/en/papers/G-2019-22&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cahier du GERAD G-2019-22&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="86" LastEditorUserId="123" LastEditDate="2020-02-04T19:47:22.470" LastActivityDate="2020-02-04T19:47:22.470" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="183" PostTypeId="1" AcceptedAnswerId="197" CreationDate="2019-06-03T15:38:40.980" Score="24" ViewCount="1067" Body="&lt;p&gt;Exact methods, e.g., models that utilize an MIP approach with a specified objective and constraints, have advantages like the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using off the shelf solvers&lt;/li&gt;&#xA;&lt;li&gt;Optimality gap provability&lt;/li&gt;&#xA;&lt;li&gt;Modelling approaches for domain problems is well understood&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Reinforcement Learning (RL) presents the opportunity to train a model and then have it &quot;predict&quot; a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why would you use this method?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the effectiveness of this as a methodology?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It &lt;em&gt;may&lt;/em&gt; be possible to get &quot;better&quot; solutions in less compute time given a pre-trained model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is any one else working on this type of approach? Or have references?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Specifically for solving network flow and assignment problems on graphs.)&lt;/p&gt;&#xA;" OwnerUserId="259" LastEditorUserId="38" LastEditDate="2019-06-06T02:07:38.943" LastActivityDate="2019-10-14T10:17:33.397" Title="What are the tradeoffs between &quot;exact&quot; and Reinforcement Learning methods for solving optimization problems" Tags="|mixed-integer-programming|graphs|reinforcement-learning|machine-learning|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="184" PostTypeId="2" ParentId="168" CreationDate="2019-06-03T16:04:29.580" Score="19" Body="&lt;p&gt;Here are a couple lessons I've learned over the years on this problem. This is in addition to Tue Christensen's answer--there are lots of reasons your problem can &quot;rust.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, if you can formulate the problem as an LP/MIP, rather than custom algorithm or heuristic, you'll be able to take advantage of commercial solvers.  It doesn't take many years for commercial solvers to get 10X faster.  A while ago, we built a Lagrangian Relaxation algorithm approach to solve a particular problem.  At the time, it was much better than the commercial tools.  However, in several years, that wasn't the case.  Our algorithm didn't get much faster, the commercial tools did.  This helps prevent slowdowns if you can keep the solver refreshed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, if you did formulate as an LP/MIP, it will be easier to allow the user to add side constraints or increase the size of the model.  With a commercial solver, you'll have a better chance of the model evolving with the user and still be able to solve. In the above example, adding a side constraint to our Lagrangian Relaxation approach just didn't work at all.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, with the second idea, you have to prevent your user from getting in trouble-- like by creating 10X more integer variables.  &lt;/p&gt;&#xA;" OwnerUserId="191" LastActivityDate="2019-06-03T16:04:29.580" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="185" PostTypeId="1" AcceptedAnswerId="234" CreationDate="2019-06-03T16:45:04.603" Score="23" ViewCount="729" Body="&lt;p&gt;Combinatorial Benders decomposition is a mathematical programming technique consisting into dividing a problem into a master problem and a sub problem.&#xA;The master problem is solved to optimality (or alternatively for a MIP, every time a potential new best solution is identified while branching) and then the associated subproblem is solved. If the subproblem is feasible then the solution of the master problem is a (optimal) solution to the original problem. Otherwise a new constraint is added to the master problem to cut the current solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of this could be the following (even though I would guess that the results would be quite deceiving):&#xA;If our original problem is the Capacitated Vehicle Routing Problem, a way to solve it using Benders decomposition would be to use the VRP as a master problem and in the subproblem to check that each vehicle respects its capacity constraints. If the capacity constraints are not respected we add a constraint stating that at least one arc used in the current (master problem) solution cannot be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to be able to successfully use this solution method, what are some characteristics that the original problem should display?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the felling that the subproblem should not be too constraining (in the sense, that for an arbitrary solution of the master problem there should be a good chance that the subproblem is feasible), but would be interested by any data backing (or refuting) this up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; One of the comments of @Michael Trick made me realise that there exist more variation of Benders decomposition than I was aware of. For clarification purposes I was referring to Combinatorial Benders decomposition .&lt;/p&gt;&#xA;" OwnerUserId="124" LastEditorUserId="87" LastEditDate="2019-06-14T23:22:11.273" LastActivityDate="2019-06-17T20:05:05.350" Title="How to determine if a given problem seems to be a good fit to be solved using combinatorial Benders decomposition" Tags="|optimization|modeling|benders-decomposition|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="186" PostTypeId="2" ParentId="185" CreationDate="2019-06-03T17:04:50.327" Score="9" Body="&lt;p&gt;Most importantly, you need to define a subproblem that you can solve as LP without violating integrality constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In many mixed integer programs, it is not possible/sensible to find a subproblem that can be written as LP without relaxing original constraints on integrality of variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is even better if that subproblem (or its dual, which is more interesting in this case) can be solved &quot;by inspection&quot;, rather than really using an LP solver because this usually speeds up things a lot. This means that fixing the master variables, the subproblem is a trivial problem whose solution can be derived by simple calculation.&lt;/p&gt;&#xA;" OwnerUserId="50" LastActivityDate="2019-06-03T17:04:50.327" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="187" PostTypeId="2" ParentId="180" CreationDate="2019-06-03T17:41:28.640" Score="12" Body="&lt;p&gt;Unlike cases where one or both of the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are binary, you won't be able to truly (i.e. exactly) linearize this.  &lt;a href=&quot;https://stackoverflow.com/questions/49021401/how-to-linearize-the-product-of-two-float-variables&quot;&gt;https://stackoverflow.com/questions/49021401/how-to-linearize-the-product-of-two-float-variables&lt;/a&gt; goes through the approximation approach to this issue.&lt;/p&gt;&#xA;" OwnerUserId="214" LastActivityDate="2019-06-03T17:41:28.640" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="188" PostTypeId="2" ParentId="185" CreationDate="2019-06-03T18:50:56.443" Score="11" Body="&lt;p&gt;My way of understanding (Benders) decomposition is that you rather solve (two) separate problems repeatedly than your original problem once. One of the two subproblems has to be resolved with an increasing number of inequalities, derived from some &quot;dual&quot; information of the other subproblem; while the second problem usually is solved for some variable values fixed from the solution of the first subproblem. The first subproblem is usually called the master problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to answer your question, in order to determine if a problem is fit to be solved using Benders decomposition you need to identify in your problem the partition in constraints/variables such that you can have two subproblems that satisfy the following conditions.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;(Master) subproblem: Can be efficiently solved, and can accommodate extra linear inequalities (Benders cuts). This is usually the case with a well structured MIP.&lt;/li&gt;&#xA;&lt;li&gt;Subproblem: Arises when fixing some variables given by the Master subproblem's solution, can be efficiently solved, and you can obtain an optimality proof to derive the cuts. In this case, you do not need to have a linear program, meaning that you can use other methods to efficiently solve the problem.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;A final note that you should take into account. The Benders cuts are there to approximate the feasible region of the second subproblem using linear inequalities, such that they inform the master problem about violations or suboptimalities that come from this subproblem. The inequalities can be seen as outer-approximation of the feasible region of the subproblem. For instance, if the subproblem's feasible region in nonconvex and the outer-approximations cut off parts of that feasible region Benders decomposition is not guaranteed to converge.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2019-06-03T18:50:56.443" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="189" PostTypeId="1" AcceptedAnswerId="439" CreationDate="2019-06-03T19:03:35.843" Score="11" ViewCount="256" Body="&lt;p&gt;The question here arises from the fact that we currently have two options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.optimization-online.org/&quot; rel=&quot;noreferrer&quot;&gt;Optimization Online&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arxiv.org/list/math.OC/current&quot; rel=&quot;noreferrer&quot;&gt;ArXiv&lt;/a&gt; Optimization and control&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Which advantages does each one of them (and others if not included) provide? OO is provided by the Mathematical Optimization Society, while ArXiv is provided by Cornell University.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2019-06-04T05:14:20.163" LastActivityDate="2019-06-16T05:06:31.030" Title="Which advantages do the manuscript repositories for our community have?" Tags="|open-source|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="190" PostTypeId="1" CreationDate="2019-06-03T19:09:54.880" Score="10" ViewCount="248" Body="&lt;p&gt;I've regularly encountered that there are too many constraints to categorize into just hard and soft constraints. For example: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Physical constraints (very hard), e.g. 1 person can only be at 1 spot at the same time&lt;/li&gt;&#xA;&lt;li&gt;Legal constraints (hard), e.g. 1 person can only do 1 shift per day&lt;/li&gt;&#xA;&lt;li&gt;Unassigned constraints (less hard), e.g. each shift must be assigned (broken during overconstrained planning)&lt;/li&gt;&#xA;&lt;li&gt;Non-disruptive constraints (even less hard), e.g. don't change the schedule unless it's to avoid breaking harder constraints given the input change&lt;/li&gt;&#xA;&lt;li&gt;Monetary constraints (soft), e.g. fuel consumption in VRP&lt;/li&gt;&#xA;&lt;li&gt;Fairness constraints (very soft or less soft depending on enterprise or government case), e.g. distribution of total workload per employee&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Obviously, physical constraints can't be broken. Legal constraints can't be broken either - unless of course you risk people dying (unassigned shifts in intensive care). And the lower hard constraints shouldn't be broken normally either, but it does happen... so I prefer to call those &lt;em&gt;medium&lt;/em&gt; constraints.&#xA;In any case, there's clear priority between these constraint &lt;em&gt;levels&lt;/em&gt; - and still each level (such as monetary constraints) might have multiple normally weighted constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One common way I've seen in the literature to deal with such cases is &lt;strong&gt;to multiply the priority constraint by a big weight and add it into the fitness function alongside the lower priority constraint&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What is the canonical name of this practice?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've started calling this practice &lt;em&gt;Score Folding&lt;/em&gt; in the &lt;a href=&quot;https://www.optaplanner.org/&quot; rel=&quot;noreferrer&quot;&gt;OptaPlanner&lt;/a&gt; manual, but I've not seen that term used anywhere else, so I am wondering if there's a consensus for it that I should use instead.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that I am not a fan of Scoring Folding, to say the least. I've introduced for multi score level support a decade ago, to avoid it, as the big weight can easily cause invalid behavior with the wrong dataset, being too big, or too small, or both (even with 64 bit numbers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an illustration: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jqY7a.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jqY7a.png&quot; alt=&quot;score folding&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the example above, we're folding a harder and a softer constraint into the soft score. The harder constraint is the number of CPU too little. The softer constraint is the maintenance price of each computer.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2019-06-04T19:28:30.157" LastActivityDate="2019-10-14T10:16:35.223" Title="Is there a canonical name for Score Folding (multiplying a priority soft constraint by a big weight)?" Tags="|constraint|reference-request|penalty-based-optimization|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="191" PostTypeId="2" ParentId="36" CreationDate="2019-06-03T19:30:13.020" Score="8" Body="&lt;p&gt;These common neighborhoods for TSP/VRP might be useful:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;2-opt, 3-opt, ..., k-opt&lt;/li&gt;&#xA;&lt;li&gt;change 1 visit: remove 1 visit from a chain and insert it somewhere else in a chain&lt;/li&gt;&#xA;&lt;li&gt;swap 2 visits&lt;/li&gt;&#xA;&lt;li&gt;change a subchain of visits: remove a number of sequential visits from a chain and insert it somewhere else in a chain, sometimes reversed&lt;/li&gt;&#xA;&lt;li&gt;swap 2 subchains&lt;/li&gt;&#xA;&lt;li&gt;ruin&amp;amp;recreate&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="350" LastActivityDate="2019-06-03T19:30:13.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="192" PostTypeId="1" AcceptedAnswerId="489" CreationDate="2019-06-03T20:51:04.393" Score="13" ViewCount="268" Body="&lt;h2&gt;Setup&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have a binary &lt;span class=&quot;math-container&quot;&gt;$N \times N$&lt;/span&gt; matrix. The objective is to minimize the number of ones in the matrix, subject to various constraints. This leads to symmetries by rotating 90 degrees and/or mirroring (along the axis and diagonals). Here's an example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kwyyi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kwyyi.png&quot; alt=&quot;8x8 matrix example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the objective function, this matrix has the same objective value as a rotated or mirrored copy of the same matrix. The model performance improves if I add symmetry-breaking constraints, especially on infeasible instances. I sum the quadrants the following way and generate symmetry-breaking constraints:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DUSNJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DUSNJ.png&quot; alt=&quot;Quadrants&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;To account for rotations and mirroring:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$ q_1 \geq q_2 $&lt;/span&gt; (A1)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$ q_1 \geq q_3 $&lt;/span&gt; (A2)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$ q_1 \geq q_4 $&lt;/span&gt; (A3)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;To account for diagonal mirroring:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$ q_2 \geq q_3 $&lt;/span&gt; (B1)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Are there more efficient/simpler alternatives to state the symmetry-breaking constraints, for example with fewer non-zero coefficients?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="69" LastEditDate="2019-06-13T21:54:11.440" LastActivityDate="2019-06-25T15:17:55.097" Title="Symmetry-breaking ILP constraints for square binary matrix" Tags="|integer-programming|modeling|symmetry|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="193" PostTypeId="2" ParentId="168" CreationDate="2019-06-03T21:05:07.397" Score="9" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;This applies to Gurobi: I found that solver parameter tuning rarely helps (apart from picking the right &lt;code&gt;method&lt;/code&gt;) and generally seem to make Gurobi perform worse when confronted with &lt;code&gt;unusual&lt;/code&gt; instances.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Keeping in touch with users helps obviously. Either by talking to people or by collecting logs (if you have the social skills of an OR practitioner ).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When working on a project I usually develop and test multiple formulations and multiple heuristics. For some applications I let all the promising algorithms run concurrently.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In general, I avoid timeouts by always generating a heuristic initial solution and using solvers &quot;only&quot; as solution polishing with time limits.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As a software developer I found that it helps to let users give feedback with the lowest effort possible. This means (A) collecting crash logs, (B) usage statistics and (C) having feedback buttons in your application letting people submit feedback anonymously. There are also several great commercial tools for desktop apps and websites to let you monitor/collect user happiness scores.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It is crucial that you design the interaction patterns in your app. People prefer to do things, instead of just waiting while the optimization is running. For example, you can start optimization even while users are still entering data/constraints in the background. Or you can start early with a suboptimal solution and provide a better solution later. These things obviously depend on the details of your concrete use case.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="69" LastActivityDate="2019-06-03T21:05:07.397" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="194" PostTypeId="5" CreationDate="2019-06-03T21:33:04.280" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-03T21:33:04.280" LastActivityDate="2019-06-03T21:33:04.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="195" PostTypeId="4" CreationDate="2019-06-03T21:33:04.280" Score="0" Body="For questions that refer to optimization instances used for testing or benchmarking algorithms and software packages." OwnerUserId="47" LastEditorUserId="123" LastEditDate="2020-02-07T19:48:14.127" LastActivityDate="2020-02-07T19:48:14.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="196" PostTypeId="2" ParentId="117" CreationDate="2019-06-03T21:37:05.607" Score="11" Body="&lt;p&gt;We wrote a book on &lt;a href=&quot;http://networkdesignbook.com/&quot; rel=&quot;noreferrer&quot;&gt;Supply Chain Network Design&lt;/a&gt;.  It is meant to be a practical guide to that problem. It starts with a simple network design formulation and then adds more to it throughout the book.  It both presents the mathematical formulation as well as a description of the problem, assumptions baked in, and reasons for those assumptions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We also recently released the models from the book in Python. Here is a &lt;a href=&quot;http://scdigest.com/experts/DrWatson_19-05-22.php?cid=15496&quot; rel=&quot;noreferrer&quot;&gt;short blog&lt;/a&gt; explaining that. You might find that useful for working through the problems.&lt;/p&gt;&#xA;" OwnerUserId="191" LastActivityDate="2019-06-03T21:37:05.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="197" PostTypeId="2" ParentId="183" CreationDate="2019-06-03T21:46:31.240" Score="26" Body="&lt;p&gt;As far as I understand it, all machine learning approaches used for solving (combinatorial) optimization problems, and in particular reinforcement learning, work as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a greedy algorithm to iteratively construct a solution (e.g., by iteratively selecting edges into a path or a tour), and &quot;learn&quot; the ranking (i.e., the ordering) of the next items to pick (e.g., an edge). This said, again, as far as I understand it, any ML based approach that follows these lines, is necessarily a local (search) approach. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It certainly is a heuristic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears to need training for specialties of instances you see and does not (yet?) work generally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a reference: &lt;a href=&quot;https://papers.nips.cc/paper/7214-learning-combinatorial-optimization-algorithms-over-graphs.pdf&quot; rel=&quot;noreferrer&quot;&gt;Dai et al.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A benefit of using an ML approach for optimization is (in my view): we may get a computational intuition about (patterns in) the solution that would not have spotted otherwise. If we would see such patterns, throw away all ML, get paper and pencil and try to prove what we see.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="123" LastEditDate="2019-10-14T10:17:33.397" LastActivityDate="2019-10-14T10:17:33.397" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="198" PostTypeId="5" CreationDate="2019-06-03T23:51:02.537" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-03T23:51:02.537" LastActivityDate="2019-06-03T23:51:02.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="199" PostTypeId="4" CreationDate="2019-06-03T23:51:02.537" Score="0" Body="Questions related to the commercial solver IBM ILOG CPLEX Optimization Studio." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-04T16:13:38.330" LastActivityDate="2019-06-04T16:13:38.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="200" PostTypeId="5" CreationDate="2019-06-03T23:52:21.747" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;https://www.gurobi.com/products/gurobi-optimizer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi Optimizer&lt;/a&gt; is a commercial optimization solver for linear programming (LP), quadratic programming (QP), quadratically constrained programming (QCP), mixed integer linear programming (MILP), mixed-integer quadratic programming (MIQP), and mixed-integer quadratically constrained programming (MIQCP).&lt;/p&gt;&#xA;&lt;p&gt;Problems can be defined and solved via Gurobi's interactive shell or one of its many programming languages interfaces: C, C++, Java, Microsoft, .NET, Python, MATLAB, and R.&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="123" LastEditDate="2021-09-15T06:44:43.373" LastActivityDate="2021-09-15T06:44:43.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="201" PostTypeId="4" CreationDate="2019-06-03T23:52:21.747" Score="0" Body="Questions related to the commercial solver Gurobi Optimizer." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-04T16:13:53.957" LastActivityDate="2019-06-04T16:13:53.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="202" PostTypeId="5" CreationDate="2019-06-03T23:56:26.317" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-03T23:56:26.317" LastActivityDate="2019-06-03T23:56:26.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="203" PostTypeId="4" CreationDate="2019-06-03T23:56:26.317" Score="0" Body="For questions related to constraints, i.e. any restriction or relation a set of decision variables has to satisfy." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-12T12:03:36.070" LastActivityDate="2019-06-12T12:03:36.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="204" PostTypeId="5" CreationDate="2019-06-04T00:50:51.860" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-04T00:50:51.860" LastActivityDate="2019-06-04T00:50:51.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="205" PostTypeId="4" CreationDate="2019-06-04T00:50:51.860" Score="0" Body="For questions related to the use of a &quot;big M&quot; (large constant) in a mathematical modeling context, either in the objective function (to initialize the simplex method) or in constraints (to formulate logical constraints, to linearize constraints, and so on)." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-04T16:14:20.507" LastActivityDate="2019-06-04T16:14:20.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="206" PostTypeId="5" CreationDate="2019-06-04T00:52:43.927" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-04T00:52:43.927" LastActivityDate="2019-06-04T00:52:43.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="207" PostTypeId="4" CreationDate="2019-06-04T00:52:43.927" Score="0" Body="For questions about optimization problems in which one or more parameters are stochastic, with known probability distributions or discrete scenarios. The goal is often, but not always, to minimize or maximize the expected value of the objective function." OwnerUserId="38" LastEditorUserId="491" LastEditDate="2019-06-17T20:16:25.570" LastActivityDate="2019-06-17T20:16:25.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="208" PostTypeId="5" CreationDate="2019-06-04T00:54:40.883" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-04T00:54:40.883" LastActivityDate="2019-06-04T00:54:40.883" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="209" PostTypeId="4" CreationDate="2019-06-04T00:54:40.883" Score="0" Body="For questions about mathematical optimization problems involving a nonlinear objective function and/or nonlinear constraints." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-04T16:13:42.903" LastActivityDate="2019-06-04T16:13:42.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="210" PostTypeId="5" CreationDate="2019-06-04T00:56:08.740" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-04T00:56:08.740" LastActivityDate="2019-06-04T00:56:08.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="211" PostTypeId="4" CreationDate="2019-06-04T00:56:08.740" Score="0" Body="For questions relating to optimization problems in which the goal is to minimize the maximum value of some function (or maximize the minimize the value)." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-04T16:13:34.603" LastActivityDate="2019-06-04T16:13:34.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="212" PostTypeId="5" CreationDate="2019-06-04T01:01:55.717" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-04T01:01:55.717" LastActivityDate="2019-06-04T01:01:55.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="213" PostTypeId="4" CreationDate="2019-06-04T01:01:55.717" Score="0" Body="For questions related to the Python optimization modeling package PuLP." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-04T16:13:59.050" LastActivityDate="2019-06-04T16:13:59.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="214" PostTypeId="5" CreationDate="2019-06-04T01:02:36.683" Score="0" Body="&lt;p&gt;Pyomo supports an object-oriented style of formulating optimization models, which are defined with a variety of modeling components: sets, scalar and multidimensional parameters, decision variables, objectives, constraints, equations, disjunctions and more.&lt;/p&gt;&#xA;&lt;p&gt;Pyomo is available for download &lt;a href=&quot;http://www.pyomo.org/installation&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&#xA;or:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;pip install pyomo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A core capability of Pyomo is modeling structured optimization applications.  Pyomo can be used to define general symbolic problems, create specific problem instances, and solve these instances using commercial and open-source solvers.  Pyomo's modeling objects are embedded within a full-featured high-level programming language providing a rich set of supporting libraries, which distinguishes Pyomo from other algebraic modeling languages like AMPL, AIMMS and GAMS.&lt;/p&gt;&#xA;&lt;p&gt;Optimization models can be initialized with Python data or external data, and external data sources can be defined using spreadsheets, databases and various formats of text files. Pyomo supports dozens of solvers, both open source and commercial.  both open source and commercial, including many solvers supported by AMPL, PICO, CBC, CPLEX, IPOPT, Gurobi and GLPK. Pyomo can either invoke the solver directly or asynchronous with a solver manager. Solver managers support remote, asynchronous execution of solvers, which supports parallel execution of Pyomo scripts. Solver interaction is performed with a variety of solver interfaces, depending on the solver being used. A very generic solver interface is supported with AMPL's nl (format).&lt;/p&gt;&#xA;&lt;p&gt;Pyomo supports a wide range of problem types, including:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Linear programming&lt;/li&gt;&#xA;&lt;li&gt;Quadratic programming&lt;/li&gt;&#xA;&lt;li&gt;Nonlinear programming&lt;/li&gt;&#xA;&lt;li&gt;Mixed-integer linear programming&lt;/li&gt;&#xA;&lt;li&gt;Mixed-integer quadratic programming&lt;/li&gt;&#xA;&lt;li&gt;Mixed-integer nonlinear programming&lt;/li&gt;&#xA;&lt;li&gt;Stochastic programming&lt;/li&gt;&#xA;&lt;li&gt;Generalized disjunctive programming&lt;/li&gt;&#xA;&lt;li&gt;Differential algebraic equations&lt;/li&gt;&#xA;&lt;li&gt;Bilevel programming&lt;/li&gt;&#xA;&lt;li&gt;Mathematical programs with equilibrium constraints&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Pyomo also supports iterative analysis and scripting capabilities within a full-featured programming language.  Further, Pyomo has also proven an effective framework for developing high-level optimization and analysis tools.  For example, the PySP package provides generic solvers for stochastic programming.  PySP leverages the fact that Pyomo's modeling objects are embedded within a full-featured high-level programming language, which allows for transparent parallelization of subproblems using Python parallel communication libraries.&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="2579" LastEditDate="2021-09-16T06:34:31.347" LastActivityDate="2021-09-16T06:34:31.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="215" PostTypeId="4" CreationDate="2019-06-04T01:02:36.683" Score="0" Body="For questions related to the Python optimization modeling package Pyomo. Pyomo is a Python-based open-source software package that supports a diverse set of optimization capabilities for formulating, solving, and analyzing optimization models. Pyomo allows users to formulate optimization problems in Python in a manner that is similar to the notation commonly used in mathematical optimization." OwnerUserId="38" LastEditorUserId="2579" LastEditDate="2021-09-16T06:34:36.673" LastActivityDate="2021-09-16T06:34:36.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="216" PostTypeId="1" CreationDate="2019-06-04T03:16:41.073" Score="14" ViewCount="1165" Body="&lt;p&gt;I want to solve an optimization model that contains a constraint like&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\Pr[F(x,\xi)\leq0]\geq1-\varepsilon&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are my decision variables, &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; is a random vector, and &lt;span class=&quot;math-container&quot;&gt;$\varepsilon\in(0,1)$&lt;/span&gt; is some tolerance that measures how certain I want to be to satisfy my constraint. Is there a general way to solve such a problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Disclaimer: I'm asking this because the Nemirovski and Shapiro paper was hard for me to read, and I wanted a brief, accessible summary).&lt;/p&gt;&#xA;" OwnerUserId="358" LastActivityDate="2020-12-17T16:11:06.433" Title="How can I approximate a chance constraint in a computationally tractable way?" Tags="|optimization|chance-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="217" PostTypeId="2" ParentId="216" CreationDate="2019-06-04T03:16:41.073" Score="14" Body="&lt;p&gt;In general, chance constraints are difficult to handle computationally. Given a fixed &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, is it often very difficult to even compute the value of &lt;span class=&quot;math-container&quot;&gt;$\Pr[F(x,\xi)\leq0]$&lt;/span&gt;, making the incorporation of such a constraint into an optimization model quite troublesome.&lt;/p&gt;&#xA;&lt;p&gt;One possible approach is outlined in the 2006 paper by Nemirovksi and Shapiro entitled &lt;a href=&quot;https://www2.isye.gatech.edu/%7Enemirovs/SIOPT_Bern_2006.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Convex Approximations of Chance Constrained Programs&lt;/a&gt;. In this paper, the authors propose techniques for creating &lt;em&gt;conservative&lt;/em&gt; approximations of chance constraints (i.e., approximations with smaller feasible regions). See &lt;a href=&quot;https://link.springer.com/article/10.1007/s11590-013-0624-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper by Shabbir Ahmed&lt;/a&gt; for convex relaxations.&lt;/p&gt;&#xA;&lt;p&gt;In what follows, we'll assume that for all &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt;, the function &lt;span class=&quot;math-container&quot;&gt;$F(\cdot,\xi)$&lt;/span&gt; is convex in its first argument (if this is not the case, you'll have to do some hard thinking). We'll also assume &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is real-valued (not vector-valued---i.e. not a joint chance constraint). For the remainder, we'll deal with the complement of the given constraint, that is, we'll deal with &lt;span class=&quot;math-container&quot;&gt;$\Pr[F(x,\xi)&amp;gt;0]\leq\varepsilon$&lt;/span&gt;.&#xA;It is well known that &lt;a href=&quot;https://en.wikipedia.org/wiki/Expected_value#%7F%27%22%60UNIQ--postMath-0000005C-QINU%60%22%27%7F&quot; rel=&quot;nofollow noreferrer&quot;&gt;the probability of an event is equal to the expectation of an indicator function on that event&lt;/a&gt;. That is,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\Pr[F(x,\xi)&amp;gt;0]=\mathbb{E}[\mathbf{1}_{\{F(x,\xi)&amp;gt;0\}}].&#xA;$$&lt;/span&gt;&#xA;The &lt;strong&gt;BIG IDEA&lt;/strong&gt; behind this approximation scheme is to replace the discontinuous, non-convex indicator function &lt;span class=&quot;math-container&quot;&gt;$\mathbf{1}_{\{\cdot\}}$&lt;/span&gt; with some nicer function---let's call it &lt;span class=&quot;math-container&quot;&gt;$\psi(\cdot)$&lt;/span&gt;. Ideally, we want &lt;span class=&quot;math-container&quot;&gt;$\psi$&lt;/span&gt; to be continuous, convex (for easier computing), and be greater than (or equal to) the indicator function (so that our approximation is conservative).&lt;/p&gt;&#xA;&lt;p&gt;Now, because &lt;span class=&quot;math-container&quot;&gt;$\psi(t)\geq\mathbf{1}_{\{t&amp;gt;0\}}$&lt;/span&gt;, we have that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\Pr[F(x,\xi)&amp;gt;0]=\mathbb{E}[\mathbf{1}_{\{F(x,\xi)&amp;gt;0\}}]\leq\mathbb{E}[\psi(F(x,\xi))].&#xA;$$&lt;/span&gt;&#xA;Hence, if we enforce &lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[\psi(F(x,\xi))]\leq\varepsilon$&lt;/span&gt;, this implies &lt;span class=&quot;math-container&quot;&gt;$\Pr[F(x,\xi)&amp;gt;0]\leq\varepsilon$&lt;/span&gt; (just like we want).&lt;/p&gt;&#xA;&lt;p&gt;So how do we pick &lt;span class=&quot;math-container&quot;&gt;$\psi$&lt;/span&gt;, the approximation to the indicator function? Here are three popular choices:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\psi(t)=\max\{1+t,0\}$&lt;/span&gt;. This choice is actually equivalent to &lt;a href=&quot;https://en.wikipedia.org/wiki/Expected_shortfall&quot; rel=&quot;nofollow noreferrer&quot;&gt;Conditional Value-at-Risk (CVaR)&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\psi(t)=(1+t)^2$&lt;/span&gt;. This choice is equivalent to approximating the chance constraint using &lt;a href=&quot;https://en.wikipedia.org/wiki/Chebyshev%27s_inequality&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chebyshev's inequality&lt;/a&gt; (see, e.g., slide 10 of &lt;a href=&quot;https://web.stanford.edu/class/ee364a/lectures/chance_constr.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;these slides&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\psi(t)=\exp(t)$&lt;/span&gt;. This choice is advantageous because the function &lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[\exp(tX)]$&lt;/span&gt; for a random variable &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is known as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Moment-generating_function&quot; rel=&quot;nofollow noreferrer&quot;&gt;moment-generating function&lt;/a&gt;, and has some nice, well-studied properties.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In fact, you can do a little bit better than this approximation. Nemirovski and Shapiro show that you can actually enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;t\mathbb{E}[\psi(\tfrac{1}{t}F(x,\xi))]\leq{t}\varepsilon\quad\leftarrow\text{If you only remember one thing...}&#xA;$$&lt;/span&gt;&#xA;for any &lt;span class=&quot;math-container&quot;&gt;$t&amp;gt;0$&lt;/span&gt;, and the approximation is still valid. This function on the left-hand side is actually convex in &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; (as long as &lt;span class=&quot;math-container&quot;&gt;$\psi$&lt;/span&gt; is convex)---this is called a &lt;em&gt;perspective function&lt;/em&gt; (see, e.g., Section 3.2.6 of Boyd and Vandenberghe's &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Convex Optimization&lt;/a&gt;). So we can just throw in a new variable &lt;span class=&quot;math-container&quot;&gt;$t\geq0$&lt;/span&gt; and enforce the above constraint, and get a tighter approximation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Toy Example&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Suppose we have the constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\Pr[\xi_1x_1+\xi_2x_2\leq2]\geq0.9.&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; are non-negative decision variables, &lt;span class=&quot;math-container&quot;&gt;$\xi_1\sim\mathrm{Poisson}(1)$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\xi_2\sim\mathrm{Poisson}(1/2)$&lt;/span&gt;. The true chance constraint can be evaluated using the law of total probability (see code below). For the conservative approximation, we take &lt;span class=&quot;math-container&quot;&gt;$F(x,\xi)=\xi_1x_1+\xi_2x_2-2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\varepsilon=0.1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\psi(t)=\exp(t)$&lt;/span&gt;. As noted above, this choice of &lt;span class=&quot;math-container&quot;&gt;$\psi$&lt;/span&gt; is equivalent to the MGF of the random variable &lt;span class=&quot;math-container&quot;&gt;$\xi_1x_1+\xi_2x_2-2$&lt;/span&gt;, which is given by&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\exp\big[\lambda_1(e^{x_1/t}-1)+\lambda_2(e^{x_2/t}-1)-2/t\big]&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\lambda_1=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda_2=1/2$&lt;/span&gt;. Hence, for any &lt;span class=&quot;math-container&quot;&gt;$t&amp;gt;0$&lt;/span&gt;, the following is a conservative approximation:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;t\cdot\exp\big[(e^{x_1/t}-1)+\tfrac{1}{2}(e^{x_2/t}-1)-2/t\big]\leq{t\varepsilon}&#xA;$$&lt;/span&gt;&#xA;An example of the true feasible region (light gray), and the approximation for &lt;span class=&quot;math-container&quot;&gt;$t=0.4$&lt;/span&gt; (dark gray) are shown here:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HIqAz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HIqAz.png&quot; alt=&quot;example of a conservative approximation&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Python code to produce this plot:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;import matplotlib.pyplot as plt&#xA;from scipy import stats&#xA;&#xA;def main():&#xA;    l1, l2 = 1.0, 0.5&#xA;    tau = 2.  # Chance constraint rhs&#xA;    eps = 0.1  # Chance risk tolerance&#xA;    tee = 0.4  # Conservatism a parameter&#xA;    num_points = 500&#xA;    X = np.linspace(0, 1, num_points)&#xA;    X, Y = np.meshgrid(X, X)&#xA;&#xA;    approx = tee * np.exp(&#xA;        l1 * (np.exp(X / tee) - 1) + l2 * (np.exp(Y / tee) - 1) - (tau / tee)&#xA;    )&#xA;    exact = np.vectorize(evaluate_poisson_cc)(X, Y, l1, l2, tau)&#xA;&#xA;    # Plot the results&#xA;    ax = plt.gca()&#xA;    ax.contourf(X, Y, exact,  levels=[1. - eps, 1.],  colors=&amp;quot;k&amp;quot;, alpha=0.2)&#xA;    ax.contourf(X, Y, approx, levels=[0., tee * eps], colors=&amp;quot;k&amp;quot;, alpha=0.4)&#xA;    ax.set_xlabel(&amp;quot;&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;&amp;quot;); ax.set_ylabel(&amp;quot;&lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;&amp;quot;)&#xA;    ax.set_aspect(&amp;quot;equal&amp;quot;)&#xA;    plt.show()&#xA;&#xA;&#xA;def evaluate_poisson_cc(x1, x2, l1, l2, tau, tol=1e-10):&#xA;    &amp;quot;&amp;quot;&amp;quot; Evaluate P[x1 * Z1 + x2 * Z2 &amp;lt;= tau] where Zi ~ Poisson(li)&#xA;    &amp;quot;&amp;quot;&amp;quot;&#xA;    assert tau &amp;gt; tol&#xA;    if np.abs(x1) &amp;lt; tol and np.abs(x2) &amp;lt; tol:&#xA;        return 1.&#xA;    if np.abs(x1) &amp;lt; tol:&#xA;        return stats.poisson.cdf(tau / x2, l2)&#xA;    if np.abs(x2) &amp;lt; tol:&#xA;        return stats.poisson.cdf(tau / x1, l1)&#xA;        &#xA;    max_value = np.floor(tau / x2)&#xA;    n_values = np.arange(max_value + 1)&#xA;    v1 = stats.poisson.pmf(n_values, l2)&#xA;    v2 = stats.poisson.cdf((tau - n_values * x2) / x1, l1)&#xA;    return np.dot(v1, v2)&#xA;&#xA;&#xA;if __name__ == &amp;quot;__main__&amp;quot;:&#xA;    main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="358" LastEditorUserId="358" LastEditDate="2020-12-17T16:11:06.433" LastActivityDate="2020-12-17T16:11:06.433" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="218" PostTypeId="2" ParentId="216" CreationDate="2019-06-04T03:56:11.037" Score="12" Body="&lt;p&gt;In addition to David M's excellent answer, another approach which sometimes can be useful is to use integer programming. Specifically, if your distribution of &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; is discrete (e.g. taking a sample-average-approximation of uncertainty is a reasonable approach) and you are willing to make a big-M assumption on &lt;span class=&quot;math-container&quot;&gt;$F(x, \xi)$&lt;/span&gt; then another way to model a chance constraint is using integer programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, if we have &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; realizations of &lt;span class=&quot;math-container&quot;&gt;$\xi_i$&lt;/span&gt; total, and they all occur with equal probability, then we can let &lt;span class=&quot;math-container&quot;&gt;$z_i=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$F(x, \xi_i) \leq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise, and model the chance constraint exactly using the following big-M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;F(x, \xi_i) \leq M(1-z_i), \forall i \in \{1, .., L\},\\ \frac{1}{L}\sum_i z_i \geq 1-\epsilon.&#xA;$$&lt;/span&gt;&#xA;This approach cannot be applied to a general continuous distribution, because it relies on the support of &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; being discrete. However, there are some fairly general conditions under which the optimal solutions &lt;span class=&quot;math-container&quot;&gt;$x^*_L$&lt;/span&gt; from sample-average-approximations of size &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; converge almost-surely to the optimal solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; for the full continuous distribution of &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$L \mapsto \infty$&lt;/span&gt;, and therefore discretizing a continuous distribution &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; and applying a big-M approach to the discretized distribution is often a reasonable idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe that some other approaches have since been shown to be faster (see &lt;a href=&quot;https://arxiv.org/pdf/1905.07377.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for instance), but the integer programming approach seems worth knowing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further reading: chapter 5.7 of &lt;a href=&quot;https://www2.isye.gatech.edu/people/faculty/Alex_Shapiro/SPbook.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this book&lt;/a&gt;, and &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-008-0247-4&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="43" LastEditorUserId="43" LastEditDate="2019-07-01T23:10:47.663" LastActivityDate="2019-07-01T23:10:47.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="219" PostTypeId="1" AcceptedAnswerId="228" CreationDate="2019-06-04T07:44:49.700" Score="8" ViewCount="399" Body="&lt;p&gt;When working with Gurobi, CPLEX and the like the user can choose between many different APIs, for example Python, C++, R, Java, Matlab or C. Some of these API are more efficient than others. For example, in R the user does not need to declare any data types like int, str and the like. R tries to find this out on its own while interpreting the code. This obviously comes with the cost that R code is slower interpreted than, for example, the same code written in C++. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, when writing optimization models it might happen that the same model is built faster in one API than in another. However, I was wondering what happens when the model has been built and it is passed to Gurobi (or CPLEX)? Will the the API have additional effects on the solution times of Gurobi? Or does Gurobi solve equally fast with all the APIs? Formulated in a different way: will &lt;code&gt;gurobi(model)&lt;/code&gt; in R, &lt;code&gt;model.optimize()&lt;/code&gt; in Python or C++ take the same amount of time (for the same model) in all the APIs or does the choice of API affect the time needed to find the optimum of the model passed to Gurobi?&lt;/p&gt;&#xA;" OwnerUserId="81" LastActivityDate="2019-06-04T16:08:12.527" Title="Does the API affect the time Gurobi requires to find an optimum?" Tags="|solver|gurobi|cplex|api|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="220" PostTypeId="2" ParentId="219" CreationDate="2019-06-04T08:23:26.940" Score="8" Body="&lt;p&gt;Once it’s passed to the underlying C library, it does not matter which API it came from. However, there may be some overhead when you are retrieving the solution through the API (for the same reasons that you ready mentioned).&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-06-04T08:23:26.940" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="221" PostTypeId="1" CreationDate="2019-06-04T08:53:07.510" Score="-7" ViewCount="269" Body="&lt;p&gt;I'm working on this problem:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In the Njaba river basin, the available water was allocated for the purposes of consumption, irrigation, and&#xA;  electric power supply among three communities. The water allocated per annum per capita for all use&#xA;  in these communities are &lt;span class=&quot;math-container&quot;&gt;$10m^3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$10m^3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$30m^3$&lt;/span&gt;&#xA;  . The allocations were made based on the critical&#xA;  factors of population, land area and the industrialization. The populations of the communities are 300,&#xA;  200, and 100, power supply capacities are 20W, 10W and 20W while the land areas for irrigation are&#xA;  50 hectares, 40 hectares, and 30 hectares respectively. Allowable allocations limits of more than 300,&#xA;  100 and 80 were stipulated for the purposes. Using the above information, formulate,&#xA;  (a) Linear Programming Model for the basin.&#xA;  (b) Maximization the allocations made&#xA;  Assume non-negativity condition?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm taking this course for the very first time, so in order to understand this subject and its problems, I'm trying to solve different problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a solved example I found on the internet. From the solution, here are the objective function and constraints.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Let the three communities be denoted by the variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;.&#xA;  The objective function should be based on the allocation per annum, per capita for the basin as stated;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Z = 10x + 10y + 30z$$&lt;/span&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The constraints can be formulated thus;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$300x + 200y + 100z \ge 300$$&lt;/span&gt;&#xA;  &lt;span class=&quot;math-container&quot;&gt;$$20x + 10y + 20z \ge 100$$&lt;/span&gt;&#xA;  &lt;span class=&quot;math-container&quot;&gt;$$50x + 40y + 30z \ge 80$$&lt;/span&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Under the negativity conditions of&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x, y, z \ge 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My confusion is writing an objecting function in this question. When different communities are supplied water for different use then it's obvious that usage of water in every community for different use is different. Like annually, per person usage of water would be different. If a person is using water only for domestic needs the whole year, they have nothing to do with the irrigation and electric power supply, so how could the following line be justified?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;The water allocated per annum per capita &lt;em&gt;for all use&lt;/em&gt; in these communities are &lt;span class=&quot;math-container&quot;&gt;$10m^3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$10m^3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$30m^3$&lt;/span&gt; ?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Does this mean every single person is allocated water for all uses like for basic consumption, irrigation, electric power supply or it means they're providing extra water?&lt;/p&gt;&#xA;" OwnerUserId="365" LastEditorUserId="38" LastEditDate="2019-06-04T16:23:08.930" LastActivityDate="2019-06-04T16:23:08.930" Title="How to decide to write an objective function?" Tags="|linear-programming|optimization|modeling|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="222" PostTypeId="2" ParentId="221" CreationDate="2019-06-04T12:52:10.353" Score="3" Body="&lt;p&gt;I think you are reading too much into the question and its details. The water is allocated based on the overall use of the community as is mentioned in the sentence right after that. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The allocations were made based on the critical factors of&#xA;  population, land area and the industrialization.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, think of it as a strategic decision that just tries to figure out the allocation to each community and doesn't bother about the &quot;fair share&quot; for each person per year. That'd be another problem!&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-06-04T12:52:10.353" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="223" PostTypeId="2" ParentId="221" CreationDate="2019-06-04T13:36:03.200" Score="4" Body="&lt;p&gt;I’m not sure Ehsan is correct. I think the coefficients in the given objective function (10, 10, 30) are the annual allocations. Yet it also states you’re supposed to maximize the allocations and the decision variables are the communities. This seems like the problem contradicts itself. It also appears to be unbounded above (unless it’s a min)? I could be misreading it though, perhaps someone can clarify.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Minor - the inequalities also shouldn’t be strict for a linear program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Evan, if you’re trying to learn how to formulate linear programs, I’d recommend you find a different source for example problems. You can ask another question on this site, and folks can recommend them.&lt;/p&gt;&#xA;" OwnerUserId="56" LastActivityDate="2019-06-04T13:36:03.200" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="224" PostTypeId="1" CreationDate="2019-06-04T13:52:50.160" Score="5" ViewCount="192" Body="&lt;p&gt;What types of organizations/sponsors in the US support applied OR research? I'm familiar with NSF and NIH.&lt;/p&gt;&#xA;" OwnerUserId="56" LastEditorUserId="279" LastEditDate="2022-10-09T13:59:36.957" LastActivityDate="2022-10-09T13:59:36.957" Title="Funding sources in the US for applied OR projects" Tags="|research|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="225" PostTypeId="1" AcceptedAnswerId="229" CreationDate="2019-06-04T13:54:19.743" Score="11" ViewCount="396" Body="&lt;p&gt;For some insertion-type heuristics for the traveling salesman problem, we have a fixed worst-case error bound of the form:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{z^H}{z^*} \le \eta,$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$z^H$&lt;/span&gt; is the objective value of the solution returned by the heuristic for a given instance, &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt; is the optimal objective value for that instance, and &lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt; is a constant, for symmetric instances satisfying the triangle inequality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, nearest-insertion has a fixed worst-case bound of &lt;span class=&quot;math-container&quot;&gt;$\eta=2$&lt;/span&gt;, while nearest-neighbor provably has no fixed worst-case bound&lt;sup&gt;1&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know, &lt;strong&gt;farthest insertion&lt;/strong&gt; has no fixed worst-case bound, nor has it been proven that no such bound exists. Is this still true, or is there a more recent proof?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Reference&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sub&gt;1&lt;/sub&gt;&lt;/sup&gt; &lt;sub&gt; D. J. Rosenkrantz, R. E. Stearns, and P. M. Lewis II. An analysis of several heuristics for the traveling salesman problem. &lt;em&gt;SIAM Journal on Computing&lt;/em&gt;, 6(3):563–581, 1977.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="112" LastEditDate="2019-06-04T18:21:40.257" LastActivityDate="2021-01-05T11:25:32.983" Title="Is there a fixed worst-case error bound for farthest-insertion?" Tags="|traveling-salesman|heuristics|error-bounds|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="226" PostTypeId="2" ParentId="224" CreationDate="2019-06-04T14:15:30.463" Score="9" Body="&lt;p&gt;If your application can be applied to naval issues, the Office of Naval Research has been a great supporter of OR. &lt;a href=&quot;https://www.onr.navy.mil/en/Science-Technology/Departments/Code-31/All-Programs/311-Mathematics-Computers-Research/computational-methods-resource-optimization&quot; rel=&quot;noreferrer&quot;&gt;https://www.onr.navy.mil/en/Science-Technology/Departments/Code-31/All-Programs/311-Mathematics-Computers-Research/computational-methods-resource-optimization&lt;/a&gt; is the more applied program.&lt;/p&gt;&#xA;" OwnerUserId="214" LastActivityDate="2019-06-04T14:15:30.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="227" PostTypeId="2" ParentId="17" CreationDate="2019-06-04T15:55:02.550" Score="10" Body="&lt;p&gt;Complementing the other good answers, please note that presolve is concerned with problem input data and tries to eliminate variables using logical reductions. While a huge reduction in the number of variables as in your case might indicate that the model is not as compact as you would desire, input data could be the reason as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, consider a capacitated facility location problem where demand split (i.e., allocating a customer to more than one facility) is not permitted (this is simply modeled via binary variables for allocation decisions). If the demands of some customers were bigger than the capacities of some facilities, then the corresponding allocation decision variables would be eliminated during the presolve phase.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Considering the above, before further analysis of your formulation for possible enhancements, I suggest you solve your model with different input data and see whether your observation is consistent for a wider range of instances.&lt;/p&gt;&#xA;" OwnerUserId="119" LastEditorUserId="119" LastEditDate="2019-06-04T17:24:33.010" LastActivityDate="2019-06-04T17:24:33.010" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="228" PostTypeId="2" ParentId="219" CreationDate="2019-06-04T16:08:12.527" Score="8" Body="&lt;p&gt;In addition to @Richard's answer:&lt;br&gt;&#xA;The time for setting up the model, i.e. declaring variables and constraints, surely depends on the programming language you use. After the model is ready, solving does no longer depend on the language &lt;strong&gt;unless&lt;/strong&gt; you use callbacks while doing the optimization. This is a more advanced technique where for example you provide the solver with feasible (not necessarily optimal) solutions (e.g. by a custom made heuristic) or you calculate cutting planes based on the current relaxation. In this cases the time spent in the callback depends on the programming language (and of course on your skill when implementing the calculations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In most cases, when using the programming language only to set up the problem, a larger amount of time will be spent by the solver computing the solution compared to the time needed to set up the model.&lt;/p&gt;&#xA;" OwnerUserId="137" LastActivityDate="2019-06-04T16:08:12.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="229" PostTypeId="2" ParentId="225" CreationDate="2019-06-04T16:16:27.077" Score="8" Body="&lt;p&gt;To my knowledge, there is yet no known constant worst-case error bound &lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt; for farthest insertion nor a proof that no constant bound exists. The results you mention here require symmetric TSP instances with costs that satisfy the triangle inequality, if I am not mistaken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nearest and cheapest insertion benefit from the fact that it can be shown that insertion steps are related in cost to costs on an underlying &lt;em&gt;minimum spanning tree&lt;/em&gt;; thus, these heuristics perform with a worst-case upper bound that is the same as the &lt;em&gt;twice-around MST heuristic&lt;/em&gt;. When selecting the &lt;em&gt;farthest&lt;/em&gt; node to insert into the tour, this correspondence to the MST is not maintained.&lt;/p&gt;&#xA;" OwnerUserId="105" LastActivityDate="2019-06-04T16:16:27.077" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="230" PostTypeId="2" ParentId="183" CreationDate="2019-06-04T16:32:35.373" Score="15" Body="&lt;p&gt;Reinforcement learning is set of the algorithms which are used to solve Markov Decision Processes and its variants, e.g. Partially Observed MDP (POMDP). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the problems that we deal with them in the industrial engineering departments and in a larger extent in the Informs community, can be modeled as a MDP or POMDP. Although, in MDP we assume that we know the transition probability distribution for transiting between states, and also assume know the reward distribution too, which are not realistic assumptions. On the other hand, RL does assume availability of those distributions and tries to learn them, which is viable option since nowadays we have huge datasets. &#xA;So, it might be a good idea to consider RL in OR community too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some papers which get better results with RL than the classical approaches:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;VRP:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Nazari, et al., &lt;a href=&quot;https://papers.nips.cc/paper/8190-reinforcement-learning-for-solving-the-vehicle-routing-problem.pdf&quot; rel=&quot;noreferrer&quot;&gt;Reinforcement Learning for Solving the Vehicle Routing Problem&lt;/a&gt;, 2018. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Inventory Optimization:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Oroojlooyjadid, et al., &lt;a href=&quot;https://arxiv.org/abs/1708.05924&quot; rel=&quot;noreferrer&quot;&gt;A Deep Q-Network for the Beer Game: A Deep Reinforcement Learning algorithm to Solve Inventory Optimization Problems&lt;/a&gt;, 2019. &lt;/li&gt;&#xA;&lt;li&gt;Gijsbrechts, et al., &lt;a href=&quot;https://www.researchgate.net/profile/Jan_Van_Mieghem/publication/329718922_Can_Deep_Reinforcement_Learning_Improve_Inventory_Management_Performance_and_Implementation_of_Dual_Sourcing-Mode_Problems/links/5c18324da6fdcc494ffc6379/Can-Deep-Reinforcement-Learning-Improve-Inventory-Management-Performance-and-Implementation-of-Dual-Sourcing-Mode-Problems.pdf&quot; rel=&quot;noreferrer&quot;&gt;Can Deep Reinforcement Learning Improve Inventory Management? Performance and Implementation of Dual Sourcing-Mode Problems&lt;/a&gt;, 2018&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;just to mention a few. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclaimer: I am one of the co-authors of the first two papers, and I am not posting the links to advertise them!&lt;/p&gt;&#xA;" OwnerUserId="41" LastEditorUserId="71" LastEditDate="2019-06-06T17:52:32.710" LastActivityDate="2019-06-06T17:52:32.710" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="231" PostTypeId="1" AcceptedAnswerId="261" CreationDate="2019-06-04T17:45:29.817" Score="19" ViewCount="7662" Body="&lt;p&gt;Various optimization modeling languages and solvers allow for both indicator constraints (see for example &lt;a href=&quot;http://www.gurobi.com/documentation/8.1/refman/c_grbaddgenconstrindicator.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.3/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/indicator_constr/02_indicators_defn.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://www.gams.com/latest/docs/UG_LanguageFeatures.html#UG_LanguageFeatures_IndicatorConstraints&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;) and traditional binary variable and big-M approaches can be used to model whether a linear constraint such as &lt;span class=&quot;math-container&quot;&gt;$a'x \le b$&lt;/span&gt; should be active in solving (mixed)-integer programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the best practices for using each? Are there definitive rules to prefer one over the other, or does it depend on the application or implementation? I'd be very interested in explanations of how they are handled in branch-and-bound, as well as any studies reporting empirical evidence.&lt;/p&gt;&#xA;" OwnerUserId="371" LastEditorUserId="38" LastEditDate="2019-06-05T13:49:38.570" LastActivityDate="2023-07-03T10:36:09.860" Title="When to use indicator constraints versus big-M approaches in solving (mixed-)integer programs" Tags="|mixed-integer-programming|integer-programming|big-m|solver|indicator-constraints|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="232" PostTypeId="2" ParentId="190" CreationDate="2019-06-04T18:09:18.590" Score="4" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;One common way I've seen in the literature to deal with such cases is to multiply the priority constraint by a big weight and add it into the fitness function alongside the lower priority constraint.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You are likely to want greater complexity than that, see below.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;What is the canonical name of this practice?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Suggestion: &lt;strong&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Representation_(mathematics)&quot; rel=&quot;nofollow noreferrer&quot;&gt;representation&lt;/a&gt;&lt;/strong&gt; of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Category_theory&quot; rel=&quot;nofollow noreferrer&quot;&gt;category&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A &lt;a href=&quot;https://en.wikipedia.org/wiki/Hasse_diagram#A_%22good%22_Hasse_diagram&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hasse Diagram&lt;/a&gt; can be used to represent &lt;a href=&quot;https://en.wikipedia.org/wiki/Order_theory#Functions_between_orders&quot; rel=&quot;nofollow noreferrer&quot;&gt;functions between special types of orders&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Your &amp;quot;very hard&amp;quot; constraints might be absolute, but your &amp;quot;hard&amp;quot; constraints might have numerous exceptions (does not apply in some places, to some people, at certain times of day, or where you would be held blameless such as the &lt;a href=&quot;https://en.wikipedia.org/wiki/Good_Samaritan_law&quot; rel=&quot;nofollow noreferrer&quot;&gt;Good Samaritan Law&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Similarly your &amp;quot;very soft&amp;quot; constraint example (distribution of workload) could become absolute if the person quit. Even your &amp;quot;soft&amp;quot; constraint (fuel and vehicle routing problems) is subject to correct operation of the gauges and road construction.&lt;/p&gt;&#xA;&lt;p&gt;Having a way to hold all the values and perform calculations to shift the values and weighs dynamically is important. You &lt;em&gt;might&lt;/em&gt; chose to derive a &lt;a href=&quot;https://en.wikipedia.org/wiki/Young_tableau#Skew_tableaux&quot; rel=&quot;nofollow noreferrer&quot;&gt;Skew Tableaux&lt;/a&gt; from the matrices and traverse it in order, based on the re-ordering of your constraints &lt;em&gt;&lt;strong&gt;after&lt;/strong&gt;&lt;/em&gt; correctly calculating the weights dynamically and determining the overlap of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Partially_ordered_set&quot; rel=&quot;nofollow noreferrer&quot;&gt;partially ordered sets&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A &lt;a href=&quot;https://en.wikipedia.org/wiki/Representation_(mathematics)&quot; rel=&quot;nofollow noreferrer&quot;&gt;representation&lt;/a&gt;, such as &lt;a href=&quot;https://en.wikipedia.org/wiki/Birkhoff%27s_representation_theorem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Birkhoff's Representation Theorem&lt;/a&gt;, is the formal word used to describe sets that have been redefined (reordered) by their weight and interaction.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;In mathematics, representation is a very general relationship that expresses similarities between objects. Roughly speaking, a collection &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; of mathematical objects may be said to represent another collection &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; of objects, provided that the properties and relationships existing among the representing objects &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; conform in some consistent way to those existing among the corresponding represented objects &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;. Somewhat more formally, for a set &lt;span class=&quot;math-container&quot;&gt;$\Pi$&lt;/span&gt; of properties and &lt;a href=&quot;https://en.wikipedia.org/wiki/Binary_relation&quot; rel=&quot;nofollow noreferrer&quot;&gt;relations&lt;/a&gt;, a &lt;span class=&quot;math-container&quot;&gt;$\Pi$&lt;/span&gt;-representation of some structure &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a structure &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; that is the image of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; under a &lt;a href=&quot;https://en.wikipedia.org/wiki/Homomorphism&quot; rel=&quot;nofollow noreferrer&quot;&gt;homomorphism&lt;/a&gt; that preserves &lt;span class=&quot;math-container&quot;&gt;$\Pi$&lt;/span&gt;. The label representation is sometimes also applied to the homomorphism itself.&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Homomorphisms of vector spaces are also called linear maps, and their study is the object of linear algebra. The concept of homomorphism has been generalized, under the name of morphism, to many other structures that either do not have an underlying set, or are not algebraic. This generalization is the starting point of &lt;a href=&quot;https://en.wikipedia.org/wiki/Category_theory&quot; rel=&quot;nofollow noreferrer&quot;&gt;category theory&lt;/a&gt;&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Perhaps, in your case, you would use &amp;quot;Representative Score&amp;quot; instead of &amp;quot;Score Folding&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-10-14T10:16:35.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="233" PostTypeId="2" ParentId="190" CreationDate="2019-06-04T18:36:38.713" Score="4" Body="&lt;p&gt;I’m not sure I’ve heard a canonical name, but that sounds like a multi-objective optimization problem where you’re minimizing the sum of weighted deviations. The weights are based on the constraint priorities. I’ve run into this a lot with nurse scheduling models - eg many types of constraints that can’t all be simultaneously satisfied (eg union rules, staff preferences, hospital requirements) and have different abilities to be violated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Rob and Michael mentioned there may be other ways to solve your problem. Depends on your requirements and your current method may be just fine. If you do want to mix it up, another framework you may want to consider is lexicographic goal programming.&lt;/p&gt;&#xA;" OwnerUserId="56" LastEditorUserId="123" LastEditDate="2019-10-14T10:15:22.953" LastActivityDate="2019-10-14T10:15:22.953" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="234" PostTypeId="2" ParentId="185" CreationDate="2019-06-04T18:40:16.727" Score="15" Body="&lt;p&gt;In combinatorial Benders, where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are the variables in the master problem and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; the variables in the subproblem, the purpose of the subproblem is to come up with constraints on the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables that force them to take on better values.  In the case where there are no costs in the subproblem, the only issue is feasibility of the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables.  In the case where the subproblem is infeasible, the Benders constraint is then of the form &quot;If you want to avoid this particular infeasibility, then &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; must satisfy this&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the very weakest, the combinatorial Benders constraint is of the form &quot;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; must be different than the current &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; solution&quot;.  The master problem will then find the next cheapest &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; solution and try that.  Sometimes that works, but in most cases that leads to way too many iterations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally the subproblem will cut off lots of possible &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;'s, and the likelihood that Benders will work well depends on how many &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;'s get cut off (along with other things like speed of master and subproblem solution, etc.).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be concrete, suppose the subproblem involves assigning jobs to machines to be scheduled within some fixed time span.  The master problem assigns &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; jobs to &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; machines, and the subproblem then determines if all jobs can be scheduled. Let the solution to the master problem be given by &lt;span class=&quot;math-container&quot;&gt;$x^*_{ij}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x^*_{ij} = 1$&lt;/span&gt; means job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to machine &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. There are multiple levels of Benders constraints that might be generated:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) These jobs cannot be assigned to those machines in that way&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{ij| x^*_{ij} = 1} \le n-1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) The &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; jobs assigned to machine &lt;span class=&quot;math-container&quot;&gt;$j^*$&lt;/span&gt; don't fit&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i|x^*_{ij^*} = 1} \le k-1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) The subset &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; of the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; jobs assigned to machine &lt;span class=&quot;math-container&quot;&gt;$j^*$&lt;/span&gt; doesn't fit&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in J|x^*_{ij^*} = 1} \le |J|-1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You remove more &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; solutions with 2) than with 1) and more with 3) than with 2).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Benders is more likely to be successful with 3) than with 1), though it might default to 1) if it is unsuccessful in identifying a 2) or 3).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the example given by OP, it would be best to determine why capacity is not being respected and find a minimum set of customers (or arcs) that cause that infeasibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TL;DR If you want combinatorial Benders to work, the subproblems must do more than say &quot;Give me another solution to try&quot;.&lt;/p&gt;&#xA;" OwnerUserId="214" LastEditorUserId="214" LastEditDate="2019-06-06T14:21:06.357" LastActivityDate="2019-06-06T14:21:06.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="235" PostTypeId="1" AcceptedAnswerId="389" CreationDate="2019-06-04T18:46:36.267" Score="31" ViewCount="453" Body="&lt;p&gt;Decision Diagrams are a relatively new approach to solving difficult combinatorial optimization problems.  See &lt;a href=&quot;http://www.andrew.cmu.edu/user/vanhoeve/mdd/&quot; rel=&quot;noreferrer&quot;&gt;http://www.andrew.cmu.edu/user/vanhoeve/mdd/&lt;/a&gt; for some information on this approach.  Are there any general rules that can help identify when MDDs or similar approaches will be successful or unsuccessful?&lt;/p&gt;&#xA;" OwnerUserId="214" LastActivityDate="2019-06-11T21:57:33.447" Title="When are Decision Diagrams the right way to model and solve a problem?" Tags="|combinatorial-optimization|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="236" PostTypeId="1" AcceptedAnswerId="237" CreationDate="2019-06-04T19:00:24.070" Score="24" ViewCount="5982" Body="&lt;p&gt;The question &lt;a href=&quot;https://or.stackexchange.com/questions/135/what-is-the-big-m-method-and-are-there-two-of-them&quot;&gt;here&lt;/a&gt; discusses the two different use of &quot;big-M method&quot;, where one of them is the big-M in logical constraints and linearization in (mixed-)integer programming problems (that's what I'm interested in). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, the question &lt;a href=&quot;https://or.stackexchange.com/questions/126/the-effect-of-choosing-big-m-properly&quot;&gt;here&lt;/a&gt; asks about the effects of big-M and I'm aware that a choice of a very large M (of course, large relative to the problem) can create a model with weak relaxations which in turn, may make the model hard for the solvers. So, my question is how can I choose big-M properly and what are the (other) consequences of a poor choice?&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-09-20T18:23:19.990" Title="Why is it important to choose big-M carefully and what are the consequences of doing it badly?" Tags="|linear-programming|mixed-integer-programming|big-m|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="237" PostTypeId="2" ParentId="236" CreationDate="2019-06-04T19:30:42.650" Score="30" Body="&lt;p&gt;The following answer presumes some familiarity with the limitations of floating-point arithmetic (&lt;a href=&quot;https://secure.wikimedia.org/wikipedia/en/wiki/Numerical_analysis#The_generation_and_propagation_of_errors&quot; rel=&quot;noreferrer&quot;&gt;rounding, truncation and representation errors&lt;/a&gt;), which I will lump together as “rounding error”. It is a trimmed down version of a longer blog post &lt;a href=&quot;https://orinanobworld.blogspot.com/2011/07/perils-of-big-m.html&quot; rel=&quot;noreferrer&quot;&gt;[1]&lt;/a&gt; with more detail and some astute comments from subject matter experts.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; in the constraints&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The constraint &lt;span class=&quot;math-container&quot;&gt;$a'x\le b+My$&lt;/span&gt; illustrates the situation where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; shows up as a coefficient in the constraint matrix. This is where serious misadventures can occur. If &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; appears in the basis matrix, rounding errors can make the basis look singular or make a column that should be ineligible for entry to the basis look eligible. The rounding errors can also cause severe loss of precision in the computation of the basic feasible solution. In technical terms, &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; (or &lt;span class=&quot;math-container&quot;&gt;$1/M$&lt;/span&gt;) appearing in the basis matrix can make it &lt;a href=&quot;https://secure.wikimedia.org/wikipedia/en/wiki/Condition_number#Matrices&quot; rel=&quot;noreferrer&quot;&gt;ill-conditioned&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if ill-conditioned basis matrices do not occur, large values of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; can cause branch-and-bound solvers to make slow progress solving the mixed-integer programming model (MIP). Consider the constraint &lt;span class=&quot;math-container&quot;&gt;$x_{ij}-My_{j}\le0$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; is the flow of some commodity &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; across and arc &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$y_{j}$&lt;/span&gt; is a binary variable indicating the presence or absence of that arc. There will be an associated penalty cost (say, &lt;span class=&quot;math-container&quot;&gt;$c_{j}y_{j}$&lt;/span&gt;) in the objective function for providing arc &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. Now suppose that, at some point, the solver is considering a node in the search tree where &lt;span class=&quot;math-container&quot;&gt;$x_{1j}=2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{2j}=5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=0$&lt;/span&gt; for other values of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Logically, we know this requires &lt;span class=&quot;math-container&quot;&gt;$y_{j}=1$&lt;/span&gt; and incurs cost &lt;span class=&quot;math-container&quot;&gt;$c_{j}$&lt;/span&gt;; but in the LP-relaxation of the node problem, &lt;span class=&quot;math-container&quot;&gt;$y_{j}=5/M$&lt;/span&gt; is sufficient, incurring a cost of just &lt;span class=&quot;math-container&quot;&gt;$5c_{j}/M$&lt;/span&gt;. For large values of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, this substantially underestimates the true cost, leading to loose node bounds. Loose bounds at nodes, in turn, make it hard for the solver to prune nodes based on objective value, and so more nodes need to be examined, slowing the solution process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The previous example also reveals another problem. Solvers have a tolerance for how close a variable value needs to be in order to consider it an integer. If &lt;span class=&quot;math-container&quot;&gt;$5/M$&lt;/span&gt; is small enough, a solver may consider &lt;span class=&quot;math-container&quot;&gt;$y_{j}=5/M$&lt;/span&gt; to be an integer (zero) and accept the solution as integer-feasible, when clearly it is not.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Choosing a value for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;There are several considerations when choosing values for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• You want the smallest value of M that is large enough to avoid cutting off a legitimate solution. If &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is chosen too small in &lt;span class=&quot;math-container&quot;&gt;$a'x\le b+My$&lt;/span&gt;, a valid choice of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; may violate the constraint even when &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• On paper, “big M” models usually use a single symbol &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; in every constraint. This is usually laziness by the authors. In practice, constraint-specific values of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; should be chosen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• Calibrating &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is generally problem-specific. For constraints like &lt;span class=&quot;math-container&quot;&gt;$a'x\le b+My$&lt;/span&gt;, one possibility is to relax the integrality constraints and maximize &lt;span class=&quot;math-container&quot;&gt;$a'x-b$&lt;/span&gt; subject to the other constraints (relaxing others by setting the binary variables to whichever value makes the constraints looser). Done properly, the maximum objective value should provide a safe choice for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; (though not necessarily the tightest safe choice).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• There may be context-specific ways to choose a safe value for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. An example of one, in the context of discriminant analysis, is in one of my old papers &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1002/mde.4090110407&quot; rel=&quot;noreferrer&quot;&gt;[2]&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Alternatives to &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; models&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;For situations where constraints need to be turned on or off using binary variables, a possible alternative is “combinatorial Benders decomposition” &lt;a href=&quot;https://www.researchgate.net/publication/220244181_Combinatorial_Benders&amp;#39;_Cuts_for_Mixed-Integer_Linear_Programming&quot; rel=&quot;noreferrer&quot;&gt;[3]&lt;/a&gt;. This is not automatically superior, but can be effective in some cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some solvers (including but not limited to CPLEX and SCIP) provide “indicator constraints” or “if-then” constraints. The preceding example, posed as an indicator constraint, would essentially be &lt;span class=&quot;math-container&quot;&gt;$y_{j}=0\implies x_{ij}=0$&lt;/span&gt;. It is up to the solver designers how to process such constraints, but frequently they will simply turn into “big M” constraints with the solver selecting a value for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. Even if that does not happen, indicator constraints may weaken LP relaxations.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;References&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;[1] Rubin, Paul. “Perils of 'Big M'.” OR in an OB World, 11 July 2011, &lt;a href=&quot;https://orinanobworld.blogspot.com/2011/07/perils-of-big-m.html&quot; rel=&quot;noreferrer&quot;&gt;https://orinanobworld.blogspot.com/2011/07/perils-of-big-m.html&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] Rubin, P. A. (1990). Heuristic Solution Procedures for a Mixed-Integer Programming Discriminant Model. Managerial and Decision Economics 11, 255-266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[3] Codato, G. &amp;amp; Fischetti, M. (2006). Combinatorial Benders' Cuts for Mixed-Integer Linear Programming. Operations Research 54, 756-766.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="123" LastEditDate="2019-09-20T18:23:19.990" LastActivityDate="2019-09-20T18:23:19.990" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="238" PostTypeId="2" ParentId="190" CreationDate="2019-06-04T19:36:08.950" Score="7" Body="&lt;p&gt;The act of moving soft constraint into the objective function using penalties is closely related to &lt;a href=&quot;https://en.wikipedia.org/wiki/Lagrangian_relaxation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lagrangian Relaxation&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Lagrange_multiplier&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lagrangian Multipliers&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The method penalizes violations of [...] constraints using a Lagrange multiplier, which imposes a cost on violations. These added costs are used instead of the strict [...] constraints in the optimization. In practice, this relaxed problem can often be solved more easily than the original problem.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In a comment you clarified: You are solving an optimization problem with different levels of soft constraints. You want to satisfy them lexicographically, i.e. hard(er) constraints take priority over soft(er) constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you solve your model multiple times. In the first pass, include only the absolutely necessary constraints. If it turns out to be infeasible already, you've got your answer. If it is feasible, include the next level constraint and re-optimize. If you still got a feasible solution, continue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eventually you will have a solution that satisfies as many soft constraints as possible.&lt;/p&gt;&#xA;" OwnerUserId="47" LastEditorUserId="123" LastEditDate="2019-06-08T04:40:35.363" LastActivityDate="2019-06-08T04:40:35.363" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="239" PostTypeId="1" AcceptedAnswerId="240" CreationDate="2019-06-04T20:14:04.793" Score="14" ViewCount="547" Body="&lt;p&gt;How do you implement a custom, global constraint in CP Optimizer? This is not a trivial thing to do, as CP Optimizer does not ship any examples of a custom constraint, and the documentation is very limited. I will post a complete example of a custom constraint to show you how this can be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Since constraints have to be implemented using CP Optimizer engine extensions, you have to implement them in C++. You cannot do this through the Java interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Information on the implementation can be found in the &quot;IBM ILOG CPLEX Optimization Studio CP Optimizer Extensions User’s Manual&quot;. For Optimization studio 12.6.2, you can find it &lt;a href=&quot;http://www-01.ibm.com/support/knowledgecenter/SSSA5P_12.6.2/ilog.odms.studio.help/pdf/advcpoptimizer.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="123" LastEditDate="2019-10-14T12:50:14.243" LastActivityDate="2021-05-12T11:35:42.707" Title="How to implement a custom global constraint in IBM's ILOG CP optimizer" Tags="|constraint-programming|c++|cp-optimizer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="240" PostTypeId="2" ParentId="239" CreationDate="2019-06-04T20:14:04.793" Score="13" Body="&lt;p&gt;The Graph Coloring example shipped with CP optimizer (file: &lt;code&gt;color.cpp&lt;/code&gt; in the examples directory):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    #include &amp;lt;ilcp/cp.h&amp;gt;&#xA;&#xA;    const char* Names[] = {&quot;blue&quot;, &quot;white&quot;, &quot;yellow&quot;, &quot;green&quot;};&#xA;&#xA;    int main(int , const char * []){&#xA;      IloEnv env;&#xA;      try {&#xA;        IloModel model(env);&#xA;        IloIntVar Belgium(env, 0, 3, &quot;B&quot;), Denmark(env, 0, 3, &quot;DK&quot;),&#xA;          France(env, 0, 3, &quot;F&quot;), Germany(env, 0, 3, &quot;D&quot;),&#xA;          Luxembourg(env, 0, 3, &quot;L&quot;), Netherlands(env, 0, 3, &quot;NE&quot;);&#xA;        model.add(Belgium != France);&#xA;        model.add(Belgium != Germany);&#xA;        model.add(Belgium != Netherlands);&#xA;        model.add(Belgium != Luxembourg);&#xA;        model.add(Denmark != Germany );&#xA;        model.add(France != Germany);&#xA;        model.add(France != Luxembourg);&#xA;        model.add(Germany != Luxembourg);&#xA;        model.add(Germany != Netherlands);&#xA;        IloCP cp(model);&#xA;        if (cp.solve())&#xA;          {&#xA;          cp.out() &amp;lt;&amp;lt; std::endl &amp;lt;&amp;lt; cp.getStatus() &amp;lt;&amp;lt; &quot; Solution&quot; &amp;lt;&amp;lt; std::endl;&#xA;          cp.out() &amp;lt;&amp;lt; &quot;Belgium:     &quot; &amp;lt;&amp;lt; Names[cp.getValue(Belgium)] &amp;lt;&amp;lt; std::endl;&#xA;          cp.out() &amp;lt;&amp;lt; &quot;Denmark:     &quot; &amp;lt;&amp;lt; Names[cp.getValue(Denmark)] &amp;lt;&amp;lt; std::endl;&#xA;          cp.out() &amp;lt;&amp;lt; &quot;France:      &quot; &amp;lt;&amp;lt; Names[cp.getValue(France)] &amp;lt;&amp;lt; std::endl;&#xA;          cp.out() &amp;lt;&amp;lt; &quot;Germany:     &quot; &amp;lt;&amp;lt; Names[cp.getValue(Germany)] &amp;lt;&amp;lt; std::endl;&#xA;          cp.out() &amp;lt;&amp;lt; &quot;Luxembourg:  &quot; &amp;lt;&amp;lt; Names[cp.getValue(Luxembourg)]  &amp;lt;&amp;lt; std::endl;&#xA;          cp.out() &amp;lt;&amp;lt; &quot;Netherlands: &quot; &amp;lt;&amp;lt; Names[cp.getValue(Netherlands)] &amp;lt;&amp;lt; std::endl;&#xA;        }&#xA;      }&#xA;      catch (IloException&amp;amp; ex) {&#xA;        env.out() &amp;lt;&amp;lt; &quot;Error: &quot; &amp;lt;&amp;lt; ex &amp;lt;&amp;lt; std::endl;&#xA;      }&#xA;      env.end();&#xA;      return 0;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above model, we add constraints stating that 2 IloIntVars have to be different in value, e.g. Belgium != France. Let's write a custom constraint &quot;IloDiffConstraint&quot; which replicates this behavior. A discription of this constraint and its implementation is provided in the &quot;IBM ILOG CPLEX Optimization Studio CP Optimizer Extensions User’s Manual&quot;. The manual only provides code snippets. Here I'll post the complete implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;diffconstraint_handler.hpp&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    #ifndef DIFFCONSTRAINT_HANDLER_HPP&#xA;    #define DIFFCONSTRAINT_HANDLER_HPP&#xA;&#xA;    #define IL_STD&#xA;&#xA;    #include &amp;lt;cstdlib&amp;gt;&#xA;    #include&amp;lt;iostream&amp;gt;&#xA;    #include &amp;lt;ilcp/cpext.h&amp;gt;&#xA;&#xA;    IloConstraint IloDiffConstraint(&#xA;        IloEnv                      env,  &#xA;        IloIntVar              x,             &#xA;        IloIntVar              y,&#xA;        const char*                name&#xA;    );&#xA;&#xA;    class IlcDiffConstraintHandler : public IlcConstraintI {&#xA;&#xA;    public:&#xA;&#xA;        /** Constructors */&#xA;        IlcDiffConstraintHandler(IloCP cp,&#xA;                IlcIntVar _x_var, IlcIntVar _y_var);&#xA;&#xA;        /** Empty destructor */&#xA;        ~IlcDiffConstraintHandler(){ };&#xA;&#xA;        /** ILOG search control */&#xA;        virtual void propagate();                     /**&amp;lt; Propagation method */&#xA;        virtual void post();                          /**&amp;lt; Daemon setting */&#xA;        virtual IlcBool isViolated() const;           /**&amp;lt; Violation checking */&#xA;&#xA;    private:&#xA;        IlcIntVar x_var;&#xA;        IlcIntVar y_var;&#xA;    };&#xA;&#xA;    inline IlcConstraint IlcDiffConstraint(&#xA;            IloCP cp,&#xA;            IlcIntVar x_var,&#xA;            IlcIntVar y_var)&#xA;    {&#xA;        return new(cp.getHeap()) IlcDiffConstraintHandler(cp, x_var, y_var);&#xA;    }&#xA;&#xA;    inline IlcBool IlcDiffConstraintHandler::isViolated() const {&#xA;        return IlcFalse; //This is handled in the propagator itself&#xA;    }&#xA;&#xA;    #endif  /* DIFFCONSTRAINT_HANDLER_HPP */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is the implementation class &lt;code&gt;diffconstraint_handler.cpp&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    #include &quot;diffconstraint_handler.hpp&quot;&#xA;&#xA;    /**&#xA;     * Wrapper for ILO object&#xA;     */&#xA;    ILOCPCONSTRAINTWRAPPER2(IloDiffConstraint,&#xA;            cp,&#xA;            IloIntVar, _x,&#xA;            IloIntVar, _y){&#xA;        use(cp,_x);&#xA;        use(cp,_y);&#xA;        return IlcDiffConstraint(cp, cp.getIntVar(_x), cp.getIntVar(_y));&#xA;    }&#xA;&#xA;    IlcDiffConstraintHandler::IlcDiffConstraintHandler(IloCP cp, IlcIntVar _x_var, IlcIntVar _y_var): &#xA;                IlcConstraintI(cp), x_var(_x_var), y_var(_y_var){&#xA;&#xA;    }&#xA;&#xA;    void IlcDiffConstraintHandler::propagate(){&#xA;        if (x_var.isFixed()) y_var.removeValue(x_var.getValue());&#xA;        if (y_var.isFixed()) x_var.removeValue(y_var.getValue());&#xA;    }&#xA;&#xA;    void IlcDiffConstraintHandler::post(){&#xA;        x_var.whenValue(this);&#xA;        y_var.whenValue(this);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally we can now write a new main file (&lt;code&gt;main.cpp&lt;/code&gt;) which utilizes the new constraint:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    #define IL_STD&#xA;&#xA;    #include &amp;lt;cstdlib&amp;gt;&#xA;    #include &amp;lt;ilcp/cp.h&amp;gt;&#xA;    #include &quot;diffconstraint_handler.hpp&quot;&#xA;&#xA;    const char* Names[] = {&quot;blue&quot;, &quot;white&quot;, &quot;yellow&quot;, &quot;green&quot;};&#xA;&#xA;    int main(int argc, char** argv) {&#xA;      IloEnv env;&#xA;      try {&#xA;        IloModel model(env);&#xA;        IloIntVar Belgium(env, 0, 3, &quot;B&quot;), Denmark(env, 0, 3, &quot;DK&quot;),&#xA;          France(env, 0, 3, &quot;F&quot;), Germany(env, 0, 3, &quot;D&quot;),&#xA;          Luxembourg(env, 0, 3, &quot;L&quot;), Netherlands(env, 0, 3, &quot;NE&quot;);&#xA;&#xA;        model.add(IloDiffConstraint(env, Belgium, France, &quot;test&quot;));&#xA;        model.add(IloDiffConstraint(env, Belgium, Germany, &quot;test&quot;));&#xA;        model.add(IloDiffConstraint(env, Belgium, Netherlands, &quot;test&quot;));&#xA;        model.add(IloDiffConstraint(env, Belgium, Luxembourg, &quot;test&quot;));&#xA;        model.add(IloDiffConstraint(env, Denmark, Germany, &quot;test&quot;));&#xA;        model.add(IloDiffConstraint(env, France, Germany, &quot;test&quot;));&#xA;        model.add(IloDiffConstraint(env, France, Luxembourg, &quot;test&quot;));&#xA;        model.add(IloDiffConstraint(env, Germany, Luxembourg, &quot;test&quot;));&#xA;        model.add(IloDiffConstraint(env, Germany, Netherlands, &quot;test&quot;));&#xA;&#xA;        IloCP cp(model);&#xA;        if (cp.solve())&#xA;          {&#xA;          cp.out() &amp;lt;&amp;lt; std::endl &amp;lt;&amp;lt; cp.getStatus() &amp;lt;&amp;lt; &quot; Solution&quot; &amp;lt;&amp;lt; std::endl;&#xA;          cp.out() &amp;lt;&amp;lt; &quot;Belgium:     &quot; &amp;lt;&amp;lt; Names[cp.getValue(Belgium)] &amp;lt;&amp;lt; std::endl;&#xA;          cp.out() &amp;lt;&amp;lt; &quot;Denmark:     &quot; &amp;lt;&amp;lt; Names[cp.getValue(Denmark)] &amp;lt;&amp;lt; std::endl;&#xA;          cp.out() &amp;lt;&amp;lt; &quot;France:      &quot; &amp;lt;&amp;lt; Names[cp.getValue(France)] &amp;lt;&amp;lt; std::endl;&#xA;          cp.out() &amp;lt;&amp;lt; &quot;Germany:     &quot; &amp;lt;&amp;lt; Names[cp.getValue(Germany)] &amp;lt;&amp;lt; std::endl;&#xA;          cp.out() &amp;lt;&amp;lt; &quot;Luxembourg:  &quot; &amp;lt;&amp;lt; Names[cp.getValue(Luxembourg)]  &amp;lt;&amp;lt; std::endl;&#xA;          cp.out() &amp;lt;&amp;lt; &quot;Netherlands: &quot; &amp;lt;&amp;lt; Names[cp.getValue(Netherlands)] &amp;lt;&amp;lt; std::endl;&#xA;        }&#xA;      }&#xA;      catch (IloException&amp;amp; ex) {&#xA;        env.out() &amp;lt;&amp;lt; &quot;Error: &quot; &amp;lt;&amp;lt; ex &amp;lt;&amp;lt; std::endl;&#xA;      }&#xA;      env.end();&#xA;      return 0;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: when running this example on linux, you need to specify &quot;define IL_STD&quot;. If you want to compile this example on windows/mac, a makefile is included in the cpoptimizer example directory which should help you determine which definition you should use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The makefile I'm using on my linux machine to compile this example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# --- SYSTEM ---&#xA;&#xA;SYSTEM     = x86-64_linux&#xA;LIBFORMAT  = static_pic&#xA;&#xA;# --- DIRECTORIES ---&#xA;&#xA;CCC = g++&#xA;BASISILOG = /opt/ILOG/CPLEX_Studio1262&#xA;CPOPTDIR   = &lt;span class=&quot;math-container&quot;&gt;$(BASISILOG)/cpoptimizer&#xA;CONCERTDIR = $&lt;/span&gt;(BASISILOG)/concert&#xA;CPLEXDIR   = $(BASISILOG)/cplex&#xA;&#xA;# --- FLAGS ---&#xA;&#xA;CCOPT = -m64 -fPIC -fexceptions -DIL_STD&#xA;CPLEXLIBDIR   = &lt;span class=&quot;math-container&quot;&gt;$(CPLEXDIR)/lib/$&lt;/span&gt;(SYSTEM)/&lt;span class=&quot;math-container&quot;&gt;$(LIBFORMAT)&#xA;CONCERTLIBDIR = $&lt;/span&gt;(CONCERTDIR)/lib/&lt;span class=&quot;math-container&quot;&gt;$(SYSTEM)/$&lt;/span&gt;(LIBFORMAT)&#xA;CPOPTLIBDIR = &lt;span class=&quot;math-container&quot;&gt;$(CPOPTDIR)/lib/$&lt;/span&gt;(SYSTEM)/$(LIBFORMAT)&#xA;&#xA;CONCERTINCDIR = &lt;span class=&quot;math-container&quot;&gt;$(CONCERTDIR)/include&#xA;CPLEXINCDIR   = $&lt;/span&gt;(CPLEXDIR)/include&#xA;CPOPTINCDIR   = $(CPOPTDIR)/include&#xA;&#xA;# --- OPTIMIZATION FLAGS ---&#xA;&#xA;DEBUG_OPT = -DNDEBUG -O3# No debug, optimized for performance.&#xA;#DEBUG_OPT = -g3 -O0 #Produces additional debug information. Add -pg to enable profiling with gprof&#xA;&#xA;CFLAGS = -ansi -DIL_STD -fPIC -fstrict-aliasing -pedantic -Wall -std=gnu++0x -fexceptions -ffloat-store  \&#xA;     -DILOUSEMT -D_REENTRANT -DILM_REENTRANT -I./include &lt;span class=&quot;math-container&quot;&gt;$(DEBUG_OPT)&#xA;CFLAGS += $&lt;/span&gt;(CCOPT) -I&lt;span class=&quot;math-container&quot;&gt;$(CPLEXINCDIR) -I$&lt;/span&gt;(CONCERTINCDIR) -I$(CPOPTINCDIR)&#xA;&#xA;LDFLAGS = -L&lt;span class=&quot;math-container&quot;&gt;$(CPOPTLIBDIR) -lcp -L$&lt;/span&gt;(CPLEXLIBDIR) -lilocplex -lcplex -L$(CONCERTLIBDIR) -lconcert -lm -pthread&#xA;&#xA;# ---- COMPILE  ----&#xA;SRC_DIR   := src&#xA;OBJ_DIR   := obj&#xA;&#xA;SRC_DIRS  := &lt;span class=&quot;math-container&quot;&gt;$(shell find $&lt;/span&gt;(SRC_DIR) -type d)&#xA;OBJ_DIRS  := &lt;span class=&quot;math-container&quot;&gt;$(addprefix $&lt;/span&gt;(OBJ_DIR)/,$(SRC_DIRS))&#xA;&#xA;SOURCES   := &lt;span class=&quot;math-container&quot;&gt;$(shell find $&lt;/span&gt;(SRC_DIR) -name '*.cpp')&#xA;OBJ_FILES := &lt;span class=&quot;math-container&quot;&gt;$(addprefix $&lt;/span&gt;(OBJ_DIR)/, $(SOURCES:.cpp=.o))&#xA;&#xA;vpath %.cpp $(SRC_DIRS)&#xA;&#xA;# ---- TARGETS ----&#xA;&#xA;EXECUTABLE=diffConstrExample&#xA;&#xA;all: $(EXECUTABLE)&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;$(EXECUTABLE): makedir $&lt;/span&gt;(SOURCES) &lt;span class=&quot;math-container&quot;&gt;$(OBJ_FILES) &#xA;    $&lt;/span&gt;(CCC) &lt;span class=&quot;math-container&quot;&gt;$(CFLAGS) $&lt;/span&gt;(OBJ_FILES) &lt;span class=&quot;math-container&quot;&gt;$(LDFLAGS) -o $&lt;/span&gt;@&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;$(OBJ_DIR)/%.o: %.cpp&#xA;    $&lt;/span&gt;(CCC) &lt;span class=&quot;math-container&quot;&gt;$(CFLAGS) $&lt;/span&gt;&amp;lt; -o $@ -c&#xA;&#xA;makedir: $(OBJ_DIRS)&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;$(OBJ_DIRS):&#xA;    @mkdir -p $&lt;/span&gt;@&#xA;&#xA;clean:&#xA;    @rm -rf obj &#xA;    @rm -rf $(EXECUTABLE)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2019-10-16T08:11:21.993" LastActivityDate="2019-10-16T08:11:21.993" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="241" PostTypeId="2" ParentId="61" CreationDate="2019-06-04T21:07:12.067" Score="24" Body="&lt;p&gt;All answers to this question are opinions. So I will add another one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are a researcher and you are good at implementation, you may be able to produce a sequence of papers and results quickly in your subfield of OR. This is especially true if you focus on heuristics for &lt;em&gt;very hard&lt;/em&gt; optimization problems. If you share your code, then you create an opening for other researchers to borrow your implementation and extend it to a related problem &lt;em&gt;before you have the chance to do so yourself&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't like this mindset and I think we should move away from it now. It probably exists in part because the academic peer community which judges scholars values papers and citations above other measures of impact. If good metrics were available to measure the impact of  your published code (reuse, application, extension, forks, etc.) then maybe this culture could change a bit.&lt;/p&gt;&#xA;" OwnerUserId="105" LastActivityDate="2019-06-04T21:07:12.067" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="242" PostTypeId="1" CreationDate="2019-06-04T21:40:55.407" Score="14" ViewCount="531" Body="&lt;p&gt;A list of OR Software forums would be nice. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone import the list of OR Software forums from the (now) read-only OR Exchange at &lt;a href=&quot;https://www.or-exchange.org/questions/9068/or-software-forums&quot; rel=&quot;noreferrer&quot;&gt;https://www.or-exchange.org/questions/9068/or-software-forums&lt;/a&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you please delete extinct software, add additional software, and update links to be current?&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="232" LastEditDate="2019-06-16T14:08:24.917" LastActivityDate="2020-08-13T04:06:02.863" Title="OR Software Forums" Tags="|software|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="243" PostTypeId="2" ParentId="242" CreationDate="2019-06-04T21:40:55.407" Score="27" Body="&lt;p&gt;Here is the augmented and updated list. This should be a good starting point for further improvements.&lt;/p&gt;&#xA;&lt;p&gt;This list is very optimization-heavy (even the automatic differentiation software is most likely to be used by O.R. people in support of nonlinear optimization). So perhaps some additions outside optimization would be warranted, as well as machine learning tools.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**ADiMat (matrix level automatic differentiator in MATLAB)**: Mailing list at https://lists.sc.informatik.tu-darmstadt.de/sympa/info/adimat-users&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**AIMMS**: http://groups.google.com/group/aimms&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**ALGOPY (Automatic differentiator in Python)**:  https://groups.google.com/forum/#!forum/algopy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;AMPL&lt;/strong&gt;: &lt;a href=&quot;http://groups.google.com/group/ampl&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://groups.google.com/group/ampl&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**CasADi**: https://groups.google.com/forum/#!forum/casadi-users&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**COIN-OR** List of mailing lists at [http://list.coin-or.org/mailman/listinfo](http://list.coin-or.org/mailman/listinfo),&amp;lt;br&amp;gt; main page at https://www.coin-or.org/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**CPLEX**: https://community.ibm.com/community/user/datascience/communities/community-home/digestviewer?CommunityKey=ab7de0fd-6f43-47a9-8261-33578a231bb7  **Legacy forum** ht&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**CP Optimizer**: [IBM Forum](http://ibm.biz/ConstraintProgForums), [StackOverflow](https://stackoverflow.com/questions/tagged/cp-optimizer)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**CVX**: http://ask.cvxr.com/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**CVXPY**: https://groups.google.com/forum/#!forum/cvxpy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**GAMS**: https://forum.gamsworld.org/ and http://www.gams.com/maillist/gams_l.htm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**Gurobi**: [https://support.gurobi.com/hc/en-us](https://support.gurobi.com/hc/en-us) (before 04/2019: [Gurobi Optimization](https://groups.google.com/forum/#!forum/gurobi) @ Google Groups)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**JuMP**: https://discourse.julialang.org/c/domain/opt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**KNITRO**: http://groups.google.com/group/knitro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**MANOPT (optimization on manifolds)**: https://groups.google.com/forum/#!forum/manopttoolbox&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**MATLAB**: http://www.mathworks.com/matlabcentral/answers/index&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**MiniZinc**: https://www.minizinc.org/forum.html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**MOSEK**: http://groups.google.com/group/mosek&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**MPT (Multiparametric Toolbox)**: https://groups.google.com/forum/#!forum/mpt-user&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**NEOS**: https://neos-server.org/neos/help.html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**OPL**: https://www.ibm.com/developerworks/community/forums/html/forum?id=11111111-0000-0000-0000-000000002053&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**OptaPlanner (Java, open source)**: [Google Group](https://groups.google.com/forum/#!forum/optaplanner-dev) - [others (issue tracker, StackOverflow, ...)](https://www.optaplanner.org/community/getHelp.html)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**Optimization Services (COIN-OR project)**: http://groups.google.com/group/optimizationservices&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**OPTI Toolbox**: https://groups.google.com/forum/#!forum/opti-toolbox-forum **Effective June 7 2019, OPTI Toolbox Development has ended and the Google group is now read only**. See https://groups.google.com/forum/#!topic/opti-toolbox-forum/dR6x-1gBMkA .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**OR-Tools:**: http://groups.google.com/group/or-tools-discuss&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**PuLP**: https://groups.google.com/forum/#!forum/pulp-or-discuss&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**PYOMO**: https://groups.google.com/forum/#!forum/pyomo-forum&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**Python-MIP**: https://groups.google.com/forum/#!forum/python-mip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**QuanDec**: http://www.cassotis.com/quandec&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**SAS/OR** http://communities.sas.com/t5/Mathematical-Optimization/bd-p/operations_research&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**SCIP**: Use SCIP tag on [https://stackoverflow.com](https://stackoverflow.com/questions/tagged/scip),&amp;lt;br&amp;gt; mailing list at https://listserv.zib.de/mailman/listinfo/scip/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**SciPy**: https://groups.google.com/forum/#!forum/scipy-user&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**SNOPT** https://groups.google.com/forum/#!forum/snopt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**Xpress** https://community.fico.com/s/optimization-user-forum&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;**YALMIP**: http://groups.google.com/group/yalmip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-08-13T04:06:02.863" LastActivityDate="2020-08-13T04:06:02.863" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="244" PostTypeId="1" AcceptedAnswerId="247" CreationDate="2019-06-04T22:07:01.213" Score="50" ViewCount="2815" Body="&lt;p&gt;Can someone please make a list of optimization problem libraries so that the community can add to and refine it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know a few off the top of my head.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="47" LastEditDate="2019-06-04T22:30:57.763" LastActivityDate="2023-03-28T19:42:42.237" Title="Optimization Problem Libraries" Tags="|linear-programming|mixed-integer-programming|nonlinear-programming|test-instances|problem-library|" AnswerCount="8" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="245" PostTypeId="2" ParentId="244" CreationDate="2019-06-04T22:07:01.213" Score="26" Body="&lt;p&gt;Here is a start. Please add to this.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;BOLIB: Bilevel Optimization LIBrary of Test Problems&lt;/strong&gt; &lt;a href=&quot;https://eprints.soton.ac.uk/436854/1/BOLIBver2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://eprints.soton.ac.uk/436854/1/BOLIBver2.pdf&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;CBLIB: The Conic Benchmark Library&lt;/strong&gt;: &lt;a href=&quot;http://cblib.zib.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://cblib.zib.de/&lt;/a&gt; . Twitter at &lt;a href=&quot;https://twitter.com/cblibtw&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://twitter.com/cblibtw&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Collection of solved Pyomo examples&lt;/strong&gt;: &lt;a href=&quot;https://github.com/OptimizationExpert/Pyomo&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/OptimizationExpert/Pyomo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;COMPlib: COnstraint Matrix-optimization Problem library&lt;/strong&gt; (Nonlinear SDPs,  control system design, and related problems) &lt;a href=&quot;http://www.complib.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.complib.de/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;CSPlib: A problem library for constraint optimization and satisfaction&lt;/strong&gt; &lt;a href=&quot;http://www.csplib.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.csplib.org/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;CUTEr/st: Constrained and Unconstrained&lt;/strong&gt; (nonlinear optimization) &lt;strong&gt;Testing Environment&lt;/strong&gt;: &lt;a href=&quot;http://www.cuter.rl.ac.uk/Problems/mastsif.shtml&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.cuter.rl.ac.uk/Problems/mastsif.shtml&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Global Optimization Test Problems (Hedar list)&lt;/strong&gt;: &lt;a href=&quot;http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO.htm&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Global Optimization Test Problems (Neumaier list)&lt;/strong&gt;:&#xA;&lt;a href=&quot;http://arnold-neumaier.at/glopt/test.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arnold-neumaier.at/glopt/test.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Handbook of Test Problems in Local and Global Optimization&lt;/strong&gt;:  &lt;a href=&quot;http://titan.princeton.edu/TestProblems/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://titan.princeton.edu/TestProblems/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;MIPLIB 2017 – The Mixed Integer Programming Library&lt;/strong&gt;: /https://miplib.zib.de/&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;QPLIB: A Library of Quadratic Programming Instances&lt;/strong&gt; &lt;a href=&quot;http://qplib.zib.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://qplib.zib.de/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;SDPLIB 1.2, A Library of Semidefinite Programming Test Problems&lt;/strong&gt; &lt;a href=&quot;http://euler.nmt.edu/%7Ebrian/sdplib/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://euler.nmt.edu/~brian/sdplib/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;SIMOPT (Stochastic) Simulation Optimization Library&lt;/strong&gt;: &lt;a href=&quot;https://github.com/simopt-admin/simopt/wiki/Problem-Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/simopt-admin/simopt/wiki/Problem-Library&lt;/a&gt;  Note: It would be nice if there were more (&amp;quot;real&amp;quot;) multivariate constrained problems.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Test Instances for Multiobjective Mixed-Integer Nonlinear Optimization&lt;/strong&gt; Paper at &lt;a href=&quot;https://optimization-online.org/2023/03/test-instances-for-multiobjective-mixed-integer-nonlinear-optimization/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://optimization-online.org/2023/03/test-instances-for-multiobjective-mixed-integer-nonlinear-optimization/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-03-28T19:42:42.237" LastActivityDate="2023-03-28T19:42:42.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="246" PostTypeId="2" ParentId="244" CreationDate="2019-06-04T22:35:10.900" Score="14" Body="&lt;p&gt;Some more libraries:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Biq Mac Library: a Binary quadratic and max cut Library: &lt;a href=&quot;http://biqmac.uni-klu.ac.at/biqmaclib.html&quot; rel=&quot;noreferrer&quot;&gt;http://biqmac.uni-klu.ac.at/biqmaclib.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;OR Library: a collection of test data sets for a variety of Operations Research problems: &lt;a href=&quot;http://people.brunel.ac.uk/~mastjjb/jeb/info.html&quot; rel=&quot;noreferrer&quot;&gt;http://people.brunel.ac.uk/~mastjjb/jeb/info.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;SIPLIB: a collection of stochastic integer programming problems: &lt;a href=&quot;https://www2.isye.gatech.edu/~sahmed/siplib/&quot; rel=&quot;noreferrer&quot;&gt;https://www2.isye.gatech.edu/~sahmed/siplib/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;SteinLib: a collection of Steiner Tree problems: &lt;a href=&quot;http://steinlib.zib.de/steinlib.php&quot; rel=&quot;noreferrer&quot;&gt;http://steinlib.zib.de/steinlib.php&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;TSPLIB: a library of travelling salesman problems: &lt;a href=&quot;http://elib.zib.de/pub/mp-testdata/tsp/tsplib/tsplib.html&quot; rel=&quot;noreferrer&quot;&gt;http://elib.zib.de/pub/mp-testdata/tsp/tsplib/tsplib.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="43" LastActivityDate="2019-06-04T22:35:10.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="247" PostTypeId="2" ParentId="244" CreationDate="2019-06-04T23:11:01.810" Score="48" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://anjos.mgi.polymtl.ca/qaplib&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quadratic assignment problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.bernabe.dorronsoro.es/vrp&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vehicle routing problem&lt;/a&gt; also at &lt;a href=&quot;http://neumann.hec.ca/chairedistributique/data&quot; rel=&quot;nofollow noreferrer&quot;&gt;HEC&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://elib.zib.de/pub/mp-testdata/tsp/tsplib/tsplib.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Traveling salesman&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://chriswalshaw.co.uk&quot; rel=&quot;nofollow noreferrer&quot;&gt;Graph partitioning&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.qbflib.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quantified Boolean formulas&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.csplib.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;Constraint solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://users.diag.uniroma1.it/challenge9/download.shtml&quot; rel=&quot;nofollow noreferrer&quot;&gt;Shortest paths&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://miplib.zib.de&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mixed integer programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://ttplib.zib.de&quot; rel=&quot;nofollow noreferrer&quot;&gt;Train timetabling&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://sites.nlsde.buaa.edu.cn/%7Ekexu/benchmarks/set-benchmarks.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Set covering and packing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://people.brunel.ac.uk/%7Emastjjb/jeb/orlib/scpinfo.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Beasley's OR library with many problems&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://sites.nlsde.buaa.edu.cn/%7Ekexu/benchmarks/graph-benchmarks.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Maximum clique, Maximum independent set, minimum vertex cover, vertex coloring&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://soa.iti.es/instancias-problemas&quot; rel=&quot;nofollow noreferrer&quot;&gt;Instances for flowshop and routing problems&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://mat.gsia.cmu.edu/COLOR/instances.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Graph coloring&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://biqmac.uni-klu.ac.at/biqmaclib.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Binary quadratic programming and Maximum cut&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.ibr.cs.tu-bs.de/alg/packlib/instances.shtml&quot; rel=&quot;nofollow noreferrer&quot;&gt;Packing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://optimizizer.com/TA.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;Job shop scheduling&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.om-db.wi.tum.de/psplib/main.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Project scheduling&lt;/a&gt; also at &lt;a href=&quot;http://solutionsupdate.ugent.be/index.php/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ghent&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.mech.kuleuven.be/en/cib/op&quot; rel=&quot;nofollow noreferrer&quot;&gt;Orienteering&lt;/a&gt; also &lt;a href=&quot;https://unicen.smu.edu.sg/oplib-orienteering-problem-library&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.coga.tu-berlin.de/v_menue/download_media/clrlib&quot; rel=&quot;nofollow noreferrer&quot;&gt;Capacitated location routing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://basblsolver.github.io/BASBLib/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bilevel programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://steinlib.zib.de//steinlib.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;Steiner trees&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www2.wiwi.uni-jena.de/Entscheidung/binpp/index.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bin packing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://fap.zib.de/problems/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Frequency assignment&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://cedric.cnam.fr/%7Elamberta/Library/iqcp_miqcp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;General mixed-integer quadratically constrained problems&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://homepage.univie.ac.at/ivana.ljubic/research/pcstp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Prize collecting Steiner tree&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.ic.unicamp.br/%7Ecid/Problem-instances/Wireless-Localization/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wireless localization&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://mirplib.scl.gatech.edu/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Maritime transportation planning problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www2.isye.gatech.edu/%7Esahmed/siplib/sslp/sslp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Stochastic server location problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://voptsolver.github.io/vOptLib/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multi-objective linear optimization&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.minlplib.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mixed integer and continuous nonlinear programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://perso.prism.uvsq.fr/%7Eblec/index.php?p=./rech/oc&amp;amp;lang=en&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bin packing, quadratic assigment, cutting stock, vehicle routing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://hhperez.webs.ull.es/PDsite/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pickup and delivery problems&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://benchmark.gent.cs.kuleuven.be/tup/en/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Traveling Umpire problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://resources.mpi-inf.mpg.de/departments/d1/projects/benchmarks/UflLib/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Uncapacitated facility location&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://mistic.heig-vd.ch/taillard/problemes.dir/ordonnancement.dir/ordonnancement.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Flow shop scheduling&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.schedulingbenchmarks.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Employee shift scheduling&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://math.nsc.ru/AP/benchmarks/english.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Discrete location problems&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="87" LastEditorUserId="4752" LastEditDate="2022-01-05T10:31:02.080" LastActivityDate="2022-01-05T10:31:02.080" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="248" PostTypeId="1" AcceptedAnswerId="249" CreationDate="2019-06-04T23:18:39.693" Score="6" ViewCount="229" Body="&lt;p&gt;Here is a typical setup for the newsvendor problem:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The newsvendor buys newspapers for &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; each, sells them for &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; each, and salvages unsold newspapers for &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; each. The demand distribution has pdf &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; and cdf &lt;span class=&quot;math-container&quot;&gt;$F(x)$&lt;/span&gt;. What is the optimal order quantity, &lt;span class=&quot;math-container&quot;&gt;$Q^*$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Each unsold unit (newspapers that the newsvendor buys but is unable to sell) incurs a &lt;em&gt;holding cost&lt;/em&gt; of &lt;span class=&quot;math-container&quot;&gt;$h = c - v$&lt;/span&gt;. Each unmet demand (newspapers that customers demanded but the newsvendor did not have enough inventory to supply) incurs a &lt;em&gt;stockout cost&lt;/em&gt; of &lt;span class=&quot;math-container&quot;&gt;$p = r - c$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Holding and stockout costs are sometimes called overage and underage costs and denoted &lt;span class=&quot;math-container&quot;&gt;$c_o$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_u$&lt;/span&gt;, respectively.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are three ways to approach formulating the objective function (minimizing the newsvendor's expected cost or maximizing expected profit). Each leads to a different &quot;optimal&quot; solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;CAUTION:&lt;/strong&gt; Two of these approaches are wrong! Keep reading.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Approach 1&lt;/em&gt;: Minimize the expected holding and stockout costs:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$g(Q) = \mathbb{E}\left[h(Q-D)^+ + p(D-Q)^+\right],$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is the random demand and &lt;span class=&quot;math-container&quot;&gt;$a^+ = \max\{0,a\}$&lt;/span&gt;; or, &#xA;&lt;span class=&quot;math-container&quot;&gt;$$g(Q) = h\int_0^Q (Q-x)f(x)dx + \int_Q^\infty (x-Q)f(x)dx.$$&lt;/span&gt;&#xA;Taking the derivative, setting it equal to 0, and solving for &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;, we get:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Q^* = F^{-1}\left(\frac{p}{p+h}\right) = F^{-1}\left(\frac{r-c}{r-v}\right).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Approach 2&lt;/em&gt;: We purchase &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; units at a cost of &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; each. Then we incur a cost of &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; per unsold item and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; per unmet demand, so:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;g(Q) &amp;amp; = cQ + \mathbb{E}\left[h(Q-D)^+ + p(D-Q)^+\right] \\&#xA; &amp;amp; = cQ + h\int_0^Q (Q-x)f(x)dx + \int_Q^\infty (x-Q)f(x)dx.&#xA;\end{align}$$&lt;/span&gt;&#xA;Then &#xA;&lt;span class=&quot;math-container&quot;&gt;$$Q^* = F^{-1}\left(\frac{p-c}{p+h}\right) = F^{-1}\left(\frac{r - 2c}{r-v}\right).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Approach 3&lt;/em&gt;: We earn a revenue of &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; per unit sold, and then we incur holding and stockout costs as above. Therefore, the expected profit is as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\pi(Q) &amp;amp; = r\mathbb{E}[\text{units sold}] - \mathbb{E}\left[h(Q-D)^+ + p(D-Q)^+\right] \\&#xA;&amp;amp; = r\left(\int_0^Q xf(x)dx + (1-F(Q))Q \right) - h\int_0^Q (Q-x)f(x)dx - \int_Q^\infty (x-Q)f(x)dx.&#xA;\end{align}$$&lt;/span&gt;&#xA;This gives:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Q^* = F^{-1}\left(\frac{r+p}{r+h+p}\right) = F^{-1}\left(\frac{2r-c}{2r-v}\right).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;All three approaches seem logical. Which one is right, and why?&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="67" LastEditDate="2019-06-05T23:19:04.053" LastActivityDate="2019-06-05T23:19:04.053" Title="Three newsvendor functions, three optimal solutions—which is correct?" Tags="|inventory|newsvendor|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="249" PostTypeId="2" ParentId="248" CreationDate="2019-06-04T23:18:39.693" Score="5" Body="&lt;p&gt;Only approach 1 is correct! The other two approaches &lt;em&gt;double-count&lt;/em&gt; one of the costs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, approach 2 double-counts the cost of purchasing units. The cost of purchasing units is already &quot;baked into&quot; the holding and stockout costs, so it is incorrect to include it explicitly in the objective function. In other words, in approach 2 we are charging &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; twice for each unit purchased, which is why the &quot;optimal&quot; solution for this approach is the same as the optimal solution for approach 1 but with &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; replaced with &lt;span class=&quot;math-container&quot;&gt;$2c$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Approach 3, meanwhile, double-counts the revenue. The revenue is already baked into the stockout cost, so it is incorrect to include it explicitly in the objective function. We are pretending we earn &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; twice for each unit sold, which is why the &quot;optimal&quot; solution for this approach is the same as the optimal solution for approach 1 but with &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; replaced with &lt;span class=&quot;math-container&quot;&gt;$2r$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-04T23:18:39.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="251" PostTypeId="5" CreationDate="2019-06-05T03:11:34.157" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-05T03:11:34.157" LastActivityDate="2019-06-05T03:11:34.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="252" PostTypeId="4" CreationDate="2019-06-05T03:11:34.157" Score="0" Body="For questions involving mathematical problems that aim to minimize or maximize some objective function, possibly subject to one or more constraints." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-07T12:58:23.287" LastActivityDate="2019-06-07T12:58:23.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="253" PostTypeId="5" CreationDate="2019-06-05T03:13:20.737" Score="0" Body="&lt;p&gt;For questions asking for references from the literature or textbooks on specific topics. If possible, references should be accompanied by a hyperlink to the article for accessibility.&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="123" LastEditDate="2020-08-19T13:50:47.990" LastActivityDate="2020-08-19T13:50:47.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="254" PostTypeId="4" CreationDate="2019-06-05T03:13:20.737" Score="0" Body="For questions asking for references from the literature or textbooks on specific topics." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-07T12:59:13.127" LastActivityDate="2019-06-07T12:59:13.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="255" PostTypeId="5" CreationDate="2019-06-05T03:15:50.830" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-05T03:15:50.830" LastActivityDate="2019-06-05T03:15:50.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="256" PostTypeId="4" CreationDate="2019-06-05T03:15:50.830" Score="0" Body="For questions related to Markov decision processes (MDPs), which model decision making in time-varying and usually stochastic environments." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-07T13:00:48.927" LastActivityDate="2019-06-07T13:00:48.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="258" PostTypeId="2" ParentId="231" CreationDate="2019-06-05T11:19:53.157" Score="14" Body="&lt;p&gt;To the best of my knowledge the indicator constraints are just syntactic sugar for the user. Internally these indicator constraints are reformulated using computed big-M formulations or SOS constraints (special ordered set constraints).&lt;br&gt;&#xA;It might be that you are better at computing the value of the big-M using additional knowledge that the solver does not have. Then it very likely that your custom made big-M formulation yields a better bound compared to the automatically generated reformulation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also the discussion here: &lt;a href=&quot;https://or.stackexchange.com/questions/236/why-is-it-important-to-choose-big-m-carefully-and-what-are-the-consequences-of-d&quot;&gt;Why is it important to choose big-M carefully and what are the consequences of doing it badly?&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="137" LastActivityDate="2019-06-05T11:19:53.157" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="259" PostTypeId="2" ParentId="231" CreationDate="2019-06-05T11:34:47.050" Score="20" Body="&lt;p&gt;Here is the advice in the IBM CPLEX documentation. So this pertains to CPLEX. I don't know to what extent it applies to other solvers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, indicator constraints may not be available in all situations:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/indicator_constr/06_restrictions.html&quot; rel=&quot;noreferrer&quot;&gt;Indicator Constraints in Optimization&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;p&gt;The constraint must be linear; a quadratic constraint is not allowed to have an indicator constraint.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;A lazy constraint cannot have an indicator constraint.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;A user-defined cut cannot have an indicator constraint.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Only &lt;span class=&quot;math-container&quot;&gt;$z=0$&lt;/span&gt; (zero) or &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt; (one) is allowed for the indicator variable because the indicator constraint implies that the indicator&#xA;  variable is binary.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/indicator_constr/07_best_prac.html&quot; rel=&quot;noreferrer&quot;&gt;Best Practices with Indicator Constraints&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;p&gt;Avoid Big M values if at all possible. If you choose to introduce Big M values in your model anyway, use the smallest possible value of&#xA;  Big M because Big M values create numerical difficulties and can&#xA;  introduce trickle-flow problems in node LP solutions.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Use indicator constraints instead of Big M when Big M values in the formulation cannot be reduced.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Do not introduce indicator constraints if Big M can be eliminated from your model.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Do not introduce indicator constraints if Big M is eliminated by preprocessing. Check the presolved model to determine whether Big M&#xA;  has been eliminated from your model by preprocessing. In that case, do&#xA;  not introduce indicator constraints for that Big M.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;If valid upper bounds on continuous variables are available, use them. Bounds strengthen LP relaxations. Bounds are used in a MIP for&#xA;  fixing and so forth.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Further Advice:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www-01.ibm.com/support/docview.wss?uid=swg21400084&quot; rel=&quot;noreferrer&quot;&gt;Difference between Using Indicator Constraints and a Big-M Formulation&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Big-M formulations are relatively straightforward, but the value of&#xA;  the &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; term needs to be chosen carefully. If &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is smaller than the&#xA;  upper bound of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, this situation may cut off valid solutions. If &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is&#xA;  too large, the model may become numerically difficult or exhibit&#xA;  trickle flow.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Indicator constraints have the advantage of avoiding these types of&#xA;  problems, as they do not rely on a separate constant value. However,&#xA;  they tend to have weaker relaxations during the MIP optimization, a&#xA;  condition which may lead to longer solve times in a model.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Consider using the big-M form instead of indicators:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;When the big-M factor is not much larger than other coefficients in the model.&lt;/li&gt;&#xA;  &lt;li&gt;If the big-M factor is eliminated in presolve. You can write out the presolved model to check this condition.&lt;/li&gt;&#xA;  &lt;li&gt;If the model does not show any side effects from a big-M formulation.&lt;/li&gt;&#xA;  &lt;li&gt;If [the solver] can not efficiently solve the model formulated with indicator constraints.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Consider using indicator constraints instead of big-M:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;When the big-M factor remains very large, relative to other coefficients in the model.&lt;/li&gt;&#xA;  &lt;li&gt;When the big-M formulation is difficult to express, such as an if-then constraint on complex expressions.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;In all cases, defining upper bound information on the continuous&#xA;  variable will generally yield a much tighter formulation and nearly&#xA;  always helps with performance.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I will have to defer to someone else as to how indicator constraints are handled internally in the solver, for instance in CPLEX, and to what extent SOS may or may not be involved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Big M formulations are subject to logic &quot;errors&quot; due to &quot;trickle flow&quot;. See &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www-01.ibm.com/support/docview.wss?uid=swg21399984&quot; rel=&quot;noreferrer&quot;&gt;Why does a binary or integer variable take on a noninteger value in the solution?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/57/single-reference-for-mixed-integer-programming-formulations-to-linearize-handle/58#58&quot;&gt;Single reference for Mixed Integer Programming formulations to linearize, handle logical constraints and disjunctive constraints, do Big M, etc?&lt;/a&gt; ). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I will update this answer based on any answer I get to a question &lt;a href=&quot;https://www.ibm.com/developerworks/community/forums/html/topic?id=553f63f9-91ce-4469-a34c-3e86b93485ad&amp;amp;ps=25&quot; rel=&quot;noreferrer&quot;&gt;Are indicator constraints immune to trickle flow or other numerics-induced logic 'errors'?&lt;/a&gt; which I just posted on the CPLEX forum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: &lt;strong&gt;Indicator Constraints in CPLEX are immune from the big M/trickle flow issue.&lt;/strong&gt;  I have placed the details, provided Ed Klotz of IBM, in a separate answer to this question.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-06-10T11:34:49.050" LastActivityDate="2019-06-10T11:34:49.050" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="260" PostTypeId="2" ParentId="117" CreationDate="2019-06-05T13:13:03.550" Score="8" Body="&lt;p&gt;This may be out of print but shouldn't be too hard to find.&#xA;One of the best in my opinion on the Practical Aspects...&#xA;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/B01FIZAZCE&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Patrick Rivett's 'The Craft of Decision Modelling'&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="395" LastActivityDate="2019-06-05T13:13:03.550" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="261" PostTypeId="2" ParentId="231" CreationDate="2019-06-05T13:17:46.880" Score="17" Body="&lt;p&gt;For Gurobi there seems to be a dual advantage of using general constraints (&lt;a href=&quot;http://www.gurobi.com/documentation/8.1/refman/constraints.html#subsubsection:GeneralConstraints&quot; rel=&quot;noreferrer&quot;&gt;http://www.gurobi.com/documentation/8.1/refman/constraints.html#subsubsection:GeneralConstraints&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Benefit number one - models are easier to create and can be interpreted easily:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If a model contains general constraints, then Gurobi adds the respective MIP formulations for those constraints during the solution process. In this respect, general constraints are just a means of concisely capturing these relationships between variables while removing the burden of creating an equivalent MIP formulation.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Benefit number two - Gurobi may be able to leverage the implicit knowledge of what a constraint actually does in the solving process:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;However, general constraints have another potential advantage: Gurobi might be able to simplify parts of the MIP formulation if it can prove during presolve that the simplified version suffices for the correctness of the model. For this reason, Gurobi might be able to produce a smaller or tighter representation of the general constraint than you would get from the most general formulation.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="33" LastActivityDate="2019-06-05T13:17:46.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="262" PostTypeId="2" ParentId="248" CreationDate="2019-06-05T14:14:01.120" Score="7" Body="&lt;p&gt;This question provides a good example about a common problem we have when teaching newsvendor concepts. In some of the most useful problem settings, it can be tricky for students to &lt;em&gt;properly specify holding (overage) and stockout (underage) costs&lt;/em&gt;. It just isn't always intuitive and it can be a disservice to students to force them to think this way in every case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is another way to introduce the particular variant in this question; my claim is not that it is easier to understand, but rather that it provides a slightly different perspective that does not require determining overage and underage for a standard form newsvendor. If demand were known, profit is maximized by selecting &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; to minimize:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(Q) = cQ - r \min(Q,d) - v \max(Q-d,0) \; .$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note now that &lt;span class=&quot;math-container&quot;&gt;$\min(Q,d) = d - \max(d-Q,0)$&lt;/span&gt; and thus:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(Q) = -rd + cQ + r \max(d-Q,0) - v \max(Q-d,0) \; .$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To minimize expected costs, we seek to minimize:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$g(Q) = k + c Q + r E[\max(D-Q,0)] - v E[\max(Q-D,0)] \; $$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; in this case is a constant equal to expected revenue earned if we could satisfy all demand. In my view, this form is also useful as an alternative &lt;em&gt;standard&lt;/em&gt; form for newsvendor. We pay &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; per unit item to procure each item, we forego revenue of &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; for each unit of demand that exceeds supply, and we receive a salvage value of &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; for each unit of supply that exceeds demand. When &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is a continuous random variable, it is not difficult to derive the minimizer of &lt;span class=&quot;math-container&quot;&gt;$g(Q)$&lt;/span&gt; directly and to show that at the optimal quantity &lt;span class=&quot;math-container&quot;&gt;$Q^*$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$F_D(Q^*) = \frac{r - c}{c - v}$$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="105" LastActivityDate="2019-06-05T14:14:01.120" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="263" PostTypeId="1" CreationDate="2019-06-05T14:24:34.697" Score="1" ViewCount="150" Body="&lt;p&gt;When coding an application involving a MIP, what are the best practices I should follow? In particular, I mean:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Domain-specific language (GAMS, AMPL) or General purpose (Python, C#)?&lt;/li&gt;&#xA;&lt;li&gt;Structure of the code: should it just be one long list of adding variables, constraints and callbacks or how should it be organized?&lt;/li&gt;&#xA;&lt;li&gt;Are there like “example projects”, where I can see how it is done?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="133" LastEditorUserId="133" LastEditDate="2019-06-05T15:22:56.480" LastActivityDate="2019-06-05T17:29:33.050" Title="What are best practices for coding up MIP models?" Tags="|modeling|" AnswerCount="1" CommentCount="12" ClosedDate="2019-06-05T19:59:55.007" ContentLicense="CC BY-SA 4.0" />
  <row Id="264" PostTypeId="2" ParentId="263" CreationDate="2019-06-05T15:27:20.867" Score="2" Body="&lt;p&gt;&lt;strong&gt;&lt;em&gt;Revised answer after OP's edit&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are interested in a high-level framework on how to start the coding process from reading your initial inputs, how to best handle writing the optimization model, how to handle different solvers, and so on, then I suggest to check out &lt;a href=&quot;https://github.com/ekhoda/optimization-tutorial&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; GitHub repository. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I put that together mainly for teaching purposes. It has an object-oriented design in Python with a simple optimization example to follow for different solvers (Cplex, Gurobi for commercial and PuLP as the open-source package) and I think it's a good starting point, especially for question #2. &lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-05T17:29:33.050" LastActivityDate="2019-06-05T17:29:33.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="265" PostTypeId="5" CreationDate="2019-06-05T17:26:32.100" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-05T17:26:32.100" LastActivityDate="2019-06-05T17:26:32.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="266" PostTypeId="4" CreationDate="2019-06-05T17:26:32.100" Score="0" Body="For questions about solving Operations Research problems using Matlab programming language." OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-18T08:40:02.073" LastActivityDate="2019-06-18T08:40:02.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="267" PostTypeId="2" ParentId="242" CreationDate="2019-06-05T18:00:20.467" Score="5" Body="&lt;ul&gt;&#xA;&lt;li&gt;For users of R and RStudio, there's the &lt;a href=&quot;https://community.rstudio.com/&quot; rel=&quot;noreferrer&quot;&gt;RStudio Community&lt;/a&gt; forum (which covers R topics, not just RStudio).&lt;/li&gt;&#xA;&lt;li&gt;An R user community formerly on Google+ is now the &lt;a href=&quot;https://groups.google.com/forum/#!forum/statistics-and-r-community&quot; rel=&quot;noreferrer&quot;&gt;Statistics and R Community&lt;/a&gt; on Google groups.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-06-05T18:00:20.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="268" PostTypeId="1" CreationDate="2019-06-05T18:05:05.220" Score="14" ViewCount="181" Body="&lt;p&gt;Despite the -- or: due to the -- plethora of alternatives, I still haven't figured out which bibliographic database/search engine (Scopus, zbMATH, Google Scholar, ProQuest, EBSCO, JSTOR, etc.) offers the best coverage of OR/MS publications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, assessing whether a paper presents what is considered the state of the art, cites highly relevant literature, a.s.o. are painful exercises.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my question is: What do &lt;em&gt;you&lt;/em&gt; actually do when you browse the &quot;interweb&quot; for certain keywords, look up relevant publications in a specific (sub-)field, check for updated and/or improved results presented in a paper you've already read, etc.?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you use any of these databases/search engines listed above?&#xA;If so, which -- and why, and how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Furthermore, if you are aware of a comparison/evaluation of databases/search engines from an OR/MS perspective, pointers are much appreciated.)&lt;/p&gt;&#xA;" OwnerUserId="138" LastEditorUserId="123" LastEditDate="2019-10-14T12:53:21.680" LastActivityDate="2019-10-14T12:53:21.680" Title="Bibliographic databases/search engines" Tags="|literature-research|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="269" PostTypeId="2" ParentId="244" CreationDate="2019-06-05T19:14:41.117" Score="13" Body="&lt;p&gt;Some other libraries (mainly for MINLP) are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.minlplib.org/instances.html&quot; rel=&quot;noreferrer&quot;&gt;MINLP-Lib&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://titan.princeton.edu/TestProblems&quot; rel=&quot;noreferrer&quot;&gt;PrincetonLib&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="42" LastActivityDate="2019-06-05T19:14:41.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="270" PostTypeId="5" CreationDate="2019-06-05T19:24:33.307" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-05T19:24:33.307" LastActivityDate="2019-06-05T19:24:33.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="271" PostTypeId="4" CreationDate="2019-06-05T19:24:33.307" Score="0" Body="For questions related to constraints intended to eliminate subtours (disconnected tours) in routing problems. " OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-07T12:58:57.480" LastActivityDate="2019-06-07T12:58:57.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="272" PostTypeId="5" CreationDate="2019-06-05T19:25:13.090" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-05T19:25:13.090" LastActivityDate="2019-06-05T19:25:13.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="273" PostTypeId="4" CreationDate="2019-06-05T19:25:13.090" Score="0" Body="For questions related to applications of operations research models to energy systems. " OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-07T12:58:42.467" LastActivityDate="2019-06-07T12:58:42.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="274" PostTypeId="5" CreationDate="2019-06-05T19:28:48.037" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-05T19:28:48.037" LastActivityDate="2019-06-05T19:28:48.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="275" PostTypeId="4" CreationDate="2019-06-05T19:28:48.037" Score="0" Body="For questions related to the newsvendor problem, which optimizes the inventory action in a single period under stochastic demand in order to balance the tradeoff between ordering too much (and having excess inventory) and ordering too little (and experiencing stockouts)." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-07T12:58:35.857" LastActivityDate="2019-06-07T12:58:35.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="276" PostTypeId="1" CreationDate="2019-06-05T19:33:26.513" Score="19" ViewCount="484" Body="&lt;p&gt;&amp;quot;Recently&amp;quot; &lt;a href=&quot;https://twitter.com/tdhopper/status/111104340621672450&quot; rel=&quot;nofollow noreferrer&quot;&gt;someone asked on Twitter&lt;/a&gt; whether &lt;em&gt;&amp;quot;people still use genetic algorithms for integer programs&amp;quot;.&lt;/em&gt; The &amp;quot;majority answer&amp;quot;, i.e., 1 out of 1, was: &lt;em&gt;&amp;quot;Yes&amp;quot;&lt;/em&gt; .&lt;/p&gt;&#xA;&lt;p&gt;So, &lt;em&gt;my&lt;/em&gt; follow-up question is: With all the (A) progress in computer hardware, solver improvements and decomposition techniques for IPs on the one hand, (B) &amp;quot;elaborated&amp;quot; frameworks for all kinds of search strategies (TS, SA, GA, VNS, ...) on the other -- and, also, (C) constraint (programming) solvers sitting somewhere in between...&lt;/p&gt;&#xA;&lt;p&gt;...how do &lt;em&gt;you&lt;/em&gt; determine if a problem &lt;em&gt;has&lt;/em&gt; to be tackled by technique(s) A, B or/and C [when problem constraints fit to (or: can be captured in) any of these &amp;quot;paradigms&amp;quot;] -- e.g., given a multi-stage version of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Job_shop_scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;JSP&lt;/a&gt; or a &lt;a href=&quot;https://en.wikipedia.org/wiki/Flow_shop_scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;FSP&lt;/a&gt; when the &amp;quot;quality&amp;quot; of the solution outweighs the aspect of availability &amp;quot;near&amp;quot;-time results?&lt;/p&gt;&#xA;&lt;p&gt;What are the criteria/rules of thumb/... that &lt;em&gt;you&lt;/em&gt; apply?&#xA;Which steps do &lt;em&gt;you&lt;/em&gt; think of/go through in order to figure out what might work best?&lt;/p&gt;&#xA;" OwnerUserId="138" LastEditorUserId="138" LastEditDate="2022-08-19T15:16:39.170" LastActivityDate="2022-08-19T15:16:39.170" Title="Combinatorial Optimization: Metaheuristics, CP, IP -- &quot;versus&quot; or &quot;and&quot;?" Tags="|integer-programming|constraint-programming|combinatorial-optimization|metaheuristics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="277" PostTypeId="2" ParentId="276" CreationDate="2019-06-05T21:02:53.310" Score="22" Body="&lt;p&gt;Here, in approximate order, are my criteria.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do I need a provably optimal solution (which rules out metaheuristics, other than to generate an initial feasible solution)?&lt;/li&gt;&#xA;&lt;li&gt;Is this something CPLEX can handle (since I have a license for CPLEX and I'm familiar with it)?&lt;/li&gt;&#xA;&lt;li&gt;If CPLEX can handle it, should I consider a heuristic, metaheuristic or constraint solver to generate a first feasible solution? (This gets determined empirically in most cases, by running CPLEX and seeing how long it takes to a get a &quot;good&quot; incumbent.)&lt;/li&gt;&#xA;&lt;li&gt;Assuming that I'm still shopping for an approach at this point, does the problem have a structure that might favor a constraint solver? In my case, given that I have CP Optimizer but am not nearly as familiar with it as with CPLEX, that usually means there's a scheduling aspect to the problem.&lt;/li&gt;&#xA;&lt;li&gt;If I'm looking for heuristics, is there something in the problem that suggests a likely problem-specific heuristic? If so, go that route. If not, I'll likely go with a GA, since I have experience with GAs and not so much with other metaheuristics.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;One other consideration that does not fit neatly into that list: am I doing this for myself or for someone else? If it's for someone else, and they don't have moderately deep pockets (to pay for a solver license), I'll probably switch to a heuristic/metaheuristic and code it myself. I know about the COIN-OR solvers, but they're mainly for C/C++/Python programmers, and I have not kept tabs with progress (if any) adding Java APIs.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-06-05T21:02:53.310" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="278" PostTypeId="2" ParentId="190" CreationDate="2019-06-05T23:32:13.720" Score="8" Body="&lt;p&gt;It's not exactly the same thing, but very close: in goal programming, using a weighted combination of the deviations from goals is often called &quot;Archimedean&quot; (as in &quot;Archimedean&quot; goal programming, or using &quot;Archimedean weights&quot;). I'm not sure what the origin of that was. An example appears &lt;a href=&quot;https://www.maths.ed.ac.uk/hall/Xpress/FICO_Docs/optimizer/HTML/section5004.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-06-05T23:32:13.720" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="279" PostTypeId="1" AcceptedAnswerId="280" CreationDate="2019-06-05T23:43:32.300" Score="20" ViewCount="2612" Body="&lt;p&gt;What is the difference between Lagrangian relaxation and Lagrangian decomposition? Are they the same thing?&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-05T23:43:32.300" Title="What's the difference between Lagrangian relaxation and Lagrangian decomposition?" Tags="|integer-programming|lagrangian-relaxation|lagrangian-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="280" PostTypeId="2" ParentId="279" CreationDate="2019-06-05T23:43:32.300" Score="25" Body="&lt;p&gt;They are not the same thing. Lagrangian decomposition is a special case of Lagrangian relaxation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;Note&lt;/em&gt;: I'm talking specifically about integer programming problems in this answer, though some of this answer applies to continuous optimization as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Lagrangian relaxation&lt;/em&gt; involves removing (relaxing) one or more constraints and penalizing violations of those constraints in the objective function using coefficients called multipliers. The constraints are chosen so that the problem without the constraints (the &lt;em&gt;subproblem&lt;/em&gt;) is much easier to solve than the original problem. The purpose is to derive a lower bound (for a minimization problem) or an upper bound (for a maximization problem). Often, we use the solution to the subproblem to derive feasible solutions for the original problem, which provide an upper bound (for minimization problems) or a lower bound (for maximization problems). By updating the multipliers (essentially solving a dual problem), we get tighter bounds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Lagrangian decomposition&lt;/em&gt; (introduced by Guignard and Kim (1987)), also known as &lt;em&gt;variable splitting&lt;/em&gt;, is a specific form of Lagrangian relaxation in which we &quot;double&quot; some of the variables, add a constraint requiring the original variables to equal their doubles, and then relax that constraint (using Lagrangian relaxation). It produces bounds that are at least as tight as those from Lagrangian relaxation.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Let me give an example. Consider the &lt;a href=&quot;https://en.wikipedia.org/wiki/Facility_location_problem#Capacitated_facility_location&quot; rel=&quot;noreferrer&quot;&gt;capacitated fixed-charge location problem&lt;/a&gt; (CFLP):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{alignat}{2}&#xA;\text{minimize} \quad &amp;amp; \sum_{j\in J}f_jx_j + \sum_{i\in I}\sum_{j\in J} h_ic_{ij}y_{ij} \\&#xA;\text{subject to} \quad &amp;amp; \sum_{j\in J} y_{ij} = 1 &amp;amp;\quad&amp;amp; \forall i\in I \\&#xA;&amp;amp; \sum_{i\in I} h_iy_{ij} \le v_jx_j &amp;amp;&amp;amp; \forall j \in J \\&#xA;&amp;amp; x_j \in \{0,1\} &amp;amp;&amp;amp; \forall j\in J \\&#xA;&amp;amp; y_{ij} \ge 0 &amp;amp;&amp;amp; \forall i\in I, j\in J &#xA;\end{alignat}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; are the sets of customers and potential facility locations; &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt; is the demand of customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;; &lt;span class=&quot;math-container&quot;&gt;$f_j$&lt;/span&gt; is the fixed cost to open facility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;; &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; is the cost per unit to supply &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;; and &lt;span class=&quot;math-container&quot;&gt;$v_j$&lt;/span&gt; is the capacity of facility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. The decision variables are &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt;, which equals 1 if we open facility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and 0 otherwise; and &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt;, which the fraction of customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;'s demand that we serve from facility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are various other formulations, some of which are superior in some ways, but this one will do for this example. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to attack the problem using &lt;em&gt;Lagrangian relaxation&lt;/em&gt; is to relax the first set of constraints to get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{alignat}{2}&#xA;\text{minimize} \quad &amp;amp; \sum_{j\in J}f_jx_j + \sum_{i\in I}\sum_{j\in J} h_ic_{ij}y_{ij} + &amp;amp;&amp;amp; \sum_{i\in I} \lambda_i\left(1 - \sum_{j\in J} y_{ij}\right) \\&#xA;\text{subject to} \quad &amp;amp; \sum_{i\in I} h_iy_{ij} \le v_jx_j &amp;amp;&amp;amp; \forall j \in J \\&#xA;&amp;amp; x_j \in \{0,1\} &amp;amp;&amp;amp; \forall j\in J \\&#xA;&amp;amp; y_{ij} \ge 0 &amp;amp;&amp;amp; \forall i\in I, j\in J &#xA;\end{alignat}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This subproblem can be solved optimally by solving &lt;span class=&quot;math-container&quot;&gt;$|J|$&lt;/span&gt; continuous knapsack problems, which are easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use &lt;em&gt;Lagrangian decomposition&lt;/em&gt;, introduce new variables &lt;span class=&quot;math-container&quot;&gt;$w_{ij}$&lt;/span&gt; that equal &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt;. We write some of the constraints in the original model using &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and some using &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, split them in the objective function, and  require them to equal each other:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{alignat}{2}&#xA;\text{minimize} \quad &amp;amp; \sum_{j\in J}f_jx_j + \beta\sum_{i\in I}\sum_{j\in J} h_ic_{ij}y_{ij} + &amp;amp;&amp;amp;(1-\beta)\sum_{i\in I}\sum_{j\in J} h_ic_{ij}w_{ij} \\&#xA;\text{subject to} \quad &amp;amp; \sum_{j\in J} w_{ij} = 1 &amp;amp;&amp;amp; \forall i\in I \\&#xA;&amp;amp; \sum_{i\in I} h_iy_{ij} \le v_jx_j &amp;amp;&amp;amp; \forall j \in J \\&#xA;&amp;amp; w_{ij} = y_{ij} &amp;amp;&amp;amp; \forall i\in I, j\in J \\&#xA;&amp;amp; x_j \in \{0,1\} &amp;amp;&amp;amp; \forall j\in J \\&#xA;&amp;amp; y_{ij}, w_{ij} \ge 0 &amp;amp;&amp;amp; \forall i\in I, j\in J &#xA;\end{alignat}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for a constant &lt;span class=&quot;math-container&quot;&gt;$\beta \in [0,1]$&lt;/span&gt;. Then we relax only the &lt;span class=&quot;math-container&quot;&gt;$w_{ij}=y_{ij}$&lt;/span&gt; constraints. I won't write out the subproblem here. It can be solved easily: It decomposes into two problems, one of which reduces to &lt;span class=&quot;math-container&quot;&gt;$|J|$&lt;/span&gt; continuous knapsack problems and a single 0–1 knapsack problem, and the other of which can be solved by inspection. (See Barcelo, Fernandez, and Jörnsten (1991).)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the subproblem from straightforward Lagrangian relaxation has the integrality property while the subproblem from Lagrangian decomposition does not, Lagrangian decomposition yields bounds that are at least as tight as those from straightforward Lagrangian relaxation.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Reference&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Barcelo, J., Fernandez, E. and Jörnsten, K.O. (1991) Computational results&#xA;from a new Lagrangean relaxation algorithm for the capacitated&#xA;plant location problem. &lt;em&gt;European Journal of Operational Research&lt;/em&gt;,&#xA;53(1), 38–45.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Guignard, M. and Kim, S. (1987) Lagrangean decomposition: a model&#xA;yielding strong Lagrangean bounds. &lt;em&gt;Mathematical Programming&lt;/em&gt;,&#xA;39, 215–228.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-05T23:43:32.300" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="281" PostTypeId="1" AcceptedAnswerId="285" CreationDate="2019-06-06T09:00:13.673" Score="11" ViewCount="1273" Body="&lt;p&gt;Let us consider the following problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; be a set of tasks. Each task &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt; has a duration &lt;span class=&quot;math-container&quot;&gt;$d_t$&lt;/span&gt; and a target start time &lt;span class=&quot;math-container&quot;&gt;$s_t$&lt;/span&gt;.&#xA;No two tasks can be executed in parallel. The objective is to minimize the sum of the absolute deviation between the start time of a task and the target start time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possible way to model this problem would be the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall t \in T$&lt;/span&gt; let &lt;span class=&quot;math-container&quot;&gt;$e_t$&lt;/span&gt; be a linear variable representing the absolute deviation between a task start time and its target start time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall t \in T$&lt;/span&gt; let &lt;span class=&quot;math-container&quot;&gt;$a_t$&lt;/span&gt; be a linear variable representing the actual start time of a task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall (t_1, t_2) \in T^2$&lt;/span&gt; let &lt;span class=&quot;math-container&quot;&gt;$x_{t_1,t_2}$&lt;/span&gt; be a binary variable representing if &lt;span class=&quot;math-container&quot;&gt;$t_1$&lt;/span&gt; starts before &lt;span class=&quot;math-container&quot;&gt;$t_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; be a sufficiently large coefficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possible model is then the following&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min\qquad &amp;amp;\sum_{t \in T}e_t\\\text{s.t.}\qquad&amp;amp;e_t \geq s_t - a_t, \forall t \in T\\&amp;amp;e_t \geq a_t - s_t, \forall t \in T\\&amp;amp;x_{t_1,t_2} + x_{t_2,t_1} = 1, \forall (t_1, t_2) \in T^2\\&amp;amp;a_{t_2} + d_{t_2} \leq a_{t_1} + M \cdot x_{t_1,t_2}, \forall (t_1, t_2)\in T^2\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to deal with the non-overlapping constraints without adding a binary variable for each pair of task?&lt;/p&gt;&#xA;" OwnerUserId="124" LastEditorUserId="123" LastEditDate="2019-08-26T18:40:51.777" LastActivityDate="2019-08-26T18:40:51.777" Title="Dealing with non-overlapping constraints" Tags="|mixed-integer-programming|modeling|scheduling|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="282" PostTypeId="1" AcceptedAnswerId="283" CreationDate="2019-06-06T11:54:05.347" Score="14" ViewCount="4772" Body="&lt;p&gt;In Gurobi the user can change the &lt;code&gt;method&lt;/code&gt; parameter in order to force Gurobi to use a particular method for solving MIPs. The user can, amongst others, choose between primal and dual simplex (not changing the parameter will result in Gurobi picking the method for you).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any kinds of problems in which a user should manually pick primal or dual simplex instead of letting Gurobi figuring this out on its own? &lt;/p&gt;&#xA;" OwnerUserId="81" LastEditorUserId="38" LastEditDate="2019-06-06T12:20:19.090" LastActivityDate="2019-06-06T18:47:59.103" Title="When should I use dual Simplex over primal Simplex?" Tags="|gurobi|mixed-integer-programming|simplex|primal-simplex|dual-simplex|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="283" PostTypeId="2" ParentId="282" CreationDate="2019-06-06T13:18:04.373" Score="8" Body="&lt;p&gt;Not an expert on simplex, but here's my attempt on an answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, the solution of the (previous) LP Relaxation will no longer be primal feasible when the primal LP is tightened (e.g. new cut in branch &amp;amp; bound). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the dual simplex, new primal cuts correspond to new dual variables, which are initialized as nonbasic, and thus the previous solution is still dual feasible. Thus dual simplex does not need to regain feasibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in a mixed-integer-programming context, dual simplex will usually outperform primal simplex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general it is easier to get dual feasibility than primal feasibility, and dual simplex appears to make more progress in many iterations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many commercial solvers also offer Barrier methods to solve LP(-Relaxations). The big drawback of interior point methods is that they can't really be warmstarted, and when solving mixed-integer-programmes using branch &amp;amp; bound are generally given a reasonable warm/hot-start (the solution of the previous LP Relaxation). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen a recommendation before that stated that one can use IPMs to solve the root node of the MIP, and then use dual simplex afterwards. See Jakob's answer on how to do that in Gurobi.&lt;/p&gt;&#xA;" OwnerUserId="47" LastEditorUserId="47" LastEditDate="2019-06-06T14:29:26.750" LastActivityDate="2019-06-06T14:29:26.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="284" PostTypeId="2" ParentId="282" CreationDate="2019-06-06T14:17:06.903" Score="9" Body="&lt;p&gt;In addition to @Michael's comment you have to distinguish between the algorithm used to solve the root node of a problem and the algorithm used for the nodes in the branch-and-bound tree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;gurobi (and very likely also other commercial solvers) offer parameters to specify this separately:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gurobi.com/documentation/8.1/refman/method.html#parameter:Method&quot; rel=&quot;noreferrer&quot;&gt;Method&lt;/a&gt; for changing the algorithm used at the root node. If you have enough RAM you can use the deterministic or even non-deterministic mode to use all three methods and use the solution from the algorithm that solves it the quickest.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gurobi.com/documentation/8.1/refman/nodemethod.html#parameter:NodeMethod&quot; rel=&quot;noreferrer&quot;&gt;NodeMethod&lt;/a&gt; for changing the algorithm used at the B&amp;amp;B-nodes.&lt;/li&gt;&#xA;&lt;li&gt;One additional special case: &lt;a href=&quot;http://www.gurobi.com/documentation/8.1/refman/miqcpmethod.html#parameter:MIQCPMethod&quot; rel=&quot;noreferrer&quot;&gt;MIQCPMethod&lt;/a&gt; for Mixed-integer-quadratically-constraint problems. Here you can choose between a linearized outer approximation (which is solved via dual simplex) and usage the barrier method.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In my experience the automatic choice of gurobi does a pretty good job, but if you have doubts you could try the parameter tuning tool. I've only encountered one case where the the problem in the B&amp;amp;B nodes were so big that using barrier was actually faster than using dual simplex.&lt;/p&gt;&#xA;" OwnerUserId="137" LastActivityDate="2019-06-06T14:17:06.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="285" PostTypeId="2" ParentId="281" CreationDate="2019-06-06T14:26:54.247" Score="7" Body="&lt;p&gt;I do not know of any way of handling this without some sort of variable that sorts out whether &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; begins before &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; or vice versa.  Given the NP-completeness of the underlying problem, you will need some sort of binary variable in formulating, but there may be other ways than the method you give.&lt;/p&gt;&#xA;" OwnerUserId="214" LastActivityDate="2019-06-06T14:26:54.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="286" PostTypeId="2" ParentId="268" CreationDate="2019-06-06T16:11:54.920" Score="10" Body="&lt;p&gt;For me, there is no substitute for &lt;a href=&quot;https://scholar.google.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google Scholar&lt;/a&gt;.  The main issue with our field is that it is pretty broad, so it is hard to tell where relevant publications might be.  In many cases, the relevant literature might not be in an &quot;operations research&quot; journal.  &lt;a href=&quot;https://iaorifors.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;International Abstracts in Operations Research&lt;/a&gt; tried to handle that issue by collecting papers from a wide range of publications, identifying those that looked like &quot;operations research&quot;.  But this sort of hand-collection turned out to be difficult to do with the proliferation of journals and with the advent of automatic collection, so IAOR was shut down, though the site given has the last 25 or so years of collected abstracts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google Scholar has the following characteristics:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It is free.  zbMATH and some of the others requires a subscription.  My university does not subscribe to zbMATH and I can't see enough of it to determine whether it is worthwhile to try to push it with our librarian.&lt;/li&gt;&#xA;&lt;li&gt;It covers both journals and conferences.  A lot of operations research is now coming out in high quality, reviewed journals, particularly in those parts of OR that overlap with computer science.  If you miss the conferences, then you miss much of the recent literature.  Google Scholar does a great job of covering things.&lt;/li&gt;&#xA;&lt;li&gt;It has great linkages.  A Google Scholar search often leads to interesting finds by clicking on references of references of references.  &lt;/li&gt;&#xA;&lt;li&gt;The Author pages are really useful.  Once I find someone in an area, being able (in many cases) to click directly on the author page gives a mildly curated view of what that person has worked on, with the ability to quickly find new (or old!) papers from that author.&lt;/li&gt;&#xA;&lt;li&gt;It covers everything.  If there is a paper in the archaeology literature that is relevant to OR, it will be somewhere in Google Scholar.  As I write this, I just got lost for 10 minutes in Google Scholar looking at the archaeology literature, including papers &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/027841658790016X&quot; rel=&quot;nofollow noreferrer&quot;&gt;like this&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;A couple disadvantages:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It is a little too comprehensive.  It can be hard to distinguish quality publications from non-quality publications. Some &lt;a href=&quot;https://or.stackexchange.com/questions/221/how-to-decide-to-write-an-objective-function&quot;&gt;questions on OR.SE&lt;/a&gt; come from trying to understand papers that are essentially nonsense.  But the paper is in Google Scholar, and other than citation count there is no mechanism for distinguishing it from a paper in a high quality journal.  This is particularly important when looking outside my own area for relevant references.&lt;/li&gt;&#xA;&lt;li&gt;As a free resource, Google Scholar can go away overnight if Google decides that is advantageous for them.  Having been burned with &lt;a href=&quot;https://picasa.google.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Picasa&lt;/a&gt; and &lt;a href=&quot;https://www.google.com/reader/about/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google Reader&lt;/a&gt;, I am cautious about putting all my eggs in Google's basket.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="214" LastEditorUserId="214" LastEditDate="2019-06-07T17:00:17.193" LastActivityDate="2019-06-07T17:00:17.193" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="288" PostTypeId="2" ParentId="282" CreationDate="2019-06-06T18:47:59.103" Score="11" Body="&lt;p&gt;Dual simplex is the method of choice for resolving an LP if you have an optimal solution and you change the problem by modifying the feasible region. Ranging the RHS, adding cuts or branching in MIP, Benders decomposition, etc. are examples where that happens. Some other problems are easy to start in the dual method, for example, when all variables have finite upper and lower bounds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Dual simplex is often applied more successfully in combinatorial problems, where degeneracy is an issue for the primal algorithm. For example, in a collection of assignment constraints, there are &lt;span class=&quot;math-container&quot;&gt;$2n$&lt;/span&gt; constraints but only &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; nonzero variables in any basic solution. (There are more efficient methods for pure assignment problems, but the assignment structure is often a component of more complex problems.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe that most industrial solvers now default to the dual algorithm even for general problems. There are effective dual phase-1 procedures and dual steepest-edge pricing, which make the method work well in general.&lt;/p&gt;&#xA;" OwnerUserId="165" LastActivityDate="2019-06-06T18:47:59.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="289" PostTypeId="2" ParentId="268" CreationDate="2019-06-06T22:17:59.363" Score="7" Body="&lt;p&gt;I agree with Dr. Trick that I tend to start with Google Scholar. If I'm looking to see what's been done since a paper was published, I'll often click the &quot;cited by&quot; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option that may be helpful is the preprint site optimization-online.org. Sometimes I'll do a quick search there too.&lt;/p&gt;&#xA;" OwnerUserId="56" LastActivityDate="2019-06-06T22:17:59.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="290" PostTypeId="2" ParentId="224" CreationDate="2019-06-06T22:26:54.457" Score="2" Body="&lt;p&gt;I have also heard the following offices/agencies in the Department of Defense support this type of work:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Army Research Office&lt;/li&gt;&#xA;&lt;li&gt;Air Force Office of Scientific Research (AFOSR)&lt;/li&gt;&#xA;&lt;li&gt;Defense Advanced Research Projects Agency (DARPA)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="56" LastActivityDate="2019-06-06T22:26:54.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="291" PostTypeId="1" CreationDate="2019-06-07T00:15:57.563" Score="23" ViewCount="753" Body="&lt;p&gt;When talking about column generation algorithms, the main example is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Cutting_stock_problem&quot; rel=&quot;noreferrer&quot;&gt;cutting stock problem&lt;/a&gt;. I'm aware that variations of vehicle routing problem (VRP) can be solved using a column generation approach. What are some other problems where column generation-based approaches have been applied successfully? References are really appreciated.&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="51" LastEditDate="2024-02-21T10:54:54.607" LastActivityDate="2024-02-21T10:54:54.607" Title="Reference for column generation applications" Tags="|mixed-integer-programming|reference-request|column-generation|cutting-stock|" AnswerCount="9" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="292" PostTypeId="1" AcceptedAnswerId="293" CreationDate="2019-06-07T00:39:43.327" Score="24" ViewCount="4437" Body="&lt;p&gt;When taking the dual of a linear program (LP), is there a trick/easy way to remember the rules for the directions of the inequalities, signs of the variables, etc.? A trick with a catchy name, perhaps?&lt;/p&gt;&#xA;" OwnerUserId="358" LastActivityDate="2023-04-10T12:27:02.850" Title="How can I remember the rules for taking the dual of a linear program (LP)?" Tags="|linear-programming|duality|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="293" PostTypeId="2" ParentId="292" CreationDate="2019-06-07T00:39:43.327" Score="36" Body="&lt;p&gt;There sure is! It's called the &lt;a href=&quot;https://math.hmc.edu/benjamin/wp-content/uploads/sites/5/2019/06/Sensible-Rules-for-Remembering-Duals%E2%80%93The-S-O-B-Method.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;SOB Method&lt;/a&gt;, originally proposed by A.T. Benjamin.&lt;/p&gt;&#xA;&lt;p&gt;In the SOB method, we classify each variable and each constraint as either &lt;em&gt;sensible&lt;/em&gt;, &lt;em&gt;odd&lt;/em&gt;, or &lt;em&gt;bizarre&lt;/em&gt; (hence the name SOB). For &amp;quot;usual&amp;quot; models, we expect variables to be non-negative (for example, lengths, times, etc.). Sometimes, a variable might be unrestricted (maybe like &lt;span class=&quot;math-container&quot;&gt;$xy$&lt;/span&gt; coordinates in the plane), though this isn't as usual. It's even possible that the variable &lt;em&gt;must&lt;/em&gt; be negative--weird! This intuition leads to:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x\geq0$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\leftarrow$&lt;/span&gt; sensible&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; free &lt;span class=&quot;math-container&quot;&gt;$\leftarrow$&lt;/span&gt; odd&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x\leq0$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\leftarrow$&lt;/span&gt; bizarre&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Note that the classification of variables doesn't depend on whether we're minimizing or maximizing.&lt;/p&gt;&#xA;&lt;p&gt;Constraints are also intuitive. Suppose we're maximizing something. Then we would expect that our constraints should bound &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; from above (so we don't run off to infinity). That is, &lt;span class=&quot;math-container&quot;&gt;$Ax\leq{b}$&lt;/span&gt; constraints are sensible. It's possible the constraints are equalities (somewhat weirder), or we might even have &lt;span class=&quot;math-container&quot;&gt;$Ax\geq{b}$&lt;/span&gt; constraints--weird, because they look like a lower bound, even though we're maximizing.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Maximization&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Ax\leq{b}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\leftarrow$&lt;/span&gt; sensible&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\leftarrow$&lt;/span&gt; odd&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Ax\geq{b}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\leftarrow$&lt;/span&gt; bizarre&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Just the opposite reasoning holds for minimization:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Minimization&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Ax\geq{b}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\leftarrow$&lt;/span&gt; sensible&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\leftarrow$&lt;/span&gt; odd&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Ax\leq{b}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\leftarrow$&lt;/span&gt; bizarre&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Once everything is labeled, taking the dual is easy! A sensible primal variable matches up with a sensible dual constraint, etc. So if we're maximizing, and we have a variable &lt;span class=&quot;math-container&quot;&gt;$x_3\geq0$&lt;/span&gt;, say, then there will be a constraint in the dual with a &lt;span class=&quot;math-container&quot;&gt;$\geq$&lt;/span&gt; sign (the dual is a minimization problem, and &lt;span class=&quot;math-container&quot;&gt;$\geq$&lt;/span&gt; constraints are sensible in the minimization case).&lt;/p&gt;&#xA;&lt;p&gt;Here's a full example from the linked paper:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rl}&#xA;\text{Minimize} &amp;amp; 3x_1+5x_2+x_3\\&#xA;\text{subject to} &amp;amp; x_1+x_2+x_3=2\\&#xA;&amp;amp; 2x_1-3x_3\leq0\\&#xA;&amp;amp;x_1\geq0,x_2\geq0&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;The primal constraints tell us that our dual variables &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; will be, respectively, odd and bizarre. Likewise, the first two dual constraints will be sensible and the third one will be odd, resulting in the following LP:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rl}&#xA;\text{Maximize} &amp;amp; 2y_1\\&#xA;\text{subject to} &amp;amp; y_1+2y_2\leq3\\&#xA;&amp;amp; y_1\leq5\\&#xA;&amp;amp; y_1-3y_2=1\\&#xA;&amp;amp; y_2\leq0&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="358" LastEditorUserId="11613" LastEditDate="2023-04-10T12:27:02.850" LastActivityDate="2023-04-10T12:27:02.850" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="294" PostTypeId="2" ParentId="291" CreationDate="2019-06-07T00:54:45.440" Score="9" Body="&lt;p&gt;I like the column generation algorithm by &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.37.1.40.12823&quot; rel=&quot;noreferrer&quot;&gt;Shen, et al. (2003)&lt;/a&gt; for a location–inventory model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Reference:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shen, Z.-J. M., C. Coullard, and M. S. Daskin. A Joint Location-Inventory Model. &#xA;&lt;em&gt;Transportation Science&lt;/em&gt;, 37:1, 40-55, 2003. &lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-07T00:54:45.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="295" PostTypeId="1" CreationDate="2019-06-07T01:43:16.793" Score="4" ViewCount="163" Body="&lt;p&gt;The following exercise is in the book &lt;em&gt;Operational Research&lt;/em&gt; by Hillier, 7th edition, page 978.&lt;/p&gt;&#xA;&lt;p&gt;In this exercise &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; are the stockout and holding cost parameters, respectively. &lt;span class=&quot;math-container&quot;&gt;$^0_i$&lt;/span&gt; is the optimal value for the order up to level. &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is the parameter &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; of the exponential distribution. In this case &lt;span class=&quot;math-container&quot;&gt;$\lambda=\frac{1}{25}$&lt;/span&gt;. If I understand correctly, period &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; is the second period.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$y^0_i$&lt;/span&gt; be the optimal order-up-to level in period &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;19.7-1.&lt;/strong&gt; Consider the following inventory situation. Demands in different periods are independent but with a common probability density function given by &lt;span class=&quot;math-container&quot;&gt;$$\varphi_D(\xi)=\begin{align}\begin{cases}\frac{e^{-\xi/25}}{25}&amp;amp;\quad\text{for}\,\,\xi\ge0\\0&amp;amp;\quad\text{otherwise}\end{cases}\end{align}$$&lt;/span&gt; Orders may be placed at the start of each period without setup cost at a unit cost of &lt;span class=&quot;math-container&quot;&gt;$c=10$&lt;/span&gt;. There are a holding cost of &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; per unit remaining in stock at the end of each period and a shortage cost of &lt;span class=&quot;math-container&quot;&gt;$15$&lt;/span&gt; per unit of unsatisfied demand at the end of each period (with backlogging except for the final period).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;(a)&lt;/strong&gt; Find the optimal one-period policy.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;(b)&lt;/strong&gt; Find the optimal two-period policy.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The procedure for finding &lt;span class=&quot;math-container&quot;&gt;$y^0_1$&lt;/span&gt; reduces to a simpler result for certain demand distributions. We summarize two such cases next. Suppose that the demand in each period has an exponential distribution.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Then &lt;span class=&quot;math-container&quot;&gt;$y_1^0$&lt;/span&gt; satisfies the relationship &lt;span class=&quot;math-container&quot;&gt;$$(h+c)e^{-\alpha(y_1^0-y_2^0)}+(p+h)e^{-\alpha y_1^0}+\alpha(p+h)(y_1^0-y_2^0)e^{-\alpha y_1^0}=2h+c.$$&lt;/span&gt; An alternative way of finding &lt;span class=&quot;math-container&quot;&gt;$y_1^0$&lt;/span&gt; is to let &lt;span class=&quot;math-container&quot;&gt;$z^0$&lt;/span&gt; denote &lt;span class=&quot;math-container&quot;&gt;$\alpha(y_1^0-y_2^0)$&lt;/span&gt;. Then &lt;span class=&quot;math-container&quot;&gt;$z^0$&lt;/span&gt; satisfies the relation &lt;span class=&quot;math-container&quot;&gt;$$e^{-z^0}\left[(h+c)+(p+h)e^{-\alpha y_2^0}+z^0(p+h)e^{-\alpha y_2^0}\right]=2h+c,$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$y_1^0=\frac1\alpha z^0+y_2^0.$$&lt;/span&gt; When the demand has either a uniform or an exponential distribution, an Excel template is available in your OR Courseware for calculating &lt;span class=&quot;math-container&quot;&gt;$y_1^0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2^0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Attempt.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I first found &lt;span class=&quot;math-container&quot;&gt;$y^0_2$&lt;/span&gt; using &lt;span class=&quot;math-container&quot;&gt;$$\Phi(y^0_2)=\frac{p-c}{p+h}$$&lt;/span&gt; and the definition of&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\Phi(x)=1-e^{-\frac{1}{25}x}.$$&lt;/span&gt; Then I found &lt;span class=&quot;math-container&quot;&gt;$y^0_2=-6.8$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;How do I interpret this value (since it is negative)?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, as the book mentions, I tried to find &lt;span class=&quot;math-container&quot;&gt;$y^0_1$&lt;/span&gt; using the relationship but the calculations started to get complicated, so I used Mathematica and the results were &lt;span class=&quot;math-container&quot;&gt;$$y^0_1= -41.2896\text{ and }y^0_1=25.064.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="415" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-10-14T13:08:06.227" Title="One and two period policy for inventory situation" Tags="|optimization|inventory|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="296" PostTypeId="2" ParentId="295" CreationDate="2019-06-07T02:43:30.297" Score="7" Body="&lt;p&gt;I think you simply made a mistake in the sign of one expression. You already figured out that:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\Phi(y_2^0) = \frac{p-c}{p+h}.$$&lt;/span&gt;&#xA;So:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;&amp;amp;1 - e^{-\frac{1}{25}y_2^0} &amp;amp;&amp;amp;\hspace{-1cm}= \frac{5}{21} \\&#xA;\iff &amp;amp;e^{-\frac{1}{25}y_2^0} &amp;amp;&amp;amp;\hspace{-1cm}= \frac{16}{21} \\&#xA;\iff &amp;amp;-\frac{1}{25}y_2^0 &amp;amp;&amp;amp;\hspace{-1cm}= \ln\frac{16}{21} \\&#xA;\iff &amp;amp;y_2^0 &amp;amp;&amp;amp;\hspace{-1cm}= 6.7983.&#xA;\end{align}$$&lt;/span&gt;&#xA;Now use Mathematica to determine &lt;span class=&quot;math-container&quot;&gt;$y_1^0$&lt;/span&gt; as you did before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, it &lt;em&gt;is&lt;/em&gt; possible to have a negative order-up-to level (i.e., if &lt;span class=&quot;math-container&quot;&gt;$y_2^0$&lt;/span&gt; really did equal &lt;span class=&quot;math-container&quot;&gt;$-6.8$&lt;/span&gt;). It just means that we are operating in &quot;backorder&quot; mode, and we order enough to reduce the number of backorders to &lt;span class=&quot;math-container&quot;&gt;$6.8$&lt;/span&gt;. It's an unusual situation but it's mathematically possible and perfectly valid in a model like this.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="123" LastEditDate="2019-10-14T12:57:30.463" LastActivityDate="2019-10-14T12:57:30.463" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="297" PostTypeId="2" ParentId="268" CreationDate="2019-06-07T04:56:30.523" Score="10" Body="&lt;p&gt;Ultimately, it depends on why you're doing the search. It also depends on what you mean by &quot;coverage&quot; - do you mean you want all papers that can be remotely considered OR/MS, or do you care about ensuring that you've captured everything from a specific (though potentially large) set of journals?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google Scholar is fantastic for broad coverage, and is my usual port of call for when I want a a quick overview on how a specific technique is being used. However, as Dr. Trick pointed out this can be too comprehensive. Also, if you're concerned with paper quality and impact then Google Scholar has a tendency to add a lot of semi-relevant or poorly written papers to the results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For these reasons, I'm a fan of the control that more traditional services such as Scopus give. I much prefer being able to restrict my search to specific journals or construct a boolean monstrosity to weed out a lot of these issues (on top of that, being able to easily export search results can be useful depending on why you're conducting the search in the first place). Of course, this isn't by any means comprehensive, which runs into the opposite problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No single database will ever be the &quot;best&quot;, as they all have competing benefits and drawbacks. The best way to make sure you've got adequate coverage is to use multiple databases. Personally, my workflow tends to be something like:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Search on Google Scholar to identify relevant papers&lt;/li&gt;&#xA;&lt;li&gt;Use the results of Step 1 to formulate a search string in Scopus (allowing restrictions to high impact journals, etc), adding these papers to the results identified through Google Scholar.&lt;/li&gt;&#xA;&lt;li&gt;If need be, repeat from Step 1&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This allows for a balance between including papers in other areas (such as linear programming in archaeology) whilst also ensuring that papers which can be trusted to be high quality as a result of their source are appropriately covered&lt;/p&gt;&#xA;" OwnerUserId="418" LastActivityDate="2019-06-07T04:56:30.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="298" PostTypeId="1" CreationDate="2019-06-07T06:22:10.270" Score="20" ViewCount="469" Body="&lt;p&gt;I have recently learned about the &lt;a href=&quot;https://en.wikipedia.org/wiki/Logarithmic_mean&quot; rel=&quot;nofollow noreferrer&quot;&gt;logarithmic mean&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{x-y}{\ln(x)-\ln(y)},\quad x,y &amp;gt; 0.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is used a lot in chemical engineering optimization models e.g. see slide 15 of &lt;a href=&quot;https://www.doc.ic.ac.uk/~rmisener/MINLPSolver_Tutorial.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Developing spatial branch &amp;amp; bound solvers&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I wonder if anyone else has come across the logarithmic mean elsewhere in optimization?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://pdfs.semanticscholar.org/78f0/2cf8229b44293fbd1e2182e8e1a46cd3a2c6.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Rao and Dey (2014)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; mention a relation to the Lambert &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; function that I find interesting. &lt;a href=&quot;https://www.carma.newcastle.edu.au/resources/jon/WinOpt.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Borwein and Lindstrom (2016)&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt; discuss about the usage of the Lambert &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; function in optimization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. The blog post  &lt;a href=&quot;https://themosekblog.blogspot.com/2019/06/logarithmic-mean-temperature-difference.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Logarithmic mean temperature difference requires yet another cone?&lt;/a&gt; discusses whether you can build a conic representation.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Rao, M., Dey, A. (2014). Scope of the Logarithmic Mean. &lt;em&gt;The Australian Journal of Mathematical Analysis and Applications.&lt;/em&gt; 11(1):1-10. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] Lindstrom, S. B., Borwein, J. M. (2016). Meetings with Lambert &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; and Other Special Functions in Optimization and Analysis.&#xA;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="123" LastEditDate="2019-12-25T10:34:40.157" LastActivityDate="2019-12-26T20:07:53.767" Title="Usages of logarithmic mean in optimization" Tags="|optimization|applications|lambert-w|wright-omega|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="299" PostTypeId="2" ParentId="292" CreationDate="2019-06-07T07:52:01.210" Score="18" Body="&lt;p&gt;I have always, for some reason, had troubles remembering those rules. In the book by Bertsimas and Tsitsiklis there is even a nice little table showing the conversion from a primal to a dual in a nice compact fashion. But as stated, I am not good at remembering these rules. Thus, I always write up the Lagrangean and identify for what values of the dual multipliers the Lagrangean function is unbounded; that gives me the constraints of the dual.&#xA;For example, if we have a linear program of the form &#xA;\begin{align}&#xA;  \min &amp;amp;\ cx\\&#xA;  s.t.: &amp;amp;\ Ax\geq b\\&#xA;        &amp;amp;\ Dx=d\\&#xA;        &amp;amp;\ x\geq 0&#xA;\end{align}&#xA;Then we can assign dual variables &lt;span class=&quot;math-container&quot;&gt;$ \mu\in\mathbb{R}^{m_b}_+ $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\pi\in\mathbb{R}^{m_d} $&lt;/span&gt; to the two sets of constraints. The sign of the dual variables tend to come a little easier when you think of them as adding a penalty for violating the constraints. For example here, &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; should be non-negative, as we want to add a positive amount to the objective function if &lt;span class=&quot;math-container&quot;&gt;$b_i&amp;lt; A_ix$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; should be able to take both positive and negative values, as any solution &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$Dx\neq d$&lt;/span&gt; should be discouraged.&#xA;Hence we have the Lagrangean&#xA;\[&#xA;  L(\mu,\pi)=\min_{x\geq 0}⁡cx+\mu(b-Ax)+\pi(d-Dx) &#xA;\]&#xA;If the Lagrangean is rearranged a bit you get&#xA;\[&#xA;L(\mu,\pi)=\mu b+\pi d + \min_{x≥0}⁡(c-\mu A-\pi D)x&#xA;\]&#xA;We should note, that as &lt;span class=&quot;math-container&quot;&gt;$x\geq 0$&lt;/span&gt; we will have the following definition of the Lagrangean&#xA;\begin{equation}&#xA;L(\mu,\pi)=\begin{cases} -\infty,&amp;amp;\text{if }  (c-\mu A-\pi D)_i&amp;lt;0  \text{ for some variable } x_i \\ \mu b+\pi d&amp;amp;\text{if } c-\mu A-\pi D\geq 0\end{cases}&#xA;\end{equation}&#xA;Thus, if the Lagrangean should be maximized, we want to avoid the cases where &lt;span class=&quot;math-container&quot;&gt;$(c-\mu A-\pi D)_i&amp;lt;0$&lt;/span&gt;. This means that the Lagrangean dual problem (and therefore also the linear programming dual) is given by&#xA;\begin{align}&#xA;\max_{\mu\geq 0,\pi\in\mathbb{R}^{m_d}}L(\mu,\pi) = \max&amp;amp;\ b\mu+d\pi\\&#xA;s.t.:&amp;amp;\ \mu A + \pi D\leq c\\&#xA;     &amp;amp; \mu \geq 0,\pi \text{ free}&#xA;\end{align}&#xA;This helps me as I do not have to remember some conversion-rules (which I most definitely will screw up), and it also keeps it present for me &lt;em&gt;why&lt;/em&gt; the dual looks as it does. This more &quot;mechanical&quot; (admitted, not &quot;easy&quot;) way, has help many of my students too. &lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2019-06-08T16:46:24.093" LastActivityDate="2019-06-08T16:46:24.093" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="300" PostTypeId="2" ParentId="292" CreationDate="2019-06-07T08:35:17.903" Score="10" Body="&lt;p&gt;Here is a simple rule I use. Assume you are minimizing and &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;A x \leq b&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the dual value &lt;span class=&quot;math-container&quot;&gt;$(y)$&lt;/span&gt; tells you how the objective value change if you increase b. Now if you increase b, then you relax the problem and the objective value most go down. Therefore, the dual variables must satisfies&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y \leq 0.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2019-06-07T08:35:17.903" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="301" PostTypeId="2" ParentId="291" CreationDate="2019-06-07T09:13:02.040" Score="12" Body="&lt;p&gt;Axel Parmentier's &lt;a href=&quot;https://pastel.archives-ouvertes.fr/tel-01526771&quot; rel=&quot;noreferrer&quot;&gt;thesis&lt;/a&gt; discuss about application in some airline operations problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You didn't really ask for it, but for reference about VRP related problem, see &lt;a href=&quot;https://link.springer.com/article/10.1007/s10288-010-0130-z&quot; rel=&quot;noreferrer&quot;&gt;Feillet (2010)&lt;/a&gt; and &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-030-17953-3_27&quot; rel=&quot;noreferrer&quot;&gt;Pessoa et al. (2019)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Reference:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Parmentier, Axel. “Algorithms for shortest path and airline problems.” Université Paris-Est, 2016.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Feillet, Dominique. “A Tutorial on Column Generation and Branch-and-Price for Vehicle Routing Problems.” 4OR 8, no. 4 (December 2010): 407–24.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pessoa, Artur, Ruslan Sadykov, Eduardo Uchoa, and François Vanderbeck. “A Generic Exact Solver for Vehicle Routing and Related Problems.” In Integer Programming and Combinatorial Optimization, edited by Andrea Lodi and Viswanath Nagarajan, 11480:354–69. Cham: Springer International Publishing, 2019.&lt;/p&gt;&#xA;" OwnerUserId="132" LastEditorUserId="132" LastEditDate="2019-06-07T09:56:13.530" LastActivityDate="2019-06-07T09:56:13.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="302" PostTypeId="2" ParentId="291" CreationDate="2019-06-07T10:57:54.827" Score="21" Body="&lt;p&gt;A nice comprehensive collection on applications can be found in the book by &lt;a href=&quot;https://doi.org/10.1007/b135457&quot; rel=&quot;noreferrer&quot;&gt;Desaulniers, Desrosiers and Solomon: Column Generation&lt;/a&gt;. It features articles about&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Shortest Path Problems with Resource Constraints&lt;/li&gt;&#xA;&lt;li&gt;Vehicle Routing Problem with Time Windows&lt;/li&gt;&#xA;&lt;li&gt;Cutting Stock Problems&lt;/li&gt;&#xA;&lt;li&gt;Large-Scale Models in the Airline Industry&lt;/li&gt;&#xA;&lt;li&gt;Robust Inventory Ship Routing by Column Generation&lt;/li&gt;&#xA;&lt;li&gt;Ship Scheduling with Recurring Visits and Visit Separation Requirements&lt;/li&gt;&#xA;&lt;li&gt;Job Shop Scheduling&lt;/li&gt;&#xA;&lt;li&gt;Machine Scheduling&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also the paper &lt;a href=&quot;ftp://ftp.math.tu-berlin.de/pub/Preprints/combi/Report-008-2004.pdf&quot; rel=&quot;noreferrer&quot;&gt;Selected Topics in Column Generation&lt;/a&gt; has some examples on page 3. (&lt;a href=&quot;https://doi.org/10.1287/opre.1050.0234&quot; rel=&quot;noreferrer&quot;&gt;DOI link&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="56" LastEditDate="2019-06-28T13:05:50.423" LastActivityDate="2019-06-28T13:05:50.423" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="303" PostTypeId="2" ParentId="291" CreationDate="2019-06-07T11:28:04.097" Score="12" Body="&lt;p&gt;Multi-agent pathfinding is a classical artificial intelligence problem that I recently solved using column generation. This implementation is substantially faster than the previous state-of-the-art. The paper and code (!) is available on my web page &lt;a href=&quot;https://ed-lam.com&quot; rel=&quot;noreferrer&quot;&gt;ed-lam.com&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="44" LastActivityDate="2019-06-07T11:28:04.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="304" PostTypeId="1" CreationDate="2019-06-07T12:23:38.100" Score="14" ViewCount="495" Body="&lt;p&gt;It is quite frequent that optimization algorithms have quite some parameters controlling their behavior (cooling schedule of a Simulated Annealing, length of the tabu list for a Tabu Search, population size for a Genetic Algorithm, etc...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One will typically spend quite some time fine tuning those parameters using a &quot;representative&quot; set of instances. However it can happen that a set of parameters will work very well on one instance but quite poorly on another one (particularly if the set of representative instances is quite heterogeneous).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would seem interesting, based on some instance characteristics to determine (probably using supervised learning techniques) before solving which parameters values are the most likely to give good results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to find some information about this idea in the literature but could not find anything. Do you know of any success/failure stories related to this idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;On a related note I know about Adaptive Large Neighborhood Search (ALNS), where one tries to figure out during the search which neighborhoods are the most efficient for the instance being currently solved. I am more interested about an approach where the parameters are completely determined before starting the actual solving process.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="124" LastEditorUserId="87" LastEditDate="2019-06-15T18:17:47.843" LastActivityDate="2023-10-24T12:51:23.820" Title="Use of machine learning techniques to determine parameter values" Tags="|literature-research|parameters-tuning|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="305" PostTypeId="2" ParentId="1" CreationDate="2019-06-07T13:28:30.303" Score="3" Body="&lt;p&gt;I've thought about this for a bit, and I now believe that leadtime demand in most common situations is &lt;em&gt;not normally distributed&lt;/em&gt;, although it may be as usual a good approximation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, we know that the normal distribution has infinite tails which means you could argue that it is not ever appropriate for non-negative random variables, like demand. This is a silly argument; after all, the Central Limit Theorem holds that the distribution of the sum of a large number of independent non-negative random variables tends to a normal distribution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When modeling demand over time, I find it useful to think about a cumulative stochastic process &lt;span class=&quot;math-container&quot;&gt;$D(t)$&lt;/span&gt; counting all demand from time zero to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$D(0)=0$&lt;/span&gt;. If this process has independent increments and if the distribution of &lt;span class=&quot;math-container&quot;&gt;$D(t)$&lt;/span&gt; is assumed to be normal with mean &lt;span class=&quot;math-container&quot;&gt;$\mu_D t$&lt;/span&gt; and variance &lt;span class=&quot;math-container&quot;&gt;$\sigma_D^2 t$&lt;/span&gt;, then it is a classic Brownian motion with drift coefficient &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; (also assuming continuous paths in time, which is somewhat technical).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some thought, I have realized that while &lt;span class=&quot;math-container&quot;&gt;$D(t)$&lt;/span&gt; is a normal random variable for any fixed &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, it is not true in general that &lt;span class=&quot;math-container&quot;&gt;$D(L)$&lt;/span&gt; is a normal random variable for a stochastic lead time &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;. The simplest counterargument is to suppose that &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is a Bernoulli random variable; in this case, the probability density of &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; would include a point mass of &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; at zero mixed with a continuous density everywhere else. This is not any normal density of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last important question is how good is a normal approximation in this case, with mean &lt;span class=&quot;math-container&quot;&gt;$\mu_D\Bbb E[L]$&lt;/span&gt; and variance &lt;span class=&quot;math-container&quot;&gt;$\sigma_D^2 \Bbb E[L] + \mu^2 \operatorname{var}(L)$&lt;/span&gt;, for setting an appropriate reorder point.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: Ideas after @LarrySnyder610 answer&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Larry's answer shows that when we assume &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is nearly normally-distributed, the distribution of &lt;span class=&quot;math-container&quot;&gt;$D(L)$&lt;/span&gt; also appears to be well-approximated by a normal distribution. In his answer, &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is a truncated non-negative normal random variable, taking value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; with probability &lt;span class=&quot;math-container&quot;&gt;$P(N(\mu_L, \sigma^2_L)\leq 0)$&lt;/span&gt; but having a normal density for &lt;span class=&quot;math-container&quot;&gt;$L &amp;gt; 0$&lt;/span&gt;. When &lt;span class=&quot;math-container&quot;&gt;$\mu_L$&lt;/span&gt; is large enough and &lt;span class=&quot;math-container&quot;&gt;$\sigma^2_L$&lt;/span&gt; is small enough, my guess is that the normal approximation is a good one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea we are exploring here is one of &lt;em&gt;compounding distributions&lt;/em&gt;. A compound probability distribution &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; results when a parametrized distribution &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is marginalized given a distribution for the parameter. In our case, we have a single parameter &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; (univariate), and thus:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f_D(t) = \int f_N(t \mid \ell) \; f_L(\ell) \, d\ell,$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f_N(t \mid \ell)$&lt;/span&gt; is normal with mean &lt;span class=&quot;math-container&quot;&gt;$\mu_D \ell$&lt;/span&gt; and variance &lt;span class=&quot;math-container&quot;&gt;$\sigma_D^2 \ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_L(\ell)$&lt;/span&gt; is normal with mean &lt;span class=&quot;math-container&quot;&gt;$\mu_L$&lt;/span&gt; and variance &lt;span class=&quot;math-container&quot;&gt;$\sigma^2_L$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know much about compounding distributions. From what I've read, compounding a normal distribution with a normally-distributed mean leads to a another normal distribution. In our case, we have a normally-distributed mean and normally-distributed variance and they depend on the same underlying normal parameter &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt;. It would be exciting to find out that such a compounding led to a normal distribution.&lt;/p&gt;&#xA;" OwnerUserId="105" LastEditorUserId="123" LastEditDate="2019-07-02T14:42:47.917" LastActivityDate="2019-07-02T14:42:47.917" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="306" PostTypeId="1" AcceptedAnswerId="309" CreationDate="2019-06-07T13:48:32.157" Score="12" ViewCount="240" Body="&lt;p&gt;Consider the following simple integer program&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{ll} \text{maximize} &amp;amp; 3 x_1 - x_2\\ \text{subject to}  &#xA;&amp;amp; 3x_1 - x_2 \leqslant 3 \\ &amp;amp; -5x_1 - 4x_2 \leqslant -10 \\ &amp;amp; 2x_1 + x_2 \leqslant 5 \\ &amp;amp; x_1, x_2 \geqslant 0 \\ &amp;amp; x_1, x_2 \in \Bbb{Z}\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When trying to solve this IP with the simplex algorithm and Gomory cutting planes, I did 3 iterations and gave up. However, by enumerating possible solutions (that's only 5 points), I easily found the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know if there's a general solution to the slow convergence of Gomory cutting.&lt;/p&gt;&#xA;" OwnerUserId="423" LastEditorUserId="8" LastEditDate="2019-06-08T17:24:16.057" LastActivityDate="2019-06-08T17:24:16.057" Title="How to reduce recursion when using Gomory cutting planes to solve an integer program?" Tags="|linear-programming|integer-programming|simplex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="307" PostTypeId="2" ParentId="304" CreationDate="2019-06-07T14:42:14.817" Score="5" Body="&lt;p&gt;To my understanding, the tuning process you just mentioned is also an learning technique where your training set is your set of representative instances. The problem is with generalization because your training has been too biased or representative set has not been a good training set. In parameter tuning, you may wish to do cross validations similar to ML. Moreover, the combinatorial problems are very unpredictable and one cannot fix a parameter and hope that it works well for all instances. For this reason, one may come up with a set of rules to determine the value of a search parameter (e.g., in root node use primal simplex and in the child nodes use dual simplex when you want to decide on what LP algorithm to use in branch-and-cut) instead having one fix a predetermined value.&lt;/p&gt;&#xA;&lt;p&gt;You may find these works interesting as well:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.qjie.ir/article_125.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;A Simulated Annealing Algorithm within the Variable Neighbourhood Search Framework to Solve the Capacitated Facility Location-Allocation Problem&#xA;Learning Mechanisms and Local Search Heuristics for the Fixed Charge Capacitated Multicommodity Network Design&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.cirrelt.ca/DocumentsTravail/CIRRELT-2018-12.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;A Learning-Based Matheuristic for Stochastic Multicommodity Network Design&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="424" LastEditorUserId="491" LastEditDate="2023-10-24T12:51:23.820" LastActivityDate="2023-10-24T12:51:23.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="308" PostTypeId="2" ParentId="304" CreationDate="2019-06-07T15:26:00.820" Score="9" Body="&lt;p&gt;The problem you are referring to is &lt;a href=&quot;https://en.wikipedia.org/wiki/Hyperparameter_optimization&quot; rel=&quot;noreferrer&quot;&gt;hyper-parameter optimization&lt;/a&gt; and a simple search in google will bring up many blogs (and of course) research that has been done in this area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You haven't asked this, but since you mentioned a few algorithms (SA, Tabu search, ...), in case you are also interested to select the best algorithm for different data sets, then you are looking at &lt;a href=&quot;https://en.wikipedia.org/wiki/Meta_learning_(computer_science)&quot; rel=&quot;noreferrer&quot;&gt;meta learning&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few other useful links to give you an idea of the research in this area can be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.aaai.org/ocs/index.php/AAAI/AAAI15/paper/viewPaper/9993&quot; rel=&quot;noreferrer&quot;&gt;Efficient Benchmarking of Hyperparameter Optimizers via Surrogates&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s10994-017-5692-y&quot; rel=&quot;noreferrer&quot;&gt;Metalearning and Algorithm Selection: progress, state of the art and introduction to the 2018 Special Issue&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-07T15:57:08.697" LastActivityDate="2019-06-07T15:57:08.697" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="309" PostTypeId="2" ParentId="306" CreationDate="2019-06-07T15:37:39.723" Score="13" Body="&lt;p&gt;The slow convergence of the Gomory cuts was well-known and source of frustration for the field up until the 90s.  It seemed that Gomory cuts would be a cute idea, but not one that would lead to any real computational success.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then work by &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/0167637796000077&quot; rel=&quot;noreferrer&quot;&gt;Balas, Ceria, Cornuejols, and Natraj&lt;/a&gt; rekindled interest in the area, and Gomory cuts became very important in real computation.  Cornuejols wrote up a &lt;a href=&quot;https://link.springer.com/article/10.1007%2Fs10479-006-0100-1?LI=true&quot; rel=&quot;noreferrer&quot;&gt;nice reminiscence&lt;/a&gt; of this.  Lots of papers followed (I particularly like &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0167637702001128&quot; rel=&quot;noreferrer&quot;&gt;Letchford and Lodi&lt;/a&gt;, available &lt;a href=&quot;https://www.lancaster.ac.uk/staff/letchfoa/articles/2002-Gomory.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, but there are others).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me give one result for better Gomory cuts.  This result was in Gomory's original paper:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a row of the simplex tableau of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_j + \sum_{i\in Q} \alpha_i x_i = x_j^*$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is the set of non-basic variables&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then the Gomory cut is &#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in Q} f(\alpha_i) x_i \ge f(x_j^*)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is the fractional part of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.  So an example of a Gomory cut might be &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$0.2 x_1 + 0.3x_2 \ge 0.1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can multiple this constraint by any integer &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and use fractional parts to get a different cut:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in Q} f(t\alpha_i) x_i \ge f(tx_j^*)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Multiplying the above example by 9 gives &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$0.8x_1+0.7x_2 \ge 0.9$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which is stronger, meaning some values that satisfy the original Gomory cut don't satisfy this constraint (&lt;span class=&quot;math-container&quot;&gt;$x_1= .5, x_2=0$&lt;/span&gt; for instance).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of this is particular useful for solving instances by hand.  Anything small enough to do by hand would generally be done better by, for instance, enumerating points, as given in the original question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Added&lt;/strong&gt; I suppose in the example being solved, if the right-hand-side of any constraint generated is less than 0.5, it would be worthwhile to see if strengthening it via the above speeds up convergence.&lt;/p&gt;&#xA;" OwnerUserId="214" LastEditorUserId="214" LastEditDate="2019-06-07T15:43:39.023" LastActivityDate="2019-06-07T15:43:39.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="312" PostTypeId="1" CreationDate="2019-06-07T19:43:39.680" Score="13" ViewCount="853" Body="&lt;p&gt;I have a problem with a nonlinear constraint. The non-linearity stems from a term of the form &lt;span class=&quot;math-container&quot;&gt;$xb$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^+$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x &amp;lt; M$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b \in \{0, 1\}$&lt;/span&gt;. I am able to remove this non-linearity by using McCormick envelopes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I solve the problem using this relaxation, am I actually solving the problem or am I just finding a very tight lower bound?. Remember that one of the variables is binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if &lt;span class=&quot;math-container&quot;&gt;$b \in \mathbb{N}$&lt;/span&gt; instead?&lt;/p&gt;&#xA;" OwnerUserId="434" LastEditorUserId="279" LastEditDate="2019-06-11T18:35:04.030" LastActivityDate="2019-06-11T18:35:04.030" Title="McCormick envelopes and nonlinear constraints" Tags="|linearization|nonlinear-programming|mccormick|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="313" PostTypeId="2" ParentId="312" CreationDate="2019-06-08T02:35:44.143" Score="11" Body="&lt;p&gt;For real &lt;span class=&quot;math-container&quot;&gt;$x\in[l,u]$&lt;/span&gt; and binary &lt;span class=&quot;math-container&quot;&gt;$b\in\{0,1\}$&lt;/span&gt; the McCormick envelope gives you bounds on &lt;span class=&quot;math-container&quot;&gt;$w=xy$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;lb &amp;amp; \leq w \leq ub,\\&#xA;ub+x-u&amp;amp; \leq w\leq x+lb-l.&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By case analysis you can see that this is equal to &lt;span class=&quot;math-container&quot;&gt;$w=xb$&lt;/span&gt;, so you will indeed solve the problem.&lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2019-06-08T02:35:44.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="314" PostTypeId="1" AcceptedAnswerId="349" CreationDate="2019-06-08T02:58:24.650" Score="12" ViewCount="506" Body="&lt;p&gt;&lt;sub&gt;&lt;a href=&quot;https://stats.stackexchange.com/questions/412055/how-to-handle-real-world-soft-constraints-in-an-optimization-problem&quot;&gt;Cross-posted&lt;/a&gt; at Stats.SE (aka Cross Validated)&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am working on a problem which involves optimizing for minimum power consumption in a large compressor network interconnected through pipelines (think of a connected graph with nodes as compressors and arcs as pipelines). I need to impose a constraint when two or more compressors share a single pipeline on their discharge side, i.e. , their individual discharge pressures should ideally be equal.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, when I read in the historical plant operational data recorded through the sensors, I notice that these variables are fairly close but not precisely equal already. This could likely be due to sensor error. My question is how to model such constraints in an optimization problem so that you account for the slight variability among the variables instead of imposing a strict equality constraint.  &lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="138" LastEditDate="2019-06-16T01:09:00.400" LastActivityDate="2019-06-17T21:07:12.677" Title="How to handle real-world (soft) constraints in an optimization problem?" Tags="|optimization|constraint|modeling|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="315" PostTypeId="2" ParentId="292" CreationDate="2019-06-08T06:02:50.057" Score="3" Body="&lt;p&gt;We can present the canonical format for minimization and maximization problems as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} \min &amp;amp;\quad cx\\ \text{s.t.} &amp;amp;\quad Ax\geq b\\  &amp;amp;\quad x\geq 0 \end{align}&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align} \max &amp;amp;\quad wb\\ \text{s.t.} &amp;amp;\quad wA\leq c\\  &amp;amp;\quad w\geq 0 \end{align}&lt;/span&gt;&#xA;The second problem is dual of the first problem and vice versa.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt; in the first problem results in having free variable &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; in the dual problem (vice versa) and &lt;span class=&quot;math-container&quot;&gt;$Ax\leq b$&lt;/span&gt; results in &lt;span class=&quot;math-container&quot;&gt;$w\leq 0$&lt;/span&gt; in dual problem  (vice versa).&lt;/p&gt;&#xA;&lt;p&gt;In the same fashion, &lt;span class=&quot;math-container&quot;&gt;$wA=c $&lt;/span&gt; gives &lt;span class=&quot;math-container&quot;&gt;$x $&lt;/span&gt; free  (vice versa) ....&lt;/p&gt;&#xA;" OwnerUserId="386" LastEditorUserId="123" LastEditDate="2022-01-18T08:42:24.687" LastActivityDate="2022-01-18T08:42:24.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="316" PostTypeId="5" CreationDate="2019-06-08T07:46:39.090" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-08T07:46:39.090" LastActivityDate="2019-06-08T07:46:39.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="317" PostTypeId="4" CreationDate="2019-06-08T07:46:39.090" Score="0" Body="Questions on algorithms that combine branch-and-bound search and the generation of cutting planes." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-08T13:07:18.187" LastActivityDate="2019-06-08T13:07:18.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="318" PostTypeId="5" CreationDate="2019-06-08T07:57:25.220" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-08T07:57:25.220" LastActivityDate="2019-06-08T07:57:25.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="319" PostTypeId="4" CreationDate="2019-06-08T07:57:25.220" Score="0" Body="Questions on algorithms that solve mathematical models by generating columns (variables) in the pricing step during solution on demand." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-08T13:07:04.590" LastActivityDate="2019-06-08T13:07:04.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="320" PostTypeId="1" AcceptedAnswerId="321" CreationDate="2019-06-08T08:44:05.007" Score="13" ViewCount="1456" Body="&lt;p&gt;I'm trying to use lazy constraints to solve an optimization problem. In some software such as CPLEX or GUROBI, they have some tools to handle them directly (in the original model) or using callback functions. &#xA;I was wondering what is the difference between them?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="38" LastEditDate="2019-06-08T11:54:08.907" LastActivityDate="2019-06-08T16:58:06.130" Title="Difference between lazy callbacks and using lazy constraints directly" Tags="|mixed-integer-programming|optimization|constraint|solver|callback|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="321" PostTypeId="2" ParentId="320" CreationDate="2019-06-08T09:44:40.247" Score="18" Body="&lt;p&gt;Lazy constraints will only be checked when an MIP solution satisfying all other constraints, including integrality, is found. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you provide all your lazy constraints in advance to CPLEX, for example, then your main benefit is that these constraints are only checked against solutions that would otherwise be feasible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you may have an exponential number of such constraints, even though in some cases you could easily tell if any of those constraints would be violated by a particular solution. In such case, implementing a lazy cut callback is a good idea because you can provide these constraints to CPLEX only when they are needed, and consequently you speed up the solving process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One classic example of that is the subtour elimination constraint for the traveling salesperson problem. If a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; is 1 when you go from city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to city &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, then you can start with the assignment constraints (you should get in and out of every city exactly once). If a solution is found in which you cycle through a subset &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of the cities, you add the corresponding subtour elimination constraint to ensure that you visit one city in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; coming from a city outside &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; or vice-versa. The number of such constraints is exponential, but you know how to efficiently identify which one matters for your current assignment.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2019-06-08T16:58:06.130" LastActivityDate="2019-06-08T16:58:06.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="322" PostTypeId="1" CreationDate="2019-06-08T19:12:10.927" Score="10" ViewCount="214" Body="&lt;p&gt;Suppose I'm solving a minimum-weight matching problem in a bipartite graph with sets &lt;span class=&quot;math-container&quot;&gt;$\mathcal{I}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$w_{ij}$&lt;/span&gt; denotes the weight of matching item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. I can model the problem as a stable marriage problem and set the preferences of &lt;span class=&quot;math-container&quot;&gt;$i \in \mathcal{I}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is preferred over &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; whenever &lt;span class=&quot;math-container&quot;&gt;$w_{ij} &amp;lt; w_{ik}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$j, k \in \mathcal{J}$&lt;/span&gt;, and similarly for all items in &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}$&lt;/span&gt;. Are there any optimality guarantees or bounds on the cost of any stable match under these preferences, compared to a minimum-weight match?&lt;/p&gt;&#xA;" OwnerUserId="448" LastEditorUserId="38" LastEditDate="2019-06-09T18:19:49.560" LastActivityDate="2019-06-09T18:19:49.560" Title="Relationship between the Assignment Problem and the Stable Marriage Problem" Tags="|combinatorial-optimization|assignment-problem|matching|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="323" PostTypeId="1" AcceptedAnswerId="324" CreationDate="2019-06-08T20:24:52.783" Score="18" ViewCount="514" Body="&lt;p&gt;The Traveling Salesman Problem is perhaps the most studied of all combinatorial optimization problems.  There has been a lot work in solving TSP instances to provable optimality.  &lt;a href=&quot;http://www.math.uwaterloo.ca/tsp/concorde.html&quot; rel=&quot;noreferrer&quot;&gt;Concorde&lt;/a&gt; solves very large instances to provable optimality, with the largest solved having &lt;a href=&quot;http://www.math.uwaterloo.ca/tsp/pla85900/index.html&quot; rel=&quot;noreferrer&quot;&gt;85,900 points&lt;/a&gt;.  There is a &lt;a href=&quot;http://www.math.uwaterloo.ca/tsp/data/ml/monalisa.html&quot; rel=&quot;noreferrer&quot;&gt;100,000 city problem&lt;/a&gt; that has not been solved to provable optimality.   But there are some &lt;a href=&quot;http://www.math.uwaterloo.ca/tsp/world/countries.html&quot; rel=&quot;noreferrer&quot;&gt;smaller instances&lt;/a&gt; not solved to optimality, with the smallest at 6732 cities.  Is this the smallest &quot;difficult instance&quot;?   Are there small TSPs that are hard for Concorde or other other optimization approaches to solve? &lt;/p&gt;&#xA;" OwnerUserId="214" LastActivityDate="2023-06-10T15:49:17.790" Title="Small Traveling Salesman Problem instance" Tags="|traveling-salesman|test-instances|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="324" PostTypeId="2" ParentId="323" CreationDate="2019-06-08T21:01:21.310" Score="13" Body="&lt;p&gt;There is a paper of &lt;a href=&quot;https://doi.org/10.1007/978-3-642-20525-5_1&quot; rel=&quot;noreferrer&quot;&gt;Ahammed and Moscato&lt;/a&gt; on finding hard instances for Concorde using Lindenmeyer systems. They were able to find small instances with about 1500 cities that took (in 2011) more than 4 hours to solve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One should probably add that &quot;hard&quot; always means &quot;hard for some algorithm&quot;. So, for balance, here is a &lt;a href=&quot;http://dx.doi.org/10.1007/s10472-011-9230-5&quot; rel=&quot;noreferrer&quot;&gt;paper of Kate Smith-Miles &amp;amp; van Hemert&lt;/a&gt; studying hardness for variants of the Kernighan-Lin algorithm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more on the pitfalls of &quot;hard&quot; versus &quot;easy&quot; in the context of SAT, there's an excellent &lt;a href=&quot;http://www.birs.ca/events/2014/5-day-workshops/14w5101/videos/watch/201401231116-Vardi.mp4&quot; rel=&quot;noreferrer&quot;&gt;talk of Moshe Vardi&lt;/a&gt; where he concludes that &quot;the 'easy-hard-easy' picture is patently wrong&quot;.&lt;/p&gt;&#xA;" OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-08T21:19:22.963" LastActivityDate="2019-06-08T21:19:22.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="325" PostTypeId="2" ParentId="323" CreationDate="2019-06-08T21:12:44.570" Score="8" Body="&lt;p&gt;There is a paper by Papadimitriou and Steiglitz &lt;a href=&quot;https://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;url=https://pdfs.semanticscholar.org/7487/ea033b1729fb7695841673ece0e4782fdb88.pdf&amp;amp;ved=2ahUKEwjvkbn14triAhUkiOAKHfrnBE8QFjAQegQICBAB&amp;amp;usg=AOvVaw3914Eqq0wxHhc6vbw-c-gK&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; to construct instances, which are very hard for local searches to find optimal solution.&lt;/p&gt;&#xA;" OwnerUserId="386" LastActivityDate="2019-06-08T21:12:44.570" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="326" PostTypeId="1" AcceptedAnswerId="331" CreationDate="2019-06-08T21:36:53.310" Score="8" ViewCount="144" Body="&lt;p&gt;Is there any implementation, code or software, which can switch between search strategies in a B&amp;amp;B framework? &lt;/p&gt;&#xA;" OwnerUserId="386" LastActivityDate="2019-06-11T08:06:03.547" Title="How to change the search strategy in a B&amp;B framework, i.e., start with depth first and then continue with best node?" Tags="|branch-and-bound|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="327" PostTypeId="2" ParentId="322" CreationDate="2019-06-08T21:37:15.273" Score="10" Body="&lt;p&gt;You don't get a minimum-weight (perfect) matching by giving preference to smaller weights in the stable marriage problem. Consider &lt;span class=&quot;math-container&quot;&gt;$\mathcal{I}=\{a,b\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}=\{1,2\}$&lt;/span&gt; and weights &lt;span class=&quot;math-container&quot;&gt;$w_{a1}=2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w_{a2}=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w_{b1}=100$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$w_{b2}=2$&lt;/span&gt;. In this case matching &lt;span class=&quot;math-container&quot;&gt;$\{a2,b1\}$&lt;/span&gt; of value &lt;span class=&quot;math-container&quot;&gt;$101$&lt;/span&gt; is the only stable one but the minimum-weight matching is &lt;span class=&quot;math-container&quot;&gt;$\{a1,b2\}$&lt;/span&gt; of value &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;. By increasing &lt;span class=&quot;math-container&quot;&gt;$w_{b1}$&lt;/span&gt; you can make the difference arbitrarily large.&lt;/p&gt;&#xA;" OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-08T21:52:25.973" LastActivityDate="2019-06-08T21:52:25.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="328" PostTypeId="2" ParentId="298" CreationDate="2019-06-09T00:53:57.553" Score="14" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;But I wonder if anyone else has come across the logarithmic mean elsewhere in optimization?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Mathematical_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimization&lt;/a&gt; is simply the selection of a best element (with regard to some criterion) from some set of available alternatives. (From: &quot;&lt;a href=&quot;https://web.archive.org/web/20140305080324/http://glossary.computing.society.informs.org/index.php?page=nature.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Nature of Mathematical Programming&lt;/a&gt;&quot;, by George B. Dantzig).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The logarithmic mean has a relationship with other means as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://www.researchgate.net/publication/268671183_Optimal_generalized_logarithmic_mean_bounds_for_the_geometric_combination_of_arithmetic_and_harmonic_means&quot; rel=&quot;nofollow noreferrer&quot;&gt;Long and Chu (2011)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;,&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$A(a,b)=(a+b)/2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$I(a,b)=1/e(b^b/a^a)^{1/(b−a)}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$L(a,b)=(b−a)/(\ln b−\ln a)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$G(a,b)=\sqrt{ab}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$H(a,b)=2ab/(a+b)$&lt;/span&gt; be the arithmetic, identric, &lt;strong&gt;logarithmic&lt;/strong&gt;, geometric, and harmonic &lt;strong&gt;means&lt;/strong&gt; of two positive numbers &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$a\ne b$&lt;/span&gt;,&#xA;  respectively. Then&#xA;  &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min\{a, b\}&amp;amp;&amp;lt; H(a, b)&amp;lt; G(a, b) = L_{−2}(a, b)&amp;lt; L(a, b) = L_{-1}(a, b)\\&amp;amp;&amp;lt; I(a, b) = L_0(a, b)&amp;lt; A(a, b) = L_1(a, b)&amp;lt;\max\{a, b\}.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/0022247X8790309X&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pittenger (1987)&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt; for a discussion of logarithmic means (page 286), and the &lt;a href=&quot;https://en.wikipedia.org/wiki/Glivenko%E2%80%93Cantelli_theorem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Glivenko-Cantelli theorem&lt;/a&gt; (p. 287). Further resources include the &lt;a href=&quot;https://en.wikipedia.org/wiki/Dvoretzky%E2%80%93Kiefer%E2%80%93Wolfowitz_inequality#Building_CDF_bands&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dvoretzky–Kiefer–Wolfowitz inequality&lt;/a&gt; and building &lt;a href=&quot;https://en.wikipedia.org/wiki/CDF-based_nonparametric_confidence_interval#CDF_bounds&quot; rel=&quot;nofollow noreferrer&quot;&gt;CDF bands&lt;/a&gt; from Wikipedia.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;a href=&quot;https://medical-dictionary.thefreedictionary.com/logarithmic&quot; rel=&quot;nofollow noreferrer&quot;&gt;logarithmic relationship&lt;/a&gt; occurs when the logs of two variables plotted against each other create a straight line. A semilogarithmic relationship is when there is linearity when only one of the variables is scaled as a logarithm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For further reading on the (weighted) logarithmic mean, see p. 885-886 of &lt;a href=&quot;https://www.researchgate.net/publication/238389878_The_Weighted_Logarithmic_Mean&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neuman (1994)&lt;/a&gt;&lt;sup&gt;3&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;https://en.wikipedia.org/wiki/Logistic_regression&quot; rel=&quot;nofollow noreferrer&quot;&gt;logistic regression&lt;/a&gt; the right-hand predictor side of the equation must be linear with the left-hand outcome side of the equation. You must &lt;a href=&quot;http://euclid.psych.yorku.ca/SCS/sasmac/boxtid.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;test for linearity&lt;/a&gt; in the logit (in logistic regression the logit is the outcome side). This is commonly done with the &lt;a href=&quot;https://ieeexplore.ieee.org/document/1677374&quot; rel=&quot;nofollow noreferrer&quot;&gt;Box-Tidwell transformation&lt;/a&gt;&lt;sup&gt;4&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Add to the logistic model interaction terms which are the cross product of each independent times its natural logarithm &lt;span class=&quot;math-container&quot;&gt;$X\ln X$&lt;/span&gt;. If these terms are significant, then there is nonlinearity in the logit.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;In the &lt;a href=&quot;https://en.wikipedia.org/wiki/Logistic_regression&quot; rel=&quot;nofollow noreferrer&quot;&gt;logistic model&lt;/a&gt;, the log-odds (the logarithm of the odds) for the value labeled &quot;1&quot; is a linear combination of one or more independent variables (&quot;predictors&quot;); the independent variables can each be a binary variable (two classes, coded by an indicator variable) or a continuous variable (any real value). The corresponding probability of the value labeled &quot;1&quot; can vary between 0 (certainly the value &quot;0&quot;) and 1 (certainly the value &quot;1&quot;), hence the labeling; the function that converts log-odds to probability is the logistic function, hence the name. The unit of measurement for the log-odds scale is called a logit, from logistic unit, hence the alternative names. Analogous models with a different sigmoid function instead of the logistic function can also be used, such as the probit model; the defining characteristic of the logistic model is that increasing one of the independent variables multiplicatively scales the odds of the given outcome at a constant rate, with each dependent variable having its own parameter; for a binary independent variable this generalizes the odds ratio.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://en.wikipedia.org/wiki/Logistic_regression#Logistic_function,_odds,_odds_ratio,_and_logit&quot; rel=&quot;nofollow noreferrer&quot;&gt;Logistic regression: Definition of the logistic function&lt;/a&gt; from Wikipedia.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Long, B-Y., Chu, Y-M. (2011). Optimal generalized logarithmic mean bounds for the geometric combination of arithmetic and harmonic means. &lt;em&gt;Journal of the Indonesian Mathematical Society.&lt;/em&gt; 17(2):85–96. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] Pittenger, A. O. (1987). Limit theorems for logarithmic means. &lt;em&gt;Journal of Mathematical Analysis and Applications.&lt;/em&gt; 123(1):281-291. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [3] Neuman, E. (1994). The Weighted Logarthmic Mean. &lt;em&gt;Journal of Mathematical Analysis and Applications.&lt;/em&gt; 188(3):885-900. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [4] Joyce T., Donovan, J., Murphy, E. (2006). The application of the box-tidwell transformation in reliability modeling. &lt;em&gt;Annual Reliability and Maintainability Symposium.&lt;/em&gt; &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="123" LastEditDate="2019-12-26T20:07:53.767" LastActivityDate="2019-12-26T20:07:53.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="330" PostTypeId="2" ParentId="304" CreationDate="2019-06-09T08:43:23.450" Score="5" Body="&lt;p&gt;There was a similar question on &lt;a href=&quot;https://stats.stackexchange.com/questions/393973/analyse-sensitivity-of-hyper-parameters-of-machine-learning-models&quot;&gt;Cross Validated&lt;/a&gt; and as in my comment there, I would look into the use of statistical experimental design, specifically factorial designs and fractional factorial designs. There is a very good book on that topic &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0471718130&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Box, Hunter &amp;amp; Hunter&lt;/a&gt; and here is a paper on its use in hyperparameter optimization &lt;a href=&quot;https://pdfs.semanticscholar.org/fab5/db46541cf40cb89d6feee58a8cd3c7db4484.pdf&quot; rel=&quot;noreferrer&quot;&gt;Design of Experiments for the&#xA;Tuning of Optimisation Algorithms&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="166" LastActivityDate="2019-06-09T08:43:23.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="331" PostTypeId="2" ParentId="326" CreationDate="2019-06-09T15:41:06.897" Score="10" Body="&lt;p&gt;In Cplex, try the following: run it once with a node or time limit, then change the search strategy, remove the node/time limit and rerun the solver. This should work also in command mode. The important thing is that you do not change the Mip model between the first and second run (otherwise Cplex will start a new run from the root node). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using similar tricks you can also repeat several times the root node (to get more cuts), or you can use aggressive cuts only in the first 100 nodes (say), etc.  &lt;/p&gt;&#xA;" OwnerUserId="429" LastEditorUserId="429" LastEditDate="2019-06-10T06:00:28.847" LastActivityDate="2019-06-10T06:00:28.847" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="332" PostTypeId="2" ParentId="236" CreationDate="2019-06-09T15:49:34.210" Score="13" Body="&lt;p&gt;Tightening the big-M is very important, but sometimes this is done in a reasonable way by the automatic MIP preprocessor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to see how the BigM in the input model is automatically tightened by Cplex, in interactive mode you can use the following series of commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;read originalproblem.lp&#xA;&#xA;write a.pre&#xA;&#xA;read a.pre&#xA;&#xA;write preprocessed.lp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then quit Cplex and text-edit &lt;code&gt;preprocessed.lp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, the big-M in the formulation is typically chosen to be “globally” valid for any feasible solution, hence it cannot be very effective. Much better “local” big-M values can be computed along the decision tree due to the branching conditions, meaning that the corresponding constraint eventually becomes tight at the optimal solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See e.g. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dei.unipd.it/~fisch/papers/indicator_constraints.pdf&quot; rel=&quot;noreferrer&quot;&gt;http://www.dei.unipd.it/~fisch/papers/indicator_constraints.pdf&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;for a discussion&lt;/p&gt;&#xA;" OwnerUserId="429" LastEditorUserId="36" LastEditDate="2019-06-09T16:29:12.740" LastActivityDate="2019-06-09T16:29:12.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="333" PostTypeId="2" ParentId="185" CreationDate="2019-06-09T16:18:24.557" Score="14" Body="&lt;p&gt;Talking about general Benders (and Geoffrion for general convex), my student @Fischenders suggested the following &lt;a href=&quot;http://www.dei.unipd.it/~fisch/papers/slides/2017%20Porquerolles%20%5bFischetti%20on%20Benders%5d.pdf&quot; rel=&quot;noreferrer&quot;&gt;slides&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An important remark is that Benders introduced TWO ideas: (1) working on a master relaxation involving only a subset of the variables, and (2) a machinery (the Benders cut) based on LP duality to take the remaning variables into account. In logic/combinatorial Benders you buy (1) and use a more combinatorial version of (2). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to Combinatorial/Logic Benders cuts, they are a way to bring feasibility constraints into the master in a more combinatorial form that does not necessarily require to have a convex subproblem (to apply duality).  The only requirement is that you are able to detect somehow a minimal certificate of infeasibility for the master solution, and to translate it into a linear cut for the master.   Depending on the application, these kinds of cuts can be strong or weak—-one should try and see. &lt;/p&gt;&#xA;" OwnerUserId="429" LastEditorUserId="429" LastEditDate="2019-06-17T20:05:05.350" LastActivityDate="2019-06-17T20:05:05.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="334" PostTypeId="1" CreationDate="2019-06-09T19:15:29.533" Score="25" ViewCount="1204" Body="&lt;p&gt;For anyone who's been on both sides of the fence: how does academic OR differ from OR in enterprises or governments?&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="8" LastEditDate="2020-09-04T08:17:02.937" LastActivityDate="2020-09-04T08:17:02.937" Title="What are the main differences between Operations Research in the academic world, in the enterprise world and in the government world?" Tags="|academia|government|industry|" AnswerCount="8" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="335" PostTypeId="2" ParentId="334" CreationDate="2019-06-09T21:22:11.673" Score="32" Body="&lt;p&gt;Here are a few differences I have noticed. (I am &lt;em&gt;mainly&lt;/em&gt; an academic, but also work part-time for a consulting company that specializes in OR and AI models for supply chain and other industries.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Project Speed.&lt;/strong&gt; The two environments operate on totally different timelines. For the most part, industry OR projects have specific deliverables with tight deadlines—weeks or months—while academic projects are much more open-ended and exploratory, with deadlines that are much longer—usually a year or more—if they exist at all. One reason for this is that academic research is conducted partly by students, so learning and training on the part of the researchers is an expected part of the process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Focus on Exactness.&lt;/strong&gt; Academic research requires a degree of rigor that is not nearly as common in industry. Even when we do research on heuristics and other approximate methods, academics try to be very careful about establishing bounds, testing thoroughly, comparing to &quot;competing&quot; approaches from the literature, etc. In industry, some degree of experimentation and comparison is common, but usually the focus is on finding an approach that seems to work well, in the timeframe needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problems vs. Methods.&lt;/strong&gt; Academic research is (sometimes, not always) driven by tools: We develop a new algorithm and we apply it to optimization problems to test it out, or we develop a new analytical model and seek case studies with which to validate it. In contrast, industry OR work is almost always driven by specific problems faced by the enterprise, using whatever methodological tools do the job. (An exception, of course, is at companies that produce solvers, network design software, etc.—obviously there is a significant focus there on methods.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Industry practitioners do sometimes come to the table with a bias for a particular method (&quot;build me a machine learning model to solve my XYZ problem&quot;) but in my opinion, part of the job of an OR practitioner is to figure out what is the right method, and, if necessary, to try to convince the client of the appropriateness of that method.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-09T21:22:11.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="336" PostTypeId="2" ParentId="334" CreationDate="2019-06-09T22:05:53.300" Score="11" Body="&lt;p&gt;Just to add one more point to what @LarrySnyder610 said above about specific problem-driven projects of enterprises: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since many of industry OR problems are driven by specific use cases, some of the simplifying assumptions in academic projects are not acceptable. I don't mean the solutions to those simplified (academic) models are not applicable, but they may only serve as a starting point for developing more tailored solutions (one may even say this is one of those areas that there is a gap between academia and industry: the closeness of the assumptions of the models in the two worlds!) &lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-09T22:10:59.100" LastActivityDate="2019-06-09T22:10:59.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="337" PostTypeId="1" CreationDate="2019-06-09T22:43:34.837" Score="3" ViewCount="221" Body="&lt;p&gt;In combinatorial optimization, on what type of problem a local search may lead to better &amp;amp; quicker solutions than usual mixed-integer programming and constraint programming techniques ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By type of problem, I mean :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Field of application&lt;/li&gt;&#xA;&lt;li&gt;Type of objective&lt;/li&gt;&#xA;&lt;li&gt;Number and type of decision variables&lt;/li&gt;&#xA;&lt;li&gt;Number and type of constraints&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="465" LastEditorUserId="87" LastEditDate="2019-06-10T08:53:51.993" LastActivityDate="2019-06-10T08:53:51.993" Title="On what kind of problems a local search may perform better than MIP / CP techniques?" Tags="|mixed-integer-programming|constraint-programming|heuristics|local-search|" AnswerCount="1" CommentCount="3" ClosedDate="2019-06-10T03:31:05.283" ContentLicense="CC BY-SA 4.0" />
  <row Id="338" PostTypeId="2" ParentId="337" CreationDate="2019-06-10T00:28:59.807" Score="3" Body="&lt;p&gt;Those that you can't completely explore the branch-and-bound tree within your time limit.  Don't forget you can do local search and large neighbourhood search in a branch-and-bound tree: fix some variables, solve, relax the fixings, fix other variables, solve, repeat. You get the best of both worlds with fast feasible solutions from a smaller search tree and dual bounds from MIP or propagation from CP.&lt;/p&gt;&#xA;" OwnerUserId="44" LastActivityDate="2019-06-10T00:28:59.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="339" PostTypeId="1" AcceptedAnswerId="352" CreationDate="2019-06-10T01:19:30.403" Score="10" ViewCount="596" Body="&lt;p&gt;This is a very basic question about a very basic model, but I can't come up with a satisfactory answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the economic order quantity (EOQ) model, let &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; be the demand rate (&lt;strong&gt;items/year&lt;/strong&gt;), &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; be the holding cost (&lt;strong&gt;\$/item/year&lt;/strong&gt;), and let &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; be the fixed cost per order.  The optimal solution is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Q^* = \sqrt{\frac{2K\lambda}{h}}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What should be the units for &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;?&lt;/strong&gt; One option is just &lt;strong&gt;\$&lt;/strong&gt;, which would give &lt;span class=&quot;math-container&quot;&gt;$Q^*$&lt;/span&gt; units of&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sqrt{\frac{\$ \cdot \frac{\text{item}}{\text{year}}}{\frac{\$}{\text{item}\cdot\text{year}}}} = \text{item},$$&lt;/span&gt;&#xA;which is right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it seems equally plausible to me to use &lt;strong&gt;\$/order&lt;/strong&gt; as the units for &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;, but then we have units&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sqrt{\frac{\frac{\$}{\text{order}} \cdot \frac{\text{item}}{\text{year}}}{\frac{\$}{\text{item}\cdot\text{year}}}} = \text{item}\sqrt{\frac{1}{\text{order}}},$$&lt;/span&gt;&#xA;which obviously doesn't make sense. It would also work out if there were another &lt;span class=&quot;math-container&quot;&gt;$\sqrt{1/\text{order}}$&lt;/span&gt; somewhere, so that &lt;span class=&quot;math-container&quot;&gt;$Q^*$&lt;/span&gt; has units &lt;span class=&quot;math-container&quot;&gt;$\text{item}/\text{order}$&lt;/span&gt;, but none of the other terms should have &lt;span class=&quot;math-container&quot;&gt;$\text{order}$&lt;/span&gt; in their units.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing? &lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-10-20T13:15:19.680" Title="Units in the EOQ problem" Tags="|inventory|economic-order-quantity|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="340" PostTypeId="2" ParentId="1" CreationDate="2019-06-10T03:11:23.833" Score="4" Body="&lt;p&gt;I tried simulating lots of normally distributed lead times and the normally distributed demand in each. The lead time demand sure &lt;em&gt;looks&lt;/em&gt; normal:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/hVAxu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hVAxu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But a normality test gives &lt;span class=&quot;math-container&quot;&gt;$p = 0$&lt;/span&gt; to at least 9 decimal places. &lt;strong&gt;Edit:&lt;/strong&gt; Since the null hypothesis for this test is “the data comes from a normal distribution,” this means we can conclude the &lt;em&gt;lead-time demands are &lt;strong&gt;not&lt;/strong&gt; normally distributed.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my Python script in case anyone wants to play around with it (or check my work):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;from scipy import stats&#xA;import matplotlib.pyplot as plt&#xA;&#xA;mu_D = 100              # mean demand per day&#xA;sigma_D = 20            # SD of demand per day&#xA;mu_L = 10               # mean lead time (days)&#xA;sigma_L = 2             # SD of lead time (days)&#xA;T = 10000000            # number of lead times to simulate&#xA;&#xA;# simulate&#xA;LTDs = []&#xA;for t in range(T):&#xA;    # generate lead time&#xA;    L = int(max(0, np.round(np.random.normal(mu_L, sigma_L))))&#xA;&#xA;    # simulate LTD&#xA;    LTD = np.random.normal(mu_D * L, sigma_D * np.sqrt(L))&#xA;&#xA;    # add to list&#xA;    LTDs.append(LTD)&#xA;&#xA;k2, p = stats.normaltest(LTDs)&#xA;print(&quot;p-value = {:.9f}&quot;.format(p))&#xA;&#xA;# draw histogram&#xA;plt.hist(LTDs, bins=100)&#xA;plt.show()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-12T12:41:24.577" LastActivityDate="2019-06-12T12:41:24.577" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="341" PostTypeId="2" ParentId="339" CreationDate="2019-06-10T03:27:47.287" Score="5" Body="&lt;p&gt;The coefficient &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; in the first equation has unit &lt;span class=&quot;math-container&quot;&gt;$1/\text{order}$&lt;/span&gt;, so the second approach is the right one, and &lt;span class=&quot;math-container&quot;&gt;$Q^*$&lt;/span&gt; has units &lt;span class=&quot;math-container&quot;&gt;$\text{item}/\text{order}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The unit comes from the holding cost &lt;span class=&quot;math-container&quot;&gt;$hQ/2$&lt;/span&gt; in &lt;a href=&quot;https://en.wikipedia.org/wiki/Economic_order_quantity#The_total_cost_function_and_derivation_of_EOQ_formula&quot; rel=&quot;noreferrer&quot;&gt;the formula&lt;/a&gt; for the total cost, which assumes that for order quantity &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; (items/order) you have in average &lt;span class=&quot;math-container&quot;&gt;$1/2$&lt;/span&gt; order in stock, so &lt;span class=&quot;math-container&quot;&gt;$1/2$&lt;/span&gt; has unit &quot;order&quot;, and &lt;span class=&quot;math-container&quot;&gt;$hQ/2$&lt;/span&gt; is in &lt;span class=&quot;math-container&quot;&gt;$\$/\text{y}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2019-06-10T03:27:47.287" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="342" PostTypeId="5" CreationDate="2019-06-10T07:43:13.177" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-10T07:43:13.177" LastActivityDate="2019-06-10T07:43:13.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="343" PostTypeId="4" CreationDate="2019-06-10T07:43:13.177" Score="0" Body="Questions on general heuristic strategies that can be instantiated for a specific problem to obtain a heuristic." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-10T12:57:01.677" LastActivityDate="2019-06-10T12:57:01.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="344" PostTypeId="5" CreationDate="2019-06-10T07:47:26.127" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-10T07:47:26.127" LastActivityDate="2019-06-10T07:47:26.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="345" PostTypeId="4" CreationDate="2019-06-10T07:47:26.127" Score="0" Body="Questions on optimization algorithms that improve a solution by repeatedly applying a small modification to it." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-10T12:56:38.323" LastActivityDate="2019-06-10T12:56:38.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="346" PostTypeId="5" CreationDate="2019-06-10T07:57:17.783" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-10T07:57:17.783" LastActivityDate="2019-06-10T07:57:17.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="347" PostTypeId="4" CreationDate="2019-06-10T07:57:17.783" Score="0" Body="Questions on problems whose solution space are one-to-one mappings between two sets." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-10T12:57:12.137" LastActivityDate="2019-06-10T12:57:12.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="348" PostTypeId="2" ParentId="231" CreationDate="2019-06-10T12:04:14.690" Score="10" Body="&lt;p&gt;Question by me at the IBM CPLEX Forum: &lt;a href=&quot;https://www.ibm.com/developerworks/community/forums/html/topic?id=553f63f9-91ce-4469-a34c-3e86b93485ad&amp;amp;ps=25&quot; rel=&quot;noreferrer&quot;&gt;Are indicator constraints immune to trickle flow or other numerics-induced logic &quot;errors&quot;?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are indicator constraints immune to trickle flow or other&#xA;  numerics-induced logic &quot;errors&quot;?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;As discussed at&#xA;  &lt;a href=&quot;https://www-01.ibm.com/support/docview.wss?uid=swg21399984&quot; rel=&quot;noreferrer&quot;&gt;IBM Technote: Why does a binary or integer variable take on a noninteger value in the solution?&lt;/a&gt;, depending&#xA;  on the value of the integrality tolerance, trickle flow can result in&#xA;  the intended logic of Big M constraints not being satisfied.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Can indicator constraints ever be violated due to a similar&#xA;  phenomenon? Does integrality tolerance come into play? What if due to&#xA;  large bounds on involved variables, M in a Big M constraint would have&#xA;  to be very large - can indicator constraints get into trouble (not&#xA;  just slow solution, but wrong solution) if they are used in lieu of&#xA;  Big M constraints in such a situation?  Does the setting of&#xA;  integrality tolerance have any effect on whether indicator constraints&#xA;  can produce the wrong solution?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Answer by Ed Klotz of IBM:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Here some details in addition to the &lt;a href=&quot;https://www-01.ibm.com/support/docview.wss?uid=swg21400084&quot; rel=&quot;noreferrer&quot;&gt;IBM Technote: Difference between using indicator constraints and a big-M formulation&lt;/a&gt; .   First,&#xA;  &lt;strong&gt;indicator constraints are indeed completely immune to the trickle flow&#xA;  issue associated with big M formulations&lt;/strong&gt;.   But there still is a trade&#xA;  off, although the downside has definitely been diminished since&#xA;  indicator constraints first appeared around CPLEX 10.0.   Namely, the&#xA;  relaxation of an indicator constraint is obtained by removing the&#xA;  indicator constraint, solving the associated relaxation, then&#xA;  branching on violated indicator constraints.   For huge big M values,&#xA;  this is not really a drawback.   But for modest values of big M of say&#xA;  100000, which can still potentially have trickle flow issues, this can&#xA;  result in a weaker formulation. Recent versions of CPLEX have made&#xA;  improvements in indicator probing and other MIP preprocessing that&#xA;  typically reduce the burden on the user to decide between an indicator&#xA;  and big M formulation that is described in the above technote.  If&#xA;  CPLEX can detect reasonable bounds on the variable or expression&#xA;  implied by the indicator variable, then it will probably be able to&#xA;  tighten the formulation for you, and you don't need to worry about the&#xA;  potential weakness.    But if the variable or expression implied by&#xA;  the indicator variable have implicit modest bounds that involve a very&#xA;  complex combination of constraints that elude CPLEX's bound&#xA;  strengthening and other MIP preprocessing methods, then you might want&#xA;  to consider supplying those bounds yourself in the formulation to&#xA;  tighten it.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Slides 19-23 of &lt;a href=&quot;http://marklstone.com/mls/RealWorldSolutions.pdf&quot; rel=&quot;noreferrer&quot;&gt;Klotz and Wunderling:Tools for Adapting Math Programming Solutions in the Real World&lt;/a&gt;  may help a bit; the info is&#xA;  similar to the content of the above technote, but it does provide a&#xA;  few more details.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note the following useful tips from slide 20 of &lt;a href=&quot;http://marklstone.com/mls/RealWorldSolutions.pdf&quot; rel=&quot;noreferrer&quot;&gt;Klotz and Wunderling:Tools for Adapting Math Programming Solutions in the Real World&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get correct answers with big-M&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use smallest possible value of big-M that doesn’t violate intent of model  &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bound strengthening in CPLEX presolve often does this automatically&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Set integrality tolerance to 0 &lt;/li&gt;&#xA;&lt;li&gt;Set simplex tolerances to minimum values, 1e-9&lt;/li&gt;&#xA;&lt;li&gt;Ask for more accuracy on an ill-conditioned system&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Turn on numerical emphasis parameter&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-06-10T17:20:56.967" LastActivityDate="2019-06-10T17:20:56.967" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="349" PostTypeId="2" ParentId="314" CreationDate="2019-06-10T12:19:23.303" Score="15" Body="&lt;p&gt;Essentially you are trying to constrain &lt;span class=&quot;math-container&quot;&gt;$|p_1-p_2|$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$p_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_2$&lt;/span&gt; are the pressures. Normally this must be done using binary variables (see &lt;a href=&quot;https://or.stackexchange.com/questions/3/working-with-absolute-values-in-constraint-in-a-lp-or-milp&quot;&gt;this question&lt;/a&gt;, which @MarcusRitt linked to), but in this case, binary variables are not needed (since the lower bound on the absolute value is 0, as @MarkLStone pointed out).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, you can simply use the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-\delta \le p_1 - p_2 \le \delta,$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\delta&amp;gt;0$&lt;/span&gt; is your desired level of deviation from equality.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-10T12:19:23.303" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="350" PostTypeId="2" ParentId="334" CreationDate="2019-06-10T12:52:29.937" Score="21" Body="&lt;p&gt;My experience, as a former phd in an academic context, post doc in a semi-industrial/semi-academic context and now working for an APS editor, is the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When working on academic problems one will typically work on well defined problems. Even though those problems will be (very) difficult they will typically not involve a lot of side constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand in the industrial world the problems tend to be much less well defined. It will typically take you a couple of rounds of presenting a solution to the end users and getting remarks to figure out that you were missing parts of the problem definition. This will typically lead to adding quite some extra constraints (which can have the side effect of bringing the approach originally developed to its knees).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my experience something else that differs between academic OR and industrial OR is the number of constraints that are actually treated as soft constraints. In the typical projects in which I am working more than half of the constraints can be turned into soft-constraints. This stems from the fact that otherwise half of the instances would be considered infeasible if all constraints were treated as hard constraints. To the end user only knowing that the instance is infeasible is not useful (she must still come up with a solution), while having a solution minimally violating some constraints can constitute a good basis to take some actions to make the solution feasible (by delaying some orders, hiring temporary workforce, ...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another difference has to do with building the trust of the user in the optimization result. When using an heuristic approach, no matter how good the solution provided is, if users can easily see a way to improve it, it can completely destroy their trust in the system (even if they would never have been able to come up with a solution as good starting from scratch). Ideally one should run some local search as a post processing making sure that any « easy » local modifications have been tried out before presenting a solution to the end user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My last point concerns the complexity of the objective functions. I have already encountered for a vehicle routing problem the case where the document detailing how the cost of a route was invoiced was spanning over more than 30 pages. I have never encountered anything similar in an academic context.&lt;/p&gt;&#xA;" OwnerUserId="124" LastEditorUserId="124" LastEditDate="2019-06-10T20:16:23.427" LastActivityDate="2019-06-10T20:16:23.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="351" PostTypeId="2" ParentId="339" CreationDate="2019-06-10T15:16:35.923" Score="4" Body="&lt;p&gt;It is an interesting question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EOQ model starts from that the minimum point of the total cost (Inventory holding + Ordering cost). At the minimum point, the Inventory holding cost equals to the Ordering cost.&lt;br&gt;&#xA;(of course you can use calculus to find the minimum point but the answer will be the same)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\frac{Q}{2}h = \frac{\lambda}{Q}K$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem starts from here. &#xA;&lt;span class=&quot;math-container&quot;&gt;$\frac{Q}{2}$&lt;/span&gt; is the average inventory level over the year. Therefore, The unit should be &lt;strong&gt;Item&lt;/strong&gt;. However, &lt;span class=&quot;math-container&quot;&gt;$\frac{\lambda}{Q}$&lt;/span&gt; is &lt;em&gt;the number of orders per year&lt;/em&gt; . Therefore if the &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is &lt;strong&gt;Item per Year&lt;/strong&gt;, Q has to be &lt;strong&gt;Item/order&lt;/strong&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we accept &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; has the unit &lt;strong&gt;Item/order&lt;/strong&gt;, The average Inventory level &lt;span class=&quot;math-container&quot;&gt;$\frac{Q}{2}$&lt;/span&gt; should have the unit, &lt;strong&gt;Item/order&lt;/strong&gt;, but it should be &lt;strong&gt;Item&lt;/strong&gt; for average Inventory level. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;the &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$\frac{Q}{2}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$\frac{\lambda}{Q}$&lt;/span&gt; are different in the unit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) The average inventory can be calculated by dividing the highest point in the sawtooth shape cycle by 2. The highest point is the highest inventory level, so the unit should be &lt;strong&gt;Item&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do we find the highest point?  We know the highest point in the inventory level is the &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;, order quantity, (&lt;strong&gt;Item per order&lt;/strong&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are indeed the same number (but in different units) so that we can solve the equation.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) The Average Inventory level per order, &lt;span class=&quot;math-container&quot;&gt;$\frac{Q}{2}$&lt;/span&gt; (unit: &lt;strong&gt;Item/order&lt;/strong&gt;) is the Annual average Inventory level &lt;span class=&quot;math-container&quot;&gt;$\frac{Q}{2}$&lt;/span&gt; (unit: &lt;strong&gt;Item&lt;/strong&gt;)&lt;br&gt;&#xA;But when we calculate Annual inventory holding cost, we use 'annual average inventory level', not 'average inventory level per order'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure it is what you are looking for. Expecting discussions &lt;/p&gt;&#xA;" OwnerUserId="217" LastEditorUserId="123" LastEditDate="2019-10-20T13:15:19.680" LastActivityDate="2019-10-20T13:15:19.680" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="352" PostTypeId="2" ParentId="339" CreationDate="2019-06-10T16:19:24.760" Score="6" Body="&lt;p&gt;In the EOQ setting, the total cost incurred during one order cycle is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$TC = K + \frac{hQ^2}{2 \lambda} \;\;,$$&lt;/span&gt;&#xA;where the units of &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; must be only \$ and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; measures the inventory count in items after placing the order at the beginning of the cycle. If &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; were to have units of \$ per order (or per cycle), then the second term must also have those units otherwise you are adding apples to oranges. Given &lt;span class=&quot;math-container&quot;&gt;$TC$&lt;/span&gt; measured only in \$, we complete the model and compute &lt;span class=&quot;math-container&quot;&gt;$\frac{TC}{t}$&lt;/span&gt; by dividing by the cycle length of &lt;span class=&quot;math-container&quot;&gt;$\frac{Q}{\lambda}$&lt;/span&gt; and then find &lt;span class=&quot;math-container&quot;&gt;$Q^*$&lt;/span&gt; to minimize cost per time in the right units of items.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possibly important idea is that there are only three fundamental dimensions in the EOQ model, where a dimension is a quantity that must be measured to specify the model. The three fundamental dimensions are cost (typically measured in \$), time (measured in years), and inventory (measured in items). In my setup above, &lt;span class=&quot;math-container&quot;&gt;$TC$&lt;/span&gt; is a cost variable and is comprised of two cost components, both measured in \$. So &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; has units of \$ and provides the fixed cost incurred in an order cycle. The second term has &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; measured in \$ per item-year multiplied by &lt;span class=&quot;math-container&quot;&gt;$\frac{Q^2}{2 \lambda}$&lt;/span&gt; measuring average item-years of inventory in an order cycle since the average inventory &lt;span class=&quot;math-container&quot;&gt;$\frac{Q}{2}$&lt;/span&gt; is measured in items and the cycle length &lt;span class=&quot;math-container&quot;&gt;$\frac{Q}{\lambda}$&lt;/span&gt; is measured in years assuming an initial inventory of &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; items. In the EOQ setup, constant order quantities makes it unnecessary to measure orders separately to specify the problem. If the unit of orders is called for simplicity &lt;em&gt;unit order&lt;/em&gt;, then the unit orders per time is just an endogenous performance metric given by demand (items per year) divided by order size (items per unit order), or &lt;span class=&quot;math-container&quot;&gt;$\frac{\lambda}{Q}$&lt;/span&gt;. Note that it is perfectly fine for &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; to be a quantity of items or a quantity of items per unit order, depending on the setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are still wanting more, it is also possible to guess wrong and assume that it is necessary to measure orders explicitly when specifying a correct EOQ model. Let's think about this. Let &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; in this case be a cost per order, measured in \$ per unit order. We can furthermore define the variable &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; as measuring inventory per order, the increase in inventory obtained for every order measured in items per unit order. Let me also suggest that variable quantity &lt;span class=&quot;math-container&quot;&gt;$o_t$&lt;/span&gt; captures the orders placed at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; again measured in unit orders. Consider a time duration that begins with a time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; when an order is placed. It isn't difficult to see that there should be no items in inventory at &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; for an optimal ordering strategy. If we place &lt;span class=&quot;math-container&quot;&gt;$o_t$&lt;/span&gt; unit orders, the inventory level will be raised to &lt;span class=&quot;math-container&quot;&gt;$Q o_t$&lt;/span&gt; at a cost of &lt;span class=&quot;math-container&quot;&gt;$K o_t$&lt;/span&gt;. During the time interval while the inventory again drops to zero, the total cost will be:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$TC' = K o_t + h \frac{Q o_t}{2} \frac{Q o_t}{\lambda} \; ,$$&lt;/span&gt;&#xA;where again both terms measure cost in \$ (the second term is again \$ per item-year multiplied first by items and then by years). Dividing again by the length of the time interval yields:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{TC'}{t} = \frac{K \lambda}{Q} + h \frac{Q o_t}{2} \; .$$&lt;/span&gt;&#xA;Both terms measure cost correctly in \$ per year, but it should be clear that cost only increases in the decision variable &lt;span class=&quot;math-container&quot;&gt;$o_t$&lt;/span&gt; so it should be set equal to one unit order before optimizing for &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;. In this formulation, it is true that &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; (and &lt;span class=&quot;math-container&quot;&gt;$Q^*$&lt;/span&gt;) is in units of items per unit order whereas in the original formulation &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; simply measures the increase in inventory that results by placing the single order. Since only one unit order is placed in a reorder cycle, we strip away the need to have &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; measure per unit order quantities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sorry for the long answer, but I hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="105" LastEditorUserId="105" LastEditDate="2019-06-10T21:46:23.173" LastActivityDate="2019-06-10T21:46:23.173" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="353" PostTypeId="2" ParentId="235" CreationDate="2019-06-10T17:21:55.420" Score="15" Body="&lt;p&gt;I am currently working with decision diagrams (DDs). From my experience, DD-based optimization works well for problems on which a recursive formulation can be exploited (i.e., problems that have a dynamic programming model).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, it is the case for the &lt;em&gt;maximum independent set problem&lt;/em&gt; and the &lt;em&gt;maximum cut problem&lt;/em&gt;. It is also the case for some sequencing and scheduling problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the &lt;a href=&quot;http://www.andrew.cmu.edu/user/vanhoeve/mdd/&quot; rel=&quot;noreferrer&quot;&gt;reference website&lt;/a&gt;, you can find many problems where DDs work well (&lt;a href=&quot;http://icaps16.icaps-conference.org/proceedings/tutorials/tutorial4.pdf&quot; rel=&quot;noreferrer&quot;&gt;This talk&lt;/a&gt; presents some problems with computational results).&lt;/p&gt;&#xA;" OwnerUserId="483" LastActivityDate="2019-06-10T17:21:55.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="354" PostTypeId="2" ParentId="57" CreationDate="2019-06-10T20:23:07.843" Score="11" Body="&lt;p&gt;I recommend &lt;strong&gt;Formulating Integer Linear Programs: A Rogues' Gallery&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://faculty.nps.edu/gbrown/docs/Rogues_Gallery.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;article&lt;/a&gt;&lt;sup&gt;[1]&lt;/sup&gt; is very accessible, clear, and has multiple examples of using binary variables to achieve logical constraints. Full citation below.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;[1] Gerald G. Brown, Robert F. Dell, (2007) Formulating Integer Linear Programs: A Rogues' Gallery. &lt;em&gt;INFORMS Transactions on Education.&lt;/em&gt; 7(2):153–159. &lt;a href=&quot;http://dx.doi.org/10.1287/ited.7.2.153&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://dx.doi.org/10.1287/ited.7.2.153&lt;/a&gt;. Also available from &lt;a href=&quot;https://faculty.nps.edu/gbrown/docs/Rogues_Gallery.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://faculty.nps.edu/gbrown/docs/Rogues_Gallery.pdf&lt;/a&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2020-02-18T17:32:02.827" LastActivityDate="2020-02-18T17:32:02.827" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="355" PostTypeId="2" ParentId="334" CreationDate="2019-06-10T20:38:45.330" Score="19" Body="&lt;p&gt;One difference I did not see mentioned in earlier responses: moving targets. In academe, we tend to start out with a well-delineated (if perhaps overly simple) problem, and we stick with that problem. In the real world, the problem you think you are given and the problem you ultimately (hopefully) solve may not be the same. As models evolve and test cases are run, you may encounter overlooked constraints, additional criteria not mentioned the first time around and so forth.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-06-10T20:38:45.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="356" PostTypeId="2" ParentId="339" CreationDate="2019-06-10T22:11:31.173" Score="3" Body="&lt;p&gt;I remember encountering the same question when teaching Operations Management for the first time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is, annual total inventory cost is simply total annual ordering cost plus total annual holding cost, all of them measured in &lt;span class=&quot;math-container&quot;&gt;$\frac{\$}{\rm year}$&lt;/span&gt;. The total ordering costs is simple: number of orders per year times fixed cost per order: &lt;span class=&quot;math-container&quot;&gt;$\frac{D \, \rm items/year}{Q \, \rm items/order} \times K \frac{\$}{\rm order} = \frac{\$}{\rm year}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The total holding cost can be calculated as annual holding cost per item times &lt;em&gt;average inventory level&lt;/em&gt;, which is measured in &lt;em&gt;items&lt;/em&gt; and happens to be equal to &lt;span class=&quot;math-container&quot;&gt;$\frac{Q}{2}$&lt;/span&gt;. Usually, in textbooks they use continuous inventory depletion model, like in the picture below, and use the triangle area formula to explain the intuition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ufRzv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ufRzv.png&quot; alt=&quot;continuous demand&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in for more general settings the EOQ formula derivation is even less straightforward, and involves derivative and integration. To explain it in apples-to-apples manner you would have to go deep into mathematical realms, which defeats the whole purpose. I noticed that in textbooks, even the Master level ones, they drop the measurement units issue in discussion of EOQ, newsvendor model and other nonlinear topics. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: If I remember correctly, in the undergraduate textbook I was using (Stevenson), &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; was measured in just dollars.&lt;/p&gt;&#xA;" OwnerUserId="322" LastEditorUserId="123" LastEditDate="2019-10-20T13:14:50.853" LastActivityDate="2019-10-20T13:14:50.853" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="357" PostTypeId="1" CreationDate="2019-06-10T22:49:33.817" Score="18" ViewCount="719" Body="&lt;p&gt;Does the apple fall not far from the tree in operations research? Who are well-known Parent/Child pairs in operations research?  I can't claim this: my father was a chemist and my son, at fifteen, has not yet caught the OR bug.&lt;/p&gt;&#xA;" OwnerUserId="214" LastEditorUserId="138" LastEditDate="2019-06-14T16:38:48.597" LastActivityDate="2020-02-09T22:24:31.400" Title="Well-known parent/child pairs in the field of OR" Tags="|people|" AnswerCount="11" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="358" PostTypeId="2" ParentId="357" CreationDate="2019-06-10T23:16:37.227" Score="16" Body="&lt;p&gt;John D.C. Little, of &lt;span class=&quot;math-container&quot;&gt;$L = \lambda W$&lt;/span&gt; fame : father&lt;/p&gt;&#xA;&#xA;&lt;p&gt;John N. &quot;Jack&quot; Little &lt;a href=&quot;https://en.wikipedia.org/wiki/John_N._Little&quot; rel=&quot;noreferrer&quot;&gt;https://en.wikipedia.org/wiki/John_N._Little&lt;/a&gt; and &lt;a href=&quot;https://www.mathworks.com/company/aboutus/founders/jacklittle.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.mathworks.com/company/aboutus/founders/jacklittle.html&lt;/a&gt;, President and co-founder of The Mathworks (MATLAB): son&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Jack received degrees (S.B. from  M.I.T.) in Electrical Engineering. Given that when I was accepted into the M.I.T. O.R. Ph.D. program, I was assigned to the Electrical Engineering (course 6) department, and in light of Jack's role in the development of MATLAB, which is heavily used in O.R., being second only to Cleve Moler, I think we can consider Jack to be close enough to O.R. for government work.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-06-12T01:38:01.083" LastActivityDate="2019-06-12T01:38:01.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="359" PostTypeId="2" ParentId="357" CreationDate="2019-06-10T23:29:30.220" Score="18" Body="&lt;p&gt;How about &lt;a href=&quot;https://en.wikipedia.org/wiki/George_Dantzig&quot; rel=&quot;noreferrer&quot;&gt;George Dantzig&lt;/a&gt; and his father &lt;a href=&quot;https://en.wikipedia.org/wiki/Tobias_Dantzig&quot; rel=&quot;noreferrer&quot;&gt;Tobias Dantzig&lt;/a&gt;, who (according to wikipedia) also had a PhD in Mathematics. &lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-06-10T23:29:30.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="360" PostTypeId="1" CreationDate="2019-06-11T00:05:00.593" Score="-9" ViewCount="194" Body="&lt;p&gt;I have found a solved example of &lt;em&gt;A Stochastic Two-Period Model with No Setup Cost&lt;/em&gt; in the book &lt;em&gt;Operational Research&lt;/em&gt; by Hillier, 7th edition, that has a lot of complicated calculations to arrive to the solution.&lt;/p&gt;&#xA;&lt;p&gt;In the following example, &lt;span class=&quot;math-container&quot;&gt;$c=$&lt;/span&gt;cost of ordering, &lt;span class=&quot;math-container&quot;&gt;$h=$&lt;/span&gt;cost of holding, &lt;span class=&quot;math-container&quot;&gt;$p=$&lt;/span&gt;shortage cost and &lt;span class=&quot;math-container&quot;&gt;$^0_$&lt;/span&gt; is the optimal order-up-to level in period .&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hzvhq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hzvhq.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The part where things start to complicate, is when making the substitution of &lt;span class=&quot;math-container&quot;&gt;$y_1^0$&lt;/span&gt; into &lt;span class=&quot;math-container&quot;&gt;$C_1(x_1)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Clearly will not be an easy calculation by hand since &lt;span class=&quot;math-container&quot;&gt;$C_1$&lt;/span&gt; has this function &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;, that it's evaluated with diferent arguments, which are two integrals.&lt;/p&gt;&#xA;&lt;p&gt;I am not sure what form the argument of &lt;span class=&quot;math-container&quot;&gt;$\displaystyle \min_{y_1\ge x_1}\{\dots\}$&lt;/span&gt; will have, nor what would be best to do next.  My book mentions this &lt;em&gt;OR Courseware&lt;/em&gt; but since I have the pdf file book I don't have the disk? is refering to.&lt;/p&gt;&#xA;&lt;p&gt;And my question is what can I do here in order to find the optimal &lt;span class=&quot;math-container&quot;&gt;$y_1^0$&lt;/span&gt; without having to deal with lots and lots of calculations by hand?&lt;/p&gt;&#xA;&lt;p&gt;Any suggestions are very appreciated.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sXC2X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sXC2X.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$C_1(x_1):$&lt;/span&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/G7Ogz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/G7Ogz.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$L(z):$&lt;/span&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/6KdJQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6KdJQ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h1&gt;edit.&lt;/h1&gt;&#xA;&lt;p&gt;Following the comment of Larry, I substitute &lt;span class=&quot;math-container&quot;&gt;$y_1^0$&lt;/span&gt; in the equation equal to zero (below the &lt;span class=&quot;math-container&quot;&gt;$C_1(x_1)$&lt;/span&gt; definition in the image).&lt;/p&gt;&#xA;&lt;p&gt;I assumed &lt;span class=&quot;math-container&quot;&gt;$y_1^0=5$&lt;/span&gt; to be the optimal and this is what I got&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$-15+(15+10)\frac{5}{10}+(10-15)\Phi(5-2)+(15+10)\int_0^{3}\Phi(5-\xi)\phi_D(\xi)d\xi $$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$=more\ calculations$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$=-\frac {11}{8}$$&lt;/span&gt; This is different than &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, which I don't understand why, the equation should have had the value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; because the book mentioned the optimal was &lt;span class=&quot;math-container&quot;&gt;$y_1^0=5$&lt;/span&gt; and not &lt;span class=&quot;math-container&quot;&gt;$y_1^0=6$&lt;/span&gt;. Also the optimal should satisfy the equation equal to zero, but does not.&lt;/p&gt;&#xA;&lt;p&gt;I really don't see what am I doing wrong? I did check twice the calculations of the expression and found no errors.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\star$&lt;/span&gt; Note: I asked this question on MSE &lt;a href=&quot;https://math.stackexchange.com/questions/3246019/why-the-optimal-value-that-minimizes-a-function-does-not-satisfy-condition&quot;&gt;https://math.stackexchange.com/questions/3246019/why-the-optimal-value-that-minimizes-a-function-does-not-satisfy-condition&lt;/a&gt;  and currently has a bounty (grape period bounty to be exact) and I asked to migrate but it was not possible :(&lt;/p&gt;&#xA;" OwnerUserId="415" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-06-11T03:15:34.127" Title="Why the optimal value that minimizes a function does not satisfy condition?" Tags="|optimization|inventory|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="361" PostTypeId="1" CreationDate="2019-06-11T01:00:34.083" Score="10" ViewCount="190" Body="&lt;p&gt;When reading various papers about two-stage (or multi-stage) stochastic programs with recourse, a common representation of the non-anticipativity constraints is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i}H_ix_i=h,&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; indexes the scenarios, and the matrices &lt;span class=&quot;math-container&quot;&gt;$H_i$&lt;/span&gt; and vector &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; are typically not specified (see, e.g., &lt;a href=&quot;https://opus4.kobv.de/opus4-zib/files/256/SC-96-46.pdf&quot; rel=&quot;noreferrer&quot;&gt;this paper by Carøe and Schultz&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; What are some common choices of &lt;span class=&quot;math-container&quot;&gt;$H_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; used to enforce non-anticipativity? What advantages and disadvantages do these choices have when used algorithmically (in decomposition approaches, etc.)?&lt;/p&gt;&#xA;" OwnerUserId="358" LastEditorUserId="162" LastEditDate="2019-06-11T18:34:56.377" LastActivityDate="2020-09-21T12:40:46.220" Title="Advantages/disadvantages of different representations of non-anticipativity constraints" Tags="|stochastic-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="362" PostTypeId="2" ParentId="357" CreationDate="2019-06-11T01:04:32.293" Score="19" Body="&lt;p&gt;In Montreal we have Louis M Rousseau whose father Jean Marc Rousseau was also a professor until he quit academua to start his own company (GIRO).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From Chile there is Gabriel Weintraub, professor at Stanford and the son of Andres Weintraub.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From Brazil, there's Daniel Aloise, professor at PolyMtl, the son of Dario Aloise from Natal RN.&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2019-06-11T01:04:32.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="363" PostTypeId="2" ParentId="361" CreationDate="2019-06-11T02:48:01.940" Score="2" Body="&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;If one define &lt;span class=&quot;math-container&quot;&gt;$H_i$&lt;/span&gt; as an operator, not necessarily a matrix, I can think of what happens in progressive hedging and go for something like: &lt;span class=&quot;math-container&quot;&gt;$H_i(x_i)=I(x_i−x^*)+1/2(x_i−x^*)^TI(x_i−x^*)$&lt;/span&gt;.&#xA;If in the matrix format: &lt;span class=&quot;math-container&quot;&gt;$H_i=1/rIx_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h=x^*$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="386" LastEditorUserId="386" LastEditDate="2019-06-14T16:27:50.707" LastActivityDate="2019-06-14T16:27:50.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="364" PostTypeId="2" ParentId="360" CreationDate="2019-06-11T03:11:32.443" Score="3" Body="&lt;p&gt;The text from the book tells you that the optimal value of &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$y_1^0 = 5.42$&lt;/span&gt;. This comes from solving the optimality condition (the equation after &quot;satisfies the equation&quot;) for &lt;span class=&quot;math-container&quot;&gt;$y_1^0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Presumably, somewhere in the example it says that the base-stock levels must be integers. Therefore, they plug the neighboring values, &lt;span class=&quot;math-container&quot;&gt;$y_1^0 = 5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1^0 = 6$&lt;/span&gt;, into the objective function to see which one gives the better value. (This relies on the objective function being convex.) They found that &lt;span class=&quot;math-container&quot;&gt;$y_1^0=5$&lt;/span&gt; is better. But it is not surprising that when you plug &lt;span class=&quot;math-container&quot;&gt;$y_1^0=5$&lt;/span&gt; into the optimality condition, you don't get &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;; &lt;span class=&quot;math-container&quot;&gt;$y_1^0 = 5$&lt;/span&gt; is only optimal because it has to be an integer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Similarly, if you want to minimize &lt;span class=&quot;math-container&quot;&gt;$(x-\frac14)^2$&lt;/span&gt;, the optimality condition is &lt;span class=&quot;math-container&quot;&gt;$2(x-\frac14)=0$&lt;/span&gt;; if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; must be an integer, you'd plug in &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; and pick the better value; but if you plug that value into the optimality condition, the LHS won't equal &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, to calculate the objective function for &lt;span class=&quot;math-container&quot;&gt;$y_1^0=5$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt;, I think they (or you) are skipping some logic here. The optimal policy is a base-stock policy, which means that you are looking for the optimal base-stock level, &lt;span class=&quot;math-container&quot;&gt;$y_1^0$&lt;/span&gt;. The cost of a given base-stock level &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; is &lt;em&gt;not&lt;/em&gt; given by calculating &lt;span class=&quot;math-container&quot;&gt;$C_1(y_1)$&lt;/span&gt;; it is given by setting &lt;span class=&quot;math-container&quot;&gt;$x_1 = $&lt;/span&gt; something small (e.g., &lt;span class=&quot;math-container&quot;&gt;$-10$&lt;/span&gt;) and then calculating what's inside the &lt;span class=&quot;math-container&quot;&gt;$\min_{y_1\ge x_1}\{\cdots\}$&lt;/span&gt; for that value of &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;. The idea is, assuming the inventory level &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; is small enough that we &lt;em&gt;will&lt;/em&gt; place an order in this period, what will be the cost if we place an order up to &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The line in the book &quot;substituting &lt;span class=&quot;math-container&quot;&gt;$y_1^0=5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1^0=6$&lt;/span&gt; into &lt;span class=&quot;math-container&quot;&gt;$C_1(x_1)$&lt;/span&gt; seems misleading to me because it sounds like you're supposed to set &lt;span class=&quot;math-container&quot;&gt;$x_1=5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt;, but that is wrong.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-11T03:11:32.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="365" PostTypeId="2" ParentId="357" CreationDate="2019-06-11T05:07:56.373" Score="10" Body="&lt;p&gt;Only few of you may know &lt;a href=&quot;http://www.erikdemaine.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;Erik Demaine&lt;/a&gt; who is not only a computer science prodigy and artist, but so is his father, Martin. They publish together.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="358" LastEditDate="2019-06-14T17:19:24.367" LastActivityDate="2019-06-14T17:19:24.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="366" PostTypeId="2" ParentId="326" CreationDate="2019-06-11T08:06:03.547" Score="4" Body="&lt;p&gt;In open source codes you usually have more flexibility to change the parameter directly compared to commercial solvers.&lt;br&gt;&#xA;Take &lt;strong&gt;SCIP&lt;/strong&gt; for example where you can program your own &lt;a href=&quot;https://scip.zib.de/doc/html/NODESEL.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;node selector rules&lt;/a&gt;. You also have &lt;a href=&quot;https://scip.zib.de/doc/html/PARAMETERS.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;tons of parameters&lt;/a&gt; to adjust the node selection.&lt;br&gt;&#xA;&lt;strong&gt;CBC&lt;/strong&gt; offers &lt;a href=&quot;https://www.coin-or.org/Cbc/cbcuserguide.html#otherclasses&quot; rel=&quot;nofollow noreferrer&quot;&gt;similar features&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="137" LastActivityDate="2019-06-11T08:06:03.547" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="367" PostTypeId="2" ParentId="304" CreationDate="2019-06-11T08:33:07.570" Score="10" Body="&lt;p&gt;You are touching three similar but different subjects in your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Choosing the set of parameter values for an algorithm and a set of instances is a task known as offline parameter tuning, algorithm configuration, or (as indicated in @EhsanK) hyper-parameter tuning (mostly in machine learning, where the term parameters means something else). There is now a considerable amount of research in the area, for example &lt;a href=&quot;http://iridia.ulb.ac.be/irace/&quot; rel=&quot;noreferrer&quot;&gt;irace&lt;/a&gt;, &lt;a href=&quot;https://www.automl.org/automated-algorithm-design/algorithm-configuration/smac/&quot; rel=&quot;noreferrer&quot;&gt;SMAC&lt;/a&gt;, &lt;a href=&quot;http://www.cs.ubc.ca/labs/beta/Projects/ParamILS/&quot; rel=&quot;noreferrer&quot;&gt;ParamILS&lt;/a&gt;, &lt;a href=&quot;https://wiwi.uni-paderborn.de/fileadmin/dep3ls7/Downloads/Publikationen/PDFs/gga-cp2009.pdf&quot; rel=&quot;noreferrer&quot;&gt;GGA&lt;/a&gt;, &lt;a href=&quot;https://cran.r-project.org/web/packages/mlrMBO/index.html&quot; rel=&quot;noreferrer&quot;&gt;mrlMBO&lt;/a&gt;, &lt;a href=&quot;https://papers.nips.cc/paper/4522-practical-bayesian-optimization-of-machine-learning-algorithms.pdf&quot; rel=&quot;noreferrer&quot;&gt;Spearmint&lt;/a&gt; and many more, both from OR and ML. These are all general-purpose configurators that can be applied to different algorithms. Other specialized tuners exist for specific software, e.g. &lt;a href=&quot;https://groups.csail.mit.edu/commit/papers/2014/ansel-pact14-opentuner.pdf&quot; rel=&quot;noreferrer&quot;&gt;Opentuner&lt;/a&gt; for GCC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is different from online tuning, as you note, where one tries to find at runtime the best parameter configuration to solve the instance currently being tackled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instance features are usually considered in algorithm selection, where an instance is analyzed to select the best algorithm to solve it. See e.g. &lt;a href=&quot;https://arxiv.org/abs/1811.11597&quot; rel=&quot;noreferrer&quot;&gt;this recent survey&lt;/a&gt; and &lt;a href=&quot;https://larskotthoff.github.io/assurvey/&quot; rel=&quot;noreferrer&quot;&gt;this comprehensive literature list&lt;/a&gt;. Instance features are often problem-specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To the best of my knowledge, the use of features in algorithm configuration has not been studied as much as general-purpose offline algorithm configuration and problem-specific algorithm selection. Some works in this category are &lt;a href=&quot;http://www.cs.ubc.ca/labs/beta/Projects/Hydra/&quot; rel=&quot;noreferrer&quot;&gt;Hydra&lt;/a&gt; and &lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.171.77&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;noreferrer&quot;&gt;ISAC&lt;/a&gt;, but there is certainly room for more research here.&lt;/p&gt;&#xA;" OwnerUserId="224" LastActivityDate="2019-06-11T08:33:07.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="368" PostTypeId="2" ParentId="117" CreationDate="2019-06-11T12:48:07.123" Score="17" Body="&lt;p&gt;Surprised that no one has yet mentioned&#xA;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0954350308&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Applications of optimization with Xpress-mp&quot;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course it is focused on their Mosel language, but it contains many good applications.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, a free PDF is &lt;a href=&quot;https://web.archive.org/web/20090718080153/http://www.dashoptimization.com/home/downloads/book/booka4.pdf&quot; rel=&quot;noreferrer&quot;&gt;available&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="34" LastEditorUserId="138" LastEditDate="2019-06-14T15:13:28.203" LastActivityDate="2019-06-14T15:13:28.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="369" PostTypeId="2" ParentId="357" CreationDate="2019-06-11T12:59:57.010" Score="19" Body="&lt;p&gt;For sure there is Bob Bixby and Ann Bixby.  Ann did her Ph.D. at Northwestern with Collette Coullard.&#xA;Also, a bit of a stretch, since his father was more of a mathematician, but there is also Gunnar Carlsson (Stanford Math) and Jon Carlsson, who is currently at USC.&lt;/p&gt;&#xA;" OwnerUserId="34" LastActivityDate="2019-06-11T12:59:57.010" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="370" PostTypeId="2" ParentId="357" CreationDate="2019-06-11T13:51:44.677" Score="23" Body="&lt;p&gt;Another father-daughter pair is Matteo Fischetti of U. of Padova and his daughter Martina Fischetti who recently completed her Ph.D. at DTU with David Pisinger. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are we still waiting for mother-child pairs? Hopefully soon...&lt;/p&gt;&#xA;" OwnerUserId="105" LastActivityDate="2019-06-11T13:51:44.677" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="371" PostTypeId="2" ParentId="117" CreationDate="2019-06-11T14:49:22.293" Score="10" Body="&lt;p&gt;This is not really to learn how to model, but could be inspirational:&#xA;I recently discovered this podcast from INFORMS, that I found very interesting as it is showcasing examples of OR in practice and the people behind them. You can find it on Spotify as well (&lt;a href=&quot;https://pubsonline.informs.org/magazine/orms-today/podcasts&quot; rel=&quot;noreferrer&quot;&gt;https://pubsonline.informs.org/magazine/orms-today/podcasts&lt;/a&gt;). They also have videos from the Edelman competition that show applications of OR in practice.&lt;/p&gt;&#xA;" OwnerUserId="511" LastActivityDate="2019-06-11T14:49:22.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="372" PostTypeId="1" AcceptedAnswerId="374" CreationDate="2019-06-11T15:30:36.647" Score="16" ViewCount="1121" Body="&lt;p&gt;The IIS is a standard part of most modern solvers, but is it unique for an LP? My intuition tells me that it should be, but I could find any proof. &lt;/p&gt;&#xA;" OwnerUserId="133" LastEditorUserId="38" LastEditDate="2019-06-18T02:17:19.450" LastActivityDate="2019-06-18T02:17:19.450" Title="Is the Irreducible Infeasible Subset (IIS) of an LP unique?" Tags="|linear-programming|constraint|irreducible-infeasible-subset|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="373" PostTypeId="2" ParentId="334" CreationDate="2019-06-11T15:50:50.987" Score="4" Body="&lt;p&gt;Something that has really become interesting to me is the creation of software in both of these contexts. Specifically as an end user of a commercial solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;strong&gt;academia&lt;/strong&gt; often code is written to solve a specific problem or explore potential solutions. This perhaps affords the ability to do more fundamental work. Like the exploration of how solvers work or detailed tuning. These implementations tend to be orientated around &quot;running&quot; a model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;strong&gt;industry&lt;/strong&gt; the goal can be to write reusable software which takes some kind of input data and then generates models which are then solved. The solution is then transformed into some kind of output format. Most of this is either delivered through customized software or on top of existing solutions for example GIS tools.&lt;/p&gt;&#xA;" OwnerUserId="259" LastActivityDate="2019-06-11T15:50:50.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="374" PostTypeId="2" ParentId="372" CreationDate="2019-06-11T16:02:09.390" Score="28" Body="&lt;p&gt;The &lt;em&gt;irreducible infeasible subsystem&lt;/em&gt; (IIS) for an infeasible linear program (LP) is a minimal subset of constraints that has no feasible solution, i.e., an inconsistent set of constraints for which any proper subset of the constraints is consistent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not true that an IIS is unique. For intuition, consider that there may be more than one source of infeasibility. As an example, take the following set of constraints:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_1 \le 0 \\&#xA;x_1 \ge 1 \\&#xA;x_2 \le 0 \\&#xA;x_2 \ge 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two options for an IIS: the first two constraints, and the last two constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sources:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://glossary.informs.org/ver2/mpgwiki/index.php/Irreducible_infeasible_subsystem&quot; rel=&quot;noreferrer&quot;&gt;https://glossary.informs.org/ver2/mpgwiki/index.php/Irreducible_infeasible_subsystem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://orinanobworld.blogspot.com/2010/07/why-is-my-model-infeasible.html&quot; rel=&quot;noreferrer&quot;&gt;https://orinanobworld.blogspot.com/2010/07/why-is-my-model-infeasible.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="442" LastEditorUserId="442" LastEditDate="2019-06-11T16:07:14.403" LastActivityDate="2019-06-11T16:07:14.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="375" PostTypeId="1" AcceptedAnswerId="378" CreationDate="2019-06-11T16:41:46.217" Score="19" ViewCount="499" Body="&lt;p&gt;Once I found a site on the web containing some classic, original material from around the WW II. One of the topics covered was submarine hunting. But I cannot find that again now ... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the question is: Where can I find original documents, especially applied ones, from that period? Preferably web sites, but failing that, other options are good.  Also of interest are references to particularly illuminating documents from that period. I found the paper &lt;em&gt;British Operational Research in World War II&lt;/em&gt; by Joseph F. McCloskey,  Operations Research, Vol. 35, No. 3 (May - Jun., 1987), pp. 453-470  (on JSTOR.) &lt;/p&gt;&#xA;" OwnerUserId="166" LastEditorUserId="8" LastEditDate="2020-09-03T23:12:31.830" LastActivityDate="2022-06-16T17:13:23.733" Title="Classics in Operations Research from around WW II?" Tags="|reference-request|history|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="376" PostTypeId="2" ParentId="375" CreationDate="2019-06-11T16:58:23.517" Score="10" Body="&lt;p&gt;About the &quot;submarine hunting&quot;, if &quot;&lt;a href=&quot;https://www.ibiblio.org/hyperwar/USN/rep/ASW-51/&quot; rel=&quot;noreferrer&quot;&gt;ANTISUBMARINE WARFARE IN WORLD WAR II&lt;/a&gt;&quot; is not the link you had in mind, it still might be useful. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I found some of the links in &quot;&lt;a href=&quot;https://www.informs.org/ORMS-Today/Public-Articles/June-Volume-42-Number-3/History-of-OR-Useful-history-of-operations-research&quot; rel=&quot;noreferrer&quot;&gt;History of OR&lt;/a&gt;&quot;, the example in &lt;a href=&quot;https://supernet.isenberg.umass.edu/visuals/lb-fo4.pdf&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; pdf, and some of the links in the &quot;second world war&quot; section of &lt;a href=&quot;https://en.wikipedia.org/wiki/Operations_research#Second_World_War&quot; rel=&quot;noreferrer&quot;&gt;Operations Research Wikipedia&lt;/a&gt; page, fascinating.  &lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-06-11T16:58:23.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="377" PostTypeId="1" AcceptedAnswerId="379" CreationDate="2019-06-11T17:24:47.650" Score="5" ViewCount="430" Body="&lt;p&gt;I am working on a forecasting project and want to reaffirm my knowledge on different techniques before blindly hitting run in my Python code. I am testing several forecasting techniques such as exponential smoothing, Holt-Winters Methods, and Box-Jenkins/ARIMA modeling as there is not excellent exogenous data to perform other forms of forecasting. I am basing my research off of Bowerman, O'Connell, and Koehler's &quot;Forecasting, Time Series, and Regression&quot; Fourth Edition. I have a good grasp of what the autoregressive(AR) term represents according to the function &lt;span class=&quot;math-container&quot;&gt;$z_t=\phi_1z_{t-1}+\alpha_1$&lt;/span&gt;. This shows that an AR process is one in which future values are constant multiples of past values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The book describes moving average (MA) processes, however, as &quot;less intuitive but equally useful&quot; and I seem to agree. Following the formula &lt;span class=&quot;math-container&quot;&gt;$z_t=\alpha_t-\theta_1\alpha_{t-1}$&lt;/span&gt;, the best I can interpret to mean is that future values are based on the errors of past estimates. Is this interpretation correct, and if so, what does that mean about the data if it relies on past errors? For AR, this means that the data is directly related to the past values, but I cannot connect the dots to what conclusion I should draw about the existance of a MA process in my data.  &lt;/p&gt;&#xA;" OwnerUserId="416" LastEditorUserId="123" LastEditDate="2019-06-11T18:34:44.033" LastActivityDate="2019-06-14T05:28:17.853" Title="Meaning of Moving Average Term in ARIMA" Tags="|forecasting|time-series|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="378" PostTypeId="2" ParentId="375" CreationDate="2019-06-11T18:15:32.513" Score="18" Body="&lt;p&gt;A few suggestions.&lt;br /&gt;&#xA;First, the series by Charles R. Shrader from the US Army Center of Military History.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;[1]&lt;/strong&gt;  &lt;em&gt;History of Operations Research in the United States Army, Volume 1: 1942–1962&lt;/em&gt;.  (&lt;a href=&quot;https://apps.dtic.mil/dtic/tr/fulltext/u2/a468757.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;full text&lt;/a&gt; or &lt;a href=&quot;https://history.army.mil/html/books/hist_op_research/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;also here&lt;/a&gt; or &lt;a href=&quot;https://history.army.mil/catalog/pubs/70/70-102.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;[2]&lt;/strong&gt;  &lt;em&gt;History of Operations Research in the United States Army, Volume 2: 1961–1973&lt;/em&gt;.  (&lt;a href=&quot;https://history.army.mil/html/books/operations_research_vol2/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;full text&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;[3]&lt;/strong&gt;  &lt;em&gt;History of Operations Research in the United States Army, Volume 3: 1973–1995&lt;/em&gt;.  (&lt;a href=&quot;https://history.army.mil/html/books/operations_research_vol3/CMH_70-110-1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;full text&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;There is also a 1987 paper by Joseph F. McCloskey in &lt;em&gt;Operations Research&lt;/em&gt; (Vol 35, No 6, pp. 910-925). You might find it helpful, especially its references.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;[4]&lt;/strong&gt; &lt;em&gt;U.S. Operations Research in World War II&lt;/em&gt; (&lt;a href=&quot;https://www.jstor.org/stable/171441&quot; rel=&quot;nofollow noreferrer&quot;&gt;stable link&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For a &lt;strong&gt;current perspective on operational use and allocation of OR analysts&lt;/strong&gt;, I recommend COL(ret.) Greg Parlier's whitepaper from 2015 for the Association of the US Army's Land Warfare Papers (No 105W).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;[5]&lt;/strong&gt; &lt;em&gt;Operations Research and the United States Army: A 75th Anniversary Perspective&lt;/em&gt; (&lt;a href=&quot;https://www.ausa.org/sites/default/files/LWP-105-Operations-Research-and-the-United-States-Army-a-75th-Anniversary-Perspective.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;full text&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;[6]&lt;/strong&gt; &lt;em&gt;An Historical Perspective on U.S. Army Operations Research&lt;/em&gt; (&lt;a href=&quot;https://www.jstor.org/stable/43940814&quot; rel=&quot;nofollow noreferrer&quot;&gt;stable link&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I have a few more. I'll try and dig them up.&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2022-06-16T17:13:23.733" LastActivityDate="2022-06-16T17:13:23.733" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="379" PostTypeId="2" ParentId="377" CreationDate="2019-06-11T18:15:40.310" Score="8" Body="&lt;p&gt;For time series, it is better to think about the &lt;span class=&quot;math-container&quot;&gt;$\alpha_t$&lt;/span&gt; terms (supposed to be an independent mean zero series) as &lt;em&gt;innovations&lt;/em&gt;, not &lt;em&gt;errors&lt;/em&gt;. They are &lt;strong&gt;not&lt;/strong&gt; modeling errors of measurements, but the really &lt;em&gt;new&lt;/em&gt; information that arrives in the series, not predictable from the history of the series. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a pure AR series depends on former &lt;em&gt;values&lt;/em&gt;, while a pure MA series depends on former &lt;em&gt;innovations&lt;/em&gt;. Natural examples can be &lt;a href=&quot;https://stats.stackexchange.com/questions/45026/real-life-examples-of-moving-average-processes&quot;&gt;found in this CV post&lt;/a&gt;. The following example &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When trying to get an intuitive real world picture of MA or AR (or&#xA;  ARMA or ARIMA if you are extending it) I often find it useful to think&#xA;  of carry over effects, that is something happening in one period&#xA;  carries over into the next.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Here's an example: say you are modelling newspaper sales. The noise&#xA;  (random error) in such a model could sensibly incorporate the&#xA;  relatively short lived effect of newspaper headlines while the rest of&#xA;  the model deals with more stable things like trend and seasonality&#xA;  (now I'm assuming an ARIMA model but if you want a pure MA model&#xA;  imagine no trend or seasonality for the paper). Although the newspaper&#xA;  headline effect is modelled as error we might decide that this effect&#xA;  does indeed carry over into the next few days (a good story brings in&#xA;  readers who then fade away again). This would invite the inclusion of&#xA;  an MA term in the model - the carryover of the effect of the previous&#xA;  error term into the current time period.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You can think in the same way about the AR term only what is carried&#xA;  over here is part of the effect of the whole of the previous days&#xA;  sales.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;is &lt;a href=&quot;https://stats.stackexchange.com/questions/94865/what-is-maq-model-input-in-real-world&quot;&gt;taken from an answer here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="166" LastActivityDate="2019-06-11T18:15:40.310" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="380" PostTypeId="2" ParentId="183" CreationDate="2019-06-11T19:14:51.223" Score="8" Body="&lt;p&gt;A main reason to use Reinforced Learning (RL) is because you don't know the dynamics (update rules) of the system. &#xA;If you don't know the details of how the system will update, you will not be able to construct tight constraints for MIPs. &#xA;For example, you may be able to write an MIP for the system with constraint &lt;span class=&quot;math-container&quot;&gt;$Ax = b$&lt;/span&gt;. However, the values of some elements in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; maybe unknown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since we don't know the dynamics of the system, RL usually requires a huge number of samples from the system to learn the dynamics. &#xA;There are two major solving approaches for RL. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Model-based: Use samples to identify a proper model and then use more samples to calibrate that model. &lt;/li&gt;&#xA;&lt;li&gt;Model-free: Update the solution with upcoming samples according to certain rules. (Policy Gradient) &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In terms of sample complexity, RL in general is quite inefficient comparing to methods with a known fitting model. But the strength of RL comes from its ability to learn the unknown dynamics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not an expert in this field. But I would recommend Ben Recht's &lt;a href=&quot;https://arxiv.org/abs/1806.09460&quot; rel=&quot;noreferrer&quot;&gt;paper&lt;/a&gt; on the connection between RL and optimal control problems. &lt;/p&gt;&#xA;" OwnerUserId="162" LastActivityDate="2019-06-11T19:14:51.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="381" PostTypeId="2" ParentId="375" CreationDate="2019-06-11T19:22:33.177" Score="14" Body="&lt;p&gt;THE classic book on WW II Operations Research is &quot;Methods of Operations Research&quot; by Philip M. Morse, George E. Kimball. It is basically WW II O.R., less classified material.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://store.doverpublications.com/0486432343.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dover Press version&lt;/a&gt; is a reprint, with intro from Saul Gass, of the original 1951 version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://mitpress.mit.edu/books/methods-operations-research-revised-edition&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIT Press version&lt;/a&gt; is the 1959 revised edition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Stanford O.R. Ph.D. and Professor, 2019 Philip McCord Morse Lectureship Award winner, Peter Glynn just scored a copy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.informs.org/Recognizing-Excellence/INFORMS-Prizes/Philip-McCord-Morse-Lectureship-Award?utm_campaign=INFORMS%20eNews&amp;amp;utm_source=hs_email&amp;amp;utm_medium=email&amp;amp;utm_content=74173307&amp;amp;_hsenc=p2ANqtz-_mMheYMs8i6xh5ky5F7-qjyLqaKvtj9qNcKQFVMqmTE3GthMcUjtBMRGYoL_Yq-lhZRWvsGZDdA8mB1jKUKJalqL06Og&amp;amp;_hsmi=74173307&quot; rel=&quot;nofollow noreferrer&quot;&gt;Philip McCord Morse Lectureship Award&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The award is \$2,000, a certificate,  a  travel fund of \$5,000, a copy of&#xA;  Morse's autobiography, In at the Beginnings: A Physicist's Life, and a&#xA;  copy of Morse and Kimball's Methods of Operations Research.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-06-28T19:44:36.250" LastActivityDate="2019-06-28T19:44:36.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="383" PostTypeId="5" CreationDate="2019-06-11T19:51:04.797" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-11T19:51:04.797" LastActivityDate="2019-06-11T19:51:04.797" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="384" PostTypeId="4" CreationDate="2019-06-11T19:51:04.797" Score="0" Body="For questions related to software designed to solve very general classes of optimization problems to guaranteed optimality." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-11T23:11:40.543" LastActivityDate="2019-06-11T23:11:40.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="385" PostTypeId="2" ParentId="244" CreationDate="2019-06-11T19:56:29.513" Score="11" Body="&lt;p&gt;Some more:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://atamturk.ieor.berkeley.edu/data/&quot; rel=&quot;noreferrer&quot;&gt;Atamturk datasets&lt;/a&gt; on fixed-charge flow, lot sizing, mixed-integer knapsack, and more&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.cs.ubc.ca/~kevinlb/CATS/&quot; rel=&quot;noreferrer&quot;&gt;Combinatorial Auction Test Suite (CATS)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.math.uwaterloo.ca/tsp/world/countries.html&quot; rel=&quot;noreferrer&quot;&gt;National Traveling Salesman Problems&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.math.uwaterloo.ca/tsp/vlsi/&quot; rel=&quot;noreferrer&quot;&gt;VLSI data sets&lt;/a&gt;: Another collection of 102 TSP instances&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://sites.google.com/site/gciports/&quot; rel=&quot;noreferrer&quot;&gt;GiC Data Sets&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I made a &lt;a href=&quot;https://github.com/ekhoda/optimization_problem_libraries&quot; rel=&quot;noreferrer&quot;&gt;GitHub repository&lt;/a&gt; and added all of these references. there. &lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-15T00:15:55.287" LastActivityDate="2019-06-15T00:15:55.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="386" PostTypeId="5" CreationDate="2019-06-11T20:04:57.600" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-11T20:04:57.600" LastActivityDate="2019-06-11T20:04:57.600" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="387" PostTypeId="4" CreationDate="2019-06-11T20:04:57.600" Score="0" Body="For questions related to the branch-and-bound method for integer programming problems, which recursively divides the solution space and identifies upper and lower bounds on the optimal objective function value." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-12T01:48:04.243" LastActivityDate="2019-06-12T01:48:04.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="388" PostTypeId="2" ParentId="244" CreationDate="2019-06-11T20:27:43.170" Score="8" Body="&lt;p&gt;Would these be helpful?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) OptaPlanner examples &lt;a href=&quot;https://docs.optaplanner.org/latestFinal/optaplanner-docs/html_single/#examplesOverview&quot; rel=&quot;noreferrer&quot;&gt;problem definitions&lt;/a&gt; and &lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/data&quot; rel=&quot;noreferrer&quot;&gt;data sets&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;Original problems&lt;/em&gt;: cloud balancing, dinner party, tennis club scheduling, meeting scheduling, task assigning, investment portfolio optimization, conference scheduling, rock tour, flight crew scheduling&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;Problems defined by academic challenges and others&lt;/em&gt;: tsp, course scheduling (ITC 2007), machine reassignment (ROADEF 2012), vrp, project job scheduling, hospital bed planning, exam timetabling (ITC 2007), nurse rostering, traveling tournament, cheap time scheduling, coach shuttle gathering&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;2) For VRP and variants, I'd argue that &lt;a href=&quot;http://www.vrp-rep.org/&quot; rel=&quot;noreferrer&quot;&gt;VRP-REP&lt;/a&gt; is the canonical place to find high-quality datasets.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2019-06-11T20:39:54.877" LastActivityDate="2019-06-11T20:39:54.877" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="389" PostTypeId="2" ParentId="235" CreationDate="2019-06-11T21:57:33.447" Score="25" Body="&lt;p&gt;Decision diagrams (DDs) are most effective when they can compactly represent a large (perhaps exponential) set of solutions.  This is done by merging equivalent states in each layer.  To make decision diagrams scalable, we can use &lt;a href=&quot;https://doi.org/10.1007/978-3-540-74970-7_11&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;relaxed&lt;/em&gt; decision diagrams&lt;/a&gt; which allow merging nodes that are not necessarily equivalent.  Relaxed decision diagrams provide &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-642-21311-3_5&quot; rel=&quot;noreferrer&quot;&gt;dual bounds on the objective function&lt;/a&gt; -- a larger width can produce a &lt;a href=&quot;https://doi.org/10.1287/ijoc.2013.0561&quot; rel=&quot;noreferrer&quot;&gt;stronger bound&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relationship between the size of the decision diagram and the underlying combinatorial structure of the problem is well studied in the computer science literature; see for example the &lt;a href=&quot;https://epubs.siam.org/doi/book/10.1137/1.9780898719789&quot; rel=&quot;noreferrer&quot;&gt;textbook by Wegener&lt;/a&gt;.  The most important feature that influences the size is the variable ordering.  We can use this to come up with some general guidelines on when a DD may be successful for combinatorial optimization:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The problem has a sequential structure, and decisions for stage &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; depend only on the decisions made in stages &lt;span class=&quot;math-container&quot;&gt;$i-k$&lt;/span&gt; through &lt;span class=&quot;math-container&quot;&gt;$i-1$&lt;/span&gt;, for small &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Ordered_graph&quot; rel=&quot;noreferrer&quot;&gt;induced width&lt;/a&gt; of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Constraint_graph&quot; rel=&quot;noreferrer&quot;&gt;constraint graph&lt;/a&gt; of the problem is small.&lt;/li&gt;&#xA;&lt;li&gt;For a MIP model, the constraint matrix has a small &lt;a href=&quot;https://en.wikipedia.org/wiki/Band_matrix&quot; rel=&quot;noreferrer&quot;&gt;bandwidth&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For &lt;a href=&quot;https://en.wikipedia.org/wiki/Knapsack_problem&quot; rel=&quot;noreferrer&quot;&gt;knapsack-like problems&lt;/a&gt;, the maximum `budget' is relatively small.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that in some of the above cases, precise characterization of 'small' may yield (pseudo-)polynomial bounds on the size of the exact DD.  In practice, relaxed DDs will always have polynomial size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several areas of combinatorial optimization in which decision diagrams have been successfully applied:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sequencing and routing problems.&lt;/strong&gt;  For example, &lt;a href=&quot;http://dx.doi.org/10.1287/opre.2013.1221&quot; rel=&quot;noreferrer&quot;&gt;single machine scheduling&lt;/a&gt; with setup times, time windows, and/or precedence constraints, which can also be applied to constrained traveling salesperson problems.  A similar decision diagram representation was used by Grubhub to solve &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0167637718305364&quot; rel=&quot;noreferrer&quot;&gt;pickup-and-delivery problems&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Decomposition and embedding in MIP models.&lt;/strong&gt;  Decision diagrams have been used to represent subproblems in MIP models that are otherwise difficult to linearize.  For example, to represent &lt;a href=&quot;https://doi.org/10.1287/mnsc.2017.2849&quot; rel=&quot;noreferrer&quot;&gt;nonlinear objective functions&lt;/a&gt;, &lt;a href=&quot;https://doi.org/10.1111/poms.12978&quot; rel=&quot;noreferrer&quot;&gt;constrained employee schedules&lt;/a&gt;, or &lt;a href=&quot;https://link.springer.com/chapter/10.1007%2F978-3-030-19212-9_30&quot; rel=&quot;noreferrer&quot;&gt;nonlinear circuit design&lt;/a&gt;.  DDs have also been used in &lt;a href=&quot;https://doi.org/10.1287/ijoc.2015.0667&quot; rel=&quot;noreferrer&quot;&gt;column generation&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Graph-theoretic problems.&lt;/strong&gt;  Examples include &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-642-21311-3_5&quot; rel=&quot;noreferrer&quot;&gt;set covering&lt;/a&gt;, &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-642-29828-8_3&quot; rel=&quot;noreferrer&quot;&gt;maximum independent set&lt;/a&gt;, and &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.2015.0648&quot; rel=&quot;noreferrer&quot;&gt;maximum cut&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Constraint programming.&lt;/strong&gt;  Constraint propagation based on (relaxed) decision diagrams can be much more effective than propagating domains of individual variables.  This was first demonstrated on &lt;a href=&quot;https://doi.org/10.1007/978-3-540-74970-7_11&quot; rel=&quot;noreferrer&quot;&gt;overlapping alldifferent constraints&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="516" LastActivityDate="2019-06-11T21:57:33.447" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="390" PostTypeId="5" CreationDate="2019-06-12T02:40:59.807" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-12T02:40:59.807" LastActivityDate="2019-06-12T02:40:59.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="391" PostTypeId="4" CreationDate="2019-06-12T02:40:59.807" Score="0" Body="For questions related to convex functions and convex sets, especially as they relate to optimization problems." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-12T04:31:39.483" LastActivityDate="2019-06-12T04:31:39.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="392" PostTypeId="5" CreationDate="2019-06-12T02:42:39.943" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-12T02:42:39.943" LastActivityDate="2019-06-12T02:42:39.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="393" PostTypeId="4" CreationDate="2019-06-12T02:42:39.943" Score="0" Body="For questions related to reinforcement learning, a type of machine learning algorithm in which a computerized agent learns through experimentation how to optimize its actions in an environment to maximize its reward." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-12T04:33:12.440" LastActivityDate="2019-06-12T04:33:12.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="394" PostTypeId="5" CreationDate="2019-06-12T02:44:04.470" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-12T02:44:04.470" LastActivityDate="2019-06-12T02:44:04.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="395" PostTypeId="4" CreationDate="2019-06-12T02:44:04.470" Score="0" Body="For questions related to Lagrangian relaxation, a method used to generate bounds on optimization problems by removing one or more constraints and including a penalty in the objective function for violating the removed constraints." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-12T04:31:00.600" LastActivityDate="2019-06-12T04:31:00.600" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="396" PostTypeId="5" CreationDate="2019-06-12T02:45:08.890" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-12T02:45:08.890" LastActivityDate="2019-06-12T02:45:08.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="397" PostTypeId="4" CreationDate="2019-06-12T02:45:08.890" Score="0" Body="For questions related to Lagrangian decomposition, an optimization method in which one or more decision variable is doubled, the new variable is set equal to the original variable via a constraint, and that constraint is relaxed using Lagrangian relaxation." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-12T04:31:22.767" LastActivityDate="2019-06-12T04:31:22.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="398" PostTypeId="5" CreationDate="2019-06-12T02:46:39.657" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-12T02:46:39.657" LastActivityDate="2019-06-12T02:46:39.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="399" PostTypeId="4" CreationDate="2019-06-12T02:46:39.657" Score="0" Body="For questions related to the economic order quantity (EOQ) problem, which seeks the optimal order quantity for an inventory system with constant, deterministic demand; fixed costs for placing orders; and holding costs." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-12T04:30:35.917" LastActivityDate="2019-06-12T04:30:35.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="400" PostTypeId="1" CreationDate="2019-06-12T03:17:17.360" Score="5" ViewCount="162" Body="&lt;p&gt;There are two common approximations for the &lt;span class=&quot;math-container&quot;&gt;$(r,Q)$&lt;/span&gt; inventory optimization problem that use the EOQ model. It is well known that one of them has a fixed worst-case error bound, but there is confusion in the literature about which one it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Approximation 1 (EOQ+SS Approximation):&lt;/strong&gt; In this approximation, we set &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; using the EOQ formula and set &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; so that the safety stock (SS) ensures a service level of &lt;span class=&quot;math-container&quot;&gt;$\alpha \equiv p/(p+h)$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;Q &amp;amp; = \sqrt{\frac{2K\lambda}{h}} \\&#xA;r &amp;amp; = \mu + z_\alpha\sigma,&#xA;\end{align}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is the fixed cost, &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is the mean demand per year, &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; is the holding cost per item per year, &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is the stockout cost per item per year, &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; are the mean and standard deviation of the lead-time demand, and &lt;span class=&quot;math-container&quot;&gt;$z_\alpha$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;th quantile of the standard normal distribution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are treating the inventory level process as being decomposed into two parts, a top part that looks like the EOQ curve and a bottom part that is flat, at height &lt;span class=&quot;math-container&quot;&gt;$s = r - \mu = z_\alpha\sigma$&lt;/span&gt; (the safety stock).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Approximation 2 (EOQB Approximation):&lt;/strong&gt; Here, we use the economic order quantity with backorders (EOQB) to set &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Q = \sqrt{\frac{2K\lambda(h+p)}{hp}}.$$&lt;/span&gt;&#xA;To set &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; we use the fact that, for given &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;, the optimal &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; satisfies&#xA;&lt;span class=&quot;math-container&quot;&gt;$$g(r) = g(r+Q),$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$g(\cdot)$&lt;/span&gt; is the standard newsvendor cost function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Which approximation has a fixed worst-case error bound?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-12T03:17:17.360" Title="Which EOQ-based $(r,Q)$ approximation has a fixed worst-case error bound?" Tags="|inventory|error-bounds|economic-order-quantity|rq-inventory-model|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="401" PostTypeId="2" ParentId="400" CreationDate="2019-06-12T03:17:17.360" Score="8" Body="&lt;p&gt;&lt;strong&gt;Only the EOQB approximation (approximation 2) has a fixed worst-case error bound.&lt;/strong&gt; &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/mnsc.38.1.87&quot; rel=&quot;noreferrer&quot;&gt;Zheng (1992)&lt;/a&gt; proved an error bound of &lt;span class=&quot;math-container&quot;&gt;$\frac18$&lt;/span&gt;, and &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/mnsc.42.6.830&quot; rel=&quot;noreferrer&quot;&gt;Axsäter (1996)&lt;/a&gt; proved a stronger bound of &lt;span class=&quot;math-container&quot;&gt;$(\sqrt{5}-2)/2 \approx 0.118$&lt;/span&gt;, which is tight. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The EOQ+SS approximation (approximation 1) does &lt;em&gt;not&lt;/em&gt; have a fixed worst-case error bound; for any &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, we can find a problem instance for which &#xA;the ratio between the cost of the EOQ+SS solution and the cost of the optimal &lt;span class=&quot;math-container&quot;&gt;$(r,Q)$&lt;/span&gt; solution is greater than &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've noticed that it's a common mistake to say that the EOQ+SS approximation has a fixed worst-case bound, even though it does not. My guess is that the confusion arises from the fact that lots of people know the EOQ+SS approximation (it is simpler and therefore taught in many OR/OM/IE courses and textbooks) while fewer people know the EOQB approximation; and from the fact that the papers by Zheng and Axsäter both use the term &quot;EOQ&quot; in the title, rather than EOQB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: Worst-case bounds aside, the EOQ+SS approximation can result in much larger errors in practice than the EOQB tends to. However, these errors largely disappear if we set &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; according to the EOQ model and then set &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; using &lt;span class=&quot;math-container&quot;&gt;$g(r)=g(r+Q)$&lt;/span&gt;, instead of using &lt;span class=&quot;math-container&quot;&gt;$r = \mu+z_\alpha\sigma$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-12T03:17:17.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="402" PostTypeId="5" CreationDate="2019-06-12T04:42:48.110" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-12T04:42:48.110" LastActivityDate="2019-06-12T04:42:48.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="403" PostTypeId="4" CreationDate="2019-06-12T04:42:48.110" Score="0" Body="For questions on modeling satisfaction or optimization problems in languages designed for expressing (often high-level) constraints on decision variables." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-13T11:04:39.150" LastActivityDate="2019-06-13T11:04:39.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="404" PostTypeId="5" CreationDate="2019-06-12T04:45:43.037" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-12T04:45:43.037" LastActivityDate="2019-06-12T04:45:43.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="405" PostTypeId="4" CreationDate="2019-06-12T04:45:43.037" Score="0" Body="For questions about standard test instances for evaluating the performance of Operations Research models or algorithms. &#xD;&#xA;&#xD;&#xA;" OwnerUserId="87" LastEditorUserId="38" LastEditDate="2019-06-12T14:05:31.600" LastActivityDate="2019-06-12T14:05:31.600" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="406" PostTypeId="5" CreationDate="2019-06-12T04:54:58.970" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-12T04:54:58.970" LastActivityDate="2019-06-12T04:54:58.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="407" PostTypeId="4" CreationDate="2019-06-12T04:54:58.970" Score="0" Body="For questions on the mathematical modeling of processes with randomized outcomes." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-12T12:03:28.403" LastActivityDate="2019-06-12T12:03:28.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="408" PostTypeId="5" CreationDate="2019-06-12T05:01:31.927" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-12T05:01:31.927" LastActivityDate="2019-06-12T05:01:31.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="409" PostTypeId="4" CreationDate="2019-06-12T05:01:31.927" Score="0" Body="For questions about invariance under transformations, in OR usually the transformation of a solution into other solutions of the same objective value." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-12T12:03:24.027" LastActivityDate="2019-06-12T12:03:24.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="410" PostTypeId="5" CreationDate="2019-06-12T05:04:47.363" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-12T05:04:47.363" LastActivityDate="2019-06-12T05:04:47.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="411" PostTypeId="4" CreationDate="2019-06-12T05:04:47.363" Score="0" Body="For questions on interfaces between a solver library and applications that allow to call user code at specific points in the solving process (e.g. on finding a new solution)." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-12T12:04:08.620" LastActivityDate="2019-06-12T12:04:08.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="412" PostTypeId="2" ParentId="357" CreationDate="2019-06-12T07:47:14.090" Score="12" Body="&lt;p&gt;There are &lt;a href=&quot;https://statweb.stanford.edu/~tibs/&quot; rel=&quot;noreferrer&quot;&gt;Robert Tibshirani&lt;/a&gt;, the father of the LASSO, and his son &lt;a href=&quot;http://www.stat.cmu.edu/~ryantibs/&quot; rel=&quot;noreferrer&quot;&gt;Ryan Tibshirani&lt;/a&gt;. Even though they mainly work in statistics they also have made some valuable contributions to the OR-community such as the LASSO, several contributions in Machine Learning or &lt;a href=&quot;http://www.stat.cmu.edu/~ryantibs/papers/bestsubset.pdf&quot; rel=&quot;noreferrer&quot;&gt;this comparison&lt;/a&gt; of regression methods. &lt;/p&gt;&#xA;" OwnerUserId="81" LastActivityDate="2019-06-12T07:47:14.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="413" PostTypeId="2" ParentId="375" CreationDate="2019-06-12T10:08:51.337" Score="15" Body="&lt;p&gt;I love this historic piece by Alexander Schrijver about &lt;a href=&quot;https://homepages.cwi.nl/~lex/files/histtrpclean.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;max flow and min cut&lt;/a&gt; (&lt;a href=&quot;https://doi.org/10.1007/s101070100259&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI link&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="56" LastEditDate="2019-06-28T13:05:26.810" LastActivityDate="2019-06-28T13:05:26.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="414" PostTypeId="5" CreationDate="2019-06-12T14:06:58.107" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-12T14:06:58.107" LastActivityDate="2019-06-12T14:06:58.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="415" PostTypeId="4" CreationDate="2019-06-12T14:06:58.107" Score="0" Body="For questions related to the simplex method for linear programming (LP), which solves LPs optimally by moving iteratively from in corner point of the feasible region to a better one. " OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-12T14:06:58.107" LastActivityDate="2019-06-12T14:06:58.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="416" PostTypeId="1" AcceptedAnswerId="418" CreationDate="2019-06-12T14:09:35.183" Score="13" ViewCount="126" Body="&lt;p&gt;Different kinds of problems involve transporting an amount &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; from A to B which results in a cost &lt;span class=&quot;math-container&quot;&gt;$c(x)$&lt;/span&gt; in the objective function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Traditionally, often linearized costs are used to get an easy, linear model. This might lead to unrealistic solutions if transport volumes are small.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are more realistic ways to model transport costs (considering especially road transport, to be more specific) which nevertheless lead to manageable and practically solvable mixed integer programs?&lt;/p&gt;&#xA;" OwnerUserId="50" LastEditorUserId="8" LastEditDate="2020-09-04T09:43:15.293" LastActivityDate="2020-09-06T13:12:09.293" Title="Sensible and realistic way to model truck based transport costs depending on amount" Tags="|mixed-integer-programming|linearization|logistics|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="417" PostTypeId="2" ParentId="416" CreationDate="2019-06-12T15:17:53.153" Score="9" Body="&lt;p&gt;One common &lt;span class=&quot;math-container&quot;&gt;$c(x)$&lt;/span&gt; function is a &amp;quot;cost per distance unit (mile/km)&amp;quot; like $2/mile, which is just distance-dependent. My 2 cents for more realistic cost functions:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;For distance-dependent costs:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a different distance function. If you are using linear distance (Euclidean or Manhattan), replace it with a better approximation like Haversine distance or the real distance obtained from, for example, Google map API.&lt;/li&gt;&#xA;&lt;li&gt;Of course, better depending on your use case. In Manhattan, Manhattan distance is good!&lt;/li&gt;&#xA;&lt;li&gt;Generally, there should be a minimum amount on the route cost. Assuming the simple \$2/mile charge, you won't charge just \$20 if you drive for 10 miles. So, &lt;span class=&quot;math-container&quot;&gt;$$\text{Cost}=\max(\min{\rm charge}, c(x))$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;For amount-dependent costs:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Use some &lt;em&gt;piecewise approximation&lt;/em&gt; so that you &lt;em&gt;can&lt;/em&gt; pre-process the cost. For example, if you have cost of &lt;span class=&quot;math-container&quot;&gt;$ c(q)$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; is a decision variable for the quantity on arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, your cost function in your code, should be conditional on the value of &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note, although I used the word &amp;quot;approximation&amp;quot;, this is more or less how it works in real-world instances. Your cost does not depend on every increment of &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt;, rather it goes up and down depending on the range or bin where &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; falls in.&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="123" LastEditDate="2020-09-06T13:12:09.293" LastActivityDate="2020-09-06T13:12:09.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="418" PostTypeId="2" ParentId="416" CreationDate="2019-06-12T15:54:56.183" Score="6" Body="&lt;p&gt;In my experience, there are two types of logistics modeling questions that require truck transportation costs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the first, a shipper will operate a fleet of its own vehicles and would like to estimate costs. In such cases, it is usually important to model both fixed costs of using additional vehicles and the variable costs of operating vehicles (which vary with distance travelled and/or time operated). Any cost approximation should be careful to appropriately model these fixed costs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the second type of problem, a shipper will &lt;em&gt;outsource&lt;/em&gt; truck transportation to meet its shipping needs. Here is a bit more detail about that scenario:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Purchased truck transportation&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, a shipper needs to &lt;em&gt;purchase&lt;/em&gt; freight transportation from third parties (like trucking companies (carriers) or from third-party logistics (3PL) firms). Different types of truck service are available for purchase, most notably &lt;em&gt;truckload&lt;/em&gt;, &lt;em&gt;less-than-truckload&lt;/em&gt;, or &lt;em&gt;small package&lt;/em&gt; services. Each type of service is priced somewhat differently. It is quite common that truckload services on a lane &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; are priced per trailerload, and thus a &lt;strong&gt;step function&lt;/strong&gt; for cost is often needed. LTL and package services on a lane are typically priced per weight (or per some weight-and-cubic-volume measure like dimensional weight), and there are often rate breaks where the price per weight decreases at larger weights making &lt;strong&gt;piecewise-linear&lt;/strong&gt; cost functions necessary. Often these functions &lt;strong&gt;do not have strictly-decreasing slopes&lt;/strong&gt; since they may include &lt;em&gt;shoulders&lt;/em&gt; where cost is fixed for a certain weight range.&lt;/p&gt;&#xA;" OwnerUserId="105" LastActivityDate="2019-06-12T15:54:56.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="419" PostTypeId="1" CreationDate="2019-06-12T20:14:06.693" Score="31" ViewCount="1642" Body="&lt;p&gt;Given an optimization problem that aims at minimizing some objective function, a lower bound that is valid for all feasible solutions, and &lt;em&gt;your&lt;/em&gt; solver of choice:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For what theoretical and/or practical (implementation-specific?) reason(s) would you &lt;em&gt;not&lt;/em&gt; feed this bound to &lt;em&gt;your&lt;/em&gt; favorite solver?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or, if you &lt;em&gt;can't&lt;/em&gt; think of any such reason, do you have [more or less] justified &amp;quot;opinions&amp;quot; on how &lt;em&gt;not&lt;/em&gt; to provide such a bound to the solver (e. g., &amp;quot;hard-wired&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt;-constraint vs. some sort of callback/&amp;quot;dynamic cut&amp;quot; vs. ...)?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="138" LastEditorUserId="138" LastEditDate="2022-07-21T15:32:04.147" LastActivityDate="2022-07-21T15:32:04.147" Title="Feeding known lower bounds to solvers" Tags="|linear-programming|mixed-integer-programming|integer-programming|solver|bounds|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="420" PostTypeId="2" ParentId="419" CreationDate="2019-06-12T21:23:09.540" Score="12" Body="&lt;p&gt;Branch-and-bound solvers often use node lower bounds to select the next node to process, e.g. in a &lt;a href=&quot;https://en.wikipedia.org/wiki/Best-first_search&quot; rel=&quot;noreferrer&quot;&gt;best-first search&lt;/a&gt;. An external lower bound can lead to a different search order, and thus you may have to explore a different number nodes until finding an optimal solution, and proving its optimality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For concreteness imagine a simple depth &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; binary search tree over &lt;span class=&quot;math-container&quot;&gt;$x\in\{0,1\}^4$&lt;/span&gt; and let the unique optimal solution be &lt;span class=&quot;math-container&quot;&gt;$x=(0\:0\:0\:0)^t$&lt;/span&gt;. If you set the lower bound equal to the optimal solution value, the search stops when an optimal solution has been found. However, the lower bound does not guide the search, and as a function of the tie-breaker you may explore between &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; nodes (&lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;-first tie-breaker) to &lt;span class=&quot;math-container&quot;&gt;$31$&lt;/span&gt; nodes (&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;-first tie-breaker) until that happens.&lt;/p&gt;&#xA;" OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-13T01:24:53.477" LastActivityDate="2019-06-13T01:24:53.477" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="421" PostTypeId="1" AcceptedAnswerId="423" CreationDate="2019-06-12T21:42:16.557" Score="18" ViewCount="489" Body="&lt;p&gt;When solving a &lt;a href=&quot;https://en.wikipedia.org/wiki/Linear_programming&quot; rel=&quot;noreferrer&quot;&gt;Linear Optimization&lt;/a&gt; model (or Linear Program), there are a lot of solution approaches. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to name a few:    &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Primal Simplex   &lt;/li&gt;&#xA;&lt;li&gt;Dual Simplex     &lt;/li&gt;&#xA;&lt;li&gt;Ellipsoid Method (as if)    &lt;/li&gt;&#xA;&lt;li&gt;Interior Point Method&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;When should I use the Interior Point Method?&lt;/strong&gt;&lt;br&gt;&#xA; Is it just a matter of trial-and-error numerically or are there some indicators within a problem that point to preferred approaches?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that the default for many solvers is to automatically choose for you unless you specify.  &lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-18T04:18:17.677" LastActivityDate="2019-06-18T04:18:17.677" Title="Guidelines for Linear Optimization approaches?" Tags="|linear-programming|optimization|simplex|interior-point-method|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="422" PostTypeId="2" ParentId="419" CreationDate="2019-06-12T23:13:47.573" Score="10" Body="&lt;p&gt;To add to Marcus's answer: you can use a callback to prune parts of the tree when your external bound proves that this part of the tree does not contain an optimal solution, without affecting the branching order. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wouldn't explicitly impose an objective constraint/explicitly feed the bound to the solver, because if your relaxations at each node can't reproduce this bound then it inhibits accurate pseudocost estimation when branching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a blogpost which touches on some other issues regarding this here: &lt;a href=&quot;https://orinanobworld.blogspot.com/2013/05/a-priori-objective-bound.html&quot; rel=&quot;noreferrer&quot;&gt;https://orinanobworld.blogspot.com/2013/05/a-priori-objective-bound.html&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="43" LastActivityDate="2019-06-12T23:13:47.573" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="423" PostTypeId="2" ParentId="421" CreationDate="2019-06-13T06:03:58.037" Score="18" Body="&lt;p&gt;Let's start with the easy one:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Ellipsoid Method&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Never use it. Even though it might appear efficient in the complexity-theory sense, it performs terrible and suffers heavily from numerical issues.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Primal Simplex&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Mostly studied for historical interest, but there are some cases where it might outperform dual simplex (when the basis matrix in the primal revised simplex is of significantly lower dimension than in the dual revised simplex, I think). Worst case exponential time, but never happens in practice.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Dual Simplex&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Usually the default choice in modern Linear Programming Solvers. Can be warmstarted and hotstarted, easy to get feasibility, and preserves dual feasibility when tightening the primal LP (such as in a MILP environment). See &lt;a href=&quot;https://or.stackexchange.com/questions/282/when-should-i-use-dual-simplex-over-primal-simplex/283#283&quot;&gt;this&lt;/a&gt; question and answer for more details on this. Worst case exponential time, but extremely efficient in practice. Can efficiently exploit sparsity in the constraint matrix. One of the reasons dual simplex implementation outperform primal simplex is the &lt;a href=&quot;https://link.springer.com/content/pdf/10.1007/BF01581089.pdf&quot; rel=&quot;noreferrer&quot;&gt;Dual Steepest Edge&lt;/a&gt; technique, which apparently is not directly applicable to the primal algorithm. The availability of the bound flipping ratio test also adds to the superiority of the dual over the primal method.&lt;/p&gt;&#xA;&lt;p&gt;Both primal and dual simplex will produce a basic solution (at a vertex of the feasible region).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Interior Point Method&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Provable polynomial complexity. Often needs a preconditioner to perform extremely well. Can not really be warmstarted, so not much use in a MILP environment apart from solving the root node. Performs competitively when you don't know much about a problem (e.g. no warm/hotstart available). IPMs do not generally produce a basic solution (at a vertex of the feasible region).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Rule of thumb:&lt;/strong&gt; You're usually not terribly wrong by using dual revised simplex, especially if a warm- or hotstart is available. Occasionally it can be beneficial to use interior point methods, when you don't have a hotstart but maybe a decent preconditioner for the IPM system matrix.&lt;/p&gt;&#xA;&lt;p&gt;Example: Use IPM to solve the root node of a MIP, use Dual Simplex to solve the other nodes.&lt;/p&gt;&#xA;" OwnerUserId="47" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-06-17T18:51:57.290" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="424" PostTypeId="2" ParentId="375" CreationDate="2019-06-13T07:13:10.007" Score="7" Body="&lt;p&gt;Not a written document, but maybe interesting: an episode of the INFORMS podcast, &lt;a href=&quot;https://pubsonline.informs.org/do/10.1287/orms.2019.03.13p/full/&quot; rel=&quot;noreferrer&quot;&gt;Looking Back at the Origins of O.R.&lt;/a&gt; on &quot;the first time the term Operations Research was employed, and some of the earliest applications of O.R. during World War II&quot;.&lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2019-06-13T07:13:10.007" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="425" PostTypeId="5" CreationDate="2019-06-13T07:26:50.283" Score="0" Body="&lt;p&gt;In constrained optimization problems the feasible points are those &lt;a href=&quot;https://en.wikipedia.org/wiki/Feasible_region&quot; rel=&quot;nofollow noreferrer&quot;&gt;which satisfy all the constraints&lt;/a&gt;, and thus are &lt;em&gt;candidate solutions&lt;/em&gt; to a problem before evaluation of an objective function narrows down the possibilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the constraints are linear and the variables are continuous, then the feasible points will form a (not necessarily bounded) convex region. If in addition the objective function is linear and the feasible region is bounded, then the maximum and the minimum values of the objective function will be attained at a &lt;em&gt;vertex&lt;/em&gt; of the feasible region.  This is the geometric foundation of the &lt;em&gt;simplex method&lt;/em&gt; for solving a linear program. In practice the simplex method usually locates such feasible points efficiently, but rigorously proving &lt;a href=&quot;http://www-sop.inria.fr/members/Frederic.Havet/Cours/polyLP.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;the complexity of the linear feasibility problem is polynomial&lt;/a&gt; led to study of the Ellipsoid Method and the Interior Point Methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the constraints are linear and the variables are discrete (integer-valued), then deciding feasibility is generically difficult, and is &lt;a href=&quot;https://en.wikipedia.org/wiki/Integer_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;NP-complete&lt;/a&gt; even when variables are restricted to binary 0-1 choices.&lt;/p&gt;&#xA;" OwnerUserId="78" LastEditorUserId="123" LastEditDate="2019-12-08T19:40:52.447" LastActivityDate="2019-12-08T19:40:52.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="426" PostTypeId="4" CreationDate="2019-06-13T07:26:50.283" Score="0" Body="For questions specifically about existence (feasibility), counting feasible points (in a discrete setting), or partitioning the feasible region (e.g. in the context of branch-and-bound methods). Feasible points are those which satisfy all the constraints of a problem, and so can be defined without regard to any optimization criterion.  " OwnerUserId="78" LastEditorUserId="123" LastEditDate="2019-12-08T19:40:52.447" LastActivityDate="2019-12-08T19:40:52.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="427" PostTypeId="1" AcceptedAnswerId="428" CreationDate="2019-06-13T08:19:15.683" Score="16" ViewCount="518" Body="&lt;p&gt;Given a conic problem &lt;span class=&quot;math-container&quot;&gt;$$\min \{c^\top x \mid Ax \succeq_\mathit{C} b\}$$&lt;/span&gt; for an arbitrary cone &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, how can I construct the dual to the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover, in Linear Programming one constructs the dual with the intention of finding a valid (in fact the best) lower bound on &lt;span class=&quot;math-container&quot;&gt;$x^*=\min \{c^\top x \mid Ax \geq b\}$&lt;/span&gt;. Is there a similar intuition in the case of conic duality?&lt;/p&gt;&#xA;" OwnerUserId="81" LastEditorUserId="123" LastEditDate="2019-09-29T12:16:59.127" LastActivityDate="2019-09-29T12:18:54.163" Title="How to take the dual of a conic optimization problem?" Tags="|duality|conic-optimization|cone|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="428" PostTypeId="2" ParentId="427" CreationDate="2019-06-13T08:19:15.683" Score="13" Body="&lt;p&gt;In Linear Programming (LP) one chooses a vector &lt;span class=&quot;math-container&quot;&gt;$\lambda \geq 0$&lt;/span&gt; to obtain &lt;span class=&quot;math-container&quot;&gt;$\lambda^\top Ax \geq \lambda^\top b$&lt;/span&gt; and whenever we find such a &lt;span class=&quot;math-container&quot;&gt;$\lambda \geq 0$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$A^\top\lambda =c$&lt;/span&gt; we obtain a lower bound &lt;span class=&quot;math-container&quot;&gt;$b^\top \lambda$&lt;/span&gt; for our linear programming problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In conic programming we also search for vectors &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\lambda^\top Ax \geq \lambda^Tb$&lt;/span&gt; follows from the conic inequalities &lt;span class=&quot;math-container&quot;&gt;$Ax \succeq_C b$&lt;/span&gt;. However, the question arises which vectors &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; we can choose such that &lt;span class=&quot;math-container&quot;&gt;$\lambda^\top Ax \geq \lambda^\top b$&lt;/span&gt; follows from &lt;span class=&quot;math-container&quot;&gt;$Ax \succeq_C b$&lt;/span&gt;. In LP these were the vectors &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\lambda \geq 0$&lt;/span&gt;. In the conic case it turns out that the vectors &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; we are looking for are those from the polar cone &lt;span class=&quot;math-container&quot;&gt;$C^*$&lt;/span&gt;, which is defined as &lt;span class=&quot;math-container&quot;&gt;$$C^*:= \{\lambda \in \mathbb{R}^n: \lambda^\top x \geq 0\quad\forall x \in C\}. $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this we arrive at the following dual to our conic programme: &lt;span class=&quot;math-container&quot;&gt;$$\max \left\{b^\top \lambda \mid A^\top\lambda=c, \lambda \succeq_{C^*} 0\right\}.$$&lt;/span&gt;&#xA;The optimal dual value is a lower bound on the optimal value of the primal problem. However, one has to note that strong duality (i.e. both optimal values are equal to each other) only holds when both the primal and the dual problem are &lt;em&gt;strictly&lt;/em&gt; feasible, which is a difference to LP!&lt;/p&gt;&#xA;" OwnerUserId="81" LastEditorUserId="123" LastEditDate="2019-09-29T12:18:54.163" LastActivityDate="2019-09-29T12:18:54.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="429" PostTypeId="2" ParentId="421" CreationDate="2019-06-13T12:30:57.707" Score="9" Body="&lt;p&gt;Bob Bixby (as just one representative of many computational guys) talks regularly about progress in LP and MIP solving; for the 50th anniversary issue of &quot;Operations Research&quot; he wrote an article on history and progress in LP solving that also contains perspectives on different algorithms (&lt;a href=&quot;https://pdfs.semanticscholar.org/2e1f/f0ff876ae97fde2559031815295d61f16021.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;), his general message is: these algorithms became &lt;em&gt;vastly&lt;/em&gt; more powerful over the years, no matter which one is actually used; a related question is also on &lt;a href=&quot;https://math.stackexchange.com/questions/607059/simplex-algorithm-primal-or-dual&quot;&gt;SE&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="354" LastEditDate="2019-06-17T19:54:27.540" LastActivityDate="2019-06-17T19:54:27.540" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="430" PostTypeId="1" CreationDate="2019-06-13T13:38:51.887" Score="21" ViewCount="332" Body="&lt;p&gt;Does anyone know of any real-world examples in which supply chain contracts, of the type introduced by &lt;a href=&quot;https://doi.org/10.1287/mksc.1070.0336&quot; rel=&quot;noreferrer&quot;&gt;Pasternack (1985)&lt;/a&gt; and reviewed by &lt;a href=&quot;https://doi.org/10.1016/S0927-0507(03)11006-7&quot; rel=&quot;noreferrer&quot;&gt;Cachon (2003)&lt;/a&gt;, are actually used in practice? I'm talking about contracts formulated as Stackelberg games, with a transfer payment between the two players, and expected profit functions that are optimized to find the Nash equilibrium for both players. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only such case study that I know of is &lt;a href=&quot;https://doi.org/10.1287/inte.33.6.18.25187&quot; rel=&quot;noreferrer&quot;&gt;this Interfaces article&lt;/a&gt; about McGriff tire treading company. But I'm curious to find out about either other published case studies or anecdotal knowledge.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="56" LastEditDate="2019-06-28T12:29:14.407" LastActivityDate="2019-12-26T16:57:49.350" Title="Real-world examples of supply chain contracts?" Tags="|reference-request|supply-chain-contracts|stackelberg-games|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="431" PostTypeId="1" AcceptedAnswerId="433" CreationDate="2019-06-13T13:50:06.933" Score="10" ViewCount="214" Body="&lt;p&gt;&lt;sub&gt;Innocently &lt;a href=&quot;https://math.stackexchange.com/q/3260001/339790&quot;&gt;cross-posted&lt;/a&gt; at Mathematics SE&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I am developing a model that operates in the realm of mixed integer programming, although I am fairly unfamiliar with this area of mathematics at the moment. I am hoping to get some clarification on whether my idea can function within the contexts of integer programming. I will provide a picture to an article to help clarify my question. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the formulation below, the chi variable can be either 0 or 1 to indicate if the cell (i,j)  received herbicide treatment or not. I will try to frame the question in relation to this equation for the sake of being on the same page. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So... suppose that in addition to herbicide treatment there was an additional type of treatment that can be applied (for the sake of example suppose it's clearing the invasive species by hand). Whether treatment by herbicide or treatment by hand is chosen would be dependent on a number of various factors, but the new problem is such that you need to somehow incorporate the additional treatment measure into the formulation of equation (9). So do you think that the introduction of a second treatment variable (or perhaps some type of logical conditional treatment variable) would be feasible, or can mixed integer programming models only handle one type of control at a time? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gyU18.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gyU18.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="8" LastEditDate="2019-06-13T21:01:10.450" LastActivityDate="2019-06-13T21:01:10.450" Title="Conditional Controls in MIP Models" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="432" PostTypeId="2" ParentId="334" CreationDate="2019-06-13T13:52:42.857" Score="7" Body="&lt;p&gt;I only have first-hand experience of the government side, which limits my ability to compare, but since none of the other answers discuss that side of things it may be useful to have an answer from that perspective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Caveat: &quot;government&quot; is a large and complex beast with many different faces. My experience comes from working in a statistical agency; somebody working in military logistics, electoral districting, or urban planning may have wildly different experiences to mine, even though we're all &quot;government&quot;. I am speaking only for my own experience here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The biggest OR problem that I've worked on required reconciling conflicting data sources for economic data. Every economic transaction has a buyer and a seller; when you collect data from both buyer and seller sides, inevitably they don't tell quite the same story, even though theoretically they should be identical. Multiply that by hundreds of products, a hundred or so economic sectors, two different ways of valuing every transaction, and several years of history, and it ends up becoming quite a complex system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To cut a long story short, in terms of the OR problem, this boils down to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A quadratic continuous problem, with linear constraints. &lt;/li&gt;&#xA;&lt;li&gt;Some non-linear constraints which can be dealt with by constructing linear approximations, and iterating the QP a few times.&lt;/li&gt;&#xA;&lt;li&gt;A LIP stage required for controlled rounding (output integer values while maintaining additive consistency - avoid the problem of 0.3 + 0.3 + 0.4 = 1 rounding to 0 + 0 + 0 = 1.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All in all, I think we had about 100k variables with ~ 1m constraints, 80% of which get eliminated in presolve. Gurobi solves the iterated QP in about 60 seconds, and the LIP stage in a few minutes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I doubt the OR aspects of this problem would be remotely challenging to anybody who's done an OR-focussed degree, and much of this had already been done by statistical agencies overseas using similar methods on similar problems. (I think the implementation of non-linear constraints was novel within that particular context?) Most of the work for me and my team lay elsewhere, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Persuading my colleagues in our econometric team that an OR-based solution was a good idea. (Full credit to them: they were very supportive of this project and receptive to change, but it's not something they were familiar with, so I needed to show them what it could do.)&lt;/li&gt;&#xA;&lt;li&gt;Understanding the (quite complex) economic theory that underpins the problem. &lt;/li&gt;&#xA;&lt;li&gt;Compiling client requirements to identify the required constraints. (All up, there are about 100 constraint statements in the problem definition.)&lt;/li&gt;&#xA;&lt;li&gt;Distinguishing between hard constraints and soft constraints.&lt;/li&gt;&#xA;&lt;li&gt;Identifying constraints that would be inconvenient to implement as specified (&quot;this thing can't be negative three years running&quot;) and negotiating substitutes that were better suited to the optimisation framework (&quot;total for any three consecutive years can't be negative&quot;).&lt;/li&gt;&#xA;&lt;li&gt;Identifying constraints which weren't actually necessary, because they related to some aspect of the old process that no longer needed to be enforced.&lt;/li&gt;&#xA;&lt;li&gt;Identifying exceptions to the specified constraints (you can't &lt;em&gt;usually&lt;/em&gt; sell a negative value of something... except when you can).&lt;/li&gt;&#xA;&lt;li&gt;Talking to our overseas colleagues about the approaches they'd taken, to learn from their experiences and identify areas where we might be able to improve.&lt;/li&gt;&#xA;&lt;li&gt;Translating &quot;adjust this data for consistency, while making as little change as possible to the economic story&quot; into a cost function.&lt;/li&gt;&#xA;&lt;li&gt;Establishing a method for weighting that cost function that is intuitive for an economist without an OR background. &lt;/li&gt;&#xA;&lt;li&gt;Debugging various issues with the inputs, and establishing necessary quality checks for inputs.&lt;/li&gt;&#xA;&lt;li&gt;Checking the outputs and quantifying the effects of this method on the economic time series. (Economists really, really hate having to issue revisions to published economic data!)&lt;/li&gt;&#xA;&lt;li&gt;Developing diagnostics to answer questions like &quot;why did that value change so much?&quot;&lt;/li&gt;&#xA;&lt;li&gt;Training my clients and team members on how to use this system and how to debug things like infeasibility errors.&lt;/li&gt;&#xA;&lt;li&gt;Admin overhead: project management etc.&lt;/li&gt;&#xA;&lt;li&gt;Liaising with our IT department, first on obtaining OR software appropriate to the job, and and then on ensuring that the final product satisfies corporate IT policy.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I expect people in industry will find many of those issues familiar. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aside from that project, most of the OR that I've worked on has ended up being basic LIPs. Again, the tough part of the job is usually in establishing requirements and in liaising with other areas, not in the OR theory. We have a lot of problems that can benefit from an OR approach, but people often don't realise that OR can help them, so part of my work is in sniffing out opportunities to use these tools.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing that is a point of difference between us and (much of) industry is that we operate in a high-security IT environment that makes it slow to get access to new software. The input and output data are confidential, which prevents us from just sending big problems off to a cloud provider. When we have collaborated with people with industry/academic backgrounds, they've often found this quite frustrating - no, you can't just download your favourite software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possible point of difference is that my agency doesn't have permanent &quot;OR expert&quot; positions. Staff will rotate in and out of OR-related areas every few years, so we end up with a wide mix of experience but nobody gets to focus just on OR, and our knowledge tends to be more ad-hoc and pragmatically-oriented than you might expect from somebody who's done a degree in it. Likewise, most of us don't have formal OR training; I think one of my co-workers studied it in undergrad many years ago, I've done one course on Coursera, the rest has been largely on-the-job.&lt;/p&gt;&#xA;" OwnerUserId="546" LastActivityDate="2019-06-13T13:52:42.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="433" PostTypeId="2" ParentId="431" CreationDate="2019-06-13T14:56:48.967" Score="10" Body="&lt;p&gt;I believe you can have more than only one controller in your model, for example, let's assume that the indicator of your second treatment type is something like &lt;span class=&quot;math-container&quot;&gt;${Y}_{i,j,t}$&lt;/span&gt; and it's effective with the rate of &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; then you can rewrite your model as follow:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P^{k}_{ijt} = BP^{k}_{ijt}  (1-\Phi X_{ijt}-\epsilon Y_{ijt})$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{ijt} + Y_{ijt} \le 1$&lt;/span&gt; if only one treatment allowed in each time cycle&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{ijt} + Y_{ijt} \le 2$&lt;/span&gt; if more than one treatment allowed in each time cycle&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{ijt} \le Y_{ijt}$&lt;/span&gt; if second treatment depends on the first one&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{ijt} + Y_{ijt} \ge 1$&lt;/span&gt; if at least one treatment should be done in each time cycle&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope it answers your question.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="38" LastEditDate="2019-06-13T15:13:28.317" LastActivityDate="2019-06-13T15:13:28.317" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="434" PostTypeId="2" ParentId="419" CreationDate="2019-06-13T16:28:59.197" Score="29" Body="&lt;p&gt;Interesting topic (the question was raised several times by my students as well). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My short answer is that adding the lower bound through a cut seems a good idea at first glance, but it creates a very large “unnatural” face where your search is trapped for a long while. Essentially you lose the objective function grip, and do not gain anything. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me explain. Take a MILP,  and let LB be the lower bound at hand. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;ASSUMPTION: LB is not tight at the integer optimum  (otherwise, as already noticed, you have essentially a “feasibility problem” hence LB can indeed be &lt;em&gt;very useful&lt;/em&gt; to stop as soon as a heuristic found a solution with cost equal to LB). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ask you: what could be a &lt;em&gt;positive&lt;/em&gt; effect of adding the cut &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$(1)\quad  c x \ge LB$$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;to the original MILP model?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a generic node of the enumeration  tree, where some cuts have been possibly added and some variables have been fixed.  Solve the corresponding LP relaxation without (1) and consider its optimal value &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; (say). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$z &amp;gt; LB$&lt;/span&gt;, then (1) is slack and hence useless. If &lt;span class=&quot;math-container&quot;&gt;$z \le LB$&lt;/span&gt; the node lower bound would apparently improve (i.e. increase) going from &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; (without (1)) to LB (using (1)) but this is again useless as you will never prune this node because of lower bound due to the ASSUMPTION above. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In other words, (1) will never help pruning a node, which would be the main reason to use it. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Instead, the &lt;em&gt;negative&lt;/em&gt; effects of using (1) include (as already discussed):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A) huge dual degeneracy &lt;span class=&quot;math-container&quot;&gt;$\rightarrow$&lt;/span&gt; you zig-zag between tons of LP solutions with the same cost (=LB)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;B) blindness wrt the objective function at the root node and for many many other nodes &lt;span class=&quot;math-container&quot;&gt;$\rightarrow$&lt;/span&gt; you are wasting 50 years of clever ideas such as pseudo costs, best-bound search, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All in all, I would not expect any improvement when adding cut (1) to the MILP formulation—barring performance variability of course. &lt;/p&gt;&#xA;" OwnerUserId="429" LastEditorUserId="36" LastEditDate="2019-06-13T19:01:31.510" LastActivityDate="2019-06-13T19:01:31.510" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="435" PostTypeId="1" AcceptedAnswerId="436" CreationDate="2019-06-13T16:59:26.630" Score="11" ViewCount="396" Body="&lt;p&gt;I'm modeling a process time, &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, for a simulation study and have an &amp;quot;expert&amp;quot; estimate of the minimum, &lt;span class=&quot;math-container&quot;&gt;$\hat a$&lt;/span&gt;, the most likely (mode), &lt;span class=&quot;math-container&quot;&gt;$\hat m$&lt;/span&gt;, and the maximum, &lt;span class=&quot;math-container&quot;&gt;$\hat b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I'd prefer to avoid the possibly unrealistic use of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Triangular_distribution&quot; rel=&quot;nofollow noreferrer&quot;&gt;Triangular distribution&lt;/a&gt;, &lt;span class=&quot;math-container&quot;&gt;$X\sim \text{Tria}(a,m,b)$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$a=\hat a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$m = \hat m$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$b = \hat b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Q: How do I use this information to fit a Generalized Beta distribution to this?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The Generalized Beta distribution has the form of &lt;span class=&quot;math-container&quot;&gt;$a+(b-a)\,\text{Beta}(\alpha_1,\alpha_2)$&lt;/span&gt; with first shape parameter &lt;span class=&quot;math-container&quot;&gt;$\alpha_1$&lt;/span&gt; and second shape parameter &lt;span class=&quot;math-container&quot;&gt;$\alpha_2$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\text{Beta}(\alpha_1,\alpha_2)$&lt;/span&gt; is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Beta_distribution&quot; rel=&quot;nofollow noreferrer&quot;&gt;Beta distribution&lt;/a&gt; on the &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt; interval.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Update:&lt;br /&gt;&#xA;Due to concerns this is unrelated to OR, some context may be warranted to confirm it is.&lt;/p&gt;&#xA;&lt;p&gt;This situation arises frequently when conducting &lt;em&gt;input modeling&lt;/em&gt; for a &lt;strong&gt;Simulation&lt;/strong&gt; study and further data is unavailable or too expensive or troublesome to get. There are legitimate concerns over the Triangular distribution due to the &amp;quot;tails&amp;quot; and this approach provides a viable alternative that may better approximate reality in some applications.&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2023-02-09T17:44:39.477" LastActivityDate="2023-02-09T17:44:39.477" Title="How to fit a Beta distribution to three estimates from an &quot;expert&quot;?" Tags="|modeling|probability-distributions|simulation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="436" PostTypeId="2" ParentId="435" CreationDate="2019-06-13T16:59:26.630" Score="9" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$a = \hat a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b = \hat b$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Denote &lt;span class=&quot;math-container&quot;&gt;$r = \frac{\hat b - \hat m}{\hat m - \hat a}$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then choose the shape parameters to be&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\alpha_1 = \frac{4 + 3r + r^2}{1 + r^2}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\alpha_2 = \frac{1 + 3r + 4r^2}{1 + r^2}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will produce a Generalized Beta distribution with mode &lt;span class=&quot;math-container&quot;&gt;$m = \hat m$&lt;/span&gt; and a variance &lt;span class=&quot;math-container&quot;&gt;$\text{Var}(X) = \left(\frac{\hat b - \hat a}{6}\right)^2$&lt;/span&gt;. Then mean will be &lt;span class=&quot;math-container&quot;&gt;$\text{E}[X] = \mu = \frac{\alpha_1 b + \alpha_2 a}{\alpha_1 + \alpha_2}$&lt;/span&gt;. &lt;sup&gt;[1]&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice there is no assumption about how the mean depends on &lt;span class=&quot;math-container&quot;&gt;$\hat a, \hat m, \hat b$&lt;/span&gt; as would occur as in a common &lt;a href=&quot;https://en.wikipedia.org/wiki/Program_evaluation_and_review_technique&quot; rel=&quot;nofollow noreferrer&quot;&gt;PERT&lt;/a&gt; assumption &lt;span class=&quot;math-container&quot;&gt;$\mu = \frac{a + 4m + b}{6}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If there are concerns the &quot;expert&quot; estimates of &lt;span class=&quot;math-container&quot;&gt;$\hat a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\hat b$&lt;/span&gt; are the smallest and largest (respectively) values they've observed, then they aren't the true bounds since &lt;span class=&quot;math-container&quot;&gt;$P(X = x)=0$&lt;/span&gt; for continuous random variables. To address this concern, one can do a heuristic expansion.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if the expansion coefficient is 20% (&lt;span class=&quot;math-container&quot;&gt;$\theta = 0.20$&lt;/span&gt;), and the initial estimate range was &lt;span class=&quot;math-container&quot;&gt;$\hat \rho = \hat b - \hat a$&lt;/span&gt;, then the new estimated bounds are&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a = \hat a - \frac{\theta \hat \rho - \hat\rho}{2}$&lt;/span&gt;   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b = \hat b + \frac{\theta \hat \rho - \hat\rho}{2}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update: Someone rightly asked in the comments, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why constrain the standard deviation to be one-sixth of the range? The&#xA;  problem is under-determined, so there has to be some such constraint&#xA;  if it's to be solved at all, but why that one in particular?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is a good question. Since this Generalized Beta distribution has four parameters &lt;span class=&quot;math-container&quot;&gt;$(a,b,\alpha_1,\alpha_2)$&lt;/span&gt; and you are starting with &lt;span class=&quot;math-container&quot;&gt;$(\hat a, \hat m, \hat b)$&lt;/span&gt;, there are many, many (even infinitely many for our mathy friends) ways to get this done.  I believe the resulting variance &lt;span class=&quot;math-container&quot;&gt;$\text{Var}(X) = \left(\frac{\hat b - \hat a}{6}\right)^2$&lt;/span&gt; is baked into the results by way of the choices for &lt;span class=&quot;math-container&quot;&gt;$\alpha_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha_2$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to being an improvement over traditional &lt;a href=&quot;https://en.wikipedia.org/wiki/Program_evaluation_and_review_technique&quot; rel=&quot;nofollow noreferrer&quot;&gt;PERT&lt;/a&gt; assumptions, this approach is simple, easy to understand, and works well when there is limited data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll look into further reasoning for this constraint and hope to add some of the reasoning here. Until then, I refer interested parties to &lt;a href=&quot;https://link.springer.com/article/10.1057/jos.2009.31&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kuhl et al. (2010)&lt;/a&gt;.&lt;sup&gt;[1]&lt;/sup&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code Demonstrating the Formulas Are Correct:&lt;/strong&gt;    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% MATLAB R2018b&#xA;ahat = 4;&#xA;bhat = 24;&#xA;mhat = 12;&#xA;&#xA;a = ahat;&#xA;b = bhat;&#xA;r = (bhat - mhat)./(mhat - ahat);&#xA;alpha1 = (4 + 3.*r + r.^2)./(1 + r.^2);&#xA;alpha2 = (1 + 3.*r + 4*r.^2)./(1 + r.^2);&#xA;&#xA;% Simulation&#xA;NumSamples = 50000;&#xA;X = a + (b-a).*betarnd(alpha1,alpha2,NumSamples,1);&#xA;SimMean = mean(X)&#xA;SimVar = var(X)&#xA;&#xA;% Analytical &#xA;AnalyticalMean = (alpha1.*b + alpha2.*a)./(alpha1 + alpha2)&#xA;AnalyticalVar = ((b-a)./6).^2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;Reference:&lt;/sub&gt;&lt;br&gt;&#xA;&lt;sub&gt;[1] Kuhl, M., Ivy, J., Lada, E., Steiger, N., Wagner, M., &amp;amp; Wilson, J.  (2010).  &lt;a href=&quot;https://link.springer.com/article/10.1057/jos.2009.31&quot; rel=&quot;nofollow noreferrer&quot;&gt;Univariate inputmodels for stochastic simulation&lt;/a&gt;. &lt;em&gt;Journal of Simulation&lt;/em&gt;, Vol 4, No 2, 81–97.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-11-15T00:28:04.180" LastActivityDate="2019-11-15T00:28:04.180" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="437" PostTypeId="1" AcceptedAnswerId="453" CreationDate="2019-06-13T18:27:09.423" Score="13" ViewCount="565" Body="&lt;p&gt;There aren't many examples of reusable functionality shared as a result of research or commercial software development.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone come across any?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is one I just learned of:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/grid-parity-exchange/Egret&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/grid-parity-exchange/Egret&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="259" LastEditorUserId="199" LastEditDate="2020-06-14T05:34:56.570" LastActivityDate="2020-06-15T20:56:28.410" Title="Are there reusable formulations/heuristics shared with the community?" Tags="|software|" AnswerCount="7" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="438" PostTypeId="2" ParentId="437" CreationDate="2019-06-13T19:09:10.817" Score="8" Body="&lt;p&gt;This may be a related question: &lt;a href=&quot;https://or.stackexchange.com/questions/61/why-is-the-programming-code-of-many-algorithms-not-public-in-the-or-community&quot;&gt;Why is the programming code of many algorithms not public in the OR community?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A recent example I've liked is this large-scale location modeling paper by &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0377221718310737&quot; rel=&quot;noreferrer&quot;&gt;Cordeau, Furini and Ljubic, 2019&lt;/a&gt;. Here's their &lt;a href=&quot;https://github.com/fabiofurini/LocationCovering&quot; rel=&quot;noreferrer&quot;&gt;code&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="56" LastActivityDate="2019-06-13T19:09:10.817" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="439" PostTypeId="2" ParentId="189" CreationDate="2019-06-13T19:15:04.270" Score="7" Body="&lt;p&gt;Which advantages does each one (arXiv vs. OO) of them (and others if not included) provide?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arXiv site has more, and an extensive review process. It is &lt;a href=&quot;https://en.wikipedia.org/wiki/ArXiv#Controversy&quot; rel=&quot;nofollow noreferrer&quot;&gt;not without controversy&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Optimization Online site is supported by the Mathematical Optimization Society (MOS), an international organization dedicated to the promotion and the maintenance of high professional standards in the subject of mathematical optimization. While they check that the author's contact information is correct they do not usually evaluate the report for quality or mathematical correctness.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://arxiv.org/about&quot; rel=&quot;nofollow noreferrer&quot;&gt;arXiv&lt;/a&gt;&lt;/strong&gt; has almost 21,458 submissions about &lt;a href=&quot;https://arxiv.org/search/advanced?advanced=&amp;amp;terms-0-operator=AND&amp;amp;terms-0-term=%22math.OC%22&amp;amp;terms-0-field=all&amp;amp;classification-physics_archives=all&amp;amp;classification-include_cross_list=exclude&amp;amp;date-filter_by=all_dates&amp;amp;date-year=&amp;amp;date-from_date=&amp;amp;date-to_date=&amp;amp;date-date_type=submitted_date&amp;amp;abstracts=show&amp;amp;size=50&amp;amp;order=-announced_date_first&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimization and Control&lt;/a&gt; (the subject matter asked about by user David Bernal), it also has:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;19,273 (cs.AI) submissions about &lt;a href=&quot;https://arxiv.org/search/advanced?advanced=&amp;amp;terms-0-operator=AND&amp;amp;terms-0-term=%22cs.AI%22&amp;amp;terms-0-field=all&amp;amp;classification-physics_archives=all&amp;amp;classification-include_cross_list=exclude&amp;amp;date-filter_by=all_dates&amp;amp;date-year=&amp;amp;date-from_date=&amp;amp;date-to_date=&amp;amp;date-date_type=submitted_date&amp;amp;abstracts=show&amp;amp;size=50&amp;amp;order=-announced_date_first&quot; rel=&quot;nofollow noreferrer&quot;&gt;Artificial Intelligence&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;35,467 (cs.LG) submissions and 27,088 (stat.ML) submission about &lt;a href=&quot;https://arxiv.org/search/advanced?advanced=&amp;amp;terms-0-operator=AND&amp;amp;terms-0-term=%22cs.LG%22&amp;amp;terms-0-field=all&amp;amp;classification-physics_archives=all&amp;amp;classification-include_cross_list=exclude&amp;amp;date-filter_by=all_dates&amp;amp;date-year=&amp;amp;date-from_date=&amp;amp;date-to_date=&amp;amp;date-date_type=submitted_date&amp;amp;abstracts=show&amp;amp;size=50&amp;amp;order=-announced_date_first&quot; rel=&quot;nofollow noreferrer&quot;&gt;Machine Learning&lt;/a&gt; (some overlap)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;23,670 (stats.*) submissions &lt;a href=&quot;https://arxiv.org/search/advanced?advanced=&amp;amp;terms-0-operator=AND&amp;amp;terms-0-field=all&amp;amp;classification-physics_archives=all&amp;amp;classification-statistics=y&amp;amp;classification-include_cross_list=exclude&amp;amp;date-filter_by=all_dates&amp;amp;date-year=&amp;amp;date-from_date=&amp;amp;date-to_date=&amp;amp;date-date_type=submitted_date&amp;amp;abstracts=show&amp;amp;size=50&amp;amp;order=-announced_date_first&quot; rel=&quot;nofollow noreferrer&quot;&gt;total&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/help/moderation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Policy&lt;/a&gt; (partial quote):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Why does arXiv moderate submissions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;arXiv is an openly accessible, moderated repository for scholarly papers in specific scientific disciplines. Material submitted to arXiv is expected to be of interest, relevance, and value to those disciplines. arXiv reserves the right to reject or reclassify any submission.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;arXiv policies that could lead to the removal of a submission are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Unrefereeable content. arXiv only accepts submissions in the form of an article that would be refereeable by a conventional publication venue. Papers that do not contain original or substantive research, including undergraduate research, course projects, and research proposals, news, or information about political causes (even those with potential special interest to the academic community) may be removed. Papers that contain inflammatory or fictitious content, papers that use highly dramatic and misrepresentative titles/abstracts/introductions, or papers in need of significant review and revision may be removed. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Rights to submit material. Submissions to arXiv must be the author’s original work, and users must have the right to grant the rights contained in the selected license. Users must ensure the submission does not, to the best of their knowledge, infringe upon anyone's copyright. Users should not submit comments by referees. Users should not submit plagiarized material.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Excessive submission rate. Articles submitted to arXiv must be of refereeable quality, and there is a practical limit to the rate at which appropriate, independent submissions can be produced by any one person. Moderators may request that a particular author limit their submission rate if this author has a history of many submissions to inappropriate areas or of doubtful refereeability.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Who are arXiv moderators?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;arXiv moderators are volunteers who are experts in their fields and in the types of submissions that are appropriate for their subject classifications. They evaluate based on the content of the submission and the policies of arXiv. Moderators consider the submissions to arXiv as privileged information, as they would with a paper being refereed for a journal.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/moderators&quot; rel=&quot;nofollow noreferrer&quot;&gt;arXiv moderators&lt;/a&gt; are approved by their discipline-level &lt;a href=&quot;https://arxiv.org/help/scientific_ad_board#advisory_committees&quot; rel=&quot;nofollow noreferrer&quot;&gt;advisory committees&lt;/a&gt; and by arXiv staff. In addition, arXiv has links at the bottom of each paper which say &quot;Which authors of this paper are endorsers?&quot;. That link has a link to: &quot;&lt;a href=&quot;https://arxiv.org/help/not-registered&quot; rel=&quot;nofollow noreferrer&quot;&gt;Why isn't a Person 'Registered as an Author?'&lt;/a&gt;&quot; and &quot;&lt;a href=&quot;https://arxiv.org/help/endorsement&quot; rel=&quot;nofollow noreferrer&quot;&gt;The arXiv endorsement system&lt;/a&gt;&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Why does arXiv require endorsement?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;arXiv is distinct from the web as a whole, because arXiv contains exclusively scientific content. The endorsement system verifies that arXiv contributors belong to the scientific community in a fair and sustainable way that can scale with arXiv's future growth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;arXiv is an openly accessible, moderated repository for scholarly papers in specific scientific disciplines. Material submitted to arXiv is expected to be of interest, relevance, and value to those disciplines. Endorsement is a necessary but not sufficient condition to have papers accepted in arXiv; arXiv reserves the right to reject or reclassify any submission.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The endorsement system ensures that arXiv content is relevant to current research at much lower cost than conventional peer-reviewed journals, so we can continue to offer free access to the scientific community and the general public. Although our system may be imperfect, people who fail to get endorsement are still free to post articles on their (own) web site or to submit their publications to (other) peer-reviewed journals.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.elsevier.com/about/this-is-elsevier&quot; rel=&quot;nofollow noreferrer&quot;&gt;Elsevier&lt;/a&gt; - Elsevier has 140 years of experience in curation and verification. 75,382 editorial board members and more than 20,000 editors in academia and over 1.3m reviewers covering hundreds of disciplines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.elsevier.com/journals/discrete-applied-mathematics/0166-218x/guide-for-authors&quot; rel=&quot;nofollow noreferrer&quot;&gt;Submission Guidelines&lt;/a&gt; and &lt;a href=&quot;https://www.elsevier.com/physical-sciences-and-engineering/mathematics/journals&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quality Statement&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Elsevier receives over 40,000 annual submissions to our mathematical sciences journals. Of these, more than  10,000 articles are accepted for publication, resulting in an average acceptance rate of 25%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We provide full text to frequently used mathematics services like MathSciNet®, ZentralBlatt, and NUMDAM. We link and produce metadata which is shared with the major abstracting and indexing services, and we improve search engine optimization, so that your research can be easily found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Their &quot;&lt;a href=&quot;https://www.elsevier.com/catalog?producttype=journals&amp;amp;cat0=27384&amp;amp;cat1=&amp;amp;sort=datedesc&quot; rel=&quot;nofollow noreferrer&quot;&gt;Decision Science&lt;/a&gt;&quot; category indexes the following Operations Research journals, and other journals of publications related to Operations Research:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Subject &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Title&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Control_engineering&quot; rel=&quot;nofollow noreferrer&quot;&gt;Control Engineering&lt;/a&gt; - &lt;a href=&quot;https://www.journals.elsevier.com/automatica&quot; rel=&quot;nofollow noreferrer&quot;&gt;Automatica&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.igi-global.com/dictionary/analytics-for-nonprofits/39434&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR/MS&lt;/a&gt; - &lt;a href=&quot;https://www.journals.elsevier.com/computers-and-operations-research&quot; rel=&quot;nofollow noreferrer&quot;&gt;Computers &amp;amp; Operations Research&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.sciencedirect.com/journal/decision-support-systems/about/aims-and-scope&quot; rel=&quot;nofollow noreferrer&quot;&gt;Decision Support Systems&lt;/a&gt; - &lt;a href=&quot;https://www.sciencedirect.com/journal/decision-support-systems&quot; rel=&quot;nofollow noreferrer&quot;&gt;Decision Support Systems and Electronic Commerce&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Applied_mathematics&quot; rel=&quot;nofollow noreferrer&quot;&gt;Applied&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Discrete_mathematics&quot; rel=&quot;nofollow noreferrer&quot;&gt;Discreet Mathematics&lt;/a&gt; - &lt;a href=&quot;https://www.journals.elsevier.com/discrete-applied-mathematics&quot; rel=&quot;nofollow noreferrer&quot;&gt;Discrete Applied Mathematics&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Operations_research&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR&lt;/a&gt; - &lt;a href=&quot;https://www.journals.elsevier.com/european-journal-of-operational-research&quot; rel=&quot;nofollow noreferrer&quot;&gt;European Journal of Operational Research&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Game_theory&quot; rel=&quot;nofollow noreferrer&quot;&gt;Game Theory&lt;/a&gt; - &lt;a href=&quot;https://www.journals.elsevier.com/games-and-economic-behavior&quot; rel=&quot;nofollow noreferrer&quot;&gt;Games and Economic Behavior&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Forecasting&quot; rel=&quot;nofollow noreferrer&quot;&gt;Forecasting&lt;/a&gt; - &lt;a href=&quot;https://www.journals.elsevier.com/international-journal-of-forecasting&quot; rel=&quot;nofollow noreferrer&quot;&gt;International Journal of Forecasting&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;[More next edit] &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Journals &lt;strong&gt;touching on&lt;/strong&gt; Operations Research:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.journals.elsevier.com/engineering-applications-of-artificial-intelligence&quot; rel=&quot;nofollow noreferrer&quot;&gt;Engineering Applications of Artificial Intelligence&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.journals.elsevier.com/fuzzy-sets-and-systems&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fuzzy Sets and Systems&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Pay to Publish (any discipline, including OR) - &lt;a href=&quot;https://www.journals.elsevier.com/heliyon&quot; rel=&quot;nofollow noreferrer&quot;&gt;Heliyon&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.journals.elsevier.com/international-journal-of-information-management&quot; rel=&quot;nofollow noreferrer&quot;&gt;International Journal of Information Management&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;a href=&quot;https://www.cors.ca/?q=content/infor&quot; rel=&quot;nofollow noreferrer&quot;&gt;Canadian Operations Research Society&lt;/a&gt; publishes &lt;strong&gt;&lt;a href=&quot;https://www.tandfonline.com/loi/tinf20&quot; rel=&quot;nofollow noreferrer&quot;&gt;INFOR&lt;/a&gt;&lt;/strong&gt;, the &quot;Information Systems and Operational Research&quot; journal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The INFORS journal has partial open access, and a helpful &lt;a href=&quot;https://authorservices.taylorandfrancis.com/frequently-asked-questions/&quot; rel=&quot;nofollow noreferrer&quot;&gt;FAQ webpage&lt;/a&gt; for people wanting information about how to get published and &lt;a href=&quot;https://authorservices.taylorandfrancis.com/category/choosing-a-journal/&quot; rel=&quot;nofollow noreferrer&quot;&gt;choosing a journal&lt;/a&gt;. There are few articles, searching for &quot;&lt;a href=&quot;https://www.tandfonline.com/action/doSearch?field1=AllField&amp;amp;text1=Optimization&amp;amp;SeriesKey=tinf20&quot; rel=&quot;nofollow noreferrer&quot;&gt;optimization&lt;/a&gt;&quot; returns 654 results, 10 per page. There are only the simplest of search options, and using Google for the same search, &quot;&lt;a href=&quot;https://www.google.com/search?ei=TYgCXaDeO6-Ak-4PucmIkAY&amp;amp;q=site%3Ahttps%3A%2F%2Fwww.tandfonline.com%2Ftoc%2Ftinf20%20%22optimization%22&amp;amp;oq=site%3Ahttps%3A%2F%2Fwww.tandfonline.com%2Ftoc%2Ftinf20%20%22optimization%22&quot; rel=&quot;nofollow noreferrer&quot;&gt;optimization&lt;/a&gt;&quot;, produces 262 results; so there's no way around their search engine's interface with another tool to obtain more results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.tandfonline.com/action/journalInformation?journalCode=tinf20&quot; rel=&quot;nofollow noreferrer&quot;&gt;Policy&lt;/a&gt;: &quot;Canadian Operational Research Society (CORS) and our publisher Taylor &amp;amp; Francis make every effort to ensure the accuracy of all the information (the &quot;Content&quot;) contained in our publications. However, Canadian Operational Research Society (CORS) and our publisher Taylor &amp;amp; Francis, our agents, and our licensors make no representations or warranties whatsoever as to the accuracy, completeness, or suitability for any purpose of the Content. Any opinions and views expressed in this publication are the opinions and views of the authors, and are not the views of or endorsed by Canadian Operational Research Society (CORS) and our publisher Taylor &amp;amp; Francis. The accuracy of the Content should not be relied upon and should be independently verified with primary sources of information.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.netlib.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Netlib Repository&lt;/a&gt;&lt;/strong&gt; has 62 results for &quot;&lt;a href=&quot;http://www.netlib.org/cgi-bin/search.pl&quot; rel=&quot;nofollow noreferrer&quot;&gt;optimization&lt;/a&gt;&quot; and while I wouldn't call it a &quot;manuscript repository&quot; it certainly is a repository of source code often referred to in (and developed by authors of) various papers. See the &lt;a href=&quot;http://www.netlib.org/master/expanded_liblist.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Master Index&lt;/a&gt; for more information. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Their &quot;&lt;a href=&quot;http://www.netlib.org/bib/gams.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Guide to Available Mathematical Software&lt;/a&gt;&quot; (GAMS) is a cross-index and virtual repository of mathematical and statistical software components of use in computational science and engineering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Netlib has a respectable &lt;a href=&quot;http://www.netlib.org/editors.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;list of editors and administrators&lt;/a&gt; but their exact criteria for publication isn't easy to find.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.optimization-online.org/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimization Online&lt;/a&gt;&lt;/strong&gt; has almost &lt;a href=&quot;http://www.optimization-online.org/cgi-bin/search.cgi&quot; rel=&quot;nofollow noreferrer&quot;&gt;7000&lt;/a&gt; submissions about optimization and related topics.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.optimization-online.org/policy.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Policy&lt;/a&gt;: &quot;Papers are screened to ensure their relevance by one of the coordinators for the category selected by the submitting author as the principal category. The acceptance/rejection decision of a coordinator is final. Coordinators check that the submission details given by the authors are all present and correct and that the submitted files are readable. They do not usually evaluate the report for quality or mathematical correctness. Consequently, we make no claim about quality or correctness of the reports on the site. Optimization Online reserves the right in its sole discretion to remove accepted papers from the repository if complaints are received regarding their accuracy or authenticity.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://vixra.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;viXra&lt;/a&gt;&lt;/strong&gt; - Not to be confused with &lt;a href=&quot;https://en.wikipedia.org/wiki/ArXiv#Controversy&quot; rel=&quot;nofollow noreferrer&quot;&gt;arXiv&lt;/a&gt;, it accepts submissions &lt;a href=&quot;https://en.wikipedia.org/wiki/ViXra&quot; rel=&quot;nofollow noreferrer&quot;&gt;without requiring&lt;/a&gt; authors to have an academic affiliation and without any threshold for quality.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;[Note: I believe that this answers the question, as-is, but I will return to add more in the days ahead; as time permits.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclaimer: Short quotes are almost all the information that is provided on their website, the lengthy quote (for arXiv) is considerably less than complete. See links for more info.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-06-16T05:06:31.030" LastActivityDate="2019-06-16T05:06:31.030" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="440" PostTypeId="5" CreationDate="2019-06-13T20:35:26.713" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-13T20:35:26.713" LastActivityDate="2019-06-13T20:35:26.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="441" PostTypeId="4" CreationDate="2019-06-13T20:35:26.713" Score="0" Body="Usage deprecated per Meta" OwnerUserId="214" LastEditorUserId="214" LastEditDate="2019-06-13T23:44:32.320" LastActivityDate="2019-06-13T23:44:32.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="442" PostTypeId="2" ParentId="437" CreationDate="2019-06-13T20:53:55.633" Score="6" Body="&lt;p&gt;For biased random-key genetic algorithms (BRKGA) there is &lt;a href=&quot;https://doi.org/10.1080/10556788.2014.890197&quot; rel=&quot;noreferrer&quot;&gt;a paper of Toso &amp;amp; Resende&lt;/a&gt; and &lt;a href=&quot;http://mauricio.resende.info/src/brkgaAPI&quot; rel=&quot;noreferrer&quot;&gt;accompanying software&lt;/a&gt;. In a BRKGA the solution is represented as vector &lt;span class=&quot;math-container&quot;&gt;$v\in\mathbb{R}^n$&lt;/span&gt; of real &quot;keys&quot; and all you have to do is to provide a &quot;decoder&quot; that maps &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; to a solution and computes its fitness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bit dated, but still useful is the chapter on &lt;a href=&quot;https://doi.org/10.1007/0-306-48056-5_18&quot; rel=&quot;noreferrer&quot;&gt;Metaheuristic Class Libraries&lt;/a&gt; in the &lt;a href=&quot;https://dx.doi.org/10.1007/b101874&quot; rel=&quot;noreferrer&quot;&gt;Handbook of Metaheuristics&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-13T21:04:41.260" LastActivityDate="2019-06-13T21:04:41.260" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="443" PostTypeId="1" AcceptedAnswerId="505" CreationDate="2019-06-13T21:34:09.023" Score="32" ViewCount="1783" Body="&lt;p&gt;Suppose we want to enforce a constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y=\lfloor{x}\rfloor&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is some continuous variable. One option is to use&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x-1\leq{y}\leq{x},\quad y\in\mathbb{Z},&#xA;$$&lt;/span&gt;&#xA;which fails on the edge case &lt;span class=&quot;math-container&quot;&gt;$x\in\mathbb{Z}$&lt;/span&gt;. One way around this which works approximately is to introduce some tolerance &lt;span class=&quot;math-container&quot;&gt;$\varepsilon&amp;gt;0$&lt;/span&gt; and enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x-1+\varepsilon\leq{y}\leq{x},\quad y\in\mathbb{Z},&#xA;$$&lt;/span&gt;&#xA;which fails if &lt;span class=&quot;math-container&quot;&gt;$x\in(\lceil{x}\rceil-\varepsilon,\lceil{x}\rceil)$&lt;/span&gt;. Is there an exact way to enforce a floor function, perhaps by introducing additional integer variables?&lt;/p&gt;&#xA;" OwnerUserId="358" LastEditorUserId="500" LastEditDate="2019-06-17T20:14:41.820" LastActivityDate="2020-01-25T10:29:24.203" Title="Modeling floor function exactly" Tags="|mixed-integer-programming|modeling|linearization|" AnswerCount="8" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="444" PostTypeId="2" ParentId="61" CreationDate="2019-06-13T22:32:24.637" Score="11" Body="&lt;p&gt;I think the five answers (up to now) give a representative sample of the different reasons for not publishing code in the OR community. That answers your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To provoke a bit, I would say most of them are invalid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an exercise, it helps to read LeVeque's &lt;a href=&quot;https://sinews.siam.org/Details-Page/top-ten-reasons-to-not-share-your-code-and-why-you-should-anyway&quot; rel=&quot;noreferrer&quot;&gt;Top Ten Reasons To Not Share Your Code (and why you should anyway)&lt;/a&gt; and imagine mathematicians defending not publishing proofs with similar arguments. Quoting from the article:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The proof is too ugly to show someone else&lt;/li&gt;&#xA;&lt;li&gt;I didn't work out all the details&lt;/li&gt;&#xA;&lt;li&gt;I didn't actually prove the theorem, my student did&lt;/li&gt;&#xA;&lt;li&gt;Giving the proof to my competitors would be unfair to me&lt;/li&gt;&#xA;&lt;li&gt;The proof is valuable intellectual property&lt;/li&gt;&#xA;&lt;li&gt;Including proofs would make maths papers much longer&lt;/li&gt;&#xA;&lt;li&gt;Referees would never agree to check proofs&lt;/li&gt;&#xA;&lt;li&gt;The proof uses sophisticated mathematical machinery that most readers/referees don't know&lt;/li&gt;&#xA;&lt;li&gt;My proof invokes other theorems with unpublished (proprietary) proofs&lt;/li&gt;&#xA;&lt;li&gt;Readers who have access to my proof will want user support&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="87" LastActivityDate="2019-06-13T22:32:24.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="447" PostTypeId="1" CreationDate="2019-06-14T00:23:46.660" Score="5" ViewCount="432" Body="&lt;p&gt;For a side project, I'm looking to install COIN-OR project solvers on a Microsoft Azure Ubuntu VM.  (I will be running Pyomo optimization models on this VM as well; using NEOS isn't cutting it.)  Anybody have any experience in installing these solvers on Unix-like machines?  Any advice?  Right now my plan is to google and indiscriminately copy-paste command line statements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Progress thus far is crossposted to &lt;a href=&quot;https://stackoverflow.com/questions/56618861/solver-did-not-exit-normally-jupyter-python3-ubuntu&quot;&gt;https://stackoverflow.com/questions/56618861/solver-did-not-exit-normally-jupyter-python3-ubuntu&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="267" LastEditDate="2019-06-22T13:47:25.750" LastActivityDate="2019-06-22T13:47:25.750" Title="Installing COIN-OR solvers in Ubuntu (Azure)" Tags="|pyomo|coin-or|" AnswerCount="2" CommentCount="18" ContentLicense="CC BY-SA 4.0" />
  <row Id="448" PostTypeId="2" ParentId="357" CreationDate="2019-06-14T04:18:37.473" Score="14" Body="&lt;p&gt;&lt;a href=&quot;https://www.informs.org/Explore/History-of-O.R.-Excellence/Biographical-Profiles/Hillier-Frederick-S&quot; rel=&quot;noreferrer&quot;&gt;Frederick Hillier&lt;/a&gt; and &lt;a href=&quot;http://faculty.washington.edu/mhillier/biography.htm&quot; rel=&quot;noreferrer&quot;&gt;Mark Hillier&lt;/a&gt;, known for their &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/B003ZM0SES&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR textbook&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="253" LastActivityDate="2019-06-14T04:18:37.473" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="449" PostTypeId="2" ParentId="61" CreationDate="2019-06-14T04:39:38.003" Score="8" Body="&lt;p&gt;In my point of view, the main reasons that people overlook sharing their codes are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;It is really time-consuming and challenging to get a good-quality code. It might take the same amount of time to clean up the code compared to the time that you originally spent on it. You may see inconsistencies in results after cleaning it and many other troubles.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The community gives almost &lt;em&gt;zero credit&lt;/em&gt; for your code. For example, a special value can be provided for your paper, if you submit the code. Or, the journals might publish the codes on their websites. It can have a value toward getting tenure, etc.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I also want to mention that this issue is not specific to our community. AI/ML people have the same concerns since not too many people still open-source their codes. Here is a talk from NIPS 2017, which discusses the reproducibility issues: &lt;a href=&quot;https://aitube.io/video/38-min-joelle-pineau-reproducibility-deep-reinforcement-learning-nips2017/&quot; rel=&quot;noreferrer&quot;&gt;https://aitube.io/video/38-min-joelle-pineau-reproducibility-deep-reinforcement-learning-nips2017/&lt;/a&gt;&#xA;At the end of this video, the author of AlphaGo argues that it will require about a year for them to clean up their code and release it. The discussions are still going on in their community...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I would like to share my experience of open-sourcing the code for one of my paper: &lt;a href=&quot;https://github.com/OptMLGroup/VRP-RL&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/OptMLGroup/VRP-RL&lt;/a&gt;&#xA;It took almost 1 month for cleaning the code, but after publicizing the code, I got very positive feedback from both optimization and computer science communities. 87 unique visitors within the last 6 month and ~30 daily repo visits show that people are learning from my code. 28 people have ''forked'', which means that these people can continue their research from the point that I stopped. I strongly believe that open-sourcing is one of the best ways to distribute your work, and I will continue to do afterward.&lt;/p&gt;&#xA;" OwnerUserId="557" LastActivityDate="2019-06-14T04:39:38.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="450" PostTypeId="2" ParentId="377" CreationDate="2019-06-14T05:28:17.853" Score="4" Body="&lt;p&gt;Kjetil's answer is very good, and the distinction between errors and innovations are important to understand. But there are also applications where measurement issues do result in MA-type errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, statistical time series are often collected from a rotating sample panel. In something like an employment survey, households might be selected for the sample for eight months at a time; each month data on employment status is collected from those households, then one-eighth of the sample is &quot;rotated out&quot; and replaced by newly-selected households.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This approach gives both operational advantages (it's more trouble to recruit a new household than to re-interview one that you've already contacted) and statistical advantages (greatly reduces the effects of sample churn on month-to-month movements, improving ability to detect real changes). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also results in MA(8) behaviour: if you select an unusual group of households in one month, then those households will affect the time series for eight months before suddenly disappearing from the time series. Many economic time series are subject to similar phenomena that can cause MA-type behaviour.&lt;/p&gt;&#xA;" OwnerUserId="546" LastActivityDate="2019-06-14T05:28:17.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="451" PostTypeId="2" ParentId="443" CreationDate="2019-06-14T05:36:54.217" Score="3" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x-1 &amp;lt;y \leq x \implies y \leq x &amp;lt; y+1\implies 0\leq x-y  &amp;lt;1$&lt;/span&gt;. We then can set &lt;span class=&quot;math-container&quot;&gt;$y\in \mathbb {Z} $&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="386" LastEditorUserId="123" LastEditDate="2019-10-14T09:45:03.927" LastActivityDate="2019-10-14T09:45:03.927" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="452" PostTypeId="1" CreationDate="2019-06-14T06:54:51.517" Score="14" ViewCount="150" Body="&lt;p&gt;If you have strategic planning problems like hub location problems, the input data often consists of average values for shipping volumes etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When planning capacities, it is risky to ignore the distribution of the input data (if your hub is large enough for average capacities, you may get huge problems when volumes are higher). On the other hand, the distribution is not known.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it make sense to derive a &quot;most likely&quot; distribution by methods like &lt;a href=&quot;https://en.wikipedia.org/wiki/Principle_of_maximum_entropy&quot; rel=&quot;noreferrer&quot;&gt;entropy maximization&lt;/a&gt;? &lt;/p&gt;&#xA;" OwnerUserId="50" LastEditorUserId="38" LastEditDate="2019-06-17T02:58:23.223" LastActivityDate="2019-06-28T17:31:37.157" Title="Strategic planning based on average values" Tags="|optimization|strategic-planning|data|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="453" PostTypeId="2" ParentId="437" CreationDate="2019-06-14T07:47:25.107" Score="12" Body="&lt;p&gt;I try to publish all my O.R. code on my GitHub page.&#xA;There are both exact and heuristic algorithms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am learning about better coding practices every day, so there is no guarantee that code I published 1-4 years ago is  of acceptable quality (for my standards of today and even less for my future standards), but perhaps it is better than nothing!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Frameworks&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/as&quot; rel=&quot;nofollow noreferrer&quot;&gt;as&lt;/a&gt;&lt;/strong&gt;: this is my general-purpose C++ library with a few goodies for operational research.&#xA;For example, &lt;a href=&quot;https://github.com/alberto-santini/as/blob/master/src/tsplib.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;a class&lt;/a&gt; to parse TSPLIB and derived instances (such as for the &lt;a href=&quot;https://github.com/alberto-santini/as/blob/master/src/oplib.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;orienteering problem&lt;/a&gt;);&#xA;&lt;a href=&quot;https://github.com/alberto-santini/as/blob/master/src/tsp.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;one&lt;/a&gt; to solve TSP problems calling either Concorde or a simple MTZ model;&#xA;a &lt;a href=&quot;https://github.com/alberto-santini/as/blob/master/src/alns.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;simple implementation&lt;/a&gt; of the Adaptive large Neighbourhood Search (ALNS) metaheuristic;&#xA;utilities to &lt;a href=&quot;https://github.com/alberto-santini/as/blob/master/src/graph.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;work&lt;/a&gt; with and &lt;a href=&quot;https://github.com/alberto-santini/as/blob/master/src/graph_plot.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;plot&lt;/a&gt; graphs, which can be used e.g. to visualise routes in routing problems;&#xA;tools for solving the &lt;a href=&quot;https://github.com/alberto-santini/as/blob/master/src/mwis.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;maximum weighted independent set&lt;/a&gt; and the &lt;a href=&quot;https://github.com/alberto-santini/as/blob/master/src/max_clique.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;max-clique&lt;/a&gt; problems, using respectively the &lt;code&gt;exactcolors&lt;/code&gt; and the &lt;code&gt;pmc&lt;/code&gt; libraries, which are also available online &lt;a href=&quot;https://github.com/heldstephan/exactcolors&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://github.com/ryanrossi/pmc&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/adaptive-large-neighbourhood-search&quot; rel=&quot;nofollow noreferrer&quot;&gt;adaptive-large-neighbourhood-search&lt;/a&gt;&lt;/strong&gt;: as the name suggests, it is a C++ framework to implement ALNS heuristics.&#xA;There is also a &lt;a href=&quot;https://github.com/alberto-santini/hybrid-alns&quot; rel=&quot;nofollow noreferrer&quot;&gt;version of ALNS hybridised with Tabu Search&lt;/a&gt; to solve flat-landscape problems.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/biased-random-key-ga&quot; rel=&quot;nofollow noreferrer&quot;&gt;biased-random-key-ga&lt;/a&gt;&lt;/strong&gt;: a C++ implementation of the BRKGA framework, with an example application to the TSP.&#xA;I also have a &lt;a href=&quot;https://github.com/alberto-santini/biased-rkga-comparison&quot; rel=&quot;nofollow noreferrer&quot;&gt;Java implementation&lt;/a&gt; of the same framework; in the beginning I implemented it to do some experimentation, but in the end I think it is modular enough that it can be used as a framework.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/simple-ga-cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;simple-ga-cpp&lt;/a&gt;&lt;/strong&gt;: a toy, but working, C++ implementation of a Genetic Algorithm framework.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solvers&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/covid-optimisation&quot; rel=&quot;nofollow noreferrer&quot;&gt;covid-optimisation&lt;/a&gt;&lt;/strong&gt;: a solver for a model used to maximise swab testing capacity during a viral epidemics. It contains a model implemented with Gurobi's C++ interface. More details in &lt;a href=&quot;https://santini.in/files/papers/santini-2020.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;the paper&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A solver for the &lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/ptspc&quot; rel=&quot;nofollow noreferrer&quot;&gt;PTSPC&lt;/a&gt;&lt;/strong&gt;, aka the Probabilistic Travelling Salesman Problem with Crowdsourcing. A part from the full-enumeration solver (exact but super-slow), there is the implementation of a machine-learning-guided heuristic search. Full details &lt;a href=&quot;https://santini.in/files/papers/santini-viana-klimentova-pedroso-2020.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/crop-growth-scheduling-vf&quot; rel=&quot;nofollow noreferrer&quot;&gt;crop-growth-scheduling&lt;/a&gt;&lt;/strong&gt; realistic instances for &lt;a href=&quot;https://santini.in/files/papers/santini-schneider-greco-2020.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this formulation&lt;/a&gt; of a problem arising in Vertical Farming.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/tsp_bc&quot; rel=&quot;nofollow noreferrer&quot;&gt;tsp_bc&lt;/a&gt;&lt;/strong&gt;: is a work-in-progress branch &amp;amp; cut solver for the TSP. It's not going to be state-of-the-art; just a quick experiment to give a more data-driven answer to &lt;a href=&quot;https://or.stackexchange.com/questions/139/subtour-elimination-constraints-enumeration-vs-dynamically-adding&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/selective-graph-colouring&quot; rel=&quot;nofollow noreferrer&quot;&gt;selective-graph-colouring&lt;/a&gt;&lt;/strong&gt;: mainly a branch &amp;amp; price solver for the Selective Graph Colouring Problem (SGCP). You can have a look at the &lt;a href=&quot;https://santini.in/files/papers/furini-malaguti-santini-2017.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;corresponding paper&lt;/a&gt; for more information.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/sgcp-via-cliques&quot; rel=&quot;nofollow noreferrer&quot;&gt;sgcp-via-cliques&lt;/a&gt;&lt;/strong&gt;: another SGCP solver which uses a transformation into a max-clique problem;&#xA;&lt;a href=&quot;https://santini.in/files/papers/cornaz-furini-malaguti-santini-2019.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here is&lt;/a&gt; the corresponding paper.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/orienteering-alns&quot; rel=&quot;nofollow noreferrer&quot;&gt;orienteering-alns&lt;/a&gt;&lt;/strong&gt;: an ALNS heuristic solver for the Orienteering Problem, presented in &lt;a href=&quot;https://santini.in/files/papers/santini-2019.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/maritime-vrp&quot; rel=&quot;nofollow noreferrer&quot;&gt;maritime-vrp&lt;/a&gt;&lt;/strong&gt;: a branch-and-price solver for a maritime vehicle routing problem for container shipping feeder networks. &lt;a href=&quot;https://santini.in/files/papers/santini-plum-ropke-2017.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;This is&lt;/a&gt; the corresponding paper.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/fast-bwkp&quot; rel=&quot;nofollow noreferrer&quot;&gt;fast-bwkp&lt;/a&gt;&lt;/strong&gt;: a C implementation of a collection of exact and heuristic solvers for the black-and-white knapsack problem.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/tsppddl&quot; rel=&quot;nofollow noreferrer&quot;&gt;tsppddl&lt;/a&gt;&lt;/strong&gt;: a C++ branch &amp;amp; cut solver for the TSP with Pickup, Delivery, and Draught Limits, a problem arising in the shipping industry and &lt;a href=&quot;https://santini.in/files/papers/malaguti-martello-santini-2017.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;detailed in this paper&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/train-energy-genetic-algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;train-energy-genetic-algorithm&lt;/a&gt;&lt;/strong&gt;: is an attempted C implementation of a genetic algorithm to come up with driving profiles for electric and diesel trains, which would minimise energy consumption. I abandoned it half-way through.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Tutorials&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/alberto-santini/cplex-example&quot; rel=&quot;nofollow noreferrer&quot;&gt;cplex-example&lt;/a&gt;&lt;/strong&gt;: example code I use to teach students the basics of modelling with CPLEX's C++ API.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2020-05-08T19:45:48.767" LastActivityDate="2020-05-08T19:45:48.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="454" PostTypeId="2" ParentId="437" CreationDate="2019-06-14T07:49:29.043" Score="6" Body="&lt;p&gt;&lt;a href=&quot;https://arxiv.org/abs/1707.08692&quot; rel=&quot;noreferrer&quot;&gt;Hastie, Tibshirani and Tibshirani&lt;/a&gt; did a comparison of Best Subset Selection (the MIP-formulation introduced by &lt;a href=&quot;https://arxiv.org/pdf/1507.03133.pdf&quot; rel=&quot;noreferrer&quot;&gt;Bertsimas, King and Mazumder&lt;/a&gt;), Forward Stepwise Selection and the Lasso. For their calculations they created an R-package which they shared &lt;a href=&quot;https://github.com/ryantibs/best-subset&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="81" LastActivityDate="2019-06-14T07:49:29.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="455" PostTypeId="5" CreationDate="2019-06-14T07:59:22.783" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-14T07:59:22.783" LastActivityDate="2019-06-14T07:59:22.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="456" PostTypeId="4" CreationDate="2019-06-14T07:59:22.783" Score="0" Body="For questions asking for real-world applications of specific concepts." OwnerUserId="81" LastEditorUserId="81" LastEditDate="2019-06-14T10:00:26.443" LastActivityDate="2019-06-14T10:00:26.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="457" PostTypeId="5" CreationDate="2019-06-14T08:01:09.180" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-14T08:01:09.180" LastActivityDate="2019-06-14T08:01:09.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="458" PostTypeId="4" CreationDate="2019-06-14T08:01:09.180" Score="0" Body="For questions about mixed-integer-linear programming problems, i.e. problems of maximizing or minimizing a linear objective function subject to linear constraints with the additional requirement that some of the variables can only take integer values. synonymous for mixed integer programming tag" OwnerUserId="81" LastEditorUserId="36" LastEditDate="2019-06-18T19:35:22.910" LastActivityDate="2019-06-18T19:35:22.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="459" PostTypeId="5" CreationDate="2019-06-14T08:03:08.653" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-14T08:03:08.653" LastActivityDate="2019-06-14T08:03:08.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="460" PostTypeId="4" CreationDate="2019-06-14T08:03:08.653" Score="0" Body="For questions about the primal Simplex method." OwnerUserId="81" LastEditorUserId="81" LastEditDate="2019-06-14T09:44:02.487" LastActivityDate="2019-06-14T09:44:02.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="461" PostTypeId="5" CreationDate="2019-06-14T08:03:39.057" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-14T08:03:39.057" LastActivityDate="2019-06-14T08:03:39.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="462" PostTypeId="4" CreationDate="2019-06-14T08:03:39.057" Score="0" Body="For questions about the dual Simplex method." OwnerUserId="81" LastEditorUserId="81" LastEditDate="2019-06-14T09:44:17.693" LastActivityDate="2019-06-14T09:44:17.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="463" PostTypeId="2" ParentId="437" CreationDate="2019-06-14T09:10:57.293" Score="5" Body="&lt;p&gt;One group at LANL published several collections of model formulations around infrastructure optimization (power grid, gas pipelines, etc.): &lt;a href=&quot;https://lanl-ansi.github.io/software/&quot; rel=&quot;noreferrer&quot;&gt;https://lanl-ansi.github.io/software/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The formulations are implemented with &lt;a href=&quot;https://github.com/JuliaOpt/JuMP.jl&quot; rel=&quot;noreferrer&quot;&gt;JuMP&lt;/a&gt; and highly configurable. So it's a good setup for comparing different formulations on the same problem type and input data.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-06-14T09:10:57.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="464" PostTypeId="2" ParentId="17" CreationDate="2019-06-14T10:46:23.280" Score="7" Body="&lt;p&gt;One common case where presolve can remove a lot is if you have constraints of the form &lt;span class=&quot;math-container&quot;&gt;$x_i = 0$&lt;/span&gt;. In that situation, you can save time and memory by instead omitting &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; from the index set of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.  Sometimes such constraints appear in the original model in the more obfuscated form &lt;span class=&quot;math-container&quot;&gt;$\sum_i x_i \le 0$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x_i \ge 0$&lt;/span&gt;, but the same idea applies.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-06-14T10:46:23.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="465" PostTypeId="2" ParentId="17" CreationDate="2019-06-14T13:20:21.633" Score="4" Body="&lt;p&gt;You can get the presolved model from Gurobi. Having a look at the variables before and after presolve might give you some interesting insights into which variables the presolver is removing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I name my variables according to the schema &lt;code&gt;variableName[42,1]&lt;/code&gt;. For the analysis I compare the number of variables per group pre- and post-presolve.&lt;/p&gt;&#xA;" OwnerUserId="69" LastActivityDate="2019-06-14T13:20:21.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="466" PostTypeId="2" ParentId="437" CreationDate="2019-06-14T15:00:56.440" Score="4" Body="&lt;p&gt;The &lt;a href=&quot;https://pypsa.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python package PyPSA&lt;/a&gt; does power system analysis, including optimal power flow (OPF) and a bunch of other optimization routines (built on Pyomo). It's a bit like MATPOWER for Python but (I believe) has more functionality. I haven't played around with it much yet, but I mean to—it seems rather awesome.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-14T15:00:56.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="467" PostTypeId="5" CreationDate="2019-06-14T15:08:12.867" Score="0" Body="&lt;p&gt;Questions related to the use of computer models to generate results. Includes situations in which physical models may be appropriate as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some examples include: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Discrete-event simulation (DES)&lt;/li&gt;&#xA;&lt;li&gt;Monte Carlo methods &lt;/li&gt;&#xA;&lt;li&gt;Agent-based simulation &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="491" LastEditorUserId="38" LastEditDate="2019-06-14T15:14:39.473" LastActivityDate="2019-06-14T15:14:39.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="468" PostTypeId="4" CreationDate="2019-06-14T15:08:12.867" Score="0" Body="For questions related to the use of computer models to estimate performance measures for complex systems, typically under uncertainty." OwnerUserId="491" LastEditorUserId="38" LastEditDate="2019-06-14T15:15:27.047" LastActivityDate="2019-06-14T15:15:27.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="469" PostTypeId="1" CreationDate="2019-06-14T16:12:51.427" Score="5" ViewCount="318" Body="&lt;p&gt;When creating a network flow formulation you can set up sinks with integer flow requirement &lt;span class=&quot;math-container&quot;&gt;$\ge 1$&lt;/span&gt;. This yields solutions with the total amount of flow along an edge. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also seen this as a real positive number between &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, the latter inclusive (i.e. &lt;span class=&quot;math-container&quot;&gt;$(0,1]$&lt;/span&gt;). Derived by dividing the sink demand by the total demand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the benefits of the approaches or are they considered equivalent?&lt;/p&gt;&#xA;" OwnerUserId="259" LastEditorUserId="123" LastEditDate="2019-06-14T20:57:21.813" LastActivityDate="2019-06-20T11:07:35.160" Title="What is the impact of making flow fractional rather than integer?" Tags="|mixed-integer-programming|network-flow|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="470" PostTypeId="2" ParentId="281" CreationDate="2019-06-14T17:06:45.180" Score="3" Body="&lt;p&gt;Perhaps its possible to solve as is then check the solution for &quot;violations&quot; of the one at a time constraint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could then push its start time by adding a constraint that enforces it to start after. Using the third constraint you defined. Plus another to set either &lt;span class=&quot;math-container&quot;&gt;$x_{t_1,t_2} = 1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x_{t_2,t_1} = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will be highly dependent on data and the solution will be of debatable quality.&lt;/p&gt;&#xA;" OwnerUserId="259" LastEditorUserId="123" LastEditDate="2019-06-14T19:09:04.427" LastActivityDate="2019-06-14T19:09:04.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="471" PostTypeId="2" ParentId="6" CreationDate="2019-06-14T19:57:39.467" Score="8" Body="&lt;p&gt;Let me first distinguish between two-stage and multi-stage models by emphasizing on two issues, namely the type of uncertainty covered by each model and the sources of stochastic parameters. In two-stage models, you have to assume that stochastic parameters are stationary after being observed. On the other hand, multi-stage models assume a non-stationary behavior. Regarding the sources of stochastic parameters, they usually come from either historical data (usually translated into probability distributions or scenario) or experts’ judgment (directly translated into a small number of scenarios).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following the case of scenarios created by experts, I believe your only option is two-stage stochastic programming models as it is hard, if not impossible, to create valid scenarios corresponding to a non-stationary behavior. This is usually the case for strategic problems where only a few scenarios are considered in detail. Now if you have enough historical data to fit probability distribution functions or create meaningful scenarios, you have to decide your modeling approach (i.e., choosing between two- stage and multi-stage models). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, let’s review the issue of stochastic parameters behavior. A stationary behavior is usually modeled as a two-stage stochastic program. This is in accordance with the way we make a decision. You anticipate some uncertainty and take some precautions. Then you observe a realization of uncertainty and react accordingly and correct your mistakes (i.e., known as the recourse action in SP literature). A non-stationary behavior is better modeled as a multi-stage stochastic program. Here, you’re making some day-to-day decisions, such as financial trading, inventory control, or vehicle routing. Let’s take the example of financial trading. Each day, you invest in some assets, gain/lose some money due to uncertainty realized that day. Then, you keep/change your position in anticipation of what is going to happen tomorrow (which might not be similar to what happened today).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your location-transportation problem is a good example of two-stage models, where you invest before knowing customers’ demands and then react (i.e., change your transportation plan) in accordance with customers’ actual demands. Here, even if you model the problem as a multi-stage problem, all stages after the first one look the same as they are essentially doing the same thing (i.e., transporting goods from warehouses to customers in the later stages vs. building warehouses in the first stages). The only way you could make this problem a multi-stage one is to assume that you could build new warehouses in every stage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the above, I don’t think a multi-stage problem could be correctly modeled as a two-stage problem. In addition, I've not seen your described approach formally stated anywhere in the literature before. Although it seems to be a practical heuristic for solving a complex problem. However, following the above discussion, I do not think it is necessarily a very good heuristic for the inherently operational problems.&#xA;Finally, I think reading section 1.5 of King and Wallace's &quot;&lt;a href=&quot;https://www.springer.com/gp/book/9780387878164&quot; rel=&quot;noreferrer&quot;&gt;Modeling with Stochastic Programming&lt;/a&gt;&quot; could shed more light into your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. As one might confuse the notion of time periods and stages in stochastic programming, I refer them to the following paragraph from King and Wallace's book on page 16.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;“We should not confuse information stages with time periods. Stages&#xA;  model the flow of information; time periods represent the ticking of&#xA;  the clock in a model. Stages, on the other hand, are points in time&#xA;  where we make decisions in the model after having learned something&#xA;  new.”&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="119" LastActivityDate="2019-06-14T19:57:39.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="472" PostTypeId="1" CreationDate="2019-06-14T21:30:27.607" Score="7" ViewCount="548" Body="&lt;p&gt;Is there any Java source code (or framework) to implement and solve MILP using the branch and price method?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK, &lt;a href=&quot;http://coin-or.github.io/jorlib/&quot; rel=&quot;nofollow noreferrer&quot;&gt;jORLib&lt;/a&gt; is a framework to implement B&amp;amp;P using Java, but it does not have any clear documents or active mailing list.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="138" LastEditDate="2019-06-16T01:08:03.763" LastActivityDate="2019-06-16T01:08:03.763" Title="Java source code for branch and price" Tags="|mixed-integer-programming|solver|software|java|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="473" PostTypeId="2" ParentId="37" CreationDate="2019-06-14T21:42:39.683" Score="25" Body="&lt;p&gt;It is worth noting that this formulation can be derived somewhat automatically by writing the logical proposition in conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;&amp;amp; z \iff x \wedge y \\&#xA;&amp;amp; \left(z \implies (x \wedge y)\right) \bigwedge \left((x \wedge y) \implies z\right) \\&#xA;&amp;amp; \left(\neg z \vee (x \wedge y)\right) \bigwedge \left(\neg(x \wedge y) \vee z\right) \\&#xA;&amp;amp; \left((\neg z \vee x) \wedge (\neg z \vee y)\right) \bigwedge \left((\neg x \vee \neg y) \vee z\right) \\&#xA;&amp;amp; (\neg z \vee x) \bigwedge (\neg z \vee y) \bigwedge (\neg x \vee \neg y \vee z) \\&#xA;&amp;amp; \left((1 - z) + x \ge 1\right) \bigwedge \left((1 - z) + y \ge 1\right) \bigwedge \left((1 - x) + (1 - y) + z \ge 1\right) \\&#xA;&amp;amp; (x \ge z) \bigwedge (y \ge z) \bigwedge (z \ge x + y - 1)&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2019-07-23T19:56:11.127" LastActivityDate="2019-07-23T19:56:11.127" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="474" PostTypeId="1" CreationDate="2019-06-14T22:58:59.683" Score="18" ViewCount="1494" Body="&lt;p&gt;It’s often said that “Benders decomposition is Dantzig-Wolfe applied to the dual”. How can this statement be made precise? I know that in Dantzig-Wolfe, cuts are added in one-to-one correspondence with the extreme points of the primal feasible region—is Benders like this but for dual extreme points? I’m interested in explanations highlighting the parallels between the two methods.&lt;/p&gt;&#xA;" OwnerUserId="358" LastEditorUserId="500" LastEditDate="2023-04-02T19:51:17.850" LastActivityDate="2023-04-02T19:51:17.850" Title="Relationship between Benders decomposition and Dantzig-Wolfe decomposition" Tags="|mixed-integer-programming|dantzig-wolfe-decomposition|benders-decomposition|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="475" PostTypeId="5" CreationDate="2019-06-14T23:01:41.980" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-14T23:01:41.980" LastActivityDate="2019-06-14T23:01:41.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="476" PostTypeId="4" CreationDate="2019-06-14T23:01:41.980" Score="0" Body="Questions related to resources (e.g. data, results, code) that can be downloaded freely from the Internet." OwnerUserId="87" LastEditorUserId="38" LastEditDate="2019-06-14T23:25:25.397" LastActivityDate="2019-06-14T23:25:25.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="477" PostTypeId="5" CreationDate="2019-06-14T23:03:35.000" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-14T23:03:35.000" LastActivityDate="2019-06-14T23:03:35.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="478" PostTypeId="4" CreationDate="2019-06-14T23:03:35.000" Score="0" Body="For questions about constraints that can be expressed in (usually propositional) logic." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-15T06:28:23.077" LastActivityDate="2019-06-15T06:28:23.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="479" PostTypeId="5" CreationDate="2019-06-14T23:04:20.023" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-14T23:04:20.023" LastActivityDate="2019-06-14T23:04:20.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="480" PostTypeId="4" CreationDate="2019-06-14T23:04:20.023" Score="0" Body="For questions about optimization over a discrete solution space." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-15T06:28:15.970" LastActivityDate="2019-06-15T06:28:15.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="481" PostTypeId="5" CreationDate="2019-06-14T23:09:14.930" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-14T23:09:14.930" LastActivityDate="2019-06-14T23:09:14.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="482" PostTypeId="4" CreationDate="2019-06-14T23:09:14.930" Score="0" Body="For questions about methods that assign resources to work requests (e.g. processor time to tasks) usually minimizing some cost measure (e.g. makespan)." OwnerUserId="87" LastEditorUserId="38" LastEditDate="2019-06-14T23:24:51.837" LastActivityDate="2019-06-14T23:24:51.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="483" PostTypeId="1" AcceptedAnswerId="1225" CreationDate="2019-06-14T23:49:02.030" Score="17" ViewCount="367" Body="&lt;p&gt;Is there a variant of integer programs for which &lt;a href=&quot;https://doi.org/10.1007/978-3-540-68279-0_4&quot; rel=&quot;noreferrer&quot;&gt;Gomory's cutting plane algorithm&lt;/a&gt; demonstrably takes a superpolynomial number of iterations?&lt;/p&gt;&#xA;" OwnerUserId="87" LastEditorUserId="51" LastEditDate="2024-02-21T11:17:09.610" LastActivityDate="2024-02-21T11:17:09.610" Title="Family of hard instances for Gomory's cutting plane algorithm" Tags="|integer-programming|reference-request|branch-and-cut|cutting-planes|cutting-stock|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="484" PostTypeId="1" AcceptedAnswerId="490" CreationDate="2019-06-14T23:59:42.680" Score="8" ViewCount="714" Body="&lt;p&gt;Which non-textbook variants (primal/dual, revised) and techniques (e.g. steepest-edge) do professional solvers like Xpress, CPLEX, CLP use, to get the best out of the simplex algorithm? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question is about the Simplex algorithm for LP only, not other parts of software packages (such as presolve and crash)&lt;/p&gt;&#xA;" OwnerUserId="556" LastEditorUserId="47" LastEditDate="2019-06-15T07:17:36.827" LastActivityDate="2019-06-15T18:48:34.797" Title="Simplex-Implementations in professional Solvers" Tags="|linear-programming|solver|simplex|dual-simplex|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="485" PostTypeId="5" CreationDate="2019-06-15T01:21:37.540" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-15T01:21:37.540" LastActivityDate="2019-06-15T01:21:37.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="486" PostTypeId="4" CreationDate="2019-06-15T01:21:37.540" Score="0" Body="For questions related to empirical or computational bounds that quantify how far the objective function value of a given solution is from the optimal objective function value." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-15T01:21:37.540" LastActivityDate="2019-06-15T01:21:37.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="487" PostTypeId="2" ParentId="484" CreationDate="2019-06-15T01:30:31.957" Score="20" Body="&lt;p&gt;There is a series of three lectures of Robert Bixby (the Bi in Gurobi) on &lt;a href=&quot;https://www.youtube.com/channel/UCpqwbRiFfQVDdSd6rMLYWXA&quot; rel=&quot;noreferrer&quot;&gt;Solving Linear Programs: The Dual Simplex Algorithm&lt;/a&gt;. Have a look at the third part &lt;a href=&quot;https://www.youtube.com/watch?v=uccbVoamiUM&quot; rel=&quot;noreferrer&quot;&gt;Implementing the algorithm&lt;/a&gt; where he talks about many details and tricks for implementing general bounds, finding a feasible basis, pricing, and solving linear systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular at about 38:00 he explains that there is a single step in solving triangular systems that, when done wrong, takes 99.9% of the solving time in sparse systems, and shows how it can be implemented efficiently.&lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2019-06-15T01:30:31.957" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="488" PostTypeId="1" AcceptedAnswerId="658" CreationDate="2019-06-15T02:17:08.557" Score="17" ViewCount="500" Body="&lt;p&gt;Is it possible to replace a binary variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; with a continuous variable that satisfies the quadratic equality constraint &lt;span class=&quot;math-container&quot;&gt;$x^2 - x=0$&lt;/span&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function &lt;span class=&quot;math-container&quot;&gt;$f(x) = x^2 -x$&lt;/span&gt; is not a convex function. Can this constraint still be helpful in using binary variables in constrained optimization problems?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will be helpful if you give literature references to problems having binary variables solved using this method.&lt;/p&gt;&#xA;" OwnerUserId="439" LastEditorUserId="38" LastEditDate="2019-06-15T02:29:23.057" LastActivityDate="2019-08-25T16:54:37.873" Title="Can we replace a binary variable with a continuous variable using a quadratic equality constraint?" Tags="|optimization|constraint|quadratic-programming|binary-variable|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="489" PostTypeId="2" ParentId="192" CreationDate="2019-06-15T02:26:59.440" Score="5" Body="&lt;p&gt;I believe you have accounted for the rotation, mirroring adequately. The diagonal mirroring may be inadequate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless it is going to be addressed in your other constraints, you also need to fix the location of &lt;span class=&quot;math-container&quot;&gt;$q_4$&lt;/span&gt; relative to either &lt;span class=&quot;math-container&quot;&gt;$q_2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$q_3$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$q_2 \ge q_4$$&lt;/span&gt;&#xA;Without the above constraint, I believe, it is possible for the diagonal mirroring to still exist.&lt;/p&gt;&#xA;" OwnerUserId="439" LastEditorUserId="439" LastEditDate="2019-06-25T15:17:55.097" LastActivityDate="2019-06-25T15:17:55.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="490" PostTypeId="2" ParentId="484" CreationDate="2019-06-15T07:14:41.327" Score="18" Body="&lt;p&gt;First of all, usually implementations are centered around the revised dual simplex, not the primal (even though solvers will still use a primal simplex method implementation for some tasks in the solution process).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;https://www.maths.ed.ac.uk/hall/HuHa13/HuHa13.pdf&quot; rel=&quot;noreferrer&quot;&gt;Huangfu and Hall&lt;/a&gt; and &lt;a href=&quot;https://link.springer.com/article/10.1007/s10589-008-9207-4&quot; rel=&quot;noreferrer&quot;&gt;Koberstein&lt;/a&gt;, the most important non-textbook techniques for the dual revised simplex appear to be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Dual Steepest Edge algorithm&lt;/strong&gt; for choosing the variable leaving the basis &lt;a href=&quot;https://link.springer.com/content/pdf/10.1007/BF01581089.pdf&quot; rel=&quot;noreferrer&quot;&gt;Forrest, Goldfarb: Steepest-edge simplex algorithms for linear programming&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bound Flipping Ratio Test&lt;/strong&gt; See for example &lt;a href=&quot;https://link.springer.com/article/10.1007/s10589-008-9207-4&quot; rel=&quot;noreferrer&quot;&gt;Koberstein&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It is based on the observation that the reduced cost value of a boxed non-basic primal variable can be kept dual feasible even if it switches sign by setting the variable it to its opposite bound. This means that the dual step length can be further increased and breakpoints associated with boxed primal variables can be skipped as long as the dual objective function keeps improving&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Using LU factorization&lt;/strong&gt; No solver I know actually inverts the basis matrix to solve the linear systems. Simplex implementations typically compute a (sparse)LU factorization and update it using Forrest-Tomlin updates to avoid too-frequent recomputation of the factorization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Exploiting Hypersparsity&lt;/strong&gt; Exploiting the fact that when solving a linear system the right hand side is soemtimes/often sparse. See for example &lt;a href=&quot;https://link.springer.com/article/10.1007/s10589-005-4802-0&quot; rel=&quot;noreferrer&quot;&gt;Hall, McKinnon&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Exploiting parallelism&lt;/strong&gt; While the linear algebra in a sparse simplex implementation is not trivial to parallelize, there are some things that can be done to make use of parallel machines. See for example &lt;a href=&quot;https://www.maths.ed.ac.uk/hall/HuHa13/HuHa13.pdf&quot; rel=&quot;noreferrer&quot;&gt;Huangfu, Hall&lt;/a&gt; and &lt;a href=&quot;https://www.maths.ed.ac.uk/hall/ParSimplex/ParSimplexFebruary2005.pdf&quot; rel=&quot;noreferrer&quot;&gt;Hall&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that much of the speedup of solvers compared to one another is often due to a better presolve and/or crashstart implementation. I suspect some of the better open-source simplex implementations to not perform much worse than commercial implementations. &lt;/p&gt;&#xA;" OwnerUserId="47" LastEditorUserId="47" LastEditDate="2019-06-15T08:10:58.270" LastActivityDate="2019-06-15T08:10:58.270" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="491" PostTypeId="2" ParentId="357" CreationDate="2019-06-15T10:16:18.467" Score="10" Body="&lt;p&gt;Raffaele Cerulli from U. Salerno and his daughter Martina Cerulli — PhD student in Paris with Leo Liberti and Claudia D’Ambrosio. &lt;/p&gt;&#xA;" OwnerUserId="429" LastActivityDate="2019-06-15T10:16:18.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="492" PostTypeId="2" ParentId="474" CreationDate="2019-06-15T10:23:13.257" Score="3" Body="&lt;p&gt;If a linear programming problem has a decomposable structure with complicating constraints, its dual linear programming problem has a decomposable structure with complicating variables. And conversely, if a linear programming problem has a decomposable structure with complicating variables, its dual linear programming problem has a decomposable structure with complicating constraints.‎ &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A problem with complicating variables can be transformed, using the dual problem, into a problem with complicating constraints.‎&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-06-15T10:23:13.257" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="493" PostTypeId="2" ParentId="427" CreationDate="2019-06-15T10:43:45.863" Score="15" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\newcommand{\Rbar}{\overline{\mathbb{R}}}\newcommand{\R}{\mathbb{R}}\newcommand{\minimize}{\operatorname{Minimize}}$&lt;/span&gt;Another way to derive the dual for any convex problem is to use Fenchel duality. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Fenchel duality&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Define &lt;span class=&quot;math-container&quot;&gt;$\Rbar=\R\cup \{+\infty\}$&lt;/span&gt;. A function &lt;span class=&quot;math-container&quot;&gt;$f:\R^n\to\Rbar$&lt;/span&gt; is called &lt;em&gt;proper&lt;/em&gt; if there is an &lt;span class=&quot;math-container&quot;&gt;$x\in\R^n$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$f(x) &amp;lt; \infty$&lt;/span&gt;. Given a nonempty convex set &lt;span class=&quot;math-container&quot;&gt;$C\subseteq \R^n$&lt;/span&gt;, define &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\delta_C(x) = \begin{cases}&#xA;0,&amp;amp;\text{if } x \in C\\&#xA;\infty,&amp;amp;\text{if } x \notin C&#xA;\end{cases}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the following optimization problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathbb{P}: &#xA;\minimize_{x\in\R^n} f(x) + g(Ax)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$f:\R^n\to\Rbar$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$g:\R^m\to\Rbar$&lt;/span&gt; are proper, convex, lower semicontinuous functions and &lt;span class=&quot;math-container&quot;&gt;$A\in\R^{m\times n}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;convex conjugate&lt;/em&gt; of a proper convex function &lt;span class=&quot;math-container&quot;&gt;$f:\R^n\to\Rbar$&lt;/span&gt; is defined as the function &lt;span class=&quot;math-container&quot;&gt;$f^*:\R^n\to\Rbar$&lt;/span&gt; with &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f^*(y) = \sup_x x^\top y - f(x)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;Fenchel dual&lt;/em&gt; of problem &lt;span class=&quot;math-container&quot;&gt;$\mathbb{P}$&lt;/span&gt; is the following convex optimization problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\minimize_y f^*(-A^\top y) + g^*(y).&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Conic duality&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Define &lt;span class=&quot;math-container&quot;&gt;$f(x) = c^\top x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$g(z) = \delta_{\mathcal{K}}(b-z)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}$&lt;/span&gt; is a closed convex cone. Then, the conic problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\minimize_x\ &amp;amp; c^\top x\\&#xA;\text{subject to }&amp;amp; b - Ax \in \mathcal{K}&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;can be written as &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathbb{P}: &#xA;\minimize_{x\in\R^n} f(x) + g(Ax)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The convex conjugates of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$f^*(v) = \delta_{\{c\}}(v)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g^*(y) = b^\top y + \delta_{\mathcal{K}^*}(y)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}^*$&lt;/span&gt; is the &lt;em&gt;dual cone&lt;/em&gt; of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}$&lt;/span&gt;. This means that the Fenchel dual problem is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\mathbb{D}: \minimize_y\ &amp;amp; b^\top y\\&#xA;\text{subject to }&amp;amp; y \in \mathcal{K}^*&#xA;\\&#xA;&amp;amp;A^\top y + c = 0&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The inclusion &lt;span class=&quot;math-container&quot;&gt;$b-Ax \in \mathcal{K}$&lt;/span&gt; in the primal problem is often written as &lt;span class=&quot;math-container&quot;&gt;$b - Ax \succeq_{\mathcal{K}} 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="70" LastActivityDate="2019-06-15T10:43:45.863" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="494" PostTypeId="2" ParentId="427" CreationDate="2019-06-15T11:06:58.680" Score="9" Body="&lt;p&gt;Succinct and (freely) accessible references, which include general &quot;theory&quot;. Also, solved examples,. for instance for Second Order Cones (SOCP) and Linear Semidefinite cones (LMI, i.e., Linear SDP):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chapter 8 &quot;Duality in conic optimization&quot; in &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/duality.html&quot; rel=&quot;noreferrer&quot;&gt;&quot;MOSEK Modeling Cookbook&quot;&lt;/a&gt;  .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Section 5.9 &quot;Generalized inequalities&quot; in &lt;a href=&quot;https://web.stanford.edu/~boyd/cvxbook/&quot; rel=&quot;noreferrer&quot;&gt;&quot;Convex Optimization&quot; by Boyd and Vandenberghe&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-06-15T11:58:42.483" LastActivityDate="2019-06-15T11:58:42.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="495" PostTypeId="1" CreationDate="2019-06-15T13:00:08.550" Score="8" ViewCount="152" Body="&lt;p&gt;In a serial inventory system without fixed costs, an echelon base-stock policy is known to be optimal &lt;em&gt;if there is no stockout cost at any stage except the last stage&lt;/em&gt;. (This was proved for finite-horizon problems by &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/mnsc.6.4.475&quot; rel=&quot;nofollow noreferrer&quot;&gt;Clark and Scarf (1960)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; and for infinite-horizon problems by &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/opre.32.4.818&quot; rel=&quot;nofollow noreferrer&quot;&gt;Federgruen and Zipkin (1984)&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt;.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;What is known about the case in which there are non-zero stockout costs at upstream stages?&lt;/em&gt; Is an echelon base-stock policy known to be optimal or non-optimal? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whether or not a base-stock policy is optimal, if we assume such a policy is used, are there algorithms for optimizing the base-stock levels, analogous to those by Clark and Scarf (1960) or &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/mnsc.40.11.1426&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chen and Zheng (1994)&lt;/a&gt;&lt;sup&gt;3&lt;/sup&gt;?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Clark, A. J., Scarf, H. (1960). Optimal Policies for a Multi-Echelon Inventory Problem. &lt;em&gt;Management Science.&lt;/em&gt; 6(4):475-490. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] Federgruen, A., Zipkin, P. (1984). Computational Issues in an Infinite-Horizon, Multiechelon Inventory Model. &lt;em&gt;Operations Research.&lt;/em&gt; 32(4):818-836. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [3] Chen, F., Zheng, Y-S. (1994). Lower Bounds for Multi-Echelon Stochastic Inventory Systems. &lt;em&gt;Management Science.&lt;/em&gt; 40(11):1426-1443. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="123" LastEditDate="2020-01-18T20:16:51.950" LastActivityDate="2020-01-18T20:16:51.950" Title="Is a base-stock policy optimal for a serial inventory system with upstream stockout costs?" Tags="|inventory|multi-echelon|base-stock|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="496" PostTypeId="5" CreationDate="2019-06-15T13:01:15.257" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-15T13:01:15.257" LastActivityDate="2019-06-15T13:01:15.257" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="497" PostTypeId="4" CreationDate="2019-06-15T13:01:15.257" Score="0" Body="For questions related to systems (e.g., supply chains) containing multiple tiers (echelons), with transfers of goods among the tiers." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-15T13:01:15.257" LastActivityDate="2019-06-15T13:01:15.257" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="498" PostTypeId="5" CreationDate="2019-06-15T13:02:18.347" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-15T13:02:18.347" LastActivityDate="2019-06-15T13:02:18.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="499" PostTypeId="4" CreationDate="2019-06-15T13:02:18.347" Score="0" Body="For questions related to inventory policies in which we &quot;order up to&quot; a given level, called the base-stock level. Questions may related to base-stock policies, base-stock levels, or optimization thereof." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-15T13:02:18.347" LastActivityDate="2019-06-15T13:02:18.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="500" PostTypeId="2" ParentId="474" CreationDate="2019-06-15T16:30:30.037" Score="7" Body="&lt;p&gt;&quot;Benders’ decomposition is Dantzig-Wolfe decomposition applied to the dual&quot; is the first sentence of Section 10.3 in Dantzig &amp;amp; Thapa's &lt;a href=&quot;https://dx.doi.org/10.1007/b97283&quot; rel=&quot;noreferrer&quot;&gt;Linear programming 2: theory and extensions&lt;/a&gt;, which then proceeds to give a precise statement of this correspondence. &lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2019-06-15T16:30:30.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="501" PostTypeId="2" ParentId="472" CreationDate="2019-06-15T17:36:42.883" Score="6" Body="&lt;p&gt;I found a manual in Coin-OR Github page where they explained the implementation of the method through 3 different examples.&#xA;You can find the document in &lt;a href=&quot;http://coin-or.github.io/jorlib/manual/manual.pdf&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; web address&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-06-15T17:36:42.883" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="502" PostTypeId="2" ParentId="281" CreationDate="2019-06-15T23:08:03.330" Score="7" Body="&lt;p&gt;One easy way to convince yourself that this is a non-convex problem - and hence can't be represented without integer constraints, or some other non-convex constraint - is to ask: &quot;If X1 and X2 are both valid solutions, is their average always a valid solution?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the problem is convex, the answer must be yes, since that's the definition of convexity. In this case, it's clearly no: there might be valid solutions where task A begins before B, and others where B begins before A, but averaging the starting times results in overlap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can squeeze this into a MIP framework by adding some binary variables, but it may be worth considering a constraint solver e.g. Gecode, which specifically supports &lt;a href=&quot;https://www.gecode.org/doc/6.0.1/reference/group__TaskTestIntNoOverlap.html&quot; rel=&quot;noreferrer&quot;&gt;non-overlap constraints&lt;/a&gt; and is programmed to deal with them.&lt;/p&gt;&#xA;" OwnerUserId="546" LastActivityDate="2019-06-15T23:08:03.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="503" PostTypeId="1" AcceptedAnswerId="504" CreationDate="2019-06-15T23:45:55.357" Score="14" ViewCount="2267" Body="&lt;p&gt;CPLEX solves non-convex quadratic problems to global optimality with a global optimality option (in version 12). The relevant pages are &#xA;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.3/ilog.odms.studio.help/CPLEX/ReleaseNotes/topics/releasenotes126/PLUGINS_ROOT/ilog.odms.cplex.help/CPLEX/UsrMan/topics/cont_optim/qp/01_QP_title_synopsis.html&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.3/ilog.odms.studio.help/CPLEX/ReleaseNotes/topics/releasenotes126/PLUGINS_ROOT/ilog.odms.cplex.help/CPLEX/UsrMan/topics/cont_optim/qp/01_QP_title_synopsis.html&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt;. I benchmarked many solvers, and see that CPLEX is by far the best solver in this problem. I am curious about the algorithms they use. Are these generally hidden, or can I find more about this?&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2023-04-04T08:01:13.270" Title="CPLEX non-convex Quadratic Programming algorithms" Tags="|solver|nonlinear-programming|cplex|quadratic-programming|global-optimality|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="504" PostTypeId="2" ParentId="503" CreationDate="2019-06-16T00:01:48.977" Score="13" Body="&lt;p&gt;The best publicly available CPLEX global QP algorithm description I am aware of is the tutorial presentation by Ed Klotz of IBM at the March 2018 INFORMS Optimization conference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://orwe-conference.mines.edu/files/IOS2018SpatialPerfTuning.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Performance Tuning for Cplex’s Spatial Branch-and-Bound Solver for Global Nonconvex (Mixed Integer) Quadratic Programs&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ABSTRACT&lt;/strong&gt;: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;MILP solvers have been improving for more than 40 years, and performance tuning tactics regarding both adjusting solver strategies and model formulations have evolved as well. State-of-the-art global nonconvex MIQP solvers have improved dramatically in recent years, but they lack the benefit of 40 years of evolution. Also, they use a broader notion of branching that can create different performance challenges. This talk will assess the effectiveness of existing MILP tuning tactics for solving nonconvex MIQPs, as well as consider more specific strategies for spatial branching. It will also examine in detail some tightening strategies specific to nonconvex MIQPs involving bilinear terms of binary variables and their associated linearizations.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note: If you haven;t already done so, it might be worthwhile benchmarking BARON (which unlike CPLEX, only globally optimizes) on non-convex (possibly mixed-integer) QPs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: As follow-up to the matter discussed in the comments to this answer of the different default values in BARON of &lt;strong&gt;epsR&lt;/strong&gt;, the relative convergence tolerance: Going forward, the default value of epsR will be 1e-9 in all BARON interfaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2&lt;/strong&gt;: The newly released BARON 19.7.13 &quot;Changed default value of epsr (relative optimality tolerance) to 1e-9 to guarantee better solutions&quot;&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-07-16T14:07:54.967" LastActivityDate="2019-07-16T14:07:54.967" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="505" PostTypeId="2" ParentId="443" CreationDate="2019-06-16T10:43:50.587" Score="19" Body="&lt;p&gt;It is not possible to model the floor function as a constraint without modeling strict inequality. To prove this, I will show how the floor function can be used to model strict inequalities. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Thanks to @Rob Pratt for showing a cleaner formulation that does not need a possibly large M&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose we can model the constraint &lt;span class=&quot;math-container&quot;&gt;$y=\lfloor x\rfloor$&lt;/span&gt; for any real variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and integer variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. First note that if we have the floor over the real numbers, we have the ceiling as well, since &lt;span class=&quot;math-container&quot;&gt;$\lceil x\rceil = -\lfloor -x\rfloor$&lt;/span&gt;. This means we can add constraints &lt;span class=&quot;math-container&quot;&gt;$\lceil x\rceil -\lfloor x\rfloor =1$&lt;/span&gt;, which is equivalent to &lt;span class=&quot;math-container&quot;&gt;$x\notin \mathbb{Z}$&lt;/span&gt;. The statement &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;x$&lt;/span&gt; for a real variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is equivalent to &lt;span class=&quot;math-container&quot;&gt;$0\leq x \wedge (1\leq x \vee x\notin \mathbb{Z})$&lt;/span&gt;. So, we can encode the statement &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;x$&lt;/span&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{align*}0&amp;amp;\leq x\\&#xA; 1-M\cdot (1-b_1)&amp;amp;\leq x\\&#xA;b_2 &amp;amp;= \lceil x\rceil -\lfloor x\rfloor\\&#xA; b_1 + b_2&amp;amp;\geq 1,&#xA;\end{align*}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, since &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is required to be positive in all cases, we can set &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to obtain the following formulation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{align*}b_1&amp;amp;\le x \\ b_2 &amp;amp;= \lceil x \rceil - \lfloor x \rfloor \\ b_1 + b_2 &amp;amp;\ge 1\end{align*}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;using only the additional binary variables &lt;span class=&quot;math-container&quot;&gt;$b_1,b_2$&lt;/span&gt;. As any strict inequality can be modeled via &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;x$&lt;/span&gt;, we are done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, if we assume we cannot model strict inequalities, then we cannot model a floor function.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Intuitively, what is going on here is that the floor function constraint is as 'powerful' as strict inequalities or integrality testing. Or, to speak in CS terms, all these constraints can be reduced to each-other and lie in the same equivalence class. (cf. complexity classes and poly-time reductions) I wonder if someone investigated these 'expressibility classes' in the context of linear programming before.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;@Rob Pratt notes that we can even do without the additional binary variables and write the constraint &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;x$&lt;/span&gt; as the single constraint &lt;span class=&quot;math-container&quot;&gt;$1-\lceil x\rceil + \lfloor x \rfloor \leq x$&lt;/span&gt;. However, note that even after removing the binary variables this reduction still only makes sense in the context of &lt;em&gt;integer&lt;/em&gt; programming, as flooring an otherwise unconstrained real variable yields an unconstrained integer variable.&lt;/p&gt;&#xA;" OwnerUserId="232" LastEditorUserId="232" LastEditDate="2019-06-17T09:41:48.813" LastActivityDate="2019-06-17T09:41:48.813" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="506" PostTypeId="1" CreationDate="2019-06-16T11:32:32.733" Score="62" ViewCount="13788" Body="&lt;p&gt;When teaching introductory OR courses I have often found that presenting counter-intuitive or paradox-like results is a great eye-opener for the students. I use these examples and results as a motivation for why we need to learn OR techniques. One of the examples I have used is the &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Braess%27s_paradox&quot; rel=&quot;noreferrer&quot;&gt;Braess Paradox&lt;/a&gt; stating that adding a link to a congested road network can end up increasing the overall journey time. What other counter-intuitive results do we have in OR that could be used as motivating examples?&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="38" LastEditDate="2019-06-16T13:01:01.367" LastActivityDate="2022-03-15T13:59:30.233" Title="Counter-intuitive results in OR" Tags="|teaching|" AnswerCount="11" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="507" PostTypeId="2" ParentId="506" CreationDate="2019-06-16T13:07:14.053" Score="27" Body="&lt;p&gt;Some results are highlighted below.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;There is one similar to the Braess paradox. In the paper by &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0167637704001567&quot; rel=&quot;noreferrer&quot;&gt;Spieksma and Woeginger&lt;/a&gt;, a paradox is proposed in which:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;Increasing the speed of some machines in a no-wait flow-shop instance may actually worsen the optimal makespan. We construct instances for which the ratio between optimal makespan with improved speed and optimal makespan without improved speed becomes arbitrarily bad.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The authors of the paper call it the &lt;em&gt;no-wait flow-shop&lt;/em&gt; paradox.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another counterintuitive result is &lt;a href=&quot;https://en.wikipedia.org/wiki/B%C3%A9l%C3%A1dy&amp;#39;s_anomaly&quot; rel=&quot;noreferrer&quot;&gt;Bélády's anomaly&lt;/a&gt;. It is&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;the phenomenon in which increasing the number of page frames results in an increase in the number of page faults for certain memory access patterns. This phenomenon is commonly experienced when using the first-in first-out (FIFO) page replacement algorithm. In FIFO, the page fault may or may not increase as the page frames increase, but in Optimal and stack-based algorithms like LRU, as the page frames increase the page fault decreases.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;em&gt;transportation paradox&lt;/em&gt;, where transportation can be more costly when the number of demands/supplies is reduced. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Spieksma, F.C.R., Woeginger, G.J. (2004). The no-wait flow-shop paradox. &lt;em&gt;ScienceDirect&lt;/em&gt;. 33:6. pp 603-608. &lt;a href=&quot;https://doi.org/10.1016/j.orl.2004.10.007&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1016/j.orl.2004.10.007&lt;/a&gt;. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] Bélády, L.A., Nelson, R.A., Shedler, G.S. (1969). An anomaly in space-time characteristics of certain programs running in a paging machine, &lt;em&gt;Commun. ACM&lt;/em&gt; 12:349–353. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [3] Charnes, A., Klingman, D. (1971). The more-for-less paradox in the distribution model, &lt;em&gt;Cah. Cent. d’Etud. Rech. Oper.&lt;/em&gt; 13:11–22. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-06-27T18:36:22.757" LastActivityDate="2019-06-27T18:36:22.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="508" PostTypeId="2" ParentId="506" CreationDate="2019-06-16T13:19:24.943" Score="45" Body="&lt;p&gt;I like to introduce students to the need for optimization algorithms by talking about the traveling salesman problem (TSP). I introduce the problem statement, which is easy to do, then let them brainstorm ways to solve it. Usually students suggest methods that are similar to nearest neighbor, etc. Eventually, someone usually says something like:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If we're solving it on a computer, then why not just let the computer check all the possible routes and pick the best one?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I ask whether this method could work even for large instances, and usually the consensus is that we could solve instances with 100s or 1000s of nodes this way. We figure out together that there are &lt;span class=&quot;math-container&quot;&gt;$n!$&lt;/span&gt; possible routes, and sometimes students revise their estimates downward, but not by much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I say, OK, let's suppose my computer can evaluate &lt;em&gt;1 trillion&lt;/em&gt; routes per second. Then:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;To solve a 10-node instance takes 3.6 microseconds. (great.)&lt;/li&gt;&#xA;&lt;li&gt;To solve a 15-node instance takes 1.3 seconds. (not bad.)&lt;/li&gt;&#xA;&lt;li&gt;To solve an 18-node instance takes 1.8 hours. (hmm.)&lt;/li&gt;&#xA;&lt;li&gt;To solve a 20-node instance takes 28.2 days. (not great.)&lt;/li&gt;&#xA;&lt;li&gt;To solve a 22-node instance takes 35.6 years. (uh-oh.)&lt;/li&gt;&#xA;&lt;li&gt;To solve a 25-node instance takes 491,857.2 years.&lt;/li&gt;&#xA;&lt;li&gt;To solve a 30-node instance takes hundreds of times the age of the universe.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then I tell them that the &lt;a href=&quot;https://apps.apple.com/us/app/concorde-tsp/id498366515&quot; rel=&quot;noreferrer&quot;&gt;Concorde iPhone app&lt;/a&gt; can solve a 30-node instance in a fraction of a second, to optimality, and then it's an &quot;easy sell&quot; as to why we need optimization algorithms. &lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-16T13:19:24.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="511" PostTypeId="2" ParentId="506" CreationDate="2019-06-16T13:49:49.193" Score="11" Body="&lt;p&gt;Consider a transportation problem with positive cost for all arcs. Now consider an augmented problem which is identical to the original, except there is an increase in supply at one origin, and an increase in demand by the same amount at one destination. The optimal cost of the augmented problem can be less than  for the original.  See EXERCISE 16 in the freely downloadable chapter 8 of &lt;a href=&quot;http://web.mit.edu/15.053/www/AMP-Chapter-08.pdf&quot; rel=&quot;noreferrer&quot;&gt;Bradley, Hax, and Magnanti &quot;Applied Mathematical Programming&quot;&lt;/a&gt; for a numerical example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Unlike all other answers so far to this question, the following is presented to the world for the first time ever.&lt;/strong&gt;&#xA;Inspired by the preceding example, I conceived of how a similar phenomenon could occur in nonlinear math: the numerical computation of the estimated variance of the ratio estimator in the Regenerative Method for Discrete Event Simulation (very much an O.R. thing). Specifically, running the regenerative simulation for &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; cycles produces &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; i.i.d. observations &lt;span class=&quot;math-container&quot;&gt;$(Y_i,\alpha_i) , i=1,\cdots,n$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\alpha_i \ge 0 \, \forall i $&lt;/span&gt;. The standard point estimator for &lt;span class=&quot;math-container&quot;&gt;$$r = \frac{E(Y_1)}{E(\alpha_1)}$$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$$\hat{r}_n = \frac{\sum\limits_{i=1}^n Y_i}{\sum\limits_{i=1}^n \alpha_i}.$$&lt;/span&gt; The standard estimator of &lt;span class=&quot;math-container&quot;&gt;$\sigma^2 = \Bbb &#xA; E(Y_1 - r\alpha_1)^2$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$$S_n^2 = \frac{\sum\limits_{i=1}^n (Y_i - \hat r_n\alpha_i)^2} {n-1}$$&lt;/span&gt; and is used to form a confidence interval for &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As we all know, if we have scalar data points &lt;span class=&quot;math-container&quot;&gt;$x_1,\cdots,x_n$&lt;/span&gt;, having mean &lt;span class=&quot;math-container&quot;&gt;$\bar{x}_n = \frac1n\sum\limits_{i=1}^n x_i$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{i=1}^{n+1} (x_i - \hat{x}_{n+1})^2 \ge \sum\limits_{i=1}^{n} (x_i - \hat{x}_{n})^2.$$&lt;/span&gt; However, the analogue for the above ratio estimator is not true! It is possible that &lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{i=1}^{n+1} (Y_i - \hat{r}_{n+1}\alpha_i)^2 &amp;lt; \sum\limits_{i=1}^n (Y_i - \hat{r}_n\alpha_i)^2.$$&lt;/span&gt; For example, &lt;span class=&quot;math-container&quot;&gt;$(Y_1, \alpha_1) = (1,1)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(Y_2, \alpha_2) = (26,2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(Y_3, \alpha_3) = (13,1)$&lt;/span&gt; for which&#xA;&lt;span class=&quot;math-container&quot;&gt;$S_2^2 = 128$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$2S_3^2 = 126$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Talk about counter intuitive. Whoa Nelly!! Ouch, this means there is no naturally numerically stable way to compote &lt;span class=&quot;math-container&quot;&gt;$S_n^2$&lt;/span&gt; in one pass as there is for the i.i.d variance estimator using a &lt;a href=&quot;https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford&amp;#39;s_online_algorithm&quot; rel=&quot;noreferrer&quot;&gt;Welford or similar algorithm&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though the math in this case is nonlinear, it is similar in spirit (at least it was to me when I conceived it more than 37 years ago) to the counterintuitive transportation problem. When we add a new data point, we have all the same &quot;work&quot; to do as before, plus some extra work, but the total cost decreases. This is because the new data point better &quot;centers&quot; &lt;span class=&quot;math-container&quot;&gt;$\hat{r}$&lt;/span&gt; to decrease the cost of getting some of the existing work done, enough so to more than compensate for the additional &quot;work&quot;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-06-19T00:28:26.470" LastActivityDate="2019-06-19T00:28:26.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="512" PostTypeId="2" ParentId="474" CreationDate="2019-06-16T16:53:01.423" Score="11" Body="&lt;p&gt;My experience is that even when two methods &quot;are equivalent&quot; (eg in the sense that they give the same dual bound), and even though they may be technically &quot;the same&quot; (like &quot;Benders is DW applied to the dual&quot;), such methods may significantly differ when looking at the computational side. DW and Lagrangian relaxation also give the same dual bound, and (dual) multipliers from one can be easily interpreted in the other, but still, in computations, the sequence of these multipliers, thus, the sequence of solutions, can be very different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just keep that in mind when you read &quot;is the same as ..., but applied to the dual.&quot;&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-06-16T16:53:01.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="513" PostTypeId="2" ParentId="443" CreationDate="2019-06-16T17:36:53.960" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Floor_and_ceiling_functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;It&lt;/a&gt; is solved by introducing a &lt;a href=&quot;https://en.wikipedia.org/wiki/Slack_variable&quot; rel=&quot;nofollow noreferrer&quot;&gt;slack variable&lt;/a&gt;, one simple explanation is &lt;a href=&quot;http://yetanothermathprogrammingconsultant.blogspot.com/2016/03/ceiling-function-in-mixed-integer.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and a more detailed video tutorial is &lt;a href=&quot;http://apmonitor.com/wiki/index.php/Main/SlackVariables&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; (with online solver).&lt;/p&gt;&#xA;&lt;p&gt;Alternative (homework preventing) example:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;How to implement the &lt;a href=&quot;http://yetanothermathprogrammingconsultant.blogspot.com/2016/03/ceiling-function-in-mixed-integer.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ceiling function&lt;/a&gt; in a Mixed Integer Program model.&lt;/p&gt;&#xA;&lt;p&gt;The constraint in question is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\left\lceil\frac{x - A}{B}\right\rceil \cdot C + D \cdot x \lt E$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Answer:&lt;/p&gt;&#xA;&lt;p&gt;Introduce an integer variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and a continuous slack variable &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and write:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}y \cdot C + D \cdot x &amp;amp;\leq E\\y&amp;amp;=\frac{x-A}{B}+s\\s &amp;amp;\in [0,0.999]\\y &amp;amp;\in \{\dots,−3,−2,−1,0,1,2,3,\dots\}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$\lt$&lt;/span&gt; constraints are no good, so we make that &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt;. We have a very small area for &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; that we don’t allow: between &lt;span class=&quot;math-container&quot;&gt;$0.999$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. This is to prevent that the ceiling of an integer &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is the next integer &lt;span class=&quot;math-container&quot;&gt;$k+1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-10-14T09:49:42.557" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="514" PostTypeId="2" ParentId="314" CreationDate="2019-06-17T01:58:52.973" Score="4" Body="&lt;p&gt;The answer by @LarrySnyder610 is a good one. There is however a supplementary/alternative technique that I feel is worth mentioning. Its appropriateness depends on how &quot;soft&quot; the constraints really are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This technique involves introducing a new non-negative variable, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; say, together with the two constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p_1 - p_2 \leq x&#xA;$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p_2 - p_1 \leq x.&#xA;$$&lt;/span&gt;&#xA;(We assume that &lt;span class=&quot;math-container&quot;&gt;$p_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_2$&lt;/span&gt; are also both non-negative, which should be true for pressure.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We now incorporate &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; into the objective function as part of a &quot;helper function&quot; so that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is minimized. This is a little tricky to get right. This component of the objective needs to be weighted appropriately. It needs to be given a low weighting relative to other objective components, but not so low that it introduces numerical instability issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This technique is &quot;softer&quot; than the &lt;span class=&quot;math-container&quot;&gt;$-\delta \leq p_1 - p_2 \leq \delta$&lt;/span&gt; technique that has been discussed. It is particularly valuable in the situation where &quot;all other things being equal&quot; we wish for &lt;span class=&quot;math-container&quot;&gt;$p_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_2$&lt;/span&gt; to be the same, but are happy for some divergence to occur if it provides objective improvement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually this technique would not be used in isolation, but would be combined with the other via the domain of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; being restricted to &lt;span class=&quot;math-container&quot;&gt;$[0,\delta]$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It often means that we can make &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; a bit larger, confident in the knowledge that this extra flexibility will only be used when needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously, the applicability of this technique depends on the problem specifics. In this case it depends on whether having occasional slight pressure imbalance is a reasonable thing or not.&lt;/p&gt;&#xA;" OwnerUserId="575" LastEditorUserId="575" LastEditDate="2019-06-17T02:04:04.133" LastActivityDate="2019-06-17T02:04:04.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="515" PostTypeId="5" CreationDate="2019-06-17T02:35:18.867" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:35:18.867" LastActivityDate="2019-06-17T02:35:18.867" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="516" PostTypeId="4" CreationDate="2019-06-17T02:35:18.867" Score="0" Body="For questions related to commercial or open-source computer software used for operations research problems." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:35:18.867" LastActivityDate="2019-06-17T02:35:18.867" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="517" PostTypeId="5" CreationDate="2019-06-17T02:37:09.247" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:37:09.247" LastActivityDate="2019-06-17T02:37:09.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="518" PostTypeId="4" CreationDate="2019-06-17T02:37:09.247" Score="0" Body="For questions related to probability distributions, functions that relate a given value to the likelihood that a random variable will take that value." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:37:09.247" LastActivityDate="2019-06-17T02:37:09.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="519" PostTypeId="5" CreationDate="2019-06-17T02:37:49.213" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:37:49.213" LastActivityDate="2019-06-17T02:37:49.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="520" PostTypeId="4" CreationDate="2019-06-17T02:37:49.213" Score="0" Body="For questions related to the absolute value function, particularly as it is modeled in optimization problems." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:37:49.213" LastActivityDate="2019-06-17T02:37:49.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="521" PostTypeId="5" CreationDate="2019-06-17T02:39:47.133" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:39:47.133" LastActivityDate="2019-06-17T02:39:47.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="522" PostTypeId="4" CreationDate="2019-06-17T02:39:47.133" Score="0" Body="For questions related to graphs, a mathematical object consisting of a set of nodes with edges connecting certain pairs of them." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:39:47.133" LastActivityDate="2019-06-17T02:39:47.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="523" PostTypeId="5" CreationDate="2019-06-17T02:45:11.460" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:45:11.460" LastActivityDate="2019-06-17T02:45:11.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="524" PostTypeId="4" CreationDate="2019-06-17T02:45:11.460" Score="0" Body="For questions related to machine learning (ML), a type of algorithm that attempts to &quot;learn&quot; how to perform a task without being given an explicit set of rules to follow in order to perform it. Questions on this site relate to the optimization algorithms that underpin ML, applications of ML in practical settings, and other ways that ML can be used as a tool for OR, and vice versa." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:45:11.460" LastActivityDate="2019-06-17T02:45:11.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="525" PostTypeId="5" CreationDate="2019-06-17T02:46:38.820" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:46:38.820" LastActivityDate="2019-06-17T02:46:38.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="526" PostTypeId="4" CreationDate="2019-06-17T02:46:38.820" Score="0" Body="For questions related to OR-related software whose source code is freely available and may be modified by users." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:46:38.820" LastActivityDate="2019-06-17T02:46:38.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="527" PostTypeId="5" CreationDate="2019-06-17T02:49:27.943" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:49:27.943" LastActivityDate="2019-06-17T02:49:27.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="528" PostTypeId="4" CreationDate="2019-06-17T02:49:27.943" Score="0" Body="For questions related to Benders decomposition, a type of optimization algorithm in which certain variables are optimized in a &quot;master problem,&quot; the values of those variables are fixed, the remaining variables are optimized in a &quot;subproblem,&quot; cuts are generated to be added to the master problem, and the method repeats." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-17T02:49:27.943" LastActivityDate="2019-06-17T02:49:27.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="529" PostTypeId="1" AcceptedAnswerId="573" CreationDate="2019-06-17T04:07:08.213" Score="13" ViewCount="6219" Body="&lt;p&gt;I was wondering if there is any repository of datasets for supply chain problems. For example, the &lt;a href=&quot;http://archive.ics.uci.edu/ml/index.php&quot; rel=&quot;noreferrer&quot;&gt;UC Irvine Machine Learning Repository&lt;/a&gt; contains datasets for ML, and &lt;a href=&quot;https://miplib.zib.de/&quot; rel=&quot;noreferrer&quot;&gt;MIPLIB&lt;/a&gt; is used as a benchmark for MIP and IP problems. But I cannot find a similar dataset for general supply chain problems. Can you please direct me to such a repository, if one exists?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the lists in &lt;a href=&quot;https://or.stackexchange.com/questions/244/optimization-problem-libraries&quot;&gt;this&lt;/a&gt; question, are mostly open-source libraries, not data-sets, although few of them include data-sets too. &lt;a href=&quot;http://archive.ics.uci.edu/ml/index.php&quot; rel=&quot;noreferrer&quot;&gt;UC Irvine Machine Learning Repository&lt;/a&gt; is just a set of data-sets, and its main point is that it is a single web-site of Machine Learning data-set collection. You can just search there to find what you need.&lt;/p&gt;&#xA;" OwnerUserId="41" LastEditorUserId="41" LastEditDate="2019-06-17T14:56:14.050" LastActivityDate="2019-06-18T21:23:29.397" Title="Supply Chain Public Data Repository" Tags="|online-resources|data|supply-chain|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="530" PostTypeId="2" ParentId="503" CreationDate="2019-06-17T05:23:42.353" Score="4" Body="&lt;p&gt;When you call optimize without any options set, the default values will be used, and those are created by the function baronset.&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2019-06-17T05:23:42.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="531" PostTypeId="2" ParentId="314" CreationDate="2019-06-17T08:08:49.003" Score="7" Body="&lt;p&gt;Answers by Larry Snyder and Mark H have already pointed out the options of (1) constraining the absolute value of the discrepancy, or (2) including abs(discrepancy) in a &quot;penalty function&quot; to be added to the objective function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are useful methods, but depending on the problem you may wish to tweak them a bit, since they have some quirks that may not always be desirable - especially if there are several of these soft constraints in the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you rely on bounding abs(discrepancy), then you are effectively telling the solver that any discrepancy greater than X is absolutely forbidden, and any discrepancy less than or equal to X is absolutely fine. You will often get solutions that are close to the maximum discrepancy, even when it would be easy to reduce this. In some problems, that might be okay; in others, it's not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I recently worked on a problem where we needed to assign work to employees, trying to keep as close as possible to each employee's requested workload. There were a few cases where &quot;as close as possible&quot; was not close at all - e.g. Bob has requested 20 hours of work, but we only have 10 hours available in his region. In order to accommodate this sort of case, we have to set the cap to at least ten hours - but that doesn't mean we want 10-hour discrepancies for every employee! (And it's not practical to micro-manage the maximum discrepancy for each individual employee.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Minimising sum(abs(discrepancy)) avoids this issue. However, it means that (e.g.) one 9-hour discrepancy is considered better than ten 1-hour discrepancies, which is probably unreasonable - you can end up with a solution that's good across most of the problem but poor in some regions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One option, if you have an appropriate solver, is to use a penalty function based on the sum of squared discrepancies. This tends to balance discrepancies through the system - the larger any one discrepancy is, the more pressure there is to reduce it. This often gives nice solutions, but if you have an integer problem it can take a long time to solve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The option that we ended up using is to combine these ideas:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Define a low and high tolerance. Any discrepancy within the low tolerance will be considered &quot;free&quot;; any discrepancy above the high tolerance is forbidden.&lt;/li&gt;&#xA;&lt;li&gt;For each employee (= &quot;group of compressors sharing a pipeline&quot; in your problem), define variable &lt;code&gt;discrepancy&lt;/code&gt; as the difference between requested and allocated hours, or between pressures.&lt;/li&gt;&#xA;&lt;li&gt;For each employee (etc.) define &lt;code&gt;abs_discrepancy&lt;/code&gt; GE &lt;code&gt;discrepancy&lt;/code&gt; and GE &lt;code&gt;-discrepancy&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Constraint &lt;code&gt;abs_discrepancy LE high_tolerance&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;For each employee (etc.) define &lt;code&gt;nonfree_discrepancy&lt;/code&gt; GE 0 and GE &lt;code&gt;abs_discrepancy - low_tolerance&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Minimise sum of &lt;code&gt;nonfree_discrepancy&lt;/code&gt; over all employees.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This effectively approximates a quadratic penalty function with three linear pieces: flat from 0 to low tolerance, then with a cost between low and high tolerances, then infinite gradient past high tolerance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In our problem, this had the benefit of helping with solution time. We found that for the min(sum(abs(discrepancy))) formulation, the solver reached near-optimal solutions quickly and then spent a lot of time grinding away trying to make very small improvements, but it was difficult to quantify exactly what tolerances to set for stopping before optimality. Setting the low tolerance meant that when an employee's discrepancy was inside that tolerance, the solver didn't need to keep fine-tuning their workload.&lt;/p&gt;&#xA;" OwnerUserId="546" LastEditorUserId="546" LastEditDate="2019-06-17T21:07:12.677" LastActivityDate="2019-06-17T21:07:12.677" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="532" PostTypeId="2" ParentId="443" CreationDate="2019-06-17T09:01:50.437" Score="9" Body="&lt;p&gt;I think you can resort to &lt;strong&gt;bilevel optimization&lt;/strong&gt;, in the spirit of slide 3 &lt;a href=&quot;http://www.dei.unipd.it/~fisch/papers/slides/2017%20Sorrento%20%5bFischetti&amp;#39;s%20plenay%20on%20Bilevel%5d.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In bilevel optimization, some variables are the optimal solutions of another optimization problem called &quot;the follower subproblem&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In our case, one can define the following follower subproblem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y = \underset{y'}{\operatorname{argmax}} \left\{ y': y' \le x, \ y' \hbox{ integer} \right\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should work also if &lt;span class=&quot;math-container&quot;&gt;$x=(x_1, \dots\,x_n)$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-dimensional vector, i.e., you can set-up a &lt;em&gt;single&lt;/em&gt; follower problem to define all the rounded &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;'s:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y = \underset{y'}{\operatorname{argmax}}\left\{ \sum_{i=1}^n y'_i: y' \le x, \ y' \hbox{ integer}\right\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whether this is useful in practice I don’t know. &lt;/p&gt;&#xA;" OwnerUserId="429" LastEditorUserId="123" LastEditDate="2019-10-14T09:40:25.167" LastActivityDate="2019-10-14T09:40:25.167" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="533" PostTypeId="2" ParentId="372" CreationDate="2019-06-17T13:42:23.483" Score="5" Body="&lt;p&gt;An IIS is not unique. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given a system &lt;span class=&quot;math-container&quot;&gt;$Ax \le b$&lt;/span&gt;, the indices of an IIS are the supports of the vertices of the polyhedron &lt;span class=&quot;math-container&quot;&gt;$P=\{y: y^{\top}A=0, \; y^{\top}b \le -1, \; y \ge 0\}$&lt;/span&gt;. &#xA;This is the theorem in &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.2.1.61&quot; rel=&quot;noreferrer&quot;&gt;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.2.1.61&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="580" LastActivityDate="2019-06-17T13:42:23.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="534" PostTypeId="1" AcceptedAnswerId="1079" CreationDate="2019-06-17T13:52:15.023" Score="11" ViewCount="241" Body="&lt;h2&gt;In MCDA, which family methods deal with uncertain criterion-specific values?&lt;/h2&gt;&#xA;&lt;h3&gt;What is MCDA?&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Multiple-criteria_decision_analysis&quot; rel=&quot;noreferrer&quot;&gt;Multiple-criteria decision analysis&lt;/a&gt;, refereed as MCDA, is a sub-field of Operations Research for aiding in decision making when several objectives have to be considered.&lt;/p&gt;&#xA;&lt;p&gt;Suppose you have &lt;span class=&quot;math-container&quot;&gt;$m\in \mathbb N^*$&lt;/span&gt; alternatives which can be projects, candidates, drugs and so on, depending on your decision problem. And suppose you have &lt;span class=&quot;math-container&quot;&gt;$n\in\mathbb N^*$&lt;/span&gt; criteria which asset the &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; alternatives.&lt;/p&gt;&#xA;&lt;p&gt;A simple instance of this is:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You have &lt;span class=&quot;math-container&quot;&gt;$m=100$&lt;/span&gt; projects&lt;/li&gt;&#xA;&lt;li&gt;You have &lt;span class=&quot;math-container&quot;&gt;$n=3$&lt;/span&gt; criteria which are:&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Cost of each project&lt;/li&gt;&#xA;&lt;li&gt;Environmental impact of each project&lt;/li&gt;&#xA;&lt;li&gt;Probability of success of each project&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;An example of uncertainty&lt;/h3&gt;&#xA;&lt;p&gt;Then you have a dataset of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; rows and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; columns. When considering this dataset, you could ask yourself which criteria are most important and which aren't? Is the environmental impact of each project more important than the cost of each project? This question defines the criteria's weights. Many MCDA techniques have already been developed for weights infering (e.g. &lt;a href=&quot;https://en.wikipedia.org/wiki/ELECTRE&quot; rel=&quot;noreferrer&quot;&gt;ELECTRE family&lt;/a&gt;) or dealing with incomplete weight information (e.g. &lt;a href=&quot;https://en.wikipedia.org/wiki/Stochastic_multicriteria_acceptability_analysis&quot; rel=&quot;noreferrer&quot;&gt;SMAA family&lt;/a&gt; or &lt;a href=&quot;http://rpm.aalto.fi/&quot; rel=&quot;noreferrer&quot;&gt;RPM family&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;h3&gt;Criterion-specific values uncertainty&lt;/h3&gt;&#xA;&lt;p&gt;Another question about this dataset is &lt;strong&gt;what if the evaluations of the alternatives' criterion-specific values are uncertain?&lt;/strong&gt; (e.g. we only know that the cost of one project is within &lt;span class=&quot;math-container&quot;&gt;$[3,6]$&lt;/span&gt;M€ for interval uncertainty, but it can be fuzzy intervals, distribution laws, missing values and so on). As far as I know, RPM family as well as SMAA methods deal with this kind of uncertainties, and my question is, &lt;strong&gt;are there other MCDA family methods dealing with such uncertainties?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-07-25T16:56:21.230" Title="Families of methods to deal with criterion uncertainties in multicriteria decision analysis" Tags="|multicriteria-decision-analysis|uncertainty|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="536" PostTypeId="2" ParentId="244" CreationDate="2019-06-17T13:59:44.917" Score="10" Body="&lt;p&gt;Some libraries for stochastic programming test problems may be found in&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pages.cs.wisc.edu/~swright/stochastic/sampling/&quot; rel=&quot;noreferrer&quot;&gt;Jeff Linderoth, Alex Shapiro, and Stephen Wright (2002)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://users.iems.northwestern.edu/~jrbirge/html/dholmes/post.html&quot; rel=&quot;noreferrer&quot;&gt;POSTS: A (PO)rtable (S)tochastic programming (T)est (S)et&lt;/a&gt; (Derek Holmes and John Birge)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www4.uwsp.edu/math/afelt/slptestset/download.html&quot; rel=&quot;noreferrer&quot;&gt;Test-Problem Collection for Stochastic Linear Programming&lt;/a&gt; (Andy Felt)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www2.isye.gatech.edu/~sahmed/siplib/&quot; rel=&quot;noreferrer&quot;&gt;SIPLIB: A (S)tochastic (I)nteger (P)rogramming Test Problem (LIB)rary&lt;/a&gt; (Shabbir Ahmed et al.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vlsicad.eecs.umich.edu/BK/Slots/cache/www-cfr.jims.cam.ac.uk/research/stprog.html&quot; rel=&quot;noreferrer&quot;&gt;WATSON pension fund management test problems&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://core.isrd.isi.edu/chaise/recordset/#1/Core:Instance@sort(RCT::desc::,RID)&quot; rel=&quot;noreferrer&quot;&gt;cORe: (c)omputational (O)perations (R)esearch (e)xchange&lt;/a&gt; (Suvrajeet Sen)&lt;/p&gt;&#xA;" OwnerUserId="580" LastActivityDate="2019-06-17T13:59:44.917" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="538" PostTypeId="1" AcceptedAnswerId="539" CreationDate="2019-06-17T14:14:06.093" Score="19" ViewCount="428" Body="&lt;p&gt;When trying a decomposition technique such as column generation, most of the times my approach is to look at the problem and then:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Decide what a column should represent&lt;/li&gt;&#xA;&lt;li&gt;Write the Master Problem&lt;/li&gt;&#xA;&lt;li&gt;Write the expression of the reduced cost, the subproblem, and use the duals of the Master Problem to generate a new column of minimum (or maximum) reduced cost to be added in the Master problem.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This process is hard to automate since it involves looking at the specific problem.&lt;br&gt;&#xA;Also, for the same problem, decisions about what a column should represent can vary, and this may lead to different master and subproblems and to restart again the process and recode it from scratch.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a generic procedure to automatically build a master and one or many subproblems according to how the 2 sets of constraints of the LP (Master and Subproblem constraints) are assigned?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="573" LastEditorUserId="500" LastEditDate="2020-08-20T02:12:47.367" LastActivityDate="2020-08-20T02:12:47.367" Title="Automating the column generation decomposition process" Tags="|linear-programming|column-generation|dantzig-wolfe-decomposition|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="539" PostTypeId="2" ParentId="538" CreationDate="2019-06-17T14:28:06.213" Score="21" Body="&lt;p&gt;You should take a look at &lt;a href=&quot;https://gcg.or.rwth-aachen.de/&quot; rel=&quot;noreferrer&quot;&gt;GCG&lt;/a&gt;, a plugin for SCIP and part of the &lt;a href=&quot;https://scip.zib.de/#scipoptsuite&quot; rel=&quot;noreferrer&quot;&gt;SCIP Optimization Suite&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;After the standard presolving process of SCIP, GCG performs a Dantzig-Wolfe decomposition of the problem to obtain an extended formulation of the problem. The decomposition is based on a structure either provided by the user or automatically detected by one of the structure detectors included in GCG . &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Another software is &lt;a href=&quot;https://projects.coin-or.org/Dip&quot; rel=&quot;noreferrer&quot;&gt;DIP&lt;/a&gt;, formerly known as DECOMP:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Given a compact formulation and a relaxation, the framework takes care of all algorithmic details associated with implementing any of a wide range of decomposition-based algorithms, such as branch and cut, branch and price, branch and cut and price, subgradient-based Lagrangian relaxation, branch and relax and cut, and decompose and cut.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yet another software is &lt;a href=&quot;https://github.com/atoptima/Coluna.jl&quot; rel=&quot;noreferrer&quot;&gt;Coluna&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Coluna is a branch-and-price-and-cut framework that decomposes and solves a mixed-integer program (MIP). The user introduces his &quot;original&quot; problem formulation using the JuMP modeling language and our specific extension BlockDecomposition.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;With &lt;a href=&quot;https://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetTarget=ormpug_decomp_overview.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en&quot; rel=&quot;noreferrer&quot;&gt;SAS/OR&lt;/a&gt; there is also a commercial software with automatic decomposition techniques:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The decomposition algorithm for LPs is based on the original Dantzig-Wolfe method (Dantzig and Wolfe 1960). [...] This method is also commonly referred to as column generation, although the algorithm implemented here is only one specific variant of this wider class of algorithms. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="47" LastEditorUserId="47" LastEditDate="2019-06-17T18:45:28.790" LastActivityDate="2019-06-17T18:45:28.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="541" PostTypeId="1" AcceptedAnswerId="7357" CreationDate="2019-06-17T14:54:40.487" Score="15" ViewCount="268" Body="&lt;p&gt;It turns out that extending MILP with any of the constraints &lt;span class=&quot;math-container&quot;&gt;$y=\lfloor x\rfloor$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y=\lceil x\rceil$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt; x$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;$x\notin \mathbb{Z}$&lt;/span&gt; is 'equally hard'. &#xA; (see &lt;a href=&quot;https://or.stackexchange.com/a/505/&quot;&gt;my answer here&lt;/a&gt;, and below)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Expressing strict inequalities exactly in MILP is something that is generally considered not to be possible with standard solvers in practice without relying on finite precision of the solver, which can be tricky. (It is of course possible to deal with infinite precision reals algebraically with, e.g., a &lt;a href=&quot;https://en.wikipedia.org/wiki/Computer_algebra_system&quot; rel=&quot;noreferrer&quot;&gt;CAS&lt;/a&gt;, but this is much slower than inexact MILP solvers.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The situation here is similar to that of complexity classes in complexity theory (and other applications of reductions within CS), where problems are shown to be 'equally hard' via reductions, but here we are not directly relating complexity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has this observation made before? &lt;strong&gt;Have equivalence classes under expressibility of 'common extensions' to exact MILP such as indicator constraints&lt;sup&gt;1&lt;/sup&gt; been studied?&lt;/strong&gt;&#xA;Are these classes known under another name?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To see why expressing these non-integrality constraints are equally 'hard' within MILP , note&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt; x$&lt;/span&gt; can be expressed as &lt;span class=&quot;math-container&quot;&gt;$0\leq x \wedge x\notin \mathbb{Z}$&lt;/span&gt; (or &lt;span class=&quot;math-container&quot;&gt;$1-\lceil x\rceil + \lfloor x\rfloor \leq x$&lt;/span&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x\notin \mathbb{Z}$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$\lceil x\rceil - \lfloor x\rfloor = 1$&lt;/span&gt;, which is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y=\lfloor x\rfloor$&lt;/span&gt; can be expressed as &lt;span class=&quot;math-container&quot;&gt;$x-1 &amp;lt; y\leq x$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$y\in\mathbb{Z}$&lt;/span&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y=\lceil x\rceil = -\lfloor -x\rfloor$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1: Big-M can be used in some cases, but only if variables are bounded, which is an assumption that makes the expressibility of this method weaker than indicator constraints both in theory and in practice. Of course, indicator constraints are usually slower to solve as a result.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="232" LastEditorUserId="232" LastEditDate="2019-06-24T06:22:08.747" LastActivityDate="2021-12-01T13:42:22.023" Title="Has the expressibility of 'non-integrality testing' as extension to MILP been studied before?" Tags="|mixed-integer-programming|reference-request|terminology|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="542" PostTypeId="2" ParentId="474" CreationDate="2019-06-17T14:58:02.267" Score="2" Body="&lt;p&gt;In theoretical side, two methods are indeed the same. I suggest to read &quot;Relationship with Dantzig-Wolfe Decomposition&quot; section of &lt;a href=&quot;https://personal.eur.nl/birbil/ie606/05_Benders_Dec/05_Benders_Dec_Octave.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this post&lt;/a&gt; as a simple proof.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way show the equivalence in the above post is to apply DW decomposition on the dual problem and take dual again. Then, it is easy to see that DW formulation for dual problem is same as the Bender's decomposition formulation for primal problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In computational side, as &lt;a href=&quot;https://or.stackexchange.com/a/512/162&quot;&gt;Marco's answer&lt;/a&gt; said, two methods still have different performance in their performances. &lt;/p&gt;&#xA;" OwnerUserId="162" LastActivityDate="2019-06-17T14:58:02.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="543" PostTypeId="5" CreationDate="2019-06-17T16:09:45.723" Score="0" Body="" OwnerUserId="491" LastEditorUserId="123" LastEditDate="2020-08-19T14:27:15.277" LastActivityDate="2020-08-19T14:27:15.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="544" PostTypeId="4" CreationDate="2019-06-17T16:09:45.723" Score="0" Body="For questions about the definition or meaning of terms used within Operations Research. Do not use this tag for questions about notation." OwnerUserId="232" LastEditorUserId="123" LastEditDate="2020-08-19T14:27:15.277" LastActivityDate="2020-08-19T14:27:15.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="545" PostTypeId="1" AcceptedAnswerId="548" CreationDate="2019-06-17T16:23:37.190" Score="15" ViewCount="936" Body="&lt;p&gt;When using the C callable library to solve a large LP, how can I get the best bound after calling the method &lt;code&gt;CPXXlpopt&lt;/code&gt;? Does it depend on the algorithm used to solve the LP? I need this for cases in which the LP is too large and the Time Limit is reached without necessarily having an optimal LP solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When solving a MIP I can call the method &lt;code&gt;CPXXgetbestobjval&lt;/code&gt;, however this only works for problems with integer variables. Is there something equivalent for pure LPs?&lt;/p&gt;&#xA;" OwnerUserId="93" LastEditorUserId="491" LastEditDate="2019-06-18T22:08:37.093" LastActivityDate="2019-06-22T21:10:07.777" Title="How to get the best bound of large LP problems in CPLEX?" Tags="|linear-programming|cplex|bounds|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="546" PostTypeId="2" ParentId="443" CreationDate="2019-06-17T17:01:10.327" Score="7" Body="&lt;p&gt;As all have mentioned, the problem is intrinsically hard, as it effectively involves a strict inequality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to represent it, using no strict inequalities or magic constants, is to use the simple trick that &lt;span class=&quot;math-container&quot;&gt;$&amp;gt; 0$&lt;/span&gt; can be replace with &lt;span class=&quot;math-container&quot;&gt;$\geq e^{-z}$&lt;/span&gt; for a new decision variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. An exact solver (not allowed to work with infinities) could then never return a non-strict solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, that would translate to &lt;span class=&quot;math-container&quot;&gt;$x-1 + e^{-z} \leq y \leq x$&lt;/span&gt;. Nice convex exponential cone relaxation and all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, a practical exact solver would not be able to work exactly with expressions involving exponentials, so this is just silly acrobatics trying to avoid introducing some kind of tolerance in the end, i.e., a magic constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: A solution which (in theory...) can be implemented and wouldn't force you out in the transcendental world is to use &lt;span class=&quot;math-container&quot;&gt;$x-1 + z^{-2} \leq y \leq x$&lt;/span&gt; &lt;/p&gt;&#xA;" OwnerUserId="487" LastEditorUserId="487" LastEditDate="2019-06-17T17:16:59.380" LastActivityDate="2019-06-17T17:16:59.380" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="547" PostTypeId="2" ParentId="538" CreationDate="2019-06-17T18:37:04.237" Score="12" Body="&lt;p&gt;Or, if you want a commercial implementation - SAS/OR has a &lt;a href=&quot;https://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetTarget=ormpug_decomp_overview.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en&quot; rel=&quot;noreferrer&quot;&gt;Decomposition feature&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="587" LastActivityDate="2019-06-17T18:37:04.237" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="548" PostTypeId="2" ParentId="545" CreationDate="2019-06-17T19:09:04.847" Score="12" Body="&lt;p&gt;One option I think is to use &lt;code&gt;CPXbaropt&lt;/code&gt; (barrier method) that produces intermediate dual (lower,  for minimization) bounds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are brave enough (and the number of variables is not really huge) you can declare the LP to be a MIP with no integer variables (or add a fictitious one), start with few randomly-chosen constraints and use lazycallback to add the remaining ones, on the fly, when they are violated. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;(Maybe you can obtain something similar without the callback, just adding a dummy integer variable in the model and declaring most of the constraints in your model as lazy constraints.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This will produce a sequence of lower bounds (for minimization problems), so at the timelimit you can retrieve the last one (I guess &lt;code&gt;CPXgetbestobjval&lt;/code&gt; should work now). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We recently used a similar trick for solving bilinear problems with Cplex &lt;a href=&quot;https://www.researchgate.net/publication/331285011_Intersection_cuts_from_bilinear_disjunctions&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I assume that the question refers to a dual bound, i.e., lower bound for minimization. &lt;/p&gt;&#xA;" OwnerUserId="429" LastEditorUserId="429" LastEditDate="2019-06-22T21:01:06.203" LastActivityDate="2019-06-22T21:01:06.203" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="549" PostTypeId="5" CreationDate="2019-06-17T19:50:27.480" Score="0" Body="&lt;p&gt;Binary variables are often used to indicate decisions or the selection of a two mutually exclusive outcomes.  &lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-17T20:15:35.720" LastActivityDate="2019-06-17T20:15:35.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="550" PostTypeId="4" CreationDate="2019-06-17T19:50:27.480" Score="0" Body="For questions that involve variables than can only take on one of two values, usually 0 or 1. " OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-17T20:15:48.797" LastActivityDate="2019-06-17T20:15:48.797" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="551" PostTypeId="2" ParentId="281" CreationDate="2019-06-17T20:13:39.697" Score="5" Body="&lt;p&gt;If you have a finite set &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; of start times, you can introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{t,i}$&lt;/span&gt; that indicates whether task &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt; starts at time &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt;.  Each task must be assigned exactly one start time: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i \in I} y_{t,i} = 1 \text{ for all } t \in T.$$&lt;/span&gt;  Conflicts are then prohibited by clique constraints: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{t, i:\ i \le j &amp;lt; i+d_t} y_{t,i} \le 1 \text{ for all } j \in I.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-06-17T20:13:39.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="552" PostTypeId="1" CreationDate="2019-06-17T20:35:34.480" Score="21" ViewCount="670" Body="&lt;p&gt;How can we measure the tightness of a linear programming relaxation for a mixed integer linear program without using the objective value? I would like to get a measure in terms of the feasible set and independent of the objective function. This is due to the reason that I believe the tightness based on objective value is not informative enough and any change to the objective function might dramatically change the tightness. I believe there should be a different measure that is not affected by the change in the objective function. I am interested in both theoretical and computational answers. This is more of like a question out of curiosity.&lt;/p&gt;&#xA;" OwnerUserId="589" LastEditorUserId="589" LastEditDate="2019-06-19T15:25:33.123" LastActivityDate="2019-08-25T17:36:01.547" Title="Tightness of an LP relaxation without using objective function" Tags="|mixed-integer-programming|linear-programming|modeling|bounds|relaxation|" AnswerCount="5" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="553" PostTypeId="2" ParentId="552" CreationDate="2019-06-17T20:44:48.117" Score="11" Body="&lt;p&gt;If the integer feasible set is finite and the LP polyhedron is bounded (a polytope), you could compare the volumes of the integer hull and this polytope.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-06-17T20:44:48.117" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="554" PostTypeId="1" CreationDate="2019-06-17T20:55:35.650" Score="10" ViewCount="152" Body="&lt;p&gt;I am new to bilevel programming. I was wondering whether it is possible (or straightforward) to formulate a bilevel problem in which there are many secondary-level problems? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example might be a type of attacker-defender problem where there are multiple simultaneous attackers against a single defender, or vice-versa. Let us assume that each attacker can attack in a different region (independent of the other attackers) but the defender has to have a strategy to defend against them all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the model, I would like to leverage the fact that the secondary problem can decompose into many subproblems such that the problems individually are quite easy to solve, but there are numerous subproblems.&lt;/p&gt;&#xA;" OwnerUserId="589" LastEditorUserId="38" LastEditDate="2019-06-27T02:30:05.540" LastActivityDate="2019-06-27T02:30:05.540" Title="Is it possible (or straightforward) to define many secondary problems in bilevel programming?" Tags="|optimization|attacker-defender|bilevel-optimization|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="555" PostTypeId="1" CreationDate="2019-06-17T21:00:48.763" Score="13" ViewCount="516" Body="&lt;p&gt;Is there an efficient way to model the connectivity of two nodes in an arbitrary undirected graph? I would like to have a binary variable representing this connectivity: 1 if there exists a path between these two nodes and 0 otherwise. Let us assume I have a set of binary variables over edges indicating that edge is active or not. By using these variables (and possibly some more), I would like create the connectivity constraints which are aimed to be linear in terms of other variables, or any auxiliary variable which might be introduced. &lt;/p&gt;&#xA;" OwnerUserId="589" LastEditorUserId="589" LastEditDate="2019-06-18T17:37:31.520" LastActivityDate="2019-07-03T16:15:57.020" Title="Connectivity of two nodes in an arbitrary undirected graph" Tags="|linear-programming|modeling|graphs|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="556" PostTypeId="2" ParentId="555" CreationDate="2019-06-17T21:06:05.077" Score="5" Body="&lt;p&gt;Hint: Connectivity is an equivalence relation on the set of nodes, so it has three properties.  You can model each of these properties with linear constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-06-17T21:06:05.077" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="558" PostTypeId="2" ParentId="529" CreationDate="2019-06-17T21:53:19.380" Score="8" Body="&lt;ul&gt;&#xA;&lt;li&gt;Éric Taillard publishes problem sets for flow shop, job shop and open shop scheduling (from one of his papers) at &lt;a href=&quot;http://mistic.heig-vd.ch/taillard/problemes.dir/ordonnancement.dir/ordonnancement.html&quot; rel=&quot;noreferrer&quot;&gt;http://mistic.heig-vd.ch/taillard/problemes.dir/ordonnancement.dir/ordonnancement.html&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Oleg Shylo publishes job shop problem sets from Demirkol et al., as well as best known solutions to both the Taillard and Demirkol problems, at &lt;a href=&quot;http://optimizizer.com/jobshop.php&quot; rel=&quot;noreferrer&quot;&gt;http://optimizizer.com/jobshop.php&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The data sets from an old paper I coauthored (scheduling a single machine to minimize tardiness with sequence-dependent setups) are available on my web site at &lt;a href=&quot;https://msu.edu/~rubin/research/c_or_data/&quot; rel=&quot;noreferrer&quot;&gt;https://msu.edu/~rubin/research/c_or_data/&lt;/a&gt;. (Note for posterity: that site is scheduled to be eliminated in the next year or so, and I do not yet know where the data will end up.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-06-17T21:53:19.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="559" PostTypeId="1" AcceptedAnswerId="575" CreationDate="2019-06-18T00:13:23.333" Score="12" ViewCount="162" Body="&lt;p&gt;How hard is it to compute an irreducible infeasible subset (IIS) for a linear program? What about an integer program (&lt;em&gt;e.g.&lt;/em&gt;, removing the integrality constraint on a single variable may be enough to render the problem feasible, but this seems rather different than the LP case)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, how hard is it to compute the &lt;em&gt;minimum&lt;/em&gt; number of constraints that must be removed to render an LP (and/or IP) feasible?&lt;/p&gt;&#xA;" OwnerUserId="358" LastEditorUserId="354" LastEditDate="2019-06-18T22:19:15.080" LastActivityDate="2019-06-18T22:19:15.080" Title="Computational complexity to compute an IIS" Tags="|linear-programming|integer-programming|feasible-points|irreducible-infeasible-subset|computational-complexity|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="560" PostTypeId="1" CreationDate="2019-06-18T00:34:30.137" Score="18" ViewCount="1334" Body="&lt;p&gt;The theory surrounding Linear Programming is based on variables, bounds and coefficients that take on values in &lt;span class=&quot;math-container&quot;&gt;$\mathbb R$&lt;/span&gt;, the set of real numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have long wondered whether there might be serious application possibilities by applying LP theory within the realm of &lt;span class=&quot;math-container&quot;&gt;$\mathbb C$&lt;/span&gt;, the set of complex numbers, but I have not come across much in the way of useful application myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have others come across any good OR applications of complex valued variables/bounds/coefficients within a LP or MILP modelling framework?&lt;/p&gt;&#xA;" OwnerUserId="575" LastEditorUserId="198" LastEditDate="2019-06-19T14:01:03.180" LastActivityDate="2022-04-28T23:49:07.720" Title="Application of complex numbers in Linear Programming?" Tags="|mixed-integer-programming|linear-programming|applications|complex-numbers|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="561" PostTypeId="2" ParentId="560" CreationDate="2019-06-18T02:13:04.477" Score="15" Body="&lt;p&gt;Complex numbers are commonly used in power systems optimization problems, in particular, AC optimal power flow (OPF) problems. We have constraints of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$p_{ij} + iq_{ij} = f(v_i,v_j),$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q_{ij}$&lt;/span&gt; are real-valued decision variables, &lt;span class=&quot;math-container&quot;&gt;$i=\sqrt{-1}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v_j$&lt;/span&gt; are complex-valued decision variables, and &lt;span class=&quot;math-container&quot;&gt;$f(\cdot)$&lt;/span&gt; is a complex-valued function. Writing each &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; as &#xA;&lt;span class=&quot;math-container&quot;&gt;$$v_i = |v_i|(\cos \theta_i + i\sin \theta_i),$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$|v_i|,\theta_i\in \mathbb{R}$&lt;/span&gt;,&#xA;and doing a lot of simplifying, we get a constraint of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$p_{ij} + iq_{ij} = f_1(|v_i|,|v_j|,\theta_i,\theta_j) + if_2(|v_i|,|v_j|,\theta_i,\theta_j),$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f_1(\cdot)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2(\cdot)$&lt;/span&gt; are real-valued functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The typical approach is then to decompose the complex constraints into two real-valued constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;p_{ij} &amp;amp; = f_1(|v_i|,|v_j|,\theta_i,\theta_j) \\&#xA;q_{ij} &amp;amp; = f_2(|v_i|,|v_j|,\theta_i,\theta_j).&#xA;\end{align}$$&lt;/span&gt;&#xA;The functions &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt; are nonconvex, so a lot of the research in OPF problems is on convexifying or approximating these constraints. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the main point here is just that each complex constraint gets rewritten as a pair of constraints that have only real-valued parameters and decision variables. I'm curious as to whether the same approach is used in other optimization problems that involve complex numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the objective function is real-valued, although it can be a function of complex decision variables.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-18T02:13:04.477" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="562" PostTypeId="5" CreationDate="2019-06-18T04:12:18.700" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Complex_number&quot; rel=&quot;nofollow noreferrer&quot;&gt;Complex numbers&lt;/a&gt; are numbers that can be written in the form of &lt;em&gt;a&lt;/em&gt; + &lt;em&gt;bi&lt;/em&gt; where &lt;em&gt;a&lt;/em&gt; and &lt;em&gt;b&lt;/em&gt; are real numbers and &lt;em&gt;i&lt;/em&gt; = sqrt(-1). &lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-18T08:38:57.113" LastActivityDate="2019-06-18T08:38:57.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="563" PostTypeId="4" CreationDate="2019-06-18T04:12:18.700" Score="0" Body="Questions having to do with the use of complex numbers. " OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-18T07:06:26.500" LastActivityDate="2019-06-18T07:06:26.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="564" PostTypeId="5" CreationDate="2019-06-18T04:16:46.177" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-18T04:16:46.177" LastActivityDate="2019-06-18T04:16:46.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="565" PostTypeId="4" CreationDate="2019-06-18T04:16:46.177" Score="0" Body="Use on questions that relate to teaching, whether in academia or otherwise. " OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-18T07:06:42.773" LastActivityDate="2019-06-18T07:06:42.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="566" PostTypeId="5" CreationDate="2019-06-18T05:24:54.223" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-18T05:24:54.223" LastActivityDate="2019-06-18T05:24:54.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="567" PostTypeId="4" CreationDate="2019-06-18T05:24:54.223" Score="0" Body="For questions about solving Operations Research problems using the Java programming language. " OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-18T08:38:36.427" LastActivityDate="2019-06-18T08:38:36.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="568" PostTypeId="5" CreationDate="2019-06-18T05:42:56.857" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-18T05:42:56.857" LastActivityDate="2019-06-18T05:42:56.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="569" PostTypeId="4" CreationDate="2019-06-18T05:42:56.857" Score="0" Body="synonymous for traveling salesman problem tag" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-18T12:13:05.783" LastActivityDate="2019-06-18T12:13:05.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="570" PostTypeId="5" CreationDate="2019-06-18T05:49:41.557" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-18T05:49:41.557" LastActivityDate="2019-06-18T05:49:41.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="571" PostTypeId="4" CreationDate="2019-06-18T05:49:41.557" Score="0" Body="For questions related to the Interior Point Method for linear programming (LP), which solves LPs optimally by traversing the interior of the feasible region. " OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-18T08:40:15.690" LastActivityDate="2019-06-18T08:40:15.690" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="572" PostTypeId="1" CreationDate="2019-06-18T05:53:28.983" Score="13" ViewCount="594" Body="&lt;p&gt;I'm building a mixed-integer programming model, and the solver is experiencing a very long run time. So I tried to solve the LP relaxation to the MIP, and I get a similarly long solve time, which surprises me. I was wondering what might make an LP take a long time to solve, without any integrality constraints.&lt;/p&gt;&#xA;" OwnerUserId="592" LastEditorUserId="38" LastEditDate="2019-06-18T20:47:45.363" LastActivityDate="2019-06-20T20:16:34.680" Title="Efficiency of solving LP relaxation" Tags="|mixed-integer-programming|linear-programming|lp-relaxation|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="573" PostTypeId="2" ParentId="529" CreationDate="2019-06-18T05:58:57.460" Score="10" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I was wondering if there is any repository of datasets for supply chain problems?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://old.datahub.io/dataset/global-garment-supply-chain-data&quot; rel=&quot;noreferrer&quot;&gt;Global Garment Supply Chain Data&lt;/a&gt; - A collection of import data from various retailers - Last updated: October 19, 2013, 10:23 AM (UTC-07:00)&lt;br&gt;&#xA;[Note: The website Datahub has &lt;a href=&quot;https://old.datahub.io/dataset&quot; rel=&quot;noreferrer&quot;&gt;11,591 other datasets&lt;/a&gt;.]&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;USAID - &lt;a href=&quot;https://www.usaid.gov/data/dataset/0162a542-4f2e-4fe2-ad5d-8f6ed2344056&quot; rel=&quot;noreferrer&quot;&gt;Supply Chain Shipment Pricing Data&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This data set provides supply chain health commodity shipment and pricing data. Specifically, the data set identifies Antiretroviral (ARV) and HIV lab shipments to supported countries. In addition, the data set provides the commodity pricing and associated supply chain expenses necessary to move the commodities to countries for use. The dataset has similar fields to the Global Fund's Price, Quality and Reporting (PQR) data. PEPFAR and the Global Fund represent the two largest procurers of HIV health commodities. This dataset, when analyzed in conjunction with the PQR data, provides a more complete picture of global spending on specific health commodities. The data are particularly valuable for understanding ranges and trends in pricing as well as volumes delivered by country.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The article &quot;&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/msom.1070.0176&quot; rel=&quot;noreferrer&quot;&gt;Data Set—Real-World Multiechelon Supply Chains Used for Inventory Optimization&lt;/a&gt;&quot; (Dec 11 2007), by Sean P. Willems has this supplemental material: &quot;&lt;a href=&quot;https://pubsonline.informs.org/doi/suppl/10.1287/msom.1070.0176&quot; rel=&quot;noreferrer&quot;&gt;Real-World Multi-Echelon Supply Chains Used for Inventory Optimization: Online Appendix&lt;/a&gt;&quot; (Feb 8 2007), by Sean P. Willems:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Supplemental Material&lt;br&gt;&#xA;  &lt;a href=&quot;https://pubsonline.informs.org/doi/suppl/10.1287/msom.1070.0176/suppl_file/msom.1070.0176-sm-data_set.pdf&quot; rel=&quot;noreferrer&quot;&gt;msom.1070.0176-sm-data_set.pdf&lt;/a&gt; (124 KB)&lt;br&gt;&#xA;  &lt;a href=&quot;https://pubsonline.informs.org/doi/suppl/10.1287/msom.1070.0176/suppl_file/msom.1070.0176-sm-datainaccess.zip&quot; rel=&quot;noreferrer&quot;&gt;msom.1070.0176-sm-datainaccess.zip&lt;/a&gt; (548 KB)&lt;br&gt;&#xA;  &lt;a href=&quot;https://pubsonline.informs.org/doi/suppl/10.1287/msom.1070.0176/suppl_file/msom.1070.0176-sm-datainexcel.zip&quot; rel=&quot;noreferrer&quot;&gt;msom.1070.0176-sm-datainexcel.zip&lt;/a&gt; (2 MB)&lt;br&gt;&#xA;  &lt;a href=&quot;https://pubsonline.informs.org/doi/suppl/10.1287/msom.1070.0176/suppl_file/msom.1070.0176-sm-datainxml.zip&quot; rel=&quot;noreferrer&quot;&gt;msom.1070.0176-sm-datainxml.zip&lt;/a&gt; (432 KB)&lt;br&gt;&#xA;  &lt;a href=&quot;https://www.researchgate.net/post/Hello_everyone_Im_looking_for_a_Dataset_of_any_kind_in_Supply_Chain_Management_SCM_Preferably_a_dataset_on_Supply_Chain_Risks_Thanks_Max&quot; rel=&quot;noreferrer&quot;&gt;Additional&lt;/a&gt; Dataset: &lt;a href=&quot;https://www.researchgate.net/profile/Maxwell_Taylor/post/Hello_everyone_Im_looking_for_a_Dataset_of_any_kind_in_Supply_Chain_Management_SCM_Preferably_a_dataset_on_Supply_Chain_Risks_Thanks_Max/attachment/59d64b3479197b80779a550e/AS%3A479066462658560%401491229753646/download/MSOM-06-038-R2+Data+Set+in+Excel.xls+-+Enhanced.zip&quot; rel=&quot;noreferrer&quot;&gt;MSOM-06-038-R2 Data Set in Excel.xls - Enhanced.zip&lt;/a&gt; (2.55 MB)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This data set describes 38 multi-echelon supply chains that have been implemented in practice. These chains exhibit special structure that can be used to inform and test analytical models. Although the data were not collected with the intention of econometric analysis, it is possible that they could be useful in an empirical study. The data described in this paper are publicly available at the journal’s web site &lt;a href=&quot;http://www.msom.org&quot; rel=&quot;noreferrer&quot;&gt;http://www.msom.org&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;[Note: The Manufacturing and Service Operations Management Society's new URL is: &lt;a href=&quot;https://msomsociety.org/&quot; rel=&quot;noreferrer&quot;&gt;https://msomsociety.org/&lt;/a&gt; - I don't see this information available on their new website, nor is it &lt;a href=&quot;https://www.google.com/search?q=msom.1070.0176-sm-datainaccess.zip%20msom.1070.0176-sm-datainexcel.zip%20msom.1070.0176-sm-datainxml.zip&amp;amp;filter=0&amp;amp;biw=980&amp;amp;bih=1666&quot; rel=&quot;noreferrer&quot;&gt;indexed&lt;/a&gt; for availability elsewhere.]&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In particular, each chain contains the exact supply chain network created by the contributor plus the exact characterization of leadtimes at every stage in the supply chain plus realistic yet disguised values for all the supply chain’s data. A secondary use of this data might be to support empirical research into the nature of the supply chains created. The data, available in Microsoft Access, Microsoft Excel and XML formats, are open to all researchers as long as the researcher is willing to cite Willems (2007) as the source. Section 2 presents background information for the chains and Section 3 presents some observations to place the data in context.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Data.gov offers &lt;a href=&quot;https://catalog.data.gov/dataset?tags=supply-chain&quot; rel=&quot;noreferrer&quot;&gt;1 public dataset&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://catalog.data.gov/dataset/nyserda-new-york-offshore-wind-supply-chain-dataset&quot; rel=&quot;noreferrer&quot;&gt;NYSERDA New York Offshore Wind Supply Chain Dataset&lt;/a&gt;&lt;br&gt;&#xA;  Metadata Updated: June 14, 2019&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The dataset contains contact and description information for local supply chain organizations, offshore wind developers, and original equipment manufacturers that provide goods and services to support New York State’s offshore wind industry. The dataset will benefit local suppliers and the offshore wind industry in New York State. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Huge &lt;a href=&quot;https://www.quora.com/Where-can-I-find-large-datasets-open-to-the-public&quot; rel=&quot;noreferrer&quot;&gt;list of public datasets&lt;/a&gt; on Quora.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.openml.org/search?q=supply%20chain&amp;amp;type=data&quot; rel=&quot;noreferrer&quot;&gt;OpenML&lt;/a&gt; has a couple of supply chain databases:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.openml.org/d/41485&quot; rel=&quot;noreferrer&quot;&gt;scm1d&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://www.openml.org/d/41486&quot; rel=&quot;noreferrer&quot;&gt;scm20d&lt;/a&gt; - The Supply Chain Management datasets are derived from the Trading Agent Competition in Supply Chain Management (TAC SCM) tournament from 2010. The precise methods for data preprocessing and normalization are described in detail by Groves and Gini (2011).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another place to ask is on our &lt;a href=&quot;https://opendata.stackexchange.com/&quot;&gt;Open Data&lt;/a&gt; beta site. It's good practice when asking the same question on more than one site to include links to your other identical questions.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-06-18T21:23:29.397" LastActivityDate="2019-06-18T21:23:29.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="574" PostTypeId="1" AcceptedAnswerId="576" CreationDate="2019-06-18T08:41:05.440" Score="8" ViewCount="564" Body="&lt;p&gt;There are five jobs to be assigned to five machines and associated cost matrix is as follows &#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{matrix}&#xA;\text{Machine} &amp;amp; 1 &amp;amp; 2 &amp;amp; 3 &amp;amp; 4 &amp;amp; 5 \\&#xA;\text{Job A} &amp;amp; [11, &amp;amp;17, &amp;amp;8, &amp;amp;16, &amp;amp;20] \\&#xA;\text{Job B} &amp;amp; [9, &amp;amp;7, &amp;amp;12, &amp;amp;6, &amp;amp;15] \\&#xA;\text{Job C} &amp;amp; [13, &amp;amp;16, &amp;amp;15, &amp;amp;12, &amp;amp;16] \\&#xA;\text{Job D} &amp;amp; [21, &amp;amp;24, &amp;amp;16, &amp;amp;28, &amp;amp;26] \\&#xA;\text{Job E} &amp;amp; [14, &amp;amp;10, &amp;amp;12, &amp;amp;11, &amp;amp;15] &#xA;\end{matrix}&#xA;$$&lt;/span&gt;&#xA;The question is now: Find the assignment of machines to jobs that will minimize the total cost?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I solved it using the Hungarian method but for job A and D I had only one zero that too in the same column. I don't know how to solve further if this happens.&lt;/p&gt;&#xA;" OwnerUserId="596" LastEditorUserId="137" LastEditDate="2019-06-18T08:58:27.690" LastActivityDate="2019-06-18T09:30:00.077" Title="Assignment problem using Hungarian method" Tags="|linear-programming|assignment-problem|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="575" PostTypeId="2" ParentId="559" CreationDate="2019-06-18T09:22:10.493" Score="9" Body="&lt;p&gt;Finding a minimum-cardinality MIS for a linear program is an NP-hard problem in general, see &lt;a href=&quot;https://doi.org/10.1007/s10107-002-0363-5&quot; rel=&quot;noreferrer&quot;&gt;Edoardo Amaldi, Marc E. Pfetsch, and Leslie E. Trotter Jr. On the maximum feasible subsystem problem, IISs and IIS-hypergraphs. Mathematical Programming, 95(3):533–554, 2003&lt;/a&gt;. For this reason, commercial solvers such as CPLEX use heuristics to identify small IIS which are not necessarily of minimum cardinality. Notice that for a given LP, there may be multiple overlapping IISs. To achieve feasibility, one must delete at least one inequality from each IIS. The aforementioned paper therefore defines Min IIS Covers.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="137" LastEditDate="2019-06-18T10:06:41.373" LastActivityDate="2019-06-18T10:06:41.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="576" PostTypeId="2" ParentId="574" CreationDate="2019-06-18T09:30:00.077" Score="5" Body="&lt;p&gt;I assume you're applying the &lt;a href=&quot;https://en.wikipedia.org/wiki/Hungarian_algorithm#Matrix_interpretation&quot; rel=&quot;noreferrer&quot;&gt;matrix version&lt;/a&gt; of the algorithm. &#xA;When you happen to have only one &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; for A and D the matrix is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\pmatrix{2&amp;amp;9&amp;amp;0&amp;amp;8&amp;amp;8\\2&amp;amp;1&amp;amp;6&amp;amp;0&amp;amp;5\\0&amp;amp;4&amp;amp;3&amp;amp;0&amp;amp;0\\4&amp;amp;8&amp;amp;0&amp;amp;12&amp;amp;6\\3&amp;amp;0&amp;amp;2&amp;amp;1&amp;amp;1}&#xA;\end{align*}&lt;/span&gt;&#xA;Now continue with &lt;a href=&quot;https://en.wikipedia.org/wiki/Hungarian_algorithm#Matrix_interpretation&quot; rel=&quot;noreferrer&quot;&gt;Step 3&lt;/a&gt;: cover all zeros minimally, and adjust the weights. After that step you will find a solution.&lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2019-06-18T09:30:00.077" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="577" PostTypeId="2" ParentId="443" CreationDate="2019-06-18T09:55:16.340" Score="3" Body="&lt;p&gt;You only specified &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is &quot;continuous&quot;. I'll interpret this as &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is rational rather than real. This is not a terrible assumption, as floating point numbers in computers are rational anyways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A rational &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; can be replaced by a fraction of two integers &lt;span class=&quot;math-container&quot;&gt;$x = \frac{p}{q}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; free and &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; positive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the constraint is &lt;span class=&quot;math-container&quot;&gt;$y = \left\lfloor \frac{p}{q}\right\rfloor$&lt;/span&gt;. This is equivalent to the two constraints &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases}y = \frac{p - m}{q}\\m = p \mod q\end{cases}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is another integer variable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's introduce yet another (non-negative) integer variable &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and additional constraints to get rid of modulo operator.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{cases}p = a \cdot q + m\\m \leq q - 1\end{cases}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So finally we can replace the constraint &lt;span class=&quot;math-container&quot;&gt;$y = \lfloor x \rfloor$&lt;/span&gt; by&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases}x = \frac{p}{q}\\y = \frac{p-m}{q}\\p = a \cdot q + m\\m \leq q - 1\end{cases}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is a free integer and &lt;span class=&quot;math-container&quot;&gt;$a,m,q$&lt;/span&gt; are positive integers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, this is no longer linear and quite ugly to solve. In implementations it will bring tolerances back when approximating the nonlinear constraints.&lt;/p&gt;&#xA;" OwnerUserId="47" LastEditorUserId="123" LastEditDate="2019-10-14T09:44:26.670" LastActivityDate="2019-10-14T09:44:26.670" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="578" PostTypeId="2" ParentId="572" CreationDate="2019-06-18T10:59:41.213" Score="15" Body="&lt;p&gt;If solving the LP relaxation is taking as much time as solving the corresponding MILP formulation to optimality, I would assume one of two things:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Most of the work done by the MILP solver consists of solving the LP relaxation. Solving the LP relaxation is usually a step to solve any MILP with a general-purpose solver. In other words, there is probably no branching going on and preprocessing is not taking much time. That also means that the solution of the LP relaxation satisfies the integrality of the binary variables, which is often a good thing. However, if it is taking too long, I would assume that the formulation is too large. In such case, I would wonder if it would be possible to formulate the problem in a different way, in which the LP formulation is not as strong and probably the solution does not satisfy the integrality of some variables, but that allows you to solve the problem faster either by relying on the solver or implementing your own strategies on top of it. For example, problems with a lot of symmetry might be solved faster with orbital branching than with a formulation having lots of symmetry-breaking constraints. It could also be the case that your current formulation is actually very good, but you are solving problems that are too big.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Another possibility is that the MILP solver is spending a lot of time in preprocessing, for example by removing redundant rows and simplifying your formulation. In that case, the fact that solving the LP and the MILP takes the same time is more of a coincidence, and you should probably be able to improve your formulation in order to avoid a lengthy preprocessing step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can probably check if either of these cases is happening by looking at the solver output while solving your MILP formulation. For a more specific answer, we would need to know what is the formulation that you are trying to solve, how big are the inputs, and what the solver is reporting to you during the process.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2019-06-18T11:09:59.810" LastActivityDate="2019-06-18T11:09:59.810" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="579" PostTypeId="5" CreationDate="2019-06-18T12:35:41.513" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-18T12:35:41.513" LastActivityDate="2019-06-18T12:35:41.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="580" PostTypeId="4" CreationDate="2019-06-18T12:35:41.513" Score="0" Body="synonymous for Linear Programming tag" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-18T19:34:50.497" LastActivityDate="2019-06-18T19:34:50.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="581" PostTypeId="5" CreationDate="2019-06-18T12:41:31.440" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-18T12:41:31.440" LastActivityDate="2019-06-18T12:41:31.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="582" PostTypeId="4" CreationDate="2019-06-18T12:41:31.440" Score="0" Body="For questions about mathematical optimization problems with continuous and discrete variables and nonlinear functions in the objective function and/or the constraints. Should be synonymous with mixed-integer-nonlinear-programming tag." OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-18T14:20:59.933" LastActivityDate="2019-06-18T14:20:59.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="583" PostTypeId="5" CreationDate="2019-06-18T12:56:21.170" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-18T12:56:21.170" LastActivityDate="2019-06-18T12:56:21.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="584" PostTypeId="4" CreationDate="2019-06-18T12:56:21.170" Score="0" Body="For questions about the problem of choosing a set of optimal parameters for an algorithm in order to achieve high-quality results." OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-18T14:20:30.550" LastActivityDate="2019-06-18T14:20:30.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="585" PostTypeId="2" ParentId="572" CreationDate="2019-06-18T15:51:46.893" Score="8" Body="&lt;p&gt;If LP takes a long time to solve, you can check a couple of things:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) How large is the problem? Large LPs (&gt;1 million variables/constraints on a ballpark) can take a long time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) How large is the range of coefficients in the objective function and constraints? Having a large range of the coefficients typically hurts computational performance.&lt;/p&gt;&#xA;" OwnerUserId="45" LastActivityDate="2019-06-18T15:51:46.893" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="586" PostTypeId="1" CreationDate="2019-06-18T15:56:52.663" Score="10" ViewCount="636" Body="&lt;p&gt;This question comes from the perspective of an MSc student new to both OR and programming OR problems in a MIP framework. My research has led me down this path of needing to program an optimization model using CPLEX and I am not entirely sure whether I should invest my time into learning the MATLAB code with a CPLEX extension or investing my time in learning the CPLEX ILOG Optimization Studio. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be interested to know if people have insights into the relevant and relative advantages and disadvantages in pursuing either option for somebody new to this area of study. Again, consider that this question comes from the perspective of someone rather new to the field, so the finer detailed differences might or might not be totally relevant to my context. &lt;/p&gt;&#xA;" OwnerUserId="547" LastActivityDate="2019-06-18T19:25:52.623" Title="Advantages of IBM CPLEX Studio over CPLEX in MATLAB?" Tags="|mixed-integer-programming|cplex|software|matlab|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="587" PostTypeId="5" CreationDate="2019-06-18T17:01:09.827" Score="0" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\bf x$&lt;/span&gt; be an &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-dimensional vector in &lt;span class=&quot;math-container&quot;&gt;$\Bbb R^n$&lt;/span&gt;. A set &lt;span class=&quot;math-container&quot;&gt;$C\in\Bbb R^n$&lt;/span&gt; is a &lt;strong&gt;cone&lt;/strong&gt; if the product &lt;span class=&quot;math-container&quot;&gt;$a{\bf x}\in C$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$a\ge0$&lt;/span&gt; and all &lt;span class=&quot;math-container&quot;&gt;$x\in C$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Learn more: &lt;a href=&quot;https://en.wikipedia.org/wiki/Cone&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia Cone page&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Convex_cone&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia Convex Cone page&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="123" LastEditDate="2020-08-19T14:19:56.060" LastActivityDate="2020-08-19T14:19:56.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="588" PostTypeId="4" CreationDate="2019-06-18T17:01:09.827" Score="0" Body="For questions relating to the mathematical or geometric structure known as a cone." OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-18T18:09:35.433" LastActivityDate="2019-06-18T18:09:35.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="589" PostTypeId="5" CreationDate="2019-06-18T17:03:14.157" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The COIN-OR project is managed by the COIN-OR Foundation, Inc., a&#xA;  non-profit educational foundation. We are building an open-source&#xA;  community for operations research software in order to speed&#xA;  development and deployment of models, algorithms, and cutting-edge&#xA;  computational research, as well as provide a forum for peer review of&#xA;  software similar to that provided by archival journals for theoretical&#xA;  research.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.coin-or.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.coin-or.org/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-18T19:35:11.273" LastActivityDate="2019-06-18T19:35:11.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="590" PostTypeId="4" CreationDate="2019-06-18T17:03:14.157" Score="0" Body="For questions relating to the Computational Infrastructure for Operations Research (COIN-OR). " OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-18T17:41:03.250" LastActivityDate="2019-06-18T17:41:03.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="591" PostTypeId="5" CreationDate="2019-06-18T17:55:02.607" Score="0" Body="&lt;p&gt;For questions relating to the historical development or contributions of Operations Research.  &lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-18T19:09:43.853" LastActivityDate="2019-06-18T19:09:43.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="592" PostTypeId="4" CreationDate="2019-06-18T17:55:02.607" Score="0" Body="For questions relating to the historical development or contributions of Operations Research.  " OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-18T18:55:47.797" LastActivityDate="2019-06-18T18:55:47.797" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="593" PostTypeId="5" CreationDate="2019-06-18T17:57:13.507" Score="0" Body="&lt;p&gt;Academic settings include public and private academic topics as well as research-oriented questions (e.g. research in OR).&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="123" LastEditDate="2020-08-19T14:27:31.003" LastActivityDate="2020-08-19T14:27:31.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="594" PostTypeId="4" CreationDate="2019-06-18T17:57:13.507" Score="0" Body="For questions relating to Operations Research in academic settings. " OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-18T18:56:10.027" LastActivityDate="2019-06-18T18:56:10.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="595" PostTypeId="2" ParentId="586" CreationDate="2019-06-18T19:25:52.623" Score="7" Body="&lt;p&gt;Since you are asking from a MSc student's point of view and actually need to use CPLEX, I assume that your research mainly focuses on the applications of OR. Therefore, two things are required to be considered. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How difficult it is to &lt;strong&gt;implement your model&lt;/strong&gt;?&lt;/li&gt;&#xA;&lt;li&gt;What is the possible &lt;strong&gt;solving approach&lt;/strong&gt; for this model?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;My suggestion:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your research problem &lt;em&gt;can not be easily implemented&lt;/em&gt; or &lt;em&gt;requires&#xA;   some extra fine-tuning solving techniques&lt;/em&gt;, it would be better to&#xA;   model it with other programming languages and solve it by calling&#xA;   CPLEX Solver.  Calling CPLEX Solver from other programs is harder to&#xA;   learn.  However, it gives you more controls in both solving and modeling&#xA;   part of your research.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are just working on &lt;em&gt;easy to implement models&lt;/em&gt; and solving&#xA;   procedure &lt;em&gt;does not require extra techniques&lt;/em&gt;, CPLEX Studio is not a bad choice.  It has a relatively nice user interface and not&#xA;   that hard to learn.&lt;/p&gt;&#xA;" OwnerUserId="162" LastActivityDate="2019-06-18T19:25:52.623" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="596" PostTypeId="5" CreationDate="2019-06-18T22:23:14.757" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-18T22:23:14.757" LastActivityDate="2019-06-18T22:23:14.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="597" PostTypeId="4" CreationDate="2019-06-18T22:23:14.757" Score="0" Body="For questions about the theoretical runtime needed for solving computational problems, often measured in the size of the input. This includes questions about whether polynomial time algorithms exist, NP-hardness, among others." OwnerUserId="354" LastEditorUserId="232" LastEditDate="2019-06-28T10:56:15.973" LastActivityDate="2019-06-28T10:56:15.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="598" PostTypeId="2" ParentId="555" CreationDate="2019-06-18T22:31:59.857" Score="10" Body="&lt;p&gt;From the question and the comments I gather that you really only have one pair between with connectivity &lt;em&gt;could&lt;/em&gt; be established (by activating edges) and whether this is the case or not should be indicated by a binary variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about sending one unit of flow between the two nodes? In, say, the source node you send the one unit either along an exisiting/activated edge, or along an artificial edge (on which you have your &quot;indicator&quot; variable with a small penalty in the objective function: when you must use the indicator, there is &lt;em&gt;no&lt;/em&gt; connectivity between the pairs, otherwise it is).&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-06-18T22:31:59.857" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="599" PostTypeId="1" CreationDate="2019-06-19T00:41:00.220" Score="10" ViewCount="192" Body="&lt;p&gt;In &lt;a href=&quot;http://pages.cs.aueb.gr/~markakis/research/jacm03-facloc.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jain &lt;em&gt;et al.&lt;/em&gt; (2003)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;, at the bottom of page 801, they construct an instance of (metric) uncapacitated facility location for which they claim the greedy (Hochbaum's) algorithm has gap &lt;span class=&quot;math-container&quot;&gt;$\Omega\left(\frac{\log n}{\log \log n}\right)$&lt;/span&gt;. The algorithm is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Construct an instance of set cover, where the ground set of elements is the set of clients &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; and the set system contains all sets of the form &lt;span class=&quot;math-container&quot;&gt;$(i,A)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$i \in F$&lt;/span&gt; is a facility and &lt;span class=&quot;math-container&quot;&gt;$A \subseteq D$&lt;/span&gt; is a set of clients. Set &lt;span class=&quot;math-container&quot;&gt;$(i,A)$&lt;/span&gt; covers the elements in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\operatorname{cost}(i,A) = f_i + \sum{d_{ij}}$&lt;/span&gt;. The greedy algorithm is to choose the set &lt;span class=&quot;math-container&quot;&gt;$(i,A)$&lt;/span&gt; that minimizes &lt;span class=&quot;math-container&quot;&gt;$\frac{\operatorname{cost}(i,A)}{|A\,\cap\, \text{uncovered}|}$&lt;/span&gt;. This can be done in polytime by iterating through the facilities &lt;span class=&quot;math-container&quot;&gt;$i \in F$&lt;/span&gt; and through &lt;span class=&quot;math-container&quot;&gt;$s = 1,\ldots,|\text{uncovered}|$&lt;/span&gt; and considering &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; to be the &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; closest uncovered clients to facility &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Part of the proof of Jain &lt;em&gt;et al.&lt;/em&gt;&lt;sup&gt;1&lt;/sup&gt; is to claim that (on the instance they construct) the above greedy algorithm will open all &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; facilities, while the optimal thing to do is to open only one of the facilities. &lt;strong&gt;I can't seem to see why the greedy algorithm will open all facilities.&lt;/strong&gt; I can see how this would be the case if the cost of each element in set &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{j=1}^ip^{j-1}$&lt;/span&gt;, but in this case opening one facility will have cost &lt;span class=&quot;math-container&quot;&gt;$$p^k + \sum_{i=1}^{k-1}p^{k-i+1}\sum_{j=1}^ip^{j-1} = \Theta(kp^k),$$&lt;/span&gt; while they claim that the optimal cost (that of opening one facility) is &lt;span class=&quot;math-container&quot;&gt;$$p^k + \sum_{i=1}^{k-1}\sum_{j=1}^ip^{j-1} = \Theta(p^k).$$&lt;/span&gt; A central part of their proof seems to be that since the greedy algorithm described above will open all &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; facilities, it will have cost &lt;span class=&quot;math-container&quot;&gt;$\Omega(kp^k)$&lt;/span&gt; and therefore, the gap between the algorithms performance and the optimum is &lt;span class=&quot;math-container&quot;&gt;$\Omega(k)$&lt;/span&gt;. Since there are &lt;span class=&quot;math-container&quot;&gt;$n = \Theta(p^k)$&lt;/span&gt; clients, &lt;span class=&quot;math-container&quot;&gt;$k = \log_p n = \ln n/\ln p$&lt;/span&gt;, and therefore for &lt;span class=&quot;math-container&quot;&gt;$p = \ln n$&lt;/span&gt;, we have that the gap is &lt;span class=&quot;math-container&quot;&gt;$\Omega\left(\frac{\log n}{\log \log n}\right)$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Another question I have is that for &lt;span class=&quot;math-container&quot;&gt;$p = O(1)$&lt;/span&gt;, wouldn't this result in a gap of &lt;span class=&quot;math-container&quot;&gt;$\Omega(\log n)$&lt;/span&gt; which is a stronger result? Why doesn't this work?&lt;/strong&gt; The last sentence of their paragraph is &quot;We do not know whether the approximation factor of Hochbaum’s algorithm on metric instances is strictly less than &lt;span class=&quot;math-container&quot;&gt;$\log n$&lt;/span&gt;.&quot; So I assume I'm missing something.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Jain, K., Mahdian, M., Markakis, E. &lt;em&gt;et al.&lt;/em&gt; (2003). Greedy Facility Location Algorithms Analyzed Using Dual Fitting with Factor-Revealing LP. &lt;em&gt;Journal of the ACM.&lt;/em&gt; &lt;strong&gt;50(6)&lt;/strong&gt;:795–824.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="606" LastEditorUserId="123" LastEditDate="2019-10-20T12:59:04.013" LastActivityDate="2019-10-20T12:59:04.013" Title="Algorithmic gap for Hochbaum's (greedy) algorithm for (metric) uncapacitated facility location" Tags="|optimization|combinatorial-optimization|error-bounds|facility-location|algorithms|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="600" PostTypeId="2" ParentId="599" CreationDate="2019-06-19T02:25:54.770" Score="9" Body="&lt;p&gt;I'm looking at the algorithm as it's described in &lt;a href=&quot;https://link.springer.com/article/10.1007/BF01581035&quot; rel=&quot;noreferrer&quot;&gt;Hochbaum (1982)&lt;/a&gt;, which works like this: Suppose we have enumerated all &lt;span class=&quot;math-container&quot;&gt;$2^n-1$&lt;/span&gt; subsets of the customers. Subset &lt;span class=&quot;math-container&quot;&gt;$P_m$&lt;/span&gt; has cost &#xA;&lt;span class=&quot;math-container&quot;&gt;$$C_m = \min_{j\in J} \left(\sum_{i\in P_m} c_{ij} + f_j\right),$$&lt;/span&gt;&#xA;i.e., the fixed plus transportation cost if we choose the best facility for the set &lt;span class=&quot;math-container&quot;&gt;$P_m$&lt;/span&gt; of customers. At each iteration, we choose the &lt;span class=&quot;math-container&quot;&gt;$P_k$&lt;/span&gt; that maximizes the ratio&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{|P_m|}{C_m},$$&lt;/span&gt;&#xA;open the best facility for that &lt;span class=&quot;math-container&quot;&gt;$P_k$&lt;/span&gt;, remove the customers in &lt;span class=&quot;math-container&quot;&gt;$P_k$&lt;/span&gt; from all of the other &lt;span class=&quot;math-container&quot;&gt;$P_m$&lt;/span&gt; sets, and repeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not exactly sure how that translates to the algorithm described in Jain et al. (2003); they say the two algorithms are equivalent, so let's take their word for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Their example has &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; facilities with a fixed cost of &lt;span class=&quot;math-container&quot;&gt;$p^k$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, all located at the same spot. (They don't give any restrictions on &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; but the example only makes sense if &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is a positive integer.) There are &lt;span class=&quot;math-container&quot;&gt;$k-1$&lt;/span&gt; groups of customers, called &lt;span class=&quot;math-container&quot;&gt;$S_1,\ldots,S_{k-1}$&lt;/span&gt;, oriented as rings around the facilities. &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; contains &lt;span class=&quot;math-container&quot;&gt;$p^{k-i+1}$&lt;/span&gt; customers, each at a distance of &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^i p^{j-1}$&lt;/span&gt; from the facilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the first iteration of Hochbaum's algorithm. Suppose &lt;span class=&quot;math-container&quot;&gt;$P_1=S_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$P_2=S_2$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$P_{1,2}=S_1\cup S_2$&lt;/span&gt;. The relevant ratios are:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\frac{|P_1|}{C_1} &amp;amp; = \frac{p^k}{p^k+p^kp^0} = \frac12 \\&#xA;\frac{|P_2|}{C_2} &amp;amp; = \frac{p^{k-1}}{p^k + p^{k-1}(p^0+p^1)} = \frac{1}{2p+1} &amp;lt; \frac12 \\&#xA;\frac{|P_{1,2}|}{C_{1,2}} &amp;amp; = \frac{p^k+p^{k-1}}{p^k + p^kp^0 + p^{k-1}(p^0+p^1)} = \frac{p+1}{3p+1} &amp;lt; \frac12.&#xA;\end{align}$$&lt;/span&gt;&#xA;And presumably the pattern will repeat, in the sense that if we either add more &quot;rings&quot; to the subset, or we replace &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt; with a different &quot;ring&quot;, the ratio will go down. Therefore, &lt;span class=&quot;math-container&quot;&gt;$P_1 = S_1$&lt;/span&gt; attains the maximum ratio, so we open a facility (doesn't matter which one) and assign &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt; to it. Then remove &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt; from all of the other subsets, and repeat. The same logic will hold at the next iteration, so we will open a facility and assign &lt;span class=&quot;math-container&quot;&gt;$S_2$&lt;/span&gt; to it, and so on. This continues until we have opened all &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; facilities.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-19T02:25:54.770" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="601" PostTypeId="2" ParentId="443" CreationDate="2019-06-19T03:40:19.697" Score="0" Body="&lt;p&gt;An answer with no &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can set &lt;span class=&quot;math-container&quot;&gt;$y+s=x $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb {Z} $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$s\geq 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Appropriate terms (appropriate in terms of sign for following terms, values for big-M's and minimization and maximization) have to be added in the objective function such as &lt;span class=&quot;math-container&quot;&gt;$M_1x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M_2y$&lt;/span&gt; based on the sign of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in the objective function and bounds on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the general case one can add these two terms somehow &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; have the same magnitude of increase in OF in both terms value and sign, if minimization &lt;span class=&quot;math-container&quot;&gt;$-M_1x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$-M_2y$&lt;/span&gt; and maximization &lt;span class=&quot;math-container&quot;&gt;$M_1x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M_2y$&lt;/span&gt;. &lt;/p&gt;&#xA;" OwnerUserId="386" LastEditorUserId="123" LastEditDate="2019-10-14T09:52:52.257" LastActivityDate="2019-10-14T09:52:52.257" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="602" PostTypeId="1" CreationDate="2019-06-19T03:52:19.227" Score="14" ViewCount="958" Body="&lt;p&gt;Why do we normally assume normal distribution/Poisson distribution  for customer demand in a supply chain? Are there other good distribution assumptions?&lt;/p&gt;&#xA;" OwnerUserId="592" LastEditorUserId="38" LastEditDate="2019-06-19T15:46:13.950" LastActivityDate="2019-12-24T14:26:49.143" Title="Good distribution assumptions for customer demand in a supply chain" Tags="|inventory|supply-chain|demand-distribution|simulation|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="603" PostTypeId="2" ParentId="602" CreationDate="2019-06-19T04:05:27.980" Score="9" Body="&lt;p&gt;In my understanding, using normal/Poisson distribution for customer demand is mainly for two reasons.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;These distributions have nice properties for theoretical analysis in supply chain models&lt;/li&gt;&#xA;&lt;li&gt;These distributions are easier to implement or already been implemented for computational concerns&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="162" LastActivityDate="2019-06-19T04:05:27.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="605" PostTypeId="5" CreationDate="2019-06-19T06:29:08.373" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-19T06:29:08.373" LastActivityDate="2019-06-19T06:29:08.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="606" PostTypeId="4" CreationDate="2019-06-19T06:29:08.373" Score="0" Body="For questions about obtaining upper or lower bounds for certain values, usually for an optimization objective." OwnerUserId="232" LastEditorUserId="232" LastEditDate="2019-06-19T14:01:21.120" LastActivityDate="2019-06-19T14:01:21.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="607" PostTypeId="2" ParentId="560" CreationDate="2019-06-19T08:36:53.760" Score="13" Body="&lt;p&gt;Not quite Linear Programming, but if you are willing to generalize to Convex Programming, I have stumbled over some modeling systems (for &lt;a href=&quot;https://dcp.stanford.edu/&quot; rel=&quot;noreferrer&quot;&gt;disciplined convex programming&lt;/a&gt;) that support optimization with complex variables and expressions, e.g.,:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.cvxpy.org/tutorial/advanced/index.html#complex-valued-expressions&quot; rel=&quot;noreferrer&quot;&gt;CVXPY&lt;/a&gt;: Complex-valued expressions&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://convexjl.readthedocs.io/en/latest/complex-domain_optimization.html&quot; rel=&quot;noreferrer&quot;&gt;Convex.jl&lt;/a&gt;: Optimization with Complex Variables.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-06-19T08:36:53.760" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="608" PostTypeId="1" AcceptedAnswerId="609" CreationDate="2019-06-19T11:22:31.707" Score="20" ViewCount="494" Body="&lt;p&gt;Consider the set covering problem&#xA;\[&#xA;\begin{align}&#xA;  \min&amp;amp;\ \sum_{j=1}^nc_jx_j\\&#xA;  s.t.:&amp;amp;\ \sum_{j=1}^na_{ij}x_j\geq 1,\quad \forall i=1,\dots,m\\&#xA;       &amp;amp;\ 0\leq x_j \leq 1&#xA;\end{align}&#xA;\]&#xA;which, in my case, should be solved using column generation as &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is exponential in &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;. By letting &lt;span class=&quot;math-container&quot;&gt;$\pi_i$&lt;/span&gt; be the dual multipliers of the set covering constraints, I can price out new variables by solving an optimization problem of the form&#xA;\[&#xA;  \min\{ c_j-\pi a(x) :x\in X\}.&#xA;\]&#xA;However, when doing this, I have not taken the dual variable of the constraint &lt;span class=&quot;math-container&quot;&gt;$x_j\leq 1$&lt;/span&gt; into account. How do I do that? As the variable has not been added yet, I do not a have a dual variable for its bound.&lt;/p&gt;&#xA;" OwnerUserId="609" LastEditorUserId="87" LastEditDate="2019-07-01T11:54:31.200" LastActivityDate="2019-07-01T11:54:31.200" Title="Variable bounds in column generation" Tags="|optimization|column-generation|set-covering|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="609" PostTypeId="2" ParentId="608" CreationDate="2019-06-19T11:39:05.767" Score="18" Body="&lt;p&gt;Assuming that the &lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt;'s are either zero or one, and the &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt;'s are positive, you do not need the upper bound on the variables. To see this, if &lt;span class=&quot;math-container&quot;&gt;$x_j=1$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, then column &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; covers all items, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$a_{ij}=1$&lt;/span&gt; and it does not cover any other items. Increasing &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$1+\varepsilon$&lt;/span&gt;, for some &lt;span class=&quot;math-container&quot;&gt;$\varepsilon&amp;gt;0$&lt;/span&gt;, will increase the cost, and cover no more items than having &lt;span class=&quot;math-container&quot;&gt;$x_j=1$&lt;/span&gt;. Thus, it will not be optimal to have &lt;span class=&quot;math-container&quot;&gt;$x_j&amp;gt;1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="145" LastEditDate="2019-06-21T00:01:56.650" LastActivityDate="2019-06-21T00:01:56.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="610" PostTypeId="1" CreationDate="2019-06-19T14:30:10.783" Score="3" ViewCount="59" Body="&lt;p&gt;Apologies if this is not an appropriate question for the SE, however, considering that it is in beta testing it might be worthwhile. Note that &quot;Cellular Automata&quot; is not yet a tag, so perhaps there is some use in this post... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am studying invasive species management and often the problems focus on using techniques from OR such as MIP to answer the problems. Another layer of complexity in these papers is that they incorporate their problems into something called a &quot;cellular automata&quot; framework, however, I have no experience with either modelling an MIP problem or cellular automata problem, let along both combined. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I am hoping that perhaps the community may be able to put together a useful information repository on optimization problems within the context of cellular automata. Ideally, people in the future who have similar problems might find this if they search for cellular automata. Again, apologies if this is not appropriate for the forum. &lt;/p&gt;&#xA;" OwnerUserId="547" LastActivityDate="2019-06-19T14:30:10.783" Title="Cellular Automata and MIP Resource Repository?" Tags="|mixed-integer-programming|cellular-automata|" AnswerCount="0" CommentCount="7" ClosedDate="2019-06-19T20:09:51.990" ContentLicense="CC BY-SA 4.0" />
  <row Id="611" PostTypeId="2" ParentId="602" CreationDate="2019-06-19T14:31:23.763" Score="10" Body="&lt;p&gt;I agree with @QianZhang's answer (nice theoretical properties, easy to implement), and I would add that there is some theoretical justification too. If demands come from customer arrivals, then Poisson is a reasonable demand distribution since customer arrivals are well modeled by Poisson (often). And if the mean is large enough, then normal is a good approximation for Poisson.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if demands don't come from a Poisson arrival process, normal is often a good approximation for whatever process they &lt;em&gt;do&lt;/em&gt; come from. Although, as suggested by the question &lt;a href=&quot;https://or.stackexchange.com/questions/529/supply-chain-public-data-repository&quot;&gt;Supply Chain Public Data Repository&lt;/a&gt;, supply chain data is hard to come by, especially at the transactional level (e.g. data on individual demands so that we can check the distribution, rather than aggregate measures like mean), so it might be hard to confirm my claim empirically.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="123" LastEditDate="2019-06-19T18:41:26.310" LastActivityDate="2019-06-19T18:41:26.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="612" PostTypeId="1" AcceptedAnswerId="648" CreationDate="2019-06-19T14:55:25.970" Score="11" ViewCount="937" Body="&lt;p&gt;I have the following constraint that I'd like to linearize:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is a given set&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b_p \in \{0,1\} , \forall p \in P$&lt;/span&gt; a binary variable associated with each element of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_p \in \mathbb{R}^+$&lt;/span&gt;, a coefficient associated with each element of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$l \in \mathbb{R}^+$&lt;/span&gt; a linear variable&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the constraint that I would like to linearize is the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$l \leq \max_{p \in P}(b_p c_p)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="124" LastEditorUserId="124" LastEditDate="2019-06-20T17:19:22.037" LastActivityDate="2019-06-21T17:52:01.247" Title="How to linearize a constraint with a maximum of binary variables times some coefficient in the right-hand-side" Tags="|modeling|linearization|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="613" PostTypeId="2" ParentId="612" CreationDate="2019-06-19T14:55:25.970" Score="4" Body="&lt;p&gt;This is how I ended up doing it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's introduce an extra linear variable&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_p \in [0,1], \forall p \in P$&lt;/span&gt; a continuous variable between 0 and 1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_p \leq b_p, \forall p \in P$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{p \in P} x_p \leq 1$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;now I can replace my original non-linear constraint with the following one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$l \leq \sum_{p \in P}(x_p c_p)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be noted that the &lt;span class=&quot;math-container&quot;&gt;$x_p$&lt;/span&gt; variables should not be used elsewhere in the model.&lt;/p&gt;&#xA;" OwnerUserId="124" LastEditorUserId="124" LastEditDate="2019-06-20T09:46:30.043" LastActivityDate="2019-06-20T09:46:30.043" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="614" PostTypeId="2" ParentId="612" CreationDate="2019-06-19T16:11:43.063" Score="3" Body="&lt;p&gt;I think your answer needs to be improved. Consider the following example and feasible answer to the constraints:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P=\{1,2,3\}, \  \ b_p=\{1,0,1\} \ \ \text{and} \ \ c_p=\{10,20,20\}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;now &lt;span class=&quot;math-container&quot;&gt;$\ x_1=0.5, \ x_2=0, \ x_3=0.5$&lt;/span&gt; then &#xA;&lt;span class=&quot;math-container&quot;&gt;$\ l \leq (0.5 \times 10 +0.5 \times 20)=15$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;which is not the answer that you expected from &lt;span class=&quot;math-container&quot;&gt;$\ l \leq \max_{p \in P}(b_p c_p) \ $&lt;/span&gt; which should be in this example &lt;span class=&quot;math-container&quot;&gt;$l \leq20$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textbf{My approach:}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Define &lt;span class=&quot;math-container&quot;&gt;$K\leq \frac{b_p c_p}{\sum c_p} \ $&lt;/span&gt; then maximize &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; in your model by adding the multiplication of an appropriate coefficient and &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; to the objective function and then add the following to the constraints:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$l \leq K.\sum_{p\in P} c_p$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-06-19T16:11:43.063" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="615" PostTypeId="2" ParentId="612" CreationDate="2019-06-19T17:42:47.540" Score="8" Body="&lt;p&gt;We want &lt;span class=&quot;math-container&quot;&gt;$\ell \le c_p b_p$&lt;/span&gt; for at least one &lt;span class=&quot;math-container&quot;&gt;$p \in P$&lt;/span&gt;.  Let &lt;span class=&quot;math-container&quot;&gt;$c_\max = \max\limits_{p \in P} c_p$&lt;/span&gt;.  Then we have an upper bound &lt;span class=&quot;math-container&quot;&gt;$\ell \le c_\max$&lt;/span&gt;.  Now introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$y_p$&lt;/span&gt; and linear &quot;big-M&quot; constraint &lt;span class=&quot;math-container&quot;&gt;$\ell - c_p b_p \le c_\max (1-y_p)$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$p \in P$&lt;/span&gt;.  Finally, linear constraint &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{p \in P} y_p \ge 1$&lt;/span&gt; forces at least one &lt;span class=&quot;math-container&quot;&gt;$y_p = 1$&lt;/span&gt;, which together with the big-M constraints yields &lt;span class=&quot;math-container&quot;&gt;$\ell \le c_p b_p$&lt;/span&gt; for that &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-06-19T17:42:47.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="616" PostTypeId="2" ParentId="608" CreationDate="2019-06-19T18:47:15.233" Score="3" Body="&lt;p&gt;Another understanding can be the following. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Denote &lt;span class=&quot;math-container&quot;&gt;$X = \{  x \in \Bbb R^n \mid 0 \leq x_j \leq 1, \forall j = 1,\dots, n\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When solving the pricing problem successfully to optimal, all variable bound constraints will be satisfied. Therefore, you only need to track the dual variables &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; of those &lt;strong&gt;'hard'&lt;/strong&gt; constraints which are &lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{j=1}^na_{ij}x_j\geq 1,\quad \forall i=1,\dots,m.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good news for this model is that the pricing problem is a knapsack problem and you can solve it over given &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; efficiently.&lt;/p&gt;&#xA;" OwnerUserId="162" LastEditorUserId="123" LastEditDate="2019-06-19T18:49:13.847" LastActivityDate="2019-06-19T18:49:13.847" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="617" PostTypeId="1" CreationDate="2019-06-19T18:54:18.957" Score="9" ViewCount="2790" Body="&lt;p&gt;I would like to solve mixed integer programs in Java. I need an approach that relies purely on software that is free (not only for academic use, but also for people outside academia).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the best approach for that?&lt;/p&gt;&#xA;" OwnerUserId="50" LastEditorUserId="123" LastEditDate="2019-06-20T06:46:04.510" LastActivityDate="2024-02-19T07:32:55.570" Title="Solving MIP in Java with free software" Tags="|mixed-integer-programming|online-resources|java|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="618" PostTypeId="2" ParentId="617" CreationDate="2019-06-19T19:04:18.593" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;http://www.eecs.harvard.edu/jopt/&quot; rel=&quot;nofollow noreferrer&quot;&gt;JOpt Mixed Integer Program Optimization Package Wrapper&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h3&gt;What is JOpt?&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;JOpt is an open source Java wrapper that provides objects like Variable, Constraint, and Term and lets you express your linear or mixed integer programs in a natural manner, while remaining agnostic to the details of the solver backend. JOpt is not a solver. Rather, it requires a solver such as CPlex or the free LPSolve to operate.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is open-source and allows you to do the following.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h3&gt;Why JOpt?&lt;/h3&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;p&gt;You do linear/quadratic or mixed integer programming, but want to think in terms of simple variables and constraints, not a complex solver-specific api.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;You want to automatically distribute and load balance your problems to one or more solver machines (when compiled for this support).&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The latest version for CPLEX 12 was released in 2017 and can be accessed &lt;a href=&quot;http://www.eecs.harvard.edu/jopt/dist/versions.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For a software that also relies on a free solver, try &lt;a href=&quot;https://java-ilp.soft112.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Java ILP&lt;/a&gt; which can be used with GLPK.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-06-19T19:10:55.683" LastActivityDate="2019-06-19T19:10:55.683" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="619" PostTypeId="2" ParentId="447" CreationDate="2019-06-20T02:05:05.187" Score="3" Body="&lt;p&gt;I do not have direct experience myself with installing COIN-OR solvers under unix-based operating systems, but I do know that it can be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen it successfully done for CLP (Linear Program Solver) and CBC (Branch and Cut Solver) by directly downloading the (open) source code and integrating these libraries with other source code. This is the approach I personally would take.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said this, there are binary distributions. See&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://projects.coin-or.org/CoinBinary&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://projects.coin-or.org/CoinBinary&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and for Debian based systems (such as Ubuntu) see&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://projects.coin-or.org/CoinBinary/wiki/CoinDeb&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://projects.coin-or.org/CoinBinary/wiki/CoinDeb&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ralph, I would be interested in hearing about how you went and about what information you were able to find out.&lt;/p&gt;&#xA;" OwnerUserId="575" LastActivityDate="2019-06-20T02:05:05.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="620" PostTypeId="2" ParentId="506" CreationDate="2019-06-20T02:12:11.830" Score="24" Body="&lt;p&gt;Finding the &lt;em&gt;shortest&lt;/em&gt; path from A to B on a network is easy enough that a high-schooler can do it with pen and paper (Dijkstra's algorithm).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finding the &lt;em&gt;longest&lt;/em&gt; path (without repeats) is much harder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I once edited a maths textbook where the authors had assumed that a longest-path algorithm would be a simple modification of Dijkstra's algorithm. Noooope.)&lt;/p&gt;&#xA;" OwnerUserId="546" LastActivityDate="2019-06-20T02:12:11.830" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="621" PostTypeId="1" CreationDate="2019-06-20T02:31:49.240" Score="11" ViewCount="365" Body="&lt;p&gt;Qualitatively, in my experience in the solving of large scale MILPs, it is common that binary variables corresponding to &quot;edge possibility&quot; components are frequently chosen. Intuitively, these seem associated with various &quot;critical values&quot; within the problem domain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to resonate with the approach of Lagrange Multipliers which identifies such critical values. I have therefore wondered whether a Lagrangian-Multiplier analysis could add significant value in the solving of MILPs. A quick online search seems to confirm that Lagrange Multipliers do indeed have a role to play.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have practical hands-on experience about the usefulness of Lagrange-Multipliers in the solving of real-world large-scale MILP problems? If so, what techniques have you found to be the most useful?&lt;/p&gt;&#xA;" OwnerUserId="575" LastEditorUserId="36" LastEditDate="2019-06-20T17:24:10.287" LastActivityDate="2019-06-20T18:25:15.380" Title="Applicability of Lagrange Multipliers in the analysis of large-scale MILPs?" Tags="|mixed-integer-programming|linear-programming|lagrange-multipliers|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="622" PostTypeId="2" ParentId="617" CreationDate="2019-06-20T02:42:38.427" Score="9" Body="&lt;p&gt;Of the open source LP and MILP solvers, I would recommend investigating the COIN-OR based solvers CLP and CBC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are C++ based libraries, though work has been done to make them more accessible from Java. See&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://spartanideas.msu.edu/2016/06/01/using-clp-with-java/&quot; rel=&quot;noreferrer&quot;&gt;https://spartanideas.msu.edu/2016/06/01/using-clp-with-java/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for example.&lt;/p&gt;&#xA;" OwnerUserId="575" LastActivityDate="2019-06-20T02:42:38.427" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="623" PostTypeId="2" ParentId="621" CreationDate="2019-06-20T07:00:08.767" Score="6" Body="&lt;p&gt;I am not aware of specific algorithmic methods for MIPs that use Lagrangian multipliers directly. However, as for the interpretation of the solution of a MIP: probably one of the nicer applications I have seen comes from &lt;a href=&quot;http://pure.au.dk/portal/en/greiner@imf.au.dk&quot; rel=&quot;noreferrer&quot;&gt;Martin Greiner&lt;/a&gt; from Aarhus university who solves a large-scale MIP of the European electricity prices with a focus on renewable energies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By converting everything into &lt;span class=&quot;math-container&quot;&gt;$CO_2$&lt;/span&gt; equivalents, the Lagrangian multiplier of the constraint on &quot;how green&quot; we want to be gives then the price needed to achieve this, i.e. the Lagrangian multipliers are interpreted in their classical way as shadow prices.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-06-20T07:00:08.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="624" PostTypeId="2" ParentId="552" CreationDate="2019-06-20T07:44:51.650" Score="6" Body="&lt;p&gt;If (for small dimensions) it is feasible to enumerate the vertices of the polyhedron of the relaxation, as well as the actual feasible set, one could try to find a vertex with the highest distance to the feasible set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess this is equivalent to finding the &quot;worst&quot; objective function and could probably be posed as a bilevel problem with LP subproblem.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-06-20T07:44:51.650" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="625" PostTypeId="2" ParentId="469" CreationDate="2019-06-20T11:07:35.160" Score="6" Body="&lt;p&gt;If you are simply normalizing the demand, then you are essentially solving the same problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would argue that the main benefit of integer capacities is from the modeling viewpoint. When solving a maximum flow problem, for example, having integer capacities in the arcs implies that every optimal basic solution satisfies integrality. Hence, if you have an integer programming problem that could be cast as a maximum flow problem with integer capacities, then you have a linear programming formulation that solves your problem and is considerably cheaper than an integer programming formulation in general.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2019-06-20T11:07:35.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="627" PostTypeId="5" CreationDate="2019-06-20T13:43:00.020" Score="0" Body="&lt;p&gt;For Mixed Integer Linear Programming (MILP) models, a &lt;strong&gt;Linear Programming (LP) Relaxation&lt;/strong&gt; removes the integer constraints on the decision (&amp;amp; auxiliary) variables. This permits using traditional LP solver techniques (e.g. simplex) to solve the relaxed problem.&lt;/p&gt;&#xA;&lt;p&gt;If the MILP problem was a minimization problem, the optimal solution (indeed, every feasible solution) to the LP relaxation provides a lower bound on the optimal solution to the MILP problem.&lt;/p&gt;&#xA;&lt;p&gt;The tightness (closeness) of this bound is a subject of great interest and applicability for both practitioners and theoreticians in optimization.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Learn more:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;[1]&lt;/strong&gt; &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0471283665&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Integer Programming&lt;/a&gt; by Lawrence Wolsey&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;[2]&lt;/strong&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Linear_programming_relaxation&quot; rel=&quot;nofollow noreferrer&quot;&gt;LP Relaxation Wiki&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="123" LastEditDate="2020-08-19T14:21:04.580" LastActivityDate="2020-08-19T14:21:04.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="628" PostTypeId="4" CreationDate="2019-06-20T13:43:00.020" Score="0" Body="For questions relating to the relaxation of linear integer or mixed-integer-linear programming (MILP) problems where the integer constraints are removed." OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-20T15:23:55.657" LastActivityDate="2019-06-20T15:23:55.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="629" PostTypeId="1" AcceptedAnswerId="630" CreationDate="2019-06-20T14:14:31.347" Score="8" ViewCount="190" Body="&lt;p&gt;&lt;strong&gt;Context:&lt;/strong&gt;&lt;br /&gt;&#xA;Given a counting process &lt;span class=&quot;math-container&quot;&gt;$\{N(t),\,t\ge 0\}$&lt;/span&gt; which tracks the number of events (arrivals) by time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, the &lt;strong&gt;index of dispersion&lt;/strong&gt; (for counts) is the &lt;em&gt;variance-to-mean ratio of the cumulative number of events (arrivals)&lt;/em&gt; by that point in time. More succinctly, &lt;span class=&quot;math-container&quot;&gt;$$I(t)=\frac{\text{Var}(N(t))}{\text{E}[N(t)]}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Comparison to NHPP.&lt;/strong&gt; In a stochastic process such as a nonhomogenous (nonstationary) Poisson Process (NHPP), &lt;span class=&quot;math-container&quot;&gt;$I(t) = 1\;\; \forall t$&lt;/span&gt;, since the mean and variance for &lt;span class=&quot;math-container&quot;&gt;$N(t)$&lt;/span&gt; are both&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{E}[N(t)] = \text{Var}(N(t))=\int_0^t \lambda(s) ds\,,$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\lambda(t)$&lt;/span&gt; is the time-varying rate for &lt;span class=&quot;math-container&quot;&gt;$N(t)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Q: Does dispersion really matter?&lt;/strong&gt; In what applications would it matter? How does it matter?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I've posted an answer based on my perspective. I'm interested in answers from other branches of OR.&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2021-04-02T13:12:39.823" LastActivityDate="2021-04-02T13:12:39.823" Title="Does dispersion really matter?" Tags="|modeling|stochastic-process|index-of-dispersion|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="630" PostTypeId="2" ParentId="629" CreationDate="2019-06-20T14:14:31.347" Score="7" Body="&lt;p&gt;Yes it matters -- the extent varies by several factors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Applications &amp;amp; Impact&lt;/strong&gt;&lt;br&gt;&#xA;In many contexts using stochastic process-based models, one is well-served to use time-varying models to capture the time-dependent behavior of the system. And sometimes close enough, &lt;span class=&quot;math-container&quot;&gt;$I(t)\approx 1$&lt;/span&gt; is good enough. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In healthcare, appointment-based systems often see &lt;em&gt;underdispersion&lt;/em&gt;, &lt;span class=&quot;math-container&quot;&gt;$I(t) &amp;lt; 1$&lt;/span&gt;, which implies staffing models would over staff if an NHPP arrival process was used, even if it captured the deterministic time-dependent behavior. This happens because the model would overestimate the stochastic variability properly about that time-dependent fluctuation. The literature reports appointment-based dispersion levels of &lt;span class=&quot;math-container&quot;&gt;$(0.4-0.6)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also in healthcare, emergency rooms often see &lt;em&gt;overdispersion&lt;/em&gt;, &lt;span class=&quot;math-container&quot;&gt;$I(t) &amp;gt; 1$&lt;/span&gt;, as well as some call centers. In this setting, a staffing model would underestimate the requirements to meet a desired performance, or Quality of Service (QoS), target. The literature reports levels &lt;span class=&quot;math-container&quot;&gt;$(1.5-2.5)$&lt;/span&gt; as being significant. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Quality of Service (QoS)&lt;/strong&gt;&lt;br&gt;&#xA;How much one should concern oneself with this also depends on the QoS target. If the QoS target is very high, then the level of control required to meet that may require accounting for the dispersion. In low QoS systems, this is less likely to cause problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br&gt;&#xA;1. Focus on the time-dependent nature of your arrival process. This is more important to get right than the dispersion.&lt;br&gt;&#xA;2. Estimate your dispersion to understand the potential &lt;strong&gt;bias&lt;/strong&gt; of your model. More complexity may not be required, even if the model isn't spot on.&lt;br&gt;&#xA;3. If you're quality of service target is high (high performance), then you may want to consider dispersion in the arrival process.&lt;br&gt;&#xA;4. Add in dispersion if necessary.  &lt;/p&gt;&#xA;" OwnerUserId="491" LastActivityDate="2019-06-20T14:14:31.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="631" PostTypeId="2" ParentId="447" CreationDate="2019-06-20T14:47:49.273" Score="3" Body="&lt;p&gt;The Coin-OR stack is pretty complex with a huge dependency chain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general i would say, that the usual rules apply: easiest to hardest in general looks like&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;System Packages&lt;/li&gt;&#xA;&lt;li&gt;Official Builds&lt;/li&gt;&#xA;&lt;li&gt;Build from Sources&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In all cases it might be critical if someone only needs an executable (probably sufficient for pyomo) or a shared library (often easier to obtain the first; and always easier to provide some software to call the binary instead of linking or loading shared libs). &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;1. System Packages&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This boils down to recognizing ones system and it's package-repositories. Then check is pre-made builds are available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The usual cli-commands like &lt;code&gt;lsb_release -a&lt;/code&gt; and the GUI-based package-managers can help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Coin-Cbc for example, one would find &lt;a href=&quot;https://packages.ubuntu.com/bionic/coinor-cbc&quot; rel=&quot;nofollow noreferrer&quot;&gt;those&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;2. Official Builds&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;It's sometimes not trivial to find those builds (and CoinOR is no exception in terms of competing documents where some are outdated and some are not). You will eventually see dead links (or 5 years old builds) trying to follow the links in Mark's answer: &lt;a href=&quot;https://projects.coin-or.org/CoinBinary&quot; rel=&quot;nofollow noreferrer&quot;&gt;CoinBinary&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would start with some of the development-places. While maybe not the core-dev place, Coin Cbc's &lt;a href=&quot;https://github.com/coin-or/Cbc&quot; rel=&quot;nofollow noreferrer&quot;&gt;github page&lt;/a&gt; for example links to &lt;a href=&quot;https://bintray.com/coin-or/download/Cbc/2.10&quot; rel=&quot;nofollow noreferrer&quot;&gt;this bintray providing builds&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;3. Build from Sources&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;If there would be one thing i learned from the past it would be: &lt;strong&gt;CI can be a blessing!&lt;/strong&gt; Exploit this.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Example&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Let's give you some example with &lt;a href=&quot;https://github.com/coin-or/CHiPPS-BLIS&quot; rel=&quot;nofollow noreferrer&quot;&gt;CHiPPS-BLIS&lt;/a&gt;. We want to develop something with it and therefore need our environment ready to link against it. It might be a good idea to build the current version from source and make use of it's makefiles for our work too (which is another terribly complex thing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We start with above github entry and find &lt;code&gt;Install.md&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We learn:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There is an extra project available just for handling Coin-OR installs / dependency management / builds: &lt;code&gt;COIN-OR-OptimizationSuite&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;This route is recommend in the &lt;code&gt;Install.md&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But we will shortly recognize the outdated nature&lt;/strong&gt; as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./coin.install.sh fetch build --no-prompt --main-proj=Blis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will not do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now: outdated documentation is very common. But here there is a cure (and this covers most Coin-OR projects): &lt;strong&gt;Continuous Integration&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main-page will show you some CI-buttons under section &lt;em&gt;TESTING STATUS&lt;/em&gt; and it's green, so how hard can it be?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We might follow this one and arrive at some &lt;a href=&quot;https://travis-ci.org/coin-or/CHiPPS-BLIS/jobs/506947381&quot; rel=&quot;nofollow noreferrer&quot;&gt;Travis-CI build&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we can emulate what's been done there and this case: we directly see the problem from before: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export PROJECT=`echo $TRAVIS_REPO_SLUG | cut -d &quot;/&quot; -f 2`&#xA;./coin.install.sh fetch --no-prompt --main-proj=$PROJECT &amp;gt; /dev/null&#xA;&#xA;-&amp;gt; either one tries to understand the export syntax or one restrict to guessing&#xA;-&amp;gt; it's just the name within the travis-address:&#xA;    -&amp;gt; https://travis-ci.org/coin-or/CHiPPS-BLIS/jobs/506947381)&#xA;&#xA;CHiPPS-BLIS is the project name needed for COIN-OR-OptimizationSuite&#xA;&#xA;Blis (as mentioned in Install.md) is not used (and won't work)!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now there are other important things in those build-logs helping to make something work. We see for example which version is checked out (and guaranteed to build assuming we got the same sane system) and some dir-change order to follow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, these CI-scripts, when maintained, really seems to help and i won't miss out on these in the future. The above was some Coin-focused example, but recently, i again failed following official install guides and made it work following CI with &lt;a href=&quot;https://github.com/google/or-tools&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google's or-tools&lt;/a&gt; (Coin deps, Protobuf deps and co.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it's safe to assume, that outdated documentation is more common than failed and unhandled CI-checks which will result in some ugly &lt;em&gt;broken&lt;/em&gt; flags (and usually E-Mails).&lt;/p&gt;&#xA;" OwnerUserId="231" LastEditorUserId="231" LastEditDate="2019-06-20T14:55:23.950" LastActivityDate="2019-06-20T14:55:23.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="632" PostTypeId="1" AcceptedAnswerId="902" CreationDate="2019-06-20T15:01:44.493" Score="13" ViewCount="1629" Body="&lt;p&gt;We are coding a Benders decomposition using CPLEX/Concert (C++) and we are having some troubles to generate a feasibility cut because we are not sure how to get an extreme ray of the dual for a primal infeasible problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to this &lt;a href=&quot;http://www-01.ibm.com/support/docview.wss?uid=swg21400058&quot; rel=&quot;noreferrer&quot;&gt;CPLEX FAQ&lt;/a&gt;, there are two ways to do that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;To solve the problem using Primal Simplex, and use &lt;code&gt;getDuals()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;To solve the problem using Dual Simplex, and use &lt;code&gt;dualFarkas()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;We are obtaining strange values using (1). We found some discussion (&lt;a href=&quot;https://www.ibm.com/developerworks/community/forums/html/threadTopic?id=77777777-0000-0000-0000-000014486650&quot; rel=&quot;noreferrer&quot;&gt;like this one&lt;/a&gt;) saying that &lt;code&gt;getDuals&lt;/code&gt; only gives you a feasible point of the dual, not an extreme ray. I'm not sure if this is true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We also tried method (2) following the instructions &lt;a href=&quot;https://orinanobworld.blogspot.com/2011/07/farkas-certificates-in-cplex.html&quot; rel=&quot;noreferrer&quot;&gt;from this blog&lt;/a&gt;, but we are having trouble porting the Java's code to C++, apparently, because the order of the dual variables returned by &lt;code&gt;dualFarkas()&lt;/code&gt; is not clear. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All previous blogs and forums are quite old (~2010). That's why I'm questioning myself which is the correct way to obtain this extreme ray. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help or hint is appreciated. &lt;/p&gt;&#xA;" OwnerUserId="73" LastEditorUserId="36" LastEditDate="2019-06-20T15:18:14.607" LastActivityDate="2019-07-06T11:38:02.043" Title="Correct way to get a dual extreme ray for an infeasible LP in CPLEX / C++" Tags="|linear-programming|cplex|duality|c++|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="633" PostTypeId="5" CreationDate="2019-06-20T15:19:19.213" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-20T15:19:19.213" LastActivityDate="2019-06-20T15:19:19.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="634" PostTypeId="4" CreationDate="2019-06-20T15:19:19.213" Score="0" Body="For questions about solving Operations Research problems using the C++ programming language. " OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-20T16:54:15.203" LastActivityDate="2019-06-20T16:54:15.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="635" PostTypeId="2" ParentId="621" CreationDate="2019-06-20T16:34:58.080" Score="5" Body="&lt;p&gt;Lagrangian relaxation is extremely common as an algorithmic method to solve facility location problems. Because many &quot;minisum&quot;-type problems (&lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median, uncapacitated facility location problem, etc.) tend to have very tight LP relaxation bounds, the Lagrangian bound is also very tight. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use of LR for facility location dates back to the 1970s—the main reference I know of from that time is &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/mnsc.23.8.789&quot; rel=&quot;noreferrer&quot;&gt;Cornuejols, Fisher, and Nemhauser (1977)&lt;/a&gt;, though there might be earlier examples too. Since it was difficult to solve LPs using the hardware and software of that time, LR methods had a big advantage over LP-based methods even though they produce the same bound (in theory). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But even today, LR-based methods for facility location are important. Even though CPLEX and Gurobi can solve very large facility location MIPs exactly, and quickly, there are problems that still cannot be solved well with those solvers. An example is the location–inventory model by &lt;a href=&quot;https://link.springer.com/article/10.1023/A:1020763400324&quot; rel=&quot;noreferrer&quot;&gt;Daskin, Coullard, and Shen (2002)&lt;/a&gt;, which is a mixed-integer &lt;em&gt;concave&lt;/em&gt; minimization problem, but can be solved very efficiently by LR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know, there isn't a lot of work on interpreting the Lagrange &lt;em&gt;multipliers&lt;/em&gt; themselves, but it could be done. It depends on the relaxation, of course. But for the most common relaxation for facility location (in which we relax the constraint of the form &#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_j y_{ij}=1\quad \forall i,$$&lt;/span&gt;&#xA;which says that each customer must be assigned to exactly one facility), a Lagrange multiplier can be interpreted as estimating the cost of having to assign a given customer.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-20T16:34:58.080" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="636" PostTypeId="2" ParentId="552" CreationDate="2019-06-20T17:20:32.003" Score="5" Body="&lt;p&gt;Let us say that we have two MILP formulations &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; on the same variables, each with the corresponding LP relaxations defining polyhedra &lt;span class=&quot;math-container&quot;&gt;$P_A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_B$&lt;/span&gt;, respectively. We say that &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is stronger than &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; if every point of &lt;span class=&quot;math-container&quot;&gt;$P_A$&lt;/span&gt; is also contained in &lt;span class=&quot;math-container&quot;&gt;$P_B$&lt;/span&gt; whereas some points of &lt;span class=&quot;math-container&quot;&gt;$P_B$&lt;/span&gt; are not contained in &lt;span class=&quot;math-container&quot;&gt;$P_A$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you may prove the first direction by showing that the constraints  of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; imply the constraints  of &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; by Farkas lemma, and then prove the second direction by finding a point that is separated by some constraint of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and not separated by any constraint of &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case that the formulations are on different variables but we can find a mapping between how MILP solutions are represented in A and B, then we can still check if each solution in &lt;span class=&quot;math-container&quot;&gt;$P_A$&lt;/span&gt; maps to a solution in &lt;span class=&quot;math-container&quot;&gt;$P_B$&lt;/span&gt; and vice-versa.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2019-06-20T17:27:02.977" LastActivityDate="2019-06-20T17:27:02.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="637" PostTypeId="2" ParentId="621" CreationDate="2019-06-20T18:15:14.753" Score="6" Body="&lt;p&gt;For an application to very large set covering problems you can see e.g. &lt;a href=&quot;https://www.researchgate.net/publication/200035262_Algorithms_for_the_Set_Covering_Problem&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; This approach can be extended  (somehow) to general MILPs and allows one to quickly find a “core” set of variables defining heuristically a restricted MILP to be solved by Cplex or alike. &lt;/p&gt;&#xA;" OwnerUserId="429" LastEditorUserId="429" LastEditDate="2019-06-20T18:25:15.380" LastActivityDate="2019-06-20T18:25:15.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="638" PostTypeId="1" CreationDate="2019-06-20T18:25:54.720" Score="3" ViewCount="1364" Body="&lt;p&gt;&lt;strong&gt;I am looking for an efficient algorithm to generate all of the unique graphs for a given number of nodes.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For small instances, the total number of graphs are as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;n=2 G=2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;n=3 G=4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;n=4 G=11&lt;/p&gt;&#xA;&#xA;&lt;p&gt;n=5 G=34&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used the complementarity property of graphs to make it easier to enumerate all of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bXsRI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bXsRI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FNTYq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FNTYq.png&quot; alt=&quot;[3]: https://i.stack.imgur.com/pAE51.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="622" LastEditorUserId="56" LastEditDate="2019-07-02T15:07:10.890" LastActivityDate="2022-08-19T13:59:05.360" Title="Is there any way to generate all the possible undirected graphs with unlabeled nodes?" Tags="|graphs|algorithms|" AnswerCount="4" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="639" PostTypeId="2" ParentId="638" CreationDate="2019-06-20T19:28:44.197" Score="7" Body="&lt;p&gt;See &lt;a href=&quot;http://oeis.org/A000088&quot; rel=&quot;noreferrer&quot;&gt;http://oeis.org/A000088&lt;/a&gt;, which gives a different number (34) for n = 5.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-06-20T19:28:44.197" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="640" PostTypeId="2" ParentId="572" CreationDate="2019-06-20T20:16:34.680" Score="5" Body="&lt;p&gt;Highly degenerate LP's can be very hard to solve using the simplex method and much easier to solve using an interior point method.  It's possible that your LP relaxation has this issue.  &lt;/p&gt;&#xA;" OwnerUserId="103" LastActivityDate="2019-06-20T20:16:34.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="641" PostTypeId="1" CreationDate="2019-06-20T20:16:40.097" Score="13" ViewCount="2701" Body="&lt;p&gt;I have a directed social network and as a preprocessing step I need to calculate the longest path lengths for each node. Longest path problem is NP-hard as far as I know but I've seen dynamic programming methods for DAGs. Is there such a method for general networks with cycles? All arc weights are one.&lt;/p&gt;&#xA;" OwnerUserId="632" LastEditorUserId="354" LastEditDate="2019-06-21T11:16:14.330" LastActivityDate="2019-06-27T23:17:11.863" Title="Are there any efficient algorithms to solve the longest path problem in networks with cycles?" Tags="|combinatorial-optimization|computational-complexity|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="642" PostTypeId="2" ParentId="632" CreationDate="2019-06-20T20:20:16.430" Score="3" Body="&lt;p&gt;Have not used CPLEX, but I've done that in Gurobi. In the latter, you just retrieve the equivalent of dualFarkas() when the primal version of the Benders subproblem you are solving is infeasible.&lt;/p&gt;&#xA;" OwnerUserId="501" LastActivityDate="2019-06-20T20:20:16.430" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="643" PostTypeId="5" CreationDate="2019-06-20T20:57:00.760" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-20T20:57:00.760" LastActivityDate="2019-06-20T20:57:00.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="644" PostTypeId="4" CreationDate="2019-06-20T20:57:00.760" Score="0" Body="For questions related to Operations Research for government applications, with governmental sponsorship or funding, or OR conducted by the government.  Tag applies to both State and Federal levels in the United States, and similarly outside of the United States. " OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-21T11:18:33.763" LastActivityDate="2019-06-21T11:18:33.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="646" PostTypeId="2" ParentId="608" CreationDate="2019-06-20T21:19:15.177" Score="12" Body="&lt;p&gt;When pricing &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt;, there are two possibilities:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; is not in the restricted master problem / &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; has not been added before.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In this case, &lt;span class=&quot;math-container&quot;&gt;$x_j=0$&lt;/span&gt; in the current solution. The constraint &lt;span class=&quot;math-container&quot;&gt;$x_j \le 1$&lt;/span&gt; is not active, such that the associated multiplier is equal to 0. It is thus not a problem that the constraint was not added to the restricted master problem, and the dual can safely be ignored.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; is in the restricted master problem / &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; has been added before.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In this case, you have already added the constraint &lt;span class=&quot;math-container&quot;&gt;$x_j \le 1$&lt;/span&gt; earlier, such that the multiplier is available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the multiplier of &lt;span class=&quot;math-container&quot;&gt;$x_j \le 1$&lt;/span&gt;, say &lt;span class=&quot;math-container&quot;&gt;$\lambda_j$&lt;/span&gt;, should only be added for the variable &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt;. This is needed to prevent finding variables that have been added before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this may severely complicate the pricing problem. In vehicle routing, for example, you would have to add &lt;span class=&quot;math-container&quot;&gt;$\lambda_j$&lt;/span&gt; for one specific route only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As proposed by Sune, you can often avoid the upper bound on &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; altogether, which is definitely preferred if possible.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-06-20T21:19:15.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="647" PostTypeId="2" ParentId="641" CreationDate="2019-06-20T21:42:48.717" Score="13" Body="&lt;p&gt;There is no theoretically efficient method, unless P=NP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Hamiltonian_path_problem&quot; rel=&quot;noreferrer&quot;&gt;Hamiltonian Path Problem&lt;/a&gt; is the problem of determining whether there exists a path in an undirected or directed graph that visits each vertex exactly once. This problem is NP-complete (see link).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you could determine the longest path efficiently, you could do so for every starting point and ending point. If for any pair the length is equal to the number of points minus one, you have proven that there exists an Hamiltonian path. If not, then there is no Hamiltonian path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It follows that determining the longest path must be NP-hard.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-06-20T21:42:48.717" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="648" PostTypeId="2" ParentId="612" CreationDate="2019-06-20T22:48:10.380" Score="6" Body="&lt;p&gt;An alternative approach to the correct answer of @RobPratt to avoid the &quot;Big-M&quot; constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume that your indices in &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; can be ordered by the values of &lt;span class=&quot;math-container&quot;&gt;$c_p$&lt;/span&gt;. Then you add binary variables &lt;span class=&quot;math-container&quot;&gt;$y_p \in \{0,1\}$&lt;/span&gt; and the constraints &lt;span class=&quot;math-container&quot;&gt;$b_p\leq y_p$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_p \leq y_{p-1}$&lt;/span&gt; and  &lt;span class=&quot;math-container&quot;&gt;$y_p \leq \sum\limits_{k\geq p} b_p$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$p\in P$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Idea: &lt;span class=&quot;math-container&quot;&gt;$y_p=1$&lt;/span&gt; if and only if there is a &lt;span class=&quot;math-container&quot;&gt;$b_k=1$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$k\geq p$&lt;/span&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, you can add constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$l \leq c_0 y_0 + (c_1-c_0) y_1 + \ldots +  (c_{|P|}-c_{|P|-1})y_{|P|}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Idea: if &lt;span class=&quot;math-container&quot;&gt;$b_p=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y_0=y_1=\cdots=y_{p}=1$&lt;/span&gt;  and this forces that &lt;span class=&quot;math-container&quot;&gt;$l\leq c_p$&lt;/span&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the indices of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; have another order, the indices in the constraints can be easily permuted to obtain an equivalent formulation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Variables &lt;span class=&quot;math-container&quot;&gt;$y_p$&lt;/span&gt; don't need to be binary, just &lt;span class=&quot;math-container&quot;&gt;$y_p\in[0,1]$&lt;/span&gt;. Also, you don't neccesarily need constraints &lt;span class=&quot;math-container&quot;&gt;$b_p\leq y_p$&lt;/span&gt;. They are required to obtain an &lt;em&gt;if-and-only-if&lt;/em&gt; in the first idea, but in the context of the problem, the implication &lt;span class=&quot;math-container&quot;&gt;$y_p=1 \Longrightarrow b_k=1$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$k\geq p$&lt;/span&gt; is enough.   (Thanks @RenaudM for these comments)&lt;/p&gt;&#xA;" OwnerUserId="73" LastEditorUserId="73" LastEditDate="2019-06-21T17:52:01.247" LastActivityDate="2019-06-21T17:52:01.247" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="649" PostTypeId="2" ParentId="641" CreationDate="2019-06-21T00:24:13.447" Score="9" Body="&lt;p&gt;As observed by Kevin Dalmeijer, you cannot expect an efficient method unless &lt;span class=&quot;math-container&quot;&gt;$\sf{P=NP}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you're asking explicitly for dynamic programming: define &lt;span class=&quot;math-container&quot;&gt;$C(s,t,V)$&lt;/span&gt; as the longest path from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; without visiting the vertices in &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;. Values &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; satisfy&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;  C(s,t,V)=&#xA;  \begin{cases}&#xA;    \max\limits_{u\in N^{-}(t)\setminus V} C(s,u,V\cup\{t\})+d_{ut}, &amp;amp; \text{if $s\neq t$ and $N^{-}(t)\setminus V\neq \emptyset$},\\&#xA;    -\infty, &amp;amp; \text{if $s\neq t$ and $N^{-}(t)\setminus V=\emptyset$},\\&#xA;    0, &amp;amp; \text{if $s=t$},&#xA;  \end{cases}&#xA;\end{align*}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$N^-(t)$&lt;/span&gt; is the set of predecessors of vertex &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$d_{uv}$&lt;/span&gt; is the distance between &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;. Computing &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; for fixed &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; takes time &lt;span class=&quot;math-container&quot;&gt;$O(n^22^n)$&lt;/span&gt; and space &lt;span class=&quot;math-container&quot;&gt;$O(n2^n)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C(s,t,\emptyset)$&lt;/span&gt; gives the longest path between &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. &lt;/p&gt;&#xA;" OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-21T11:18:20.303" LastActivityDate="2019-06-21T11:18:20.303" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="651" PostTypeId="2" ParentId="552" CreationDate="2019-06-21T03:33:48.840" Score="5" Body="&lt;p&gt;Another way of looking at this is to construct randomized-rounding algorithms from both relaxations, and select the relaxation which yields a randomized rounding algorithm with the best approximation guarantee. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, in max-cut we can construct an LP relaxation which provides a &lt;span class=&quot;math-container&quot;&gt;$0.5$&lt;/span&gt; approximation ratio, or an SDP relaxation which provides a &lt;span class=&quot;math-container&quot;&gt;$0.878$&lt;/span&gt; approximation ratio, so the SDP relaxation is a better option (provided you can solve it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Admittedly, constructing randomized rounding methods might be more effort than its worth, but quite a bit of work has already been done in this area, so you can often get the relevant approximation ratios via a literature search. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.b. randomized rounding algorithms are typically agnostic to the objective function used, so i'm going to claim that this counts as not using an objective function ;)&lt;/p&gt;&#xA;" OwnerUserId="43" LastActivityDate="2019-06-21T03:33:48.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="652" PostTypeId="1" CreationDate="2019-06-21T06:43:38.893" Score="10" ViewCount="263" Body="&lt;p&gt;I am solving (or say, trying to find good solutions for) an arbitrary combinatorial optimization problem, think of it as a Vehicle Routing Problem with a bunch of side constraints that are not relevant for this question. I coded an Adaptive Large Neighborhood Search (ALNS) for it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to explore &quot;easy&quot; opportunities to enhance its speed by using some kind of parallelization, to at least make use of what every modern computer has available nowadays (more than a single core). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already tried two simple &quot;tweaks&quot;. 1) Simply run the ALNS for each available thread and pick the best solution at the end, and 2) Run the ALNS for each available thread, but ensure that after every X iterations each thread continues with the best solution of all the threads at that time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is if there are other alternatives to parallelize an ALNS which are easy to implement, won't require days of coding, and potentially impact the runtime/solution quality in a positive way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ps. I code in C++, so suggestions tailored towards that are welcome. &lt;/p&gt;&#xA;" OwnerUserId="48" LastEditorUserId="36" LastEditDate="2019-06-21T13:29:01.160" LastActivityDate="2019-06-21T13:29:01.160" Title="Parallelization of an existing Adaptive Large Neighbourhood Search Heuristic" Tags="|metaheuristics|c++|parallel-computing|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="653" PostTypeId="2" ParentId="652" CreationDate="2019-06-21T07:34:53.220" Score="2" Body="&lt;p&gt;I've implemented &lt;strong&gt;reproducible&lt;/strong&gt; &lt;strong&gt;parallelization&lt;/strong&gt; on a number of Local Search variants &lt;strong&gt;with incremental score calculation&lt;/strong&gt; (= delta constraint and fitness evaluation). Some of our requirements you might be able to forgo (most notably OO/FP support), but others (such as not sacrificing incremental calculation) are crucial to get better results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.optaplanner.org/blog/2018/07/03/AGiantLeapForwardWithMultithreadedIncrementalSolving.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;For more information, see this blog post&lt;/a&gt; and we're finishing up an academic paper that will include all the details too.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2019-06-21T12:29:04.447" LastActivityDate="2019-06-21T12:29:04.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="654" PostTypeId="2" ParentId="652" CreationDate="2019-06-21T07:43:03.180" Score="5" Body="&lt;p&gt;Another paradigm to parallelize search heuristics is the Backbone strategy. See for example &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/0010465596000628&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main idea is to run multiple instances of an arbitrary heuristic in parallel, and then compare the resulting solutions of each instance. &quot;structures&quot; (e.g. subtours in TSP) common in all/most solutions (called Backbones) are used to reduce the problem size (e.g. TSP: reduce the subtour to 2 nodes), and then the same approach is used on the reduced problem. &lt;/p&gt;&#xA;" OwnerUserId="47" LastActivityDate="2019-06-21T07:43:03.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="655" PostTypeId="2" ParentId="617" CreationDate="2019-06-21T07:52:04.577" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://timefold.ai&quot; rel=&quot;nofollow noreferrer&quot;&gt;Timefold&lt;/a&gt; (previous OptaPlanner) is an &lt;em&gt;open source constraint solver in Java&lt;/em&gt;.&#xA;It's:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Used across the globe in governments, Fortune 500 and other companies, startups, nonprofits, ...&lt;/li&gt;&#xA;&lt;li&gt;100% pure java - just a jar&lt;/li&gt;&#xA;&lt;li&gt;compatible with Kotlin too&lt;/li&gt;&#xA;&lt;li&gt;open source (Apache License), so you can modify/redistribute without fees&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;That being said, it has a OO/FP approach, which is very different if you're coming from a traditional MIP model approach. But it pays off if you need to scale to bigger datasets and want to integrate with other Java technologies.&lt;/p&gt;&#xA;&lt;p&gt;Other open source alternatives in Java/JVM include Choco, Oscar (= scala), the COIN-OR solvers, eclipse, jacop, ... IIRC&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2024-02-19T07:32:55.570" LastActivityDate="2024-02-19T07:32:55.570" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="656" PostTypeId="5" CreationDate="2019-06-21T12:16:19.093" Score="0" Body="&lt;p&gt;A time series is a series of data points indexed (or listed or graphed) in time order, so it is a sequence of discrete-time data. There are generally 3 distinguishing features of time-series data:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Arriving data is usually recorded as a new data point (appended to the data).&lt;/li&gt;&#xA;&lt;li&gt;Data arrival is usually ordered by time.&lt;/li&gt;&#xA;&lt;li&gt;The primary axis is time though the time intervals between data points may be regular or irregular.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Time series can be used to form predictions and have substantial applications in economics and signal processing.&lt;/p&gt;&#xA;&lt;p&gt;For further details see &lt;a href=&quot;https://en.wikipedia.org/wiki/Time_series&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia: Time Series&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="123" LastEditDate="2020-08-19T14:25:12.503" LastActivityDate="2020-08-19T14:25:12.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="657" PostTypeId="4" CreationDate="2019-06-21T12:16:19.093" Score="0" Body="For questions about sequential data indexed by time. Time intervals between data may be regular or irregular. " OwnerUserId="491" LastEditorUserId="123" LastEditDate="2020-02-09T20:22:13.780" LastActivityDate="2020-02-09T20:22:13.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="658" PostTypeId="2" ParentId="488" CreationDate="2019-06-21T13:47:12.583" Score="5" Body="&lt;p&gt;A similar idea has been used in the paper &lt;a href=&quot;http://doi.org/10.1137/0403036&quot; rel=&quot;noreferrer&quot;&gt;A Hierarchy of Relaxations between the Continuous and Convex Hull Representations for Zero-One Programming Problems&lt;/a&gt; by Sherali and Adams (1990).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the abstract (emphasis mine):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In this paper a reformulation technique is presented that takes a given linear zero-one programming problem, &lt;strong&gt;converts it into a zero-one polynomial programming problem&lt;/strong&gt;, and then relinearizes it into an extended linear program. It is shown that the strength of the resulting reformulation depends on the degree of the terms used to produce the polynomial program at the intermediate step of this method. In fact, as this degree varies from one up to the number of variables in the problem, &lt;strong&gt;a hierarchy of sharper representations is obtained with the final relaxation representing the convex hull of feasible solutions&lt;/strong&gt;. (...)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is, equalities like the one you propose can be used to derive stronger linear programming relaxations, up to the convex hull for zero-one programming problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The authors of the above paper also mention applications in generating strong or facetial valid inequalities. &lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-06-21T13:47:12.583" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="659" PostTypeId="5" CreationDate="2019-06-21T14:01:26.757" Score="0" Body="&lt;p&gt;This tag should be used when describing or referring to the attainment of a solution which maximizes or minimizes a particular objective function for a mathematical model &lt;em&gt;over the entire feasible domain&lt;/em&gt;. This will commonly be associated with Optimization, but other contexts may arise that warrant this tag. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;global&lt;/strong&gt; optimality refers to the attainment of a maximum or minimum objective function value &lt;strong&gt;over all possible (feasible)&lt;/strong&gt; solutions and should not be used when discussing &lt;a href=&quot;https://en.wikipedia.org/wiki/Local_optimum&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;local optimal&lt;/em&gt; solutions&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-21T19:01:05.990" LastActivityDate="2019-06-21T19:01:05.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="660" PostTypeId="4" CreationDate="2019-06-21T14:01:26.757" Score="0" Body="Use this tag for questions relating to an optimal (best) solution which attains the best objective function value over the entire set of feasible solutions. " OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-06-21T17:59:13.923" LastActivityDate="2019-06-21T17:59:13.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="661" PostTypeId="1" AcceptedAnswerId="1088" CreationDate="2019-06-21T14:18:40.950" Score="11" ViewCount="286" Body="&lt;p&gt;When solving large-scale hub assignment models (1000+ candidate hubs and 1000+ demand nodes), it is possible that parts of a cost matrix are not connected to one another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A typical workflow would be:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Read in data&lt;/li&gt;&#xA;&lt;li&gt;Create a graph (can be based on street or other network data)&lt;/li&gt;&#xA;&lt;li&gt;Create potential assignments with some cut off distance&lt;/li&gt;&#xA;&lt;li&gt;Calculate cost matrix&lt;/li&gt;&#xA;&lt;li&gt;Create formulation&lt;/li&gt;&#xA;&lt;li&gt;Solve&lt;/li&gt;&#xA;&lt;li&gt;Create output from solution&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is it better to create a separate formulation for each and solve?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OR&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it better to break the formulation apart into the sub-problems?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OR&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do solvers just handle this (my experience would say no...)?&lt;/p&gt;&#xA;" OwnerUserId="259" LastEditorUserId="51" LastEditDate="2019-07-29T15:12:32.237" LastActivityDate="2019-07-29T15:12:32.237" Title="partitioning hub assignment models" Tags="|modeling|algorithms|facility-location|hub-location|cost-matrix|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="662" PostTypeId="2" ParentId="179" CreationDate="2019-06-21T15:16:14.633" Score="7" Body="&lt;p&gt;You can check the &lt;code&gt;Test Sets&lt;/code&gt; section of the &lt;a href=&quot;https://stoprog.org/resources&quot; rel=&quot;nofollow noreferrer&quot;&gt;Stochastic Programming Resources&lt;/a&gt; website. It contains different types of problems — two-stage or multi-stage, mixed or pure IP, and even LP in the different stages. Hopefully, you should find something close to the problem type you are looking for.&lt;/p&gt;&#xA;" OwnerUserId="635" LastEditorUserId="123" LastEditDate="2022-04-29T12:41:20.267" LastActivityDate="2022-04-29T12:41:20.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="663" PostTypeId="2" ParentId="617" CreationDate="2019-06-21T16:14:27.507" Score="1" Body="&lt;p&gt;I once made CBC work from JAVA with &lt;a href=&quot;https://developers.google.com/optimization/mip/integer_opt&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google's OR-Tools&lt;/a&gt;. From the &quot;free&quot; category, it should also allow to use GLPK.&lt;/p&gt;&#xA;" OwnerUserId="649" LastActivityDate="2019-06-21T16:14:27.507" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="664" PostTypeId="1" AcceptedAnswerId="665" CreationDate="2019-06-21T17:26:52.130" Score="12" ViewCount="444" Body="&lt;p&gt;I have been going through Andrew NG's original data science course on Coursera. I learned the &lt;a href=&quot;https://en.wikipedia.org/wiki/Broyden%E2%80%93Fletcher%E2%80%93Goldfarb%E2%80%93Shanno_algorithm&quot; rel=&quot;noreferrer&quot;&gt;BFGS&lt;/a&gt; algorithm at some point in my OR education, but not the &lt;a href=&quot;https://en.wikipedia.org/wiki/Limited-memory_BFGS&quot; rel=&quot;noreferrer&quot;&gt;Limited Memory&lt;/a&gt; version that Andrew NG focuses on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a practical point of view, are there some scenarios where it makes sense to use the original BFGS? Usually limited memory means slower computation, but it is not clear to me ML packages even give the user a choice between the two.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2019-06-22T09:25:13.480" Title="When is the original BFGS algorithm still better than the Limited-Memory version?" Tags="|nonlinear-programming|computational-complexity|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="665" PostTypeId="2" ParentId="664" CreationDate="2019-06-21T17:40:15.537" Score="9" Body="&lt;p&gt;If you have enough memory to use the non-limited memory version of BFGS, then, subject to the caveat below that not all BFGS (or LBFGS) implementations are equal, use that in preference to LBFGS (Limited Memory version of BFGS). I.e., a high quality LBFGS implementation may still perform better than a lower quality implementation of BFGS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not all BFGS implementations are equal. BFGS specifies only one aspect of the algorithm, and without further elaboration, does not distinguish between, trust region, line search, and unsafeguarded, among many other attributes. Some BFGS implementations require objective function gradient to be provided, while others do not and can use numerical differentiation for the gradient. BGFS implementations vary in what types of constraints they handle. They can markedly vary in the numerical robustness of the algorithm implementation, And they also vary in terms of what, if any, presolve algorithm they employ, which can be very significant if there are complicated and (partially) redundant constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most machine learning package authors either assume that all nonlinear optimization problems to be solved are so large that LBGS is required in place of BFGS, or they have only ever even heard of LBFGS, so don't know that non-limited memory version of BFGS exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, BFGS is not the only Quasi-Newton method. SR1 (Symmetric Rank One) is often superior to BFGS on highly non-convex problems. That is because the SR1 Hessian updates do not preserve positive definiteness. Therefore they can better adapt to non-convex and changing curvature, and so provide a better model (approximation) for optimization purposes of the objective function (or more generally, the Lagrangian, if there are nonlinear constraints), which can improve performance of the optimization algorithm.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-06-22T09:25:13.480" LastActivityDate="2019-06-22T09:25:13.480" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="666" PostTypeId="1" CreationDate="2019-06-21T19:25:41.677" Score="33" ViewCount="2466" Body="&lt;p&gt;&lt;strong&gt;&quot;All models are wrong, but some are useful&quot; - George E. P. Box&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I usually work on what one could call operational problems. There I usually do not have too much trouble figuring out the level of detail needed for a model to provide value. However, when I happen to work on tactical/strategic problems I struggle more to figure out the appropriate level of detail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give some support for the discussion, consider this made up example:&#xA;Suppose that you are working on a problem where you want to determine the appropriate mix of vehicles to transport handicapped people from their home to the day-care center. You know that the demand varies every day but you want to decide which vehicles you need to buy to operate for the next 4 years.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some vehicles have a fixed configuration while others can be reconfigured (some seats can be folded and you can accommodate a wheel chair in place of 2 regular seats, for example). In an operational model you would definitely want to take this reconfiguration into account because it can make a difference between a “good” and a “bad” route. However, when solving a more long term problem in which you only have a partial view of what your demand will look like in 2 months from now does it make sense to take this into account? Or is it a step too far which is just going to make the model more complex/slow without really adding values to the solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR &#xA;How do you determine when your model is detailed enough to be useful?&#xA;When is an excess of detail actually hurting the model?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="124" LastEditorUserId="232" LastEditDate="2019-07-01T10:36:49.103" LastActivityDate="2019-07-01T10:36:49.103" Title="How to determine the correct level of detail when modelling?" Tags="|modeling|strategic-planning|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="667" PostTypeId="1" CreationDate="2019-06-21T19:39:08.283" Score="17" ViewCount="463" Body="&lt;p&gt;When working on an optimization project, what is the typical time division (in percentage) between the various tasks that you have to work on:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Problem understanding/definition (figuring out what is to be&#xA;optimised, what are the relevant constraints, etc...)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Interfacing of the data needed to solve the problem (getting the data from a database, a plain file, etc... into the application)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Determination of the actual solution method to be used to solve the problem (am I going to solve it using a MIP solver or a heuristic, which neighbourhoods am I going to use, which valid inequalities could help me)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Implementation of the solution method&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Re-working 3-4 to get better performance&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Visualisation of the resulting solution&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="124" LastEditorUserId="38" LastEditDate="2019-06-22T01:19:48.393" LastActivityDate="2019-06-24T21:59:52.667" Title="As an Operations Research professional, how is your time divided when working on an optimization project?" Tags="|optimization|modeling|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="668" PostTypeId="2" ParentId="179" CreationDate="2019-06-21T19:39:31.597" Score="5" Body="&lt;p&gt;&quot;&lt;em&gt;Ruszczynski, Andrzej, and Robert J. Vanderbei. &quot;Frontiers of stochastically nondominated portfolios.&quot; Econometrica 71.4 (2003): 1287-1297&lt;/em&gt;&quot;. This paper provides a large number of test problems which for example were used for testing purpose in &quot;&lt;em&gt;Dentcheva, Darinka, and Andrzej Ruszczyński. &quot;Portfolio optimization with stochastic dominance constraints.&quot; Journal of Banking &amp;amp; Finance 30.2 (2006): 433-451&lt;/em&gt;.&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following may or may not help to provide some benchmark problems but definitely worth a short glance:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the paper, &quot;&lt;em&gt;PySP: modeling and solving stochastic programs in Python&lt;/em&gt;&quot;, by &quot;Jean-Paul Watson, David L. Woodruff, and William E. Hart&quot;, the authors explained the third party software and packages related to PySP. One of those packages, &quot;&lt;em&gt;DET2STO&lt;/em&gt;&quot;, provide&#xA;a script taking an augmented AMPL model as input and generating the extensive form via an&#xA;SMPS output file.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-06-21T19:39:31.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="669" PostTypeId="2" ParentId="666" CreationDate="2019-06-21T20:04:25.517" Score="23" Body="&lt;p&gt;Interesting! Here are some questions that may be helpful to think through:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Will more detail substantially change the optimal solution?&lt;/li&gt;&#xA;&lt;li&gt;Am I including enough detail to answer the question I want to answer?&lt;/li&gt;&#xA;&lt;li&gt;If there are similar models for my problem, what do they include?&lt;/li&gt;&#xA;&lt;li&gt;What other details am I excluding? Could they have more of an effect that the dynamic I'm debating?&lt;/li&gt;&#xA;&lt;li&gt;Will a more precise answer be a more accurate answer? (E.g., if data for the extra details are wrong, including them may give a better solution to the wrong problem)&lt;/li&gt;&#xA;&lt;li&gt;What are my computational limitations? (E.g., if I don't have to solve the problem very often, maybe a longer solution time with a better answer is the way to go.)&lt;/li&gt;&#xA;&lt;li&gt;What level of detail does my client/collaborator need to &quot;trust&quot; the model?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some downsides to excess detail include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Longer solution time/tractability&lt;/li&gt;&#xA;&lt;li&gt;Risk of obscuring key takeaways&lt;/li&gt;&#xA;&lt;li&gt;Bad data may lead astray&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To figure out whether more detail may affect the solution, one option is to do sensitivity/scenario analysis on the simpler model. For the example you give, that might be running the model with different levels of demand to see how the solution changes. If it doesn't change much, that may indicate you don't need to let it vary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of being able to answer the right question, that sounds obvious but perhaps a good practice to double-check. For the example you give, if the goal is to figure out what mix of vehicles to buy, the model should probably include all of the vehicle types/configuration options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking forward to other responses.&lt;/p&gt;&#xA;" OwnerUserId="56" LastActivityDate="2019-06-21T20:04:25.517" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="670" PostTypeId="2" ParentId="667" CreationDate="2019-06-21T23:21:39.860" Score="14" Body="&lt;p&gt;Personal experience, very rough estimates, these will obviously vary from person to person and from project to project. I have added a few significant items that weren't in the original question and tweaked one of the others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;0/ Making the case to clients and gatekeepers that we should adopt an OR solution&lt;/strong&gt; ~ 10%. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I work in a government agency where part of my job is looking for ways to help other people do their job better/more efficiently. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Despite stereotypes of government, my co-workers have been pretty receptive to change. But anything I propose is likely to require a significant investment of time and money on their part, and if it doesn't work they have to live with the consequences. So I need to get through various approval/endorsement processes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will undoubtedly be a bit different for people working in areas like private OR consulting. But going by the presentations I've attended, client engagement is a significant issue for most OR projects. Even if the Big Boss thinks your project is the best thing since sliced bread, if the operational staff who have to use it and the IT staff who have to help build it aren't supportive, it's likely to die.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1/ Problem understanding/definition (figuring out what is to be optimised, what are the relevant constraints, etc...)&lt;/strong&gt; ~ 30%&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Big messy complex systems. My last project required learning large amounts of macroeconomic theory just to understand the problem. Inevitably translation is required to reach a common understanding of what the requirements &lt;em&gt;really&lt;/em&gt; are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2/ Interfacing of the data needed to solve the problem (getting the data from a database, a plain file, etc... into the application)&lt;/strong&gt; ~ 10% &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be significantly higher if I had sole responsibility for the data wrangling, but generally I can hand most of that off to other people.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3/ Determination of the actual solution method to be used to solve the problem (am I going to solve it using a MIP solver or a heuristic, which neighbourhoods am I going to use, which valid inequalities could help me)&lt;/strong&gt; ~ 10%&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the problems I've worked on aren't complex in terms of OR theory (just as well, given how little I know of the theory!) and it's preferable to solve with one of the tools we already have available than to spend months trying to get new software products etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;4/ Implementation of the solution method&lt;/strong&gt; ~ 5%&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually, once I understand what the requirements are, coding them is pretty straightforward, with only a few that are challenging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;5/ Re-working 3-4 to get better performances&lt;/strong&gt; ~ 5%&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;6/ Visualisation and diagnostics for the resulting solution&lt;/strong&gt; ~ 10%&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've edited this from your original question, because non-visual diagnostics can also be important here. This one is quite variable - in some problems we can just recycle visualisation/diagnostic systems that already exist, in others we have to come up with new ones. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;7/ End-user training and documentation&lt;/strong&gt; ~ 10%&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So we can hand the OR solution over to end-users without needing to be there every time they use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;8/ Project management and admin&lt;/strong&gt; ~ 10%&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Planning work in order to meet deadlines. Reworking the plan when deadlines or circumstances change. Risk management. Coordinating with the IT team whose job it will be to integrate our solution into corporate systems. Software procurement. Finding staff to work on the project with me and coordinating their work (which can sometimes be more work than just doing the thing myself!) Communicating with stakeholders to keep them up to date on project progress. Probably some other things I've forgotten.&lt;/p&gt;&#xA;" OwnerUserId="546" LastActivityDate="2019-06-21T23:21:39.860" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="671" PostTypeId="5" CreationDate="2019-06-22T01:23:16.477" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-22T01:23:16.477" LastActivityDate="2019-06-22T01:23:16.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="672" PostTypeId="4" CreationDate="2019-06-22T01:23:16.477" Score="0" Body="For questions about people related to Operations Research." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-23T20:18:53.067" LastActivityDate="2019-06-23T20:18:53.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="673" PostTypeId="2" ParentId="666" CreationDate="2019-06-22T01:43:13.143" Score="15" Body="&lt;p&gt;I think it's useful to think about &lt;em&gt;timescale&lt;/em&gt;, which is related to, but not equivalent to, level of detail. In particular, I think it is usually better to start with a model that does not include multiple, very different, timescales. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your hypothetical problem involving vehicle mix (strategic question, timescale = years) and seat configuration (operational question, timescale = days) is a great example of this. One would presumably want to start with a model that optimized one or the other, but not both. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this is not a hard-and-fast rule, and it is worth some experimentation.&#xA;If the shorter-timescale decisions do not significantly affect the longer-timescale ones, they should not be included in the model. So, if the optimal vehicle mix changes significantly when you include seat configuration in the model, seat configuration should be included in the vehicle mix model. Otherwise, it should not. (Probably it will not change the mix problem, so it should not be included.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, it is always a tradeoff. As another example, facility location is a strategic problem. So it's worth asking whether we should include tactical decisions like inventory or operational decisions like routing into the facility location decision.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of inventory, the inclusion of inventory &lt;em&gt;changes the optimal facility locations&lt;/em&gt;, and moreover in at least &lt;a href=&quot;https://doi.org/10.1287/trsc.37.1.40.12823&quot; rel=&quot;noreferrer&quot;&gt;some location–inventory models&lt;/a&gt;, the computational cost of adding inventory is relatively small. Therefore, it seems reasonable to include inventory in the facility location problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, routing tends not to change the optimal facility locations much (I believe—someone might want to check me on that), and moreover, &lt;a href=&quot;https://doi.org/10.1016/0377-2217(81)90212-5&quot; rel=&quot;noreferrer&quot;&gt;location–routing models are &lt;em&gt;much&lt;/em&gt; harder to solve&lt;/a&gt; than straight facility location models, so the tradeoff argues for not including routing, in general.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="56" LastEditDate="2019-06-28T13:18:25.920" LastActivityDate="2019-06-28T13:18:25.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="674" PostTypeId="1" AcceptedAnswerId="675" CreationDate="2019-06-22T03:35:27.670" Score="5" ViewCount="614" Body="&lt;p&gt;I am having issues with setting up constraints using both input arrays from excel and variable arrays within PuLP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;It appears the model only works with square matrices and my final code has a matrix that is 365x24.  The code below has a matrix of 5x6 and throws an error when running saying index out of range.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have provided the code that I am working with so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sheet11 Matrix&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;91  37  36  38  33  16&#xA;1   36  59  29  23  4&#xA;25  74  72  39  69  1&#xA;22  68  48  70  12  41&#xA;98  86  75  16  99  12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sheet12 Matrix&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;59  63  66  57  4   15&#xA;26  33  75  71  21  2&#xA;37  88  89  1   90  3&#xA;91  48  27  24  23  14&#xA;68  13  61  37  77  20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import *&#xA;from pandas import *&#xA;import pandas as pd&#xA;import numpy as np&#xA;import xlrd&#xA;&#xA;model = pulp.LpProblem(&quot;Basic Model&quot;, pulp.LpMinimize)&#xA;&#xA;YPER = 5&#xA;HE = 6&#xA;&#xA;yearlyhours = []&#xA;yearlyhours = [(i,j) for i in range(YPER) for j in range(HE)]&#xA;&#xA;book = xlrd.open_workbook('Stack.xlsx')&#xA;sheet11 = book.sheet_by_name('Sheet11')&#xA;sheet12 = book.sheet_by_name('Sheet12')&#xA;sheet13 = book.sheet_by_name('Sheet13')&#xA;&#xA;TEST = [[sheet11.cell_value(i,j) for i in range(YPER)] for j in range(HE)]&#xA;YAPR = [[sheet12.cell_value(i,j) for i in range(YPER)] for j in range(HE)]&#xA;MAPR = [[sheet13.cell_value(i,j) for i in range(YPER)] for j in range(HE)]&#xA;&#xA;YAHL = pulp.LpVariable.dicts(&quot;YAHL&quot;, (range(YPER), range(HE)), lowBound=0, cat='Continuous')&#xA;MAHL = pulp.LpVariable.dicts(&quot;MAHL&quot;, (range(YPER), range(HE)), lowBound=0, cat='Continuous')&#xA;&#xA;##OBJECTIVE##&#xA;model += pulp.lpSum([YAPR[i][j] * YAHL[i][j] + MAPR[i][j] * MAHL[i][j] for i in range(YPER) for j in range(HE)]), 'Sum_of_Value'&#xA;&#xA;for i,j in yearlyhours:&#xA;    model += pulp.lpSum([YAHL[i][j] + MAHL[i][j]]) == ([TEST[i][j]])&#xA;&#xA;LpSolverDefault.msg = 1&#xA;model.writeLP('Opt.lp')&#xA;model.solve()&#xA;pulp.LpStatus[model.status]&#xA;print(&quot;Status:&quot;, LpStatus[model.status])&#xA;obj = value(model.objective)&#xA;print(&quot;Total Cost: ${}&quot;.format(obj,2))&#xA;print('\n')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When changing to a non-square matrix the following error message is given:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IndexError: list index out of range&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help appreciated as I am still learning.&lt;/p&gt;&#xA;" OwnerUserId="662" LastEditorUserId="162" LastEditDate="2019-06-22T21:09:35.057" LastActivityDate="2019-06-22T21:09:35.057" Title="Python PuLP - Unable to Model Non-Square Matrix" Tags="|optimization|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="675" PostTypeId="2" ParentId="674" CreationDate="2019-06-22T05:57:27.127" Score="5" Body="&lt;p&gt;I think that the issue is the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;YAPR = [[sheet12.cell_value(i,j) for i in range(YPER)] for j in range(HE)]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you create a list of list (YAPR) to represent your matrix. The outer list has a length of HE and the inner lists have a length of YPER.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;model += pulp.lpSum([YAPR[i][j] * YAHL[i][j] + MAPR[i][j] * MAHL[i][j] for i in range(YPER) for j in range(HE)]), 'Sum_of_Value'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you address the list of list YAPR as if the outer list had a size of YPER and the inner list a size of HE. This is causing your out of bounds exception. You do not have the issue with square matrix because then YPER=HE which means that swapping the dimensions does not cause to go out of bounds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably want to review your complete model because I saw those indices inversion on multiple lines.&lt;/p&gt;&#xA;" OwnerUserId="124" LastEditorUserId="124" LastEditDate="2019-06-22T16:48:20.267" LastActivityDate="2019-06-22T16:48:20.267" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="678" PostTypeId="1" AcceptedAnswerId="681" CreationDate="2019-06-22T12:47:20.663" Score="16" ViewCount="1084" Body="&lt;p&gt;Prove that these linear programming problems are bounded by &lt;span class=&quot;math-container&quot;&gt;$O(k^{1/2})$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conjecturally the expanded partial sums of the Möbius transform of the Harmonic numbers have two out of three properties in common with this set of linear programming problems:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{ll} \text{minimize} &amp;amp; \displaystyle\sum_{n=1}^{n=k} \frac{x_{n}}{n} \\ \text{subject to constraints:} &amp;amp; k + \displaystyle\sum_{n=2}^{n=k}x_{n}=1 \\ &amp;amp; x_1 \geq -1 \end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for all &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and for &lt;span class=&quot;math-container&quot;&gt;$n&amp;gt;1:$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$-2(n-1) \leq x_n \leq 0 \tag{4}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, there is one linear programming problem for each &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sequence I get is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$${-(1/2), -1, -(4/3), -(5/3), -2, -(7/3), -(31/12), -(17/6), -(37/&#xA;  12), -(10/3), -(43/12), -(23/6), -(121/30), -(127/30), -(133/30), -(&#xA;  139/30), -(29/6), -(151/30), -(157/30), -(163/30), -(28/5),...}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Based on a OEIS search, the solutions &lt;span class=&quot;math-container&quot;&gt;$f(k)$&lt;/span&gt; to the linear programming problems (without the first column) appear to have the asymptotic:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f(k)=-\left(2 \sqrt{k}-2 \log \left(\sqrt{k}+1\right)-2 \gamma +1\right) \tag{5}$$&lt;/span&gt;&#xA;  Is it true?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Please don't be so harsh on me. If the problem is ill defined in the latex I post the short Mathematica program from which I defined the optimization problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(*start*)&#xA;nn = 180;&#xA;TableForm[&#xA;  L2 = Table[&#xA;    LinearProgramming[&#xA;     Table[1/n, {n, 1, k}], {Table[If[n == 1, k, 1], {n, 1, k}]}, {{1,&#xA;        0}}, Table[&#xA;      If[n == 1, {-1, 1}, {-2 (n - 1), 0 (n - 1)}], {n, 1, k}]], {k, &#xA;     1, nn}]];&#xA;t1 = Table[Sum[L2[[n, k]]/k, {k, 2, n}], {n, 2, nn}];&#xA;t2 = Table[-(2*k^(1/2) + 1 - 2*Log[k^(1/2) + 1] - 2*EulerGamma), {k, &#xA;    2, nn}];&#xA;Show[ListLinePlot[t1], ListLinePlot[t2, PlotStyle -&amp;gt; Red]]&#xA;ListLinePlot[t1/t2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The blue curve is the linear programming minimum and the red curve is the asymptotic.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/X3ERP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/X3ERP.jpg&quot; alt=&quot;asymptotic and linear programming minimum&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Zoom in:&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/GUp9C.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GUp9C.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ratio between the linear programming minimum and the asymptotic tends to one.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tzUoE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tzUoE.jpg&quot; alt=&quot;ratio of blue and red curve&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So as I said this is NOT a bound on the partial sums of the Möbius inverse of the Harmonic numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solutions &lt;span class=&quot;math-container&quot;&gt;$x_1,\cdots,x_k$&lt;/span&gt; to the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-th linear programming problem form a number triangle:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{llllllllllll}&#xA; 1 &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} \\&#xA; 1 &amp;amp; -1 &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} \\&#xA; 1 &amp;amp; -2 &amp;amp; 0 &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} \\&#xA; 1 &amp;amp; -2 &amp;amp; -1 &amp;amp; 0 &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} \\&#xA; 1 &amp;amp; -2 &amp;amp; -2 &amp;amp; 0 &amp;amp; 0 &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} \\&#xA; 1 &amp;amp; -2 &amp;amp; -3 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} \\&#xA; 1 &amp;amp; -2 &amp;amp; -4 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} \\&#xA; 1 &amp;amp; -2 &amp;amp; -4 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} \\&#xA; 1 &amp;amp; -2 &amp;amp; -4 &amp;amp; -2 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \text{} &amp;amp; \text{} &amp;amp; \text{} \\&#xA; 1 &amp;amp; -2 &amp;amp; -4 &amp;amp; -3 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \text{} &amp;amp; \text{} \\&#xA; 1 &amp;amp; -2 &amp;amp; -4 &amp;amp; -4 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \text{} \\&#xA; 1 &amp;amp; -2 &amp;amp; -4 &amp;amp; -5 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first column is here equal to the all ones sequence because Mathematicas linear programming command seems to require it. But setting the constraint to begin with &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; (in the linear program in the beginning of the question) makes it equivalent to the first column in the numerators for partial sums of the Möbius inverse of the Harmonic numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Counting only the negative entries in each row we find with a OEIS search that their number appear to be nearest integer to square root of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, and from there it becomes easy to conjecture formula &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The partial sums of the Möbius inverse of the Harmonic numbers have the numerators:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$J(m,k)=\begin{array}{lllllll}&#xA; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA; 2 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA; 3 &amp;amp; 0 &amp;amp; -2 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA; 4 &amp;amp; -1 &amp;amp; -1 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA; 5 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; -4 &amp;amp; 0 &amp;amp; 0 \\&#xA; 6 &amp;amp; -1 &amp;amp; -2 &amp;amp; -1 &amp;amp; -3 &amp;amp; 2 &amp;amp; 0 \\&#xA; 7 &amp;amp; 0 &amp;amp; -1 &amp;amp; 0 &amp;amp; -2 &amp;amp; 3 &amp;amp; -6&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;given by the sum:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum _{n=1}^m \text{If}[n\geq k,a(\gcd (n,k)),0]$$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;for&lt;br&gt;&#xA; &lt;span class=&quot;math-container&quot;&gt;$n=1,\cdots,m$&lt;/span&gt;,&lt;br&gt;&#xA; &lt;span class=&quot;math-container&quot;&gt;$k=1,\cdots,N$&lt;/span&gt;,&lt;br&gt;&#xA; &lt;span class=&quot;math-container&quot;&gt;$m=1,\cdots,N$&lt;/span&gt;.&#xA;and where &lt;span class=&quot;math-container&quot;&gt;$a(n)$&lt;/span&gt; is the Dirichlet inverse of the Euler totient function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The properties are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k=1}^{k=n} \frac{J(n,k)}{k}=\sum _{k=1}^n \text{If}\left[n \bmod k=0,H_k \mu \left(\frac{n}{k}\right),0\right]$$&lt;/span&gt;&#xA;which is the partial sums of the Möbius inverse of the m-th harmonic number&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k=1}^{k=n}J(n,k)=1$$&lt;/span&gt; as in the constraint in the linear programming problem.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$J(n,1)=n$$&lt;/span&gt; as in the linear programming problem (but in the linear programming problem it is in the constraint and not the goal function because of some Mathematica technicality.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last property, for all &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$-2(k-1) \leq J(n,k) \leq 2(k-1)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is conjectural and differs from the linear programming problem.&#xA;This last conjectural property should not be too hard to prove.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(*Numerators of the partial sums of the Möbius inverse of the \&#xA;Harmonic numbers*)(*start*)&#xA;Clear[T, n, k, a];&#xA;nn = 7;&#xA;a[n_] := If[n &amp;lt; 1, 0, Sum[d MoebiusMu@d, {d, Divisors[n]}]]&#xA;TableForm[&#xA; M = Table[&#xA;   Table[Sum[If[n &amp;gt;= k, a[GCD[n, k]], 0], {n, 1, m}], {k, 1, nn}], {m,&#xA;     1, nn}]]&#xA;Table[Sum[M[[n, k]]/k, {k, 2, n}], {n, 1, nn}] (*&amp;lt;--sequence to be bounded*)&#xA;(*end*)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Previously asked yesterday at Mathematics stack exchange, where I was not understood. I also asked about the notation at &lt;a href=&quot;https://mathematica.stackexchange.com/q/200836/328&quot;&gt;Mathematica stack exchange&lt;/a&gt;. And I also asked it at &lt;a href=&quot;https://mathoverflow.net/q/334570/25104&quot;&gt;mathoverflow&lt;/a&gt; but was sent here.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit 14.10.2019:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words this linear programming problem is valid for the partial sums of the Möbius inverse of the Harmonic numbers:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{ll} \text{minimize} &amp;amp; \displaystyle\sum_{n=1}^{n=k} \frac{x_{n}}{n} \\ \text{subject to constraints:} &amp;amp; k + \displaystyle\sum_{n=2}^{n=k}x_{n}=1 \\ &amp;amp; x_1 \geq -1 \end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for all &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and for &lt;span class=&quot;math-container&quot;&gt;$n&amp;gt;1:$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$-2(n-1) \leq x_n \leq 2(n-1)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: 24.10.2019&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JvALu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JvALu.png&quot; alt=&quot;Numerators of Dirichlet inverse of Euler totient function expansion of Möbius inverse of Harmonic numbers&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keyword(s) for Google searches: Square root bound&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit 13.4.2020:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(*start*)&#xA;Clear[A];&#xA;nn = 20;&#xA;L = LinearProgramming[&#xA;   Flatten[Table[Table[1/k, {k, 1, n}], {n, 1, nn}]], &#xA;   Table[Flatten[&#xA;     Table[Table[If[n == i, 1, 0], {k, 1, n}], {n, 1, nn}]], {i, 1, &#xA;     nn}], Table[{1, 0}, {n, 1, nn}], &#xA;   Flatten[Table[&#xA;     Table[If[k == 1, {n, n}, {-(k - 1), (k - 1)}], {k, 1, n}], {n, 1,&#xA;       nn}], 1]];&#xA;TableForm[&#xA; A = Table[Take[L, {n*(n - 1)/2 + 1, n*(n + 1)/2}], {n, 1, nn}]]&#xA;(*end*)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XXFky.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XXFky.png&quot; alt=&quot;motivation for linear programming problem&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="671" LastEditorUserId="671" LastEditDate="2020-05-31T17:04:18.787" LastActivityDate="2020-05-31T17:04:18.787" Title="Prove that these linear programming problems are bounded by $O(k^{1/2})$" Tags="|linear-programming|bounds|knapsack|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="679" PostTypeId="2" ParentId="667" CreationDate="2019-06-22T15:27:22.357" Score="5" Body="&lt;p&gt;As @GeoffreyBrent said, it differs from project to project and from person to person and I agree with all of his 9 points. I just modify points 4-6 for a different flavor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Iteratively doing the following&lt;/strong&gt; &gt; 50%&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Implementation of the solution method for the problem at hand&lt;/li&gt;&#xA;&lt;li&gt;Debugging (lots of it)&lt;/li&gt;&#xA;&lt;li&gt;Check with the users for feedback and whether there are any requirements (constraints) that should be adjusted&lt;/li&gt;&#xA;&lt;li&gt;Update the problem at hand&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Deliver the solution&lt;/strong&gt; ~  &gt; 10%&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Almost always, this is more than just handing over the code, some reports, and some visualization of the results (if needed). The user may need to have a GUI or a web-interface or an executable of some sort. In cases that you are dealing with simpler or more straightforward OR problems (or shorter projects, if you will), this step can, in fact, take the majority of the time.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-06-22T15:27:22.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="680" PostTypeId="2" ParentId="666" CreationDate="2019-06-22T16:15:05.773" Score="12" Body="&lt;p&gt;Assuming that (a) the model is going to be used repeatedly, (b) solving the more complex version can be done in a tolerable (if perhaps longer) time and (c) the complexity does not rise to the level of blowing your credibility with the user, you might try coding both models, running both against a few reasonable scenarios (using different guesstimates for the uncertain parameters), and assess whether the solution to the more complex model looks meaningfully better than that of the less complex model. If the input data will be uncertain at the time the model will be used (as opposed to uncertain at development time but certain at production time), you might also try evaluating the solutions you got in the previous step against other scenarios besides the scenario that generated each one, to get a feel for how robust the models are. This is not as good as a full fledged simulation experiment, but perhaps better than just giving the user one model or the other and crossing your fingers.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-06-22T16:15:05.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="681" PostTypeId="2" ParentId="678" CreationDate="2019-06-22T21:02:47.350" Score="13" Body="&lt;p&gt;Your linear program is similar to a mathematical formulation of a bounded Knapsack problem and has a similar linear relaxation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First note that &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; is only restricted by &lt;span class=&quot;math-container&quot;&gt;$x_1\geq -1$&lt;/span&gt; and thus &lt;span class=&quot;math-container&quot;&gt;$x_1=-1$&lt;/span&gt; at optimality. The sum of remaining variables is bounded by &lt;span class=&quot;math-container&quot;&gt;$1-k$&lt;/span&gt; (indeed has to be equal to &lt;span class=&quot;math-container&quot;&gt;$1-k$&lt;/span&gt;) and since variables with lower indices have higher value in the objective function, each variable in order of increasing indices will be at its lower bound at optimality, until hitting the bound, with the possible exception of the last variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular for &lt;span class=&quot;math-container&quot;&gt;$k=3,7,13,\cdots,\ell(\ell+1)+1$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$\ell=1,2,\cdots$&lt;/span&gt; the optimal solution has variables &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2,\cdots,x_{\ell+1}$&lt;/span&gt; at their lower bounds and the remaining variables at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. The objective value for these solutions is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\sum_{i\in I}\frac{x_i}i = -1 +\sum_{i\in I} \frac{-2(i-1)}i = -1 - 2 \sum_{i\in I}\left(1-\frac1i\right)= 2\left(H_{\ell+1}-(\ell+1)\right)-1&#xA;\end{align*}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$I=[2,l+1]$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sequence you give seems to ignore the contribution &lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;, so for asymptotics we look at &lt;span class=&quot;math-container&quot;&gt;$2\left(H_{\ell+1}-(\ell+1)\right)$&lt;/span&gt;. Substituting &lt;span class=&quot;math-container&quot;&gt;$\ell=(\sqrt{4k-3}-1)/2$&lt;/span&gt; you get&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;2\left(H_{(\sqrt{4k-3}+1)/2}-(\sqrt{4k-3}+1)/2\right)\approx\ln(4k-3)-2\ln 2+2\gamma-(\sqrt{4k-3}+1)&#xA;\end{align*}&lt;/span&gt;&#xA;using &lt;span class=&quot;math-container&quot;&gt;$H_n\approx\ln n+\gamma$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="87" LastEditorUserId="123" LastEditDate="2019-08-04T08:39:46.370" LastActivityDate="2019-08-04T08:39:46.370" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="683" PostTypeId="5" CreationDate="2019-06-23T05:21:59.280" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-23T05:21:59.280" LastActivityDate="2019-06-23T05:21:59.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="684" PostTypeId="4" CreationDate="2019-06-23T05:21:59.280" Score="0" Body="For questions related to the design or implementation of algorithms (exact or heuristic) for solving optimization problems." OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-23T20:16:54.163" LastActivityDate="2019-06-23T20:16:54.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="685" PostTypeId="5" CreationDate="2019-06-23T05:33:37.743" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-23T05:33:37.743" LastActivityDate="2019-06-23T05:33:37.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="686" PostTypeId="4" CreationDate="2019-06-23T05:33:37.743" Score="0" Body="For questions related to the set covering problem. Having a set of elements, S, and a collection of sets whose union equals S, the set covering problem tries to identify the smallest sub-collection of sets whose union equals S." OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-23T20:18:46.287" LastActivityDate="2019-06-23T20:18:46.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="687" PostTypeId="1" AcceptedAnswerId="1169" CreationDate="2019-06-23T06:39:28.757" Score="8" ViewCount="2548" Body="&lt;p&gt;I wrote a branch-and-price algorithm in Python 2.7 which solves several small LP and MIP models by Gurobi 8.1 in each node. The algorithm runs fine at first, it produces both lower bound and upper bounds, solves all of the mentioned models many times. However after solving roughly 200 nodes suddenly Gurobi returns an Out of Memory error!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have 128 GB of RAM, of which 70% was free all the time during the algorithm execution. The models are written in different files and functions and called (imported) by the main file when necessary. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any hidden option that limits the RAM usage for Gurobi? Is it possible that the previous model builds affect the current one, considering that all of them are in the separate files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: I am using Window 10, Python 2.7.10 64-bit version and Gurobi 8.0.1 64-bit. I tried solving another single model with Gurobi and it could use the RAM without any problem. So I guess there is something wrong with my implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update2: &#xA;I have a Class called &quot;Node&quot;. During the algorithm I generate many instances of this class and assign three gurobi.Model instances to each them as their attributes. This obviously leads to excessive use of memory. Even frequently deleting Node instances by &quot;del&quot; command did not solve the problem. So I had to reorganize the algorithm to not store any of these gurobi.Model instances which significantly reduced the memory usage. This helped to avoid the Out of memory error. However, I am not sure what was causing the error. &lt;/p&gt;&#xA;" OwnerUserId="172" LastEditorUserId="47" LastEditDate="2019-07-27T18:36:57.067" LastActivityDate="2019-10-09T20:46:32.943" Title="Gurobi's &quot;Out of memory&quot; error without exhausting the RAM?" Tags="|python|gurobi|software|" AnswerCount="2" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="688" PostTypeId="5" CreationDate="2019-06-23T09:30:44.160" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-23T09:30:44.160" LastActivityDate="2019-06-23T09:30:44.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="689" PostTypeId="4" CreationDate="2019-06-23T09:30:44.160" Score="0" Body="For questions on constraints controlled by binary variables." OwnerUserId="87" LastEditorUserId="123" LastEditDate="2020-02-07T19:32:00.287" LastActivityDate="2020-02-07T19:32:00.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="690" PostTypeId="5" CreationDate="2019-06-23T09:42:09.960" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-23T09:42:09.960" LastActivityDate="2019-06-23T09:42:09.960" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="691" PostTypeId="4" CreationDate="2019-06-23T09:42:09.960" Score="0" Body="For questions on duals of (primal) mathematical programs that optimize the complementary bound. When minimizing, for example, primal solutions are upper bounds, and dual solutions lower bounds on the optimal value." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-23T22:47:19.807" LastActivityDate="2019-06-23T22:47:19.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="692" PostTypeId="5" CreationDate="2019-06-23T09:44:14.967" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-23T09:44:14.967" LastActivityDate="2019-06-23T09:44:14.967" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="693" PostTypeId="4" CreationDate="2019-06-23T09:44:14.967" Score="0" Body="For questions on constraints over random variables that need to be satisfied with a given probability." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-23T22:46:42.143" LastActivityDate="2019-06-23T22:46:42.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="694" PostTypeId="5" CreationDate="2019-06-23T09:45:22.380" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-23T09:45:22.380" LastActivityDate="2019-06-23T09:45:22.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="695" PostTypeId="4" CreationDate="2019-06-23T09:45:22.380" Score="0" Body="For questions on the commercial constraint solver CPLEX CP Optimizer." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-23T22:46:35.390" LastActivityDate="2019-06-23T22:46:35.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="696" PostTypeId="5" CreationDate="2019-06-23T09:46:39.170" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-23T09:46:39.170" LastActivityDate="2019-06-23T09:46:39.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="697" PostTypeId="4" CreationDate="2019-06-23T09:46:39.170" Score="0" Body="For questions on optimization problems that seek solutions that are globally optimal (in contrast to locally optimal solutions)." OwnerUserId="87" LastEditorUserId="123" LastEditDate="2020-08-19T13:47:07.680" LastActivityDate="2020-08-19T13:47:07.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="698" PostTypeId="5" CreationDate="2019-06-23T09:49:39.017" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-23T09:49:39.017" LastActivityDate="2019-06-23T09:49:39.017" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="699" PostTypeId="4" CreationDate="2019-06-23T09:49:39.017" Score="0" Body="For questions on the set of points that satisfy a finite set of linear inequalities." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-23T22:47:05.193" LastActivityDate="2019-06-23T22:47:05.193" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="700" PostTypeId="5" CreationDate="2019-06-23T09:58:10.333" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-23T09:58:10.333" LastActivityDate="2019-06-23T09:58:10.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="701" PostTypeId="4" CreationDate="2019-06-23T09:58:10.333" Score="0" Body="For questions on a method that transforms a subset of the linear inequalities of a linear program into an equivalent representation by its extreme points and rays; this generally introduces a large number of new variables." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-23T22:47:27.707" LastActivityDate="2019-06-23T22:47:27.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="702" PostTypeId="5" CreationDate="2019-06-23T09:59:53.657" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-23T09:59:53.657" LastActivityDate="2019-06-23T09:59:53.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="703" PostTypeId="4" CreationDate="2019-06-23T09:59:53.657" Score="0" Body="For questions on subsets of constraints of an infeasible mathematical program whose (strict) subsets are feasible. " OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-23T22:46:54.540" LastActivityDate="2019-06-23T22:46:54.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="704" PostTypeId="2" ParentId="666" CreationDate="2019-06-23T11:32:51.517" Score="7" Body="&lt;p&gt;Which problems are you trying to solve? What is an acceptable level of failures? The level of detail you need is bounded by those answers. You need a sufficiently detailed model where you can statistically prove a certain level of avoidance through the variants you expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trying to solve problems you don't know or have is not solvable by the same model, IMHO; don't try. Try simplifying. If normal operations are simple and non error prone, deviations will be easier to handle. &lt;/p&gt;&#xA;" OwnerUserId="683" LastActivityDate="2019-06-23T11:32:51.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="705" PostTypeId="2" ParentId="666" CreationDate="2019-06-23T19:36:56.350" Score="11" Body="&lt;p&gt;&lt;em&gt;The best model is the one that will make the users of the model make the best decisions.&lt;/em&gt; &#xA;This requires both that the solutions are high-quality and that the users actually use them to drive decisions. &#xA;It is therefore important always to keep the end-goal in mind when finding the balance between simplicity and complexity. &#xA;The following three tips can help you strike that balance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Be agile.&lt;/strong&gt;&#xA;Finding the right detail-level of a model from the start is almost impossible as it requires you to understand all aspects of the problem upfront i.e. operational aspects, available data, computational difficulties, and the decision-process the model is going to be used in. The most important thing is therefore to have an &lt;em&gt;iterative&lt;/em&gt; and &lt;em&gt;agile&lt;/em&gt; approach where you can learn new aspects of the problem along the way and tune your model. &#xA;Keep the end-users included in the process and get their ongoing feedback&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;When in doubt, leave it out.&lt;/strong&gt; Increasing the complexity of a model has a cost. It will be harder for you to explain to the end-users what is going on which can decrease adoption. It will also be more expensive to maintain and more difficult to extend further. &#xA;Often a model is only for decision-support, where the user can fine-tune the solution provided by the model before making the final decision. If a user can spend a few minutes and get the perfect solution, it might not be worth extending the model.&#xA;Therefore, if you are in doubt if something should be added, wait and get some feedback.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Ensure you understand the problem with your current model before you extend it.&lt;/strong&gt;&#xA;Users will often upfront list constraints and objectives that they think are critical for solving the problem. This doesn't imply that it should be part of your model. &#xA;Before you add a new constraint, ensure you understand exactly what solutions that the model is currently proposing that are not infeasible and why.&#xA;In the same way, before adding a new objective, ensure you understand when the model is proposing a solution where a better one exists.&#xA;Therefore, if you not sure if or why something will improve the decisions, probe the users more to understand where the output of the model is not working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, spend some time early in the process to find a good way of visualizing your solutions. This will make it much easier to get good feedback from users that will help you tune your model!&lt;/p&gt;&#xA;" OwnerUserId="140" LastActivityDate="2019-06-23T19:36:56.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="706" PostTypeId="5" CreationDate="2019-06-23T22:57:34.040" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-23T22:57:34.040" LastActivityDate="2019-06-23T22:57:34.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="707" PostTypeId="4" CreationDate="2019-06-23T22:57:34.040" Score="0" Body="For questions related to the formulation or solution methodologies of network flow problems. Some of the well-known network flow problems are maximum flow problem, minimum-cost flow problem, and multi-commodity flow problem." OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-06-24T10:03:27.400" LastActivityDate="2019-06-24T10:03:27.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="708" PostTypeId="2" ParentId="506" CreationDate="2019-06-24T00:39:21.287" Score="15" Body="&lt;p&gt;One neat example is in the context of network design problems and is brought about by the concept of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Steiner_point_(computational_geometry)&quot; rel=&quot;noreferrer&quot;&gt;Steiner node&lt;/a&gt;. In brief, a Steiner node is an auxiliary node that may or may not be included in a particular network design problem (say, a spanning tree or a survivable network design problem). Why would you ever need such a thing, since presumably adding such a node, optional by definition, would necessarily increase the solution cost, right? Wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider a minimum spanning tree problem defined on an equilateral triangle with each side equal to 1, for simplicity. Clearly, the MST solution would pick any two edges for a total cost of 2. Now, suppose that you're also allowed to place a &lt;strong&gt;fourth&lt;/strong&gt; node somewhere inside the triangle. Can you improve the solution cost? You could, if you remember your elementary geometry and place such a node precisely at the centroid (the intersection of the medians) of your triangle. You remember that the centroid is two thirds away from the vertex and one third away from the base and therefore the distance from the centroid to any vertex is &lt;span class=&quot;math-container&quot;&gt;$\sqrt{2}/3$&lt;/span&gt;. Therefore, connecting this Steiner node to each vertex creates a new MST on the original graph, with a total cost of &lt;span class=&quot;math-container&quot;&gt;$\sqrt{2} &amp;lt; 2$&lt;/span&gt;! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Watch:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vR1ty.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vR1ty.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remember correctly, this example comes from the wonderful book &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/B000SEKUUS&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to Solve It: Modern Heuristics&lt;/a&gt; by Zbigniew Michalewicz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Later edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, consider a telecommunication design problem, where each node in the given network has a connectivity requirement &lt;span class=&quot;math-container&quot;&gt;$\rho \ge 0$&lt;/span&gt; associated with it. Steiner nodes have &lt;span class=&quot;math-container&quot;&gt;$\rho=0$&lt;/span&gt;, meaning that they may or may not be included in the solution. So-called local access nodes have &lt;span class=&quot;math-container&quot;&gt;$\rho=1$&lt;/span&gt;, meaning they should be reachable via (at least) a path from any other node in the network. Backbone nodes have &lt;span class=&quot;math-container&quot;&gt;$\rho \ge 2$&lt;/span&gt;, meaning that any other node in the network must reach the backbone node via (at least) two edge disjoint paths. In such a problem, typically the objective is to minimize the cost, the constraints are enforcing the connectivity requirements and the decision variables are the edges that have to be included in the solution. The existence of Steiner nodes leads to potential solutions like the graphs above and explaining to a pointy-haired boss why they work explains the paradox.&lt;/p&gt;&#xA;" OwnerUserId="253" LastEditorUserId="253" LastEditDate="2019-07-03T15:23:12.753" LastActivityDate="2019-07-03T15:23:12.753" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="709" PostTypeId="1" CreationDate="2019-06-24T02:07:57.257" Score="18" ViewCount="1590" Body="&lt;p&gt;All of the applications of metaheuristics that I can think of are for &lt;strong&gt;discrete optimization&lt;/strong&gt; (usually combinatorial optimization) problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Are metaheuristics ever practical tools for continuous optimization problems?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched a bit on the web for this and found a few examples, but I get the sense that these examples are rather artificial and that metaheuristics are not usually a practical method for continuous optimization. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The exception might be the case of nonconvex, global optimization, in which case sometimes metaheuristics are used to find a good &lt;em&gt;starting solution&lt;/em&gt; and then continuous optimization is used to find the nearby local optimum. But one could argue that this is really like solving a discrete problem—the problem of choosing which local optimum to target—rather than actually doing any continuous optimization.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-24T02:41:27.380" LastActivityDate="2023-12-05T00:00:31.280" Title="Are metaheuristics ever practical for continuous optimization?" Tags="|nonlinear-programming|metaheuristics|" AnswerCount="8" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="710" PostTypeId="2" ParentId="666" CreationDate="2019-06-24T03:01:30.080" Score="7" Body="&lt;p&gt;Something in another dimension that hasn't been mentioned yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;size&quot; of the problem in its simplest form may inform which techniques are most useful. You may even be on the fringe of using just one technique and need to combine some. One thing that I have used for example is clustering techniques to pre-compute assignments thus removing a bunch of decision variables. You of course have to be careful as this may create packing issues if you are using integer assignments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example if you wanted to scale your current model to a 10 year time horizon. Does it make sense to model the detail or is something like cashflow more relevant?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further you could also start to exploit parts of the problem definition, you mention that its a pickup and drop off service. You can maybe bake in some assumptions that represent the potential routes for each customer, humans are quite predictable after all. This may remove the need to generate actual routes. The solutions can then be validated using your detailed model.&lt;/p&gt;&#xA;" OwnerUserId="259" LastActivityDate="2019-06-24T03:01:30.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="711" PostTypeId="1" AcceptedAnswerId="712" CreationDate="2019-06-24T03:40:25.183" Score="16" ViewCount="9769" Body="&lt;p&gt;How to formulate (linearize) a maximum function in a constraint? Suppose &lt;span class=&quot;math-container&quot;&gt;$C = \max \{c_1, c_2\}$&lt;/span&gt;, where both &lt;span class=&quot;math-container&quot;&gt;$c_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_2$&lt;/span&gt; are variables. If the objective function is minimizing &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, then it can be simply done by applying &lt;span class=&quot;math-container&quot;&gt;$C \geqslant c_1$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$C \geqslant c_2$&lt;/span&gt;. But if the objective function is non-regular, e.g. earliness tardiness, the value of &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; will be larger than the maximum of &lt;span class=&quot;math-container&quot;&gt;$c_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_2$&lt;/span&gt;. So my question is how to formulate it correctly?&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-04-01T04:08:04.570" LastActivityDate="2020-04-01T04:08:04.570" Title="How to formulate (linearize) a maximum function in a constraint?" Tags="|constraint|linearization|nonlinear-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="712" PostTypeId="2" ParentId="711" CreationDate="2019-06-24T04:03:00.103" Score="26" Body="&lt;p&gt;(&lt;em&gt;I'm going to change &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in my answer, since &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is usually used for cost coefficients, not decision variables.&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We want a set of constraints that enforces &lt;span class=&quot;math-container&quot;&gt;$X = \max\{x_1,x_2\}$&lt;/span&gt;. Define a new binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, which will equal 1 if &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;gt; x_2$&lt;/span&gt;, will equal 0 if &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;lt; x_2$&lt;/span&gt;, and could equal either if &lt;span class=&quot;math-container&quot;&gt;$x_1 = x_2$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; be a constant such that &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2 \le M$&lt;/span&gt; in any &quot;reasonable&quot; solution to the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following constraints enforce the definition of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;x_1 - x_2 &amp;amp; \le My \\&#xA;x_2 - x_1 &amp;amp; \le M(1-y)&#xA;\end{align}$$&lt;/span&gt;&#xA;Then, the following constraints enforce &lt;span class=&quot;math-container&quot;&gt;$X = \max\{x_1,x_2\}$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;X &amp;amp; \ge x_1 \\&#xA;X &amp;amp; \ge x_2 \\&#xA;X &amp;amp; \le x_1 + M(1-y) \\&#xA;X &amp;amp; \le x_2 + My.&#xA;\end{align}$$&lt;/span&gt;&#xA;The first two constraints say &lt;span class=&quot;math-container&quot;&gt;$X \ge \max\{x_1,x_2\}$&lt;/span&gt;, as you suggested in the question. Combined with these constraints, the last two constraints say that &lt;span class=&quot;math-container&quot;&gt;$X = x_1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;gt; x_2$&lt;/span&gt; (so &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$X = x_2$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_2 &amp;gt; x_1$&lt;/span&gt; (so &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; @EhsanK correctly pointed out to me that the first 2 constraints are not necessary. The 4 remaining constraints are sufficient to enforce the definition of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, and therefore of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For more on logical constraints, see &lt;a href=&quot;https://or.stackexchange.com/q/33/38&quot;&gt;In an integer program, how I can force a binary variable to equal 1 if some condition holds?&lt;/a&gt;. &lt;/li&gt;&#xA;&lt;li&gt;For more on big-M, see &lt;a href=&quot;https://or.stackexchange.com/questions/236/why-is-it-important-to-choose-big-m-carefully-and-what-are-the-consequences-of-d&quot;&gt;Why is it important to choose big-M carefully and what are the consequences of doing it badly?&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For a similar constraint, see &lt;a href=&quot;https://or.stackexchange.com/q/612/38&quot;&gt;How to linearize a constraint with a maximum of binary variables times some coefficient in the right-hand-side&lt;/a&gt;. But note that in that question, only an inequality constraint is required for &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, not an equality constraint.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2020-01-16T22:12:27.287" LastActivityDate="2020-01-16T22:12:27.287" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="713" PostTypeId="2" ParentId="709" CreationDate="2019-06-24T07:13:01.783" Score="8" Body="&lt;p&gt;I haven't seen any good use cases of metaheuristics for &lt;strong&gt;continuous variables optimization&lt;/strong&gt;. That doesn't mean it's not possible, &lt;strong&gt;I just think it's not the right tool for the job&lt;/strong&gt;. Particularly, all forms of Local Search (Tabu Search, Late Acceptance, Simulated Annealing) with real continuous variables feel like using a hammer on a screw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, there are interesting gray-area cases, such &lt;a href=&quot;https://www.youtube.com/watch?v=NdyIf0JG94Y&amp;amp;list=PLJY69IMbAdq0uKPnjtWXZ2x7KE1eWg3ns&quot; rel=&quot;noreferrer&quot;&gt;Investment Portfolio Optimization&lt;/a&gt;, which is about buying stock exchange assets. Each variable represents the percentage of an asset to buy. This would clearly be a continuous variable, except that practically &lt;a href=&quot;https://github.com/kiegroup/optaplanner/blob/master/optaplanner-examples/src/main/java/org/optaplanner/examples/investment/domain/InvestmentSolution.java#L110&quot; rel=&quot;noreferrer&quot;&gt;we limited it in millis (so in 0.001 units)&lt;/a&gt;: the motivation being that in the real world there's a minimum unit granularity to buy anyway. And that works ok, not great (but some investors actually use the example impl). And I believe it will improve with dedicated neighborhoods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: Ironically, we coined the term for &lt;em&gt;continuous planning&lt;/em&gt; for &lt;a href=&quot;https://docs.optaplanner.org/latestFinal/optaplanner-docs/html_single/#continuousPlanning&quot; rel=&quot;noreferrer&quot;&gt;something completely different&lt;/a&gt; than &lt;em&gt;continuous (variables) optimization&lt;/em&gt;. &lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2019-06-24T11:20:51.517" LastActivityDate="2019-06-24T11:20:51.517" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="714" PostTypeId="2" ParentId="661" CreationDate="2019-06-24T15:01:24.843" Score="7" Body="&lt;p&gt;Formulating as one big problem requires more memory, some way to recognize that the problem decomposes into disjoint subproblems, and some way to then solve the subproblems independently.  At least one commercial solver (SAS) looks for such structure after presolve and suggests using the &lt;a href=&quot;https://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetTarget=ormpug_decomp_toc.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en&quot; rel=&quot;noreferrer&quot;&gt;decomposition algorithm&lt;/a&gt; in that case.  The decomposition algorithm automates the process, solving the independent subproblems concurrently, and returning the solution in the original space.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-06-24T15:01:24.843" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="715" PostTypeId="1" CreationDate="2019-06-24T16:05:02.827" Score="10" ViewCount="228" Body="&lt;p&gt;We know that a convex quadratic maximization (&lt;strong&gt;not&lt;/strong&gt; minimization!) on a polyhedron has its global optimal value on a vertex. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I have read in some papers that checking whether a vertex is globally optimal or not reduces to a simple condition. I am interested in that particular condition. Could you please help me with that -- either demonstrating or giving a reference would be great!&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2019-08-26T01:07:50.990" Title="Global optimality condition of non-convex quadratic programs" Tags="|quadratic-programming|global-optimization|nonconvex-programming|optimality-conditions|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="716" PostTypeId="2" ParentId="709" CreationDate="2019-06-24T17:39:55.037" Score="4" Body="&lt;p&gt;The authors of &quot;Optimisation in Signal and Image Processing &lt;a href=&quot;https://www.researchgate.net/publication/280893608_Metaheuristics_for_Continuous_Variables_The_Registration_of_Retinal_Angiogram_Images&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;&quot;, in chapter 11 of their book &lt;em&gt;Metaheuristics for Continuous Variables. The Registration of Retinal Angiogram Images&lt;/em&gt; (available on &lt;a href=&quot;https://www.researchgate.net/publication/280893608_Metaheuristics_for_Continuous_Variables_The_Registration_of_Retinal_Angiogram_Images&quot; rel=&quot;nofollow noreferrer&quot;&gt;ResearchGate&lt;/a&gt;) discussed the various implementations of some well-known metaheuristic methods in the optimization of continuous variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In [2], which is one of the introductory papers in the Harmony search metaheuristic, the authors discussed the theoretical bases and the implementation of the new proposed metaheuristic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.researchgate.net/publication/280893608_Metaheuristics_for_Continuous_Variables_The_Registration_of_Retinal_Angiogram_Images&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt; Siarry, Patrick, ed. Optimisation in signal and image processing. John Wiley &amp;amp; Sons, 2013.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] Lee, Kang Seok, and Zong Woo Geem. &quot;A new meta-heuristic algorithm for continuous engineering optimization: harmony search theory and practice.&quot; Computer methods in applied mechanics and engineering 194.36-38 (2005): 3902-3933.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="38" LastEditDate="2019-06-24T22:01:53.343" LastActivityDate="2019-06-24T22:01:53.343" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="717" PostTypeId="2" ParentId="667" CreationDate="2019-06-24T19:08:36.377" Score="6" Body="&lt;p&gt;I personally don't have the relevant experience in working on a project for a third party user. My experiences that I am going to itemize in the following are all about my work on my own projects. (So eventually some of the steps in previous answers may not be necessary when you work on your own project.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Understanding the problem at hand and defining the variables and constraints by carefully investigating the inputs of the problem and the expected outputs. (30%)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Modeling the problem considering as many details as you can by using an available modeling language (can be AMPL, Pyomo, ...) (30%)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Getting the first solution and checking the reasonability of small instances. For example, if you have a transportation problem with 1000 nodes, a smaller size problem can be considered with only 10 nodes (10%)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Solving bigger problems and trying to modify the code in terms of solving time. (20%)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5) Visualizing the results and comparing them to the benchmarks, if any (5%)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;6) Putting the necessary comments in the code, because it's going to be used later. (5%) &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="38" LastEditDate="2019-06-24T21:59:52.667" LastActivityDate="2019-06-24T21:59:52.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="718" PostTypeId="2" ParentId="554" CreationDate="2019-06-24T23:29:07.987" Score="4" Body="&lt;p&gt;Well, as @Matteo Fischetti has said in the comments to your question, your case of multiple &quot;easy&quot; secondary level problems is definitely more tractible than multiple levels. Even in a continuous linear case, you go one level higher in the polynomial hierarchy as you increase the number of levels [1]. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But having multiple &quot;easy&quot; problems is not a complete triviality either. For example, &#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Ax \leq b \\&#xA;0\leq x \leq 1\\&#xA;y \geq 0\\&#xA;y_i \in \arg\min_y \{ y: y \geq -x_i; y \geq x_i -1 \}&#xA;\} \quad i=1,\dots,n&#xA;$$&lt;/span&gt;&#xA;This has &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; simple bilevel constraints. Each program is trivial enough to have a closed form solution, &lt;span class=&quot;math-container&quot;&gt;$y_i = \max \{x_i-1, -x_i\}$&lt;/span&gt;!&#xA;This along with the requirement &lt;span class=&quot;math-container&quot;&gt;$y\geq 0$&lt;/span&gt; enforces that &lt;span class=&quot;math-container&quot;&gt;$x\in\{0,1\}$&lt;/span&gt;. In other words, we have re-written a binary program this way asking for one &quot;trivial&quot; bilevel constraint in the lifted space for each binary variable!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can regard having numerous trivial subproblems as having numerous binary variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, it is also fair to have numerous such bilevel constraints - they can be rewritten as a single one. In our case as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(y_1, \dots, y_n) \in \arg\min_y \left \{ \sum_{i=1}^n y_i: y_i \geq -x_i; y_i \geq x_i -1 \quad i=1,\dots,n \right \}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] Jeroslow, R. G. (1985). The polynomial hierarchy and a simple model for competitive analysis. Mathematical Programming, 32(2), 146–164.&lt;/p&gt;&#xA;" OwnerUserId="161" LastActivityDate="2019-06-24T23:29:07.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="719" PostTypeId="2" ParentId="709" CreationDate="2019-06-24T23:41:01.237" Score="3" Body="&lt;p&gt;In some domains, metaheuristics are the most common way of optimising things. I have a bit of experience in water resource management, and using &quot;common&quot; optimisation tools is like a big word in these communities. Don't talk about simplex, interior point, branch-and-bound, or anything like this. Often, they don't have linear or convex models (nor of large size), but they could use linearisation techniques (many relationships could use piece-wise linear modelling instead of precomputed tables -- the latter being only useable within metaheuristics). I daresay metaheuristics are preferable for people not willing to invest time in modelling &quot;properly&quot; a given problem, but rather prefer spend time to build an algorithm (which is really fun, by the way!). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relatedly, when you deal with multiobjective problems, using evolutionary methods brings you a lot of potentially good solutions for a subset of objective functions in exactly the same computational budget as solving the usual optimisation problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, have a look at &lt;a href=&quot;https://doi.org/10.1007/s11269-014-0700-5&quot; rel=&quot;nofollow noreferrer&quot;&gt;Reservoir Optimization in Water Resources: a Review&lt;/a&gt;. Sometimes, they also include simulation in the optimisation loop, which is harder to include with standard solvers; see &lt;a href=&quot;https://doi.org/10.1016/j.advwatres.2009.06.008&quot; rel=&quot;nofollow noreferrer&quot;&gt;Evaluation of stochastic reservoir operation optimization models&lt;/a&gt; for instance. However, this community also acknowledges the fact that metaheuristics are very hard to really understand, you never really have an idea of how good a solution is, whether progress remains to be made in the solving process &lt;a href=&quot;https://doi.org/10.1016/j.envsoft.2014.09.013&quot; rel=&quot;nofollow noreferrer&quot;&gt;Evolutionary algorithms and other metaheuristics in water resources: Current status, research challenges and future directions&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB. I'm not a fan of metaheuristics, which means I'm a little bit biased. &lt;/p&gt;&#xA;" OwnerUserId="156" LastEditorUserId="56" LastEditDate="2019-06-28T13:18:23.007" LastActivityDate="2019-06-28T13:18:23.007" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="720" PostTypeId="2" ParentId="715" CreationDate="2019-06-25T00:00:03.037" Score="3" Body="&lt;p&gt;In addition to the references already given in the comments, &lt;a href=&quot;https://link.springer.com/content/pdf/10.1023%2FA%3A1025794313696.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; (&lt;a href=&quot;https://doi.org/10.1023/A:1025794313696&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI link&lt;/a&gt;) demonstrates that exact solutions to some non-convex quadratic programs are given by semi-definite programming, and whenever the SDP relaxation is tight we can actually solve the SDP via SOCP! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general the SDP relaxation will of course not be tight, but as shown by &lt;a href=&quot;https://link.springer.com/content/pdf/10.1007/s101070050100.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nemirovski et. al.&lt;/a&gt; (&lt;a href=&quot;https://doi.org/10.1007/s101070050100&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI link&lt;/a&gt;) we can provide some constant factor guarantees when the sufficient condition does not hold.&lt;/p&gt;&#xA;" OwnerUserId="43" LastEditorUserId="56" LastEditDate="2019-06-28T13:13:44.783" LastActivityDate="2019-06-28T13:13:44.783" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="721" PostTypeId="1" AcceptedAnswerId="723" CreationDate="2019-06-25T01:37:44.943" Score="19" ViewCount="3638" Body="&lt;p&gt;Is there any compact resource that includes a list of all academic journals in the OR/MS space, ranked by journal importance? Although there are some helpful features offered by publisher websites such as &lt;a href=&quot;https://journalfinder.elsevier.com/&quot; rel=&quot;noreferrer&quot;&gt;Elsevier journal finder&lt;/a&gt;, I think it would be helpful if such a list were to be added here as well.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="715" LastEditDate="2019-06-27T02:34:34.627" LastActivityDate="2019-08-30T19:05:57.593" Title="Ordered list of OR journals" Tags="|optimization|academia|journals|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="722" PostTypeId="1" AcceptedAnswerId="727" CreationDate="2019-06-25T02:05:21.120" Score="7" ViewCount="505" Body="&lt;p&gt;Let's say I have an objective function &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f(x_1,x_2, \cdots, x_n)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; constraints &#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i \ge 0. $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to solve it with KKT conditions. Now the objective function becomes&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f(x_1,x_2, \cdots, x_n)+ \mu_i(g_i(x)).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to solve it using a C program so I solved the equation manually for both cases where I take &lt;span class=&quot;math-container&quot;&gt;$\mu_i =0$&lt;/span&gt; and the other case when &lt;span class=&quot;math-container&quot;&gt;$x_i &amp;lt; 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_i = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So let's say I run the algorithm and take all &lt;span class=&quot;math-container&quot;&gt;$\mu_i = 0$&lt;/span&gt; initially and get &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;lt; 0$&lt;/span&gt; (the rest all are positive), so I run the algorithm again with &lt;span class=&quot;math-container&quot;&gt;$x_1 = 0$&lt;/span&gt;. Now assume that I get &lt;span class=&quot;math-container&quot;&gt;$x_2 &amp;lt; 0$&lt;/span&gt; (the rest all are positive). Now I updated with &lt;span class=&quot;math-container&quot;&gt;$x_2 = 0$&lt;/span&gt; so here I want to know whether I should take &lt;span class=&quot;math-container&quot;&gt;$x_1 =0$&lt;/span&gt; also or whether I need to perform all possible combinations with &lt;span class=&quot;math-container&quot;&gt;$x_i =0$&lt;/span&gt;  and &lt;span class=&quot;math-container&quot;&gt;$\mu_i = 0$&lt;/span&gt; to get the final answer. &lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="38" LastEditDate="2019-06-25T02:30:42.923" LastActivityDate="2019-06-25T07:12:48.603" Title="KKT inequality conditions" Tags="|optimization|constraint|nonlinear-programming|convexity|kkt-conditions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="723" PostTypeId="2" ParentId="721" CreationDate="2019-06-25T02:28:49.633" Score="19" Body="&lt;p&gt;Here are a few sources. In my opinion, all are to be taken with a grain of salt.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Scimago Journal and Country Rank&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.scimagojr.com/journalrank.php?category=1803&quot; rel=&quot;noreferrer&quot;&gt;Scimago Journal and Country Rank&lt;/a&gt; (the link goes to the &lt;em&gt;Management Science and Operations Research&lt;/em&gt; category) ranks journals according to SJR's proprietary index. The first 7 are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8uQT2.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8uQT2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To me, the rankings seem reasonable, if not totally reliable. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Journal Citation Report&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I came up for tenure about 10 years ago, my university used the &lt;em&gt;Journal Citation Report,&lt;/em&gt; which at the time was owned by ISI Web of Science, but now appears to be on &lt;a href=&quot;https://jcr.clarivate.com/&quot; rel=&quot;noreferrer&quot;&gt;a separate site&lt;/a&gt; (but linked to from WoS). It's behind a paywall, so I can't link to the exact portion of the site (and I am finding the site quite clunky and un-user-friendly), but here is a screenshot of the first few journals listed under the &lt;em&gt;Operations Research and Management Science&lt;/em&gt; category, ranked by Impact Factor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VGEHX.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VGEHX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The journals listed here are perfectly good, but I think most of us would agree that these are not the &quot;top&quot; 7 OR journals. (For example, &lt;em&gt;Operations Research&lt;/em&gt;, &lt;em&gt;Management Science&lt;/em&gt;, &lt;em&gt;Math Programming&lt;/em&gt;, etc. are ranked 26, 9, and 14, respectively.) But we all also know that Impact Factor is not a terribly reliable measure of quality.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There is also a carefully designed, although now out of date, &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/inte.1050.0149&quot; rel=&quot;noreferrer&quot;&gt;article in &lt;em&gt;Interfaces&lt;/em&gt;&lt;/a&gt; in 2005, that presents rankings of OM journals, compiled from surveys by business school professors. Here are the top 10:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lePfs.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lePfs.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-25T02:28:49.633" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="724" PostTypeId="2" ParentId="721" CreationDate="2019-06-25T05:14:45.650" Score="14" Body="&lt;p&gt;Personally, I think you shouldn't be merely motivated by quantitative journal rankings as they often rely on measures that could be manipulated. In particular, the impact factor of a journal would increase if the editor required authors to cite a large number of recent publications of that journal. Although the organizations responsible for calculating these measures try to fight these tactics, there are occasional slip-ups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, I suggest that consult your senior colleagues or respected scholars in your field about this issue as top journals in OR or your field do not necessarily have the highest impact factors (a prominent example is Operations Research published by INFORMS). Ask them which journals are worth the attention or might impress the hiring committees better. This is important especially if you're working on OR-related areas such as operations management.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, to complete Larry's answer, there is the &quot;Academic Journal Guide&quot; published by &lt;a href=&quot;https://charteredabs.org&quot; rel=&quot;noreferrer&quot;&gt;Chartered Association of Business Schools&lt;/a&gt;, available from &lt;a href=&quot;https://charteredabs.org/academic-journal-guide-2018/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. It combines quantitative measures with the opinions of experts in different fields to create a ranking list. Hence, while there is a correlation with impacts factors offered by Web of Science, the final order is not necessarily the same and offer some insights about the prestige of the journals. For example, the first OR journal in this ranking is the &quot;Management Science&quot; with an impact factor of about three, while the fourth journal is the &quot;IEEE Transactions on Evolutionary Computation&quot; with an impact factor of about eight. I think this ranking could help you better than mere impact factors.&lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2019-06-25T05:14:45.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="725" PostTypeId="1" CreationDate="2019-06-25T06:19:26.320" Score="6" ViewCount="93" Body="&lt;p&gt;I have a project and I want to minimize the costs. I am are responsible for the inspection of 1000 miles of sewer grid in Canada. My goal is to provide time high quality inspection reports. I tried to define the problem using optimization but I haven't used for a year. I want to know what would be the optimised number of people I should hire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The people I have to pay are robots drivers and inspectors.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have a &lt;span class=&quot;math-container&quot;&gt;$\$90000$&lt;/span&gt; budget, two months on site and two weeks off site before.&lt;/li&gt;&#xA;&lt;li&gt;robots drivers take 6 pictures of every pole under different point of views and upload them on my cloud. The drivers upload their pics once a week.&lt;/li&gt;&#xA;&lt;li&gt;A well trained driver can inspect 15miles of sewer grid per day. Training lasts for one day, you can train two pilots in parallel.&lt;/li&gt;&#xA;&lt;li&gt;A photo inspector performs a quality check of the pictures on the Sterblue cloud. Sterblue asks the drone pilots to reinspect any poles not passing the quality checks. You can assume 10% of the poles have to be re-inspected.&lt;/li&gt;&#xA;&lt;li&gt;My AI on the cloud detects the defects. The customer expects 95% accuracy.&lt;/li&gt;&#xA;&lt;li&gt;The inspector performs a quality check of the detections found by the AI. They cost $300 a day and can handle 30miles/day for image quality review, 30miles/day to review the work of the AI.&lt;/li&gt;&#xA;&lt;li&gt;I have a free operations team that generates the inspection reports. 0,5 day is needed to prepare a report for 100 miles of grid.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{cases}&#xA;\begin{aligned}&#xA;\min \ &amp;amp;800 \overbrace{x_1.y_1}^{\text{robot pilots x days}} &amp;amp;+ 300  \overbrace{x_2.y_2}^{\text{inspectors x days}}\\&#xA;&amp;amp;800 x_1.y_1 &amp;amp;+ 300 x_2.y_2&amp;amp;\le $90000\\&#xA;&amp;amp;y_1&amp;amp;+y_2 &amp;amp;\le 2 months\\&#xA;&amp;amp;15 x_1.y_1&amp;amp;&amp;amp;\ge 1000 miles+10\%x_1.y_1 \\&#xA;&amp;amp;15 y_1 &amp;amp;&amp;amp;= 30 y_2 \\&#xA;\forall i, x_i&#xA;\end{aligned}&#xA;\end{cases}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; is the number of robots drivers, &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; the number of inspectors, &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; the time spent by robot drivers, &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; the time spent by inspectors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that inspection can't start before reports, and that I haven't found a way to write the 95% accuracy constraints.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can you help me improve the problem so I take into account every constraints ?&lt;/li&gt;&#xA;&lt;li&gt;What should &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;, the number of people I should hire, be ?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I know I should do a Gantt diagram as well but I don't know yet where the major steps and dependencies are.&lt;/p&gt;&#xA;" OwnerUserId="702" LastEditorUserId="702" LastEditDate="2019-06-25T08:55:26.343" LastActivityDate="2019-06-25T08:55:26.343" Title="Minimizing a project costs through nonlinear optimization" Tags="|optimization|nonlinear-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="726" PostTypeId="2" ParentId="725" CreationDate="2019-06-25T07:06:26.900" Score="5" Body="&lt;p&gt;You have multiple things at hand here, none of which seem like an optimization problem to me:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;To understand how many people to hire, consider that you have ca. 620 miles (= 1000km) of grid, and a single driver can do 15 miles of grid per day. Given that you have two months (ca. 60 days), this means that in theory one person could do it all, since &lt;span class=&quot;math-container&quot;&gt;$\frac{620}{60} \approx 10$&lt;/span&gt;. However, in order to account for off days, vehicle breakdown etc. you should look for 2, possibly 3 drivers. For me, this is not an optimization problem because a lot of qualitative measures need to be taken into account (e.g. worker reliability, actual progress speed) etc.&lt;/li&gt;&#xA;&lt;li&gt;The 95% constraint exclusively depends on your &quot;AI&quot; (calling image recognition &quot;AI&quot; is a bit of a stretch for me, sounds more like machine learning to me, but ok), so you need to prove that. The easiest way is to check against some test data (see e.g. &lt;a href=&quot;https://developers.google.com/machine-learning/crash-course/training-and-test-sets/splitting-data&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; for the split between training and test data) and if that sample is large enough, you can draw some conclusion from that. A step further would be to incorporate the feedback from the inspectors in real time and see whether your prediction quality matches what you assume.&lt;/li&gt;&#xA;&lt;li&gt;As for the number of inspectors: you have not specified how many poles there are per mile, but assuming an equidistant distribution, we can say that a total of &lt;span class=&quot;math-container&quot;&gt;$620\cdot 0.1 = 62$&lt;/span&gt; miles have a problem. With a speed of 30 miles/day, you basically only need one, since you have a two month period at your disposal. I am not sure what you mean by &quot;AI review&quot;, but if you simply want to get test data to validate the predictions from the image recognition software, I would suggest the inspector does that the remaining time he/she is not busy with defect piles.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Of course you could throw some optimization at this, but I don't see the point given on the description you provided.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-06-25T07:06:26.900" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="727" PostTypeId="2" ParentId="722" CreationDate="2019-06-25T07:12:48.603" Score="10" Body="&lt;p&gt;If you want to use the KKT conditions for the solution, you need to test all possible combinations. This is why in most cases, we use the KKT's to validate that something is an optimal solution, since the KKT's are the first-order necessary conditions for optimality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For convex nonlinear optimization, you are better off using sequential quadratic programming or similar (see &lt;a href=&quot;https://www.artelys.com/docs/knitro/2_userGuide/algorithms.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; for a nice overview over some methods), and then validate using the duality gap and KKT conditions.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-06-25T07:12:48.603" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="728" PostTypeId="2" ParentId="721" CreationDate="2019-06-25T07:57:59.980" Score="10" Body="&lt;p&gt;Another source providing this information is google scholar. &lt;a href=&quot;https://scholar.google.com/citations?view_op=top_venues&amp;amp;hl=en&amp;amp;vq=phy_mathematicaloptimization&quot; rel=&quot;noreferrer&quot;&gt;Here&lt;/a&gt; is the ranking for &lt;strong&gt;mathematical optimization&lt;/strong&gt; journals. Also as &lt;a href=&quot;https://or.stackexchange.com/users/118/chang&quot;&gt;@Chang&lt;/a&gt; pointed out &lt;a href=&quot;https://scholar.google.com/citations?view_op=top_venues&amp;amp;hl=en&amp;amp;vq=eng_operationsresearch&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; is the ranking for operations research journals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per one's subject of interest; after a little search, one can get the ranking for other areas as well e.g. &lt;strong&gt;game theory and decision sciences&lt;/strong&gt; could be found under &lt;em&gt;Business, Economics and Management&lt;/em&gt; &lt;a href=&quot;https://scholar.google.com/citations?view_op=top_venues&amp;amp;hl=en&amp;amp;vq=bus_gametheorydecisionscience&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="129" LastEditorUserId="129" LastEditDate="2019-06-26T17:19:18.350" LastActivityDate="2019-06-26T17:19:18.350" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="729" PostTypeId="1" CreationDate="2019-06-25T08:46:15.043" Score="5" ViewCount="124" Body="&lt;p&gt;I have an &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;-dimensional vector of data, say &lt;span class=&quot;math-container&quot;&gt;$X_{t}$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$1 \leq t \leq T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Of this vector &lt;span class=&quot;math-container&quot;&gt;$X_{t}$&lt;/span&gt;, I want to consider sub-vectors, say &lt;span class=&quot;math-container&quot;&gt;$X_{t}^{b}$&lt;/span&gt;, which are &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;-dimensional combinations of elements of the original vector &lt;span class=&quot;math-container&quot;&gt;$X_{t}$&lt;/span&gt;. In total, I have &lt;span class=&quot;math-container&quot;&gt;${N}\choose{m}$&lt;/span&gt; of such combinations.&lt;/p&gt;&#xA;&lt;p&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; can be a large number; I need to allow for &lt;span class=&quot;math-container&quot;&gt;$N \rightarrow \infty$&lt;/span&gt;. Also, I will choose &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; in such a way that &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is &amp;quot;smaller&amp;quot; than &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;, e.g. &lt;span class=&quot;math-container&quot;&gt;$m=O(N^{1/2})$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I want to compute the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-th eigenvalue (&lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is user-defined) of the second moment matrix of each of these &lt;span class=&quot;math-container&quot;&gt;$X_{t}^{b}$&lt;/span&gt;s, i.e.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\lambda_{k}^{b} \left( \frac{1}{T} \sum_{t=1}^{T} X_{t}^{b} (X_{t}^{b})' \right).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, finally, I want to compute&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{1 \leq b \leq B} \lambda_{k}^{b},$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is defined as &lt;span class=&quot;math-container&quot;&gt;${N}\choose{m}$&lt;/span&gt;. In principle, I may need to compute also other measures such as the average of &lt;span class=&quot;math-container&quot;&gt;$\lambda_{k}^{b}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have two questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is this problem NP-hard? Is there a reference to back up either statement (i.e. &amp;quot;it is&amp;quot; or &amp;quot;it is not&amp;quot;)?&lt;/li&gt;&#xA;&lt;li&gt;Is there some heuristic to make the problem less computationally burdensome? Is there any way to prove, for a given heuristic, that the solution found by the heuristic is &amp;quot;very close&amp;quot; to &lt;span class=&quot;math-container&quot;&gt;$ \max\limits_{1 \leq b \leq B} \lambda_{k}^{b}$&lt;/span&gt; - e.g. by showing that the solution found by the heuristic and &lt;span class=&quot;math-container&quot;&gt;$ \max\limits_{1 \leq b \leq B} \lambda_{k}^{b}$&lt;/span&gt; are equal almost surely, or something similar?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="703" LastEditorUserId="491" LastEditDate="2021-05-10T12:20:17.790" LastActivityDate="2021-05-10T12:20:17.790" Title="Maximum eigenvalue across subsamples" Tags="|combinatorial-optimization|computational-complexity|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="730" PostTypeId="2" ParentId="602" CreationDate="2019-06-25T09:52:57.770" Score="3" Body="&lt;p&gt;Theoretically it is quite naturally convincing to assume that demand time points are independent. In other words knowing that an item was bought in &lt;code&gt;t1&lt;/code&gt; does not give one any good clue in understanding next sales time &lt;code&gt;t2&lt;/code&gt;. It is like process renews/regenerate itself after each event and hence time between events are independent of each other. This particular phenomenon can be modeled elegantly by exponential distribution which itself have this property.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also when time between events are exponentially distributed then number of event occurrences is Poisson distributed. So making Poisson distribution assumption makes sense when you have to generate data (Don't have actual data). For more details you can search Poisson process or some elementary literature in queuing theory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normal distribution could be assumed when demand hovers around certain average like newspapers sales etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when supplied with data it makes better sense to check actual distribution than just assume some distribution and model. I worked on slow moving commodity sales project and sales data was not following any Poisson distribution.&lt;/p&gt;&#xA;" OwnerUserId="129" LastActivityDate="2019-06-25T09:52:57.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="731" PostTypeId="2" ParentId="721" CreationDate="2019-06-25T13:08:23.867" Score="4" Body="&lt;p&gt;There is a very new OR journal with a very broad scope:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/business+%26+management/operations+research/journal/43069&quot; rel=&quot;nofollow noreferrer&quot;&gt;SN Operations Research Forum&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In addition to the journals listed in the other answers, there are some military-themed journals: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.mors.org/Publications/MOR-Journal&quot; rel=&quot;nofollow noreferrer&quot;&gt;Military Operations Research&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://journals.sagepub.com/home/dms&quot; rel=&quot;nofollow noreferrer&quot;&gt;Journal of Defense Modeling and Simulation: Applications, Methodology, Technology&lt;/a&gt;   &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.emeraldgrouppublishing.com/services/publishing/jdal/index.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Journal of Defense Analytics and Logistics&lt;/a&gt;   &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These may to be good outlets for national security, defense, or other military application-themed articles.  &lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-08-30T19:05:57.593" LastActivityDate="2019-08-30T19:05:57.593" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="732" PostTypeId="1" CreationDate="2019-06-25T15:33:11.420" Score="41" ViewCount="13143" Body="&lt;p&gt;I would like to clarify that I am absolutely not an expert when it comes to constraint programming (I happen to use it when it seems to be the right tool for the right job).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is my understanding that the possibility to use global constraints can have a tremendous impact on how efficiently a problem can be solved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, not all global constraint are implemented in all constraint programming solvers. For example if I use the &lt;a href=&quot;https://sofdem.github.io/gccat/gccat/index.html&quot; rel=&quot;noreferrer&quot;&gt;global constraint catalog&lt;/a&gt; to search existing global constraints, I will find out that the &lt;a href=&quot;https://sofdem.github.io/gccat/gccat/Calldifferent.html&quot; rel=&quot;noreferrer&quot;&gt;AllDifferent constraint&lt;/a&gt; (which represents the fact that no two variables of a given subset of the variables of the problem should take the same value) is implemented, under different names, in quite some constraint programming solvers. On the other hand only two solvers are referenced as implementing the &lt;a href=&quot;https://sofdem.github.io/gccat/gccat/Cincreasing.html&quot; rel=&quot;noreferrer&quot;&gt;increasing constraint&lt;/a&gt; is referenced as only being implemented by three solvers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here comes my question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;When using constraint programming, do you first write the model, trying to use global constraints when possible, and later on select which constraint programming solver you are going to use based on the availability of those global constraint? Or do you have a set constraint programming solver that you always use, no matter which global constraint you actually need (implementing the needed global constraint yourself if needed)?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="124" LastEditorUserId="8" LastEditDate="2019-10-15T21:08:05.700" LastActivityDate="2020-02-24T22:35:23.007" Title="How to select a Constraint Programming Solver" Tags="|solver|constraint-programming|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="734" PostTypeId="1" AcceptedAnswerId="741" CreationDate="2019-06-25T15:53:17.920" Score="11" ViewCount="193" Body="&lt;p&gt;What are some primal heuristics that mixed-integer linear and nonlinear program solvers use to quickly obtain a reasonably good feasible solution?&lt;/p&gt;&#xA;" OwnerUserId="161" LastEditorUserId="38" LastEditDate="2019-06-25T16:39:18.893" LastActivityDate="2019-06-25T20:25:35.790" Title="Heuristics for mixed integer linear and nonlinear programs" Tags="|mixed-integer-programming|solver|nonlinear-programming|heuristics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="735" PostTypeId="1" AcceptedAnswerId="736" CreationDate="2019-06-25T16:53:46.977" Score="10" ViewCount="786" Body="&lt;p&gt;Suppose I give a solver (CPLEX, Gurobi, SCIP or anything else) an IP which is a reformulation of a stable set problem (or vertex cover problem or coloring problem) of some graph, is there a way I can tell the solver that it is a stable set or vertex cover instance? Will that enhance the heuristics used by the solver?&lt;/p&gt;&#xA;" OwnerUserId="161" LastEditorUserId="56" LastEditDate="2019-06-25T19:52:17.360" LastActivityDate="2019-06-25T19:59:29.987" Title="Graph problems as integer programs" Tags="|solver|graphs|heuristics|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="736" PostTypeId="2" ParentId="735" CreationDate="2019-06-25T17:12:29.240" Score="7" Body="&lt;p&gt;I suspect there are a few &lt;em&gt;specific&lt;/em&gt; problems for which the answer is &quot;yes,&quot; and I hope others will answer to provide examples of those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in general I believe the answer is &quot;no.&quot; For example, if you formulate the minimum-spanning tree problem as an IP and try to solve it with a general-purpose solver, it will be much slower than just using Prim's or Kruskal's algorithm. If there were some option you could set that says &quot;hey, this is an MST!&quot;, then the solver would basically have to have a ton of separate graph algorithms (Prim's for MST, Dijkstra's for shortest path, etc.) built into it, which is not really what general-purpose solvers are designed to do.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-25T17:12:29.240" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="737" PostTypeId="2" ParentId="735" CreationDate="2019-06-25T18:06:54.953" Score="10" Body="&lt;p&gt;CPLEX has a parameter (RootAlgorithm) that lets you select the method for solving an LP (or for solving the root node relaxation of an ILP). The default setting is to let CPLEX choose, which usually (but not always) results in it using dual simplex. One of the choices is &quot;network simplex&quot;, which you might try for a graph problem. I don't know whether CPLEX would detect the graph structure and automatically try network simplex if left on the default setting.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-06-25T18:06:54.953" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="738" PostTypeId="1" CreationDate="2019-06-25T19:58:43.643" Score="11" ViewCount="353" Body="&lt;p&gt;Context: I am a CS student currently in a non-CS internship (logistics, supply chain).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My manager wants to leverage my knowledge of programming to build a program to solve the following problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a company, we have different units of product that we have to distribute to our stores. Some stores are good at selling, others not so much. Sometimes, we don't have enough of our product to give every store what they need, therefore, we have to decide where to send the product so that it sells as fast as possible / makes the most profit. So the inputs would be the historical and current data of the performance of each store, as well as how many units we want to distribute and the output would be how many units to allocate in each store.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My approach is the following: Using historical data, use &lt;code&gt;scipy.curve_fit&lt;/code&gt; function to fit the data of each store to a distribution (how do I pick which distribution to fit?) with sales and level of inventory for a day as the axis for each store. Then, from this function, construct a multi variable global profit function, and then maximize this function with the constraints (how many units we have to distribute) using &lt;code&gt;scipy.optimize&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for example, if we decide that a simple square root function fits our data the best, and after using &lt;code&gt;scipy.cure_fit&lt;/code&gt; we estimate that for store A Profit = &lt;span class=&quot;math-container&quot;&gt;$2\sqrt{3x}$&lt;/span&gt; and for Store B Profit = &lt;span class=&quot;math-container&quot;&gt;$5\sqrt{y}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are the number of units in each store, then the global profit function would be Profit = &lt;span class=&quot;math-container&quot;&gt;$2\sqrt{3x} + 5\sqrt{y}$&lt;/span&gt;. If we only have 500 units to allocate for example, then we have to optimize the function &lt;span class=&quot;math-container&quot;&gt;$2\sqrt{3x} + 5\sqrt{y}$&lt;/span&gt; with the constraint that &lt;span class=&quot;math-container&quot;&gt;$x + y \leq 500$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Does my general approach make sense? Is there a better way to approach this?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;scipy.curve_fit&lt;/code&gt; takes a distribution for fitting. What is the best way to pick a distribution given my data?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In my approach, I use SciPy a lot. Are there other technologies that would be better to use?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How can I include lead time (time for the product to get to the store) in this model?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Would Machine Learning be of possible use here? My manager is interested in ML and I think it would be kinda cool to include it somehow.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="709" LastEditorUserId="51" LastEditDate="2019-07-31T19:19:25.637" LastActivityDate="2019-07-31T19:19:25.637" Title="Is my approach to my internship project good? Optimal allocation of product across stores, constrained optimization" Tags="|optimization|constraint|fitting|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="739" PostTypeId="2" ParentId="735" CreationDate="2019-06-25T19:59:29.987" Score="9" Body="&lt;p&gt;Often such problems have side constraints, and &lt;a href=&quot;https://patents.google.com/patent/US9448793B2/en&quot; rel=&quot;noreferrer&quot;&gt;this patent&lt;/a&gt; covers that more general case, using Dantzig-Wolfe decomposition with the network subproblem (MST, TSP, etc.) expressed compactly (not algebraically) and solved with a specialized solver.  This functionality is implemented in SAS but currently undocumented.  Please contact me if you are interested in using it.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-06-25T19:59:29.987" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="740" PostTypeId="1" CreationDate="2019-06-25T20:23:32.700" Score="12" ViewCount="325" Body="&lt;p&gt;I often spend much, much, more time QAing and debugging my code than I do actually writing the optimization problem or shaping my data. Are there any tools or techniques to make it easier? I am asking specifically about the challenges operations research adds to programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example: Let's say we wanted to solve a newsvendor problem with shortage costs. An initial optimization model may look like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{Q\geq 0} ~E(-cQ - e(d_i-Q)^+ +v(Q-d_i)^+ ) $$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is the order quantity, &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; is the stochastic demand for each &lt;span class=&quot;math-container&quot;&gt;$i \in \{1,\ldots, N\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is the per-unit cost, &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; is a shortage cost, and &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is a salvage value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this has nonlinearities that we have to resolve. The linear model looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{Q\geq 0} ~E(-cQ - eS_i^{(1)} +vS_i^{(2)}) \\&#xA;\mbox{s.t.} ~ S_i^{(1)} &amp;gt; d-Q~~~~~\forall i \in \{1,\ldots, N\}~~~~~~~~~~ \\&#xA;S_i^{(2)} &amp;gt; Q-d~~~~~\forall i \in \{1,\ldots, N\}~~~~\\&#xA;S_i^{(1)}, S_i^{(2)} \geq 0~~~~\forall i \in \{1,\ldots, N\}.~~~$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even this may not be the final version though. Sometimes we might want to know details that are not easily available from the information in the optimal solution. In the past, I have sometimes added even more variables to see a particular slice of costs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a model this many steps from the original, I often find it slow to verify that I haven't mixed up inequalities or left something out. When I am using PuLP, I can inspect the lp model directly, but the slack variables can still make it confusing for practical-sized problems. Is there anything I'm missing in how to handle these two sources of OR-specific programming complexity?&lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="60" LastEditDate="2019-06-26T15:21:46.940" LastActivityDate="2019-06-26T21:29:41.860" Title="QA techniques for optimization problem coding" Tags="|linearization|software|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="741" PostTypeId="2" ParentId="734" CreationDate="2019-06-25T20:25:35.790" Score="10" Body="&lt;p&gt;This is a question, for which google &quot;primal heuristics integer program solver&quot; may give a better answer than I can give myself, but: One of the &quot;definitive&quot; references is &lt;a href=&quot;http://www.zib.de/berthold/Berthold2014.pdf&quot; rel=&quot;noreferrer&quot;&gt;this dissertation&lt;/a&gt; by Timo Berthold.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-06-25T20:25:35.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="742" PostTypeId="1" CreationDate="2019-06-25T20:34:22.463" Score="10" ViewCount="13695" Body="&lt;p&gt;In Python's &lt;code&gt;PuLP&lt;/code&gt; package, how can I get the value of a decision variable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I declare a variable—&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = LpVariable('x_var', cat=LpContinuous)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;—then solve the problem, then use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print(x)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Python just outputs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x_var&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get the value of the variable, not its name?&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-02-21T05:03:28.193" Title="How do I access the value of a variable in PuLP?" Tags="|python|pulp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="743" PostTypeId="2" ParentId="742" CreationDate="2019-06-25T20:34:22.463" Score="12" Body="&lt;p&gt;To get the &lt;em&gt;value&lt;/em&gt; of the decision variable, you need to use the &lt;code&gt;varValue&lt;/code&gt; property of the &lt;code&gt;LpVariable&lt;/code&gt;, so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print(x.varValue)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print(x.value())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The explanation is that the Python variable &lt;code&gt;x&lt;/code&gt; is not the decision variable itself, it is a &lt;code&gt;PuLP&lt;/code&gt; object of type &lt;code&gt;LpVariable&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In[5]: type(x)&#xA;Out[5]: pulp.pulp.LpVariable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Therefore, just using &lt;code&gt;print(x)&lt;/code&gt; does not give you the value of the decision variable, it gives you the variable name that you supplied in the &lt;code&gt;name&lt;/code&gt; argument when you declared your &lt;code&gt;LpVariable&lt;/code&gt;. (In particular, Python is printing the string returned by the &lt;code&gt;LpVariable&lt;/code&gt;'s &lt;code&gt;__repr__&lt;/code&gt; function, which is just the &lt;code&gt;name&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also access the name of a variable using the &lt;code&gt;name&lt;/code&gt; property. This is also convenient for listing all of the variables at once:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for v in prob.variables():&#xA;    print(v.name, &quot;=&quot;, v.varValue)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's a more complete example, using Hillier and Lieberman's (in)famous &quot;Wyndor Glass&quot; model:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import *&#xA;&#xA;prob = LpProblem('glass', LpMaximize)&#xA;&#xA;# Declare variables.&#xA;x1 = LpVariable('x1_var', lowBound=0, upBound=None, cat=LpContinuous)&#xA;x2 = LpVariable('x2_var', lowBound=0, upBound=None, cat=LpContinuous)&#xA;&#xA;# Build objective function.&#xA;prob += 3 * x1 + 5 * x2&#xA;&#xA;# Add constraints.    &#xA;prob += x1 &amp;lt;= 4&#xA;prob += 2 * x2 &amp;lt;= 12&#xA;prob += 3 * x1 + 2 * x2 &amp;lt;= 18&#xA;&#xA;# Solve problem.&#xA;prob.solve()&#xA;&#xA;# Print status.&#xA;print(&quot;Status:&quot;, LpStatus[prob.status], &quot;\n&quot;)&#xA;&#xA;print(&quot;The value of x1 = {}. (Not what we want.)&quot;.format(x1))&#xA;print(&quot;The values of x1.value() and x1.varValue = {} and {}. (That's what we want.)\n&quot;.format(x1.value(), x1.varValue))&#xA;&#xA;# Print optimal values of decision variables.&#xA;print(&quot;All variables:&quot;)&#xA;for v in prob.variables():&#xA;    print(v.name, &quot;=&quot;, v.varValue)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Status: Optimal &#xA;&#xA;The value of x1 = x1_var. (Not what we want.)&#xA;The values of x1.value() and x1.varValue = 2.0 and 2.0. (That's what we want.)&#xA;&#xA;All variables:&#xA;x1_var = 2.0&#xA;x2_var = 6.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the idea is the same if we declare the variables using &lt;code&gt;LpVariable.dicts&lt;/code&gt;, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = LpVariable.dicts('x_var', range(1, 3), lowBound=0, upBound=None, cat=LpContinuous)&#xA;&#xA;prob += 3 * x[1] + 5 * x[2]&#xA;&#xA;(etc.)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;print(x[1])&lt;/code&gt; gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x_var_1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;print(x[1].varValue)&lt;/code&gt; gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-25T20:34:22.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="744" PostTypeId="2" ParentId="709" CreationDate="2019-06-25T21:51:42.353" Score="6" Body="&lt;p&gt;Personally I use them all the time, regardless of variable type, typically for low-dimensional (&amp;lt;= 100 variables)  black-box optimization problems of unknown structure where I want an approximate solution quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, this solver uses a GA and accepts continuous and discrete variables:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://support.sas.com/documentation/onlinedoc/or/132/hplso.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://support.sas.com/documentation/onlinedoc/or/132/hplso.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the continuous smooth world, if a method doesn't use derivatives, its effectiveness tends to decay like one divided by  the square-root of the dimension for the same work per iteration; so I might be more focused on the number of variables as opposed to variable type.  (Look at equations 3.10 define K(G) &lt;a href=&quot;http://www.cs.wm.edu/~va/research/sirev.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; (&lt;a href=&quot;https://doi.org/10.1137/S003614450242889&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI link&lt;/a&gt;), though not used in GA's I believe they work probabilistically the same way.  The dimension explodes and you cannot possibly keep pace.  At best you have an underlying spanning set whose effectiveness degrades rapidly with dimension.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, to avoid being rudely laughed at, if you are publishing results, &#xA;a basic rule of thumb is to apply the solver in your toolbox that matches your optimization problem closest.   For example, if you are solving a TSP and have SAS/OPTMILP, don't use a GA. GA's assume almost nothing about the problem while a MILP solver is very specific on problem type. The more assumptions a solver makes about the problem and its structure, the more targeted/expeditious the algorithm design becomes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider group theory (&lt;a href=&quot;https://www.britannica.com/science/group-theory&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.britannica.com/science/group-theory&lt;/a&gt;).  It arises from 4 simple assumptions a child might understand (axioms) that result in volumes of complex implications and hours upon hours of mathematical fun.  Never under estimate the power limiting assumptions in the hands of a motivated mathematician/developer:)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if you were on a desert island and had to code up a solver from scratch to find the best solution that day to stay on the island, metaheuristics start to look a lot more attractive, regardless of problem type.  I.e. always take your pre-solve set-up time into account.  If you spend 3 weeks setting things up to reduce the solve time from 3 hours to 3 minutes, not a clear win ... unless it is for a paper:)&lt;/p&gt;&#xA;" OwnerUserId="712" LastEditorUserId="56" LastEditDate="2019-06-28T13:18:19.127" LastActivityDate="2019-06-28T13:18:19.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="745" PostTypeId="2" ParentId="709" CreationDate="2019-06-26T00:22:24.563" Score="2" Body="&lt;p&gt;The answer is: of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, nonconvex, global optimization, is a huge and challenging area, and arguably one of the most interesting. If you limit the scope to finding a&#xA;nearby local minimum in a continuous space, then the answer is an easy &quot;no&quot; almost by definition. But for finding a nearby local minimum in a discrete&#xA;space a simple (discrete) local search is also sufficient, so no meta-heuristic needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, I would agree with the previous answers, in that the most direct application of meta-heuristics to continuous problems seems to be not very&#xA;competitive. In metaheuristics you usually need to instantiate some problem-specific components such as local search neighborhoods, recombination&#xA;operators, or constructive heuristics. In continuous optimization these components often are naturally given, e.g. an &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-neighborhood in a&#xA;local search for some fixed step size &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;, or a convex combination of two solutions. In this case you end up with a generic approach, that can&#xA;easily beaten by one the more specific approaches to continuous optimization, that use the extra structure available (e.g. gradients, dynamic steps&#xA;sizes, etc.). This is probably why &quot;classic&quot; meta-heuristics such a Tabu Search for continous optimization are rare (although &lt;a href=&quot;https://dx.doi.org/10.1007/978-1-4615-6089-0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Glover &amp;amp; Laguna, Tabu&#xA;search&lt;/a&gt; has two short sections 7.7 and 8.8.1 on continuous optimization).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, two examples of what I believe to be successful meta-heuristic strategies for continuous optimization:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Continuous GRASP (C-GRASP): there's a chapter &quot;GRASP for continuous optimization&quot; in &lt;a href=&quot;https://dx.doi.org/10.1007/978-1-4939-6530-4&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ribeiro, Resende, &lt;em&gt;Optimization by&#xA;GRASP&lt;/em&gt;&lt;/a&gt; including some applications.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Covariance matrix adaptation evolution strategies (CMA-ES). &lt;a href=&quot;https://arxiv.org/pdf/1604.00772.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hansen (2016)&lt;/a&gt; is a good introduction. Citing&#xA;&lt;a href=&quot;https://doi.org/10.1007/978-3-319-91086-4_8&quot; rel=&quot;nofollow noreferrer&quot;&gt;Whitley (2018)&lt;/a&gt;, CMA-ES &quot;have now replaced genetic algorithms for real-valued parameter&#xA;optimization&quot;. Arguably, they borrow some good ideas from continuous optimization, but still rely on evolutionary principles.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-26T00:32:03.257" LastActivityDate="2019-06-26T00:32:03.257" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="746" PostTypeId="2" ParentId="738" CreationDate="2019-06-26T03:33:15.287" Score="12" Body="&lt;p&gt;This is a very broad question and there is a lot going on here. So I will provide a few initial thoughts; hopefully others will chime in as well; and then you might want to post more specific questions, which will be easier for us to provide more concrete answers to. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The approach you outlined is focused on the &lt;strong&gt;inventory level&lt;/strong&gt; (IL). It assumes that there is a function &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;, which gives the (expected) profit if the inventory level is &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. You are suggesting a statistical approach for estimating the &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; functions, and then an optimization approach to allocate the products among the stores according to the various stores' &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; functions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more standard supply chain-oriented approach would be instead to focus on the &lt;strong&gt;demand&lt;/strong&gt;, or really on its probability distribution, at each store. Then use cost/revenue parameters to build a model &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; of the expected profit as a function of the inventory level; and then you could allocate the products accordingly, again using an optimization model. I'm not sure whether this approach will be better than yours, but here are a few advantages going for it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It uses historical data to estimate a random variable (the demand) rather than something that is a &lt;em&gt;function&lt;/em&gt; of the random variable (the profit). &lt;/li&gt;&#xA;&lt;li&gt;It draws on well-established methods from the supply chain literature. &lt;/li&gt;&#xA;&lt;li&gt;If the historical data contains profit data, it is probably an aggregate number that reflects many things that happened that affected the profit, such as promotions, bad weather, a sale by a competitor, a surprise endorsement from a Twitter celebrity, whatever. That makes your function &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; very noisy. But in the demand-centric approach, you build the function &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; from more primitive elements—the demand distribution and per-unit cost or revenue parameters, which are easier to estimate.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;One problem with the demand-centric approach is &lt;em&gt;censoring&lt;/em&gt;: If the store ran out of inventory, then you don't know what the actual demand was, you only know that the demand was &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; the inventory level. There are methods to deal with this (google &quot;censored demand data&quot;) but they are imperfect, obviously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially what I am proposing is as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Estimate the demand distribution at each store using historical data and any forecasting/estimation techniques you like. If you want to use ML, this is a perfect spot to do it.&lt;/li&gt;&#xA;&lt;li&gt;Estimate the per-unit parameters like the cost to buy each item from the supplier, the cost to hold each item in inventory, the revenue from selling each item, etc. This might require talking to the company's supply chain managers and/or accountants. But most companies are used to thinking about these parameters; it shouldn't be a foreign concept.&lt;/li&gt;&#xA;&lt;li&gt;The classical &lt;a href=&quot;https://en.wikipedia.org/wiki/Newsvendor_model&quot; rel=&quot;noreferrer&quot;&gt;newsvendor problem&lt;/a&gt; would give you the optimal inventory level at each store &lt;em&gt;if&lt;/em&gt; there were no constraints on how much you could send to each store. But of course there are, in particular you have a finite number of units that you want to distribute to the stores. Therefore:&lt;/li&gt;&#xA;&lt;li&gt;Build some kind of optimization model for doing the allocation. The model would basically have the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\text{maximize} \quad &amp;amp; \mathbb{E}\left[\sum_n g_n(x_n)\right] \\&#xA;\text{subject to} \quad &amp;amp; \sum_n x_n = [\text{number of units available}]&#xA;\end{align}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; is the inventory level allocated to store &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_n(\cdot)$&lt;/span&gt; is the profit function for store &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. (&lt;span class=&quot;math-container&quot;&gt;$g_n(x)$&lt;/span&gt; is essentially the newsvendor expected-profit function.) The objective function will be concave, but since this is a maximization problem, it might still be tractable. You can formulate it in a modeling language like AMPL or GAMS, or using a package like &lt;code&gt;PuLP&lt;/code&gt; for Python, and then solve it using a commercial solver like CPLEX or Gurobi, or an open-source solver.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Hope this helps, and good luck!&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-06-26T03:33:15.287" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="747" PostTypeId="1" AcceptedAnswerId="769" CreationDate="2019-06-26T10:16:31.293" Score="16" ViewCount="1061" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;There are &lt;span class=&quot;math-container&quot;&gt;$ N $&lt;/span&gt; bins with equal capacity &lt;span class=&quot;math-container&quot;&gt;$ C $&lt;/span&gt;. In addition, there are &lt;span class=&quot;math-container&quot;&gt;$ N $&lt;/span&gt; objects &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2, \dots, x_N $&lt;/span&gt; that need to be accommodated using the least amount of bins. Each object &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; has a volume &lt;span class=&quot;math-container&quot;&gt;$ v_i &amp;lt; C $&lt;/span&gt;. However, there is a penalization &lt;span class=&quot;math-container&quot;&gt;$ p_{ij} $&lt;/span&gt; for accommodating any two objects &lt;span class=&quot;math-container&quot;&gt;$x_i, x_j$&lt;/span&gt; together. This penalization is related to the shape incompatibility among objects, which causes capacity waste. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;To summarize, the objective is to minimize the number of bins used while taking into consideration the capacity constraints and penalization due to grouping.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need help to formulate this problem. My ultimate objective is to use dynamic programming to solve this problem but I cannot come up with a formulation, mainly due to the penalization policy. Also, if you have seen a similar problem before, please point me to the source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Further information:&lt;/strong&gt;&#xA;For instance, if three objects &lt;span class=&quot;math-container&quot;&gt;$ x_1, x_2, x_3$&lt;/span&gt; are put together in the same bin, the overall occupied volume is &lt;span class=&quot;math-container&quot;&gt;$ v_1 +  v_2 + v_3 + p_{12} + p_{13} + p_{23}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&#xA;I just want to thank you all for your help. Thank you @MarcoLübbecke for the paper you shared about bin packing with conflicts. Thank you @RenaudM for the two formulations you proposed and for pointing me to this article in your blog &lt;a href=&quot;https://orandtricks.wordpress.com/2013/08/12/planning-your-wedding-is-not-easy-and-i-am-not-even-speaking-of-handling-the-brides-moods/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://orandtricks.wordpress.com/2013/08/12/planning-your-wedding-is-not-easy-and-i-am-not-even-speaking-of-handling-the-brides-moods/&lt;/a&gt; about the issue with symmetric formulations. Thank you @RobPratt for your simplified formulation. I have implemented @RobPratt's formulation and @RenaudM's first approach, and for small-scale problems they perform the same. I aim at developing a dynamic programming solution for either of these two formulations. If I succeed I will post the solution. Thank you again for your time and help in this matter.&lt;/p&gt;&#xA;" OwnerUserId="719" LastEditorUserId="123" LastEditDate="2019-11-08T07:40:41.590" LastActivityDate="2019-11-08T07:40:41.590" Title="Bin Packing with Relational Penalization" Tags="|modeling|combinatorial-optimization|quadratic-programming|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="748" PostTypeId="2" ParentId="747" CreationDate="2019-06-26T11:22:16.893" Score="8" Body="&lt;p&gt;If you are just looking for a formulation here is one (not particularly good due to symmetries, I'll rework it if I can think of something better in this regard).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; be an arbitrary upper bound on the minimum number of bins needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$a_{i,k} \in [0,1]$&lt;/span&gt; be a binary variable representing the assignment of object &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; to bin &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$b_{i,j,k} \in [0,1]$&lt;/span&gt; be a binary variable representing if object &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; are both assigned to bin &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$u_k \in [0,1]$&lt;/span&gt; be a binary variable representing if bin &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We then have the following model:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad \sum_{k \leq K} u_k\\\text{s.t.}&amp;amp;\quad a_{i,k} \leq u_k, &amp;amp;&amp;amp;\forall i \leq N, \forall k \leq K\\&amp;amp;\quad b_{i,j,k} \geq a_{i,k} + a_{j,k} - 1, &amp;amp;&amp;amp;{\small\forall i \leq N-1, \forall i+1 \leq j \leq N, \forall k \leq K}\\&amp;amp;\quad\sum_{i \leq N}a_{i,k}\cdot v_i + \sum_{i \leq N-1, j \geq i+1}b_{i,j,k}\cdot p_{i,j} \leq C, &amp;amp;&amp;amp;\forall k \leq K\end{align}&lt;/span&gt;&#xA;&lt;strong&gt;Edit 1:&lt;/strong&gt;&#xA;As pointed out by @RobPratt I am missing the following constraint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k \leq K}a_{i,k} = 1, \forall i \leq N$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the last constraint is tighter with the following formulation:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i \leq N}a_{i,k}.v_i + \sum_{i \leq N-1, j \geq i+1}b_{i,j,k}.p_{i,j} \leq C\cdot u_k, \forall k \leq K$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I could find a symmetry less model (would be grateful to anybody pointing out errors in it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let us call &lt;span class=&quot;math-container&quot;&gt;$t_{i,j} \in [0,1], \forall i &amp;lt; j \leq N$&lt;/span&gt; the binary (decision) variable indicating that &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are put in the same bin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let us call &lt;span class=&quot;math-container&quot;&gt;$b_i \in [0,1], \forall i \leq N$&lt;/span&gt; a helper variable letting us find out that &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is used to represent one bin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let us call &lt;span class=&quot;math-container&quot;&gt;$r_{i,j} \in [0,1], \forall i &amp;lt; j \leq N$&lt;/span&gt; a helper variable indicating that &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are put in the same bin and that &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is used to represent that bin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We then have the following model:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{2}\min&amp;amp;\quad\sum_{i \leq N}b_i\\\text{s.t.}&amp;amp;\quad\sum_{j &amp;lt; i}t_{j,i}\cdot(v_j + p_{j,i}) + \sum_{j &amp;gt; i}t_{i,j}\cdot(v_j + p_{i,j}) \leq C - v_i, &amp;amp;&amp;amp;\,\,\forall i \leq N\tag1\\&amp;amp;\quad\sum_{j &amp;lt; i}r_{j,i} + b_i = 1, &amp;amp;&amp;amp;\,\,\forall i \leq N\tag2\\&amp;amp;\quad r_{i,j} \leq t_{i,j}, &amp;amp;&amp;amp;\,\,\forall i &amp;lt; j \leq N\tag3\\&amp;amp;\quad r_{i,j} \leq b_i, &amp;amp;&amp;amp;\,\,\forall i &amp;lt; j \leq N\tag4\\&amp;amp;\quad t_{i,k} \geq t_{i,j} + t_{j,k} - 1, &amp;amp;&amp;amp;\,\,\forall i &amp;lt; j &amp;lt; k \leq N\tag5\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 3:&lt;/strong&gt;&#xA;As correctly pointed out by @RobPratt constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; is not constraining enough. To tackle that let’s add an extra variable:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$s_{i,j,k} \in [0,1], \forall i &amp;lt; j &amp;lt; k \leq N$&lt;/span&gt; be a helper variable indicating if &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; are in the same bin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; then becomes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\small\sum_{j &amp;lt; i}t_{j,i}\cdot(v_j + p_{j,i}) + \sum_{j &amp;gt; i}t_{i,j}\cdot(v_j + p_{i,j}) +\sum_{i &amp;lt; j &amp;lt; k}s_{i,j,k}\cdot p_{j,k} + \sum_{j &amp;lt; i &amp;lt; k}s_{j,i,k}\cdot p_{j,k} + \sum_{j &amp;lt; k &amp;lt; i} s_{j,k,i}\cdot p_{j,k}  \leq C - v_i, \forall i \leq N$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We also need the following extra constraints:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{2}s_{i,j,k} &amp;amp;\geq t_{i,j} + t_{j,k} - 1, &amp;amp;&amp;amp;\,\,\forall i &amp;lt; j &amp;lt; k \leq N\tag6\\t_{i,j} &amp;amp;\geq t_{i,k} + t_{j,k} - 1, &amp;amp;&amp;amp;\,\,\forall i &amp;lt; j &amp;lt; k \leq N\tag7\\t_{j,k} &amp;amp;\geq t_{i,j} + t_{i,k} - 1, &amp;amp;&amp;amp;\,\,\forall i &amp;lt; j &amp;lt; k \leq N\tag8\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="124" LastEditorUserId="123" LastEditDate="2019-11-08T07:36:54.550" LastActivityDate="2019-11-08T07:36:54.550" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="749" PostTypeId="2" ParentId="738" CreationDate="2019-06-26T11:30:29.420" Score="5" Body="&lt;p&gt;One possible way to estimate the distribution function or fitting curve from the historical data is to use ‎some of the statistical software such as R or Minitab. They have some facilities (and also easy to use) ‎to estimate them. AFAIK, they have a free or academic licence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For optimization, ‎if you don't have any force to construct a global profit function (as you said), ‎you might use some of the inventory optimization models with your own constraints ‎and using the optimization software (as Larry said) to solve the model.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-06-26T11:30:29.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="750" PostTypeId="5" CreationDate="2019-06-26T11:36:15.407" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-26T11:36:15.407" LastActivityDate="2019-06-26T11:36:15.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="751" PostTypeId="4" CreationDate="2019-06-26T11:36:15.407" Score="0" Body="For questions on first-order necessary conditions for optimality in non-linear programs due to Karush, Kuhn, and Tucker." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-28T18:33:50.673" LastActivityDate="2019-06-28T18:33:50.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="752" PostTypeId="5" CreationDate="2019-06-26T11:42:08.483" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-26T11:42:08.483" LastActivityDate="2019-06-26T11:42:08.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="753" PostTypeId="4" CreationDate="2019-06-26T11:42:08.483" Score="0" Body="For questions on matchings, i.e. sets of disjoint edges of an undirected graph." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-28T18:37:26.583" LastActivityDate="2019-06-28T18:37:26.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="754" PostTypeId="2" ParentId="747" CreationDate="2019-06-26T11:48:42.723" Score="12" Body="&lt;p&gt;This is very related to the &lt;em&gt;bin packing with conflicts&lt;/em&gt; problem (see eg. &lt;a href=&quot;https://www.math.u-bordeaux.fr/~rsadykov/papers/SadykovVanderbeck_BPPC.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;), where you model the conflict as &quot;soft&quot; (with a binary variable to indicate violation, with a penalty in the objective function).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The literature about this problem may contain a DP, too.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-06-26T11:48:42.723" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="755" PostTypeId="1" CreationDate="2019-06-26T13:24:39.960" Score="11" ViewCount="293" Body="&lt;p&gt;Are there any classes of NP-hard combinatorial optimization problems where Second order cone programs (SOCP) gives a better approximation than linear programs (LP)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for results in the flavor of Goemans and Williamson's celebrated result of approximating max-cut using semidefinite programs. But I want to use SOCP instead. &lt;/p&gt;&#xA;" OwnerUserId="161" LastEditorUserId="161" LastEditDate="2019-06-26T19:29:44.290" LastActivityDate="2019-06-26T19:29:44.290" Title="Can SOCPs approximate better than LPs?" Tags="|computational-complexity|conic-optimization|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="756" PostTypeId="2" ParentId="755" CreationDate="2019-06-26T14:20:04.907" Score="3" Body="&lt;p&gt;I had heard about comparisons of hierarchies for polynomial optimisations (LP vs. SOCP vs. SDP). For instance, have a look at &lt;a href=&quot;https://arxiv.org/pdf/1510.06797.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/1510.06797.pdf&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="156" LastActivityDate="2019-06-26T14:20:04.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="758" PostTypeId="1" AcceptedAnswerId="812" CreationDate="2019-06-26T16:26:08.040" Score="15" ViewCount="187" Body="&lt;p&gt;I am working on a very large optimisation problem. All variables are continuous, the objective is linear and the constraints convex, but I have many such constraints (on the order of &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; — actually, one constraint per possible solution to a given combinatorial problem with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables). Due to the large number of constraints, I generate them lazily, one by one, as they are required (in case you're wondering, the separation problem involves solving a nonconvex MIQP, but I can approximate it). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to have any kind of bound on the number of lazy constraints to be generated. Do you have any idea of what techniques could be applied? I am not necessarily interested by an algorithm that could be computing this number (without actually solving the problem and seeing that there are no more lazy constraints to add). However, I would also be keen on getting any insight in the distance to the optimal value when adding &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; lazy constraints (always found by the separation procedure as maximising the infeasibility). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There should be results like this, as it could be a way to tell whether a robust optimisation program or a TSP instance is hard to solve (i.e. requires an exponential number of lazy constraints, be they retrieved from the uncertainty set or subtour elimination). The only thing I could find was an application of robust optimisation in network routing (&lt;a href=&quot;https://ttic.uchicago.edu/~harry/pdf/optimal_oblivious_journal.pdf&quot; rel=&quot;noreferrer&quot;&gt;Optimal Oblivious Routing in Polynomial Time&lt;/a&gt;), but the article did not really provide the required details to fully understand what they are doing: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;First, the polynomial bound on the number of iterations follows using the standard bounds on the size of the initial ellipsoid and the smallest “volume” of the feasible set.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="156" LastActivityDate="2019-07-04T14:28:25.100" Title="Bound on the number of constraints to be generated (lazy constraints)" Tags="|error-bounds|convexity|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="759" PostTypeId="5" CreationDate="2019-06-26T16:27:05.877" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-26T16:27:05.877" LastActivityDate="2019-06-26T16:27:05.877" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="760" PostTypeId="4" CreationDate="2019-06-26T16:27:05.877" Score="0" Body="Questions relevant to the PuLP modelling framework in Python" OwnerUserId="156" LastEditorUserId="156" LastEditDate="2019-06-26T20:22:40.393" LastActivityDate="2019-06-26T20:22:40.393" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="761" PostTypeId="2" ParentId="755" CreationDate="2019-06-26T18:06:08.340" Score="4" Body="&lt;p&gt;Interesting question! Unfortunately, Chan et. al. (2013) &lt;a href=&quot;https://arxiv.org/pdf/1309.0563.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/1309.0563.pdf&lt;/a&gt; have shown that any polynomially sized LP relaxation of max-cut has an integrality gap of &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2}$&lt;/span&gt; in the worst-case. Since, as pointed out in the comments, Ben-Tal and Nemirovski have shown that SOCPs can be approximated by polynomially-sized LPs, polynomially-sized SOCP relaxations of max-cut therefore have an integrality gap of &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2}$&lt;/span&gt; in the worst-case. &lt;/p&gt;&#xA;" OwnerUserId="43" LastActivityDate="2019-06-26T18:06:08.340" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="762" PostTypeId="2" ParentId="721" CreationDate="2019-06-26T18:17:10.510" Score="11" Body="&lt;p&gt;Sharing the same reservations on journal rankings I can add some more which are particular relevant for hiring decisions in Germany and Europe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The German association of business administration professors maintains the following journal rankings for different categories:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OR: &lt;a href=&quot;https://vhbonline.org/vhb4you/jourqual/vhb-jourqual-3/teilrating-or/&quot; rel=&quot;noreferrer&quot;&gt;https://vhbonline.org/vhb4you/jourqual/vhb-jourqual-3/teilrating-or/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OM: &lt;a href=&quot;https://vhbonline.org/vhb4you/jourqual/vhb-jourqual-3/teilrating-prod/&quot; rel=&quot;noreferrer&quot;&gt;https://vhbonline.org/vhb4you/jourqual/vhb-jourqual-3/teilrating-prod/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Business Administration: &lt;a href=&quot;https://vhbonline.org/vhb4you/jourqual/vhb-jourqual-3/teilrating-abwl/&quot; rel=&quot;noreferrer&quot;&gt;https://vhbonline.org/vhb4you/jourqual/vhb-jourqual-3/teilrating-abwl/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Logistics: &lt;a href=&quot;https://vhbonline.org/vhb4you/jourqual/vhb-jourqual-3/teilrating-log/&quot; rel=&quot;noreferrer&quot;&gt;https://vhbonline.org/vhb4you/jourqual/vhb-jourqual-3/teilrating-log/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For European business schools hiring the ERIM and FT50 lists are very important:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.erim.eur.nl/about-erim/erim-journals-list-ejl/&quot; rel=&quot;noreferrer&quot;&gt;https://www.erim.eur.nl/about-erim/erim-journals-list-ejl/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://research.library.gsu.edu/c.php?g=388883&amp;amp;p=2638798&quot; rel=&quot;noreferrer&quot;&gt;https://research.library.gsu.edu/c.php?g=388883&amp;amp;p=2638798&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="33" LastActivityDate="2019-06-26T18:17:10.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="763" PostTypeId="1" AcceptedAnswerId="764" CreationDate="2019-06-26T18:19:18.713" Score="8" ViewCount="1343" Body="&lt;p&gt;I was trying to read a &lt;code&gt;MPS&lt;/code&gt; file by using the &lt;code&gt;PuLP&lt;/code&gt; package in the Python, but I can't find any related documents on it. Does anybody know, is there any way to read an LP/MPS file on the &lt;code&gt;PuLP&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="162" LastEditDate="2019-06-26T19:29:57.733" LastActivityDate="2019-06-26T19:29:57.733" Title="Read an LP/MPS file in the PuLP" Tags="|mixed-integer-programming|solver|python|pulp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="764" PostTypeId="2" ParentId="763" CreationDate="2019-06-26T18:50:14.713" Score="7" Body="&lt;p&gt;According to PuLP's &lt;a href=&quot;https://pythonhosted.org/PuLP/main/amply.html#Amply.load_file&quot; rel=&quot;noreferrer&quot;&gt;documentation&lt;/a&gt;, it seems that &lt;code&gt;load_file&lt;/code&gt; function in PuLP's &lt;code&gt;Amply&lt;/code&gt; class can only handle AMPL files with a subset of AMPL syntax for data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you want to use those LP/MPS files in &lt;code&gt;PuLP&lt;/code&gt;, you may have to first convert them into AMPL files. You can either write a small script by yourself or use some existing scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some discussions (&lt;a href=&quot;https://groups.google.com/forum/#!topic/ampl/5Q0NEALTBe4&quot; rel=&quot;noreferrer&quot;&gt;post 1&lt;/a&gt;, &lt;a href=&quot;https://groups.google.com/forum/#!topic/ampl/R6g4oT6IdyI&quot; rel=&quot;noreferrer&quot;&gt;post 2&lt;/a&gt;) in AMPL users group on how to do that or whether it is a good idea.&lt;/p&gt;&#xA;" OwnerUserId="162" LastActivityDate="2019-06-26T18:50:14.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="765" PostTypeId="2" ParentId="57" CreationDate="2019-06-26T19:13:54.783" Score="7" Body="&lt;p&gt;Another resource is &lt;a href=&quot;https://ampl.com/MEETINGS/TALKS/2014_03_Houston_TA-01.pdf&quot; rel=&quot;noreferrer&quot;&gt;&quot;Strategies for “Not Linear” Optimization&quot;&lt;/a&gt; from the AMPL group.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-06-26T19:13:54.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="766" PostTypeId="1" AcceptedAnswerId="1422" CreationDate="2019-06-26T19:32:11.017" Score="11" ViewCount="206" Body="&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$P = \{x\in\mathbb R^n: Ax \leq b\}$&lt;/span&gt;,  I want to decide if &lt;span class=&quot;math-container&quot;&gt;$(\mathbb Z^\ell \times \mathbb R^{n-\ell}) \cap \operatorname{relint}(P)$&lt;/span&gt; is non-empty. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this problem in NP?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;One idea is to check if &lt;span class=&quot;math-container&quot;&gt;$P_\varepsilon \cap (\mathbb Z^\ell \times \mathbb R^{n-\ell})$&lt;/span&gt; is non-empty by solving a MILP, where &lt;span class=&quot;math-container&quot;&gt;$P_\varepsilon = \{x\in\mathbb R^n: Ax \leq b - \varepsilon e\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; is a vector of ones. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then how do I choose a &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt; whose representation is polynomially large in the description of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, so I don't end up cutting away some integer point? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can assume &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; to have integer entries only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think, if I have &lt;span class=&quot;math-container&quot;&gt;$\ell = n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; full-dimensional, we can choose &lt;span class=&quot;math-container&quot;&gt;$\varepsilon = 1$&lt;/span&gt;. But what if &lt;span class=&quot;math-container&quot;&gt;$\ell &amp;lt; n$&lt;/span&gt; strictly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is not full-dimensional, we can do some transformations to get around it.&lt;/p&gt;&#xA;" OwnerUserId="161" LastEditorUserId="232" LastEditDate="2019-08-31T13:21:15.210" LastActivityDate="2019-08-31T13:21:15.210" Title="Is deciding the presence of mixed-integer points in the relative interior of a polyhedron in NP?" Tags="|mixed-integer-programming|integer-programming|computational-complexity|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="767" PostTypeId="2" ParentId="57" CreationDate="2019-06-26T19:43:56.547" Score="9" Body="&lt;p&gt;What about &lt;a href=&quot;https://dspace.mit.edu/handle/1721.1/96480&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;Mixed Integer Linear Programming Formulation Techniques&lt;/em&gt;&lt;/a&gt;, J.P. Vielma, SIAM Rev., 57(1), 3–57, 2015?&lt;/p&gt;&#xA;" OwnerUserId="58" LastEditorUserId="58" LastEditDate="2019-06-26T20:21:47.923" LastActivityDate="2019-06-26T20:21:47.923" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="768" PostTypeId="2" ParentId="732" CreationDate="2019-06-26T20:47:59.233" Score="30" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;... Do you have a set &lt;a href=&quot;https://en.wikipedia.org/wiki/Constraint_solver#Constraint_programming_libraries_for_imperative_programming_languages&quot; rel=&quot;noreferrer&quot;&gt;constraint programming&lt;/a&gt; solver that you always use, no matter which global constraint you actually need (implementing the needed global constraint yourself if needed)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Find one that is well supported, that you understand to some extent, and that is powerful enough (speed and expressiveness) to suit your future needs. &lt;strong&gt;Invest&lt;/strong&gt; your time in choosing a good tool and learning to use it well, then implementing constraints will be easier than struggling with a tool that is inadequate for the job.&lt;/p&gt;&#xA;&lt;p&gt;There are online tools for &lt;a href=&quot;https://online-optimizer.appspot.com/?model=builtin:default.mod&quot; rel=&quot;noreferrer&quot;&gt;linear optimization&lt;/a&gt;, constraint solving, even an extension for Microsoft Excel called &lt;a href=&quot;https://opensolver.org/&quot; rel=&quot;noreferrer&quot;&gt;OpenSolver&lt;/a&gt; which extends Excel’s built-in Solver with more powerful solvers. &lt;a href=&quot;http://www.constraintsolving.com/solvers&quot; rel=&quot;noreferrer&quot;&gt;Constraint Logic Solvers&lt;/a&gt; are available which run on many different languages:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.constraintsolving.com/solvers/java-based-solvers&quot; rel=&quot;noreferrer&quot;&gt;Java-based constraint solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.constraintsolving.com/solvers/c-based-constraint-solvers&quot; rel=&quot;noreferrer&quot;&gt;C-based constraint solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.constraintsolving.com/solvers/c-based-constraint-solvers-2&quot; rel=&quot;noreferrer&quot;&gt;C++ -based constraint solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.constraintsolving.com/solvers/c-c-python-and-tcl-based-constraint-solver&quot; rel=&quot;noreferrer&quot;&gt;C, C++, Python and Tcl based constraint solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.constraintsolving.com/solvers/cjavapythonscheme-and-smalltalk-based-constraint-solver&quot; rel=&quot;noreferrer&quot;&gt;C++/Java/Python/Scheme and Smalltalk-based constraint solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.constraintsolving.com/solvers/python-based-constraint-solver&quot; rel=&quot;noreferrer&quot;&gt;Python-based constraint solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.constraintsolving.com/solvers/prolog-based-constraint-solvers&quot; rel=&quot;noreferrer&quot;&gt;PROLOG-based constraint solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.constraintsolving.com/solvers/vb-net-constraint-solver&quot; rel=&quot;noreferrer&quot;&gt;VB.NET-based constraint solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.constraintsolving.com/solvers/mozart-oz-based-constraint-solvers&quot; rel=&quot;noreferrer&quot;&gt;Mozart-Oz-based constraint solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.constraintsolving.com/solvers/other-constraint-solvers&quot; rel=&quot;noreferrer&quot;&gt;Other constraint solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Which to choose is partly a function of many things. Different Contraint Programming Solvers perform better than others in &lt;a href=&quot;https://www.minizinc.org/challenge.html&quot; rel=&quot;noreferrer&quot;&gt;benchmarks&lt;/a&gt;, speed and ability is one aspect to consider.&lt;/p&gt;&#xA;&lt;p&gt;Focus on how easy is it to learn a system, and the modelling aspect. Consider the syntax, element constraint, &lt;a href=&quot;https://www.swi-prolog.org/pldoc/man?section=clpfd-reification&quot; rel=&quot;noreferrer&quot;&gt;reification&lt;/a&gt; and defining predicates (decompositions). Look for community support and the number of examples, documentation, etc.&lt;/p&gt;&#xA;&lt;p&gt;You'll notice that Google's &lt;a href=&quot;https://developers.google.com/optimization/&quot; rel=&quot;noreferrer&quot;&gt;OR-Tools&lt;/a&gt; has a Stack Overflow &lt;a href=&quot;https://stackoverflow.com/questions/tagged/or-tools&quot;&gt;tag for OR-Tools&lt;/a&gt; and is free. In Java, there's &lt;a href=&quot;https://www.optaplanner.org/&quot; rel=&quot;noreferrer&quot;&gt;OptaPlanner&lt;/a&gt; (&lt;a href=&quot;https://stackoverflow.com/questions/tagged/optaplanner&quot;&gt;StackOverflow&lt;/a&gt;) and &lt;a href=&quot;http://www.choco-solver.org/&quot; rel=&quot;noreferrer&quot;&gt;Choco&lt;/a&gt; (&lt;a href=&quot;https://stackoverflow.com/questions/tagged/choco&quot;&gt;StackOverflow&lt;/a&gt;), both open source too. OR-Tools is placed well in the benchmarks:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;&lt;a href=&quot;https://developers.google.com/optimization/&quot; rel=&quot;noreferrer&quot;&gt;OR-Tools&lt;/a&gt; is an open source software suite for optimization, tuned for tackling the world's toughest problems in vehicle routing, flows, integer and linear programming, and constraint programming.&lt;/p&gt;&#xA;&lt;p&gt;After modeling your problem in the programming language of your choice, you can use any of a half dozen solvers to solve it: commercial solvers such as Gurobi or CPLEX, or open-source solvers such as SCIP, GLPK, or Google's GLOP and award-winning CP-SAT.&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Further afield are proof solvers such as &lt;a href=&quot;http://www.cs.utexas.edu/users/moore/acl2/&quot; rel=&quot;noreferrer&quot;&gt;ACL2&lt;/a&gt; (A Computational Logic for Applicative Common Lisp), an extension to &lt;a href=&quot;https://en.wikipedia.org/wiki/Lisp_(programming_language)&quot; rel=&quot;noreferrer&quot;&gt;Lisp&lt;/a&gt; which is itself an &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S1570868307000602&quot; rel=&quot;noreferrer&quot;&gt;extensible&lt;/a&gt; theory in a &lt;a href=&quot;https://en.wikipedia.org/wiki/First-order_logic&quot; rel=&quot;noreferrer&quot;&gt;first-order logic&lt;/a&gt;, and an &lt;a href=&quot;https://en.wikipedia.org/wiki/Automated_theorem_proving#Software_systems&quot; rel=&quot;noreferrer&quot;&gt;automated theorem prover&lt;/a&gt;. It represents a &lt;strong&gt;difficult&lt;/strong&gt; uphill climb, but it produces programs capable of proving themselves to be correct.&lt;/p&gt;&#xA;&lt;p&gt;If you visit the &lt;a href=&quot;https://sofdem.github.io/gccat/gccat/index.html&quot; rel=&quot;noreferrer&quot;&gt;GCC&lt;/a&gt; you'll notice that they &lt;a href=&quot;https://sofdem.github.io/gccat/gccat/sec2.html&quot; rel=&quot;noreferrer&quot;&gt;describe the global contraints&lt;/a&gt; in &lt;a href=&quot;https://sofdem.github.io/gccat/gccat/sec4.5.1.html&quot; rel=&quot;noreferrer&quot;&gt;Prolog&lt;/a&gt; (and XML) so if you want to rely on that reference it's helpful if your &lt;a href=&quot;https://en.wikipedia.org/wiki/Constraint_logic_programming&quot; rel=&quot;noreferrer&quot;&gt;Constraint Logic Solver&lt;/a&gt; is written in (or accepts) &lt;a href=&quot;https://en.wikipedia.org/wiki/Prolog#Constraints&quot; rel=&quot;noreferrer&quot;&gt;Prolog&lt;/a&gt; (or that you are fluent in that language).&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;&lt;strong&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Prolog#Constraints&quot; rel=&quot;noreferrer&quot;&gt;Constraints&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;&#xA;Constraint logic programming extends Prolog to include concepts from constraint satisfaction. A constraint logic program allows constraints in the body of clauses, such as: A(X,Y) :- X+Y&amp;gt;0. It is suited to large-scale combinatorial optimisation problems and is thus useful for applications in industrial settings, such as automated time-tabling and production scheduling. Most Prolog systems ship with &lt;strong&gt;at least one constraint solver&lt;/strong&gt; for finite domains, and often also with solvers for other domains like rational numbers.&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There are global constraints in &lt;a href=&quot;https://sicstus.sics.se/sicstus/docs/latest4/html/sicstus.html/The-Prolog-Library.html#The-Prolog-Library&quot; rel=&quot;noreferrer&quot;&gt;SICStus Prolog&lt;/a&gt;, and five libraries: &lt;a href=&quot;https://sicstus.sics.se/sicstus/docs/latest4/html/sicstus.html/lib_002dchr.html#lib_002dchr&quot; rel=&quot;noreferrer&quot;&gt;Constraint Handling Rules&lt;/a&gt;, &lt;a href=&quot;https://sicstus.sics.se/sicstus/docs/latest4/html/sicstus.html/lib_002dclpb.html#lib_002dclpb&quot; rel=&quot;noreferrer&quot;&gt;Constraint Logic Programming over Booleans&lt;/a&gt; (unsupported since release 4.0.7), &lt;a href=&quot;https://sicstus.sics.se/sicstus/docs/latest4/html/sicstus.html/lib_002dclpfd.html#lib_002dclpfd&quot; rel=&quot;noreferrer&quot;&gt;Constraint Logic Programming over Finite Domains&lt;/a&gt;, &lt;a href=&quot;https://sicstus.sics.se/sicstus/docs/latest4/html/sicstus.html/lib_002dclpqr.html#lib_002dclpqr&quot; rel=&quot;noreferrer&quot;&gt;Constraint Logic Programming over Rationals or Reals&lt;/a&gt; (unsupported), and a &lt;a href=&quot;https://sicstus.sics.se/sicstus/docs/latest4/html/sicstus.html/lib_002dfdbg.html#lib_002dfdbg&quot; rel=&quot;noreferrer&quot;&gt;Finite Domain Constraint Debugger&lt;/a&gt; - it's quite a &lt;a href=&quot;https://sicstus.sics.se/sicstus/docs/latest4/html/sicstus.html/&quot; rel=&quot;noreferrer&quot;&gt;full featured&lt;/a&gt; version of Prolog, but it's &lt;a href=&quot;https://sicstus.sics.se/order4.html&quot; rel=&quot;noreferrer&quot;&gt;not free&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.picat-lang.org/bprolog/&quot; rel=&quot;noreferrer&quot;&gt;B-Prolog&lt;/a&gt; is a &lt;a href=&quot;http://www.picat-lang.org/bprolog/performance.htm&quot; rel=&quot;noreferrer&quot;&gt;fast alternative&lt;/a&gt; and while it does have a &lt;a href=&quot;https://stackoverflow.com/questions/tagged/b-prolog&quot;&gt;tag on SO&lt;/a&gt; there's barely a dozen uses of it. But if you look at Wikipedia's &lt;a href=&quot;https://en.wikipedia.org/wiki/Comparison_of_Prolog_implementations&quot; rel=&quot;noreferrer&quot;&gt;comparison of Prolog implementations&lt;/a&gt; you'll notice that it has a feature set comparable to SICStus.&lt;/p&gt;&#xA;&lt;p&gt;So you should probably favor a Prolog implementation, but there's no reason why you couldn't &lt;a href=&quot;http://hackage.haskell.org/packages/search?terms=Constraint&quot; rel=&quot;noreferrer&quot;&gt;use Haskell&lt;/a&gt;. Which underlying language is used to run whichever solver is very much a personal preference, but choosing one language and a &lt;em&gt;solver framework&lt;/em&gt; with a large community and numerous libraries for different solvers (or the ability to output for a long list of separate solver executables) ensures that you'll always be able to progress forward rather than getting stuck implementing missing features or asking for assistance.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Additional Info&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;One way to try different solvers is to visit the &lt;a href=&quot;https://neos-server.org/neos/&quot; rel=&quot;noreferrer&quot;&gt;NEOS Server&lt;/a&gt;, a &lt;strong&gt;free&lt;/strong&gt; internet-based service for solving numerical optimization problems. Hosted by the Wisconsin Institute for Discovery at the University of Wisconsin in Madison, the NEOS Server provides access to more than &lt;a href=&quot;https://neos-server.org/neos/solvers/index.html&quot; rel=&quot;noreferrer&quot;&gt;60 state-of-the-art solvers&lt;/a&gt; in more than a dozen optimization categories. There are &lt;a href=&quot;https://neos-guide.org/content/third-party-tools&quot; rel=&quot;noreferrer&quot;&gt;3rd party submission tools&lt;/a&gt; that allow you to write a simple program at home and submit your job to the server. See the &lt;a href=&quot;https://neos-guide.org/content/FAQ&quot; rel=&quot;noreferrer&quot;&gt;NEOS FAQ&lt;/a&gt; for details.&lt;/p&gt;&#xA;&lt;p&gt;A means to get your problem solutions reviewed is at &lt;a href=&quot;https://www.optil.io/optilion/&quot; rel=&quot;noreferrer&quot;&gt;OPTIL.io&lt;/a&gt;, an on-line judge system that receives algorithmic solutions of optimization problems in a form of source code from the crowd of developers, compiles it, executes in a homogeneous run-time environment and objectively evaluates using the set of test cases. Problems that are solved can be provided by external companies or scientists. Solutions can be submitted in almost any programming language.&lt;/p&gt;&#xA;&lt;p&gt;A good tool to compare some of the popular solvers is the Apache Software Foundation's &lt;a href=&quot;http://openjvm.jvmhost.net/CPSolvers/&quot; rel=&quot;noreferrer&quot;&gt;Constraint Programming Solvers comparison tool&lt;/a&gt;. For example comparing Choco, Picat, and OR-Tools shows that OR-Tools requires quite a lengthy specification compared to Picat, while Choco is certainly more mature and supports more Global Constraints.&lt;/p&gt;&#xA;&lt;p&gt;Hakan Kjellerstrand's &lt;a href=&quot;http://www.hakank.org/constraint_programming/&quot; rel=&quot;noreferrer&quot;&gt;webpage&lt;/a&gt; and &lt;a href=&quot;http://www.hakank.org/constraint_programming_blog/&quot; rel=&quot;noreferrer&quot;&gt;blog&lt;/a&gt; on Constraint Programming while not updated in the past year has a decade of archives and (amongst numerous other pages) a webpage about &lt;a href=&quot;http://www.hakank.org/constraint_programming_blog/global_constraints/&quot; rel=&quot;noreferrer&quot;&gt;Global Constraints&lt;/a&gt;, also one on &lt;a href=&quot;http://www.hakank.org/constraint_programming_blog/operations_research/&quot; rel=&quot;noreferrer&quot;&gt;Operations Research&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Wikipedia's has webpages on: &lt;a href=&quot;https://en.wikipedia.org/wiki/Constraint_satisfaction&quot; rel=&quot;noreferrer&quot;&gt;Constraint Satisfaction&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Hill_climbing&quot; rel=&quot;noreferrer&quot;&gt;Hill Climbing&lt;/a&gt; (but nothing for &lt;a href=&quot;https://en.wikipedia.org/wiki/Late_acceptance_hill_climbing&quot; rel=&quot;noreferrer&quot;&gt;Late Acceptance Hill Climbing&lt;/a&gt; (&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221716305495?via%3Dihub&quot; rel=&quot;noreferrer&quot;&gt;LAHC&lt;/a&gt;)). LAHC is one of the techniques employed by &lt;a href=&quot;https://www.optaplanner.org/&quot; rel=&quot;noreferrer&quot;&gt;OptaPlanner&lt;/a&gt;, an AI constraint solver. Google returns over &lt;a href=&quot;https://www.google.com/search?q=Late%20acceptance%20hill%20climbing&quot; rel=&quot;noreferrer&quot;&gt;70M results&lt;/a&gt; for &amp;quot;Late Acceptance Hill Climbing&amp;quot; - lesson: don't let one site's &lt;em&gt;miss&lt;/em&gt; (due to chosen search terms) make you miss out on other results, check multiple search terms and search engines. Another search term to use is &amp;quot;Late Acceptance Anytime Algorithm&amp;quot; (related to LAHC) which returns another &lt;a href=&quot;https://www.google.com/search?q=Late%20acceptance%20Anytime%20algorithm&quot; rel=&quot;noreferrer&quot;&gt;56M results&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Some of the newest directions have the least information available, it's important to do your own research and determine which direction you wish to go. Breakthroughs in AI and Neuromorphic Computing are frequent enough that best laid plans go awry a few years later; but as long as the legacy tools you have available are sufficiently capable and fast enough for your needs you shouldn't worry about bleeding edge too much, nor completely discount it either.&lt;/p&gt;&#xA;&lt;p&gt;The website arXiv has &lt;a href=&quot;https://arxiv.org/search/?query=Constraint%20Programming&amp;amp;searchtype=all&amp;amp;source=header&quot; rel=&quot;noreferrer&quot;&gt;3761 results&lt;/a&gt; for &amp;quot;Constraint Programming&amp;quot; and is an excellent source for researching the latest techniques.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I would like to clarify that I am absolutely not an expert when it comes to constraint programming (I happen to use it when it seems to be the right tool for the right job).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;A description of the &lt;a href=&quot;https://artint.info/html/ArtInt_109.html&quot; rel=&quot;noreferrer&quot;&gt;bottom-up&lt;/a&gt; and &lt;a href=&quot;https://artint.info/html/ArtInt_110.html&quot; rel=&quot;noreferrer&quot;&gt;top-down&lt;/a&gt; proof procedures used for &lt;a href=&quot;https://artint.info/html/ArtInt_46.html&quot; rel=&quot;noreferrer&quot;&gt;searching the problem space&lt;/a&gt; gives some insight into choosing your tool and approach.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-02-11T12:07:35.640" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="769" PostTypeId="2" ParentId="747" CreationDate="2019-06-26T21:04:00.780" Score="14" Body="&lt;p&gt;Here is a simpler symmetry-less formulation based on the one proposed by @RenaudM.  For &lt;span class=&quot;math-container&quot;&gt;$i \le j$&lt;/span&gt;, let binary variable &lt;span class=&quot;math-container&quot;&gt;$r_{i,j}$&lt;/span&gt; indicate that the bin represented by item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; contains item &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.  (Here, &lt;span class=&quot;math-container&quot;&gt;$r_{i,i}$&lt;/span&gt; corresponds to &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; in the other formulation.)  For &lt;span class=&quot;math-container&quot;&gt;$i \le j &amp;lt; k$&lt;/span&gt;, let binary variable &lt;span class=&quot;math-container&quot;&gt;$t_{i,j,k}$&lt;/span&gt; indicate that the bin represented by item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; contains both items &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.  Then we want to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_i r_{i,i}$&lt;/span&gt; subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i \le j} r_{i,j} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $j$}\\&#xA;r_{i,j} &amp;amp;\le r_{i,i} &amp;amp;&amp;amp;\text{for all $i&amp;lt;j$}\\&#xA;r_{i,j} + r_{i,k} - 1 &amp;amp;\le t_{i,j,k} &amp;amp;&amp;amp;\text{for all $i \le j &amp;lt; k$}\\&#xA;\sum_{j \ge i} v_j r_{i,j} + \sum_{i \le j &amp;lt; k} p_{j,k} t_{i,j,k} &amp;amp;\le C r_{i,i} &amp;amp;&amp;amp;\text{for all $i$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2019-06-27T17:12:29.213" LastActivityDate="2019-06-27T17:12:29.213" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="770" PostTypeId="2" ParentId="740" CreationDate="2019-06-26T21:29:41.860" Score="10" Body="&lt;p&gt;The following suggestion is conjecture (I don't do it myself) and certainly not guaranteed to prevent all possible errors. Develop your initial model, run it against multiple scenarios, and store the scenarios (parameter values) and solutions. As you modify the model, be sure to retain previous model versions (perhaps using a version control system, perhaps just by storing files).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now suppose that you have an older version A and a newer version B, and suppose that B has a modified objective function but the same constraints as A. Plug into B the parameters from each test scenario from A (make up any new objective parameters), solve B, and confirm that the solution does at least as well on the new objective as the solution from A. Also substitute the solution from A into B, solve for the values of any new variables if necessary, and confirm that the A solution satisfies all constraints in B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now suppose instead that B has the same objective as A but different constraints. Again, run B against each scenario used to test A. Verify that the solution to A (expanded with any new variables) either does no better than the solution to B or is infeasible in B. For extra credit, if the A solution is infeasible in B, verify that it should be (i.e., that any constraint it violates is one that it should violate).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All this is a bunch of work, so you'll have to decide if it's worth the effort. It's basically my analog of what is known in coding circles as &quot;unit testing&quot;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-06-26T21:29:41.860" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="771" PostTypeId="2" ParentId="357" CreationDate="2019-06-26T22:37:59.003" Score="8" Body="&lt;p&gt;François Louveaux (mostly known for the book on stochastic programming he coauthored with John Birge) and Quentin Louveaux, both of them in Belgium (UNamur and ULiège, respectively). &lt;/p&gt;&#xA;" OwnerUserId="156" LastActivityDate="2019-06-26T22:37:59.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="772" PostTypeId="2" ParentId="183" CreationDate="2019-06-26T22:47:17.000" Score="3" Body="&lt;p&gt;Reinforcement learning does not seem to be the most obvious choice in machine learning for optimisation. I have heard a lot of using supervised learning to decide the decisions to take when exploring a B&amp;amp;B tree (which could very straightforwardly be transformed into a reinforcement learning problem). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also have research in ML giving directly a good answer to your problem. For instance, using recurrent neural networks to deal with graphs: the output is a probability distribution on &quot;interesting&quot; edges of your graph, the ones you should consider taking for your solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One reference for all of this: &lt;a href=&quot;https://arxiv.org/abs/1811.06128&quot; rel=&quot;nofollow noreferrer&quot;&gt;Machine Learning for Combinatorial Optimization:a Methodological Tour d’Horizon&lt;/a&gt;. Section 3.2.1 to get complete solutions from ML, 3.2.3 to use ML within the B&amp;amp;B exploration.&lt;/p&gt;&#xA;" OwnerUserId="156" LastActivityDate="2019-06-26T22:47:17.000" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="773" PostTypeId="5" CreationDate="2019-06-27T02:18:41.133" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T02:18:41.133" LastActivityDate="2019-06-27T02:18:41.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="774" PostTypeId="4" CreationDate="2019-06-27T02:18:41.133" Score="0" Body="For questions related to journals that publish papers related to Operations Research." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-28T18:34:40.267" LastActivityDate="2019-06-28T18:34:40.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="775" PostTypeId="5" CreationDate="2019-06-27T02:20:36.977" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T02:20:36.977" LastActivityDate="2019-06-27T02:20:36.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="776" PostTypeId="4" CreationDate="2019-06-27T02:20:36.977" Score="0" Body="For questions related to hub location problems, in which we must determine the locations of hub facilities that ship to one another as well as to customer nodes. " OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-28T18:35:22.737" LastActivityDate="2019-06-28T18:35:22.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="777" PostTypeId="5" CreationDate="2019-06-27T02:22:35.210" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T02:22:35.210" LastActivityDate="2019-06-27T02:22:35.210" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="778" PostTypeId="4" CreationDate="2019-06-27T02:22:35.210" Score="0" Body="For questions related to processes that change randomly over time. Examples include Markov processes, random walks, and renewal processes." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-28T18:35:15.137" LastActivityDate="2019-06-28T18:35:15.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="779" PostTypeId="5" CreationDate="2019-06-27T02:23:58.673" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T02:23:58.673" LastActivityDate="2019-06-27T02:23:58.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="780" PostTypeId="4" CreationDate="2019-06-27T02:23:58.673" Score="0" Body="For questions related to Lagrange (or Lagrangian) multipliers, coefficients used to penalize violations of constraints that have been relaxed from an optimization problem." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-28T18:35:19.610" LastActivityDate="2019-06-28T18:35:19.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="781" PostTypeId="5" CreationDate="2019-06-27T02:26:02.643" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T02:26:02.643" LastActivityDate="2019-06-27T02:26:02.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="782" PostTypeId="4" CreationDate="2019-06-27T02:26:02.643" Score="0" Body="For questions related to probability distributions used to model demands for products or services, e.g., in an inventory or supply chain optimization context." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-28T18:34:45.400" LastActivityDate="2019-06-28T18:34:45.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="783" PostTypeId="5" CreationDate="2019-06-27T02:32:38.407" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T02:32:38.407" LastActivityDate="2019-06-27T02:32:38.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="784" PostTypeId="4" CreationDate="2019-06-27T02:32:38.407" Score="0" Body="For questions related to optimization problems in which one decision maker (the &quot;leader&quot;) chooses decision variables, then a second decision maker (the &quot;follower&quot;) chooses decision variables in response. The optimization problem is formulated from the leader's point of view and takes into account the follower's best response. Bilevel optimization is closely related to Stackelberg games." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-28T18:35:30.383" LastActivityDate="2019-06-28T18:35:30.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="785" PostTypeId="5" CreationDate="2019-06-27T02:40:27.357" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T02:40:27.357" LastActivityDate="2019-06-27T02:40:27.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="786" PostTypeId="4" CreationDate="2019-06-27T02:40:27.357" Score="0" Body="For questions related to a class of bilevel optimization problems called attacker-defender problems, in which an attacker attempts to disrupt a system (e.g. increase the travel times on edges in a network) and then a defender optimizes (e.g. solves a shortest path problem) on the disrupted network." OwnerUserId="38" LastEditorUserId="123" LastEditDate="2020-02-07T19:31:29.317" LastActivityDate="2020-02-07T19:31:29.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="787" PostTypeId="5" CreationDate="2019-06-27T02:42:07.310" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T02:42:07.310" LastActivityDate="2019-06-27T02:42:07.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="788" PostTypeId="4" CreationDate="2019-06-27T02:42:07.310" Score="0" Body="For questions related to optimization problems that are obtained from other optimization problems by increasing the feasible region, typically by removing one or more constraints or changing their right-hand sides." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-07-09T16:15:36.807" LastActivityDate="2019-07-09T16:15:36.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="789" PostTypeId="5" CreationDate="2019-06-27T02:42:58.973" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T02:42:58.973" LastActivityDate="2019-06-27T02:42:58.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="790" PostTypeId="4" CreationDate="2019-06-27T02:42:58.973" Score="0" Body="For questions related to Operations Research approaches for modeling, managing, or optimizing supply chains, systems designed to move goods from where they are produced to where they are consumed." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-28T18:37:43.310" LastActivityDate="2019-06-28T18:37:43.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="791" PostTypeId="5" CreationDate="2019-06-27T02:45:22.227" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T02:45:22.227" LastActivityDate="2019-06-27T02:45:22.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="792" PostTypeId="4" CreationDate="2019-06-27T02:45:22.227" Score="0" Body="For questions related to mechanisms for improving coordination within a supply chain, increasing the total expected supply chain profit. Examples include the wholesale price contract, the revenue sharing contract, and the buyback contract." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-28T18:34:34.823" LastActivityDate="2019-06-28T18:34:34.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="793" PostTypeId="5" CreationDate="2019-06-27T02:48:58.603" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T02:48:58.603" LastActivityDate="2019-06-27T02:48:58.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="794" PostTypeId="4" CreationDate="2019-06-27T02:48:58.603" Score="0" Body="For questions related to Stackelberg (also known as leader–follower) games, in which one player acts first and then the other player acts, usually having knowledge of the first player's actions. Stackelberg games are closely related to bilevel optimization models." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-28T18:34:30.540" LastActivityDate="2019-06-28T18:34:30.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="795" PostTypeId="5" CreationDate="2019-06-27T02:50:03.323" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T02:50:03.323" LastActivityDate="2019-06-27T02:50:03.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="796" PostTypeId="4" CreationDate="2019-06-27T02:50:03.323" Score="0" Body="For questions related to the (r,Q) inventory model, in which stochastic demands reduce the inventory level over time, and when the inventory position reaches the reorder point (r), an order is placed of size Q." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-06-28T18:34:54.033" LastActivityDate="2019-06-28T18:34:54.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="797" PostTypeId="1" AcceptedAnswerId="798" CreationDate="2019-06-27T05:24:43.470" Score="14" ViewCount="2076" Body="&lt;p&gt;I can remember that I spent some time in understanding how to formulate my first model. So I aimed at presenting a complete model here, wishing to save some time for students or researchers needing it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The model is a flow shop scheduling problem, presented in Wilson (1989), as following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\label{eq1}&#xA;z = \min (s_{m,n} + \sum_{j=1}^{n}{p_{m,j} z_{j,n}}) &#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;subject to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} &#xA;\sum_{j=1}^{n}{z_{j,i}} = 1, \quad 1 \leqslant i \leqslant n&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} &#xA;\sum_{i=1}^{n}{z_{j,i}} = 1, \quad 1 \leqslant j \leqslant n&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} &#xA;s_{1,1}=0 &#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} &#xA;s_{1,i} + \sum_{j=1}^{n}{p_{1,j} z_{j,i} = s_{1,i+1}}, \quad 1 \leqslant i \leqslant n-1 &#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} &#xA;s_{r,1} + \sum_{j=1}^{n}{p_{r,j} z_{j,1} = s_{r+1,1}}, \quad 1 \leqslant r \leqslant m-1 &#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} &#xA;s_{r,i} + \sum_{j=1}^{n}{p_{r,j} z_{j,i}\leqslant s_{r+1,i}}, \quad 1 \leqslant r \leqslant m-1, \quad 2 \leqslant i \leqslant n&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;s_{r,i} + \sum_{j=1}^{n}{p_{r,j} z_{j,i}\leqslant s_{r,i+1}}, \quad 2 \leqslant r \leqslant m, \quad 1 \leqslant i \leqslant n-1&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;z_{j,i} \in \{0,1\}, \quad 1 \leqslant j \leqslant n, \quad 1 \leqslant i \leqslant n&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;s_{r,i} \geqslant 0, \quad 1 \leqslant r \leqslant m, \quad 1 \leqslant i \leqslant n&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$s_{r,i}$&lt;/span&gt; is the starting time of job in position &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; on machine &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z_{j,i}$&lt;/span&gt; is equal to 1 if job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is assigned to position &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Also, &lt;span class=&quot;math-container&quot;&gt;$p_{r,j}$&lt;/span&gt; is the processing time of job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on machine &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;. I don't go to the details of the model as in not the purpose of this post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the question is how to formulate this model in Python, using the Gurobi solver. i.e. using the module gurobipy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Details of model can be found in:&#xA;Wilson JM. Alternative formulations of a flow-shop scheduling problem. &lt;em&gt;Journal of the Operational Research Society&lt;/em&gt; (1989) 40:395–399.&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-04-01T04:13:11.100" LastActivityDate="2021-09-22T08:12:02.837" Title="How to model a mixed-integer linear programming formulation in Python using Gurobi?" Tags="|mixed-integer-programming|python|gurobi|scheduling|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="798" PostTypeId="2" ParentId="797" CreationDate="2019-06-27T05:24:43.470" Score="12" Body="&lt;p&gt;Here is the complete implementation for the above-mentioned model.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from gurobipy import *&#xA;import numpy as np&#xA;&#xA;# Parameters needed are:&#xA;# (1) the total number of jobs (n). Here I denote it by &amp;quot;NumofJobs&amp;quot;&#xA;# (2) the total number of machines (m). Here I denote it by &amp;quot;NumofMachines&amp;quot;&#xA;# (3) the processing times.  Here I use a numpy matrix: &amp;quot;Tasktime[r, j]&amp;quot; : p_{r,j}&#xA;&#xA;# Based on the matrix Tasktime, we can set:&#xA;&#xA;NumofMachines = Tasktime.shape[0]&#xA;NumofJobs = Tasktime.shape[1]&#xA;&#xA;# Building the model:&#xA;m = Model (&amp;quot;Wilson&amp;quot;)&#xA;&#xA;&#xA;# Generating variables:&#xA;z = {}&#xA;for j in range(NumofJobs):&#xA;    for i in range(NumofJobs):&#xA;        z[j, i] = m.addVar(vtype=GRB.BINARY)&#xA;&#xA;s = {}&#xA;for r in range(NumofMachines):&#xA;    for j in range(NumofJobs):&#xA;        s[r, j] = m.addVar(vtype=GRB.CONTINUOUS)&#xA;&#xA;m.update()&#xA;&#xA;&#xA;# Generating constraints:&#xA;for i in range(NumofJobs):&#xA;    m.addConstr(quicksum(z[j, i] for j in range(NumofJobs)) == 1)&#xA;&#xA;for j in range(NumofJobs):&#xA;    m.addConstr(quicksum(z[j, i] for i in range(NumofJobs)) == 1)&#xA;&#xA;m.addConstr(s[0, 0] == 0)&#xA;&#xA;for i in range(NumofJobs - 1):&#xA;    m.addConstr(s[0, i] + quicksum((Tasktime[0, j]) * z[j, i] for j in range(NumofJobs)) == s[0, i + 1])&#xA;&#xA;for r in range(NumofMachines - 1):&#xA;    m.addConstr(s[r, 0] + quicksum((Tasktime[r, j]) * z[j, 0] for j in range(NumofJobs)) == s[r + 1, 0])&#xA;&#xA;for r in range(NumofMachines - 1):&#xA;    for i in range(1, NumofJobs):&#xA;        m.addConstr(s[r, i] + quicksum(Tasktime[r, j] * z[j, i] for j in range(NumofJobs)) &amp;lt;= s[r + 1, i])&#xA;&#xA;for r in range(1, NumofMachines):&#xA;    for i in range(NumofJobs - 1):&#xA;        m.addConstr(s[r, i] + quicksum(Tasktime[r, j] * z[j, i] for j in range(NumofJobs)) &amp;lt;= s[r, i + 1])&#xA;&#xA;&#xA;# Setting the objective function:&#xA;m.setObjective(s[NumofMachines - 1, NumofJobs - 1] + quicksum(Tasktime[NumofMachines - 1, j] * z[j, NumofJobs - 1] for j in range(NumofJobs)), GRB.MINIMIZE)&#xA;&#xA;&#xA;m.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2021-09-22T08:12:02.837" LastActivityDate="2021-09-22T08:12:02.837" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="799" PostTypeId="1" CreationDate="2019-06-27T06:01:53.653" Score="15" ViewCount="1329" Body="&lt;p&gt;In the context of discrete optimization, what exactly does it mean to &quot;quadratize&quot; a function? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The term seems to be used mainly by operations researchers, in my experience.&lt;/p&gt;&#xA;" OwnerUserId="727" LastEditorUserId="727" LastEditDate="2022-07-18T17:41:09.580" LastActivityDate="2022-07-18T17:41:09.580" Title="What is quadratization?" Tags="|integer-programming|quadratic-programming|terminology|qubo|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="800" PostTypeId="2" ParentId="799" CreationDate="2019-06-27T07:02:15.007" Score="15" Body="&lt;p&gt;One definition of quadratization (perhaps there is more) is provided in the paper by &lt;a href=&quot;https://pdfs.semanticscholar.org/681c/fec7c11135428b336e727be47e1b49949fb2.pdf&quot; rel=&quot;noreferrer&quot;&gt;Boros, 2018&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In non-mathematical terms, quadratization is defined as &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;a quadratic reformulation of the nonlinear problem obtained by introducing a set of auxiliary binary&#xA;  variables which can be optimized using quadratic optimization techniques.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Rewriting this in functional notation, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Given a pseudo-Boolean function &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$\{0,1\}^n$&lt;/span&gt;, we say that &lt;span class=&quot;math-container&quot;&gt;$g(x,y)$&lt;/span&gt; is a quadratization of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$g(x,y)$&lt;/span&gt; is a quadratic polynomial depending on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and on &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; auxiliary variables &lt;span class=&quot;math-container&quot;&gt;$y_1,\cdots,y_m$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$$f(x)=\min\limits_{y\in\{0,1\}^m}g(x,y)\quad\forall x\in\{0,1\}^n.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that a pseudo-Boolean function is one that maps from &lt;span class=&quot;math-container&quot;&gt;$\{0,1\}^n$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\Bbb R$&lt;/span&gt; which &quot;assigns a real value to each tuple of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; binary variables &lt;span class=&quot;math-container&quot;&gt;$x_1,\cdots,x_n$&lt;/span&gt;&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One addition where the name comes from: in the same way as we speak of &lt;em&gt;linearization&lt;/em&gt; (approximating a non-linear function or region by one or many linear functions) &lt;em&gt;quadratization&lt;/em&gt; means approximating a non-linear function by quadratic ones.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Boros, E., Crama, Y., Rodríguez-Heck, E. (2018). Quadratizations of symmetric pseudo-Boolean functions: sub-linear bounds on&#xA;the number of auxiliary variables. &lt;em&gt;ISAIM&lt;/em&gt;. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="354" LastEditDate="2019-06-27T13:19:48.073" LastActivityDate="2019-06-27T13:19:48.073" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="801" PostTypeId="1" AcceptedAnswerId="811" CreationDate="2019-06-27T14:08:51.223" Score="16" ViewCount="1291" Body="&lt;p&gt;I know that given &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ &#xA;S = \{ (x,y,z) \in \mathbb R^3: \ell_x \leq x \leq u_x; \ell_y \leq y \leq u_y; z = xy\}&#xA;$$&lt;/span&gt;&#xA;with finite lower and upper bounds, the McCormick envelope of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; gives the convex hull of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there other such known families of sets where the McCormick envelope gives the convex hull?&lt;/p&gt;&#xA;" OwnerUserId="161" LastEditorUserId="38" LastEditDate="2019-06-27T14:22:22.037" LastActivityDate="2019-06-28T00:08:17.613" Title="When is the McCormick envelope exact?" Tags="|mccormick|convex-hull|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="802" PostTypeId="5" CreationDate="2019-06-27T15:41:34.243" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T15:41:34.243" LastActivityDate="2019-06-27T15:41:34.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="803" PostTypeId="4" CreationDate="2019-06-27T15:41:34.243" Score="0" Body="For questions on problems that come from a finite representation of real numbers." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-28T18:34:19.637" LastActivityDate="2019-06-28T18:34:19.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="804" PostTypeId="5" CreationDate="2019-06-27T15:44:06.763" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-27T15:44:06.763" LastActivityDate="2019-06-27T15:44:06.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="805" PostTypeId="4" CreationDate="2019-06-27T15:44:06.763" Score="0" Body="For questions on Nash equilibria, i.e. solutions to game-theoretic problems that are stable in the sense that no player has an incentive to change one's strategy. " OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-28T18:34:24.720" LastActivityDate="2019-06-28T18:34:24.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="806" PostTypeId="2" ParentId="738" CreationDate="2019-06-27T16:43:54.957" Score="-2" Body="&lt;p&gt;Your approach could make sense if a customer's likelihood to buy depends on the number of units on the shelf. Typical inventory optimization assumes people arrive planning to buy a product or not, and either it's available when they get there or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If management does think that customer demand depends on inventory, you have a good use case for ML to see if they are correct. You would use some stats and regression models to demonstrate whether inventory being 5 is different than 50. At that point, you can decide on your next step. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If inventory level does matter, I still probably wouldn't try to infer unique profit functions for each store. I would instead add some kind of heuristic constraint like &quot;any store we stock should have at least &lt;span class=&quot;math-container&quot;&gt;$1/2$&lt;/span&gt; the optimal order-up-to level of inventory.&quot; If inventory level doesn't matter, you would follow something closer to Larry's proposed approach.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2019-06-27T16:43:54.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="807" PostTypeId="1" CreationDate="2019-06-27T18:36:29.460" Score="9" ViewCount="176" Body="&lt;p&gt;The assignment problem is well-studied and has a nice polynomial time algorithm. I'm interested in an extension of this problem where all edges are in a certain group and taking multiple edges from the same group can end up with diminishing returns due to dependence on a shared resource. This means the edges are no longer independent and therefore it cannot be directly modeled as an assignment problem.&lt;/p&gt;&#xA;&lt;p&gt;More formally, the problem is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Given:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;A weighted bipartite graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; with weight function &lt;span class=&quot;math-container&quot;&gt;$w:E\rightarrow \mathbb{Q}$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;a &amp;quot;type set&amp;quot;  &lt;span class=&quot;math-container&quot;&gt;$\mathcal{T}$&lt;/span&gt; which partitions &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; into groups that require the same resource. &lt;span class=&quot;math-container&quot;&gt;$T:E\rightarrow \mathcal{T}$&lt;/span&gt; shows which type is associated with an edge.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A resource function &lt;span class=&quot;math-container&quot;&gt;$R: \mathcal{T}\times \mathbb{N}\rightarrow \mathbb{Q}$&lt;/span&gt;, decreasing in the second argument&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Find a matching &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; and index &lt;span class=&quot;math-container&quot;&gt;$I:M\rightarrow \mathbb{N}$&lt;/span&gt; that maximizes &lt;span class=&quot;math-container&quot;&gt;$$\sum_{e\in M} \min\{w(e), R(T(e),I(e))\},$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; can use each value only once for each type (i.e. if &lt;span class=&quot;math-container&quot;&gt;$I(e)=I(e')$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e\neq e'$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$T(e)\neq T(e')$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Can this problem still be solved in polynomial time? If not, what would be a good alternative to model this, and why? Does this change if the number of types is a small constant (e.g. &lt;span class=&quot;math-container&quot;&gt;$&amp;lt;10$&lt;/span&gt;)?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Some observations:&lt;/p&gt;&#xA;&lt;p&gt;I think it is possible to model this as an MILP, but that could take long even when the number of types is small. Still, it is possible that is the best we can do.&lt;/p&gt;&#xA;&lt;p&gt;Also note that this is a special case of the 3-dimensional (weighted) matching problem, but that problem is very hard and modelling this in that way seems less promising than the MILP.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;This question is inspired by an answer I gave &lt;a href=&quot;https://cs.stackexchange.com/a/110689/&quot;&gt;here&lt;/a&gt;, which can be seen as an application of this problem.&lt;/p&gt;&#xA;" OwnerUserId="232" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-06-27T18:36:29.460" Title="Modelling resource dependency in the assignment problem" Tags="|computational-complexity|assignment-problem|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="808" PostTypeId="2" ParentId="452" CreationDate="2019-06-27T22:39:45.780" Score="4" Body="&lt;p&gt;Fabian, I believe many situations have this tension of strategic decisions that may turn out not to suit every operational situation; I think of locating charging stations for electric vehicles, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this generality, I can only come up with general answers. Of course, robust optimization comes to mind, but these days also data-driven approaches. Don't you have past data from which a distribution could be generated? &lt;a href=&quot;http://cerc-datascience.polymtl.ca/wp-content/uploads/2019/03/Technical-Report_DS4DM-2019-003.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; most recent article from the Montreal people may also be relevant as it employs machine learning to try to overcome the tactical/strategic information imbalance.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-06-27T22:39:45.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="809" PostTypeId="2" ParentId="641" CreationDate="2019-06-27T23:17:11.863" Score="8" Body="&lt;p&gt;As other answers have already noted, this problem is NP-hard. That, however, is not the end of the story. The longest path problem has some positive algorithmic results in the context of &lt;em&gt;parametrized algorithms&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main idea is that even though the problem may be NP-hard in general, we can consider a parameter of the input &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and try to develop algorithms that are efficient when &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is small. In particular, a problem is considered fixed parameter tractable (FPT) w.r.t. parameter &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; if there is an &lt;span class=&quot;math-container&quot;&gt;$O(f(k)\cdot \mathrm{poly}(n))$&lt;/span&gt; time algorithm that solve the problem, for some computable function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will discuss two of the techniques, which I mostly took from the textbook &lt;em&gt;Cygan, et al. Parameterized algorithms. Vol. 4. No. 8. Cham: Springer, 2015.&lt;/em&gt;. (I highly recommend this book for anyone interested in parametrized algorithms and analysis!)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Color coding&lt;sup&gt;1&lt;/sup&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For this technique, we will consider the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-path problem, where we ask if there is a simple path of length &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. This is the longest path problem in disguise: if we know the longest path is at most of length &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, we can do a binary search and only add a &lt;span class=&quot;math-container&quot;&gt;$\log x$&lt;/span&gt; factor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One reason why longest path is hard is because we want a &lt;em&gt;simple&lt;/em&gt; path. It is a bit easier to decide whether there is a walk of length &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. So we want to get an efficient way to look only at simple paths. I will quote the main trick directly from the book:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Color the vertices uniformly at random from &lt;span class=&quot;math-container&quot;&gt;$\{1,\ldots,k\}$&lt;/span&gt;, and find a path&#xA;  on &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; vertices, if it exists, whose all colors are pairwise distinct.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;We call a path with pairwise distinct colors &lt;em&gt;colorful&lt;/em&gt;. Note that a colorful path must be simple. What remains to be shown is whether it is likely for a simple path of length &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; to be colorful. It turns out that this happens with probability at least &lt;span class=&quot;math-container&quot;&gt;$e^{-k}$&lt;/span&gt;. In the end, we get an &lt;span class=&quot;math-container&quot;&gt;$(2e)^k\mathrm{poly}(n)$&lt;/span&gt; time algorithm with one-sided constant error probability, where the &lt;span class=&quot;math-container&quot;&gt;$2^k$&lt;/span&gt; factor is for checking whether there is a colorful &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-path. A more involved algorithm can lower the base of the exponent somewhat, to get an &lt;span class=&quot;math-container&quot;&gt;$4^{k+o(k)}\mathrm{poly}(n)$&lt;/span&gt;-time algorithm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are methods to derandomize this technique, but I will not discuss them here.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Treewidth&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Many graph problems are easy on trees, longest path included. The notion of treewidth is used to extend these techniques to more general graphs. We can group vertices of our graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; into 'bags' and then construct a graph &lt;span class=&quot;math-container&quot;&gt;$G'$&lt;/span&gt; with the bags as vertices and an edge between bags if some vertices in the bags are connected in the original graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$G'$&lt;/span&gt; is a tree, this is called a &lt;em&gt;tree decomposition&lt;/em&gt;&lt;sup&gt;2&lt;/sup&gt;. The &lt;em&gt;treewidth&lt;/em&gt; of a graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; is the minimum &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; such that there is a tree decomposition where every bag has size at most &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;sup&gt;3&lt;/sup&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, it is not immediately clear that treewidth is less than &lt;span class=&quot;math-container&quot;&gt;$O(n)$&lt;/span&gt; for an arbitrary graph. The treewidth of a graph can be found in time FPT wrt to the treewidth as a parameter. Additionally, cycles have treewidth &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t\times t$&lt;/span&gt; grids have treewidth &lt;span class=&quot;math-container&quot;&gt;$O(t)$&lt;/span&gt;, and more generally planar graphs have treewidth &lt;span class=&quot;math-container&quot;&gt;$O(\sqrt{n})$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get an algorithm that is FPT in the treewidth, the main trick is that dynamic programming is as easy on a tree decomposition of bounded size as on ordinary trees. With this technique, we get an &lt;span class=&quot;math-container&quot;&gt;$k^{O(k)}\cdot n$&lt;/span&gt; time algorithm. This is pretty bad if the treewidth of your graph is not small, but if it happens to be bounded by a constant, this is a linear time algorithm!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&#xA;1: This is the technique mentioned by @Nobody in the comments .&lt;br/&gt;&#xA;2,3: This is not completely correct, but it should give you an idea.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="232" LastActivityDate="2019-06-27T23:17:11.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="810" PostTypeId="2" ParentId="797" CreationDate="2019-06-27T23:57:21.357" Score="7" Body="&lt;p&gt;Substantively similar to the OP's answer, but with some Python tweaks. Mostly, I just put things in their own functions, tweaked some Gurobi API calls to be cleaner and more efficient, and provided an example of how to check solve output after you solve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Part I: Eliminated extra imports + added comment characters&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as grb&#xA;&#xA;# Parameters needed are:&#xA;# (1) the total number of jobs (n). Here I denote it by &quot;NumofJobs&quot;&#xA;# (2) the total number of machines (m). Here I denote it by &quot;NumofMachines&quot;&#xA;# (3) the processing times.  Here I use a numpy matrix: &quot;Tasktime[r, j]&quot; : p_{r,j}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Part II: Wrote a separate main function to separate the building from the solving.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def main(): # Always wrap things in functions!&#xA;    # Separated the building of the model from the solving of the model.&#xA;    NumofJobs = 10&#xA;    NumofMachines = 14&#xA;    Tasktime = ... # Whatever data you want&#xA;    model = buildModel(NumofJobs, NumofMachines, Tasktime)&#xA;&#xA;    model.optimize()&#xA;    # Check to see what happened!&#xA;    if (model.status != grb.GRB.OPTIMAL):&#xA;        print('Oh no, something went wrong!')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Part III: Build the actual model.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def buildModel(NumofJobs, NumofMachines, Tasktime)&#xA;    # Building the model:&#xA;    m = grb.Model(&quot;Wilson&quot;)&#xA;&#xA;    # Generating variables:&#xA;    z = m.addVars(NumofJobs, NumofJobs, vtype=grb.GRB.BINARY)&#xA;&#xA;    s = m.addVars(NumofMachines, NumofMachines) # Default is continuous&#xA;&#xA;    # Don't need to call m.update() these days.&#xA;&#xA;    # Generating constraints:&#xA;    for i in range(NumofJobs):&#xA;        m.addConstr(grb.quicksum(z[j, i] for j in range(NumofJobs)) == 1)&#xA;&#xA;    for j in range(NumofJobs):&#xA;        m.addConstr(grb.quicksum(z[j, i] for i in range(NumofJobs)) == 1)&#xA;&#xA;    m.addConstr(s[0, 0] == 0)&#xA;&#xA;    for i in range(NumofJobs - 1):&#xA;        m.addConstr(s[0, i] + grb.quicksum((Tasktime[0, j]) * z[j, i] &#xA;                        for j in range(NumofJobs)) == s[0, i + 1])&#xA;&#xA;    for r in range(NumofMachines - 1):&#xA;        m.addConstr(s[r, 0] + grb.quicksum((Tasktime[r, j]) * z[j, 0] &#xA;                        for j in range(NumofJobs)) == s[r + 1, 0])&#xA;&#xA;    for r in range(NumofMachines - 1):&#xA;        for i in range(1, NumofJobs):&#xA;            m.addConstr(s[r, i] + grb.quicksum(Tasktime[r, j] * z[j, i] &#xA;                            for j in range(NumofJobs)) &amp;lt;= s[r + 1, i])&#xA;&#xA;    for r in range(1, NumofMachines):&#xA;        for i in range(NumofJobs - 1):&#xA;            m.addConstr(s[r, i] + grb.quicksum(Tasktime[r, j] * z[j, i] &#xA;                        for j in range(NumofJobs)) &amp;lt;= s[r, i + 1])&#xA;&#xA;&#xA;    # Setting the objective function:&#xA;    m.setObjective(s[NumofMachines - 1, NumofJobs - 1] + &#xA;        grb.quicksum(Tasktime[NumofMachines - 1, j] * z[j, NumofJobs - 1] &#xA;            for j in range(NumofJobs)), sense=grb.GRB.MINIMIZE)&#xA;&#xA;    return m&#xA;&#xA;if __name__=='__main__': # Standard way to call Python main function&#xA;    main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course there are lots more things that could be done here, but this is a template of how I write prototypes. As &lt;a href=&quot;https://or.stackexchange.com/questions/61/why-is-the-programming-code-of-many-algorithms-not-public-in-the-or-community&quot;&gt;has been discussed&lt;/a&gt;, the OR community can always do better with our code!&lt;/p&gt;&#xA;" OwnerUserId="358" LastActivityDate="2019-06-27T23:57:21.357" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="811" PostTypeId="2" ParentId="801" CreationDate="2019-06-28T00:08:17.613" Score="13" Body="&lt;p&gt;For a function &lt;span class=&quot;math-container&quot;&gt;$f:[0,1]^n\to\mathbb{R}$&lt;/span&gt; of the form &lt;span class=&quot;math-container&quot;&gt;$f(x_1,\dots,x_n)=\sum_{ij\in E}a_{ij}x_ix_j$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is the edge set of a graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; on the vertex set &lt;span class=&quot;math-container&quot;&gt;$\{1,\dots,n\}$&lt;/span&gt;, the McCormick envelope gives the convex hull if and only if every cycle in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; has an even number of positive edges and an even number of odd edges (where an edge &lt;span class=&quot;math-container&quot;&gt;$ij$&lt;/span&gt; is called positive or negative depending on the sign of the coefficient &lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt;). In particular, &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; needs to be bipartite. This is a direct consequence of Theorem 3.10 in&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Misener, R., Smadbeck, J.B., Floudas, C.A.: Dynamically generated cutting planes for mixed-integer quadratically constrained quadratic programs and their incorporation into GloMIQO 2. Optim. Methods Softw. 30(1), 215--249 (2014)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative proof can be found in (Theorem 4)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;N. Boland, S. Dey, T. Kalinowski, M. Molinaro, F. Rigterink: &lt;em&gt;Bounding the gap between the McCormick relaxation and the convex hull for bilinear functions&lt;/em&gt;, Mathematical programming &lt;strong&gt;162&lt;/strong&gt; (2017), &lt;a href=&quot;https://arxiv.org/abs/1507.08703&quot; rel=&quot;noreferrer&quot;&gt;https://arxiv.org/abs/1507.08703&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="741" LastActivityDate="2019-06-28T00:08:17.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="812" PostTypeId="2" ParentId="758" CreationDate="2019-06-28T00:17:45.913" Score="9" Body="&lt;p&gt;The number of lazy constraints that have to be used, depends on the algorithm that is used. I will discuss two algorithms:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The &lt;em&gt;cutting-plane method&lt;/em&gt;: solve the problem to optimality for a subset of constraints. If any lazy constraints are violated, add some of the violated constraints and solve again. Stop when the solution satisfies all lazy constraints.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;em&gt;ellipsoid method&lt;/em&gt;: the optimal solution is contained in an ellipsoid. In each step of the algorithm, the volume of the ellipsoid is decreased until the optimum is found with sufficient precision. See &lt;a href=&quot;https://en.wikipedia.org/wiki/Ellipsoid_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt; for details.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In practice, the cutting-plane method is often effective for solving problems. However, I am not aware of a bound on the number of lazy constraints that have to be added. For specific problems, such a bound may exists, but I agree with Marco Lübbecke that you can likely construct examples where all lazy constraints are added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ellipsoid method is often not useful in practice due to its numerical instability, among other things. However, it is used in theory because of its good worst-case complexity. For example, linear programs can be solved in polynomial time with the ellipsoid method. Under technical assumptions, convex programs can also be solved in polynomial time. In papers, this fact is used to make arguments like:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;We model problem X as a convex program. As convex programs can be solved in polynomial time with the ellipsoid method, problem X can be solved in polynomial time. In our implementation, however, we will make use of the cutting-plane method.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Hence, if the technical conditions are satisfied, it follows that only a polynomial number of lazy constraints are used &lt;strong&gt;if the ellipsoid method is used&lt;/strong&gt;. It is probably not possible to translate this result to the cutting-plane method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a final remark: even if you only have to add a polynomial number of lazy constraints, the ellipsoid method may still take exponential time if &lt;em&gt;finding&lt;/em&gt; a violated lazy constraint takes exponential time.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2019-06-29T22:43:55.520" LastActivityDate="2019-06-29T22:43:55.520" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="813" PostTypeId="2" ParentId="291" CreationDate="2019-06-28T06:30:35.067" Score="9" Body="&lt;p&gt;Column Generation is one of the best method to solve the classical &lt;strong&gt;Graph Coloring Problem&lt;/strong&gt;, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Mehrotra, A. and Trick, M.A., 1996. &lt;a href=&quot;https://mat.tepper.cmu.edu/trick/color.pdf&quot; rel=&quot;noreferrer&quot;&gt;A column generation approach for graph coloring&lt;/a&gt;. INFORMS Journal on Computing, 8(4), pp.344-354.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Gualandi, S. and Malucelli, F., 2012. &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.1100.0436&quot; rel=&quot;noreferrer&quot;&gt;Exact solution of graph coloring problems via constraint programming and column generation&lt;/a&gt;. INFORMS Journal on Computing, 24(1), pp.81-100.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Another survey you can have a look is about &lt;strong&gt;Constraint Programming-based Column Generation&lt;/strong&gt;, where typically the pricing subproblem is solved using a Constraint Programming solver (with applications in Airline plannig, Travelling tournament problem, Employee timetabling, Wireless Mesh Networks, ...):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Gualandi, S. and Malucelli, F., 2013. &lt;a href=&quot;https://idp.springer.com/authorize/casa?redirect_uri=https://link.springer.com/article/10.1007/s10479-012-1299-7&quot; rel=&quot;noreferrer&quot;&gt;Constraint programming-based column generation&lt;/a&gt;. Annals of Operations Research, 204(1), pp.11-32.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="171" LastActivityDate="2019-06-28T06:30:35.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="814" PostTypeId="2" ParentId="291" CreationDate="2019-06-28T06:43:23.100" Score="13" Body="&lt;p&gt;Every four years (year mod 4 = 0) there is an international Column Generation conference,  alternated with a school on column generation, also every four years (year mod 4 = 2), (e.g. school in &lt;a href=&quot;https://www.gerad.ca/colloques/ColumnGeneration2018/&quot; rel=&quot;noreferrer&quot;&gt;2018&lt;/a&gt;, workshop in &lt;a href=&quot;https://www.gerad.ca/colloques/ColumnGeneration2016/&quot; rel=&quot;noreferrer&quot;&gt;2016&lt;/a&gt;, etc.),&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find plenty of applications there.&lt;/p&gt;&#xA;" OwnerUserId="743" LastEditorUserId="354" LastEditDate="2019-11-08T04:42:17.607" LastActivityDate="2019-11-08T04:42:17.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="815" PostTypeId="2" ParentId="452" CreationDate="2019-06-28T06:50:39.500" Score="5" Body="&lt;p&gt;I come across the problem quite a bit (am a practitioner in a utility company building offshore wind farms), and here is my take:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As Marco said, try to get as much data about the system as possible: past shipment values, domain experts giving their opinion (treat those with a pinch of salt though) etc. then incorporate this in the best way you see fit (fit a distribution, derive ML predictive model, robust optimization etc)&lt;/li&gt;&#xA;&lt;li&gt;However, if you don’t have anything available, I would &lt;em&gt;not assume anything&lt;/em&gt;. There are two reasons for this:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;1) You are introducing “magic numbers” into the problem without any justification. However, somebody who looks at your results may not know this and suddenly you end up suggesting that you have more information than you do. This makes debugging, new development and handovers more difficult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) On a more fundamental level, in my opinion it is the job of OR people to provide the best answer given our current knowledge of the system. We take what is there and make the most of it. It is the clients’ responsibility to provide the data to use. You can (and should) highlight what you think would make the model more accurate and hence more valuable. However it is their responsibility, and they have to live up to that.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-06-28T06:50:39.500" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="816" PostTypeId="2" ParentId="709" CreationDate="2019-06-28T08:00:46.590" Score="3" Body="&lt;p&gt;Metaheuristics for continuous global optimization is &lt;em&gt;the only&lt;/em&gt; way to obtain good solutions when your problem is even of moderately high dimension. There are several examples in the literature. Our research group (but many others too) have successfully applied metaheuristics to solve large scale molecular conformation problems, optimal disk packing problems, space trajectory planning, and many many others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The book I wrote with my colleague Marco Locatelli, Global Optimization: Theory, Algorithms and Applications, SIAM-MOS, 2013 / viii + 439 pages / Softcover / ISBN: 978-1-611972-66-5 &lt;a href=&quot;http://bookstore.siam.org/mo15/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://bookstore.siam.org/mo15/&lt;/a&gt; has plenty of pages devoted to different heuristics for continuous globopt as well as applications.&lt;/p&gt;&#xA;" OwnerUserId="745" LastActivityDate="2019-06-28T08:00:46.590" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="817" PostTypeId="2" ParentId="452" CreationDate="2019-06-28T09:33:03.143" Score="5" Body="&lt;p&gt;The following may or may not be useful for hub location problems, but is certainly applicable to many problems pertaining to the title &quot;Strategic planning based on average values&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a random variable for which only the mean, &lt;span class=&quot;math-container&quot;&gt;$\bar{X}$&lt;/span&gt; is known, sometimes qualitative analysis can be performed to determine the direction of the error between&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) the  solution obtained by using the mean of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; in lieu of its actual distribution&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) the correct solution&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, suppose we are interested in &lt;span class=&quot;math-container&quot;&gt;$E(f(X))$&lt;/span&gt;, the expected value (i.e., mean) of &lt;span class=&quot;math-container&quot;&gt;$f(X)$&lt;/span&gt;. If the function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is known to be convex, for instance &lt;span class=&quot;math-container&quot;&gt;$f(x) = x^2$&lt;/span&gt;, or concave, for instance, &lt;span class=&quot;math-container&quot;&gt;$f(x) = \sqrt{x}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$f(x) = \text{log}(x)$&lt;/span&gt;, then &lt;a href=&quot;https://en.wikipedia.org/wiki/Jensen%27s_inequality&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jensen's Inequality&lt;/a&gt; can be applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is convex, Jensen's inequality tells us that &lt;span class=&quot;math-container&quot;&gt;$f\bar{X}) \le E(f(X))$&lt;/span&gt; I.e., substitution of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; by its mean causes &lt;span class=&quot;math-container&quot;&gt;$E(f(X))$&lt;/span&gt; to be underestimated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is concave, Jensen's inequality tells us that &lt;span class=&quot;math-container&quot;&gt;$f\bar{X}) \ge E(f(X))$&lt;/span&gt; I.e., substitution of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; by its mean causes &lt;span class=&quot;math-container&quot;&gt;$E(f(X))$&lt;/span&gt; to be overestimated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because it supports such qualitative analysis, Jensen's Inequality is one of the most powerful tools in applied probability, and therefore in Operations Research. Sometimes this qualitative analysis of the error goes in the direction needed to support decisions, even with missing quantitative information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: In the real world, many managers, decision makers, etc, think that the only rigorous analysis is quantitative. In many cases, qualitative analysis is more rigorous and better supports decisions than inadequate quantitative analysis. So sometimes a &quot;sales job&quot; is needed.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-06-28T17:31:37.157" LastActivityDate="2019-06-28T17:31:37.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="818" PostTypeId="5" CreationDate="2019-06-28T11:08:05.010" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Wright_Omega_function&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wright omega function&lt;/a&gt;  is defined as &lt;span class=&quot;math-container&quot;&gt;$\omega(z)=W_{\left\lceil\frac{\operatorname{Im}(z)-\pi}{2\pi}\right\rceil}(e^z)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Lambert_W_function&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lambert &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; function&lt;/a&gt; and &lt;span class=&quot;math-container&quot;&gt;$z\in\Bbb C$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="123" LastEditDate="2020-02-09T20:16:06.373" LastActivityDate="2020-02-09T20:16:06.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="819" PostTypeId="4" CreationDate="2019-06-28T11:08:05.010" Score="0" Body="For questions on the Wright omega function, a selected branch the Lambert W function." OwnerUserId="87" LastEditorUserId="123" LastEditDate="2020-02-09T20:16:06.373" LastActivityDate="2020-02-09T20:16:06.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="820" PostTypeId="5" CreationDate="2019-06-28T11:10:54.947" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-06-28T11:10:54.947" LastActivityDate="2019-06-28T11:10:54.947" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="821" PostTypeId="4" CreationDate="2019-06-28T11:10:54.947" Score="0" Body="For questions on the Lambert W function, the (multi-valued) inverse of $f(z)=ze^z$ for complex $z$." OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-06-28T18:37:39.217" LastActivityDate="2019-06-28T18:37:39.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="823" PostTypeId="2" ParentId="375" CreationDate="2019-06-28T19:33:05.467" Score="6" Body="&lt;p&gt;I really like this excerpt from Philip Morse's biography: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/opre.34.1.10&quot; rel=&quot;noreferrer&quot;&gt;https://pubsonline.informs.org/doi/abs/10.1287/opre.34.1.10&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;He doesn't go deep into methods, but he does discuss OR in WWII, including submarine-related problems.&lt;/p&gt;&#xA;" OwnerUserId="754" LastActivityDate="2019-06-28T19:33:05.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="824" PostTypeId="2" ParentId="638" CreationDate="2019-06-28T21:45:50.027" Score="5" Body="&lt;p&gt;There is a program that generates those graphs for the small number of vertices.&#xA;&lt;a href=&quot;http://users.cecs.anu.edu.au/%7Ebdm/data/graphs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://users.cecs.anu.edu.au/~bdm/data/graphs.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The following code converts the file with the g6 format to an array (it is written in python).&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import numpy as np&#xA;&#xA;file_contents = open(&amp;quot;graph3c.txt&amp;quot;, &amp;quot;r&amp;quot;)&#xA;&#xA;lines = file_contents.readlines()&#xA;&#xA;for line in lines:&#xA;&#xA;    n = ord(line.split()[0][0]) - 63&#xA;    h = ''&#xA;&#xA;    l = n - 1&#xA;    for i in range(1,l):&#xA;        temp = bin(ord(line.split()[0][i])-63)[2:]&#xA;        if len(temp) &amp;lt; 6:&#xA;            for k in range(6 - len(temp)):&#xA;                h = h + '0'&#xA;        h = h + temp&#xA;    &#xA;     &#xA;    A = [[0]*n for j in range(n)]&#xA;    k = 0;&#xA;    for i in range(1,n):&#xA;        for j in range(0,i):&#xA;            A[i][j] = int(h[k])&#xA;            A[j][i] = A[i][j]&#xA;            k = k+1&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="622" LastEditorUserId="491" LastEditDate="2022-08-17T17:42:18.760" LastActivityDate="2022-08-17T17:42:18.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="825" PostTypeId="2" ParentId="732" CreationDate="2019-06-29T08:14:50.667" Score="40" Body="&lt;p&gt;@Rob wrote a great and extensive answer, but I would like to add two systems.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.minizinc.org&quot; rel=&quot;noreferrer&quot;&gt;MiniZinc&lt;/a&gt; is a high level CP system that is great for learning CP, prototyping problems as well as testing different solvers. MiniZinc first flatten a MiniZinc (.mzn) model to FlagZinc format (.fzn) and there are quite a few CP solvers that supports the FlatZinc format, e.g. Gecode, Chuffed, OR-tools, SICStus Prolog, JaCoP, Picat (CP/SAT), etc (they are listed in the MiniZinc main page). There is also an MiniZinc IDE where some of these solvers are included.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of the high level syntax of MiniZinc is the &lt;code&gt;element&lt;/code&gt; constraint &lt;code&gt;x[y] = z&lt;/code&gt; where &lt;code&gt;x&lt;/code&gt; in an array of decision variables, &lt;code&gt;y&lt;/code&gt; and &lt;code&gt;z&lt;/code&gt; are decision variables. The constraint constrain &lt;code&gt;z&lt;/code&gt; to be the &lt;code&gt;y&lt;/code&gt;th value in &lt;code&gt;x&lt;/code&gt;. Most other CP languages write this constraint as something like &lt;code&gt;element(x,y,z)&lt;/code&gt;. Thus this syntax in MiniZinc makes it a little easier to write and understand the constraint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MiniZinc support quite a few &lt;a href=&quot;https://www.minizinc.org/doc-2.3.0/en/lib-globals.html&quot; rel=&quot;noreferrer&quot;&gt;global constraints&lt;/a&gt;, though if a FlatZinc solver supports a specific global constraint, it will use its own instead. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also an yearly &lt;a href=&quot;https://www.minizinc.org/challenge.html&quot; rel=&quot;noreferrer&quot;&gt;MiniZinc Challenge&lt;/a&gt; where FlatZinc solvers are solving a number of different MiniZinc models. Last year, OR-Tools dominated the challenge completely. Most MiniZinc models and instances of former challenges are collected at &lt;a href=&quot;https://github.com/MiniZinc/minizinc-benchmarks&quot; rel=&quot;noreferrer&quot;&gt;GitHub&lt;/a&gt;,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One drawback of MiniZinc is that it is not a - Turing compatible - programming language, but it is quite easy to spawn a MiniZinc process to solve a problem, and some systems have this integrated (e.g. SICStus Prolog, ECLiPse CLP). And if you are into C++ it is not that complicated to integrate it even more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here's my &lt;a href=&quot;http://www.hakank.org/minizinc/&quot; rel=&quot;noreferrer&quot;&gt;MiniZinc page&lt;/a&gt; with a couple of examples, small and large.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To summarize, MiniZinc is great for learning the concept of Constraint Programming and for prototyping. If one need to use another programming language, it's often quite easy to port the MiniZinc model to another CP system.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://picat-lang.org/&quot; rel=&quot;noreferrer&quot;&gt;Picat&lt;/a&gt;&#xA;Well, I have to add it to the list since I am in the Picat team and I really like Picat as a CP system. :-) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Picat is a logic-based multi-paradigm programming language inspired by Prolog. The creator of Picat - Neng-Fa Zhou - is also the creator of B-Prolog (which is used in Picat's engine). This Prolog inspiration is seen for example with the support of non-determinism, but Picat also supports for loops, while loops, re-assignments, indexing of lists/arrays etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Picat supports a couple of constraint solving modules: MIP (GLPK and Gurobi), SAT, and SMT (z3 and cvc4); all these solvers has support for the same syntax/constraints (with exception of MIP solver which only supports linear constraints). The PicatSAT FlatZinc solver has done quite well the last &lt;a href=&quot;https://www.minizinc.org/challenge.html&quot; rel=&quot;noreferrer&quot;&gt;MiniZinc Challenges&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One feature of Picat that I - mostly - like is that the order of the constraints are important when using the CP module. In most CP systems the order of the constraints does not matter, but in Picat (for the CP module) the order might make a difference and this is one other way to make a model more efficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Picat also has a &lt;code&gt;planner&lt;/code&gt; module for traditional planning problems, but this is a bit out of scope of the question.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We wrote a book &lt;a href=&quot;http://picat-lang.org/picatbook2015.html&quot; rel=&quot;noreferrer&quot;&gt;Constraint Solving and Planning with Picat&lt;/a&gt; about how to use Picat for Constraint Programming problems (as well as planning problems). The freely available &lt;a href=&quot;http://picat-lang.org/picatbook2015/constraint_solving_and_planning_with_picat.pdf&quot; rel=&quot;noreferrer&quot;&gt;PDF&lt;/a&gt;. I hope that the two chapters about CP might be useful as an introduction to CP in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;a href=&quot;http://hakank.org/picat/&quot; rel=&quot;noreferrer&quot;&gt;My Picat page&lt;/a&gt; has quite a few examples of Picat models.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For harder CP problems, it's no uncommon have one have to tweak the model to make it fast enough. Most CP systems has a different ways of doing that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;selecting the order of variables to test (variable selection)&lt;/li&gt;&#xA;&lt;li&gt;when testing a specific variable, selecting the order of the values to test (value selecting).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, selecting these is - as of now - and art and one have to test different variants.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, there are some &quot;tricks&quot; that often speed things up, apart from finding the best variable/value strategies, e.g. symmetry breaking and adding redundant constraints to prune the search tree.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A side note: @Rob mentioned that I don't blog anymore which is correct. Instead I write - occasionally - at &#xA;  - &lt;a href=&quot;https://www.facebook.com/hakankj&quot; rel=&quot;noreferrer&quot;&gt;Facebook&lt;/a&gt;&#xA;  - &lt;a href=&quot;https://twitter.com/hakankj&quot; rel=&quot;noreferrer&quot;&gt;Twitter&lt;/a&gt; &#xA;  - &lt;a href=&quot;https://stackoverflow.com/users/195636/hakank&quot;&gt;StackOverflow&lt;/a&gt;, mostly answering questions about MiniZinc and Constraint Programming&#xA;  - And publish stuff on &lt;a href=&quot;https://github.com/hakank/hakank&quot; rel=&quot;noreferrer&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="260" LastActivityDate="2019-06-29T08:14:50.667" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="827" PostTypeId="2" ParentId="797" CreationDate="2019-06-29T14:28:51.013" Score="6" Body="&lt;p&gt;To complete the answer, I will add some other things that may be useful. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;To change the parameters of the solver gurobi, e.g. setting the time-limit to 600 seconds:&#xA;&lt;code&gt;m.setParam('TimeLimit', 600)&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To retrieve the objective function of the problem:&#xA;&lt;code&gt;Objective_Of_The_Problem = m.objVal&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To retrieve the status of the problem:&#xA;&lt;code&gt;Status_Of_The_Problem = m.status&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To retrieve the run-time of the solver:&#xA;&lt;code&gt;Time_To_Solve = m.Runtime&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To retrieve the value of a variable &lt;span class=&quot;math-container&quot;&gt;$z[j, i]$&lt;/span&gt;:&#xA;&lt;code&gt;Wilson_Variable = z[j, i].x&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note that we defined &lt;code&gt;m = Model (&quot;Wilson&quot;)&lt;/code&gt; previously.&lt;/p&gt;&#xA;" OwnerUserId="660" LastActivityDate="2019-06-29T14:28:51.013" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="828" PostTypeId="1" CreationDate="2019-06-29T19:02:59.207" Score="18" ViewCount="2517" Body="&lt;p&gt;QUBO (Quadratic Unconstrained Binary Optimization) is the minimization of a quadratic function of binary variables.&lt;/p&gt;&#xA;&lt;p&gt;It has been used for &lt;a href=&quot;https://www.cv-foundation.org/openaccess/content_cvpr_2014/html/Ishikawa_Higher-Order_Clique_Reduction_2014_CVPR_paper.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;computer vision&lt;/a&gt;, &lt;a href=&quot;https://arxiv.org/abs/1103.1345&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ramsey numbers&lt;/a&gt;,  &lt;a href=&quot;https://arxiv.org/abs/1411.6758&quot; rel=&quot;nofollow noreferrer&quot;&gt;factoring numbers&lt;/a&gt;, the &lt;a href=&quot;https://arxiv.org/abs/1811.11538&quot; rel=&quot;nofollow noreferrer&quot;&gt;integer partitioning problem&lt;/a&gt;, the &lt;a href=&quot;https://arxiv.org/abs/1811.11538&quot; rel=&quot;nofollow noreferrer&quot;&gt;MaxCut&lt;/a&gt; problem, and many other problems.&lt;/p&gt;&#xA;&lt;p&gt;But in the real-world, one would not factor numbers this way, no new Ramsey number has been found by solving a QUBO problem, and it's not the most efficient way to solve the integer partitioning problem.&lt;/p&gt;&#xA;&lt;p&gt;Are there any real-world problems, for which QUBO is the state-of-the-art way to solve the problem?&lt;/p&gt;&#xA;" OwnerUserId="727" LastEditorUserId="500" LastEditDate="2020-10-21T00:06:31.817" LastActivityDate="2020-10-21T00:06:31.817" Title="What are some real-world applications of QUBO?" Tags="|optimization|combinatorial-optimization|binary-variable|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="829" PostTypeId="1" CreationDate="2019-06-29T22:48:54.747" Score="18" ViewCount="325" Body="&lt;p&gt;I am working at a hostel which uses a reservation system for each room and the beds in the room (e.g. &lt;span class=&quot;math-container&quot;&gt;$14$&lt;/span&gt; beds in one room, bed numbers &lt;span class=&quot;math-container&quot;&gt;$1-14$&lt;/span&gt;.) When we get bookings for multiple people, we assign beds as available, which can cause problems in the future.&#xA;An example of our system is seen here (click to enlarge images):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jbQ24.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jbQ24m.jpg&quot; alt=&quot;image 1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, the groups 'Finan' and 'George' (&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;st of July) are nicely coordinated such that they are sequential. However, looking at the same image, the group 'Alice' is split between beds, and so is 'Aidan'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a bit of 'tetris', it's possible to move around all the reservations such that they are all together, however this takes time and most definitely can be automated. This can be seen much more easily in this photo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uWGXU.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uWGXUm.jpg&quot; alt=&quot;image 2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be an optimal way to automate the process of repositioning these reservations such that they are all combined sequentially?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another issue, which may, therefore, contradict the previous issue, is when reservations must be reorganized due to a required change of bed for a multi-day stay. For example, if a guest were to book for 2 nights in this situation &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yw2c9.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yw2c9m.jpg&quot; alt=&quot;image 3&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;would be forced to change beds after their first night; perhaps (distinctive of the first issue) it is possible to algorithmically find a 'solution' such that the guest wouldn't have to change beds, and all groups are kept together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any support for this would be much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="760" LastEditorUserId="47" LastEditDate="2019-06-30T18:12:11.733" LastActivityDate="2019-07-08T21:34:47.847" Title="Mathematically creating the 'perfect' permutation for reservations in a hostel" Tags="|linear-programming|modeling|constraint-programming|algorithms|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="830" PostTypeId="1" CreationDate="2019-06-30T01:59:21.907" Score="10" ViewCount="4998" Body="&lt;ol&gt;&#xA;&lt;li&gt;When can we approximate a finite horizon MDP with infinite horizon? &lt;/li&gt;&#xA;&lt;li&gt;Can we use infinite horizon stochastic shortest path problem on a directed acyclic graph?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="761" LastActivityDate="2019-08-28T14:54:05.320" Title="Infinite horizon versus finite horizon MDP" Tags="|optimization|stochastic-programming|markov-decision-process|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="831" PostTypeId="1" CreationDate="2019-06-30T08:31:43.617" Score="14" ViewCount="244" Body="&lt;p&gt;I am studying about sequential decision making and I am willing to know if there is any course which is recorded and is publically available covering topics in dynamic programming (DP), reinforcement learning (RL), bandit problem, approximate DP\RL, online optimization?&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="491" LastEditDate="2021-12-16T20:15:11.827" LastActivityDate="2021-12-16T20:15:11.827" Title="Suggestion of some courses in sequential decision making" Tags="|reference-request|online-resources|reinforcement-learning|dynamic-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="832" PostTypeId="2" ParentId="831" CreationDate="2019-06-30T10:06:39.177" Score="11" Body="&lt;p&gt;There are a few courses on Coursera that offer such learning materials.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.coursera.org/learn/algorithms-greedy&quot; rel=&quot;noreferrer&quot;&gt;Greedy Algorithms, Minimum Spanning Trees, and Dynamic Programming&lt;/a&gt; (Intermediate)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The primary topics in this part of the specialization are: greedy algorithms (scheduling, minimum spanning trees, clustering, Huffman codes) and dynamic programming (knapsack, sequence alignment, optimal search trees).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If you want to go directly to dynamic programming then you can skip to weeks 3 and 4 of the syllabus.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.coursera.org/learn/practical-rl&quot; rel=&quot;noreferrer&quot;&gt;Practical Reinforcement Learning&lt;/a&gt; (Advanced)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Here you will find out about:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;foundations of RL methods: value/policy iteration, q-learning, policy gradient, etc. - with math &amp;amp; batteries included&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;using deep neural networks for RL tasks - also known as &amp;quot;the hype train&amp;quot;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;state of the art RL algorithms - and how to apply duct tape to them for practical problems.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and, of course, teaching your neural network to play games - because that's what everyone thinks RL is about. We'll also use it for seq2seq and contextual bandits.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="123" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-06-30T10:06:39.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="833" PostTypeId="1" AcceptedAnswerId="837" CreationDate="2019-06-30T10:58:05.090" Score="11" ViewCount="498" Body="&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; items, I want to select a set items &lt;span class=&quot;math-container&quot;&gt;$S\subseteq\{1,2,\dots,n\}$&lt;/span&gt; that maximize profit. The profit of item &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,2,\dots,n\}$&lt;/span&gt; is given by &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; and may be assumed to be non-negative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, I have a set &lt;span class=&quot;math-container&quot;&gt;$\mathscr{F}$&lt;/span&gt; of forbidden subsets. That is, if &lt;span class=&quot;math-container&quot;&gt;$F \in \mathscr{F}$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is not allowed to contain &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; as a subset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: if &lt;span class=&quot;math-container&quot;&gt;$n=3$&lt;/span&gt;, profits are given by &lt;span class=&quot;math-container&quot;&gt;$p_1=p_2=p_3=1$&lt;/span&gt;, and the forbidden subsets are given by &lt;span class=&quot;math-container&quot;&gt;$\mathscr{F} = \{\{1,2\},\{2,3\}\}$&lt;/span&gt;, then the optimum is given by &lt;span class=&quot;math-container&quot;&gt;$S=\{1,3\}$&lt;/span&gt; with profit &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question is how to best approach this problem.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I am using a knapsack problem type formulation that I solve with CPLEX. This works relatively well, but I am interested if better approaches exist, especially because I do not have any side constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max \sum_{i=1}^n p_i x_i,$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i \in F} x_i \le \lvert F \rvert - 1, \forall F \in \mathscr{F},$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x \in \{0,1\}^n.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-06-30T19:31:25.220" Title="Finding an optimal set without forbidden subsets" Tags="|integer-programming|combinatorial-optimization|algorithms|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="834" PostTypeId="1" AcceptedAnswerId="840" CreationDate="2019-06-30T12:10:58.330" Score="31" ViewCount="2611" Body="&lt;p&gt;Often there are many alternatives ways for formulating a MIP. For example:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The model contains inequality constraints that must hold with equality in an optimal solution. &lt;/li&gt;&#xA;&lt;li&gt;The model contains continuous variables that will necessarily be integer in an optimal (or just integer feasible) solution.&lt;/li&gt;&#xA;&lt;li&gt;The model contains variables that have a value of at most 1 in an optimal solution. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In these cases, the modeler can decide whether to (1) include the constraints as equality constraints or not, (2) declare the variables as integer or continuous variables and (3) to declare the variables with upper bounds of 1 or not. When using commercial solvers, I have noticed that the performance may vary significantly dependent on such choices. Hence, I am wondering whether there are any rules of thumb for formulating MIPs in solvers. More generally, what information is valuable to solvers and what information may even hurt performance?&lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2019-07-01T17:49:48.570" Title="&quot;Best practices&quot; for formulating MIPs" Tags="|mixed-integer-programming|linear-programming|solver|cplex|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="835" PostTypeId="2" ParentId="834" CreationDate="2019-06-30T12:29:19.437" Score="10" Body="&lt;p&gt;Perhaps you are only talking about MILPs, but you don't say, so I will say something of interest for MINLPs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding point 1:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Suppose your model has a convex nonlinear inequality constraint, &lt;span class=&quot;math-container&quot;&gt;$f(x) \le c$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is convex.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It is known that the constraint will be active at the optimum, of any continuous relaxation i.e., &lt;span class=&quot;math-container&quot;&gt;$f(x) = c$&lt;/span&gt;, for instance because the continuous relaxations are concave programs with compact constraints, thereby  having global optimum at an extreme of the constraints&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then you are usually better off entering the constraint as an inequality rather than as an equality. That is because the inequality constraint is convex, and generally much easier for an optimizer to deal with than a nonlinear equality constraint, which is a non-convex constraint. You might think you'd be doing the optimizer a favor by specifying the equality constraint, thereby cleaving off &lt;span class=&quot;math-container&quot;&gt;$f(x) &amp;lt; c$&lt;/span&gt; from consideration, but such a &quot;favor&quot; will usually backfire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in the case of a linear equality constraint known to hold with equality at the optimum of the original problem, or a continuous relaxation, I think it would generally be better, and in any event, not worse (except for (un)lucky &quot;stars aligning&quot; cases), to specify such a linear constraint as an equality constraint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding point 3, I have a pretty hard time imagining it would be better to not provide an upper bound of 1 than to provide it when you know the optimal variable value is at most 1. But I suppose for some particular model and solver, the stars could always align such that specifying such an upper bound slowed things down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will leave others to comment on point 2.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-06-30T12:52:33.053" LastActivityDate="2019-06-30T12:52:33.053" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="836" PostTypeId="2" ParentId="834" CreationDate="2019-06-30T13:45:43.770" Score="18" Body="&lt;p&gt;I’m assuming that we want our models to be solved as quickly as possible. If that is the case, then the honest answer is: you need to try the models out and see.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give you a concrete example (see &lt;a href=&quot;https://github.com/RichardOberdieck/optimization-blog/blob/master/Is%20a%20better%20model%20really%20always%20better.ipynb&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;): through what I thought was a super-clever reformulation, I was able to remove 85% of the variables in the problem, and I thought that this would make it super fast. However the performance was orders(!!) of magnitude worse than before, because the original problem was symmetric, and the new one was not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I always try to put the tightest upper bound I have, make my big-M as small as possible, use continuous over binary/integer when I can, but honestly, you cannot know anything for sure until you test it.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-06-30T13:45:43.770" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="837" PostTypeId="2" ParentId="833" CreationDate="2019-06-30T17:37:23.327" Score="9" Body="&lt;p&gt;Your problem is equivalent to finding a maximum weighted independent set in a hypergraph, where each item is a vertex and every forbidden set is an hyperedge over the elements in the set. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a hard problem, not just NP-hard (since it is a generalisation of the NP-hard weighted independent set problem), but also NP-hard to approximate within a constant factor (Because independent set is also NP-hard to approximate&lt;sup&gt;1&lt;/sup&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What this means is that unless your specific instances have some structure that can be exploited, heuristic solutions or MILP, SAT, etc. solvers are going to be the best you can do for this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is some literature on the (non-weighted) independent set problem in hypergraphs. Most of the results I see are about &lt;em&gt;regular&lt;/em&gt; or &lt;em&gt;uniform&lt;/em&gt; hypergraphs, where all hyperedges have the same size. So, in case your forbidden subsets have different cardinality, then there doesn't really seem to be much research about your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All in all, I think this provides some evidence that there is not much better you can do than you already did. I'm happy to be proven wrong, of course, in which case the literature on hypergraphs may help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1: It is known to be NP-hard to get a better approximation ratio than &lt;span class=&quot;math-container&quot;&gt;$n/2^{(\log n)^{3/4+\gamma}}$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$\gamma&amp;gt;0$&lt;/span&gt;, see Khot, S., &amp;amp; Ponnuswami, A. K. (2006, July). &lt;em&gt;Better inapproximability results for maxclique, chromatic number and min-3lin-deletion&lt;/em&gt;. In International Colloquium on Automata, Languages, and Programming (pp. 226-237). Springer, Berlin, Heidelberg.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="232" LastActivityDate="2019-06-30T17:37:23.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="838" PostTypeId="2" ParentId="833" CreationDate="2019-06-30T19:31:25.220" Score="7" Body="&lt;p&gt;Since this problem has exponentially many constraints, I suspect that most forbidden subset constraints (FSCs) will not be binding at optimality. Therefore, something which you could try is: (a) pick a promising set of FSCs to add apriori and (b) add the remaining forbidden constraints via lazy callbacks, where you add the &quot;most violated&quot; constraint at each iteration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you know that some of the FSCs imply other FSCs then you should also ignore the redundant constraints. In practise, this means that you should favour adding hidden subsets of small cardinality first.&lt;/p&gt;&#xA;" OwnerUserId="43" LastActivityDate="2019-06-30T19:31:25.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="839" PostTypeId="2" ParentId="506" CreationDate="2019-07-01T03:53:29.897" Score="22" Body="&lt;p&gt;One nice similar result I have seen in the Open shop scheduling problem, where &lt;strong&gt;Three is easy, two is hard&lt;/strong&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the paper Gribkovskaia et al. (2006), they write:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;In discrete optimization the complexity of a problem often increases dramatically when a numerical parameter changes its value from 2 to 3. Fascinated with this issue, Eugene Lawler wrote: “Sad to say, but it will be many more years, if ever, before we really understand the Mystical Power of Twoness (or what Jan Karel [J.K. Lenstra] calls the Magical Power of Threeness): 2-SAT is easy, 3-SAT is hard, 2-dimensional matching is easy, 3-dimensional matching is hard.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, they proved a rarely found opposite behavior. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It was proved by Glass et al. (2001) that for the two-machine open shop sum-batch problem to minimize the makespan, an optimal schedule is known to contain one, two or three batches on each machine. Also they proved that &lt;strong&gt;finding a two-batch optimal schedule is NP-hard&lt;/strong&gt;. Hence it was conjectured that it is NP-hard for three-batch schedules as well. Surprisingly, Gribkovskaia et al. (2006) showed that &lt;strong&gt;three-batch optimal schedules can be found in linear time&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Refs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Glass, Celia A., Chris N. Potts, and Vitaly A. Strusevich. &quot;Scheduling batches with sequential job processing for two-machine flow and open shops.&quot; INFORMS Journal on Computing 13.2 (2001): 120-137.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gribkovskaia, Irina V., et al. &quot;Three is easy, two is hard: open shop sum-batch scheduling problem refined.&quot; Operations Research Letters 34.4 (2006): 459-464.&lt;/p&gt;&#xA;" OwnerUserId="660" LastActivityDate="2019-07-01T03:53:29.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="840" PostTypeId="2" ParentId="834" CreationDate="2019-07-01T07:30:52.000" Score="20" Body="&lt;p&gt;This is an extremely interesting question. I agree with @Richard that you have to try it out. I have seen that tiny changes to a model can make huge differences, but in my experience, more general changes to a model may have more impact in the end. There are, I think, some guidelines that may help, from algorithmics and theory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do we choose &quot;big &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; as small as possible&quot; (so, in fact, we look for small &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;)? Because we know that the LP based B&amp;amp;B algorithm which solves our MILPs can benefit from a better bound. Then again, since we know that big &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; usually gives horrible relaxations, we try to avoid it altogether. A reformulation may help, maybe at the expense of investing more variables. Maybe too many, in that case, you would need a different algorithm (like dynamic variable or constraint generation). In my view, the model and the algorithm (may) go hand in hand. General observations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use binary variables instead of general integers &lt;/li&gt;&#xA;&lt;li&gt;avoid symmetric formulations&lt;/li&gt;&#xA;&lt;li&gt;think of completely different representations of a solution (eg in the cutting stock problem, variables can represent (a) how often an item is cut from a particular roll, or (b) an entire cutting pattern given as non-negative integer numbers, or (c) an entire cutting pattern given as a path in an acyclic network, or or or. &lt;/li&gt;&#xA;&lt;li&gt;look at the LP solution in the root node: anything you &quot;see&quot; that the LP is allowed to do that would be forbidden for the IP? May give an extra constraint. Or a cutting plane.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It may happen that the vanialla solver on an ugly model is still faster than a specialized solver on the elaborate model, and this is frustrating at first, but then we realize that this is what drives solver development.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="354" LastEditDate="2019-07-01T08:33:17.993" LastActivityDate="2019-07-01T08:33:17.993" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="841" PostTypeId="1" AcceptedAnswerId="845" CreationDate="2019-07-01T08:11:18.133" Score="25" ViewCount="3927" Body="&lt;p&gt;For the TSP there famously is the concord solver (&lt;a href=&quot;http://www.math.uwaterloo.ca/tsp/concorde.html&quot; rel=&quot;noreferrer&quot;&gt;http://www.math.uwaterloo.ca/tsp/concorde.html&lt;/a&gt;) which is argubly the fastest exact solver for the TSP. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many other problems that also show up again and again, for example the capacitated vehicle routing problem (CVRP). CVRP can be solved very efficiently using branch and price, and there are many papers, on the fastest current methodes and how they can incorporate different constraints (e.g. time windows). However, i was unable to find any available implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I wonder, are there some good implementations of the state of the art for other problems than the TSP? Is there a list of such implementations and if not, can we create one?&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2019-07-03T09:14:45.217" LastActivityDate="2023-01-22T10:03:07.177" Title="List of Implementations for common OR problems" Tags="|algorithms|online-resources|software|vehicle-routing|implementation|" AnswerCount="7" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="842" PostTypeId="1" CreationDate="2019-07-01T08:20:27.533" Score="10" ViewCount="420" Body="&lt;p&gt;There is a directed social network with large number of nodes and arcs and there are many instances of the network (nodes are same but arcs change in each instance). You can think of it as a stochastic network with probabilities on the arcs, so that in each scenario you end up a different instance of the network (in terms of arcs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For each node in the network and for each instance we run BFS to determine the successor set. As you may realize we need to run the BFS (V.R) times where V is the number of nodes and R is the number of instances. However for a given instance, there may be a much efficient way of doing the BFS. For instance during the steps of BFS if we meet a node whose successor set is already calculated, we directly add that whole set and do not continue further in that direction. This improves the performance when we consider all the nodes, however it still takes too much time for large networks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the challenge is: Is there an efficient all-nodes BFS algorithm that computes the BFS sets of all nodes, that is faster than the above method? (Similar to the comparison of Dijkstra and Floyd-Warshall for shortest paths)&lt;/p&gt;&#xA;" OwnerUserId="632" LastEditorUserId="87" LastEditDate="2019-07-01T11:26:56.307" LastActivityDate="2019-07-01T13:04:46.620" Title="Many-to-many Breadth First Search" Tags="|graphs|algorithms|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="843" PostTypeId="2" ParentId="841" CreationDate="2019-07-01T08:50:23.230" Score="17" Body="&lt;p&gt;A good place to start is &lt;a href=&quot;https://www.coin-or.org/&quot; rel=&quot;noreferrer&quot;&gt;COIN-OR&lt;/a&gt;, which aims to &quot;create for mathematical software what the open literature is for mathematical theory&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also take a look at Google's &lt;a href=&quot;https://developers.google.com/optimization/&quot; rel=&quot;noreferrer&quot;&gt;OR-Tools&lt;/a&gt;. It contains many algorithms for specific problems (like knapsack or max flow) and also generic LP and CP solvers.&lt;/p&gt;&#xA;" OwnerUserId="132" LastActivityDate="2019-07-01T08:50:23.230" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="844" PostTypeId="2" ParentId="842" CreationDate="2019-07-01T10:40:46.290" Score="5" Body="&lt;p&gt;I am not sure. But this is an obvious case where parallelization will help (per source node, and instance).&lt;/p&gt;&#xA;" OwnerUserId="587" LastActivityDate="2019-07-01T10:40:46.290" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="845" PostTypeId="2" ParentId="841" CreationDate="2019-07-01T11:00:46.363" Score="27" Body="&lt;p&gt;Let's make an inventory of example code for each common OR problem?&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Vehicle Routing Problem&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OptaPlanner: &lt;a href=&quot;https://www.optaplanner.org/learn/useCases/vehicleRoutingProblem.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;explanation + videos&lt;/a&gt; - &lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/src/main/java/org/optaplanner/examples/vehiclerouting&quot; rel=&quot;nofollow noreferrer&quot;&gt;source code&lt;/a&gt; (capacitated, time windows, multiple depots, ...)&lt;/li&gt;&#xA;&lt;li&gt;LocalSolver: &lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/vrp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;explanation + source code&lt;/a&gt; (same with &lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/vrptw.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;time windows&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;OR-tools: &lt;a href=&quot;https://developers.google.com/optimization/routing/cvrp&quot; rel=&quot;nofollow noreferrer&quot;&gt;explanation + source code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Jsprit: &lt;a href=&quot;https://github.com/graphhopper/jsprit&quot; rel=&quot;nofollow noreferrer&quot;&gt;source code&lt;/a&gt; - &lt;a href=&quot;https://www.graphhopper.com/open-source/&quot; rel=&quot;nofollow noreferrer&quot;&gt;company website&lt;/a&gt; (capacitated, time windows, multiple depots, ...) (Related: &lt;a href=&quot;https://opendoorlogistics.com/software/odl-studio/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ODL Studio&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Kuifje02/vrpy&quot; rel=&quot;nofollow noreferrer&quot;&gt;vrpy&lt;/a&gt;: A python framework for solving the VRP and its variants with column generation.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/yorak/VeRyPy&quot; rel=&quot;nofollow noreferrer&quot;&gt;VeRyPy&lt;/a&gt;: A python library with implementations of 15 classical heuristics for the capacitated vehicle routing problem.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/VROOM-Project/vroom&quot; rel=&quot;nofollow noreferrer&quot;&gt;vroom&lt;/a&gt;: Vehicle Routing Open-source Optimization Machine&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vidalt/HGS-CVRP&quot; rel=&quot;nofollow noreferrer&quot;&gt;HGS-CVRP&lt;/a&gt;: Modern implementation of the hybrid genetic search (HGS) algorithm specialized to the capacitated vehicle routing problem (CVRP).&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vrpsolver.math.u-bordeaux.fr/&quot; rel=&quot;nofollow noreferrer&quot;&gt;VRPSolver&lt;/a&gt;: Branch-Cut-and-Price based exact solver for vehicle routing and some related problems&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/reinterpretcat/vrp&quot; rel=&quot;nofollow noreferrer&quot;&gt;vrp&lt;/a&gt;: A Vehicle Routing Problem solver&lt;/li&gt;&#xA;&lt;li&gt;COIN-OR tools: TODO&lt;/li&gt;&#xA;&lt;li&gt;OscaR: TODO&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Nurse Rostering problem&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OptaPlanner: &lt;a href=&quot;https://www.optaplanner.org/learn/useCases/employeeRostering.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;explanation + videos&lt;/a&gt; - &lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/src/main/java/org/optaplanner/examples/nurserostering&quot; rel=&quot;nofollow noreferrer&quot;&gt;source code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Conference Scheduling&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OptaPlanner: &lt;a href=&quot;https://www.optaplanner.org/learn/useCases/conferenceScheduling.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;explanation + videos&lt;/a&gt; - &lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/src/main/java/org/optaplanner/examples/conferencescheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;source code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Course Scheduling&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OptaPlanner: &lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/src/main/java/org/optaplanner/examples/curriculumcourse&quot; rel=&quot;nofollow noreferrer&quot;&gt;source code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Exam Scheduling&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OptaPlanner: &lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/src/main/java/org/optaplanner/examples/examination&quot; rel=&quot;nofollow noreferrer&quot;&gt;source code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Job Shop scheduling&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OptaPlanner: &lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/src/main/java/org/optaplanner/examples/projectjobscheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;source code of variant&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;LocalSolver: &lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/jobshop.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;explanation + source code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Knapsack&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;LocalSolver: &lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/knapsack.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;explanation + source code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;OR-Tools: &lt;a href=&quot;https://developers.google.com/optimization/bin/knapsack&quot; rel=&quot;nofollow noreferrer&quot;&gt;explanation + source code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/fontanf/knapsacksolver&quot; rel=&quot;nofollow noreferrer&quot;&gt;knapsacksolver&lt;/a&gt;: A solver for the 0-1 Knapsack Problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Bin Packing&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ktnr/BinPacking2D&quot; rel=&quot;nofollow noreferrer&quot;&gt;BinPacking2D&lt;/a&gt;: Exact solutions for two-dimensional bin packing problems by branch-and-cut&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Pseudomanifold/bin-packing&quot; rel=&quot;nofollow noreferrer&quot;&gt;bin-packing&lt;/a&gt;: C++ implementation of heuristics for solving the bin-packing problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Assembly Line Balancing Problem&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SALOME Branch &amp;amp; Bound Algorithm:&lt;a href=&quot;https://assembly-line-balancing.de/salbp/salome/&quot; rel=&quot;nofollow noreferrer&quot;&gt;explanation + source code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Branch &amp;amp; Bound &amp;amp; Remember Algorithm: &lt;a href=&quot;https://assembly-line-balancing.de/salbp/bbr-branch-bound-remember-for-salbp-1/&quot; rel=&quot;nofollow noreferrer&quot;&gt;explanation + source code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;P-median site location&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Territorium: &lt;a href=&quot;https://github.com/PGWelch/territorium&quot; rel=&quot;nofollow noreferrer&quot;&gt;source code&lt;/a&gt;, &lt;a href=&quot;https://opendoorlogistics.com/tutorials/tutorial-territory-design/territorium/&quot; rel=&quot;nofollow noreferrer&quot;&gt;UI&lt;/a&gt;. Does capacitated clustering for both min and max quantity range using heuristics.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;K-median Problem&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/AustinLBuchanan/kmedian&quot; rel=&quot;nofollow noreferrer&quot;&gt;kmedian&lt;/a&gt;: Lagrangian tools for the k-median problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Resource constrainted shortest path&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/torressa/cspy&quot; rel=&quot;nofollow noreferrer&quot;&gt;cspy&lt;/a&gt;: A collection of algorithms for the (Resource) Constrained Shortest Path problem in Python / C++ / C#&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/DouYishun/vrp-espprc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vrp-espprc&lt;/a&gt;: Elementary Shortest Path Problem with Resource Constraints&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Assignment Problems&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/fontanf/generalizedassignmentsolver&quot; rel=&quot;nofollow noreferrer&quot;&gt;generalizedassignmentsolver&lt;/a&gt;: A solver for the Generalized Assignment Problem&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ryanjoneil/ap.cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;ap.cpp&lt;/a&gt;: C++ implementation of an incremental primal-dual assignment problem solver.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Set Covering Problem&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/fontanf/setcoveringsolver&quot; rel=&quot;nofollow noreferrer&quot;&gt;setcoveringsolver&lt;/a&gt;: A solver for the (Unicost) Set Covering Problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Hitting Set Problem&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/felerius/findminhs&quot; rel=&quot;nofollow noreferrer&quot;&gt;findminhs&lt;/a&gt;: Implementation of the Minimum Hitting Set solver described in the paper &amp;quot;An Efficient Branch-and-Bound Solver for Hitting Set&amp;quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Stable Set Problem&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/fontanf/stablesolver&quot; rel=&quot;nofollow noreferrer&quot;&gt;stablesolver&lt;/a&gt;: Solvers for the Maximum(-Weight) Independent Set and the Maximum(-Weight) Clique Problems&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://users.aalto.fi/%7Epat/cliquer.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cliquer&lt;/a&gt;: Cliquer - routines for clique searching&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://karlsruhemis.github.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;KaMIS&lt;/a&gt;: A framework for computing maximum independent sets (and related problems)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Graph Coloring Problem&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/fontanf/coloringsolver&quot; rel=&quot;nofollow noreferrer&quot;&gt;coloringsolver&lt;/a&gt;: A solver for the Graph Coloring Problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I've made this post a wiki: please add &lt;em&gt;common&lt;/em&gt; OR problems and/or implementations.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="9673" LastEditDate="2023-01-22T10:03:07.177" LastActivityDate="2023-01-22T10:03:07.177" CommentCount="4" CommunityOwnedDate="2019-07-01T11:00:46.363" ContentLicense="CC BY-SA 4.0" />
  <row Id="846" PostTypeId="2" ParentId="842" CreationDate="2019-07-01T11:31:34.373" Score="8" Body="&lt;p&gt;Since your graph is directed you can first compute the &lt;a href=&quot;https://en.wikipedia.org/wiki/Strongly_connected_component&quot; rel=&quot;nofollow noreferrer&quot;&gt;strongly connected components&lt;/a&gt; in linear time &lt;span class=&quot;math-container&quot;&gt;$O(n+m)$&lt;/span&gt;, contract the components, and then run BFS on the contracted graph. For each strongly connected component with &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; nodes this saves you &lt;span class=&quot;math-container&quot;&gt;$c-1$&lt;/span&gt; BFS calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the resulting graph is a DAG, so processing it in reverse topological order the reachable nodes of a node are given by the union of the reachable nodes of the successors and the node itself.&lt;/p&gt;&#xA;" OwnerUserId="87" LastEditorUserId="87" LastEditDate="2019-07-01T13:04:46.620" LastActivityDate="2019-07-01T13:04:46.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="847" PostTypeId="2" ParentId="841" CreationDate="2019-07-01T12:16:51.467" Score="12" Body="&lt;p&gt;I would, for everything &lt;strong&gt;knapsack&lt;/strong&gt;-like, always go to David Pisingers &lt;a href=&quot;http://hjemmesider.diku.dk/~pisinger/codes.html&quot; rel=&quot;noreferrer&quot;&gt;homepage&lt;/a&gt;. Here you can find very efficient codes for knapsack problems (COMBO), multiple-choice knapsack problems (Mcknap), and quadratick knapsack problems (quadknap) among others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if it qualifies as a &quot;common OR problem&quot; but for &lt;strong&gt;linear vector optimization&lt;/strong&gt; (and therefore also linear multi-objective optimization) there is the &lt;em&gt;&lt;a href=&quot;http://www.bensolve.org/&quot; rel=&quot;noreferrer&quot;&gt;BENSOLVE&lt;/a&gt;&lt;/em&gt; solver.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2019-07-02T11:30:44.573" LastActivityDate="2019-07-02T11:30:44.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="848" PostTypeId="1" CreationDate="2019-07-01T13:08:03.867" Score="24" ViewCount="5150" Body="&lt;p&gt;I have found a &lt;a href=&quot;https://ura3.c.ism.ac.jp/opt2019/slides/Hall.pdf&quot; rel=&quot;noreferrer&quot;&gt;PowerPoint presentation&lt;/a&gt; in which the presentor Hall claims instances could be of the size of 10&lt;sup&gt;8&lt;/sup&gt; in variables and constraints to be solved today. I assume that he meant sparse problems. Bixby claims that since CPLEX 5 the problem size scales proportionally with the time needed. Is there actually evidence for this? Which problems are hard nuts to crack? What actual time is necessary to solve a problem with certain characteristics in general?&lt;/p&gt;&#xA;" OwnerUserId="556" LastEditorUserId="123" LastEditDate="2019-07-02T13:16:15.997" LastActivityDate="2019-07-02T13:16:15.997" Title="What instances can be solved today by modern solvers (pure LP)?" Tags="|linear-programming|optimization|solver|cplex|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="849" PostTypeId="2" ParentId="848" CreationDate="2019-07-01T15:44:05.420" Score="19" Body="&lt;p&gt;Hans Mittelmann maintains a well-respected &lt;a href=&quot;http://plato.asu.edu/bench.html&quot; rel=&quot;noreferrer&quot;&gt;website&lt;/a&gt; with benchmarks for optimization software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For LP problems, both simplex and barrier methods are compared. The first instance on the barrier page is &lt;em&gt;L1_sixm1000obs&lt;/em&gt;, with 3,082,940 constraints, 1,426,256 variables, and 14,262,560 non-zero elements in the constraint matrix. This problem is solved within the hour by the MOSEK solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do note that due to an incident (see site) the performance of solvers CPLEX, Gurobi, and XPRESS are not included in the current benchmarks, but can in part be found in the archives.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on this information, the claim that significantly larger LP problems can be solved by state-of-the-art solvers is not unbelievable to me.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-07-01T15:44:05.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="850" PostTypeId="1" CreationDate="2019-07-01T16:29:47.637" Score="4" ViewCount="69" Body="&lt;p&gt;I have the following constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f\geq C_1\left(d-z-E_1-E_2\right)+C_2\left(E_1+E_2\right).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$f, d,z\in \mathbb{R}_{\geq 0}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y\in \{0,1\}$&lt;/span&gt; are variables and &lt;span class=&quot;math-container&quot;&gt;$C_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$C_2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$E_1$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$E_2$&lt;/span&gt; are parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to have this constraint active only if &lt;span class=&quot;math-container&quot;&gt;$(d-z-E_1-E_2)\geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current solution is the following. I introduce &lt;span class=&quot;math-container&quot;&gt;$v\in \{0,1\}$&lt;/span&gt; and use the following constraints to make sure that &lt;span class=&quot;math-container&quot;&gt;$v=1$&lt;/span&gt; only if &lt;span class=&quot;math-container&quot;&gt;$\left(d-z-E_1-E_2\right)\geq 0$&lt;/span&gt;. The parameter &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a big &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \begin{aligned}&#xA;        f\geq C_1\left(d-z-E_1-E_2\right)+C_2\left(E_1+E_2\right)-M\left(2-y-v\right)&#xA;    \end{aligned}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \begin{aligned}&#xA;        \left(d-z-E_1-E_2\right)\leq Mv&#xA;    \end{aligned}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the above solution is not sufficient because I want &lt;span class=&quot;math-container&quot;&gt;$v = 0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$\left(d-z-E_1-E_2\right)&amp;lt;0$&lt;/span&gt;. I couldn't come up with that simple inequality constraint. Please let me know if you have a better solution.&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="145" LastEditDate="2019-07-01T18:42:08.780" LastActivityDate="2019-07-01T18:42:08.780" Title="If and then constraint for a special case" Tags="|mixed-integer-programming|constraint|big-m|" AnswerCount="0" CommentCount="2" ClosedDate="2019-07-01T18:58:07.527" ContentLicense="CC BY-SA 4.0" />
  <row Id="852" PostTypeId="2" ParentId="834" CreationDate="2019-07-01T17:49:48.570" Score="10" Body="&lt;p&gt;In addition to previous answers, I like to cite the following book, which discuss in details several different options (and kind of &lt;strong&gt;good practices&lt;/strong&gt;) to model different common applications:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.wiley.com/en-us/Model+Building+in+Mathematical+Programming%2C+5th+Edition-p-9781118443330&quot; rel=&quot;noreferrer&quot;&gt;Model Building in Mathematical Programming&lt;/a&gt;, by H. Paul Williams. March, 2013.&#xA;ISBN: 978-1-118-44333-0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every chapter is very interesting and is worth of (re)reading several times.&lt;/p&gt;&#xA;" OwnerUserId="171" LastActivityDate="2019-07-01T17:49:48.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="853" PostTypeId="1" CreationDate="2019-07-01T18:36:50.517" Score="4" ViewCount="115" Body="&lt;p&gt;How can I create constraints to make sure &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$k\geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$k&amp;lt;0$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x\in \{0,1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k\in \mathbb{R}$&lt;/span&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my attempt:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{cons:1}&#xA;    \begin{aligned}&#xA;        k\leq Mx&#xA;    \end{aligned}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Considering &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; as the big-M, the above constraint makes sure &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$k&amp;gt;0$&lt;/span&gt;. Surely, it is missing all other components.&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="145" LastEditDate="2019-07-01T19:54:41.673" LastActivityDate="2019-07-01T19:54:41.673" Title="Conditional constraint formulation" Tags="|mixed-integer-programming|logical-constraints|" AnswerCount="0" CommentCount="5" ClosedDate="2019-07-02T08:20:44.540" ContentLicense="CC BY-SA 4.0" />
  <row Id="854" PostTypeId="2" ParentId="848" CreationDate="2019-07-01T18:40:12.793" Score="17" Body="&lt;p&gt;A couple years ago, I solved an integer program with more than 11,000,000 variables &lt;a href=&quot;https://www.kaggle.com/c/santa-gift-matching/discussion/48709#latest-276620&quot; rel=&quot;noreferrer&quot;&gt;as part of a Kaggle competition&lt;/a&gt;. To solve the IP, the MIP solver first solved the LP relaxation, which took about 45 minutes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently, my PhD student Hamid solved an LP with 65 million variables, 65 million constraints, and 325 million nonzeros. It took 5 days to solve with barrier and required roughly 60 GB RAM. That's getting close to the 10&lt;sup&gt;8&lt;/sup&gt; number you quote.&lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="123" LastEditDate="2019-07-02T13:15:46.677" LastActivityDate="2019-07-02T13:15:46.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="855" PostTypeId="2" ParentId="848" CreationDate="2019-07-01T18:48:17.503" Score="28" Body="&lt;p&gt;For sure Julian Hall meant sparse problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to solve huge sparse LP problems. If they have sufficiently nice structure your can solve problems with up 2&lt;sup&gt;31&lt;/sup&gt; constraints or variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance we solve some huge problems in &lt;a href=&quot;https://github.com/MOSEK/Tutorials/blob/master/wasserstein/wasserstein-bary.ipynb&quot; rel=&quot;noreferrer&quot;&gt;this GitHub tutorial&lt;/a&gt; in a moderate amount of time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Saying some about the solution time based of some simple statistics of the problem is in my opinion impossible. You have to run it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, &lt;a href=&quot;https://twitter.com/pkhuong/status/1120313295834165250&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; is an example where glop (a simplex solver sponsored by Google) did not finish in 40 days.&#xA;Although this problem is not huge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually I find interior-point methods are better than simplex algorithm for large problems. It is also true the time per simplex iteration is almost constant independent of the problem dimension for many practical LPs. But there are exceptions and the number of iterations can be huge for degenerate problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, this based on experience with developing &lt;a href=&quot;https://www.mosek.com&quot; rel=&quot;noreferrer&quot;&gt;Mosek&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="123" LastEditDate="2019-07-02T13:16:11.933" LastActivityDate="2019-07-02T13:16:11.933" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="856" PostTypeId="1" AcceptedAnswerId="857" CreationDate="2019-07-01T19:15:19.613" Score="-3" ViewCount="94" Body="&lt;p&gt;I have a question of how to make a geometric interpretation of this problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA; \mbox{max} &amp;amp;  z = 3x_1+x_3 \\ &#xA; s.a: &amp;amp; \\&#xA; &amp;amp; \begin{array}{cc}&#xA;      x_1+2x_2+x_3+x_4&amp;amp; =10 \\&#xA;      x_1-2x_2+2x_3&amp;amp;=6\\&#xA;      1 \leq x_1\leq 4&amp;amp;\\&#xA;      -5 \leq x_2 \leq 4\\&#xA;      0 \leq x_3 \leq 4&amp;amp;\\&#xA;      0 \leq x_4 \leq 5&amp;amp;&#xA; \end{array} &#xA;\end{eqnarray}&lt;/span&gt; &lt;/p&gt;&#xA;" OwnerUserId="777" LastEditorUserId="777" LastEditDate="2019-07-02T11:27:10.273" LastActivityDate="2019-07-02T11:27:10.273" Title="Geometric interpretation of a Linear problem with bounded variables" Tags="|linear-programming|optimization|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="857" PostTypeId="2" ParentId="856" CreationDate="2019-07-01T19:34:45.647" Score="5" Body="&lt;p&gt;How about this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the first two constraints you will cancel out &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; which gives you: &lt;span class=&quot;math-container&quot;&gt;$2x_1 + 2x_3 + x_4 = 16$&lt;/span&gt;. Now, you can solve for &lt;span class=&quot;math-container&quot;&gt;$x_4$&lt;/span&gt; and substitute that in the last constraint (&lt;span class=&quot;math-container&quot;&gt;$0 \le x_4 \le 5$&lt;/span&gt;) and you will have a system which only relies on &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-07-01T19:34:45.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="858" PostTypeId="1" CreationDate="2019-07-01T19:45:29.667" Score="9" ViewCount="1402" Body="&lt;p&gt;I am solving a MILP model using CPLEX 12.8.0, but CPLEX exceeds the time limit on some test instances. More specifically, I set the time limit for 30 minutes using the &lt;strong&gt;cplex.setParam(IloCplex::TiLim, 1800)&lt;/strong&gt; command, but in some instances, CPLEX runs for over 2 hours.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-07-04T10:05:28.370" Title="CPLEX exceeds time limit issue" Tags="|cplex|mixed-integer-programming|c++|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="859" PostTypeId="2" ParentId="858" CreationDate="2019-07-01T21:06:24.360" Score="12" Body="&lt;p&gt;It could be that you faced the issue described in this bug report.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RS03137: CPLEX MAY IGNORE TIME LIMITS ON HIGHLY SYMMETRIC MODELS ON WHICH A NEW INCUMBENT IS FOUND CLOSE TO THE TIME LIMIT.&#xA;&lt;a href=&quot;http://www-01.ibm.com/support/docview.wss?uid=swg1RS03137&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www-01.ibm.com/support/docview.wss?uid=swg1RS03137&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bug was fixed in version 12.9, which was released earlier in the year.&lt;/p&gt;&#xA;" OwnerUserId="295" LastEditorUserId="295" LastEditDate="2019-07-04T10:05:28.370" LastActivityDate="2019-07-04T10:05:28.370" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="860" PostTypeId="1" AcceptedAnswerId="861" CreationDate="2019-07-01T21:41:28.920" Score="13" ViewCount="1103" Body="&lt;p&gt;Maximizing sum-of-max terms is an NP-hard problem. The objective function is a convex function and maximizing a convex function is a hard problem. Also, this is a non-differentiable function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CPLEX and GUROBI solve these problems to global optimality. I don't know what method they use. I guess they first eliminate the obviously bad terms in the beginning and then follow a branching tree to optimize each combination. Is this correct? What methods do they use, how can I (roughly) learn about this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am interested in linear constraints. For example:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\begin{array}{ll}&#xA;\max &amp;amp; \left\{\max\{3x_1 + 4x_2 , -2x_1 +7x_2 \}  + \max\{-x_1 + 6x_2 , 5x_1 +3x_2 \} \right\} \\&#xA;\text{st} &amp;amp;  a \leq x_1 + x_2 \leq  b  \\&#xA;&amp;amp; x_1 \geq c, x_2 \geq d&#xA;\end{array}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am solving a way bigger case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Apparently, CPLEX and GUROBI solve Mixed Integer Optimization problems. The equivalent formulation as given in the accepted answer is being generated by YALMIP parser which I use.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2019-07-04T21:41:22.380" LastActivityDate="2019-07-04T21:41:22.380" Title="Sum of Max terms maximization" Tags="|solver|nonlinear-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="861" PostTypeId="2" ParentId="860" CreationDate="2019-07-01T22:26:01.337" Score="15" Body="&lt;p&gt;If your problem is reasonably small then one relatively simple approach is to reformulate the objective as a MIP, under a big-M assumption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose that our objective is to maximize &lt;span class=&quot;math-container&quot;&gt;$$\sum_i g_i(x),$$&lt;/span&gt; where each &lt;span class=&quot;math-container&quot;&gt;$g_i(x):=\max_j a_j^{i\top} x+b^i_j$&lt;/span&gt; is the maximum of some affine functions. We can model this by introducing auxilliary variables &lt;span class=&quot;math-container&quot;&gt;$\theta_i$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\theta_i \leq g_i(x)$&lt;/span&gt;, letting &lt;span class=&quot;math-container&quot;&gt;$z_{i,j}=1$&lt;/span&gt; if the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;th affine function in &lt;span class=&quot;math-container&quot;&gt;$g_i(x)$&lt;/span&gt; is the largest at &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, and maximizing the following problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\max \quad &amp;amp; \sum_i \theta_i\\&#xA;\text{s.t.} \quad &amp;amp; \theta_i \leq a_j^{i\top}x+b_j^i+M(1-z_{i,j}), \forall i, \forall j,\\&#xA;&amp;amp; \sum_j z_{i,j}=1, \forall i,\\&#xA;&amp;amp; z_{i,j} \in \{0, 1 \}, \forall i, \forall j.&#xA;\end{align*}&lt;/span&gt;&#xA;The combination of the big-M constraints and &quot;objective pressure&quot; ensures that &lt;span class=&quot;math-container&quot;&gt;$\theta_i=g_i(x)$&lt;/span&gt; at optimality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the problem is larger, the above big-M approach won't give tight enough relaxations for branch-and-bound to perform well and we will need to think about using more complicated formulations. In this case, you should think about exploiting the structure of the problem, i.e., explicitly treating the problem as maximizing the sum of piecewise linear functions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tighter formulations than the generic big-M approach have been developed &lt;a href=&quot;https://arxiv.org/pdf/1708.00050.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea whether or not this approach is what CPLEX/Gurobi use.&lt;/p&gt;&#xA;" OwnerUserId="43" LastActivityDate="2019-07-01T22:26:01.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="862" PostTypeId="2" ParentId="858" CreationDate="2019-07-02T03:39:33.330" Score="8" Body="&lt;p&gt;That may be related to the &quot;presolve&quot; phase of the optimization procedure. In large instances, the time for &quot;presolve&quot; may be too large, that makes the total time larger than the specified time-limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that is the case, you can set the presolve parameter to zero, so that CPLEX does not perform a presolve on your instances. The following link is useful to perform that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/en/SS9UKU_12.6.1/com.ibm.cplex.zos.help/CPLEX/Parameters/topics/PreInd.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.ibm.com/support/knowledgecenter/en/SS9UKU_12.6.1/com.ibm.cplex.zos.help/CPLEX/Parameters/topics/PreInd.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you don't want to eliminate the presolve totally, you can limit the number of passes it performs. For that, you can find the parameter in the following link:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.1/ilog.odms.cplex.help/CPLEX/Parameters/topics/PrePass.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.1/ilog.odms.cplex.help/CPLEX/Parameters/topics/PrePass.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="660" LastActivityDate="2019-07-02T03:39:33.330" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="864" PostTypeId="2" ParentId="848" CreationDate="2019-07-02T09:11:44.710" Score="11" Body="&lt;p&gt;The instances I referred to are stochastic LPs (for unit commitment problems)&lt;sup&gt;1&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We developed a parallel simplex solver exploiting the block structure and used a special hot start procedure. The biggest solved had 500,000,000 variables and constraints, but took only 41000 iterations. So, highly specialised problems and solution method, and far from reality!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, Bixby's correct regarding problems exhibiting hyper-sparsity. The cost per iteration is &lt;span class=&quot;math-container&quot;&gt;$\mathcal O(1)$&lt;/span&gt;, so the &lt;span class=&quot;math-container&quot;&gt;$\mathcal O(m+n)$&lt;/span&gt; iteration count means that the solution time scales linearly with problem size. Many practical problems are hyper-sparse, but by no means all, and particularly so for benchmark instances. Mittelmann's 11 recent changes of problem means that there are fewer hyper-sparse problems. Witness the fact that most solvers are less uncompetitive relative to Clp as a result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're solving a single LP with no information about the solution, then IPM will generally be faster - simplex is better for some hyper-sparse problems and oddities like the QAPs (following the Idiot crash).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Lubin, M., Hall, J. A. J., Petra, C. G., Anitescu, M. (2013). Parallel distributed-memory simplex for large-scale stochastic LP problems. &lt;em&gt;Computational Optimization and Applications&lt;/em&gt;. &lt;strong&gt;55&lt;/strong&gt;(3), 571-596, 2013. DOI: 10.1007/s10589-013-9542-y &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="228" LastEditorUserId="123" LastEditDate="2019-07-02T13:16:00.187" LastActivityDate="2019-07-02T13:16:00.187" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="865" PostTypeId="1" AcceptedAnswerId="866" CreationDate="2019-07-02T10:16:34.600" Score="40" ViewCount="1747" Body="&lt;p&gt;Many abbreviations are used in Operations Research. For example, we have abbreviations for problem classes (LP, MIP), solution methods (IPM), and specific problems (TSP, VRP).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which abbreviations are commonly used by the Operations Research community?&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="68" LastEditDate="2020-01-09T15:58:40.203" LastActivityDate="2024-02-17T13:57:32.463" Title="What are common and not so common abbreviations in Operations Research?" Tags="|terminology|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="866" PostTypeId="2" ParentId="865" CreationDate="2019-07-02T10:16:34.600" Score="61" Body="&lt;p&gt;This answer is a Community Wiki post to allow everybody to contribute to the list. As a guideline, only add abbreviations that most people in the field are familiar with.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;General&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CS - Computer Science&lt;/li&gt;&#xA;&lt;li&gt;IE - Industrial Engineering&lt;/li&gt;&#xA;&lt;li&gt;MS - Management Science&lt;/li&gt;&#xA;&lt;li&gt;OM - Operations Management&lt;/li&gt;&#xA;&lt;li&gt;OR - Operations Research (or Operational Research)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem classes&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;BP - Bilevel Program&lt;/li&gt;&#xA;&lt;li&gt;BLP - Binary Linear Program&lt;/li&gt;&#xA;&lt;li&gt;BMI - Bilinear Matrix Inequality&lt;/li&gt;&#xA;&lt;li&gt;CCP - Chance-Constrained Program(ming) (note: also stands for Convex-Concave Procedure)&lt;/li&gt;&#xA;&lt;li&gt;CP - Constraint Programming&lt;/li&gt;&#xA;&lt;li&gt;CSP - Constraint Satisfaction Program&lt;/li&gt;&#xA;&lt;li&gt;DC - Difference of Convex (Functions) Programming&lt;/li&gt;&#xA;&lt;li&gt;DCCP - Disciplined Convex-Concave Programming (handles DC Programming)&lt;/li&gt;&#xA;&lt;li&gt;DCP - Disciplined Convex Programming (used by CVX, CVXPY, CVXR)&lt;/li&gt;&#xA;&lt;li&gt;DGP - Disciplined Geometric Programming (used by CVX, CVXPY, CVXR)&lt;/li&gt;&#xA;&lt;li&gt;DES - Discrete-Event Simulation&lt;/li&gt;&#xA;&lt;li&gt;DGO - Deterministic Global Optimization&lt;/li&gt;&#xA;&lt;li&gt;DMCP - Disciplined Multi-Convex Programming&lt;/li&gt;&#xA;&lt;li&gt;DQCP - Disciplined Quasiconvex Programming&lt;/li&gt;&#xA;&lt;li&gt;DP - Dynamic Program(ming)&lt;/li&gt;&#xA;&lt;li&gt;GO - Global Optimization&lt;/li&gt;&#xA;&lt;li&gt;GP - Geometric Program(ming)&lt;/li&gt;&#xA;&lt;li&gt;ILP - Integer Linear Program(ming)&lt;/li&gt;&#xA;&lt;li&gt;IP - Integer Program(ming)&lt;/li&gt;&#xA;&lt;li&gt;LCP - Linear Complementarity Problem&lt;/li&gt;&#xA;&lt;li&gt;LFP - Linear-Fractional Program(ming)&lt;/li&gt;&#xA;&lt;li&gt;LMI - Linear Matrix Inequality&lt;/li&gt;&#xA;&lt;li&gt;LP - Linear Program(ming)&lt;/li&gt;&#xA;&lt;li&gt;MBLP - Mixed Binary Linear Program&lt;/li&gt;&#xA;&lt;li&gt;MDE - Minimum-Distortion Embedding&lt;/li&gt;&#xA;&lt;li&gt;MCF / MCNF - Minimum Cost Flow, or Minimum Cost Network Flow (note: also stands for Multi-Commodity Network Flow).&lt;/li&gt;&#xA;&lt;li&gt;MFP - Maximum Flow Problem&lt;/li&gt;&#xA;&lt;li&gt;MIDCP - Mixed Integer Disciplined Convex Programming&lt;/li&gt;&#xA;&lt;li&gt;MIGP - Mixed Integer Geometric Program(ming)&lt;/li&gt;&#xA;&lt;li&gt;MIP - Mixed Integer Program&lt;/li&gt;&#xA;&lt;li&gt;MILP - Mixed Integer Linear Program&lt;/li&gt;&#xA;&lt;li&gt;MINLP - Mixed Integer Nonlinear Program&lt;/li&gt;&#xA;&lt;li&gt;MIQCQP - Mixed Integer Quadratically Constrained Quadratic Program&lt;/li&gt;&#xA;&lt;li&gt;MIQP - Mixed Integer Quadratic Program&lt;/li&gt;&#xA;&lt;li&gt;MISOCP - Mixed Integer Second Order Cone Program&lt;/li&gt;&#xA;&lt;li&gt;MISDP - Mixed Integer Semidefinite Program&lt;/li&gt;&#xA;&lt;li&gt;MOOP - Multi-Objective Optimization Problem&lt;/li&gt;&#xA;&lt;li&gt;MCNF - Multi-Commodity Network Flow problem (note: also stands for Minimum Cost Network Flow)&lt;/li&gt;&#xA;&lt;li&gt;MaOOP - Many-Objective Optimization Problem&lt;/li&gt;&#xA;&lt;li&gt;MOLP - Multi-Objective Linear Program&lt;/li&gt;&#xA;&lt;li&gt;MP - Mathematical Program (or Master Problem)&lt;/li&gt;&#xA;&lt;li&gt;MPCC - Mathematical Program with Complementarity Constraints (same as MPEC)&lt;/li&gt;&#xA;&lt;li&gt;MPEC - Mathematical Program with Equilibrium Constraints (same as MPCC)&lt;/li&gt;&#xA;&lt;li&gt;NLCP - Nonlinear Complementarity Problem&lt;/li&gt;&#xA;&lt;li&gt;NLP - Nonlinear Program(ming) (now far more commonly stands for &amp;quot;Natural Language Processing&amp;quot; outside of OR and nonlinear programming people, but Nonlinear Program(ming) was the original)&lt;/li&gt;&#xA;&lt;li&gt;NMF or NNMF - Non-Negative Matrix Factorization&lt;/li&gt;&#xA;&lt;li&gt;POP - Polynomial Optimization Problem&lt;/li&gt;&#xA;&lt;li&gt;QP - Quadratic Program(ming)&lt;/li&gt;&#xA;&lt;li&gt;QCQP - Quadratically Constrained Quadratic Program&lt;/li&gt;&#xA;&lt;li&gt;QUBO - Quadratic Unconstrained Binary Optimization (problem)&lt;/li&gt;&#xA;&lt;li&gt;RO - Robust Optimization&lt;/li&gt;&#xA;&lt;li&gt;ARO - Adjustable Robust Optimization&lt;/li&gt;&#xA;&lt;li&gt;SCP - Set-Covering Problem&lt;/li&gt;&#xA;&lt;li&gt;SDP - Semidefinite Program(ming)&lt;/li&gt;&#xA;&lt;li&gt;SOCP - Second Order Cone Program (or Problem)&lt;/li&gt;&#xA;&lt;li&gt;SMINLSDP - Stochastic Mixed Integer Nonlinear Semidefinite Program&lt;/li&gt;&#xA;&lt;li&gt;SOS - Sum of Squares Programming (note: also stands for Special Ordered Set)&lt;/li&gt;&#xA;&lt;li&gt;SP - Stochastic Program(ming)&lt;/li&gt;&#xA;&lt;li&gt;SPP - Saddle Point Problem (note: also stands for Set-Partitioning Problem)&lt;/li&gt;&#xA;&lt;li&gt;SPP - Set-Partitioning Problem (note: also stands for Saddle Point Problem)&lt;/li&gt;&#xA;&lt;li&gt;TDI - Total Dual Integrality&lt;/li&gt;&#xA;&lt;li&gt;TF - Tensor Factorization&lt;/li&gt;&#xA;&lt;li&gt;UBQP - Unconstrained Binary Quadratic Program(ming)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Solution methods&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;AD - Automatic Differentiation, a.k.a. Algorithmic Differentiation&lt;/li&gt;&#xA;&lt;li&gt;ADMM - Alternating Direction Method of Multipliers&lt;/li&gt;&#xA;&lt;li&gt;ADP - Approximate Dynamic Programming&lt;/li&gt;&#xA;&lt;li&gt;ASM - Active Set Method&lt;/li&gt;&#xA;&lt;li&gt;BB, B&amp;amp;B, or BnB - Branch-and-bound&lt;/li&gt;&#xA;&lt;li&gt;BCP - Branch-Cut-and-Price&lt;/li&gt;&#xA;&lt;li&gt;BD - Benders Decomposition&lt;/li&gt;&#xA;&lt;li&gt;BDD - Binary Decision Diagram&lt;/li&gt;&#xA;&lt;li&gt;BFGS - Broyden Fletcher Goldfarb Shanno (Quasi-Newton)&lt;/li&gt;&#xA;&lt;li&gt;BFS - Breadth-First Search&lt;/li&gt;&#xA;&lt;li&gt;BPC - Branch-Price-and-Cut&lt;/li&gt;&#xA;&lt;li&gt;CCP - Convex-Concave Procedure (note: also stands for Chance-Constrained Program(ming))&lt;/li&gt;&#xA;&lt;li&gt;CF - Cholesky Factorization&lt;/li&gt;&#xA;&lt;li&gt;CG - Column Generation (note: also stands for Conjugate Gradient)&lt;/li&gt;&#xA;&lt;li&gt;CG - Conjugate Gradient (note: also stands for Column Generation)&lt;/li&gt;&#xA;&lt;li&gt;CPM - Cutting Plane Method&lt;/li&gt;&#xA;&lt;li&gt;CQ - Constraint Qualification&lt;/li&gt;&#xA;&lt;li&gt;CRCQ - Constant Rank constraint qualification&lt;/li&gt;&#xA;&lt;li&gt;DFP - Davidon Fletcher Powell (Quasi-Newton)&lt;/li&gt;&#xA;&lt;li&gt;DFS - Depth-First Search&lt;/li&gt;&#xA;&lt;li&gt;DW - Dantzig–Wolfe decomposition&lt;/li&gt;&#xA;&lt;li&gt;ECP - Extended Cutting Plane (Method)&lt;/li&gt;&#xA;&lt;li&gt;FJ - Fritz John conditions&lt;/li&gt;&#xA;&lt;li&gt;GBD - Generalized Benders Decomposition&lt;/li&gt;&#xA;&lt;li&gt;GD - Gradient Descent&lt;/li&gt;&#xA;&lt;li&gt;IPA - Infinitesimal Perturbation Analysis  (for stochastic simulation derivative estimation)&lt;/li&gt;&#xA;&lt;li&gt;IPM - Interior Point Method&lt;/li&gt;&#xA;&lt;li&gt;KKT - Karush Kuhn Tucker conditions&lt;/li&gt;&#xA;&lt;li&gt;LCQ - Linearity constraint qualification&lt;/li&gt;&#xA;&lt;li&gt;LICQ - Linear Independence constraint qualification&lt;/li&gt;&#xA;&lt;li&gt;L-SR1 - Limited Memory Symmetric Rank One (Quasi-Newton)&lt;/li&gt;&#xA;&lt;li&gt;L-BFGS - Limited Memory Broyden Fletcher Goldfarb Shanno (Quasi-Newton)&lt;/li&gt;&#xA;&lt;li&gt;LR - Lagrangian Relaxation decomposition/method/problem&lt;/li&gt;&#xA;&lt;li&gt;LRM - Likelihood Ratio Method (for stochastic simulation derivative estimation)&lt;/li&gt;&#xA;&lt;li&gt;LU - LU decomposition&lt;/li&gt;&#xA;&lt;li&gt;MP - Master Problem (or Mathematical Program)&lt;/li&gt;&#xA;&lt;li&gt;MFCQ - Mangasarian–Fromovitz constraint qualification&lt;/li&gt;&#xA;&lt;li&gt;OA - Outer Approximation&lt;/li&gt;&#xA;&lt;li&gt;PSB - Powell Symmetric Broyden (Quasi-Newton&lt;/li&gt;&#xA;&lt;li&gt;RLT - Reformulation-Linearization Technique&lt;/li&gt;&#xA;&lt;li&gt;RPT - Reformulation-Perspectification Technique&lt;/li&gt;&#xA;&lt;li&gt;RPT-SDP - Reformulation-Perspectification Technique with SDP Relaxation&lt;/li&gt;&#xA;&lt;li&gt;RRQR - Rank Revealing QR factorization&lt;/li&gt;&#xA;&lt;li&gt;QN - Quasi-Newton&lt;/li&gt;&#xA;&lt;li&gt;QR - QR decomposition (a.k.a. factorization) or algorithm&lt;/li&gt;&#xA;&lt;li&gt;SA - Stochastic Approximation (note: SA also stands for &amp;quot;Simulated Annealing&amp;quot;)&lt;/li&gt;&#xA;&lt;li&gt;SAA - Sample Average Approximation&lt;/li&gt;&#xA;&lt;li&gt;SCA - Sequential Convex Approximation (more or less the same as SCP)&lt;/li&gt;&#xA;&lt;li&gt;SCP - Sequential Convex Programming (more or less the same as SCA)&lt;/li&gt;&#xA;&lt;li&gt;SDDP - Stochastic Dual Dynamic Programming&lt;/li&gt;&#xA;&lt;li&gt;SGD - Stochastic Gradient Descent&lt;/li&gt;&#xA;&lt;li&gt;SLP - Sequential Linear Programming&lt;/li&gt;&#xA;&lt;li&gt;SLQP - Sequential Linear-Quadratic Programming&lt;/li&gt;&#xA;&lt;li&gt;SO - Simulation Optimization&lt;/li&gt;&#xA;&lt;li&gt;SCQA - Sequential Quasi-Convex Approximation&lt;/li&gt;&#xA;&lt;li&gt;SQP - Sequential Quadratic Programming&lt;/li&gt;&#xA;&lt;li&gt;SR1 - Symmetric Rank One (Quasi-Newton)&lt;/li&gt;&#xA;&lt;li&gt;SVD - Singular Value Decomposition&lt;/li&gt;&#xA;&lt;li&gt;TR - Trust Region&lt;/li&gt;&#xA;&lt;li&gt;UBFGS - ultra BFGS (Broyden Fletcher Goldfarb Shanno) (Quasi-Newton)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Meta-heuristics&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ACO - Ant Colony Optimization&lt;/li&gt;&#xA;&lt;li&gt;ALNS - Adaptive Large Neighborhood Search&lt;/li&gt;&#xA;&lt;li&gt;BCO - Bee Colony Optimization&lt;/li&gt;&#xA;&lt;li&gt;GA - Genetic Algorithm&lt;/li&gt;&#xA;&lt;li&gt;LA - Late Acceptance&lt;/li&gt;&#xA;&lt;li&gt;LNS - Large Neighborhood Search&lt;/li&gt;&#xA;&lt;li&gt;LS - Local Search&lt;/li&gt;&#xA;&lt;li&gt;MOEA - Multi-Objective Evolutionary Algorithms&lt;/li&gt;&#xA;&lt;li&gt;MaOEA - Many-Objective Evolutionary Algorithms&lt;/li&gt;&#xA;&lt;li&gt;PSO - Particle Swarm Optimization&lt;/li&gt;&#xA;&lt;li&gt;SA - Simulated Annealing (note: SA also stands for &amp;quot;Stochastic Approximation&amp;quot;)&lt;/li&gt;&#xA;&lt;li&gt;SCO - Social Cognitive Optimization&lt;/li&gt;&#xA;&lt;li&gt;TS - Tabu Search&lt;/li&gt;&#xA;&lt;li&gt;VNS - Variable Neighborhood Search&lt;/li&gt;&#xA;&lt;li&gt;DEA - Differential Evolution Algorithm&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Vehicle Routing&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ACVRP - Asymmetric Capacitated Vehicle Routing Problem&lt;/li&gt;&#xA;&lt;li&gt;CARP - Capacitated Arc Routing Problem&lt;/li&gt;&#xA;&lt;li&gt;CLuVRP - Clustered Vehicle Routing Problem&lt;/li&gt;&#xA;&lt;li&gt;CVRP - Capacitated Vehicle Routing Problem&lt;/li&gt;&#xA;&lt;li&gt;DARP - Dial A Ride Problem&lt;/li&gt;&#xA;&lt;li&gt;ESPPRC - Elementary Shortest Path Problem with Resource Constraints&lt;/li&gt;&#xA;&lt;li&gt;ERCSPP - Elementary Resource Constrained Shortest Path Problem (same problem as above)&lt;/li&gt;&#xA;&lt;li&gt;MAVRP - Multi-Attribute Vehicle Routing Problem&lt;/li&gt;&#xA;&lt;li&gt;MMVRP - Min-Max Vehicle Routing Problem&lt;/li&gt;&#xA;&lt;li&gt;OPTW - Orienteering Problem with Time Windows&lt;/li&gt;&#xA;&lt;li&gt;OVRP - Open Vehicle Routing Problem&lt;/li&gt;&#xA;&lt;li&gt;PCTSP - Prize Collecting Travelling Salesman Problem&lt;/li&gt;&#xA;&lt;li&gt;PDP - Pickup and Delivery Problem&lt;/li&gt;&#xA;&lt;li&gt;PDPTW - Pickup and Delivery Problem with Time Windows&lt;/li&gt;&#xA;&lt;li&gt;PVRP - Periodic Vehicle Routing Problem&lt;/li&gt;&#xA;&lt;li&gt;RVRP - Rich Vehicle Routing Problem&lt;/li&gt;&#xA;&lt;li&gt;RVRPTW - Robust Vehicle Routing Problem with Time Windows (see also RVRP-TWA)&lt;/li&gt;&#xA;&lt;li&gt;RVRP-TWA - Robust Vehicle Routing Problem with Time Window Assignments (see also RVRPTW)&lt;/li&gt;&#xA;&lt;li&gt;SVRP - Stochastic Vehicle Routing Problem&lt;/li&gt;&#xA;&lt;li&gt;TDTSP - Time-Dependent Traveling Salesman Problem&lt;/li&gt;&#xA;&lt;li&gt;TDVRP - Time-Dependent Vehicle Routing Problem&lt;/li&gt;&#xA;&lt;li&gt;TSP - Traveling Salesman Problem&lt;/li&gt;&#xA;&lt;li&gt;TSPTW - Traveling Salesman Problem with Time Windows&lt;/li&gt;&#xA;&lt;li&gt;TSP-rd - Traveling Salesman Problem with Release Dates&lt;/li&gt;&#xA;&lt;li&gt;TTP - Traveling Tournament Problem&lt;/li&gt;&#xA;&lt;li&gt;VRP - Vehicle Routing Problem&lt;/li&gt;&#xA;&lt;li&gt;VRPTW - Vehicle Routing Problem with Time Windows&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Scheduling Problems&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;RCPSP - Resource‐Constrained Project Scheduling Problem&lt;/li&gt;&#xA;&lt;li&gt;FSP - Flow Shop scheduling Problem&lt;/li&gt;&#xA;&lt;li&gt;JSP - Job Shop scheduling Problem&lt;/li&gt;&#xA;&lt;li&gt;BJSP - Blocking Job Shop scheduling Problem, some papers also use BJSS.&lt;/li&gt;&#xA;&lt;li&gt;OSP - Open Shop scheduling Problem&lt;/li&gt;&#xA;&lt;li&gt;JIT - Just In Time&lt;/li&gt;&#xA;&lt;li&gt;FMS - Flexible Manufacturing System&lt;/li&gt;&#xA;&lt;li&gt;UET - Unit Execution Time&lt;/li&gt;&#xA;&lt;li&gt;(W)SPT - (Weighted) Shortest Processing Time&lt;/li&gt;&#xA;&lt;li&gt;(W)LPT - (Weighted) Longest Processing Time&lt;/li&gt;&#xA;&lt;li&gt;EDD - Earliest Due Date&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Facility location&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CFLP - Capacitated Facility Location Problem&lt;/li&gt;&#xA;&lt;li&gt;MCLP - Maximal Covering Location Problem&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;CP - &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-Center Problem&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;MP - &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-Median Problem&lt;/li&gt;&#xA;&lt;li&gt;SCLP - Set Covering Location Problem&lt;/li&gt;&#xA;&lt;li&gt;SSCFLP - Single Source Capacitated Facility Location Problem&lt;/li&gt;&#xA;&lt;li&gt;UFLP - Uncapacitated Facility Location Problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Inventory&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;EOQ - Economic Order Quantity&lt;/li&gt;&#xA;&lt;li&gt;MEIO - Multi-Echelon Inventory Optimization&lt;/li&gt;&#xA;&lt;li&gt;OWMR - One-Warehouse, Multiple-Retailer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Reliability and Maintenance&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CBM - Condition-Based Maintenance&lt;/li&gt;&#xA;&lt;li&gt;CM - Corrective Maintenance&lt;/li&gt;&#xA;&lt;li&gt;DFR - Decreasing Failure Rate&lt;/li&gt;&#xA;&lt;li&gt;DFRA - Decreasing Failure Rate on Average&lt;/li&gt;&#xA;&lt;li&gt;IFR - Increasing Failure Rate&lt;/li&gt;&#xA;&lt;li&gt;IFRA - Increasing Failure Rate on Average&lt;/li&gt;&#xA;&lt;li&gt;PM - Preventive Maintenance&lt;/li&gt;&#xA;&lt;li&gt;RUL - Remaining Useful Life&lt;/li&gt;&#xA;&lt;li&gt;TBM - Time-based maintenance&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$TP_r$&lt;/span&gt; - Totally Positive of order &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Cutting and Packing&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;2D-BPP - Two Dimensional Bin Packing Problem&lt;/li&gt;&#xA;&lt;li&gt;3D-BPP - Three Dimensional Bin Packing Problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Assignment Problems&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GAP - Generalized Assigment Problem&lt;/li&gt;&#xA;&lt;li&gt;LAP - Linear Assignment Problem&lt;/li&gt;&#xA;&lt;li&gt;LOP - Linear Ordering Problem&lt;/li&gt;&#xA;&lt;li&gt;QAP - Quadratic Assignment Problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Assembly/Disassembly Line Balancing&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ALB(P) - Assembly Line Balancing (Problem)&lt;/li&gt;&#xA;&lt;li&gt;DLB(P) - Disassembly Line Balancing (Problem)&lt;/li&gt;&#xA;&lt;li&gt;SALBP - Simple Assembly Line Balancing Problem&lt;/li&gt;&#xA;&lt;li&gt;MMALBP - Mixed Model Assembly Line Balancing Problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Stochastic Processes &amp;amp; Queueing&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CPP - Compound Poisson Process&lt;/li&gt;&#xA;&lt;li&gt;CTMC - Continuous Time Markov Chain&lt;/li&gt;&#xA;&lt;li&gt;DTMC - Discrete Time Markov Chain&lt;/li&gt;&#xA;&lt;li&gt;MDP - Markov Decision Process/Problem&lt;/li&gt;&#xA;&lt;li&gt;M/M/1 - single-server queue with exponential interarrival and service&#xA;times (see &lt;a href=&quot;https://en.wikipedia.org/wiki/Kendall%27s_notation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kendall's&#xA;notation&lt;/a&gt; for&#xA;others)&lt;/li&gt;&#xA;&lt;li&gt;MRP - Markov Renewal Process&lt;/li&gt;&#xA;&lt;li&gt;NHPP - nonhomogeneous Poisson Process&lt;/li&gt;&#xA;&lt;li&gt;NNPP - nonhomogeneous non-Poisson Process&lt;/li&gt;&#xA;&lt;li&gt;POMDP - Partially Observable Markov Decision Process&lt;/li&gt;&#xA;&lt;li&gt;PP - Poisson Process&lt;/li&gt;&#xA;&lt;li&gt;RRP - Renewal Reward Process&lt;/li&gt;&#xA;&lt;li&gt;SMDP - Semi-Markov Decision Process&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Other&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;AHP - Analytic Hierarchy Process&lt;/li&gt;&#xA;&lt;li&gt;ANP - Analytic Network Process&lt;/li&gt;&#xA;&lt;li&gt;DEA - Data Envelopment Analysis&lt;/li&gt;&#xA;&lt;li&gt;INFORMS - Institute for Operations Research and the Management Sciences&lt;/li&gt;&#xA;&lt;li&gt;MADM - Multi-Attribute Decision Making&lt;/li&gt;&#xA;&lt;li&gt;MCDM - Multi-Criteria Decision Making&lt;/li&gt;&#xA;&lt;li&gt;MODM - Multi-Objective Decision Making&lt;/li&gt;&#xA;&lt;li&gt;ML - Machine Learning&lt;/li&gt;&#xA;&lt;li&gt;MST - Minimum Spanning Tree&lt;/li&gt;&#xA;&lt;li&gt;SOS - Special Ordered Set (note: also stands for Sum of Squares Programming)&lt;/li&gt;&#xA;&lt;li&gt;FIFO - First In First Out&lt;/li&gt;&#xA;&lt;li&gt;LIFO - Last In First Out&lt;/li&gt;&#xA;&lt;li&gt;FCFS - First Come, First Served (see FIFO)&lt;/li&gt;&#xA;&lt;li&gt;LCFS - Last Come, First Served (see LIFO)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="145" LastEditorUserId="68" LastEditDate="2024-02-17T13:57:32.463" LastActivityDate="2024-02-17T13:57:32.463" CommentCount="9" CommunityOwnedDate="2019-07-02T10:16:34.600" ContentLicense="CC BY-SA 4.0" />
  <row Id="867" PostTypeId="2" ParentId="555" CreationDate="2019-07-02T18:15:27.790" Score="2" Body="&lt;p&gt;So assuming you have a graph that you can compute something like &lt;a href=&quot;https://networkx.github.io/documentation/latest/reference/algorithms/generated/networkx.algorithms.simple_paths.all_simple_paths.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;all_paths&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then for the the given start and end node you can create a constraint such that you have at least one of these in your solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;sum_i_j x_i_j &gt;= 1&lt;/p&gt;&#xA;" OwnerUserId="259" LastActivityDate="2019-07-02T18:15:27.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="868" PostTypeId="2" ParentId="830" CreationDate="2019-07-02T19:14:30.723" Score="3" Body="&lt;p&gt;Markov decision problem theory and computation is based on using backward induction (dynamic programming) to recursively evaluate expected rewards. When we define a policy &lt;span class=&quot;math-container&quot;&gt;$\pi = (d_1, d_2,...,d_{N-1})$&lt;/span&gt;, we assume that &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;, the length of horizon or the number of epochs is given.While in the infinite horizon the policies can be defined as, &lt;span class=&quot;math-container&quot;&gt;$\nu = (d_1, d_2,...)$&lt;/span&gt; with no limitation on the length of the horizon. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, we can only compare two policies whenever their length is equal, in other words, we can compare the immediate rewards in each and every epochs for those policies. In my opinion, the infinite horizon can be used to approximate the finite horizon if it is possible to compare a given policy on both horizons and the infinite horizon policy's reward can give a good upper or lower bound on the expected value of finite horizon policy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whit that being mentioned, approximating infinite horizon continuous time stochastic processes by using &quot;Uniformization&quot; technique and convert the problem to a discrete time Markov decision process is a well-known and well-studied procedure. Looking at the technique may give some hints on how the same approach can be used for approximation of the finite horizon process by the infinite horizon one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chapter 4 and 5 of the below-referenced book by Martin PUTERMAN, which discuss the finite and infinite horizon processes are highly recommended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Puterman, Martin L. Markov Decision Processes.: Discrete Stochastic Dynamic Programming. John Wiley &amp;amp; Sons, 2014.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-07-02T19:14:30.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="869" PostTypeId="1" CreationDate="2019-07-03T06:04:19.893" Score="10" ViewCount="3409" Body="&lt;p&gt;The reference books should cover the wide range of problem-solving techniques and methods. &lt;/p&gt;&#xA;" OwnerUserId="789" LastEditorUserId="38" LastEditDate="2020-01-29T15:17:15.663" LastActivityDate="2022-08-01T14:25:09.610" Title="What are good reference books for introduction to operations research?" Tags="|mixed-integer-programming|linear-programming|integer-programming|minlp|books|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="870" PostTypeId="2" ParentId="869" CreationDate="2019-07-03T06:23:13.427" Score="25" Body="&lt;p&gt;For books with a focus on industrial applications, see &lt;a href=&quot;https://or.stackexchange.com/questions/117/recommended-books-materials-for-practical-applications-of-operations-research-in?rq=1&quot;&gt;this other question of this forum&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As textbooks, I would recommend to have a look at:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;General Intro to OR:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;W. Winston. &lt;a href=&quot;https://itslearningakarmazyan.files.wordpress.com/2015/09/operation-research-aplications-and-algorithms.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Operations Research: Applications and Algorithms&lt;/em&gt;&lt;/a&gt; (4th Ed.). Brooks/Cole. 2004.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Modeling:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;H.P. Williams. &lt;a href=&quot;https://www.wiley.com/en-us/Model+Building+in+Mathematical+Programming%2C+5th+Edition-p-9781118443330&quot; rel=&quot;nofollow noreferrer&quot;&gt;Model building in mathematical programming&lt;/a&gt;. John Wiley &amp;amp; Sons, 2013.&lt;/p&gt;&#xA;&lt;p&gt;D. Chen, R.G. Batson, Y. Dang. &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/book/10.1002/9781118166000&quot; rel=&quot;nofollow noreferrer&quot;&gt;Applied Integer Programming: Modeling and Solution&lt;/a&gt;. John Wiley &amp;amp; Sons, 2009.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;MOSEK Modeling Cookbook&lt;/a&gt; How to formulate and reformulate conic optimization problems (convex QP, SOCP, SDP, Exponential Cone, Power Cone, and mixed integer). Requires some &amp;quot;mathematical maturity&amp;quot; to understand. This is very helpful for users of CVX, CVXPY, CVXR, YALMIP. Note, this is complementary to H.P. Williams &amp;quot;Model building in mathematical programming&amp;quot;, because Williams doesn't cover any conic optimization material.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Graph Theory and Algorithms:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;R. K. Ahuja, T. L. Magnanti, and J. B. Orlin. &lt;a href=&quot;http://mitmgmtfaculty.mit.edu/jorlin/network-flows/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Network flows&lt;/a&gt;, 1988.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Linear Programming:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;V. Chvátal. &lt;a href=&quot;https://www.amazon.com/s?k=9780716715870&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linear Programming&lt;/a&gt;. New York: W.H. Freeman, 1983.&lt;/p&gt;&#xA;&lt;p&gt;D. Bertsimas and J. N. Tsitsiklis. &lt;a href=&quot;http://www.athenasc.com/linoptbook.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Introduction to Linear Optimization&lt;/a&gt;, Athena Scientific, 1997.&lt;/p&gt;&#xA;&lt;p&gt;G.B. Dantzig. &lt;a href=&quot;https://press.princeton.edu/titles/413.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linear Programming and Extensions&lt;/a&gt;.Reprinted in 1998 by Princeton Press.&lt;/p&gt;&#xA;&lt;p&gt;G.B. Dantzig and M.N. Thapa &lt;a href=&quot;https://www.springer.com/gp/book/9780387948331&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linear Programming 1: Introduction&lt;/a&gt;, Springer, 1997 and&#xA;&lt;a href=&quot;https://www.springer.com/gp/book/9780387986135&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linear Programming 2: Theory and Extension&lt;/a&gt;, Spinger, 2003. Linear Programming 2, especially, is hard-core. I think these books supersede and render G.B. Dantzig &amp;quot;Linear Programming and Extensions&amp;quot; to be of historical interest only.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Integer Programming:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;D. Bertsimas and R. Weismantel. &lt;a href=&quot;https://www.dynamic-ideas.com/books/x0g7bsm2nvnl6j7ebqodcrhsvlgbm7&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimization over Integers&lt;/a&gt;. Belmont, MA: Dynamic Ideas, 2005.&lt;/p&gt;&#xA;&lt;p&gt;G. Desaulniers, J. Desrosiers, and M. M. Solomon. &lt;a href=&quot;https://www.springer.com/gp/book/9780387254852&quot; rel=&quot;nofollow noreferrer&quot;&gt;Column Generation&lt;/a&gt;. New York: Springer, 2005.&lt;/p&gt;&#xA;&lt;p&gt;G. Nemhauser, and L. Wolsey. &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/book/10.1002/9781118627372&quot; rel=&quot;nofollow noreferrer&quot;&gt;Integer and Combinatorial Optimization&lt;/a&gt;. Wiley, 1988.&lt;/p&gt;&#xA;&lt;p&gt;L. Wolsey. &lt;a href=&quot;https://www.wiley.com/en-us/Integer+Programming-p-9780471283669&quot; rel=&quot;nofollow noreferrer&quot;&gt;Integer programming&lt;/a&gt;, John Wiley &amp;amp; Sons Canada, 1998&lt;/p&gt;&#xA;&lt;p&gt;M. Conforti, G. Cornuéjols, G. Zambelli. &lt;a href=&quot;https://link.springer.com/book/10.1007%2F978-3-319-11008-0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Integer Programming&lt;/a&gt;, GTM 271, Springer, 2014.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Convex Optimization:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;S. Boyd and L. Vandenberghe &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Convex Optimization&lt;/a&gt;. Cambridge University Press, 2004 (freely downloadable at provided link). Also serves as good background for non-convex optimization.&lt;/p&gt;&#xA;&lt;p&gt;A. Ben-Tal, A. Nemirovski &lt;a href=&quot;https://www2.isye.gatech.edu/%7Enemirovs/Lect_ModConvOpt.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lectures on Modern Convex Optimization&lt;/a&gt;, 2013 (most recent version). Very advanced mathematically.&lt;/p&gt;&#xA;&lt;p&gt;N. Parikh and S. Boyd, &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/papers/pdf/prox_algs.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Proximal Algorithms&lt;/a&gt;, now Foundations and Trends in Optimization, 2013. &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/papers/prox_algs/errata.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Errata&lt;/a&gt;. Mostly algorithms, a few examples.&lt;/p&gt;&#xA;&lt;p&gt;J. Tropp, &lt;a href=&quot;https://arxiv.org/pdf/1501.01571.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;An Introduction to Matrix Concentration Inequalities&lt;/a&gt;, now Foundations and Trends in Optimization, 2014. Goes beyond Ben-Tal and Nemirovski in such areas as operator convexity and matrix (quantum) relative entropy.&lt;/p&gt;&#xA;&lt;p&gt;L. Vandenberghe and M. Andersen. &lt;a href=&quot;http://www.seas.ucla.edu/%7Evandenbe/publications/chordalsdp.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chordal Graphs and Semidefinite Optimization&lt;/a&gt;, now Foundations and Trends in Optimization, 2015. Advanced material in Semidefinite Optimization (Programming), i.e., SDP.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Nonlinear Optimization:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;J. Nocedal, S. Wright. &lt;a href=&quot;https://www.springer.com/gp/book/9780387303031&quot; rel=&quot;nofollow noreferrer&quot;&gt;Numerical Optimization&lt;/a&gt;. Springer, 2006.&lt;/p&gt;&#xA;&lt;p&gt;A. Beck. &lt;a href=&quot;https://epubs.siam.org/doi/book/10.1137/1.9781611973655?mobileUi=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Introduction to nonlinear optimization: Theory, algorithms, and applications with MATLAB.&lt;/a&gt; SIAM, 2014.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Geometric Programming&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;S. Boyd, Seung-Jean Kim, L. Vandenberghe, and A. Hassibi. &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/papers/pdf/gp_tutorial.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;A tutorial on geometric programming&lt;/a&gt;, Optimization and Engineering, 2007. A tutorial journal article covering geometric programming and generalizations and extensions, starting from basics and proceeding to more advanced material.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Combinatorial Optimization:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;A. Schrijver. &lt;a href=&quot;https://www.springer.com/gp/book/9783540443896&quot; rel=&quot;nofollow noreferrer&quot;&gt;Combinatorial Optimization - Polyhedra and Efficiency&lt;/a&gt;. Springer, 2003&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Stochastic Optimization:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;A.J. King, and S.W. Wallace. &lt;a href=&quot;https://link.springer.com/book/10.1007/978-0-387-87817-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Modeling with Stochastic Programming&lt;/a&gt;. Springer, 2012.&lt;/p&gt;&#xA;&lt;p&gt;J.R. Birge, and F. Louveaux. &lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4614-0237-4&quot; rel=&quot;nofollow noreferrer&quot;&gt;Introduction to stochastic programming&lt;/a&gt;. Springer Science &amp;amp; Business Media, 2011.&lt;/p&gt;&#xA;&lt;p&gt;A. Shapiro, D.Dentcheva, and A. Ruszczyński. &lt;a href=&quot;https://epubs.siam.org/doi/book/10.1137/1.9780898718751&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lectures on Stochastic Programming: Modeling and Theory&lt;/a&gt;. SIAM, 2009.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Robust Optimization:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;A. Ben-Tal, L. El Ghaoui, and A. Nemirovski. &lt;a href=&quot;https://press.princeton.edu/titles/9099.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Robust optimization&lt;/a&gt;. Princeton University Press, 2009.&lt;/p&gt;&#xA;&lt;p&gt;P. Kouvelis, and G. Yu. &lt;a href=&quot;https://www.springer.com/gp/book/9780792342915&quot; rel=&quot;nofollow noreferrer&quot;&gt;Robust Discrete Optimization and Its Applications&lt;/a&gt;. Springer, 1997.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Transportation Problems&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;G. Peyré, M. Cuturi, &lt;a href=&quot;https://arxiv.org/pdf/1803.00567.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Computational Optimal Transport&lt;/a&gt;, now Foundations and Trends in Machine Learning, 2019. Very advanced and theoretical. Shows how to formulate and calculate such things as Wasserstein distance as computational optimal transport problems. This is not an Intro to OR Transportation Problem book.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Vehicle Routing Problems&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Paolo Toth and Daniele Vigo &lt;a href=&quot;https://epubs.siam.org/doi/book/10.1137/1.9781611973594&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vehicle Routing: Problems, Methods, and Applications, Second Edition&lt;/a&gt; SIAM, 2014&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Metaheuristics&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Michel Gendreau and Jean-Yves Potvin. &lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4419-1665-5&quot; rel=&quot;nofollow noreferrer&quot;&gt;Handbook of Metaheuristics&lt;/a&gt; (2nd Ed.). Springer Publishing Company, 2010&lt;/p&gt;&#xA;" OwnerUserId="171" LastEditorUserId="3464" LastEditDate="2022-08-01T14:25:09.610" LastActivityDate="2022-08-01T14:25:09.610" CommentCount="7" CommunityOwnedDate="2019-07-03T07:28:37.973" ContentLicense="CC BY-SA 4.0" />
  <row Id="871" PostTypeId="1" CreationDate="2019-07-03T07:50:00.173" Score="9" ViewCount="303" Body="&lt;p&gt;I am trying to benchmark our vehicle routing solver against Gehring &amp;amp; Homberger instances. However, I got bit puzzled by the route duration constraint (maximum driving / maximum working time). In some data set format, this constraint is enforce as end time window of the depot (Option1): e.g. see &lt;a href=&quot;https://www.sintef.no/projectweb/top/vrptw/homberger-benchmark/documentation/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. However, in some other references, e.g. &lt;a href=&quot;https://www.researchgate.net/publication/230846314_A_hybrid_genetic_algorithm_with_adaptive_diversity_management_for_a_large_class_of_vehicle_routing_problems_with_time-windows&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vidal et. al 2013&lt;/a&gt;, this constraint is different: i.e. &#xA;&lt;a href=&quot;https://i.stack.imgur.com/mknrR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mknrR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;, which actually means arrivalTimeBackAtDepot - departureTimeFromDepot &amp;lt;= maxRouteDuration (Option2). Hence, an Option2 solution could be infeasible for Option1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anyone shed some light on this? How are the results compared and updated on &lt;a href=&quot;https://www.sintef.no/projectweb/top/vrptw/homberger-benchmark/documentation/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sintef&lt;/a&gt; webpage?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance. &lt;/p&gt;&#xA;" OwnerUserId="798" LastEditorUserId="798" LastEditDate="2019-07-04T11:13:27.617" LastActivityDate="2019-07-04T11:13:27.617" Title="Capacitated VRP-TW: Gehring &amp; Homberger instances" Tags="|benchmark|vehicle-routing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="872" PostTypeId="2" ParentId="841" CreationDate="2019-07-03T08:00:04.790" Score="3" Body="&lt;p&gt;For assembly line balancing problem, test problems, codes for several versions of problem and useful resources can be found at &lt;a href=&quot;https://assembly-line-balancing.de&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://assembly-line-balancing.de&lt;/a&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="432" LastActivityDate="2019-07-03T08:00:04.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="873" PostTypeId="1" CreationDate="2019-07-03T09:32:22.750" Score="8" ViewCount="359" Body="&lt;p&gt;The bound flipping ratio test (BFRT) appears to be an &lt;a href=&quot;https://or.stackexchange.com/questions/484/simplex-implementations-in-professional-solvers/490#490&quot;&gt;important feature&lt;/a&gt; of modern Simplex implementations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is it, and how does it work?&lt;/p&gt;&#xA;" OwnerUserId="47" LastActivityDate="2019-07-03T18:30:46.083" Title="What is the Bound Flipping Ratio test?" Tags="|linear-programming|simplex|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="874" PostTypeId="2" ParentId="555" CreationDate="2019-07-03T11:03:13.637" Score="2" Body="&lt;p&gt;Have a look at the &lt;a href=&quot;https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Floyd-Warshall algorithm&lt;/a&gt;. This classic shortest-path algorithm produces &lt;span class=&quot;math-container&quot;&gt;$n^2$&lt;/span&gt; min-constraints, each min-constraint over &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables and a constant &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, larger than the diameter of the graph. It calculates all shortest paths, between all nodes. You can then look at the distance of the two nodes you're interested in. If they belong to different, disconnected components, their distance will be &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the corresponding implementation in pseudo-code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i from 1 to |V|&#xA;    for j from 1 to |V|&#xA;        dist[i, j] = min(dist[i, k]+dist[k, j] for k=1..|V|, M)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some solvers support min-constraints directly, e.g. Gurobi does with &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/cs_grbmodel_addgenconstrmi.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;general min constraints&lt;/a&gt;. You can also linearize a min-constraint &lt;span class=&quot;math-container&quot;&gt;$y = \min_i(x_i)$&lt;/span&gt; manually, by introducing a couple of binary indicator variables &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA;x_i - M(1-z_i) \leq y \leq x_i \qquad \forall x_i \\&#xA;\sum z_i = 1 \\&#xA;z \in \{0,1\}^n&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="69" LastEditDate="2019-07-03T12:09:50.103" LastActivityDate="2019-07-03T12:09:50.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="875" PostTypeId="1" CreationDate="2019-07-03T11:04:29.797" Score="23" ViewCount="346" Body="&lt;p&gt;The maximum matching problem is solvable in polynomial time using Edmonds' blossom algorithm. However, unlike for example the spanning tree polytope, it has been proven fairly recently that the matching polytope has exponential extension complexity, meaning that it cannot be represented by a polynomially sized linear program &lt;a href=&quot;https://arxiv.org/pdf/1311.2369.pdf&quot; rel=&quot;noreferrer&quot;&gt;Rothvoss (2017)&lt;/a&gt;. I think this is a very interesting result, as it illustrates the limitations of expressing problems as linear programs. My question: are there any other problems that are solvable in polynomial time but whose polytopes have exponential extension complexity? &lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2019-08-25T18:02:58.497" Title="Polynomially solvable problems with exponential extension complexity" Tags="|linear-programming|computational-complexity|matching|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="876" PostTypeId="2" ParentId="871" CreationDate="2019-07-03T11:30:36.083" Score="4" Body="&lt;p&gt;You seem to be mixing up two related but different attributes: time windows and route duration. Duration is the time elapsed since the beginning of a route, and depends on the starting time as you mention. The time windows, on the other hand, are absolute and do not depend on the starting times of the routes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a classical VRPTW setting, only time windows are present. Route duration constraints are additional attributes commonly found in periodic or multitrip problems.&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2019-07-03T13:12:16.987" LastActivityDate="2019-07-03T13:12:16.987" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="877" PostTypeId="1" CreationDate="2019-07-03T11:39:26.400" Score="5" ViewCount="118" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Consider the primal problem &lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{ll} \text{minimize} &amp;amp; c^\top x\\ \text{subject to} &amp;amp; Ax = b\\ &amp;amp; x \geq 0\end{array}$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$ A \in \mathbb {R}^{ m × n}$&lt;/span&gt; has rank &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;. Suppose that, in a certain iteration of the dual-simplex method, relative to a dual-feasible base &lt;span class=&quot;math-container&quot;&gt;$A_B \in \mathbb {R}^{m × n}$&lt;/span&gt;, for some &lt;span class=&quot;math-container&quot;&gt;$ r \in\{1,. . . , m\}$&lt;/span&gt; happens &lt;span class=&quot;math-container&quot;&gt;$b_{r} &amp;lt;0 $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ a_{rs} \geq 0$&lt;/span&gt;  for every &lt;span class=&quot;math-container&quot;&gt;$ j = 1,..,n.$&lt;/span&gt; Determine a direction of&#xA;  recession of the dual that is from growth to dual function.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Bazaraa has a hint; he said to consider &lt;span class=&quot;math-container&quot;&gt;$w=c_B\cdot A^{-1}_B + B^r$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$B^r$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;th row of &lt;span class=&quot;math-container&quot;&gt;$A^{-1}_B$&lt;/span&gt;. But I can't see how this can be true. Anyway, I would like to prove that &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is in fact a recession ray; in other words, &lt;span class=&quot;math-container&quot;&gt;$Aw \leq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w\geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w \neq 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="800" LastEditorUserId="8" LastEditDate="2019-10-25T12:46:41.437" LastActivityDate="2019-10-25T12:46:41.437" Title="Construct a direction of recession of the dual that is from growth to dual function" Tags="|linear-programming|dual-simplex|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="878" PostTypeId="2" ParentId="555" CreationDate="2019-07-03T16:15:57.020" Score="3" Body="&lt;p&gt;Marco suggests using a flow-based mechanism to check whether you can send a unit of flow from source to sink (e.g. set all edge costs to one, set a supply of 1 at one node, a demand of 1 at the other, set all edge capacities to 1 and run a maxflow. If the problem is feasible, you have edge connectivity). By the &lt;a href=&quot;https://en.wikipedia.org/wiki/Max-flow_min-cut_theorem&quot; rel=&quot;nofollow noreferrer&quot;&gt;max-flow min-cut duality&lt;/a&gt;, you could do the same thing using cuts, but you'll pay a price in terms of how many constraints you need. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a suggestion - it may not be correct or complete, as I don't have time to think it through properly. For your graph &lt;span class=&quot;math-container&quot;&gt;$G=\{N,E\}$&lt;/span&gt;, partition your node set &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; into two parts &lt;span class=&quot;math-container&quot;&gt;$\{T, N \setminus T\}, T\subset N$&lt;/span&gt; that separate your node pair &lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt;. Define a binary decision variable &lt;span class=&quot;math-container&quot;&gt;$u_{ij}=1$&lt;/span&gt; if edge &lt;span class=&quot;math-container&quot;&gt;$\{i,j\}$&lt;/span&gt; is in your solution. Define another decision variable &lt;span class=&quot;math-container&quot;&gt;$z_{ij}=1$&lt;/span&gt; if node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is connected to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and 0 otherwise (this is your original request). Consider the constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{\{k,l\} \in \{T, N \setminus T\}}u_{kl} \ge z_{ij}, \forall \, \text{cutsets} \,T, \forall \, \{i,j\} \in \{T, N \setminus T\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;think&lt;/em&gt; this does what you want. The LHS says that if there's a way &quot;across&quot; from &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; to the other side and reach your desired node, at least one of the &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;'s will be one so the RHS can grow from 0 to 1 and properly indicate that you have connectivity. The last ingredient is setting up the objective function by adding something like &lt;span class=&quot;math-container&quot;&gt;$\sum_{\{i,j\} \in E} z_{ij}$&lt;/span&gt; with the appropriate sign in front, depending on your overall objective, in order to encourage the &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;'s to be 1. Just remember that the number of cutsets &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; grows exponentially with the cardinality of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; (so, something like cutting planes may be needed as well).&lt;/p&gt;&#xA;" OwnerUserId="253" LastActivityDate="2019-07-03T16:15:57.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="879" PostTypeId="2" ParentId="873" CreationDate="2019-07-03T18:30:46.083" Score="5" Body="&lt;p&gt;When taking a step in the dual simplex method, if a dual variable is zeroed, the dual objective may continue to improve if the variable passes through zero. To maintain dual feasibility, the variable must be associated with a primal variable with finite lower and upper bounds. As the dual variable passes through zero, the corresponding primal variable [which is necessarily nonbasic] &quot;flips&quot; from one bound to the other. This process changes the gradient of the dual objective, making it less attractive to make a further change in the dual variable. Thus, eventually, the ratio test will terminate (unless the LP is dual unbounded). &lt;/p&gt;&#xA;" OwnerUserId="228" LastActivityDate="2019-07-03T18:30:46.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="880" PostTypeId="2" ParentId="179" CreationDate="2019-07-03T20:41:06.703" Score="5" Body="&lt;p&gt;Pantelis,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a great detriment that no such collection of examples exists. One problem is that there is no established format for multistage problems like &lt;a href=&quot;https://en.wikipedia.org/wiki/MPS_(format)&quot; rel=&quot;nofollow noreferrer&quot;&gt;MPS&lt;/a&gt;. (There is &lt;a href=&quot;https://www.lindo.com/doc/online_help/lingo17_0/smps.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;SMPS&lt;/a&gt; [&lt;a href=&quot;http://www.maximalsoftware.com/resources/GassmannKristjansson_dpm007v1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt;], but this doesn't scale to the types of problems we typically solve with &lt;span class=&quot;math-container&quot;&gt;$10^{40}$&lt;/span&gt; leaf nodes in a scenario tree.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been collecting a number of &lt;a href=&quot;https://github.com/odow/SDDP.jl/tree/master/examples&quot; rel=&quot;nofollow noreferrer&quot;&gt;examples in the SDDP.jl library&lt;/a&gt;. These are mostly small, but there are some large-scale problems such as a &lt;a href=&quot;https://github.com/odow/SDDP.jl/blob/master/examples/msppy_hydro_thermal.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;simplified model of the Brazilian electricity system&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;a href=&quot;https://github.com/odow/MilkPOWDER&quot; rel=&quot;nofollow noreferrer&quot;&gt;this medium-sized example from pastoral agriculture&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The python package &lt;a href=&quot;https://github.com/lingquant/msppy&quot; rel=&quot;nofollow noreferrer&quot;&gt;msppy&lt;/a&gt; has some &lt;a href=&quot;https://github.com/lingquant/msppy/tree/master/examples&quot; rel=&quot;nofollow noreferrer&quot;&gt;other examples&lt;/a&gt;, but these are mainly focused on binary problems.&lt;/p&gt;&#xA;" OwnerUserId="805" LastEditorUserId="805" LastEditDate="2019-07-05T13:46:17.087" LastActivityDate="2019-07-05T13:46:17.087" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="881" PostTypeId="1" AcceptedAnswerId="885" CreationDate="2019-07-03T22:29:25.127" Score="10" ViewCount="3895" Body="&lt;p&gt;Note: See the EDIT below for one possible solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I apologize if this is not appropriate but I don't really have anywhere else to turn. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was hoping that someone would be able to post how they would install CPLEX with the Python API. I have tried calling IBM, looking at documentation, YouTube videos, and trying to find examples. Unfortunately, I have had no luck and am unable to install it properly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anybody has a simple guide, tutorial, steps, whatever, i'm sure that this would be super helpful to many people down the road. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I have followed the instructions &lt;a href=&quot;https://github.com/IBMPredictiveAnalytics/Simple_Linear_Programming_with_CPLEX/blob/master/cplex_instruction.md&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and I have installed the CPLEX Optimizer Studio, but when I run &quot;python setup.py install&quot; I get the following: &lt;a href=&quot;https://i.stack.imgur.com/6CK6P.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6CK6P.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;I then tried to set the PYTHONPATH, and that had no impact on my results. My objective is to run the code at the bottom of the link provided above which suggests that the installation would be correct. However, I am unable to run the code completely because I can only get part way until it crashes: &#xA;&lt;a href=&quot;https://i.stack.imgur.com/ZSx5W.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZSx5W.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: The entire issue here is that I was running Python 3.7 instead of Python 3.6. Python 3.7 is not available in 64-bit (only 32-bit), but this was overlooked entirely when I first installed Python to begin learning the language. For anybody who finds this and is interested in getting CPLEX up and running, these are the steps I have followed: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Ensure that you are running Python 3.6.x 64-bit. CPLEX will not work on a 32-bit and Python 3.7 is not set up for 64-bit as of yet. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run pip install cplex&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run pip install docplex &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Figure out how to set your &quot;Environment Variable&quot; and create it as PYTHONPATH and then specify the file path for the environment variable in a similar fashion like this: C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\python\3.6\x64_win64&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The only downside to this is that each time you want to run CPLEX you need to specify this environment variable it seems, and I am not sure if this will end up causing headaches down the road or not. Unfortunately I was unable to successfully run the script.py, but I found this to work as well. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;" OwnerUserId="547" LastEditorUserId="123" LastEditDate="2019-10-21T18:26:37.347" LastActivityDate="2019-10-21T18:26:37.347" Title="Python API and CPLEX" Tags="|cplex|python|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="882" PostTypeId="2" ParentId="881" CreationDate="2019-07-04T01:38:15.480" Score="2" Body="&lt;p&gt;Have you tried &lt;a href=&quot;https://pypi.org/project/cplex/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The CPLEX Python API is a Python package named cplex that allows the Callable Library to be accessed from the Python programming language. It is equally suitable for interactive use through the Python interpreter or for writing scripts or full-fledged applications.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-07-04T01:38:15.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="883" PostTypeId="1" AcceptedAnswerId="917" CreationDate="2019-07-04T04:09:17.777" Score="11" ViewCount="910" Body="&lt;p&gt;I am solving a nonlinear optimization problem using &lt;a href=&quot;http://www.pyomo.org/&quot; rel=&quot;noreferrer&quot;&gt;Pyomo&lt;/a&gt; with Ipopt as solver. The solver exits with the status:&lt;br&gt;&#xA;&lt;code&gt;EXIT: Optimal Solution Found.&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This I can cross check by testing:&lt;code&gt;results.solver.termination_condition == TerminationCondition.optimal&lt;/code&gt;, which returns True. I was now curious to check, whether the solution is globally or locally optimal. However, for both of the statements below, I get a False return.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;results.solver.termination_condition == TerminationCondition.globallyOptimal&lt;/code&gt;&#xA; &lt;code&gt;results.solver.termination_condition == TerminationCondition.locallyOptimal&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand, why is it False for both of these statements. Would anyone having previous experience with Pyomo help me out ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bit of background information on accessing solver status and termination conditions in Pyomo can be found &lt;a href=&quot;http://www.pyomo.org/blog/2015/1/8/accessing-solver&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2020-06-06T14:04:26.800" Title="Termination Criteria of Solver in Pyomo" Tags="|nonlinear-programming|python|pyomo|global-optimality|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="884" PostTypeId="1" AcceptedAnswerId="898" CreationDate="2019-07-04T07:24:59.323" Score="10" ViewCount="403" Body="&lt;p&gt;The prize collecting shortest path problem (PCSPP) is a special case of the prize collecting Steiner tree problem (PCSTP) (PCSPP is the PCSTP with only two &lt;em&gt;terminal vertices&lt;/em&gt;, namely the source and sink nodes of the PCSPP). I am aware of quite some work on the PCSTP (by Ivana Ljubic amongst others) but I have never seen specialized algorithms for the PCSPP. Do such algorithms exist?&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="87" LastEditDate="2019-07-05T12:31:50.410" LastActivityDate="2019-07-05T13:17:08.530" Title="Does the &quot;prize-collecting shortest path problem&quot; exist?" Tags="|reference-request|algorithms|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="885" PostTypeId="2" ParentId="881" CreationDate="2019-07-04T07:42:50.250" Score="9" Body="&lt;p&gt;It seems there are multiple problems, here...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Python will not automatically find the script &lt;code&gt;setup.py&lt;/code&gt;. You need to either specify the path to that script, or be in the directory where that script exists.  Assuming that you installed CPLEX Optimization Studio in the default location, the following would work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python &quot;c:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\python\setup.py&quot; install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note also that you are using a 32-bit Python environment.  And as the warning in the second screenshot tells you, this is not supported.  If you have a 32-bit Windows version, CPLEX will definitely not work: it needs a 64 bit operating system.&lt;/p&gt;&#xA;" OwnerUserId="295" LastActivityDate="2019-07-04T07:42:50.250" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="886" PostTypeId="1" CreationDate="2019-07-04T08:50:23.987" Score="12" ViewCount="166" Body="&lt;p&gt;I have a simple blending problem, where each final product is a blend or mixture of several raw materials, and want to calculate the price per unit of weight for each of the products. So for a given product, the price &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; per unit weight is given by:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;P = \frac{p_1 x_1 + p_2 x_2 + \dots + p_n x_n}{x_1 + x_2 + \dots+ x_n}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are the weights of each of the constituent raw materials (the decision variables), and the &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; are the prices per unit weight of the raw materials (constants in each time period).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other constraints on the proportions of each raw material that can be present in the final product, but these are typically quite wide ranges and are not difficult to achieve, so are not directly relevant here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is also a multi-time period problem. The raw material availabilities and prices vary from one week to the next, and the amount of each product required each week also varies. The blend of the raw materials in the product is allowed to vary from one week to the next.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An important constraint in the overall problem is that the price per unit weight of the product must not differ by more than a small amount (maybe 5 - 10%) from one week to the next, so if we have the final product unit prices for each week as &lt;span class=&quot;math-container&quot;&gt;$P_1, P_2, \dots, P_m$&lt;/span&gt; then we need constraints like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;0.9 P_{i-1} \le P_i \le 1.1 P_{i-1}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so that the unit price of the product cannot change more than 10% from one week to the next. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using a MILP solver for this problem, and this is giving me an issue because this expression for the price of the final product involves the division of one expression by another, where both the numerator and denominator contain decision variables. I cannot yet see how I can reformulate this model to linearise it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So does anyone have a way to restructure or reformulate this problem model so that I can model the final product unit prices and limit the variability of the final product prices from one week to the next in a multi-period problem using MILP?&lt;/p&gt;&#xA;" OwnerUserId="310" LastEditorUserId="47" LastEditDate="2019-07-04T19:33:20.747" LastActivityDate="2019-07-05T08:40:24.213" Title="Pricing of blends/mixtures across multiple timesteps" Tags="|mixed-integer-programming|linear-programming|modeling|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="887" PostTypeId="2" ParentId="758" CreationDate="2019-07-04T14:28:25.100" Score="5" Body="&lt;p&gt;Unless you use the ellipsoid method, it is very difficult to find a bound on the number of constraints that need to be generated. &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-018-1302-4&quot; rel=&quot;noreferrer&quot;&gt;A recent review paper&lt;/a&gt; on cutting planes mentions only a single paper that develops a polynomial cutting plane algorithm, namely &lt;a href=&quot;https://doi.org/10.1287/moor.2015.0714&quot; rel=&quot;noreferrer&quot;&gt;Chandrasekaran, Végh and Vempala (2016)&lt;/a&gt;, who propose a tailored cutting plane approach for the minimum-cost perfect matching problem and prove it converges in polynomial time. Both the algorithm and the proof are rather involved and cannot easily be extended to other problems. Hence, I am afraid there is not much more you can do than wait until your separation oracle indicates the solution is feasible. &lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2019-07-04T14:28:25.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="888" PostTypeId="2" ParentId="886" CreationDate="2019-07-04T21:01:42.563" Score="6" Body="&lt;p&gt;I don't think a MILP is in the cards. Here's one formulation that at least might be (somewhat) solvable. In the formulation, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; indexes a product, &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; indexes a raw material and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; indexes a time period. Parameters are the cost of a material (&lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt;), the penalty for each unit shortfall in production of a product (&lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;), and the demand for each product (&lt;span class=&quot;math-container&quot;&gt;$D_{it}$&lt;/span&gt;). Variables are the fraction of a product that comes from a raw material in a given period (&lt;span class=&quot;math-container&quot;&gt;$r_{ijt}$&lt;/span&gt;), the quantity of a product made in a period (&lt;span class=&quot;math-container&quot;&gt;$q_{it}$&lt;/span&gt;), the shortfall of a product in a period (&lt;span class=&quot;math-container&quot;&gt;$s_{it}$&lt;/span&gt;), and the unit cost of the output of a product in a period (&lt;span class=&quot;math-container&quot;&gt;$P_{it}$&lt;/span&gt;). I'm assuming that inventory carryover is not allowed, but if it is, inventory terms are easy to add.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All variables are nonnegative. The first constraint is &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j}r_{ijt}=1\,\forall i,t,$$&lt;/span&gt; which enforces the fact that the &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; variables are mixture proportions. Next, &lt;span class=&quot;math-container&quot;&gt;$$q_{it} + s_{it}=D_{it}\,\forall i,t$$&lt;/span&gt; defines shortfalls. &lt;span class=&quot;math-container&quot;&gt;$$P_{it} = \sum_{j} p_j r_{ijt}\,\forall i,t$$&lt;/span&gt; defines the unit production costs for the outputs. Finally, &lt;span class=&quot;math-container&quot;&gt;$$0.9P_{i,t-1}\le P_{i,t}\le 1.1P_{i,t-1}\,\forall i,\forall t&amp;gt;1$$&lt;/span&gt; is your limitation on product variability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far everything is linear. Where we get in trouble is the objective function:&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_t\sum_i (P_{it} q_{it} + c_i s_{it}).$$&lt;/span&gt; The objective function is not convex (nor concave), so you cannot just hit it with any old MILP solver. I believe that CPLEX (and perhaps Gurobi?) can solve problems like this one. There are special purpose solvers for nonconvex problems (although I'm not familiar with any). You can also try approximating the quadratic portion with piecewise linear functions (which will give you an approximate solution).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-07-04T21:01:42.563" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="889" PostTypeId="1" AcceptedAnswerId="896" CreationDate="2019-07-04T21:33:05.590" Score="25" ViewCount="1831" Body="&lt;p&gt;Can someone give me a few examples, if they exist, of problems in operations research that could be solved using machine learning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware that machine learning examples are data-driven and do not give exact solutions, so I am expecting heuristics, and possibly solutions that are specific for a particular instance of the problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for 'direct' machine learning solutions that use machine learning to find a solution of the actual problem, and not just 'indirect' approaches that try to improve existing methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;I am looking for examples in which the ML approach outperforms other methods.&lt;/p&gt;&#xA;" OwnerUserId="811" LastEditorUserId="811" LastEditDate="2019-07-04T22:21:18.297" LastActivityDate="2019-08-23T07:57:07.880" Title="Examples of machine learning applied to operations research?" Tags="|modeling|machine-learning|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="890" PostTypeId="2" ParentId="889" CreationDate="2019-07-04T21:53:34.047" Score="6" Body="&lt;p&gt;Using OR in ML is a very popular approach due to the optimization nature lying behind ML.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as you ask, there are also many examples (younger, newer) where you apply ML to solve OR problems. For example, for routing problems: &lt;a href=&quot;https://arxiv.org/pdf/1803.08475.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://arxiv.org/pdf/1803.08475.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The list can be appended, but I think your question needs to be improved before.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2019-07-04T21:53:34.047" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="891" PostTypeId="2" ParentId="889" CreationDate="2019-07-05T05:39:39.270" Score="4" Body="&lt;p&gt;There is a paper &lt;a href=&quot;http://auai.org/uai2018/proceedings/papers/217.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learning Fast Optimizers for Contextual Stochastic Integer Programs&lt;/a&gt; where they develop a &quot;learnable local solver&quot; to solve problems where the MIP solvers did not scale.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not studied the paper, yet, but it may fit your bill.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: From the abstract/introduction: The problems are two-stage stochastic optimization, where the learned local solver is applied to the first stage, after which the (deterministic) second stage is handed to a MIP solver. This performs better than handing the overall problem to a MIP solver (better objective within same time limit).&lt;/p&gt;&#xA;" OwnerUserId="126" LastEditorUserId="126" LastEditDate="2019-07-09T08:01:16.297" LastActivityDate="2019-07-09T08:01:16.297" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="892" PostTypeId="1" CreationDate="2019-07-05T06:14:21.830" Score="19" ViewCount="4419" Body="&lt;p&gt;I am looking for a reliable open source solver to solve LP and MILP (with a few thousand variables). How can I evaluate the performance of a given solver for a particular use case?&lt;/p&gt;&#xA;" OwnerUserId="789" LastEditorUserId="38" LastEditDate="2019-07-08T02:14:56.383" LastActivityDate="2022-02-16T09:23:59.723" Title="How to evaluate the performance of open source solver?" Tags="|mixed-integer-programming|linear-programming|solver|open-source|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="893" PostTypeId="2" ParentId="892" CreationDate="2019-07-05T07:20:45.773" Score="16" Body="&lt;p&gt;For the evaluation of several solvers you need &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;several solvers&lt;/li&gt;&#xA;&lt;li&gt;a testset of instances&lt;/li&gt;&#xA;&lt;li&gt;a performance measure&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Several solvers you probably already have in mind. The testset of instances is a bit tricky, because ideally, this is a not too small, not too large, not trivial, not too hard, still representative set of instances (that is, LPs or MIPs) that you will later see when solving actual instances. There are several ideas how to choose such a testset, I think the &lt;a href=&quot;http://mpc.zib.de/index.php/MPC/article/viewFile/56/28&quot; rel=&quot;noreferrer&quot;&gt;MIPLIB2010 paper&lt;/a&gt; is still a very good reference for this. Then you run your solvers on the testset, gather the results, and plot them in a way that you can interpret them. For performance (mainly: runtime to optimality, or runtime to a &quot;good&quot; solution) I would use &lt;em&gt;performance profiles&lt;/em&gt; as described by &lt;a href=&quot;https://link.springer.com/article/10.1007/s101070100263&quot; rel=&quot;noreferrer&quot;&gt;Dolan and More&lt;/a&gt;. They are kind of an &lt;em&gt;industry standard&lt;/em&gt; in the optimization community.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-07-05T07:20:45.773" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="894" PostTypeId="2" ParentId="892" CreationDate="2019-07-05T07:21:28.300" Score="7" Body="&lt;p&gt;Meindl and Templ published the paper &lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.455.3926&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;noreferrer&quot;&gt;Analysis of commercial and free and open source&#xA;solvers for linear optimization problems&lt;/a&gt; in 2012 in which they investigate the running times and solving percentages of various solvers. The main table is replicated below. &lt;span class=&quot;math-container&quot;&gt;\begin{array}{cr}\hline\sf{solver}&amp;amp;\sf{running\,time}&amp;amp;\sf{instances\,solved}&amp;amp;\sf{solved}\,(\%)\\\hline\sf CBC&amp;amp;10.20&amp;amp;41&amp;amp;47.13\\\sf{CPLEX}&amp;amp;1.45&amp;amp;73&amp;amp;83.91\\\sf{GLPK}&amp;amp;22.11&amp;amp;3&amp;amp;3.45\\\sf{GUROBI}&amp;amp;1.00&amp;amp;77&amp;amp;88.51\\\sf{LP\text{_}SOLVE}&amp;amp;19.40&amp;amp;5&amp;amp;5.75\\\sf{SCIP\,\text{-}\,C}&amp;amp;3.76&amp;amp;63&amp;amp;72.41\\\sf{SCIP\,\text{-}\,L}&amp;amp;6.40&amp;amp;52&amp;amp;59.77\\\sf{SCIP\,\text{-}\,S}&amp;amp;5.33&amp;amp;57&amp;amp;65.52\\\sf{XPRESS}&amp;amp;1.29&amp;amp;74&amp;amp;85.06\\\hline\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The following data are based on data from the 9th of January of 2012. The following solvers have been used in the test on PC with an Intel Xeon X5680 processor with 2 x 6 cores, 32 gigabytes of RAM on a Linux 64-bit operating system. A total of 9 different solvers were compared using a single thread.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can thus try to replicate some of the analysis used in the paper where possible.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Meindl, B., Templ, M. (2012). Analysis of commercial and free and open source&#xA;solvers for linear optimization problems. Technische Universität Vienna, Austria. Available from &lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.455.3926&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;noreferrer&quot;&gt;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.455.3926&amp;amp;rep=rep1&amp;amp;type=pdf&lt;/a&gt;. [Accessed 5 July 2019].&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-07-05T07:21:28.300" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="895" PostTypeId="2" ParentId="892" CreationDate="2019-07-05T07:24:02.923" Score="20" Body="&lt;p&gt;The pitfall is to only focus on performance, will ignoring scalability, maintenance, integration and reliability. Some of these are easier to measure than others:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Performance&lt;/strong&gt;: if I give 2 constraint solvers a - for example a VRP - dataset with 100 visits, which one is better after 5 minutes. See Marco's answer on this question and &lt;a href=&quot;https://www.optaplanner.org/blog/2014/11/07/OpenBenchmarksForTheWin.html&quot; rel=&quot;noreferrer&quot;&gt;my blog post on benchmarking&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Scalability&lt;/strong&gt;: if I give a constraint solver 3 VRP datasets, one with 100 visits, one with 1000 and one with 10 000 visits, for 5 minutes each. How does it scale up? Don't just focus on solution quality, also look at memory consumption.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Maintenance&lt;/strong&gt;: How easy is it to write a constraint? How easy is it to hire juniors and train them to write constraints? Most business constraints change often. Some even completely pivot their business problem.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Integration&lt;/strong&gt;: How easy does it integrate with other Java/C++/Python/Kotlin/Scala/... libraries. Can you reuse an existing date &amp;amp; time API (just &lt;a href=&quot;https://www.youtube.com/watch?v=-5wpm-gesOY&quot; rel=&quot;noreferrer&quot;&gt;watch this video why you too will fail at writing your own&lt;/a&gt;)? Is available in the library repository (Maven Central / Ruby Gems / Nuget / ...)?&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Reliability&lt;/strong&gt;: Does it fail-fast (or pretend nothing is wrong when things go very wrong)? Does it eat exceptions? Does &lt;em&gt;debug&lt;/em&gt; or even &lt;em&gt;trace&lt;/em&gt; logging show you what's going on inside the black box?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And that's just the tip of the iceberg. &lt;a href=&quot;https://ge0ffrey.github.io/ge0ffrey-presentations/usingAndContributingToOpenSource/#/19&quot; rel=&quot;noreferrer&quot;&gt;See also my slides&lt;/a&gt; on &lt;em&gt;What makes an open source project mature?&lt;/em&gt; which covers fun topics such as which licenses are open source ok to build your proprietary business on and which are not.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2019-07-05T12:36:51.637" LastActivityDate="2019-07-05T12:36:51.637" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="896" PostTypeId="2" ParentId="889" CreationDate="2019-07-05T08:32:15.853" Score="16" Body="&lt;p&gt;There are many recent and not so recent papers that use ML to &quot;solve&quot; optimization problems, like &lt;a href=&quot;https://arxiv.org/abs/1704.01665&quot; rel=&quot;noreferrer&quot;&gt;Learning Combinatorial Optimization Algorithms over Graphs&lt;/a&gt;. A very, very good entry to the subject is the survey &lt;a href=&quot;https://arxiv.org/abs/1811.06128&quot; rel=&quot;noreferrer&quot;&gt;Machine Learning for Combinatorial Optimization: a Methodological Tour d'Horizon&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your last sentence you probably ask too much. For optimization problems, there are basically two kinds of approaches, exact and heuristic. For all optimization problems you can think of, both approaches have been suggested. Of course (&lt;strong&gt;of course!&lt;/strong&gt;) no algorithm can beat an exact approach, at least not in terms of solution quality as these - by definition - find the best possible solutions. This is not the case for heuristics, which can be of better or worse quality (but maybe beat the exact methods in terms of runtime, so there is a tradeoff). Therefore, when you ask for ML approaches to beat optimization algorithms, these can beat, at best, other heuristics. And again: An ML approach is (almost always) a heuristic approach, and I would add &quot;yet another heuristic approach&quot;. You cannot expect them to beat existing heuristics, but you can be lucky, which is true for any other heuristic. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;edit:&lt;/em&gt; re-reading your question I conclude that I could not really contribute to an answer.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="354" LastEditDate="2019-07-05T08:49:50.677" LastActivityDate="2019-07-05T08:49:50.677" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="897" PostTypeId="2" ParentId="886" CreationDate="2019-07-05T08:40:24.213" Score="5" Body="&lt;p&gt;You can introduce a continuous variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$$\frac{p_1 x_1 + p_2 x_2 + \dots + p_n x_n}{x_1 + x_2 + \dots+ x_n} = y.$$&lt;/span&gt;&#xA;Multiplying by the denominator gives &lt;span class=&quot;math-container&quot;&gt;$$p_1 x_1 + p_2 x_2 + \dots + p_n x_n = x_1y + x_2y + \dots+ x_ny.$$&lt;/span&gt;&#xA;This turns your problem into a non-convex (MI)QCQP (&lt;a href=&quot;https://or.stackexchange.com/a/866/145&quot;&gt;abbreviation list&lt;/a&gt;), depending on whether you have integer variables or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Manual reformulation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on you problem, you may be able to linearize the quadratic constraints. If the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are binary, you can linearize the product &lt;span class=&quot;math-container&quot;&gt;$x_i y$&lt;/span&gt; as explained on &lt;a href=&quot;https://or.stackexchange.com/questions/39/how-to-linearize-the-product-of-a-binary-and-a-non-negative-continuous-variable&quot;&gt;StackExchange&lt;/a&gt; and on &lt;a href=&quot;https://orinanobworld.blogspot.com/2010/10/binary-variables-and-quadratic-terms.html&quot; rel=&quot;noreferrer&quot;&gt;OR in an OB World&lt;/a&gt; in more detail. &lt;a href=&quot;https://orinanobworld.blogspot.com/2013/07/integer-variables-and-quadratic-terms.html&quot; rel=&quot;noreferrer&quot;&gt;Something similar&lt;/a&gt; can be done when the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are integer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are not integer, you can make your own discretization to obtain an approximation of the optimal solution. For example, if you only allow prices &lt;span class=&quot;math-container&quot;&gt;$P \in \{0, 0.1, 0.2, \dots, 1\}$&lt;/span&gt;, you may add the variable &lt;span class=&quot;math-container&quot;&gt;$z \in \{0,1,2,\dots,10\}$&lt;/span&gt; and substitute &lt;span class=&quot;math-container&quot;&gt;$y = 0.1z$&lt;/span&gt;. Then, you can linearize the product &lt;span class=&quot;math-container&quot;&gt;$(x_1 + x_2 + \dots+ x_n) z$&lt;/span&gt; as above, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Software&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of reformulating yourself and using a MILP solver, there may be software to help you.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As mentioned by prubin, CPLEX &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.3/ilog.odms.studio.help/CPLEX/ReleaseNotes/topics/releasenotes126/newNonconvexMIQP.html&quot; rel=&quot;noreferrer&quot;&gt;can solve non-convex quadratic&#xA;programs&lt;/a&gt;, but only if the constraints are linear (i.e., MIQP instead of MIQCQP). Hence, if you&#xA;are able to put all quadratic terms in the objective, you can use&#xA;CPLEX.&lt;/li&gt;&#xA;&lt;li&gt;Gurobi does not seem to support non-convex problems at this time. If I recall correctly, they are planning to add support for MIQCQP in version 9.0. &lt;a href=&quot;https://www.gurobi.com/event/2019-euro-conference/&quot; rel=&quot;noreferrer&quot;&gt;This conference talk&lt;/a&gt; at least seems to hint in this direction.&lt;/li&gt;&#xA;&lt;li&gt;Global optimization software exists, but I am less familiar with it. It seems that &lt;a href=&quot;http://archimedes.cheme.cmu.edu/?q=baron&quot; rel=&quot;noreferrer&quot;&gt;BARON&lt;/a&gt; might be able to solve your problem.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Create your own method&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also create your own algorithm. The &lt;a href=&quot;http://www.orsj.or.jp/ramp/2014/paper/4-3.pdf&quot; rel=&quot;noreferrer&quot;&gt;following paper&lt;/a&gt; explains how CPLEX deals with non-convex quadratic objectives. This might not be sufficient for your problem, but the ideas may be useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bliek, C., Bonami, P., &amp;amp; Lodi, A. (2014, October). Solving mixed-integer quadratic programming problems with IBM-CPLEX: a progress report. In Proceedings of the twenty-sixth RAMP symposium.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-07-05T08:40:24.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="898" PostTypeId="2" ParentId="884" CreationDate="2019-07-05T12:29:31.597" Score="7" Body="&lt;p&gt;You can make the graph directed, push the prizes into the arcs and solve a shortest path problem with negative lengths (i.e. for an undirected graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; with distances &lt;span class=&quot;math-container&quot;&gt;$d_e\geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$e\in E$&lt;/span&gt; and prizes &lt;span class=&quot;math-container&quot;&gt;$p_v\geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$v\in V$&lt;/span&gt;, construct a directed graph &lt;span class=&quot;math-container&quot;&gt;$G'=(V,A)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is obtained by replacing each edge &lt;span class=&quot;math-container&quot;&gt;$e=\{u,v\}\in E$&lt;/span&gt; of length &lt;span class=&quot;math-container&quot;&gt;$d_e$&lt;/span&gt; by two arcs &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt; of length &lt;span class=&quot;math-container&quot;&gt;$d_e-p_v$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(v,u)$&lt;/span&gt; of length &lt;span class=&quot;math-container&quot;&gt;$d_e-p_u$&lt;/span&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So as a partial answer, specialized algorithms for the (general) SPP apply. &lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2019-07-05T12:29:31.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="899" PostTypeId="2" ParentId="884" CreationDate="2019-07-05T12:50:30.823" Score="6" Body="&lt;p&gt;I think there is some work on this, for the context of vehicle routing problem solvers using branch and price. The subproblem (or pricing) becomes an price collecting path problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good starting point for references for that might be Chapter 3.5 of &quot;Vehicle Routing: Problems, Methods, and Applications&quot; by Paolo Toth and Danielle Vigo.&lt;/p&gt;&#xA;" OwnerUserId="405" LastActivityDate="2019-07-05T12:50:30.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="900" PostTypeId="2" ParentId="884" CreationDate="2019-07-05T13:17:08.530" Score="6" Body="&lt;p&gt;As others already said, the PCSPP described resorts to a simple SPP with potentially negative costs. It would still be solvable in poly time if no cycles of negative weight are present. Otherwise, you could impose elementary constraints and solve it as an elementary shortest path problem which, however, is NP-hard, and for which several algorithms exist already (B&amp;amp;C or Dyn Prog most notably).&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2019-07-05T13:17:08.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="901" PostTypeId="2" ParentId="892" CreationDate="2019-07-05T17:29:08.557" Score="10" Body="&lt;p&gt;If you're just trying to &amp;quot;evaluate performance&amp;quot; to decide what to use, then avoid LP_SOLVE and GLPK (and the results above are also indicative of their LP performance) and the solution time for LPs (and MIPs, so long as they aren't really nasty) won't be an issue. I suggest Clp/HiGHS for LP and HiGHS/SCIP for MIP.&lt;/p&gt;&#xA;" OwnerUserId="228" LastEditorUserId="228" LastEditDate="2022-02-16T09:23:59.723" LastActivityDate="2022-02-16T09:23:59.723" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="902" PostTypeId="2" ParentId="632" CreationDate="2019-07-05T22:55:39.870" Score="7" Body="&lt;p&gt;Can you elaborate a bit on what you mean when you say you are getting &quot;Strange values&quot;? One possible explanation is that if you call &lt;code&gt;getDuals()&lt;/code&gt; on a model that includes some variables bounds other than &lt;span class=&quot;math-container&quot;&gt;$[0, +\infty)$&lt;/span&gt;, then your dual unbounded ray requires that you look at the reduced costs as well as the the dual variables returned by &lt;code&gt;getDuals()&lt;/code&gt;. However, based on your comment that you didn't encounter this behavior with Gurobi, this seems somewhat less likely to explain this (unless you formulated the subproblem in Gurobi in a way that has such nondefault bounds, but your CPLEX subproblem uses just the default ones). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the other questions, when the primal simplex method has determined your problem is infeasible, &lt;code&gt;getDuals()&lt;/code&gt; will return the dual variable values associated with the phase I objective from which infeasibility was determined.   In the case where all variables have bounds of &lt;span class=&quot;math-container&quot;&gt;$[0,+\infty)$&lt;/span&gt;, this comprises the unbounded ray for the dual. That is also true if some of the primal variables are free variables.   But if they have finite bounds, you also need to look at the reduced costs to properly construct the direction of unboundedness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the order in which &lt;code&gt;dualFarkas()&lt;/code&gt; the object oriented APIs returns dual variables, that depends completely on the order on which you pass the constraints in the first argument to this method.   So look at the order in which the constraints were added when you built the model. If you built the model using a single IloRangeArray, then that gives you the order you seek.   But, if you used multiple IloRangeArrays, or build it with individual statements where you didn't record a handle to point to some of the ranges being added (e.g. &lt;code&gt;call model.add(x + y &amp;lt;= 2)&lt;/code&gt;), then you probably should maintain an IloRangeArray of handles to the individual linear constraints you created for the model, in the order you added them to the model.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally, regarding the experiment you are doing, note that CPLEX's automatic Benders also allows you to customize the boundary between the master and subproblems through variable annotations instead of letting CPLEX just decide the boundary.   So if your Benders decomposition approach can be implemented by adjusting the boundary in this way, you might be able to just compare default and nondefault annotations.&lt;/p&gt;&#xA;" OwnerUserId="820" LastEditorUserId="123" LastEditDate="2019-07-06T11:38:02.043" LastActivityDate="2019-07-06T11:38:02.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="903" PostTypeId="2" ParentId="889" CreationDate="2019-07-06T06:50:13.070" Score="11" Body="&lt;p&gt;Bertsimas and Stellato just put up a new preprint which proposes a method to solve online mixed-integer optimization (MIO) problems at very high speed using machine learning. They benchmark their method against Gurobi and obtain speedups of two to three orders of magnitude on benchmarks with real-world data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/abs/1907.02206&quot; rel=&quot;noreferrer&quot;&gt;https://arxiv.org/abs/1907.02206&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="33" LastActivityDate="2019-07-06T06:50:13.070" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="904" PostTypeId="1" AcceptedAnswerId="913" CreationDate="2019-07-06T19:01:17.257" Score="5" ViewCount="516" Body="&lt;p&gt;I have an element &lt;em&gt;e&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$\in E$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; the set containing all elements e and &lt;span class=&quot;math-container&quot;&gt;$e \in Y_i$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$Y_i \subseteq E$&lt;/span&gt;. Each set &lt;span class=&quot;math-container&quot;&gt;$Y_i$&lt;/span&gt; has different attributes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$G_j$&lt;/span&gt; is a set of sets and the following holds: &lt;span class=&quot;math-container&quot;&gt;$ Y_i\in\ G_j $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\cup_j G_j = E$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$e=5$&lt;/span&gt; and sets &lt;span class=&quot;math-container&quot;&gt;$Y_2$&lt;/span&gt;={5,2,7}; &lt;span class=&quot;math-container&quot;&gt;$Y_{40}$&lt;/span&gt;={5,100,7}; ...; &lt;span class=&quot;math-container&quot;&gt;$Y_t$&lt;/span&gt;={300,400,2,5} are in &lt;span class=&quot;math-container&quot;&gt;$G_1$&lt;/span&gt; so:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ G_1=\{Y_2, Y_{40},..., Y_t\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;In the end, I want to write a sum over a decision variable, that sums all variables found in the different sets for a particular element &lt;em&gt;e&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This should look likes this -&amp;gt; &lt;span class=&quot;math-container&quot;&gt;$\sum\limits^{G_1}_{Y_i \ni e}x_e(Y_i)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\sum\limits^{G_j}_{Y_i}x_{e,Y_i} \; \forall e \in E: e \in Y_i:Y_i \in G_j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I want a sum over all elements within a set &lt;span class=&quot;math-container&quot;&gt;$Y_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This should look like this -&amp;gt; &lt;span class=&quot;math-container&quot;&gt;$\sum \limits^{Y_i}_e x_{e,Y_i} \; \forall\ Y_i \in G_j: e\in Y_i $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;x is a binary decision variable.&lt;/p&gt;&#xA;&lt;p&gt;With my knowledge, I do not see how a solver could work like this.&lt;/p&gt;&#xA;&lt;p&gt;I could have used indices for the attributes found in the sets &lt;span class=&quot;math-container&quot;&gt;$Y_i$&lt;/span&gt;. This way I would avoid using &lt;span class=&quot;math-container&quot;&gt;$Y_i$&lt;/span&gt; as an index. That though would probably add too many unnecessary decision variables that would be set to zero, since not for all elements exists these combinations of attributes.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to formulate such a thing?&lt;/p&gt;&#xA;" OwnerUserId="456" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-07-08T14:59:13.627" Title="Formulation of a constraint in a MIP for an element in different Sets" Tags="|mixed-integer-programming|linear-programming|constraint-programming|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="905" PostTypeId="1" CreationDate="2019-07-06T20:06:29.563" Score="6" ViewCount="249" Body="&lt;p&gt;What are good sources (literature, internet, etc) on learning to model real-world problems using mathematical formulations?&#xA;In particular, I would like to know sources which establish the relationship between the meaning of a mathematical construct and its real-world counterpart.&#xA;For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;quantities are usually represented through variables or parameters&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;equations represent causal-effect relationships between concepts&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;inequations represent limits&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;etc.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="62" LastEditorUserId="36" LastEditDate="2019-07-06T20:15:22.913" LastActivityDate="2019-07-07T13:02:24.477" Title="Good sources on developing mathematical models" Tags="|modeling|reference-request|" AnswerCount="2" CommentCount="2" ClosedDate="2019-07-07T22:24:38.380" ContentLicense="CC BY-SA 4.0" />
  <row Id="906" PostTypeId="1" CreationDate="2019-07-07T00:10:56.500" Score="8" ViewCount="101" Body="&lt;p&gt;Given a ground set, say &lt;span class=&quot;math-container&quot;&gt;$[n]=\{1,2,\dots,n\}$&lt;/span&gt;, and a collection of subset families &lt;span class=&quot;math-container&quot;&gt;$\mathcal F_i\subseteq 2^{[n]}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i=1,2,\dots,m$&lt;/span&gt;, I want to select &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; sets &lt;span class=&quot;math-container&quot;&gt;$B_i\in\mathcal F_i$&lt;/span&gt; such that the cardinality of the union &lt;span class=&quot;math-container&quot;&gt;$B_1\cup B_2\cup\dots\cup B_m$&lt;/span&gt; is minimized. In other words, I want to hit each of the families &lt;span class=&quot;math-container&quot;&gt;$\mathcal F_i$&lt;/span&gt; touching as few elements of the ground set as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://cstheory.stackexchange.com/a/44197/15637&quot;&gt;this answer&lt;/a&gt; over at cstheory, I learnt that the general problem is very hard to approximate (reduction from the Min-Rep problem introduced in  &lt;a href=&quot;http://www.crab.rutgers.edu/~guyk/pub/hard/nabs.pdf&quot; rel=&quot;noreferrer&quot;&gt;Kortsarz, Guy. &quot;On the hardness of approximating spanners.&quot; Algorithmica &lt;strong&gt;30&lt;/strong&gt;(2001): 432-450&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, the following scheduling problem can be interpreted as a very very special case which can be solved efficiently: We want to schedule a set of jobs indexed by &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (given by earliest start time &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt;, latest completion time &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt;  and processing time &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt;) on a single machine of infinite capacity, and the objective is to minimize the total busy time of the machine. In this setting, the family &lt;span class=&quot;math-container&quot;&gt;$\mathcal F_i$&lt;/span&gt; would just be the set of intervals &lt;span class=&quot;math-container&quot;&gt;$\{[r_i,r_i+p_i-1],[r_i+1,r_i+p_i],\dots,[d_i-p_i+1,d_i]\}$&lt;/span&gt; (Rohit Khandekar, Baruch Schieber, Hadas Shachnai, and Tami Tamir. “Real-time scheduling&#xA;to minimize machine busy times”. Journal of Scheduling &lt;strong&gt;18&lt;/strong&gt; (2015), p. 561-573, doi:&lt;a href=&quot;https://doi.org/10.1007/s10951-014-0411-z&quot; rel=&quot;noreferrer&quot;&gt;10.1007/s10951-014-0411-z&lt;/a&gt;)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd be interested to learn about any other special cases of the problem with structured families &lt;span class=&quot;math-container&quot;&gt;$\mathcal F_i$&lt;/span&gt; which may have been considered in an OR context.&lt;/p&gt;&#xA;" OwnerUserId="741" LastEditorUserId="741" LastEditDate="2019-07-07T01:04:46.153" LastActivityDate="2019-07-07T01:04:46.153" Title="Examples for a kind of &quot;set family hitting&quot; problem" Tags="|reference-request|scheduling|set-covering|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="907" PostTypeId="2" ParentId="334" CreationDate="2019-07-07T04:18:34.183" Score="9" Body="&lt;p&gt;&lt;strong&gt;TL;DR version&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For vehicle routing problems (which is a subset of OR), academic works focus on getting the best possible solution cost for overly simplified problems, industry focuses on getting workable solutions to much more complex problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Long version&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't comment on wider OR but I can comment on vehicle routing problems. I've worked as a CS postdoc and now I develop a commercial solver for the dynamic vehicle routing problem (see &lt;a href=&quot;https://odllive.com&quot; rel=&quot;noreferrer&quot;&gt;odllive.com&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion, academics and practitioners in industry have two different goals when they tackle vehicle routing problems - for academics this is to publish papers, for industry this is to make it work for the customer. Academic studies on vehicle routing (with a few notable exceptions), therefore tend to focus on simpler problems where their chosen optimisation method/problem formulation etc. can have provably better results, which makes it suitable for publication. Finding best new solutions for the standard VRP benchmarks (e.g. Solomon etc) is one way of showing you're getting better results (ignoring the problem that computers get more powerful every year). As a result, there is a strong focus on improving existing benchmarks on known simple problems, so you can compare your work to previous works and demonstrate it worthy of publication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The kind of VRP problems in industry tend to be a lot more complex, involving many different side-constraints. Implementing a VRP optimisation algorithm that can handle this kind of complexity is beyond the scale of most academic VRP research projects (it's certainly more work than would be involved in a single PhD thesis). So it's not that feasible for academic studies to handle this amount of problem complexity and it's not beneficial either - if they implement an algorithm that could handle the kind of rich problem variants you find in industry, it arguably makes it harder to get published as there's no prior benchmarks for these type of rich problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In industry you can't use a simpler version of the problem you're trying to solve, instead you just have to make it work - so you have to implement these more complex problem formulations. As a result, the focus is much more on getting a working solver for the problem, not getting the absolute best possible solution for a simpler version of the problem. Correctly formulating the objective functions to reflect the client's preferences is far more important than a marginal gain in your transport costs (which let's not forget, are only an estimate). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possibly the most commonly studied academic problem formulation is the vehicle routing problem with time windows (VRPTW). This does match-up reasonably well to the real-world case of distribution from a single depot, and therefore represents a 'best case' of translating an academic problem to the real-world. Even for this though, in the real-world you might need soft time windows, you'd need to consider road-network travel times, rush hour effects, multi-depot setups, non-homogeneous vehicles, work breaks, as well as driver preference in-terms of the geographic area they'd cover (minimal travel solutions from a central depot create petal shaped routes but drivers usually prefer to work in a compact geographic area). &lt;strong&gt;Most of these side constraints have actually been considered in academic works, but not all together in a single work&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more complex problem variants the disconnect between academia and industry becomes worse. Consider dynamic and stochastic vehicle routing problems (i.e. realtime routing problems where probability of future jobs is fed into the optimisation algorithm somehow). Several papers on dynamic and stochastic vehicle routing problems assume that you can decide the next job to dispatch to a vehicle one-at-a-time, and before each dispatch you run a set of parallel vehicle routing problems, where each problem includes the current known jobs and a random sample of possible future jobs. The most commonly found job-vehicle combination that should be served next is then dispatched (i.e. you decide that job 31 should be dispatched to vehicle 7, and then you re-run another set of parallel vehicle routing problems). This works as an academic solution but (in my opinion) is unlikely to be workable in the real-world. For larger problems - e.g. optimising an UberEats type restaurant delivery service in a large city - the optimisation algorithm would not be able to keep up with the number of new jobs, when you consider that parallel optimisation runs are required between each job dispatch. Communication delays with drivers would also make matter worse. In my opinion, for dynamic and stochastic VRPs only a solver that can provide the next dispatches for all vehicles at once, and not the next dispatch for only one vehicle out of the entire fleet, are workable. This hasn't been addressed in an academic paper I'm aware of.&lt;/p&gt;&#xA;" OwnerUserId="825" LastActivityDate="2019-07-07T04:18:34.183" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="908" PostTypeId="2" ParentId="503" CreationDate="2019-07-07T09:48:55.820" Score="4" Body="&lt;p&gt;In addition to the reference of Mark, you can have a look at his technical report:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://cerc-datascience.polymtl.ca/wp-content/uploads/2016/06/Technical-Report_DS4DM-2016-001-1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Solving standard quadratic programming by cutting planes&lt;/a&gt;. &#xA;by P. Bonami, A.Lodi, J. Schweiger, A. Tramontani&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the authors are involved with the development of CPLEX, I guess this paper is relevant to your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be aware that also Gurobi will soon have support for binary non convex quadratic problem. You can have a look at the slides of Tobias Achterberg at CPAIOR 2019 last June:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://cpaior2019.uowm.gr/wp-content/uploads/CPAIOR_Achterberg.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Products in Mixed Integer Programming&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In both cases, it looks that a careful combination of cutting planes and spatial branch-and-bound is the winning approach.&lt;/p&gt;&#xA;" OwnerUserId="171" LastActivityDate="2019-07-07T09:48:55.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="909" PostTypeId="2" ParentId="905" CreationDate="2019-07-07T11:28:07.643" Score="6" Body="&lt;p&gt;In my case I found these two sources to be very helpful for mathematical modelling: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://ampl.com/resources/the-ampl-book/chapter-downloads/&quot; rel=&quot;noreferrer&quot;&gt;AMPL: A Modeling Language &#xA;for Mathematical Programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.amazon.de/gp/product/1118443330/ref=ox_sc_saved_title_9?smid=A3JWKAKR8XB7XF&amp;amp;psc=1&quot; rel=&quot;noreferrer&quot;&gt;Model Building in Mathematical Programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The first one is free and very simple to understand.&lt;/p&gt;&#xA;" OwnerUserId="456" LastActivityDate="2019-07-07T11:28:07.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="910" PostTypeId="2" ParentId="905" CreationDate="2019-07-07T13:02:24.477" Score="8" Body="&lt;p&gt;I have found MOSEKs modelling cookbook particularly useful: &lt;a href=&quot;https://docs.mosek.com/MOSEKModelingCookbook-letter.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://docs.mosek.com/MOSEKModelingCookbook-letter.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2019-07-07T13:02:24.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="911" PostTypeId="1" CreationDate="2019-07-07T15:23:05.190" Score="15" ViewCount="885" Body="&lt;p&gt;What are the mainstream models for portfolio optimization? We have Markowitz mean-variance model and CVaR-based models (e.g., max return subject to a CVaR constraint). What else is out there in terms of risk measures or formulations?&lt;/p&gt;&#xA;" OwnerUserId="602" LastEditorUserId="602" LastEditDate="2019-07-09T16:13:59.293" LastActivityDate="2019-07-10T14:29:32.160" Title="Optimization models for portfolio optimization" Tags="|optimization|combinatorial-optimization|finance|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="912" PostTypeId="2" ParentId="911" CreationDate="2019-07-07T16:39:22.323" Score="8" Body="&lt;p&gt;Here's what is not really mainstream now, but should be.  The mean and especially the covariance matrix of returns is not known. Treating estimates of then as though they are known with certainty can lead to very suboptimal results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to start vectoring yourself in the right direction, you can start by looking at &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://projecteuclid.org/download/pdfview_1/euclid.aoas/1310562206&quot; rel=&quot;noreferrer&quot;&gt;MEAN–VARIANCE PORTFOLIO OPTIMIZATION WHEN MEANS AND COVARIANCES ARE UNKNOWN&lt;/a&gt;, TZE  LEUNG LAI, HAIPENG XING, and ZEHAO CHEN, Annals of Statistics, 2011, Vol. 5, No. 2A, 798–823.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/pdf/1804.00191.pdf&quot; rel=&quot;noreferrer&quot;&gt;Improving Portfolios Global Performance with Robust Covariance Matrix Estimation:Application to the Maximum Variety Portfolio&lt;/a&gt;, Emmanuelle Jay, Eugenie Terreaux, Jean-Philippe Ovarlez, and Frederic Pascal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also find of interest methods to identify financial risk factors using large data sets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://cdar.berkeley.edu/wp-content/uploads/2016/09/risk_seminar_slides_041216.pdf&quot; rel=&quot;noreferrer&quot;&gt;Identifying Financial Risk Factors with a Low-Rank Sparse Decomposition&lt;/a&gt;, Lisa Goldberg and Alex Shkolnik.  This  decomposes covariance as a sum of a rank-one factor component and a diagonal security specific return component&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a semi-classic paper advising you NOT to use the sample covariance matrix for portfolio optimization. &quot;Shrinking&quot; it toward a better conditioned matrix. even though producing a biased estimator of the covariance matrix, can improve the results of portfolio optimization (note that the condition number of the sample covariance matrix is a very biased estimator of the condition number of the true covariance matrix, and is infinite when the number of vector data points is less than the number of variables).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ledoit.net/honey.pdf&quot; rel=&quot;noreferrer&quot;&gt;Honey, I Shrunk the Sample Covariance Matrix&lt;/a&gt;, Olivier Ledoit and MichaelWolf, The Journal of Portfolio Management Summer 2004, 30 (4) 110-119 (link is to free version of the paper)&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-07-07T16:54:16.993" LastActivityDate="2019-07-07T16:54:16.993" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="913" PostTypeId="2" ParentId="904" CreationDate="2019-07-07T16:41:43.033" Score="5" Body="&lt;p&gt;Update:&#xA;So, for all &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; indexing the larger set of sets, let &lt;span class=&quot;math-container&quot;&gt;$M_j$&lt;/span&gt; be the set of indices &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; within  &lt;span class=&quot;math-container&quot;&gt;$G_j$&lt;/span&gt;, meaning &lt;span class=&quot;math-container&quot;&gt;$G_j=\cup_{i\in M_j}Y_i$&lt;/span&gt; (e.g., &lt;span class=&quot;math-container&quot;&gt;$M_1=\{2,40,\ldots,t\}$&lt;/span&gt;). Now define the (binary) decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{e,i}$&lt;/span&gt; (to avoid using &lt;span class=&quot;math-container&quot;&gt;$Y_i$&lt;/span&gt;). This variable only exists &lt;span class=&quot;math-container&quot;&gt;$\forall e\in E, i\in M_j:e\in Y_i$&lt;/span&gt;. You could further pre-compute &lt;span class=&quot;math-container&quot;&gt;$Y(e) = \{i: e\in Y_i\}$&lt;/span&gt; (set of i's such that &lt;span class=&quot;math-container&quot;&gt;$e\in Y_i$&lt;/span&gt;). With the notation in place:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in Y(e)}{x_{e,i}} \quad  \forall e \in E$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{e\in Y_i}{x_{e,i}} \quad  \forall j=1,2,\ldots;i\in M_j$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Old:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$g \in G_1$&lt;/span&gt; be any of those sets &lt;span class=&quot;math-container&quot;&gt;$Y_i$&lt;/span&gt; you listed, and first define the union &lt;span class=&quot;math-container&quot;&gt;$U_1 = \displaystyle\cup_{g\in G}{g}$&lt;/span&gt;. Now you are sure all elements contained in the sets of &lt;span class=&quot;math-container&quot;&gt;$G_1$&lt;/span&gt; are there. Now, if you want to &quot;write a sum over a decision variable, that sums all variables found in the different sets&quot;, it would be &lt;span class=&quot;math-container&quot;&gt;$\displaystyle\sum_{e\in U_1}x_e$&lt;/span&gt;. &lt;/p&gt;&#xA;" OwnerUserId="602" LastEditorUserId="602" LastEditDate="2019-07-08T14:59:13.627" LastActivityDate="2019-07-08T14:59:13.627" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="914" PostTypeId="2" ParentId="904" CreationDate="2019-07-07T19:58:22.450" Score="1" Body="&lt;p&gt;I tried to understand your question and ended up with the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want to count the number of &lt;span class=&quot;math-container&quot;&gt;$Y_i$&lt;/span&gt; sets in each set of sets &lt;span class=&quot;math-container&quot;&gt;$G_j$&lt;/span&gt; which include the variable &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;. If it is the right way to translate your problem, my suggestion is to define binary variables with two indices like &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; with the following definition:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}=\left\{&#xA;                \begin{array}{ll}&#xA;                  1 &amp;amp; \text{if $e \in Y_i$ &amp;amp; $Y_i \in G_j$ }\\&#xA;                  0 &amp;amp; \text{if $e \notin Y_i$ || $Y_i \notin G_j$}&#xA;                \end{array}&#xA;              \right.&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then you can easily sum over the binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-07-07T19:58:22.450" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="915" PostTypeId="1" CreationDate="2019-07-08T10:51:31.747" Score="1" ViewCount="140" Body="&lt;p&gt;I am solving a nonlinear numerical optimization problem in Pyomo using Scip as a solver. The goal is to minimize a certain objective function. For certain input conditions, I notice that the solver yields final optimal value of the objective function that is higher than the initial objective function value. &#xA;I am wondering as to why this could be the case. Any comments would be helpful.      &lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2019-07-08T10:51:31.747" Title="Optimal value exceeds actual value for a minimization problem" Tags="|optimization|pyomo|" AnswerCount="0" CommentCount="5" ClosedDate="2019-08-12T22:54:47.733" ContentLicense="CC BY-SA 4.0" />
  <row Id="916" PostTypeId="2" ParentId="841" CreationDate="2019-07-08T12:24:06.710" Score="5" Body="&lt;p&gt;I am sorry to advertise our own VRP solver, but may be it is what you are looking for:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vrpsolver.math.u-bordeaux.fr/&quot; rel=&quot;noreferrer&quot;&gt;https://vrpsolver.math.u-bordeaux.fr/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For knapsack, Pisinger's code is the best (mentioned above), however integer knapsack code there has a bug. I only use 0-1 knapsack code, it is reliable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For bin packing, this nice paper has links to several available solvers: &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2016.04.030&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1016/j.ejor.2016.04.030&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For (weighted) maximum clique (minimum stable set), Ostergard's code is very good: &lt;a href=&quot;https://users.aalto.fi/~pat/cliquer.html&quot; rel=&quot;noreferrer&quot;&gt;https://users.aalto.fi/~pat/cliquer.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although, it may not be state-of-the-art anymore.&lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2019-07-08T12:24:06.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="917" PostTypeId="2" ParentId="883" CreationDate="2019-07-08T13:01:48.113" Score="10" Body="&lt;p&gt;If the IPOPT termination condition is &lt;code&gt;Optimal Solution Found&lt;/code&gt; then the returned solution is locally optimal. IPOPT is, by design, not a global solver and therefore does not have any built-in infrastructure for checking if a solution is global vs. local. However, if you know certain features of your problem, like if it is convex, then you as the user might be able to prove that you're getting the globally optimal solution on your specific problem (but there is no automated infrastructure in IPOPT or Pyomo for doing this).&lt;/p&gt;&#xA;" OwnerUserId="583" LastActivityDate="2019-07-08T13:01:48.113" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="918" PostTypeId="2" ParentId="829" CreationDate="2019-07-08T16:24:47.043" Score="4" Body="&lt;p&gt;This is eerily similar to &lt;a href=&quot;https://www.youtube.com/watch?v=s_pgTLcywek&quot; rel=&quot;nofollow noreferrer&quot;&gt;hospital bed planning&lt;/a&gt; which has a number of papers under the term Patient Admission Scheduling. It is originally &lt;a href=&quot;https://people.cs.kuleuven.be/~wim.vancroonenburg/pas/&quot; rel=&quot;nofollow noreferrer&quot;&gt;defined and implemented by the CoDES group here&lt;/a&gt;. I have an implementation in optaplanner-examples too.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2019-07-08T16:24:47.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="919" PostTypeId="1" CreationDate="2019-07-08T21:03:20.060" Score="24" ViewCount="2372" Body="&lt;p&gt;A &amp;quot;serious game&amp;quot; is a game (usually a simulation) designed for a primary purpose other than pure entertainment. Games like &lt;em&gt;the beer game&lt;/em&gt; or &lt;em&gt;the fresh connection&lt;/em&gt; can be considered serious games serving an educational purpose.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edited after comments&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;My question is twofold:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I am interested in using games in my logistics and supply chain&#xA;management classes. Are there other serious games (educational games&#xA;in general) that use OR principles, methods and tools (perhaps&#xA;beyond simulation)?&lt;/li&gt;&#xA;&lt;li&gt;I am also interested in the mechanics of such games. My question is NOT how to use games to teach OR, but how to use OR to create games about other subjects, typically in the Operation Management, Management Science, Supply chain and logistics areas.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="459" LastEditorUserId="491" LastEditDate="2022-08-19T02:30:09.053" LastActivityDate="2024-03-03T13:33:35.957" Title="OR-backed serious games" Tags="|optimization|simulation|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="920" PostTypeId="2" ParentId="829" CreationDate="2019-07-08T21:34:47.847" Score="4" Body="&lt;p&gt;Here are a couple of simple MIP models that (I think) accomplish the first task, of assigning everyone to a bed while minimizing splits. They are both single-day models, which means they don't address the second task, of minimizing the number of people who have to switch beds during multi-day stays.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;First Model&lt;/h1&gt;&#xA;&lt;p&gt;&lt;strong&gt;Parameters:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; = number of beds (= 14 in your example)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; = number of groups to be booked&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$m_g$&lt;/span&gt; = number of people in group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, for &lt;span class=&quot;math-container&quot;&gt;$g = 1,\ldots,G$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Decision variables:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ng}$&lt;/span&gt; = 1 if someone from group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; uses bed &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, 0 otherwise, for &lt;span class=&quot;math-container&quot;&gt;$g=1,\ldots,G, n = 1,\ldots,N$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y^-_g$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y^+_g$&lt;/span&gt; = min, max bed number used by group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, for &lt;span class=&quot;math-container&quot;&gt;$g = 1,\ldots,G$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Formulation:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\text{minimize} \quad &amp;amp; \sum_{g=1}^G (y^+_g - y^-_g + 1 - m_g) \\&#xA;\text{subject to} \quad &amp;amp; \sum_{n=1}^N x_{ng} = m_g \quad \forall g=1,\ldots,G \\&#xA;&amp;amp; \sum_{g=1}^G x_{ng} \le 1 \quad \forall n = 1,\ldots, N \\&#xA;&amp;amp; y_g^- \le nx_{ng} \le y^+_g \quad \forall g=1,\ldots,G, n = 1,\ldots,N \\&#xA;&amp;amp; x_{ng} \in \{0,1\} \quad \forall g=1,\ldots,G, n = 1,\ldots,N \\&#xA;&amp;amp; y^+_g, y^-_g \ge 0 \quad \forall g=1,\ldots,G&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective function minimizes the number of &amp;quot;extra&amp;quot; beds between the first and last bed used by a group. The total size of the &amp;quot;range&amp;quot; used by the group is &lt;span class=&quot;math-container&quot;&gt;$y^+_g - y^-_g+1$&lt;/span&gt;, and we want this to be as close as possible to &lt;span class=&quot;math-container&quot;&gt;$m_g$&lt;/span&gt;. For example, if the group has 5 people and uses beds 3, 4, 5, 6, 7, then the group is consecutive, and we have &lt;span class=&quot;math-container&quot;&gt;$y_g^- = 3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_g^+=7$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$y_g^+ - y_g^- + 1 - m_g = 0$&lt;/span&gt;, whereas if the group uses beds 3, 4, 5, 8, 9, then the objective function &amp;quot;score&amp;quot; is 2, because there are two skipped beds.&lt;/p&gt;&#xA;&lt;p&gt;Note that the objective function penalty is the same if 1 group skips 2 beds as it is if 2 groups each skip 1 bed. Therefore, it's not really minimizing the number of &lt;em&gt;splits&lt;/em&gt;, but the number of &lt;em&gt;skips&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The first constraint says that each group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; must be assigned to exactly &lt;span class=&quot;math-container&quot;&gt;$m_g$&lt;/span&gt; beds. The second constraint says that each bed can have at most one group assigned to it. The next constraint says that &lt;span class=&quot;math-container&quot;&gt;$y^-_g$&lt;/span&gt; must be no larger than the smallest bed number used for group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$y^+_g$&lt;/span&gt; must be no smaller than the largest. Because of the sign of the corresponding terms in the objective function, these will always &lt;em&gt;equal&lt;/em&gt; the min and max bed indices.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;Second Model&lt;/h1&gt;&#xA;&lt;p&gt;This model uses the same parameters, and the following additional decision variable:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{ng}$&lt;/span&gt; = number of &amp;quot;stranger-neighbors&amp;quot; for bed &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, if someone from group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is assigned to bed &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; (and 0 otherwise),&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;where a &amp;quot;stranger-neighbor&amp;quot; is a person from a group &lt;span class=&quot;math-container&quot;&gt;$\ne$$g$&lt;/span&gt; who is assigned to bed &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt;. For bed &lt;span class=&quot;math-container&quot;&gt;$n=1$&lt;/span&gt;, &amp;quot;bed 0&amp;quot; counts as a stranger-neighbor, and for bed &lt;span class=&quot;math-container&quot;&gt;$n=N$&lt;/span&gt;, &amp;quot;bed &lt;span class=&quot;math-container&quot;&gt;$N+1$&lt;/span&gt;&amp;quot; counts as a stranger-neighbor. To model this, assume there is a dummy group &lt;span class=&quot;math-container&quot;&gt;$g=0$&lt;/span&gt;, and set &lt;span class=&quot;math-container&quot;&gt;$x_{00} = x_{N+1,0} = 1$&lt;/span&gt;, i.e., put a person from group 0 in beds 0 and &lt;span class=&quot;math-container&quot;&gt;$N+1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So, if group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is assigned to a consecutive set of beds, then the total number of stranger-neighbors for the people in group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; will be exactly 2; and for each skip in the assignments, the number of stranger-neighbors will increase by 2. In other words, the number of skips is equal to the total number of stranger-neighbors, minus 2, divided by &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;. This is our objective function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\text{minimize} \quad &amp;amp; \frac1G \sum_{g=1}^G \sum_{n=1}^N (z_{ng} - 2) \\&#xA;\text{subject to} \quad &amp;amp; \sum_{n=1}^N x_{ng} = m_g \quad \forall g=1,\ldots,G \\&#xA;&amp;amp; \sum_{g=1}^G x_{ng} \le 1 \quad \forall n = 1,\ldots, N \\&#xA;&amp;amp; x_{00} = x_{N+1,0} = 1 \\&#xA;&amp;amp; z_{ng} \ge \sum_{h\in G\setminus\{g\}} (x_{n-1,h} + x_{n+1,h}) - 2 (1 - x_{ng}) \quad \forall g=1,\ldots,G, n = 1,\ldots,N \\&#xA;&amp;amp; x_{ng} \in \{0,1\} \quad \forall g=1,\ldots,G, n = 1,\ldots,N \\&#xA;&amp;amp; z_{ng} \ge 0 \quad \forall g=1,\ldots,G, n = 1,\ldots, N&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first two constraints are the same as in the first model. The third constraint assigns the dummy group. The fourth constraint says that if &lt;span class=&quot;math-container&quot;&gt;$x_{ng}=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$z_{ng}$&lt;/span&gt; must be at least equal to the number of stranger-neighbors—the number of people of other groups that are assigned to beds &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; and/or &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt;—(but really it will &lt;em&gt;equal&lt;/em&gt; this number, since we want to minimize &lt;span class=&quot;math-container&quot;&gt;$z_{ng}$&lt;/span&gt;); and if &lt;span class=&quot;math-container&quot;&gt;$x_{ng}=0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$z_{ng}$&lt;/span&gt; can equal 0.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Personally I like the second model a little more—I like counting &amp;quot;splits&amp;quot; rather than &amp;quot;skips&amp;quot;. But it has more decision variables. On the other hand, I think you'll be solving small instances (&lt;span class=&quot;math-container&quot;&gt;$N=14$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$G\le 14$&lt;/span&gt;?) so either formulation should solve plenty quickly.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-07-08T21:34:47.847" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="921" PostTypeId="2" ParentId="919" CreationDate="2019-07-08T21:49:10.257" Score="6" Body="&lt;p&gt;The company &lt;a href=&quot;https://www.gamelabeducation.com/en/games/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GameLab&lt;/a&gt; offers these types of games. There you will find a few more &quot;serious games&quot;.&lt;/p&gt;&#xA;" OwnerUserId="602" LastEditorUserId="38" LastEditDate="2019-07-09T11:49:38.807" LastActivityDate="2019-07-09T11:49:38.807" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="922" PostTypeId="2" ParentId="919" CreationDate="2019-07-08T21:49:38.917" Score="7" Body="&lt;p&gt;One simple game for educational purposes that doesn't use simulation is the &lt;em&gt;&lt;a href=&quot;https://slickoilgame.github.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Slick Oil Distribution Game&lt;/a&gt;&lt;/em&gt;. &lt;em&gt;(Thanks to &lt;a href=&quot;https://or.stackexchange.com/users/191/michael-watson&quot;&gt;Dr. Michael Watson&lt;/a&gt; for turning the light on and a new link on the game)&lt;/em&gt;. As Mike mentioned in his update post:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The game went offline several years ago. I know that many people used&#xA;it to teach optimization. In August 2022, I created a janky Excel&#xA;version as a patch. &lt;a href=&quot;https://substack.com/redirect/7c41fc2d-0ac9-435c-8ea6-344b5760d7c0?j=eyJ1IjoiMXJlOWZ6In0.AR01pr8_lf1nTl0MY6zChzgsiAlMUqfG4eXu98cF7Qg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here is that article&lt;/a&gt; with some links to a version&#xA;with OpenSolver and the guides created by Sara Hoormann.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/X1BQe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/X1BQe.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2024-03-03T13:33:35.957" LastActivityDate="2024-03-03T13:33:35.957" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="923" PostTypeId="2" ParentId="919" CreationDate="2019-07-08T22:39:55.487" Score="5" Body="&lt;p&gt;You could set your class the challenge of manually planning a set of delivery routes and seeing if they can find better routes (less vehicles used, less travel distance/time) than an optimisation algorithm can do? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have an open source/free VRP solver desktop app called &lt;a href=&quot;https://opendoorlogistics.com/software/odl-studio/&quot; rel=&quot;noreferrer&quot;&gt;ODL Studio&lt;/a&gt; that would let you do this - see tutorial video &lt;a href=&quot;https://www.youtube.com/watch?v=0DJdubVWX_A&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We also have a &lt;a href=&quot;https://opendoorlogistics.com/tutorials/tutorial-territory-design/territorium/&quot; rel=&quot;noreferrer&quot;&gt;p-median site location solver&lt;/a&gt; in ODL Studio. Again you could set your class the task of beating the solver using this. Some students at &lt;a href=&quot;https://www.northampton.ac.uk/news/budding-logistics-managers-graduate-with-practical-experience-of-industry-software/&quot; rel=&quot;noreferrer&quot;&gt;this university&lt;/a&gt; did something similar using ODL Studio.&lt;/p&gt;&#xA;" OwnerUserId="825" LastEditorUserId="825" LastEditDate="2019-07-08T23:14:27.073" LastActivityDate="2019-07-08T23:14:27.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="924" PostTypeId="1" AcceptedAnswerId="927" CreationDate="2019-07-09T00:00:22.383" Score="7" ViewCount="491" Body="&lt;p&gt;I have an optimization problem as below. I am having a hard time with the last constraint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max \eta$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;subject to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\bf U}(:,m)^T{\bf A}{\bf U}(:,m)=0,m=1,2,\cdots,M$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bf{A}$&lt;/span&gt; is a Binary Matrix of size &lt;span class=&quot;math-container&quot;&gt;$N\times N$&lt;/span&gt; (given, known)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bf{U}$&lt;/span&gt; is an optimization variable matrix &lt;span class=&quot;math-container&quot;&gt;$\bf U$&lt;/span&gt; of size &lt;span class=&quot;math-container&quot;&gt;$N\times M$&lt;/span&gt; (Binary matrix)&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2019-07-09T07:19:25.053" LastActivityDate="2019-07-09T20:03:57.263" Title="How can I linearize or convexify this binary quadratic optimization problem?" Tags="|linearization|combinatorial-optimization|quadratic-programming|convexity|binary-variable|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="925" PostTypeId="2" ParentId="919" CreationDate="2019-07-09T06:14:35.437" Score="11" Body="&lt;p&gt;&lt;a href=&quot;http://www.seriouslogisticsgames.be/&quot; rel=&quot;noreferrer&quot;&gt;This link&lt;/a&gt;, provide 3 different logistic related games, TopShoe, JIT Flight and MyDC.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;TopShoe:&lt;/em&gt; introduces the players to the logistical processes and the tactical decisions that must be made.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;JIT Flight:&lt;/em&gt; is a multi-round bussiness game in which students optimize the process according to the JIT philosophy (minimum stocks, zero defects, minimum product outages, responsible employees without stress).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;MyDC:&lt;/em&gt; in MyDC distribution center students will become acquainted with the various departments and their operational processes. (order management - inventory management - location management - order picking - shipping - storage - goods receipt - purchase).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.scmglobe.com/multi-player-supply-chain-game/&quot; rel=&quot;noreferrer&quot;&gt;SCM GLOBE&lt;/a&gt;, provide a supply chain management, multi-player competition, educational game that can be used in a class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Considering their &lt;a href=&quot;https://www.biba-gaminglab.com/en/publications-2/&quot; rel=&quot;noreferrer&quot;&gt;publications&lt;/a&gt; and their collaboration in projects by University of Bremen, &lt;a href=&quot;https://www.biba-gaminglab.com/en/home/&quot; rel=&quot;noreferrer&quot;&gt;BIBA&lt;/a&gt; (Bremer Institut für Produktion und Logistik GmbH) is definitely one of the gaming labs that should be considered when a teacher wants to use serious games for educational purpose. &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-07-09T06:44:39.613" LastActivityDate="2019-07-09T06:44:39.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="926" PostTypeId="1" CreationDate="2019-07-09T06:55:44.237" Score="8" ViewCount="419" Body="&lt;p&gt;Considering a set of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; existing weighted demand points (very large) and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; different-sized facilities, what is the best approach for locating new facilities to maximise coverage? I have used the Weber problem, which is non-linear (quadratic). I used the &lt;span class=&quot;math-container&quot;&gt;$\ell_p$&lt;/span&gt;-metric method to measure distance but it is not accurate. (For example, where to locate a new police station to cover the demand points, or which of the existing facilities can be shifted to maximize the coverage).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I found a very similar model to what do I mean &lt;a href=&quot;https://stackoverflow.com/questions/48213881/facility-location-algorithm-to-minimize-facilities-serving-customers-with-dist&quot;&gt;here&lt;/a&gt;. Sorry if my question was not clear. So put simply, referring to the provided link my main questions are as below: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to solve such this model for large cases?&lt;/li&gt;&#xA;&lt;li&gt;This model is nonlinear. How to linearize it?&lt;/li&gt;&#xA;&lt;li&gt;What if there are already some facility established? How to locate the new facilities by considering them? &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="838" LastEditorUserId="36" LastEditDate="2019-07-14T13:10:16.883" LastActivityDate="2019-07-14T13:17:06.397" Title="Linear facility location problem for large size problems (police station)" Tags="|facility-location|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="927" PostTypeId="2" ParentId="924" CreationDate="2019-07-09T07:02:06.417" Score="8" Body="&lt;p&gt;The constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$${\bf U}(:,m)^T{\bf A}{\bf U}(:,m)=0,m=1,2,\cdots,M$$&lt;/span&gt;&#xA;can be rewritten as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^N \sum_{j=1}^N A(i,j) U(i,m)U(j,m)=0,m=1,2,\cdots,M.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, you can linearize each of the &lt;span class=&quot;math-container&quot;&gt;$U(i,m)U(j,m)$&lt;/span&gt; terms as explained &lt;a href=&quot;https://or.stackexchange.com/q/37/145&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-07-09T07:02:06.417" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="928" PostTypeId="1" CreationDate="2019-07-09T08:56:50.323" Score="51" ViewCount="6321" Body="&lt;p&gt;More than 10 years ago, there was during an INFORMS annual meeting a session dedicated to “&lt;em&gt;Great Unsolved Problems in O.R.&lt;/em&gt;” (you can find a small report of that session on &lt;a href=&quot;https://www.informs.org/ORMS-Today/Archived-Issues/2007/orms-2-07/GUPOR-Great-Unsolved-Problems-in-O.R&quot; rel=&quot;noreferrer&quot;&gt;this webpage&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which are nowadays the most important &lt;strong&gt;open problems in O.R.&lt;/strong&gt; that will have a strong impact on other research fields? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 13/07/2019:&lt;/strong&gt; so far the answers are mainly theoretically oriented. Anyone can suggest more &lt;strong&gt;computational unsolved/open problems&lt;/strong&gt;?&lt;/p&gt;&#xA;" OwnerUserId="171" LastEditorUserId="171" LastEditDate="2019-07-13T08:36:31.670" LastActivityDate="2019-07-24T10:07:38.070" Title="Great Unsolved Problems in O.R" Tags="|open-problems|" AnswerCount="8" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="929" PostTypeId="2" ParentId="928" CreationDate="2019-07-09T10:24:52.347" Score="27" Body="&lt;p&gt;Two open problems in linear optimization (which is considered more or less a 'solved' subfield by many):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Is there a pivoting strategy for the Simplex algorithm guaranteeing to find an optimal vertex in a polynomial number of steps?&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is related to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Hirsch_conjecture&quot; rel=&quot;noreferrer&quot;&gt;Hirsch conjecture&lt;/a&gt;. The diameter of a polytope is a theoretical lower bound on the Simplex iterations necessary. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The average number of iterations appears to have been proven to be polynomial, and there are various pivoting strategies with &lt;em&gt;expected&lt;/em&gt; polynomial number of iterations, but the worst case for all strategies still appears to be exponential.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;strong&gt;Can convergence in less than &lt;span class=&quot;math-container&quot;&gt;$\sqrt n$&lt;/span&gt; steps be guaranteed for any interior point method for linear programming?&lt;/strong&gt; &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It can be proved that interior point methods converge in &lt;span class=&quot;math-container&quot;&gt;$O(\sqrt n \ln \frac{1}{\epsilon})$&lt;/span&gt; iterations (see for example &lt;a href=&quot;https://www.maths.ed.ac.uk/~gondzio/reports/ipmXXV.pdf&quot; rel=&quot;noreferrer&quot;&gt;Gondzio 2012&lt;/a&gt;). In practice they are observed to converge faster (in the order of around &lt;span class=&quot;math-container&quot;&gt;$O(\ln (n+m))$&lt;/span&gt; iterations. But (to the best of my knowledge) no better bound has been proven so far.&lt;/p&gt;&#xA;" OwnerUserId="47" LastEditorUserId="47" LastEditDate="2019-07-09T14:07:26.737" LastActivityDate="2019-07-09T14:07:26.737" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="930" PostTypeId="2" ParentId="926" CreationDate="2019-07-09T10:49:05.773" Score="11" Body="&lt;p&gt;You may have a look at our recent work based on Benders decomposition, for the discrete Maximum Coverage Facility Location problem. It works very well if the number of facilities is relatively small, but the number of customers can run in millions…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;J.F. Cordeau, F. Furini, I. Ljubic: Benders Decomposition for Very Large Scale Partial Set Covering and Maximal Covering Problems, &#xA;European Journal of Operational Research 275(3):882-896, 2019 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can donwload the preprint from &lt;a href=&quot;http://www.optimization-online.org/DB_HTML/2018/06/6665.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is &lt;a href=&quot;https://github.com/fabiofurini/LocationCovering&quot; rel=&quot;noreferrer&quot;&gt;open-source&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="839" LastEditorUserId="47" LastEditDate="2019-07-09T10:55:07.187" LastActivityDate="2019-07-09T10:55:07.187" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="931" PostTypeId="2" ParentId="926" CreationDate="2019-07-09T12:09:24.987" Score="9" Body="&lt;p&gt;It sounds like you are describing either the &lt;strong&gt;set covering location problem (SCLP)&lt;/strong&gt; (&lt;a href=&quot;https://en.wikipedia.org/wiki/Set_cover_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia entry&lt;/a&gt;; &lt;a href=&quot;https://doi.org/10.1287/opre.13.3.462&quot; rel=&quot;nofollow noreferrer&quot;&gt;canonical citation&lt;/a&gt;) or the &lt;strong&gt;maximal coverage location problem (MCLP)&lt;/strong&gt; (&lt;a href=&quot;https://en.wikipedia.org/wiki/Maximum_coverage_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia entry&lt;/a&gt;; &lt;a href=&quot;https://doi.org/10.1007/BF01942293&quot; rel=&quot;nofollow noreferrer&quot;&gt;canonical citation&lt;/a&gt;). The SCLP minimizes the number of facilities subject to a constraint that every demand node is covered; the MCLP maximizes the number of covered demands subject to a constraint on the number of facilities to be located. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your question specifies &lt;em&gt;weighted&lt;/em&gt; demand points, which suggests the MCLP to me, since the weights don't matter in the SCLP (you have to cover everyone). You also say &lt;em&gt;different-sized facilities&lt;/em&gt; and I'm not sure what you mean by that. If you mean that the &lt;em&gt;coverage radius&lt;/em&gt; is different for different facilities, that's an easy modification. If you mean that the facilities have capacities, and the capacity is different for each facility, that's harder. The SCLP and MCLP assume the facilities are uncapacitated. You could add capacity constraints, but depending on how you are solving the problem, it may add computational difficulties.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Standard MIP formulations of both the SCLP and MCLP usually have very tight LP relaxations, which means you can often just solve them with a commercial solver. Other good algorithms exist, for example using Lagrangian relaxation or metaheuristics. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a &lt;a href=&quot;https://doi.org/10.1007/978-1-4419-7572-0_6&quot; rel=&quot;nofollow noreferrer&quot;&gt;book chapter on covering problems&lt;/a&gt; a while back; maybe that will be useful. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer your main questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The SCLP and MCLP can be solved for large instances using off-the-shelf MIP solvers. By large, I mean 1000s of nodes, at least. If you need larger, you may have to look at specialized algorithms, e.g., the one mentioned in @IvanaLjubic’s answer. But if &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is large and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is not, you can often reduce the size simply by aggregating the demand nodes, e.g., by postal code or some other grouping. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The SCLP and MCLP are linear. The p-center problem is also linear, although the variant of it in the answer you linked to happens to be nonlinear. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Easy, just set their fixed cost to 0, either in the objective function of the SCLP, or don’t include it in the LHS of the “open p facilities” constraint of the MCLP. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-07-14T13:17:06.397" LastActivityDate="2019-07-14T13:17:06.397" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="932" PostTypeId="2" ParentId="841" CreationDate="2019-07-09T12:24:50.660" Score="5" Body="&lt;p&gt;A nice framework for heuristic optimization is provided by HeuristicLab. Several classical problems, such as Job Shop Scheduling, Knapsack, Bin Packing or &#xA;TSP are also integrated (&lt;a href=&quot;https://dev.heuristiclab.com/trac.fcgi/wiki/Features&quot; rel=&quot;noreferrer&quot;&gt;https://dev.heuristiclab.com/trac.fcgi/wiki/Features&lt;/a&gt;). &lt;/p&gt;&#xA;" OwnerUserId="840" LastActivityDate="2019-07-09T12:24:50.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="933" PostTypeId="1" CreationDate="2019-07-09T13:18:30.030" Score="11" ViewCount="276" Body="&lt;p&gt;Problem: I have &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; jobs that I can assign to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; workers. Each job has a cost. Each worker can perform up to an arbitrary max number of jobs. However, there is a cost efficiency for each job that is assigned to the worker. For example, if two jobs are assigned then the cost of the jobs is multiplied by &lt;span class=&quot;math-container&quot;&gt;$0.95$&lt;/span&gt;. Three jobs, by &lt;span class=&quot;math-container&quot;&gt;$0.90$&lt;/span&gt;. This function can also be linear. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any examples of this in literature? I've been able to implement this if the multiplicative cost function is a step function. I'm not exactly sure how to proceed if the value that I multiply against the number of jobs is a function. &lt;/p&gt;&#xA;" OwnerUserId="841" LastEditorUserId="38" LastEditDate="2019-07-09T14:06:01.760" LastActivityDate="2019-08-06T15:20:11.530" Title="Assignment Problem with Decreasing Costs" Tags="|mixed-integer-programming|assignment-problem|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="934" PostTypeId="1" AcceptedAnswerId="936" CreationDate="2019-07-09T15:41:28.237" Score="31" ViewCount="4893" Body="&lt;p&gt;In optimization literature, I frequently see solution methods termed &quot;exact&quot; or &quot;approximate&quot;. (I use the term &quot;method&quot; here because I suspect exactness, or its lack, is a function of both algorithm and model.) My understanding is that &quot;exact&quot; translates to &quot;produces a provably optimal solution&quot; and &quot;approximate&quot; translates to &quot;may or may not find an optimal solution but will not provide proof of optimality&quot;. I'd like to know how others view the terms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motivation is a review of recent paper submission. In it, we posed a binary linear programming model and a solution procedure that used branch-and-cut with a variant of Benders decomposition. We called the combination an exact method for solving the underlying problem. We also provided computational examples, all but one of which we solved to optimality. In the one remaining case, I cut off the run at 10 hours with an optimality gap of around 12%. The reviewer pointed to that case as an indication the procedure was not &quot;exact&quot;. My initial inclination is to dismiss the comment, since branch-and-cut on a bounded ILP will always reach proven optimality &lt;em&gt;given enough resources&lt;/em&gt; (time and memory). On the other hand, from a practical standpoint, if you're not going to get a proven optimal solution within your lifetime, perhaps the method really should not be considered exact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know we're not supposed to ask for opinions here, so instead I'll ask which is the proper interpretation of &quot;exact&quot; (or whether I'm completely off base in my interpretation of the term).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-07-10T11:12:00.157" Title="Optimization terminology: &quot;Exact&quot; v. &quot;Approximate&quot;" Tags="|combinatorial-optimization|terminology|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="935" PostTypeId="2" ParentId="934" CreationDate="2019-07-09T15:50:22.580" Score="13" Body="&lt;p&gt;Exact: Provably optimal&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Approximate: offers an upper bound on the gap&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would add heuristics: procedures that, as you described, may or may not provide an optimal solution (with out any proof or guarantee).&lt;/p&gt;&#xA;" OwnerUserId="602" LastEditorUserId="602" LastEditDate="2019-07-09T15:58:02.193" LastActivityDate="2019-07-09T15:58:02.193" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="936" PostTypeId="2" ParentId="934" CreationDate="2019-07-09T15:55:20.550" Score="28" Body="&lt;p&gt;Exact: algorithm will eventually provide a provably optimal solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Approximate: algorithm will eventually produce a solution with some guarantees (e.g. a tour being at most twice as long as the shortest tour)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Heuristic: Algorithms that do not give any worst-case guarantee whatsoever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finite convergence and runtime are separate from &quot;exactness&quot; properties of an algorithm.&lt;/p&gt;&#xA;" OwnerUserId="47" LastActivityDate="2019-07-09T15:55:20.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="937" PostTypeId="2" ParentId="934" CreationDate="2019-07-09T15:59:06.100" Score="14" Body="&lt;p&gt;An &lt;em&gt;exact method&lt;/em&gt; will (typically within a bounded number of steps) provide a proven optimal solution. This is, a solution &lt;code&gt;x*&lt;/code&gt; and a guarantee that no other feasible solution has an objective better than that of &lt;code&gt;x*&lt;/code&gt;. Typically, exact methods compute two types of bounds: lower (&lt;code&gt;L&lt;/code&gt;) and upper (&lt;code&gt;U&lt;/code&gt;) bounds. Optimality is then proven whenever both bounds coincide. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In contrast to exact methods that provide a guarantee of optimality, &lt;em&gt;heuristics&lt;/em&gt; provide no such guarantee. In the OR literature, it is common to refer to those methods as &lt;em&gt;heuristics&lt;/em&gt; rather than &lt;em&gt;approximate&lt;/em&gt; methods. The latter is more commonly used to refer to algorithms with a proof of solution quality, although not necessarily exact. For instance, the TSP admits a 1.5-approximate algorithm (&lt;a href=&quot;https://en.wikipedia.org/wiki/Christofides_algorithm&quot; rel=&quot;noreferrer&quot;&gt;Christofides method&lt;/a&gt;), this is a method that will construct a solution whose cost is at most 1.5x that of an optimal TSP solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With respect to the reviewer comment, it is indeed a little odd. Using the same rationale, one would argue that Dijkstra's method is not exact because it will fail at solving shortest path problems containing trillions of points. The &lt;strong&gt;CONCORDE&lt;/strong&gt; solver for the TSP is another remarkable example of exact method. Like any other method for a reasonably difficult optimization problem, it will fail at solving extremely large problems. No one would argue that CONCORDE is not exact though. It seems to me that you need to make your point using such type of argument. As I pointed before, an exact algorithm is one that constructs, within a finite number of steps, a solution &lt;code&gt;x*&lt;/code&gt; and a guarantee that no other feasible solution of better objective value exists (usually by computing lower and upper bounds). No such algorithm will scale to solve every single possible instance on earth, unless of course the problem is trivial. &lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2019-07-10T11:12:00.157" LastActivityDate="2019-07-10T11:12:00.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="938" PostTypeId="2" ParentId="934" CreationDate="2019-07-09T16:05:55.687" Score="10" Body="&lt;p&gt;In addition to the other answers posted already, I'll add that the term &lt;strong&gt;approximation algorithm&lt;/strong&gt; means an algorithm with a provable worst-case error bound that (as @MarcoLubbecke reminded me in the comments) has polynomial runtime. But the term is often misused to refer to a &lt;em&gt;heuristic&lt;/em&gt; that may or may not have such a provable bound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would have interpreted the term &lt;strong&gt;approximate algorithm&lt;/strong&gt; as roughly equivalent to &lt;em&gt;heuristic&lt;/em&gt;, with or without error bounds. From others' answers, it seems they would disagree, and that they would argue that &lt;em&gt;approximate algorithm&lt;/em&gt; = &lt;em&gt;approximation algorithm&lt;/em&gt;. From a purely linguistic point of view, that certainly seems preferable; it would be really annoying if &lt;em&gt;-e&lt;/em&gt; and &lt;em&gt;-ion&lt;/em&gt; meant two very different things. But I am not sure I have seen the terms used this way consistently.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-07-09T20:24:15.843" LastActivityDate="2019-07-09T20:24:15.843" CommentCount="18" ContentLicense="CC BY-SA 4.0" />
  <row Id="939" PostTypeId="1" CreationDate="2019-07-09T16:11:42.357" Score="11" ViewCount="259" Body="&lt;p&gt;When solving a routing problem with time windows, unless you go for the arc-based math program that describes it, you have to check time windows &quot;manually.&quot; For example, generating routes with any procedure would require this verification in the route generation process. Are there computational (or numerical or mathematical) tricks to perform this constraint verification quickly for a given route (sequence of nodes)? In particular (and this is the harder case) when you can't wait until the time window starts (meaning, can't arrive way too early to a location).&lt;/p&gt;&#xA;" OwnerUserId="602" LastEditorUserId="38" LastEditDate="2019-07-09T16:14:32.930" LastActivityDate="2019-07-09T22:40:05.520" Title="Fast validation of time windows in a routing problem" Tags="|constraint|vehicle-routing|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="940" PostTypeId="1" CreationDate="2019-07-09T16:11:46.313" Score="12" ViewCount="219" Body="&lt;p&gt;Does anyone know of any good benchmark problems for combinatorial multi-objective optimisation? Something where pareto frontiers are known for example would be very useful.&lt;/p&gt;&#xA;" OwnerUserId="843" LastEditorUserId="491" LastEditDate="2019-11-25T17:28:48.033" LastActivityDate="2019-11-25T17:28:48.033" Title="Benchmark problems for combinatorial multi-objective optimisation" Tags="|combinatorial-optimization|online-resources|benchmark|multi-objective-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="941" PostTypeId="2" ParentId="939" CreationDate="2019-07-09T16:32:47.043" Score="9" Body="&lt;p&gt;Indeed, as you pointed out already, checking time windows feasibility is only doable in linear time for a given, static, route.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you may exploit preprocessing techniques and partial paths concatenation to achieve constant time worst-case complexity to assess time windows feasibility within a typical routing metaheuristic. Take a look at the &lt;a href=&quot;http://doi.org/10.1016/j.cor.2012.07.018&quot; rel=&quot;noreferrer&quot;&gt;article by T Vidal et al&lt;/a&gt; on the subject.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2019-07-09T16:32:47.043" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="942" PostTypeId="2" ParentId="934" CreationDate="2019-07-09T16:51:05.683" Score="7" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;According to L. Jourdan, et. al.[1], &quot;NP-hard problems are difficult to solve and no polynomial-time algorithms are known for solving them. Most combinatorial optimization problems are NP-hard. Two approaches can be considered to solve this kind of problems depending on their &lt;em&gt;size&lt;/em&gt;. For small instances, researchers usually use &lt;strong&gt;exact&lt;/strong&gt; methods. Exact methods &lt;em&gt;find the optimal solution and assess its optimality&lt;/em&gt;. There exist numerous exact methods such as the family of Branch and X, LP, DP and etc. Exact methods are known to be time expensive, so they can not be applied to large NP-hard problems or difficult ones. When instances become too large for exact methods, heuristics and in particular metaheuristics are often used&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Authors of [2] are also mentioned the &quot;solving-time&quot; of the method for combinatorial optimization problem as the only disjunctive difference between Exact and Approximate methods saying that: &quot;The available techniques for COPs can roughly be classified into two main categories: &lt;em&gt;exact&lt;/em&gt; and &lt;em&gt;heuristic&lt;/em&gt; methods. Exact algorithms are guaranteed to find an optimal solution and to prove its optimality for every instance of a COP. The &lt;em&gt;run-time&lt;/em&gt;, however, often increases dramatically with the instance size, and often only small or moderately-sized instances can be practically solved to provable optimality. In this case, the only possibility for larger instances is &lt;strong&gt;to trade optimality for run-time&lt;/strong&gt;, yielding heuristic algorithms. In other words, the guarantee of finding optimal solutions is sacrificed for the sake of getting good solutions in a limited time.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Last two sentences of the above paragraph explain exactly the approach that you followed in your paper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my interpretation is: &quot;ALL exact methods can solve the large instances of COPs optimally if there are no limitations on their resources in terms of time and computational power, on the other hand, No method can be considered Exact unless the optimality of its solution can be proven.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1]: Jourdan, Laetitia, Matthieu Basseur, and E-G. Talbi. &quot;Hybridizing exact methods and metaheuristics: A taxonomy.&quot; European Journal of Operational Research 199.3 (2009): 620-629.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2]: Puchinger, Jakob, and Günther R. Raidl. &quot;Combining metaheuristics and exact algorithms in combinatorial optimization: A survey and classification.&quot; International Work-Conference on the Interplay Between Natural and Artificial Computation. Springer, Berlin, Heidelberg, 2005.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-07-09T16:51:05.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="943" PostTypeId="2" ParentId="940" CreationDate="2019-07-09T17:36:42.860" Score="9" Body="&lt;p&gt;&lt;a href=&quot;https://voptsolver.github.io/vOptLib/&quot; rel=&quot;noreferrer&quot;&gt;vOptLib&lt;/a&gt;: Library of numerical instances for MultiObjective Linear Optimization problems&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the site:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;vOptLib (short for vector optimization library) is a collection&#xA;  problem instances for benchmarking multi-objective solvers. It covers&#xA;  a variety of Multiobjective linear optimization problems&#xA;  (multiobjective combinatorial problems, multiobjective integer linear&#xA;  programs, multiobjective mixed integer programs).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-07-09T17:36:42.860" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="944" PostTypeId="2" ParentId="940" CreationDate="2019-07-09T17:47:23.130" Score="7" Body="&lt;p&gt;There is also the &lt;em&gt;&lt;a href=&quot;https://github.com/MCDMSociety/MOrepo&quot; rel=&quot;noreferrer&quot;&gt;MOrepo&lt;/a&gt;&lt;/em&gt; maintained by &lt;a href=&quot;https://www.research.relund.dk/&quot; rel=&quot;noreferrer&quot;&gt;Lars Relund Nielsen&lt;/a&gt;. MOrepo describe itself as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;This repository is a response to the needs of researchers from the MCDM society to access multi-objective (MO) optimization instances. The repository contains instances, results, generators etc. for different MO problems and is continuously updated. The repository can be used as a test set for testing new algorithms, validating existing results and for reproducibility. All researchers within MO optimization are welcome to contribute.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The repository consists of a main repository MOrepo at GitHub and a set of sub-repositories, one for each contribution. Sub-repositories are named MOrepo- where name normally is the surname of the first author and year of the study. All repositories are located within the MCDMSociety organization at GitHub.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The main repository contains documentation about how to use and contribute to MOrepo. Moreover, a set of tools are given in the R package MOrepoTools which can be used to retrieve info about test instance groups, results and problem classes.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2019-07-09T17:47:23.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="945" PostTypeId="2" ParentId="924" CreationDate="2019-07-09T20:03:57.263" Score="8" Body="&lt;p&gt;Kevin Dalmeijer's answer is correct for the general case. Since &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is symmetric, there &lt;em&gt;may&lt;/em&gt; be a method that involves fewer constraints. As suggested by Kevin's comment, I'm going to represent a typical equation with the simpler notation &lt;span class=&quot;math-container&quot;&gt;$x^T A x = 0$&lt;/span&gt; (mostly to save typing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A square matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; &lt;em&gt;may&lt;/em&gt; have a &lt;a href=&quot;https://en.wikipedia.org/wiki/Square_root_of_a_matrix&quot; rel=&quot;noreferrer&quot;&gt;square root&lt;/a&gt; &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$BB=A$&lt;/span&gt;. In some cases, such as when &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is positive semidefinite (implying symmetric), the square root is guaranteed to exist and will be symmetric (&lt;span class=&quot;math-container&quot;&gt;$B^T=B$&lt;/span&gt;). (If &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is positive definite, &lt;span class=&quot;math-container&quot;&gt;$x^TAx=0\implies x=0$&lt;/span&gt; and there's not much to solve.) If your &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is such a matrix, you can compute the square root &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; before solving the problem, rewrite &lt;span class=&quot;math-container&quot;&gt;$x^T Ax=0$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$x^TB^TBx=0$&lt;/span&gt;, and observe that this is equivalent to &lt;span class=&quot;math-container&quot;&gt;$Bx=0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-07-09T20:03:57.263" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="946" PostTypeId="1" AcceptedAnswerId="959" CreationDate="2019-07-09T20:18:17.743" Score="8" ViewCount="160" Body="&lt;p&gt;Network flow problems are very well studied in the literature (e.g., see the &lt;a href=&quot;http://mitmgmtfaculty.mit.edu/jorlin/network-flows/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Network Flows book&lt;/a&gt;), and &lt;a href=&quot;http://archive.dimacs.rutgers.edu/Challenges/&quot; rel=&quot;nofollow noreferrer&quot;&gt;the first DIMACS challenge&lt;/a&gt; was dedicated to these problems.&lt;/p&gt;&#xA;&lt;p&gt;Very efficient implementation of state-of-the-art algorithms are available, for instance, in the &lt;a href=&quot;https://lemon.cs.elte.hu/pub/doc/latest/a00005.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;LEMON graph library&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, I am unable find any reference dealing for the special case of “&lt;strong&gt;metric network flow problems&lt;/strong&gt;”, that is, for problems where, given the network &lt;span class=&quot;math-container&quot;&gt;$G=(N,A)$&lt;/span&gt;, the costs coefficients &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; associated to any arc &lt;span class=&quot;math-container&quot;&gt;$(i,j) \in A$&lt;/span&gt; define a &lt;strong&gt;distance function&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{ij} \geq 0$&lt;/span&gt; (&lt;em&gt;non negativity&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{ij} = 0 \iff i=j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{ij} = c_{ji}$&lt;/span&gt; (&lt;em&gt;symmetry&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{ik} \leq c_{ij} + c_{jk}$&lt;/span&gt; (&lt;em&gt;triangle inequality&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Do you know any work related to this case? If yes, does exist standard benchmarks for this case available online?&lt;/p&gt;&#xA;&lt;p&gt;In particular, I am interested to the &lt;em&gt;metric&lt;/em&gt; transportation problem and the &lt;em&gt;metric&lt;/em&gt; minimum cost flow problem.&lt;/p&gt;&#xA;" OwnerUserId="171" LastEditorUserId="491" LastEditDate="2022-11-15T20:56:22.203" LastActivityDate="2022-11-15T20:56:22.203" Title="References for &quot;metric&quot; network flow problems" Tags="|linear-programming|reference-request|online-resources|graphs|network-flow|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="947" PostTypeId="2" ParentId="933" CreationDate="2019-07-09T20:53:45.333" Score="9" Body="&lt;p&gt;Here's a formulation that may be rather large but I think is correct.&lt;/p&gt;&#xA;&lt;h3&gt;Indices:&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i=$&lt;/span&gt; job;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$j=$&lt;/span&gt; worker;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$k=$&lt;/span&gt; discount factor;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$n=$&lt;/span&gt; job count for a worker&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Parameters:&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{i}=$&lt;/span&gt; undiscounted cost of job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_{k}=$&lt;/span&gt; discount factor for doing &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; jobs (&lt;span class=&quot;math-container&quot;&gt;$d_{1}=1.0,d_{2}=0.95,\dots$&lt;/span&gt;);&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$N=$&lt;/span&gt; total number of jobs to be assigned&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Binary variables:&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1$&lt;/span&gt; if job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at discount rate &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{jn}=1$&lt;/span&gt; if worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; gets &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; jobs&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Continuous variables:&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{i}=$&lt;/span&gt; ultimate cost of job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Objective function: &lt;span class=&quot;math-container&quot;&gt;$\min\,\sum\limits_{i}z_{i}$&lt;/span&gt;&lt;/h2&gt;&#xA;&lt;h3&gt;Constraints:&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Assign every job once: &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{j}\sum\limits_{k}x_{ijk}=1\;\forall i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Compute cost of each job: &lt;span class=&quot;math-container&quot;&gt;$z_{i}=\sum\limits_{j}\sum\limits_{k}(d_{k}c_{i})x_{ijk}\ \forall i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Compute &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables: &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i}\sum\limits_{k}x_{ijk}=y_{j1}+2y_{j2}+\dots+Ny_{jN}\ \forall j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Make sure discounts are earned: &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}\le y_{jk}\ \forall i,j,k$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If there are limits on how many jobs a worker can take, that's easily incorporated.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-08-06T15:20:11.530" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="948" PostTypeId="1" AcceptedAnswerId="965" CreationDate="2019-07-09T22:09:23.650" Score="7" ViewCount="516" Body="&lt;p&gt;Let there be &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; users with individual demands (of some items). Some users can have higher demands while the others can have lower demands. There are exactly &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; service points. There is a one-to-one mapping between the users and the service points. At any point in time, only &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; persons can be served, i.e., only &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; service points are activated. There are a total of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; time slots where one time slot is equal to one hour. The &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; service points that are activated simultaneously must not be adjacent. A service point can deliver a given number of items in a time slot. So, a given user can be served during some of the time slots.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my formulation of the scheduling problem becomes&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\max \min&amp;amp;\quad \left\{\frac{s_1}{d_1},\frac{s_2}{d_2},\cdots,\frac{s_N}{d_N}\right\}\\\text{s.t.}&amp;amp;\quad s_n=\sum_{m=1}^MZ(n,m)q_n\\&amp;amp;\quad Z(:,m)^\top{\bf A} Z(:,m)=0\quad&amp;amp;\forall m\in\{1,2,\cdots,M\}\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the objective, the first and second constraints are convex/linear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last constraint is binary quadratic, which is very difficult to solve. Of course we can express it in a different way and linearize it as proposed in &lt;a href=&quot;https://or.stackexchange.com/questions/924/how-can-i-linearize-or-convexify-this-binary-quadratic-optimization-problem&quot;&gt;How can I linearize or convexify this binary quadratic optimization problem?&lt;/a&gt;. With the values I have for &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, the number of resulting linear constraints from the linearization is huge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;span class=&quot;math-container&quot;&gt;$\bf A$&lt;/span&gt; is not a PSD. It has eigenvalues which are both positive and negative.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2019-12-16T23:24:59.047" LastActivityDate="2019-12-16T23:24:59.047" Title="How to formulate this scheduling problem efficiently?" Tags="|mixed-integer-programming|optimization|modeling|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="949" PostTypeId="2" ParentId="939" CreationDate="2019-07-09T22:40:05.520" Score="4" Body="&lt;p&gt;The standard slack time calculation used by various authors takes the last stop in a route (which could be the 'depot' stop), works out the latest feasible time it can be served without breaking its time window, and then propagates this 'latest feasible time' backwards in the route (i.e. to the stop before, the stop before that etc). The back propagation calculation uses open time, travel time etc. Each time it propagates this 'latest feasible time' backwards, it takes the min of 'latest feasible time' from the stops later in the route and the current stop. The result is that for each stop, you get the latest feasible time it can be served without breaking its time window constraint or those later in the route.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding not being able to wait until the time window starts, I'm guessing - but haven't proved mathematically - that you could use this methodology but for each stop calculate the 'earliest feasible time' it can be served instead and when you back propagate, take the max of 'earliest feasible time' instead? You'd presumably only use this 'earliest feasible time' if you're removing or swapping a stop in a route though?&lt;/p&gt;&#xA;" OwnerUserId="825" LastActivityDate="2019-07-09T22:40:05.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="950" PostTypeId="2" ParentId="933" CreationDate="2019-07-10T00:09:34.127" Score="4" Body="&lt;p&gt;This reminds me a little of the maximum expected covering location model (MEXCLP) by &lt;a href=&quot;https://doi.org/10.1287/trsc.17.1.48&quot; rel=&quot;nofollow noreferrer&quot;&gt;Daskin (1983)&lt;/a&gt;. The objective function depends nonlinearly on the number of facilities that cover each customer. Binary decision variables are used to count these assignments, similar to the &lt;span class=&quot;math-container&quot;&gt;$y_{jn}$&lt;/span&gt; variables in @prubin's answer, and (again like in @prubin's answer), the binary variables are added, with appropriate coefficients, in order to calculate the nonlinear cost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a neat trick, and quite general, basically allowing you to model a nonlinear function of the sum of some binary variables.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-07-10T00:09:34.127" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="951" PostTypeId="2" ParentId="928" CreationDate="2019-07-10T02:52:58.900" Score="17" Body="&lt;p&gt;Problem #9 in the list of &lt;a href=&quot;https://en.wikipedia.org/wiki/Smale%27s_problems&quot; rel=&quot;noreferrer&quot;&gt;Smale's Problems&lt;/a&gt; states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The linear programming problem: Find a strongly-polynomial time algorithm which for given matrix &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{m \times n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b \in \mathbb{R}^m$&lt;/span&gt; decides whether there exists &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^n$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$Ax \ge b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If interested in other (not-necessarily OR but in related fields), you can check the following pages too:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_unsolved_problems_in_mathematics&quot; rel=&quot;noreferrer&quot;&gt;List of unsolved problems in mathematics&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_unsolved_problems_in_computer_science&quot; rel=&quot;noreferrer&quot;&gt;List of unsolved problems in computer science&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-07-10T02:52:58.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="952" PostTypeId="5" CreationDate="2019-07-10T02:55:14.320" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-07-10T02:55:14.320" LastActivityDate="2019-07-10T02:55:14.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="953" PostTypeId="4" CreationDate="2019-07-10T02:55:14.320" Score="0" Body="For questions about open problems or questions which are problems that can be accurately stated, and which is assumed to have an objective and verifiable solution, but which has not yet been solved." OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-07-10T13:53:00.390" LastActivityDate="2019-07-10T13:53:00.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="954" PostTypeId="1" CreationDate="2019-07-10T06:43:55.990" Score="22" ViewCount="3334" Body="&lt;p&gt;Consider a standard optimization problem: Minimize an objective function with respect to constraints. My question is: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What does the term &quot;solution of the optimization problem&quot; mean?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first I would think that the answer is obviously:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A solution is a point that produces the smallest objective function value among all feasible possibilites. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But then I notice that people also use the following terms:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;feasible solution&lt;/em&gt; (this implies that even infeasible points may be considered some kind of solutions),&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;optimal solution&lt;/em&gt; (this implies that points that are not optimal may be considered solutions),&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;approximate solutions&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In light of the above one may even speak of &quot;infeasible, non-optimal solutions&quot; which may well just be any point at all, and this is a rather unusual meaning of &quot;solution&quot; - and I suspect that I haven't read this in any paper yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is, maybe, a bit different from what I wrote above. It's more: What is the usual understanding of &quot;solution&quot; without any other qualifier?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;P.S.: I am not sure about how to tag the question. Maybe there are better ones?&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="624" LastEditorUserId="278" LastEditDate="2019-07-10T07:47:04.850" LastActivityDate="2019-07-10T12:44:32.247" Title="What is a solution?" Tags="|terminology|global-optimality|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="955" PostTypeId="2" ParentId="928" CreationDate="2019-07-10T06:54:03.803" Score="12" Body="&lt;p&gt;Here is a list of &lt;a href=&quot;http://www.statslab.cam.ac.uk/~rrw1/research/unsolved.html&quot; rel=&quot;noreferrer&quot;&gt;unsolved (open) problems by R. Weber&lt;/a&gt;. The most fascinating ones in my opinion are the following.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Search for a moving target in discrete time&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The discrete-time version of this problem is still unsolved. There have been partial solutions, but no solution for all possible values of the model parameters.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Non-preemptive release of stochastic jobs to uniform machines&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I make the conjecture that an optimal policy has the property that whenever it assigns a job to an available processor, it makes the assignment to the fastest available processor. Moreover, there exist thresholds, one for each state of the processors and decreasing in the state (seen as a boolean vector, in which busy and idle processors are indicated by 1 and 0, respectively), such that an optimal policy is to assign a job to an available processor if, and only if, the number of jobs in the buffer exceeds the relevant threshold for the present state of the processors.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-07-10T06:54:03.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="956" PostTypeId="2" ParentId="954" CreationDate="2019-07-10T07:12:03.357" Score="14" Body="&lt;p&gt;Great question, @Dirk. People regularly stumble across this, and I believe the notion is not generally agreed upon. Here is how I use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Main qualifiers for a solution are &lt;em&gt;feasible&lt;/em&gt; and &lt;em&gt;optimal&lt;/em&gt;. When nothing is said, I associate with &quot;solution&quot; (without qualifiers) that it is feasible, that is, it satisfies all the constraints. This goes also for &quot;a solution to an optimization problem&quot; where I would &lt;strong&gt;not&lt;/strong&gt; assume that this implies optimality. For optimal solutions I always use the qualifier &lt;em&gt;optimal&lt;/em&gt;, &lt;strong&gt;always&lt;/strong&gt;. A solution can be infeasible. This is strange, but often necessary. For example, I can have a vector of variables which has the right dimension, but this vector does not satisfy all the constraints. Some people would not speak of a solution then, but I'd call it an &quot;infeasible solution&quot;. I need this often, e.g., when I try whether a given vector of variables is feasible for an integer program (in solvers there is usually even a method to check this). Solutions can even be optimal and infeasible, for linear programs exactly the situation when we would apply the dual simplex method.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="36" LastEditDate="2019-07-10T12:44:32.247" LastActivityDate="2019-07-10T12:44:32.247" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="957" PostTypeId="2" ParentId="954" CreationDate="2019-07-10T07:15:48.087" Score="8" Body="&lt;p&gt;I often encounter &lt;strong&gt;a clear difference in the point of view of an operator (business) and a programmer (engineering)&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;From the &lt;strong&gt;business POV: if it's not feasible, it's not a solution.&lt;/strong&gt; Given that an unfeasible solution is useless to them, it's pretty easy to argue this is also the dictionary definition (&lt;em&gt;an answer to, explanation for, or means of effectively dealing with a problem&lt;/em&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;From the &lt;strong&gt;software engineering POV&lt;/strong&gt; however, for very practical reasons, the state of the collection of optimization variables needs to have a name - and &lt;em&gt;solution&lt;/em&gt; is the lesser evil, so it's the best name. And that state can be infeasible, so &lt;strong&gt;solutions can be infeasible&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For example in TSP, such a state could be &lt;code&gt;[Brussels -&amp;gt; Paris -&amp;gt; Amsterdam -&amp;gt; London -&amp;gt; Berlin]&lt;/code&gt;. As your algorithms or a general purpose constraint solver discovers better states (such as &lt;code&gt;[Brussels -&amp;gt; London -&amp;gt; Paris -&amp;gt; Berlin -&amp;gt; Amsterdam]&lt;/code&gt;), it finds better solutions. Now, in the beginning, these solutions might not be feasible. Furthermore, there's often one or more &lt;em&gt;working&lt;/em&gt; solution(s) that can temporarily become infeasible to escape a local optima. But internally in your algorithms or in the constraint solver, that state will still be referred to as the solution, even in those unfeasible cases, for practical reasons.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In our implementation these even goes a step further, as the user define their own &lt;em&gt;custom solution class&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@PlanningSolution&#xA;public class ConferenceSolution {&#xA;&#xA;    private List&amp;lt;Timeslot&amp;gt; timeslotList;&#xA;    private List&amp;lt;Room&amp;gt; roomList;&#xA;    private List&amp;lt;Talk&amp;gt; talkList; // Assign these to timeslots and talks&#xA;&#xA;    private HardMediumSoftScore score;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, if we create a &lt;code&gt;ConferenceSolution&lt;/code&gt; instance for which we assign all those talks in the same timeslot in the same room, that &lt;code&gt;ConferenceSolution&lt;/code&gt; instance is definitely not feasible, so &lt;em&gt;the business users won't agree that it's a solution&lt;/em&gt;...&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2019-07-10T12:00:20.400" LastActivityDate="2019-07-10T12:00:20.400" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="958" PostTypeId="2" ParentId="911" CreationDate="2019-07-10T08:04:24.743" Score="2" Body="&lt;p&gt;I'm no expert on the topic, but I found the textbook &lt;a href=&quot;https://doi.org/10.1017/9781107297340&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimization Methonds in Finance&lt;/a&gt; really accessible. The authors teach optimization modeling and solving motivated by applications in finance, including portfolio optimization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular they describe a linear model using &lt;em&gt;mean absolute deviation&lt;/em&gt; as a linear proxy for variance.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-07-10T08:04:24.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="959" PostTypeId="2" ParentId="946" CreationDate="2019-07-10T08:08:07.993" Score="4" Body="&lt;p&gt;The following references do not completely answer the idea of a &lt;em&gt;metric&lt;/em&gt; (that satisfies the triangle inequality) as said by the OP they are still useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under network flow, &lt;a href=&quot;https://pemami4911.github.io/cs-dojo/algorithms-geometric-transportation.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Emami (2018)&lt;/a&gt; describes several algorithms that can be used to tackle the geometric transportation problem.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;em&gt;exact geometric algorithm&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The main contribution of this paper is that, when the ground distance is the &lt;span class=&quot;math-container&quot;&gt;$l_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$l_2$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;$l_\infty$&lt;/span&gt; norm, the algorithm runs in &lt;span class=&quot;math-container&quot;&gt;$\mathcal O(n^{2.5}\log n \log N)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The author describes the results by &lt;a href=&quot;https://link.springer.com/article/10.1007/BF01190848&quot; rel=&quot;nofollow noreferrer&quot;&gt;Atkinson and Vaidya (1995)&lt;/a&gt; through the &lt;a href=&quot;https://en.wikipedia.org/wiki/Weighted_Voronoi_diagram&quot; rel=&quot;nofollow noreferrer&quot;&gt;weighted Voronoi diagram&lt;/a&gt; (WVD). Where this fits into the question is that in such a diagram, the distance between cells can satisfy the standard Euclidean metric.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;em&gt;approximate geometric algorithm&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In fact, there are two such algorithms proposed by &lt;a href=&quot;http://drops.dagstuhl.de/opus/volltexte/2017/7234/pdf/LIPIcs-SoCG-2017-7.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Agarwal &lt;em&gt;et al.&lt;/em&gt; (2017)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The first is a randomized &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-approximation algorithm that finds the optimal&#xA;  transportation in &lt;span class=&quot;math-container&quot;&gt;$\mathcal O(n^{1+\epsilon})$&lt;/span&gt; expected time whose expected cost is &lt;span class=&quot;math-container&quot;&gt;$\mathcal O(\log(1/\epsilon))\mu(\tau^*)$&lt;/span&gt; if the spread of &lt;span class=&quot;math-container&quot;&gt;$A \cup B$&lt;/span&gt; is bounded by some polynomial. This algorithm uses randomly-shifted grids to recursively decompose the problem into a set of easier subproblems that are solved by Orlin’s algorithm.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The second algorithm described is a &lt;span class=&quot;math-container&quot;&gt;$(1 + \epsilon)$&lt;/span&gt; approximation algorithm&#xA;  that finds a transportation plan with cost &lt;span class=&quot;math-container&quot;&gt;$(1 + \epsilon)\mu(\tau^*)$&lt;/span&gt; in time&#xA;  &lt;span class=&quot;math-container&quot;&gt;$\mathcal O(n^{1.5}\epsilon^{-d}\operatorname{polylog}(U)\operatorname{polylog}(n))$&lt;/span&gt;. The algorithm constructs an efficient representation of the pairwise distances between the point sets, and then makes use&#xA;  of Lee and Sidford’s min-cost flow algorithm on the resulting flow graph.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;NB There is a post here on OR.SE that explains the difference between &lt;a href=&quot;https://or.stackexchange.com/questions/934/optimization-terminology-exact-v-approximate&quot;&gt;&lt;em&gt;exact&lt;/em&gt; and &lt;em&gt;approximate&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, there is an older paper by &lt;a href=&quot;https://www.jstor.org/stable/25769287?seq=1#metadata_info_tab_contents&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lim &lt;em&gt;et al.&lt;/em&gt; (2006)&lt;/a&gt; that studies a transportation problem with &lt;em&gt;minimum quality commitment&lt;/em&gt; (MQC).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The transportation problem with MQC can be classified into two classes: the metric version and the non-metric version. The metric version makes the restriction that the transportation costs satisfy the triangular inequality. In other words, in the metric version, &lt;span class=&quot;math-container&quot;&gt;$c_{i,j}$&lt;/span&gt; depends on the distance between the location of carrier &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and the location of customer &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; which forms a metric. The metric version is practical in some real applications. [...] This paper focuses on the non-metric version of the transportation problem with MQC; in terms of the computational complexities [...] The other [heuristic] is a greedy heuristic, whose solution quality depends on the scale of the minimum quantity when the transportation cost forms a distance metric.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is also proven that the transportation problem with MQC and metric transportation costs in &lt;span class=&quot;math-container&quot;&gt;$\sf{NP}$&lt;/span&gt;-hard.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Emami, P. (2018). Algorithms for the Geometric Transportation&#xA;Problem. Available from: &lt;a href=&quot;https://pemami4911.github.io/cs-dojo/algorithms-geometric-transportation.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pemami4911.github.io/cs-dojo/algorithms-geometric-transportation.pdf&lt;/a&gt;. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] Atkinson, D. S., Vaidya, P. M. (1995) Using geometry to solve the transportation problem in the plane. &lt;em&gt;Algorithmica.&lt;/em&gt; &lt;strong&gt;13&lt;/strong&gt;(5):442–461. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [3] Agarwal, P. K., Fox, K., Panigrahi, D., Varadarajan, K. R., Xiao, A. (2017). Faster algorithms for the geometric transportation problem.&#xA;&lt;em&gt;Proceedings of the 33rd International Symposium on Computational&#xA;Geometry (SoCG 2017).&lt;/em&gt; &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [4] Lim, A., Wang, F., Xu, Z. (2006). A Transportation Problem with Minimum Quantity Commitment. &lt;em&gt;Transportation Science.&lt;/em&gt; &lt;strong&gt;40&lt;/strong&gt;(1):117-129. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-07-10T08:16:19.783" LastActivityDate="2019-07-10T08:16:19.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="960" PostTypeId="2" ParentId="954" CreationDate="2019-07-10T08:57:08.630" Score="6" Body="&lt;p&gt;I mostly agree with Marco Lübbecke. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to add that &quot;vectors of the right dimension&quot; are sometimes called solution candidates. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also when we refer to an &quot;infeasible solution&quot; we often mean that a piece of software determined that the problem is infeasible, not an actual vector of values.&lt;/p&gt;&#xA;" OwnerUserId="47" LastActivityDate="2019-07-10T08:57:08.630" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="961" PostTypeId="2" ParentId="954" CreationDate="2019-07-10T10:45:54.877" Score="6" Body="&lt;p&gt;Here are  two more &quot;dimensions&quot; to the question which have not yet been addressed in any of the other answers, but can be of great significance in practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Global optimum vs. local optimum&lt;/strong&gt;: I will first assume that only globally optimal solutions are of interest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let us just consider feasible and globally optimal solutions to the problem. What does the solution consist of?  It can be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) &lt;strong&gt;Optimal argument values&lt;/strong&gt;, i.e., argopt.  This is argmin for minimization and argmax for maximization&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) &lt;strong&gt;Optimal objective value&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if there is a unique argopt, a complete description of the optimal solution consists of the argopt and the optimal objective value.  However, there are some problems for which the &quot;user&quot; of the solution does not care about both. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, in worst case engineering analysis, the user may only care about the worst case objective value (or a good enough bound for it), but not care at all the argopt achieving it. The user may choose to use a lower bound on the optimal objective value (for a minimization problem), obtained from convex relaxation in a global optimization algorithm, if the gap is below a specified tolerance; and not have, or care about, an argument value which achieves it. So that problem is &quot;solved&quot; without having an optimal argument value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, if the objective function is only a proxy for (or inaccurate approximation or statistical estimation of) the &quot;true: objective function, then in some cases, only the argopt may be of interest. Furthermore, if the optimal argument value is not unique, there is more than one argopt. The user may or may not care about getting all argopts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For users only interested in optimal objective value, closeness of an approximate solution to the exact optimal solution is based on closeness of objective values. For users only interested in optimal argument value, closeness of an approximate solution to the exact optimal solution is based on closeness of argument values between approximate and exactly optimal solutions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for globally vs. locally optimal solutions. Some users are only interested in globally optimal solutions. Other users consider any locally (or globally) optimal solution to be a &quot;solution&quot;. Depending on the user, a solution might consist of a (any) single locally or globally optimal solution, or of all locally optimal solutions.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-07-10T10:51:05.867" LastActivityDate="2019-07-10T10:51:05.867" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="962" PostTypeId="1" CreationDate="2019-07-10T10:57:47.130" Score="41" ViewCount="6772" Body="&lt;p&gt;Can someone give me some suggestions for projects that use both machine learning/deep learning and operations research to solve business problems? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Background: I am a student in OR and I am learning ML/DL on my own, I will graduate next year. My idea is to convince recruiters of my abilities by building a small portfolio with 2 or 3 projects that use both of the fields. I will deploy the models by making web/mobile apps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: A possible interplay is explained in the first five minutes of &lt;a href=&quot;https://www.youtube.com/watch?v=jJgdJaCo568&quot; rel=&quot;noreferrer&quot;&gt;this talk&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2019-07-10T11:20:08.107" LastActivityDate="2021-09-29T16:40:05.963" Title="Machine learning and operations research projects" Tags="|machine-learning|" AnswerCount="11" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="963" PostTypeId="2" ParentId="962" CreationDate="2019-07-10T11:09:49.720" Score="8" Body="&lt;p&gt;Machine learning can sometimes be used to create inputs into an optimisation problem. For example, we make a commercial vehicle route optimisation system for dynamic/realtime routing. Travel times between locations are an input into the optimisation algorithm. We have a module which uses machine learning to estimate travel times from historic journey data, which is then fed into the optimisation algorithm.&lt;/p&gt;&#xA;" OwnerUserId="825" LastActivityDate="2019-07-10T11:09:49.720" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="964" PostTypeId="2" ParentId="962" CreationDate="2019-07-10T11:13:19.400" Score="15" Body="&lt;p&gt;You can have a look at the program of the &lt;a href=&quot;https://www.math.uwaterloo.ca/~bico/co759/2018/index.html&quot; rel=&quot;noreferrer&quot;&gt;Deep Learning in Discrete Optimization&lt;/a&gt; by William Cook. In addition to the references to material relevant to your question, you can find at the end of the page a small section about 7 possible &quot;&lt;em&gt;final projects&lt;/em&gt;&quot;. An update list of references and projects is available on &lt;a href=&quot;http://www.ams.jhu.edu/~wcook12/dl/index.html&quot; rel=&quot;noreferrer&quot;&gt;2019 version of the course&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those projects do not look like explicit business projects. Nevertheless, they are indeed very important for business. Take for instance project 3: &quot;&lt;em&gt;Displacement Activity: Improving local-search methods using deep neural networks&lt;/em&gt;&quot;. Local search is a fundamental component in several commercial solvers, both in general-purpose solvers or dedicated solvers (e.g., vehicle routing solvers). If you can improve the state-of-the-art of local search algorithms by using deep neural networks, this will place you in a very good shape in front of recruiters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Concerning the web/mobile app comment, please, note the William Cook is the author of a &lt;a href=&quot;https://apps.apple.com/us/app/concorde-tsp/id498366515&quot; rel=&quot;noreferrer&quot;&gt;very nice App about the TSP&lt;/a&gt;: maybe you can get inspired by his app.&lt;/p&gt;&#xA;" OwnerUserId="171" LastEditorUserId="171" LastEditDate="2019-07-10T12:54:09.773" LastActivityDate="2019-07-10T12:54:09.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="965" PostTypeId="2" ParentId="948" CreationDate="2019-07-10T12:10:41.693" Score="6" Body="&lt;p&gt;I would rephrase the model a bit not using OP's matrix formulation. Instead of a matrix I will use binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{st}$&lt;/span&gt; indicating whether a service point &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is active in time slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Using the same two constraints and reformulating the &lt;span class=&quot;math-container&quot;&gt;$\min$&lt;/span&gt; in the objective function and the last constraint to be linear we arrive at the following model:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;\text{maximize}  &amp;amp; v \\&#xA;\text{subject to}&amp;amp; \forall m=1,\ldots,M: \sum\limits_{n=1}^N z_{nm} \leq P \\&#xA;&amp;amp;\forall n=1,\ldots,N: s_n = \sum\limits_{m=1}^M z_{nm}q_n \\&#xA;&amp;amp;\forall n=1,\ldots,N: v \leq \dfrac{1}{d_n}s_n\\&#xA;&amp;amp;\forall  m=1,\ldots,M \,\forall (n_1, n_2)\in A \text{ where } A_{n_1 n_2}=1: z_{n_1m} + z_{n_2m} \leq 1\\&#xA;&amp;amp;\forall m=1,\ldots,M \,\forall n=1,\ldots,N: z_{nm} \in \{0,1\}&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="123" LastEditDate="2019-12-07T14:34:44.200" LastActivityDate="2019-12-07T14:34:44.200" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="966" PostTypeId="2" ParentId="962" CreationDate="2019-07-10T12:33:55.837" Score="5" Body="&lt;p&gt;ML + Optimization makes a lot of sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me quote &lt;a href=&quot;https://medium.com/inside-machine-learning/decision-optimization-and-machine-learning-complementary-techniques-for-an-ai-driven-future-98f4e4794c5d&quot; rel=&quot;noreferrer&quot;&gt;https://medium.com/inside-machine-learning/decision-optimization-and-machine-learning-complementary-techniques-for-an-ai-driven-future-98f4e4794c5d&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The interplay between Decision Optimization and Machine learning is best appreciated when one understands how each technique complements the other. Machine Learning models bring the ability to provide accurate forecasts (demand forecasts, equipment failure predictions, etc.) by considering real-time inputs as well as historical data. While a reliable forecast is invaluable, having the ability to make analytics-driven decisions around the best course of action to take is priceless. This can be accomplished by feeding the forecasts generated by machine-learning models as inputs to a Decision Optimization model that can then consider the various tradeoffs and constraints to recommend the optimal solution to meet business goals.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;On the other hand, once an optimization model has recommended an&#xA;  action plan and that plan is in operation, the data on the execution&#xA;  of that plan can be used by machine-learning models to improve&#xA;  forecasts, to automatically make the decision models more accurate,&#xA;  and to hedge against risks.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And IBM Watson Studio offers &lt;a href=&quot;https://medium.com/ibm-watson/decision-optimization-is-now-available-in-watson-studio-66e834220ed2&quot; rel=&quot;noreferrer&quot;&gt;both&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I work for IBM &lt;a href=&quot;https://stackexchange.com/users/4592706/alex-fleischer&quot;&gt;https://stackexchange.com/users/4592706/alex-fleischer&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2019-07-10T14:03:29.980" LastActivityDate="2019-07-10T14:03:29.980" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="967" PostTypeId="2" ParentId="962" CreationDate="2019-07-10T12:58:26.943" Score="11" Body="&lt;p&gt;Here two examples that would combine OR and ML swiftly:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Suppose you have a math program in which the objective function can only be computed via simulation (very realistic engineering problem). Since you can’t tackle such an objective function in a math program, you could use a regression (to keep things simple for now) to estimate the objective function (your predictors are the values of the decision variables and your label is the output of the simulation). Since you need many solutions (and simulations of those solutions) to get a good estimate, you probably need to run multiple iterations of the math program and the simulation to enrich the regression. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Doing the opposite is also possible. Now you want a MIP to solve a (say) logistic regression problem. In the MIP world, you can write any constraint such as: “at most &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; non-zero predictors”. For example check &lt;a href=&quot;https://arxiv.org/abs/1507.03133&quot; rel=&quot;noreferrer&quot;&gt;Bertsimas&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="602" LastEditorUserId="36" LastEditDate="2019-07-10T14:53:36.933" LastActivityDate="2019-07-10T14:53:36.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="968" PostTypeId="2" ParentId="962" CreationDate="2019-07-10T13:27:42.343" Score="19" Body="&lt;p&gt;There are &lt;em&gt;tons&lt;/em&gt; of applications of ML for making &lt;em&gt;forecasts&lt;/em&gt; in business settings, but in my opinion the more interesting approach is to use ML directly to make &lt;em&gt;decisions&lt;/em&gt;—use it for prescriptive, rather than predictive, analytics. In other words, think of ML as essentially nothing more than a (potentially very powerful) heuristic for solving an optimization problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this regard, reinforcement learning (RL) is a natural fit, because it is already designed for optimization; it's basically an approach for solving large-scale MDPs. But even ML tools that are usually used for predictive/descriptive analytics, like neural networks, can be jury-rigged to do optimization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To provide a few examples, we have worked on projects that use &lt;a href=&quot;https://doi.org/10.1080/24725854.2019.1632502&quot; rel=&quot;noreferrer&quot;&gt;deep learning for inventory optimization&lt;/a&gt;, &lt;a href=&quot;https://arxiv.org/abs/1708.05924&quot; rel=&quot;noreferrer&quot;&gt;RL for inventory optimization&lt;/a&gt;, and &lt;a href=&quot;http://papers.nips.cc/paper/8190-reinforcement-learning-for-solving-the-vehicle-routing-problem&quot; rel=&quot;noreferrer&quot;&gt;RL for vehicle routing&lt;/a&gt;. We are not alone in this; there are other groups working on similar approaches. I'm only mentioning these papers as illustrative examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you could create a very interesting project by choosing an OR problem that interests you—vehicle routing, health care scheduling, portfolio optimization, whatever—and using an ML technique as a heuristic for solving it. Packaging it in a nice app is even better.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-07-10T13:27:42.343" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="969" PostTypeId="2" ParentId="911" CreationDate="2019-07-10T13:49:14.463" Score="2" Body="&lt;p&gt;For what it's worth, here's a &lt;a href=&quot;https://www.youtube.com/watch?v=NdyIf0JG94Y&quot; rel=&quot;nofollow noreferrer&quot;&gt;video explanation&lt;/a&gt; and &lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/src/main/java/org/optaplanner/examples/investment&quot; rel=&quot;nofollow noreferrer&quot;&gt;the source code&lt;/a&gt; of my Portfolio Optimization implementation. Run &lt;code&gt;InvestmentApp&lt;/code&gt; to try it yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the sake of having a simple example, we decided to go with expected return (1 year), standard deviation risk and asset correlation. The example xlsx data came from Yahoo Finance IIRC.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2019-07-10T13:49:14.463" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="970" PostTypeId="2" ParentId="928" CreationDate="2019-07-10T13:52:33.987" Score="16" Body="&lt;p&gt;In inventory theory, I would argue that the most significant unsolved question is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What is the optimal inventory policy for a multi-echelon inventory system with at least one distribution node?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A &quot;distribution node&quot; is a node that has at least 2 successors. For serial systems (in which every node has at most one successor and at most one predecessor) and for assembly systems (in which every node has at most one successor), it is well known that a base-stock policy is optimal. But for systems with distribution nodes (which could include one-warehouse multiple-retailer systems, general distribution systems, general tree systems, etc.), the optimal policy is unknown. The primary complication is that in addition to deciding when and how much to order, we also have to decide how to allocate inventory to the successor nodes when the current inventory is insufficient to meet their combined demand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A related question is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In a multi-echelon inventory system with at least one distribution node, if we assume each node follows a base-stock ordering policy and a first-come, first-served allocation policy (whether or not such policies are actually optimal), how can we efficiently optimize the base-stock levels at all nodes?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This one turns out to be hard, too.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-07-10T13:52:33.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="971" PostTypeId="1" CreationDate="2019-07-10T13:59:21.697" Score="11" ViewCount="586" Body="&lt;p&gt;I want some resources (tutorials, online courses, lecture notes, articles, books, etc.) to learn the different techniques to solve OR problems (metaheuristics, CP, MILP, etc). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be better if the resources are &lt;strong&gt;practice-oriented&lt;/strong&gt;, as near as possible to what is actually used in the industry. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: In order to make this question less broad, my background is an MS in applied mathematics with some theoretic-oriented courses in OR. For example, we had some lectures on metaheuristics but we didn't implement any of them. Where can I find some source code or some tutorials that have an open-source code? Same for some techniques used to solve MILP, branch and bound, cutting planes, decomposition methods etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bottom-line : I want to see some codes or some practical insights on using those techniques. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit 2 :  I am looking for is some small pieces of code that help reproduce methods described in papers rather than entire libraries/ general softwares.&lt;/p&gt;&#xA;" OwnerUserId="859" LastEditorUserId="859" LastEditDate="2019-07-10T15:44:20.780" LastActivityDate="2019-07-11T08:02:08.803" Title="Good resources for solving techniques (Metaheuristics, MILP, CP etc)" Tags="|mixed-integer-programming|online-resources|constraint-programming|metaheuristics|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="972" PostTypeId="2" ParentId="971" CreationDate="2019-07-10T14:24:19.250" Score="7" Body="&lt;p&gt;I really liked the &lt;strong&gt;&quot;Discrete Optimization&quot; course at coursera&lt;/strong&gt; - not sure if they still run it.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2019-07-10T14:24:19.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="973" PostTypeId="2" ParentId="911" CreationDate="2019-07-10T14:29:32.160" Score="4" Body="&lt;p&gt;Another aspect of portfolio optimization which is often important in practise is sparsity, i.e., requiring that the portfolio invests in at most &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; non-zero stocks to cut down on transaction fees and avoid functioning as an index fund. This can be achieved by imposing a sparsity constraint &lt;span class=&quot;math-container&quot;&gt;$\Vert x \Vert_0 \leq k.$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The classical reference on this topic is &lt;a href=&quot;https://link.springer.com/content/pdf/10.1007%2FBF02592208.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; 1996 paper by Bienstock.&lt;/p&gt;&#xA;" OwnerUserId="43" LastActivityDate="2019-07-10T14:29:32.160" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="974" PostTypeId="2" ParentId="971" CreationDate="2019-07-10T14:32:53.683" Score="12" Body="&lt;p&gt;You should take a look at a series of three courses at coursera : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.coursera.org/learn/basic-modeling&quot; rel=&quot;noreferrer&quot;&gt;Basic Modeling for Discrete Optimization&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.coursera.org/learn/solving-algorithms-discrete-optimization&quot; rel=&quot;noreferrer&quot;&gt;Solving Algorithms for Discrete Optimization&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.coursera.org/learn/advanced-modeling&quot; rel=&quot;noreferrer&quot;&gt;Advanced Modeling for Discrete Optimization&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They use MiniZinc as modeling language. &lt;/p&gt;&#xA;" OwnerUserId="858" LastActivityDate="2019-07-10T14:32:53.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="975" PostTypeId="1" AcceptedAnswerId="976" CreationDate="2019-07-10T15:21:11.313" Score="2" ViewCount="123" Body="&lt;p&gt;Let's observe an example constraint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum \limits^E_{e\ \in \ A_a \ \cap \ B_b \ \cap \ C_c} x_{e,a,b,c} \geq n_{a,b,c} \; \; \; \forall a \in A,b \in B,c \in C$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$e \in E$&lt;/span&gt; an element and &lt;span class=&quot;math-container&quot;&gt;$A_a$&lt;/span&gt; a set containing elements &lt;em&gt;e&lt;/em&gt; with the attribute &lt;em&gt;a&lt;/em&gt;, &lt;span class=&quot;math-container&quot;&gt;$B_b$&lt;/span&gt; a set containing elements &lt;em&gt;e&lt;/em&gt; with the attribute &lt;em&gt;b&lt;/em&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_c$&lt;/span&gt; a set containing elements &lt;em&gt;e&lt;/em&gt; with the attribute &lt;em&gt;c&lt;/em&gt; and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; a parameter and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; a decision variable.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it even possible to write this constraint only for the combinations that exist without using the following part &lt;span class=&quot;math-container&quot;&gt;$\forall a \in A,b \in B,c \in C$&lt;/span&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example could be &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; a set of airplanes, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; a set of altitude capabilities, &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; a set of different wheelbase and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; a set of colors. Not all combinations exist.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;If not, what happens to a solver when for a &lt;em&gt;parameter&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$n_{a,b,c}$&lt;/span&gt; and &lt;em&gt;decision variable&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$x_{e,a,b,c}$&lt;/span&gt; there is no combination set from the user? Do these appear for the solver?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The goal is to avoid unnecessary zero parameters and variables.&lt;/p&gt;&#xA;" OwnerUserId="456" LastActivityDate="2019-07-10T15:42:05.330" Title="Reduction of Unnecessary Parameters and Variables in an MIP" Tags="|mixed-integer-programming|optimization|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="976" PostTypeId="2" ParentId="975" CreationDate="2019-07-10T15:42:05.330" Score="6" Body="&lt;p&gt;Because I see that your summation goes over all &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; in the intersection of the sets, (from an implementation standpoint) I would approach this problem by first creating the intersection set which contains the desired parameters. So, think of it like several loops where you check whether element &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; exists in each of the sets &lt;span class=&quot;math-container&quot;&gt;$A, B$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; and then you add &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; that exists in all (intersection) as your decision variable. Now, rather than all those loops, first, create the desired set (let's call it &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;) and then only iterate over &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;. That works for &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; too. If you save them in a dictionary or hash table (again, implementation-wise), you are avoiding all the unnecessary &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; parameters and variables creation.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-07-10T15:42:05.330" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="977" PostTypeId="2" ParentId="971" CreationDate="2019-07-10T17:01:59.753" Score="6" Body="&lt;p&gt;I'm bringing my comment here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case you are looking for some code to see how these types of problems are implemented, check out &lt;a href=&quot;https://github.com/ekhoda/optimization-tutorial&quot; rel=&quot;noreferrer&quot;&gt;this repo&lt;/a&gt;. I created a small production planning example for the sake of tutorial and solved it by 2 commercial solvers (Gurobi and CPLEX) and PuLP as the open-source package. I used a simple script and then a more robust (for lack of a better word) object-oriented approach. There is no specific method or heuristic implementation in there, it's just pure coding of a MIP model, but you may find it useful or a good place to start.&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-07-10T17:09:24.787" LastActivityDate="2019-07-10T17:09:24.787" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="978" PostTypeId="2" ParentId="828" CreationDate="2019-07-10T18:13:23.230" Score="7" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;In chapter 10 of his dissertation [1], Gabriel Tavares, talked about some real-world applications of QUBO. He also proposed a new approach to solve QUBOs by modifying some of the previously existed methods.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Authors in [2], listed a wide range of important optimization problems that the QUBO model encompasses:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Quadratic Assignment Problems &lt;/li&gt;&#xA;&lt;li&gt;Capital Budgeting Problems&lt;/li&gt;&#xA;&lt;li&gt;Multiple Knapsack Problems&lt;/li&gt;&#xA;&lt;li&gt;Task Allocation Problems (distributed computer systems)&lt;/li&gt;&#xA;&lt;li&gt;Maximum Diversity Problems&lt;/li&gt;&#xA;&lt;li&gt;P-Median Problems&lt;/li&gt;&#xA;&lt;li&gt;Asymmetric Assignment Problems&lt;/li&gt;&#xA;&lt;li&gt;Symmetric Assignment Problems&lt;/li&gt;&#xA;&lt;li&gt;Side Constrained Assignment Problems&lt;/li&gt;&#xA;&lt;li&gt;Quadratic Knapsack Problems&lt;/li&gt;&#xA;&lt;li&gt;Constraint Satisfaction Problems (CSPs)&lt;/li&gt;&#xA;&lt;li&gt;Set Partitioning Problems&lt;/li&gt;&#xA;&lt;li&gt;Fixed Charge Warehouse Location Problems&lt;/li&gt;&#xA;&lt;li&gt;Maximum Clique Problems&lt;/li&gt;&#xA;&lt;li&gt;Maximum Independent Set Problems&lt;/li&gt;&#xA;&lt;li&gt;Maximum Cut Problems&lt;/li&gt;&#xA;&lt;li&gt;Graph Coloring Problems&lt;/li&gt;&#xA;&lt;li&gt;Graph Partitioning Problems&lt;/li&gt;&#xA;&lt;li&gt;Number Partitioning Problems&lt;/li&gt;&#xA;&lt;li&gt;Linear Ordering Problems&lt;/li&gt;&#xA;&lt;li&gt;Number Partitioning Problems.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In [3], which is a tutorial of modeling and solving combinatorial optimization problems, the authors mention illustrative computational examples of using QUBO in modeling and solving real-world problems in section 5 of the paper including the following examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Warehouse Location: (Single source, Uncapacitated)&lt;/li&gt;&#xA;&lt;li&gt;Constraint Satisfiability problems (CSPs)&lt;/li&gt;&#xA;&lt;li&gt;Quadratic Knapsack Problems&lt;/li&gt;&#xA;&lt;li&gt;Maximum Diversity&lt;/li&gt;&#xA;&lt;li&gt;Set Partitioning&lt;/li&gt;&#xA;&lt;li&gt;Vertex Coloring&lt;/li&gt;&#xA;&lt;li&gt;Maximum Clique (Max Independent Set)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;These are some of the interesting papers that I found in the literature (because of my curiosity - I am not an expert in this field). I believe there should be some valuable clues to follow, in these papers.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] Tavares, Gabriel. New algorithms for Quadratic Unconstrained Binary Optimization (QUBO) with applications in engineering and social sciences. Diss. Rutgers University-Graduate School-New Brunswick, 2008.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] Glover, Fred, Gary Kochenberger, and Yu Du. &quot;A Tutorial on Formulating and Using QUBO Models.&quot; (2019).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[3] Kochenberger, Gary A., and Fred Glover. &quot;A unified framework for modeling and solving combinatorial optimization problems: A tutorial.&quot; Multiscale Optimization Methods and Applications. Springer, Boston, MA, 2006. 101-124.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-07-10T18:38:19.680" LastActivityDate="2019-07-10T18:38:19.680" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="979" PostTypeId="2" ParentId="962" CreationDate="2019-07-10T21:35:17.100" Score="21" Body="&lt;p&gt;Besides the &amp;quot;obvious&amp;quot; marriage of ML and optimization (namely, use ML to prepare the input for optimization), there can be combinations that make use of the respective strengths: ML is good for decisions that are repetitive, ill-structured, simple in their solution; opt is good for well-structured situations, complex in their solution. Thus, a combination can work well eg to make a base plan with optimization and react to disturbances with ML. A preprint that employs ML and optimization to deal with different information statii for tactical and operational decisions is by Larsen et al. on &lt;a href=&quot;http://cerc-datascience.polymtl.ca/wp-content/uploads/2019/03/Technical-Report_DS4DM-2019-003.pdf&quot; rel=&quot;noreferrer&quot;&gt;Predicting Tactical Solutions to Operational Planning Problems under Imperfect Information&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="491" LastEditDate="2020-10-22T02:31:16.463" LastActivityDate="2020-10-22T02:31:16.463" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="980" PostTypeId="1" AcceptedAnswerId="983" CreationDate="2019-07-10T23:43:10.960" Score="22" ViewCount="1086" Body="&lt;p&gt;I am interested in evaluating and &lt;em&gt;demonstrating&lt;/em&gt; various aspects of the performance of general solvers for mathematical optimization problems (in particular MILPs). I assume that I have a good testset of instances. What &amp;quot;revealing&amp;quot; experiments should/could I perform, and more importantly, what graphical presentations can I provide to convey certain key aspects? These may refer to information on the testset, on the solver, on several different settings/versions of the solver, on particular aspects of the solver, etc. I am particularly interested in example figures from papers or talks.&lt;/p&gt;&#xA;&lt;p&gt;Examples:&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Performance variability&lt;/em&gt; displayed using the instance &lt;code&gt;enlight13&lt;/code&gt;: 100 runs of the same instance, each time with differently permuted input, and resulting CPU times; taken from the &lt;a href=&quot;http://mpc.zib.de/index.php/MPC/article/view/56&quot; rel=&quot;noreferrer&quot;&gt;MIPLIB2010 paper&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PfkHz.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PfkHz.png&quot; alt=&quot;performance variability&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s101070100263&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;Performace profiles&lt;/em&gt;&lt;/a&gt; for different solvers on the same test set, the further &amp;quot;top left&amp;quot;, the better.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZbiPf.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZbiPf.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;What other graphical aids do you find enlightening when evaluating solvers?&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-07-11T19:55:24.987" Title="How to (graphically) present computational results?" Tags="|computational-experiments|visualization|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="981" PostTypeId="5" CreationDate="2019-07-10T23:46:39.163" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-07-10T23:46:39.163" LastActivityDate="2019-07-10T23:46:39.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="982" PostTypeId="4" CreationDate="2019-07-10T23:46:39.163" Score="0" Body="For questions on experimentation in computational OR, for example, the performing, analysing and reporting of experiments." OwnerUserId="354" LastEditorUserId="123" LastEditDate="2019-07-29T11:29:49.697" LastActivityDate="2019-07-29T11:29:49.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="983" PostTypeId="2" ParentId="980" CreationDate="2019-07-11T07:24:52.807" Score="9" Body="&lt;p&gt;Some further plots that can be helpful are bar charts with the type of solver going along the horizontal axis and the number of problem instances on the vertical axis. However, each bar is colour-coded with certain proportions that can indicate how &quot;successful&quot; a solver is compared to others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s11081-018-9411-8&quot; rel=&quot;noreferrer&quot;&gt;Kronqvist &lt;em&gt;et al.&lt;/em&gt; (2019)&lt;/a&gt; provide several such charts in their paper.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Figure 3 presents statistics regarding the termination of the solvers, e.g., how&#xA;  many errors and timeouts occurred. These values are as reported by the solver, but also include solver crashes where no solution was returned.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rMM1o.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rMM1o.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;PAVER also verifies if the solver runs were completed successfully, e.g., by comparing the objective values returned to known values or bounds; if there is a discrepancy, these instances are given the status failed. Statistics on instances marked as failed are shown in Fig. 4.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that the environment used was PAVER 2.0, which is in fact open source. For further details see &lt;a href=&quot;https://link.springer.com/article/10.1007%2Fs10898-013-0131-5&quot; rel=&quot;noreferrer&quot;&gt;Bussieck &lt;em&gt;et al.&lt;/em&gt; (2014)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Wqe7c.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wqe7c.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Figure 5 shows the number of problems where the solver was able to obtain a solution within 0.1% and 1% of the best-known solution, but not necessarily able to verify optimality. The fgure shows that none of the solvers was able to obtain a solution within 1% of the best-known solution for all of the problems, given the 900 s time limit. For example, BARON was able to obtain a solution within 1% of the optimum for 317 problems, and SHOT obtained such a solution for 320 problems.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CplXn.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CplXn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Kronqvist, J., Bernal, D. E., Lundell, A., Grossmann, I. E. (2019). A review and comparisons of solvers for convex MINLP. &lt;em&gt;Optimization and Engineering.&lt;/em&gt; &lt;strong&gt;20&lt;/strong&gt;(2):397-455. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] Bussieck, M. R., Dirkse, S. P., Vigerske, S. (2014). PAVER 2.0: an open source environment for automated performance analysis of benchmarking data. &lt;em&gt;Journal of Global Optimization.&lt;/em&gt; &lt;strong&gt;59&lt;/strong&gt;(2-3):259-275. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-07-11T07:45:21.630" LastActivityDate="2019-07-11T07:45:21.630" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="984" PostTypeId="2" ParentId="980" CreationDate="2019-07-11T07:38:25.087" Score="10" Body="&lt;p&gt;We've written a &lt;a href=&quot;http://file:///home/ge0ffrey/projects/jboss/just-optaplanner/optaplanner/optaplanner-docs/target/generated-docs/html_single/index.html#benchmarkReport&quot; rel=&quot;noreferrer&quot;&gt;benchmark toolkit&lt;/a&gt; that spits out a html with a number of statistics we find useful. Of these, I'll highlight the ones that I use regularly in bold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Over multiple datasets and multiple algorithms:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Best Score Summary (Graph And Table)&lt;/strong&gt; to see which algorithm works best&lt;/li&gt;&#xA;&lt;li&gt;Best Score Scalability Summary (Graph)&lt;/li&gt;&#xA;&lt;li&gt;Best Score Distribution Summary (Graph)&lt;/li&gt;&#xA;&lt;li&gt;Winning Score Difference Summary (Graph And Table)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Worst Score Difference Percentage (ROI) Summary (Graph and Table)&lt;/strong&gt; for talking to management stakeholders&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Score Calculation Speed Summary (Graph and Table)&lt;/strong&gt;: moves per second - it's a great way to determine constraint calculation efficiency&lt;/li&gt;&#xA;&lt;li&gt;Time Spent Summary (Graph And Table): most of the time, I am working within a fixed time budget, so this is useless then&lt;/li&gt;&#xA;&lt;li&gt;Time Spent Scalability Summary (Graph)&lt;/li&gt;&#xA;&lt;li&gt;Best Score Per Time Spent Summary (Graph)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Per dataset over multiple algorithms:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Best Score Over Time Statistic (Graph And CSV)&lt;/strong&gt;: your second graph - this is by far, the most important graph for me&lt;/li&gt;&#xA;&lt;li&gt;Step Score Over Time Statistic (Graph And CSV): local search specific&lt;/li&gt;&#xA;&lt;li&gt;Score Calculation Speed over time Statistic (Graph And CSV)&lt;/li&gt;&#xA;&lt;li&gt;Best Solution Mutation Over Time Statistic (Graph And CSV): To see how much each new best solution differs from the previous best solution, by counting the number of planning variables which have a different value. In rare occasions this is very useful&lt;/li&gt;&#xA;&lt;li&gt;Move Count Per Step Statistic (Graph And CSV)&lt;/li&gt;&#xA;&lt;li&gt;Memory Use Statistic (Graph And CSV): Not as useful as you'd think in a JVM, due to inaccuracy. For day-to-day checks, I just use VisualVM. For accurate checks, I set up HonestProfiler.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Per dataset and algorithm combination:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Constraint Match Total Best Score Over Time Statistic (Graph And CSV): To see which constraints are matched in the best score (and how much) over time&lt;/li&gt;&#xA;&lt;li&gt;Constraint Match Total Step Score Over Time Statistic (Graph And CSV)&lt;/li&gt;&#xA;&lt;li&gt;Picked Move Type Best Score Diff Over Time Statistic (Graph And CSV)&lt;/li&gt;&#xA;&lt;li&gt;Picked Move Type Step Score Diff Over Time Statistic (Graph And CSV)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here's a VRP example of the 4 statistics in bold (&lt;a href=&quot;https://github.com/kiegroup/optaplanner/blob/master/optaplanner-examples/src/main/java/org/optaplanner/examples/vehiclerouting/app/VehicleRoutingBenchmarkApp.java#L21&quot; rel=&quot;noreferrer&quot;&gt;reproducible with this app&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To see which algorithm worked best across the datasets:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EHJrz.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EHJrz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To talk about Return On Investment to management:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zHqNn.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zHqNn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To measure if the custom constraints are written efficiently:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vwpNn.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vwpNn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To see where we should focus our time on to improve solution quality. The shape of this graph tells a lot. Notice here how the yellow Tabu Search gets temporarily stuck in local optima (a clear sign to invest is smarter neighborhoods). Notice how vanilla Late Acceptance is worst, but adding Nearby Selection in the mix, LA outperforms TS (which reminds me that we might want to write a paper on Nearby Selection, especially parabolic):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/D7BRG.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/D7BRG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They all end up in a report like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yXHsS.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yXHsS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2019-07-11T08:59:51.100" LastActivityDate="2019-07-11T08:59:51.100" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="985" PostTypeId="2" ParentId="971" CreationDate="2019-07-11T08:02:08.803" Score="6" Body="&lt;p&gt;For a basic introduction to OR, you can take a look at the open course on &lt;a href=&quot;https://caseine.org/course/index.php?categoryid=20&quot; rel=&quot;noreferrer&quot;&gt;Caseine&lt;/a&gt;. There is many exercises, some that make you use CPLEX.&lt;/p&gt;&#xA;" OwnerUserId="132" LastActivityDate="2019-07-11T08:02:08.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="986" PostTypeId="1" AcceptedAnswerId="988" CreationDate="2019-07-11T14:55:56.943" Score="15" ViewCount="359" Body="&lt;p&gt;I am looking for (introductory) references on the empirical studies on the practice of OR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mean literature that looks at questions like: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Which methods are used in practice? &lt;/li&gt;&#xA;&lt;li&gt;How do people interact with the optimization software?&lt;/li&gt;&#xA;&lt;li&gt;What factors contribute to the acceptance of optimization software among employees?&lt;/li&gt;&#xA;&lt;li&gt;What is the gap between theory and practice in the algorithms used? &lt;/li&gt;&#xA;&lt;li&gt;How long is the same model used/useful?&lt;/li&gt;&#xA;&lt;li&gt;What is the gap between the solutions output by OR-methods and the solutions implemented?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Maybe one could say all the OR-questions that don't revolve around the OR-methodology (i.e. modeling and solving the models). Or maybe one could say, literature on the things that happen before the modeling or after the development of the algorithm. If there is a book or a review paper, that would be ideal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does such literature exist?&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="36" LastEditDate="2019-07-11T15:11:28.660" LastActivityDate="2019-07-12T07:25:34.677" Title="references on the empirical study on the practice of OR" Tags="|reference-request|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="987" PostTypeId="2" ParentId="828" CreationDate="2019-07-11T15:38:58.927" Score="8" Body="&lt;p&gt;1QBit published a white paper &quot;Optimal feature selection in credit scoring and classification using a quantum annealer&quot;. The authors compare their feature selecting QUBO model to mainstream recursive feature elimination (RFE) methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://qbit.wpengine.com/wp-content/uploads/2017/04/1QBit_-_Optimal-Feature-Selection-in-Credit-Scoring-and-Classification-Using-a-Quantum-Annealer_-_2017.04.13.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://qbit.wpengine.com/wp-content/uploads/2017/04/1QBit_-&lt;em&gt;Optimal-Feature-Selection-in-Credit-Scoring-and-Classification-Using-a-Quantum-Annealer&lt;/em&gt;-_2017.04.13.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quoting from their conclusions:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;QUBO Feature Selection delivered a smaller feature set (24 features) than either recursive feature elimination (28 features) or recursive feature elimination with wrapped cross-validation (31 features). All three methods showed comparable accuracy.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The company has quite a few other related white papers. Their research is interesting if only because they had an actual quantum annealer at their disposal for tackling QUBO and its applications.&lt;/p&gt;&#xA;" OwnerUserId="482" LastEditorUserId="482" LastEditDate="2019-07-16T17:37:59.360" LastActivityDate="2019-07-16T17:37:59.360" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="988" PostTypeId="2" ParentId="986" CreationDate="2019-07-11T16:31:41.653" Score="13" Body="&lt;p&gt;Just about every article in &lt;em&gt;Interfaces&lt;/em&gt;—now called &lt;em&gt;&lt;a href=&quot;https://pubsonline.informs.org/journal/inte&quot; rel=&quot;noreferrer&quot;&gt;INFORMS Journal on Applied Analytics&lt;/a&gt;&lt;/em&gt;—answers at least some of the questions you laid out. I have found these articles to be very valuable as a way to study how OR gets implemented in practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're asking for a sort of meta-study that looks at those questions in the aggregate, rather than for specific projects, I'm not sure if such a study exists, but maybe others can point you to one.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-07-11T16:31:41.653" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="989" PostTypeId="1" AcceptedAnswerId="995" CreationDate="2019-07-11T18:41:46.070" Score="32" ViewCount="5346" Body="&lt;p&gt;It is almost inevitable in Operations Research to come across linear or quadratic programming problems. The overall structures of these problems are below: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\begin{array}{ll}&#xA;\sf{Linear}\\&#xA;\max &amp;amp; \bf c^\top x\\&#xA;\text{s.t.} &amp;amp; A\bf x\le b \\&#xA;\text{and} &amp;amp; \bf x \ge 0&#xA;\end{array}\quad\quad\quad\quad\begin{array}{ll}\sf{Quadratic}\\\min &amp;amp;\frac12{\bf{x^\top}}Q\bf x+c^\top x\\\text{s.t.} &amp;amp; A\bf x\preceq b\\{}\end{array}\end{align}&lt;/span&gt; Both types of programming have their own (if not overlapping) applications; see, for example &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/0305048377900202&quot; rel=&quot;noreferrer&quot;&gt;McCarl &lt;em&gt;et al.&lt;/em&gt; (1977)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have rarely heard of specific names for higher-order programming problems other than the generic &quot;non-linear programming&quot; term.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How much work has gone into the study of cubic/quartic etc. programming? What do the structures of these problems look like, and are there any specific examples of where they can be useful?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] McCarl, B. A., Moskowitz, H., Furtan, H. (1977). Quadratic programming applications. &lt;em&gt;Omega.&lt;/em&gt; &lt;strong&gt;5&lt;/strong&gt;(1):43-55. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-09-22T01:18:20.473" Title="Cubic programming and beyond?" Tags="|reference-request|nonlinear-programming|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="990" PostTypeId="2" ParentId="989" CreationDate="2019-07-11T18:49:26.570" Score="17" Body="&lt;p&gt;I am not sure whether you are looking for &lt;em&gt;polynomial optimization&lt;/em&gt; like &lt;a href=&quot;https://inf.ethz.ch/personal/fukudak/semi/optpast/FS07/opt_abs/PolynomialOptimization.pdf&quot; rel=&quot;noreferrer&quot;&gt;Introduction to concepts and advances in polynomial optimization&lt;/a&gt; by Martin Mevissen, or &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-319-31484-6_12&quot; rel=&quot;noreferrer&quot;&gt;polynomial optimization&lt;/a&gt; by Hoang Tuy?&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="354" LastEditDate="2019-07-11T20:17:45.777" LastActivityDate="2019-07-11T20:17:45.777" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="991" PostTypeId="2" ParentId="989" CreationDate="2019-07-11T19:30:52.183" Score="13" Body="&lt;p&gt;+1 for @MarcoLübbecke&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in addition, this is also known as &quot;Polynomial Programming&quot;. Also look at &lt;a href=&quot;http://www.mit.edu/~parrilo/pubs/files/SDPrelaxations.pdf&quot; rel=&quot;noreferrer&quot;&gt;algebraic geometry and semialgebraic sets&lt;/a&gt;, and sum of squares optimization: &lt;a href=&quot;https://en.wikipedia.org/wiki/Sum-of-squares_optimization&quot; rel=&quot;noreferrer&quot;&gt;Wikipedia&lt;/a&gt; and &lt;a href=&quot;https://web.stanford.edu/class/ee364b/lectures/sos_slides.pdf&quot; rel=&quot;noreferrer&quot;&gt;Lall, 2011&lt;/a&gt;. This leads to such cool things as Sum of Squares Programming (optimization), for which Semidefinite Programming relaxation comes into play.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2019-07-13T12:59:01.893" LastActivityDate="2019-07-13T12:59:01.893" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="992" PostTypeId="2" ParentId="980" CreationDate="2019-07-11T19:55:24.987" Score="6" Body="&lt;p&gt;There are a couple of situations where I would find box plots enlightening. For performance variability (either time to proven optimum or gap at a fixed time limit), box-and-whiskers plots with the performance measure on the vertical axis and the instance identifier on the horizontal axis (so one box per instance) make comparisons of instances easy. Similarly, for a comparison of algorithms, solvers or parameter combinations, performance measure (solution time to optimality or quality at a fixed time limit) on the vertical axis and algorithm/solver/whatever on the horizontal axis works nicely (albeit providing comparisons on only one quality measure).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-07-11T19:55:24.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="993" PostTypeId="5" CreationDate="2019-07-11T20:05:33.470" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-07-11T20:05:33.470" LastActivityDate="2019-07-11T20:05:33.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="994" PostTypeId="4" CreationDate="2019-07-11T20:05:33.470" Score="0" Body="For questions about creating images, diagrams, charts, or animations to present the data (inputs or results) graphically" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-07-11T22:12:49.433" LastActivityDate="2019-07-11T22:12:49.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="995" PostTypeId="2" ParentId="989" CreationDate="2019-07-11T20:36:45.277" Score="22" Body="&lt;p&gt;In addition to the excellent answers that are already posted, I want to add that for the pragmatic optimizer, quadratic may already be sufficient.&lt;/p&gt;&#xA;&lt;p&gt;For example, the cubic constraint &lt;span class=&quot;math-container&quot;&gt;$x^3 \le x$&lt;/span&gt; may be replaced by &lt;span class=&quot;math-container&quot;&gt;$xy \le x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y=x^2$&lt;/span&gt;, which are both quadratic constraints. Note that these constraints are non-convex, which may not be desirable.*&lt;/p&gt;&#xA;&lt;p&gt;Sometimes non-convexity can be avoided. &lt;a href=&quot;https://doi.org/10.1016/S0024-3795(98)10032-0&quot; rel=&quot;noreferrer&quot;&gt;This paper&lt;/a&gt; is full of examples of non-linear models that can be reformulated as second order cone programs, which are convex quadratic problems. Maximizing a product of non-negative affine functions is one of the examples.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt;*In this simple example, you may also overcome the non-linearity by introducing a binary variable. In general, this will not work.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-07-12T05:30:07.483" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="996" PostTypeId="1" AcceptedAnswerId="1038" CreationDate="2019-07-11T22:48:46.467" Score="7" ViewCount="411" Body="&lt;p&gt;I have a scheduling problem at hand. In my system, there is a service station with &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; service outlets, therefore, the service station can serve &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; users at a time. But, there are &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; users &lt;span class=&quot;math-container&quot;&gt;$N&amp;gt;M$&lt;/span&gt; in the system requesting for service. There, the scheduler needs to schedule &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; users out of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; users along with some signal processing. The service station has some money budget. At any point of operation, the money spending for serving &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; users cannot exceed the budget.&#xA;Let us assume that the scheduling frequency is one hour. So, each hour, the service station serves (at most) &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; users.&lt;/p&gt;&#xA;&lt;p&gt;There exists a path between the service point and any user. Let vector &lt;span class=&quot;math-container&quot;&gt;${\bf h}_i\in\mathbb{C}^{M\times 1}$&lt;/span&gt; define the path between the service station and user &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. If user &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is schduled, the amount of money spent after user &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is given by &lt;span class=&quot;math-container&quot;&gt;$||{\bf w}_i||_2^2=P_i$&lt;/span&gt;, where, &lt;span class=&quot;math-container&quot;&gt;${\bf w}_i\in\mathbb{C}^{M\times 1}$&lt;/span&gt; is some financial tool employed by the service station. Note that &lt;span class=&quot;math-container&quot;&gt;${\bf h}_i\in\mathbb{C}^{M\times 1},i=1,2,\dots,N$&lt;/span&gt; are known. Here, &lt;span class=&quot;math-container&quot;&gt;${\bf w}_i, i=1,2,\dots,M$&lt;/span&gt; are optimization variables.&lt;/p&gt;&#xA;&lt;p&gt;The objective of the optimization is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\underset{\mathcal{M}\subset \mathcal{N}}{\max}\hspace{2mm}\underset{{\bf w}_i,i\in \mathcal{M} }{\max}\hspace{2mm}\sum_{i\in\mathcal{M}}\alpha_i \log_2(1+\gamma_i)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{1}&#xA;{\gamma}_i = \frac{\left|\mathbf{h}_i^H\mathbf{w}_i\right|^2}{\sum\limits_{j=1,j\ne i}^N\left|\mathbf{h}_i^H\mathbf{w}_j\right|^2 + {\sigma^2}}.&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in\mathcal{M}}||{\bf w}_i||^2_2\le P$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$\mathcal{M}=\{1,2,\dots,M\}$&lt;/span&gt; is a finite set of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; scheduled users, and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}=\{1,2,\cdots,N\}$&lt;/span&gt; is a finite set of all users. &lt;span class=&quot;math-container&quot;&gt;$\alpha_i$&lt;/span&gt;s are also known positive (&amp;gt;0) numbers.&#xA;Therefore, I want to find the subset &lt;span class=&quot;math-container&quot;&gt;$\mathcal{M}$&lt;/span&gt;, i.e., schedule &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; users out of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; so that the objective is maximized while fulfilling the constraint.&lt;/p&gt;&#xA;&lt;p&gt;Note that this is a complex scheduling problem. Anyway, is this formulation reflecting what I just described?&lt;/p&gt;&#xA;&lt;p&gt;Note: &lt;span class=&quot;math-container&quot;&gt;${\bf w}_i$&lt;/span&gt; is the interference (at user &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;) cancelling vector used at the sevice station.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\textbf{The approach:}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let us introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_i\in\{0,1\}$&lt;/span&gt;. If user &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is scheduled, &lt;span class=&quot;math-container&quot;&gt;$x_i=1$&lt;/span&gt;, else &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt;.&#xA;Now, I have a mixed integer programming problem as below&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\underset{{\bf w}_i }{\max}\sum_{i=1}^N x_i\alpha_i \log_2(1+\gamma_i)$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^N x_i||{\bf w}_i||^2_2\le P$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^Nx_i=M$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i\in\{0,1\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can we deal with the objective and the constraints to have an efficient linear/convex formulation?&lt;/p&gt;&#xA;&lt;p&gt;Can we take advantage of the monotonic behavior of the logarithm in the transformation?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2023-01-24T22:47:47.287" LastActivityDate="2023-01-24T22:47:47.287" Title="How to reformulate (linearize/convexify) a budgeted assignment problem?" Tags="|modeling|nonlinear-programming|linearization|combinatorial-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="997" PostTypeId="1" AcceptedAnswerId="998" CreationDate="2019-07-11T23:45:34.337" Score="8" ViewCount="316" Body="&lt;p&gt;How can I reformat the problem below to follow DCP rules? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;DCP rules are Disciplined Convex Programming Rules that allow convex programs to be solved. &lt;a href=&quot;https://dcp.stanford.edu/&quot; rel=&quot;nofollow noreferrer&quot;&gt;DCP&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to reformat the problem below so that I can solve it with any solver?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to maximize (or minimize) &lt;span class=&quot;math-container&quot;&gt;$x\cdot\min x$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is an array.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import cvxpy as cp&#xA;&#xA;x = cp.Variable(10)&#xA;objective = cp.Maximize(cp.sum(x*cp.min(x)))&#xA;constraints = [x &amp;gt;=0, x&amp;lt;=10]&#xA;prob = cp.Problem(objective, constraints)&#xA;result = prob.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="841" LastEditorUserId="123" LastEditDate="2019-12-27T10:28:54.303" LastActivityDate="2019-12-27T10:28:54.303" Title="Disciplined convex programming representation of $x\cdot\min x$" Tags="|optimization|nonlinear-programming|disciplined-convex-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="998" PostTypeId="2" ParentId="997" CreationDate="2019-07-12T00:29:41.267" Score="8" Body="&lt;p&gt;See &lt;a href=&quot;https://dcp.stanford.edu/&quot; rel=&quot;noreferrer&quot;&gt;https://dcp.stanford.edu/&lt;/a&gt; for an explanation of Disciplined Convex Programming (DCP)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for your problem. First consider the case in which the dimension of &lt;code&gt;x&lt;/code&gt; is 1. Then the objective is &lt;code&gt;x^2&lt;/code&gt;, which is convex, and therefore maximizing it is a non-convex problem, which therefore can not be modeled by DCP. That objective could be minimized however if entered as &lt;code&gt;x^2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the dimension of &lt;code&gt;x&lt;/code&gt; is greater than 1, &lt;code&gt;sum(x)*min(x)&lt;/code&gt; is neither convex nor concave, so neither minimizing nor maximizing it is a convex optimization problem. Therefore, this can not be handled by Disciplined Convex Programming. (DCP). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The one remaining question is whether this problem can be handled by MIDCP - Mixed-Integer DCP. The answer is yes, presuming an ungainly approximation is used.  First of all, replace &lt;code&gt;min(x)&lt;/code&gt; with the scalar continuous variable &lt;code&gt;y&lt;/code&gt;, and add a number of binaries equal to the dimension of &lt;code&gt;x&lt;/code&gt;, and Big M constraints, per the last portion of section 2.2 of &lt;a href=&quot;https://www.fico.com/en/resource-download-file/3217&quot; rel=&quot;noreferrer&quot;&gt;FICO MIP formulations and linearizations Quick reference&lt;/a&gt;. That results in an objective of &lt;code&gt;sum(x)*y&lt;/code&gt;, which can not be handled by DCP. The only way to handle that in MIDCP is to use approximate binary-encoded expansions of both &lt;code&gt;sum(x)&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;, which turns &lt;code&gt;sum(x)*y&lt;/code&gt; into a sum of products of binary variables, each of which can be linearized as shown in section 2.8 of that linked reference. The resulting objective function is linear, as are all constraints (other than binary &quot;constraint&quot;), and therefore this objective can be either maximized or minimized in accordance with MIDCP. That is a horrible mess, which can be implemented in CVXPY and CVX, but I recommend you don't try, except for educational purposes.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2019-07-12T00:29:41.267" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="999" PostTypeId="1" CreationDate="2019-07-12T03:49:51.467" Score="11" ViewCount="1328" Body="&lt;p&gt;Once a model is implemented in PuLP, how do you change a coefficient (e.g.,  &lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt;) of a program of the from &lt;span class=&quot;math-container&quot;&gt;$\min\{c^{\top}x: Ax=b, x\geq0\}$&lt;/span&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to update coefficients or RHSs?&lt;/li&gt;&#xA;&lt;li&gt;Once it is updated, do we have to tell PuLP to update (e.g. in Gurobi we would do &lt;code&gt;model.update()&lt;/code&gt;) ?&lt;/li&gt;&#xA;&lt;li&gt;Does PuLP re-optimize or start from scratch?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="602" LastEditorUserId="123" LastEditDate="2019-11-29T20:28:31.020" LastActivityDate="2020-06-30T13:58:29.083" Title="Change coefficient in PuLP" Tags="|constraint|python|pulp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1000" PostTypeId="2" ParentId="999" CreationDate="2019-07-12T03:49:51.467" Score="10" Body="&lt;p&gt;If the model in PuLP is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import LpProblem, LpVariable, LpMaximize, lpSum&#xA;m = LpProblem(name='example', sense = LpMaximize)&#xA;x = LpVariable.dicts(name='x',indexs=[1,2,3])&#xA;m += lpSum(x) &amp;lt;= 3, 'c1'&#xA;m += lpSum(i*x[i] for i in [1,2,3]), 'obj'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We can access the coefficient of &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; in 'C1' with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;m.constraints['c1'][x[1]] # This the coefficient =&amp;gt; 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and further set it in a pythonic way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;m.constraints['c1'][x[1]] = 2 # Now the coefficient is 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The same is true for the objective function with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;m.objective[x[1]] = 0 # objective coefficient of x_1 is zero&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To chance the RHS, one way is to add or subtract the difference. If the new RHS is 4, we proceed as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;m.constrains['c1'][x[1]] += 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A new call of m.solve() would be required, the value() function for all the objects won't change until the new call of solve().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure about 3, but perhaps a PuLP developer knows. &lt;/p&gt;&#xA;" OwnerUserId="602" LastActivityDate="2019-07-12T03:49:51.467" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1001" PostTypeId="2" ParentId="986" CreationDate="2019-07-12T07:25:34.677" Score="5" Body="&lt;p&gt;Besides the cases published in Interfaces, I recommend taking a look at a series of articles entitled &quot;&lt;a href=&quot;https://pubsonline.informs.org/action/doSearch?field1=Title&amp;amp;text1=The%20Fifth%20Column&amp;amp;field2=Contrib&amp;amp;text2=Gene%20Woolsey&amp;amp;field3=AllField&amp;amp;text3=&amp;amp;publication=&amp;amp;Ppub=&amp;amp;Ppub=&amp;amp;AfterMonth=&amp;amp;AfterYear=&amp;amp;BeforeMonth=&amp;amp;BeforeYear=&amp;amp;sortBy=Ppub&quot; rel=&quot;noreferrer&quot;&gt;The Fifth Column&lt;/a&gt;&quot; by &lt;a href=&quot;https://www.informs.org/ORMS-Today/Public-Articles/June-Volume-42-Number-3/In-Memoriam-Robert-Eugene-Donald-Woolsey-1936-2015&quot; rel=&quot;noreferrer&quot;&gt;Gene Woolsey&lt;/a&gt; in Interfaces. While they may not exactly cover for what you are looking, they convey the ideas and opinions of a great OR practitioner over the course of almost 40 years.&lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2019-07-12T07:25:34.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1002" PostTypeId="2" ParentId="962" CreationDate="2019-07-12T08:01:44.673" Score="8" Body="&lt;p&gt;This is a post that of my interest. I can give you one such example. I am currently working on an optimization problem, where we have a large LNG gas compressor network (eg. a connected graph with nodes as compressors and arcs as trunklines), and the goal is to find the operational conditions of the compressors such that we end up minimizing the total power consumption of the network. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Equations that represent power consumption of the compressors form a part of our objective function and equations like frictional pressure drop, form a part of the constraints for the optimization problem. Realistic plant operations deviate significantly from the ideal physics-based equations and for this reason, we decided to build data-driven models for compressors and frictional pressure drop, where to put simply, we developed a bunch of linear and polynomial regression equations from historical data of the plant that we can later plug into our optimization model. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple of other examples where Optimization meets Machine Learning are here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://c3.ai/resources/blog/re-imagining-inventory-optimization-big-data-artificial-intelligence/&quot; rel=&quot;noreferrer&quot;&gt;Inventory Optimization with Artificial Intelligence&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://medium.com/opex-analytics/machine-learning-for-inventory-optimization-38a9ac86a80a&quot; rel=&quot;noreferrer&quot;&gt;Machine Learning for Inventory Optimization&lt;/a&gt; &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="113" LastEditorUserId="36" LastEditDate="2019-07-12T14:03:04.617" LastActivityDate="2019-07-12T14:03:04.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1003" PostTypeId="2" ParentId="989" CreationDate="2019-07-12T11:56:01.837" Score="11" Body="&lt;p&gt;Thanks to everyone who answered this question for introducing the concept of polynomial programming.&lt;/p&gt;&#xA;&lt;p&gt;From there I have found two papers that link cubic programming to convex programming, and provide some applications of cubic programming problem.&lt;/p&gt;&#xA;&lt;h3&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/BF01918319&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bector (1968)&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;In this paper, indefinite cubic programming is considered. The general structure of the problem is given as &lt;span class=&quot;math-container&quot;&gt;\begin{array}{ll}&#xA;\sf{Cubic}\\&#xA;\max &amp;amp; \left({\bf c^\top x}-{\bf x^\top} P{\bf x}-({\bf x^\top} Q{\bf x})^{\frac12}+\alpha\right)({\bf d^\top x}+\beta)\\&#xA;\text{s.t.} &amp;amp; A\bf x\preceq b \\&#xA;\text{and} &amp;amp; \bf x \ge 0&#xA;\end{array}&lt;/span&gt; where the expression to be optimised is a product of a quadratic term and a linear term. The change of variable &lt;span class=&quot;math-container&quot;&gt;${\bf y}=t{\bf x}$&lt;/span&gt; is introduced, and it is proven that the problem can be reduced to a convex programming one: &lt;span class=&quot;math-container&quot;&gt;\begin{array}{ll}&#xA;\sf{Cubic}\\&#xA;\min &amp;amp; \dfrac{t^2}{{\bf c^\top y}-\frac{{\bf y^\top}P{\bf y}}t-({\bf y^\top}Q{\bf y})^{\frac12}+\alpha t}\\&#xA;\text{s.t.} &amp;amp; A{\bf y}-{\bf b}t\le\bf0 \\&#xA;\text{and} &amp;amp; {\bf{d^\top y}}+\beta t=1\\&#xA;\text{and}&amp;amp;t,\bf x \ge 0&#xA;\end{array}&lt;/span&gt; Finally, the problem is also considered with both terms being quadratic and a similar form is derived.&lt;/p&gt;&#xA;&lt;h3&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/BF02089026&quot; rel=&quot;nofollow noreferrer&quot;&gt;Henin and Doutriaux (1980)&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;In this paper, the convex simplex method is applied to cubic objective functions. Applications of cubic objective functions are provided below.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Portfolio selection: maximising the expected utility of an investor; that is, finding &lt;span class=&quot;math-container&quot;&gt;$\max(AX+BX^2+CX^3)$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$X=\sum\limits_{i=1}^n\alpha_iR_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i=1}^n\alpha_i=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Agricultural research: maximising crop yield when fertiliser amount or type changes; that is, finding &lt;span class=&quot;math-container&quot;&gt;$\max(a_1x+a_2y+a_3z+a_4xy+a_5xz+a_6yz+a_7xyz)$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$$\begin{cases}C_xx+C_yy+C_zz\le C\\x_0\le x\le x_1\\y_0\le y\le y_1\\z_0\le z\le z_1\end{cases}$$&lt;/span&gt; for fertiliser amounts &lt;span class=&quot;math-container&quot;&gt;$x,y,z$&lt;/span&gt; and their respective costs &lt;span class=&quot;math-container&quot;&gt;$C_x,C_y,C_z$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Bector, C. R. (1968). Indefinite cubic programming with standard errors in objective function. &lt;em&gt;Unternehmensforschung.&lt;/em&gt; &lt;strong&gt;12&lt;/strong&gt;(1):113-120. &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [2] Henin, C., Doutriaux, J. (1980). A specialization of the convex simplex method to cubic programming. &lt;em&gt;Rivista di matematica per le scienze economiche e sociali&lt;/em&gt;. &lt;strong&gt;3&lt;/strong&gt;(2):61-72. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-07-30T08:42:42.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1004" PostTypeId="1" CreationDate="2019-07-12T20:50:35.397" Score="4" ViewCount="817" Body="&lt;p&gt;It's noted that the number of folks in a stationary system will maintain an average equal to the rate of arrival multiplied by the mean of the service distribution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The formula &lt;span class=&quot;math-container&quot;&gt;$L = \lambda w$&lt;/span&gt; is valid for any queueing model in steady-state, where &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; are long-term steady-state average values respectively, and &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; denotes the arrival rate to the system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can add up the total service time in the system as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum w_{j} = \sum i T_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$T_i$&lt;/span&gt; represents the time units in which &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; entities were in the system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But things are always more interesting with sample sizing and simulating results, so say in &lt;span class=&quot;math-container&quot;&gt;$5000$&lt;/span&gt; iterations we estimate a state of a system in 1-min intervals, between the first minute and the last arrival at a determined time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So suppose we use a random interarrival rate of &lt;span class=&quot;math-container&quot;&gt;$\lambda = 2$&lt;/span&gt; per minute and the service distribution is &lt;span class=&quot;math-container&quot;&gt;$N(8,1)$&lt;/span&gt; minutes for the system.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I simulate this model in R, using &lt;code&gt;rexp()&lt;/code&gt; and &lt;code&gt;rnorm()&lt;/code&gt;? I also want to display in &lt;code&gt;ts()&lt;/code&gt; to show in time plot.&lt;/p&gt;&#xA;" OwnerUserId="901" LastEditorUserId="38" LastEditDate="2020-01-06T23:43:57.227" LastActivityDate="2020-01-06T23:43:57.227" Title="Queuing models in R, $\lambda$ Little" Tags="|modeling|probability-distributions|simulation|queuing-theory|r|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1006" PostTypeId="2" ParentId="1004" CreationDate="2019-07-13T00:24:47.627" Score="1" Body="&lt;p&gt;So far this is what I have come up with&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-r prettyprint-override&quot;&gt;&lt;code&gt;lambda &amp;lt;- 2&#xA;interarrivals &amp;lt;- rexp(5000,lambda)  ## (2 items per minute)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Provided the &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; we expect that the interarrivals is about half a minute&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-r prettyprint-override&quot;&gt;&lt;code&gt;mean(interarrivals) &amp;lt;- 0.516&#xA;service.times &amp;lt;- rnorm(5000, mean=8,sd=1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the service distribution is &lt;span class=&quot;math-container&quot;&gt;$N(8,1)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-r prettyprint-override&quot;&gt;&lt;code&gt;arrival.times &amp;lt;- cumsum(interarrivals)&#xA;departure.times &amp;lt;- arrival.times+service.times&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where I am having issues is determining how many individuals remain in the system at time 1-min to the last.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am having issues conceptualizing the model - this is what you are supposed to estimate (Little's law), which states that rate of arrival = 2 units per minute × mean of the service distribution = 8.&lt;/p&gt;&#xA;" OwnerUserId="901" LastEditorUserId="123" LastEditDate="2020-01-06T20:12:09.217" LastActivityDate="2020-01-06T20:12:09.217" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1007" PostTypeId="1" AcceptedAnswerId="1010" CreationDate="2019-07-13T03:24:02.657" Score="4" ViewCount="2064" Body="&lt;p&gt;I try to solve the following linear program with the simplex method:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{alignedat}{4}&#xA;\max              &amp;amp; \quad &amp;amp; x_1 &amp;amp; {}-{} &amp;amp; 2x_2\\&#xA;\text{subject to} &amp;amp;       &amp;amp;     &amp;amp;       &amp;amp;  x_2 &amp;amp; \le &amp;amp; ~5 \\&#xA;                  &amp;amp;       &amp;amp; x_1 &amp;amp; {}-{} &amp;amp;  x_2 &amp;amp; \ge &amp;amp; 2 \\&#xA;                  &amp;amp;       &amp;amp; x_1 &amp;amp;       &amp;amp;      &amp;amp; \ge &amp;amp; 0 \\&#xA;                  &amp;amp;       &amp;amp;     &amp;amp;       &amp;amp;  x_2 &amp;amp; \ge &amp;amp; 0 \\&#xA;\end{alignedat}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Convert to standard form:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{alignedat}{4}&#xA;\max              &amp;amp; \quad &amp;amp; x_1 &amp;amp; {}-{} &amp;amp; 2x_2\\&#xA;\text{subject to} &amp;amp;       &amp;amp;     &amp;amp;       &amp;amp;  x_2 &amp;amp; \le &amp;amp; 5 \\&#xA;                  &amp;amp; {}-{} &amp;amp; x_1 &amp;amp; {}+{} &amp;amp;  x_2 &amp;amp; \le &amp;amp; ~-2 \\&#xA;                  &amp;amp;       &amp;amp; x_1 &amp;amp;       &amp;amp;      &amp;amp; \ge &amp;amp; 0 \\&#xA;                  &amp;amp;       &amp;amp;     &amp;amp;       &amp;amp;  x_2 &amp;amp; \ge &amp;amp; 0 \\&#xA;\end{alignedat}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Convert to slack form: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{alignedat}{4}&#xA;z   &amp;amp; = &amp;amp; 0   &amp;amp; {}+{} &amp;amp; x_1 &amp;amp; {}-{} &amp;amp; 2x_2\\&#xA;x_3 &amp;amp; = &amp;amp; 5   &amp;amp;       &amp;amp;     &amp;amp; {}-{} &amp;amp;  x_2\\&#xA;x_4 &amp;amp; = &amp;amp; ~-2 &amp;amp; {}+{} &amp;amp; x_1 &amp;amp; {}-{} &amp;amp; x_2\\&#xA;\end{alignedat}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic solution is &lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2,x_3,x_4) = (0,0,5,-2)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I find an optimal solution here? If not, why not?&lt;/p&gt;&#xA;" OwnerUserId="904" LastEditorUserId="145" LastEditDate="2019-07-14T07:12:06.460" LastActivityDate="2019-07-14T07:12:06.460" Title="Having negative value for non basic variable gives a infeasible solution in simplex method?" Tags="|linear-programming|optimization|simplex|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1008" PostTypeId="2" ParentId="117" CreationDate="2019-07-13T08:25:18.573" Score="12" Body="&lt;p&gt;&lt;a href=&quot;https://www.springer.com/gp/book/9780387299594&quot; rel=&quot;noreferrer&quot;&gt;Production Planning by Mixed Integer Programming&lt;/a&gt; by Yves Pochet and Laurence A. Wolsey might fit the bill. Panos Padalos says on &lt;a href=&quot;https://mathscinet.ams.org/mathscinet-getitem?mr=2219955&quot; rel=&quot;noreferrer&quot;&gt;MathSciNet&lt;/a&gt;: &quot;... Practitioners who are interested in using MIP solvers to solve different production planning problems, can use the book to identify the most efficient way to formulate the problems and to choose the most efficient solution method.... Since the book summarizes the state of the art in the area of formulations and solution methods of production planning problems, it also can serve as a good reference for students and researchers.&quot; &lt;/p&gt;&#xA;" OwnerUserId="741" LastActivityDate="2019-07-13T08:25:18.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1009" PostTypeId="2" ParentId="962" CreationDate="2019-07-13T17:09:38.707" Score="19" Body="&lt;p&gt;When you build up your portfolio, you should ask yourself why a specific project is interesting to you (and potentially to a broader audience). What advantage could it have to combine OR and ML, or why use one instead of the other?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion, these considerations add additional value to your portfolio, as they go beyond 'just' displaying your technical skills. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in addition to the ideas mentioned in previous posts, I could think of the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ML as input to OR:&lt;/strong&gt; Find a problem relevant to industry, but too big to be solved in reasonable time using a MIP solver. Then use dimensionality reduction (e.g. principal component analysis) on the input data. Investigate the tradeoff between information loss and performance increase. You could also compare the optimal solution using reduced data to a heuristic solution using the original data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;OR to (better) solve ML problems:&lt;/strong&gt; Find a machine learning problem and solve it using a MIP solver (or use other OR technique). The &lt;a href=&quot;http://www.mit.edu/~dbertsim/papers/Machine%20Learning%20under%20a%20Modern%20Optimization%20Lens/An%20Algorithmic%20Approach%20to%20Linear%20Regression.pdf&quot; rel=&quot;noreferrer&quot;&gt;Bertsimas and King paper&lt;/a&gt; on linear regression might be a good point to start. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;OR vs ML:&lt;/strong&gt; Find a problem for which both OR and ML algorithms exist to solve it. Implement both and compare run time, solution quality, ease of implementation, etc. &lt;/p&gt;&#xA;" OwnerUserId="670" LastActivityDate="2019-07-13T17:09:38.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1010" PostTypeId="2" ParentId="1007" CreationDate="2019-07-13T20:00:07.617" Score="9" Body="&lt;p&gt;From the slack form we can observe two things about your starting point &lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2) = (0,0)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The starting point is not primal feasible. This follows from the fact that not all variables &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_4$&lt;/span&gt; are non-negative (&lt;span class=&quot;math-container&quot;&gt;$x_4 &amp;lt; 0$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;li&gt;The starting point is not dual feasible. This follows from the fact that not all variable coefficients in the &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;-row are non-positive (&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; has coefficient &lt;span class=&quot;math-container&quot;&gt;$1 &amp;gt; 0$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This means that before you can use primal or dual simplex, you first have to find a primal or dual feasible solution. You can do this with the Big M method or with the two phase simplex method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the following very helpful site to see all the simplex steps for your problem:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://cbom.atozmath.com/CBOM/Simplex.aspx?q=ds&amp;amp;q1=2%602%60MAX%60Z%60x1%2Cx2%601%2C-2%600%2C1%3B1%2C-1%60%3C%3D%2C%3E%3D%605%2C2%60%60A%60false%60true%60false%60true%60false%60false%60true&amp;amp;do=1#PrevPart&quot; rel=&quot;noreferrer&quot;&gt;Link for dual simplex method.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://cbom.atozmath.com/CBOM/Simplex.aspx?q=sm&amp;amp;q1=2%602%60MAX%60Z%60x1%2Cx2%601%2C-2%600%2C1%3B1%2C-1%60%3C%3D%2C%3E%3D%605%2C2%60%60A%60false%60true%60false%60true%60false%60false%60true&amp;amp;do=1#PrevPart&quot; rel=&quot;noreferrer&quot;&gt;Link for primal simplex with Big M method.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://cbom.atozmath.com/CBOM/Simplex.aspx?q=tp&amp;amp;q1=2%602%60MAX%60Z%60x1%2Cx2%601%2C-2%600%2C1%3B1%2C-1%60%3C%3D%2C%3E%3D%605%2C2%60%60A%60false%60true%60false%60true%60false%60false%60true&amp;amp;do=1#PrevPart&quot; rel=&quot;noreferrer&quot;&gt;Link for primal simplex with two phase method.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The first link will tell you that the initial solution is indeed dual infeasible. The other links will show that the problem is actually unbounded, and does not have a solution.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2019-07-13T20:31:24.993" LastActivityDate="2019-07-13T20:31:24.993" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1011" PostTypeId="1" AcceptedAnswerId="1044" CreationDate="2019-07-13T21:02:34.700" Score="7" ViewCount="185" Body="&lt;p&gt;I am working on an implementation of &lt;a href=&quot;https://en.wikipedia.org/wiki/Cuckoo_search&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cuckoo Search&lt;/a&gt; for a &lt;a href=&quot;https://en.wikipedia.org/wiki/Set_cover_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;set covering problem&lt;/a&gt;. After reading some papers I cannot understand how choosing a random solution (new cuckoo) works. What I see is that solutions are represented in 2 dimensions and by Lévy flight it picks a random solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure how to implement this. Do I need to generate a lot of solutions and then pick one by Lévy flight? Or generate the solution after the Lévy flight algorithm is executed? &lt;/p&gt;&#xA;" OwnerUserId="912" LastEditorUserId="232" LastEditDate="2019-07-20T12:05:25.137" LastActivityDate="2019-07-22T10:40:42.400" Title="How to interpret the random solution pick by Lévy flight on cuckoo search" Tags="|combinatorial-optimization|metaheuristics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1012" PostTypeId="5" CreationDate="2019-07-14T13:26:25.773" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-07-14T13:26:25.773" LastActivityDate="2019-07-14T13:26:25.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1013" PostTypeId="4" CreationDate="2019-07-14T13:26:25.773" Score="0" Body="For questions about solving Operations Research problems using the R programming language." OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-07-14T17:58:34.633" LastActivityDate="2019-07-14T17:58:34.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1014" PostTypeId="2" ParentId="1004" CreationDate="2019-07-14T21:04:07.723" Score="7" Body="&lt;p&gt;Not directly answering your question of how to code it manually but for discrete simulation of queues in R I would strongly recommend the &lt;code&gt;simmer&lt;/code&gt; package. The minimal code for your example would look like this (adapted from the tutorial).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;library(simmer)&#xA;library(simmer.plot)&#xA;lambda &amp;lt;- 2&#xA;&#xA;queue &amp;lt;- trajectory() %&amp;gt;%&#xA;  seize(&quot;server&quot;, amount=1) %&amp;gt;%&#xA;  timeout(function() {rnorm(1, 8, 1)}) %&amp;gt;%&#xA;  release(&quot;server&quot;, amount=1)&#xA;&#xA;env &amp;lt;- simmer() %&amp;gt;%&#xA;  add_resource(&quot;server&quot;, capacity=1) %&amp;gt;%&#xA;  add_generator(&quot;arrival&quot;, queue, function() {rnorm(1, lambda)}) %&amp;gt;%&#xA;  run(until=100000)&#xA;&#xA;&#xA;resources &amp;lt;- get_mon_resources(env)&#xA;arrivals &amp;lt;- get_mon_arrivals(env)&#xA;&#xA;plot(resources, metric = &quot;usage&quot;, items = &quot;server&quot;)&#xA;plot(arrivals, metric = &quot;flow_time&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, looking at the plot of flow times I am unsure if you conceived a stable queuing system - for mean = 1 in the service time it looks better:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Service Time Mean 8:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ntSV1.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1Ejze.jpg&quot; alt=&quot;mean = 8&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Service Time Mean 1:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ntSV1.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ntSV1.jpg&quot; alt=&quot;mean = 1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="33" LastEditorUserId="123" LastEditDate="2020-01-06T20:13:44.360" LastActivityDate="2020-01-06T20:13:44.360" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1015" PostTypeId="1" AcceptedAnswerId="2611" CreationDate="2019-07-15T06:06:53.530" Score="16" ViewCount="1378" Body="&lt;p&gt;The newer versions of Gurobi include a couple of built-in functionalities for multi-objective optimization: &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/working_with_multiple_obje.html&quot; rel=&quot;noreferrer&quot;&gt;blended objectives and hierarchical (lexicographically ordered) objectives&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose we wanted to minimize &lt;span class=&quot;math-container&quot;&gt;$2x + 3.5y + 7z$&lt;/span&gt;. Using the &quot;blended&quot; functionality &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/py_model_setobjectiven.html#pythonmethod:Model.setObjectiveN&quot; rel=&quot;noreferrer&quot;&gt;by specifying weights for each objective&lt;/a&gt;, the relevant parts of the python code would be something like:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model.setParam('NumObj', 3)&#xA;model.SetObjectiveN(x, index = 0, weight = 2)&#xA;model.SetObjectiveN(y, index = 1, weight = 3.5)&#xA;model.SetObjectiveN(z, index = 2, weight = 7)&#xA;model.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the other hand, if we wanted to do the same minimization by manually specifying a weighted-sum objective, the python code would look like:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model.setObjective(2*x + 3.5*y + 7*z)&#xA;model.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; It seems to me, based on the documentation available, that specifying &quot;blended&quot; objectives is no different from the manual weighted-sum approach. From an algorithmic/computational efficiency perspective, are there any possible benefits to using one approach over the other? Does Gurobi tackle the optimization differently if the objective is constructed in one way versus the other? Or are the differences purely &quot;cosmetic&quot;? &lt;/p&gt;&#xA;" OwnerUserId="196" LastEditorUserId="196" LastEditDate="2019-07-15T06:39:06.370" LastActivityDate="2019-09-21T05:19:45.673" Title="Are there any benefits to using Gurobi's built-in &quot;blended&quot; multi-objective functionality?" Tags="|gurobi|multi-objective-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1016" PostTypeId="2" ParentId="117" CreationDate="2019-07-15T10:17:26.110" Score="6" Body="&lt;p&gt;&lt;a href=&quot;https://www.mheducation.com/highered/product/online-access-introduction-operations-research-hillier-lieberman/9781259545962.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Introduction to Operations Research&lt;/em&gt; (10th ed.)&lt;/a&gt; by Hiller and Liebermann is also a great book for concrete and complete examples of applications.&lt;/p&gt;&#xA;" OwnerUserId="920" LastEditorUserId="123" LastEditDate="2020-02-10T14:18:37.310" LastActivityDate="2020-02-10T14:18:37.310" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1017" PostTypeId="1" CreationDate="2019-07-15T15:44:40.760" Score="8" ViewCount="1464" Body="&lt;p&gt;In relation to using CBC via Pyomo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if anyone knew if it was possible to set a maximum allowed time to improve a solution, rather than a maximum total time. This way, if you've been stuck on a solution without improving for a while, you can exit the solver by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A work around could be to pause the solver and check the logs but I couldn't find anything about pausing a solver either. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks.&lt;/p&gt;&#xA;" OwnerUserId="843" LastActivityDate="2019-07-15T17:37:56.843" Title="How to set a maximum time to improve a solution with Pyomo and CBC" Tags="|mixed-integer-programming|pyomo|coin-or|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1019" PostTypeId="1" AcceptedAnswerId="1021" CreationDate="2019-07-15T17:23:01.350" Score="9" ViewCount="178" Body="&lt;p&gt;Currently, I am working on a problem in which I need to use &lt;strong&gt;MILP&lt;/strong&gt; to model equilibrium equations in a lightweight structure. Although this is an application based question, I wondered if there is a good reference in the literature discussing the mathematical modeling of such an application based on statical concepts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A brief discussion of structural optimization is given in chapter 15 of &lt;strong&gt;Linear Programming: Foundations and Extensions&lt;/strong&gt;, by &lt;em&gt;Robert J. Vanderbei&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Structural optimization is the general name that researchers use for a wide range of research topics in the literature, i.e., Shape optimization, Size optimization and also Topology optimization. &lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-07-16T15:53:46.530" Title="Structural Optimization" Tags="|mixed-integer-programming|linear-programming|modeling|applications|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1020" PostTypeId="2" ParentId="1017" CreationDate="2019-07-15T17:37:56.843" Score="2" Body="&lt;p&gt;Please check &lt;a href=&quot;https://stackoverflow.com/q/35405642&quot;&gt;this question&lt;/a&gt; which is asked and answered in Stack Overflow. Also, &lt;a href=&quot;http://www.pyomo.org/blog/2015/1/8/accessing-solver&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt; includes the explanation of different termination condition in Pyomo. One of those conditions is &quot;userInterrupt&quot; that I think can be used to define a condition inside Pyomo to force the solver to stop. In that situation, the solver status will be &quot;Aborted&quot;.   &lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-07-15T17:37:56.843" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1021" PostTypeId="2" ParentId="1019" CreationDate="2019-07-16T15:53:46.530" Score="5" Body="&lt;p&gt;You should have a look at the work of Mathias Stolpe. He has done a lot of modelling for structural optimization problems with integer constraints. See for example his &lt;a href=&quot;https://orbit.dtu.dk/en/publications/models-and-methods-for-structural-topology-optimization-with-discrete-design-variables(eefb877e-065f-43a0-9958-d42eef42c2da).html&quot; rel=&quot;noreferrer&quot;&gt;PhD thesis&lt;/a&gt;. As you already written, the topic comes from a more continuous direction. See the &lt;a href=&quot;https://www.springer.com/de/book/9783540429920&quot; rel=&quot;noreferrer&quot;&gt;nice book by Martin Bendsoe and Ole Sigmund&lt;/a&gt; for a really good overview. You can also have a look at the &lt;a href=&quot;http://www.topopt.mek.dtu.dk/&quot; rel=&quot;noreferrer&quot;&gt;website&lt;/a&gt; of this chair.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you provide more information on your problem I can adjust my answer to guide you to more relevant papers.&lt;/p&gt;&#xA;" OwnerUserId="137" LastActivityDate="2019-07-16T15:53:46.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1022" PostTypeId="1" AcceptedAnswerId="1023" CreationDate="2019-07-17T00:21:21.403" Score="13" ViewCount="548" Body="&lt;p&gt;Is there a way to configure Gurobi to allow the LP relaxation associated with the optimal solution leaf of a MIP branch-and-bound tree to be queried for shadow prices &amp;amp; other general LP properties--understanding that there may be serious shortcomings about some of the inferences that can be made given the cutting planes that are put in.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is possible, how would one go about storing this LP relaxation or querying the properties of a given constraint &lt;em&gt;c&lt;/em&gt;?  &lt;/p&gt;&#xA;" OwnerUserId="928" LastActivityDate="2019-07-18T01:01:24.563" Title="Querying attributes of LP relaxation at MIP-optimality in Gurobi" Tags="|mixed-integer-programming|linear-programming|gurobi|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1023" PostTypeId="2" ParentId="1022" CreationDate="2019-07-17T03:28:34.773" Score="8" Body="&lt;p&gt;Based on the documentation, this level of information retrieval from a specific branch-and-bound node is currently not available. If this was possible, we'd have to use a &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/callback_codes.html&quot; rel=&quot;noreferrer&quot;&gt;callback&lt;/a&gt; function (&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/py_callbacks.html&quot; rel=&quot;noreferrer&quot;&gt;python documentation&lt;/a&gt;, &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/examples/callback_py.html&quot; rel=&quot;noreferrer&quot;&gt;python examples&lt;/a&gt;) to get the information from the relevant MIP branch-and-bound tree. We'd need &lt;code&gt;where == GRB.Callback.MIPNODE&lt;/code&gt; since we want information from a specific node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the &lt;code&gt;what&lt;/code&gt; &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/callback_codes.html&quot; rel=&quot;noreferrer&quot;&gt;callback codes&lt;/a&gt; and archived Google Groups discussions for &lt;code&gt;MIPNODE&lt;/code&gt;, there is no code to get the LP relaxation constraints and their properties. The closest thing would be &lt;code&gt;MIPNODE_REL&lt;/code&gt; (or &lt;code&gt;Model.cbGetNodeRel()&lt;/code&gt; for python), which provides the values of the variables for a node relaxation solution. &lt;/p&gt;&#xA;" OwnerUserId="196" LastEditorUserId="196" LastEditDate="2019-07-17T14:46:17.593" LastActivityDate="2019-07-17T14:46:17.593" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1024" PostTypeId="1" CreationDate="2019-07-17T08:13:51.287" Score="29" ViewCount="12597" Body="&lt;p&gt;The Machine Learning community has largely benefited from modern &lt;a href=&quot;https://en.wikipedia.org/wiki/Graphics_processing_unit&quot; rel=&quot;noreferrer&quot;&gt;GPUs&lt;/a&gt; and several large companies are investing in new dedicated hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, academic and commercial mathematical optimization solvers still lack support for GPUs. They have support for distributed or shared memory computing environment (e.g., see the &lt;strong&gt;&lt;a href=&quot;https://ug.zib.de/&quot; rel=&quot;noreferrer&quot;&gt;Ubiquity Generator framework&lt;/a&gt;&lt;/strong&gt; from ZIB), but it looks that GPUs raise different technical challenges for (discrete) math optimizers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here my two questions: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;em&gt;Which GPU, if any, should I get for mathematical optimization?&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Does there exist any mathematical optimization software that can fully exploit multiple modern GPUs?&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="171" LastEditorUserId="8" LastEditDate="2019-07-18T05:05:31.067" LastActivityDate="2019-07-22T18:41:28.653" Title="Which GPUs to get for Mathematical Optimization (if any)?" Tags="|solver|parallel-computing|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1025" PostTypeId="2" ParentId="1024" CreationDate="2019-07-17T08:27:42.223" Score="15" Body="&lt;p&gt;I've not seen any efficient use from GPU's for metaheuristics - only experiments that proved their inefficiency for these algorithms. So not the right tool for the job, apparently. Maybe there's a undiscovered technique to make them work efficiently. (I have seen/build efficient use of multiple CPU cores for metaheuristics, even on Local Search with incremental fitness calculation.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me define &lt;em&gt;efficient use&lt;/em&gt; as: in a apples to apples comparison on multiple non-trivial datasets, running for the same amount of time (ideally a few minutes), the GPU strategy isn't dominated by the non-GPU strategy.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2019-07-17T08:27:42.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1027" PostTypeId="1" CreationDate="2019-07-17T12:45:52.887" Score="19" ViewCount="432" Body="&lt;p&gt;Looking at the news as well as at content of tech conferences, I think it is fair to say that AI is getting a lot of attention -- one might even call it &lt;em&gt;an AI hype&lt;/em&gt; (like in the &lt;a href=&quot;https://www.optaplanner.org/blog/2017/09/07/DoesAIIncludeConstraintSolvers.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;80's&lt;/a&gt;). Plenty of articles describe how CEO's and CIO's are either exploring or are being advised they should be exploring AI within their company. This reflects in big budgets and the creation of dedicated AI and &quot;data scientist&quot; teams.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet, in practice, these teams seem to treat AI as a substitute by Machine Learning -- and specifically Deep Learning Neural Nets (or Random Forests at best). In any case, not constraint solvers (regardless of the underlying tech being MH, LP or CP).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do constraint solvers have trouble riding the AI wave? Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Opinionated disclaimer: this question is provoking opinionated, rather than fact-based answers. Take all answers with a grain of salt.&lt;/strong&gt; See comments discussion for more info.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="8" LastEditDate="2019-07-28T13:26:58.817" LastActivityDate="2019-07-28T13:26:58.817" Title="AI gets a lot of attention these days. Does constraint optimization get more attention, too? Why (not)?" Tags="|constraint-programming|machine-learning|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="1028" PostTypeId="2" ParentId="1024" CreationDate="2019-07-17T14:06:19.200" Score="14" Body="&lt;p&gt;If you problem is continuous I would say that it might be beneficial. For problems that involve discrete variables I've not seen anything that does benefit from the usage of a GPU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GPUs aid problem solving if the underlying problem has a structure that can exploit the massive parallel computation structure of the graphical processing unit. Calculations which involve large matrices are a good example. Deep learning is able to make very good use of GPUs as their computations can (roughly) be written as matrix vector operations. There exist specialized BLAS and LAPACK instructions for GPUs (e.g. &lt;a href=&quot;https://developer.nvidia.com/cublas&quot; rel=&quot;noreferrer&quot;&gt;https://developer.nvidia.com/cublas&lt;/a&gt;), so algorithms making use of these are likely to see a speedup.&lt;br&gt;&#xA;On the other hand algorithms which exhibit inherent &quot;branches&quot; (i.e. decisions) within their flow cannot use the parallel computation capabilities of GPUs because with each branch the problem changes a bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to answer your question(s):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If your problem involves discrete decisions: You won't get any benefit from having a potent GPU.&lt;br&gt;&#xA;If your problem involves only continuous variables: It might be beneficial - but I've not seen any solver that claims to specifically exploit GPUs.&lt;/li&gt;&#xA;&lt;li&gt;I'm not aware of any.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="137" LastEditorUserId="137" LastEditDate="2019-07-17T19:22:49.443" LastActivityDate="2019-07-17T19:22:49.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1029" PostTypeId="2" ParentId="1024" CreationDate="2019-07-17T15:49:11.937" Score="14" Body="&lt;p&gt;The first algorithm coming to mind that can benefit from GPUs is the Interior-Point Method (IPM), at its heart is the resolution of a linear system. See references:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://doi.org/10.1007/978-3-642-31464-3_69&quot; rel=&quot;noreferrer&quot;&gt;GPU Acceleration of the Matrix-Free Interior Point Method&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.84.8623&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;noreferrer&quot;&gt;Cholesky Decomposition and Linear Programming&#xA;on a GPU&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="323" LastEditorUserId="145" LastEditDate="2019-07-17T16:02:48.773" LastActivityDate="2019-07-17T16:02:48.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1030" PostTypeId="2" ParentId="962" CreationDate="2019-07-17T16:55:55.797" Score="6" Body="&lt;p&gt;&lt;strong&gt;MDP and ML:&lt;/strong&gt; The run-time for solving Markov Decision Processes to find the optimal policy is exponentially increased when the problem size is increased. Exact methods for the large problems, most of the times, face the curse of dimensionality and failed to solve the problem in a fair amount of time. Sometimes heuristic methods can be used to find the near-optimal policies in a shorter run-time. All of these said Machine Learning can be used to generate a model to come up with near-optimal policies for large MDP problems. Accuracy of such a model will increase if the online learning of the model also considered in the process. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be considered as a project which can connect ML to the optimization of queueing network or solving Markov Decision Processes.   &lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-07-17T16:55:55.797" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1031" PostTypeId="2" ParentId="1022" CreationDate="2019-07-18T01:01:24.563" Score="7" Body="&lt;p&gt;If you only care about those attributes in an optimal solution (or integral solution), save the integer part of the solution, fix the value of those integer variables in the model (x.ub=value, x.lb=value) and re-solve the remainder linear relaxation (model2=model.relax()) . Now you can query what you normally could for an LP. Not quite what you want, but is a hack around. &lt;/p&gt;&#xA;" OwnerUserId="602" LastActivityDate="2019-07-18T01:01:24.563" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1032" PostTypeId="1" AcceptedAnswerId="1124" CreationDate="2019-07-18T04:57:26.027" Score="19" ViewCount="8655" Body="&lt;p&gt;I am solving a highly constrained (large number of constraints and large number of variables, but small degree of freedom) NLP problem, and for start, I was using Matlab's &lt;code&gt;fmincon&lt;/code&gt; - SQP algorithms. This works wonders, and in &lt;span class=&quot;math-container&quot;&gt;$95\%$&lt;/span&gt; of the cases finds an optimal solution even with poor initial guesses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now - Matlab does not have built-in Automatic Differentiation (AD) technology (there are packages, but I was not always successful in getting my constraint set AD'd, so I use numerical derivatives), so as the size of the problems expands, I get slower and slower convergence. Then I started to re-implement the problem in Pyomo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To my surprise, apart from ipopt, I did not find many open-source/freeware solvers for NLP problems. Ipopt performs very poorly as it struggles to find a feasible solution. It finds the right optimum in maybe &lt;span class=&quot;math-container&quot;&gt;$5\%$&lt;/span&gt; of the cases. Now both ipopt and SQP are local solvers, so the solutions should not be that much different. I tried Matlab's own ipopt, as well as ipopt supplied by opti-toolbox. Both perform miserably compared to Matlab's SQP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure if it's the ipopt settings - do you know any handles that could work for the highly constrained problems? I found that filterSQP could be called from pyomo, but not much literature outside. Also, it's not publicly available for use - one needs to get a license from Dundee university. Also, I saw &lt;code&gt;basic_sqp.py&lt;/code&gt; developed for numpy, but no reference on how to call it from pyomo. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone has any experience with any sort of SQP algorithms (or non-ipopt solvers, especially active set implementation that would hopefully work in my case), it would really help a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks!&lt;/p&gt;&#xA;" OwnerUserId="935" LastEditorUserId="36" LastEditDate="2019-08-17T14:02:01.723" LastActivityDate="2019-08-23T17:14:14.390" Title="NLP solvers in pyomo other than ipopt?" Tags="|nonlinear-programming|pyomo|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="1033" PostTypeId="2" ParentId="928" CreationDate="2019-07-18T05:34:33.737" Score="7" Body="&lt;p&gt;The following books on approximation algorithms each have a chapter dedicated to open problems:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Chapter 17 of &lt;a href=&quot;http://www.designofapproxalgs.com/book.pdf&quot; rel=&quot;noreferrer&quot;&gt;The Design of Approximation Algorithms by Williamson and Shmoys (freely available)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Chapter 30 of &lt;a href=&quot;https://www.springer.com/gp/book/9783540653677&quot; rel=&quot;noreferrer&quot;&gt;Approximation Algorithms by Vazirani&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="606" LastActivityDate="2019-07-18T05:34:33.737" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1034" PostTypeId="2" ParentId="1032" CreationDate="2019-07-18T07:43:50.073" Score="9" Body="&lt;p&gt;I think it is a good idea to have a look at &lt;a href=&quot;https://stackoverflow.com/a/51374477&quot;&gt;this&lt;/a&gt; question on StackOverflow. In addition to that, in the &lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/solving_pyomo_models.html&quot; rel=&quot;noreferrer&quot;&gt;Pyomo manual&lt;/a&gt;, it is stated that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Pyomo supports a wide variety of solvers. Pyomo has specialized interfaces to some solvers (for example, BARON, CBC, CPLEX, and Gurobi). It also has generic interfaces that support calling any solver that can read AMPL “.nl” and write “.sol” files and the ability to generate GAMS-format models and retrieve the results. The following Pyomo command will give you the current list of supported solvers:&quot;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;pyomo help --solvers&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The following two papers may also help in choosing a solver for your problem:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Gill, P. E., Murray, W., and Saunders, M. A. (2005). SNOPT: An SQP algorithm for large-scale constrained optimization. SIAM review, 47(1):99–131.&lt;/li&gt;&#xA;&lt;li&gt;Kronqvist, Jan, et al. &quot;A review and comparison of solvers for convex MINLP.&quot; Optimization and Engineering 20.2 (2019): 397-455.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-07-18T07:43:50.073" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1035" PostTypeId="2" ParentId="928" CreationDate="2019-07-18T10:56:22.427" Score="10" Body="&lt;p&gt;Even though the following problem is usually not listed as a typical OR-problem, its solution might (depending on how the solution looks like) have a HUGE effect on OR algorithms. I am speaking of nothing less but the &lt;code&gt;P vs. NP&lt;/code&gt;-problem, which is one of the most important open problems in all of mathematics (and computer science). It is also listed as one of the Millenium Problems and its solution would bring the person to solve it $1,000,000 from the Clay Mathematics Institute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem ask whether the two formal classes P and NP are the same or not, i.e. whether P=NP or  P&lt;span class=&quot;math-container&quot;&gt;$\not =$&lt;/span&gt;NP. While the inclusion P&lt;span class=&quot;math-container&quot;&gt;$\subseteq$&lt;/span&gt;NP is rather trivial, the other inclusion is not. In fact, it is widely believed nowadays that P&lt;span class=&quot;math-container&quot;&gt;$\not=$&lt;/span&gt;NP is true (c.f. the latest &lt;a href=&quot;https://www.cs.umd.edu/users/gasarch/BLOGPAPERS/pollpaper3.pdf&quot; rel=&quot;noreferrer&quot;&gt;P =? NP Poll&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, however, it would turn out that P=NP, then this would have a tremendous effect on OR because this would imply that all those NP-complete problems which people from OR like to deal with (TSP, Graph Coloring, Integer Programming in general...) would allow polynomial-time solution algorithms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the solution were P&lt;span class=&quot;math-container&quot;&gt;$\not =$&lt;/span&gt;NP then this would not have such a big effect on OR as P=NP. Yet, for people working in OR it would nevertheless be interesting to know the final solution to the P vs. NP question.&lt;/p&gt;&#xA;" OwnerUserId="81" LastActivityDate="2019-07-18T10:56:22.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1037" PostTypeId="2" ParentId="1024" CreationDate="2019-07-18T16:08:18.347" Score="10" Body="&lt;p&gt;A lot depends on what kinds of computations you are doing.  The subject of this group is &quot;Operations Research&quot;, but that surely includes a range of computational work including discrete event simulation, machine learning, linear and nonlinear programming, discrete optimization, etc.  There's no one answer applicable to all of those kinds of problems.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For linear and nonlinear programming, one important issue is that nearly all of these computations are typically performed in double precision rather than single precision.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;NVIDIA has adopted a strategy in which different models of their GPU's are optimized for different uses and priced differently.  Except for the Tesla line of GPU's aimed at high performance computing applications, most of NVIDIA's GPU's are configured so that double precision is much (e.g. 32 times) slower than single precision.  This means that these other models are poorly suited for double precision floating point computations.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In contrast, most machine learning computing can be done in single precision (or even half precision.)  The inexpensive consumer oriented GPU's sold by NVIDIA perform incredibly well on these kinds of computations.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another important issue in linear algebra computations is whether the matrices that you're working with are sparse (have lots of zero entries) or dense (all or nearly all entries are nonzero.)  GPU's excel at dense matrix linear algebra but don't perform quite so well with sparse matrices.  Nearly all linear programming models have sparse constraint matrices and this is exploited by both simplex and interior point solvers.  Thus GPU's have not been very successful in linear programming (you'll notice that neither CPLEX nor GuRoBi work with GPU's.)  The situation with nonlinear programming is somewhat more varied.   &lt;/p&gt;&#xA;" OwnerUserId="103" LastEditorUserId="103" LastEditDate="2019-07-19T03:55:52.823" LastActivityDate="2019-07-19T03:55:52.823" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1038" PostTypeId="2" ParentId="996" CreationDate="2019-07-19T00:41:35.067" Score="8" Body="&lt;p&gt;Cool problem! There are a couple of things you can do to make this problem more tractable. Before starting, do you really need the variables and some parameters to be complex numbers? In particular, according to your notation, are the &lt;span class=&quot;math-container&quot;&gt;$|\cdot|$&lt;/span&gt; the complex modulus of the vectors? For more details of (MI)LP over complex numbers check this other &lt;a href=&quot;https://or.stackexchange.com/questions/560/application-of-complex-numbers-in-linear-programming&quot;&gt;question&lt;/a&gt;. There are some tools that allow you to do optimization over complex number using a bijective mapping between the complex and the real numbers. But well, the following reformulation stands for real or complex variables.&lt;/p&gt;&#xA;&lt;p&gt;Let's begin.&lt;/p&gt;&#xA;&lt;h3&gt;1) Objective function&lt;/h3&gt;&#xA;&lt;p&gt;Notice that the objective function can be written as &lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{i=1}^N x_i\alpha_i \log_2 \left(1+\frac{|\bf{h}_i^Hw_i|^2}{\sigma^2+\sum\limits_{j=1\\ j\neq i}^N|\bf{h}_j^Hw_j|^2}\right).$$&lt;/span&gt;&#xA;You can write the &lt;span class=&quot;math-container&quot;&gt;$\log_2$&lt;/span&gt; term as follows (just distribute the denominator and use the logarithm properties)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\log_2 \left(1+\frac{|\mathbf{h}_i^H \mathbf{w}_i|^2}{\sigma^2+\sum\limits_{j=1\\ j\neq i}^N|\mathbf{h}_j^H \mathbf{w}_j|^2}\right)&amp;amp;=\log_2 \left(\frac{\sigma^2+\sum\limits_{j=1}^N|\mathbf{h}_j^H \mathbf{w}_j|^2}{\sigma^2+\sum\limits_{j=1\\ j\neq i}^N|\mathbf{h}_j^H \mathbf{w}_j|^2}\right)\\&amp;amp;=&#xA;\log_2 \left(\sigma^2+\sum\limits_{j=1}^N|\mathbf{h}_j^H \mathbf{w}_j|^2\right)-\log_2 \left(\sigma^2+\sum\limits_{j=1\\ j\neq i}^N|\mathbf{h}_j^H \mathbf{w}_j|^2\right).\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This yields an objective function that can be separated into two parts: &lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{i=1}^N x_i\alpha_i \log_2 \left(\sigma^2+\sum\limits_{j=1}^N|\mathbf{h}_j^H \mathbf{w}_j|^2\right) - \sum\limits_{i=1}^N x_i\alpha_i \log_2 \left(\sigma^2+\sum\limits_{j=1\\ j\neq i}^N|\mathbf{h}_j^H \mathbf{w}_j|^2\right).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first term can be further simplified as &lt;span class=&quot;math-container&quot;&gt;$$\log_2 \left(\sigma^2+\sum\limits_{j=1}^N|\mathbf{h}_j^H \mathbf{w}_j|^2\right)\sum\limits_{i=1}^N x_i\alpha_i$$&lt;/span&gt; but let's leave it inside as if it was indexed in &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; for simplicity.&lt;/p&gt;&#xA;&lt;p&gt;Since you are maximizing, you would like the terms in the objective function to be concave to make your problem easier to solve. Since you have a product of binary and continuous variables in both terms of your objective function, you would like to reformulate the product. Fortunately, this can be done.&lt;/p&gt;&#xA;&lt;p&gt;For simplification assume that you have the product &lt;span class=&quot;math-container&quot;&gt;$x_i v_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i \in \{ 0,1 \}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v_i \in [L_i, U_i]$&lt;/span&gt;. Since you correctly commented that &lt;span class=&quot;math-container&quot;&gt;$\log_2$&lt;/span&gt; is monotonic, you can derive the lower and upper bounds for each continuous part. Once you have there, for each product you introduce a variable &lt;span class=&quot;math-container&quot;&gt;$z_i = x_i v_i$&lt;/span&gt; and the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases}z_i \leq U_i x_i \\ z_i \geq L_i x_i \\ z_i \leq v_i - (1-x_i)L_i \\ z_i \geq v_i - (1-x_i)U_i\end{cases}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Notice that since you have some positive and negative values in the objective function you can ignore two of the constraints that arise from the reformulation since they will never be active.&lt;/p&gt;&#xA;&lt;p&gt;Your objective function becomes the linear expression &lt;span class=&quot;math-container&quot;&gt;$$\max\limits_{x,\mathbf{w},z} \sum\limits_{i=1}^N \alpha_i(z_i^1-z_i^2).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You would still have some constraint of the type&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases}z_i^1 \leq \log_2 \left(\sigma^2+\sum\limits_{j=1}^N|\mathbf{h}_j^H \mathbf{w}_j|^2\right) - (1-x_i)L_i^1\\z_i^2 \geq \log_2 \left(\sigma^2+\sum\limits_{j=1}^N|\mathbf{h}_j^H \mathbf{w}_j|^2\right) - (1-x_i)U_i^2\end{cases}&lt;/span&gt; with some bounds that you can find (e.g. &lt;span class=&quot;math-container&quot;&gt;$L_i^1 \leq \log_2(\sigma^2)$&lt;/span&gt;) which are nonlinear because of the &lt;span class=&quot;math-container&quot;&gt;$\log_2$&lt;/span&gt;. The first set of constraints is convex though (assuming you can compute those complex norms as with real numbers), so that's something.&lt;/p&gt;&#xA;&lt;h3&gt;2) Constraints&lt;/h3&gt;&#xA;&lt;p&gt;These are easier, given that the norm is already convex, meaning that after reformulating the binary-norm product with the trick above, you will obtain a set of convex inequalities. Just use &lt;span class=&quot;math-container&quot;&gt;$v_i = ||\mathbf{w}_i||_2^2$&lt;/span&gt;. Since according to your previous comment &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}_i$&lt;/span&gt; are unit vectors, deriving bounds to its norm is trivial. In this case, you can also ignore two of the constraints from the reformulation (given the fact that you have an inequality), and you don't need to worry about &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}_i$&lt;/span&gt; being complex given that the &lt;span class=&quot;math-container&quot;&gt;$||\cdot||_2^2$&lt;/span&gt; is the same as if you have a twice as large real vector (in this case a matrix).&lt;/p&gt;&#xA;&lt;h3&gt;3) Final thoughts&lt;/h3&gt;&#xA;&lt;p&gt;You are dealing with a nonconvex MINLP. Some of those nonconvexities can be easily convexified (the bilinear binary-continuous terms), while others are not so easy. It may also depend heavily on the algorithm that you are using to solve the problem and what you are interested in. If you do not mind obtaining a local optimal solution, you may just partially reformulate the problem as written here. You may even try to put all the nonlinearities and nonconvexities in the objective and see how far a local solver can get you. If you do care about global optimality, the reformulations here are valid (no relaxations or approximation were introduced) but the global solvers (e.g. BARON, ANTIGONE or SCIP) might be more successful on the original form of the problem.&lt;/p&gt;&#xA;&lt;p&gt;I'm curious how this ends up behaving, let us know!&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-07-31T09:05:39.233" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1039" PostTypeId="1" CreationDate="2019-07-19T03:09:23.883" Score="8" ViewCount="869" Body="&lt;p&gt;I am currently working on software that deals with a specific type of scheduling problem, and I want to improve the scheduling algorithms that it uses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I tried to research algorithms the information I found deals mostly with a much different kind of scheduling problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my problem, the givens are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A set of &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; jobs.  Each job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; has an availability interval with start and end times &lt;span class=&quot;math-container&quot;&gt;$[s_j,e_j]$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;A reward function &lt;span class=&quot;math-container&quot;&gt;$R(j,t)$&lt;/span&gt; which gives the utility of processing a job for a given amount of time.&lt;/li&gt;&#xA;&lt;li&gt;A changeover time function &lt;span class=&quot;math-container&quot;&gt;$C(j,j',t)$&lt;/span&gt; which gives the amount of time required, starting at a time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, to switch from job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to job &lt;span class=&quot;math-container&quot;&gt;$j'$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;A set of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; minimum time constraints.  Each constraint &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; has an associated set of jobs &lt;span class=&quot;math-container&quot;&gt;$J_m$&lt;/span&gt; and a minimum time &lt;span class=&quot;math-container&quot;&gt;$c_m$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The solution is a list of jobs and intervals: &lt;span class=&quot;math-container&quot;&gt;$\{(j_1,I_1),(j_2,I_2),\ldots,(j_N,I_N)\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The constraints are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each interval must fall within the corresponding job's availability interval: &lt;span class=&quot;math-container&quot;&gt;$I_n\subseteq[s_{j_n},e_{j_n}]$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;There must be adequate changeover time between jobs: &lt;span class=&quot;math-container&quot;&gt;$$\max I_n + C(j_{n},j_{n+1},\max I_n)\leq \min I_{n+1}$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The minimum time constraints must be met: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{\substack{n=1 \\ j_n\in J_m}}^{N}\left|I_n\right|\ge c_m $$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The objectives are (multiobjective optimization):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(Primary) Maximize the reward given by: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{n=1}^{N}R(j_n,\left|I_n\right|)$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;(Secondary) Minimize the amount of &quot;idle&quot; time (idle time is the &quot;slack&quot; in the changeover constraint): &lt;span class=&quot;math-container&quot;&gt;$$\sum_{n=1}^{N-1}\left(\min I_{n+1}-\max I_n\right) - C(j_{n},j_{n+1},\max I_n)$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;(Secondary) Minimize the longest idle (same as previous with &lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; replacing &lt;span class=&quot;math-container&quot;&gt;$\sum$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Has this type of problem been studied?  If so, what names is it usually called by?&lt;/p&gt;&#xA;" OwnerUserId="944" LastEditorUserId="944" LastEditDate="2019-07-23T00:34:18.457" LastActivityDate="2019-07-23T00:34:18.457" Title="What is this type of scheduling problem called?" Tags="|optimization|scheduling|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="1040" PostTypeId="1" CreationDate="2019-07-19T06:47:48.037" Score="19" ViewCount="3051" Body="&lt;p&gt;I have seen a lot of interview questions and answers for Software Engineering, Data Science and Machine Learning roles. I haven't found many interviews Questions for Operations Research. Can someone recommend a comprehensive way to prepare for interview questions and answers that are found for Operations Research&lt;/p&gt;&#xA;" OwnerUserId="537" LastEditorUserId="354" LastEditDate="2019-07-19T13:47:57.150" LastActivityDate="2019-07-21T19:29:44.850" Title="Interview Questions and Answers" Tags="|job-market|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1042" PostTypeId="5" CreationDate="2019-07-19T13:49:49.560" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-07-19T13:49:49.560" LastActivityDate="2019-07-19T13:49:49.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1043" PostTypeId="4" CreationDate="2019-07-19T13:49:49.560" Score="0" Body="Topics related to job search, be it academic or industrial. Anything from finding positions, writing applications, interviewing, to perspectives." OwnerUserId="354" LastEditorUserId="354" LastEditDate="2019-07-22T20:20:54.350" LastActivityDate="2019-07-22T20:20:54.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1044" PostTypeId="2" ParentId="1011" CreationDate="2019-07-20T09:31:02.540" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;https://arxiv.org/abs/1003.1594v1&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt; in which Yang and Deb introduce Cuckoo Search presents their method as a way to maximise the value of an objective function &lt;span class=&quot;math-container&quot;&gt;$f: C\rightarrow \mathbb{R}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is some &lt;em&gt;continuous&lt;/em&gt; space (e.g. some area in the plane) and each individual solution &lt;span class=&quot;math-container&quot;&gt;$x\in C$&lt;/span&gt; can be represented as a vector. In such a space, a Levy flight is well defined and I think section 2 and 3 of the paper explain fairly clearly how this is done. However, you cannot directly approach to the set cover problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem here is that set cover is not a continuous optimisation problem, but a discrete one. It is possible to represent a solution set cover as a binary vector &lt;span class=&quot;math-container&quot;&gt;$x\in \{0,1\}^{|S|}$&lt;/span&gt; where the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th coordinate of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if the set &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; is included in the cover and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise. We cannot perform a Levy flight directly here, because a single jump from a valid solution vector such as &lt;span class=&quot;math-container&quot;&gt;$[0,1,0,0]$&lt;/span&gt; often changes into something like &lt;span class=&quot;math-container&quot;&gt;$[-3.54,2.3,0.84,1.05]$&lt;/span&gt;, for which it isn't clear how to map this to a valid solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gherboudj et al.&lt;sup&gt;1&lt;/sup&gt; resolve this issue by performing the Levy flights in a continuous space &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; and then mapping the points in this space to a (valid) binary solution vector to evaluate the solution. For each coordinate of a vector &lt;span class=&quot;math-container&quot;&gt;$c\in C$&lt;/span&gt;, they use a sigmoid function to get a number &lt;span class=&quot;math-container&quot;&gt;$p_i\in [0,1]$&lt;/span&gt; and then create the vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; where the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th coordinate is set to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; with probability &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to look at this approach is that here Cuckoo Search is used to search in a continuous space of 'strategies' for the discrete problem, where each strategy is evaluated by the best result it has lead to in the original problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this is just one approach to apply Levy flights in a discrete context. There may be better methods in general, or better methods for your specific problem. As with most heuristics, you will have to try and see how well it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1: Gherboudj, Amira, Abdesslem Layeb, and Salim Chikhi. &lt;a href=&quot;https://pdfs.semanticscholar.org/3599/ca39dbfc86a488f83b6f357718872a8fae42.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Solving 0-1 knapsack problems by a discrete binary version of cuckoo search algorithm.&quot;&lt;/a&gt; International Journal of Bio-Inspired Computation 4.4 (2012): 229-236.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="232" LastEditorUserId="232" LastEditDate="2019-07-22T10:40:42.400" LastActivityDate="2019-07-22T10:40:42.400" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1045" PostTypeId="2" ParentId="1039" CreationDate="2019-07-20T17:58:30.987" Score="6" Body="&lt;p&gt;I guess I'm missing something here, or making an incorrect assumption, because the problem seems trivial. I'm assuming that the contribution of each partially done project is a nondecreasing function of the time spent on it, that contributions are additive (the value of partially doing task 1 does not in any way depend on what is done with task 2), that the worker does not fatigue (so worker time late in the shift is no different from worker time early in the shift), and that there is no cost in time or objective value for moving from one task to another. Under those assumptions, you can determine from the data which tasks are available at any instant and time and which among them has the highest object contribution rate per unit time. The contribution-maximizing solution is just to have the worker, at every time epoch, work on whichever task has the highest contribution rate among those available at that epoch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something else in play here?&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-07-20T17:58:30.987" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1046" PostTypeId="1" AcceptedAnswerId="1047" CreationDate="2019-07-20T18:47:21.953" Score="6" ViewCount="106" Body="&lt;p&gt;at my company, we have a product level forecast that we run through a model which pulls out an hours number for our retail outlets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We do this by binning various products into categories and give them a time value lets call this &lt;code&gt;tmv&lt;/code&gt; (timed minute values). So product &lt;code&gt;coffee&lt;/code&gt; gets a &lt;code&gt;tmv&lt;/code&gt; of 0:50 s per quantity. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;we then do a simple &lt;code&gt;product&lt;/code&gt; * &lt;code&gt;tmv&lt;/code&gt; and aggregate up while accounting for certain constraints, such as minimum hours required to run a shop floor, management hours and so forth. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;when I inherited this beast, it was all written in excel which I ported into SQL and Python, although a lot of work has gone into it, there is little statistical modeling, optimization, or basic ML applied. Although, I'm not sure what could be done to better optimize this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder what more to-date tech companies do to allocate their work-force in a retail environment. &lt;/p&gt;&#xA;" OwnerUserId="956" LastActivityDate="2019-07-20T19:34:16.780" Title="Labour Model - Resource Allocation based off Product Forecasts" Tags="|optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1047" PostTypeId="2" ParentId="1046" CreationDate="2019-07-20T19:34:16.780" Score="3" Body="&lt;p&gt;This problem can be converted to a mathematical model and be solved using the approaches which are admissible with respect to the conditions of the problem. Generally, in optimization, limited resources allocated to some demands while optimizing (minimizing/maximizing) the objective function. So to successfully model your problem you need to verify the followings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Variables (can be the number of a specific product to be produced)&lt;/li&gt;&#xA;&lt;li&gt;Constraints ( demands should be satisfied, limitations on the available resources)&lt;/li&gt;&#xA;&lt;li&gt;The objective function (Maximizing the profit, minimizing the wasted time on the production line, etc.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After defining the mentioned concepts, the mathematical model, which needs to cover as many details as it can, should be written. The solving approach depends on the type of objective function and constraints that you have in the model. In &lt;a href=&quot;https://www.solver.com/examples-optimization-problems&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt;, you can find a set of examples for mathematical modeling of real-life problems.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-07-20T19:34:16.780" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1048" PostTypeId="2" ParentId="1027" CreationDate="2019-07-20T21:26:10.047" Score="6" Body="&lt;p&gt;I go out on a limb and have a controversial answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;All the problems in machine learning are not optimization problems.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before you object, think twice. What about training a deep net? Isn't that an optimization problem. It sure is! But the underlying problem, i.e. the one which is the &lt;em&gt;machine learning problem&lt;/em&gt;, is to build a deep net that is able to predict the outcome for unseen data. (If you know the terms: Training the net is minimizing the empirical loss, but the goal is to minimize the expected loss over the unknown distribution of the data - why minimization of the empirical loss works as good as is does is not full explained to this day.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Isn't clustering an optimization problem? Well, yes and no. You can cluster according to some objective and then you need to solve an optimization problem. But there are different objectives which could make sense and again, the underlying problem in unsupervised learning does not have an objective, but the goal is &quot;to discover hidden clusters in the data&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Isn't regression an optimization problem? The answer is the same: You can use optimization to compute the regressors, but the underlying problem is prediction of unseen data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't get me wrong: Machine learning uses and needs &lt;em&gt;a lot&lt;/em&gt; of optimization (and constraint programming is no exception) but the real problems in machine learning (mostly prediction) are of a different type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I may have another point as to why AI/ML gets so much attention: Recent results in machine learning are surprising (to both scientists and non-scientists), since ML can make the computer do things which we as humans can not explain, because we have no idea how they work. I (and I guess anybody else) do not have any idea on how to write an algorithm that makes the computer tell what is on an image. It's not that we did not try. Computer vision developed tools for about 70 years, but nobody could write a programm that makes a computer tell &quot;This image shows a car.&quot; Now machine learning can produce algorithms which do exactly that. But the difference is: The programmer did not directly encode any mechanism to detect cars. That's a big difference to all the things that have been done in optimization. We have tons of great code that can make the computer do incredible things. But we worked hard to figure out all that lines of code and basically we can tell exactly what we told the computer to do. If you don't like images: It's the same with the question &quot;How can we make a computer understand spoken language?&quot;&lt;/p&gt;&#xA;" OwnerUserId="624" LastEditorUserId="624" LastEditDate="2019-07-21T05:33:28.760" LastActivityDate="2019-07-21T05:33:28.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1049" PostTypeId="2" ParentId="1039" CreationDate="2019-07-21T03:32:03.370" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Take visiting a conference as an example; you (the worker) want to choose which talks/events (jobs) to attend (process) during the fixed duration of the conference, but can only be in one place at once. Has this type of problem been studied? If so, what names is it usually called by?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Generally it's called scheduling, timetabling or rostering, but there are many specific variations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Such problems go by various names (all the following information is from Wikipedia):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Generalized_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Generalized Assignment Problem&lt;/a&gt; (more than one person and one task)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of agents and a number of tasks. Any agent can be assigned to perform any task, incurring some cost and profit that may vary depending on the agent-task assignment. Moreover, each agent has a budget and the sum of the costs of tasks assigned to it cannot exceed this budget. It is required to find an assignment in which all agents do not exceed their budget and total profit of the assignment is maximized. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the special case in which all the agents' budgets and all tasks' costs are equal to 1, this problem reduces to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;assignment problem&lt;/a&gt;. When the costs and profits of all tasks do not vary between different agents, this problem reduces to the multiple knapsack problem. If there is a single agent, then, this problem reduces to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Knapsack_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;knapsack problem&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Assignment Problem&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the numbers of agents and tasks are equal, and the total cost of the assignment for all tasks is equal to the sum of the costs for each agent (or the sum of the costs for each task, which is the same thing in this case), then the problem is called the &lt;em&gt;linear assignment problem&lt;/em&gt;. Commonly, when speaking of the assignment problem without any additional qualification, then the linear assignment problem is meant. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Nurse_scheduling_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nurse Scheduling Problem&lt;/a&gt; (NSP), also called the nurse rostering problem (NRP)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Operations_research&quot; rel=&quot;nofollow noreferrer&quot;&gt;operations research&lt;/a&gt; problem of finding an optimal way to assign nurses to shifts, typically with a set of &lt;a href=&quot;https://en.wikipedia.org/wiki/Constrained_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;hard constraints&lt;/a&gt; which all valid solutions must follow, and a set of soft constraints which define the relative quality of valid solutions. Solutions to the nurse scheduling problem can be applied to constrained scheduling problems in other fields.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.m.wikipedia.org/wiki/Schedule_(workplace)&quot; rel=&quot;nofollow noreferrer&quot;&gt;Workplace Scheduling&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A schedule, often called a rota or roster, is a list of employees, and associated information e.g. location, working times, responsibilities for a given time period e.g. week, month or sports season.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A schedule is necessary for the day-to-day operation of many businesses e.g. retail store, manufacturing facility and some offices. The process of creating a schedule is called scheduling. An effective workplace schedule balances the needs of stakeholders such as management, employees and customers. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Gantt_chart&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gantt Chart&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Gantt chart is a type of bar chart that illustrates a project schedule, named after its inventor, Henry Gantt (1861–1919), who designed such a chart around the years 1910–1915. Modern Gantt charts also show the dependency relationships between activities and current schedule status.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This chart lists the tasks to be performed on the vertical axis, and time intervals on the horizontal axis. The width of the horizontal bars in the graph shows the duration of each activity. Gantt charts illustrate the start and finish dates of the terminal elements and summary elements of a project. Terminal elements and summary elements constitute the work breakdown structure of the project. Modern Gantt charts also show the dependency (i.e., precedence network) relationships between activities.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-07-21T03:32:03.370" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1050" PostTypeId="1" AcceptedAnswerId="1051" CreationDate="2019-07-21T06:25:07.007" Score="15" ViewCount="13954" Body="&lt;p&gt;The terms &quot;soft constraints&quot; and &quot;hard constraints&quot; are used in the context of optimization modeling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any standard way to figure out which is which in some of the complicated models?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="145" LastEditDate="2019-07-21T09:21:22.203" LastActivityDate="2019-07-23T15:33:48.723" Title="Soft constraints and hard constraints" Tags="|optimization|modeling|constraint|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1051" PostTypeId="2" ParentId="1050" CreationDate="2019-07-21T06:52:42.110" Score="26" Body="&lt;p&gt;In an optimization model, a &lt;em&gt;hard constraint&lt;/em&gt; is a constraint that &lt;strong&gt;must&lt;/strong&gt; be satisfied by any feasible solution to the model. On the other hand, a &lt;em&gt;soft constraint&lt;/em&gt; can be violated, but violating the constraint incurs a penalty in the objective function (often, the greater the amount by which the constraint is violated, the greater the penalty). So, a good way to start looking for soft constraints in models is to find constraints that have associated penalty terms in the objective function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, suppose you are a manager, and you are planning one of your salaried employee’s schedule for the next week. Suppose that &lt;span class=&quot;math-container&quot;&gt;$x \geq 0$&lt;/span&gt; is the total number of hours the employee is to work Monday through Friday, and &lt;span class=&quot;math-container&quot;&gt;$y \geq 0$&lt;/span&gt; is the total number of hours the employee is to work on Saturday and Sunday. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A hard constraint in this scenario might be - “by her contract, this salaried employee is allowed to work no more than 40 hours per week”: &lt;span class=&quot;math-container&quot;&gt;$x+y \leq 40$&lt;/span&gt;. A similar soft constraint might be - “this employee &lt;em&gt;should&lt;/em&gt; work no more than 40 hours per week, but must be paid £150 per hour for every hour she works over 40”: &lt;span class=&quot;math-container&quot;&gt;$x + y - z \leq 40$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$z \geq 0$&lt;/span&gt; is the number of hours over 40 the employee is scheduled to work. Then, in the model’s objective function, you would include a term “&lt;span class=&quot;math-container&quot;&gt;$+150z$&lt;/span&gt;” (assuming some type of cost minimization objective).&lt;/p&gt;&#xA;" OwnerUserId="196" LastEditorUserId="196" LastEditDate="2019-07-21T06:58:59.627" LastActivityDate="2019-07-21T06:58:59.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1052" PostTypeId="1" AcceptedAnswerId="1053" CreationDate="2019-07-21T07:01:04.163" Score="22" ViewCount="3251" Body="&lt;p&gt;I encounter a nonlinear constraint that contains the square root of a sum of integer variables. Of course one could use nonlinear solvers and techniques; but I like linear programming. Are there any standard results on linearizing or approximating a square root of the sum of integer variables?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the constraints look like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sqrt{\sum_{i \in \mathcal{I}} a_{ij}x_{ij}  }  \leq \theta_j, \quad \quad \forall j \in \mathcal{J}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \in \{0,1\}$&lt;/span&gt; are binary variables, &lt;span class=&quot;math-container&quot;&gt;$\theta_j \in \mathbb{R}$&lt;/span&gt; are continuous variables, and &lt;span class=&quot;math-container&quot;&gt;$a_{ij} \geq 0$&lt;/span&gt; are parameters.  &lt;span class=&quot;math-container&quot;&gt;$\mathcal{I}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}$&lt;/span&gt; are any given sets of polynomial size. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, this constraint is part of a larger MIP, but as I am curious to general methods and results regarding this constraint I believe it not to be of interest to post it here.&lt;/p&gt;&#xA;" OwnerUserId="48" LastEditorUserId="123" LastEditDate="2019-09-30T06:40:06.003" LastActivityDate="2019-09-30T06:40:06.003" Title="Linearize or approximate a square root constraint" Tags="|linear-programming|nonlinear-programming|constraint|linearization|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1053" PostTypeId="2" ParentId="1052" CreationDate="2019-07-21T10:44:10.450" Score="21" Body="&lt;p&gt;This can be handled as an MISOCP, Mixed-Integer Second Order Cone problem. The leading commercial MILP solvers can also handle MISOCP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, due to &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; being binary, &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^2 = x_{ij}$&lt;/span&gt;. Therefore, the left-hand side is the two-norm of the vector over &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt; having elements &lt;span class=&quot;math-container&quot;&gt;$\sqrt{a_{ij}} x_{ij}$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know whether this is the best way to handle this constraint, but it is a way, and it is &quot;exact&quot;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="67" LastEditDate="2019-07-21T15:21:51.337" LastActivityDate="2019-07-21T15:21:51.337" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="1054" PostTypeId="2" ParentId="357" CreationDate="2019-07-21T11:49:51.630" Score="11" Body="&lt;p&gt;I learned of another one recently. Again depending on how broad your definition of &quot;OR&quot; is. There is Jim Orlin from MIT and his son Ben Orlin, of Math With Bad Drawings fame.  (&lt;a href=&quot;https://mathwithbaddrawings.com/&quot; rel=&quot;noreferrer&quot;&gt;https://mathwithbaddrawings.com/&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="34" LastActivityDate="2019-07-21T11:49:51.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1055" PostTypeId="2" ParentId="928" CreationDate="2019-07-21T11:55:05.553" Score="8" Body="&lt;p&gt;I personally like the 4/3 conjecture for Metric or Euclidean TSP:&#xA;&lt;a href=&quot;http://himtp.or.uni-bonn.de/index.php/The_4/3-Conjecture_for_Eulidean_TSP&quot; rel=&quot;noreferrer&quot;&gt;http://himtp.or.uni-bonn.de/index.php/The_4/3-Conjecture_for_Eulidean_TSP&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="34" LastActivityDate="2019-07-21T11:55:05.553" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1056" PostTypeId="2" ParentId="1040" CreationDate="2019-07-21T14:44:30.940" Score="20" Body="&lt;p&gt;First of all, ensure you can explain previous projects you have done very detailed. If you recently graduated this could also be your master thesis or papers you wrote as part of your PhD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the best ways to test a candidate, in my opinion, is to do a case interview where we ask the candidate to solve an OR problem and go through the different steps. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An overall question could be &quot;Let's say we want to build a model to schedule all our delivery trucks. What should we do?&quot;, I would then go through with the candidate in questions similar to these in broadly these three categories. (I won't provide answers to the questions, as I don't think it will help you in an interview to memorize answers to some specific questions. A good interviewer will keep probing to understand the depth of your knowledge.)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Problem definition skills&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The ability to go from a loosely defined problem to a well-defined problem that can be solved using OR-methods. This also tests creativity and the ability to brainstorm potential problem components. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What could the objectives we would want to improve be?&lt;/li&gt;&#xA;&lt;li&gt;What decisions should be taken by the model?&lt;/li&gt;&#xA;&lt;li&gt;What constraints should we likely take into account?&lt;/li&gt;&#xA;&lt;li&gt;What data should we try to gather?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Technical OR skills&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The ability to build and code a model. This is where we can get really deep into the OR methods and technical details. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What method would you use to solve this problem? &lt;/li&gt;&#xA;&lt;li&gt;How would you decide between using an exact or a heuristic method?&lt;/li&gt;&#xA;&lt;li&gt;If we should formulate this as a mixed-integer programming model, what would your decision variables be? Can you write up a constraint that should be included?&lt;/li&gt;&#xA;&lt;li&gt;If we solved this using a Tabu search, how would you create an initial solution? What would your neighborhood be?&lt;/li&gt;&#xA;&lt;li&gt;What programming language would you use? &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Communication skills&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The ability to communicate findings and results to both technical and non-technical people.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Let's say we solved this problem and now want to present it to the responsible manager. How should we do that?&lt;/li&gt;&#xA;&lt;li&gt;How can we visualize a solution?&lt;/li&gt;&#xA;&lt;li&gt;How can we prove that our solutions are better than what they do today? What data would we need?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Hope this can help you. Good luck with your job search!&lt;/p&gt;&#xA;" OwnerUserId="140" LastEditorUserId="140" LastEditDate="2019-07-21T19:29:44.850" LastActivityDate="2019-07-21T19:29:44.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1057" PostTypeId="2" ParentId="1052" CreationDate="2019-07-21T16:19:03.210" Score="4" Body="&lt;p&gt;Please also have a look at the very &lt;a href=&quot;https://math.stackexchange.com/a/3203652&quot;&gt;similar question&lt;/a&gt; in math.stackexchange. As @Mark L. Stone mentioned in his answer, all you need is a second-order cone model to solve your problem.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-07-21T16:19:03.210" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1058" PostTypeId="2" ParentId="1050" CreationDate="2019-07-21T16:54:59.250" Score="6" Body="&lt;p&gt;Out of many implementations of these terms in the literature, an example of categorization of the constraint into soft and hard constraints can be found in the paper by Ilham Berrada et al., where they categorized their constraints in a nurse scheduling problem as either soft or hard. They stated that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Some hard constraints &lt;strong&gt;must&lt;/strong&gt; be satisfied by all feasible solutions. They are related to administrative and union contract specifications. Other constraints (so-called soft constraints) are concerned with days off, the number of consecutive working days, and other specific nurses' wishes&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;These soft constraints are treated as &lt;strong&gt;goals&lt;/strong&gt; to be reached&lt;/em&gt;, where the overall objective is to get as close as possible to these goals. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Paper: Berrada, Ilham, Jacques A. Ferland, and Philippe Michelon. &quot;A multi-objective approach to nurse scheduling with both hard and soft constraints.&quot; Socio-economic planning sciences 30.3 (1996): 183-193.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-07-22T14:24:58.867" LastActivityDate="2019-07-22T14:24:58.867" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1059" PostTypeId="2" ParentId="1052" CreationDate="2019-07-21T17:36:25.843" Score="3" Body="&lt;p&gt;To linearize that constraint &lt;em&gt;as it is&lt;/em&gt; can be hard since it is non-convex. Assuming you still want to do that, you would need to introduce binary variables that allow you characterize the function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Focusing on a single &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, let first define &lt;span class=&quot;math-container&quot;&gt;$w_j=\sum\limits_{I\in I}a_{i,j} x_{i,j}$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$w_j\geq 0$&lt;/span&gt; and assume you have a bound on such that &lt;span class=&quot;math-container&quot;&gt;$w_j\leq UB_j$&lt;/span&gt;. Now let &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; be the number of pieces (linear inequalities) you want to use to describe &lt;span class=&quot;math-container&quot;&gt;$\sqrt{w_j}$&lt;/span&gt;, and for each piece, let &lt;span class=&quot;math-container&quot;&gt;$m_{k,j}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_{k,j}$&lt;/span&gt; be the slope and intercept of the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;th piece of the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;th constraint for &lt;span class=&quot;math-container&quot;&gt;$k=1,\ldots,n$&lt;/span&gt;, which are tangent lines of &lt;span class=&quot;math-container&quot;&gt;$\theta_j=\sqrt{w_j}$&lt;/span&gt; at (finite) points &lt;span class=&quot;math-container&quot;&gt;$w_{k,j}\in[0,UB_j]$&lt;/span&gt; (these are the breakpoints in the &lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt; space), &lt;span class=&quot;math-container&quot;&gt;$k=1,\ldots,n+1$&lt;/span&gt;. Since the constraint are not convex, only one piece can be &quot;on&quot; in an optimal solution, hence, let &lt;span class=&quot;math-container&quot;&gt;$\lambda_{k,j}\in\{0,1\}$&lt;/span&gt; be a binary variable that is one if the piece is &quot;on&quot; for constraint &lt;span class=&quot;math-container&quot;&gt;$j\in J$&lt;/span&gt;, zero otherwise. Putting all together, &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Choose only one piece for crt &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{k=1}^n{\lambda_{k,j}}=1 \quad\forall j\in J$$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt; need to be in the right interval if you choose piece &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$-M(1-\lambda_{k,j}) + w_{k,j}\le w_j \le w_{k+1,j} + M(1-\lambda_{k,j}) \quad \forall j \in J,\,k=1,\ldots,n$$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Definition of &lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$$w_j = \sum\limits_{I\in I}a_{i,j} x_{i,j} \quad\forall j \in J$$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This is the linearized constraint, where &lt;span class=&quot;math-container&quot;&gt;$\theta_j$&lt;/span&gt; is greater or equal to the piece that is selected: &lt;span class=&quot;math-container&quot;&gt;$$\theta_j\ge m_{k,j} w_j + b_{k,j} - M(1-\lambda_{k,j}) \quad\forall j\in J,\, k=1,\ldots,n$$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As a side note, you have to choose the breakpoints upfront. A plot of &lt;span class=&quot;math-container&quot;&gt;$\theta_j\ge \sqrt{w_j}$&lt;/span&gt; (for a single &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, this a 2D-plot) can help to clarify the linearization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your constraints are convex (e.g., the inequality is &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; or you treat it as an SOCP as described in the answer above), then you could implement &lt;a href=&quot;https://epubs.siam.org/doi/abs/10.1137/0108053?journalCode=smjmap.1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kelley's cutting-plane&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; method which is an outer approximation method. Those cuts are not cuts in the integer programming sense, so don't add them as cuts. Rather, in B&amp;amp;B add them as lazy constraints. Alternatively, if the MIP is easy to solve, generate a single (Kelley's) cut at a time an re-optimize.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Kelley, J. E., Jr. (1960). The Cutting-Plane Method For Solving Convex Programs. &lt;em&gt;Journal of the Society for Industrial and Applied Mathematics&lt;/em&gt;. 8(4):703-712. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="602" LastEditorUserId="123" LastEditDate="2019-09-30T06:36:45.207" LastActivityDate="2019-09-30T06:36:45.207" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1060" PostTypeId="1" CreationDate="2019-07-21T21:00:37.673" Score="-3" ViewCount="358" Body="&lt;p&gt;I need help in solving part b). I need to solve it using excel can someone help?&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;a) Conduct a discounted cash flow calculation to determine the NPV of the following project, assuming a required rate of return of 0.22. The project will cost 75,000 USD but will result in cash inflows of 18,000 USD, 25,000 USD, 35,000 USD, and 50,000 USD in each of the next four years.&lt;/p&gt;&#xA;&lt;p&gt;b) In Problem a), assume that the inflows are uncertain but normally distributed with standard deviations of 1000 USD, 1500 USD, 2000 USD, and 3000 USD, respectively. Find the mean forecast NPV. What is the probability the actual NPV will be positive? Hint: Use Monte Carlo simulation&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I solved part a) using this:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{NPV} = 75000 + \frac{18000}{1+0.22} + \frac{25000}{(1 + 0.22)^2} + \frac{35000}{(1 + 0.22)^3}  + \frac{50000}{(1+ 0.22)^4}$$&lt;/span&gt;&#xA;However, in part b) the inflows are not constant and have a normal distribution. How can I calculate the NPV in such cases? Can someone tell me how to proceed?&lt;/p&gt;&#xA;" OwnerUserId="964" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-07-22T06:04:42.830" Title="NPV calculation using monte carlo simulation" Tags="|modeling|" AnswerCount="1" CommentCount="5" ClosedDate="2019-07-22T09:49:06.583" ContentLicense="CC BY-SA 4.0" />
  <row Id="1061" PostTypeId="2" ParentId="1060" CreationDate="2019-07-21T23:21:39.617" Score="2" Body="&lt;p&gt;Here is an attempt to solve the problem using Monte Carlo simulation. I used &lt;a href=&quot;https://www.palisade.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Palisade software package&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Monte Carlo solution to the problem: I simulated the problem using 10,000 iterations.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/7OxRZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7OxRZ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="965" LastEditorUserId="36" LastEditDate="2019-07-22T00:33:01.547" LastActivityDate="2019-07-22T00:33:01.547" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1062" PostTypeId="2" ParentId="1024" CreationDate="2019-07-22T04:21:56.907" Score="8" Body="&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Which GPU, if any, should I get for mathematical optimization?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In the case of commercially available software, where no source code is available, you are &lt;em&gt;stuck&lt;/em&gt; using the GPU that is better supported by the applications you intend to run.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://developer.nvidia.com/amgx&quot; rel=&quot;nofollow noreferrer&quot;&gt;AmgX&lt;/a&gt;, &lt;a href=&quot;https://developer.nvidia.com/cusolver&quot; rel=&quot;nofollow noreferrer&quot;&gt;cuSOLVER&lt;/a&gt; and &lt;a href=&quot;https://developer.nvidia.com/nvgraph&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvGRAPH&lt;/a&gt; all require Nvidia GPUs, and offer supporting articles on their &lt;a href=&quot;https://devblogs.nvidia.com/parallel-direct-solvers-with-cusolver-batched-qr/&quot; rel=&quot;nofollow noreferrer&quot;&gt;blog&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://cusplibrary.github.io/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cusp&lt;/a&gt; is a library for sparse linear algebra and graph computations based on Thrust. Cusp provides a flexible, high-level interface for manipulating sparse matrices and solving sparse linear systems. It is written to use CUDA.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/danielhanchen/hyperlearn&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hyperlearn&lt;/a&gt; requires CUDA. Offers GPU acceleration of: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Matrix Completion algorithms - Non Negative Least Squares, NNMF&lt;/li&gt;&#xA;&lt;li&gt;Batch Similarity Latent Dirichelt Allocation (BS-LDA)&lt;/li&gt;&#xA;&lt;li&gt;Correlation Regression&lt;/li&gt;&#xA;&lt;li&gt;Feasible Generalized Least Squares FGLS&lt;/li&gt;&#xA;&lt;li&gt;Outlier Tolerant Regression&lt;/li&gt;&#xA;&lt;li&gt;Multidimensional Spline Regression&lt;/li&gt;&#xA;&lt;li&gt;Generalized MICE (any model drop in replacement)&lt;/li&gt;&#xA;&lt;li&gt;Using Uber's Pyro for Bayesian Deep Learning&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.mathworks.com/products/new_products/latest_features.html?s_tid=hp_release_2019a&quot; rel=&quot;nofollow noreferrer&quot;&gt;Matlab&lt;/a&gt; only supports &lt;a href=&quot;https://www.mathworks.com/support/requirements/matlab-system-requirements.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;GPU acceleration&lt;/a&gt; on Nvidia GPUs when using the &lt;a href=&quot;https://www.mathworks.com/solutions/gpu-computing.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Parallel Computing Toolbox&lt;/a&gt;, otherwise any graphics card supporting OpenGL 3.3 with 1GB GPU memory is recommended.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/esa/pagmo2&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pagmo2&lt;/a&gt; supports both Nvidia and AMD GPU acceleration. Pagmo (C++) or pygmo (Python) is a scientific library for massively parallel optimization. It is built around the idea of providing a unified interface to optimization algorithms and to optimization problems and to make their deployment in massively parallel environments easy. A short list of &lt;a href=&quot;https://github.com/esa/pagmo/wiki/Publications&quot; rel=&quot;nofollow noreferrer&quot;&gt;some papers&lt;/a&gt; from the European Space Agency where pagmo was utilized.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Python has a number of libraries that &lt;a href=&quot;https://towardsdatascience.com/python-performance-and-gpus-1be860ffd58d&quot; rel=&quot;nofollow noreferrer&quot;&gt;support CUDA&lt;/a&gt;, but not as much support for &lt;a href=&quot;https://stackoverflow.com/q/56220260/3648282&quot;&gt;AMD GPUs&lt;/a&gt; and OpenCL, some libraries such as &lt;a href=&quot;https://github.com/numba/numba&quot; rel=&quot;nofollow noreferrer&quot;&gt;Numba&lt;/a&gt; support both GPU manufacturers but Nvidia certainly &lt;a href=&quot;https://developer.nvidia.com/how-to-cuda-python&quot; rel=&quot;nofollow noreferrer&quot;&gt;blogs about it&lt;/a&gt; more.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://pypi.org/project/scikit-cuda/&quot; rel=&quot;nofollow noreferrer&quot;&gt;scikit-CUDA&lt;/a&gt; provides Python interfaces to many of the functions in the CUDA device/runtime, cuBLAS, cuFFT, and cuSOLVER libraries distributed as part of NVIDIA’s CUDA Programming Toolkit, as well as interfaces to select functions in the CULA Dense Toolkit. Both low-level wrapper functions similar to their C counterparts and high-level functions comparable to those in NumPy and Scipy are provided.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://faculty.cse.tamu.edu/davis/suitesparse.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;SuiteSparse&lt;/a&gt; libraries for sparse matrix operations on Nvidia GPUs.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.deeplearning.net/software/theano/introduction.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Theano&lt;/a&gt; combines aspects of a computer algebra system (CAS) with aspects of an optimizing compiler. It can also generate customized C code for many mathematical operations. This combination of CAS with optimizing compilation is particularly useful for tasks in which complicated mathematical expressions are evaluated repeatedly and evaluation speed is critical. For situations where many different expressions are each evaluated once Theano can minimize the amount of compilation/analysis overhead, but still provide symbolic features such as automatic differentiation.It &lt;a href=&quot;http://www.deeplearning.net/software/theano/requirements.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;requires CUDA&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://viennacl.sourceforge.net/viennacl-about.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;ViennaCL&lt;/a&gt; provides CUDA, OpenCL and OpenMP computing backends. It enables simple, high-level access to the vast computing resources available on parallel architectures such as GPUs and is primarily focused on common sparse and dense linear algebra operations (BLAS levels 1, 2 and 3). It also provides iterative solvers with optional preconditioners for large systems of equations.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;A good website for benchmarks for FP64, FP32 and FP16 is Lambda Labs, one article in particular (&quot;&lt;a href=&quot;https://lambdalabs.com/blog/best-gpu-tensorflow-2080-ti-vs-v100-vs-titan-v-vs-1080-ti-benchmark/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Deep Learning GPU Benchmarks - Tesla V100 vs RTX 2080 Ti vs GTX 1080 Ti vs Titan V&lt;/a&gt;&quot;) offers a great &lt;em&gt;bottom line&lt;/em&gt; on what you get, and how much it costs. Don't let the DL slant discourage you, DL can be used for optimization (fast results, not guaranteed to be absolutely optimal) either as a starting point for your variables or a final result. &lt;strong&gt;My purpose&lt;/strong&gt; of mentioning this article is to cite these quotes:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Results summary&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;As of February 8, 2019, the NVIDIA RTX 2080 Ti is the best GPU for deep learning research on a single GPU system running TensorFlow. A typical single GPU system with this GPU will be:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;37% faster than the 1080 Ti with FP32, 62% faster with FP16, and 25% more expensive.&lt;/li&gt;&#xA;  &lt;li&gt;35% faster than the 2080 with FP32, 47% faster with FP16, and 25% more expensive.&lt;/li&gt;&#xA;  &lt;li&gt;96% as fast as the Titan V with FP32, 3% faster with FP16, and ~1/2 of the cost.&lt;/li&gt;&#xA;  &lt;li&gt;80% as fast as the Tesla V100 with FP32, 82% as fast with FP16, and ~1/5 of the cost.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Note that all experiments utilized Tensor Cores when available and are priced out on a complete single GPU system cost. As a system builder and AI research company, we're trying to make benchmarks that are scientific, reproducible, correlate with real world training scenarios, and have accurate prices. So, we've decided to make the spreadsheet that generated our graphs and (performance / \$) tables public.&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&quot;2080 Ti vs V100 - is the 2080 Ti really that fast?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;How can the 2080 Ti be 80% as fast as the Tesla V100, but only 1/8th of the price? The answer is simple: NVIDIA wants to segment the market so that those with high willingness to pay (hyper scalers) only buy their TESLA line of cards which retail for ~\$9,800. The RTX and GTX series of cards still offers the best performance per dollar.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If you're not AWS, Azure, or Google Cloud then you're probably much better off buying the 2080 Ti. There are, however, a few key use cases where the V100s can come in handy:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;If you need FP64 compute. If you're doing Computational Fluid Dynamics, n-body simulation, or other work that requires high numerical precision (FP64), then you'll need to buy the Titan V or V100s. If you're not sure if you need FP64, you don't. You would know.&lt;/li&gt;&#xA;  &lt;li&gt;If you absolutely need 32 GB of memory because your model size won't fit into 11 GB of memory with a batch size of 1. If you are creating your own model architecture and it simply can't fit even when you bring the batch size lower, the V100 could make sense. However, this is a pretty rare edge case. Fewer than 5% of our customers are using custom models. Most use something like ResNet, VGG, Inception, SSD, or Yolo.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;So. You're still wondering. Why would anybody buy the V100? It comes down to marketing.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;2080 Ti is a Porsche 911, the V100 is a Bugatti Veyron&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The V100 is a bit like a Bugatti Veyron. It's one of the fastest street legal cars in the world, ridiculously expensive, and, if you have to ask how much the insurance and maintenance is, you can't afford it. The RTX 2080 Ti, on the other hand, is like a Porsche 911. It's very fast, handles well, expensive but not ostentatious, and with the same amount of money you'd pay for the Bugatti, you can buy the Porsche, a home, a BMW 7-series, send three kids to college, and have money left over for retirement. [Rob's note: costs are different for him compared to my calculations.]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;And if you think I'm going overboard with the Porsche analogy, you can buy a DGX-1 8x V100 for \$120,000 or a Lambda Blade 8x 2080 Ti for \$28,000 and have enough left over for a real Porsche 911. Your pick.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus, you want to pick a GPU manufacturer that provides better benchmarks for the programs you want to run, unless you have the source code &lt;strong&gt;&lt;em&gt;and&lt;/em&gt;&lt;/strong&gt; possess some GPU tweaking skills.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best &lt;strong&gt;deal&lt;/strong&gt; is probably the &lt;strong&gt;&lt;a href=&quot;https://www.anandtech.com/show/13923/the-amd-radeon-vii-review/15&quot; rel=&quot;nofollow noreferrer&quot;&gt;AMD Radeon VII&lt;/a&gt;&lt;/strong&gt; with it's &lt;a href=&quot;https://www.anandtech.com/show/13923/the-amd-radeon-vii-review/3&quot; rel=&quot;nofollow noreferrer&quot;&gt;FP64 rate of 1/4&lt;/a&gt; for only U$700, and even though it's new it's also being discontinued; so there may be some price drops coming. Unfortunately while the hardware is probably a better deal for many people the amount of software available that can wrestle the performance out of it is far fewer and not as developed as what's available for an Nvidia card.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;2&quot;&gt;&#xA;  &lt;li&gt;Does there exist any mathematical optimization software that can fully exploit multiple modern GPUs?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;All of the above links list software that benefits from more GPU cores, even if they are spread across multiple cards, multiple machines or even cloud GPU computing in some cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An often quoted article about selecting a GPU and using multiple GPUs is: &quot;&lt;a href=&quot;https://timdettmers.com/2019/04/03/which-gpu-for-deep-learning/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Which GPU(s) to Get for Deep Learning: My Experience and Advice for Using GPUs in Deep Learning&lt;/a&gt;&quot; (2019-04-03) by Tim Dettmers. While it's focus is on Deep Learning it provides an excellent explanation of the difficulties and performance increase to be expected when using multiple GPUs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;He also says something about the usage of GPUs, in general (where applicable), but again it's in reference to DL (though still applicable to OR optimization):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Overall I think I still cannot give a clear recommendation for AMD GPUs for ordinary users that just want their GPUs to work smoothly. More experienced users should have fewer problems and by supporting AMD GPUs and ROCm/HIP developers they contribute to the combat against the monopoly position of NVIDIA as this will greatly benefit everyone in the long-term. If you are a GPU developer and want to make important contributions to GPU computing, then an AMD GPU might be the best way to make a good impact over the long-term. For everyone else, NVIDIA GPUs might be the safer choice.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Articles about using GPUs for Operations Research:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.researchgate.net/publication/308967833_GPU_Computing_Applied_to_Linear_and_Mixed_Integer_Programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;GPU Computing Applied to Linear and Mixed Integer Programming&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s13676-013-0026-0&quot; rel=&quot;nofollow noreferrer&quot;&gt;GPU computing in discrete optimization. Part II: Survey focused on routing problems&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.researchgate.net/publication/282461882_gpuMF_a_framework_for_parallel_hybrid_metaheuristics_on_GPU_with_application_to_the_minimisation_of_harmonics_in_multilevel_inverters&quot; rel=&quot;nofollow noreferrer&quot;&gt;gpuMF: a framework for parallel hybrid metaheuristics on GPU with application to the minimisation of harmonics in multilevel inverters&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sup&gt;I'll return later to expand this answer.&lt;/sup&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-07-22T18:41:28.653" LastActivityDate="2019-07-22T18:41:28.653" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1063" PostTypeId="2" ParentId="962" CreationDate="2019-07-22T06:25:54.770" Score="9" Body="&lt;p&gt;There are many good answers already, but here are a few viewpoints I have not seen yet.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Machine Learning (including deep learning) is nothing but mathematical optimization.  Indeed, training a model amounts to minimize a loss function.  The main difference between ML/DL and optimization used in OR/MS is that the former is usually non-linear and unconstrained, while the latter is often linear and heavily constrained.  I include integrality as part of constraints here.  Therefore I encourage you to deep dive on the optimizers used in ML/DL.  A good intro is &lt;a href=&quot;https://arxiv.org/abs/1609.04747&quot; rel=&quot;noreferrer&quot;&gt;https://arxiv.org/abs/1609.04747&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Second, I would not use ML/DL just because it is hot.  I remember when someone bragged on social media about deep learning for sudoku able to solve a sudoku in 5 minutes when any decent MIP solver takes few milliseconds.  I also recently showed colleagues how using cplex (another state of the art solver would do well too) to solve a complex resource allocation problem in few seconds when their deep reinforcement learning was finding a low-quality solution.  &lt;/li&gt;&#xA;&lt;li&gt;Ask yourself when ML/DL would be better suited to predict actions than an optimization solver?  To me, the best case is near real-time decision making.  This is where reinforcement learning can complement methods better suited for longer-term decision making.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="967" LastEditorUserId="36" LastEditDate="2019-07-22T13:01:02.443" LastActivityDate="2019-07-22T13:01:02.443" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1064" PostTypeId="2" ParentId="1027" CreationDate="2019-07-22T13:26:55.217" Score="6" Body="&lt;p&gt;This is an interesting question. One way that I'm thinking about this question is to look at how companies are actually using the term AI. I wrote &lt;a href=&quot;https://medium.com/opex-analytics/why-business-leaders-should-think-of-ai-as-an-umbrella-term-dba8badc55e4&quot; rel=&quot;noreferrer&quot;&gt;blog post&lt;/a&gt; arguing that AI is being used by industry as an umbrella term. And as an umbrella term, it includes deep learning, machine learning, and optimization.  I didn't call it out in the blog, but Constraint Programming would definitely fall under the umbrella. (Of course, reasonable people could argue that industry is using the term incorrectly.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that when the latest version of the term AI surfaced around 2012 with breakthroughs in Deep Learning, the scientists were not using it as an umbrella term. Just like you mentioned in your post that in 80's, researchers thought they were on to something different.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, the business community seems to have taken over the term AI over the last few years. It has largely replaced the term &quot;analytics.&quot;  I think this is a good thing-- the term &quot;analytics&quot; allowed people to get away with just doing reporting.  AI implies that you need some algorithms to help make decisions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We've also seen a recent rise in the term &quot;Artificial General Intelligence&quot; (AGI) to refer to algorithms that think more like a person. AGI seems to be what people were (or are) thinking Deep Learning may do and, maybe, what people thought CP would do in the 80's.&lt;/p&gt;&#xA;" OwnerUserId="191" LastActivityDate="2019-07-22T13:26:55.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1065" PostTypeId="1" CreationDate="2019-07-22T16:24:58.337" Score="12" ViewCount="289" Body="&lt;p&gt;My question concerns recovering a primal optimal solution while performing dual sub gradient ascent. Denoting by &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; the dual multiplier in the &lt;span class=&quot;math-container&quot;&gt;$i^{\text{th}}$&lt;/span&gt; iteration, let &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;x_i = \underset{x \in X}{\operatorname{arg\,min}} \,L(x, y_i) &#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$L(x, y_i) = f(x) + y_i^T g(x)$&lt;/span&gt; is the Lagrangian, where &lt;span class=&quot;math-container&quot;&gt;$f, g$&lt;/span&gt; are convex functions and &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a convex set. The following papers:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Two “well-known” properties of sub-gradient optimization, Kurt M. Anstreicher, Laurence A. Wolsey&#xA;(&lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-007-0148-y&quot; rel=&quot;noreferrer&quot;&gt;https://link.springer.com/article/10.1007/s10107-007-0148-y&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Recovery of primal solutions when using subgradient optimization methods to solve Lagrangian duals of linear programs, Sherali and Choi&#xA;(&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/0167637796000193&quot; rel=&quot;noreferrer&quot;&gt;https://www.sciencedirect.com/science/article/pii/0167637796000193&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;propose to recover the primal optimal solution by constructing an auxiliary sequence &lt;span class=&quot;math-container&quot;&gt;$A = \left( a_i \right)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; is a convex combination of points in the set &lt;span class=&quot;math-container&quot;&gt;$\lbrace{x_k \rbrace}_{k=1}^{i}$&lt;/span&gt;. These papers prove that any accumulation point of the sequence &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; converges to the optimal primal solution of the problem &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\underset{\substack{ x \in X,\\ g(x) \leq 0}}{\min} f(x) &#xA;\end{equation}&lt;/span&gt;&#xA;My question, how does one compute such an accumulation point in practice (code) given that often we only perform a finite number of dual sub gradient iterations? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The construction scheme for primal optimal solution has been applied to practical problems in many papers, but none of them provide any detail as to how they compute such an accumulation point. &lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="51" LastEditDate="2019-07-25T12:58:22.937" LastActivityDate="2019-07-25T12:58:22.937" Title="Recovering primal optimal solutions from dual sub gradient ascent using ergodic primal sequences" Tags="|convexity|duality|global-optimality|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1066" PostTypeId="2" ParentId="1065" CreationDate="2019-07-22T17:15:26.260" Score="7" Body="&lt;p&gt;In general, nonlinear optimization algorithms implemented in finite precision floating point software don't converge exactly to an optimal solution exactly satisfying the optimality conditions. Therefore, practical criteria are developed and implemented whereby the algorithm is terminated and optimality declared when the optimality conditions (or convergence) are met to within some specified tolerance. How such a tolerance is implemented and the numerical value of tolerance is chosen are among the trickiest, and least documented, aspects of practical nonlinear optimization software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, in this case, you will need to implement some practical criterion(a) involving a specified tolerance as to what constitutes &quot;convergence&quot; to an accumulation point. The practical criterion(a) will not be perfect, and can erroneously report convergence which has not really occurred, or not report convergence when it has essentially occurred. Exact convergence will not be achieved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, there is no clean, simple, answer.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2019-07-22T17:15:26.260" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1067" PostTypeId="2" ParentId="1027" CreationDate="2019-07-22T22:27:56.733" Score="2" Body="&lt;p&gt;AI in the 80s has much of the theory, a fraction of the compute capacity and none of the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Machine Learning covers a very broad field of statistical modelling.&#xA;A &quot;data scientist&quot; faces operational and practical challenges in handling the huge volume of data.  Of course there is hype but there is also a step-change in effectiveness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Vanishing Gradient Problem had blocked efforts to learn complex features automatically, Hinton's paper in 2006 allowed unsupervised self-training of much more complex networks given enough data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Continuous dense data is often susceptible to Linear analysis and the kernel trick is very powerful for non-linear fitting.  Robustness and sparsity can be incorporated by the LASSO penalty which is well understood.&#xA;Constrained optimisation is tractable for convex problems, but scalability becomes an issue and even proving you have a convex model can be tough for general types of constraint.&#xA;The big-data approach often involves imposing sparsity, a lot of progress has been made with much stronger non-convex models : compressive sensing.  There are no guarantees and some data is better suited to certain techniques.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Decision trees and forests are not necessarily cutting edge, random forest is one example of a general technique &quot;Bagging&quot;.  I think the question is better posed if you split the optimisation methods (convex/non-convex) and the numerical methods (algebraic/scaling).&lt;/p&gt;&#xA;" OwnerUserId="763" LastActivityDate="2019-07-22T22:27:56.733" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1068" PostTypeId="2" ParentId="1050" CreationDate="2019-07-23T15:33:48.723" Score="8" Body="&lt;p&gt;Note that a particular function of the decision variables can appear in both hard and soft constraints in the same model. For instance, the total hours worked by an individual worker in a week might have a hard upper limit of 60, with a goal of at most (or exactly) 40 and objective penalties for exceeding 40.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-07-23T15:33:48.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1069" PostTypeId="1" AcceptedAnswerId="1075" CreationDate="2019-07-23T22:11:40.967" Score="16" ViewCount="1575" Body="&lt;p&gt;I have been trying to use the SetHint python API in google or-tools to warm start MIPs and solve it using CPLEX. It looks like my hints are accepted by the SetHint function but I am not sure whether CPLEX is actually using the warm start, the CPLEX output log has nothing related to warm start. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have set the following parameters in CPLEX through or-tools&#xA;&lt;code&gt;solver.SetSolverSpecificParametersAsString(f&quot;CPLEX Parameter File Version 12.8.0.0 \n CPXPARAM_Advance 1 \n CPXPARAM_MIP_Display 3 \n  CPXPARAM_MIP_Limits_RepairTries 100 &quot;)&#xA;&lt;/code&gt;&#xA;Does the SetHint API work with CPLEX? Is there a way to warm start CPLEX using or-tools?&lt;/p&gt;&#xA;" OwnerUserId="873" LastEditorUserId="500" LastEditDate="2023-12-13T17:57:56.743" LastActivityDate="2023-12-13T17:57:56.743" Title="Warm start CPLEX using google or-tools" Tags="|mixed-integer-programming|cplex|or-tools|warm-start|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1070" PostTypeId="5" CreationDate="2019-07-23T22:22:53.367" Score="0" Body="&lt;p&gt;Google's &lt;a href=&quot;https://developers.google.com/optimization/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Operations Research tools (OR-Tools)&lt;/a&gt; is open-source software for solving combinatorial optimization problems. It includes solvers for:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vehicle Routing (a specialized library for identifying best vehicle routes given constraints)&lt;/li&gt;&#xA;&lt;li&gt;Graph Algorithms&lt;/li&gt;&#xA;&lt;li&gt;Constraint Programming&lt;/li&gt;&#xA;&lt;li&gt;Linear and Mixed-Integer Programming&lt;/li&gt;&#xA;&lt;li&gt;Algorithms for TSP, VRP, and Graphs.&lt;/li&gt;&#xA;&lt;li&gt;Bin packing and knapsack algorithms.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;It has the ability to call commercial solvers such as Gurobi or CPLEX, or open-source solvers such as SCIP, GLPK, or Google's GLOP (Google linear optimization solver).&lt;/p&gt;&#xA;&lt;p&gt;It is natively written in C++, but is also available in Python, C#, or Java.&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="123" LastEditDate="2021-09-15T06:47:49.547" LastActivityDate="2021-09-15T06:47:49.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1071" PostTypeId="4" CreationDate="2019-07-23T22:22:53.367" Score="0" Body="Questions related to or-tools, Google's open-source software suite for optimization" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-07-24T12:02:51.767" LastActivityDate="2019-07-24T12:02:51.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1072" PostTypeId="2" ParentId="928" CreationDate="2019-07-23T22:52:08.650" Score="6" Body="&lt;p&gt;Personally, I feel that solving bilevel MILPs and non-convex quadratic problems is not yet practically possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While there is some literature on bilevel MIPLPs (e.g. &lt;a href=&quot;http://homepage.univie.ac.at/markus.sinnl/wp-content/uploads/2015/11/secondbilevel-techreport.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fischetti, Matteo, et al. &quot;A new general-purpose algorithm for mixed-integer bilevel linear programs.&quot;&lt;/a&gt;), this work has not yet arrived in robust (commercial) off-the-shelf solvers. But these bilevel problems have many practical applications, quoting from the same paper:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Bilevel optimization problems are very challenging optimization models arising in many important practical contexts, including pricing mechanisms in the energy sector, airline and telecommunication industry, transportation networks, optimal expansion of gas networks, critical infrastructure defense, and machine learning.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For the relevance and discussion of nonconvex QP, &lt;a href=&quot;https://or.stackexchange.com/a/504/69&quot;&gt;this OR answer&lt;/a&gt; is very insightful.&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="69" LastEditDate="2019-07-24T10:07:38.070" LastActivityDate="2019-07-24T10:07:38.070" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1073" PostTypeId="1" AcceptedAnswerId="1074" CreationDate="2019-07-24T09:47:27.497" Score="13" ViewCount="295" Body="&lt;p&gt;Given a fast-stepping Local Search (such as Simulated Annealing or Late Acceptance), which reheating approach is proven to work well?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally speaking, &lt;strong&gt;reheating&lt;/strong&gt; works like this: &lt;em&gt;if [a condition is met] then we [take action] to increase the chance of selecting moves as winning steps.&lt;/em&gt; But the devil is in the details. So let's split that up:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Reheating condition&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When do we check the condition? At the end of every step iteration? Or at every move iteration (so every selected move) for a step?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And what do we check?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The best score hasn't improved for X time&lt;/li&gt;&#xA;&lt;li&gt;Or, the best score hasn't improved for X step iterations&lt;/li&gt;&#xA;&lt;li&gt;Or, the best score hasn't improved for X selected moves evaluated&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Reheating action&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Simulated Annealing we increase the temperature. But how?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;By a configured increasement&lt;/li&gt;&#xA;&lt;li&gt;By a relative increase&lt;/li&gt;&#xA;&lt;li&gt;To the starting temperature&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In Late Acceptance we increase the late score. Again, which way is proven to work well?&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2019-07-24T09:55:54.253" LastActivityDate="2019-07-24T12:51:39.020" Title="In Local Search, which reheating techniques have a good track record?" Tags="|metaheuristics|local-search|simulated-annealing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1074" PostTypeId="2" ParentId="1073" CreationDate="2019-07-24T11:02:12.223" Score="8" Body="&lt;p&gt;This is where automatic algorithm configuration and design comes to the rescue. In my experience, different combinations of strategies work equally fine, at least when combined with other components that have a stronger impact in the algorithm (see my work at [1]); it could even be that in certain cases reheating is not necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, following the list of questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) When to check the condition: after every evaluation of a candidate solution. Checking after every accepted move might work fine at the beginning of the search, less so when you already are in a local optimum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) What to check: relying on time is probably not a good idea, since this is going to be inconsistent across different machines (at the same time, you can evaluate fewer solutions on a slower machine), but all the possibilities you list are valid, and there are many more possible ones (e.g. the acceptance rate in the last X moves falls below a certain threshold). If you want to test only a few solutions, I suggest reheating after X moves evaluated, or after X consecutive rejected moves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) How to increase the temperature: again, there are many possibilities. To keep things simple, you can reheat to the initial temperature, keeping in mind that a &quot;low&quot; value is better than a &quot;high&quot; one, because high values may promote an excessive exploration, and the search will fail to converge for a lot of time. In general, in my experiments with SA I have observed that the better performing algorithms exhibit a strong intensification from the beginning; reheating to high temperature values may bring you very far from good areas of the solution space, because you will accept too many worsening moves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Late Acceptance Hill-Climbing (LAHC) can fit in the SA template, so many of the considerations done for SA apply also here. However, LAHC has fewer parameters and is also very robust, so it is easier to tune.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, the final settings will depend on the problem, the specific instances, and the other settings of the algorithm (cooling scheme, but also e.g. the running time you allow). In my experiments the temperature was usually updated after some long intervals, but with a strong cooling. But again, for your problem, YMMV.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;[1] Alberto Franzin, Thomas Stützle. &quot;Revisiting Simulated Annealing: a Component-Based Analysis&quot;. Computers and Operations Research, 2019; 104, 191-206. &lt;a href=&quot;https://doi.org/10.1016/j.cor.2018.12.015&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1016/j.cor.2018.12.015&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="224" LastEditorUserId="36" LastEditDate="2019-07-24T12:51:39.020" LastActivityDate="2019-07-24T12:51:39.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1075" PostTypeId="2" ParentId="1069" CreationDate="2019-07-24T14:15:27.187" Score="12" Body="&lt;p&gt;See answer on &lt;a href=&quot;https://github.com/google/or-tools/issues/1444&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/issues/1444&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is not implemented.&#xA;I welcome pull requests.&lt;/p&gt;&#xA;&lt;p&gt;You can have a look at the code in the Gurobi or Scip interface files.&lt;/p&gt;&#xA;" OwnerUserId="981" LastEditorUserId="491" LastEditDate="2022-03-03T23:14:42.967" LastActivityDate="2022-03-03T23:14:42.967" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1076" PostTypeId="1" AcceptedAnswerId="1078" CreationDate="2019-07-24T18:11:01.883" Score="10" ViewCount="725" Body="&lt;p&gt;I have a dataframe like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; df&#xA;[Output]: day  spent_amount  location  prediction&#xA;           1        10         US         '0-2'&#xA;           1        20         US         '3-5'&#xA;           1        30         US         '3-5'&#xA;           2        10         US         '3-5'&#xA;           2        20         US         '3-5'&#xA;           2        30         US         '6+'&#xA;           3        10         US         '0-2'&#xA;           3        20         US         '0-2'&#xA;           3        30         US         '6+'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To sum up, I have 3 days, 3 spent_amounts, also 2 locations (I didn't add UK since that is pretty much similar to US) and predictions that are generated by a previous model. So the model predicted for instance on day 3, if you spent 20 for marketing in the US the predictions of sold goods will be between 0 and 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to maximize the value of sold goods based on the predictions and considering the daily budget as the limiting constraint. But since I need to quantify the predictions, I am confused about how to replace them. One idea is to replace them with the mean of two ends. For instance 1 for the prediction '0-2'. But that generates unrealistic results. How can I determine the numeric values to assign to each prediction group?&lt;/p&gt;&#xA;" OwnerUserId="984" LastEditorUserId="47" LastEditDate="2019-07-24T18:48:05.840" LastActivityDate="2019-07-24T21:19:10.963" Title="Running a linear programming model to maximize binned predictions" Tags="|linear-programming|modeling|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1077" PostTypeId="2" ParentId="1076" CreationDate="2019-07-24T20:56:35.007" Score="6" Body="&lt;p&gt;Do you have the distribution of the values in each prediction group? Or are you able to fit those values using a distribution model, into statistical values? If so, you may consider the expected value of each prediction group in your model. Then VAR(Value At Risk) and C-VAR may be used to cover the uncertainty in your predictions. It’s just an idea, I really doubt about the applicability of the approach.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-07-24T20:56:35.007" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1078" PostTypeId="2" ParentId="1076" CreationDate="2019-07-24T21:19:10.963" Score="10" Body="&lt;p&gt;First, I'm not sure that maximizing estimated sales is the correct criterion. If it's possible that a higher marketing spend could raise sales but not enough to compensate for the extra marketing cost, then you might want to work with a net value objective (sales margin less marketing cost).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, supporting what Oguz Toragay said, if you can get distributional data for the values in the prediction groups, you could use that to compute mean (or median) sales in each group and go on from there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third, if you believe that falling at the low / middle / high end of one prediction interval is likely to coincide with the same locations in other intervals, you could run scenarios. (To clarify that condition, what I mean is believing that if one marketing spend gets a prediction of 0-2 and another gets a prediction of 3-5, and if circumstances would conspire to put actual sales at the 0 end of the 0-2 interval, then those same circumstances would tend to put sales at the 3 end of the 3-5 interval.) Under that assumption, you could run one LP using the low end of each interval, one LP using the high end of each interval (with some plausible choice for the high end of &quot;6+&quot;), one LP using the middle of each interval, and maybe a couple more using the first and third quartiles of each interval. So you now have three to five solutions (likely not the same), which you can order according to degree of &quot;conservatism&quot;, present to the decision maker (who is hopefully not you), and say in essence &quot;pick one based on your risk preference&quot;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-07-24T21:19:10.963" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1079" PostTypeId="2" ParentId="534" CreationDate="2019-07-25T00:55:38.650" Score="6" Body="&lt;p&gt;There are many applications of different MCDM (Multi-Criteria Decision Making) method families when there is some kind of uncertainty in weights or amount of objectives or criteria. Mosadeghi et al. (1), in their paper, explained the dimensions of uncertainty in the MCDM problems as follow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the location of uncertainty – where the uncertainty manifests itself within the model&#xA;structure;&lt;/li&gt;&#xA;&lt;li&gt;the level of uncertainty – where the uncertainty manifests itself along the spectrum&#xA;between deterministic knowledge and total ignorance;&lt;/li&gt;&#xA;&lt;li&gt;the nature of uncertainty – whether the uncertainty is due to the imperfection of our&#xA;knowledge or is due to the inherent variability of the phenomena being described.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;They also categorized the methods and approaches that can be used to handle various kind of uncertainty as follow:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Most of the current works have focused on addressing uncertainty in criteria weights estimation. The resulting methodological approaches can be subdivided into two main groups:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first concentrate on developing more sophisticated MCDM techniques, which can process uncertain or inaccurate criteria information. Such advanced MCDM methods include ELECTRE, PROMETHEE, MAUT, Fuzzy set theory, and Random set theory. The Fuzzy set theory techniques are the most common techniques for dealing with imprecise and uncertain problems.&lt;/li&gt;&#xA;&lt;li&gt;The second group of methodologies addressing uncertainty in criteria weightings consists of uncertainty analysis techniques, mostly sensitivity analysis tools. Sensitivity analyses can be performed for both stakeholder weights and attribute weights and provide DMs with an understanding of the system's behavior under the varying nature of the preference parameters.&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The following table, from their paper (1), will also be helpful in finding the related literature:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SqzaI.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SqzaI.png&quot; alt=&quot; Recommended methods to deal with uncertainty in future application of MCDM&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1)  Razieh Mosadeghi, Jan Warnken, Rodger Tomlinson &amp;amp; Hamid Mirfenderesk (2012): Uncertainty analysis in the application of multi-criteria decision-making methods in Australian strategic environmental decisions, Journal of Environmental Planning and Management, DOI:10.1080/09640568.2012.717886&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-07-25T01:23:12.567" LastActivityDate="2019-07-25T01:23:12.567" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1080" PostTypeId="2" ParentId="534" CreationDate="2019-07-25T16:56:21.230" Score="0" Body="&lt;p&gt;There is a whole body of literature in the &lt;a href=&quot;https://en.wikipedia.org/wiki/Analytic_hierarchy_process&quot; rel=&quot;nofollow noreferrer&quot;&gt;Analytic Hierarchy Process&lt;/a&gt; / Analytic Neural Process (AHP/ANP) that examines precisely the issue of stability of the results. For example, &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-1-4614-7279-7_15&quot; rel=&quot;nofollow noreferrer&quot;&gt;Saaty and Vargas&lt;/a&gt; (2013) is a good reference, although you can also look at some of Luis Vargas' recent papers in the area. &lt;/p&gt;&#xA;" OwnerUserId="253" LastActivityDate="2019-07-25T16:56:21.230" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1081" PostTypeId="5" CreationDate="2019-07-25T19:52:12.443" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Parallel_computing#Types_of_parallelism&quot; rel=&quot;nofollow noreferrer&quot;&gt;Parallel computing&lt;/a&gt; and processing involves more than one computational core (CPU or GPU, even &lt;a href=&quot;https://en.wikipedia.org/wiki/Field-programmable_gate_array#Applications&quot; rel=&quot;nofollow noreferrer&quot;&gt;FPGA&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/Application-specific_integrated_circuit&quot; rel=&quot;nofollow noreferrer&quot;&gt;ASIC&lt;/a&gt;) where one task is broken up into sub-tasks or multiple different tasks are executed in parallel in a shorter amount of time than would be required to execute on a single core, assuming a well written program.&lt;/p&gt;&#xA;&lt;p&gt;Each sub-task or entirely different task must be capable of being executed for some period of time without interaction with the other parallel running tasks, otherwise a &lt;a href=&quot;https://en.wikipedia.org/wiki/Deadlock&quot; rel=&quot;nofollow noreferrer&quot;&gt;deadlock&lt;/a&gt; would occur where one running task must wait for the result of another.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Concurrent_computing&quot; rel=&quot;nofollow noreferrer&quot;&gt;Concurrent computing&lt;/a&gt; differs from parallel computing in that with concurrent computing each task can run without reliance on another, if one input (from one user, for example) isn't available the routine can continue to solicit other input. Once the input has been processed it can be sent to it's output destination.&lt;/p&gt;&#xA;&lt;p&gt;Parallel computing, on the other hand, requires that the tasks that were broken up (or the entirely separate tasks, whose output is to be combined) be synchronized to end in-order, or await other tasks which must be completed first. When complex tasks can be divided between more cores and simpler tasks ran on fewer cores, with the completion times synchronized, the execution time can be reduced over running each instruction serially on one core (there being a relatively low upper limit on the clock speed of each core, but an extremely high practical limit on the total number of cores).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="279" LastEditDate="2023-02-24T20:28:38.557" LastActivityDate="2023-02-24T20:28:38.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1082" PostTypeId="4" CreationDate="2019-07-25T19:52:12.443" Score="0" Body="In parallel computing a computational task is typically broken down into many sub-tasks that can be processed independently and whose results are combined upon completion. It is also called multiprocessing. In serial computing a single core multitasks all or part of a series of instructions for a short period of time before switching to another task, giving the appearance of all the tasks running simultaneously even though they run one at a time." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-07-25T21:08:05.613" LastActivityDate="2019-07-25T21:08:05.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1083" PostTypeId="1" CreationDate="2019-07-28T09:38:05.273" Score="15" ViewCount="1694" Body="&lt;p&gt;About Polyhedra, Polyhedron, Polytopes and Polygon, what do they mean in the context of linear programming and what is the difference between them?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2019-07-28T14:01:32.543" LastActivityDate="2019-07-28T14:01:32.543" Title="Polyhedra, Polyhedron, Polytopes and Polygon" Tags="|linear-programming|terminology|polyhedra|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1084" PostTypeId="1" AcceptedAnswerId="1087" CreationDate="2019-07-28T10:11:38.067" Score="8" ViewCount="447" Body="&lt;p&gt;Given a set of Vehicles with source and destination I need to find the minimum time of travel for all the vehicles, there are also some charging stations and its necessary for vehicles to charge 1 time at any of the charging stations&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following input:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.) Vehicles source and destination pair ([(1, 15), (16, 25), (6, 5)])&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.) Charging station [12, 8, 13, 18]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BwPeN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BwPeN.png&quot; alt=&quot;Image of charging station no. 12&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Image of charging station no. 12&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Y5qUm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Y5qUm.png&quot; alt=&quot;Image of charging station no. 18&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Image of charging station no. 18&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Image &lt;strong&gt;&lt;span class=&quot;math-container&quot;&gt;$node_i$&lt;/span&gt;&lt;/strong&gt; denote the vehicle source, &lt;strong&gt;start&lt;/strong&gt; is the time to reach from source to the charging station, &lt;strong&gt;charge&lt;/strong&gt; is the time to charge at that charging station, &lt;strong&gt;destination&lt;/strong&gt; is the time to reach from charging station to their respective destination, &lt;strong&gt;total&lt;/strong&gt; is the sum of all time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to find an allocation of vehicles to the charging station so that total time is minimum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a vehicle is charging at a charging station and at the same time any other vehicle arrives, it needs to wait until charging station is free.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried a greedy approach in which I wrote values in a matrix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lJb19.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lJb19.png&quot; alt=&quot;Greedy Matrix&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Greedy Matrix of total time from charging station tables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this, vehicles are the rows, charging stations are the columns, and the bold ones are the minimum of each row, therefore, I choose them. But, vehicles &lt;strong&gt;1,6&lt;/strong&gt; are allocated to charging station &lt;strong&gt;8&lt;/strong&gt;, which means there can be some waiting time. After checking their start and charging time, the new matrix is formed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/B30BO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/B30BO.png&quot; alt=&quot;updated Greedy Matrix&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Updated Greedy Matrix&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see vehicle &lt;strong&gt;1&lt;/strong&gt; value is updated from &lt;strong&gt;1.21&lt;/strong&gt; to &lt;strong&gt;1.63&lt;/strong&gt;. Now, it's better to allocate &lt;strong&gt;1&lt;/strong&gt; to charging station &lt;strong&gt;13&lt;/strong&gt; because now it has the minimum time. But again, it may need to wait because charging station &lt;strong&gt;13&lt;/strong&gt; already has &lt;strong&gt;16&lt;/strong&gt; allocated to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the approach to solve this kind of problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After suggestions from @prubin I have created these equation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is set of vehicles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is the set of charging stations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$src$&lt;/span&gt; source time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ch$&lt;/span&gt; charging time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$dst$&lt;/span&gt; destination time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$wt$&lt;/span&gt; waiting time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; boolean variable for deciding if v is allocated to s or not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{v \in V} \sum_{s \in S}  (src_{v,s} + ch_{v,s} + dst_{v,s} + wt_{v,s}) * b_{v,s} &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;    \forall i \in V \hspace{0.3cm} \forall j \in V \hspace{0.3cm} \forall s \in S \hspace{0.3cm} wt_{j,s} \geq  ((src_{i,s} + ch_{i,s}) - src_{j,s}) * x_{ij} &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\forall v  \in  V \sum_{s \in S} b_{v,s} = 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{v \in V} \sum_{s \in S} b_{v,s} = |V|&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't figure out way to include non overlapping condition and if multiple vehicles are allocated to the same station how to update &lt;span class=&quot;math-container&quot;&gt;$CH$&lt;/span&gt; value in equation.&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="700" LastEditDate="2019-08-01T18:24:33.557" LastActivityDate="2019-08-01T18:24:33.557" Title="Finding minimum time for vehicle to reach to its destination" Tags="|optimization|combinatorial-optimization|algorithms|scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1085" PostTypeId="2" ParentId="1083" CreationDate="2019-07-28T10:26:46.153" Score="21" Body="&lt;p&gt;The following definitions are taken from this &lt;a href=&quot;https://courses.engr.illinois.edu/cs598csc/sp2010/Lectures/Lecture2.pdf&quot; rel=&quot;noreferrer&quot;&gt;lecture&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Polyhedron&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A &lt;em&gt;polyhedron&lt;/em&gt; in &lt;span class=&quot;math-container&quot;&gt;$\Bbb R^n$&lt;/span&gt; is the intersection of finitely many sets of all points &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$ax\le b$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$a\in\Bbb R^n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b\in\Bbb R$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Polyhedra&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;Polyhedra&lt;/em&gt; is the plural of polyhedron.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Polytope&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A &lt;em&gt;polytope&lt;/em&gt; is a bounded polyhedron, equivalent to the convex hull of a finite set of points which can be shown using Fourier-Motzkin elimination.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Polygon&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A &lt;em&gt;polygon&lt;/em&gt; is a two-dimensional polytope, which can be used when describing the set of feasible solutions.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-07-28T13:01:50.603" LastActivityDate="2019-07-28T13:01:50.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1086" PostTypeId="2" ParentId="1083" CreationDate="2019-07-28T10:29:17.593" Score="10" Body="&lt;p&gt;These are all names used for the feasible set of a linear programming problem. In other words, all the combination of values for the decision variables that correspond to a solution, hence satisfying all of the constraints. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In linear programming, you have continuous variables and linear constraints, which can be equalities or inequalities. For example, let us suppose that we have two decision variables, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. An equality like &lt;span class=&quot;math-container&quot;&gt;$x + y = 5$&lt;/span&gt; defines a line and implies that the all feasible solutions should be in this line, like &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y=5$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x=4.5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y=0.5$&lt;/span&gt;. We may also have inequalities, such as &lt;span class=&quot;math-container&quot;&gt;$x \geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y \geq 0$&lt;/span&gt;, which on top of the equality &lt;span class=&quot;math-container&quot;&gt;$x + y = 5$&lt;/span&gt; would imply that the feasible set is restricted to &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; between 0 and 5 and &lt;span class=&quot;math-container&quot;&gt;$y = 5- x$&lt;/span&gt;. Hence, now we have a segment as our feasible set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Geometrically, the feasible set is a polytope if it is bounded on every direction, such as the segment that we mentioned before. If the feasible set is not bounded, such as when we have only the equality &lt;span class=&quot;math-container&quot;&gt;$x+y=5$&lt;/span&gt; and therefore we can pick an arbitrarily large positive value for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and a corresponding negative value for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, then the feasible set is a polyhedron but not a polytope. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Polyhedra is the plural of polyhedron. A polygon is a polytope with only two dimensions.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2019-07-28T10:29:17.593" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1087" PostTypeId="2" ParentId="1084" CreationDate="2019-07-28T14:57:38.283" Score="12" Body="&lt;p&gt;You can solve this with a mixed integer linear program. It has some similarities to job shop scheduling (with parallel machines) and &lt;a href=&quot;https://en.wikipedia.org/wiki/Multiprocessor_scheduling&quot; rel=&quot;noreferrer&quot;&gt;multiprocessor scheduling&lt;/a&gt;, although it is not identical to either. In one approach, you create continuous variables for each vehicle representing the time the vehicle begins charging, the time it ends charging, and the time it reaches its destination. You add binary variables for each combination of vehicle and charging station, and constraints tying those variables to the continuous variables. Those constraints look like &quot;if vehicle 1 charges at station 12 then charging of vehicle 1 ends ... minutes after it starts and arrival at destination is ... minutes after charging ends.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That leaves the issue of nonoverlap at charging stations, which leads to more binary variables. You can create a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; for each pair &lt;span class=&quot;math-container&quot;&gt;$i \neq j$&lt;/span&gt; of vehicles, such that &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1$&lt;/span&gt; means that &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; charges before &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; if they are at the same charging station. Then you need constraints that relate the time each vehicle starts charging to the time the other vehicle ends charging and the correct &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variable.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-07-28T14:57:38.283" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="1088" PostTypeId="2" ParentId="661" CreationDate="2019-07-29T08:03:32.543" Score="4" Body="&lt;p&gt;Cost matrixes are discussed in the book: &amp;quot;&lt;a href=&quot;https://books.google.ca/books?id=FH6_Bb82I_UC&amp;amp;pg=PA305&amp;amp;lpg=PA305&amp;amp;dq=hub%20assignment%20cost%20matrix&amp;amp;source=bl&amp;amp;ots=dLhHQy9Ulx&amp;amp;sig=ACfU3U0m97RIk43jChoFVHJ6RglqrxH2Dw&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ved=2ahUKEwiJ_76rx9njAhWM4FQKHZckD3wQ6AEwBnoECAkQAQ#v=onepage&amp;amp;q=cost%20matrix&amp;amp;f=false&quot; rel=&quot;nofollow noreferrer&quot;&gt;Assignment Problems&lt;/a&gt;&amp;quot; by Rainer Burkard, Mauro Dell'Amico, Silvano Martello (on pages &lt;a href=&quot;https://books.google.ca/books?id=FH6_Bb82I_UC&amp;amp;pg=PA305&amp;amp;lpg=PA305&amp;amp;dq=hub%20assignment%20cost%20matrix&amp;amp;source=bl&amp;amp;ots=dLhHQy9Ulx&amp;amp;sig=ACfU3U0m97RIk43jChoFVHJ6RglqrxH2Dw&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ved=2ahUKEwiJ_76rx9njAhWM4FQKHZckD3wQ6AEwBnoECAkQAQ#v=onepage&amp;amp;q=cost%20matrix&amp;amp;f=false&quot; rel=&quot;nofollow noreferrer&quot;&gt;73&lt;/a&gt;, and 200, etc.). Yes, some parts would be unconnected (most likely) in such a large problem.&lt;/p&gt;&#xA;&lt;p&gt;Seperation and calculation of the cost matrixes is only the start of the problem. Solving using traditional methods, for so many hubs and nodes, using CPLEX (for example) is going to run into out-of-memory problems.&lt;/p&gt;&#xA;&lt;p&gt;Solution of these problems is complex (nearly NP-hard at that size; but you'll run into time and memory constraints, as opposed to simply not being able to formulate a solution). I can recommend a couple of papers (with 100's of equations) that address the hub-location-allocation problem (HLAP).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&amp;quot;&lt;a href=&quot;https://link.springer.com/article/10.1007/s40092-018-0288-0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bi-objective optimization of multi-server intermodal hub-location-allocation problem in congested systems: modeling and solution&lt;/a&gt;&amp;quot; by Mahdi Rashidi Kahag, Seyed Taghi Akhavan Niaki, Mehdi Seifbarghy and Sina Zabihi, from the Journal of Industrial Engineering International (June 2019, Volume 15, Issue 2, pp 221–248):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;&lt;strong&gt;Abstract:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;A new multi-objective intermodal hub-location-allocation problem is modeled in this paper in which both the origin and the destination hub facilities are modeled as an M/M/m queuing system. The problem is being formulated as a constrained bi-objective optimization model to minimize the total costs as well as minimizing the total system time. A small-size problem is solved on the GAMS software to validate the accuracy of the proposed model. As the problem becomes strictly NP-hard, an MOIWO algorithm with an efficient chromosome structure and a fuzzy dominance method is proposed to solve large-scale problems.&lt;/p&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this paper, a new bi-objective intermodal hub-location-allocation problem within queuing framework was investigated. The developed model of this problem intended to simultaneously minimize the total network costs and the total time spent in the network. The solution of a small-size problem using the GAMS software was presented to show the accuracy of the developed formulation. As the problem belongs to the class of NP-Hard problems with conflicting objectives, an MOIWO algorithm with a new chromosome structure was utilized to solve the problem. Moreover, a fuzzy ranking method was used in MOIWO to prioritize the solutions obtained in each iteration.&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I kept that quote short as I prefer the second paper.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;In the paper: &amp;quot;&lt;a href=&quot;https://link.springer.com/article/10.1007/s10479-017-2517-0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Managing facility disruption in hub-and-spoke networks: formulations and efficient solution methods&lt;/a&gt;&amp;quot; by Nader Azizi, an open access publication of the: Annals of Operations Research (January 2019, Volume 272, Issue 1–2, pp 159–185), in the first section, he offers an introduction to his paper: &amp;quot;The focus of this paper is on the Uncapacitated Single Allocation p-Hub Location problem where the number of hub facilities to open is predetermined. This problem is also known as the Single Allocation p-Hub Median problem.&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;He details some of the history of solving this problem:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;Early research on hub-and-spoke systems focused on developing efficient mathematical formulations and solution techniques for this paradigm. O’Kelly (1986, 1987) presented the first mathematical model for the single allocation p-hub median problem. Another pioneer of the hub location research, Campbell (1994), developed a linear integer formulation for the problem. Based on the idea of multicommodity flow, Ernst and Krishnamoorthy (1996) proposed a new set of formulations for both single and multiple allocation cases. A widely used formulation in the literature for single and multiple allocation p-hub median problem is the work of Skorin-Kapov et al. (1996). The MIP models proposed by Skorin-Kapov et al. (1996) yield to tight linear relaxation.&lt;/p&gt;&#xA;&lt;p&gt;Over the years, a number of solution techniques e.g., approximation and exact methods have been developed and successfully applied to solve instances of the hub location-allocation problem. Examples of such methods include Simulated Annealing (Ernst and Krishnamoorthy 1999), Genetic Algorithm (Kratica et al. 2007), Hybrid GA and Tabu Search (Abdinnour-Helm 1998), Lagrangian Relaxation (Elhedhli and Wu 2010; Contreras et al. 2009), Benders Decomposition (Contreras et al. 2012), Branch and Bound (Ernst and Krishnamoorthy 1998), and Branch and Cut (Yaman and Carello 2005) among others.&lt;/p&gt;&#xA;&lt;p&gt;More recent studies focus on the extension of the classical version and aim to develop more realistic hub location-allocation problems such as models with congestion (e.g., Elhedhli and Wu 2010; Azizi et al. 2017), flow dependent economies of scale (Camargo et al. 2009; Campbell et al. 2005), and competitive hub location models (Eiselt and Marianov 2009). For an overview of hub location problem the reader may refer to Campbell and O’Kelly (2012) and Contreras (2015).&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;In short, the contribution of the paper include:&lt;/p&gt;&#xA;&lt;p&gt;(i) An investigation into a reliable hub-and-spoke system incorporating heterogeneous probability of hub failure&lt;/p&gt;&#xA;&lt;p&gt;(ii) A non-linear model purposely designed to simultaneously construct networks with and without symmetrical flow and select backup facilities for every demand possibly affected by a disruption&lt;/p&gt;&#xA;&lt;p&gt;(iii) An improved linear model with the use of indicator constraints and&lt;/p&gt;&#xA;&lt;p&gt;(iv) Efficient Particle Swarm Optimization (PSO) based meta-heuristics for large instances.&lt;/p&gt;&#xA;&lt;p&gt;The remainder of this paper is organised as follow. In Sect. 2, we describe the problem and present non-linear, linear and improved linear formulations. The details of the three proposed PSO based algorithms are presented in Sect. 3 followed by computational results and discussions in Sect. 5. Concluding remarks are presented in Sect. 6.&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In section 2 he explains (in detail, with almost 100 equations) that a Reliable Single Allocation p-Hub Location problem (RSApHL-I) involves a Mixed Integer Quadratic Programing (MIQP) formulation, and includes &lt;span class=&quot;math-container&quot;&gt;$n^2+4n^3+n^4$&lt;/span&gt; variables. His approach is similar to the technique proposed by Chaovalitwongse et al. (2004) to linearize multi-quadratic 0–1 programming problems. He demonstrates that the problems could be solved more effectively and with significantly less computational efforts when all Big-M formulations are replaced with indicator constraints.&lt;/p&gt;&#xA;&lt;p&gt;He concludes section 2 by saying:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;Due to the limitation in solving the above model formulation to optimality for realistically sized problem instances with CPLEX, one way forward is to design an efficient metaheuristic. In this study, we developed three metaheuristics based on the well-known evolutionary algorithm of Particle Swarm Optimisation (PSO). These algorithms are discussed in section 3.&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;A large portion of the published research works on PSO is dedicated to continuous optimization problems whereas there is a lack of research dealing with its discrete counterpart namely combinatorial optimization problems (Liu et al. 2008). To the best of our knowledge, our proposed algorithms is the first PSO-based optimisation technique to be developed for solving this interesting though challenging class of hub location problem.&lt;/p&gt;&#xA;&lt;p&gt;In this paper two variations of a basic PSO and a hybrid PSO algorithm that incorporate crossover and memory are proposed. The two versions which we refer to as PSO-v1 and PSO-v2, differ in terms of solutions representation and the mechanism by which a continuous particle position is transformed into one or more discrete solution(s). The hybrid PSO algorithm on the other hand, is an extension of PSO-v2 which incorporates a short-term memory and a crossover operator, both of which are in our knowledge, new ingredients that are successfully embedded for the first time into the PSO search methodology.&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In section 6 the paper concludes:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;In this study, a mixed integer quadratic programming (MIQP) formulation is proposed for the reliable single allocation hub location problem with heterogeneous probability of hub failure. The model assigned a backup facility to every demand point in the network for a fast and a low-cost recovery after hub failure. The objective function of the model minimises the weighted transportation cost in regular situation and the expected cost resulted from hub failures.&lt;/p&gt;&#xA;&lt;p&gt;The proposed formulation is developed in such way to maintain the size of the problem after linearization. To improve the computational efficiency of the resulting MILP model, all constraints initially formulated using Big Ms are substituted with logical constraints known as Indicator Constraints. Using the proposed formulation, we solved all small instances and some medium size problem instances to optimality and provided lower and/or upper bounds for other problems. To tackle large instances, three novel algorithms based on PSO namely PSO-v1, PSO-v2 and H-PSO are proposed. In PSO-v1 and PSO-v2, we investigated the effect of two different solution representations and the mechanisms through which a continuous particle is transferred to a discrete solution. It was found that PSO-v2 that maps a continuous particle to a single discrete solution performs better than PSO-v1. The performance of the PSO-v2 is then further improved by introducing two new interesting features namely a crossover operator and a memory to keep track of good solutions that are explored during the search. To our knowledge, this is the first time the hybridisation of PSO with those attributes is examined.&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Other:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;O'Kelly's paper: &amp;quot;&lt;a href=&quot;https://www.researchgate.net/publication/263365490_Hub_Network_Location&quot; rel=&quot;nofollow noreferrer&quot;&gt;Network Hub Location&lt;/a&gt;&amp;quot; (2009) is a quick read with a basic overview of the subject.&lt;/p&gt;&#xA;&lt;p&gt;Campbell and O’Kelly provide an excellent survey on the literature of hub location research in their paper: &amp;quot;&lt;a href=&quot;https://www.researchgate.net/publication/236509352_Twenty-Five_Years_of_Hub_Location_Research&quot; rel=&quot;nofollow noreferrer&quot;&gt;Twenty-Five Years of Hub Location Research&lt;/a&gt;&amp;quot;, published in Transportation Science 46(2):153-169 (January 2013).&lt;/p&gt;&#xA;&lt;p&gt;Wikipedia: &lt;a href=&quot;https://en.wikipedia.org/wiki/Facility_location_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Facility Location Problem&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Distributional_cost-effectiveness_analysis&quot; rel=&quot;nofollow noreferrer&quot;&gt;Distributional cost-effectiveness analysis&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Allocative_efficiency&quot; rel=&quot;nofollow noreferrer&quot;&gt;Allocative efficiency&lt;/a&gt;, and &lt;a href=&quot;https://en.wikipedia.org/wiki/Geometric_median&quot; rel=&quot;nofollow noreferrer&quot;&gt;Geometric median&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;LocalSolver 9.0 documentation: &lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/pmedian.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;P-median&lt;/a&gt; (Code examples for LSP, Python, C++, C#, and Java)&lt;/p&gt;&#xA;&lt;p&gt;IBM Forum - &lt;a href=&quot;https://www.ibm.com/developerworks/community/forums/html/forum?id=11111111-0000-0000-0000-000000002053&quot; rel=&quot;nofollow noreferrer&quot;&gt;OPL using CPLEX Optimizer&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-07-29T14:53:36.120" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1089" PostTypeId="1" CreationDate="2019-07-29T22:32:05.327" Score="27" ViewCount="475" Body="&lt;p&gt;It seems the most common answer to this question is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;we periodically scan the websites of our favorite OR journals&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This approach however has several problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you are likely to miss articles.&lt;/li&gt;&#xA;&lt;li&gt;you are likely to forget to do this on a regular basis.&lt;/li&gt;&#xA;&lt;li&gt;it is labor-intensive and time-consuming to manually scan/navigate journal sites&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some alternatives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Academia.com/ResearchGate.net&lt;/strong&gt;: similar to Facebook: large, unordered stream of messages. Personally I find it unsuitable to keep up-to-date with the latest OR publications. It seems primarily useful to request articles/preprints of articles which fall outside your institution's library subscription. These website tend to send a lot of click-bait.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;optimization-online.org/arxiv.org&lt;/strong&gt;: excellent resources to obtain early versions/preprints. optimization-online provides a montly e-mail digest. Good source for cutting-edge papers which are work-in-progress or currently under review. &lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Google scholar&lt;/strong&gt; allows you to follow individual researchers and receive an email when the researcher publishes a new article.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;RSS feeds&lt;/strong&gt;. Many journals provide RSS feeds via which they announce new article publications. RSS readers can aggregate the feeds of different journals. Moreover, you can setup RSS feeds to track publications by individual authors. Sadly, not all top-tier journals keep their RSS feeds up-to-date. Currently, OMEGA international journal of management science for instance hasn't updated their feed for months.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Twitter&lt;/strong&gt;: some 'influencers' share important publications on their twitter feed. Relatively efficient but incomplete.&lt;/li&gt;&#xA;&lt;li&gt;Some journals send out table of contents via &lt;strong&gt;e-mail digests&lt;/strong&gt; (that is, IFF you can find the link/button to subscribe).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Personally I use RSS feeds together with the popular RSS reader Feedly.&#xA;Advantages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I receive all new publications in 1 place (as opposed to scattered over many emails)&lt;/li&gt;&#xA;&lt;li&gt;I can keep track of the ones I read/haven't read.&lt;/li&gt;&#xA;&lt;li&gt;I can quickly scan new articles from a large range of journals, and 'tag' the ones I find interesting.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Disadvantages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There does not seem to be a single RSS reader which is able to generate a proper ToC which states per article the (1) title, (2) journal, (3) authors. Most journals implement the &lt;a href=&quot;https://www.crossref.org/wp/labs/whitepapers/rss-best-practice/&quot; rel=&quot;noreferrer&quot;&gt;'recommendations on RSS Feeds for Scholarly Publishers'&lt;/a&gt;, so all necessary information to generate a proper ToC is present in the RSS stream, but is simply not extracted by the RSS reader. As per example no author information is shown by feedly for the article 'The Structure of the Infinite Models in Integer Programming' published in Mathematics of Operations Research, as can be seen in the following screenshot:  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pfaVg.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pfaVg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The latter disadvantage I find quite significant. It would be worth the effort to implement a simple RSS parser which properly extracts the necessary information from various RSS feeds and which is also able to highlight publications made by researchers you are 'following'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do you follow the latest developments in OR in terms of paper publications/cutting-edge research? I'm particularly interested to learn of structured, systematic, low-effort approaches.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2019-07-30T15:49:31.973" LastActivityDate="2019-08-07T15:59:06.813" Title="How do you keep track of the latest publications in OR" Tags="|literature-research|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1090" PostTypeId="6" CreationDate="2019-07-30T08:35:53.670" Score="0" Body="&lt;h3&gt;TheSimpliFire&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I would like to present my candidature as pro-tempore moderator. And that means a few things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pro-tempore matters&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having participated in Area 51 (e.g creating proposals), I recognise the paramount issues that can hinder the progress of a new site like OR.SE&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Voting: I am glad that the &lt;a href=&quot;https://or.meta.stackexchange.com/q/17/123&quot;&gt;Vote Early, Vote Often&lt;/a&gt; principle has had great effect on the community. I do my best to vote on every Q/A here, and it is nice to see many users casting many votes too.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Q&amp;amp;A: I try to contribute to asking/answering so that the site gets a plentiful supply of knowledge, as well as providing comments. This site has given me great motivation into OR, something I have never thought of before.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Moderation matters&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am an active participant of OR Meta and I strive to maintain this in future. This includes raising ideas that will benefit the community, and voting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I frequently tackle the review queues, and having had much experience on two other sites, I believe this is an area that I am rather strong in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I treat all users fairly and respectfully; the OR community is a very friendly group of people.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-07-30T08:35:53.670" LastActivityDate="2019-07-30T08:35:53.670" CommentCount="0" CommunityOwnedDate="2019-07-30T08:35:53.670" ContentLicense="CC BY-SA 4.0" />
  <row Id="1091" PostTypeId="2" ParentId="1089" CreationDate="2019-07-30T11:11:39.170" Score="5" Body="&lt;p&gt;Very interesting notes about different alternatives.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMHO, it is not necessary a real-time or periodic scan of updates. Related to a particular topic you're researching, it may be enough to do a full &quot;literature review&quot; every, let's say, three or four months.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, to be aware of research trends in general, I like to read twitter (periodically), RG and Google Scholar updates (weekly) and OO digest (monthly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The RSS of engineering blogs are also interesting (for example, &lt;a href=&quot;https://ai.googleblog.com/?m=1&quot; rel=&quot;nofollow noreferrer&quot;&gt;google AI blog &lt;/a&gt;or &lt;a href=&quot;https://eng.uber.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;uber engineering&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="806" LastEditorUserId="39" LastEditDate="2019-07-31T04:42:37.740" LastActivityDate="2019-07-31T04:42:37.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1092" PostTypeId="1" AcceptedAnswerId="1093" CreationDate="2019-07-30T15:00:22.593" Score="14" ViewCount="2267" Body="&lt;p&gt;I am trying to find a reference (or a reformulation) of a variant of the multiple Traveling Salesman Problem, where multiple agents need to visit each vertex in a graph with minimal cost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the literature that I found requires that only one agent needs to visit each vertex, but I am looking to generalize this to requiring multiple and different agents visiting some of the vertices. I have been trying to form this problem into the multiple Traveling Salesman problem, (and eventually use an approximation algorithm) but I have not been successful in reformulating the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the references that I looked into were&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1016/j.jalgor.2005.01.007&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arkin, Esther M., Refael Hassin, and Asaf Levin. &quot;Approximations for minimum and min-max vehicle routing problems.&quot; Journal of Algorithms 59.1 (2006): 1-18&lt;/a&gt;, and&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1016/j.omega.2004.10.004&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bektas, Tolga. &quot;The multiple traveling salesman problem: an overview of formulations and solution procedures.&quot; Omega 34.3 (2006): 209-219.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But, as I mentioned before, these papers require that each vertex is visited only once, and I want to require multiple agents to visit some of the vertices.&lt;/p&gt;&#xA;" OwnerUserId="1017" LastEditorUserId="1017" LastEditDate="2019-07-31T13:16:46.107" LastActivityDate="2019-07-31T13:16:46.107" Title="A variant of the Multiple Traveling Salesman Problem" Tags="|integer-programming|reference-request|combinatorial-optimization|graphs|traveling-salesman|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1093" PostTypeId="2" ParentId="1092" CreationDate="2019-07-30T17:34:54.803" Score="9" Body="&lt;p&gt;Y. Kaempfer and L. Wolf, in their recent paper [1] applied ML techniques to solve the Multiple Traveling Salesmen Problem (mTSP). They provide a mathematical model for problem formulation which can be modified to cover what you need in the solution to your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can replace the constraint (2d) which is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\forall 2\leq j \leq n: \sum\limits_{i=1}^{n}\sum\limits_{k=1}^m \delta_{i,j,k}=1 \ \ (2d)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\forall 2\leq j \leq n: \sum\limits_{i=1}^{n}\sum\limits_{k=1}^m \delta_{i,j,k} \geq 2 \ \ (2d')$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;depends on the number of agents that need to visit each vertex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rest of the constraints in their model can be kept the same. In addition to the mentioned paper the following resources could also be helpful:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Multiple Traveling Salesman Problem (mTSP) in &lt;a href=&quot;https://neos-guide.org/content/multiple-traveling-salesman-problem-mtsp&quot; rel=&quot;noreferrer&quot;&gt;Neos guide&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A Multi-Agent Approach for Solving Traveling Salesman Problem [2], in which you may find some hints regarding the approximation approach to solve the problem.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There is also a similar question in &lt;a href=&quot;https://stackoverflow.com/q/6239148&quot;&gt;Stack Overflow: Travelling Salesman with multiple salesmen?&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;[1] &lt;a href=&quot;https://arxiv.org/abs/1803.09621&quot; rel=&quot;noreferrer&quot;&gt;Kaempfer, Yoav, and Lior Wolf. &quot;Learning the multiple traveling salesmen problem with permutation invariant pooling networks.&quot; arXiv preprint arXiv:1803.09621 (2018).&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] &lt;a href=&quot;https://doi.org/10.1007/BF02829218&quot; rel=&quot;noreferrer&quot;&gt;Tiejun, Zhou, Tan Yihong, and Xing Lining. &quot;A multi-agent approach for solving traveling salesman problem.&quot; Wuhan University Journal of Natural Sciences 11.5 (2006): 1104-1108.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-07-30T19:43:54.357" LastActivityDate="2019-07-30T19:43:54.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1094" PostTypeId="2" ParentId="1092" CreationDate="2019-07-30T17:43:47.763" Score="9" Body="&lt;p&gt;You can model your problem by defining separate variables for each traveling salesman. Below I will use 'vehicle' instead of 'traveling salesman', which is more common in this setting.&lt;/p&gt;&#xA;&lt;h3&gt;Defining separate variables&lt;/h3&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; be the number of customers and let &lt;span class=&quot;math-container&quot;&gt;$m \le n$&lt;/span&gt; be the number of vehicles.&#xA;For each vehicle &lt;span class=&quot;math-container&quot;&gt;$k = 1, \dots, m$&lt;/span&gt;, define the variables&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{ij}^k := \begin{cases} 1 &amp;amp; \textrm{ if vehicle $k$ travels from $i$ to $j$} \\ 0 &amp;amp; \textrm{ else.} \end{cases}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Constraints&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For each vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, add constraints to make sure that the variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^k$&lt;/span&gt; describe a valid route. It is important that customers cannot be visited twice by the same vehicle. If you don't know the number of vehicles in advance, choose &lt;span class=&quot;math-container&quot;&gt;$m=n$&lt;/span&gt; and make sure that empty routes are allowed (all &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^k = 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; for a given &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Add constraints that say that every node is visited by the appropriate number of vehicles. Note that the earlier constraints enforce that each visit is by a unique vehicle.&lt;/li&gt;&#xA;&lt;li&gt;You can enforce that node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; can only be visited by certain vehicles by setting &lt;span class=&quot;math-container&quot;&gt;$x_{pi}^k = 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$p \in V$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; are incompatible.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="145" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-07-30T18:18:43.867" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1095" PostTypeId="1" AcceptedAnswerId="1097" CreationDate="2019-07-30T19:14:16.737" Score="12" ViewCount="595" Body="&lt;p&gt;I looked around for a while, but I couldn't find a precise answer to the following question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I'm given a candidate solution for a (mixed) integer (convex) program, what's the complexity of deciding whether this solution (a point in the decision space) is optimal or not? I imagine that this decision problem is not NP (i.e., optimality of a MIP feasible solution can't be certified in polynomial time), right? Do you know any text or a reference where this problem is treated in detail?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much!&lt;/p&gt;&#xA;" OwnerUserId="994" LastActivityDate="2019-07-30T21:03:02.263" Title="Complexity of verifying optimality in (mixed) integer programming" Tags="|mixed-integer-programming|computational-complexity|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1096" PostTypeId="6" CreationDate="2019-07-30T19:27:45.237" Score="0" Body="&lt;h3&gt;LarrySnyder610&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I would be happy to serve as a moderator for OR.SE. I was one of the founding members of the site and have been active in promoting it in various ways—on Twitter, by email, at conferences, in my classes—and plan to continue to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm interested in the governance of our site. I &lt;a href=&quot;https://or.meta.stackexchange.com/users/38/larrysnyder610?tab=topactivity&quot;&gt;post frequently on Meta&lt;/a&gt; and have tried to be proactive in building consensus regarding OR.SE's attitude toward policy questions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a moderator, I would be mindful of the consensus of the OR.SE community (especially on Meta), even when it differs from that of SE as a whole. For example, our community seems to welcome certain types of questions (e.g., &quot;big lists&quot;) that SE tends to frown upon, and is (I think) still making up its mind about other types (e.g., homework questions). I would do my best to encourage new members to post, and to help them formulate productive Q&amp;amp;A. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Above all, I would strive to be fair and patient with all members of the community. I've really enjoyed spending time and effort on OR.SE so far, and look forward to helping it grow into a successful site.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-07-31T13:24:03.300" LastActivityDate="2019-07-31T13:24:03.300" CommentCount="0" CommunityOwnedDate="2019-07-30T19:27:45.237" ContentLicense="CC BY-SA 4.0" />
  <row Id="1097" PostTypeId="2" ParentId="1095" CreationDate="2019-07-30T19:39:05.673" Score="13" Body="&lt;p&gt;Deciding if a given solution to a mixed integer linear program is optimal is &lt;a href=&quot;https://en.wikipedia.org/wiki/Co-NP-complete&quot; rel=&quot;noreferrer&quot;&gt;coNP-complete&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the answer is “no, it is not optimal” there is an efficiently verifiable witness—a better solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Minor caveat: This answer assumes that there is a better solution that is &lt;em&gt;efficiently&lt;/em&gt; verifiable (which necessitates that it can be represented with a polynomial number of bits). This is true for mixed integer linear programs, but might not be true for a more generic mixed integer convex program. Here is a &lt;a href=&quot;https://link.springer.com/article/10.1007%2Fs10107-016-1036-0&quot; rel=&quot;noreferrer&quot;&gt;recent paper on the issue of polynomial-size bit encodings for mixed integer quadratic programs&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="53" LastEditDate="2019-07-30T21:03:02.263" LastActivityDate="2019-07-30T21:03:02.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1098" PostTypeId="2" ParentId="1092" CreationDate="2019-07-30T19:40:23.910" Score="5" Body="&lt;p&gt;I'd like to add a few more ideas that could be important for solving this problem. I agree that a multiple-vehicle integer programming formulation may be a reasonable approach. In an arc-based model, decision variables &lt;span class=&quot;math-container&quot;&gt;$x^k_{ij}$&lt;/span&gt; specify that vehicle/salesperson &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; travels between &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on its subtour. In such a formulation, you should create multiple copies for each vertex that needs to be visited multiple times, not create edges between vertex copies, and add a side constraint that ensures that vehicle/salesperson &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; visits at most one copy of any vertex. Note that making copies introduces some symmetries that can create computational problems. A modeling idea to avoid some difficulties that might arise due to such symmetries is to allow vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; to only visit copies &lt;span class=&quot;math-container&quot;&gt;$\{1,2,...,k\}$&lt;/span&gt; of any vertex by not including certain edges/variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It may be important to include some constraints on the tours generated. For example, you could constrain the number of visits made by each vehicle: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{ij} x^k_{ij} \leq c$$&lt;/span&gt; or constrain the total duration of each vehicle tour: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{ij} t_{ij} x^k_{ij} \leq d \quad .$$&lt;/span&gt; If you want to be sure that vehicles serve tours with roughly the same number of visits or same total duration, you could use a minimax objective where you minimize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and constrain &lt;span class=&quot;math-container&quot;&gt;$$z \geq \sum_{ij} x^k_{ij} \quad \text{or} \quad z \geq \sum_{ij} t_{ij} x^k_{ij} \quad \forall \; k \quad .$$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One minor problem with such an arc-based formulation is that &lt;em&gt;subtour elimination&lt;/em&gt; constraints will be required for each vehicle/salesperson. Since no individual vehicle needs to serve all vertices, it is important to use appropriate SEC constraints. One option is the Miller-Tucker-Zemlin approach that introduces ordering decision variables (in this case, for each vehicle). If all the vehicles have a common base/depot vertex 0, then the typical SEC constraints that prevent cycles that do not include vertex 0 will work with minor modifications. Since these types of constraints are added dynamically, symmetry requires that you add them for each vehicle when they are required for any vehicle and that all copies of vertex &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; should be included in the subtour set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="105" LastActivityDate="2019-07-30T19:40:23.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1099" PostTypeId="1" CreationDate="2019-07-30T20:07:27.707" Score="21" ViewCount="4967" Body="&lt;p&gt;I am a graduate student in OR and I want to build one or two independent projects that go beyond academic projects in my university. I would like to target average people and/or those in the industry who may or may not use an existing app/software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The obstacle is I feel that everything is already done. Whenever I pick a problem I find at least one application developed by a certain company that solves it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: how to innovate in OR i.e (a) how to identify new problems for which there is no  existing apps or (b) how to create competitive products that add values by solving a problem that is already solved ? &#xA;Examples are welcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit : The problem is the difficulty to get demos to try to improve on existing apps which make (b) very difficult. Meanwhile, (a) needs a lot of creativity. So, any tricks ?&lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2019-07-31T01:09:21.293" LastActivityDate="2020-01-19T20:39:57.693" Title="How to innovate in OR" Tags="|applications|" AnswerCount="8" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1100" PostTypeId="2" ParentId="1099" CreationDate="2019-07-30T20:49:20.797" Score="10" Body="&lt;p&gt;I'd argue that any OR application that you can find in the real world, even when you find a product for it, can still be improved. How? By answering this question: How realistic the underlying assumptions of that software are? Because the more generic a tool gets, there will be sacrifices by means of simplified assumptions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you are creating a tool that solves variants of VRP, can your tool actually handles all sorts of VRP? Of course you can argue that you can bake in some conditions to check what type of VRP you are solving, and activate an appropriate algorithm accordingly, but still, you need to make some simplifying assumptions, one way or the other, to obtain your goal of having a generic tool that can be used by anyone with a routing problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many other metrics you can think about. Consider the VRP tool from above again. Is the benchmark software that you are comparing your hypothetical tool with, gives you the optimal solution? How long does it take for that software to get the answer? How user-friendly the software is? How long does it take to train a new user on that software? How can you load data (from what sources) and how can you see the outputs and reports? Is it compatible with other common tools? How much does that software cost? If you can improve even on one of these aspects (while keeping all the others at least the same), you can create a useful product.&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-07-30T20:56:26.063" LastActivityDate="2019-07-30T20:56:26.063" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1101" PostTypeId="2" ParentId="1099" CreationDate="2019-07-30T21:20:54.687" Score="18" Body="&lt;p&gt;Many times the problems people have are similar to, but not identical to, problems that have been solved. So previously employed techniques may still work, but either the model or the solution method may need to be &quot;tweaked&quot; to handle the current stakeholder's problem. In the context of optimization, this may mean adding new constraints and/or new variables, or it may go so far as to require new solution methods (such as moving from a single MIP model to some version of decomposition). In some cases, the stakeholder's problem may have been solved previously, but not at the scale the stakeholder requires. So, again, new solution methods (and possibly new models) may be needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are looking for a new &quot;generic&quot; category of problems to work with (the next &quot;linear program&quot; or the next &quot;agent-based simulation&quot;), that may be difficult. If you are looking for specific stakeholders who need help (and are not well served by &quot;off the shelf&quot; solutions), that's a bit easier.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-07-30T21:20:54.687" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1102" PostTypeId="2" ParentId="1099" CreationDate="2019-07-31T07:58:08.313" Score="18" Body="&lt;p&gt;Over a decade ago, I also had the feeling that pretty much everything is already done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Today, dealing with OR problems every day, I see more opportunities that can fit in a lifetime - or even our team's bandwidth (*).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The best way to see great opportunities, is to talk to customers, users, communities, operators.&lt;/strong&gt; It's hard and time consuming to build up a good network, but it's vital to avoid getting stuck in an ivory tower. A couple of opportunities I see (some are general OR, some are specific to our work):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A production solver for 2D surface and 3D volume packing. Think cutting clothes out of fabric, diamonds out of stone, etc. The CoDES group has done great research around it.&lt;/li&gt;&#xA;&lt;li&gt;VRP variants have a lot of opportunity (as Ehsan pointed out). Mixed pick up and delivery, ...&lt;/li&gt;&#xA;&lt;li&gt;Hyperheuristics in a production solver.&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(*) Today, we have &lt;a href=&quot;https://issues.jboss.org/browse/PLANNER-1552?filter=-8&amp;amp;jql=project%20%3D%20PLANNER%20AND%20status%20in%20(Open%2C%20%22Coding%20In%20Progress%22%2C%20Reopened%2C%20%22Pull%20Request%20Sent%22)%20order%20by%20updated%20DESC&quot; rel=&quot;noreferrer&quot;&gt;555 open issues&lt;/a&gt;, most of which are feature requests. &lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2019-07-31T07:58:08.313" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1103" PostTypeId="2" ParentId="1099" CreationDate="2019-07-31T08:19:53.697" Score="23" Body="&lt;p&gt;Operations Research is still way underutilized in many industries. Even when there exist commercial tools you often find that few organizations have them, and out of the ones that have them, it might only be a few who really utilizes the full capabilities. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an optimization tool to be successful it needs to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Create significant value&lt;/li&gt;&#xA;&lt;li&gt;Fit into the decision process &lt;/li&gt;&#xA;&lt;li&gt;Be easy to understand and use&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Each of these parameters is an opportunity to innovate! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Identifying a problem&lt;/strong&gt; To do this successfully, I recommend identifying a concrete problem that an organization or person is facing where you will be able to develop a tool. If you try to solve a generic problem, such as high-school timetabling or route planning with time windows, you will have a hard time to prioritize what is important and what is not, to get someone to use your tool. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Questions to identify opportunities&lt;/strong&gt; Here are some questions you can try to answer to get a sense around where you innovate:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can OR create value?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can we decrease costs?&lt;/li&gt;&#xA;&lt;li&gt;Can we increase profit?&lt;/li&gt;&#xA;&lt;li&gt;Can we reduce risk?&lt;/li&gt;&#xA;&lt;li&gt;Can we increase customer satisfaction? &lt;/li&gt;&#xA;&lt;li&gt;Can we make the planning process simpler?&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Can it fit into their process flow?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Who makes this decision? Is it one or multiple persons?&lt;/li&gt;&#xA;&lt;li&gt;What information is available when they solve this problem?&lt;/li&gt;&#xA;&lt;li&gt;How often is this problem solved?&lt;/li&gt;&#xA;&lt;li&gt;How fast should we be able to make the decisions?&lt;/li&gt;&#xA;&lt;li&gt;How is the decision communicated out?&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Will the users be able to use it?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How tech-savvy are the users?    &lt;/li&gt;&#xA;&lt;li&gt;How much information does the user need to input? Can we automate it?&lt;/li&gt;&#xA;&lt;li&gt;How can we visualize the result in a simple way?&lt;/li&gt;&#xA;&lt;li&gt;How should the user share the result with the rest of the organization?&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="140" LastEditorUserId="140" LastEditDate="2020-01-19T20:39:57.693" LastActivityDate="2020-01-19T20:39:57.693" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1104" PostTypeId="1" CreationDate="2019-07-31T09:34:10.957" Score="6" ViewCount="1157" Body="&lt;p&gt;In the normal EMSRa and EMSRb (Expected Marginal Seat Revenue) algorithms, each fare class is utilizes exactly 1 unit of capacity (for example, one seat on a plane).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I have a similar problem for Revenue Optimization, where each fare class can occupy a different levels capacity, for example, some fare classes might utilize 1.5x the amount the capacity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you modify the EMSR algorithm such that along with the Fare and the Demand forecast (mean, standard deviation). You are also given a capacity &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; occupied by each fare class &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and given you have some fixed total capacity &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to modify EMSR when capacity for each fare class is different?&lt;/p&gt;&#xA;" OwnerUserId="1020" LastEditorUserId="123" LastEditDate="2019-07-31T09:37:34.790" LastActivityDate="2019-08-04T13:44:11.400" Title="How to modify EMSR when capacity for each fare class is different" Tags="|optimization|combinatorial-optimization|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1105" PostTypeId="1" AcceptedAnswerId="1106" CreationDate="2019-07-31T09:52:14.200" Score="21" ViewCount="3574" Body="&lt;p&gt;This is a question that I've been thinking about for a while, as my background is mainly on pure mathematics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a few OR papers that I've looked at, I could identify some areas of pure mathematics that can be applied to OR:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;(Analytic) Number Theory: deriving asymptotics such as polynomial time&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Metric Spaces: use of the Euclidean metric in TSP&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Differential Geometry: optimal transportation problems&lt;sup&gt;1&lt;/sup&gt; in this case, the Monge and Kantorovich formulations.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Are there other branches of pure mathematics that are currently applied in OR? For each branch that you specify, at least one reference to literature would be much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Loeper, G. (2009). On the regularity of solutions&#xA;of optimal transportation problems. &lt;em&gt;Acta Math.&lt;/em&gt; 202:241-283. doi: 10.1007/s11511-009-0037-8. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-08-02T15:16:26.240" LastActivityDate="2020-09-21T05:59:18.200" Title="Applications of pure mathematics in operations research" Tags="|reference-request|applications|" AnswerCount="9" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1106" PostTypeId="2" ParentId="1105" CreationDate="2019-07-31T11:06:31.703" Score="18" Body="&lt;p&gt;In the following paper &lt;em&gt;Grothendieck inequalities&lt;/em&gt; are applied to OR (Grothendieck was one (if not THE) pioneer of algebraic geometry.)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Briët, Jop, and Frank Vallentin. &quot;Grothendieck inequalities for semidefinite programs with rank constraint.&quot; arXiv preprint arXiv:1011.1754 (2010).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Another example where it is the other way around, i.e. where OR is used to help pure mathematics is the following in which Linear Programming is used to calculate bounds for densities of some measurable sets:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;de Oliveira Filho, Fernando Mário, and Frank Vallentin. &quot;Fourier analysis, linear programming, and densities of distance avoiding sets in ℝn.&quot; Journal of the European Mathematical Society 12.6 (2010): 1417-1428.&#xA;  &amp;nbsp;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="81" LastEditorUserId="-1" LastEditDate="2019-08-01T18:38:39.357" LastActivityDate="2019-08-01T18:38:39.357" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1107" PostTypeId="2" ParentId="1105" CreationDate="2019-07-31T12:55:29.487" Score="10" Body="&lt;p&gt;The latest Notices have a nice article about &lt;a href=&quot;http://www.ams.org/journals/notices/201907/rnoti-p1023.pdf&quot; rel=&quot;noreferrer&quot;&gt;Algebraic and Topological Tools in Linear Optimization&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="741" LastActivityDate="2019-07-31T12:55:29.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1108" PostTypeId="2" ParentId="1105" CreationDate="2019-07-31T13:38:53.810" Score="10" Body="&lt;p&gt;I don't know if you consider combinatorics &quot;pure math.&quot; (I do.) If so, combinatorics is ubiquitous in OR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calculus is also used heavily in many OR fields. One easy example is inventory theory (e.g., the newsvendor problem). Another is calculating expected values over probability distributions, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Speaking of which, metric spaces are central to probability theory, and probability theory is central to many fields of OR such as stochastic processes.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-07-31T13:38:53.810" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1109" PostTypeId="2" ParentId="1099" CreationDate="2019-07-31T13:51:49.450" Score="12" Body="&lt;p&gt;Unfortunately, there's no straightforward answer to the question of &quot;how to innovate in OR.&quot; Innovation is, almost by definition, hard: If it were easy to innovate, everyone would do it, and then it would be hard to find new innovations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds like you are looking for a side project to occupy your spare time, use some of your spare brain-CPU cycles, and provide you with some professional satisfaction. To that end, my advice would be to &lt;strong&gt;choose a project that excites &lt;em&gt;you&lt;/em&gt;,&lt;/strong&gt; and to worry less about &quot;innovating&quot; or &quot;improving on existing apps.&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless your goal is to start a commercial enterprise or to write a research paper (neither of which sounds like your goal), you can innovate simply by doing good work on a project that interests you. It will be more fun for you, and if you do a good job with it, it may find an audience even if it's not &quot;innovative.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give you an example: When I was in grad school, &gt;15 years ago, I wrote a small &lt;a href=&quot;https://coral.ise.lehigh.edu/larry/software/vrp-solver/&quot; rel=&quot;noreferrer&quot;&gt;app to solve the VRP&lt;/a&gt;. It basically implements classical heuristics like Clarke-Wright and 2-opt, with a little randomization thrown in. The project started for a class but I devoted some additional time to it later because I enjoyed it. I packaged the code in a simple Windows app and posted it on my web site. Since then, thousands of people from all over the world have downloaded it, and it's very gratifying to get the little notifications each time someone downloads it. (I still get several each week.) The project has earned me $0, has resulted in 0 publications, and contains nothing innovative, but it remains one of my favorite things I've ever produced. &lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-07-31T13:51:49.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1110" PostTypeId="2" ParentId="1105" CreationDate="2019-07-31T14:52:27.877" Score="15" Body="&lt;p&gt;There's a pretty active research area on incorporating group theory into integer programming (since symmetry can cause a lot of headaches during branch-and-bound). See &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-540-68279-0_19&quot; rel=&quot;noreferrer&quot;&gt;The Group-Theoretic Approach in Mixed Integer Programming&lt;/a&gt; by Richard and Dey, for example.&lt;/p&gt;&#xA;" OwnerUserId="253" LastEditorUserId="354" LastEditDate="2019-08-03T23:41:47.827" LastActivityDate="2019-08-03T23:41:47.827" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1111" PostTypeId="2" ParentId="1104" CreationDate="2019-07-31T15:11:19.520" Score="4" Body="&lt;p&gt;You might be interested in &lt;a href=&quot;https://dl.acm.org/citation.cfm?id=2433809&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;, which addresses the issue of different capacity requests in the context of surgery scheduling. In the paper, the tweak to EMSR is dubbed EMCR-OR.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Stanciu, A., Vargas, L., &amp;amp; May, J. (2010, December). A revenue management approach for managing operating room capacity. In Proceedings of the Winter Simulation Conference (pp. 2444-2454). Winter Simulation Conference.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For a more in-depth treatment, you can also read the &lt;a href=&quot;http://d-scholarship.pitt.edu/8718/&quot; rel=&quot;nofollow noreferrer&quot;&gt;doctoral dissertation&lt;/a&gt; that looked at a more general question, specifically when each request for capacity &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; is a random variable (say, the duration of a surgery):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Stanciu, A. (2009). Applications of revenue management in healthcare (Doctoral dissertation, University of Pittsburgh).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="253" LastActivityDate="2019-07-31T15:11:19.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1113" PostTypeId="5" CreationDate="2019-07-31T20:00:55.897" Score="0" Body="&lt;p&gt;A &lt;a href=&quot;https://en.wikipedia.org/wiki/Distance_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;cost or distance matrix&lt;/a&gt; is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Square_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;square matrix&lt;/a&gt; (two-dimensional array) containing the &lt;a href=&quot;https://en.wikipedia.org/wiki/Distance&quot; rel=&quot;nofollow noreferrer&quot;&gt;distances&lt;/a&gt;, taken pairwise, between the elements of a set. Depending upon the application involved, the distance being used to define this matrix may or may not be a &lt;a href=&quot;https://en.wikipedia.org/wiki/Metric_(mathematics)&quot; rel=&quot;nofollow noreferrer&quot;&gt;metric&lt;/a&gt;. If there are &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; elements, this matrix will have size &lt;span class=&quot;math-container&quot;&gt;$N\times N$&lt;/span&gt;. In graph-theoretic applications the elements are more often referred to as points, nodes or vertices. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When distance is defined as a metric, as for example in the &lt;a href=&quot;https://en.wikipedia.org/wiki/Euclidean_distance_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;Euclidean distance matrix&lt;/a&gt;, the distance matrix satisfies properties directly related to the defining properties of a metric.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A non metric distance can occur in a &lt;a href=&quot;https://en.wikipedia.org/wiki/Network_(mathematics)&quot; rel=&quot;nofollow noreferrer&quot;&gt;network&lt;/a&gt;, a &lt;a href=&quot;https://en.wikipedia.org/wiki/Directed_graph&quot; rel=&quot;nofollow noreferrer&quot;&gt;directed graph&lt;/a&gt; with weights assigned to the arcs, where the distance between two nodes of the network can be defined as the minimum of the sums of the weights on the shortest paths joining the two nodes. There need be no restrictions on the weights other than the need to be able to combine and compare them, so negative weights are used in some applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A classification cost matrix is a matrix, where the element of value is the misclassification cost of guessing a case belongs to class &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, when it actually belongs to class &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Matrix_(mathematics)#Graph_theory&quot; rel=&quot;nofollow noreferrer&quot;&gt;Graph theory&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An undirected graph with adjacency matrix&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ak5LO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ak5LO.png&quot; alt=&quot;Unidirected Graph&quot;&gt;&lt;/a&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{bmatrix}{}&#xA;1 &amp;amp; 1 &amp;amp; 0 \\\&#xA;1 &amp;amp; 0 &amp;amp; 1 \\\&#xA;0 &amp;amp; 1 &amp;amp; 0&#xA;\end{bmatrix}.$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Adjacency_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;adjacency matrix&lt;/a&gt; of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Finite_graph&quot; rel=&quot;nofollow noreferrer&quot;&gt;finite graph&lt;/a&gt; is a basic notion of &lt;a href=&quot;https://en.wikipedia.org/wiki/Graph_theory&quot; rel=&quot;nofollow noreferrer&quot;&gt;graph theory&lt;/a&gt;. It records which vertices of the graph are connected by an edge. Matrices containing just two different values (1 and 0 meaning for example &quot;yes&quot; and &quot;no&quot;, respectively) are called &lt;a href=&quot;https://en.wikipedia.org/wiki/Logical_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;logical matrices&lt;/a&gt;. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Distance_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;distance&lt;/a&gt; (or &lt;strong&gt;cost&lt;/strong&gt;) &lt;a href=&quot;https://en.wikipedia.org/wiki/Square_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;matrix&lt;/a&gt; contains information about distances of the edges. These concepts can be applied to websites connected by hyperlinks or cities connected by roads etc., in which case (unless the connection network is extremely dense) the matrices tend to be &lt;a href=&quot;https://en.wikipedia.org/wiki/Sparse_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;sparse&lt;/a&gt;, that is, contain few nonzero entries. Therefore, specifically tailored matrix algorithms can be used in &lt;a href=&quot;https://en.wikipedia.org/wiki/Network_theory&quot; rel=&quot;nofollow noreferrer&quot;&gt;network theory&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Part of the excerpt was derived from: IBM - &lt;a href=&quot;https://webcache.googleusercontent.com/search?q=cache:fUCT_1zh6pYJ:https://www.ibm.com/support/knowledgecenter/en/SSEPGG_9.7.0/com.ibm.im.model.doc/c_cost_matrix.html%20&amp;amp;cd=5&amp;amp;hl=en&amp;amp;ct=clnk&amp;amp;gl=ca&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cost Matrix&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sources: Wikipedia: &lt;a href=&quot;https://en.wikipedia.org/wiki/Distance_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;Distance Matrix&lt;/a&gt; and Matrix Mathematics (&lt;a href=&quot;https://en.wikipedia.org/wiki/Matrix_(mathematics)#Graph_theory&quot; rel=&quot;nofollow noreferrer&quot;&gt;Graph Theory&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also: Science Direct - &lt;a href=&quot;https://www.sciencedirect.com/topics/computer-science/distance-matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;Distance Matrix&lt;/a&gt;, Wikipedia - &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quadratic Assignment Problem&lt;/a&gt; and Oracle - Data Mining Concepts - &lt;a href=&quot;https://docs.oracle.com/cd/E11882_01/datamine.112/e16808/classify.htm#DMCON004&quot; rel=&quot;nofollow noreferrer&quot;&gt;Biasing a Classification Model&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="38" LastEditDate="2019-07-31T22:52:02.027" LastActivityDate="2019-07-31T22:52:02.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1114" PostTypeId="4" CreationDate="2019-07-31T20:00:55.897" Score="0" Body="For questions related to the cost or distance matrix, a square matrix (two-dimensional array) containing the distances, taken pairwise, between the elements of a set." OwnerUserId="51" LastEditorUserId="38" LastEditDate="2019-08-01T03:24:44.917" LastActivityDate="2019-08-01T03:24:44.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1115" PostTypeId="5" CreationDate="2019-07-31T20:34:14.780" Score="0" Body="&lt;p&gt;Curve or model fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points, possibly subject to constraints. This can involve either &lt;a href=&quot;https://en.wikipedia.org/wiki/Interpolation&quot; rel=&quot;nofollow noreferrer&quot;&gt;interpolation&lt;/a&gt;, where an exact fit to the data is required, or &lt;a href=&quot;https://en.wikipedia.org/wiki/Smoothing&quot; rel=&quot;nofollow noreferrer&quot;&gt;smoothing&lt;/a&gt;, in which a &amp;quot;smooth&amp;quot; function is constructed that approximately fits the data.&lt;/p&gt;&#xA;&lt;p&gt;A related topic is &lt;a href=&quot;https://en.wikipedia.org/wiki/Regression_analysis&quot; rel=&quot;nofollow noreferrer&quot;&gt;regression analysis&lt;/a&gt;, which focuses more on questions of &lt;a href=&quot;https://en.wikipedia.org/wiki/Statistical_inference&quot; rel=&quot;nofollow noreferrer&quot;&gt;statistical inference&lt;/a&gt; such as how much uncertainty is present in a curve that is fit to data observed with random errors. Fitted curves can be used as an aid for data visualization, to infer values of a function where no data are available, and to summarize the relationships among two or more variables. &lt;a href=&quot;https://en.wikipedia.org/wiki/Extrapolation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Extrapolation&lt;/a&gt; refers to the use of a fitted curve beyond the range of the observed data, and is subject to a degree of uncertainty since it may reflect the method used to construct the curve as much as it reflects the observed data.&lt;/p&gt;&#xA;&lt;p&gt;Source: Wikipedia - &lt;a href=&quot;https://en.wikipedia.org/wiki/Curve_fitting&quot; rel=&quot;nofollow noreferrer&quot;&gt;Curve Fitting&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="123" LastEditDate="2020-08-19T14:12:11.533" LastActivityDate="2020-08-19T14:12:11.533" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1116" PostTypeId="4" CreationDate="2019-07-31T20:34:14.780" Score="0" Body="Curve or model fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points, possibly subject to constraints." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-07-31T22:52:18.083" LastActivityDate="2019-07-31T22:52:18.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1117" PostTypeId="1" CreationDate="2019-07-31T21:23:30.867" Score="18" ViewCount="921" Body="&lt;p&gt;My background is a bachelor in mathematics. I learned basics OR on my own using the following :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Introduction to Operations Research by F. Hillier and G. Lieberman&lt;/li&gt;&#xA;&lt;li&gt;Integer programming by l. Wolsey&lt;/li&gt;&#xA;&lt;li&gt;How to Solve It: Modern Heuristics by D. Fogel and Z. Michalewicz&lt;/li&gt;&#xA;&lt;li&gt;Constraint programming online courses available at Coursera&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I learned to use some open-source solvers (Clp, CBC, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to learn skills that are useful for deploying solutions and doing end-to-end projects. I don't know where to start. How about a course in software engineering such as &lt;a href=&quot;https://edge.edx.org/courses/course-v1:UCBerkeley+CS169+2017_Fall/course/&quot; rel=&quot;noreferrer&quot;&gt;CS169 at Berkeley&lt;/a&gt;? Is it useful? Any suggestions for other skills that may be useful?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S: I know how to code using Python, C++, and Java&lt;/p&gt;&#xA;" OwnerUserId="1028" LastEditorUserId="36" LastEditDate="2019-07-31T22:06:20.627" LastActivityDate="2022-08-01T15:54:39.557" Title="Deploying OR solutions and shipping projects" Tags="|reference-request|applications|" AnswerCount="8" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1118" PostTypeId="1" CreationDate="2019-07-31T22:14:20.727" Score="11" ViewCount="216" Body="&lt;p&gt;Disclosure: I am an MSc student in economics, but not an expert by any means in OR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to model a spatial MIP problem of an invasive species similar to &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221716308013&quot; rel=&quot;noreferrer&quot;&gt;this academic paper&lt;/a&gt;, however, my problem differs in that it models the control of a forest pest moving throughout an &lt;span class=&quot;math-container&quot;&gt;$i \times j$&lt;/span&gt; grid killing trees and facing management control constraints. I am using Python and the CPLEX Solver to model and solve my problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conceptually what happens in my problem is that the beetle population moves throughout the gridded landscape and kills a proportion of trees in a cell, but in each time period there is a chance that the beetles will be detected and possibly eradicated. The wall that I am having difficulty in understanding is how you would go about bringing in a spatial element into the problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found some examples of MIP problems that revolve around production decisions, but I have not found any problems that incorporate a spatial grid element in the development of the problem. I have typed phrases such as the following in Google with no prevail of finding examples remotely similar (many academic articles do not release code, so that sucks): &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;CPLEX spatial optimization Python&quot;&#xA;&quot;Python Bioeconomic Optimization&quot;&#xA;&quot;CPLEX Cellular Automata optimization&quot; ... I have a hunch my search terms are not optimal...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I am hoping that someone might be able to point me towards information regarding spatially explicit MIP problems. I apologize if this is not appropriate for the forum, I just don't really know where else to turn to. &lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="196" LastEditDate="2019-07-31T22:39:32.007" LastActivityDate="2019-08-01T18:27:05.950" Title="Are there examples of spatially explicit MIP problems?" Tags="|mixed-integer-programming|python|applications|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1119" PostTypeId="2" ParentId="1117" CreationDate="2019-07-31T22:24:08.013" Score="11" Body="&lt;p&gt;(I focus on the skills rather than suggesting specific courses).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to deploy something, I assume you need a GUI. With that in mind:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you want to host it somewhere, as Stradivari suggested, you can work on Web API. If you want to have it as an executable, well, the software development courses (such as the one you mentioned yourself) can be useful.&lt;/li&gt;&#xA;&lt;li&gt;Do you intend to show some reports or maybe some visualization? If so, you need to know how to do that in the language of your choice.&lt;/li&gt;&#xA;&lt;li&gt;Depending on how you are thinking about your application and how it should work, how it should read the data (from somewhere online, from users, etc), you may need to acquire database management knowledge.&lt;/li&gt;&#xA;&lt;li&gt;Assuming you are familiar with LP and MIP and some open-source solvers, you may want to learn (if you don't know it already) how to solve your desired problem using one of the well-known commercial solvers as well. Because you may hit the wall of the open-source solvers' abilities pretty soon when you try to solve harder problem instances.&lt;/li&gt;&#xA;&lt;li&gt;You can also learn about heuristics and meta-heuristic algorithms for solving difficult problems in case the solvers cannot provide you with an optimal (or even feasible) solution as fast as you like (even after tweaking their parameters). In those cases, you may consider the trade-off between quality and speed and knowing how to develop heuristic algorithms can be your only option.&lt;/li&gt;&#xA;&lt;li&gt;After developing your application, you may find it useful knowing how to gather and process the analytics you collect from the users (such as how many times it's being used? Are there any additional feature requests? How to handle those or answer users' questions? Are there going to be bots involved for the users to interact with and get the answers to some of their basic questions? etc.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-07-31T22:34:39.780" LastActivityDate="2019-07-31T22:34:39.780" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1120" PostTypeId="2" ParentId="1099" CreationDate="2019-07-31T23:17:30.397" Score="7" Body="&lt;p&gt;How to innovate?&#xA;One of my most fruitless experiences was being thrown into an &quot;inventors' club&quot; when I was in fifth grade. We were placed in a room and given a simple task: &quot;Invent something!&quot;&#xA;The result was dismal. No one creates solutions in a vacuum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It was only when I teamed up with people who are solving some of the most worthwhile problems on the face of the Earth that I gained some familiarity with what they do and began to feel their pain for what was needed that I began to acquire the vision and insights to know which problems even needed to be solved. Chasing the dollar won't get you there, either. Pyramid schemes might move a lot of money but they don't do any good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The greatest innovations are found on the path of duty.&lt;/strong&gt;&#xA;Try to serve humanity in the greatest ways possible, and the roadblocks will in process of time become apparent. Interestingly, they are often more human than technical. Nonetheless, if you want to go the route of technical development more than human interaction, there is still much to be done, and intelligent service transforms the human aspect more quickly than anything else that I know of. Henry Ford's maxim was &quot;Service ahead of profit&quot;. You can see we are very much a world on wheels ever since.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Much-wanted attributes of an OR solution are &lt;strong&gt;Generalization&lt;/strong&gt; and &lt;strong&gt;efficiency&lt;/strong&gt;. So many times industry professionals investigate a hyped tool that makes sweeping claims, only to find that (a) it doesn't actually apply out-of-the-box or even with extensive adaptation to their needs in a way that justifies the onboarding expense, and/or (b) the tool is applicable, but intractable for their use case, making its integration unappealing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many of the greatest untapped gold mines are in the space of finding connections across disciplines and building bridges or discovering that two or more things formerly thought to be distinct are actually one and the same. When a high proportion of your learning transfers to another realm, the payoff can be tremendous and many barriers will be removed. Remember that one of the crucial decisions you make is what is your optimization criterion. Once you have chosen a good direction and a good metric, you set the pace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So simply go and serve humankind!&#xA;I'll offer just three very high ROI ideas for starters:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;De-globalization: How to make manufacturing and agricultural endeavors leverage high-yield automation purely from local resources, without relying on the highly sensitive and manipulable global supply chain. I suggest this one as a relief for poverty that will be effective above anything else I can think of except a handful of ideals such as Prohibition and permanently scrapping socialism.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Home medicine and decision-making: Commoditized Bayesian analysis, decision-tree growing, and measurement tools to make pre-diagnosis, citizen science and early treatment of life-threatening diseases orders of magnitude more accessible. The idea is not to have the machine do everything for you, the goal is instead to educate and empower individuals so that they make smarter, better choices.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Personal organization and information management. Help people to discover their talents and resources and maintain their personal knowledge base in a principled way. E-mail clients and web browsing experiences, for example, need extensive overhauls (e.g., when you are researching a problem at work is in many fields probably not the best time for Google to be showing you ads). If you have organized individuals, you have organized organizations, and learning and flow of information will be accelerated exponentially. This problem would undoubtedly benefit from generalized machine learning.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You will notice that all three of these endeavors have a common theme of maximizing service to all people, rather than fattening the bottom line of a given sector. They are intentionally extremely broad so as to demonstrate the necessity of &lt;strong&gt;finding connections&lt;/strong&gt;, interrelatedness, and achieving unity and true generality and efficiency in your solutions, with the end in mind of maximizing service. There is great advantage and progress in empowering the human &quot;swarm&quot; with increased intelligence and education, and this is a key to the success of most if not all operational endeavors: &lt;a href=&quot;https://www.churchofjesuschrist.org/study/general-conference/2008/10/lift-where-you-stand?lang=eng&quot; rel=&quot;noreferrer&quot;&gt;&quot;Lift where you stand&quot;&lt;/a&gt;. When a nineteenth-century religious leader was asked how it was that he had accomplished superhuman feats of societal organization, prosperity, and unity, &lt;a href=&quot;https://www.churchofjesuschrist.org/study/ensign/1990/05/teach-them-correct-principles?lang=eng&quot; rel=&quot;noreferrer&quot;&gt;he replied&lt;/a&gt;, &quot;I teach them correct principles, and they govern themselves.&quot;&lt;/p&gt;&#xA;" OwnerUserId="1030" LastActivityDate="2019-07-31T23:17:30.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1121" PostTypeId="2" ParentId="1118" CreationDate="2019-08-01T01:39:21.113" Score="6" Body="&lt;p&gt;I just searched in Google Scholar for &lt;em&gt;spatial integer programming&lt;/em&gt; and found the following (maybe related, as I am not an expert in this area) papers: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The authors in [1] modeled landfill sitting analysis using spatial data and enhanced their results using a factor they called 'compactness'. You can consider this paper like a facility location problem as LarrySnyder610 mentioned in his comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second paper [2] that I found related to your question, presents MIP formulations that optimize the spatial layout of management actions for providing wildlife habitat, over time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the third study [3], the authors propose a design method that considers the ecological role of the spatial arrangement of reserve sites in relation to the long-term persistence of metapopulations of the target species. They mentioned three MIP models in the paper aiming for three different objectives that they have, then illustrate the applications fo those models in a case study. This study proposed a design method that accounts for the spatial context of reserve designs by emphasizing the ecological function of the spatial arrangement of reserve sites.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope you find these papers helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] Lin, Hung-Yueh, and Jehng-Jung Kao. &quot;Enhanced spatial model for landfill siting analysis.&quot; Journal of environmental engineering 125.9 (1999): 845-851.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] Hof, John, et al. &quot;An integer programming approach for spatially and temporally optimizing wildlife populations.&quot; Forest Science 40.1 (1994): 177-191.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[3] Jiang, Yong, Stephen K. Swallow, and Peter WC Paton. &quot;Designing a spatially-explicit nature reserve network based on ecological functions: an integer programming approach.&quot; Biological Conservation 140.3-4 (2007): 236-249.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-08-01T01:39:21.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1122" PostTypeId="1" AcceptedAnswerId="1123" CreationDate="2019-08-01T02:33:16.270" Score="14" ViewCount="762" Body="&lt;p&gt;&lt;em&gt;A short background:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A paper [1] published in 2006 intends to show that the time needed to solve mixed-integer programming problems by branch and bound can be roughly predicted early in the solution process. Authors mentioned that &quot;The application of the branch-and-bound algorithm can be limited by both the computing time and the storage space required (even when storing nodes on a hard disk). The solution process may take hours or days and there is very little a priori indication of how difficult a model will be to solve. Unfortunately, there is no known method to extract this information from the problem formulation.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;on the other hand, commercial solvers are like black boxes, from which extracting useful data about the number of nodes, number of branches and so on, is very hard (I tried to extract related data from Cplex callback functions in Matlab but the trial was unsuccessful). My question is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there any way to use ML techniques to estimate the branch and bound tree size? Are open-source solvers provide such data that can be used to train an ML model and then test the model on benchmark problems?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing my homework on searching for answers before asking the question, I can mention the following papers that also aimed to tackle the problem:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;Knuth's method:&lt;/em&gt; In [2], two new online methods for estimating the size of backtracking search tree are proposed. They mentioned that, &quot;Knuth’s method estimates &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;, the size of a backtrack tree as &lt;span class=&quot;math-container&quot;&gt;$1 + b_1 + b_1.b_2 + . . .$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; is the branching rate observed at depth &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; using random probing&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Mentioning the effect of choosing the right variable to branch on, the authors in [3] mentioned that &quot;branching on a variable that does not lead to any serious simplifications on any of the (two) children can be seen as doubling the size of the tree with no improvement, thus leading to extremely large (out of control) search trees.&quot;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;[1] Cornuéjols, Gérard, Miroslav Karamanov, and Yanjun Li. &quot;Early estimates of the size of branch-and-bound trees.&quot; INFORMS Journal on Computing 18.1 (2006): 86-96.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] Kilby, Philip, et al. &quot;Estimating search tree size.&quot; Proc. of the 21st National Conf. of Artificial Intelligence, AAAI, Menlo Park. 2006.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[3] Lodi, Andrea, and Giulia Zarpellon. &quot;On learning and branching: a survey.&quot; Top 25.2 (2017): 207-236.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-08-01T06:01:33.283" Title="Estimation of the size of Branch-and-Bound trees using ML" Tags="|mixed-integer-programming|machine-learning|branch-and-bound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1123" PostTypeId="2" ParentId="1122" CreationDate="2019-08-01T05:55:46.830" Score="13" Body="&lt;p&gt;Great question. You might be interested in this paper here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/chapter/10.1007%2F978-3-030-19212-9_18&quot; rel=&quot;noreferrer&quot;&gt;Learning MILP Resolution Outcomes Before Reaching Time-Limit&lt;/a&gt; by Martina Fischetti, Andrea Lodi, and Giulia Zarpellon. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They don't exactly answer your question but you may see why the question is hard to answer and what partial progress can be made.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;A priori&lt;/em&gt; estimating the tree size is estimating whether a model is hard to solve or not. From the static features of the instance, without any runtime knowledge (and even with it!), I personally deem this task virtually undoable. But this is just gut feeling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt; concerning the data: B&amp;amp;B solvers do not provide such data, but of course you can collect this from B&amp;amp;B runs a posteriori.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="354" LastEditDate="2019-08-01T06:01:33.283" LastActivityDate="2019-08-01T06:01:33.283" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1124" PostTypeId="2" ParentId="1032" CreationDate="2019-08-01T05:59:53.747" Score="7" Body="&lt;p&gt;This post is of my interest. I also required a global solver for my problem. I found out that Pyomo has python interface for an opensource global solver called &lt;a href=&quot;https://scip.zib.de/&quot; rel=&quot;noreferrer&quot;&gt;SCIP&lt;/a&gt; for nonlinear optimization problems. You might want to check that out. The process of getting SCIP installed and ready to work on Pyomo is slightly non-trivial and might take some (for which I can help you, &lt;a href=&quot;https://stackoverflow.com/questions/56885640/problems-in-interfacing-scip-with-pyomo&quot;&gt;this&lt;/a&gt; link might be useful) time, but I think this can be something to look out. Hope that helps!&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2019-08-01T05:59:53.747" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1125" PostTypeId="1" AcceptedAnswerId="1271" CreationDate="2019-08-01T09:26:48.920" Score="7" ViewCount="499" Body="&lt;p&gt;I want to solve a problem with &lt;code&gt;docplex.cp&lt;/code&gt; (module for Constraint Programming optimizer CPLEX for Python), and the problem is available in &lt;code&gt;.lp&lt;/code&gt; or &lt;code&gt;.mps&lt;/code&gt; formats. But I did not find the attribute for reading a file in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the CPLEX itself, utilizing the &lt;code&gt;cplex&lt;/code&gt; module it can be done as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import cplex&#xA;&#xA;Model = cplex.Cplex(&quot;MyProblem.lp&quot;)&#xA;Model.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But for the &lt;code&gt;docplex&lt;/code&gt; module I tried to use &lt;code&gt;import_model&lt;/code&gt; as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.cp.model import CpoModel&#xA;&#xA;m = CpoModel()&#xA;Model = CpoModel.import_model(m,&quot;MyProblem.lp&quot;)&#xA;Model.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it is not working as &lt;code&gt;import_model&lt;/code&gt; only supports &lt;code&gt;.cpo&lt;/code&gt;  and &lt;code&gt;.fzn&lt;/code&gt; formats.&lt;/p&gt;&#xA;" OwnerUserId="660" LastActivityDate="2019-08-14T09:46:43.303" Title="Can docplex (module for Constraint Programming optimizer CPLEX for Python) read .lp or .mps file?" Tags="|cplex|python|constraint-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1126" PostTypeId="2" ParentId="1099" CreationDate="2019-08-01T11:40:49.670" Score="12" Body="&lt;p&gt;Think about how many places in the world some kind of staff scheduling are done on a weekly/monthly basis. Everything from hospitals (per ward), schools, retail stores, factories, call centers, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting together the work schedule starting next month is a significant part of many peoples job. However, this problem can surely be solved by OR which would be faster (save time) and more efficient (save money). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From my (limited) overview of the scheduling literature I would say the academic literature is focused on Nurse scheduling and Airline crew scheduling. I know several nurses how has as a part of their job to do this kind of scheduling, so why isn't the well-established literature made into a product they can buy? Maybe it is, maybe some have a few demands (constraints) which are not support by current solutions, but I would argue the main reason is that they are simply not aware of the existence of such solutions. I imagine that the airline are chasing this kind of cost savings more active due to years of price competition. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply applying the existing academic literature with minor to moderate changes to the algorithms is sufficient to become a world-leader within OR in the industry. The market is huge, but market penetration has been poor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Luckily, I feel that there is a shift in focus due to the hype surrounding AI (which I interpret as machine learning in most cases). At my work we have a lot of customer leads that basically starts with the customer stating that &quot;they need some AI to solve this problem&quot;. In the end it might be a min cost network flow problem that needs to be solved, which I would not call AI. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe we should rename OR to AI Classic? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;TL;DR, just because there are existing apps doesn't mean they cannot be enhance with OR techniques/features. Often well-studied OR problems can still have a huge impact in the real-world.&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2019-08-01T11:40:49.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1127" PostTypeId="2" ParentId="1117" CreationDate="2019-08-01T12:24:51.993" Score="9" Body="&lt;p&gt;Gurobi has a series on &lt;a href=&quot;https://www.gurobi.com/resources/seminars-and-videos/?category-filter=seminars-and-videos&quot; rel=&quot;noreferrer&quot;&gt;Adopting Optimization in Your Organization&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently they showcased a state-of-the-art architecture for optimization applications that you can try out on their website. You can even get your hands on the source code. Here is the accompanying webinar: &lt;a href=&quot;https://www.gurobi.com/resource/gurobi-optimization-application-demos/&quot; rel=&quot;noreferrer&quot;&gt;https://www.gurobi.com/resource/gurobi-optimization-application-demos/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="869" LastActivityDate="2019-08-01T12:24:51.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1128" PostTypeId="2" ParentId="1117" CreationDate="2019-08-01T16:13:58.703" Score="5" Body="&lt;p&gt;How about creating a small end-to-end program (GUI, data stored, OR, business logic). It could be a program with GUI that lets the user solve a sudoku. What sets your program apart from various other solutions is a &quot;Solve by MIP&quot; where you then solve it by a MIP like &lt;a href=&quot;https://www.mathworks.com/help/optim/examples/solve-sudoku-puzzles-via-integer-programming.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also make a reverse Sudoku game where you start with a solved game and then make the user remove numbers while keeping a unique solution to the instance. This is somewhat like a game of finding the longest path (very loosely speaking)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course you don't really need a MIP for this problem...&lt;/p&gt;&#xA;" OwnerUserId="268" LastEditorUserId="279" LastEditDate="2020-04-28T12:03:00.413" LastActivityDate="2020-04-28T12:03:00.413" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1129" PostTypeId="2" ParentId="1118" CreationDate="2019-08-01T18:27:05.950" Score="7" Body="&lt;p&gt;You might find the following interesting:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Beyer et al., &quot;Solving conservation planning problems with integer linear&#xA;programming&quot;, Ecological Modelling 328 (2016) 14–22. They deal with planning units, and the spatial considerations may be limited to &quot;adjacent&quot; v. &quot;nonadjacent&quot; (I'm not sure).&lt;/li&gt;&#xA;&lt;li&gt;Haider et al., &quot;A robust optimization approach for solving problems in conservation&#xA;planning&quot;, Ecological Modelling 368 (2018) 288–297. Again, they deal with parcels (something to do with invasive species), and spatial considerations may again be limited to adjacency (something bleeding from one parcel into an adjacent parcel).&lt;/li&gt;&#xA;&lt;li&gt;St. John et al., &quot;Optimizing the Geometry of Wildlife Corridors&quot;, Operations Research, 2018, vol. 66, no. 6, pp. 1471–1485. This uses polygonal decomposition of the relevant space, rather than a lattice of points, and spatial considerations include contiguous paths and the widths of those paths.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Tangentially related to conservation, I'm coauthor of a conference paper on placement of pollution sensors. The spatial domain is treated as a grid of points, and spatial concerns include probability of detecting a pollution event (tied to the distance from each sensor to the event) and communication between sensors (basically creating a path from every sensor, through other sensors, to a base, with distance limits on the links).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-01T18:27:05.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1130" PostTypeId="2" ParentId="1105" CreationDate="2019-08-01T20:27:34.463" Score="8" Body="&lt;h3&gt;Boolean Algebra&lt;/h3&gt;&#xA;&lt;p&gt;Used in network flow and pseudo-Boolean optimisation.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Hammer, P. L., Rudeanu, S. (1968). Boolean Methods in Operations Research and Related Areas. ISBN: 978-3-642-85825-3.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h3&gt;First-Order Logic&lt;/h3&gt;&#xA;&lt;p&gt;Primal and dual algorithms for &amp;quot;blockages&amp;quot;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Hooker, J. N. (1993). New methods for computing inferences in first order logic. &lt;em&gt;Annals of Operations Research.&lt;/em&gt; 43(9):477-492.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="123" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-08-01T20:27:34.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1131" PostTypeId="2" ParentId="1117" CreationDate="2019-08-01T20:56:44.880" Score="10" Body="&lt;p&gt;I think the best way to learn, is to start by building small prototypes for OR tools, and slowly build something bigger. You might already know someone who is struggling with a planning problem where you can help! Maybe a local business, club or organization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you start doing that, I think you will obtain the following skills I think are required to build an OR solution end-to-end:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;OR skills (the secret sauce in your application)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Formulate a problem into a mathematical model&lt;/li&gt;&#xA;&lt;li&gt;Coding an algorithm or use a mathematical solver on your model&lt;/li&gt;&#xA;&lt;li&gt;Present your result in a compelling way&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think the only way to obtain these skills is by solving many different kinds of OR problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Full-stack engineering skills (building stuff)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Creating a user interface&lt;/li&gt;&#xA;&lt;li&gt;Load and save data from API-calls, databases etc.&lt;/li&gt;&#xA;&lt;li&gt;Creating a maintainable infrastructure by separating your code into smaller modules&lt;/li&gt;&#xA;&lt;li&gt;Ensure your code is robust and have unit tests&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A way to obtain these by start building some smaller projects yourself or contribute to open-source projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Product management skills (figuring out what to build)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Talking to users to understand their needs and requirements&lt;/li&gt;&#xA;&lt;li&gt;Deciding which features to build&lt;/li&gt;&#xA;&lt;li&gt;Testing the product which users to obtain feedback&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I can recommend the following two books:&#xA;&quot;Dan Olsen - The Lean Playbook&quot; and &quot;Eric Ries - The Lean Startup&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck. The world needs more OR solutions!&lt;/p&gt;&#xA;" OwnerUserId="140" LastEditorUserId="140" LastEditDate="2020-04-28T17:57:07.523" LastActivityDate="2020-04-28T17:57:07.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1132" PostTypeId="1" AcceptedAnswerId="1136" CreationDate="2019-08-02T14:59:39.433" Score="16" ViewCount="2757" Body="&lt;p&gt;I am enrolled in an Operational Research program. I am also interested in Algorithms, and I wish to know whether &quot;P vs NP&quot; is a common point in both of the fields, so that the effort put in understanding this problem forwards me in both directions.&lt;/p&gt;&#xA;" OwnerUserId="1048" LastEditorUserId="354" LastEditDate="2019-08-02T15:26:57.660" LastActivityDate="2019-08-05T00:11:26.700" Title="Does the problem of P vs NP come under the category of Operational Research?" Tags="|algorithms|computational-complexity|open-problems|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1133" PostTypeId="1" CreationDate="2019-08-02T15:04:12.947" Score="-3" ViewCount="214" Body="&lt;p&gt;Can I know some theories and laws of Operation Research which has being widely used nowadays?&lt;/p&gt;&#xA;" OwnerUserId="530" LastEditorUserId="530" LastEditDate="2019-08-03T06:25:42.440" LastActivityDate="2019-08-03T06:25:42.440" Title="Some theories and laws of Operations Research?" Tags="|optimization|" AnswerCount="2" CommentCount="11" ClosedDate="2019-08-02T17:53:46.433" ContentLicense="CC BY-SA 4.0" />
  <row Id="1134" PostTypeId="2" ParentId="1133" CreationDate="2019-08-02T15:07:45.590" Score="6" Body="&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Little%27s_law&quot; rel=&quot;noreferrer&quot;&gt;Little's Law: &lt;/a&gt; &lt;span class=&quot;math-container&quot;&gt;$L = \lambda W$&lt;/span&gt;. Widely applicable. Widely used.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2019-08-02T15:07:45.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1135" PostTypeId="2" ParentId="1133" CreationDate="2019-08-02T15:13:53.330" Score="6" Body="&lt;p&gt;How about &lt;a href=&quot;https://en.wikipedia.org/wiki/Weak_duality&quot; rel=&quot;noreferrer&quot;&gt;weak&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Strong_duality&quot; rel=&quot;noreferrer&quot;&gt;strong&lt;/a&gt; duality?&lt;/p&gt;&#xA;" OwnerUserId="69" LastActivityDate="2019-08-02T15:13:53.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1136" PostTypeId="2" ParentId="1132" CreationDate="2019-08-02T15:15:19.500" Score="21" Body="&lt;p&gt;The short answer is &lt;em&gt;yes&lt;/em&gt;, operations researchers care a lot about P vs NP. We deal in algorithms, and the complexity of those algorithms matters a lot to us. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The title of your question suggests you are asking whether P-vs-NP is &lt;em&gt;contained within&lt;/em&gt; OR (although the body of your question does not). I would not say that P-vs-NP is contained within OR; rather, it is a topic that is of interest to operations researchers, computer scientists, mathematicians, and others.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-08-02T15:15:19.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1138" PostTypeId="2" ParentId="1132" CreationDate="2019-08-02T15:33:08.473" Score="16" Body="&lt;p&gt;P vs. NP may come &quot;under&quot; the category of Operational Research (O.R.). But unlike theoretical computer science and algorithm analysis, in which P vs. NP may be a be all and end all, practical (non-academic) O.R. people are not necessarily fixated on it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In some circles, NP Hard is essentially considered to mean unsolvable. However, there are several commercial MILP (Mixed Integer Linear Programming) vendors whose entire business model is predicated on the ability and success of their customers to routinely solve NP Hard problems of practical business significance - that is O.R. in action.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2019-08-02T15:33:08.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1139" PostTypeId="2" ParentId="1132" CreationDate="2019-08-02T16:01:31.073" Score="5" Body="&lt;p&gt;As mentioned by others, OR is definitely involved in the P vs. NP issue. If you can find a polynomial time algorithm to solve &lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.217.1914&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;noreferrer&quot;&gt;the Quadratic Assignment Problem&lt;/a&gt; or the TSP which Marco mentioned, both of which are essentially OR problems, then you can say P = NP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, the P vs. NP issue is not strictly “under” OR because there are other fields which are closely intertwined with the “debate” (pure math, applied math, computer science).&lt;/p&gt;&#xA;" OwnerUserId="196" LastActivityDate="2019-08-02T16:01:31.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1140" PostTypeId="1" CreationDate="2019-08-02T22:46:56.757" Score="7" ViewCount="400" Body="&lt;p&gt;A logical constraint combines linear constraints using&#xA;logical operators, such as logical-and, logical-or, negation (that is, not), conditional statements (that is, if ... then ...) to express complex relations between linear constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About chance constraints, it is desired to specify that a certain constraint be satisfied with a given probability.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;P\left[\sum_{j} a_{j} x_{j} \leq b\right] \geq \beta&#xA;\end{equation}&lt;/span&gt;&#xA;According to the above definitions, Is there any difference between Logical constraints and chance constraints?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-08-02T23:40:26.863" Title="Difference between Chance constraints and logical constraints" Tags="|modeling|logical-constraints|chance-constraints|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1141" PostTypeId="2" ParentId="1140" CreationDate="2019-08-02T23:19:58.947" Score="8" Body="&lt;p&gt;Logical constraints do not involve probability, except perhaps for the implicit probability of one or zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chance constraints specify conditions (constraints) which must hold with a(t least) specified probability, which generally would not be one or zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chance constraints could include logical conditions, and potentially even be specified in terms of holding with specified conditional probability, conditional on specified conditions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that neither logical constraints nor chance constraints need be linear.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2019-08-02T23:19:58.947" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1142" PostTypeId="2" ParentId="1140" CreationDate="2019-08-02T23:40:26.863" Score="8" Body="&lt;p&gt;These two types of constraint are totally different in terms of their applications in modeling. In fact, the way of using these constraint types (based on your modeling approach) end up in two totally distinct problems each of which can be solved different solution approaches. In the following, I will try to explain where we need to implement each of the constraint types:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The most direct way to treat &lt;em&gt;stochastic data uncertainty&lt;/em&gt; in the context of uncertain Linear Optimization is offered by an old concept (going back to 50s) of chance constraints &lt;a href=&quot;https://pdfs.semanticscholar.org/3abc/656a6b075d403afa488ce5b9392c32e2f2ff.pdf&quot; rel=&quot;noreferrer&quot;&gt;[source]&lt;/a&gt;. So you can use the chance constraint to deal with uncertainty in the problem and some of the possible approaches to solving this kind of problems are, &lt;em&gt;Value-at-Risk (VaR)&lt;/em&gt; and &lt;em&gt;Conditional Value-at-Risk (CVaR)&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Logical constraints, on the other hand, do not enclose uncertainty. Most of the time logical statements in the problem can be explained and modeled by using constraints that shadow forth the logical situations in the problem.&lt;a href=&quot;http://ben-israel.rutgers.edu/386/Logic.pdf&quot; rel=&quot;noreferrer&quot;&gt;Here&lt;/a&gt; is a good explanation of how to use binary variables to model the logical situations in the form of &lt;em&gt;logical constraints&lt;/em&gt;. To solve the problems with logical constraints most of the solvers can be easily used. &lt;a href=&quot;https://ampl.com/resources/logic-and-constraint-programming-extensions/&quot; rel=&quot;noreferrer&quot;&gt;This link&lt;/a&gt;, includes the details and examples of modeling logical situation in the constraints in one of the commercial modeling languages.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-08-02T23:40:26.863" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1143" PostTypeId="2" ParentId="1117" CreationDate="2019-08-03T00:17:06.987" Score="6" Body="&lt;p&gt;Maybe it's because people take them for granted, but we're forgetting some fundamentals here. No matter what you develop, what solvers you use, what 3rd-party libraries you incorporate,... &lt;strong&gt;put your projects in version control&lt;/strong&gt;. And then learn how to use version control effectively. This helps everyone from developers to end-users to salespeople.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes it's subjective, but in my experience the most difficult part of deploying a solution is not developing the software, it's tracking all the moving parts and expeditiously identifying root causes of problems. This is especially true in multi-developer/team environments. So in addition to version control, let me also throw in documentation, unit testing, code coverage, build automation, and all those types of tools and practices that target code quality and comprehension. They can be boring to learn at times, but they will save you countless hours in the long run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And always keep track of the use cases. :)&lt;/p&gt;&#xA;" OwnerUserId="482" LastActivityDate="2019-08-03T00:17:06.987" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1144" PostTypeId="2" ParentId="1132" CreationDate="2019-08-03T06:14:54.707" Score="11" Body="&lt;p&gt;This goes against the grain of the other answers here, but I do not believe that the P vs NP problem would naturally be categorized as a question in operations research. Instead, I would argue that it is a quintessential example of a question belonging to the TCS (theoretical computer science) field. As others have pointed out, a solution of the P vs NP problem would have potentially significant ramifications in OR, along with many other fields - including in the mathematical and physical sciences. It could even be the case that ultimately a solution of this problem arises from work that started out in OR, in which case it would be yet another example of techniques developed in one field solving a problem in another field.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do I hold this belief? Well, when people ask &quot;what field does question X belong to?&quot; they generally mean something along the lines of &quot;which field did question X originate in? which field studies questions and lines of inquiry that naturally lead to question X? which field would experience the most significant influence due to a resolution of question X?&quot; etc. etc.&#xA;And the field of TCS meets all these criteria (in my opinion) for the P vs NP problem. For instance, &lt;a href=&quot;https://en.wikipedia.org/wiki/P_versus_NP_problem#cite_note-4&quot; rel=&quot;noreferrer&quot;&gt;wikipedia&lt;/a&gt; claims that the question was introduced in a paper entitled &quot;The complexity of theorem proving procedures&quot;, presented at the  Proceedings of the Third Annual ACM Symposium on &lt;strong&gt;Theory of Computing&lt;/strong&gt; (emphasis mine).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While OR and TCS may have many overlapping areas of study and researchers, they are undoubtedly distinct fields (evidenced for example by the fact that I am writing this comment on the OR stackexchange and not the TCS stackexchange!)&lt;/p&gt;&#xA;" OwnerUserId="1053" LastEditorUserId="1053" LastEditDate="2019-08-03T08:58:40.927" LastActivityDate="2019-08-03T08:58:40.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1145" PostTypeId="2" ParentId="1132" CreationDate="2019-08-03T11:43:33.967" Score="6" Body="&lt;p&gt;While other answers have focused on the question whether &quot;P vs. NP&quot; can be considered to be in OR, I will instead look at the parts about this topic that I think are most relevant to study in the context of OR. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The basics&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Before you can even properly understand what &quot;&lt;span class=&quot;math-container&quot;&gt;$\mathsf{P}=\mathsf{NP}$&lt;/span&gt;&quot; or &quot;&lt;span class=&quot;math-container&quot;&gt;$\mathsf{P}\neq \mathsf{NP}$&lt;/span&gt;&quot; means, you need to know what computational problems, complexity classes, and the classes &lt;span class=&quot;math-container&quot;&gt;$\mathsf{P}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathsf{NP}$&lt;/span&gt; are. Some algorithms textbooks include an explanation of the basics. &lt;a href=&quot;https://cs.stackexchange.com/a/9566/&quot;&gt;this answer&lt;/a&gt; also provides a good introduction.&lt;sup&gt;1&lt;/sup&gt;  &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Is my problem NP-hard?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The main practical application of the theory surrounding the P vs. NP question is that for many important computational problems for which no one has been able to find a polynomial-time algorithm, we can show that they are NP-hard. Proving that a problem is NP-hard provides a good argument that trying to find a polynomial-time algorithm for this problem is futile. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does this mean that once we have shown a problem is NP-hard, we should give up on this problem?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Beyond NP-hardness&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;No, of course not. We should give up on finding an exact polynomial-time algorithm and look at other algorithms instead. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other types of algorithms with theoretical performance and quality guarantees: e.g. approximation algorithms, exact exponential algorithms, and fixed parameter tractable (FPT) algorithms. There are general frameworks that can be used to describe NP-hard problems and highly optimized solvers that can often find optimal solutions within reasonable time: e.g. ILP-solvers, SAT-solvers, and constraint satisfaction solvers. We can also choose not to provide guarantees on the solution quality or performance at all and try to find heuristics that work well in practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many problems of interest within OR are NP-hard (e.g. scheduling, TSP), yet there are plenty of algorithms within the frameworks mentioned above that can find solutions to these hard problems that can be used in practice.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is, in my opinion, why the P vs. NP question is relevant for OR. It is not the answer to the question: that will probably elude us for a long time and is very likely not to come from OR. Also, whether it is within the context of OR that the question was originally asked is debatable. What is relevant for OR is the fact that this question has remained unresolved for years. This justifies looking beyond NP-hardness to get actual solutions, which is what a large part of OR has been doing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1: A completely formal treatment of this topics requires diving into computational models such as Turing machines, but I do not think that is nessecary to use the concepts in &quot;guiding&quot; algorithm design&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="232" LastActivityDate="2019-08-03T11:43:33.967" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1146" PostTypeId="1" AcceptedAnswerId="1151" CreationDate="2019-08-03T17:29:43.393" Score="6" ViewCount="1819" Body="&lt;h3&gt;Notation&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{src}_{h,s},\text{dst}_{h,s},\text{ch}_{h,s}$&lt;/span&gt; are constants.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{h,s},x_{i,j,s}$&lt;/span&gt; are binary variables.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{wt}_{h,s}$&lt;/span&gt; are continuous variables.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Problem&lt;/h3&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min.&amp;amp;\qquad\sum_{h \in H}\sum_{s\in S}(\text{src}_{h,s}+\text{ch}_{h,s}+\text{dst}_{h,s}+\text{wt}_{h,s})\times a_{h,s}\\\text{s.t.}&amp;amp;\qquad{\forall h,i,j\in H\\\forall s\in S}:\begin{cases}\text{wt}_{j,s}\geq((\text{src}_{i,s}+\text{ch}_{i,s}+\text{wt}_{i,s})-\text{src}_{j,s})\times x_{i,j,s}\\x_{ij} + x_{ji}\leq1\\x_{ij}+x_{ji}\geq a_{i,s}+a_{j,s}+1\\\sum\limits_{s\in S}b_{h,s}\leq 1\end{cases}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I want to use a LP solver on this problem but there are continuous variable &lt;span class=&quot;math-container&quot;&gt;$\text{wt}_{h,s}$&lt;/span&gt; and Boolean variable &lt;span class=&quot;math-container&quot;&gt;$a_{h,s}$&lt;/span&gt; together in objective function, how to separate them.&lt;/p&gt;&#xA;&lt;p&gt;I have found a link for linearization in constraints&lt;sup&gt;1&lt;/sup&gt;, but how to linearize in objective function?&lt;/p&gt;&#xA;&lt;p&gt;Also in first constraint there are two continuous variable &lt;span class=&quot;math-container&quot;&gt;$\text{wt}_{j,s}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\text{wt}_{i,s}$&lt;/span&gt;, is it possible to linearize it?&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt;[1] &lt;a href=&quot;https://www.leandro-coelho.com/linearization-product-variables&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.leandro-coelho.com/linearization-product-variables&lt;/a&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-08-04T08:25:34.240" Title="Linearization of objective function" Tags="|linear-programming|optimization|linearization|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1147" PostTypeId="2" ParentId="1146" CreationDate="2019-08-03T18:27:33.987" Score="6" Body="&lt;p&gt;Piecewise linearization methods have been widely applied to convert a nonlinear programming problem into a linear programming problem or a mixed-integer convex programming problem for obtaining an approximated global optimal solution. In the transformation process, extra binary variables, continuous variables, and constraints are introduced to reformulate the original problem. These extra variables and constraints mainly determine the solution efficiency of the converted problem.[&lt;a href=&quot;https://www.hindawi.com/journals/mpe/2013/101376/&quot; rel=&quot;noreferrer&quot;&gt;source&lt;/a&gt;]&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-08-03T18:27:33.987" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1148" PostTypeId="2" ParentId="1105" CreationDate="2019-08-03T19:26:42.070" Score="5" Body="&lt;p&gt;Adding on to dxb's answer, we can take a step back and apply Algebraic Geometry to solve discrete constraint satisfaction problems (for example, Graph Coloring). The idea is to model the constraints as a system of multivariate polynomials then use &lt;a href=&quot;http://www.scholarpedia.org/article/Groebner_basis&quot; rel=&quot;noreferrer&quot;&gt;Groebner basis&lt;/a&gt; to solve them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of graph coloring, to obtain a &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-coloring we let each color correspond to a root of unity and set up &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables &lt;span class=&quot;math-container&quot;&gt;$x_1, \dots, x_n$&lt;/span&gt;, one for each vertex of the graph. If the graph is &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-colorable, there is an assignment of roots of unity (colors) to the variables &lt;span class=&quot;math-container&quot;&gt;$x_1, \dots, x_n$&lt;/span&gt; such that a certain set of &lt;a href=&quot;http://www.scholarpedia.org/article/Groebner_basis#Graph_Coloring&quot; rel=&quot;noreferrer&quot;&gt;polynomial constraints&lt;/a&gt; are satisfied.&lt;/p&gt;&#xA;" OwnerUserId="1060" LastActivityDate="2019-08-03T19:26:42.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1149" PostTypeId="1" AcceptedAnswerId="1162" CreationDate="2019-08-03T21:18:12.390" Score="6" ViewCount="496" Body="&lt;h3&gt;Notation&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{src}_{h,s},\text{dst}_{h,s},\text{ch}_{h,s}$&lt;/span&gt; are constants.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{h,s},x_{i,j,s}$&lt;/span&gt; are binary variables.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{wt}_{h,s}$&lt;/span&gt; are continuous variables.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Problem&lt;/h3&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min.&amp;amp;\qquad\sum_{h \in H}\sum_{s\in S}(\text{src}_{h,s}+\text{ch}_{h,s}+\text{dst}_{h,s}+\text{wt}_{h,s})\times a_{h,s}\\\text{s.t.}&amp;amp;\qquad{\forall i,j\in H,\,\forall s\in S}:\text{wt}_{j,s}\geq((\text{src}_{i,s}+\text{ch}_{i,s}+\text{wt}_{i,s})-\text{src}_{j,s})\times x_{i,j,s}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,s} = 1$&lt;/span&gt; only when vehicle &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; charges before vehicle &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. (&lt;a href=&quot;https://or.stackexchange.com/questions/1084/finding-minimum-time-for-vehicle-to-reach-to-its-destination&quot;&gt;Finding minimum time for vehicle to reach to its destination&lt;/a&gt;) for reference.&lt;/p&gt;&#xA;&lt;p&gt;Vehicle &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; charges before &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; only when &lt;span class=&quot;math-container&quot;&gt;$\text{src}_{i,s} &amp;lt; \text{src}_{j,s}$&lt;/span&gt; so how could I force &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,s} = 1$&lt;/span&gt; when this condition meets?&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-08-05T00:42:26.543" Title="How to add Binary Variable with condition in LP" Tags="|linear-programming|optimization|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1150" PostTypeId="2" ParentId="1149" CreationDate="2019-08-03T21:29:21.747" Score="9" Body="&lt;p&gt;Add two indicator constraints:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;when &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,s} = 1$&lt;/span&gt;, the condition must be true (&lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; charges before &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;)&lt;/li&gt;&#xA;&lt;li&gt;when &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,s} = 0$&lt;/span&gt;, the condition must be false (&lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; charges after &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Most commercial solvers have simple APIs that allow you to add indicator constraints directly, without reformulation. For example, here's the documentation for Gurobi's &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/py_model_addgenconstrindic.html&quot; rel=&quot;noreferrer&quot;&gt;addGenConstrIndicator&lt;/a&gt; function.&lt;/p&gt;&#xA;" OwnerUserId="69" LastActivityDate="2019-08-03T21:29:21.747" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1151" PostTypeId="2" ParentId="1146" CreationDate="2019-08-03T21:41:53.510" Score="8" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Add some additional continuous variables &lt;span class=&quot;math-container&quot;&gt;$s_{h,s}$&lt;/span&gt; to your model and use those variables in the objective, instead of the products.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add the following constraints for each &lt;span class=&quot;math-container&quot;&gt;$s_{h,s}$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;This constraint ensures that &lt;span class=&quot;math-container&quot;&gt;$s_{h,s}$&lt;/span&gt; is at most equal to the sum:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{h,s} \leq \text{src}_{h,s}+\text{ch}_{h,s}+\text{dst}_{h,s}+\text{wt}_{h,s}$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This constraint ensures that &lt;span class=&quot;math-container&quot;&gt;$s_{h,s}$&lt;/span&gt; will be at least the sum when &lt;span class=&quot;math-container&quot;&gt;$a_{h,s}=1$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{h,s} \geq \text{src}_{h,s}+\text{ch}_{h,s}+\text{dst}_{h,s}+\text{wt}_{h,s} - M \times (1 - a_{h,s}) $&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This constraints ensures that &lt;span class=&quot;math-container&quot;&gt;$s_{h,s}=0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$a_{h,s}=0$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{h,s} \leq M \times a_{h,s} $&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Some notes about this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I assumed that your constants and variables are all nonnegative.&lt;/li&gt;&#xA;&lt;li&gt;You should pick small values for the constant &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to make it all work (e.g. &lt;span class=&quot;math-container&quot;&gt;$\text{src}_{h,s}+\text{ch}_{h,s}+\text{dst}_{h,s}+\text{UB}(\text{wt}_{h,s})$&lt;/span&gt;). Picking much larger values leads to lower performance and might even introduce numerical problems.&lt;/li&gt;&#xA;&lt;li&gt;If your solver of choice supports indicator constraints, you could also formulate it using those.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="69" LastEditorUserId="123" LastEditDate="2019-08-04T08:25:17.203" LastActivityDate="2019-08-04T08:25:17.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1152" PostTypeId="6" CreationDate="2019-08-03T22:48:36.183" Score="0" Body="&lt;p&gt;&lt;strong&gt;EhsanK&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been involved in the OR.SE since its infancy stage back in Area51 and I've participated in its growth by:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Asking and answering questions on both Meta and the main site&lt;/li&gt;&#xA;&lt;li&gt;Practicing the &quot;vote early, vote often&quot; exercise&lt;/li&gt;&#xA;&lt;li&gt;Creating and modifying tag wiki excerpts&lt;/li&gt;&#xA;&lt;li&gt;Modifying posts and resolving outstanding review queues&lt;/li&gt;&#xA;&lt;li&gt;Visiting the website on average twice a day to ensure that OR.SE keeps a high engagement rate on questions&lt;/li&gt;&#xA;&lt;li&gt;And lastly, sharing OR.SE questions on different social media platforms and at work among my colleagues&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've always asked for more explanation on unclear questions rather than closing or downvoting, which can turn away a potentially great member of our community; something I personally experienced on another SE site. &#xA;I believe that this perspective helps me to be more patient and understanding toward questions asked on OR.SE, especially from new members.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been enjoying my time here and I plan to keep being an active member and lead by example. And that's why I would be happy to serve as one of the moderators for the OR.SE community.&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-08-03T22:48:36.183" LastActivityDate="2019-08-03T22:48:36.183" CommentCount="0" CommunityOwnedDate="2019-08-03T22:48:36.183" ContentLicense="CC BY-SA 4.0" />
  <row Id="1153" PostTypeId="2" ParentId="1104" CreationDate="2019-08-04T06:09:50.033" Score="3" Body="&lt;p&gt;EMSR heuristics are discussed on page &lt;a href=&quot;https://books.google.ca/books?id=InuQPrC6GtQC&amp;amp;pg=PA161&amp;amp;lpg=PA161&amp;amp;source=bl&amp;amp;ots=9K1EN-GhOp&amp;amp;sig=ACfU3U3bB6XlV_TaWmBv4Mmrx1myfW8FqQ&amp;amp;hl=en&amp;amp;sa=X&amp;amp;f=false&quot; rel=&quot;nofollow noreferrer&quot;&gt;161&lt;/a&gt; of &quot;Pricing and Revenue Optimization&quot;, by Robert Lewis Phillips. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;7.3.2 Expected Marginal Seat Revenue (EMSR) Heuristics&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Expected marginal seat revenue (EMSR) comes in (at least) two flavors: EMSR-a and EMSR-b. Both EMSR-a and EMSR-b were introduced by Peter Belobaba in his PhD dissertation and a series of subsequent papers (Belobaba 1987, 1989). Both are based on approximating the multiclass problem by a series of two-class problems and applying Littlewood's rule to obtain a solution.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;EMSR-a&lt;/strong&gt;. Expected marginal seat revenue—version a is the most well-known heuristic for the capacity allocation problem. It is based on the idea of calculating protection levels for the current class relative to each of the higher classes using Littlewood's rule. These protection levels are then summed to create the protection level for the current class. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;EMSR-b&lt;/strong&gt;. Expected marginal seat revenue—version b assumes that a passenger displaced by an additional booking would be paying a fare equal to a weighted average of future fares. EMSR-b creates an &quot;artificial class&quot; with demand equal to the sum of the demands for all the future periods and a fare equal to the average expected fare from future bookings. It then uses Littlewood's rule to calculate the booking limit of the current class &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; with respect to the artificial class. EMSR-b assumes that the &quot;expected fare&quot; of the displaced booking is equal to the expected fare of future demand. This is an approximation because limits will also be set on higher-fare booking, so the demand accepted won't generally be equal to the mean. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;To formalize EMSR-b, assume that demand in all classes follows a normal distribution, with the demand in class &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; having a mean of &lt;span class=&quot;math-container&quot;&gt;$\mu_i$&lt;/span&gt; and a standard deviation of &lt;span class=&quot;math-container&quot;&gt;$\delta_i$&lt;/span&gt;.&quot;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\mu = \sum^{j-1}_{i=1} \mu_i, \qquad p = \sum^{j-1}_{i=1} p_i\mu_i/\mu, \qquad \delta = \sqrt{\sum^{j-1}_{i=1} \delta^2_i}. \tag{7.9}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On page &lt;a href=&quot;https://books.google.ca/books?id=InuQPrC6GtQC&amp;amp;pg=PA168&amp;amp;lpg=PA168&amp;amp;source=bl&amp;amp;ots=9K1EN-GhOp&amp;amp;sig=ACfU3U3bB6XlV_TaWmBv4Mmrx1myfW8FqQ&amp;amp;hl=en&amp;amp;sa=X&amp;amp;f=false#v=onepage&amp;amp;q&amp;amp;f=false&quot; rel=&quot;nofollow noreferrer&quot;&gt;168&lt;/a&gt;, in section 7.4.2 Modified EMSR heuristics, he explains:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;7.4.2 Modified EMSR Heuristics&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Both EMSR-a and EMSR-b can be modified to incorporate imperfect segmentations. The modifications are based on the assumption that when a class closes, rejected demand for that class may buy up to the next highest class—but not to any higher classes. For example, if we close class 3, some class 3 demand may seek to buy in class 2 but not in class 1. We can easily derive modified versions of the EMSR heuristics under this simple assumption. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Define &lt;span class=&quot;math-container&quot;&gt;$a_j \text{ for } j = 2, 3, \dots , n$&lt;/span&gt; as the fraction of class &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; customers who would purchase in the next-higher class &lt;span class=&quot;math-container&quot;&gt;$j-1$&lt;/span&gt; if class &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is closed. Thus, &lt;span class=&quot;math-container&quot;&gt;$a_3$&lt;/span&gt; is the fraction of class 3 customers who would &quot;buy up&quot; to class 2 if they find class 3 closed when they request a booking. &lt;span class=&quot;math-container&quot;&gt;$a_j$&lt;/span&gt; is referred to as the &lt;em&gt;buy-up factor&lt;/em&gt; for class &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. Note that there is no buy-up factor for the highest fare class. Then, for the case of normal demand distributions, EMSR-a and EMSR-b can be extended to incorporate buy-up factors as follows:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\text{EMSR-a with buy-up:} &amp;amp; \quad y_j = \mu_{j-1} + \delta_{j-1}\Phi^{-1}\!\!\left [ \frac{1}{1-a} \left(1-\frac{p_j}{p_{j-1} }\right ) \right ] \\&#xA;&amp;amp; \qquad \qquad \qquad - \sum^{j-2}_{i=1}\!\!\left [ \delta_i\Phi^{-1}\!\!\left(1-\frac{p_j}{p_i}\right ) -\mu_i \right ] \\&#xA;\text{EMSR-b with buy-up:} &amp;amp; \quad y_j = \mu + \delta\Phi^{-1}\!\!\left [ \frac{1}{1-a} \left(1-\frac{p_j}{f}\right ) \right ]&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$u, p, \text{ and } \delta$&lt;/span&gt; for the modified EMSR-b algorithm are as &lt;strong&gt;defined in Equation 7.9&lt;/strong&gt;. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Modified EMSR-a calculates the protection levels for class &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; against every higher class under the assumption that buy-up will only occur to the next-highest class, &lt;span class=&quot;math-container&quot;&gt;$j-1$&lt;/span&gt;, if we close &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;It then subtracts the sum of all these protection levels from the remaining capacity to determine the booking limit for class &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. EMSR-b assumes that buy-up will occur to the &quot;aggregate class&quot; consisting of all the higher classes and calculates the booking limit using the version of Littlewood's rule in Equation 7.16.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;These two modifications to the EMSR heuristics have been studied by Belobaba and Weatherford (1996) who showed that the modified EMSR heuristics provide additional revenue when buy-up is present. The modified EMSR heuristics are easy to implement, and versions of them have been used by many revenue management companies. However, they  have some disadvantages. They require a set of &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; buy-up factors to be estimated and stored for each flight. They also require redefining the demand for each fare class as the demand that would be received if the next-higher class is open. They do not incorporate the possibility of buy-up from class &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to classes higher than &lt;span class=&quot;math-container&quot;&gt;$j-1$&lt;/span&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Perhaps more fundamentally, the modified EMSR approaches are a &quot;heuristic grafted on to another heuristic.&quot; They are not derived from a fundamental model of consumer choice. Rather, they assume that passengers have M-Class and Y-Class stamped on their heads and that only some of the M-Class passengers will buy up to Y-Class if M-Class is closed. Development of more fundamental models including consumer choice is an &lt;strong&gt;active&lt;/strong&gt; research area.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.researchgate.net/publication/37601188_Air_travel_demand_and_airline_seat_inventory_management&quot; rel=&quot;nofollow noreferrer&quot;&gt;Air Travel Demand and Airline Seat Inventory Management&lt;/a&gt;&quot; (1987), by Peter Belobaba&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/opre.37.2.183&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR Practice - Application of a Probabilistic Decision Model to Airline Seat Inventory Control&lt;/a&gt;&quot; (1989), by Peter Belobaba&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.researchgate.net/scientific-contributions/80628486_Peter_Belobaba&quot; rel=&quot;nofollow noreferrer&quot;&gt;Peter Belobaba&lt;/a&gt;'s research while affiliated with Massachusetts Institute of Technology and other places&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-08-04T13:44:11.400" LastActivityDate="2019-08-04T13:44:11.400" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1154" PostTypeId="1" CreationDate="2019-08-04T10:35:27.647" Score="5" ViewCount="879" Body="&lt;p&gt;At first, I should apologize if this question is not relevant to this website, but since there are some researchers from the management science community, I ask the question here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have data for the demand of 1200 products for 25 periods. That is, 1200 time series. I want to predict the demand for each product for the next period (26). However, because of the high-complexity of tuning the parameters &lt;span class=&quot;math-container&quot;&gt;$(p,d,q)$&lt;/span&gt; of the ARIMA model, it is not possible to use the ARIMA model. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used the time-slicing approach to train ML approaches (random forest, xgboost, catboost, ....) to predict the demand, but it is satisfactory. I would like to know if there is any other approach for demand prediction of 1200 products? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I have used the following approach. I would be thankful if someone can suggest any idea. At first, I have generated new feature (trend) for each time-slicing time serie as if the demand of a product for a period is increase compared to the previous period (+1 for increase, 0 no difference, -1 decrease) and then clustered time-slicing time series based on the trend data (not the value of demand) and then predict the demand of each product according to the demand of products which fall into the same cluster with KNN. KNN algorithm is trained on the demand values but clustering is trained on trend data. KNN algorithm with a large number of neighbors produces good results but other algorithms such as catboost, xgboost, knn with small k produces poor results.  &lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="139" LastEditDate="2019-08-05T14:01:28.373" LastActivityDate="2022-04-25T05:53:23.047" Title="How to handle many time series?" Tags="|time-series|forecasting|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1155" PostTypeId="2" ParentId="1117" CreationDate="2019-08-04T13:21:51.557" Score="5" Body="&lt;p&gt;Very interesting question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that it is more general than OR: how can I deploy a solution for my customer? It seems to be a software engineering question. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I imagine different scenarios depending of the problem context and the customer:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Deploy as a web service: there is an endpoint that the customer can GET/POST to get solutions&lt;/li&gt;&#xA;&lt;li&gt;Provide ONE solution: you are asked to solve a particular instance and you just provide the solution to that instance of the problem in a file&lt;/li&gt;&#xA;&lt;li&gt;Build an offline tool that solves the problem for your customer: it could be something like a jupyter notebook that guides you through the solving process, or just an executable file that takes input.txt and gives you solution.txt&lt;/li&gt;&#xA;&lt;li&gt;Deploy as a backoffice where your customer can upload the input and get the solution in a self-service manner&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="806" LastEditorUserId="806" LastEditDate="2019-08-04T13:28:41.373" LastActivityDate="2019-08-04T13:28:41.373" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1156" PostTypeId="2" ParentId="1154" CreationDate="2019-08-04T14:58:41.617" Score="5" Body="&lt;p&gt;This problem is a multivariate (simply when you have more than one time-dependent variables) time series for which you can use &lt;strong&gt;&lt;em&gt;Vector Auto Regression (VAR)&lt;/em&gt;&lt;/strong&gt; technique among some others. Explanation and Python implementation of this technique has been discussed in details &lt;a href=&quot;https://www.analyticsvidhya.com/blog/2018/09/multivariate-time-series-guide-forecasting-modeling-python-codes/&quot; rel=&quot;noreferrer&quot;&gt;in here&lt;/a&gt;. This technique is also considered the dependencies between various time-dependent variables in the &lt;span class=&quot;math-container&quot;&gt;$AR(n)$&lt;/span&gt; calculations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not pretty sure that the implementation code will take less than your own approaches for the forecasting of variables but at least it gives you some hints to accelerate other approaches. (of course, it also required some familiarities with univariate time-series and Python programming language). &lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-08-04T14:58:41.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1157" PostTypeId="6" CreationDate="2019-08-04T15:41:23.527" Score="0" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\huge\mathtt{Rob}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been a member of Stack Overflow for over 5 years and an active &lt;a href=&quot;https://stackexchange.com/users/4485506/rob?tab=accounts&quot;&gt;member&lt;/a&gt; of our main Meta. I am also a &lt;strong&gt;core&lt;/strong&gt; Charcoal member. I visit our Review Queues a half dozen times a day and I am active on our meta and chat, helping out with the startup of our site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On sites where I have over 200 reputation I have 42 gold, 124 silver, and 513 bronze badges and over &lt;a href=&quot;https://stackexchange.com/users/flair/4485506.png&quot;&gt;29K reputation&lt;/a&gt;. I also have over another 250 badges on the other child metas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I lead by example in uncommon disputes and exceptions and would feel privileged to assist with moderation, leaving it to our community to decide the direction of Operations Research and intervening only when duty calls.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-08-04T15:41:23.527" LastActivityDate="2019-08-04T15:41:23.527" CommentCount="0" CommunityOwnedDate="2019-08-04T15:41:23.527" ContentLicense="CC BY-SA 4.0" />
  <row Id="1158" PostTypeId="2" ParentId="1154" CreationDate="2019-08-04T17:00:53.380" Score="7" Body="&lt;p&gt;If the 1200 products are closely related, so that trend (if any) and noise are likely to be correlated across products, a single model might make sense. If they are loosely related (so that they might share a common trend but separate noise processes), you might consider fitting a single trend model (linear regression on time?), &quot;detrending&quot; the data, then fitting separate ARMA models ... or perhaps just separate exponential smoothing models? If the products are unrelated, either separate ARIMA models or separate exponential smoothing models would be warranted, and a composite model would not be.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-04T17:00:53.380" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1159" PostTypeId="2" ParentId="1154" CreationDate="2019-08-04T19:40:15.467" Score="4" Body="&lt;p&gt;The demand of 1200 product will often be related. There might be common events (Christmas, some large accident, ...) that influence all or many of the demands, substitution effects, ... or there may be relations imposed by the cost function (inventory control ...)&lt;/p&gt;&#xA;&lt;p&gt;These can be tackled by some common model, and this is often &lt;strong&gt;hierarchical forecasting&lt;/strong&gt;. There are some posts on Cross Validated, and rather than rewrite here, &lt;a href=&quot;https://stats.stackexchange.com/search?q=foreca*+hiera*+time+series+answers%3A1&quot;&gt;this is a list&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There is also a lot of information on the &lt;strong&gt;Hyndsight blog&lt;/strong&gt;, start with &lt;a href=&quot;https://robjhyndman.com/hyndsight/thief/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://robjhyndman.com/hyndsight/thief/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="166" LastEditorUserId="166" LastEditDate="2022-04-25T05:53:23.047" LastActivityDate="2022-04-25T05:53:23.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1160" PostTypeId="1" CreationDate="2019-08-04T20:24:26.090" Score="7" ViewCount="9236" Body="&lt;p&gt;I'm trying to solve an optimization problem including following constraint, and I need to linearize it in a maximization nonlinear programming model. Please help me to reformulate it with mixed integer programming. A part of my model is here:&#xA;   &lt;span class=&quot;math-container&quot;&gt;$$\min\ Z=-q_1p_1 \\&#xA;   q_1=\min\{b,ap_1\}$$&lt;/span&gt;&lt;br&gt;&#xA;Note that &lt;span class=&quot;math-container&quot;&gt;$q_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_1$&lt;/span&gt; are non-negative variables and the others are parameters. &#xA;I know that &lt;span class=&quot;math-container&quot;&gt;$$q_1\le b,\, q_1\le ap_1 $$&lt;/span&gt; are helpful. But I'm trying to find another way to linearize it. &lt;/p&gt;&#xA;" OwnerUserId="1064" LastEditorUserId="123" LastEditDate="2019-08-06T10:08:19.347" LastActivityDate="2019-08-06T10:08:19.347" Title="How to linearize min function as a constraint?" Tags="|mixed-integer-programming|optimization|linearization|logical-constraints|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="1161" PostTypeId="2" ParentId="1132" CreationDate="2019-08-05T00:05:01.553" Score="5" Body="&lt;p&gt;The other answers are good.  I'd add that &quot;P vs. NP&quot; spans OR, CS, project management, education, HR, governance, and several other related fields. Procedures, algorithms, project and business plans, software, curricula, legislation, and other forms of code are hard to prove correct without actually executing them to see what happens.  The execution may be NP-hard or even undecidable, but due in part to e.g. the halting problem and its cousins we seldom can know ahead of time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This very practical and day-to-day OR-class problem hits organizations all the time; few understand or deal with it well.  One symptom of this is lengthy project plans that stack all of the testing towards the end.  Another is logistics systems with long queues where testing happens on exit from the queue instead of on entry. Staffing practices which revolve around an annual review along with infrequent formal training or certification are another. The worst are the mega-projects which rely on an untested architecture set in stone years before an immovable completion date.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Practitioners who do tend to get things right are those who break the problem up into smaller chunks and then iterate, test, and refactor rapidly in response to intermediate results.  You'll see implementations of this in lean manufacturing, war/scenario gaming, agile and test driven software development, devops, US military training, the &quot;fail fast&quot; ethos in startups, and so on. &lt;/p&gt;&#xA;" OwnerUserId="1067" LastEditorUserId="1067" LastEditDate="2019-08-05T00:11:26.700" LastActivityDate="2019-08-05T00:11:26.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1162" PostTypeId="2" ParentId="1149" CreationDate="2019-08-05T00:42:26.543" Score="5" Body="&lt;p&gt;Since the &lt;span class=&quot;math-container&quot;&gt;$\text{src}$&lt;/span&gt; are constants, you know in advance whether &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; charges before &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and you can just force &lt;span class=&quot;math-container&quot;&gt;$x_{ijs}=1$&lt;/span&gt; in this case (via a constraint or by treating it like a constant).&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-08-05T00:42:26.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1163" PostTypeId="1" CreationDate="2019-08-05T02:03:58.137" Score="3" ViewCount="1164" Body="&lt;p&gt;I am in the process of compiling a critical review of the field. Wanted to reach out to the community to get insight on top researchers so I can summarize the state of the art and see where the field is headed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="357" LastEditorUserId="36" LastEditDate="2019-08-05T02:16:00.277" LastActivityDate="2019-08-05T15:52:48.710" Title="Who are the top researchers in the field of Operations Research?" Tags="|people|" AnswerCount="3" CommentCount="4" ClosedDate="2019-08-05T12:26:25.223" ContentLicense="CC BY-SA 4.0" />
  <row Id="1164" PostTypeId="2" ParentId="1163" CreationDate="2019-08-05T02:18:14.893" Score="2" Body="&lt;p&gt;In my opinion the number of citations in Google Scholar can be one of the criteria. You can find the researchers in different branches of optimization and mathematical programming sorted by their citations and field of research. Simply click on the field of research to get the sorted list of all researchers in that field. But you need to consider the fact that some of the publications for instance books or review papers may affect the sorting.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-08-05T02:18:14.893" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1165" PostTypeId="2" ParentId="1163" CreationDate="2019-08-05T02:46:05.880" Score="7" Body="&lt;p&gt;A better idea to understand the &quot;state of the art and see where the field is headed&quot; would be to look at the research being done instead of the researchers themselves. You could search Google Scholar for &quot;optimization&quot; (or any other OR term) and look at recent articles. Alternatively, you can look at recent articles in popular journals like &lt;em&gt;Operations Research&lt;/em&gt;; a discussion on &lt;a href=&quot;https://or.stackexchange.com/q/721/196&quot;&gt;&quot;top&quot; OR journals can be found here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="196" LastEditorUserId="196" LastEditDate="2019-08-05T15:52:48.710" LastActivityDate="2019-08-05T15:52:48.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1166" PostTypeId="1" CreationDate="2019-08-05T06:48:32.340" Score="8" ViewCount="169" Body="&lt;p&gt;In the Flow/Job Shop problems, and other related scheduling problems, a common assumption is that at any given time, a particular job will be being processed on at most one machine (usually... none).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now imagine a scheduling problem in which a particular job requires multiple &quot;machines&quot; simultaneously, e.g. multiple &quot;resources&quot; instances which are modelled as separate machines. For example, producing a particular type of widget requires 1x human resource A and 1x lathe B and 1x computer server C, at the same time, during which those particular resource instances are locked and cannot work on any other jobs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What class of scheduling problem is this? (One-to-many job-to-machine model)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ANSWER: &quot;Resource constrained scheduling&quot; seems to be the idea, e.g. as discussed in Chapter 17 of &quot;Principles of Sequencing and Scheduling&quot; by Baker/Trietsch.&lt;/p&gt;&#xA;" OwnerUserId="1071" LastEditorUserId="1071" LastEditDate="2019-08-05T10:20:12.293" LastActivityDate="2019-08-05T21:32:14.207" Title="What class of scheduling problem models jobs which require multiple machines simultaneously?" Tags="|combinatorial-optimization|scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1167" PostTypeId="2" ParentId="1163" CreationDate="2019-08-05T07:00:11.710" Score="8" Body="&lt;p&gt;In addition to the other mentioned criteria, you can look up the plenary speakers at international OR conferences, or look at prizes awarded by organizations such as &lt;a href=&quot;https://www.informs.org/Recognizing-Excellence/INFORMS-Prizes&quot; rel=&quot;noreferrer&quot;&gt;INFORMS&lt;/a&gt; and &lt;a href=&quot;https://www.euro-online.org/web/pages/104/prizes-and-awards&quot; rel=&quot;noreferrer&quot;&gt;EURO&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-08-05T07:00:11.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1168" PostTypeId="2" ParentId="1166" CreationDate="2019-08-05T08:46:56.613" Score="2" Body="&lt;p&gt;The sequencing models (flow/job shops or hybrid too) are the basic (concept) in the scheduling. It means that to use them into the real world scheduling problems you will have to modify them. (adding some constraints to the model which represent your limitations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK, as you mentioned constraints, it can be expressed as a specific project scheduling with resource constraints. &#xA;would you search for some of the practical scheduling software such as &lt;a href=&quot;https://blogs.sap.com/2015/09/27/sap-apo-general-overview/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SAP-APO&lt;/a&gt;, &lt;a href=&quot;https://www.asprova.com/en/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ASPROVA&lt;/a&gt; or some of the &lt;a href=&quot;https://www.mrpeasy.com/production-planning-software/&quot; rel=&quot;nofollow noreferrer&quot;&gt;online sequencing software&lt;/a&gt;? (some of them have a trial version)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They have some nice features such as resource leveling, flexible Gantt chart, exact or heuristic algorithms and other facilities that might be useful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="39" LastEditDate="2019-08-05T21:32:14.207" LastActivityDate="2019-08-05T21:32:14.207" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1169" PostTypeId="2" ParentId="687" CreationDate="2019-08-05T10:08:09.383" Score="2" Body="&lt;p&gt;The problem was that I stored too many Gurobi models during the algorithm execution, which increase the RAM usage by seconds!! I still don't know why Gurobi returned the &quot;Out of memory&quot; error when there was plenty of memory available!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To future readers, pay attention to what you actually store in your RAM. Keep it simple and store just what you need (for example a float instead of an object!). RAM usage can add up very quickly!&lt;/p&gt;&#xA;" OwnerUserId="172" LastActivityDate="2019-08-05T10:08:09.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1170" PostTypeId="1" AcceptedAnswerId="1173" CreationDate="2019-08-05T14:38:35.677" Score="21" ViewCount="1768" Body="&lt;p&gt;In Laurence Wolsey's &lt;a href=&quot;https://books.google.com/books/about/Integer_Programming.html?id=x7RvQgAACAAJ&quot; rel=&quot;noreferrer&quot;&gt;Integer  Programming&lt;/a&gt;&lt;sup&gt;[1]&lt;/sup&gt;, he presents a well-known procedure for deriving &lt;strong&gt;valid inequalities (VI)&lt;/strong&gt;  suitable for integer and mixed integer linear problems (see Section 8.3, and also Ch 9).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the application-oriented literature, I've often seen authors present a MILP formulation then follow it up with &lt;strong&gt;VIs&lt;/strong&gt; they have derived and found to be helpful in the problem, usually accompanied with experimental results (robust or not) to show the utility of the &lt;strong&gt;VI&lt;/strong&gt;. (For clarification, I'm referring to VIs authors suggest adding to the formulation, not user-generated cuts derived and/or added during the solution procedure. Modern solvers have many powerful tricks for both pre-processing and during the solution process, including powerful cutting plane approaches.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; With the extensive &lt;s&gt;pre-processing&lt;/s&gt; options available with commercial solvers like CPLEX or Gurobi, is this still worth doing? If yes, what are the best practices for testing and convincing oneself a &lt;strong&gt;VI&lt;/strong&gt; (or set of VIs) is worth the trouble?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Clarification:&lt;/strong&gt; Based on the comments, by &quot;&lt;em&gt;extensive options&lt;/em&gt;&quot; I mean the powerful pre-processing options and the in-process bag-o-tricks used by solvers.  Why mention pre-processing (as a commenter asks)? For one, because pre-processing options exist. Second, in the literature I've seen authors recommend a certain level based on empirical testing.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;[1] Wolsey, Laurence A. 1998. &lt;em&gt;&lt;a href=&quot;https://books.google.com/books/about/Integer_Programming.html?id=x7RvQgAACAAJ&quot; rel=&quot;noreferrer&quot;&gt;Integer Programming&lt;/a&gt;&lt;/em&gt;. Wiley: New York. ISBN 0471283665.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-08-06T13:03:17.667" LastActivityDate="2020-05-08T19:30:19.073" Title="Are valid inequalities worth the effort given modern solvers?" Tags="|mixed-integer-programming|optimization|solver|valid-inequalities|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1172" PostTypeId="2" ParentId="1170" CreationDate="2019-08-05T15:19:44.720" Score="9" Body="&lt;p&gt;In my experience, it's rarely, but sometimes still, worth doing. There is no general answer however, as it's very model-specific (and sometimes even instance-specific). The only way to know for sure is to try both ways with the solver of your choice. Your results will also change over time, because newer versions of solvers generally implement better algorithms and use differently tuned heuristics.&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="69" LastEditDate="2019-08-05T17:08:36.523" LastActivityDate="2019-08-05T17:08:36.523" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1173" PostTypeId="2" ParentId="1170" CreationDate="2019-08-05T22:06:46.993" Score="13" Body="&lt;p&gt;It is, at least sometimes, still very useful.&#xA;I have a &lt;a href=&quot;https://www.tandfonline.com/doi/abs/10.1080/0305215X.2014.958731&quot; rel=&quot;nofollow noreferrer&quot;&gt;short note&lt;/a&gt; (&lt;a href=&quot;https://santini.in/files/papers/santini-friberg-ropke-2015.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;) on a problem in quay crane scheduling in which adding a single - rather uninspired - family of valid inequalities greatly reduced solution times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My understanding is that you make the most out of enumerated valid inequalities when the linear relaxation of the MIP is poor, as they can quickly improve the dual bound.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2020-05-08T19:30:19.073" LastActivityDate="2020-05-08T19:30:19.073" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1174" PostTypeId="2" ParentId="1160" CreationDate="2019-08-05T23:49:58.590" Score="14" Body="&lt;p&gt;Here is an answer that uses the same approach as in &lt;a href=&quot;https://or.stackexchange.com/a/712/38&quot;&gt;this answer&lt;/a&gt;, but converted from &lt;span class=&quot;math-container&quot;&gt;$\max\{\cdot,\cdot\}$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\min\{\cdot,\cdot\}$&lt;/span&gt;. I'll write the constraint in a more general form:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$X = \min\{x_1,x_2\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method works if &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; are constants or decision variables (or one of each). (In your question, &lt;span class=&quot;math-container&quot;&gt;$X = q_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_1 = b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2 = ap_1$&lt;/span&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We want a set of constraints that enforces &lt;span class=&quot;math-container&quot;&gt;$X = \min\{x_1,x_2\}$&lt;/span&gt;. Define a new binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, which will equal 1 if &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;lt; x_2$&lt;/span&gt;, will equal 0 if &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;gt; x_2$&lt;/span&gt;, and could equal either if &lt;span class=&quot;math-container&quot;&gt;$x_1 = x_2$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; be a constant such that &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2 \le M$&lt;/span&gt; in any &quot;reasonable&quot; solution to the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following constraints enforce the definition of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;x_2 - x_1 &amp;amp; \le My \\&#xA;x_1 - x_2 &amp;amp; \le M(1-y)&#xA;\end{align}$$&lt;/span&gt;&#xA;Then, the following constraints enforce &lt;span class=&quot;math-container&quot;&gt;$X = \min\{x_1,x_2\}$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;X &amp;amp; \le x_1 \\&#xA;X &amp;amp; \le x_2 \\&#xA;X &amp;amp; \ge x_1 - M(1-y) \\&#xA;X &amp;amp; \ge x_2 - My.&#xA;\end{align}$$&lt;/span&gt;&#xA;The first two constraints say &lt;span class=&quot;math-container&quot;&gt;$X \le \min\{x_1,x_2\}$&lt;/span&gt;. Combined with these constraints, the last two constraints say that &lt;span class=&quot;math-container&quot;&gt;$X = x_1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;lt; x_2$&lt;/span&gt; (so &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$X = x_2$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_2 &amp;lt; x_1$&lt;/span&gt; (so &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-08-05T23:49:58.590" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1175" PostTypeId="1" AcceptedAnswerId="1177" CreationDate="2019-08-06T05:33:54.880" Score="8" ViewCount="200" Body="&lt;p&gt;The question I am about to ask is not a technical one but rather based on following a correct approach, which I am sure would be helpful to many. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently working on a project which involves data driven optimization for a gas compressor network, where we read in plant's data for process variables such as pressure, temperature, flow etc. We in there, are building several statistical (regression) models that form part of our objective function and constraints. We are in the pilot phase, and our ultimate purpose is to deploy this tool real time in plant. At this moment. I am currently having with me a large data set that is reliable enough to build generalized models.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, thinking it from the deployment perspective, we would not want to be in a position where we are doing an optimization based on data that is too old. In fact, my project adviser mentioned that I should have the facility to read in live data from the plant and update my model parameters based on the new data points. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, what I can think of is to read in new data to new csv files via python and update my models. However, this requires me to manually run the code at fixed frequency (eg daily at 10:00 AM). I am wondering, if there is some more smarter way to approach this problem ? Ex. deploying my code on some cloud platform that is automatically able to stack new data to the existing database, run the code and update parameters, the latest values of which I can then retrieve to my local machine to run the optimization code. I would be keen to know if someone has worked on some similar problem before as I would like to learn more on this topic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,  &lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="113" LastEditDate="2019-08-06T06:04:18.400" LastActivityDate="2019-08-06T06:15:12.977" Title="Model Update for Data Driven Real Time Process Optimization" Tags="|optimization|data|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1176" PostTypeId="1" CreationDate="2019-08-06T06:14:18.363" Score="11" ViewCount="385" Body="&lt;p&gt;I am trying to solve a workforce scheduling and optimization problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Available data:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;daily level forecasted call volumes,&lt;/li&gt;&#xA;&lt;li&gt;shift schedules,&lt;/li&gt;&#xA;&lt;li&gt;resource utilization at the aggregate level,&lt;/li&gt;&#xA;&lt;li&gt;AHT at daily and hourly level.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I wanted to identify an algorithm that will help me come up with the optimal schedule.&lt;/em&gt; I have looked at a couple of methods like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Linear Programming,&lt;/li&gt;&#xA;&lt;li&gt;Greedy Algorithm,&lt;/li&gt;&#xA;&lt;li&gt;Constraint Programming&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am unable to decide which one will be useful for solving my problem efficiently. I want to schedule the minimum number of people in each shift to achieve maximum foretasted volumes with minimum AHT. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also if you can provide a comparison of different methods and their advantages and disadvantages that would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="1079" LastEditorUserId="51" LastEditDate="2019-09-01T22:46:32.033" LastActivityDate="2019-09-01T22:46:32.033" Title="Algorithm for workforce scheduling for call volumes" Tags="|linear-programming|constraint-programming|scheduling|markov-decision-process|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="1177" PostTypeId="2" ParentId="1175" CreationDate="2019-08-06T06:15:12.977" Score="5" Body="&lt;p&gt;One of the PhD students in my office is working on a similar project that they called digitalization, in which they use raspberry pi and various sensors to collect the data from the machines in production line, send them to cloud and after extracting data-driven parameters, they use those parameters to estimate the down-time of the machine and control the inventory and plan the production.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-08-06T06:15:12.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1178" PostTypeId="2" ParentId="49" CreationDate="2019-08-06T10:17:44.367" Score="2" Body="&lt;p&gt;Here is a book often used by statisticians: &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0470139005&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nonlinear Regression Analysis and Its Applications&lt;/a&gt; by Douglas M. Bates and Donald G. Watts.  Douglas Bates is a member of the R core team and not without responsibility for the nonlinear regression routines in R ... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0471617601&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;This other book&lt;/a&gt; by Seber &amp;amp; Wild can also be useful.  &lt;/p&gt;&#xA;" OwnerUserId="166" LastEditorUserId="123" LastEditDate="2019-10-16T08:11:08.143" LastActivityDate="2019-10-16T08:11:08.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1179" PostTypeId="2" ParentId="11" CreationDate="2019-08-06T10:46:15.983" Score="9" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Has anyone performed a benchmark of the various stabilization techniques in column generation? ... implemented in SCIP ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The thesis &quot;&lt;a href=&quot;http://www.zib.de/gamrath/publications/gamrath2010_genericBCP.pdf&quot; rel=&quot;noreferrer&quot;&gt;Generic Branch-Cut-and-Price&lt;/a&gt;&quot; (.PDF), by Gerald Gamrath (and supervised by &lt;strong&gt;&lt;em&gt;our&lt;/em&gt;&lt;/strong&gt; &lt;a href=&quot;https://or.stackexchange.com/users/354/marco-l%C3%BCbbecke&quot;&gt;Marco Lübbecke&lt;/a&gt;) is mentioned on the &lt;a href=&quot;https://gcg.or.rwth-aachen.de/#about&quot; rel=&quot;noreferrer&quot;&gt;About&lt;/a&gt; webpage for the &lt;a href=&quot;https://gcg.or.rwth-aachen.de/&quot; rel=&quot;noreferrer&quot;&gt;Generic Column Generation&lt;/a&gt; (GCG) software. Compare with &lt;a href=&quot;https://scip.zib.de/doc-3.1.0/examples/VRP/&quot; rel=&quot;noreferrer&quot;&gt;SCIP's VRP (tiny) example docs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It explains the improvements for Vehicle Routing Problems (VRP) using an enhanced branch-cut-and-price approach. On page 127 he writes:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;... one of the main goals of this thesis was to investigate whether the branch-cut-and-price approach in the implemented generic form is still competitive to a state-of-the-art branch-and-cut MIP solver for these problems. It turned out that the &lt;strong&gt;generic branch-cut-and-price solver GCG&lt;/strong&gt; still &lt;strong&gt;outperforms SCIP&lt;/strong&gt; although it does not use any problem specific knowledge except for the structure of the problem.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;We studied how some concepts that are successfully used in LP based&#xA;  branch-and-cut MIP solvers can be transferred to the branch-cut-and-price approach, using the example of the capacited p-median problem. By performing domain propagation in the original problem and transferring its results into the extended problem, we enforce proper variables [96]. This slightly improved the performance of GCG. It turned out that using pseudocosts to select the variable to branch on has a big impact: it essentially halved the solving time. Furthermore, we tried to separate cutting planes in the original&#xA;  problem, but did not find any for the problems classes regarded in this thesis. It seems that the reason for this is the special structure of the problems. However, for more general problems, cutting planes were found and could improve the solving capabilities of GCG.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;For the column generation process, apart from incorporating further problem specific pricing solvers, stabilization of the dual variables [64, 57] is one of the most promising concepts. During the column generation process, the dual variables may highly oscillate. Through stabilization techniques, e.g., penalizing big differences to the value of the dual variable in the last solution, this is reduced which typically improves the column generation performance.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The newest version is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;02/Jul/2018 - A major GCG 3.0.0 release is available together with the SCIP optimization Suite 6.0.0. See the &lt;a href=&quot;https://gcg.or.rwth-aachen.de/doc/CHANGELOG.html&quot; rel=&quot;noreferrer&quot;&gt;CHANGELOG&lt;/a&gt; and the &lt;a href=&quot;https://gcg.or.rwth-aachen.de/doc/RELEASENOTES.html&quot; rel=&quot;noreferrer&quot;&gt;Release notes&lt;/a&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The newest version of &lt;a href=&quot;https://scip.zib.de/&quot; rel=&quot;noreferrer&quot;&gt;SCIP&lt;/a&gt;, incorporating GCG, is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;0/Jul/2019 - SCIP version 6.0.2 released - The SCIP Optimization Suite 6.0.2 consists of SCIP 6.0.2, SoPlex 4.0.2, ZIMPL 3.3.8, GCG 3.0.2, and UG 0.8.8. It contains important bugfixes and other improvements for all components of the Optimization Suite, see the &lt;a href=&quot;https://scip.zib.de/doc-6.0.2/html/RN60.php&quot; rel=&quot;noreferrer&quot;&gt;CHANGELOG of SCIP&lt;/a&gt; or browse the individual CHANGELOGs of the other projects. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;See also&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.researchgate.net/publication/226683077_A_Primer_in_Column_Generation&quot; rel=&quot;noreferrer&quot;&gt;A Primer in Column Generation&lt;/a&gt;&quot;, (March 2006), by Jacques Desrosiers and &lt;a href=&quot;https://or.stackexchange.com/users/354/marco-l%C3%BCbbecke&quot;&gt;Marco Lübbecke&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S037722171300800X&quot; rel=&quot;noreferrer&quot;&gt;A unified solution framework for multi-attribute vehicle routing problems&lt;/a&gt;&quot;, (May 2014), by Thibaut Vidal, Teodor Gabriel Crainic, Michel Gendreau and Christian Prins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Unified Hybrid Genetic Search (UHGS) with a unified Split algorithm is proposed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UHGS matches or outperforms all current best problem-tailored algorithms on 29 notable VRP variants and 42 benchmark sets.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221716306270&quot; rel=&quot;noreferrer&quot;&gt;New benchmark instances for the Capacitated Vehicle Routing Problem&lt;/a&gt;&quot;, (Mar 2017), by Eduardo Uchoaa, Diego Pecin, Artur Pessoa, Marcus Poggi, Thibaut Vidal, and Anand Subramanian.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We show the limitations of existing Capacitated Vehicle Routing Problem instances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We propose 100 new instances and evaluate recent exact and heuristic methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same generating scheme is used to create an extended benchmark of 600 instances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extensive experiments and statistical analyses are done on the extended benchmark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We present a sophisticated &lt;a href=&quot;http://vrp.atd-lab.inf.puc-rio.br/index.php/en/&quot; rel=&quot;noreferrer&quot;&gt;website&lt;/a&gt; containing all existing and new instances. See &lt;a href=&quot;https://w1.cirrelt.ca/~vidalt/en/VRP-resources.html&quot; rel=&quot;noreferrer&quot;&gt;Thibaut Vidal's webpage&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://arxiv.org/abs/1801.00712&quot; rel=&quot;noreferrer&quot;&gt;Multi-Objective Vehicle Routing Problem Applied to Large Scale Post Office Deliveries&lt;/a&gt;&quot;, (Dec 2017), by Luis A. A. Meira, Paulo S. Martins, Mauro Menzori, Guilherme A. Zeni.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Abstract: &quot;The number of optimization techniques in the combinatorial domain is large and diversified. Nevertheless, real-world based benchmarks for testing algorithms are few. This work creates an extensible real-world mail delivery benchmark to the Vehicle Routing Problem (VRP) in a planar graph embedded in the 2D Euclidean space. Such problem is multi-objective on a roadmap with up to 25 vehicles and 30,000 deliveries per day. Each instance models one generic day of mail delivery, allowing both comparison and validation of optimization algorithms for routing problems. The benchmark may be extended to model other scenarios.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.researchgate.net/publication/309283944_VRPBench_A_Vehicle_Routing_Benchmark_Tool&quot; rel=&quot;noreferrer&quot;&gt;VRPBench: A Vehicle Routing Benchmark Tool&lt;/a&gt;&quot;, (Oct 2016), by Guilherme A. Zeni, Mauro Menzori, Paulo Martins and Luis Meira (PostVRP &lt;a href=&quot;https://www.ft.unicamp.br/docentes/meira/postvrp/&quot; rel=&quot;noreferrer&quot;&gt;Software link&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Abstract: &quot;The number of optimization techniques in the combinatorial domain is large and diversified. Nevertheless, there is still a lack of real benchmarks to validate optimization algorithms. In this work we introduce VRPBench, a tool to create instances and visualize solutions to the Vehicle Routing Problem (VRP) in a planar graph embedded in the Euclidean 2D space. ...&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0305054813000762&quot; rel=&quot;noreferrer&quot;&gt;Using the primal-dual interior point algorithm within the branch-price-and-cut method&lt;/a&gt;&quot;, (Aug 2013), by Pedro Munari and Jacek Gondzio.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Abstract: &quot;Branch-price-and-cut has proven to be a powerful method for solving integer programming problems. It combines decomposition techniques with the generation of both columns and valid inequalities and relies on strong bounds to guide the search in the branch-and-bound tree.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;We present the computational results of solving well-known instances of the vehicle routing problem with time windows, a challenging integer programming problem. The results indicate that the proposed approach delivers the best overall performance when compared with a similar branch-price-and-cut method which is based on the simplex algorithm.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.researchgate.net/publication/326096337_Exact_branch-price-and-cut_algorithms_for_vehicle_routing&quot; rel=&quot;noreferrer&quot;&gt;Exact branch-price-and-cut algorithms for vehicle routing&lt;/a&gt;&quot;, (Jun 2018), by Luciano Costa, (&lt;strong&gt;&lt;em&gt;our&lt;/em&gt;&lt;/strong&gt;) &lt;a href=&quot;https://or.stackexchange.com/users/86/claudio-contardo&quot;&gt;Claudio Contardo&lt;/a&gt; and Guy Desaulniers.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Abstract: &quot;Vehicle routing problems (VRPs) are among the most studied problems in operations research. Nowadays, the leading exact algorithms for solving many classes of VRPs are branch-price-and-cut algorithms. In this survey paper, we highlight the main methodological and modeling contributions made over the years on branch-and-price(-and-cut) algorithms for VRPs, whether they are generic or specific to a VRP variant. We focus on problems related to the classical VRP, i.e., problems in which customers must be served by several capacitated trucks, and which are not combinations of a VRP and another optimization problem.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.researchgate.net/publication/49461088_Two-stage_column_generation&quot; rel=&quot;noreferrer&quot;&gt;Two-stage column generation&lt;/a&gt;&quot;, (Jan 2010), Matteo Salani, Ilaria Vacca and Michel Bierlaire.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Abstract: &quot;We introduce a new concept in column generation for handling complex large scale optimization problems, called two-stage column generation, where columns for the compact and extensive formulation are simultaneously generated. The new framework is specifically conceived for tackling complex problems that cannot be efficiently solved by standard column generation and exploits the relationship between compact and extensive formulation. In particular, the concept of extensive reduced cost is introduced in order to estimate the contribution of compact formulation variables to the master problem. A formal description of the proposed framework is provided and major theoretical issues are discussed. An example based on the Resource Constrained Shortest Path Problem illustrates how two-stage column generation works when the pricing subproblem satisfies or not the integrality property. The two-stage scheme is applied to the Discrete Split Delivery Vehicle Routing Problem and extensive computational experiments are provided to validate our framework. In particular, computational &lt;strong&gt;resurts show&lt;/strong&gt; that two-stage column generation reduces the number of generated columns and the computational time for complex instances. The transferability of the designed framework across applications and future research directions are further discussed.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Wikipedia - &lt;a href=&quot;https://en.wikipedia.org/wiki/Branch_and_price&quot; rel=&quot;noreferrer&quot;&gt;Branch and Price&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-08-06T10:46:15.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1181" PostTypeId="1" AcceptedAnswerId="1184" CreationDate="2019-08-06T12:41:11.340" Score="32" ViewCount="5160" Body="&lt;p&gt;I would like to know how the (job) market for operations research works. My dream would be to work as a freelancer in the area of math programming. I have a PHD and several years of proven experience in programming, modeling, bioinformatics, and optimization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some blogs and websites by small companies or individuals working in this area, however they do not tell how they &quot;made it&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can one make a decent living outside the walls of a big consulting firm or software company?&lt;/p&gt;&#xA;" OwnerUserId="1081" LastActivityDate="2019-08-10T20:02:08.590" Title="Make a living as a math programming freelancer?" Tags="|job-market|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="1182" PostTypeId="1" AcceptedAnswerId="1194" CreationDate="2019-08-06T13:09:41.703" Score="11" ViewCount="167" Body="&lt;p&gt;I have a given formulation that looks like this (just for the constraints): &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i \beta_{i,j} \geq \alpha_j,\qquad\forall j$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\alpha_j \geq \sum_i f_{i,j},\qquad\forall j$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\alpha_j \geq 0, f_{i,j} \geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to reduce the size of my formulation, I eliminated the variable &lt;span class=&quot;math-container&quot;&gt;$\alpha_j$&lt;/span&gt; by the means of a valid inequality (may I call it a projection?): &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i \beta_{i,j} \geq \sum_i f_{i,j},\qquad\forall j$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f_{i,j} \geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am now interested in the dual values for each of these constraints (actually, just &lt;span class=&quot;math-container&quot;&gt;$\sum_i \beta_{i,j} \geq \alpha_j$&lt;/span&gt;). How these dual values are related to the ones of the reformulation (mostly &lt;span class=&quot;math-container&quot;&gt;$\sum_i \beta_{i,j} \geq \sum_i f_{i,j}$&lt;/span&gt;)? &lt;/p&gt;&#xA;" OwnerUserId="156" LastActivityDate="2019-08-07T15:31:21.967" Title="How to relate dual values of valid inequality to the dual values of the original problem?" Tags="|duality|valid-inequalities|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1183" PostTypeId="2" ParentId="1170" CreationDate="2019-08-06T13:17:04.490" Score="7" Body="&lt;p&gt;I've seen rather encouraging results using symmetry-breaking constraints, but most valid inequalities were useless (no effect on solving time or, worse, degradation thereof…), both with CPLEX and Gurobi. You really have to test: sometimes, the solver already found better tricks; other times, there are things they are just not smart enough to seee. &lt;/p&gt;&#xA;" OwnerUserId="156" LastActivityDate="2019-08-06T13:17:04.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1184" PostTypeId="2" ParentId="1181" CreationDate="2019-08-06T16:31:18.693" Score="31" Body="&lt;p&gt;Here's what I've seen succeed from my experience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;0) Be comfortable with OR methods. I'm assuming this is a given for anyone who finds this stack exchange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Know your markets. Some aspects of business need OR more than others. Operations management has had a lot in my experience (surprise). One buddy of mine took his clients from consulting and started his own practice doing procurement and network design. For the more technically inclined, I would think the same could happen if you sniffed around for work in planning, logistics, and scheduling. As you noted consulting firms play in this space because they're great at selling themselves. You can be too. Consulting firms can't match your rate if you're independent, and you would be amazed by the number of small to mid market firms who pay people full time to solve by hand the problems I mentioned above. Get out of your comfort zone and start going to networking events and see what people react to. Also, get on sites like upwork. My other most successful friend in OR consulting brought in all his gigs that way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Kill your delivery. This could mean either being comfortable with financial analysis and powerpoint for more strategic projects or being a solid software developer for those more tactical. I think you should be good enough at both of those that you can get a job doing them alone. On the more tactical side of things, this is why you see software companies working in this space too because they're awesome at making OR methods super simple to use. If you're a decent developer though, you can deliver 80% of the value of a software company's product at 20% of the time and cost (and use some finance skills to prove it). I've seen people do this by writing their math models with an ORM (i.e. TicDat or SqlAlchemy) so you quickly get something with data constraints and few changes between dev and production environments. Additionally some background in web development can go a long way here. An API or a GUI will make it as easy as possible for someone else to consume your work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Don't be afraid to jump. No one I've met doing this had a &quot;right time&quot; to start working independently. They worked contracts at night; they used their vacation to network; they left their full time gigs not knowing what their next contract would be 6 months from then. Worst case, you fail, you're out a little money, but you've gained a ton of experience. I think there are plenty of software companies and consulting firms who would hire you just on the story that you tried this, and they would help to show upon hiring you what skills you were missing in order to succeed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Connect with us. Hit up the people on the websites you've seen. Ask them how they did it. You'd be surprised how many experienced professionals would be willing to help you if you have the humility to ask.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best of luck and I hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="342" LastEditorUserId="342" LastEditDate="2019-08-06T17:34:45.633" LastActivityDate="2019-08-06T17:34:45.633" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1185" PostTypeId="1" CreationDate="2019-08-07T04:51:54.007" Score="13" ViewCount="962" Body="&lt;p&gt;I'm specifically looking for real applications of the following form of MIP:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max\,Cx$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;subject to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}Ax +By &amp;amp;= D\\Ax &amp;amp;= E\\By &amp;amp;= F\\ x     &amp;amp;\ge 0\\ y &amp;amp;\in \mathbb{Z}^{+}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Part of these constraints can be excluded. The important thing for me is to have integer (or binary) variables in the constraints but not objective function.&lt;/p&gt;&#xA;" OwnerUserId="1094" LastEditorUserId="123" LastEditDate="2019-08-07T07:30:36.533" LastActivityDate="2019-08-07T20:00:22.833" Title="What are the examples (applications) of the MIPs in which the objective function has nonzero coefficients for only continuous variables?" Tags="|mixed-integer-programming|optimization|combinatorial-optimization|applications|" AnswerCount="7" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1186" PostTypeId="2" ParentId="1185" CreationDate="2019-08-07T05:04:29.073" Score="5" Body="&lt;p&gt;You can find lots of applications of MIPs in the explained form in the engineering fields. As an example, you can look at topology and size optimization problems in the design of structures in the field of civil or mechanical engineering. Where in the objective function you have the volume of the structure (&lt;span class=&quot;math-container&quot;&gt;$V = \sum l_i \cdot A_i$&lt;/span&gt;) and in the constraints, you have both continuous and binary variables for all the elements. Continuous variables, for example, can explain the cross-sectional area of each member and binary variables can be an indicator of whether you have an element in the specific location of the structure or not. In paper [1], the authors explained this formulation.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] &lt;a href=&quot;https://doi.org/10.1002/nme.2871&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kanno, Yoshihiro, and Xu Guo. &quot;A mixed integer programming for robust truss topology optimization with stress constraints.&quot; International Journal for Numerical Methods in Engineering 83.13 (2010): 1675-1699.&lt;/a&gt; &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="145" LastEditDate="2019-08-07T07:33:33.090" LastActivityDate="2019-08-07T07:33:33.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1187" PostTypeId="2" ParentId="1185" CreationDate="2019-08-07T05:23:17.373" Score="8" Body="&lt;p&gt;An example in the field of public transport is the &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.1080.0240&quot; rel=&quot;noreferrer&quot;&gt;Periodic Event Scheduling Problem&lt;/a&gt;, which is used to model periodic timetabling problems. The objective is typically to minimize the total travel time of passengers, which can be represented as a weighted sum of continuous variables representing driving, dwelling and transfer times. The constraints impose lower and upper bounds for various activity durations (e.g. minimum driving times and minimum separation times between services). To ensure that the timetable is periodic, integer variables are needed in these constraints, but these do not appear in the objective function. &lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2019-08-07T05:23:17.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1188" PostTypeId="2" ParentId="1185" CreationDate="2019-08-07T05:47:29.390" Score="8" Body="&lt;p&gt;An example can be shipping products from plants (&lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;) to warehouses (&lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;), where you are interested in minimizing the total transportation cost subject to some constraints. Now, if you calculate transportation cost based on the amount you ship from plant to warehouse (&lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt;), then you can have constraints where this amount is bounded by the number of trucks you need to use to ship your products between locations (&lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt;). So, your constraint can be something like the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_{ij} \le C_{ij}y_{ij}$$&lt;/span&gt; &#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{ij} \ge 0, y_{ij} \in \mathbb{Z}^+$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$C_{ij}$&lt;/span&gt; was the capacity of the truck shipping products from plant &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to warehouse &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (I used it that way for generality).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also (as I said in a comment), take a look at &lt;a href=&quot;https://or.stackexchange.com/questions/1160/how-to-linearize-min-function-as-a-constraint/1174#1174&quot;&gt;this answer&lt;/a&gt;. Anytime you have a min/max constraint, introduce binary variables to linearize it. Those binary variables are not in your objective function!&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-08-07T05:54:22.643" LastActivityDate="2019-08-07T05:54:22.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1189" PostTypeId="2" ParentId="1185" CreationDate="2019-08-07T05:58:54.377" Score="6" Body="&lt;p&gt;A couple of related examples (with a minimization objective, but the idea is the same):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This structure comes up in many minimax optimization problems. Say you have binary/integer variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and corresponding costs &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;, and you want to minimize a &quot;bottleneck&quot; cost: &lt;span class=&quot;math-container&quot;&gt;$$\min [\max_{i} \{c_i x_i\}]$$&lt;/span&gt;&#xA;You would then introduce a continuous variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, add constraints &lt;span class=&quot;math-container&quot;&gt;$y \geq c_i x_i$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and instead solve &lt;span class=&quot;math-container&quot;&gt;$\min y$&lt;/span&gt;. &lt;/li&gt;&#xA;&lt;li&gt;In &lt;a href=&quot;https://arxiv.org/pdf/1803.09040.pdf&quot; rel=&quot;noreferrer&quot;&gt;this approach&lt;/a&gt; to school bus scheduling by Zeng et al., the total number of buses required is minimized as a continuous variable, but all of the scheduling variables in the constraints are binary (see p. 7 of linked paper).  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="196" LastEditorUserId="196" LastEditDate="2019-08-07T06:56:41.390" LastActivityDate="2019-08-07T06:56:41.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1191" PostTypeId="2" ParentId="1185" CreationDate="2019-08-07T09:53:51.910" Score="7" Body="&lt;p&gt;To complete @EhsanK's answer, a relevant yet more general class of problems is the &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median problem, which is a variant of facility location problems aiming to minimize total transportation costs via locating only &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; facilities. In this class of problems, a facility must be located (i.e., binary decision variables) before allowing transporting goods from it to customers (i.e., continuous decision variables). A simple variant of the problem is modeled as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \min\,\sum_{i \in C,j \in F}h_{i}c_{ij}x_{ij}$$&lt;/span&gt; &#xA;subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j \in F}x_{ij}=1\qquad \forall i \in C$$&lt;/span&gt; &#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x_{ij} \le y_{j} \qquad \forall i \in C\,\&amp;amp;\,\forall j \in F$$&lt;/span&gt; &#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j \in F}y_{j}=p$$&lt;/span&gt; &#xA;&lt;span class=&quot;math-container&quot;&gt;$$0 \le x_{ij} \le 1\qquad \forall i \in C\,\&amp;amp;\,\forall j \in F$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{j} \in \{0,1\}\qquad \forall j \in F$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="119" LastEditorUserId="119" LastEditDate="2019-08-07T12:54:14.513" LastActivityDate="2019-08-07T12:54:14.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1192" PostTypeId="2" ParentId="1185" CreationDate="2019-08-07T10:28:43.650" Score="8" Body="&lt;p&gt;If you are dealing with feasibility problems then you won't worry about an objective function as you only need one feasible solution. A classical feasibility problem is a Sudoku. A (&lt;span class=&quot;math-container&quot;&gt;$9\times 9$&lt;/span&gt;) Sudoku can be formulated as a MIP in the following way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned}&#xA;&amp;amp; {\text{minimize}}&#xA;&amp;amp; &amp;amp;0 \\&#xA;&amp;amp; \text{subject to}&#xA;&amp;amp; &amp;amp; \sum_{i=1}^9 x_{ijk}   = 1 \; \text{ for } j,k = 1, \ldots, 9\\&#xA;&amp;amp;&amp;amp; &amp;amp; \sum_{j=1}^9 x_{ijk}   = 1 \; \text{ for } i,k = 1, \ldots, 9\\&#xA;&amp;amp;&amp;amp; &amp;amp; \sum_{k=1}^9 x_{ijk}   = 1 \; \text{ for } i,j = 1, \ldots, 9\\&#xA;&amp;amp;&amp;amp; &amp;amp; \sum_{i=3p-2}^{3p} \sum_{j=3q-2}^{3q} x_{ijk}   = 1 \; \text{ for } k= 1, \ldots, 9 \text{ and } p,q = 1,\ldots,3\\&#xA;\end{aligned}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The objective function does not play a role since there is no &quot;best&quot; Sudoku solution. You only need a feasible one. You could even change the objective to max &lt;span class=&quot;math-container&quot;&gt;$x_{123}$&lt;/span&gt; for example, even though this would not be in the sense of your question since you asked for problems where the objective coefficients of the integer variables are 0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Sudoku is just one example. The same also holds for every other feasibility problem.&lt;/p&gt;&#xA;" OwnerUserId="81" LastActivityDate="2019-08-07T10:28:43.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1193" PostTypeId="1" CreationDate="2019-08-07T11:02:45.587" Score="22" ViewCount="5071" Body="&lt;p&gt;Within the subject of simulation I have found some literature on validation and verification (e.g. Sargent's &lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.51.4210&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;noreferrer&quot;&gt;paper&lt;/a&gt;). My question is, what techniques do you use to validate and verify your mathematical (optimization) models and their implementation?&lt;/p&gt;&#xA;" OwnerUserId="609" LastEditorUserId="145" LastEditDate="2019-08-07T18:35:04.743" LastActivityDate="2019-08-07T20:29:47.723" Title="Validation and verification of mathematical models" Tags="|optimization|modeling|simulation|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1194" PostTypeId="2" ParentId="1182" CreationDate="2019-08-07T11:24:25.053" Score="9" Body="&lt;p&gt;For simplicity, I will&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;replace &lt;span class=&quot;math-container&quot;&gt;$\sum_i \beta_{i,j}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ \sum_i f_{i,j}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\alpha_j$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, respectively.&lt;/li&gt;&#xA;&lt;li&gt;assume that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; are defined to be non-negative.&lt;/li&gt;&#xA;&lt;li&gt;assume that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; has a coefficient &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; in the objective, and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; has a coefficient &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; in the objective.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That is, we consider the following program, with the dual variables in parenthesis:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\min &amp;amp;~cx + dy\\&#xA;x &amp;amp; \ge z &amp;amp; (\lambda)\\&#xA;z &amp;amp; \ge y &amp;amp; (\mu)\\&#xA;x, y, z &amp;amp; \ge 0.&#xA;\end{align}$$&lt;/span&gt;&#xA;The dual program is given by&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\max &amp;amp; ~0 \\&#xA;\lambda &amp;amp; \le c\\&#xA;\mu &amp;amp; \ge -d\\&#xA;\lambda &amp;amp; \ge \mu\\&#xA;\lambda, \mu &amp;amp; \ge 0.&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, we can consider the smaller formulation:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\min &amp;amp;~cx + dy\\&#xA;x &amp;amp; \ge y &amp;amp; (\gamma)\\&#xA;x, y &amp;amp; \ge 0,&#xA;\end{align}$$&lt;/span&gt;&#xA;with dual&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\max &amp;amp; ~0 \\&#xA;\gamma&amp;amp; \le c\\&#xA;\gamma &amp;amp; \ge -d\\&#xA;\gamma &amp;amp; \ge 0.&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given a feasible dual solution &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; for the second formulation, we can always obtain a dual feasible solution for the first formulation by using &lt;span class=&quot;math-container&quot;&gt;$\lambda = \gamma$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu = \max\{0,-d\}$&lt;/span&gt;.&#xA;Note that other choices for &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; may also be possible.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Verification:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; be a dual feasible solution to the second formulation, and let &lt;span class=&quot;math-container&quot;&gt;$\lambda = \gamma$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu = \max\{0,-d\}$&lt;/span&gt;. Now, we check the constraints of the dual of the first formulation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\lambda \le c \Leftrightarrow \gamma \le c$&lt;/span&gt;, follows from dual feasibility of &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mu \ge -d \Leftrightarrow \max\{0,-d\} \ge -d$&lt;/span&gt;, holds by definition.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\lambda \ge \mu \Leftrightarrow \gamma \ge \max\{0,-d\}$&lt;/span&gt;, follows from dual feasibility of &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\lambda \ge 0 \Leftrightarrow \gamma \ge 0$&lt;/span&gt;, follows from dual feasibility of &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mu \ge 0 \Leftrightarrow \max\{0,-d\} \ge 0$&lt;/span&gt;, holds by definition.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2019-08-07T15:31:21.967" LastActivityDate="2019-08-07T15:31:21.967" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1195" PostTypeId="2" ParentId="1193" CreationDate="2019-08-07T12:36:03.333" Score="7" Body="&lt;p&gt;Kleijnen (1995) analyses various methods of model verification and validation (V&amp;amp;V). Quoting the abstract (with slight changes to formatting):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;For verification it discusses&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;general good programming practice (such as modular programming),&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;checking intermediate simulation outputs through tracing and statistical testing per module,&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;statistical testing of final simulation outputs against analytical results, and&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;animation.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;For validation it discusses&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;obtaining real-world data,&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;comparing simulated and real data through simple tests such as graphical, Schruben-Turing, and &lt;em&gt;t&lt;/em&gt;-tests,&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;testing whether simulated and real responses are positively correlated and moreover have the same mean, using two new statistical procedures based on regression analysis,&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;sensitivity analysis based on design of experiments and regression analysis, and risk or uncertainty analysis based on Monte Carlo sampling, and&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;white versus black box simulation models.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Both verification and validation require good documentation, and are crucial parts of assessment, credibility, and accreditation.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Kleijnen, J. C. (1995). Verification and validation of simulation models. &lt;em&gt;European Journal of Operational Research.&lt;/em&gt; &lt;strong&gt;82(1)&lt;/strong&gt;:145-162. &lt;a href=&quot;https://doi.org/10.1016/0377-2217(94)00016-6&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1016/0377-2217(94)00016-6&lt;/a&gt; &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-08-07T12:36:03.333" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1196" PostTypeId="2" ParentId="1193" CreationDate="2019-08-07T12:42:44.050" Score="20" Body="&lt;p&gt;Generally speaking, verification refers to evaluating the conformation of a system, product, or service with its intended requirements and design specifications. On the other hand, validation refers to evaluate how much that system, product, or service is in accordance with the customers' or stakeholders' expectations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK, there is no concrete literature on verification and validation of optimization models. Over the years, I gathered some useful points and methods based on my own and other colleagues' experiences as well as what is mentioned in the literature.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Verification in Optimization:&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here, verification refers to the extent to which the model/solution method is performing in accordance with the initial modeling assumptions. Some useful methods are as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Double-check the mathematics/coding of your model/algorithm with the problem definition and assumptions to make sure everything is OK (i.e., no assumption is violated or left out of the model/algorithm).&lt;/li&gt;&#xA;&lt;li&gt;Check whether the solution provided by a solver or your implemented algorithm is sound and logical (e.g., it doesn't violate any constraint).&lt;/li&gt;&#xA;&lt;li&gt;Feed deliberately designed (either by hand or the solutions obtained from the experts or the real system) feasible and infeasible solutions to your model and solution method and see if it can confirm the feasibility/infeasibility of the provided solution.&lt;/li&gt;&#xA;&lt;li&gt;Fix some decision variables and/or change input data to see if the model/algorithm behavior changes. It's possible that the model is OK with some input data, but not with some others (this could either be due to the input data or the model itself).&lt;/li&gt;&#xA;&lt;li&gt;Compare the solutions provided by the model (obtained via a solver) and your implemented solution method to see if there is any concerning disparity.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Validation in Optimization:&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here, validation refers to the extent to which the model/algorithm is satisfying the expectations of the problem owner. Some useful methods are as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Compare your solution with the current solution in the system and see whether it can outperform the incumbent.&lt;/li&gt;&#xA;&lt;li&gt;Use standard problem instances and compare your results with the best-known solutions form the literature.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If there are no standard problem instances, create random ones (either according to the literature with some tweaks or completely from scratch), and then do one of the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Compare your algorithm with solutions obtained from solving the mathematical model using a solver.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Compare your model/algorithm with solutions obtained from the state-of-the-art models/algorithms.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Develop a lower/upper bound on the objective function (e.g., using linear programming relaxation or Lagrangian relaxation). This could also be useful when you have real-world data from the system but no previously implemented solution exists.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="119" LastEditorUserId="119" LastEditDate="2019-08-07T17:39:09.937" LastActivityDate="2019-08-07T17:39:09.937" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1197" PostTypeId="1" CreationDate="2019-08-07T13:16:17.247" Score="10" ViewCount="2495" Body="&lt;p&gt;I want to run a model written in Pyomo language with CPLEX solver of GAMS.&#xA;However I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;No 'gams' command found on system PATH - GAMS shell&quot;&#xA;NameError: No 'gams' command found on system PATH - GAMS shell solver &#xA;functionality is not available. &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have added the folder (C:\GAMS\win64\25.1) to environmental variables of system. &#xA;Pyomo version is 5.6.5. Python is 3.5.2. and GAMS is 25.1.2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be grateful if you could provide me with help.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;solvername = 'gams'&#xA;opt = SolverFactory(solvername)&#xA;results = opt.solve(&#xA;    instance, solver='cplex', keepfiles=True, tee=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1107" LastEditorUserId="38" LastEditDate="2019-09-21T01:22:00.870" LastActivityDate="2019-09-21T01:22:00.870" Title="How to get GAMS's solvers to work from Pyomo?" Tags="|cplex|python|pyomo|modeling-languages|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1198" PostTypeId="2" ParentId="1193" CreationDate="2019-08-07T13:20:11.597" Score="13" Body="&lt;p&gt;This is just to complement the answer that @Ehsan gave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For both verification and validation, if possible, visualize your results. For example, if you are solving a routing problem, simply visualizing the resulting routes may provide great insights.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Does the solution (routes) make sense? &lt;/li&gt;&#xA;&lt;li&gt;Are there constraints in the model that are violated and I had no idea about (assume you had no idea about subtour elimination and visualizing the routes may help you identify them)? &lt;/li&gt;&#xA;&lt;li&gt;Should I add more constraints that I was not considering, simply by looking at the results? Imagine you see a route that starts in FL, goes to NY and then CA. Maybe it doesn't violate any of your current constraints, but it's something you don't like to have.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also, check &lt;a href=&quot;https://or.stackexchange.com/a/770/36&quot;&gt;this answer&lt;/a&gt; which shares a procedure for debugging an optimization code which can be very useful in your verification process.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-08-07T13:20:11.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1199" PostTypeId="2" ParentId="1193" CreationDate="2019-08-07T14:06:59.097" Score="6" Body="&lt;p&gt;I really like the paper by &lt;a href=&quot;https://doi.org/10.1287/ijoc.12.1.24.11899&quot; rel=&quot;noreferrer&quot;&gt;Coffin and Saltzman (&lt;em&gt;INFORMS JOC&lt;/em&gt;, 2000)&lt;/a&gt;, which argues that we should be using much more rigorous statistical tests when we compare the performance of one algorithm/heuristic against another. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not exactly about &lt;em&gt;validation&lt;/em&gt; (which I interpret as &quot;checking correctness&quot;) but rather about &lt;em&gt;comparison&lt;/em&gt;, so feel free to tell me if this answer is off-topic. &lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-08-07T14:06:59.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1200" PostTypeId="2" ParentId="12" CreationDate="2019-08-07T14:10:17.627" Score="11" Body="&lt;p&gt;I don't know if it's really what you are asking for, but Julia has a few packages that implement algorithms for stochastic programming (on top of other LP solvers): &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/JuliaStochOpt/StochDynamicProgramming.jl&quot; rel=&quot;noreferrer&quot;&gt;StochDynamicProgramming.jl&lt;/a&gt; (seems more oriented towards control problems)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/martinbiel/StochasticPrograms.jl&quot; rel=&quot;noreferrer&quot;&gt;StochasticPrograms.jl&lt;/a&gt;, rather complete modelling environment&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/odow/SDDP.jl&quot; rel=&quot;noreferrer&quot;&gt;SDDP.jl&lt;/a&gt;, an implementation of SDDP and a modelling layer&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/StructJuMP/StructJuMP.jl&quot; rel=&quot;noreferrer&quot;&gt;StructJuMP.jl&lt;/a&gt; is a modelling layer for block-structured optimisation programs, that can then be solved with &lt;a href=&quot;https://github.com/JuliaStochOpt/StructDualDynProg.jl&quot; rel=&quot;noreferrer&quot;&gt;StructDualDynProg.jl&lt;/a&gt; (implementing SDDP)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="156" LastActivityDate="2019-08-07T14:10:17.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1201" PostTypeId="2" ParentId="1197" CreationDate="2019-08-07T14:40:58.880" Score="2" Body="&lt;p&gt;One way to use CPLEX solver of GAMS in Pyomo (I am assuming you have a license for GAMS and CPLEX itself licensed for your GAMS, In other words, your CPLEX solver can only be used by GAMS) is that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/library_reference/solvers/gams.html#gams-writer&quot; rel=&quot;nofollow noreferrer&quot;&gt;GAMS Writer&lt;/a&gt; in Pyomo to translate your model from Pyomo into a format that can be read by GAMS and then use GAMS to solve the model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/library_reference/solvers/gams.html#gams&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt;, there are two more ways by them you can use GAMS solvers in Pyomo. &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-08-08T01:31:05.807" LastActivityDate="2019-08-08T01:31:05.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1202" PostTypeId="2" ParentId="1089" CreationDate="2019-08-07T15:59:06.813" Score="3" Body="&lt;p&gt;My recommendation is to use something like &lt;a href=&quot;https://scirate.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://scirate.com/&lt;/a&gt; or even Mendeley also provides recommendations if you have built up a reference list.&lt;/p&gt;&#xA;" OwnerUserId="259" LastActivityDate="2019-08-07T15:59:06.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1203" PostTypeId="1" AcceptedAnswerId="1204" CreationDate="2019-08-07T17:44:50.717" Score="9" ViewCount="153" Body="&lt;p&gt;The two-commodity flow formulation is introduced by &lt;a href=&quot;https://doi.org/10.1287/opre.1040.0111&quot; rel=&quot;noreferrer&quot;&gt;Baldacci et al. (2004)&lt;/a&gt;. It is known for its good performance and providing a tight lower bound. &#xA;I searched the literature, but couldn't find any study that expands this formulation on asymmetric digraphs. &#xA;Do you think it is possible to expand this formulation on asymmetric digraphs? If not, why? If yes, do you know a study that did this already?&lt;/p&gt;&#xA;" OwnerUserId="172" LastEditorUserId="145" LastEditDate="2019-08-07T18:16:43.750" LastActivityDate="2019-08-07T18:16:43.750" Title="Two-commodity flow formulation for an asymmetric cost VRP" Tags="|vehicle-routing|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1204" PostTypeId="2" ParentId="1203" CreationDate="2019-08-07T18:14:40.777" Score="7" Body="&lt;p&gt;One way to do this is as follows: for each edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_{ji}$&lt;/span&gt; that indicate whether a vehicle travels from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; or from &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and add the constraint &lt;span class=&quot;math-container&quot;&gt;$z_{ij} + z_{ji} \le 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now &lt;span class=&quot;math-container&quot;&gt;$z_{ij} + z_{ji}$&lt;/span&gt; is equal to 1 if edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is used in the solution and equal to 0 if edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is not used. You can now simply replace &lt;span class=&quot;math-container&quot;&gt;$\xi_{ij}$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$z_{ij} + z_{ji}$&lt;/span&gt;. This follows from the fact that capacity is symmetric: it does not matter in which direction you travel, the load remains the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above approach is explained in more detail in &lt;a href=&quot;https://doi.org/10.1016/j.cor.2017.08.015&quot; rel=&quot;noreferrer&quot;&gt;a paper of mine&lt;/a&gt;. I am not claiming that this is the only way or the best way to use this formulation in an asymmetric setting.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-08-07T18:14:40.777" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1205" PostTypeId="2" ParentId="1185" CreationDate="2019-08-07T20:00:22.833" Score="6" Body="&lt;p&gt;A problem that sometimes arises in logistics is to find a minimum cost shipping schedule from warehouses to customers (think min cost flow network) with a side constraint that each customer must receive deliveries from at most &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; sources, where &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is an integer (typically small, say 2). Binary variables are used to signal which sources are supplying which customers, but do not appear in the objective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe I've seen similar structures in work allocation models, where the &quot;customers&quot; are projects, the &quot;delivery quantity&quot; is time/effort devoted to the project, the sources are workers and the binary variables are used to limit either how many projects a single worker can be asked to contribute to or how many workers can be asked to share a single project (or both).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-07T20:00:22.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1206" PostTypeId="2" ParentId="1193" CreationDate="2019-08-07T20:29:47.723" Score="11" Body="&lt;p&gt;For models being deployed in the &quot;real world&quot; (something that, as an academic, I have heard rumors about), one element of validation is to describe both the objective criteria and the constraints to the decision makers (in their language, not in algebraic terms) and see if they agree with you. Another is to run the model on historical inputs and see if the resulting solution makes sense to them. This is an opportunity for them to discover constraints they kinda sorta forgot to mention the first time around, or to modify the objective criterion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Switching to verification, if the model parameterized by historical inputs is infeasible, then you have likely found a flaw in the model. If the model using historical data is feasible but either (a) the historical solution is not feasible or (b) the historical solution is better than the &quot;optimal&quot; solution, the model is likely wrong.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-07T20:29:47.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1207" PostTypeId="1" AcceptedAnswerId="1209" CreationDate="2019-08-07T21:16:24.990" Score="26" ViewCount="601" Body="&lt;p&gt;Currently I need to solve a quite specific problem involving symmetric TSP as a sub-problem (i.e., a Hamiltonian cycle is a necessary condition for optimizing some problem-specific variables that should make use of that cycle).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the literature review, the Dantzig-Fulkerson-Johnson (DFJ) formulation seems to be the tightest and most practical TSP formulation. However, I have also encountered a large number of papers trying to improve the Miller-Tucker-Zemlin (MTZ) formulation that is more convenient than DFJ but very loose (e.g., papers by Desrochers-Laporte, H. Sherali etc.). Why would people spend time improving MTZ, if DFJ is much tighter and all &lt;em&gt;compact&lt;/em&gt; MTZ improvements never come close to DFJ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the paper by &lt;a href=&quot;https://doi.org/10.1287/opre.50.4.656.2865&quot; rel=&quot;noreferrer&quot;&gt;H. Sherali and P. Driscoll (2002)&lt;/a&gt;, the authors mention that generating DFJ constraints via branch-and-cut may be &quot;inconvenient&quot; if TSP is only a substructure within the model (precisely my situation). However, I don't understand why would it be inconvenient? Some other authors mention that it is important to tighten the polyhedral representation of the initial TSP formulation to use the best bounds  produced by the linear programming relaxation of the initial formulation &lt;em&gt;that guides branching decisions&lt;/em&gt;, regardless of the run-time actions taken by the MIP optimizers. Can it really be so that a good initial formulation may outweigh the benefits of strong DFJ cuts generated during the run-time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, if there is indeed any merit in improved MTZ-like TSP formulations (e.g., &lt;a href=&quot;https://doi.org/10.1016/0167-6377(91)90083-2&quot; rel=&quot;noreferrer&quot;&gt;Desrochers and Laporte (1991)&lt;/a&gt;), would it make sense to use such improved MTZ formulations to support the TSP subproblem, while still generating valid DFJ cuts in the run-time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S.: Some MTZ-papers are as new as 2018, so I am wondering if such new formulations can outperform DFJ on problems which only include TSP as a sub-problem (otherwise why so many papers; for pure TSP DFJ should be much better, this is clear).&lt;/p&gt;&#xA;" OwnerUserId="1099" LastEditorUserId="1099" LastEditDate="2019-08-08T18:05:51.943" LastActivityDate="2019-08-09T08:02:51.643" Title="The rationale to improve MTZ?" Tags="|mixed-integer-programming|modeling|traveling-salesman|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1208" PostTypeId="2" ParentId="1197" CreationDate="2019-08-08T03:42:50.613" Score="4" Body="&lt;p&gt;The syntax that you are using in your Pyomo code is correct and you should be able to access the GAMS solvers once Pyomo is able to find GAMS.&#xA;As the error mentions, the GAMS command is not found in the system PATH. I would double check if the GAMS path is correctly added to the system PATH. A way of doing so is opening a command prompt (since you are using Windows cmd.exe or the PowerShell) and writing &lt;code&gt;gams&lt;/code&gt;. It should show your license details as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PS C:\Users\debernal&amp;gt; gams&#xA;--- Job ? Start 08/08&#xA;/19 03:32:16 25.1.0 r944b73f WEX-WEI x86 64bit/MS Windows&#xA;*** GAMS Base Module 27.2.0 r944b73f Released May 23, 2019 WEI x86 64bit/MS Window&#xA;***&#xA;*** GAMS Development Corporation&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Pyomo-GAMS interface is able to access both the GAMSShell solver (through the environment variable) and the GAMSDirect solver (which is GAMS Python API). To install the last one you need to run the code &lt;code&gt;python setup.py install&lt;/code&gt; in the directory &lt;code&gt;C:\GAMS\win64\25.1\apifiles\Python\api_36\&lt;/code&gt; (adjust if you use different versions of Python/GAMS than the ones mentioned by the OP). More instructions can be found &lt;a href=&quot;https://www.gams.com/latest/docs/API_PY_TUTORIAL.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2019-08-08T03:42:50.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1209" PostTypeId="2" ParentId="1207" CreationDate="2019-08-08T11:52:43.387" Score="11" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Why would people spend time improving MTZ, if DFJ is much tighter and all compact MTZ improvements never come close to DFJ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Although this might not be used in TSP solvers, it could still be interesting to research finding tight &lt;em&gt;compact&lt;/em&gt; formulations for the TSP from a theoretical perspective. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In the paper by H. Sherali and P. Driscoll, the authors mention that generating DFJ constraints via branch-and-cut may be &quot;inconvenient&quot; if TSP is only a substructure within the model (precisely my situation). However, I don't understand why would it be inconvenient?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I suppose that implementing branch-and-cut is more time-consuming than simply implementing the MTZ formulation. If the TSP substructure contains a small number of nodes, the MTZ formulation might work fine and the benefits of the tighter DFJ formulation are not worth the effort.  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can it really be so that a good initial formulation may outweigh the benefits of strong DFJ cuts generated during the run-time? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Did the authors you mentioned perform any experiments to back up this claim? If not, you might want to take this with a grain of salt. A good initial formulation may indeed lead to better bounds and therefore a smaller branch-and-bound tree. On the other hand, strengthening MTZ requires introducing more variables and constraints. For example, the improved MTZ-formulation by Sherali and Driscoll (2002) contains &lt;span class=&quot;math-container&quot;&gt;$2n^2$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$2n^2+3n$&lt;/span&gt; constraints. As a result, solving each node in the tree might be more time-consuming. Only experiments can show which of these forces is stronger. However, a significant speed-up would be required for such an approach to become competitive with a branch-and-cut algorithm for the DFJ formulation.  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Finally, if there is indeed any merit in improved MTZ-like TSP formulations (e.g., Desrochers-Laporte 1991), would it make sense to use such improved MTZ formulations to support the TSP subproblem, while still generating valid DFJ cuts in the run-time?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This strongly relates to your third question. My suggestion would be to at least not try this as your first approach. Rather, start with either the MTZ formulation or a branch-and-cut algorithm to solve the DFJ formulation. If this does not lead to satisfactory results, you could try some more exotic approaches. &lt;/p&gt;&#xA;" OwnerUserId="764" LastEditorUserId="764" LastEditDate="2019-08-09T08:02:51.643" LastActivityDate="2019-08-09T08:02:51.643" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1210" PostTypeId="1" AcceptedAnswerId="1212" CreationDate="2019-08-08T18:47:41.650" Score="14" ViewCount="1171" Body="&lt;p&gt;I am looking for journals which do not focus on OR or a subfield (math programming, simulation, logistics, etc.) but still publish a few OR papers on a regular basis. What are some journals which would fit this criteria?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example is &lt;a href=&quot;https://www.sciencedirect.com/journal/socio-economic-planning-sciences/vol/67/suppl/C&quot; rel=&quot;noreferrer&quot;&gt;Socio-Economic Planning Sciences&lt;/a&gt;, which isn't explicitly an OR journal, but publishes an article or two every issue which uses OR methods. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recent papers:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Faiz, T. I., Noor-E-Alam, M. (2019). &lt;a href=&quot;https://doi.org/10.1016/j.seps.2018.07.008&quot; rel=&quot;noreferrer&quot;&gt;Data center supply chain configuration design: A two-stage decision approach.&lt;/a&gt; &lt;em&gt;Socio-Economic Planning Sciences.&lt;/em&gt; 66:119-135.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Caceres, H., Batta, R., He, Q. (2019). &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0038012117301374&quot; rel=&quot;noreferrer&quot;&gt;Special need students school bus routing: Consideration for mixed load and heterogeneous fleet.&lt;/a&gt; &lt;em&gt;Socio-Economic Planning Sciences.&lt;/em&gt; 65:10-19.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="196" LastEditorUserId="123" LastEditDate="2019-08-09T07:04:23.217" LastActivityDate="2019-08-09T07:42:00.710" Title="Non-OR journals which regularly publish OR research" Tags="|academia|journals|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1211" PostTypeId="2" ParentId="1210" CreationDate="2019-08-08T19:02:34.727" Score="6" Body="&lt;p&gt;I would say &lt;strong&gt;&lt;a href=&quot;https://link.springer.com/journal/158&quot; rel=&quot;nofollow noreferrer&quot;&gt;Structural and Multidisciplinary Optimization&lt;/a&gt;&lt;/strong&gt; with the following description taken from &lt;em&gt;Springer&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Journal Description&lt;/h3&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The journal’s scope ranges from mathematical foundations of the field to algorithm and software development, and from benchmark examples to case studies of practical applications in structural, aerospace, mechanical, civil, chemical, naval and bio-engineering.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Fields such as computer-aided design and manufacturing, uncertainty quantification, artificial intelligence, system identification and modeling, inverse processes, computer simulation, biomechanics, bio-medical applications, nanotechnology, MEMS, optics, chemical processes, computational biology, meta-modeling, DOE and active control of structures are covered when the topic is closely related to the optimization of structures or fluids. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;em&gt;Structural and Multidisciplinary Optimization&lt;/em&gt; publishes original research papers, review articles, industrial applications, brief notes, educational articles, book reviews, conference diary, forum section, discussions on papers, authors´ replies, obituaries, announcements, and society news.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-08-09T07:42:00.710" LastActivityDate="2019-08-09T07:42:00.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1212" PostTypeId="2" ParentId="1210" CreationDate="2019-08-08T20:07:20.223" Score="12" Body="&lt;p&gt;I'm going to assume here that we are talking about papers utilizing OR concepts (model, solution procedure, some sort of consequences of interest to the readers) as opposed to &quot;pure OR papers&quot; (theorem-proof, metaheuristic races, ...).&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Many of the journals in supply chain management and related disciplines (operations management, logistics and even sourcing) publish articles that use what I would call OR/MS techniques, concepts or models. In particular, &lt;em&gt;Naval Research Logistics&lt;/em&gt; publishes some pretty quantitative articles.&lt;/li&gt;&#xA;&lt;li&gt;There are journals in healthcare management (or journals with healthcare departments/areas) that publish OR-type articles. Although I have no first-hand experience, I have been told that &lt;em&gt;Healthcare Management Science&lt;/em&gt; falls into this category.&lt;/li&gt;&#xA;&lt;li&gt;There are journals in agriculture, forestry etc. that take those types of articles. I coauthored a simulation-based paper in the &lt;em&gt;Canadian Journal of Forestry&lt;/em&gt; (way back when).&lt;/li&gt;&#xA;&lt;li&gt;On a related note, there are journals devoted to conservation that take OR-type articles. Someone I know is in the review process with an article containing a multiobjective binary optimization model. (I'm not sure I know which journal they are targeting.)&lt;/li&gt;&#xA;&lt;li&gt;Articles containing optimization models can show up in journals in a variety of engineering fields. I've snuck into &lt;em&gt;IIE Transactions&lt;/em&gt; and &lt;em&gt;IEEE Transactions on Pattern Analysis and Machine Intelligence&lt;/em&gt;, and &lt;em&gt;IEEE Transactions on Networking&lt;/em&gt; may yet get a paper on which I am a contributor.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In many (most?) cases with application-area journals, the journal is mainly interested in meaningful outcomes with reasonable assumptions (and reasonable rigor), and not in how many mathematical symbols you can cram on a page or whether you can prove the problem is NP-annoying.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-08T20:07:20.223" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1213" PostTypeId="2" ParentId="1210" CreationDate="2019-08-08T20:09:17.373" Score="8" Body="&lt;h2&gt;&lt;a href=&quot;https://tbiomed.biomedcentral.com/&quot; rel=&quot;noreferrer&quot;&gt;Theoretical Biology and Medical Modelling&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;h3&gt;Journal Description&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;Theoretical Biology and Medical Modelling&lt;/em&gt; is an open access peer-reviewed journal adopting a broad definition of &amp;quot;biology&amp;quot; and focusing on theoretical ideas and models associated with developments in biology and medicine. Mathematicians, biologists and clinicians of various specialisms, philosophers and historians of science are all contributing to the emergence of novel concepts in an age of systems biology, bioinformatics and computer modelling. This is the field in which &lt;em&gt;Theoretical Biology and Medical Modelling&lt;/em&gt; operates.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h3&gt;Operations Research Papers&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Polisetty, P. K., Voit, E. O., Gatzke, E. P. (2006). &lt;a href=&quot;https://link.springer.com/content/pdf/10.1186%2F1742-4682-3-4.pdf&quot; rel=&quot;noreferrer&quot;&gt;Identification of metabolic system parameters using global optimization methods.&lt;/a&gt; &lt;em&gt;Theoretical Biology and Medical Modelling.&lt;/em&gt; 3:4.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Marin-Sanguino, A., Voit, E. O., Gonzalez-Alcon, C., Torres, N. V. (2007). &lt;a href=&quot;https://link.springer.com/content/pdf/10.1186%2F1742-4682-4-38.pdf&quot; rel=&quot;noreferrer&quot;&gt;Optimization of biotechnological systems through geometric&#xA;programming.&lt;/a&gt; &lt;em&gt;Theoretical Biology and Medical Modelling.&lt;/em&gt; 4:38.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="123" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-08-08T20:09:17.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1214" PostTypeId="1" CreationDate="2019-08-08T20:18:57.617" Score="9" ViewCount="1636" Body="&lt;p&gt;I am trying to solve a MIP using SCIP. I let my solver run for some initial time-bound - let's say 10min. After 10min, I check if the problem is solved to optimality or 1% gap. If not, then I would like to start solving the problem again, but warm started with the solution I had at the end of my last run. I am new to SCIP, hence not aware if it's possible and how to do so (if yes). &lt;/p&gt;&#xA;" OwnerUserId="635" LastEditorUserId="500" LastEditDate="2023-12-13T18:01:05.850" LastActivityDate="2023-12-13T18:01:05.850" Title="Warm-start SCIP with a solution" Tags="|mixed-integer-programming|solver|scip|warm-start|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1215" PostTypeId="1" CreationDate="2019-08-08T20:27:53.780" Score="18" ViewCount="2148" Body="&lt;p&gt;Sometimes, when solving mathematical optimization models (especially MIPs), they may be infeasible.  Is there any comprehensive method to deal with the infeasibility conditions? (especially in complex models)&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="38" LastEditDate="2019-08-08T21:10:08.940" LastActivityDate="2023-05-18T18:06:48.673" Title="Infeasibility in mathematical optimization models" Tags="|optimization|modeling|" AnswerCount="6" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1216" PostTypeId="2" ParentId="1214" CreationDate="2019-08-08T20:41:32.900" Score="6" Body="&lt;p&gt;The branch-and-bound tree management and LP solving including storage of warm start bases are possible using SCIP according to &lt;a href=&quot;https://scip.zib.de/doc/html/FAQ.php&quot; rel=&quot;noreferrer&quot;&gt;this link&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Page 14 of the cited paper(1), they explained how to pause the process of solving for SCIP, check or even change some parameters and then continue the solution of the problem. &quot;...first reset all parameters to their default values using &lt;strong&gt;&lt;em&gt;set default&lt;/em&gt;&lt;/strong&gt;. ... Then, after node 200, the user pressed &lt;strong&gt;&lt;em&gt;CTRL-C&lt;/em&gt;&lt;/strong&gt; which &lt;em&gt;interrupts&lt;/em&gt; the solving process, We see that now in the short status report, primal and dual bound are different, thus, the problem is not solved yet. Nevertheless, we could access statistics, see the current incumbent solution, &lt;em&gt;change parameters&lt;/em&gt; and so on. Entering &lt;strong&gt;&lt;em&gt;optimize&lt;/em&gt;&lt;/strong&gt;, we continue the solving process from the point at which it had been interrupted.&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) Berthold, Timo, et al. &quot;Solving mixed integer linear and nonlinear problems using the SCIP optimization suite.&quot; (2012).&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-08-08T20:41:32.900" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1217" PostTypeId="2" ParentId="1215" CreationDate="2019-08-08T20:41:43.647" Score="20" Body="&lt;p&gt;Adding slack variables (with high penalty in the objective function) converts hard constraint into soft ones, and can also be useful to locate the source of infeasibility. This approach can be very useful for feasible problems for which finding a heuristic feasible solution is hard/very time consuming. &lt;/p&gt;&#xA;" OwnerUserId="429" LastActivityDate="2019-08-08T20:41:43.647" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1218" PostTypeId="2" ParentId="1210" CreationDate="2019-08-08T21:15:34.843" Score="7" Body="&lt;p&gt;Journals focused on electricity/power systems often publish OR papers. Examples include &lt;em&gt;&lt;a href=&quot;https://ieeexplore.ieee.org/xpl/RecentIssue.jsp?punumber=5165411&quot; rel=&quot;noreferrer&quot;&gt;IEEE Transactions on Smart Grid&lt;/a&gt;&lt;/em&gt; and &lt;em&gt;&lt;a href=&quot;https://ieeexplore.ieee.org/xpl/RecentIssue.jsp?punumber=5165391&quot; rel=&quot;noreferrer&quot;&gt;IEEE Transactions on Sustainable Energy&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-08-08T21:15:34.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1219" PostTypeId="2" ParentId="1215" CreationDate="2019-08-08T21:34:07.477" Score="5" Body="&lt;p&gt;Here is a good (but a little bit old) paper&lt;sup&gt;1&lt;/sup&gt; discussing the algorithmic approaches to identify and manage the infeasibility situation in MIPs and IPs.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Guieu, Olivier, and John W. Chinneck. &quot;&lt;a href=&quot;https://pdfs.semanticscholar.org/254b/ef29783f83ddfe9146f02452e0f22c248e1c.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Analyzing infeasible mixed-integer and integer linear programs.&lt;/a&gt;&quot; INFORMS Journal on Computing 11.1 (1999): 63-77. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-08-09T13:40:26.567" LastActivityDate="2019-08-09T13:40:26.567" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1220" PostTypeId="1" AcceptedAnswerId="1237" CreationDate="2019-08-08T21:38:13.527" Score="15" ViewCount="187" Body="&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median problem is NP-hard, so its LP relaxation does not naturally have all-integer solutions. However, it very often does; in fact, it can be hard to find an instance for which the LP relaxation solution is &lt;em&gt;not&lt;/em&gt; integer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only examples that I know of for which the LP solution is non-integer use &lt;em&gt;asymmetric&lt;/em&gt; distances (or, equivalently, directed graphs)—for example, the examples by &lt;a href=&quot;https://doi.org/10.1111/j.1538-4632.1970.tb00142.x&quot; rel=&quot;noreferrer&quot;&gt;ReVelle and Swain (1970)&lt;/a&gt; and &lt;a href=&quot;https://doi.org/10.1016/j.disopt.2010.12.002&quot; rel=&quot;noreferrer&quot;&gt;Baïou and Barahona (2011)&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a symmetric, undirected &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median instance for which the optimal solution to the LP relaxation is not integer?&lt;/strong&gt; I'm especially looking for small examples (say, 5 nodes).&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-09-30T03:04:42.697" Title="Symmetric undirected $p$-median instance with fractional LP solution?" Tags="|mixed-integer-programming|facility-location|p-median|lp-relaxation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1221" PostTypeId="2" ParentId="1215" CreationDate="2019-08-08T21:48:37.130" Score="15" Body="&lt;p&gt;CPLEX offers the conflict refiner for this purpose:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A conflict is a set of mutually contradictory constraints and bounds within a model. Given an infeasible model, IBM ILOG CPLEX can identify conflicting constraints and bounds within it. CPLEX refines an infeasible model by examining elements that can be removed from the conflict to arrive at a minimal conflict. A conflict smaller than the full model may make it easier for the user to analyze the source of infeasibilities in the original model.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Taken from the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/infeas_unbd/conflict_refiner/01_ref_confl_title_synopsis.html&quot; rel=&quot;noreferrer&quot;&gt;CPLEX documentation&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-08-08T21:48:37.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1222" PostTypeId="2" ParentId="1215" CreationDate="2019-08-08T22:05:05.290" Score="10" Body="&lt;p&gt;Related to &lt;a href=&quot;https://or.stackexchange.com/a/1221/196&quot;&gt;@Kevin Dalmeijer's answer&lt;/a&gt;, Gurobi offers Irreducible Inconsistent Subsystem functionality via &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/py_model_computeiis.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;Model.computeIIS()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Compute an Irreducible Inconsistent Subsystem (IIS). An IIS is a subset of the constraints and variable bounds with the following properties:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;the subsystem represented by the IIS is infeasible, and&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if any of the constraints or bounds of the IIS is removed, the subsystem becomes feasible.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note that an infeasible model may have multiple IISs. The one returned by Gurobi is not necessarily the one with minimum cardinality; there may exist others with fewer constraints or bounds.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="196" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-08-08T22:05:05.290" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1223" PostTypeId="2" ParentId="1215" CreationDate="2019-08-08T22:40:39.633" Score="11" Body="&lt;p&gt;On top of getting IIS from the solver and using slack variables (as suggested by other answers), one more thing that you can do for debugging purposes is to &lt;strong&gt;fix your variables to a known feasible solution&lt;/strong&gt; and see what is reported from your model. Doing that, you can figure out what has happened to make the problem infeasible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, assume you have &lt;span class=&quot;math-container&quot;&gt;$x_1 +x_2 = 10$&lt;/span&gt; constraint and a known feasible solution is &lt;span class=&quot;math-container&quot;&gt;$x_1 = 6, x_2 = 2$&lt;/span&gt;, you can see the infeasibility and the constraint that throws the infeasibility.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-08-08T22:40:39.633" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1224" PostTypeId="2" ParentId="1210" CreationDate="2019-08-09T00:53:59.533" Score="4" Body="&lt;p&gt;How about &lt;a href=&quot;https://www.sigmetrics.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ACM SIGMETRICS&lt;/a&gt;?  Or publications of the &lt;a href=&quot;https://www.cmg.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Computer Measurement Group&lt;/a&gt;?  Both have lots of work using modeling,  queuing, and simulation.&lt;/p&gt;&#xA;" OwnerUserId="1132" LastEditorUserId="196" LastEditDate="2019-08-09T06:31:54.990" LastActivityDate="2019-08-09T06:31:54.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1225" PostTypeId="2" ParentId="483" CreationDate="2019-08-09T07:16:41.683" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a variant of integer programs for which Gomory's cutting plane algorithm demonstrably takes a superpolynomial number of iterations?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Definitions:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;&lt;strong&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Time_complexity#Superpolynomial_time&quot; rel=&quot;nofollow noreferrer&quot;&gt;Superpolynomial time&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;&#xA;  An algorithm is said to take superpolynomial time if &lt;span class=&quot;math-container&quot;&gt;$T(n)$&lt;/span&gt; is not bounded above by any polynomial. Using little omega notation, it is &lt;span class=&quot;math-container&quot;&gt;$\omega (n^c)$&lt;/span&gt; time for all constants &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the input parameter, typically the number of bits in the input. For example, an algorithm that runs for &lt;strong&gt;&lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; steps on an input of size &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;&lt;/strong&gt; requires superpolynomial time (more specifically, &lt;strong&gt;exponential time&lt;/strong&gt;).&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;&lt;strong&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Time_complexity#Exponential_time&quot; rel=&quot;nofollow noreferrer&quot;&gt;Exponential time&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;&#xA;  An algorithm is said to be exponential time, if &lt;span class=&quot;math-container&quot;&gt;$T(n)$&lt;/span&gt; is upper bounded by &lt;span class=&quot;math-container&quot;&gt;$2^{poly(n)}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$poly(n)$&lt;/span&gt; is some polynomial in &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. More formally, an algorithm is exponential time if &lt;span class=&quot;math-container&quot;&gt;$T(n)$&lt;/span&gt; is bounded by &lt;span class=&quot;math-container&quot;&gt;$O(2^{{n}^{k}})$&lt;/span&gt; for some constant &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. Problems which admit exponential time algorithms on a deterministic Turing machine form the complexity class known as &lt;a href=&quot;https://en.wikipedia.org/wiki/EXP&quot; rel=&quot;nofollow noreferrer&quot;&gt;EXP&lt;/a&gt;.&quot; and &quot;The exponential time hypothesis implies &lt;a href=&quot;https://en.wikipedia.org/wiki/P_%E2%89%A0_NP&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$P \ne NP$&lt;/span&gt;&lt;/a&gt;.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In &quot;&lt;a href=&quot;https://link.springer.com/chapter/10.1007/3-540-47867-1_11&quot; rel=&quot;nofollow noreferrer&quot;&gt;An Exponential Lower Bound on the Length of Some Classes of Branch-and-Cut Proofs&lt;/a&gt;&quot; (May 21 2002), by &lt;a href=&quot;https://researcher.watson.ibm.com/researcher/view_person_subpage.php?id=2717&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sanjeeb Dash&lt;/a&gt; (IBM), preliminary version in: IBM Research Report &lt;a href=&quot;https://researcher.watson.ibm.com/researcher/files/us-sanjeebd/RC22575.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;RC22575&lt;/a&gt; (.PDF), Sept 2002:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;&lt;strong&gt;Abstract&lt;/strong&gt;&lt;br&gt;&#xA;  Branch-and-cut methods are among the most important techniques for solving integer programming problems. They can also be used to prove that all solutions of an integer program satisfy a given linear inequality. We examine the complexity of branch-and-cut proofs in the context of 0-1 integer programs. We prove an exponential lower bound on the length of branch-and-cut proofs which use 0-1 branching and lift-and-project cuts (called simple disjunctive cuts by some authors), Gomory-Chvátal cuts, and cuts arising from the &lt;span class=&quot;math-container&quot;&gt;$N_0$&lt;/span&gt; matrix-cut operator of Lovász and Schrijver. A consequence of the lower-bound result in this paper is that branch-and-cut methods of the type described above have &lt;strong&gt;exponential&lt;/strong&gt; running time in the worst case.&quot;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On page 10:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;&lt;strong&gt;4 Interpolation and Cutting-Plane Proofs&lt;/strong&gt;&lt;br&gt;&#xA;  The problem of determining if a system of linear inequalities &lt;span class=&quot;math-container&quot;&gt;$Ax \le b$&lt;/span&gt; has a 0-1 solution is NP-complete. Therefore, every algorithm which finds a 0-1 solution, or provides a certificate that no 0-1 solution exists, is expected to have &lt;strong&gt;super-polynomial time&lt;/strong&gt; complexity. In fact, many believe that polynomial-size certificates of infeasibility (in the encoding size of &lt;span class=&quot;math-container&quot;&gt;$A, b$&lt;/span&gt;) do not always exist; this is the same as saying that &lt;span class=&quot;math-container&quot;&gt;$NP \ne coNP$&lt;/span&gt;. This question is far from being solved. However there has been progress in studying various restricted classes of certificates – formally, proofs in&#xA;  some proof system – and in showing exponential worst case complexity (size) for some classes. Achieving this goal for all proof systems would show that &lt;span class=&quot;math-container&quot;&gt;$NP = coNP$&lt;/span&gt;, and therefore that &lt;span class=&quot;math-container&quot;&gt;$P \ne NP$&lt;/span&gt;. (Note that exponential length branch-and-cut proofs have exponential size; we will focus on the lengths of such proofs).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;We will be interested only in infeasible 0-1 integer programs; we will use the phrase “integer program” to mean a problem without an objective function where we want to find 0-1 solutions of linear inequality systems.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;More recently, &quot;&lt;a href=&quot;https://arxiv.org/abs/1805.02782&quot; rel=&quot;nofollow noreferrer&quot;&gt;Theoretical challenges towards cutting-plane selection&lt;/a&gt;&quot; (May 7 2018), by Santanu S. Dey and Marco Molinaro, on page 4:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Finite Cutting-plane Algorithms. One natural question is: can we solve an MILP in finite time using solely cuts from a given family without branching or any other operation? Gomory gave the first finitely convergent cutting-plane algorithm for pure integer programs [131], using CG cuts. There have been very few results since then on finite cutting-plane algorithms, see [181] and references therein. See [68] for a polynomial-time cutting-plane algorithm for matching, [69] for a finite cutting-plane algorithm for bounded MILPs, and [104] for a finite cutting-plane algorithm for general MILPs. There are also lower bounds on the length of cutting-plane proofs (length of sequence of cuts needed to prove optimality or infeasibility) [73]. For example, generalizing previous work of Pudlák [189], Dash [98] presents &lt;strong&gt;exponential lower bounds&lt;/strong&gt; for proofs via branch-and-cut procedures that use L&amp;amp;P and &lt;strong&gt;CG cuts&lt;/strong&gt;.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For a practical example read: &quot;Applied Integer Programming - Modeling and Solution&quot;, by Der-san Chen, Robert G. Batson, and Yu Dang&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Page: 120&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;The difficulty of cutting stock problem is that the number of possible cutting patterns n is usually too huge to enumerate them all. For example, with a roll of width 20 in. and demand for 40 different widths ranging from 20-80 in., the number of cutting patterns can exceed 100 million (Gilmore and Gomory, 1961). The number of cutting patterns is multiplied when there are multiple standard widths to be cut from. Therefore, the IP model of a cutting stock problem is rarely solved exactly. In practice, its LP relaxation is solved by using Dantzig-Wolfe decomposition principle through a column generation technique.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But generally one would prefer a Lagrangian over Dantzig-Wolfe for column generation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further reading:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.semanticscholar.org/paper/On-the-augmented-Lagrangian-dual-for-integer-Boland-Eberhard/5a7f413fd4e55a18810d20773acd3f35d7ff2390&quot; rel=&quot;nofollow noreferrer&quot;&gt;On the augmented Lagrangian dual for integer programming&lt;/a&gt;&quot;, by Natashia Boland, Andrew C. Eberhard. Published in Math. Program. 2015, DOI:10.1007/s10107-014-0763-3&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Page 1:&lt;br&gt;&#xA;  &quot;... for nonlinear, nonsmooth optimisation there have been a number of strong duality schemes proposed in the last 10 years. The augmented Lagrangian dual has been of particular interest in this area. In convex optimisation, algorithms to solve the augmented Lagrangian dual were found to be more robust, and converged under less stringent assumptions, than their standard Lagrangian dual predecessors [29]. Early application of the augmented Lagrangian in IP [30] was aimed at producing better dual bounds at the root node of the branch-and-bound tree. ... One of the challenges for applying the augmented dual in IP computational methods is that the&#xA;  augmented Lagrangian term destroys the natural separability properties of the Lagrangian dual. However this can be overcome by the use of an approach known as the alternating direction method of multipliers [4, 9], which is enjoying recent attention in the literature. Thus the augmented Lagrangian dual for IP warrants further attention. In this paper, we contribute to the theory of the augmented Lagrangian dual for IP so as to provide insight into how it obtains better bounds than the standard Lagrangian dual.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Wikipedia - Augmented Lagrangian method (&lt;a href=&quot;https://en.wikipedia.org/wiki/Augmented_Lagrangian_method#Software&quot; rel=&quot;nofollow noreferrer&quot;&gt;Software&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.nowpublishers.com/article/Details/MAL-016&quot; rel=&quot;nofollow noreferrer&quot;&gt;Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers&lt;/a&gt;&quot;, (Jul 26 2011), by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato and Jonathan Eckstein&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://arxiv.org/abs/1709.05747&quot; rel=&quot;nofollow noreferrer&quot;&gt;Douglas-Rachford splitting and ADMM for nonconvex optimization: tight convergence results&lt;/a&gt;&quot;, (Nov 9 2018), by Andreas Themelis, Panagiotis Patrinos&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;COIN|OR &lt;a href=&quot;https://projects.coin-or.org/Dip&quot; rel=&quot;nofollow noreferrer&quot;&gt;DIP&lt;/a&gt; - Discrete Integer Programming software&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-08-10T03:25:39.730" LastActivityDate="2019-08-10T03:25:39.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1226" PostTypeId="2" ParentId="1214" CreationDate="2019-08-09T07:27:46.547" Score="5" Body="&lt;p&gt;If you use the SCIP shell, you can simply interrupt the solving process with Ctrl+C, then use the &lt;code&gt;newstart&lt;/code&gt; command the clear the tree and start solving again with &lt;code&gt;optimize&lt;/code&gt;. This will keep not only the solutions found so far, but might also migrate some cuts found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of watching the process and interrupting manually, you can also set both limits on the runtime and the gap, of course (&lt;code&gt;set limits/time 600&lt;/code&gt; and &lt;code&gt;set limits/gap 0.01&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using SCIP linked to another program, the same things should still work, but you will need to call the C API functions, then.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-08-09T07:27:46.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1227" PostTypeId="5" CreationDate="2019-08-09T13:12:47.167" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-08-09T13:12:47.167" LastActivityDate="2019-08-09T13:12:47.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1228" PostTypeId="4" CreationDate="2019-08-09T13:12:47.167" Score="0" Body="For questions about dynamic programming, a mathematical optimization technique where the optimal solution to the problem is found by breaking it down to simpler sub-problems and solved recursively." OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-08-09T13:54:43.940" LastActivityDate="2019-08-09T13:54:43.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1229" PostTypeId="5" CreationDate="2019-08-09T13:18:25.417" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-08-09T13:18:25.417" LastActivityDate="2019-08-09T13:18:25.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1230" PostTypeId="4" CreationDate="2019-08-09T13:18:25.417" Score="0" Body="For questions about the use of Simulated Annealing (SA) for solving combinatorial problems. SA is a probabilistic metaheuristic that can approximate the global optimum in a large (and usually discrete) search space." OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-08-09T13:54:36.753" LastActivityDate="2019-08-09T13:54:36.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1231" PostTypeId="2" ParentId="1215" CreationDate="2019-08-09T13:25:24.957" Score="17" Body="&lt;p&gt;Some methods I've used - most of these have already been discussed in other answers, but I wanted to elaborate a little on these. Ordered roughly in the order that I would try to apply these, which is of course influenced by the kind of problems that I work on.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;1. Confirm specification of constraints by testing against a &quot;known feasible&quot; solution (as mentioned by @EhsanK).&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In my own experience, and in almost every OR project I've heard about from other practitioners, it's very unusual that clients will be able to specify the rules perfectly on their first attempt. It's just a very difficult thing to do, especially for people who aren't familiar with OR programming. Sometimes you'll find that rules presented as hard constraints are actually soft constraints, or have exceptions that haven't been included in the specs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your client is able to provide an example of what they consider to be a satisfactory solution, testing it against your understanding of the rules is a very effective way to discover misunderstandings and mis-specifications. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As well as being pretty straightforward to code (assuming that your client can provide an example of a feasible solution), this approach is often easy to communicate to clients. If I produce an IIS and discover that the problem lies &lt;em&gt;somewhere&lt;/em&gt; in this set of &lt;span class=&quot;math-container&quot;&gt;$500$&lt;/span&gt; constraints, that will be very hard for clients to interpret. If I can say &quot;hi, this example solution that you gave me breaks this rule that you said I needed to include, what gives?&quot; that's a lot easier for the client to understand and address.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;2. Build up the model one rule at a time and test as often as possible.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is a good idea in almost any area of programming. The faster you detect new bugs, the easier it is to figure out the causes.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;3. Eyeball infeasibility diagnostics and look for obvious matches in inputs.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I mostly work via AMPL. When it detects infeasibility in presolve, it will usually give information on the size of that infeasibility - &quot;upper bound &lt;span class=&quot;math-container&quot;&gt;$-67$&lt;/span&gt;, lower bound &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;&quot; sort of thing. Quite often I can find the cause of the infeasibility by scanning the inputs for values that match the size of that gap; for instance, I might have a value that has been constrained to be non-positive but also to be equal to &lt;span class=&quot;math-container&quot;&gt;$67$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is by no means a foolproof approach, but it's quick and easy to do, so I'll often give it a try before going to more systematic methods.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;4. Ersatz/manual IIS methods&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Experiment with switching off constraints selectively and attempting solves, to figure out which rules are incompatible with one another. Again, this is not as systematic as using proper IIS methods, but it's often easier to do/interpret, and it can be used with solvers that don't have IIS capability.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;5. Automated IIS methods (as mentioned by @dxb and @KevinDalmeijer).&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Some solvers have the capability to automatically identify a set of conflicting constraints. This is a useful capability but I tend to de-prioritise it because much of my experience has been with problems where the IIS's tend to be large and tedious to interpret, so I like to try other methods first. YMMV.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I do use this approach, if I have a large IIS, I try to look for commonalities between the constraints - for instance, if my variables are indexed &lt;span class=&quot;math-container&quot;&gt;$i,j,k$&lt;/span&gt; and the IIS constraints have different values for &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; but all have the same &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;-value, that's probably where I want to look first. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: some products can get in the way of IIS methods. For instance, when I use Gurobi via AMPL, it's possible that AMPL presolve will detect an infeasibility before it ever passes the problem to Gurobi. In this case, I can't use Gurobi's IIS capability because Gurobi never sees the problem. The solution here is to switch off presolve.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;6. Slack methods (as mentioned by @MatteoFischetti).&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;One thing I'd add to Matteo's advice is that the shape of the penalty function will affect the information that you get from this approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I have a system of constraints like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}C_1&amp;amp;: x \le 5\\C_2&amp;amp;: y \le 5\\C_3&amp;amp;: x+y \ge 13\\&amp;amp;\cdots\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If my penalty function is linear, then most likely the solution I get will only use slack from one of these three constraints, e.g. &lt;span class=&quot;math-container&quot;&gt;$x=8$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y=5$&lt;/span&gt;. Looking at the results, I can then see that &lt;span class=&quot;math-container&quot;&gt;$C_1$&lt;/span&gt; is involved in the infeasibility, but I can't easily tell what else is involved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If my penalty function is quadratic, OTOH, then I will usually get a solution that uses slack from all constraints involved in the infeasibility. In this case, if I weight all three slack variables equally - and if I switch off the non-penalty components of the objective function - I will get the solution &lt;span class=&quot;math-container&quot;&gt;$x=6$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y=6$&lt;/span&gt;, which violates each of the constraints by exactly 1. This makes it much easier to see all the constraints involved in the infeasibility by scanning the slack values. It can even help to identify and distinguish multiple groups of incompatible constraints in a single run - e.g. if I have three constraints that end up with a slack value of &lt;span class=&quot;math-container&quot;&gt;$1.33333$&lt;/span&gt; and two others that end up with slack of &lt;span class=&quot;math-container&quot;&gt;$2.5$&lt;/span&gt;, these probably form two separate groups of incompatible constraints, something that I can't identify from an IIS method without multiple runs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously this requires that you have a solver that can handle quadratic objectives, or alternately that you construct a piecewise linear approximation to a quadratic penalty function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be quite a nice method; I only put it below the others because it's a little bit more work to program.&lt;/p&gt;&#xA;" OwnerUserId="546" LastEditorUserId="546" LastEditDate="2019-08-11T09:40:20.437" LastActivityDate="2019-08-11T09:40:20.437" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1232" PostTypeId="1" AcceptedAnswerId="1236" CreationDate="2019-08-09T14:08:26.440" Score="10" ViewCount="474" Body="&lt;p&gt;In a simple convex optimisation problem, the standard form &lt;a href=&quot;https://en.wikipedia.org/wiki/Convex_optimization&quot; rel=&quot;noreferrer&quot;&gt;is given by&lt;/a&gt; &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_{\bf x}&amp;amp;\qquad f({\bf x})\\\text{s.t.}&amp;amp;\qquad g_i({\bf x})\le 0,\quad i=1,\cdots,m\\&amp;amp;\qquad h_j({\bf x})=0,\quad j=1,\cdots,p\end{align}&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;${\bf x}\in\Bbb R^n$&lt;/span&gt; being the vector of variables to be optimised.&lt;/p&gt;&#xA;&lt;p&gt;By changing the RHS of the constraints, we obtain a geometric optimisation problem, whose standard form &lt;a href=&quot;https://en.wikipedia.org/wiki/Geometric_programming&quot; rel=&quot;noreferrer&quot;&gt;is given by&lt;/a&gt; &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_{\bf x}&amp;amp;\qquad f({\bf x})\\\text{s.t.}&amp;amp;\qquad g_i({\bf x})\le 1,\quad i=1,\cdots,m\\&amp;amp;\qquad h_j({\bf x})=1,\quad j=1,\cdots,p\end{align}&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;${\bf x}\in\Bbb R^n$&lt;/span&gt; being the vector of variables to be optimised. This has the additional restrictions that &lt;span class=&quot;math-container&quot;&gt;$f,g_i$&lt;/span&gt; are &lt;a href=&quot;https://en.wikipedia.org/wiki/Posynomials&quot; rel=&quot;noreferrer&quot;&gt;posynomials&lt;/a&gt; and &lt;span class=&quot;math-container&quot;&gt;$h_j$&lt;/span&gt; are simple monomials.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Questions&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Why is it so common to have 1 as the RHS of the constraints? That is, is there anything significant/geometrically convenient about it or is it by convention? For example, in a simple LP, the constraint is of the form &lt;span class=&quot;math-container&quot;&gt;$A{\bf x}\le \bf b$&lt;/span&gt; and not usually written as &lt;span class=&quot;math-container&quot;&gt;$A{\bf x}{\bf b}^{-1}\le 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Suppose that we replace 1 by the more general set of constraints &lt;span class=&quot;math-container&quot;&gt;\begin{cases}g_i({\bf x})\le a_i,\quad i=1,\cdots,m\\h_j({\bf x})=b_j,\quad j=1,\cdots,p.\end{cases}&lt;/span&gt; What is the terminology for this generalised problem?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="123" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-08-10T06:39:45.873" Title="Geometric programming: Why are the constraints defined to be less than/equal to 1?" Tags="|terminology|geometric-programming|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1233" PostTypeId="2" ParentId="1232" CreationDate="2019-08-09T14:23:38.353" Score="8" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\log 1 = 0$&lt;/span&gt; could explain that: take &lt;span class=&quot;math-container&quot;&gt;$\log$&lt;/span&gt; of both sides.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I have now looked and found this in &lt;a href=&quot;https://web.stanford.edu/~boyd/papers/pdf/gp_tutorial.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;A tutorial on geometric programming&quot;, Stephen Boyd · Seung-Jean Kim · Lieven Vandenberghe · Arash Hassibi&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look on p. 73 equation (6), and the paragraph which precedes it:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The conversion of a GP to a convex problem is based on a logarithmic change of variables, and a logarithmic transformation of the objective and constraint functions. In place of the original variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, we use their logarithms, &lt;span class=&quot;math-container&quot;&gt;$y_i = \log x_i$&lt;/span&gt; (so &lt;span class=&quot;math-container&quot;&gt;$x_i = e^{y_i}$&lt;/span&gt;). Instead of minimizing the objective &lt;span class=&quot;math-container&quot;&gt;$f_0$&lt;/span&gt;, we minimize its logarithm &lt;span class=&quot;math-container&quot;&gt;$\log f_0$&lt;/span&gt;. We replace the inequality constraints &lt;span class=&quot;math-container&quot;&gt;$f_i \le 1$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\log f_i \le 0$&lt;/span&gt;, and the equality constraints &lt;span class=&quot;math-container&quot;&gt;$g_i = 1$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\log g_i = 0$&lt;/span&gt;. This results in the problem &lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{minimize}&amp;amp;\qquad f_0(e^y)\\\text{subject to}&amp;amp;\qquad\log f_i(e^y)\le 0,\quad i=1,\cdots,m\\&amp;amp;\qquad\log g_i(e^y)=0,\quad i=1,\cdots,p\tag6\end{align}&lt;/span&gt; with variables &lt;span class=&quot;math-container&quot;&gt;$y=(y_1,\cdots,y_n)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As for the RHS not being 1, that is still basically a Geometric Program, which can be converted to standard form by dividing both the LHS and RHS by the RHS. That is addressed in the first paragraph of section 2.3 on p. 71 of the link:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Several extensions are readily handled. If &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a posynomial and &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is a monomial, then the constraint &lt;span class=&quot;math-container&quot;&gt;$f(x) \le g(x)$&lt;/span&gt; can be handled by expressing it as &lt;span class=&quot;math-container&quot;&gt;$f(x)/g(x) \le 1$&lt;/span&gt; (since &lt;span class=&quot;math-container&quot;&gt;$f/g$&lt;/span&gt; is posynomial). This includes as a special case a constraint of the form &lt;span class=&quot;math-container&quot;&gt;$f(x) \le a$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is posynomial and &lt;span class=&quot;math-container&quot;&gt;$a &amp;gt; 0$&lt;/span&gt;. In a similar way if &lt;span class=&quot;math-container&quot;&gt;$g_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_2$&lt;/span&gt; are both monomial functions, then we can handle the equality constraint &lt;span class=&quot;math-container&quot;&gt;$g_1(x) = g_2(x)$&lt;/span&gt; by expressing it as &lt;span class=&quot;math-container&quot;&gt;$g_1(x)/g_2(x) = 1$&lt;/span&gt; (since &lt;span class=&quot;math-container&quot;&gt;$g_1/g_2$&lt;/span&gt; is monomial).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2019-08-10T06:39:45.873" LastActivityDate="2019-08-10T06:39:45.873" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1235" PostTypeId="1" CreationDate="2019-08-09T15:19:59.260" Score="10" ViewCount="573" Body="&lt;p&gt;I've been using CPLEX on the NEOS server, via Pyomo, to solve a binary program I'm working on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;NEOS is amazing, but the documentation is somewhat lacking on the Pyomo side, so I haven't been able to find out how I can access the solve time for an optimisation run. If I use a local solver on my machine (CBC) I can access the solve time in the results, and I can see it from the solver output, neither of which I get with CPLEX on NEOS. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="843" LastActivityDate="2019-09-26T17:26:10.607" Title="How to get solver time from CPLEX when using the NEOS server through Pyomo?" Tags="|combinatorial-optimization|cplex|pyomo|neos|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1236" PostTypeId="2" ParentId="1232" CreationDate="2019-08-10T00:13:00.297" Score="12" Body="&lt;p&gt;Some of the reasons are convention (and the reason &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; is the convention is that after substituting &lt;span class=&quot;math-container&quot;&gt;$x_i = e^{y_i}$&lt;/span&gt; and taking logs of both sides, we get a convex program where all right-hand sides are &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;). But the primary &lt;em&gt;practical&lt;/em&gt; reason to put the constraints in a standard form - that is, &lt;span class=&quot;math-container&quot;&gt;$g_i(\mathbf x) \le 1$&lt;/span&gt; - is that then the dual of a geometric program is slightly more convenient to state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm going to be lazy and link to &lt;a href=&quot;https://faculty.math.illinois.edu/~mlavrov/docs/484-spring-2019/ch5lec9.pdf&quot; rel=&quot;noreferrer&quot;&gt;my own notes&lt;/a&gt; on the geometric programming dual. The dual geometric program is described on the first page. The description is, uh, kind of long. The example at the bottom of page &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; might be more helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a dual variable &lt;span class=&quot;math-container&quot;&gt;$\delta_i$&lt;/span&gt; for each term &lt;span class=&quot;math-container&quot;&gt;$C_i x_1^{\alpha_{i1}} x_2^{\alpha_{i2}} \dotsm x_m^{\alpha_{im}}$&lt;/span&gt; that appears in the geometric program, &lt;em&gt;wherever&lt;/em&gt; it appears: in the objective function, or in one of the constraints. The key point to highlight for your question is that, provided your geometric program is in standard form, the dual objective function has a &lt;span class=&quot;math-container&quot;&gt;$\left(\frac{C_i}{\delta_i}\right)^{\delta_i}$&lt;/span&gt; factor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we're working with a geometric program that's not in standard form, and the &lt;span class=&quot;math-container&quot;&gt;$i^{\text{th}}$&lt;/span&gt; term comes from a constraint with right-hand side &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, then this factor should look like &lt;span class=&quot;math-container&quot;&gt;$\left(\frac{C_i/B}{\delta_i}\right)^{\delta_i}$&lt;/span&gt; instead. Effectively, we are forced to divide through by &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; before we can take the dual.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I would still consider programs that have the more general constraints of the form &lt;span class=&quot;math-container&quot;&gt;$\text{posynomial} \le B$&lt;/span&gt; (for &lt;span class=&quot;math-container&quot;&gt;$B&amp;gt;0$&lt;/span&gt;) to be geometric programs. They're not in standard form, but depending on what you're about to do with them, you may not care.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, we could even allow the right-hand side to be any monomial with a positive coefficient. For example, the constraint &lt;span class=&quot;math-container&quot;&gt;$$x_1^2 + x_2^2 \le x_3^2$$&lt;/span&gt; is not any harder to deal with. The reason, of course, is that we can divide through by such a monomial to get a posynomial constraint &lt;span class=&quot;math-container&quot;&gt;$$x_1^2 x_3^{-2} + x_2^2 x_3^{-2} \le 1$$&lt;/span&gt; in standard form. I would still call programs with such constraints geometric programs, though somewhat less neatly stated ones.&lt;/p&gt;&#xA;" OwnerUserId="1139" LastActivityDate="2019-08-10T00:13:00.297" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1237" PostTypeId="2" ParentId="1220" CreationDate="2019-08-10T01:45:21.383" Score="11" Body="&lt;p&gt;I think I've found an instance with four nodes and &lt;span class=&quot;math-container&quot;&gt;$p = 2$&lt;/span&gt; via brute force (a lot of randomized instances). I've attached my Python script as well. I relaxed the &lt;a href=&quot;https://pdfs.semanticscholar.org/2094/882d425fe9b3f668eaafbcf8ac0bba478b5f.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Daskin and Maass (2015)&lt;/a&gt; formulation and assumed &lt;span class=&quot;math-container&quot;&gt;$I = J$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nodes: &lt;span class=&quot;math-container&quot;&gt;$I = J = \{1, 2, 3, 4\}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Demands: &lt;span class=&quot;math-container&quot;&gt;$d = (75, 34, 40, 40)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Costs (or distances):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c = &#xA;    \begin{bmatrix}&#xA;    0  &amp;amp; 39 &amp;amp; 95 &amp;amp; 7  \\&#xA;    39 &amp;amp; 0  &amp;amp; 83 &amp;amp; 18 \\&#xA;    95 &amp;amp; 83 &amp;amp; 0  &amp;amp; 16 \\&#xA;     7 &amp;amp; 18 &amp;amp; 16 &amp;amp; 0\\    &#xA;    \end{bmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gurobi gives the following solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ y = (0.5, 0.5, 0.5, 0.5 )$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x = &#xA;    \begin{bmatrix}&#xA;    0.5  &amp;amp; 0 &amp;amp; 0 &amp;amp; 0.5  \\&#xA;    0 &amp;amp; 0.5  &amp;amp; 0 &amp;amp; 0 \\&#xA;    0 &amp;amp; 0 &amp;amp; 0.5  &amp;amp; 0 \\&#xA;    0.5 &amp;amp; 0.5 &amp;amp; 0.5 &amp;amp; 0.5\\    &#xA;    \end{bmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The optimal demand-weighted cost is &lt;span class=&quot;math-container&quot;&gt;$1028.5$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;# Edited to add code highlighting&#xA;from gurobipy import *&#xA;import numpy as np&#xA;from random import *&#xA;&#xA;## DEFINE MODEL ###&#xA;&#xA;def p_median_relaxed(I, J, c, d, p):&#xA;    model = Model(&quot;relaxed&quot;)&#xA;&#xA;    model.setParam('OutputFlag', 0) &#xA;&#xA;    ######### VARIABLES AND BOUNDS #########&#xA;    x = {} &#xA;    y = {} # the (binary) facility location variable being relaxed&#xA;&#xA;    for i in I:&#xA;        for j in J:&#xA;            x[i, j] = model.addVar(vtype = GRB.CONTINUOUS, lb = 0)&#xA;&#xA;    for i in I:&#xA;        y[i] = model.addVar(vtype = GRB.CONTINUOUS, lb = 0, ub = 1)&#xA;&#xA;    ######### CONSTRAINTS #########&#xA;&#xA;    # (2.2)&#xA;    for j in J:&#xA;        model.addConstr(quicksum(x[i, j] for i in I) == 1, name = &quot;c1_{}&quot;.format(j))&#xA;&#xA;    # (2.3)&#xA;    model.addConstr(quicksum(y[i] for i in I) == p, name = &quot;c2&quot;)&#xA;&#xA;    # (2.4)&#xA;    for i in I:&#xA;        for j in J:&#xA;            model.addConstr(x[i, j] - y[i] &amp;lt;= 0, name = &quot;c3_{}_{}&quot;.format(i, j))&#xA;&#xA;    ######### OBJECTIVE ##########&#xA;&#xA;    model.setObjective(quicksum((d[j] * c[i, j] * x[i, j]) for i in I for j in J), GRB.MINIMIZE)&#xA;&#xA;    ############ SOLVE ###########&#xA;&#xA;    model.optimize()&#xA;&#xA;    ### STORE AND RETURN SOLUTION ###&#xA;&#xA;    x_val = {}&#xA;    y_val = {}&#xA;&#xA;    for i in I:&#xA;        y_val[i] = y[i].x&#xA;&#xA;        for j in J:&#xA;            x_val[i, j] = x[i, j].x&#xA;&#xA;    return(x_val, y_val, model.objVal)&#xA;&#xA;&#xA;## CREATE RANDOMIZED INSTANCES AND SOLVE ##&#xA;&#xA;siz = 4 # size of network&#xA;&#xA;I = range(1, 5)&#xA;J = range(1, 5)&#xA;c = {}&#xA;d = {}&#xA;&#xA;found_flag = 0&#xA;&#xA;for ii in range(1000):&#xA;    p = randrange(2, siz)&#xA;&#xA;    for j in J:&#xA;        d[j] = randrange(0, 100, 1)&#xA;&#xA;        for i in I:&#xA;&#xA;            if i == j:&#xA;                c[i, j] = 0&#xA;            elif i &amp;lt; j:&#xA;                c[i, j] = randrange(0, 100, 1)&#xA;&#xA;    for i in I:&#xA;        for j in J:&#xA;            if i &amp;gt; j:&#xA;                c[i, j] = c[j, i]&#xA;&#xA;    (x_val, y_val, cost) = p_median_relaxed(I, J, c, d, p)&#xA;&#xA;    for i in I:&#xA;        if y_val[i] &amp;lt;= 0.999:&#xA;            if y_val[i] &amp;gt;= 0.001:&#xA;                print(x_val)&#xA;                print(y_val)&#xA;                print(c)&#xA;                print(d)&#xA;                print(p)&#xA;                print(cost)&#xA;                print(' ')&#xA;&#xA;                found_flag = 1&#xA;                break&#xA;&#xA;    if found_flag == 1:&#xA;        break&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I put this together quickly, so please let me know if I've made any errors or incorrect assumptions.&lt;/p&gt;&#xA;" OwnerUserId="196" LastEditorUserId="196" LastEditDate="2019-09-30T03:04:42.697" LastActivityDate="2019-09-30T03:04:42.697" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1238" PostTypeId="1" CreationDate="2019-08-10T06:43:10.343" Score="12" ViewCount="135" Body="&lt;p&gt;In numerical tests of optimization algorithms, one often reads &quot;We used a XY computer with X GB RAM for the experiments&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually, when I want to compare my results with theirs, I do not have an XY computer, but a YZ computer. And rerunning the tests of others is often difficult because I do not have the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder whether one of the large cloud providers allows you to configure a virtual server in a way that others could easily do the same. &lt;/p&gt;&#xA;" OwnerUserId="50" LastActivityDate="2019-08-11T09:09:57.730" Title="Run repeatable numerical tests in the cloud" Tags="|optimization|experimental-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1239" PostTypeId="5" CreationDate="2019-08-10T07:06:36.880" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-08-10T07:06:36.880" LastActivityDate="2019-08-10T07:06:36.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1240" PostTypeId="4" CreationDate="2019-08-10T07:06:36.880" Score="0" Body="For questions related to problems that optimize a posynomial subject to posynomial and monomial constraints." OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-08-10T14:56:52.087" LastActivityDate="2019-08-10T14:56:52.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1241" PostTypeId="1" AcceptedAnswerId="1243" CreationDate="2019-08-10T10:37:13.153" Score="12" ViewCount="5475" Body="&lt;p&gt;I was trying to solve a moderate scheduling model using an open-source solver. I did two different ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A) using pure branch and bound algorithm (disable all options).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;B) using the default setting of the solver option (activating pre-solving, separating and heuristics).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I'm using (A) the results are better than using (B).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible that the performance of a pure branch and bound algorithm be better than branch-cut-heuristic?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-08-12T07:33:31.650" Title="Performance of a branch and bound algorithm VS branch-cut-heuristics" Tags="|optimization|algorithms|branch-and-cut|branch-and-bound|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1242" PostTypeId="2" ParentId="1241" CreationDate="2019-08-10T11:57:44.103" Score="5" Body="&lt;p&gt;If all of the unknown variables are required to be integers, then the problem is called an integer programming (IP) problem, if only some of the unknown variables are required to be integers, then the problem is called a mixed integer programming (MIP) problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Cutting-plane_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;cutting-plane method&lt;/a&gt; is an optimization that iteratively refines a feasible set and is commonly used to find integer solutions to mixed integer linear programming (MILP) problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Branch and cut is a method of combinatorial optimization for solving integer linear programs (ILPs), where some or all the unknowns are restricted to integer values. Branch and cut involves running a branch and bound algorithm and using cutting planes to tighten the linear programming relaxations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The branch-and-bound algorithm is used to find a value &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; that maximizes or minimizes the value of a real-valued function &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often a problem can be split into a master problem and the subproblem, that is called &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Column_generation&quot; rel=&quot;nofollow noreferrer&quot;&gt;column generation&lt;/a&gt;. Branch-and-price is a hybrid of branch and bound and column generation methods. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The branch-and-bound was first described by John Little in: &quot;&lt;a href=&quot;https://doi.org/10.1287/opre.11.6.972&quot; rel=&quot;nofollow noreferrer&quot;&gt;An Algorithm for the Traveling Salesman Problem&lt;/a&gt;&quot;, (Dec 1 1963):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;A “branch and bound” algorithm is presented for solving the traveling salesman problem. The set of all tours (feasible solutions) is broken up into increasingly small subsets by a procedure called branching. For each subset a lower bound on the length of the tours therein is calculated. Eventually, a subset is found that contains a single tour whose length is less than or equal to some lower bound for every tour.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Egon Balas described branch-and-bound in his paper &quot;Branch-and-bound Methods for the Travelling Salesman Problem&quot; as follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Enumerative (branch and bound, implicit enumeration) methods solve a discrete optimization problem by breaking up its feasible set into successively smaller subsets, calculating bounds on the objective function value over each subset, and using them to discard certain subsets from further consideration. The bounds are obtained by replacing the problem over a given subset with an easier (relaxed) problem, such that the solution value of the latter bounds that of the former. The procedure ends when each subset has either produced a feasible solution, or was shown to contain no better solution than the one already in hand. The best solution found during the procedure is a global optimum.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Branch-and-cut on the other hand is a means to divide the problem (as is branch-and-price) so branch-and-bound can be called upon it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the problem is simple enough BnB can look at the whole problem at once and provide an optimal solution, if the problem is enormous (as practical problems, opposed to simple ones, usually are) then solving pieces involves later recombining them and reiterating over them; that can lead to small errors, or pieces that were useful in the final solution having been trimmed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.m.wikipedia.org/wiki/Heuristic&quot; rel=&quot;nofollow noreferrer&quot;&gt;Heuristics&lt;/a&gt; are an estimation and not an exact method, they enable a significant speedup at the cost of accuracy. Ideally they can be used to obtain an estimate from which to start rather than being relied upon as partial answers incorporated into the solution.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-08-10T12:34:59.350" LastActivityDate="2019-08-10T12:34:59.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1243" PostTypeId="2" ParentId="1241" CreationDate="2019-08-10T11:58:56.600" Score="11" Body="&lt;p&gt;If your outcome is confirmed by 10 runs with different random seeds (or 10 permutations of the input) on different instances of your problem, then you are facing a (rare) case where the default cuts and heuristics are not needed and actually slow-down the solver (of course this can happen, as the default setting is not perfect in all cases). &lt;/p&gt;&#xA;" OwnerUserId="429" LastActivityDate="2019-08-10T11:58:56.600" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1246" PostTypeId="2" ParentId="1238" CreationDate="2019-08-10T15:37:56.677" Score="8" Body="&lt;p&gt;If the purpose of the comparison is to compare solution times (as opposed to validating the answers obtained), my feeling is that the XY v. YZ computer should not be an issue. Getting the source code (or binary) for the other algorithm is definitely a problem. Assuming you have their code (and that it runs on your computer, which may require getting the source and recompiling), and assuming you have enough memory for both methods, I think you can do a plausible comparison. If one algorithm has more stringent hardware requirements than the other (e.g., they need 16GB of RAM to solve problems you can solve in 4GB), that is worth noting. Memory aside, the primary difference between an XY and a YZ computer will be CPU speed and number of simultaneous threads it can handle (which relates to number of cores). Neither should dictate whether an algorithm can or cannot solve a problem (whereas memory might); they just affect solution speed. So running both methods on your computer v. theirs is like running a race on one track v. a different track: as long as both competitors are on the same track, it's a fair race.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For me, a trickier issue in algorithm races lies in comparability of the coding. If my code is in Python and theirs is compiled C code, they may have an inherent speed advantage unrelated to the wonderfulness of their algorithm. Even with the same language, differences in compilers could account for some speed differences. Similarly, if one method is coded by someone who is adept at optimizing for speed and the other is coded by someone who knows the math well but is a dabbler in coding, the &quot;tighter&quot; code might win even if the other algorithm is inherently better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get at the cloud part, I'm not aware of a cloud platform that lets you choose between different CPUs. (I think some of them let you configure the amount of RAM and possibly the number of cores, but not Intel XXX chip v. AMD yyy chip, say.) On the other hand, I'm no expert on cloud platforms.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-10T15:37:56.677" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1247" PostTypeId="1" AcceptedAnswerId="1254" CreationDate="2019-08-10T17:38:47.553" Score="9" ViewCount="246" Body="&lt;p&gt;In the &lt;em&gt;static stochastic knapsack problem&lt;/em&gt; (SSKP) the weights &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; of the items are distributed according to a probability distribution. Each item &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt; can be selected at most once. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, considering a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_i \in \{0, 1\}$&lt;/span&gt; and a set of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; scenarios &lt;span class=&quot;math-container&quot;&gt;$W = \{\mathbf{w^1},\dots,\mathbf{w^N}\} $&lt;/span&gt; we can write constraints like the following (i.e. worst-case robust optimization):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i \in I} w_{i}^{\xi} \cdot x_i \le C \qquad \forall \xi =1,\dots, N$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is the capacity of the knapsack. &#xA;Or, in terms of a chance constraint program:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ Pr\left(\sum_{i \in I} \tilde{w}_{i} \cdot x_i  \le C\right) \ge 1-\alpha $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\tilde{w}_{i}$&lt;/span&gt; are random variables. Or other similar formulations (i.e. stochastic optimization)...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;QUESTION:&lt;/strong&gt; Considering the &lt;em&gt;unbounded&lt;/em&gt; version of the SSKP, that is a problem in which:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;each item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; can be selected multiple times, without a priori limit besides what imposed by the total capacity &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; of the knapsack (i.e. type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; with average weight &lt;span class=&quot;math-container&quot;&gt;$\bar w_i$&lt;/span&gt; can be selected at most about &lt;span class=&quot;math-container&quot;&gt;$\left \lfloor{\frac{C}{\bar w_i}}\right \rfloor $&lt;/span&gt; times),&lt;/li&gt;&#xA;&lt;li&gt;the weight of each item is stochastic,&lt;/li&gt;&#xA;&lt;li&gt;items of the same type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; can have different weights.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;how can I express the constraints?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example (I know it is not correct, just to &quot;formalize&quot; what I mean), let &lt;span class=&quot;math-container&quot;&gt;$x_i \in \mathbb{N}$&lt;/span&gt; represent the number of items &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; included in the selection, and &lt;span class=&quot;math-container&quot;&gt;$\tilde{w}_{ij}$&lt;/span&gt; be the (stochastic) weight of the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;-th instance of the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th type, I would formally express the probabilistic constraint as follows (notice the variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; in the summation, which is where I think I abused the notation):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$  Pr\left(\sum_{i \in I}\sum_{j=0}^{x_i}  \tilde{w}_{ij}  \le C \right)\ge 1-\alpha $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to deal with this type of constraint with a MIP formulation (not necessarily for the chance constraint)?&lt;/p&gt;&#xA;" OwnerUserId="459" LastEditorUserId="459" LastEditDate="2019-08-12T07:21:00.890" LastActivityDate="2019-08-12T14:10:59.320" Title="Static stochastic knapsack problem: unbounded version" Tags="|mixed-integer-programming|modeling|constraint|integer-programming|chance-constraints|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1248" PostTypeId="1" CreationDate="2019-08-10T19:06:40.347" Score="8" ViewCount="852" Body="&lt;p&gt;I am trying to do my first MINLP problem using PYOMO and CPLEX - although I am not committed to using CPLEX, but it was recommended to me. To my understanding you need to formulate your problem in terms of matricies. However, In my own problem I have an exponential term which is a function of three other variables - the equation is a type of growth function for context: &lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$I^{(i,j)}_{\,t+1,pre} \!= R_t I^{(i,j)}_{\,t,pre}\;e^{-\beta\bigl(J^{(i,j)}_{\,t+1}+I^{(i,j)}_{t}+I^{(i,j)}_{\,t-1}\bigr)}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In PYOMO I could probably code the constraint something like the following: &lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;# Define the index sets for the grid and time horizons. &#xA;&#xA;# Defining the maximum value that the index can take. e.g. j = {1, 2, 3, ... , model.Jmax}&#xA;model.Imax = Param(within=NonNegativeIntegers) # Value = 10&#xA;model.Jmax = Param(within=NonNegativeIntegers) # Value = 10&#xA;model.Tmax = Param(within=NonNegativeIntegers) # Value = 7&#xA;&#xA;# Constructing the actual indicies used for the problem.&#xA;model.Iset = RangeSet(1, model.Imax) #e.g i = {1, 2, 3, ... , model.Imax=10}&#xA;model.Jset = RangeSet(1, model.Jmax)&#xA;model.Tset = RangeSet(1, model.Tmax)&#xA;&#xA;# Constraint &#xA;def Ipre_Recruitment(model):&#xA;   return model.Ipre == model.R * exp([EXPRESSION])&#xA;&#xA;model.Ipre_constraint = Constraint(rule = Ipre_Recruitment)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While the code is not by any means accurate, the idea is that I could more easily code up the constraint as it is in contrast to figuring out how to generate a matrix formulation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question I have then is if I am able to keep coding my MINLP in PYOMO in the manner that I have shown above, would you need to use a different solver to code it in this way, or do I need to restart somehow?&lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="51" LastEditDate="2019-08-11T06:33:50.457" LastActivityDate="2019-08-13T06:07:15.657" Title="Formulating a MINLP for CPLEX in PYOMO" Tags="|solver|cplex|pyomo|minlp|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1249" PostTypeId="2" ParentId="1181" CreationDate="2019-08-10T20:02:08.590" Score="11" Body="&lt;p&gt;I like Sean Kelly’s response.  I’ll just add a few points to this.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Over my career, I’ve worked in small to large firms, always close to OR.  And, I’ve run into quite a few people who have been successful at being a freelance math modeler—either I worked with them, they brought me into projects, or I brought them into projects.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are a few other observations of different ways of making it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Some have used their experience in big consulting firms to build a&#xA;network and build the skills to go out on their own.  So, you could&#xA;go to a big firm with the goal of figuring it out so you can go out&#xA;on your own.&lt;/li&gt;&#xA;&lt;li&gt;You have to be good at sales—getting projects to actually sign can be&#xA;time consuming and harder than you think.&lt;/li&gt;&#xA;&lt;li&gt;Related, you need to be prepared to weather the time, and more&#xA;important, the lack of cash coming in, between projects.  This time&#xA;can seem memoryless when you are in it, and endlessly frustrating&#xA;waiting for prospects to move forward or surface.  Remember, when you&#xA;are really busy with a project, your pipeline and network will grow&#xA;cold.&lt;/li&gt;&#xA;&lt;li&gt;Make sure you are ready for the other aspects of being a&#xA;freelancer—collecting money for the work you do (be ready for some&#xA;firms to be super slow in paying) and being able to manage&#xA;expectations and tricky situations (like a client who claims you&#xA;didn’t actually do what they wanted and isn’t paying)&lt;/li&gt;&#xA;&lt;li&gt;Don’t put pressure on yourself to make it an all-or-nothing type of&#xA;career choice.  I’ve seen people who do this jump between short-term&#xA;projects, long-term projects (that look almost like a job), and even&#xA;taking employment with firms.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="191" LastActivityDate="2019-08-10T20:02:08.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1250" PostTypeId="2" ParentId="1238" CreationDate="2019-08-11T09:09:57.730" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I wonder whether one of the large cloud providers allows you to configure a virtual server in a way that others could easily do the same.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;a href=&quot;https://neos-server.org/neos/&quot; rel=&quot;noreferrer&quot;&gt;NEOS Server&lt;/a&gt; is a &lt;strong&gt;free&lt;/strong&gt; internet-based service for solving numerical optimization problems. Hosted by the Wisconsin Institute for Discovery at the University of Wisconsin in Madison, the NEOS Server provides access to more than &lt;a href=&quot;https://neos-server.org/neos/solvers/index.html&quot; rel=&quot;noreferrer&quot;&gt;60 state-of-the-art solvers&lt;/a&gt; in more than a dozen optimization categories. There are &lt;a href=&quot;https://neos-guide.org/content/third-party-tools&quot; rel=&quot;noreferrer&quot;&gt;3rd party submission tools&lt;/a&gt; that allow you to write a simple program at home and submit your job to the server. See the &lt;a href=&quot;https://neos-guide.org/content/FAQ&quot; rel=&quot;noreferrer&quot;&gt;NEOS FAQ&lt;/a&gt; for details.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://opendreamkit.org/try/&quot; rel=&quot;noreferrer&quot;&gt;OpenDreamKit&lt;/a&gt; offers a &lt;a href=&quot;https://jupyter.org/&quot; rel=&quot;noreferrer&quot;&gt;Jupyter&lt;/a&gt; &lt;a href=&quot;https://mybinder.org/&quot; rel=&quot;noreferrer&quot;&gt;notebook&lt;/a&gt; to: &lt;a href=&quot;https://www.gap-system.org/Overview/Capabilities/links.html&quot; rel=&quot;noreferrer&quot;&gt;GAP&lt;/a&gt; (which supports &lt;a href=&quot;https://www.openmath.org/&quot; rel=&quot;noreferrer&quot;&gt;OpenMath&lt;/a&gt;), &lt;a href=&quot;https://pari.math.u-bordeaux.fr/&quot; rel=&quot;noreferrer&quot;&gt;PARI/GP&lt;/a&gt; (number theory) or try the &lt;a href=&quot;https://pari.math.u-bordeaux.fr/gp.html&quot; rel=&quot;noreferrer&quot;&gt;simple web interface&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/SageMath#Software_packages_contained_in_SageMath&quot; rel=&quot;noreferrer&quot;&gt;SageMath&lt;/a&gt; (includes &lt;strong&gt;R&lt;/strong&gt;, and a lot more), and &lt;a href=&quot;https://en.wikipedia.org/wiki/Singular_(software)&quot; rel=&quot;noreferrer&quot;&gt;Singular&lt;/a&gt; (a computer algebra system for polynomial computations with special emphasis on the needs of commutative and non-commutative algebra, algebraic geometry, and singularity theory).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.singular.uni-kl.de:8003/&quot; rel=&quot;noreferrer&quot;&gt;Singular Online&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://online-optimizer.appspot.com/?model=builtin:default.mod&quot; rel=&quot;noreferrer&quot;&gt;Online Solver&lt;/a&gt; for the &lt;a href=&quot;https://en.m.wikipedia.org/wiki/GNU_Linear_Programming_Kit&quot; rel=&quot;noreferrer&quot;&gt;GNU Linear Programming Kit&lt;/a&gt; from the book: &quot;&lt;a href=&quot;http://www.lio.yoriz.co.uk/&quot; rel=&quot;noreferrer&quot;&gt;Linear and Integer Optimization - Theory and Practice&lt;/a&gt;&quot;, by Gerard Sierksma and Yori Zwols.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.wolframalpha.com/examples/mathematics/applied-mathematics/optimization/&quot; rel=&quot;noreferrer&quot;&gt;WolframAlpha Optimizer&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can install &lt;a href=&quot;https://developers.google.com/optimization/&quot; rel=&quot;noreferrer&quot;&gt;OR-Tools&lt;/a&gt; on &lt;a href=&quot;https://cloud.google.com/&quot; rel=&quot;noreferrer&quot;&gt;Google Cloud&lt;/a&gt; (free year long trial) and Stack Overflow offers some support: &quot;&lt;a href=&quot;https://stackoverflow.com/q/55191430/3648282&quot;&gt;How to install ortools library on Google Cloud&lt;/a&gt;&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.phpsimplex.com/en/&quot; rel=&quot;noreferrer&quot;&gt;PHPSimplex&lt;/a&gt; is an online tool for solving linear programming problems.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.optil.io/optilion/&quot; rel=&quot;noreferrer&quot;&gt;OPTIL.io&lt;/a&gt; is the on-line judge system that receives algorithmic solutions of optimization problems in a form of source code from the crowd of developers, compiles it, executes in a homogeneous run-time environment and objectively evaluates using the set of test cases. Problems that are solved can be provided by external companies or scientists. Solutions can be submitted in almost any programming language.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-08-11T09:09:57.730" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1251" PostTypeId="2" ParentId="1241" CreationDate="2019-08-12T07:33:31.650" Score="3" Body="&lt;p&gt;Note that a different solver might yield a different result. The quality differences between solver, especially between open-source and commercial solvers, are huge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, there are problems where cuts, pre-solving, primal heuristics and other features don't help all that much. In some rare cases, as pointed out by Matteo Fischetti, they even hurt enough so that on average the slow down the solver more than they help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might also be possible that only one of the deactivated features hurts and the others are performance neutral or even slightly helpful, really hard to say anything without a lot of experimentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that in a reasonably advance solver, doing &quot;just branch-and-bound&quot; might be very far from what is described in textbooks. Solvers might do node-presolve, probing in nodes, restarts and all kinds of other advanced features that might be hard to turn off or there even might be no option to do that.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2019-08-12T07:33:31.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1252" PostTypeId="1" CreationDate="2019-08-12T08:14:31.157" Score="9" ViewCount="3687" Body="&lt;p&gt;Has anyone used the google OR tools in python to solve the workforce scheduling problem. Can you please let me know&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Advantages and Disadvantages&lt;/li&gt;&#xA;&lt;li&gt;Any issues faced during usage and implementation&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1079" LastEditorUserId="981" LastEditDate="2019-08-13T06:06:26.370" LastActivityDate="2019-08-13T10:59:59.133" Title="Google - OR tools for workforce scheduling problems" Tags="|linear-programming|online-resources|or-tools|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1253" PostTypeId="2" ParentId="1252" CreationDate="2019-08-12T12:55:56.263" Score="8" Body="&lt;p&gt;I used OR-tools for TSP and VRP. These are my observations: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- It provides a good quality solution in reasonable time. However, it is not the optimal solution and in some cases you can find much better solutions easily. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2- The implantation in Python is straightforward. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;3- It is not flexible. You can not add many extensions to the problem, just basic assumptions and constraints. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;4- You will have some option such as giving the initial solution, the algorithm settings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a good solution fast and you are sure you will not expand the problem later, then go for it. &lt;/p&gt;&#xA;" OwnerUserId="172" LastActivityDate="2019-08-12T12:55:56.263" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1254" PostTypeId="2" ParentId="1247" CreationDate="2019-08-12T14:10:59.320" Score="3" Body="&lt;p&gt;Couldn't you just introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; and consider the sum&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$  Pr\left(\sum_{i \in I}\sum_{j=0}^{\text{max}}  \tilde{w}_{ij} x_{ij}  \le C \right)\ge 1-\alpha $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where max is chosen with respect to the capacity and the minimal appearing weight? If you want the elements chosen &quot;in order&quot;, you could introduce constraints like &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \geq x_{ij+1}$&lt;/span&gt;, but due to the stochasticity of the problem, this seems unnecessary.&lt;/p&gt;&#xA;" OwnerUserId="50" LastActivityDate="2019-08-12T14:10:59.320" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1255" PostTypeId="1" CreationDate="2019-08-12T17:52:14.663" Score="13" ViewCount="1699" Body="&lt;p&gt;It would be very useful for beginning and non technical users to be able to define models in a way that was natural for them. Further this could perhaps assist generating some kind of generic modelling language which could be used in applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inspired by the &lt;a href=&quot;http://lettuce.it/tutorial/simple.html&quot; rel=&quot;noreferrer&quot;&gt;BDD (Behavior Driven Development) library&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's take a diet like problem. It could be stated as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Given I have ingredient banana&#xA;Given that a banana costs 1 unit&#xA;The ingredient banana has 10 units of potassium&#xA;Find me the cheapest ingredient combination for 100 units of potassium&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe it's an implementation detail? And I should just define the types of constraints and parse the string data? Is this an area of research?&lt;/p&gt;&#xA;" OwnerUserId="259" LastEditorUserId="279" LastEditDate="2019-08-13T09:18:18.110" LastActivityDate="2019-08-14T01:37:30.000" Title="Is there a SQL/English like language that lets you define formulations given some data?" Tags="|mixed-integer-programming|applications|modeling|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1256" PostTypeId="2" ParentId="1255" CreationDate="2019-08-12T18:15:43.253" Score="11" Body="&lt;p&gt;Not answering your question, but related: I just came across a paper (&lt;a href=&quot;https://arxiv.org/pdf/1908.01839.pdf&quot; rel=&quot;noreferrer&quot;&gt;Wang, Shi, and Reddy 2019&lt;/a&gt;) that aims to translate natural English into SQL queries. Here's an example of their results:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/midu8.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/midu8.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe this can be a useful starting point if you're searching for literature on this, or starting to build your own English-to-modelling-language translator.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-08-12T18:15:43.253" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1257" PostTypeId="2" ParentId="1248" CreationDate="2019-08-12T22:15:33.837" Score="5" Body="&lt;p&gt;As mentioned in the comments, CPLEX cannot handle MINLP problems which are not Mixed-Integer Second-order cones (MISOCP) and Mixed-integer quadratic or quadratically constrained programs (MIQP and MIQCP).&#xA;Given that you have a general nonlinear constraint, you cannot write it in a matrix was, meaning that you cannot express the exponential constraint &lt;span class=&quot;math-container&quot;&gt;$g(x)=\exp(x) \leq 0$&lt;/span&gt; as a matrix (in)equality &lt;span class=&quot;math-container&quot;&gt;$Ax \leq b$&lt;/span&gt;.&#xA;Fortunately, Pyomo allows you to write down general nonlinear optimization problems using the expressions' syntax as you can check &lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/pyomo_modeling_components/Expressions.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the solution methods, you have available in Pyomo for MINLP both open-source (&lt;a href=&quot;https://projects.coin-or.org/Bonmin&quot; rel=&quot;nofollow noreferrer&quot;&gt;BONMIN&lt;/a&gt;, &lt;a href=&quot;https://projects.coin-or.org/Couenne&quot; rel=&quot;nofollow noreferrer&quot;&gt;COUENNE&lt;/a&gt;, &lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/contributed_packages/mindtpy.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;MindtPy&lt;/a&gt;) and commercial (&lt;a href=&quot;https://www.artelys.com/solvers/knitro/&quot; rel=&quot;nofollow noreferrer&quot;&gt;KNITRO&lt;/a&gt;, &lt;a href=&quot;https://minlp.com/baron&quot; rel=&quot;nofollow noreferrer&quot;&gt;BARON&lt;/a&gt;) solvers. Finally keep in mind that your model (as it is right now) is nonconvex and some of the solvers can only give you local optimality guarantees (BONMIN, MindtPy, KNITRO).&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="123" LastEditDate="2019-08-13T06:07:15.657" LastActivityDate="2019-08-13T06:07:15.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1258" PostTypeId="2" ParentId="1255" CreationDate="2019-08-13T02:13:46.650" Score="11" Body="&lt;p&gt;MiniZinc is the closest I know of. In terms of syntax, it is closer to&#xA;Python, R, and MATLAB than SQL. However, it is a pretty powerful language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://www.minizinc.org/doc-2.3.1/en/modelling.html#ex-cakes2&quot; rel=&quot;nofollow noreferrer&quot;&gt;Example&lt;/a&gt;:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% Baking cakes for the school fete (with data file)&#xA;&#xA;int: flour;  %no. grams of flour available&#xA;int: banana; %no. of bananas available&#xA;int: sugar;  %no. grams of sugar available&#xA;int: butter; %no. grams of butter available&#xA;int: cocoa;  %no. grams of cocoa available&#xA;&#xA;constraint assert(flour &amp;gt;= 0,&quot;Invalid datafile: &quot; ++&#xA;                  &quot;Amount of flour should be non-negative&quot;);&#xA;constraint assert(banana &amp;gt;= 0,&quot;Invalid datafile: &quot; ++&#xA;                  &quot;Amount of banana should be non-negative&quot;);&#xA;constraint assert(sugar &amp;gt;= 0,&quot;Invalid datafile: &quot; ++&#xA;                  &quot;Amount of sugar should be non-negative&quot;);&#xA;constraint assert(butter &amp;gt;= 0,&quot;Invalid datafile: &quot; ++&#xA;                  &quot;Amount of butter should be non-negative&quot;);&#xA;constraint assert(cocoa &amp;gt;= 0,&quot;Invalid datafile: &quot; ++&#xA;                  &quot;Amount of cocoa should be non-negative&quot;);&#xA;&#xA;var 0..100: b; % no. of banana cakes&#xA;var 0..100: c; % no. of chocolate cakes&#xA;&#xA;% flour&#xA;constraint 250*b + 200*c &amp;lt;= flour;&#xA;% bananas&#xA;constraint 2*b  &amp;lt;= banana;&#xA;% sugar&#xA;constraint 75*b + 150*c &amp;lt;= sugar;&#xA;% butter&#xA;constraint 100*b + 150*c &amp;lt;= butter;&#xA;% cocoa&#xA;constraint 75*c &amp;lt;= cocoa;&#xA;&#xA;% maximize our profit&#xA;solve maximize 400*b + 450*c;&#xA;&#xA;output [&quot;no. of banana cakes = \(b)\n&quot;,&#xA;        &quot;no. of chocolate cakes = \(c)\n&quot;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1147" LastEditorUserId="1160" LastEditDate="2019-08-14T01:37:30.000" LastActivityDate="2019-08-14T01:37:30.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1259" PostTypeId="2" ParentId="1252" CreationDate="2019-08-13T03:59:05.830" Score="7" Body="&lt;p&gt;Workforce scheduling describes many different problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best technology for those is IMO CP-SAT (see the &lt;a href=&quot;https://developers.google.com/optimization/cp/cp_solver&quot; rel=&quot;noreferrer&quot;&gt;introduction&lt;/a&gt;, the &lt;a href=&quot;http://google.github.io/or-tools/&quot; rel=&quot;noreferrer&quot;&gt;reference manual&lt;/a&gt; in the CP-SAT sections and a set of &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/sat/doc/README.md&quot; rel=&quot;noreferrer&quot;&gt;recipes&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A popular concert is shift scheduling. &#xA;This &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/python/shift_scheduling_sat.py&quot; rel=&quot;noreferrer&quot;&gt;example&lt;/a&gt; has gained a lot of traction in the past. It shows how to implement useful constraints on the problem that contains fixed daily shifts.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2019-08-13T03:59:05.830" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1260" PostTypeId="1" AcceptedAnswerId="1261" CreationDate="2019-08-13T06:01:02.940" Score="12" ViewCount="799" Body="&lt;p&gt;I'm currently developing a small capacity planning problem and right now I am struggling with the &quot;activation&quot; of a subset. Needless to say I am not an expert in this kind of things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a set of &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; products. Each product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; can be produced by &lt;span class=&quot;math-container&quot;&gt;$p∈P_i$&lt;/span&gt; processes. Each process &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; requires a set of different machines &lt;span class=&quot;math-container&quot;&gt;$w∈W_p$&lt;/span&gt;. Decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{tip}$&lt;/span&gt; represents the quantity of product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; produced in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; through process &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;.  The quantity is subject to change in each period to satisfy the demand &lt;span class=&quot;math-container&quot;&gt;$D_{ti}$&lt;/span&gt;. However, the company must stick to the process selected in &lt;span class=&quot;math-container&quot;&gt;$t=1$&lt;/span&gt; for the whole planning period &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;. This is indicated by the binary variable &lt;span class=&quot;math-container&quot;&gt;$u_{tip}$&lt;/span&gt;. I already formulated the relevant constraints to force this behavior:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{tip} \le u_{tip}\cdot M \quad \quad \forall t \in T,i\in I, p \in P_i$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$u_{tip} = u_{t+1ip} \quad \quad \forall t \in T,i\in I, p \in P_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{p∈P_i} u_{tip} \le 1 \quad \quad \forall t \in T,i\in I$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$u_{tip} \in \{0,1\}\quad \quad \forall t \in T,i\in I, p \in P_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now I want to use &lt;span class=&quot;math-container&quot;&gt;$u_{tip}$&lt;/span&gt; to activate all machines that are required for the selected process &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;. However, I am at my wit's end and just have no clue how to implement this behavior linearly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&#xA;Assume we have a product &lt;span class=&quot;math-container&quot;&gt;$i=1$&lt;/span&gt; that can be produced by processes &lt;span class=&quot;math-container&quot;&gt;$P_1\in\{1,3\}$&lt;/span&gt;. Disregarding the other products, process &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; is selected for product &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$u_{t11}=1$&lt;/span&gt;. Process &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; requires machines &lt;span class=&quot;math-container&quot;&gt;$W_1 \in \{2,3\}$&lt;/span&gt;. Is there a way to use a new indicator variable, e.g. &lt;span class=&quot;math-container&quot;&gt;$y_{tiw}$&lt;/span&gt;, to &quot;activate&quot; all machines &lt;span class=&quot;math-container&quot;&gt;$w \in W_1$&lt;/span&gt; for product &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I try to minimize my set-up costs, I need to know whether a machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is used by a product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. I tried it with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$u_{tip} \le y_{tiw} \quad \quad \forall t \in T, i \in I, p \in P_i, w \in W_i$$&lt;/span&gt;&#xA;but after toying around I don't think this works. Note that every process &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; may have a different no. of required machines &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I said I am currently struggling to find a way to make this work linearly. I tried to find similar papers in the operations management literature but that wasn't successful either. I would gladly appreciate any help or hints/references on similar work. Thank you!&lt;/p&gt;&#xA;" OwnerUserId="1149" LastEditorUserId="123" LastEditDate="2019-08-13T06:09:23.367" LastActivityDate="2019-08-13T12:07:08.027" Title="Mixed-Integer Linear Programming (Capacity Planning)" Tags="|mixed-integer-programming|linear-programming|reference-request|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1261" PostTypeId="2" ParentId="1260" CreationDate="2019-08-13T09:11:07.580" Score="7" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;: Number of products&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$|P_i|$&lt;/span&gt;: Number of available processes for product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$|p|$&lt;/span&gt;: Number of machines in each process &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can define two new binary variables for each &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; machine as follow:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{tipk} = \left\{\begin{array}{l}1 &amp;amp; \text{if machine $k$ in time $t$ under process $p$ is working on product $i$}\\0 &amp;amp; \text{otherwise}\end{array}\right.$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$q_{pk} = \left\{\begin{array}{l}1 &amp;amp; \text{if machine $k$ is among the ones that are being used in process $p$}\\0 &amp;amp; \text{otherwise}\end{array}\right.$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you need to add the following constraints to the model:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in I} s_{tipk} =1 \ \ \ \forall \ t,k$&lt;/span&gt; (each machine can produce only one type of product at each time period)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{k} q_{pk} =|p|*u_{tip} \ \ \ \forall \ \ i,t$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{tipk} \leq q_{pk} \ \ \ \forall \ \ t,k,i,p$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I believe this answer will give you at least some hints on how to model the problem (if it hasn't already covered all the necessary details).&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-08-13T09:11:07.580" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1262" PostTypeId="2" ParentId="1252" CreationDate="2019-08-13T09:14:18.613" Score="9" Body="&lt;p&gt;In addition to the answer from @Mehdi... I've recently started to work with OR-tools and find it very nice for prototyping. The Python interface allowed me to produce a first version of my model within one day. The times to obtain a first solution seem good - it performed very favorable in the &lt;a href=&quot;https://www.minizinc.org/challenge2018/results2018.html&quot; rel=&quot;noreferrer&quot;&gt;MiniZinc Challenge 2018&lt;/a&gt;.&lt;br&gt;&#xA;The main struggles/disadvantages that I've run into so far are the very limited support for floating point numbers. Compared to MiniZinc for example (which I also used) there is no possibility to have cumulative constraints with floats. Also, some constraints seem to be lacking from the catalog/ that MiniZinc offers. For example the &lt;code&gt;AddMaxEquality&lt;/code&gt; function allows only variables and no expressions to be used, so you'll have to add additional variables.&lt;br&gt;&#xA;I also found that the documentation could use some improvements - for example the solver parameters were hidden in the &lt;a href=&quot;https://github.com/google/or-tools/blob/master/ortools/sat/sat_parameters.proto&quot; rel=&quot;noreferrer&quot;&gt;source code&lt;/a&gt; and there was no dedicated place where they were listed (or I looked in the wrong directions).&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="137" LastEditDate="2019-08-13T10:59:59.133" LastActivityDate="2019-08-13T10:59:59.133" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1263" PostTypeId="2" ParentId="1255" CreationDate="2019-08-13T09:48:30.103" Score="3" Body="&lt;h2&gt;Controlled natural language&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There's a bunch of research in using controlled natural language (e.g. in the CNL workshop &lt;a href=&quot;https://link.springer.com/conference/cnl&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/conference/cnl&lt;/a&gt;) and one of the use cases is for making queries in some knowledge base. If the data and its ontology is in a structured format such as RDF, then there exist tools for querying that data directly (usually with SPARQL), there are a bunch of tools for visualizing the models/ontologies and the data in them, and there are also natural language querying tools such as &lt;a href=&quot;http://aksw.org/Projects/AutoSPARQL.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://aksw.org/Projects/AutoSPARQL.html&lt;/a&gt; or &lt;a href=&quot;https://github.com/AKSW/NSpM&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/AKSW/NSpM&lt;/a&gt; which I admittedly haven't tried. It's a whole field of research that's not that related to operations research, but there are some interesting things there.&lt;/p&gt;&#xA;" OwnerUserId="1140" LastActivityDate="2019-08-13T09:48:30.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1265" PostTypeId="1" AcceptedAnswerId="1295" CreationDate="2019-08-13T14:07:34.847" Score="16" ViewCount="1241" Body="&lt;p&gt;There are many approaches to deal with the uncertainty such as stochastic programming, robust optimization and fuzzy programming. Finding a suitable approach that is applicable in the real situations can be tricky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two main questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- In general, what are the conditions to use Stochastic Programming in favor of Robust Optimization? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2- When we should model the uncertain parameters with discrete scenarios instead of their probability distributions?&lt;/p&gt;&#xA;" OwnerUserId="172" LastEditorUserId="123" LastEditDate="2019-10-20T13:01:45.997" LastActivityDate="2019-12-08T16:18:08.937" Title="Modeling the uncertainty of the input parameters" Tags="|stochastic-programming|probability-distributions|uncertainty|robust-optimization|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1266" PostTypeId="2" ParentId="1265" CreationDate="2019-08-13T15:00:56.363" Score="10" Body="&lt;p&gt;The following papers discuss this extensively with numerical experiments, but they tackle specific examples. Emphasis is mine.&lt;/p&gt;&#xA;&lt;h2&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s12667-017-0265-5&quot; rel=&quot;noreferrer&quot;&gt;Kazamzadeh &lt;em&gt;et al.&lt;/em&gt; (2017)&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;This is a comparison of the two techniques using the example of unit commitment, answering your first question.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A popular impression has arisen that the &lt;strong&gt;robust approach&lt;/strong&gt;, with its focus on the worst case, is &lt;strong&gt;better able to control risk while stochastic programming emphasizes expected values&lt;/strong&gt;. However, the &lt;strong&gt;stochastic programming formulation can easily accommodate a risk measure&lt;/strong&gt;. Moreover, the results of both methods depend strongly on the model for the uncertain parameters—either the uncertainty set or the probabilistic scenarios employed in the optimization. [...]&lt;/p&gt;&#xA;&lt;p&gt;[...] By incorporating risk in the stochastic programming formulation in terms of CVaR with a sufficiently low tail probability, the &lt;strong&gt;stochastic programming formulation can achieve the most efficient combinations of cost and risk when a decision maker emphasizes cost&lt;/strong&gt;. However, &lt;strong&gt;when a higher level of conservatism is preferred, robust optimization models can achieve the most efficient combinations of cost and risk&lt;/strong&gt;. Between the two uncertainty set formulations for robust optimization, the data-driven method that incorporates probabilities of scenarios as well as their ranges of values achieves better cost-risk trade-offs than the one based on ranges alone when the risk parameter is set to its most stringent value.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h2&gt;&lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2015/03/4805.pdf&quot; rel=&quot;noreferrer&quot;&gt;Maggioni &lt;em&gt;et al.&lt;/em&gt; (2014)&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;This is a comparison of the two techniques using the example of a standard transportation problem. This answers the reverse of your first question (i.e. robust optimisation in favour of stochastic programming) which you may find useful. From the abstract,&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The proposed &lt;strong&gt;robust formulations&lt;/strong&gt; have the advantage to be &lt;strong&gt;solvable in polynomial time and to have theoretical guarantees for the quality of their solutions&lt;/strong&gt;, which is not the case for the stochastic formulation. Numerical experiments show that the &lt;strong&gt;robust approach results in larger objective function values than the stochastic approach&lt;/strong&gt; due to the certitude of constraints satisfaction and more conservative decision strategies on the number of booked vehicles. Conversely, the &lt;strong&gt;computational complexity is higher for the stochastic approach.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Kazamzadeh, N., Ryan, S. M., Hamzeei, M. (2017). Robust optimization vs. stochastic programming incorporating risk measures for unit commitment with uncertain variable renewable generation. &lt;em&gt;Energy Syst.&lt;/em&gt; 10:517-541. &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [2] Maggioni, F., Potra, F. A., Bertocchi, M. (2014). Stochastic versus Robust Optimization for a Transportation Problem. Available from: &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2015/03/4805.pdf&quot; rel=&quot;noreferrer&quot;&gt;http://www.optimization-online.org/DB_FILE/2015/03/4805.pdf&lt;/a&gt;. [Accessed 13 August 2019]. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-08-13T15:00:56.363" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1267" PostTypeId="2" ParentId="1265" CreationDate="2019-08-13T15:23:24.977" Score="12" Body="&lt;p&gt;In reference to the first question, I think it often comes down to the information you have about the underlying uncertainty. If you only have intervals or ranges, robust is the way to go. If you have all of the distributional information (or assume it), stochastic programming is an option. As @TheSimpliFire mentioned, you can include risk measures in stochastic programming formulations to consider risk.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a note, another option that's becoming more popular is distributionally-robust optimization [1]. The information required is in between robust optimization and stochastic programming. Here, you consider an &quot;ambiguity set&quot; of all of the possible distributions your data could be and optimize your objective hedging against the worst-case distribution.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Delage E, Ye Y (2010) &lt;a href=&quot;http://web.hec.ca/pages/erick.delage/distRobOpt_draft.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Distributionally Robust Optimization Under Moment Uncertainty with Application to Data-Driven Problems.&lt;/a&gt; &lt;em&gt;Oper. Res.&lt;/em&gt; 58(3):595–612. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="56" LastEditorUserId="123" LastEditDate="2019-08-14T19:14:29.303" LastActivityDate="2019-08-14T19:14:29.303" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1268" PostTypeId="2" ParentId="1255" CreationDate="2019-08-13T19:28:43.030" Score="5" Body="&lt;p&gt;It is a little uncommon these days, but prolog is well suited to this type of problem.  It allows you to concisely state and efficiently solve a wide variety of interesting things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://stackoverflow.com/questions/57316504/zebra-puzzle-who-lives-on-which-floor&quot;&gt;https://stackoverflow.com/questions/57316504/zebra-puzzle-who-lives-on-which-floor&lt;/a&gt; as well as a whole mess of tagged questions &lt;a href=&quot;https://stackoverflow.com/questions/tagged/prolog+zebra-puzzle&quot;&gt;https://stackoverflow.com/questions/tagged/prolog+zebra-puzzle&lt;/a&gt; as examples.&lt;/p&gt;&#xA;" OwnerUserId="1157" LastActivityDate="2019-08-13T19:28:43.030" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1269" PostTypeId="1" AcceptedAnswerId="1270" CreationDate="2019-08-14T01:10:24.843" Score="9" ViewCount="261" Body="&lt;p&gt;In one of the archived research topics of mine, I tried to model and solve &lt;strong&gt;SVRP&lt;/strong&gt;s using &lt;em&gt;Multiple Tandem Queues&lt;/em&gt;. I have two related questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What are the sources for uncertainty in Stochastic VRPs? In other words, what causes the stochasticity in VRPs?&lt;/li&gt;&#xA;&lt;li&gt;Which of those factors has been most/least studied?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I couldn't find any paper implementing &lt;strong&gt;any queue theory ideas&lt;/strong&gt; in the modeling of the stochastic VRPs. I appreciate suggestions in this regard as well.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-08-14T01:32:23.173" LastActivityDate="2019-08-14T01:32:23.173" Title="Stochastic VRP: Sources of uncertainty and modeling approaches" Tags="|vehicle-routing|stochastic-process|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1270" PostTypeId="2" ParentId="1269" CreationDate="2019-08-14T01:26:38.890" Score="9" Body="&lt;p&gt;The source of uncertainty is usually customer demand, travel time, service time at the location (during pick up or serving the customer), or presence of the customer (customers may not be available to receive their orders). As mentioned in the paper:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Capacitated vehicle routing problem with stochastic demand has been by far the most studied version of the problem.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This paper &quot;&lt;a href=&quot;https://link.springer.com/article/10.1007/s13676-016-0100-5&quot; rel=&quot;noreferrer&quot;&gt;The stochastic vehicle routing problem, a literature review, part I: models&lt;/a&gt;&quot; reviews these different cases. In &lt;a href=&quot;https://link.springer.com/article/10.1007/s13676-016-0099-7&quot; rel=&quot;noreferrer&quot;&gt;another review&lt;/a&gt;, the same authors discuss different solution methods. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;About queueing theory idea for solving SVRP, you can take a look at this paper: &quot;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221707003116&quot; rel=&quot;noreferrer&quot;&gt;Vehicle routing with dynamic travel times: a queueing approach&lt;/a&gt;&quot; where:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;a vehicle routing problem with dynamic travel times due to potential traffic congestion is considered. The approach developed introduces mainly the traffic congestion component based on queueing theory.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-08-14T01:30:58.123" LastActivityDate="2019-08-14T01:30:58.123" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1271" PostTypeId="2" ParentId="1125" CreationDate="2019-08-14T08:50:09.743" Score="6" Body="&lt;p&gt;Thank you for using docplex.&#xA;Currently, docplex.cp can import only .cpo and .mzn files. Maybe this could be extended in the next future.&lt;/p&gt;&#xA;" OwnerUserId="1163" LastEditorUserId="71" LastEditDate="2019-08-14T09:46:43.303" LastActivityDate="2019-08-14T09:46:43.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1272" PostTypeId="1" CreationDate="2019-08-14T11:45:23.057" Score="12" ViewCount="476" Body="&lt;p&gt;So assume we have a MILP (e.g. inventory or capacity planning) and the objective is to minimize total costs (inventory costs, set-up costs, backorder costs, production costs etc.). The production of a product &lt;span class=&quot;math-container&quot;&gt;$x_{tp}$&lt;/span&gt; must meet demand &lt;span class=&quot;math-container&quot;&gt;$D_{tp}$&lt;/span&gt;. Most models and papers I reviewed in this area only consider the variable costs of a product (e.g. material) in the objective function, but do not incorporate the fixed costs per unit  (as they assume that they are fixed). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So normally, unit costs of a product &lt;span class=&quot;math-container&quot;&gt;$UC_p$&lt;/span&gt; would consist of a variable term (&lt;span class=&quot;math-container&quot;&gt;$VC$&lt;/span&gt;) and a fixed term, with the fixed portion being proportionalized based on the whole output Level &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{p \in P}x_{tp}$&lt;/span&gt; (simplified). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$UC_p =\frac{FC}{\sum\limits_{p \in P}x_{tp}} + VC$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem now is that, if i want to calculate the total costs, this term leads to non-linearity of my MILP, as i would need to multiply it with the production quantity &lt;span class=&quot;math-container&quot;&gt;$x_{tp}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I am looking for such a formulation is that I want to incorporate the idea of economies of scale into the model, e.g. the more I produce of a specific product the lower are my unit costs. It is basically an alternative formulation to an utilization constraint that sets a lower bound on the output quantity. Still, i wanted to try if there is a way to formulate it completely from a cost perspective.&lt;/p&gt;&#xA;" OwnerUserId="1149" LastEditorUserId="123" LastEditDate="2019-08-14T18:13:29.430" LastActivityDate="2019-08-14T19:54:15.320" Title="Is there a way to proportionalize fixed costs in a MILP?" Tags="|mixed-integer-programming|modeling|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1274" PostTypeId="2" ParentId="1272" CreationDate="2019-08-14T13:32:10.873" Score="4" Body="&lt;ul&gt;&#xA;&lt;li&gt;Introduce new binary variable &lt;span class=&quot;math-container&quot;&gt;$s_t$&lt;/span&gt; for each timebucket &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; to the problem. Set objective coefficient of &lt;span class=&quot;math-container&quot;&gt;$s_t$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$FC$&lt;/span&gt; (your fixed costs). This variable indicates whether some product is produced in timebucket &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Link overall production variable &lt;span class=&quot;math-container&quot;&gt;$s_t$&lt;/span&gt; to the production variables &lt;span class=&quot;math-container&quot;&gt;$u_{tp}$&lt;/span&gt; which indicate that some amount of product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is produced in timebucket &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. To do this you'll need two constraints&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\forall t\in T: \sum_{p\in P} u_{tp} \leq |P|s_{t} \\&#xA;\forall t\in T, \forall p\in P: u_{tp} \leq s_{t}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Your objective function will probably look something like this: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{t\in T} FC\cdot s_{t} + \sum_{t\in T}\sum_{p\in P} VC\cdot x_{tp}$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="137" LastEditorUserId="123" LastEditDate="2019-08-14T18:14:40.350" LastActivityDate="2019-08-14T18:14:40.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1275" PostTypeId="1" CreationDate="2019-08-14T16:43:39.760" Score="15" ViewCount="4976" Body="&lt;p&gt;Can someone recommend a good self-study textbook for queueing theory and performance modeling? My interest is in applying this to understanding the behavior of some real-world server networks, predicting what loads they can handle, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a strong background in probability theory, stats, and graphical models, and familiarity with survival models, Poisson processes, and Markov chains, but don't know a lot about queueing theory, renewal processes, or how to efficiently simulate queueing networks.&lt;/p&gt;&#xA;" OwnerUserId="1167" LastEditorUserId="123" LastEditDate="2019-08-14T18:11:13.510" LastActivityDate="2019-08-15T16:54:16.277" Title="Good textbook for queueing theory and performance modeling" Tags="|reference-request|simulation|stochastic-process|queuing-theory|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1276" PostTypeId="2" ParentId="1272" CreationDate="2019-08-14T19:54:15.320" Score="12" Body="&lt;p&gt;I believe that, in practice, economies of scale usually manifest as reductions in the unit &lt;em&gt;variable&lt;/em&gt; cost as quantities increase. A common approach is to model the economies of scale using piecewise linear functions (which will be accurate in some situations and an approximation in others). You then break up the production quantity for a particular product into a sum of variables, each representing the amount of production in one of the segments of the PWL cost function. Assuming that you have an economy of scale (not a diseconomy), and that you are minimizing rather than maximizing cost (i.e., you are not the federal government), you will also need binary variables to signal whether an interval has been fully used and constraints to ensure that you do not use one of the cheaper intervals until you have filled out the more expensive intervals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The preceding assumes incremental discounts (where the cumulative cost function is continuous). &quot;All-units&quot; discounts result in the cumulative cost function having jump discontinuities. You still use binary variables to signal qualification for an interval (sufficient overall quantity), and then write the total cost for that product as the sum of cost variables for each interval, constrained via those binary variables so that only the one correct quantity makes it into the objective function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that some solvers support piecewise linear functions directly, which can help.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-14T19:54:15.320" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1277" PostTypeId="2" ParentId="1275" CreationDate="2019-08-14T21:11:01.047" Score="7" Body="&lt;p&gt;Unfortunately, much of the &lt;em&gt;performance analysis&lt;/em&gt; and transient approximations for time-varying systems with non-Markovian (non-exponential) properties are not easily obtained in book form (see note at bottom). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This answer lists some books that don't require &lt;a href=&quot;https://en.wikipedia.org/wiki/Measure_(mathematics)&quot; rel=&quot;noreferrer&quot;&gt;measure theory&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some &lt;strong&gt;Queueing &amp;amp; Renewal theory&lt;/strong&gt;  books: (non-measure theoretic) &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Probability, Markov Chains, Queues, and Simulation: The Mathematical Basis of Performance Modeling&lt;/em&gt;&lt;/strong&gt;  by William J. Stewart&#xA;(Princetion University Press).&lt;sup&gt;[1]&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Includes an impressive amount on various &lt;strong&gt;queues &amp;amp; queueing networks&lt;/strong&gt;.       &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Introduction to Probability Models&lt;/em&gt;&lt;/strong&gt; by Sheldon M. Ross (Academic Press).&lt;sup&gt;[2]&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ross is anything but an &quot;introduction&quot; but is widely used&#xA;for its body of examples. Unfortunately, the type-setting is terrible&#xA;and makes it difficult to distinguish between key points, theorems,&#xA;examples, etc., at a glance. Includes &lt;strong&gt;queues, queueing networks, &amp;amp; renewal &#xA;processes&lt;/strong&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Stochastic Processes&lt;/em&gt;&lt;/strong&gt; by Sheldon M. Ross (Wiley).&lt;sup&gt;[3]&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This covers &lt;strong&gt;renewal theory&lt;/strong&gt; in greater depth. (&lt;a href=&quot;http://home.ustc.edu.cn/~alex2014/SPpdf/Stochastic%20Processes%20SM.pdf&quot; rel=&quot;noreferrer&quot;&gt;Full text&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some relevant &lt;strong&gt;Simulation&lt;/strong&gt; books: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;em&gt;Simulation Modeling &amp;amp; Analysis&lt;/em&gt;&lt;/strong&gt; by Averill M. Law (McGraw-Hill).&lt;sup&gt;[4]&lt;/sup&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;em&gt;Simulation&lt;/em&gt;&lt;/strong&gt; by Sheldon M. Ross (Academic Press).&lt;sup&gt;[5]&lt;/sup&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note: If relevant to the OP, I can add resources for time-varying systems with non-Markovian (non-exponential) properties, to include recent surveys.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;br&gt;&#xA;&lt;sub&gt; [1] &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0691140626&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;ISBN: 978-1400832811&lt;/a&gt; or &lt;a href=&quot;https://press.princeton.edu/titles/8844.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/sub&gt;&lt;br&gt;&#xA;&lt;sub&gt; [2] &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/B07PRL5562&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;ISBN: 978-0128143469&lt;/a&gt;&lt;/sub&gt;&lt;br&gt;&#xA;&lt;sub&gt; [3] &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0471120626&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;ISBN: 978-0471120629&lt;/a&gt; or (&lt;a href=&quot;http://home.ustc.edu.cn/~alex2014/SPpdf/Stochastic%20Processes%20SM.pdf&quot; rel=&quot;noreferrer&quot;&gt;full text&lt;/a&gt;)&lt;/sub&gt;&lt;br&gt;&#xA;&lt;sub&gt; [4] &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0073401323&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;ISBN: 978-0073401324&lt;/a&gt; or &lt;a href=&quot;http://www.averill-law.com/simulation-book/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; &lt;/sub&gt;&lt;br&gt;&#xA;&lt;sub&gt; [5] &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0124158250&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;ISBN: 978-0124158252&lt;/a&gt; &lt;/sub&gt;             &lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-08-14T22:08:02.950" LastActivityDate="2019-08-14T22:08:02.950" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1278" PostTypeId="1" AcceptedAnswerId="1328" CreationDate="2019-08-14T21:21:42.127" Score="22" ViewCount="6591" Body="&lt;p&gt;Can someone explain how warm starts/ MIP starts work?&lt;/p&gt;&#xA;&lt;p&gt;How do solvers like CPLEX/GUROBI use warm start with the Simplex algorithm?&lt;/p&gt;&#xA;&lt;p&gt;I am interested in understanding how the entire warm start pipeline works in a MILP solver. I would appreciate links to any good reference papers talking about warm start.&lt;/p&gt;&#xA;" OwnerUserId="873" LastEditorUserId="500" LastEditDate="2023-12-13T18:00:12.583" LastActivityDate="2023-12-13T18:00:12.583" Title="How does a warm start work in LP/MIP?" Tags="|mixed-integer-programming|linear-programming|cplex|gurobi|warm-start|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1279" PostTypeId="2" ParentId="1275" CreationDate="2019-08-14T21:54:57.133" Score="2" Body="&lt;p&gt;&lt;em&gt;Introduction to queueing theory and stochastic teletraffic models&lt;span class=&quot;math-container&quot;&gt;$^1$&lt;/span&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The aim of this textbook is to provide students with basic knowledge of stochastic models&#xA;  that may apply to telecommunications research areas, such as traffic modeling, performance&#xA;  evaluation, resource provisioning, and traffic management. These research areas are included in a field called teletraffic.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Introduction to queueing theory&lt;span class=&quot;math-container&quot;&gt;$^2$&lt;/span&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This book is one of the best introductory books in the field, the good thing about this book is, the video lectures of Prof. Cooper can be found on the net and you can easily follow the book base on the lectures.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;An introduction to queueing theory: modeling and analysis in applications&lt;span class=&quot;math-container&quot;&gt;$^3$&lt;/span&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;With an emphasis on modeling and analysis this book deals with topics such as identification of models, collection of data, and tests for stationarity and independence of observations. It provides a rigorous treatment of basic models commonly used in applications with references for advanced topics.  It gives a comprehensive discussion of statistical inference techniques usable in the modeling of queueing systems and an introduction to decision problems in their management. &lt;em&gt;The book also includes a chapter, written by computer scientists, on the use of computational tools and simulation in solving queueing theory problems.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Markov Chains: Models, Algorithms and Applications&lt;span class=&quot;math-container&quot;&gt;$^4$&lt;/span&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The mentioned two chapters are very good examples of modeling: &lt;strong&gt;Chapter 2&lt;/strong&gt; discusses the applications of continuous-time Markov chains to model queueing systems and discrete-time Markov chain for computing the PageRank, the ranking of websites on the Internet. &lt;strong&gt;Chapter 3&lt;/strong&gt; studies Markovian models for manufacturing and re-manufacturing systems and presents closed-form solutions and fast numerical algorithms for solving the captured systems.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Queues A Course in Queueing Theory&lt;span class=&quot;math-container&quot;&gt;$^5$&lt;/span&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The first three chapters focus on the needed preliminaries, including exposition distributions, Poisson processes and generating functions, renewal theory, and Markov chains,  Then, rather than switching to first-come-first-served memoryless queues here as most texts do, Haviv discusses the M/G/1 model instead of the M/M/1, and then covers priority queues. Later chapters cover the G/M/1 model, thirteen examples of continuous-time Markov processes, open networks of memoryless queues and closed networks, queueing regimes with insensitive parameters, and then concludes with two-dimensional queueing models which are quasi birth and death processes.  Each chapter ends with exercises.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;References:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Zukerman, Moshe. &quot;Introduction to queueing theory and stochastic teletraffic models.&quot; arXiv preprint arXiv:1307.2968 (2013).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Cooper, Robert B. Introduction to queueing theory. North Holland, 1981.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Bhat, U. Narayan. An introduction to queueing theory: modeling and analysis in applications. Birkhäuser, 2015.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Ching, Wai-Ki, and Michael K. Ng. &quot;Markov chains.&quot; Models, algorithms and applications (2006).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5) Haviv, Moshe. Queues: A Course in Queueing Theory. Vol. 191. Springer Science &amp;amp; Business Media, 2013.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-08-14T21:54:57.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1280" PostTypeId="2" ParentId="1275" CreationDate="2019-08-14T23:30:06.367" Score="4" Body="&lt;p&gt;I have used &lt;em&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0486477703&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Stochastic Modeling: Analysis and Simulation&lt;/a&gt;&lt;/em&gt; by Barry Nelson and found it to be a pretty gentle introduction. It covers stochastic processes, queuing, and simulation.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-08-14T23:30:06.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1281" PostTypeId="1" AcceptedAnswerId="1286" CreationDate="2019-08-15T01:59:13.373" Score="26" ViewCount="1779" Body="&lt;p&gt;In the set covering/column generation approach for the VRP (&lt;a href=&quot;https://doi.org/10.1287/opre.12.2.300&quot; rel=&quot;noreferrer&quot;&gt;Balinski and Quandt (1964)&lt;/a&gt;, or e.g. &lt;a href=&quot;https://doi.org/10.1007/s10288-010-0130-z&quot; rel=&quot;noreferrer&quot;&gt;this tutorial&lt;/a&gt;), the basic idea is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Generate some routes.&lt;/li&gt;&#xA;&lt;li&gt;Solve the set covering problem using those routes.&lt;/li&gt;&#xA;&lt;li&gt;Generate more routes (using the dual values, via the pricing problem).&lt;/li&gt;&#xA;&lt;li&gt;Go to 2.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;(Obviously I'm leaving out a lot of details.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm interested in situations where step 3 happens heuristically—either because the pricing problem can't be solved exactly (efficiently), or maybe even because the dual can't be formulated well or solved well. Presumably this would happen for VRP variants, not for the classical VRP itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Are there examples in the literature of new routes being generated heuristically? Are there standard approaches that are used?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-12-17T00:14:28.793" Title="Solving pricing problem heuristically in column generation algorithm for VRP" Tags="|reference-request|vehicle-routing|heuristics|column-generation|set-covering|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1282" PostTypeId="1" AcceptedAnswerId="1283" CreationDate="2019-08-15T05:33:45.943" Score="13" ViewCount="553" Body="&lt;p&gt;Can you help me identify if this technique has a standard name to help me explore the literature?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I have a black-box stochastic simulation parameterised by &lt;span class=&quot;math-container&quot;&gt;$X=[x_1,...,x_p]$&lt;/span&gt; with some single output measure &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and wish to minimize &lt;span class=&quot;math-container&quot;&gt;$E[y]$&lt;/span&gt; within some bounded parameter region &lt;span class=&quot;math-container&quot;&gt;$\Theta \subset \mathbb{R}^p$&lt;/span&gt;. However the simulator is computationally expensive and a limited number of runs are possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a possible method?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Produce some Latin hypercube of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; parameter points, &lt;span class=&quot;math-container&quot;&gt;$\theta_1,...,\theta_n$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Perform simulations for each parameter point &lt;span class=&quot;math-container&quot;&gt;$\theta_i$&lt;/span&gt;, each with &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; replications, resulting in &lt;span class=&quot;math-container&quot;&gt;$y_{ir}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Estimate a regression model &lt;span class=&quot;math-container&quot;&gt;$y \sim \theta$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Assumption: making &quot;predictions&quot; with this regression model is computationally efficient compared to running the original simulator)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Apply standard optimisation search methods to find &lt;span class=&quot;math-container&quot;&gt;$\theta^* \in \Theta$&lt;/span&gt; by &quot;predicting&quot; &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; using regression model (instead of simulator)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the regression model (hopefully) &quot;approximates&quot; the simulation and so optimising within the regression model (hopefully) optimises approximately within the simulation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this methods a) a good idea; b) a well recognized method; and if so c) what name does it go by in literature?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does &quot;Kriging&quot; replace the regression model? (Is the regression model a &quot;meta-model&quot;?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&#xA;So &quot;Surrogate Based Model Optimisation&quot; (SBMO) is the field I was looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Follow on question: how applicable are the methods for stochastic simulations? i.e. for fixed parameters &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; I get different results out of the simulator. The sample mean can be taken as a point estimate of the expectation but a large number of samples might be necessary to make it stable. &lt;/p&gt;&#xA;" OwnerUserId="1071" LastEditorUserId="1071" LastEditDate="2019-08-15T06:52:04.260" LastActivityDate="2019-08-15T17:56:45.133" Title="Simulation optimisation: Monte carlo simulation, regression, optimise within regression model?" Tags="|optimization|simulation|global-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1283" PostTypeId="2" ParentId="1282" CreationDate="2019-08-15T05:53:03.540" Score="11" Body="&lt;p&gt;After further reading it seems that &quot;surrogate models&quot; do exactly this (aka. &quot;meta-models&quot;), a recent discussion of methods is here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://onlinelibrary.wiley.com/doi/full/10.1111/itor.12292&quot; rel=&quot;noreferrer&quot;&gt;https://onlinelibrary.wiley.com/doi/full/10.1111/itor.12292&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also called &quot;Surrogate model-based optimisation&quot; (SMBO)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Survey of methods: &lt;a href=&quot;https://martinzaefferer.de/wp-content/uploads/2016/10/survey-1.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://martinzaefferer.de/wp-content/uploads/2016/10/survey-1.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1071" LastEditorUserId="1071" LastEditDate="2019-08-15T06:36:50.813" LastActivityDate="2019-08-15T06:36:50.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1284" PostTypeId="2" ParentId="1275" CreationDate="2019-08-15T06:11:31.997" Score="4" Body="&lt;p&gt;I enjoyed &lt;em&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/1107027500&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Performance Modeling and Design of Computer Systems: Queueing&#xA;Theory in Action&lt;/a&gt;&lt;/em&gt; (Amazon link) by &lt;a href=&quot;https://www.cs.cmu.edu/~harchol/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mor Harchol-Balter&lt;/a&gt;, which sounds&#xA;like it fits your bill pretty well. I have it on my desk.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ISBN-13: 978-1107027503&lt;/p&gt;&#xA;" OwnerUserId="1173" LastActivityDate="2019-08-15T06:11:31.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1285" PostTypeId="2" ParentId="1281" CreationDate="2019-08-15T07:55:23.397" Score="2" Body="&lt;p&gt;I found a survey paper&lt;sup&gt;1&lt;/sup&gt; that talks about the heuristics for the VRP. In page 289 it is mentioned that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This formulation was first proposed by Balinski and Quandt (1964), but becomes impractical when &lt;span class=&quot;math-container&quot;&gt;$|S|$&lt;/span&gt; is large. Agarwal et al. (1989) have used column generation to solve small instances of the VRP optimally. Heuristic rules for producing a promising subset &lt;span class=&quot;math-container&quot;&gt;$S'$&lt;/span&gt;of simple vehicle routes, called 1-petals, have been put forward by Foster and Ryan (1976) and Ryan et al. (1993). Renaud et al. (1996b) go one step further by including in &lt;span class=&quot;math-container&quot;&gt;$S'$&lt;/span&gt; not only single vehicle routes, but also configurations, called 2-petals, consisting of two embedded or intersecting routes.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;1) Classical and modern heuristics for the vehicle routing problem, &lt;em&gt;Gilbert Laporte, Michel Gendreau, Jean-Yves Potvin, Frédéric Semet&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-10-14T19:34:36.260" LastActivityDate="2019-10-14T19:34:36.260" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1286" PostTypeId="2" ParentId="1281" CreationDate="2019-08-15T08:41:24.710" Score="22" Body="&lt;p&gt;Generating routes heuristically, or &lt;em&gt;heuristic pricing&lt;/em&gt;, is very common in the vehicle routing literature. Even when the pricing problem can be solved exactly, heuristic pricing is often tried first. Only when no more routes can be generated by heuristics, the exact pricing algorithm is run. When heuristic pricing is used in this way, the overall method is still exact in the sense that the optimal solution to the problem is guaranteed to be found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For vehicle routing, the state-of-the-art is summarized in a recent survey by &lt;a href=&quot;https://doi.org/10.1287/trsc.2018.0878&quot; rel=&quot;nofollow noreferrer&quot;&gt;Costa et al. (2019)&lt;/a&gt;, see &lt;em&gt;Heuristic Pricing&lt;/em&gt; (Section 3.1.6).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Among other things, the authors list and provide references for&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Relaxing dominance rules in labeling algorithms.&lt;/li&gt;&#xA;&lt;li&gt;Heuristically reducing the size of the network.&lt;/li&gt;&#xA;&lt;li&gt;Using aggressive dominance rules in labeling algorithms.&lt;/li&gt;&#xA;&lt;li&gt;Using tabu search.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="145" LastEditorUserId="123" LastEditDate="2019-10-14T19:33:36.867" LastActivityDate="2019-10-14T19:33:36.867" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1287" PostTypeId="2" ParentId="1281" CreationDate="2019-08-15T09:38:22.603" Score="8" Body="&lt;p&gt;The general rule is to use dynamic programming (Labeling Algorithm) to solve the VRP pricing problem. It has some advantage over solving the mathematical model. DP can yield many columns in each iteration versus the one column that yielded by solving the model. As @Kevin Dalmeijer mentioned you need to be able to solve the pricing problem exactly even if you mainly use a heuristic approach. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, a constructive approach combined with a local search would do the work. I saw examples that solves the pricing problem with GRASP or Tabu Search. But if you are going to develop a branch-and-price algorithm later on you should choose a method that is compatible with the branching rule (e.g. Avoiding some edges or including certain edges in the routes). &#xA;Here are some studies that use a heuristic approach combined with DP to solve the pricing sub problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Archetti, C., Bouchard, M., &amp;amp; Desaulniers, G. (2011). Enhanced Branch and price and cut for vehicle routing with split deliveries and time windows. Transportation Science, 45(3), 285–298. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Ozbaygin, G., Karasan, O. E., Savelsbergh, M., &amp;amp; Yaman, H. (2017). A branch-and-price algorithm for the vehicle routing problem with roaming delivery locations. Transportation Research Part B: Methodological, 100, 115-137&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Dayarian, I., Crainic, T., Gendreau, M. and Rei, W. (2019). A branch-and-price approach for a multi-period vehicle routing problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Gauvin, C., Desaulniers, G., &amp;amp; Gendreau, M. (2014). A branch-cut-and-price algorithm for the vehicle routing problem with stochastic demands. Computers &amp;amp; Operations Research, 50, 141–153&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5) Dayarian, I., Crainic, T. G., Gendreau, M., &amp;amp; Rei, W. (2015b). A column generation&#xA;approach for a multi-attribute vehicle routing problem. European Journal of Operational Research, 241(3), 888–906&lt;/p&gt;&#xA;" OwnerUserId="172" LastActivityDate="2019-08-15T09:38:22.603" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1288" PostTypeId="2" ParentId="1281" CreationDate="2019-08-15T10:36:28.633" Score="6" Body="&lt;p&gt;Contrary to the other answers, I claim that you don't &lt;strong&gt;need&lt;/strong&gt; to solve the pricing problem exactly, not even as a last resort after trying heuristics.&#xA;If you &lt;em&gt;do solve&lt;/em&gt; it exactly, then you found the optimal solution (say &lt;span class=&quot;math-container&quot;&gt;$z^*_\text{LP}$&lt;/span&gt;) to the relaxed reduced master problem at the node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this is not needed: you want to use &lt;span class=&quot;math-container&quot;&gt;$z^*_\text{LP}$&lt;/span&gt; as a lower bound for the objective value at the current B&amp;amp;B node.&#xA;If you can find another lower bound, you don't need &lt;span class=&quot;math-container&quot;&gt;$z^*_\text{LP}$&lt;/span&gt; and can you use your other bound.&#xA;Perhaps your LB will be worse, which means you will be less effective at pruning your B&amp;amp;B tree, but the overall correctness of the algorithm is not affected.&#xA;In other words, exploring a B&amp;amp;B tree does not mandate that the dual bound comes from the linear relaxation of the integer programme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For VRP-like problems you can use the best column found by any pricing heuristic which solves a relaxation of the pricing problem, and plug it into  the master problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See, for example: Mauro Dell’Amico, Giovanni Righini, and Matteo Salani. &quot;&lt;a href=&quot;http://pubsonline.informs.org.sci-hub.tw/doi/abs/10.1287/trsc.1050.0118&quot; rel=&quot;nofollow noreferrer&quot;&gt;A branch-and-price approach to the vehicle routing problem with simultaneous distribution and collection.&lt;/a&gt;&quot; Transportation science 40.2 (2006): 235-247.&#xA;Section 3 in general and subsection &quot;Lower bounding and termination&quot; in particular provide a good hint on how you can use dual information from the pricing problem to provide a lower bound for the node.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2019-12-17T00:14:28.793" LastActivityDate="2019-12-17T00:14:28.793" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1289" PostTypeId="5" CreationDate="2019-08-15T12:50:58.937" Score="0" Body="&lt;p&gt;&lt;strong&gt;Application Programming Interface (API)&lt;/strong&gt;&lt;br&gt;&#xA;An API is a set of rules, procedures, or functions that enable interaction with an external user, application, operating system, or other services. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;APIs are commonly used to permit the use of particular software libraries or to access data stories in a repository. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info, see the &lt;a href=&quot;https://en.wikipedia.org/wiki/Application_programming_interface&quot; rel=&quot;nofollow noreferrer&quot;&gt;API wiki page&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="36" LastEditDate="2019-08-15T13:00:49.343" LastActivityDate="2019-08-15T13:00:49.343" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1290" PostTypeId="4" CreationDate="2019-08-15T12:50:58.937" Score="0" Body="For questions referring to an Application Programming Interface (API) that performs or used to support Operations Research or OR-related functions. Do not use this tag for a general problem with a non-OR related API. &#xD;&#xA;&#xD;&#xA;" OwnerUserId="491" LastEditorUserId="123" LastEditDate="2020-02-07T19:30:20.990" LastActivityDate="2020-02-07T19:30:20.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1292" PostTypeId="1" CreationDate="2019-08-15T14:43:06.730" Score="5" ViewCount="351" Body="&lt;p&gt;I've finished Wolsey's book on Integer programming. It's a theoretic book. &#xA;I aim to learn how the ideas presented in the book can be applied to solve &lt;strong&gt;real-world non-academic problems&lt;/strong&gt;. &#xA;I am looking for examples (codes, papers, etc.), any resource that can bridge the gap between theory and practice.&lt;/p&gt;&#xA;" OwnerUserId="1179" LastEditorUserId="1179" LastEditDate="2019-08-15T15:00:18.193" LastActivityDate="2019-08-23T17:25:07.883" Title="Bridge the gap between theory and practice in Integer Programming" Tags="|mixed-integer-programming|reference-request|integer-programming|applications|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1293" PostTypeId="2" ParentId="1292" CreationDate="2019-08-15T15:12:49.750" Score="6" Body="&lt;p&gt;Some of the problems in our repository (&lt;a href=&quot;https://docs.optaplanner.org/latestFinal/optaplanner-docs/html_single/#examplesOverview&quot; rel=&quot;noreferrer&quot;&gt;problem definitions&lt;/a&gt;, &lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/data&quot; rel=&quot;noreferrer&quot;&gt;datasets&lt;/a&gt;) are based on conversations with real-world business users or end users:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These directly:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;conference scheduling&lt;/li&gt;&#xA;&lt;li&gt;flight assignment scheduling&lt;/li&gt;&#xA;&lt;li&gt;rocktour&lt;/li&gt;&#xA;&lt;li&gt;meetingscheduling&lt;/li&gt;&#xA;&lt;li&gt;tennis&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Others indirectly, through the academic challenges that defined them (such as pas, nurserostering, course scheduling, etc IIRC)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also a bunch that we just invented out of thin air (cloud balancing, dinnerparty, etc)&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2019-08-15T15:12:49.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1295" PostTypeId="2" ParentId="1265" CreationDate="2019-08-15T16:49:18.037" Score="9" Body="&lt;p&gt;Regarding your first question, I think other answers have summed it up pretty good. Two things I would add are as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Stochastic programming models (besides chance constraint/probabilistic programming ones) allow you to correct your decision using the concept of recourse. In this idea, you have to make some decisions before the realization of uncertain parameters and some decisions after their realization (i.e., first- and second-stage decisions, respectively, in the case of two-stage models). This idea is generally absent in robust optimization as its models try to obtain one solution immune to all possible perturbations of uncertain parameters. A relatively new research area in robust optimization is adjustable robust optimization, which allows modification of some decision variables after some time (a recent survey paper is available from &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221718307264&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Stochastic programming models require knowledge about probability distribution functions of uncertain parameters. However, robust optimization models do not require such knowledge. So this situation could be used as an indication of which methodology should you use (please note the concepts of expectation and variation could not be defined without such knowledge).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Regarding your second question, scenarios used in stochastic programming or robust optimization usually comes from three sources, namely experts' opinions, historical logs of the system states over the time, or sampling of probability distribution functions governing the uncertain parameters. I think the first two could be used with both stochastic programming and robust optimization. Regarding the third option, you should note that using scenarios is an option to overcome the modeling and solution complexities arising from using discrete or continuous probability functions (e.g., making objective functions and/or feasible region non-convex, non-differentiable, and discontinuous). Other than increasing the number of decision variables and constraints, using scenarios would not result in increasing the complexity of the original deterministic model. In addition, it has been shown that stochastic programming models constructed using scenarios could become good approximations of the original stochastic programming models with discrete or continuous probability functions (see section 3.1.c of &quot;&lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4614-0237-4&quot; rel=&quot;noreferrer&quot;&gt;Introduction to Stochastic Programming&lt;/a&gt;&quot; by Birge and Louveaux for a discussion).&lt;/p&gt;&#xA;" OwnerUserId="119" LastEditorUserId="43" LastEditDate="2019-08-16T18:54:26.053" LastActivityDate="2019-08-16T18:54:26.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1296" PostTypeId="2" ParentId="1275" CreationDate="2019-08-15T16:54:16.277" Score="2" Body="&lt;p&gt;I learned from &lt;a href=&quot;https://homes.cs.washington.edu/~lazowska/qsp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quantitative System Performance&#xA;Computer System Analysis Using Queueing Network Models&lt;/a&gt; by Lazowska, et.al.  Unfortunately, it is no longer published, &lt;em&gt;but&lt;/em&gt; it is available for free online.  It may seem a bit out of date today but it is considered the classic for queueing network analysis of computer performance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does not really cover the areas of simulation much (it focuses on MVA rather than either convolution or simulation), or general operations research, but once you've read this, you should be able to easily move to and apply it to those.&lt;/p&gt;&#xA;" OwnerUserId="1040" LastActivityDate="2019-08-15T16:54:16.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1297" PostTypeId="2" ParentId="1282" CreationDate="2019-08-15T17:56:45.133" Score="6" Body="&lt;p&gt;You might want to google &quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Response_surface_methodology&quot; rel=&quot;noreferrer&quot;&gt;response surface methodology&lt;/a&gt;&quot; and &quot;simulation&quot; together. There is a ton of literature on this, a mixture of how do to response surface modeling (and how to use it to optimize system parameters) and examples of its application.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-15T17:56:45.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1298" PostTypeId="1" AcceptedAnswerId="1313" CreationDate="2019-08-15T19:19:38.140" Score="12" ViewCount="1105" Body="&lt;p&gt;I am trying to understand a problem and would like to generate all extreme rays for a given set of linear constraints. With the Python interface of CPLEX, I was able to generate a single ray (not sure if it is guaranteed to be extreme) but is there a way to get all extreme rays?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a theoretical level, I know that in my problem, 0 is always a feasible solution and if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is feasible and &lt;span class=&quot;math-container&quot;&gt;$\lambda \ge 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\lambda x$&lt;/span&gt; is feasible (I think this means that the constraints describe a pointed polyhedral cone). So as far as I understand that means that there is a ray through every feasible point. But how do I find the extreme ones out of this infinite set?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&#xA;Thanks to the helpful comments below, I learned about the double description algorithm and found implementations in &lt;a href=&quot;http://doc.sagemath.org/html/en/reference/discrete_geometry/sage/geometry/polyhedron/double_description.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;sagemath.org&lt;/a&gt; and &lt;a href=&quot;https://forum.polymake.org/viewtopic.php?t=24&quot; rel=&quot;nofollow noreferrer&quot;&gt;polymake&lt;/a&gt;. Unfortunately, I had problems with both implementations. The first could not handle a matrix with a rank smaller than the number of columns. The second returns a set of rays but I think it must be missing some because there are solutions to the original constraints that cannot be expressed as a non-negative combination of the rays. I'm not certain about using polymake correctly, so let me give an example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example (in polymake)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;math-container&quot;&gt;$inequalities=new Matrix&amp;lt;Rational&amp;gt;([&#xA;    [0, 0, 0, 0, 1, 0, 0, 0, 0],&#xA;    [0, 0, 0, 0,-1, 0, 0, 0, 0],&#xA;    [0, 1, 0, 0, 1,-1, 0, 0, 0],&#xA;    [0, 0, 1, 0, 0, 1,-1, 0, 0],&#xA;    [0, 0, 0, 1, 0, 1, 0,-1, 0],&#xA;    [0, 1, 0, 0, 0, 0, 1,-1, 0],&#xA;    [0, 0, 0, 0, 0, 0, 0, 1,-1]]);&#xA;$&lt;/span&gt;p=new Polytope&amp;lt;Rational&amp;gt;(INEQUALITIES=&amp;gt;&lt;span class=&quot;math-container&quot;&gt;$inequalities);&#xA;print_constraints($&lt;/span&gt;p-&amp;gt;INEQUALITIES);&#xA;0: x4 &amp;gt;= 0&#xA;1: -x4 &amp;gt;= 0&#xA;2: x1 + x4 - x5 &amp;gt;= 0&#xA;3: x2 + x5 - x6 &amp;gt;= 0&#xA;4: x3 + x5 - x7 &amp;gt;= 0&#xA;5: x1 + x6 - x7 &amp;gt;= 0&#xA;6: x7 - x8 &amp;gt;= 0&#xA;7: 0 &amp;gt;= -1&#xA;# All variables are general, i.e., not restricted to non-negative values.&#xA;&#xA;print $p-&amp;gt;VERTICES;&#xA;1  0  0  0  0  0  0  0  0&#xA;0  1 -1 -1  0  1  0  0  0&#xA;0  0  1  0  0  0  0  0  0&#xA;0  0  0  1  0  0  0  0  0&#xA;0  0  1  1  0 -1  0  0  0&#xA;0  1 -1  0  0  1  0  1  0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I think the first coordinate indicates whether the following row vector is an extreme point (1) or ray (0). Since this is a pointed cone, it makes sense that the only extreme point is 0 and all other rows are rays. However, I thought that every solution to the constraints should be expressible as a non-negative combination of these rows. But there are solutions with &lt;span class=&quot;math-container&quot;&gt;$x_8 = 1$&lt;/span&gt; even though all rays have &lt;span class=&quot;math-container&quot;&gt;$x_8 = 0$&lt;/span&gt;. For example, &lt;span class=&quot;math-container&quot;&gt;$(1, 0, 0, 0, 1, 1, 1, 1)$&lt;/span&gt; should be a solution. Can someone help me understand this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Second Edit&lt;/strong&gt;&#xA;The trick with polymake was that rays &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$-r$&lt;/span&gt; are extreme rays are not part of &lt;code&gt;RAYS&lt;/code&gt;. Instead they are given as &lt;code&gt;LINEALITY_SPACE&lt;/code&gt;. Including them and their negative values gave me the answer I was looking for.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print $p-&amp;gt;LINEALITY_SPACE;&#xA;0 -1 2 1 0 -1 1 0 0&#xA;0 1/2 0 1/2 0 1/2 1/2 1 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1180" LastEditorUserId="1180" LastEditDate="2019-08-19T08:34:28.843" LastActivityDate="2021-08-18T14:39:54.450" Title="Generating all extreme rays" Tags="|linear-programming|cplex|extreme-rays|unboundedness|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1299" PostTypeId="1" AcceptedAnswerId="1314" CreationDate="2019-08-16T09:54:33.600" Score="9" ViewCount="830" Body="&lt;p&gt;I am looking for a publicly available real world demand data to compare the performance of some algorithms. The dataset should include some products with data of a sufficiently long period of time. I know the &lt;a href=&quot;http://pentaho.dlpage.phi-integration.com/mondrian/mysql-foodmart-database&quot; rel=&quot;noreferrer&quot;&gt;FoodMart&lt;/a&gt; dataset, whose structure you can find described on &lt;a href=&quot;https://github.com/julianhyde/foodmart-data-hsqldb&quot; rel=&quot;noreferrer&quot;&gt;this page&lt;/a&gt;; but, this dataset includes a small number of records per product so that it is not suitable for my purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appreciate any link to such dataset or papers which have made their dataset publicly available.&lt;/p&gt;&#xA;" OwnerUserId="41" LastEditorUserId="38" LastEditDate="2019-08-16T14:28:23.680" LastActivityDate="2019-08-17T15:21:14.133" Title="Real world demand dataset" Tags="|online-resources|data|demand-distribution|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="1300" PostTypeId="1" AcceptedAnswerId="1302" CreationDate="2019-08-16T14:51:35.610" Score="12" ViewCount="635" Body="&lt;p&gt;How to express a chain of &lt;strong&gt;OR&lt;/strong&gt; operations in an ILP in which each expression is a less than or equal constraint and the left hand side variable in all inequalities is always the same? All the variables are binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I would like to express &lt;span class=&quot;math-container&quot;&gt;$x_1 \leq x_3$&lt;/span&gt; OR &lt;span class=&quot;math-container&quot;&gt;$x_1 \leq x_4$&lt;/span&gt; OR &lt;span class=&quot;math-container&quot;&gt;$x_1 \leq x_6$&lt;/span&gt;. Notice the first variable in all the inequality constraints is &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="39" LastEditDate="2019-08-16T15:18:05.623" LastActivityDate="2019-08-16T19:14:57.053" Title="Expressing a chain of boolean ORs using ILP" Tags="|optimization|modeling|integer-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1301" PostTypeId="2" ParentId="1300" CreationDate="2019-08-16T15:20:20.637" Score="9" Body="&lt;p&gt;Your example constraint is equivalent to &lt;span class=&quot;math-container&quot;&gt;$x_1 \le \text{max}(x_3,x_4,x_6)$&lt;/span&gt;, which I will generalize to &lt;span class=&quot;math-container&quot;&gt;$x_1 \le \max(x_2,\ldots,x_n)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This max can be handled using section 2.6 &quot;Logical OR&quot; of &lt;a href=&quot;https://www.fico.com/en/resource-download-file/3217&quot; rel=&quot;nofollow noreferrer&quot;&gt;FICO MIP formulations and linearizations: Quick reference&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, introduce a binary variable, &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;, to be constrained as follows so that it will be equal to &lt;span class=&quot;math-container&quot;&gt;$\text{max}(x_2,\ldots,x_n)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}d &amp;amp;\ge x_i, \quad i=2,\ldots, n\\d &amp;amp;\le \sum\limits_{i=2}^n x_i\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now add the constraint: &lt;span class=&quot;math-container&quot;&gt;$x_1 \le d$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="145" LastEditDate="2019-08-16T17:36:57.230" LastActivityDate="2019-08-16T17:36:57.230" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1302" PostTypeId="2" ParentId="1300" CreationDate="2019-08-16T17:01:12.247" Score="16" Body="&lt;p&gt;Derivation via conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;x_1 \implies \underset{i=2}{\overset n{\lor}} x_i \\&#xA;\neg x_1 \bigvee \underset{i=2}{\overset n{\lor}} x_i \\&#xA;1 - x_1 + \sum_{i=2}^n x_i \ge 1 \\&#xA;x_1 \le \sum_{i=2}^n x_i&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="123" LastEditDate="2019-08-16T19:14:57.053" LastActivityDate="2019-08-16T19:14:57.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1303" PostTypeId="2" ParentId="1298" CreationDate="2019-08-16T19:19:49.473" Score="11" Body="&lt;p&gt;I'm assuming that your variables (&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;) are nonnegative. If you take a cross-section of the cone by adding a constraints such as &lt;span class=&quot;math-container&quot;&gt;$\sum_i x_i = 1$&lt;/span&gt;, you get a polytope, and I believe that there is a 1-1 correspondence between extreme rays of the original cone and extreme points of the polytope. IIRC, there are programs for computing all extreme points of a polytope. You can also try a Monte Carlo approach, which will not provably find all of them but will likely find most if not all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the Monte Carlo approach on your algebraic representation (constraints 0 through 6) above. What I did was minimize a randomly weighted combination of the variables, then maximize the same weighted sum, then repeat with new weights, until a certain number of consecutive LPs had been solved without finding a new solution. (I set the limit as 1,000 consecutive failures. CPLEX hit the limit after solving 1,370 LPs in under a second. Using this method, I found what I believe are 16 extreme rays:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;[0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;[0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0]&#xA;[0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0]&#xA;[0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0]&#xA;[1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;[1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]&#xA;[1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0]&#xA;[1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0]&#xA;[1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0]&#xA;[1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0]&#xA;[1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]&#xA;[1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0]&#xA;[1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0]&#xA;[1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 2.0, 0.0]&#xA;[1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 2.0, 2.0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cranking the failure limit to 10,000 did not alter the results (and, somewhat scarily, still only needed about a second, with output turned off).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-16T19:19:49.473" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1304" PostTypeId="1" CreationDate="2019-08-16T23:29:13.290" Score="45" ViewCount="5817" Body="&lt;p&gt;I am looking for previous OR challenges.&lt;/p&gt;&#xA;&lt;p&gt;My goal is :&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Applying my knowledge while solving problems suggested in those competitions; and/or&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If possible, reading solutions posted by participants.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I learned a lot about machine learning (ML) by reading solutions to &lt;a href=&quot;https://www.kaggle.com/competitions&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kaggle competitions&lt;/a&gt;. I couldn't find any similar website for OR problems. It seems that the ML hype is eating up everything.&lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="491" LastEditDate="2022-04-06T20:31:16.347" LastActivityDate="2022-04-06T20:31:16.347" Title="Are there any OR challenges that are similar to Kaggle's competitions?" Tags="|online-resources|applications|" AnswerCount="12" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1305" PostTypeId="2" ParentId="1304" CreationDate="2019-08-16T23:33:24.553" Score="13" Body="&lt;p&gt;Here is a link to INFORMS OR and analytics students team competition. You can also find the challenges for previous years and the presentations of the winner team. I believe you need to be registered in INFORMS in order to get the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://connect.informs.org/oratc/home&quot; rel=&quot;noreferrer&quot;&gt;https://connect.informs.org/oratc/home&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: in &lt;a href=&quot;http://orchallenge.org/&quot; rel=&quot;noreferrer&quot;&gt;The Operation Research Challenge&lt;/a&gt; (TORCH)'s website, you can find the challenges and required data as well.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-08-17T00:36:36.327" LastActivityDate="2019-08-17T00:36:36.327" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1306" PostTypeId="2" ParentId="1304" CreationDate="2019-08-17T04:51:45.637" Score="16" Body="&lt;p&gt;The French OR society has some interesting OR challenges &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.roadef.org/challenge/2018/en/index.php&quot; rel=&quot;noreferrer&quot;&gt;http://www.roadef.org/challenge/2018/en/index.php&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="117" LastActivityDate="2019-08-17T04:51:45.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1307" PostTypeId="2" ParentId="1304" CreationDate="2019-08-17T07:29:51.057" Score="16" Body="&lt;p&gt;&lt;a href=&quot;https://codingcompetitions.withgoogle.com/hashcode&quot; rel=&quot;noreferrer&quot;&gt;Google Hashcode&lt;/a&gt; had some optimization challenges in the past. Problem definitions and data from previous years can be found &lt;a href=&quot;https://codingcompetitions.withgoogle.com/hashcode/archive&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="47" LastActivityDate="2019-08-17T07:29:51.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1308" PostTypeId="2" ParentId="1304" CreationDate="2019-08-17T08:12:41.027" Score="28" Body="&lt;p&gt;The &lt;em&gt;Helmut Schmidt Universitat&lt;/em&gt; contains a list of past, ongoing, and future contests in Operations Research.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://www.hsu-hh.de/logistik/research/challenges&quot; rel=&quot;noreferrer&quot;&gt;https://www.hsu-hh.de/logistik/research/challenges&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Active challenges: &lt;a href=&quot;https://www.itc2019.org/home#overview&quot; rel=&quot;noreferrer&quot;&gt;ITC 2019&lt;/a&gt; on finding feasible solutions for organising student rooms and times.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Past challenges: &lt;a href=&quot;https://pacechallenge.wordpress.com/pace-2018/&quot; rel=&quot;noreferrer&quot;&gt;PACE 2018&lt;/a&gt; on Steiner trees on an undirected edge-weighted graph&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;They are a considerable number of links to past events, though some of them have already been introduced in other answers, such as ROADEF.&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-08-17T08:12:41.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1309" PostTypeId="2" ParentId="1304" CreationDate="2019-08-17T08:19:18.147" Score="20" Body="&lt;p&gt;I personally like &lt;a href=&quot;https://projecteuler.net/&quot; rel=&quot;noreferrer&quot;&gt;Project Euler&lt;/a&gt;. This website has mathematical problems that usually require programming to solve them. If you solve a problem you get access to the corresponding problem forum, in which users post their code and discuss their approaches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Admittedly, I consider Project Euler to be more about mathematics and computer science than about Operations Research. Still, there are plenty of problems that involve optimization, or to which OR techniques can be applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest the following problems for those with OR skills. Whether these problems are really OR is of course debatable, and the list is non-exhaustive: Problem &lt;a href=&quot;https://projecteuler.net/problem=11&quot; rel=&quot;noreferrer&quot;&gt;11&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=18&quot; rel=&quot;noreferrer&quot;&gt;18&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=67&quot; rel=&quot;noreferrer&quot;&gt;67&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=68&quot; rel=&quot;noreferrer&quot;&gt;68&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=81&quot; rel=&quot;noreferrer&quot;&gt;81&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=82&quot; rel=&quot;noreferrer&quot;&gt;82&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=83&quot; rel=&quot;noreferrer&quot;&gt;83&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=84&quot; rel=&quot;noreferrer&quot;&gt;84&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=96&quot; rel=&quot;noreferrer&quot;&gt;96&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=122&quot; rel=&quot;noreferrer&quot;&gt;122&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=149&quot; rel=&quot;noreferrer&quot;&gt;149&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=185&quot; rel=&quot;noreferrer&quot;&gt;185&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=190&quot; rel=&quot;noreferrer&quot;&gt;190&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=280&quot; rel=&quot;noreferrer&quot;&gt;280&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=345&quot; rel=&quot;noreferrer&quot;&gt;345&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=392&quot; rel=&quot;noreferrer&quot;&gt;392&lt;/a&gt;, &lt;a href=&quot;https://projecteuler.net/problem=460&quot; rel=&quot;noreferrer&quot;&gt;460&lt;/a&gt;, and &lt;a href=&quot;https://projecteuler.net/problem=607&quot; rel=&quot;noreferrer&quot;&gt;607&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-08-17T08:19:18.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1310" PostTypeId="2" ParentId="1304" CreationDate="2019-08-17T09:19:13.627" Score="15" Body="&lt;p&gt;There is a &lt;a href=&quot;http://coral.ie.lehigh.edu/~mopta/competition&quot; rel=&quot;noreferrer&quot;&gt;competition section&lt;/a&gt; held during &lt;a href=&quot;http://coral.ie.lehigh.edu/~mopta/&quot; rel=&quot;noreferrer&quot;&gt;MOPTA&lt;/a&gt; (Modeling and Optimization: Theory and Applications), which is organized annually by Lehigh University. The competition is for students only and usually devoted to a practical problem and sponsored by a solver company.&lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2019-08-17T09:19:13.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1311" PostTypeId="2" ParentId="1304" CreationDate="2019-08-17T12:04:18.993" Score="15" Body="&lt;p&gt;And we also have the &lt;a href=&quot;http://dimacs.rutgers.edu/programs/challenge/&quot; rel=&quot;noreferrer&quot;&gt;DIMACS implementation challenges&lt;/a&gt;  #ofcourse &lt;/p&gt;&#xA;" OwnerUserId="429" LastActivityDate="2019-08-17T12:04:18.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1312" PostTypeId="2" ParentId="1032" CreationDate="2019-08-17T12:12:55.153" Score="8" Body="&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/APOPT&quot; rel=&quot;noreferrer&quot;&gt;APOPT&lt;/a&gt; is another NLP (and MINLP) solver that works with Pyomo by reading &lt;code&gt;.nl&lt;/code&gt; files and producing &lt;code&gt;.sol&lt;/code&gt; files. The solver is &lt;code&gt;apopt.py&lt;/code&gt; and called with Python to send the &lt;code&gt;.nl&lt;/code&gt; file to a compute server and then return the &lt;code&gt;.sol&lt;/code&gt; file back to Python and returned to Pyomo. Here is the &lt;a href=&quot;https://github.com/APMonitor/apopt/&quot; rel=&quot;noreferrer&quot;&gt;source code on GitHub&lt;/a&gt; with instructions on use. Please note that we are still developing this solver and I'd appreciate any feedback on the performance. Here are some &lt;a href=&quot;https://apm.byu.edu/prism/uploads/Members/minlp_apopt_informs2012.pdf&quot; rel=&quot;noreferrer&quot;&gt;benchmark results that we shared in 2012 at INFORMS&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nKpaF.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nKpaF.png&quot; alt=&quot;NLP Benchmark Results&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1184" LastActivityDate="2019-08-17T12:12:55.153" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1313" PostTypeId="2" ParentId="1298" CreationDate="2019-08-17T14:49:12.043" Score="11" Body="&lt;p&gt;What is the dimension of your set? If it is not &amp;quot;too big&amp;quot; then you should be googling &amp;quot;double description algorithm&amp;quot;. A list of codes that do polyhedral computation is at: &lt;a href=&quot;https://www.cs.mcgill.ca/%7Efukuda/soft/polyfaq/node41.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.cs.mcgill.ca/~fukuda/soft/polyfaq/node41.html&lt;/a&gt;. If the dimension is large, then you probably can't enumerate all extreme rays, there are likely to be too many unless your set is specially-structured.&lt;/p&gt;&#xA;" OwnerUserId="34" LastEditorUserId="123" LastEditDate="2021-08-18T14:39:54.450" LastActivityDate="2021-08-18T14:39:54.450" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1314" PostTypeId="2" ParentId="1299" CreationDate="2019-08-17T15:13:34.800" Score="9" Body="&lt;h1&gt;Time Series Data Library&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://pkg.yangzhuoranyang.com/tsdl/&quot; rel=&quot;noreferrer&quot;&gt;time series data library&lt;/a&gt; from &lt;a href=&quot;https://robjhyndman.com/&quot; rel=&quot;noreferrer&quot;&gt;Rob Hyndman&lt;/a&gt; has hundreds (~648+) of time-series data. It depends on what you call &quot;&lt;em&gt;demand&lt;/em&gt;&quot; and what you require as a &quot;&lt;em&gt;sufficiently long period of time&lt;/em&gt;.&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The entire dataset has been migrated to an R package called &lt;strong&gt;tsdl&lt;/strong&gt;. It is also available on &lt;a href=&quot;https://github.com/FinYang/tsdl&quot; rel=&quot;noreferrer&quot;&gt;GitHub&lt;/a&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find descriptions of the data in the &lt;a href=&quot;https://pkg.yangzhuoranyang.com/tsdl/reference/meta_tsdl.html&quot; rel=&quot;noreferrer&quot;&gt;meta data&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Select examples:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&quot;Monthly demand repair parts large/heavy equip. Iowa 1972 – 1979&quot;&lt;/strong&gt;&lt;br&gt;&#xA;&lt;strong&gt;&quot;Montly av. residential gas usage Iowa (cubic feet)*100 ’71 – ’79&quot;&lt;/strong&gt;&lt;br&gt;&#xA;&lt;strong&gt;&quot;Monthly gasoline demand Ontario gallon millions 1960 – 1975&quot;&lt;/strong&gt;&lt;br&gt;&#xA;&quot;Monthly sales of U.S. houses (thousands) 1965 – 1975&quot;&lt;br&gt;&#xA;&lt;strong&gt;&quot;Monthly Av. residential electricity usage Iowa city 1971 – 1979&quot;&lt;/strong&gt;&lt;br&gt;&#xA;&lt;strong&gt;&quot;Monthly car sales in Quebec 1960-1968&quot;&lt;/strong&gt;&lt;br&gt;&#xA;&quot;Monthly U.S. housing starts (privately owned 1-family) 1965 – 1975&quot;&lt;br&gt;&#xA;&quot;Four-weekly totals of beer shipments&quot;&lt;br&gt;&#xA;&quot;Annual unit price of lynx pelts (Hudson’s Bay company, Canada) 1857 – 1911&quot;&lt;br&gt;&#xA;&quot;Annual yield of straw on Broadbalk field at Rothamsted 1852-1925&quot;&lt;br&gt;&#xA;&quot;Basic quarterly iron production in Australia: thousand tonnes. Mar 1956 – Sep 1994&quot;&lt;br&gt;&#xA;&quot;Monthly beer production in Australia: megalitres.&quot;&lt;br&gt;&#xA;&quot;Quarterly beer production in Australia: megalitres. March 1956 – June 1994&quot; &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There is another way to see data descriptions: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/FinYang/tsdl/tree/master/data-raw&quot; rel=&quot;noreferrer&quot;&gt;raw data&lt;/a&gt; is also available. If you &lt;a href=&quot;https://github.com/FinYang/tsdl/tree/master/data-raw/monthly&quot; rel=&quot;noreferrer&quot;&gt;drill down&lt;/a&gt;, there is a &lt;strong&gt;&lt;em&gt;README.txt&lt;/em&gt;&lt;/strong&gt; for each one (e.g. example for &lt;a href=&quot;https://github.com/FinYang/tsdl/tree/master/data-raw/monthly&quot; rel=&quot;noreferrer&quot;&gt;&quot;monthly&quot;&lt;/a&gt;). These text files are viewable on GitHub in your browser. &lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-08-17T15:21:14.133" LastActivityDate="2019-08-17T15:21:14.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1315" PostTypeId="2" ParentId="1304" CreationDate="2019-08-17T15:27:54.610" Score="12" Body="&lt;p&gt;&lt;strong&gt;Simulation&lt;/strong&gt;&lt;br&gt;&#xA;The simulation-software company &lt;a href=&quot;https://www.simio.com/index.php&quot; rel=&quot;noreferrer&quot;&gt;Simio&lt;/a&gt; holds an annual &lt;a href=&quot;https://www.simio.com/academics/student-competition.php&quot; rel=&quot;noreferrer&quot;&gt;student competition&lt;/a&gt;.&lt;br&gt;&#xA;&lt;a href=&quot;https://www.arenasimulation.com/&quot; rel=&quot;noreferrer&quot;&gt;Arena&lt;/a&gt; has &lt;a href=&quot;https://www.arenasimulation.com/academic/iie-arena-student-competition&quot; rel=&quot;noreferrer&quot;&gt;one also&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Forecasting&lt;/strong&gt;&lt;br&gt;&#xA;There are the &lt;a href=&quot;https://en.wikipedia.org/wiki/Makridakis_Competitions&quot; rel=&quot;noreferrer&quot;&gt;Makridakis Competitions&lt;/a&gt;, though they are infrequent. &lt;strong&gt;M-4&lt;/strong&gt; is just now getting finalized. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Optimization&lt;/strong&gt;&lt;br&gt;&#xA;List of &lt;a href=&quot;https://www.hsu-hh.de/logistik/research/challenges&quot; rel=&quot;noreferrer&quot;&gt;active &amp;amp; historical competitions&lt;/a&gt;. (&lt;a href=&quot;https://or.stackexchange.com/a/1308/491&quot;&gt;as mentioned&lt;/a&gt;)&lt;br&gt;&#xA;&lt;a href=&quot;https://gocompetition.energy.gov/challenges&quot; rel=&quot;noreferrer&quot;&gt;Grid Optimization competition&lt;/a&gt;.&lt;br&gt;&#xA;&lt;a href=&quot;https://bbcomp.ini.rub.de/&quot; rel=&quot;noreferrer&quot;&gt;Black Box Optimization competition&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-08-17T15:35:06.333" LastActivityDate="2019-08-17T15:35:06.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1316" PostTypeId="1" AcceptedAnswerId="1317" CreationDate="2019-08-17T15:42:32.573" Score="13" ViewCount="890" Body="&lt;p&gt;I want to represent the indicator function:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$  \mathbb{1}_{(y=j)}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a non negative, integer variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My attempt is as follows: define a binary variable:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_j =\begin{cases}&#xA;1 \qquad\text{if $y=j$} \\&#xA;0 \qquad\text{otherwise}&#xA;\end{cases} $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the model of the indicator function would be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j=0}^{n} z_j = 1&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j=0}^{n} j \cdot z_j = y&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is an upper bound for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, this can be conveniently modeled in OPL Cplex (for example) using &lt;em&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.2/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/indicator_constr/04_Interactive.html&quot; rel=&quot;noreferrer&quot;&gt;indicator constraints&lt;/a&gt;&lt;/em&gt; such as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;forall(j in 0..n){&#xA;    (y == j) == (z[j] == 1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;QUESTIONS:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;is my binary-variables-based formulation attempt correct? Do you know better (performance wise) formulations?&lt;/li&gt;&#xA;&lt;li&gt;in a hypothetical academic journal paper, is the second formulation (based on indicator constraints) acceptable? If yes, how would you formally express it in the paper in a way that is implementation-independent (that is, in a way that does not depend upon how a specific solver models such a constraint)? Or it is better to provide the more general, binary-variables-based formulation?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot.&lt;/p&gt;&#xA;" OwnerUserId="459" LastActivityDate="2019-08-17T16:34:08.983" Title="Representing an indicator function: binary variables and &quot;indicator constraints&quot;" Tags="|modeling|cplex|academia|binary-variable|indicator-constraints|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1317" PostTypeId="2" ParentId="1316" CreationDate="2019-08-17T16:34:08.983" Score="7" Body="&lt;p&gt;First question: Yes, your algebraic formulation is correct. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second question: I would lean toward using the algebraic formulation, for two reasons. First, it is not solver-specific. Second, a reader not familiar with indicator constraints will find interpreting the algebraic formulation a bit easier, while a reader familiar with indicators is not likely to find the algebraic formulation much harder. That said, it would not hurt to mention in the paper that the constraint can be implemented by indicators in a solver that supports them (or, if your computational results were produced using CPLEX and you used indicators, just say that in the section describing the experiments).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-17T16:34:08.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1318" PostTypeId="1" CreationDate="2019-08-17T17:41:47.113" Score="12" ViewCount="1002" Body="&lt;p&gt;After carefully reading the answers to my &lt;a href=&quot;https://or.stackexchange.com/questions/1117/deploying-or-solutions-and-shipping-projects&quot;&gt;previous post&lt;/a&gt; I decided to opt for developing and deploying an app as a web service.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I watched a &lt;a href=&quot;https://www.gurobi.com/resource/gurobi-optimization-application-demos/&quot; rel=&quot;noreferrer&quot;&gt;talk&lt;/a&gt; on optimization apps. It suggests using the following architecture to build a &lt;a href=&quot;http://demos.gurobi.com/cutstock&quot; rel=&quot;noreferrer&quot;&gt;Cutting Stock&lt;/a&gt; app - you need an account to try it : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/exOGY.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/exOGY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4m8Os.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4m8Os.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Several frameworks/tools were mentioned : React, NodeJs, MongoDB, Redis, WebSockets, AWS (and similar cloud services), Docker, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But since I dont't have any background in CS (except for some coding), I am struggling a lot. Thus, I have several questions : &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there any way to make the architecture simpler. My goal is to build &quot;prototype&quot; apps to add in my portfolio/resume as a student (not to be deployed at a large scale). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Depending on the architecture you will suggest, how to learn about the whole stack without going too deep, just enough to develop and deploy basic apps that are similar to what is presented in the talk ? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Assuming that I want to use an open-source solver (Cbc, Clp) instead of Gurobi, what do I need to do to make the app available on the web, do you I need to use AWS (or a similar cloud service). But, is it cost-effective ? Any alternatives ? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1187" LastEditorUserId="1188" LastEditDate="2019-08-17T18:52:50.157" LastActivityDate="2022-10-19T15:49:20.973" Title="How to choose an architecture for an OR web app and how to learn the tech stack associated?" Tags="|applications|software|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1319" PostTypeId="1" AcceptedAnswerId="1321" CreationDate="2019-08-17T20:40:01.150" Score="16" ViewCount="1683" Body="&lt;p&gt;Suppose I'm modeling a problem where I want to compute the start time bucket for some jobs. All time buckets have equal duration. There are some additional constraints involved but I also have to model some precedence constraints for certain jobs.&lt;br&gt;&#xA;Due to the rest of the model I have to use binary variables &lt;span class=&quot;math-container&quot;&gt;$s_{jt}$&lt;/span&gt; that are 1 if job &lt;span class=&quot;math-container&quot;&gt;$j\in J$&lt;/span&gt; starts in time bucket &lt;span class=&quot;math-container&quot;&gt;$t\in T$&lt;/span&gt;. Suppose I furthermore have a set &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; of tuples of jobs &lt;span class=&quot;math-container&quot;&gt;$(j_1, j_2)\in P\subset J\times J$&lt;/span&gt; for which the second has to start after the first is finished. Each job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; has duration &lt;span class=&quot;math-container&quot;&gt;$d_j$&lt;/span&gt;, i.e the number of time buckets that are needed to finish the job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how to model the precedence constraint using the above variables (plus maybe some additional ones) in the most efficient and/or effective way. Meaning I'm interested in the smallest formulation but also in the formulation that gives the tightest bound, respectively the fastest solving times when solved with a MIP solver.&lt;/p&gt;&#xA;" OwnerUserId="137" LastActivityDate="2019-08-26T18:42:20.173" Title="Best model for precedence constraints within scheduling problem" Tags="|mixed-integer-programming|modeling|scheduling|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1320" PostTypeId="2" ParentId="1319" CreationDate="2019-08-17T20:54:52.267" Score="11" Body="&lt;p&gt;A straightforward formulation that suffices is to impose conflict constraints of the form &lt;span class=&quot;math-container&quot;&gt;$$s_{j_1,t_1}+s_{j_2,t_2}\le 1$$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$t_1+d_1&amp;gt;t_2$&lt;/span&gt;, but you can strengthen that to &lt;span class=&quot;math-container&quot;&gt;$$\sum_{t\ge t_1}s_{j_1,t}+\sum_{t\le t_2}s_{j_2,t}\le 1.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-08-17T20:54:52.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1321" PostTypeId="2" ParentId="1319" CreationDate="2019-08-17T21:25:19.340" Score="14" Body="&lt;p&gt;Can you change the meaning of your variables? A classic trick when you have a lot of precedences is to use the &lt;em&gt;by&lt;/em&gt; formulation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$s'_{jt}$&lt;/span&gt; be 1 if job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; starts &lt;em&gt;by&lt;/em&gt; time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; (i.e. at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; or before). In that case, your precedence constraint can be formulated as &#xA;&lt;span class=&quot;math-container&quot;&gt;$$s'_{j_2,t} \leq s'_{j_1,t-d_1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that you can do a change of variables (&lt;span class=&quot;math-container&quot;&gt;$s_{j,1}=s'_{j,1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s_{j,t} =s'_{j,t}-s'_{j,t-1}$&lt;/span&gt;) to write the remaining constraints with these new variables. You also need to add constraints &lt;span class=&quot;math-container&quot;&gt;$s'_{j,t}\leq s'_{j,t+1}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This usually provide a very tight bound, specially if the number of precedence constraints is very large and the additional constraints are just a few (see &lt;a href=&quot;http://dx.doi.org/10.1007/s10589-017-9946-1&quot; rel=&quot;noreferrer&quot;&gt;[1]&lt;/a&gt;). &lt;/p&gt;&#xA;" OwnerUserId="73" LastEditorUserId="73" LastEditDate="2019-08-17T21:39:46.983" LastActivityDate="2019-08-17T21:39:46.983" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1323" PostTypeId="1" CreationDate="2019-08-18T02:11:01.850" Score="5" ViewCount="581" Body="&lt;p&gt;I was wondering if you could refer me to some online video/text resources to learn linear and integer programming. I am intending to work in the field of data science. I greatly appreciate your kind help. Have a good evening! &lt;/p&gt;&#xA;" OwnerUserId="1190" LastEditorUserId="196" LastEditDate="2019-08-18T02:36:16.957" LastActivityDate="2019-08-18T15:39:13.797" Title="Linear and Integer programming materials" Tags="|linear-programming|reference-request|integer-programming|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="1324" PostTypeId="2" ParentId="1323" CreationDate="2019-08-18T15:05:52.667" Score="11" Body="&lt;p&gt;Since you mentioned videos, I would suggest checking &lt;a href=&quot;https://www.coursera.org/&quot; rel=&quot;noreferrer&quot;&gt;Coursera&lt;/a&gt; and &lt;a href=&quot;https://www.edx.org/&quot; rel=&quot;noreferrer&quot;&gt;edX&lt;/a&gt; for free MOOCs (such as the &lt;a href=&quot;https://www.edx.org/course/deterministic-optimization-0&quot; rel=&quot;noreferrer&quot;&gt;Deterministic Optimization&lt;/a&gt; course on edX or the &lt;a href=&quot;https://www.coursera.org/learn/discrete-optimization&quot; rel=&quot;noreferrer&quot;&gt;Discrete Optimization&lt;/a&gt; course on Coursera). The Coursera site in particular has a nice search engine that makes finding courses easy. I have not done any of the optimization courses there, but I have done a couple of the analytics courses, and liked them greatly.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-18T15:05:52.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1325" PostTypeId="2" ParentId="1323" CreationDate="2019-08-18T15:39:13.797" Score="9" Body="&lt;p&gt;In addition to the online courses that &lt;em&gt;prubin&lt;/em&gt; mentioned, I can recommend the &lt;a href=&quot;https://lagunita.stanford.edu/courses/Engineering/CVX101/Winter2014/about&quot; rel=&quot;noreferrer&quot;&gt;Convex Optimization&lt;/a&gt; online course from Stanford University with the following features:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The course is very helpful and free.&lt;/li&gt;&#xA;&lt;li&gt;The textbook is also freely available on the website.&lt;/li&gt;&#xA;&lt;li&gt;There are quizzes in the MOOC which help your learning process.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-08-18T15:39:13.797" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1326" PostTypeId="2" ParentId="1278" CreationDate="2019-08-19T03:04:07.480" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How do solvers like CPLEX/GUROBI use warm start with the Simplex algorithm?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For proprietary closed sourced programs we have to rely on the explanation offered in the documentation. For an open source solver, such as &lt;a href=&quot;https://github.com/coin-or/SYMPHONY/wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;Symphony&lt;/a&gt;, explanations of their methodology are offered. Questions about proprietary software can be asked about on our &lt;a href=&quot;https://reverseengineering.stackexchange.com/help/on-topic&quot;&gt;Reverse Engineering.SE&lt;/a&gt; site if you need information beyond what is available in the documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Symphony uses an alternative definition &lt;a href=&quot;https://en.wikipedia.org/wiki/Duality_gap&quot; rel=&quot;nofollow noreferrer&quot;&gt;duality gap&lt;/a&gt; to describe the distance between a solution offered from one run and a true optimal solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the assistance of &lt;a href=&quot;https://link.springer.com/article/10.1007/s10479-006-0058-z&quot; rel=&quot;nofollow noreferrer&quot;&gt;Saltzman and Wiecek&lt;/a&gt; Symphony developers created an algorithm for determining all Pareto outcomes for a bicriteria MILP by solving a sequence of related ILPs that is asymptotically optimal. In addition warm starting can be used to improve efficiency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bicriteria MILPs&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The general form of a bicriteria (pure) ILP is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{}\max&amp;amp;\{cx, dx\}\\&#xA;\text{s.t.} &amp;amp; Ax \le b,\\&#xA;&amp;amp; x \in \Bbb Z^n.\end{array}&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Solutions don’t have single objective function values, but pairs of values called outcomes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A feasible &lt;span class=&quot;math-container&quot;&gt;$\hat{x}$&lt;/span&gt; is called &lt;em&gt;efficient&lt;/em&gt; if there is no feasible &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$c\bar{x}\ge c\hat{x}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d\bar{x}\ge d\hat{x}$&lt;/span&gt;, with at least one inequality strict.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The outcome corresponding to an efficient solution is called Pareto.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The goal of a bicriteria ILP is to enumerate Pareto outcomes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To allow resolving from a warm start, they defined a warm start class, which is derived from CoinWarmStart. The class stores a snapshot of the search tree, in a compact form by storing the node descriptions as differences from the parent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For closed source programs the explanation of the exact algorithm isn't available publically.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/analytics/cplex-optimizer&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;CPLEX&lt;/strong&gt;&lt;/a&gt; - &lt;a href=&quot;https://webcache.googleusercontent.com/search?q=cache:axdLuOk1NFYJ:https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.2/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/mip/para/49_mipStarts.html%20&amp;amp;cd=1&amp;amp;hl=en&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Starting from a solution: MIP starts&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Documents advanced starts; also known as warm starts or MIP starts.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When you are solving a mixed integer programming problem (MIP), you can supply hints to help CPLEX find an initial solution. These hints consist of pairs of variables and values, known as a MIP start, an advanced start, or a warm start. A MIP start might come from a different problem you have previously solved or from your knowledge of the problem, for example. You can also provide CPLEX with one or more MIP starts, that is, multiple MIP starts.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A MIP start may be a feasible solution of the model, but it need not be; it may even be infeasible or incomplete. If you are interested in debugging an infeasible MIP start, that is, if you want to discover why CPLEX regards the model inferred from the pairs of variables and values in a MIP start as infeasible, consider using the conflict refiner on that model inferred from that MIP start, as explained in &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.1/ilog.odms.cplex.help/CPLEX/UsrMan/topics/infeas_unbd/conflict_refiner/22_MIPstart.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Refining a conflict in a MIP start&lt;/a&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Using a MIP start&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When you provide a MIP start as data, &lt;strong&gt;CPLEX processes it before starting branch and cut during an optimization. If one or more of the MIP starts define a solution, CPLEX installs the best of these solutions as the incumbent solution. Having an incumbent from the very beginning of branch and cut allows CPLEX to eliminate portions of the search space and thus may result in smaller branch-and-cut trees. Having an incumbent also allows CPLEX to use heuristics which require an incumbent, such as relaxation induced neighborhood search (RINS heuristic) or solution polishing.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Gurobi&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/examples/mip_starts.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;MIP starts&lt;/strong&gt;&lt;/a&gt; - Example: facility&lt;br&gt;&#xA;  A MIP modeler often knows how to compute a feasible solution to their problem. In cases where the MIP solver is slow in finding an initial feasible solution, it can be helpful for the modeler to provide a feasible solution along with the model itself. This is done through the Start attribute on the variables. &lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Variable Attribute: &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/start.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Start&lt;/strong&gt;&lt;/a&gt;, Type: double, Modifiable: Yes&lt;br&gt;&#xA;  The current MIP start vector. The MIP solver will attempt to build an initial solution from this vector when it is available. Note that the start can be partially populated -- the MIP solver will attempt to fill in values for missing start values. If you wish to leave the start value for a variable undefined, you can either avoid setting the Start attribute for that variable, or you can set it to a special undefined value (GRB_UNDEFINED in C and C++, or GRB.UNDEFINED in Java, .NET, and Python). &lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/parameter_tuning_tool.html#sec:Tuning&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Parameter Tuning Tool&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;&#xA;  The Gurobi Optimizer provides a wide variety of parameters that allow you to control the operation of the optimization engines. The level of control varies from extremely coarse-grained (e.g., the Method parameter, which allows you to choose the algorithm used to solve continuous models) to very fine-grained (e.g., the MarkowitzTol parameter, which allows you to adjust the tolerances used during simplex basis factorization). While these parameters provide a tremendous amount of user control, the immense space of possible options can present a significant challenge when you are searching for parameter settings that improve performance on a particular model. The purpose of the Gurobi tuning tool is to &lt;strong&gt;automate&lt;/strong&gt; this search.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.sas.com/en_ca/software/or.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;SAS/OR&lt;/strong&gt;&lt;/a&gt;(R) 15.1 &lt;a href=&quot;http://documentation.sas.com/?docsetId=ormpug&amp;amp;docsetTarget=ormpug_milpsolver_syntax02.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en&quot; rel=&quot;nofollow noreferrer&quot;&gt;User's Guide: Mathematical Programming&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\color{blue}{\text{The Mixed Integer Linear Programming Solver}}$&lt;/span&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;MILP Solver Options&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This section describes the options that are recognized by the MILP solver in PROC OPTMODEL. These options can be specified after a forward slash (/) in the SOLVE statement, provided that the MILP solver is explicitly specified using a WITH clause. For example, the following line could appear in PROC OPTMODEL statements:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;solve with milp / allcuts=aggressive maxnodes=10000 primalin;&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Warm Start Option&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;PRIMALIN&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;enables you to input a starting solution in PROC OPTMODEL before invoking the MILP solver. Adding the PRIMALIN option to the SOLVE statement requests that the MILP solver use the current variable values as a starting solution (warm start). &lt;strong&gt;If the MILP solver finds that the input solution is feasible, then the input solution provides an incumbent solution and a bound for the branch-and-bound algorithm&lt;/strong&gt;. If the solution is not feasible, the MILP solver tries to repair it. It is possible to set a variable value to the missing value '.' to mark a variable for repair. When it is difficult to find a good integer feasible solution for a problem, warm start can reduce solution time significantly.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: If the MILP solver produces a feasible solution, the variable values from that run can be used as the warm start solution for a subsequent run. If the warm start solution is not feasible for the subsequent run, the solver automatically tries to repair it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="123" LastEditDate="2019-10-15T18:05:52.810" LastActivityDate="2019-10-15T18:05:52.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1327" PostTypeId="2" ParentId="1304" CreationDate="2019-08-19T03:33:04.773" Score="14" Body="&lt;p&gt;For constraint programming, there's the &lt;a href=&quot;https://www.minizinc.org/challenge.html&quot; rel=&quot;noreferrer&quot;&gt;Minizinc Challenge&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="546" LastActivityDate="2019-08-19T03:33:04.773" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1328" PostTypeId="2" ParentId="1278" CreationDate="2019-08-19T06:51:42.497" Score="17" Body="&lt;p&gt;For the simplex algorithms, warmstarting a solver typically means installing a near-optimal basis and using that as a starting point instead of doing a crash or slack basis as a first step. This works best if the starting basis is already primal feasible (for the primal simplex algorithm) or dual feasible (for the dual simplex) because that eliminates the need for a phase 1. In the special case of installing an optimal basis the algorithm should normally only need a single iteration to verify its optimality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simplex warmstarting is crucial to the performance of MILP solvers since the MILP solver does various modifications to a base problem to solve subproblems. Using warmstart speeds up solving these subproblems a lot, most common case is solving a node in the branch-and-bound tree. Tightening the bound of a basic variable means that the basis of the parent node stays dual feasible and hence typically only a few iterations are needed to solve the new node. For use cases where one wants to change the objective (e.g. feasibility pump) one can use the primal simplex with warmstart to improve performance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that inside a solver and potentially in a solver API it is also possible to use what I would call hotstart. Instead of just using the basis, the simplex algorithm can also store additional information such as a factorization of this basis and steepest edge weights for pricing. This can further improve the performance when solving only slightly changed subproblems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For MILP solvers, the warmstart input is typically a primal solution (potentially only a partial solution) that preferably is already primal feasible. Hence its objective will give a primal (upper bound in case of minimization) on the objective value and thus can be used to prune nodes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The effectivness of &quot;warmstarting&quot; MILP solvers depends on a lot of factors, sometimes it is crucial, sometimes completely useless. I prefer to calling it providing an input solution or a bound, since its not the same level of effort saving as the warmstarting of a simplex algorithm. The exact way this is done depends on the solver details but you can envision it as being equivalent to the solver finding a solution really early (even before presolve) and installing it from then on as the current incumbent until a better solution is found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When is a MILP solution worth it? An obvious factor is how good the solution provided is. Then it also matters whether it is hard to find any solutions. As a rule of thump I would say that for instances where it is hard to find any solutions or where the solutions found early by the solver are of bad quality, it makes sense to put some thought into providing a good quality input solution. For other cases, if one happens to have a solution anyways, it normally can't hurt to provide that solution to the solver.&lt;/p&gt;&#xA;" OwnerUserId="302" LastEditorUserId="228" LastEditDate="2019-10-15T11:31:24.167" LastActivityDate="2019-10-15T11:31:24.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1329" PostTypeId="1" AcceptedAnswerId="1332" CreationDate="2019-08-19T17:28:54.903" Score="25" ViewCount="2201" Body="&lt;p&gt;I somewhat know how to compare two MILP formulations of a problem that both use the same set of decision variables (as in the classical MTZ vs DFJ formulations of the TSP). I was wondering how two formulations of a problem that use different sets of decision variables are compared. Can we just compare the LP-relaxation bounds?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, a route-based formulation for a vehicle routing problem (using an exponential number of variables) is usually considered to provide a better LP-relaxation bound. However, such a formulation employs a completely different set of decision variables. What is the right way to show that such a formulation is better? Is there a standard definition?&lt;/p&gt;&#xA;" OwnerUserId="1202" LastEditorUserId="1202" LastEditDate="2019-08-20T01:24:19.090" LastActivityDate="2019-08-23T16:40:09.687" Title="How to compare two different formulations of a problem?" Tags="|mixed-integer-programming|vehicle-routing|bounds|lp-relaxation|polyhedra|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1330" PostTypeId="2" ParentId="1329" CreationDate="2019-08-19T19:42:43.420" Score="2" Body="&lt;p&gt;Generally I see on the papers, at first comparison according to number of variables and equations, after then experimental performance comparison on test problems. &lt;/p&gt;&#xA;" OwnerUserId="432" LastActivityDate="2019-08-19T19:42:43.420" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1331" PostTypeId="2" ParentId="1329" CreationDate="2019-08-19T20:33:40.187" Score="15" Body="&lt;p&gt;I'm not sure there is a single, definitive best way to compare models, and if there is I likely have never seen it applied. I lean toward computational comparisons if properly done, but &quot;properly done&quot; is in the eye of the beholder. The most obvious criteria for computational comparisons are that they use the same test problems (&lt;em&gt;not&lt;/em&gt; selected because they favor one model over the other) and that they use the same hardware. The next criterion is that, ideally, the test problems are both realistic (comparable to real-world versions of the problem) and span a reasonable range of sizes. You are correct that the MTZ algorithm for TSP has looser relaxations than DFJ, but about the time you are running out of memory trying to look at all node subsets of cardinality greater than two, the MTZ formulation starts to look pretty darn good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, some formulations may benefit from specific features of certain solvers, which needs to be made clear if those features are used in the comparisons.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-19T20:33:40.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1332" PostTypeId="2" ParentId="1329" CreationDate="2019-08-19T22:04:44.287" Score="20" Body="&lt;p&gt;Even if the decision variables differ, you may still be able to prove that one of the formulations is stronger than the other by introducing an appropriate mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take for example a flow formulation and a route formulation for a vehicle routing problem (minimization). Typically, the folllowing argument can be made:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Given (fractional) values for the route variables, we can find values for the flow variables that result in the same objective value.&lt;/li&gt;&#xA;&lt;li&gt;Given (fractional) values for the flow variables, there may not be values for the route variables that result in the same or a lower objective value.&lt;/li&gt;&#xA;&lt;li&gt;It follows that the route formulation always provides a bound that is at least as high as that of the flow formulation, and sometimes higher.&lt;/li&gt;&#xA;&lt;li&gt;So the route formulation is stronger.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For vehicle routing problems, step 1 is often trivial, and step 2 may require a little bit of work.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-08-19T22:04:44.287" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1333" PostTypeId="2" ParentId="1329" CreationDate="2019-08-19T23:41:23.887" Score="11" Body="&lt;p&gt;I agree with most of the comments here; Even if the decision variables are different, you may use proof by construction, for example, with appropriate mapping to prove that a formulation is stronger than another one. When comparing two different (yet equivalent) formulation for the same problem, I often use three criteria: (1) LP relaxation/tightness, (2) sizes of the formulations (in terms of number of variables and constraints; a larger size often suggests an increase in solution time for the LP relaxations), (3) the existence of artificial/logical/etc Big-M constraints. You can check our recent paper (&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0377221719304989&quot; rel=&quot;noreferrer&quot;&gt;https://www.sciencedirect.com/science/article/pii/S0377221719304989&lt;/a&gt;), in which we compare different (equivalent) SMILP formulation for single server stochastics sequencing and scheduling. Then after comparing the formulation theoretically, you may consider comparing them computationally using a wide range of realistic problem instances. &lt;/p&gt;&#xA;" OwnerUserId="77" LastActivityDate="2019-08-19T23:41:23.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1334" PostTypeId="2" ParentId="1329" CreationDate="2019-08-20T03:23:53.923" Score="6" Body="&lt;p&gt;I would like to add some criteria for the computational comparison, that I think is appropriate and common. As mentioned, the experiments should be performed on standard benchmarks, and if available, on more than one benchmark. Then, the metrics can be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Number of feasible solutions,&lt;/li&gt;&#xA;&lt;li&gt;Number of best found solutions,&lt;/li&gt;&#xA;&lt;li&gt;Number of optimal solutions,&lt;/li&gt;&#xA;&lt;li&gt;Gap to the best found solution,&lt;/li&gt;&#xA;&lt;li&gt;Computational time,&lt;/li&gt;&#xA;&lt;li&gt;LP relaxation bound.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think the number of constraints and/or variables do not always reveal the superiority of models. Nevertheless, the comparison is very dependent to the size of the inputs when time-index models (models with discretization of the time horizon) are among the comparing models.&lt;/p&gt;&#xA;" OwnerUserId="660" LastActivityDate="2019-08-20T03:23:53.923" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1335" PostTypeId="2" ParentId="1319" CreationDate="2019-08-20T05:01:06.367" Score="5" Body="&lt;p&gt;May I suggest CP-SAT modeling. See this incomplete &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/sat/doc/scheduling.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;section&lt;/a&gt;.&#xA;And a few examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/cpp/jobshop_sat.cc&quot; rel=&quot;nofollow noreferrer&quot;&gt;Complex jobshop in C++&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/cpp/weighted_tardiness_sat.cc&quot; rel=&quot;nofollow noreferrer&quot;&gt;Single Machine Weighted tardiness in C++&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/python/rcpsp_sat.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;RCPSP in Python&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/python/gate_scheduling_sat.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gate scheduling in Python&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/python/single_machine_scheduling_with_setup_release_due_dates_sat.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;Single machine scheduling with setup and release date in Python&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2019-08-20T17:38:45.087" LastActivityDate="2019-08-20T17:38:45.087" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1336" PostTypeId="1" AcceptedAnswerId="1337" CreationDate="2019-08-20T07:02:22.113" Score="11" ViewCount="496" Body="&lt;p&gt;How can I express a chain of OR operations in an ILP, given that each operand is an inequality between two binary variables? I have asked a similar question here: &lt;a href=&quot;https://or.stackexchange.com/questions/1300/expressing-a-chain-of-boolean-ors-using-ilp&quot;&gt;Chain of Boolean ORs&lt;/a&gt;. In that question, I asked specifically about the scenario where the variable on the left-hand sides is always the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this question, I am interested in the more general case. For example, &lt;span class=&quot;math-container&quot;&gt;$$(x_1 \leq x_3) \textrm{ OR } (x_2 \leq x_3) \textrm{ OR } (x_1 \leq x_4),$$&lt;/span&gt;&#xA;in which the left-hand sides nor the right-hand sides are always the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A boolean OR of just two variables can be expressed by introducing an additional variable and modifying the constraints appropriately. But how can we model the general case described above?&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="38" LastEditDate="2019-08-20T13:06:58.000" LastActivityDate="2019-08-20T14:00:26.190" Title="Expressing a chain of boolean ORs using ILP involving different variables" Tags="|optimization|modeling|integer-programming|logical-constraints|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1337" PostTypeId="2" ParentId="1336" CreationDate="2019-08-20T12:18:39.320" Score="11" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be the set of &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; pairs.  Here’s a derivation via conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\bigvee_{(i,j)\in P} \left(x_i \implies x_j\right) \\&#xA;\bigvee_{(i,j)\in P} \left(\neg x_i \vee x_j\right) \\&#xA;\sum_{(i,j)\in P} \left(1-x_i + x_j\right) \ge 1 \\&#xA;\sum_{(i,j)\in P} (x_i - x_j) \le |P| - 1&#xA;\end{equation}&lt;/span&gt;&#xA;For your example, this yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$2x_1+x_2 - 2x_3 - x_4 \le 2.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2019-08-20T14:00:26.190" LastActivityDate="2019-08-20T14:00:26.190" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1338" PostTypeId="2" ParentId="1318" CreationDate="2019-08-20T14:02:26.200" Score="5" Body="&lt;p&gt;OK so indeed there are many ways to cut this cake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suggest starting with something very simple (please pardon the self content posting).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Create a REST end point&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/fhk/link_src&quot; rel=&quot;noreferrer&quot;&gt;example&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use Python web framework flask&lt;/li&gt;&#xA;&lt;li&gt;Write your formulation in pulp &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This makes the whole solve environment creation free, both in terms&#xA;of $ but also in terms of install overhead.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;parse json request into formulation objects&lt;/li&gt;&#xA;&lt;li&gt;create response solution json&lt;/li&gt;&#xA;&lt;li&gt;deploy on heroku&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Create a front end&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://tranquil-dusk-58927.herokuapp.com/&quot; rel=&quot;noreferrer&quot;&gt;example&lt;/a&gt; - purely front end app to solve models&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a raw js or whatever framework (nodejs, Angular, React et al)&lt;/li&gt;&#xA;&lt;li&gt;Call your API (be sure to enable CORS)&lt;/li&gt;&#xA;&lt;li&gt;Create a way to upload and download data&lt;/li&gt;&#xA;&lt;li&gt;Can also be deployed on heroku&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Happy to talk through in more detail.&lt;/p&gt;&#xA;" OwnerUserId="259" LastActivityDate="2019-08-20T14:02:26.200" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1339" PostTypeId="2" ParentId="875" CreationDate="2019-08-20T16:02:49.940" Score="5" Body="&lt;p&gt;I think the spanning tree polytope also falls under this category. Computing the minimum spanning tree is easy. However, we would require all the sub-tour elimination constraints (which is exponential in number of vertices) to represent the spanning tree polytope in 0-1 variables as a LP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the comments below, one can find a reference for a polynomial characterization of the spanning tree polytope. So my answer that the spanning tree has &lt;span class=&quot;math-container&quot;&gt;``&lt;/span&gt;exponential extension complexity&quot; is incorrect. I will however let this answer remain because I think not many people are aware of polynomial formulations for the spanning tree polytope. The edit is meant to notify people who read this post, not to overlook that fact.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2019-08-25T18:02:58.497" LastActivityDate="2019-08-25T18:02:58.497" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1340" PostTypeId="1" CreationDate="2019-08-20T18:06:27.163" Score="11" ViewCount="499" Body="&lt;p&gt;I have an assignment type problem in which there is a set of students, &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, and a set of training classes &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;. Each training has a fixed start and end day and can accommodate at most 1 student. In addition, a training will give a student credit towards two types of requirements, and each training varies in how much credit is given for each type. A student must receive enough credit of type 1 and type 2 in order to be considered trained. For example, student ABC needs 2 credits of type 1, and 5 credits of type 2, and can be assigned to training 123, and receive 1 credit toward requirement 1, and 3 credits toward requirement 2. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Students become first available for training on different days (and have days off after too), and the model objective is to minimize the total wait time across all students, where wait time is defined as the number of days from when a student first becomes available to when they are finished with training.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general the training dates can overlap, and a student can only take the class if they are available for the entire time of the class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I have modeled the problem with arcs, where &lt;span class=&quot;math-container&quot;&gt;$a_{\text{st}} \in\{0,1\}$&lt;/span&gt; is created if a student can possibly take the training (i.e., student is available during training). Each arc also has an attribute called &lt;code&gt;wait_days&lt;/code&gt; which is equal to the number of days from when the student first became available to the last day of the training on that arc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I create sets of trainings that have overlapping dates and then create a constraint in the model so that for each student at most 1 training from each of these sets is assigned in order to avoid scheduling conflicts.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;conflict_sets = set()&#xA;for t1 in trainings:&#xA;   conflicts = [t1]&#xA;   for t2 in trainings:&#xA;      if t1.start &amp;lt;= t2.end and t1.start &amp;gt;= t2.start:&#xA;         conflicts.append[t2]&#xA;   conflict_sets.add(conflicts)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a model using the CP solver from Google OR-tools that assigns students to trainings so that the student completes both training requirements, there are no scheduling conflicts, and then it minimizes total wait time summed across all students.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from ortools.sat.python import cp_model&#xA;&#xA;model = cp_model.CpModel()&#xA;&#xA;arc_vars = {}&#xA;for arc in arcs:&#xA;   arc_vars[arc] = model.NewBoolVar(f'arc_{arc}')&#xA;&#xA;wait_vars = {}&#xA;# total wait is at most 31 days&#xA;for s in students:&#xA;   wait_vars[s] = model.NewIntVar(0,31, f'wait_{s}')&#xA;&#xA;&#xA;for s in students:&#xA;   # ensure student completes both types of necessary training&#xA;   model.Add(sum(arc_vars[a] * a[1].type1 for a in arcs if a[0]==s) &amp;gt;= s.Type1_req)&#xA;   model.Add(sum(arc_vars[a] * a[1].type2 for a in arcs if a[0]==s) &amp;gt;= s.Type2_req)&#xA;&#xA;   # student can't be in trainings that have overlapping times&#xA;   for c_list in conflict_sets:&#xA;      model.Add(sum(arc_vars[(s, t)] for t in c_list if (s,t) in arcs) &amp;lt;= 1)&#xA;&#xA;&#xA;&#xA;# make wait variable the max waiting days &#xA;# across all arcs a student is assigned to&#xA;for a in arcs:&#xA;   model.Add(wait_vars[a[0]] &amp;gt;= arc_vars[a]*arcs[a].waiting_days)&#xA;&#xA;# minimize total wait time in system&#xA;model.Minimize(sum(wait_vars[s] for s in students))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I modeling this in an efficient way? I am new to constraint programming, and I believe this would be a good way to model it as an IP, but I'm not sure if this is true for CP. I switched to CP because it has been solving much faster than my original IP formulation. I was thinking maybe there would be a better to model the wait time or the training conflicts with a CP paradigm but I'm not sure.&lt;/p&gt;&#xA;" OwnerUserId="1214" LastEditorUserId="981" LastEditDate="2023-12-29T10:51:53.583" LastActivityDate="2023-12-29T10:51:53.583" Title="Modeling an assignment/scheduling problem to minimize total wait" Tags="|modeling|constraint-programming|or-tools|assignment-problem|cp-sat|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1341" PostTypeId="1" AcceptedAnswerId="1397" CreationDate="2019-08-21T03:23:46.577" Score="11" ViewCount="538" Body="&lt;p&gt;This post is not really about a specific question but rather a topic I am curious about to know more. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We know that when it comes to integrate machine/statistical learning with optimization for the purpose of replacing ideal equations with data-driven models, the choices are quite limited - mostly regression (linear, polynomial) and spline models or at best a  shallow neural network that can be decoded back by hand as an analytical expression. Such limited choices naturally mean that generally speaking highly non-linear functions would be difficult to approximate well. Deep neural networks are known to do exceptionally well when it comes to model complex functions. However, the problem is that they are hard to represent then as an expression/formula (&lt;em&gt;without needing a mile long paper&lt;/em&gt;), which however if becomes possible would indeed be great from optimization perspective.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know if there been some work done on this topic previously or is any active research going on that you guys may be aware of. Keen to hear about it. Thanks.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT - My question is more from the side of using AML's (Pyomo, JuMP etc), where one has the luxury of directly writing the algebraic expressions.    &lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="113" LastEditDate="2019-08-21T10:08:03.037" LastActivityDate="2019-08-27T12:31:44.790" Title="Decoding a Deep Neural Network as an Analytical Expression for Optimization Purpose" Tags="|optimization|modeling|machine-learning|data|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1342" PostTypeId="1" AcceptedAnswerId="1347" CreationDate="2019-08-21T13:37:17.960" Score="11" ViewCount="198" Body="&lt;p&gt;I am currently solving an indefinite quadratic program with linear constraints using CPLEX. Moreover, I am trying to determine whether the candidate point CPLEX is feeding my callback function is an extreme point. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that a certain &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^n$&lt;/span&gt; is an extreme point if and only if there is equality in at least &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; &lt;strong&gt;linearly independent&lt;/strong&gt; rows in the inequality &lt;span class=&quot;math-container&quot;&gt;$A x \le b$&lt;/span&gt;, but I do not know how to guarantee that the constraints I feed CPLEX (also the ones it generates itself) are linearly independent with respect to the other constraints in the model. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question thus is&lt;/strong&gt;: How do I check in CPLEX (or another off-the-shelf MIQP solver) whether a certain candidate &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is an extreme point?&lt;/p&gt;&#xA;" OwnerUserId="1218" LastEditorUserId="145" LastEditDate="2019-08-21T13:55:40.207" LastActivityDate="2019-08-22T23:22:03.553" Title="Quadratic programming using CPLEX: how to check whether candidate is an extreme point?" Tags="|cplex|quadratic-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1343" PostTypeId="1" CreationDate="2019-08-21T13:50:07.513" Score="19" ViewCount="280" Body="&lt;p&gt;What is the optimality argument in a simultaneous column and row generation procedure? By column and row generation procedure I mean a procedure in which every time a column in generated, several constraints need to be added to the master program.&lt;/p&gt;&#xA;" OwnerUserId="602" LastActivityDate="2019-08-22T15:17:59.630" Title="Optimality in a simultaneous column and row generation procedure" Tags="|column-generation|optimality-conditions|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1344" PostTypeId="2" ParentId="1343" CreationDate="2019-08-22T15:17:59.630" Score="8" Body="&lt;p&gt;As you are probably aware of, the standard optimality condition for column generation is not valid if not all constraints are included in the master problem, as the dual information of the missing constraints needs to be taken into account in the computation of the reduced costs. &lt;a href=&quot;https://link.springer.com/content/pdf/10.1007%2Fs10107-012-0561-8.pdf&quot; rel=&quot;noreferrer&quot;&gt;Muter et al. (2013)&lt;/a&gt; consider this issue and show that if the formulation satisfies certain assumptions, it is possible to anticipate the optimal dual variables of the missing dual variables, such that the reduced costs can be computed correctly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are successful applications of this approach, see e.g. &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2018.05.051&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt; or &lt;a href=&quot;https://doi.org/10.1287/trsc.2014.0552&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt;. However, whether this approach is computationally feasible fully depends on your model. In some cases, the pricing problem itself becomes an integer program with exponentially many variables, so then it might be worthwhile to try and come up with a different formulation without column-dependent rows. &lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2019-08-22T15:17:59.630" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1345" PostTypeId="1" AcceptedAnswerId="1351" CreationDate="2019-08-22T15:20:00.363" Score="8" ViewCount="2824" Body="&lt;p&gt;Is there a way of writing an algorithm with if-, while-statements to find an optimal solution without using linear-programming (LP)/MIP? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, what would the benefits be against the LP/MIP?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it then possible with the first method to get a solution with an x% margin to the optimal solution, for the sake of speed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Employee scheduling could be one use-case.&lt;/p&gt;&#xA;" OwnerUserId="456" LastEditorUserId="456" LastEditDate="2019-08-22T15:42:31.520" LastActivityDate="2019-08-27T10:28:19.403" Title="Algorithms vs LP or MIP" Tags="|mixed-integer-programming|optimization|modeling|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1346" PostTypeId="2" ParentId="1345" CreationDate="2019-08-22T15:32:41.387" Score="4" Body="&lt;p&gt;Without using mathematical modeling you can(!) (except for the problems with continuous variables and/or infinitely many dimensions) enumerate all the candidates in the feasible solution space to find the best solution (which will be exact, optimal one). For sure you can write a code using &lt;em&gt;if&lt;/em&gt;, &lt;em&gt;while&lt;/em&gt; or &lt;em&gt;for&lt;/em&gt; loops and evaluate all the candidates. Computational power to evaluate all the points in the feasible solution is one of the main drawbacks of enumeration. To avoid the computational burden, mathematical modeling has been used instead of enumeration although it is not guaranteed to solve all the problems optimally (local minima). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;For your second question:&lt;/em&gt; Yes it is possible to define a margin from the optimal solution and find with enumeration the answers in that margin. But the question is if you have the optimal solution of a problem why do you need to find all the answers in a specific margin using other methods like enumeration. If you don't have the answer, how its possible to define a margin from optimality? &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-08-23T12:43:39.173" LastActivityDate="2019-08-23T12:43:39.173" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1347" PostTypeId="2" ParentId="1342" CreationDate="2019-08-22T17:58:29.717" Score="7" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\bar{y} \in \mathbb{R}^n$&lt;/span&gt; is the point you are feeding, then assuming that you have verified that &lt;span class=&quot;math-container&quot;&gt;$\bar{y}$&lt;/span&gt; is feasible to your linear constraints to begin with, then try to find a direction &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; such that both &lt;span class=&quot;math-container&quot;&gt;$\bar{y}+d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{y}-d$&lt;/span&gt; are feasible to your linear constraints. In other words, if the following problem has an optimum objective &gt; 0, then you can conclude that &lt;span class=&quot;math-container&quot;&gt;$\bar{y}$&lt;/span&gt; is not a vertex. If the objective is &gt;0, then &lt;span class=&quot;math-container&quot;&gt;$\bar{y}$&lt;/span&gt; can be represented as a convex combination of 2 other points, &lt;span class=&quot;math-container&quot;&gt;$\bar{y} +d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{y} - d$&lt;/span&gt;, where both points are feasible to your linear constraints. If the optimum objective is 0, then we can safely conclude that &lt;span class=&quot;math-container&quot;&gt;$d = 0$&lt;/span&gt;, so no line segment can pass through &lt;span class=&quot;math-container&quot;&gt;$\bar{y}$&lt;/span&gt;, lying completely inside the feasible region.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_{d \in \mathbb{R}^n} &amp;amp; \,\, \|d \|_1\\&#xA; \mbox{s.t. } &amp;amp; A(\bar{y} + d) \leq b \\&#xA; &amp;amp;A(\bar{y} - d) \leq b&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As pointed out in the comments below, the objective is non-convex. However if we are looking for efficiency, then we can overcome the non-convexity issue by instead solving &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; linear maximization problems instead. Have a look at the comments below for the specification of those &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; maximization problems. Even if one of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; maximization problems has an objective &gt; 0, we can conclude that &lt;span class=&quot;math-container&quot;&gt;$\bar{y}$&lt;/span&gt; is not a vertex point.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2019-08-22T23:22:03.553" LastActivityDate="2019-08-22T23:22:03.553" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="1348" PostTypeId="1" CreationDate="2019-08-22T18:53:21.883" Score="8" ViewCount="203" Body="&lt;p&gt;I'm using the &lt;a href=&quot;https://developers.google.com/optimization/&quot; rel=&quot;noreferrer&quot;&gt;OR-Tools&lt;/a&gt; &lt;a href=&quot;https://developers.google.com/optimization/cp/cp_solver&quot; rel=&quot;noreferrer&quot;&gt;CP-SAT&lt;/a&gt; solver to fill a table with integers, with various constraints, as illustrated by the &lt;code&gt;x&lt;/code&gt; in the following figure.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|   | A | B | C | D | E |&#xA;| 1 | x | x | x | x | x |&#xA;| 2 | x | x | x | x | x |&#xA;| 3 | x | x | x | x | x |&#xA;| 4 | x | x | x | x | x |&#xA;| 5 | x | x | x | x | x |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sadly, the solving time become prohibiting when the dimensions of the table increase. I know that if a given problem has no solution with, for instance, 5 columns (&lt;code&gt;A-E&lt;/code&gt;), it won't have a solution with any number of additional columns (&lt;code&gt;A-Z&lt;/code&gt;). Therefore, theoretically, I should be able to know quickly if a problem with 26 columns is infeasible by checking beforehand if the same problem with 5 columns, or 6 columns, or 7 columns, … is infeasible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I make the solver aware of this fact? I have tried to loop over the number of columns and breaking at the first failure, but it comes with two problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the solver can't use the knowledge gained in the previous iteration of the loop;&lt;/li&gt;&#xA;&lt;li&gt;the solver fails quickly if the problem is infeasible, but takes a long time to succeed; if a 26-column problem is feasible until the 25th column, then I've lost a long time in finding 25 useless partial solutions.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is is impossible, or have I overlooked a way to do that? Is there any way to use a &lt;a href=&quot;https://github.com/google/or-tools/blob/2c67e00f3a8a861440f0b8016e209c51990a0403/ortools/sat/cp_model.h#L671&quot; rel=&quot;noreferrer&quot;&gt;decision strategy&lt;/a&gt;, for instance?&lt;/p&gt;&#xA;" OwnerUserId="1223" LastEditorUserId="981" LastEditDate="2023-12-22T15:14:10.700" LastActivityDate="2023-12-22T15:14:10.700" Title="Strategy for filling a table only slightly dependant on the number of columns" Tags="|modeling|constraint-programming|or-tools|cp-sat|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1349" PostTypeId="2" ParentId="1348" CreationDate="2019-08-23T00:38:54.400" Score="3" Body="&lt;p&gt;Manually &lt;a href=&quot;https://developers.google.com/optimization/assignment/assignment_groups#create-the-allowed-groups&quot; rel=&quot;nofollow noreferrer&quot;&gt;create groups&lt;/a&gt;, if you &lt;em&gt;know&lt;/em&gt; which groups make more sense than others then you don't need to define every possible permutation. If you are less certain you can use a script to enumerate the combinations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you actually &lt;em&gt;need&lt;/em&gt; (eventually) all 26 columns for a successful solution (fewer than 26 is always a failure, regardless of early success) then the &lt;a href=&quot;https://developers.google.com/optimization/mip/integer_opt_cp#which_solver&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIP solver is faster&lt;/a&gt;; you would be staring at &lt;em&gt;blank&lt;/em&gt; progress for a while, but for less time than false hopes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also &lt;a href=&quot;https://developers.google.com/optimization/cp/cp_tasks&quot; rel=&quot;nofollow noreferrer&quot;&gt;use time limits&lt;/a&gt; during the day, while you check for an answer, and remove them overnight (or all weekend, if at work) to pursue hopeful paths when more time is available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of showing the first solution of a smaller set &lt;a href=&quot;https://developers.google.com/optimization/cp/cp_solver#all_solutions&quot; rel=&quot;nofollow noreferrer&quot;&gt;show all solutions&lt;/a&gt;, then combine each permutation of the smaller solution sets into bigger sets; eventually producing a group of 26 that work together.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-08-23T00:38:54.400" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1350" PostTypeId="2" ParentId="1345" CreationDate="2019-08-23T06:41:49.000" Score="10" Body="&lt;p&gt;Yes, there are optimization algorithms that do not use LP/MIP solvers as a component. Most of these are problem specific algorithms, for example the Dijkstra algorithm for the shortest path problem. The power of LP and MIP is that you have one algorithm to solve many different kinds of problems fairly reliable. Problem specific algorithms can be better in some cases, but its also a lot more effort to implement, test and debug them than just modeling a problem and using a solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Constraint programming is an alternative to MIP that has a similar range of problems it can solve. Specifically for scheduling problems, a constraint programming solver might do better than MIP, but your mileage may vary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess there are algorithms for employee scheduling out there. I would expect most of them to be heuristics, i.e. not guaranteeing optimal solutions and probably not a dual bound, which probably is what you mean by x% margin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A problem might also be that employee scheduling can have all kinds of side constraints that make it difficult to implement one algorithm that many different people can use. This again is a strength of LP/MIP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Orguz Toragay pointed out, it is always possible to enumerate all solutions and keep the best. As soon as problems are larger than a hand full of variables this will quickly be impossible because of combinatorial explosion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, there are many problem specific algorithms that use LP/MIP solvers (or CP, or SAT, or ...) as part of them to get dual bounds or solve sub-problems. That is probably the first thing to try if LP/MIP does not perform well enough for ones use case.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2019-08-23T06:41:49.000" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1351" PostTypeId="2" ParentId="1345" CreationDate="2019-08-23T07:54:26.830" Score="19" Body="&lt;p&gt;As mentioned earlier, all algorithms are constructed using loops and conditional statements, including the algorithms employed by LP/MIP solvers. There are plenty of problems where it is more efficient to implement a &quot;direct&quot; algorithm using those constructs, rather than first write and algorithm that translates your problem data into a LP/MIP model, then execute the solver, and then translate the solution data back to your problem data. There are also plenty of problems that can not be modelled (in a straightforward way) by LP/MIP, such as non-linear optimization problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For many classic optimization problems such as Shortest Path, Maximum Flow and Minimum Spanning Tree, it is more common to find the exact solution with such &quot;direct&quot; algorithms, rather than by employing a MIP solver. If you need pointers on how &quot;direct&quot; algorithms that do not involve a LP/MIP solver work, you could look at the Wikipedia pages for &lt;a href=&quot;https://en.wikipedia.org/wiki/Prim%27s_algorithm&quot; rel=&quot;noreferrer&quot;&gt;Prim's algorithm (Minimum Spanning Tree)&lt;/a&gt;, the &lt;a href=&quot;https://en.wikipedia.org/wiki/Bellman%E2%80%93Ford_algorithm&quot; rel=&quot;noreferrer&quot;&gt;Bellman-Ford algorithm (Shortest Path)&lt;/a&gt;, or the &lt;a href=&quot;https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm&quot; rel=&quot;noreferrer&quot;&gt;Edmonds-Karp algorithm (Maximum Flow)&lt;/a&gt;. While these may not be the fastest algorithms for their particular problems, they are relatively easy to understand compared to some of the more sophisticated methods for these problems. Some practical problems, including certain types of employee scheduling, can sometimes be written as a maximum flow problem (e.g. you want to maximize the number of tasks covered by employees that are only able to cover a certain number of tasks). To determine what is possible, it is very important to know the exact details of the problem: a small change in the specification of the problem you want to solve may render an algorithm totally useless. The advantage of the LP/MIP approach is that it is so flexible, and often is fast enough 'in practice', in particular with the powerful solvers that exist nowadays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question whether it is possible to get within a x% margin of the optimal solution is a different approach, and &quot;direct&quot; algorithms based on that idea exist as well. Sometimes these are heuristic methods, e.g. evolutionary algorithms or local search methods. Those algorithms usually do not give you a guarantee, although they often produce good solutions in practice. If you have an algorithm that guarantees the solution produced is within %x of the optimal solution, this is called an &lt;a href=&quot;https://en.wikipedia.org/wiki/Approximation_algorithm&quot; rel=&quot;noreferrer&quot;&gt;Approximation Algorithm&lt;/a&gt;. A famous example is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Christofides_algorithm&quot; rel=&quot;noreferrer&quot;&gt;Christofides algorithm for the metric Travelling Salesman Problem&lt;/a&gt;, which combines a minimum spanning tree and a matching to obtain a tour that is guaranteed to be at most 50% longer than the shortest possible tour.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastActivityDate="2019-08-23T07:54:26.830" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1352" PostTypeId="2" ParentId="889" CreationDate="2019-08-23T07:57:07.880" Score="1" Body="&lt;p&gt;Also this special issues can give idea:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.euro-online.org/web/pages/1486/special-issues?id=19&quot; rel=&quot;nofollow noreferrer&quot;&gt;Special issue: Combining optimization and machine learning: applications in vehicle routing, network design and crew scheduling&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.mdpi.com/journal/energies/special_issues/Machine_Learning_Optimization_Power_System&quot; rel=&quot;nofollow noreferrer&quot;&gt;Special Issue &quot;Machine Learning and Optimization with Applications of Power System&quot;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://pubsonline.informs.org/toc/ijoo/1/2&quot; rel=&quot;nofollow noreferrer&quot;&gt;Special Issue on Machine Learning and Optimization&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="432" LastActivityDate="2019-08-23T07:57:07.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1353" PostTypeId="1" AcceptedAnswerId="1365" CreationDate="2019-08-23T07:57:40.397" Score="8" ViewCount="279" Body="&lt;p&gt;I am working on a scheduling program for a service desk. I want to decide the number of people required to come in at each shift. The data I have is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There are 4 overlapping shifts&lt;/li&gt;&#xA;&lt;li&gt;Arrival pattern at the hour level&lt;/li&gt;&#xA;&lt;li&gt;Each defect has a 24 hr to solved. If a defect comes in 2:00 am then I have 24 hrs from 2:00 am to solve this defect. So someone else coming in the next shift can take it over. The defects needn't be solved by the same person or within the shift he/she is working in.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have built a simplex model where I am able to solve saying every hour how many resources are required to solve the defects within that hour. Currently my approach does not consider the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Overlapping shifts are not taken into account&lt;/li&gt;&#xA;&lt;li&gt;24 hour window to solve the defect is not taken into account&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Can you please suggest an approach to solve this? Papers or links that solve a similar problem would also be welcome.&lt;/p&gt;&#xA;" OwnerUserId="1079" LastEditorUserId="56" LastEditDate="2019-08-23T13:10:23.757" LastActivityDate="2024-03-15T11:07:51.217" Title="Workforce Scheduling problem - Modelling to minimize resources" Tags="|linear-programming|constraint-programming|scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1354" PostTypeId="1" AcceptedAnswerId="1360" CreationDate="2019-08-23T12:04:53.797" Score="15" ViewCount="1846" Body="&lt;p&gt;&lt;a href=&quot;https://epubs.siam.org/doi/abs/10.1137/17M1142922&quot; rel=&quot;noreferrer&quot;&gt;Průša and Werner&lt;/a&gt;  (2019) show that the general linear programming problem reduces in nearly linear time to the LP relaxations of many classical NP-hard problems (assuming sparse encoding of instances). As the authors write:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arguably, the most important consequences of our reductions are constraints on algorithms to solve the LP relaxations. Leaving runtime aside, they show that such algorithms cannot be arbitrarily simple since they must be able to solve any linear program.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Linear programming is an important tool used to solve integer linear programs (via the LP-based branch and bound approach). There has been a huge progress towards solving such integer programs. However, there does not seem to be much progress in solving the general linear programming problem. As far as I know, the classical simplex algorithm or its dual variant is still used in modern IP solvers (even as the default LP algorithm).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there are any new algorithms that could potentially beat the simplex algorithm in practice (at least on average)? If not, then I am wondering why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result of Průša and Werner implies that no matter how good the underlying formulation is (or no matter how good the valid inequalities can be), we still need to solve the resulting linear program (i.e., ANY linear program) efficiently to be able to solve large problems.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastEditorUserId="8" LastEditDate="2019-08-24T01:04:54.283" LastActivityDate="2019-08-27T10:25:16.323" Title="State-of-the-art algorithms for solving linear programs" Tags="|mixed-integer-programming|linear-programming|combinatorial-optimization|computational-complexity|valid-inequalities|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1355" PostTypeId="2" ParentId="1345" CreationDate="2019-08-23T12:25:38.567" Score="8" Body="&lt;p&gt;A &lt;strong&gt;Construction Heuristic&lt;/strong&gt; like &lt;a href=&quot;https://docs.optaplanner.org/latestFinal/optaplanner-docs/html_single/#firstFitDecreasing&quot; rel=&quot;noreferrer&quot;&gt;First Fit Decreasing&lt;/a&gt; gets an ok solution for &lt;a href=&quot;https://www.optaplanner.org/learn/useCases/employeeRostering.html&quot; rel=&quot;noreferrer&quot;&gt;Employee Rostering&lt;/a&gt;. But of course, metaheuristics (such as &lt;a href=&quot;https://docs.optaplanner.org/latestFinal/optaplanner-docs/html_single/#tabuSearch&quot; rel=&quot;noreferrer&quot;&gt;Tabu Search&lt;/a&gt;) improve a lot on that solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First Fit Decreasing&lt;/strong&gt; (a greedy algorithm) is relatively simple (just a few &lt;code&gt;while&lt;/code&gt;/&lt;code&gt;for&lt;/code&gt; and &lt;code&gt;if&lt;/code&gt; statements), something like:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Iterate the shifts based on start dateTime.&lt;/li&gt;&#xA;&lt;li&gt;For each shift, iterate through every employee and assign it the employee that gives the best overall score (= hard and soft constraint penalty), keeping the shifts already assigned in mind (but without changing those).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="350" LastActivityDate="2019-08-23T12:25:38.567" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1356" PostTypeId="1" CreationDate="2019-08-23T13:58:28.820" Score="14" ViewCount="176" Body="&lt;p&gt;I would like to compare human solutions for OR-problems to optimal solutions. Therefore, I am looking for a dataset with the manual solutions computed by a human. I do not have a specific problem in mind, any problem would be nice. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does such a dataset exist?&lt;/p&gt;&#xA;" OwnerUserId="601" LastActivityDate="2019-08-26T14:41:33.657" Title="Dataset human solutions for OR problems" Tags="|online-resources|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1358" PostTypeId="2" ParentId="1356" CreationDate="2019-08-23T15:48:08.773" Score="9" Body="&lt;p&gt;By chance, I happened across &lt;a href=&quot;https://doi.org/10.3758/BF03194380&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt; earlier today. It discusses human performance in solving the TSP manually. The paper is short but there are a few other references in it that probably provide more details of other experiments.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-08-23T15:48:08.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1359" PostTypeId="2" ParentId="1345" CreationDate="2019-08-23T16:02:53.097" Score="8" Body="&lt;p&gt;Is it possible? Probably. Is it likely? Not really.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LP/MILP is a thoroughly studied field so it is very unlikely that a homebrew solution will outperform a commercial (or even open source) solver even for specialised cases (with very few exceptions). The algorithms used by modern solvers are very powerful (especially dual simplex), and come with decades of black magic, know-how and acceleration heuristics that are not always found in the literature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other people have covered the algorithmic perspective however my point of view is more on the implementation side since I develop optimisation solvers for a living, so I will share my thoughts on why linear solvers are highly likely to be superior to homebrew algorithms.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Quality of implementation&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;A solver like CPLEX or GUROBI comes with many years of high quality implementation from people who really know what they are doing to ensure that it switches algorithms dynamically, employs acceleration heuristics, and scales well for large problem sizes. A typical example would be their in-house matrix factorisation algorithms which outperform anything we can find in open source.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;strong&gt;Numerical stability&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For my company, this is the prime reason that we use commercial MILP solvers. Ensuring the quality of numerics, especially when it comes to matrices with numbers that span several orders of magnitude (and just can't be scaled well), is something very few people know how to do properly. Another typical example would be constraint propagation which is notoriously numerically unstable if implemented using normal floating point numbers.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;strong&gt;MIP Heuristics&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;When it comes to pure LP, open source is actually not much worse than commercial for decently sized problems. When integer variables are introduced however, the difference in performance can be 1000x or even more for large problems. The main reason is the MIP heuristics employed by commercial solvers. This information is a closely guarded trade secret.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;&lt;strong&gt;Finding an integral feasible point&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Finding an integral feasible point is actually (if memory serves) NP-complete. People don't notice most of the time because solvers have great heuristics to find these initial feasible points in practice, but implementing that from scratch is quite non-trivial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Coming back to my very first sentence, it is very possible to build a specialised solution if one knows what they are doing and decides they don't care about e.g. numerical stability for their application because that specific application happens to be well-behaved (for instance skip matrix preconditioning, scaling, or expensive numerics for stable constraint propagation). In any other case, my experience has been that solvers will win nearly every time.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2019-08-27T10:28:19.403" LastActivityDate="2019-08-27T10:28:19.403" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1360" PostTypeId="2" ParentId="1354" CreationDate="2019-08-23T16:22:44.470" Score="10" Body="&lt;p&gt;The simple answer is that for large scale problems (1m+ rows and columns) we would use interior point instead of dual simplex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main challenge is not really the solving algorithm, since interior point has polynomial complexity for LP, it's the implementation challenges, i.e., manipulating matrices that take up massive memory (and sometimes need to be cached into the hard drive or distributed among numerous machines), as well as numerical stability and factorising the coefficient matrix which are prone to large scale difficulties.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2019-08-27T10:25:16.323" LastActivityDate="2019-08-27T10:25:16.323" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="1361" PostTypeId="2" ParentId="1329" CreationDate="2019-08-23T16:40:09.687" Score="-1" Body="&lt;p&gt;It is not really fair to compare formulations with different decision variables because the two models essentially describe different things, hence performance is tied to how well the problem is described. An example would be coarse-graining a problem with say 1000 products into 10 chunks of 100 products to improve runtime. Sure, the second formulation is more powerful (because it's tractable), but it's up to the modeller to determine whether the loss of modelling accuracy is acceptable. Sometimes it will be (and the coarse-grained formulation wins) and sometimes it won't. The same goes for modelling time as a set of integer variables vs one continuous variable.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-08-23T16:40:09.687" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1362" PostTypeId="2" ParentId="1032" CreationDate="2019-08-23T17:07:41.333" Score="6" Body="&lt;p&gt;Pyomo has an ASL interface, hence any solver that is equipped with one will work out of the box. Commercial options that have free variable limited demos would be KNITRO, BARON, or Octeract Engine, and open source options include Couenne, or MINOTAUR. For some of the commercial solvers you might need to request a special version from the vendor that comes with the interface (or buy the AMPL) version, whereas other provide it by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, ipopt is so widespread among open source that many other nonlinear solvers invoke it anyway. Couenne and MINOTAUR are interesting options because they come with computational graph-based automatic differentiation which their version of ipopt uses.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2019-08-23T17:14:14.390" LastActivityDate="2019-08-23T17:14:14.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1363" PostTypeId="2" ParentId="1292" CreationDate="2019-08-23T17:25:07.883" Score="2" Body="&lt;p&gt;Some good places code-wise to start would be SCIP, Couenne, and MINOTAUR, because their code is fairly well written. If you're feeling really hardcore you can also try reading BONMIN's code but that's pretty undecipherable.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-08-23T17:25:07.883" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1364" PostTypeId="1" AcceptedAnswerId="1377" CreationDate="2019-08-23T17:46:20.587" Score="9" ViewCount="286" Body="&lt;p&gt;I am trying to find extreme rays of a polyhedral cone using polymake. My understanding is that in a cone, every feasible solution is also a ray and an extreme ray is a ray that cannot be written as the convex combination of two other rays. The methods &lt;code&gt;RAYS&lt;/code&gt; and &lt;code&gt;LINEARITY_SPACE&lt;/code&gt; give me some rays that generate the cone but I found an example where one of the rays can be written as the combination of two other rays. Are the results of &lt;code&gt;RAYS&lt;/code&gt; not guaranteed to be extreme rays? If so, is there a method to get the extreme rays?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;declare $cone=new Cone&amp;lt;Rational&amp;gt;(INEQUALITIES=&amp;gt;[[1, 0, 1], [2, 1, 0]]);&#xA;# Note that all variables are unbounded.&#xA;&#xA;print_constraints($cone);&#xA;Inequalities:&#xA;0: x0 + x2 &amp;gt;= 0&#xA;1: 2 x0 + x1 &amp;gt;= 0&#xA;&#xA;print $cone-&amp;gt;RAYS; &#xA;1 -2 0&#xA;0 1 0&#xA;&#xA;print $pq-&amp;gt;LINEALITY_SPACE; &#xA;-1 2 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first returned ray &lt;span class=&quot;math-container&quot;&gt;$(1, -2, 0)$&lt;/span&gt; can be written as &lt;span class=&quot;math-container&quot;&gt;$(1, -2, -1) + (0, 0, 1)$&lt;/span&gt; so it cannot be extreme.&lt;/p&gt;&#xA;" OwnerUserId="1180" LastActivityDate="2019-08-26T06:16:43.893" Title="Extreme rays in polymake" Tags="|linear-programming|extreme-rays|unboundedness|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="1365" PostTypeId="2" ParentId="1353" CreationDate="2019-08-23T18:07:19.107" Score="7" Body="&lt;p&gt;I assume that each defect requires a specified amount of labor (expressed in worker-hours) to solve, and that each worker contributes one hour of labor for each hour of their shift (no breaks). You might look at modeling demand and labor in a cumulative manner. For each hour of the time horizon, total the worker-hours required to fix all defects that must be completed on or before that hour. (This is a cumulative total, including defects that were reported more than 24 hours earlier than the target hour.) Similarly, for each hour of the time horizon calculate the total number of worker-hours applied from the start of the horizon up to that hour (where each worker contributes one hour for each hour that his/her shift overlaps the cumulative time interval). In order not to have any defects &quot;age out&quot;, the cumulative total of worker-hours must equal or exceed the cumulative demand at each hour of the horizon.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-23T18:07:19.107" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1366" PostTypeId="1" CreationDate="2019-08-23T21:59:09.923" Score="14" ViewCount="1364" Body="&lt;p&gt;Some optimization software/frameworks (commercial or open-source) such as &lt;a href=&quot;https://ampl.com/&quot; rel=&quot;noreferrer&quot;&gt;AMPL&lt;/a&gt;, &lt;a href=&quot;https://www.gams.com/&quot; rel=&quot;noreferrer&quot;&gt;GAMS&lt;/a&gt;, &lt;a href=&quot;https://www.ibm.com/analytics/cplex-optimizer&quot; rel=&quot;noreferrer&quot;&gt;Cplex&lt;/a&gt;, ... have a specific Algebraic modelling language. Some of them have another type of programming that uses APIs to connect with general programming languages ​​like C ++ / Java or others. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK, Algebraic modelling language is a bit easier than general programming to write optimization models. I would like to know, especially in the practical situation (solving a real-world optimization model):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) What is the difference between them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Is it necessary to know a general programming language to write an optimization model?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) What is the benefit of using a specific Algebraic modelling language over others (for instance GAMS Vs AMPL or OPL)?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="38" LastEditDate="2019-09-21T01:20:16.907" LastActivityDate="2019-09-21T01:20:16.907" Title="Comparison of Algebraic modelling languages and general programming languages" Tags="|modeling|ampl|gams|modeling-languages|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1367" PostTypeId="1" AcceptedAnswerId="1371" CreationDate="2019-08-23T22:43:58.560" Score="16" ViewCount="1615" Body="&lt;p&gt;In the study of a certain pure mathematical problem (related to infinite-dimensional Lie algebras) I found myself in a situation where it would be very desirable to be able to solve an integer programming problem, where one of the constraints is a divisibility assumption. Namely, for the variables &lt;span class=&quot;math-container&quot;&gt;$x_i\in\mathbb{Z}_{\geqslant0}$&lt;/span&gt; this constraint is of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ Q(x_1,\ldots,x_n)\quad \text{divides}\quad L(x_1,\ldots,x_n),$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is linear and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is quadratic. (for completeness: the function to minimize is simply &lt;span class=&quot;math-container&quot;&gt;$\sum x_i$&lt;/span&gt;, and other constraints are &lt;span class=&quot;math-container&quot;&gt;$P(x_i)&amp;gt;0$&lt;/span&gt; for some quadratic &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(x_1,\ldots,x_n)$&lt;/span&gt; is not an integer linear combination of some given integer vectors)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't reckon there is an out-of-the-box solution for this, so I wonder if someone has considered any other problems of this sort, say, where there is a constraint of the form &quot;&lt;span class=&quot;math-container&quot;&gt;$L_1(x_i)$&lt;/span&gt; divides &lt;span class=&quot;math-container&quot;&gt;$L_2(x_i)$&lt;/span&gt;&quot; for some linear &lt;span class=&quot;math-container&quot;&gt;$L_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L_2$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1231" LastEditorUserId="123" LastEditDate="2019-10-19T15:45:01.420" LastActivityDate="2019-10-19T15:45:59.187" Title="Divisibility constraints in integer programming" Tags="|integer-programming|constraint|quadratic-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1368" PostTypeId="2" ParentId="1366" CreationDate="2019-08-24T04:12:30.993" Score="10" Body="&lt;p&gt;GAMS and AMPL are general purpose modelling languages and can he used to describe any type of nonlinear function, including some niche stuff like floor, ceil, max, etc (AMPL). I don't have experience with OPL so I can't comment on that. The purpose of these languages is twofold: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;They provide a solver interface for your math. Solvers typically require input in a matrix or computational graph format, and for some (e.g. IPOPT) users need to also provide derivatives as callbacks. AMPL/GAMS take care of that for us.&lt;/li&gt;&#xA;&lt;li&gt;They enable the modeller to describe the problem using set notation which is a very powerful way to describe complicated problems.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To answer your questions specifically: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The difference among the languages is mainly in syntax and that they are typically tied to that vendor's product, i.e. you need AMPL to interpret AMPL models. For most cases users won't experience any limitations using one vs the other unless they are doing advanced stuff, e.g. generating defining variables/constraints (AMPL), or coding loops in their model (GAMS).&lt;/li&gt;&#xA;&lt;li&gt;No it is not necessary to know a programming language. Especially for AMPL, it pretty much looks like typing math.&lt;/li&gt;&#xA;&lt;li&gt;At the end of the day it depends on what platform you want to use and what solvers are available. GAMS has a workable GUI and many more solvers than AMPL, however AMPL is blazingly fast for large problems. In my opinion, the AMPL language is also much easier to read and to work with than the GAMS language is. I suggest that you download their demos and read some examples to get a feel for the two platforms and see which one works best for you.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-08-24T04:12:30.993" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1369" PostTypeId="1" AcceptedAnswerId="1370" CreationDate="2019-08-24T16:59:24.403" Score="6" ViewCount="215" Body="&lt;p&gt;I know that for some solvers, for example, the constraint programming solver in Google OR-Tools, it is possible to see all the intermediate solutions that the solver finds while it searches for an optimal solution. (An example is in &lt;a href=&quot;https://developers.google.com/optimization/cp/cp_solver#all_solutions&quot; rel=&quot;noreferrer&quot;&gt;this link&lt;/a&gt;.) I need these step-wise partial solutions to visualize the evolution of the optimization process in a physical example where I have a nonlinear 0-1 integer problem that I programmed in AMPL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;My questions are:&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;When solving nonlinear 0-1 integer problems, is it logical to consider such intermediate solutions?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it possible to obtain the intermediate solutions of solvers using AMPL? Which solvers have such a feature for AMPL?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="39" LastEditorUserId="38" LastEditDate="2019-08-24T20:40:35.770" LastActivityDate="2019-08-24T20:40:35.770" Title="Obtaining the intermediate solutions in AMPL" Tags="|integer-programming|solver|nonlinear-programming|binary-variable|ampl|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1370" PostTypeId="2" ParentId="1369" CreationDate="2019-08-24T19:20:02.297" Score="4" Body="&lt;p&gt;Yes it is reasonable. For problems where closing the optimality gap is difficult, you may want to save e.g. the 10 best solutions found before termination. This is called a solution pool and it is a solver specific option that you must pass to the solver from AMPL (check the solvers' manuals for &quot;solution pool&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most linear solvers support this (including CPLEX and GUROBI) - as for NLP solvers I believe that BARON supports this as well.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-08-24T19:20:02.297" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1371" PostTypeId="2" ParentId="1367" CreationDate="2019-08-24T21:28:17.143" Score="17" Body="&lt;p&gt;I going to assume that the ratio &lt;span class=&quot;math-container&quot;&gt;$L(x)/Q(x)$&lt;/span&gt; is nonnegative. If it can be negative, I think there may be a workaround, but this will complicated enough without dealing with that. I'm also going to assume that &lt;span class=&quot;math-container&quot;&gt;$Q(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L(x)/Q(x)$&lt;/span&gt; have &lt;em&gt;a priori&lt;/em&gt; upper and lower bounds, say &lt;span class=&quot;math-container&quot;&gt;$\underline{Q} \le Q(x) \le \overline{Q}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L(x)/Q(x) \in \{1,\dots,N\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create new general variables &lt;span class=&quot;math-container&quot;&gt;$z_1,\dots,z_N$&lt;/span&gt; and binary variables &lt;span class=&quot;math-container&quot;&gt;$y_1,\dots,y_n$&lt;/span&gt;. Add the constraint &lt;span class=&quot;math-container&quot;&gt;$y_1 + \dots + y_N = 1$&lt;/span&gt;. The &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables will pick the multiple to use. Add the following constraints: &lt;span class=&quot;math-container&quot;&gt;$$L(x)=\sum_{i=1}^N z_i$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$\underline{Q}y_i \le z_i \le \overline{Q}y_i \quad \forall i$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$i\cdot Q(x) - M_{i1} (1-y_i) \le z_i \le i\cdot Q(x) + M_{i2} (1- y_i) \quad \forall i,$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M_{i1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_{i2}$&lt;/span&gt; are sufficiently large positive constants (but not too much larger than necessary -- making them overly large impacts solver performance negatively).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Exactly one of the &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; will take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. For all other indices &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, you'll have &lt;span class=&quot;math-container&quot;&gt;$y_j = 0 \implies z_j = 0$&lt;/span&gt;. For that one index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, you'll have &lt;span class=&quot;math-container&quot;&gt;$L(x) = z_i = i\cdot Q(x)$&lt;/span&gt;. &lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="123" LastEditDate="2019-10-19T15:45:59.187" LastActivityDate="2019-10-19T15:45:59.187" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1372" PostTypeId="2" ParentId="1318" CreationDate="2019-08-25T08:36:02.743" Score="7" Body="&lt;p&gt;Earlier this year I needed a web application to let some Chinese students (with varying English language proficiencies) play around with models for Timetabling and Rolling Stock scheduling. I used an architecture much flatter than what Gurobi proposes, which did work in the small scale classroom setting (10~20 students). I first toyed around with a client-side only architecture, but since that was too limited and I do most of my stuff in Java with CPLEX, I ended up using &lt;a href=&quot;https://spring.io/projects/spring-boot&quot; rel=&quot;nofollow noreferrer&quot;&gt;Spring Boot&lt;/a&gt; for the backend. I'll discuss your questions based on my experience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question 1&lt;/strong&gt;: there are definitely simpler architectures than the one proposed by Gurobi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Option A: everything client-side&lt;/em&gt;: this is the simplest architecture you can have, in my opinion, but it has a large drawback: you need a solver in pure Javascript, so the high-quality commercial solvers are definitely out of scope. However, some people have used &lt;a href=&quot;https://github.com/emscripten-core/emscripten&quot; rel=&quot;nofollow noreferrer&quot;&gt;Emscripten&lt;/a&gt; to compile some of the open source solvers to Javascript. The example posted by &lt;a href=&quot;https://gist.github.com/fhk/0aba10a289a5e6b253fb2abf268469ac&quot; rel=&quot;nofollow noreferrer&quot;&gt;fhk&lt;/a&gt; uses a Javascript compiled version of &lt;a href=&quot;http://lpsolve.sourceforge.net/5.5/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lp_solve&lt;/a&gt;, in my own attempts I ended up using a &lt;a href=&quot;https://github.com/jvail/glpk.js&quot; rel=&quot;nofollow noreferrer&quot;&gt;Javascript version of GLPK&lt;/a&gt;. Both solvers are fine for small linear programs, but for integer programs, you run into problems quickly. Also, running everything in the browser results in a lot of overhead, so even if the official version is able to solve a model, it is still possible the Javascript version runs into trouble. Also, the API's of these solvers are not extremely nice (at least there are quite different from the way I like to convert instance data into an LP/IP-model). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An important advantage of this approach is that deployment is dead simple: you just have to server static HTML, and you can do that from something like Github pages. Also, you can build everything in Javascript, so you need to focus on a single programming language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Option B: call the solver in a request handler:&lt;/em&gt; this approach introduces a server-side but keeps the server-side minimal. In my case, the design of the back-end looked roughly as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    // Return the .html template that contains the client side application&#xA;    @GetMapping(&quot;/tt&quot;)&#xA;    public String tt() {&#xA;       return &quot;timetabling&quot;;&#xA;    }&#xA;&#xA;    @PostMapping(&quot;/tt/solve&quot;)&#xA;    @ResponseBody&#xA;    public TTSolution ttSolve(@RequestBody TTInstance instance) throws IloException {&#xA;        // Check if the size of the instance is small enough to solve quickly&#xA;        // Build a CPLEX model based on the TTInstance object (set the number of threads used to 1)&#xA;        // Solve this model like you would in a regular Java program calling CPLEX&#xA;        // Obtain a TTSolution object from the solution found by the solver.&#xA;        return solution;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The nice thing is that if you design your &lt;code&gt;TTInstance&lt;/code&gt; and &lt;code&gt;TTSolution&lt;/code&gt; classes properly (in particular in a way that they can be automatically converted to/from JSON by Spring), your client-side application only needs to send a properly structured instance data object as a web-request, and it will receive a nicely structured object with the solution after POSTing the instance data to the &lt;code&gt;/tt/solve&lt;/code&gt; endpoint. I used &lt;a href=&quot;https://vuejs.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vue.js&lt;/a&gt; to make a nice front-end application where it is easy to edit model data in a guided manner and explore the resulting solution, &lt;a href=&quot;https://github.com/axios/axios&quot; rel=&quot;nofollow noreferrer&quot;&gt;Axios&lt;/a&gt; to POST the model data and receive a solution from the server, and &lt;a href=&quot;https://getbootstrap.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bootstrap&lt;/a&gt; to make things look nice. Creating the front-end was more effort than creating the backend, in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this architecture still has a number of drawbacks: your solutions times/memory usage should be reasonably low, and the number of concurrent users should be low as well. The first reason is that if a POST-request takes to long, the web-browser or web-server will typically cancel the request. Additionally, if the solver consumes too many resources, it can take the whole web application server down with it. This is the main reason why Gurobi proposes an architecture with separate worker processes: the web controller's request handlers, only need to send the data into a job queue, from where the workers retrieve their tasks. If a worker then takes too long or uses too many resources, it can be killed without any risk for the web application server (besides having a failed job).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the advantages of this design are pretty clear: by running the solver directly in the handler of a POST-request, you avoid the need for a job queue, separate worker processes and a database to store the instances and their solutions. In fact, there is no need to persist data at all, and if you want to do it anyway, you can opt to do it all in the browser, e.g. via localStorage, or by implementing import/export functionality based on Javascript's FileReader functionality and ability to create a local download.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yes, you can flatten the architecture either to a single client-side application (html/css/javascript), or to a client-side application with a simple backend server that does the solving directly in the request handler. Both options do make sense for prototyping/demonstration purposes. For a backend, you need a language that offers both a web-framework and a good interface to a solver. For someone who is inexperienced, Python is probably the most convenient candidate (fhk mentions the &lt;a href=&quot;https://github.com/pallets/flask&quot; rel=&quot;nofollow noreferrer&quot;&gt;Flask web framework&lt;/a&gt;), as I believe Python has nicer bindings with different solvers, in particular, the open source ones. From experience, I know Java is also up to the task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question 2:&lt;/strong&gt; If your prototype is small enough to do everything in the browser, the only technology you need to understand is html/css/javascript. It is likely you need to learn these technologies anyway, as they are so fundamental to web applications. There are plenty of tutorials and guides for these technology stacks, just pick something modern that suits you well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do need a better solver, but can still call in directly in a POST-request handler, the backend will be very easy to set up and a basic introduction to your web application framework of choice should probably cover what you need, as there is no need to work with databases/message queue/job workers. The main thing that needs to happen is to convert JSON data to object data, and you need to write code that does the actual optimization, but any REST-API tutorial should give you what you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question 3:&lt;/strong&gt; how easy it is to deploy something, depends on the web application framework and the architecture. The client-side only application can be made available on almost any place where you can put a static website, which is really easy. If you work with a backend, it is easier to do the actual development on your own computer before you deploy it to the internet. If you are satisfied with your application, you should read the documentation of your web application framework whether it has pointers on good ways to deploy an application. There are many cloud providers that can run these applications directly, but it is also an option to get a virtual private server and run the application yourself (although that is probably more of a hassle).&lt;/p&gt;&#xA;" OwnerUserId="1047" LastEditorUserId="36" LastEditDate="2019-08-25T15:00:48.167" LastActivityDate="2019-08-25T15:00:48.167" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1374" PostTypeId="2" ParentId="488" CreationDate="2019-08-25T16:54:37.873" Score="3" Body="&lt;p&gt;Yes it is very possible, we experimented with this when designing &lt;a href=&quot;https://octeract.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Engine&lt;/a&gt;. However, it turns out that in practice NLP solvers have a lot of trouble finding feasible solutions once the model has more than a few binaries. Even when they do find feasible solutions, these tend not to be very numerically stable most of the time.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-08-25T16:54:37.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1375" PostTypeId="2" ParentId="552" CreationDate="2019-08-25T17:36:01.547" Score="1" Body="&lt;p&gt;Assuming you have two closed polytopes, we can compare the volumes of the two polytopes as Rob Pratt mentioned. Unfortunately this is NP-hard as we need to identify all the vertices. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more tractable (heuristic) metric would be to measure the distance between every constraint and its relaxation (e.g. at the midpoints or some arbitrary vertex) and get a point-system based measure of tightness. This is of course a heuristic, but it can give you some measure of what's happening and how your overall tightness improves over time. This is much more tractable than calculating the volumes as it has linear complexity with respect to the number of your constraints.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-08-25T17:36:01.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1376" PostTypeId="2" ParentId="1367" CreationDate="2019-08-25T17:47:10.940" Score="2" Body="&lt;p&gt;There are two ways I would interpret the divisibility requirement:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Functional division, i.e., &lt;span class=&quot;math-container&quot;&gt;$L_1(x)/L_2(x)$&lt;/span&gt; is a valid polynomial division. Since we are dividing a linear function by another linear function, that result should be a constant or another linear function.&lt;/li&gt;&#xA;&lt;li&gt;Integer division, i.e., &lt;span class=&quot;math-container&quot;&gt;$L_1(x)/L_2(x)$&lt;/span&gt; produces an integral result.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Functional division&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you want is to show that after the division operation you are left with a polynomial of at most degree &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. A way to impose this would be through a constraint like so: &lt;span class=&quot;math-container&quot;&gt;$L/Q = y_1x+y_2$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; are real auxiliary variables (usually with fairly large bounds).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vector format, that would be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{L_1(x)}{L_2(x)}=\sum_{i=1}^n\left(y_{1i}x_i+y_{2i}\right).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is impossible to get a valid linear function as a result of the division, this constraint will be infeasible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Integer division&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming that we want the result of the division operation to be a pure integer, we can impose this by adding the following constraint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L_1(x)=yL_2(x),y\in[L,U]$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is integer and L,U are large integer bounds for this constraint. Moving &lt;span class=&quot;math-container&quot;&gt;$L_2(x)$&lt;/span&gt; to the rhs is usually a good idea as division by zero is not a problem numerically (we can handle the zero case in a different constraint if we so desire). This formulation also allows us to handle a case where there is a remainder, like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L_1(x)=yL_2(x)+r,y,r\in[L,U]^2$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where r is our remainder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, for the original case of &lt;span class=&quot;math-container&quot;&gt;$L(x)/Q(x)$&lt;/span&gt;, the constraint would be the very similar:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L(x)=yQ(x),y\in[L,U]$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Big bounds for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are quite important here because the result of the division may span several orders of magnitude. A more solver-friendly way to handle &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in this case would be to reformulate it as a binary sum.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2019-08-26T01:12:38.407" LastActivityDate="2019-08-26T01:12:38.407" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1377" PostTypeId="2" ParentId="1364" CreationDate="2019-08-25T22:11:50.540" Score="4" Body="&lt;p&gt;Not all polyhedral cones possess extreme rays. Take for instance the half-space &lt;span class=&quot;math-container&quot;&gt;$x = 0$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$\Bbb R^3$&lt;/span&gt;. There are no extreme rays, but there are lineality rays &lt;span class=&quot;math-container&quot;&gt;$(0, 1, 0)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(0,0,1)$&lt;/span&gt;. The pair &lt;span class=&quot;math-container&quot;&gt;$(0, 1, 0)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(0,0,1)$&lt;/span&gt; isn't unique, in fact they can be rotated by any angle about &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;-axis, and you still get a valid lineality space. There exist polyhedral cones that can be decomposed into a Minkowski sum of lineality space and conic combination of a bunch of rays (say &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt;), where the set &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; is not unique. In such cases, you need to check what polymake will return. An example would be is &lt;span class=&quot;math-container&quot;&gt;$z\ge x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z\ge0$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$(x,y,z)$&lt;/span&gt; space. &#xA;The concept of extreme rays is relevant mostly to pointed cones i.e cones that do not contain a line segment passing through the origin.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="123" LastEditDate="2019-08-26T06:16:43.893" LastActivityDate="2019-08-26T06:16:43.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1378" PostTypeId="2" ParentId="715" CreationDate="2019-08-26T01:07:50.990" Score="2" Body="&lt;p&gt;With the exception of special cases, this problem is NP-hard. One interesting case is that minimizing a convex or concave function over a simplex can be solved in &lt;a href=&quot;https://link.springer.com/referenceworkentry/10.1007%2F0-306-48332-7_65&quot; rel=&quot;nofollow noreferrer&quot;&gt;polynomial time&lt;/a&gt;. In other special cases it is also possible to linearise the problem through reformulations. In the general case however this would be solved by relaxing the objective and using branch and bound to find the global optimum. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is interesting to note that there are two parts to NP-hardness in optimisation: (i) finding a solution, and (ii) verifying the solution. Because verifying the solution cannot be done in polynomial time, even if we have a solution it is still NP-hard to prove that it is globally optimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We see this a lot in practice as well. In global optimisation finding a solution is the easy part - the difficult part is to prove/disprove that it is globally optimal.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-08-26T01:07:50.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1379" PostTypeId="2" ParentId="503" CreationDate="2019-08-26T01:22:20.293" Score="2" Body="&lt;p&gt;A non-convex QP is solved to global optimality by generating the McCormick relaxation of the objective and using that relaxation in a branch-and-bound framework. For non-convex MIQPs, we also introduce integer cuts during the branch-and-bound procedure (branch-and-cut).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-08-26T01:22:20.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1380" PostTypeId="1" CreationDate="2019-08-26T05:02:13.340" Score="17" ViewCount="856" Body="&lt;p&gt;The closest thing I know is the computer vision problem, in which an image is de-blurred and/or de-noised by quadratizing a quartic problem into a quadratic optimization problem (QUBO) and then the QUBO is solved. However it seems that deep neural networks solve this computer vision problem much more efficiently. Are there any cases where quadratization is an essential component of a state-of-the-art algorithm for a real-world problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Added:&lt;/strong&gt; I thank the user named Rob for answering my question when no one else did, but I am still looking for an answer. The copying and pasting of those abstracts from papers that I am very familiar with, was not really what I was looking for (in fact I am an author on one of those papers!). The statement &quot;Quadratization has been used in pseudo-Boolean optimization (Implementation of QPBO (C++)) and unconstrained binary polynomial optimization problems&quot; is not really true, because QPBO happens &lt;em&gt;after&lt;/em&gt; quadratization. QPBO is used in exactly the example I already gave (computer vision), but there's better ways to solve that computer vision problem (e.g. deep neural networks) so QPBO and quadratization are both not needed to to solve that problem. The question does not request a list of papers that have &lt;strong&gt;&lt;em&gt;used&lt;/em&gt;&lt;/strong&gt; quadratization, but asks for an example of a problem for which &lt;strong&gt;&lt;em&gt;no better solution exists without using quadratization&lt;/em&gt;&lt;/strong&gt; because in all examples given so far, the problem can be solved better without quadratization into QUBO form.  &lt;/p&gt;&#xA;" OwnerUserId="727" LastEditorUserId="727" LastEditDate="2020-06-07T19:41:09.257" LastActivityDate="2020-10-17T09:05:49.683" Title="Are there any real-world problems where quadratization helps to solve something that couldn't have been solved without quadratization?" Tags="|optimization|applications|quadratic-programming|machine-learning|open-problems|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1381" PostTypeId="2" ParentId="11" CreationDate="2019-08-26T09:16:58.493" Score="7" Body="&lt;p&gt;In our JOC paper (Pessoa et al.) mentioned by Claudio, we have performed comparison (on 9 different problems including VRP) between some penalty function approaches and dual price smoothing (both are described in the Claudio's answer). Penalty function approaches we tried have generally better performance than dual price smoothing. However, the former are harder to implement and they are tricky to parameterize. The issue with parameterization gets worse when you start to add cuts and branch (dual values for cuts and branching constraints have generally different magnitude than ones for the &quot;core&quot; constraints). As a result, we almost always employ only dual price smoothing when using column generation or branch-(cut)-and-price (and we use them a lot). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the paper, we present a modification of original dual price smoothing by Wentges in which no parameterization is needed. This is very convenient, and it allows us to use dual price smoothing by default. Our experiments showed that using the parameter-less dual price smoothing is usually much better than not using any stabilization, and it never significantly deteriorates results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way to stabilize column generation is to use barrier solver for the master LP instead of the simplex algorithm. It may have a significant impact on the column generation performance. However, in some cases using barrier solver can deteriorate results significantly. We give some notes about this in the conclusions of our JOC paper. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I am not familiar with SCIP and I do not understand about which objective coefficients you talk about (in the master problem or in the pricing problem). &lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2019-08-26T09:16:58.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1382" PostTypeId="2" ParentId="1281" CreationDate="2019-08-26T10:02:30.940" Score="6" Body="&lt;p&gt;There are two possible situations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) You still want to solve your VRP exactly or obtain a valid lower bound. Then heuristic pricing is used only to speed up column generation (and it is always used nowadays). At the end, you &lt;strong&gt;always&lt;/strong&gt; need to solve the pricing problem (or at least its relaxation) exactly. A standard approach for heuristic pricing is some modification of the labelling algorithm (mentioned above). Meta-heuristic algorithms have been less successful for this task. Although there is a paper on this subject (&lt;a href=&quot;https://doi.org/10.1287/trsc.1070.0223&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/trsc.1070.0223&lt;/a&gt;), recent attempts have not been successful (yet) as I know from communication with people working on it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) You want to solve you VRP heuristically by a branch-(cut)-and-price (BCP). In principle, you can then solve the pricing problem heuristically. However, this approach is (arguably) not competitive with other more standard heuristics. Probably for this reason there are no papers on heuristic BCP in the literature for vehicle routing problems (I am not aware of them). &lt;/p&gt;&#xA;" OwnerUserId="835" LastEditorUserId="835" LastEditDate="2019-08-26T10:56:18.390" LastActivityDate="2019-08-26T10:56:18.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1383" PostTypeId="2" ParentId="1319" CreationDate="2019-08-26T10:27:00.123" Score="3" Body="&lt;p&gt;The smallest formulation will be with these constraints:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{t}t\cdot s_{j_1,t} + p_{j_1}\leq \sum_{t}t\cdot s_{j_2,t},\quad \forall (j_1,j_2)\in P$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, much stronger LP relaxation will be with constraints&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{t'\leq t}s_{j_1,t'}\geq \sum_{t'\leq t+p_{j_1}}s_{j_2,t'},\quad \forall (j_1,j_2)\in P, \forall t$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(or its equivalent form suggested by @Borelian, which produces a much sparser matrix).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having to handle precedence constraints usually makes a scheduling problem much more complicated when solved by MIP approaches. So a CP approach can be more efficient, as suggested by @Laurent.&lt;/p&gt;&#xA;" OwnerUserId="835" LastEditorUserId="123" LastEditDate="2019-08-26T18:42:20.173" LastActivityDate="2019-08-26T18:42:20.173" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1384" PostTypeId="1" CreationDate="2019-08-26T10:41:11.110" Score="11" ViewCount="1881" Body="&lt;p&gt;What is the most common package for discrete-event simulation in the OR community?&#xA;I have found &lt;a href=&quot;https://simpy.readthedocs.io/en/latest/&quot; rel=&quot;noreferrer&quot;&gt;SimPy&lt;/a&gt; package. &lt;/p&gt;&#xA;" OwnerUserId="1094" LastEditorUserId="126" LastEditDate="2019-08-27T06:52:58.580" LastActivityDate="2019-08-27T06:52:58.580" Title="Simulation in Python" Tags="|python|software|simulation|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1385" PostTypeId="2" ParentId="281" CreationDate="2019-08-26T10:49:14.853" Score="1" Body="&lt;p&gt;There is a nice in-depth review of different MIP formulations for machine scheduling problems by Queyranne and Schulz: &lt;a href=&quot;https://pdfs.semanticscholar.org/a00d/f7ab46627debbfde11bfe2b019d4d3a5c72d.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pdfs.semanticscholar.org/a00d/f7ab46627debbfde11bfe2b019d4d3a5c72d.pdf&lt;/a&gt;&#xA;It is dated, but still relevant today I think.&lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2019-08-26T10:49:14.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1386" PostTypeId="1" AcceptedAnswerId="1389" CreationDate="2019-08-26T12:17:10.850" Score="12" ViewCount="636" Body="&lt;p&gt;Consider an implication of the form &lt;span class=&quot;math-container&quot;&gt;$A \implies B$&lt;/span&gt; where both &lt;span class=&quot;math-container&quot;&gt;$A, B$&lt;/span&gt; comprises a chain of Boolean OR variables. For example, &lt;span class=&quot;math-container&quot;&gt;$(a_1 \lor a_2 \lor a_3) \implies  (b_1 \lor b_2 \lor b_3)$&lt;/span&gt;. How can this be expressed as an ILP? All variables are Boolean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have derived the following using CNF, however it turns out to be non-linear, can this be expressed in Linear Form?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let us suppose &lt;span class=&quot;math-container&quot;&gt;$A = \{ a_1, a_2, a_3\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B = \{ b_1, b_2, b_3\}$&lt;/span&gt;. thus,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\bigvee A \implies \bigvee B \\&#xA;\overline{\bigvee A} \bigvee \left(\bigvee B\right) \\&#xA;\left(\bigwedge_{a \in A} \overline a\right) \bigvee  \left(\bigvee B\right) \\&#xA;\left(\bigwedge_{a \in A} (1-a)\right) \bigvee  \left(\bigvee B\right) \\&#xA;\left(\prod_{a \in A} (1-a)\right) \bigvee  \left(\sum_{b \in B} b\right) \\&#xA;\prod_{a \in A} (1-a) +  \sum_{b \in B} b \geq 1&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, thus leads to  &lt;span class=&quot;math-container&quot;&gt;$(1-a_1)(1-a_2)(1-a_3) + b_1 + b_2 + b_3 \geq 1$&lt;/span&gt;, which essentially leads to a product of complements of the variables in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;. Can this be expressed in terms of linear constraints?&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="123" LastEditDate="2019-08-26T18:38:19.717" LastActivityDate="2019-10-19T15:43:34.010" Title="Expressing an implication as ILP where each implication term comprises a chain of boolean ORs" Tags="|optimization|modeling|integer-programming|nonlinear-programming|logical-constraints|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1387" PostTypeId="2" ParentId="1386" CreationDate="2019-08-26T12:30:02.397" Score="8" Body="&lt;p&gt;If I understand your question correctly then you want to model that if &lt;span class=&quot;math-container&quot;&gt;$$a_1+a_2+a_3\geq 1$$&lt;/span&gt; then it follows that &lt;span class=&quot;math-container&quot;&gt;$$b_1+b_2+b_3\geq 1.$$&lt;/span&gt; Since &lt;span class=&quot;math-container&quot;&gt;$A \implies B$&lt;/span&gt; is equivalent to &lt;span class=&quot;math-container&quot;&gt;$\neg A \lor B$&lt;/span&gt; we want to model &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^3 a_i &amp;lt; 1 \quad\bigvee\quad \sum_{i=1}^3 b_i \geq 1.$$&lt;/span&gt;&#xA; We can replace &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^3 a_i &amp;lt; 1$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i=1}^3 a_i =0$&lt;/span&gt; because the &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; are binary and obtain &lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{i=1}^3 a_i = 0\quad\bigvee\quad\sum_{i=1}^3 b_i \geq 1.$$&lt;/span&gt; This can be written as a single constraint in the following way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$3\sum_{i=1}^3 b_i \geq \sum_{i=1}^3 a_i $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if any of the &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; is true then the constraint forces at least of of the &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; to be true as well. On the other hand, if all the &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; anything can happen to the &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="81" LastEditorUserId="123" LastEditDate="2019-10-19T15:43:34.010" LastActivityDate="2019-10-19T15:43:34.010" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1388" PostTypeId="2" ParentId="1356" CreationDate="2019-08-26T13:53:43.240" Score="9" Body="&lt;p&gt;From my experience with industry: typically, you do not obtain the human planners' solutions to compare against optimal solutions for at least two reasons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the decisions/plans/solutions are not recorded, at least not completely&lt;/li&gt;&#xA;&lt;li&gt;the manual plans sometimes violate constraints in your model.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Even if both can be dealt with, companies don't want their data, let alone plans available online, which is reason number three (and probably the show stopper).&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-08-26T13:53:43.240" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1389" PostTypeId="2" ParentId="1386" CreationDate="2019-08-26T14:01:37.607" Score="9" Body="&lt;p&gt;For boolean formulas, you can use the following systematic approach. First, convert your formula to conjunctive normal form. &lt;a href=&quot;https://en.wikipedia.org/wiki/Conjunctive_normal_form#Converting_from_first-order_logic&quot; rel=&quot;noreferrer&quot;&gt;Wikipedia&lt;/a&gt; details how to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Applied to this specific case it follows that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(a_1 \vee a_2 \vee a_3) \Longrightarrow (b_1 \vee b_2 \vee b_3)$$&lt;/span&gt;&#xA;is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(\bar{a}_1 \vee b_1 \vee b_2 \vee b_3) \wedge (\bar{a}_2 \vee b_1 \vee b_2 \vee b_3) \wedge (\bar{a}_3 \vee b_1 \vee b_2 \vee b_3).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We then add a constraint for each clause:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;1 - a_1 + b_1 + b_2 + b_3 &amp;amp; \ge 1\\&#xA;1 - a_2 + b_1 + b_2 + b_3 &amp;amp; \ge 1\\&#xA;1 - a_3 + b_1 + b_2 + b_3 &amp;amp; \ge 1,&#xA;\end{align}$$&lt;/span&gt;&#xA;or equivalently&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;a_1 &amp;amp;\le b_1 + b_2 + b_3\\&#xA;a_2 &amp;amp;\le b_1 + b_2 + b_3\\&#xA;a_3 &amp;amp;\le b_1 + b_2 + b_3.&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this formulation is at least as strong as the one proposed by YukiJ, as adding the constraints together gives&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_1 + a_2 + a_3 \le 3(b_1 + b_2 + b_3).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, different approaches may give different formulations, and I am not claiming that this is the best approach. For more information, you may consider the book &lt;a href=&quot;https://www.doi.org/10.1007/978-0-387-92280-5&quot; rel=&quot;noreferrer&quot;&gt;Logic and Integer Programming by H. Paul Williams&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2019-08-26T14:13:36.450" LastActivityDate="2019-08-26T14:13:36.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1390" PostTypeId="2" ParentId="1356" CreationDate="2019-08-26T14:41:33.657" Score="7" Body="&lt;p&gt;It is not a dataset of solutions, but Section 1.4 of the TSP book [1] has a discussion about &quot;Human solution of the TSP&quot; with several references to the relevant &#xA;literature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] Applegate, D.L., Bixby, R.E., Chvatal, V. and Cook, W.J., 2006. The traveling salesman problem: a computational study. Princeton university press.&lt;/p&gt;&#xA;" OwnerUserId="224" LastActivityDate="2019-08-26T14:41:33.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1391" PostTypeId="2" ParentId="1384" CreationDate="2019-08-26T19:05:18.607" Score="6" Body="&lt;p&gt;Although this question is subjective (as noted in the paper below), I believe that there is enough research done on this topic to make it more answerable.&lt;/p&gt;&#xA;&lt;h2&gt;&lt;a href=&quot;https://www.informs-sim.org/wsc16papers/095.pdf&quot; rel=&quot;noreferrer&quot;&gt;Dias &lt;em&gt;et al.&lt;/em&gt; (2016)&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;The paper is very much like a systematic review. However, the paper ranks &lt;em&gt;commercial&lt;/em&gt; discrete-event simulation software, rather than the open-source &lt;em&gt;SimPy&lt;/em&gt; your have mentioned. Results are below.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In fact, apart from &lt;em&gt;Arena&lt;/em&gt; – &lt;strong&gt;by far the best classification tool with 9.9 out of 10 points&lt;/strong&gt; – and from the last four tools – &lt;em&gt;SimCAD Pro&lt;/em&gt;, &lt;em&gt;GPSS World&lt;/em&gt;, &lt;em&gt;SLX + Proof 3D&lt;/em&gt;&#xA;and &lt;em&gt;ShowFlow&lt;/em&gt; – the remaining tools are closely ranked.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Here is the breakdown. Content in bullet points is extracted from the paper.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;Arena&lt;/em&gt;, &lt;em&gt;ProModel&lt;/em&gt;, &lt;em&gt;AutoMod&lt;/em&gt; and &lt;em&gt;SIMPROCESS&lt;/em&gt; are the tools with the most presence in the WSC and Plant Simulation, &lt;em&gt;QUEST&lt;/em&gt;, &lt;em&gt;SimCAD Pro&lt;/em&gt; and &lt;em&gt;ShowFlow&lt;/em&gt; are the ones with the least WSC presence.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note: WSC = Winter Simulation Conference.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Three new parameters [...] were added: Scopus, Google Books and&#xA;number of published books related to the tool. &lt;em&gt;Arena&lt;/em&gt;, &lt;em&gt;ProModel&lt;/em&gt; and &lt;em&gt;SIMPROCESS&lt;/em&gt; are the tools with most presence in these documents databases. In their turns, &lt;em&gt;SimCAD Pro&lt;/em&gt;, &lt;em&gt;SLX + Proof 3D&lt;/em&gt; and &lt;em&gt;Showflow&lt;/em&gt; are the ones with the lowest factor parameter values.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The following analysis was obtained by using existing reviews and surveys.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Considering all the obtained average factor parameters values, &lt;em&gt;Arena&lt;/em&gt;, &lt;em&gt;ProModel&lt;/em&gt; and &lt;em&gt;Simul8&lt;/em&gt; obtained the best results, whilst &lt;em&gt;ProcessModel&lt;/em&gt; and &lt;em&gt;GPSS&lt;/em&gt; obtained the lowest values.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In terms of social networks such as Google+ and Twitter, the rankings are as follows.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The lack of significant presence of some tools in this frame should be stressed, c.f. &lt;em&gt;Micro Saint&lt;/em&gt;, &lt;em&gt;GPSS World&lt;/em&gt; and &lt;em&gt;ShowFlow&lt;/em&gt;. On the other hand, &lt;em&gt;Arena&lt;/em&gt; and &lt;em&gt;FlexSim&lt;/em&gt; are the tools with the most presence in social networks.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The following analysis (Google search) is very similar to that for Google books so one should expect similar results.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;Arena&lt;/em&gt;, &lt;em&gt;ProModel&lt;/em&gt;, &lt;em&gt;Micro Saint&lt;/em&gt; and &lt;em&gt;ProcessModel&lt;/em&gt; are the tools with higher&#xA;Google search results. On the other hand, &lt;em&gt;SimCAD Pro&lt;/em&gt;, &lt;em&gt;GPSS&lt;/em&gt; and &lt;em&gt;SLX&lt;/em&gt; obtained the lowest values.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Calculating the proportion of search results, &lt;em&gt;Arena&lt;/em&gt; wins again.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;Arena&lt;/em&gt; and &lt;em&gt;Simio&lt;/em&gt; are the tools with the best result for these parameters, indicating that these are the 2 tools with most growth in search results over the last 5 years. [...] &lt;em&gt;ShowFlow&lt;/em&gt; got the lowest value.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Dias, L. M. S., Vieira, A. A. C., Pereira, G. A. B., Oliveira, J. A. (2016). Discrete Simulation Software Ranking - A Top List Of The Worldwide Most Popular And Used Tools. &lt;em&gt;Proceedings of the 2016 Winter Simulation Conference.&lt;/em&gt; INFORMS. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-08-26T19:05:18.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1392" PostTypeId="1" AcceptedAnswerId="1395" CreationDate="2019-08-27T00:52:28.853" Score="24" ViewCount="3737" Body="&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A while ago my team was implementing an interior point LP solver and we came across the following conundrum:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a polynomial-time algorithm to find a feasible starting point&#xA;  in linear programming? If so, what is the algorithm?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Of course, it is a well-established result in the literature that LPs can be solved in polynomial-time, and we know from LP theory that the feasibility problem is as hard to solve as the LP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, looking deeper into the algorithms (as we had to implement them), we noticed that everything we could find either (i) assumed that a feasible starting point is already known, or (ii) required using an NP-complete/NP-hard method to locate the feasible point with a &lt;strong&gt;guarantee&lt;/strong&gt; (the guarantee part is important).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though this is not a big issue in practice because the algorithms work pretty well, we were left with a contradiction between what we knew from theory, and what we could find in the literature (no-one seems to mention this explicitly). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mentioned this in a couple of answers (namely &lt;a href=&quot;https://or.stackexchange.com/a/1360/1228&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/a/1359/1228&quot;&gt;here&lt;/a&gt;) and it naturally sparked some controversy, so I think it's an interesting question. It is of course very possible that at the time I missed/misunderstood something about the theoretical complexity of Phase I, so I am keen to know what you guys think!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: everything that follows assumes a general LP problem (inequality+equality constraints).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What we know&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Minimising the slack error during interior point is not guaranteed to get us to the interior of the feasible region.&lt;/li&gt;&#xA;&lt;li&gt;The ellipsoid method requires a feasible starting point.&lt;/li&gt;&#xA;&lt;li&gt;Phase I in the Two-Phase method (which is to identify a feasible basis) requires Simplex iterations, hence is not p-hard (especially if there is no feasible point at all).&lt;/li&gt;&#xA;&lt;li&gt;All algorithms we could find were based either on Simplex or Newton's method, neither of which is of polynomial complexity.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why the worst-case for Newton's method for interior point is not polynomial&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two main reasons for this. First, one of the assumptions for Newton's method requires us to be in the neighborhood of the solution, which we cannot guarantee in the general case. Second, Newton's method is not quite robust, as it depends not only on the quality of the derivatives but also on the step size. Therefore, the only way to &lt;strong&gt;always&lt;/strong&gt; solve the Newton system in practice is to use a higher complexity method such as Interval Newton or to solve a global optimisation problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Characteristics of the polynomial time algorithm&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Considering the above, if said algorithm exists I believe that it must have the following characteristics:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It must &lt;strong&gt;always&lt;/strong&gt; give a feasible point/prove no feasible point exists.&lt;/li&gt;&#xA;&lt;li&gt;It must not require a feasible starting point (otherwise it's a chicken and egg problem).&lt;/li&gt;&#xA;&lt;li&gt;It must not rely on Simplex pivots.&lt;/li&gt;&#xA;&lt;li&gt;It must be possible to &lt;strong&gt;implement&lt;/strong&gt; this algorithm in a way that it works in polynomial-time &lt;strong&gt;in practice&lt;/strong&gt; (see regular Newton vs Interval Newton).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2019-08-27T15:36:08.517" LastActivityDate="2022-10-06T19:29:12.727" Title="Find feasible point in polynomial time in linear programming" Tags="|linear-programming|feasible-points|interior-point-method|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1393" PostTypeId="2" ParentId="1392" CreationDate="2019-08-27T06:30:48.027" Score="14" Body="&lt;p&gt;Point 2 of &quot;What we know&quot; is incorrect: the ellipsoid method does not require a feasible starting point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I stated in a comment earlier, in &lt;a href=&quot;https://doi.org/10.1016/0041-5553(80)90061-0&quot; rel=&quot;noreferrer&quot;&gt;Khachiyan (1980)&lt;/a&gt; it is proven that &quot;determining the compatibility of a system of linear inequalities in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n$&lt;/span&gt; belongs to the class of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; of problems&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Section 6 of the paper, Khachiyan shows that if you can determine the compatibility of a system of linear inequalities in polynomial time, then you can also find the optimal solution to an LP in polynomial time, which is of course feasible.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2019-08-27T10:42:09.107" LastActivityDate="2019-08-27T10:42:09.107" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1394" PostTypeId="2" ParentId="1354" CreationDate="2019-08-27T06:32:27.683" Score="3" Body="&lt;p&gt;You are right that the dual simplex (and to some degree the primal simplex) are still very much state-of-the-art ways to solve LPs. The last 3 decades saw significant improvements on these algorithms but their main advantage remains warmstarting capabilities. Inside MILP solvers we need to solve many closely related problems and dual simplex (and in some cases primal simplex) excel at doing that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The interior point method lacks warmstarting but has the major advantage that for large problems it can be threaded fairly efficiently. Simplex algorithms in most cases gain very little from using parallel computing, which in the MIP solver setting is not that much of a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;New&quot; methods for solving LPs I am aware of (and currently remember) are the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;criss-cross methods (&lt;a href=&quot;https://en.wikipedia.org/wiki/Criss-cross_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Criss-cross_algorithm&lt;/a&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Kernel Simplex Method by Roland Wunderling. I saw several talks but can't seem to find a link.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;An Improved Primal Simplex Algorithm for Degenerate Linear Programs by Elhallaoui et al. (&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.1100.0425&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.1100.0425&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="302" LastActivityDate="2019-08-27T06:32:27.683" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1395" PostTypeId="2" ParentId="1392" CreationDate="2019-08-27T07:15:10.003" Score="22" Body="&lt;p&gt;It is not true that the Two-Phase methods requires Simplex iterations, it is just the common way to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's assume we have a linear program with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 1)&lt;/strong&gt; Convert this LP into standard form by splitting all unbounded variables into two &lt;span class=&quot;math-container&quot;&gt;$\geq 0$&lt;/span&gt; variables, making sure &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is non-negative (by multiplying the rows that violate this by &lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt;) and by introducing slack variables for all inequalities. Let's assume that this gives us the program:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{array}{lll} \max &amp;amp; cx \\ \mbox{s.t.} &amp;amp; Ax &amp;amp; = b \\ &amp;amp; x &amp;amp; \geq 0\end{array}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this program has at most &lt;span class=&quot;math-container&quot;&gt;$2n+m$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 2)&lt;/strong&gt; Construct the following linear program where we introduce &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; artificial variables as the vector &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and use identity matrix &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{array}{lll} \min &amp;amp; y \\ \mbox{s.t.} &amp;amp; Ax + Iy &amp;amp; =b \\ &amp;amp; x,y &amp;amp; \geq 0\end{array}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 3)&lt;/strong&gt; We now know for certain that the solution &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y=b$&lt;/span&gt; is a feasible solution for this LP (recall we made sure that &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is non-negative). Since &lt;span class=&quot;math-container&quot;&gt;$y \geq 0$&lt;/span&gt;, we also know that the minimum value of the LP can not be negative. Now if we optimize this LP and find a solution of objective &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, we know two things: (1) all artificial &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables have value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; in this solution (otherwise the objective would be positive) and (2) the solution we found is feasible for the LP in standard form. We also know that if the minimal objective is positive, no feasible point exist for the original LP (because if such a point would exist, it would provide us a with &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;-objective solution to the LP with artificial variables). Thus, we have found a feasible point by optimizing a linear program that is polynomially larger in size than the original LP. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the LP in step 3 can be optimized with any algorithm you like, you just must be able to find a path from your starting point to your feasible point. Therefore, if you have an algorithm that can take you from a feasible solution to an optimal solution in polynomial time, you can find a feasible solution in polynomial time. &lt;s&gt;Furthermore, you can solve the LP in step 3 with only &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; simplex iterations, because you should just pivot out one artificial variable in each step, and forget it exists as soon as you pivot it out. If the original LP is feasible, you can forget artificial variables without introducing any infeasibility. So in fact, the simplex method should also run in polynomial time for the first phase of the two phase approach.&lt;/s&gt; &lt;strong&gt;Correction:&lt;/strong&gt; I mistakenly assumed you can always select which variables you pivot out, but that is not true. However, it does not matter which polynomial time algorithm you use: as long as you believe there exists an algorithm that can take you from a feasbible solution to an optimal solution in polynomial time, you will always be able to find a feasible solution in polynomial time. As mentioned, the classical algorithms that prove this is possible are the &lt;a href=&quot;https://en.wikipedia.org/wiki/Ellipsoid_method&quot; rel=&quot;noreferrer&quot;&gt;Ellipsoid method&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Karmarkar%27s_algorithm&quot; rel=&quot;noreferrer&quot;&gt;Karmarkar's algorithm&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastEditorUserId="1047" LastEditDate="2019-08-27T13:11:01.463" LastActivityDate="2019-08-27T13:11:01.463" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1397" PostTypeId="2" ParentId="1341" CreationDate="2019-08-27T11:02:40.410" Score="5" Body="&lt;p&gt;It is possible. Although I haven't done this for a deep neural network (my experience was on a multi-layer perceptron), it shouldn't be that different procedure-wise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Considering that each neuron represents an analytical expression, it very possible to unwrap your network into one massive function. You can in principle do this using SymPy. You can walk your NN and recursively print the neurons to functions into a massive string and then parse it with SymPy. This will give you all the information you need to build a Pyomo model in code, however there are quite a few pitfalls.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;SymPy will likely not be able to handle this for any NN large enough to be useful.&lt;/li&gt;&#xA;&lt;li&gt;Pyomo (at least up till a couple of years ago) doesn't scale very well for big expressions.&lt;/li&gt;&#xA;&lt;li&gt;The resulting optimisation problem is highly non-linear and will probably destroy most solvers.&lt;/li&gt;&#xA;&lt;li&gt;A lot of code is required to glue all these pieces together properly.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Generally speaking, neural networks are not very amenable to classical optimisation technology, because (i) there are no constraints to exploit in order to reduce the solution space, (ii) the problems can be so large that memory/differentiation efficiency issues overpower most implementations. One way to handle this in practice would be to plug the model into a stochastic solver, but at that point we are not really benefiting from classical optimisation theory anymore.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-08-27T11:02:40.410" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1399" PostTypeId="2" ParentId="1341" CreationDate="2019-08-27T12:31:44.790" Score="4" Body="&lt;p&gt;Instead of deep learning, you can try to use so-called &quot;explainable machine learning&quot;, where you learn directly Boolean rules which are generally restricted to be short (of course, accuracy may suffer in this case). See, for example, this paper: &lt;a href=&quot;https://papers.nips.cc/paper/7716-boolean-decision-rules-via-column-generation.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://papers.nips.cc/paper/7716-boolean-decision-rules-via-column-generation.pdf&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2019-08-27T12:31:44.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1400" PostTypeId="2" ParentId="1392" CreationDate="2019-08-27T12:37:28.850" Score="18" Body="&lt;p&gt;LP is solvable in polynomial time. The polynomial depends not only on problem size, but also the size of numbers of the input matrix. The standard proof is using the ellipsoid method. Of course, the proof uses exact arithmetic, as any complexity proof would. That method isn't practical though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is unknown if LP is strongly polynomial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In practice you can solve an LP to any precision using an IPM. The hard part is to get an exact solution. These are called rounding methods: they use IPM to a certain precision then jump to the surface of the polyhedron. Both steps are polynomial in the problem data. This is again theory only, in practice we use standard crossover techniques and a few extra simplex iterations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to get a strictly feasible starting point for your IPM you have two choices:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use an embedding method. This adds one extra variable to all problem dimensions. In that higher dimensional space there is a trivial strictly interior point. Then from the solution of this new problem you can recover the solution of the original problem. This is very different from just adding slacks. This is implemented in practical solvers. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use an infeasible start IPM. These minimize the primal and dual infeasibilities together with minimizing complementarity. This tends to be a more popular option in practical implementations.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also, it isn't true that solving the phase-1 problem with simplex is polynomial: while you are pivoting out the infeasibilities new ones can appear. In general getting a feasible solution for an LP is equivalent to solving an LP to optimality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this helps to clear up some of the confusion.&lt;/p&gt;&#xA;" OwnerUserId="319" LastActivityDate="2019-08-27T12:37:28.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1401" PostTypeId="1" AcceptedAnswerId="1416" CreationDate="2019-08-27T15:08:58.910" Score="11" ViewCount="264" Body="&lt;p&gt;Recently, I've been working on some two-stage stochastic programming problems. Due to the presence of integer second-stage variables in the model, I've preferred to use the Progressive Hedging Algorithm (PHA). I've implemented my algorithms in GAMS and run them successfully. However, a common issue between all problems was that occasionally PHA underestimated the optimal solution of the original problem (obtained via solving the deterministic equivalent problem).&lt;/p&gt;&#xA;&lt;p&gt;I've found out that on some problems the method is highly sensitive to the penalty term, &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;,  in the objective function depicted below (i.e., the one penalizing the distance between the current solution from the previous nonanticipative solution). Please note that &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\hat{x}$&lt;/span&gt; are parameters determined iteratively within the PHA. Also, &lt;span class=&quot;math-container&quot;&gt;$c^Tx_k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q^T_ky_k$&lt;/span&gt; are the first-stage and second-stage costs, respectively.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min\qquad&amp;amp;\sum_{k=1}^{K} p_{k}\left[c^Tx_k+q^T_ky_k+\rho^{v,T}_{k}(x_k-\hat{x}_k)+\dfrac{r}{2}\lVert x_k-\hat{x}_k\rVert^2\right]\\\text{s.t.}\qquad&amp;amp;Ax_k = b,\\\qquad&amp;amp;Wy_k=h_k-T_kx_x,\\\qquad&amp;amp;x_k \ge 0,\,\exists x_k\in \mathbb{Z}^+,\\\qquad&amp;amp;y_k \ge 0, \,\exists y_k\in \mathbb{Z}^+.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, tuning &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; could take considerable time and be a pain. I was wondering if there is any way to tune &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; and find the optimal or near-optimal solutions with less hassle. I would really appreciate it if you could share your experience and tricks to overcome this difficulty.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update #1&lt;/strong&gt;: The problems under study are completely linear. In other words, they are two-stage stochastic mixed-integer programming (with integer first- and second-stage variables).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update #2:&lt;/strong&gt; As my first-stage variables are binary, I'm able to completely linearize the term &lt;span class=&quot;math-container&quot;&gt;$\lVert x_k-\hat{x}_k\rVert^2$&lt;/span&gt;. Therefore, the problem solved in each iteration of PHA is completely linear. In addition, it is separable under index &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; for different scenarios.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update #3&lt;/strong&gt;: The progressive hedging algorithm was implemented as discussed &lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4614-0237-4&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; on page 257.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Step 0&lt;/strong&gt;. Suppose some nonanticipative &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt;, some initial multiplier &lt;span class=&quot;math-container&quot;&gt;$\rho_0$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$r &amp;gt; 0$&lt;/span&gt; . Let &lt;span class=&quot;math-container&quot;&gt;$ν = 0$&lt;/span&gt;. Go to Step 1.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$(x_k^{v+1},y_k^{v+1}) \; \forall k = 1,...,K$&lt;/span&gt; solve the problem above. Let &lt;span class=&quot;math-container&quot;&gt;$\hat{x}^{v+1} = (\hat{x}^{v+1,1},...,\hat{x}^{v+1,K})^T$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\hat{x}^{v+1,k} = \sum_{l=1}^{K} p_lx^{v+1,l}  \; \forall k = 1,...,K$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$\rho^{v+1}=\rho^{v} + r(x^{v+1,k}-\hat{x}^{v+1})$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$\hat{x}^{v+1}=\hat{x}^{v}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\rho^{v+1}=\rho^{v}$&lt;/span&gt;, then, stop; &lt;span class=&quot;math-container&quot;&gt;$\hat{x}^{v}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\rho^{v}$&lt;/span&gt; are optimal. Otherwise, let &lt;span class=&quot;math-container&quot;&gt;$v = v+1$&lt;/span&gt; and go to Step 1.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="119" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-09-26T18:05:30.410" Title="Difficulties with Finding a Proper Penalty Value for the Progressive Hedging Algorithm" Tags="|stochastic-programming|penalty-based-optimization|lagrangian-relaxation|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="1402" PostTypeId="1" AcceptedAnswerId="1405" CreationDate="2019-08-28T03:30:57.387" Score="7" ViewCount="1621" Body="&lt;p&gt;I have a two-stage stochastic programming problem in which the expected-value solution results in a quite different first-stage solution than the recourse problem. Although the value of VSS (defined below) is often positive, it is somewhat negligible.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Value of Stochastic Solution (VSS) is defined as the difference&#xA;  between the Expectation of the Expected Value Solution (EEVS) and the&#xA;  optimal objective value of the Recourse Problem (RP).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This definition only considers the objective function values to determine the merits of the stochastic solution. I think this is not a good index in the sense that it does not consider the structure of the solutions. I was wondering if there are any other index for evaluating the merits of a stochastic problem in comparison to the expected value problem? I feel that this has already been studied in the literature, but I could not find a reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; It should mention that the stochastic program with a large number of scenarios can be solved efficiently, so I am not looking for a way to speedup solving the SP by reducing the number of first-stage variables or by reducing the number of scenarios. I just want a measure to quantify the value of stochastic solution. I thought maybe this has something to do with robustness or robust optimization, but RO is a different field.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastEditorUserId="1202" LastEditDate="2019-08-28T07:09:16.760" LastActivityDate="2019-08-28T07:09:16.760" Title="Alternative definition for the value of stochastic solution" Tags="|stochastic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1404" PostTypeId="2" ParentId="1380" CreationDate="2019-08-28T03:39:24.113" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Are there any cases where quadratization is an essential component of a state-of-the-art algorithm for a real-world problem?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quadratization has been used in &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_pseudo-Boolean_optimization#Higher_order_terms&quot; rel=&quot;nofollow noreferrer&quot;&gt;pseudo-Boolean optimization&lt;/a&gt; (&lt;a href=&quot;http://pub.ist.ac.at/~vnk/software.html#qpbo&quot; rel=&quot;nofollow noreferrer&quot;&gt;Implementation of QPBO (C++)&lt;/a&gt;) and unconstrained binary polynomial optimization problems.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.researchgate.net/publication/331523760_Quadratic_Reformulation_of_Nonlinear_Pseudo-Boolean_Functions_via_the_Constraint_Composite_Graph&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quadratic Reformulation of Nonlinear Pseudo-Boolean Functions via the Constraint Composite Graph&lt;/a&gt;&quot;, (Jun 2019), by Ka Wa Yip, Hong Xu, Sven Koenig, and T. K. Satish Kumar:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;&lt;strong&gt;Abstract&lt;/strong&gt;:&lt;br&gt;&#xA;  Nonlinear pseudo-Boolean optimization (nonlinear PBO) is the minimization problem on nonlinear pseudo-Boolean functions (non-linear PBFs). One promising approach to nonlinear PBO is to first use a quadratization algorithm to reduce the PBF to a quadratic PBF by introducing intelligently chosen auxiliary variables and then solve it using a quadratic PBO solver. In this paper, we develop a new quadratization algorithm based on the idea of the constraint composite graph (CCG). We demonstrate its theoretical advantages over state-of-the-art quadratization algorithms. We experimentally demonstrate that our CCG-based quadratization algorithm outperforms the state-of-the-art algorithms in terms of both effectiveness and efficiency on randomly generated instances and a novel reformulation of the &lt;strong&gt;uncapacitated facility location problem&lt;/strong&gt;.&lt;br&gt;&#xA;  ...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;&#xA;  We developed the CCG-based quadratization algorithm for the nonlinear PBO on general PBFs and compared it to state-of-the-art algorithms. We first proved the theoretical advantages of the CCG-based quadratization algorithm over other algorithms. We then experimentally verified these advantages. We observed&#xA;  that our CCG-based quadratization algorithm not only significantly outperforms other algorithms on medium-sized and large PBFs but is also preferable for smaller PBFs, to which asymptotic theoretical results are not directly applicable. We also showed that the CCG-based quadratization algorithm is applicable to real-world problems such as the UFLP, especially when the number of users to deliver products to is large.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://arxiv.org/abs/1901.07904&quot; rel=&quot;nofollow noreferrer&quot;&gt;Solving unconstrained 0-1 polynomial programs through quadratic convex reformulation&lt;/a&gt;&quot;, (Jan 22 2019), by &#xA;Sourour Elloumi, Amélie Lambert, and Arnaud Lazare (CEDRIC):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;&lt;strong&gt;Abstract&lt;/strong&gt;&lt;br&gt;&#xA;  We propose an exact solution approach for the problem (&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;) of minimizing an unconstrained binary polynomial optimization problem. We call PQCR (Polynomial Quadratic Convex Reformulation) this three-phase method. The first phase consists in reformulating (&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;) into a quadratic program (&lt;span class=&quot;math-container&quot;&gt;$QP$&lt;/span&gt;). To that end, we recursively reduce the degree of (&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;) to two, by use of the standard substitution of the product of two variables by a new one. We then obtain a linearly constrained binary quadratic program. In the second phase, we rewrite the objective function of (&lt;span class=&quot;math-container&quot;&gt;$QP$&lt;/span&gt;) into an equivalent and parameterized quadratic function using the identity &lt;span class=&quot;math-container&quot;&gt;$x^2_i =x_i$&lt;/span&gt; and other valid quadratic equalities that we introduce&#xA;  from the reformulation of phase 1. Then, we focus on finding the best parameters to get a quadratic convex program which continuous relaxation’s optimal value is maximized. For this, we build a new semi-definite relaxation (&lt;span class=&quot;math-container&quot;&gt;$SDP$&lt;/span&gt;) of (&lt;span class=&quot;math-container&quot;&gt;$QP$&lt;/span&gt;). Then, we prove that the standard linearization inequalities, used for the quadratization step, are redundant in presence of the new quadratic equalities. Next, we deduce our optimal parameters from the dual optimal solution of (&lt;span class=&quot;math-container&quot;&gt;$SDP$&lt;/span&gt;). The third phase consists in solving (&lt;span class=&quot;math-container&quot;&gt;$QP∗$&lt;/span&gt;), the optimally reformulated problem, with a standard solver. In particular, at each node of the branch-and-bound, the solver computes the optimal value of a continuous quadratic convex program. We present computational results where we compare PQCR with other convexification methods, and with the solver Baron. We evaluate our method on&#xA;  instances of the image restoration problem and the low autocorrelation binary sequence problem from minlplib. For this last problem, 33 instances among the 45 were unsolved in minlplib. We solve to optimality 6 of them, and for the 27 others we improve primal and/or dual bounds.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://arxiv.org/abs/1901.04405&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quadratization in discrete optimization and quantum mechanics&lt;/a&gt;&quot; (Jan 14 2019), by Nike Dattani:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Abstract&lt;/strong&gt;:&lt;br&gt;&#xA;  &quot;A book about turning high-degree optimization problems into quadratic optimization problems that maintain the same global minimum (ground state). This book explores quadratizations for pseudo-Boolean optimization, perturbative gadgets used in QMA completeness theorems, and also non-perturbative k-local to 2-local transformations used for quantum mechanics, quantum annealing and universal adiabatic quantum computing. The book contains ~70 different Hamiltonian transformations, each of them on a separate page, where the cost (in number of auxiliary binary variables or auxiliary qubits, or number of sub-modular terms, or in graph connectivity, etc.), pros, cons, examples, and references are given. One can therefore look up a quadratization appropriate for the specific term(s) that need to be quadratized, much like using an integral table to look up the integral that needs to be done. This book is therefore useful for writing compilers to transform general optimization problems, into a form that quantum annealing or universal adiabatic quantum computing hardware requires; or for transforming quantum chemistry problems written in the Jordan-Wigner or Bravyi-Kitaev form, into a form where all multi-qubit interactions become 2-qubit pairwise interactions, without changing the desired ground state. Applications cited include computer vision problems (e.g. image de-noising, un-blurring, etc.), number theory (e.g. integer factoring), graph theory (e.g. Ramsey number determination), and quantum chemistry. The book is open source, and anyone can make modifications here: &quot;&lt;a href=&quot;https://github.com/HPQC-LABS/Book_About_Quadratization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Open collaborative book on quadratization in discrete optimization and quantum mechanics&lt;/a&gt;&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://arxiv.org/abs/1908.09043&quot; rel=&quot;nofollow noreferrer&quot;&gt;Proximal gradient flow and Douglas-Rachford splitting dynamics: global exponential stability via integral quadratic constraints&lt;/a&gt;&quot; (Aug 23 2019), by Sepideh Hassan-Moghaddam and Mihailo R. Jovanović:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Abstract&lt;/strong&gt;:&lt;br&gt;&#xA;  &quot;Many large-scale and distributed optimization problems can be brought into a composite form in which the objective function is given by the sum of a smooth term and a nonsmooth regularizer. Such problems can be solved via a proximal gradient method and its variants, thereby generalizing gradient descent to a nonsmooth setup. In this paper, we view proximal algorithms as dynamical systems and leverage techniques from control theory to study their global properties. In particular, for problems with strongly convex objective functions, we utilize the theory of integral quadratic constraints to prove global exponential stability of the differential equations that govern the evolution of proximal gradient and Douglas-Rachford splitting flows. In our analysis, we use the fact that these algorithms can be interpreted as variable-metric gradient methods on the forward-backward and the Douglas-Rachford envelopes and exploit structural properties of the nonlinear terms that arise from the gradient of the smooth part of the objective function and the proximal operator associated with the nonsmooth regularizer. We also demonstrate that these envelopes can be obtained from the augmented Lagrangian associated with the original nonsmooth problem and establish conditions for global exponential convergence even in the absence of strong convexity.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-08-28T16:55:53.570" LastActivityDate="2019-08-28T16:55:53.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1405" PostTypeId="2" ParentId="1402" CreationDate="2019-08-28T05:38:21.157" Score="6" Body="&lt;p&gt;In the paper by Crainic et al.&lt;sup&gt;1&lt;/sup&gt;, the authors stated that &quot;Focusing on two-stage formulations, we show how and under which conditions the reduced costs associated to the variables in the deterministic formulation can be used as an indicator for excluding/retaining decision variables in the stochastic model. We introduce a new measure, the &lt;strong&gt;Loss of Reduced Costs-based Variable Fixing (LRCVF)&lt;/strong&gt;, computed as the difference between the optimal values of the stochastic problem and its reduced version obtained by fixing a certain number of variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maggioni et al.&lt;sup&gt;2&lt;/sup&gt; proposed the concepts of the &lt;strong&gt;Value of the Right Distribution (VRD)&lt;/strong&gt;, &lt;strong&gt;the Performance Bound (PB)&lt;/strong&gt; and the &lt;strong&gt;Worst-Case Performance Bound (WPB)&lt;/strong&gt;, which can be applied to quantify how much the lost will be if we guess the wrong distribution of the uncertain parameters affecting a stochastic optimization problem. They applied these concepts in two-stage stochastic programming model of the cost-based variant of the classical Newsvendor problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think above-mentioned papers can give you a good start point in searching for alternative indexes for VSS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] Crainic, Teodor G., et al. &quot;Reduced cost-based variable fixing in two-stage stochastic programming.&quot; Annals of Operations Research (2018): 1-37.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] Maggioni, Francesca, Matteo Cagnolari, and Luca Bertazzi. &quot;The value of the right distribution in stochastic programming with application to a Newsvendor problem.&quot; Computational Management Science (2019): 1-20.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-08-28T06:04:20.193" LastActivityDate="2019-08-28T06:04:20.193" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1406" PostTypeId="2" ParentId="830" CreationDate="2019-08-28T13:57:07.247" Score="3" Body="&lt;p&gt;I hope to provide intuitively-appealing answers to both questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textbf{Question 1:}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Infinite horizon MDP's do not care about the initial state. They attempt to be optimal in the sense that the policy is optimal for all given allowable initial states. Finite MDP's are computed as optimal for a given state. The policy is intended to be optimal only if you start from that initial state. Neighbouring states (such as in a grid or queue) may have the same finite horizon policy as the aforementioned state but that has more to do with state aggregation properties.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, finite horizon MDP's typically have time involved in the Cost function as one might seek time-optimal control (diffusing a bomb as soon as possible). Infinite horizon problems have a boundedness condition on the value function for most algorithms to work. Thus, putting time into the value function simply will not work. Time optimal control cannot be performed via the infinite horizon case or is not recommended. So infinite horizon problems are 'chilled' in the sense that they are not in a rush. An example is controlling traffic at an intersection. There is no goal to reach in some shortest time. You just want to minimize the waiting time of vehicles in some long run scenario.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, that I mentioned a goal. This will soon tie into your second question. Finite horizon problems can be distinguished in the sense that they have minimal time as a goal. If you do not include time into your cost function then you can compare infinite and finite horizon problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take Windy Grid-world for an example. Grid-world usually has some absorbing reward state to be reached with negative costs for each step taken. A very big negative state can be placed right next to the reward state. Transitions are stochastic in that the agent might be given forward as an action to be performed but only does so with probability &lt;span class=&quot;math-container&quot;&gt;$0.6$&lt;/span&gt;. Thus one must be open to the risk that the &quot;wind&quot; might blow the agent into the big negative state if it passes too close to it. We have risk. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you have an N-step finite horizon recursion from a given state then the agent will be concerned with getting to the big reward state in &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; steps or under. This might even mean risking to go directly passed the big negative state. The infinite horizon policy is not concerned by this rush and will take the risk of the big negative state into account. Its policy will most likely attempt to avoid it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When can we compare them? Well if &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is larger than some number &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; which might be the sum of the length and width of the grid or even the diagonal length of the grid, then it will essentially not be rushed anymore. That is, &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; can be considered to be large enough to be an infinite horizon. We would never want to compute an infinite horizon problem using a finite horizon algorithm with large &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; as it stores a policy for each epoch. Infinite horizon algorithms store only the stationary policy. Exceptions include the n-bias optimality in average reward MDP's. Algorithms exist to deal with this. It is not a issue if dealing with discounted case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textbf{Question 2:}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Stochastic shortest path (SSP) problems require a path to exist from any initial state to some given &quot;goal&quot; state (I promised we would use the goal state term again). This would be formulated as an absorbing state. If this path does not exist then the problem is not well-posed. The optimal control community uses goal-orientated to essentially describe what the reinforcement community would call an episodic problem. SSP does not require a discount factor to ensure that asymptotic costs be bounded. Note that the boundedness assumption means we are referring to SSP as an inifinite horizon problem. As you mention, it needs a directed acyclic graph where the edges are non-zero transition probabilities. This is discussed in the book Dynamic Programming and Optimal Control Vol II by D. Bertsekas. The questions you ask are dealt with, very elegantly, in this book. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;SSP is also good for optimal stopping time problems. These are concerned with time. But wait, did I not mention that when we are concerned with time we use finite horizon recursion of size &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;? Yes, but we need to specify &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; and the initial state. SSP deals with the best way of transitioning to some goal state in the long run, taking risk into account. The policy is optimal for all well-posed initial states. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textbf{Conclusion}$&lt;/span&gt;&#xA;You might see that MDP's are quite specific in what you want to model. One needs to classify them and check assumptions. The book by Bertsekas guides you through all of this as well as the book mentioned above by Puterman (a bit expensive though). The price of these books are well worth the reward of satisfying one's curiosity for MDP's which are a truly amazing class of problems.&lt;/p&gt;&#xA;" OwnerUserId="1241" LastEditorUserId="36" LastEditDate="2019-08-28T14:54:05.320" LastActivityDate="2019-08-28T14:54:05.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1407" PostTypeId="1" CreationDate="2019-08-28T14:02:01.967" Score="12" ViewCount="138" Body="&lt;h2&gt;Introduction&lt;/h2&gt;&#xA;&lt;p&gt;I am currently modelling a scenario where two queues need to be served by a single server in a non preemptive discipline. I am quite sorted on generating the optimal policy via Value or Policy Iteration when given the arrival and service rates of the two queues.&lt;/p&gt;&#xA;&lt;h2&gt;The Model&lt;/h2&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$A_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_2$&lt;/span&gt; denote the arrival operators for each queue and let &lt;span class=&quot;math-container&quot;&gt;$D_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D_2$&lt;/span&gt; denote the departure/service operators.&lt;/p&gt;&#xA;&lt;p&gt;We have &lt;span class=&quot;math-container&quot;&gt;$\lambda_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\lambda_2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mu_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu_2$&lt;/span&gt; as the arrival and service rates whereas &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; is the control and &lt;span class=&quot;math-container&quot;&gt;$u = 0$&lt;/span&gt; corresponds to serve queue 2 and &lt;span class=&quot;math-container&quot;&gt;$u=1$&lt;/span&gt; corresponds to serve queue 1.&lt;/p&gt;&#xA;&lt;p&gt;Now we use uniformization to allow for the time-continuous process to be described as a discrete chain sampled at intervals of length &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt;. Here &lt;span class=&quot;math-container&quot;&gt;$\gamma = \lambda_1 + \lambda_2 + \mu_2 + \mu_2$&lt;/span&gt;. Hence the transition probabilities are given as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$p(x_{k+1},x_k,u_k)= &#xA; \begin{cases}  \frac{\lambda_1}{\gamma} &amp;amp; ,x_{k+1} = A_1(x_k) \\&#xA; \frac{\lambda_2}{\gamma} &amp;amp; ,x_{k+1} = A_2(x_k) \\&#xA; \frac{\mu_1}{\gamma}u &amp;amp; ,x_{k+1} = D_1(x_k) \\&#xA;\frac{\mu_2}{\gamma}(1-u) &amp;amp; ,x_{k+1} = D_2(x_k) \\&#xA;\frac{\mu_1}{\gamma}(1-u) + \frac{\mu_2}{\gamma}u&#xA;&amp;amp;,x_{k+1} = x_{k}\end{cases}  $$&lt;/span&gt;&#xA;Note that we have introduced fictitious transition rates.&lt;/p&gt;&#xA;&lt;h2&gt;Actual Question&lt;/h2&gt;&#xA;&lt;p&gt;Now we get to the actual question. The arrival rates change over time hence the poisson process is not stationary. However, it is stationary for a good amount of time. So I use a Bayesian change-point model to track any changes when they have occurred. I love these models as they are really quite robust and once can tune them to account for zero-inflated data etc.&lt;/p&gt;&#xA;&lt;p&gt;The Bayesian change-point model gives the following output for the measurement of a single lambda, lets say the arrival rate of queue 1:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6XpEG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6XpEG.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; values are to account for zero inflation so please ignore them. Focus must turn to the arrival rates. We note that the change has left us quite uncertain about what the new rate might be (the turquoise one is a wider distribution than the purple one).&lt;/p&gt;&#xA;&lt;p&gt;So I can take the mean of the new arrival rate, plug it into the transition probabilities and then call it a day. However, the Bayesian change point suggests otherwise. We now have the turquoise distribution being our belief distribution of &lt;span class=&quot;math-container&quot;&gt;$\lambda_1$&lt;/span&gt;. Is this model uncertainty because we are now uncertain about the transition matrix &lt;span class=&quot;math-container&quot;&gt;$p(x_{k+1},x_k,u)$&lt;/span&gt; as a result of &lt;span class=&quot;math-container&quot;&gt;$\lambda_1$&lt;/span&gt; not being a single scalar but a belief distribution (please excuse I have not scaled the distribution yet to be considered valid probability distributions)?&lt;/p&gt;&#xA;&lt;p&gt;I think it is not state uncertainty as state uncertainty results from errors in measurement or observations and should affect the state vector &lt;span class=&quot;math-container&quot;&gt;$x_k$&lt;/span&gt; and not the transition model. Am I correct then in saying we are not dealing with a Partially Observable Markov Decision Process ?&lt;/p&gt;&#xA;&lt;p&gt;If my assumption on model uncertainty is correct, how would you recommend I deal with it?&lt;/p&gt;&#xA;&lt;h2&gt;My Attempt at my own question&lt;/h2&gt;&#xA;&lt;p&gt;I propose the following which may be incorrect. Let &lt;span class=&quot;math-container&quot;&gt;$\lambda_{1} \sim b(\theta)$&lt;/span&gt; be the belief distribution given in turquoise. Then we have &lt;span class=&quot;math-container&quot;&gt;$p(x_{k+1},x_{k},u\mid \lambda_1) =p(x_{k+1},x_{k},u\mid b(\theta)) $&lt;/span&gt;. So we can do the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ p(x_{k+1},x_k,u) = \sum_{i=1}^{N}p(x_{k+1},x_{k},u\mid b(\theta_i))  $$&lt;/span&gt;&#xA;Where we assume &lt;span class=&quot;math-container&quot;&gt;$b(\theta)$&lt;/span&gt; to be the discrete multinomial turquoise distribution with &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; categories over &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Conclusion&lt;/h2&gt;&#xA;&lt;p&gt;I would love my policy to be sensitive to the arrival uncertainty produced by a change in the stationary distribution. I feel that this would make my controller robust in the sense of being prudent when a change in arrivals rate occurs and is detected. Is there another method that would be superior?&lt;/p&gt;&#xA;" OwnerUserId="1241" LastEditorUserId="491" LastEditDate="2020-11-06T19:46:26.637" LastActivityDate="2020-11-06T19:47:02.240" Title="Model or State Uncertainty in Queueing Model due to uncertain arrival rate" Tags="|markov-decision-process|probability-distributions|stochastic-process|uncertainty|queuing-theory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1408" PostTypeId="1" CreationDate="2019-08-29T07:30:16.770" Score="11" ViewCount="805" Body="&lt;p&gt;I am researching a Vehicle Routing Problem for a safety insurance company that provides roadside assistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The company does not have a depot, as in classical VRP, and has a set of heterogeneous vehicles, as of their use (motorbike used for the easy cases, and tow trucks used for the hard ones). They don't have capacity limitations, but they have other constraints and limitations, such as road accessibility (not all vehicles can have access in all roads), type accessibility (you cannot send a motorbike to tow a car) and time limitations (a customer shouldn't be served - waiting more than T). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am searching the literature for almost a week now, trying to approach it by searching for dynamic VRPs with no depots or multiple depot VRP (having the vehicles as depots), but I can't find a similar problem. Does anyone happen to know any work done on the subject?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT :&lt;/strong&gt; As I can see, and imagined, there is no current approach to roadside assistance routing problems. The answer by &lt;a href=&quot;https://or.stackexchange.com/a/1409/1243&quot;&gt;Oguz Toragay&lt;/a&gt; seems very interesting, but it needs much work. I have thought many variants that could fit, but don't. The problem I am facing is how to calculate a good objective function, as the problem is bi-objective (time and kilometers). I mean it's difficult, as I cannot solve this problem by exact methods, to have a metric that can evaluate a solution in comparison to another. &#xA;Thank you very much once again!&lt;/p&gt;&#xA;" OwnerUserId="1243" LastEditorUserId="1243" LastEditDate="2019-08-29T09:52:19.047" LastActivityDate="2019-08-29T16:08:43.037" Title="What is the following VRP?" Tags="|reference-request|vehicle-routing|traveling-salesman|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1409" PostTypeId="2" ParentId="1408" CreationDate="2019-08-29T07:42:56.320" Score="4" Body="&lt;p&gt;Maybe you need to look at assignment problems, in which some tasks(customer) should be assigned to some trucks, not all connections are available (road access, waiting time) and you need to minimize the traveling time of each vehicle or alternatively maximize the served customers as your objective function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; here is a good&lt;sup&gt;1&lt;/sup&gt; book about assignment problems which includes both various models and also different solution methods. Also, have a look at &lt;a href=&quot;https://towardsdatascience.com/assigning-fastest-pick-ups-to-uber-drivers-with-linear-programming-8f8bd3c44c9a&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; website (assigning fastest pick-ups to **** drivers with linear programming).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://towardsdatascience.com/assigning-fastest-pick-ups-to-uber-drivers-with-linear-programming-8f8bd3c44c9a&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt; Patriksson, Michael. The traffic assignment problem: models and methods. Courier Dover Publications, 2015.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-08-29T08:21:52.323" LastActivityDate="2019-08-29T08:21:52.323" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1410" PostTypeId="2" ParentId="1408" CreationDate="2019-08-29T09:20:27.523" Score="10" Body="&lt;p&gt;This recent review on &lt;em&gt;rich routing problems&lt;/em&gt; may be helpful:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://repository.psau.edu.sa/jspui/retrieve/6358c84c-e14d-4e4c-8645-c8f7320606ab/EJOR_2015.pdf&quot; rel=&quot;noreferrer&quot;&gt;http://repository.psau.edu.sa/jspui/retrieve/6358c84c-e14d-4e4c-8645-c8f7320606ab/EJOR_2015.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick scan on the categories would suggest you have:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.3.2 Multiple Depots&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.1.1.2 Heterogeneous Vehicles&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.2.1 Restrictions on Customer Waiting Time&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.2.2 Restrictions on Road Access&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.4 Compatibility Constraints&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will certainly not find a paper in the references which has the combination of all these special cases but looking into multiple ones should help you come up with your very own rich VRP - paper coming up?&lt;/p&gt;&#xA;" OwnerUserId="33" LastEditorUserId="33" LastEditDate="2019-08-29T11:12:57.227" LastActivityDate="2019-08-29T11:12:57.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1411" PostTypeId="2" ParentId="1408" CreationDate="2019-08-29T09:34:06.683" Score="5" Body="&lt;p&gt;Would you see, &lt;a href=&quot;https://neos-guide.org/content/multiple-traveling-salesman-problem-mtsp&quot; rel=&quot;noreferrer&quot;&gt;Multiple Traveling Salesman Problem (mTSP)&lt;/a&gt;. I think with add some limitation (as your constraints), it might be useful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-08-29T09:34:06.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1412" PostTypeId="1" AcceptedAnswerId="1436" CreationDate="2019-08-29T10:14:43.187" Score="16" ViewCount="1404" Body="&lt;p&gt;As a practical (real-world problems) point of view, it's important we could solve optimization problems as quickly as possible (for instance, to release a daily schedule). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe a problem with many variables Or constraints is solved in a few time but, another takes a long time to solve. My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;What does &quot;hard problem&quot; mean?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there any way to figure out such problems?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How can we solve these problems without using some advanced algorithms? (In an optimal sense)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-08-31T15:50:17.353" Title="What is a &quot;hard problem&quot; in the context of Mixed-integer programming?" Tags="|mixed-integer-programming|optimization|modeling|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1413" PostTypeId="2" ParentId="766" CreationDate="2019-08-29T11:30:51.707" Score="3" Body="&lt;p&gt;This problem is NP-complete, and equivalent to solving a MILP problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can see the complexity equivalence by considering that, if there are no integer feasible points in the polyhedron, we need to prove that there are none - this is equivalent to solving the MILP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is typically solved by relaxing the MILP and using branch and bound. In some cases, Benders decomposition, or outer approximation may also be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we don't need a guarantee, but just a feasible point, we can use MIP heuristics, e.g. a feasibility pump.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-08-29T11:30:51.707" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1414" PostTypeId="2" ParentId="1412" CreationDate="2019-08-29T11:44:29.670" Score="15" Body="&lt;p&gt;MILP problems are hard in general, in the sense that there is no algorithm that solves any given MILP in polynomial time (unless P=NP).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With respect to when it's hard in practice, unfortunately, the answer is that, in general, we can't know until we try to solve them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We do know some things that usually make the problems harder to solve but even then it's a rule of thumb:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Degeneracy/multiple global optima&lt;/li&gt;&#xA;&lt;li&gt;Using full integers instead of binaries&lt;/li&gt;&#xA;&lt;li&gt;Having too many integer variables&lt;/li&gt;&#xA;&lt;li&gt;Using large M in big M notations&lt;/li&gt;&#xA;&lt;li&gt;Having very large variable ranges&lt;/li&gt;&#xA;&lt;li&gt;Overestimating feasible regions&lt;/li&gt;&#xA;&lt;li&gt;Having dense problems, i.e., not sparse&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Because these problems are generally quite hard we need advanced algorithms/solvers to solve anything meaningfully big in practice.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="764" LastEditDate="2019-08-29T12:43:03.953" LastActivityDate="2019-08-29T12:43:03.953" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1415" PostTypeId="2" ParentId="1408" CreationDate="2019-08-29T13:02:24.027" Score="6" Body="&lt;p&gt;Stating the obvious, even if you don't have a depot in its traditional definition, you can still use dummy nodes as your depot(s). I think an area closer to what you are looking for can be &lt;strong&gt;Ambulance dispatching&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It has a richer literature compared to other roadside assistance type VRP. &lt;/li&gt;&#xA;&lt;li&gt;Moreover, during disasters, the roads can be blocked or very hard to access and there are active researches for Ambulance (or emergency vehicles) relocation, dispatching, and routing during disaster reliefs. Hope one of these keywords help.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-08-29T13:02:24.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1416" PostTypeId="2" ParentId="1401" CreationDate="2019-08-29T13:39:10.277" Score="6" Body="&lt;p&gt;This problem is addressed in some detail in Section 2.1 of the paper &lt;a href=&quot;https://link.springer.com/article/10.1007/s10287-010-0125-4&quot; rel=&quot;noreferrer&quot;&gt;Progressive hedging innovations for a class of stochastic mixed-integer resource allocation problems&lt;/a&gt; by Watson and Woodruff (a non-paywall version is given &lt;a href=&quot;https://pdfs.semanticscholar.org/f75f/ed76db11997b66093099f1a933e2f59e7306.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;). In general, proper selection can be quite tricky and is highly problem-specific. I recommend trying some of the tricks in the linked paper.&lt;/p&gt;&#xA;" OwnerUserId="358" LastActivityDate="2019-08-29T13:39:10.277" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1417" PostTypeId="1" AcceptedAnswerId="1418" CreationDate="2019-08-29T14:18:12.370" Score="9" ViewCount="276" Body="&lt;p&gt;My problem is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min\limits_{x_{ij}}\qquad&amp;amp;{\sum_{i\in N}\sum_{j\in M}\frac{x_{ij}}{C_j-\sum\limits_{i\in N} x_{ij}a_i}}\\\text{s.t.}\qquad&amp;amp;0&amp;lt;C_j-\sum_{i\in N} x_{ij}a_i\\\qquad&amp;amp;\sum_{j\in M} x_{ij}=1\\\qquad&amp;amp;x_{ij}\in[0,1]\\\quad&amp;amp;{\sum_{j\in M}\frac{x_{ij}}{C_j-\sum\limits_{i\in N} x_{ij}a_i}} \le d_i,\forall i\in N\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is worth mentioning that the third constraint indicates the range and &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; isn't binary. As I calculated the Hessian of my objective function, I understood that the sign of matrix elements is dependent on &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_j-\sum\limits_{i\in N} x_{ij}a_i$&lt;/span&gt; which are always positive or zero.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Due to this, can I conclude that my problem is convex?  &lt;/li&gt;&#xA;&lt;li&gt;If the answer is yes, what class of convex problems does it belong to? (conic, geometric, etc.) and if no what is the type of problem?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1098" LastEditorUserId="1098" LastEditDate="2019-08-29T22:05:41.687" LastActivityDate="2019-08-30T00:59:40.283" Title="How to determine the convexity of my problem and categorize it?" Tags="|optimization|convexity|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1418" PostTypeId="2" ParentId="1417" CreationDate="2019-08-29T14:28:52.607" Score="9" Body="&lt;p&gt;This is a Linear-Fractional Programming problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be transformed to a Linear Programming problem as shown in section 4.3.2 &quot;Linear-fractional programming&quot; of &lt;a href=&quot;https://web.stanford.edu/~boyd/cvxbook/bv_cvxbook.pdf&quot; rel=&quot;noreferrer&quot;&gt;&quot;Convex Optimization&quot; by Boyd and Vandenberghe&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2019-08-29T14:28:52.607" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1419" PostTypeId="1" AcceptedAnswerId="1424" CreationDate="2019-08-29T15:20:36.267" Score="9" ViewCount="288" Body="&lt;p&gt;I wanted to write two objective functions for an employee scheduling problem (MIP) until it occurred to me, that one objective function may be redundant.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there a difference between the &lt;strong&gt;cost minimization&lt;/strong&gt; and &lt;strong&gt;profit maximization&lt;/strong&gt; for this assigning problem?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the following, I have made an example in Excel and the values and assigning, seems to be the same. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All 4 employees are available and capable of taking all 3 projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Noted:&lt;/strong&gt; I made the assigning manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I chose the employees for the &lt;strong&gt;cost minimization&lt;/strong&gt; objective is the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Get the project with the most days to fill within a week.&lt;/li&gt;&#xA;&lt;li&gt;Assign the most cost-effective employee to this project.&lt;/li&gt;&#xA;&lt;li&gt;Repeat this process until all projects are fulfilled.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For the &lt;strong&gt;profit maximization&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Get the daily revenue from a project&lt;/li&gt;&#xA;&lt;li&gt;Subtract it from the employee's daily cost&lt;/li&gt;&#xA;&lt;li&gt;Multiply it with the days in a week the employee should work on this project.&lt;/li&gt;&#xA;&lt;li&gt;Assign the employees such the sum from all calculations such the above is maximum.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The optimum assigning seems to be &lt;strong&gt;Cost Minimization v1&lt;/strong&gt; and &lt;strong&gt;Cost Minimization v2&lt;/strong&gt; which would also work with the &lt;strong&gt;profit maximization&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, all projects must be staffed and the achieved revenue is not employee dependant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UvwDl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UvwDl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/7K8JQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7K8JQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="456" LastEditorUserId="456" LastEditDate="2019-08-30T11:03:22.507" LastActivityDate="2019-08-30T11:03:22.507" Title="Profit Maximization vs Cost Minimization for Employee Scheduling" Tags="|mixed-integer-programming|optimization|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1420" PostTypeId="2" ParentId="1408" CreationDate="2019-08-29T16:08:43.037" Score="5" Body="&lt;p&gt;From the first look, you have an heterogeneous multi-depot site-dependent vehicle routing problem with time windows. I think you can use our solver for the deterministic variant of your problem: &lt;a href=&quot;https://vrpsolver.math.u-bordeaux.fr&quot; rel=&quot;noreferrer&quot;&gt;https://vrpsolver.math.u-bordeaux.fr&lt;/a&gt;. Efficiency of the solver of course depends on the size of your instances. An exact approach may be useful for you to estimate the quality of heuristics you will use/create for your problem. You can contact me if you need help to model your problem for our solver.&lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2019-08-29T16:08:43.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1421" PostTypeId="1" CreationDate="2019-08-29T17:13:00.887" Score="11" ViewCount="743" Body="&lt;p&gt;The objective of the Cumulative Traveling Salesman Problem (CTSP) is to minimize the sum of arrival times at customers, instead of the total travelling time. This is different than minimizing the overall time of travel. For example, if one has unlimited vehicles (# vehicles is the same as # of locations) and the objective is to minimize the overall time to locations, one would send one vehicle per location, for it is the fastest way to satisfy said demands. One can see that the or-tools routing module focuses mainly on minimizing the overall travel time (not the time to locations). Is there a way to solve the CTSP, and, even better, have a balance (maybe using weights) between minimizing time to locations vs. minimizing travelling time? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Let me show an analytical example&lt;/em&gt;.&#xA;Let's say we have a depot (0) and two customers (1 and 2). Let's consider the following time matrix:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[[0, 10, 20],&#xA;[10, 0, 15],&#xA;[20, 15, 0]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's assume we have a number of vehicles equal to the number of locations (2 vehicles). Let's consider the following two situations:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Objective 1: if we want to minimize overall travel time&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is &lt;code&gt;0 -&amp;gt; 1 -&amp;gt; 2 -&amp;gt; 0&lt;/code&gt; (one vehicle is used), where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;travel time&lt;/em&gt; is 45. &lt;code&gt;0 -&amp;gt; 1&lt;/code&gt;: 10 + &lt;code&gt;1 -&amp;gt; 2&lt;/code&gt;: 15 + &lt;code&gt;2 -&amp;gt; 0&lt;/code&gt;: 20 = &lt;code&gt;10 + 15 + 20&lt;/code&gt; = 45.&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;locations time&lt;/em&gt; is 35. For location 1: &lt;code&gt;0 -&amp;gt; 1&lt;/code&gt;: 10. For location 2 (note that we have to pass through location 1): &lt;code&gt;0 -&amp;gt; 1&lt;/code&gt;: 10 + &lt;code&gt;1 -&amp;gt; 2&lt;/code&gt;: 15. In summation, we have: &lt;code&gt;10 + 10 + 15&lt;/code&gt; = 35.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Objective 2: if we want to minimize time to locations&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is &lt;code&gt;0 -&amp;gt; 1 -&amp;gt; 0&lt;/code&gt; and &lt;code&gt;0 -&amp;gt; 2 -&amp;gt; 0&lt;/code&gt; (two vehicles are used), where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;travel time&lt;/em&gt; is 60. For vehicle 1: &lt;code&gt;0 -&amp;gt; 1&lt;/code&gt;: 10 + &lt;code&gt;1 -&amp;gt; 0&lt;/code&gt;: 10. For vehicle 2: &lt;code&gt;0 -&amp;gt; 2&lt;/code&gt;: 20 + &lt;code&gt;2 -&amp;gt; 0&lt;/code&gt;: 20. In summation, we have &lt;code&gt;10 +&#xA;10 + 20 + 20&lt;/code&gt; = 60.&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;locations time&lt;/em&gt; is 30. For location 1: &lt;code&gt;0 -&amp;gt; 1&lt;/code&gt;: 10. For location 2 (note that we &lt;em&gt;do not&lt;/em&gt; have to pass through location 1): &lt;code&gt;0 -&amp;gt; 2&lt;/code&gt;: 20. In summation, we have: &lt;code&gt;10 + 20&lt;/code&gt; = 30.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So... Can this be done? Can one solve the CTSP (objective 2)? Is it possible to have an objective function such that we could balance both of these objectives (i.e. &lt;code&gt;min alpha * overall_travel_time + beta * time_to_locations&lt;/code&gt;, such that &lt;code&gt;alpha&lt;/code&gt; and &lt;code&gt;beta&lt;/code&gt; are weights). &lt;strong&gt;Python&lt;/strong&gt; code is much appreciated. Thank you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Working code for objective 1: minimizing the overall travel time&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot;Vehicles Routing Problem (VRP).&quot;&quot;&quot;&#xA;&#xA;from __future__ import print_function&#xA;&#xA;from ortools.constraint_solver import pywrapcp&#xA;&#xA;&#xA;def create_data_model():&#xA;    &quot;&quot;&quot;Stores the data for the problem.&quot;&quot;&quot;&#xA;    data = {}&#xA;    data['time_matrix'] = [&#xA;        [0, 10, 20],&#xA;        [10, 0, 15],&#xA;        [20, 15, 0]&#xA;    ]&#xA;    data['num_vehicles'] = 2&#xA;    data['depot'] = 0&#xA;    return data&#xA;&#xA;&#xA;def print_solution(data, manager, routing, solution):&#xA;    &quot;&quot;&quot;Prints solution on console.&quot;&quot;&quot;&#xA;    max_route_time = 0&#xA;    for vehicle_id in range(data['num_vehicles']):&#xA;        index = routing.Start(vehicle_id)&#xA;        plan_output = 'Route for vehicle {}:\n'.format(vehicle_id)&#xA;        route_time = 0&#xA;        while not routing.IsEnd(index):&#xA;            plan_output += ' {} -&amp;gt; '.format(manager.IndexToNode(index))&#xA;            previous_index = index&#xA;            index = solution.Value(routing.NextVar(index))&#xA;            route_time += routing.GetArcCostForVehicle(&#xA;                previous_index, index, vehicle_id)&#xA;        plan_output += '{}\n'.format(manager.IndexToNode(index))&#xA;        plan_output += 'time of the route: {}\n'.format(route_time)&#xA;        print(plan_output)&#xA;        max_route_time = max(route_time, max_route_time)&#xA;    print('Maximum of the route times: {}'.format(max_route_time))&#xA;&#xA;&#xA;def main():&#xA;    &quot;&quot;&quot;Solve the CVRP problem.&quot;&quot;&quot;&#xA;    # Instantiate the data problem.&#xA;    data = create_data_model()&#xA;&#xA;    # Create the routing index manager.&#xA;    manager = pywrapcp.RoutingIndexManager(&#xA;        len(data['time_matrix']), data['num_vehicles'], data['depot'])&#xA;&#xA;    # Create Routing Model.&#xA;    routing = pywrapcp.RoutingModel(manager)&#xA;&#xA;    # Create and register a transit callback.&#xA;    def time_callback(from_index, to_index):&#xA;        &quot;&quot;&quot;Returns the time between the two nodes.&quot;&quot;&quot;&#xA;        # Convert from routing variable Index to time matrix NodeIndex.&#xA;        from_node = manager.IndexToNode(from_index)&#xA;        to_node = manager.IndexToNode(to_index)&#xA;        return data['time_matrix'][from_node][to_node]&#xA;&#xA;    transit_callback_index = routing.RegisterTransitCallback(time_callback)&#xA;&#xA;    # Define cost of each arc.&#xA;    routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)&#xA;&#xA;    # Setting first solution heuristic.&#xA;    search_parameters = pywrapcp.DefaultRoutingSearchParameters()&#xA;&#xA;    # Solve the problem.&#xA;    solution = routing.SolveWithParameters(search_parameters)&#xA;&#xA;    # Print solution on console.&#xA;    if solution:&#xA;        print_solution(data, manager, routing, solution)&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Results for the above code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Route for vehicle 0:&#xA; 0 -&amp;gt; 0&#xA;time of the route: 0&#xA;&#xA;Route for vehicle 1:&#xA; 0 -&amp;gt;  1 -&amp;gt;  2 -&amp;gt; 0&#xA;time of the route: 45&#xA;&#xA;Maximum of the route times: 45&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1245" LastEditorUserId="39" LastEditDate="2019-08-29T18:27:44.980" LastActivityDate="2019-08-30T15:05:26.913" Title="How to solve the Cumulative Traveling Salesman Problem using or-tools in python?" Tags="|python|traveling-salesman|or-tools|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1422" PostTypeId="2" ParentId="766" CreationDate="2019-08-29T17:47:59.310" Score="6" Body="&lt;p&gt;In the full-dimensional case, I think you can consider &lt;span class=&quot;math-container&quot;&gt;$\varepsilon\geq 0$&lt;/span&gt; as an extra continuous variable in order to get your poly-size certificate. Let &lt;span class=&quot;math-container&quot;&gt;$$Q=\{(x,\varepsilon)\,:\,Ax+e\varepsilon\leq b, 0\leq\varepsilon\leq1\}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a mixed-integer point in the interior of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; then there exists a mixed-integer point of poly-size in &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\varepsilon&amp;gt;0$&lt;/span&gt; (for instance a mixed-integer optimal solution of maximizing &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;). More precisely, since &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; contains a mixed-integer point in its interior then: &lt;span class=&quot;math-container&quot;&gt;$$\varepsilon^*=\max\{\varepsilon \,:\, (x,\varepsilon) \in Q\cap(\mathbb{Z}^l\times\mathbb{R}^{n-l+1})\}$$&lt;/span&gt;&#xA; must be positive. Then, since the polyhedron &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is rational there exists a mixed-integer optimal solution &lt;span class=&quot;math-container&quot;&gt;$(x^*,\varepsilon^*)$&lt;/span&gt; of poly-size. This  point &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is the certificate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The non-fulldimensional case can be reduced to the full-dimensional case by applying an unimodular transformation to &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; that makes &lt;span class=&quot;math-container&quot;&gt;$\text{aff}(P)$&lt;/span&gt; to be equal to &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^p\times\{0\}$&lt;/span&gt; (for instance by using the Hermite Normal form of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="17" LastEditorUserId="17" LastEditDate="2019-08-30T18:18:11.433" LastActivityDate="2019-08-30T18:18:11.433" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1423" PostTypeId="1" AcceptedAnswerId="1425" CreationDate="2019-08-29T19:09:48.537" Score="8" ViewCount="1278" Body="&lt;p&gt;We know that the ellipsoid method is proven to be of polynomial complexity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as far as I can tell we may need to add exponentially many feasibility cuts in order to solve the LP (or prove no solution exists), which results in a non-polynomial amount of calculations, which is the method is inefficient in practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the method considered polynomial simply because we measure P-hardness as a function of the number of variables, or is there also a polynomial bound on the number of constraints that we need to add?&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="38" LastEditDate="2019-08-29T23:46:58.290" LastActivityDate="2019-08-30T01:03:59.987" Title="Why is the Ellipsoid Method of polynomial complexity?" Tags="|linear-programming|computational-complexity|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1424" PostTypeId="2" ParentId="1419" CreationDate="2019-08-29T20:46:17.287" Score="13" Body="&lt;p&gt;If you assume that (a) all projects must be fully staffed and (b) the revenue for a project is constant regardless of who does it, then total revenue is fixed. In that case, cost minimization and profit maximization are the same. Where they would differ would be if either not all projects need be done (but some minimum number must be -- otherwise cost minimization is achieved by doing nothing) or project revenue is a function of who does it (in which case using the cheaper labor might &quot;leave money on the table&quot; in excess of the cost savings).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-29T20:46:17.287" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1425" PostTypeId="2" ParentId="1423" CreationDate="2019-08-29T23:01:39.000" Score="22" Body="&lt;p&gt;The ellipsoid method is polynomial for the same reason that &lt;a href=&quot;https://gizmodo.com/if-you-fold-a-paper-in-half-103-times-it-will-be-as-thi-1607632639&quot; rel=&quot;noreferrer&quot;&gt;you cannot fold a piece of paper 103 times&lt;/a&gt;: exponential growth! Because the formal proof is already in &lt;a href=&quot;https://doi.org/10.1016/0041-5553(80)90061-0&quot; rel=&quot;noreferrer&quot;&gt;Khachiyan (1980)&lt;/a&gt;, I will try to give a more informal and intuitive explanation. Please forgive my simplifications for the sake of clarity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider a linear program. That is, we want to minimize a linear function over a polyhedron.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Bounding the polyhedron&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If the polyhedron is not bounded, we will cut off a region to make it bounded. If the region that we cut off is far away, this probably doesn't matter anyways.&lt;span class=&quot;math-container&quot;&gt;$^1$&lt;/span&gt; Hence, we may assume that the feasible region is a polytope.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Observation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Given a point in the polytope, we can split the polytope in a 'good side' and a 'bad side'. In the good side, all objective values are better or equal. In the bad side, all objective values are worse. This follows from the linear objective function.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Center of gravity method&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The center of gravity method is related to the ellipsoid method, but is not polynomial. The idea is simple:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Calculate the center of gravity of the current polytope.&lt;/li&gt;&#xA;&lt;li&gt;Throw away the 'bad side'.&lt;/li&gt;&#xA;&lt;li&gt;Repeat Steps 1 and 2 until the current polytope is small.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note that Step 2 always halves the volume of the current polytope, because we use the center of gravity. Hence, the volume of the current polytope decreases exponentially. This means that in a polynomial number of steps you will have an exponentially small area that contains an optimal solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is only one problem: calculating the center of gravity for an arbitrary polytope is difficult.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Ellipsoid method&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The ellipsoid method solves this problem in a clever way: calculating the center of gravity of ellipsoids is almost trivial, so let's just pretend that our polytope is an ellipsoid. We start with an ellipsoid that contains the polytope completely.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Calculate the center of gravity of the current ellipsoid.&lt;/li&gt;&#xA;&lt;li&gt;Throw away the 'bad side'.&lt;/li&gt;&#xA;&lt;li&gt;Put the 'good side' in a smaller ellipsoid, which becomes the current ellipsoid.&lt;/li&gt;&#xA;&lt;li&gt;Repeat Steps 1 to 3 until the current ellipsoid is small.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In Step 2, if it happens to be that the center of gravity of the current ellipsoid is feasible for the original LP, then we throw away the bad side as before. If the center of gravity is not feasible, there is still a bad side: it is the half of the ellipsoid that is completely infeasible. Make a sketch to convince yourself this is true. In both cases, the result is that the bad side does not contain the optimum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Step 2, half of the current ellipsoid is removed. In Step 3, we create a new ellipsoid that is smaller than the current ellipsoid. It turns out you can do this in such a way that the new volume is bounded by some factor between 0.5 and 1 of the previous ellipsoid. Hence, we again get exponential decrease!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a result, after a polynomial amount of work, we know the optimal solution to exponential precision. We do not need explicit feasibility cuts, just ellipsoids.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Final thoughts&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Basically, knowing the optimal solution to exponential precision is good enough to find an exact solution, because all input values have only so many digits. In the paper by Khachiyan, technical details like this are discussed properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$^1$&lt;/span&gt; It really does not matter, see Lemma 1 (Khachiyan, 1980).&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2019-08-30T01:03:59.987" LastActivityDate="2019-08-30T01:03:59.987" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1426" PostTypeId="2" ParentId="1417" CreationDate="2019-08-30T00:59:40.283" Score="4" Body="&lt;p&gt;If the feasible region would be convex, then you have a &lt;a href=&quot;https://doi.org/10.1023/A:1008316327038&quot; rel=&quot;nofollow noreferrer&quot;&gt;sum-of-ratios problem&lt;/a&gt;. In general, sum-of-ratios problems are &lt;span class=&quot;math-container&quot;&gt;$\mathcal{NP}$&lt;/span&gt;-hard, although your specific problem could be easier to solve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My intuition says that the function &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j\in M}\frac{x_{ij}}{C_j-\sum\limits_{i\in N} x_{ij}a_i}$$&lt;/span&gt; is not convex, such that the feasible region is probably non-convex. Note that for proving convexity you need that the Hessian is positive semi-definite. It is not sufficient for all elements to be non-negative.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-08-30T00:59:40.283" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1428" PostTypeId="2" ParentId="1412" CreationDate="2019-08-30T07:38:12.497" Score="12" Body="&lt;p&gt;In the context of computational complexity theory, a &lt;em&gt;hard problem&lt;/em&gt; typically refers to an infinite set of problem instances for which it is widely believed that the worst-case amount of work needed to solve the problem grows super-polynomially when the size of the problem instance grows. Here &quot;amount of work&quot; is typically measured in elementary operations (e.g. CPU instructions, that typically take a fixed amount of time), and the &quot;size of the problem&quot; instance is typically measured as the amount of symbols need to express the problem data (e.g. number of bits). Mixed Integer Programming is such a &lt;em&gt;hard&lt;/em&gt; problem. However, the theory only tells us that for any instance size, &lt;em&gt;some&lt;/em&gt; instances that are difficult to solve must exist. There may be plenty of instances for that same size that are easy to solve and the theory doesn't say anything about a fixed specific instance as the amount of work required to solve a fixed single instance is fixed as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above mentioned hardness is often proven using a reduction proof: you show that if you can solve a new problem class in a certain (e.g. polynomial) amount of work, you can solve another problem that is known to be hard in roughly the same amount of work. Such hardness proof are thus relative: they just argue that problem A is at least as hard as problem B. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In come cases, it is also possible to prove that a subclass of problem instances is significantly easier to solve. For mixed integer programming, these are for example instances where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The constraint matrix is &lt;a href=&quot;https://en.wikipedia.org/wiki/Unimodular_matrix#Total_unimodularity&quot; rel=&quot;noreferrer&quot;&gt;totally unimodular&lt;/a&gt; (the LP-relaxation will give you an integer solution)&lt;/li&gt;&#xA;&lt;li&gt;You have total &lt;a href=&quot;https://en.wikipedia.org/wiki/Total_dual_integrality&quot; rel=&quot;noreferrer&quot;&gt;dual-integrality&lt;/a&gt; (the LP-relaxation will give you an integer solution)&lt;/li&gt;&#xA;&lt;li&gt;The number of variables is bounded by a constant. (I don't recall the exact reference on how to do this, but I remember that it involves using the &lt;a href=&quot;https://en.wikipedia.org/wiki/Lenstra%E2%80%93Lenstra%E2%80%93Lov%C3%A1sz_lattice_basis_reduction_algorithm&quot; rel=&quot;noreferrer&quot;&gt;LLL-algorithm&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;The number of constraints is bounded by a constant, and the size of numbers in the instance are also bounded by a constant. This result is due to &lt;a href=&quot;https://dl.acm.org/citation.cfm?id=322287&quot; rel=&quot;noreferrer&quot;&gt;Papadimitriou&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If we are talking about a single problem instance without any additional information, the best you can do is try to solve it. If it turns out that the LP-relaxation is integer feasible, you stumbled upon an easy MIP instance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, solving a MIP to optimality requires two things: (1) a solution and (2) a proof that the solution is optimal. While finding a feasible solution is already a hard problem according to computational complexity theory, in practice the main difficulty is often finding the proof of optimality. If the LP-relaxation of the MIP turns out to be integer, this proof is relatively easy: it is the same as the proof that the LP is optimal (which you can check using duality theorems). If the LP-relaxation is not integer, the only way we know involves some form of enumeration. In fact, all branch-and-bound approaches are just a clever way to enumerate all possible integer solutions, cutting away only the part of the solution space for which it is known that the optimal solution can not lie there.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastActivityDate="2019-08-30T07:38:12.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1429" PostTypeId="2" ParentId="1421" CreationDate="2019-08-30T13:21:57.323" Score="3" Body="&lt;p&gt;This is a heuristic approach to the problem you describe using OR tools. Consider a procedure in which you “guess” what the maximum route duration is (across all routes), and will find this in a binary search fashion. Your guess, &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;, is between &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt;, and for a particular iteration, set it to &lt;span class=&quot;math-container&quot;&gt;$G=\frac{U+L}{2}$&lt;/span&gt;. At iteration 0, &lt;span class=&quot;math-container&quot;&gt;$L=0$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$U=\texttt{max duration vrp}$&lt;/span&gt; (45 in your example). Now add a constraint to the problem using &lt;code&gt;routing.AddDimension()&lt;/code&gt; that says that routes should have a duration less or equal to &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;. If the problem is feasible, then &lt;span class=&quot;math-container&quot;&gt;$U=G$&lt;/span&gt; and update &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;. Otherwise, &lt;span class=&quot;math-container&quot;&gt;$L=G$&lt;/span&gt; and update &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;. You do this until the &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; are arbitrarily close. Note that every time you update &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;, you need to update the constraint you added to the routing object (or create a new object from scratch).  &lt;/p&gt;&#xA;" OwnerUserId="602" LastEditorUserId="602" LastEditDate="2019-08-30T15:05:26.913" LastActivityDate="2019-08-30T15:05:26.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1430" PostTypeId="2" ParentId="1407" CreationDate="2019-08-30T16:20:38.600" Score="4" Body="&lt;p&gt;After having read Chapter 5.3 of Decision Making Under Uncertainty by Mykel J. Kochenderfer, I have come to some conclusions.&lt;/p&gt;&#xA;&lt;p&gt;We are dealing with model uncertainty, in which case we can formulate a Bayes Adaptive Model. In the book that I read, the term model uncertainty refers more to not knowing what the transition probabilities nor the structure of the model might be. In other papers that I read, model uncertainty pertaining to uncertainty of the arrival or service rates in queues might even refer to not knowing what the distribution of the arrival rate might be. So we actually know a lot about our model. We are just a bit uncertain about the exact value of the arrival rate but we know the model.&lt;/p&gt;&#xA;&lt;p&gt;In the book by Kochenderfer, the compare the Bayes Adaptive Model that of a Partially Observeable Markov Decision Process (POMDP). The same algorithms can essentially be used to solve these problems. Basically, these models make use of belief states and include some form of observation along the way in order to update the beliefs.&lt;/p&gt;&#xA;&lt;p&gt;I believe our model to be somewhat a bit different. We assume our model to be time-homogeneous/stationary and we will not be updating our beliefs at each epoch as a result. We assume our beliefs to be stationary until the Bayesian Filter is finished running. Only after it has completed do we do one of two things:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We update our beliefs of the arrival rates and the distribution changes a bit (it likely will become thinner as certainty increases). Increased certainty should have a small effect on the policy (or so it is hypothesized).&lt;/li&gt;&#xA;&lt;li&gt;A change in arrival rate is detected by the filter with 95% confidence. The arrival rate changes completely. It is introduced along with its new beliefs. This should have a large effect on the policy (this is known).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;We will thus create a new tuple to describe the state-space. Instead of having &lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2)$&lt;/span&gt; to describe the length of the two queues, we augment our belief of what the arrival rate might be and end up with &lt;span class=&quot;math-container&quot;&gt;$(x_1,\lambda_1^i,x_2,\lambda_2^j)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$i \in \{[0,N_{\lambda_1}] \cap \mathbb{Z}\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j \in \{[0,N_{\lambda_2}] \cap \mathbb{Z}\}$&lt;/span&gt;. The indices have to do with how many classes we divide the continuous distribution up into. The more classes, the more accurate but the strain on the size of the state-space. Our state-space is now of size &lt;span class=&quot;math-container&quot;&gt;$M\times N \times N_{\lambda_1}\times N_{\lambda_2}$&lt;/span&gt; which is quite large and the &amp;quot;curse-of-dimensionality&amp;quot; is likely to have an effect of Value and Policy Iteration.&lt;/p&gt;&#xA;&lt;p&gt;Now onto the new model. We want our policy to be based on the new 4 element tuple. Why? We can observe fully the queue lengths &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;. However we can use the last observed arrival rate into each queue as our current beliefs. Thus we can then lookup our required action to perform for the given tuple based on the current observed states and beliefs.&lt;/p&gt;&#xA;&lt;p&gt;We must account for the transitions resulting in both changes in state and belief. It is probably also worth mentioning at this point that only one event can cause a transition. I forgot to mention this in the description of the question. The transition rates are stated first (for the continuous time Markov chain) and then the transition probabilities  (as for the uniformized Markov chain) as I want to discuss the uniformization factor.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ &#xA;\begin{align}&#xA;T(x_1+1,\lambda_1^i,x_2,\lambda_2^j\mid x_1,\lambda_1^k,x_2,\lambda_2^l,u) &amp;amp; =  p(\lambda_1^i)p(\lambda_2^j)p(\lambda_1^k)p(\lambda_2^l)\times\lambda_1^i \\&#xA;T(x_1,\lambda_1^i,x_2+1,\lambda_2^j\mid x_1,\lambda_1^k,x_2,\lambda_2^l,u) &amp;amp; =  p(\lambda_1^i)p(\lambda_2^j)p(\lambda_1^k)p(\lambda_2^l)\times\lambda_2^j \\&#xA;T(x_1-1,\lambda_1^i,x_2,\lambda_2^j\mid x_1,\lambda_1^k,x_2,\lambda_2^l,u) &amp;amp; = p(\lambda_1^i)p(\lambda_2^j)p(\lambda_1^k)p(\lambda_2^l)\times u \mu_1 \\&#xA;T(x_1,\lambda_1^i,x_2-1,\lambda_2^j\mid x_1,\lambda_1^k,x_2,\lambda_2^l,u) &amp;amp; =  p(\lambda_1^i)p(\lambda_2^j)p(\lambda_1^k)p(\lambda_2^l)\times (1-u)\mu_2 \\&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Note that in the above the indices &lt;span class=&quot;math-container&quot;&gt;$i,j,k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; serve only to show different beliefs. We do assume that we may have &lt;span class=&quot;math-container&quot;&gt;$i = k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j = l$&lt;/span&gt; which corresponds to cases where the belief for the given arrival rate remains the same.&lt;/p&gt;&#xA;&lt;p&gt;We will have to use some factor to unformize the transitions. Let us call the factor &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt;. We think of &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; as some sample rate. I we observe the continuous time system evolve at intervals of this sample rate then we should be able to observe any event occur and never miss it. This is where the tricky part comes in. We assume the following sample rate:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \gamma = \mu_1 + \mu_2 + \max_{i}(\lambda_1^i) + \max_{j}(\lambda_2^j) $$&lt;/span&gt;&#xA;We note that the upper bound of our beliefs (the largest assumed arrival rate) is accounted for and will be observed. If &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; is our sample rate, then &lt;span class=&quot;math-container&quot;&gt;$\gamma^a$&lt;/span&gt; is our actual transition rate of the system to a change. Hence, denote &lt;span class=&quot;math-container&quot;&gt;$\gamma - \gamma^a$&lt;/span&gt; as our fictitious self-transition rate. Thus we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\gamma - \gamma^a = (1-u)\mu_1 + u\mu_2$$&lt;/span&gt;&#xA;We know have transition probabilities as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ &#xA;\begin{align}&#xA;P(x_1+1,\lambda_1^i,x_2,\lambda_2^j\mid x_1,\lambda_1^k,x_2,\lambda_2^l,u) &amp;amp; =  \frac{p(\lambda_1^i)p(\lambda_2^j)p(\lambda_1^k)p(\lambda_2^l)\times\lambda_1^i}{\gamma} \\&#xA;P(x_1,\lambda_1^i,x_2+1,\lambda_2^j\mid x_1,\lambda_1^k,x_2,\lambda_2^l,u) &amp;amp; =  \frac{p(\lambda_1^i)p(\lambda_2^j)p(\lambda_1^k)p(\lambda_2^l)\times\lambda_2^j}{\gamma} \\&#xA;P(x_1-1,\lambda_1^i,x_2,\lambda_2^j\mid x_1,\lambda_1^k,x_2,\lambda_2^l,u) &amp;amp; = \frac{p(\lambda_1^i)p(\lambda_2^j)p(\lambda_1^k)p(\lambda_2^l)\times u \mu_1}{\gamma} \\&#xA;P(x_1,\lambda_1^i,x_2-1,\lambda_2^j\mid x_1,\lambda_1^k,x_2,\lambda_2^l,u) &amp;amp; =  \frac{p(\lambda_1^i)p(\lambda_2^j)p(\lambda_1^k)p(\lambda_2^l)\times (1-u)\mu_2}{\gamma} \\&#xA;P(x_1,\lambda_1^i,x_2,\lambda_2^j\mid x_1,\lambda_1^k,x_2,\lambda_2^l,u) &amp;amp; = \frac{p(\lambda_1^i)p(\lambda_2^j)p(\lambda_1^k)p(\lambda_2^l)\times [(1-u)\mu_1 + u\mu_2]}{\gamma} \\&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;There we have it. This model should promise to account for the initial large uncertainty we face in the arrival rates once a change is detected in the Poisson process. I like this model as it separates the probe (Bayesian model for Poisson arrivals) and the actuator (control to implement from the updated policy). It would seem like it is quite an intuitive model and this would make it easier to understand/describe and troubleshoot. It might not be a computationally efficient approach though. Those are just opinions though.&lt;/p&gt;&#xA;" OwnerUserId="1241" LastEditorUserId="491" LastEditDate="2020-11-06T19:47:02.240" LastActivityDate="2020-11-06T19:47:02.240" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1431" PostTypeId="1" AcceptedAnswerId="1432" CreationDate="2019-08-31T08:09:03.300" Score="15" ViewCount="1349" Body="&lt;p&gt;Let us suppose we have an optimization problem which we have modeled as an ILP. Suppose we solve this problem using some set of constraints which restricts the search space. Let us suppose we model the same problem with the same objective function as an ILP but with some other set of constraints which produces a much larger search space. Which ILP could work faster, the one with the larger search space or the smaller search space? Is the same true for LP solvers?&lt;/p&gt;&#xA;" OwnerUserId="584" LastActivityDate="2019-08-31T14:52:52.253" Title="How does the search space affect the speed of an ILP solver?" Tags="|mixed-integer-programming|linear-programming|integer-programming|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1432" PostTypeId="2" ParentId="1431" CreationDate="2019-08-31T08:46:19.430" Score="11" Body="&lt;p&gt;When the solvers in question do not add cutting planes to further reduce the search space, the larger search space model typically produces feasible solutions more quickly, but its faster to prove optimality for the smaller search space model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that all modern codes use cutting planes, its difficult to predict performance, as always.&lt;/p&gt;&#xA;" OwnerUserId="69" LastActivityDate="2019-08-31T08:46:19.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1433" PostTypeId="2" ParentId="1431" CreationDate="2019-08-31T11:16:24.673" Score="7" Body="&lt;p&gt;The geometry of a polyhedron obtained by relaxing the integer variables is proposed as a complexity measure for IPs. This idea is based on the concept of ill-conditioning, something like the intrinsic difficulty of the problem. For instance, if you compare a solution space which is a &lt;em&gt;thin&lt;/em&gt; polyhedron with a few integer points on it, it is more difficult to solve than a &lt;em&gt;fat&lt;/em&gt; polyhedron with many integer points.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About the size of the problem (number of variables (columns) and number of constraints (rows)), Van Roy and Wolsey&lt;sup&gt;1&lt;/sup&gt; mentioned that: &quot;in contrast with LP, size is a poor indicator of difficulty. We believe that size is perhaps an even less reliable measure for mixed-integer programs than it is for pure integer programs.&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For two-dimensional Knapsack problem, Hill, Raymond R., and Charles H. Reilly&lt;sup&gt;2&lt;/sup&gt;, investigated the effect of various factors such as, the population correlation structure among coefficients, the level of constraint slackness, and the type of correlation, to evaluate the influence of these problem parameters on performance of branch-and-bound and heuristic solution procedures. Population correlation structure, and in particular the interconstraint component of the correlation structure, is found to be a &lt;em&gt;significant factor&lt;/em&gt; influencing the performance of both the algorithm and the heuristic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are some of the research directions that I think will help you find your answer. But unfortunately, there is not an exact answer to this question AFAIK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] Van Roy, Tony J., and Laurence A. Wolsey. &quot;Solving mixed integer programming problems using automatic reformulation.&quot; Operations Research 35.1 (1987): 45-57.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] Hill, Raymond R., and Charles H. Reilly. &quot;The effects of coefficient correlation structure in two-dimensional knapsack problems on solution procedure performance.&quot; Management Science 46.2 (2000): 302-317.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-08-31T11:16:24.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1434" PostTypeId="1" CreationDate="2019-08-31T12:24:56.773" Score="4" ViewCount="242" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XSxxF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XSxxF.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;Now, for each system &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$(X=A,B,C,E)$&lt;/span&gt;, my objective is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max\min\frac{s_{x_u}}{d_{x_u}}$$&lt;/span&gt;&#xA;here, &lt;span class=&quot;math-container&quot;&gt;$x=a$&lt;/span&gt; for system A, &lt;span class=&quot;math-container&quot;&gt;$x=b$&lt;/span&gt; for system B and follows...&lt;/p&gt;&#xA;&lt;p&gt;and for the whole system, my objective is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max\min\frac{s_{X}}{d_{X}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$s_{x_u}$&lt;/span&gt; is a function of optimization variable &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, i.e.,&lt;span class=&quot;math-container&quot;&gt;$s_{x_u}=f(a),$&lt;/span&gt;&#xA;while &lt;span class=&quot;math-container&quot;&gt;$s_{X}$&lt;/span&gt; is a function of optimization variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and of course &lt;span class=&quot;math-container&quot;&gt;$s_{x_u}$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$s_{X}=f(z,s_{x_u}).$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I formulate this optimization problem?&lt;/p&gt;&#xA;&lt;p&gt;I mean how to have a single objective function.&lt;/p&gt;&#xA;&lt;h2&gt;Ideas&lt;/h2&gt;&#xA;&lt;p&gt;For each system, I can rewrite the objective as &lt;span class=&quot;math-container&quot;&gt;$\max t_x$&lt;/span&gt; by adding the following constraint &lt;span class=&quot;math-container&quot;&gt;$s_{x_u}\ge t_x d_{x_u}$&lt;/span&gt;. So, I now have &lt;span class=&quot;math-container&quot;&gt;$\max t_a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\max t_b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\max t_c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\max t_e$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Likewise, for the overall system I can reformulate it as &lt;span class=&quot;math-container&quot;&gt;$\max t_X$&lt;/span&gt; and adding the following constraints &lt;span class=&quot;math-container&quot;&gt;$s_X\ge t_X d_X$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$X=\{A,B,C,E\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So, now the objective function I have is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max t_a\hspace{1mm} \&amp;amp; \max t_b \hspace{1mm} \&amp;amp; \max t_c \hspace{1mm} \&amp;amp; \max t_e \hspace{1mm} \&amp;amp; \max t_X.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is it okay to write &lt;span class=&quot;math-container&quot;&gt;$\max t_a+t_b+t_c+t_e+t_X$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-09-03T21:22:44.340" Title="How can I formulate this multi-objective optimization problem?" Tags="|optimization|linear-programming|modeling|nonlinear-programming|multi-objective-optimization|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1435" PostTypeId="2" ParentId="1431" CreationDate="2019-08-31T12:58:10.997" Score="6" Body="&lt;p&gt;With the exception of special cases and ill-posed problems, the answer is that no-one can really know until we start solving the problem. We know that this is related to the shape of the polyhedron, but performance is highly dependent on the exact formulation and the solvers' implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ILP solvers use two main techniques to reduce the solution space:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Integer cuts&lt;/li&gt;&#xA;&lt;li&gt;Constraint propagation&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Both can reduce the solution space massively, to the point that a smaller feasible space might be much harder to solve than a larger one if the above techniques are not very effective for that problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other side of the coin is the ILP heuristics. Because ILPs are solved using branch and bound (BnB). If the heuristics find the global solution very quickly BnB will usually be much faster. Unfortunately, this is largely a matter of luck (because heuristics are just that - heuristics).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="36" LastEditDate="2019-08-31T14:52:52.253" LastActivityDate="2019-08-31T14:52:52.253" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1436" PostTypeId="2" ParentId="1412" CreationDate="2019-08-31T15:50:17.353" Score="10" Body="&lt;p&gt;I'm going to stay away from asymptotic stuff and stick with problems whose dimensions seem manageable with current software. (Any problem is hard to solve if large enough. I once worked with some folks who proposed a spatial model so granular that the constraint matrix would not fit in memory.)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Slow improvement in the best node bound makes it hard to solve a MIP, at least if &quot;solve&quot; means &quot;to proven optimality&quot;. It's not uncommon to run a model with multiple sets of input parameters and have some instances solve quickly and others exhibit slow bound improvement. @nikaza mentioned &quot;big M&quot; models with large values of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. They tend to have weak relaxations, but it also happens with other types of models.&lt;/li&gt;&#xA;&lt;li&gt;Bad numerics can make your life miserable. By this I mean situations where rounding error results in incorrect solutions, slow progress or the solver just surrendering. Again, &quot;big M&quot; is sometimes the culprit, but it can happen for other reasons, including poorly scaled variables and constraints.&lt;/li&gt;&#xA;&lt;li&gt;Dealing with multiple objectives can be hard, in part because there may be no definitive &quot;correct&quot; way to balance them. I think the difficulty here is usually not that the model is hard to solve (although that can happen, due to numerics, if you optimize a weighted combination of objectives and use really big or really small weights for some). The difficulty tends to be needing to solve the model repeatedly with different trade-offs to find a solution that makes everyone happy.&lt;/li&gt;&#xA;&lt;li&gt;Symmetry can slow progress of the solver, largely because equivalent solutions can exist in different parts of the search tree. There are ways to exploit symmetry in some cases (if you know enough about the symmetry in the model at the outset, and possibly if you are coding your own solver) and ways to mitigate it (either by modeling or, with some solvers, by asking the solver to try to mitigate it), but I've dealt with instances where my best efforts were not enough to get the solution time down to something I was happy with.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-08-31T15:50:17.353" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1437" PostTypeId="2" ParentId="1099" CreationDate="2019-09-01T16:54:15.657" Score="5" Body="&lt;p&gt;First of all, kudos for wanting to do that - as others pointed out, optimization knowledge is vastly underutilized throughout the industry and we need more people like you. People have already given some excellent answers, so I'll focus more on the company-building point of view.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you realised, the most important thing is to identify the problem you want to solve - the solution will come later, once you have identified something that people care enough about to actually pay money for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second most important thing is to identify your market. Selling to consumers is very different than selling to companies: companies have long sales cycles, you need sales people and account managers, you need to do demos, charge a lot more money because you have fewer clients, provide stellar support, etc. Consumers on the other hand will simply buy your product if they like it and the price is good, but you need to raise awareness and build up the consumer base.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Application-wise, where to even begin? Interfacing existing applications, creating specialised solutions for sectors that don't traditionally use optimisation, creating tools to improve the workflow, tools to make modelling easier/more accessible, tools to process data before people even start optimising. Funnily enough, solvers are the toughest market because it takes so long to develop a solver that works properly and efficiently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Overall, the greatest advise I can give you is to talk to people. What we think the community needs is rarely what the community actually needs. A great book on how to interview people for information is called The Mom Test.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you mentioned, coming up with a demo, (or Minimal Viable Product) is tough in optimisation. We faced this problem a lot when building Octeract Engine - you don't just build a demo for a high performance solver, it either works or it doesn't. What we did instead was to make sure that the product, if and when it would be ready, would actually be useful enough for people to buy it, and we did that by interviewing people about the challenges they face and by crunching market data. Once we had that information, we then invested resources, effort, and time to build the engine, but not before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, whatever you end up choosing, make sure it's something you will enjoy doing and that you are passionate about. Building companies from scratch is hard, so you might as well have fun doing it.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-09-01T16:54:15.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1438" PostTypeId="2" ParentId="1176" CreationDate="2019-09-01T22:29:39.147" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I am trying to solve a workforce scheduling and optimization problem ...&lt;br&gt;&#xA;  I want to schedule the minimum number of people in each shift to achieve maximum foretasted volumes with minimum AHT. Also if you can provide a comparison of different methods and their advantages and disadvantages that would be helpful.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Make certain that your input data is correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's important to note that we typically assume the NCO (number of calls offered) accurately portrays the workload for which we need to staff. This assumption is valid as long as &lt;strong&gt;all calls are getting in&lt;/strong&gt; and that none are blocked at the network level by insufficient telephone trunks (busy signals). It's always a good idea to validate this assumption by requesting periodic &lt;em&gt;busy studies&lt;/em&gt; from your local and long distance carriers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another critical step of the data gathering process is to eyeball your information to make sure there are no data aberrations. You'll want to look for any abnormally low or high numbers as well as missing information. When you identify something out of the ordinary you should first determine the reason for the anomaly and then decide if it needs to be adjusted or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure you consider all the other pertinent areas as well. Will the billing department's new invoice format cause a flood of calls? How about sales forecasts from the Sales VP that can help you plan staff based on the new customer account base a year from now? Is the fulfillment area changing the way they package and ship products that may cause an increase (or decrease!) in your call volume? It's critical that you communicate regularly with all these influencers of call center workload as you prepare and fine-tune the forecast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make certain that there isn't anything that will unduly influence your gathered statistics. Ideally you will want to have available the previous 24 months so you can compare holiday periods and seasonal upward or downward trends. You'll also want available recent weeks without intervening holidays so week to week comparisons can be made.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once your input data is clean your resulting answer output will be better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Traditionally call center volumes have been modeled using &lt;a href=&quot;https://en.wikipedia.org/wiki/Erlang_(unit)#Erlang_C_formula&quot; rel=&quot;nofollow noreferrer&quot;&gt;Erlang C&lt;/a&gt; calculations, more recently the &lt;a href=&quot;https://en.wikipedia.org/wiki/Erlang_(unit)#Extended_Erlang_B&quot; rel=&quot;nofollow noreferrer&quot;&gt;Extended Erlang B&lt;/a&gt; formula has been applied. Those methods have &lt;a href=&quot;https://en.wikipedia.org/wiki/Erlang_(unit)#Limitations_of_the_Erlang_formula&quot; rel=&quot;nofollow noreferrer&quot;&gt;shortcomings&lt;/a&gt; which I've attempted to address in the previous paragraphs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most recently the formula has been improved, you guessed it, and now we have the Erlang A method. &lt;a href=&quot;https://www.callcentrehelper.com/a-beginners-guide-to-the-erlang-a-formula-140998.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Combining Erlang C and Erlang A&lt;/a&gt; you can receive the most accurate prediction for how many staff are needed, in accordance with your:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Forecast contact volumes&lt;/li&gt;&#xA;&lt;li&gt;Average Handling Time (AHT)&lt;/li&gt;&#xA;&lt;li&gt;Service level&lt;/li&gt;&#xA;&lt;li&gt;Occupancy&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.callcentrehelper.com/how-to-calculate-contact-centre-shrinkage-90353.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Shrinkage&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Average patience&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What Is the &lt;a href=&quot;https://www.callcentrehelper.com/erlang-c-formula-example-121281.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Erlang C Formula&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Erlang C formula is a mathematical equation for calculating the number of agents (advisors) that you need in a call centre, given the number of calls and the service level that you want to achieve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Erlang C formula is the most important part of the equation. It allows you to work out the probability that a call waits (Pw), given the Traffic Intensity (A) and the Number of Agents (N) available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$P_W = \Large \frac {\frac {A^N}{N!} \frac {N}{N - A} }{ \left( \sum  \limits^{\small N-1}_{\small i=0} \frac {A^i}{i!} \right) + \frac {A^N}{N!} \frac {N}{N - A} }&#xA;$$&lt;/span&gt;&lt;br&gt;&#xA;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.callcentrehelper.com/a-beginners-guide-to-the-erlang-a-formula-140998.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Erlang A formula&lt;/a&gt; is highlighted below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$P \{Ab | W &amp;gt; 0 \} = \Large {\frac { 1 }{\rho A \&amp;gt; \LARGE ( \frac {\eta \mu }{ \theta} , \frac { \lambda}{ \theta})}} + \normalsize {1 \&amp;gt;} – \&amp;gt; \Large \frac { 1 }{ \rho }$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where the formula is explained in Mandelbaum and Zeltyn's paper, equation 4.3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also: &quot;&lt;a href=&quot;https://arxiv.org/abs/1712.08445&quot; rel=&quot;nofollow noreferrer&quot;&gt;New Perspectives on the Erlang-A Queue&lt;/a&gt;&quot; (Dec 22 2017), by Andrew Daw and Jamol Pender for an analysis, &quot;&lt;a href=&quot;https://www.callcentrehelper.com/how-to-work-out-how-many-staff-you-need-in-a-contact-centre-96591.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to Work Out How Many Staff You Need in a Contact Centre&lt;/a&gt;&quot; from callcenterhelper.com and &quot;&lt;a href=&quot;https://scholar.google.com/scholar?cluster=8244984202566102497&amp;amp;hl=en&amp;amp;as_sdt=0,5&amp;amp;sciodt=0,5&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Palm/Erlang-A queue, with applications to call centers&lt;/a&gt;&quot; (Dec 28 2004), by A Mandelbaum and S Zeltyn. Here is an updated URL for the program &lt;a href=&quot;http://ie.technion.ac.il/serveng/4CallCenters/Downloads.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;4CallCenters&lt;/a&gt; mentioned in their paper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of online calculators available, saving you from writing a program. This one incorporates both Erlang &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;: &quot;&lt;a href=&quot;https://www.callcentrehelper.com/tools/erlang-calculator/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Erlang Calculator - for Call Centre Staffing (Online Version 4.2)&lt;/a&gt;&quot;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-09-01T22:29:39.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1439" PostTypeId="1" CreationDate="2019-09-02T12:00:02.037" Score="-4" ViewCount="1955" Body="&lt;p&gt;Does anyone know of a problem previously believed to be NP hard, to be solved nowadays in polynomial time optimally?&lt;/p&gt;&#xA;" OwnerUserId="1243" LastEditorUserId="81" LastEditDate="2019-09-03T10:37:53.647" LastActivityDate="2019-09-10T06:23:00.870" Title="Are there NP hard problems solved in P time?" Tags="|optimization|reference-request|computational-complexity|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="1440" PostTypeId="2" ParentId="1439" CreationDate="2019-09-02T12:07:05.067" Score="13" Body="&lt;p&gt;This is an answer to the original question before it was edited (&lt;em&gt;Can a problem move from NP to P&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No, if a problem is NP-complete then it is not solvable in polynomial time unless P=NP, which has not been proven yet. Furthermore, if there were any NP-hard problem which would be solvable in polynomial time then (by reduction) it could be used to solve any other problem in NP, thus implying P=NP.&lt;/p&gt;&#xA;" OwnerUserId="81" LastEditorUserId="81" LastEditDate="2019-09-04T06:10:51.930" LastActivityDate="2019-09-04T06:10:51.930" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1442" PostTypeId="1" AcceptedAnswerId="1499" CreationDate="2019-09-03T07:37:08.030" Score="15" ViewCount="1105" Body="&lt;p&gt;It is that dreadful time of the year when I am prepping classes and over the last few terms I came to the realization that I need to significantly beef up the practice-oriented content of my lectures. Consequently, I have started looking for case studies / problems with (ideally sufficiently large) data that can be modeled, solved and interpreted by the students.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware of synthetic test instances for Knapsack / TSP but I fear that they are a little too abstract for regular business students. Therefore, I would highly appreciate combinations of paper and data (e.g., &lt;a href=&quot;https://link.springer.com/content/pdf/10.1007%2Fs40685-014-0008-6.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://link.springer.com/content/pdf/10.1007%2Fs40685-014-0008-6.pdf&lt;/a&gt;, &lt;a href=&quot;https://drive.google.com/file/d/0BxuwSmNrxiTySWxJV3pQZ2I1YTg/edit&quot; rel=&quot;noreferrer&quot;&gt;https://drive.google.com/file/d/0BxuwSmNrxiTySWxJV3pQZ2I1YTg/edit&lt;/a&gt;) or free case studies (again ideally with data).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no requirements concerning the problem types - so anything that leverages OR tools and methods and can be replicated would work nicely. Ideally, the problem types should be close to what a student can handle equipped with a MIP solver plus general data preparation skills.&lt;/p&gt;&#xA;" OwnerUserId="33" LastEditorUserId="981" LastEditDate="2023-12-22T15:00:16.497" LastActivityDate="2023-12-22T15:00:16.497" Title="Case Studies and Real Problems for Teaching Optimization and Modelling" Tags="|or-tools|applications|teaching|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1443" PostTypeId="2" ParentId="1442" CreationDate="2019-09-03T08:36:19.817" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;http://www.math.uwaterloo.ca/tsp/concorde/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Concorde TSP solver&lt;/a&gt; comes with a nice GUI which visualizes the optimal TSP tour. Moreover, it also has several TSP-heuristics such as Greedy, Nearest Neighbor or Random-generation implemented. This makes it easy to visually compare heuristics and optimal solutions. According to their website the solver &quot;has been used to obtain the optimal solutions to the full set of 110 &lt;a href=&quot;https://wwwproxy.iwr.uni-heidelberg.de/groups/comopt/software/TSPLIB95/&quot; rel=&quot;nofollow noreferrer&quot;&gt;TSPLIB&lt;/a&gt; instances, the largest having 85,900 cities.&quot;&lt;/p&gt;&#xA;" OwnerUserId="81" LastActivityDate="2019-09-03T08:36:19.817" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1444" PostTypeId="2" ParentId="1442" CreationDate="2019-09-03T09:17:23.750" Score="14" Body="&lt;p&gt;The &lt;a href=&quot;https://pubsonline.informs.org/journal/ited&quot; rel=&quot;noreferrer&quot;&gt;INFORMS Transactions on Education&lt;/a&gt; is devoted to works about education in OR. There you can find many cases already used by teachers in their courses, along with &lt;a href=&quot;https://www.informs.org/Publications/Subscribe/Access-Restricted-Materials&quot; rel=&quot;noreferrer&quot;&gt;material for instructors&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="224" LastActivityDate="2019-09-03T09:17:23.750" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1445" PostTypeId="2" ParentId="1439" CreationDate="2019-09-03T14:00:16.800" Score="-7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Does anyone know of &lt;strong&gt;one&lt;/strong&gt; problem that is NP hard, but can now be solved in polynomial time optimally?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Wikipedia has this to say about &lt;a href=&quot;https://en.m.wikipedia.org/wiki/NP-completeness&quot; rel=&quot;nofollow noreferrer&quot;&gt;NP-completeness&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;In computational complexity theory, a problem is NP-complete when it can be solved by a restricted class of brute force search algorithms and it can be used to simulate any other problem with a &lt;strong&gt;similar algorithm&lt;/strong&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A problem is said to be NP-hard if everything in NP can be transformed in polynomial time into it, and a problem is NP-complete if it is both in NP and NP-hard. The NP-complete problems represent the hardest problems in NP. If any NP-complete problem has a polynomial time algorithm, all problems in NP do.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's not a &lt;em&gt;one size fits all&lt;/em&gt;, solve one you've solved them all, type of problem/solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a case of discovering one of the many difficult problems that can be solved by a new technique, and the applicability of using the same (or similar) methods to solve similar problems (not categorically every problem, or stating the equality of one set of problems to another).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few hard problems that now can be solved in polynomial time, or faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has been proven and demonstrated, using a new architecture, that the &lt;strong&gt;subset-sum problem&lt;/strong&gt; has been solved using standard microelectronic technology in a laboratory setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Z4h8I.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Z4h8I.jpg&quot; alt=&quot;Memcomputer Processor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &quot;&lt;a href=&quot;https://arxiv.org/abs/1411.4798&quot; rel=&quot;nofollow noreferrer&quot;&gt;Memcomputing NP-complete problems in polynomial time using polynomial resources and collective states&lt;/a&gt;&quot; (July 7 2015), by Fabio L. Traversa, Chiara Ramella, Fabrizio Bonani, and Massimiliano Di Ventra:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Memcomputing is a novel non-Turing paradigm of computation that uses interacting memory cells (memprocessors for short) to store and process information on the same physical platform. It was recently proved mathematically that memcomputing machines have the same computational power of non-deterministic Turing machines. Therefore, they can solve NP-complete problems in polynomial time and, using the appropriate architecture, with resources that only grow polynomially with the input size.&lt;br&gt;&#xA;  ...&lt;br&gt;&#xA;  Here, we show an experimental demonstration of an actual&#xA;  memcomputing architecture that &lt;strong&gt;solves the NP-complete version of the subset-sum problem in only one step (&lt;span class=&quot;math-container&quot;&gt;$T = 1/f_0$&lt;/span&gt;)&lt;/strong&gt; and is composed of a number of memprocessors that scales linearly with the size of the problem. We have fabricated this architecture using standard microelectronic technology so that it can be easily realized in any laboratory setting.&quot;.&lt;br&gt;&#xA;  ...  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Another hard problem is the Planted (&lt;span class=&quot;math-container&quot;&gt;$L, \Delta$&lt;/span&gt;) motif search (PMS) problem and the quorum PMP where the motif needs to occur in at least &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; of the &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.researchgate.net/publication/334457240_A_Survey_on_Applications_and_Architectural-optimizations_of_Micron&amp;#39;s_Automata_Processor&quot; rel=&quot;nofollow noreferrer&quot;&gt;A Survey on Applications and Architectural-optimizations of Micron's Automata Processor&lt;/a&gt;&quot;, Article in Journal of Systems Architecture · July 2019, DOI: 10.1016/j.sysarc.2019.07.006 &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;&lt;strong&gt;3.1 Bioinformatics&lt;/strong&gt;&lt;br&gt;&#xA;  &lt;strong&gt;“Planted (L, ∆) motif search problem” (PMP)&lt;/strong&gt;: For &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; strings, each of length &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, PMP finds a motif of length &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; that occurs in all the strings with at most &lt;span class=&quot;math-container&quot;&gt;$\Delta$&lt;/span&gt; mismatches [8]. For example, let the input strings be &lt;span class=&quot;math-container&quot;&gt;$\text{GATCAGTTCAC}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\text{TAAGACGGTCA}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\text{AGTCTCTCGAG}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$L = 4$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\Delta = 1$&lt;/span&gt;. Then the motif &lt;span class=&quot;math-container&quot;&gt;$\text{CTCA}$&lt;/span&gt; is present in all the three strings. Here, the motif itself need not be exactly present in any string, which is what happens in this case. PMP can be generalized to the “quorom PMP” (qPMP), where the motif needs to occur in at least &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; of the &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; strings. PMP and hence, qPMP are NP-hard problems [8]. PMP is useful in domains such as DNA and protein sequencing.&quot;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;[8]&lt;/code&gt; I. Roy and S. Aluru, “&lt;a href=&quot;https://www.semanticscholar.org/paper/Finding-Motifs-in-Biological-Sequences-Using-the-Roy-Aluru/124f0dbb0743049047fc767a27c31e6533c1c9ec#citing-papers&quot; rel=&quot;nofollow noreferrer&quot;&gt;Finding motifs in biological sequences using the Micron automata processor&lt;/a&gt;&quot;, in Parallel and Distributed Processing Symposium, 2014 IEEE 28th International, 2014, pp. 415–424.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.researchgate.net/publication/310821021_An_overview_of_micron&amp;#39;s_automata_processor&quot; rel=&quot;nofollow noreferrer&quot;&gt;An Overview of Micron’s Automata Processor&lt;/a&gt;&quot; by Ke Wang, Kevin Angstadt, Chunkun Bo, Nathan Brunelle, Elaheh Sadredini, Tommy Tracy II, Jack Wadden, Mircea Stan, Kevin Skadron, Dept. of Comp. Sci., Dept. of Elec. &amp;amp; Comp. Eng. University of Virginia&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Included image:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/K6umT.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aKz9i.jpg&quot; alt=&quot;Micron&amp;#39;s Automata Processor&quot;&gt;&lt;/a&gt;&#xA;  &lt;sub&gt;Figure 2 – Testing Board of Micron’s Automata processor. Click for a labeled diagram. The production model has the FPGA upgraded to Arria 10 GX270, uses a PCIe 3.0x8 connector and has 4 GB DDR3 32 bit @ 533 MHz. The SODIMM boards have four chips on each side.&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.micron.com/about/blog/2013/december/automata-processor-its-not-just-about-speed-and-power-consumption&quot; rel=&quot;nofollow noreferrer&quot;&gt;Micron&lt;/a&gt; sold their Automata Processor IP to &lt;a href=&quot;http://www.naturalsemi.com/products/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Natural Intelligence&lt;/a&gt;, whom licenses usage to the &lt;a href=&quot;https://engineering.virginia.edu/center-automata-processing-cap&quot; rel=&quot;nofollow noreferrer&quot;&gt;University of Virginia&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Videos:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;YouTube: &quot;&lt;a href=&quot;https://youtu.be/5guIAaOrMhk&quot; rel=&quot;nofollow noreferrer&quot;&gt;Micron's Automata Processor&lt;/a&gt;&quot; - Micron&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;YouTube: &quot;&lt;a href=&quot;https://youtu.be/RR34oPRaPEQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Micron Showcases Automata Processor for Big Data&lt;/a&gt;&quot; - RichReport&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Vimeo: &quot;&lt;a href=&quot;https://vimeo.com/170507280&quot; rel=&quot;nofollow noreferrer&quot;&gt;Webinar2.1 - Introductions.Skadron.final&lt;/a&gt;&quot; - UVA Computer Science&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Other: &quot;&lt;a href=&quot;https://ieeexplore.ieee.org/document/7516024&quot; rel=&quot;nofollow noreferrer&quot;&gt;Algorithmic Techniques for Solving Graph Problems on the Automata Processor&lt;/a&gt;&quot;, by Indranil Roy, Nagakishore Jammula and Srinivas Aluru,  Published in: 2016 IEEE International Parallel and Distributed Processing Symposium (IPDPS), Date of Conference: 23-27 May 2016,  DOI: 10.1109/IPDPS.2016.116 &lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-09-10T06:23:00.870" LastActivityDate="2019-09-10T06:23:00.870" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="1446" PostTypeId="1" AcceptedAnswerId="1452" CreationDate="2019-09-03T17:19:34.513" Score="13" ViewCount="616" Body="&lt;p&gt;Given a general non-linear problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}P:\qquad&amp;amp;\min_{x\in X} f(x)\\\text{s.t.}\qquad&amp;amp;g(x)\leq 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a non-linear function, &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is a vector of non-linear constraints, and &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a box-constrained domain, is there a way to formulate an optimisation problem to prove whether &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is convex or not?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is typically handled through heuristic procedures (symbolic compositions of functions, eigenvalue arithmetic, Dr. AMPL, etc.) but I'm curious about how to formulate an optimisation problem to definitively prove/disprove the convexity of a problem regardless of computing cost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We know from the theory that proving/disproving convexity of an NLP is an NP-hard (global optimisation) problem in the general case, but I can't find a formulation. Does one exist? Are you aware of a reference describing the formulation?&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="123" LastEditDate="2019-09-03T21:16:33.443" LastActivityDate="2019-09-07T11:40:49.117" Title="How to formulate a problem to prove/disprove convexity?" Tags="|nonlinear-programming|convexity|nonconvex-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1447" PostTypeId="1" CreationDate="2019-09-03T17:40:09.213" Score="8" ViewCount="200" Body="&lt;p&gt;I am working on a weekly staff scheduling optimization problem with 24/7 demand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The binary decision variable is: &lt;span class=&quot;math-container&quot;&gt;$X_{\text{staff},\,\text{day},\,\text{shift}}$&lt;/span&gt; whether to assign the staff &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; shift &lt;span class=&quot;math-container&quot;&gt;$\text{sh}$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several shift sets for everyday like 8-17 for full time. 14-19 for part time, and 20-6 for night shift.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 0-1 shift/hour matrix is: &lt;span class=&quot;math-container&quot;&gt;$\text{ShiftHourMap}_{\text{shift},\,\text{hour}}$&lt;/span&gt; which has 24 hours as columns, shifts as rows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The demand is formulated as: &lt;span class=&quot;math-container&quot;&gt;$\text{Demand}_{\text{day},\,\text{hour}}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current constraints are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;weekly upper/lower limit of total hours for every staff.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The demand coverage constraint is :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{\text{staff}}X_{\text{staff},\,\text{day},\,\text{shift}}\cdot \text{ShiftHourMap}_{\text{shift},\,\text{hour}}\ge\text{Demand}_{\text{day},\,\text{hour}}\,\forall{\text{day},\,\text{hour},\,\text{shift}}$$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The constraint like no assignment of daily shift after a night shift is not necessary, because the night shift is basically sleeping on site and staff sometimes is willing to pick a morning shift right after the overnight shift.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be fine if there's no overnight shift. How do I model the constraint to consider the overnight shift? And also, how to model the next Monday's early morning demand (last shift of Sunday)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I &lt;strong&gt;model as 24 * 7 hours&lt;/strong&gt; and use the hour as index? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can use MiniZinc or Pyomo.&lt;/p&gt;&#xA;" OwnerUserId="1219" LastEditorUserId="137" LastEditDate="2019-09-04T08:28:30.877" LastActivityDate="2019-09-04T08:28:30.877" Title="How to model 24 hours demand into a daily shift schedule?" Tags="|mixed-integer-programming|modeling|constraint|scheduling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1448" PostTypeId="1" CreationDate="2019-09-03T17:57:32.760" Score="7" ViewCount="670" Body="&lt;p&gt;I am trying to install the solver &quot;APOPT&quot; in Pyomo by following the guidelines laid out below: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;*Instructions for usage:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Place apopt.py in an appropriate folder in the system path (e.g. Linux, /usr/bin/)&lt;/li&gt;&#xA;&lt;li&gt;Set appropriate permissions to make the script executable (e.g. chmod 775 apopt.py)&lt;/li&gt;&#xA;&lt;li&gt;In AMPL, Pyomo, or other NL file write, set solver option to apopt.py&lt;/li&gt;&#xA;&lt;li&gt;Test installation by running apopt.py -test&#xA;*&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I essentially copy/paste the apopt.py script from the GitHub Repository into a .py file and have placed it in my project folder that I am working in. I think that the permissions should be okay. However, when I run step 3 at the command line I get the following errors: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;WARNING: Failed to create solver with name 'apopt': Failed to set executable&#xA;    for solver asl. File with name=apopt either does not exist or it is not&#xA;    executable. To skip this validation, call set_executable with&#xA;    validate=False.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And when I try to do Step 4 I get: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;'apopt' is not recognized as an internal or external command,&#xA;operable program or batch file.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure why this is happening though?&lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="51" LastEditDate="2019-09-07T23:29:40.913" LastActivityDate="2019-09-20T18:13:00.103" Title="Problems Installing APOPT in Pyomo" Tags="|solver|pyomo|windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1449" PostTypeId="2" ParentId="1448" CreationDate="2019-09-03T18:03:34.960" Score="5" Body="&lt;p&gt;It sounds like the APOPT executable is not in your system's PATH. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From your description, I suspect that the solver's name should be &lt;code&gt;--solver=apopt.py&lt;/code&gt; instead of &lt;code&gt;--solver=apopt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="123" LastEditDate="2019-09-20T18:13:00.103" LastActivityDate="2019-09-20T18:13:00.103" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1450" PostTypeId="2" ParentId="1447" CreationDate="2019-09-03T20:09:30.247" Score="5" Body="&lt;p&gt;I'm not sure I understand what the questions are. In your demand constraint, you should also include a term for &lt;span class=&quot;math-container&quot;&gt;$X_{\text{staff},\,\text{day} - 1, \,\text{overnight}}$&lt;/span&gt; on every day other than day 1. On day 1, the equivalent tweak is to adjust the demand by the staff level of the overnight shift from the last day of the previous week (which you presumably know).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adjusting for carryover to the first day of the following planning horizon is a bit trickier. You might want to search for &quot;horizon effects&quot; (or something similar with the word &quot;horizon&quot; in it) in the context of scheduling or planning models. There are multiple approaches to dealing with horizon limits. Three among them come to mind. The first is to ignore the horizon and just take your chances on what the carryover staff is the following week. This is best not used if there's a legitimate chance you would not be able to cover demand (because this week's model put too few people in the graveyard shift at the end of the week). The second option is to add a constraint assigning a nonzero lower limit to the final graveyard shift. You would have to guess the limit to use. The third option is to assign a per-person value for the last graveyard shift and incorporate it into the objective (as a cost reduction, assuming you're minimizing cost). Again, that coefficient would necessarily be a guess. The idea is to encourage the solver to put people in that last shift.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you are armed with a reasonable amount of historical demand data, you could try option 2 or option 3 with various guesses for the extra parameter (staff lower limit or staff &quot;bonus&quot; value) and see which value produces best overall results on the historical data.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="123" LastEditDate="2019-09-03T21:08:05.957" LastActivityDate="2019-09-03T21:08:05.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1451" PostTypeId="1" CreationDate="2019-09-04T00:07:13.913" Score="10" ViewCount="335" Body="&lt;p&gt;When using DOCplex to implement column generation, is it possible to add columns as an object, as opposed to creating a variable and then modifying the coefficients in the constraints? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; In gurobi one can add a column creating the object &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/py_column2.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Column&lt;/a&gt; and passing that object as the last argument of the &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/py_model_addvar.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;function that creates variables&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="602" LastEditorUserId="38" LastEditDate="2019-09-04T13:32:17.030" LastActivityDate="2019-09-04T13:32:17.030" Title="DOCplex adding columns" Tags="|cplex|column-generation|docplex|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1452" PostTypeId="2" ParentId="1446" CreationDate="2019-09-04T03:04:11.703" Score="14" Body="&lt;p&gt;Based on the comment by Ryan Cory-Wright, you could formulate it like this.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Verify convexity of the domain &lt;span class=&quot;math-container&quot;&gt;$\{x \in X : g(x) \le 0\}$&lt;/span&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Solve the following problem, and check the optimal value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max\qquad&amp;amp; g\left(\lambda x + (1-\lambda) y\right) &amp;amp;&amp;amp; \small\textrm{(maximize constraint violation of convex combination)}\\&#xA;\text{s.t.}\qquad&amp;amp; g(x) \le 0 &amp;amp;&amp;amp; \textrm{($x$ is feasible)}\\&#xA;&amp;amp; g(y) \le 0 &amp;amp;&amp;amp; \textrm{($y$ is feasible)}\\&#xA;&amp;amp; 0 \le \lambda \le 1 &amp;amp;&amp;amp; \textrm{(define convex combination)}\\&#xA;&amp;amp; x, y \in X &amp;amp;&amp;amp; \textrm{(definitions $x$ and $y$)}\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the optimal value is (strictly) positive, then the set is not convex, as &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are both in the set, while their convex combination &lt;span class=&quot;math-container&quot;&gt;$\lambda x + (1-\lambda) y$&lt;/span&gt; is not. If the optimal value is non-positive, then the set is convex. &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Verify convexity of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; on the domain &lt;span class=&quot;math-container&quot;&gt;$\{x \in X : g(x) \le 0\}$&lt;/span&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Solve the following problem, and check the optimal value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max\qquad&amp;amp; \small f(\lambda x + (1-\lambda) y) - \left(\lambda f(x) - (1-\lambda) f(y)\right) &amp;amp;&amp;amp; \small\textrm{(maximize violation of convex combination)}\\&#xA;\text{s.t.}\qquad&amp;amp; g(x) \le 0 &amp;amp;&amp;amp; \textrm{($x$ is feasible)}\\&#xA;&amp;amp; g(y) \le 0 &amp;amp;&amp;amp; \textrm{($y$ is feasible)}\\&#xA;&amp;amp; 0 \le \lambda \le 1 &amp;amp;&amp;amp; \textrm{(define convex combination)}\\&#xA;&amp;amp; x, y \in X &amp;amp;&amp;amp; \textrm{(definitions $x$ and $y$)}\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the optimal value is (strictly) positive, then there exists a convex combination such that &lt;span class=&quot;math-container&quot;&gt;$f(\lambda x + (1-\lambda) y) &amp;gt; \lambda f(x) + (1-\lambda) f(y)$&lt;/span&gt;, which violates convexity. If the optimal value is non-positive, &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is convex.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Solving the above problems&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;As you already mention, solving the above problems could be very difficult, even if &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; are actually convex. Things can become even more difficult if the functions are 'weird'. For example,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$g(x) = \begin{cases}\textrm{0 if $x \in \mathbb{Q}^n$}\\\textrm{1 if $x \notin \mathbb{Q}^n$}\end{cases}$$&lt;/span&gt; seems very problematic!&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2019-09-07T11:40:49.117" LastActivityDate="2019-09-07T11:40:49.117" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1453" PostTypeId="2" ParentId="1451" CreationDate="2019-09-04T09:11:50.683" Score="4" Body="&lt;p&gt;let me a tiny example out of my &lt;a href=&quot;https://medium.com/@alexfleischer_84755/optimization-simply-do-more-with-less-zoo-buses-and-kids-66940178db6&quot; rel=&quot;nofollow noreferrer&quot;&gt;zoo and buses story&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;# original model&#xA;&#xA;mdl = Model(name='buses')&#xA;nbbus40 = mdl.integer_var(name='nbBus40')&#xA;nbbus30 = mdl.integer_var(name='nbBus30')&#xA;ctKids=mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;mdl.minimize(nbbus40*500 + nbbus30*400)&#xA;&#xA;mdl.solve()&#xA;&#xA;&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&quot; = &quot;,v.solution_value)&#xA;&#xA;print()&#xA;print(&quot;Same number of 40 and 30 seats buses&quot;)&#xA;&#xA;mdl.add_constraint(nbbus40==nbbus30, 'samenumberofbuses')&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&quot; = &quot;,v.solution_value)    &#xA;&#xA;&#xA;print()&#xA;print(&quot;Now with buses with 50 seats&quot;)&#xA;&#xA;&#xA;&#xA;&#xA;# And now we add 50 seats buses&#xA;&#xA;nbbus50 = mdl.integer_var(name='nbBus50')&#xA;&#xA;ctKids.left_expr.add_term(nbbus50, 50)&#xA;mdl.minimize(nbbus40*500 + nbbus30*400 + nbbus50*700)&#xA;&#xA;mdl.solve()&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&quot; = &quot;,v.solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nbBus40  =  6.0&#xA;nbBus30  =  2.0&#xA;&#xA;Same number of 40 and 30 seats buses&#xA;nbBus40  =  6.0&#xA;nbBus30  =  2.0&#xA;&#xA;Now with buses with 50 seats&#xA;nbBus40  =  3.0&#xA;nbBus30  =  3.0&#xA;nbBus50  =  2.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2019-09-04T09:11:50.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1454" PostTypeId="2" ParentId="1442" CreationDate="2019-09-04T11:17:27.017" Score="10" Body="&lt;p&gt;There are lots of resources that contain optimization models and whose codes. Some of them are as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Supply chain:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0073525235&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Operations and supply management: The core&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://networkdesignbook.com/academic-use/new-book-teach-cplex-and-optimization-along-with-network-design/&quot; rel=&quot;noreferrer&quot;&gt;A deep dive into strategic network design&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;2) Scheduling and manufacturing:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/gp/book/9783540298786&quot; rel=&quot;noreferrer&quot;&gt;Introduction to Computational Optimization Models for Production Planning in a Supply Chain&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://onlinelibrary.wiley.com/doi/book/10.1002/9781118029114&quot; rel=&quot;noreferrer&quot;&gt;Scheduling in Supply Chains Using Mixed Integer Programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.stern.nyu.edu/om/faculty/pinedo/book2/new/index.html&quot; rel=&quot;noreferrer&quot;&gt;Operations Scheduling&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.math.vu.nl/~sbhulai/papers/thesis-titiyevska.pdf&quot; rel=&quot;noreferrer&quot;&gt;The shift scheduling problem using a branch-and-price approach&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://icaps17.icaps-conference.org/tutorials/T3-Introduction-to-CP-Optimizer-for-Scheduling.pdf&quot; rel=&quot;noreferrer&quot;&gt;Introduction to CP Optimizer for Scheduling&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.researchgate.net/publication/325624743_An_Update_on_the_Comparison_of_MIP_CP_and_Hybrid_Approaches_for_Mixed_Resource_Allocation_and_Scheduling&quot; rel=&quot;noreferrer&quot;&gt;Comparison of MIP, CP and Hybrid Approaches&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;3) Facility location and VRP:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/gp/book/9783790821505&quot; rel=&quot;noreferrer&quot;&gt;Facility Location Concepts, Models, Algorithms and Case Studies&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://books.google.com/books/about/Facilities_Design.html?id=GxljDAAAQBAJ&quot; rel=&quot;noreferrer&quot;&gt;Facilities design&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;4) Softwares (CPLEX, GAMS, MIPCL)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gams.com/resources/presentations-advertisements-books/&quot; rel=&quot;noreferrer&quot;&gt;GAMS Modelling&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.0/ilog.odms.ide.help/OPL_Studio/usroplexamples/topics/opl_mp_examples.html&quot; rel=&quot;noreferrer&quot;&gt;CPLEX Examples&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://mipcl-cpp.appspot.com/mipcl-py.html&quot; rel=&quot;noreferrer&quot;&gt;MIPCL&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;5) Some websites and blogs that contain so nice examples, codes and tricks&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://orinanobworld.blogspot.com/&quot; rel=&quot;noreferrer&quot;&gt;OR in an OB World by @prubin&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/&quot; rel=&quot;noreferrer&quot;&gt;Yet Another Math Programming Consultant by Erwin Kalvelagen&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.amsterdamoptimization.com/&quot; rel=&quot;noreferrer&quot;&gt;Amsterdam optimization&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://agecon2.tamu.edu/people/faculty/mccarl-bruce/&quot; rel=&quot;noreferrer&quot;&gt;Bruce A. McCarl&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.dropbox.com/sh/c8anpwz3uxlz8so/AADdJ8261mdupDytZrhnYLHZa?dl=0&quot; rel=&quot;noreferrer&quot;&gt;Location-routing problem with simultaneous pickup and delivery&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.dropbox.com/sh/c8anpwz3uxlz8so/AADdJ8261mdupDytZrhnYLHZa?dl=0&quot; rel=&quot;noreferrer&quot;&gt;Two-stage DEA with Fuzzy Data&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;6) Some excel-based modelling&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.doanalytics.net/Documents/OPTEX-Tutorial-2-VRP-Modeling-Excel.pdf&quot; rel=&quot;noreferrer&quot;&gt;Implementation of the VRP problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://dl4a.org/uploads/pdf/Wiley%20Excel%20Models%20for%20Business%20and%20Operations%20Management%202nd.pdf&quot; rel=&quot;noreferrer&quot;&gt;Excel Models for Business and Operations Management&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.me.utexas.edu/~jensen/ORMM/excel/library_windows.html&quot; rel=&quot;noreferrer&quot;&gt;ORMM Excel&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Indeed, there are many other related resources. I hope they would be helpful to you. &lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-09-04T11:17:27.017" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1455" PostTypeId="1" AcceptedAnswerId="2539" CreationDate="2019-09-04T12:56:54.210" Score="7" ViewCount="1008" Body="&lt;p&gt;I am using a mixed-integer-program to schedule employees to projects. These projects can have a time window to get completed from a few weeks to a few months.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment I am working in a dimension of dates. Surely, you can argue that a week dimension is more suitable but I want to make the formulation as generic as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In the end, I would like to have my employees scheduled in such a manner, that if an employee is picked he should stay assigned for the project for as long as he is available for sequence dates.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an oversimplified example of how it should look like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have three dates 1,2,3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;x is the binary decision variable of employee x&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; for date 1&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; for date 2&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; for date 3 &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;analog for employee y with the decision variable y&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I know that I have to implement this within my objective function which will have to get maximized. Otherwise, if I use constraints there may be a problem with finding a feasible solution.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would like to achieve is the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The calculation of the following should look like this if there is employee availability: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notation: [&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;] means that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) [&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;]&lt;br&gt;&#xA; b) [&lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt;] &lt;/p&gt;&#xA;&#xA;&lt;p&gt;are greater &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;$&lt;/span&gt; than&lt;/p&gt;&#xA;&#xA;&lt;p&gt;c) [&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt;]&lt;br&gt;&#xA; d) [&lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;]  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;] &lt;/li&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt;]&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;are strictly greater &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;$&lt;/span&gt; than&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt;]&lt;/li&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;]&lt;/li&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt;]&lt;/li&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;]&lt;/li&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;] &lt;/li&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt;] &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt;]&lt;/li&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;]&lt;/li&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt;]&lt;/li&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;]&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;are strictly greater &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;$&lt;/span&gt; than&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;7&quot;&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;] &lt;/li&gt;&#xA;&lt;li&gt;[&lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt;] &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;At the moment this is how my objective function would look like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1 + y_1 + (x_1 + x_2) + (y_1 + y_2) + (x_1 + x_2 + x_3) + (y_1 + y_2 + y_3)$&lt;/span&gt; &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1,x_2$&lt;/span&gt; -&gt; 5&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1,y_2$&lt;/span&gt; -&gt; 2&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1,x_2,x_3$&lt;/span&gt; -&gt; 6&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1,x_2,y_3$&lt;/span&gt; -&gt; 4&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1,y_2,y_3$&lt;/span&gt; -&gt; 4&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1,y_2,x_3$&lt;/span&gt; -&gt; 4&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_1,x_2,y_3$&lt;/span&gt; -&gt; 4&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_1,y_2,x_3$&lt;/span&gt; -&gt; 4&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I still have to tweak it since &lt;span class=&quot;math-container&quot;&gt;$y_1,x_2,y_3$&lt;/span&gt; should be strictly smaller &lt;span class=&quot;math-container&quot;&gt;$&amp;lt;$&lt;/span&gt; than &lt;span class=&quot;math-container&quot;&gt;$y_1,y_2,x_3$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would this method work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I could achieve the same, by assigning as few employees as possible to a project for a given task. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Surely, employees could get assigned to dates interchangeably and asymmetrically but within a week this would not matter since it is not relevant which employee is assigned to which date but to which week.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;" OwnerUserId="456" LastEditorUserId="38" LastEditDate="2019-09-06T12:38:11.540" LastActivityDate="2019-09-12T13:30:51.930" Title="Finding an Objective Function for Assigning Employees to Sequence Dates" Tags="|mixed-integer-programming|modeling|scheduling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1456" PostTypeId="1" CreationDate="2019-09-04T13:45:59.233" Score="8" ViewCount="1073" Body="&lt;p&gt;For anyone familiar with the Pyomo book, it occasionally makes reference to the AMPL Solver Library, and to my understanding, if you can manage to hook up to the solver library then you are able to use those particular solvers. However, I am confused because I am interpreting the idea of the AMPL Solver Library as open source in a similar way as to how you can just use NEOS as a &quot;Solver Manager&quot; and then get access to various solvers that way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way that I understand how solvers work is that you can either 'hook up' to something like the NEOS Server and then use the available solvers, or you can download the solvers locally and use those somehow. It's a crude understanding, but how exactly we connect to the solvers is still something I am trying to wrap my head around. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would you first need to purchase the solver - knitro for example - and then we can use the knitro solver through the AMPL library? Or, if we interface through the AMPL library (like we can do with NEOS) then we can use knitro for free? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lz8bH.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lz8bH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="38" LastEditDate="2019-09-21T01:21:25.653" LastActivityDate="2019-09-21T01:21:25.653" Title="Understanding the AMPL Solver LIbrary within Pyomo" Tags="|solver|pyomo|ampl|modeling-languages|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1457" PostTypeId="2" ParentId="1456" CreationDate="2019-09-04T18:17:13.920" Score="3" Body="&lt;p&gt;The AMPL Solver Library (or ASL) is an open-source interface between solvers and modelling languages. As long as a solver can (i) read an .nl file and (ii) produce a .sol file, it will work out of the box with AMPL and any other modelling platform, such as Pyomo, that supports ASL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, many solvers do not come with an ASL interface out of the box. For commercial solvers, the vendors sometimes sell the version of the solver with an ASL interface separately, or they send it upon request.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-09-04T18:17:13.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1458" PostTypeId="1" CreationDate="2019-09-04T20:42:50.337" Score="9" ViewCount="80" Body="&lt;p&gt;Is it possible to use SMCA (Spatial Multi Criteria Analysis) for determining simultaneously where to locate various facilities? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose, for example, I'm planing to build a new city and everything has already been determined, with the exception of the hospital locations. If I needed to build a single hospital, it would be easy to use Spatial Multi Criteria Analysis to determine where it should be placed. Nevertheless, how can the problem of determining the locations of possibly many hospitals be approached?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I googled every possible keyword to find similar problems, but no success so far. My current guess is that I should break the problem in two, first creating a model with SMCA to assign a cost to each choice of hospital location and then creating a single utility function combining the costs of any combination of choice locations. Then I could use gradient descent (or other non-linear optimization procedure) to find the combination of locations which maximizes my utility function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this makes sense! I'm new to Operations Research and I just got the opportunity to receive &quot;free consulting&quot; for my company, but for that I need to submit a project until Friday and my boss believes this is a problem we could tackle.&lt;/p&gt;&#xA;" OwnerUserId="1270" LastEditorUserId="38" LastEditDate="2019-09-04T20:55:12.613" LastActivityDate="2019-09-06T05:18:42.460" Title="Using Spatial Multi Criteria Analysis for simultaneously locating various facilities?" Tags="|modeling|facility-location|multi-objective-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1459" PostTypeId="1" AcceptedAnswerId="1460" CreationDate="2019-09-05T02:51:48.700" Score="9" ViewCount="3652" Body="&lt;p&gt;Using Matlab to solve a problem which has linear objective function and many nonlinear constraints, I am trying to generate the inequality nonlinear constraints by a function and pass it to fmincon solver via &lt;em&gt;nonlcon&lt;/em&gt; option. My question is if there are no equality nonlinear constraints in the model what should the constraints generator pass to fmincon? I tried the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function [c, ceq] = consgenerator(x) &#xA;&#xA;c = @(x) *[some constraints]*;  &#xA;&#xA;ceq = [];    &#xA;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In another attempt, I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ceq = @(x) [];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I got errors in both trials and couldn’t find an example of passing many nonlinear inequality constraints into fmincon.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="36" LastEditDate="2019-09-05T12:41:56.970" LastActivityDate="2020-11-09T21:42:38.330" Title="Matlab fmincon for a problem with many nonlinear constraints" Tags="|solver|nonlinear-programming|matlab|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1460" PostTypeId="2" ParentId="1459" CreationDate="2019-09-05T04:00:52.960" Score="10" Body="&lt;p&gt;The problem might be &lt;code&gt;@(x)&lt;/code&gt; in the first line of the function. Adding this creates an anonymous function, while MATLAB simply expects a numerical vector as output. Removing &lt;code&gt;@(x)&lt;/code&gt; should resolve the issue. Using &lt;code&gt;ceq = []&lt;/code&gt; should not give any problems.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="123" LastEditDate="2019-09-05T06:58:08.863" LastActivityDate="2019-09-05T06:58:08.863" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1461" PostTypeId="2" ParentId="1459" CreationDate="2019-09-05T07:46:35.977" Score="8" Body="&lt;p&gt;Following &lt;a href=&quot;https://or.stackexchange.com/users/145/kevin-dalmeijer&quot;&gt;Kevin Dalmeijer&lt;/a&gt;'s &lt;a href=&quot;https://or.stackexchange.com/a/1460/39&quot;&gt;answer&lt;/a&gt; (&lt;em&gt;Accepted&lt;/em&gt;), I found the following approach to solve the problem that I had. (&lt;em&gt;composing this answer for future similar questions&lt;/em&gt;):&lt;/p&gt;&#xA;&lt;p&gt;The general form of Fmincon function (minimizing constrained nonlinear multivariable function) in Matlab optimization toolbox is as follow:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Option 1: fmincon(ObjFun,x0,A,b,Aeq,beq,lb,ub,@nonlcon,options); or &#xA;Option 2: fmincon(ObjFun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;in which &lt;strong&gt;nonlcon&lt;/strong&gt; (used to add the nonlinear constraints to the model) can be a function name or a &lt;a href=&quot;https://www.mathworks.com/help/matlab/matlab_prog/creating-a-function-handle.html?s_tid=doc_ta&quot; rel=&quot;nofollow noreferrer&quot;&gt;function handle&lt;/a&gt; (by putting @ before function's name). Two mentioned expressions have a very slight difference in their implementation.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For the first case, as Kevin mentioned you can define a function with the same name and generate all the nonlinear constraints (including Equality and Inequality) and return &lt;code&gt;[c,ceq]&lt;/code&gt; to Fmincon as the output of the defined &lt;strong&gt;nonlcon&lt;/strong&gt; function. In this option, &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;ceq&lt;/code&gt; can be two vectors of residual.&lt;/li&gt;&#xA;&lt;li&gt;In the second option, function handle should be either defined outside of definition of Fmincon or defined inside the &lt;strong&gt;nonlcon&lt;/strong&gt; function.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Explanation of all the other variables in fmincon can be found &lt;a href=&quot;https://www.mathworks.com/help/optim/ug/fmincon.html?searchHighlight=fmincon&amp;amp;s_tid=doc_srchtitle&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I tried the combination of two approaches which caused the error in my code.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="491" LastEditDate="2020-11-09T21:42:38.330" LastActivityDate="2020-11-09T21:42:38.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1462" PostTypeId="2" ParentId="1458" CreationDate="2019-09-06T05:18:42.460" Score="3" Body="&lt;p&gt;Although it seems to be late to answer this question (as you need to submit a project until Friday), the following papers can be helpful in determining a solution approach to the multi-facility decision-making framework:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the paper&lt;sup&gt;1&lt;/sup&gt;, the authors applied &lt;em&gt;mixed integer goal programming&lt;/em&gt; in determining the facility location, route and flow of different varieties of recyclable waste paper in the multi-item, multi-echelon and &lt;strong&gt;multi-facility&lt;/strong&gt; decision-making framework.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While surveying the MCDM methods in facility location problems the paper&lt;sup&gt;2&lt;/sup&gt;, stated that: &quot;There are many decision-making problems whose information is spatial (geographical). In many real-world problems, the decision-maker likes to pursue more than one target or consider more than one factor or measure. Such a desire transforms the decision-making problem to a multi-objective decision making (MODM) problem or a multi-attribute decision making (MADM) problem. These groups of problems all come together in one category, named multi-criteria decision making (MCDM) problems.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, (based on my own experience for master thesis), there are some of the MADM methods which can be used to rank the alternatives based on their closeness to the most desired option for the DMs and also their remoteness from least desired answer. Examples of these type of methods are TOPSIS and ELECTRE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] Pati, Rupesh Kumar, Prem Vrat, and Pradeep Kumar. &quot;A goal programming model for paper recycling system.&quot; Omega 36.3 (2008): 405-417.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] Farahani, Reza Zanjirani, Maryam SteadieSeifi, and Nasrin Asgari. &quot;Multiple criteria facility location problems: A survey.&quot; Applied Mathematical Modelling 34.7 (2010): 1689-1709.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-09-06T05:18:42.460" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1463" PostTypeId="2" ParentId="1455" CreationDate="2019-09-06T09:58:04.473" Score="4" Body="&lt;p&gt;I think that if you don't want to introduce additional variables, you will have to use products of them, to give additional value to, say, &lt;span class=&quot;math-container&quot;&gt;$x_1 \cdot x_2$&lt;/span&gt;. Since theses are all binary variables, you could also linearize the terms yourself (introducing auxiliary variables) and stay in the MIP form.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe it's natural to introduce another dimension to your variables, indicating the &lt;em&gt;duration&lt;/em&gt; that a person is assigned to a project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;span class=&quot;math-container&quot;&gt;$x_{t,d}$&lt;/span&gt; would mean that person &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; starts at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and then stays on that project for exactly &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; time steps.&#xA;This way, you could give higher weight to the &lt;span class=&quot;math-container&quot;&gt;$x_{.,d}$&lt;/span&gt; variables with large &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-09-06T09:58:04.473" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="1464" PostTypeId="1" CreationDate="2019-09-06T13:41:45.837" Score="9" ViewCount="509" Body="&lt;p&gt;The problem I solved is a flow-shop scheduling problem with parallel machines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I solved it with the IBM ILOG CPLEX Optimization framework.&#xA;There I used the constraint programming (CP).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is now to what kind of field of operations research CP belongs, in particular the described flow-shop problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the definition of some books and websites I thought that it would be part of linear optimization, in particular integer linear optimization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'm not sure because I don't know if my problem can be formulated in a mathematical way, needed for linear optimization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So can someone help me classify this?&lt;/p&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="123" LastEditDate="2019-09-06T13:57:35.940" LastActivityDate="2021-03-11T03:33:48.957" Title="To which area does constraint programming belong?" Tags="|optimization|constraint-programming|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1466" PostTypeId="1" AcceptedAnswerId="1468" CreationDate="2019-09-06T17:12:09.910" Score="7" ViewCount="151" Body="&lt;p&gt;I'm trying to use Neos/GAMS to solve an optimization problem. I will need to get a MPS file from the model. With using GAMS IDE it is easy to use an option file to get it but, it needs a licence file for large models. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, is there any way to get an MPS file using the Neos/GAMS web interface?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-09-06T20:17:21.573" Title="Get a MPS file using NEOS/GAMS web interface" Tags="|modeling|neos|gams|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1468" PostTypeId="2" ParentId="1466" CreationDate="2019-09-06T20:17:21.573" Score="6" Body="&lt;p&gt;To create a MPS file using GAMS, you have two options as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Your first option is to use the &lt;a href=&quot;https://www.gams.com/latest/docs/S_CONVERT.html&quot; rel=&quot;noreferrer&quot;&gt;CONVERT&lt;/a&gt; solver. AFAIK, this solver is not available on NEOS Server (see &lt;a href=&quot;https://neos-server.org/neos/solvers/index.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; for a list of available solvers).&lt;/li&gt;&#xA;&lt;li&gt;Your second option is to use the solver-specific options to create MPS files. For example, CPLEX has a &lt;em&gt;writemps&lt;/em&gt; option, which allows you to generate a MPS file in CPLEX format. Again, NEOS Server does not allow any output file other than solution GDX and log files. Hence, I don't think you can use this option either.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I think you have to option to overcome this situation as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First, you might find some open-source solver that supports generating MPS files as its output. Perhaps, COIN-OR can do this, but I'm not familiar with it. Others might provide more information.&lt;/li&gt;&#xA;&lt;li&gt;The second option is to write a computer code to write MPS files for your specific problem. There are various sources on the web that describe the MPS file structure. One example is available from &lt;a href=&quot;http://lpsolve.sourceforge.net/5.0/mps-format.htm&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="119" LastActivityDate="2019-09-06T20:17:21.573" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1469" PostTypeId="2" ParentId="1464" CreationDate="2019-09-07T08:49:42.123" Score="12" Body="&lt;p&gt;In general, I think Constraint Programming or Constraint Satisfaction Problems have their roots in Computer Science/Artificial Intelligence communities that may or may not overlap to some extent with the Operations Research communities. According to &quot;&lt;a href=&quot;http://aima.cs.berkeley.edu/&quot; rel=&quot;noreferrer&quot;&gt;Artificial Intelligence, A Modern Approach&lt;/a&gt;&quot; by Stuart Russel and Peter Norvig, an early example within computer of a specific constraint satisfaction problem was &lt;a href=&quot;https://en.wikipedia.org/wiki/Sketchpad&quot; rel=&quot;noreferrer&quot;&gt;Sketchpad&lt;/a&gt;. That book furthermore notes that the idea that CSP's can be generalized came from a &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/0020025574900085v&quot; rel=&quot;noreferrer&quot;&gt;1974 paper by Ugo Montanari&lt;/a&gt; in the journal Information Sciences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Linear programming was developed earlier, mostly by mathematicians, as pure Computer Scientists did not even exist back then. &lt;a href=&quot;https://en.wikipedia.org/wiki/George_Dantzig#Linear_programming&quot; rel=&quot;noreferrer&quot;&gt;Wikipedia mentions contributions&lt;/a&gt; from Kantovorich in 1939, and from Dantzig and Von Neumann in 1947.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both approaches are quite different. Linear programming basically solves systems of linear equations. With this approach, it is typically difficult to obtain integral solutions, since in general we only know how to solve continuous problems efficiently. &#xA;However, it is usually quite efficient to find optimal solutions for such continuous problems, and if we are lucky, those solutions are (close to some) integral solutions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Constraint Programming, you can imagine your variables to be nodes in a network with a discrete set of possible values, and the constraints as links between two or more variables/nodes. It performs a &quot;clever&quot; brute force technique: you can pick a constraint, and see if the sets of possible values in the variables affected by the constraint are compatible. For example, if for a variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; we have &lt;span class=&quot;math-container&quot;&gt;$\{1,2,3\}$&lt;/span&gt; as possible options, and for variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; we have &lt;span class=&quot;math-container&quot;&gt;$\{2,3,4\}$&lt;/span&gt; as possible options, the constraint &lt;span class=&quot;math-container&quot;&gt;$x+y\leq 4$&lt;/span&gt; can be used to determine that &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; can never become &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;, so it can be safely removed from &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;'s set of possible values. It performs guessing (what happens if I assume &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; should be &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;?), backtracking and repeatedly using constraints to update the possible values of each variable (this is called constraint propagation). It aims to search for a &lt;strong&gt;feasible&lt;/strong&gt; solution that satisfies all constraints, not necessarily an optimal one. If it turns out one of the sets of potential values for a variable becomes empty, it is clear you need to backtrack. The advantage of this approach is that you do not need all your constraints to be linear. In fact, as long as a constraint can be efficiently used to prune possible values from the variables it affects, it can get as crazy as you want, and this is why Constraint Programming typically offers greater modeling flexibility compared to linear programming. The downside is, however, that it is very hard to deal with continuous variables in a basic setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the IBM ILOG CP Solver has many advanced features that seem to combine ideas from Constraint Programming and Linear Optimization, as it does allow optimization and, I believe, continuous variables.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastEditorUserId="36" LastEditDate="2019-09-07T15:31:15.940" LastActivityDate="2019-09-07T15:31:15.940" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1470" PostTypeId="1" CreationDate="2019-09-07T16:23:27.367" Score="12" ViewCount="802" Body="&lt;p&gt;I have read/heard quite a few time that in the old days, it was considered that linear programs constitute the class of optimization problems that can be solved efficiently in practice (as a rule of thumb) and that nowadays it's not that way anymore, that nowadays the class of efficiently solvable problems are the convex programs (again, as a rule of thumb).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, according to the cited paper&lt;sup&gt;1&lt;/sup&gt;, one can convexify strictly quasiconvex programs. Then for what reason do people say that &lt;em&gt;it is &quot;convex problems&quot; not &quot;strictly quasiconvex&quot;, that we can solve&lt;/em&gt;. Aren't those the same while we can transform one to another using convexification?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;[1] Gerencsér, L. &lt;a href=&quot;https://www.tandfonline.com/doi/abs/10.1080/02331887308801122&quot; rel=&quot;noreferrer&quot;&gt;On a close relation between quasi-convex and convex functions and related investigations.&lt;/a&gt; &lt;em&gt;Statistics: A Journal of Theoretical and Applied Statistics.&lt;/em&gt; 4.3 (1973): 201-211.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="1282" LastEditorUserId="123" LastEditDate="2019-09-08T12:08:32.687" LastActivityDate="2019-09-12T21:26:03.937" Title="Convex vs Strictly Quasiconvex Functions in Optimization" Tags="|convexity|nonconvex-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1471" PostTypeId="5" CreationDate="2019-09-07T23:31:46.800" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-09-07T23:31:46.800" LastActivityDate="2019-09-07T23:31:46.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1472" PostTypeId="4" CreationDate="2019-09-07T23:31:46.800" Score="0" Body="Questions about the Windows operating system version of OR software." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-09-07T23:53:18.490" LastActivityDate="2019-09-07T23:53:18.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1473" PostTypeId="2" ParentId="1464" CreationDate="2019-09-08T01:04:00.347" Score="6" Body="&lt;p&gt;From a &lt;a href=&quot;https://or.stackexchange.com/questions/1464/to-which-area-does-constraint-programming-belong#comment2362_1464&quot;&gt;comment&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... the main question is &quot;how to classify CP within the hierarchy of OR and optimization&quot;. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There's a useful graphic on IBM's webpage: &quot;IT Best Kept Secret Is Optimization - &lt;a href=&quot;https://www.ibm.com/developerworks/community/blogs/jfp/entry/constraint_programming_history?lang=en&quot; rel=&quot;noreferrer&quot;&gt;Constraint Programming History&lt;/a&gt;&quot; (Jan 21 2014), by Jean Francois Puget:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Paul Shaw and I were invited by John Poppelaars to give talks at the Back to School seminar of Dutch ORMS society. Part of our presentation was a brief history of constraint programming.  We drafted this slide to summarize it:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/w17wq.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/w17wq.png&quot; alt=&quot;Constraint Programming History Chart&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;... Its abstract is reproduced below, and the slides are available &lt;a href=&quot;https://www.ibm.com/developerworks/community/wikis/form/api/wiki/de368162-e90b-432c-a4e9-795cc51440dd/page/3603e312-bd20-4280-8011-60bbc26f8280/attachment/1fcb5c85-3641-4dc7-af92-0c9dfbc80c77/media/DutchORCPBackground.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; (requires IBMid) [alternative source &quot;&lt;a href=&quot;http://www.lnmb.nl/conferences/2014/programlnmbconference/Shaw-1.pdf&quot; rel=&quot;noreferrer&quot;&gt;Constraint Programming Background and History - LNMB&lt;/a&gt;&quot; (.PDF) 35 pages].&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Background and Theory of Constraint Programming&lt;/strong&gt;&lt;br&gt;&#xA;  Jean-François Puget and Paul Shaw&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This talk will review the principles and the historical roots of constraint programming (CP). Indeed, understanding the history behind this field helps understand the basic principles it is built on. CP can be traced back to a combination of Artificial Intelligence, Combinatorics (graph algorithms), and programming language design. It took two decades to unify these in a comprehensive and versatile framework shared by all modern CP tools and solvers. We'll review this framework and how it is implemented in recent tools. Last we will relate it and contrast it with mathematical programming.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The webpage link contains some additional unrelated (to the question) but interesting information. The blog: &quot;&lt;a href=&quot;https://optimiser.com/optimization-engines-make-the-industry-efficient/&quot; rel=&quot;noreferrer&quot;&gt;Optimization Engines Make The Industry Efficient&lt;/a&gt;&quot; (Aug 28 2018), by Diego explains the earliest history of CP:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In 1997 the Parrot project started with ILOG, Carmen Systems, Lufthansa and Olympic Airways.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The objective of the PARROT project is to provide efficient means to address the highly complex and costly problem of airline crew scheduling […] developing on promising results in the combination of Operations Research (OR) techniques and Constraint Programming (CP).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&quot;I like to describe early Constraint Programming toolkits as “systems that help you write backtracking heuristics”&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Prolog (Colmerauer, 1972) was a programming language that included an backtracking mechanism in its core&lt;/li&gt;&#xA;  &lt;li&gt;Alice (Laurière) 1976 was a “modern” constraint programming engine where you described your problem with equations and it would find the optimal solution for you&lt;/li&gt;&#xA;  &lt;li&gt;CHIP (Dincbas 1988) was an early commercial system based on Prolog&lt;/li&gt;&#xA;  &lt;li&gt;ILOG Solver (Puget 1994) was the first successful commercial system in C++ but was harder to use than a MIP engine&quot;.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Parrot Project: &quot;&lt;a href=&quot;https://www.researchgate.net/publication/220462132_Crew_Assignment_via_Constraint_Programming_Integrating_Column_Generation_and_Heuristic_Tree_Search&quot; rel=&quot;noreferrer&quot;&gt;Crew Assignment via Constraint Programming: Integrating Column Generation and Heuristic Tree Search&lt;/a&gt;&quot;, in Annals of Operations Research 115(1):207-225, September 2002:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;We developed two different algorithms to tackle the large scale optimization problem;of Airline Crew Assignment. The ﬁrst is an application of the Constraint Programming (CP) based Column Generation Framework. The second approach performs a CP based heuristic tree search. We present how both algorithms can be coupled to overcome their inherent weaknesses by integrating methods from&#xA;  Constraint Programming and Operations Research.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-09-08T01:04:00.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1474" PostTypeId="2" ParentId="1470" CreationDate="2019-09-08T02:43:06.183" Score="10" Body="&lt;p&gt;Even though I consider &quot;convex is easy&quot; to be a good rule of thumb, there are some important details to consider. Maybe surprisingly:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Convex programming is NP-hard in general&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1007/s10107-008-0223-z&quot; rel=&quot;noreferrer&quot;&gt;In this paper&lt;/a&gt;, Samuel Burer shows that every mixed integer quadratic program is equivalent to some convex program that is not significantly bigger. Because mixed integer programming is NP-hard, it must be that convex programming is also NP-hard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Burer is able to obtain this result by adding a constraint of the form &lt;span class=&quot;math-container&quot;&gt;$X \in C^*_q$&lt;/span&gt;, for some matrix &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; of variables. Here &lt;span class=&quot;math-container&quot;&gt;$C^*_q$&lt;/span&gt; is the cone of &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; &lt;a href=&quot;http://mathworld.wolfram.com/CompletelyPositiveMatrix.html&quot; rel=&quot;noreferrer&quot;&gt;completely positive matrices&lt;/a&gt;, defined as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$C^*_q = \left\{ X \in \mathbb{R}^{q \times q} : X = ZZ^\top \textrm{ for some } Z \in \mathbb{R}_{\ge 0}^{q\times r} \textrm{ for some finite } r \right\}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only two details about this definition are relevant here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The set &lt;span class=&quot;math-container&quot;&gt;$C^*_q$&lt;/span&gt; is convex.&lt;/li&gt;&#xA;&lt;li&gt;Checking if a given matrix &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is an element of &lt;span class=&quot;math-container&quot;&gt;$C^*_q$&lt;/span&gt; is NP-hard.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The ellipsoid method can be used as a theoretical tool to prove that various convex programs are easy to solve. I gave an intuitive explanation of this algorithm &lt;a href=&quot;https://or.stackexchange.com/a/1425/145&quot;&gt;in another answer&lt;/a&gt;. In this case, the ellipsoid method is not efficient, because we cannot efficiently check if the current point is feasible due to point 2. Or as I phrase it in the other question: it will be difficult to throw away the 'bad side' of the ellipsoid in each iteration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Formally we say that for the problem above, we do not have a &lt;em&gt;polynomial-time separation oracle&lt;/em&gt; (unless P = NP). A separation oracle is an algorithm that for a given point either returns that it is feasible, or returns a hyperplane that separates the point and the feasible set.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What is easy?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Some general classes for which it has been proven that they are polynomially solvable are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Linear Programs (LP)&lt;/li&gt;&#xA;&lt;li&gt;Second Order Cone Programs (SOCP)&lt;/li&gt;&#xA;&lt;li&gt;Semi-Definite Programs (SDP)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My feeling is that we are extremely good at solving LPs, very good at solving SOCPs (which include convex quadratic programs), but large scale SDPs are still relatively difficult to solve in practice (feel free to correct me). But from a complexity standpoint, all of these are easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many other convex problems that use well-known functions (like exponents, polynomials, and logarithms) are also polynomially solvable. Checking feasibility can be done by going over all individual constraints, and separating hyperplanes can be based on the gradients of the violated constraints. In practice, we have to take into account that software for more general problems is necessarily less specialized than the LP, SOCP, or SDP software, which may affect performance if you solve large scale problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We conclude that &quot;convex is easy&quot; is a reasonable rule of thumb.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Quasi-convex programs&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are various generalizations of convexity. A general class of programs for which every KKT point is a global optimum are &lt;a href=&quot;https://en.wikipedia.org/wiki/Invex_function&quot; rel=&quot;noreferrer&quot;&gt;type I invex programs&lt;/a&gt;. While definitely interesting from a theoretical viewpoint, many of these generalizations do not seem practically useful to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have yet to encounter a practical problem for which a quasi-convex program or invex program is used to solve it. One reason for this could be that modeling with these functions is surprisingly difficult! Where convex functions remain convex if you sum them, it is not true that the sum of quasi-convex functions is quasi-convex. This already complicates modeling. Invex programs are even worse: the objective and all constraints need to be invex with respect to the same function, creating a dependency among constraints.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Summary&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Convex programs are usually easy, but not always. Some more general programs are also easy to solve, but don't seem to be that useful in modeling practical problems. To me, it seems therefore unnecessary to mention them in our rule of thumb, at least for now.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Burer, S. (2009). On the copositive representation of binary and continuous nonconvex quadratic programs. &lt;em&gt;Mathematical Programming.&lt;/em&gt; 120(2):479-495. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2019-09-08T13:22:04.330" LastActivityDate="2019-09-08T13:22:04.330" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1475" PostTypeId="1" CreationDate="2019-09-08T10:44:57.860" Score="19" ViewCount="7919" Body="&lt;p&gt;This semester I will start teaching Programming in Python to Master students in Supply Chain Management.&#xA;I would like to start the first lesson with &quot;Why learning programming languages will be useful to them&quot;.&#xA;But when I search about this term in the internet using search engines like Google, Bing, Yahoo, DuckDuckGo, I do not get good answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following terms&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&quot;industrial engineering&quot; &quot;programming languages&quot;&lt;/li&gt;&#xA;&lt;li&gt;&quot;operations research&quot;  &quot;programming languages&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Interestingly, I do not see useful scientific articles or news. Only one related result is &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0927050705801999&quot; rel=&quot;noreferrer&quot;&gt;Chapter 2 Programming languages in Handbooks in Operations Research and Management Science&lt;/a&gt;. &#xA;Apart from this old chapter from 1992, other results, for me at least, are not useful.&#xA;Then come my questions.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Are programming languages is necessary for operations research practitioner?&lt;/li&gt;&#xA;&lt;li&gt;If programming languages are not necessary, then are they at least useful for operations research practitioner?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="235" LastEditorUserId="123" LastEditDate="2019-09-08T12:06:46.770" LastActivityDate="2019-09-26T17:03:59.740" Title="Are programming languages necessary/useful for operations research practitioner?" Tags="|applications|software|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1476" PostTypeId="1" AcceptedAnswerId="1501" CreationDate="2019-09-08T11:15:58.870" Score="11" ViewCount="2267" Body="&lt;p&gt;Consider the following mixed-integer set:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;P(A, b ; S) \stackrel{\text { def }}{=}\left\{x \in \mathbb{R}^{n} : A x \leq b, x_{j} \in \mathbb{Z} \text { for } j \in S\right\}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a real &lt;span class=&quot;math-container&quot;&gt;$m \times n$&lt;/span&gt; matrix &lt;span class=&quot;math-container&quot;&gt;$, b \in \mathbb{R}^{m}, S \subseteq\{1, \ldots, n\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A valid inequality (in an LP/MIP) is defined as an inequality that is valid for some set if all points from this set satisfy this inequality. Let the inequalities &lt;span class=&quot;math-container&quot;&gt;$a^\top x \leq u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha^\top x \leq v$&lt;/span&gt; hold for all points in &lt;span class=&quot;math-container&quot;&gt;$P(A, b ; S)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is said that the inequality &lt;span class=&quot;math-container&quot;&gt;$a^\top x \leq u$&lt;/span&gt; is stronger than the inequality &lt;span class=&quot;math-container&quot;&gt;$\alpha^\top x \leq v$&lt;/span&gt; (or the inequality &lt;span class=&quot;math-container&quot;&gt;$a^\top x \leq u$&lt;/span&gt; dominates the inequality &lt;span class=&quot;math-container&quot;&gt;$\alpha^\top x \leq v$&lt;/span&gt;) if&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;P(A, b) \cap H_{ \leq}(a, u) \subset P(A, b) \cap H_{ \leq}(\alpha, v).&#xA;$$&lt;/span&gt;&#xA;AFAIK, valid inequalities appear in the cutting planes method (please, correct me if I'm wrong). Indeed, many optimization models have their own definition such that sets, data and constraints have been interpreted with regards to the real limitations of the problem (for instance, in many cases a capacity constraint is written as &lt;span class=&quot;math-container&quot;&gt;$A x \leq b$&lt;/span&gt; and it seems that it works fine in the real situation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the mentioned definition, what are your thoughts on the following questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What exactly does &quot;valid inequality&quot; mean?&lt;/li&gt;&#xA;&lt;li&gt;What does &quot;Strong Inequalities&quot; mean? &lt;/li&gt;&#xA;&lt;li&gt;How can we find them in our optimization model or replace the constraints of the model with whose valid?&lt;/li&gt;&#xA;&lt;li&gt;How can I figure out whether one inequality is stronger than other (especially in the scheduling models)?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2019-09-20T18:02:42.043" LastActivityDate="2019-09-20T18:07:03.253" Title="Valid Inequalities and Strong Inequalities" Tags="|mixed-integer-programming|optimization|modeling|valid-inequalities|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1477" PostTypeId="2" ParentId="1475" CreationDate="2019-09-08T11:23:22.037" Score="19" Body="&lt;p&gt;In my opinion, programming languages are necessary as an OR practitioner. There are a number of reasons for this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Data Input/Output often requires some programming language. Whether it’s reading in data from an excel spreadsheet, or an SQL database or what have you, you will want to do this programmatically using Python etc.&lt;/li&gt;&#xA;&lt;li&gt;Many companies do not have GAMS, CPLEX Optimization Studio or similar, so a practitioner is basically forced to use a general programming language.&lt;/li&gt;&#xA;&lt;li&gt;When working interdisciplinary (eg with machine learning), a general language is much easier to interface than a special modeling language&lt;/li&gt;&#xA;&lt;li&gt;In my opinion, general programming languages offer a lot of advantages (test ability, continuous integration etc) that make deployment much, much easier. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;By the way, I’d be curious to hear about how your course goes. Any way you could make the material public?&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-09-08T11:23:22.037" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1478" PostTypeId="2" ParentId="1475" CreationDate="2019-09-08T11:42:08.067" Score="6" Body="&lt;p&gt;Some optimization software/frameworks (commercial or open-source) such as AMPL, GAMS, Cplex, ... have a specific Algebraic modelling language. Some of them have another type of programming that uses APIs to connect with general programming languages ​​like C ++ / Java or others. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK, Algebraic modelling language is a bit easier than general programming to write optimization models. Indeed, you would also see &lt;a href=&quot;https://or.stackexchange.com/questions/1366/comparison-of-algebraic-modelling-languages-and-general-programming-languages&quot;&gt;this&lt;/a&gt; or &lt;a href=&quot;https://or.stackexchange.com/questions/1442/case-studies-and-real-problems-for-teaching-optimization-and-modelling&quot;&gt;this&lt;/a&gt; posts.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-09-08T11:42:08.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1479" PostTypeId="2" ParentId="1475" CreationDate="2019-09-08T11:48:06.477" Score="28" Body="&lt;p&gt;To go beyond prototyping a model, you will need a programming language.&#xA;Here is a non-exhaustive list :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Sometimes simply modeling and calling the solver won't suffice to handle complex problems. To develop custom algorithms, heuristics, etc you will need to learn a programming language. Python is a good choice for fast prototyping and C/C++ for developing fast algorithms.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To deal with end-users and to build useful end-to-end products, you will need to build a GUI, have some database knowledge, etc. Here I would say that even some web programming/scripting languages (e.g. Javascript) are useful since a lot of the applications are web-based and host on the cloud. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Python programming is a good way to mix OR methods with data analytics and machine learning.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Programming knowledge and learning how write elegant code is crucial to work with a team of software engineers/data scientists etc who are developing end-to-end apps or integrating OR methods with data analytics etc. Those people don't know about specific modeling languages.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Finally, I think one needs also to learn the best practices such as version control, documentation, unit testing, etc.&lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="-1" LastEditDate="2019-09-10T18:18:26.353" LastActivityDate="2019-09-10T18:18:26.353" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1480" PostTypeId="1" AcceptedAnswerId="1482" CreationDate="2019-09-08T11:54:09.093" Score="14" ViewCount="590" Body="&lt;p&gt;I am looking for educational programmes which can be conducted online, such as&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;full MSc., degree certificates, &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;postgraduate courses/modules, &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;MOOCs.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Topics I am looking for are on advanced optimization such as &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;column generation, &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;(meta)heuristics, &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;reinforcement learning. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any recommendations? Feel free to share experiences!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Longer background: I have an MSc. in Engineering during which I focussed on optimization methods (MILP, heuristics, queuing models etc.) in a specific sector. At my work, I get the freedom to develop myself further into the field with the goal of being able to develop (prototype) tooling for decision support at our clients. &lt;/p&gt;&#xA;" OwnerUserId="954" LastEditorUserId="123" LastEditDate="2019-09-08T12:14:21.760" LastActivityDate="2019-10-29T16:27:06.197" Title="Online Education for OR and Developing Decision Support Systems" Tags="|optimization|online-resources|column-generation|metaheuristics|reinforcement-learning|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1481" PostTypeId="2" ParentId="1480" CreationDate="2019-09-08T13:45:08.240" Score="6" Body="&lt;p&gt;For heuristics you can take a look at this &lt;a href=&quot;https://homes.di.unimi.it/righini/Didattica/AlgoritmiEuristici/MaterialeAE/MaterialeAE.htm&quot; rel=&quot;noreferrer&quot;&gt;course&lt;/a&gt;. Also the book &quot;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/3540224947&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to solve it : Modern heuristics&lt;/a&gt;&quot; by Zbigniew Michalewicz and David B. Fogel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reinforcement Learning has similiarities with approximate dynamic programming, these &lt;a href=&quot;https://www.youtube.com/watch?v=6CaUxbFX8Oc&amp;amp;list=PLiCLbsFQNFAxOmVeqPhI5er1LGf2-L9I4&quot; rel=&quot;noreferrer&quot;&gt;video lectures&lt;/a&gt; by D. P. Bertsekas may be useful.&lt;/p&gt;&#xA;" OwnerUserId="858" LastActivityDate="2019-09-08T13:45:08.240" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1482" PostTypeId="2" ParentId="1480" CreationDate="2019-09-08T14:56:55.310" Score="11" Body="&lt;p&gt;Check Coursera, edX, Udemy, or any other online courses (such as those of Stanford). For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Free: &lt;a href=&quot;https://www.coursera.org/learn/discrete-optimization&quot; rel=&quot;noreferrer&quot;&gt;Discrete Optimization&lt;/a&gt; course on Coursera, covers column generation and an introduction to (meta)heuristic&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.udemy.com/optimization-with-metaheuristics/&quot; rel=&quot;noreferrer&quot;&gt;Optimization with Metaheuristics in Python&lt;/a&gt; on Udemy&lt;/li&gt;&#xA;&lt;li&gt;Lectures of &lt;a href=&quot;https://www.u-aizu.ac.jp/~qf-zhao/TEACHING/MH/mh.html&quot; rel=&quot;noreferrer&quot;&gt;Introduction to Meta-heuristics&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.udemy.com/course/artificial-intelligence-reinforcement-learning-in-python/&quot; rel=&quot;noreferrer&quot;&gt;Artificial Intelligence: Reinforcement Learning in Python&lt;/a&gt; and &lt;a href=&quot;https://www.udemy.com/deep-reinforcement-learning-in-python/&quot; rel=&quot;noreferrer&quot;&gt;Advanced AI: Deep Reinforcement Learning in Python&lt;/a&gt; are intermediate and advanced courses on Udemy (by the same instructor.)&lt;/li&gt;&#xA;&lt;li&gt;Also, check the great answers already provided in other questions on the site. For example, &lt;a href=&quot;https://or.stackexchange.com/questions/971/good-resources-for-solving-techniques-metaheuristics-milp-cp-etc&quot;&gt;Good resources for solving techniques (Metaheuristics, MILP, CP etc)&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/questions/1323/linear-and-integer-programming-materials/1325#1325&quot;&gt;Linear and Integer programming materials&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-09-08T14:56:55.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1483" PostTypeId="2" ParentId="1480" CreationDate="2019-09-08T18:30:36.563" Score="5" Body="&lt;h3&gt;Institute of Applied Optimization&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://iao.hfuu.edu.cn/teaching/lectures/metaheuristic-optimization&quot; rel=&quot;noreferrer&quot;&gt;Metaheuristic Optimization&lt;/a&gt; - prerequisite: Java programming&lt;/p&gt;&#xA;&lt;h3&gt;Coursera&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.coursera.org/learn/practical-rl&quot; rel=&quot;noreferrer&quot;&gt;Practical Reinforcement Learning&lt;/a&gt; - &lt;a href=&quot;https://or.stackexchange.com/questions/831/suggestion-of-some-courses-in-sequential-decision-making&quot;&gt;related&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-09-08T18:30:36.563" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1484" PostTypeId="2" ParentId="1475" CreationDate="2019-09-08T18:39:09.790" Score="9" Body="&lt;p&gt;Agree with all the mentioned great answers, I also think general programming languages are necessary for the OR practitioners and would like to add the following points:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Applications:&lt;/strong&gt; Beside the theoretical advancement of OR techniques and concepts in academia, there is another parallel and strong branch of OR, namely &lt;em&gt;application of the OR in real-world problems&lt;/em&gt;. Those problems are usually complicated and managing all the necessary data and details needs lots of variables and constraints which are interconnected by different logics among them. Although some of the algebraic languages are able to deal with these type of constraints, most of the time it is easier to use general programming languages to tackle big problems. Moreover, sometimes you need to compare and validate your results with the outputs of specific software in the field of application. Those software usually need predefined format for the inputs and even you need the output of software as your model's input. These connections can be easily made by using a general programming language. As an example: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;AMPL &lt;span class=&quot;math-container&quot;&gt;$\longleftrightarrow$&lt;/span&gt; Matlab &lt;span class=&quot;math-container&quot;&gt;$\longleftrightarrow$&lt;/span&gt; Abaqus(as software for structural analysis). &lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Theory:&lt;/strong&gt; Looking at the huge literature of the proposed &lt;a href=&quot;https://github.com/fcampelo/EC-Bestiary&quot; rel=&quot;noreferrer&quot;&gt;metaheuristic&lt;/a&gt; approaches, one can easily see the necessity of those approaches. AFAIK, using algebraic languages to code those algorithms are nearly impossible or tediously sophisticated.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-09-08T18:39:09.790" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1485" PostTypeId="2" ParentId="1475" CreationDate="2019-09-08T20:37:36.653" Score="12" Body="&lt;p&gt;There are quite a few good answers here. I'll mention one more thing (related to two previously mentioned issues, building a GUI and accessing data): data cleaning. This may mean a number of things: detecting and removing errors or anomalies in input data; merging observations into single parameters (averages, etc.); converting units; and my personal favorite (related to the user interface, graphical or otherwise), defending against user screw-ups. Left to their own devices, users may, for example, ask you to create six teams of exactly four people each from a pool of 22 people, with each person assigned to exactly one team. This morning, I tripped over a query asking for prediction of pavement quality on a stretch of highway of length zero. (On the positive side, at least the length wasn't negative.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some modeling packages include provisions for user interfaces, and some may have the capability to let you do sanity checks on parameters and input data ... but it would be rash to assume that you will always be using such a product. So, yes, I would say some programming chops are necessary, even if only to design a prototype that professional programmers will then spruce up.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-08T20:37:36.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1486" PostTypeId="1" CreationDate="2019-09-08T20:54:19.033" Score="14" ViewCount="964" Body="&lt;p&gt;I've been learning and playing with CPLEX/Gurobi for a year using C++/Python API. I know some basic stuff like writing a model, callbacks, basic playing with solvers' parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am wondering what are the most important steps you recommend to learn more about those solvers. I mean the steps to go from apprenticeship to guru status. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The kind of answers I would enjoy (but feel free to suggest whatever you want ) :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Read this (e.g. tutorial, source code)&lt;/li&gt;&#xA;&lt;li&gt;Pay attention to that kind of details&lt;/li&gt;&#xA;&lt;li&gt;Learn about these concepts &lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Implement X&lt;/strong&gt; &lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Edit : I would appreciate a &lt;strong&gt;structured&lt;/strong&gt; step-by-step path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Backgrounds : B.S. in pure mathematics, M.S. student in Applied mathematics (with O.R specialization)   &lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2019-09-09T15:08:01.507" LastActivityDate="2019-09-09T20:56:10.397" Title="How to progress with CPLEX/Gurobi" Tags="|solver|reference-request|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1487" PostTypeId="2" ParentId="1486" CreationDate="2019-09-08T21:17:08.927" Score="7" Body="&lt;p&gt;I recommend you read the Gurobi Documentation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gurobi.com/wp-content/plugins/hd_documentations/content/pdf/quickstart_linux_8.1.pdf&quot; rel=&quot;noreferrer&quot;&gt;Quick Start&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gurobi.com/wp-content/plugins/hd_documentations/content/pdf/example_tour.pdf&quot; rel=&quot;noreferrer&quot;&gt;Example Tour&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gurobi.com/wp-content/plugins/hd_documentations/content/pdf/reference_manual.pdf&quot; rel=&quot;noreferrer&quot;&gt;Reference&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;the Gurobi Documentation is better than Cplex Documentation and their classes, functions, ... are similar. Besides that, check some codes using Cplex in a git-hub repository.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good question to learn more is &quot;how to stop the solver when your model finding the first feasible solution. To clarify, you need to stop your program or return an integer solution found when the column of the Cplex-log named Best Integer to stop being empty&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;hint: CPX_PARAM_INTSOLLIM&lt;/p&gt;&#xA;" OwnerUserId="1252" LastEditorUserId="1252" LastEditDate="2019-09-08T23:00:09.663" LastActivityDate="2019-09-08T23:00:09.663" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1488" PostTypeId="2" ParentId="1486" CreationDate="2019-09-08T21:18:07.200" Score="7" Body="&lt;p&gt;Solvers like CPLEX and Gurobi usually use the pre-solve steps to simplify the modeled problem. Actually, the aim of pre-solving step is, to eliminate fixed variables, remove redundant constraints, remove linear dependencies, substitute out (implied) free variables, and reduce the size of the optimization problem in general. As a guru user, you may focus on the implementation of those steps and compare the results(in terms of solution time and complexity) with/without those options. In the pre-solve steps, on the other hand, those solvers use some heuristics to modify the solution space which comes out of a black box without any details. Focusing on the implementation of those heuristics may help you understand and even design more effective approaches.   &lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-09-08T21:18:07.200" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1489" PostTypeId="2" ParentId="1486" CreationDate="2019-09-09T02:59:32.120" Score="16" Body="&lt;p&gt;You may be interest in the blog by @prubin, which has many interesting CPLEX posts: &lt;a href=&quot;http://orinanobworld.blogspot.com&quot; rel=&quot;noreferrer&quot;&gt;OR in an OB World&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the best way to become better at using solvers, is by actually using them in your own projects. An interesting project could be to solve a problem with Benders decomposition, or with multithreaded callbacks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://orinanobworld.blogspot.com/2017/11/benders-decomposition-with-generic.html&quot; rel=&quot;noreferrer&quot;&gt;This blog post&lt;/a&gt; from the above-mentioned blog is about Benders decomposition, and can serve as a starting point.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-09-09T02:59:32.120" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1490" PostTypeId="2" ParentId="1464" CreationDate="2019-09-09T08:20:39.010" Score="8" Body="&lt;p&gt;Regarding your question “The question is now to what kind of field of operations research CP belongs”, I will say that CP is not a subfield of operations research, but it is another field, closely related to OR, but it is another field.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really like to understand the fundamental of Constraint (Logic) Programming, you should read the paper &lt;em&gt;&lt;a href=&quot;https://dl.acm.org/citation.cfm?doid=242224.242304&quot; rel=&quot;noreferrer&quot;&gt;In Pursuit of the Holy Grail&lt;/a&gt;&lt;/em&gt; by Eugene C. Freuder, where in the abstract he writes:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Constraint programming represents one of the closest approaches computer science has yet made to the Holy Grail of programming: the user states the problem, the computer solves it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The main focus of CP is not on a specific single problem or a single class of problems, but it is the design of a very general declarative computer language that would permit to solve any problem that can be stated using that computer language, regardless of the techniques used inside the solver. For instances, the plot reported by @Rob presents several different computer languages for different CP solvers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is quite different from a mathematical programming approach, were the focus is on the problem you must (efficiently) solve. A mathematician would study the mathematical properties of the problem of interest, and then, she would try to exploit as much as possible the mathematical structure of the given problem to design an efficient solution algorithm (e.g., Linear Programming relies on the strong duality theorem).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once say that, indeed, if you look at the programming techniques used internally by CP and/or MP solvers, there is a growing intersection of methods, and several researchers are trying to unify the two worlds. Just to mention two seminal references, you can look at:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Looking at OR from CP&lt;/strong&gt;: &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/book/10.1002/9781118033036&quot; rel=&quot;noreferrer&quot;&gt;Logic-based Methods for Optimization&lt;/a&gt;, by John Hooker. &lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Looking at CP from OR&lt;/strong&gt;: &lt;a href=&quot;https://opus4.kobv.de/opus4-zib/frontdoor/index/index/docId/1112&quot; rel=&quot;noreferrer&quot;&gt;Constraint Integer Programming&lt;/a&gt;, by Tobias Achterberg.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Finally, for looking deeper at the interplay between CP and OR, I would suggest to explore the proceeding of the &lt;a href=&quot;https://cpaior.org/&quot; rel=&quot;noreferrer&quot;&gt;CPAIOR Conference Series&lt;/a&gt;, where you can find several papers related to scheduling problems close to yours.&lt;/p&gt;&#xA;" OwnerUserId="171" LastActivityDate="2019-09-09T08:20:39.010" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1491" PostTypeId="1" CreationDate="2019-09-09T10:15:21.910" Score="12" ViewCount="1269" Body="&lt;p&gt;Suppose that an airline company has X planes, in general the companies keep a number of these aircraft (say 80% of X) in reserve in case of hazards. My question is how the airline companies compute the number of aircraft to operate and the ones to keep in reserve?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot find any papers written about this problem on the literature.&lt;/p&gt;&#xA;" OwnerUserId="1294" LastEditorUserId="123" LastEditDate="2019-09-09T10:43:26.667" LastActivityDate="2019-09-10T19:53:04.197" Title="Number of aircraft to operate in an airline company" Tags="|modeling|reference-request|scheduling|markov-decision-process|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1492" PostTypeId="2" ParentId="1491" CreationDate="2019-09-09T14:25:39.490" Score="12" Body="&lt;p&gt;In &lt;a href=&quot;https://www.icao.int/MID/Documents/2017/Aviation%20Data%20and%20Analysis%20Seminar/PPT4%20-%20Fleet%20Planning.pdf&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; document the airline fleet decision process has been categorized in the following bullets:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Forecast of expected traffic demand (RPK)&lt;/li&gt;&#xA;&lt;li&gt;Planning average load factor (%)&lt;/li&gt;&#xA;&lt;li&gt;ASK needed to be generated to meet the traffic demand&lt;/li&gt;&#xA;&lt;li&gt;The productivity of the aircraft (ASK per day) results in the number of aircraft to be acquired and its financial impact (Costs)&lt;/li&gt;&#xA;&lt;li&gt;Merging revenue estimates with costs results in different margin scenarios for aircraft types being considered&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;which in turn has the following main drivers:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Traffic forecasts&lt;/li&gt;&#xA;&lt;li&gt;Yield forecasts&lt;/li&gt;&#xA;&lt;li&gt;Operating costs estimation&lt;/li&gt;&#xA;&lt;li&gt;Estimated aircraft productivity&lt;/li&gt;&#xA;&lt;li&gt;Holistic drivers feed the decision process system&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In addition to the mentioned document, you can also find the following papers that discuss the different aspects of the fleet planning problem:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Airline schedule planning: Integrated models and algorithms for schedule design and fleet assignment [p1].&lt;/li&gt;&#xA;&lt;li&gt;Robust optimization for fleet planning under uncertainty [p2].&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;[p1]: Lohatepanont, Manoj, and Cynthia Barnhart. &quot;Airline schedule planning: Integrated models and algorithms for schedule design and fleet assignment.&quot; Transportation Science 38.1 (2004): 19-32.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[p2]: List, George F., et al. &quot;Robust optimization for fleet planning under uncertainty.&quot; Transportation Research Part E: Logistics and Transportation Review 39.3 (2003): 209-227.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-09-09T14:25:39.490" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1493" PostTypeId="1" AcceptedAnswerId="2581" CreationDate="2019-09-09T15:50:29.417" Score="8" ViewCount="434" Body="&lt;p&gt;I have the following multiobjective optimization problem. The objectives are non-conflicting.&lt;/p&gt;&#xA;&lt;h2&gt;The Optimization Problem:&lt;/h2&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\underset{\large{a^{(l)}_{c,u},f^{(l)}_{c,u},z_{l,t},l\in\mathcal{L}}}{\max}\hspace{6mm}\left\{t^{(l)}_{\rm U},l=1,2,\cdots,N_{\rm L},t_{\rm L}\right\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since there is no preference (all the objectives have the same priority), I tried with the following objective.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\underset{\large{a^{(l)}_{c,u},f^{(l)}_{c,u},z_{l,t},l\in\mathcal{L}}}{\max}\hspace{6mm}\left\{\sum_{l=1}^{N_L}t^{(l)}_{\rm U}+t_{\rm L}\right\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am not sure if I am doing it right.&lt;/p&gt;&#xA;&lt;p&gt;Is the single objective that I am using correct?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-09-19T07:43:55.700" Title="How to resolve this issue in multi-objective optimization?" Tags="|mixed-integer-programming|optimization|linear-programming|multi-objective-optimization|disciplined-convex-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1494" PostTypeId="2" ParentId="1475" CreationDate="2019-09-09T16:11:06.347" Score="7" Body="&lt;p&gt;While the other answers are solid, to directly answer your stated questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;strong&gt;2&lt;/strong&gt;) Very broadly, I believe understanding how to program will help your students better understand and compare processes which involve software (which I hear is quite popular these days).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;strong&gt;2&lt;/strong&gt;) OR students specifically will be more prepared to do modeling and simulation with a little programming experience.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(&lt;strong&gt;1&lt;/strong&gt;) To go further, I believe &lt;em&gt;anyone&lt;/em&gt; in science will be at at major disadvantage in the industry if they are not just familiar with, but comfortable with a programming language to get at the vast quantity of readily-available and powerful solving libraries, &lt;em&gt;which their peers will be taking advantage of&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some validation, I did my undergrad in industrial engineering, but moved into software and now work at a logistics firm.&lt;/p&gt;&#xA;" OwnerUserId="1300" LastActivityDate="2019-09-09T16:11:06.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1495" PostTypeId="2" ParentId="1491" CreationDate="2019-09-09T20:48:31.600" Score="8" Body="&lt;p&gt;The reason you're not finding anything about this in the literature is that airlines do everything they can to avoid having airplanes in reserve: an airplane on the ground is an airplane that's losing money.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An airline will determine the fleet size needed to serve the anticipated demand (see Oguz's answer for literature on how they do this), and will cover isolated problems (eg. an airplane with an engine that won't start) by deferring scheduled maintenance, by dispatching aircraft that have minor problems (eg. the backup compass isn't working), or by rebooking passengers on alternate flights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://aviation.stackexchange.com/q/56957/1677&quot;&gt;this question and answers on Aviation SE&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="89" LastActivityDate="2019-09-09T20:48:31.600" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1496" PostTypeId="2" ParentId="1486" CreationDate="2019-09-09T20:56:10.397" Score="6" Body="&lt;p&gt;There's an old joke (popular at least in New York, back in the day). Newly arrived tourist to local: &quot;How do I get to &lt;a href=&quot;https://www.carnegiehall.org/&quot; rel=&quot;noreferrer&quot;&gt;Carnegie Hall&lt;/a&gt;?&quot; Local to tourist: &quot;Practice, practice, practice.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't say how to reach guru status, not having gotten there myself. I suspect it involves working for the tech team that produces one of the solvers. To get to what I might call &quot;power user&quot; status, you need to use the solver repeatedly, starting with easy to formulate models and progressing to models that involve advanced techniques (decomposition, column generation, mysterious oracles, ...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things that have helped me get where I am today vis-a-vis CPLEX, in no particular order, are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using it ... a lot.&lt;/li&gt;&#xA;&lt;li&gt;Using it with a programming API. APIs require you to attend to details from which modeling languages (such as OPL, MPL, AMPL, GAMS etc.) might shield you. I personally don't think you need experience with more than one API, although it certainly does not hurt. When programming, if something in the API documentation seems unclear or unexpected, take some time to chase it down and see if there is a (possibly hidden) reason why it is the way it is.&lt;/li&gt;&#xA;&lt;li&gt;Monitoring the relevant help forums. (I subscribe to the CPLEX forums via RSS feed.) Not only can you get your own questions answered, but you can learn tidbits about the internals from seeing the answers to other peoples' questions ... plus you can find out where people get confused by the solver.&lt;/li&gt;&#xA;&lt;li&gt;Watching for solver-related questions and answers on forums such as this one.&lt;/li&gt;&#xA;&lt;li&gt;Experimenting, as time permits, to see if you can figure out the answer to a question (or the source of an error message) when someone asks something not particularly mundane on one of those forums.&lt;/li&gt;&#xA;&lt;li&gt;Attending conference workshops (and occasionally presentations in technical sessions) by the vendor. IBM, Gurobi and (I think) FICO put on workshops at some conferences, including the INFORMS annual meetings.&lt;/li&gt;&#xA;&lt;li&gt;Stopping by the vendor booths at those conferences and chatting up the technical folks.&lt;/li&gt;&#xA;&lt;li&gt;Attending (or watching after the fact) vendor webinars. I know that IBM and Gurobi both have periodic free webinars on topics related to their solvers, and I'm pretty sure I've seen FICO webinars listed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm not sure that list is exhaustive, but it's all I can think of at the moment.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-09T20:56:10.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1497" PostTypeId="2" ParentId="1476" CreationDate="2019-09-09T23:06:24.627" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What exactly does &quot;valid inequality&quot; mean?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Valid Inequalities are constraints that reduce your feasible space without removing integer solutions. In other words, Valid Inequalities approximate your feasible space to the integer convex hull.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What does &quot;Strong Inequalities&quot; mean?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are many Valid Inequalities and the best of them are called Strong Valid Inequalities. In this case, there is no any Valid Inequality dominate a Strong Valid Inequality. To clarify, Strong Valid Inequality is a non-dominated Valid Inequality.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can we find them in our optimization model or replace the constraints of the model with whose valid?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For a generic MIP, my suggestion is &lt;a href=&quot;https://www.researchgate.net/publication/230872913_Outline_of_an_Algorithm_for_Integer_Solutions_to_Linear_Programs?enrichId=rgreq-c5d9427fa9965d81b19118e8bd81ea44-XXX&amp;amp;enrichSource=Y292ZXJQYWdlOzIzMDg3MjkxMztBUzoxNTI5MDUxODUyMzkwNDBAMTQxMzQ2Njg0NTgzMg%3D%3D&amp;amp;el=1_x_2&amp;amp;_esc=publicationCoverPdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gomory&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;. But you can read about cover cuts applied to the knapsack problem.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I figure out whether one inequality is stronger than other (especially in the scheduling models)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need to analyze many papers about your scheduling problem version. After that, you need to study the ideas of the main papers to ​​adapt good ideas or to take an original idea. For example, check out &lt;a href=&quot;https://www.researchgate.net/publication/220090472_Strong_valid_inequalities_for_the_resource-constrained_scheduling_problem_with_uniform_resource_requirements&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt; on Strong Valid Inequalities.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Gomory, R. (1958). Outline of an Algorithm for Integer Solutions to Linear Programs. &lt;em&gt;Bulletin of the American Mathematical Society&lt;/em&gt;. 64(5):275-278. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] Hardin, J. R., Nemhauser, G. L., Savelsbergh, M. (2008). Strong valid inequalities for the resource-constrained scheduling problem with uniform resource requirements. &lt;em&gt;Discrete Optimization&lt;/em&gt;. 5(1):19-35. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="1252" LastEditorUserId="123" LastEditDate="2019-09-20T18:07:03.253" LastActivityDate="2019-09-20T18:07:03.253" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1498" PostTypeId="1" AcceptedAnswerId="1511" CreationDate="2019-09-10T04:51:25.197" Score="14" ViewCount="439" Body="&lt;p&gt;I am interested in applying to some OR faculty positions this academic cycle and I am hoping to get a better understanding of the field. For context, I come from an (electrical) engineering background, specifically control systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Classically, it seems the problems that OR people studied (at least the ones I am most familiar with) were related to decision theory, optimization and scheduling, and queuing theory with the general sentiment that solving these problems would be of interest to a company's operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More recently, the lines between OR and other fields have gotten a bit more blurry for me. I am seeing more venues that focus on the intersection between OR, economics (game theory), and computer science. For example, see the &lt;a href=&quot;https://www.youtube.com/channel/UCFat6uPNM2KnPlm5uDZnwmQ?view_as=subscriber&quot; rel=&quot;noreferrer&quot;&gt;recent talks at EC&lt;/a&gt;. Also see a &lt;a href=&quot;https://www.informs.org/Meetings-Conferences/INFORMS-Conference-Calendar/2020-INFORMS-Security-Conference&quot; rel=&quot;noreferrer&quot;&gt;new INFORMS conference&lt;/a&gt; on the intersection of OR and security.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question(s)&lt;/strong&gt;: My main question concerns the current trajectory of the OR field and OR departments. Is the focus of OR becoming blurry or has the underlying motivation for the field changed? What's the future for OR: as problems traditionally studied under OR become more central in society, will other fields (e.g. computer science) begin to take over/cannibalize OR departments? &lt;/p&gt;&#xA;" OwnerUserId="1310" LastEditorUserId="1310" LastEditDate="2019-09-23T17:20:45.530" LastActivityDate="2019-09-23T17:20:45.530" Title="How is the field of operations research evolving?" Tags="|academia|job-market|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1499" PostTypeId="2" ParentId="1442" CreationDate="2019-09-10T07:35:14.433" Score="5" Body="&lt;p&gt;I think for business students looking at papers (for example from Interfaces) might be asking too much. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is about getting business students to use OR tools, specifically MIP solvers, I would recommend the book &quot;Model Building in Mathematical Programming&quot; by H. Paul Williams. It mostly consists of case studies from various fields and is easy enough to understand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a free PDF that has the data and code for the SAS OPTMODEL modeling language (called the Mathematical Programming Examples Book):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://support.sas.com/documentation/onlinedoc/or/151/ormpex.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://support.sas.com/documentation/onlinedoc/or/151/ormpex.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other MIP solver vendors have similar collections of example problems that might be worthwhile looking into.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2019-09-10T07:35:14.433" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1500" PostTypeId="1" AcceptedAnswerId="1502" CreationDate="2019-09-10T11:06:14.480" Score="10" ViewCount="577" Body="&lt;p&gt;I know some general concepts regarding Constraint Programming (e.g., the ones explained in &lt;a href=&quot;https://or.stackexchange.com/questions/176/what-is-the-difference-between-integer-programming-and-constraint-programming&quot;&gt;this answer&lt;/a&gt;). I am interested in learning how to formulate a combinatorial optimisation problem as a constraint programming model. What steps should be taken for developing such a formulation? What is the standard practice/convention?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the quality of LP-relaxation is an important factor for deciding the quality of an integer program. I was wondering what formulations are considered as good in constraint programming?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I appreciate if someone could give a simple example of an integer program and compares the way(s) it can be represented as a constraint program.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastEditorUserId="1202" LastEditDate="2019-09-10T11:21:21.333" LastActivityDate="2019-09-10T20:49:54.267" Title="What is the standard practice in Constraint Programming modeling?" Tags="|constraint|constraint-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1501" PostTypeId="2" ParentId="1476" CreationDate="2019-09-10T11:07:36.270" Score="5" Body="&lt;p&gt;Usually in the context of LP/MIP you make statements about the convex hull of the mixed-integer set that you defined &lt;span class=&quot;math-container&quot;&gt;$P = \text{conv}(\left\{x \in \mathbb{R}^{n} : A x \leq b, x_{j} \in \mathbb{Z} \text { for } j \in S\right\})$&lt;/span&gt;. Branch-and-bound techniques work by relaxing the integrality constraint and compute lower bounds of the problem (when you minimize). The problem is to find a compact representation of the convex hull of the feasible (mixed-)integer points. Cutting planes are valid inequalities that are valid for the convex hull of the feasible points which try to remove some part of the relaxed set &lt;span class=&quot;math-container&quot;&gt;$\tilde{P}=\left\{x \in \mathbb{R}^{n} : A x \leq b\right\}$&lt;/span&gt;. Ideally you want to have &lt;strong&gt;facet&lt;/strong&gt; defining inequalities for &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;strong&gt;face&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$F\subseteq P$&lt;/span&gt; is a subset of a polyhedron &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; if there exists a valid inequality &lt;span class=&quot;math-container&quot;&gt;$a^Tx\leq \alpha$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$F=\left\{x\in P \mid a^\top x = \alpha \right\}$&lt;/span&gt;.&lt;br&gt;&#xA;A &lt;strong&gt;facet&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is an inclusion-wise maximal face of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; (while &lt;span class=&quot;math-container&quot;&gt;$\emptyset\neq F\neq P$&lt;/span&gt;). Note that, equivalently, a facet is a nonempty face of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; with dimension &lt;span class=&quot;math-container&quot;&gt;$\text{dim}(P)-1$&lt;/span&gt;.&lt;br&gt;&#xA;Taken from &lt;a href=&quot;https://www.zib.de/groetschel/pubnew/paper/groetschellovaszschrijver1988.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Grötschel, Lovasz, Schrijver - Geometric Algorithms and Combinatorial Optimization&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What exactly does &quot;valid inequality&quot; mean?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You already give a definition which is correct. You could write a bit more mathematically that an inequality &lt;span class=&quot;math-container&quot;&gt;$a^\top x \leq $&lt;/span&gt; is valid for a polyhedron &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$P\subseteq \left\{x\in\mathbb{R}^n \mid a^\top x \leq u \right\}$&lt;/span&gt; which means that the polyhedron &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is included in the halfspace defined by the inequality.&lt;br&gt;&#xA;Note that a valid inequality does not necessarily need to cut off non-integral points. In fact a inequality can be valid for a polyhedron does not even to have a nonempty intersection between the induced hyperplane and the polyhedron.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What does &quot;Strong Inequalities&quot; mean?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Again, you already give a definition. A valid inequality is stronger than another (or dominates it) if the induced halfspace intersected with the polyhedron is included in the halfspace (intersected with the polyhedron) induced by the other one.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I've written in the introduction paragraph, facets are the inequalities that are inclusion-wise maximal. If you are able to find facets for your problem it is a very good thing as these inequalities cannot be dominated by other inequalities.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can we find them in our optimization model or replace the constraints of the model with whose valid?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are many investigations about the structure of the underlying polyhedron for different problems. Sometimes it is possible to find (and prove) facet inducing inequalities and in some cases one is even able to state the precise description of the convex hull of the (mixed-)integer points. Some examples for well-known polyhedrons are the (perfect) matching polytope, cut polytope, boolean quadric polytope and many more...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides analysis by hand (or rather brain) there exist software packages (e.g. &lt;a href=&quot;https://polymake.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;polymake&lt;/a&gt;) that can compute facets of (small instances) of polyhedrons. If you are lucky you can generalize these to make statements about the polyhedron.&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="137" LastEditDate="2019-09-10T20:30:06.083" LastActivityDate="2019-09-10T20:30:06.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1502" PostTypeId="2" ParentId="1500" CreationDate="2019-09-10T12:24:26.830" Score="8" Body="&lt;p&gt;at &lt;a href=&quot;https://www.slideshare.net/PhilippeLaborie/an-introduction-to-cp-optimizer&quot; rel=&quot;noreferrer&quot;&gt;https://www.slideshare.net/PhilippeLaborie/an-introduction-to-cp-optimizer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you may find some information about RCPSP with Linear programming and constraint programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plus &lt;a href=&quot;https://tidel.mie.utoronto.ca/pubs/JSP_CandOR_2016.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://tidel.mie.utoronto.ca/pubs/JSP_CandOR_2016.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;concludes&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Comparing the best MIP results with that of CP, results show that MIP&#xA;  performs similarly to CP for smaller problems in terms of proving&#xA;  optimality. However, CP dominates MIP for larger problems both in&#xA;  terms of proving optimality and solution quality.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Let me show how they are different and similar with OPL for jobshop :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With Linear Programming one can write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; int nbJobs = ...;&#xA;int nbMchs = ...;&#xA;&#xA;range Jobs = 0..nbJobs-1;&#xA;range Mchs = 0..nbMchs-1;&#xA;// Mchs is used both to index machines and operation position in job&#xA;&#xA;tuple Operation {&#xA;  int mch; // Machine&#xA;  int pt;  // Processing time&#xA;};&#xA;&#xA;Operation Ops[j in Jobs][m in Mchs] = ...;&#xA;&#xA;dvar int+ s[j in Jobs][o in Mchs];&#xA;dexpr int e[j in Jobs][o in Mchs]=s[j][o]+Ops[j][o].pt;&#xA;&#xA;&#xA;&#xA;minimize max(j in Jobs) e[j][nbMchs-1];&#xA;subject to {&#xA;  forall (m in Mchs,ordered i,j in Jobs, o1 in Mchs,o2 in Mchs:Ops[i][o1].mch == m &amp;amp;&amp;amp; Ops[j][o2].mch == m)&#xA;    (e[i][o1]&amp;lt;=s[j][o2]) || (e[j][o2]&amp;lt;=s[i][o1]);&#xA;  forall (j in Jobs, o in 0..nbMchs-2)&#xA;    e[j][o]&amp;lt;=s[j][o+1];&#xA;}&#xA;&#xA;execute {&#xA;  for (var j = 0; j &amp;lt;= nbJobs-1; j++) {&#xA;    for (var o = 0; o &amp;lt;= nbMchs-1; o++) {&#xA;      write(s[j][o] + &quot; &quot;);&#xA;    }&#xA;    writeln(&quot;&quot;);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;whereas with Constraint Programming you would directly write a much better &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.ide.help/examples/html/opl/sched_jobshop/sched_jobshop.mod.html&quot; rel=&quot;noreferrer&quot;&gt;model&lt;/a&gt; that is within IBM CPLEX Optimization Studio&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am an IBM employee&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2019-09-10T12:24:26.830" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1503" PostTypeId="2" ParentId="1498" CreationDate="2019-09-10T15:58:15.970" Score="8" Body="&lt;p&gt;In my opinion, OR is definitely broadening in scope, but let me try to be a bit more concrete (N.B.: all of this is my opinion, and I hope others will add their views as well):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OR is a relatively &quot;old&quot; field, with the classical problems (scheduling, traveling salesman problem etc) studied by many thousands of people. In addition, OR is a very applied field, so in many places you'll find OR solutions just running fine because they are so well established. Therefore, in the classical OR problems, the progress is mostly (but definitely not exclusively) in new variants of these problems (e.g. vehicle routing problem with time windows and fixed pick-up and drop off and uncertainty in time).&lt;/li&gt;&#xA;&lt;li&gt;This has resulted in more and more connections to machine learning and data science in general, see e.g. &lt;a href=&quot;http://web.mit.edu/jaillet/www/general/online-routing-18.pdf&quot; rel=&quot;noreferrer&quot;&gt;this recent paper&lt;/a&gt; by Bertsimas which highlights a very good example of this connection. So a new faculty in OR should definitely be ready to work interdisciplinarily to have high impact (in my opinion).&lt;/li&gt;&#xA;&lt;li&gt;The recent hype in machine learning has lead to some cannibalization &quot;attempts&quot;, where people try to solve OR problems using ML methods. This is not particularly successful though, since a shortest path problem will always be solved best by OR. ML and the like will however enable augmentation of existing algorithms (see also &lt;a href=&quot;https://arxiv.org/abs/1811.06128&quot; rel=&quot;noreferrer&quot;&gt;this review paper&lt;/a&gt;), c.f. the previous point.&lt;/li&gt;&#xA;&lt;li&gt;In my opinion, the core of OR - smart decision support systems to achieve enhanced performance - will get more and more important, because the more data etc. you have available, the more angles you can take to enhance your decision making. In my opinion, this is one of the most exciting times to be in OR because of the number of possible directions to take.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-09-10T15:58:15.970" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1504" PostTypeId="1" CreationDate="2019-09-10T18:04:11.840" Score="25" ViewCount="10070" Body="&lt;p&gt;I'm new to the OR world, and trying to learn the various tools available. I originally thought that Pyomo and Google OR tools were open source alternatives to commercial solvers like Gurobi or CPLEX. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now I'm discovering more and more that they are used more as a sort of interface to those solvers, not as an alternative to them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this the case? What purpose do these libraries serve? Gurobi for example already has a Python interface, why would I need Pyomo to interface with it? &lt;/p&gt;&#xA;" OwnerUserId="1315" LastEditorUserId="981" LastEditDate="2021-11-18T00:39:18.233" LastActivityDate="2021-11-18T00:39:18.233" Title="What is the purpose of libraries like Pyomo and Google OR tools?" Tags="|cplex|gurobi|pyomo|or-tools|modeling-languages|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1505" PostTypeId="2" ParentId="1504" CreationDate="2019-09-10T18:34:27.937" Score="22" Body="&lt;p&gt;Pyomo is an &lt;a href=&quot;https://en.wikipedia.org/wiki/Algebraic_modeling_language&quot; rel=&quot;noreferrer&quot;&gt;algebraic modeling language&lt;/a&gt; and allows users to easily represent optimization problems at a high-level (by defining variables, constraints, objective, etc.). Pyomo then provides interfaces to a variety of optimization solvers including Gurobi and CPLEX. This allows an optimization model to be formulated once and then a user can experiment with using different solvers to actually solve the problem. Pyomo also provides several modeling extensions for representing high-level modeling constructs (e.g. differential equations or disjunctions) and general implementations of transformations for converting these constructs to a form that off-the-shelf optimization solvers can solve. &lt;/p&gt;&#xA;" OwnerUserId="583" LastActivityDate="2019-09-10T18:34:27.937" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1506" PostTypeId="2" ParentId="1504" CreationDate="2019-09-10T18:49:00.350" Score="10" Body="&lt;p&gt;Different solvers have their own interfaces (for example Cplex studio by IBM). You can use the specific syntax for those IDE or interfaces to input your model and then use the solver to solve it. Although the logic behind them all is the same but those languages or syntaxes are usually differing from one solver to the other. If you need to solve your problem by using more than one solver you will need a general form of problem which can be converted to the solver specific problems. This conversion is done using some &lt;a href=&quot;https://en.wikipedia.org/wiki/Algebraic_modeling_language&quot; rel=&quot;noreferrer&quot;&gt;Algebraic Modeling Languages (AML)&lt;/a&gt;. Pyomo is an AML that extends Python to include objects for mathematical modeling. After generating your problem in Pyomo you will be able to use many solvers to solve it. Some of those are glpk(open source), CPLEX, Gurobi, BARON and many more. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use interfaces of specific solver in python you may won't have the ability to solve the same problem with other solvers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google created OR-Tools in C++, but you can also use it with Python, Java, or C#. So Pyomo and Google OR-tools are packages that can be called by python (in case of Google or: some other platforms) and are including many classes (for example &lt;em&gt;ConcreteModel()&lt;/em&gt; in Pyomo) with many attributes (for example &lt;em&gt;Objective&lt;/em&gt; in ConcreteModel class).&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-09-10T19:07:00.710" LastActivityDate="2019-09-10T19:07:00.710" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1507" PostTypeId="2" ParentId="1491" CreationDate="2019-09-10T19:51:53.313" Score="1" Body="&lt;p&gt;I think this is an interesting question from an operations research / simulation exercise. As such you could attack the question very simply to start with and then go on more and more detailed if it makes sense. Not very different really from many other OR questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A very first, very simple calculation can be done on the back of an envelope, say per week:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;each week of flights creates &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; dollars in profit per plane. &lt;/li&gt;&#xA;&lt;li&gt;each plane set aside as spare costs &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; dollars.&lt;/li&gt;&#xA;&lt;li&gt;one problem takes &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; weeks to fix.&lt;/li&gt;&#xA;&lt;li&gt;the probability of a plane getting a problem needed to be fixed is &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can now calculate an optimum where (profit) - (costs for spare planes) is at maximum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess though, is that the cost to keep a plane as a spare is high, and the profit per week is low, giving a profit maximum at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; spare planes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting from this very simple back of the envelope calculation you can start adding details. Maybe it takes different amounts of time to fix the plane (with different probabilities). Maybe, even if you have a plane it is in the wrong airport so you will miss a few of the flights. Maybe you could rent a plane for a while. And on it goes. My guess is that rather soon you find that there are several stochastical variables and that the analytical answer will be difficult to find -- you then start doing simulations instead. &lt;/p&gt;&#xA;" OwnerUserId="1318" LastEditorUserId="123" LastEditDate="2019-09-10T19:53:04.197" LastActivityDate="2019-09-10T19:53:04.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1508" PostTypeId="1" AcceptedAnswerId="3307" CreationDate="2019-09-10T20:18:04.997" Score="9" ViewCount="801" Body="&lt;p&gt;I'm new to Gurobi in Python and I was wondering if someone knows how to code some common structures of linear constraints. I'm trying to understand how you'll code something like the following constraints: &lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\sum_{i\in A\mid i\ne j}\sum_{j\in A\mid i\ne j}x_{ij}&amp;amp;\le10\tag1\\\sum_{i\in A\mid i\ne j}x_{ij}&amp;amp;\le10\quad\forall j\in B\tag2\\x_{ij}&amp;amp;\le10\quad\forall i\in A,j\in B\mid i\ne j\tag3.\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In FICO Xpress, the first constraint would be coded like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sum(i in A, j in A | i&amp;lt;&amp;gt;j)x(i,j)&amp;lt;=10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I don't know how to code such structures in Gurobi Python.&lt;/p&gt;&#xA;&lt;p&gt;If you can provide a code example, that would be great.&lt;/p&gt;&#xA;" OwnerUserId="1301" LastEditorUserId="491" LastEditDate="2021-05-07T14:27:29.477" LastActivityDate="2021-05-07T14:27:29.477" Title="Common structures in Gurobi - Python" Tags="|linear-programming|constraint|python|gurobi|logical-constraints|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1509" PostTypeId="2" ParentId="1508" CreationDate="2019-09-10T20:44:34.667" Score="5" Body="&lt;p&gt;&lt;em&gt;Let's define the model as &lt;strong&gt;m&lt;/strong&gt;:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;m = Model('AnyName')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Now the constraint can be added to the model:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;m.addConstrs((xVar.sum('*',i) &amp;lt;= 10 for i in A, j in B, i&amp;lt;&amp;gt;j), &quot;constraintName&quot;)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/quickstart_mac/py_netflow_py_example.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.gurobi.com/documentation/8.1/quickstart_mac/py_netflow_py_example.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-09-10T22:36:51.690" LastActivityDate="2019-09-10T22:36:51.690" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1510" PostTypeId="2" ParentId="1500" CreationDate="2019-09-10T20:49:54.267" Score="3" Body="&lt;p&gt;I'm considerably more familiar with integer programming than with constraint programming, so what I'm about to say is personal opinion. I think one key characteristic of a &quot;good&quot; CP model is one that exploits &lt;em&gt;global&lt;/em&gt; constraints. The best known global constraint is, I think, the &quot;all different&quot; constraint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a possibly subtle implication to this. MILP solvers differ in their internals (what cuts they apply and when, for example), but they all work from models containing the same basic components (linear constraints, linear objectives, integrality restrictions, variable bounds). There may be some differences at the margin, regarding whether they inherently support SOS1 and SOS2 constraints and logical implications (and things like second order cone constraints, if you need to work with quadratic models), but I suspect that most commercial or high-quality open-source solvers have a pretty common set of model elements they can handle. So, for the most part, a &quot;good&quot; MIP formulation is a &quot;good&quot; formulation regardless of which solver you are using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In contrast, I don't think there is a particularly large set of global constraints understood by all major CP solvers (although, somewhat ironically, I would bet that they are all similar in having &quot;all different&quot;). So, for instance, in developing a CP model for solving cutting stock problems, you would want to look for global constraints related to rectangles not overlapping. I don't know whether every good CP solver has them (maybe: similar constraints arise in resource scheduling), and, if so, I don't know whether every good CP solver supports non-overlap in the same way, and with equal efficacy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this is my long-winded way of saying that what makes a &quot;good&quot; CP model might be more solver-dependent than what makes a &quot;good&quot; MIP model is.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-10T20:49:54.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1511" PostTypeId="2" ParentId="1498" CreationDate="2019-09-10T21:05:49.333" Score="9" Body="&lt;p&gt;As far as I can tell, industry demand for people who check the &quot;OR&quot; box (whether they are labeled as OR, industrial engineering or management science, or &quot;analytics&quot; with a clear ability to go beyond basic data-molesting) remains strong. As long as there are jobs, there will be majors, and as long as there are majors, there will be departments. (Occasional &quot;cannibalization&quot;) may occur during university reorganizations, but I don't anticipate a major wave any time soon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is true that some things originally arcane enough to require OR specialists have now been commoditized, either taught to people in other disciplines (such as supply chain management) or baked into commercial software packages that insulate the user from algorithmic details. Even those things (truck routing comes to mind) require specialists when scope or scale grow too much, or when there are &quot;side constraints&quot; or other user-specific elements that the canned programs don't accommodate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shortly after I started teaching (management science, in a business school), supply chain took off as a discipline, and to grow its supply chain program my school cannibalized its rather modest management science program. That as approximately 40 years ago, and OR/MS/IE is still chugging along in rather strong shape today (albeit not at my school). So I'm inclined to bet that the next &quot;cannibalization&quot; is a one-off anecdotal event and not a trend.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-10T21:05:49.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1512" PostTypeId="1" CreationDate="2019-09-10T21:47:00.807" Score="17" ViewCount="5078" Body="&lt;p&gt;What approaches can I use for a Linear Programming problem with the additional constraint that if a decision variable falls below a certain threshold, then it should just be forced to 0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking about the following business scenario: My decision variables are shipment/ordering quantities for a set products, and I want to say that if an order quantity falls below a certain threshold, then I shouldn't bother ordering it as all and just set the value for that product to zero (i.e a supplier won't ship less than x amount of units). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does this still count as a linear programming problem? Is it still convex? Does this increase the computational difficulty of the problem? &lt;/p&gt;&#xA;" OwnerUserId="1315" LastEditorUserId="1315" LastEditDate="2019-09-10T22:19:33.680" LastActivityDate="2019-09-11T19:03:10.410" Title="Linear Programming with additional &quot;if-then&quot;/&quot;Default to zero&quot; constraints?" Tags="|linear-programming|convexity|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1513" PostTypeId="2" ParentId="1512" CreationDate="2019-09-10T22:14:32.017" Score="9" Body="&lt;p&gt;You asked several questions at once but these should be answered all at once too. The problem that you describe is no longer convex. An easy way of seeing this is that the linear combination of the following two feasible solutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Value of the product at its minimum feasible value (Ordering quantity at its given threshold).&lt;/li&gt;&#xA;&lt;li&gt;Value of the product at zero (Ordering quality below threshold)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;is not feasible (say the value of the product being between these two numbers is ruled out by your logic constraints). This violates the definition of convexity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if your constraints are all linear, only using linear constraints is not enough to model nonconvexities. One of the most versatile tools that we have nowadays to model non-convexities is through integer variables. In the case of only linear constraints, this yields a (Mixed-)Integer Linear Programming problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, since finding the optimal solutions over a nonconvex feasible region cannot rely solely on the algorithms that assume convexity (Simplex or traditional interior point methods for LP), by removing the convexity assumption, the algorithms to solve these more complicated problems are more computationally demanding. For example, in the case of having discrete variables, you might be forced to evaluate at least some of the discrete choices by fixing them separately (branching).&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2019-09-10T22:14:32.017" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1514" PostTypeId="2" ParentId="1512" CreationDate="2019-09-10T22:57:29.623" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://www.fico.com/en/resource-download-file/3217&quot; rel=&quot;noreferrer&quot;&gt;FICO document&lt;/a&gt; (part 2.10 page 8) explain this situation as follow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Lets &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; has the situation that you explained. Define a binary variable for each of those variables like &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; and call them &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;for each variable that you already defined in the original model consider the lower bound and upper bound(defined &lt;span class=&quot;math-container&quot;&gt;$l_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u_j$&lt;/span&gt;). Lower bounds are simply your thresholds for each variable and upper bounds, if you don’t have maximum available ordering amounts, can be a defined big M.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;finally add the following constraints to your model: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\\\forall j \in \text{original variables}$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_j \geq l_j . y_j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_j \leq u_j . y_j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-09-11T01:01:32.890" LastActivityDate="2019-09-11T01:01:32.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1515" PostTypeId="2" ParentId="1459" CreationDate="2019-09-11T00:55:16.830" Score="4" Body="&lt;p&gt;You can specify many nonlinear constraints and objectives without having to define functions with the problem-based modeling approach starting with MATLAB R2019a. &quot;Many&quot; are those that are polynomial or rational expressions. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;p = optimproblem;&#xA;x = optimvar(&quot;x&quot;,&quot;LowerBound&quot;,0);&#xA;y = optimvar(&quot;y&quot;,&quot;LowerBound&quot;,0);&#xA;p.Objective = x + y;&#xA;p.ObjectiveSense = &quot;min&quot;;&#xA;p.Constraints.c1 = x^2 - y^2 &amp;gt;= 10;&#xA;initPt.x = 4;&#xA;initPt.y = 4;&#xA;sol = solve(p,initPt)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For other expressions, you will still need to write functions. Details &lt;a href=&quot;https://www.mathworks.com/help/optim/problem-based-approach.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="497" LastActivityDate="2019-09-11T00:55:16.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1516" PostTypeId="1" CreationDate="2019-09-11T00:56:54.443" Score="8" ViewCount="724" Body="&lt;p&gt;(Another OR noob question) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I'm trying to learn about OR and Optimization methods for work, I'm having a hard time understanding the difference between &quot;Optimization&quot; and &quot;Constrained Optimization&quot;: Isn't any real world optimization  problem constrained one way or the other? Why do people talk about &quot;Constrained Optimization&quot; as a specific sub-topic? &lt;/p&gt;&#xA;" OwnerUserId="1315" LastEditorUserId="38" LastEditDate="2019-09-11T01:35:11.440" LastActivityDate="2019-09-11T18:08:21.313" Title="Difference between &quot;Optimization&quot; and &quot;Constrained Optimization&quot;?" Tags="|optimization|constraint|terminology|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1517" PostTypeId="2" ParentId="1516" CreationDate="2019-09-11T01:16:17.653" Score="-4" Body="&lt;p&gt;The way I think of it is in terms of budget.  In general optimization, I could get the best solution given technology and all other CTQ's.  However, i only can afford so much given my cash and budget, so I may find another solution within that subset that is best given what is possible, namely what is within my constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While in general, these may be very similar, in application it is a totally different problem with a budget constraint, especially when you start adding other constraints like whole units (i cant buy 1/2 a bolt and still get the same use) and interdependencies...&lt;/p&gt;&#xA;" OwnerUserId="1326" LastActivityDate="2019-09-11T01:16:17.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2515" PostTypeId="2" ParentId="1516" CreationDate="2019-09-11T01:34:33.860" Score="13" Body="&lt;p&gt;You are right that most real-world problems are constrained, and therefore, for the most part, &quot;optimization&quot; and &quot;constrained optimization&quot; are synonymous. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, some algorithms only apply to unconstrained problems: an easy example is &lt;a href=&quot;https://en.wikipedia.org/wiki/Bisection_method&quot; rel=&quot;noreferrer&quot;&gt;bisection search&lt;/a&gt;. So when people say &quot;constrained optimization,&quot; they are emphasizing that they're considering the general case, as opposed to the special case of unconstrained optimization.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-09-11T01:34:33.860" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2516" PostTypeId="2" ParentId="1504" CreationDate="2019-09-11T06:20:24.297" Score="20" Body="&lt;p&gt;OR-Tools is a set of solver:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A very popular &lt;code&gt;Routing Library&lt;/code&gt; built on top of a traditional constraint programming solver&lt;/li&gt;&#xA;&lt;li&gt;An award winning &lt;code&gt;CP-SAT&lt;/code&gt; solver that combines Constraint Programming techniques, SAT solver search and Boolean centric approach, MIP solver techniques like cuts and linear relaxation, and Large Neighborhood search&lt;/li&gt;&#xA;&lt;li&gt;A Simplex solver: &lt;code&gt;GLOP&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;A Boolean linear solver (&lt;code&gt;BOP&lt;/code&gt;) geared towards finding good solutions fast&lt;/li&gt;&#xA;&lt;li&gt;A &lt;code&gt;Linear solver interface&lt;/code&gt; that offers a unified API for GLOP, BOP, and third_party solvers like Coin OR, SCIP, CPLEX, Gurobi, and XPRESS MP. &lt;/li&gt;&#xA;&lt;li&gt;Graph and Flow algorithms&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;OR-Tools is implemented in C++ and offers interfaces in Python, Java, and .NET.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, Linear and MIP solver are just one tool among many. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, to answer you questions, the goal of OR-Tools is to interact with the scientific community and the OR community. This being said, we are very pleased to see a large community of commercial users relying on it for their business, and we do our best to support them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These tools are just what we use internally to optimize Google.&lt;/p&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2019-09-11T09:58:15.080" LastActivityDate="2019-09-11T09:58:15.080" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2517" PostTypeId="1" CreationDate="2019-09-11T08:40:27.667" Score="7" ViewCount="643" Body="&lt;p&gt;First I want to say that I'm very new to this field.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I understand it, there are two different ways to use a Constraint Programming (CP) Solver: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Using the API from the Solver itself. For example .Net Interface for &lt;a href=&quot;https://www.ibm.com/products/ilog-cplex-optimization-studio&quot; rel=&quot;noreferrer&quot;&gt;IBM ILOG CPLEX&lt;/a&gt;. &lt;/li&gt;&#xA;&lt;li&gt;Using a Framework that works with many solvers. The Framework translates the constrains in the format that the chosen solver can read. For example, &lt;a href=&quot;https://ampl.com&quot; rel=&quot;noreferrer&quot;&gt;AMPL&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There is a related &lt;a href=&quot;https://or.stackexchange.com/questions/732/how-to-select-a-constraint-programming-solver&quot;&gt;question&lt;/a&gt; that gives a very good explanation and insights.&#xA;@Rob posted a very detailed answer with many solvers. The disadvantage is that the list shows, in that language the solvers are coded and not in which they can be used. Also, it's not up to date.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Problem that I want to solve is a Job Shop scheduling problem, which also has parallel machines. It is for planning real production and not a research project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The project is programmed in .Net Core, so I am looking for a solver or a framework that has a compatible API for .Net Core. The desired is a framework that can use various solvers in the background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.ide.help/OPL_Studio/usroplinterfaces/topics/opl_interf_intro_dotnet.html&quot; rel=&quot;noreferrer&quot;&gt;CPLEX&lt;/a&gt; has an interface for .NET.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second is &lt;a href=&quot;https://developers.google.com/optimization/install/dotnet/&quot; rel=&quot;noreferrer&quot;&gt;Google OR&lt;/a&gt;, there @Laurent Perron answerded in the &lt;a href=&quot;https://or.stackexchange.com/questions/1504/what-is-the-purpose-of-libraries-like-pyomo-and-google-or-tools&quot;&gt;question&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Now, to answer you questions, the goal of OR-Tools is to interact with&#xA;  the scientific community and the OR community. This being said, we are&#xA;  very pleased to see a large community of commercial users relying on&#xA;  it for their business, and we do our best to support them.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So this two might be possiblities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my question is, &quot;Doe's anyone have experience with using frameworks/solvers for Constraint Programming in .Net Core?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I appreciate any suggestion to find links of more frameworks/solvers that are compatible with .Net Core.&lt;/p&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="1278" LastEditDate="2019-09-11T11:20:33.543" LastActivityDate="2019-09-11T15:09:43.197" Title="CP Framework/Solver for .Net Core" Tags="|solver|cplex|constraint-programming|or-tools|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2518" PostTypeId="2" ParentId="1512" CreationDate="2019-09-11T09:18:14.857" Score="6" Body="&lt;p&gt;One way to approach this in an &lt;em&gt;integer&lt;/em&gt; linear programming formulation is using Big-M.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{Z}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x \geq 0$&lt;/span&gt; be your quantity variable for a product.&#xA;You now introduce a variable &lt;span class=&quot;math-container&quot;&gt;$y \in \{0, 1\}$&lt;/span&gt; that will be assigned &lt;em&gt;zero&lt;/em&gt; when you shouldn't be bother ordering, and &lt;em&gt;one&lt;/em&gt; otherwise. Let's use this constraint:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x \leq M y$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a sufficiently large integer, an upper bound for the maximum quantity you will encounter in an order. So if &lt;span class=&quot;math-container&quot;&gt;$y = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; will be your quantity, if &lt;span class=&quot;math-container&quot;&gt;$y = 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; will be limited to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; be your threshold. We now need some &quot;logic&quot; to set &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x \geq T$&lt;/span&gt; and to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y \leq x/T$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The case &lt;span class=&quot;math-container&quot;&gt;$x &amp;lt; T$&lt;/span&gt; yields &lt;span class=&quot;math-container&quot;&gt;$y &amp;lt; 1$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$y = 0$&lt;/span&gt;, and the case &lt;span class=&quot;math-container&quot;&gt;$x \geq T$&lt;/span&gt; allows &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; to be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, we get, as &lt;a href=&quot;https://or.stackexchange.com/a/1514/2327&quot;&gt;Oguz Toragay already cited from the FICO document&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x \geq T y$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x \leq M y$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: A slightly different approach would be as follows: You could use a variable &lt;span class=&quot;math-container&quot;&gt;$z \in \mathbb{Z}, z \geq 0,$&lt;/span&gt; for quantities that are added &lt;em&gt;on top of your threshold&lt;/em&gt;, and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; as described above. So replace all occurrences of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$z + T y$&lt;/span&gt; and only use the constraint &lt;span class=&quot;math-container&quot;&gt;$z \leq M y$&lt;/span&gt;. I guess it's not much of a difference for most MIP solvers, but it's worth trying.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Does this increase the computational difficulty of the problem?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, in two ways:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) The formulation is an &lt;em&gt;integer&lt;/em&gt; formulation, that is, you cannot simply use simplex or barrier methods to solve it, you need to solve the LP relaxation and branch over the fractional variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) The LP relaxation is bad (i.e. there will be a lot of branching, which is expensive). That's usually the issue with Big-M formulations.&lt;/p&gt;&#xA;" OwnerUserId="2327" LastEditorUserId="2327" LastEditDate="2019-09-11T19:03:10.410" LastActivityDate="2019-09-11T19:03:10.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2519" PostTypeId="2" ParentId="1512" CreationDate="2019-09-11T11:12:37.183" Score="2" Body="&lt;p&gt;As previous posts mentioned, you will need to use binary variables to deal with it. Might, &lt;a href=&quot;https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_prodplan.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; example be useful to you.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-09-11T11:12:37.183" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2520" PostTypeId="2" ParentId="2517" CreationDate="2019-09-11T11:49:20.590" Score="1" Body="&lt;p&gt;As you mentioned, you will need to develop a practical (non-academic) scheduling model, you have two different options. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First, if your problem scale is not too large, I recommend developing a MIP formulation for your problem. Indeed, you could achieve an optimal solution. Some useful examples have been found via &lt;a href=&quot;http://amsterdamoptimization.com/models/blog/ft10.gms&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;, &lt;a href=&quot;https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_flowshop.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; or &lt;a href=&quot;https://mipcl-cpp.appspot.com/static/pdf/OM.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; links. &lt;/li&gt;&#xA;&lt;li&gt;Second, if your problem is the large scale that MIP solvers can not solve it in a reasonable time,  you should use other techniques like CP.&lt;br&gt;&#xA;However, CP has a suboptimal solution but, in the large scale model, it can solve the problem in a reasonable time. Some useful example in the CP could be found via &lt;a href=&quot;https://www.slideshare.net/PhilippeLaborie/vug-scheduling28-may2014&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; or &lt;a href=&quot;https://www.ibm.com/developerworks/community/forums/html/topic?id=02ecc339-015e-490e-b5a2-5bdf8d86f15d&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; links.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In both cases, you will need a solver such as CPLEX to solve MIP or CP, or you can use an open-source solver such as &lt;a href=&quot;https://mipcl-cpp.appspot.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIPCL&lt;/a&gt;. Might, you want to use some ASP software that I recommended &lt;a href=&quot;https://www.asprova.com/en/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ASPROVA&lt;/a&gt; or &lt;a href=&quot;https://www.mrpeasy.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;MRPEasy&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-09-11T11:49:20.590" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="2522" PostTypeId="1" CreationDate="2019-09-11T14:38:51.383" Score="14" ViewCount="956" Body="&lt;p&gt;Gurobipy is a fast solver and can convert a mathematical programming model to its underneath language very fast compared to some open source wrappers (e.g., PuLP, OR-tools, etc.). However, a commercial license is a big issue in some cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to use a wrapper to convert models as fast as gurobipy, and solve with open source solvers? Alternatively, can we pass the model written with gurobipy to an open source solver?&lt;/p&gt;&#xA;" OwnerUserId="2332" LastActivityDate="2021-01-19T10:38:54.953" Title="Model conversion as fast as gurobipy and solved by open source solvers" Tags="|solver|gurobi|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2523" PostTypeId="2" ParentId="2522" CreationDate="2019-09-11T14:51:30.363" Score="12" Body="&lt;p&gt;You can use &lt;code&gt;model.write(&quot;mymodel.lp&quot;)&lt;/code&gt; to generate an LP file (similarly for &lt;code&gt;.mps&lt;/code&gt; and other common formats) that you can pass in open source solvers, provided that they can read that respective format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since LP files are also human readable it is not too hard to transform a gurobipy model script into a script using only plain Python file operations that generates your LP file.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In order to make the second part of my answer a bit (in hindsight, it got out of hand) more succinct, I just give an example on how to generate an LP file &quot;by hand&quot; instead of using the gurobipy &lt;code&gt;Model.write()&lt;/code&gt; method. For a minimal working example, consider the binpacking problem (how cliché).&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\text{minimize } &amp;amp; \sum_{j=0}^{n-1} y_j\\&#xA;\text{subject to } &amp;amp; \sum_{i=0}^{n-1} w_i x_{ij} \leq Cy_j &amp;amp; j \in \{0, \ldots, n-1\}\\&#xA;&amp;amp; \sum_{j=0}^{n-1} x_{ij} \geq 1 &amp;amp; i \in \{0, \ldots, n-1\}\\&#xA;&amp;amp; x_{ij}, y_j \in \{0, 1\} &amp;amp; i, j \in \{0, \ldots, n-1\}&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;Using &lt;code&gt;gurobipy&lt;/code&gt;, your file looks somewhat similar to this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from gurobipy import *&#xA;&#xA;# params&#xA;w = [5, 4, 1, 2, 3] &#xA;C = 6&#xA;n = len(w)&#xA;&#xA;model = Model('Binpacking')&#xA;&#xA;x = {}&#xA;for i in range(n):&#xA;  for j in range(n):&#xA;    x[i,j] = model.addVar(vtype=GRB.BINARY, name=&quot;x#{}#{}&quot;.format(i, j))&#xA;&#xA;y = {}&#xA;for j in range(n):&#xA;  y[j] = model.addVar(vtype=GRB.BINARY, name=&quot;y#{}&quot;.format(j))&#xA;&#xA;model.setObjective(quicksum(y[j] for j in range(n)), GRB.MINIMIZE)&#xA;&#xA;for j in range(n):&#xA;  model.addConstr(quicksum(w[i] * x[i,j] for i in range(n)) &amp;lt;= C * y[j], name=&quot;capacity#{}&quot;.format(j))&#xA;&#xA;for i in range(n):&#xA;  model.addConstr(quicksum(x[i,j] for j in range(n)) &amp;gt;= 1, name=&quot;assignment#{}#{}&quot;.format(i, j))&#xA;&#xA;model.write(&quot;binpacking.lp&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the same program structure (which is meant to be human readable, not necessarily optimal w.r.t. execution time), we can also create a similar file only using &lt;code&gt;write()&lt;/code&gt;. It is a bit tedious but given the simple structure of LP files straight-forward:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# params&#xA;w = [5, 4, 1, 2, 3] &#xA;C = 6&#xA;n = len(w)&#xA;&#xA;model = open(&quot;binpacking.lp&quot;, 'w')&#xA;&#xA;model.write(&quot;Minimize\n&quot;)&#xA;model.write(&quot;bins: &quot;)&#xA;for j in range(n):&#xA;  model.write(&quot;+ y#{} &quot;.format(j))&#xA;&#xA;model.write(&quot;\n\nSubject to\n&quot;)&#xA;for j in range(n):&#xA;  model.write(&quot;capacity#{}:\n&quot;.format(j))&#xA;  for i in range(n):&#xA;    model.write(&quot; + {} x#{}#{}&quot;.format(w[i], i, j))&#xA;  model.write(&quot; - {} y#{} &amp;lt;= 0\n&quot;.format(C, j))&#xA;&#xA;for i in range(n):&#xA;  model.write(&quot;assignment#{}:\n&quot;.format(i))&#xA;  for j in range(n):&#xA;    model.write(&quot; + x#{}#{}&quot;.format(i, j))&#xA;  model.write(&quot; &amp;gt;= 1\n&quot;)&#xA;&#xA;model.write(&quot;\n\nBounds\n&quot;)&#xA;model.write(&quot;Binaries\n&quot;)&#xA;for j in range(n):&#xA;  for i in range(n):&#xA;    model.write(&quot; x#{}#{}\n&quot;.format(i, j))&#xA;  model.write(&quot; y#{}\n&quot;.format(j))&#xA;&#xA;model.write(&quot;End\n&quot;)&#xA;model.close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="130" LastEditorUserId="130" LastEditDate="2019-09-13T12:24:07.103" LastActivityDate="2019-09-13T12:24:07.103" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2524" PostTypeId="2" ParentId="2517" CreationDate="2019-09-11T15:09:43.197" Score="1" Body="&lt;p&gt;Not sure about CP solvers, but for FICO Xpress the .NET .dll also works for .NET core. So I would suspect that similar transferability is also applicable for CP solvers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason is in my opinion fairly clear: the API .dlls (the ones that contain the classes and methods accessible in .NET Core) are pretty simple, and the heavy lifting is done in the C part of the library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check whether a given .dll is compatible with .NET core, check out the .&lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/standard/analyzers/portability-analyzer&quot; rel=&quot;nofollow noreferrer&quot;&gt;NET portability analyzer&lt;/a&gt; from Windows.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-09-11T15:09:43.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2525" PostTypeId="1" CreationDate="2019-09-11T15:31:46.523" Score="9" ViewCount="585" Body="&lt;p&gt;I am trying to write out a MINLP problem of optimal control for an invasive species and the code that I have for my PYOMO model is below. Some of the initialization values take from an Excel spreadsheet, so they are not made explicit in the formulation below. Additionally, these values aren't real data, but simulated data I have made just to try and get my model running. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem that I am encountering is that my binary variable &lt;em&gt;model.level1&lt;/em&gt;, which emphasizes whether or not a cell receives treatment, is always slammed to zero in my objective function which indicates that no control is applied to any cells and this effect cascades throughout the rest of the equations and results in unrealistic results even for fake data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps I am overlooking something in my constraints that are causing the binary variable to be slammed to 0 rather than having a variety of different 0's and 1's throughout the solution?&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model = ConcreteModel()&#xA;Imax = 2&#xA;Jmax = 2&#xA;Tmax = 3&#xA;Kmax = 2&#xA;model.Iset = RangeSet(1, Imax)  # e.g. i = {1, 2, 3}&#xA;model.Jset = RangeSet(1, Jmax)&#xA;model.Tset = RangeSet(1, Tmax)&#xA;model.Kset = RangeSet(1, Kmax)&#xA;&#xA;model.juvsurv = Param(initialize=0.60)&#xA;model.juvdeath = Param(initialize=0.40)&#xA;model.lambd = Param(initialize=0.20)&#xA;model.alpha = Param(initialize=2)&#xA;&#xA;model.juvenille = Var(model.Iset, model.Jset, model.Tset, model.Kset, within=NonNegativeReals, initialize=initial_values_ext(3, Tmax, 2, juvenille_init))&#xA;model.susceptible = Var(model.Iset, model.Jset, model.Tset,within=NonNegativeReals, initialize=initial_values(3, Tmax, susceptible_init))&#xA;model.juvenilleTotal = Var(model.Iset, model.Jset, model.Tset, within=NonNegativeReals)&#xA;model.inf_b4treat = Var(model.Iset, model.Jset, model.Tset, within=NonNegativeReals, initialize=initial_values(3, Tmax, inf_b4treat_init))&#xA;model.inf_treated = Var(model.Iset, model.Jset, model.Tset, within=NonNegativeReals)&#xA;model.obj = Var(model.Iset, model.Jset, model.Tset, within=NonNegativeReals)&#xA;&#xA;def objective_rule(model):&#xA;    return sum (sum (sum (model.obj[i,j,t] for i in model.Iset ) for j in model.Jset ) for t in model.Tset )&#xA;model.damages = Objective(rule=objective_rule, sense=minimize)&#xA;&#xA;def obj_rule(model, i,j,t):&#xA;    return model.obj[i,j,t] == 10*model.inf_b4treat[i,j,t] + 5*model.level1[i,j,t]*model.inf_b4treat[i,j,t]&#xA;model.object = Constraint(model.Iset, model.Jset, model.Tset, rule=obj_rule)&#xA;&#xA;# Constraint 1: juvenilles that advance to the next age class (eq. 1)&#xA;def juv_advance_rule(model, i, j, t, k):&#xA;    if t != Tmax and k != Kmax:&#xA;        return model.juvenille[i, j, t + 1, k + 1] == model.juvenille[i, j, t, k] * model.juvsurv&#xA;    return Constraint.Skip&#xA;model.juv_advance = Constraint(model.Iset, model.Jset, model.Tset, model.Kset, rule=juv_advance_rule)&#xA;&#xA;# Constraint 2: total number of juvenilles in all age classes on cell (i,j)&#xA;def juv_total_rule(model, i, j, t):&#xA;    return model.juvenilleTotal[i, j, t] == sum(model.juvenille[i, j, t, k] for k in model.Kset)&#xA;model.juv_total = Constraint(model.Iset, model.Jset, model.Tset, rule=juv_total_rule)&#xA;&#xA;# Constraint 3: recruitment of seedlings to the first juvenille age class.&#xA;def juv_recruit_rule(model, i, j, t, k):&#xA;    if k == 1 and t != Tmax:&#xA;        return model.juvenille[i, j, t + 1, k] == model.juvdeath * model.juvenilleTotal[i, j, t]&#xA;    else:&#xA;        return Constraint.Skip&#xA;model.juv_recruit = Constraint(model.Iset, model.Jset, model.Tset, model.Kset, rule=juv_recruit_rule)&#xA;&#xA;# Constraint 4: Susceptible recruitment&#xA;def susceptible_advance_rule(model, i, j, t):&#xA;    if t == Tmax:&#xA;        return Constraint.Skip&#xA;    else:&#xA;        return model.susceptible[i, j, t + 1] == model.susceptible[i, j, t] - model.inf_b4treat[i, j, t] + model.juvsurv * model.juvenille[i, j, t, Kmax]&#xA;model.susceptible_advance = Constraint(model.Iset, model.Jset, model.Tset, rule=susceptible_advance_rule)&#xA;&#xA;# Constraint 5(10): Population Growth:&#xA;def infested_growth_rule(model, i, j, t):&#xA;    if t == Tmax:&#xA;        return Constraint.Skip&#xA;    else:&#xA;        return model.inf_b4treat[i, j, t + 1] == ( model.inf_treated[i, j, t]**2 / (model.inf_treated[i,j,t]**2 + model.alpha) ) * model.susceptible[i,j,t] + 10&#xA;model.inf_growth = Constraint(model.Iset, model.Jset, model.Tset, rule=infested_growth_rule)&#xA;&#xA;# Constraint 9: Treated Infestation&#xA;def treatment_rule(model, i, j, t):&#xA;    return model.inf_treated[i, j, t] == model.inf_b4treat[i, j, t] * (1 - model.level1[i, j, t] )&#xA;model.treated_pop = Constraint(model.Iset, model.Jset, model.Tset, rule=treatment_rule)&#xA;&#xA;def budget_rule(model):&#xA;    return sum(sum(sum(2*model.level1[i,j,t] for i in model.Iset) for j in model.Jset) for t in model.Tset) &amp;lt;= 3&#xA;model.budget = Constraint(model.Iset, model.Jset, model.Tset, rule=budget_rule)&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="547" LastEditorUserId="56" LastEditDate="2019-09-11T16:34:20.880" LastActivityDate="2019-09-11T19:21:45.417" Title="Integer Decision Variables Always Forced to Zero in Minimization Problem (MINLP)" Tags="|pyomo|minlp|optimal-control|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2526" PostTypeId="1" AcceptedAnswerId="2537" CreationDate="2019-09-11T16:07:22.233" Score="16" ViewCount="486" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a discrete random variable taking value &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; with probability &lt;span class=&quot;math-container&quot;&gt;$1/N$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$n=1,&#xA;\ldots,N$&lt;/span&gt;. I would like to set the &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; values in an optimization problem. My objective is to minimize the variance while satisfying a set of constraints.&lt;/p&gt;&#xA;&lt;p&gt;So the problem is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{ll} &amp;amp; \min\limits_{\{x_n\}_{n=1}^N}{\operatorname{Var}(X)} \\ &amp;amp; \text{s.t.} \ \ldots  \end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Denote &lt;span class=&quot;math-container&quot;&gt;$x = \begin{pmatrix} x_1 &amp;amp; \ldots &amp;amp; x_n\end{pmatrix}^\top$&lt;/span&gt;. So in this discrete distribution, the variance is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\operatorname E[X^2] -\operatorname E[X]^2 = \frac{1}{N} \sum_{n=1}^N x_n^2 - \frac{1}{N^2} \left( \sum_{n=1}^N x_n \right)^2 = \frac{x^\top x}{N} - \frac{(\mathbf{e}^\top x)(x^\top \mathbf{e})}{N^2}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The variance is not convex, so minimization is hard, right? Is there a common method for this?&lt;/li&gt;&#xA;&lt;li&gt;Is there any convex function which results in a low variance after being minimized?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Edit: The variance may be convex based on the comments. We can show that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\operatorname E[X^2] -\operatorname E[X]^2 = \frac{x^\top \left(  I - \tfrac{\mathbf{e}\mathbf{e}^\top}{N}\right) x}{N},$$&lt;/span&gt;&#xA;so to show this is convex, we need to show that &lt;span class=&quot;math-container&quot;&gt;$I - \tfrac{\mathbf{e}\mathbf{e}^\top}{N}$&lt;/span&gt; is a p.s.d. matrix. That is itself a challenge. I need to see the proof of how this is p.s.d, or if one can properly write down how the variance can be shown as a closed-form norm expression as in the comments.&lt;/p&gt;&#xA;&lt;p&gt;To show the variance is &lt;span class=&quot;math-container&quot;&gt;$\ell^2$&lt;/span&gt;-norm-representable we need to have &lt;span class=&quot;math-container&quot;&gt;$a^\top a = I - \tfrac{\mathbf{e}\mathbf{e}^\top}{N}$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;. Finding &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; will also make it.&lt;/p&gt;&#xA;&lt;p&gt;Edit-2: Ok, I got the comment. He follows the &lt;span class=&quot;math-container&quot;&gt;$\operatorname{Var}(X) = \operatorname E[(X - \operatorname E[X])^2]$&lt;/span&gt; approach, then it is obvious.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-09-12T11:03:13.483" Title="Convexity of Variance Minimization" Tags="|optimization|convexity|probability-distributions|nonconvex-programming|variance|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2527" PostTypeId="2" ParentId="2525" CreationDate="2019-09-11T16:11:34.833" Score="3" Body="&lt;p&gt;I only skimmed your model so others may be better able to point to the error directly, but here are some reasons this may occur:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Constraints: as you mention, perhaps they're set so that it's not possible to apply the treatment. E.g, is the budget accidentally set too tightly so it can't afford it? (There are several sums in your budget_rule - I'd double check that constraint)&lt;/li&gt;&#xA;&lt;li&gt;Objective function: perhaps it hurts the OF value when treatment is applied. E.g., does the cost of treatment outweigh the benefit? Also I'm not sure why model.inf_b4treat is included in both the not treated and treated terms (could be fine). Also, always good to double-check whether you mean to minimize vs. maximize.&lt;/li&gt;&#xA;&lt;li&gt;Inputs: is the problem initialized so that no one needs treatment?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Other ideas to debug:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Test the model with the an extreme inputs and/or adjusted/removed constraints. E.g., no budget limit, no treatment cost&lt;/li&gt;&#xA;&lt;li&gt;If still not clear, iteratively remove constraints and resolve. See what the limiting one may be.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Best wishes!&lt;/p&gt;&#xA;" OwnerUserId="56" LastActivityDate="2019-09-11T16:11:34.833" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2528" PostTypeId="2" ParentId="1516" CreationDate="2019-09-11T18:08:21.313" Score="5" Body="&lt;p&gt;Problems involving physical/tangible systems (such as production scheduling, crew assignment, ...) are inherently constrained, whether the modeler bothers to put all the constraints in or not. Any variable representing a physical process has a finite domain (presuming that the physicists are correct in saying there is a finite amount of matter in the known universe), whether the model author bounds them or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, consider the problem of fitting a regression model (least squares) using gradient descent. The variables are the model coefficients, and while there may be ways to argue that this particular coefficient cannot be astronomically large in magnitude, it's unlikely there will be any &lt;strong&gt;known&lt;/strong&gt; &lt;em&gt;a priori&lt;/em&gt; bounds for the coefficients. (The computer's limited range of floating point values will inherently bound them, whether you like it or not.) So the problem is treated as unconstrained, with no loss of validity or functionality.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-11T18:08:21.313" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2529" PostTypeId="2" ParentId="1512" CreationDate="2019-09-11T18:17:08.123" Score="9" Body="&lt;p&gt;An alternative to using binary variables is to use semicontinuous variables, supported by some solvers. You still wind up with a discrete optimization problem (integer program), but the binary &quot;buy/don't buy&quot; variables and the related bounds are order sizes are handled internally by the solver rather than explicitly in your model. Some citations (shamelessly starting with one of my own):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://orinanobworld.blogspot.com/2011/03/semicontinuous-variables.html&quot; rel=&quot;noreferrer&quot;&gt;Semicontinuous Variables&lt;/a&gt; (my blog; I refuse to waste hyphens where not needed)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2016/08/semi-continuous-variables.html&quot; rel=&quot;noreferrer&quot;&gt;Semi-continuous variables&lt;/a&gt; (Erwin Kalvelagen's blog)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://lpsolve.sourceforge.net/5.1/semi-cont.htm&quot; rel=&quot;noreferrer&quot;&gt;semi-continuous variables&lt;/a&gt; (lp_solve documentation)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-11T18:17:08.123" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2530" PostTypeId="1" AcceptedAnswerId="2533" CreationDate="2019-09-11T19:02:13.670" Score="15" ViewCount="1182" Body="&lt;p&gt;In the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; queens puzzle, we have to put &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; queens on an &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt; chessboard, without any &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; queens being able to attack each other. Finding a single feasible solution is not NP-complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a useful example nonetheless, because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it is simple to understand&lt;/li&gt;&#xA;&lt;li&gt;it has a visual solution&lt;/li&gt;&#xA;&lt;li&gt;it has exactly &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; parameter (the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;) to generate a dataset&lt;/li&gt;&#xA;&lt;li&gt;it doesn't have an immediately obvious solution&lt;/li&gt;&#xA;&lt;li&gt;it is a single-player game&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Are there any other similar puzzles/games, you might think of?&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="38" LastEditDate="2022-04-11T00:47:06.117" LastActivityDate="2022-04-11T00:47:06.117" Title="Might you know any simple puzzles similar to $n$ queens? Anything parametrized worth running to a constraint solver?" Tags="|puzzles-games|" AnswerCount="7" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2531" PostTypeId="2" ParentId="2525" CreationDate="2019-09-11T19:21:45.417" Score="5" Body="&lt;p&gt;You can try adding a constraint forcing one of the affected variable to be nonzero. If the model becomes infeasible, you can try to find the conflicting constraints. If the model stays feasible, this means that your objective function represents other priorities than you expected.&lt;/p&gt;&#xA;" OwnerUserId="69" LastActivityDate="2019-09-11T19:21:45.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2532" PostTypeId="2" ParentId="2530" CreationDate="2019-09-11T19:25:23.360" Score="9" Body="&lt;p&gt;The book &lt;strong&gt;Puzzles and Games: A Mathematical Modeling Approach&lt;/strong&gt; by Tony Hurlimann, is a comprehensive guide to mathematical modeling of games and puzzles. It uses about 100 puzzles as &quot;case studies&quot; and represents them as a mathematical model. All the games have already coded using LPL language. The &lt;a href=&quot;http://lpl.unifr.ch/lpl/mainpuzzles.html&quot; rel=&quot;noreferrer&quot;&gt;website&lt;/a&gt; included all the codes and interactive solving environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: the book even has a chapter for chessboard placement puzzles. Below I added a sample of the puzzles in the reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XNrtA.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XNrtA.png&quot; alt=&quot;Description of the puzzle&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/L5Eqo.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/L5Eqo.png&quot; alt=&quot;Model&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gzT0Q.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gzT0Q.png&quot; alt=&quot;Solution&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-09-11T19:59:32.773" LastActivityDate="2019-09-11T19:59:32.773" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2533" PostTypeId="2" ParentId="2530" CreationDate="2019-09-11T19:45:47.983" Score="11" Body="&lt;p&gt;I adressed part of that in&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/pulse/puzzles-having-fun-useful-mathematics-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Puzzles : having fun and useful mathematics&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;where I mention the &lt;a href=&quot;http://www.research.ibm.com/haifa/ponderthis/&quot; rel=&quot;nofollow noreferrer&quot;&gt;IBM Ponder This Challenge&lt;/a&gt;, a monthly puzzle that is 20+ years old now.&lt;/p&gt;&#xA;&lt;p&gt;Let me also mention the &lt;a href=&quot;https://dmcommunity.org/challenge/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Decision Management Community challenge&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Without much effort many of those challenges can be turn into generic puzzles you can scale with a simple parameter.&lt;/p&gt;&#xA;&lt;p&gt;Within the IBM CPLEX product, some examples comply 100% with your requirement:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.5.1/ilog.odms.ide.help/examples/html/opl/lifegameip/lifegameip.mod.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lifegame&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.5.1/ilog.odms.ide.help/examples/html/opl/euler/euler.mod.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Euler&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;linear_peg_solitaire.py in CPLEX_Studio129\python\examples\cp\basic&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;NB:&lt;/p&gt;&#xA;&lt;p&gt;I work for IBM&lt;/p&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2021-02-28T17:55:27.757" LastActivityDate="2021-02-28T17:55:27.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2534" PostTypeId="1" CreationDate="2019-09-11T22:46:59.043" Score="10" ViewCount="182" Body="&lt;p&gt;I'm working on an Inventory Optimization (Allocation) problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The decision variable is the amount of inventory budget to allocate for each product, from a set of products. My objective is to maximize my profit. My constraint is a total budget which limits how much inventory I can purchase (I can't satisfy demand for all products - otherwise my allocations would simply be my forecasts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The inputs to the problem are the following: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Future sales forecast for each product. &lt;/li&gt;&#xA;&lt;li&gt;Forecast intervals (analogous to standard deviation) for each product: For example, for product 1, the forecast is 190 Units +/- 50 units, while the forecast for product 2 is 200 +/- 20 units.  &lt;/li&gt;&#xA;&lt;li&gt;A desired in-stock rate for each product. &lt;/li&gt;&#xA;&lt;li&gt;A profit margin for each product. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I only use point forecasts (i.e. I discard the second input), then maximizing my total profit across all products becomes pretty straightforward. I would just allocate as much as possible to products that will get me the most profit based on the margin × forecast sales. Basically allocate to products in order of decreasing profitability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I take into account the forecast intervals, then the problem becomes more complex, and a &quot;risk&quot; factor seems to come into play: Product 1 might be the most profitable if I consider the upper bound of the forecast interval, but product 2 might be the most profitable if I consider the median of the forecast interval. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way to optimally allocate my budget is if I define a risk factor (similar to portfolio optimization). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I go about deciding this risk factor? What the approaches for doing so? Does service level/in stock rate come into play? &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;To clarify based on LarrySnyder610♦ 's comments.&lt;/em&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By risk I do not mean risk of running out of stock. I mean the risk that comes from the variance in the product forecasts. To take the example I mentioned above: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say we have just two products, where all is equal: margins, cost, etc...and lets say that I am forced to choose between one or the other for space or logistics constraints. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Product 1 one has a mean forecast of 190 units and a forecast interval of 50 units, so my forecast can be thought of as most likely falling between 140 and 240. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Product 2 has a mean forecast of 200 units and a forecast interval of 20 units, so my forecast can be thought of as most likely falling between 180 and 220.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I disregard my forecast intervals, then obviously should go with product 2, since that means I would sell 200 units instead of 190. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I take into account the forecast intervals, then there is a possibility that I will make more money if I go with product 1 (I'm lucky and I sell 240 units, compared to 220 units for product 2). But there is also a chance that I sell only 140 units, hence making less the lower bound of 180 for product 2. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there is this idea that there is a &quot;risk&quot; factor involved: If I am willing to take the risk, then my optimal solution is to allocate to product 1. If I want to play it safe, then my optimal solution is to go with product 2. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To reiterate the main question: How do I quantify the risk? And what are the approaches for deciding whether I should take a risk or not? And does this risk factor somehow tie into service levels/in-stock rates (I don't think it does, but I might be wrong) ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of all how do I communicate this to business users and product managers who have no math or stats knowledge? &lt;/p&gt;&#xA;" OwnerUserId="1315" LastEditorUserId="1315" LastEditDate="2019-09-13T14:18:05.770" LastActivityDate="2019-09-13T14:18:05.770" Title="Approaches for choosing a &quot;risk&quot; factor in an Inventory Optimization problem?" Tags="|optimization|reference-request|inventory|supply-chain|rq-inventory-model|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2535" PostTypeId="1" CreationDate="2019-09-12T01:40:00.297" Score="9" ViewCount="201" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^n$&lt;/span&gt; be an optimization variable. Now, at a constraint, I would like to count how many times a value, say &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;, appears in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; decision. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think we can have a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; indicating whether &lt;span class=&quot;math-container&quot;&gt;$x_i =2$&lt;/span&gt;. So, &lt;span class=&quot;math-container&quot;&gt;$x_i - 2 = 0$&lt;/span&gt; should imply &lt;span class=&quot;math-container&quot;&gt;$y_i = 1$&lt;/span&gt;. But, anything except &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; should imply &lt;span class=&quot;math-container&quot;&gt;$y_i = 0$&lt;/span&gt;. What is the easiest way for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: since we can subtract &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; from each element of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, we are interested in the number of zeros in &lt;span class=&quot;math-container&quot;&gt;$x-2$&lt;/span&gt;. So, 'the number of zeros in a decision vector' constraint will also make it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We may assume &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; consists of elements &lt;span class=&quot;math-container&quot;&gt;$x_i&amp;lt; M$&lt;/span&gt; for some constant &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="123" LastEditDate="2019-09-12T07:09:39.733" LastActivityDate="2019-09-12T17:43:16.160" Title="Binary variable to count appearances" Tags="|modeling|logical-constraints|binary-variable|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2536" PostTypeId="2" ParentId="2530" CreationDate="2019-09-12T02:19:28.740" Score="10" Body="&lt;p&gt;In my book &lt;em&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/1731343647&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Opex Analytics Weekly Puzzle&lt;/a&gt;&lt;/em&gt;, there are several puzzles that &lt;em&gt;can&lt;/em&gt; be solved as MIPs. Part of the fun (in my opinion) is that some people will want to solve them this way, but others will prefer to solve them in other ways. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A prize-collecting TSP-type puzzle&lt;/li&gt;&#xA;&lt;li&gt;A &quot;clueless&quot; sudoku-type puzzle&lt;/li&gt;&#xA;&lt;li&gt;A graph connectivity puzzle&lt;/li&gt;&#xA;&lt;li&gt;An attacking-queen-type puzzle&lt;/li&gt;&#xA;&lt;li&gt;A poker-hand puzzle&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(I don't mean to &lt;a href=&quot;https://or.stackexchange.com/help/behavior&quot;&gt;self-promote&lt;/a&gt; with this answer. I hope it doesn't come across this way.)&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-09-12T02:19:28.740" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2537" PostTypeId="2" ParentId="2526" CreationDate="2019-09-12T06:07:58.480" Score="15" Body="&lt;p&gt;It holds&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rcl}&#xA;\operatorname V(x) &amp;amp;= &amp;amp;\dfrac1N\left\| x-\dfrac{e^\top x}{N} e \right\|^2 \\&#xA;     &amp;amp; = &amp;amp; \dfrac1N\left(x^\top x+\dfrac{(e^\top x)^2 e^\top e}{N^2}-2\dfrac{(e^\top x)^2}N\right) \\ &#xA;     &amp;amp; = &amp;amp; \dfrac{x^\top x}{N} - \dfrac{(e^\top x)^2}{N^2}.&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;So you are minimizing the &lt;span class=&quot;math-container&quot;&gt;$\ell^2$&lt;/span&gt;-norm of an affine expression which is known to be convex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{lcl}&#xA;\min      &amp;amp; \dfrac{\|x-e u\|}{N} &amp;amp; \\&#xA;\mbox{s.t.} &amp;amp; \dfrac{e^\top x}{N} - u &amp;amp; = &amp;amp; 0 \\ &#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;provides a nice interpretation since &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; is the average. Note the problem tries to make all the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; equal to the average value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively the last problem can be stated as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{lcl}&#xA;\min      &amp;amp; \dfrac{s}{N}&amp;amp;\\&#xA;\mbox{s.t.} &amp;amp; \dfrac{e^\top x}{N} - u &amp;amp;=0 \\ &#xA;          &amp;amp;(s;x-e u) &amp;amp;\in Q.    \\&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is a quadratic cone. This provides another convexity proof because the quadratic cone is convex. Hence, the problem can be solved using SOCP also known as conic quadratic optimization.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2019-09-12T11:03:13.483" LastActivityDate="2019-09-12T11:03:13.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2538" PostTypeId="2" ParentId="1470" CreationDate="2019-09-12T06:36:29.600" Score="5" Body="&lt;p&gt;My claim is that everything that can be formulated as a conic optimization problem using&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Linear cones&lt;/li&gt;&#xA;&lt;li&gt;Quadratic cones&lt;/li&gt;&#xA;&lt;li&gt;Power cones&lt;/li&gt;&#xA;&lt;li&gt;Exponential cones&lt;/li&gt;&#xA;&lt;li&gt;Semi definite cone (with some qualifications)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;can be solved efficiently in practice. First of all there are surprisingly few convex optimization problems that fall outside this class of problems and secondly only efficient (near) symmetric primal-dual algorithms are known for this class of problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note if you use the popular software software packages &lt;a href=&quot;https://www.cvxr.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cvx&lt;/a&gt; or &lt;a href=&quot;https://cvxpy.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cvxpy&lt;/a&gt; they will only allow you to formulate problems that can converted to the above mentioned conic problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read more about conic problems in the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek modelling cookbook&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="38" LastEditDate="2019-09-12T21:26:03.937" LastActivityDate="2019-09-12T21:26:03.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2539" PostTypeId="2" ParentId="1455" CreationDate="2019-09-12T06:38:21.930" Score="2" Body="&lt;p&gt;I think that you want this set of non-linear constraints&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\text{first}&amp;amp;\begin{cases}x_1 x_2 &amp;gt; x_1 y_2\\&#xA;x_1 x_2 &amp;gt; y_1 x_2\\&#xA;y_1 y_2 &amp;gt; x_1 y_2\\&#xA;y_1 y_2 &amp;gt; y_1 x_2\end{cases}\\&#xA;\text{second}&amp;amp;\begin{cases}x_1 x_2 x_3 &amp;gt; x_1 y_2 y_3\\&#xA;x_1 x_2 x_3 &amp;gt; y_1 y_2 x_3\\&#xA;x_1 x_2 x_3 &amp;gt; x_1 x_2 y_3\\&#xA;x_1 x_2 x_3 &amp;gt; y_1 x_2 x_3\\&#xA;x_1 x_2 x_3 &amp;gt; x_1 y_2 x_3\\&#xA;x_1 x_2 x_3 &amp;gt; y_1 x_2 y_3\\&#xA;y_1 y_2 y_3 &amp;gt; x_1 y_2 y_3\\&#xA;y_1 y_2 y_3 &amp;gt; y_1 y_2 x_3\\&#xA;y_1 y_2 y_3 &amp;gt; x_1 x_2 y_3\\&#xA;y_1 y_2 y_3 &amp;gt; y_1 x_2 x_3\\&#xA;y_1 y_2 y_3 &amp;gt; x_1 y_2 x_3\\&#xA;y_1 y_2 y_3 &amp;gt; y_1 x_2 y_3\end{cases}\\&#xA;\text{third}&amp;amp;\begin{cases}x_1 y_2 y_3 &amp;gt; x_1 y_2 x_3\\&#xA;x_1 y_2 y_3 &amp;gt; y_1 x_2 y_3\\&#xA;y_1 y_2 x_3 &amp;gt; x_1 y_2 x_3\\&#xA;y_1 y_2 x_3 &amp;gt; y_1 x_2 y_3\\&#xA;x_1 x_2 y_3 &amp;gt; x_1 y_2 x_3\\&#xA;x_1 x_2 y_3 &amp;gt; y_1 x_2 y_3\\&#xA;y_1 x_2 x_3 &amp;gt; x_1 y_2 x_3\\&#xA;y_1 x_2 x_3 &amp;gt; y_1 x_2 y_3\end{cases}&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and you need to maximize the following function&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_1 + y_1 + x_1 + x_2 + y_1 + y_2 + x_1 + x_2 + x_3 + y_1 + y_2 + y_3.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can linearize these non-linear constraints by &lt;span class=&quot;math-container&quot;&gt;$z=h_1 h_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z=h_1 h_2 h_3$&lt;/span&gt;. The generalization of this technique is&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$z_{1,\ldots,n}= \prod_{i=1}^{n} h_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then you can replace that as follows&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;z_{1,\ldots,n} \leq h_i, \quad \forall i\in\{1,\ldots, n\}\\&#xA;z_{1,\ldots,n} \geq \sum_{i = 1}^n h_i - n + 1\\&#xA;\end{align}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The proof using logical propositions is easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to remove many redundant constraints such as &lt;span class=&quot;math-container&quot;&gt;$x_1 x_2 x_3 &amp;gt; x_1 y_2 x_3$&lt;/span&gt; because you have &lt;span class=&quot;math-container&quot;&gt;$x_1 x_2 x_3 &amp;gt; x_1 y_2 y_3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_1 y_2 y_3 &amp;gt; x_1 y_2 x_3$&lt;/span&gt;. The same reason for &lt;span class=&quot;math-container&quot;&gt;$x_1 x_2 x_3 &amp;gt; y_1 x_2 y_3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_1 y_2 y_3 &amp;gt; x_1 y_2 x_3$&lt;/span&gt; and  &lt;span class=&quot;math-container&quot;&gt;$y_1 y_2 y_3 &amp;gt; y_1 x_2 y_3$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1252" LastEditorUserId="1252" LastEditDate="2019-09-12T13:30:51.930" LastActivityDate="2019-09-12T13:30:51.930" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2540" PostTypeId="1" CreationDate="2019-09-12T13:22:29.643" Score="12" ViewCount="264" Body="&lt;p&gt;I am wondering what kinds of linearisations people do for MINLPs outside my field of expertise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I work in global optimisation, so by &quot;linearisation&quot; we would typically mean one of the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Exact linearisations, i.e., to reformulate a nonlinear structure to LP or MILP&lt;/li&gt;&#xA;&lt;li&gt;Convex/concave LP/MILP relaxations of nonlinear functions, e.g., outer approximations, secants, or piecewise relaxations&lt;/li&gt;&#xA;&lt;li&gt;Integer cuts to eliminate nonlinear constraints or reduce the domain&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What kinds of linearisations do you do? Does the term mean something different in your field? Can you share some examples/references?&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-09-18T10:23:33.837" Title="Linearisation techniques for MINLPs" Tags="|mixed-integer-programming|nonlinear-programming|linearization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2541" PostTypeId="2" ParentId="2535" CreationDate="2019-09-12T17:43:16.160" Score="8" Body="&lt;p&gt;As LarrySnyder610 said, you cannot do exactly what you want when &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is continuous. (You can if it is an integer variable.) I discussed how to model this particular issue here: &lt;a href=&quot;https://orinanobworld.blogspot.com/2015/02/flagging-specific-variable-value.html&quot; rel=&quot;noreferrer&quot;&gt;Flagging a Specific Variable Value&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-12T17:43:16.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2542" PostTypeId="2" ParentId="2530" CreationDate="2019-09-12T19:42:55.617" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://dkmgames.com/LogicGames.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;dkmGames&lt;/a&gt; has a bunch of online logic puzzles that would be amenable to constraint programming. Nonograms in particular would be easy to explain and (I think) easy to code.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-12T19:42:55.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2543" PostTypeId="2" ParentId="2522" CreationDate="2019-09-13T00:13:17.243" Score="6" Body="&lt;p&gt;So I experimented somewhat with the formulation generation in pulp and profiled it. The biggest time sink hole was string creation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be resolved by using f strings in Python 3.6+&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This lead to a more than 2X speed up for formulating models.&lt;/p&gt;&#xA;" OwnerUserId="259" LastActivityDate="2019-09-13T00:13:17.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2544" PostTypeId="2" ParentId="2534" CreationDate="2019-09-13T02:20:14.733" Score="4" Body="&lt;p&gt;Here's an approach that might be close to what you are looking for. Suppose that we have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; products, and for each product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; we know:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; = purchase cost per unit (i.e., cost to order inventory from the supplier)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\pi_i$&lt;/span&gt; = profit margin per unit sold&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$F_i$&lt;/span&gt; = probability distribution (pdf, cdf) of demand per period&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If there is only 1 product, then this is just a newsvendor problem. With multiple products, it's just multiple newsvendor problems subject to a budget constraint. The decision variables are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; = order quantity for product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(You didn't specify whether this is a single- or multi-period model. I'm assuming single period, but it's not too hard to adapt this to the multi-period case. In that case we assume we follow a base-stock policy for each product, and the &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; variables are interpreted as base-stock levels.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For each product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, the expected profit function is&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;  \Pi_i(S_i) &amp;amp; = \pi_i\mathbb{E}[\min\{S_i,D_i\}] - c_iS_i \\&#xA;    &amp;amp; = \pi_i\left[\mathbb{E}[D_i] - n_i(S_i)\right] - c_iS_i,&#xA;\end{align*}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$n_i(x)$&lt;/span&gt; is the &lt;a href=&quot;https://or.stackexchange.com/q/102/38&quot;&gt;loss function&lt;/a&gt; for distribution &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt;, i.e.,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$n_i(x) = \int_x^\infty (y-x)f_i(y)dy.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The second &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; follows from the fact that &lt;span class=&quot;math-container&quot;&gt;$\min\{S,D\} = D - (D-S)^+$&lt;/span&gt;.) &#xA;The loss function &lt;span class=&quot;math-container&quot;&gt;$n_i(x)$&lt;/span&gt; is convex (its derivative is &lt;span class=&quot;math-container&quot;&gt;$F_i(x)-1&amp;gt;0$&lt;/span&gt;), so &lt;span class=&quot;math-container&quot;&gt;$\Pi_i(S_i)$&lt;/span&gt; is concave. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we want to solve the following optimization problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\text{maximize} \quad &amp;amp; \sum_{i=1}^n \Pi_i(S_i) \\&#xA;\text{subject to} \quad &amp;amp; \sum_{i=1}^n c_iS_i \le B \\&#xA;&amp;amp; S_i \ge 0 \quad \forall i=1,\ldots,n,&#xA;\end{align*}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is the budget. This is a convex problem (concave maximization), and should be easy to solve.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-09-13T02:20:14.733" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="2545" PostTypeId="2" ParentId="2522" CreationDate="2019-09-13T06:46:51.387" Score="9" Body="&lt;p&gt;If you do a lot of looping in Python to build your model, then model building is going to be slow. We have illustrated this for Pyomo (and the same undoubtedly holds for Pulp) in a notebook that implements the socalled &lt;a href=&quot;https://github.com/MOSEK/Tutorials/blob/master/wasserstein/wasserstein-bary.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wasserstein model&lt;/a&gt;. Note this shows &lt;a href=&quot;https://docs.mosek.com/9.0/pythonfusion/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek Fusion&lt;/a&gt; and &lt;a href=&quot;https://cvxpy.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cvxpy&lt;/a&gt; is much faster than Pyomo for this particular model.&lt;/p&gt;&#xA;&lt;p&gt;We tried to use the &lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/developer_reference/expressions/performance.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;fast expressions&lt;/a&gt; in Pyomo but it made no difference.&lt;/p&gt;&#xA;&lt;p&gt;The key to the speed of MOSEK Fusion (and Cvxpy) is that it employs a vectorized notation which allows Fusion to move a lot of the model generation and input from Python to C based code.&lt;/p&gt;&#xA;&lt;p&gt;Btw we are currently implementing the model using Julia JuMP. It is slower than both Mosek Fusion and &lt;a href=&quot;https://cvxpy.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cvxpy&lt;/a&gt;. We are quite surprised by that and do not know yet why.&lt;/p&gt;&#xA;&lt;p&gt;Edit 2021-01-19: Here is the &lt;a href=&quot;https://github.com/MOSEK/Tutorials/tree/master/wasserstein-julia&quot; rel=&quot;nofollow noreferrer&quot;&gt;Julia notebook&lt;/a&gt; of Wasserstein problem.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2021-01-19T07:51:44.110" LastActivityDate="2021-01-19T07:51:44.110" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="2546" PostTypeId="1" AcceptedAnswerId="2547" CreationDate="2019-09-13T07:44:48.853" Score="8" ViewCount="186" Body="&lt;p&gt;I'm trying to write an optimization model using an open-source solver's Python API. I'm new to use Python. The model objective function is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{k=1}^{K} \sum_{j=1}^{n}\left(f_{k}+c_{0, j}^{k}\right) x_{0, j}^{k}+\sum_{k=1}^{K} \sum_{i=1}^{n} \sum_{j \in\{0, \ldots, n\} \backslash\{i\}} c_{i j}^{k} x_{i j}^{k}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$(i, j, k)$&lt;/span&gt; are indices, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a variable and &lt;span class=&quot;math-container&quot;&gt;$c,f$&lt;/span&gt; are given parameters. In the second term of the objective function, there is a specific filter on the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; index. Doing this filter using C++/Java is easy. I was wondering, how can I do that in Python? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The snippet Python code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;minimize (sum(c(k,i,j)*x[k][i][j] for k in range(K) for i in range(n) for j in range(n)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2019-09-13T08:00:31.147" LastActivityDate="2019-09-13T08:00:31.147" Title="Specific filter on the set using Python" Tags="|optimization|modeling|python|open-source|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2547" PostTypeId="2" ParentId="2546" CreationDate="2019-09-13T07:46:54.630" Score="8" Body="&lt;p&gt;Easy:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;minimize (sum(c(k,i,j)*x[k][i][j] for k in range(K) for i in range(n) for j in range(n) if j != i))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But note that your sums start from indices &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and end at &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, while &lt;code&gt;range(n)&lt;/code&gt; gives you &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2019-09-13T07:46:54.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2548" PostTypeId="2" ParentId="2522" CreationDate="2019-09-13T09:45:26.230" Score="2" Body="&lt;p&gt;Do you need a Python library in particular?&#xA;If you are happy using &lt;a href=&quot;https://julialang.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Julia&lt;/a&gt;, you should give &lt;a href=&quot;https://github.com/JuliaOpt/JuMP.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;JuMP&lt;/a&gt; a try.&#xA;It will give you high-level modeling with &lt;a href=&quot;https://mlubin.github.io/pdf/jump-sirev.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;fast model generation&lt;/a&gt; and connection to most solvers.&lt;/p&gt;&#xA;&lt;p&gt;In addition if you resolve basically the same problem just with some changed parameters &lt;a href=&quot;https://github.com/tkoolen/Parametron.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;Parametron&lt;/a&gt; allows you to do that fast enough to be usable in the inner planning loop of humanoid robots.&lt;/p&gt;&#xA;" OwnerUserId="126" LastEditorUserId="4777" LastEditDate="2021-01-19T10:38:54.953" LastActivityDate="2021-01-19T10:38:54.953" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2549" PostTypeId="1" CreationDate="2019-09-13T10:07:10.490" Score="12" ViewCount="1778" Body="&lt;p&gt;I'm researching ways of solving constrained optimization problems on a cloud platform. I stumbled across this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://cloud.google.com/blog/products/data-analytics/distributed-optimization-with-cloud-dataflow&quot; rel=&quot;noreferrer&quot;&gt;https://cloud.google.com/blog/products/data-analytics/distributed-optimization-with-cloud-dataflow&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where they claim that gradient descent (and potentially even Tensorflow) can be used to solve MIP. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that a good idea? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My understanding is that even though MIP is NP-Hard, it has enough structure that you are better off using Branch-and-X and other linear specific solvers than search methods or heuristic methods. Is this correct? &lt;/p&gt;&#xA;" OwnerUserId="1315" LastEditorUserId="1315" LastEditDate="2019-09-13T10:33:18.247" LastActivityDate="2019-10-13T13:42:01.663" Title="Is using gradient descent for MIP a good idea?" Tags="|mixed-integer-programming|solver|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2550" PostTypeId="2" ParentId="2549" CreationDate="2019-09-13T10:10:54.607" Score="10" Body="&lt;p&gt;I think that this article is not about using gradient descent to solve MIP problems. It seems to me that they are explicitly enumerating all possible value combinations for the discrete decisions and then apply gradient descent to all of the continuous subproblems where the discrete decisions are fixed the candidate values.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-09-13T10:10:54.607" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2551" PostTypeId="2" ParentId="2549" CreationDate="2019-09-13T10:29:26.727" Score="6" Body="&lt;p&gt;If you're solving a very odd and trivial LP without any constraints, then gradient descent would be directly applicable (N.B. but still useless, because such a problem would be unbounded). As soon as constraints enter the picture, you have to extend gradient descent to &quot;respect&quot; these constraints. There are various ways of doing this, but these extensions are no longer called &quot;Gradient Descent&quot;. For example, you can express the constraints as penalties (Lagrange multipliers) or project the point back into the feasible set. Both approaches would only be able to solve LPs, not (M)ILPs however.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer your questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GD in general is probably not a good idea for (MI)LP, but it might be interesting for very special problems.&lt;/li&gt;&#xA;&lt;li&gt;Again, this depends on the problem - but I'd lean towards agreeing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="69" LastActivityDate="2019-09-13T10:29:26.727" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2552" PostTypeId="2" ParentId="2530" CreationDate="2019-09-13T13:39:51.943" Score="3" Body="&lt;p&gt;I just ran across two papers by Sönke Hartmann in &lt;em&gt;INFORMS Transactions on Education&lt;/em&gt; (&lt;a href=&quot;https://doi.org/10.1287/ited.2017.0182&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hartman 2017&lt;/a&gt; and &lt;a href=&quot;https://doi.org/10.1287/ited.2019.0212&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hartmann 2019&lt;/a&gt;) that present IP formulations for logic puzzles that are available as smartphone apps. I'm not sure if these can be formulated as CPs, but it might be worth a look.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, on closer look, there are a lot of puzzle-related articles in that journal; here's a &lt;a href=&quot;https://pubsonline.informs.org/action/doSearch?AllField=puzzle&amp;amp;SeriesKey=ited&quot; rel=&quot;nofollow noreferrer&quot;&gt;search query&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-09-13T13:39:51.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2553" PostTypeId="1" CreationDate="2019-09-13T21:19:41.493" Score="9" ViewCount="199" Body="&lt;p&gt;I have implemented a Benders decomposition for a constrained network flow but the LP solver (Gurobi) warns me of the ill-conditioning of the subproblem dual LP. As you can see below, the coefficients seem well behaved but I still get warnings like the one highlighted. I have already tried different values for classic parameters like &lt;strong&gt;NumericFocus&lt;/strong&gt; and &lt;strong&gt;MarkowitzTol&lt;/strong&gt; but without success. One such LP that displays this problem can be found &lt;a href=&quot;https://www.dropbox.com/s/fipxqt1kd5ogxhr/slavedual.lp?dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  Matrix range     [3e-01, 9e+02]&#xA;  Objective range  [1e-02, 9e+02]&#xA;  Bounds range     [0e+00, 0e+00]&#xA;  RHS range        [1e+01, 2e+02]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;Warning: very big Kappa = 2.97774e+13, try parameter NumericFocus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2340" LastEditorUserId="500" LastEditDate="2023-04-02T19:49:19.050" LastActivityDate="2023-04-02T19:49:19.050" Title="Ill-conditioned LP in Benders decomposition" Tags="|linear-programming|gurobi|benders-decomposition|numerical-issues|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2555" PostTypeId="2" ParentId="2540" CreationDate="2019-09-14T03:52:07.803" Score="2" Body="&lt;p&gt;I am not sure if you talk about this &lt;a href=&quot;https://or.stackexchange.com/questions/1455/finding-an-objective-function-for-assigning-employees-to-sequence-dates/2539#2539&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$z=\prod\limits_{i=1}^{n}x_i$&lt;/span&gt;&lt;/a&gt; or the technique described on pages 3, 4 and 5 in this report &lt;a href=&quot;https://www.researchgate.net/publication/332859832_Mixed_Integer_Programming_Models_and_Methods&quot; rel=&quot;nofollow noreferrer&quot;&gt;piecewise linear function&lt;/a&gt;. These are the two main approaches used.&lt;/p&gt;&#xA;" OwnerUserId="1252" LastEditorUserId="123" LastEditDate="2019-09-14T07:25:32.637" LastActivityDate="2019-09-14T07:25:32.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2556" PostTypeId="2" ParentId="2540" CreationDate="2019-09-14T08:05:17.153" Score="4" Body="&lt;p&gt;In the context of gas networks my former colleagues used (and still use) &lt;a href=&quot;https://www.optimization-online.org/DB_HTML/2017/05/6029.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;adaptive linearization techniques&lt;/a&gt; combined with other (sometimes nonlinear) heuristics. There is a whole &lt;a href=&quot;https://doi.org/10.1137/1.9781611973693&quot; rel=&quot;nofollow noreferrer&quot;&gt;book about the topic&lt;/a&gt; which also won the &lt;a href=&quot;https://www.euro-online.org/web/pages/603/last-activities-list&quot; rel=&quot;nofollow noreferrer&quot;&gt;EURO Excellence in Practice Award 2016&lt;/a&gt; for best book on applications of optimization.&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="137" LastEditDate="2019-09-18T10:23:33.837" LastActivityDate="2019-09-18T10:23:33.837" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2557" PostTypeId="1" CreationDate="2019-09-14T10:48:36.730" Score="4" ViewCount="454" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Problem statement: Meet the demand which can be met across 2 facilities each having multiple machines where several components are made. The objective is to find the optimal solution to meet the demand with the lowest utilization of machines. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Demand is total and can be met by loading on either facility.&lt;/li&gt;&#xA;&lt;li&gt;Facility A has to be loaded and only when it is completely utilized,&#xA;then we load facility B. &lt;/li&gt;&#xA;&lt;li&gt;Each machine can make one or more components on it (until its available hours are exhausted). &lt;/li&gt;&#xA;&lt;li&gt;Not all machines make all components. &lt;/li&gt;&#xA;&lt;li&gt;Each machine has a &quot;run-time&quot; which is the time to produce 1 unit of a component. The lower run-time the better.                                                                                              &lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Different components take different time to produce on a machine. We choose the machine which takes the least run-time to produce. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each machine has a total &quot;Available-hours&quot; for an entire month which is total runtime available for that machine. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This &quot;available-hours&quot; constraint is hard.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Demand for one component cannot be split across different machines.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Given this information, we need to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pick the machine (which can make a component) with the lowest run time first.&lt;/li&gt;&#xA;&lt;li&gt;See if demand is met by choosing that machine to produce that component or not. (check the available hours of a machine, subtract available hours with the total time to meet demand. the remaining time is now the updated available hours for that machine). the total time to meet demand is simply run-time &lt;span class=&quot;math-container&quot;&gt;$\times$&lt;/span&gt; demand for that component.&lt;/li&gt;&#xA;&lt;li&gt;Repeat 1 &amp;amp; 2 for all components.&lt;/li&gt;&#xA;&lt;li&gt;If a demand is so high that a machine gets completely utilized, then choose the next best machine where a component can be made(machine with 2nd lowest run-time).&lt;/li&gt;&#xA;&lt;li&gt;All demand should be met(not exceeded) for all components.&lt;/li&gt;&#xA;&lt;li&gt;Try to see that machines should be optimally utilized overall.&lt;/li&gt;&#xA;&lt;li&gt;Evaluation metric to compare results between 2 runs are:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;% demand met&lt;/li&gt;&#xA;&lt;li&gt;% utilization overall variance between utilization across machines&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have tried using Google's OR-TOOLS package but the solution never converges. Maybe the model is not right (based on &lt;a href=&quot;https://stackoverflow.com/questions/57929840/google-or-tools-solution-unable-to-converge-for-assignment-with-task-sizes-usi/57930315#57930315&quot;&gt;this answer&lt;/a&gt; on Stack Overflow.)&#xA;For machines where a component cannot be made, I have used a really large number (10000000) as part of cost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using any other package/approach is fine as long as the solution can scale for large data-sets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize this is a special case of bin-packing problem where the bin sizes vary and also not all bins allow all items to be kept. &#xA;Any help is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2345" LastEditorUserId="981" LastEditDate="2019-09-15T07:17:10.840" LastActivityDate="2019-09-15T07:17:10.840" Title="Machine Allocation &amp; optimal Utilization using python" Tags="|optimization|linear-programming|constraint-programming|python|or-tools|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2558" PostTypeId="1" CreationDate="2019-09-14T17:24:40.063" Score="26" ViewCount="2735" Body="&lt;p&gt;Suppose that you have two algorithms for solving an optimization model, and you want to benchmark their performance over a large set of instances (with only one performance metric, for example, the running time). I want to show that one algorithm is &quot;faster&quot; than the other by using some statistical test.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question: Which test is the correct one to use? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More precisely: Most of the paper in OR just compare mean times, which is clearly too weak. On the other extreme, you can use a &lt;a href=&quot;https://en.wikipedia.org/wiki/Sign_test&quot; rel=&quot;noreferrer&quot;&gt;Sign Test&lt;/a&gt;, but it doesn't consider the magnitude of the difference, only if you are faster or not on the different instances.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My knowledge of statistics is low (for being a mathematician), but if I'm not wrong, you need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a nonparametric test (because I cannot assume normality or any other distribution)&lt;/li&gt;&#xA;&lt;li&gt;paired (because the time of each algorithm in the same instance are not independent)&lt;/li&gt;&#xA;&lt;li&gt;one-sided (because I want to show that one algorithm is better than the other)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also, does it make a difference if the instances are randomly independently generated or not?&lt;/p&gt;&#xA;" OwnerUserId="73" LastEditorUserId="73" LastEditDate="2019-09-18T12:55:31.050" LastActivityDate="2019-09-22T17:34:07.020" Title="Statistical tests for benchmark comparison" Tags="|optimization|algorithms|benchmark|" AnswerCount="6" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="2559" PostTypeId="1" CreationDate="2019-09-14T17:38:42.377" Score="9" ViewCount="322" Body="&lt;p&gt;Are there any rules of thumb for when to use classical methods like branch and bound, branch and cut, etc...for non-convex problems, vs using meta-heuristic methods like genetic algorithms, evolutionary algorithms, simulated annealing, etc....?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When both classes of algorithms are applicable, what are the main trade-offs between the two? &lt;/p&gt;&#xA;" OwnerUserId="1315" LastActivityDate="2019-09-14T19:40:31.827" Title="Rules of thumb for using classic methods (e.g. branch and bound) vs. meta-heuristics (G.A, S.A, etc..) for non-convex problems?" Tags="|metaheuristics|branch-and-cut|nonconvex-programming|branch-and-bound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2560" PostTypeId="2" ParentId="2558" CreationDate="2019-09-14T19:20:25.473" Score="7" Body="&lt;p&gt;Options for you: McNemar&lt;sup&gt;NP&lt;/sup&gt;, &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; test (with variants)&lt;sup&gt;P&lt;/sup&gt;, Wilcoxon&lt;sup&gt;NP&lt;/sup&gt;, sign test&lt;sup&gt;NP&lt;/sup&gt;, Friedman&lt;sup&gt;NP&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;&lt;a href=&quot;http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.37.3325&quot; rel=&quot;noreferrer&quot;&gt;Dietterich (1998)&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Five statistical tests are compared primarily on the type I error produced. Emphasis mine.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Two widely used statistical tests are shown to have high probability of type I error in certain situations and should &lt;strong&gt;never&lt;/strong&gt; be used: a test for the &lt;strong&gt;difference of two proportions&lt;/strong&gt; and a &lt;strong&gt;paired-differences &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; test based on taking several random train-test splits&lt;/strong&gt;. A third test, a &lt;strong&gt;paired differences &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; test based on &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt;-fold cross-validation&lt;/strong&gt;, exhibits somewhat elevated probability of type I error.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In your case, this shouldn't matter as a &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; test assumes normality to a certain extent.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The cross-validated &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; test is the most powerful. The &lt;span class=&quot;math-container&quot;&gt;$5×2$&lt;/span&gt; cv test is shown to be slightly more powerful than McNemar’s test. The choice of the best test is determined by the computational cost of running the learning algorithm. &lt;strong&gt;For algorithms that can be executed only once, McNemar’s test is the only test with acceptable type I error.&lt;/strong&gt; For algorithms that can be executed &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; times, the &lt;span class=&quot;math-container&quot;&gt;$5×2$&lt;/span&gt; cv test is recommended, because it&#xA;is slightly more powerful and because it directly measures variation due to the choice of training set.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Note that McNemar's test is non-parametric, similar to goodness-of-fit that uses a &lt;span class=&quot;math-container&quot;&gt;$\chi^2$&lt;/span&gt;-distribution.&lt;/p&gt;&#xA;&lt;h2&gt;&lt;a href=&quot;http://www.jmlr.org/papers/volume7/demsar06a/demsar06a.pdf&quot; rel=&quot;noreferrer&quot;&gt;Demšar (2006)&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;This paper is more interesting as it considers some alternative, non-parametric approaches, such as the Wilcoxon signed-rank test.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When the assumptions of the paired &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;-test are met, the Wilcoxon signed-ranks test is less powerful than the paired &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;-test. On the other hand, when the assumptions are violated, the Wilcoxon test can be even more powerful than the &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;-test.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Another non-parametric test is the Friedman test. It is similar to ANOVA, and still uses ranking as part of the expression for the test statistic.&lt;/p&gt;&#xA;&lt;p&gt;A simpler method is to use the sign test, and the larger the number of data the closer the equivalence of this test to the &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;-test. However, the cost of the simplicity is highlighted below.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This test does not assume any commensurability of scores or differences nor does it assume normal distributions and is thus applicable to any data (as long as the observations, i.e. the data sets, are independent). On the other hand, it is much weaker than the Wilcoxon signed-ranks test.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In conclusion...&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Overall, the non-parametric tests, namely the Wilcoxon and Friedman test are suitable for our problems. They are appropriate since they assume some, but limited commensurability. They are safer than parametric tests since they &lt;strong&gt;do not assume normal distributions or homogeneity of variance&lt;/strong&gt;. As such, they can be applied to classification accuracies, error ratios or any other measure for evaluation of classifiers, including &lt;strong&gt;even model sizes and computation times&lt;/strong&gt;. Empirical results suggest that they are also stronger than the other tests studied.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Dietterich, T. G. (1998). Approximate Statistical Tests for Comparing Supervised&#xA;Classification Learning Algorithms. &lt;em&gt;Neural Computation&lt;/em&gt;. 10:1895-1923. &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [2] Demšar, J. (2006). Statistical Comparisons of Classifiers over Multiple Data Sets. &lt;em&gt;Journal of Machine Learning Research&lt;/em&gt;. 7:1-30. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-09-14T19:26:48.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2561" PostTypeId="2" ParentId="2558" CreationDate="2019-09-14T19:22:14.617" Score="9" Body="&lt;p&gt;I think there are many different factors to consider. There's a very good paper by &lt;a href=&quot;https://doi.org/10.1287/ijoc.12.1.24.11899&quot; rel=&quot;noreferrer&quot;&gt;Coffin and Saltzman&lt;/a&gt; (Statistical Analysis of Computational Tests of Algorithms&#xA;and Heuristics, &lt;em&gt;INFORMS JOC&lt;/em&gt; 12(1): 24-44, 2000) that discusses this issue in detail. &lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-09-14T19:22:14.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2562" PostTypeId="2" ParentId="2559" CreationDate="2019-09-14T19:40:31.827" Score="3" Body="&lt;h2&gt;&lt;a href=&quot;http://www.scholarpedia.org/article/Metaheuristics&quot; rel=&quot;nofollow noreferrer&quot;&gt;Glover and Sörensen (2015)&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Metaheuristics have been demonstrated by the scientific community to be a viable, and often superior, alternative to more traditional (exact) methods of mixed-integer optimization such as branch and bound and dynamic programming. Especially for complicated problems or large problem instances, metaheuristics are often able to offer &lt;strong&gt;a better trade-off between solution quality and computing time&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, metaheuristics are more flexible than exact methods in two important ways. First, because metaheuristic frameworks are defined in general terms, metaheuristic algorithms can be adapted to fit the needs of most real-life optimization problems in terms of expected solution quality and allowed computing time, which can vary greatly across different problems and different situations.&lt;/p&gt;&#xA;&lt;p&gt;Secondly, metaheuristics do not put any demands on the formulation of the optimization problem (like requiring constraints or objective functions to be expressed as linear functions of the decision variables). However, this flexibility comes at the cost of requiring considerable problem-specific adaptation to achieve good performance.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Glover, F., Sörensen, K. (2015). Metaheuristics. &lt;em&gt;Scholarpedia.&lt;/em&gt; 10(4):6532. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-09-14T19:40:31.827" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2563" PostTypeId="2" ParentId="2558" CreationDate="2019-09-14T20:24:06.333" Score="14" Body="&lt;p&gt;I know that you explicitly ask for a statistical test, but maybe this is because you don't know about alternatives that are rather established in the community. When comparing algorithms, my number one is &lt;em&gt;performance profiles&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They were introduced in this article:     Elizabeth D. Dolan and Jorge J. Moré, &lt;a href=&quot;https://link.springer.com/article/10.1007/s101070100263&quot; rel=&quot;noreferrer&quot;&gt;Benchmarking optimization software with performance profiles&lt;/a&gt;, Mathematical Programming, 91(2):201–213, 2002.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-09-14T20:24:06.333" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2564" PostTypeId="2" ParentId="2557" CreationDate="2019-09-14T20:29:36.027" Score="1" Body="&lt;p&gt;According to your problem mentioned and if you are interested to develop an optimization model, I think your problem likes the &quot;Comprehensive Equipment Selection Model&quot;. You would find some examples in this &lt;a href=&quot;https://www.dropbox.com/s/dxs6ugp142npr6s/Comprehensive%20Equipment%20Selection%20Model.pdf?dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;. It should be noted that, the problem needs some modifications as your constraints (Or limitations). I hope it would be useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference: &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/1498732895&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Facilities Design 4th Edition by Sunderesh S. Heragu&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2019-09-14T20:35:49.500" LastActivityDate="2019-09-14T20:35:49.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2565" PostTypeId="1" AcceptedAnswerId="2567" CreationDate="2019-09-15T09:52:02.407" Score="9" ViewCount="241" Body="&lt;p&gt;Suppose you have a standard hotel with a set of rooms. If you have booked a room for a fixed period of time, would allocating a specific room in advance potentially cause a conflict when trying to allocate rooms for other bookings in the future?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have thought about this and can not think of an example where allocating in advance would make any difference, given the rooms are all interchangeable within their class (single/double etc.). Assuming that every booking &lt;strong&gt;has to be&lt;/strong&gt; assigned a room eventually, there must be a solution so that every booking is associated with a matching room. Which specific room within the set of matching rooms should be irrelevant, hence a pre-allocation of a specific room should make no difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this in fact the case or am I missing something? I would like to have an example of where pre-allocation would cause an issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Background&lt;/em&gt;: I was told at checkin that my requested room could not be allocated because I would have been blocking it for other guests.&lt;/p&gt;&#xA;" OwnerUserId="2352" LastActivityDate="2019-09-18T06:50:28.700" Title="Could reserving a hotel room potentially lead to a suboptimal allocation of rooms?" Tags="|optimization|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2566" PostTypeId="2" ParentId="2565" CreationDate="2019-09-15T18:44:25.530" Score="7" Body="&lt;p&gt;I respond to your question, assuming you are interested in &quot;types of &lt;em&gt;constraints&lt;/em&gt; that can restrict a pre-allocation or assignment of a room to a person in advance.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since there is a time aspect in that problem, think of these assignments as scheduling jobs on machines (so a pre-allocation is assignment without the complete knowledge of all the other jobs). For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) A group of jobs needs to be processed together on a machine. Think of a group of people traveling and would like their rooms to be &lt;em&gt;next to each other during their time&lt;/em&gt; in the hotel. Pre-assignment of rooms may avoid that to happen because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Some of the rooms are pre-assigned and not available.&lt;/li&gt;&#xA;&lt;li&gt;The rooms next to each other can be available but only for a portion of the time (they want it for a whole week but only two days those rooms are available)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;2) Extending on point 1, there are cases that there is uncertainty in the processing time of a job on a machine. i.e. a regular businesswoman staying at the hotel and historically, she may require several extra days beyond what she reserves for. As the manager, I prefer to keep her current room available for a few extra days (beyond what she has reserved) rather than pre-assigning it to someone, in case she likes to stay a few more days!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) And now extending on point 2, I like to take into account the uncertainty of job assignment, i.e. the person may show up or cancel the reservation (of course, unless you are willing to reserve the room and pay the non-refundable price in advance, which in that case, it falls under the 1st point again)&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-09-15T18:44:25.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2567" PostTypeId="2" ParentId="2565" CreationDate="2019-09-16T08:30:11.207" Score="7" Body="&lt;p&gt;In case the number of reservations for any of the days does not exceed the number of available rooms, by applying &lt;a href=&quot;https://en.wikipedia.org/wiki/Dilworth%27s_theorem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dilworth's theorem&lt;/a&gt; one can show that there always exists an allocation of rooms to reservations in such a way that none of the guests has to switch rooms during their stay. When a single room is pre-allocated, this indeed will still always be possible as the rooms are interchangeable. However, when two rooms are pre-allocated, conflicts may occur as the following example shows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Guest 1 books day 1 &lt;/li&gt;&#xA;&lt;li&gt;Guest 2 books day 2 and day 3 &lt;/li&gt;&#xA;&lt;li&gt;Guest 3 books day 1&#xA;and day 2 &lt;/li&gt;&#xA;&lt;li&gt;Guest 4 books day 3&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Clearly, assigning guests 1 and 2 to the same room and guests 3 and 4 to the same room requires only two rooms. However, if guests 1 and 4 are pre-allocated to the same room, three rooms are required. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, note that a reason for such a seemingly shortsighted assignment (besides the ones that @EhsanK mentions) is that in reality often not all rooms are interchangeable. For example, guests 1 and 4 could both have requested a quiet room at the backside of the hotel. &lt;/p&gt;&#xA;" OwnerUserId="764" LastEditorUserId="764" LastEditDate="2019-09-18T06:50:28.700" LastActivityDate="2019-09-18T06:50:28.700" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2568" PostTypeId="2" ParentId="2558" CreationDate="2019-09-16T09:05:37.350" Score="6" Body="&lt;p&gt;&lt;em&gt;Choosing is loosing.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We should be collecting raw benchmarks results at a grand scale, independent of how we evaluate them. And we should have a free, open, objective website hosting all that data, from different researchers and different vendors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd love to help build out an &lt;strong&gt;open datawarehouse of benchmarks&lt;/strong&gt;, using our benchmark toolkit on top of Continuous Integration (Jenkins? Travis?). Once that's build, determining the best algorithm becomes a query problem for academic researchers. It enables Data Science.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ironically, we have the means to generate a gold mine of data in optaplanner:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/src/main/java/org/optaplanner/examples&quot; rel=&quot;noreferrer&quot;&gt;22 use cases&lt;/a&gt; (including CVRP, VRPTW, NRP, ...)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/data&quot; rel=&quot;noreferrer&quot;&gt;thousands of data sets&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://docs.optaplanner.org/latestFinal/optaplanner-docs/html_single/#optimizationAlgorithmsOverview&quot; rel=&quot;noreferrer&quot;&gt;dozens of algorithms&lt;/a&gt; to apply on those 22 use cases&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://docs.optaplanner.org/latestFinal/optaplanner-docs/html_single/#statisticalBenchmarking&quot; rel=&quot;noreferrer&quot;&gt;Statistical benchmarking&lt;/a&gt; (different random seeds), JVM warm up support, ...&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://docs.optaplanner.org/latestFinal/optaplanner-docs/html_single/#benchmarker&quot; rel=&quot;noreferrer&quot;&gt;optaplanner-benchmark&lt;/a&gt; that spits out an &lt;code&gt;xml&lt;/code&gt; file with all benchmark results, &lt;code&gt;csv&lt;/code&gt; files with all the telemetry data and a pretty &lt;code&gt;html&lt;/code&gt; report&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But the main problem is a lack of CPU power (there's little business revenue in buying AWS instances for this) and lack of time to code automating the start/collection of those benchmarks.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2019-09-16T09:05:37.350" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2569" PostTypeId="2" ParentId="2558" CreationDate="2019-09-16T15:28:09.603" Score="6" Body="&lt;p&gt;A good thing for you to invoke in your case is the &lt;strong&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Central_limit_theorem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Central Limit Theorem&lt;/a&gt;&lt;/strong&gt;. It states, roughly speaking, that you can assume a normal distribution (a special case of the Gaussian Function) provided your sample size is &quot;large enough.&quot; Usually &quot;large enough&quot; is taken to mean &lt;span class=&quot;math-container&quot;&gt;$n\ge30$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use a &lt;em&gt;&lt;a href=&quot;https://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Two Sample &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;-test&lt;/a&gt;&lt;/em&gt; for this. You want to show that Algorithm &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$A_1$&lt;/span&gt;) is faster than Algorithm &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$A_2$&lt;/span&gt;) WLOG. So you get: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}H_0&amp;amp;: \mu_{A_1} - \mu_{A_2} = 0\\H_1&amp;amp;: \mu_{A_1} - \mu_{A_2} &amp;gt; 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm assuming you want &lt;span class=&quot;math-container&quot;&gt;$95\%$&lt;/span&gt; confidence, since you didn't specify in the question. You can change this if you want, but you should &lt;em&gt;know going in what you want it to be and stick to it.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your statistic takes the form of: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$T_0  = \frac{\mu_{A_1} - \mu_{A_2}}{s_p\sqrt{\frac1{n_1}+\frac1{n_2}}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$s_p$&lt;/span&gt; is the pooled variance (more on that in a moment), &lt;span class=&quot;math-container&quot;&gt;$n_1$&lt;/span&gt; is the sample size for algorithm &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n_2$&lt;/span&gt; is the sample size for algorithm &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s_p$&lt;/span&gt; operates under the assumption that your population variances for the two algorithms are the same, and is a weighted average of the two sample variances. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$s_p  = \sqrt{\frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{n_1+n_2 - 2}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a whole rabbit hole I would happily travel down about unequal variances and testing for variance equality, but I sense you just want to know if one algorithm is faster than the other, right now. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; &lt;strong&gt;Take a sample large enough to invoke the Central Limit Theorem and use a Two Sample &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;-Test.&lt;/strong&gt; You can download the statistical software RStudio (it's free!) and perform the &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;-Test within minutes of booting up and installing required packages. It will spit out a &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-value, and if your &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-value is less that &lt;span class=&quot;math-container&quot;&gt;$1-\text{confidence level} =1-0.95 = 0.05$&lt;/span&gt; you've made your case, so to speak. &lt;/p&gt;&#xA;" OwnerUserId="2360" LastEditorUserId="123" LastEditDate="2019-09-16T19:59:55.300" LastActivityDate="2019-09-16T19:59:55.300" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2570" PostTypeId="2" ParentId="2530" CreationDate="2019-09-16T15:34:43.020" Score="4" Body="&lt;p&gt;I've never tried it, but the &lt;a href=&quot;https://en.wikipedia.org/wiki/Knight%27s_tour&quot; rel=&quot;nofollow noreferrer&quot;&gt;knight's tour&lt;/a&gt; is certainly a conceptually simple problem which meets your constraints. I'm curious whether there exists an efficient CP formulation for this problem.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2019-09-16T15:34:43.020" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2571" PostTypeId="1" CreationDate="2019-09-16T23:05:18.467" Score="12" ViewCount="3699" Body="&lt;p&gt;MIP is NP-Hard, so it is possible that an instance is very difficult and has multiple local minima that the search can get stuck in. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a Metaheuristic Algorithm, the stochastic and approximate nature of the algorithm means that that is a risk we were assuming from the get go. And we are willing to start over if the algorithm doesn't converge towards an acceptable solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But with classical solvers like Gurobi or CPLEX, which, if I understand correctly, are deterministic, what happens when they come across such an instance? Do they just stay stuck in the local minima for a really long time and take several days to complete their run? Do they error out after a certain number of trials? &lt;/p&gt;&#xA;" OwnerUserId="1315" LastEditorUserId="8" LastEditDate="2019-10-13T12:56:19.930" LastActivityDate="2019-10-13T12:56:19.930" Title="What do solvers like Gurobi and CPLEX do when they run into hard instances of MIP?" Tags="|mixed-integer-programming|solver|cplex|gurobi|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2572" PostTypeId="2" ParentId="2571" CreationDate="2019-09-17T01:34:19.463" Score="16" Body="&lt;p&gt;The term &quot;local optimum&quot; is a little misleading here. Assuming your MIP is linear (or at least convex), every local minimum is also a global minimum, so there is no such thing as &quot;getting stuck in a local minimum.&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When we say that a (meta)heuristic gets &quot;stuck in a local minimum,&quot; we are referring to a local minimum &lt;em&gt;as defined by the search neighborhood&lt;/em&gt;. For example: If a &quot;move&quot; in the heuristic involves swapping two model elements (e.g., open one facility and close another), then a local minimum occurs when no move results in a better objective function. But this is not the same as saying that the solution to the MIP is a local minimum, because it's still possible that there are directions in the solution space that lead to improvement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To put it another way, if you are at a non-optimal point in the solution space in a linear/convex MIP, there must exist a direction that improves the objective. However, this direction might not be a legal &quot;move&quot; for the heuristic, and in that case we say the heuristic is &quot;stuck in a local minimum.&quot; In my opinion it's a slightly sloppy use of the terminology.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, to your original question, MIPs can still be hard even though the solver doesn't get &quot;stuck in a local minimum.&quot; When that happens, CPLEX, Gurobi etc. will keep working at it until one of the termination criteria is met. Those criteria could be a sufficiently small gap between the upper and lower bounds, a sufficiently long CPU time, a sufficiently large number of iterations, etc.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-09-17T01:34:19.463" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2573" PostTypeId="2" ParentId="2571" CreationDate="2019-09-17T02:16:09.763" Score="11" Body="&lt;p&gt;Gurobi and CPLEX use (very sophisticated) variants of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Branch_and_bound&quot; rel=&quot;noreferrer&quot;&gt;branch-and-bound algorithm&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Mixed Integer Programs, there can be both continuous and integer variables. It turns out that the integer variables are the complicating factor: without integer variables, what remains is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Linear_programming&quot; rel=&quot;noreferrer&quot;&gt;Linear Program&lt;/a&gt; (LP). LPs are always convex, which implies that every local optimum is a global optimum. Hence, you can never get stuck in a local minimum when solving an LP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, assume that we have a single complicating integer variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; that is allowed to take values between 1 and 3, that is &lt;span class=&quot;math-container&quot;&gt;$x\in \{1,2,3\}$&lt;/span&gt;. I will explain how &lt;em&gt;branching&lt;/em&gt; can be used to deal with this integer variable (more on &lt;em&gt;bounding&lt;/em&gt; later).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, we ignore the integer requirement, and instead we use &lt;span class=&quot;math-container&quot;&gt;$1 \le x \le 3$&lt;/span&gt;. We call this the &lt;em&gt;linear programming relaxation&lt;/em&gt;. And for good reason! There are no more integer variables, so we are left with an LP that is easy to solve. We solve the LP, and we find that &lt;span class=&quot;math-container&quot;&gt;$x = 2.5$&lt;/span&gt; in the current solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, we have not solved the original problem, as &lt;span class=&quot;math-container&quot;&gt;$x = 2.5$&lt;/span&gt; is not integer. To continue, we &lt;em&gt;branch&lt;/em&gt;. That is, we split the problem in two. Problem 1 requires that &lt;span class=&quot;math-container&quot;&gt;$x \in \{1,2\}$&lt;/span&gt; while Problem 2 requires that &lt;span class=&quot;math-container&quot;&gt;$x = 3$&lt;/span&gt;. Obviously, one of the two contains the optimal solution to the MIP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Problem 1, we get the relaxation &lt;span class=&quot;math-container&quot;&gt;$1 \le x \le 2$&lt;/span&gt;. If we are lucky, solving the LP will give either &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x=2$&lt;/span&gt;. If this is not the case, we will branch again into &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x=2$&lt;/span&gt;, resulting in Problem 3 and Problem 4. If Problem 2 is feasible, we get a solution with &lt;span class=&quot;math-container&quot;&gt;$x=3$&lt;/span&gt;. If we have performed all the necessary splits, for all variables, we can compare all MIP solutions that we have obtained, and pick the best one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of how we split the problem, a global optimum is guaranteed to be found. We cannot get stuck in a local optimum: if the integer variables do not yet have integer values, we branch, and if all integer variables have integer values, the remaining LP cannot get stuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then for the &lt;em&gt;bounding&lt;/em&gt; part of branch-and-bound. By calculating bounds on the objective value for each of the subproblems, we are often able to tell that a subproblem does not contain a global optimum. In that case, we do not have to branch further, and we can focus on the other subproblems. Bounding is extremely important in practice&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2019-09-17T02:21:14.627" LastActivityDate="2019-09-17T02:21:14.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2574" PostTypeId="2" ParentId="2571" CreationDate="2019-09-17T06:39:21.987" Score="13" Body="&lt;p&gt;As pointed out by others here, in principle a branch-and-cut based solver can't get stuck, it can just continue until in the worst case it enumerated all integer solutions. Of course that might take forever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, sophisticated solvers have all kinds of tricks to avoid &quot;getting stuck&quot;, meaning not having any progress for a long time. One such trick that not many people talk about is restarting the branching phase of the solver. Restarts are mentioned in &lt;a href=&quot;http://dx.doi.org/10.14279/depositonce-1634&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tobias Achterbergs thesis&lt;/a&gt; in section 10.9, but back then he came (in his context) to the conclusion that they don't work very well. Nevertheless, I know that at least one commercial solver (namely SAS) does use restarts successfully and there are hints in the logs that other solvers do as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Restarts are especially good if some variables have been fixed globally (or at least have tightened bounds globally), even if it is not possible to keep some of the search information from the previous attempt to solve the problem, this will lead to a different tree. There is a decent chance that on its second (or 3rd or 4th) attempt the solver will do better or even solve the problem to within the required gap. Note that this is not very elegant or anything but it seems to work in practice.&lt;/p&gt;&#xA;" OwnerUserId="302" LastEditorUserId="302" LastEditDate="2019-10-11T08:13:29.517" LastActivityDate="2019-10-11T08:13:29.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2575" PostTypeId="2" ParentId="2571" CreationDate="2019-09-17T11:21:19.963" Score="4" Body="&lt;p&gt;All non-trivial MIPs are hard, intuitively because our optimality conditions become integrality conditions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Finding an integer solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A common way of doing this is to relax the integer variables to continuous and solve the relaxed problem. This solution will typically be optimal but not integral, in which case we solve a series of problems trying to find an integer solution in the neighborhood of the continuous one. One example of this would be a feasibility pump.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Finding the best integer solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most common way to do this is using branch-and-bound. MILP solvers make this look easy sometimes, but it's mostly by educated guessing that any large problem is solved quickly. In branch-and-bound there are 5 elements that vastly affect the convergence rate:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Selecting which node to branch on (heuristic)&lt;/li&gt;&#xA;&lt;li&gt;Selecting which variable to branch on (heuristic)&lt;/li&gt;&#xA;&lt;li&gt;Finding a feasible upper bound (heuristic)&lt;/li&gt;&#xA;&lt;li&gt;Quality of lower bounds (deterministic)&lt;/li&gt;&#xA;&lt;li&gt;Domain reduction using constraint propagation/OBBT (deterministic)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As we can see from the list above, three out of five components are heuristics. Therefore, regardless of the quality of a solver, certain problems will be extremely challenging because they don't fit its default heuristics very well. This is why changing the model a bit can help: minor changes can sometimes result in completely different branch-and-bound behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So what do solvers do if their heuristics don't work?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually they just get pwned. Because of the chaotic nature of branch-and-bound it's hard to tell when something isn't working. The algorithm might seem stuck for 2 hours and then it can suddenly converge. There is no way to know conclusively that what we are trying doesn't work, therefore we should try something else. As others have said, restarting is a viable option, but it's hard to pull off correctly for the reason I just mentioned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing some solvers do is to dynamically change some heuristics, but the pitfall here is that once we have created a bloated branch-and-bound tree using a bad heuristic, the problem is probably doomed anyway so we're better off restarting with a different configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What if the problem is non-convex?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then it's about 1,000,000 times harder to demonstrate the same level of consistency that MILP solvers do. On top of the above we also need libraries of reformulations (heuristic), combinations of different domain reduction methods (heuristic), specialised structures for representing the problem which change depending on the problem's size (heuristic), we need to chose which of our many heuristics to apply on what problem (metaheuristic), and so on.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-09-17T11:21:19.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2576" PostTypeId="1" CreationDate="2019-09-17T16:29:01.590" Score="6" ViewCount="5534" Body="&lt;p&gt;I am fairly new to optimization modelling but I am encountering a situation in which I supply initial values to my problem and then after I run my optimization those initial values change. This seems counter-intuitive to me though because if the initial values define the starting point of the problem, how then would these values be altered during the optimization process? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This leads me to my question regarding &quot;warm starts&quot;. Unfortunately the book I am learning from does not mention what a warm start is, but from what I gather it seems to have something to do with regards to initial values being supplied to solvers. As well, when I Google some variant of what a warm start is, I get a lot of papers on all the various methods to implement them, but not really explaining what they are. If someone would be able to clarify what a warm-start is, and if it's related to my issue, that would be great. &lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="500" LastEditDate="2023-12-13T17:59:57.603" LastActivityDate="2023-12-13T17:59:57.603" Title="What Exactly Is A Warm Start?" Tags="|pyomo|warm-start|" AnswerCount="2" CommentCount="1" ClosedDate="2019-09-17T19:52:00.843" ContentLicense="CC BY-SA 4.0" />
  <row Id="2577" PostTypeId="2" ParentId="2576" CreationDate="2019-09-17T16:43:06.557" Score="4" Body="&lt;p&gt;Generally &lt;em&gt;warm-start&lt;/em&gt; is a feasible solution for your problem and the nature of optimization problems is to evaluate feasible region(all the feasible solutions) to find the optimal solution which is not indeed the initial solution. AFAIK by providing a warm start to the solver you help the solver converge in less number of iterations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In pyomo to use this feature set the values of variables in the instance and pass &lt;code&gt;warmstart=True&lt;/code&gt; to the solve() method. Example(a problem with two variables with the pre-set amount of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$y_0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;instance = model.create()&#xA;instance.y[0] = 1&#xA;instance.y[1] = 0&#xA;opt = pyo.SolverFactory(&quot;cplex&quot;)&#xA;results = opt.solve(instance, warmstart=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-09-17T16:43:06.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2578" PostTypeId="2" ParentId="2576" CreationDate="2019-09-17T16:43:46.917" Score="8" Body="&lt;p&gt;There is a difference between an initial condition and initial values. Initial conditions in the context of differential equations fix the values of dynamic variables at the initial point. When you provide initial &lt;strong&gt;values&lt;/strong&gt; for your variables you are essentially providing a guess of where you think the optimal point is. The optimizer is still free to move the variable values as it (hopefully) converges to the optimal solution (minimizes or maximizes the objective function while satisfying all constraints). A warm start usually means that you're using the optimal solution of a related/simplified optimization problem to provide the initial values (guess) for the problem you actually care about. The hope is that the problems are similar enough that the warm start will get you close to the optimal solution and make convergence easier. Providing a good initial guess is particularly important when solving nonlinear optimization problems or problems known to have many local minima.&lt;/p&gt;&#xA;" OwnerUserId="583" LastActivityDate="2019-09-17T16:43:46.917" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2579" PostTypeId="2" ParentId="2530" CreationDate="2019-09-17T16:44:54.460" Score="2" Body="&lt;p&gt;The variant &lt;a href=&quot;https://arxiv.org/abs/1907.08246&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; has been suggested by Donald Knuth&lt;/p&gt;&#xA;" OwnerUserId="429" LastActivityDate="2019-09-17T16:44:54.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2581" PostTypeId="2" ParentId="1493" CreationDate="2019-09-18T14:25:01.903" Score="5" Body="&lt;p&gt;If there is a solution that maximizes all the objectives at once, then your choice of objective function is satisfying because this solution will be optimal for the weighted sum. However, from experience, the existence of such a solution is rare. There is rather a whole set of points representing possible compromises between objectives. Exploring them can be done partially by aggregating all objectives into one with a scalarizing function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several ways of scalarizing multiple objectives. Here you chose to sum up all 5 objectives, so you use a weighted sum with a weight of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; for each objective. This means that you estimate that &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; unit on one objective is &quot;tradeable&quot; for &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; unit of any other objective. Thus, the first thing to check is that your objectives have comparable units. If these are gains that are in €, \$ or another currency, this makes sense. If, for instance, you want to optimize energy gain and a gain in €, then you need to adjust the weight so that it matches your preferences on the tradeoff between &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; unit of energy gain and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; €. From you notations, the last objective, denoted by &lt;span class=&quot;math-container&quot;&gt;$t_L$&lt;/span&gt;, seems to be a bit different from the others. Make sure that trading one unit of &lt;span class=&quot;math-container&quot;&gt;$t_L$&lt;/span&gt; for one unit on another objective is something desirable in your case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To better illustrate the principle of tradeoffs and its limitations, suppose you have two solutions, resp. denoted by &lt;span class=&quot;math-container&quot;&gt;$y^1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^2$&lt;/span&gt;, and evaluated on two objectives such that &lt;span class=&quot;math-container&quot;&gt;$y^1=(12,1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^2=(3,10)$&lt;/span&gt;. Suppose &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; represents the objective sum that you proposed. Then, the two solutions are equivalent, since we have &lt;span class=&quot;math-container&quot;&gt;$f(y^1)=f(y^2)=13$&lt;/span&gt;.  From &lt;span class=&quot;math-container&quot;&gt;$y^1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$y^2$&lt;/span&gt;, there were &lt;span class=&quot;math-container&quot;&gt;$9$&lt;/span&gt; units on the first objective that were traded for an increase of &lt;span class=&quot;math-container&quot;&gt;$9$&lt;/span&gt; units on objective 2. Now, suppose that you have a third solution &lt;span class=&quot;math-container&quot;&gt;$y^3=(6,6)$&lt;/span&gt;. This solution will not be optimal since &lt;span class=&quot;math-container&quot;&gt;$f(y^3)=12$&lt;/span&gt;, even if its performances on both objectives seems to be more balanced and the weight of each objective equals &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. More than that, no combination of weights on both objectives will put &lt;span class=&quot;math-container&quot;&gt;$y^3$&lt;/span&gt; as the optimal solution, compared to &lt;span class=&quot;math-container&quot;&gt;$y^1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^2$&lt;/span&gt;. This type of solution is called non-supported solutions, and cannot be optimal with a weighted sum, no matter the chosen weights for the objectives. Therefore, choosing the weighted sum as scalarizing function limits the scope of solutions you can reach. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are interested in other options, there are other scalarizing function like the &lt;a href=&quot;https://ieeexplore.ieee.org/document/87068&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ordered Weighted Average&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;, or some function &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-642-48782-8_32&quot; rel=&quot;nofollow noreferrer&quot;&gt;based on reference points&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt;, that integrates different types of preference but are more complex than the weighted sum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since it is a supply/demand problem, the OWA seems to be a potential good fit, because it can be parametrized such that it represents preferences towards equitable performance across all objectives. It will come with a computational cost because it involves additional constraints and variables to keep everything linear. Otherwise, you could only maximize the minimum objective (specific case of the OWA).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To elaborate a bit more on the latter part, I am going to illustrate the &lt;span class=&quot;math-container&quot;&gt;$\max\min$&lt;/span&gt; approach on the previous example. Suppose now that the aggregating function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is simply the minimum value across all objectives. So, &lt;span class=&quot;math-container&quot;&gt;$f(y)=\min y$&lt;/span&gt;, which means that &lt;span class=&quot;math-container&quot;&gt;$f(y^1)=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f(y^2)=2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f(y^3)=6$&lt;/span&gt;. Therefore, the optimal solution that maximizes the newly defined &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; function is &lt;span class=&quot;math-container&quot;&gt;$y^3$&lt;/span&gt;. This approach is useful when you want to have a solution with a fair repartition across objectives. However, practically, you will have to add an extra term to the objective function. Indeed, suppose now that there is a fourth solution &lt;span class=&quot;math-container&quot;&gt;$y^4=(6,7)$&lt;/span&gt;. Observe that &lt;span class=&quot;math-container&quot;&gt;$\min y^4=6=\min y^3$&lt;/span&gt;, but you will prefer &lt;span class=&quot;math-container&quot;&gt;$y^4$&lt;/span&gt;, because it dominates &lt;span class=&quot;math-container&quot;&gt;$y^3$&lt;/span&gt; on all objectives. For the solver &lt;span class=&quot;math-container&quot;&gt;$y^3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^4$&lt;/span&gt; are equivalent (because &lt;span class=&quot;math-container&quot;&gt;$f(y^3)=f(y^4)$&lt;/span&gt;), therefore it will randomly choose &lt;span class=&quot;math-container&quot;&gt;$y^3$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$y^4$&lt;/span&gt;. In order to prevent this behavior, the function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; should then be defined as &lt;span class=&quot;math-container&quot;&gt;$f(y) = \min(y) + \epsilon \sum\limits_{i=1}^n{y_i}$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; being the number of objectives. &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; should be small enough to just be useful when the solver needs to arbitrate between several solutions that have the same minimum value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now for the model, you need to add an extra variable, for example denoted by &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, and add &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; constraints: &lt;span class=&quot;math-container&quot;&gt;$z \leq y_i$&lt;/span&gt; ,&lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,n$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; still being the number of objectives. Your objective function will then be &lt;span class=&quot;math-container&quot;&gt;$\max\left\{z + 0.0001\sum\limits_{i=1}^n{y_i}\right\}$&lt;/span&gt;. Since &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is lower than all objectives, it is lower or equal to the objective with the minimum value, thus maximizing it will yield the solution having the maximum minimum value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Larry pointed out in your other post, MultiObjective Optimization (MOO) may also be an area worth looking at. This area focuses on the nondominated solutions, which are solutions that are not worse than another one on all objectives. You can either generate the whole set of nondominated points, a subset of it or exhibit one specific point. Using a scalarizing function does the latter. Some meta-heuristics provide a subset of the nondominated solutions. And if the problem is not too large, you can try to generate the whole nondominated set (for example, see &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0377221713006474&quot; rel=&quot;nofollow noreferrer&quot;&gt;[3]&lt;/a&gt; and the code can be accessed &lt;a href=&quot;http://home.ku.edu.tr/~moolibrary/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Yager, R. R. (1988). On ordered weighted averaging aggregation operators in multicriteria decisionmaking. &lt;em&gt;IEEE Transactions on Systems, Man, and Cybernetics&lt;/em&gt;. 18(1):183-190. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] Wierzbicki, A. P. (1980). The Use of Reference Objectives in Multiobjective Optimization. &lt;em&gt;Multiple Criteria Decision Making Theory and Application&lt;/em&gt;. pp. 468-486. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [3] Kirlik, G., Sayın, S. (2014). A new algorithm for generating all nondominated solutions of multiobjective discrete optimization problems. &lt;em&gt;European Journal of Operational Research&lt;/em&gt;. 232(3):479-488. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="2367" LastEditorUserId="123" LastEditDate="2019-09-19T07:43:55.700" LastActivityDate="2019-09-19T07:43:55.700" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2582" PostTypeId="1" CreationDate="2019-09-18T19:05:09.280" Score="7" ViewCount="1033" Body="&lt;p&gt;I am writing a Pyomo model and trying to code the following mathematical constraint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^I\sum_{j=1}^J\sum_{t=1}^T 5I_{ijt} + 10L_{ijt}I_{ijt}  $$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$L_{ijt}$&lt;/span&gt;  is binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am hoping that I could get someone to clarify if what I have written in my model makes sense: &lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def objective_rule(model):&#xA;    return sum (sum (sum (model.obj[i,j,t] for i in model.Iset ) for j in model.Jset ) for t in model.Tset )&#xA;model.damages = Objective(rule=objective_rule, sense=minimize)&#xA;&#xA;def obj_rule(model, i,j,t):&#xA;    return model.obj[i,j,t] == 5*model.inf_b4treat[i,j,t] + 10 *model.level1[i,j,t]*model.inf_b4treat[i,j,t]&#xA;model.object = Constraint(model.Iset, model.Jset, model.Tset, rule=obj_rule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am getting a couple of strange results and having debugged my model I am thinking that it might be due to my objective function not being formatted properly. To clarify, the reason that I chose to create an additional object called &lt;code&gt;model.obj[i,j,t]&lt;/code&gt; is so that I could access the objective function values after I solve the model. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would appreciate any corrections. &lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="123" LastEditDate="2019-09-18T19:41:07.450" LastActivityDate="2019-12-03T07:47:53.507" Title="Pyomo: Is this triple summation objective function formatted correctly?" Tags="|pyomo|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2583" PostTypeId="1" AcceptedAnswerId="2586" CreationDate="2019-09-19T01:43:00.400" Score="13" ViewCount="1381" Body="&lt;p&gt;I’m interested in the idea behind this in general, so I thought this would be the best place to post, though I have a practical and semi-urgent need of allocating the points on my credit card towards purchases.&lt;/p&gt;&#xA;&lt;p&gt;Each purchase I make can be paid for in points. However, it goes by purchase, not by my total bill. Therefore, I can wind up with points left, but too few to be able to put them towards a purchase. Further, points don’t have the same value for each purchase. One purchase may regard a point as a cent, while another may regard a point as 0.9 cents.&lt;/p&gt;&#xA;&lt;p&gt;My goal is to have as little left on my bill after I use points. Certainly I can do this by brute force and try out every combination of purchases to see which results in the lowest remaining bill, but that lacks elegance and seems like it would be quite slow (dealing with factorials).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Questions&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;What slicker techniques are there for solving this minimization problem?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there existing software that will solve this problem?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Responding to some comments...&lt;/p&gt;&#xA;&lt;p&gt;CMichael (1): I get to make the decision at the end of the month when I am paying my bill. Instead of paying the entire bill, I can use points to pay off some purchases and then pay off the remaining bill. I want the remaining bill to be minimized.&lt;/p&gt;&#xA;&lt;p&gt;CMichael (2): If I want to use points towards a purchase, I have to cover all of that purchase with points. If my purchase is \$100 or 10,000 points, I can either spend the \$100 or the 10,000 points, but \$50 and 5000 points would not be allowed.&lt;/p&gt;&#xA;" OwnerUserId="2372" LastEditorUserId="2372" LastEditDate="2024-01-05T02:21:42.707" LastActivityDate="2024-01-05T02:21:42.707" Title="Allocating credit card points" Tags="|optimization|integer-programming|finance|knapsack|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="2584" PostTypeId="2" ParentId="2583" CreationDate="2019-09-19T09:36:21.217" Score="7" Body="&lt;p&gt;That sounds like you could formulate it as MIP. You have a fixed set of planned purchases, right? Each of them (&lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;) will yield a constraint of the form &lt;span class=&quot;math-container&quot;&gt;$x_p + c_p \cdot y_p = t_p$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x_p$&lt;/span&gt;  is the amount of money you will spend on that purchase, &lt;span class=&quot;math-container&quot;&gt;$y_p$&lt;/span&gt; the amount of points with the conversion rate (per purchase) and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; the total price. &lt;span class=&quot;math-container&quot;&gt;$x \ge 0$&lt;/span&gt; would be continuous, and &lt;span class=&quot;math-container&quot;&gt;$y \ge 0$&lt;/span&gt; integer.&#xA;Then you would need to limit the points available: &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_p y_p \le Y$&lt;/span&gt; and minimize the total amount of money spent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does that make sense?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: The above is a description of a MIP model formulation. To get the answer, you will need some solver software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT2: According to the comments, a purchase can not be made with a combination of money and points. In that case, the constraints need to change, e.g., by adding a &lt;span class=&quot;math-container&quot;&gt;$\operatorname{SOS1}(x_p,y_p)$&lt;/span&gt; for each purchase. But the problem can also be simplified by using binary variables for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$x_p + y_p = 1$&lt;/span&gt;. In that case, you would need to limit the number of points used by &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_p d_p\cdot y_p \le Y$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$d_p$&lt;/span&gt; gives the number of points needed for &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;. The function to minimize is then &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_p c_p \cdot x_p$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$c_p$&lt;/span&gt; the price of the purchase.&lt;/p&gt;&#xA;" OwnerUserId="126" LastEditorUserId="123" LastEditDate="2019-09-19T15:43:02.233" LastActivityDate="2019-09-19T15:43:02.233" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2585" PostTypeId="2" ParentId="2583" CreationDate="2019-09-19T11:24:28.070" Score="8" Body="&lt;p&gt;This seems like some sort of &lt;a href=&quot;https://en.wikipedia.org/wiki/Knapsack_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;knapsack problem&lt;/a&gt;: Suppose you have a set of purchases and a certain amount of points. Each purchase can be &quot;paid&quot; by points as a whole, no partial usage of points for each purchase is viable.&lt;br&gt;&#xA;Let's declare some sets and parameters: let &lt;span class=&quot;math-container&quot;&gt;$P={1,\ldots,n}$&lt;/span&gt; be the set of purchases which each get a number to distinguish them. For each purchase &lt;span class=&quot;math-container&quot;&gt;$p\in P$&lt;/span&gt; you have an amount of points &lt;span class=&quot;math-container&quot;&gt;$w_p$&lt;/span&gt; that is needed to cover the purchase with points completely. You also have a certain amount of points &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; which you can use.&#xA;As you want to maximize the amount of money covered by using points, you define the value &lt;span class=&quot;math-container&quot;&gt;$v_p$&lt;/span&gt; for each purchase which corresponds to the price of the purchase (as you have stated, the number of points used can differ from the actual amount of money you cover with the points).&lt;br&gt;&#xA;Now you can use a standard knapsack solver to compute the solution with &lt;span class=&quot;math-container&quot;&gt;$w_p$&lt;/span&gt; as weights, &lt;span class=&quot;math-container&quot;&gt;$v_p$&lt;/span&gt; as values and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; as the maximum weight capacity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the Knapsack problem is NP-hard, it is some of the more benevolent optimization problems that have a pseudo-polynomial time algorithm that uses dynamic programming. The solving time depends on the number of items and the maximum weight capacity &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; (so you have &lt;span class=&quot;math-container&quot;&gt;$O(nM)$&lt;/span&gt;). There exist many implementations which you can find for example &lt;a href=&quot;https://rosettacode.org/wiki/Knapsack_problem/0-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. If your problem is reasonable small (which I can imagine as you won't make thousands of purchases per month) there shouldn't be a problem to solve your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this only covers the decision for one month. If you want to decide at the end of a month how much points you should use or whether it is beneficial to save your points and use them later in the year, this problem is much harder and your problem changes into a online version. Here, you also have to guess the purchases you will do in the future. Maybe you have recurring stuff that you pay every month, but very likely there is an amount of purchases you won't know in advance.&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="279" LastEditDate="2020-06-14T03:38:03.763" LastActivityDate="2020-06-14T03:38:03.763" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2586" PostTypeId="2" ParentId="2583" CreationDate="2019-09-19T11:30:18.947" Score="10" Body="&lt;p&gt;With the OP's clarifications I would say this is a straight-forward variant of the knapsack problem where &lt;strong&gt;you want to pack as many saved dollars into your budget of points&lt;/strong&gt;. Find below the simple formalization where the index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; spans across all items on the current bill:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Capacity of the knapsack: &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; = Available points&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Item weight: &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; = number of points necessary for item&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Value of item: &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; = dollar value of an item (note that if purchased with points you get to keep the money)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Decision variables: &lt;span class=&quot;math-container&quot;&gt;$y_i \in \{0,1\}$&lt;/span&gt; = item is payed with points&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Objective function: &lt;span class=&quot;math-container&quot;&gt;$\max\limits_{y_i} \sum\limits_i \left(v_i y_i\right)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;subject to: &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_i \left(y_i w_i\right) \leq C$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The little trick that may be confusing here is the following: The weight is not directly given but obtains from the price of item multiplied with the item's point conversion rate &lt;span class=&quot;math-container&quot;&gt;$\gamma_i$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$w_i = v_i \gamma_i$&lt;/span&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick google search yielded the following web site with a simple branch and bound solver: &lt;a href=&quot;https://jacopo.cc/BB/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://jacopo.cc/BB/&lt;/a&gt; Depending on the number of items on your bill you could also use &lt;a href=&quot;https://www.theoptimizationexpert.com/case-studies/knapsack/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Microsoft Excel&lt;/a&gt; - the built-in solver supports something like 200 decision variables. If you are dealing with larger problems you may want to look over &lt;a href=&quot;https://www.jonaslindstrom.dk/?p=280&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; where somebody created a dynamic programming solution in VBA. Probably this could be integrated in your workflow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want an &lt;a href=&quot;http://ac.informatik.uni-freiburg.de/lak_teaching/ws11_12/combopt/notes/knapsack.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ok heuristic solution&lt;/a&gt; you can try out &lt;strong&gt;greedy by value density&lt;/strong&gt; - that is sort your items by descending &lt;span class=&quot;math-container&quot;&gt;$v_i / w_i$&lt;/span&gt; and pick sequentially the items with the highest value density which fit into your point budget. Of course such a heuristic will not guarantee an optimal solution.&lt;/p&gt;&#xA;" OwnerUserId="33" LastEditorUserId="123" LastEditDate="2019-09-19T15:41:52.367" LastActivityDate="2019-09-19T15:41:52.367" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2587" PostTypeId="1" AcceptedAnswerId="2588" CreationDate="2019-09-19T13:11:45.057" Score="7" ViewCount="2233" Body="&lt;p&gt;Is there a way to see why a solver (&lt;em&gt;OR-Tools&lt;/em&gt;, &lt;em&gt;CPLEX&lt;/em&gt;, &lt;em&gt;Gurobi&lt;/em&gt;) cannot find a feasible solution when solving a MIP?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By that I mean, is there a possibility to show at which constraint and exact indices the solver stoped?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; a binary variable&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a_j$&lt;/span&gt; a parameter&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ i \in I:|I| =3$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;constraint: &lt;span class=&quot;math-container&quot;&gt;$\sum \limits_i x_i &amp;gt; a_j \ \ \forall j$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;no solution found because for index &lt;span class=&quot;math-container&quot;&gt;$j=2$&lt;/span&gt; not able to fulfill this constraint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;---&gt; &lt;span class=&quot;math-container&quot;&gt;$a_2= 100$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum \limits_i x_i =3$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="456" LastEditorUserId="38" LastEditDate="2019-09-20T02:49:08.473" LastActivityDate="2019-09-28T12:37:39.773" Title="Why is there not a feasible solution for a MIP?" Tags="|mixed-integer-programming|integer-programming|cplex|gurobi|feasible-points|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2588" PostTypeId="2" ParentId="2587" CreationDate="2019-09-19T13:16:31.333" Score="13" Body="&lt;p&gt;Yes - such a question can be answered by looking at the &lt;strong&gt;irreducible inconsistent subsystem&lt;/strong&gt; (IIS).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the Gurobi documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An IIS is a subset of the constraints and variable bounds with the following properties:&#xA;  the subsystem represented by the IIS is infeasible, and&#xA;  if any of the constraints or bounds of the IIS is removed, the subsystem becomes feasible.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="33" LastActivityDate="2019-09-19T13:16:31.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2589" PostTypeId="2" ParentId="2587" CreationDate="2019-09-19T14:13:13.740" Score="9" Body="&lt;p&gt;There exist various reasons why a solver could not find the optimal solution. You must always check why a solver terminated. Typical reasons are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;optimal solution was found&lt;/li&gt;&#xA;&lt;li&gt;termination criteria was reached, e.g. time limit or a limit on the optimality gap&lt;/li&gt;&#xA;&lt;li&gt;solver proved that problem is infeasible&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Popular solvers such as cplex/gurobi can report their status through a &lt;code&gt;getStatus&lt;/code&gt; function. When a solver terminates due to some termination criteria, you can end up in any of the following situations:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Some solution was found. The optimality gap gives you insight into the quality of this solution. However, there might exist better solutions, i.e. it is unknown whether this solution is optimal or not.&lt;/li&gt;&#xA;&lt;li&gt;No solution was found. There might however exist feasible solutions. This status is usually indicated as 'undefined/unknown', as it is unknown whether the solution space is empty or not.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Frequently, the solver is quickly able to determine feasibility of a problem. This can already happen in the pre-solve status. Modern solvers can search for a Minimal irreducible inconsistent subsystem. This is a subset of constraints which collectively render your problem infeasible. Deleting any constraint of this set would render the subproblem defined by these constraints feasible. Note that there may exist multiple causes of infeasibility in your model, i.e. multiple different IISs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to know more about this subject, I recommend the following papers:&#xA;- Finding the minimum weight IIS cover of an infeasible system of linear inequalities by Parker and Ryan, 1996&#xA;- Minimal Infeasible Subsystems and Benders cuts by Fischetti, Salvagnin, Zanette, 2008&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finding a &lt;strong&gt;minimum&lt;/strong&gt; IIS, i.e. the smallest IIS is an NP-hard problem. Therefore, many solvers use heuristics to find a minimal, but not necessarily minimum IIS. I my experience, trying to find an IIS using CPLEX or Gurobi is a game of hit and miss: finding an IIS might take quite some time, especially in large models. Also, the IIS returned can be big, so interpreting the source of infeasibility might not be trivial. In practice I often use the following approach:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Compute a feasible solution to your problem using for instance a simple heuristic.&lt;/li&gt;&#xA;&lt;li&gt;Fix all variables in your model to their corresponding values in the solution found in the previous step.&lt;/li&gt;&#xA;&lt;li&gt;Solve the model and search for an IIS. Gurobi: &lt;code&gt;Model.computeIIS()&lt;/code&gt;. Cplex: &lt;code&gt;Cplex.getIIS&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Since all variables are fixed, the IIS returned by the solvers is typically very small.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="49" LastActivityDate="2019-09-19T14:13:13.740" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2590" PostTypeId="2" ParentId="2587" CreationDate="2019-09-19T14:56:13.530" Score="5" Body="&lt;p&gt;Another possibility not mentioned in the other answers is that an optimal solution exists, but the solver is not able to find it, or perhaps confirm its optimality, due to numerical difficulties, which might in turn be due to poor scaling or ill-conditioning of the original problem. Double precision floating point computation can be a cruel mistress.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-09-28T12:37:39.773" LastActivityDate="2019-09-28T12:37:39.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2591" PostTypeId="1" CreationDate="2019-09-19T16:57:23.007" Score="4" ViewCount="415" Body="&lt;p&gt;I want to solve below optimization problem. This is scheduling problem where I seek to complete as many of the jobs &lt;span class=&quot;math-container&quot;&gt;$\xi_l$&lt;/span&gt; (objective function and constraint 1), with &lt;span class=&quot;math-container&quot;&gt;$T_C$&lt;/span&gt; being the last time until I can finish them (constraint 2). Constraint 3 to disallow any parallel activities. Also, each job can wait &lt;span class=&quot;math-container&quot;&gt;$t_l$&lt;/span&gt; to start in scheduling (waiting time that it's maximum is &lt;span class=&quot;math-container&quot;&gt;$T_c$&lt;/span&gt;). &lt;span class=&quot;math-container&quot;&gt;$T_{r,l}$&lt;/span&gt; is time that job &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; is registered, and &lt;span class=&quot;math-container&quot;&gt;$T_{e,l}$&lt;/span&gt; is time that job &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; is completed (if &lt;span class=&quot;math-container&quot;&gt;$\xi_l=1$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$t_l=0$&lt;/span&gt;). &#xA;The optimization problem is: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\underset{t_l,\xi_l}{\max}\quad&amp;amp;  \sum_{l=1}^{L}\xi_l\\&#xA;\text{s.t.}\quad&amp;amp;\xi_l \in \{0, 1\}\\&#xA;&amp;amp;\xi_l t_l\leq T_c~~~~~~\forall l,\\&#xA;&amp;amp;\begin{cases}T_{r,l}+t_l\geq (\xi_l+\xi_{l^\prime}-1)(T_{e,l^\prime}+t_{l^\prime})\\\hspace{3cm}\text{or}\\T_{r,l^\prime}+t_{l^\prime}\geq (\xi_l+\xi_{l^\prime}-1)(T_{e,l}+t_{l})\quad\forall l\neq l^\prime\end{cases}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I solve above optimization problem and find closed form for &lt;span class=&quot;math-container&quot;&gt;$\xi_l$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_l$&lt;/span&gt; (as function of &lt;span class=&quot;math-container&quot;&gt;$T_c$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$T_{r,l}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$T_{e,l}$&lt;/span&gt;)?, OR how can I find an algorithm to solve this optimization problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To have an idea for the general solution for &lt;span class=&quot;math-container&quot;&gt;$\xi_l$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_l$&lt;/span&gt; in optimized solution, I solve this problem for two job (&lt;span class=&quot;math-container&quot;&gt;$L=2$&lt;/span&gt;), by using Lagrangian method (I can't import one of OR constraints):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;L= \xi_1+\xi_2+\lambda_1(T_c-\xi_1t_1)+\lambda_2(T_c-\xi_2t_2)+\alpha_1(1-\xi_1)+\alpha_2(1-\xi_2)\\+\gamma_1t_1+\gamma_2t_2+\beta(T_{r,2}+t_2-(\xi_1+\xi_2-1)(T_{e,1}+t_1))&#xA;\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$L=L(\xi_1,t_1,\xi_2,t_2,\lambda_1,\lambda_2,\alpha_1,\alpha_2,\gamma_1,\gamma_2,\beta)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, &lt;span class=&quot;math-container&quot;&gt;$\frac{\partial L}{\partial ...}$&lt;/span&gt;, I have these equations:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;1-\lambda_1 t_1 -\alpha_1-\beta(T_{e,1}+t_1) = 0\\&#xA;&amp;amp;1-\lambda_2 t_2 -\alpha_2-\beta(T_{e,1}+t_1) = 0\\&#xA;&amp;amp;-\xi_1 \lambda_1-\beta\xi_1-\beta-\xi_2+\gamma_1+\beta=0\\&#xA;&amp;amp;-\lambda_2\xi_2+\gamma_2+\beta=0\\&#xA;&amp;amp;\xi_1 = 1, \xi_2=1\\&#xA;&amp;amp;t_1 = 0, t_2 = 0\\&#xA;&amp;amp;\xi_1t_1= T_c\\&#xA;&amp;amp;\xi_2t_2= T_c\\&#xA;&amp;amp;T_{r,2}+t_2= (\xi_1+\xi_{2}-1)(T_{e,1}+t_{1})&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I continue this to find &lt;span class=&quot;math-container&quot;&gt;$\xi_1, \xi_2, t_1$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$t_2$&lt;/span&gt;? and how can I generalize this solution for my optimization problem?&lt;/p&gt;&#xA;" OwnerUserId="2365" LastEditorUserId="2365" LastEditDate="2019-09-20T06:06:02.807" LastActivityDate="2019-09-20T06:06:02.807" Title="Scheduling Optimization Problem" Tags="|mixed-integer-programming|optimization|modeling|scheduling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2592" PostTypeId="2" ParentId="2591" CreationDate="2019-09-19T18:48:27.750" Score="6" Body="&lt;p&gt;You can model the disjunction by introducing binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{l,l^\prime}$&lt;/span&gt; and the following linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\xi_l+\xi_{l^\prime}-1 &amp;amp;\le x_{l,l^\prime} + x_{l^\prime,l}\\&#xA;T_{r,l}+t_l&amp;amp;\geq x_{l^\prime,l}(T_{e,l^\prime}+t_{l^\prime}) \\ T_{r,l^\prime}+t_{l^\prime}&amp;amp;\geq x_{l,l^\prime}(T_{e,l}+t_{l}) \\&#xA;\end{align}&lt;/span&gt;&#xA;The first constraint can be derived by rewriting the desired logical proposition in conjunctive normal form as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;(\xi_l \land \xi_{l^\prime}) \implies (x_{l,l^\prime} \lor x_{l^\prime,l}) \\&#xA;\neg(\xi_l \land \xi_{l^\prime}) \lor (x_{l,l^\prime} \lor x_{l^\prime,l}) \\&#xA;\neg \xi_l \lor \neg \xi_{l^\prime} \lor x_{l,l^\prime} \lor x_{l^\prime,l} \\&#xA;(1 - \xi_l) + (1 - \xi_{l^\prime}) + x_{l,l^\prime} + x_{l^\prime,l} \ge 1 \\ \xi_l+\xi_{l^\prime}-1 \le x_{l,l^\prime} + x_{l^\prime,l}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2019-09-19T19:05:16.853" LastActivityDate="2019-09-19T19:05:16.853" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2593" PostTypeId="1" CreationDate="2019-09-19T20:54:38.983" Score="9" ViewCount="225" Body="&lt;p&gt;Are there any rules of thumb for figuring out when you need to use a solver like Gurobi or CPLEX, and when you can just solve you problems directly with a Python, R, or Matlab package? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it just a question of the size of the problem, or are there other considerations?&lt;/p&gt;&#xA;" OwnerUserId="1315" LastActivityDate="2019-09-20T11:59:29.980" Title="When should I use a solver for IP and MIP and can I just use a library from Python, R, Matlab, etc...?" Tags="|optimization|solver|python|matlab|r|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2594" PostTypeId="2" ParentId="2593" CreationDate="2019-09-19T21:50:00.430" Score="8" Body="&lt;p&gt;I assume the solver you're referring to in Python/R/Matlab, are the open-source solvers such as CBC or GLPK (you can find out more in this question: &lt;a href=&quot;https://or.stackexchange.com/questions/4/where-can-i-find-open-source-lp-solvers&quot;&gt;Where can I find open source LP solvers?&lt;/a&gt;). If that's the case then you should consider:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The size of the problem&lt;/li&gt;&#xA;&lt;li&gt;Solution time: which can be very different between open-source and commercial solvers&lt;/li&gt;&#xA;&lt;li&gt;How much flexibility you need or what type of problems you are solving? For example, do you need to solve a quadratic problem? How about fine-tuning capabilities, callback functionality, using solution pools, usage of the software on the cloud, and a lot more which are much better in commercial solvers (if they even exist in open-source solvers)&lt;/li&gt;&#xA;&lt;li&gt;How much money you can spend!&lt;/li&gt;&#xA;&lt;li&gt;If you need any support or maintenance. This can be a concern when:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You are solving problems for companies that require someone to answer any question that arises with the performance or even modeling itself&lt;/li&gt;&#xA;&lt;li&gt;The problem is important and almost no risk can be taken! (e.g. when there is a concern about the performance or accuracy of an open-source solver). In a commercial solver (since you are paying), you can assume the solvers don't have any bug and if they do, you can reach out to their support system and resolve it (hopefully quickly). But that cannot necessarily be the case using an open-source solver.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-09-20T01:42:37.330" LastActivityDate="2019-09-20T01:42:37.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2595" PostTypeId="1" CreationDate="2019-09-20T05:35:00.980" Score="18" ViewCount="6329" Body="&lt;p&gt;I'm trying to wrap my head around an apparent paradox that I've come across while trying to learn more about optimization algorithms: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;On one hand several sources state that convex optimization is easy, because every local minimum is a global minimum. &lt;a href=&quot;https://www.youtube.com/watch?v=U41e7hKAAPQ&amp;amp;t=3696s&quot; rel=&quot;noreferrer&quot;&gt;In this video, starting at 27:00&lt;/a&gt;, Stephen Boyd from Stanford claims that convex optimization problems are tractable and in polynomial time. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Other sources state that a convex optimization problem can be NP-hard. See for example this &lt;a href=&quot;https://mathoverflow.net/a/92961&quot;&gt;post&lt;/a&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://cs.stackexchange.com/questions/114924/if-a-convex-optimization-problem-can-be-np-hard-in-what-sense-are-convex-proble&quot;&gt;See this post&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't wrap my head around the two statements, are convex optimization problems tractable or not? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I try to dig deeper, one thing I noticed it that the term convex doesn't seem to be used the same way by different people when it comes to integer problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By some definitions, it seems that a convex integer optimization problem is impossible by definition: the very fact of constraining the variables to integer values removes the convexity of the problem, since for a problem to be convex, both the objective function and the feasible set have to be convex. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other places seem to consider problems where if aside from the integer constraint, all other constraints and the objective function are convex, to be convex optimization problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which one of the two is correct? Can an integer programming problem be convex? Or is it non-convex by definition, given the restrictions it puts on the feasible set? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is possible for an integer programming problem to be convex, then in what sense are convex optimization problems &quot;easier&quot; that non-convex problems, since both are NP-Hard? &lt;/p&gt;&#xA;" OwnerUserId="1315" LastEditorUserId="38" LastEditDate="2019-09-20T12:35:47.070" LastActivityDate="2019-09-22T06:17:43.157" Title="Can an integer optimization problem be convex?" Tags="|optimization|integer-programming|computational-complexity|convexity|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2596" PostTypeId="2" ParentId="2595" CreationDate="2019-09-20T05:56:20.507" Score="13" Body="&lt;p&gt;Mathematically, mixed-integer programs (MIPs) are non-convex, for the very reason you stated: the set &lt;span class=&quot;math-container&quot;&gt;$x \in \{0,1\}$&lt;/span&gt; is inherently non-convex. In fact, for a convex optimization problem (e.g. linear programming), you can find the solution in polynomial time using &lt;a href=&quot;https://en.wikipedia.org/wiki/Interior-point_method&quot; rel=&quot;noreferrer&quot;&gt;interior-point methods&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason the optimization community is going against the pure &quot;mathematical&quot; grain lies in the way that MIPs are solved: to find the best combination of binary variables, the problem is relaxed, e.g. &lt;span class=&quot;math-container&quot;&gt;$x\in \{0,1\} \rightarrow x \in [0,1]$&lt;/span&gt;. In other words, the problem is &quot;made&quot; continuous. If then the objective function and constraints are convex, this relaxed version of the problem is also convex and can be solved in polynomial time. This allows e.g. &lt;a href=&quot;https://en.wikipedia.org/wiki/Branch_and_bound&quot; rel=&quot;noreferrer&quot;&gt;branch-and-bound&lt;/a&gt; algorithms to be computationally sensible, as they have to solve these subproblems many, many times to solve a MIP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, MIPs are, in general, NP-hard, precisely because they are non-convex.&lt;/p&gt;&#xA;" OwnerUserId="133" LastEditorUserId="123" LastEditDate="2019-09-20T06:25:35.943" LastActivityDate="2019-09-20T06:25:35.943" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2597" PostTypeId="2" ParentId="2595" CreationDate="2019-09-20T06:54:26.510" Score="15" Body="&lt;p&gt;Feels like you are asking two things, tractability of convex problems and convexity of integer problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A first order approximation is that convex programs are tractable, .i.e., most problems you can think of as a layman in the field that are convex, are (probably) tractable to solve. That's why you would be told that in an introductory course on convex optimization. It is not true though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tractability of convex problems essentially boils down to being able to decide if an iterate &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is feasible, in a computationally tractable way (having a so called oracle available). There are convex sets for which this isn't the case. One such example if the set of co-positive matrices. If you are trying to find a matrix &lt;span class=&quot;math-container&quot;&gt;$M(x)$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$z^TM(x)z \geq 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$z\geq 0$&lt;/span&gt;, you have problems, as it is very hard to decide if a candidate &lt;span class=&quot;math-container&quot;&gt;$M(x)$&lt;/span&gt; satisfies that property. Compare to the simple case of positive-semidefinite where all &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; should lead to non-negativity, this is simply an eigenvalue test and thus semidefinite programming is tractable. Alas, also this statement is up for debate, as it depends on what you mean with solving a problem. A semidefinite programming problem with size &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; (what ever we mean with that) can have a solution whose representation grows at an exponential rate &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the second issue whether an integer problem is convex, the answer is no, and that follows directly from geometry (unless there is only 1 solution). However, as shown by Sam Burer, nononvex mixed-binary quadratic programs can be rewritten as convex optimization over the co-positive cone. Remember from the discussion above though, this only implies we've made a convex reformulation, not that the problem has been made tractable.&lt;/p&gt;&#xA;" OwnerUserId="487" LastEditorUserId="487" LastEditDate="2019-09-22T06:17:43.157" LastActivityDate="2019-09-22T06:17:43.157" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2598" PostTypeId="2" ParentId="2587" CreationDate="2019-09-20T07:39:49.233" Score="5" Body="&lt;p&gt;As an alternative to finding irreducible infeasible subsets (smaller subproblems that are still infeasible) would be to introduce slack variables into your constraints. Then you would replace your original objective with the minimization of these (non-negative) slack variables, penalizing their use.&#xA;This way, you can also get some insight into which constraints are difficult to satisfy (simultaneously).&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-09-20T07:39:49.233" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2599" PostTypeId="2" ParentId="2595" CreationDate="2019-09-20T08:07:02.910" Score="3" Body="&lt;p&gt;The terminology here is a bit ambiguous. I've heard the term &quot;convex MINLP&quot; being used in two different ways:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;As others said, a problem where the continuous relaxation of the integer variables results in a convex problem, and &lt;/li&gt;&#xA;&lt;li&gt;An MINLP with a linear integer part and a convex continuous part (which is a subset of the previous definition). This is important for certain techniques, e.g. generalised Benders decomposition.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-09-20T08:07:02.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2600" PostTypeId="1" CreationDate="2019-09-20T10:08:00.997" Score="4" ViewCount="822" Body="&lt;p&gt;In an scheduling optimization problem, for job &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\xi_l$&lt;/span&gt; is binary variable that &lt;span class=&quot;math-container&quot;&gt;$\xi_l=1$&lt;/span&gt; shows job &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; is selected.  &lt;span class=&quot;math-container&quot;&gt;$t_{r,l}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_{e,l}$&lt;/span&gt; are registration time and time that job is completed. Also, each job can wait for &lt;span class=&quot;math-container&quot;&gt;$t_l$&lt;/span&gt;. In this problem, one contrarian disallows any parallel activities. This constraint is XOR:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\begin{cases}T_{r,l}+t_l\geq (\xi_l+\xi_{l^\prime}-1)(T_{e,l^\prime}+t_{l^\prime})\quad\forall l\neq l^\prime\\\hspace{3cm}\text{xor}\\T_{r,l^\prime}+t_{l^\prime}\geq (\xi_l+\xi_{l^\prime}-1)(T_{e,l}+t_{l})\quad\forall l\neq l^\prime\end{cases}&#xA;\end{align}&lt;/span&gt;&#xA;How can I merge these two part in one (linear form) constriction? Can I represent this constraint using other equation?&lt;/p&gt;&#xA;" OwnerUserId="2365" LastEditorUserId="2365" LastEditDate="2019-09-20T10:17:46.053" LastActivityDate="2019-09-20T17:56:04.587" Title="XOR constraint representation" Tags="|mixed-integer-programming|optimization|modeling|scheduling|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="2601" PostTypeId="2" ParentId="2593" CreationDate="2019-09-20T11:59:29.980" Score="4" Body="&lt;p&gt;The main reasons are performance and quality of numerics. Non-professional stuff tend to lack the polish professionals spend time doing to ensure that numerical issues don't compromise the solving procedure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Performance-wise, a good rule of thumb is problem density: if a problem is large but really sparse, open source solvers can perform really well. If a problem is dense however, we need a professional-grade implementation. The main reason is the development time invested when it comes to the scalability of the data structures and algorithms in a solver, as well as uncommon/edge use cases. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an anecdotal real-world example, our engine calculates some of the fastest derivatives in the world, but one day we discovered that our differentiation algorithm stopped scaling well after 70,000 or so non-zero hessian elements (so it was really slow beyond that). The reason was fundamentally linked to how we were getting such speed for less dense problems, so it took my team three weeks to come up with a high performance alternative, which now triggers automatically after a certain density. Interestingly, our alternative algorithm is really slow for sparse problems, which is why we never considered it before. Taking the time to do these kinds of tricks is really common in commercial products, because our selling point is that the solver will work well even on edge cases, but not as much in most free software where the focus is (for good reason) on the average use case.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-09-20T11:59:29.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2602" PostTypeId="2" ParentId="2600" CreationDate="2019-09-20T17:18:07.160" Score="1" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; be the count of &lt;span class=&quot;math-container&quot;&gt;$\xi_l$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prevent any &lt;span class=&quot;math-container&quot;&gt;$\xi_l=1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$\xi_{l^\prime}=1$&lt;/span&gt;, we can have &lt;span class=&quot;math-container&quot;&gt;$\sum\xi_l+\xi_{l^\prime}L\le L$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prevent the case when all binary are &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, we can have &lt;span class=&quot;math-container&quot;&gt;$\sum\xi_l+\xi_{l^\prime}&amp;gt;0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2388" LastEditorUserId="123" LastEditDate="2019-09-20T17:56:04.587" LastActivityDate="2019-09-20T17:56:04.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2603" PostTypeId="1" AcceptedAnswerId="2604" CreationDate="2019-09-20T22:12:49.190" Score="9" ViewCount="682" Body="&lt;p&gt;I recently started working on the classical split delivery vehicle routing problem (SDVRP). I appreciate if someone could let me know where to download benchmark instances for this problem? I am also interested to know what problem instances are still unsolved. Is this information available and updated in the proposed data sets or I should read recent papers to find out?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could find &lt;a href=&quot;https://w1.cirrelt.ca/~vidalt/en/VRP-resources.html&quot; rel=&quot;noreferrer&quot;&gt;this website&lt;/a&gt; and it mentions something about &quot;split library&quot; which is confusing to me as it seems to be an algorithm that is not relevant to SDVRP. Any ways, the website has instances for SDVRP with time windows but I could not find simple SDVRP instances. A friend told me that I could also use VRP instances instead of SDVRP instances. Is that a good idea? I prefer not to do this as I am mainly interested to know about the SDVRP instances commonly used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://neumann.hec.ca/chairedistributique/data/&quot; rel=&quot;noreferrer&quot;&gt;This website&lt;/a&gt; has two sets of SDVRP instances (old and new), but I could not find their solution status and that when and in which publication they were introduced.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastEditorUserId="123" LastEditDate="2019-09-21T07:45:49.610" LastActivityDate="2019-09-23T07:59:12.467" Title="Vehicle routing benchmark instances" Tags="|reference-request|vehicle-routing|benchmark|data|split-delivery-routing|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2604" PostTypeId="2" ParentId="2603" CreationDate="2019-09-20T23:09:38.023" Score="9" Body="&lt;p&gt;For a table of benchmark instances on SDVRP you can have a look at &lt;em&gt;&lt;a href=&quot;https://www.researchgate.net/profile/Jean_Berger/publication/267641014/figure/tbl3/AS:667912717205510@1536254209335/Benchmark-on-known-SDVRP-problem-instances-30_W640.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Table 4&lt;/a&gt; (Benchmark on known SDVRP problem instances)&lt;/em&gt; of &lt;a href=&quot;https://www.researchgate.net/publication/267641014_The_multi-depot_split-delivery_vehicle_routing_problem_Model_and_solution_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ray &lt;em&gt;et al.&lt;/em&gt; (2014)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;. More details are provided in &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/0166218X9200172I&quot; rel=&quot;nofollow noreferrer&quot;&gt;reference [30]&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt; of the paper.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Ray, S., Soeanu, A., Berger, J., Debbabi, M. (2014). The multi-depot split-delivery vehicle routing problem: Model and solution algorithm. &lt;em&gt;Knowledge-Based Systems&lt;/em&gt;. 71. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] Dror, M., Laporte, G., Trudeau, P. (1994). Vehicle routing with split deliveries. &lt;em&gt;Discrete Applied Mathematics&lt;/em&gt;. 50(3):239-254. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-09-21T07:49:52.777" LastActivityDate="2019-09-21T07:49:52.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2605" PostTypeId="1" CreationDate="2019-09-21T01:08:32.750" Score="11" ViewCount="623" Body="&lt;p&gt;I've formulated my linear/nonlinear/integer/mixed-integer optimization problem in algebraic form (possibly with the help of the folks on this site). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now what? How do I solve it?&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-09-21T01:19:05.170" LastActivityDate="2019-09-21T01:19:05.170" Title="I've formulated my optimization model; now what?" Tags="|modeling|solver|modeling-languages|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2606" PostTypeId="2" ParentId="2605" CreationDate="2019-09-21T01:08:32.750" Score="11" Body="&lt;p&gt;You need to &lt;strong&gt;send your model to a solver.&lt;/strong&gt; Let's discuss the &lt;strong&gt;&quot;solver&quot;&lt;/strong&gt; part and the &lt;strong&gt;&quot;send&quot;&lt;/strong&gt; part separately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The &quot;solver&quot; part:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A solver is a piece of software that implements a general-purpose algorithm for solving optimization problems. Solvers implement algorithms like the simplex method, interior point methods, branch-and-bound, and branch-and-cut. Their goal is to be able to solve any problem, within certain classes (linear, integer, nonlinear, convex, etc.), that you can dream up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(That's the &lt;em&gt;goal&lt;/em&gt;. A solver's ability to solve your actual problem depends on the structure of your problem, the size of your instance, and many other factors.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A (very non-exhaustive) list of commercial solvers includes &lt;a href=&quot;https://www.ibm.com/analytics/cplex-optimizer&quot; rel=&quot;noreferrer&quot;&gt;CPLEX&lt;/a&gt;, &lt;a href=&quot;https://www.gurobi.com/&quot; rel=&quot;noreferrer&quot;&gt;Gurobi&lt;/a&gt;, and &lt;a href=&quot;https://www.mosek.com/&quot; rel=&quot;noreferrer&quot;&gt;Mosek&lt;/a&gt;. A (similarly non-exhaustive) list of open-source solvers includes &lt;a href=&quot;https://opensolver.org/&quot; rel=&quot;noreferrer&quot;&gt;OpenSolver&lt;/a&gt; for Excel, as well as the large suite of solvers in the &lt;a href=&quot;https://www.coin-or.org/&quot; rel=&quot;noreferrer&quot;&gt;COIN-OR&lt;/a&gt; project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many factors to consider when choosing a solver, including performance, cost, reliability, and the type of problems it is capable of solving (linear, integer, quadratic, second-order cone, etc.). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More about solvers on OR.SE:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/4/where-can-i-find-open-source-lp-solvers&quot;&gt;Where can I find open source LP solvers?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/892/how-to-evaluate-the-performance-of-open-source-solver&quot;&gt;How to evaluate the performance of open source solver?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/732/how-to-select-a-constraint-programming-solver&quot;&gt;How to select a Constraint Programming Solver&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/12/stochastic-programming-mip-solvers&quot;&gt;Stochastic programming MIP solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The &quot;send&quot; part:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the sake of simplicity, let's assume that your problem is a linear program (LP), which you have formulated algebraically as something like this:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat*}{2}&#xA;\text{minimize} \quad &amp;amp; \sum_{j=1}^n c_jx_j \\&#xA;\text{subject to} \quad &amp;amp; \sum_{j=1}^n a_{ij}x_j \le b_i &amp;amp;\qquad&amp;amp; \forall i=1,\ldots,m \\&#xA;&amp;amp; x_j \ge 0 &amp;amp;&amp;amp; \forall j=1,\ldots,n&#xA;\end{alignat*}&lt;/span&gt;&#xA;Or, in matrix form:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\text{minimize} \quad &amp;amp; \mathbf{cx} \\&#xA;\text{subject to} \quad &amp;amp; \mathbf{Ax} \le {\mathbf b} \\&#xA;&amp;amp; {\mathbf x} \ge {\mathbf 0}&#xA;\end{align*}&lt;/span&gt;&#xA;The solver needs to know the matrix &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}$&lt;/span&gt; and the vectors &lt;span class=&quot;math-container&quot;&gt;$\mathbf{c}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}$&lt;/span&gt;, as well as some other information like the sense of the objective function (min/max), bounds on the decision variables, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The naive way to approach this is to build the matrix and vectors explicitly and then pass them to the solver. This is &lt;em&gt;possible&lt;/em&gt;—for example, MATLAB's &lt;code&gt;linprog&lt;/code&gt; function works like this—but it is extremely tedious and error-prone if your model is anything other than a tiny, toy model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An easier and much more flexible approach is to use a &lt;strong&gt;modeling language&lt;/strong&gt;, or &lt;strong&gt;modeling package&lt;/strong&gt; in a language of your choice. Modeling languages/packages will do the tedious work of translating your algebraic model into one that a solver can understand, and the reverse work of translating the solver's output into formats that you can understand. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modeling languages include &lt;a href=&quot;https://ampl.com/&quot; rel=&quot;noreferrer&quot;&gt;AMPL&lt;/a&gt;, &lt;a href=&quot;https://www.gams.com/&quot; rel=&quot;noreferrer&quot;&gt;GAMS&lt;/a&gt;, and &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.ide.help/OPL_Studio/maps/groupings/opl_Language.html&quot; rel=&quot;noreferrer&quot;&gt;OPL&lt;/a&gt;. They are standalone programming languages specialized for mathematical optimization, with their own syntax, commands, etc. Some are free, others are not, and some have free trial versions or free licenses for academia or other special uses. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modeling packages are meant to be used within another programming language. These include &lt;a href=&quot;https://pypi.org/project/PuLP/&quot; rel=&quot;noreferrer&quot;&gt;PuLP&lt;/a&gt; and &lt;a href=&quot;http://www.pyomo.org/&quot; rel=&quot;noreferrer&quot;&gt;Pyomo&lt;/a&gt; for Python, &lt;a href=&quot;https://github.com/JuliaOpt/JuMP.jl&quot; rel=&quot;noreferrer&quot;&gt;JuMP&lt;/a&gt; for Julia, and &lt;a href=&quot;https://yalmip.github.io/&quot; rel=&quot;noreferrer&quot;&gt;YALMIP&lt;/a&gt; for MATLAB. For the most part these packages are free.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, some commercial solvers offer their own modeling packages. These include &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/quickstart_mac/the_gurobi_python_interfac.html&quot; rel=&quot;noreferrer&quot;&gt;gurobipy&lt;/a&gt; for Gurobi + Python, &lt;a href=&quot;https://pypi.org/project/docplex/&quot; rel=&quot;noreferrer&quot;&gt;docplex&lt;/a&gt; for CPLEX + Python, and &lt;a href=&quot;https://www.ibm.com/analytics/optimization-modeling-interfaces&quot; rel=&quot;noreferrer&quot;&gt;CPLEX Concert Technologies&lt;/a&gt; for CPLEX + C++, Java, or C#. In the special case of Excel's Solver and OpenSolver, Excel plays the role of the modeling language. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More about modeling languages/packages on OR.SE:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/1366/comparison-of-algebraic-modelling-languages-and-general-programming-languages&quot;&gt;Comparison of Algebraic modelling languages and general programming languages&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/1504/what-is-the-purpose-of-libraries-like-pyomo-and-google-or-tools/1505#1505&quot;&gt;What is the purpose of libraries like Pyomo and Google OR tools?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/2593/when-should-i-use-a-solver-for-ip-and-mip-and-can-i-just-use-a-library-from-pyth&quot;&gt;When should I use a solver for IP and MIP and can I just use a library from Python, R, Matlab, etc...?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-09-21T01:08:32.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2607" PostTypeId="5" CreationDate="2019-09-21T01:25:34.163" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-09-21T01:25:34.163" LastActivityDate="2019-09-21T01:25:34.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2608" PostTypeId="4" CreationDate="2019-09-21T01:25:34.163" Score="0" Body="For questions related to (algebraic) modeling languages such as AMPL and GAMS, which facilitate the process of translating an optimization model written in algebraic form to the matrices, vectors, and other data needed by general-purpose solvers." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-09-21T01:25:34.163" LastActivityDate="2019-09-21T01:25:34.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2609" PostTypeId="1" CreationDate="2019-09-21T02:16:19.433" Score="6" ViewCount="86" Body="&lt;p&gt;I can see that this algorithm is quite popular, and that one of the original papers now has 820 citations on Google Scholar. However, what are the most highly cited applications of it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If in Google Scholar I click on a paper about the reverse search algorithm, I can get a list of the papers that cited it, in order of most highly cited papers to least highly cited papers. For example: &lt;a href=&quot;https://scholar.google.com/scholar?oi=bibs&amp;amp;hl=en&amp;amp;cites=4354690463473566057&amp;amp;as_sdt=5&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. However you can see in this case that the most popular works that cited the paper, are books or surveys that mention the paper (along with mentioning every other paper in the field), and so do not give any indication about the popularity of a specific application of the method itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems the answer to this question would best be given by experts in the field who would know how to immediately sift through those Google Scholar citations and pick out the ones that they know to be relevant. I ask the question here in case some of those experts may be in this Stack Exchange community.&lt;/p&gt;&#xA;" OwnerUserId="727" LastEditorUserId="727" LastEditDate="2019-09-21T17:17:38.010" LastActivityDate="2019-09-21T17:17:38.010" Title="What are the top three applications (in terms of number of citations) of the &quot;reverse search&quot; algorithm of David Avis?" Tags="|combinatorial-optimization|applications|algorithms|polyhedra|convex-hull|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2610" PostTypeId="1" CreationDate="2019-09-21T02:20:48.157" Score="10" ViewCount="391" Body="&lt;p&gt;Is the &quot;reverse search&quot; algorithm of David Avis the state-of-the-art method for finding discrete solutions to a system of linear inequalities? If it is not, then what is?&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; inequalities in &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; dimensions, the most expensive part of Avis's algorithm seems to complete in &lt;span class=&quot;math-container&quot;&gt;$\mathcal{O}(md^2)$&lt;/span&gt; time, although it has to be repeated &lt;span class=&quot;math-container&quot;&gt;$N_b$&lt;/span&gt; times where &lt;span class=&quot;math-container&quot;&gt;$N_b$&lt;/span&gt; is the number of &quot;bases&quot;, which is a bit unpredictable. &lt;/p&gt;&#xA;" OwnerUserId="727" LastEditorUserId="727" LastEditDate="2019-09-21T17:11:26.187" LastActivityDate="2019-09-22T09:33:47.073" Title="Is the &quot;reverse search&quot; algorithm of David Avis the state-of-the-art method for finding discrete solutions to a system of linear inequalities?" Tags="|optimization|algorithms|valid-inequalities|polyhedra|convex-hull|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2611" PostTypeId="2" ParentId="1015" CreationDate="2019-09-21T05:13:22.353" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Q: It seems to me, based on the documentation available, that specifying &quot;blended&quot; objectives is no different from the manual weighted-sum approach? ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's two different explanations of the same way of specifying the same parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the prior section of the documentation titled: &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/multi_objective_attributes.html&quot; rel=&quot;noreferrer&quot;&gt;Multi-objective Attributes&lt;/a&gt; it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;These are the attributes for setting and querying multiple objectives (refer to the &quot;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/multiple_objectives.html#sec:MultipleObjectives&quot; rel=&quot;noreferrer&quot;&gt;Multiple Objectives&lt;/a&gt;&quot; section for additional information on multi-objective optimization).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Subsections&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;ObjN&lt;/li&gt;&#xA;  &lt;li&gt;ObjNCon&lt;/li&gt;&#xA;  &lt;li&gt;ObjNPriority&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/objnweight.html&quot; rel=&quot;noreferrer&quot;&gt;ObjNWeight&lt;/a&gt; &lt;span class=&quot;math-container&quot;&gt;$\Large{\color{red}{\Leftarrow\!\!\!\bbox{\small\text{ This is the parameter you asked about. See below.}}}}$&lt;/span&gt;&lt;/li&gt;&#xA;  &lt;li&gt;ObjNRelTol&lt;/li&gt;&#xA;  &lt;li&gt;ObjNAbsTol&lt;/li&gt;&#xA;  &lt;li&gt;ObjNVal&lt;/li&gt;&#xA;  &lt;li&gt;ObjNName&lt;/li&gt;&#xA;  &lt;li&gt;NumObj&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The &quot;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/multiple_objectives.html#sec:MultipleObjectives&quot; rel=&quot;noreferrer&quot;&gt;Multiple Objectives&lt;/a&gt;&quot; section (mentioned above) says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot; While typical optimization models have a single objective function, real-world optimization problems often have multiple, competing objectives. For example, in a production planning model, you may want to both maximize profits and minimize late orders, or in a workforce scheduling application, you may want to minimize the number of shifts that are short-staffed while also respecting worker's shift preferences.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The main challenge you face when working with multiple, competing objectives is deciding how to manage the trade-offs between them. Gurobi provides tools that simplify the task: Gurobi allows you to blend multiple objectives, to treat them hierarchically, or to combine the two approaches. &lt;strong&gt;In a blended approach, you optimize a weighted combination of the individual objectives&lt;/strong&gt;. In a hierarchical or lexicographic approach, you set a priority for each objective, and optimize in priority order. When optimizing for one objective, you only consider solutions that would not degrade the objective values of higher-priority objectives. Gurobi allows you to enter and manage your objectives, to provide weights for a blended approach, or to set priorities for a hierarchical approach.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Subsections&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/specifying_multiple_object.html&quot; rel=&quot;noreferrer&quot;&gt;Specifying Multiple Objectives&lt;/a&gt;&#xA;  &lt;span class=&quot;math-container&quot;&gt;$\require{menclose}$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/working_with_multiple_obje.html&quot; rel=&quot;noreferrer&quot;&gt;Working With Multiple Objective&lt;/a&gt; &lt;span class=&quot;math-container&quot;&gt;$\Large{\color{red}{\Leftarrow\!\!\!\bbox{\small\text{ This is the first link in your question.}}}}$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/additional_details.html&quot; rel=&quot;noreferrer&quot;&gt;Additional Details&lt;/a&gt;&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;From your first link:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Blended Objectives&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A blending approach creates a single objective by taking a linear combination of your objectives. You provide a weight for each objective as an argument to &lt;strong&gt;setObjectiveN&lt;/strong&gt;. Alternatively, you can use the &lt;strong&gt;ObjNWeight&lt;/strong&gt; attribute, together with &lt;strong&gt;ObjNumber&lt;/strong&gt;. The default weight for an objective is 1.0.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From the webpage: &quot;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/ampl-gurobi/parameters.html&quot; rel=&quot;noreferrer&quot;&gt;AMPL-Gurobi Parameter Reference&lt;/a&gt;&quot;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;feasrelax&lt;br&gt;&#xA;  &amp;emsp; &amp;emsp; Whether to modify the problem into a feasibility relaxation problem:&lt;br&gt;&#xA;  &amp;emsp; &amp;emsp; 0 = no (default)&lt;br&gt;&#xA;  &amp;emsp; &amp;emsp; 1 = yes, minimizing the weighted sum of violations&lt;br&gt;&#xA;  &amp;emsp; &amp;emsp; 2 = yes, minimizing the weighted count of violations&lt;br&gt;&#xA;  &amp;emsp; &amp;emsp; 3 = yes, minimizing the sum of squared violations&lt;br&gt;&#xA;  &amp;emsp; &amp;emsp; 4-6 = same objective as 1-3, but also optimize the original objective, subject&lt;br&gt;&#xA;  &amp;emsp; &amp;emsp; to the violation objective being minimized&lt;br&gt;&#xA;  &amp;nbsp;&lt;br&gt;&#xA;  &amp;emsp; &amp;emsp; Weights are given by suffixes .lbpen and .ubpen on variables and .rhspen on constraints (when positive), else by keywords lbpen, ubpen, and rhspen, respectively (default values = 1). Weights ≤ 0 are treated as ∞, allowing no violation.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can specify pre-solve tactics, dual (many) solver approaches, and weights/methods for each. Some methods work better on different datasets, allowing something that's working to succeed in one thread and a poorly progressing solution in another thread to be terminated; allowing the best/easiest/fastest/worst choice to be preferred depending on what it to be optimized for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/objnweight.html&quot; rel=&quot;noreferrer&quot;&gt;ObjNWeight&lt;/a&gt;&lt;/strong&gt; webpage says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Type: &amp;emsp; &amp;emsp; &amp;emsp; double&lt;br&gt;&#xA;  Modifiable: &amp;emsp; Yes&lt;br&gt;&#xA;  &amp;nbsp;&lt;br&gt;&#xA;  This attribute is used to query or modify the weight of objective &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; when doing blended multi-objective optimization. You set &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; using the &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/objnumber.html#parameter:ObjNumber&quot; rel=&quot;noreferrer&quot;&gt;ObjNumber&lt;/a&gt; parameter.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The default weight for an objective is 1.0.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The number of objectives in the model can be queried (or modified) using the &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/numobj.html#attr:NumObj&quot; rel=&quot;noreferrer&quot;&gt;NumObj&lt;/a&gt; attribute.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Please refer to the discussion of &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/multiple_objectives.html#sec:MultipleObjectives&quot; rel=&quot;noreferrer&quot;&gt;Multiple Objectives&lt;/a&gt; for more information on the use of alternative objectives.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;For examples of how to query or modify attributes, refer to our &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/attribute_examples.html#sec:AttributeExamples&quot; rel=&quot;noreferrer&quot;&gt;Attribute Examples&lt;/a&gt;.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Q: Does Gurobi tackle the optimization differently if the objective is constructed in one way versus the other? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, see above, &quot;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/specifying_multiple_object.html&quot; rel=&quot;noreferrer&quot;&gt;Specifying Multiple Objectives&lt;/a&gt;&quot;, &quot;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/working_with_multiple_obje.html&quot; rel=&quot;noreferrer&quot;&gt;Working With Multiple Objective&lt;/a&gt;&quot; and &quot;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/additional_details.html&quot; rel=&quot;noreferrer&quot;&gt;Additional Details&lt;/a&gt;&quot;; which are &lt;em&gt;previous&lt;/em&gt; and &lt;em&gt;next&lt;/em&gt; links of the links above.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-09-21T05:19:45.673" LastActivityDate="2019-09-21T05:19:45.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2612" PostTypeId="1" AcceptedAnswerId="2844" CreationDate="2019-09-21T15:48:53.940" Score="7" ViewCount="131" Body="&lt;p&gt;I have the following maximization program&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \max\limits_{\{q_i\}}&amp;amp;\quad\sum\limits_{i=1}^nq_i \\&#xA;    \text{s.t.}&amp;amp;\quad\begin{cases} k_j \geq \sum\limits_{i=1}^n q_i^{1 \over \alpha}x_{ij} &amp;amp; j=\{1,\dots,J\} \\&#xA;     q_i \geq 0 &amp;amp; i=\{1,\dots,n\} \\&#xA;    \end{cases} \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$\alpha&amp;gt;0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{ij}\geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k_j \geq 0$&lt;/span&gt; for all indices. I'd like to prove that if &lt;span class=&quot;math-container&quot;&gt;$\mathbf q^*=(q_1^*,\dots,q_n^*)$&lt;/span&gt; is a solution to this problem for  &lt;span class=&quot;math-container&quot;&gt;$\mathbf k^*=(k_1^*,\dots,k_J^*),$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\delta^{\alpha}\mathbf q^*$&lt;/span&gt; is a solution for &lt;span class=&quot;math-container&quot;&gt;$\delta \mathbf k^*.$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I proceed by contradiction: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume that the solution for &lt;span class=&quot;math-container&quot;&gt;$\delta \mathbf k^*$&lt;/span&gt; was &lt;span class=&quot;math-container&quot;&gt;$\mathbf {\hat q}$&lt;/span&gt; and such that &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i=1}^n \hat q_i&amp;gt;\delta^{\alpha}\sum\limits_{i=1}^n q_i^*$&lt;/span&gt;. Consider &lt;span class=&quot;math-container&quot;&gt;$\mathbf {\bar q}=\dfrac1{\delta^{\alpha}}\mathbf {\hat q}.$&lt;/span&gt; It is easily seen that &lt;span class=&quot;math-container&quot;&gt;$\mathbf {\bar q}$&lt;/span&gt; is feasible for &lt;span class=&quot;math-container&quot;&gt;$\mathbf k^*$&lt;/span&gt;. But we have that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n \bar q_i&amp;gt;\sum_{i=1}^n q_i^*,$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so &lt;span class=&quot;math-container&quot;&gt;$\mathbf q^*$&lt;/span&gt; cannot be a solution for &lt;span class=&quot;math-container&quot;&gt;$\mathbf k^*$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this correct? I worry that if the program has multiple solutions (and this can be the case when &lt;span class=&quot;math-container&quot;&gt;$\alpha&amp;gt;1$&lt;/span&gt;) my proof is not general enough or even wrong altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Perhaps it would be more accurate to say that, letting &lt;span class=&quot;math-container&quot;&gt;$\mathbf S(\mathbf k) $&lt;/span&gt; denote the set of solutions to the maximization program for a given &lt;span class=&quot;math-container&quot;&gt;$\mathbf k$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$$\mathbf q^*\in \mathbf S(\mathbf k^*) \iff \delta^{\alpha}\mathbf q^*\in \mathbf S(\delta\mathbf k^*)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2391" LastEditorUserId="123" LastEditDate="2019-09-21T16:06:15.850" LastActivityDate="2019-10-16T21:11:02.917" Title="Solutions to a parametrized optimization problem" Tags="|optimization|nonlinear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2613" PostTypeId="2" ParentId="2610" CreationDate="2019-09-21T16:09:28.993" Score="5" Body="&lt;p&gt;I am not familiar with the &quot;reverse search&quot; algorithm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For solving systems of linear inequalities in practice, algorithms for integer programming or constraint programming are probably most applicable. If you are concerned about theoretical complexity, there exist algorithms to solve integer programming problems in polynomial time &lt;strong&gt;in fixed dimension&lt;/strong&gt;. For example, see the &lt;a href=&quot;https://en.wikipedia.org/wiki/Lenstra%E2%80%93Lenstra%E2%80%93Lov%C3%A1sz_lattice_basis_reduction_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;LLL algorithm&lt;/a&gt;. These algorithms are interesting from a theoretical point of view, but are not often used in practice.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2019-09-21T17:23:32.920" LastActivityDate="2019-09-21T17:23:32.920" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="2614" PostTypeId="1" AcceptedAnswerId="2618" CreationDate="2019-09-21T16:36:24.733" Score="10" ViewCount="615" Body="&lt;p&gt;Burke's theorem says that the output process of an &lt;span class=&quot;math-container&quot;&gt;$\rm M/M/1$&lt;/span&gt;, an &lt;span class=&quot;math-container&quot;&gt;$\rm M/M/C$&lt;/span&gt;, and a &lt;span class=&quot;math-container&quot;&gt;$\rm M/M/\infty$&lt;/span&gt; queue with arrival rate &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and service rate &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; follows a Poisson with parameter &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I was able to derive the proof for the &lt;span class=&quot;math-container&quot;&gt;$\rm M/M/1$&lt;/span&gt; easily using Laplace transforms:&lt;/p&gt;&#xA;&lt;p&gt;For the busy period, the time spent in between departures is given by an exponential distribution with parameter &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;. For the non-busy period the inter-departure is given by a sum of an inter-arrival and one service time.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}LD(s)&amp;amp;=\frac{\lambda}{\mu}\cdot\frac{\mu}{\mu+s}+(1−\frac{\lambda}{\mu})\cdot\frac{\lambda}{\lambda+s}\cdot\frac{ \mu}{\mu+s}=\frac{\lambda}{\lambda+s}\\D(t)&amp;amp;=\lambda e^{-\lambda t}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, I am struggling immensely to derive the proof for the &lt;span class=&quot;math-container&quot;&gt;$\rm M/M/\infty$&lt;/span&gt; case. Can someone point out where I am going wrong?&lt;/p&gt;&#xA;&lt;p&gt;So far I have for the busy period: &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i=1}^\infty e^{-\lambda/μ}\cdot \frac{i\mu}{ i\mu+s}$&lt;/span&gt;. I am not even sure if this is correct. Do we need to account for the possibility of new arrivals before the departure too? How one would go with that?&lt;/p&gt;&#xA;&lt;p&gt;Also, how would I set it up for the non-busy period? And how do I deal with this &lt;span class=&quot;math-container&quot;&gt;$\frac{i\mu}{ i\mu+s}$&lt;/span&gt; term in the busy one?&lt;/p&gt;&#xA;" OwnerUserId="2392" LastEditorUserId="491" LastEditDate="2020-11-03T03:46:52.017" LastActivityDate="2020-11-03T03:46:52.017" Title="The departure process of an $\rm M/M/\infty$ queue" Tags="|probability-theory|queuing-theory|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2615" PostTypeId="1" AcceptedAnswerId="2617" CreationDate="2019-09-21T16:50:03.300" Score="7" ViewCount="2385" Body="&lt;p&gt;I'm trying to create an assignment optimization model where the areas are assigned to either the south or north school districts so that the total distance is minimized. Each school must have at least 1500 students, an average income of at least $85,000 and a minority % of at least 10%. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue I am having is that when I use solver to find a solution by changing cells G4:G13 (H4:H13 is calculated to be the opposite), there seems to be at least one iteration where the denominator of the average income of a school is 0 (in other words, no districts assigned to one school) and of course this causes a dividing-by-0 error. I tried adding a constraint to ensure each school had at least one district in it which did nothing to solve my problem and I also tried suppressing the error with =IFERROR() which only made the model non-linear. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to use the Simplex LP method in solver for this assignment. Is there a way I can add these &quot;Average&quot; constraints without issue? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bSAzO.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bSAzO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2393" LastEditorUserId="123" LastEditDate="2019-09-21T16:52:16.147" LastActivityDate="2019-09-21T18:14:51.953" Title="Excel Solver linear programming - Is it possible to use average of values as a constraint without #DIV/0! errors or sacrificing linearity?" Tags="|optimization|linear-programming|solver|binary-variable|assignment-problem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2617" PostTypeId="2" ParentId="2615" CreationDate="2019-09-21T18:14:51.953" Score="11" Body="&lt;p&gt;Instead of&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{\textrm{Total school income}}{\textrm{Number of areas}} \ge \$ 85000$$&lt;/span&gt;&#xA;you could have a constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\textrm{Total school income} \ge \$ 85000 \times \textrm{Number of areas}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, you won't have any problems when the number of areas is zero. It also makes the model linear instead of non-linear, which is usually a good thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative would be to add constraints to require that each district has at least one area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would probably use both suggestions at the same time.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-09-21T18:14:51.953" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2618" PostTypeId="2" ParentId="2614" CreationDate="2019-09-21T19:42:49.407" Score="6" Body="&lt;p&gt;The following proof approach for Bruke's Theorem was given in &lt;a href=&quot;http://www.richardclegg.org/sites/default/files/Lecture10_05.pdf&quot; rel=&quot;noreferrer&quot;&gt;this Lecture&lt;/a&gt;  by &lt;em&gt;Richard Clegg&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Definition:&lt;/em&gt; A chain is called time-reversible if &lt;span class=&quot;math-container&quot;&gt;$p_{ij} = p^*_{ij}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. This occurs if and only if:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{ij}\pi_i = p_{ji}\pi_j \ \ \forall i, j$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the Birth-Death processes are time-reversible. Therefore all the queues which can be modelled as such are, themselves time-reversible. This includes the &lt;span class=&quot;math-container&quot;&gt;$M/M/1$&lt;/span&gt;, the &lt;span class=&quot;math-container&quot;&gt;$M/M/m$&lt;/span&gt; and the &lt;span class=&quot;math-container&quot;&gt;$M/M/\infty$&lt;/span&gt; queues. Therefore, queue which can be represented as a Birth-Death process can be considered, once it has reached the steady-state. An important point here is that the departure process of the forward system is the arrival process of the forward system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Broke's Theorem:&lt;/em&gt; For a &lt;span class=&quot;math-container&quot;&gt;$M/M/1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M/M/m$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$M/M/\infty$&lt;/span&gt; queue in the steady-state then: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The departure process is Poisson with a rate of &lt;span class=&quot;math-container&quot;&gt;$λ$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;At the time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; the number of customers is independent of the sequence of departure times prior to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Proof.&lt;/em&gt; Part (1) follows immediately from the fact that the arrival process is Poisson with rate &lt;span class=&quot;math-container&quot;&gt;$λ$&lt;/span&gt; the time reverse of this is also a Poisson with rate &lt;span class=&quot;math-container&quot;&gt;$λ$&lt;/span&gt;. Part (2) follows from the fact that the departures prior to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; in the reversed system is the same process as the arrival process after &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; in the reversed process. It can be seen that the number in the system queue is independent of the arrivals after that point in a Poisson system.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-09-21T19:42:49.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2619" PostTypeId="1" CreationDate="2019-09-21T23:30:03.687" Score="9" ViewCount="170" Body="&lt;p&gt;Given a CVRP where the number of trucks is not constrained, is there an upper bound on the number of trucks used in an optimal solution in terms of number of customers, some distances, capacities, and demands?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the most general level I would like to say something about the case of heterogeneous vehicles, heterogeneous demand, and even the possibility of splitting demands across vehicles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, the case of homogeneous vehicles, homogeneous demand of say 1, and no splitting of demand is also of interest for this.&lt;/p&gt;&#xA;" OwnerUserId="2398" LastEditorUserId="2398" LastEditDate="2019-09-23T02:43:03.187" LastActivityDate="2019-09-23T07:22:18.997" Title="CVRP With Unconstrained Fleet Size: Upper Bound on Optimal Fleet Size" Tags="|combinatorial-optimization|vehicle-routing|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2620" PostTypeId="1" AcceptedAnswerId="2651" CreationDate="2019-09-22T00:24:38.537" Score="11" ViewCount="234" Body="&lt;p&gt;I'm working with a sort of pickup delivery problem right now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We need to assign vehicles to routes and requests to those vehicles. Each request has its due date, client and may be delivered in one of multiple possible trips departing from depot time windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The routes are predetermined, so we don't have routing decisions!&lt;/strong&gt; This part is giving me a headache, since it looks more like an assignment problem but with many features of routing problems. I am quite lost... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on benchmark problems to look after?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; by suggestions of Ruslan for better explanation&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By predetermined routes, I mean that the sequence of clients that a vehicle will visit is already known (ex.[2,3,5,6]). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The depot time windows are operational constraints meaning when we can start loading the vehicle with cargo and the maximum amount of time available for loading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not necessary to have a vehicle assigned to every trip, only if a delivery is performed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A solution structure example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3 routes, 2 trips for each&lt;/p&gt;&#xA;&#xA;&lt;p&gt;trips = [trip1, trip2, trip3, trip4...]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Total clients = [1,2,3,4,5,6,7,8,9,10]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vehicles = [v0,v1,v2,v3]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;requests = [r1, r2,...]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|Trip   |time window |vehicle|Clients       |Requests delivered |&#xA;|:-----:|:----------:|:-----:|:------------:|:-----------------:|&#xA;|trip 1 |  [t1,t2]   | v1    |[2,3,5,6]     |  [r1, r2, ...]    |&#xA;|trip 2 |  [t3,t4]   | v3    |[2,3,5,6]     |  [r, r, ...]      |&#xA;|trip 3 |  [t5,t6]   | none  |[4,1,7]       |       --          |&#xA;|trip 4 |  [t7,t8]   | v2    |[4,1,7]       |  [r, r, ...]      |&#xA;|trip 5 |  [t9,t10]  | v0    |[10,8,9]      |  [r, r, ...]      |&#xA;|trip 5 |  [t9,t10]  | none  |[10,8,9]      |       --          |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2397" LastEditorUserId="2397" LastEditDate="2019-09-24T01:31:09.883" LastActivityDate="2019-09-24T22:26:32.957" Title="Difficulties with finding equivalent problem on literature" Tags="|mixed-integer-programming|reference-request|vehicle-routing|assignment-problem|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2621" PostTypeId="2" ParentId="989" CreationDate="2019-09-22T01:18:20.473" Score="3" Body="&lt;p&gt;I think this question is very related to a different question I asked here: &lt;a href=&quot;https://or.stackexchange.com/questions/1380/are-there-any-real-world-problems-where-quadratization-helps-to-solve-something&quot;&gt;Are there any real-world problems where quadratization helps to solve something that couldn&amp;#39;t have been solved without quadratization?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/abs/1901.04405&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quadratization&lt;/a&gt; is the process of turning a cubic or higher-order problem into a quadratic one, so just like you, I was asking for specific super-quadratic problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many super-quadratic problems (for example in computer vision) but rather than doing &quot;cubic programming&quot; it is common to quadratize these problems and then do quadratic programming. Super-quadratic problems are sometimes called &quot;higher-order MRFs&quot; where MRF=Markov Random Field, and &lt;a href=&quot;https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=5206846&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; is an example from the computer vision literature where quadratization is &lt;em&gt;not&lt;/em&gt; performed (i.e. they actually try to solve the higher-order problem itself, as in your question). The abstract says their algorithm:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;is very general; we thus use it to derive a generic optimizer that&#xA;  can be applied to almost any higher-order MRF and that provably&#xA;  optimizes a dual relaxation related to the input MRF problem.&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="727" LastActivityDate="2019-09-22T01:18:20.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2623" PostTypeId="1" AcceptedAnswerId="2626" CreationDate="2019-09-22T06:56:57.223" Score="12" ViewCount="1710" Body="&lt;p&gt;I may not be correct but it seems that the leading operations research and management science journals (Informs OR and MS) do not publish any works on fuzzy logic or fuzzy sets. I could find only three papers in MS  and zero papers in OR that have &quot;fuzzy&quot; in their title. The first of the three papers in MS is from Zadeh and Richard Bellman (who are well known for their contributions) and has been cited over nine thousand times. The last of the three papers is published in  1983 as can be seen in the picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GPSGy.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GPSGy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it mean that fuzzy sets have nothing to do with OR? I don't understand why an OR paper relevant to fuzzy sets cannot or should not be submitted to such journals.&lt;/p&gt;&#xA;" OwnerUserId="2399" LastEditorUserId="123" LastEditDate="2019-09-22T11:58:43.630" LastActivityDate="2019-09-22T19:20:02.527" Title="Are fuzzy sets appreciated by OR community?" Tags="|journals|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2624" PostTypeId="2" ParentId="2610" CreationDate="2019-09-22T07:41:49.633" Score="5" Body="&lt;p&gt;As far as I can tell from the information I could on the &quot;Reverse Search&quot; algorithm, it is a technique that helps to enumerate combinatorial structures. In particular &lt;a href=&quot;https://link.springer.com/article/10.1007/s12532-017-0129-y&quot; rel=&quot;nofollow noreferrer&quot;&gt;the paper you mention in a comment&lt;/a&gt; deals with vertex and facet enumeration. Since it is a bit unclear what you mean by &quot;discrete solutions&quot;, let us distinguish four cases.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Finding a single vertex of a polytope&lt;/strong&gt;: for this case, you can use any Linear Programming solver. There tools can even produce a &lt;em&gt;best&lt;/em&gt; vertex according to some linear objective function. Common tools to solve this in practice are the &lt;a href=&quot;https://en.wikipedia.org/wiki/Simplex_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;simplex method&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Interior-point_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;interior point methods&lt;/a&gt;. Compared to those techniques, using an enumeration method is probably like shooting a mosquito with a bazooka.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Finding a single integer point within a polytope&lt;/strong&gt;: in general this problem is NP-complete, so in the worst case we do not know a better way to do it that by some clever form of enumeration. However, the main reason why this is difficult is that we have no real guarantee that the vertices of a polytope are actually integer points. If we have a special case where we do know that the vertices of the polytope are integer, for example because your system of inequalities is &lt;a href=&quot;https://en.wikipedia.org/wiki/Unimodular_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;totally unimodular&lt;/a&gt;, or if for some reason you are sure that your system of inequalities defines all the facets of the convex hull of the integer points within your polytope, this case reduces to case 1. In practice, this problem is solved using a combination of Branch-and-Bound and Linear Programming techniques: in each step you solve a linear program. If it results in an integer point, you are happy. If it does not, you take a fractional variable of the vertex you found, and create two sub-problems: one where that variable can be at most its current value rounded down, and another where that variable must be at least its current value rounded up. These sub-problems can be easily derived by introducing a new inequality into your system.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Enumerating all vertices of a polytope&lt;/strong&gt;: since the number of vertices of a polytope can already be exponential in the number of inequalities and dimensions of your system, this is a problem that has exponential output. Since the amount of output of an algorithm is a lower bound on the running time, it is implied this problem takes exponential time in the worst case, even under the unlikely assumption that P=NP. This seems to be the problem that the &quot;Reverse Search&quot; algorithm tries to tackle. I think the number of vertices of the polytope gives a lower bound for the number of bases of the polytope (since the simplex method basically starts out with a base, and adjusts it to find a new vertex in each step). As the reverse search algorithm must be repeated for every base, this would imply it is an exponential time algorithm in the worst case. Note that even counting the number of vertices of a polytope, which is easier than enumeration since you do not need to output the actual vertices, is already difficult in general, see for example &lt;a href=&quot;https://epubs.siam.org/doi/abs/10.1137/0607036?journalCode=sjamdu&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; or &lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.706.5186&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Enumerating the vertices of the convex hull of integer points within a polytope&lt;/strong&gt;: This problem combines the issues we have in case 2 and case 3. I did not read deep enough into the paper to see if this case is also covered, but I know that some researchers in the operations research communities use tools that can do this. I can imagine those tools are indeed based on the reverse search algorithm, although I don't know for sure. The main reason why these tools are used, is to obtain descriptions of the facets of an integer polytope, and check if some structure can be found in the inequalities that correspond to the facets. That way, researchers can try and develop valid inequalities.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1047" LastEditorUserId="123" LastEditDate="2019-09-22T08:42:31.040" LastActivityDate="2019-09-22T08:42:31.040" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2625" PostTypeId="2" ParentId="2623" CreationDate="2019-09-22T08:10:41.067" Score="7" Body="&lt;p&gt;In my opinion, fuzzy sets inherently suggest a notion of uncertainty, e.g. a statement may be “half-true” as it cannot be clearly determined whether it is true or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This type of uncertainty is very often dealt with in OR through e.g. stochastic programming. So I don’t think there is any limitation of using fuzzy sets in OR, for as long as it solves the problem. In fact, I for one would be curious to see what type of use fuzzy sets could have in our community.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-09-22T08:10:41.067" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2626" PostTypeId="2" ParentId="2623" CreationDate="2019-09-22T09:07:11.713" Score="13" Body="&lt;p&gt;Generally, fuzzy sets are not appreciated by the operations research community, particularly in the United States.  The topic is not included in any of the standard OR textbooks (like Taha &quot;Operations Research&quot; or Winston &quot;Operations Research: Applications and Algorithms&quot;) nor is it part of the curriculum of any undergraduate or graduate program I have seen.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Operations research journals seem to differ as to whether they will look at fuzzy set papers.  The OP mentions the INFORMS journals &quot;Operations Research&quot; and &quot;Management Science&quot; as not publishing fuzzy set papers.  Another journal (non-US) I know which is good, but not top tier, will not send fuzzy set papers out for review and simply returns them to the author.  But European Journal of Operational Research will publish fuzzy set papers, as will the UK Journal of the Operational Research Society.  I do not know if UK or European curricula are more likely to include the topic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inclusion of &quot;fuzzy sets&quot; in operations research seems itself to be fuzzy.&lt;/p&gt;&#xA;" OwnerUserId="214" LastActivityDate="2019-09-22T09:07:11.713" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2627" PostTypeId="2" ParentId="2610" CreationDate="2019-09-22T09:33:47.073" Score="6" Body="&lt;p&gt;There are many algorithms suggested for converting the &quot;external&quot; representation of a polyhedron (i.e., the set of solutions to a finite set of linear inequalities) into an &quot;internal&quot; one (i.e., a finite set of generators, extreme points and extreme rays). At it's core there often is some sort of finding all (discrete) solutions to a set of linear inequalities. The Fourier-Motzkin Elimination comes to mind here. The additonal requirement of discreteness and &quot;all solutions&quot; came later, but there are implementations out there. A classic is &lt;a href=&quot;https://wwwproxy.iwr.uni-heidelberg.de/groups/comopt/software/PORTA/&quot; rel=&quot;noreferrer&quot;&gt;porta&lt;/a&gt; and I would, still today, always start from there.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-09-22T09:33:47.073" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2628" PostTypeId="2" ParentId="2558" CreationDate="2019-09-22T17:34:07.020" Score="3" Body="&lt;p&gt;Actually, I asked myself the same question some time ago. But after some time I figured out that the question is just too imprecise. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Faster&quot; can mean a lot of things. It can mean that the average time is shorter, that you win in the majority of benchmark instances (which is not a good measure in general, especially because it is intransitive), that you find a &quot;significant&quot; (however you define that, e.g. 50% better) advantage in the majority of cases, that the worst case is better etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of these measures (and many more) are sensible for their use cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I very much understand the desire to rank algorithms, and it is important in science to distinguish between the fruitful and less fruitful approaches. But first of all you need to come up with a justified definition of &quot;faster&quot; that applies to the circumstances in which the algorithm shall be used. &lt;/p&gt;&#xA;" OwnerUserId="50" LastActivityDate="2019-09-22T17:34:07.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2629" PostTypeId="2" ParentId="2623" CreationDate="2019-09-22T19:20:02.527" Score="8" Body="&lt;p&gt;Disclaimer: The following is based on my own thoughts and discussions with colleagues, hence not supported with hard data. Also, I'm no expert in fuzzy theory, but I've good experience with robust optimization and stochastic programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One line research in OR, which is relatively very active, is the fuzzification of MADM methods (e.g., fuzzy AHP or fuzzy TOPSIS). Another line of research is the fuzzification of DEA models. In addition, I've seen many papers on SCM considering fuzzy input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the possible publication venues, as @michael-trick already mentioned, journals such as EJOR, JORS, and OMEGA publish papers in this area on a regular basis. In addition, journals dedicated to artificial intelligence (e.g., Expert Systems with Application and Information Science) or OR applications (e.g., Computers &amp;amp; Industrial Engineering) usually publish a good number of fuzzy papers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About why fuzzy is relatively neglected by North American researchers, here is my two cents. Fuzzy sets were originally intended for modeling ambiguity. Fuzzy sets are a better tool to be used in soft-OR models (usually advocated by European researchers), as opposed to hard-OR models (usually advocated by North American researchers). To clarify this, I've to explain the idea behind fuzzy sets. For this matter, a classical example is that different people have different perceptions of hot, warm, and cold water and those perceptions are not necessarily related to the water temperature. This idea is not very consistent with the input data used usually used in optimization models. Following the fuzzy terminology, numbers used in optimization are crisp by nature and usually have no ambiguity in them. For example, consider customer's demand in a supply chain model. Perhaps you don't know what the future demand would be, however the demand itself is crisp. In other words, the fact that you cannot measure the future demand does not make it ambiguous. It's just unknown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I do not think that optimization models with fuzzy parameters and stochastic programming (or even robust optimization models) are very comparable. The types of uncertainty considered by each method are very different (fuzzy membership function vs. probability distribution or uncertainty intervals). Also, stochastic programming and robust optimization models have structural properties for modeling the uncertainty and how to deal with it, while, AFAIK, fuzzy models lack such properties. For details, please see a relatively similar question on OR-X, available from &lt;a href=&quot;https://www.or-exchange.org/questions/14232/fuzzy-mathematical-programming-vs-stochastic-programming&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2019-09-22T19:20:02.527" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2630" PostTypeId="1" AcceptedAnswerId="2645" CreationDate="2019-09-22T21:04:39.687" Score="13" ViewCount="1327" Body="&lt;p&gt;Many practical optimization models (specially MIPs) are NP-Hard and solving them need much time even with the modern solvers like CPLEX or GUROBI. One of the best way (but not easy) is using decomposition techniques (at least for mathematician :) ). AFAIK, there are other ways to simplify MIPs which are done easier. Some of them are as follows. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Reformulation of the original problem to a tighter problem which, It needs to enough knowledge about the current model. it may be a bit hard. &lt;/li&gt;&#xA;&lt;li&gt;Using some useful concepts such as Lazy constraints which cause solving the model be faster (E.g. sub tour elimination in TSP). Many of advanced solvers have had such capabilities. &lt;/li&gt;&#xA;&lt;li&gt;Using GAP control in the Branch and Bound algorithm to achieve the desired solution in a reasonable time. &lt;/li&gt;&#xA;&lt;li&gt;Solution pools to solve problems as soon as possible (especially in scheduling models) but, may return suboptimal solutions.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question is:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would you know other efficient ways (as mentioned above) to solve practical MIPs without using complicated methods?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-09-24T12:24:07.257" Title="How could we simplify solving the large scale MIPs without using any advanced methods like decompositions?" Tags="|optimization|mixed-integer-programming|modeling|solver|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2631" PostTypeId="2" ParentId="2620" CreationDate="2019-09-22T23:22:26.980" Score="3" Body="&lt;p&gt;I tried to find the below-cited paper to read and answer your question but unfortunately, I couldn't find that. Anyway, in this paper, the authors investigated VRPPDTW (Vehicle Routing Problem with Pick up and Delivery with Time Windows) and proposed an exact algorithm (there are also some heuristic and metaheuristic approaches to solve this type of VRPs) to solve the problem. They mentioned that &quot; This algorithm uses a column generation scheme with a constrained shortest path as a subproblem. The algorithm can handle multiple depots and different types of vehicles.&lt;sup&gt;1&lt;/sup&gt;&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think if they modeled the problem in such a way that they first generate a subproblem to find the shortest path and then assign the customers to those routs, it will be your answer. The only thing that you need to change would be modifying the constraints of the subproblem (somehow relax them to let the predefined routes to be a feasible solution) and fix the objective function of the subproblem. The results of the model then would focus on the assignment part rather than first finding the shortest path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] Dumas, Yvan, Jacques Desrosiers, and Francois Soumis. &quot;The pickup and delivery problem with time windows.&quot; European journal of operational research 54.1 (1991): 7-22.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-09-22T23:22:26.980" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2632" PostTypeId="2" ParentId="33" CreationDate="2019-09-23T01:52:18.650" Score="7" Body="&lt;p&gt;To model &lt;span class=&quot;math-container&quot;&gt;$x=b \implies y=1$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$L \le x \le U$&lt;/span&gt;, you can do the following:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;L y^- + b y + (b+\delta)y^+ \le x &amp;amp;\le (b-\delta) y^- + b y + U y^+\\&#xA;y^- + y + y^+ &amp;amp;= 1 \\&#xA;y^-, y, y^+ &amp;amp;\in \{0,1\}&#xA;\end{align}&lt;/span&gt;&#xA;In fact, this formulation also enforces the converse &lt;span class=&quot;math-container&quot;&gt;$y=1 \implies x=b$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-09-23T01:52:18.650" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2633" PostTypeId="2" ParentId="2619" CreationDate="2019-09-23T04:47:05.907" Score="6" Body="&lt;p&gt;This article &lt;a href=&quot;https://arxiv.org/abs/1905.05557&quot; rel=&quot;noreferrer&quot;&gt;https://arxiv.org/abs/1905.05557&lt;/a&gt; might help you. The authors &quot;present an analytical upper bound on the number of required vehicles for vehicle routing problems with split deliveries and any number of capacitated depots.&quot; and &quot;discuss the validity of the bound for a wide variety of routing problems with or without split deliveries.&quot;&lt;/p&gt;&#xA;" OwnerUserId="2399" LastActivityDate="2019-09-23T04:47:05.907" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2634" PostTypeId="2" ParentId="2619" CreationDate="2019-09-23T07:22:18.997" Score="3" Body="&lt;p&gt;The &quot;knapsack relaxation&quot; or the bin packing problem will give you the minimum number of vehicles needed for a feasible solution. However, if you restrict the number of vehicles to this minimum value, you may change your optimal solution (it is unlikely but possible).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prove that an optimal solution does not use more than a certain number of vehicles, you need a lower bound. You may use for example the linear relaxation optimum value of some MIP formulation.&lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2019-09-23T07:22:18.997" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2635" PostTypeId="2" ParentId="2603" CreationDate="2019-09-23T07:43:56.813" Score="3" Body="&lt;p&gt;The usual way to check which instances are still open is to check the latest paper(s) on exact solution of the problem. The latest papers seem to be &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.2018.0825&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pubsonline.informs.org/doi/abs/10.1287/trsc.2018.0825&lt;/a&gt; (SDVRP with time windows) and &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2014.04.026&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.ejor.2014.04.026&lt;/a&gt; (standard SDVRP).&lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2019-09-23T07:43:56.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2636" PostTypeId="2" ParentId="2603" CreationDate="2019-09-23T07:59:12.467" Score="2" Body="&lt;p&gt;You might be able to adjust &lt;a href=&quot;https://github.com/ge0ffrey/vrp-dataset-generator&quot; rel=&quot;nofollow noreferrer&quot;&gt;my vrp generator code&lt;/a&gt; to generate some SDVRP problems. That way you'll immediately have road distances etc. I used it to create the &lt;a href=&quot;http://www.vrp-rep.org/datasets/item/2017-0001.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Belgium road-km/road-time/air - 50-2750 visits&lt;/a&gt; datasets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whatever you do, post the datasets on vrp-rep.org - we as a community should try to centralize all vrp datasets. (I am not affiliated with vrp-rep.org.)&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2019-09-23T07:59:12.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2637" PostTypeId="1" CreationDate="2019-09-23T08:41:42.240" Score="10" ViewCount="963" Body="&lt;p&gt;Not sure if this question is appropriate here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to run customized spline fitting with commercial package such as mosek and gurobi. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since beginning of this year, I tried to migrate to open source packages like tensorflow. I am surprised that the performance is not too bad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They only difference seems to me that commercial packages are faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's your view on this ? Can we say that commercial packages are more for real-time or semi-real-time problems where speed matters? &lt;/p&gt;&#xA;" OwnerUserId="2402" LastActivityDate="2019-09-23T14:06:13.843" Title="What's the use case of commercial optimizer when we have Tensorflow?" Tags="|software|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2638" PostTypeId="1" CreationDate="2019-09-23T12:18:21.710" Score="9" ViewCount="609" Body="&lt;p&gt;Mosek provided a concrete example of using the Huber loss function,&#xA;&lt;a href=&quot;https://nbviewer.jupyter.org/github/MOSEK/Tutorials/blob/version9/leastsquares/regression-leastsquares.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;Huber loss&lt;/a&gt;, which is great!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One problem I am trying to tackle is to use asymmetric loss, as described in the answer of &lt;a href=&quot;https://datascience.stackexchange.com/a/10474/74529&quot;&gt;asymmetric loss&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply speaking, instead of using a classic quadratic square error loss, the loss function becomes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}e &amp;amp;= y-y_{\text{predicted}}\\\text{loss} &amp;amp;= x\cdot x \cdot (\operatorname{sgn}(x) + a) \cdot(\operatorname{sgn}(x) + a).\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, the loss is not quadratic any more. The advantage of using some loss function, is that we can penalize under-estimate and over-estimate differently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can we somehow restructure the problem and make it solvable by Mosek (or other optimization tools)?&lt;/p&gt;&#xA;" OwnerUserId="2402" LastEditorUserId="1160" LastEditDate="2019-09-24T00:12:34.143" LastActivityDate="2019-09-24T00:12:34.143" Title="How can I model regression with an asymmetric loss function?" Tags="|optimization|modeling|quadratic-programming|loss-functions|fitting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2639" PostTypeId="2" ParentId="2638" CreationDate="2019-09-23T13:00:21.763" Score="11" Body="&lt;p&gt;I suspect you want to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_i \left[k_1\max(e_i,0)^2 + k_2\max(-e_i,0)^2\right]$&lt;/span&gt;. For instance, &lt;span class=&quot;math-container&quot;&gt;$a=0.5$&lt;/span&gt; would correspond to &lt;span class=&quot;math-container&quot;&gt;$k_1 = 0.25$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k_2 = 2.25$&lt;/span&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be formulated as a quadratic program by introducing new variables &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, using the objective &lt;span class=&quot;math-container&quot;&gt;$k_1 u^\top u + k_2 v^\top v$&lt;/span&gt; with the constraints &lt;span class=&quot;math-container&quot;&gt;$u\geq 0, u \geq e, v\geq 0, v\geq -e$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="487" LastEditorUserId="123" LastEditDate="2019-09-23T14:33:45.847" LastActivityDate="2019-09-23T14:33:45.847" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2640" PostTypeId="2" ParentId="2637" CreationDate="2019-09-23T14:06:13.843" Score="11" Body="&lt;p&gt;I'd say that you are comparing software packages with very different aims and capabilities. Tensorflow was developed to solve problems which involve (deep) neural nets. Mosek and gurobi on the other hand are usually used to solve optimization problems that involve discrete decisions (i.e. variables that can take only discrete values which means you are dealing with a Mixed-Integer Optimization Problem). While they are also able to solve (certain) continuous problems, they perform best on the former problems. Tensorflow on the other hand is specifically tailored for the neural nets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding your specific problem of spline fitting I'd suppose you do not have any discrete aspects? In that case you probably could use a variety of solvers from different areas (Ipopt for example is a nonlinear solver which probably could also be worth a try). Again, special tailored algorithms and program packages will very likely perform better than general purpose programs or algorithms that work on a generalized form of a problem.&lt;br&gt;&#xA;For example you can state &lt;a href=&quot;https://en.wikipedia.org/wiki/Support-vector_machine#Linear_SVM&quot; rel=&quot;noreferrer&quot;&gt;SVM&lt;/a&gt; as a linear problem and solve it via a linear solver (CLP, SCIP, Gurobi, Mosek, CPLEX, Xpress, you name it...) but specialized SVM solvers will probably perform better as they use special tricks which are inherent in the underlying structure of the problem. General problem solvers might not be able to detect these structures and thus perform not as good. To be honest I would be very interested in a benchmark between programs specifically written for SVM and general purpose LP solvers that solve the problem.&lt;/p&gt;&#xA;" OwnerUserId="137" LastActivityDate="2019-09-23T14:06:13.843" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2641" PostTypeId="1" AcceptedAnswerId="2642" CreationDate="2019-09-23T16:58:19.340" Score="8" ViewCount="1364" Body="&lt;p&gt;In a scheduling problem I want to assign the maximum number of tasks to one worker before assigning it to another. For example, if I have &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; tasks and &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; workers, the best assignment would be &lt;span class=&quot;math-container&quot;&gt;$(10, 0)$&lt;/span&gt; and the worst &lt;span class=&quot;math-container&quot;&gt;$(5, 5)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried the following ideas:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Iterative approach: assign tasks to each worker one by one with the objective of maximizing the number of assigned tasks. Didn't really work because there are constraints and objectives that take into account the other workers.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Maximize the sum of squares: &lt;span class=&quot;math-container&quot;&gt;$\sum(\text{number of tasks}^2)$&lt;/span&gt;, this way &lt;span class=&quot;math-container&quot;&gt;$(10, 0)$&lt;/span&gt; has a score of &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(5, 5)$&lt;/span&gt; a score of &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am going by the second approach but the solving speed drops quite a bit, not sure if it is because the problem is much more complex, or because it becomes quadratic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to model this objective? Maybe something in terms of distance?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: The logic of my current OR-Tools code is something along the lines of this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for w in workers:&#xA;    worker_task_count[w] = model.NewIntVar(&#xA;        0, number_tasks, f'{w}_task_count'&#xA;    )&#xA;    squared_count[w] = model.NewIntVar(&#xA;        0, number_tasks**2, f'{w}_squared_task_count'&#xA;    )&#xA;    model.Add(&#xA;        worker_task_count[w] == sum(&#xA;            assigned_tasks[w, t]&#xA;            for t in tasks&#xA;        )&#xA;    )&#xA;    model.AddMultiplicationEquality(&#xA;        squared_count[w],&#xA;        [worker_task_count[w], worker_task_count[w]]&#xA;    )&#xA;self.model.Add(objective == sum(squared_count.values()))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2019-09-25T20:52:57.177" LastActivityDate="2019-09-30T11:08:00.583" Title="Maximize assigned tasks to each worker" Tags="|python|scheduling|or-tools|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2642" PostTypeId="2" ParentId="2641" CreationDate="2019-09-23T19:06:45.167" Score="9" Body="&lt;p&gt;Why quadratic?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;just use a larger (linear) weight for tasks assigned to worker 1.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2019-09-23T19:06:45.167" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2643" PostTypeId="2" ParentId="2630" CreationDate="2019-09-24T01:06:35.730" Score="5" Body="&lt;p&gt;It depends on what we define as &quot;solving&quot;. There are many heuristic methods that are designed to find feasible solutions to MIPs (I would also include MINLPs), such as the A* algorithm, simulated annealing, the local search algorithm, tunneling, evolutionary algorithms, etc. These methods are usually used when:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The problem is too large.&lt;/li&gt;&#xA;&lt;li&gt;A solution is needed very quickly (e.g. pathfinding in video games or control problems).&lt;/li&gt;&#xA;&lt;li&gt;There is no budget for a commercial solver.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Other techniques used in various solvers would include Benders decomposition, outer approximation, the Quessada-Grossman algorithm, extended supporting hyperplanes, domain reduction, feasibility pumps, and elimination of redundant constraints and variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Implementing any of these algorithms is not what I would call hard per se, however it takes deep knowledge of the math and programming to create scalable and numerically stable implementations of most of this stuff. In my opinion, the easiest class of methods to code for scale as a non-professional would be evolutionary algorithms, otherwise we come across difficulties such as factorising massive matrices or propagation of error across millions of constraints, which very few people know how to properly code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, a commercial solver is invaluable when we want a solution that is likely to &quot;make sense&quot;. A lot of the time, non-global solutions to MIPs (especially MILPs) tend to not make any sense in practice, unless we have a very small optimality gap. In these types of situations our only option tends to be using methods such as the ones you described, usually in the form of a commercial solver (the quality of implementation makes a huge difference).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2019-09-24T01:13:00.703" LastActivityDate="2019-09-24T01:13:00.703" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="2644" PostTypeId="2" ParentId="2630" CreationDate="2019-09-24T06:26:39.040" Score="7" Body="&lt;p&gt;In some cases #matheuristics can be quite effective; see e.g. the tutorial &lt;a href=&quot;https://link.springer.com/referenceworkentry/10.1007/978-3-319-07153-4_14-1&quot; rel=&quot;noreferrer&quot;&gt;Fischetti M., Fischetti M. (2016) Matheuristics. In: Martí R., Panos P., Resende M. (eds) Handbook of Heuristics. Springer, Cham&lt;/a&gt; also available &lt;a href=&quot;https://www.researchgate.net/publication/313828030_Matheuristics&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="429" LastEditorUserId="49" LastEditDate="2019-09-24T12:24:07.257" LastActivityDate="2019-09-24T12:24:07.257" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2645" PostTypeId="2" ParentId="2630" CreationDate="2019-09-24T07:21:34.103" Score="13" Body="&lt;p&gt;In practical applications, you often need to speed up the optimization. Advanced decomposition methods add an extra layer of complexity to your code that needs to be maintained and kept bug-free. I, therefore, likes to avoid them to keep the code and model simple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some methods I like to use. Some of them have the downside that you won't necessarily find the optimal solution, but if you benchmark your different models you can get a good sense about the trade-offs between running time and solution quality. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Simplify the model&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Identify which constraints or objectives that contribute the most to the high solution time. Often a small part of the model can have a huge impact. Try to see if the parts of the model really are necessary for the solutions to be useful. Talk to the end-users and see if there are other ways they could be formulated that would make it easier to solve. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Reduce the solution space&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You will often have solutions that are very unlikely because they are expensive or have some bad features that makes them hard to use in practice. You can fix variables to zero that likely would result in bad solutions, or add some additional constraints to remove solutions that wouldn't be practical. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Warm starts&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is an easy one. Often you will have an existing solution that is almost feasible or just bad quality. Feed it into the solver as a start solution will usually give significant speed improvements. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Parameter tuning&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;MIP solvers are built to solve a large variety of different models. You can often get significant speed ups by tuning the parameters to your specific model. Both CPLEX and Gurobi have parameter tunning tools that can help you find better parameters.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Sequential optimization&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you have multiple levels of decisions. You can start by solving the most important decisions and fix those before you solve for the rest of the decisions.&#xA;A good example is this article by &lt;a href=&quot;https://www.researchgate.net/publication/220461816_Curriculum_based_course_timetabling_New_solutions_to_Udine_benchmark_instances&quot; rel=&quot;noreferrer&quot;&gt;Lach and Lübbecke (2012)&lt;/a&gt; where they solve a timetabling problem by first assigning the times for courses and then assign the rooms. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Fix-and-optimize&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can also use the MIP solver as part of a local search. If you have a start solution you can fix a part of the variables and solve the resulting smaller problem. You can then fix a different part of the variables and continue like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of this used to solve a timetabling problem can be seen in this paper by &lt;a href=&quot;https://link.springer.com/article/10.1007/s10732-018-9371-3&quot; rel=&quot;noreferrer&quot;&gt;Lindahl &lt;em&gt;et al.&lt;/em&gt; (2018)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Lach, G., Lübbecke, M. (2012). Curriculum based course timetabling: New solutions to Udine benchmark instances. &lt;em&gt;Annals of Operations Research&lt;/em&gt;. 194:255-272. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] Lindahl, M., Sørensen, M., Stidsen, T. R. (2018). A fix-and-optimize matheuristic for university timetabling. &lt;em&gt;Journal of Heuristics&lt;/em&gt;. 24(4):645-665. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="140" LastEditorUserId="123" LastEditDate="2019-09-24T07:27:43.400" LastActivityDate="2019-09-24T07:27:43.400" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2646" PostTypeId="1" CreationDate="2019-09-24T17:50:22.617" Score="8" ViewCount="177" Body="&lt;p&gt;Actually the question below is not specific to Gurobi, but that's the tool I am using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider a scheduling problem where a 2D array of binary variables &lt;span class=&quot;math-container&quot;&gt;$Z(i,v)$&lt;/span&gt; is defined, where &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is index of time slot, and &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is index of operation, each &lt;span class=&quot;math-container&quot;&gt;$Z(i,v)$&lt;/span&gt; is a 0-1 binary variable, &lt;span class=&quot;math-container&quot;&gt;$Z(i,v)=1$&lt;/span&gt; means operation &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is allocated to time slot &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now consider adding the following constraint/penalty based on &lt;span class=&quot;math-container&quot;&gt;$Z(i,v)$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A certain operation &lt;span class=&quot;math-container&quot;&gt;$v_0$&lt;/span&gt; can be scheduled multiple times, i.e., there are multiple &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; values where &lt;span class=&quot;math-container&quot;&gt;$Z(i,v_0) = 1$&lt;/span&gt;. We want to add constraint to the &quot;last &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&quot; where &lt;span class=&quot;math-container&quot;&gt;$Z(i,v_0)=1$&lt;/span&gt;, i.e., the last &lt;span class=&quot;math-container&quot;&gt;$v_0$&lt;/span&gt; operation. For example, in the last &lt;span class=&quot;math-container&quot;&gt;$v_0$&lt;/span&gt; operation the product volume &lt;span class=&quot;math-container&quot;&gt;$\operatorname{vol}(i, v_0)\ge100$&lt;/span&gt;. The problem is we must tell what is the &lt;em&gt;last&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; that satisfies &lt;span class=&quot;math-container&quot;&gt;$Z(i,v_0) = 1$&lt;/span&gt;, and only after that add &lt;span class=&quot;math-container&quot;&gt;$\operatorname{vol}(i,v_0)\ge100$&lt;/span&gt;, how to do that?&lt;/li&gt;&#xA;&lt;li&gt;This is an extension of the above problem. Here we consider multiple operations &lt;span class=&quot;math-container&quot;&gt;$v_0, v_1, \cdots, v_n$&lt;/span&gt;. In certain applications the &quot;order&quot; of those &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; operations matter, meaning that certain order could incur extra cost, and that the objective should contain a penalty term that is a function of the order. To add penalty, we should know the order first, which in turns means that we should extract all those &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; values where &lt;span class=&quot;math-container&quot;&gt;$Z(i, v_0)=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Z(i,v_1)=1$&lt;/span&gt;, etc.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Comment: if &lt;span class=&quot;math-container&quot;&gt;$Z(i,v)$&lt;/span&gt; is given, then I can just use a for loop to locate all those &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; values where &lt;span class=&quot;math-container&quot;&gt;$Z(i,v)=1$&lt;/span&gt;, the problem is &lt;span class=&quot;math-container&quot;&gt;$Z(i,v)$&lt;/span&gt; is part of the solution, and is unknown &lt;em&gt;during&lt;/em&gt; the solution process. That's what gets me confused. But I expect that Gurobi has some built-in syntax/function to handle those scenarios because technically it should be possible.&lt;/p&gt;&#xA;" OwnerUserId="2410" LastEditorUserId="123" LastEditDate="2019-09-24T18:43:47.293" LastActivityDate="2019-09-25T06:48:12.477" Title="Extract info from Gurobi binary variables during run-time" Tags="|mixed-integer-programming|gurobi|scheduling|penalty-based-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2647" PostTypeId="2" ParentId="2646" CreationDate="2019-09-24T18:18:08.150" Score="3" Body="&lt;p&gt;We can't modify the optimisation problem while it's being solved. What you could try instead is to solve once (maybe with a lax convergence criterion), add/update the constraints based on that solution, and then re-solve by warm-starting the problem using the solution from the previous step.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-09-24T18:18:08.150" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2648" PostTypeId="1" CreationDate="2019-09-24T19:44:11.027" Score="5" ViewCount="199" Body="&lt;p&gt;Reading the famous book by &lt;a href=&quot;http://www.math.nsc.ru/LBRT/k5/Scheduling/Scheduling_Theory,%20Algorithms,%20and%20Systems(Pinedo,2008).pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pinedo&lt;/a&gt;, I came across :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Usually, the subscript &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; refers to a job while the subscript &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&#xA;  refers to a machine. If a job requires a number of processing steps or&#xA;  operations then the pair &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; refers to the processing step or&#xA;  operation of job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on machine &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then he defines the processing time : &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt; represents the processing time of job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on machine &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On the other hand, &lt;a href=&quot;http://www.math.nsc.ru/LBRT/k5/Scheduling/BruckerSchedulingAlgorithms_Full.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Brucker&lt;/a&gt; defines the processing time as follows : &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; consists of &lt;span class=&quot;math-container&quot;&gt;$n_j$&lt;/span&gt; operations &lt;span class=&quot;math-container&quot;&gt;$O_{j1},..,O_{jn_j}$&lt;/span&gt;. Associated with  operation &lt;span class=&quot;math-container&quot;&gt;$O_{ji}$&lt;/span&gt;  a processing time &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;N.B: here &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; indicates the operations and not the machines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Associated with each operation &lt;span class=&quot;math-container&quot;&gt;$O_{ji}$&lt;/span&gt; a set of machines &lt;span class=&quot;math-container&quot;&gt;$\mu_{ji} \subseteq \{M_1,..,M_m\}$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$O_{ji}$&lt;/span&gt; may be processed on any machine in &lt;span class=&quot;math-container&quot;&gt;$\mu_{ji}$&lt;/span&gt;. Usually, all &lt;span class=&quot;math-container&quot;&gt;$\mu_{ji}$&lt;/span&gt; are one element sets or all &lt;span class=&quot;math-container&quot;&gt;$\mu_{ji}$&lt;/span&gt; are equal to the set of all machines.   In the first case, we have &lt;em&gt;dedicated&lt;/em&gt; machines. In the second case, the machines are called &lt;em&gt;parallel&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The definitions are not the same. For example, if a job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; consists of two operations &lt;span class=&quot;math-container&quot;&gt;$O_{j1}, O_{j2}$&lt;/span&gt;, two possible cases are creating confusion : &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If one operation can be done by the same machine, using the definition of Brucker is not sufficient. Indeed, in addition to the job and operation indices, we need a third one indicating the machine (the processing time can differ from one machine to another) &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the two operations can be done by the same machine, the processing time definition by Pinedo is not sufficient we need an additional index for the operation.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I think that Bruker is somehow assuming that all machines are identical and Pinedo is somehow assuming that a machine can only do one operation and each operation can be done by only one machine. In other terms, there is a one-to-one function that maps operations to machines. Or, eventually, we define an equivalence relation &lt;span class=&quot;math-container&quot;&gt;$\mathcal{R}$&lt;/span&gt; as follows &lt;span class=&quot;math-container&quot;&gt;$x \mathcal{R} y \Leftrightarrow$&lt;/span&gt; machines &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; have the same speed. In this case, Pinedo is somehow assuming that there is a one-to-one mapping between operations and the quotient set. Thus, there is no need to talk about the operations index. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help to clarify the situation? Or even any suggestion for a reference that may be less ambiguous? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.B. This may be a dumb question, but I have a pure mathematics background, where everything is defined the same way nearly everywhere. Coming across multiple definitions without precising the underlying assumptions is a huge frustration for me.&lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2019-09-24T20:43:53.960" LastActivityDate="2019-09-25T08:02:22.837" Title="Trouble with scheduling problem assumptions" Tags="|reference-request|scheduling|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2650" PostTypeId="2" ParentId="2648" CreationDate="2019-09-24T20:42:41.153" Score="2" Body="&lt;p&gt;Fattahi et al., in their paper&lt;sup&gt;1&lt;/sup&gt;, defined the decision variable that you mentioned in your question as follow:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{ijh} =  &#xA;\begin{cases}&#xA;1 &amp;amp; \text{ if} \ \ O_{jh} \ \text{can be performed on machine }i \\&#xA;0 &amp;amp; \text{ if otherwise} \\ &#xA;\end{cases}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even more, they make their model more general by defining various priority for the job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; for which the operation &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; is decided to be done on machine &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; on priority &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] Fattahi, Parviz, Mohammad Saidi Mehrabad, and Fariborz Jolai. &quot;Mathematical modeling and heuristic approaches to flexible job shop scheduling problems.&quot; Journal of intelligent manufacturing 18.3 (2007): 331-342.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-09-25T07:29:01.237" LastActivityDate="2019-09-25T07:29:01.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2651" PostTypeId="2" ParentId="2620" CreationDate="2019-09-24T22:26:32.957" Score="5" Body="&lt;p&gt;I'm not 100% certain, but I think your problem is rather similar to a cutting stock problem. The routes represent &quot;patterns&quot;, and the assignment of vehicles to routes is  equivalent to choosing how many times each pattern is cut. That last equivalence depends on vehicles being identical (any vehicle can handle any route, and the cost of the route is independent of which vehicle is used). The depot time windows might correspond to units of base stock (what's being cut), or you might have to make a pattern a combination of route + time window, depending on some details I didn't see in the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, I'm not entirely certain, but it does look a bit like a cutting problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-24T22:26:32.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2652" PostTypeId="2" ParentId="2648" CreationDate="2019-09-25T02:31:16.290" Score="4" Body="&lt;p&gt;In Pinedo's book, on page 13 (directly above your quotation) it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Over the last fifty years a considerable amount of research effort has been focused on deterministic scheduling. The number and variety of models considered is astounding. During this time &lt;strong&gt;a notation has evolved that succinctly captures the structure of many (but for sure not all) deterministic models&lt;/strong&gt; that have been considered in the literature.&lt;br&gt;&#xA;  &amp;nbsp; &lt;strong&gt;The first section in this chapter presents an adapted version of this notation&lt;/strong&gt;. The second section contains a number of examples and &lt;strong&gt;describes some of the shortcomings of the framework and notation&lt;/strong&gt;.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In Brucker's book, on page 3 (the next page, after your quote), it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;In general, all data &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; are assumed to be integer. A schedule is feasible if no two time intervals overlap on the same machine, if no two time intervals allocated to the same job overlap, and if, in addition, it meets a number of problem-specific characteristics. A schedule is optimal if it minimizes a given optimality criterion.&lt;br&gt;&#xA;  &amp;nbsp; &lt;strong&gt;Sometimes it is convenient to identify a job &lt;span class=&quot;math-container&quot;&gt;$J_i$&lt;/span&gt; by its index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. We will use this brief notation&lt;/strong&gt; in later chapters.&lt;br&gt;&#xA;  &amp;nbsp; We will discuss a &lt;strong&gt;large variety of classes&lt;/strong&gt; of scheduling problems which differ in their complexity. Also &lt;strong&gt;the algorithms we will develop are quite different for different classes of scheduling problems&lt;/strong&gt;. Classes of scheduling problems are specified in terms of a three-field classification &lt;span class=&quot;math-container&quot;&gt;$\alpha | \beta | \gamma$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; specifies the machine environment, &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; specifies the job characteristics, and &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; denotes the optimality criterion. Such a classification scheme was &lt;strong&gt;introduced by Graham et al&lt;/strong&gt;. [108].&lt;br&gt;&#xA;  &lt;code&gt;[108]&lt;/code&gt; R.L. Graham, E.L. Lawler, J.K. Lenstra, and A.H.G. Rinnooy Kan. Optimization and approximation in deterministic sequencing and&#xA;  scheduling: A survey. Annals of Discrete Mathematics, 5:287–326,&#xA;  1979.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I think that Bruker is somehow assuming that all machines are identical and Pinedo is somehow assuming that a machine can only do one operation and each operation can be done by only one machine.&#xA;  ...&#xA;  Any help to clarify the situation? Or even any suggestion for a reference that may be less ambiguous?&lt;/p&gt;&#xA;  &#xA;  &#xA;  &#xA;  &lt;p&gt;N.B. This may be a dumb question, but I have a pure mathematics background, where everything is defined the same way nearly everywhere. Coming across multiple definitions without precising the underlying assumptions is a huge frustration for me.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Each author presents a method and algorithm for various aspects of similar and differing problems, and each adapts a notation used previously or creates their own (usually with justification as to why it's necessary).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Coincidentally Brucker explains that people share your concern in: &quot;&lt;a href=&quot;https://doi.org/10.1016/S0377-2217(98)00204-5&quot; rel=&quot;nofollow noreferrer&quot;&gt;Resource-constrained project scheduling: Notation, classification, models, and methods&lt;/a&gt;&quot;, European Journal of Operational Research Volume 112, Issue 1, 1 January 1999, Pages 3-41:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;So far, no classification scheme exists which is compatible with what is commonly accepted in machine scheduling. Also, a variety of symbols are used by project scheduling researchers in order to denote one and the same subject. Hence, there is a gap between machine scheduling on the one hand and project scheduling on the other with respect to both, viz. a common notation and a classification scheme. As a matter of fact, in project scheduling, an ever growing number of papers is going to be published and it becomes more and more difficult for the scientific community to keep track of what is really new and relevant. One purpose of our paper is to close this gap. That is, we provide a classification scheme, i.e. a description of the resource environment, the activity characteristics, and the objective function, respectively, which is compatible with machine scheduling and which allows to classify the most important models dealt with so far. Also, we propose a unifying notation.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Definition of &quot;&lt;strong&gt;&lt;a href=&quot;https://en.wiktionary.org/wiki/exact_science&quot; rel=&quot;nofollow noreferrer&quot;&gt;exact science&lt;/a&gt;&lt;/strong&gt;&quot;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Noun: exact science (plural: exact sciences)&lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;&lt;p&gt;(sciences, narrowly) A mathematical science, i.e. a field of science such as mathematics or mathematical physics which is capable of perfectly exact results based on rigorously formal methods.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;(sciences, broadly) A field of science such as physics or chemistry that is not perfectly exact, but still capable of highly quantitative results based on methods that are are not strictly rigorous, but still systematic and scrupulous.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;  &#xA;  &lt;p&gt;Usage notes: Often used in the form of litotes when something is far from being an exact science.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Some things are simple or can only &lt;em&gt;work&lt;/em&gt; one way, thus rigorous standardization is not only desirable but possible. Other things are &lt;em&gt;discovered&lt;/em&gt; in isolation and are complex, resulting in each person or group having their own language and methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arguably one of the first things mankind discovered was soil, rock, or the Sun. Each language doesn't use the same word to represent the same concept despite their universality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.improbable.com/ig-about/winners/#ig2015&quot; rel=&quot;nofollow noreferrer&quot;&gt;2015 Ig Nobel Prize Winners&lt;/a&gt; for Literature was awarded to  Mark Dingemanse [The Netherlands, USA], Francisco Torreira [Spain, The Netherlands, Belgium, USA, Canada], and Nick J. Enfield [Australia, The Netherlands], for discovering that the word “&lt;strong&gt;huh?&lt;/strong&gt;” (or its equivalent) seems to exist in every human language — and for not being completely sure why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference: “&lt;a href=&quot;http://huh.ideophone.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Is ‘Huh?’ a universal word? Conversational infrastructure and the convergent evolution of linguistic items&lt;/a&gt;”, Mark Dingemanse, Francisco Torreira, and Nick J. Enfield, PLOS ONE, 2013. [a &lt;a href=&quot;https://www.youtube.com/watch?t=19&amp;amp;v=nm_klOMto4o&quot; rel=&quot;nofollow noreferrer&quot;&gt;video&lt;/a&gt; accompanies the paper.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Who attended the ceremony: The authors were unable to attend the ceremony; they sent a video acceptance speech. They received their prize at a special event (The European Ig Nobel Show) in Amsterdam, The Netherlands on October 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Max Planck Institute for Psycholinguistics, &quot;&lt;a href=&quot;https://www.mpg.de/9646844/ig-nobel-prize-2015&quot; rel=&quot;nofollow noreferrer&quot;&gt;Is &quot;huh&quot; a universal word?&lt;/a&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personal opinion: In English &quot;huh&quot; has two meanings - &quot;what&quot; and &quot;understood&quot;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-09-25T02:36:31.620" LastActivityDate="2019-09-25T02:36:31.620" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2653" PostTypeId="1" CreationDate="2019-09-25T04:47:03.620" Score="19" ViewCount="859" Body="&lt;p&gt;How do you decide or plan an &lt;a href=&quot;https://en.wikipedia.org/wiki/Service-level_agreement&quot; rel=&quot;noreferrer&quot;&gt;SLA (Service Level Agreement)&lt;/a&gt; for an application that depends on an optimization process when the problems you deal with are NP-hard? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, if you are developing an optimization application that is integrated with other applications (execution, reporting, etc...) and you want to be able to guarantee that the scheduled optimization calculations are complete within a certain time frame, how can you guarantee a time frame if your problem is NP-Complete or NP-Hard, and therefore you cannot know beforehand how long it will take the solver to reach an optimal solution? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You have an inventory optimization problem that is NP-hard, for a company that deals in 50000 products. &lt;/li&gt;&#xA;&lt;li&gt;You have designed an application to find the optimal inventory purchases and allocations using a suitable solver + modeling language + user interface. &lt;/li&gt;&#xA;&lt;li&gt;This optimization application feeds the optimal inventory decisions to an ordering system which then sends out the orders to suppliers and vendors. &lt;/li&gt;&#xA;&lt;li&gt;This optimization process runs on a weekly or daily schedule and needs to be completed within a certain time frame every time it runs, because it needs to synch up with the rest of the company's financial and ordering systems, and the orders need to go out on a regular cadence. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How can we time box the solver's running time, since there is a possibility that every now and then the instance that it is provided is a hard one and it takes an inordinate amount of time to find the optimal solution? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do we just put a stopping criteria that says stop after x hours, and deliver whatever best solution you have at that point? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do we &quot;plan ahead&quot; and make sure that ample running time is planned for and throw ridiculously large amounts of compute resources to make sure that it always completes?  &lt;/p&gt;&#xA;" OwnerUserId="1315" LastEditorUserId="1315" LastEditDate="2019-09-25T08:18:31.857" LastActivityDate="2019-09-25T12:36:52.230" Title="How do we decide/plan an SLA for an NP-hard optimization process running in production?" Tags="|optimization|mixed-integer-programming|solver|computational-complexity|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2654" PostTypeId="2" ParentId="2648" CreationDate="2019-09-25T08:02:22.837" Score="2" Body="&lt;p&gt;From a practical point of view, Scheduling models have own definitions according to the structure of the problem under study. Both definitions above are true and have been mentioned based on two different approaches. If you are interested to survey such explanations you could find lots of models and definitions in the literature. As Rob and Oguz mentioned too.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-09-25T08:02:22.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2655" PostTypeId="2" ParentId="2653" CreationDate="2019-09-25T08:15:02.340" Score="7" Body="&lt;p&gt;I think there is three angles to attack this problem. A complete solution will probably feature each one of them&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Large set of (hard) test cases:&lt;/strong&gt; If you are worried about the hard instances, then I would create a large set of test cases which you can update anytime you find a new one that was difficult. These can be integrated into the build pipeline of your software, so every time you publish a new version of your application, you can see whether the tests still run (of course, these tests should run on the hardware to be used).&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Algorithmic development and testing:&lt;/strong&gt; Once you have at least some test cases available, you should check whether your time requirements are met. The most important thing here is that you have a quantifiable target. The sentence &quot;I want it faster&quot; is not good enough. If your time box is 4 hours, you may want to say that &quot;I want my hard cases to reach a 1% optimality gap within 2 hours&quot;. This is quantifiable and can be used to drive the algorithmic development. A description of this process I very much liked can be found &lt;a href=&quot;https://www.crcpress.com/Accelerating-MATLAB-Performance-1001-tips-to-speed-up-MATLAB-programs/Altman/p/book/9781482211290#isbn&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; (even though it is for MATLAB).&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Hardware testing:&lt;/strong&gt; Once you have at least some test cases available, and you settled (more or less) on your algorithm you can start checking different hardware. Of course this is easiest if you have e.g. a &lt;a href=&quot;https://www.gurobi.com/products/gurobi-compute-server/&quot; rel=&quot;noreferrer&quot;&gt;Gurobi Compute Server&lt;/a&gt;, where you can scale up and down and see what your problem instance does. If you work for a big company they may also have in-house clusters etc. However, a word of caution: the speed-up you get from e.g. multi-threading tapers off after ca. 20-30 cores (depends on solver and application), and may even increase run time again. So if you throw a 80 core beast at your problem, you may be slower than a 16 core machine. In fact, one of the easiest investments to make is to increase the RAM on your machine, so that the solver can hold more information in memory.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As for your original question of the SLA: first you should go through these steps and see what you need, and then go from there. In general I would probably always go for something that gives me a lot of flexibility and does not limit the amount of computing power I can use (certain vendors do that).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And lastly, NP-hardness itself is not an argument for &quot;difficulty&quot; in the practical sense. Some cases are hard, some are easy while all may be NP-hard. &lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-09-25T08:15:02.340" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2656" PostTypeId="2" ParentId="2653" CreationDate="2019-09-25T12:36:52.230" Score="9" Body="&lt;p&gt;Another approach is to include &lt;em&gt;both&lt;/em&gt; an exact algorithm (e.g., MIP solver) &lt;em&gt;and&lt;/em&gt; a very fast heuristic. If the exact algorithm times out, you can compare its best solution with the solution from the heuristic and return the best one. The advantage of this approach is that the heuristic can be tailored to your specific problem, and therefore might have a better chance of finding a good solution than the MIP solver, which may be finding feasible solutions &quot;by accident.&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, the downside is that now you have &lt;em&gt;two&lt;/em&gt; algorithms that need to be completed within the time limit, instead of one. So this approach only works if you have a reliably fast heuristic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover, this still doesn't give you guaranteed performance measures to include in an SLA; it just gives you a better chance of meeting whatever guarantees &lt;em&gt;are&lt;/em&gt; included in the SLA.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-09-25T12:36:52.230" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2657" PostTypeId="1" CreationDate="2019-09-25T17:10:23.100" Score="14" ViewCount="261" Body="&lt;p&gt;In lasso, we have a regularization term in the loss function:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum \|y-\hat{y}\|_{2} + \lambda \sum\|\beta\|_{1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the loss function is minimized, some &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;'s will become zero. That's what people refer to as 'sparsity'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is : how to add a hard constraint for 'max number of non-zero beta' , say, 10? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose this is a mixed-integer programming problem: we introduce a temporary variable &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, which only takes value of &lt;span class=&quot;math-container&quot;&gt;$\{0, 1\}$&lt;/span&gt;, so we have an extra constraint &lt;span class=&quot;math-container&quot;&gt;$\sum s = 10$&lt;/span&gt; . Afterward, we will have &lt;span class=&quot;math-container&quot;&gt;$\beta = \beta_{\rm raw} \cdot s$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I got stuck, how to constraint &lt;span class=&quot;math-container&quot;&gt;$\beta_{\rm raw}$&lt;/span&gt; ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any insight?&lt;/p&gt;&#xA;" OwnerUserId="2402" LastEditorUserId="123" LastEditDate="2019-09-26T06:43:01.270" LastActivityDate="2019-09-26T06:43:01.270" Title="In the context of LASSO regression, how to introduce a constraint for max number of selected betas?" Tags="|optimization|mixed-integer-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2658" PostTypeId="1" AcceptedAnswerId="2691" CreationDate="2019-09-25T18:55:24.440" Score="6" ViewCount="116" Body="&lt;p&gt;Without trying to manually sketch out a graph on paper, is there a simple way I could get the arcs between nodes in this problem? I am using R and it seems there must be an elegant way of doing so but I'm at a loss.  I'm going to need to be passing this into &lt;code&gt;getShortestPathTree()&lt;/code&gt; from &lt;code&gt;optrees&lt;/code&gt;, which takes a matrix with the list of arcs of the graph. Each row represents one arc. The first two columns contain the two endpoints of each arc and the third column contains their weights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By going through with a pen and paper and sketching the graph I was able to create this matrix but I'm just looking for a simpler solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;head =   c(1,1,1,     2,  3, 4,4,4,    6,  7,  9)&#xA;tail =   c(2,6,9,     3,  7, 5,8,10,   7,  4,  10)&#xA;weight = c(90,90,90,  15, 5, 20,20,20, 21, 25, 30)&#xA;&#xA;arcs = cbind(head, tail, weight)&#xA;head(arcs)&#xA;     head tail weight&#xA;[1,]    1    2     90&#xA;[2,]    1    6     90&#xA;[3,]    1    9     90&#xA;[4,]    2    3     15&#xA;[5,]    3    7      5&#xA;[6,]    4    5     20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2aWtp.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2aWtp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2393" LastEditorUserId="2393" LastEditDate="2019-09-25T19:38:38.880" LastActivityDate="2019-09-29T12:12:40.183" Title="DAG shortest path in R - I have a list of nodes, each node's completion time and each node's predecessor(s). How can I turn this to a list of arcs?" Tags="|optimization|r|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2659" PostTypeId="1" AcceptedAnswerId="2660" CreationDate="2019-09-25T18:59:34.383" Score="10" ViewCount="1490" Body="&lt;p&gt;Is there a way to set a decision variable to take values from a set?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;decision variable &lt;span class=&quot;math-container&quot;&gt;$x \in \{0,50,100\}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this variable can only take one of these three values and not more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found a documentation online which unfortunately does not state such a thing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/variables.html&quot; rel=&quot;noreferrer&quot;&gt;Gurobi Documentation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this example, I could probably set two different decision variables, with lower bound 0 and 50 or 100, respectively. I am not satisfied with this method, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how it would probably look like in Java:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//GRBVar addVar(double lb, double ub, double obj, char type, String name)&#xA;GRBVar x = model.addVar(50.0,50.0,null,GRB.SEMIINT,&quot;x&quot;);&#xA;GRBVar y = model.addVar(100.0,100.0,null,GRB.SEMIINT,&quot;y&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A semi-continous variable has the property that it takes a value of 0, or a value between the specified lower and upper bounds. A semi-integer variable adds the additional restriction that the variable also take an integral value (GRB.SEMIINT).&lt;/p&gt;&#xA;" OwnerUserId="456" LastEditorUserId="38" LastEditDate="2019-09-26T00:08:10.910" LastActivityDate="2019-09-26T00:08:10.910" Title="Decision Variable Value from a Set (Gurobi)" Tags="|integer-programming|gurobi|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2660" PostTypeId="2" ParentId="2659" CreationDate="2019-09-25T19:17:32.330" Score="11" Body="&lt;p&gt;I don't think directly, but one way to model that would be to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;define a parameter as the vector of the possible values: &lt;span class=&quot;math-container&quot;&gt;$p = [0,50,100]$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;define three binary decision variables that each correspond to whether a value in the set is selected (&lt;span class=&quot;math-container&quot;&gt;$y_i \in \{0,1\}, i = 1,2,3$&lt;/span&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;enforce constraints: &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in \{1,2,3\} } y_i = 1$&lt;/span&gt; (select exactly 1 of the values to use)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x=\sum_{i\in \{1,2,3\} } p_iy_i $&lt;/span&gt; (apply the chosen value to the variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;)&lt;/p&gt;&#xA;" OwnerUserId="56" LastActivityDate="2019-09-25T19:17:32.330" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2661" PostTypeId="2" ParentId="2659" CreationDate="2019-09-25T19:20:44.940" Score="4" Body="&lt;p&gt;In the case of the example that you provided,(and generally, if you have a pattern in the set of available values for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;), I am &lt;em&gt;assuming&lt;/em&gt; that you have the mentioned pattern in the values of the set, you can define your variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; as the integer and then multiply the value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; by a constant. To explain what I mean:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x \in \{0, 50, 100\}$&lt;/span&gt; can be equivalently replaced by &lt;span class=&quot;math-container&quot;&gt;$x' \in \{0, 1, 2\}$&lt;/span&gt; and then &lt;span class=&quot;math-container&quot;&gt;$x = 50 \times x'$&lt;/span&gt; in all constraints and objective function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if the general form of decision variable's set is not like the example that you mentioned, this approach won't work. Comment on this solution if my assumption is not correct. &lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-09-25T19:20:44.940" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2662" PostTypeId="1" AcceptedAnswerId="2665" CreationDate="2019-09-25T19:21:18.280" Score="12" ViewCount="2841" Body="&lt;p&gt;Simple question, but &lt;strong&gt;very&lt;/strong&gt; hard to find an answer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I cite version 12.9 of CPLEX? Shall I cite the very first CPLEX and indicate that I am using the version 12.9 of this, or shall I cite the new release's handbook? If you suggest the latter one, how can I do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cite V12.1 as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;CPLEX, IBM ILOG. &quot;V12. 1: User’s Manual for CPLEX.&quot; International Business Machines Corporation 46.53 (2009): 157.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And say that I use version 12.9 of this. It is a bit odd since 12.9 is released in 2019, but I cite 10 years ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ps: Is it only me who thinks IBM documentation, especially in CPLEX, is a bit sloppy? In general, it is very hard to jump through topics in the CPLEX website...&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2019-09-25T19:27:31.327" LastActivityDate="2019-09-26T15:36:36.497" Title="Citing CPLEX 12.9" Tags="|solver|reference-request|cplex|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2663" PostTypeId="2" ParentId="2657" CreationDate="2019-09-25T20:33:24.337" Score="11" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt; be the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;-th regression coefficient and &lt;span class=&quot;math-container&quot;&gt;$s_j$&lt;/span&gt; the binary variable indicating whether you are including that term in the regression. To simplify the objective function, add a nonnegative variable &lt;span class=&quot;math-container&quot;&gt;$u_j$&lt;/span&gt; representing the absolute value of &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt;. The lasso term in the objective becomes &lt;span class=&quot;math-container&quot;&gt;$\sum_j u_j$&lt;/span&gt;. Now add the constraints &lt;span class=&quot;math-container&quot;&gt;$\beta_j \le u_j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$-\beta_j \le u_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u_j \le M_j s_j$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$M_j$&lt;/span&gt; is an &lt;em&gt;a priori&lt;/em&gt; upper bound on &lt;span class=&quot;math-container&quot;&gt;$|\beta_j|$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tricky part is picking reasonable values for &lt;span class=&quot;math-container&quot;&gt;$M_j$&lt;/span&gt;. Too small and you risk producing a suboptimal fit; too large and the solver may do funny things. If the problem solves quickly, you might do it by trial and error: pick values; solve; increase the values; solve again; iterate until the regression coefficients do not change from one run to the next. If the solution time is not short, maybe start with a regression with no limit on the number of terms (and no &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; variables), then guess &lt;span class=&quot;math-container&quot;&gt;$M_j$&lt;/span&gt; values from the fitted &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-25T20:33:24.337" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2664" PostTypeId="2" ParentId="2662" CreationDate="2019-09-25T21:36:11.730" Score="9" Body="&lt;p&gt;Here's an answer (from 2018) by one of IBM's CPLEX specialists: &lt;a href=&quot;https://developer.ibm.com/answers/questions/439521/citing-cplex.html&quot; rel=&quot;noreferrer&quot;&gt;&quot;Citing CPLEX&quot;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-25T21:36:11.730" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2665" PostTypeId="2" ParentId="2662" CreationDate="2019-09-25T22:18:20.360" Score="6" Body="&lt;p&gt;The below-mentioned format has been used for citation of &lt;em&gt;CPLEX&lt;/em&gt; in over 100 papers. I just cite two of those which have been published in 2019 but used different versions of the &lt;em&gt;CPLEX&lt;/em&gt;. These papers are from well-known journals so I believe that even citation format should be considered in the publication process.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;IBM (2017) IBM ILOG CPLEX 12.7 User’s Manual (IBM ILOG CPLEX Division, Incline Village, NV).&lt;sup&gt;1&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;IBM, 2013 IBM ILOG CPLEX 12.6 User Manual IBM Corp. (2013)&lt;sup&gt;2&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I think just putting the sub-version of &lt;em&gt;CPLEX&lt;/em&gt; 12.* &lt;em&gt;User's Manual&lt;/em&gt; in the citation will be alright.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] Petit, Thierry, and Andrew C. Trapp. &quot;Enriching solutions to combinatorial problems via solution engineering.&quot; INFORMS Journal on Computing (2019).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] Ceselli, Alberto, et al. &quot;Optimized assignment patterns in Mobile Edge Cloud networks.&quot; Computers &amp;amp; Operations Research 106 (2019): 246-259.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-09-25T22:18:20.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2666" PostTypeId="2" ParentId="2662" CreationDate="2019-09-25T22:19:27.553" Score="11" Body="&lt;p&gt;Depending on the journal, CPLEX may be so well known that it is acceptable to omit the reference. It is always important to include a version number (&quot;we use CPLEX 12.9&quot;), as performance can differ significantly between versions.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-09-25T22:19:27.553" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2667" PostTypeId="1" AcceptedAnswerId="2673" CreationDate="2019-09-25T23:14:58.060" Score="10" ViewCount="344" Body="&lt;p&gt;I am writing a small wrapper around Gurobi and Cplex so that the models I write are solver independent. I'm very familiar with Gurobi but I'm very new to Cplex and I'm having trouble replicating certain api calls that I use very frequently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically I'm having trouble figuring out how to pass the sense to the Cplex API:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;std::shared_ptr&amp;lt;Constraint&amp;gt; Model::addConstr(const std::vector&amp;lt;std::shared_ptr&amp;lt;Variable&amp;gt;&amp;gt;&amp;amp; vars,&#xA;      const std::vector&amp;lt;double&amp;gt;&amp;amp; coeffs, char sense,&#xA;      double rhs, const std::string&amp;amp; name) &#xA;#ifdef GUROBI   &#xA;    GRBLinExpr expr;&#xA;    std::vector&amp;lt;GRBVar&amp;gt; grb_vars;&#xA;    for(auto var : vars) {&#xA;      grb_vars.push_back(*(var-&amp;gt;getGRBVar()));&#xA;    }&#xA;    expr.addTerms(&amp;amp;coeffs[0], &amp;amp;grb_vars[0], (int) vars.size());&#xA;    GRBConstr constraint = _grb_model-&amp;gt;addConstr(expr, sense, rhs, name);&#xA;    std::shared_ptr&amp;lt;GRBConstr&amp;gt; grb_constr_shared = std::make_shared&amp;lt;GRBConstr&amp;gt;(constraint);&#xA;    return std::make_shared&amp;lt;Constraint&amp;gt;(grb_constr_shared);&#xA;#elif defined CPLEX&#xA;  // do exactly the same process for cplex&#xA;  IloExpr expr(_cplex_env);&#xA;  for(int i = 0; i &amp;lt; vars.size(); ++i) {&#xA;    expr += coeffs[i] * vars[i];  &#xA;  }&#xA;  // this line below doesn't work -- I don't know how to pass the sense of&#xA;  // the constraint. I'd like to avoid using a switch statement if possible..&#xA;  IloConstraint constraint = _cplex_model.add(expr, sense, rhs);&#xA;#endif&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I'm having trouble figuring out how to pass the coefficient for a variable in the objective. I'd like to be able to do this on creation of the variable (or at least immediately after creating the variable) so that I can have similar functionality to gurobi.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;std::shared_ptr&amp;lt;Variable&amp;gt; Model::addVar(double lb, double ub, double obj,&#xA;      char var_type, std::string name) {&#xA;#ifdef GUROBI&#xA;    GRBVar grb_var = _grb_model-&amp;gt;addVar(lb, ub, obj, var_type, std::move(name));&#xA;    std::shared_ptr&amp;lt;GRBVar&amp;gt; grb_var_shared = std::make_shared&amp;lt;GRBVar&amp;gt;(grb_var);&#xA;    return std::make_shared&amp;lt;Variable&amp;gt;(grb_var_shared);&#xA;#elif defined CPLEX&#xA;  // do the same process for CPLEX and return std::make_shared&amp;lt;Variable&amp;gt;(cplex_var_shared);&#xA;    // this line defines the variable but doesn't set its coeff in the&#xA;    // objective function -- how do I set the variable's objective coefficient?&#xA;    IloNumVar var(*_cplex_env, lb, ub, IloNumVar::Int, name.c_str());&#xA;&#xA;#endif&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: stackoverflow link: &lt;a href=&quot;https://stackoverflow.com/questions/58107655/specify-the-sense-of-a-constraint-in-cplex&quot;&gt;https://stackoverflow.com/questions/58107655/specify-the-sense-of-a-constraint-in-cplex&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll update both posts if I receive an answer in either community.&lt;/p&gt;&#xA;" OwnerUserId="173" LastEditorUserId="173" LastEditDate="2019-09-26T16:49:34.093" LastActivityDate="2019-09-26T20:01:50.687" Title="Specify the sense of a constraint in CPLEX" Tags="|cplex|gurobi|c++|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2668" PostTypeId="1" CreationDate="2019-09-26T09:20:38.513" Score="11" ViewCount="163" Body="&lt;p&gt;I have the following maximization program&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \max\limits_{\{q_i\}}&amp;amp;\quad\sum\limits_{i=1}^nq_i \\&#xA;    \text{s.t.}&amp;amp;\quad\begin{cases} k_j \geq \sum\limits_{i=1}^n q_i^{1 \over \alpha_i}x_{ij} &amp;amp; j=\{1,\dots,J\} \\&#xA;     q_i \geq 0 &amp;amp; i=\{1,\dots,n\} \\&#xA;    \end{cases} \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$\alpha_i&amp;gt;0$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$k_j &amp;gt; 0$&lt;/span&gt; for all indices. Also, &lt;span class=&quot;math-container&quot;&gt;$x_{ij}\geq 0 \quad \forall i,j$&lt;/span&gt; and, in addition, it must be the case that, if we fix &lt;span class=&quot;math-container&quot;&gt;$i^*$&lt;/span&gt;, there exists at least one &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$x_{i^*j}&amp;gt;0$&lt;/span&gt; and similarly, given &lt;span class=&quot;math-container&quot;&gt;$j^*$&lt;/span&gt;, there exists at least one &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$x_{ij^*}&amp;gt;0$&lt;/span&gt;. Examination of several examples has led me to believe (and I'd like to prove) that solutions (denoted &lt;span class=&quot;math-container&quot;&gt;$q_i^*$&lt;/span&gt;) to this problem are of the form:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$\alpha_i&amp;lt;1 \quad \forall i,$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$q_i^*&amp;gt;0 \quad \forall i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$\alpha_i \geq 1 \quad \forall i,$&lt;/span&gt; the solution needs not be unique and within a given solution &lt;span class=&quot;math-container&quot;&gt;$q_i^*$&lt;/span&gt; can be indeed &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; for some indices. If, for any of the solutions, we denote &lt;span class=&quot;math-container&quot;&gt;$I_+$&lt;/span&gt; the set of indices for which &lt;span class=&quot;math-container&quot;&gt;$q_i^*&amp;gt;0$&lt;/span&gt;, my claim is that the cardinality of &lt;span class=&quot;math-container&quot;&gt;$I_+$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$1 \leq n^*\leq \min [J,n]$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The first part is easy, as &lt;span class=&quot;math-container&quot;&gt;$\alpha_i&amp;lt;1 \quad \forall i,$&lt;/span&gt; leads to a bounded convex feasible set, but I don't know how to approach the second. Any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; If &lt;span class=&quot;math-container&quot;&gt;$\alpha_i = 1 \quad \forall i,$&lt;/span&gt; the problem is linear and I believe that my claim is true, because (I think that I recall that) the solution needs to be at a &lt;em&gt;corner&lt;/em&gt; or a &lt;em&gt;side&lt;/em&gt; of the feasible region. Any hint towards the development of this idea will also be of great help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit #2:&lt;/strong&gt; I could do with a proof for the case &lt;span class=&quot;math-container&quot;&gt;$\alpha_i=\alpha \quad \forall i$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2391" LastEditorUserId="2391" LastEditDate="2019-09-27T09:34:32.773" LastActivityDate="2019-09-27T09:34:32.773" Title="Characterizing the solution of a (non) linear maximization program" Tags="|nonlinear-programming|nonconvex-programming|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2669" PostTypeId="1" AcceptedAnswerId="2675" CreationDate="2019-09-26T13:02:24.993" Score="16" ViewCount="2708" Body="&lt;p&gt;What are the advantages (if any) of using IPOPT with HSL vs MUMPS? HSL has a reputation of being faster, but does it walk the walk? In particular, does HSL scale better for large-scale problems? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have been using IPOPT with MUMPS in our engine and every time we solve anything remotely large (e.g. &gt;50000 variables) MUMPS lights up like a Christmas tree in the profiler. Therefore, I was wondering whether HSL (maybe MA57) would make a noticable difference over MUMPS. The &lt;a href=&quot;ftp://ftp.numerical.rl.ac.uk/pub/talks/jas.edinburgh.21I05.pdf&quot; rel=&quot;noreferrer&quot;&gt;most recent comparison&lt;/a&gt; I could find is not very relevant as it's ten years old and doesn't measure IPOPT's performance, which is what I'm interested in. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've never really been one to trust benchmarks, so I'm really interested in hands-on experience people might have using IPOPT with HSL. I should also note that our solver uses MPI, so we have to use MUMPS in serial mode.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-09-26T22:44:13.227" Title="IPOPT with HSL vs MUMPS" Tags="|nonlinear-programming|algorithms|nonconvex-programming|linear-algebra|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2670" PostTypeId="2" ParentId="2662" CreationDate="2019-09-26T15:36:36.497" Score="1" Body="&lt;p&gt;I agree with Kevin. Unless you want to refer the reader to some specific solver features, there is no need to cite the CPLEX documentation as it is famous enough. While I think this is acceptable for commercial software, you might double-check the website and documentation of open-source solvers as they usually ask/require you to do so.&lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2019-09-26T15:36:36.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2671" PostTypeId="2" ParentId="1235" CreationDate="2019-09-26T17:03:58.853" Score="4" Body="&lt;p&gt;I found it hard, using Pyomo, to get that kind of information since Pyomo's &lt;code&gt;results&lt;/code&gt; object has a different structure depending on the solver that has been used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get around that, I consider that the ugly solution is still the most reliable one up to now, until someone shows me a better way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Convert the &lt;code&gt;results&lt;/code&gt; object that was returned by the &lt;code&gt;solve()&lt;/code&gt; method into a &lt;code&gt;String&lt;/code&gt; using &lt;code&gt;str(results)&lt;/code&gt;. Find the text &lt;code&gt;'Time: '&lt;/code&gt; in this string. Add all characters after the &lt;code&gt;'Time: '&lt;/code&gt; substring that corresponds to a number and stop when you reach the &lt;code&gt;\n&lt;/code&gt; character. You now have the value you wanted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a function that I created and that I still use to get this kind of informations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def get_info_from_results(results, info_string):&#xA;    i = str(results).lower().find(info_string.lower()) + len(info_string)&#xA;    value = ''&#xA;    while str(results)[i] != '\n':&#xA;        value = value + str(results)[i]&#xA;        i += 1&#xA;    return value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using this function, you should get your solve time from your (let's call it) &lt;code&gt;neos_results&lt;/code&gt; object doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;solver_solve_time = get_info_from_results(neos_results, 'Time: ')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Keep in mind at this point that the value returned by this function is still considered by Python as a &lt;code&gt;String&lt;/code&gt;, so you might want to convert it to a number if you want to make calculations with it. &lt;/p&gt;&#xA;" OwnerUserId="582" LastEditorUserId="36" LastEditDate="2019-09-26T17:26:10.607" LastActivityDate="2019-09-26T17:26:10.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2672" PostTypeId="2" ParentId="1475" CreationDate="2019-09-26T17:03:59.740" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I would like to start the first lesson with &quot;Why learning programming languages will be useful to them&quot;. ... &lt;a href=&quot;https://or.stackexchange.com/questions/1475/are-programming-languages-necessary-useful-for-operations-research-practitioner#comment2376_1477&quot;&gt;Comment&lt;/a&gt;: &#xA;  Right now, I have only general guidelines for this course. ...&lt;br&gt;&#xA;  &amp;nbsp;  &lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Are programming languages is necessary for operations research practitioner?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would say yes, learning computer programming (beyond the basics) is necessary for Operations Research, Artificial Intelligence, and personal development. I used to be fluent in several languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which languages to learn leads to a whole series of other questions, here are a few:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/q/2236690/3648282&quot;&gt;F# vs Haskell vs Lisp - which language to learn? [closed]&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/q/1314732/3648282&quot;&gt;Scala vs. Groovy vs. Clojure [closed]&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/q/11641098/3648282&quot;&gt;Interpreting a benchmark in C, Clojure, Python, Ruby, Scala and others [closed]&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/q/13647482/3648282&quot;&gt;Which language should I learn? [closed]&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mostly such broad questions are closed as opinion based, though I do believe that there's some expertise available on these subjects. Basically, one would pick something that's not too complicated and fairly popular; at the expense of missing out on the features of more powerful languages. This is why a seperate course is necessary, and a decade of experience (if you want the computer to be a tool that you can master).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;2&quot;&gt;&#xA;  &lt;li&gt;If programming languages are not necessary, then are they at least useful for operations research practitioner?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would say learning programming is necessary, it's useful for other courses to &lt;strong&gt;briefly&lt;/strong&gt; introduce it but the couple of years necessary can't be devoted to learning the basics, and that's why a &lt;a href=&quot;https://www.eecs.mit.edu/csminor&quot; rel=&quot;nofollow noreferrer&quot;&gt;minor in Computer Science&lt;/a&gt; consists of 6 subjects and 72 units. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Much as Operations Research is divided into &lt;a href=&quot;https://orc.mit.edu/academics/course-offerings&quot; rel=&quot;nofollow noreferrer&quot;&gt;multiple categories of study&lt;/a&gt; one couldn't combine proper learning of computer programming within another course. &lt;a href=&quot;https://openlearning.mit.edu/courses-programs/mitx-courses-edx?f%5B0%5D=course_department%3A21&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIT&lt;/a&gt; has a free online course&#xA;called: &quot;&lt;a href=&quot;https://www.edx.org/course/6-00-1x-introduction-to-computer-science-and-programming-using-python-3?utm_source=mitopenlearning-mit-open-learning&amp;amp;utm_medium=affiliate_partner&quot; rel=&quot;nofollow noreferrer&quot;&gt;Introduction to Computer Science and Programming Using Python&lt;/a&gt;&quot; (taught by Charter Oak State College) which takes 9 Weeks at 14–16 hours per week (a month, straight), and you can pay extra to get a verified Certificate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your &quot;introduction&quot; to computer programming would be best spent outlining the expected level of understanding one needs to complete your course and what people's options are at your school and elsewhere. Teaching Python in a month takes a month and likely isn't going to be helpful to everyone. Some people might learn that quickly, particularly with a lot of homework, but some certainly won't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the prerequisites:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;High school algebra and a reasonable aptitude for mathematics. Students without prior programming background will find there is a steep learning curve and may have to put in more than the estimated time effort.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is a webpage called &quot;&lt;a href=&quot;https://wiki.python.org/moin/PythonForOperationsResearch&quot; rel=&quot;nofollow noreferrer&quot;&gt;PythonForOperationsResearch&lt;/a&gt;&quot; that lists some of the Python packages that someone interested in using that language in an Operations Research capacity might want to familiarize themselves with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A search on GitHub returns 112 results for Python and the &lt;a href=&quot;https://github.com/topics/operations-research?l=python&quot; rel=&quot;nofollow noreferrer&quot;&gt;Operations Research tag&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also our question: &lt;a href=&quot;https://or.stackexchange.com/q/841/51&quot;&gt;List of Implementations for common OR problems&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The webpage: &quot;&lt;a href=&quot;https://medium.com/opex-analytics/optimization-modeling-in-python-pulp-gurobi-and-cplex-83a62129807a&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimization Modeling in Python: PuLP, Gurobi, and CPLEX&lt;/a&gt;&quot; has this to say:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;I have been involved in the design, development, and implementation of operations research (OR) and optimization models such as Linear Programs (LP), Mixed Integer Linear Programs (MILP), and Quadratic Programs (QP) for more than a decade.&lt;br&gt;&#xA;  ...&lt;br&gt;&#xA;  These days, however, many in industry want to plan and make optimal decisions regularly as a part of their hourly, daily, or weekly operations. Recent computational advances have provided the infrastructure for us to incorporate optimization models in analytic software solutions. This means that today’s OR practitioners need to design, model, and implement robust software engines that are based on LP/MILP models. They need to utilize a programming language such as C++, Java, C#, Python, etc. for that purpose.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A good and popular programming language recommended by many in the OR and Data Science communities is Python. It is easy, flexible, and powerful, and has great libraries for Machine Learning, Optimization, and Statistical Modeling.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Perhaps the above provides some useful information about what you would discuss in your first lesson &quot;Why learning programming languages will be useful to them&quot;. At the school I went to it was universally understood, by students and faculty (but not management), that pulling students out of their course and sending them for a three day crash course elsewhere on campus was not productive; but still a necessary part of the main course, to say such skills were included.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-09-26T17:03:59.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2673" PostTypeId="2" ParentId="2667" CreationDate="2019-09-26T20:01:50.687" Score="7" Body="&lt;p&gt;For specifying constraint direction, look to the various IloRange constructors. You can specify both a lower and upper bound (for constraints of the form &lt;span class=&quot;math-container&quot;&gt;$b_0 \le a'x \le b_1$&lt;/span&gt;, or use a constructor that either defaults the lower bound to &lt;span class=&quot;math-container&quot;&gt;$-\infty$&lt;/span&gt; or defaults the upper bound to &lt;span class=&quot;math-container&quot;&gt;$+\infty$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For adding objective terms, you have at least a couple of options I can think of. You can create a linear expression for the objective first, then add terms to it as the variables are created, and then add the completed expression as an objective. Alternatively, you can store the coefficients in a one-dimensional double array (and, if not already doing so, the variables in another vector) as the variables are generated, then use that vector to create the objective. Check out IloScalProd for use in that approach.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-26T20:01:50.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2674" PostTypeId="1" CreationDate="2019-09-26T20:27:56.287" Score="7" ViewCount="95" Body="&lt;p&gt;We have tried to design a manufacturing cell which will produce specific families of products. We figure out three layout plans for implementation. For practical reasons, we need to calculate the robustness of plans. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK, one reasonable way to do that is to use the statistical method such as Monte Carlo simulation. To use this method we have to define three main steps. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The first step is to identify the transfer equation. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The second step is to define the input parameters. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The last step creating random data.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Finally, there will be an analysis of output for each input data. Our goal is to define the transfer equation based on minimizing delay, transfer time and workers for each product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My questions are:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Is our method suitable to calculate the robustness of plans?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Would you know other methods to do that which aren't complicated?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2019-12-01T14:32:31.963" LastActivityDate="2019-12-01T14:32:31.963" Title="Calculating robustness of layout plans" Tags="|optimization|robust-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2675" PostTypeId="2" ParentId="2669" CreationDate="2019-09-26T22:44:13.227" Score="12" Body="&lt;p&gt;This question happened to appear only a couple days after Byron Tasseff, Carleton Coffrin, Andreas Wächter, and Carl Laird (the last two are the original authors of IPOPT together with Larry Biegler) uploaded the following &lt;a href=&quot;https://arxiv.org/pdf/1909.08104.pdf&quot; rel=&quot;noreferrer&quot;&gt;paper&lt;/a&gt; in arXiV.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The paper compares the different Linear Solvers (and potential parallelization schemes) performance within IPOPT. They perform a really thorough computational comparison using both CUTEr instances and other more challenging cases. I will just include the last table in the manuscript here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FEok9.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FEok9.png&quot; alt=&quot;Taken from [1]&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you also wanted some hands-on experience I can share mine with IPOPT. Every time I need to use it and do have access to the HSL licenses (academic), it does not take long for me to switch to HSL licensed solvers (I have good experiences with MA57, MA 86 (non-deterministic) and MA 97). I have yet to try PARDISO and SPRAL (I will try it after reading the paper on arXiv I mentioned).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, some more benchmarks appear in the original &lt;a href=&quot;https://dl.acm.org/citation.cfm?id=992202&quot; rel=&quot;noreferrer&quot;&gt;paper&lt;/a&gt; of MA57, where they have a full comparison against MA27 within optimization solvers (tables 13 and 14). Although old (2002), the codes have not changed and I would expect the same trend today.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2019-09-26T22:44:13.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2676" PostTypeId="5" CreationDate="2019-09-27T01:14:30.047" Score="0" Body="&lt;p&gt;A cellular automaton (pl. cellular automata, abbrev. CA) is a discrete model studied in computer science, mathematics, physics, complexity science, theoretical biology and microstructure modeling. Cellular automata are also called cellular spaces, tessellation automata, homogeneous structures, cellular structures, tessellation structures, and iterative arrays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Cellular_automaton&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia - Cellular Automaton&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cellular automata come in a variety of shapes and varieties. One of the most fundamental properties of a cellular automaton is the type of grid on which it is computed. The simplest such &quot;grid&quot; is a one-dimensional line. In two dimensions, square, triangular, and hexagonal grids may be considered. Cellular automata may also be constructed on Cartesian grids in arbitrary numbers of dimensions, with the &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;-dimensional integer lattice &lt;span class=&quot;math-container&quot;&gt;$\mathbb{Z}^d$&lt;/span&gt; being the most common choice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The number of colors (or distinct states) &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; a cellular automaton may assume must also be specified. This number is typically an integer, with &lt;span class=&quot;math-container&quot;&gt;$k=2$&lt;/span&gt; (binary) being the simplest choice. For a binary automaton, color &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; is commonly called &quot;white,&quot; and color &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; is commonly called &quot;black&quot;. However, cellular automata having a continuous range of possible values may also be considered. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to the grid on which a cellular automaton lives and the colors its cells may assume, the neighborhood over which cells affect one another must also be specified. The simplest choice is &quot;nearest neighbors&quot;, in which only cells directly adjacent to a given cell may be affected at each time step. Two common neighborhoods in the case of a two-dimensional cellular automaton on a square grid are the so-called Moore neighborhood (a square neighborhood) and the von Neumann neighborhood (a diamond-shaped neighborhood).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://mathworld.wolfram.com/CellularAutomaton.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wolfram MathWorld - Cellular Automaton&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-09-27T04:10:45.627" LastActivityDate="2019-09-27T04:10:45.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2677" PostTypeId="4" CreationDate="2019-09-27T01:14:30.047" Score="0" Body="Cellular automaton consists of a regular grid of cells, each in one of a finite number of states, such as on and off (in contrast to a coupled map lattice)." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-09-27T04:10:56.160" LastActivityDate="2019-09-27T04:10:56.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2678" PostTypeId="1" CreationDate="2019-09-27T10:13:14.960" Score="6" ViewCount="132" Body="&lt;p&gt;I have &lt;span class=&quot;math-container&quot;&gt;$N_{\rm C}=8,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N_{\rm U}=25$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Scenario 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{l_{c,u}}{\sum\limits_{c=1}^{N_{\rm C}}l_{c,u}}\ge 0.1,\quad\forall u,u=1,2,\cdots,N_{\rm U}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{u=1}^{N_{\rm U}}l_{c,u}\le 1,\quad\forall c,c=1,2,\cdots,N_{\rm C}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, a maximum of &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; out of the &lt;span class=&quot;math-container&quot;&gt;$N_{\rm C}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$l_{c,u}$&lt;/span&gt;s can be non-zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Scenario 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{l_{c,u}}{\sum\limits_{c=1}^{N_{\rm C}}l_{c,u}}\ge 0.5,\quad\forall u,u=1,2,\cdots,N_{\rm U}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{u=1}^{N_{\rm U}}l_{c,u}\le 1,\quad\forall c,c=1,2,\cdots,N_{\rm C}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, a maximum of &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; out of the &lt;span class=&quot;math-container&quot;&gt;$N_{\rm C}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$l_{c,u}$&lt;/span&gt;s can be non-zero.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Which scenario will give the maximum number of users with at least &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; non-zero &lt;span class=&quot;math-container&quot;&gt;$l_{c,u}$&lt;/span&gt;s?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="39" LastEditDate="2019-09-27T21:42:11.313" LastActivityDate="2019-09-28T08:25:04.707" Title="How can I solve this problem?" Tags="|linear-programming|modeling|feasible-points|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2680" PostTypeId="2" ParentId="629" CreationDate="2019-09-27T13:50:18.970" Score="4" Body="&lt;p&gt;SecretAgentMan has given some specific examples of cases where over- and underdispersion will affect outcomes. I thought it might complement that answer to generalise those examples to some general principles about when over/under-dispersion is likely to happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Poisson process typically represents a count of many low-probability events, each of which is probabilistically independent of each other event that could contribute to the count. A classic example is radioactive gamma-decay: every nucleus has X% chance of decaying in a given time period, but whether it decays has no effect on whether other nuclei decay in the same time period. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Overdispersion is likely to arise when events contributing to the count have positive correlation, i.e. one event occurring makes it more likely that others will occur. Reasons for this could include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Counted events can cause other counted events. (Example: a business bankruptcy may lead to flow-on bankruptcies, as other businesses lose a client and invoices go unpaid.)&lt;/li&gt;&#xA;&lt;li&gt;A single event not directly included in the count can cause several counted events. (Example: one traffic collision may cause several injuries, and one system outage might cause many helpdesk calls, helping explain the overdispersion that SecretAgentMan notes in emergency rooms and call centres.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Underdispersion is likely to arise when events contributing to the count have negative correlation, e.g. because events suppress one another or are &quot;spaced&quot; by some mechanism. In the example of an appointment-based medical system, staff will attempt to spread appointments relatively evenly (subject to capacity by time); the more appointments that have already been booked in a given time slot, the less likely it is that other appointments will also be booked for that slot.&lt;/p&gt;&#xA;" OwnerUserId="546" LastActivityDate="2019-09-27T13:50:18.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2681" PostTypeId="2" ParentId="2678" CreationDate="2019-09-27T20:36:30.437" Score="3" Body="&lt;p&gt;I assume that the &lt;span class=&quot;math-container&quot;&gt;$N_C$&lt;/span&gt; is the number of customers (or something similar) and the &lt;span class=&quot;math-container&quot;&gt;$N_U$&lt;/span&gt; is the number of utilities (or again something similar) that can be used to satisfy the customers' demand. As I understood you want to maximize the number of customers for whom more than 2 utilities used in the model to satisfy the demand. You have these components in your model then (based on my assumptions):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$l_{c,u}$&lt;/span&gt;: Amount of customer &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;'s demand satisfied by utility &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;constraint 1:&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$$l_{c,u} \ge (0.1)\sum_{c=1}^{N_C} l_{c,u} \ \ \forall u \in \{1,2,...,N_U\} \ \ \text{and} \ \ \forall c \in \{1,2,..., N_C\}$$&lt;/span&gt; which means amount of satisfied demand for each customer and each utility combination can not exceed &lt;span class=&quot;math-container&quot;&gt;$10\%$&lt;/span&gt; of all shipments (or service).&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;constraint 2:&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$$\sum_{u=1}^{N_U}l_{c,u}\le 1,\ \ \forall c \in \{1,2,...,N_C\}$$&lt;/span&gt; that means for all customers the amount of service would be less than or equal to the demand.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;constraint 3:&lt;/strong&gt; The utilities can not serve more than 4 customers (utilities' capacity constraint). For this constraint, you need to define binary variables for each customer and each utility combination (&lt;span class=&quot;math-container&quot;&gt;$\forall c,u$&lt;/span&gt;)  as follow:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;decision variable: &lt;span class=&quot;math-container&quot;&gt;$$x_{c,u} =  &#xA;\begin{cases}&#xA;1 &amp;amp; \text{ if utility } u \text{ served customer }c \\&#xA;0 &amp;amp; \text{ otherwise} \\ &#xA;\end{cases}$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;then the constraint can be written as: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{c=1}^{N_C} x_{c,u} \le 4 \ \ \forall u \in \{1,2,...,N_U\}$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;and of course the indicator constraints like: &lt;span class=&quot;math-container&quot;&gt;$$l_{c,u} \le x_{c,u}\times M \ \  \forall c,u $$&lt;/span&gt; &lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now the objective function can be:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{maximize} \ \ z=\sum_{\forall c}\sum_{\forall u} (x_{c,u}-2)$$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With this linear programming, you can compare the two scenarios that you mentioned just by modifying the constraint 2's RHS. I didn't put the formulation in standard LP form just to explain every constraint separately. Even if my assumptions are not correct, I hope this model gives you at list an idea to pursue.  &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-09-28T08:25:04.707" LastActivityDate="2019-09-28T08:25:04.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2682" PostTypeId="1" AcceptedAnswerId="2684" CreationDate="2019-09-28T02:18:20.513" Score="11" ViewCount="386" Body="&lt;p&gt;Lemma 3 in &lt;a href=&quot;https://www.jstor.org/stable/3689422&quot; rel=&quot;noreferrer&quot;&gt;Haimovich and Rinnooy Kan (1985)&lt;/a&gt; (&lt;em&gt;Math of OR&lt;/em&gt; 10(4):527–542) says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; [the set of nodes] is contained in a rectangle with sides &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, then&#xA;  &lt;span class=&quot;math-container&quot;&gt;$$ T^*(X) \le \sqrt{2(n-1)ab} + 2(a+b).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$T^*(X)$&lt;/span&gt; is the length of the optimal TSP tour through &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$n=|X|$&lt;/span&gt;. The proof uses a clever construction that divides the rectangle into &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; horizontal strips, builds two snaking paths along the strips, inserts every node onto both paths, and converts the paths into cycles, which are then upper bounds on &lt;span class=&quot;math-container&quot;&gt;$T^*(X)$&lt;/span&gt;. The proof winds up at the following inequality:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$T^*(X) \le \frac32a + 2b + \frac12ah + \frac{(n-2)b}{h}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can follow the proof up to this point and I agree with it. Then they say:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The right-hand side of [the inequality above] is minimized by taking &lt;span class=&quot;math-container&quot;&gt;$h=\sqrt{2(n-2)b/a}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The proof ends there.&#xA;I've confirmed that this &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; minimizes the right-hand side of the inequality.&#xA;But if we plug the optimal &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; into the right-hand side of the inequality and we get:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align*}&#xA;		T^*(X) &amp;amp; \le \frac{3}{2}a + 2b + \frac{a\sqrt{\frac{2(n-2)b}{a}}}{2} + \frac{(n-2)b}{\sqrt{\frac{2(n-2)b}{a}}} \\&#xA;		&amp;amp; = \frac{3}{2}a + 2b + \sqrt{2(n-2)ab}.&#xA;	\end{align*}$$&lt;/span&gt;&#xA;I agree that this is &lt;span class=&quot;math-container&quot;&gt;$\le \sqrt{2(n-1)ab} + 2(a+b)$&lt;/span&gt;, as in the lemma—but why not state the lemma using this tighter bound? I feel like I'm missing something here.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-09-29T01:00:18.057" LastActivityDate="2019-10-04T00:41:11.330" Title="Proof of bound on optimal TSP tour length in rectangular region" Tags="|traveling-salesman|bounds|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2683" PostTypeId="2" ParentId="2682" CreationDate="2019-09-28T04:05:55.357" Score="7" Body="&lt;p&gt;I went over all the math included in the proof and confirmed that your claim which is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{3a}2+2b+\sqrt{2(n-2)ab}\le\sqrt{2(n-1)ab}+2(a+b)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is true. But I think they didn't use the tighter bound to make the lemma more general. In the bound that you proposed the following assumption for the number of nodes must be true:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$|X|\ge 2$$&lt;/span&gt;&#xA;But in the suggested bound in the lemma even if &lt;span class=&quot;math-container&quot;&gt;$n=1$&lt;/span&gt;, the lemma holds. &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-09-28T08:26:10.147" LastActivityDate="2019-09-28T08:26:10.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2684" PostTypeId="2" ParentId="2682" CreationDate="2019-09-28T08:59:05.590" Score="6" Body="&lt;p&gt;As @OguzToragay has mentioned, writing &lt;span class=&quot;math-container&quot;&gt;$\sqrt{2(n-1)ab}$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$\sqrt{2(n-2)ab}$&lt;/span&gt; allows for the trivial case of one point in the Euclidean plane since &lt;span class=&quot;math-container&quot;&gt;$|X|\ge1$&lt;/span&gt; in section 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other point to make is that writing &lt;span class=&quot;math-container&quot;&gt;$2(a+b)$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$3a/2+2b$&lt;/span&gt; means that &lt;span class=&quot;math-container&quot;&gt;$T^*(X)$&lt;/span&gt; can be succinctly expressed in terms of the perimeter of a rectangle, as in the case in Theorem 2.&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-09-28T08:59:05.590" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2686" PostTypeId="2" ParentId="2641" CreationDate="2019-09-28T17:49:05.667" Score="5" Body="&lt;p&gt;There are some linear possibilities, depending on exactly what your goal is. They all require adding some binary variables to what is already a discrete optimization problem. One is to maximize the spread between the largest and smallest assigned loads (or maybe largest and smallest nonzero loads). That may result in one large load, one minimal (zero or one task) load and just about any mix of loads for the remaining workers, so I don't think it's the best choice. Another is to use a piecewise linear value function for individual loads, where each additional unit of load adds progressively larger amounts to the objective (to be maximized).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also count the number of workers with loads above various predefined thresholds, and reward those counts in the objective. So, for example, assuming a load limit of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; for each worker, you could count workers with loads of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0.75M$&lt;/span&gt; (inclusive) to &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; (exclusive), or &lt;span class=&quot;math-container&quot;&gt;$0.5M$&lt;/span&gt; (inclusive) to &lt;span class=&quot;math-container&quot;&gt;$0.75M$&lt;/span&gt; (exclusive), and give the first category the highest value, the second category the second highest value, etc. (In this example, workers at less than 50% capacity would have objective value zero.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-09-28T17:49:05.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2688" PostTypeId="1" AcceptedAnswerId="2690" CreationDate="2019-09-28T22:04:13.407" Score="7" ViewCount="1568" Body="&lt;p&gt;I am trying to create a constraint for &lt;code&gt;model.z&lt;/code&gt; that builds up as a summation during a new time index. I tried to use the += but this does not work with Constraints it seems. I am also trying to use an Expression, because I think that this might be the way to go here, but I am not having much success just yet. I included a M.W.E below and separated the output. The output that I am trying to accomplish is also included.  &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from __future__ import division&#xA;from pyomo.environ import *&#xA;from pyomo import environ as pym&#xA;model = ConcreteModel()&#xA;&#xA;Imax = 1&#xA;Jmax = 1&#xA;Tmax = 3&#xA;model.Iset = RangeSet(1, Imax)&#xA;model.Jset = RangeSet(1, Jmax)&#xA;model.Tset = RangeSet(0, Tmax)&#xA;model.Tset2 = RangeSet(1, Tmax)&#xA;&#xA;model.x = Var(model.Iset, model.Jset, model.Tset, initialize=5)&#xA;model.y = Var(model.Iset, model.Jset, model.Tset)&#xA;model.y[1,1,0].fix(1)&#xA;model.z = Var(model.Iset, model.Jset, model.Tset)&#xA;&#xA;def first_rule(model,i,j,t):&#xA;    if t == 0:&#xA;        return Constraint.Skip&#xA;    else:&#xA;        return model.y[i,j,t] == model.x[i,j,t-1]&#xA;model.rule1 = Constraint(model.Iset,model.Jset,model.Tset, rule=first_rule)&#xA;&#xA;def second_rule(model,i,j,t):&#xA;    if t == 0:&#xA;        return Constraint.Skip&#xA;    else:&#xA;        return model.z[i,j,t] == sum(model.y[i,j,t-1] for t in model.Tset2)&#xA;model.rule2 = Constraint(model.Iset,model.Jset,model.Tset, rule=second_rule)&#xA;&#xA;model.x.pprint()&#xA;model.rule1.pprint()&#xA;model.rule2.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Current Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x : Size=4, Index=x_index&#xA;    Key       : Lower : Value : Upper : Fixed : Stale : Domain&#xA;    (1, 1, 0) :  None :     5 :  None : False : False :  Reals&#xA;    (1, 1, 1) :  None :     5 :  None : False : False :  Reals&#xA;    (1, 1, 2) :  None :     5 :  None : False : False :  Reals&#xA;    (1, 1, 3) :  None :     5 :  None : False : False :  Reals&#xA;rule1 : Size=3, Index=rule1_index, Active=True&#xA;    Key       : Lower : Body                : Upper : Active&#xA;    (1, 1, 1) :   0.0 : y[1,1,1] - x[1,1,0] :   0.0 :   True&#xA;    (1, 1, 2) :   0.0 : y[1,1,2] - x[1,1,1] :   0.0 :   True&#xA;    (1, 1, 3) :   0.0 : y[1,1,3] - x[1,1,2] :   0.0 :   True&#xA;rule2 : Size=3, Index=rule2_index, Active=True&#xA;    Key       : Lower : Body                                        : Upper : Active&#xA;    (1, 1, 1) :   0.0 : z[1,1,1] - (y[1,1,0] + y[1,1,1] + y[1,1,2]) :   0.0 :   True&#xA;    (1, 1, 2) :   0.0 : z[1,1,2] - (y[1,1,0] + y[1,1,1] + y[1,1,2]) :   0.0 :   True&#xA;    (1, 1, 3) :   0.0 : z[1,1,3] - (y[1,1,0] + y[1,1,1] + y[1,1,2]) :   0.0 :   True&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Desired Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x : Size=4, Index=x_index&#xA;    Key       : Lower : Value : Upper : Fixed : Stale : Domain&#xA;    (1, 1, 0) :  None :     5 :  None : False : False :  Reals&#xA;    (1, 1, 1) :  None :     5 :  None : False : False :  Reals&#xA;    (1, 1, 2) :  None :     5 :  None : False : False :  Reals&#xA;    (1, 1, 3) :  None :     5 :  None : False : False :  Reals&#xA;rule1 : Size=3, Index=rule1_index, Active=True&#xA;    Key       : Lower : Body                : Upper : Active&#xA;    (1, 1, 1) :   0.0 : y[1,1,1] - x[1,1,0] :   0.0 :   True&#xA;    (1, 1, 2) :   0.0 : y[1,1,2] - x[1,1,1] :   0.0 :   True&#xA;    (1, 1, 3) :   0.0 : y[1,1,3] - x[1,1,2] :   0.0 :   True&#xA;rule2 : Size=3, Index=rule2_index, Active=True&#xA;    Key       : Lower : Body                                        : Upper : Active&#xA;    (1, 1, 1) :   0.0 : z[1,1,1] - (y[1,1,0])                       :   0.0 :   True&#xA;    (1, 1, 2) :   0.0 : z[1,1,2] - (y[1,1,0] + y[1,1,1])            :   0.0 :   True&#xA;    (1, 1, 3) :   0.0 : z[1,1,3] - (y[1,1,0] + y[1,1,1] + y[1,1,2]) :   0.0 :   True&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="547" LastEditorUserId="410" LastEditDate="2019-09-29T01:34:08.843" LastActivityDate="2019-09-29T14:40:53.880" Title="Pyomo: Building Up A Constraint Over An Index" Tags="|pyomo|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2689" PostTypeId="2" ParentId="2682" CreationDate="2019-09-29T03:44:03.970" Score="5" Body="&lt;p&gt;The book seems to have left out a few steps. It's important to realize that &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{3}{2}a + 2b + \sqrt{2(n-2)ab}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is &lt;strong&gt;not&lt;/strong&gt; a valid upper bound on the longest tour, even for &lt;span class=&quot;math-container&quot;&gt;$n\ge 2$&lt;/span&gt;. That can be seen by simply setting &lt;span class=&quot;math-container&quot;&gt;$n=2$&lt;/span&gt;, which reduces the above to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{3}{2}a + 2b$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then setting &lt;span class=&quot;math-container&quot;&gt;$a=6,b=1$&lt;/span&gt;. If we put our 2 points of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; into ends of a side of length &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; of the bounding rectangle, then the one and only tour has length &lt;span class=&quot;math-container&quot;&gt;$2a=12$&lt;/span&gt;, while the above bound gives &lt;span class=&quot;math-container&quot;&gt;$\frac32\times 6+2\times 1 = 11$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They key error in the argument (which I desribed in a comment before realizing it is more than a technicality) is that it proves&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ T^*(X) \le \frac32a + 2b + \frac12ah + \frac{(n-2)b}{h}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;only for &lt;strong&gt;integer&lt;/strong&gt; values of &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; (it is defined as a number of stripes), but then proceeds to plug in an usually non-integer value of &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; into the right hand side of the above, which is not valid as the inequality was only proven for &lt;strong&gt;integer&lt;/strong&gt; values of &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As my example shows, it's more than a technicality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea if the finally given upper bound&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sqrt{2(n-1)ab} + 2(a+b)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is also incorrect, I assume not (simply on having seemingly survived 30+ years). It also isn't countered by my previous counter example. But the above makes it clear that the step from&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ T^*(X) \le \frac32a + 2b + \frac12ah + \frac{(n-2)b}{h}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ T^*(X) \le \sqrt{2(n-1)ab} + 2(a+b)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;cannot simply be done by setting &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$h=\sqrt{2(n-2)b/a}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;because that is not an integer usually and leads to an incorrect intermediate inequality.&lt;/p&gt;&#xA;" OwnerUserId="2432" LastActivityDate="2019-09-29T03:44:03.970" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2690" PostTypeId="2" ParentId="2688" CreationDate="2019-09-29T10:49:02.107" Score="6" Body="&lt;p&gt;You just need to sum over another index variable than &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Here is the correct code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from __future__ import division&#xA;from pyomo.environ import *&#xA;from pyomo import environ as pym&#xA;model = ConcreteModel()&#xA;&#xA;Imax = 1&#xA;Jmax = 1&#xA;Tmax = 3&#xA;model.Iset = RangeSet(1, Imax)&#xA;model.Jset = RangeSet(1, Jmax)&#xA;model.Tset = RangeSet(0, Tmax)&#xA;model.Tset2 = RangeSet(1, Tmax)&#xA;&#xA;model.x = Var(model.Iset, model.Jset, model.Tset, initialize=5)&#xA;model.y = Var(model.Iset, model.Jset, model.Tset)&#xA;model.y[1,1,0].fix(1)&#xA;model.z = Var(model.Iset, model.Jset, model.Tset)&#xA;&#xA;def first_rule(model,i,j,t):&#xA;    if t == 0:&#xA;        return Constraint.Skip&#xA;    else:&#xA;        return model.y[i,j,t] == model.x[i,j,t-1]&#xA;model.rule1 = Constraint(model.Iset,model.Jset,model.Tset, rule=first_rule)&#xA;&#xA;def second_rule(model,i,j,t):&#xA;    if t == 0:&#xA;        return Constraint.Skip&#xA;    else:&#xA;        return model.z[i,j,t] == sum(model.y[i,j,k] for k in model.Tset2 if k&amp;lt;= t)&#xA;model.rule2 = Constraint(model.Iset,model.Jset,model.Tset, rule=second_rule)&#xA;&#xA;model.x.pprint()&#xA;model.rule1.pprint()&#xA;model.rule2.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which produces&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x : Size=4, Index=x_index&#xA;    Key       : Lower : Value : Upper : Fixed : Stale : Domain&#xA;    (1, 1, 0) :  None :     5 :  None : False : False :  Reals&#xA;    (1, 1, 1) :  None :     5 :  None : False : False :  Reals&#xA;    (1, 1, 2) :  None :     5 :  None : False : False :  Reals&#xA;    (1, 1, 3) :  None :     5 :  None : False : False :  Reals&#xA;rule1 : Size=3, Index=rule1_index, Active=True&#xA;    Key       : Lower : Body                : Upper : Active&#xA;    (1, 1, 1) :   0.0 : y[1,1,1] - x[1,1,0] :   0.0 :   True&#xA;    (1, 1, 2) :   0.0 : y[1,1,2] - x[1,1,1] :   0.0 :   True&#xA;    (1, 1, 3) :   0.0 : y[1,1,3] - x[1,1,2] :   0.0 :   True&#xA;rule2 : Size=3, Index=rule2_index, Active=True&#xA;    Key       : Lower : Body                                        : Upper : Active&#xA;    (1, 1, 1) :   0.0 :                         z[1,1,1] - y[1,1,1] :   0.0 :   True&#xA;    (1, 1, 2) :   0.0 :            z[1,1,2] - (y[1,1,1] + y[1,1,2]) :   0.0 :   True&#xA;    (1, 1, 3) :   0.0 : z[1,1,3] - (y[1,1,1] + y[1,1,2] + y[1,1,3]) :   0.0 :   True&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="137" LastEditorUserId="123" LastEditDate="2019-09-29T11:42:31.657" LastActivityDate="2019-09-29T11:42:31.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2691" PostTypeId="2" ParentId="2658" CreationDate="2019-09-29T12:12:40.183" Score="3" Body="&lt;p&gt;The problem here seems to be that the data is provided in a somewhat untidy fashion. To use the function the data needs to be preprocessed to extract each entry from the column &quot;Predecessor(s)&quot;. You can use the function &lt;code&gt;separate_rows&lt;/code&gt; from the R package &lt;a href=&quot;https://tidyr.tidyverse.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;tidyr&lt;/a&gt; (contained in the tidyverse) to do this. You'll also have to convert the letters to numbers.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-r prettyprint-override&quot;&gt;&lt;code&gt;library(tidyverse)&#xA;&#xA;myLetters &amp;lt;- LETTERS[1:26]&#xA;&#xA;raw_table &amp;lt;- tribble(&#xA;    ~Task, ~Predecessors, ~ECT,&#xA;    &quot;A&quot;, &quot;-&quot;, 90,&#xA;    &quot;B&quot;, &quot;A&quot;, 15,&#xA;    &quot;C&quot;, &quot;B,A&quot;, 25,&#xA;    &quot;D&quot;, &quot;A,B,C&quot;, 10&#xA;)&#xA;&#xA;processed_table &amp;lt;- raw_table %&amp;gt;% &#xA;    separate_rows(Predecessors) %&amp;gt;%&#xA;    filter(Predecessors != &quot;&quot;) %&amp;gt;%&#xA;    transmute(start=match(Predecessors, myLetters), &#xA;              end=match(Task, myLetters),&#xA;              weight=ECT)&#xA;processed_table&#xA;#&amp;gt; # A tibble: 6 x 3&#xA;#&amp;gt;   start   end weight&#xA;#&amp;gt;   &amp;lt;int&amp;gt; &amp;lt;int&amp;gt;  &amp;lt;dbl&amp;gt;&#xA;#&amp;gt; 1     1     2     15&#xA;#&amp;gt; 2     2     3     25&#xA;#&amp;gt; 3     1     3     25&#xA;#&amp;gt; 4     1     4     10&#xA;#&amp;gt; 5     2     4     10&#xA;#&amp;gt; 6     3     4     10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="137" LastActivityDate="2019-09-29T12:12:40.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2692" PostTypeId="2" ParentId="2688" CreationDate="2019-09-29T14:34:41.940" Score="3" Body="&lt;p&gt;The best code was answered above, however, I think that this is another way to implement what I intended as well. Although, it is more complicated but it does provide another way of thinking about the problem for anyone who sees it down the line. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from __future__ import division&#xA;from pyomo.environ import *&#xA;from pyomo import environ as pym&#xA;model = ConcreteModel()&#xA;&#xA;Imax = 1&#xA;Jmax = 1&#xA;Tmax = 5&#xA;model.Iset = RangeSet(1, Imax)&#xA;model.Jset = RangeSet(1, Jmax)&#xA;model.Tset = RangeSet(0, Tmax)&#xA;model.Tset2 = RangeSet(1, Tmax)&#xA;&#xA;model.x = Var(model.Iset, model.Jset, model.Tset, initialize=5)&#xA;model.y = Var(model.Iset, model.Jset, model.Tset)&#xA;model.y[1,1,0].fix(1)&#xA;model.z = Var(model.Iset, model.Jset, model.Tset)&#xA;&#xA;def first_rule(model,i,j,t):&#xA;    if t == 0:&#xA;        return Constraint.Skip&#xA;    else:&#xA;        return model.y[i,j,t] == model.x[i,j,t-1]&#xA;model.rule1 = Constraint(model.Iset,model.Jset,model.Tset, rule=first_rule)&#xA;&#xA;def second_rule(model,i,j,t):&#xA;    if t == 0:&#xA;        return Constraint.Skip&#xA;    if t == 1:&#xA;        return model.z[i,j,t] == model.y[i,j,t-1]&#xA;    else:&#xA;        return model.z[i,j,t] == model.z[i,j,t-1] + model.y[i,j,t-1]&#xA;model.rule2 = Constraint(model.Iset,model.Jset,model.Tset, rule=second_rule)&#xA;&#xA;model.pprint()&#xA;&#xA;Edited Output:&#xA;&#xA;2 Constraint Declarations&#xA;    rule1 : Size=5, Index=rule1_index, Active=True&#xA;        Key       : Lower : Body                : Upper : Active&#xA;        (1, 1, 1) :   0.0 : y[1,1,1] - x[1,1,0] :   0.0 :   True&#xA;        (1, 1, 2) :   0.0 : y[1,1,2] - x[1,1,1] :   0.0 :   True&#xA;        (1, 1, 3) :   0.0 : y[1,1,3] - x[1,1,2] :   0.0 :   True&#xA;        (1, 1, 4) :   0.0 : y[1,1,4] - x[1,1,3] :   0.0 :   True&#xA;        (1, 1, 5) :   0.0 : y[1,1,5] - x[1,1,4] :   0.0 :   True&#xA;    rule2 : Size=5, Index=rule2_index, Active=True&#xA;        Key       : Lower : Body                             : Upper : Active&#xA;        (1, 1, 1) :   0.0 :              z[1,1,1] - y[1,1,0] :   0.0 :   True&#xA;        (1, 1, 2) :   0.0 : z[1,1,2] - (z[1,1,1] + y[1,1,1]) :   0.0 :   True&#xA;        (1, 1, 3) :   0.0 : z[1,1,3] - (z[1,1,2] + y[1,1,2]) :   0.0 :   True&#xA;        (1, 1, 4) :   0.0 : z[1,1,4] - (z[1,1,3] + y[1,1,3]) :   0.0 :   True&#xA;        (1, 1, 5) :   0.0 : z[1,1,5] - (z[1,1,4] + y[1,1,4]) :   0.0 :   True&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="547" LastEditorUserId="123" LastEditDate="2019-09-29T14:40:53.880" LastActivityDate="2019-09-29T14:40:53.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2693" PostTypeId="2" ParentId="1052" CreationDate="2019-09-30T04:33:53.850" Score="3" Body="&lt;p&gt;You can manipulate this inequality as follows&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sqrt{\sum_{i \in \mathcal{I}} a_{ij}x_{ij}  }  \leq \theta_j, \quad \quad \forall j \in \mathcal{J}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i \in \mathcal{I}} a_{ij}x_{ij}  \leq \theta_j^2, \quad \quad \forall j \in \mathcal{J}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, you need to linearize &lt;span class=&quot;math-container&quot;&gt;$\theta_j^2$&lt;/span&gt; using &lt;a href=&quot;https://optimization.mccormick.northwestern.edu/index.php/McCormick_envelopes&quot; rel=&quot;nofollow noreferrer&quot;&gt;McCormick Envelopes&lt;/a&gt;. To do this, assume &lt;span class=&quot;math-container&quot;&gt;$-M_j\leq \theta_j \leq M_j$&lt;/span&gt; and consider &lt;span class=&quot;math-container&quot;&gt;$w_j=\theta_j^2$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;0\leq (\theta_j + M_j)(\theta_j + M_j) &amp;amp; \implies &amp;amp; -w_j - 2M_j\theta \leq M_j^2\\&#xA;0\leq (M_j - \theta_j)(M_j - \theta_j) &amp;amp; \implies &amp;amp; -w_j + 2M_j\theta \leq M_j^2\\&#xA;0\leq (\theta_j + M_j)(M_j - \theta_j) &amp;amp; \implies &amp;amp; w_j \leq M_j^2\\&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The final set of constraints is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\sum_{i \in \mathcal{I}} a_{ij}x_{ij}  \leq w_j, \quad \quad \forall j \in \mathcal{J}\\&#xA;-w_j - 2M_j\theta_j \leq M_j^2, \quad \quad \forall j \in \mathcal{J}\\&#xA;-w_j + 2M_j\theta_j \leq M_j^2, \quad \quad \forall j \in \mathcal{J}\\&#xA;0 \leq w_j \leq M_j^2, \quad \quad \forall j \in \mathcal{J}\\&#xA;-M_j \leq \theta_j \leq M_j, \quad \quad \forall j \in \mathcal{J}\\&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OBS: Verify my counts, please.&lt;/p&gt;&#xA;" OwnerUserId="1252" LastEditorUserId="1252" LastEditDate="2019-09-30T06:09:35.060" LastActivityDate="2019-09-30T06:09:35.060" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2694" PostTypeId="1" CreationDate="2019-09-30T10:08:30.710" Score="11" ViewCount="297" Body="&lt;p&gt;I was wondering what is the state-of-the-art for solving the Generalized Assignment Problem (GAP) and if there are special cases that are polynomially solvable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover, is there any usage of this problem as a sub-problem within a decomposition algorithm such as Lagrangian relaxation algorithms?&lt;/p&gt;&#xA;" OwnerUserId="1094" LastEditorUserId="1094" LastEditDate="2019-09-30T12:03:04.470" LastActivityDate="2019-09-30T20:02:42.747" Title="Generalized Assignment Problem as the sub-problem" Tags="|integer-programming|computational-complexity|assignment-problem|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2695" PostTypeId="2" ParentId="2641" CreationDate="2019-09-30T11:08:00.583" Score="2" Body="&lt;p&gt;One thing that might be worth considering is symmetry breaking constraints, since your workers are identical. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You haven't provided a formulation but I would assume that with a set of workers &lt;span class=&quot;math-container&quot;&gt;$\mathcal{W}$&lt;/span&gt; and a set of jobs &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}$&lt;/span&gt; you have a variable like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_{w,j} = \left\{ \begin{matrix}1 \text{ if worker } w \text{ is assigned job } j \\ 0 \text{ otherwise} \end{matrix} \right. $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From this variable you could create another variable as such:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ y_{w} = \left\{ \begin{matrix}1 \text{ if worker } w \text{ is assigned any job } \\ 0 \text{ otherwise} \end{matrix} \right. $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the following constraint to link the variables:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j \in \mathcal{J}} x_{w,j} \leq \vert \mathcal{J} \vert \hspace{0.05cm} y_{w} \hspace{0.5cm} \forall w \in \mathcal{W}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can now implement a symmetry breaking constraint as such:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ y_{w} \geq y_{w+1} \hspace{0.5cm} \forall w \in \left[0, \vert \mathcal{W} \vert -1 \right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This constraint imposes an artificial precedence on the staff to be allocated, meaning that a staff member indexed by &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; can only be assigned a job if the staff member indexed &lt;span class=&quot;math-container&quot;&gt;$w-1$&lt;/span&gt; has been assigned at least one job. This is useful for two reasons:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You can now simply minimise the number of staff used by minimising &lt;span class=&quot;math-container&quot;&gt;$ \sum_{w \in \mathcal{W}} y_{w} $&lt;/span&gt;, since this will make the model try and fill in each workers capacity before assigning the next worker a job.&lt;/li&gt;&#xA;&lt;li&gt;This should help speed up the solving time, since by imposing symmetry breaking constraints you drastically reduce the size of the solution space.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;More information about symmetry breaking can be found at: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://pdfs.semanticscholar.org/0bac/193bc74453aa97759d1162401aaa4d6d907a.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pdfs.semanticscholar.org/0bac/193bc74453aa97759d1162401aaa4d6d907a.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="843" LastActivityDate="2019-09-30T11:08:00.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2696" PostTypeId="2" ParentId="2694" CreationDate="2019-09-30T11:42:45.747" Score="3" Body="&lt;p&gt;AFAIK, one of an efficient way to solve Generalized Assignment Problem (GAP),  is using Branch and Price technique. I will hope, &lt;a href=&quot;https://www2.isye.gatech.edu/people/faculty/Martin_Savelsbergh/publications/or45.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; or &lt;a href=&quot;https://pdfs.semanticscholar.org/be5f/08847224184c4161ab1dc6fcb6dc7d28f96c.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; link be useful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-09-30T11:42:45.747" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2697" PostTypeId="2" ParentId="2694" CreationDate="2019-09-30T13:10:32.557" Score="9" Body="&lt;p&gt;I have used a GAP as a subproblem in a previous project where the aim was to solve the single source capacitated facility location problem. I tried several things in order to speed up the computations, and found that the most effective approach was to use exact knapsack separation from the capacity constraints. That is, I basically solved the dual of the &quot;natural&quot; column generation master. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I implemented it was using CPLEX by first solving the LP relaxation at the root node, then I ran several cut-loops until I experienced too much trailing off. After that, I converted the problem to an IP and added a cut callback, which used the same separation routine as I used at the root node. After experimenting a bit, I found that I got the best results this way, as CPLEX wanted to stop the cut-loop at the root node earlier than I did. I am definitely not saying this is the best way to do it, but in my experience, it worked quite okay. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, given that it is an NP-annoying (complexity class formally defined by @prubin, I think) problem, you will have to expect that in some cases the computation time explodes!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(You can find an implementation in c of a exact knapsack separation routine here: &lt;a href=&quot;https://github.com/SuneGadegaard/SSCFLPsolver/blob/master/vico.h&quot; rel=&quot;noreferrer&quot;&gt;header&lt;/a&gt; &lt;a href=&quot;https://github.com/SuneGadegaard/SSCFLPsolver/blob/master/vico.c&quot; rel=&quot;noreferrer&quot;&gt;source&lt;/a&gt;, the function you need is &lt;code&gt;VICkpsep()&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="123" LastEditDate="2019-09-30T20:02:42.747" LastActivityDate="2019-09-30T20:02:42.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2698" PostTypeId="1" CreationDate="2019-09-30T15:22:35.377" Score="7" ViewCount="342" Body="&lt;p&gt;When I tried to use Java to call CPLEX and use callback functions to solve a VRP problem with branch-and-cut, some problems emerged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I took out the subtour elimination constraint from the original problem, and used it as &lt;code&gt;usercut&lt;/code&gt; and &lt;code&gt;lazyconstraint&lt;/code&gt;. When I only used it as a &lt;code&gt;lazyconstraint&lt;/code&gt;, the algorithm worked out very well, but when I used it as both &lt;code&gt;usercut&lt;/code&gt; and &lt;code&gt;lazyconstraint&lt;/code&gt; Java program couldn't stop, it kept calling &lt;code&gt;usercutCallback&lt;/code&gt; at &lt;code&gt;node0&lt;/code&gt; and wouldn't make branch. I really don't know what the problem is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does CPLEX loop calling &lt;code&gt;usercutCallback&lt;/code&gt; at each non-integer node until no usercut are violated, and then make branch? If so, can I set the maximum number of calls at each node? Maybe just one time is ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another problem is why it kept generating the same cut. I think when cut A has been already added, even if I generate A again in the next loop, it should have been satisfied so that no &lt;code&gt;usercut&lt;/code&gt; is violated and the loop should be stopped.&lt;/p&gt;&#xA;" OwnerUserId="2438" LastEditorUserId="123" LastEditDate="2019-09-30T20:05:06.420" LastActivityDate="2021-03-17T17:27:43.790" Title="Program can't stop when using callback of usercut in CPLEX to solve a branch-and-cut problem" Tags="|cplex|vehicle-routing|branch-and-cut|callback|java|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2699" PostTypeId="1" CreationDate="2019-09-30T17:51:56.867" Score="6" ViewCount="109" Body="&lt;p&gt;The job responsibility is exactly the same in the department. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The department has a total number of working hours required.&#xA;The total retention is about 50% a year, and the hiring cost is about $2000 per person.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Salary is about $12 per hour. Full time works 40 hours, while part time works 20 hours per week.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this an optimization or simulation problem? I guess the output is a range of workers required. How to model this? &lt;/p&gt;&#xA;" OwnerUserId="1219" LastEditorUserId="123" LastEditDate="2019-10-01T19:06:22.163" LastActivityDate="2019-10-01T19:06:22.163" Title="How to decide the hiring headcount for a retail department" Tags="|optimization|modeling|simulation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2700" PostTypeId="2" ParentId="2699" CreationDate="2019-09-30T19:18:18.553" Score="6" Body="&lt;p&gt;If you want to find the number of workers that you need for the job to be done while the hiring cost and available hours differ from full-time work to part-time work and on the other hand you want to minimize the cost, that is exactly an optimization problem with the following specifications:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Objective function: will be the summation of all hiring costs. We want to minimize this value.&lt;/li&gt;&#xA;&lt;li&gt;Constraint on available time:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;each part-time worker can not exceed the 20 hours available working time.&lt;/li&gt;&#xA;&lt;li&gt;Full-time workers can not work more than 40 hours&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I think there should be also some constraints in the model related to the number of hours that is necessary for the job to be done, some budget limitations and etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you put more details in your question, I believe it will be easier for answerers to help you in the modeling step. &lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-09-30T19:18:18.553" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2701" PostTypeId="1" CreationDate="2019-09-30T21:07:14.237" Score="17" ViewCount="2501" Body="&lt;p&gt;I am a master student in operations research with a specialization in operations research. To get my degree, I need to have a 6-month internship (from March to September).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am preparing my CV and I am browsing some offers in websites like glassdoor or LinkedIn etc. to have an idea about the market. I think that there is not a lot of offers in OR on those websites. I need to start to apply by the end of this month and I don't have an idea where to look. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So any tips on finding an internship ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am based in France but I am willing to travel.  &lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="38" LastEditDate="2019-09-30T23:06:47.143" LastActivityDate="2022-12-04T20:39:01.267" Title="How to find an internship in OR/Optimization?" Tags="|job-market|or-careers|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2702" PostTypeId="2" ParentId="2701" CreationDate="2019-09-30T21:56:24.437" Score="7" Body="&lt;p&gt;As @Mark L. Stone said your professors, and particularly those you had a course or project could be a good source for the networking. Some websites like &lt;a href=&quot;https://www.indeed.com/q-Operations-Research-Intern-jobs.html&quot; rel=&quot;noreferrer&quot;&gt;this link&lt;/a&gt; can be helpful, while I am not sure about those opportunities in Europe. Also, you can find some job (mostly) and internship position posting in the following resources:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://lists.clemson.edu/mailman/listinfo/iefac.list&quot; rel=&quot;noreferrer&quot;&gt;IEFac.list&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.higheredjobs.com/&quot; rel=&quot;noreferrer&quot;&gt;HigherEd Jobs&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://academicjobsonline.org/ajo&quot; rel=&quot;noreferrer&quot;&gt;AcademicJobsOnline.org&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-09-30T21:56:24.437" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="2703" PostTypeId="2" ParentId="2701" CreationDate="2019-09-30T22:01:18.697" Score="12" Body="&lt;p&gt;On top of the websites you mentioned:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Search on Google! If this is not what you are already doing, this should be on top of your list. Not all ads are on job sites.&lt;/li&gt;&#xA;&lt;li&gt;Check different companies websites. Some companies ads may not show up in the first pages of your search. So you can focus your search by having some companies in mind. For example, ask your friends or colleagues where they had their internships. That's a good place to start creating a list (on top of having a chance of a referral). If you don't have a list, think of what industry you like to work on and then search for that industry to find companies that are in that industry (e.g. you like to work in retail. Search for companies in retail)&lt;/li&gt;&#xA;&lt;li&gt;On top of having an up-to-date Linkedin account, upload your resume in all the job websites you know (Indeed, Monster, etc).&lt;/li&gt;&#xA;&lt;li&gt;If you know of any recruiter on LinkedIn, connect with them. Even if they can't help you now for your internship, that's a good investment for the future.&lt;/li&gt;&#xA;&lt;li&gt;Don't confine yourself to a keyword. Search for responsibilities or tasks you like to do. You never know how each company brand themselves. You may look for an operations research position and find nothing, while a company can call all of their employees &quot;analyst&quot; or &quot;data scientist&quot; (especially with all the hype around data science!) All that matters is the requirements in the job posting match your interest and expertise. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-09-30T22:01:18.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2704" PostTypeId="2" ParentId="2701" CreationDate="2019-10-01T07:45:54.960" Score="11" Body="&lt;p&gt;From my experience:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1/ Lookup where the students did their internships in the previous years. Contacting those companies might be a good option, as they might be willing to take an intern coming from your program if they were happy with the experience the previous year(s).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2/ Try to find companies working on product linked to Operations Research (companies developing Advanced Planning and Scheduling Software (APS), Transport Management Software (TMS), Workforce Management Software, etc.) and contact them to see if they might be interested to take you as an intern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3/ As you mentioned that you are based in France, looking at the forum of the ROADEF (&lt;a href=&quot;http://roadef.org/forum&quot; rel=&quot;noreferrer&quot;&gt;http://roadef.org/forum&lt;/a&gt;) can also be a good bet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not because a company does not publicly post internship offers that they are not taking interns. Anecdotal evidence: when I was a student the most interesting internship that I got to do was with a company that was not advertising any internship. They were making an interesting product, so I contacted them to know if they would be willing to take me as an intern, and I ended up working on an interesting crew rostering problem with them. Another anecdotal evidence: my company is having some operations research related internships available but they are mainly communicated to university with which we already have an existing link (which does not mean that we would not consider somebody coming from another university for them).&lt;/p&gt;&#xA;" OwnerUserId="124" LastEditorUserId="123" LastEditDate="2019-10-01T15:52:50.437" LastActivityDate="2019-10-01T15:52:50.437" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2705" PostTypeId="1" AcceptedAnswerId="2707" CreationDate="2019-10-01T14:21:19.747" Score="6" ViewCount="1107" Body="&lt;p&gt;I am solving a Certainty Equivalent (Decision Analysis) problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is a Risk-Averse Case - a deal of &lt;span class=&quot;math-container&quot;&gt;$60\%$&lt;/span&gt; chance to win &lt;span class=&quot;math-container&quot;&gt;$\$100,\!000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$40\%$&lt;/span&gt; chance to lose &lt;span class=&quot;math-container&quot;&gt;$\$10,\!000$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose the decision-maker is risk-averse with a risk tolerance of &lt;span class=&quot;math-container&quot;&gt;$\$20,\!000$&lt;/span&gt; and his utility function is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$u(x)=1.0067837 (1-e^{-x/20\,000}).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer shows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}u(\rm CE)&amp;amp;= 0.6 u(100\,000) + 0.4 u(-10\,000)\\&amp;amp;= 0.4(1.00) + 0.4(-0.65312)\\&amp;amp;= 0.338751\\\implies{\rm CE}&amp;amp;=u^{-1}(0.338751)=\$8,\!203.59.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does &lt;span class=&quot;math-container&quot;&gt;$0.6 u(100\,000)$&lt;/span&gt; equal to &lt;span class=&quot;math-container&quot;&gt;$0.4(1.00)$&lt;/span&gt;, and likewise &lt;span class=&quot;math-container&quot;&gt;$0.4 u(-10\,000)$&lt;/span&gt; equals to &lt;span class=&quot;math-container&quot;&gt;$0.4(-0.65312)$&lt;/span&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, with &lt;span class=&quot;math-container&quot;&gt;$u^{-1}(0.338751)$&lt;/span&gt;, how does it arrive at &lt;span class=&quot;math-container&quot;&gt;$\$8,\!203.59$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2440" LastEditorUserId="123" LastEditDate="2019-10-01T15:50:29.020" LastActivityDate="2019-10-01T16:15:21.257" Title="Solving a Certainty Equivalent (Decision Analysis) problem" Tags="|optimization|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2706" PostTypeId="2" ParentId="2705" CreationDate="2019-10-01T15:19:39.193" Score="3" Body="&lt;p&gt;There is a typo in the calculation that you mentioned.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$u({\rm CE}) = 0.6 u(100\,000)+0.4 u(-10\,000)=0.6(1.0000)+0.4(-0.65312)=0.338751$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your second question, if &lt;span class=&quot;math-container&quot;&gt;$y=f(x) \text{ then  } x=f^{-1}(y).$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the calculations:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}u(100\,000)&amp;amp;=1.0067837(0.993262053000)=1.000000044789&#xA;\\u(-10\,000)&amp;amp;=1.0067837(-0.64872127070)=-0.65312200118\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-10-01T15:41:46.537" LastActivityDate="2019-10-01T15:41:46.537" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2707" PostTypeId="2" ParentId="2705" CreationDate="2019-10-01T15:48:02.850" Score="3" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$u(d)=c$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$d=u^{-1}(c)$&lt;/span&gt; since &lt;span class=&quot;math-container&quot;&gt;$u\circ u^{-1}$&lt;/span&gt; forms the identity. Thus in general, under suitable constraints for &lt;span class=&quot;math-container&quot;&gt;$a,b,c$&lt;/span&gt;,&lt;span class=&quot;math-container&quot;&gt;\begin{align}a(1-e^{-d/b})=c&amp;amp;\implies1-e^{-d/b}=\frac ca\\&amp;amp;\implies e^{-d/b}=1-\frac ca=\frac{a-c}a\\&amp;amp;\implies-\frac db=\ln\frac{a-c}a&amp;amp;&amp;amp;\\&amp;amp;\implies d=-b\ln\frac{a-c}a=b\ln\frac a{a-c}.\end{align}&lt;/span&gt; Now substitute the values of &lt;span class=&quot;math-container&quot;&gt;$a=1.0067837$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b=20\,000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c=0.338751$&lt;/span&gt; to obtain &lt;span class=&quot;math-container&quot;&gt;$d=u^{-1}(c)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-10-01T16:15:21.257" LastActivityDate="2019-10-01T16:15:21.257" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2708" PostTypeId="1" AcceptedAnswerId="2720" CreationDate="2019-10-01T17:45:19.337" Score="9" ViewCount="2219" Body="&lt;p&gt;I am trying to extract my variable values into unique lists so that I can pass them to a panadas dataframe and eventually export the dataframe to Excel after I solve my model. The idea is to have the variables of interest in a much more readable and familiar format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thought process right now looks like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create an empty list and add new lists.&lt;/li&gt;&#xA;&lt;li&gt;For each variable in the model, get the dictionary-key values and insert those in the list. &lt;/li&gt;&#xA;&lt;li&gt;The resultant list, &lt;code&gt;value_list&lt;/code&gt;, will have each variables values stored in its own list. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;value_list = []&#xA;&#xA;for v in model.component_objects(Var):&#xA;    value_list.append( list(model.v.get_values().values()) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would think that the loop variable would replace the &lt;code&gt;v&lt;/code&gt; component in the body of &lt;code&gt;for&lt;/code&gt; loop and then run the operation as if it was the explicit variable name, but this is not the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately I am trying to produce a dataframe of my solved variables with the  first series being the index of tuples (i,j,t) up to (I,J,T), but it's a bit cumbersome to manually create a series object for each of my variables. Note that all variables as shown below: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;list_of_series = [  pd.Series(pyomo_index_list),&#xA;                    pd.Series(list(model.susceptible.get_values().values())),&#xA;                    pd.Series(list(model.inf_treated.get_values().values())),&#xA;                    pd.Series(list(model.inf_b4treat.get_values().values())),&#xA;                    pd.Series(list(model.level1.get_values().values())),&#xA;                    pd.Series(list(model.juvenilleTotal.get_values().values()))   ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If there was a way to create a loop so that &lt;code&gt;model.&amp;lt;var&amp;gt;.get_values().values()&lt;/code&gt; was not hard coded, then the code would be more reproducible for models that have 15, 30, or 50 variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The final output would look like this, but as a pandas dataframe: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;          Susceptible inf_treated inf_b4treat level1 JuvTotal   &#xA;Key                                                             &#xA;(1, 1, 0)          50           7         NaN    NaN       21   &#xA;(1, 1, 1)        50.2     8.22148      16.443      1     13.8   &#xA;(1, 1, 2)     52.5085     10.1232     20.2464      1     3.27   &#xA;(1, 1, 3)     44.0863     26.5758     26.5758      0    1.569   &#xA;(1, 2, 0)          30           7         NaN    NaN        8   &#xA;(1, 2, 1)        25.7     4.93289     9.86577      1      5.3   &#xA;(1, 2, 2)     24.8171     2.51488     5.02976      1     1.25   &#xA;(1, 2, 3)     22.9502     1.47623     1.47623      0    0.602   &#xA;(2, 1, 0)          20           9         NaN    NaN       18   &#xA;(2, 1, 1)        17.3     4.47514     8.95028      1     11.7   &#xA;(2, 1, 2)     21.7349     1.44328     2.88656      1     2.79   &#xA;(2, 1, 3)     21.7496    0.443511    0.443511      0    1.332   &#xA;(2, 2, 0)          35           8         NaN    NaN       16   &#xA;(2, 2, 1)        35.1     6.82927     13.6585      1      7.9   &#xA;(2, 2, 2)     33.9407     5.58183     11.1637      1     2.23   &#xA;(2, 2, 3)     29.6549     8.06275     8.06275      0    0.934 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="547" LastEditorUserId="547" LastEditDate="2019-10-02T14:18:10.083" LastActivityDate="2019-10-02T20:13:42.853" Title="Pyomo: Looping Over A Variable Method" Tags="|python|pyomo|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="2709" PostTypeId="2" ParentId="2701" CreationDate="2019-10-01T19:34:01.397" Score="5" Body="&lt;p&gt;The &lt;a href=&quot;https://listserv.zib.de/mailman/listinfo/opt-net&quot; rel=&quot;noreferrer&quot;&gt;Opt-Net&lt;/a&gt; mailing list contains lots of position announcements for faculty and industry, including positions in doctoral programs. I don't recall seeing any announcements for internships, but you could check the archive. Also, I'm not aware of any injunctions against asking about internships on it.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-10-01T19:34:01.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2710" PostTypeId="1" AcceptedAnswerId="2716" CreationDate="2019-10-02T02:22:08.783" Score="11" ViewCount="1269" Body="&lt;p&gt;I read here &lt;a href=&quot;https://slideplayer.com/slide/3353960/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://slideplayer.com/slide/3353960/&lt;/a&gt; that RCPS is a generalized version of job shop scheduling. I'm new to this area and I'm trying to classify a specific variation of these types of problems. Understanding this difference would be a good start.&lt;/p&gt;&#xA;" OwnerUserId="2445" LastEditorUserId="491" LastEditDate="2022-01-16T14:47:02.947" LastActivityDate="2022-01-16T14:47:02.947" Title="What is the difference between job shop scheduling and resource constrained project scheduling?" Tags="|optimization|combinatorial-optimization|scheduling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2711" PostTypeId="1" AcceptedAnswerId="2715" CreationDate="2019-10-02T04:13:45.663" Score="10" ViewCount="199" Body="&lt;p&gt;Let's say I have a bunch of linear functions &lt;span class=&quot;math-container&quot;&gt;$f_1,\cdots,f_n$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; variables; then &lt;span class=&quot;math-container&quot;&gt;$f_1,\cdots, f_n\le0$&lt;/span&gt; defines a polyhedron &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; in the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-dimensional space. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm looking for is going the other way: given data points inside a polyhedron &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;, is there an efficient/fast way to find the functions &lt;span class=&quot;math-container&quot;&gt;$f_1,\cdots,f_n$&lt;/span&gt; cutting the polyhedron? Those data points are finitely many integer points (i.e. points whose all coordinates are integers) and &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is &quot;the smallest&quot; polyhedron containing them. Basically I require two things: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; does not contain any other integer points. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The linear functions themselves have integer coefficients.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;A naive way would be to loop over all possible candidate functions (their integer coefficients) in a certain range but there should be a much better/faster/efficient way of doing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not specifically looking for an answer to this problem, rather a reference or direction for where I should be looking at. Has this been studied at all? I understand that this is not exactly what linear/integer programming is about, so apologies if the question is not appropriate for this site.&lt;/p&gt;&#xA;" OwnerUserId="2446" LastEditorUserId="38" LastEditDate="2019-10-04T00:23:49.930" LastActivityDate="2019-10-04T00:23:49.930" Title="Finding the linear functions defining a polyhedron through integer data?" Tags="|linear-programming|reference-request|integer-programming|polyhedra|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2712" PostTypeId="2" ParentId="180" CreationDate="2019-10-02T05:39:49.373" Score="3" Body="&lt;p&gt;In addition, you can search for McCormick Envelopes in this site:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/search?q=McCormick%20envelopes&quot;&gt;McCormick&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;span class=&quot;math-container&quot;&gt;$0\leq x \leq 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0\leq y\leq 1$&lt;/span&gt;. By substituition &lt;span class=&quot;math-container&quot;&gt;$z=xy$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$0\leq z\leq 1$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;z\leq x\\&#xA;z\leq y\\&#xA;z\geq x+y-1&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but, it is a relaxation for continuous variables. Note that &lt;span class=&quot;math-container&quot;&gt;$x=0.5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y=0.5$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$0\leq z\leq 0.5$&lt;/span&gt; and not &lt;span class=&quot;math-container&quot;&gt;$z=0.25$&lt;/span&gt;. For binary variables this method is exact.&lt;/p&gt;&#xA;" OwnerUserId="1252" LastEditorUserId="1252" LastEditDate="2019-10-02T05:58:24.980" LastActivityDate="2019-10-02T05:58:24.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2713" PostTypeId="2" ParentId="2682" CreationDate="2019-10-02T05:47:39.693" Score="4" Body="&lt;p&gt;Set &#xA;\[f(h)=\frac32a+2b+\frac{ah}{2}+\frac{(n-2)b}{h}.\]&#xA;Then &lt;span class=&quot;math-container&quot;&gt;$T^*(X)\leqslant f(h)$&lt;/span&gt; for every positive integer &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt;. For &lt;span class=&quot;math-container&quot;&gt;$n\geqslant 3$&lt;/span&gt; and &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;h^* &amp;amp;= \sqrt{2(n-2)b/a}, &amp;amp; h&amp;amp;=\left\lceil h^*\right\rceil&#xA;\end{align*}&lt;/span&gt;&#xA; we have &lt;span class=&quot;math-container&quot;&gt;$h^*\leqslant h\leqslant h^*+1$&lt;/span&gt;, hence&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{ah}{2}\leqslant\frac{a(h^*+1)}{2}=\frac{ah^*}{2}+\frac{a}{2},$$&lt;/span&gt;&#xA;and &#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{(n-2)b}{h}\leqslant\frac{(n-2)b}{h^*},$$&lt;/span&gt;&#xA;and then&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{multline*}&#xA;T^*(X)\leqslant f(h)=\frac32a+2b+\frac{ah}{2}+\frac{(n-2)b}{h}\\&#xA;\leqslant \frac32a+2b+\left(\frac{ah^*}{2}+\frac{a}{2}\right)+\frac{(n-2)b}{h^*}&#xA;= f\left(h^*\right)+\frac{a}{2}\\&#xA;=\frac{3}{2}a+2b+\sqrt{2(n-2)ab}+\frac{a}{2}&#xA;=2(a+b)+\sqrt{2(n-2)ab}.&#xA;\end{multline*}&lt;/span&gt;&#xA;The claimed inequality is trivial for &lt;span class=&quot;math-container&quot;&gt;$n=2$&lt;/span&gt;, and as mentioned in other answers, the &lt;span class=&quot;math-container&quot;&gt;$n-2$&lt;/span&gt; is replaced by &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; to cover the case &lt;span class=&quot;math-container&quot;&gt;$n=1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="741" LastEditorUserId="741" LastEditDate="2019-10-04T00:41:11.330" LastActivityDate="2019-10-04T00:41:11.330" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2714" PostTypeId="2" ParentId="2710" CreationDate="2019-10-02T06:50:15.527" Score="4" Body="&lt;p&gt;From a practical point of view, Job shop scheduling defines as, processing of specific jobs on the machines in some stages which is called route (maybe involve reverse routes), That even may contain more than one machine in each stage (hybrid models).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Resource-constrained project scheduling defines as, allocate tasks to the resources that, in general, don't have a specific route.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the job shop scheduling, the objective is to find an optimum sequence of the jobs on the machine (in each stage) to minimize specific aims (E.g. makespan). but in the RCPS, tasks are usually predefined by users and objective is to minimize the duration of the project. In the job shop models, sequencing of the processes is important while in the RCPS it may be or may not. Job shops (or hybrid) scheduling arise in the manufacturing system as a detailed schedule while RCPS comes from projects planning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, you could find many related issues by googling. If you are interested to develop a practical scheduling model, I recommended the below reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.springer.com/de/book/9781441909091&quot; rel=&quot;nofollow noreferrer&quot;&gt;Planning and Scheduling in Manufacturing and Services&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2019-10-02T09:34:19.640" LastActivityDate="2019-10-02T09:34:19.640" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2715" PostTypeId="2" ParentId="2711" CreationDate="2019-10-02T08:26:07.857" Score="11" Body="&lt;p&gt;You are looking for algorithms to find the integer convex hull of a polytope. Unfortunately, there is no easy way to do it efficiently and I am not sure the 2. point (the functions have integer coefficients) is even possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to do this for studying cutting planes (for small toy problems) using PORTA (&lt;a href=&quot;http://porta.zib.de/&quot; rel=&quot;noreferrer&quot;&gt;http://porta.zib.de/&lt;/a&gt;), which is not under development anymore. But there are more modern software packages listed on the PORTA webpage that might be able to do this more efficiently and with more modern algorithms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remember correctly, one algorithm to do this is the double description method, i.e. an algorithm that converts an extreme point and ray representation of a polyhedron into an matrix (inequalities) representation of a polyhedron. That this is possible goes back to the Minkowski-Weyl theorem. &lt;a href=&quot;ftp://ftp.math.tu-berlin.de/pub/Lehre/LinOpt/WS06/Uebung15.11.06/fukuda96double.pdf&quot; rel=&quot;noreferrer&quot;&gt;Here&lt;/a&gt; you can find a paper about that algorithm, there is probably a lot more out there.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2019-10-02T08:26:07.857" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2716" PostTypeId="2" ParentId="2710" CreationDate="2019-10-02T09:24:41.397" Score="9" Body="&lt;p&gt;There are three main structural differences between the classic job-shop problem and the classic RCPSP:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) In the job-shop problem, resource consumption of tasks and capacities of resources (machines) are unitary, i.e. one machine can process only one task at a time. In the RCPSP, resource consumption of tasks and capacities of resources may not be unitary, so in general two tasks demanding the same resource may be executed in parallel. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) In the job-shop problem, one task (operation) requires only one resource (machine) to be executed. In the RCPSP, one task may require several resources simultaneously to be executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Precedence constraints form chains in the job-shop problem, tasks forming a chain are called operations and the set of tasks forming a chain is called a job. Different operations of the same job require different machines for execution. In the RCPSP, the precedence constraints can form any acyclic graph.&lt;/p&gt;&#xA;" OwnerUserId="835" LastEditorUserId="123" LastEditDate="2019-10-02T17:47:20.417" LastActivityDate="2019-10-02T17:47:20.417" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2717" PostTypeId="1" AcceptedAnswerId="2721" CreationDate="2019-10-02T09:51:21.117" Score="6" ViewCount="247" Body="&lt;p&gt;I want to calculate realization ratio of a value related to a target when lower values are considered better, in one special case the goal is zero.&#xA;To make my problem more clear, there is a complete use case here:&#xA;&lt;a href=&quot;http://jhealthscope.com/en/articles/80342.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://jhealthscope.com/en/articles/80342.html&lt;/a&gt;&#xA;Where author wants to calculate the ratio in table 2:&#xA;&lt;a href=&quot;http://jhealthscope.com/en/articles/80342.html#A80342TBL2&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://jhealthscope.com/en/articles/80342.html#A80342TBL2&lt;/a&gt; &#xA;Author have solved the same question by dividing the target by the performance where lower is better, e.g. &quot;The job complications of personnel&quot; index.&#xA;But I have doubt about this approach and want to find the best approach and a complete answer.&lt;/p&gt;&#xA;" OwnerUserId="2447" LastEditorUserId="2447" LastEditDate="2019-10-03T08:25:54.850" LastActivityDate="2019-10-04T14:27:59.450" Title="Calculating realization ratio of a value related to a target where lower values are more interesting" Tags="|strategic-planning|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2718" PostTypeId="1" CreationDate="2019-10-02T13:58:20.163" Score="17" ViewCount="4773" Body="&lt;p&gt;Is there a tool that reads any linear optimization problem (for example an .lp or .mps file), converts it to the dual problem and prints the dual problem?&lt;/p&gt;&#xA;" OwnerUserId="1008" LastEditorUserId="981" LastEditDate="2019-10-02T17:23:19.140" LastActivityDate="2019-10-10T16:23:53.840" Title="Tool to get dual problem from any linear optimization problem (.lp)" Tags="|linear-programming|duality|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2719" PostTypeId="2" ParentId="2718" CreationDate="2019-10-02T14:15:26.487" Score="6" Body="&lt;p&gt;The &lt;a href=&quot;https://cbom.atozmath.com/CBOM/Simplex.aspx?q=pd&amp;amp;q1=3%605%60MIN%60z%60x1%2Cx2%2Cx3%603%2C-2%2C4%603%2C5%2C4%3B6%2C1%2C3%3B7%2C-2%2C-1%3B1%2C-2%2C5%3B4%2C7%2C-2%60%3E%3D%2C%3E%3D%2C%3C%3D%2C%3E%3D%2C%3E%3D%607%2C4%2C10%2C3%2C2%60%60D%60false%60true%60false%60true%60false%60false%60true&amp;amp;do=1#PrevPart&quot; rel=&quot;noreferrer&quot;&gt;link&lt;/a&gt; includes an online converter from primal to dual linear programs. The downside is you need to input all the coefficients and variables into the pre-defined form on the webpage.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-10-02T14:15:26.487" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2720" PostTypeId="2" ParentId="2708" CreationDate="2019-10-02T20:13:42.853" Score="5" Body="&lt;p&gt;&lt;em&gt;v&lt;/em&gt; represent each of your variables. I assume that your model is called 'model':&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from pyomo.environ import *&#xA;import pandas as pd &#xA;# add the following to your python script&#xA;DF = pd.DataFrame()&#xA;    for v in model.component_objects(Var,active=True):&#xA;        for index in v:&#xA;            DF.at[index, v.name] = value(v[index])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This part of the code directly generates the pandas' data frame for you with columns named according to the name of your variables. I hope it works for you, I tried it in my own model and got the following data frame:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6ja2h.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6ja2h.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-10-02T20:13:42.853" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2721" PostTypeId="2" ParentId="2717" CreationDate="2019-10-02T20:58:35.307" Score="4" Body="&lt;p&gt;If the actual value (&lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;) is never less than the goal (&lt;span class=&quot;math-container&quot;&gt;$g\ge 0$&lt;/span&gt;), you could look at &lt;span class=&quot;math-container&quot;&gt;$100 \frac{a-g}{a}$&lt;/span&gt;. For a goal of 10 and an actual value of 22 (difference of 12), this would evaluate to about 54.55%. For a goal of 0 and an actual value of 12 (the same difference), it would evaluate to 100%. The figure represents how much you would need to improve, as a fraction of the current value, to reach your goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: To avoid having the ratio default to 100% when &lt;span class=&quot;math-container&quot;&gt;$g=0$&lt;/span&gt;, regardless of the value of &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, you can adjust the denominator as follows. Make the deviation ratio &lt;span class=&quot;math-container&quot;&gt;$\frac{a - g}{\max\{a,\epsilon\}}$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt;0$&lt;/span&gt;. If the &lt;span class=&quot;math-container&quot;&gt;$g=0$&lt;/span&gt;, the deviation is 1 (and realization is 0) until &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; gets small enough that &lt;span class=&quot;math-container&quot;&gt;$a&amp;lt;\epsilon$&lt;/span&gt;, at which point deviation is &lt;span class=&quot;math-container&quot;&gt;$\frac{a}{\epsilon}$&lt;/span&gt; and realization is &lt;span class=&quot;math-container&quot;&gt;$\frac{\epsilon - a}{\epsilon}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2019-10-04T14:27:59.450" LastActivityDate="2019-10-04T14:27:59.450" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="2722" PostTypeId="1" AcceptedAnswerId="2723" CreationDate="2019-10-03T06:43:10.017" Score="9" ViewCount="702" Body="&lt;p&gt;Consider a layerwise directed acyclic graph DAG, &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; and two vertices &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is connected to all vertices in &lt;span class=&quot;math-container&quot;&gt;$L_0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$L_0$&lt;/span&gt; is connected to all vertices in &lt;span class=&quot;math-container&quot;&gt;$L_1$&lt;/span&gt; and so forth. Consider all possible paths between &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. In addition there is a set &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; of requirements whose elements are of the form of  tuples &lt;span class=&quot;math-container&quot;&gt;$(a,b)$&lt;/span&gt; interpreted as : if node &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is present in a path, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; must also be present. For example, in the figure if a path contains the red node, the blue node must also be present. Similarly if a path contains the green node, the yellow node must also be present. All tuples &lt;span class=&quot;math-container&quot;&gt;$(a,b)$&lt;/span&gt; are between vertices which have edges directly connecting them, i.e., &lt;span class=&quot;math-container&quot;&gt;$(a,b) \in E$&lt;/span&gt;, hence they must be in successive layers. How to find the shortest path from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; which satisfies all requirements in &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a linear time algorithm that find the shortest paths in a DAG by relaxing all the edges in topological sorted order. However how to consider the requirement set &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nRUnL.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nRUnL.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="123" LastEditDate="2019-10-03T18:20:27.000" LastActivityDate="2019-10-03T18:20:27.000" Title="A variant of the Shortest Path Problem" Tags="|optimization|graphs|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2723" PostTypeId="2" ParentId="2722" CreationDate="2019-10-03T07:24:14.270" Score="14" Body="&lt;p&gt;Wouldn't eliminating all outgoing arcs from the red node except to the blue node, and eliminating all arcs from the green node except to the yellow node, or in general, eliminating all arcs from &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; except those to &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; already do the job?&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-10-03T07:24:14.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2724" PostTypeId="2" ParentId="180" CreationDate="2019-10-03T08:17:19.710" Score="3" Body="&lt;p&gt;A good reference for McCormick envelopes can be found &lt;a href=&quot;https://optimization.mccormick.northwestern.edu/index.php/McCormick_envelopes&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the quality of the relaxation is quite impacted by the bounds &lt;span class=&quot;math-container&quot;&gt;$x_L, x_U$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_L, y_U$&lt;/span&gt; we have on the two variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;: the tighter, the better.&lt;/p&gt;&#xA;" OwnerUserId="2452" LastEditorUserId="123" LastEditDate="2019-10-11T06:47:55.747" LastActivityDate="2019-10-11T06:47:55.747" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2725" PostTypeId="1" CreationDate="2019-10-03T10:11:13.397" Score="12" ViewCount="604" Body="&lt;p&gt;Are you aware of a fast solver (open source or commercial) for convex NLPs that is faster than IPOPT? I'm interested in problems in the 50K+ variable range, both dense and sparse. Ideally, it would be a solver dedicated to solving convex NLPs.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="123" LastEditDate="2019-10-03T18:21:10.817" LastActivityDate="2019-10-05T07:55:52.733" Title="Dedicated solver for convex problems" Tags="|solver|nonlinear-programming|convexity|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2726" PostTypeId="2" ParentId="2725" CreationDate="2019-10-03T10:20:01.330" Score="10" Body="&lt;p&gt;You may want to try out the NLP solver Knitro, which, despite being commercial, is faster than Ipopt: &#xA;&lt;a href=&quot;http://plato.asu.edu/ftp/ampl-nlp.html&quot; rel=&quot;noreferrer&quot;&gt;http://plato.asu.edu/ftp/ampl-nlp.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2452" LastActivityDate="2019-10-03T10:20:01.330" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2727" PostTypeId="2" ParentId="2725" CreationDate="2019-10-03T11:21:36.587" Score="13" Body="&lt;p&gt;Are you formulating your model with nonlinear expressions that just happen to be convex?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or can you provide conic normal forms, maybe using a modeling tool based on &lt;a href=&quot;https://dcp.stanford.edu&quot; rel=&quot;nofollow noreferrer&quot;&gt;displicined convex programming&lt;/a&gt;? In that case, some solvers might be able to exploit that! &lt;a href=&quot;https://www.cvxpy.org/tutorial/dgp/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Disciplined geometric programming&lt;/a&gt; is another way to teach solvers how to exploit convexity in nonlinear situations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.mosek.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MOSEK&lt;/a&gt; is a commercial solver in that field.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/cvxgrp/scs&quot; rel=&quot;nofollow noreferrer&quot;&gt;SCS&lt;/a&gt;, &lt;a href=&quot;https://web.stanford.edu/~boyd/papers/ecos.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;ECOS&lt;/a&gt; and &lt;a href=&quot;https://oxfordcontrol.github.io/COSMO.jl/stable/&quot; rel=&quot;nofollow noreferrer&quot;&gt;COSMO&lt;/a&gt; are some open-source packages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: Added a reference to DCP.&lt;/p&gt;&#xA;" OwnerUserId="126" LastEditorUserId="886" LastEditDate="2019-10-05T07:55:52.733" LastActivityDate="2019-10-05T07:55:52.733" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2728" PostTypeId="1" AcceptedAnswerId="2729" CreationDate="2019-10-03T12:49:15.090" Score="8" ViewCount="2666" Body="&lt;p&gt;I would like to linearize a constraint with max. I have the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{pcj}X_{pwcj}\leqslant L_{wk}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With this constraint, I would like to ensure that for &lt;span class=&quot;math-container&quot;&gt;$\forall w \in W$&lt;/span&gt;, no matter the values of &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, the max value of the decision variable &lt;span class=&quot;math-container&quot;&gt;$X_{pwcj}$&lt;/span&gt; must be less than or equal to the value of the decision variable &lt;span class=&quot;math-container&quot;&gt;$L_{wk}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How can I linearize this function? I've seen some examples, such as &lt;a href=&quot;https://or.stackexchange.com/questions/612/how-to-linearize-a-constraint-with-a-maximum-of-binary-variables-times-some-coef/614&quot;&gt;How to linearize a constraint with a maximum of binary variables times some coefficient in the right-hand-side&lt;/a&gt;. However, their decision variable has only one index. In my case, I have 4 indexes and &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; must be fixed at each time.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Actually, I would like to check for each set of &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; occurrences in a sequence given by &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$H_w=\max \{X_{pwcj}, X_{pwcj+1},\ldots, X_{pwcn}\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I was wondering what the best way to write my constraint could be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$H_{w}\leqslant L_{wk}$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the max number of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; positions, but I am not sure.&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;If I use this notation, I think that I could do something like this: &lt;a href=&quot;https://or.stackexchange.com/questions/711/how-to-formulate-maximum-function-in-a-constraint&quot;&gt;How to formulate (linearize) a maximum function in a constraint?&lt;/a&gt; proposed by @LarrySnyder610, however, in my case I have a set of the same variables thus I am not sure that I can do this.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;If this notation can be used in my case, could I ignore the big M value, since both of my variables are binary?&lt;/p&gt;&#xA;&lt;p&gt;Could someone help me with these questions?&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="491" LastEditDate="2021-03-03T18:43:58.390" LastActivityDate="2021-03-03T18:43:58.390" Title="How to linearize a constraint with max" Tags="|optimization|constraint|linearization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2729" PostTypeId="2" ParentId="2728" CreationDate="2019-10-03T13:09:14.113" Score="10" Body="&lt;p&gt;Welcome to OR.SE! If you're looking to enforce &lt;span class=&quot;math-container&quot;&gt;$$\max\limits_{pcj}X_{pwcj} \leq L_{wk}, \  \forall w,k$$&lt;/span&gt; then simply using the constraint &lt;span class=&quot;math-container&quot;&gt;$$X_{pwcj} \leq L_{wk}, \ \forall p,w,c,j,k$$&lt;/span&gt; will do the trick. This will ensure every value (including the maximum) will be at most &lt;span class=&quot;math-container&quot;&gt;$L_{wk}$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If there's another dynamic you're looking to enforce, e.g., within a set of occurrences, could you clarify/add some more detail to your question?)&lt;/p&gt;&#xA;" OwnerUserId="56" LastEditorUserId="56" LastEditDate="2019-10-04T16:03:19.043" LastActivityDate="2019-10-04T16:03:19.043" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2730" PostTypeId="1" CreationDate="2019-10-03T16:49:48.830" Score="11" ViewCount="413" Body="&lt;p&gt;Are there any theoretical results on the performance of branch-and-bound, even for a subset of instances of a particular discrete optimization problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, does there exist a result of the form &quot;When instances of problem &lt;span class=&quot;math-container&quot;&gt;$\Pi$&lt;/span&gt; satisfy properties &lt;span class=&quot;math-container&quot;&gt;$P_1, P_2,...$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$R_1, R_2, ...$&lt;/span&gt;, branch-and-bound finds an &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;-approximation to the global optimum (maybe even w.h.p. or in expectation with respect to randomness in the instance) in a polynomial number of nodes&quot;?&lt;/p&gt;&#xA;" OwnerUserId="606" LastEditorUserId="38" LastEditDate="2019-10-04T00:18:10.767" LastActivityDate="2022-04-07T16:37:04.583" Title="Theoretical results on performance of branch-and-bound" Tags="|mixed-integer-programming|reference-request|integer-programming|error-bounds|branch-and-bound|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2731" PostTypeId="1" CreationDate="2019-10-03T16:59:04.367" Score="8" ViewCount="642" Body="&lt;p&gt;&lt;strong&gt;Algebraic Formulation&lt;/strong&gt; - Note: All parameter values are subject to change, I have just used the numbers you see here as place holders for the time being. Additionally, there are a few other equations but I am highly confident that they are not causing the infeasibility problems that I am having.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min\quad&amp;amp;\sum_{i=1}^I\sum_{j=1}^J\sum_{t=1}^T(2+5 L_{t}^{ij}) I_{t,post}^{ij}\\\text{s.t.}\quad&amp;amp;I_{t,post}^{ij} = \frac{I_{t-1,treated}^2} {I_{t-1,treated}^2 + a^2} S_{t-1}^{ij}\\\quad&amp;amp;I_{t,treated} = (1 - 0.5L_{t}^{ij})I_{t,post}^{ij}\\\quad&amp;amp;S_{t}^{ij} = S_{t}^{ij} + sj_{t-1,k=2}^{ij} - I_{t-1,treated}\\\quad&amp;amp;\sum_{t=1}^T\sum_{i=1}^I\sum_{j=1}^J2L_{t}^{ij} \le B \\\quad&amp;amp;0 \le I_{t,post}^{ij},I_{t,treated}^{ij},S_{t}^{ij} \\ \quad&amp;amp;0 \le I_{0,treated}^{ij} \,\ S_{0}^{ij} \,\ j_{0,k=2}^{ij}\\\quad&amp;amp;L_{t}^{ij}=\,\text{ binary decision variable}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running a MINLP model of invasive species control and I would ideally want all of my variables (except the binary variable &lt;code&gt;L&lt;/code&gt;) to be in the NonNegativeReals domain, however, when I set this specification on any of the variables it forces some of my constraints to become infeasible. I can run the model with all variables in the Real domain and everything works out okay but it provides me with negative numbers which is not realistic in regards to the problems physical interpretation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the case where all variables are set to real and we look at the first few solutions for &lt;code&gt;Constraint 4: Susceptible Recruitment&lt;/code&gt; under Output 1, we can see that at &lt;code&gt;(1,1,3)&lt;/code&gt; that the variable begins taking negative values, and the culprit in the constraint is &lt;code&gt;model.inf_treated[i,j,t-1]&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;# Constraint 4: Susceptible recruitment&#xA;def susceptible_advance_rule(model, i, j, t):&#xA;    if t == 0:&#xA;        return Constraint.Skip&#xA;    else:&#xA;        return model.susceptible[i, j, t ] == model.susceptible[i, j, t-1] + model.juvsurv * model.juvenille[i, j, t-1, Kmax] - model.inf_treated[i,j,t-1]&#xA;model.susceptible_advancement = Constraint(model.Iset, model.Jset, model.Tset, rule=susceptible_advance_rule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Output 1: model.susceptible in the 'Reals' domain&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;susceptible : Size=20, Index=susceptible_index&#xA;        Key       : Lower : Value               : Upper : Fixed : Stale : Domain&#xA;        (1, 1, 0) :  None :                50.0 :  None :  True :  True :  Reals&#xA;        (1, 1, 1) :  None :                53.2 :  None : False : False :  Reals&#xA;        (1, 1, 2) :  None :   19.28555555556563 :  None : False : False :  Reals&#xA;        (1, 1, 3) :  None :  -32.15963392758387 :  None : False : False :  Reals&#xA;        (1, 1, 4) :  None :  -50.31374332256311 :  None : False : False :  Reals&#xA;        (1, 2, 0) :  None :                30.0 :  None :  True :  True :  Reals&#xA;        (1, 2, 1) :  None :  30.700000000000003 :  None : False : False :  Reals&#xA;        (1, 2, 2) :  None :  14.750000000000497 :  None : False : False :  Reals&#xA;        (1, 2, 3) :  None : -15.149263681592133 :  None : False : False :  Reals&#xA;        (1, 2, 4) :  None : -29.438417445000606 :  None : False : False :  Reals&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the case, I would want to try and restrict the domain of &lt;code&gt;model.susceptible&lt;/code&gt; to the NonNegativeReals and upon doing so I would expect that all of my model variables become greater than 0, but I get infeasibility in my constraints as a result, and my binary variables become non-binary as a symptom. The same infeasibility comes about if I then turn every one of my variables to exist in the domain of the NonNegativeReals, but I think the infeasibility comes from the conflict that arises from &lt;code&gt;Constraint 4&lt;/code&gt; when I restrict &lt;code&gt;model.susceptible&lt;/code&gt; to be positive, but then I subtract away &lt;code&gt;model.inf_treated&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Output 2: model.susceptible in the 'NonNegativeReals' domain&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt; susceptible : Size=20, Index=susceptible_index&#xA;        Key       : Lower : Value                  : Upper : Fixed : Stale : Domain&#xA;        (1, 1, 0) :     0 :                   50.0 :  None :  True :  True : NonNegativeReals&#xA;        (1, 1, 1) :     0 :                   53.2 :  None : False : False : NonNegativeReals&#xA;        (1, 1, 2) :     0 :     63.222379594592645 :  None : False : False : NonNegativeReals&#xA;        (1, 1, 3) :     0 :      58.85143663732718 :  None : False : False : NonNegativeReals&#xA;        (1, 1, 4) :     0 : 1.4845965610247883e-08 :  None : False : False : NonNegativeReals&#xA;        (1, 2, 0) :     0 :                   30.0 :  None :  True :  True : NonNegativeReals&#xA;        (1, 2, 1) :     0 :     30.700000000000003 :  None : False : False : NonNegativeReals&#xA;        (1, 2, 2) :     0 :     14.750000001550784 :  None : False : False : NonNegativeReals&#xA;        (1, 2, 3) :     0 :      6.753462538302196 :  None : False : False : NonNegativeReals&#xA;        (1, 2, 4) :     0 :  3.620342424247316e-10 :  None : False : False : NonNegativeReals&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Infeasible Constraints When Variable Boundaries Appied&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;#Constraint 9: Treated Infestation&#xA;def treatment_rule(model, i, j, t):&#xA;    if t == 0:&#xA;        return Constraint.Skip&#xA;    else:&#xA;        return model.inf_treated[i, j, t] == model.inf_b4treat[i, j, t] * (1 - 0.5*model.level1[i, j, t] )&#xA;model.treated_population = Constraint(model.Iset, model.Jset, model.Tset, rule=treatment_rule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;INFO: CONSTR treated_population[1,1,1]: -21.71460181746589 != 0.0&#xA;INFO: CONSTR treated_population[1,2,2]: -6.629094367820306 != 0.0&#xA;INFO: CONSTR treated_population[2,1,2]: -7.140628683877534 != 0.0&#xA;INFO: CONSTR treated_population[2,2,1]: -15.008019076531863 != 0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Output From Solver With NonNegativeReals boundaries applied + Code 413 Description from Knitro&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;Problem: &#xA;- Lower bound: -inf&#xA;  Upper bound: inf&#xA;  Number of objectives: 1&#xA;  Number of constraints: 180&#xA;  Number of variables: 164&#xA;  Sense: unknown&#xA;Solver: &#xA;- Status: warning&#xA;  Message: Knitro 11.1.0\x3a MIP\x3a All nodes have been explored. No integer feasible point found.; objective 1398.5939509578325; integrality gap 1.8e+308; 3 nodes; 104 subproblem solves&#xA;  Termination condition: maxIterations&#xA;  Id: 413&#xA;Solution: &#xA;- number of solutions: 0&#xA;  number of solutions displayed: 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Code 413 Description: All nodes have been explored. No integer feasible point was found. The MIP optimality gap has not been reduced below the specified threshold, but there are no more nodes to explore in the branch and bound tree. If the problem is convex, this could occur if the gap tolerance is difficult to meet because of bad scaling or roundoff errors, or there was a failure at one or more of the subproblem nodes. This might also occur if the problem is nonconvex.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In theory, none of my variables should be negative when the model gets solutions. However, the question becomes the following: Why are the constraints becoming infeasible when I specify that all of my variables exist in the NonNegativeReals but are feasible when all domains are Real? Perhaps it has to do with the initial input values? Alternatively, perhaps there is a way that I can tell the model that if the &lt;code&gt;model.susceptible&lt;/code&gt; variable goes negative, that instead it will just floor it to zero instead. &lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="8" LastEditDate="2019-10-13T17:11:12.287" LastActivityDate="2019-10-13T17:11:12.287" Title="Understanding why this MINLP formulation is infeasible" Tags="|pyomo|minlp|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="2732" PostTypeId="2" ParentId="2728" CreationDate="2019-10-03T17:11:46.113" Score="-1" Body="&lt;p&gt;There are some nice topics on linearization of MAX/MIN/ABS functions in LPs/MIPs. Would you see the following links by @prubin and C. Coelho? I hope, they will be useful.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://orinanobworld.blogspot.com/2011/01/max-and-min-functions-in-mip.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Max and Min Functions in a MIP&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://orinanobworld.blogspot.com/2012/01/maxmin-bounds.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Max/Min Bounds&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.leandro-coelho.com/how-to-linearize-max-min-and-abs-functions/&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to linearize max, min, and abs functions&lt;/a&gt; &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-10-03T17:11:46.113" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2733" PostTypeId="2" ParentId="2730" CreationDate="2019-10-03T19:45:51.283" Score="4" Body="&lt;p&gt;I refer you to &lt;a href=&quot;https://or.stackexchange.com/q/1122/39&quot;&gt;this question&lt;/a&gt; in which I mentioned some of the related papers investigated the performance of the Branch-and-Bound method by estimating the size of the BB tree. The old paper&lt;sup&gt;1&lt;/sup&gt; by Lai et al. investigated the performance of the parallel BB in which several nodes with least lower bounds are expanded simultaneously. In addition Lobjois et al. in their paper&lt;sup&gt;2&lt;/sup&gt;, tried to estimate, for each particular problem instance, the most appropriate Branch-and-Bound algorithm from among several promising ones. May be these papers can be a good start point for your investigation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1): Lai, Ten-Hwang, and Alan Sprague. &quot;Performance of parallel branch-and-bound algorithms.&quot; IEEE Transactions on Computers 100.10 (1985): 962-964.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2): Lobjois, Lionel, and Michel Lemaître. &quot;Branch and bound algorithm selection by performance prediction.&quot; AAAI/IAAI. 1998.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-10-03T19:45:51.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2734" PostTypeId="1" CreationDate="2019-10-04T01:46:40.447" Score="9" ViewCount="282" Body="&lt;p&gt;I am trying to formulate a problem that will spit out an optimal schedule for my tasks to be completed. To keep the information confidential, I will refer to my tasks as papers that need to be written. Here is the premise of my problem.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There are &lt;strong&gt;320 papers&lt;/strong&gt; to be written. (All writers can write these papers and &lt;strong&gt;can all work at the same time&lt;/strong&gt;). Each paper takes a different amount of time to complete.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We have &lt;strong&gt;2 types&lt;/strong&gt; of workers available to complete this set of papers. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We have &lt;strong&gt;150 writers&lt;/strong&gt;, whose responsibility it is to actually write the paper.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We have &lt;strong&gt;25 movers&lt;/strong&gt;, whose responsibility it is to take the completed papers and go and grab a new paper for the writers to work on. For the sake of simplicity, I am assuming that the time to take a completed paper and deliver a new one is constant for each move.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The goal of this problem will be to minimize the total length of time it takes to write all of these papers with my staff. We are restricted by the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How many writers we have to write papers at the same time&lt;/li&gt;&#xA;&lt;li&gt;How many movers are available to move papers at the same time&lt;/li&gt;&#xA;&lt;li&gt;Each mover takes 25 minutes to move a paper for the writer&lt;/li&gt;&#xA;&lt;li&gt;Movers cannot move papers for writers that are within 2 writers of each other at the same time (If writer 3 has completed his paper and a mover begins moving a paper for them, then writers 1,2,4, and 5 will have to wait until the mover for writer 3 has finished their move). This constraint is meant to represent a physical limitation we have at our facility.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My Approach:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has been some time since I've properly done LP so I am rusty(I'm also still a student so my skills were never good to begin with). I have defined the following variables but am not sure if these are good or not. &lt;strong&gt;I don't know whether to consider time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; as a parameter for these variables or as its own variable and this is what I'm mainly struggling with.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_p$&lt;/span&gt;: The length of time for paper &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; to be completed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_{p,w}$&lt;/span&gt;: The point in time when writer &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; begins writing paper &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{p,w}$&lt;/span&gt;: Binary variable representing whether or not a paper &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is being written by writer &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;s&gt; &lt;span class=&quot;math-container&quot;&gt;$M_{m,w}$&lt;/span&gt;: Whether or not mover &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; moves a paper for writer &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; &lt;/s&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Constraints that I have come up with are as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{w \in W} X_{p,w} = 1$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_{p,w} \ge 0$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am struggling with how to wrap my head around how to factor in a timeline as either a variable or some set or whatever. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I've spent some more time and discovered that this is a common difficulty with this type of problem(yay!). The two routes to be taken are to consider time as either a discrete or a continuous variable. Though the precision would be nice, the data I have at the facility is available per minute so I think treating time as a discrete variable with &lt;em&gt;one-minute&lt;/em&gt; intervals is reasonable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to be able to get an output that gives me an optimal schedule for the papers to be written and for the output to tell me which papers are being completed by which writers at what time. I will be as active as I can in the comments if there needs any clarification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I have also posted this question on SO&#xA;link: &lt;a href=&quot;https://stackoverflow.com/questions/58223716/how-to-formulate-scheduling-matrix-problem-with-mixed-integer-linear-programming&quot;&gt;https://stackoverflow.com/questions/58223716/how-to-formulate-scheduling-matrix-problem-with-mixed-integer-linear-programming&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also posted this on Math.SE &#xA;link: &lt;a href=&quot;https://math.stackexchange.com/questions/3384542/should-i-factor-in-time-as-a-parameter-or-a-variable-in-a-scheduling-problem-wit&quot;&gt;https://math.stackexchange.com/questions/3384542/should-i-factor-in-time-as-a-parameter-or-a-variable-in-a-scheduling-problem-wit&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2460" LastEditorUserId="2460" LastEditDate="2019-10-08T19:12:59.837" LastActivityDate="2019-10-08T22:13:58.990" Title="Should I factor in time as a parameter or a variable in a scheduling problem with MILP?" Tags="|optimization|mixed-integer-programming|linear-programming|integer-programming|binary-variable|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2735" PostTypeId="1" AcceptedAnswerId="2736" CreationDate="2019-10-04T07:16:33.137" Score="18" ViewCount="1430" Body="&lt;p&gt;Suppose you have a combinatorial optimization problem that is formulated as a mixed integer linear program (minimization). The problem size is denoted &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and the expected &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is around &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt;. The integer program has &lt;span class=&quot;math-container&quot;&gt;$O(n^5)$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$O(n^2)$&lt;/span&gt; constraints and its LP relaxation bound is very good. We also have a very good feasible solution that is at most &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;-&lt;span class=&quot;math-container&quot;&gt;$5\%$&lt;/span&gt; far from optimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is that there are so many variables and it takes so much run-time even for the LP-relaxation. I was wondering how we could fix some of the decision variables given the feasible solution. We do not have the lower bound at the beginning so it cannot be used. I know that MIP solvers have their own preprocessing, but this can happen only after the LP is loaded to the memory which is an issue by itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do you suggest? Are you aware of any reference or paper in which the knowledge of having a good upper bound is used to fix the decision variables of an optimization problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think my question is essentially reduced to the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For a combinatorial optimization problem, how can we obtain a non-trivial lower bound on the optimal objective value given a good feasible solution!?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2019-10-06T10:45:18.077" Title="Variable fixing based on a good feasible solution" Tags="|integer-programming|combinatorial-optimization|presolve-preprocessing|bounds|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2736" PostTypeId="2" ParentId="2735" CreationDate="2019-10-04T09:27:13.490" Score="15" Body="&lt;p&gt;As far as I know, it is not possible to fix any variables solely based on a feasible solution without compromising the exactness of your solution method. However, variable fixing is possible when you have both an upper bound and a lower bound on the optimal objective value, using a method called &lt;em&gt;reduced cost fixing&lt;/em&gt; (see e.g. &lt;a href=&quot;https://atamturk.ieor.berkeley.edu/pubs/_published/jh1-1996.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Atamtürk, Nemhauser &amp;amp; Savelsbergh (1996)&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, consider the problem &lt;span class=&quot;math-container&quot;&gt;$\min \left\{cx: Ax\leq b, x\in \{0,1\}^n\right\}$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$LB$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$UB$&lt;/span&gt; denote a known lower and upper bound, respectively. Let &lt;span class=&quot;math-container&quot;&gt;$\bar{c_j}$&lt;/span&gt; denote the reduced cost of variable &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; in the optimal solution of the linear relaxation. Then, if &lt;span class=&quot;math-container&quot;&gt;$LB+c_j\geq UB$&lt;/span&gt;, there exists an optimal solution where &lt;span class=&quot;math-container&quot;&gt;$x_j=0$&lt;/span&gt;, so this variable can be fixed to 0. It is possible to generalize this method to integer variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your problem, perhaps it would be worthwhile to investigate whether you can solve the linear relaxation using column generation, where negative reduced costs variables (columns) are added on the fly. This avoids having to add all &lt;span class=&quot;math-container&quot;&gt;$O(n^5)$&lt;/span&gt; variables to the model. Once you have solved the linear relaxation, you could fix all variables using your good feasible solution using the method I explained above, and solve the remaining problem as a mixed-integer programming problem. &lt;/p&gt;&#xA;" OwnerUserId="764" LastEditorUserId="764" LastEditDate="2019-10-06T10:45:18.077" LastActivityDate="2019-10-06T10:45:18.077" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2737" PostTypeId="2" ParentId="2735" CreationDate="2019-10-04T11:43:55.420" Score="3" Body="&lt;p&gt;You could try loading the problem through AMPL. AMPL is blazing fast so size won't be an issue, and it has its own presolve, which is very good. I've seen it reduce problems from 100Kx100K to 5Kx5K. The way you would use this would be to use AMPL to produce an .nl file which is a dense format to describe the presolved model. You can then load that .nl file very quickly to any solver that supports ASL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have/don't want to use AMPL, you could try (i) coding some size reduction algorithms yourself to reduce the size of your model, or (ii) getting a cheap lower bound by running a constraint propagation algorithm on your MILP. The latter is the most promising, just be aware that constraint propagation algorithms are notoriously hard to code correctly (numerics-wise).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-10-04T11:43:55.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2738" PostTypeId="2" ParentId="2735" CreationDate="2019-10-04T13:37:31.310" Score="15" Body="&lt;p&gt;A similar idea as suggested by @ RolfvanLieshout uses Lagrangian duals instead of LP duals, in a Lagrangian-based branch-and-bound scheme. For example, in the uncapacitated fixed-charge location problem (UFLP), the most common Lagrangian approach relaxes the assignment constraints (&lt;span class=&quot;math-container&quot;&gt;$\sum_j y_{ij} = 1 \ \forall i$&lt;/span&gt;), uses the Lagrangian subproblem to calculate a &quot;benefit&quot; &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt; for each facility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and then opens facility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$\beta_j + f_j &amp;lt; 0$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$f_j$&lt;/span&gt; is the fixed cost).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if we have a lower bound &lt;span class=&quot;math-container&quot;&gt;$z_{LR}(\lambda)$&lt;/span&gt; for a particular vector &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; of Lagrange multipliers, and we have an upper bound &lt;span class=&quot;math-container&quot;&gt;$\text{UB}$&lt;/span&gt; from a feasible solution, then we can say:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_j=0$&lt;/span&gt; in the optimal solution to the subproblem under &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_{LR}(\lambda) + \beta_j + f_j &amp;gt; \text{UB},$$&lt;/span&gt;&#xA;then &lt;span class=&quot;math-container&quot;&gt;$x_j=0$&lt;/span&gt; in every optimal solution to the UFLP.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_j=1$&lt;/span&gt; in the optimal solution to the subproblem under &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_{LR}(\lambda) - (\beta_j+f_j) &amp;gt; \text{UB},$$&lt;/span&gt;&#xA;then &lt;span class=&quot;math-container&quot;&gt;$x_j=1$&lt;/span&gt; in every optimal solution to the UFLP.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The basic idea is that we are &quot;peeking&quot; down the branch-and-bound tree from the root node. If &lt;span class=&quot;math-container&quot;&gt;$x_j=0$&lt;/span&gt; and we branch on &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt;, then when we set &lt;span class=&quot;math-container&quot;&gt;$x_j=1$&lt;/span&gt; in the child node, the new lower bound will be &lt;span class=&quot;math-container&quot;&gt;$z_{LR}(\lambda) + \beta_j + f_j$&lt;/span&gt;. If this is &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;\text{UB}$&lt;/span&gt;, then we'd fathom that node, so we can just fix &lt;span class=&quot;math-container&quot;&gt;$x_j=0$&lt;/span&gt;. A similar argument applies for the second case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This idea is used by &lt;a href=&quot;https://doi.org/10.1023/A:1020763400324&quot; rel=&quot;noreferrer&quot;&gt;Daskin, et al. (2002)&lt;/a&gt; for a location–inventory model. We also discuss the idea (in the context of UFLP) in &lt;a href=&quot;https://www.wiley.com/en-us/Fundamentals+of+Supply+Chain+Theory%2C+2nd+Edition-p-9781119024842&quot; rel=&quot;noreferrer&quot;&gt;our textbook&lt;/a&gt;, 2nd edition, Section 8.2.3.7.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2019-10-05T15:29:19.977" LastActivityDate="2019-10-05T15:29:19.977" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2739" PostTypeId="1" AcceptedAnswerId="2748" CreationDate="2019-10-04T14:39:35.507" Score="14" ViewCount="262" Body="&lt;p&gt;I am trying to solve robust optimisation problems, but I am getting nonsensical solutions most of the time… Here is a very simplified example: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{2}\max&amp;amp;\quad x+z&amp;amp;\\\text{s.t.}&amp;amp;\quad\alpha x + \beta z&amp;amp; \leq 2&amp;amp;, \quad\forall (\alpha, \beta) \in \mathcal{U}\\&amp;amp;\quad x, z&amp;amp;\,\,\geq 0&amp;amp;\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my uncertainty set &lt;span class=&quot;math-container&quot;&gt;$\mathcal U$&lt;/span&gt;: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\gamma+\alpha\leq4,\quad \delta+\beta\leq4\gamma,\quad \gamma+\delta\leq2,\qquad \alpha,\beta,\gamma,\delta\geq0$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following &lt;a href=&quot;https://arxiv.org/pdf/1501.02634.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;A Practical Guide to Robust Optimization&lt;/a&gt; and &lt;a href=&quot;https://www.robustopt.com/references/Price%20of%20Robustness.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Price of Robustness&lt;/a&gt;, I reformulate the problem as such, sequentially: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\alpha x + \beta z \leq 2,\quad\forall (\alpha, \beta) \in \mathcal{U}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max_{(\alpha, \beta) \in \mathcal{U}} \alpha x + \beta z &amp;amp;\leq 2\\\min_{(u, v, w) \in \mathcal{U}^*} 4u+2w &amp;amp;\leq 2\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{2}\max&amp;amp;\quad x+z&amp;amp;\\\text{s.t.}&amp;amp;\quad4u+2w&amp;amp;\leq 2\\&amp;amp;\quad u&amp;amp;\leq z\\&amp;amp;\quad v&amp;amp;\leq x\\&amp;amp;\quad u+w-4v&amp;amp;\leq0\\&amp;amp;\quad v+w&amp;amp;\leq0\\&amp;amp;\quad u, v, w, x, z&amp;amp;\,\,\geq 0\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this reformulation is unbounded. Nevertheless, you can compute an upper bound to the original formulation: &lt;span class=&quot;math-container&quot;&gt;$\alpha=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta=2$&lt;/span&gt; is in &lt;span class=&quot;math-container&quot;&gt;$\mathcal U$&lt;/span&gt;, and using only this point from the uncertainty set, the objective function is &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{2}\max&amp;amp;\quad x+z&amp;amp;\\\text{s.t.}&amp;amp;\quad x + 2 z &amp;amp;\leq 2\\&amp;amp;\quad x, z&amp;amp;\,\,\geq 0\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="156" LastEditorUserId="123" LastEditDate="2019-10-14T12:29:50.447" LastActivityDate="2019-10-14T12:29:50.447" Title="Robust counterpart: why is dual reformulation not working?" Tags="|duality|robust-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2740" PostTypeId="2" ParentId="2730" CreationDate="2019-10-05T00:42:00.997" Score="1" Body="&lt;p&gt;Unfortunately the answer is that we can't know a priori how many nodes we'll have to explore, at least as far as we know today. Because the problem is NP-Hard (assuming we resort to BnB because we have to), determining how many nodes we will explore is as hard as solving the problem itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is unlikely to change in the future because it's intrinsically linked to the NP-hardness of branch-and-bound. BnB is np-hard because at the worst case scenario we'll have to explore all nodes. In continuous bnb, that literally means infinity (integer BnB is somewhat better). People have come up with heuristic estimates but nothing (to my knowledge) that is useful in practice. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At a solver level, this is impossible to predict because of the numerous heuristics in place that accelerate BnB to closer-to-linear runtime complexity. Sometimes these things work amazingly well, and we tune our solvers so that is generally the case, but it can never be true in general for an NP-Hard problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to caution you when interpreting results in this domain - while it is true that we can derive correlations (and people have tried) between runtime behaviour and problem formulation by solving a large number of problems, correlation does not imply causation, which is something many people attempt to do. Such results can be statistically true for the specific problem set studied, but have no transferability (pretty much like all of machine learning).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-10-05T00:42:00.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2741" PostTypeId="1" CreationDate="2019-10-05T01:47:03.910" Score="19" ViewCount="1474" Body="&lt;p&gt;My graduate Linear Programming class uses Bertsimas &amp;amp; Tsitsiklis's &lt;a href=&quot;http://www.athenasc.com/linoptbook.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Introduction to Linear Optimization&lt;/a&gt;. Are there any alternative texts that I could use to supplement this textbook (mainly the content of Chapter 2 of Bertsimas &amp;amp; Tsitsiklis: extreme point, vertex, basic feasible solution, contains/does not a line, Fourier-Motzkin) at the same level rigor and which contain exercises that I could practice on?&lt;/p&gt;&#xA;&lt;p&gt;Ideally, I would also like a book with a decent (the more the better) number of pictures that gives geometric intuition behind proofs.&lt;/p&gt;&#xA;" OwnerUserId="2467" LastEditorUserId="491" LastEditDate="2020-10-22T02:11:09.820" LastActivityDate="2020-10-22T02:11:09.820" Title="PhD-level textbooks on linear programming" Tags="|optimization|linear-programming|reference-request|linear-algebra|phd|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2742" PostTypeId="2" ParentId="2741" CreationDate="2019-10-05T01:59:21.663" Score="7" Body="&lt;p&gt;There are some good problems in &lt;em&gt;Linear Optimization: Theory and Extensions&lt;/em&gt; by Fang and Puthenputra. Chapter 2 of the book (&quot;Geometry of Linear Programming&quot;) is most comparable to Chapter 2 of Bertsimas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see this related question on Math.SE: &lt;a href=&quot;https://math.stackexchange.com/q/20643/669798&quot;&gt;https://math.stackexchange.com/q/20643/669798&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="196" LastActivityDate="2019-10-05T01:59:21.663" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2743" PostTypeId="2" ParentId="2730" CreationDate="2019-10-05T05:56:10.167" Score="5" Body="&lt;p&gt;If the problem you are solving is in &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;, I guess you can construct a branch-and-bound algorithm that only produces a polynomial number of nodes, since you can use your polynomial time algorithm to make a perfect prediction which branch to explore first, and produce perfect bounds that allow you to prune away every node in the tree except the ones that lead to the optimal solution. But in practice, you would not even bother with branch-and-bound in those cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there are papers on a technique called &lt;a href=&quot;https://doi.org/10.1145/1552285.1552286&quot; rel=&quot;noreferrer&quot;&gt;measure and conquer&lt;/a&gt;, which is used to obtain tighter bounds on the number of nodes in a branch-and-bound tree of &lt;span class=&quot;math-container&quot;&gt;$NP$&lt;/span&gt;-complete problem than the trivial &lt;span class=&quot;math-container&quot;&gt;$b^n$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is the number of branching decisions you can make at each step an &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the depth of the tree. Typically, these papers obtain results of the kind: problem X can be solved in &lt;span class=&quot;math-container&quot;&gt;$O^*(c^n)$&lt;/span&gt; where typically &lt;span class=&quot;math-container&quot;&gt;$1&amp;lt;c\leq b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$O^*$&lt;/span&gt; is similar to the common &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; but also ignores polynomial factors. Some proofs may show that &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is a lower number if the instance has certain properties (e.g. bounded degree).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, there are sophisticated branching algorithms that have been analyzed with other techniques. For the Maximum Independent Set problem, &lt;a href=&quot;https://en.wikipedia.org/wiki/Independent_set_(graph_theory)#Exact_algorithms&quot; rel=&quot;noreferrer&quot;&gt;Wikipedia&lt;/a&gt; currently lists a &lt;a href=&quot;https://doi.org/10.1016%2Fj.tcs.2012.09.022&quot; rel=&quot;noreferrer&quot;&gt;reference&lt;/a&gt; that can solve this problem in &lt;span class=&quot;math-container&quot;&gt;$O(1.1996^n)$&lt;/span&gt; time for general graphs and &lt;span class=&quot;math-container&quot;&gt;$O(1.0836^n)$&lt;/span&gt; time if a graph has maximum degree three.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think branch and bound can reduce to a polynomial tree for &lt;span class=&quot;math-container&quot;&gt;$NP$&lt;/span&gt;-hard problems (if you don't use a super-polynomial algorithm to obtain bounds). Since branch and bound is ultimately a clever enumeration technique, I don't think it is often useful when a problem's structure is so well understood that you can solve it in polynomial time. In those cases you typically employ a greedy, dynamic programming or divide and conquer approach. I am also not aware of any approximation results, although they might exist as I am not that familiar with everything that is happening in the analysis of exponential time and/or approximation algorithms. &lt;/p&gt;&#xA;" OwnerUserId="1047" LastEditorUserId="1047" LastEditDate="2019-10-05T06:08:04.933" LastActivityDate="2019-10-05T06:08:04.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2744" PostTypeId="1" AcceptedAnswerId="2747" CreationDate="2019-10-05T11:44:52.437" Score="9" ViewCount="3166" Body="&lt;p&gt;I would like to know is it possible to read an LP/MPS file into the Pyomo software and solve the problem? If so, how can I do that?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-10-06T07:46:36.960" Title="Reading an LP/MPS file using Pyomo software" Tags="|optimization|python|pyomo|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2745" PostTypeId="2" ParentId="2741" CreationDate="2019-10-05T16:17:09.317" Score="12" Body="&lt;p&gt;A classic textbook that does a really good job of building from the fundamentals is &lt;a href=&quot;https://www.wiley.com/en-us/Theory+of+Linear+and+Integer+Programming-p-9780471982326&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;Theory of Linear and Integer Programming&lt;/em&gt; by Schrijver&lt;/a&gt;. Chapter 7 in particular gives great intuition on linear programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These &lt;a href=&quot;http://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15859-f11/www/&quot; rel=&quot;noreferrer&quot;&gt;lecture notes by Ryan O'Donnell and Anupam Gupta&lt;/a&gt; are also a good, quicker reference as well as the textbook they refer to, &lt;a href=&quot;https://www.springer.com/gp/book/9783540306979&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;Understanding and Using Linear Programming&lt;/em&gt; by Matoušek and Gärtner&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="606" LastActivityDate="2019-10-05T16:17:09.317" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2747" PostTypeId="2" ParentId="2744" CreationDate="2019-10-05T20:28:13.180" Score="10" Body="&lt;p&gt;According to &lt;a href=&quot;https://groups.google.com/d/msg/pyomo-forum/5O8RbQhl518/m6nc85KkAwAJ&quot; rel=&quot;noreferrer&quot;&gt;this link&lt;/a&gt; on Pyomo forum from 2016 about LP files, and &lt;a href=&quot;https://groups.google.com/d/msg/pyomo-forum/BkSxxZN-228/8PZv1H0wCQAJ&quot; rel=&quot;noreferrer&quot;&gt;this one&lt;/a&gt; from 2018 about MPS file, this functionality doesn't exist yet. To quote from the first link:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;LP files are “flat” representations of a model, and there really hasn’t been a strong motivation to import that into a structured system like Pyomo.  It’s not impossible to write an LP file reader, but none exist (nor are any under development).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-10-05T20:28:13.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2748" PostTypeId="2" ParentId="2739" CreationDate="2019-10-06T02:33:27.260" Score="12" Body="&lt;p&gt;I think there are two small mistakes in your formulation:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;In the final formulation, the roles of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; should be reversed.&lt;/li&gt;&#xA;&lt;li&gt;Except for the first constraint and for the non-negativity of the variables, all signs should be reversed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The mistake probably occured when using duality to rewrite the expression &lt;span class=&quot;math-container&quot;&gt;$\max\limits_{(\alpha, \beta, \gamma, \delta) \in \mathcal{U}} x\alpha + z\beta$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above expression is a linear program, and can be written as follows (nothing special going on yet):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad c^\top \zeta\\\text{s.t.}&amp;amp;\quad A\zeta \le b\\&amp;amp;\quad\zeta \ge 0\end{align}&lt;/span&gt;&#xA;in which &lt;span class=&quot;math-container&quot;&gt;$\zeta = (\alpha, \beta, \gamma, \delta)^\top$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c=(x,z,0,0)^\top$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;A = \begin{bmatrix}1 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0\\ 0 &amp;amp; 1 &amp;amp; -4 &amp;amp; 1 \\ 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 1\\\end{bmatrix},&#xA;\end{equation}&lt;/span&gt;&#xA;and &lt;span class=&quot;math-container&quot;&gt;$b = (4,0,2)^\top$&lt;/span&gt;. Verify for yourself that &lt;span class=&quot;math-container&quot;&gt;$\{\zeta : A\zeta \le b, \zeta \ge 0\}$&lt;/span&gt; indeed describes the uncertainty set &lt;span class=&quot;math-container&quot;&gt;$\mathcal{U}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we use standard duality theory to write down the &lt;a href=&quot;https://en.wikipedia.org/wiki/Dual_linear_program&quot; rel=&quot;nofollow noreferrer&quot;&gt;dual problem&lt;/a&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad b^\top \lambda\\\text{s.t.}&amp;amp;\quad A^\top \lambda \ge c\\&amp;amp;\quad\lambda \ge 0\end{align}&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$\lambda = (u,v,w)^\top$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By writing out the equations, we get&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{4}\min\quad&amp;amp;4u + 2w&amp;amp;\\\text{s.t.}\quad &amp;amp;u&amp;amp;\ge x\\\quad &amp;amp;v&amp;amp; \ge z\\\quad &amp;amp;u - 4v + w&amp;amp; \ge 0\\\quad &amp;amp;v + w&amp;amp; \ge 0\\\quad &amp;amp;u, v, w&amp;amp;\,\,\ge 0\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should lead you to the correct answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The papers that you reference may use different standard forms for linear programs. The first one (Gorissen et al.), for example, uses &lt;span class=&quot;math-container&quot;&gt;$D\zeta + q \ge 0$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$A \zeta \le b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\zeta \ge 0$&lt;/span&gt;, like I did above. Transforming between these forms is not that difficult, and not even necessary. The main step is always the same: use duality to transform a &lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; in a &lt;span class=&quot;math-container&quot;&gt;$\min$&lt;/span&gt;, and which standard form you use to derive the dual does not change the correctness of this approach.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="123" LastEditDate="2019-10-14T12:25:05.490" LastActivityDate="2019-10-14T12:25:05.490" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2749" PostTypeId="2" ParentId="2744" CreationDate="2019-10-06T07:46:36.960" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I would like to know is it possible to read an LP/MPS file into the Pyomo software and solve the problem?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Pyomo has &lt;a href=&quot;https://www.stat.washington.edu/~hoytak/code/pylpsolve/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PyLPSolve&lt;/a&gt;, a wrapper for the open source LP solver &lt;a href=&quot;http://lpsolve.sourceforge.net/5.5/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lpsolve&lt;/a&gt;, listed on the &lt;a href=&quot;http://www.pyomo.org/related-projects&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo Python Optimisation Tools&lt;/a&gt; webpage. The webpage &quot;&lt;a href=&quot;http://lpsolve.sourceforge.net/5.5/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Introduction to lp_solve 5.5.2.5&lt;/a&gt;&quot; says that lpsolve itself is written in &lt;strong&gt;C&lt;/strong&gt; and that along with an &quot;&lt;a href=&quot;http://lpsolve.sourceforge.net/5.5/XLI.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;External Language Interface&lt;/a&gt;&quot; and &quot;&lt;a href=&quot;http://lpsolve.sourceforge.net/5.5/lp_solveAPIreference.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;API&lt;/a&gt;&quot; it reads &lt;a href=&quot;http://lpsolve.sourceforge.net/5.5/lp-format.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;LP&lt;/a&gt; and &lt;a href=&quot;http://lpsolve.sourceforge.net/5.5/mps-format.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;MPS&lt;/a&gt; format files. See the &lt;a href=&quot;http://lpsolve.sourceforge.net/5.5/Intro.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Introduction&lt;/a&gt; and &lt;a href=&quot;http://lpsolve.sourceforge.net/5.5/FAQ.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;FAQ&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://pythonhosted.org/PuLP/search.html?q=read%20%20LP&quot; rel=&quot;nofollow noreferrer&quot;&gt;PuLP&lt;/a&gt; also appears to read LP and MPS files. From the &lt;a href=&quot;https://github.com/coin-or/pulp&quot; rel=&quot;nofollow noreferrer&quot;&gt;PuLP GitHub&lt;/a&gt; webpage:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;PuLP is an LP modeler written in Python. PuLP can generate MPS or LP files and call GLPK, COIN &lt;a href=&quot;https://github.com/coin-or/clp&quot; rel=&quot;nofollow noreferrer&quot;&gt;CLP&lt;/a&gt;/&lt;a href=&quot;https://www.coin-or.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;CBC&lt;/a&gt;, &lt;a href=&quot;https://www.ibm.com/products/ilog-cplex-optimization-studio&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPLEX&lt;/a&gt;, and &lt;a href=&quot;https://www.gurobi.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GUROBI&lt;/a&gt; to solve linear problems.&quot;. The default solver is &lt;a href=&quot;https://www.coin-or.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;CBC&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/modeling_extensions/pysp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;PySP&lt;/a&gt; (a Modeling Extension for Pyomo) can convert Pyomo format to SMPS:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;&lt;strong&gt;Generating SMPS Input Files From PySP Models&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This document explains how to convert a PySP model into a set of files representing the SMPS format for stochastic linear programs. Conversion can be performed through the command line by invoking the SMPS converter using the command python -m pyomo.pysp.convert.smps. This command is available starting with Pyomo version 5.1. Prior to version 5.1, the same functionality was available via the command pysp2smps (starting at Pyomo version 4.2).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;SMPS is a standard for expressing stochastic mathematical programs that is based on the ancient MPS format for linear programs, which is matrix-based. Modern algebraic modeling languages such as Pyomo offer a lot of flexibility so it is a challenge to take models expressed in Pyomo/PySP and force them into SMPS format. The conversions can be inefficient and error prone because Pyomo allows flexible expressions and model construction so the resulting matrix may not be the same for each set of input data. We provide tools for conversion to SMPS because some researchers have tools that read SMPS and exploit its limitations on problem structure; however, the user should be aware that the conversion is not always possible.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;GNU &lt;a href=&quot;https://wiki.octave.org/GNU_Octave_Wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octave&lt;/a&gt; is open source software and like &lt;a href=&quot;https://www.mathworks.com/help/optim/ug/mpsread.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Matlab&lt;/a&gt; it has a function called &lt;a href=&quot;https://wiki.octave.org/Optimization_package&quot; rel=&quot;nofollow noreferrer&quot;&gt;mpsread&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some information about the MPS file format is contained at &lt;a href=&quot;http://miplib2010.zib.de/miplib3/mps_format.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;miplib3&lt;/a&gt;, &lt;a href=&quot;https://www.gurobi.com/documentation/5.6/refman/mps_format.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi&lt;/a&gt;, the &lt;a href=&quot;https://docs.mosek.com/6.0/pyapi/node021.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;MOSEK Python API manual&lt;/a&gt;, and the Wolfram &lt;a href=&quot;https://reference.wolfram.com/language/ref/format/MPS.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Language and System Documentation Center&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-10-06T07:46:36.960" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2750" PostTypeId="1" CreationDate="2019-10-07T09:19:31.107" Score="10" ViewCount="178" Body="&lt;p&gt;Suppose I have a set &lt;span class=&quot;math-container&quot;&gt;$S=\{1,2,\dots,500\}$&lt;/span&gt; and some function &lt;span class=&quot;math-container&quot;&gt;$f(\sigma)$&lt;/span&gt; from the permutations &lt;span class=&quot;math-container&quot;&gt;$\operatorname{Perm}(S) \rightarrow \mathbb{R}$&lt;/span&gt; to be minimized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function is complex (simulation based), black box, non-smooth, and since dealing with a discrete space there is no gradient defined. However there is reason to believe that there are strong relationships between the positions of some elements and the value of &lt;span class=&quot;math-container&quot;&gt;$f(\sigma)$&lt;/span&gt; for example when &lt;span class=&quot;math-container&quot;&gt;$17 \in S$&lt;/span&gt; is &quot;earlier&quot; in the permutation then this contributes to minimizing &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and when &lt;span class=&quot;math-container&quot;&gt;$305\in S$&lt;/span&gt; is &quot;later&quot; in the permutation then this also helps minimize &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;. There are other relationships such as if &lt;span class=&quot;math-container&quot;&gt;$s \in S$&lt;/span&gt; is earlier than &lt;span class=&quot;math-container&quot;&gt;$s' \in S$&lt;/span&gt; in the permutation then this is also &quot;good&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words we are seeking the optimal &lt;strong&gt;ranking&lt;/strong&gt; of the elements where the objective function is really defined on the ranks, not the permutation indices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A first attempt I made at optimisation is to define entity weights &lt;span class=&quot;math-container&quot;&gt;$\theta\in[0,1]^{500}$&lt;/span&gt; such that the ranks within &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; define the permutation/ranks of the entities, inspired by the &quot;random keys&quot; approach in genetic algorithms. Then I fed &lt;span class=&quot;math-container&quot;&gt;$\min f(\operatorname{ranks}(\theta))$&lt;/span&gt; into Nelder-Mead function to minimize and also compared to uniform random sampling within the parameter space. Nelder-Mead typically does not out-perform random sampling (given same limit on function evaluations) and often gets stuck in a poor local minimum. Neither approach leverages the ranked structure in the parameter space which has a huge degree of symmetry (e.g. any perturbation of &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; which does not alter the ranking will not change the objective value).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is a more natural approach to optimising the rankings of a discrete, finite set of entities with respect to some black box objective function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I am looking for practical and effective methods to apply - global optimality/analytic solutions are not necessary. A reasonable function call limit in this context would be 10000-50000.&lt;/p&gt;&#xA;" OwnerUserId="1071" LastEditorUserId="123" LastEditDate="2019-10-07T19:15:13.903" LastActivityDate="2019-10-07T23:33:15.437" Title="Heuristic methods for optimising complex black box function over permutations/ranks?" Tags="|combinatorial-optimization|global-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2751" PostTypeId="2" ParentId="2750" CreationDate="2019-10-07T12:37:46.177" Score="6" Body="&lt;p&gt;An approach that is easy to implement and always worth a shot is a simple neighborhood search, where you start with some candidate solution and iteratively move to a neighbor solution. For your problem, a 2-opt or swap neighborhood could perhaps already find good local optima, as it will pick up on some of the relationships that your function possesses. More intricate neighborhoods might of course lead to better results. &lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2019-10-07T12:37:46.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2752" PostTypeId="1" AcceptedAnswerId="2756" CreationDate="2019-10-07T18:00:03.180" Score="10" ViewCount="192" Body="&lt;p&gt;You have a ticket allowing you to visit up to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; carnival booths offering games of chance. At each booth you have probability &lt;span class=&quot;math-container&quot;&gt;$p_{i}$&lt;/span&gt; of winning a reward with average value &lt;span class=&quot;math-container&quot;&gt;$r_{i}$&lt;/span&gt;. Each booth can be visited once at most. You can visit the booths in any order but you can only win once, and you have to accept the first reward that you win. The objective is to select the subset of booths to visit, and the order in which to visit them, to maximize the expected reward. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's easy enough to solve the problem using brute force. The expected value of the reward can be calculated for each permutation of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; booths. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be a more computationally feasible way to formulate the problem?&lt;/p&gt;&#xA;" OwnerUserId="2485" LastEditorUserId="123" LastEditDate="2019-10-07T19:18:35.640" LastActivityDate="2019-10-27T07:36:02.140" Title="Optimal set order to maximize stochastic reward" Tags="|modeling|combinatorial-optimization|stochastic-programming|dynamic-programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2753" PostTypeId="1" AcceptedAnswerId="2754" CreationDate="2019-10-07T18:10:53.933" Score="8" ViewCount="386" Body="&lt;p&gt;We all know that expressions in mathematical optimization models can't contain &quot;black boxes&quot; around a decision variable since everything has to be written using mathematical expressions. For example, &quot;yes/no&quot; decisions can't be written as &quot;if this then that&quot; expressions in a model, but can be written using big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; constraints with a binary variable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the recommended way of writing a model that must compute the value of a cumulative distribution function from a decision variable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's suppose we have a model with the following constraint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\Phi_X(x)\le b$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\Phi_X(x)$&lt;/span&gt; is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Cumulative_distribution_function&quot; rel=&quot;noreferrer&quot;&gt;cumulative distribution function&lt;/a&gt; of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Normal_distribution#Definition&quot; rel=&quot;noreferrer&quot;&gt;standard Normal random variable&lt;/a&gt; &lt;span class=&quot;math-container&quot;&gt;$X\sim N(\mu = 0,\sigma =1)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a decision variable, and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a parameter of the model. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way of converting this kind of constraint into a valid mathematical formulation? What is the approach suggested by experts? Does that kind of constraint absolutely require the use of special tools that can't be found in regular optimization solvers?&lt;/p&gt;&#xA;" OwnerUserId="582" LastEditorUserId="491" LastEditDate="2019-10-08T01:17:50.003" LastActivityDate="2019-10-08T01:17:50.003" Title="Standard cumulative distribution function with optimization model variable" Tags="|optimization|modeling|probability-distributions|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2754" PostTypeId="2" ParentId="2753" CreationDate="2019-10-07T18:41:31.497" Score="12" Body="&lt;p&gt;For strictly increasing CDFs, you can invert:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x \le \Phi^{-1}(b)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-10-07T18:41:31.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2755" PostTypeId="2" ParentId="2752" CreationDate="2019-10-07T18:48:44.380" Score="3" Body="&lt;p&gt;To get &lt;span class=&quot;math-container&quot;&gt;$O(2^M M^2)$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$O(M!)$&lt;/span&gt;, you could modify the &lt;a href=&quot;https://en.wikipedia.org/wiki/Held%E2%80%93Karp_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;dynamic programming formulation of the traveling salesman problem&lt;/a&gt;, with a state for each subset of booths visited so far.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2019-10-07T19:01:27.760" LastActivityDate="2019-10-07T19:01:27.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2756" PostTypeId="2" ParentId="2752" CreationDate="2019-10-07T19:26:59.810" Score="6" Body="&lt;p&gt;As it is explained &lt;a href=&quot;http://focapo.cheme.cmu.edu/2012/presentations/Ahmed.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, this problem is a &lt;strong&gt;portfolio selection problem&lt;/strong&gt;. The player should select the first &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; booths with the maximum &lt;span class=&quot;math-container&quot;&gt;$E(g_i)=p_i \times r_i$&lt;/span&gt; in which &lt;span class=&quot;math-container&quot;&gt;$E(g_i)$&lt;/span&gt; represents the expected value of gain, then among the selected &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; booths, the player should start playing the games from the one with maximum &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt;. In other words, the selected booths should be sorted based on their &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; value (from max to min value).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit(example):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider &lt;span class=&quot;math-container&quot;&gt;$M=3, n=2, r_1=100, p_1=0.6, r_2=50, p_2=0.95, r_3=1000, p_3=0.1$&lt;/span&gt; with these data, we have:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$E(g_1)=60 , E(g_2)=47.5 \ \ \text{and} \ \ \ E(g_3)=100.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sorted list of choices for the player is &lt;span class=&quot;math-container&quot;&gt;$\text{list}=(3,1)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also consider that in this type of problem, the solution is related to the amount of &lt;strong&gt;risk&lt;/strong&gt; that the player is willing to take. This relation can be explained as the tradeoff between the risk value and expected total gain.    &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-10-27T07:36:02.140" LastActivityDate="2019-10-27T07:36:02.140" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2757" PostTypeId="2" ParentId="2750" CreationDate="2019-10-07T23:33:15.437" Score="3" Body="&lt;p&gt;A &quot;random key&quot; genetic algorithm (henceforth RKGA) might get you a pretty good solution within your function call limit (particularly if you cache function values, so that repeated evaluations of the same sequence do not require repeated simulations). The idea behind RKGA is that a &quot;solution&quot; (population member) would in your case be a vector of 500 numbers (say, doubles between 0 and 1). The sort order of those numbers would be your permutation. So your examples of wanting 17 &quot;early&quot; and 305 &quot;late&quot; would correspond to the 17th element of a solution tending to be closer to 0 and the 305th element closer to 1. A reference to RKGA (I think maybe the seminarl paper) is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bean, J. C. (1994) Genetic Algorithms and Random Keys for Sequencing and Optimization, &lt;em&gt;ORSA Journal on Computing&lt;/em&gt; &lt;strong&gt;6&lt;/strong&gt;, 154-160.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-10-07T23:33:15.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2758" PostTypeId="1" AcceptedAnswerId="2764" CreationDate="2019-10-08T08:08:31.543" Score="9" ViewCount="182" Body="&lt;p&gt;I'm trying to deal with a process planning and machine layout allocation simultaneously. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following variables: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_p{_w}_{cj}=1$&lt;/span&gt; if an operation &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is done by a machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; with a configuration &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; at process plan position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and zero otherwise&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$T_w{_{w'}}_{,jj+1}=1$&lt;/span&gt; if there is a change of machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; between position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j+1$&lt;/span&gt;, and zero otherwise. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C_w{_{cc'}}_{,jj+1}=1$&lt;/span&gt; if for a given machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; there is a change of configuration between position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j+1$&lt;/span&gt;, and zero otherwise. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since the variable  &lt;span class=&quot;math-container&quot;&gt;$X_p{_w}_{cj}$&lt;/span&gt; gives me the position of each machine and configuration on the process plan, I think I must establish a relation between this variable and &lt;span class=&quot;math-container&quot;&gt;$T_w{_{w'}}_{,jj+1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_w{_{cc'}}_{,jj+1}$&lt;/span&gt;, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to do that, I created the following constraint: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{c}(X_p{_w}_{cj}+X_{p+1}{_{w'}}_{cj+1})\leqslant T_w{_{w'}}_{,jj+1} + 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this constraint I would like to state that for 2 followed positions on the process plan, the sum of variables &lt;span class=&quot;math-container&quot;&gt;$X_p{_w}_{cj}$&lt;/span&gt; must be equal or less than the variable &lt;span class=&quot;math-container&quot;&gt;$T_w{_{w'}}_{,jj+1}+1$&lt;/span&gt;. In other words, this constraint states if there is a change of machine between &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j+1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, the following constraint states if there is a change of configuration for the same machine between &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j+1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$X_p{_w}_{cj}+X_{p+1}{_w}_{{c'}j+1}\leqslant C_w{_{cc'}}_{,jj+1} + 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know if it is correct or if there is a better way to express these relations. Could someone help me?&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="2453" LastEditDate="2019-10-08T12:50:07.750" LastActivityDate="2019-10-08T17:06:51.263" Title="Constraint to state the relation between 2 binary variables" Tags="|linear-programming|constraint|binary-variable|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2759" PostTypeId="2" ParentId="2734" CreationDate="2019-10-08T08:25:34.967" Score="5" Body="&lt;p&gt;My advice is to use discrete variables for time. Modelling time as a continuous variable in scheduling problems tends to make the problem unsolvable, even though the continuous formulation results in a smaller problem. I don't know if anyone knows why that is the case, but everyone I've discussed this with over the last 5 years has found that to be true in practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way this is typically modelled is that we create a matrix of binary variables, each representing a time chunk: &lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt; would be a discrete chunk of time spent by person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; writing paper &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_{jk}$&lt;/span&gt; would be the a chunk of time spent by mover &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; moving paper &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. If the value is of a chunk is 1, then that person performs that activity for that amount of time, otherwise they don't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then use those time building blocks to build your problem logic. For instance, if each time chunk represents an hour, you may want the sum of all chunks per paper to not exceed some time limit, and so on.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-10-08T08:25:34.967" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2760" PostTypeId="1" CreationDate="2019-10-08T13:22:41.087" Score="6" ViewCount="285" Body="&lt;p&gt;I am new to thinking about math programming and I have a particular constraint I am hoping to reformulate, I just don't know the proper mathematical translation for what I am hoping to do. Enforcing the non-negativity constraint on &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; in Constraint (1) seems to make my model infeasible, and so I am hoping that with a reformulation of my problem the solver I am using (knitro) will be able to report feasibility. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My original constraint looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ X_{t} = X_{t-1} + aY_{t-1} - Z_{t-1}, \quad t\in[1,T] \tag1&#xA;\\X_{t} \ge 0 &#xA;\\ \\ X_{0}, Y_{0}, Z_{0} \ge0 $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way that I am thinking about the new formulation is shown in Constraint (2), but I feel that this is where I will need some correction on the formulation: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ X_t = \begin{cases}&#xA;0,  &amp;amp; \text{if} \quad  X_{t-1} + aY_{t-1} - Z_{t-1} \le 0 \\&#xA;X_{t-1} + aY_{t-1} - Z_{t-1}, &amp;amp; \text{otherwise}&#xA;\end{cases} \tag2&#xA;\\t\in[1,T]&#xA;\\ X_{0}, Y_{0}, Z_{0} \ge0 $$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I apologize if this is straightforward, I just don't know the precise wording to Google my problem because this is not my field of study. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone would be able to (1) help me classify what type of constraint this would be called and possibly a way to linearize it or a useful resource I can follow up on, I would be appreciative of that.&lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="123" LastEditDate="2019-10-08T15:27:03.367" LastActivityDate="2019-10-08T15:27:03.367" Title="How To Linearize $X = \max\{x_1,x_2\}$" Tags="|constraint|linearization|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="2761" PostTypeId="1" AcceptedAnswerId="2769" CreationDate="2019-10-08T14:25:30.783" Score="12" ViewCount="144" Body="&lt;p&gt;Which stabilization techniques in column generation, like penalty function approaches and dual price smoothing, can be used when subproblems are not solved optimally? (I am particularly interested in the parameter-less dual price smoothing approach proposed by &lt;a href=&quot;https://www.researchgate.net/publication/259849155_In-Out_Separation_and_Column_Generation_Stabilization_by_Dual_Price_Smoothing&quot; rel=&quot;noreferrer&quot;&gt;Pessoa &lt;em&gt;et al.&lt;/em&gt; (2013)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Pessoa, A., Sadykov, R., Uchoa, E., Vanderbeck, F. (2013). In-Out Separation and Column Generation Stabilization by Dual Price Smoothing. &lt;em&gt;Lecture Notes in Computer Science Volume 7933, 12th International Symposium on Experimental Algorithms&lt;/em&gt;, Rome, Italy. DOI: 10.1007/978-3-642-38527-8_31. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="2489" LastEditorUserId="123" LastEditDate="2019-10-08T15:34:30.623" LastActivityDate="2019-10-09T07:33:24.433" Title="Stabilization techniques in column generation when subproblems are not solved optimally" Tags="|column-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2762" PostTypeId="2" ParentId="2741" CreationDate="2019-10-08T14:43:05.183" Score="8" Body="&lt;p&gt;G.B. Dantzig and M.N. Thapa &lt;a href=&quot;https://www.springer.com/gp/book/9780387948331&quot; rel=&quot;noreferrer&quot;&gt;Linear Programming 1: Introduction&lt;/a&gt;, Springer, 1997 and&#xA;&lt;a href=&quot;https://www.springer.com/gp/book/9780387986135&quot; rel=&quot;noreferrer&quot;&gt;Linear Programming 2: Theory and Extensions&lt;/a&gt;, Spinger, 2003. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Linear Programming 2, Theory and Extensions&lt;/strong&gt;, is the one with the hard-core theoretical Linear Programming Ph.D. material which you seem to want. Among other things, it contains some of the old Stanford O.R. Ph.D. comprehensive exam questions in Linear Programming - you won't find that in any other book.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2019-10-08T14:43:05.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2763" PostTypeId="2" ParentId="2760" CreationDate="2019-10-08T15:10:27.283" Score="6" Body="&lt;p&gt;&lt;strong&gt;Solution provided by LarrySnyder610, &lt;a href=&quot;https://or.stackexchange.com/questions/711/how-to-formulate-maximum-function-in-a-constraint/712#712&quot;&gt;full original post can be found here&lt;/a&gt;:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We want a set of constraints that enforces &lt;span class=&quot;math-container&quot;&gt;$X = \max\{x_1,x_2\}$&lt;/span&gt;. Define a new binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, which will equal 1 if &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;gt; x_2$&lt;/span&gt;, will equal 0 if &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;lt; x_2$&lt;/span&gt;, and could equal either if &lt;span class=&quot;math-container&quot;&gt;$x_1 = x_2$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; be a constant such that &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2 \le M$&lt;/span&gt; in any &quot;reasonable&quot; solution to the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following constraints enforce the definition of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;x_1 - x_2 &amp;amp; \le My \\&#xA;x_2 - x_1 &amp;amp; \le M(1-y)&#xA;\end{align}$$&lt;/span&gt;&#xA;Then, the following constraints enforce &lt;span class=&quot;math-container&quot;&gt;$X = \max\{x_1,x_2\}$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;X &amp;amp; \ge x_1 \\&#xA;X &amp;amp; \ge x_2 \\&#xA;X &amp;amp; \le x_1 + M(1-y) \\&#xA;X &amp;amp; \le x_2 + My.&#xA;\end{align}$$&lt;/span&gt;&#xA;The first two constraints say &lt;span class=&quot;math-container&quot;&gt;$X \ge \max\{x_1,x_2\}$&lt;/span&gt;, as you suggested in the question. Combined with these constraints, the last two constraints say that &lt;span class=&quot;math-container&quot;&gt;$X = x_1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;gt; x_2$&lt;/span&gt; (so &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$X = x_2$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_2 &amp;gt; x_1$&lt;/span&gt; (so &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="547" LastActivityDate="2019-10-08T15:10:27.283" CommentCount="1" CommunityOwnedDate="2019-10-08T15:28:33.310" ContentLicense="CC BY-SA 4.0" />
  <row Id="2764" PostTypeId="2" ParentId="2758" CreationDate="2019-10-08T16:18:56.707" Score="6" Body="&lt;p&gt;The following constraint should be correct:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{c}(X_p{_w}_{cj}+X_{p+1}{_{w'}}_{cj+1})\leq T_w{_{w'}}_{,jj+1} +1 \ \ \ \forall w,w',p,p+1,j,j+1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because if in your machine layout allocation, the process flows from machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; to machine &lt;span class=&quot;math-container&quot;&gt;$w'$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$X_{pwcj}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_{p+1w'cj+1}$&lt;/span&gt; both should be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. Otherwise, either &lt;span class=&quot;math-container&quot;&gt;$T_{ww',jj+1}=0$&lt;/span&gt; that means one of the following situations:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;your process is &lt;span class=&quot;math-container&quot;&gt;$\{...,w,...,w',...\}$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is in position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; but &lt;span class=&quot;math-container&quot;&gt;$w'$&lt;/span&gt; is not in position &lt;span class=&quot;math-container&quot;&gt;$j+1$&lt;/span&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;your process is &lt;span class=&quot;math-container&quot;&gt;$\{...,w,...,w',...\}$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is not in position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; but &lt;span class=&quot;math-container&quot;&gt;$w'$&lt;/span&gt; is in position &lt;span class=&quot;math-container&quot;&gt;$j+1$&lt;/span&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;your process is &lt;span class=&quot;math-container&quot;&gt;$\{...,w,...,w',...\}$&lt;/span&gt; (neither &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is in position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; nor &lt;span class=&quot;math-container&quot;&gt;$w'$&lt;/span&gt; is in position &lt;span class=&quot;math-container&quot;&gt;$j+1$&lt;/span&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The same logic procedure can be seen in your second constraint.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-10-08T17:06:51.263" LastActivityDate="2019-10-08T17:06:51.263" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2765" PostTypeId="2" ParentId="2741" CreationDate="2019-10-08T18:46:41.887" Score="9" Body="&lt;p&gt;I  used to study with the following book:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chvatal, V. (1983). Linear programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Overall it's very clear. It's written primary for graduate courses in operations research, math and computer science. Chapter 17: Connections with Geometry, may give some geometric intuitions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope it helps you.&lt;/p&gt;&#xA;" OwnerUserId="806" LastEditorUserId="354" LastEditDate="2019-10-17T07:47:01.987" LastActivityDate="2019-10-17T07:47:01.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2767" PostTypeId="1" CreationDate="2019-10-09T00:51:39.843" Score="6" ViewCount="773" Body="&lt;p&gt;I have the following network flow model diagram and I have already calculated maximum flow using the R package &lt;code&gt;igraph&lt;/code&gt; to be 28. However, what I would like to know how to do is to solve this for maximum flow using the simplex method of linear programming.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I would need to put values into a matrix which I could then pass through the R function &lt;code&gt;rref()&lt;/code&gt; which puts the matrix into row reduced echelon form, but what I am not sure about is what values need to be put into this matrix.  What would such a matrix look like?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xDmvX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xDmvX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to follow Oguz Toragay's advice but I must be doing something wrong because my matrix is clearly not correct. I made a &lt;code&gt;LHS&lt;/code&gt; matrix which was all the inflows for each node, and a &lt;code&gt;RHS&lt;/code&gt; list that was all the outflows for each node, then binded them together to make &lt;code&gt;A&lt;/code&gt;, but the sides clearly do not equal each other.  I have written the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-r prettyprint-override&quot;&gt;&lt;code&gt;#LHS &#xA;#from      1   2   3   4   5   6   7&#xA;node1 = c( 0,  0,  0,  0,  0,  0,  0)&#xA;node2 = c(20,  0,  0,  0, 15,  0,  0)&#xA;node3 = c(15,  0,  0, 13,  0,  0,  0)&#xA;node4 = c( 0, 10, 13,  0,  0,  0,  0)&#xA;node5 = c( 0, 15,  0, 10,  0,  7,  0)&#xA;node6 = c( 0,  0, 15,  0,  7,  0,  8)&#xA;node7 = c( 0,  0,  3, 12,  0,  8,  0)&#xA;node8 = c( 0,  0,  0,  0, 10,  8, 10)&#xA;LHS = rbind(node1,node2,node3,node4,node5,node6,node7,node8)&#xA;&#xA;#RHS&#xA;#to           1   2   3   4   5   6   7   8&#xA;node1o = sum( 0, 20, 15,  0,  0,  0,  0,  0)&#xA;node2o = sum( 0,  0,  0, 10, 15,  0,  0,  0)&#xA;node3o = sum( 0,  0,  0, 13,  0, 15, 10,  0)&#xA;node4o = sum( 0,  0, 13,  0, 10,  0, 12,  0)&#xA;node5o = sum( 0, 15,  0,  0,  0,  7,  0, 10)&#xA;node6o = sum( 0,  0,  0,  0,  7,  0,  8,  8)&#xA;node7o = sum( 0,  0,  0,  0,  0,  8,  0, 10)&#xA;node8o = sum( 0,  0,  0,  0,  0,  0,  0,  0)&#xA;RHS = c(node1o,node2o,node3o,node4o,node5o,node6o,node7o,node8o)&#xA;&#xA;A = cbind(LHS, RHS)&#xA;&#xA;# Calling A returns:&#xA;                          RHS&#xA;node1  0  0  0  0  0 0  0  35&#xA;node2 20  0  0  0 15 0  0  25&#xA;node3 15  0  0 13  0 0  0  38&#xA;node4  0 10 13  0  0 0  0  35&#xA;node5  0 15  0 10  0 7  0  32&#xA;node6  0  0 15  0  7 0  8  23&#xA;node7  0  0  3 12  0 8  0  18&#xA;node8  0  0  0  0 10 8 10   0&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2393" LastEditorUserId="123" LastEditDate="2019-10-09T06:30:11.263" LastActivityDate="2023-08-16T13:12:45.757" Title="Network flow model - How can I turn this diagram into a matrix that when converted to RREF solves for max flow?" Tags="|linear-programming|linearization|graphs|simplex|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2768" PostTypeId="2" ParentId="2767" CreationDate="2019-10-09T01:07:06.700" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://web.archive.org/web/20200805065504/http://www.mathcs.emory.edu/%7Echeung/Courses/323/Syllabus/NetFlow/max-flow-lp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is a link that includes all the information that you need. The matrix should include all the capacity limitations on all the connections between nodes. Actually, for your example, it should be a &lt;span class=&quot;math-container&quot;&gt;$8\times8$&lt;/span&gt; matrix with all the coefficients. Each row represents one of the constraints in your LP model. In other words for each row, you consider one of the nodes in the network and write a constraint which implies that:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{All incoming flow} = \text{All outgoing flow}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also in &lt;a href=&quot;https://www.arl.wustl.edu/%7Ejst/cse/542/text/sec14.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; the matrix for a given simple network extracted from the linear model, which I think would be helpful for your problem.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="12287" LastEditDate="2023-08-16T13:12:45.757" LastActivityDate="2023-08-16T13:12:45.757" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2769" PostTypeId="2" ParentId="2761" CreationDate="2019-10-09T07:33:24.433" Score="12" Body="&lt;p&gt;I am a co-author of this paper. The parameter-less dual price smoothing approach can totally be used even if pricing subproblems are solved heuristically. We do it very often. When calculating the sub-gradient, you just use your best heuristic solutions (in terms of reduced cost) for the pricing subproblems. Of course, the better is your heuristic, the better will be the stabilization effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only condition to use this technique is that you need to solve (exactly or heuristically) all your pricing subproblems in every column generation iteration, in order to calculate the sub-gradient. This may be slow if there are many subproblems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. The full version of the paper is published here: &lt;a href=&quot;http://dx.doi.org/10.1287/ijoc.2017.0784&quot; rel=&quot;noreferrer&quot;&gt;http://dx.doi.org/10.1287/ijoc.2017.0784&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2019-10-09T07:33:24.433" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2770" PostTypeId="1" AcceptedAnswerId="2773" CreationDate="2019-10-09T08:27:36.337" Score="14" ViewCount="685" Body="&lt;p&gt;Given matrix &lt;span class=&quot;math-container&quot;&gt;$A \in \{0,1\}^{m \times n}$&lt;/span&gt; and vector &lt;span class=&quot;math-container&quot;&gt;$b \in (\mathbb{Z^+})^m$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathbb{Z^+}$&lt;/span&gt; is the set of positive integers,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{ll} \text{maximize} &amp;amp; c^\top x\\ \text{subject to} &amp;amp; Ax \leq b\\ &amp;amp; x \geq 0\\ &amp;amp; x \in \{0,1\}^n\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice the biggest difference from normal &lt;span class=&quot;math-container&quot;&gt;$0-1$&lt;/span&gt; integer programming is that &#xA;&lt;span class=&quot;math-container&quot;&gt;$A \in \{0,1\}^{m \times n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b \in (\mathbb{Z^+})^m$&lt;/span&gt;. Is there anything special about such integer programs? Is there an algorithm to solve them in polynomial time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question also exists at &lt;a href=&quot;https://math.stackexchange.com/questions/3383975/does-this-0-1-integer-program-have-any-speciallity&quot;&gt;math.stackexchange&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="2491" LastEditorUserId="8" LastEditDate="2019-10-10T00:02:08.940" LastActivityDate="2019-10-10T07:35:13.857" Title="Does this $0-1$ integer program have any speciality?" Tags="|optimization|linear-programming|integer-programming|binary-variable|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2771" PostTypeId="2" ParentId="2770" CreationDate="2019-10-09T09:41:28.603" Score="14" Body="&lt;p&gt;In general no, these problems are hard. BUT: You might want to look into &lt;a href=&quot;https://en.wikipedia.org/wiki/Unimodular_matrix#Total_unimodularity&quot; rel=&quot;nofollow noreferrer&quot;&gt;totally unimodular matrices&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Total_dual_integrality&quot; rel=&quot;nofollow noreferrer&quot;&gt;total dual integrality&lt;/a&gt; but this requires additional assumptions on the matrix or the problem respectively. If you are lucky, then your problem has these properties and you can solve it efficiently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Totally Unimodular Matrices&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A totally unimodular matrix (TU matrix) is a matrix for which every square non-singular submatrix is unimodular. Equivalently, every square submatrix has determinant 0, +1 or −1. From the definition it follows that any submatrix of a totally unimodular matrix is itself totally unimodular (TU). Furthermore it follows that any TU matrix has only 0, +1 or −1 entries (the opposite is not true).&lt;br&gt;&#xA;  Some notable examples are network matrices, or the coefficient matrices of maximum flow and minimum cost flow problems.&lt;br&gt;&#xA;  These types of matrices are very benevolent for integer problems because if &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is TU and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is integral, then linear programs of forms like &lt;span class=&quot;math-container&quot;&gt;$\{\min c^Tx ∣ A x ≥ b , x ≥ 0\}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\{\max c^Tx ∣ A x ≤ b\}$&lt;/span&gt; have integral optima, for any &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;TU matrices are also &lt;a href=&quot;https://en.wikipedia.org/wiki/Balanced_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;balanced matrices&lt;/a&gt; for which you can also show that they yield integral solutions. For these the assumptions on the matrix a more relaxed compared to totally unimodularity but to get integral solutions the right-hand side or the objective must be an all one vector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Total Dual Integrality&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also, for TDI problems you'll get an integer optimal solution, but here the definition is a bit tricky to prove.&lt;br&gt;&#xA;  A  rational  system  of  inequalities &lt;span class=&quot;math-container&quot;&gt;$Ax≤b$&lt;/span&gt; is totally  dual  integral  (TDI) if,  for  all integral &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\{\min y^Tb ∣ y≥0,y^TA=c\}$&lt;/span&gt; is attained by an integral vector &lt;span class=&quot;math-container&quot;&gt;$\hat{y}$&lt;/span&gt; whenever the optimum exists and is finite.&lt;br&gt;&#xA;  You can show that if a matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is TU, then &lt;span class=&quot;math-container&quot;&gt;$Ax\leq b$&lt;/span&gt; is TDI for all rational &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As some other folks have pointed out your problem might fall into a specific problem type, for example set packing. For those problems there could be specialized approximation algorithms which guarantee a certain optimality gap.&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="137" LastEditDate="2019-10-10T07:23:42.117" LastActivityDate="2019-10-10T07:23:42.117" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2772" PostTypeId="2" ParentId="2701" CreationDate="2019-10-09T10:07:06.413" Score="4" Body="&lt;p&gt;Regular announcements are posted on the website: &lt;a href=&quot;http://www.roadef.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;www.roadef.org&lt;/a&gt; (see forum).&lt;/p&gt;&#xA;&lt;p&gt;Here is the link:&#xA;&lt;a href=&quot;http://www.roadef.org/forum-messages?forum_id=4&amp;amp;offset=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.roadef.org/forum-messages?forum_id=4&amp;amp;offset=0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="206" LastEditorUserId="491" LastEditDate="2022-12-04T20:39:01.267" LastActivityDate="2022-12-04T20:39:01.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2773" PostTypeId="2" ParentId="2770" CreationDate="2019-10-09T12:24:58.087" Score="9" Body="&lt;p&gt;With binary &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, it is called a &lt;em&gt;set packing problem&lt;/em&gt;: &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Set_packing&quot; rel=&quot;noreferrer&quot;&gt;https://en.m.wikipedia.org/wiki/Set_packing&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With integer &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, it is called a &lt;em&gt;generalized set packing problem&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2019-10-09T12:33:18.133" LastActivityDate="2019-10-09T12:33:18.133" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2774" PostTypeId="2" ParentId="2770" CreationDate="2019-10-09T12:49:22.327" Score="2" Body="&lt;p&gt;AFAIK, your model constraint is a special case of the 0,1-knapsack inequality with binary parameters. Even for a rather large problem (which A is a 1000*1000 matrix) the problem is solved resonably.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BLOCKS OF EQUATIONS           2     SINGLE EQUATIONS        1,001&#xA;BLOCKS OF VARIABLES           2     SINGLE VARIABLES        1,001&#xA;NON ZERO ELEMENTS       501,753     DISCRETE VARIABLES      1,000&#xA;&#xA;Space for names approximately 0.03 Mb&#xA;Use option 'names no' to turn use of names off&#xA;MIP status(107): time limit exceeded&#xA;Cplex Time: 1000.02sec (det. 592962.48 ticks)&#xA;Fixing integer variables, and solving final LP...&#xA;Fixed MIP status(1): optimal&#xA;Cplex Time: 0.02sec (det. 26.90 ticks)&#xA;Resource limit exceeded.&#xA;&#xA;Root node processing (before b&amp;amp;c):&#xA;  Real time             =   10.00 sec. (7157.25 ticks)&#xA;Parallel b&amp;amp;c, 4 threads:&#xA;  Real time             =  990.02 sec. (585805.23 ticks)&#xA;  Sync time (average)   =   35.25 sec.&#xA;  Wait time (average)   =    0.00 sec.&#xA;                          ------------&#xA;Total (root+branch&amp;amp;cut) = 1000.02 sec. (592962.48 ticks)&#xA;&#xA;MIP Solution:          730.011130    (3528690 iterations, 74270 nodes)&#xA;Final Solve:           730.011130    (0 iterations)&#xA;&#xA;Best possible:         785.426613&#xA;Absolute gap:           55.415484&#xA;Relative gap:            0.070555&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Update: as @ Marco Lübbecke said, there are also other ways to solve such a problem like dynamic programming. I try to show that, it is possible to solve this problem using the static model by any MIP solver.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2019-10-10T07:35:13.857" LastActivityDate="2019-10-10T07:35:13.857" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2775" PostTypeId="2" ParentId="2770" CreationDate="2019-10-09T13:22:31.727" Score="7" Body="&lt;p&gt;While this class of problems is still hard to solve (see the other answers for details), one speciality is that it has a trivial feasible solution &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt;, which is not the case in general integer programming.&lt;/p&gt;&#xA;" OwnerUserId="47" LastActivityDate="2019-10-09T13:22:31.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2776" PostTypeId="2" ParentId="687" CreationDate="2019-10-09T20:46:32.943" Score="3" Body="&lt;p&gt;For anyone reading this after the fact, it is extremely likely that OP was using 32-bit python on 64 bit Windows. This will restrict your memory space to 2GB. (see here: &lt;a href=&quot;https://stackoverflow.com/questions/18282867/python-32-bit-&quot;&gt;https://stackoverflow.com/questions/18282867/python-32-bit-&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="173" LastActivityDate="2019-10-09T20:46:32.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2777" PostTypeId="2" ParentId="2718" CreationDate="2019-10-10T16:23:53.840" Score="8" Body="&lt;p&gt;I recommend having a look at the most recent developments around &lt;a href=&quot;https://github.com/JuliaOpt/JuMP.jl/&quot; rel=&quot;noreferrer&quot;&gt;JuMP&lt;/a&gt;. They have developed two interesting packages this year:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/odow/MathOptFormat.jl/&quot; rel=&quot;noreferrer&quot;&gt;MathOptFormat.jl&lt;/a&gt;, that allows to import/export optimization problem in MPS, LP, CBF, etc...&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/guilhermebodin/Dualization.jl&quot; rel=&quot;noreferrer&quot;&gt;Dualization.jl&lt;/a&gt;, that allows to dualize automatically any optimization problem in conic form&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can find &lt;a href=&quot;https://gist.github.com/frapac/86fd965a252012ba1d4ce3b39dee0390&quot; rel=&quot;noreferrer&quot;&gt;here a Julia script&lt;/a&gt; that takes as input a MPS file and output the dual problem in a LP file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I get some problems with MathOptFormat, as this package is not yet able to import LP files... Still a work in progress I guess!&lt;/p&gt;&#xA;" OwnerUserId="2452" LastActivityDate="2019-10-10T16:23:53.840" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2778" PostTypeId="2" ParentId="2731" CreationDate="2019-10-10T17:56:52.817" Score="7" Body="&lt;p&gt;There is a systematic way of finding the infeasibility of your problem. You would like to find the Irreducibly Inconsistent System (IIS) of your model. This technology is available in CPLEX and Gurobi for MIP and in BARON for MINLP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you have implemented your model in Pyomo (in case you do not have a BARON license), you can submit the problem to the &lt;a href=&quot;https://neos-server.org/neos/&quot; rel=&quot;nofollow noreferrer&quot;&gt;NEOS server&lt;/a&gt; for them to run the problem for you. You can either use the Pyomo-GAMS interface to generate a .gms file (make sure to use the &lt;code&gt;symbolic_solver_labels=True, keepfiles=True&lt;/code&gt; option to keep the original names in the flattened GAMS model) as described &lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/library_reference/solvers/gams.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, or generate the .bar file to submit it to NEOS. If you have a BARON license run it directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you do that, you need to use the option &lt;code&gt;CompIIS 1&lt;/code&gt; for either &lt;a href=&quot;https://www.gams.com/latest/docs/S_BARON.html#BARON_SYSTEMATIC_TREATMENT_OF_INFEASIBLE_PROBLEMS&quot; rel=&quot;nofollow noreferrer&quot;&gt;GAMS&lt;/a&gt; or BARON &lt;a href=&quot;https://minlp.com/downloads/docs/baron%20manual.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;directly&lt;/a&gt; to obtain the IIS for your problem. The formulation looks correct in my opinion, and from my own experience,  the infeasibility usually comes from typos/data errors. I highly recommend the IIS computation to debug your models.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This procedure tends to be more expensive than the solution of the original MINLP, so consider using a small instance.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="123" LastEditDate="2019-10-10T18:48:26.103" LastActivityDate="2019-10-10T18:48:26.103" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2779" PostTypeId="1" CreationDate="2019-10-11T01:54:59.583" Score="6" ViewCount="124" Body="&lt;p&gt;I've been pondering on this question for some work optimization, and I need some help in being directed to the right direction.&lt;/p&gt;&#xA;&lt;p&gt;I have multiple customers that require an amount of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; each. From the factories, I have a number of trucks that can carry a few configurations of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; (either &lt;span class=&quot;math-container&quot;&gt;$1 X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$3 Y$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$2 Y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$5 Z$&lt;/span&gt;) to deliver to the customers.&lt;/p&gt;&#xA;&lt;p&gt;What I would like to do is to select the trucks and configuration that should be sent out in order to reduce the number of trips to the customers.&lt;/p&gt;&#xA;&lt;p&gt;Example:&#xA;It's better to have 3 trucks delivering to 3 customers like this:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$[T_1 - C_1,T_2 - C_2,T_3 - C_3]$$&lt;/span&gt;&#xA;Total trips: &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Than 2 trucks delivering to 3 customers like this:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$[T_1 - C_1, C_2,T_2 - C_2, C_3]$$&lt;/span&gt;&#xA;Total trips: &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The target selection is what has stumped me for now. You can assume that distance does not matter for now.&lt;/p&gt;&#xA;&lt;p&gt;Here is an example to better explain it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{Configuration}\,1&amp;amp;:3A,2B,1C\qquad&amp;amp;&amp;amp;\text{Customer}\,1:2A,2B,1C\\\text{Configuration}\,2&amp;amp;:1A,3B,3C\qquad&amp;amp;&amp;amp;\text{Customer}\,2:2A\\\text{Configuration}\,3&amp;amp;:4A,1B\qquad&amp;amp;&amp;amp;\text{Customer}\,3:4B,2C\\\text{Configuration}\,4&amp;amp;:2A,3B,1C\end{align}&lt;/span&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{c|cccc|c}&amp;amp;\text{CC}1&amp;amp;\text{CC}2&amp;amp;\text{CC}3&amp;amp;\text{CC}4&amp;amp;\text{Sent To}\\\hline\text{Truck}\,1&amp;amp;1&amp;amp;1&amp;amp;0&amp;amp;0&amp;amp;1,2\\\text{Truck}\,2&amp;amp;1&amp;amp;1&amp;amp;1&amp;amp;0&amp;amp;2,3\\\text{Truck}\,3&amp;amp;0&amp;amp;1&amp;amp;0&amp;amp;1&amp;amp;\text{Not Sent}\\\text{Truck}\,4&amp;amp;1&amp;amp;0&amp;amp;1&amp;amp;0&amp;amp;3\end{array}&lt;/span&gt; The objective is to select the number of trucks sent out, what configuration they should hold and minimize the number of trips sent out.&lt;/p&gt;&#xA;" OwnerUserId="2503" LastEditorUserId="491" LastEditDate="2020-10-22T02:24:54.683" LastActivityDate="2020-10-22T02:24:54.683" Title="Help in solving resource allocation optimization problem" Tags="|modeling|integer-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2780" PostTypeId="1" AcceptedAnswerId="2781" CreationDate="2019-10-11T12:05:37.653" Score="9" ViewCount="742" Body="&lt;p&gt;I'm looking for examples of (classes of) problems with a non-convex, non-linear formulation, but convex feasible region.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, a problem of the sort:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{lll}&#xA; \text{minimize}   &amp;amp;  c^Tx        &amp;amp; \\&#xA; \text{subject to} &amp;amp; g_i(x) \le 0 &amp;amp; (i \in I)&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;where at least some of the &lt;span class=&quot;math-container&quot;&gt;$g_i$&lt;/span&gt; are non-convex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the same time, the feasible region &lt;span class=&quot;math-container&quot;&gt;$F = \{ x \in \mathbb{R}^n \ | \ g_i(x) \le 0, i \in I \}$&lt;/span&gt; should be a convex set. Preferably &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is full-dimensional, in the sense of containing a small ball.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$g_i$&lt;/span&gt;, both smooth and non-smooth examples would be interesting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: Bonus points for problems that have some practical relevance. I would like to use such an example as motivation for a method to solve these kinds of problems.&lt;/p&gt;&#xA;" OwnerUserId="126" LastEditorUserId="126" LastEditDate="2019-10-11T14:05:19.463" LastActivityDate="2019-10-12T09:48:36.127" Title="Examples of problems with non-convex constraint functions but convex feasible region" Tags="|reference-request|convexity|nonconvex-programming|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2781" PostTypeId="2" ParentId="2780" CreationDate="2019-10-11T13:56:55.457" Score="10" Body="&lt;p&gt;Couldn't we use a combination of trigonometric functions ? E.g. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases}&#xA;x \in [0, 2\pi] \\&#xA;y \le \sin x \\&#xA;y \ge -\sin x&#xA;\end{cases}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2452" LastEditorUserId="2510" LastEditDate="2019-10-12T09:48:36.127" LastActivityDate="2019-10-12T09:48:36.127" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2782" PostTypeId="1" AcceptedAnswerId="2812" CreationDate="2019-10-11T14:30:34.023" Score="5" ViewCount="1089" Body="&lt;p&gt;I am new in CPLEX and I am using docplex in Python to solve an ILP.&lt;/p&gt;&#xA;&lt;p&gt;I would like to translate the following constraint in docplex:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{c}(X_p{_w}_{cj}+X_{p+1}{_{w'}}_{cj+1})\leqslant T_w{_{w'}}_{,jj+1} + 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Knowing that the binary variables are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_p{_w}_{cj}=1$&lt;/span&gt; if an operation &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is done by a machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; with a configuration &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; at process plan position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and zero otherwise&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$T_w{_{w'}}_{,jj+1}=1$&lt;/span&gt; if there is a change of machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; between position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j+1$&lt;/span&gt;, and zero otherwise.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I've tried to code a dictionary:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;cnrt_10 = {(w, w1, j-1, j): opt_model.add_constraint(ct=opt_model.sum(X_var[p-1, w, c, j-1] + X_var[p, w1, c, j] for c in set_C) &amp;lt;= 1 + T_var[w, w1, j-1, j], ctname=&amp;quot;cnrt10_{0}_{1}_{2}_{3}&amp;quot;.format(w, w1, j-1, j)) for p in set_OP for w in set_W for w1 in set_W for j in set_J}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And also a list:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;opt_model.add_constraints(opt_model.sum(X_var[p-1, w, c, j-1] + X_var[p, w1, c, j] for c in set_C) &amp;lt;= 1 + T_var[w, w1, j-1, j] for p in set_OP for w in set_W for w1 in set_W for j in set_J)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But both are returning an error.&lt;/p&gt;&#xA;&lt;p&gt;I am sorry for my elementary question, but I am a beginner in Python and CPLEX, so I would really appreciate if someone can help me with these problems.&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="491" LastEditDate="2021-01-14T22:07:13.377" LastActivityDate="2021-01-14T22:07:13.377" Title="How to establish constraint between variables with multiple indexes using CPLEX in Python" Tags="|integer-programming|cplex|python|binary-variable|docplex|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2783" PostTypeId="2" ParentId="2780" CreationDate="2019-10-11T16:39:11.700" Score="8" Body="&lt;p&gt;+1 for answer by @fpacaud .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are two non-contrived examples, which commonly arise in modern O.R. optimization.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Rotated Second Order Cone&lt;/strong&gt;, which arises in Second Order Cone Programming.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For simplicity, I'll show the formulation for 3-D.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}x^2 &amp;amp;\le yz\\y &amp;amp;\ge 0\\z &amp;amp;\ge 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moving everything to the Left-Hand Side (LHS), the first inequality is &lt;span class=&quot;math-container&quot;&gt;$x^2 - yz \le 0$&lt;/span&gt;, for which the LHS is neither convex nor concave as a function of &lt;span class=&quot;math-container&quot;&gt;$x,y,z$&lt;/span&gt;, even when restricted to &lt;span class=&quot;math-container&quot;&gt;$y \ge 0, z \ge 0$&lt;/span&gt;. yet the Rotated Second Order Cone describes a convex region. Re: the update bonus, there are already efficient algorithms for solving these problems.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;strong&gt;Geometric Programming&lt;/strong&gt; See &lt;a href=&quot;https://web.stanford.edu/~boyd/papers/pdf/gp_tutorial.pdf&quot; rel=&quot;noreferrer&quot;&gt;A tutorial on geometric programming, Stephen Boyd, Seung-Jean Kim, Lieven Vandenberghe, Arash Hassibi, Optim Eng (2007) 8: 67–127&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As seen in section 2.2 of the link, the standard form has constraints &lt;span class=&quot;math-container&quot;&gt;$f_i \le 1$&lt;/span&gt;, in which the &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; are non-convex posynomials (although they are log-convex). Yet when a logarithmic transformation is applied, as shown in section 2.5 of the link, the constraint region becomes convex. This shows convexity is not invariant to change of variables, and is not an inherent geometric property of the constraint region. Re: the update bonus, there are already efficient algorithms for solving Geometric Programs.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2019-10-11T17:04:23.307" LastActivityDate="2019-10-11T17:04:23.307" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2784" PostTypeId="2" ParentId="2780" CreationDate="2019-10-11T18:16:19.663" Score="4" Body="&lt;p&gt;For any &lt;a href=&quot;https://en.wikipedia.org/wiki/Monotonic_function&quot; rel=&quot;nofollow noreferrer&quot;&gt;monotonic function&lt;/a&gt; &lt;span class=&quot;math-container&quot;&gt;$f:\mathbb{R} \rightarrow \mathbb{R}$&lt;/span&gt; your problem is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{lll}&#xA; \text{minimize}   &amp;amp;  c^Tx        &amp;amp; \\&#xA; \text{subject to} &amp;amp; h_i(x) \le f(0) &amp;amp; (i \in I)&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$h_i(x) = f(g(x_i))$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, &lt;span class=&quot;math-container&quot;&gt;$h_i(x)$&lt;/span&gt; need not be convex. You can see this by taking &lt;span class=&quot;math-container&quot;&gt;$f(x) = x^3$&lt;/span&gt; for example.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-10-11T18:16:19.663" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2785" PostTypeId="2" ParentId="2782" CreationDate="2019-10-11T19:14:45.133" Score="2" Body="&lt;p&gt;I believe there is a problem in the indices that you used in the construction of constraints. For example, you defined &lt;span class=&quot;math-container&quot;&gt;$T_w{_{w'}}_{,jj+1}$&lt;/span&gt; which should have had 4 indices in your constraint while you put 5 of them.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;T_var[w, c, c1, j-1, j]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I am not an expert in DOcplex but I am familiar with Pyomo in which you can first define a &quot;&lt;strong&gt;ConstraintList()&lt;/strong&gt;&quot; and then through a for loop, you can add instances of that type of constraint in the constraint list. I tried to model that part of the code even though it isn't exact but may give you some hints. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;model.cons_list = ConstraintList()&#xA;for c in set_C:&#xA;   for p in set_OP:&#xA;      for w, w1 in set_W: &#xA;         for j in set_J:&#xA;            model.cons_list.add(sum(X_var[p-1, w, c, j-1] + X_var[p, w1, c, j]) &amp;lt;= 1 + T_var[w, c, c1, j-1, j])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also you can use &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;Constraint.Skip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for those combinations that you don't want to have a constraint.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-10-11T19:14:45.133" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2786" PostTypeId="1" AcceptedAnswerId="2816" CreationDate="2019-10-12T09:42:06.333" Score="7" ViewCount="411" Body="&lt;p&gt;I am implementing a solution for packages consolidation (basing on Nurse Problem solution) with OR-Tools CP Solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a factory that manufactures some small Packages that need to be transported by post to the customers.&#xA;It would be optimal to consolidate some mini_Packages into bigger Packages (for example if we respect total weight limit, we can merge 3 light mini_Packages into one Package and pay transport costs once not 3 times).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mini_Packages have some important attributes in data source (fixed destination, weight, acceptable delivery date range).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My main 0-1 integer variable looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x[mini_package_number, optimal_shipment_date, package_number]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It == 1 if mini_Package should be send on a certain day, consolidated to a certain Package_number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Conflicting products&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A mini_Package represents a single product item. Name of the product is an attribute of mini_Package, given in a certain list (position on the list = mini_Package_number).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;products = [34, 12, 12, 456 ...]&lt;br&gt;&#xA;meaning that:&lt;br&gt;&#xA;mini_Package 0 contains product 34&lt;br&gt;&#xA;mini_Package 1 contains product 12&lt;br&gt;&#xA;mini_Package 2 also contains product 12  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some products that cannot be merged together.&#xA;If a mini_Packages represent a certain product it cannot be merged (to the same Package) with another mini_Package that represents conflicting product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The format of conflict matrix can be adjusted for the model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment I plan following format:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;conflict_list = [(1,3), (3,6), (5,19)]&#xA;saying that:&lt;br&gt;&#xA;product 1 and 3 cannot go together&lt;br&gt;&#xA;product 3 and 6 cannot go together&lt;br&gt;&#xA;product 5 and 19 cannot go together  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conflict list represents mutually exclusive pairs, however it is important that final Package may merge more products (for example four mini_Packages with non-conflicting products 1, 1, 2, 6).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any ideas how such a logic could be implemented?&lt;/p&gt;&#xA;" OwnerUserId="2509" LastEditorUserId="2509" LastEditDate="2019-10-14T10:46:38.583" LastActivityDate="2019-10-14T14:24:41.233" Title="Shipments consolidation - how to model mutually exclusive items with OR-Tools CP Solver in Python (multi-knapsack, updated)" Tags="|modeling|or-tools|knapsack|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2789" PostTypeId="1" AcceptedAnswerId="2793" CreationDate="2019-10-12T19:41:29.903" Score="9" ViewCount="862" Body="&lt;p&gt;I was wondering if the KKT conditions are applicable for for MINLPs, and if not, why not? What about the case when the integer variables are modeled using constraints involving just continuous variables?  &lt;/p&gt;&#xA;" OwnerUserId="2513" LastActivityDate="2019-10-12T22:36:55.137" Title="Do the KKT conditions hold for mixed integer nonlinear problems?" Tags="|nonlinear-programming|minlp|kkt-conditions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2790" PostTypeId="1" AcceptedAnswerId="2797" CreationDate="2019-10-12T20:38:07.300" Score="8" ViewCount="829" Body="&lt;p&gt;Modeling various non-differentiable functions is quite common knowledge including &lt;span class=&quot;math-container&quot;&gt;$\operatorname{abs}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\min$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; functions. How would one go about modeling the nearest integer function, say in an inequality constraint &lt;span class=&quot;math-container&quot;&gt;$\lfloor{x}\rceil \leq C$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2513" LastEditorUserId="123" LastEditDate="2019-10-13T08:02:53.543" LastActivityDate="2019-10-13T08:02:53.543" Title="Modeling the Round (Nearest Integer) function" Tags="|mixed-integer-programming|modeling|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2791" PostTypeId="2" ParentId="2790" CreationDate="2019-10-12T20:55:10.697" Score="5" Body="&lt;p&gt;Assuming finite bounds on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, this could be modeled with disjunctions on the many cases to which &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; can be rounded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if &lt;span class=&quot;math-container&quot;&gt;$x \in [ 0, 2 ]$&lt;/span&gt;, we would have:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{cases}&#xA;x \le 0.5, &amp;amp; 0 \le C \\&#xA;0.5 \le x \le 1.5, &amp;amp; 1 \le C \\&#xA;1.5 \le x , &amp;amp; 2 \le C &#xA;\end{cases}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The disjunction itself could be modeled with auxiliary binary variables and big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; constraints, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that rounding in this context has some ambiguity, as a value of &lt;span class=&quot;math-container&quot;&gt;$0.5$&lt;/span&gt; may be rounded either to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, because strict inequalities can usually not be enforced by MIP solvers.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-10-12T20:55:10.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2792" PostTypeId="2" ParentId="2790" CreationDate="2019-10-12T20:59:22.603" Score="2" Body="&lt;p&gt;As an alternative solution, I propose to add an auxiliary integral variable &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{Z}$&lt;/span&gt; that should play the role of the rounded &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your example of the inequality, I would add:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rll}&#xA;  y &amp;amp;\le&amp;amp; C \\&#xA;  x - 0.5&amp;amp;\le&amp;amp; y&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-10-12T20:59:22.603" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2793" PostTypeId="2" ParentId="2789" CreationDate="2019-10-12T21:38:18.957" Score="14" Body="&lt;p&gt;No, the KKT conditions aren't applicable to mixed-integer programming problems with integer variables.  The theory behind the KKT conditions depends on the objective and constraint functions being differentiable but functions of integer variables aren't differentiable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's certainly possible to enforce integrality constraints using continuous&#xA;variables.  For example, the constraint that &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; is 0 or 1 can be written as the nonconvex nonlinear equality constraint &lt;span class=&quot;math-container&quot;&gt;$x_{i}(1-x_{i})=0$&lt;/span&gt;. You could apply the KKT conditions to such a problem, but you would end up with locally optimal points for every possible combination of the integer variable values.  &lt;/p&gt;&#xA;" OwnerUserId="103" LastEditorUserId="103" LastEditDate="2019-10-12T22:36:55.137" LastActivityDate="2019-10-12T22:36:55.137" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2794" PostTypeId="1" AcceptedAnswerId="2813" CreationDate="2019-10-12T21:55:46.420" Score="11" ViewCount="1266" Body="&lt;p&gt;I've noticed that parallel (CPU or GPU) nonlinear programming solvers are few and far between. It seems that if any parallelization is involved at all, it generally applies to solving the underlying linear system or using multi-start methods.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a particular reason for this - i.e. inherent difficulties in finding a good scalable parallel framework for the interior point and SQP algorithms? &lt;/p&gt;&#xA;" OwnerUserId="2513" LastEditorUserId="8" LastEditDate="2019-10-13T17:28:49.813" LastActivityDate="2020-07-20T01:10:05.997" Title="Parallel nonlinear solvers" Tags="|solver|nonlinear-programming|parallel-computing|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2795" PostTypeId="2" ParentId="2790" CreationDate="2019-10-12T22:12:14.183" Score="1" Body="&lt;p&gt;Assuming that the value &lt;span class=&quot;math-container&quot;&gt;$C + 0.5$&lt;/span&gt; is valid, you could model this by simply adding the constraint&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x \leq C + 0.5$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you define a constant say &lt;span class=&quot;math-container&quot;&gt;$\epsilon = 10^{-7}$&lt;/span&gt; and do&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x \leq C + 0.5 - \epsilon$$&lt;/span&gt; &lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2019-10-12T22:19:13.147" LastActivityDate="2019-10-12T22:19:13.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2796" PostTypeId="1" AcceptedAnswerId="2798" CreationDate="2019-10-12T22:37:43.433" Score="9" ViewCount="537" Body="&lt;p&gt;In quadratic programming (QP), you encounter an objective of the following form:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x^TQx + c^Tx$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and often it's desirable to know if the QP is convex. One method to check for convexity is by determining whether matrix &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is positive semidefinite (PSD). What are some common algorithms that can quickly check whether matrix &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is PSD?  &lt;/p&gt;&#xA;" OwnerUserId="2513" LastEditorUserId="8" LastEditDate="2019-10-13T12:56:52.463" LastActivityDate="2019-10-13T12:56:52.463" Title="Convexity of a QP" Tags="|convexity|quadratic-programming|linear-algebra|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2797" PostTypeId="2" ParentId="2790" CreationDate="2019-10-12T23:06:30.630" Score="6" Body="&lt;p&gt;This is a hack of Robert Schwarz's answer, to accommodate the &quot;round .5 to even&quot; rule. We introduce integer variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, along with the constraints &lt;span class=&quot;math-container&quot;&gt;$$2y+z \le x \le 2y + z + 1$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$x + z - 0.5 \le C.$$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is noninteger, the first constraint finds the nearest integers on either side. If the floor of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is even (meaning a fraction of one half would round down), &lt;span class=&quot;math-container&quot;&gt;$z=0$&lt;/span&gt; and we require that &lt;span class=&quot;math-container&quot;&gt;$x - 0.5 \le C$&lt;/span&gt;. If the floor of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is odd (meaning a fraction of one half would round up), &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt; and we require that &lt;span class=&quot;math-container&quot;&gt;$x + 0.5 \le C$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an ambiguity when &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is integer. For instance, if &lt;span class=&quot;math-container&quot;&gt;$x = 3$&lt;/span&gt;, both &lt;span class=&quot;math-container&quot;&gt;$(y,z)=(1,1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(y,z)=(1,0)$&lt;/span&gt; satisfy the constraint. Fortunately, the solver will bail us out: if it &quot;wants&quot; to have &lt;span class=&quot;math-container&quot;&gt;$x=3$&lt;/span&gt; be feasible (and if &lt;span class=&quot;math-container&quot;&gt;$C=3$&lt;/span&gt;), it will choose &lt;span class=&quot;math-container&quot;&gt;$(y,z)=(1,0)$&lt;/span&gt;, so that &lt;span class=&quot;math-container&quot;&gt;$x=3=C$&lt;/span&gt; satisfies the second constraint.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-10-12T23:06:30.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2798" PostTypeId="2" ParentId="2796" CreationDate="2019-10-13T05:17:26.160" Score="6" Body="&lt;p&gt;You can use Singular Value Decomposition or Cholesky Decomposition. I recommend you read this &lt;a href=&quot;http://www.ti3.tuhh.de/paper/rump/Ru06c.pdf&quot; rel=&quot;noreferrer&quot;&gt;Verification of Positive Definiteness&lt;/a&gt;. On page 9 there is an algorithm in MATLAB.&lt;/p&gt;&#xA;" OwnerUserId="1252" LastEditorUserId="1252" LastEditDate="2019-10-13T07:34:27.720" LastActivityDate="2019-10-13T07:34:27.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2799" PostTypeId="1" CreationDate="2019-10-13T05:26:47.610" Score="6" ViewCount="78" Body="&lt;p&gt;I have a 3 step process. Step A takes 20 min, Step B : 60 min, Step C : 20 min&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps in production of output &quot;news nuggets&quot; is as below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step A : Do Secondary Research&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step B : Analyse the data, Generate Insights, Arrange Information&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step C : Check Grammar, Formatting &amp;amp; convert to PDF&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aDbKj.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aDbKj.png&quot; alt=&quot;3 Step Process for resource allocation&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is my calculation of crew size correct ?&lt;/li&gt;&#xA;&lt;li&gt;What step is the constraint and why?  &lt;/li&gt;&#xA;&lt;li&gt;Manual calculation as in the excel (&lt;a href=&quot;http://bit.ly/OpsResearchProblem&quot; rel=&quot;noreferrer&quot;&gt;attached&lt;/a&gt;) makes Step C as&#xA;constraint.&lt;/li&gt;&#xA;&lt;li&gt;What is the best way to allocate resources.PS: The flow is assumed&#xA;to be constant&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2514" LastEditorUserId="123" LastEditDate="2019-10-13T08:03:51.760" LastActivityDate="2019-10-15T18:28:51.600" Title="Optimal resource allocation - 3 step process" Tags="|constraint|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="2800" PostTypeId="2" ParentId="2796" CreationDate="2019-10-13T05:53:52.857" Score="4" Body="&lt;p&gt;Some quadratic problems are convex while others may not. This is a nice discussion in the QP by &lt;a href=&quot;http://yetanothermathprogrammingconsultant.blogspot.com/2013/07/qp-is-convex-or-not.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Erwin Kalvelagen&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-10-13T05:53:52.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2801" PostTypeId="2" ParentId="2794" CreationDate="2019-10-13T06:40:14.893" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;I've noticed that parallel (CPU or GPU) nonlinear programming solvers are few and far between.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;The General Nonlinear Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt; nonlinear problem is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}&#xA;\mathcal{f}_1(x_1, x_2, \cdots , x_n)=0 \\&#xA;\mathcal{f}_2(x_1, x_2, \cdots , x_n)=0 \\&#xA;\vdots \tag 1 \\&#xA;\mathcal{f}_n(x_1, x_2, \cdots , x_n)=0&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which can be summarized as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f (x) = 0 \tag 2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where we use bold face to denote vectors:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \mathbf{f} = \left [ \begin{array}&#xA;\mathcal{f}_1 \\ \mathcal{f}_2 \\ \vdots \\ \mathcal{f}_n \end{array} \right ]  \!\!,\,\,&#xA;\mathbf{x} = \left [ \begin{array}&#xA;\mathcal{x}_1 \\ \mathcal{x}_2 \\ \vdots \\ \mathcal{x}_n \end{array} \right ]  \!\!,\,\,&#xA;\mathbf{0} = \left [ \begin{array} 00 \\ 0 \\ 0 \\ 0 \end{array} \right ]  $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Two points:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Nonlinear equations are generally solved numerically by the iterative solution of linear equations&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.jstor.org/stable/2004333?seq=1#page_scan_tab_contents&quot; rel=&quot;nofollow noreferrer&quot;&gt;John Rice&lt;/a&gt; states (approximately) that the solution of nonlinear equations is the most difficult problem in scientific computation&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Parallel programming is &lt;strong&gt;difficult to implement&lt;/strong&gt;, but there are more than a few solvers.&lt;/p&gt;&#xA;&lt;p&gt;Mathworks &lt;a href=&quot;https://www.mathworks.com/help/optim/ug/objective-and-constraints-using-common-function.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;solves non-linear equations in parallel&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A &lt;a href=&quot;https://computing.llnl.gov/projects/sundials/uses-sundials&quot; rel=&quot;nofollow noreferrer&quot;&gt;number of solvers&lt;/a&gt; incorporate &lt;a href=&quot;https://computing.llnl.gov/projects/sundials/usage-notes&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sundials&lt;/a&gt; and use the &lt;a href=&quot;https://computing.llnl.gov/projects/sundials/kinsol&quot; rel=&quot;nofollow noreferrer&quot;&gt;KINSOL&lt;/a&gt; solver for nonlinear algebraic systems. It can use MPI, CUDA, or operate serially. It is written and maintained by the &lt;a href=&quot;https://computing.llnl.gov/projects/sundials/team&quot; rel=&quot;nofollow noreferrer&quot;&gt;team at LLNL&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://juliadiffeq.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;JuliaDiffEq&lt;/a&gt; allows &lt;a href=&quot;http://diffeq.sciml.ai/stable/features/linear_nonlinear/#&quot; rel=&quot;nofollow noreferrer&quot;&gt;non-linear methods&lt;/a&gt;, and has an &lt;a href=&quot;https://github.com/JuliaDiffEq/Sundials.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;interface to Sundials&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;PETSc supports &lt;a href=&quot;https://www.mcs.anl.gov/petsc/miscellaneous/petscthreads.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;threads&lt;/a&gt;, MPI, and &lt;a href=&quot;https://www.mcs.anl.gov/petsc/features/gpus.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;GPUs through CUDA or OpenCL&lt;/a&gt;, as well as hybrid MPI-GPU parallelism. It has over a dozen &lt;a href=&quot;https://www.mcs.anl.gov/petsc/documentation/nonlinearsolvertable.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;non-linear methods&lt;/a&gt;. It is written and maintained by the &lt;a href=&quot;https://www.mcs.anl.gov/petsc/miscellaneous/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;team at ANL&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Trilinos &lt;a href=&quot;https://trilinos.org/docs/files/TrilinosBuildReference.html#configuring-with-kokkos-and-advanced-back-ends&quot; rel=&quot;nofollow noreferrer&quot;&gt;supports&lt;/a&gt; CUDA, OpenMP, Pthread and serial modes to solve non-linear problems. Visit their &lt;a href=&quot;https://github.com/trilinos/Trilinos&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub&lt;/a&gt; for sources to the &lt;a href=&quot;https://trilinos.github.io/packages.html#nonlinear-transient-and-optimization-solvers&quot; rel=&quot;nofollow noreferrer&quot;&gt;NOX, LOCA and GlobiPack&lt;/a&gt; non-linear solver packages.&lt;/p&gt;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&lt;p&gt;CS.SE - &amp;quot;&lt;a href=&quot;https://cs.stackexchange.com/q/43849/86889&quot;&gt;Solving large nonlinear systems in parallel&lt;/a&gt;&amp;quot; (parallel)&lt;/p&gt;&#xA;&lt;p&gt;Math.SE - &amp;quot;&lt;a href=&quot;https://math.stackexchange.com/q/913579/510296&quot;&gt;Using jacobian to solve a nonlinear system of equations?&lt;/a&gt;&amp;quot; (not parallel)&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;&lt;a href=&quot;https://www.researchgate.net/publication/262077780_Parallelization_Research_of_SapTis-Software_of_Multi-Field_Simulation_and_Nonlinear_Analysis_of_Complex_Structures&quot; rel=&quot;nofollow noreferrer&quot;&gt;Parallelization Research of SapTis-Software of Multi-Field Simulation and Nonlinear Analysis of Complex Structures&lt;/a&gt;&amp;quot; (the difficulty of parallelization)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="279" LastEditDate="2020-07-20T01:10:05.997" LastActivityDate="2020-07-20T01:10:05.997" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2802" PostTypeId="1" AcceptedAnswerId="2803" CreationDate="2019-10-13T09:29:58.883" Score="7" ViewCount="129" Body="&lt;p&gt;I will explain the problem in a simplified version.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Three Tasks: &lt;span class=&quot;math-container&quot;&gt;$T_1, T_2, T_3$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Four Machines: &lt;span class=&quot;math-container&quot;&gt;$M_1, M_2, M_3, M_4$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The machines &lt;span class=&quot;math-container&quot;&gt;$M_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_3$&lt;/span&gt; make the same processing, so they are parallel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tasks &lt;span class=&quot;math-container&quot;&gt;$T_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T_3$&lt;/span&gt; must go through the machines in the following order:&#xA;&lt;span class=&quot;math-container&quot;&gt;$M_1 \to (M_2\, or\, M3) \to M_4$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Task &lt;span class=&quot;math-container&quot;&gt;$T_2$&lt;/span&gt; is different, not all machines need to be run through. The order is&#xA;&lt;span class=&quot;math-container&quot;&gt;$M_1\to M_4$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is now if this counts to the family of job-shop problems?&#xA;Because in books I always read that in the job-shop problem every task must be processed on every machine, but the order does not matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is not a job-shop problem, to which family of the shop problems does this explanation count?&#xA;It would be very helpful if you can add the book/paper where this is defined, that I can obtain more info about it?&lt;/p&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="1278" LastEditDate="2019-10-13T11:16:59.317" LastActivityDate="2019-10-13T11:31:20.670" Title="Count this to the family of Job Shop Problem?" Tags="|optimization|reference-request|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2803" PostTypeId="2" ParentId="2802" CreationDate="2019-10-13T10:57:46.270" Score="4" Body="&lt;p&gt;As per you have a specific route for each job, it sounds like a flexible job shop problem. In a practical situation, many times, a specific job maybe does not need to process in all stages. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, we have two jobs (A and B) and four stages. Job A should be processed in all four stages while job B need to be processed in the three stages. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fZBNi.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fZBNi.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if you are willing to learn more about job shop models, the following links would be useful.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/2710/what-is-the-difference-between-job-shop-scheduling-and-resource-constrained-proj&quot;&gt;What is the difference between job shop scheduling and resource constrained project scheduling?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/1166/what-class-of-scheduling-problem-models-jobs-which-require-multiple-machines-sim&quot;&gt;What class of scheduling problem models jobs which require multiple machines simultaneously?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Indeed, a good reference is: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/de/book/9781441909091&quot; rel=&quot;nofollow noreferrer&quot;&gt;Planning and Scheduling in Manufacturing and Services by Michael Pinedo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2019-10-13T11:31:20.670" LastActivityDate="2019-10-13T11:31:20.670" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2804" PostTypeId="2" ParentId="2794" CreationDate="2019-10-13T11:09:19.950" Score="6" Body="&lt;p&gt;I think that there exist multiple solvers based on &lt;a href=&quot;https://en.wikipedia.org/wiki/Augmented_Lagrangian_method#Alternating_direction_method_of_multipliers&quot; rel=&quot;noreferrer&quot;&gt;ADMM&lt;/a&gt;. If the variables can be partitioned in two sets in a way that the problem decomposes for one set fixed, then every other iteration can be executed in parallel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a specific solver implementation in mind, but could not find it now. Instead I found &lt;a href=&quot;http://foges.github.io/pogs/&quot; rel=&quot;noreferrer&quot;&gt;POGS&lt;/a&gt; which seems to be more recent and targeting the GPU. The documentation has its own &lt;a href=&quot;http://foges.github.io/pogs/ref/admm.html&quot; rel=&quot;noreferrer&quot;&gt;summary of ADMM&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: The paper &lt;a href=&quot;https://web.stanford.edu/~boyd/papers/block_splitting.html&quot; rel=&quot;noreferrer&quot;&gt;Block Splitting for Distributed Optimization&lt;/a&gt; might have been my original exposure to this idea.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-10-13T11:09:19.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2805" PostTypeId="2" ParentId="180" CreationDate="2019-10-13T13:14:32.140" Score="1" Body="&lt;p&gt;To complement the other answers, one can also approach this using piecewise McCormick relaxations. References and examples for how this works can be found &lt;a href=&quot;http://minlp.cheme.cmu.edu/2014/papers/castro.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://arxiv.org/pdf/1707.02514.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="2513" LastActivityDate="2019-10-13T13:14:32.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2807" PostTypeId="2" ParentId="2549" CreationDate="2019-10-13T13:42:01.663" Score="3" Body="&lt;p&gt;In general, no, as Gradient Descent (G)D is designed primarily for unconstrained continuous problems. However, you &lt;em&gt;might&lt;/em&gt; get somewhere if you formulate your problem such that the constraints and integrality conditions are penalized in the objective and apply GD on that. &lt;/p&gt;&#xA;" OwnerUserId="2513" LastActivityDate="2019-10-13T13:42:01.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2808" PostTypeId="1" CreationDate="2019-10-13T16:38:53.980" Score="3" ViewCount="774" Body="&lt;p&gt;Arrivals at a telephone booth are considered to be Poisson with an average time of 10 minutes between one arrival and the next. The length of phone calls is assumed to be distributed exponentially, with a mean of 3 minutes.  What is the probability that a person arriving at the booth will have to wait?&lt;/p&gt;&#xA;" OwnerUserId="2517" LastEditorUserId="123" LastEditDate="2019-10-13T19:29:39.580" LastActivityDate="2019-10-13T19:29:39.580" Title="Question about a queueing problem" Tags="|probability-distributions|queuing-theory|probability-theory|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2809" PostTypeId="2" ParentId="2808" CreationDate="2019-10-13T18:41:38.763" Score="3" Body="&lt;p&gt;This is a &lt;span class=&quot;math-container&quot;&gt;$M/M/1$&lt;/span&gt; queue with Poisson arrival distribution with &lt;span class=&quot;math-container&quot;&gt;$\lambda =1/10$&lt;/span&gt; and Exponential service distribution with &lt;span class=&quot;math-container&quot;&gt;$\mu=1/3$&lt;/span&gt;. The proportion of the time that the system is busy can be calculated by using the following equation:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\rho=\frac{\lambda}{\mu} = \frac{1/10}{1/3}=0.3$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which is exactly the proportion of time that a person arriving at the booth should wait while the server (telephone booth) is busy. So for a person arriving to the booth the probability of finding the booth busy is &lt;span class=&quot;math-container&quot;&gt;$0.3$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://web.mst.edu/~gosavia/queuing_formulas.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; document will help you understand the basics of queueing models and Kendall's notation for queues. &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-10-13T19:10:13.983" LastActivityDate="2019-10-13T19:10:13.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2810" PostTypeId="1" AcceptedAnswerId="2811" CreationDate="2019-10-13T22:17:47.863" Score="11" ViewCount="565" Body="&lt;p&gt;It seems like most solvers that can tackle nonlinear nonconvex optimization problems (e.g. IPOPT) operate on ultimately solving for the first-order optimality conditions. Can it therefore be assumed that these solvers do not guarantee convergence to a local minimzer, since saddle points and maximizers also satisfy the optimality conditions? If this is the case, what techniques do solvers use to try and avoid the points that are not minimizers (if at all)?&lt;/p&gt;&#xA;" OwnerUserId="2513" LastEditorUserId="38" LastEditDate="2019-10-15T12:23:41.810" LastActivityDate="2019-10-15T12:23:41.810" Title="Solvers and saddle points" Tags="|solver|nonlinear-programming|nonconvex-programming|global-optimality|optimality-conditions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2811" PostTypeId="2" ParentId="2810" CreationDate="2019-10-13T23:03:03.787" Score="12" Body="&lt;p&gt;While iteratively approximately solving the first order Karush-Kuhn-Tucker conditions, many (nonconvex) nonlinear solvers &lt;strong&gt;&quot;roll downhill&quot;&lt;/strong&gt;, i.e., enforce descent (for minimization) of the objective function for algorithms which attain and maintain primal feasibility, or improvement in a merit function (or similarly with filter methods) for algorithms which don't immediately attain and maintain primal feasibility. This is often accomplished by line search or trust regions (in which whether tentative step is accepted and trust region size is changed depends on improvement in the objective function relative to what was expected).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of these techniques generally guarantee convergence to a local minimum (for minimization), as opposed to a local maximum or saddle point, but they tend to help. They are very unlikely to &quot;land&quot; (terminate) on a local maximum, although this can happen at the starting point if it happens to be a local maximum and second order conditions are not checked.  Most of these algorithms tend not to terminate at saddle points, but they can, and the propensity for doing so depends on the algorithm, the details of its implementation, and the problem and starting point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not common, but it is possible to add a(n optional) second order optimality check, presuming the Hessian of the Lagrangian can be computed or adequately approximated. Note that a BFGS Hessian estimate is useless for this purpose as it artificially maintains positive semidefinitenss.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second order KKT conditions are as follows: A point satisfying 1st order KKT conditions and for which objective function and constraints are twice continuously differentiable is (sufficient for) a local minimum if the the Hessian of the Lagrangian projected into the nullspace of the Jacobian of active constraints is positive semidefinite. Letting &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; be a basis for the nullspace of the Jacobian of active constraints, second order KKT condition is that &lt;span class=&quot;math-container&quot;&gt;$Z^THZ$&lt;/span&gt; is positive semi-definite, where &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; is the Hessian of the Lagrangian. If  &lt;span class=&quot;math-container&quot;&gt;$Z^THZ$&lt;/span&gt; is indefinite, i.e., has at least one positive eigenvalue and at least one negative eigenvalue, then the point is a saddle point. Active constraints consist of all equality constraints plus all inequality constraints which are satisfied with equality at the point under consideration. If no constraints are active at the 1st order KKT point under consideration, the identity matrix is a nullspace basis &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;, and all Lagrange multipliers must be zero, therefore, the second order necessary condition for a local minimum reduces to the familiar condition from unconstrained optimization that the Hessian of the objective function is positive semidefinite. If all constraints are linear, the Hessian of the Lagrangian = Hessian of objective function because the 2nd derivative of a linear function = 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good book to learn in depth about much of this is &lt;a href=&quot;https://www.springer.com/gp/book/9780387303031&quot; rel=&quot;noreferrer&quot;&gt;&quot;Numerical Optimization&quot;, Nocedal and Wright&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-10-15T12:16:30.807" LastActivityDate="2019-10-15T12:16:30.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2812" PostTypeId="2" ParentId="2782" CreationDate="2019-10-13T23:36:51.157" Score="3" Body="&lt;p&gt;Based on a clarification in the comment, you have &lt;code&gt;KeyError&lt;/code&gt; and more or less, this is what's happening:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're looking at an index or key (in your dictionary) that doesn't exist and those are keys related to indices &lt;code&gt;j-1&lt;/code&gt; and &lt;code&gt;p-1&lt;/code&gt;. What you need to do is not to loop over all &lt;code&gt;set_J&lt;/code&gt; and &lt;code&gt;set_OP&lt;/code&gt;. So, for example, assuming &lt;code&gt;set_J = {1,2,3}&lt;/code&gt;, you can't have an index of &lt;code&gt;j=0&lt;/code&gt; which happens for the first time when &lt;code&gt;p=1&lt;/code&gt; and &lt;code&gt;j=1&lt;/code&gt; in your loop and &lt;code&gt;X_var[p-1, w, c, j-1]= X_var[0, 1, 1, 0]&lt;/code&gt;. One way to avoid that is to say something like &lt;code&gt;for j in range(2, len(set_J)+1)&lt;/code&gt; (Note that the idea is the same even if your &lt;code&gt;set_J&lt;/code&gt; or &lt;code&gt;set_OP&lt;/code&gt; are defined using other Python objects). Do the same thing for &lt;code&gt;set_OP&lt;/code&gt; too.&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-10-13T23:51:27.373" LastActivityDate="2019-10-13T23:51:27.373" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2813" PostTypeId="2" ParentId="2794" CreationDate="2019-10-14T00:40:08.663" Score="8" Body="&lt;p&gt;As a developer of parallel non-linear software, I want to share my experience working in this space and the challenges we face. If I were to break down why we don't have more parallel non-linear software I would pick the following reasons:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Expectations vs reality&lt;/li&gt;&#xA;&lt;li&gt;Inherent difficulties in designing and implementing the algorithms.&lt;/li&gt;&#xA;&lt;li&gt;Lack of good tools to implement, test, and deploy distributed software.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1.  Expectations vs reality&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, NLP or MINLP are very broad terms so people tend to expect a piece of software that solves e.g., NLP to solve every type of NLP, which simply cannot happen. That NLP may be sparse, dense, mostly linear, convex, pseudoconvex, large, small, parametric, etc. In every case, there are different optimal ways of exploiting parallel hardware, but building a piece of software that implements all of these ways is incredibly difficult, which is why we have several specialised packages. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, parallelism in non-linear optimisation is tricky from a design point of view because how we choose to allocate parallel resources depends on the real-life problems our solver is designed to solve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are three main applications of parallelism for MINLPs:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Calculating derivatives in parallel (important in very dense problems)&lt;/li&gt;&#xA;&lt;li&gt;Doing the factorisation step in parallel (important in very large problems)&lt;/li&gt;&#xA;&lt;li&gt;Solving the problem many times in parallel, e.g., parallel branch-and-bound or multistart (important in MINLP problems)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;A solver can only really do one of these in parallel, and that design choice determines what problems that solver can solve well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, with some tweaking IPOPT can run MUMPS in MPI mode, so if factorisation is the bottleneck, that's a solid choice. This makes sense for IPOPT as it is designed to do a single local optimisation as quickly as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, our own solver, &lt;a href=&quot;https://octeract.com/dgo-engine/&quot; rel=&quot;noreferrer&quot;&gt;Octeract Engine&lt;/a&gt;, is designed to prove global optimality and to locate feasible solutions for difficult MINLP problems. Therefore, for us it made sense to use parallel branch-and-bound because we need to solve millions of local optimisation problems, so when we run in MPI mode that's how we allocate work to the CPUs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other examples with various degrees of parallelism are SCIP, KNITRO, and NLPAROPT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if one was to use IPOPT with MPI-MUMPS for a large-scale local optimisation problem, that would be much faster than a parallel branch-and-bound solver, &lt;strong&gt;if IPOPT manages to solve the problem&lt;/strong&gt;. If it doesn't, it often turns out that no amount of manual tweaking can yield a feasible solution in which case parallel branch-and-bound would have saved us time all along. Similarly, certain problems are just too big to feed into a solver that doesn't factorise a matrix in parallel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These differences in expectations vs what the scientific reality is, mean that solver companies usually have to engage a lot in consultancy work (vs just building more and better stuff), and that academic projects rarely come to a state where they are usable by the community (IPOPT is a bright exception).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. Algorithmic/Implementation difficulties&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From an implementation point of view, it is hellishly difficult to come up with and implement a parallel framework correctly. As an example, it took us about a year to implement the parallel framework for Octeract Engine (and this is a team of people who had done this before). For the problems that our engine solves, we implemented so-called &quot;true parallelism&quot;, in the sense that investing more CPUs results in linear speedups. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it took me 5 years to create and test the algorithm that achieves this (my PhD and post-doc). The reason this takes so long is that a high performance algorithm is never something we can implement by reading/creating a flowchart. In other words, it never &quot;just works&quot;. It takes hundreds of tricks (the term is literally &quot;advanced black magic&quot;) to make these kinds of algorithms work well in practice. Importantly, it takes much more effort than LP algorithms, because the structure we can expect in NLP can literally be anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On top of that, parallel computing applications tend to target large problems. The size factor comes with a plethora of issues around data structures, distributing memory, and actually thinking about the complexity of every tiny part of the solver to avoid bottlenecks, which are non-issues for smaller problems. All of this blends into one big interactive system that is very hard to design using good software practices without compromising performance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3. Lack of tools for development, deployment and testing&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Algorithmic difficulties aside, a big bottleneck is that our best choice for high throughput applications is MPI, which is simply just not a good enough tool anymore because it requires too much boilerplate and modern software is just too complex for that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is compounded by the fact that even when we do make it work on our rigs it comes with a host of portability, deployment, and maintenance issues. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, after solver development was done, it took us around 4 months of full-time testing to ensure that it would run on all OS/hardware, and I swear that we ran into every single obscure issue in the history of Linux in the process (can't deny that it was a lot of fun though). We saw compiler bugs, kernel bugs, dependencies that would only build if we tried twice, linking problems that only happened some of the time even on the same machine, but my favorite is an issue where MPI would fail to work 1 in 10 times, and only if we used more than 60 cores (59 or fewer was fine).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even then, we still have a few tickets of obscure issues that only occur when people run massive problems on clusters, and it can take a lot of time to reproduce and fix each one because we have to build our own tools most of the time (there's nothing we can buy out of the box).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From our point of view, we would love to have better tools because it would allow us to spend less manpower on maintenance and testing, and more on R&amp;amp;D and implementing new parallel algorithms.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-10-14T00:40:08.663" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2815" PostTypeId="1" CreationDate="2019-10-14T04:09:01.543" Score="11" ViewCount="99" Body="&lt;p&gt;Say I want to do Portfolio Optimization using the mean-variance approach (i.e Markowitz model), but that some of my assets are new with no returns history. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can use a judgmental (expert knowledge, not statistic based) forecast to come up with mean expected return values from my new assets, but how can we estimate variances and coefficients of correlation for the new assets?   &lt;/p&gt;&#xA;" OwnerUserId="1315" LastEditorUserId="1315" LastEditDate="2019-10-14T08:48:37.293" LastActivityDate="2019-10-15T09:21:41.473" Title="In portfolio optimization, how do we estimate the variance of a new asset?" Tags="|optimization|finance|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2816" PostTypeId="2" ParentId="2786" CreationDate="2019-10-14T08:37:09.273" Score="1" Body="&lt;p&gt;You can use the linear constraint function to add additional constraints which prohibit mutually exclusive pairs. I'd imagine that each mini package has to be scheduled on one date so this leads to the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;for (product_a, product_b) in conflict_list:&#xA;    mps_with_productb = [mp for mp, p in enumerate(products) where p == product_b]&#xA;    for mp1 in [mp for mp, p in enumerate(products) where p == product_a]:&#xA;        model.AddLinearConstraint(sum(x[mp1,i,k] for i in shipping_dates for k in package_numbers) + sum(x[mp2,i,k] for mp2 in mps_with_productb for i in shipping_dates for k in package_numbers), 1, 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will force only one of the variables to be 1, thus, for a given mini package &lt;code&gt;mp1&lt;/code&gt; which has &lt;code&gt;product_a&lt;/code&gt; no other mini package which has &lt;code&gt;product_b&lt;/code&gt; can be scheduled in the same package. If you do not have to ship all mini packages then change the first 1 to a 0.&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="137" LastEditDate="2019-10-14T14:24:41.233" LastActivityDate="2019-10-14T14:24:41.233" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2817" PostTypeId="1" AcceptedAnswerId="2819" CreationDate="2019-10-14T11:11:11.520" Score="17" ViewCount="2499" Body="&lt;p&gt;I know that the standard duality theory for the linear programming problem does not hold for mixed integer linear programming problems. I was wondering why an integer program does not have a dual problem and whether this extends to any integer program?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, an integer program with a totally unimodular coefficient matrix has integral extreme points. Does this property hold for the dual of such a linear program? What can be said about duality of integer programs in general?&lt;/p&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2019-10-14T14:48:51.950" Title="Duality in mixed integer linear programs" Tags="|mixed-integer-programming|linear-programming|integer-programming|combinatorial-optimization|duality|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2818" PostTypeId="1" CreationDate="2019-10-14T11:15:16.430" Score="5" ViewCount="42" Body="&lt;p&gt;Imagine we are running a logistic regression to identify opportunities for car sale promotion, using previous promotion campaign's result. Each &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is the increase of car sale after the promotion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there is a problem here: once we launch a campaign and boost the sales for a specific month, another campaign in the next month won't boost the sales anymore, because anyone who wants to buy a car would have bought it in the first promotion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, although the samples are independent, the results of the regression are NOT independent, because we are dealing with a dynamic system. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably we can add some predictors into the regression model, such as 'duration since last promotion', to make the prediction more realistic. That being said, just from a theoretical perspective, &lt;em&gt;without&lt;/em&gt; introducing any new predictors, is there a way to introduce a constraint into the regression model, so that the resulting positive predictions are 'sparse' in some sense?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several ways we can define sparsity here. In a simple sense, we can demand that, if one sample is classified as &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, the next &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; samples must be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, or cannot contain more than &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;'s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, we can demand that the sum of the distance between consecutive &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;'s must be above a threshold. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't really have a concert idea here. I think this looks like a control problem, similar to LQR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone share some ideas or provide some references?&lt;/p&gt;&#xA;" OwnerUserId="2402" LastEditorUserId="123" LastEditDate="2019-10-14T12:15:16.343" LastActivityDate="2019-10-14T12:15:16.343" Title="In a binary logistic regression context, how to introduce a constraint to model the dependency between consecutive samples" Tags="|optimization|linear-programming|nonlinear-programming|constraint-programming|optimal-control|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2819" PostTypeId="2" ParentId="2817" CreationDate="2019-10-14T13:05:28.960" Score="15" Body="&lt;p&gt;It is a difference whether one can dualize (or not) or that a duality theory holds (or not). Formally, you can formulate a dual of any integer program, e.g., by considering the linear relaxation, dualizing it, and then enforcing integrality again on the dual variables. It is already trickier which variables to consider as integer in the dual when you dualize a mixed-integer program; but for integer programs, this formally works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you are lucky, as in the cases you mention, e.g., that the coefficient matrix is TU (and the cost and RHS are integral), then the dual possesses the same nice properties as the primal, essentially since transposing a matrix (what happens when you dualize) does not destroy TUness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when you are unlucky, and this is what you usually are, the matrix does not have any such special property, neither the primal nor the dual are integer when only solving the linear relaxations. So, still, when you consider the two LP relaxations (the primal and the dual), of course they have the same objective function value (strong duality), after all, this is how you constructed the dual. Yet, when you impose integrality again, on the primal and the dual, you usually &lt;strong&gt;do not&lt;/strong&gt; get the same objective function value, there remains a &lt;strong&gt;duality gap&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may consider the maximum (cardinality) matching problem on a general undirected graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt;. You have a variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}\in\{0,1\}$&lt;/span&gt; whether edge &lt;span class=&quot;math-container&quot;&gt;$ij\in E$&lt;/span&gt; is in the matching or not. The classic model reads &lt;span class=&quot;math-container&quot;&gt;$$\max\left.\left\{\sum_{ij\in E}x_{ij} \,\,\right\vert\,\,  \sum_{ij\in E} x_{ij}\leq1 \;\forall i\in V,\; x_{ij}\in\{0,1\}\; \forall ij\in E\right\}\enspace.$$&lt;/span&gt; If you relax this, dualize (with a dual variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; per vertex &lt;span class=&quot;math-container&quot;&gt;$i\in V$&lt;/span&gt;), and impose integrality on the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;-variables again, you obtain  &lt;span class=&quot;math-container&quot;&gt;$$\min \left.\left\{\sum_{i\in V}y_i \,\,\right\vert\,\,  y_i+y_j\geq1 \;\forall ij\in E,\; y_i\in\{0,1\}\; \forall i\in V\right\}\enspace,$$&lt;/span&gt; which is the minimum vertex cover problem on &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;. If you consider a cycle of odd length, say length 5, you can match at most 2 pairs, but for covering all the edges you need at least 3 nodes, so the optima do not coincide. If &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;, however, is bipartite (like for a cycle of even length), the underlying node-edge incidence matrix is TU, and strong duality holds for the integer programs because they are, in fact, linear programs.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="354" LastEditDate="2019-10-14T14:48:51.950" LastActivityDate="2019-10-14T14:48:51.950" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2820" PostTypeId="1" AcceptedAnswerId="2823" CreationDate="2019-10-14T14:10:21.713" Score="8" ViewCount="472" Body="&lt;p&gt;I am trying to maximize the workload per employee.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; the index of an employee&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; the index of a project&lt;/li&gt;&#xA;&lt;li&gt;decision variable: &lt;span class=&quot;math-container&quot;&gt;$x_{e,j} \in \mathbb{Z}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0 \leq x_{e,j} \leq 100$&lt;/span&gt; deciding with how much percent an employee may work on a project. (Yes it is possible that an employee works on a project with 40%. The remaining 60% should get covered from someone else and all projects should get covered but this is not a part of this problem.)&lt;/li&gt;&#xA;&lt;li&gt;decision variable: &lt;span class=&quot;math-container&quot;&gt;$y_e \in \{0,1\}$&lt;/span&gt; deciding if employee e is working&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I had in mind something like the following as a part of the objective function &#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \max\sum\limits_{e,j}\frac{x_{e,j}}{y_e}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that this is not linear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;span class=&quot;math-container&quot;&gt;$\frac{160}{3} &amp;lt; \frac{160}{2}$&lt;/span&gt; thus 2 employees whould be preferred instead of 3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following constraint has to hold,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum\limits_e x_{e,j} = 1 \ \ \forall \ \ j $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;implying that all projects have to get covered.&lt;/p&gt;&#xA;" OwnerUserId="456" LastEditorUserId="456" LastEditDate="2019-10-15T10:28:50.017" LastActivityDate="2019-10-15T10:28:50.017" Title="Linearization of a scheduling objective function" Tags="|mixed-integer-programming|linearization|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2821" PostTypeId="2" ParentId="2820" CreationDate="2019-10-14T15:34:41.120" Score="5" Body="&lt;p&gt;Another approach to model the objective function could be the following where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a big number that forces the model to choose as few as possible numbers of operators.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max \sum_{e,j} x_{e,j}-M\times \sum_e y_e$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-10-14T19:23:40.007" LastActivityDate="2019-10-14T19:23:40.007" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2823" PostTypeId="2" ParentId="2820" CreationDate="2019-10-14T21:06:32.073" Score="4" Body="&lt;p&gt;You can linearize the objective function, but at the cost of more binary variables and big-M type constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's assume that we know &lt;em&gt;a priori&lt;/em&gt; that the number of employees used will be between 0 (or maybe 1) and &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;. Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$z_0, \dots, z_N$&lt;/span&gt; with the constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{k=0}^N z_k = 1.$$&lt;/span&gt;The &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; variables will determine how many employees are being used, via the constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_e y_e = \sum_k kz_k.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, introduce a continuous variable &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; representing the objective value (to be maximized) and continuous variables &lt;span class=&quot;math-container&quot;&gt;$S_0, \dots, S_k$&lt;/span&gt;, along with the linear constraints &lt;span class=&quot;math-container&quot;&gt;$$S_k =\frac{1}{k}\sum_{e,j} x_{e,j}\quad \forall k$$&lt;/span&gt;(so that &lt;span class=&quot;math-container&quot;&gt;$S_k$&lt;/span&gt; is the objective value you want &lt;em&gt;if&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; employees are used) along with the constraints &lt;span class=&quot;math-container&quot;&gt;$$S_k - \underline{M}_k (1-z_k) \le W \le S_k + \overline{M}_k (1-z_k)\quad \forall k,$$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$\underline{M}_k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\overline{M}_k$&lt;/span&gt; are sufficiently large constants (the sizes of which, as the notation suggests, may vary as &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; varies). This ensures that &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt;, the thing you are maximizing, equals &lt;span class=&quot;math-container&quot;&gt;$S_k$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$z_k=1$&lt;/span&gt; (i.e., you are using &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; workers).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-10-14T21:06:32.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2824" PostTypeId="2" ParentId="2815" CreationDate="2019-10-14T21:26:27.943" Score="7" Body="&lt;p&gt;If we accept that there is no really accurate way to do this (barring time travel, which introduces multiple paradoxes), one possible way to at least get something vaguely plausible would be to look for older assets with known variances that are &quot;similar&quot; to a new asset (same industry, comparable capitalization, being investigated by the same government agencies, ...) and then take a possibly weighted average of their variances and covariances. Now how you define similarity will be a whole new can of worms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume that &quot;new&quot; means &quot;newly on the market&quot;, not just &quot;new in my portfolio&quot;, since in the latter case the variances and covariances are out there somewhere waiting to be looked up. So, if &quot;new&quot; means &quot;recent IPO&quot;, you would want to look for older assets that were similar to the new ones around the time of the older ones' IPOs.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-10-14T21:26:27.943" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2825" PostTypeId="2" ParentId="2820" CreationDate="2019-10-15T06:08:05.890" Score="4" Body="&lt;p&gt;Suppose that, the following non-linear objective arises (MAX/MIN):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\max\frac{\sum\limits_{j} a_{j} x_{j}}{\sum\limits_{j} b_{j} x_{j}}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Replace the expression &lt;span class=&quot;math-container&quot;&gt;$\dfrac{1}{\sum\limits_{j} b_{j} x_{j}}$&lt;/span&gt; by a variable &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Represent the products &lt;span class=&quot;math-container&quot;&gt;$x_{j} t$&lt;/span&gt; by variables &lt;span class=&quot;math-container&quot;&gt;$w_{j}$&lt;/span&gt;. The objective now becomes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\max \sum_{j} a_{j} w_{j}.&#xA;\end{equation}&lt;/span&gt;&#xA;Introduce a constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{j} b_{j} w_{j}=1&#xA;\end{equation}&lt;/span&gt;&#xA;in order to satisfy condition 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Convert the original constraints of the form:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{j} d_{j} x_{j} &amp;amp;\leqq e \\&#xA;\sum_{j} d_{j} w_{j}-e t &amp;amp;\leqq 0&#xA;\end{align}&lt;/span&gt;&#xA;It must be pointed out that this transformation is only valid if the denominator &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{j} b_{j} x_{j}$&lt;/span&gt; is always of the same sign and non-zero. If necessary (and it is valid), an extra constraint must be introduced to ensure this. If &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{j} b_{j} x_{j}$&lt;/span&gt; always be negative the directions of the inequalities in the constraints above must, of course, be reversed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference: &lt;a href=&quot;https://www.wiley.com/en-ir/Model+Building+in+Mathematical+Programming%2C+5th+Edition-p-9781118443330&quot; rel=&quot;nofollow noreferrer&quot;&gt;Model Building in Mathematical Programming&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2019-10-15T07:43:30.297" LastActivityDate="2019-10-15T07:43:30.297" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2826" PostTypeId="2" ParentId="2815" CreationDate="2019-10-15T09:21:41.473" Score="1" Body="&lt;p&gt;You can try the &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Black%E2%80%93Litterman_model&quot; rel=&quot;nofollow noreferrer&quot;&gt;Black-Litterman&lt;/a&gt; model, which allows to rate the relative expectations on the returns of assets. Because this evaluation does not necessarily rely on historical data it allows the incorporation of new assets.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-10-15T09:21:41.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2827" PostTypeId="2" ParentId="61" CreationDate="2019-10-15T12:38:49.673" Score="4" Body="&lt;p&gt;You might be surprised how much OR algorithm code is open source:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kiegroup/optaplanner&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner (Java) is on Github&lt;/a&gt;, including algorithm's such as:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kiegroup/optaplanner/blob/master/optaplanner-core/src/main/java/org/optaplanner/core/impl/localsearch/decider/acceptor/lateacceptance/LateAcceptanceAcceptor.java#L65&quot; rel=&quot;nofollow noreferrer&quot;&gt;Late Acceptance Hill Climbing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kiegroup/optaplanner/blob/master/optaplanner-core/src/main/java/org/optaplanner/core/impl/localsearch/decider/acceptor/tabu/EntityTabuAcceptor.java&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tabu Search&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kiegroup/optaplanner/blob/master/optaplanner-core/src/main/java/org/optaplanner/core/impl/localsearch/decider/acceptor/simulatedannealing/SimulatedAnnealingAcceptor.java&quot; rel=&quot;nofollow noreferrer&quot;&gt;Simulated Annealing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;First Fit&lt;/li&gt;&#xA;&lt;li&gt;Cheapest Insertion&lt;/li&gt;&#xA;&lt;li&gt;Brute Force&lt;/li&gt;&#xA;&lt;li&gt;Branch and Bound&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://bitbucket.org/account/user/oscaremr/projects/OSCAR&quot; rel=&quot;nofollow noreferrer&quot;&gt;Oscar (Scala) is on BitBucket&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/chocoteam/choco-solver/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Choco (Java) is on GitHub&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now, the thing is that production solvers can complexify the algorithm. For example, if you look at the &lt;a href=&quot;https://github.com/kiegroup/optaplanner/blob/master/optaplanner-core/src/main/java/org/optaplanner/core/impl/localsearch/DefaultLocalSearchPhase.java#L62&quot; rel=&quot;nofollow noreferrer&quot;&gt;Local Search solver phase code&lt;/a&gt; in OptaPlanner, you'll see the Local Search algorithm, but much is hidden behind the &lt;code&gt;decideNextStep()&lt;/code&gt; method, which has an &lt;a href=&quot;https://github.com/kiegroup/optaplanner/blob/master/optaplanner-core/src/main/java/org/optaplanner/core/impl/localsearch/decider/LocalSearchDecider.java#L104&quot; rel=&quot;nofollow noreferrer&quot;&gt;single-threaded implementation&lt;/a&gt; that is understandable, but also a &lt;a href=&quot;https://github.com/kiegroup/optaplanner/blob/master/optaplanner-core/src/main/java/org/optaplanner/core/impl/localsearch/decider/MultiThreadedLocalSearchDecider.java#L144&quot; rel=&quot;nofollow noreferrer&quot;&gt;multi-threaded implementation&lt;/a&gt; that is much harder to read.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2019-10-15T17:54:23.753" LastActivityDate="2019-10-15T17:54:23.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2828" PostTypeId="1" AcceptedAnswerId="2829" CreationDate="2019-10-15T15:54:22.427" Score="13" ViewCount="1227" Body="&lt;p&gt;I have a constraint that I believe to be convex and not affine which I think means that I can implement a relaxation. I will first define the full constraint, and then build up my (informal) reasoning as to why I think it's convex. Hopefully the holes in my thinking can be pointed out and corrected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$   X_{t} = \frac{ Y_{t-1}^2 }{Y_{t-1}^2 + a^2}Z_{t-1}, \quad t=1,2,\dots,T \tag1 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ X_t,Y_t,Z_t \ge 0, $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ X_0, Y_0, Z_0, \alpha  \gt 0 $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Argument 1:&lt;/strong&gt;  A quadratic polynomial is convex, so if the constraint was simply &lt;span class=&quot;math-container&quot;&gt;$ X_{t} = Y_{t-1}^2$&lt;/span&gt; then the constraint would be convex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Argument 2:&lt;/strong&gt; By a similar extension, &lt;span class=&quot;math-container&quot;&gt;$ X_{t} = Y_{t-1}^2 + \alpha^2 $&lt;/span&gt; would be convex. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Argument 3:&lt;/strong&gt; The ratio of two convex functions, call it &lt;span class=&quot;math-container&quot;&gt;$F_{t-1}$&lt;/span&gt;, should also be convex. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Argument 4:&lt;/strong&gt; If &lt;span class=&quot;math-container&quot;&gt;$F_{t-1}$&lt;/span&gt; is convex, then multiplying &lt;span class=&quot;math-container&quot;&gt;$F_{t-1}$&lt;/span&gt; by a continuous linear variable would not impose any non-convexity issues. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt; The original constraint is convex but not affine and as such we can apply a relaxation to change the problem into:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$   X_{t} \le \frac{ Y_{t-1}^2 }{Y_{t-1}^2 + a^2}Z_{t-1}, \quad t=1,2,\dots,T \tag1 $$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="68" LastEditDate="2019-10-17T15:45:58.847" LastActivityDate="2019-10-17T15:45:58.847" Title="Is This Constraint Convex?" Tags="|constraint|convexity|nonconvex-programming|lp-relaxation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2829" PostTypeId="2" ParentId="2828" CreationDate="2019-10-15T16:01:51.567" Score="18" Body="&lt;p&gt;Arguments 3 and 4 are incorrect. The Right-Hand Side (RHS) is not convex. Even if it were, setting a nonlinear equality with either side non-affine is non-convex. As the final coup de grace, even if the RHS were convex, an inequality, {affine expression} &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; {convex RHS}, is going the wrong direction to be convex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you study sections 2.3 and especially 3.2, both named &quot;Operations that preserve convexity&quot; of &lt;strong&gt;&lt;a href=&quot;http://web.stanford.edu/~boyd/cvxbook/bv_cvxbook.pdf&quot; rel=&quot;noreferrer&quot;&gt;Convex Optimization, by Boyd and Vandenberghe&lt;/a&gt;&lt;/strong&gt; which is freely available at the linked website of one of the authors.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-10-15T17:07:07.790" LastActivityDate="2019-10-15T17:07:07.790" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2830" PostTypeId="2" ParentId="2799" CreationDate="2019-10-15T18:28:51.600" Score="2" Body="&lt;p&gt;Your &quot;cycle times&quot; are round numbers. (20 min, 60 min, 20 min respectively). Are these numbers &lt;em&gt;measured and observed&lt;/em&gt; cycle times, or are they allocated time for the task?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are seeing work build up, then the actual work likely varies from your planned time. What is the actual time? Measure the time of &lt;em&gt;each actual cycle&lt;/em&gt; - plot them on a run chart. Look at how much variation there is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The more variation there is, the more you have to &quot;pad&quot; the resources. &#xA;If you have to pad the resources to get the work done, then this is likely what is happening.&lt;/p&gt;&#xA;" OwnerUserId="2534" LastActivityDate="2019-10-15T18:28:51.600" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2831" PostTypeId="1" CreationDate="2019-10-15T18:53:21.683" Score="10" ViewCount="2835" Body="&lt;p&gt;I was reading an article on supply chain management and encountered a number of inventory costs like ordering, carrying, shortage, holding, storage costs. I cannot understand the difference between holding, carrying and storage cost. Literally these costs sound the same. But the article mentions separate costs for these terms. Web searches didn't clear my confusion. Certain sites say that holding cost and carrying cost are the same. Certain says they are not the same. Kindly differentiate these costs.&lt;/p&gt;&#xA;" OwnerUserId="2535" LastActivityDate="2019-10-15T22:55:51.210" Title="Holding cost vs carrying cost vs storage cost" Tags="|inventory|supply-chain|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2832" PostTypeId="2" ParentId="2828" CreationDate="2019-10-15T18:55:31.493" Score="13" Body="&lt;p&gt;Counterexamples to your arguments:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Argument 1:&#xA;Only affine equality constraints are convex, &lt;span class=&quot;math-container&quot;&gt;$x = y^2$&lt;/span&gt; is not convex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Argument 3:&#xA;Take &lt;span class=&quot;math-container&quot;&gt;$f(x) = x^4$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g(x) = x$&lt;/span&gt;. Both are convex, but the ratio &lt;span class=&quot;math-container&quot;&gt;$h(x) = \frac{x^4}{x} $&lt;/span&gt; is not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Argument 4:&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$f(x) = x$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{R}$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is convex, but &lt;span class=&quot;math-container&quot;&gt;$g(x, y) = yf(x) = xy$&lt;/span&gt; is not.&lt;/p&gt;&#xA;" OwnerUserId="47" LastActivityDate="2019-10-15T18:55:31.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2833" PostTypeId="2" ParentId="2831" CreationDate="2019-10-15T20:24:19.417" Score="7" Body="&lt;p&gt;According to a buddy of mine who was a faculty member in the area of purchasing / sourcing / procurement (they change their name every few years), &quot;holding cost&quot; and &quot;carrying cost&quot; are used pretty much interchangeably. They include costs to operate storage facilities, pilferage, spoilage, insurance and opportunity cost of capital tied up in inventory. He is not familiar with any formal use of &quot;storage cost&quot;. One might speculate that it could be direct costs of storing stuff (facility operating costs, pilferage, spoilage, maybe insurance) but not including cost of capital. Maybe.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-10-15T20:24:19.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2834" PostTypeId="2" ParentId="2831" CreationDate="2019-10-15T22:27:23.910" Score="3" Body="&lt;p&gt;The unit of each cost shows the nature of that type of cost. With that, I mean if you look through the units, you can easily figure out whether:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The cost is fixed (it is independent of the inventory amount of products). For instance, the cost of operating a storage facility which does not depend on whether you store one unit of product or many units.&lt;/li&gt;&#xA;&lt;li&gt;The cost is variable and can be calculated based on the amount of the product in your facility, for example, the cost of storing one car engine is different than that for 1000 engines. This cost can include carrying costs for instance. If your products(by nature) are affected by the length of time that you hold them on the shelf, your holding cost is a variable cost as well.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As you see, based on the &lt;em&gt;assumptions&lt;/em&gt; that each paper has, your costs can be defined either as a fixed or variable cost interchangeably. Based on what I have mentioned(and of course based on the definitions in the paper) those costs can be defined as follow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;Holding cost:&lt;/em&gt; variable cost which depends on the number of units of a product that you have in the inventory and the length of time that you keep those products on the shelf.&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Carrying cost:&lt;/em&gt; variable cost which depends on the number of units and the distances that each unit of product is being carried inside the storage or from supplier to the storage location.&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Storage cost:&lt;/em&gt; fixed cost that can include all the costs related to the opening and operating a storage center.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I hope it makes sense for you after re-investigating those costs in the paper.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-10-15T22:27:23.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2835" PostTypeId="2" ParentId="2831" CreationDate="2019-10-15T22:55:51.210" Score="7" Body="&lt;p&gt;I agree that &lt;em&gt;holding cost&lt;/em&gt;, &lt;em&gt;carrying cost&lt;/em&gt;, and &lt;em&gt;storage cost&lt;/em&gt; all sound like the same thing. The only thing I will add to the answer by @prubin is that often holding costs are expressed as a percentage of the value of the product. So, you might have a holding cost &lt;em&gt;rate&lt;/em&gt; of &lt;span class=&quot;math-container&quot;&gt;$i=25\%$&lt;/span&gt; and a product value of &lt;span class=&quot;math-container&quot;&gt;$c=200$&lt;/span&gt;, in which case the holding &lt;em&gt;cost&lt;/em&gt; is &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt;. Perhaps the article is using one of those terms (holding/carrying/storage) to refer to the &lt;em&gt;rate&lt;/em&gt; and another to refer to the &lt;em&gt;cost&lt;/em&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, I would say that any distinction between those terms is idiosyncratic to that article. In other words, that article might define them a certain way, but other articles/books will define them in different ways, and/or use them interchangeably.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-10-15T22:55:51.210" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2836" PostTypeId="1" CreationDate="2019-10-16T02:59:10.087" Score="8" ViewCount="116" Body="&lt;p&gt;Consider a three level supply chain consisting of a manufacturer, a wholesaler and a retailer. Suppose I wish to include a buyback contract to this network. Then am I right when I say that wholesaler buys unsold items from the retailer at a specific buyback price. Similar is the case between manufacturer and wholesaler. But what does a manufacturer do with unsold goods? Suppose the product is perishable say a food item.&lt;/p&gt;&#xA;" OwnerUserId="2535" LastEditorUserId="2535" LastEditDate="2019-10-17T04:35:50.580" LastActivityDate="2019-10-17T04:35:50.580" Title="Buyback policy in a supply chain" Tags="|supply-chain|supply-chain-contracts|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2837" PostTypeId="1" AcceptedAnswerId="2838" CreationDate="2019-10-16T04:31:18.823" Score="8" ViewCount="3569" Body="&lt;p&gt;I am creating an optimization model with 2 sets of binary decision variables. The first, &lt;code&gt;site&lt;/code&gt;, is regarding which of 380 cities to place manufacturing sites in, and the second, &lt;code&gt;ASSG&lt;/code&gt; is regarding which of 12 cities each manufacturing site will be assigned to service.  There will be 3 manufacturing sites total.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to add a constraint that the sum of all cities serviced by a &lt;em&gt;potential&lt;/em&gt; manufacturing site is the number of cities that need serviced, &lt;code&gt;12&lt;/code&gt;, but this limit needs to be &lt;code&gt;0&lt;/code&gt; if a manufacturing site is not placed in that location.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is difficult for me to explain so I've included a screenshot of the Excel model I am trying to scale-up using Python.  The &quot;Logical constraint&quot; is what I am trying to code into Python:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qLrmc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qLrmc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this code is a bit of a mess, I'm not great with dictionaries and there's too much going on here for me to keep track of it, but this is what I have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;site = m.addVars(siteLoc, vtype=GRB.BINARY, name='site')  # siteLoc is a list of 380 potential mfg site locations&#xA;ASSG = m.addVars(siteASSG, vtype=GRB.BINARY, name='ASSG') # siteASSG is a gurobi tuplelist of the format: (potential mfg site location, one of 12 cities mfg site will service)&#xA;m.update()&#xA;&#xA;m.addConstr(sum(val for key, val in ASSG.items() if key[0] == k for k in site.keys()) &amp;lt;= 12 * val for key, val in site.items())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2393" LastEditorUserId="2393" LastEditDate="2019-10-16T14:20:51.703" LastActivityDate="2019-10-16T14:20:51.703" Title="How can I add this conditional constraint to my model in Python?" Tags="|optimization|python|gurobi|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2838" PostTypeId="2" ParentId="2837" CreationDate="2019-10-16T07:41:27.697" Score="4" Body="&lt;p&gt;If I understood the problem correctly, you can have &lt;span class=&quot;math-container&quot;&gt;$380$&lt;/span&gt; binary variables  &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; that can be defined as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{i}=\begin{cases}&#xA;1, &amp;amp; \text{If location}\,\,i \,\,\text{has been selected for a manufacturing site}\\&#xA;0, &amp;amp; \text{Otherwise} \\&#xA;\end{cases}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and for the chosen sites: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y_{ij}=\begin{cases}&#xA;1, &amp;amp; \text{If site}\, \, i \, \, \text{serves city} \, j\\&#xA;0, &amp;amp; \text{Otherwise} \\&#xA;\end{cases}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then you need to add the following constraints to your model:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases}\sum\limits_i x_{i}=3 \ \ \forall i \in \{1,2,\dots,380\}\\\sum\limits_j y_{ij} \le 12 \ \ \forall i \in \{\text{chosen sites}\}\\\sum\limits_i y_{ij}=1 \ \ \forall i \in \{\text{chosen sites}\}\,\,\text{and} \ \ \forall j \in \{1,2,\cdots,12\}\end{cases}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;first and second constraints can be combined to force the model to assign the &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; cities to those &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; cities (out of &lt;span class=&quot;math-container&quot;&gt;$380$&lt;/span&gt; potentials) that have a manufacturing site placed in. The constraint would be as follow:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_j y_{ij} \le 12 \times x_i  \ \ \forall i$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, to define the aforementioned constraint in Python (the code is based on Pyomo but I believe it is almost the same if you use solver interfaces as well):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import numpy as np&#xA;from pyomo.environ import *&#xA;model.sites = set(np.arange(1,381)) #Index for the potential locations&#xA;model.cities  = set(np.arange(1,13)) #Index for the 12 cities with demands&#xA;cons = pyomo.constraint((sum y[i,j] for j in model.cities) &amp;lt;= 12*x[i] for i in model.sites) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-10-16T08:18:36.163" LastActivityDate="2019-10-16T08:18:36.163" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2839" PostTypeId="1" CreationDate="2019-10-16T09:18:27.110" Score="8" ViewCount="204" Body="&lt;p&gt;In the calculus of variations (unconstrained), one applies a first-order variation on a general functional of the form&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\int_{a}^{b}F(x,y,y')\,dx$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to obtain the first-order necessary condition for optimality as expressed by the Euler-Lagrange equality&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{d}{dx}F_{y'} -F_y = 0.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the necessary condition for a minima? How about a sufficient condition? &lt;/p&gt;&#xA;" OwnerUserId="2513" LastEditorUserId="123" LastEditDate="2019-10-16T12:03:24.393" LastActivityDate="2019-11-16T20:21:02.377" Title="Conditions for minima in calculus of variations" Tags="|optimality-conditions|optimal-control|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2840" PostTypeId="2" ParentId="2839" CreationDate="2019-10-16T09:26:28.550" Score="6" Body="&lt;p&gt;Coming from the world of optimal control, I tend to view the calculus of variations from a &lt;a href=&quot;https://en.wikipedia.org/wiki/Pontryagin%27s_maximum_principle&quot; rel=&quot;noreferrer&quot;&gt;Pontryagin&lt;/a&gt; point of view. The conditions stated by Pontryagin are necessary, and sufficient under certain hypotheses (mainly related to the convexity of the function &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt;). I used to refer to this article during my PhD:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://epubs.siam.org/doi/10.1137/0304013&quot; rel=&quot;noreferrer&quot;&gt;O. L. Mangasarian, Sufficient Conditions for the Optimal Control of Nonlinear Systems&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2452" LastActivityDate="2019-10-16T09:26:28.550" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2841" PostTypeId="2" ParentId="2839" CreationDate="2019-10-16T09:35:07.457" Score="6" Body="&lt;p&gt;It is possible to apply the notions of stationary points and the second derivative of a function to functionals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$|\varepsilon|\ll1$&lt;/span&gt; and and a differentiable function &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt;, we can write, using Taylor series,&lt;span class=&quot;math-container&quot;&gt;$$F(x,y+\varepsilon h,y'+\varepsilon h')=F(x,y,y')+\varepsilon\mathcal{I}(\Delta[y,h])+\frac{\varepsilon^2}2\mathcal I(\Delta_2[y,h])+\mathcal O(\varepsilon^3)$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\mathcal I$&lt;/span&gt; denotes the integrand, &lt;span class=&quot;math-container&quot;&gt;$\Delta$&lt;/span&gt; the Gâteaux differential and &lt;span class=&quot;math-container&quot;&gt;$$\Delta_2[y,h]=\int_a^b\left(F_{y'y'}h'^2+\left(F_{yy}-\frac {dF_{yy'}}{dx}\right)h^2\right)\,dx$$&lt;/span&gt; over the domain &lt;span class=&quot;math-container&quot;&gt;$[a,b]$&lt;/span&gt;. Analogous to functions, at a stationary &lt;s&gt;point&lt;/s&gt; path, the Gâteaux differential is zero. Note that &lt;span class=&quot;math-container&quot;&gt;$\Delta_2$&lt;/span&gt; is also analogous to the second derivative.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Therefore, it is sufficient that &lt;span class=&quot;math-container&quot;&gt;$\Delta_2&amp;gt;0$&lt;/span&gt; for all non-zero &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; for a minimum to occur, whereas the necessary condition is weaker with &lt;span class=&quot;math-container&quot;&gt;$\Delta_2\ge0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-11-16T20:21:02.377" LastActivityDate="2019-11-16T20:21:02.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2842" PostTypeId="2" ParentId="2837" CreationDate="2019-10-16T13:14:31.937" Score="3" Body="&lt;p&gt;My answer was longer than I could put it in a comment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how you defined your variables &lt;code&gt;site&lt;/code&gt; and &lt;code&gt;ASSG&lt;/code&gt;, so here is what I think should be your constraint (I based it on @Oguz formulation):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from gurobipy import * # I assume this is how you imported&#xA;&#xA;SITES = range(380)  # index i&#xA;CITIES = range(12)  # index j&#xA;m.addConstrs((quicksum(ASSG[i,j] for j in CITIES) &amp;lt;= 12 * site[i] for i in SITES), 'site-city-relation')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I'm using &lt;code&gt;addConstrs&lt;/code&gt; (plural)&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-10-16T13:27:47.667" LastActivityDate="2019-10-16T13:27:47.667" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2843" PostTypeId="2" ParentId="12" CreationDate="2019-10-16T13:40:18.327" Score="4" Body="&lt;p&gt;We recently had a review paper on the software packages for Benders decomposition and dual decomposition. We did some benchmark studies on their performance as well through the stochastic programming library. You can find the paper from the link below:&#xA;&lt;a href=&quot;http://www.optimization-online.org/DB_HTML/2019/07/7269.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.optimization-online.org/DB_HTML/2019/07/7269.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2537" LastActivityDate="2019-10-16T13:40:18.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2844" PostTypeId="2" ParentId="2612" CreationDate="2019-10-16T21:11:02.917" Score="5" Body="&lt;p&gt;Your logic seems fine to me. There's no issue with multiple solutions: just make &lt;span class=&quot;math-container&quot;&gt;$\hat{\bf{q}}$&lt;/span&gt; &lt;em&gt;any&lt;/em&gt; optimal solution to the modified problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-10-16T21:11:02.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2845" PostTypeId="2" ParentId="2836" CreationDate="2019-10-16T21:19:36.607" Score="4" Body="&lt;p&gt;Per my friend the procurement guru, buyback contracts are apparently rare, whether between retailer and wholesaler or between wholesaler and manufacturer. In any case, the options for the party buying the inventory back are pretty much the same at any level: push it off on another customer (possibly at a discount); put it in inventory in hopes of future orders (apparently not too likely); or ship it to the nearest landfill.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-10-16T21:19:36.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2846" PostTypeId="1" CreationDate="2019-10-16T22:30:49.943" Score="12" ViewCount="2367" Body="&lt;p&gt;I started hunting for jobs and I'm not sure what are good websites I should be keeping an eye on. &#xA;I'm interested mainly in Europe.&lt;/p&gt;&#xA;" OwnerUserId="2541" LastEditorUserId="123" LastEditDate="2019-10-17T07:38:16.783" LastActivityDate="2019-10-17T15:28:54.530" Title="Where to search for PhD level jobs in OR?" Tags="|job-market|phd|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2847" PostTypeId="1" CreationDate="2019-10-16T22:43:23.553" Score="7" ViewCount="865" Body="&lt;p&gt;I am trying to figure out how I can write this objective function into python using Gurobi.  I have to minimize the sum of the product of three dictionary's values.  The reason I am confused is that while the first two dictionaries I am multiplying are the same length (somewhere in the thousands), the third has only 12 items. Also the first two dictionaries have tuple keys and the third does not.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first dictionary &lt;code&gt;ASSG&lt;/code&gt; is a decision variable that has the format: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;ASSG = {('Abilene, TX', 'Boston, MA'): &amp;lt;gurobi.Var ASSG[Abilene, TX,Boston, MA]&amp;gt;, &#xA;        ('Abilene, TX', 'Chicago, IL'): &amp;lt;gurobi.Var ASSG[Abilene, TX,Chicago, IL]&amp;gt;,&#xA;        ('Abilene, TX', 'Dallas, TX'): &amp;lt;gurobi.Var ASSG[Abilene, TX,Dallas, TX]&amp;gt;,&#xA;        ('Abilene, TX', 'Denver, CO'): &amp;lt;gurobi.Var ASSG[Abilene, TX,Denver, CO]&amp;gt;,&#xA;        ...}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second dictionary is &lt;code&gt;miles&lt;/code&gt; and it has the following format:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;miles = {('Abilene, TX', 'Boston, MA'): 2091.92,&#xA;         ('Abilene, TX', 'Chicago, IL'): 1148.37,&#xA;         ('Abilene, TX', 'Dallas, TX'): 189.87,&#xA;         ('Abilene, TX', 'Denver, CO'): 775.6,&#xA;        ...}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The third dictionary is called &lt;code&gt;Demand&lt;/code&gt; and it looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;Demand = {'Boston, MA': 1051,&#xA;          'Chicago, IL': 940,&#xA;          'Dallas, TX': 1131,&#xA;          'Denver, CO': 466,&#xA;          'Los Angeles, CA': 1301,&#xA;          'Richmond, VA': 1171,&#xA;          'Miami, FL': 1463,&#xA;          'New York, NY': 1120,&#xA;          'Phoenix, AZ': 665,&#xA;          'Pittsburgh, PA': 1280,&#xA;          'San Fransisco, CA': 615,&#xA;          'Seattle, WA': 528}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think what I need to do is multiply all of the values where the keys in &lt;code&gt;Demand&lt;/code&gt; match the second element in the tuple of &lt;code&gt;ASSG&lt;/code&gt; and &lt;code&gt;miles&lt;/code&gt;'s keys.  i.e. All the items with &lt;code&gt;'Boston, MA'&lt;/code&gt; get multiplied, all the Chicagos, all the Dallases...  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried multiplying them separately and then using quicksum but I receive an error:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;a = {k: ASSG[k]*miles[k] for k in ASSG}&#xA;b = {k:Demand.get(k[1], 1)* v for k,v in x.items()}&#xA;&#xA;m.setObjective(quicksum(b.values()))&#xA;m.ModelSense = GRB.MINIMIZE&#xA;m.update()&#xA;&#xA;GurobiError: Variable not in model&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2393" LastEditorUserId="123" LastEditDate="2019-10-17T07:32:05.890" LastActivityDate="2019-10-17T07:32:05.890" Title="Having trouble with objective function in Python: &quot;GurobiError: Variable not in model&quot;. What else could I try?" Tags="|optimization|python|gurobi|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2848" PostTypeId="2" ParentId="2846" CreationDate="2019-10-16T22:55:12.333" Score="6" Body="&lt;p&gt;The INFORMS Career Centre may be a good starting point&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://careercenter.informs.org/jobs&quot; rel=&quot;noreferrer&quot;&gt;https://careercenter.informs.org/jobs&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck in your search!&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2019-10-16T22:55:12.333" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2849" PostTypeId="2" ParentId="2836" CreationDate="2019-10-16T23:22:48.190" Score="4" Body="&lt;p&gt;In terms of the theory of buyback contracts (i.e., the math), it doesn't matter what the party doing the &quot;buying back&quot; (the manufacturer, in your question) does with the goods. They can resell them, dispose of them, rework them, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, in practice, the other firm isn't always even required to physically send the units back, but only to provide evidence that they have been destroyed and can't be sold. For example, newspaper publishers sometimes allow resellers to cut off the banner (e.g., the part that says the name of the newspaper and the date) and send back that small strip of paper in order to get the buyback credit. This saves freight costs and disposal costs on the part of the publisher.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect @prubin's friend is right that buyback contracts may be rare. However, I have seen first-hand a hotel cutting newspapers apart for this purpose, and I once worked in a deli that essentially had a buyback contract with its bagel provider. So, they do occur in practice, at least sometimes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, &lt;a href=&quot;https://or.stackexchange.com/questions/430/real-world-examples-of-supply-chain-contracts&quot;&gt;this question&lt;/a&gt; asks for real-world examples of supply chain contracts and got no responses.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-10-16T23:22:48.190" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2851" PostTypeId="2" ParentId="2846" CreationDate="2019-10-17T07:33:10.250" Score="7" Body="&lt;p&gt;Disclaimer: I work as an optimization specialist in a large utility company in Denmark.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Look for &quot;Data Scientist&quot;, &quot;Data Engineer&quot;, &quot;Optimization specialist&quot;, &quot;Operations Research Specialist&quot; or other variations. Examples can be see &lt;a href=&quot;https://careers.vattenfall.com/jobs/optimization-specialist/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://www.amazon.jobs/en/jobs/898834/ops-research-analyst?ss=paid&amp;amp;utm_campaign=cxro&amp;amp;utm_content=job_posting&amp;amp;utm_medium=social_media&amp;amp;utm_source=linkedin.com&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;However, the problem is that many businesses do not know about optimization and how it can benefit them &lt;strong&gt;even if they are using it&lt;/strong&gt;. Therefore try to find the optimization specialists in companies and reach out directly to find out where the best part to apply is. Of course this works best the clearer you know what company you want to work for.&lt;/li&gt;&#xA;&lt;li&gt;There are not many &quot;pure&quot; OR jobs going around. In most cases, it also include data analysis and &quot;science&quot;, as well as software and tool development (i.e. putting your stuff into production). So if you have a &quot;standard&quot; OR degree, I would suggest for you to create competencies in those areas, apply for a &quot;Data Scientist&quot; position and then find your OR niche there.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-10-17T07:33:10.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2852" PostTypeId="2" ParentId="2846" CreationDate="2019-10-17T07:53:23.317" Score="2" Body="&lt;p&gt;If you are thinking about working in the UK, &lt;a href=&quot;https://www.indeed.co.uk/jobs?q=Operations+Research&amp;amp;l=&quot; rel=&quot;nofollow noreferrer&quot;&gt;indeed.co.uk&lt;/a&gt; might be useful for preliminary searching. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you ask for PhD level jobs, &lt;a href=&quot;https://www.indeed.co.uk/jobs?q=Operations%20Research&amp;amp;vjk=3732830d1c9c0da3&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;https://www.indeed.co.uk/jobs?q=Operations%20Research&amp;amp;vjk=14df46094d368d58&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; (both Operational Research Scientists) are good examples; a key requirement being &quot;PhD in operations research, mathematics, ...&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck.&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-10-17T07:53:23.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2853" PostTypeId="2" ParentId="2846" CreationDate="2019-10-17T15:28:54.530" Score="3" Body="&lt;p&gt;If you are interested in PhD-level research jobs in Europe, you might regularly check &lt;a href=&quot;https://euraxess.ec.europa.eu&quot; rel=&quot;nofollow noreferrer&quot;&gt;EURAXES&lt;/a&gt;. In addition, mailing lists of different societies or groups are great for learning about new positions as well as upcoming CfPs, seminars, and workshops. One example is &lt;a href=&quot;https://www.zaik.uni-koeln.de/mailman/listinfo/dmanet&quot; rel=&quot;nofollow noreferrer&quot;&gt;DMANET&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2019-10-17T15:28:54.530" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2854" PostTypeId="1" CreationDate="2019-10-17T17:00:11.387" Score="9" ViewCount="225" Body="&lt;p&gt;What are some methods or algorithms for solving a large-scale stochastic mixed-integer optimization problem that runs on an hourly dataset for a year? Do we employ some kind of decomposition? (the problem in consideration is not bilevel). I am actually looking for general ways/guidelines to tackle these types of problems that are hard to solve even with a large optimality gap but do have an optimal solution.&lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="2477" LastEditDate="2020-01-21T07:29:21.600" LastActivityDate="2020-01-21T07:29:21.600" Title="Solving large-scale stochastic mixed integer program" Tags="|optimization|mixed-integer-programming|algorithms|stochastic-programming|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="2855" PostTypeId="1" AcceptedAnswerId="2856" CreationDate="2019-10-18T03:55:39.857" Score="9" ViewCount="1523" Body="&lt;p&gt;&lt;a href=&quot;https://accounting-simplified.com/management/limiting-factor-analysis/linear-programming/graphical-example.html&quot; rel=&quot;noreferrer&quot;&gt;This page&lt;/a&gt; describes the graphical method to solve a linear program. The formulation is as follows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{alignat}{2} \max &amp;amp;\quad Z = 200W + 100B\\ \text{s.t.} &amp;amp;\quad  1W + 0.8B &amp;amp;&amp;amp;\leq 4000\\ &amp;amp;\quad 0.004W + 0.001B &amp;amp;&amp;amp;\leq 10\\ &amp;amp;\quad W, B &amp;amp;&amp;amp;\geq 0\end{alignat}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ALS9T.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ALS9T.png&quot; alt=&quot;Graph is:&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution given is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Co-ordinates of the optimum point are approximately 1850 W and 2750 B (1850, 2750).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What would be an easy way to calculate the optimal solution in addition to an estimate seen from graph (rather than the simplex method)? Thank you.&lt;/p&gt;&#xA;" OwnerUserId="2440" LastEditorUserId="123" LastEditDate="2019-10-18T09:17:41.823" LastActivityDate="2019-10-18T09:17:41.823" Title="Graphical method in linear programming" Tags="|optimization|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2856" PostTypeId="2" ParentId="2855" CreationDate="2019-10-18T04:16:04.483" Score="10" Body="&lt;p&gt;In the example you shared with two variables and two constraints, as you're seeing from the graph, your solution lies at the intersection of the two constraints (not considering the non-negativity constraints). So, just solve that system of equations and you get the values for &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; (which should give you &lt;span class=&quot;math-container&quot;&gt;$B = \frac{30000}{11}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$W = \frac{20000}{11}$&lt;/span&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to go further and try the optimum values in your objective function, there are four corner points: &lt;span class=&quot;math-container&quot;&gt;$(0,0), (3000, 0), (0, 5000), (\frac{20000}{11}, \frac{30000}{11})$&lt;/span&gt;. Place these values in your objective function and you get the objective value of each point as well. &lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-10-18T04:20:42.413" LastActivityDate="2019-10-18T04:20:42.413" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2857" PostTypeId="2" ParentId="430" CreationDate="2019-10-18T07:58:53.587" Score="4" Body="&lt;p&gt;Blockbuster's revenue-sharing contract might represent an example of an application. See for example &lt;a href=&quot;https://knowledge.wharton.upenn.edu/article/now-showing-at-blockbuster-how-revenue-sharing-contracts-improve-supply-chain-performance/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="459" LastActivityDate="2019-10-18T07:58:53.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2858" PostTypeId="1" CreationDate="2019-10-18T09:24:38.637" Score="7" ViewCount="220" Body="&lt;p&gt;I am coding a MIP problem in docplex and I would like to ask for some tips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to input a binary &lt;strong&gt;parameter&lt;/strong&gt; that states a compatibility relation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a set of characteristics &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; to be satisfied in a product. The product is made by a set of components &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; and each component can have many variants &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;. For stating the compatibility between variant of component and required characteristics, I stated the following binary parameter: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$G_h{_{c}}_{v}=1$&lt;/span&gt; if the characteristic &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; can be accomplished by variant &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; of component &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, and zero otherwise&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I was wandering to use a 3D numpy array to state this relation. But I if I'm not wrong, I did not find examples using 3D numpy array. Instead, I saw &lt;code&gt;namedTuple&lt;/code&gt;, that I guess was used to state similar relation for string elements. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I code binary parameters in docplex keeping the index of each element, by accessing the value of each parameter and also its key ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone could help me, I will be very grateful.&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="123" LastEditDate="2019-10-18T09:35:09.840" LastActivityDate="2019-10-18T13:05:57.223" Title="DOCPLEX: tips to manipulate data input (binary parameter)" Tags="|python|docplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2859" PostTypeId="1" CreationDate="2019-10-18T12:20:22.547" Score="7" ViewCount="350" Body="&lt;p&gt;I am trying to model some logical constraints in ILOG. Logical constraints could be given such as: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 1 or Constraint 2, &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 3 or Constraint 4,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 5 or Constraint 6. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The six constraints in question are listed below. &lt;span class=&quot;math-container&quot;&gt;\begin{align}&amp;amp;\,\,\sum_{s=1}^Sx_{is}=1\quad\forall i\in T\\\text{Constraint}\,1:&amp;amp;\,\,\sum_{s=1}^Ss\cdot x_{is}-\sum_{s=1}^Ss\cdot x_{js}&amp;amp;=0&amp;amp;\quad(i,j)\in\text{linked}\\\text{Constraint}\,2:&amp;amp;\,\,\sum_{s=1}^Ss\cdot x_{is}-\sum_{s=1}^Ss\cdot x_{j(2\cdot m-s)}&amp;amp;=0&amp;amp;\quad(i,j)\in\text{linked}\\\text{Constraint}\,3:&amp;amp;\,\,\left\vert\sum_{s=1}^Ss\cdot x_{is}-\sum_{s=1}^Ss\cdot x_{js}\right\vert&amp;amp;\ge d_1&amp;amp;\quad(i,j)\in\min\\\text{Constraint}\,4:&amp;amp;\,\,\left\vert\sum_{s=1}^Ss\cdot x_{is}-\sum_{s=1}^Ss\cdot x_{j(2\cdot m-s)}\right\vert&amp;amp;\ge d_1&amp;amp;\quad(i,j)\in\min\\\text{Constraint}\,5:&amp;amp;\,\,\left\vert\sum_{s=1}^Ss\cdot x_{is}-\sum_{s=1}^Ss\cdot x_{js}\right\vert&amp;amp;\le d_2&amp;amp;\quad(i,j)\in\max\\\text{Constraint}\,6:&amp;amp;\,\,\left\vert\sum_{s=1}^Ss\cdot x_{is}-\sum_{s=1}^Ss\cdot x_{j(2\cdot m-s)}\right\vert&amp;amp;\le d_2&amp;amp;\quad(i,j)\in\max\end{align}&lt;/span&gt; Only one of the constraints in each group should be satisfied and active, i.e if Constraint 1 is active, Constraint 2 should not be active, or vice versa. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried some logical constraints definition method, e.g. Big M method, but I could not define the constraints and run the model. Since there are too many sum functions in my model, it is very challenging to build a big-M model. So I need your help. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would appreciate it if you have any suggestions. Thank you in advance. Regards.&lt;/p&gt;&#xA;" OwnerUserId="2548" LastEditorUserId="38" LastEditDate="2019-10-18T13:42:05.990" LastActivityDate="2019-10-19T08:03:07.677" Title="Logical Constraints Modelling using Big-M formulation" Tags="|mixed-integer-programming|modeling|logical-constraints|big-m|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2860" PostTypeId="2" ParentId="2859" CreationDate="2019-10-18T12:47:13.763" Score="3" Body="&lt;p&gt;You can enforce constraints 1 and 2 by instead imposing &lt;span class=&quot;math-container&quot;&gt;$x_{i,s}= x_{j,s}+ x_{j, 2m-s}$&lt;/span&gt;.  For the other four, you can impose no-good constraints of the form &lt;span class=&quot;math-container&quot;&gt;$$x_{i,s}+ \sum\limits_{(j,t)\in D_{i,s}} x_{j,t}\le 1,$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$D_{i,s}$&lt;/span&gt; is the set of disallowed assignments for &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="123" LastEditDate="2019-10-19T08:03:07.677" LastActivityDate="2019-10-19T08:03:07.677" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="2861" PostTypeId="1" CreationDate="2019-10-18T12:49:55.640" Score="7" ViewCount="127" Body="&lt;p&gt;The task pertains to choosing an algorithm based on the data, requirements and constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a number of electrical devices (&lt;span class=&quot;math-container&quot;&gt;$d_1,d_2,\dots,d_n$&lt;/span&gt;) with batteries. Throughout the day I will receive these devices with arbitrary battery storage (from 0 to 100%). Batteries have varying capacity. My job is to refill the batteries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to consider the price of charging these devices (cost per unit), since the price of charging a device changes throughout the day, for each day we have 24 different prices for 24 different intervals (&lt;span class=&quot;math-container&quot;&gt;$c_1,c_2,\dots,c_{24}$&lt;/span&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to charge these devices optimally, that is determine how much to charge each available device for each time interval in the future, while minimizing the cost of charging them, while also taking into account that I have a limited amount of charging capacity (upper bound) at any one time at &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; units.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I would like to run this each time I get a new device, to get the current optimal solution. If possible, I would like to avoid having sharp peaks of aggressive charging followed by low (no) charging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What kind of algorithm can I use for this task? How would I formulate it? Can LP be used for this?&lt;/p&gt;&#xA;" OwnerUserId="2550" LastEditorUserId="38" LastEditDate="2019-10-18T13:41:20.853" LastActivityDate="2019-10-18T13:41:20.853" Title="Maximize charging, minimize cost" Tags="|modeling|algorithms|energy|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2862" PostTypeId="1" CreationDate="2019-10-18T12:51:20.410" Score="17" ViewCount="729" Body="&lt;p&gt;Is there a tool with a graphical user interface which helps to visualize optimization problem files (e.g. lp/mps) and solutions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say you have an optimization problem and a solution and want to be able to track individual variables, solution values, maybe even dual values and so on. For example, to click on a variable and see all containing rows. Or to select a row and highlight all variables which are in the row. Or even to fuse the information of an solution with the lp file so that you can see all variables and their solution value in the problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My working method is to use Notepad++, highlight variable names or searching for variable names and clicking through the files and copying individual rows to a new text file...&lt;/p&gt;&#xA;" OwnerUserId="1008" LastEditorUserId="38" LastEditDate="2019-10-18T13:31:40.803" LastActivityDate="2019-10-24T02:57:33.657" Title="Tool/Editor to visualize optimization problem files and solutions" Tags="|optimization|data|visualization|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2863" PostTypeId="2" ParentId="2858" CreationDate="2019-10-18T12:58:20.047" Score="5" Body="&lt;p&gt;One thing I would personally do is stick to dictionaries as accessing each key is easier and faster (Its complexity is &lt;span class=&quot;math-container&quot;&gt;$O(1)$&lt;/span&gt;). If you have three collections for your keys, namely your &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;, then, as you probably know, you can use &lt;a href=&quot;http://ibmdecisionoptimization.github.io/docplex-doc/mp/docplex.mp.model.html#docplex.mp.model.Model.binary_var_cube&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;binary_var_cube&lt;/code&gt;&lt;/a&gt; where you can see, from the documentation linked:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Creates a dictionary of binary decision variables, indexed by triplets.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Using dictionaries will help you tremendously especially in cases where you have a sparse matrix. e.g. only a handful of variants &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; are present in each component &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;. That way, rather than having a 3D numpy array or list of list of list, you can have only those indices for your variables that exist. Of course, you can achieve that with tuple or &lt;code&gt;namedTuple&lt;/code&gt;, but as I mentioned, accessing dictionaries is faster (you can read more about some of Python data types &lt;a href=&quot;https://wiki.python.org/moin/TimeComplexity&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;)  &lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="123" LastEditDate="2019-10-18T13:05:57.223" LastActivityDate="2019-10-18T13:05:57.223" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2864" PostTypeId="2" ParentId="2862" CreationDate="2019-10-18T13:29:06.807" Score="5" Body="&lt;p&gt;This might be not exactly what you are looking for but &lt;a href=&quot;https://gcg.or.rwth-aachen.de&quot; rel=&quot;noreferrer&quot;&gt;GCG&lt;/a&gt; (based on SCIP) has a nice &lt;code&gt;visualize&lt;/code&gt; command that you can call after it found a decomposition (Dantzig-Wolfe or Benders). It visualizes the decomposition in its master and subproblems but also highlights the non-zero entries of the matrix. If there is no such decomposition it still shows you the non-zeros. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://miplib.zib.de&quot; rel=&quot;noreferrer&quot;&gt;MIPLIB&lt;/a&gt; and &lt;a href=&quot;https://striplib.or.rwth-aachen.de&quot; rel=&quot;noreferrer&quot;&gt;strIPlib&lt;/a&gt; use these (or similar) plots for problem visualization.&lt;/p&gt;&#xA;" OwnerUserId="130" LastEditorUserId="130" LastEditDate="2019-10-18T13:34:12.643" LastActivityDate="2019-10-18T13:34:12.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2865" PostTypeId="2" ParentId="2861" CreationDate="2019-10-18T13:40:53.393" Score="3" Body="&lt;p&gt;I would encourage you to think about the &lt;em&gt;model&lt;/em&gt; and the &lt;em&gt;algorithm&lt;/em&gt; separately. I think your question is really about what sort of &lt;em&gt;model&lt;/em&gt; you should build. Once you know that, the question of &lt;em&gt;algorithm&lt;/em&gt; is largely determined, because you'll probably just be passing your model to a solver that will handle the algorithmic part automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My short answer is that it sounds like your problem can be modeled as an LP. There don't seem to be any nonlinearities (which would arise if, say, the charging cost was a nonlinear function of the amount of energy charged) or binary variables (which would arise if, say, there was a fixed cost to start charging a battery). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I would recommend formulating this as an LP. If you get stuck while you're doing that, folks here can help. Once you have formulated the model, you'll want to implement it in a modeling language and then send it to an LP solver. &lt;a href=&quot;https://or.stackexchange.com/questions/2605/ive-formulated-my-optimization-model-now-what&quot;&gt;This Q&amp;amp;A&lt;/a&gt; might help get you started on that part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming the problem isn't too huge (thousands and thousands of batteries or time periods, for example), it should solve quickly in an LP solver, and I would guess that you'll be able to solve it every time you get a new device. &lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-10-18T13:40:53.393" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2866" PostTypeId="1" CreationDate="2019-10-18T14:56:31.100" Score="9" ViewCount="292" Body="&lt;p&gt;I have a nurse-scheduling type of problem with a time span of a year and many employees. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Formulation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;My main variables are:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}x_{e,t} &amp;amp;= \begin{cases}1 \text{ if employee } e \text{ is assigned to task } t \\ 0 \text{ otherwise} \end{cases}\\w_{e,d} &amp;amp;= \begin{cases}1 \text{ if employee } e \text{ is assigned to any task in day } d \\ 0 \text{ otherwise} \end{cases}\\v_{e,d} &amp;amp;= \begin{cases}1 \text{ if employee } e \text{ is on vacation on day } d \\ 0 \text{ otherwise} \end{cases}\end{align}&lt;/span&gt;&#xA;Hired days:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ H_{e} = \text{last work day}-\text{first work day} $$&lt;/span&gt;&#xA;Employee vacations:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ V_{e} = \left\lceil\frac{H_{e}\cdot31}{366}\right\rceil $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Details&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I cannot divide the problem more in terms of time as there are some constraints and variables that need to be calculated yearly.&lt;/li&gt;&#xA;&lt;li&gt;I have the following symmetry breaking constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{t\in T}{x_{e,t}} \le \sum_{t\in T}{x_{e-1,t}}$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;I have divided the problem into &lt;a href=&quot;https://en.wikipedia.org/wiki/Clique_(graph_theory)&quot; rel=&quot;noreferrer&quot;&gt;cliques&lt;/a&gt; of related tasks and employees.&lt;/li&gt;&#xA;&lt;li&gt;I can provide more details about my variables and constraints if needed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to formulate this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe I could add more symmetry breaking or redundant constraints that could speed up the solving (I'm using OR-Tools).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also feel like I should assign group of tasks instead of individual tasks, is that a good idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this formulation I have around 159245 variables and 478303 constraints with 80 employees.&lt;/p&gt;&#xA;" OwnerUserId="991" LastEditorUserId="981" LastEditDate="2023-12-22T15:04:36.117" LastActivityDate="2023-12-22T15:04:36.117" Title="How to tackle large nurse scheduling problem?" Tags="|modeling|scheduling|constraint-programming|or-tools|cp-sat|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2867" PostTypeId="2" ParentId="2866" CreationDate="2019-10-18T19:49:29.340" Score="5" Body="&lt;p&gt;There are many approaches to formulate nurse scheduling model. In practice, MIPs and some heuristics have frequently been used. AFAIK, for large scale MIPs, column generation technique can be applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some useful references are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://amsterdamoptimization.com/pdf/colgen.pdf&quot; rel=&quot;noreferrer&quot;&gt;A workforce scheduling problem (column generation)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arxiv.org/ftp/arxiv/papers/1210/1210.3652.pdf&quot; rel=&quot;noreferrer&quot;&gt;A Flexible Mixed Integer Programming framework for Nurse Scheduling&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://developers.google.com/optimization/scheduling/employee_scheduling&quot; rel=&quot;noreferrer&quot;&gt;Employee Scheduling using OR-Tools&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/gp/book/9781441909091&quot; rel=&quot;noreferrer&quot;&gt;Planning and Scheduling in Manufacturing and Services. Workforce Scheduling. chapter 13 by Michael L. Pinedo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I hope, they would be useful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-10-18T19:49:29.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2868" PostTypeId="2" ParentId="2862" CreationDate="2019-10-18T21:05:03.937" Score="7" Body="&lt;p&gt;AFAIK, some software such as GAMS, Lingo, AMPL and SCIP have had facilities to deal with it. For example, GAMS has a list file which contains much useful information about the problem and its solution. Also, Lingo has a graphical interface to depict the problem specifications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, Lingo matrix picture:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RUtEc.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RUtEc.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-10-18T21:05:03.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2869" PostTypeId="1" CreationDate="2019-10-18T23:37:10.270" Score="17" ViewCount="348" Body="&lt;p&gt;Almost every graph-cut paper I look at seems to have exactly the same pattern of monotonic growth in citations and then monotonic decline starting around 5 years ago:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/h0b7X.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h0b7X.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/JwWOV.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JwWOV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/n72Lc.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n72Lc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For privacy I've cut the all author names out, but it seems that the people who published several graph-cut papers have the same (highly unusual) downward citation trend:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AHgA0m.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AHgA0m.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ptjecm.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ptjecm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Y54Wgm.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Y54Wgm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/VlCKcm.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VlCKcm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;These trends are highly uncommon in academia (if not &lt;em&gt;completely&lt;/em&gt; uncommon except for in this unique case). What happened to the field of graph-cuts? Is some rising new interest such as Deep Learning provably better for the most popular application, in almost every way? Has something made graph-cuts obsolete for the most popular applications?&lt;/p&gt;&#xA;" OwnerUserId="727" LastEditorUserId="727" LastEditDate="2020-03-16T02:07:44.727" LastActivityDate="2020-03-17T13:47:44.890" Title="Was there something specific that caused graph cuts to lose popularity in the last 5 years?" Tags="|optimization|algorithms|graphs|branch-and-cut|network-flow|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2871" PostTypeId="1" AcceptedAnswerId="2963" CreationDate="2019-10-19T10:09:27.797" Score="9" ViewCount="376" Body="&lt;p&gt;I am trying to solve the following problem. I have a set &lt;span class=&quot;math-container&quot;&gt;$\{1,2,3\}$&lt;/span&gt;, which gives the following subsets with its costs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\{1\}=8$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\{2\}=9$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\{3\}=7$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\{1,2\}=9$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\{1,3\}=18$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\{2,3\}=15$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\{1,2,3\}=24$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which combinations of subsets give the cheapest option, so that every element is in one the subsets only once?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this example the solution would be: &lt;span class=&quot;math-container&quot;&gt;$\{1,2\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\{3\}$&lt;/span&gt;, with a total cost of &lt;span class=&quot;math-container&quot;&gt;$16$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to formulate this as a mixed-integer programming problem, any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I have the program running with some additional time constraints for elements in the subsets. For sets with 15 elements, the program solves it in a reasonable time, but for every element I add more, the amount of subsets increase really fast. Therefore I am not able to solve large instances.&#xA;I tried to random sample, x amount of subsets, but this is not optimal...&#xA;Is there any method to solve such problem for a set of 50? &lt;/p&gt;&#xA;" OwnerUserId="2555" LastEditorUserId="2555" LastEditDate="2019-10-31T20:47:30.857" LastActivityDate="2019-10-31T21:06:47.340" Title="How to formulate a MIP that can minimize the costs with a combination of subsets given a set?" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2872" PostTypeId="2" ParentId="2871" CreationDate="2019-10-19T10:42:16.907" Score="8" Body="&lt;p&gt;You can introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_s \in \{0,1\}$&lt;/span&gt; for each of your sets.&#xA;Then, for every element &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;, you add an inequality that implies that exactly one set containing it may be selected: &lt;span class=&quot;math-container&quot;&gt;$\sum_{s \ni e} x_s = 1$&lt;/span&gt;.&#xA;Now you can simply minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{s}c_s x_s$&lt;/span&gt; for the cost coefficients &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-10-19T10:42:16.907" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2873" PostTypeId="1" CreationDate="2019-10-19T10:42:59.307" Score="12" ViewCount="5155" Body="&lt;p&gt;For continuous variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, the constraints are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if x &amp;gt;= 0 and x &amp;lt; 1 then y &amp;lt;= 10 and&#xA;if x &amp;gt;= 1 and x &amp;lt; 2 then y &amp;lt;= 5 and&#xA;&#xA;(up to the ten lines of inequalities)&#xA;&#xA;if x &amp;gt;= 2 then y &amp;lt;= 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is on modeling nonlinear behaviour of gas storage pumping efficiency, which decreases for high load in case of very large gas storages (decrease is seen for storages with capacity above 5 million cubic meters).&#xA;I have to write these constrains using  MIP (or LP) formulation. I can use SOS1/SOS2 variables in GAMS with cplex/gurobi solvers.&lt;/p&gt;&#xA;" OwnerUserId="2557" LastEditorUserId="38" LastEditDate="2019-10-20T00:59:24.983" LastActivityDate="2019-10-20T00:59:24.983" Title="If-then constraints in MIP programming" Tags="|optimization|mixed-integer-programming|constraint|logical-constraints|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2874" PostTypeId="1" CreationDate="2019-10-19T15:16:37.043" Score="16" ViewCount="252" Body="&lt;p&gt;I am working on my MSc thesis right now which is in resource economics, but I have ended up actually operating mostly in the realm of OR and learning about programming, algorithms, optimization problems, some complexity theory, and a bit of machine learning, and I find it all pretty interesting. My thesis project is more or less an application of OR on a particular real world application, but I enjoy it and I think that it could potentially be a fun field to pursue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am curious what research in OR is actually like as opposed to simply applying OR concepts and techniques to a particular problem. With that being said, what are some areas that OR scientists actually do research in? What are some current topics currently being worked on and why, and is OR research more about developing algorithms to solve things like MINLPs or is it more about application?&lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="145" LastEditDate="2019-10-19T16:33:44.523" LastActivityDate="2019-10-25T22:07:27.063" Title="What Is OR Research Like?" Tags="|academia|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2875" PostTypeId="1" AcceptedAnswerId="2876" CreationDate="2019-10-19T16:04:38.960" Score="9" ViewCount="228" Body="&lt;p&gt;Good day.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the following notation for an initial canonical tableau for a linear program in standard form:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;T_1 = &#xA;\begin{bmatrix}&#xA;I &amp;amp; B^{-1}N &amp;amp; \bar{x}_{B} \\&#xA;0^\intercal &amp;amp; \hat{x}_{N}^\intercal &amp;amp; -\bar{z}&#xA;\end{bmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; representing the matrix of the basic technological coefficients (&lt;span class=&quot;math-container&quot;&gt;$x_{ij})$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; representing the matrix of the non-basic tech. coefficients,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\bar{x}_{B}$&lt;/span&gt; representing the &lt;code&gt;B&lt;/code&gt;-partition of the given feasible basic solution,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\hat{x}_{N}^\intercal$&lt;/span&gt; representing the vector of the non-basic reduced costs,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\bar{z}$&lt;/span&gt; representing the value of the objective function at the given &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; solution.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;how would you go about representing the following standard linear program in tableau form?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{alignedat}{4}&#xA;\min_x{z} = &amp;amp; \; -4x_1        &amp;amp; \; -3x_2 &amp;amp; \; +7x_3 \\&#xA;            &amp;amp; \; \quad\ 3x_1  &amp;amp; \; -5x_2 &amp;amp; \; +4x_3 &amp;amp; \; + x_4 &amp;amp;&amp;amp; = &amp;amp; \; 3 \\&#xA;            &amp;amp; \; \quad\ 6x_1  &amp;amp; \; +4x_2 &amp;amp; \; -5x_3 &amp;amp; &amp;amp; \; +x_5 \ &amp;amp; = &amp;amp; \; 2 \\&#xA;            &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp; \quad\ \ x  &amp;amp; \ge &amp;amp; \; 0  &#xA;\end{alignedat}$$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update (adding what I have already tried/already know and tried to apply)&lt;/strong&gt;: looking for help on manuals and here on OR SE alike, the tableau seems to be generally in the form:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;T_2 = &#xA;\begin{bmatrix}&#xA;A &amp;amp; b \\&#xA;c^\intercal &amp;amp; -\bar{z}&#xA;\end{bmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; being the matrix of all technological coefficients, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; the resources vector and &lt;span class=&quot;math-container&quot;&gt;$c^\intercal$&lt;/span&gt; the transpose costs vector. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem does &lt;strong&gt;not&lt;/strong&gt; give you an initial &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; solution and I don't personally know how to represent the program above in tableau form. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the following correct? If so, why is &lt;span class=&quot;math-container&quot;&gt;$T_1 = T_2$&lt;/span&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\bar{T} = &#xA;\begin{bmatrix}&#xA;3 &amp;amp; -5 &amp;amp; 4 &amp;amp; 1 &amp;amp; 0 &amp;amp; 3 \\&#xA;6 &amp;amp; 4 &amp;amp; -5 &amp;amp; 0 &amp;amp; 1 &amp;amp; 2 \\&#xA;-4 &amp;amp; -3 &amp;amp; 7 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0&#xA;\end{bmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tableau above is built supposing that &lt;span class=&quot;math-container&quot;&gt;$x_4, x_5$&lt;/span&gt; is the feasible basic solution vector and that, then, the tableau is in canonical form with respect to &lt;span class=&quot;math-container&quot;&gt;$\bar{x} = \begin{bmatrix} 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 3 &amp;amp; 2 \end{bmatrix}$&lt;/span&gt;. &lt;/p&gt;&#xA;" OwnerUserId="2559" LastEditorUserId="2559" LastEditDate="2019-10-19T16:27:42.720" LastActivityDate="2019-10-19T20:26:04.640" Title="Doubt on finding simplex's initial canonical tableau (II Phase)" Tags="|linear-programming|simplex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2876" PostTypeId="2" ParentId="2875" CreationDate="2019-10-19T19:32:34.307" Score="5" Body="&lt;p&gt;In page 17 of &lt;a href=&quot;http://math.mit.edu/~goemans/18310S15/lpnotes310.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; note by &lt;em&gt;Michel Goemans&lt;/em&gt;, the process of converting &lt;span class=&quot;math-container&quot;&gt;$T_2 \iff T_1$&lt;/span&gt;, has been explained. If you define &lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$A_Bx_B+A_Nx_N=b$&lt;/span&gt; (in your formulation for &lt;span class=&quot;math-container&quot;&gt;$T_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$A_B=B$&lt;/span&gt;) in which &lt;span class=&quot;math-container&quot;&gt;$x_B$&lt;/span&gt; are the basic variables and &lt;span class=&quot;math-container&quot;&gt;$x_N$&lt;/span&gt; are the Non-basic variables, then &lt;span class=&quot;math-container&quot;&gt;$T_1$&lt;/span&gt; has been obtained from the &lt;span class=&quot;math-container&quot;&gt;$T_2$&lt;/span&gt; by a &lt;strong&gt;sequence of elementary row operations&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://home.deib.polimi.it/guariso/appunti/software/simplex/feasible.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; page:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We divide the simplex method into two phases:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Finds an &lt;em&gt;initial&lt;/em&gt; feasible basic solution.&lt;/li&gt;&#xA;&lt;li&gt;finds an &lt;em&gt;optimal&lt;/em&gt; feasible basic solution.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The steps of phases 1 and 2 are identical. They differ in the objective function and the variables included in the problem. The steps of phase 1 are performed until a basic solution is obtained without any artificial variables. Starting from the solution of phase 1, the artificial variables are removed from the problem and the objective value is restored and phase 2 continues to find an optimal solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the first link, there is an example of writing down the tableau format explained in a very detailed way. Another good example by &lt;em&gt;Vanderbei&lt;/em&gt; can be found &lt;a href=&quot;https://vanderbei.princeton.edu/542/lectures/lec6.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. I hope these will be helpful for your problem as well.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-10-19T20:26:04.640" LastActivityDate="2019-10-19T20:26:04.640" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2877" PostTypeId="1" CreationDate="2019-10-19T20:20:23.247" Score="11" ViewCount="864" Body="&lt;p&gt;In statistics, one often encounters the choose function &lt;span class=&quot;math-container&quot;&gt;${x \choose y}$&lt;/span&gt; which encodes the number of ways of choosing &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; items from a set of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; items. How would one go about modeling a choose equality constraint&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$${x \choose y} = C$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;without explicitly using the factorial-based formulation (if possible)? &lt;/p&gt;&#xA;" OwnerUserId="2513" LastEditorUserId="51" LastEditDate="2019-10-21T06:09:17.640" LastActivityDate="2022-09-17T23:43:39.333" Title="Modeling the Choose function" Tags="|mixed-integer-programming|modeling|combinatorial-optimization|probability-theory|combinatorics|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2879" PostTypeId="1" CreationDate="2019-10-19T22:13:11.473" Score="6" ViewCount="437" Body="&lt;p&gt;How do I turn my convex constraints (described below) into constraints that are DCP so that I can solve them in CVXPy? Is there some ``cheat sheet'' of standard tricks?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to implement the convex program highlighted in section 3.2 of the paper &lt;em&gt;&lt;a href=&quot;http://homepage.divms.uiowa.edu/~kvaradar/paps/production.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Equilibria for Economies with Production: Constant-Returns Technologies and Production Planning Constraints&lt;/a&gt;&lt;/em&gt; by Drs. Kamal Jain and Kasturi Varadarajany. I've reduced a model I am working on in my research to a special case of Arrow-Debreu with Constant Returns Technology (AD economy) and would like to implement the constraint satisfaction problem in that paper to run some simulations/find equilibria.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In case it is helps, I will describe the convex program specifically in my setting now (depending on the reader, it may be easier to just glance at the paper's section 3). If you'd rather look at the paper skip the bit between lines:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Using CVXPy I am trying to solve a convex program in terms of non-negative variables&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p_1,\dots,p_n,p_{n+1},\dots,p_{n+m}$&lt;/span&gt; which represent prices of the goods. Here &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the number of goods in the AD economy and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is the number of consumers in the AD economy. They introduce the goods &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; through &lt;span class=&quot;math-container&quot;&gt;$n+m$&lt;/span&gt; for the sake of writing convex constraints (basically they treat utility as a commodity and force consumers to by their utility from an exclusive producer which produces their utility instead of having them directly buy goods which they derive utility from). I'm implementing this as a vector form CVXPy variable of length &lt;span class=&quot;math-container&quot;&gt;$n+m$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{1},\dots,x_{m}$&lt;/span&gt; which, for each consumer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, represents the demand of that consumer  for good &lt;span class=&quot;math-container&quot;&gt;$n+i$&lt;/span&gt;. As I described briefly in above, consumers have utility only for a good representing their own utility which a special producer will produce for them and they will sell their endowments to maximize the amount of this good they receive. I'm implementing this as a vector CVXPy variable of length &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_1,\dots,z_{n+m}$&lt;/span&gt; which, for each producer &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, is a vector &lt;span class=&quot;math-container&quot;&gt;$z_k = (z_{k1},\dots,z_{kn})$&lt;/span&gt; describing the inputs used by the &lt;span class=&quot;math-container&quot;&gt;$k^{th}$&lt;/span&gt; producer. Note that, each producer has a function (described in the convex program below) describing how to turn these input into output. I'm implementing this as a matrix CVXPy variable of dimensions &lt;span class=&quot;math-container&quot;&gt;$(n+m, n)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$q_1,\dots,q_{n+m}$&lt;/span&gt; which, for each producer &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, is the scalar output of their production function (which outputs only good &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;). In other words, this variable described &lt;span class=&quot;math-container&quot;&gt;$q_k = f_k(z_k)$&lt;/span&gt;. I'm implementing this as a vector CVXPy variable of length &lt;span class=&quot;math-container&quot;&gt;$n+m$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm writing the convex program as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad1\\\text{s.t.}&amp;amp;\quad p_{n+i}x_{i} \geq \sum\limits_{j=1}^{n} p_{j} E_{ij} \text{, for } 1 \leq i \leq m\\&amp;amp;\quad q_k \leq \sum\limits_{j=1}^{n} z_{kj} \text{, for } 1 \leq k \leq n\\&amp;amp;\quad q_{n+k} \leq \left(\sum\limits_{j=1}^{n} U_{kj} z_{(n+k),j}^{\rho}\right)^{\frac{1}{\rho}} \text{, for } 1 \leq k \leq m\\&amp;amp;\quad p_k \leq A_{kj} \cdot p_{j} \text{, for } 1 \leq k \leq n \text{ and for } 1 \leq j \leq n\\&amp;amp;\quad p_{n+k}^{1-\frac{1}{1-\rho}} \geq \sum\limits_{j=1}^{n} U_{kj}^{\frac{1}{1-\rho}} p_{j}^{1-\frac{1}{1-\rho}} \text{, for } 1 \leq k \leq m\\&amp;amp;\quad\sum\limits_{k=1}^{n+m} z_{kj} \leq q_j + \sum_{i=1}^{m} E_{ij} \text{, for } 1 \leq j \leq n\\&amp;amp;\quad x_i \leq q_{n+i} \text{, for } 1 \leq i \leq m\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;strong&gt;&lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;&lt;/strong&gt; is a constant matrix of dimension &lt;span class=&quot;math-container&quot;&gt;$(m,n)$&lt;/span&gt; denoting the consumers' initial &quot;endowment&quot; of goods, &lt;strong&gt;&lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt;&lt;/strong&gt; is a constant matrix of dimension &lt;span class=&quot;math-container&quot;&gt;$(m,n)$&lt;/span&gt; denoting the utility coefficient of each good for each consumer, &lt;strong&gt;&lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt;&lt;/strong&gt; is a scalar constant on the open interval &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt; which describes the &quot;elasticity of substitution&quot; in the economy, and finally &lt;strong&gt;&lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;&lt;/strong&gt; is a constant binary matrix (used to encode a &quot;local&quot; notion on goods).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, notice that when we make the substitution &lt;span class=&quot;math-container&quot;&gt;$p_j = e^{\psi_j}$&lt;/span&gt; in these constraints all of them become convex.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After writing this into CVXPy (with the substitution to &lt;span class=&quot;math-container&quot;&gt;$e^{\psi_j}$&lt;/span&gt; done), I am having problems in the first constraint with &lt;span class=&quot;math-container&quot;&gt;$p_{n+i}x_{i}$&lt;/span&gt; not being dcp, in the third constraint where the CES (constant elasticity of substitution) utility function is not dcp, and in the fifth constraint since again the CES function is not dcp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anybody help me massage these three sub-expressions into dcp sub-expressions? I'm at a loss and this would be a huge help! Thanks! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;By DCP I mean &quot;Disciplined Convex Programming.&quot; More info can be&#xA;found &lt;a href=&quot;https://www.cvxpy.org/tutorial/dcp/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You may have noticed that in my AD economy I have exactly &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;&#xA;producers and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; goods (i.e. one producer per good that produces an&#xA;amount of it's output good exactly equal to the sum of the amount of&#xA;other goods it take as input). In reality there are fewer producers&#xA;than goods, but explaining this number is rather involved (it comes&#xA;out of the proof that my model reduces to it, but it shouldn't affect&#xA;anything in this case.)&lt;/li&gt;&#xA;&lt;li&gt;Simply stated I am having trouble getting CVXPy to accept the following constraints: &lt;span class=&quot;math-container&quot;&gt;\begin{align}e^{\psi_{n+1}}x_{i} &amp;amp;\geq \sum\limits_{j=1}^{n} e^{\psi_{j}} E_{ij}\\e^{\psi_{n+k}\left(1-\frac{1}{1-\rho}\right)} &amp;amp;\geq \sum\limits_{j=1}^{n} U_{kj}^{\frac{1}{1-\rho}} e^{\psi_{j}\left(1-\frac{1}{1-\rho}\right)}\\q_{n+k} &amp;amp;\leq \left(\sum\limits_{j=1}^{n} U_{kj} z_{(n+k),j}^{\rho}\right)^{\frac{1}{\rho}}\end{align}&lt;/span&gt; where the &lt;span class=&quot;math-container&quot;&gt;$\psi$&lt;/span&gt;'s, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;'s, and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;'s are the non-negative variables in these constraints. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2561" LastEditorUserId="123" LastEditDate="2019-12-01T14:36:30.557" LastActivityDate="2019-12-01T14:36:30.557" Title="How to make constraints satisfy disciplined convex programming guidelines?" Tags="|optimization|python|constraint-programming|disciplined-convex-programming|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="2880" PostTypeId="2" ParentId="2877" CreationDate="2019-10-19T22:32:30.837" Score="1" Body="&lt;p&gt;AFAIK, some optimization software such as GAMS has some nice functions to deal with this. For example, function likes factorial (fact(x)).&lt;/p&gt;&#xA;&lt;p&gt;Indeed, some estimations for the factorial function using the probability distribution functions like Gamma or Beta might be applied and be interpreted using (in)equality constraints.&lt;/p&gt;&#xA;&lt;p&gt;Reference:&#xA;&lt;a href=&quot;http://mhtlab.uwaterloo.ca/courses/me755/web_chap1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Factorial, Gamma and Beta Functions&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="491" LastEditDate="2022-09-17T23:43:39.333" LastActivityDate="2022-09-17T23:43:39.333" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2881" PostTypeId="1" AcceptedAnswerId="3382" CreationDate="2019-10-19T23:19:45.320" Score="7" ViewCount="285" Body="&lt;p&gt;I can not seem to find the needed functions to model the following problem through the Java API (CP Optimizer): a machine that has downtime and sequence-dependent setup times, with the extra constraint, that the physical preparation (setup) of a job ends right before the job starts.&lt;/p&gt;&#xA;&lt;p&gt;Since there are no preemptions, I am using &lt;code&gt;IloIntervalSequenceVar&lt;/code&gt; (with a &lt;code&gt;noOverlap&lt;/code&gt; that contains the setup time matrix) and &lt;code&gt;IloNumToNumStepFunction&lt;/code&gt; for downtimes. This leads to solutions in which a job can start right after a downtime, because the downtime offers enough distance for the transition time to take place (or at least a part of it). The problem is that this transition itself is also an activity, so it is illegal for it to overlap with downtime.&lt;/p&gt;&#xA;&lt;p&gt;Next, I tried modeling the setup times and/or downtimes as intervals themselves, which solves the overlap problem. However, I always bump into the same problem: it is possible to access intervals and their properties after the model has been solved, but not when formulating decision variables. Since setup times are sequence-dependent, I want to assign a certain size to a setup interval, based on its predecessor (its successor is implied through the constraint I mentioned earlier). I have no way of retrieving this. Methods such as &lt;code&gt;getPrev&lt;/code&gt; are Native, methods such as &lt;code&gt;prev&lt;/code&gt; are Constraints. I basically want a Boolean matrix for each setup interval so I can assign the correct size to it based on the setup time matrix, but I can not find any method that provides this. I can think of ways without modeling setups as intervals, using extra constraints, but they need this same functionality.&lt;/p&gt;&#xA;&lt;p&gt;What do I oversee, is there a better way to go about this?&lt;/p&gt;&#xA;&lt;p&gt;Edit for clarification with &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\rm Setup$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\rm Downtime$&lt;/span&gt; being intervals, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; being the last job before &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}{\rm End}(A) + |{\rm{Setup}}(A,B)| &amp;amp;\leq {\rm Start}(B)\\{\rm End}({\rm Setup}(A,B)) &amp;amp;= {\rm Start}(B)\\{\rm Downtime} \cap (A \cup {\rm Setup}(A,B) \cup B)&amp;amp;= \emptyset\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Which propagates the following constraint I am trying to model as such:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&amp;amp;{\rm Start}({\rm Downtime}) - {\rm End}(A) &amp;lt; |{\rm Setup}(A,B)| + |B|\\\implies&amp;amp;{\rm End}({\rm Downtime}) + |{\rm Setup}(A,B)| \leq {\rm Start}(B) \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2562" LastEditorUserId="491" LastEditDate="2023-04-12T12:09:55.460" LastActivityDate="2023-04-12T12:09:55.460" Title="CPLEX CP Optimizer Java API function missing" Tags="|modeling|constraint-programming|scheduling|java|cp-optimizer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2882" PostTypeId="2" ParentId="2873" CreationDate="2019-10-20T00:58:47.033" Score="9" Body="&lt;p&gt;Let's just consider one constraint, since they all have the same form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if x &amp;gt;= 0 and x &amp;lt; 1 then y &amp;lt;= 10 and&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First, you really can't test for &lt;span class=&quot;math-container&quot;&gt;$x&amp;lt;1$&lt;/span&gt;, with a strict inequality. The best you can do is something like &lt;span class=&quot;math-container&quot;&gt;$x \le 1-\delta$&lt;/span&gt;, for small &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt;. So I'll assume you're taking that approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Introduce a new binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; that equals 1 if the &quot;if&quot; condition (&lt;span class=&quot;math-container&quot;&gt;$x \ge 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x\le \delta$&lt;/span&gt;) holds. To do this, you can use &lt;em&gt;two more&lt;/em&gt; binary variables: &lt;span class=&quot;math-container&quot;&gt;$w_1=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x\ge 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_2 = 1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x \le \delta$&lt;/span&gt;. See this Q&amp;amp;A for a discussion of how to set those variables: &lt;a href=&quot;https://or.stackexchange.com/questions/33/in-an-integer-program-how-i-can-force-a-binary-variable-to-equal-1-if-some-cond&quot;&gt;In an integer program, how I can force a binary variable to equal 1 if some condition holds?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can set &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align*}&#xA;z &amp;amp; \le w_1 \\&#xA;z &amp;amp; \le w_2 \\&#xA;z &amp;amp; \ge w_1 + w_2 - 1&#xA;\end{align*}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you can enforce the implication &quot;if &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y\le 10$&lt;/span&gt;&quot; using the discussion here: &lt;a href=&quot;https://or.stackexchange.com/questions/76/in-an-integer-program-how-can-i-activate-a-constraint-only-if-a-decision-vari&quot;&gt;In an integer program, how can I “activate” a constraint only if a decision variable has a certain value?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other related posts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/1336/expressing-a-chain-of-boolean-ors-using-ilp-involving-different-variables&quot;&gt;Expressing a chain of boolean ORs using ILP involving different variables&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/1386/expressing-an-implication-as-ilp-where-each-implication-term-comprises-a-chain-o&quot;&gt;Expressing an implication as ILP where each implication term comprises a chain of boolean ORs&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-10-20T00:58:47.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2883" PostTypeId="2" ParentId="2877" CreationDate="2019-10-20T04:35:11.283" Score="16" Body="&lt;p&gt;I am going to assume that &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{N}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{N}$&lt;/span&gt; are variables, and that &lt;span class=&quot;math-container&quot;&gt;$C \in \mathbb{N}$&lt;/span&gt; is a constant. In this case, you can benefit from the fact that your equality constraint does not have that many possible solutions.&lt;/p&gt;&#xA;&lt;h3&gt;Case 1: &lt;span class=&quot;math-container&quot;&gt;$C = 1$&lt;/span&gt;&lt;/h3&gt;&#xA;&lt;p&gt;This only happens when &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$y = x$&lt;/span&gt;. Assume that we have some upper bounds &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{y}$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, respectively. You can then model the choose equality constraint as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;0 &amp;amp;\le&amp;amp; y &amp;amp; \le&amp;amp; \bar{y}z\\&#xA;-\bar{x}(1-z) &amp;amp;\le&amp;amp; y-x &amp;amp;\le&amp;amp; \bar{y}(1-z)&#xA;\end{eqnarray}&lt;/span&gt;&#xA;for a binary variable &lt;span class=&quot;math-container&quot;&gt;$z \in \mathbb{B}$&lt;/span&gt;. Note that &lt;span class=&quot;math-container&quot;&gt;$z=0$&lt;/span&gt; corresponds to &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt; corresponds to &lt;span class=&quot;math-container&quot;&gt;$y = x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Case 2: &lt;span class=&quot;math-container&quot;&gt;$C \neq 1$&lt;/span&gt;&lt;/h3&gt;&#xA;&lt;p&gt;It is conjectured that for &lt;span class=&quot;math-container&quot;&gt;$C \neq 1$&lt;/span&gt;, your equality constraint does not have many solutions, see &lt;a href=&quot;https://en.wikipedia.org/wiki/Singmaster%27s_conjecture&quot; rel=&quot;noreferrer&quot;&gt;Singmaster's conjecture on Wikipedia&lt;/a&gt;. In fact, for &lt;span class=&quot;math-container&quot;&gt;$C \le 2^{48} \approx 3 \times 10^{14}$&lt;/span&gt;, &lt;a href=&quot;https://doi.org/10.2307/2319526&quot; rel=&quot;noreferrer&quot;&gt;it has been shown&lt;/a&gt; that there are never more than 8 different solutions in terms of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So for a given &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; that is not too big, you can simply look up all &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; solutions &lt;span class=&quot;math-container&quot;&gt;$a_i, b_i\in \mathbb{N}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;${a_i \choose b_i} = C$&lt;/span&gt;, for &lt;span class=&quot;math-container&quot;&gt;$i = 1,\dots, n$&lt;/span&gt;.&#xA;Next, introduce &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; binary variables &lt;span class=&quot;math-container&quot;&gt;$z_i \in \mathbb{Z}$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$z_i = 1$&lt;/span&gt; if and only if solution &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is chosen. That is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;x &amp;amp;=&amp;amp; \sum_{i=1}^n a_i z_i\\&#xA;y &amp;amp;=&amp;amp; \sum_{i=1}^n b_i z_i\\&#xA;\sum_{i=1}^n z_i &amp;amp;=&amp;amp; 1&#xA;\end{eqnarray}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-10-20T12:44:20.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2884" PostTypeId="2" ParentId="2862" CreationDate="2019-10-20T04:54:56.833" Score="1" Body="&lt;p&gt;What you are asking for sounds somewhat similar to &lt;a href=&quot;https://www.alteryx.com/platform&quot; rel=&quot;nofollow noreferrer&quot;&gt;Alteryx&lt;/a&gt; (which starts at $5,195/user per year). Let's see how we can duplicate some of the look and functionality that with &lt;strong&gt;free&lt;/strong&gt; tools. A demo video &quot;&lt;a href=&quot;https://www.youtube.com/watch?v=h2OpMPla5uc&quot; rel=&quot;nofollow noreferrer&quot;&gt;Alteryx Designer in 20 Minutes&lt;/a&gt;&quot; (titled &quot;Alteryx Demo&quot; on YouTube) is available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an overview of the workflow:&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/6eXb0.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6eXb0.jpg&quot; alt=&quot;Overview of Alteryx&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You asked for:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Let's say you have an optimization problem and a solution and want to be able to track individual variables, solution values, maybe even dual values and so on. For example, to click on a variable and see all containing rows. Or to select a row and highlight all variables which are in the row. Or even to fuse the information of an solution with the lp file so that you can see all variables and their solution value in the problem.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here's the Alteryx user interface:&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/3Fkm4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3Fkm4.jpg&quot; alt=&quot;Alteryx GUI&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can we obtain that sort of functionality for less than the cost of Alteryx?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;a href=&quot;https://en.wikipedia.org/wiki/Gekko_(optimization_software)&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gekko&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/APMonitor&quot; rel=&quot;nofollow noreferrer&quot;&gt;APMonitor&lt;/a&gt;, along with &lt;a href=&quot;https://pypi.org/project/PyFMI/&quot; rel=&quot;nofollow noreferrer&quot;&gt;pyFMI&lt;/a&gt; for &lt;a href=&quot;https://fmi-standard.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;FMI&lt;/a&gt; support (that provides drag and drop), you end up with (description from &lt;a href=&quot;https://gekko.readthedocs.io/en/latest/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gekko's webpage&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;&lt;strong&gt;What does GEKKO do?&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;GEKKO is optimization software for mixed-integer and differential algebraic equations. It is coupled with large-scale solvers for linear, quadratic, nonlinear, and mixed integer programming (LP, QP, NLP, MILP, MINLP). Modes of operation include data reconciliation, real-time optimization, dynamic simulation, and nonlinear predictive control. The client or server is freely available with interfaces in MATLAB, Python, or from a web browser.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;GEKKO is a high-level abstraction of mathematical optimization problems. Values in the models are defined by Constants, Parameters, and Variables. The values are related to each other by Intermediates or Equations. Objective functions are defined to maximize or minimize certain values. Objects are built-in collections of values (constants, parameters, and variables) and relationships (intermediates, equations, and objective functions). Objects can build upon other objects with object-oriented relationships.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The APMonitor executable on the back-end compiles a model to byte-code and performs model reduction based on analysis of the sparsity structure (incidence of variables in equations or objective function) of the model. For differential and algebraic equation systems, orthogonal collocation on finite elements is used to transcribe the problem into a purely algebraic system of equations. APMonitor has several modes of operation, adjustable with the imode parameter. The core of all modes is the nonlinear model. Each mode interacts with the nonlinear model to receive or provide information. The 9 modes of operation are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. Steady-state simulation (SS)&#xA;2. Model parameter update (MPU)&#xA;3. Real-time optimization (RTO)&#xA;4. Dynamic simulation (SIM)&#xA;5. Moving horizon estimation (EST)&#xA;6. Nonlinear control / dynamic optimization (CTL)&#xA;7. Sequential dynamic simulation (SQS)&#xA;8. Sequential dynamic estimation (SQE)&#xA;9. Sequential dynamic optimization (SQO)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Modes 1-3 are steady state modes with all derivatives set equal to zero. Modes 4-6 are dynamic modes where the differential equations define how the variables change with time. Modes 7-9 are the same as 4-6 except the solution is performed with a sequential versus a simultaneous approach. Each mode for simulation, estimation, and optimization has a steady state and dynamic option.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;APMonitor provides the following to a Nonlinear Programming Solver (APOPT, BPOPT, IPOPT, MINOS, SNOPT) in sparse form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- Variables with default values and constraints&#xA;- Objective function&#xA;- Equations&#xA;- Evaluation of equation residuals&#xA;- Sparsity structure&#xA;- Gradients (1st derivatives)&#xA;- Gradient of the equations&#xA;- Gradient of the objective function&#xA;- Hessian of the Lagrangian (2nd derivatives)&#xA;- 2nd Derivative of the equations&#xA;- 2nd Derivative of the objective function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Once the solution is complete, APMonitor writes the results in results.json that is loaded back into the python variables by GEKKO&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When the system of equations does not converge, APMonitor produces a convergence report in ‘infeasibilities.txt’. There are other levels of debugging that help expose the steps that APMonitor is taking to analyze or solve the problem. Setting DIAGLEVEL to higher levels (0-10) gives more output to the user. Setting COLDSTART to 2 decomposes the problem into irreducible sets of variables and equations to identify infeasible equations or properly initialize a model.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Of course you can extend those capabilities with any number of other &lt;a href=&quot;https://wiki.python.org/moin/PythonForOperationsResearch&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python packages for Operation Research&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pyFMI GUI is a fair bit more modern looking than Alteryx:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/31ik5.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/31ik5.jpg&quot; alt=&quot;FMI GUI&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-10-20T04:54:56.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2885" PostTypeId="1" CreationDate="2019-10-20T20:48:50.377" Score="9" ViewCount="296" Body="&lt;p&gt;Suppose I have an optimal solution and I want to know how the solution would (likely) change if one of the coefficients in the objective function changes, or if I add a constraint that forces &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; away from its optimal value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to estimate for small changes, without re-running the optimization?&lt;/p&gt;&#xA;" OwnerUserId="2564" LastEditorUserId="123" LastEditDate="2019-10-21T07:33:09.827" LastActivityDate="2019-10-22T08:23:16.623" Title="Partial derivative of LP solution $(x_1 , \ldots, x_n)$ w.r.t. $x_i$ or $a_i$" Tags="|optimization|linear-programming|sensitivity-analysis|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2886" PostTypeId="5" CreationDate="2019-10-21T06:17:36.727" Score="0" Body="&lt;p&gt;Combinatorics is the study of finite or countable discrete structures — especially enumerative combinatorics: how to count or enumerate elements in a set (perhaps of all possibilities) or any subset. This tag can be used for questions about permutations, combinations, partially ordered sets, bijection proofs, and generating functions.&lt;/p&gt;&#xA;&lt;p&gt;Questions about:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;graph theory should be tagged with &lt;a href=&quot;/questions/tagged/graphs&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;graphs&amp;#39;&quot; rel=&quot;tag&quot;&gt;graphs&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;combinatorial optimization should be tagged with &lt;a href=&quot;/questions/tagged/discrete-optimization&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;discrete-optimization&amp;#39;&quot; rel=&quot;tag&quot;&gt;discrete-optimization&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;These tags may be used alone or together with &lt;a href=&quot;/questions/tagged/combinatorics&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;combinatorics&amp;#39;&quot; rel=&quot;tag&quot;&gt;combinatorics&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To learn more about enumerative combinatorics, see &lt;a href=&quot;https://en.wikipedia.org/wiki/Enumerative_combinatorics&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt; or &lt;a href=&quot;https://math.mit.edu/%7Erstan/ec/ec1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Richard P. Stanley's &lt;em&gt;Enumerative Combinatorics&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt;Adapted from: &lt;a href=&quot;https://math.stackexchange.com/tags/combinatorics/info&quot;&gt;Mathematics.SE [combinatorics]&lt;/a&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="123" LastEditDate="2020-08-19T14:06:04.327" LastActivityDate="2020-08-19T14:06:04.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2887" PostTypeId="4" CreationDate="2019-10-21T06:17:36.727" Score="0" Body="For questions about the study of finite or countable discrete structures, especially how to count or enumerate elements in a set (perhaps of all possibilities) or any subset. It includes questions on permutations, combinations, bijective proofs, and generating functions. " OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-10-21T07:32:20.853" LastActivityDate="2019-10-21T07:32:20.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2888" PostTypeId="2" ParentId="2877" CreationDate="2019-10-21T09:04:20.083" Score="-1" Body="&lt;p&gt;From Wikipedia's webpage on &amp;quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Binomial_coefficient&quot; rel=&quot;nofollow noreferrer&quot;&gt;binomial coefficients&lt;/a&gt;&amp;quot;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;The symbol &lt;span class=&quot;math-container&quot;&gt;$\tbinom {n}{k}$&lt;/span&gt; is usually read as &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; choose &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;&amp;quot; because there are &lt;span class=&quot;math-container&quot;&gt;$\tbinom {n}{k}$&lt;/span&gt; ways to choose an (unordered) subset of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; elements from a fixed set of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; elements.&lt;/p&gt;&#xA;&lt;p&gt;Arranging the numbers &lt;span class=&quot;math-container&quot;&gt;$\tbinom {n}{0},\tbinom {n}{1},\ldots ,\tbinom {n}{n}$&lt;/span&gt; in successive rows for &lt;span class=&quot;math-container&quot;&gt;$n=0,1,2,\ldots$&lt;/span&gt; gives a triangular array called Pascal's triangle, satisfying the &lt;a href=&quot;https://en.wikipedia.org/wiki/Recurrence_relation&quot; rel=&quot;nofollow noreferrer&quot;&gt;recurrence relation&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\binom {n}{k} &amp;amp; ={\binom {n-1}{k}}+{\binom {n-1}{k-1}}. \\&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Commonly, a binomial coefficient is indexed by a pair of integers &lt;span class=&quot;math-container&quot;&gt;$n ≥ k ≥ 0$&lt;/span&gt; and is written &lt;span class=&quot;math-container&quot;&gt;$\tbinom {n}{k}$&lt;/span&gt;. It is the coefficient of the &lt;span class=&quot;math-container&quot;&gt;$x^k$&lt;/span&gt; term in the polynomial expansion of the binomial power &lt;span class=&quot;math-container&quot;&gt;$(1 + x)^n$&lt;/span&gt;, and it is given by the formula&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\binom {n}{k} &amp;amp; ={\frac {n!}{k!(n-k)!}}. \qquad\qquad&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For example, the fourth power of &lt;span class=&quot;math-container&quot;&gt;$1 + x$&lt;/span&gt; is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned}(1+x)^{4}&amp;amp;={\tbinom {4}{0}}x^{0}+{\tbinom {4}{1}}x^{1}+{\tbinom {4}{2}}x^{2}+{\tbinom {4}{3}}x^{3}+{\tbinom {4}{4}}x^{4}\\&amp;amp;=1+4x+6x^{2}+4x^{3}+x^{4},\end{aligned}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and the binomial coefficient &lt;span class=&quot;math-container&quot;&gt;$\tbinom {4}{2} ={\tfrac {4!}{2!2!}}=6$&lt;/span&gt; is the coefficient of the &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt; term.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The section titled: &amp;quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Binomial_coefficient#Computing_the_value_of_binomial_coefficients&quot; rel=&quot;nofollow noreferrer&quot;&gt;computing the value of binomial coefficients&lt;/a&gt;&amp;quot; explains:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Recursive formula&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;One method uses the recursive, purely additive, formula&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\binom {n}{k} = \binom {n-1}{k-1} + \binom {n-1}{k} \quad \text{for all integers } n,k:1\leq k\leq n-1, \qquad $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with initial/boundary values&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$${\binom {n}{0}}={\binom {n}{n}}=1\quad {\text{for all integers }}n\geq 0, \qquad \qquad \qquad \quad \qquad$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Multiplicative formula&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;A more efficient method to compute individual binomial coefficients is given by the formula&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\binom {n}{k} ={\frac {n^{\underline {k}}}{k!}}={\frac {n(n-1)(n-2)\cdots (n-(k-1))}{k(k-1)(k-2)\cdots 1}}=\prod _{i=1}^{k}{\frac {n+1-i}{i}},\qquad $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the numerator of the first fraction &lt;span class=&quot;math-container&quot;&gt;$n^{\underline {k}}$&lt;/span&gt; is expressed as a falling factorial power. This formula is easiest to understand for the combinatorial interpretation of binomial coefficients. The numerator gives the number of ways to select a sequence of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; distinct objects, retaining the order of selection, from a set of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; objects. The denominator counts the number of distinct sequences that define the same &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-combination when order is disregarded.&lt;/p&gt;&#xA;&lt;p&gt;Due to the symmetry of the binomial coefficient with regard to &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n−k$&lt;/span&gt;, calculation may be optimised by setting the upper limit of the product above to the smaller of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n−k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Factorial formula&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Finally, though computationally unsuitable, there is the compact form, often used in proofs and derivations, which makes repeated use of the familiar factorial function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$${\binom {n}{k}}={\frac {n!}{k!\,(n-k)!}}\quad {\text{for }}\ 0\leq k\leq n, \qquad \qquad \qquad \qquad \qquad \qquad \qquad $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$n!$&lt;/span&gt; denotes the factorial of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. This formula follows from the multiplicative formula above by multiplying numerator and denominator by &lt;span class=&quot;math-container&quot;&gt;$(n − k)!$&lt;/span&gt;; as a consequence it involves many factors common to numerator and denominator. It is less practical for explicit computation (in the case that &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is small and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is large) unless common factors are first cancelled (in particular since factorial values grow very rapidly).&lt;/p&gt;&#xA;&lt;p&gt;See also: &amp;quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Twelvefold_way#case_in&quot; rel=&quot;nofollow noreferrer&quot;&gt;Injective functions from &lt;span class=&quot;math-container&quot;&gt;$\underline{N}$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\underline{X}$&lt;/span&gt;, up to a permutation of &lt;span class=&quot;math-container&quot;&gt;$\underline{N}$&lt;/span&gt;&lt;/a&gt;&amp;quot; and the &amp;quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Twelvefold_way&quot; rel=&quot;nofollow noreferrer&quot;&gt;Twelvefold Way&lt;/a&gt;&amp;quot;, or confirm this at the &lt;a href=&quot;https://web.archive.org/web/20171222050153/http://mathforum.org/library/drmath/view/56229.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;MathForum&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What is the &lt;a href=&quot;https://www.dcode.fr/combinations#q10&quot; rel=&quot;nofollow noreferrer&quot;&gt;algorithm&lt;/a&gt; for counting combinations?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// pseudo code&#xA;start count_combinations( k , n ) {&#xA; if (k = n) return 1;&#xA; if (k &amp;gt; n/2) k = n-k;&#xA; res = n-k+1;&#xA; for i = 2 by 1 while i &amp;lt; = k&#xA;  res = res * (n-k+i)/i;&#xA; end for&#xA; return res;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So for &lt;a href=&quot;https://en.wikipedia.org/wiki/Catalan_number&quot; rel=&quot;nofollow noreferrer&quot;&gt;Catalan numbers&lt;/a&gt;, a sequence of positive integers, where the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;th term in the sequence denoted &lt;span class=&quot;math-container&quot;&gt;$C_n$&lt;/span&gt;, is found in the following formula:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$C_n = (2n)! / ((n + 1)!n!)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; factorial is equal to the product of all of the integers from &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; down to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$(n) ⋅ (n - 1) ⋅ (n - 2) ⋅ … ⋅ 2 ⋅ 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Without using factorial that's:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$C_{n}={2n \choose n}-{2n \choose n+1}={1 \over n+1}{2n \choose n}\quad {\text{ for }}n\geq 0,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$C_{0}=1\quad {\text{and}}\quad C_{n+1}={\frac {2(2n+1)}{n+2}}C_{n}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="279" LastEditDate="2022-09-13T20:29:03.377" LastActivityDate="2022-09-13T20:29:03.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2889" PostTypeId="2" ParentId="881" CreationDate="2019-10-21T09:05:58.290" Score="2" Body="&lt;p&gt;Here is the solution that works on me:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;open cmd (command prompt)    &lt;/li&gt;&#xA;&lt;li&gt;know where you install ILOG (As for me &gt;&gt; C:\Program Files\IBM\ILOG\CPLEX_Studio129\python)&lt;/li&gt;&#xA;&lt;li&gt;copy the location&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;cd C:\Program Files\IBM\ILOG\CPLEX_Studio129\python&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;python &quot;c:/Program Files/IBM/ILOG/CPLEX_Studio129/python/setup.py&quot; install&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note: I don't really sure that the following will help or not, but I also do this on my cmd (it seems that you already do it anyway, just for the passerby):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;type &lt;code&gt;pip install cplex&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;pip install docplex&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Those steps also solve Error can't find certifi-2017.7.27.1.tar.gz&lt;/p&gt;&#xA;" OwnerUserId="2568" LastActivityDate="2019-10-21T09:05:58.290" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2890" PostTypeId="2" ParentId="2885" CreationDate="2019-10-21T20:49:56.743" Score="7" Body="&lt;p&gt;As Larry Snyder mentioned in his comment, almost all of the Operations Research books include a chapter dedicated to answering your question which is about &quot;Sensitivity Analysis&quot;. A good(short and concise) example can be found &lt;a href=&quot;https://personal.utdallas.edu/~scniu/OPRE-6201/documents/LP12-Sensitivity-Analysis.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, where all the following changes have been done to the problem and their effects on the optimal solution have been shown:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Change the right-hand side of a constraint (resource availability)&lt;/li&gt;&#xA;&lt;li&gt;Change the coefficient of a variable in objective function.&lt;/li&gt;&#xA;&lt;li&gt;Adding a new variable to the model.&lt;/li&gt;&#xA;&lt;li&gt;Adding a new constraint to the model.&lt;/li&gt;&#xA;&lt;li&gt;Simultaneous change in all the coefficients of a variable both in the objective function and in the constraints.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It's not necessary to resolve the problem after any of the abovementioned changes, sensitivity analysis is being used to manage, not only the small changes in the model but also some large modifications like adding a new variable or constraint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a list of &lt;em&gt;&quot;sensitivity analysis chapters&quot;&lt;/em&gt; from two famous operations research books:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;Taha, Hamdy A.&lt;/em&gt; Operations research: an introduction. Pearson Education India, 2013.&#xA;&lt;strong&gt;Chapter 3:&lt;/strong&gt; The Simplex Method and Sensitivity Analysis&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Hillier, Frederick S., and Gerald J. Lieberman.&lt;/em&gt; Introduction to operations research. McGraw-Hill Science, Engineering &amp;amp; Mathematics, 1995. &lt;strong&gt;Chapter 6:&lt;/strong&gt; Duality Theory and Sensitivity Analysis &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-10-21T21:15:42.270" LastActivityDate="2019-10-21T21:15:42.270" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2891" PostTypeId="2" ParentId="2885" CreationDate="2019-10-22T08:23:16.623" Score="6" Body="&lt;p&gt;The solution to an LP is given directly by its active set, &lt;span class=&quot;math-container&quot;&gt;$I = \{i_1,i_2,...,i_n\}$&lt;/span&gt;, which forms a system of equations that recovers the solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your solution varies, then the question is whether your active set changes or not:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If it does not change, then you can simply re-solve the system of equations to get the new solution.&lt;/li&gt;&#xA;&lt;li&gt;If it does change, then you need to find the new active set and then solve the resulting system of equations.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This principle was first detailed by Fiacco in 1976, where he called it the &quot;&lt;a href=&quot;https://link.springer.com/article/10.1007%2FBF01580677&quot; rel=&quot;noreferrer&quot;&gt;Basic Sensitivity Theorem&lt;/a&gt;&quot;. The interesting question at this point is of course: how do you decide whether the active set still holds, and what the new active set would be. To understand this, you need to consider:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Primal feasibility (is the solution feasible): so you get the solution from your set of equations and see whether it satisfies all your constraints.&lt;/li&gt;&#xA;&lt;li&gt;Dual feasibility (is the solution optimal): You can prove that the Lagrangian multipliers (which define dual feasibility via &lt;span class=&quot;math-container&quot;&gt;$\lambda_i \geq 0$&lt;/span&gt;) do not vary when the active set stays the same. So as long as your primal feasibility is given, your active set stays the same. If it becomes infeasible, I'd suggest that you resolve the problem and get the new active set. There are techniques to do this without solving another problem using a variety of approaches, in a field called &quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Parametric_programming&quot; rel=&quot;noreferrer&quot;&gt;multi-parametric programming&lt;/a&gt;&quot;. A review paper I have written that collects a lot of these thoughts can be found &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0263876216303276&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="133" LastActivityDate="2019-10-22T08:23:16.623" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2892" PostTypeId="1" AcceptedAnswerId="2895" CreationDate="2019-10-22T21:14:07.843" Score="11" ViewCount="8402" Body="&lt;p&gt;So I am new to OR (not my field, but I have found myself working in it for a thesis project). My problem is a non-linear problem by design and unfortunately I cannot linearize everything, however, there are parts of my problem that I can linearize such as the product of two continuous variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am not certain about is how linearization helps in the context of a non-linear problem. For example, if I were to linearize the product of the two continuous variables, would the linearization get the solution closer to a global optimum if it exists or would the problem just compute faster such that the problem can be made larger in scale. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What exactly are the benefits of performing linearization in math programming, and in particular, to NLPs?&lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="123" LastEditDate="2019-10-23T05:45:34.210" LastActivityDate="2019-10-23T23:21:24.917" Title="What are the benefits of linearization?" Tags="|linearization|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2893" PostTypeId="2" ParentId="2892" CreationDate="2019-10-22T22:10:55.120" Score="3" Body="&lt;p&gt;&lt;strong&gt;Definition&lt;/strong&gt;(from Wikipedia):  In a mathematical programming model, if the objective functions and constraints are represented entirely by linear equations, then the model is regarded as a linear model. If one or more of the objective functions or constraints are represented with a nonlinear equation, then the model is known as a nonlinear model. In optimization, cost functions and non-linear components within can be linearized &lt;strong&gt;in order to apply a linear solving method such as the Simplex algorithm&lt;/strong&gt;. The optimized result &lt;strong&gt;is reached much more efficiently&lt;/strong&gt; and is deterministic as a global optimum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note that:&lt;/strong&gt; I googled but couldn't find any paper in which the authors compare the performance of linear vs. non-linear models for a specific problem. Without loss of generality, this can be inferred that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The two modeling approaches (for the same problem) are not comparable because different algorithms with totally different complexity have been used in modeling and in the solving process.&lt;/li&gt;&#xA;&lt;li&gt;In all possible situations(if you have the opportunity to model the problem as an LP), some linearization techniques have been used to avoid nonlinearity in the model and convert the NLP to an LP model. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-10-22T22:20:51.417" LastActivityDate="2019-10-22T22:20:51.417" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2894" PostTypeId="2" ParentId="2892" CreationDate="2019-10-23T03:29:02.000" Score="7" Body="&lt;p&gt;In Operations Research, we have very good algorithms for solving certain classes of well-structured convex optimization problems. Our specialty is the class of linear programs, which is discussed by Oguz Toragay. Other classes are listed by ErlingMOSEK in &lt;a href=&quot;https://or.stackexchange.com/a/2538/145&quot;&gt;this answer&lt;/a&gt;. These optimization problems can be solved efficiently in practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Operations Research also provides good algorithms for optimization problems in which some or all of the variables are integer, but would otherwise be well-structured and convex. This includes mixed-integer programs, which are linear programs that include integer variables. These problems are more difficult to solve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So given that we are very good at solving linear programs and mixed-integer programs, it makes sense to attempt to linearize non-linear problems to make them fit in this framework. This allows us to solve these problems with the existing machinery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the non-linear problem is not convex, it is probably not possible to find an equivalent linear program. However, we might be able to obtain an equivalent mixed-integer problem. On this site, there are plenty of questions about linearization in which the answers introduce binary variables to model the non-linearity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the above, I have assumed that you are interested in finding an equivalent representation of your non-linear program. Linearization then allows you to get the same global optimum, but faster. If you approximate non-linear functions by (piece-wise) linear ones, global optimality is no longer guaranteed.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="123" LastEditDate="2019-10-23T05:46:08.353" LastActivityDate="2019-10-23T05:46:08.353" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2895" PostTypeId="2" ParentId="2892" CreationDate="2019-10-23T07:11:43.127" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What I am not certain about is how linearization helps in the context of a non-linear problem. ... would the linearization get the solution closer to a global optimum if it exists or would the problem just compute faster such that the problem can be made larger in scale. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If a portion of the equation has a linear section this can be partitioned from the non-linear sections and solved using simpler equations, this will be faster; especially if the area is large or is involved in a complex analysis or optimization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the partitioned section can only be approximated using linear equations this will still be faster, but with a loss of accuracy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to approximate, optimize, and for a final pass use exact equations. In a complex system this can result in a huge speedup without loss of accuracy, but possibly at the cost of missing the most optimal solution due to missing the &lt;em&gt;true&lt;/em&gt; global optimum and relying on the approximations of local optimums to hopefully arrive at a global optimum. That is called the &lt;a href=&quot;https://en.wikipedia.org/wiki/Hartman%E2%80%93Grobman_theorem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hartman–Grobman theorem&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where a small smooth change made to the parameter values (the bifurcation parameters) of a system causes a sudden 'qualitative' or topological change in its behavior that is called &lt;a href=&quot;https://en.wikipedia.org/wiki/Bifurcation_theory&quot; rel=&quot;nofollow noreferrer&quot;&gt;bifurcation theory&lt;/a&gt; or a &lt;a href=&quot;https://en.wikipedia.org/wiki/Crisis_(dynamical_systems)&quot; rel=&quot;nofollow noreferrer&quot;&gt;crisis&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Wikipedia explanation of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Nonlinear_system&quot; rel=&quot;nofollow noreferrer&quot;&gt;non-linear system&lt;/a&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Typically, the behavior of a nonlinear system is described in mathematics by a nonlinear system of equations, which is a set of simultaneous equations in which the unknowns (or the unknown functions in the case of differential equations) appear as variables of a polynomial of degree higher than one or in the argument of a function which is not a polynomial of degree one. In other words, in a nonlinear system of equations, the equation(s) to be solved cannot be written as a linear combination of the unknown variables or functions that appear in them. Systems can be defined as nonlinear, regardless of whether known linear functions appear in the equations. In particular, a differential equation is linear if it is linear in terms of the unknown function and its derivatives, even if nonlinear in terms of the other variables appearing in it. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Linearization#Uses_of_linearization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linearization&lt;/a&gt; of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Nonlinear_system#Types_of_nonlinear_dynamic_behaviors&quot; rel=&quot;nofollow noreferrer&quot;&gt;non-linear&lt;/a&gt; equation allows the use of &lt;a href=&quot;https://en.wikipedia.org/wiki/Linear_approximation&quot; rel=&quot;nofollow noreferrer&quot;&gt;linear&lt;/a&gt; equations to estimate a point of a non-linear function, the further from that point the greater the likelihood of error. An iteration of &lt;a href=&quot;https://en.wikipedia.org/wiki/Linear_approximation&quot; rel=&quot;nofollow noreferrer&quot;&gt;linear approximations&lt;/a&gt; applied to a non-linear functions necessitates choosing a step size, too small a step size will be slow but more accurate while larger steps will be faster but may lead to &lt;a href=&quot;https://en.wikipedia.org/wiki/Finite_difference_method#Comparison&quot; rel=&quot;nofollow noreferrer&quot;&gt;instabilities&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example a well-posed &lt;a href=&quot;https://en.wikipedia.org/wiki/Finite_difference_method#Example:_ordinary_differential_equation&quot; rel=&quot;nofollow noreferrer&quot;&gt;ordinary differential equation&lt;/a&gt; can be processed using a &lt;a href=&quot;https://en.wikipedia.org/wiki/Finite_difference_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;finite difference method&lt;/a&gt; and solved using &lt;a href=&quot;https://en.wikipedia.org/wiki/Matrix_differential_equation#Deconstructed_example_of_a_matrix_ordinary_differential_equation&quot; rel=&quot;nofollow noreferrer&quot;&gt;matrix differential equations&lt;/a&gt;. A matrix of small simple equations is easier, and faster, to solve than a matrix of polynomials.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For much easier to follow examples see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://blog.minitab.com/blog/adventures-in-statistics-2/what-is-the-difference-between-linear-and-nonlinear-equations-in-regression-analysis&quot; rel=&quot;nofollow noreferrer&quot;&gt;What Is the Difference between Linear and Nonlinear Equations in Regression Analysis?&lt;/a&gt;&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Compare a linear versus a nonlinear regression model of the &lt;a href=&quot;https://blog.minitab.com/blog/adventures-in-statistics/linear-or-nonlinear-regression-that-is-the-question&quot; rel=&quot;nofollow noreferrer&quot;&gt;relationship between density and electron mobility&lt;/a&gt;. The nonlinear equation is so long it that it doesn't fit on the graph:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\Tiny{\begin{align}&#xA;\text{Linear equation (left side)} &amp;amp; \qquad \qquad \qquad \qquad \\&#xA;\text{Mobility } = &amp;amp; \text{ } 1243 + 412.3 \times \text{Density Ln} - 94.29 \times \text{Density Ln}^2 - 32.90 \times \text{Density Ln}^3 \qquad \quad \\&#xA;&amp;amp; \\&#xA;\text{Non-linear equation (right side)}  &amp;amp; \\&#xA;\text{Mobility } = &amp;amp; (1288.14 + 1491.08 \times \text{Density Ln} + 583.238 \times \text{Density Ln}^2 + 75.4167 \times \text{Density Ln}^3) / (1 + 0.966295 \times \text{Density Ln} + 0.397973 \times \text{Density Ln}^2 + 0.0497273 \times \text{Density Ln}^3) \quad \\&#xA;\end{align}}$$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5m0Xh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5m0Xh.jpg&quot; alt=&quot;Linear versus Non-linear&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the left:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;The fitted line plot shows that the raw data follow a nice tight function and the R-squared is 98.5%, which looks pretty good. However, look closer and the regression line systematically over and under-predicts the data at different points in the curve. When you check the residuals plots (which you always do, right?), you see patterns in the Residuals versus Fits plot, rather than the randomness that you want to see. This indicates a bad fit, but it’s the best that linear regression can do.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On the right:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;The fitted line plot shows that the regression line follows the data almost exactly -- there are no systematic deviations. It’s impossible to calculate R-squared for nonlinear regression, but the &lt;a href=&quot;https://blog.minitab.com/blog/adventures-in-statistics/regression-analysis-how-to-interpret-s-the-standard-error-of-the-regression&quot; rel=&quot;nofollow noreferrer&quot;&gt;S value&lt;/a&gt; (roughly speaking, the average absolute distance from the data points to the regression line) improves from 72.4 (linear) to just 13.7 for nonlinear regression. You want a lower S value because it means the data points are closer to the fit line. What's more, the Residual versus Fits plot shows the randomness that you want to see.  It’s a good fit!&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Beginner level references:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;&lt;a href=&quot;https://blog.minitab.com/blog/adventures-in-statistics-2/linear-or-nonlinear-regression-that-is-the-question&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linear or Nonlinear Regression? That Is the Question.&lt;/a&gt;&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;&lt;a href=&quot;https://blog.minitab.com/blog/adventures-in-statistics-2/how-to-predict-with-minitab-using-bmi-to-predict-the-body-fat-percentage-part-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to Predict with Minitab: Using BMI to Predict the Body Fat Percentage, Part 1&lt;/a&gt;&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;&lt;a href=&quot;https://blog.minitab.com/blog/adventures-in-statistics-2/how-to-predict-with-minitab-using-bmi-to-predict-the-body-fat-percentage-part-2&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to Predict with Minitab: Using BMI to Predict the Body Fat Percentage, Part 2&lt;/a&gt;&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;&lt;a href=&quot;https://blog.minitab.com/blog/adventures-in-statistics-2/what-is-the-difference-between-linear-and-nonlinear-equations-in-regression-analysis&quot; rel=&quot;nofollow noreferrer&quot;&gt;What Is the Difference between Linear and Nonlinear Equations in Regression Analysis?&lt;/a&gt;&quot;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="123" LastEditDate="2019-10-23T18:59:19.823" LastActivityDate="2019-10-23T18:59:19.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2896" PostTypeId="1" AcceptedAnswerId="2901" CreationDate="2019-10-23T14:37:58.550" Score="7" ViewCount="1254" Body="&lt;p&gt;I'm solving the magic square problem for my operational research exam. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The constraints of my model are that the sum of the elements on the lines must be equal to a constant (var constant), that the sum of the elements on the columns must be equal to the same constant and that also the sum on the diagonals must be equal to the same constant . These constraints are &lt;code&gt;r, c, d1&lt;/code&gt; and &lt;code&gt;d2&lt;/code&gt;.&#xA;I have also inserted a constraint &lt;code&gt;q1&lt;/code&gt; to find this constant because there is the property that multiplying the order of the matrix by the magic constant yields the sum of the values ​​from &lt;code&gt;1 to k^2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;k=3&lt;/code&gt;, I get this matrix in output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 9 5&#xA;5 9 1&#xA;5 1 9&#xA;&#xA;Magic_Constant: 15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that's not good, I have to find a way to insert a constraint that says that all the values ​​in the matrix must be different (from &lt;code&gt;1&lt;/code&gt; to &lt;code&gt;n^2&lt;/code&gt;). But I can't use the &lt;code&gt;alldiff&lt;/code&gt; operator!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;### PARAMETER ###&#xA;param k;&#xA;param firstKnumber = ((k*k)/2)*(k*k+1);&#xA;&#xA;### VARIABLE ###&#xA;var x{1..k,1..k} &amp;gt;= 1 &amp;lt;= k*k integer;&#xA;var constant;&#xA;&#xA;### CONSTRAINT ###&#xA;subject to r{t in 1..k}: sum{i in 1..k} x[t,i] = constant;&#xA;subject to c{t in 1..k}: sum{i in 1..k} x[i,t] = constant;&#xA;subject to d1: sum{i in 1..k} x[i,i] = constant;&#xA;subject to d2: sum{i in 1..k} x[i,k-i+1] = constant;&#xA;subject to q1: firstKnumber = constant*k;&#xA;&#xA;&#xA;### OBJECTIVE ###&#xA;minimize Magic_Constant: constant;&#xA;&#xA;data;&#xA;param k:= 3;&#xA;option solver gurobi;&#xA;solve;&#xA;&#xA;display Magic_Constant;&#xA;&#xA;for{i in 1..n} {&#xA; for {j in 1..n} {&#xA;  printf &quot;%3d &quot;, x[i,j];&#xA;  }&#xA; printf &quot;\n&quot;;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2577" LastActivityDate="2019-10-24T05:14:48.763" Title="Matrix in ampl: constraint that the values ​are all different" Tags="|ampl|" AnswerCount="4" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2897" PostTypeId="2" ParentId="831" CreationDate="2019-10-23T15:21:03.920" Score="4" Body="&lt;p&gt;The previous answer provided a great list on the classical dynamic programming. For Reinforcement learning and Deep Reinforcement learning, a wonderful online free course on RL by David Silver (the first author of the AlphaZero, AlphaGo algorithms) exists:&#xA;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLzuuYNsE1EZAXYR4FJ75jcJseBmo4KQ9-&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouTube links&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more advanced course by Sergey Levine exists for free at:&#xA;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLkFD6_40KJIxJMR-j5A1mkxK26gh_qg37&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouTube link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For both course the link to the material of the course is available too. &lt;/p&gt;&#xA;" OwnerUserId="41" LastActivityDate="2019-10-23T15:21:03.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2898" PostTypeId="2" ParentId="2896" CreationDate="2019-10-23T15:26:09.583" Score="3" Body="&lt;p&gt;In &lt;a href=&quot;https://ampl.com/resources/logic-constraint-extensions-examples/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AMPL's website&lt;/a&gt;, there is a code for solving sudoku which is very similar to your problem. In their code they also used &lt;code&gt;alldiff&lt;/code&gt;. The only thing that you need to add to the following model is some constraint to consider the diagonal summation as well. By the way, &quot;a Sudoku puzzle is defined as a logic-based, number-placement puzzle. The objective is to fill a 9×9 grid with digits in such a way that each column, each row, and each of the nine 3×3 grids that make up the larger 9×9 grid contains all of the digits from 1 to 9. Each Sudoku puzzle begins with some cells filled in&quot;(1). In some sudokus, main diagonals also contain the digits 1 through 9. This variant is called Sudoku X (&lt;em&gt;Diagonal Sudoku&lt;/em&gt;)(2).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The AMPL code for Sudoku:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;param given {1..9, 1..9} integer, in 0..9;&#xA;  # given[i,j] &amp;gt; 0 is the value given for row i, col j&#xA;  # given[i,j] = 0 means no value given &#xA;var X {1..9, 1..9} integer, in 1..9;&#xA;  # x[i,j] = the number assigned to the cell in row i, col j&#xA;subj to AssignGiven {i in 1..9, j in 1..9: given[i,j] &amp;gt; 0}: X[i,j]= given[i,j];&#xA;  # assign given values&#xA;subj to Rows {i in 1..9}: alldiff {j in 1..9} X[i,j];&#xA;  # cells in the same row must be assigned distinct numbers&#xA;subj to Cols {j in 1..9}: alldiff {i in 1..9} X[i,j];&#xA;  # cells in the same column must be assigned distinct numbers&#xA;subj to Regions {I in 1..9 by 3, J in 1..9 by 3}: alldiff {i in I..I+2, j in J..J+2} X[i,j];&#xA;  # cells in the same region must be assigned distinct numbers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Thanks to @GeoffreyBrent, I think I need to provide &lt;a href=&quot;http://profs.sci.univr.it/~rrizzi/classes/PLS2015/sudoku/doc/497_Olszowy_Wiktor_Sudoku.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt;, where you can find another version of the AMPL code for sudoku problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) &lt;a href=&quot;https://www.bigfishgames.com/blog/how-to-solve-sudoku-puzzles-quickly-and-reliably/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.bigfishgames.com/blog/how-to-solve-sudoku-puzzles-quickly-and-reliably/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) &lt;a href=&quot;http://www.cross-plus-a.com/sudoku.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.cross-plus-a.com/sudoku.htm&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-10-24T05:14:48.763" LastActivityDate="2019-10-24T05:14:48.763" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2899" PostTypeId="1" AcceptedAnswerId="2915" CreationDate="2019-10-23T16:58:38.070" Score="10" ViewCount="341" Body="&lt;p&gt;&lt;strong&gt;General question:&lt;/strong&gt; What software can solve convex programs defined by a separation oracle?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The objective function is concave, and the feasible set is a polytope. By a  separation oracle I mean that I would program a function that, on input a point, would return whether or not that point is in the feasible set and, if the point is not, also produce an inequality separating the given point from the feasible set. I'd love to be able to feed this function into something like cvxopt or mosek and maximize a concave function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More specifically, the polytope I'm interested in is the convex hull of the indicators of basis of a matroid. We assume that we have an efficient independence oracle for the matroid, meaning that we obtain a separation oracle for the polytope via the techniques in &lt;a href=&quot;https://doi.org/10.1016/0095-8956(84)90023-6&quot; rel=&quot;nofollow noreferrer&quot;&gt;Testing Membership in Matroid Polyhedra&lt;/a&gt; by Cunningham.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be interested in the following special case:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Specific Question:&lt;/strong&gt; What software / algorithms are practically useful for maximizing a concave function over the spanning tree polytope?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; It appears that the correct word to use for OR is &quot;cutting plane,&quot; rather than &quot;separation oracle.&quot; &lt;a href=&quot;https://see.stanford.edu/materials/lsocoee364b/05-localization_methods_notes.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;These notes overview some cutting plane methods.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt; I am interested in implementing the algorithm in &lt;a href=&quot;https://arxiv.org/abs/1807.00929&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware that the ellipsoid method can be in theory used for this, but as I understand it that algorithm is not practically useful. I know that the number of spanning trees can be calculated efficiently without this; I'm just curious about the effectiveness of this particular algorithm, and would like to compare it to this case where the correct answer can be calculated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Update:&lt;/em&gt; We reached out to Nima Anari, and he suggested using something like Frank-Wolfe since the specific polytopes I was interested in had efficient linear optimization oracles. There is a little bit of funny business guaranteeing convergence, since the curvature of the entropy function blows up near parts of the boundary, but initializing with a &quot;random&quot; point in the interior worked well in practice. The code is here: &lt;a href=&quot;https://github.com/LorenzoNajt/EntropyCounting/blob/master/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/LorenzoNajt/EntropyCounting/blob/master/README.md&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1027" LastEditorUserId="1027" LastEditDate="2019-12-15T20:51:28.957" LastActivityDate="2019-12-15T20:51:28.957" Title="Solving convex programs defined by separation oracles?" Tags="|optimization|nonlinear-programming|convexity|polyhedra|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2900" PostTypeId="2" ParentId="2892" CreationDate="2019-10-23T23:21:24.917" Score="0" Body="&lt;p&gt;This is a complicated question with a complicated answer. Linearisations are a powerful tool when used correctly, but can also have massive drawbacks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Others have covered a lot of the theoretical implications, so I will share what I have seen in applied problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because we (Octeract) sell nonlinear optimisation technology we spend a lot of time studying whether a client needs nonlinear optimisation, or if they are better off using linear approximations. Our conclusion so far has been it depends on the math and the people writing the math. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Certain problems are just not amenable to linearisations. These predominantly tend to be problems where the price of things is a dependent variable. In these cases we have seen linearised models (that our clients were using at the time) diverge by up to 10,000% from where the global solution actually was. In other cases, where clients were using massive linear models with only a few nonlinear terms, linearisations were just fine. In process design problems, we have seen deviations up to 2,000%. When it comes to modelling risk, we have seen that linearising inherently nonlinear dependencies is basically equivalent to making random decisions - solutions tend to be at least 10x the noise in the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I was to distil these down to rules of thumb, then I would say that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;linearisations work well for problems that are mostly linear&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;linearisations work well if variable dependencies are not critical to performance &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;linearisations work well as long as they produce sub-million variable MILPs&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;linearisations make (partial) sense if someone has already paid for a license for an expensive linear solver&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;linearisations make sense for applications where accuracy is not that important, but getting a feasible solution quickly is (e.g. certain control problems).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;linearisations make sense if you know there is little noise in the data. Otherwise it is impossible to tell how good the solution of the linearisation is.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;linearisations make sense when doing soft constraint modelling, or linearising fairly smooth parts of nonlinear problems to make them more easy to solve.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;linearisations make sense in cases where we empirically know that they work well.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;linearisations make sense as long as the person performing them is experienced enough to avoid a combinatorial explosion.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In all other cases it is worth at least trying to solve the MINLP and measure the difference in quality of solution, performance, and consistency.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-10-23T23:21:24.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2901" PostTypeId="2" ParentId="2896" CreationDate="2019-10-24T00:31:50.813" Score="3" Body="&lt;p&gt;Outside an exam scenario, the correct answer is &quot;switch to a solver that supports &lt;code&gt;alldiff&lt;/code&gt;&quot;, but I'm assuming you are required to solve this in Gurobi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to approach this within the confines of a linear integer problem is to make your decision variable a binary, with an extra dimension added. Hence, instead of &quot;value of X at [i,j]&quot; your decision variable now represents &quot;whether X[i,j] = h&quot; for h in 1..n^2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this is an exam question, I won't spell out everything, but with this change it should be easy enough to represent all the constraints in linear format including the alldiff constraint.&lt;/p&gt;&#xA;" OwnerUserId="546" LastActivityDate="2019-10-24T00:31:50.813" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2902" PostTypeId="2" ParentId="2862" CreationDate="2019-10-24T02:57:33.657" Score="-2" Body="&lt;p&gt;I know a guy that is working on this project:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/gleraromero/kaleidoscope&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/gleraromero/kaleidoscope&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it supports some common optimization algorithms like Column Generation, Branch &amp;amp; Cut and Branch Cut &amp;amp; Price among others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's based on the output of another project he's working on, but maybe it's useful for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I liked this question because some years ago I found that solvers (for instance CPLEX) don't have, as far as I know, good visualisation tools. It could be an interesting side project something that takes some simple CPLEX output and builds a simple dashboard with that (call it CPLEXboard ;) ).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It could be useful to analyse how the tree is explored, the value of the variables, branching variables, number of cuts, time, nodes and stuff, all live in an interactive environment, instead of just digging a log file... &lt;/p&gt;&#xA;" OwnerUserId="806" LastActivityDate="2019-10-24T02:57:33.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2903" PostTypeId="1" AcceptedAnswerId="2910" CreationDate="2019-10-24T10:44:57.670" Score="8" ViewCount="2118" Body="&lt;p&gt;I have the following constraints&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\sum_{i=1}^{N}{x_it_i}&amp;amp;= M\\\sum_{i=1}^{N}{t_i}&amp;amp;\le S\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x_i\ge 0$&lt;/span&gt; is an integer variable, &lt;span class=&quot;math-container&quot;&gt;$t_i\in\{0,1\}$&lt;/span&gt; is a binary variable and &lt;span class=&quot;math-container&quot;&gt;$M,S$&lt;/span&gt; are known numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I linearize this?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="123" LastEditDate="2019-10-24T18:04:58.373" LastActivityDate="2019-10-24T23:36:15.577" Title="How to linearize the multiplication of an integer and a binary integer variable?" Tags="|linear-programming|integer-programming|linearization|binary-variable|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2904" PostTypeId="1" CreationDate="2019-10-24T11:39:27.400" Score="12" ViewCount="1331" Body="&lt;p&gt;As far as I know, most machine learning algorithms solve unconstrained optimization problems, i.e., if we were to unroll all the neurons into symbolic expressions we would end up with a massive objective function and no constraints.&lt;/p&gt;&#xA;&lt;p&gt;I read somewhere that SVM algorithms solve constrained problems instead, so I am wondering:&lt;/p&gt;&#xA;&lt;p&gt;Which machine learning algorithms actually solve constrained optimization problems?&lt;/p&gt;&#xA;&lt;p&gt;Just to clarify, my question is with respect to using constrained optimization as part of the algorithm, not feeding constrained problems in.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="491" LastEditDate="2022-11-18T17:40:53.513" LastActivityDate="2022-11-18T17:40:53.513" Title="Which ML algorithms work by solving constrained optimization problems?" Tags="|constraint|machine-learning|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2906" PostTypeId="1" CreationDate="2019-10-24T16:48:35.507" Score="5" ViewCount="150" Body="&lt;p&gt;I am using docplex.cp and I need to state the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{c}(X_p{_w}_{cj}+X_{p+1}{_{w'}}_{cj+1})\leqslant T_w{_{w'}}_{,jj+1} + 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Knowing that the binary variables are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_p{_w}_{cj}=1$&lt;/span&gt; if an operation &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is done by a machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; with a configuration &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; at process plan position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and zero otherwise&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$T_w{_{w'}}_{,jj+1}=1$&lt;/span&gt; if there is a change of machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; between position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j+1$&lt;/span&gt;, and zero otherwise.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;    for w in range(1, len(operation_cost) + 1): &#xA;        for w1 in range(1, len(operation_cost) + 1):&#xA;            for c in range(1, len(operation_cost[w-1]) + 1):&#xA;                for c1 in range(1, len(operation_cost[w1-1]) + 1):&#xA;                    for p in range(1, len(operation_cost[w-1][c-1]) + 1): &#xA;                        for p1 in range(1, len(operation_cost[w1-1][c1-1]) + 1): &#xA;                            for j in range(2, len(operation_cost[w-1][c-1]) + 1):&#xA;                                opt_model.add(opt_model.sum(X_var[p, w, c, j-1] + X_var[p1, w1, c1, j]&#xA;                                            for c in range(1, len(operation_cost[w-1]) + 1) &#xA;                                            for c1 in range(1, len(operation_cost[w1-1]) + 1)) &amp;lt;= 1 + T_var[w, w1, j-1, j])&#xA;   &#xA;&#xA;&#xA;    operation_cost = [[[29, 0, 0, 31, 0, 27, 0], [23, 0, 19, 0, 36, 0, 0], [0, 14, 0, 0, 0, 0, 50]],&#xA;     [[0, 0, 0, 34, 0, 41, 0],&#xA;      [0, 25, 0, 0, 32, 23, 0],&#xA;      [24, 21, 56, 0, 0, 0, 30]]]                        &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I run this constraint it works well, without returning errors. However, when I run the total code (considering all objectives, variables, constraints) I cannot attain a result.&#xA;I am wondering that the program is not able to understand the relation between &lt;em&gt;X&lt;/em&gt; and &lt;em&gt;T&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here there are some info concerning my result. As it shows, it was not possible to find a solution.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{'AverageFailDepth': 0,&#xA; 'DepthFirstAverageIdleTime': 0,&#xA; 'DepthFirstIdleTime': 0,&#xA; 'DepthFirstIdleTimePercentage': 0,&#xA; 'DeterministicTimePerBranch': 0,&#xA; 'EffectiveDepthFirstWorkers': 0,&#xA; 'EffectiveIterativeDivingWorkers': 0,&#xA; 'EffectiveMultiPointWorkers': 0,&#xA; 'EffectiveOptimalityTolerance': 'infinity',&#xA; 'EffectiveRestartWorkers': 0,&#xA; 'EffectiveWorkers': 4,&#xA; 'EngineAverageIdleTime': 0,&#xA; 'EngineIdleTime': -864688000.0,&#xA; 'EngineIdleTimeCount': 0,&#xA; 'EngineIdleTimePercentage': 0,&#xA; 'EngineIdleTimeSum': 0,&#xA; 'EngineMaxIdleTime': 0,&#xA; 'EngineMemoryUsage': 53702761,&#xA; 'ExtractionTime': 0.31,&#xA; 'FailDepthCount': 0,&#xA; 'FailDepthSum': 0,&#xA; 'FailStatus': 'SearchHasFailedNormally',&#xA; 'Gap': 'infinity',&#xA; 'IterativeDivingAverageIdleTime': 0,&#xA; 'IterativeDivingIdleTime': 0,&#xA; 'IterativeDivingIdleTimePercentage': 0,&#xA; 'MemoryUsage': 54433713,&#xA; 'MultiPointAverageIdleTime': 0,&#xA; 'MultiPointIdleTime': 0,&#xA; 'MultiPointIdleTimePercentage': 0,&#xA; 'NumberOfAuxiliaryVariables': 0,&#xA; 'NumberOfBranches': 0,&#xA; 'NumberOfChoicePoints': 0,&#xA; 'NumberOfConstraints': 14488,&#xA; 'NumberOfConstraintsAdded': 0,&#xA; 'NumberOfConstraintsAggregated': 4770,&#xA; 'NumberOfConstraintsGenerated': 0,&#xA; 'NumberOfConstraintsRemoved': 0,&#xA; 'NumberOfCriteria': 1,&#xA; 'NumberOfEngineConstraints': 0,&#xA; 'NumberOfEngineVariables': 440,&#xA; 'NumberOfErrors': 0,&#xA; 'NumberOfFails': 0,&#xA; 'NumberOfIntegerVariables': 438,&#xA; 'NumberOfIntervalVariables': 0,&#xA; 'NumberOfModelVariables': 438,&#xA; 'NumberOfPresolveTransformations': 4770,&#xA; 'NumberOfSequenceVariables': 0,&#xA; 'NumberOfSolutions': 0,&#xA; 'NumberOfStateFunctions': 0,&#xA; 'NumberOfUnboundModelVariables': 438,&#xA; 'NumberOfUnboundModelVariablesInLogPeriod': 'intmax',&#xA; 'NumberOfVariables': 438,&#xA; 'NumberOfWarnings': 0,&#xA; 'NumberOfWorkerSynchronizations': 4,&#xA; 'PeakMemoryUsage': 54434018,&#xA; 'PresolveTime': 0.289,&#xA; 'RestartAverageIdleTime': 0,&#xA; 'RestartIdleTime': 0,&#xA; 'RestartIdleTimePercentage': 0,&#xA; 'SearchDeterministicTime': 0,&#xA; 'SearchMemoryUsage': 730952,&#xA; 'SearchStatus': 'SearchCompleted',&#xA; 'SearchStopCause': 'SearchHasNotBeenStopped',&#xA; 'SolveTime': 0.32,&#xA; 'TotalTime': 0.321}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My question is:&lt;/p&gt;&#xA;&lt;p&gt;Is there a better way to state the relation between these two variables using docplex? What could I do to rectify this problem?&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="491" LastEditDate="2022-01-25T22:44:06.237" LastActivityDate="2022-01-25T22:44:06.237" Title="How to handle constraints in docplex to states the relation between two variables?" Tags="|python|constraint-programming|docplex|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2907" PostTypeId="1" CreationDate="2019-10-24T20:08:36.527" Score="11" ViewCount="1856" Body="&lt;p&gt;I am trying to understand how the Vehicle Routing Problem is solved in OR-Tools.&#xA;Using the example given &lt;a href=&quot;https://developers.google.com/optimization/routing/vrp&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, I have tried to solve the following distance matrix with 9 separate vehicles:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[0, 1, 1, 1, 1, 1, 1, 1, 1, 1], &#xA;[1, 0, 1, 1, 1, 1, 1, 1, 1, 1], &#xA;[1, 1, 0, 1, 1, 1, 1, 1, 1, 1], &#xA;[1, 1, 1, 0, 1, 1, 1, 1, 1, 1], &#xA;[1, 1, 1, 1, 0, 1, 1, 1, 1, 1], &#xA;[1, 1, 1, 1, 1, 0, 1, 1, 1, 1], &#xA;[1, 1, 1, 1, 1, 1, 0, 1, 1, 1], &#xA;[1, 1, 1, 1, 1, 1, 1, 0, 1, 1], &#xA;[1, 1, 1, 1, 1, 1, 1, 1, 0, 1], &#xA;[1, 1, 1, 1, 1, 1, 1, 1, 1, 0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My understanding is, that the example given should minimize the longest route, resulting in 9 routes of similar length. To quote the example:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This makes the global span the predominant factor in the objective function, so the program minimizes the length of the longest route.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In this simple example, each vehicle should visit one node and return to the depot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead I get this result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0 -&amp;gt; 6 -&amp;gt; 7 -&amp;gt; 8 -&amp;gt; 9 -&amp;gt; 0&#xA;0 -&amp;gt; 4 -&amp;gt; 3 -&amp;gt; 2 -&amp;gt; 1 -&amp;gt; 0&#xA;0 -&amp;gt; 5 -&amp;gt; 0&#xA;... 6x times ...&#xA;0 -&amp;gt; 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I misunderstanding the VRP, OR-Tools, or is there a more basic mistake?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried various settings for &lt;code&gt;FirstSolutionStrategy&lt;/code&gt; and &lt;code&gt;LocalSearchMetaheuristic&lt;/code&gt;, and used other symmetric matrices with the same result: It's always possible to remove a node from the longest route, assign it to an unused one and thereby trivially improve the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import com.google.ortools.constraintsolver.Assignment;&#xA;import com.google.ortools.constraintsolver.FirstSolutionStrategy;&#xA;import com.google.ortools.constraintsolver.RoutingDimension;&#xA;import com.google.ortools.constraintsolver.RoutingIndexManager;&#xA;import com.google.ortools.constraintsolver.RoutingModel;&#xA;import com.google.ortools.constraintsolver.RoutingSearchParameters;&#xA;import com.google.ortools.constraintsolver.main;&#xA;import java.util.logging.Logger;&#xA;&#xA;/** Minimal VRP.*/&#xA;public class VrpGlobalSpan {&#xA;  static {&#xA;    System.loadLibrary(&quot;jniortools&quot;);&#xA;  }&#xA;&#xA;  private static final Logger logger = Logger.getLogger(VrpGlobalSpan.class.getName());&#xA;&#xA;  static class DataModel {&#xA;    public final long[][] distanceMatrix = {&#xA;        {0,1,1,1,1,1,1,1,1,1},&#xA;        {1,0,1,1,1,1,1,1,1,1},&#xA;        {1,1,0,1,1,1,1,1,1,1},&#xA;        {1,1,1,0,1,1,1,1,1,1},&#xA;        {1,1,1,1,0,1,1,1,1,1},&#xA;        {1,1,1,1,1,0,1,1,1,1},&#xA;        {1,1,1,1,1,1,0,1,1,1},&#xA;        {1,1,1,1,1,1,1,0,1,1},&#xA;        {1,1,1,1,1,1,1,1,0,1},&#xA;        {1,1,1,1,1,1,1,1,1,0}&#xA;    };&#xA;    public final int vehicleNumber = 9;&#xA;    public final int depot = 0;&#xA;  }&#xA;&#xA;  /// @brief Print the solution.&#xA;  static void printSolution(&#xA;      DataModel data, RoutingModel routing, RoutingIndexManager manager, Assignment solution) {&#xA;    // Inspect solution.&#xA;    long maxRouteDistance = 0;&#xA;    for (int i = 0; i &amp;lt; data.vehicleNumber; ++i) {&#xA;      long index = routing.start(i);&#xA;      logger.info(&quot;Route for Vehicle &quot; + i + &quot;:&quot;);&#xA;      long routeDistance = 0;&#xA;      String route = &quot;&quot;;&#xA;      while (!routing.isEnd(index)) {&#xA;        route += manager.indexToNode(index) + &quot; -&amp;gt; &quot;;&#xA;        long previousIndex = index;&#xA;        index = solution.value(routing.nextVar(index));&#xA;        routeDistance += routing.getArcCostForVehicle(previousIndex, index, i);&#xA;      }&#xA;      logger.info(route + manager.indexToNode(index));&#xA;      logger.info(&quot;Distance of the route: &quot; + routeDistance + &quot;m&quot;);&#xA;      maxRouteDistance = Math.max(routeDistance, maxRouteDistance);&#xA;    }&#xA;    logger.info(&quot;Maximum of the route distances: &quot; + maxRouteDistance + &quot;m&quot;);&#xA;  }&#xA;&#xA;  public static void main(String[] args) throws Exception {&#xA;    // Instantiate the data problem.&#xA;    final DataModel data = new DataModel();&#xA;&#xA;    // Create Routing Index Manager&#xA;    RoutingIndexManager manager =&#xA;        new RoutingIndexManager(data.distanceMatrix.length, data.vehicleNumber, data.depot);&#xA;&#xA;    // Create Routing Model.&#xA;    RoutingModel routing = new RoutingModel(manager);&#xA;&#xA;    // Create and register a transit callback.&#xA;    final int transitCallbackIndex =&#xA;        routing.registerTransitCallback((long fromIndex, long toIndex) -&amp;gt; {&#xA;          // Convert from routing variable Index to user NodeIndex.&#xA;          int fromNode = manager.indexToNode(fromIndex);&#xA;          int toNode = manager.indexToNode(toIndex);&#xA;          return data.distanceMatrix[fromNode][toNode];&#xA;        });&#xA;&#xA;    // Define cost of each arc.&#xA;    routing.setArcCostEvaluatorOfAllVehicles(transitCallbackIndex);&#xA;&#xA;    // Add Distance constraint.&#xA;    routing.addDimension(transitCallbackIndex, 0, 3000,&#xA;        true, // start cumul to zero&#xA;        &quot;Distance&quot;);&#xA;    RoutingDimension distanceDimension = routing.getMutableDimension(&quot;Distance&quot;);&#xA;    distanceDimension.setGlobalSpanCostCoefficient(100);&#xA;&#xA;    // Setting first solution heuristic.&#xA;    RoutingSearchParameters searchParameters =&#xA;        main.defaultRoutingSearchParameters()&#xA;            .toBuilder()&#xA;            .setFirstSolutionStrategy(FirstSolutionStrategy.Value.PATH_CHEAPEST_ARC)&#xA;            .build();&#xA;&#xA;    // Solve the problem.&#xA;    Assignment solution = routing.solveWithParameters(searchParameters);&#xA;&#xA;    // Print solution on console.&#xA;    printSolution(data, routing, manager, solution);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2586" LastEditorUserId="2586" LastEditDate="2019-10-25T15:11:57.060" LastActivityDate="2019-10-25T16:06:40.240" Title="Incorrect solution for Vehicle Routing Problem in or-tools" Tags="|vehicle-routing|or-tools|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2908" PostTypeId="1" CreationDate="2019-10-24T23:26:00.643" Score="6" ViewCount="60" Body="&lt;p&gt;I am doing some output analysis on a discrete event simulation model and trying to interpret the results. My first step was to run the baseline model to get the response variable, let's say it's 10 with a 95% confidence interval(&lt;em&gt;CI&lt;/em&gt;) of 8-12. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then run three more simulations, adjusting, one at a time, input Factor A, B, and C. This gives me the mean response and CI, showing the response output is significantly different:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Baseline    Factor A     Factor B      Factor C&#xA;10(8-12)   14(13-15)    20 (16-24)    15(13-18)  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then run a full factorial DOE, setting my factors to low (baseline value), or high (same input values as before). The DOE has no significant P-values when I run an ANOVA on the 8 different runs. Does this mean my simulation is incorrect? Or is this the difference of testing the simulation against a control (baseline), versus the impact of each factor as other factors change?&lt;/p&gt;&#xA;" OwnerUserId="2587" LastEditorUserId="39" LastEditDate="2019-10-24T23:39:27.803" LastActivityDate="2019-10-24T23:39:27.803" Title="DOE Output Versus Testing Against Baseline" Tags="|simulation|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2910" PostTypeId="2" ParentId="2903" CreationDate="2019-10-24T23:36:15.577" Score="3" Body="&lt;p&gt;&lt;strong&gt;Case 1:&lt;/strong&gt; As @KevinDalmeijer commented: If &lt;span class=&quot;math-container&quot;&gt;$\ \forall x_i \ \ \exists \ \ U_i \in \mathbb{Z}^+$&lt;/span&gt;(given upper bounds for variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;) you can define new integer variables &lt;span class=&quot;math-container&quot;&gt;$y_i = x_it_i \ \ \forall i \in \{1,2,...,N\}$&lt;/span&gt; and then replace your constraints with the followings:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{1}^{N} y_i = M$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t_i \leq y_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_i \leq t_i \times U_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note that, when &lt;span class=&quot;math-container&quot;&gt;$t_i=0$&lt;/span&gt; constraints &lt;em&gt;2&lt;/em&gt; and &lt;em&gt;3&lt;/em&gt; forces &lt;span class=&quot;math-container&quot;&gt;$y_i=0$&lt;/span&gt;, but when &lt;span class=&quot;math-container&quot;&gt;$t_i=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$1 \leq y_i \leq U_i$&lt;/span&gt; which excludes the &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt;, but as &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; is &lt;em&gt;neutral element&lt;/em&gt; for addition, it won't affect your summation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Case 2:&lt;/strong&gt; If there are no upper bounds for &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;  in the model, you can define constraint &lt;em&gt;3&lt;/em&gt; as follow:&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_i \leq t_i \times M$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;which indicates that if &lt;span class=&quot;math-container&quot;&gt;$t_i \neq 0$&lt;/span&gt;, for any &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; can not be greater than &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; which is necessary to hold your first constraint.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-10-24T23:36:15.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2911" PostTypeId="1" CreationDate="2019-10-25T07:10:52.870" Score="10" ViewCount="289" Body="&lt;p&gt;In a Linear Programming formulation, stating that a punishment is to be introduced in an objective minimization function if a variable &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; holds a value above a given constant &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$K = 35$&lt;/span&gt; in the below example), is quite easy:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Variable &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is included in (minimize) objective function such that &lt;span class=&quot;math-container&quot;&gt;$M\ge0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S-M-35\le0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Exemplified explanation: If &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; gets value &lt;span class=&quot;math-container&quot;&gt;$30$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; may be kept at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, so no punishment in objective function. However, if &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; gets value &lt;span class=&quot;math-container&quot;&gt;$40$&lt;/span&gt; in problem solution, &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is forced to at least &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;, and consequently a punishment of &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; is included, just as desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what if we want to include goodness in objective function if &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; gets value above &lt;span class=&quot;math-container&quot;&gt;$35$&lt;/span&gt;? E.g. in the previous example, a value of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; equal to &lt;span class=&quot;math-container&quot;&gt;$30$&lt;/span&gt; should (still) not influence the objective function. But a value of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; equal to &lt;span class=&quot;math-container&quot;&gt;$40$&lt;/span&gt; should decrease the objective function cost with &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I originally thought this &quot;swap&quot; from badness to goodness would be easy, but I worked on it for almost a full day without finding a solution...&lt;/p&gt;&#xA;" OwnerUserId="2588" LastEditorUserId="123" LastEditDate="2019-10-25T15:37:48.193" LastActivityDate="2019-10-26T22:25:58.443" Title="Linear Programming: Objective function goodness if variable holds value above a given constant value" Tags="|linear-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2912" PostTypeId="2" ParentId="2911" CreationDate="2019-10-25T07:19:35.913" Score="5" Body="&lt;p&gt;For anyone reading the post.  I have got the following answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;In other words, you want to maximize &lt;span class=&quot;math-container&quot;&gt;$\max\{S−35,0\}$&lt;/span&gt;. You cannot maximize a max or minimize a min in linear programming because these problems are nonconvex. You would need to introduce binary variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the badness example, you are instead minimizing &lt;span class=&quot;math-container&quot;&gt;$\max\{S−35,0\}$&lt;/span&gt;. Both minimizing a max and maximizing a min are doable with linear programming.&quot;&lt;/p&gt;&#xA;" OwnerUserId="2588" LastEditorUserId="123" LastEditDate="2019-10-25T15:38:26.023" LastActivityDate="2019-10-25T15:38:26.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2913" PostTypeId="2" ParentId="2907" CreationDate="2019-10-25T10:47:44.110" Score="6" Body="&lt;p&gt;I notice you are using &lt;code&gt;FirstSolutionStrategy.Value.PATH_CHEAPEST_ARC&lt;/code&gt;. If this name does what it suggests, then it's probably a greedy strategy that chooses between distance &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt; and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The clue is that you're using a strategy that does not guarantee optimal solutions. The structure also suggests that a certain random seed is used; there is an iteration above five until the largest node number is reached, an iteration under five until the lowest number is reached and in the end, five is left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: For any strategy to work, you cannot force it into making random decisions (such as choosing between &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;). This matrix offers enough variation for a simple strategy to work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],&#xA;[1, 0, 100, 100, 100, 100, 100, 100, 100, 100],&#xA;[2, 100, 0, 100, 100, 100, 100, 100, 100, 100],&#xA;[3, 100, 100, 0, 100, 100, 100, 100, 100, 100],&#xA;[4, 100, 100, 100, 0, 100, 100, 100, 100, 100],&#xA;[5, 100, 100, 100, 100, 0, 100, 100, 100, 100],&#xA;[6, 100, 100, 100, 100, 100, 0, 100, 100, 100],&#xA;[7, 100, 100, 100, 100, 100, 100, 0, 100, 100],&#xA;[8, 100, 100, 100, 100, 100, 100, 100, 0, 100],&#xA;[9, 100, 100, 100, 100, 100, 100, 100, 100, 0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2562" LastEditorUserId="2562" LastEditDate="2019-10-25T16:06:40.240" LastActivityDate="2019-10-25T16:06:40.240" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="2914" PostTypeId="1" CreationDate="2019-10-25T12:03:28.430" Score="7" ViewCount="700" Body="&lt;p&gt;I would like to solve an ILP and get all feasible solutions (even the worst one).&#xA;How could I do that using docplex.cp?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen a similar question in: &lt;a href=&quot;https://or.stackexchange.com/questions/167/using-cplex-solution-pool-to-count-feasible-points&quot;&gt;Using CPLEX &amp;quot;solution pool&amp;quot; to count feasible points&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I am not wrong, the answers were only focused on MIP problem, instead of ILP. I was not able to find a function in docplex for ILP problems able to call all feasible solutions.&#xA;I was wondering that I need to do an intermediate step in order to get these solutions, but I really do not know if it is possible. Could someone help me?&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="123" LastEditDate="2019-10-27T13:42:04.250" LastActivityDate="2019-10-30T19:12:43.917" Title="When using docplex.cp is it possible to get all feasible solutions?" Tags="|integer-programming|feasible-points|docplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2915" PostTypeId="2" ParentId="2899" CreationDate="2019-10-25T13:25:01.770" Score="6" Body="&lt;p&gt;The algorithm you are describing is Kelley's Cutting-Plane Method. &lt;a href=&quot;https://en.wikipedia.org/wiki/Cutting-plane_method&quot; rel=&quot;noreferrer&quot;&gt;Wikipedia&lt;/a&gt; gives a good description, and the original paper can be found &lt;a href=&quot;https://doi.org/10.1137/0108053&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this differs from the cutting plane methods described in the &lt;a href=&quot;https://see.stanford.edu/materials/lsocoee364b/05-localization_methods_notes.pdf&quot; rel=&quot;noreferrer&quot;&gt;note that you link&lt;/a&gt;. These 'ellipsoid method like methods' are also called cutting planes methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference is that with Kelley's method, you build an outer approximation of the feasible set, while with the ellipsoid method, you cut of sub-optimal regions of the feasible set. As a rule of thumb, the first one is only efficient in practice, and the second one is only efficient in theory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your problem is of the general form&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max &amp;amp;~f(x)\\&#xA;Ax &amp;amp;= b\\&#xA;x &amp;amp;\ge 0.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can rewrite this to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max &amp;amp;~t\\&#xA;g(x,t) &amp;amp;\le 0 \\&#xA;Ax &amp;amp;= b\\&#xA;x &amp;amp;\ge 0\\&#xA;t &amp;amp;\in \mathbb{R},&#xA;\end{align}&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$g(x,t) = t-f(x)$&lt;/span&gt;, which is a joint convex function in &lt;span class=&quot;math-container&quot;&gt;$(x,t)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kelley's method would first remove &lt;span class=&quot;math-container&quot;&gt;$g(x,t) \le 0$&lt;/span&gt; and solve the remaining linear program. Then, you find a cutting plane for &lt;span class=&quot;math-container&quot;&gt;$g(x,t)$&lt;/span&gt;, add it, and solve again. Repeat until the point that you find is (almost) feasible for the original problem. Because you are building an outer approximation, this point must be optimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solving the linear programs can be done with software such as CPLEX and Gurobi. Kelley's method is easily implemented as a simple loop, or as a callback in CPLEX or Gurobi. &lt;a href=&quot;https://orinanobworld.blogspot.com/2013/11/lp-cutting-planes-in-cplex.html&quot; rel=&quot;noreferrer&quot;&gt;In his blog&lt;/a&gt;, Paul Rubin describes how you can do this.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2019-10-25T13:25:01.770" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2917" PostTypeId="2" ParentId="2911" CreationDate="2019-10-25T15:53:32.887" Score="2" Body="&lt;p&gt;You can easily add &lt;span class=&quot;math-container&quot;&gt;$(S-35)\times N$&lt;/span&gt; to your objective function where &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is a big constant number. It works in two ways in a minimization problem:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$S \ge 35$&lt;/span&gt; then you will have punishment in your objective function.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$S \le 35$&lt;/span&gt; then it will decrease the objective function by the magnitude of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;While in your approach&lt;/em&gt;: when you don't want the effect of &lt;span class=&quot;math-container&quot;&gt;$S\le 35$&lt;/span&gt; in the objective function you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Define &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; as binary variables and add all the following constraints to the model (&lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is a big positive constant number):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$S\le 35 \times p + B\times q$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$S\ge 35 \times p - B\times p$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$p+q=1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$M \ge -B\times q$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$M \le B\times q$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$M \le S-35+B\times p$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$M \ge S-35-B\times p$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$p=1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$S\le35$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q=1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$S\ge35$&lt;/span&gt;. In each of these situation only two of the last four constraints will be active. When &lt;span class=&quot;math-container&quot;&gt;$p=1 \rightarrow M=0$&lt;/span&gt; and when &lt;span class=&quot;math-container&quot;&gt;$q=1 \rightarrow M=S-35$&lt;/span&gt;. Now you can add &lt;span class=&quot;math-container&quot;&gt;$-M$&lt;/span&gt; to your objective function.   &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-10-26T22:25:58.443" LastActivityDate="2019-10-26T22:25:58.443" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2918" PostTypeId="1" AcceptedAnswerId="2919" CreationDate="2019-10-25T18:02:41.480" Score="8" ViewCount="529" Body="&lt;p&gt;Trying to use minizinc builtins to do some basic validation of data inputs but I get a type error &lt;code&gt;MiniZinc: type error: no function or predicate with this signature found: 'assert(var bool,string)'&lt;/code&gt;&#xA;Is this because I'm using a predicate and not a function?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;include &quot;globals.mzn&quot;;&#xA;array[1..5] of int: x = 1..5;&#xA;constraint assert(increasing(x), &quot;x is not increasing&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2595" LastEditorUserId="260" LastEditDate="2019-10-26T06:22:41.100" LastActivityDate="2019-10-26T06:22:41.100" Title="Minizinc: How to use a predicate in an assert statement?" Tags="|constraint|constraint-programming|minizinc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2919" PostTypeId="2" ParentId="2918" CreationDate="2019-10-25T20:47:07.437" Score="6" Body="&lt;p&gt;&lt;code&gt;assert&lt;/code&gt; requires a &lt;code&gt;bool&lt;/code&gt; in the test part, and don't support &lt;code&gt;var bool&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A suggestion is to rewrite the &lt;code&gt;increasing&lt;/code&gt; constraint to a loop with single asserts with &lt;code&gt;bool&lt;/code&gt; expressions. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;include &quot;globals.mzn&quot;;&#xA;int: n = 5;&#xA;&#xA;array[1..n] of 1..n: x = [5,4,3,1,2];&#xA;&#xA;constraint forall(i in 1..n-1) (&#xA;   assert(x[i] &amp;lt;= x[i+1], &quot;x is not increasing&quot;)&#xA;);&#xA;&#xA;solve satisfy;&#xA;&#xA;output[ &quot;\(x)\n&quot;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This yield the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MiniZinc: evaluation error: &#xA;   /home/hakank/g12/me/assert_test.mzn:31:&#xA;   in call 'forall'&#xA;   in call 'forall'&#xA;   in array comprehension expression&#xA;   with i = 1&#xA;   /home/hakank/g12/me/assert_test.mzn:32:&#xA;   in call 'assert'&#xA;   in call 'assert'&#xA;   Assertion failed: x is not increasing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Update: Another way is to put the &lt;code&gt;forall&lt;/code&gt; inside &lt;code&gt;assert&lt;/code&gt;, i.e. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% ...&#xA;constraint&#xA;    assert(&#xA;       forall(i in 1..n-1) (&#xA;           assert(x[i] &amp;lt;= x[i+1], &quot;x is not increasing&quot;)&#xA;       )&#xA;       , &quot;x is not increasing&quot;&#xA;     );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="260" LastEditorUserId="260" LastEditDate="2019-10-26T05:49:50.137" LastActivityDate="2019-10-26T05:49:50.137" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2920" PostTypeId="2" ParentId="2904" CreationDate="2019-10-25T21:22:25.437" Score="9" Body="&lt;p&gt;As the borders between statistics and machine learning are diffuse, I take freedom to include statistics. Some links:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Non-negative least squares, &lt;a href=&quot;https://stats.stackexchange.com/search?q=non-negative+least+squares+answers%3A1&quot;&gt;posts on cross validated&lt;/a&gt;.&#xA;But often restrictions can &lt;a href=&quot;https://stats.stackexchange.com/questions/186050/regression-with-restrictions-like-b1-b2-q&quot;&gt;be implemented just by reformulation&lt;/a&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/3642240062&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Order-restricted statistical inference&lt;/a&gt; should be better known and more used.  &lt;a href=&quot;http://www.restriktor.ugent.be/&quot; rel=&quot;nofollow noreferrer&quot;&gt;There is a new R package being developed here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Shape-restricted splines, a &lt;a href=&quot;https://stats.stackexchange.com/questions/206073/looking-for-function-to-fit-sigmoid-like-curve/316446#316446&quot;&gt;very simple example&lt;/a&gt;.   &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A little known problem: A &lt;a href=&quot;http://147.156.1.4/bernardo/Lee.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper on optimization under &lt;em&gt;unknown&lt;/em&gt; constraints&lt;/a&gt;.   &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A paper on &lt;a href=&quot;https://www.ispor.org/docs/default-source/publications/newsletter/constrained-optimization-methods-health-services-research-guideline.pdf?sfvrsn=90105fc5_0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Constrained Optimization Methods in Health Services&#xA;Research&lt;/a&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.31.494&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;A paper&lt;/a&gt; showing how to parametrize covariance matrices (that is, positive definite (posdef) matrices. That is, a trick to avoid to use nonlinear restrictions. After all, generally the best method for restricted optimization is to transform to a nonrestricted problem ... &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="166" LastEditorUserId="123" LastEditDate="2019-11-07T07:19:13.843" LastActivityDate="2019-11-07T07:19:13.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2921" PostTypeId="2" ParentId="2881" CreationDate="2019-10-25T21:45:10.293" Score="3" Body="&lt;p&gt;I'm not a CP Optimizer user, so this may be clunkier than necessary (by an order of magnitude). I'm going to assume that your setup times satisfy the triangle inequality (meaning it's faster to go straight from A to B than from A to C to B).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For each place where you would use an interval variable for down time, you could instead create multiple interval variables, one for each possible state the machine might be in either when it went down or when it came up (i.e., the state of the last job before it went down or the first job after it came up -- I'm being intentionally vague about which). You would make those variables optional (&lt;code&gt;IloIntervalVar.setOptional()&lt;/code&gt;) and tell the model that exactly one must be present (&lt;code&gt;IloCP.alternative()&lt;/code&gt;). Then give them &lt;code&gt;noOverlaps&lt;/code&gt; with all possible preceding and following intervals using the appropriate setup times. If the schedule contains a sequence &quot;job A&quot; -- down -- &quot;job B&quot;, then one of three things will happen. If the solver chooses an &quot;A flavor&quot; of the downtime variable, you'll pay the A-B setup when downtime ends. If it chooses a &quot;B flavor&quot; downtime variable, you'll pay the A-B setup when downtime begins. If it chooses the &quot;C flavor&quot;, you'll pay both an A-C and a C-B setup cost, which via the triangle inequality is no better than A-B. So, in this case, the solver might have some unintentional inserted slack in the schedule ... but that should only happen if it does not affect the optimal solution.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="123" LastEditDate="2019-10-26T07:45:40.693" LastActivityDate="2019-10-26T07:45:40.693" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2922" PostTypeId="1" CreationDate="2019-10-25T21:50:01.667" Score="11" ViewCount="205" Body="&lt;p&gt;I'm trying to address the question of how many times should I order a product from my supplier, assuming highly stochastic demand. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my mind there would be something like the Newsvendor model, but would not only provide me with an optimal buy quantity, but also the optimal number of times I should reorder (i.e. should I buy again tomorrow and the next day? Should I buy once a day for the next week? etc...) &lt;/p&gt;&#xA;" OwnerUserId="1315" LastEditorUserId="1315" LastEditDate="2020-05-02T22:30:30.317" LastActivityDate="2020-05-03T02:20:54.373" Title="Is a &quot;multistep&quot; or &quot;multiphase&quot; Newsvendor model possible?" Tags="|optimization|supply-chain|newsvendor|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2924" PostTypeId="2" ParentId="2874" CreationDate="2019-10-25T22:07:27.063" Score="11" Body="&lt;p&gt;Disclaimer: the following is doomed not to be comprehensive. (I'm still cautiously optimistic about it being at least somewhat correct.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some OR research is devoted to theory: proving that some problem is NP-weird, finding worst case bounds on either computation time or the gap between achieved solution and optimal solution for some algorithm, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some OR research is devoted to developing (or refining) algorithms applicable to OR problems. So people may work on things like figuring out facet defining cuts for specific combinatorial problems, or accelerating convergence of data fitting algorithms, or concocting new metaheuristics. This intersects with my &quot;theory&quot; category; figuring out where the boundary is is left to the reader as an exercise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some OR research is devoted to application. Here what makes it research (as opposed to just solving something) may be applying an OR framework to a problem not previously recognized as fitting it, or finding a non-obvious model for a problem, or finding heuristics specific to a particular problem or problem class. In some cases just identifying the problem and formulating a model may be novel enough to be considered research.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as current topics, (a) they vary depending on which category you're looking at and (b) to borrow from Shakespeare, there are more topics in heaven and earth than are dreamt of in my philosophy. A good way to identify current topics (give or take having any idea what the terminology means) is to look at the program of a relevant conference. INFORMS maintains a &lt;a href=&quot;https://www.informs.org/Meetings-Conferences/INFORMS-Conference-Calendar&quot; rel=&quot;noreferrer&quot;&gt;calendar&lt;/a&gt; of both past and future meetings. You can look for recent past conferences, drill down to the program for one, and have a look at what was presented. Fair warning: if you grab a national conference without having a pretty good idea what sorts of papers you are looking for (e.g., healthcare applications), you will drown quickly. So you might want to look at a regional or specialty conference first.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-10-25T22:07:27.063" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2925" PostTypeId="5" CreationDate="2019-10-26T07:52:06.697" Score="0" Body="&lt;p&gt;MiniZinc is a high level solver-independent constraint modeling language.  The solvers supporting  the FlatZinc files (which is generated during the process of running MiniZinc) format use different solving algorithms: Constraint Programming (Finite Domain), Lazy Clause Generation (CP/SAT), SAT, MIP,  Local Search, SMT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.minizinc.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.minizinc.org&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="260" LastEditorUserId="1118" LastEditDate="2019-10-28T16:08:04.203" LastActivityDate="2019-10-28T16:08:04.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2926" PostTypeId="4" CreationDate="2019-10-26T07:52:06.697" Score="0" Body="MiniZinc is a high level solver-independent constraint modeling language." OwnerUserId="260" LastEditorUserId="260" LastEditDate="2019-10-26T07:54:07.630" LastActivityDate="2019-10-26T07:54:07.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2927" PostTypeId="1" AcceptedAnswerId="2928" CreationDate="2019-10-26T09:47:57.843" Score="6" ViewCount="222" Body="&lt;p&gt;I have a utility function &lt;span class=&quot;math-container&quot;&gt;$u(x) = a - b e^{-x/20\,000}$&lt;/span&gt; and it is given that &lt;span class=&quot;math-container&quot;&gt;$u(0)=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u(100\,000)=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to show that &lt;span class=&quot;math-container&quot;&gt;$a = 1.0067837$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b = 1.0067837$&lt;/span&gt;. Here is what I tried:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}u(0) &amp;amp;= a - b e^{-0/20\,000} = 0 &amp;amp;\implies a-be^1=0 &amp;amp;\implies a=be\\u(100\,000) &amp;amp;= a - b e^{100\,000/20\,000} = 1 &amp;amp;\implies a-be^5=1 &amp;amp;\implies a=1+be^5\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When &lt;span class=&quot;math-container&quot;&gt;$a=be=1+be^5$&lt;/span&gt;, taking &lt;span class=&quot;math-container&quot;&gt;$e = 2.72$&lt;/span&gt;, it doesn't get &lt;span class=&quot;math-container&quot;&gt;$b = 1.0067837$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where did I do wrong, and how can I correct it? Thank you.&lt;/p&gt;&#xA;" OwnerUserId="2440" LastEditorUserId="123" LastEditDate="2019-10-27T07:38:21.377" LastActivityDate="2020-11-18T17:30:40.027" Title="Solving an exponential utility function" Tags="|multicriteria-decision-analysis|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2928" PostTypeId="2" ParentId="2927" CreationDate="2019-10-26T10:10:32.603" Score="5" Body="&lt;p&gt;The utility function &lt;span class=&quot;math-container&quot;&gt;$u(x)=a-be^{-x/20\,000}$&lt;/span&gt; with the conditions &lt;span class=&quot;math-container&quot;&gt;$u(0)=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u(100\,000)=1$&lt;/span&gt; gives &lt;span class=&quot;math-container&quot;&gt;$$u(0)=a-be^{-0/20\,000}\implies 0=a-be^0=a-b\implies a=b\tag1$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$u(100\,000)=a-be^{-100\,000/20\,000}\implies 1=a-ae^{-5}=a(1-e^{-5})\tag2$$&lt;/span&gt; so that &lt;span class=&quot;math-container&quot;&gt;$a=b=(1-e^{-5})^{-1}=1.0067837$&lt;/span&gt; as desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where you went wrong:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u(0) = a - b e^{-0/20\,000} = 0 \implies a-be^1=0$&lt;/span&gt; should be &lt;span class=&quot;math-container&quot;&gt;$a-be^0=0$&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u(100\,000) = a - b e^{100\,000/20\,000} = 1$&lt;/span&gt; should be &lt;span class=&quot;math-container&quot;&gt;$a-be^{-100\,000/20\,000}$&lt;/span&gt;; you just forgot the minus sign.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-10-26T10:10:32.603" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2929" PostTypeId="2" ParentId="2922" CreationDate="2019-10-26T15:16:52.080" Score="9" Body="&lt;p&gt;There are several models available to make the sort of decisions you are asking about. Most tend to make ordering decisions based on &lt;em&gt;inventory level&lt;/em&gt; rather than on &lt;em&gt;time&lt;/em&gt;: That is, they say things like &quot;when the IL = 12, order 25&quot; rather than &quot;order 25 every 3 days&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The newsvendor problem is usually interpreted as a periodic-review model, so if you're looking for a multi-periodic model that is analogous, consider either the &lt;strong&gt;base-stock model&lt;/strong&gt; or the &lt;strong&gt;&lt;span class=&quot;math-container&quot;&gt;$(s,S)$&lt;/span&gt; model&lt;/strong&gt;. Both assume that the period length is already fixed (e.g., 1 day). The base-stock model assumes we order every period, while the &lt;span class=&quot;math-container&quot;&gt;$(s,S)$&lt;/span&gt; model assumes there is a fixed ordering costs, which means the orders are spaced out more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main model that uses order interval as a decision variable (i.e., focusing on time, not IL) is the &lt;strong&gt;&lt;span class=&quot;math-container&quot;&gt;$(r,T)$&lt;/span&gt; model.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In continuous review, the relevant model is the &lt;strong&gt;&lt;span class=&quot;math-container&quot;&gt;$(r,Q)$&lt;/span&gt; model&lt;/strong&gt;, but I wouldn't exactly think of that as multi-period newsvendor, since it's continuous review.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-10-26T15:16:52.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2930" PostTypeId="2" ParentId="167" CreationDate="2019-10-27T20:46:26.977" Score="1" Body="&lt;p&gt;As @Richard said, one of the possible ways to find multiple solutions is using the specific cut. There is a nice topic has been described by Erwin Kalvelagen to find &lt;a href=&quot;http://yetanothermathprogrammingconsultant.blogspot.com/2016/01/finding-all-optimal-lp-solutions.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;all optimal LP solutions&lt;/a&gt; using specific cuts which implementation into GAMS software. &lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-10-27T20:46:26.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2931" PostTypeId="1" CreationDate="2019-10-28T06:23:58.697" Score="10" ViewCount="991" Body="&lt;p&gt;I'm working on the scheduling model which takes a long time to solve to optimality (even for a small instance), therefore I would like to use a warm start (MIP start) to solve the problem. I'm using the following two different methods:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Determine a feasible solution and feed that into the model.&lt;/li&gt;&#xA;&lt;li&gt;Using B&amp;amp;B GAP control to achieve a sub-optimal solution and then feeding that into the model.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The original model, a small instance, is solved in 2 minutes. Its objective function value is 5966. In the first case, the model is solved quickly (less than 1 second) and the objective function value is 6737. &#xA;In the second case, I set the GAP to be 0.20. The model is solved in 12 seconds and the objective function value is 5966.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the above comments, I was wondering if:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is my approach suitable to use a warm start into the model?&lt;/li&gt;&#xA;&lt;li&gt;Is there any way to improve the objective function value of 6737 (first case)?&lt;/li&gt;&#xA;&lt;li&gt;Are there any other ways to execute a warm start to solve the problem as quickly as possible?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="199" LastEditorUserId="500" LastEditDate="2023-12-13T18:00:25.047" LastActivityDate="2023-12-13T18:00:25.047" Title="How to use warm start to solve MIPs efficiently?" Tags="|optimization|mixed-integer-programming|warm-start|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2932" PostTypeId="1" AcceptedAnswerId="2988" CreationDate="2019-10-28T10:57:53.127" Score="11" ViewCount="255" Body="&lt;p&gt;I really enjoyed reading Hans Kellerer, David Pisinger, Ulrich Pferschy 2004 book Knapsack Problems. Can anybody recommend books in a similar style, about some other classes of problems / optimisation?&lt;/p&gt;&#xA;" OwnerUserId="2611" LastEditorUserId="38" LastEditDate="2020-01-29T15:18:55.007" LastActivityDate="2020-01-29T15:18:55.007" Title="Looking for books in the same style as Hans Kellerer 2004, Knapsack Problems" Tags="|optimization|reference-request|knapsack|books|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2933" PostTypeId="2" ParentId="2931" CreationDate="2019-10-28T12:51:07.323" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Is my approach suitable to use a warm start into the model?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I understand you correctly, you first compute some solution, either by using the first feasible solution you get (variant 1) or by solving the model till a certain optimality gap is achieved (e.g. 20%), and then use the found solution as a warm start for your original model.&lt;br&gt;&#xA;This is a suitable approach: It will help the solver to fathom certain nodes in the branch-and-bound-tree which have a higher (relaxed) objective value than the warm start solution you provide (or the current best solution if a better was found).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;2&quot;&gt;&#xA;  &lt;li&gt;Is there any way to improve the objective function value of 6737 (first case)?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It depends on how you get the feasible solution... If you use a heuristic, you would want to tweak it or give it more computation time. If you also use the MIP and then just take the first found solution you could also try to give the solver more time to find a better solution.&lt;br&gt;&#xA;Another idea would be to provide just a partial solution and then let the solver try to repair the solution. Sometimes the solver is able to not only repair the partial solution but also find one with better objective value.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;3&quot;&gt;&#xA;  &lt;li&gt;Are there any other ways to execute a warm start to solve the problem as quickly as possible&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It seems that for your problem it takes more time to prove optimality rather than finding the best solution. You could try to give more emphasis on proving optimality (which you usually can adjust via some of the solver's parameters).&lt;/p&gt;&#xA;" OwnerUserId="137" LastActivityDate="2019-10-28T12:51:07.323" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2934" PostTypeId="1" CreationDate="2019-10-28T15:33:28.280" Score="16" ViewCount="3026" Body="&lt;p&gt;Apart from: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;modeling, &quot;coding&quot; the model and using an open source/commercial solver&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Implementing an approximation method (metaheuristics, greedy, etc.) &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Implementing exact methods (dynamic programming, specific algorithms like network flows, etc) &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What are the technical skills that one needs in OR, especially in industry? What about hybridization and decomposition? Any other &quot;advanced&quot; skills? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: feel free to suggest references to learn about the skills you mention.&lt;/p&gt;&#xA;" OwnerUserId="1188" LastEditorUserId="123" LastEditDate="2019-10-30T07:45:50.230" LastActivityDate="2020-05-20T15:38:38.200" Title="What are the most-used technical skills in OR?" Tags="|reference-request|applications|or-careers|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2935" PostTypeId="2" ParentId="2931" CreationDate="2019-10-28T18:43:50.133" Score="9" Body="&lt;p&gt;Just for concreteness, I'll phrase this in terms of a minimization problem, but the same arguments apply to maximization as well. Warm-starting a model is essentially a gamble. You are gambling that the time spent computing the initial solution will be compensated by a reduction in solution time (most likely resulting from earlier pruning of nodes due to a better upper bound on the objective value). There are several things to consider.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Sometimes a better starting solution actually results in worse solver performance. This seems to be due to the better start altering some of the cuts the solver generates and/or leading the solver to explore less productive portions of search space and/or bad karma (on your part, not the solver's). AFAIK there is no way to anticipate this occurring.&lt;/li&gt;&#xA;&lt;li&gt;If the solver, without a warm start (or with an inferior warm start), finds as good an incumbent as your starting solution (or better) in an amount of time shorter than what you spent finding the starting solution, it's probably not worth warm starting. This can happen if the solver's heuristics are either better than yours or just luckier.&lt;/li&gt;&#xA;&lt;li&gt;Assuming that you are seeking proven optimality, a slow solve can be the result of either or both of two factors: slow improvement of the upper bound to the optimal value; and slow improvement of the lower bound to the optimal value. A good warm start may help the first but not the second. If your lower bound is far from optimal and improving slowly, extra effort generating a better warm start will not help. You need to investigate bound tightening procedures, options in the solver, or tighter formulations ... or just accept that the solution will take forever. (I'm in that boat myself right now.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-10-28T18:43:50.133" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2936" PostTypeId="2" ParentId="2934" CreationDate="2019-10-28T18:52:29.537" Score="18" Body="&lt;p&gt;Your examples of &quot;technical skills&quot; are centered on optimization. An understanding of at least some aspects of probability models (especially Markov chains and queues) may be important, depending on the work you do. So might a better-than-minimal understanding of statistical modeling and analysis. Again depending on your work, you might need to be able to write, validate/verify and analyze the output of simulation models.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mark L. Stone mentioned soft skills in a comment, and I endorse that. There's also what some people refer to (a bit loosely) as &quot;systems thinking&quot;, which to my mind means being able to look beyond the immediate problem to recognize how the problem and any potential solution fit in the larger scheme of things. For instance, you might be tasked with reducing turn-around times for commercial aircraft. Getting a major reduction in turn-arounds might increase utilization ... but then how does that affect maintenance schedules?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also the ability to listen to someone venting and figure out what the actual problem is and what its principal components would be. In an optimization context, that would be recognizing what decisions need to be made (variables), what the criteria are for a &quot;good&quot; solution (objective or objectives) and what the restrictions are on those decisions (constraints). I don't know if you consider that a technical skill or not, but it's definitely somewhere in the skill -- art form spectrum.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-05-20T15:38:38.200" LastActivityDate="2020-05-20T15:38:38.200" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2937" PostTypeId="1" CreationDate="2019-10-29T02:14:06.830" Score="10" ViewCount="168" Body="&lt;p&gt;As the question says, I am wondering what happens &quot;behind the scene&quot; when the Dual Infeasibility column of the Gurobi runtime log oscillates wildly, before Gurobi eventually quits with infeasibility. I am solving a mixed-integer model. More specifically, all integer variables are binary. An example plot of Dual Inf is below (value of Dual Inf. versus clock time). I am hoping this could point to some problems in my model formulation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CKUbx.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CKUbx.png&quot; alt=&quot;Value of dual infeasibility versus solver clock time&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2410" LastEditorUserId="123" LastEditDate="2019-10-29T08:03:43.063" LastActivityDate="2019-10-29T14:26:40.043" Title="Wild oscillation of dual infeasibility in Gurobi mixed-integer solver" Tags="|optimization|mixed-integer-programming|gurobi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2938" PostTypeId="2" ParentId="2934" CreationDate="2019-10-29T07:49:06.377" Score="13" Body="&lt;ul&gt;&#xA;&lt;li&gt;I think domain knowledge is essential if you want to be a good OR practitioner. If you don't know how a supply chain works, designing an optimization model for planning and coordinating a complex supply chain could be difficult and time-consuming. The same goes for healthcare, energy, finance, manufacturing, and other industries. Also, domain knowledge could help with problem identification and definition a lot.&lt;/li&gt;&#xA;&lt;li&gt;An often neglected issue about optimization in textbooks and discussions is data input (i.e., parameters used in the models). Even if you were proficient with programming and optimization techniques, you would be working on data gathering and preparation most of the time. Here, the ability to work with a database is essential. Also, cleaning, summarizing, and forecasting techniques are of great importance. For these tasks, a wide variety of statistical and data science tools such as regression, time series, data mining, etc. could be useful. Personally, I believe an excellent operations researcher should be very good at probability and statistics.  &lt;/li&gt;&#xA;&lt;li&gt;Another vital skill is the visualization of the system and the possible solutions. For this matter, simulation (especially 2D and 3D simulation) is beneficial.&lt;/li&gt;&#xA;&lt;li&gt;If you intend to engage in software development, having a good command of programming languages, data structures, and algorithms is necessary.&lt;/li&gt;&#xA;&lt;li&gt;Finally, technical writing and reporting, as well as presentation, are critical soft skills. If you could not convey your ideas and results well enough, even the best algorithms in the world would not have any customer. While OR is a technical and math-based field, your customers and even your boss are sometimes not very good with it. Therefore, it is important to talk about OR as simple as possible.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="119" LastActivityDate="2019-10-29T07:49:06.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2939" PostTypeId="2" ParentId="2934" CreationDate="2019-10-29T12:13:09.820" Score="6" Body="&lt;p&gt;As you said &quot;especially in industry&quot; and if you have a background in IE/MS/Math and to confirm @prubin and @Ehsan, you should know:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each industry has specific factories/organizations which have different departments. (E.g. in the factory: production, quality, planning and ..., in the organization R&amp;amp;D, sale and, ...). Depends on which industry and department you would work on, you need to know some specific knowledge about that. Some of them are described in the following.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you are going to work in the production/planning area, I strongly recommended, you should know simulation, optimization, operation management, inventory control, supply chain management, warehouse management and some special designing software such as CAD families.&lt;/li&gt;&#xA;&lt;li&gt;If you are going to work in the quality area, you need to know quality management, probability, statistical tools and simulation. &lt;/li&gt;&#xA;&lt;li&gt;if you are going to work in the R&amp;amp;D area, you need to know project management, programming knowledge, optimization and some special designing software such as CAD families.&lt;/li&gt;&#xA;&lt;li&gt;if you are interested to work in the sale/supply area, you would need to know statistical and data science tools (such as regression, time series and data mining), supply chain management, inventory optimization, market analysis and so on.&lt;/li&gt;&#xA;&lt;li&gt;As Ehsan said, If you intend to engage in software development, having a good command of programming languages, data structures, and algorithms is necessary.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In some cases, the above fields may overlap together.&#xA;Besides all the above mentioned, it should be noted that having skill in popular&#xA;software such as Excell, databases and reporting issues is essential.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, do not forget, people in the industry work in teams and you might not need to know everything.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-10-29T12:13:09.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2940" PostTypeId="2" ParentId="2937" CreationDate="2019-10-29T14:26:40.043" Score="1" Body="&lt;p&gt;According to &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/barrier_logging.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi's documentation&lt;/a&gt;: &quot;When the primal infeasibility, dual infeasibility, and complementarity satisfy barrier convergence tolerances (controlled using the BarConvTol parameter), the solution is declared optimal and optimization is complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unlike the simplex and MIP optimizers, the barrier optimizer produces a logline for each iterate, independent of the value of the DisplayInterval parameter. You may sometimes see a star after the iteration count in the barrier progress log:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  15   2.42800468e+03  8.54543324e+04  1.68e+02 1.02e-09  8.30e+04     0s&#xA;  16   4.05292006e+03  4.65997441e+04  1.82e+02 2.50e-01  4.25e+04     0s&#xA;  17*  4.88742259e+08  4.30781025e+10  5.17e+00 1.31e-01  2.52e-02     0s&#xA;  18*  1.21709951e+06  3.39471138e+13  8.55e-06 3.14e-06  3.14e-05     0s&#xA;  19* -1.38021972e+06  3.31580578e+16  3.42e-08 8.20e-09  3.22e-08     0s&#xA;  20*  1.25182178e+06  3.31575855e+19  6.54e-12 7.34e-09  3.22e-11     0s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This indicates that the model may be primal or dual infeasible. Note that these intermediate indications of infeasibility won't necessarily turn into an infeasibility proof, so the star may disappear in later iterations.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the oscillation that was shown in the plot is related to one of those points with the star in the log file.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-10-29T14:26:40.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2941" PostTypeId="1" CreationDate="2019-10-29T15:21:46.703" Score="5" ViewCount="110" Body="&lt;p&gt;I'm solving the magic square problem without using the &lt;code&gt;alldiff&lt;/code&gt; operator. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To insert different values ​​in the matrix, I initialized a variable:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;var y {1..n, 1..n, 1..n * n} binary;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;y[i,j,k]&lt;/code&gt; will equal 1 if and only if entry &lt;code&gt;i, j&lt;/code&gt; in the matrix equals &lt;code&gt;k&lt;/code&gt;. Then each cell contains exactly one number is given by:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s.t. OneEach {i in 1..n, j in 1..n}: sum {k in 1..n * n} y[i,j,k] = 1;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and the constraint that all entries are different is given by:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s.t. AllDifferent {k in 1..n * n}: sum {i in 1..n, j in 1..n} y[i,j,k] &amp;lt;= 1;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem now is to formalize the constraint that the sum on the rows, columns and on the diagonals is equal to the magic constant. I tried with&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s.t. RowsSum {k in 1..n * n}: sum {i in 1..n, j in 1..n} k * y [i, j, k] = constant;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s.t. ColsSum {k in 1..n * n}: sum {i in 1..n, j in 1..n} k * y [j, i, k] = constant;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An additional constraint is used to calculate the value of the constant:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s.t. q1: ((k*k)/2)*(k*k+1) = constant*k;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I load the model, he tells me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;presolve: constraint ColsSum [1] cannot hold: body&amp;gt; = 15 cannot be &amp;lt;= 9; difference = 6&lt;/code&gt;&#xA;&lt;code&gt;presolve: constraint RowsSum [1] cannot hold: body&amp;gt; = 15 cannot be &amp;lt;= 9; difference = 6&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without the constraints on the sum of rows and columns, the result is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Magic_Constant = 15&#xA;&#xA;  1   2   3&#xA;  4   5   6&#xA;  7   8   9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The value of the magic constant is right, the square works because there are all the numbers from &lt;code&gt;1&lt;/code&gt; to &lt;code&gt;n^2&lt;/code&gt;, and they also appear only once. But now I must add that the sums on rows and columns must be equal to the magic constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tips?&lt;/p&gt;&#xA;" OwnerUserId="2577" LastEditorUserId="2577" LastEditDate="2019-10-29T16:06:41.500" LastActivityDate="2019-10-29T18:28:06.253" Title="Magic square in AMPL: presolve: constraint cannot hold" Tags="|ampl|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ClosedDate="2019-10-29T19:44:27.260" ContentLicense="CC BY-SA 4.0" />
  <row Id="2942" PostTypeId="1" CreationDate="2019-10-29T15:43:51.107" Score="6" ViewCount="182" Body="&lt;p&gt;I have a code in MATLAB which uses YALMIP to structure my optimization model and solve it via a solver. I would like to obtain a .mps file out of my model, apparently, YALMIP does not produce this if I am not mistaken. I would like to obtain a .mps file, how can I do this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I know this is not an OR question, but I am sure a lot of OR people may face this challenge someday.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2019-10-29T15:51:59.220" LastActivityDate="2019-10-29T16:13:50.563" Title="MPS file generation" Tags="|optimization|matlab|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2943" PostTypeId="2" ParentId="2896" CreationDate="2019-10-29T15:50:34.593" Score="3" Body="&lt;p&gt;Please check &lt;a href=&quot;https://or.stackexchange.com/a/2898/39&quot;&gt;this link&lt;/a&gt; to my answer to your previous question. I included a link in which without using &lt;code&gt;alldiff&lt;/code&gt;, Sudoku problem (where the magic constant is equal to 9) has been solved. You may find some tips and hints there. I hope it helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Try the following constraints for the rows and columns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subject to RowsSum {i in I}: sum {j in J, k in K} k*y[i, j, k] = constant;&#xA;subject to ColsSum {j in J}: sum {i in I, k in K} k*y[i, j, k] = constant;&#xA;subject to Diag: sum {i in I, k in K} k*y[i, i, k] = constant;&#xA;subject to ADiag: sum {i in I, k in K} k*y[i, n-i+1, k] = constant;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I translated the code by @hakank into AMPL.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-10-29T18:28:06.253" LastActivityDate="2019-10-29T18:28:06.253" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2944" PostTypeId="2" ParentId="2942" CreationDate="2019-10-29T16:13:50.563" Score="2" Body="&lt;p&gt;I am not an expert in YALMIP but you may check the &lt;code&gt;saveampl(F,h,filename)&lt;/code&gt; command written in YALMIP &lt;a href=&quot;https://yalmip.github.io/command/saveampl/&quot; rel=&quot;nofollow noreferrer&quot;&gt;website&lt;/a&gt;. An example of the implementation is given as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = sdpvar(3,1);&#xA;A = randn(5,3);&#xA;b = randn(5,1);&#xA;c = randn(3,1);&#xA;F = [A*x &amp;lt;= b, integer(x(2:3))];&#xA;saveampl(F,c'*x,'myamplmodel.mod');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where I think you can save the model with &lt;code&gt;.mps&lt;/code&gt; extension instead of &lt;code&gt;.mod&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-10-29T16:13:50.563" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2945" PostTypeId="2" ParentId="1480" CreationDate="2019-10-29T16:27:06.197" Score="4" Body="&lt;p&gt;For Reinforcement learning and Deep Reinforcement learning, a wonderful online free course on RL by David Silver (the first author of the AlphaZero, AlphaGo algorithms) exists:&#xA;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLzuuYNsE1EZAXYR4FJ75jcJseBmo4KQ9-&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouTube links&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more advanced course by Sergey Levine exists for free at:&#xA;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLkFD6_40KJIxJMR-j5A1mkxK26gh_qg37&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouTube link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For both course the link to the material of the course is available too. &lt;/p&gt;&#xA;" OwnerUserId="41" LastActivityDate="2019-10-29T16:27:06.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2946" PostTypeId="2" ParentId="2896" CreationDate="2019-10-29T17:48:39.873" Score="4" Body="&lt;p&gt;I'm not sure if this helps you, but here is a &quot;pure&quot; IP model for the magic square problem, i.e. no &lt;code&gt;all_different&lt;/code&gt;. However it's in MiniZinc (not AMPL), but it should be possible to port it to AMPL. The model also available here: &lt;a href=&quot;http://hakank.org/minizinc/magic.mzn&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://hakank.org/minizinc/magic.mzn&lt;/a&gt;.  (Note: it's a port of the GLPK model magic.mod, available in the GLPK distribution.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% square order&#xA;int: n = 3; &#xA;&#xA;% integers to be placed&#xA;set of 1..n*n: N = 1..n*n;&#xA;&#xA;% x[i,j,k] = 1 means that cell (i,j) contains integer k&#xA;array[1..n, 1..n, N] of var 0..1: x;&#xA;&#xA;array[1..n, 1..n] of var 1..n*n: square;&#xA;&#xA;var int: s; % the magic sum&#xA;&#xA;solve :: int_search(&#xA;    [x[i,j,k] | i,j in 1..n, k in N] ++ &#xA;    [square[i,j] | i,j in 1..n] ++&#xA;    [s],&#xA;    first_fail,&#xA;    indomain_min, &#xA;    complete % &quot;credit(640, bbs(5))&quot; % &quot;complete&quot;&#xA;  ) &#xA;satisfy;&#xA;&#xA;constraint &#xA;  s &amp;gt;= 0 &#xA;  /\&#xA;  s &amp;lt;= n*n*n&#xA;  /\&#xA;  % each cell must be assigned exactly one integer&#xA;  forall(i in 1..n, j in 1..n) (&#xA;     sum(k in N) (x[i,j,k]) = 1&#xA;  )&#xA;  /\&#xA;  % each integer must be assigned exactly to one cell&#xA;  forall(k in N) (&#xA;      sum(i in 1..n, j in 1..n) (x[i,j,k]) = 1&#xA;  )&#xA;&#xA;  /\&#xA;  % the sum in each row must be the magic sum &#xA;  forall(i in 1..n) (&#xA;     sum(j in 1..n, k in N) (k * x[i,j,k]) = s&#xA;  )&#xA;&#xA;  /\&#xA;  % the sum in each column must be the magic sum&#xA;  forall(j in 1..n) (&#xA;    sum(i in 1..n, k in N) (k * x[i,j,k]) = s&#xA;  )&#xA;&#xA;  /\&#xA;  % the sum in the diagonal must be the magic sum&#xA;  sum(i in 1..n, k in N) (k * x[i,i,k]) = s&#xA;&#xA; /\&#xA; % the sum in the co-diagonal must be the magic sum&#xA; sum(i in 1..n, k in N) (k * x[i,n-i+1,k]) = s&#xA;&#xA; /\&#xA; % for output&#xA; forall(i,j in 1..n) ( square[i,j] = sum(k in N) (k * x[i,j,k]))&#xA; ;&#xA;&#xA;&#xA; output [ &#xA;    &quot;\ns: &quot;, show(s)&#xA; ] ++&#xA; [&#xA;  if  j = 1 then &quot;\n&quot; else &quot; &quot; endif ++&#xA;    show(square[i,j]) &#xA;    | i,j in 1..n&#xA; ] ++ [&quot;\n&quot;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="260" LastActivityDate="2019-10-29T17:48:39.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2947" PostTypeId="1" CreationDate="2019-10-29T23:40:11.407" Score="18" ViewCount="658" Body="&lt;p&gt;I came across the preface of &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0486419991&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimization Theory for Large Systems&lt;/a&gt; (you can read it in Amazon). The author claims in the table (page v) that some of the methods such as Dantzig Wolfe decomposition, some column generations, etc. are not widely used today. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do you think of this claim ? Is there a difference between the academic world and the industrial world in terms of use of those methods ? As someone who looks forward to work in the industry (ideally in a company that is developing solvers), what are the methods that I need to know ?&lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="123" LastEditDate="2019-12-01T14:39:44.853" LastActivityDate="2023-04-02T19:55:46.707" Title="What are the modern optimization methods for large systems?" Tags="|benders-decomposition|lagrangian-decomposition|dantzig-wolfe-decomposition|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2949" PostTypeId="2" ParentId="2914" CreationDate="2019-10-30T10:55:25.693" Score="5" Body="&lt;p&gt;I am answering my own question because it may help other people. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could not find a function in docplex able to get all feasible solutions for a &lt;em&gt;ILP&lt;/em&gt; problem. For my best knowledge, docplex only has this kind of function for MIP problems.&#xA;If you are dealing with &lt;em&gt;MIP&lt;/em&gt;, you can check additional information here: &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SS9UKU_12.8.0/com.ibm.cplex.zos.help/CPLEX/Parameters/topics/listSolnPool.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/support/knowledgecenter/SS9UKU_12.8.0/com.ibm.cplex.zos.help/CPLEX/Parameters/topics/listSolnPool.html&lt;/a&gt;&#xA;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.cplex.help/refpythoncplex/html/cplex._internal._subinterfaces.SolnPoolInterface-class.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.cplex.help/refpythoncplex/html/cplex._internal._subinterfaces.SolnPoolInterface-class.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Feasible solutions for ILP problems:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With OR-tools I could find a way to get all feasible solutions for constrained problems by using SearchForAllSolutions. As expected, this functions is available for CP-SAT and you cannot state any objective function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are interested in it, I suggest you to take a look at this example: &#xA;&lt;a href=&quot;https://developers.google.com/optimization/cp/cp_solver#first_sol_program&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization/cp/cp_solver#first_sol_program&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: In my case, I was trying to solve a 01LP, so it generated many solutions, but with several duplicates. In order to avoid that, you can state a limit (time or number of solutions found). Please, check CP-SAT documentation for additional information. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it will help someone! &lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="123" LastEditDate="2019-10-30T19:12:43.917" LastActivityDate="2019-10-30T19:12:43.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2950" PostTypeId="1" AcceptedAnswerId="2951" CreationDate="2019-10-30T14:31:00.760" Score="7" ViewCount="496" Body="&lt;p&gt;Suppose I have the following constraint: &lt;span class=&quot;math-container&quot;&gt;\begin{align}x_{t} &amp;amp;= x_{t-1} + y_{t-1} - z_{t-1}\\x_{t} &amp;amp;\ge 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From my limited experience in coding my own problem, I have found that my model becomes infeasible if I impose the non-negativity constraint on &lt;span class=&quot;math-container&quot;&gt;$ x_{t} $&lt;/span&gt; because what happens is the &lt;span class=&quot;math-container&quot;&gt;$z_{t-1}$&lt;/span&gt; term begins to overpower the other two positive terms and the non-negativity constraint just does not hold, ultimately resulting in infeasibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I reformulate the problem as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x_{t} = \max\{x_{t-1} + y_{t-1} - z_{t-1}, 0 \} $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and then perform a linearization on this formulation, I can run the model and get the desired result of the non-negativity constraint. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it seems strange to my naive eye that reformulating the problem as a max constraint and then doing a linearization ~ which seems to be a much more complicated route ~ will work for me, but the non-negativity constraint does not. At least to me, formulating the constraint as a linear relation with a non-negativity constraint and then as a 'max' are essentially the same thing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clearly, they are not, but why not? Part of me feels like this could be a 'solver' problem, but i'm hoping there is a more theoretical way of understanding. &lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="123" LastEditDate="2019-10-30T19:13:56.897" LastActivityDate="2019-10-31T08:13:12.233" Title="Why does a Max constraint work, but this non-negativity constraint does not?" Tags="|nonlinear-programming|linearization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2951" PostTypeId="2" ParentId="2950" CreationDate="2019-10-30T14:59:28.110" Score="13" Body="&lt;p&gt;A rigorous way to look at this problem is to consider the polyhedra corresponding to your constraints (I linearized the 'max' for the second one):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$P_1 = \left\{(x_t,x_{t-1},y_{t-1},z_{t-1}): x_t = x_{t-1}+y_{t-1}-z_{t-1}, x_t \geq 0 \right\}$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$P_2 = \left\{(x_t,x_{t-1},y_{t-1},z_{t-1}): x_t \geq x_{t-1}+y_{t-1}-z_{t-1}, x_t \geq 0 \right\}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your answer you state that the two sets of constraints are &quot;essentially the same thing&quot;, which would formally mean that &lt;span class=&quot;math-container&quot;&gt;$P_1=P_2$&lt;/span&gt;. However, we can observe that while &lt;span class=&quot;math-container&quot;&gt;$P_1\subseteq P_2$&lt;/span&gt;, it is not true that &lt;span class=&quot;math-container&quot;&gt;$P_2\subseteq P_1$&lt;/span&gt; as e.g. the point &lt;span class=&quot;math-container&quot;&gt;$(0,0,0,1)$&lt;/span&gt; is an element of &lt;span class=&quot;math-container&quot;&gt;$P_2$&lt;/span&gt; but not of &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt;. So actually, &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt; is a proper subset of &lt;span class=&quot;math-container&quot;&gt;$P_2$&lt;/span&gt;, which is why it is possible that the first set of constraints gives you an infeasibility, while the second does not. &lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2019-10-30T14:59:28.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2952" PostTypeId="1" CreationDate="2019-10-30T19:00:37.237" Score="5" ViewCount="87" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$X_1,\ldots,X_n$&lt;/span&gt; are drawn i.i.d from a uniform distribution on &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; be the random vector &lt;span class=&quot;math-container&quot;&gt;$(X_1,\ldots,X_n)$&lt;/span&gt;. Then consider the random variable &lt;span class=&quot;math-container&quot;&gt;$Y_v = v^\top x $&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$v \in \{0,1\}^n$&lt;/span&gt; — note there are &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; such random variables &lt;span class=&quot;math-container&quot;&gt;$Y_v$&lt;/span&gt;. Given a range (say &lt;span class=&quot;math-container&quot;&gt;$\left[\frac{1}{2}n, \frac{2}{3}n\right]$&lt;/span&gt; for example), what is the expected number of random variables &lt;span class=&quot;math-container&quot;&gt;$Y_v$&lt;/span&gt; that take a value in this range; i.e. what is &lt;span class=&quot;math-container&quot;&gt;$$\sum_{v \in \{0,1\}^n}{\Large{}}_{Y_v \in \left[\frac{1}{2}n, \frac{2}{3}n\right]}?$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="606" LastEditorUserId="123" LastEditDate="2019-10-30T19:19:27.513" LastActivityDate="2019-10-30T19:19:27.513" Title="What's the expected number of subsets of iid random variables with sum in given range?" Tags="|probability-distributions|probability-theory|" AnswerCount="0" CommentCount="3" ClosedDate="2019-10-31T07:25:21.613" ContentLicense="CC BY-SA 4.0" />
  <row Id="2953" PostTypeId="1" AcceptedAnswerId="2959" CreationDate="2019-10-30T22:06:37.893" Score="39" ViewCount="6264" Body="&lt;p&gt;You probably have done some OR projects within the industry or - if you are in academia - for the industry. I'm wondering if you've seen some patterns of why such projects fail (or at least do not meet the clients requirements). Surely, there might be causes which are common to any other non-OR project but I'm specifically interested in ones that occur only within an OR context.&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="8" LastEditDate="2020-09-04T09:43:21.147" LastActivityDate="2020-09-04T09:43:21.147" Title="What are the reasons OR industry projects fail?" Tags="|applications|industry|" AnswerCount="9" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2954" PostTypeId="2" ParentId="2953" CreationDate="2019-10-30T22:31:52.237" Score="13" Body="&lt;p&gt;This may or may not be considered as occurring only within an OR context, but not getting senior-enough leadership guidance and buy-in on the client side (whether internal or external) as to the need for and value of the project, resources required (including support from people outside the OR analysts) as well as key assumptions and ground rules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a specific example (don't blame me, I was not involved nor had any opportunity to be). An OR study was done for a large industrial company, which among other things, involved cost/benefit analysis for a project involving the potential for large capital expenditures. The OR group did their usual wonderful analysis job, dutifully modeling the situation, applying relevant OR techniques, etc, just as they had done for smaller projects. The OR team only interfaced with mid-level people on the client side. The OR team asked those mid-level people what interest rate to use in their study, and were provided an interest rate to use commensurate with the company's borrowing costs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;WHOOPS!! Major Fail!! The recommended capital expenditure was so large that it would have likely lowered the credit rating of the client company, thereby increasing its cost of borrowing, which therefore should have been accounted for in the analysis. When the analysis results, which didn't account for possible credit rating change, was briefed to the CEO of the client company, he gave them the heave-ho.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2019-10-31T00:00:52.383" LastActivityDate="2019-10-31T00:00:52.383" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="2955" PostTypeId="2" ParentId="2953" CreationDate="2019-10-30T23:52:48.183" Score="26" Body="&lt;p&gt;I can immediately think of two reasons, both of which occurred on a consulting project in which I participated.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Every project needs one or more &quot;champions&quot;, people in the client organization with a vested interest in seeing the analysis completed &lt;em&gt;and the results implemented&lt;/em&gt;. If the champions leave the organization or are transferred to some other part of the organization, the project may easily get shelved.&lt;/li&gt;&#xA;&lt;li&gt;Garbage in, garbage out. If the organization is working with incorrect / corrupted data (and nobody realizes it, or nobody can fix it), the analysis is probably doomed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;One other possible reason (that I've heard mumbled about but not tripped over myself): management wants the projected implemented but the IT guys are opposed (possibly because it will create headaches, real or imagined, down the road when the OR people are gone and the IT people have to maintain it).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-10-30T23:52:48.183" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2956" PostTypeId="2" ParentId="2953" CreationDate="2019-10-31T00:11:24.923" Score="15" Body="&lt;p&gt;Last year I attended a presentation by Maria Antónia Carravilla where she gave several case studies of optimisation projects, examining the factors affecting their success or failure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Her main point was that project failures often have nothing to do with the technical aspects of the work and everything to do with non-technical factors, in particular stakeholder relationship management. She identified six key dimensions of client involvement in an optimisation project (a couple of which have already been mentioned in other answers):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Top management&lt;/li&gt;&#xA;&lt;li&gt;Middle management&lt;/li&gt;&#xA;&lt;li&gt;End users&lt;/li&gt;&#xA;&lt;li&gt;IT staff&lt;/li&gt;&#xA;&lt;li&gt;Having a team member within the client company&lt;/li&gt;&#xA;&lt;li&gt;Deliverables (I think this includes the actual optimisation model/software).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;She gave a couple of examples of projects where the optimisation was great &lt;em&gt;in silico&lt;/em&gt; but failed as a project because these other aspects weren't adequately handled:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Consultants called in to improve decision process for a complex manufacturing business. One of the team members said that they could do much better than the company's production director, in his hearing, and he became hostile to the project.&lt;/li&gt;&#xA;&lt;li&gt;Consultants working on decision support for reservations in a car rental company. They produced a system that was considerably more efficient than the existing solution, but there was a lot of work involved in providing the necessary data inputs, and the IT department was't willing to support it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;She also pointed out that projects that only need to be run once have very different requirements to those which will become a regular part of the client's business; the latter require much more attention to ease of use, user training, etc. etc.&lt;/p&gt;&#xA;" OwnerUserId="546" LastActivityDate="2019-10-31T00:11:24.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2957" PostTypeId="2" ParentId="2950" CreationDate="2019-10-31T08:13:12.233" Score="3" Body="&lt;p&gt;I think it is helpful to analyze the situation from a practical point of view. Please note that your constraint is of the general form of linear control constraints, arising in many practical problems such as inventory control, production planning, and finance. In such applications, you are relating the current variable level, &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt;, to the previous variable level, &lt;span class=&quot;math-container&quot;&gt;$x_{t-1}$&lt;/span&gt;, via some activities (e.g., subtraction of demand, &lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt;, and addition of new production, &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt;). In such case, it is possible that &lt;span class=&quot;math-container&quot;&gt;$z_t \gt x_{t-1} + y_t$&lt;/span&gt;, which would result in &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; becoming negative. This would be infeasible due to the constraint &lt;span class=&quot;math-container&quot;&gt;$x_t \ge 0$&lt;/span&gt;. From the practical POV, negative &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; is equivalent to shortage (i.e., not having enough product to satisfy the customer's demand), while positive &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; corresponds to surplus (i.e., having more inventory than required and being forced to keep it in your own warehouse). To allow for shortages, you could rewrite &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$x_{t}^{+} - x_{t}^{-}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x_{t}^{+} \ge 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{t}^{-} \ge 0$&lt;/span&gt;. This would make your original constraint rewritten as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{t}^{+} - x_{t}^{-} = x_{t-1}^{+} - x_{t-1}^{-}+y_{t-1}-z_{t-1}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you intend to allow for shortages, the above constraint is what you need (in the inventory control literature, this is referred to as inventory control with backlog). If not, your second constraint is the way to go (in the inventory control literature, this is referred to as inventory control with lost sales). Of course, this is to be determined based on your problem definition and application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt;. Depending on your whole model, it might be incorrect to linearize &lt;span class=&quot;math-container&quot;&gt;$ x_{t} = \max\{x_{t-1} + y_{t-1} - z_{t-1}, 0 \} $&lt;/span&gt; simply as &lt;span class=&quot;math-container&quot;&gt;$ x_{t} \ge x_{t-1} + y_{t-1} - z_{t-1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_t \ge 0$&lt;/span&gt;. Suppose that the inventory cost is smaller that the production cost. This might result in &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; being greater than &lt;span class=&quot;math-container&quot;&gt;$x_{t-1} + y_{t-1} - z_{t-1}$&lt;/span&gt;, while you want &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; to be exactly equal to &lt;span class=&quot;math-container&quot;&gt;$x_{t-1} + y_{t-1} - z_{t-1}$&lt;/span&gt;. Hence, you might need to linearize the &lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; constraint using binary variables (you could find the method for doing this with a little search on the web).&lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2019-10-31T08:13:12.233" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2958" PostTypeId="2" ParentId="2953" CreationDate="2019-10-31T08:49:45.917" Score="12" Body="&lt;p&gt;One obstacle in finding champions within the client company is that with OR solutions, there is a fear of automating decisions, which might make some people's job redundant. Or at least this impression can exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case, it would be important to emphasize, from the start, that the goal is not to replace people with algorithms, but rather provide them with a tool, to make even better decisions, or answer new questions that were out of scope before.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2019-10-31T08:49:45.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2959" PostTypeId="2" ParentId="2953" CreationDate="2019-10-31T13:55:06.983" Score="41" Body="&lt;p&gt;In addition to what others have shared, in my experience, the following can cause industry OR projects to fail or can at least cause big issues and/or delays:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) &lt;strong&gt;Quickly changing problem specification&lt;/strong&gt;. The problem specification often changes very rapidly (e.g. hard constraints become soft), as the client gets a better idea of what optimisation can offer. If you cannot keep up with the changes and develop a decision support system that really solves the client's project, the client might not accept it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) &lt;strong&gt;End-users' trust and acceptance&lt;/strong&gt;. If the end-users do not accept or do not trust the decision support system that has been built, then they will not use it, which is one of the worst case scenarios. Two measures can help with this from my experience: involve the end-users as soon as possible, and give them the sense that they are still in charge of making the end-decisions, for instance by providing several solutions from which they can choose from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) &lt;strong&gt;Many soft constraints&lt;/strong&gt;. In real-world applications there are often a lot of soft constraints and it can be very challenging to weight them according to the client's preferences (and for the client to find out their preferences!), and to design solving approaches that can solve such complex models. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) &lt;strong&gt;Fear of being replaced&lt;/strong&gt;. I've heard of cases where domain experts on the clients side would boycott projects, probably because they feared being replaced by the decision support system (often rightly so).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5) &lt;strong&gt;Domain language&lt;/strong&gt;. Probably not project-critical, but it can be a source of misunderstandings if the domain experts and the mathematicians use different domain languages that use the same vocabulary. For instance, if a mathematician talks about a &quot;constraint&quot; then they might imply that it is hard, while for the domain expert it might also be soft.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;6) &lt;strong&gt;&quot;It's always been like that&quot;&lt;/strong&gt;. With some clients you might come across business rules or process rules that have been installed by someone (who has often already left the company ages ago), and nobody remembers why it's done that way. It can be difficult to identify these cases, and debunk them, but if you do, you get a better idea of the underlying problem and can often provide better solutions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;7) &lt;strong&gt;&quot;Unspeakable&quot; constraints&lt;/strong&gt;. There are some constraints that the client will not be able to give you. For instance, when designing a roster, there might be employees who do not want to work together for personal reasons, so you should not schedule them in the same shift. However, it is not ethical to put this kind of information, say, into a database, from which you then extract these constraints. In such cases, your problem model will not be able to be fully accurate, and will not produce the solution the client would actually prefer.&lt;/p&gt;&#xA;" OwnerUserId="298" LastActivityDate="2019-10-31T13:55:06.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2960" PostTypeId="2" ParentId="2953" CreationDate="2019-10-31T15:19:26.607" Score="4" Body="&lt;p&gt;I haven't had the experience in any project in the industry but in my research which is on a collaborative project, I can see the potential reasons for failure:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Lake of a common understanding of the problem to solve. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Usually, it is very hard to have the same understanding of details and the same technical terms if you don't have the same background (in terms of educational major).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Implementation is hard&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It is sometimes very hard for the industry or project partner to accept all the details of what you propose and then implement it. As an example, when your solution to a problem in a factory floor needs the replacement of a production cell, it is almost impossible to convince the management to implement the changes unless you speak in their own language (profit, profit, profit). So you need to have an explanation (in terms of money) for all aspects of your solution unless the project will fail.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Lack of sufficient amount of necessary data&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Although most of the time it is hard to gather the data that you need to model the details of the project, sometimes you won't have those data because of either it's impossible to gather the data with the equipment in use, or it needs a long time and hard work to get the data so in this situation you need either to consider some assumptions or estimate them. Both of ways are very prone to failure.   &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-10-31T19:44:55.530" LastActivityDate="2019-10-31T19:44:55.530" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2961" PostTypeId="1" AcceptedAnswerId="10157" CreationDate="2019-10-31T15:26:20.860" Score="12" ViewCount="152" Body="&lt;p&gt;We have a number of test libraries to test solver performance like MINLPLIB, QPLIB, etc., but the problems in all libraries I know are overwhelmingly on the feasible side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a library to test a solver's ability to prove infeasibility?&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="38" LastEditDate="2019-11-01T00:07:37.000" LastActivityDate="2023-03-17T15:15:43.603" Title="Is there a library of infeasible MINLP problems?" Tags="|minlp|feasible-points|test-instances|problem-library|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2962" PostTypeId="1" CreationDate="2019-10-31T17:47:58.680" Score="12" ViewCount="490" Body="&lt;p&gt;I'm trying to understand a paper called &quot;Supersparse Linear Integer Models for Predictive Scoring Systems&quot; by Ustun, Tracà and Rudin, who introduce a really interesting method for generating an understandable classification system that actually challenges machine learning models for binary decisions in at least some areas. According to the authors, they use a mixed-integer problem (MIP), whose objective penalizes the training error (of which I do not what it is), the &lt;span class=&quot;math-container&quot;&gt;$L_0$&lt;/span&gt;-norm and the &lt;span class=&quot;math-container&quot;&gt;$L_1$&lt;/span&gt;-norm (of which I know the definition in regular Linear Algebra cases, but not in this instance) of its coefficients. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In their formulation, they use an optimization in the form of: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_\lambda\frac{1}{N}\sum_{i = 1}^{N}\mathbb{1}[y_1x_1^\top\lambda \leq 0] + C_0\|\lambda\|_0+C_1\|\lambda\|_1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which produces a classifier &lt;span class=&quot;math-container&quot;&gt;$\hat y = \operatorname{sgn}(x^\top\lambda)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^P$&lt;/span&gt; is a vector of features (with &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; being number of features), &lt;span class=&quot;math-container&quot;&gt;$\lambda \in \mathbb{Z}^P$&lt;/span&gt; being number of coefficients and &lt;span class=&quot;math-container&quot;&gt;$\hat y \in \{-1,1\}$&lt;/span&gt; being the predicted labels. Also within the formula, &lt;span class=&quot;math-container&quot;&gt;$C_0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_1$&lt;/span&gt; are referred to as penalties, and the paper continues by listing an MIP with &lt;span class=&quot;math-container&quot;&gt;$N + 3P$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$2N + 6P$&lt;/span&gt; constraints, which I could also have listed, but didn't, since I only wanted to give an idea of what I will have to work with. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, the reason I even posted all this here, is not because I'm expecting an explanation of the research, but rather because I'd be really happy if anybody could provide me with information on what topics I will have to deal with and whether anyone with knowledge on this can tell if I should even bother trying to understand it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a second-year physics and third-year psychology student with basic knowledge in Statistics, Linear Algebra, and Analysis (we got introduced to multivariate analysis some while ago and were talking about Lagrange Multipliers and more general integrals (Lebesgue, Darboux) in the last lessons). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the paper, I now started out by looking at optimization problems, for which I found some very easy and comprehensible examples, and then looked at examples of Linear-Programming Problems, which I understand to be optimization problems in which the function domain has been constrained, for example by some inequalities. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really want to apologize for the vast and general character of my question and understand that there probably is no simple solution to this and do not want to upset anyone with it, but I'm rather just looking for general information on whether these types of problem are graspable for someone with basic understanding in math and what type of material I should read/watch/work out. Any help is greatly appreciated. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If this is the wrong forum to ask this question, please let me know.&lt;/p&gt;&#xA;" OwnerUserId="2627" LastEditorUserId="68" LastEditDate="2019-11-09T12:45:51.743" LastActivityDate="2019-11-09T12:45:51.743" Title="How difficult is it to understand a Machine Learning method based on integer optimization?" Tags="|optimization|mixed-integer-programming|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2963" PostTypeId="2" ParentId="2871" CreationDate="2019-10-31T21:06:47.340" Score="2" Body="&lt;p&gt;A few suggestions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If possible, relax to a set covering problem (&lt;span class=&quot;math-container&quot;&gt;$\ge 1$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$=1$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Use a greedy heuristic to generate a good feasible starting solution.&lt;/li&gt;&#xA;&lt;li&gt;Instead of listing all the sets &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; explicitly, reformulate the problem compactly, with binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,k}$&lt;/span&gt; indicating whether element &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; appears in the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;th set.  This approach requires a way to express the cost as a function of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Use a dynamic column generation approach to add promising sets as needed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-10-31T21:06:47.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2964" PostTypeId="1" AcceptedAnswerId="2971" CreationDate="2019-11-01T00:38:47.590" Score="10" ViewCount="1435" Body="&lt;p&gt;I have the following optimization problem which is a MILP. I can solve it with a MILP solver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_t&amp;amp;\quad t\\\text{s.t.}&amp;amp;\quad d_{c}-t\le \sum_{n=1}^{N} B_{n,c}x_{n}\le d_{c}+t,\quad\forall c\in\{1,2,\cdots,C\}\\&amp;amp;\quad\sum_{n=1}^{N} x_n = M\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is a binary matrix of size &lt;span class=&quot;math-container&quot;&gt;$N\times C$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is a known vector of the positive numbers of size &lt;span class=&quot;math-container&quot;&gt;$1\times C$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a known parameter&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; is an optimization variable (integer variable, &lt;span class=&quot;math-container&quot;&gt;$x_n\ge 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_n\in\{0,1,2,3,\cdots,M\}$&lt;/span&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is also an optimization variable (integer/continuous)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Therefore, I am looking for a heuristic solution to the problem above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&quot;EDIT&quot;$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;span class=&quot;math-container&quot;&gt;$C=10$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$N=6$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$M=50$&lt;/span&gt;.&#xA;Each row of &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; has 3 ones. &#xA;&lt;span class=&quot;math-container&quot;&gt;$d=\begin{bmatrix}&#xA;32 &amp;amp; 14 &amp;amp; 18 &amp;amp; 20 &amp;amp; 10 &amp;amp; 15 &amp;amp; 10 &amp;amp; 12 &amp;amp; 16 &amp;amp; 18&#xA;\end{bmatrix}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With @prubin's approach:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say, the first 5 rows of B looks like this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{bmatrix}&#xA;1 &amp;amp; 1 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 \\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 1 \\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 1 \\&#xA;\end{bmatrix}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the approach, we will have &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; iterations. In each iteration, we increase one of the variables &lt;span class=&quot;math-container&quot;&gt;$x_n,n=1,2,\cdots,N$&lt;/span&gt; by 1.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2019-11-05T23:08:02.963" LastActivityDate="2019-11-05T23:08:02.963" Title="Is there a heuristic approach to the MILP problem?" Tags="|mixed-integer-programming|linear-programming|linearization|heuristics|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2965" PostTypeId="2" ParentId="2934" CreationDate="2019-11-01T00:54:06.220" Score="4" Body="&lt;p&gt;Being able to elicit a &quot;necessary and sufficient&quot; statement of the &quot;Problem&quot;.  Being able to structure the &quot;Problem&quot; so as to know whether the proposed Problem Solution is good fit for OR-based approaches. Being able to effectively communicate the benefits, costs and, very importantly, the risks of your recommended approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The middle one of being able to understand the problem sufficiently well that you can structure it in terms of an OR approach requires that you understand how to apply OR techniques at a profound level is THE most important technical skill.&lt;/p&gt;&#xA;" OwnerUserId="2631" LastActivityDate="2019-11-01T00:54:06.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2966" PostTypeId="2" ParentId="2964" CreationDate="2019-11-01T01:16:26.857" Score="10" Body="&lt;p&gt;You can solve the LP relaxation and round the resulting solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;, being careful to preserve the equality constraint.  Then take &lt;span class=&quot;math-container&quot;&gt;$t=\max_c |\sum_n B_{n,c} x_n - d_c|$&lt;/span&gt;.  There are lots of choices for rounding methods, but two natural choices are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x = \lfloor x^* \rfloor$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R=M-\sum_n x_n$&lt;/span&gt;. In descending order of &lt;span class=&quot;math-container&quot;&gt;$x^*_n$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$x_n = x_n+1$&lt;/span&gt; for the top &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; values.&lt;/li&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x = \lfloor x^* \rfloor$&lt;/span&gt;. In descending order of &lt;span class=&quot;math-container&quot;&gt;$x^*_n - \lfloor x^*_n \rfloor$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$x_n = x_n+1$&lt;/span&gt; for the top &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; values.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you don't mind solving multiple LPs, you can round only one variable at a time, permanently fixing it to that value.  This is sometimes called a &lt;em&gt;diving&lt;/em&gt; heuristic.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2019-11-01T12:43:33.850" LastActivityDate="2019-11-01T12:43:33.850" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2968" PostTypeId="1" AcceptedAnswerId="2970" CreationDate="2019-11-01T11:58:12.010" Score="7" ViewCount="153" Body="&lt;p&gt;I have a binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and a set of binary variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt;.&#xA;My problem requires that &lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{i\in I}x_i = b.$$&lt;/span&gt;&#xA;What I want to formulate is the following implication: if &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i\in \tilde{I}} x_i \leq b-1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\tilde{I}\subseteq I$&lt;/span&gt;, but I can't seem to figure out how. I have been able to find a formulation that says if &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i\in \tilde{I}}x_i=m$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt; by the inequality &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i\in \tilde{I}}x_i + y \leq m$&lt;/span&gt; but that is not exactly what I want. Any help is greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="609" LastEditorUserId="123" LastEditDate="2019-11-01T17:01:51.087" LastActivityDate="2019-11-01T17:01:51.087" Title="Help with formulating an implication" Tags="|modeling|binary-variable|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2969" PostTypeId="2" ParentId="2964" CreationDate="2019-11-01T12:07:31.643" Score="4" Body="&lt;p&gt;Add penalty terms to nudge variables toward integers. For example, for binary variables,&#xA;add piecewise-linear penalties &#xA;&lt;span class=&quot;math-container&quot;&gt;$$ 100 \times \text{min}( x_i, 1 - x_i ), \ 0 \leq x_i \leq 1 . $$&lt;/span&gt;&#xA;In the general case, you could run two passes:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;plain LP &lt;span class=&quot;math-container&quot;&gt;$\to$&lt;/span&gt; some variables that you want to be ints (not too many)&lt;/li&gt;&#xA;&lt;li&gt;penalize those as above.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Rounding, @Rob Pratt's answer, is certainly simpler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(By the way, &lt;a href=&quot;https://www.gnu.org/software/glpk/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GLPK&lt;/a&gt;&#xA;does MILP, and is 100 % opensource.)&lt;/p&gt;&#xA;" OwnerUserId="2634" LastActivityDate="2019-11-01T12:07:31.643" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2970" PostTypeId="2" ParentId="2968" CreationDate="2019-11-01T12:21:29.730" Score="12" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i \le y$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in I \setminus \tilde{I}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-11-01T12:21:29.730" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2971" PostTypeId="2" ParentId="2964" CreationDate="2019-11-01T17:31:36.170" Score="9" Body="&lt;p&gt;There are a variety of heuristics and metaheuristics (not necessarily using LP) that you could employ. If we set &lt;span class=&quot;math-container&quot;&gt;$S_c = \{n : B_{n,c}=1\}$&lt;/span&gt;, we can rewrite the problem as &lt;span class=&quot;math-container&quot;&gt;$$\begin{align*}&#xA;\min_{t} &amp;amp; \quad t\\&#xA;\text{s.t.} &amp;amp; \quad\left|\sum_{n\in S_{c}}x_{n}-d_{c}\right|\le t,\quad\forall c\in\{1,2,\cdots,C\}\\&#xA; &amp;amp; \quad\sum_{n=1}^{N}x_{n}=M.&#xA;\end{align*}$$&lt;/span&gt;A simple greedy heuristic is to start with &lt;span class=&quot;math-container&quot;&gt;$x_n=0\,\forall n$&lt;/span&gt; and, in each iteration, bump one of the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables up by 1, selecting the &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; that most improves (or least degrades) &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, until the equality constraint is satisfied. The problem would be amenable to any of the &quot;usual&quot; suspects among metaheuristics (simulated annealing, tabu search, genetic algorithms) with proper adjustments to handle the equality constraint.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2019-11-04T15:35:38.570" LastActivityDate="2019-11-04T15:35:38.570" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="2972" PostTypeId="2" ParentId="2962" CreationDate="2019-11-01T17:48:48.450" Score="12" Body="&lt;p&gt;This forum is fine for this question. The training error is just the first term (summation) in the objective function. Technically, I would say the sum without the factor &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{N}$&lt;/span&gt; is the training error; they scaled it to make it commensurable in some sense with the penalties for model size (the two norm terms). The model size penalties are intended to discourage overfitting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To understand how to solve the model (beyond &quot;stick it in a solver program and turn the crank&quot;), you would need to first understand linear programming (which optimizes a linear function of continuous variables subject to constraints posed as linear equalities and inequalities), and then move on to integer linear programming (in which some or all of those continuous variables are restricted to integer values, which makes solving &lt;em&gt;much&lt;/em&gt; harder in general). On the other hand, to understand how to use this approach, you could get by with just an understanding of what integer linear programming is (basically what I just said, maybe expanded a bit), plus a knowledge of what are/are not suitable programs for solving such models (and how to specify the model as input to such a program), plus how to &quot;linearize&quot; the term in the summation (which I'm pretty sure Ustun et al. would do using so-called &quot;big M&quot; constraints). The distinction here is somewhat like learning to drive a car (second case) v. learning how the internal combustion engine works (first case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;drive the car&quot; version (including what &quot;big M&quot; constraints are) is certainly within reach of someone with your math background, with what I would consider to be modest effort. The &quot;internal combustion engine&quot; version does not require more mathematical chops than what you have demonstrated, but does require quite a bit more time and effort getting up to speed ... and, I suspect, would not pay dividends in the psychology domain. (I refuse to speculate about physics, since I'm pretty sure all physics beyond basic mechanics is voodoo.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-11-01T17:48:48.450" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2973" PostTypeId="2" ParentId="2962" CreationDate="2019-11-01T18:11:30.957" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I'd be really happy if anybody could provide me with information on what topics I will have to deal with and whether anyone with knowledge on this can tell if I should even bother trying to understand it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The topics under discussion are medicine, statistics and artificial intelligence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The paper &quot;&lt;a href=&quot;https://arxiv.org/abs/1306.5860&quot; rel=&quot;nofollow noreferrer&quot;&gt;Supersparse Linear Integer Models for Predictive Scoring Systems&lt;/a&gt;&quot; (Jun 25 2013), by Berk Ustun, Stefano Traca, and Cynthia Rudin is an introduction to a:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;formal approach for creating &lt;a href=&quot;https://en.wikipedia.org/wiki/Medical_Scoring_Systems&quot; rel=&quot;nofollow noreferrer&quot;&gt;scoring systems&lt;/a&gt;, called Supersparse Linear Integer Models (SLIM). SLIM produces scoring systems that are accurate and interpretable using a mixed-integer program (MIP) whose objective penalizes the training error, &lt;span class=&quot;math-container&quot;&gt;$L^0$&lt;/span&gt;-&#xA;  norm (empty set) and &lt;a href=&quot;http://mathworld.wolfram.com/VectorNorm.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$L^1$&lt;/span&gt;&lt;/a&gt;-norm of its coefficients.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A scoring system consists of as small a list as possible of properties, each property is assigned a score. The score is added up and serves as a prediction of an outcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Receiver_operating_characteristic#ROC_curves_beyond_binary_classification&quot; rel=&quot;nofollow noreferrer&quot;&gt;Receiver operating characteristic curve analysis&lt;/a&gt; provides tools to select possibly optimal models and to discard suboptimal ones independently from (and prior to specifying) the cost context or the class distribution. ROC analysis is related in a direct and natural way to cost/benefit analysis of diagnostic decision making.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple explanation is that they are optimizing the input space, collecting the least amount of data, asking the fewest questions, and using AI with MIP feedback to determine how optimal the answer is compared to using a full data set (a much larger list of information).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That permits a doctor to perform the fewest number of tests, or ask the patient the least number of questions, and obtain extremely close to the same diagnosis as would be obtained from a much more thorough (and costly) investigation.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... I'm rather just looking for general information on whether these types of problem are graspable for someone with basic understanding in math and what type of material I should read/watch/work out. Any help is greatly appreciated. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;An example of how a new scoring system is developed and improved from an existing scoring system is presented in: &quot;&lt;a href=&quot;https://wjps.bmj.com/content/2/3/e000060.info&quot; rel=&quot;nofollow noreferrer&quot;&gt;Validation and modification of the ‘Chiang Mai University Intussusception scoring system’ used to predict failure of non-surgical treatment in infantile intussusception&lt;/a&gt;&quot; (July 23 2019), by Kaimook Boonsanit, Supika Kritsaneepaiboon, Piyawan Chiengkriwate, and Surasak Sangkhathat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They were able to improve the sensitivity of the &lt;a href=&quot;https://www.dovepress.com/prognostic-indicators-for-failed-nonsurgical-reduction-of-intussuscept-peer-reviewed-article-TCRM&quot; rel=&quot;nofollow noreferrer&quot;&gt;origonal&lt;/a&gt; Chiang Mai University Intussusception (&lt;a href=&quot;https://www.dovepress.com/clinical-prediction-rules-for-failed-nonoperative-reduction-of-intussu-peer-reviewed-article-TCRM&quot; rel=&quot;nofollow noreferrer&quot;&gt;CMUI&lt;/a&gt;) scoring system by altering the input parameters (asking different questions) at a cost of a small reduction in specificity. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading those articles, to understand scoring improvement, involves some understanding of medical terminology and procedures but doesn't require an understanding of artificial intelligence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The original analysis, as described in &quot;&lt;a href=&quot;https://www.dovepress.com/prognostic-indicators-for-failed-nonsurgical-reduction-of-intussuscept-peer-reviewed-fulltext-article-TCRM&quot; rel=&quot;nofollow noreferrer&quot;&gt;Prognostic indicators for failed nonsurgical reduction of intussusception&lt;/a&gt;&quot;, is simply:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Statistical analysis was done with commercial statistical software (STATA 11.0; StataCorp LP, College Station, TX, USA). The descriptive data were reported in count and percent for categorical data, and mean and standard deviation or median and interquartile range for continuous data. The univariable analysis was done by Fisher’s exact test for categorical data and Student’s t-test or Mann–Whitney U-test for continuous data. The multivariable regression analysis of the prognostic factors for intussusception reduction failure was done by generalized linear model for exponential risk regression, and reported by risk ratio (RR) clustered by an age of 3 years (due to the risk for pathologic leading point). The receiver operating characteristic curve was plotted for assessing the performance of the multivariable model. The statistical significance level was set as two-tailed with a P-value &amp;lt;0.05.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Ustun's paper is simply the application of artificial intelligence to determine the best input to provide the most optimal output, that differs from a simple application of Operations Research where most or all of the available data would be utilized to provide the most optimal solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A newer paper (Sept 17 2019) by Ustun and Rudin, &quot;&lt;a href=&quot;https://arxiv.org/abs/1610.00168&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learning Optimized Risk Scores&lt;/a&gt;&quot; follows up on their earlier work:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Abstract&lt;/strong&gt;&lt;br&gt;&#xA;  Risk scores are simple classification models that let users make quick risk predictions by adding and subtracting a few small numbers. These models are widely used in medicine and criminal justice, but are difficult to learn from data because they need to be calibrated, sparse, use small integer coefficients, and obey application-specific constraints. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;In this paper, we introduce a machine learning method to learn risk scores. We formulate the risk score problem as a mixed integer nonlinear program, and present a cutting plane algorithm to recover its optimal solution. We improve our algorithm with specialized techniques that generate feasible solutions, narrow the optimality gap, and reduce data-related computation. Our algorithm can train risk scores in a way that scales linearly in the number of samples in a dataset, and that allows practitioners to address application-specific constraints without parameter tuning or post-processing.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-11-01T18:11:30.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2974" PostTypeId="2" ParentId="2953" CreationDate="2019-11-02T16:11:24.090" Score="14" Body="&lt;p&gt;Adding to the other good answers here...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Failing to employ an iterative process&lt;/strong&gt;&lt;br&gt;&#xA;The idea that a few meetings to communicate and understand the problem, scope the OR solution, desired outputs, etc., will enable the OR magician to disappear only to return with the holy grail is a fantasy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It requires &lt;strong&gt;iteration&lt;/strong&gt;. Develop initial capability, evaluate, improve or add capability, evaluate, ..., continue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If during each iterative meeting, the OR team plus stakeholders explicitly ask &lt;em&gt;What are the 10 reasons this won't work (for the stakeholders)?&lt;/em&gt;, then fix those issues, the team can often achieve convergence as they employ this strategy. Often the issues the stakeholders raise with a preliminary solution are fixable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clearly a good process to start the project affects this, but that's already well-covered in the other answers. &lt;/p&gt;&#xA;" OwnerUserId="491" LastActivityDate="2019-11-02T16:11:24.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2975" PostTypeId="1" AcceptedAnswerId="2976" CreationDate="2019-11-02T19:38:59.463" Score="12" ViewCount="572" Body="&lt;p&gt;On Wikipedia's page for the &lt;a href=&quot;https://en.wikipedia.org/w/index.php?title=Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions&amp;amp;oldid=922819290&quot; rel=&quot;noreferrer&quot;&gt;KKT conditions&lt;/a&gt;, it is stated that Mangasarian-Fromovitz constraint qualification (MFCQ) is weaker than linear independent constraint qualification (LICQ).  What is a counter-example to the claim MFCQ &lt;span class=&quot;math-container&quot;&gt;$\Rightarrow$&lt;/span&gt; LICQ?&lt;/p&gt;&#xA;" OwnerUserId="324" LastEditorUserId="145" LastEditDate="2019-11-02T23:46:52.113" LastActivityDate="2019-11-03T08:19:54.163" Title="Example satisfying Mangasarian-Fromovitz CQ but not LICQ" Tags="|constraint|kkt-conditions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2976" PostTypeId="2" ParentId="2975" CreationDate="2019-11-03T00:57:04.903" Score="8" Body="&lt;p&gt;Consider the following minimization problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;\min &amp;amp;&amp;amp;\quad f(x) ~&amp;amp;= -x &amp;amp;\\&#xA;\text{s.t.} &amp;amp;&amp;amp;\quad g_1(x) &amp;amp; =x &amp;amp;\le 0\\&#xA;&amp;amp;&amp;amp;\quad g_2(x) &amp;amp; = 2x &amp;amp;\le 0&#xA;\end{eqnarray}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which attains the unique global minimum for &lt;span class=&quot;math-container&quot;&gt;$x^* = 0$&lt;/span&gt;. Note that both constraints are active in this point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By definition, &lt;span class=&quot;math-container&quot;&gt;$\nabla g_1(x^*) = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\nabla g_2(x^*) = 2$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;MFCQ&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The gradients of the equality constraints are linearly independent at &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; and there exists a vector &lt;span class=&quot;math-container&quot;&gt;$d \in \mathbb{R}^n$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\nabla g_i(x^*)^\top d &amp;lt; 0$&lt;/span&gt; for all active inequality constraints and &lt;span class=&quot;math-container&quot;&gt;$\nabla h_j(x^*)^\top d = 0$&lt;/span&gt; for all equality constraints.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In this case, we can choose &lt;span class=&quot;math-container&quot;&gt;$d = -1$&lt;/span&gt; to obtain &lt;span class=&quot;math-container&quot;&gt;$\nabla g_i(x^*)^\top d &amp;lt; 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i \in \{1,2\}$&lt;/span&gt;. We have no equality constraints. It follows that MFCQ holds.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;LICQ&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The gradients of the active inequality constraints and the gradients of the equality constraints are linearly independent at &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;At &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;, both constraints are active and their gradients are clearly &lt;em&gt;not&lt;/em&gt; independent. It follows that LICQ does not hold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We conclude that MFCQ &lt;span class=&quot;math-container&quot;&gt;$\Rightarrow$&lt;/span&gt; LICQ is false.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="123" LastEditDate="2019-11-03T08:19:54.163" LastActivityDate="2019-11-03T08:19:54.163" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2977" PostTypeId="2" ParentId="2953" CreationDate="2019-11-03T02:43:59.447" Score="6" Body="&lt;p&gt;There are many reasons, but at the end of the day I believe it comes down to people like us trying to make industrial customers understand what optimisation is and how it works. Although this is a natural approach for academically trained people, this is not how products or services are sold, nor how adoption is driven. Adoption of a technology in every single field has historically been driven by automation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;People without the right training are unlikely to be able to really understand what we do, and that's fine. Unfortunately, it is hard to approach the adoption process in a different way due to (i) a lack of out-of-the-box solutions that clients can use and understand, and (ii) any decent industrial software in our field being obscenely expensive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Think about why people like machine learning so much: in their mind, they just give someone a bunch of data and something good &quot;magically&quot; happens. Even better, all software they will need to use is free!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, I have never once come across a situation where we could help a client adopt an OR solution (assuming they're not just buying a new solver or a maths compiler) without some consulting, a customised solution, and some integration work. The lack of our community's ability to do so is, in my opinion, due to a lack of tools designed (at least partially) for non-OR people. Even though some decent software for specialised things does exist, it is so expensive that very few people can afford it (or are willing to take the leap of faith), which stagnates market growth. This specialisation is literally killing the market: no-one wants to fork out half a million or more for something that doesn't do everything they (think they) might need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One could argue of course that what we do is complicated and requires a certain level of boilerplate, but that's just not true - machine learning used to be equally obscure, but hype along with very good tools have turned that into something that people in the industry want to adopt. Heck, even maths enjoys smaller adoption barriers, largely due the efforts of companies like Wolfram or Mathworks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In OR, the lack of this plug-and-play functionality makes non-experts distrustful: they don't understand the technology, they don't understand what it is that we'll do for them, they don't understand how they'll interact with it, they don't feel confident they'll be able to keep using the solution without the people who set everything up in the first place, they have to endure long iterations of meetings until we become able to communicate properly, and so on. &lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-11-03T02:43:59.447" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2978" PostTypeId="1" AcceptedAnswerId="2983" CreationDate="2019-11-03T12:01:34.757" Score="8" ViewCount="549" Body="&lt;p&gt;I have the following optimization problem which is an MILP. I can solve it with an MILP solver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{1}\max_{x_n,t}\,&amp;amp;\quad t\quad\\\text{s.t.}&amp;amp;\quad\sum_{n=1}^{N} x_n \,&amp;amp;= M\\&amp;amp;\quad\qquad\!s_c&amp;amp;\ge t d_c\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s_c=\sum\limits_{n=1}^{N} B_{n,c}x_{n}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is a given matrix of size &lt;span class=&quot;math-container&quot;&gt;$N\times C$&lt;/span&gt; with elements &lt;span class=&quot;math-container&quot;&gt;$\ge 0$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is a known vector of the positive numbers of size &lt;span class=&quot;math-container&quot;&gt;$1\times C$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a known parameter&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; is an optimization variable (integer variable, &lt;span class=&quot;math-container&quot;&gt;$x_n\ge 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_n\in\{0,1,2,3,\cdots,M\}$&lt;/span&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is also an optimization variable (integer/continuous)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I want to transform this into an LP, not MILP. Let us say I do not have a MILP solver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, I am looking for a heuristic solution to the problem above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to use the solution suggested by @prubin for the problem at: &lt;a href=&quot;https://or.stackexchange.com/questions/2964/is-there-a-heuristic-approach-to-the-milp-problem&quot;&gt;Is there a heuristic approach to the MILP problem?&lt;/a&gt;, but this is not working. It is choosing the same row of &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;&#xA;at every iteration.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2019-11-03T15:17:19.633" LastActivityDate="2019-11-03T15:42:27.517" Title="Is there a greedy heuristic approach to the MILP problem?" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|metaheuristics|heuristics|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2979" PostTypeId="2" ParentId="2978" CreationDate="2019-11-03T14:01:59.143" Score="6" Body="&lt;p&gt;Unlike the problem from the linked post, the objective here is “flat” at the initial solution in the sense that increasing some &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; by 1 unit will not change the objective value, which is initially 0.  The LP rounding approaches still apply if you linearize the &lt;span class=&quot;math-container&quot;&gt;$\min_c$&lt;/span&gt;, which you can do by introducing &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$t\le s_c/d_c$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-11-03T14:01:59.143" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2980" PostTypeId="1" CreationDate="2019-11-03T15:10:46.690" Score="13" ViewCount="261" Body="&lt;p&gt;We have two sets, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;. Some elements of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; must be connected to some elements of &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, but no element of a given set is connected to another element of the same set. (Think of a bipartite graph, and we are trying to establish the edges between the two sets.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a constraint that says: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For every &lt;em&gt;pair&lt;/em&gt; of elements of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, there is (at least/exactly) one element of &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; that both elements of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; are connected to. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For now, I have formulated this constraint by introducing a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{a_1,a_2,b}$&lt;/span&gt; that equals 1 if &lt;span class=&quot;math-container&quot;&gt;$a_1,a_2\in A$&lt;/span&gt; are both connected to &lt;span class=&quot;math-container&quot;&gt;$b\in B$&lt;/span&gt;, and then adding a constraint that says:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{b\in B} x_{a_1,a_2,b} \ge 1 \qquad \forall a_1,a_2\in A$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Or replace &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; for the &quot;exactly one&quot; version.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'd really like to avoid having these triply-indexed variables. Can anyone think of a way to enforce this constraint &lt;em&gt;without&lt;/em&gt; the &lt;span class=&quot;math-container&quot;&gt;$x_{a_1,a_2,b}$&lt;/span&gt; variables?&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="500" LastEditDate="2019-11-05T18:08:07.493" LastActivityDate="2019-11-06T00:00:35.683" Title="How to formulate: each pair of elements in $A$ has one common unit in $B$" Tags="|mixed-integer-programming|modeling|linearization|logical-constraints|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2982" PostTypeId="2" ParentId="2980" CreationDate="2019-11-03T15:23:11.227" Score="3" Body="&lt;p&gt;How about we write your constraint, just replacing the tuple of &lt;span class=&quot;math-container&quot;&gt;$(a_1, a_2)$&lt;/span&gt; with, say, &lt;span class=&quot;math-container&quot;&gt;$a'$&lt;/span&gt;. So, you'll have two indexed variables of &lt;span class=&quot;math-container&quot;&gt;$x_{a',b}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I mean is, first enumerate all the pairs of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, and then, do your sum over those (and I think you'll have a faster write-time of your constraint in python, for instance, too)&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-11-03T15:23:11.227" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2983" PostTypeId="2" ParentId="2978" CreationDate="2019-11-03T15:42:27.517" Score="6" Body="&lt;p&gt;Here is a somewhat greedy heuristic. First, to simplify notation a bit, let &lt;span class=&quot;math-container&quot;&gt;$$f_{c}(x)=\frac{1}{d_c}\sum_{n=1}^N B_{n,c}x_n\, \forall c.$$&lt;/span&gt; So we want to maximize &lt;span class=&quot;math-container&quot;&gt;$$t=\min_c f_c(x)$$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$$\sum_n x_n = M.\quad (1)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now start with some arbitrary (let's say randomly generated) &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; satisfying (1). Calculate all the &lt;span class=&quot;math-container&quot;&gt;$f_c(x)$&lt;/span&gt;, and for each &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; calculate two values: the change &lt;span class=&quot;math-container&quot;&gt;$\delta_n$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; increases by 1, and the change &lt;span class=&quot;math-container&quot;&gt;$\gamma_n$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; decreases by 1. (If &lt;span class=&quot;math-container&quot;&gt;$x_n=0$&lt;/span&gt;, set &lt;span class=&quot;math-container&quot;&gt;$\gamma_n=-\infty$&lt;/span&gt;, since &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; cannot go below zero.) Choose &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; that maximizes &lt;span class=&quot;math-container&quot;&gt;$\delta_n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; that maximizes &lt;span class=&quot;math-container&quot;&gt;$\gamma_m$&lt;/span&gt;. If the net change &lt;span class=&quot;math-container&quot;&gt;$\delta_n + \gamma_m$&lt;/span&gt; is positive, increase &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; by 1 and decrease &lt;span class=&quot;math-container&quot;&gt;$x_m$&lt;/span&gt; by 1, preserving satisfaction of (1), and repeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the net change is less than or equal to zero, compare the current &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; to the best solution so far. If it is better, record &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; as the new best solution. At this point, you can either stop or generate a new random &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and continue from there.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-11-03T15:42:27.517" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2984" PostTypeId="2" ParentId="2980" CreationDate="2019-11-03T16:03:16.443" Score="1" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$B_i$&lt;/span&gt; is the set whose elements are connected by &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;, then for the &quot;at least&quot; condition we want &lt;span class=&quot;math-container&quot;&gt;$$\sum_{b_k\in B_i\cap B_j\\\quad i\ne j}|b_k|&amp;gt;0\qquad\forall a_i,a_j\in A$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$k=1,\cdots,K$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$K=|B_i\cap B_j|$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the &quot;exactly one&quot; condition we want &lt;span class=&quot;math-container&quot;&gt;$$-b_1+\sum_{b_k\in B_i\cap B_j\\\quad i\ne j}|b_k|=0\qquad\forall a_i,a_j\in A.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-11-03T16:03:16.443" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="2985" PostTypeId="2" ParentId="2980" CreationDate="2019-11-03T16:17:00.230" Score="9" Body="&lt;p&gt;If you don’t require linear constraints, you can introduce (or reuse) binary variables &lt;span class=&quot;math-container&quot;&gt;$y_{a.b}$&lt;/span&gt; and quadratic constraints &#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{b\in B} y_{a_1,b} y_{a_2,b} \ge 1 \qquad \forall a_1,a_2\in A,$$&lt;/span&gt;&#xA;for which your triply-indexed formulation is a linearization.&#xA;If you do need linear and are worried about the problem size, you can generate the violated constraints dynamically.&#xA;Depending on your other constraints, you might also be able to use &lt;em&gt;compact linearization&lt;/em&gt; a la Liberti.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-11-03T16:17:00.230" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2986" PostTypeId="2" ParentId="2980" CreationDate="2019-11-03T21:17:35.583" Score="7" Body="&lt;p&gt;Can you consider an extended formulation?&#xA;In this case you could consider variables &lt;span class=&quot;math-container&quot;&gt;$x_{A',b} \in \{0,1\}$&lt;/span&gt; with value 1 iff&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;  \{a,b\} \in E &amp;amp; \quad &amp;amp; \forall a \in A' \\&#xA;  \{a,b\} \not\in E &amp;amp; \quad &amp;amp; \forall a \not\in A'&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(where &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is the edge set of the bipartite graph). In other words it determines which subset &lt;span class=&quot;math-container&quot;&gt;$A' \subseteq A$&lt;/span&gt; is connected with vertex &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I believe, your constraint becomes:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{b \in B} \sum_{A' \supseteq \{a_1, a_2\}} x_{A',b} = 1 \quad \forall a_1,a_2 \in A \;\; (a_1 \neq a_2)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and you need to ensure that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{A' \subseteq A} x_{A',b} = 1 \quad \forall b \in B&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course enumerating the variables is not feasible, and you should resort to some column generation approach.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2019-11-03T21:17:35.583" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2987" PostTypeId="1" CreationDate="2019-11-04T12:03:02.787" Score="12" ViewCount="448" Body="&lt;p&gt;The problem I am facing is clustering problem, needed for a Vehicular Routing Problem (VRP) I'm tackling. It is a heterogeneous VRP with Time Window (TW) and a capacity utilization constraint, i.e. a truck can be routed only if its loading factor is more than 80%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have a set of customers dispersed on the map. Each customer has placed an order of a certain volume, varying from 1.000 to 36.000lt of a petroleum product. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to cluster these customers, in order to route them. Right now, I am using the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-means algorithm, and to find the number of clusters I am taking the integer value of &lt;span class=&quot;math-container&quot;&gt;$$\frac{\text{Sum Of Unrouted Orders}}{\text{Capacity Of Biggest Idle Vehicle}}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this method is kind of faulty, because of the following problems:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) A cluster may be very small because the algorithm MUST create a certain number of clusters. In this case the customers of this small cluster will not be routed, due to the capacity utilization constraint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Clusters with customers that are far away from the other are created, in order to reach the target volume of the cluster (close to the vehicle's capacity)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is the following: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) Do you know any method of finding the optimal number of clusters, beside the elbow and silhouette methods, as the clustering part is running several times, and I cannot spend time picking the number of clusters in each iteration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) Do you know a variation of the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-means algorithm that takes into consideration the volumes of the orders?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Some further research lead me to the capacitated clustering problem, which seems to be perfectly fit to what I'm looking for. As I was reading the work from &lt;em&gt;Marcos Negreirosa, Augusto Palhano&lt;/em&gt; found at &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0305054804003120&quot; rel=&quot;nofollow noreferrer&quot;&gt;The capacitated centred clustering problem&lt;/a&gt;, I realised that the work suggested was similar to what I have implemented. My implementation is the following:&#xA;Clustering Algorithm:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;1. Initialize k centers (random points from dataset which are scattered on the map)&#xA;2. For each center, perform Range search around it with radius 1, 2, 4, …. and collect points in cluster with total capacity ~ C/2.&#xA;3. Update centers using the median per cluster&#xA;4. Assignment: For each point P that does not belong to any cluster&#xA;    I. Sort centers by distance to P&#xA;    II. Assign P to nearest cluster with availability in capacity&#xA;5. Update each center with cluster's median&#xA;6. Repeat steps 2-5, until the algorithm converges i.e. the centers do not change much in step 5.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but some of the results were a disappointment, along the run, as &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Many customers were left unrouted (Cluster didn't fit perfectly in a vehicle, so a cluster could leave unrouted customers, even though the volume was close the its capacity).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Clusters created, after the creation of some routes, were combining customers very far from each other, as these customers were left off from when the cluster was routed.&lt;/p&gt;&#xA;" OwnerUserId="2647" LastEditorUserId="2599" LastEditDate="2020-01-11T15:38:23.487" LastActivityDate="2020-01-11T15:38:23.487" Title="Two-stage $k$-means clustering" Tags="|combinatorial-optimization|vehicle-routing|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2988" PostTypeId="2" ParentId="2932" CreationDate="2019-11-04T13:32:11.837" Score="7" Body="&lt;p&gt;I waited some time but apparently no easy answer here. Thanks for providing some more hints in the comments to your question. One specialty about the knapsack book is: it is a &lt;strong&gt;monograph&lt;/strong&gt;, that is, written by the same author(s). There are only few other books about a particular combinatorial optimization problem, with theory and algorithmic components, and precise in the mathematics, and the &quot;LPs are used&quot; portion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A brilliant example is &lt;a href=&quot;https://www.amazon.de/Pursuit-Traveling-Salesman-William-Cook/dp/0691152705&quot; rel=&quot;noreferrer&quot;&gt;In Pursuit of the Traveling Salesman - Mathematics at the Limits of Computation&lt;/a&gt; by Bill Cook.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often, books are &lt;strong&gt;collections&lt;/strong&gt;, that is, they are edited by a small number of researchers, but the single chapters are written by different people, and thus usually differ in style and presentation; usually, there is not much coherence in terms of cross references among chapters etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One example is the area of vehicle routing, with books like &lt;a href=&quot;https://www.amazon.de/Vehicle-Routing-Problem-Challenges-Operations/dp/0387777776&quot; rel=&quot;noreferrer&quot;&gt;The Vehicle Routing Problem&lt;/a&gt; by Golden et al., or &lt;a href=&quot;https://www.amazon.de/Vehicle-Routing-Problems-Applications-Optimization/dp/1611973589&quot; rel=&quot;noreferrer&quot;&gt;Vehicle Routing: Problems, Methods, and Applications&lt;/a&gt; by Toth and Vigo.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-11-04T13:32:11.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2989" PostTypeId="1" AcceptedAnswerId="2990" CreationDate="2019-11-04T21:53:19.117" Score="9" ViewCount="178" Body="&lt;p&gt;I have the following simplified optimization problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max &amp;amp;\quad ax+by\\\text{s.t.}&amp;amp;\quad0 \le x \le \overline X\\&amp;amp;\quad0 \le y \le\overline Y\\&amp;amp;\quad z = E-x+\beta\cdot y\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\overline X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\overline Y$&lt;/span&gt; are parameters and the rest are variables. What would be the dual objective function for this optimization problem? &lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="123" LastEditDate="2019-11-05T07:11:37.897" LastActivityDate="2019-11-05T14:08:31.587" Title="Finding Dual Objective" Tags="|optimization|linear-programming|duality|dual|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2990" PostTypeId="2" ParentId="2989" CreationDate="2019-11-04T23:06:50.883" Score="8" Body="&lt;p&gt;For each variable, you need to define a constraint in the dual problem and likewise, for each constraint in the primal problem, you will have a dual variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\overline X\times D_1 + \overline Y \times D_2 + E\times D_3\\\text{s.t.}&amp;amp;\quad D_1+D_3 \ge a\\&amp;amp;\quad D_2-\beta D_3 \ge b\\&amp;amp;\quad D_3 = 0\\&amp;amp;\quad D_1 \ge 0\\&amp;amp;\quad D_2 \ge 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After simplifications you will have the following dual problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\overline X \times D_1 + \overline Y \times D_2\\\text{s.t.}&amp;amp;\quad D_1\ge a\\&amp;amp;\quad D_2\ge b\\&amp;amp;\quad D_1\ge 0\\&amp;amp;\quad D_2\ge 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="145" LastEditDate="2019-11-05T14:08:31.587" LastActivityDate="2019-11-05T14:08:31.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2991" PostTypeId="1" CreationDate="2019-11-05T06:01:47.080" Score="8" ViewCount="190" Body="&lt;p&gt;Most formulations of Markov Decision Processes for stochastic inventory models I've come across assume a fixed demand distribution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in my case I have a time series forecast with a non stationary distribution and seasonal behavior. Is it still possible to formulate the problem as an MDP? &lt;/p&gt;&#xA;" OwnerUserId="1315" LastActivityDate="2020-01-21T07:38:56.613" Title="Can I use an MDP for a stochastic inventory model when my demand distribution is non-stationary?" Tags="|optimization|inventory|markov-decision-process|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2992" PostTypeId="2" ParentId="2991" CreationDate="2019-11-05T08:21:14.700" Score="2" Body="&lt;p&gt;You can still use the MDP modeling approach for your system with unknown or non-stationary request distributions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the paper: &lt;strong&gt;&lt;a href=&quot;https://doi.org/10.1016/B978-0-444-63576-1.50012-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;MDP formulation and solution algorithms for inventory management with multiple suppliers and supply and demand uncertainty&lt;/a&gt;&lt;/strong&gt;, is a good start point to deepen your search. Also, look at POMDPs(Partially Observable MDPs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the literature, there are also some applications of learning techniques and MDPs in parallel to manage the uncertainty in the system. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Imani, Mahdi, Seyede Fatemeh Ghoreishi, and Ulisses M. Braga-Neto. &quot;Bayesian control of large MDPs with unknown dynamics in data-poor environments.&quot; Advances in neural information processing systems. 2018.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="39" LastEditorUserId="71" LastEditDate="2020-01-21T07:38:56.613" LastActivityDate="2020-01-21T07:38:56.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2993" PostTypeId="1" CreationDate="2019-11-05T11:49:58.697" Score="9" ViewCount="607" Body="&lt;p&gt;&lt;em&gt;Context:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am dealing with a kind of scheduling problem, in which I have a set of tasks and machines. All tasks must be assigned to machines (not necessary all of them). In addition to that, I must calculate the cost of transferring the product between two machines.&lt;/p&gt;&#xA;&lt;p&gt;For starting, I based my problem in the nurses assignment: &lt;a href=&quot;https://developers.google.com/optimization/scheduling/employee_scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization/scheduling/employee_scheduling&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, I do not know how to obtain the cost of changing machine, it means, take the material from one machine to another.&lt;/p&gt;&#xA;&lt;p&gt;To consider the task assignment with the process sequence I established the binary variable &lt;em&gt;X[w, o, j]&lt;/em&gt;, where &lt;em&gt;w&lt;/em&gt; is the machine, &lt;em&gt;o&lt;/em&gt; is the operation and &lt;em&gt;j&lt;/em&gt; is the position on the process plan.&lt;/p&gt;&#xA;&lt;p&gt;For calculating the cost of changing machine I also established another binary variable T[w1, w2, j-1, j], that states if there is a material transition from one machine to another in two followed positions on the process plan.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Some code&lt;/em&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Create the decision variabl&#xA;X = {}&#xA;for w in range(num_machines):&#xA;    for p in range(num_operations):&#xA;        for j in range(num_operations):&#xA;            X[w, p, j] = model.NewBoolVar('X_{}_{}_{}'.format(w + 1, p + 1, j + 1))&#xA;T = {}&#xA;for w1 in range(num_machines):&#xA;    for w2 in range(num_machines):&#xA;        for j in range(1, num_operations):&#xA;            #if w1 != w2:&#xA;                # T[w1, w2] = model.NewBoolVar(f'T_{w1}_{w2}') # using f-string notation&#xA;            T[w1, w2, j-1, j] = model.NewBoolVar('T_{}_{}_{}_{}'.format(w1 + 1, w2 + 1, j, j + 1))&#xA;&#xA;B = model.NewBoolVar('B')     # declaring an intermediate variable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I've tried to implement some constraints:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1) The number of transitions must be equal the number of operations -1&#xA;  number_transitions = sum(&#xA;        T[(w1, w2, j-1, j)] &#xA;        for w1 in range(num_machines) &#xA;        for w2 in range(num_machines)&#xA;        for j in range(1, num_operations)&#xA;    &#xA;        )&#xA;    model.Add(number_transitions == num_operations - 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So to establish the relation between X and T I tried 2 different ways, but any of them worked.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;1st way:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Implementing B == [X1 + X2]&#xA;for w1 in all_machines:&#xA;    for w2 in all_machines:&#xA;        for p1 in all_operations:&#xA;            for p2 in all_operations:&#xA;                for j in range(1, num_operations):&#xA;                    model.Add(X[w1, p1, j-1] + X[w2, p2, j] == 2).OnlyEnforceIf(B)&#xA;                    model.Add(X[w1, p1, j-1] + X[w2, p2, j] != 2).OnlyEnforceIf(B.Not())&#xA;&#xA;# Reinforcing the value of T&#xA;for w1 in all_machines:&#xA;    for w2 in all_machines:&#xA;        for j in range(1, num_operations):&#xA;            model.Add(T[w1, w2, j-1, j] == 1).OnlyEnforceIf(B)&#xA;            model.Add(T[w1, w2, j-1, j] == 0).OnlyEnforceIf(B.Not())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;em&gt;2nd way&lt;/em&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; for p in all_operations:&#xA;     for w1 in all_machines:&#xA;         for w2 in all_machines:&#xA;             for j in range(1, num_operations):&#xA;                 model.Add((X[w1, p, j-1] + X[w2, p, j]) == T[w1, w2, j-1, j] + 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In both of ways, when I run the code, it returns as result just solutions that do not do transitions between two machines, meaning that these constraints are not being read correctly.&lt;/p&gt;&#xA;&lt;p&gt;I would like to know if there is a better way to solve this problem by establishing the relation between variables X and T.&lt;/p&gt;&#xA;&lt;p&gt;I guess that it could be possible to solve like a TSP, but in my case, not all nodes are visited, but just nodes(machines) required to do a task.&lt;/p&gt;&#xA;&lt;p&gt;Someone know how could I solve this problem?&#xA;Or maybe do you have an example to send me?&lt;/p&gt;&#xA;&lt;p&gt;I asked the same question here: &lt;a href=&quot;https://stackoverflow.com/questions/58709914/tsp-problem-traveller-does-not-visit-all-nodes-google-or-tools&quot;&gt;https://stackoverflow.com/questions/58709914/tsp-problem-traveller-does-not-visit-all-nodes-google-or-tools&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="491" LastEditDate="2022-04-19T13:07:43.533" LastActivityDate="2022-04-19T13:07:43.533" Title="TSP problem: traveller does not visit all nodes - Google OR-tools" Tags="|integer-programming|python|constraint-programming|or-tools|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2994" PostTypeId="2" ParentId="2993" CreationDate="2019-11-05T14:52:57.400" Score="7" Body="&lt;p&gt;(already answered on &lt;a href=&quot;https://stackoverflow.com/questions/58709914/tsp-problem-traveller-does-not-visit-all-nodes-google-or-tools/58713373#58713373&quot;&gt;S.O.&lt;/a&gt; )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should have a look at &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/python/jobshop_ft06_distance_sat.py&quot; rel=&quot;noreferrer&quot;&gt;Jobshop scheduling example with transitions&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, it maintains a graph of direct successor between tasks on the same machine.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2019-11-05T14:52:57.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2995" PostTypeId="2" ParentId="2980" CreationDate="2019-11-05T15:37:25.420" Score="6" Body="&lt;p&gt;For the at-least variant, it seems you can write down this problem as propositional logic and convert your constraints into &lt;a href=&quot;https://en.wikipedia.org/wiki/Conjunctive_normal_form&quot; rel=&quot;noreferrer&quot;&gt;Conjunctive Normal Form&lt;/a&gt;, which gives you the constraints you need only using the edge-variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given sets &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; and variables &lt;span class=&quot;math-container&quot;&gt;$\forall i\in A, j \in B: x_{i,j}$&lt;/span&gt;, the constraints can be written as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\bigwedge_{i,j \in A} \bigvee_{k \in B} (x_{ik} \wedge x_{jk})$$&lt;/span&gt;&#xA;which are not the constraints of the language of Integer Programming. However, these constraints can be converted into the Conjunctive Normal Form to obtain constraints that are easily mapped to IP constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a short Python script that uses the &lt;a href=&quot;https://docs.sympy.org/latest/modules/logic.html&quot; rel=&quot;noreferrer&quot;&gt;boolean algebra module of Sympy&lt;/a&gt; to automate this process. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from sympy.core import Symbol&#xA;from sympy.logic.boolalg import *&#xA;&#xA;# Define the sizes of sets A and B&#xA;a_size = 3&#xA;b_size = 2&#xA;&#xA;# Define sets A and B&#xA;A = [i for i in range(a_size)]&#xA;B = [i for i in range(b_size)]&#xA;&#xA;# Build a dictionary for the variables&#xA;X = {i : {j : Symbol('x{}_{}'.format(i,j)) for j in B} for i in A}&#xA;&#xA;# Construct a logic expression capturing all constraints&#xA;expr = True&#xA;for i in A:&#xA;    for j in A:&#xA;        if i != j:&#xA;            subExpr = False&#xA;            for k in B:&#xA;                subSubExpr = And(X[i][k],X[j][k])&#xA;                subExpr = Or(subExpr, subSubExpr)&#xA;            expr = And(expr, subExpr)&#xA;&#xA;print('The logic expression is:')&#xA;print(expr)&#xA;&#xA;# Convert the logic expression to CNF&#xA;cnf_expr = to_cnf(expr)&#xA;&#xA;print('In CNF the logic expression is:')&#xA;print(cnf_expr)&#xA;&#xA;# Iterate over the 'And' terms of the CNF expression&#xA;for conjunctive_term in cnf_expr.args:&#xA;    # Extract variable names of the terms&#xA;    varnames = [str(a) for a in conjunctive_term.args]&#xA;    # Print the IP-constraint corresponding to the conjunctive term&#xA;    lhs = ' + '.join(varnames)&#xA;    print(lhs + ' &amp;gt;= 1')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Applied to a case where &lt;span class=&quot;math-container&quot;&gt;$|A| = 3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$|B| = 2$&lt;/span&gt;, this gives us the logical constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$((x_{0,0} \wedge x_{1,0}) \vee (x_{0,1} \wedge x_{1,1})) \wedge ((x_{0,0} \wedge x_{2,0}) \vee (x_{0,1} \wedge x_{2,1})) \wedge ((x_{1,0} \wedge x_{2,0}) \vee (x_{1,1} \wedge x_{2,1}))$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;converted to CNF this constraint becomes&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$(x_{0,0} \vee x_{0,1}) \wedge (x_{0,0} \vee x_{1,1}) \wedge (x_{0,0} \vee x_{2,1}) \wedge (x_{0,1} \vee x_{1,0}) \wedge (x_{0,1} \vee x_{2,0}) \wedge (x_{1,0} \vee x_{1,1}) \wedge (x_{1,0} \vee x_{2,1}) \wedge (x_{1,1} \vee x_{2,0}) \wedge (x_{2,0} \vee x_{2,1})$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And converted to linear constraints, this gives us&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;x_{0,0} + x_{0,1} &amp;amp;&amp;gt;= 1 \\&#xA;x_{0,0} + x_{1,1} &amp;amp;&amp;gt;= 1 \\&#xA;x_{0,0} + x_{2,1} &amp;amp;&amp;gt;= 1 \\&#xA;x_{0,1} + x_{1,0} &amp;amp;&amp;gt;= 1 \\&#xA;x_{0,1} + x_{2,0} &amp;amp;&amp;gt;= 1 \\&#xA;x_{1,0} + x_{1,1} &amp;amp;&amp;gt;= 1 \\&#xA;x_{1,0} + x_{2,1} &amp;amp;&amp;gt;= 1 \\&#xA;x_{1,1} + x_{2,0} &amp;amp;&amp;gt;= 1 \\&#xA;x_{2,0} + x_{2,1} &amp;amp;&amp;gt;= 1&#xA;\end{align*}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the number of constraints generated by this approach grows quite rapidly: for &lt;span class=&quot;math-container&quot;&gt;$|A|=3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$|B|$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$3, 4, 5, 6$&lt;/span&gt; the numbers of constraints generated by this script seem to be &lt;span class=&quot;math-container&quot;&gt;$21, 45, 93, 189$&lt;/span&gt;. The &lt;a href=&quot;https://oeis.org/A068156&quot; rel=&quot;noreferrer&quot;&gt;Online Encyclopedia of Integer Sequences&lt;/a&gt; seems to contain some information on this sequence which suggest some binomial-related growth, but I did not analyze this in more detail. It may thus be necessary to figure out the actual structure of the generated constraints and use a cutting plane method to solve larger instances in practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I do think does avoid the need to generate the triplet variables for the at-least variant.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastActivityDate="2019-11-05T15:37:25.420" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2996" PostTypeId="1" AcceptedAnswerId="3014" CreationDate="2019-11-05T16:49:24.260" Score="10" ViewCount="226" Body="&lt;p&gt;Suppose that I have access to an optimal non-degenerate extreme point of an LP. I need to find some &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-optimal extreme points. That is, a point &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c'x \le z^{*} + \epsilon$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to do this is to add this constraint to the problem, replace the problem with a different objective function, and re-optimize. Each iteration will either generate a new extreme point, or generate a solution already existed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to do this systematically in Cplex? That is, retrieve the optimal basis, do one or more pivoting and get to a new extreme point, and keep the solution if is satisfies &lt;span class=&quot;math-container&quot;&gt;$c'x \le z^{*} + \epsilon$&lt;/span&gt;. To make the search easier, neighboring extreme points that are one pivot away are fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated. I am using C++ Concert Technology. &lt;/p&gt;&#xA;" OwnerUserId="580" LastEditorUserId="580" LastEditDate="2019-11-06T15:56:01.017" LastActivityDate="2019-11-10T12:24:23.200" Title="How to access neighboring extreme points to an optimal extreme point of an LP?" Tags="|linear-programming|cplex|simplex|dual-simplex|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="2997" PostTypeId="2" ParentId="2980" CreationDate="2019-11-05T21:01:01.913" Score="1" Body="&lt;p&gt;(edit: now I read more carefully, I see Rob Pratt already alluded to this approach, but might as well expand on it)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is the lazy constraint method: solve the problem without bothering to implement the constraint, check whether the constraint is violated, and if it is add a new constraint that prevents those particular violations and repeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, suppose I get a solution where &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_j$&lt;/span&gt; have no common connection. Let &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; be the set of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; connected to &lt;span class=&quot;math-container&quot;&gt;$b_k$&lt;/span&gt; in this particular (invalid) solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that particular &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, I can then add a constraint: if &lt;span class=&quot;math-container&quot;&gt;$x_{i,k}=1 \forall {k\in S}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{i,k}=0 \forall {k\notin S}$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\sum_{k\in S} x_{j,k} \ge 1$&lt;/span&gt;. This is very easily linearised.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Iterating on this will eventually give a solution that satisfies the &quot;&lt;span class=&quot;math-container&quot;&gt;$\ge 1$&lt;/span&gt;&quot; condition; a &quot;&lt;span class=&quot;math-container&quot;&gt;$\le 1$&lt;/span&gt;&quot; condition can be handled in a similar way if desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whether this is an efficient way to do it depends on other aspects of the problem. If the other constraints and objective/s are such that solutions will &lt;em&gt;mostly&lt;/em&gt; satisfy the condition even without being specifically constrained to do so, with only a few violations, then this might be a relatively painless way to deal with those exceptions. It might be useful since it avoids needing to create &lt;span class=&quot;math-container&quot;&gt;$O(n^3)$&lt;/span&gt; extra DVs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;OTOH, if there are a &lt;em&gt;lot&lt;/em&gt; of violations of this rule, then you may end up iterating for a long time. Especially if solution time per iteration is long, lazy constraints might not be your best bet.&lt;/p&gt;&#xA;" OwnerUserId="546" LastEditorUserId="546" LastEditDate="2019-11-06T00:00:35.683" LastActivityDate="2019-11-06T00:00:35.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2998" PostTypeId="2" ParentId="2987" CreationDate="2019-11-05T23:19:51.257" Score="7" Body="&lt;p&gt;Two stage k-means is discussed in:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.researchgate.net/publication/224095891_Balanced_K-Means_Algorithm_for_Partitioning_Areas_in_Large-Scale_Vehicle_Routing_Problem&quot; rel=&quot;noreferrer&quot;&gt;Balanced K-Means Algorithm for Partitioning Areas in Large-Scale Vehicle Routing Problem&lt;/a&gt;&quot; (Dec 2009), by Ruhan He, Weibin Xu, Jiaxia Sun, and Bingqiao Zu&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.researchgate.net/publication/316160522_Solving_the_Heterogeneous_Capacitated_Vehicle_Routing_Problem_using_K-Means_Clustering_and_Valid_Inequalities&quot; rel=&quot;noreferrer&quot;&gt;Solving the Heterogeneous Capacitated Vehicle Routing Problem using K-Means Clustering and Valid Inequalities&lt;/a&gt;&quot; (Apr 2017), by Noha A. Mostafa and Amr Eltawil&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second paper presents a rather simple solution on page 6, simply assign each truck by k-means and where one truck has more customers than the other calculate the customer's distance from the centroid and move the nearest customers to the less full truck, thus balancing the load (or weight / delivery time / packages, etc.).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;In that way, it is possible to find the customers on the borders of different clusters and transfer them to the cluster with fewer customers, so that the clusters are balanced in terms of the number of customers in each cluster, the difference in the number of customers between any two clusters has a threshold θ. After performing the clustering, the MIP model presented in section 3.1 is solved for clusters instead of customers to assign vehicles to clusters.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;&lt;a href=&quot;https://www.researchgate.net/publication/258159609_Modeling_and_Solving_the_Clustered_Capacitated_Vehicle_Routing_Problem&quot; rel=&quot;noreferrer&quot;&gt;Modeling and Solving the Clustered Capacitated Vehicle Routing&#xA;Problem&lt;/a&gt;&quot; (Feb 2013), by Christopher Expósito Izquierdo, André Rossi, and Marc Sevaux&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This next paper explains how to divide a large problem into sub-problems.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;&lt;strong&gt;Conclusions and Further Research&lt;/strong&gt;&lt;br&gt;&#xA;  This work introduces the Clustered Capacitated Vehicle Routing Problem (CCVRP), a new logistic problem for parcel delivery and courier services companies where the demand of a large number of customers organized in clusters have to be fulﬁlled.&#xA;  This problem presents the clustering constraints, in such a way that, the delivery trucks have to serve all the customers belonging to the same cluster in a row.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;An approximate two-level solution approach is proposed with the goal of solving the CCVRP. It is based on a decomposition of the CCVRP into two general subproblems. The ﬁrst one pursues to deﬁne the number and composition of the routes aimed at serving the clusters and the latter is aimed at determining the visiting order of the customers within each cluster. This approach allows to use&#xA;  speciﬁc optimization techniques for both subproblems. For this purpose, several methods have been proposed.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The computational experiments have allowed to check that using the adaptation of the Lin-Kernighan heuristic for the LRP is highly competitive in a wide range of scenarios. Similarly, exact&#xA;  methods require large computational times in order to obtain high-quality solutions for the CCVRP and, therefore, they can be dismissed in real environments.&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;By being able to distribute the work equally between the trucks and also divide the complexity evenly (or at least to ease solving) between the parts of the solution one obtains workload balance of both the vehicles and the solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another point is that simply filling the &quot;biggest idle vehicle&quot; to ~80% isn't efficient. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vehicles should be filled with the fewest orders (delivery points) so the vehicle is mostly full for the longest period of time. For example, if a large vehicle is filled 100% with two orders then half the capacity during the time getting to the second location is unused; if both locations were nearby then the truck would be half empty for less time. An opposite example being a small vehicle consisting of only separate one liter orders, at least when it is half full less fuel (and carrying capacity) is lost during the second half of the routes.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="123" LastEditDate="2019-11-06T07:21:41.837" LastActivityDate="2019-11-06T07:21:41.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2999" PostTypeId="1" CreationDate="2019-11-05T23:20:27.797" Score="6" ViewCount="449" Body="&lt;p&gt;I have the following optimization problem which is a MILP. I can solve it with a MILP solver. This one I posted here &lt;a href=&quot;https://or.stackexchange.com/questions/2964/is-there-a-heuristic-approach-to-the-milp-problem&quot;&gt;Is there a heuristic approach to the MILP problem?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since I have an additional but very important constraint, I am putting it as a new post. I am looking for a heuristic approach to solve this problem. Any Hint?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{2}\min_t&amp;amp;\quad t\\\text{s.t.}&amp;amp;\quad d_{c}-t\le \sum_{n=1}^{N} B_{n,c}x_{n}\le d_{c}+t,\quad&amp;amp;\forall c\in\{1,2,\cdots,C\}\\&amp;amp;\quad\sum_{n=1}^{N} x_n = M\\&#xA;&amp;amp;\quad x_n\le M y_n, \quad\forall n\\&#xA;&amp;amp;\quad\sum_{n=1}^N y_n \le 3&#xA;\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h2&gt;&lt;strong&gt;VERY IMPORTANT&lt;/strong&gt;&lt;/h2&gt;&#xA;&lt;p&gt;As this a part of another problem, I found that this is not serving what I actually needed. I want to put one more constraint. There can be only a given number of non-zero &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt;, for example, for the previous example, let say, we can have a maximum &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; non-zero &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt;s.&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is a binary matrix of size &lt;span class=&quot;math-container&quot;&gt;$N\times C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is a known vector of the positive numbers of size &lt;span class=&quot;math-container&quot;&gt;$1\times C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a known parameter&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; is an optimization variable (integer variable, &lt;span class=&quot;math-container&quot;&gt;$x_n\ge 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_n\in\{0,1,2,3,\cdots,M\}$&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_n$&lt;/span&gt; is a binary variable&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is also an optimization variable (integer/continuous)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;@prubin has suggested a reformulation of the problem as&lt;/p&gt;&#xA;&lt;p&gt;If we set &lt;span class=&quot;math-container&quot;&gt;$S_c = \{n : B_{n,c}=1\}$&lt;/span&gt;, we can rewrite the problem as &lt;span class=&quot;math-container&quot;&gt;$$\begin{align*}&#xA;\min_{t} &amp;amp; \quad t\\&#xA;\text{s.t.} &amp;amp; \quad\left|\sum_{n\in S_{c}}x_{n}-d_{c}\right|\le t,\quad\forall c\in\{1,2,\cdots,C\}\\&#xA; &amp;amp; \quad\sum_{n=1}^{N}x_{n}=M.&#xA;\end{align*}$$&lt;/span&gt;A simple greedy heuristic is to start with &lt;span class=&quot;math-container&quot;&gt;$x_n=0\,\forall n$&lt;/span&gt; and, in each iteration, bump one of the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables up by 1, selecting the &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; that most improves (or least degrades) &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, until the equality constraint is satisfied.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-11-07T07:18:41.790" Title="A heuristic approach to solve a MILP problem?" Tags="|optimization|mixed-integer-programming|integer-programming|metaheuristics|heuristics|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3000" PostTypeId="1" CreationDate="2019-11-06T00:27:46.910" Score="7" ViewCount="496" Body="&lt;h2&gt;Problem summary :&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A complete problem description is given &lt;a href=&quot;https://storage.googleapis.com/coding-competitions.appspot.com/HC/2014/hashcode2014_final_task.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Given a description of city streets and a number of Street View cars (cars that captures pictures as they move around) available for a period of time, your task is to schedule the movement of the cars to maximize the total length of city streets that were traversed at least once.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The city is represented by a graph, the nodes of which represent city junctions and are connected with edges representing the streets.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Streets are modeled as straight segments connecting two junctions. Each street has three properties: direction length( the distance in meters that a StreetView car covers while moving through the street) and the time in seconds that a StreetView car takes to traverse the street.&#xA;  Each pair of junctions is connected by at most one street. Each street connects two different junctions. The graph is not necessarily planar (due to bridges and tunnels).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;We have a fleet of &lt;span class=&quot;math-container&quot;&gt;$N=8$&lt;/span&gt; cars, all located at the junction &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; at the beginning of the game. All car movement scheduled in the itinerary has to complete in &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; seconds (or less) ­ a car cannot be in transit when the time runs out.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The objective function is the total length of all streets that were traversed by at least one car of their fleet at least once. Traversing a street that was already traversed multiple times (including traversing a&#xA;  bi­-directional street in the opposite direction) does not increase the objective function.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is a &lt;strong&gt;single&lt;/strong&gt; data file that is available &lt;a href=&quot;https://github.com/antgus/hashcode2014/blob/master/paris_54000.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.(The number of junctions is &lt;span class=&quot;math-container&quot;&gt;$11348$&lt;/span&gt; and the number of edges is &lt;span class=&quot;math-container&quot;&gt;$2\,\times$&lt;/span&gt; number of streets (since I'm orienting them) which is equal to &lt;span class=&quot;math-container&quot;&gt;$2\times17958$&lt;/span&gt;) &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Model for a single car :&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The aim is to find a formulation that can lead to a solution using a commercial/open source solver.&lt;/strong&gt; My idea is to write a model for a single car by taking &lt;span class=&quot;math-container&quot;&gt;$T := 8T$&lt;/span&gt;, then I need to divide the path obtained into 8 different paths for the 8 cars.  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$G= (V,E)$&lt;/span&gt; is a graph where &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is the set of junctions in the city and &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is the set of &lt;em&gt;oriented&lt;/em&gt; edges (I redefine it by setting &lt;span class=&quot;math-container&quot;&gt;$t_e = \infty$&lt;/span&gt; if it's one way, it's not oriented in the statement)&lt;/li&gt;&#xA;&lt;li&gt;for every &lt;span class=&quot;math-container&quot;&gt;$e = (u,v) \in E$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t_e$&lt;/span&gt; is the cost(time) of the road (&lt;span class=&quot;math-container&quot;&gt;$t_e = \infty$&lt;/span&gt; if it's one-way) and &lt;span class=&quot;math-container&quot;&gt;$l_e$&lt;/span&gt; is its length. &lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; time limit for each car&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$v_s$&lt;/span&gt; the starting junction &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Variables:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall v \in V, f_v := 1$&lt;/span&gt; if the car stops at &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise. &lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall e \in E, x_e :=1$&lt;/span&gt; if the road &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; is taken in picture and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall e \in E, y_e$&lt;/span&gt; indicates the number of times of passing this edge&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Constraints for a single car:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall e = (u,v) \in E, x_e \leq y_e$&lt;/span&gt;  (to take a picture we must pass by the street !)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall e =(u,v) \in E, x_{(u,v)} + x_{(v,u)} \leq 1$&lt;/span&gt; &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{e \in E} y_e t_e \leq T$&lt;/span&gt;  (meaning that the path should be finished within &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall v_i \in V, v_i \neq v_s,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;\begin{align}\sum\limits_{\,\,\,e \in E\\ e=(u,v_i)} y_e &amp;amp;= \sum\limits_{\,\,\,e' \in E, \\e' = (v_i,u)} y_{e'} + f_{v_i}\\\sum_{\,\,\,e \in E \\ e =(v_s,v)} y_e &amp;amp;= \sum_{\,\,\,e' \in E \\ e'=(v,v_s)} y_{e'} + f_{v_s} + 1\end{align}&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{v \in V} f_v = 1$&lt;/span&gt; (a unique end) &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The two last constraints but one guarantee that there is no &quot;jumping&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Objective function:&lt;/strong&gt; &#xA;&lt;span class=&quot;math-container&quot;&gt;$\max \sum\limits_{e \in E} x_e l_e$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Questions&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have three questions: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If I set &lt;span class=&quot;math-container&quot;&gt;$T = 8T$&lt;/span&gt;, and implement the model, it will give one big path. How to split it to find a path for each car?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The number of junctions is &lt;span class=&quot;math-container&quot;&gt;$11348$&lt;/span&gt; and the number of edges is &lt;span class=&quot;math-container&quot;&gt;$2\,\times$&lt;/span&gt; number of streets (since I'm orienting them) which is equal to &lt;span class=&quot;math-container&quot;&gt;$2\times17958$&lt;/span&gt;. Someone told me that there is a lot of variables and it can't be solved with MIP solver. Do you think it's true? what are the limits of MIP solvers?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a way to make the model better (from a computational point of view)?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1188" LastEditorUserId="858" LastEditDate="2019-11-10T22:37:08.453" LastActivityDate="2019-11-12T23:26:17.643" Title="Solving a VRP (google hashcode competition) using an off-the-shelf solver" Tags="|modeling|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3001" PostTypeId="2" ParentId="2999" CreationDate="2019-11-06T12:37:51.750" Score="5" Body="&lt;p&gt;Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$y_n$&lt;/span&gt; and constraints &lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_n &amp;amp;\le M y_n &amp;amp;&amp;amp;\text{for all $n$}\\&#xA;\sum_n y_n &amp;amp;\le 3&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-11-06T12:37:51.750" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3002" PostTypeId="2" ParentId="2999" CreationDate="2019-11-06T22:55:18.240" Score="1" Body="&lt;p&gt;Here is a modification of the bumping heuristic, assuming that you are limited to using &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; of the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables (so &lt;span class=&quot;math-container&quot;&gt;$K=3$&lt;/span&gt; in your example):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Select &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; distinct values of the index &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; randomly.&lt;/li&gt;&#xA;&lt;li&gt;Apply the bumping heuristic, but limit it to bumping those &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; variables. Note that the heuristic may not bump all of them.&lt;/li&gt;&#xA;&lt;li&gt;Record the new solution if it beats the previous incumbent.&lt;/li&gt;&#xA;&lt;li&gt;Repeat &lt;em&gt;ad nauseum&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-11-06T22:55:18.240" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3003" PostTypeId="1" AcceptedAnswerId="3005" CreationDate="2019-11-07T19:18:37.427" Score="7" ViewCount="199" Body="&lt;p&gt;I'm trying to approximately solve a 3D container loading problem. Is it possible to use 2D bin packing algorithms? If so, how do we make the transformation? What are the conditions needed to make the transformation?&lt;/p&gt;&#xA;" OwnerUserId="2663" LastEditorUserId="123" LastEditDate="2019-11-07T19:53:56.877" LastActivityDate="2019-11-08T07:30:44.980" Title="How to convert 3D bin packing problem to 2D bin packing approximation?" Tags="|combinatorial-optimization|algorithms|heuristics|knapsack|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3004" PostTypeId="2" ParentId="291" CreationDate="2019-11-07T21:33:47.137" Score="4" Body="&lt;p&gt;Column generation is widely used in airline applications. For instance : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The aircraft routing problem.&#xA;The crew pairing problem.&#xA;The crew rostering problem.&lt;/p&gt;&#xA;" OwnerUserId="2664" LastActivityDate="2019-11-07T21:33:47.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3005" PostTypeId="2" ParentId="3003" CreationDate="2019-11-07T22:24:58.487" Score="3" Body="&lt;p&gt;According to the attached file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;-dimensional bin packing problem (&lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;-BPP) there are many large boxes&#xA;of equal sizes, which are called bins, and the objective is to pack all &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; items into a minimum number of bins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can translate any &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;-BPP instance into an instance of &lt;span class=&quot;math-container&quot;&gt;$(m+1)$&lt;/span&gt;-SPP (strip packing problem), where the additional &lt;span class=&quot;math-container&quot;&gt;$(m+1)$&lt;/span&gt;st direction (the height of the strip)&#xA;is used to count bins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope, &lt;a href=&quot;https://www.dropbox.com/s/qgxhtjtuk60u1u5/Multidimensional%20Orthogonal%20Packing.pdf?dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; link would be useful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2019-11-08T07:30:44.980" LastActivityDate="2019-11-08T07:30:44.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3006" PostTypeId="2" ParentId="291" CreationDate="2019-11-08T08:30:07.870" Score="5" Body="&lt;p&gt;There are also several papers on column generation for location problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/mnsc.1050.0410?casa_token=0Q40p3gy9XwAAAAA:PN8Mky-W_T98MF_905MkILy4j0CbcJixpW7q_mD4oGl6OMS5kFXonXweYQnbmYFgtT2039hLf5k&quot; rel=&quot;nofollow noreferrer&quot;&gt;Capacitated facility location problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://link.springer.com/article/10.1057/palgrave.jors.2601353&quot; rel=&quot;nofollow noreferrer&quot;&gt;Single source capacitated facility location problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://link.springer.com/content/pdf/10.1007%2Fs10107-005-0700-6.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median problem&lt;/a&gt; (this method works on the original variables, and the columns are then generated on an &quot;as needed&quot; basis)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="278" LastEditorUserId="36" LastEditDate="2019-11-08T14:15:32.150" LastActivityDate="2019-11-08T14:15:32.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3008" PostTypeId="1" AcceptedAnswerId="3009" CreationDate="2019-11-09T12:08:46.267" Score="9" ViewCount="536" Body="&lt;p&gt;I have a question on the Equipment Replacement Problem, where the following is taken (with some syntactic modifications) from &lt;a href=&quot;https://www.coursehero.com/file/9386204/DP1-Shortest-Path-Alpern/&quot; rel=&quot;noreferrer&quot;&gt;IB2070 Mathematical Programming II (MP2)&lt;/a&gt;, Warwick Business School.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Equipment Replacement Problem&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;\begin{array}{cc}\hline\text{Age of Car}&amp;amp;\text{Annual Maintenance}&amp;amp;\text{Trade-in Price at the}\\&amp;amp;\text{Cost}&amp;amp;\text{end of the period}\\\hline0&amp;amp;{\it\unicode{xA3}}2,000&amp;amp;{\it\unicode{xA3}}7,000\\1&amp;amp;{\it\unicode{xA3}}4,000&amp;amp;{\it\unicode{xA3}}6,000\\2&amp;amp;{\it\unicode{xA3}}5,000&amp;amp;{\it\unicode{xA3}}2,000\\3&amp;amp;{\it\unicode{xA3}}9,000&amp;amp;{\it\unicode{xA3}}1,000\\4&amp;amp;12,000&amp;amp;0\\\hline\end{array}&lt;/span&gt; When should I trade in my car?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Arc Length&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;\begin{align}c_{i,j}=&amp;amp;\,\,\text{maintenance cost during years}\,\,i,i+1,\cdots,j-1\\&amp;amp;+\text{cost of purchasing a new car at year}\,\,i\\&amp;amp;-\text{trade-in value received at year}\,\,j\\\\c_{1,2}=&amp;amp;\,\,{\it\unicode{xA3}}2000+{\it\unicode{xA3}}12000-{\it\unicode{xA3}}7000={\it\unicode{xA3}}7000\\\\c_{2,3}=&amp;amp;\,\,{\it\unicode{xA3}}2000+{\it\unicode{xA3}}4000+{\it\unicode{xA3}}12000-{\it\unicode{xA3}}6000={\it\unicode{xA3}}12000\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Shortest Path Problem&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;\begin{array}{|c|c|}\hline c_{i,j}&amp;amp;1&amp;amp;2&amp;amp;3&amp;amp;4&amp;amp;5&amp;amp;6\\\hline1&amp;amp;\phantom{25pt}&amp;amp;7,000&amp;amp;12,000&amp;amp;21,000&amp;amp;31,000&amp;amp;44,000\\\hline2&amp;amp;&amp;amp;&amp;amp;7,000&amp;amp;12,000&amp;amp;21,000&amp;amp;31,000\\\hline3&amp;amp;&amp;amp;&amp;amp;&amp;amp;7,000&amp;amp;12,000&amp;amp;21,000\\\hline4&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;7,000&amp;amp;12,000\\\hline5&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;7,000\\\hline\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Could somebody please explain how in the last diagram, for &lt;span class=&quot;math-container&quot;&gt;$c_{2,3}$&lt;/span&gt; they get  &lt;span class=&quot;math-container&quot;&gt;$7,000$&lt;/span&gt;? I only understand how they get &lt;span class=&quot;math-container&quot;&gt;$c_{1,i}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,6$&lt;/span&gt; but that's all I can understand. If someone explains to me how they get it for &lt;span class=&quot;math-container&quot;&gt;$c_{2,3}$&lt;/span&gt; then I'll be able to understand the whole of it.&lt;/p&gt;&#xA;" OwnerUserId="1117" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-11-09T16:00:20.150" Title="Equipment replacement problem" Tags="|combinatorial-optimization|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3009" PostTypeId="2" ParentId="3008" CreationDate="2019-11-09T14:20:49.597" Score="8" Body="&lt;p&gt;It is the same calculation as &lt;span class=&quot;math-container&quot;&gt;$c_{1,2}$&lt;/span&gt;. The purchase price is £12,000 no matter when that purchase is made, and the rest of the costs depend on age of the car (number of years since purchase), not the actual year. So each row in the final table is the same as the previous row shifted one place to the right.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-11-09T14:20:49.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3010" PostTypeId="2" ParentId="3008" CreationDate="2019-11-09T14:50:59.257" Score="5" Body="&lt;p&gt;The constant car price means that &lt;span class=&quot;math-container&quot;&gt;$$c_{i,j}=12\,000-t_j+\sum_i^{j-1}m_i$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt; denotes the trade-in price on year &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m_i$&lt;/span&gt; the maintenance cost on year &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Thus &lt;span class=&quot;math-container&quot;&gt;$$c_{i,i+1}=12\,000-t_{i+1}+m_i\tag1.$$&lt;/span&gt; However, all indices can be shifted up or down (as @RobPratt mentions) as the age of the car from year &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to year &lt;span class=&quot;math-container&quot;&gt;$i+1$&lt;/span&gt; is constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, shifting &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; down by &lt;span class=&quot;math-container&quot;&gt;$i-1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i-2$&lt;/span&gt; yields &lt;span class=&quot;math-container&quot;&gt;$c_{1,2}=c_{2,3}$&lt;/span&gt; respectively.&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-11-09T14:50:59.257" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3011" PostTypeId="2" ParentId="3008" CreationDate="2019-11-09T15:05:59.093" Score="4" Body="&lt;p&gt;In addition to @Rob Pratt's answer, consider the following table which helps you understand the shifts in each row of the matrix in the question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{cccccc}\hline&#xA;              i &amp;amp;  j &amp;amp; j-i &amp;amp; \rm{purchase} &amp;amp; \text{trade-in} &amp;amp; \rm{maintenance} &amp;amp; \rm{total}\\ \hline&#xA;              1 &amp;amp;  2 &amp;amp;   1 &amp;amp;   12000 &amp;amp;   7000 &amp;amp;   2000  &amp;amp;   7000   \\&#xA;              2 &amp;amp;  3 &amp;amp;   1 &amp;amp;   12000 &amp;amp;   7000 &amp;amp;   2000  &amp;amp;   7000   \\&#xA;              3 &amp;amp;  4 &amp;amp;   1 &amp;amp;   12000 &amp;amp;   7000 &amp;amp;   2000  &amp;amp;   7000   \\&#xA;              4 &amp;amp;  5 &amp;amp;   1 &amp;amp;   12000 &amp;amp;   7000 &amp;amp;   2000  &amp;amp;   7000   \\&#xA;              5 &amp;amp;  6 &amp;amp;   1 &amp;amp;   12000 &amp;amp;   7000 &amp;amp;   2000  &amp;amp;   7000   \\ \hline&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This table summarizes the calculations for &lt;span class=&quot;math-container&quot;&gt;$c_{12},c_{23},c_{34},c_{45},c_{56}$&lt;/span&gt; in each of its rows. All the costs are the same because the age or the value of &lt;span class=&quot;math-container&quot;&gt;$j-i$&lt;/span&gt; is the same for all rows. Three other tables like the one I mentioned, this time with &lt;span class=&quot;math-container&quot;&gt;$j-i=2,3,4$&lt;/span&gt; can be constructed to cover whole cost table in the question. This problem can also be solved by using &lt;em&gt;Dynamic Programming&lt;/em&gt;. &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-11-09T15:11:31.960" LastActivityDate="2019-11-09T15:11:31.960" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3012" PostTypeId="1" CreationDate="2019-11-09T16:28:00.113" Score="8" ViewCount="281" Body="&lt;p&gt;In finance, they have lots of books and sources for interview questions. Especially, 'brainteasers' are pretty famous. A brainteaser can be logical deduction questions or questions like 'when does the hour and minute hands of a wall-clock are exactly at the same place after 3 PM'. There are also questions dedicated to the finance field.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is the following: how kind of questions can we ask for OR &amp;amp; Analytics jobs? Of course, it can not be very detailed mathematical questions since the expertise in OR can vary from financial modeling to discrete optimization. Hence, I am thinking about a good way to measure the analytical thinking skills of applicants for the OR &amp;amp; Analytics fields. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence, I will be happy to see whether:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We have good sources for such questions&lt;/li&gt;&#xA;&lt;li&gt;We can give some good examples here showing what kind of skills does this question measure&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Let me list some examples. An OR &amp;amp; Analytics applicant needs to be really good at induction, so without going in  much detail we can ask:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use induction to show that&#xA;  &lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;    \sum_{k=1}^n k^3 = \frac{n^2 (n+1)^2}{4}.&#xA;\end{align*}&lt;/span&gt; &#xA;  Hint: For induction you need to define a base case, .... &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Or, even to measure mathematical modeling skills we can again stay in the high school level and ask questions like:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;George is 1 year more than twice Luke's age. 3 years from now, Maggy will be 27 less than twice George's age. 4 years ago, Maggy was 1 year less than 3 times Luke's age. How old will Maggy be 3 years from now?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Or, with a very simple question, we can measure the knowledge of functions and calculus with:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On what interval(s) is the function &lt;span class=&quot;math-container&quot;&gt;$f(x) = x^3 e^x$&lt;/span&gt; increasing?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: I am aware that there is a similar discussion &lt;a href=&quot;https://or.stackexchange.com/questions/1040/interview-questions-and-answers&quot;&gt;here&lt;/a&gt;, but I think it can be nice to give some problems here as a resource for applicants and application receivers.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="123" LastEditDate="2019-11-10T08:48:43.780" LastActivityDate="2020-11-18T15:16:21.480" Title="O.R. Brainteasers" Tags="|job-market|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3014" PostTypeId="2" ParentId="2996" CreationDate="2019-11-10T12:24:23.200" Score="3" Body="&lt;p&gt;There is no way to do this with CPLEX directly as far as I know, but you can use CPLEX's C++ API to code the iterative process yourself. The API allows the user to build/modify the model in C++ as well as to retrieve solutions, so you can retrieve the solution in code, add the new constraint, and resolve. You can also use the solution pool to get other vertices, but there is no guarantee that they will be close to your current optimum (I guess that depends on our definition of &quot;neighbouring&quot;).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-11-10T12:24:23.200" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3015" PostTypeId="1" CreationDate="2019-11-10T18:41:02.207" Score="9" ViewCount="4511" Body="&lt;p&gt;My original problem is an MILP. I make it an LP by relaxing the integer variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please comment on the complexity, solvability and optimality of MILP and LP problems, in general?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a guarantee that a given MILP can be solved optimally?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="123" LastEditDate="2019-11-10T20:02:01.183" LastActivityDate="2019-11-11T12:31:21.990" Title="Complexity of LP and MILP Problems?" Tags="|mixed-integer-programming|linear-programming|computational-complexity|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3016" PostTypeId="2" ParentId="3015" CreationDate="2019-11-10T20:07:49.457" Score="11" Body="&lt;p&gt;LP can be solved in polynomial time (both in theory and in practice by primal-dual interior-point methods.)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;MILP is NP-Hard, so it can't be solved in polynomial time unless P=NP.  However, MILP can certainly be solved in exponential time by branch and bound.  &lt;/p&gt;&#xA;" OwnerUserId="103" LastActivityDate="2019-11-10T20:07:49.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3017" PostTypeId="2" ParentId="3000" CreationDate="2019-11-10T21:52:41.713" Score="9" Body="&lt;p&gt;This is the distance constrained multi-depot open arc routing problem. I doubt you will find any paper on this particular problem. You can use VRPSolver to solve it (vrpsolver.math.u-bordeaux.fr). However, the instance size is out of reach of this solver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;MIP solvers are bad for solving vehicle routing problems, even for much smaller instances (50-100 nodes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some heuristic solvers which can be used for vehicle routing problems, for example LocalSolver. You will probably need to transform arc routing problem into more classic node routing. You can check this paper for comparative analysis of approaches how to do it: &lt;a href=&quot;https://doi.org/10.1287/trsc.2019.0900&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1287/trsc.2019.0900&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not think you will get a good heuristic solution based on your one vehicle model. &lt;/p&gt;&#xA;" OwnerUserId="835" LastEditorUserId="835" LastEditDate="2019-11-10T22:00:58.373" LastActivityDate="2019-11-10T22:00:58.373" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3018" PostTypeId="1" CreationDate="2019-11-11T00:37:56.720" Score="10" ViewCount="1846" Body="&lt;p&gt;I have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; objects that need to be divided among &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; groups. Each group must receive at least &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; objects. In addition, the percentage of objects in group &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; should be as close as possible to &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i=1}^k p_i = 1$&lt;/span&gt;. I was thinking of formulating this as an integer programming problem with the number of objects in group &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; denoted by &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt;. The problem then becomes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum\limits_{i=1}^k\left(\frac{h_i}{n}-p_i\right)^2\\\text{s.t.}&amp;amp;\quad h_i \geq 5\\&amp;amp;\quad\sum_i h_i = n\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And of course, all the &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt; are integers. I was looking at solving this in Python since the production environment I need to deploy to has this setup. I looked into integer programming for Python but can only find linear programs so far. Any pointers?&lt;/p&gt;&#xA;" OwnerUserId="2436" LastEditorUserId="123" LastEditDate="2019-11-11T07:46:14.523" LastActivityDate="2019-11-22T15:08:01.327" Title="Integer programming problem with simple quadratic objective function in Python" Tags="|optimization|linearization|python|quadratic-programming|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3019" PostTypeId="2" ParentId="3018" CreationDate="2019-11-11T03:29:39.463" Score="5" Body="&lt;p&gt;I finally found &lt;code&gt;cvxpy&lt;/code&gt;, which seems to work for me. Not sure if it has integer programming, but for now I just used non-integer and then split the fractional parts back among the solution array. Not ideal, but better than nothing. Code below. If someone has a solution that involves actual integer programming using an open-source library, please post an answer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import cvxpy as cp&#xA;import numpy as np&#xA;&#xA;## Number of objects.&#xA;n=50&#xA;&#xA;## Required proportions (array length should be n and sum to 1).&#xA;p = np.array([.4,.2,.15,.1,.05,.05,.025,.025])&#xA;&#xA;x = cp.Variable(len(p))&#xA;constraints = [4 &amp;lt;= x, x &amp;lt;= n, sum(x) == n]&#xA;objective = cp.Minimize(cp.sum_squares(x/n - p))&#xA;problm = cp.Problem(objective, constraints)&#xA;&#xA;res = problm.solve()&#xA;&#xA;vals = x.value // 1&#xA;excess = int(sum(x.value % 1))&#xA;&#xA;excess_vals_unif = np.ones(len(p))* excess//len(p)&#xA;&#xA;excess_vals_nonunif = np.concatenate((np.ones(excess % len(p)),\&#xA;                np.zeros(len(p)-excess%len(p)))\&#xA;                ,axis=0)&#xA;&#xA;final_vals = vals + excess_vals_unif + excess_vals_nonunif&#xA;print(final_vals)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2436" LastEditorUserId="36" LastEditDate="2019-11-11T06:23:54.267" LastActivityDate="2019-11-11T06:23:54.267" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3020" PostTypeId="2" ParentId="3015" CreationDate="2019-11-11T12:31:21.990" Score="5" Body="&lt;p&gt;MIP are NP-hard, meaning that  in general we don't know of a polynomial-time algorithm for solving MIPs. Note that this statement does not mean that &quot;every MIP is NP-hard&quot; but &quot;solving &lt;em&gt;every&lt;/em&gt; MIP in polynomial time is NP-hard&quot;. Indeed, there are special cases of MIP problems for which  we do have fast algorithms e.g. MIP for which the constraint matrix is TUM (totally unimodular matrix), then it can be relaxed into the linear program, which can be solved in polynomial time.&lt;/p&gt;&#xA;" OwnerUserId="858" LastActivityDate="2019-11-11T12:31:21.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3021" PostTypeId="1" AcceptedAnswerId="3240" CreationDate="2019-11-11T12:45:41.613" Score="5" ViewCount="1518" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;A library must build shelving to shelve &lt;span class=&quot;math-container&quot;&gt;$200$&lt;/span&gt; 4-inch high books, &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt; 8-inch high books, and &lt;span class=&quot;math-container&quot;&gt;$80$&lt;/span&gt; 12-inch high books. Each book is 0.5-inch thick.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The library has several ways to store books. For example, an 8-inch high shelf may be built to store all books of height no more than &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; inches, and a 12-inch high shelf may be built for the 12-inch high books. Alternatively, a 12-inch high shelf may be built to store all books. The library believes it costs &lt;span class=&quot;math-container&quot;&gt;${\it£}2300$&lt;/span&gt; to build a shelf and that a cost of &lt;span class=&quot;math-container&quot;&gt;${\it£}5$&lt;/span&gt; per square inch is incurred for book storage. (Assume that the area required to store a book is given by the height&#xA;  of storage area times book thickness.)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Formulate and solve a shortest path problem that could be used to help the library determine how to shelve the books at minimum cost. (Hint: Have nodes &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt;, with being the total cost of shelving all books of height &lt;span class=&quot;math-container&quot;&gt;$&amp;gt; i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\le j$&lt;/span&gt; on a single shelf.) &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I went on with the hint, and I discovered that the cost is minimised when we build only one shelf which is for all books (a 12-inch shelf). So the cost would be the cost of shelving all the 4-inch, 8-inch and 12-inch books) plus that of building the shelve which is &lt;span class=&quot;math-container&quot;&gt;$2000+2000+2400+2300$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;${\it£}8700$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would this be the correct answer? I'm confused since this is a pretty obvious answer, which I think is not correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an answer on Chegg solutions which gives me the following table of costs: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{rr}\hline\text{Shelves}&amp;amp;\text{Books}&amp;amp;\text{Building}&amp;amp;\text{Storage Costs}&amp;amp;\text{Unshelved}\\&amp;amp;&amp;amp;\text{Costs}&amp;amp;&amp;amp;\\\hline4''&amp;amp;4''&amp;amp;{\it£}2300&amp;amp;200\times0.5\times5\times4={\it£}2000&amp;amp;8'',12''\\8''&amp;amp;8''&amp;amp;{\it£}2300&amp;amp;100\times0.5\times5\times8={\it£}2000&amp;amp;4'',12''\\8''&amp;amp;4'',4''&amp;amp;{\it£}2300&amp;amp;2\times200\times0.5\times5\times4={\it£}4000&amp;amp;8'',12''\\12''&amp;amp;12''&amp;amp;{\it£}2300&amp;amp;80\times0.5\times5\times12={\it£}2400&amp;amp;4'',8''\\12''&amp;amp;4'',4'',4''&amp;amp;{\it£}2300&amp;amp;\small{\it£}2000+{\it£}2000+{\it£}2000+{\it£}2400={\it£}8400&amp;amp;8''\\12''&amp;amp;\small4'',8'',12''&amp;amp;{\it£}2300&amp;amp;{\it£}2000+{\it£}2000+{\it£}2400={\it£}6400&amp;amp;-\\\hline\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, this is the shortest path problem they're trying to optimize:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;In the above table, the building cost is given to be &lt;span class=&quot;math-container&quot;&gt;${\it£}2300$&lt;/span&gt;. From the above table, it is clear that four nodes are to be taken, that is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$C_{i,j}$&lt;/span&gt; being the total cost of shelving all books of height &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\le j$&lt;/span&gt; on a single shelf. The network will have four nodes (&lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt;). The network for minimizing cost is given below.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Oan0V.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Oan0V.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and they calculate the cost of building a shelf for the 4-inch books only with the following formula:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Now &lt;span class=&quot;math-container&quot;&gt;$X_{i,j}=$&lt;/span&gt; one unit of flow from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; through &lt;span class=&quot;math-container&quot;&gt;$x(i,j)$&lt;/span&gt;. It is now seen that the length of any path from node &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; is the net cost incurred. The cost from node &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; is calculated as below.&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;\begin{align}C_{0,4}=\frac{\text{Building cost}+\text{Storage cost}}{\text{Number of books}\times\text{per square inch cost}}=\frac{{\it£}2300+{\it£}2000}{200\times5}=\frac{{\it£}4300}{1000}={\it£}4.3.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why, in the above way of calculating &lt;span class=&quot;math-container&quot;&gt;$C_{0,4}$&lt;/span&gt; , do they divide by (number of books per square inch x cost per square inch) . What is the logic behind this? If someone could explain if this is the right path to the solution and if not, explain how would I solve this.&lt;/p&gt;&#xA;" OwnerUserId="1117" LastEditorUserId="123" LastEditDate="2019-12-26T15:32:07.237" LastActivityDate="2019-12-26T15:32:07.237" Title="Minimisation of shelving cost problem" Tags="|dynamic-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3022" PostTypeId="1" CreationDate="2019-11-11T13:21:46.903" Score="6" ViewCount="232" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;A company will be using a new technology for 5 years. For this purpose a specialized machine is required. The company currently has one, which will be 2-year old at the beginning of next year. The cost of a new machine is £6,000. The profit that can be obtained from the machine is decreasing with the age of the machine. There is no salvage value for an old machine. &lt;span class=&quot;math-container&quot;&gt;\begin{array}{cc}\hline\text{Age of Machine}&amp;amp;\text{Profit}\,\,(\text{in}\,\,{\it£}1,000)\\\hline0 &amp;amp; 10\\1 &amp;amp; 7\\2 &amp;amp; 5\\3 &amp;amp; 1\\\hline\end{array}&lt;/span&gt; By the end of each year it has to be decided whether or not to replace the old machine by a new one. In any case, the age of the machine must not exceed 3. The goal is to maximize the net profit during the next 5 years. Formulate and solve the problem as a shortest path problem. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have tried it using dynamic programming:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Define &lt;span class=&quot;math-container&quot;&gt;$p_{i,j}$&lt;/span&gt; as profit from using a machine from years &lt;span class=&quot;math-container&quot;&gt;$1,2,3,4,5,6$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$1\le i&amp;lt;j\le 6$&lt;/span&gt;. Then &lt;span class=&quot;math-container&quot;&gt;$p_{1,2}= 1$&lt;/span&gt; since at the second year I would face a cost of buying a new machine and the machine is already going into its second year, hence the &lt;span class=&quot;math-container&quot;&gt;$7$&lt;/span&gt; profit. Thus &lt;span class=&quot;math-container&quot;&gt;$p_{1,3}= 7+5=12$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_{2,3}$&lt;/span&gt; would be &lt;span class=&quot;math-container&quot;&gt;$10-6=4$&lt;/span&gt;, since we are buying a new machine after second year. The same logic would be for all the other arcs.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I got as a result is that the profit maximizing path would be &lt;span class=&quot;math-container&quot;&gt;$1-3-5-6$&lt;/span&gt; since &lt;span class=&quot;math-container&quot;&gt;$p_{1,3}=7+5=12$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$p_{3,5}=4+7=11$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_{5,6}=4$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{|c|c|}\hline p_{i,j}&amp;amp;1&amp;amp;2&amp;amp;3&amp;amp;4&amp;amp;5&amp;amp;6\\\hline1&amp;amp;&amp;amp;1&amp;amp;6&amp;amp;7&amp;amp;-&amp;amp;-\\\hline2&amp;amp;&amp;amp;&amp;amp;4&amp;amp;11&amp;amp;12&amp;amp;-\\\hline3&amp;amp;&amp;amp;&amp;amp;&amp;amp;4&amp;amp;11&amp;amp;12\\\hline4&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;4&amp;amp;11\\\hline5&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;4\\\hline\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just calculated this result using the graph I sketched, but not using the recursive method as dynamic programming tells us to do. How do I solve this using the method, and are my results/reasoning correct?&lt;/p&gt;&#xA;" OwnerUserId="1117" LastEditorUserId="123" LastEditDate="2019-11-11T20:11:00.390" LastActivityDate="2020-01-08T06:15:55.657" Title="Dynamic programming problem with machines" Tags="|dynamic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3023" PostTypeId="1" AcceptedAnswerId="3034" CreationDate="2019-11-11T13:28:06.037" Score="-2" ViewCount="347" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DxJjD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DxJjD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone please show how he uses dynamic programming to solve for minimum cost of getting from 1 to 6? Is it recommended to use dynamic programming to solve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I know that dynamic programming on shortest path examples requires us to go from 'back to front'. So I start with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) 5 is closest and shortest to 6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2)4 is closest and shortest to 5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and so on. I'm actually not sure how to use dynamic programming on this. Maybe somebody could hint me?&lt;/p&gt;&#xA;" OwnerUserId="1117" LastEditorUserId="1117" LastEditDate="2019-11-11T23:40:39.090" LastActivityDate="2019-11-12T00:57:09.947" Title="dynamic programming shortest path example" Tags="|dynamic-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3024" PostTypeId="1" CreationDate="2019-11-11T14:28:56.250" Score="6" ViewCount="172" Body="&lt;p&gt;I am going to buy a family car at the beginning of the New Year. I am going to stay in the UK for the next 4 years. I am considering the possibility of being a customer of company A which sells BMW models. Not only I can buy a car from this company but I can also trade in my car at this company and have my car serviced by the company. Company A gives a warranty that the annual maintenance costs and &#xA;trade-in prices will remain the same for the next 4 years.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are: &lt;span class=&quot;math-container&quot;&gt;\begin{array}{cc}\hline\text{Age of Car}&amp;amp;\text{Annual Maintenance}&amp;amp;\text{Trade-in Price at the}\\&amp;amp;\text{Cost}&amp;amp;\text{end of the period}\\\hline0&amp;amp;{\it\unicode{xA3}}2,000&amp;amp;{\it\unicode{xA3}}6,000\\1&amp;amp;{\it\unicode{xA3}}4,000&amp;amp;{\it\unicode{xA3}}5,000\\2&amp;amp;{\it\unicode{xA3}}6,000&amp;amp;{\it\unicode{xA3}}4,000\\3&amp;amp;{\it\unicode{xA3}}7,000&amp;amp;{\it\unicode{xA3}}2,000\\\hline\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid maintenance costs associated with an older car, I may trade in my car and purchase a new car. My wife prefers a Rover to a BMW. Company B which sells Rover models proposes similar conditions with figures in the table below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{cc}\hline\text{Age of Car}&amp;amp;\text{Annual Maintenance}&amp;amp;\text{Trade-in Price at the}\\&amp;amp;\text{Cost}&amp;amp;\text{end of the period}\\\hline0&amp;amp;{\it\unicode{xA3}}2,000&amp;amp;{\it\unicode{xA3}}8,000\\1&amp;amp;{\it\unicode{xA3}}3,000&amp;amp;{\it\unicode{xA3}}7,000\\2&amp;amp;{\it\unicode{xA3}}7,000&amp;amp;{\it\unicode{xA3}}5,000\\3&amp;amp;{\it\unicode{xA3}}8,000&amp;amp;{\it\unicode{xA3}}3,000\\\hline\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to find the minimal net cost for these 4 years which he would be using the car, here is how I went with the solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this would be the cost table for the BMW and Rover respectively: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{BMW}\hspace{4cm}\text{Rover}\hspace{2cm}\\\begin{array}{|c|c|}\hline c_{i,j}&amp;amp;1&amp;amp;2&amp;amp;3&amp;amp;4&amp;amp;5\\\hline1&amp;amp;&amp;amp;8&amp;amp;13&amp;amp;20&amp;amp;29\\\hline2&amp;amp;&amp;amp;&amp;amp;7&amp;amp;12&amp;amp;19\\\hline3&amp;amp;&amp;amp;&amp;amp;&amp;amp;6&amp;amp;11\\\hline4&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;4\\\hline5&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;\\\hline\end{array}\quad\begin{array}{|c|c|}\hline c_{i,j}&amp;amp;1&amp;amp;2&amp;amp;3&amp;amp;4&amp;amp;5\\\hline1&amp;amp;&amp;amp;10&amp;amp;14&amp;amp;23&amp;amp;32\\\hline2&amp;amp;&amp;amp;&amp;amp;8&amp;amp;12&amp;amp;30\\\hline3&amp;amp;&amp;amp;&amp;amp;&amp;amp;5&amp;amp;9\\\hline4&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;4\\\hline5&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;\\\hline\end{array}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By my sketch in my notebook, I see that if we got from &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; with BMW and then from &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; with Rover, then this would minimize the cost. Is this correct?&lt;/p&gt;&#xA;" OwnerUserId="1117" LastEditorUserId="123" LastEditDate="2019-11-11T19:51:39.083" LastActivityDate="2020-01-07T13:16:32.813" Title="Minimization of car cost during 4 years problem" Tags="|dynamic-programming|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3025" PostTypeId="1" CreationDate="2019-11-11T14:38:22.477" Score="5" ViewCount="590" Body="&lt;p&gt;I have been assigned to make a literature review on evacuation planning. Could you please suggest some papers that I can use for the review?&lt;/p&gt;&#xA;" OwnerUserId="2682" LastEditorUserId="491" LastEditDate="2022-01-31T02:13:59.407" LastActivityDate="2022-01-31T02:13:59.407" Title="Reference request for Evacuation Planning" Tags="|reference-request|literature-research|journals|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3026" PostTypeId="2" ParentId="3025" CreationDate="2019-11-11T16:08:10.150" Score="4" Body="&lt;p&gt;A buzzword that comes to my mind are &lt;em&gt;Flows over time&lt;/em&gt; and especially &lt;em&gt;Earliest Arrival Flows&lt;/em&gt;. Martin Skutella and students of his have worked out a bit of theory for that, see e.g.&#xA;&lt;a href=&quot;ftp://ftp.math.tu-berlin.de/pub/Preprints/combi/Report-022-2008.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;An introduction to Network Flows over time&lt;/a&gt;, &lt;a href=&quot;ftp://ftp.math.tu-berlin.de/pub/Preprints/combi/Report-035-2008.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Earliest Arrival Flows with multiple sources&lt;/a&gt;, &lt;a href=&quot;http://page.math.tu-berlin.de/~skutella/ISCO10-final.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Earliest Arrival Flows with multiple sinks&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2019-11-11T16:08:10.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3027" PostTypeId="1" AcceptedAnswerId="3043" CreationDate="2019-11-11T17:18:57.410" Score="12" ViewCount="3910" Body="&lt;p&gt;The pieces of information I get online are sometimes confusing. &lt;a href=&quot;https://or.stackexchange.com/questions/3015/complexity-of-lp-and-milp-problems&quot;&gt;Someone&lt;/a&gt; says MILP problems are NP-hard, and &lt;a href=&quot;https://www.cs.upc.edu/~erodri/webpage/cps/theory/lp/milp/slides.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;somewhere&lt;/a&gt; else I found the claim that MILP problems are NP-complete. Can someone please clarify it?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="8" LastEditDate="2019-11-17T10:03:56.967" LastActivityDate="2019-11-17T10:03:56.967" Title="MILP: is it NP-complete or NP-hard?" Tags="|mixed-integer-programming|linear-programming|computational-complexity|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3028" PostTypeId="1" AcceptedAnswerId="3029" CreationDate="2019-11-11T17:49:45.390" Score="10" ViewCount="1358" Body="&lt;p&gt;I am trying to formulate the following in linear programming.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{cases}\text{if}\,\,a&amp;gt;b\,\,\text{then}\,\,c=a\\\text{else}\,\,c=b.\end{cases}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried some things with big &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, like &lt;span class=&quot;math-container&quot;&gt;$$a + my &amp;gt; b+m(1-y),$$&lt;/span&gt; so that &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; (binary) can be used to pick either &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this does not work, because &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; will always be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in this example. But even with the help of other examples I cannot seem to figure it out. Any tips?&lt;/p&gt;&#xA;" OwnerUserId="2555" LastEditorUserId="491" LastEditDate="2019-11-26T18:22:29.050" LastActivityDate="2019-11-26T18:22:29.050" Title="Linear programming with if-then-else (big-M)" Tags="|linear-programming|constraint|big-m|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3029" PostTypeId="2" ParentId="3028" CreationDate="2019-11-11T18:16:57.497" Score="10" Body="&lt;p&gt;Equivalently, &lt;span class=&quot;math-container&quot;&gt;$c=\max(a,b)$&lt;/span&gt;.  See &lt;a href=&quot;https://or.stackexchange.com/questions/711/how-to-formulate-maximum-function-in-a-constraint&quot;&gt;this post&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-11-11T18:16:57.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3030" PostTypeId="2" ParentId="3025" CreationDate="2019-11-11T19:56:58.530" Score="4" Body="&lt;p&gt;In reverse chronological order, here are some papers which use OR (or OR-related) techniques to solve problems in evacuation planning:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1016/j.ejor.2016.05.037&quot; rel=&quot;nofollow noreferrer&quot;&gt;Goerigk, Marc et al. &quot;Ranking robustness and its application to evacuation planning.&quot; &lt;em&gt;European Journal of Operational Research&lt;/em&gt; 264.3 (2018): 837-846.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1016/j.seps.2016.10.009&quot; rel=&quot;nofollow noreferrer&quot;&gt;Swamy, Rahul et al. &quot;Hurricane evacuation planning using public transportation.&quot; &lt;em&gt;Socio-Economic Planning Sciences&lt;/em&gt; 59 (2017): 43-55.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1016/j.trb.2015.09.008&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pillac, Victor et al. &quot;A conflict-based path-generation heuristic for evacuation planning.&quot; &lt;em&gt;Transportation Research Part B&lt;/em&gt; 83 (2016): 136-150.&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1016/j.ejor.2008.07.032&quot; rel=&quot;nofollow noreferrer&quot;&gt;Saadatseresht, Mohammad et al. &quot;Evacuation planning using multiobjective evolutionary optimization approach.&quot; &lt;em&gt;European Journal of Operational Research&lt;/em&gt; 198.1 (2009): 305-314.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1016/0191-2615(91)90037-J&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sherali, Hanif et al. &quot;A location-allocation model and algorithm for evacuation planning under hurricane/flood conditions.&quot; &lt;em&gt;Transportation Research Part B&lt;/em&gt; 25.6 (1991): 439-452.&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find many related articles through the literature review sections of these papers. Also, you may find the following reviews helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1016/j.ejor.2013.01.039&quot; rel=&quot;nofollow noreferrer&quot;&gt;Galindo, Gina and Rajan Batta. &quot;Review of recent developments in OR/MS research in disaster operations management.&quot; &lt;em&gt;European Journal of Operational Research&lt;/em&gt; 230.2 (2013): 201-211.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1016/j.ejor.2005.05.016&quot; rel=&quot;nofollow noreferrer&quot;&gt;Altay, Nezih and Walter Green. &quot;OR/MS research in disaster operations management.&quot; &lt;em&gt;European Journal of Operational Research&lt;/em&gt; 175.1 (2006): 475-493.&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="196" LastEditorUserId="196" LastEditDate="2019-11-11T20:08:26.207" LastActivityDate="2019-11-11T20:08:26.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3032" PostTypeId="2" ParentId="3025" CreationDate="2019-11-11T20:05:50.767" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S1366554514001471&quot; rel=&quot;nofollow noreferrer&quot;&gt;Goerigk &lt;em&gt;et al&lt;/em&gt;. (2014)&lt;/a&gt; may be a good start to your literature search. It uses mixed-integer programming to propose a genetic algorithm that can be used for urban evacuation planning. Examples of scenarios are provided at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bonus of this paper is that it already contains an extensive literature review in section 1.2.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Goerigk, M., Deghdak, K., Heßler, P. (2014). A comprehensive evacuation planning model and genetic solution algorithm. &lt;em&gt;Transportation Research Part E: Logistics and Transportation Review.&lt;/em&gt; 71:82-97. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-11-11T21:13:50.757" LastActivityDate="2019-11-11T21:13:50.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3033" PostTypeId="2" ParentId="506" CreationDate="2019-11-11T22:45:50.167" Score="21" Body="&lt;p&gt;I belatedly realised that we've missed one of the most famous OR paradoxes of all:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In WW2, the Statistical Research Group at Columbia University considered the problem of how best to protect bombers from enemy fire. They observed patterns of bullet and shrapnel damage on bombers returning from missions over Europe. The obvious interpretation of these patterns was that bombers should be armoured in the areas that were hit most often, as shown by recorded damage frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fI1Wb.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fI1Wb.png&quot; alt=&quot;A diagram of a WW2 bomber showing red spots for areas where returning aircraft showed damage. Some parts of the plane have many spots, others such as the engines and cockpit have none.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, Abraham Wald's group realised this was exactly the wrong interpretation. The data was compiled from bombers that had &lt;em&gt;survived&lt;/em&gt; damage. The lack of reports of damage to areas such as engines and cockpits didn't mean that enemy fire never struck these areas - rather, it meant that they didn't survive when hit in these areas, so bombers should be armoured in these locations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another story from WW2, though I can't remember enough specifics to find a cite for this one: ice on wings is a major danger to aircraft, and the Allies were considering installing de-icing gear on bombers, but eventually concluded that even though it improved the survival rate for bombing missions, it actually increased the danger to pilots. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason for this was that the weight of de-icing gear reduced the payload that bombers could carry, requiring more flights to deliver the same weight of bombs, and hence more risk from enemy fire and other causes, something which more than outweighed the reduction in crashes due to icing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These examples might not be considered &quot;hard OR&quot; by modern standards, but both of them have some important lessons that are relevant to hard OR practitioners.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I wasn't sure whether to edit this into my old answer, but since it's in a completely different area, maybe it makes more sense to separate it?)&lt;/p&gt;&#xA;" OwnerUserId="546" LastActivityDate="2019-11-11T22:45:50.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3034" PostTypeId="2" ParentId="3023" CreationDate="2019-11-12T00:57:09.947" Score="2" Body="&lt;p&gt;There are algorithms specifically designed for shortest path problems, so dynamic programming is not the most common choice for it. On the other hand, small shortest path examples are commonly used to demonstrate DP (in part because they are easy to grasp).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for how to use DP here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you are at 5, the least costly (not to mention only) path to 6 costs 7.&lt;/li&gt;&#xA;&lt;li&gt;If you are at 4, you can go directly to 6 (cost 12) or go to 5 (cost 7) and then take the cheapest (and, as it turns out, only) route to 6 (costing another 7, for a total of 14). So the cheapest route from 4 to 6 costs 12.&lt;/li&gt;&#xA;&lt;li&gt;If you are at 3, [left to the reader as an exercise].&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-11-12T00:57:09.947" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3036" PostTypeId="2" ParentId="3027" CreationDate="2019-11-12T08:02:02.740" Score="3" Body="&lt;p&gt;A very good discussion of the complexity of MILP is given in the paper&lt;sup&gt;1&lt;/sup&gt; and the reference within&lt;sup&gt;2&lt;/sup&gt;. Based on the discussion in section &lt;span class=&quot;math-container&quot;&gt;$3.2$&lt;/span&gt; MILP is NP-hard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) Bulut, Aykut, and Ted K. Ralphs. On the complexity of inverse mixed integer linear optimization. Tech. rep. COR@ L Laboratory Report 15T-001-R3, Lehigh University, 2015 (cit. on p. 147).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) Papadimitriou, Christos H., and Mihalis Yannakakis. &quot;The complexity of facets (and some facets of complexity).&quot; Journal of Computer and System Sciences 28.2 (1984): 244-259.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-11-12T08:02:02.740" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3038" PostTypeId="2" ParentId="506" CreationDate="2019-11-12T11:41:43.627" Score="8" Body="&lt;p&gt;In my opinion the following result is counter intuitive. At least it was for me when I started studying OR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you study probability theory, you typically start by manipulating &lt;strong&gt;discrete&lt;/strong&gt; laws which are intuitive and easy to grasp, for example when you study the probability of getting a certain deck of cards, or a certain combination of balls from an urn. When studying such probabilities you perform summations and (almost) everything is nice and smooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, you are introduced to &lt;strong&gt;continuous&lt;/strong&gt; laws, and sums become integrals. In my opinion, things become more complex and much less intuitive. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In operations research, it is the opposite. You start with continuous (linear) optimisation (typically with the simplex algorithm), and (almost) everything is nice and smooth. Then, you are introduced to discrete optimisation and its algorithms where the simplex is embedded in more general frameworks such as branching procedures. Discrete optimisation becomes harder to grasp. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a computational point of view, continuous (linear) optimisation is easy, while discrete optimisation is hard. I find this counter intuitive ! I expected that manipulating finite and discrete elements would be easier than continuous ones (as in probability theory), where you have to deal with infinity at some point.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2019-11-12T19:27:49.423" LastActivityDate="2019-11-12T19:27:49.423" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3039" PostTypeId="1" AcceptedAnswerId="3040" CreationDate="2019-11-12T12:48:18.820" Score="10" ViewCount="665" Body="&lt;p&gt;I have an MIP problem where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; different types of cars are delivering packages. Sometimes multiple types of cars are required to go to a single location. For example if car &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; makes two deliveries to location &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, car &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; needs to make an equal amount of deliveries as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words: if an integer variable &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; is larger than &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; it should be equal to all &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; larger than &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I capture this in constraints in linear programming?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I need to create a new decision variable &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; that is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if a car makes &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; or more deliveries, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if there are no deliveries. From there on I need to somehow set the &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; values equal. But how?&lt;/p&gt;&#xA;" OwnerUserId="2691" LastEditorUserId="123" LastEditDate="2019-11-12T19:31:19.627" LastActivityDate="2019-11-12T19:31:19.627" Title="MIP: If integer variable $&gt;0$ it should be equal to other integer variables $&gt;0$" Tags="|mixed-integer-programming|integer-programming|logical-constraints|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3040" PostTypeId="2" ParentId="3039" CreationDate="2019-11-12T13:26:45.640" Score="11" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$b_n$&lt;/span&gt; be a binary indicator variable, and let integer variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; be the common value of the positive &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt;.  Then you want to enforce &lt;span class=&quot;math-container&quot;&gt;$x_n=b_n y$&lt;/span&gt;, which you can linearize using the formulation given &lt;a href=&quot;https://or.stackexchange.com/questions/39/how-to-linearize-the-product-of-a-binary-and-a-non-negative-continuous-variable&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-11-12T13:26:45.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3041" PostTypeId="2" ParentId="3025" CreationDate="2019-11-12T14:11:14.773" Score="3" Body="&lt;p&gt;Excluding papers listed in other answers...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Surveys:&lt;/strong&gt;&lt;br&gt;&#xA;Great starting points would be surveys on general evacuation and disaster operations management such as &lt;a href=&quot;https://kluedo.ub.uni-kl.de/frontdoor/deliver/index/docId/1477/file/bericht24.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hamacher &amp;amp; Tjandra (2002)&lt;/a&gt; and &lt;a href=&quot;http://dx.doi.org/10.3934/jimo.2015.11.265&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dhamala (2014)&lt;/a&gt; for time-expanded network flow models. &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/inte.1060.0253&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wright (2006)&lt;/a&gt; gives a homeland security-themed survey. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;General Evacuation:&lt;/strong&gt;&lt;br&gt;&#xA;Multiobjective evolutionary algorithm with GIS-integration: &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S037722170800670X&quot; rel=&quot;nofollow noreferrer&quot;&gt;Saadatsersht et al. (2019)&lt;/a&gt;.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Noncombatant Evacuation:&lt;/strong&gt;&lt;br&gt;&#xA;Discrete Event Simulation (DES):  &lt;a href=&quot;https://apps.dtic.mil/dtic/tr/fulltext/u2/a618492.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kuchell (2013)&lt;/a&gt;; &lt;a href=&quot;https://apps.dtic.mil/dtic/tr/fulltext/u2/a546629.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Scheer (2011)&lt;/a&gt;; &lt;a href=&quot;https://apps.dtic.mil/dtic/tr/fulltext/u2/a546629.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Olsen (2011)&lt;/a&gt;, &lt;a href=&quot;https://ieeexplore.ieee.org/document/873392&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sumner and Zahn (1996)&lt;/a&gt;.   &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References (alphabetical order by last name of first author) &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] T.N. Dhamala. 2014. A survey of models and algorithms for discrete evacuation planning network problems. &lt;em&gt;Journal of Industrial and Management Optimization&lt;/em&gt;, 11(1):265–289. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] H.W. Hamacher and S.A. Tjandra. 2002. Mathematical modelling of evacuation problems: a state of the art. In M. Schrekenberg and S.D. Sharma, editors, &lt;em&gt;Pedestrian and Evacuation Dynamics&lt;/em&gt;, pages 227–266. Springer, Berlin, Germany. &lt;/sub&gt;    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [3] D. Kuchell. 2013. Analyzing noncombatant evacuation operations using discrete event simulation, &lt;em&gt;Proceedings of the 2013 Winter Simulation Conference&lt;/em&gt;, pages 2751–2761. R. Pasupathy, S.H. Kim, A. Tolk, R. Hill, and M.E. Kuhl, eds. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [4] C.M. Olsen. 2011. &lt;em&gt;Simulation study of evacuation control center operations analysis&lt;/em&gt;, Master’s thesis, Air Force Institute of Technology. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [5] M. Saadatseresht, A. Mansourian, and M. Taleai. 2009. Evacuation planning  using multiobjective evolutionary optimization approach, &lt;em&gt;European Journal of Operational Research&lt;/em&gt;, 198(1):305–314. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [6] M.A. Scheer. 2011. &lt;em&gt;Noncombatant evacuation operations in EUCOM&lt;/em&gt;,  Master’s thesis, Air Force Institute of Technology. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [7] J.E. Sumner and E.A. Zahn. 1996.  A simulation of the evacuation of American citizens with an object-oriented animated model. &lt;em&gt;Proceedings of the 1996  Winter Simulation Conference&lt;/em&gt;, pages 967–974. J.M Charnes, D.J.Morrice, D.T. Brunner, and J.J. Swain, eds. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [8] P.D. Wright, M.J. Liberatore, and R.L. Nydick. 2006. A Survey of Operations Research Models and Applications in Homeland Security. &lt;em&gt;INFORMS Journal on Applied Analytics&lt;/em&gt;, 36(6):514–529. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-11-12T22:05:00.070" LastActivityDate="2019-11-12T22:05:00.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3042" PostTypeId="1" AcceptedAnswerId="3044" CreationDate="2019-11-12T15:22:24.280" Score="6" ViewCount="1088" Body="&lt;p&gt;There is an explanation in my book for an integer programming example, which goes like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A company is considering manufacturing three types of autos: compact, midsize, and large. The resources required, and the profits yielded, by each type of car are shown in the table. &lt;span class=&quot;math-container&quot;&gt;\begin{array}{c|ccc|c}&amp;amp;&amp;amp;\underline{\text{Car Type}}&amp;amp;&amp;amp;\text{Available}\\\text{Resource}&amp;amp;\text{Compact}&amp;amp;\text{Midsize}&amp;amp;\text{Large}&amp;amp;\text{Resources}\\\hline \text{Steel Required}&amp;amp;1.5\,\,\text{tons}&amp;amp;3 \,\,\text{tons}&amp;amp;5 \,\,\text{tons}&amp;amp;6000\,\, \text{tons}\\\text{Labour Required}&amp;amp;30\,\, \text{hrs}&amp;amp;25 \,\,\text{hrs}&amp;amp;40\,\, \text{hrs}&amp;amp;60000 \,\,\text{hrs}\\\hline \text{Profit}\,\, ({\it£})&amp;amp;2000&amp;amp;3000&amp;amp;4000&amp;amp;\\\hline\end{array}&lt;/span&gt; For the production of a type of car to be economically feasible, at least &lt;span class=&quot;math-container&quot;&gt;$1000$&lt;/span&gt; cars of that type must be produced.&#xA;Formulate an IP to maximize the profit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; be the number of compact, midsize and large cars produced respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Resource Constraints:&lt;/em&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}1.5x_1 + 3x_2 + 5x_3&amp;amp;\leq 6000 \ \ \text{(Steel resource)}\\30x_1 + 25x_2 + 40x_3 &amp;amp;\leq 60000 \ \ \text{(Labour resource)}\end{align}&lt;/span&gt; If we decide to produce any cars of a given type, then it must be at least &lt;span class=&quot;math-container&quot;&gt;$1000$&lt;/span&gt; cars of that type. &lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{Constraint 3}:x_1 \le 0 \ \ &amp;amp;\text{or} \ \ x_1\ge 1000\\\text{Constraint 4}:x_2 \le 0 \ \ &amp;amp;\text{or} \ \ x_2\ge 1000\\\text{Constraint 5}:x_3 \le 0 \ \ &amp;amp;\text{or} \ \ x_3\ge 1000.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For Constraint &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_1 \le 0 \ \ \text{or} \ \ x_1\ge 1000$&lt;/span&gt; so &lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{Either}&amp;amp;\quad x_1\le0\color{maroon}{+My_1}\\\text{or}&amp;amp;\quad-x_1\le-1000\color{maroon}{+M(1-y_1)}\\&amp;amp;\quad y_1=0\ \ \text{or}\ \ 1\end{align}&lt;/span&gt; When &lt;span class=&quot;math-container&quot;&gt;$y_1=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;\begin{align}x_1&amp;amp;\le0\\-x_1&amp;amp;\le-1000+M\end{align}&lt;/span&gt; and when &lt;span class=&quot;math-container&quot;&gt;$y_1=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;\begin{align}x_1&amp;amp;\le M\\-x_1&amp;amp;\le-1000.\end{align}&lt;/span&gt; The constant &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; should not restrict the values of decision variables, so &lt;span class=&quot;math-container&quot;&gt;\begin{align}1.5x_1+3x_2+5x_3&amp;amp;\le6000\\30x_1+25x_2+40x_3&amp;amp;\le60000.\end{align}&lt;/span&gt; For &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M\ge2000$&lt;/span&gt;. For &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M\ge2000$&lt;/span&gt;. For &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M\ge1200$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't understand why &lt;span class=&quot;math-container&quot;&gt;$M_1, M_2, M_3$&lt;/span&gt; are equal or bigger than &lt;span class=&quot;math-container&quot;&gt;$2000$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$2000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1200$&lt;/span&gt; respectively. From where have these numbers been deduced? I'm confused.&lt;/p&gt;&#xA;" OwnerUserId="1117" LastEditorUserId="123" LastEditDate="2019-11-12T19:50:23.817" LastActivityDate="2019-11-12T19:50:23.817" Title="Integer programming example clarification" Tags="|integer-programming|big-m|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3043" PostTypeId="2" ParentId="3027" CreationDate="2019-11-12T15:33:18.290" Score="16" Body="&lt;p&gt;For an introduction to complexity theory, see &lt;a href=&quot;https://cs.stackexchange.com/a/9566/&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A problem is NP-complete if it is both in NP and it is NP-hard. Only decision problems are in NP. Hence, if one considers MILP as a decision or feasibility problem, it is correct to say that MILP is NP-complete as well as NP-hard. Maximization and minimization problems are not decision problems (although they can easily be transformed into decision problems), so if one considers MILP as an optimization problem, MILP is not NP-complete but is NP-hard. &lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2019-11-12T15:33:18.290" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3044" PostTypeId="2" ParentId="3042" CreationDate="2019-11-12T16:26:11.183" Score="7" Body="&lt;p&gt;You can choose large numbers for your &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;s (big-M) (that's why they are called that), but you also want to make sure they are not very large. See the discussions &lt;a href=&quot;https://or.stackexchange.com/questions/236/why-is-it-important-to-choose-big-m-carefully-and-what-are-the-consequences-of-d&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/questions/126/the-effect-of-choosing-big-m-properly&quot;&gt;here&lt;/a&gt; for the reasons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your example, your big-Ms just need to be bigger than the upper bound of the values that the variables can take (as @Stradivari mentioned). So, for each of &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2, x_3$&lt;/span&gt;, take the &lt;span class=&quot;math-container&quot;&gt;$\min$&lt;/span&gt; of values they can get from the resource (steel and labor) constraints and you get your big-Ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example for &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min\left(\frac{6000}{1.5}, \frac{60000}{30}\right)=2000 $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do the same for &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; and you get &lt;span class=&quot;math-container&quot;&gt;$2000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1200$&lt;/span&gt;, respectively.&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="123" LastEditDate="2019-11-12T19:33:57.480" LastActivityDate="2019-11-12T19:33:57.480" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3045" PostTypeId="1" CreationDate="2019-11-12T17:20:26.390" Score="11" ViewCount="162" Body="&lt;p&gt;I am trying to understand an algorithm in a paper by &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0305054811000037&quot; rel=&quot;noreferrer&quot;&gt;Crévits &lt;em&gt;et al.&lt;/em&gt; (2012)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;  (see algorithm 2, the cuts I'm referring to are from the reduced costs).  It uses a series of successive cuts on a linear relaxation of a problem. But it also uses a variable fixation rule. I'm not sure whether to adjust or remove the cut (constraint) under certain circumstances where the fixation is contrary to the values that made the constraint in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example say you have a new cut (constraint) as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$5.5x_1 + 2.3x_2 + 6.4x_3 + 7.3x_4 + 8.1x_5 + 4.9x_6 \le s - r$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is the value of a previous relaxation and &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; is the value of a previous incumbent (both calculated at the time the cut was made).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And there are also these constraints in the original ILP problem and the LP relaxation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}x_1 + x_2 + x_3&amp;amp;= 1\\x_4 + x_5 + x_6 &amp;amp;= 1\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say later a fixation is found where &lt;span class=&quot;math-container&quot;&gt;$x_3=0$&lt;/span&gt;, but is contrary to what was used to calculate &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; i.e. &lt;span class=&quot;math-container&quot;&gt;$x_3=1$&lt;/span&gt; when calculating &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;. What then to do with the cut (constraint)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that if the fixation value is in accordance with the RHS then the column can be removed from the LHS and the value adjusted on the RHS, assuming the fixation is at &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, otherwise the fixation is at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and the column can just be removed with the RHS left unchanged.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Crévits, I., Hanafi, S., Mansi, R., Wilbaut, C. (2012). Iterative semi-continuous relaxation heuristics for the multiple-choice multidimensional knapsack problem. &lt;em&gt;Computers and Operations Research.&lt;/em&gt; 39(1):32-41. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="2611" LastEditorUserId="2611" LastEditDate="2019-11-12T21:26:18.090" LastActivityDate="2021-05-24T09:47:35.557" Title="What to do with cuts (constraints) when a fixation is contrary to a RHS in a ILP / LP relaxation?" Tags="|linear-programming|integer-programming|lp-relaxation|cutting-planes|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3046" PostTypeId="2" ParentId="3000" CreationDate="2019-11-12T23:26:17.643" Score="5" Body="&lt;ol&gt;&#xA;&lt;li&gt;I think there may still be errors in your one car formulation, but in any event there is no obvious way to do a one car, &lt;span class=&quot;math-container&quot;&gt;$8T$&lt;/span&gt; route and divide it up if all routes need to start at &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. You would need to constraint your route to return to &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; exactly seven times, and then figure out how to compute separate transit times for each return to &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;There is no simple answer to how large a MIP model commercial solvers can handle. For one thing, it depends on how dense the coefficient matrices are, how much memory you have (both RAM and disk), how many cores / CPUs / nodes (on a computing cluster), and how many lifetimes you are willing to wait. For another, some large problems solve quickly (because they have tight relaxations, or because you just get lucky) and some moderately small problems take forever (because they have weak relaxations, or because you get unlucky). I would not automatically conclude that your one-car model would be too big to solve, but I also would not bet money that it could be solved in &quot;reasonable&quot; time on &quot;reasonable&quot; hardware.&lt;/li&gt;&#xA;&lt;li&gt;You could consider column generation. Rather than focusing on arcs, the master problem would look at complete paths (each starting at &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; and having transit time no longer than &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;). The master problem would assign a binary variable (&lt;span class=&quot;math-container&quot;&gt;$x_p$&lt;/span&gt;) to each path &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; (1 if used, 0 if not) with a constraint that &lt;span class=&quot;math-container&quot;&gt;$\sum_p x_p \le 8$&lt;/span&gt; (one path per car). It would also contain your &lt;span class=&quot;math-container&quot;&gt;$y_e$&lt;/span&gt; variables (and your current objective), with constraints saying that &lt;span class=&quot;math-container&quot;&gt;$y_e \le \sum_{e\in p}x_p$&lt;/span&gt; (you traverse arc &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; only if you drive at least one path containing it). If the cameras on the cars have 360 degree sweep (which I believe is the case), you should also say &lt;span class=&quot;math-container&quot;&gt;$y_e + y_{e'}\le 1$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$e'$&lt;/span&gt; is the reverse of arc &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; (so that you don't get double credit for a street by hitting it both directions). The path generation subproblem would have a binary variable for each arc (used or not), a binary variable for each node (is this where the path ends?), and flow conservation constraints. The objective would be to maximize the &quot;value&quot; of the path, with the objective coefficients being based on something akin to shadow prices/dual values from the LP relaxation of the master problem.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There's not enough room here to enter into a discourse on column generation (plus I'd be the wrong person to do so), so I'll stop here. I will note that (a) there is &quot;branch-price-and-cut&quot;, which is like branch-and-cut for column generation problems and gives optimal solutions if the problem cooperates, and (b) there are heuristics using column generation to get good but not provably optimal solutions.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-11-12T23:26:17.643" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3047" PostTypeId="1" CreationDate="2019-11-13T03:51:29.487" Score="3" ViewCount="130" Body="&lt;p&gt;Consider a telephone company which receives call request at some arrival rate and serves each request with some service rate. This can be modeled using a Poisson Process. However I wish to model the behaviour of individual calls and their individual service times, that is, the model should be able to tell whether the system has received a call request from user &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, and if it indeed has, whether the request has been catered to with the requisite service rate. Note that the system is probabilistic. What would be an appropriate model to use to represent such a system? If I use a Markov Decision Process, how to characterize the arrival rates and the service rates?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mGG5P.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mGG5P.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have tried is the above Markov Process. I have kept states which keep track of call request from each user. Here, I have modeled for &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; users. Once a call from a user is completed, it can move to any of the other states where a call from the other user is in progress or go back to the no call state. In addition, there would be states to keep track of calls from multiple users at the same time. I have not shown that for brevity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to this, what I would like to model is calls from user &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is arriving at rate &lt;span class=&quot;math-container&quot;&gt;$\lambda_{n}$&lt;/span&gt; and its service rate is say &lt;span class=&quot;math-container&quot;&gt;$s_{n}$&lt;/span&gt;. Can this behavior be captured with the Markov Process? Or would a Birth-Death process be a better model of this?&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="584" LastEditDate="2019-11-14T10:38:15.633" LastActivityDate="2019-11-21T19:36:00.707" Title="Queuing Theoretic Model with Memory" Tags="|modeling|markov-decision-process|probability-theory|queuing-theory|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="3050" PostTypeId="1" AcceptedAnswerId="3051" CreationDate="2019-11-14T01:43:54.123" Score="6" ViewCount="75" Body="&lt;p&gt;I'm new to AMPL and am trying to model the following constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}y_{ij3}&amp;amp;\le\sum_\ell X_{j\ell2}\quad(m=2,k=3)\\y_{ijk}&amp;amp;\le\sum_\ell\sum_mx_{j\ell m},\quad\forall i\in I,\forall j\in J,k=1,2.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if I am on the right track. This is what I have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subject to C1 {i in DEMAND, j in FACILITY}: Y[i,j,&quot;CO&quot;] &amp;lt;= sum{l in SIZE} X[j,l,&quot;TRI&quot;] ;&#xA;&#xA;subject to C2_1 {i in DEMAND, j in FACILITY}: Y[i,j,&quot;EL&quot;] &amp;lt;= sum{l in SIZE,m in TECH} X[j,l,m] ;&#xA;&#xA;subject to C2_2 {i in DEMAND, j in FACILITY}: Y[i,j,&quot;TH&quot;] &amp;lt;= sum{l in SIZE, m in TECH} X[j,l,m] ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I modelled the second constraint in two parts. The relevant sets are as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ENERGY:= EL CO TH; #k&#xA;&#xA;set TECH := COG TRI; #m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2693" LastEditorUserId="1160" LastEditDate="2019-11-14T14:40:25.127" LastActivityDate="2019-11-14T14:40:25.127" Title="Issue interpreting sets of constraints in AMPL" Tags="|ampl|gams|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3051" PostTypeId="2" ParentId="3050" CreationDate="2019-11-14T02:59:43.293" Score="4" Body="&lt;pre&gt;&lt;code&gt;model;&#xA;&#xA;set energy:= el co th;&#xA;set tech  := cog tri;&#xA;subject to cons1 {i in demand, j in facility}: y[i,j,'th'] &amp;lt;= sum{i in size} x[j,l,'tri'];&#xA;subject to cons2 {i in demand, j in facility, k in energy}: y[i,j,k] &amp;lt;= sum{j in facility, l in size, m in tech} x[j,l,m];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only thing that you need to change is in your first constraint 'CO' to 'TH'.&#xA;A good resource for the constraints declaration can be found &lt;a href=&quot;https://ampl.com/BOOK/CHAPTERS/11-linprog.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-11-14T07:49:46.220" LastActivityDate="2019-11-14T07:49:46.220" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3052" PostTypeId="1" CreationDate="2019-11-14T07:56:19.840" Score="7" ViewCount="176" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}$&lt;/span&gt; be a &lt;span class=&quot;math-container&quot;&gt;${n\times J}$&lt;/span&gt; matrix with &lt;span class=&quot;math-container&quot;&gt;$A_{ij}\geq0$&lt;/span&gt; (and &lt;span class=&quot;math-container&quot;&gt;$A_{ij}&amp;gt;0$&lt;/span&gt; for most &lt;span class=&quot;math-container&quot;&gt;$ij$&lt;/span&gt;, there cannot be any rows or columns that consist only of &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;s), &lt;span class=&quot;math-container&quot;&gt;$Q=\left\{\mathbf{q}\mid \mathbf{q}\in\Bbb R^n_+\land\sum\limits_{i=1}^n q_i=1\right\}$&lt;/span&gt; and an &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;\alpha&amp;lt;1$&lt;/span&gt;. Abusing notation, let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^{\frac{1}{\alpha}}=\bigl(q_1^\frac{1}{{\alpha}},\dots,q_n^\frac{1}{{\alpha}}\bigr).$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the set &lt;span class=&quot;math-container&quot;&gt;$K=\{\mathbf{k}\in\Bbb R^J_+\mid \mathbf{k}=\mathbf{A}^{\top}\mathbf{q}^\frac{1}{{\alpha}}\land \mathbf{q}\in Q\}.$&lt;/span&gt; There exist &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; members of &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; such that the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;-th component of &lt;span class=&quot;math-container&quot;&gt;$\underline{\mathbf{k}}^j$&lt;/span&gt; is lower than the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;-th component of any other &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\in K$&lt;/span&gt;. These can be easily identified using calculus. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\in K$&lt;/span&gt; that I'm interested in can be found as follows&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Choose some &lt;span class=&quot;math-container&quot;&gt;$\beta \in\Bbb R^J_+$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{j=1}^J b_j=1,$&lt;/span&gt; &lt;/li&gt;&#xA;&lt;li&gt;Compute &lt;span class=&quot;math-container&quot;&gt;$\widehat{\mathbf{k}} =\sum\limits_{j=1}^J\beta_j\underline{\mathbf{k}}^j,$&lt;/span&gt; &lt;/li&gt;&#xA;&lt;li&gt;Determine the proportions &lt;span class=&quot;math-container&quot;&gt;$\mathbf{r}=\frac{1}{\hat k_1}\widehat{\mathbf{k}}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$k_j=\sum\limits_{i=1}^nA_{ij}q_i^{\frac{1}{\alpha}}$&lt;/span&gt; and minimize &lt;span class=&quot;math-container&quot;&gt;$k_1$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\in K$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k_j=r_j k_1 \quad \forall j=\{2,\dots,J\}.$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$k^*_1$&lt;/span&gt; is the minimum of this problem, then &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^*=(k^*_1,r_2 k^*_1,\dots,r_J k^*_1)$&lt;/span&gt; lies on the frontier.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;@MikeY suggested that I could solve instead the following problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;    \min\limits_{\{q_i\}}&amp;amp;\quad \delta^{\top}\mathbf{A}^{\top}\mathbf{q}^\frac{1}{{\alpha}}\\&#xA;    \text{s.t.}&amp;amp;\quad\begin{cases} \sum\limits_{i=1}^n q_i=1 \\&#xA;     q_i \geq 0 &amp;amp; i=\{1,\dots,n\} \\&#xA;    \end{cases} \end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for some &lt;span class=&quot;math-container&quot;&gt;$\delta \in \Bbb R_+^J$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{j=1}^J \delta_j=1$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^*$&lt;/span&gt; is the minimand of this problem, then &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^*=\mathbf{A}^{\top}\left(\mathbf{q}^*\right)^\frac{1}{{\alpha}}$&lt;/span&gt; lies on the frontier. I've tried this approach, that is computationally much more efficient, and it works fine in the sense that it results in a frontier that is indistinguishable from the one obtained with my approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why is this second approach equivalent to mine? I can see that if &lt;span class=&quot;math-container&quot;&gt;$\delta^j$&lt;/span&gt; is a vector of zeroes except for the &lt;span class=&quot;math-container&quot;&gt;$j-th$&lt;/span&gt; component that is a &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, @MikeY's approach yields &lt;span class=&quot;math-container&quot;&gt;$\underline{\mathbf{k}}^j$&lt;/span&gt;, but I don't see why this is also the case for other points in the frontier.&lt;/li&gt;&#xA;&lt;li&gt;What is the relationship between &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt;? For &lt;span class=&quot;math-container&quot;&gt;$J=2$&lt;/span&gt;, @MikeY suggests that &lt;span class=&quot;math-container&quot;&gt;$\delta=(\beta,1-\beta)$&lt;/span&gt;. My exploration of a &lt;span class=&quot;math-container&quot;&gt;$J=3$&lt;/span&gt; case, indicates that the relationship is not so obvious.&lt;/li&gt;&#xA;&lt;li&gt;Ideally, I'd like to be able to determine the &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; that corresponds to any &lt;span class=&quot;math-container&quot;&gt;$\widehat{\mathbf{k}}$&lt;/span&gt; that is a convex combination of the &lt;span class=&quot;math-container&quot;&gt;$\underline{\mathbf{k}}^j$&lt;/span&gt;s.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; @MikeY's suggestion is the third answer to my &lt;a href=&quot;https://mathematica.stackexchange.com/questions/193563/identifying-points-in-the-frontier-of-a-set&quot;&gt;question&lt;/a&gt; in Stack Exchange Mathematica site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt; We can write the Lagrangian of the first problem to ressemble that of the second (ommiting the non-negativity constraints is of no consequence): &#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}\mathcal L &amp;amp;=k_1+\sum\limits_{j=2}^J \lambda_j (k_j -k_1 r_j) +\gamma \left(1-\sum\limits_{i=1}^nq_i\right)\\ &amp;amp; =\left(1-\sum\limits_{j=2}^J \lambda_j r_j\right)k_1 + \sum\limits_{j=2}^J \lambda_j k_j+\gamma \left(1-\sum\limits_{i=1}^nq_i\right)\end{align}.$$&lt;/span&gt;&#xA;One could set &lt;span class=&quot;math-container&quot;&gt;$\rho_1=1-\sum\limits_{j=2}^J \lambda_j r_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\rho_j=\lambda_j \quad j=\{2,\dots,J\},$&lt;/span&gt; observe that &lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{j=1}^J\rho_j=1-\sum\limits_{j=2}^J\lambda_j(r_j-1),$$&lt;/span&gt;&#xA;and write &lt;span class=&quot;math-container&quot;&gt;$\delta_j=\frac{\rho_j}{\sum\limits_{j=1}^J\rho_j}$&lt;/span&gt; which would result in an equivalent lagrangian (in the sense that the minimand is the same) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \mathcal L' =\sum\limits_{j=1}^J \delta_j k_j+\gamma' \left(1-\sum\limits_{i=1}^nq_i\right)$$&lt;/span&gt;&#xA;The problem is that, although these deltas do add up to one, &lt;span class=&quot;math-container&quot;&gt;$\delta_1$&lt;/span&gt; can be negative, in which case (some) &lt;span class=&quot;math-container&quot;&gt;$\delta_j$&lt;/span&gt;s can be larger than one. Further, I'd like to be able to obtain &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; without having to compute the &lt;span class=&quot;math-container&quot;&gt;$\lambda_j$&lt;/span&gt;s first.&lt;/p&gt;&#xA;" OwnerUserId="2391" LastEditorUserId="2391" LastEditDate="2019-11-21T08:05:19.027" LastActivityDate="2019-11-21T08:05:19.027" Title="Relationship between two minimization problems" Tags="|optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3053" PostTypeId="1" AcceptedAnswerId="3061" CreationDate="2019-11-14T11:13:39.893" Score="10" ViewCount="398" Body="&lt;p&gt;I have a MIP minimization problem where I have a maximization in the constraints:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max(c_1x_2,\, c_2x_2,\, \ldots,\, c_nx_n) \geq q$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_n$&lt;/span&gt; constants&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; binary variables&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; constant&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; is not part of the objective function. How can I linearize this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first step to solve this would be to create a new variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; representing the the maximum value. Further I think a Big M should be used. But what would become the constraints?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;https://orinanobworld.blogspot.com/2011/01/max-and-min-functions-in-mip.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;an option&lt;/a&gt; that almost does this but it is for two variables instead of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. For example &lt;span class=&quot;math-container&quot;&gt;$\max(x,y)$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, &lt;a href=&quot;https://or.stackexchange.com/questions/612/how-to-linearize-a-constraint-with-a-maximum-of-binary-variables-times-some-coef&quot;&gt;this&lt;/a&gt; problem is similar but doesn't cover the problem exactly. &lt;/p&gt;&#xA;" OwnerUserId="2691" LastEditorUserId="123" LastEditDate="2019-11-14T19:58:44.657" LastActivityDate="2019-11-14T22:34:08.570" Title="Linearization $\max(c_1 x_2, c_2 x_2, \ldots, c_nx_n) \geq q$ constraint" Tags="|mixed-integer-programming|linear-programming|constraint|linearization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3054" PostTypeId="2" ParentId="3053" CreationDate="2019-11-14T12:20:03.297" Score="10" Body="&lt;p&gt;Assuming that the &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; are all positive you may add one binary variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$i=1,\cdots,n$&lt;/span&gt; then you may do &lt;span class=&quot;math-container&quot;&gt;\begin{align}c_i x_i &amp;amp;\geq q y_i \quad\forall i\\\sum_i y_i &amp;amp;\geq 1\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="123" LastEditDate="2019-11-14T19:59:26.003" LastActivityDate="2019-11-14T19:59:26.003" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3055" PostTypeId="1" CreationDate="2019-11-14T16:11:06.463" Score="5" ViewCount="353" Body="&lt;p&gt;I am dealing with a kind of scheduling problem. I have a set of tasks to be executed by a set of machines. It is known that different machines are able to execute the same task, but each machine can execute one task at time. The cost of executing each task is dependent of each machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to find the minimal cost of executing all required tasks, in addition to the cost of executing each task I need to consider that there is an supplementary cost of transferring the material between two consecutive machines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this example that consider the alternative resources in house building (chapter 6) : &lt;a href=&quot;https://github.com/IBMDecisionOptimization/docplex-examples/blob/b2cb101befaa3febba0fc5fcfb77f28436891cc4/examples/cp/jupyter/scheduling_tuto.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/IBMDecisionOptimization/docplex-examples/blob/b2cb101befaa3febba0fc5fcfb77f28436891cc4/examples/cp/jupyter/scheduling_tuto.ipynb&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: how to add the cost of changing the worker that executes the operation in this example?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same question asked here: &lt;a href=&quot;https://stackoverflow.com/questions/58859430/scheduling-with-transition-costs-docplex&quot;&gt;https://stackoverflow.com/questions/58859430/scheduling-with-transition-costs-docplex&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="2453" LastEditDate="2019-11-15T09:32:26.803" LastActivityDate="2019-11-15T11:23:51.610" Title="Scheduling with transition costs - DOCPLEX" Tags="|cplex|python|scheduling|docplex|cp-optimizer|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3056" PostTypeId="1" AcceptedAnswerId="3058" CreationDate="2019-11-14T17:42:07.567" Score="12" ViewCount="690" Body="&lt;p&gt;I implemented a cplex model and I am convinced that the model should allow a better solution on a specific instance. However, when I impose the variable values of the solution onto the model, it returns no solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simple way to find &quot;the inequality that makes the solution infeasible&quot;? I think, I once had cplex give me a violated inequality?&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="39" LastEditDate="2019-11-14T17:50:45.577" LastActivityDate="2019-11-14T20:02:26.143" Title="Debugging cplex model" Tags="|modeling|cplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3057" PostTypeId="2" ParentId="3056" CreationDate="2019-11-14T17:48:37.913" Score="8" Body="&lt;p&gt;With CPLEX_CMD : execute the following commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;read(your_problem.lp)      &#xA;&#xA;optimize &#xA;&#xA;tools&#xA;&#xA;conflict&#xA;&#xA;display&#xA;&#xA;conflict &#xA;&#xA;all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will give you the smallest set of equations that make the problem infeasible.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2019-11-14T20:02:26.143" LastActivityDate="2019-11-14T20:02:26.143" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3058" PostTypeId="2" ParentId="3056" CreationDate="2019-11-14T17:49:22.657" Score="10" Body="&lt;p&gt;CPLEX has a conflict refiner. The instructions for invoking it are at &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/infeas_unbd/conflict_refiner/04_invoke.html&quot; rel=&quot;noreferrer&quot;&gt;How to invoke the conflict refiner&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2019-11-14T17:49:22.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3059" PostTypeId="1" CreationDate="2019-11-14T18:26:45.807" Score="18" ViewCount="1729" Body="&lt;p&gt;How to approach a traveling salesman problem with an aim to maximize revenue at each town visited in a certain number of days (total number of towns is greater than what can be visited in the given time window) ? The demand for the product being sold varies by the town. Is there any published literature I can refer to approach this variant of the TSP?&lt;/p&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="491" LastEditDate="2022-03-09T04:50:09.090" LastActivityDate="2022-03-09T04:50:09.090" Title="TSP with revenue maximization" Tags="|optimization|linear-programming|traveling-salesman|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3060" PostTypeId="2" ParentId="3059" CreationDate="2019-11-14T18:56:00.420" Score="18" Body="&lt;p&gt;Search for &lt;em&gt;orienteering problem&lt;/em&gt; or &lt;em&gt;prize-collecting TSP&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-11-14T18:56:00.420" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3061" PostTypeId="2" ParentId="3053" CreationDate="2019-11-14T22:34:08.570" Score="11" Body="&lt;p&gt;You can do this with no new variables. Let &lt;span class=&quot;math-container&quot;&gt;$S=\{k:c_k \ge q\}$&lt;/span&gt; and add the constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{k\in S}x_k \ge 1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-11-14T22:34:08.570" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3062" PostTypeId="2" ParentId="3059" CreationDate="2019-11-15T03:05:28.237" Score="3" Body="&lt;p&gt;You can adapt the algorithm of this paper &lt;a href=&quot;https://www.researchgate.net/publication/230596635_An_Optimal_Algorithm_for_the_Traveling_Salesman_Problem_with_Time_Windows&quot; rel=&quot;nofollow noreferrer&quot;&gt;TSPTW&lt;/a&gt;. It is almost the same problem. Check these other papers cited in that &lt;a href=&quot;https://homepages.dcc.ufmg.br/~rfsilva/tsptw/&quot; rel=&quot;nofollow noreferrer&quot;&gt;site&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Bjmk8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Bjmk8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1252" LastEditorUserId="1252" LastEditDate="2019-11-15T03:11:31.310" LastActivityDate="2019-11-15T03:11:31.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3063" PostTypeId="1" AcceptedAnswerId="3066" CreationDate="2019-11-15T10:59:06.310" Score="9" ViewCount="573" Body="&lt;p&gt;In this &lt;a href=&quot;https://or.stackexchange.com/questions/506/counter-intuitive-results-in-or&quot;&gt;post&lt;/a&gt;, it was asked to describe counter intuitive results in the field of operations research.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Among the answers came up &lt;strong&gt;the more-for-less transportation paradox&lt;/strong&gt;. In essence, this paradox in transportation problems occurs when it is possible to ship more total goods for less total cost, while shipping more or equal amounts from each origin and to each destination.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This paradox has been analysed, for example &lt;a href=&quot;https://www.tandfonline.com/doi/abs/10.1080/07408179008964192?journalCode=uiie20&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2007/09/1763.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; or &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0895717711003098#br000020&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, and typically dual analysis is used to understand the paradox.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is : for teaching purposes, what would be the best way to explain this paradox in simple terms (e.g., for someone not familiar with dual analysis or even linear programming) ? What is the intuition behind the paradox ? If dual analysis provides good elements to explain the paradox, how to explain what is going on from a more physical point of view ?&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2019-11-17T22:34:50.167" Title="Intuition behind more-for-less transportation paradox?" Tags="|teaching|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3064" PostTypeId="2" ParentId="3055" CreationDate="2019-11-15T11:23:51.610" Score="2" Body="&lt;p&gt;According to you mentioned, it sounds like the Resource‐Constrained Project Scheduling Problem (RCPS). To execute such a problem with CPLEX, you have two different options. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First, develop a mixed-integer programming model and solve it using CPLEX solver.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Second, using constraint programming with CPLEX/CPO.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For the first option, some examples could be found &lt;a href=&quot;https://www.ibm.com/developerworks/community/forums/html/threadTopic?id=df83c45a-a38f-4b92-aa3c-18a055a6f4ce&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://opus4.kobv.de/opus4-zib/files/6020/Tesch_Compact_MIP_Models_for_the_RCPSP.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A nice topic on CPLEX/CPO has been explained by &lt;a href=&quot;https://www.slideshare.net/PhilippeLaborie/an-introduction-to-cp-optimizer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Philippe Laborie&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the ways to calculate the cost of transferring the material between two consecutive machines is to define a binary variable which counts the number of changeovers between tasks and equals one if task A is processed before task B on the machine M, otherwise zero. (many of MIP models contain such variable). Then, you could calculate material handling cost using this variable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be noted that, in both options, you could try developing your model in CPLEX python API and feeding that into the DOCPLEX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope it would be useful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-11-15T11:23:51.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3065" PostTypeId="2" ParentId="3063" CreationDate="2019-11-16T04:21:47.100" Score="4" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;My question is : for teaching purposes, what would be the best way to explain this paradox in simple terms ... how to explain what is going on from a more physical point of view ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;One of the easiest examples to explain and visualize is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Iron_Ore_Line#Operations&quot; rel=&quot;nofollow noreferrer&quot;&gt;iron ore trains of Sweden&lt;/a&gt;. The trains hauled by &lt;a href=&quot;https://en.wikipedia.org/wiki/Iore&quot; rel=&quot;nofollow noreferrer&quot;&gt;Iore&lt;/a&gt;-class locomotives from Riksgränsen on the national border to the Port of Narvik &lt;strong&gt;use only a fifth of the power they regenerate&lt;/strong&gt;. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Regenerative_brake#Conversion_to_electric_energy:_the_motor_as_a_generator&quot; rel=&quot;nofollow noreferrer&quot;&gt;regenerated energy&lt;/a&gt; is sufficient to power the empty trains back up to the national border. The more ore the train can carry the more electricity that can be generated on the downhill trip. Excess energy from the railway is pumped into the power grid to supply homes and businesses in the region, the railway is a net generator of electricity.&lt;/p&gt;&#xA;&lt;p&gt;Additional reading:&lt;/p&gt;&#xA;&lt;p&gt;You are referring to &lt;a href=&quot;https://or.stackexchange.com/a/507/51&quot;&gt;TheSimpliFire's answer&lt;/a&gt;, part 3:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;3.The transportation paradox, where transportation can be more costly when the number of demands/supplies is reduced.&lt;/p&gt;&#xA;&lt;p&gt;References&lt;/p&gt;&#xA;&lt;p&gt;[3] Charnes, A., Klingman, D. (1971). The more-for-less paradox in the distribution model, Cah. Cent. d’Etud. Rech. Oper. 13:11–22.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;That paper is referenced in another paper: &amp;quot;&lt;a href=&quot;http://pubs.sciepub.com/ajams/2/1/3/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Paradox Algorithm in Application of a Linear Transportation Problem&lt;/a&gt;&amp;quot; (Jan 5 2014), by Osuji George A., Opara Jude, Nwobi Anderson C., Onyeze Vitus, and Iheagwara Andrew I.:&lt;/p&gt;&#xA;&lt;p&gt;Some helpful references mentioned there are:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;... Charnes and Klingman (1971), Szwarc (1973), Adlakha and Kowalski (1998) and Storoy (2007) considered the paradoxical transportation problem. Gupta et al (1993) ... Joshi and Gupta (2010) ...&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-11-17T22:34:50.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3066" PostTypeId="2" ParentId="3063" CreationDate="2019-11-16T09:33:00.283" Score="8" Body="&lt;p&gt;While it may seem reasonable to think that costs increase when you increase production, the transportation problem only considers the costs of moving things around. As a consequence, increasing production may provide opportunity to change how things are moved around, and that may help save costs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For problems like this, is it often useful to think about an ideal situation. In the transportation problem, the ideal situation is where your supply is located as close to the demand as possible. That way, the costs of moving stuff around will be the lowest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, we may have situations where there is a lot of supply at a location where there is not enough demand, and we have to move that supply to other locations. If demand would be increased at the location where there is excess supply, and the supply would be increased at the location where there was excess demand, you can get rid of some transportation costs, because the geographic imbalance of supply and demand is reduced. This is where the paradox comes from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give a pretty clear example: if the US produces 1 unit of apples, and Europe produces 2 units of apples, while the US has demand for 2 units of apples and Europe has only demand for 1 unit of apples, it is obvious you need to transport 1 unit of apples over the Atlantic Ocean. Now suppose the US increases it production to 2 units of apples. As a consequence the necessity to transport apples over the Atlantic disappears. The Europeans will be stuck with excess apples, and to overcome this issue they will probably lower the price, increasing demand of apples within Europe to 2 units of apples as well. Thus, by increasing supply and demand, we removed the geographic imbalance between supply and demand (all are 2), saving transportation costs compared to the previous situation where an imbalance existed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, the important thing to realize is that transportation costs are caused by a locational imbalance between supply and demand. Increasing supply and demand may give you an opportunity to reduce this imbalance and thus reduce transportation costs. The intuition that costs should increase when production is increased is valid, but this only applies to the production costs themselves and not how much we need to move around.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastEditorUserId="123" LastEditDate="2019-11-16T10:02:37.617" LastActivityDate="2019-11-16T10:02:37.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3067" PostTypeId="2" ParentId="3059" CreationDate="2019-11-16T10:57:07.467" Score="13" Body="&lt;p&gt;There are a few problems in this category.&#xA;They are variants of the Travelling Salesman Problem in which you don't need to visit all customers, but can choose which ones to visit.&#xA;They fall under the general name of &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.1030.0079&quot; rel=&quot;nofollow noreferrer&quot;&gt;Travelling Salesman Problems with Profits&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main variants are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1002/1520-6750(198706)34:3%3C307::AID-NAV3220340302%3E3.0.CO;2-D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Orienteering Problem&lt;/strong&gt;&lt;/a&gt; (OP) in which you want to maximise the profit collected at visited customers, under an upper bound on the trip length.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1002/net.3230190602&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Prize-collecting TSP&lt;/strong&gt;&lt;/a&gt; in which you want to minimise the trip length, under a lower bound on the amount of profit collected.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1475-3995.1995.tb00023.x&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Profitable Tour Problem&lt;/strong&gt;&lt;/a&gt; in which instead of considering travel time, you consider travel &lt;em&gt;costs&lt;/em&gt;. In this case you can express profits collected and travel costs with the same unit of measure (say, €). The objective is to maximise the &lt;em&gt;revenue&lt;/em&gt; (= profit collected, minus travel costs).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Most of these problems also appear in the literature with variants (multi-vehicle, time windows, etc.) which are common for other &quot;classic&quot; routing problems.&#xA;For example, the multi-vehicle OP is called the &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/0377221794002894&quot; rel=&quot;nofollow noreferrer&quot;&gt;Team Orienteering Problem&lt;/a&gt; (TOP).&#xA;Adding time windows gives the &lt;a href=&quot;https://www.tandfonline.com/doi/abs/10.1057/jors.1992.88&quot; rel=&quot;nofollow noreferrer&quot;&gt;OPTW&lt;/a&gt; and &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S030505480900080X&quot; rel=&quot;nofollow noreferrer&quot;&gt;TOPTW&lt;/a&gt;.&#xA;Adding vehicle capacities gives the &lt;a href=&quot;https://www.tandfonline.com/doi/abs/10.1057/palgrave.jors.2602603&quot; rel=&quot;nofollow noreferrer&quot;&gt;Capacitated TOP&lt;/a&gt;.&#xA;Some stochastic versions include the &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1111/itor.12310&quot; rel=&quot;nofollow noreferrer&quot;&gt;TSP with Profits and Stochastic Customers&lt;/a&gt;, the &lt;a href=&quot;https://link.springer.com/article/10.1007/s10479-011-0895-2&quot; rel=&quot;nofollow noreferrer&quot;&gt;OP with stochastic travel times&lt;/a&gt; and the &lt;a href=&quot;https://www.tandfonline.com/doi/full/10.1080/07408170701592481&quot; rel=&quot;nofollow noreferrer&quot;&gt;OP with stochastic profits&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per the solution methods for the Orienteering Problem (which seems the one most suited for your question), as far as I know the state-of-the-art exact algorithm is still &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.10.2.133&quot; rel=&quot;nofollow noreferrer&quot;&gt;the one by Fischetti, Salazar-Gonzalez, and Toth&lt;/a&gt;.&#xA;In the last couple of years, new heuristics have improved on previously best-known results: a &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0305054817302241&quot; rel=&quot;nofollow noreferrer&quot;&gt;genetic algorithm&lt;/a&gt; and an &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0957417418308182&quot; rel=&quot;nofollow noreferrer&quot;&gt;ALNS&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2020-05-08T19:36:30.353" LastActivityDate="2020-05-08T19:36:30.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3069" PostTypeId="1" AcceptedAnswerId="5246" CreationDate="2019-11-18T12:02:51.513" Score="13" ViewCount="343" Body="&lt;p&gt;For many families of optimization problems there is some sort of classification scheme. I am thinking about the triple notation for machine scheduling introduced in &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S016750600870356X&quot; rel=&quot;noreferrer&quot;&gt;&quot;Optimization and approximation in deterministic sequencing and scheduling: a survey&lt;/a&gt;&quot; by Graham, Lawler, Lenstra, and Kan, or &quot;&lt;a href=&quot;http://theory.cs.uni-bonn.de/info5/steinerkompendium/netcompendium.pdf&quot; rel=&quot;noreferrer&quot;&gt;A Compendium on Steiner Tree Problems&lt;/a&gt;&quot; by Hauptmann and Karpinski. I wouldn't include something like &quot;Vehicle Routing Problems, Methods, and Applications&quot; by Toth and Vigo, as it focuses on the overview of solution techniques and not so much on a comprehensive list/system to talk about &quot;all&quot; vehicle routing problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering, if there was a survey of surveys with the scope of all operations research/combinatorial optimization problems? If not, are there any publications that try something similar (surveys/books of optimization problems with a much broader scope than the examples given)?&#xA;Or to ask the same question in different words: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What are the broadest surveys of operations research/combinatorial optimization problems?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="2453" LastEditDate="2019-11-19T09:44:40.030" LastActivityDate="2020-11-19T00:42:30.773" Title="Categorization of optimization models" Tags="|optimization|reference-request|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3070" PostTypeId="1" AcceptedAnswerId="3071" CreationDate="2019-11-18T14:46:26.280" Score="8" ViewCount="538" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://www.gnu.org/software/glpk/&quot; rel=&quot;noreferrer&quot;&gt;GLPK&lt;/a&gt; to solve an LP.&lt;br&gt;&#xA;I use it through its standalone solver, that I call with the &lt;code&gt;glpsol&lt;/code&gt; command, and I get the solution detail written in a file using the &lt;code&gt;-o&lt;/code&gt;/&lt;code&gt;--output&lt;/code&gt; option.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no problem parsing the file to recover the actual solution, but I'm wondering what is the meaning of the &quot;marginal&quot; column.&lt;br&gt;&#xA;Here is what the output file looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Problem:    &#xA;Rows:       60&#xA;Columns:    9821&#xA;Non-zeros:  405355&#xA;Status:     OPTIMAL&#xA;Objective:  obj = 1.355170551 (MINimum)&#xA;&#xA;   No.   Row name   St   Activity     Lower bound   Upper bound    Marginal&#xA;------ ------------ -- ------------- ------------- ------------- -------------&#xA;     1 r.9825       B        1.07478             1               &#xA;     2 r.17470      NL             1             1                   0.0287012 &#xA;     3 r.24250      B        1.23575             1               &#xA;     4 r.31488      NL             1             1                       &amp;lt; eps&#xA;     5 r.38796      B         1.0038             1               &#xA;     6 r.44423      B        1.03857             1               &#xA;     7 r.50832      NL             1             1                   0.0109038 &#xA;     8 r.57288      NL             1             1                   0.0233011 &#xA;// some more rows ......&#xA;&#xA;   No. Column name  St   Activity     Lower bound   Upper bound    Marginal&#xA;------ ------------ -- ------------- ------------- ------------- -------------&#xA;     1 Z1           NL             0             0                    0.233221 &#xA;     2 Z2           NL             0             0                    0.174953 &#xA;     3 Z3           NL             0             0                    0.157688 &#xA;     4 Z4           NL             0             0                    0.164336 &#xA;     5 Z5           NL             0             0                     0.20934 &#xA;     6 Z6           NL             0             0                    0.124799 &#xA;[ .... ]&#xA;   237 Z237         NL             0             0                   0.0686442 &#xA;   238 Z238         NL             0             0                    0.159257 &#xA;   239 Z239         B      0.0424075             0               &#xA;   240 Z240         NL             0             0                   0.0370097 &#xA;   241 Z241         NL             0             0                    0.324198 &#xA;[ .... ]&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The actual values I'm looking for are actually referred to as &quot;activity&quot; (my decision variables being the &lt;code&gt;Zn&lt;/code&gt;).&lt;br&gt;&#xA;But what does &lt;code&gt;marginal&lt;/code&gt; represent? And, while I'm here, why are the solution values called &lt;code&gt;activity&lt;/code&gt; (there must be a historical/theoretical reason, and I'm interested)?&lt;/p&gt;&#xA;" OwnerUserId="59" LastEditorUserId="36" LastEditDate="2019-11-18T14:54:55.590" LastActivityDate="2019-11-18T15:07:10.370" Title="GLPK: meaning of the &quot;marginal' column in the solution output" Tags="|optimization|linear-programming|solver|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3071" PostTypeId="2" ParentId="3070" CreationDate="2019-11-18T15:07:10.370" Score="8" Body="&lt;p&gt;According to &lt;a href=&quot;https://en.wikibooks.org/wiki/GLPK/Solution_information&quot; rel=&quot;noreferrer&quot;&gt;GLPK Wikibook page&lt;/a&gt;, &quot;marginal&quot; shows the &lt;em&gt;reduced cost&lt;/em&gt; of your variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About why the primal values of the variables are called activity, my guess is the following quote from the &lt;a href=&quot;http://most.ccib.rutgers.edu/glpk.pdf&quot; rel=&quot;noreferrer&quot;&gt;reference manual for GLPK&lt;/a&gt; (page 93):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... Since the variable being analyzed is non-basic, its activity, which is&#xA;  equal to its active bound, also starts changing...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-11-18T15:07:10.370" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3072" PostTypeId="1" AcceptedAnswerId="3079" CreationDate="2019-11-19T14:38:04.703" Score="14" ViewCount="3745" Body="&lt;p&gt;What are the handiest optimization parsers out there? Is COIN-OR's PyPy being used actively? I am currently trying to do an optimization project in Python, but I am used to using MATLAB + YALMIP combination, so I need some advice!&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2023-10-09T18:43:04.897" Title="YALMIP-like modeling environment in Python" Tags="|optimization|solver|python|software|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3073" PostTypeId="2" ParentId="3072" CreationDate="2019-11-19T15:06:20.053" Score="8" Body="&lt;p&gt;Handiest optimization package in python is Pyomo(in my opinion). I recommend that because of the following specifications:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There is a google group ( in addition to se and or.se) that you can ask for help if you stacked.&lt;/li&gt;&#xA;&lt;li&gt;You can use all the pythonic facilities to write your model&lt;/li&gt;&#xA;&lt;li&gt;There are enough books, tutorials and documents about it.&lt;/li&gt;&#xA;&lt;li&gt;Pyomo is an active and well developed package.&lt;/li&gt;&#xA;&lt;li&gt;You can also use many available solvers to solve your model written in Pyomo.&lt;/li&gt;&#xA;&lt;li&gt;You can easily use solvers on Neos server to solve the model.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-11-19T15:34:26.283" LastActivityDate="2019-11-19T15:34:26.283" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3074" PostTypeId="2" ParentId="3072" CreationDate="2019-11-19T15:06:25.770" Score="9" Body="&lt;p&gt;I think the two most common are &lt;a href=&quot;https://pypi.org/project/PuLP/&quot; rel=&quot;noreferrer&quot;&gt;PuLP&lt;/a&gt; and &lt;a href=&quot;http://www.pyomo.org/&quot; rel=&quot;noreferrer&quot;&gt;Pyomo&lt;/a&gt;. Some commercial solvers also have dedicated Python packages, e.g., &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/quickstart_mac/the_gurobi_python_interfac.html&quot; rel=&quot;noreferrer&quot;&gt;Gurobipy&lt;/a&gt; and &lt;a href=&quot;https://pypi.org/project/docplex/&quot; rel=&quot;noreferrer&quot;&gt;docplex&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related: &lt;a href=&quot;https://or.stackexchange.com/q/2605/38&quot;&gt;I&amp;#39;ve formulated my optimization model; now what?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2019-11-19T15:06:25.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3075" PostTypeId="2" ParentId="3018" CreationDate="2019-11-19T15:51:26.550" Score="7" Body="&lt;p&gt;&lt;strong&gt;MOSEK&lt;/strong&gt; can handle large-scale problems of a wide variety, including conic and Mixed-Integer programming problems. The &lt;em&gt;Fusion&lt;/em&gt; API provided by &lt;strong&gt;MOSEK&lt;/strong&gt; makes it straightforward to utilize the &lt;strong&gt;MOSEK&lt;/strong&gt; solver in a structured manner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the problem that you state, one can rephrase the quadratic objective function by introducing an auxiliary scalar variable &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;, as follows: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{min}&amp;amp;\quad H\\\text{s.t.}&amp;amp;\quad H \geq \sqrt{\sum_{i=1}^k \bigg( \frac{h_i}{n} - p_i\bigg)^{2}}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;while the other constraints are unchanged. I have expressed the objective in terms of the epigraph of the Euclidean norm of the vector &lt;span class=&quot;math-container&quot;&gt;$\vec{d} = \vec{(h/n)} - \vec{p}$&lt;/span&gt; that can be implemented exactly in &lt;em&gt;Fusion&lt;/em&gt; as a &lt;span class=&quot;math-container&quot;&gt;$k+1$&lt;/span&gt; dimensional quadratic cone, i.e. &lt;span class=&quot;math-container&quot;&gt;$(H,\vec{d})\in Q^{k+1}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;Fusion&lt;/em&gt; implementation for your problem could be as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;from mosek.fusion import *&#xA;&#xA;#n is the number of objects and p is the vector of ratios (size k)&#xA;def quad_int_prog(n,p):&#xA;    #Number of groups&#xA;    k = len(p)&#xA;    #Making a Mosek model&#xA;    with Model('k_groups') as M:&#xA;        #h (vector of size k): Integer and h&amp;gt;=5&#xA;        h = M.variable('h',k,Domain.integral(Domain.greaterThan(5))) &#xA;        #Auxiliary Variable (epigraph)&#xA;        H = M.variable('H',Domain.greaterThan(0))&#xA;&#xA;        #Linear Constraint: sum(h_i)=n&#xA;        M.constraint('h_sum_constraint',Expr.sum(h),Domain.equalsTo(n))&#xA;        #Conic Constraint: (H,d) belongs to Quadratic cone domain of size k+1 &#xA;        H_d_vector = Expr.vstack(H,Expr.sub(Expr.mul(1/n,h),p))&#xA;        M.constraint('Percentage_constraint',H_d_vector,Domain.inQCone(k+1))&#xA;&#xA;        #Objective: Minimize H &#xA;        M.objective('Objective',ObjectiveSense.Minimize,H)&#xA;        #Solving... (To enable log output, use M.setLogHandler(sys.stdout))&#xA;        M.solve()&#xA;        #Optimal value for h&#xA;        h_optimal = h.level()&#xA;    return(h_optimal)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Being a large-scale solver, &lt;strong&gt;MOSEK&lt;/strong&gt; can easily handle scaled up versions of the discussed model. For instance, on my desktop (with i7-6700HQ and 16 GB of RAM) I could solve a problem of the above-stated structure with &lt;span class=&quot;math-container&quot;&gt;$k=3000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n=20000$&lt;/span&gt; (with a randomly generated &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;) in about 4.23 seconds with a relative tolerance gap of less than &lt;span class=&quot;math-container&quot;&gt;$2 \%$&lt;/span&gt;. Remember, it can be crucial to set a termination criteria when dealing with Mixed-Integer problems, such as setting a tolerance gap or providing a maximum number of iterations. Moreover, I highly recommend enabling the log-output in &lt;strong&gt;MOSEK&lt;/strong&gt; (using the command &lt;code&gt;M.setLogHandler(sys.stdout)&lt;/code&gt;) because it not only tells you the progress the solver has made, but can also provide key insights into the model and the structure of your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a quick reference guide for mathematical optimization and general model building (like the rephrasing presented above using the Euclidean norm), check out the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;MOSEK&lt;/strong&gt; modelling cookbook&lt;/a&gt;. For a comprehensive guide to using &lt;em&gt;Fusion&lt;/em&gt; and/or other products that &lt;strong&gt;MOSEK&lt;/strong&gt; offers, see &lt;a href=&quot;https://www.mosek.com/documentation/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. It is possible to acquire a &lt;em&gt;free trial license&lt;/em&gt; (valid for 30 days), and a &lt;em&gt;free academic license&lt;/em&gt; (valid for 1 year) is also provided.&lt;/p&gt;&#xA;" OwnerUserId="2713" LastEditorUserId="123" LastEditDate="2019-11-19T19:55:47.500" LastActivityDate="2019-11-19T19:55:47.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3076" PostTypeId="2" ParentId="3018" CreationDate="2019-11-19T21:21:28.343" Score="5" Body="&lt;p&gt;Your problem is an &lt;em&gt;Integer Quadratic Knapsack Problem&lt;/em&gt;. Your specific problem is considered by &lt;a href=&quot;https://doi.org/10.1287/ijoc.7.1.109&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bretthauer et al.&lt;/a&gt; The book by &lt;a href=&quot;https://doi.org/10.1007/978-3-540-24777-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kellerer et al.&lt;/a&gt; is an excellent source for information on knapsack problems in general.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Modeling&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Bretthauer et al. consider the following problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{eqnarray}&#xA;\min &amp;amp; &amp;amp; \frac{1}{2} x^\top D x - a^\top x\\&#xA;s.t. &amp;amp; &amp;amp; \sum_{i=1}^n p_i x_i = c\\&#xA;&amp;amp; &amp;amp; l_i \le x_i \le u_i &amp;amp; \forall i = 1 \dots, n\\&#xA;&amp;amp; &amp;amp; x_i \in \mathbb{N}_{\ge 0} &amp;amp; \forall i = 1 \dots, n&#xA;\end{eqnarray}$$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; a diagonal matrix with positive components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left(\frac{h_i}{n} - p_i\right)^2 = \frac{1}{2} \left(\frac{2}{n^2}\right) h_i^2 - \left(\frac{2 p_i}{n}\right) h_i + p_i^2$$&lt;/span&gt;&#xA;In the optimization, we can ignore the constant &lt;span class=&quot;math-container&quot;&gt;$p_ i^2$&lt;/span&gt; and we can define &lt;span class=&quot;math-container&quot;&gt;$D_{ii} = \frac{2}{n^2}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_i = \frac{2 p_i}{n}$&lt;/span&gt; to arrive at the formulation of Bretthauer et al.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Branch and bound&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Bretthauer et al. solve this problem with branch and bound. This paper was published in 1995, and in the meantime many different algorithms have been published. This paper, and the book by Kellerer et al., however, could serve as a starting point.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Dynamic programming&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;There is a well-known dynamic programming formulation for knapsack problems. Dynamic programming is discussed in the book by Kellerer et al., and also on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Knapsack_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;knapsack Wikipedia page&lt;/a&gt;. Because the optimal &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h_j$&lt;/span&gt; are only related through the constraint, I see no reason why this dynamic program could not be adapted to your problem. The only preprocessing that is necessary is that you set all &lt;span class=&quot;math-container&quot;&gt;$h_i = 5$&lt;/span&gt; as the starting value, and adjust the remaining capacity accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be different if &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is not diagonal. In this case, we would have terms like &lt;span class=&quot;math-container&quot;&gt;$D_{ij} h_i h_j$&lt;/span&gt; in the objective, and the choice of &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt; changes how &lt;span class=&quot;math-container&quot;&gt;$h_j$&lt;/span&gt; influences the objective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Implementing the dynamic program is relatively straightforward, but it may not be fast enough for your problem size. Or it might, I simply don't know!&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2019-11-22T12:38:51.323" LastActivityDate="2019-11-22T12:38:51.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3077" PostTypeId="1" CreationDate="2019-11-20T03:48:14.647" Score="20" ViewCount="4782" Body="&lt;p&gt;I am wondering what are the fastest ways(faster than classical dynamic programming)  to solve the knapsack problem (to optimality) with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; items when &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is nearly equal to &lt;span class=&quot;math-container&quot;&gt;$10000$&lt;/span&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from classic local search, is there any heuristics that are efficient ?&#xA;Edit: I asked for both exact and approximation methods &lt;/p&gt;&#xA;" OwnerUserId="1188" LastEditorUserId="1188" LastEditDate="2019-11-20T17:52:10.230" LastActivityDate="2019-11-22T09:42:07.313" Title="Solving a knapsack problem with a lot of items" Tags="|dynamic-programming|knapsack|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3078" PostTypeId="2" ParentId="3077" CreationDate="2019-11-20T04:52:57.733" Score="9" Body="&lt;p&gt;A comprehensive comparison of different approaches to solving the knapsack problem is given in the recent paper&lt;sup&gt;1&lt;/sup&gt; by Ezugwu et al., where the authors compare the performance of the following approaches both in small size and large size problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Genetic algorithms, &lt;/li&gt;&#xA;&lt;li&gt;Simulated annealing, &lt;/li&gt;&#xA;&lt;li&gt;Branch and bound, &lt;/li&gt;&#xA;&lt;li&gt;Dynamic programming, &lt;/li&gt;&#xA;&lt;li&gt;Greedy search algorithm,&lt;/li&gt;&#xA;&lt;li&gt;Hybrid genetic algorithm-simulated annealing&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This paper can be a good start point for your search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) Ezugwu, Absalom E., et al. &quot;A Comparative Study of Meta-Heuristic Optimization Algorithms for 0–1 Knapsack Problem: Some Initial Results.&quot; IEEE Access 7 (2019): 43979-44001. &lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2019-11-20T04:52:57.733" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3079" PostTypeId="2" ParentId="3072" CreationDate="2019-11-20T07:50:12.557" Score="9" Body="&lt;p&gt;Given you are a MATLAB+Yalmip user you may prefer &lt;a href=&quot;https://www.cvxpy.org/&quot; rel=&quot;noreferrer&quot;&gt;Cvxpy&lt;/a&gt;. Cvxpy is particularly useful if you do nonlinear models. &lt;a href=&quot;https://www.mosek.com&quot; rel=&quot;noreferrer&quot;&gt;Mosek&lt;/a&gt; also includes 2 Python interfaces where the so called Fusion interface may be the most interesting for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/MOSEK/Tutorials/blob/master/wasserstein/wasserstein-bary.ipynb&quot; rel=&quot;noreferrer&quot;&gt;Here&lt;/a&gt; you find a comparison of Cvxpy, Pyomo and Fusion for some large scale problems.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2019-11-20T10:26:32.933" LastActivityDate="2019-11-20T10:26:32.933" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3080" PostTypeId="2" ParentId="3077" CreationDate="2019-11-20T09:07:50.523" Score="19" Body="&lt;p&gt;For the knapsack problem, you just use the Pisinger's code. It implements an exact algorithm, it is the fastest algorithm known in the literature, and it is open-source: &lt;a href=&quot;http://hjemmesider.diku.dk/~pisinger/codes.html&quot; rel=&quot;noreferrer&quot;&gt;http://hjemmesider.diku.dk/~pisinger/codes.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2019-11-20T09:07:50.523" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3081" PostTypeId="1" CreationDate="2019-11-20T11:19:18.547" Score="5" ViewCount="478" Body="&lt;p&gt;Consider &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; knapsack and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; items. With each knapsack &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; associated a capacity &lt;span class=&quot;math-container&quot;&gt;$c(j)$&lt;/span&gt; and with each item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; associated a profit &lt;span class=&quot;math-container&quot;&gt;$p(i,j)$&lt;/span&gt;  (that depends on the knapsack, so it's not exactly the classic multiple knapsack problem) and a weight &lt;span class=&quot;math-container&quot;&gt;$w(i)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There is a particular knapsack &lt;span class=&quot;math-container&quot;&gt;$j^*$&lt;/span&gt; with infinite capacity and for which the following condition is satisfied : &lt;span class=&quot;math-container&quot;&gt;$$\forall i \in I, p(i,j^*) =0$$&lt;/span&gt;&#xA;We assume that this knapsack has already all the items (so there is a  covering constraint that is always satisfied since the items are always there)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For a given knapsack &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, an item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; can have a profit &lt;span class=&quot;math-container&quot;&gt;$p(i,j)$&lt;/span&gt; that is either positive or negative.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;An item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; must satisfy the following &quot;presence&quot; constraints: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Can be put in more than one finite knapsack (it can be &quot;copied&quot; and put in several knapsacks so it's not the classic generalized assignment problem).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Present at most once in the same knapsack. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The objective is to choose what items to pick in order to maximize the profit while satisfying the capacity constraint for each knapsack and the presence constraints for the items. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm interested in:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Proving the complexity&lt;/li&gt;&#xA;&lt;li&gt;Finding upper-bounds: intuitively, is there a decomposition method that is suitable for this problem? If so, what is it?&lt;/li&gt;&#xA;&lt;li&gt;Finding lower-bounds: I was thinking about considering the knapsacks independently. Solving each one exactly by a DP and then assign the remaining items to the knapsack &lt;span class=&quot;math-container&quot;&gt;$j^*$&lt;/span&gt;. Do you have another heuristic?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;PS: the number of items is &lt;span class=&quot;math-container&quot;&gt;$10000$&lt;/span&gt; and the number of knapsacks is between &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$500$&lt;/span&gt; depending on the instance.&lt;/p&gt;&#xA;" OwnerUserId="1188" LastEditorUserId="123" LastEditDate="2019-11-20T19:31:19.683" LastActivityDate="2019-11-20T19:31:19.683" Title="Solving a variant of multiple knapsack problem/ generalized assignment problem" Tags="|computational-complexity|dynamic-programming|knapsack|bounds|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3082" PostTypeId="2" ParentId="3081" CreationDate="2019-11-20T15:54:00.010" Score="4" Body="&lt;p&gt;It looks like there is no relationship between different knapsacks, so you can solve this exactly as &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; independent 0-1 knapsack problems.  Also, for knapsack &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, you can eliminate any items &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; that have &lt;span class=&quot;math-container&quot;&gt;$p(i,j)\le 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-11-20T15:54:00.010" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3083" PostTypeId="2" ParentId="3077" CreationDate="2019-11-21T08:04:24.713" Score="2" Body="&lt;p&gt;You don't give that bit of information, but you might be able to use a far more efficient algorithm when knapsack size (let's call it &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;) is small enough (small enough to create an array of each possible value you could get) and all the items have positive (or zero) weight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if maximum knapsack size is &lt;span class=&quot;math-container&quot;&gt;$10^7$&lt;/span&gt; units, you could easily create an array of that size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way you go from &lt;span class=&quot;math-container&quot;&gt;$O(2^n)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$O(S\cdot n)$&lt;/span&gt;. I believe that would be called memoization (I can paste my implementation if that's what you're looking for).&lt;/p&gt;&#xA;" OwnerUserId="2720" LastEditorUserId="2720" LastEditDate="2019-11-22T09:42:07.313" LastActivityDate="2019-11-22T09:42:07.313" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3084" PostTypeId="2" ParentId="3047" CreationDate="2019-11-21T19:36:00.707" Score="2" Body="&lt;p&gt;Since you are assuming infinite capacity, this sounds like an &lt;a href=&quot;https://en.wikipedia.org/wiki/M/M/%E2%88%9E_queue&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$M/M/\infty$&lt;/span&gt; queueing system&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-11-21T19:36:00.707" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3085" PostTypeId="2" ParentId="3018" CreationDate="2019-11-22T12:53:07.657" Score="6" Body="&lt;p&gt;As the &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt; are integers, you can reformulate your problem as a Mixed Integer Linear Program. Here's how:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$c_i^m = \left(\frac{m}{n} - p_i\right)^2$&lt;/span&gt; denote the penalty that is received when assigning &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; items to group &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Now introduce binary decision variables &lt;span class=&quot;math-container&quot;&gt;$x_i^m$&lt;/span&gt; that are equal to 1 if &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; items are assigned to group &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and 0 otherwise. As you have a constraint stating that at least 5 items must be assigned to every group and there are &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; groups, you need to define these variables for &lt;span class=&quot;math-container&quot;&gt;$5\leq m \leq n - 5(k-1)$&lt;/span&gt; (EDIT: you can probably find much better bounds. For example, suppose that &lt;span class=&quot;math-container&quot;&gt;$\lfloor{p_in\rfloor}\geq 5$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, then it is never optimal to assign less than &lt;span class=&quot;math-container&quot;&gt;$\lfloor{p_in\rfloor}$&lt;/span&gt; objects to group &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, your problem is equivalent to &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min \quad &amp;amp;\sum_{i=1}^k \sum_{m=5}^{n-5(k-1)} c_i^mx_i^m, \\&#xA;\text{s.t.} \quad &amp;amp;\sum_{m=5}^{n-5(k-1)} x_i^m =1 \quad&amp;amp;&amp;amp;\forall i, \\&#xA;&amp;amp;\sum_{i=1}^k \sum_{m=5}^{n-5(k-1)} mx_i^m = n, \\&#xA;&amp;amp;x_i^m \in \{0,1\} \quad &amp;amp;&amp;amp;\forall i,m. &#xA;\end{align}&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first constraint makes sure that for each group, only one number of items can be assigned. The second constraint guarantees that in total &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; items are assigned. Given that your problem has such simple structure (I imagine a rounding approach would perform well), I'm pretty sure this is not the most efficient way to solve your problem, but at least you can implement it easily as a MIP in Python. &lt;/p&gt;&#xA;" OwnerUserId="764" LastEditorUserId="764" LastEditDate="2019-11-22T15:08:01.327" LastActivityDate="2019-11-22T15:08:01.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3086" PostTypeId="1" AcceptedAnswerId="3089" CreationDate="2019-11-22T13:35:01.070" Score="7" ViewCount="245" Body="&lt;p&gt;I have the decision variable &lt;span class=&quot;math-container&quot;&gt;$X_{iz}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I have two parameters &lt;span class=&quot;math-container&quot;&gt;$T_i\in\{0,1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$IT_z\in\{0,1,2\}$&lt;/span&gt;. I can only assign &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; if the following holds:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;for &lt;span class=&quot;math-container&quot;&gt;$T_i=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$IT_z$&lt;/span&gt; needs to be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;for &lt;span class=&quot;math-container&quot;&gt;$T_i=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$IT_z$&lt;/span&gt; needs to be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;So for every value of &lt;span class=&quot;math-container&quot;&gt;$T_i$&lt;/span&gt;, a value of &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$IT_z$&lt;/span&gt; must satisfy the constraint&lt;/li&gt;&#xA;&lt;li&gt;Or &lt;span class=&quot;math-container&quot;&gt;$T_i$&lt;/span&gt; needs to be equal to &lt;span class=&quot;math-container&quot;&gt;$IT_z$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I cannot seem to figure out how to make a valid constraint for this problem, any tips?&lt;/p&gt;&#xA;" OwnerUserId="2555" LastEditorUserId="2555" LastEditDate="2019-11-22T19:30:40.410" LastActivityDate="2019-11-22T20:09:35.067" Title="Linear constraint formulation (OR-statement)" Tags="|linear-programming|integer-programming|constraint|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3087" PostTypeId="2" ParentId="3086" CreationDate="2019-11-22T13:46:39.273" Score="2" Body="&lt;p&gt;Introduce a new binary variable &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; and linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;-z_i \le \text{IT}_i - \text{T}_i &amp;amp;\le 2 z_i \\&#xA;\text{IT}_i &amp;amp;\ge 2 z_i&#xA;\end{align}&lt;/span&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$z_i=0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\text{IT}_i = \text{T}_i$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$z_i=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\text{IT}_i \ge 2$&lt;/span&gt;, hence &lt;span class=&quot;math-container&quot;&gt;$=2$&lt;/span&gt;. &lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2019-11-22T15:04:35.047" LastActivityDate="2019-11-22T15:04:35.047" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="3088" PostTypeId="1" AcceptedAnswerId="3090" CreationDate="2019-11-22T18:36:43.477" Score="7" ViewCount="219" Body="&lt;p&gt;Can you help me figure out if this formulation constitutes a non-linear problem? I believe It is a linear problem but my solver (GAMS) is unable  to produce a acceptable solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x,y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\text{state}$&lt;/span&gt; are variables and the rest are parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{n=1}^{N}\left[\sum\limits_{i=1}^{T}x_{n,i}\cdot p_{i}-y_{n,i}\cdot p_{i}\right]$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \forall_{n} \forall_{i} x_{n,i},y_{n,i}\geq 0  \wedge x_{n,i},y_{n,i}\leq M_{n} $&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall_{n} \forall_{i} \text{state}_{n,i}=\text{state}_{n,i-1}+y_{n,i}-x_{n,i}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \forall_{n} \forall_{i} \text{statemin}_{n} \leq \text{state}_{n,i} \leq \text{statemax}_{n}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \text{flow}_{l,i} = A \cdot K_{i}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \text{flow}_{l,i} \leq \text{fmax}_{l}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ K_{i} = L_{i} - (G_{i} + y_{i} - x_{i})$&lt;/span&gt;    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$N \times N$&lt;/span&gt; matrix.&#xA;Any feedback is appreciated,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The GAMS code is the following: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;** Define the structure to connect with the matlab code&#xA;*&lt;span class=&quot;math-container&quot;&gt;$onempty&#xA;$&lt;/span&gt;include matglobs.gms&#xA;&#xA;set      t /1*%timeSteps%/,&#xA;         b /1*%bus%/,&#xA;         l /1*%lines%/&#xA;         ;&#xA;&#xA;Positive Variable x(b,t),&#xA;                  y(b,t)&#xA;                  state(b,t)&#xA;                  ;&#xA;&#xA;Free Variable    res, unit(b), revenue, flow(l,t), K(b,t);&#xA;&#xA;parameters       size(b), rate(b), fmax(l), P(b,t), A(l,b), price(t);&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;$if exist matdata.gms $&lt;/span&gt;include matdata.gms&#xA;&#xA;Equations&#xA;&#xA;stateCalc1(b,t)&#xA;stateCalc2(b,t)&#xA;Initial_y(b,t)&#xA;Initial_x(b,t)&#xA;stateMax(b,t)&#xA;stateMin(b,t)&#xA;&#xA;max_x(b,t)&#xA;max_y(b,t)&#xA;&#xA;K_Calc(b,t)&#xA;flow_Calc(l,t)&#xA;lim_K(l,t)&#xA;&#xA;Con10(b)&#xA;Con11&#xA;Obj&#xA;;&#xA;&#xA;stateCalc1(b,t)&lt;span class=&quot;math-container&quot;&gt;$(ord(t)=1)..      state(b,t) =e= size(b)/2;&#xA;stateCalc2(b,t)$&lt;/span&gt;(ord(t)&amp;gt;1)..      state(b,t) =e= state(b,t-1) + y(b,t) - x(b,t);&#xA;&#xA;Initial_y(b,t)&lt;span class=&quot;math-container&quot;&gt;$(ord(t)=1)..           y(b,t) =e= 0;&#xA;Initial_x(b,t)$&lt;/span&gt;(ord(t)=1)..           x(b,t) =e= 0;&#xA;&#xA;stateMax(b,t)..                   state(b,t) =l= size(b);&#xA;stateMin(b,t)..                   state(b,t) =g= 0;&#xA;&#xA;max_x(b,t)..        x(b,t) =l= rate(b)*size(b); &#xA;max_y(b,t)..        y(b,t) =l= rate(b)*size(b);&#xA;&#xA;&#xA;K_Calc(b,t)..       K(b,t) =e= P(b,t)+y(b,t)-x(b,t);&#xA;flow_Calc(l,t)..    flow(l,t) =e= sum(b, A(l,b)*K(b,t));&#xA;lim_K(l,t)..        flow(l,t) =l= fmax(l);&#xA;&#xA;Con10(b)..               sum(t, x(b,t)*price(t) - y(b,t)*price(t)) =e= unit(b);&#xA;Con11..                  sum(b, unit(b)) =e= revenue;&#xA;&#xA;Obj..                    revenue =e= res;&#xA;&#xA;Model Opt_Bat /all/;&#xA;&#xA;Solve Opt_Bat using LP maximazing res;&#xA;&#xA;Display state.l, size;&#xA;&#xA;$libinclude matout res.l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To be noted that &lt;span class=&quot;math-container&quot;&gt;$M_{n} = size_{n} * rate_{n}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastEditorUserId="2736" LastEditDate="2019-11-23T12:27:23.417" LastActivityDate="2019-11-23T12:27:23.417" Title="Is this formulation linear or non-linear?" Tags="|linear-programming|nonlinear-programming|gams|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3089" PostTypeId="2" ParentId="3086" CreationDate="2019-11-22T20:09:35.067" Score="5" Body="&lt;p&gt;For the new problem description, it seems like you just want to fix &lt;span class=&quot;math-container&quot;&gt;$X_{i,z}=0$&lt;/span&gt; for some disallowed &lt;span class=&quot;math-container&quot;&gt;$(i,z)$&lt;/span&gt; pairs. An even better approach is to avoid defining &lt;span class=&quot;math-container&quot;&gt;$X_{i,z}$&lt;/span&gt; in those cases.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-11-22T20:09:35.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3090" PostTypeId="2" ParentId="3088" CreationDate="2019-11-23T00:34:43.483" Score="6" Body="&lt;p&gt;The model you describe is linear. There are a couple of reasons why GAMS wouldn't like it though: (I) did you define the right solver for your problem? and (ii) GAMS initialises any uninitiated variables to 0 - it then proceeds to evaluate all constraints at the initial values before sending the problem to a solver. If the initial values are infeasible (including the implicit 0 values), then GAMS will refuse to solve your model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possibility for what you report is that your problem is integer, in which case there can be multiple solutions unless you specify that you desire a very small MIP gap for convergence.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-11-23T00:34:43.483" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="3091" PostTypeId="1" AcceptedAnswerId="4506" CreationDate="2019-11-23T10:05:52.833" Score="11" ViewCount="623" Body="&lt;p&gt;I am using CPLEX's 12.9 auto-Benders decomposition feature (from the CPLEX Java API). Following the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/benders/parameterBenders.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; I let CPLEX decide the decomposition strategy as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// model is an IloCplex object and is currently modeling a MIP problem.&#xA;// The following lets Cplex decide how to decompose the problem.&#xA;model.setParam(IloCplex.Param.Benders.Strategy,IloCplex.BendersStrategy.Full);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works, and in the output to screen I read&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CPXPARAM_Benders_Strategy                        3&#xA;CPXPARAM_Simplex_Tolerances_Feasibility          9.9999999999999995e-08&#xA;CPXPARAM_MIP_Tolerances_MIPGap                   9.9999999999999995e-07&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Benders cuts applied:  120&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I cannot manage to access that number 120. I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model.getNcuts(IloCplex.CutType.Benders);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it returns 0.&#xA;So my question is: How do I access the number of Benders cuts? And is there a way to tell optimality and feasibility cuts apart?&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="237" LastEditDate="2020-02-03T13:52:46.470" LastActivityDate="2020-07-09T21:14:05.720" Title="CPLEX Auto-Benders: How do I get the number of optimality and feasibility cuts?" Tags="|cplex|benders-decomposition|java|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3093" PostTypeId="5" CreationDate="2019-11-24T16:35:18.150" Score="0" Body="" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-11-24T16:35:18.150" LastActivityDate="2019-11-24T16:35:18.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3094" PostTypeId="4" CreationDate="2019-11-24T16:35:18.150" Score="0" Body="Questions related to the IBM Decision Optimization CPLEX (docplex) which is designed for modeling and solving optimization problems in Python. " OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-11-24T16:35:18.150" LastActivityDate="2019-11-24T16:35:18.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3095" PostTypeId="5" CreationDate="2019-11-24T17:41:29.117" Score="0" Body="" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-11-24T17:41:29.117" LastActivityDate="2019-11-24T17:41:29.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3096" PostTypeId="4" CreationDate="2019-11-24T17:41:29.117" Score="0" Body="For questions about non-convex optimization problems where the objective or any of the constraints are non-convex." OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-11-24T17:41:29.117" LastActivityDate="2019-11-24T17:41:29.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3097" PostTypeId="1" CreationDate="2019-11-24T17:44:11.450" Score="11" ViewCount="474" Body="&lt;p&gt;I recently completed an undergraduate course in Linear Programming and Operations Research. I am willing to look into advanced concepts and Non-Linear Optimization algorithms and also, their method of implementation using a programming language/toolbox. I would be glad if I am guided towards specific resources.&lt;/p&gt;&#xA;" OwnerUserId="2742" LastEditorUserId="36" LastEditDate="2019-11-24T18:47:24.220" LastActivityDate="2019-11-30T09:20:13.893" Title="Suggested Resources for Non-Linear Optimization" Tags="|optimization|reference-request|nonlinear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3098" PostTypeId="5" CreationDate="2019-11-24T18:40:31.530" Score="0" Body="" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-11-24T18:40:31.530" LastActivityDate="2019-11-24T18:40:31.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3099" PostTypeId="4" CreationDate="2019-11-24T18:40:31.530" Score="0" Body="For questions related to the knapsack problem that seeks to find the number of each item to include in a  limited container (in an integer knapsack or whether to include an item in a binary knapsack), given each item's weight and value, with the goal of maximizing the total value. " OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-11-24T18:40:31.530" LastActivityDate="2019-11-24T18:40:31.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3100" PostTypeId="1" AcceptedAnswerId="3101" CreationDate="2019-11-24T18:45:41.507" Score="8" ViewCount="269" Body="&lt;p&gt;I am working on a problem involving the average number of jobs &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; in an M/M/1 queue with arrival rate &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;, service rate &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;. For traffic intensity &lt;span class=&quot;math-container&quot;&gt;$\rho = \frac{\lambda}{\mu}$&lt;/span&gt;,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;L = \frac{\rho}{1 - \rho} = \frac{\lambda}{\mu - \lambda}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to assess if &lt;span class=&quot;math-container&quot;&gt;$L(\lambda, \mu)$&lt;/span&gt; is jointly convex, so I started by finding the Hessian &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; of the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;H = \begin{bmatrix}&#xA;\frac{2\lambda}{(\mu-\lambda)^3} + \frac{2}{(\mu-\lambda)^2} &amp;amp; -\frac{2\lambda}{(\mu-\lambda)^3} - \frac{1}{(\mu-\lambda)^2} \\&#xA;-\frac{2\lambda}{(\mu-\lambda)^3} - \frac{1}{(\mu-\lambda)^2} &amp;amp; \frac{2\lambda}{(\mu-\lambda)^3}&#xA;\end{bmatrix}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I understand, my next step should be to assess the value of the function &lt;span class=&quot;math-container&quot;&gt;$\vec{x}^TH\vec{x}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\vec{x} = \begin{bmatrix}\lambda \\ \mu\end{bmatrix}$&lt;/span&gt; over the feasible region (which is &lt;span class=&quot;math-container&quot;&gt;$\lambda, \mu \ge 0, \mu \gt \lambda$&lt;/span&gt;). However, through factoring and simplification I found that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{bmatrix}\lambda &amp;amp; \mu\end{bmatrix}&#xA;\begin{bmatrix}&#xA;\frac{2\lambda}{(\mu-\lambda)^3} + \frac{2}{(\mu-\lambda)^2} &amp;amp; -\frac{2\lambda}{(\mu-\lambda)^3} - \frac{1}{(\mu-\lambda)^2} \\&#xA;-\frac{2\lambda}{(\mu-\lambda)^3} - \frac{1}{(\mu-\lambda)^2} &amp;amp; \frac{2\lambda}{(\mu-\lambda)^3}&#xA;\end{bmatrix}\begin{bmatrix}\lambda \\ \mu\end{bmatrix}&#xA;= 0.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This indicates the matrix &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; is both positive semidefinite and negative semidefinite which in turn means &lt;span class=&quot;math-container&quot;&gt;$L(\lambda, \mu)$&lt;/span&gt; is both convex and concave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this correct or am I missing something here? Either my computations or my intuitions are flawed because I thought only linear functions could be both convex and concave. And if it is correct, are there any implications that would disallow me from having &lt;span class=&quot;math-container&quot;&gt;$L(\lambda, \mu)$&lt;/span&gt; as the objective in a convex optimization problem? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="482" LastEditorUserId="482" LastEditDate="2019-11-24T19:08:13.363" LastActivityDate="2019-11-24T19:30:13.887" Title="Convexity/Concavity of Average Number of Jobs in M/M/1 Queue?" Tags="|convexity|queuing-theory|convex-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3101" PostTypeId="2" ParentId="3100" CreationDate="2019-11-24T19:30:13.887" Score="9" Body="&lt;p&gt;Your calculations (factoring and simplification) are incorrect. &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is neither convex nor concave as a function of &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be concluded by examining the eigenvalues of the Hessian of &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; with respect to &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;. I used MAPLE to compute the Hessian, and then evaluate its eigenvalues at the point &lt;span class=&quot;math-container&quot;&gt;$\lambda = 0.5,  \mu = 1$&lt;/span&gt;. The eigenvalues are 24.649 and -0.649. This shows that the Hessian is indefinite at that point, and therefore that &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is neither convex nor concave at that point, or in general.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2019-11-24T19:30:13.887" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3102" PostTypeId="2" ParentId="3097" CreationDate="2019-11-24T22:00:55.493" Score="11" Body="&lt;p&gt;There are plenty of courses and books out there.&#xA;For convex optimization I'd take a look into Boyd's &amp;amp; Vandenberghe's lecture which also has a &lt;a href=&quot;https://web.stanford.edu/~boyd/cvxbook/bv_cvxbook.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;good accompanying script&lt;/a&gt;.&#xA;The &lt;a href=&quot;https://www2.isye.gatech.edu/~nemirovs/Lect_ModConvOpt.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;lecture/book&lt;/a&gt; from Nemirovsky &amp;amp; Ben-Tal is also very good.&#xA;If you are looking into algorithms that can be used for general (non-convex) problems, you might want for example look into the &lt;a href=&quot;https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-252j-nonlinear-programming-spring-2003/lecture-notes/&quot; rel=&quot;nofollow noreferrer&quot;&gt;nonlinear programming course at MIT by Bertsekas&lt;/a&gt;.&#xA;There are more advanced topics like optimization with differential equations or the interplay of optimization methods and machine/deep learning. But I'd start out with the more general ones before going into the more advanced ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a personal note, I advise you to also look at the discrete part of OR, i.e. the Mixed-Integer Programming world which is a nice advanced topic which you could explore coming from linear programming. The interplay of mixed-integer and nonlinear problems is even more advanced (and interesting).&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="123" LastEditDate="2019-11-30T09:20:13.893" LastActivityDate="2019-11-30T09:20:13.893" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3103" PostTypeId="1" AcceptedAnswerId="3108" CreationDate="2019-11-25T14:56:56.847" Score="9" ViewCount="1776" Body="&lt;p&gt;I would like to know what are some best practices in designing a solver implementation with Object Oriented Programming. We have implemented a solver with procedural programming paradigm, using python, and therefore we have data structures and functions written all in one python file. The solver works and is adding value to the organization. But now that we have to maintain and scale the code, (as always developing is just 20% of work load, maintenance is where 80% is) we are stumbling upon the need to design the solution with clear separation of model, data, algorithm, and reporting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help shed some light on how to do this the best way?&lt;/p&gt;&#xA;" OwnerUserId="2748" LastActivityDate="2019-11-25T23:48:24.300" Title="Implementing solvers with Object Oriented Programming" Tags="|solver|python|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="3104" PostTypeId="1" AcceptedAnswerId="3106" CreationDate="2019-11-25T15:30:35.057" Score="10" ViewCount="988" Body="&lt;p&gt;GUB/SOS1 branching is an old and well-known idea (&lt;a href=&quot;https://homepages.cae.wisc.edu/~linderot/classes/ie418/lecture4.pdf&quot; rel=&quot;noreferrer&quot;&gt;see for example page 9 of Jeff Linderoth's notes&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this implemented in commercial solvers these days? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.gurobi.com/wp-content/plugins/hd_documentations/documentation/9.0/refman.pdf&quot; rel=&quot;noreferrer&quot;&gt;Gurobi documentation&lt;/a&gt; mentions SOS1 constraints, but never mentions SOS1 branching.&lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="123" LastEditDate="2019-11-25T19:30:52.713" LastActivityDate="2019-12-02T20:07:06.053" Title="Do solvers use GUB/SOS1 branching?" Tags="|mixed-integer-programming|solver|branch-and-bound|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3105" PostTypeId="2" ParentId="3104" CreationDate="2019-11-25T16:20:08.960" Score="9" Body="&lt;p&gt;If you accept non-commercial solvers too, then &lt;a href=&quot;https://scip.zib.de/doc-6.0.2/html/RN32.php&quot; rel=&quot;noreferrer&quot;&gt;SCIP&lt;/a&gt; seems to have it. From the link:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;constraints/sos1/branchingrule&lt;/code&gt; to decide whether to use neighborhood, bipartite, or SOS1 branching...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;AIMMS also seems to have a mention of SOS1 branching according to page 9 of &lt;a href=&quot;https://download.aimms.com/aimms/download/manuals/AIMMS3OM_IntegerProgrammingTricks.pdf&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; manual. &lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-11-25T16:20:08.960" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3106" PostTypeId="2" ParentId="3104" CreationDate="2019-11-25T16:55:17.480" Score="6" Body="&lt;p&gt;I found in the IBM website that: &lt;strong&gt;CPLEX&lt;/strong&gt; automatically converts SOS1 constraints on binary variables into a regular set packing constraint(&lt;a href=&quot;https://www.ibm.com/developerworks/community/forums/html/topic?id=0eb262af-1bc0-4506-9ab4-d4410ab8ee7c&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On page 80 of &lt;a href=&quot;http://egon.cheme.cmu.edu/ewo/docs/LinderothJan07.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; presentation by Jeff Linderoth, it is mentioned that some noncommercial solvers like &lt;strong&gt;CBC&lt;/strong&gt; and &lt;strong&gt;Ip_solve&lt;/strong&gt; SOS(2) branching while &lt;strong&gt;CBC&lt;/strong&gt; and &lt;strong&gt;MINTO&lt;/strong&gt; equipped with GUB branching.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2019-12-02T20:07:06.053" LastActivityDate="2019-12-02T20:07:06.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3107" PostTypeId="1" CreationDate="2019-11-25T18:01:25.753" Score="7" ViewCount="90" Body="&lt;p&gt;I have the following optimization problem: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\min &amp;amp;\quad A(t)\cdot x(t)-B(t)\cdot y(t)+C(t)\cdot z(t)-D(t)\cdot k(t)\\\text{s.t.}&amp;amp;\quad z(t)+z_1(t)-y(t)-y_1(t)+x(t) = k(t);&amp;amp; \lambda(t)\\&amp;amp;\quad0 \le x(t) \le \bar{X};&amp;amp; \mu^1(t),\mu^2(t)\\&amp;amp;\quad0 \le k(t) \le \bar{K};&amp;amp; \mu^3(t),\mu^4(t)\\&amp;amp;\quad0 \le y(t) \le \bar{Y};&amp;amp; \mu^5(t),\mu^6(t)\\&amp;amp;\quad0 \le z(t) \le \bar{Z};&amp;amp; \mu^7(t),\mu^8(t)\\&amp;amp;\quad0 \le e(t) \le \bar{E};&amp;amp; \mu^9(t),\mu^{10}(t)\\&amp;amp;\quad e(t) = e(t-1)-(z+z_1)+\beta(y+y_1);&amp;amp;\mu^{11}(t)\\&amp;amp;\quad e(1) = 0;&amp;amp;\mu^{12}(t)\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The dual variables are listed against each equation. All the capital letters and letters under the bar are parameters and the rest are variables. Then, I derive the KKT optimality conditions for this problem by taking the Lagrangian. When I take the derivative of the Lagrangian w.r.t &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;, I get the following primal feasibility conditions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2-\lambda(t)+\mu^{11}(t) &amp;amp;= 0 \tag1\\\lambda(t)-\beta\cdot\mu^{11}(t) &amp;amp;= 0 \tag2\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where, &lt;span class=&quot;math-container&quot;&gt;$\beta = 0.85$&lt;/span&gt;. My question is - what does it mean to have one dual variable (&lt;span class=&quot;math-container&quot;&gt;$\lambda(t)$&lt;/span&gt; in this case) equating to two different values as shown in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="123" LastEditDate="2019-11-25T19:37:46.493" LastActivityDate="2019-11-25T19:37:46.493" Title="KKT conditions validation- one dual variable equating to two values" Tags="|optimization|kkt-conditions|dual|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3108" PostTypeId="2" ParentId="3103" CreationDate="2019-11-25T19:03:31.637" Score="11" Body="&lt;p&gt;I'm not sure there is any &quot;best way&quot;, but I can speak to personal practice (using Java, which is inherently object oriented). I will typically have one class that represents the &quot;problem&quot; (including data). If the data for the problem instance is drawn from an XML file, a text file, a database connection or whatever, I'll use a separate class for the data import. Next, I'll have a model class, whose constructor receives the problem class as an argument. The model class has the various CPLEX constructs (CPLEX model, variables, constraints, objective, ...) as fields, along with any structures that facilitate accessing them. (For instance, I might have two maps, one mapping model objects to CPLEX variables and the other doing the reverse mapping.) If the model involves callbacks, I'll usually make them subclasses of the model class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the algorithm just consists of calling the solve() method for the CPLEX object in the model class, I'll make solving a method in the model class. If it is more complicated (initial heuristics, looping through modifications of the model, ...), I'll create a separate solver class that accesses the model class and does all that stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the problem is sufficiently complicated, or if I want to be able to seed the algorithm with starting solutions from other runs, I'll create a separate solution class, which holds the solution (typically in terms understandable by the problem class, so storing &quot;number of vehicles = ...&quot; rather than &quot;IloNumVar nveh = ...&quot;). If solutions need to be read from and/or written to files of a particular type (XML, JSON, CSV) or a database, I'll use a separate class for that I/O.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the user gets to set algorithm parameters (including CPLEX parameters), I typically put those in a class of their own, along with a mechanism to import and export them. That helps with reproducibility and cuts user time if the user wants to reuse parameter settings repeatedly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a GUI, that will, of course, be a class of its own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I adhere to a couple of general practices. If anything (problem data, solutions, parameters) is read from or written to external sources, I try to make the relevant field names (column headings in a CSV file, database field names, ...) text data, either static string values in the relevant class or text resources read from a text file that is part of the source code. That way, if someone mucks with one of the names, I can tweak one line of source code or one line in a text resource file, and not run around looking for every place in the code where that name is used (inevitably missing one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, when specifying the APIs for each class, I try to be as minimalist/vague/general as possible. So the problem class provides accessors to give the model class what it needs to know, but only what it really needs, and at more or less the most general level possible. As one example of that last point, if the model class needs to know the arcs in a network model, the problem class (which is where the network details are stored) will ideally return a Collection of arcs, not a HashSet or ArrayList. (In Java, both HashSet and ArrayList are subclasses of Collection.) That way, if something changes and I find myself needing to alter how the arcs are stored in the problem class, I don't have to worry about breaking any code in the model class.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="36" LastEditDate="2019-11-25T20:17:13.420" LastActivityDate="2019-11-25T20:17:13.420" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3109" PostTypeId="2" ParentId="231" CreationDate="2019-11-25T21:21:41.547" Score="2" Body="&lt;p&gt;For Gurobi, based on the material presented &lt;a href=&quot;https://www.gurobi.com/resource/numerical-issues-webinar/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, there are numerical issues associated with Big-M &lt;em&gt;since the real numbers are not really real in computer&lt;/em&gt;. To solve these issues, you should use &lt;em&gt;SOS or General Implication&lt;/em&gt; constraints, however,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The price that you'll be paying is extra computing time.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Based on my personal experience, it significantly increases the time to the point that I discarded the indicator constraints and went with Big-M, which I had a pretty good idea of its bound and it was in the order of 1000.&lt;/p&gt;&#xA;" OwnerUserId="2735" LastActivityDate="2019-11-25T21:21:41.547" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3110" PostTypeId="1" AcceptedAnswerId="3111" CreationDate="2019-11-25T21:44:42.607" Score="9" ViewCount="584" Body="&lt;p&gt;While I do understand the general workings of the Big-M-method I am struggling with the following sample exercise, in which the Big-M-method has to be used to find a first feasible solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\max&amp;amp;\quad 10x_1+4x_2\\\text{s.t.}&amp;amp;\quad x_1+x_2+x_3=4\tag1 \\&amp;amp;\quad 2x_1-x_2-x_4=2\tag2\\&amp;amp;\quad -x_1+x_5=-1\tag3\\&amp;amp;\quad x_1+x_3-x_4+x_5=4\tag4\\&amp;amp;\quad x_1,\cdots,x_5 \geq 0\tag5\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure how to introduce the artificial variable for the Big-M. The only problem here seems to be the negative value on the right side of equation #3. So I would multiply with &lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt;. Now it looks as though we have a negative slack variable &lt;span class=&quot;math-container&quot;&gt;$x_5$&lt;/span&gt; which would allow us to add another variable &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; as part of the Big-M-Method. But I doubt if &lt;span class=&quot;math-container&quot;&gt;$x_5$&lt;/span&gt; can be considered a slack variable here since it is given as part of the task and is also specified as &lt;span class=&quot;math-container&quot;&gt;$\geq 0$&lt;/span&gt;.&#xA;So I just need to know if I am on the wrong track and if so, how to introduce the Big-M the right way&lt;/p&gt;&#xA;" OwnerUserId="2752" LastEditorUserId="2752" LastEditDate="2019-11-26T17:56:02.213" LastActivityDate="2019-11-26T17:56:02.213" Title="Introducing a big M variable in given equations" Tags="|linear-programming|big-m|simplex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3111" PostTypeId="2" ParentId="3110" CreationDate="2019-11-25T22:08:06.133" Score="4" Body="&lt;p&gt;All your constraints are equality. So, add an artificial variable to each constraint (let's call them &lt;span class=&quot;math-container&quot;&gt;$a_i \quad i\in\{1,..,4\}$&lt;/span&gt;). Now all these artificial variables need to be in the objective function with a coefficient of Big-M. Since you are maximizing, you want to make sure using any of them will penalize your objective function (so, you add them with negative sign). So, your objective function becomes:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \max \quad 10x_1 +4x_2 - Ma_1 - Ma_2 - Ma_3 - Ma_4$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The artificial variables play the role of your initial basis. So, you need to standardize your simplex table and make sure they are zero in the objective row. After doing that, just solve the simplex problem as you normally do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you like to check a simple example, take a look at &lt;a href=&quot;http://www.columbia.edu/~cs2035/courses/ieor3608.F05/david-bigM.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this example&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-11-25T22:08:06.133" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3112" PostTypeId="2" ParentId="3104" CreationDate="2019-11-25T23:18:34.013" Score="2" Body="&lt;p&gt;It's actually quite common, on top of what other people mentioned, I believe MINOTAUR and Couenne support that too, and as of the December release, so will Octeract Engine.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2019-11-25T23:23:49.873" LastActivityDate="2019-11-25T23:23:49.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3113" PostTypeId="2" ParentId="3103" CreationDate="2019-11-25T23:48:24.300" Score="6" Body="&lt;p&gt;The abstractions necessary to describe the components are fairly straightforward in optimisation, i.e., problem, function, variable, constraint, linear function, nonlinear function, Jacobian, Hessian of Lagrangian, and so on. A great open source example of how this can be modelled is the MINOTAUR solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can tell you from experience (this is my job) that in an OOP design you will struggle with two things, especially if your solver is parallel: (i) keeping track of the states/exit conditions of the solver, and (ii) global variables. The latter is unfortunately an integral part of achieving high performance (by caching and taking shortcuts), and requires masterful design to get rid of. As a rule of thumb, it took one of our developers about 5 months of full time work to get rid of all global variables in our solver (C++) by redesigning a bunch of components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My recommendation on this would be to identify the performance critical data structures in your solver in advance, by taking into account memory complexity, cache efficiency, and insertion/lookup operations, so that your OOP design incorporates how to handle them well from the very first design. Otherwise, you will enter a long vicious cycle of micro-optimisations that interfere with good design practices and code readability.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-11-25T23:48:24.300" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3114" PostTypeId="1" AcceptedAnswerId="3130" CreationDate="2019-11-26T08:07:33.370" Score="8" ViewCount="5626" Body="&lt;p&gt;Python does not identify the academic version of CPLEX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Linux, Ubuntu. I have Python 3.6. I installed CPLEX studio 12.9 (academic version installed via the file &lt;code&gt;cplex_studio129.linux-x86-64.bin&lt;/code&gt; that I downloaded from &lt;code&gt;ibm.biz/CPLEXonAI&lt;/code&gt;) installed at &lt;code&gt;\opt&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also installed the file &lt;code&gt;setup.py&lt;/code&gt; that is available in &lt;code&gt;/opt/ibm/ILOG/CPLEX_Studio129/cplex/python/3.7/x86-64_linux&lt;/code&gt;, using the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With all those, when I run my code in PyCharm, or in Terminal, I get: &lt;code&gt;CPLEX Error  1016: Community Edition. Problem size limits exceeded. Purchase at https://ibm.co/2s0wqSa.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found some similar questions, with helps suggesting to do correct the &lt;code&gt;PYTHONPATH&lt;/code&gt;, but I could not understand what to do actually.&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2019-11-26T09:05:00.390" LastActivityDate="2019-11-29T06:58:59.023" Title="Python does not identify the academic version of CPLEX" Tags="|cplex|python|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3115" PostTypeId="1" AcceptedAnswerId="3150" CreationDate="2019-11-26T15:56:29.610" Score="3" ViewCount="1527" Body="&lt;p&gt;I have a &lt;span class=&quot;math-container&quot;&gt;$16\times11$&lt;/span&gt; matrix and want to find all &lt;strong&gt;eligible*&lt;/strong&gt; combinations of this matrix including always entities from all 11 columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple example from a &lt;span class=&quot;math-container&quot;&gt;$2\times3$&lt;/span&gt; matrix would be the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{bmatrix}&#xA;1 &amp;amp; 2 \\&#xA;3 &amp;amp; 0 \\&#xA;5 &amp;amp; 6&#xA;\end{bmatrix}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1,2; &lt;s&gt;1,0&lt;/s&gt;; 1,6; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;3,2; &lt;s&gt;3,0&lt;/s&gt;; 3,6;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5,2; &lt;s&gt;5,0&lt;/s&gt;; 5,6&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1,3,5 (is for my case, not an option)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;*Combinations with 0 entries should get neglected&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already found a direct algorithm that provides all such combinations &lt;a href=&quot;https://stackoverflow.com/questions/41453353/return-all-combinations-from-the-matrix-in-java&quot;&gt;Return all combinations from the matrix in Java&lt;/a&gt; provided from the user @Niklas Rosencrantz. I have edited the code to fit my case. The problem with this case is it takes too long since I have to use for-loop &lt;span class=&quot;math-container&quot;&gt;$16^{11} = 17,592,186,044,416$&lt;/span&gt; times. For an iteration of &lt;span class=&quot;math-container&quot;&gt;$10,000,000$&lt;/span&gt; the code needs 25s including reading the data from an Excel file. This means that I need roughly &lt;strong&gt;21 days&lt;/strong&gt; for the calculation of all data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can model the same problem using linear programming. Is there a way to find only the feasible solutions of the problem without searching for the optimal one? I have found documentation in the gurobi site &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/poolsolutions.html#parameter:PoolSolutions&quot; rel=&quot;nofollow noreferrer&quot;&gt;PoolSolutions&lt;/a&gt; although I am not sure if this is the best way to search them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it make any sense to use linear programming for this case?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public class main {&#xA;private static String excelFileName = &quot;Mappe1 v2.xlsx&quot;;&#xA;private static int startExcelColumnIndex = 1;&#xA;private static int endExcelColumnIndex = 11;&#xA;private static int startExcelRowIndex = 1;&#xA;private static int endExcelRowIndex = 16;&#xA;private static ArrayList&amp;lt;String&amp;gt; stringArrayList = new ArrayList&amp;lt;String&amp;gt;();&#xA;private static int maxNumberProviders = 2;&#xA;private static List&amp;lt;int[]&amp;gt; combine(int[][] matrix) {&#xA;    int sizeArray[] = new int[matrix[0].length];&#xA;    int counterArray[] = new int[matrix[0].length];&#xA;    long total = 1;&#xA;    for (int i = 0; i &amp;lt; matrix[0].length; ++i) {&#xA;        sizeArray[i] = matrix.length; //todo: check this if the following two lines are correct!&#xA;        total *= matrix.length; // rows^columns&#xA;    }&#xA;//        total = 100000000; //fixme: remove this line after checking the &#xA;//        combinations barier&#xA;//        List&amp;lt;int[]&amp;gt; list = new ArrayList&amp;lt;&amp;gt;(total);&#xA;    List&amp;lt;int[]&amp;gt; list = new ArrayList&amp;lt;&amp;gt;();&#xA;    StringBuilder sb;&#xA;    String s;&#xA;    for (long count = total; count &amp;gt; 0; --count) {&#xA;        // check the number of different providers, using the counterArray&#xA;        boolean combinationAcceptable = combinationAllowedForMaxNumberOfProviders(counterArray);&#xA;        boolean combinationPossible;&#xA;        sb = new StringBuilder();&#xA;        s = &quot;&quot;;&#xA;        if (combinationAcceptable) {&#xA;            combinationPossible = true;&#xA;            for (int i = 0; i &amp;lt; matrix[0].length; ++i) {&#xA;                if (matrix[counterArray[i]][i]&amp;gt;0) {&#xA;                    sb.append(matrix[counterArray[i]][i]);&#xA;                    s = s + &quot;; &quot; + counterArray[i] +  &quot;,&quot; + i + &quot;; &quot;;&#xA;                } else {&#xA;                    combinationPossible = false;&#xA;                    break;&#xA;                }&#xA;            }&#xA;        } else {&#xA;            combinationPossible = false;&#xA;        }&#xA;        if (combinationPossible) {&#xA;            stringArrayList.add(s);&#xA;            int tmpi[] = new int[sb.toString().length()];&#xA;            for (int tmp = 0; tmp &amp;lt; sb.toString().length(); tmp++) {&#xA;                tmpi[tmp] = Integer.parseInt(&quot;&quot; + sb.toString().toCharArray()[tmp]);&#xA;            }&#xA;            list.add(tmpi);&#xA;        } else {&#xA;            combinationPossible = true;&#xA;        }&#xA;        for (int incIndex = matrix[0].length - 1; incIndex &amp;gt;= 0; --incIndex) {&#xA;            if (counterArray[incIndex] + 1 &amp;lt; sizeArray[incIndex]) {&#xA;                ++counterArray[incIndex];&#xA;                break;&#xA;            }&#xA;            counterArray[incIndex] = 0;&#xA;        }&#xA;    }&#xA;    return list;&#xA;}&#xA;public static boolean combinationAllowedForMaxNumberOfProviders(int[] counterArray) {&#xA;    HashSet&amp;lt;Integer&amp;gt; integerHashSet = new HashSet&amp;lt;&amp;gt;();&#xA;    for (int i = 0; i &amp;lt; counterArray.length; i++) {&#xA;        int rowIndex = counterArray[i];&#xA;        integerHashSet.add(rowIndex);&#xA;    }&#xA;    if (integerHashSet.size() &amp;lt;= maxNumberProviders) {&#xA;        return true;&#xA;    } else {&#xA;        return false;&#xA;    }&#xA;}&#xA;public static void main(String[] args) {&#xA;    /*int[][] matrix = {{1, 2, 3},&#xA;            {4, 5, 6},&#xA;            {7, 8, 9}};*/&#xA;    int[][] matrix = new int[endExcelRowIndex][endExcelColumnIndex];&#xA;    readXlsx(matrix);&#xA;    int i = 0;&#xA;    combine(matrix);&#xA;    writeToTXT();&#xA;}&#xA;public static void writeToTXT() {&#xA;    PrintWriter writer = null;&#xA;    try {&#xA;        writer = new PrintWriter(&quot;MatrixCombinations.txt&quot;, &quot;UTF-8&quot;);&#xA;    } catch (FileNotFoundException e) {&#xA;        e.printStackTrace();&#xA;    } catch (UnsupportedEncodingException e) {&#xA;        e.printStackTrace();&#xA;    }&#xA;    for (String s: stringArrayList&#xA;    ) {&#xA;        writer.println(s);&#xA;    }&#xA;    writer.close();&#xA;}&#xA;public static void readXlsx(int[][] matrix) {&#xA;    File myFile = new File(excelFileName);&#xA;    FileInputStream fis = null;&#xA;    try {&#xA;        fis = new FileInputStream(myFile);&#xA;    } catch (FileNotFoundException e) {&#xA;        e.printStackTrace();&#xA;        System.exit(0);&#xA;    }&#xA;&#xA;    // Finds the workbook instance for XLSX file&#xA;    XSSFWorkbook myWorkBook = null;&#xA;    try {&#xA;        myWorkBook = new XSSFWorkbook(fis);&#xA;    } catch (IOException e) {&#xA;        e.printStackTrace();&#xA;        System.exit(0);&#xA;    }&#xA;    // read Excel Sheet&#xA;    XSSFSheet mySheet = myWorkBook.getSheet(&quot;Kombinationen&quot;);&#xA;    // Get iterator to all the rows in current sheet&#xA;    Iterator&amp;lt;Row&amp;gt; rowIterator = mySheet.iterator();&#xA;    while (rowIterator.hasNext()) {&#xA;        Row row = rowIterator.next();&#xA;        if (row.getRowNum() &amp;gt;= startExcelRowIndex &amp;amp;&amp;amp; row.getRowNum() &amp;lt;= endExcelRowIndex) {&#xA;            Iterator&amp;lt;Cell&amp;gt; cellIterator = row.cellIterator();&#xA;            while (cellIterator.hasNext()) {&#xA;                Cell cell = cellIterator.next();&#xA;                if (cell.getColumnIndex() &amp;gt;= startExcelColumnIndex &amp;amp;&amp;amp; cell.getColumnIndex() &amp;lt;= endExcelColumnIndex) {&#xA;                    matrix[row.getRowNum()-startExcelRowIndex][cell.getColumnIndex()-startExcelColumnIndex] = (int) cell.getNumericCellValue();&#xA;&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="456" LastEditorUserId="456" LastEditDate="2019-11-28T16:55:01.597" LastActivityDate="2019-12-04T12:59:50.370" Title="Find all Combinations of a Matrix" Tags="|linear-programming|modeling|feasible-points|java|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3116" PostTypeId="2" ParentId="3114" CreationDate="2019-11-26T16:02:12.983" Score="5" Body="&lt;p&gt;I've had this problem in the past with &lt;code&gt;CPLEX Error 1016&lt;/code&gt;, though in Windows, and this is how I resolved it (assuming you have the correct installation of CPLEX on your machine and the appropriate python packages):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;From the command prompt, go to the directory where CPLEX is installed (e.g. &quot;C:\Program Files\IBM\ILOG\CPLEX_Studio129\python&quot;)&lt;/li&gt;&#xA;&lt;li&gt;Run &lt;code&gt;python setup.py install&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Restart your system!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After doing these steps, when I navigate to the system path, I could see the path for CPLEX. You can check that on your machine too by doing the following (again, this is for windows but hopefully the idea is the same):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Go to Control panel &gt; Edit the system environment variables &gt; Advanced &gt; Environment Variables...&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In the &quot;User variables for &lt;em&gt;your_name&lt;/em&gt;&quot;, you'll see &quot;Path&quot;. Make sure you see the path for the cplex.exe and python version you have installed the &lt;code&gt;setup.py&lt;/code&gt; for. &#xA;For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;C:\Program Files\IBM\ILOG\CPLEX_Studio129\cplex\python\3.6\x64_win64&quot; and&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;C:\Program Files\IBM\ILOG\CPLEX_Studio129\cplex\bin\x64_win64\cplex.exe&quot;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-11-26T16:02:12.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3117" PostTypeId="1" CreationDate="2019-11-27T04:06:00.297" Score="11" ViewCount="1689" Body="&lt;p&gt;I noticed the similarities between KKT and complementary slackness, but I do not fully understand it.&lt;/p&gt;&#xA;" OwnerUserId="2759" LastEditorUserId="8" LastEditDate="2019-11-27T14:12:58.513" LastActivityDate="2020-02-11T12:49:22.177" Title="Is there any relationship between KKT and duality?" Tags="|linear-programming|duality|kkt-conditions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3118" PostTypeId="1" AcceptedAnswerId="3132" CreationDate="2019-11-27T06:49:36.187" Score="13" ViewCount="946" Body="&lt;p&gt;In my research, I do a black-box optimization based on a simulation model with nonlinear properties. The simulation model gets an operation plan for a time period and then returns a time series, which is evaluated in the fitness function of the algorithms.&#xA;There are several local minima in the state space. For optimization, I use heuristic algorithms like Particle Swarm Optimization (PSO) or Simulated Annealing (SA). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this optimization problem, I have already written several papers and each time the reviewers mention why I don't use methods like Mixed integer linear programming, dynamic programming, quadratic programming, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, I have assumed that these mathematical methods do not make sense in my case. How do you see this?&lt;/p&gt;&#xA;" OwnerUserId="2756" LastActivityDate="2019-11-29T14:23:16.210" Title="Black-box optimization with linear programming?" Tags="|optimization|linear-programming|heuristics|simulated-annealing|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3119" PostTypeId="2" ParentId="3118" CreationDate="2019-11-27T10:35:17.503" Score="8" Body="&lt;p&gt;AFAIK, it depends on the optimization problem under study. As @Kuifje said, black boxes are used when the problem is too complex. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the ways to apply simulation-optimization is to use discrete event simulation to calculate the results of the complex problem and then, feeding that into the model which can be represented using the mixed-integer programming. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An interesting example can be a blood supply chain optimization under uncertainty. However, there are many articles which authors have used such a method to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference: &lt;a href=&quot;https://link.springer.com/article/10.1007/s10729-016-9370-6&quot; rel=&quot;noreferrer&quot;&gt;Simulation-optimization model for production planning in the blood supply chain&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-11-27T10:35:17.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3120" PostTypeId="2" ParentId="3117" CreationDate="2019-11-27T16:23:49.683" Score="26" Body="&lt;p&gt;KKT and duality are indeed closely related. To demonstrate this, I will look at a convex minimization problem in which all functions are convex and smooth. I will make use of &lt;a href=&quot;https://en.wikipedia.org/wiki/Duality_(optimization)&quot; rel=&quot;noreferrer&quot;&gt;Lagrange duality&lt;/a&gt;. Linear programming duality is just a &lt;a href=&quot;https://or.stackexchange.com/a/299/145&quot;&gt;special case of Lagrange duality&lt;/a&gt; applied to linear programs.&lt;/p&gt;&#xA;&lt;p&gt;Consider the following convex minimization problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;p^* = \min_x &amp;amp; ~f(x)\\&#xA;\text{s.t.} &amp;amp; ~g_i(x) \le 0 &amp;amp; \forall i = 1,\dots,m&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which we will call the &lt;em&gt;primal problem&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;em&gt;Lagrangian dual problem&lt;/em&gt; is given by&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;d^* = \max_{\lambda \ge 0} \min_x\left\{ f(x) + \sum_{i=1}^m \lambda_i g(x)\right\}.&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; be the value of the primal problem for a given &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; be the value of the dual problem for a given &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;. By definition, &lt;span class=&quot;math-container&quot;&gt;$p \ge p^*$&lt;/span&gt; (due to the minimum), &lt;span class=&quot;math-container&quot;&gt;$d \le d^*$&lt;/span&gt; (due to the maximum), and &lt;span class=&quot;math-container&quot;&gt;$p \ge d$&lt;/span&gt; (by weak duality).&lt;/p&gt;&#xA;&lt;p&gt;It follows that if we can find an &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and a &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$p=d$&lt;/span&gt;, then it must be that &lt;span class=&quot;math-container&quot;&gt;$p=p^*$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d=d^*$&lt;/span&gt;. That is, we have found the optimal solution! By strong duality, we know that this is possible for convex problems (given some technical conditions).&lt;/p&gt;&#xA;&lt;h2&gt;Goal: find &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$p = d$&lt;/span&gt;.&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; that we find should be feasible for the primal problem, or &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; would be considered to have value &lt;span class=&quot;math-container&quot;&gt;$\infty$&lt;/span&gt;. So we need &lt;em&gt;primal feasibility&lt;/em&gt;: &lt;span class=&quot;math-container&quot;&gt;$g_i(x) \le 0$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i = 1,\dots,m$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;In the same way, our &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; should be consistent with our definition of the dual problem. So we need &lt;em&gt;dual feasibility&lt;/em&gt;: &lt;span class=&quot;math-container&quot;&gt;$\lambda \ge 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For a given &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; in the dual problem, the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in the dual problem should actually minimize &lt;span class=&quot;math-container&quot;&gt;$f(x) + \sum\limits_{i=1}^m \lambda_i g(x)$&lt;/span&gt;. Otherwise, we would be cheating. Due to convexity and smoothness, minimizing this function over &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is equivalent to finding a stationary point. So we add &lt;em&gt;stationarity&lt;/em&gt;: &lt;span class=&quot;math-container&quot;&gt;$\nabla f(x) + \sum\limits_{i=1}^m \lambda_i \nabla g_i(x) = 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Now that everything is properly defined, we just add the condition &lt;span class=&quot;math-container&quot;&gt;$p=d$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$f(x) = f(x) + \sum\limits_{i=1}^m \lambda_i g(x)$&lt;/span&gt;, or equivalently &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i=1}^m \lambda_i g(x) = 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;If you meet the above conditions, you are guaranteed to have found an optimal solution (in the case of strong duality).&lt;/p&gt;&#xA;&lt;p&gt;Note that the above conditions are &lt;em&gt;almost&lt;/em&gt; the KKT conditions. To arrive at the KKT conditions, we state condition 4. slightly stronger.&lt;/p&gt;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;ALTERNATIVE: By conditions 1. and 2. it follows that &lt;span class=&quot;math-container&quot;&gt;$\lambda_i g_i(x) \le 0$&lt;/span&gt;. By condition 4. we have &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i=1}^m \lambda_i g(x) = 0$&lt;/span&gt;. It follows immediately that all &lt;span class=&quot;math-container&quot;&gt;$\lambda_i g_i(x)$&lt;/span&gt; must be equal to 0. We call this &lt;em&gt;complementary slackness&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2&gt;To summarize&lt;/h2&gt;&#xA;&lt;p&gt;In the convex case, the KKT conditions are neccesary and sufficient conditions for a primal dual pair &lt;span class=&quot;math-container&quot;&gt;$(x,\lambda)$&lt;/span&gt; to obtain zero duality gap &lt;span class=&quot;math-container&quot;&gt;$p=d$&lt;/span&gt;, which implies optimality.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-02-11T12:49:22.177" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3121" PostTypeId="5" CreationDate="2019-11-27T19:21:40.170" Score="0" Body="&lt;p&gt;Given a stochastic process, &lt;span class=&quot;math-container&quot;&gt;$\{N(t), t\ge0\}$&lt;/span&gt;, which counts the number of events by time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, the index of dispersion (for counts) is the &lt;strong&gt;variance-to-mean ratio&lt;/strong&gt; of the cumulative number of events by time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More succinctly, &lt;span class=&quot;math-container&quot;&gt;$I(t) = \operatorname{Var}(N(t))/\Bbb E[N(t)]$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For further details see &lt;a href=&quot;https://en.wikipedia.org/wiki/Index_of_dispersion&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia: Index of Dispersion&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="123" LastEditDate="2020-02-09T20:20:46.070" LastActivityDate="2020-02-09T20:20:46.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3122" PostTypeId="4" CreationDate="2019-11-27T19:21:40.170" Score="0" Body="For questions relating to the index of dispersion, or the variance-to-mean ratio for a random variable or stochastic process. " OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-11-27T19:42:21.560" LastActivityDate="2019-11-27T19:42:21.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3123" PostTypeId="5" CreationDate="2019-11-27T20:00:20.167" Score="0" Body="&lt;p&gt;The convex hull of a set &lt;em&gt;X&lt;/em&gt; is the smallest convex set that contains &lt;em&gt;X&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternate and more formal definitions &lt;a href=&quot;https://en.wikipedia.org/wiki/Convex_hull&quot; rel=&quot;nofollow noreferrer&quot;&gt;available&lt;/a&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;Elastic Band&lt;/em&gt; analogy demonstrates this below for a finite set in 2D. Surround the points with the smallest elastic band that contains the points. The result is a convex set itself (blue band) and is the smallest convex set possible that contains all 10 points. All points inside this set (the blue band) comprise the convex hull for these 10 points. &#xA;&lt;a href=&quot;https://i.stack.imgur.com/T5KSN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T5KSN.png&quot; alt=&quot;2D Elastic band illustration of a convex hull taken from the public domain.&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://en.wikipedia.org/wiki/Convex_hull#/media/File:ConvexHull.svg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Source&lt;/a&gt;, &quot;Convex hull of a finite set: elastic-band analogy&quot; image from public domain.&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-11-27T20:25:04.343" LastActivityDate="2019-11-27T20:25:04.343" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3124" PostTypeId="4" CreationDate="2019-11-27T20:00:20.167" Score="0" Body="For questions related to the convex hull of a set, often (but not limited to) referring to the feasible region in optimization. &#xD;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2019-11-27T20:25:13.650" LastActivityDate="2019-11-27T20:25:13.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3125" PostTypeId="1" AcceptedAnswerId="3129" CreationDate="2019-11-28T04:09:52.370" Score="7" ViewCount="1372" Body="&lt;p&gt;It is known that, in a linear program with &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; constraints, there exists a basic feasible solution in which at most &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; variables are non-zero. How can I find such a solution? &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a polynomial-time algorithm for this? I know that the simplex method finds these solutions, but it is not polynomial time.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In practice, how can I tell the common Python libraries for linear programming (particularly: &lt;a href=&quot;https://www.cvxpy.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;cvxpy&lt;/a&gt; and scipy.linprog) to find me a solution with a small number of zeros?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="8" LastEditDate="2019-11-29T01:49:25.720" LastActivityDate="2019-11-29T20:22:25.957" Title="Finding a solution to a linear program with a small number of zeros" Tags="|linear-programming|python|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3126" PostTypeId="2" ParentId="3125" CreationDate="2019-11-28T07:08:05.020" Score="9" Body="&lt;p&gt;The more precise statement is that in a basic solution at most k out of the n variables are away from their bounds. If they have a non-zero lower or upper bounds, non-basic variables can also be non-zero. But that might not be the case in what you are working on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding (1): If you google &quot;polynomial algorithm for linear programming&quot; you can probably have a lot of fun reading. The short version: Interior point (barrier methods) and the ellipsoid method are polynomial, but only interior point methods are good in practice. The simplex method is not known to be polynomial but especially the dual simplex works very well in practice. I wrote more about this here already: &lt;a href=&quot;https://or.stackexchange.com/questions/1354/state-of-the-art-algorithms-for-solving-linear-programs/1394#1394&quot;&gt;State-of-the-art algorithms for solving linear programs&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding (2): I can't say anything specific about these packages, but interior point methods are also different from simplex methods in that they don't necessarily return basic solutions. If the problem is degenerate (and most problems are) they return a solution that sits on a face of the polyhedron instead of a vertex (basic solution). Thus interior point methods will return solutions with &quot;a small number of zeros&quot;.&lt;/p&gt;&#xA;" OwnerUserId="302" LastEditorUserId="36" LastEditDate="2019-11-28T16:30:02.300" LastActivityDate="2019-11-28T16:30:02.300" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3127" PostTypeId="1" AcceptedAnswerId="3137" CreationDate="2019-11-28T09:13:28.630" Score="5" ViewCount="369" Body="&lt;p&gt;I would like to establish a precedence constraint to ensure the precedence relation of tasks. I have a set of tasks available, but required tasks are not always the same. It means, the tasks executed will depend of the demand.&lt;/p&gt;&#xA;&lt;p&gt;When I searched for examples of precedence constraints in CPLEX/DOCPLEX and also OR-TOOLS, all examples I found use interval variables for establishing precedence constraints. In my case, I don't have interval variables, just binary ones.&lt;/p&gt;&#xA;&lt;p&gt;I tried to implement the following precedence constraint:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  for t1 in required_tasks:&#xA;        for t2 in required_tasks:&#xA;            for w in range(1, len(task_cost) + 1):&#xA;                for j1 in range(1, number_tasks + 1):&#xA;                    for j2 in range(1, number_tasks + 1):&#xA;                        if j1 &amp;lt; j2:&#xA;                             if t2 in preced_task[t1]:&#xA;                                  opt_model.add(&#xA;                                        X[t1, w, j1] *&#xA;                                        precedence[t1, t2]&#xA;                                        &amp;gt;= X[t2, w, j2]&#xA;                                    )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;em&gt;Some definitions:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;X&lt;/code&gt; is a binary variable&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;w&lt;/code&gt; is the worker index&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;t1&lt;/code&gt; and &lt;code&gt;t2&lt;/code&gt; are task indexes&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;j1&lt;/code&gt; and &lt;code&gt;j2&lt;/code&gt; are the positions of the tasks in the sequence&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;preced_task&lt;/code&gt; is a dictionary containing the precedence relation.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Example: In this case, task 2 must be done after task 1, task 3 must be done after task 2. Task 1, 4, etc do not require any tasks before them.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;preced_task = {1: [], 2: [1], 3: [2], 4: [], 5: [], 6: [], 7: []}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I consider &lt;code&gt;j1&lt;/code&gt; and &lt;code&gt;j2&lt;/code&gt; in &lt;code&gt;range(1, number_tasks + 1)&lt;/code&gt; it does not return a solution. However, if I consider &lt;code&gt;j1&lt;/code&gt; and &lt;code&gt;j2&lt;/code&gt; in &lt;code&gt;range(2, number_tasks + 1)&lt;/code&gt; it returns a solution respecting precedence for one task (2, for example), but not for task 3.&lt;/p&gt;&#xA;&lt;p&gt;Could someone help me with that?&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="981" LastEditDate="2023-12-22T14:58:55.137" LastActivityDate="2023-12-22T14:58:55.137" Title="Precedence constraints using binary variables - DOCPLEX" Tags="|constraint|cplex|constraint-programming|or-tools|docplex|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3128" PostTypeId="1" AcceptedAnswerId="3138" CreationDate="2019-11-28T15:26:11.763" Score="12" ViewCount="512" Body="&lt;p&gt;I have an NLP that I am hoping to solve with Knitro and I am aware of a multitude of different settings that you can &quot;tune&quot; in order to improve solution performance. I am not familiar with optimization solvers and the various settings, and so what I am trying to determine is exactly how much of a difference tuning the settings can make in solving problems. Does tuning the solver have the potential to drastically improve the solving times, and if so, could you provide a small conceptual example that illustrates how different solver settings might be able to improve the computational efficiency of a problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to determine if investing time into learning the fundamentals of the solver (and thus the tuning specs) is really worth my time as a student if my problem is very difficult to solve. &lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="36" LastEditDate="2019-11-28T16:00:37.723" LastActivityDate="2019-12-02T14:10:12.830" Title="Can Tuning Knitro Solver Considerably Make A Difference?" Tags="|solver|nonlinear-programming|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3129" PostTypeId="2" ParentId="3125" CreationDate="2019-11-28T15:59:54.060" Score="8" Body="&lt;p&gt;As also mentioned by Philipp Christophel: polynomial-time does not mean that the algorithm is better in practice. I strongly suggest that you try the simplex method first, as it does exactly what you want, implementations are readily available, and it might very well be the fastest method for your purpose.&lt;/p&gt;&#xA;&lt;p&gt;That being said: yes, you can obtain a basic feasible solution in polynomial time with the ellipsoid method or with interior point methods.&lt;/p&gt;&#xA;&lt;h3&gt;Ellipsoid method&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1016/0041-5553(80)90061-0&quot; rel=&quot;noreferrer&quot;&gt;Khachiyan (1980)&lt;/a&gt; describes how the ellipsoid method can be used to find an optimal basic feasible solution in polynomial time. This result is interesting theoretically, but you definitely do not want to implement this, as practical performance is terrible.&lt;/p&gt;&#xA;&lt;h3&gt;Interior point methods&lt;/h3&gt;&#xA;&lt;p&gt;Interior point methods by themselves return a feasible solution that is close to the optimum, but it need not be a basic feasible solution. To go from an interior point solution to a basic feasible solution, &lt;em&gt;crossover algorithms&lt;/em&gt; can be used. These are implemented in most commercial solvers, e.g., see the crossover page in the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/BarCrossAlg.html&quot; rel=&quot;noreferrer&quot;&gt;CPLEX documentation&lt;/a&gt; and in the &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/crossover.html&quot; rel=&quot;noreferrer&quot;&gt;Gurobi documentation&lt;/a&gt;. So if simplex is not fast enough, you may try interior point/barrier with one of these solvers and enable the crossover.&lt;/p&gt;&#xA;&lt;p&gt;Given optimal primal-dual solutions, crossover is possible in polynomial time.&#xA;&lt;a href=&quot;https://doi.org/10.1287/ijoc.3.1.63&quot; rel=&quot;noreferrer&quot;&gt;Megiddo (1991)&lt;/a&gt; gives a strongly polynomial algorithm to find an optimal basic feasible solution. However, I do not know how numerical imprecision in the numerical solution affects this result. And even then, I highly doubt that solvers implement a polynomial time algorithm, as algorithms without complexity guarantees may perform significantly better. This was observed by &lt;a href=&quot;https://doi.org/10.1016/0167-6377(94)90074-4&quot; rel=&quot;noreferrer&quot;&gt;Bixby and Saltzman (1994)&lt;/a&gt;, for example.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-11-28T16:29:40.273" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3130" PostTypeId="2" ParentId="3114" CreationDate="2019-11-29T05:59:43.887" Score="5" Body="&lt;p&gt;Thanks to all for the great suggestions. The thing that should be done is to install CPLEX &lt;code&gt;setup.py&lt;/code&gt; in the site-packages of the python. But it is not enough. Actually, what worked was the suggestion to remove the community version first (as MarkL.Stone suggested).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what I suggest for further reference is to do something like:&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;1- Remove your CPLEX community version. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be in a folder like the following:&#xA;&lt;code&gt;/home/&amp;lt;&amp;lt;your-computer-name&amp;gt;&amp;gt;/.local/lib/python3.6/site-packages/cplex/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this, you can open terminal and run: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;rm -r /home/&amp;lt;&amp;lt;your-computer-name&amp;gt;&amp;gt;/.local/lib/python3.6/site-packages/cplex/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;2- Install the CPLEX &lt;code&gt;setup.py&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this, go to the folder that CPLEX is installed, and go to the following subfolder: &lt;code&gt;opt/ibm/ILOG/CPLEX_Studio129/python&lt;/code&gt; (&lt;code&gt;opt&lt;/code&gt; is where my CPLEX is installed). Then open the terminal and run: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sudo python setup.py install --home home/&amp;lt;&amp;lt;your-computer-name&amp;gt;&amp;gt;/.local/lib/python3.6/site-packages/cplex&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that you should adjust the part &lt;code&gt;&amp;lt;&amp;lt;your-computer-name&amp;gt;&amp;gt;&lt;/code&gt; in the commands in both steps.&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2019-11-29T06:58:59.023" LastActivityDate="2019-11-29T06:58:59.023" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3131" PostTypeId="2" ParentId="3125" CreationDate="2019-11-29T12:20:44.900" Score="2" Body="&lt;p&gt;In practice, I have had great success in Python with &lt;a href=&quot;http://lpsolve.sourceforge.net/5.5/&quot; rel=&quot;nofollow noreferrer&quot;&gt;LpSolve 5.5&lt;/a&gt;,&#xA;I have never had to resort to interior point methods, yet. Dual simplex has been sufficient for me- even for integer problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, for your second question, the global best solution depends on your cost function. If the best solution is reached with a large number of zeros - that is still the solution. In rare / integer cases you may find multiple solutions for the same objective value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you can add an integer choice variable like 'Is &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; allowed to be non-zero?'  Depending on the number of decision variables you have, you can add an additional variable to each of them:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For each decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i &amp;gt; 0$&lt;/span&gt;, add the constraint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_i \le Q_i \cdot \text{Inf},$$&lt;/span&gt;  where &lt;span class=&quot;math-container&quot;&gt;$Q_i$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$\{0, 1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q_i=1$&lt;/span&gt; allows &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; to be greater than &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now sum &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_iQ_i$&lt;/span&gt; (for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;) to your objective function, with a weight that doesn't significantly affect your objective. And this should naturally lead to an objective function where fewer zeros are better.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If your problem has many decision variables this approach may just make the problem too large to solve in a reasonable time, especially since you're adding integer decision variables.&lt;/p&gt;&#xA;" OwnerUserId="2770" LastEditorUserId="123" LastEditDate="2019-11-29T20:22:25.957" LastActivityDate="2019-11-29T20:22:25.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3132" PostTypeId="2" ParentId="3118" CreationDate="2019-11-29T14:23:16.210" Score="10" Body="&lt;p&gt;My experience in this may be a bit dated (it comes from a previous millennium), but back then I recall (vaguely) using a form of &lt;a href=&quot;https://en.wikipedia.org/wiki/Response_surface_methodology&quot; rel=&quot;noreferrer&quot;&gt;response surface methodology&lt;/a&gt; to optimize parameters in a simulation model. The idea was to run the model with a range of parameter values and harvest observations, fit a nonlinear model statistically (with the performance measure as the dependent variable), optimize that function, and optionally simulate again using parameter values in a neighborhood of the alleged optimum, refit, reoptimize, ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that the response surface is almost always nonlinear, using a MIP model strikes me as unlikely. A quadratic program (or quadratic MIP) might work. That still leaves a couple of questions. The first is whether the parameters are constrained in known ways. (MILP and MIQP generally assume there are linear constraints.) The second is whether worrying about closing an optimality gap makes sense when (a) you are dealing with a somewhat coarse approximation of the actual response function and (b) you are going to do this iteratively. In my graduate student days (at a school with strong agricultural college), we referred to this as &quot;milking a duck&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I would use a &quot;good&quot; heuristic or metaheuristic. Feel free to suggest (tactfully) to reviewers what I said above about optimality gaps of very approximate response functions and iteration/repetition.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-11-29T14:23:16.210" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3133" PostTypeId="1" CreationDate="2019-11-29T19:04:22.230" Score="11" ViewCount="390" Body="&lt;p&gt;I am trying to compare many unconstrained optimization algorithms like gradient method, Newton method with line search, Polak-Ribiere algorithm, Broyden-Fletcher-Goldfarb-Shanno algorithm, so on so forth. For these methods, I use Armijo line search method to determine how much to go towards a descent direction at each step. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As commonly known, the Armijo condition requires some parameter selection (namely the distance to go &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;, the coefficient that will multiply &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; at each step which is &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt;, and some &lt;span class=&quot;math-container&quot;&gt;$\gamma \in (0, 1/2)).$&lt;/span&gt; I am not familiar with a way of choosing the best set of parameters. I could imagine they would differ from problem to problem, but what is the most common way to decide these parameters?&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2023-03-17T15:12:42.720" Title="Armijo Line Search Parameters" Tags="|optimization|algorithms|unconstrained-optimization|continuous-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3134" PostTypeId="1" CreationDate="2019-11-30T14:10:33.437" Score="11" ViewCount="381" Body="&lt;p&gt;I am going through the great &lt;a href=&quot;https://www2.isye.gatech.edu/people/faculty/Alex_Shapiro/TutorialSP.pdf&quot; rel=&quot;noreferrer&quot;&gt;tutorial on Stochastic Programming by Shapiro and Philpott&lt;/a&gt;. &#xA;When talking about Monte Carlo techniques, I get confused by the way they calculate the sample variance (page 13, equation (2.8)).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Given a solution &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, we approximate the recourse function &lt;span class=&quot;math-container&quot;&gt;$Q(x)=\Bbb E_{\xi}[Q(x,\xi)]$&lt;/span&gt; by&#xA;taking an i.i.d. sample of &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt;, and thus obtaining&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\hat{q}_N(x)=\frac1N\sum\limits_{i=1}^NQ(x,\xi^i).$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The sample variance is then calculated as &lt;span class=&quot;math-container&quot;&gt;$$\hat{\sigma}^2_N(x)=\dfrac{1}{N(N-1)}\sum\limits_{i=1}^N[Q(x,\xi^i)-\hat{q}_N(x)]^2.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since the mean is estimated from the sample itself (&lt;span class=&quot;math-container&quot;&gt;$\hat{q}_N(x)$&lt;/span&gt;), I would have expected to divide by &lt;span class=&quot;math-container&quot;&gt;$N-1$&lt;/span&gt; (as in, e.g. &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S1876735414000038&quot; rel=&quot;noreferrer&quot;&gt;Homem-de-Mello &amp;amp; Bayaraksan 2014&lt;/a&gt; page 67, before formula (21)). Instead I find &lt;span class=&quot;math-container&quot;&gt;$N(N-1)$&lt;/span&gt;. I would be grateful if someone could help me understand this formula.&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="123" LastEditDate="2019-11-30T15:06:08.217" LastActivityDate="2019-12-01T09:47:00.893" Title="Why is the sample variance of a Sample Average Approximation calculated in this way?" Tags="|stochastic-programming|variance|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3135" PostTypeId="2" ParentId="3134" CreationDate="2019-11-30T14:52:44.250" Score="8" Body="&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$\hat q_{N'}(\hat x)\approx\Bbb E[Q(\hat x,\xi)]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\Bbb V[\hat q_{N'}(\hat x)]=\Bbb V[Q(\hat x,\xi)]/N'$&lt;/span&gt;, we have &lt;span class=&quot;math-container&quot;&gt;\begin{align}\hat\sigma_{N'}^2(\hat x)=\Bbb V[\hat q_{N'}(\hat x)]&amp;amp;=\frac1{N'}\cdot\frac1{N'-1}\sum_{j=1}^{N'}[Q(\hat x,\xi^j)-\Bbb E[Q(\hat x,\xi)]]^2\\&amp;amp;\approx\frac1{N'(N'-1)}\sum_{j=1}^{N'}[Q(\hat x,\xi^j)-\hat q_{N'}(\hat x)]^2\end{align}&lt;/span&gt; as required. The approximation is improved as &lt;span class=&quot;math-container&quot;&gt;$N'$&lt;/span&gt; increases, under the Law of Large Numbers.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2019-12-01T09:47:00.893" LastActivityDate="2019-12-01T09:47:00.893" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3136" PostTypeId="2" ParentId="3128" CreationDate="2019-12-01T11:46:29.983" Score="4" Body="&lt;p&gt;Tuning a solver can make a big difference when it comes to IP/MIP problems. For continuous problems, it's unlikely to see a significant difference in performance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the solver enters branch and bound and/or has to use MIP heuristics to find primal solutions/feasible points, then there's no reason that the default settings would work better than something different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, it's rare to find a better configuration than what a solver's developers suggest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, we tune our solvers over large diverse sets of difficult problems (our own set is 3,000+) and pick combinations of features that (i) work best on average, and (ii) are well balanced, i.e., don't give an amazing performance for some problems but horrendous in others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We even have hard coded overrides to prevent users from using combinations of options that are known to perform badly for certain types of problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's usually 1% of cases not covered by the defaults, which is the only reason we make algorithmic options available to our users.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If one finds themselves in that 1% of cases, I would suggest experimenting with one option at a time, and to pick the important ones first, e.g. branching rules, type/frequency of heuristics, etc. I strongly advise against tweaking numbers/parameters, maybe with the exception of feasibility tolerances.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="36" LastEditDate="2019-12-02T01:04:18.610" LastActivityDate="2019-12-02T01:04:18.610" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3137" PostTypeId="2" ParentId="3127" CreationDate="2019-12-01T13:56:54.430" Score="4" Body="&lt;p&gt;After a while, I finally found a way to establish a precedence constraint using binary variables. &#xA;It was hard to find examples of precedence constraints that do not use time as a parameter in both theoretical models and also code implementation tutorials. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I am sharing here the code I used in DOCPLEX to establish the precedence constraint with binary variable without using time, but just process plan position as a parameter. I hope it will help other people dealing with similar problems. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for t1 in required_tasks:&#xA;    for t2 in required_tasks:&#xA;        for j2 in range(1, number_tasks + 1):&#xA;            opt_model.add(&#xA;                opt_model.sum(&#xA;                    X_var[t1, w1, j1]&#xA;                    for w1 in range(1, len(workers) + 1)&#xA;                    for j1 in range(1, j2)&#xA;                )&#xA;                 &amp;gt;= opt_model.sum(&#xA;                    X_var[t2, w2, j2] * precedence[t1,t2]&#xA;                    for w2 in range(1, len(workers) + 1)&#xA;&#xA;                )&#xA;            )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: precedence is a dictionary showing the precedence relation between &lt;code&gt;t1&lt;/code&gt; and &lt;code&gt;t2&lt;/code&gt;. If &lt;code&gt;t1&lt;/code&gt; must be done before &lt;code&gt;t2&lt;/code&gt;, &lt;code&gt;precedence[t1, t2] = 1&lt;/code&gt;, and &lt;code&gt;0&lt;/code&gt; otherwise.&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="2453" LastEditDate="2019-12-01T14:13:45.443" LastActivityDate="2019-12-01T14:13:45.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3138" PostTypeId="2" ParentId="3128" CreationDate="2019-12-02T10:11:31.107" Score="12" Body="&lt;p&gt;(Disclaimer: I am a developer of Knitro)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When developing a NLP solver, we set the default values for the different options so as to minimize the resolution time &lt;em&gt;in average&lt;/em&gt; for different class of problems (CUTer, QPLIB, Mittelmann instances, etc.). When working on a &lt;em&gt;specific&lt;/em&gt; problem, it often pays to find appropriate parameters to improve the resolution time. In Knitro, the most impactful parameters are usually: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;algorithm&lt;/code&gt;: Knitro comes with 4 different algorithms to solve NLP problems. &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;algorithm=1&lt;/code&gt; uses the classical interior point algorithm, and Knitro computes at each iteration a line-search step using direct linear algebra (you could specify the line-search procedure with &lt;code&gt;linesearch&lt;/code&gt;). If the line-search fails to improve the merit function used inside Knitro, the algorithm falls back to a trust-region step (the &lt;code&gt;CG step&lt;/code&gt; appearing in the log of Knitro). &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;algorithm=2&lt;/code&gt; uses a trust-region algorithm, using a quadratic approximation of the non-linear function internally. This algorithm could be powerful if you have callbacks available to compute the Hessian vector product &lt;span class=&quot;math-container&quot;&gt;$\nabla^2f(x^k) v$&lt;/span&gt;, as you won't need to compute the whole Hessian in this case. &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;algorithm=3&lt;/code&gt; uses an active-set algorithm (more precisely, a sequential linear-quadratic programming algorithm). &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;algorithm=4&lt;/code&gt; uses a classical SQP algorithm, which could be powerful if evaluating the oracle for the function, the gradient and the Hessian is costly. Indeed, the SQP algorithm usually performs a smaller number of iterations than the other algorithms.  &lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;linsolver&lt;/code&gt;: determine which linear solvers to use when solving the Newton step at each iteration. On large-scale problems, setting an appropriate linear solver could improve a lot the performance. MA27 and MA57 give good performance overall, and MA86/MA97 target more specific architecture. You may also want to use Intel PARDISO here. &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;hessopt&lt;/code&gt;: specify which algorithm to use internally. If you provide the Hessian, &lt;code&gt;hessopt=1&lt;/code&gt; performs the classical Newton algorithm. If you have only gradients available, I recommend using &lt;code&gt;hessopt=2&lt;/code&gt; (BFGS) if the problem is medium-sized, and &lt;code&gt;hessopt=6&lt;/code&gt; (L-BFGS) if the problem has more than 10,000 variables or constraints. When using L-BFGS, you can play with the parameter &lt;code&gt;lm_size&lt;/code&gt; to determine how many coefficients to use in the limited memory approximation of the Hessian. &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;presolve&lt;/code&gt;: determine the level of the presolve. Basically, the presolve removes redundancies in the linear constraints (fixed variables, linearly dependant rows, etc). You can specify the level of the presolve with &lt;code&gt;presolve_level&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;li&gt;Concerning the specific parameters for the barrier used inside the interior point algorithm, they are often more difficult to tune. I recommend setting &lt;code&gt;bar_conic_enable=1&lt;/code&gt; if you are using the conic API of Knitro. &lt;code&gt;bar_murule&lt;/code&gt; allows to change the update rule of the penalty parameter &lt;code&gt;\mu&lt;/code&gt;, &lt;code&gt;bar_penaltycons&lt;/code&gt; is useful if your problem has difficult or degenerate constraints, &lt;code&gt;bar_watchdog&lt;/code&gt; enables a watchdog procedure in the line-search, and &lt;code&gt;bar_penaltyrule&lt;/code&gt; allows more control to define the merit function uses internally in Knitro. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In any case, before tuning the performance of the solver, I recommend to spend some time on formulating the NLP problem properly, e.g.: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Choosing an appropriate scaling (the closer the objective and the range of the constraint to 1.0, the better) ;&lt;/li&gt;&#xA;&lt;li&gt;Avoiding redundant and linearly dependent constraints ; &lt;/li&gt;&#xA;&lt;li&gt;Specifying most of the constraints by using the linear and quadratic API of Knitro (by doing so, we let Knitro computes automatically the Jacobian and the Hessian, and that could lead to much better performance). &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In any case, I recommend having a look at: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.artelys.com/docs/knitro//2_userGuide/algorithms.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.artelys.com/docs/knitro//2_userGuide/algorithms.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.artelys.com/docs/knitro//3_referenceManual/userOptions.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.artelys.com/docs/knitro//3_referenceManual/userOptions.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and we would be happy to help you more specifically if you choose to contact the support team on &lt;code&gt;support-knitro [AT] artelys.com&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I am trying to determine if investing time into learning the fundamentals of the solver (and thus the tuning specs) is really worth my time as a student if my problem is very difficult to solve. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you are interested by the theory lying behind the optimization solver Knitro, I advise usually to have a look at this article: &#xA;&lt;a href=&quot;http://users.iems.northwestern.edu/~nocedal/PDFfiles/integrated.pdf&quot; rel=&quot;noreferrer&quot;&gt;http://users.iems.northwestern.edu/~nocedal/PDFfiles/integrated.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, &lt;a href=&quot;https://link.springer.com/book/10.1007/978-0-387-40065-5&quot; rel=&quot;noreferrer&quot;&gt;Numerical Optimization&lt;/a&gt; by Nocedal and Wright is a must read. &lt;/p&gt;&#xA;" OwnerUserId="2452" LastActivityDate="2019-12-02T10:11:31.107" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3139" PostTypeId="1" CreationDate="2019-12-03T01:42:57.103" Score="13" ViewCount="571" Body="&lt;p&gt;I want to minimize the following objective function: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min &amp;amp;\quad x\cdot y\\\text{s.t.}&amp;amp;\quad2 \le x \le 5\\&amp;amp;\quad5 \le y \le 10.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the objective function is a product of two real-valued variables, I am taking the following approach to linearize the problem using the binary expansion method. I pick the value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to discretize although either of the variables could be picked since the upper and lower bounds are known for both. So, I discretize the value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; with a step value of &lt;span class=&quot;math-container&quot;&gt;$0.003$&lt;/span&gt;. Therefore, the sequence of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; values will look like this: &lt;span class=&quot;math-container&quot;&gt;$2, 2.003,2.006,\cdots,5$&lt;/span&gt;. Now, I implement the following optimization problem which is a mixed-integer linear program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min &amp;amp;\quad \sum_i x(i)\cdot p(i)\\\text{s.t.}&amp;amp;\quad\sum_i z(i) =1\\&amp;amp;\quad0 \le y-p(i) \le M\cdot(1-z(i))\\&amp;amp;\quad0 \le p(i) \le M\cdot z(i)\\&amp;amp;\quad5 \le y \le 10\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where, &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is the big-M value, &lt;span class=&quot;math-container&quot;&gt;$p(i)$&lt;/span&gt; is an auxiliary real-valued variable and &lt;span class=&quot;math-container&quot;&gt;$z(i)$&lt;/span&gt; is a binary variable. In &lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.453.4522&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;noreferrer&quot;&gt;Pereira &lt;em&gt;et al.&lt;/em&gt; (2005)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;, however, they implement a different approach which is as follows when applied to my problem. First, they obtain discrete values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; similar to my approach, where &lt;span class=&quot;math-container&quot;&gt;$x = \{x(i), i=0,1,\cdots,M\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M=2^K$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is some non-negative integer. The optimization formulation is as follows: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad x_{\rm LB}+\delta\cdot\sum_{i=0}^K 2^i\cdot p(i)\\\text{s.t.}&amp;amp;\quad0 \le y-p(i) \le M\cdot(1-z(i))\\&amp;amp;\quad0 \le p(i) \le M\cdot z(i)\\&amp;amp;\quad5 \le y \le 10\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where, &lt;span class=&quot;math-container&quot;&gt;$p(i) =y\cdot z(i)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\delta = (x_{\rm UB}-x_{\rm LB})/M$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z(i)$&lt;/span&gt; is a binary variable and &lt;span class=&quot;math-container&quot;&gt;$\rm LB$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\rm UB$&lt;/span&gt; refer to the lower and upper bound respectively. My question is while doing my linearization process, am I missing something in the first formulation compared to the second one? I appreciate your input on this.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Pereira, M. V., &lt;em&gt;et al.&lt;/em&gt; (2005). Strategic Bidding Under Uncertainty: A Binary Expansion Approach. &lt;em&gt;IEEE Transactions on Power Systems&lt;/em&gt;. 20(1):180-188. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="123" LastEditDate="2019-12-03T06:56:26.560" LastActivityDate="2019-12-03T14:21:25.793" Title="Linearization of the product of two real valued variables - Binary expansion approach" Tags="|optimization|mixed-integer-programming|nonlinear-programming|linearization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3141" PostTypeId="1" AcceptedAnswerId="3146" CreationDate="2019-12-03T07:06:14.003" Score="10" ViewCount="161" Body="&lt;p&gt;I am working with the following MIP :&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\min&amp;amp;\quad\sum_{j\in J} c_j x_j\\\text{s.t.}&amp;amp;\quad l_j \le f(x_j,t_j) \le u_j \quad &amp;amp;\forall j \in J \\&amp;amp;\quad x_j \in \mathbb{N} \quad &amp;amp;\forall j \in J \\&amp;amp;\quad t_j \in \mathbb{R}^+ \quad &amp;amp;\forall j \in J&#xA;\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a linear function, &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; are decision variables and &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt; represents starting time for task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to perform some sort of &quot;sensitivity analysis&quot; on variables &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt; (maybe sensitivity analysis is the wrong term, feel free to correct me).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once I solve the MIP, the solver outputs a set of starting times &lt;span class=&quot;math-container&quot;&gt;$(t_1,\cdots,t_n)$&lt;/span&gt;. I would like to determine the earliest and latest starting times for each task, such that the optimal solution is unchanged (in terms of cost). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my current approach :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Solve the MIP. Let &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; be the optimal values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables.&lt;/li&gt;&#xA;&lt;li&gt;Solve the MIP again, with the additional constraint &lt;span class=&quot;math-container&quot;&gt;$x=x^*$&lt;/span&gt;, and minimize &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_j t_j$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Solve the MIP again, with the additional constraint &lt;span class=&quot;math-container&quot;&gt;$x=x^*$&lt;/span&gt;, and maximize &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_j t_j$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Steps 2) and 3) sequentially give me a set of &quot;earliest&quot; and &quot;latest&quot; starting times. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a more straightforward way to achieve this? Any approach is welcome. &lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2019-12-03T07:08:33.257" LastActivityDate="2019-12-03T16:52:11.233" Title="Variable Sensitivity Analysis" Tags="|linear-programming|sensitivity-analysis|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3142" PostTypeId="2" ParentId="2582" CreationDate="2019-12-03T07:47:53.507" Score="2" Body="&lt;p&gt;You actually don't need to add so many &quot;sum&quot; while writing constraints or objective function in Pyomo, write your objective function like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def objective_rule(model):&#xA;    return sum((5*model.inf_b4treat[i,j,t] + 10*model.level1[i,j,t]*model.inf_b4treat[i,j,t]) for i in model.Iset for j in model.Jset for t in model.Tset)&#xA;model.objective_rule = Objective(rule=objective_rule, sense=minimize, doc='Objective Function')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can check your constraints or objective function using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model.objective_rule.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2780" LastActivityDate="2019-12-03T07:47:53.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3143" PostTypeId="2" ParentId="3139" CreationDate="2019-12-03T08:39:34.523" Score="4" Body="&lt;p&gt;The notations that you used in the second formulation is confusing. I will reformulate your problem based on the approach that the authors explained on page 182 of the paper. In the following, I choose to discretize your continuous variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. The binary expansion will be in the following form:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x=2+((5-2)/M_1) \sum_{i=0}^{K}2^i \cdot s_i$$&lt;/span&gt;&#xA;in which &lt;span class=&quot;math-container&quot;&gt;$M_1 = 2^{K}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is a nonnegative integer. Now by multiplying two sides of the above equation by &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, you will be able to generate your objective function:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x \cdot y=2 \cdot y+((5-2)/M_1) \sum_{i=0}^{K}2^is_i \cdot y$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Define the new variable &lt;span class=&quot;math-container&quot;&gt;$z_i =s_i \cdot y$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x \cdot y=2 \cdot y+((5-2)/M_1) \sum_{i=0}^{K}2^i \cdot z_i$$&lt;/span&gt;&#xA;Now considering all of these changes, your model will be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min &amp;amp;\quad 2 \cdot y+((5-2)/M_1) \sum_{i=0}^{K}2^i \cdot z_i\\&#xA;\text{s.t.}&#xA;&amp;amp;\quad 0 \le y-z_i \le G(1-s_i)\\&#xA;&amp;amp;\quad 0 \le z_i \le G \cdot s_i\\&#xA;&amp;amp;\quad 5 \le y \le 10&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; is a scalar value that is large enough for the first and second constraints to be relaxed when &lt;span class=&quot;math-container&quot;&gt;$s_i=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s_i=1$&lt;/span&gt; respectively, based on the mentioned paper.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="36" LastEditDate="2019-12-03T14:21:25.793" LastActivityDate="2019-12-03T14:21:25.793" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3144" PostTypeId="1" AcceptedAnswerId="3151" CreationDate="2019-12-03T13:35:44.410" Score="15" ViewCount="346" Body="&lt;p&gt;Currently, I am working on a relatively simple optimization problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a set of time series (red) that get summed up to a cumulated time series (blue). The red time series have different forms (simplified here).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;During the optimization process, I want to scale the time series up or down so that my optimization solution is a set of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; factors for scaled the individual time series.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It applies:&#xA; &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol y = \sum\limits_{i=1}^{n}(\boldsymbol x_i \cdot s_i)$&lt;/span&gt;, where the &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol x_i$&lt;/span&gt; are the individual time series and &lt;span class=&quot;math-container&quot;&gt;$\pmb y$&lt;/span&gt; is the cumulated time series.&#xA;The factors are not allowed to be negative and together they must add up to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ugxzd.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ugxzd.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function for evaluating the cumulated time series calculates the MSE between the cumulated time series &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol y$&lt;/span&gt; and another time series &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol z$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{MSE} = \frac{1}{m}\sum_{i = 1}^{m}{(z_i - y_i)^2}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For my first tests, I used the heuristic Simulated Annealing to set the factors iteratively. This works, however, it seems to be a bit oversized for this problem, because it has only one minimum. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="2756" LastEditorUserId="123" LastEditDate="2019-12-04T19:13:46.113" LastActivityDate="2019-12-11T10:57:53.653" Title="Search approach to solve optimization problem with only a minimum where time series get scaled" Tags="|optimization|linear-programming|heuristics|simulated-annealing|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3145" PostTypeId="2" ParentId="3115" CreationDate="2019-12-03T16:42:41.357" Score="2" Body="&lt;p&gt;In the end, I reduced the matrix by using HashMaps and ignoring the 0 entities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code needs around 60' to run for a maximum of 2 different row combinations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sure that I can still optimize it, by reducing the iterations when I need at maximum &lt;strong&gt;X&lt;/strong&gt; different row combinations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code, is what I have at this moment.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import org.apache.poi.ss.usermodel.Cell;&#xA;import org.apache.poi.ss.usermodel.Row;&#xA;import org.apache.poi.xssf.usermodel.XSSFSheet;&#xA;import org.apache.poi.xssf.usermodel.XSSFWorkbook;&#xA;&#xA;import java.io.*;&#xA;import java.util.*;&#xA;&#xA;public class main {&#xA;    private static String excelFileName = &quot;Mappe1 v2.xlsx&quot;;&#xA;    private static int startExcelColumnIndex = 1;&#xA;    private static int endExcelColumnIndex = 11;&#xA;    private static int startExcelRowIndex = 1;&#xA;    private static int endExcelRowIndex = 16;&#xA;    private static ArrayList&amp;lt;String&amp;gt; stringArrayList = new ArrayList&amp;lt;String&amp;gt;();&#xA;    private static int maxNumberProviders = 2;&#xA;&#xA;    private static void combine(HashMap&amp;lt;Integer,HashMap&amp;lt;Integer,Integer&amp;gt;&amp;gt; rowsColumnsMatrixEntitiesHashMapHashMap,&#xA;                                HashMap&amp;lt;Integer,HashMap&amp;lt;Integer,Integer&amp;gt;&amp;gt; columnsRowsMatrixEntitiesHashMapHashMap,&#xA;                                HashMap&amp;lt;Integer,ArrayList&amp;lt;Integer&amp;gt;&amp;gt; columnsRowsIndicesArrayListHashMap) {&#xA;        /*matrix.length = 16 anzahl der zeilen&#xA;        * matrix[0].length = 11 anzahl der spalten*/&#xA;        int columnsNumber = columnsRowsMatrixEntitiesHashMapHashMap.size();&#xA;        int sizeArray[] = new int[columnsNumber];&#xA;        int counterArray[] = new int[columnsNumber];&#xA;        long total = 1;&#xA;        total = initializeSizeArraysAndFindIterationsCount(columnsRowsMatrixEntitiesHashMapHashMap,sizeArray,total);&#xA;//        total = 1000000;&#xA;        StringBuilder sb;&#xA;        String s;&#xA;        for (long count = total; count &amp;gt; 0; --count) {&#xA;            /*check the number of different providers, using the counterArray&#xA;            * this check is not anymore sufficient since not all indices start from the same number*/&#xA;            boolean combinationAcceptable = combinationAllowedForMaxNumberOfProviders(counterArray);&#xA;            sb = new StringBuilder();&#xA;            s = &quot;&quot;;&#xA;            HashSet&amp;lt;Integer&amp;gt; rowIndexInAColumn = new HashSet&amp;lt;Integer&amp;gt;();&#xA;            if (combinationAcceptable) {&#xA;                for (Map.Entry&amp;lt;Integer,ArrayList&amp;lt;Integer&amp;gt;&amp;gt; integerArrayListEntry: columnsRowsIndicesArrayListHashMap.entrySet()&#xA;                     ) {&#xA;                    int columnI = integerArrayListEntry.getKey();&#xA;                    ArrayList&amp;lt;Integer&amp;gt; columnIndices = integerArrayListEntry.getValue();&#xA;                    int rowIndex = columnIndices.get(counterArray[columnI]);&#xA;                    rowIndexInAColumn.add(rowIndex);&#xA;                    s = s + &quot;; &quot; + rowIndex +  &quot;,&quot; + columnI + &quot;; &quot;;&#xA;                }&#xA;               if (rowIndexInAColumn.size() &amp;lt;= maxNumberProviders) {&#xA;                   combinationAcceptable = true;&#xA;               } else {&#xA;                   combinationAcceptable = false;&#xA;               }&#xA;            }&#xA;            if (combinationAcceptable) {&#xA;                stringArrayList.add(s);&#xA;                int tmpi[] = new int[sb.toString().length()];&#xA;                for (int tmp = 0; tmp &amp;lt; sb.toString().length(); tmp++) {&#xA;                    tmpi[tmp] = Integer.parseInt(&quot;&quot; + sb.toString().toCharArray()[tmp]);&#xA;                }&#xA;            }&#xA;            for (int incIndex = columnsNumber - 1; incIndex &amp;gt;= 0; --incIndex) {&#xA;                if (counterArray[incIndex] + 1 &amp;lt; sizeArray[incIndex]) {&#xA;                    ++counterArray[incIndex];&#xA;                    break;&#xA;                }&#xA;                counterArray[incIndex] = 0;&#xA;            }&#xA;        }&#xA;    }&#xA;    public static long initializeSizeArraysAndFindIterationsCount(HashMap&amp;lt;Integer,HashMap&amp;lt;Integer,Integer&amp;gt;&amp;gt; columnsRowsMatrixEntitiesHashMapHashMap,&#xA;                                                                  int sizeArray[], long total) {&#xA;        for (Map.Entry&amp;lt;Integer,HashMap&amp;lt;Integer,Integer&amp;gt;&amp;gt; integerHashMapEntry: columnsRowsMatrixEntitiesHashMapHashMap.entrySet()&#xA;             ) {&#xA;            Integer providerColumn = integerHashMapEntry.getKey(); // provider index&#xA;            HashMap&amp;lt;Integer,Integer&amp;gt; rowMatrixEntityHashMap = integerHashMapEntry.getValue(); // eligibility for attribute of a provider&#xA;            int numberOfRowsInColumn = rowMatrixEntityHashMap.size();&#xA;           sizeArray[providerColumn] = numberOfRowsInColumn;&#xA;           total *= numberOfRowsInColumn; // multiply rows per column -&amp;gt; rows(columns[i])&#xA;        }&#xA;        return total;&#xA;    }&#xA;    public static boolean combinationAllowedForMaxNumberOfProviders(int[] counterArray) {&#xA;        HashSet&amp;lt;Integer&amp;gt; integerHashSet = new HashSet&amp;lt;&amp;gt;();&#xA;        for (int i = 0; i &amp;lt; counterArray.length; i++) {&#xA;            int rowIndex = counterArray[i];&#xA;            integerHashSet.add(rowIndex);&#xA;        }&#xA;        if (integerHashSet.size() &amp;lt;= maxNumberProviders) {&#xA;            return true;&#xA;        } else {&#xA;            return false;&#xA;        }&#xA;    }&#xA;    public static void main(String[] args) {&#xA;        /*int[][] matrix = {{1, 2, 3},&#xA;                {4, 5, 6},&#xA;                {7, 8, 9}};*/&#xA;        int[][] matrix = new int[endExcelRowIndex][endExcelColumnIndex];&#xA;        HashMap&amp;lt;Integer,HashMap&amp;lt;Integer,Integer&amp;gt;&amp;gt; rowsColumnsMatrixEntitiesHashMapHashMap = new HashMap&amp;lt;Integer, HashMap&amp;lt;Integer, Integer&amp;gt;&amp;gt;();&#xA;        HashMap&amp;lt;Integer,HashMap&amp;lt;Integer,Integer&amp;gt;&amp;gt; columnsRowsMatrixEntitiesHashMapHashMap = new HashMap&amp;lt;Integer, HashMap&amp;lt;Integer, Integer&amp;gt;&amp;gt;();&#xA;        HashMap&amp;lt;Integer,ArrayList&amp;lt;Integer&amp;gt;&amp;gt; columnsRowsIndicesArrayListHashMap = new HashMap&amp;lt;Integer,ArrayList&amp;lt;Integer&amp;gt;&amp;gt;();&#xA;        readXlsx(matrix);&#xA;        writeToDataStructures(matrix,rowsColumnsMatrixEntitiesHashMapHashMap,columnsRowsMatrixEntitiesHashMapHashMap,columnsRowsIndicesArrayListHashMap);&#xA;        System.out.println(&quot;matrix.length: &quot; + matrix.length);&#xA;        System.out.println(&quot;matrix[0].length: &quot; + matrix[0].length);&#xA;        constraintProgramming(matrix,rowsColumnsMatrixEntitiesHashMapHashMap,columnsRowsMatrixEntitiesHashMapHashMap,columnsRowsIndicesArrayListHashMap);&#xA;//        combine(rowsColumnsMatrixEntitiesHashMapHashMap,columnsRowsMatrixEntitiesHashMapHashMap,columnsRowsIndicesArrayListHashMap);&#xA;        writeToTXT();&#xA;    }&#xA;    public static void constraintProgramming(int[][] matrix, HashMap&amp;lt;Integer,HashMap&amp;lt;Integer,Integer&amp;gt;&amp;gt; rowsColumnsMatrixEntitiesHashMapHashMap,&#xA;                                             HashMap&amp;lt;Integer,HashMap&amp;lt;Integer,Integer&amp;gt;&amp;gt; columnsRowsMatrixEntitiesHashMapHashMap,&#xA;                                             HashMap&amp;lt;Integer,ArrayList&amp;lt;Integer&amp;gt;&amp;gt; columnsRowsIndicesArrayListHashMap) {&#xA;&#xA;    }&#xA;    public static void writeToDataStructures(int[][] matrix, HashMap&amp;lt;Integer,HashMap&amp;lt;Integer,Integer&amp;gt;&amp;gt; rowsColumnsMatrixEntitiesHashMapHashMap,&#xA;                                             HashMap&amp;lt;Integer,HashMap&amp;lt;Integer,Integer&amp;gt;&amp;gt; columnsRowsMatrixEntitiesHashMapHashMap,&#xA;                                             HashMap&amp;lt;Integer,ArrayList&amp;lt;Integer&amp;gt;&amp;gt; columnsRowsIndicesArrayListHashMap ) {&#xA;        // column-wise&#xA;        for (int i = 0; i &amp;lt; matrix.length; i++) {&#xA;            HashMap&amp;lt;Integer,Integer&amp;gt; columnsMatrixEntitiesHashMap = new HashMap&amp;lt;Integer, Integer&amp;gt;();&#xA;            for (int j = 0; j &amp;lt; matrix[0].length; j++) {&#xA;                int matrixEntity = matrix[i][j];&#xA;                if (matrixEntity &amp;gt;0) {&#xA;                    columnsMatrixEntitiesHashMap.put(j,matrixEntity);&#xA;                }&#xA;            }&#xA;            rowsColumnsMatrixEntitiesHashMapHashMap.put(i,columnsMatrixEntitiesHashMap);&#xA;        }&#xA;        for (int j = 0; j &amp;lt; matrix[0].length; j++) {&#xA;            HashMap&amp;lt;Integer,Integer&amp;gt; rowsMatrixEntitiesHashMap = new HashMap&amp;lt;Integer, Integer&amp;gt;();&#xA;            ArrayList&amp;lt;Integer&amp;gt; rowIndicesList = new ArrayList&amp;lt;Integer&amp;gt;();&#xA;            for (int i = 0; i &amp;lt; matrix.length; i++) {&#xA;                int matrixEntity = matrix[i][j];&#xA;                if (matrixEntity &amp;gt;0) {&#xA;                    rowIndicesList.add(i);&#xA;                    rowsMatrixEntitiesHashMap.put(i,matrixEntity);&#xA;                }&#xA;            }&#xA;            columnsRowsIndicesArrayListHashMap.put(j,rowIndicesList);&#xA;            columnsRowsMatrixEntitiesHashMapHashMap.put(j,rowsMatrixEntitiesHashMap);&#xA;        }&#xA;    }&#xA;    public static void writeToTXT() {&#xA;        PrintWriter writer = null;&#xA;        try {&#xA;            writer = new PrintWriter(&quot;MatrixCombinations.txt&quot;, &quot;UTF-8&quot;);&#xA;        } catch (FileNotFoundException e) {&#xA;            e.printStackTrace();&#xA;        } catch (UnsupportedEncodingException e) {&#xA;            e.printStackTrace();&#xA;        }&#xA;        for (String s: stringArrayList&#xA;        ) {&#xA;            writer.println(s);&#xA;        }&#xA;        writer.close();&#xA;    }&#xA;    public static void readXlsx(int[][] matrix) {&#xA;        File myFile = new File(excelFileName);&#xA;        FileInputStream fis = null;&#xA;        try {&#xA;            fis = new FileInputStream(myFile);&#xA;        } catch (FileNotFoundException e) {&#xA;            e.printStackTrace();&#xA;            System.exit(0);&#xA;        }&#xA;        // Finds the workbook instance for XLSX file&#xA;        XSSFWorkbook myWorkBook = null;&#xA;        try {&#xA;            myWorkBook = new XSSFWorkbook(fis);&#xA;        } catch (IOException e) {&#xA;            e.printStackTrace();&#xA;            System.exit(0);&#xA;        }&#xA;        // read Excel Sheet&#xA;        XSSFSheet mySheet = myWorkBook.getSheet(&quot;Kombinationen&quot;);&#xA;        // Get iterator to all the rows in current sheet&#xA;        Iterator&amp;lt;Row&amp;gt; rowIterator = mySheet.iterator();&#xA;        while (rowIterator.hasNext()) {&#xA;            Row row = rowIterator.next();&#xA;            if (row.getRowNum() &amp;gt;= startExcelRowIndex &amp;amp;&amp;amp; row.getRowNum() &amp;lt;= endExcelRowIndex) {&#xA;                Iterator&amp;lt;Cell&amp;gt; cellIterator = row.cellIterator();&#xA;                while (cellIterator.hasNext()) {&#xA;                    Cell cell = cellIterator.next();&#xA;                    if (cell.getColumnIndex() &amp;gt;= startExcelColumnIndex &amp;amp;&amp;amp; cell.getColumnIndex() &amp;lt;= endExcelColumnIndex) {&#xA;                        matrix[row.getRowNum()-startExcelRowIndex][cell.getColumnIndex()-startExcelColumnIndex] = (int) cell.getNumericCellValue();&#xA;                    }&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="456" LastActivityDate="2019-12-03T16:42:41.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3146" PostTypeId="2" ParentId="3141" CreationDate="2019-12-03T16:52:11.233" Score="4" Body="&lt;p&gt;Having fixed the discrete decisions, you could start at the beginning and work forward through the task dependency graph, starting each task as early as possible; then work backward from the end, starting each task as late as possible. I don't know that it is superior in any way to what you are doing, but it might be easier to explain to someone (a customer of the analysis, for instance).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-12-03T16:52:11.233" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3147" PostTypeId="1" AcceptedAnswerId="3148" CreationDate="2019-12-03T18:01:15.003" Score="6" ViewCount="1080" Body="&lt;p&gt;As a similar post of mine &lt;a href=&quot;https://or.stackexchange.com/questions/3115/find-all-combinations-of-a-matrix/3145#3145&quot;&gt;Find all Combinations of a Matrix&lt;/a&gt; I am trying to find matrix combinations with entries &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;0$&lt;/span&gt; meaning for a matrix&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{bmatrix}&#xA;0 &amp;amp; 1 &amp;amp; 3 \\&#xA;5 &amp;amp; 2 &amp;amp; 1 \\&#xA;0 &amp;amp; 0 &amp;amp; 10&#xA;\end{bmatrix}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following combinations: &lt;span class=&quot;math-container&quot;&gt;$(5,1,3); (5,2,1); (5,1,10);...$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have decided to use constraint-programming with OR-Tools for this case to find all the solutions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, I want to use added constraints so that at most &lt;strong&gt;X&lt;/strong&gt; rows should get used for a combination, e.g., max 2 rows &lt;span class=&quot;math-container&quot;&gt;$(5,1,3)$&lt;/span&gt; but not &lt;s&gt;(5,1,10)&lt;/s&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;At the moment I have the following model:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; is a binary decision variable with &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; being a row and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; being a column&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; a binary variable stating whether row &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is getting used for the combinations&lt;/li&gt;&#xA;&lt;li&gt;I need exactly one row per column:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_ix_{i,j} = 1 \ \forall j \in J$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Choose only a matrix entity if it is &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;0$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$p_{i,j}$&lt;/span&gt; stating the matrix elements:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{i,j} \leq p_{i,j} \ \forall i,j$$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Help constraint to see whether a row is used for a combination by setting &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_jx_{i,j} \leq y_i \cdot |J| \ \forall i \in I$$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Limit the use of rows for the combinations by a number of &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_iy_i = q$$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1) (Solved) As of now, I am getting weird results when I define the variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;. By that, I mean that I am getting the same result multiple times.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2) Also, how to find which row is used in the combinations? As of now, the constraint 5 is inadequate, since y can still get the value 1 although the whole row is not chosen.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y = {}&#xA;       for i in range(matrixRows): # rows&#xA;          y[i] = model.NewBoolVar('vendor_%d' % (i))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I comment it out the results are fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you can find the complete code with constraints 5 and 6 commented out (definition of &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; included):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    from __future__ import print_function&#xA;    from ortools.sat.python import cp_model&#xA;&#xA;    class SolutionPrinter(cp_model.CpSolverSolutionCallback):&#xA;&#xA;        # def __init__(self,x,y,matrixRows,matrixColumns,matrix):&#xA;        def __init__(self,x,matrixRows,matrixColumns,matrix):&#xA;            cp_model.CpSolverSolutionCallback.__init__(self)&#xA;            self._x = x&#xA;            # self._y = y&#xA;            self._matrixRows = matrixRows&#xA;            self._matrixColumns = matrixColumns&#xA;            self._matrix = matrix&#xA;            self._solution_count = 0&#xA;&#xA;        def OnSolutionCallback(self):&#xA;            self._solution_count += 1&#xA;            for j in range(self._matrixColumns):&#xA;                for i in range(self._matrixRows):&#xA;                    if self.Value(self._x[(i,j)]):&#xA;                        print('x: %d for x(%d,%d) and matrix value:%d' %(self.Value(self._x[(i,j)]),i,j,matrix[i][j]))&#xA;            # for v in self._x:&#xA;            # print('%s = %i' % (v, self.Value(v)), end=' ')&#xA;            print()&#xA;&#xA;        def SolutionCount(self):&#xA;            return self._solution_count&#xA;&#xA;    def main(matrix):&#xA;       model = cp_model.CpModel()&#xA;       matrixRows = len(matrix)&#xA;       matrixColumns = len(matrix[0])&#xA;      # define variables&#xA;       x = {}&#xA;       for i in range(matrixRows): # rows&#xA;         for j in range(matrixColumns):&#xA;           x[(i,j)] = model.NewBoolVar('company_%d,%d' % (i,j))&#xA;&#xA;       y = {}&#xA;       for i in range(matrixRows): # rows&#xA;          y[i] = model.NewBoolVar('vendor_%d' % (i))&#xA;&#xA;       # choose exactly one vendor per attribute&#xA;       for j in range(matrixColumns):&#xA;        model.Add(sum(x[(i,j)] for i in range(matrixRows)) == 1)&#xA;&#xA;       # to choose value x(i,j), the parameter of the matrix has to be &amp;gt;0&#xA;       for i in range(matrixRows):&#xA;           for j in range(matrixColumns):&#xA;               model.Add(x[i,j] &amp;lt;= matrix[i][j])&#xA;&#xA;       # # help constraint to count whether a vendor is in the mix&#xA;       # for i in range(matrixRows):&#xA;       #         model.Add(sum(x[i, j] for j in range(matrixRows)) &amp;lt;= y[i] *matrixColumns)&#xA;       #&#xA;       # # set the max vendors&#xA;       # model.Add(sum(y[i] for i in range(matrixRows)) &amp;lt;= 2)&#xA;&#xA;       #call the solver and display the results&#xA;       solver = cp_model.CpSolver()&#xA;       # solution_printer = SolutionPrinter(x,y,matrixRows,matrixColumns,matrix)&#xA;       # the following is an object of the class SolutionPrinter&#xA;       solution_printer = SolutionPrinter(x,matrixRows,matrixColumns,matrix)&#xA;       status = solver.SearchForAllSolutions(model, solution_printer)&#xA;       print()&#xA;       print('Solutions found: %i' % solution_printer.SolutionCount())&#xA;&#xA;    if __name__ == '__main__':&#xA;      matrix = [[0,1,3],[5,0,1],[0,0,10]]&#xA;      main(matrix)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="456" LastEditorUserId="981" LastEditDate="2023-12-29T10:51:28.697" LastActivityDate="2023-12-29T10:51:28.697" Title="Constraint Programming OR-Tools finding Matrix Combinations" Tags="|python|constraint-programming|or-tools|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3148" PostTypeId="2" ParentId="3147" CreationDate="2019-12-03T18:52:23.053" Score="7" Body="&lt;p&gt;You get the same result &lt;span class=&quot;math-container&quot;&gt;$2^{\operatorname{len}(y)}$&lt;/span&gt; times because &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; is not constrained.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see that by adding this to your callback:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;print(&quot;y:&quot;, [self.Value(y) for y in self._y.values()])&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x: 1 for x(1,0) and matrix value:5&#xA;x: 1 for x(0,1) and matrix value:1&#xA;x: 1 for x(1,2) and matrix value:1&#xA;y: [0, 0, 0]&#xA;&#xA;x: 1 for x(1,0) and matrix value:5&#xA;x: 1 for x(0,1) and matrix value:1&#xA;x: 1 for x(1,2) and matrix value:1&#xA;y: [1, 0, 0]&#xA;&#xA;...&#xA;y: [1, 0, 1]&#xA;&#xA;...&#xA;y: [0, 0, 1]&#xA;&#xA;...&#xA;y: [0, 1, 1]&#xA;&#xA;...&#xA;y: [0, 1, 0]&#xA;&#xA;...&#xA;y: [1, 1, 0]&#xA;&#xA;...&#xA;y: [1, 1, 1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: I would check &lt;code&gt;matrix[i][j] != 0&lt;/code&gt; before creating the boolean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model.Add(sum(x[i, j] for j in range(matrixRows)) &amp;gt; 0).OnlyEnforceIf(y[i])&#xA;model.Add(sum(x[i, j] for j in range(matrixRows)) == 0).OnlyEnforceIf(y[i].Not())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2019-12-04T16:16:58.340" LastActivityDate="2019-12-04T16:16:58.340" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3149" PostTypeId="2" ParentId="2947" CreationDate="2019-12-04T07:21:59.773" Score="4" Body="&lt;p&gt;It is also my impression that decomposition methods are not widely used in a commercial context. In the industry, you often make an &quot;effort vs. value&quot; estimation to decide what methods to use. This will often not favor decomposition algorithms due to a relatively high effort and the risk of it not providing better results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would make the following considerations before deciding to implement a decomposition algorithm:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Value for end-user&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The first question is to estimate what business value would we get out of it. Does the problem currently take unreasonable amount of time to solve or do we want to get better solutions within some timespan? &#xA;Another aspect is how likely is it that the decomposition will give us these results, it can be fairly hard to predict if decomposition actually will work.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Effort to build&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It is not straight forward to implement a robust decomposition algorithm. It requires quite a lot of code that would require testing and error handling&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Effort to maintain&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The code has to be maintained. Not only by the person who implemented it, but also by team members. This will require that multiple persons have a fairly deep understanding of the decomposition method and I would be fairly concerned around how fast we could identify a bug and fix it if an error occurred in a production system.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Effort to extend&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In industry, models are living organisms that keep changing based on new business requirements. I would be concerned that the decomposition would either not work or lose its advantage if we had to incorporate some new constraints or objectives into the model.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In the end, it depends on the specific problem and there are definitely problems where decomposition works very well and if the potential upside is high, a first step would be to build a proof-of-concept to understand it better (e.g. try something like &lt;a href=&quot;https://gcg.or.rwth-aachen.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GCG&lt;/a&gt; for Dantzig-Wolfe, and &lt;a href=&quot;https://gcg.or.rwth-aachen.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GCG&lt;/a&gt; or &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/benders/defaultDecomp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPLEX&lt;/a&gt; for Benders decomposition). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of what methods to try instead, I refer to this previous answer: &lt;a href=&quot;https://or.stackexchange.com/questions/2630/how-could-we-simplify-solving-the-large-scale-mips-without-using-any-advanced-me/2645#2645&quot;&gt;How could we simplify solving the large scale MIPs without using any advanced methods like decompositions?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="140" LastEditorUserId="140" LastEditDate="2019-12-05T07:52:21.273" LastActivityDate="2019-12-05T07:52:21.273" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3150" PostTypeId="2" ParentId="3115" CreationDate="2019-12-04T12:59:50.370" Score="4" Body="&lt;p&gt;It sounds like what you want is to reduce each vector in your matrix to the relevant entries, and take the &lt;a href=&quot;https://en.wikipedia.org/wiki/Cartesian_product&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cartesian Product&lt;/a&gt; of the column vectors. That is definitely not a problem where linear programming can help, but where you should resort either to traditional combinatorial algorithms, or use a database system that typically has support for generating all kinds of combinations of (sets of) columns in tables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Writing code that generates a Cartesian product is doable, but also a hassle. I would advice to use a Java library that supports combinatorics; one that I could find with a simple search is &lt;a href=&quot;https://github.com/dpaukov/combinatoricslib3&quot; rel=&quot;nofollow noreferrer&quot;&gt;combinatoricslib3&lt;/a&gt;. This library has the advantage that it does not generate all combinations in memory, but rather generates them one-by-one when they are requested (in a lazy fashion). That is probably a lot more efficient when you just want to write all combinations to a file, and the amount of RAM in your computer is not a bottleneck any more on which sizes of files you can generate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noted that your Java code suffers from resource leaks, which is wise (and easy) to avoid by using the &lt;a href=&quot;https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;try-with-resources&lt;/a&gt; construct that was introduced in Java 7 and which is very similar to Python's &lt;code&gt;with&lt;/code&gt; keyword.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, it is not clear to me how you want to deal with duplicate values in columns. Maybe your data is sanitized and such values do not occur, or maybe you want duplicate values to result in certain combinations being duplicated in your output as well. That is something to think about.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Writing neater Java code than in your example, you would end up with something like the following. Note that I did not test this code in much detail, and that I use some Java 8 features to make life easier or more flexible.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-java prettyprint-override&quot;&gt;&lt;code&gt;import java.io.File;&#xA;import java.io.FileInputStream;&#xA;import java.io.IOException;&#xA;import java.io.PrintWriter;&#xA;import java.lang.reflect.Array;&#xA;import java.util.ArrayList;&#xA;import java.util.Collections;&#xA;import java.util.HashSet;&#xA;import java.util.List;&#xA;import java.util.Set;&#xA;import java.util.function.IntPredicate;&#xA;import java.util.stream.Collectors;&#xA;&#xA;import org.apache.poi.ss.usermodel.Cell;&#xA;import org.apache.poi.ss.usermodel.Row;&#xA;import org.apache.poi.ss.usermodel.Sheet;&#xA;import org.apache.poi.ss.util.CellRangeAddress;&#xA;import org.apache.poi.xssf.usermodel.XSSFWorkbook;&#xA;import org.paukov.combinatorics3.Generator;&#xA;import org.paukov.combinatorics3.IGenerator;&#xA;&#xA;public class Main {&#xA;&#xA;    public static void main(String [] args) throws IOException {&#xA;        // Define input/output files&#xA;        File input = new File(&quot;Mappe1 v2.xlsx&quot;);&#xA;        File output = new File(&quot;MatrixCombinations.txt&quot;);&#xA;&#xA;        // Define cell range&#xA;        CellRangeAddress range = CellRangeAddress.valueOf(&quot;B2:L17&quot;);&#xA;        // Alternatively, you can do:&#xA;        //CellRangeAddress range = new CellRangeAddress(1, 16, 1, 11);&#xA;&#xA;        // Read the data from the input file (this is the non-unique version due to the use of false)&#xA;        List&amp;lt;List&amp;lt;Integer&amp;gt;&amp;gt; data = readDataNonZero(input, &quot;Kombinationen&quot;, range, true);&#xA;&#xA;        // Generate a lazy/iterable version of cartesian product based combinations&#xA;        IGenerator&amp;lt;List&amp;lt;Integer&amp;gt;&amp;gt; combinations = combinations(data);&#xA;        // Write everything to the output file delimited by ; symbols&#xA;        writeToFile(output, &quot;;&quot;, combinations);     &#xA;    }&#xA;&#xA;    public static void writeToFile(File output, String delim, Iterable&amp;lt;List&amp;lt;Integer&amp;gt;&amp;gt; combinations) throws IOException {&#xA;        try (PrintWriter pw = new PrintWriter(output, &quot;UTF-8&quot;)) {&#xA;            for (List&amp;lt;Integer&amp;gt; combination : combinations) {&#xA;                // Convert the integers to a delimited String&#xA;                String row = combination.stream()&#xA;                                        .map(Object::toString)&#xA;                                        .collect(Collectors.joining(delim));&#xA;                // Write the row to the output&#xA;                pw.println(row);&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    public static IGenerator&amp;lt;List&amp;lt;Integer&amp;gt;&amp;gt; combinations(List&amp;lt;List&amp;lt;Integer&amp;gt;&amp;gt; matrix) {&#xA;        // Some casting required due to generics/arrays behavior in Java&#xA;        @SuppressWarnings(&quot;unchecked&quot;)&#xA;        List&amp;lt;Integer&amp;gt; [] array = (List&amp;lt;Integer&amp;gt;[]) Array.newInstance(List.class, matrix.size());&#xA;        array = matrix.toArray(array);&#xA;        return Generator.cartesianProduct(array);&#xA;    }&#xA;&#xA;    // Reads the data from a particular spreadsheet file and provides a default predicate which only removes zero values&#xA;    public static List&amp;lt;List&amp;lt;Integer&amp;gt;&amp;gt; readDataNonZero(File file, String sheetName, CellRangeAddress range, boolean unique) throws IOException {&#xA;        return readData(file, sheetName, range, i -&amp;gt; i != 0, unique);&#xA;    }&#xA;&#xA;    // Reads the data from a particular spreadsheet file&#xA;    public static List&amp;lt;List&amp;lt;Integer&amp;gt;&amp;gt; readData(File file, String sheetName, CellRangeAddress range, IntPredicate accept, boolean unique) throws IOException {&#xA;        // This try-with-resources avoids a resource leak&#xA;        try (XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(file))) {&#xA;            return readData(wb.getSheet(sheetName), range, accept, unique);&#xA;        }&#xA;    }&#xA;&#xA;    /**&#xA;     * Reads data from a spreadsheet in the given cell range and constructs a sparsified data set as a list of lists&#xA;     * @param sheet the sheet to read&#xA;     * @param range the cell range address we want to read from the spreadsheet&#xA;     * @param accept a predicate which we use to check which numbers should be included&#xA;     * @param unique whether each column in our data set should hold unique values or whether duplicates are allowed&#xA;     * @return a list of column-lists that contain possibly unique occurrences of values that are valid according to the predicate&#xA;     */&#xA;    public static List&amp;lt;List&amp;lt;Integer&amp;gt;&amp;gt; readData(Sheet sheet, CellRangeAddress range, IntPredicate accept, boolean unique) {&#xA;        int firstCol = range.getFirstColumn();&#xA;        // Initialize the output data structure&#xA;        int cols = 1 + range.getLastColumn() - firstCol;&#xA;        List&amp;lt;List&amp;lt;Integer&amp;gt;&amp;gt; result = new ArrayList&amp;lt;&amp;gt;(cols);&#xA;        List&amp;lt;Set&amp;lt;Integer&amp;gt;&amp;gt; uniqueCheck = new ArrayList&amp;lt;&amp;gt;(cols);&#xA;        for (int t=0; t &amp;lt; cols; t++) {&#xA;            result.add(new ArrayList&amp;lt;&amp;gt;());&#xA;            if (unique) {&#xA;                uniqueCheck.add(new HashSet&amp;lt;&amp;gt;());&#xA;            }&#xA;        }&#xA;        // Read the input&#xA;        Set&amp;lt;Integer&amp;gt; checkSet = Collections.emptySet();&#xA;        for (Row row : sheet) {&#xA;            for (Cell c : row) {&#xA;                if (range.isInRange(c)) {&#xA;                    int col = c.getColumnIndex() - firstCol;&#xA;                    int val = (int) c.getNumericCellValue();&#xA;                    if (unique) {&#xA;                        checkSet = uniqueCheck.get(col);&#xA;                    }&#xA;                    // Also check if we already added if we require uniqueness&#xA;                    if (accept.test(val) &amp;amp;&amp;amp; !checkSet.contains(val)) {&#xA;                        result.get(col).add(val);&#xA;                        // If we are checking for unique, add this value to the set&#xA;                        if (unique) {&#xA;                            checkSet.add(val);&#xA;                        }&#xA;                    }&#xA;                }&#xA;            }&#xA;        }&#xA;        return result;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which assumes you have added the following external dependencies to your project:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-xml prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;&#xA;    &amp;lt;groupId&amp;gt;org.apache.poi&amp;lt;/groupId&amp;gt;&#xA;    &amp;lt;artifactId&amp;gt;poi-ooxml&amp;lt;/artifactId&amp;gt;&#xA;    &amp;lt;version&amp;gt;4.1.0&amp;lt;/version&amp;gt;&#xA;&amp;lt;/dependency&amp;gt;&#xA;&amp;lt;dependency&amp;gt;&#xA;    &amp;lt;groupId&amp;gt;com.github.dpaukov&amp;lt;/groupId&amp;gt;&#xA;    &amp;lt;artifactId&amp;gt;combinatoricslib3&amp;lt;/artifactId&amp;gt;&#xA;    &amp;lt;version&amp;gt;3.3.0&amp;lt;/version&amp;gt;&#xA;&amp;lt;/dependency&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1047" LastActivityDate="2019-12-04T12:59:50.370" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3151" PostTypeId="2" ParentId="3144" CreationDate="2019-12-04T13:50:19.400" Score="11" Body="&lt;p&gt;Your problem actually comes down to a constrained linear regression problem where &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is your dependent variable, the &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$j=1,\dots,n$&lt;/span&gt; are your independent variables and &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is your vector with regression coefficients. Without any constraints, the unique solution optimizing the MSE is the least squares estimator: &#xA;&lt;span class=&quot;math-container&quot;&gt;$$\hat{s}=(X'X)^{-1}X'z, \quad \text{where}\quad X=\begin{bmatrix}x_1&amp;amp;x_2&amp;amp;\cdots&amp;amp; x_n\end{bmatrix}$$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The requirement that all weights add up to one can be formalized as the constraint &lt;span class=&quot;math-container&quot;&gt;$\iota's = 1$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$\iota$&lt;/span&gt; the all-ones vector. There also exists a closed-form solution to the least squares problem with such an equality constraint, see &lt;a href=&quot;https://en.wikipedia.org/wiki/Ordinary_least_squares#Constrained_estimation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding the inequality constraints is more complicated. My approach would be to use an &lt;a href=&quot;https://en.wikipedia.org/wiki/Active-set_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Active Set&lt;/a&gt; algorithm. Here, we start by solving the problem without the inequality constraints. Then, we check whether there are any time series (regression coefficients) with negative weights. We then remove these time series from the problem and resolve. We continue until all weights are positive. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty confident this method would result in finding the global optimum (although it would take me some time to write down a proof).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an alternative method, if you do not like programming an algorithm yourself, you could also pass your original problem to a commercial solver. For example, both CPLEX and Gurobi can solve convex quadratic programs with linear constraints fairly well. &lt;/p&gt;&#xA;" OwnerUserId="764" LastEditorUserId="764" LastEditDate="2019-12-11T10:57:53.653" LastActivityDate="2019-12-11T10:57:53.653" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3152" PostTypeId="1" CreationDate="2019-12-04T16:17:47.607" Score="7" ViewCount="448" Body="&lt;p&gt;Since max flow formulation can be easily solved using LP, I wanted to ask the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to solve a simple max flow problem where the graph is bipartite but with one added constraint. The constraint is that the flow from any supply node '&lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;' should not be split, i.e. suppose I have a supply at node '&lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;' of 4 units and have arcs &lt;span class=&quot;math-container&quot;&gt;$(a,x)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(a,y)$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$(a,z)$&lt;/span&gt;, then the entire 4 units of supply should go through one and only one arc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an LP formulation for this? I can model it using integer variables....&lt;/p&gt;&#xA;" OwnerUserId="899" LastEditorUserId="36" LastEditDate="2019-12-04T16:51:05.220" LastActivityDate="2019-12-04T19:16:44.810" Title="Max flow problem without splitting the flow from the supply nodes - LP formulation help" Tags="|linear-programming|modeling|network-flow|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3153" PostTypeId="2" ParentId="3152" CreationDate="2019-12-04T17:00:16.913" Score="4" Body="&lt;p&gt;Add binary variables &lt;span class=&quot;math-container&quot;&gt;$y_{ai}$&lt;/span&gt; and the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_{ax}+ y_{ay} + y_{za} &amp;amp;\le 1\\&#xA;x_{ai} &amp;amp;\le 4 y_{ai}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2019-12-04T19:16:44.810" LastActivityDate="2019-12-04T19:16:44.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3154" PostTypeId="2" ParentId="3152" CreationDate="2019-12-04T18:20:51.383" Score="4" Body="&lt;p&gt;If you define binary variables for each of the arcs let's say &#xA;&lt;span class=&quot;math-container&quot;&gt;$$m_{ij} \ \ \forall i\in \text{supply}\ \ \text{and} \ \ j \in \text{demand}$$&lt;/span&gt; then you can add the following constraint to the model:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_j m_{ij} = 1$$&lt;/span&gt;&#xA;and the shipment then can be limited as the following (&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a large number to relax &lt;span class=&quot;math-container&quot;&gt;$s_{ij}$&lt;/span&gt; if necessary):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$s_{ij} \le M \cdot m_{ij}$$&lt;/span&gt;&#xA;In this formulation &lt;span class=&quot;math-container&quot;&gt;$s_{ij}$&lt;/span&gt; is still continuous variable &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2019-12-04T19:16:12.410" LastActivityDate="2019-12-04T19:16:12.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3155" PostTypeId="2" ParentId="2947" CreationDate="2019-12-05T12:38:43.060" Score="14" Body="&lt;p&gt;The gap between industry and academia is huge.&lt;/p&gt;&#xA;&lt;p&gt;My suggestion for a future professional would be to learn very good coding because without that skill people are very limited.&lt;/p&gt;&#xA;&lt;p&gt;What I have seen in practice is that it's impossible to gauge how useful an algorithm/method is without trying it out first, so the most important skill is the skill to try different things out quickly, a.k.a. coding.&lt;/p&gt;&#xA;&lt;p&gt;What I tell my developers and optimisation specialists is to work smart, not hard - this means writing tools to automate anything that is time consuming and needs to be done more than once, because we need to try many different things to see what works. We have tools for generating symbolic decompositions automatically, distributing calculations over a cluster, scripting reformulations, testing, benchmarking, etc. Basically, if we can imagine it, it's either built, being built, or scheduled to be built.&lt;/p&gt;&#xA;&lt;h2&gt;Methods&lt;/h2&gt;&#xA;&lt;p&gt;For large-scale systems, modern methods focus on lowering memory requirements or distributing memory among many machines.&lt;/p&gt;&#xA;&lt;p&gt;If the reason the problem is large is that it's very dense, and not because it has a trillion variables, then:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For NLPs, fast gradient methods are state of the art (e.g., the fast proximal gradient method).&lt;/li&gt;&#xA;&lt;li&gt;For LPs, interior point is still the king if the system is very large.&lt;/li&gt;&#xA;&lt;li&gt;For MI(N)LPs, people focus on distributing the calculations for traditional methods, e.g., generate the Benders decomposition and use many parallel workers to solve the subproblems.&lt;/li&gt;&#xA;&lt;li&gt;Where branch-and-bound is applicable, using a hierarchical multiple manager-worker system to process nodes and create branch-and-bound subtrees in parallel like in PARASCIP or Octeract Engine.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If a system has so many variables that we can't fit it into memory, people are unlikely to use deterministic methods in practice, and will try stochastic stuff instead (e.g., evolutionary algorithms or PSO).&lt;/p&gt;&#xA;&lt;p&gt;In general, the main differentiator nowadays is not theory, but figuring out how to implement it properly using parallel hardware. Unfortunately, this is not what academic research is designed to disseminate, which brings me to the &amp;quot;what I think of this claim&amp;quot; part of your question:&lt;/p&gt;&#xA;&lt;h2&gt;Industrial adoption&lt;/h2&gt;&#xA;&lt;p&gt;Software-wise, industrial software is light years ahead of any academic code in terms of performance, robustness, and reliability. CPLEX/GUROBI vs CBC is a great example of this.&lt;/p&gt;&#xA;&lt;p&gt;Theory-wise, it's hard to tell. While a lot of amazing theoretical work has been done in academia over the past three decades, maybe 0.01% of it has found its way to actual application.&lt;/p&gt;&#xA;&lt;p&gt;As a former academic, my conclusion was that the reason is the way the academic system is designed, which is why I left academia.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The academic reality&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The central fallacy is that professors believe that PhD students can write professional-grade software. They can't. As a former PhD student myself, I realised this when I hired our first professional developer. There is simply no comparison between what people who write code for a living and the rest of us can do. My development work is mostly in the R&amp;amp;D, i.e., to prototype new features and to do algorithmic optimisations for performance. My code eventually goes to our developers who turn it into proper code. It's not that my code is bad, it's just not efficient for me to spend two months designing something properly. I do the things only I can do, and the developers do the things only they can do, and that is how it should be done nowadays.&lt;/p&gt;&#xA;&lt;p&gt;Coding has advanced a lot since the 90's, so asking a theorist to write good code is not as straightforward as it was 30 years ago, but most professors still think that way, maybe because this was kind of true when they were students. There was less to know.&lt;/p&gt;&#xA;&lt;p&gt;Because of the overwhelming growth in coding techniques and tools, asking students to write good (by today's standards) code is the equivalent of expecting an experimentalist to know as much as the theorists and the developers. It's simply too much for any one person.&lt;/p&gt;&#xA;&lt;p&gt;This is a very practical issue because, at the end of the day, applied math is pointless unless implemented into software. This becomes trickier if we consider that it's very hard to properly compare the runtime behaviour of two algorithms unless both are professionally implemented. If there is a flaw in implementation, an algorithm can easily be 1,000,000 times slower than it could. If there is a bug because there is no testing framework in place, an algorithm can be 1,000,000 faster instead.&lt;/p&gt;&#xA;&lt;p&gt;Developing software properly costs money, time, and requires hiring professional developers. Unfortunately, only a handful of universities world-wide are willing to make that investment.&lt;/p&gt;&#xA;&lt;p&gt;The systemic issue is that academics are not rewarded by the system for producing good, tested, and reusable software. In fact they are actively discouraged because their h-index will not be as high (5 years of development for one good publication vs 4-5 theoretical papers a year).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The result&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;As a result, we have software to solve optimisation problems, but we still lack proper tools and libraries for developing new optimisation software quickly and correctly. This stagnates experimentation, is in the way of proper testing, and so on.&lt;/p&gt;&#xA;&lt;p&gt;Everything anyone implements needs to be done pretty much from scratch. The COIN-OR project was an amazing idea that tried to address this, however the overwhelming majority of code in the projects is not reusable either because (i) it's unreadable so it can only be used as a black box (e.g., CBC/IPOPT), or (ii) it's unreadable and buggy, so it can't be used at all because no-one can read the code to fix it, or (iii) is really good but almost completely undocumented (e.g., CBC).&lt;/p&gt;&#xA;&lt;p&gt;Don't get me wrong, some of the COIN-OR/open-source stuff is really good, it's simply rarely designed to be a true open source collaborative project, because it's driven by academics instead of coders. It's usually the code someone wrote and generously decided to share with others. The difference between OR code and other popular open source projects is actually staggering - there is a reason Tensorflow has 56,000 watchers on github and IPOPT only has 16.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="500" LastEditDate="2023-04-02T19:55:46.707" LastActivityDate="2023-04-02T19:55:46.707" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3156" PostTypeId="1" CreationDate="2019-12-05T12:50:47.670" Score="7" ViewCount="1099" Body="&lt;p&gt;Could someone give additional explanations about the TimeLimit of CPLEX for CPO? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using CPLEX to solve a problem of assignment and scheduling in which each task needs to be assigned to a worker, by respecting a correct sequence. There is a cost of changing the worker and the cost of tasks execution changes from one worker to another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I do not state the time limit, it takes about 15 hours to return a result. When I stated the time limit = 10 seconds, it took about 10 seconds to find a correct result, correspondent to that found by the solver after turning during 15 hours. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only difference between both results is the sequence of tasks executed by the same worker, but it does not imply on the objective function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My questions are:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why the solver takes 15 hours to obtain a result if it could take&#xA;just few seconds to obtain an equivalent result?  &lt;/li&gt;&#xA;&lt;li&gt;Could it be related to the fact that there are many possibilities of&#xA;sequencing the tasks without changing the objective function value?&lt;/li&gt;&#xA;&lt;li&gt;How to know which is the most appropriate time limit to use?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2453" LastActivityDate="2019-12-07T16:26:51.863" Title="Constraint programming using solver: how to state the time limit of search?" Tags="|solver|cplex|constraint-programming|docplex|cp-optimizer|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3157" PostTypeId="2" ParentId="3156" CreationDate="2019-12-05T13:04:26.580" Score="6" Body="&lt;p&gt;CPLEX is probably spending 15 hours trying to reduce the optimality gap. This is very common issue in MILP problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way MILPs are solved is commonly to make all integers continuous and solve the resulting LP. That is called the linear relaxation, and its solution provides a valid lower bound (if we are minimising) on the objective function. The difference between the best integer solution the solver has found and that lower bound is called the optimality gap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In branch and bound, it's common to find the best integer solution fairly quickly, and the bulk of calculations is spent to prove that this solution is globally optimal, i.e., to close the optimality gap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two ways to handle that in practice:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use the optimality gap as your convergence criterion, i.e., &quot;stop calculating if the gap is smaller than 10%&quot;.&lt;/li&gt;&#xA;&lt;li&gt;Define a design goal in your objective function. This means that, instead of minimising cost you would minimise &lt;code&gt;cost-good_enough_cost&lt;/code&gt; and stop when that number is zero. This could also be expressed in terms of a constraint: &lt;code&gt;cost-good_enough_cost &amp;gt;= 0&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="123" LastEditDate="2019-12-05T20:19:16.043" LastActivityDate="2019-12-05T20:19:16.043" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3159" PostTypeId="2" ParentId="3156" CreationDate="2019-12-06T04:11:44.310" Score="9" Body="&lt;p&gt;What Nikaza said, and also: problems of this kind often have a large number of solutions that differ only by trivial permutations/relabellings/reorderings. For example, if one worker is assigned 10 tasks that can be done in any order with no change to the objective, then there are 10! = 3628800 solutions that will have exactly the same OF. If another worker has the same situation, then you have around 10&lt;sup&gt;13&lt;/sup&gt; optimal solutions that are identical modulo task reorderings, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my experience, this kind of symmetry sometimes leads to excessively slow solution times with the sort of behaviour you describe, and tweaking the problem to break symmetry can significantly improve performance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple of options for symmetry-breaking:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Add constraints that impose orderings.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For example, if tasks A and B are identical in requirements, we might require that B can't start before A does.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make small perturbations to the objective function weights such that the solutions are no longer identical. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For example, if your model has a binary decision variable &lt;code&gt;x[j,t]&lt;/code&gt; indicating whether task j begins at time t, then adding the sum of &lt;code&gt;x[j,t]*r[j,t]*smallnum&lt;/code&gt; to the objective function breaks symmetry with respect to task ordering. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;code&gt;r[j,t]&lt;/code&gt; is a randomly-determined parameter chosen separately for each &lt;code&gt;[j,t]&lt;/code&gt; and &lt;code&gt;smallnum&lt;/code&gt; is chosen small enough that the solution will still be approximately optimal with respect to the original objective function, but large enough not to get rounded away to zero.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;IME, these options can sometimes produce a surprisingly large improvement in runtime.&lt;/p&gt;&#xA;" OwnerUserId="546" LastEditorUserId="546" LastEditDate="2019-12-06T22:12:40.140" LastActivityDate="2019-12-06T22:12:40.140" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3160" PostTypeId="1" AcceptedAnswerId="3165" CreationDate="2019-12-06T15:07:06.983" Score="9" ViewCount="789" Body="&lt;p&gt;In Constraint Programming it is possible to use &lt;em&gt;interval variables&lt;/em&gt; to represent intervals of time during which something happens &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.ide.help/OPL_Studio/opllangref/topics/opl_langref_scheduling_interval.html&quot; rel=&quot;noreferrer&quot;&gt;(see here)&lt;/a&gt;, usable in scheduling problems, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there something similar in MIP?&lt;/strong&gt; I am aware of some modeling approaches in MIP using binary variables to represent the order of jobs on a machine (i.e. &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; equal to 1 if job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is worked before job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;), but I was wondering whether other modeling approaches referring to intervals exist in MIP.&lt;/p&gt;&#xA;" OwnerUserId="459" LastActivityDate="2019-12-06T21:01:36.213" Title="Interval variables in MIP" Tags="|mixed-integer-programming|modeling|constraint-programming|binary-variable|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3161" PostTypeId="2" ParentId="3160" CreationDate="2019-12-06T16:26:06.437" Score="6" Body="&lt;p&gt;The &lt;a href=&quot;http://www.bernabe.dorronsoro.es/vrp/data/articles/VRPTW.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;vehicle routing problem with time windows&lt;/a&gt; is the first problem that comes to my mind, well researched, highly applicable. There are usually continuous variables that represent the visit (or start of service) time of a vehicle at a customer; that time must fall into a time window, which is an interval.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="123" LastEditDate="2019-12-06T21:01:36.213" LastActivityDate="2019-12-06T21:01:36.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3162" PostTypeId="2" ParentId="176" CreationDate="2019-12-06T16:31:45.090" Score="7" Body="&lt;p&gt;There were times when the IP and CP communities started to learn about the existence of the other, and initially, people tried to build a list of vocabulary to translate one concept into another. You can still find these attempts like in these &lt;a href=&quot;http://www.mi.fu-berlin.de/wiki/pub/ABI/CombinatorialOptimization/IP-CP.pdf&quot; rel=&quot;noreferrer&quot;&gt;lecture notes by Bockmayr/Reinert&lt;/a&gt;. Examples are &quot;node preprocessing&quot; (in IP) vs. &quot;domain propagation&quot; etc.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-12-06T16:31:45.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3163" PostTypeId="2" ParentId="176" CreationDate="2019-12-06T18:05:16.760" Score="2" Body="&lt;p&gt;In practice and without being exhaustive,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Linear Programming solves a linear combination of constraint with, but not only) a linear objective expression. As integer combinatorial problem, it use the simplex current optimal and dual deductions: That is the deduction are very strong but costly (cpu and memory) and heuristic decision are quite systematic. when working, it is a top quality techniques. When problems are strongly disjunctive (highly non linear) it may gives poor results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Constraint Programming use both arithmetical and logical algebra. That is handle highly disjunctive (non linear) constraints. Deductions are made by constraint propagation, a relatively quick method but not as strong as with simplex. It is compensate by more effort in decisions heuristics techniques. It is known to work very well for highly disjunctive problem as scheduling with a large time horizon.&lt;/p&gt;&#xA;" OwnerUserId="2797" LastEditorUserId="123" LastEditDate="2019-12-06T21:00:42.577" LastActivityDate="2019-12-06T21:00:42.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3164" PostTypeId="2" ParentId="3160" CreationDate="2019-12-06T19:56:04.860" Score="6" Body="&lt;p&gt;To complete @Marco Lübbecke said, There are many scheduling problems which use binary and continuous variables to represent the interval of time. For instance, machine scheduling problems use such a method to calculate the intervals. (start time or compilation time.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are interested to develop a MIP formulation, I recommended some references like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A) &lt;a href=&quot;https://www.springer.com/gp/book/9781489990433&quot; rel=&quot;noreferrer&quot;&gt;Scheduling (Theory, Algorithms, and Systems)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;B) &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/book/10.1002/9781118029114&quot; rel=&quot;noreferrer&quot;&gt;Scheduling in Supply Chains Using Mixed Integer Programming&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be noted that MIPs are usually NP-hard (They are difficult to solve), specifically in the real world situation even by using some commercial solvers like CPLEX or GUROBI, for large-scale models.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, some useful approaches such as constraint programming (CP) can be applied to solve large-scale problems in a reasonable and efficient way.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-12-06T19:56:04.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3165" PostTypeId="2" ParentId="3160" CreationDate="2019-12-06T20:20:00.110" Score="7" Body="&lt;p&gt;There is no single entity in MIP modeling that is a direct analog of an interval variable. The general MIP approach is as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;discretize the time domain (which is inherent in CP models using interval variables);&lt;/li&gt;&#xA;&lt;li&gt;in lieu of a single interval variable, create a binary variable for each possible starting time and add a constraint setting the sum of those variables equal to 1 (so that you start at exactly one time epoch) or less than equal to 1 (so that you start once or not at all -- the analog to an optional interval variable);&lt;/li&gt;&#xA;&lt;li&gt;use a constraint to define the ending time (a continuous variable) in terms of the processing time/interval width plus the starting time (an expression using those binary variables);&lt;/li&gt;&#xA;&lt;li&gt;handle non-overlap requirements using constraints (involving all those binary variables) that say one interval either starts after the other ends or ends before the other starts.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In modeling terms, it's a bigger PITA than expressing the same concepts in a CP model ... but it is doable.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-12-06T20:20:00.110" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3166" PostTypeId="1" AcceptedAnswerId="3167" CreationDate="2019-12-07T01:38:07.267" Score="12" ViewCount="2366" Body="&lt;p&gt;Once I learned from some post that the strict equality constraint in an optimization problem does not make much sense. We should always use &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; constraint. How much truth is in this?&lt;/p&gt;&#xA;&lt;p&gt;If I must have a strict equality constraint, should I use both &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; constraints to satisfy strict equality constraints?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="123" LastEditDate="2021-07-31T09:48:22.823" LastActivityDate="2021-07-31T09:48:22.823" Title="Does it make sense to use strict equality constraints in optimization?" Tags="|optimization|constraint|logical-constraints|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3167" PostTypeId="2" ParentId="3166" CreationDate="2019-12-07T02:25:30.313" Score="14" Body="&lt;p&gt;I suspect you read that actual floating point optimization solvers treat strict inequalities (&lt;span class=&quot;math-container&quot;&gt;$&amp;lt;$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;$&lt;/span&gt;) as non-strict inequalities (&lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt;). Solvers also give themselves a fudge factor, called feasibility tolerance, equal to the amount by which they may be violated in reality but treated as satisfying the constraint by the solver. If you must really have strict inequality and strict feasibility for a &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; constraint, &lt;span class=&quot;math-container&quot;&gt;$\textsf{LHS} &amp;lt; \textsf{RHS}$&lt;/span&gt;, then pick a number &quot;margin&quot;, such that &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\textsf{margin &amp;gt; feasibility tolerance}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and make your constraint &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sf LHS + margin \le RHS.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly for &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Equality constraints are treated by solvers as being satisfied if they are violated by no more than the feasibility tolerance. If you can not choose a feasibility tolerance which satisfies your desires across all constraint types to which it applies, then you can instead use two inequality constraints, with whatever tolerance for &quot;equality satisfaction&quot; you want. So, for the equality constraint &lt;span class=&quot;math-container&quot;&gt;$\sf LHS = RHS$&lt;/span&gt;, you could treat it as being &lt;span class=&quot;math-container&quot;&gt;$\sf |LHS - RHS| \le tolerance$&lt;/span&gt;, which is equivalent to &#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sf LHS - RHS \le tolerance,\quad\sf RHS - LHS \le tolerance$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep in mind, that solvers will treat &lt;span class=&quot;math-container&quot;&gt;$\sf LHS = RHS$&lt;/span&gt; as being &lt;span class=&quot;math-container&quot;&gt;$\sf |LHS - RHS|  \le \textsf{feasibility tolerance}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will never get (ensure) equality constraints satisfied strictly in floating point solvers.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2019-12-07T09:56:08.997" LastActivityDate="2019-12-07T09:56:08.997" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3168" PostTypeId="2" ParentId="3166" CreationDate="2019-12-07T03:07:48.400" Score="4" Body="&lt;p&gt;This also depends on what &quot;optimization&quot; is for you. When you think of linear programs, or linear objective functions optimized over convex sets, an optimum would always be attained at the boundary of the feasible region. With strict inequality constraints you would just exclude that boundary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There may be situations, however, in which you would like to &quot;measure&quot; whether you are strictly away from some value, in expressions as &quot;if &lt;span class=&quot;math-container&quot;&gt;$x&amp;gt;0$&lt;/span&gt; then something&quot; which can be typically written as linear constraints with inequalities that are not strict but involves integer/binary variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from all that, as @mark-l-stone said, &lt;span class=&quot;math-container&quot;&gt;$x&amp;gt;0$&lt;/span&gt; always means &lt;span class=&quot;math-container&quot;&gt;$x \geq \varepsilon$&lt;/span&gt; in practice.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-12-07T03:07:48.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3169" PostTypeId="2" ParentId="3156" CreationDate="2019-12-07T16:26:51.863" Score="3" Body="&lt;p&gt;CP Optimizer is doing a search for progressively better solutions. Each time it finds a feasible solution, it restricts the remainder of the search to solutions with better objective values than what it just found. So you should get a sequence of progressively better solutions. Given enough time and memory, it will exhaust the search space, and the last solution found will be provably optimal. Stopped early, the last solution found will not necessarily be optimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it sounds as though CPO is finding a good solution in the first 10 seconds and then struggling to find a better one. If the 15 hour run completed the search (i.e., was not stopped by time or memory limits), then that early solution is optimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Geoffrey Brent said, you might have significant symmetry in your model, in which case symmetry-breaking constraints would reduce the size of the search space (and hopefully let CPO terminate sooner). There are also ways you can change the search strategy CPO uses, but if the early solution is actually optimal, I'm not sure that messing with the search strategy will get proven optimality (exhaustion of the search space) any sooner.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-12-07T16:26:51.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3170" PostTypeId="1" AcceptedAnswerId="3182" CreationDate="2019-12-07T20:03:57.253" Score="10" ViewCount="517" Body="&lt;p&gt;I have to generate scenarios for a stochastic optimization program. I want to reduce this number of scenarios but the assignment of a probability to each scenario is my problem. How can I assign a probability to each scenario?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Background&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have historical data for a renewable energy profile such as wind and solar, and I want to formulate a market clearing operation problem using a two-stage stochastic program to minimize the operation cost in the day ahead. I want to have scenarios for each uncertain variable (wind, solar) using a neural network so I don't make fitting to a probability distribution. I then want to assign a probability for each scenario to sum over all scenarios and multiply by its probability to calculate the expected cost. Also I have some confusions about scenarios when I have a lot of uncertain variables like wind, solar and electric load.&lt;/p&gt;&#xA;" OwnerUserId="2802" LastEditorUserId="123" LastEditDate="2019-12-08T19:31:38.297" LastActivityDate="2019-12-12T09:07:57.397" Title="Scenario Generation and Reduction in Stochastic Optimization" Tags="|stochastic-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3171" PostTypeId="2" ParentId="1265" CreationDate="2019-12-08T13:13:31.947" Score="2" Body="&lt;p&gt;Stochastic Optimization (SO) requires the probability distributions (PDF) of the uncertain variables which are usually hard to fit. Then, a large number of scenarios are required to be sampled from these PDFs with their probabilities. This makes some computational complexities and intractability so, scenario reductions are needed but some information will be lost (trade-off). But generally, SO gives acceptable solutions with reduced costs (when you minimize the cost). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, Robust Optimization (RO) requires only upper/lower limits of the uncertain variables (simpler than PDFs) but it optimizes over the worst-case scenario which usually has low probability (with higher cost value). So RO gives more conservative solutions with lower computations but with higher costs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think using SO is preferred when you concern more about cost function value but RO is useful when reliability and security are more important than cost.&lt;/p&gt;&#xA;" OwnerUserId="2802" LastEditorUserId="36" LastEditDate="2019-12-08T16:18:08.937" LastActivityDate="2019-12-08T16:18:08.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3172" PostTypeId="2" ParentId="3166" CreationDate="2019-12-08T22:33:33.013" Score="6" Body="&lt;p&gt;Equality constraints are typically fine, and often very useful:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;branch and bound solvers use them for domain reduction (constraint propagation, FBBT , etc)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;linear/non linear equality constraints are also used by some solvers to eliminate redundant variables and constraints. Note that this is not possible if we only have inequality constraints.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;equality constraints are also used to produce cuts, both for MILPs, NLPs, and MINLPs.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any decent solver will reformulate the constraints to a format that is better suited to its own calculations, so equality constraints are usually best left as they are. For instance, many linear solvers will reformulate all inequalities to equalities and add slack variables, in order to create a square system that can be iterated over.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One important exception is solvers that use callbacks, such as IPOPT or KNITRO. If all the solver can see is the derivatives/function values, it can't reformulate because it doesn't have the actual equations. In that case there's no one answer, and it's best to experiment. For instance, I've seen problems with many small linear equality constraints where IPOPT with mumps took forever to do one iteration, and switching to HSL was 100 times faster. However, running problem reduction algorithms before sending the problem to IPOPT/mumps solved about 100,000 times faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to stress that although equality constraints can cause problems sometimes, the solution is never to use inequalities instead. It typically indicates a modelling problem, such as an overdefined linear system in the problem. The solution is to sanitize the linear system so that the degrees of freedom are equal to the number of equations, or to use a solver that will do these manipulations automatically.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-12-08T22:33:33.013" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3173" PostTypeId="2" ParentId="3144" CreationDate="2019-12-09T00:16:59.690" Score="9" Body="&lt;p&gt;The bounty convinced me to compete with Rolf's excellent answer, which is exactly how I would approach the problem myself. Next to CPLEX and Gurobi, it also worth noting that MATLAB and Octave provide the function &lt;em&gt;fmincon&lt;/em&gt;, which can also be used to solve your problem directly, and SPSS provides &lt;em&gt;Constrained Nonlinear Regression&lt;/em&gt; (which also allows for constrained linear regression). Because of all the available software, the method that I propose below is probably not practically useful.&lt;/p&gt;&#xA;&lt;p&gt;You have the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i=1}^n s_i &amp;amp;= 1\\&#xA;s_i &amp;amp;\ge 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Without these constraints, your problem would be an ordinary least squares regression problem, as pointed out by Rolf. Without the equality constraint, your problem would be a &lt;a href=&quot;https://en.wikipedia.org/wiki/Non-negative_least_squares&quot; rel=&quot;nofollow noreferrer&quot;&gt;non-negative least squares problem&lt;/a&gt; (NNLS). I will assume that you have access to statistics software that can solve NNLS, but is somehow unable to handle the equality constraint.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\lambda \in \mathbb{R}$&lt;/span&gt; be a parameter, with initial value &lt;span class=&quot;math-container&quot;&gt;$\lambda = 1$&lt;/span&gt;. Add the artificial time period &lt;span class=&quot;math-container&quot;&gt;$m+1$&lt;/span&gt; to every time series. At time &lt;span class=&quot;math-container&quot;&gt;$m+1$&lt;/span&gt;, give &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; the value &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;, and give each &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; the value 1. Due to this extra time period, we get the additional MSE term &lt;span class=&quot;math-container&quot;&gt;$$\frac{1}{m+1} (z_{m+1} - y_{m+1})^2 = \frac{1}{m+1} \left(\lambda - \sum_{i=1}^n s_i\right)^2.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This MSE term is an incentive for &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n s_i$&lt;/span&gt; to be close to &lt;span class=&quot;math-container&quot;&gt;$\lambda=1$&lt;/span&gt;. Otherwise, this MSE term would become large. Now use NNLS to solve the problem with the artificial time period. It is guaranteed that &lt;span class=&quot;math-container&quot;&gt;$s_i \ge 0$&lt;/span&gt;, and hopefully, &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n s_i$&lt;/span&gt; will be close to 1.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n s_i &amp;lt; 1$&lt;/span&gt;, then increase &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and try again. If &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n s_i &amp;gt; 1$&lt;/span&gt;, then decrease &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and try again. It can be shown that &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n s_i$&lt;/span&gt; is non-decreasing in &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;, so you can use the &lt;a href=&quot;https://en.wikipedia.org/wiki/Bisection_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;bisection search&lt;/a&gt; to find the value of &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; that nudges the sum to be exactly 1. You could even search for &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; by hand.&lt;/p&gt;&#xA;&lt;p&gt;When NNLS gives you an answer with &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n s_i = 1$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;, then it is guaranteed that you have found the optimal weights!&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Justification&lt;/h3&gt;&#xA;&lt;p&gt;The above method follows from using the &lt;a href=&quot;https://en.wikipedia.org/wiki/Augmented_Lagrangian_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;augmented Lagrangian method&lt;/a&gt; and solving the problem &lt;span class=&quot;math-container&quot;&gt;$$\max_{\mu \in \mathbb{R}} \min_{s_i \ge 0} \mathcal{L}(s,\mu) = \text{MSE} + \mu\left(1-\sum_{i=1}^n s_i\right) + \frac{\rho}{2}\left(1-\sum_{i=1}^n s_i\right)^2.$$&lt;/span&gt;&#xA;We choose &lt;span class=&quot;math-container&quot;&gt;$\lambda= \frac{\mu}{2}+1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\rho = 1$&lt;/span&gt;, as we may. After rewriting, the inner minimization is equivalent to the NNLS problem, and the outer maximization is the search for &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;. Guaranteed optimality follows from the optimality of the augmented Lagrangian method.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-12-09T07:51:03.597" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3174" PostTypeId="1" CreationDate="2019-12-09T06:03:20.643" Score="8" ViewCount="112" Body="&lt;p&gt;When solving best subset regression as a mixed integer program, how do you decide how tightly to bound the range of values of the &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; values?  When the box is tight, the solver finds a solution quickly, but potential solutions are ignored.  How quickly should I expand the box? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I built my constraints to estimate variance using the following approach:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than apply cuts on the covariance matrix directly, the cuts are applied on the principal components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to minimize the variance of the sum of a vector &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$1\times N$&lt;/span&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{Variance} = X \Sigma  X^\top= X(Q\Lambda Q^\top)X^\top.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$E_i:$&lt;/span&gt; Eigenvalue &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$1\times1$&lt;/span&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$V_i:$&lt;/span&gt; Eigenvector &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$N\times1$&lt;/span&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$= \sum_{i} E_i (XV_i)^2 = \sum_{i}\text{ComponentContribution}_i$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Near a reference vector &lt;span class=&quot;math-container&quot;&gt;$X_0$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{ComponentContribution}_i \ge E_i (X_0V_i)^2+ 2E_i (X_0V_i)(XV_i-X_0V_i).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that there are many potential &lt;span class=&quot;math-container&quot;&gt;$X_0$&lt;/span&gt; that have an equal value for &lt;span class=&quot;math-container&quot;&gt;$X_0V_i$&lt;/span&gt;. The above estimate for the component's contribution to variance does not depend on &lt;span class=&quot;math-container&quot;&gt;$X_0$&lt;/span&gt;. It only depends on &lt;span class=&quot;math-container&quot;&gt;$X_0V_i$&lt;/span&gt;. This allows the approximation to be useful near many different &lt;span class=&quot;math-container&quot;&gt;$X_0$&lt;/span&gt;. It is an approximation near a load value. Substituting:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}L_0 &amp;amp;= X_0V_i\quad(1\times1)\\\text{ComponentContribution}_i &amp;amp;\ge E_iL^2 + 2E_iL(XV_i - L)\\\text{ComponentContribution}_i &amp;amp;\ge E_i(2LXV_i - L^2).\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This allows each component's contribution to be estimated independently. One benefit is that more constraints (more &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; values) can be made for estimating the first component than for the smallest. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this leads to a second question, when evaluating the sources of error for an intermediate solution, how should I decide which components are contributing enough to error in the estimate to justify adding a constraint?  Which should be lumped together into a single constraint? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I posted a working test to &lt;a href=&quot;https://github.com/charlesfox97/VarianceConstraints&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="2388" LastEditorUserId="123" LastEditDate="2019-12-12T20:15:02.107" LastActivityDate="2019-12-12T20:15:02.107" Title="For subset selection regression as a mixed integer program, how tightly should the bounding box be set?" Tags="|mixed-integer-programming|quadratic-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3175" PostTypeId="2" ParentId="45" CreationDate="2019-12-09T08:17:52.477" Score="1" Body="&lt;p&gt;If you are interested to develop an optimization model (specifically MIP), based on your specific problem and also you would like to solve your problem using the commercial solvers to obtain the optimal solution, you could try writing your model in an algebraic modelling language like AMPL or GAMS and feeding that into the &lt;a href=&quot;https://neos-server.org/neos/&quot; rel=&quot;nofollow noreferrer&quot;&gt;NEOS server&lt;/a&gt; which contains many open-source and commercial solvers like CPLEX, GUROBI, CBC and ..., Then get the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK, the NEOS have had some useful APIs which can be connected to the other programming languages and optimization software.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-12-09T08:17:52.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3176" PostTypeId="1" CreationDate="2019-12-09T11:44:13.813" Score="11" ViewCount="216" Body="&lt;p&gt;We've been working on a new feature for Octeract Engine, namely to automatically extract SOS structure from a model and then exploit it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the literature is quite rich on what to do with SOS once we have them, I couldn't find any work on how to algorithmically detect the structure. So far we just home-brewed the detection algorithm and it works pretty well, but I was curious whether there's some theoretical work on the subject out there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware that such detection will have bad theoretical complexity, however this is not an issue for us, so if you are aware of a bad complexity algorithm do post an answer - the engine uses Octeract Reformulator technology so we can easily detect abstract mathematical structure even in very large problems with or without set notation.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2023-03-17T15:47:57.383" Title="Automatic detection of SOS variables and constraints" Tags="|mixed-integer-programming|integer-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3177" PostTypeId="1" CreationDate="2019-12-10T15:32:21.833" Score="8" ViewCount="116" Body="&lt;p&gt;I am trying to solve a problem statement with the help of jsprit.&lt;/p&gt;&#xA;&lt;p&gt;There is a depot.&#xA;Identical items need to be delivered or picked up. An item can have two states: Bad or good.&lt;/p&gt;&#xA;&lt;p&gt;Bad items need to be collected from different locations and they end up at the depot.&#xA;Good items can originate from the depot or different locations and they end up at various other locations.&lt;/p&gt;&#xA;&lt;p&gt;Items are identical, hence any good item can be dropped where a good item needs to be dropped. However, the items are big in size and the last item in has to be the first item out. So, if a good item has gone in, then the next task has to be to drop a good item. We cannot pick up a bad item after a good item, since all bad items go to the depot and good items are not dropped at the depot.&lt;/p&gt;&#xA;&lt;p&gt;How can I model this with jsprit or any other good VRP engine available in Java?&lt;/p&gt;&#xA;" OwnerUserId="2813" LastEditorUserId="491" LastEditDate="2022-01-04T16:26:30.320" LastActivityDate="2022-01-04T16:26:30.320" Title="Multiple shipments with FILO order" Tags="|vehicle-routing|graphs|java|split-delivery-routing|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3178" PostTypeId="2" ParentId="45" CreationDate="2019-12-10T21:01:25.687" Score="5" Body="&lt;p&gt;Just a (maybe obvious) remark: by doubling the number of nodes you can transform any ATSP instance into an STSP one, so you can use Concorde or any other STSP exact/heuristic code. &lt;/p&gt;&#xA;" OwnerUserId="429" LastActivityDate="2019-12-10T21:01:25.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3179" PostTypeId="1" AcceptedAnswerId="3180" CreationDate="2019-12-11T21:50:58.567" Score="11" ViewCount="357" Body="&lt;p&gt;The specific optimization problem I'm trying to solve is this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Find the minimum integer number of &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;em&gt;m&lt;/em&gt; pieces required to cover &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; distances of length &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; given that adjacent pieces must have an overlap of &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt;&lt;em&gt;mm&lt;/em&gt;. Pieces may be cut and distributed as desired, e.g. if one and a half pieces are required to cover one distance the remaining half piece can be used in covering the rest of the distances.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Somewhat more generalized, and a bit more interesting, I think the problem can be stated as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Find the minimum integer number of pieces of length &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; required to cover &lt;span class=&quot;math-container&quot;&gt;$N_D$&lt;/span&gt; distances of length &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; given that adjacent pieces must have an overlap of length &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. Pieces may be cut and distributed as desired.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Even more generalized:&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Find the minimum total length of pieces of lengths &lt;span class=&quot;math-container&quot;&gt;$\{L_1, \dots, L_m\}$&lt;/span&gt; required to cover the distances &lt;span class=&quot;math-container&quot;&gt;$\{D_1, \dots, D_m\}$&lt;/span&gt; given that adjacent pieces must have an overlap of length &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. Pieces may be cut and distributed as desired.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have unsuccessfully tried to map it onto one of these standard optimization problems: &lt;a href=&quot;https://en.wikipedia.org/wiki/Cutting_stock_problem&quot; rel=&quot;noreferrer&quot;&gt;Cutting stock problem&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Bin_packing_problem&quot; rel=&quot;noreferrer&quot;&gt;Bin packing problem&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Subset_sum_problem&quot; rel=&quot;noreferrer&quot;&gt;Subset sum problem&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm rather inexperienced in optimization theory, so I may be missing even something obvious though.&lt;/p&gt;&#xA;" OwnerUserId="2819" LastEditorUserId="123" LastEditDate="2019-12-12T20:09:37.253" LastActivityDate="2019-12-12T22:21:22.880" Title="Minimize number of pieces required to cover distances, with overlap" Tags="|optimization|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3180" PostTypeId="2" ParentId="3179" CreationDate="2019-12-12T00:39:26.233" Score="10" Body="&lt;p&gt;Although it does not map exactly to a &quot;classical&quot; 1-D cutting stock problem, you can approach your problem the way you would approach a 1-D cutting problem. Here is one possible formulation (assuming a single length &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; for items to be covered). The term &quot;piece&quot; here means a portion of material cut from a stock item. I assume it is okay for the covering pieces to extend a little beyond the end of the item being covered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem parameters&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L=$&lt;/span&gt; length of a unit of stock&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D=$&lt;/span&gt; length of each item to be covered&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$N_{D}=$&lt;/span&gt; number of items to be covered&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M=$&lt;/span&gt; required overlap of adjacent pieces covering one item&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Patterns&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}=$&lt;/span&gt; set of patterns&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}=$&lt;/span&gt; set of possible piece lengths&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\pi_{k,p}=$&lt;/span&gt; number of pieces of length &lt;span class=&quot;math-container&quot;&gt;$k\in\mathcal{K}$&lt;/span&gt; obtained&#xA;from one instance of pattern &lt;span class=&quot;math-container&quot;&gt;$p\in\mathcal{P}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All patterns &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; satisfy the requirement &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{k\in\mathcal{K}}k\cdot\pi_{k,p}\le L$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt; (all nonnegative integers):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{p}=$&lt;/span&gt; number of stock units cut using pattern &lt;span class=&quot;math-container&quot;&gt;$p\in\mathcal{P}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{k}=$&lt;/span&gt; number of pieces of length &lt;span class=&quot;math-container&quot;&gt;$k\in\mathcal{K}$&lt;/span&gt; produced&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{k,t}=$&lt;/span&gt; number of pieces of length &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; used to cover item &lt;span class=&quot;math-container&quot;&gt;$t\in\left\{ 1,\dots,N_{D}\right\} $&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Model&lt;/strong&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_{p\in\mathcal{P}}x_{p}\\\text{s.t.}&amp;amp;\quad y_{k}=\sum_{p\in\mathcal{P}}\pi_{k,p}x_{p}\quad\forall k\in\mathcal{K}\quad(\text{production of smaller pieces})&#xA;\\&amp;amp;\quad\sum_{t=1}^{N_{D}}z_{k,t}\le y_{k}\quad\forall k\in\mathcal{K}\quad(\text{consumption of smaller pieces})\\&amp;amp;\quad\sum_{k\in\mathcal{K}}k\cdot z_{k,t}\ge D+M\left(\sum_{k\in\mathcal{K}}z_{k,t}-1\right)\quad\forall t \in \{1,\dots,N_D\}\quad(\text{coverage and overlap requirements})\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can enumerate all possible patterns, solving this model should provide an optimal solution. If enumerating all patterns is not feasible, you can try branch-price-and-cut, or use a heuristic similar to the Gilmore-Gomory heuristic for the &quot;standard&quot; 1-D problem. For a GG-like heuristic, you start with a set of patterns sufficient to get the job done, relax the integrality constraints, solve the LP relaxation and use dual values to tell you what additional pieces of each size might be worth. Then solve a separate pattern-generating problem (basically a knapsack problem) to look for a new pattern. Add it to the LP relaxation, iterate until you do not find a new pattern, then restore the integrality restrictions and optimize.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For performance reasons, you might want to add symmetry-breaking constraints. (Given any feasible solution, permuting the indices &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; for the items being covered produces a different solution with an identical consumption of stock.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2019-12-12T22:21:22.880" LastActivityDate="2019-12-12T22:21:22.880" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3181" PostTypeId="1" CreationDate="2019-12-12T05:37:40.370" Score="7" ViewCount="81" Body="&lt;p&gt;Assuming that I should buy 50 items from 25 different vendors with pre-known delivery duration between 2-7 day for each, which day of a week should I place each order so that the delivery days be even and balanced and even as much as possible? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to model the simple problem below?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a simple example is like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Items Vendors Delivery     order day of week &#xA;1      v1       2 days       ?&#xA;2      v2       3 days       ?&#xA;3      v3       4 days       ?&#xA;4      v4       7 days       ?&#xA;.      .        .            . &#xA;.      .        .            . &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="838" LastEditorUserId="123" LastEditDate="2019-12-12T20:07:55.670" LastActivityDate="2019-12-12T20:07:55.670" Title="Modelling a simple ordering problem to have balanced delivery days" Tags="|mixed-integer-programming|linear-programming|modeling|inventory|" AnswerCount="0" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="3182" PostTypeId="2" ParentId="3170" CreationDate="2019-12-12T08:27:38.250" Score="10" Body="&lt;ul&gt;&#xA;&lt;li&gt;If you have historical data, you might use them as scenario inputs to a scenario reduction algorithm. Some references are available from &lt;a href=&quot;https://link.springer.com/article/10.1023/A:1021805924152&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://ieeexplore.ieee.org/document/1304379/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Fitting a probability distribution does not prevent you from using a scenario approach to modeling uncertainty. In fact, the scenario approach is a popular and viable approach for handling uncertainty modeling as the numerical integration of the recourse function leads to complex and difficult problems (see section 3.1.c of &lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4614-0237-4&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;). If you decide to generate random scenarios from the fitted probability distributions, some useful references are available from &lt;a href=&quot;https://epubs.siam.org/doi/10.1137/S1052623499363220?mobileUi=0&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221704002292&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Regarding the presence of multiple uncertain parameters, the uncertainty modeling is done separately for each uncertain parameter as long as they are independent. If not, you have to know joint probability distribution functions for the uncertain parameters and sample from them. For examples of such sampling, see &lt;a href=&quot;http://www.kybernetika.cz/content/2014/6/1049&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://link.springer.com/article/10.1007%2Fs10287-013-0184-4&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;I'm not sure why you are using a neural network to build scenarios. If what you are doing is correct and the number of scenarios is large enough, then you might assume equal probability for all of the scenarios.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Besides the above references, the book chapter available from &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-0-387-87817-1_4&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and the presentation available from &lt;a href=&quot;http://work.michalkaut.net/papers_etc/scen-gen-intro.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; are good introductions to the topic.&lt;/p&gt;&#xA;" OwnerUserId="119" LastEditorUserId="119" LastEditDate="2019-12-12T09:07:57.397" LastActivityDate="2019-12-12T09:07:57.397" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3183" PostTypeId="1" CreationDate="2019-12-12T09:11:46.760" Score="14" ViewCount="296" Body="&lt;p&gt;I have a bilevel max-min optimization problem over binary variables, with constraints expressed using linear inequalities. The inner (minimization) problem is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{alignat}2&#xA;\min\limits_x&amp;amp;\quad c^\top x\\&#xA;\text{s.t. }&amp;amp;\quad Ax\geq b\\&#xA;&amp;amp;\quad x_i \in \{0,1\},&#xA;\end{alignat}&#xA;$$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; depending linearly on the variables over which maximization happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To obtain a single maximization problem, I want to consider the dual of the inner problem. I am unable to verify if the inner program is total dual integral (all I know is that the matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; &lt;strong&gt;is not&lt;/strong&gt; totally unimodular). So I start by considering the relaxation of the inner problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;\min\limits_x&amp;amp;\quad c^\top x\\&#xA;\text{s.t.}&amp;amp;\quad Ax \geq b\\&#xA;&amp;amp;\quad x_i \in [0,1],&#xA;\end{align*}&#xA;$$&lt;/span&gt;&#xA;which can be rewritten as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;\min\limits_x&amp;amp;\quad c^\top x\\&#xA;\text{s.t.}&amp;amp;\quad A'x \geq b'\\&#xA;&amp;amp;\quad x_i \geq 0,&#xA;\end{align*}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A'$&lt;/span&gt; is obtained by appending rows of negated identity matrix to &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;,&#xA;and &lt;span class=&quot;math-container&quot;&gt;$b'$&lt;/span&gt; by extending &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; with a vector of &lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt;'s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I take the dual of the relaxed problem, which is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;\max\limits_{\lambda}&amp;amp;\quad b'^\top \lambda\\&#xA;\text{s.t.}&amp;amp;\quad A'^\top\lambda \leq c\\&#xA;&amp;amp;\quad \lambda \geq 0.&#xA;\end{align*}&#xA;$$&lt;/span&gt;&#xA;Finally, I activate the maximization variables, say &lt;span class=&quot;math-container&quot;&gt;$\mathbf{z}$&lt;/span&gt;, and obtain the program&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;\max\limits_{\mathbf{z}, \lambda}&amp;amp;\quad b'^\top \lambda\\&#xA;\text{s.t.}&amp;amp;\quad A'^\top\lambda \leq c(\mathbf{z})\\&#xA;&amp;amp;\quad B z \leq d\\&#xA;&amp;amp;\quad \lambda \geq 0, z_i \in \{0,1\}.&#xA;\end{align*}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Switching to relaxed program introduces integrality gap. How can I check the extent of/minimize its impact on the solution of the final problem?&lt;/p&gt;&#xA;" OwnerUserId="2820" LastEditorUserId="2820" LastEditDate="2019-12-16T07:24:17.483" LastActivityDate="2022-01-27T19:41:12.827" Title="Integrality gap in bilevel binary linear programming problem" Tags="|integer-programming|binary-variable|duality|bilevel-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3184" PostTypeId="1" CreationDate="2019-12-12T21:04:46.790" Score="6" ViewCount="323" Body="&lt;p&gt;Compared with the Variable Elimination algorithm, when does the Junction Tree algorithm work better? For what kind of graph structures? Size of the problem? Sparsity of the network?&lt;/p&gt;&#xA;" OwnerUserId="2823" LastEditorUserId="123" LastEditDate="2019-12-24T17:05:37.687" LastActivityDate="2019-12-24T17:05:37.687" Title="When does the Junction Tree Algorithm work better than Variable Elimination?" Tags="|algorithms|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3186" PostTypeId="1" CreationDate="2019-12-13T21:43:31.067" Score="13" ViewCount="821" Body="&lt;p&gt;For an LP problem where &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n$&lt;/span&gt; are free variables (which may take positive or negative values), I want to bound the sums of &lt;span class=&quot;math-container&quot;&gt;$a_i\cdot x_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_i&amp;gt;0$&lt;/span&gt;, and where &lt;span class=&quot;math-container&quot;&gt;$x_i&amp;lt;0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect this requires MIP with a sign variable for each &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers or suggestions would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2564" LastEditorUserId="123" LastEditDate="2019-12-13T22:04:53.110" LastActivityDate="2019-12-14T09:30:27.763" Title="LP how to sum up positive free variables and negative free variables separately?" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3187" PostTypeId="2" ParentId="3186" CreationDate="2019-12-13T22:09:27.830" Score="14" Body="&lt;p&gt;This can be done using the standard trick of splitting each free variable into the difference of two nonnegative variables:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{i}=u_{i}-v_{i}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$u \geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v \geq 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your constraint is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{n} a_{i} \max(x_{i},0) \leq b$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$a \geq 0$&lt;/span&gt;, then this can be written as &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{n} a_{i} u_{i} \leq b.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the constraint&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{n} a_{i} \min(x_{i},0) \geq -b$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$a \geq 0$&lt;/span&gt;, use &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{n} a_{i} v_{i} \leq b.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it's easy to formulate related constraints that can't be formulated using LP.  For example, a constraint like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i} a_{i} \max(x_{i},0) \geq b$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$a_{i} \geq 0$&lt;/span&gt; is nonconvex and thus can't possibly be represented with LP.  In that case, you might formulate the problem using 0-1 integer variables to encode whether variables are positive or negative.  &lt;/p&gt;&#xA;" OwnerUserId="103" LastEditorUserId="123" LastEditDate="2019-12-14T09:30:27.763" LastActivityDate="2019-12-14T09:30:27.763" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3188" PostTypeId="1" AcceptedAnswerId="3191" CreationDate="2019-12-14T18:08:01.857" Score="26" ViewCount="1731" Body="&lt;p&gt;After a bit of reading I think I've been able to conclude that state-of-the-art VRP can get solutions for 100~500 stops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is around how this actually affects logistics (like Amazon for instance).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do they actually practically use these algorithms to drive efficiencies?&#xA;How? Is the current state-of-the art good enough, as in it's not a big deal for logistics companies? Or is it something they are actively looking to improve?&lt;/p&gt;&#xA;" OwnerUserId="2828" LastEditorUserId="8" LastEditDate="2020-09-04T09:43:18.540" LastActivityDate="2020-09-09T09:26:07.210" Title="What's the current status of the Vehicle Routing Problem in the logistics industry?" Tags="|combinatorial-optimization|vehicle-routing|traveling-salesman|industry|logistics|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3189" PostTypeId="1" AcceptedAnswerId="3190" CreationDate="2019-12-14T18:08:07.573" Score="7" ViewCount="781" Body="&lt;p&gt;Why are shadow prices associated with nonnegativity constraints also called as reduced costs, even if they have the same interpretation as shadow prices associated with an optimal solution? Why the use of the term &quot;reduced cost&quot;?&lt;/p&gt;&#xA;" OwnerUserId="2474" LastActivityDate="2019-12-15T09:00:58.530" Title="shadow prices associated with nonnegativity constraints" Tags="|linear-programming|constraint|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3190" PostTypeId="2" ParentId="3189" CreationDate="2019-12-14T18:28:07.463" Score="8" Body="&lt;p&gt;In the simplex method, the term &quot;reduced cost&quot; is used for the marginal cost to introduce a nonbasic variable into the basis. At each iteration, reduced costs are calculated and in a minimization (maximization) problem the variable with the most negative (positive) reduced cost enters the basis via a pivot operation. One can show that the shadow price of a nonnegativity constraint is equal to the reduced cost of that variable in the final (optimal) basic feasible solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &quot;reduced cost&quot; is not an alternate term for shadow price; it's a term related to the simplex method for solving the primal problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="36" LastEditDate="2019-12-14T22:36:12.983" LastActivityDate="2019-12-14T22:36:12.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3191" PostTypeId="2" ParentId="3188" CreationDate="2019-12-14T20:18:03.553" Score="13" Body="&lt;p&gt;The answer to this question is quite complicated. There are two main types of vehicle routing problems, the offline and the online problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solving the offline problem takes longer and is used to make planning-level decisions. The online problem is solved as real-time information comes in, and tells us what to do at the low level (as in which vehicle should go where right now).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What we need to establish is that these problems must always give us some answer, especially the online problem, because having idle vehicles means losing money.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Companies like Uber or Amazon have very sophisticated ways of achieving this, which involves a convoluted combination of methods. Amazon would solve both the online and offline problems, for thousands of destinations. The offline solutions help reduce the solution space for the online problem. Uber is more dependent on the online problem, but these problems are much easier because there are only so many cars within a 5-10 min drive at any given time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What makes this problem complicated is that the way this problem is solved, even by the same company, changes depending on the city, time of day, and time of year. The differentiator is usually the quality/reliability of traffic data. In Europe or North America (but usually only in large urban areas) we have pretty good data to help us run data-driven optimisation with pretty good predictive power. In Africa or Asia, traffic tends to be more unpredictable and the data available is usually not as good, which means we need to depend much more on heuristic methods, machine learning, offline optimisation, and to be upfront with customers about possible delays in delivery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Companies are indeed looking for ways to improve this, however the quality of data tends to be much more of a bottleneck than actual optimisation is. When we do have good data, more powerful optimisation software/methods do make a huge difference and tech companies are aware of this.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-12-14T20:18:03.553" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3193" PostTypeId="2" ParentId="3189" CreationDate="2019-12-15T07:31:04.850" Score="1" Body="&lt;p&gt;As @prubin mentioned, the &quot;reduced cost&quot; is not an alternative term for shadow price. Many of optimization software like AMPL, GAMS and others, have an automatic facility to calculate and show these terms. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, in the &lt;a href=&quot;https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_trnsport.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;classical transportation problem (using GAMS)&lt;/a&gt;, you could try the following to show what you want easily, where the (.m) in the last line is the marginal syntax to show dual of constraints and the reduced cost of variables.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Model transport / all /;&#xA;solve transport using lp minimizing z;&#xA;display x.l, x.m, supply.m, demand.m;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The results are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---- EQU supply  observe supply limit at plant i&#xA;&#xA;             LOWER     LEVEL     UPPER    MARGINAL&#xA;&#xA;seattle       -INF    350.000   350.000      EPS       &#xA;san-diego     -INF    550.000   600.000      .         &#xA;&#xA;---- EQU demand  satisfy demand at market j&#xA;&#xA;            LOWER     LEVEL     UPPER    MARGINAL&#xA;&#xA;new-york   325.000   325.000     +INF      0.225      &#xA;chicago    300.000   300.000     +INF      0.153      &#xA;topeka     275.000   275.000     +INF      0.126      &#xA;&#xA;---- VAR x  shipment quantities in cases&#xA;&#xA;                      LOWER     LEVEL     UPPER    MARGINAL&#xA;&#xA;seattle  .new-york      .       50.000     +INF       .         &#xA;seattle  .chicago       .      300.000     +INF       .         &#xA;seattle  .topeka        .         .        +INF      0.036      &#xA;san-diego.new-york      .      275.000     +INF       .         &#xA;san-diego.chicago       .         .        +INF      0.009      &#xA;san-diego.topeka        .      275.000     +INF       .         &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope, it would be useful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2019-12-15T09:00:58.530" LastActivityDate="2019-12-15T09:00:58.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3194" PostTypeId="1" AcceptedAnswerId="3196" CreationDate="2019-12-15T10:09:47.207" Score="10" ViewCount="320" Body="&lt;p&gt;In the context of a larger optimization problem I realized that I am missing the skill to implement/exploit the following observation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the problem I was faced with two related sets of indicator variables which contributed to the objective function through two separate terms. I obtained very weak root relaxation bounds (only considered one part of the objective function) and correspondingly long solution times (Gurobi). While this slow approach eventually worked out I kept wondering how to do it better the next time:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I manually relaxed the set of binary variables related to the part that was properly captured and retained the formulation the problem very quickly solved yielding a very strong LB - but of course just including the LB value does not help. So here comes the question: How to &quot;suggest&quot; such a partial relaxation scheme to the solver? Is there a modeling technique that achieves this or am I missing a feature/parameter? I first thought about lazy handling of integrality but could not figure out how to do this.&lt;/p&gt;&#xA;" OwnerUserId="33" LastEditorUserId="36" LastEditDate="2019-12-15T15:24:25.580" LastActivityDate="2019-12-15T16:12:10.257" Title="Partial Relaxation" Tags="|mixed-integer-programming|modeling|solver|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3195" PostTypeId="1" AcceptedAnswerId="3197" CreationDate="2019-12-15T15:05:19.440" Score="8" ViewCount="343" Body="&lt;p&gt;I'm solving an MIP: &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\mathrm{arg\,min}&amp;amp;\quad\sum\limits_{i}{x_i}\\\text{s.t.}&amp;amp;\quad A\,x\geq1,\end{align}&lt;/span&gt; where both the matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are boolean valued, and &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is symmetric (adjacency matrix).&#xA;I am then solving this problem repeatedly for different values of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, but with the same dimension. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question: How can I make this process faster? I solve the same MIP around 6 times on average, with different values of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; (generated using solution &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; from previous iteration and a threshold value).&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a way to cache the results? I'm not sure what I could cache apart from storing the calculated values in a dictionary &lt;span class=&quot;math-container&quot;&gt;$A: x$&lt;/span&gt; mapping, but there are &lt;span class=&quot;math-container&quot;&gt;$2^{(\dim{A})^2}$&lt;/span&gt; variants for the dictionary key, so I don't think it's useful. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can we parallelise the computation somehow? I am currently using &lt;a href=&quot;https://www.cvxpy.org/index.html&quot; rel=&quot;noreferrer&quot;&gt;CVXPY&lt;/a&gt; open source Python library, which doesn't support parallel computation, and I don't know how to split the problem into smaller chunks. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2832" LastEditorUserId="2832" LastEditDate="2019-12-15T16:19:32.743" LastActivityDate="2019-12-15T21:09:07.300" Title="Speedup or Caching for a Multi-Iteration MIP problem" Tags="|optimization|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3196" PostTypeId="2" ParentId="3194" CreationDate="2019-12-15T16:12:10.257" Score="6" Body="&lt;p&gt;I think this is very close to the idea proposed by &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221712002731&quot; rel=&quot;noreferrer&quot;&gt;Yang et al.&lt;/a&gt; for the single source capacitated facility location problem (SS-CFLP). They relax the allocation/assignment variables to be continuous which leads to a CFLP as a relaxation of the SS-CFLP. This is what they call a &lt;em&gt;partial relaxation&lt;/em&gt; as the location variables are still kept as binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They then embed this relaxation into the so called &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0004370206000233&quot; rel=&quot;noreferrer&quot;&gt;cut and solve&lt;/a&gt; framework (Climer and Zhang, 2006) which alternates between solving a relaxation with some additional &quot;piercing cuts&quot; called &lt;em&gt;the dense problem&lt;/em&gt; generating a lower bound, and a &lt;em&gt;sparse problem&lt;/em&gt; with many variables fixed from which upper bounds are generated. &lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2019-12-15T16:12:10.257" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3197" PostTypeId="2" ParentId="3195" CreationDate="2019-12-15T21:09:07.300" Score="6" Body="&lt;p&gt;If you can switch the solver to either CPLEX or Gurobi, you can have parallel threads during the MIP solutions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not familiar with Gurobi, but with CPLEX, you could try passing a previous solution in as a hot start, and let CPLEX try to repair it. Depending on how you do your updates to A, you might use the previous solution, or you might stockpile solutions and choose the one that satisfies the most constraints (breaking ties via the objective function). Whether that would be faster than just turning CPLEX loose without a hot start is an empirical question.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-12-15T21:09:07.300" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3198" PostTypeId="1" AcceptedAnswerId="3199" CreationDate="2019-12-16T05:09:59.740" Score="14" ViewCount="788" Body="&lt;p&gt;I'm starting to read about column generation-based approaches to vehicle routing problems (VRP). Let's say that I want to solve very large instances of an intricate VRP, I'm not looking to always solve my problem to optimality, but I still want to estimate valid optimality gaps for my solutions. Please, allow me to ask you two questions in this regard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say that I implement a column generation-based approach where the pricing subproblem is always solved heuristically (because we are dealing with a very large and intricate problem); however, the pricing method still finds columns that are added to the master problem at each iteration. My first question is, can I still calculate valid lower bounds (for a minimization problem) if I opt for using such a heuristic pricing method? If so, how can I do it? correct me if I'm wrong, but as far as I know, when the subproblem is not solved to optimality, like in this case, we don't longer obtain a valid lower bound by solving the linear relaxation of the master problem. So, I wonder if it is possible at least to estimate a lower bound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that the method I just described is a hybrid exact-heuristic approach based on column generation, still I don't know if it can provide lower bounds for the solutions. So, my second question is, are you aware of alternative hybrid exact-heuristic approaches that can solve a given problem heuristically, while providing optimality gaps of the solutions? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much, I would highly appreciate if you can provide me with some references to guide my research. Kind regards.&lt;/p&gt;&#xA;" OwnerUserId="2834" LastEditorUserId="36" LastEditDate="2019-12-16T05:33:37.837" LastActivityDate="2019-12-16T15:06:02.417" Title="Obtaining optimality gaps when using hybrid exact-heuristic approaches to vehicle routing problems" Tags="|mixed-integer-programming|reference-request|vehicle-routing|heuristics|column-generation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3199" PostTypeId="2" ParentId="3198" CreationDate="2019-12-16T08:35:11.177" Score="11" Body="&lt;p&gt;You are right. If you solve the pricing heuristically, you do not have a valid lower bound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One approach to obtain a lower bound would be to solve a relaxation of the pricing problem exactly. Usually, the faster a relaxation can be solved, the worse in the resulting bound. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another (but still similar) approach is to calculate a lower bound on the pricing solution value. The Lagrangian lower bound then can be calculated. You can check the &quot;Lagrangian duality&quot; chapter 10 of the Laurence Wolsey &quot;Integer Programming&quot; book: &lt;a href=&quot;https://www.wiley.com/en-us/Integer+Programming-p-9780471283669&quot; rel=&quot;noreferrer&quot;&gt;https://www.wiley.com/en-us/Integer+Programming-p-9780471283669&lt;/a&gt;, or some other textbook on Lagrangian duality in Integer Programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not needed to calculate the lower bound in every iteration of column generation. The best would be to converge using a heuristic pricing and calculate the lower bound in the last column generation iteration, or in several last iterations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To calculate the gap, you need also upper bounds. For large instances, I recommend to use more conventional VRP heuristics, like local search, genetic algorithm, etc. &lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2019-12-16T08:35:11.177" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3200" PostTypeId="1" CreationDate="2019-12-16T10:25:52.373" Score="17" ViewCount="3324" Body="&lt;p&gt;I often read in papers when branch-and-X algorithms are used to solve mixed integer programming problems, that the lower bound (in the minimization case) obtained from solving a linear programming relaxation at each branching node, is called a &lt;em&gt;dual bound&lt;/em&gt;. Consequently, the gap between the best (smallest) linear programming lower bound of an active branching node and the best known integer feasible solution, is then called the &lt;em&gt;duality gap&lt;/em&gt;. But can we consider the bound from the LPs a dual bound and the gap a duality gap? I would at least consider the gap to be an &lt;em&gt;optimality gap&lt;/em&gt; and maybe say that the bound is a &lt;em&gt;linear programming bound&lt;/em&gt; as there is no duality going on. Or am I wrong?&lt;/p&gt;&#xA;" OwnerUserId="609" LastActivityDate="2019-12-17T10:06:22.970" Title="Dual bounds of integer programming problems" Tags="|mixed-integer-programming|duality|terminology|branch-and-bound|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3201" PostTypeId="2" ParentId="3198" CreationDate="2019-12-16T15:06:02.417" Score="8" Body="&lt;p&gt;Even if you solve the pricing heuristically, you can still obtain a valid lower bound in certain cases. However, it depends on your pricing heuristic whether this is possible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have found the optimal solution to the linear relaxation of the master problem if there are no more columns with negative reduced costs. Suppose you have a heuristic that always &lt;strong&gt;underestimates&lt;/strong&gt; the reduced cost of a column and according to this heuristic all columns have positive reduced costs. Then, the current solution is optimal and hence a valid lower bound. If instead, your heuristic always &lt;strong&gt;overestimates&lt;/strong&gt; the reduced cost of a column, it is possible to miss negative reduced cost columns so the solution is not a valid lower bound, even when the heuristic cannot find new columns to be added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case you have a heuristic that overestimates reduced costs, people will often first try to find negative reduced costs columns using the heuristic. Once the heuristic fails to find new columns, they switch to an exact pricing method to still find the correct lower bound. I can recommend the book &lt;a href=&quot;https://www.springer.com/gp/book/9780387254852&quot; rel=&quot;noreferrer&quot;&gt;Column Generation&lt;/a&gt;. You may also consider &lt;a href=&quot;https://or.stackexchange.com/questions/1281/solving-pricing-problem-heuristically-in-column-generation-algorithm-for-vrp&quot;&gt;this question on OR.SE&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2019-12-16T15:06:02.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3202" PostTypeId="2" ParentId="3200" CreationDate="2019-12-16T22:06:17.360" Score="27" Body="&lt;p&gt;The notions of &lt;em&gt;dual bound&lt;/em&gt; and &lt;em&gt;primal bound&lt;/em&gt; originate a bit more generally, I think. We typically call an (iterative optimization) algorithm &lt;em&gt;primal&lt;/em&gt; when it maintains a feasible solution in every iteration. The Ford-Fulkerson algorithm for solving maximum flow is an example where we have a feasible flow in every iteration, or the simplex method, where we have a feasible LP solution all the time. A complementary concept is a &lt;em&gt;dual&lt;/em&gt; algorithm that maintains a certificate of optimality in each iteration; the dual simplex algorithm is an example: we have an optimal solution after each pivot, but the solution does not necessarily satisfy the constraints; in fact, it becomes feasible (if there is a feasible solution) only in the very last iteration. For LPs and other problems you may know that (primal) optimality is the same as dual feasibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In brief: &lt;em&gt;primal&lt;/em&gt; refers to feasibility, &lt;em&gt;dual&lt;/em&gt; refers to optimality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, returning to your question: the &lt;em&gt;primal bound&lt;/em&gt; always refers to the value of a solution that satisfies all the constraints, in particular the integrality constraints. According to the above, a &lt;em&gt;dual bound&lt;/em&gt; refers to the value of the current &quot;optimality proof.&quot; This is one, out of several, viewpoints, I guess. So, finally, I agree that you can call the dual bound an LP bound when it comes from solving an LP relaxation. And even when I use &lt;em&gt;dual bound&lt;/em&gt; I would not speak of duality gap, but of optimality gap as you do. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope someone has more substance to add to this.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-12-16T22:06:17.360" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3203" PostTypeId="1" CreationDate="2019-12-16T23:15:00.353" Score="9" ViewCount="928" Body="&lt;p&gt;I have a MILP problem with one of the constraints is given below. Sometimes, even for a small-sized problem, the solver takes a very long time to find a solution. What could be an efficient transformation into an LP or heuristic solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;\text{maximize}  &amp;amp; v \\&#xA;\text{subject to}&amp;amp; \forall m=1,\ldots,M: \sum_{n=1}^N z_{nm} \leq P \\&#xA;&amp;amp;\forall n=1,\ldots,N: s_n = \sum_{m=1}^M z_{nm}q_n \\&#xA;&amp;amp;\forall n=1,\ldots,N: v \leq \frac{1}{d_n}s_n\\&#xA;&amp;amp;\forall  m=1,\ldots,M \,\forall (n_1, n_2)\in A \text{ where } A_{n_1 n_2}=1: z_{n_1m} + z_{n_2m} \leq 1\\&#xA;&amp;amp;\forall m=1,\ldots,M \,\forall n=1,\ldots,N: z_{nm} \in \{0,1\}&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;For example, &lt;span class=&quot;math-container&quot;&gt;$M=200$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N=50$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2019-12-17T15:33:03.893" LastActivityDate="2020-01-17T22:54:40.530" Title="How can I transform this MILP into an LP problem?" Tags="|optimization|mixed-integer-programming|nonlinear-programming|linearization|binary-variable|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3204" PostTypeId="2" ParentId="3203" CreationDate="2019-12-16T23:53:22.483" Score="8" Body="&lt;p&gt;These &lt;em&gt;conflict&lt;/em&gt; constraints can be replaced with &lt;em&gt;clique&lt;/em&gt; constraints of the form &lt;span class=&quot;math-container&quot;&gt;$$\sum_{n\in C} z_{n,m}\le 1 \quad \text{for all $m$},$$&lt;/span&gt; where each &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is a clique in the graph with nodes &lt;span class=&quot;math-container&quot;&gt;$1,\dots,N$&lt;/span&gt; and edges determined by &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-12-16T23:53:22.483" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3205" PostTypeId="2" ParentId="3200" CreationDate="2019-12-17T10:06:22.970" Score="-3" Body="&lt;p&gt;As you said branch-and-X algorithm, AFAIK, the main method of solving MIPs is the branch-and-cut method, since it is used in all modern MIP solvers. The branch-and-cut method is a combination of the branch-and-bound and cutting-plane algorithms. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be noted that the dual simplex method is the main LP method to solve MIPs which, it repeats the work of the primal simplex method applied to the dual LP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic structure of the branch-and-bound method is the search tree. Each of the MIPs in the child nodes is obtained from the parent MIP by adding one or more new constraints that are usually upper or lower bounds for integer variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @Marco Lübbecke said, In the LP-based branch-and-bound method, the upper bound at any node is the optimal objective value of the relaxation LP at this node. The lower bound is the largest value of the objective function attained on the already found feasible solutions of the original MIP and then, The B&amp;amp;B gap is the difference between these terms.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-12-17T10:06:22.970" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3206" PostTypeId="2" ParentId="3188" CreationDate="2019-12-17T15:19:11.167" Score="5" Body="&lt;p&gt;Talking about real use in logistics, I suggest reading about the &lt;a href=&quot;https://www.pressroom.ups.com/pressroom/ContentDetailsViewer.page?ConceptType=Factsheets&amp;amp;id=1426321616277-282&quot; rel=&quot;noreferrer&quot;&gt;UPS ORION&lt;/a&gt; project. Not many details, but it provides an example of a real system dealing with this kind of problem.&lt;/p&gt;&#xA;" OwnerUserId="459" LastActivityDate="2019-12-17T15:19:11.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3207" PostTypeId="2" ParentId="3203" CreationDate="2019-12-17T18:44:53.013" Score="7" Body="&lt;p&gt;To transform an MILP into LP, you need to use an exponential number of variables:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check the book: &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0975914626&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Optimization over Integers&lt;/em&gt;, by Bertsimas and Weismantel&lt;/a&gt;. Chapter 4  contains different ways to convert binary linear programming (BLP) into linear programming (LP).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first step: &lt;span class=&quot;math-container&quot;&gt;$$s_n=\sum_{m=1}^{M} z_{n,m}q_{n}=q_{n}\sum_{m=1}^{M} z_{n,m}$$&lt;/span&gt; bacause the summation is not over the index &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. Thus, its constraint is &lt;span class=&quot;math-container&quot;&gt;$$v\leq \frac{s_n}{d_n}\implies v\leq \frac{q_n}{d_n}\sum_{m=1}^{M} z_{n,m}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second step: the problem can be converted into a binary program. I will remove its variable &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; by fixing the order on &lt;span class=&quot;math-container&quot;&gt;$\dfrac{q_n}{d_n}\sum\limits_{m=1}^{M} z_{n,m} , \quad \forall n\in 1,\dots,N$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{q_n}{d_n}\sum_{m=1}^{M} z_{n,m} - \frac{q_{n-1}}{d_{n-1}}\sum_{m=1}^{M} z_{n-1,m} \geq 0 , \quad \forall n\in 2,\dots,N$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, &lt;span class=&quot;math-container&quot;&gt;$v=\dfrac{q_1}{d_1}\sum\limits_{m=1}^{M} z_{1,m}$&lt;/span&gt;. The equivalent binary programming problem is&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{ll}&#xA;\max &amp;amp; \frac{q_1}{d_1}\sum_{m=1}^{M} z_{1,m} \\&#xA;\text{s.t.} &amp;amp; \sum\limits_{n=1}^{N} z_{n,m} \leq P, \quad \forall m\in 1,\dots,M\\&#xA;&amp;amp; \dfrac{q_n}{d_n}\sum\limits_{m=1}^{M} z_{n,m} - \frac{q_{n-1}}{d_{n-1}}\sum\limits_{m=1}^{M} z_{n-1,m} \geq 0 , \quad \forall n\in 2,\dots,N\\&#xA;&amp;amp; z_{n_1, m}+z_{n_2, m} \leq 1, \quad \forall (n_1, n_2)\in 1,\dots,N, \, \forall m\in1,\dots,M\\&#xA;&amp;amp; z_{n,m}\in\{0,1\}, \quad \forall n\in 1,\dots,N, \, \forall m\in 1,\dots,M&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OBS: Also, use the recommendation of Rob Pratt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Final step: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apply the same method shown in the &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0975914626&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;book&lt;/a&gt;, where it is proved that the optimal objective value of LP1 is equal to BLP1 and the solution &lt;span class=&quot;math-container&quot;&gt;$w_S=1$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$x_i=1, \forall i\in S$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i=0, \forall i\notin S$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BLP1:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;\max &amp;amp; cx\\&#xA;\text{s.t.} &amp;amp; Ax=b\\&#xA;&amp;amp; x\in\{0,1\}&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;LP1:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;\max &amp;amp; \sum\limits_{S\subseteq N}\left(\sum\limits_{i\in S} c_i\right)w_S\\&#xA;\text{s.t.} &amp;amp; (A_S -b)w_S =0,\quad \forall S\subseteq N\\&#xA;     &amp;amp; \sum\limits_{S\subseteq N} w_S=1\\&#xA;     &amp;amp; w_S \geq 0.&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="1252" LastEditorUserId="500" LastEditDate="2020-01-17T22:54:40.530" LastActivityDate="2020-01-17T22:54:40.530" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="3208" PostTypeId="1" CreationDate="2019-12-18T08:12:42.177" Score="9" ViewCount="787" Body="&lt;p&gt;[Topic to discuss GA and CPLEX]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen some papers trying to integrate genetic algorithm with CPLEX, such as &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S095741741100577X&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0360544215017612&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. Although they integrated both, it is done in 2 different steps; that means, they use CPLEX in one step and the results obtained are used as input for the second step, in which GA is used (or vice-versa). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am wondering if it would be possible to integrate CPLEX in GA on the same step to solve large instances of problems. Considering the GA methodology and the fact that CPLEX is a solver, initially, I would say no to this question. &#xA;But I would like to open this discussion about the integration of heuristic methods with CPLEX to know other opinions and perspectives. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone already worked with both, heuristic and CPLEX integrated, and can share some tips, I would be really grateful.&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="36" LastEditDate="2019-12-18T14:18:41.137" LastActivityDate="2020-06-04T19:29:58.383" Title="Integrating genetic algorithm (or other heuristic methods) with CPLEX" Tags="|cplex|heuristics|metaheuristics|docplex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3209" PostTypeId="1" AcceptedAnswerId="3210" CreationDate="2019-12-18T13:27:42.133" Score="14" ViewCount="1473" Body="&lt;p&gt;When I have to write the formulation of an IP, I usually have the choice between writing &lt;span class=&quot;math-container&quot;&gt;$i\times j$&lt;/span&gt; binary variables with two indices such as &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j} $&lt;/span&gt; or, writing &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; integer variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it better to use only binary variables but with a higher number of variables or to use fewer integer variables?&#xA;Does a solver work better with binary variables?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally think that the stronger limitation of a variable is the number of variables so I would choose the solution with fewer integer variables. However, I would like to confirm that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance for your advice!&#xA;(PS: Tell me if my question is not clear)&lt;/p&gt;&#xA;" OwnerUserId="986" LastEditorUserId="986" LastEditDate="2019-12-18T21:24:47.813" LastActivityDate="2019-12-19T10:29:22.683" Title="How to choose between high number of binary variables or fewer number of integer (not only 0 and 1) variables in a IP formulation?" Tags="|modeling|integer-programming|binary-variable|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3210" PostTypeId="2" ParentId="3209" CreationDate="2019-12-18T13:42:37.657" Score="20" Body="&lt;p&gt;I learned very early (this may not be &lt;em&gt;generally&lt;/em&gt; true) that I should always prefer binary over integer variables. A reason is that from binary values you can infer logical information, branching on a binary variable fixes its value (=reduces the model) etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would go even further. It may be better to have &lt;em&gt;more&lt;/em&gt; variables. Why? Of course, this depends on the formulation, but more variables often means that you have more possibilities to &lt;em&gt;express&lt;/em&gt; yourself, that may imply more opportunities to derive cuts etc. I personally think that it is easier to formulate the constraints (think even only of avoiding that two integer variables have the same value, and how easy it is with binary variables). All this is not computationally supported here by myself, but I am sure that someone could. I, for one, use as many variables as I can, I introduce variables which carry a lot of meaning, represent entire partial solutions, configurations, subsets, etc. This typically gives me stronger relaxations. You may need a special algorithm to deal with a larger number of variables (like column generation).&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2019-12-18T13:42:37.657" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3211" PostTypeId="2" ParentId="3208" CreationDate="2019-12-18T17:53:10.047" Score="7" Body="&lt;p&gt;I am aware of two ways of combining a (meta-)heuristic with a solver (like cplex). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Warm start: use a heuristic to quickly find a good solution and give it to the solver as a starting solution. This can help pruning the branch and bound tree considerably. (e.g. &quot;Designing sustainable energy regions using genetic algorithms and location-allocation approach&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Advice:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The warm start method is useful, if cplex struggles to find a legal solution but is quick to improve it, once found; or cplex struggles to find a good solution, but once given it, is quick to make the optimality gap small; Or a good initial solution helps prune the branch and bound tree significantly.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sometimes improving the model or solution method, s.t. the solver is faster on its own (e.g. by making the relaxation tighter or using local branching) is better when you need the optimal solution. If you don't need any guaranties on the optimization gap and the model is incredibly hard to solve, more runtime for the heuristic and no second phase is sometimes the better bet.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;2) Decompose: part your model in a &quot;master model&quot; that doesn't contain all variables or all constraints. Put the rest in a &quot;slave model&quot; that based on the solution to the master model computes a solution to a different model and returns the information to the master model (e.g. adding variables in column generation, adding constraints in (combinatorial) benders decomposition, &quot;A distribution network optimization problem for third party logistics service providers&quot;). Or the slave model combines the solution of the master model with its own solution to a solution to the entire problem. In this case you could also consider multi-stage techniques (e.g. fix and optimize or hierarchical planing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Advice:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Decomposition is hard. The idea is to find a subproblem, that is easier to solve than the original problem. Easier could mean it is solvable in polynomial time, or that it can be solved very fast in practice (e.g. set covering).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Think about the communication between the different levels of models. How does the solution to the master model influence the slave model(s)? How is the solution to the slave model communicated to the master model?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the master model is heuristic, it is typically because you need to solve a practically easily solvable problem to get the objective value for the solution of the heuristic. Therefore you use an exact solver to get that objective value in the slave model.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the master model is an exact MIP-model and the slave model is a heuristic, you typically generate variables and cuts with it. This usually means that the whole process is a heuristic. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the master model is an exact MIP-model, the information communicated to the subproblem are typically the dual prices, if you want to generate variables; and the solution, if you want to generate cuts.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="405" LastEditorUserId="405" LastEditDate="2020-06-04T19:29:58.383" LastActivityDate="2020-06-04T19:29:58.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3212" PostTypeId="1" AcceptedAnswerId="3219" CreationDate="2019-12-19T04:07:25.193" Score="5" ViewCount="458" Body="&lt;p&gt;The optimization problem that I am dealing with is very similar to this &lt;a href=&quot;https://www.mathworks.com/help/gads/solving-a-mixed-integer-engineering-design-problem-using-the-genetic-algorithm.html&quot; rel=&quot;noreferrer&quot;&gt;example&lt;/a&gt;. In brief, I have some decision variables that can take real values with lower/upper bounds, and some other variables that are constrained to be integers (which are then mapped to another value). The objective function and constraints are non-convex and non-linear. So far, the genetic algorithm is the one method that I have found, but I would like to know about other techniques (that are possibly better/faster) to approach this problem. &lt;/p&gt;&#xA;" OwnerUserId="2843" LastEditorUserId="47" LastEditDate="2019-12-19T07:28:52.913" LastActivityDate="2019-12-21T09:06:11.303" Title="Solving a non-linear non-convex mixed-integer program" Tags="|minlp|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3213" PostTypeId="2" ParentId="3209" CreationDate="2019-12-19T10:29:22.683" Score="4" Body="&lt;p&gt;If you have a question about what's faster for your work cases, try both on your system. There's quite a variety in simplex solvers, especially when you're talking about integer programming. If you can convert it, a smart enough system can convert it, and probably more optimally than you can without system details. Testing the system is the only way to figure out what's faster on your system. &lt;/p&gt;&#xA;" OwnerUserId="2845" LastActivityDate="2019-12-19T10:29:22.683" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3214" PostTypeId="1" CreationDate="2019-12-19T13:37:29.027" Score="13" ViewCount="1037" Body="&lt;p&gt;Typically OR-projects steps are: observing a situation, modeling it, solving the model, implementing the solution, and evaluating the situation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the area of production and logistics, the models are typically NP-hard combinatorial optimization problems. Typically, the contribution of these papers is to determine the complexity status of the problem and give a solution method with a small optimality gap. Some give some managerial insights based on the model.&#xA;The focus is on the optimization and the steps that come after modeling and before the implementation of the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But &lt;strong&gt;any optimization model also has a predictive element to it&lt;/strong&gt;. (The prediction is if you take this solution, the objective value will be  X and the solution will be implementable.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Are there any studies on the predictive element of OR models?&lt;/strong&gt; I would be especially interested in studies of the &quot;implementation gap&quot;, i.e. the difference in cost predicted by the model and the real cost (or travel distance or ...). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could so far not find any such studies, but I think such a study would be highly relevant:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question of the gap between practice and theory is not new: e.g.&#xA;  &lt;a href=&quot;https://doi.org/10.1080/00207549308956713&quot; rel=&quot;noreferrer&quot;&gt;Addressing the gap in scheduling research: a review of optimization and heuristic methods in production scheduling&lt;/a&gt; ask it in 1993.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There still seems to be a large gap with many models: e.g. for cross-docking, this study &lt;a href=&quot;https://doi.org/10.1016/j.omega.2015.09.006&quot; rel=&quot;noreferrer&quot;&gt;Cross-docking operations: Current research versus industry practice&lt;/a&gt; finds (in 2015): &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But the cross-docking optimization literature evoked earlier seems&#xA;  somewhat disconnected from the actual industrial implementations of&#xA;  cross-docking&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There would probably be a considerable implementation gap if the model is &quot;disconnected from the actual industrial implementations of cross-docking&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming that literature reviews are somewhat representative of literature, we can look at: &lt;a href=&quot;https://doi.org/10.1016/j.sorms.2016.05.002&quot; rel=&quot;noreferrer&quot;&gt;A ‘‘Meta survey’’ analysis in Operations Research and Management&#xA;Science: A survey of literature reviews&lt;/a&gt; and find that &quot;there is a fair concentration of topical coverage in the broad field of OR/MS, focusing on supply chain and logistics, sustainability, and scheduling&quot;. This therefore doesn't seem to be a small niche.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously there is research in the more mathematical sense on strongly abstracted problems like the TSP, CVRP or the RCPSP. I also understand, that studying special cases, can lead to insights that might later be abstracted. However, most extensions of these models typically come with the claim, that it is &quot;relevant for practice&quot;, yet I've never seen any inclusion of an &quot;implementation gap&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I'm aware of the informs journal of applied analytics, which does publish case studies, but even there I couldn't find anything on an &quot;implementation gap&quot;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question: Is there any research on this &quot;implementation gap&quot;. Is there maybe a different name/search term for it?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;And why is it not always included anyway; some information on the quality of the model seem almost indispensable to me?&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2019-12-19T21:04:54.113" LastActivityDate="2019-12-20T00:26:38.237" Title="Implementation gap in logistics" Tags="|reference-request|academia|literature-research|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3215" PostTypeId="2" ParentId="3214" CreationDate="2019-12-19T15:13:41.143" Score="10" Body="&lt;p&gt;You asked two questions at the end and I only try to answer the second &quot;why is it [implementation gap] not always included anyway&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I understand your question correctly, I'd say there can be many reasons why such an &quot;implementation gap&quot; that you refer to doesn't exist or reported. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The academic studies are not necessarily implemented. Why? It can be due to the simplicity of the model's assumptions, the specificity of the assumptions (e.g. your study is on VRP with backhauls with no time windows but I have a case for simultaneous pickups and delivery with time windows), the complexity of the solution or implementation cost of the solution (e.g. &lt;a href=&quot;https://www.wired.com/2012/04/netflix-prize-costs/&quot; rel=&quot;noreferrer&quot;&gt;Netflix never used its 1 million dollar code!&lt;/a&gt;), or that nobody knows about that study (among many other reasons).&lt;/li&gt;&#xA;&lt;li&gt;Today's problems can be very different from tomorrow's. You may do research on a specific case study (thus, no such implementation gap) but by introducing even the smallest tweaks or additional constraints, the algorithms you have (and thus your solutions) don't work anymore (For example, you implement a great solution for a VRP where you pick from one central depot and you can deliver to a maximum of 4 warehouses and all of a sudden, I ask you for a small tweak of picking from more than one depot, i.e. multiple picks.) So, how do you measure the implementation gap here?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bear in mind that I don't mean simple models are useless or &quot;just for insight&quot;. On the contrary, they can serve as the minimum viable product (MVP) and that may do the job. Maybe you only need a feasible solution, something you don't currently have, and a model with simple assumptions provide that for you.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;You also mentioned that this implementation gap is like the &quot;predictive element&quot; in an optimization model. But for a prediction, you have actual and predicted values. How do you know the actual values? Do you consider the status quo the actual (Whether manual solutions, the solutions from another tool, or solutions that are far from being optimal)? As I mentioned above, we can't expect that even the most relevant studies are implemented, so that to have a sense of the actual vs predicted values. So, when studies perform tests against the standard library of datasets and report their results, that, IMO, is the best that they can do.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And finally, in journals such as IJAA that you mentioned where case studies are published, presumably, those implementations gaps should not exist as the study is already implemented!&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-12-19T15:13:41.143" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3216" PostTypeId="1" CreationDate="2019-12-19T15:45:11.663" Score="9" ViewCount="170" Body="&lt;p&gt;I have a simple model such as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad z=X_1+X_2+X_3+X_4\\\text{s.t.}&amp;amp;\quad y_1+y_2+y_3+y_4=2\\&amp;amp;\quad X_1 \leq y_1\\&amp;amp;\quad X_2 \leq y_1+y_2\\&amp;amp;\quad X_3 \leq y_2+y_3\\&amp;amp;\quad X_4 \leq y_1+y_4\\&amp;amp;\quad x,y \in \{0,1\}.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above formulation can be simplified by removing &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; variable, &lt;span class=&quot;math-container&quot;&gt;$X_1 \leq y_1$&lt;/span&gt; constraint and adding &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; to the objective function  to get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad z=y_1+X_2+X_3+X_4\\\text{s.t.}&amp;amp;\quad y_1+y_2+y_3+y_4=2\\&amp;amp;\quad X_2 \leq y_1+y_2\\&amp;amp;\quad X_3 \leq y_2+y_3\\&amp;amp;\quad X_4 \leq y_1+y_4\\&amp;amp;\quad x,y \in \{0,1\}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;because &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The direction of optimization is maximization,&lt;/li&gt;&#xA;&lt;li&gt;Objective function coefficients are &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, &lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;'s are bounding &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;'s and  &lt;/li&gt;&#xA;&lt;li&gt;Variables are all binary. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is it possible to assess any results on the polytopes or (extreme points of the polytopes) of these two formulations, something like &quot;these two polytopes are equivalent as they yield the same optimal solution with this objective function&quot;? What would be your approach to prove the equivalence of these two formulations?&lt;/p&gt;&#xA;" OwnerUserId="632" LastEditorUserId="123" LastEditDate="2019-12-19T21:04:01.257" LastActivityDate="2019-12-20T00:49:38.927" Title="Equivalence of formulations" Tags="|integer-programming|combinatorial-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3217" PostTypeId="2" ParentId="3214" CreationDate="2019-12-19T18:28:18.287" Score="13" Body="&lt;p&gt;The implementation gap may not be a function of the &quot;quality of the model&quot; (or the algorithm used to solve it, which is a separate dimension). I had an experience with a logistics problem where the model was a simple shortest-path network model and the solution method was Dijkstra's shortest path algorithm. Both are time tested and thoroughly accepted. The implementation never happened, in part because the initial test was a dud. Why? The data used to parameterize the model, taken from a corporate database, was garbage. So there was a large implementation gap, but it was unrelated to the model (or algorithm).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2019-12-19T18:28:18.287" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3218" PostTypeId="2" ParentId="3214" CreationDate="2019-12-19T21:55:59.447" Score="4" Body="&lt;p&gt;In solving optimization problems, the gap is a relative concept. In the academic papers, the authors, have often used small instances to represent the model under study and usually, they could solve them optimality with a small gap. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, in the real-world problems (specifically, supply chain or scheduling) the problem is large, and the solution might be accepted with a relatively large gap. (separate from which kind of method, exact/heuristic, is used to solve the model.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, however, many practical works have not been published for commercial reasons that are hard to predict and compare the real and academic gap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are interested, some useful references (real-world case study) could be found on the optimization software host like &lt;a href=&quot;https://www.gurobi.com/resources/?category-filter=case-study&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; or &lt;a href=&quot;https://www.ibm.com/products/ilog-cplex-optimization-studio/resources&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2019-12-19T21:55:59.447" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3219" PostTypeId="2" ParentId="3212" CreationDate="2019-12-20T00:13:28.813" Score="5" Body="&lt;p&gt;If you have the mathematical formulas for your problem (i.e., it's not black box), you can use a local MINLP solver, such as BONMIN, KNITRO, or MINOTAUR, or a deterministic global optimisation solver such as ANTIGONE, BARON, Couenne, or Octeract Engine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your problem is black box but you have access to derivatives, and function evaluations, I believe that KNITRO also supports callbacks and you can do the same in MINOTAUR but you'll probably need to edit the source code a bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The local optimisation solvers will be fast but might not find good/any solutions, whereas the deterministic global optimisation solvers are typically  slower but much more likely to find a feasible point, and guarantee global optimality in a finite number of steps.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2019-12-20T00:18:50.473" LastActivityDate="2019-12-20T00:18:50.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3220" PostTypeId="2" ParentId="3214" CreationDate="2019-12-20T00:26:38.237" Score="4" Body="&lt;p&gt;It's unlikely that you will find a generalised study on this, as the predictive power of an optimisation model depends on the accuracy of the data we use to build the model, and on the skill of the modeler themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is also compounded by the fact that the predictive power of a model is also dependent on the solver we use, in particular on whether the solver is able to close the optimality gap and get us close to the global solution which, in many cases, is the only solution of the model which corresponds to reality.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2019-12-20T00:26:38.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3221" PostTypeId="2" ParentId="3216" CreationDate="2019-12-20T00:43:27.147" Score="4" Body="&lt;p&gt;This kind of depends on how one defines &quot;equivalent&quot;, but in my opinion these formulations are not equivalent. Notice that in the original expression &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; can be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$y_1=1$&lt;/span&gt;. By performing that substitution, you effectively fix that degree of freedom because now your objective will be incremented by &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$y_1=1$&lt;/span&gt;, which was not necessarily the case in the original formulation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While this might or might not give you the same optimal value, there is no guarantee that your active set will be the same (and although it's hard to tell without solving the problem in this case I suspect they will not be).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of the polytope, you created a different polytope which possibly shares one or more vertices with the original one.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2019-12-20T00:49:38.927" LastActivityDate="2019-12-20T00:49:38.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3222" PostTypeId="1" CreationDate="2019-12-20T13:53:40.407" Score="5" ViewCount="102" Body="&lt;p&gt;I am trying to understand the route constraints in jsprit. While I got the concept of HardActivityConstraint, I am unable to have clarity on HardRouteConstraint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone, preferably with a simple example explain to me how it works, what is its relevance with JobInsertionContext, how sending true/false impacts the routes? Or direct me to any literature or blog where I can read and understand.&lt;/p&gt;&#xA;" OwnerUserId="2813" LastEditorUserId="36" LastEditDate="2019-12-20T14:58:45.120" LastActivityDate="2019-12-20T14:58:45.120" Title="Understanding HardRouteConstraint" Tags="|reference-request|vehicle-routing|java|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3223" PostTypeId="2" ParentId="3212" CreationDate="2019-12-20T23:05:34.567" Score="1" Body="&lt;p&gt;Try to take a look at these non-convex programming techniques:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DC Programming and DCA&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.lita.univ-lorraine.fr/~lethi/index.php/dca.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.lita.univ-lorraine.fr/~lethi/index.php/dca.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-018-1235-y&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/article/10.1007/s10107-018-1235-y&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="206" LastEditorUserId="123" LastEditDate="2019-12-21T09:06:11.303" LastActivityDate="2019-12-21T09:06:11.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3224" PostTypeId="1" CreationDate="2019-12-22T12:35:11.867" Score="6" ViewCount="618" Body="&lt;p&gt;I am solving an MIP through Benders decomposition (coded both generic and legacy callback versions), by employing Java with Cplex 12.9. For some of the instances, Cplex is stuck for two hours (time limit is two hours) after solving root node relaxation very fast (in less than a second) and finally at the end of two hours it reports a single line of branch and bound tree (root node) and exits due to time limit. Nothing is reported after root node relaxation solution and before the first line of branch and bound tree (to understand what Cplex is doing for two hours). I turned off reductions and presolve and all possible cuts. Nothing changed. Please see that portion of the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;master.setParam(IloCplex.IntParam.MIPDisplay, 4);&#xA;master.setParam(IloCplex.Param.Threads, nThreads);&#xA;master.setParam(IloCplex.Param.Preprocessing.Reduce, 0); &#xA;master.setParam(IloCplex.BooleanParam.PreInd, false);  &#xA;master.setParam(IloCplex.IntParam.MIPEmphasis, 2);&#xA;master.setParam(IloCplex.IntParam.VarSel, 3);&#xA;master.setParam(IloCplex.Param.MIP.Strategy.HeuristicFreq, -1);&#xA;master.setParam(IloCplex.DoubleParam.TiLim, 7200);&#xA;&#xA;master.setParam(IloCplex.IntParam.Cliques, -1);&#xA;master.setParam(IloCplex.IntParam.Covers, -1);&#xA;master.setParam(IloCplex.IntParam.DisjCuts, -1);&#xA;master.setParam(IloCplex.IntParam.FlowCovers, -1);&#xA;master.setParam(IloCplex.IntParam.FracCuts, -1);&#xA;master.setParam(IloCplex.IntParam.GUBCovers, -1);&#xA;master.setParam(IloCplex.IntParam.LiftProjCuts, -1);&#xA;master.setParam(IloCplex.IntParam.MCFCuts, -1);&#xA;master.setParam(IloCplex.IntParam.MIRCuts, -1);&#xA;master.setParam(IloCplex.IntParam.FlowPaths, -1);&#xA;master.setParam(IloCplex.IntParam.ZeroHalfCuts, -1);&#xA;&#xA;master.setParam(IloCplex.Param.MIP.Cuts.BQP, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.Cliques, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.Covers, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.Disjunctive, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.FlowCovers, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.Gomory, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.GUBCovers, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.Implied, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.LiftProj, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.LocalImplied, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.MCFCut, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.MIRCut, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.PathCut, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.RLT, -1);&#xA;master.setParam(IloCplex.Param.MIP.Cuts.ZeroHalfCut, -1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please see the log file below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CPXPARAM_Preprocessing_Presolve                  0&#xA;CPXPARAM_Preprocessing_Reduce                    0&#xA;CPXPARAM_Threads                                 40&#xA;CPXPARAM_MIP_Cuts_Cliques                        -1&#xA;CPXPARAM_MIP_Cuts_Covers                         -1&#xA;CPXPARAM_MIP_Display                             4&#xA;CPXPARAM_MIP_Strategy_VariableSelect             3&#xA;CPXPARAM_MIP_Cuts_FlowCovers                     -1&#xA;CPXPARAM_MIP_Cuts_Implied                        -1&#xA;CPXPARAM_MIP_Cuts_GUBCovers                      -1&#xA;CPXPARAM_MIP_Cuts_Gomory                         -1&#xA;CPXPARAM_MIP_Cuts_PathCut                        -1&#xA;CPXPARAM_MIP_Cuts_MIRCut                         -1&#xA;CPXPARAM_MIP_Cuts_Disjunctive                    -1&#xA;CPXPARAM_Emphasis_MIP                            2&#xA;CPXPARAM_MIP_Cuts_ZeroHalfCut                    -1&#xA;CPXPARAM_MIP_Cuts_MCFCut                         -1&#xA;CPXPARAM_MIP_Cuts_LiftProj                       -1&#xA;CPXPARAM_MIP_Cuts_LocalImplied                   -1&#xA;CPXPARAM_MIP_Cuts_BQP                            -1&#xA;CPXPARAM_MIP_Cuts_RLT                            -1&#xA;CPXPARAM_MIP_Strategy_HeuristicFreq              -1&#xA;CPXPARAM_TimeLimit                               7200&#xA;Lazy constraint(s) or lazy constraint callback is present.&#xA;    Disabling non-linear reductions (CPX_PARAM_PRELINEAR) in presolve.&#xA;Clique table members: 114063.&#xA;MIP emphasis: optimality.&#xA;MIP search method: dynamic search.&#xA;Parallel mode: deterministic, using up to 40 threads.&#xA;Parallel mode: deterministic, using up to 40 threads for concurrent optimization.&#xA;Initializing dual steep norms . . .&#xA;Initializing dual steep norms . . .&#xA;&#xA;Dual simplex solved model.&#xA;&#xA;Root relaxation solution time = 0.61 sec. (227.78 ticks)&#xA;&#xA;        Nodes                                         Cuts/&#xA;   Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap&#xA;&#xA;      0     0  3898607.0000     0                      0.0000        0         &#xA;&#xA;User cuts applied:  2&#xA;&#xA;Root node processing (before b&amp;amp;c):&#xA;  Real time             = 7199.43 sec. (2190540.20 ticks)&#xA;Parallel b&amp;amp;c, 40 threads:&#xA;  Real time             =    0.00 sec. (0.00 ticks)&#xA;  Sync time (average)   =    0.00 sec.&#xA;  Wait time (average)   =    0.00 sec.&#xA;                          ------------&#xA;Total (root+branch&amp;amp;cut) = 7199.43 sec. (2190540.20 ticks)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="123" LastEditDate="2019-12-22T14:41:01.043" LastActivityDate="2019-12-22T14:41:01.043" Title="Cplex is stuck after root node relaxation solution" Tags="|mixed-integer-programming|cplex|presolve-preprocessing|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3225" PostTypeId="1" CreationDate="2019-12-22T15:31:54.577" Score="3" ViewCount="77" Body="&lt;p&gt;I am mimicking a GAMS model that was introduced in &lt;a href=&quot;https://ieeexplore.ieee.org/document/6495737&quot; rel=&quot;nofollow noreferrer&quot;&gt;Soler &lt;em&gt;et al.&lt;/em&gt; (2013)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; to compare my new model with its results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a nutshell, assume we have a variable &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; that is supposed to only take certain discrete values from the set &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$D=\{0.12,0.22,0.32,0.42,0.52, 0.62\}$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The proposed method is to relax &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and make it a continuous variable between two upper and lower limits &lt;span class=&quot;math-container&quot;&gt;$\min D\le t\le\max D$&lt;/span&gt; and then add a penalty function to the model objective function to force the solver to allocate only discrete values for &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The penalty function is &lt;span class=&quot;math-container&quot;&gt;$\sin^2\left(\pi t/(\text{upr}-\text{lwr})\right)$&lt;/span&gt; where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{upr}$&lt;/span&gt; is the upper closest values for &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{lwr}$&lt;/span&gt; is the lower closest values for &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This clever trick will make the penalty function take positive values if the allocated value for &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is not discrete, and zero if &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is discrete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;During the optimization process, when the solver allocates a value for &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, it needs to find the two closest elements from &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; to the allocated value of &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Let's say it gives &lt;span class=&quot;math-container&quot;&gt;$t=0.14$&lt;/span&gt;, then it has to find the upper and lower values of &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; which are &lt;span class=&quot;math-container&quot;&gt;$\text{lwr}=0.12$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\text{upr}=0.22$&lt;/span&gt;. This has to be done during the optimization process not after it finishes like in some iterative methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So, my question is how I should code this in GAMS. How can I tell the solver to find the upper and lower values of a variable from a set during the optimization process? In MATLAB we use the function &lt;code&gt;find&lt;/code&gt; but it is not effective.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Soler, E. M., Asada, E. N., da Costa, G. R. M. (2013). Penalty-based nonlinear solver for optimal reactive power dispatch with discrete controls. &lt;em&gt;IEEE Transactions on Power Systems.&lt;/em&gt; &lt;strong&gt;28(3)&lt;/strong&gt;:2174-2182. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="2854" LastEditorUserId="123" LastEditDate="2019-12-22T16:03:43.440" LastActivityDate="2019-12-22T16:03:43.440" Title="How can I do this in GAMS?" Tags="|optimization|gams|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3226" PostTypeId="1" AcceptedAnswerId="3258" CreationDate="2019-12-22T21:14:51.560" Score="4" ViewCount="195" Body="&lt;p&gt;I have a model written in &lt;code&gt;CPLEX OPL&lt;/code&gt;. Is there a way to export the model to &lt;code&gt;.cpo&lt;/code&gt; extension?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Python &lt;code&gt;docplex&lt;/code&gt; module the syntax is as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;mdl.export_as_cpo()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I could not find an  equivalent command for the &lt;code&gt;OPL&lt;/code&gt; in the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.studio.help/pdf/opl_languser.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;OPL User's manual&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="660" LastActivityDate="2020-01-21T20:37:47.803" Title="Can I export to .cpo file using OPL?" Tags="|modeling|cplex|cp-optimizer|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3227" PostTypeId="2" ParentId="3188" CreationDate="2019-12-22T21:54:25.620" Score="7" Body="&lt;p&gt;I am a researcher in vehicle routing, and my answer is based on my experience as a researcher, conversations with practitioners and consultants, and seminars and conference talks I have attended.&lt;/p&gt;&#xA;&lt;p&gt;You make a very interesting observation: solving VRP's to optimality is currently only possible for hundreds of customers, while problems in practice are significantly bigger. However, there are several ways how exact methods (methods that guarantee optimality) have an impact on the industry.&lt;/p&gt;&#xA;&lt;h3&gt;Splitting the problem&lt;/h3&gt;&#xA;&lt;p&gt;If a problem is too difficult to solve at once, it may be split into more manageable parts. One way to do this is by solving parts of the problem sequentially, at the cost of losing guaranteed optimality. Each sequential problem might be small enough to be solved exactly, or is at least easier to solve with heuristics. This approach was used for optimizing the timetable of the Dutch Railways, for example. To quote from &lt;a href=&quot;https://doi.org/10.1287/inte.1080.0409&quot; rel=&quot;nofollow noreferrer&quot;&gt;The New Dutch Timetable: The O.R. Revolution&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;To construct a new timetable and its related resource schedules, we modeled and solved a sequence of planning problems. As input, we had to define a linesystem. Then, we calculated the timetable, including the detailed routings through the stations. Finally, we needed to construct rolling-stock and crew schedules. Note that we solved these different planning problems sequentially.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Another way to split problems is by splitting them geographically. This is an approach that is used by some grocery deliverers for example. After dividing the service area into regions, each region is optimized independently. If the regions are sufficiently small, exact methods may be used.&lt;/p&gt;&#xA;&lt;h3&gt;Heuristics&lt;/h3&gt;&#xA;&lt;p&gt;Even if exact methods are computationally infeasible, they often serve as a starting point for developing heuristics. It is very common (especially in the scientific literature) to first present the problem as a mixed integer program, even if it will not be solved as such.&lt;/p&gt;&#xA;&lt;p&gt;Exact methods provide a way to evaluate the performance of heuristics for small problems that can be solved to optimality. This provides some confidence that a heuristic provides good solutions.&lt;/p&gt;&#xA;&lt;p&gt;In industry, heuristics are a lot more common than exact methods. It should be noted however, that there is also a lot of research into heuristic methods. In my experience, local search methods, e.g., variable neighborhood search, are common for vehicle routing problems. Some consultants and companies are actively involved in research, typically with a focus on heuristics. For example, I attended a &lt;a href=&quot;https://verolog2019.sciencesconf.org/resource/page/id/4&quot; rel=&quot;nofollow noreferrer&quot;&gt;talk by Mauricio Resende&lt;/a&gt;, Principal Research Scientist at Amazon, who talked about routing problems at Amazon at a scientific conference.&lt;/p&gt;&#xA;&lt;p&gt;Some heuristics are based on exact methods. Such heuristics are often referred to as &lt;a href=&quot;https://en.wikipedia.org/wiki/Matheuristics&quot; rel=&quot;nofollow noreferrer&quot;&gt;matheuristics&lt;/a&gt;. For example, one may remove all arcs that are unlikely to appear in an optimal solution, and solve the remaining problem exactly. Another example is heuristics based on &lt;a href=&quot;https://en.wikipedia.org/wiki/Column_generation&quot; rel=&quot;nofollow noreferrer&quot;&gt;column generation&lt;/a&gt;, where only a subset of the columns is generated. Such heuristics are used for bus scheduling, for example.&lt;/p&gt;&#xA;&lt;h3&gt;Conclusion&lt;/h3&gt;&#xA;&lt;p&gt;In industry, you are unlikely to find complex problems that are solved to optimality. However, exact methods are still useful in practice. They can be used to solve subproblems, and they inspire matheuristics. Some companies are heavily involved in research, but their interest is typically more in heuristic methods, which is a research area in itself.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-12-23T09:23:07.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3228" PostTypeId="1" CreationDate="2019-12-23T05:20:42.000" Score="7" ViewCount="153" Body="&lt;p&gt;Using a for loop to append terms to an expression seems to be much faster than summing a group of terms all at once.  Constructing the expression using a for loop uses __iadd__, which does not include a call to copy.  The other methods of building the expression result in many calls to __add__ which does call copy and is quite slow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of the six methods below, &quot;using_loop&quot; is arguably the most difficult to read, but is by far the fastest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a best practice method of building large constraints which is both readable and avoids the call to __add__ (and copy) in pulp? If I edit the __add__ function in pulp to remove the copy, are there side effects I should anticipate?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import pulp&#xA;import numpy as np&#xA;&#xA;&#xA;def using_np_mat_mul(X, coef):&#xA;    x2d = np.atleast_2d(np.array(X))&#xA;    coef2d = np.atleast_2d(np.array(coef)).T&#xA;    expr = np.matmul(x2d, coef2d)&#xA;    return expr&#xA;&#xA;&#xA;def using_loop(X, coef):&#xA;    expr = 0&#xA;    for i in range(len(X)):&#xA;        expr += X[i]*coef[i]&#xA;    return expr&#xA;&#xA;&#xA;def using_sum_of_list(X, coef):&#xA;    expr = sum([X[i]*coef[i] for i in range(len(X))])&#xA;    return expr&#xA;&#xA;def using_sum_mult(X, coef):&#xA;    expr = sum(np.array(X)*np.array(coef))&#xA;    return expr&#xA;&#xA;&#xA;def using_lpsum(X, coef):&#xA;    expr = pulp.lpSum(X[i]*coef[i] for i in range(len(X)))&#xA;    return expr&#xA;&#xA;def using_dict_and_lpsum(X_dict, coef):&#xA;    expr = pulp.lpSum(X_dict[i]*coef[i] for i in X_dict.keys())&#xA;    return expr&#xA;&#xA;if __name__ == &quot;__main__&quot;:&#xA;    nx = 5000&#xA;&#xA;    X = [pulp.LpVariable(str(i)) for i in range(nx)]&#xA;&#xA;    coef = np.random.rand(nx)&#xA;&#xA;    e1 = using_np_mat_mul(X, coef)&#xA;    e2 = using_loop(X, coef)&#xA;    e3 = using_sum_of_list(X, coef)&#xA;    e4 = using_sum_mult(X, coef)&#xA;    e5 = using_lpsum(X, coef)&#xA;&#xA;    # create an expression = X * coef&#xA;    X_dict = pulp.LpVariable.dicts('', range(nx))&#xA;    e6 = using_dict_and_lpsum(X_dict, coef)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VBeht.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VBeht.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2388" LastEditorUserId="2388" LastEditDate="2019-12-24T05:37:34.423" LastActivityDate="2019-12-24T05:37:34.423" Title="Why does PuLP call copy for addition and how can I avoid it?" Tags="|modeling|pulp|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3229" PostTypeId="2" ParentId="3184" CreationDate="2019-12-23T10:04:46.570" Score="2" Body="&lt;p&gt;You may wish to take a look at the paper by &lt;a href=&quot;https://pdfs.semanticscholar.org/d3e9/8707c845ef0071689a4cea32501a18cf7319.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cozman (2000)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;; the following is taken from the Introduction.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;One of the advantages of junction tree algorithms is that it is possible to efficiently compute marginal probability values for every variable in a Bayesian network. Algebraic schemes like variable and bucket elimination compute marginal probability values only for a given set of variables.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Conversely, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An attractive property of approaches based on variable elimination is that they are relatively easy to understand and to implement. Junction tree algorithms are quite complex in comparison, demanding long digressions on graph theoretic concepts.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Cozman, F. G. (2000). Generalizing Variable Elimination in Bayesian Networks. &lt;em&gt;Workshop on Probabilistic Reasoning in Artificial Intelligence,&lt;/em&gt;&#xA;Atibaia, Brazil. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-12-23T10:04:46.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3231" PostTypeId="2" ParentId="602" CreationDate="2019-12-24T12:43:37.107" Score="4" Body="&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: Why do we normally assume normal distribution/Poisson distribution for customer demand in a supply chain?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Answer&lt;/strong&gt; :&lt;br&gt;&#xA;Based on my experience in the industry, I have seen that generally, business users use simple thumb rules-based methods for safety stock or inventory models. The next level of sophistication for these users is usage of Normal or Poisson distribution. Usage of these distributions may not be most optimal but these distribution-based models are far more superior as compared to thumb rule-based methods. Now the next level of sophistication is the implementation of actual distribution. When you want to implement the actual distribution then first you need to conduct certain tests to identify the actual fit. The next level of complication arises when you want to combine Actual Demand Distribution with Actual Lead time distribution for computation of safety stocks in the supply chain. Unfortunately not much info is available on how to combine the actual distribution of Demand with the actual distribution of lead time to compute optimal safety stock.&#xA;In my experience, for most of the time Forecast Error or Demand distribution is not normally or Poisson distributed.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;  Are there other good distribution assumptions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Answer&lt;/strong&gt;: There are some approximations available. These are based on research work mentioned in book Inventory and Production Management in Supply Chains by Edward, Silver &amp;amp; Spike&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Std Deviation to mean demand &lt;span class=&quot;math-container&quot;&gt;$\le 0.5$&lt;/span&gt; and Lead time demand &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;10$&lt;/span&gt;:&#xA;normal distribution.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Std Deviation to mean demand &lt;span class=&quot;math-container&quot;&gt;$&amp;gt; 0.5$&lt;/span&gt; and Lead time demand &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;10$&lt;/span&gt;: gamma&#xA;distribution&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Lead time demand &lt;span class=&quot;math-container&quot;&gt;$&amp;lt;10$&lt;/span&gt;, then use Poisson, Binomial, and Negative&#xA;Binomial distributions&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2860" LastEditorUserId="123" LastEditDate="2019-12-24T14:26:49.143" LastActivityDate="2019-12-24T14:26:49.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3232" PostTypeId="2" ParentId="1" CreationDate="2019-12-24T15:38:14.530" Score="2" Body="&lt;p&gt;I have done extensive analysis of procurement lead time distribution across industries. In my experience, I found most of the distribution are heavily skewed towards the left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, you are right! Most of the books talk about mathematical modeling by considering lead time as normally distributed. I have yet to see mathematical models that leverage actual distributions for demand and supply lead time. Another way to come out with reorder point/safety stock is to randomly generate demand and lead time based on actual distributions and compute safety stock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In practical situations, direct usage of formula &lt;span class=&quot;math-container&quot;&gt;$\sigma^2_{LTD} = \mu_L\sigma^2 + \mu^2\sigma_L^2$&lt;/span&gt; spikes up safety stock significantly and provide over protection from stock out situations. It is strongly recommended to look at variability in lead time and take measures to reduce variability.&lt;/p&gt;&#xA;" OwnerUserId="2860" LastEditorUserId="123" LastEditDate="2019-12-24T17:03:22.320" LastActivityDate="2019-12-24T17:03:22.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3233" PostTypeId="1" AcceptedAnswerId="3235" CreationDate="2019-12-24T19:04:41.683" Score="10" ViewCount="989" Body="&lt;p&gt;I am trying to implement a user-written lazy constraint callback in concert CPLEX with C++. Although I know there exists a way to implement callbacks in concert CPLEX with C++ via &lt;a href=&quot;http://www-eio.upc.edu/lceio/manuals/cplex-11/html/usrcplex/callbacks16.html#1009168&quot; rel=&quot;nofollow noreferrer&quot;&gt;macros&lt;/a&gt;, I am looking for a way to implement lazy constraint callback without macros.&lt;/p&gt;&#xA;&lt;p&gt;At this moment I know that I must create a class that inherits from the class &lt;code&gt;IloCplex.LazyConstraintCallback&lt;/code&gt; (the documentation of this class can be found &lt;a href=&quot;https://perso.ensta-paris.fr/%7Ediam/ro/online/cplex/cplex1271/refjavacplex/html/ilog/cplex/IloCplex.LazyConstraintCallback.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;). I am aware that this type of implementation requires (a kind of) profound understanding of the algorithms used by CPLEX, however, I want to learn how to do it without the using of macros. After spending some days looking for any code in C++ I could not find anything. Therefore, I am here to know if anyone has any template of how it could be done.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="491" LastEditDate="2022-10-12T21:07:17.020" LastActivityDate="2022-10-12T21:07:17.020" Title="How can I implement a user-written lazy constraint callback in concert CPLEX with C++?" Tags="|cplex|c++|callback|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3234" PostTypeId="2" ParentId="3233" CreationDate="2019-12-24T22:06:45.030" Score="4" Body="&lt;p&gt;I don't have any C++ code using a lazy constraint callback, although I could show you a Java example if you can't find anything better. The basic approach, IIRC, is to create an instance of class &lt;code&gt;IloCplex::LazyConstraintCallbackI&lt;/code&gt;. In it, you implement the &lt;code&gt;main()&lt;/code&gt; method, which is what CPLEX will call to invoke the callback. Inside the &lt;code&gt;main&lt;/code&gt; method, you call various &lt;code&gt;get&lt;/code&gt; methods to get the proposed solution, do whatever calculations you need to do, and call &lt;code&gt;add()&lt;/code&gt; or &lt;code&gt;addLocal()&lt;/code&gt; once for each cut you want to add. If you exit &lt;code&gt;main()&lt;/code&gt; without adding any cuts, you are accepting the proposed solution.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="36" LastEditDate="2019-12-24T22:13:43.367" LastActivityDate="2019-12-24T22:13:43.367" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3235" PostTypeId="2" ParentId="3233" CreationDate="2019-12-25T23:24:38.367" Score="12" Body="&lt;p&gt;You have it almost all right, with a few caveats. Let's say I want to implement a Foo Lazy Constraint:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ilocplex/ilocplex.h&amp;gt;&#xA;#include &amp;lt;ilocplex/ilocplexi.h&amp;gt;&#xA;&#xA;struct Foo : IloCplex::LazyConstraintCallbackI {&#xA;  // Your code goes here...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There are three main things you need to put inside your class; two of these are documented (more or less) and one comes from my experience:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A reference to the current CPLEX environment and any variable you might want to use, captured via the constructor. Pass the environment up to the parent constructor. This is the part that comes from my experience... indeed, you might think that to access the CPLEX environment object you can just use the inherited &lt;code&gt;getEnv()&lt;/code&gt; method, but for me this consistently causes crashes if I do something like &lt;code&gt;IloExpr lhs{getEnv()};&lt;/code&gt;. Perhaps some more knowledgeable user can explain why.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ilocplex/ilocplex.h&amp;gt;&#xA;#include &amp;lt;ilocplex/ilocplexi.h&amp;gt;&#xA;&#xA;struct Foo : IloCplex::LazyConstraintCallbackI {&#xA;  IloEnv&amp;amp; env;&#xA;  IloNumVar&amp;amp; x;&#xA;  &#xA;  Foo(IloEnv&amp;amp; env, IloNumVar&amp;amp; x) :&#xA;    LazyConstraintCallbackI{env}, env{env}, x{x} {}&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Implement a &lt;code&gt;duplicateCallback()&lt;/code&gt; method for CPLEX to use internally. This always looks the same, I basically just copy-paste it from project to project.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ilocplex/ilocplex.h&amp;gt;&#xA;#include &amp;lt;ilocplex/ilocplexi.h&amp;gt;&#xA;&#xA;struct Foo : IloCplex::LazyConstraintCallbackI {&#xA;  IloEnv&amp;amp; env;&#xA;  IloNumVar&amp;amp; x;&#xA;  &#xA;  Foo(IloEnv&amp;amp; env, IloNumVar&amp;amp; x) :&#xA;    LazyConstraintCallbackI{env}, env{env}, x{x} {}&#xA;&#xA;  [[nodiscard]] IloCplex::CallbackI* duplicateCallback() const override {&#xA;    return new(env) Foo{*this};&#xA;  }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Implement a &lt;code&gt;main()&lt;/code&gt; function that adds the cut using the parent's &lt;code&gt;add()&lt;/code&gt; method. This is the juicy part... here you access the current solution, decide whether you need a new cut and, in this case, add it.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ilocplex/ilocplex.h&amp;gt;&#xA;#include &amp;lt;ilocplex/ilocplexi.h&amp;gt;&#xA;&#xA;struct Foo : IloCplex::LazyConstraintCallbackI {&#xA;  IloEnv&amp;amp; env;&#xA;  IloNumVar&amp;amp; x;&#xA;  &#xA;  Foo(IloEnv&amp;amp; env, IloNumVar&amp;amp; x) :&#xA;    LazyConstraintCallbackI{env}, env{env}, x{x} {}&#xA;&#xA;  [[nodiscard]] IloCplex::CallbackI* duplicateCallback() const override {&#xA;    return new(env) Foo{*this};&#xA;  }&#xA;&#xA;  void main() override {&#xA;    const auto x_value = getValue(x);&#xA;    &#xA;    if(x_value &amp;lt; 2.0) {&#xA;      try {&#xA;        add(x &amp;gt;= 2.0);&#xA;      } catch(IloException&amp;amp; e) {&#xA;        std::cerr &amp;lt;&amp;lt; &amp;quot;Exception while adding lazy constraint for x = &amp;quot; &amp;lt;&amp;lt; x_value &amp;lt;&amp;lt; &amp;quot;: &amp;quot; &amp;lt;&amp;lt; e.getMessage() &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&#xA;        throw;&#xA;    }&#xA;  }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note how I can use the inherited &lt;code&gt;getValue()&lt;/code&gt; to access variables' values, and finally &lt;code&gt;add()&lt;/code&gt; to eventually add a cut. If &lt;code&gt;add()&lt;/code&gt; is called at least once, CPLEX knows that it needs to re-solve the node; otherwise, it assumes that no cuts are needed and proceeds with branching. If the lazy constraint should not join the &amp;quot;global&amp;quot; pool of constraints, but should only be active in the subtree of the current node, use &lt;code&gt;addLocal()&lt;/code&gt; instead of &lt;code&gt;add()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2020-09-04T08:07:45.870" LastActivityDate="2020-09-04T08:07:45.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3236" PostTypeId="1" AcceptedAnswerId="3238" CreationDate="2019-12-26T00:09:47.010" Score="4" ViewCount="1652" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;A company sells seven types of boxes, ranging in volume from 17 to 33 cubic feet. The demand and size of each box is given in the following table. The variable cost (in dollars) of producing each box is equal to the box's volume. A fixed cost of \$1,000 is incurred to produce any of a particular box. If the company desires, demand for a box may be satisfied by a box of larger size. Formulate and solve a shortest-path problem whose solution will minimize the cost of meeting the demand for boxes. &lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{lr}\hline&amp;amp;&amp;amp;&amp;amp;&amp;amp;\text{Box}\\\hline&amp;amp;1&amp;amp;2&amp;amp;3&amp;amp;4&amp;amp;5&amp;amp;6&amp;amp;7\\\hline\text{Size}&amp;amp;33&amp;amp;30&amp;amp;26&amp;amp;24&amp;amp;19&amp;amp;18&amp;amp;17\\\text{Demand}&amp;amp;400&amp;amp;300&amp;amp;500&amp;amp;700&amp;amp;200&amp;amp;400&amp;amp;200\\\hline\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm trying to understand this exercise from W.L Winston's &lt;em&gt;Operations Research: Algorithms and Applications&lt;/em&gt;. What I don't get is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) What does &quot;if the company desires, demand for a box may be satisfied by a box of larger size&quot; mean? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Is the demand for the quantity of that particular box( the box which is shown above that demand)? If so, isn't the problem nonsensical? We need to produce as many boxes as the demand requests, and there is no way of creating the shortest path problem? i.e we produce 400 of 33 cubic feet boxes, 300 of 30 cubic feet boxes, etc.&lt;/p&gt;&#xA;" OwnerUserId="1117" LastEditorUserId="123" LastEditDate="2019-12-26T09:49:53.060" LastActivityDate="2019-12-26T14:53:46.790" Title="Shortest path problem with boxes" Tags="|optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3237" PostTypeId="1" AcceptedAnswerId="3241" CreationDate="2019-12-26T00:46:57.540" Score="4" ViewCount="1577" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;At the beginning of year 1, a new machine must be purchased. The cost of maintaining a machine &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; years old is given in Table 5. The cost of purchasing a machine at the beginning of each year is given in Table 6. There is no trade-in value when a machine is replaced. Your goal is to minimize the total cost (purchase plus maintenance) of having a machine for five years. Determine the years in which a new machine should be purchased.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The solution (from Chegg solutions) is given by:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1y7H7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1y7H7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2QyZX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2QyZX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/auv9Z.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/auv9Z.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) What is the logic behind creating this massive objective function, if we could just calculate the optimal cost using dynamic programming?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Why is the sum of the first row equal to 1? Why is the second row of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;'s equal to &lt;span class=&quot;math-container&quot;&gt;$X_{1,2}$&lt;/span&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) I don't understand the logic behind the other equalities. If someone could explain, that would be great.&lt;/p&gt;&#xA;" OwnerUserId="1117" LastEditorUserId="123" LastEditDate="2019-12-26T09:52:06.987" LastActivityDate="2019-12-26T16:35:59.273" Title="Shortest path problem" Tags="|optimization|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3238" PostTypeId="2" ParentId="3236" CreationDate="2019-12-26T01:59:37.123" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;1) What does &quot;if the company desires, demand for a box may be satisfied by a box of larger size&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It means that if you don't have a box size &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, you can satisfy it with a box of size &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$y&amp;gt;x$&lt;/span&gt;. For example, satisfy the demand of box 30 with 33 if you don't have boxes of size 30. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2) Is the demand for the quantity of that particular box which is show above that demand? ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, the demand for each box is given below the size. But on top of your variable cost (related to the volume of the box), you have a fixed cost of producing any particular box of a given size.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-12-26T01:59:37.123" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3239" PostTypeId="2" ParentId="3237" CreationDate="2019-12-26T09:24:50.367" Score="4" Body="&lt;p&gt;1/ this is just the classical formulation of the shortest path problem as a linear program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2/ the first equality equals 1, as you need exactly one unit of flow to enter the first node &lt;/p&gt;&#xA;&#xA;&lt;p&gt;3/ these are flow conservation constraints : what goes in must come out of a node&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2019-12-26T09:24:50.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3240" PostTypeId="2" ParentId="3021" CreationDate="2019-12-26T10:25:56.803" Score="2" Body="&lt;p&gt;I do not understand why the formula for &lt;span class=&quot;math-container&quot;&gt;$C_{0,4}$&lt;/span&gt; is as such. A simple check reveals that the unit on the RHS are pounds / (pounds / inch&lt;sup&gt;2&lt;/sup&gt;) = inch&lt;sup&gt;2&lt;/sup&gt; whereas the unit for the cost is pounds.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;We have only three cases to consider here: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;12'' shelf,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;8'' shelf + 12'' shelf, &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;4'' shelf + 8'' shelf + 12'' shelf.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The general formula for the total cost is given by &lt;span class=&quot;math-container&quot;&gt;\begin{align}C=2300\times\#\,\text{shelves}&amp;amp;+200\times\text{thickness}_{4''}\times\text{height of storage}_{4''}\times5\\&amp;amp;+100\times\text{thickness}_{8''}\times\text{height of storage}_{8''}\times5\\&amp;amp;+80\times\text{thickness}_{12''}\times\text{height of storage}_{12''}\times5.\end{align}&lt;/span&gt; We know that the thickness is 0.5'' no matter the height of the book, and that the height of storage for the 12'' books must be, of course, 12''. The other heights depend on the number of shelves, so &lt;span class=&quot;math-container&quot;&gt;\begin{align}\small C&amp;amp;=\small2300\times\#\,\text{shelves}+0.5\times5\times(200\times\text{height of storage}_{4''}+100\times\text{height of storage}_{8''}+80\times12)\\&amp;amp;=\small2300\times\#\,\text{shelves}+2.5\times(200\times\text{height of storage}_{4''}+100\times\text{height of storage}_{8''}+960)\\&amp;amp;=\small2300\times\#\,\text{shelves}+250\times(2\times\text{height of storage}_{4''}+\text{height of storage}_{8''})+2400\end{align}&lt;/span&gt; after tidying up terms.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If only a 12'' shelf is used to store all books, &lt;span class=&quot;math-container&quot;&gt;$\#\,\text{shelves}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\text{height of storage}_{4''}=\text{height of storage}_{8''}=12$&lt;/span&gt;. This gives &lt;span class=&quot;math-container&quot;&gt;$$C=2300+250\times(2\times12+12)+2400={\it£}13,700.$$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If one 8'' (to store 4'' and 8'' books) and one 12'' shelf (to store 12'' books) are used, &lt;span class=&quot;math-container&quot;&gt;$\#\,\text{shelves}=2$&lt;/span&gt; so &lt;span class=&quot;math-container&quot;&gt;$\text{height of storage}_{4''}=\text{height of storage}_{8''}=8$&lt;/span&gt;. This gives &lt;span class=&quot;math-container&quot;&gt;$$C=2300\times2+250\times(2\times8+8)+2400={\it£}13,000.$$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If one 4'' shelf, one 8'' shelf and one 12'' shelf are used to store books of their corresponding heights, &lt;span class=&quot;math-container&quot;&gt;$\#\,\text{shelves}=3$&lt;/span&gt; so &lt;span class=&quot;math-container&quot;&gt;$\text{height of storage}_{4''}=4$&lt;/span&gt; whereas &lt;span class=&quot;math-container&quot;&gt;$\text{height of storage}_{8''}=8$&lt;/span&gt;. This gives &lt;span class=&quot;math-container&quot;&gt;$$C=2300\times3+250\times(2\times4+8)+2400={\it£}13,300.$$&lt;/span&gt; &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Evidently, the shortest path problem is solved when one 8'' shelf and one 12'' shelf are used. The error in your solution is due to the height of &lt;em&gt;storage&lt;/em&gt;, not the height of each book.&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-12-26T10:25:56.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3241" PostTypeId="2" ParentId="3237" CreationDate="2019-12-26T11:58:47.247" Score="7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What is the logic behind creating this massive objective function, if we could just calculate the optimal cost using dynamic programming?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You pay for each arc you use, so all arcs have to appear in the objective function. If an arc variable (and its respective cost) weren't in the objective function, you could use it &quot;for free&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question about dynamic programming is separate. Solving an integer formulation or using a dynamic programming algorithm are two ways to approach the same problem. Both are valid, and any of them might outperform the other on specific instances.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2) Why is the sum of the first row equal to 1? Why is the second row of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;'s equal to &lt;span class=&quot;math-container&quot;&gt;$X_{1,2}$&lt;/span&gt;?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;3) I don't understand the logic behind the other equalities. If someone could explain, that would be great.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;All constraints refer to flow.&#xA;The first constraint says that one unit of flow is sent out from the first node.&#xA;This is analogous to the last constraint, which says that one unit of flow is ultimately arriving at the sixth node.&#xA;Each of the other constraints in the middle refer to a node, from node 2 to node 5.&#xA;On the left-hand side you have arcs incoming to the node, and on the right-hand side you have arcs outgoing from the node.&#xA;Because you want to conserve flow (as much goes in as goes out) you have equality constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine you didn't have these constraints.&#xA;Then a valid solution would be &lt;span class=&quot;math-container&quot;&gt;$X_{12} = 1$&lt;/span&gt; to satisfy the first constraint, &lt;span class=&quot;math-container&quot;&gt;$X_{46} = 1$&lt;/span&gt; to satisfy the last constraint, and all other variables would be equal to zero.&#xA;So the only selected arcs would be &lt;span class=&quot;math-container&quot;&gt;$1 \to 2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$4 \to 6$&lt;/span&gt;.&#xA;This would give you an &quot;artificially cheap&quot; solution: you are not paying for any of the arcs linking node 2 with node 4.&#xA;But one unit of flow cannot disappear at node 2 (after &lt;span class=&quot;math-container&quot;&gt;$1 \to 2$&lt;/span&gt;) and magically appear at node 4 (before &lt;span class=&quot;math-container&quot;&gt;$4 \to 6$&lt;/span&gt;)... it needs to follow a path from 2 to 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now by adding constraint &lt;span class=&quot;math-container&quot;&gt;$X_{23} + X_{24} + X_{25} + X_{26} = X_{12}$&lt;/span&gt; you are forcing one unit of flow to move out from node 2, because &lt;span class=&quot;math-container&quot;&gt;$X_{12} = 1$&lt;/span&gt; will force one of the variables on the left-hand side to take value one.&#xA;For example, if &lt;span class=&quot;math-container&quot;&gt;$X_{24} = 1$&lt;/span&gt;, then you would obtain a feasible solution corresponding to path &lt;span class=&quot;math-container&quot;&gt;$1 \to 2 \to 4 \to 6$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2019-12-26T15:03:43.110" LastActivityDate="2019-12-26T15:03:43.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3242" PostTypeId="2" ParentId="3236" CreationDate="2019-12-26T14:53:46.790" Score="4" Body="&lt;p&gt;EhsanK's answer clearly explains your questions.  My input is to give you a quick way to resolve this issue.  Just think about the marginal cost of &quot;up-sizing&quot; each box demand.  If this costs less than the $1000 fixed cost, it is worthwhile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the No. 3 boxes, the marginal cost is 4 dollars per box to up-size to No. 2 and you need 500 No. 3 boxes, which would cost 2000 dollars total to up-size.  So, it is cheaper to just produce the #3 boxes at size 26.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For box #6, there is a 1 dollar cost to up-size to #5, and you need 400 #6s.  So, this would only cost 400 dollars to up-size, and should be a candidate for doing so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this process is iterative, as you might up-size a box 2 or 3 sizes if the costs are lower.&lt;/p&gt;&#xA;" OwnerUserId="2869" LastActivityDate="2019-12-26T14:53:46.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3243" PostTypeId="2" ParentId="3237" CreationDate="2019-12-26T16:35:59.273" Score="3" Body="&lt;p&gt;Problems solvable using dynamic programming (including the machine replacement problem) could be viewed as shortest path problems, although usually in more than two dimensions (see chapter 2 of &quot;&lt;a href=&quot;https://www.sciencedirect.com/bookseries/mathematics-in-science-and-engineering/vol/130&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Art and Theory of Dynamic Programming&lt;/a&gt;&quot; by Dreyfus and Law for the relevant discussion). Therefore, those problems could also be solved using the mathematical formulation or appropriate algorithms for the shortest path problem.&lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2019-12-26T16:35:59.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3244" PostTypeId="2" ParentId="430" CreationDate="2019-12-26T16:57:49.350" Score="2" Body="&lt;p&gt;Examples of some of the conditions of supply contracts from Hi-Tech industry&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Buy back of  x% of parts supplied if part becomes non-moving&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Buyer (assume buyers company being a cloud company who keeps pacing purchase orders for servers with manufacturers i.e. Tier-1 Supplier) being responsible for part inventory at Tier-1 supplier if Buyer stops placing orders for finished products with Tier-1 supplier or parts become obsolete. Contracts of buyer organization with Tier-2 organization to ensure purchase orders  placed by Tier-1 organization are fulfilled by Tier-2 on time&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Charge back to Suppliers by OEM for parts in case of Warranty returns/defects.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2860" LastActivityDate="2019-12-26T16:57:49.350" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3245" PostTypeId="1" CreationDate="2019-12-27T05:21:06.073" Score="8" ViewCount="560" Body="&lt;p&gt;Anyone have an idea for a disciplined convex programming (DCP) representation of the concave function &lt;span class=&quot;math-container&quot;&gt;$x\sqrt{1-x}$&lt;/span&gt;, which is defined over the domain &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;The Taylor series about &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$$x - \frac{x^2}{2} - \frac{x^3}{8} - \frac{x^4}{16} + O(x^5),$$&lt;/span&gt; which is DCP. However, I'm trying to find a DCP representation for the function itself, preferably.&lt;/p&gt;&#xA;" OwnerUserId="2871" LastEditorUserId="491" LastEditDate="2021-01-12T19:20:51.110" LastActivityDate="2021-01-18T16:41:34.373" Title="Disciplined convex programming representation of $x\sqrt{1-x}$" Tags="|disciplined-convex-programming|convex-optimization|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3246" PostTypeId="2" ParentId="3245" CreationDate="2019-12-27T08:25:32.517" Score="6" Body="&lt;p&gt;I don't think you can represent this as a concave function in the (cvxpy-)DCP sense:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import cvxpy as cp&#xA;x=cp.Variable()&#xA;a=x*cp.sqrt(1-x)&#xA;a.curvature&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'UNKNOWN'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, you can represent it using &lt;a href=&quot;https://www.cvxpy.org/tutorial/dqcp/index.html&quot; rel=&quot;noreferrer&quot;&gt;DQCP (disciplined quasiconvex programming)&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import cvxpy as cp&#xA;x=cp.Variable(pos=True)&#xA;a=x*cp.sqrt(1-x)&#xA;a.curvature&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'QUASICONCAVE'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="886" LastEditorUserId="123" LastEditDate="2019-12-27T11:24:13.140" LastActivityDate="2019-12-27T11:24:13.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3247" PostTypeId="2" ParentId="3245" CreationDate="2019-12-27T10:00:34.917" Score="6" Body="&lt;p&gt;This is possible purely under DCP. As you are interested in the interval &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt;, rewrite your function as &lt;span class=&quot;math-container&quot;&gt;$$x\sqrt{1-x}=\exp\left(\ln x+\frac12\ln(1-x)\right),\quad x\in[0,1].$$&lt;/span&gt; Then the following &lt;a href=&quot;https://repl.it/repls/YearlyGoodApache&quot; rel=&quot;noreferrer&quot;&gt;code&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import cvxpy as cp&#xA;x = cp.Variable()&#xA;y = cp.exp(cp.log(x) + 0.5 * cp.log(1 - x))&#xA;print(&quot;x * sqrt(1 - x) curvature:&quot;, y.curvature)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives &lt;code&gt;QUASICONCAVE&lt;/code&gt; as desired.&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2019-12-27T10:00:34.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3248" PostTypeId="2" ParentId="3245" CreationDate="2019-12-27T16:19:45.330" Score="4" Body="&lt;p&gt;Does this appear in a context in your program such that it can be replaced with a strictly monotonically increasing function of itself? For example, if it is the only term in the objective function, or the only term on the LHS of a &lt;code&gt;LHS &amp;gt;= constant&lt;/code&gt; constraint.&lt;/p&gt;&#xA;&lt;p&gt;If so, this can be handled as a weighted-geometric mean, which actually represents  &lt;span class=&quot;math-container&quot;&gt;$(x\sqrt{1-x})^{2/3}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In CVX (the original DCP tool), this can be done using the geo_mean function, as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin&#xA;variable x&#xA;maximize(geo_mean([x;1-x],1,[2;1]))&#xA;&amp;lt;add any constraints&amp;gt;&#xA;cvx_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Internally, this geo_mean formulation is handled by CVX in a manner similar to @TheSimpliFire 's answer.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;help geo_mean&#xA; geo_mean   Geometric mean.&#xA;    Y=geo_mean(X), where X is a vector, computes the geometrix mean of X. If any&#xA;    of the elements of X are negative, then Y=-Inf. Otherwise, it is equivalent&#xA;    to Y=PROD(X).^(1/LENGTH(X)). All elements must be real.&#xA; &#xA;    For matrices, geo_mean(X) is a row vector containing the geometric means of&#xA;    the columns. For N-D arrays, geo_mean(X) is an array of the geometric means&#xA;    taken along the first non-singleton dimension of X.&#xA; &#xA;    geo_mean(X,DIM) takes the geometric mean along the dimension DIM of X.&#xA; &#xA;    geo_mean(X,DIM,W), where W is a vector of nonnegative integers, computes a&#xA;    weighted geometric mean Y = PROD(X.^W)^(1/SUM(W)). This is more efficient&#xA;    than replicating the values of X W times. Note that W must be a vector,&#xA;    even if X is a matrix, and its length must be the same as SIZE(X,DIM).&#xA; &#xA;    Disciplined convex programming information:&#xA;        geo_mean is concave  and nondecreasing; therefore, when used in CVX&#xA;        specifications, its argument must be concave.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: @Henrik Alsing Friberg's subsequent answer is better than mine. I showed how to represent the stated function to the 2/3 power (which would only be useful in the circumstances I described), whereas he showed how to represent the function as stated in the question.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2021-01-18T16:41:34.373" LastActivityDate="2021-01-18T16:41:34.373" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3249" PostTypeId="1" AcceptedAnswerId="3250" CreationDate="2019-12-27T21:04:23.830" Score="5" ViewCount="1200" Body="&lt;p&gt;Because of excessive pollution on the Momiss River, the&#xA;state of Momiss is going to build pollution control stations.&#xA;Three sites (1, 2, and 3) are under consideration. Momiss is interested in controlling the pollution levels of two pollutants&#xA;(1 and 2). The state legislature requires that at least 80,000&#xA;tons of pollutant 1 and at least 50,000 tons of pollutant 2 be&#xA;removed from the river. The relevant data for this problem&#xA;are shown in Table 10. Formulate an IP to minimize the cost&#xA;of meeting the state legislature’s goals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rn66c.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rn66c.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is from &lt;em&gt;Winston Operations Research Applications and Algorithms 4th edition chapter 9.2 problem 4&lt;/em&gt;&#xA;Here is the solution to the problem(From Chegg solutions):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4gPvE.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4gPvE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sjvva.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sjvva.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing I'm struggling to understand is how did they calculate big M?&lt;/p&gt;&#xA;" OwnerUserId="1117" LastActivityDate="2019-12-27T21:18:58.940" Title="How is Big M calculated?" Tags="|optimization|mixed-integer-programming|integer-programming|big-m|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3250" PostTypeId="2" ParentId="3249" CreationDate="2019-12-27T21:18:58.940" Score="7" Body="&lt;p&gt;There is no incentive to have both &lt;span class=&quot;math-container&quot;&gt;$0.40x_1 &amp;gt; 80000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0.30x_1 &amp;gt; 50000$&lt;/span&gt; because then both of the pollutant removal constraints are oversatisfied, so you can take &lt;span class=&quot;math-container&quot;&gt;$$x_1 \le \max(80000/0.40,50000/0.30) = 200000.$$&lt;/span&gt;  Similarly,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_2 &amp;amp;\le \max(80000/0.25,50000/0.20) = 320000 \\&#xA;x_3 &amp;amp;\le \max(80000/0.20,50000/0.25) = 400000&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-12-27T21:18:58.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3251" PostTypeId="1" AcceptedAnswerId="3253" CreationDate="2019-12-27T21:20:52.073" Score="5" ViewCount="1980" Body="&lt;p&gt;I have the following exercise:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Stockco is considering four investments. Investment 1 will yield a net present value (NPV) of \$16,000; investment 2, an NPV of \$22,000; investment 3, an NPV of \$12,000; and investment 4, an NPV of \$8,000. Each investment requires a certain cash overflow at the present time: investment 1, \$5,000; investment 2, \$7,000; investment 3, \$4,000; and investment 4, \$3,000. Currently, \$14,000 is available for investment. Formulate an IP whose solution will tell Stockco how to maximize the NPV obtained from investments 1-4.&lt;/p&gt;&#xA;&lt;p&gt;As in LP formulations, we begin by defining a variable for each decision that Stockco must make. This leads us to define a 0-1 variable: &lt;span class=&quot;math-container&quot;&gt;$$x_j(j=1,2,3,4)=\begin{cases}1\quad\text{if investment}\,j\,\text{is made}\\0\quad\text{otherwise}.\end{cases}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Suppose we add the following restriction to Example 1 (Stockco):&lt;/p&gt;&#xA;&lt;p&gt;If investments 2 and 3 are chosen, then investment 4 must be chosen. What constraints would be added to the formulation given in the text?&lt;/p&gt;&#xA;&lt;p&gt;The solution is as given below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Condition 2:&lt;/strong&gt; If investments 2 and 3 are chosen, then investment 4 must be chosen. This condition is obtained by the constraint &lt;span class=&quot;math-container&quot;&gt;$x_2+x_3-2x_4\le0$&lt;/span&gt;. If both &lt;span class=&quot;math-container&quot;&gt;$x_2,x_3=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_4$&lt;/span&gt; must be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. Otherwise &lt;span class=&quot;math-container&quot;&gt;$x_4$&lt;/span&gt; may be zero. Hence the condition is satisfied.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Hence the following IP is formulated.&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\max&amp;amp;\quad16x_1+22x_2+12x_3+8x_4\\\text{s.t.}&amp;amp;\quad5x_1+7x_2+4x_3+3x_4&amp;amp;\le14\\&amp;amp;\quad x_2+x_3-2x_4&amp;amp;\le0\\&amp;amp;\quad x_1,x_2,x_3,x_4&amp;amp;\ge0\end{alignat}&lt;/span&gt;&#xA;&lt;strong&gt;My question&lt;/strong&gt;: Is the solution correct? It seems incorrect since it's a &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; are chosen&amp;quot; statement, not a &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and  &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; are chosen&amp;quot; statement. i.e it satisfies for one of them to be chosen for the inequality to be true.&lt;/p&gt;&#xA;" OwnerUserId="1117" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2019-12-28T08:01:23.763" Title="Integer programming problem" Tags="|optimization|mixed-integer-programming|integer-programming|constraint|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3253" PostTypeId="2" ParentId="3251" CreationDate="2019-12-27T21:40:25.300" Score="9" Body="&lt;p&gt;The given constraint is a weak linearization of &lt;span class=&quot;math-container&quot;&gt;$(x_2 \lor x_3)\implies x_4$&lt;/span&gt;, which can be rewritten in conjunctive normal form as &lt;span class=&quot;math-container&quot;&gt;$(\neg x_2 \lor x_4) \land (\neg x_3 \lor x_4)$&lt;/span&gt;, yielding the tighter linearization &lt;span class=&quot;math-container&quot;&gt;$x_2 \le x_4 \land x_3 \le x_4$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wording of the problem seems to instead mean &lt;span class=&quot;math-container&quot;&gt;$(x_2 \land x_3)\implies x_4$&lt;/span&gt;, which can be rewritten in conjunctive normal form as &lt;span class=&quot;math-container&quot;&gt;$\neg x_2 \lor \neg x_3 \lor x_4$&lt;/span&gt;, yielding the linearization &lt;span class=&quot;math-container&quot;&gt;$x_2 +x_3 -1\le x_4$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2019-12-27T21:40:25.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3254" PostTypeId="2" ParentId="3251" CreationDate="2019-12-27T21:42:11.510" Score="7" Body="&lt;p&gt;With &lt;span class=&quot;math-container&quot;&gt;$x_2 + x_3 \le 2x_4$&lt;/span&gt;, you see that &lt;span class=&quot;math-container&quot;&gt;$x_4$&lt;/span&gt; can be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; only if both &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. In any other case, &lt;span class=&quot;math-container&quot;&gt;$x_4=1$&lt;/span&gt;. If you want to enforce a constraint that &quot;&lt;span class=&quot;math-container&quot;&gt;$x_4=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; are both &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;&quot;, then you can have &lt;span class=&quot;math-container&quot;&gt;$x_4 \ge x_2 + x_3 -1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2019-12-27T22:26:36.863" LastActivityDate="2019-12-27T22:26:36.863" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3255" PostTypeId="1" AcceptedAnswerId="3256" CreationDate="2019-12-28T13:45:49.380" Score="8" ViewCount="756" Body="&lt;p&gt;There's a great example &lt;a href=&quot;https://developers.google.com/optimization/routing/tsp&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; of how to find a solution to the travelling salesman problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot;Simple travelling salesman problem between cities.&quot;&quot;&quot;&#xA;&#xA;from __future__ import print_function&#xA;from ortools.constraint_solver import routing_enums_pb2&#xA;from ortools.constraint_solver import pywrapcp&#xA;&#xA;&#xA;&#xA;def create_data_model():&#xA;    &quot;&quot;&quot;Stores the data for the problem.&quot;&quot;&quot;&#xA;    data = {}&#xA;    data['distance_matrix'] = [&#xA;        [0, 2451, 713, 1018, 1631, 1374, 2408, 213, 2571, 875, 1420, 2145, 1972],&#xA;        [2451, 0, 1745, 1524, 831, 1240, 959, 2596, 403, 1589, 1374, 357, 579],&#xA;        [713, 1745, 0, 355, 920, 803, 1737, 851, 1858, 262, 940, 1453, 1260],&#xA;        [1018, 1524, 355, 0, 700, 862, 1395, 1123, 1584, 466, 1056, 1280, 987],&#xA;        [1631, 831, 920, 700, 0, 663, 1021, 1769, 949, 796, 879, 586, 371],&#xA;        [1374, 1240, 803, 862, 663, 0, 1681, 1551, 1765, 547, 225, 887, 999],&#xA;        [2408, 959, 1737, 1395, 1021, 1681, 0, 2493, 678, 1724, 1891, 1114, 701],&#xA;        [213, 2596, 851, 1123, 1769, 1551, 2493, 0, 2699, 1038, 1605, 2300, 2099],&#xA;        [2571, 403, 1858, 1584, 949, 1765, 678, 2699, 0, 1744, 1645, 653, 600],&#xA;        [875, 1589, 262, 466, 796, 547, 1724, 1038, 1744, 0, 679, 1272, 1162],&#xA;        [1420, 1374, 940, 1056, 879, 225, 1891, 1605, 1645, 679, 0, 1017, 1200],&#xA;        [2145, 357, 1453, 1280, 586, 887, 1114, 2300, 653, 1272, 1017, 0, 504],&#xA;        [1972, 579, 1260, 987, 371, 999, 701, 2099, 600, 1162, 1200, 504, 0],&#xA;    ]  # yapf: disable&#xA;    data['num_vehicles'] = 1&#xA;    data['depot'] = 0&#xA;    return data&#xA;&#xA;&#xA;def print_solution(manager, routing, assignment):&#xA;    &quot;&quot;&quot;Prints assignment on console.&quot;&quot;&quot;&#xA;    print('Objective: {} miles'.format(assignment.ObjectiveValue()))&#xA;    index = routing.Start(0)&#xA;    plan_output = 'Route for vehicle 0:\n'&#xA;    route_distance = 0&#xA;    while not routing.IsEnd(index):&#xA;        plan_output += ' {} -&amp;gt;'.format(manager.IndexToNode(index))&#xA;        previous_index = index&#xA;        index = assignment.Value(routing.NextVar(index))&#xA;        route_distance += routing.GetArcCostForVehicle(previous_index, index, 0)&#xA;    plan_output += ' {}\n'.format(manager.IndexToNode(index))&#xA;    print(plan_output)&#xA;    plan_output += 'Route distance: {}miles\n'.format(route_distance)&#xA;&#xA;&#xA;def main():&#xA;    &quot;&quot;&quot;Entry point of the program.&quot;&quot;&quot;&#xA;    # Instantiate the data problem.&#xA;    data = create_data_model()&#xA;&#xA;    # Create the routing index manager.&#xA;    manager = pywrapcp.RoutingIndexManager(len(data['distance_matrix']),&#xA;                                           data['num_vehicles'], data['depot'])&#xA;&#xA;    # Create Routing Model.&#xA;    routing = pywrapcp.RoutingModel(manager)&#xA;&#xA;&#xA;    def distance_callback(from_index, to_index):&#xA;        &quot;&quot;&quot;Returns the distance between the two nodes.&quot;&quot;&quot;&#xA;        # Convert from routing variable Index to distance matrix NodeIndex.&#xA;        from_node = manager.IndexToNode(from_index)&#xA;        to_node = manager.IndexToNode(to_index)&#xA;        return data['distance_matrix'][from_node][to_node]&#xA;&#xA;    transit_callback_index = routing.RegisterTransitCallback(distance_callback)&#xA;&#xA;    # Define cost of each arc.&#xA;    routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)&#xA;&#xA;    # Setting first solution heuristic.&#xA;    search_parameters = pywrapcp.DefaultRoutingSearchParameters()&#xA;    search_parameters.first_solution_strategy = (&#xA;        routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)&#xA;&#xA;    # Solve the problem.&#xA;    assignment = routing.SolveWithParameters(search_parameters)&#xA;&#xA;    # Print solution on console.&#xA;    if assignment:&#xA;        print_solution(manager, routing, assignment)&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It returns&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Objective: 7293 miles&#xA;Route for vehicle 0:&#xA; 0 -&amp;gt; 7 -&amp;gt; 2 -&amp;gt; 3 -&amp;gt; 4 -&amp;gt; 12 -&amp;gt; 6 -&amp;gt; 8 -&amp;gt; 1 -&amp;gt; 11 -&amp;gt; 10 -&amp;gt; 5 -&amp;gt; 9 -&amp;gt; 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to modify the code so that I still start at node &lt;code&gt;0&lt;/code&gt;, but instead of having to visit all the nodes, I only have to visit, say, 5 of them. How can I change the code accordingly? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    manager = pywrapcp.RoutingIndexManager(len(data['distance_matrix']),&#xA;                                           data['num_vehicles'], data['depot'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    manager = pywrapcp.RoutingIndexManager(5,&#xA;                                           data['num_vehicles'], data['depot'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;because I still want to consider all the nodes - I just only want to visit 5 of them.&lt;/p&gt;&#xA;" OwnerUserId="2875" LastActivityDate="2019-12-28T16:48:58.260" Title="Travelling salesman problem with given number of locations to visit" Tags="|optimization|python|or-tools|traveling-salesman|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3256" PostTypeId="2" ParentId="3255" CreationDate="2019-12-28T16:48:58.260" Score="9" Body="&lt;p&gt;Thanks to @Laurent Perron for their answer - I've tried modifying the code as follows, and it appears to work fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from __future__ import print_function&#xA;from ortools.constraint_solver import routing_enums_pb2&#xA;from ortools.constraint_solver import pywrapcp&#xA;&#xA;&#xA;&#xA;def create_data_model():&#xA;    &quot;&quot;&quot;Stores the data for the problem.&quot;&quot;&quot;&#xA;    data = {}&#xA;    data['distance_matrix'] = [&#xA;        [0, 2451, 713, 1018, 1631, 1374, 2408, 213, 2571, 875, 1420, 2145, 1972],&#xA;        [2451, 0, 1745, 1524, 831, 1240, 959, 2596, 403, 1589, 1374, 357, 579],&#xA;        [713, 1745, 0, 355, 920, 803, 1737, 851, 1858, 262, 940, 1453, 1260],&#xA;        [1018, 1524, 355, 0, 700, 862, 1395, 1123, 1584, 466, 1056, 1280, 987],&#xA;        [1631, 831, 920, 700, 0, 663, 1021, 1769, 949, 796, 879, 586, 371],&#xA;        [1374, 1240, 803, 862, 663, 0, 1681, 1551, 1765, 547, 225, 887, 999],&#xA;        [2408, 959, 1737, 1395, 1021, 1681, 0, 2493, 678, 1724, 1891, 1114, 701],&#xA;        [213, 2596, 851, 1123, 1769, 1551, 2493, 0, 2699, 1038, 1605, 2300, 2099],&#xA;        [2571, 403, 1858, 1584, 949, 1765, 678, 2699, 0, 1744, 1645, 653, 600],&#xA;        [875, 1589, 262, 466, 796, 547, 1724, 1038, 1744, 0, 679, 1272, 1162],&#xA;        [1420, 1374, 940, 1056, 879, 225, 1891, 1605, 1645, 679, 0, 1017, 1200],&#xA;        [2145, 357, 1453, 1280, 586, 887, 1114, 2300, 653, 1272, 1017, 0, 504],&#xA;        [1972, 579, 1260, 987, 371, 999, 701, 2099, 600, 1162, 1200, 504, 0],&#xA;    ]  # yapf: disable&#xA;    data['num_vehicles'] = 1&#xA;    data['depot'] = 0&#xA;    data['vehicle_capacities'] = [5]&#xA;    data['demands'] = [1]*13&#xA;    return data&#xA;&#xA;&#xA;def print_solution(data, manager, routing, assignment):&#xA;    &quot;&quot;&quot;Prints assignment on console.&quot;&quot;&quot;&#xA;    total_distance = 0&#xA;    total_load = 0&#xA;    for vehicle_id in range(data['num_vehicles']):&#xA;        index = routing.Start(vehicle_id)&#xA;        plan_output = 'Route for vehicle {}:\n'.format(vehicle_id)&#xA;        route_distance = 0&#xA;        route_load = 0&#xA;        while not routing.IsEnd(index):&#xA;            node_index = manager.IndexToNode(index)&#xA;            route_load += data['demands'][node_index]&#xA;            plan_output += ' {0} Load({1}) -&amp;gt; '.format(node_index, route_load)&#xA;            previous_index = index&#xA;            index = assignment.Value(routing.NextVar(index))&#xA;            route_distance += routing.GetArcCostForVehicle(&#xA;                previous_index, index, vehicle_id)&#xA;        plan_output += ' {0} Load({1})\n'.format(manager.IndexToNode(index),&#xA;                                                 route_load)&#xA;        plan_output += 'Distance of the route: {}m\n'.format(route_distance)&#xA;        plan_output += 'Load of the route: {}\n'.format(route_load)&#xA;        print(plan_output)&#xA;        total_distance += route_distance&#xA;        total_load += route_load&#xA;    print('Total distance of all routes: {}m'.format(total_distance))&#xA;    print('Total load of all routes: {}'.format(total_load))&#xA;&#xA;def main():&#xA;    &quot;&quot;&quot;Entry point of the program.&quot;&quot;&quot;&#xA;    # Instantiate the data problem.&#xA;    data = create_data_model()&#xA;&#xA;    # Create the routing index manager.&#xA;    manager = pywrapcp.RoutingIndexManager(len(data['distance_matrix']),&#xA;                                           data['num_vehicles'], data['depot'])&#xA;&#xA;    # Create Routing Model.&#xA;    routing = pywrapcp.RoutingModel(manager)&#xA;&#xA;    def distance_callback(from_index, to_index):&#xA;        &quot;&quot;&quot;Returns the distance between the two nodes.&quot;&quot;&quot;&#xA;        # Convert from routing variable Index to distance matrix NodeIndex.&#xA;        from_node = manager.IndexToNode(from_index)&#xA;        to_node = manager.IndexToNode(to_index)&#xA;        return data['distance_matrix'][from_node][to_node]&#xA;&#xA;    transit_callback_index = routing.RegisterTransitCallback(distance_callback)&#xA;&#xA;    # Define cost of each arc.&#xA;    routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)&#xA;&#xA;    def demand_callback(from_index):&#xA;        &quot;&quot;&quot;Returns the demand of the node.&quot;&quot;&quot;&#xA;        # Convert from routing variable Index to demands NodeIndex.&#xA;        from_node = manager.IndexToNode(from_index)&#xA;        return data['demands'][from_node]&#xA;&#xA;    demand_callback_index = routing.RegisterUnaryTransitCallback(&#xA;        demand_callback)&#xA;    routing.AddDimensionWithVehicleCapacity(&#xA;        demand_callback_index,&#xA;        0,  # null capacity slack&#xA;        data['vehicle_capacities'],  # vehicle maximum capacities&#xA;        True,  # start cumul to zero&#xA;        'Capacity')&#xA;&#xA;    penalty = 1000&#xA;    for node in range(1, len(data['distance_matrix'])):&#xA;        routing.AddDisjunction([manager.NodeToIndex(node)], penalty)&#xA;&#xA;    # Setting first solution heuristic.&#xA;    search_parameters = pywrapcp.DefaultRoutingSearchParameters()&#xA;    search_parameters.first_solution_strategy = (&#xA;        routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)&#xA;&#xA;    # Solve the problem.&#xA;    assignment = routing.SolveWithParameters(search_parameters)&#xA;&#xA;    # Print solution on console.&#xA;    if assignment:&#xA;        print_solution(data, manager, routing, assignment)&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    main()&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2875" LastActivityDate="2019-12-28T16:48:58.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3257" PostTypeId="2" ParentId="2698" CreationDate="2019-12-28T22:18:11.367" Score="5" Body="&lt;p&gt;This question was also asked and answered &lt;a href=&quot;https://www.ibm.com/developerworks/community/forums/html/topic?id=68510fc5-7a7f-4835-9077-058ae2fdf4f4&quot; rel=&quot;nofollow noreferrer&quot;&gt;on a CPLEX forum&lt;/a&gt; and &lt;a href=&quot;https://orinanobworld.blogspot.com/2012/08/user-cuts-versus-lazy-constraints.html?showComment=1569856835717#c355814014496274523&quot; rel=&quot;nofollow noreferrer&quot;&gt;on my blog&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: The gist of the answer is that when you add a cut in a callback, CPLEX updates the node solution to reflect that cut and then invokes the callback again (still at the same node) to see if you have more cuts to add. To let CPLEX move on to another node, your callback needs to exit without adding another cut. In particular, if you add the same cut each time the callback is invoked at the same node, you will create an indefinite loop.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-03-17T17:27:43.790" LastActivityDate="2021-03-17T17:27:43.790" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3258" PostTypeId="2" ParentId="3226" CreationDate="2019-12-28T23:07:11.630" Score="4" Body="&lt;p&gt;The steps taken from the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.ide.help/OPL_Studio/refoplide/topics/opl_ideref_intell_ed_export_to_cpfile.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;IBM Knowledge Center&lt;/a&gt; are:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Create a new settings file&lt;/li&gt;&#xA;  &lt;li&gt;Change the export format to CPO&lt;/li&gt;&#xA;  &lt;li&gt;Add the settings file to the default run configuration &lt;/li&gt;&#xA;  &lt;li&gt;Run the run configuration&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thanks to @Mark L. Stone who provided the link.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2019-12-28T23:07:11.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3259" PostTypeId="1" CreationDate="2019-12-30T07:07:15.697" Score="14" ViewCount="646" Body="&lt;p&gt;As far as I know, implementing a branch-and-price algorithm is a task far from trivial. However, there are tools such as SCIP or the BCP framework of COIN-OR that help implement such algorithms.&lt;/p&gt;&#xA;&lt;p&gt;I would like to ask you two questions in this regard:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;According to your experience, what is the best alternative to implement a branch-and-price algorithm: using SCIP, the BCP framework of COIN-OR, another tool I am not aware of, or maybe implementing an algorithm from scratch?&lt;/li&gt;&#xA;&lt;li&gt;Can you comment on the advantages and disadvantages of the alternative you recommend? e.g., learning curve, good/bad documentation, the possibility of parallel executions, or availability/lack of methods to improve performance such as dual variable stabilization.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2834" LastEditorUserId="491" LastEditDate="2022-01-10T16:03:23.193" LastActivityDate="2022-01-10T18:59:19.227" Title="Tools to implement branch-and-price algorithms" Tags="|mixed-integer-programming|software|column-generation|branch-and-price|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3260" PostTypeId="1" CreationDate="2019-12-30T17:12:18.227" Score="10" ViewCount="564" Body="&lt;p&gt;I am trying to code a constraint of the form:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i y_i &amp;lt; K\,\text{where}\,\begin{cases}y_i = x_i\quad\text{if}\,x_i&amp;gt;k_i\\0\quad\text{otherwise}.\end{cases}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, I want to constrain the sum of &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; (only) for those &lt;span class=&quot;math-container&quot;&gt;$x_i&amp;gt;k_i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$k_i$&lt;/span&gt; are fixed and all positive, and &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are free and all positive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this is a straightforward MIP, but wondering if it can be coded in LP.  I can't show it's not convex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2564" LastEditorUserId="123" LastEditDate="2019-12-30T20:20:30.943" LastActivityDate="2019-12-30T20:20:30.943" Title="LP sum of variables that are above a threshold" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3263" PostTypeId="2" ParentId="3260" CreationDate="2019-12-30T18:38:41.620" Score="10" Body="&lt;p&gt;The constraint is not convex, and cannot be formulated as a pure LP. You will have to resort to a MIP model.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Why it is not convex&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As an example, consider the case where : &lt;span class=&quot;math-container&quot;&gt;$K = 2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$k_1 = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$k_2 = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution where &lt;span class=&quot;math-container&quot;&gt;$x_1 = 1.8$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2 = 0.8$&lt;/span&gt; gives &lt;span class=&quot;math-container&quot;&gt;$y_1 = 1.8$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2 = 0$&lt;/span&gt;, and is valid. The symmetric solution with &lt;span class=&quot;math-container&quot;&gt;$x_1 = 0.8$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2 = 1.8$&lt;/span&gt; is valid as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But their average is &lt;span class=&quot;math-container&quot;&gt;$x_1 = 1.3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2 = 1.3$&lt;/span&gt;. This gives &lt;span class=&quot;math-container&quot;&gt;$y_1 = 1.3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2 = 1.3$&lt;/span&gt;, where the constraint is violated. Hence the feasible set has a hole: it is not convex.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;A possible MIP formulation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It is possible to formulate this constraint as a MIP by adding boolean variables &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. For example, using the big-M method (with &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; chosen to be bigger than the range of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}y &amp;amp;\geq x - Mb\\b &amp;amp;\leq (k-x)/M + 1\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="123" LastEditDate="2019-12-30T20:17:56.867" LastActivityDate="2019-12-30T20:17:56.867" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3265" PostTypeId="1" AcceptedAnswerId="3266" CreationDate="2019-12-31T04:04:01.977" Score="8" ViewCount="598" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I am going to buy a family car at the beginning of the New Year. I am going to stay in the UK&#xA;  for the next 4 years. I am considering the possibility of being a customer of company A which&#xA;  sells BMW models. Not only I can buy a car from this company but I can also trade in my car&#xA;  at this company and have my car serviced by the company. Company A gives a warranty that&#xA;  the annual maintenance costs and trade-in prices will remain the same for the next 4 years.&#xA;  They are: &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{cc}\hline\text{Age of Car}&amp;amp;\text{Annual Maintenance}&amp;amp;\text{Trade-in Price at the}\\&amp;amp;\text{Cost}&amp;amp;\text{end of the period}\\\hline0&amp;amp;{\it\unicode{xA3}}2,000&amp;amp;{\it\unicode{xA3}}6,000\\1&amp;amp;{\it\unicode{xA3}}4,000&amp;amp;{\it\unicode{xA3}}5,000\\2&amp;amp;{\it\unicode{xA3}}6,000&amp;amp;{\it\unicode{xA3}}4,000\\3&amp;amp;{\it\unicode{xA3}}7,000&amp;amp;{\it\unicode{xA3}}2,000\\\hline\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;a) Suppose that I can buy a new car at £12000, a price which is fixed for the next 4 years.&#xA;  What strategy should I choose to minimize the net cost (purchasing costs + maintenance&#xA;  costs - money received in trade-ins) incurred during the next four years? Given the optimal&#xA;  strategy found, do I have to solve the problem again if the company changes the price from&#xA;  £12000 to £&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; before I buy a car?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution to a)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/07iYd.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/07iYd.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Could somebody please explain how do they get the values in the first table? Isn't the cost for using a car for 1 year supposed to be &lt;span class=&quot;math-container&quot;&gt;$2000+4000$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1117" LastEditorUserId="196" LastEditDate="2019-12-31T06:39:13.687" LastActivityDate="2019-12-31T06:40:41.080" Title="Dynamic programming example" Tags="|dynamic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3266" PostTypeId="2" ParentId="3265" CreationDate="2019-12-31T06:34:38.133" Score="6" Body="&lt;p&gt;The &quot;cost&quot; values in the lower left table are calculated as the sum of the cost of buying the car (&lt;span class=&quot;math-container&quot;&gt;$12000$&lt;/span&gt;), plus the total maintenance cost of each year of owning the car, minus the trade in cost after the specified number of years has elapsed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the total cost of owning the car for one year is &lt;span class=&quot;math-container&quot;&gt;$12000$&lt;/span&gt; (price of car) &lt;span class=&quot;math-container&quot;&gt;$+$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$2000$&lt;/span&gt; (maintenance cost during year &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;) &lt;span class=&quot;math-container&quot;&gt;$-$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$6000$&lt;/span&gt; (the value of the car at the end of period &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, i.e., after &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; year) &lt;span class=&quot;math-container&quot;&gt;$= 8000$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, the total cost of owning the car for two years is &lt;span class=&quot;math-container&quot;&gt;$12000$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$+$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$2000$&lt;/span&gt; (maintenance cost during year &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;) &lt;span class=&quot;math-container&quot;&gt;$+$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$4000$&lt;/span&gt; (maintenance cost during year &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;) &lt;span class=&quot;math-container&quot;&gt;$-$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$5000$&lt;/span&gt; (value of the car at the end of period &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, i.e., after the second year) &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$13000$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="196" LastEditorUserId="196" LastEditDate="2019-12-31T06:40:41.080" LastActivityDate="2019-12-31T06:40:41.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3267" PostTypeId="1" AcceptedAnswerId="3268" CreationDate="2020-01-01T01:41:57.210" Score="8" ViewCount="309" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WhR3X.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WhR3X.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my textbook, to generate cutting planes, they tell you to proceed as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A procedure for generating cutting planes:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;&lt;p&gt;Select a (&lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt;) constraint that has only nonnegative coefficients.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Find a group of variables such that&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;  &#xA;  &lt;p&gt;a) The constraint is violated when all variables in the group equals 1&#xA;  and the remaining variables equal to 0.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;b) But the constraint is satisfied if any one of the variables in the&#xA;  group is changed from 1 to 0.&lt;/p&gt;&#xA;  &#xA;  &lt;ol start=&quot;3&quot;&gt;&#xA;  &lt;li&gt;Suppose there are &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; variables in the group add the following&#xA;  constraint as a new cutting plane:&#xA;  Sum of variables in the group &lt;span class=&quot;math-container&quot;&gt;$\le  − 1$&lt;/span&gt;&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; Why isn't &lt;span class=&quot;math-container&quot;&gt;$x_2+x_3+x_4\le 2$&lt;/span&gt; a cutting plane? Since if we go by 2a) , and put &lt;span class=&quot;math-container&quot;&gt;$x_2=1 , x_3=1 , x_4=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_1=0$&lt;/span&gt; , then it violates the inequality? Since &lt;span class=&quot;math-container&quot;&gt;$11&amp;gt;7$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="1117" LastEditorUserId="500" LastEditDate="2020-01-01T02:44:23.693" LastActivityDate="2020-01-01T02:44:23.693" Title="Why isn't $x_2+x_3+x_4\le 2$ a cutting plane?" Tags="|branch-and-cut|cutting-planes|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3268" PostTypeId="2" ParentId="3267" CreationDate="2020-01-01T01:51:04.280" Score="13" Body="&lt;p&gt;It is a cutting plane, but it is implied by &lt;span class=&quot;math-container&quot;&gt;$x_2+x_4\le 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3\le 1$&lt;/span&gt; so not very useful.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-01-01T01:51:04.280" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3269" PostTypeId="1" AcceptedAnswerId="3270" CreationDate="2020-01-01T16:46:54.877" Score="5" ViewCount="580" Body="&lt;p&gt;I have a very simple problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{align*}&#xA;\begin{array}{ll}&#xA;\min\limits_{x_1,x_2} &amp;amp; -x_1x_2 \\&#xA;\text{s.t.} &amp;amp; x_1 + x_2 - 2 = 0.&#xA;\end{array}&#xA;\end{align*} $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The KKT system gives me &lt;span class=&quot;math-container&quot;&gt;$x_1^* = x_2^* = \lambda^* = 1$&lt;/span&gt; where the &lt;span class=&quot;math-container&quot;&gt;$*$&lt;/span&gt; denotes the KKT solution and &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is the Lagrangian variable. The point &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2 =  (1,1)$&lt;/span&gt; is the &lt;strong&gt;only&lt;/strong&gt; solution to the KKT system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I need to answer:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Show that this point is a constrained local minimizer. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My idea is that, since there is a single equality constraint with a nonzero gradient, there is no irregular point. Hence, the KKT system includes all of the local minimizers. Since there is one solution, this is the local and global minimizer of the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think my answer is correct. But, I have a hesitation here, what if this solution was a local maximum? Can it be the case? We know that when the problem is not convex the KKT system returns all the stationary points, and maybe &lt;span class=&quot;math-container&quot;&gt;$(1,1)$&lt;/span&gt; is not the minimizer (I know it is but I am wondering conceptually). What is the cleanest way to show that &lt;span class=&quot;math-container&quot;&gt;$(1,1)$&lt;/span&gt; is a local minimizer &lt;strong&gt;without substituting &lt;span class=&quot;math-container&quot;&gt;$x_1 = 2 - x_2$&lt;/span&gt;&lt;/strong&gt;?&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="123" LastEditDate="2020-01-01T19:13:07.010" LastActivityDate="2020-01-01T19:19:35.373" Title="Single KKT solution for a simple problem: proof of being minimizer" Tags="|constraint|kkt-conditions|local-minimum|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3270" PostTypeId="2" ParentId="3269" CreationDate="2020-01-01T17:20:13.357" Score="6" Body="&lt;p&gt;You have shown that KKT is necessary for a local minimum. Also that it is necessary for a local maximum. But you have not shown that a local minimum or local maximum exists. Indeed, there is no local maximum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is the KKT point you found a local minimum? That is what 2nd order conditions can assess. The 2nd order (KKT) sufficiency conditions (whose requisite applicability conditions are met - I leave the details to you) for a strict local minimum are that the projection of the Hessian of the Lagrangian into the nullspace of the Jacobian of the active constraints is positive definite. Because there are no nonlinear constraints, the Hessian of the Lagrangian is the Hessian of the objective function. There is only one constraint, and it is active. If &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; is a basis for the nullspace of the Jacobian of the active constraint, then the projection of the Hessian, &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;, of the objective function into the nullspace of the Jacobian of active constraints is &lt;span class=&quot;math-container&quot;&gt;$Z^\top HZ$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any non-zero multiple of the column vector &lt;span class=&quot;math-container&quot;&gt;$\begin{bmatrix}-1&amp;amp;1\end{bmatrix}^\top$&lt;/span&gt; is a basis for the nullspace of the active constraint &lt;span class=&quot;math-container&quot;&gt;$x_1 + x_2 -2 = 0$&lt;/span&gt;.  Putting it all together, we see that &lt;span class=&quot;math-container&quot;&gt;$Z^\top HZ$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$1\times1$&lt;/span&gt; matrix &lt;span class=&quot;math-container&quot;&gt;$\begin{bmatrix}2\end{bmatrix}$&lt;/span&gt; (or any positive multiple of it), and so is positive definite, completing the proof.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, this winds up being a long-winded way of essentially substituting out one of the variables and seeing that the resulting problem is an unconstrained strictly convex quadratic problem. But the method I outlined is much more general.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-01-01T19:19:35.373" LastActivityDate="2020-01-01T19:19:35.373" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3271" PostTypeId="1" CreationDate="2020-01-02T14:43:11.513" Score="26" ViewCount="655" Body="&lt;p&gt;For many operations research applications a user will often be in charge of making the final decision and will use the optimization algorithms software as a part of their planning flow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, optimization software often needs a user interface that allows the user to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Input data required to do the optimization e.g. required demands and available resources that the optimizer should take into account&lt;/li&gt;&#xA;&lt;li&gt;Give priorities to different objectives e.g. making a trade-off between reducing cost and increasing the service levels for customers. &lt;/li&gt;&#xA;&lt;li&gt;Validate the resulting plan to ensure it is operationally feasible and look for potential improvements&lt;/li&gt;&#xA;&lt;li&gt;Iterate on the plan, e.g. based on the optimized solution they might realize they forgot to add a constraint and don't want to start the optimization from scratch again.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Often, a planner will not have an operations research background and the software needs to be easy and intuitive so the user (and organization) will capture the value from the optimization algorithms. I am, therefore, very interested in:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What are examples of optimization software with an excellent and intuitive user interface? (screenshots would be great)&lt;/li&gt;&#xA;&lt;li&gt;Are there some good principles to use when building the user interface? &lt;/li&gt;&#xA;&lt;li&gt;Are there any research papers addressing this issue?&lt;/li&gt;&#xA;&lt;li&gt;To formulate it slightly differently: How can we design optimization applications that are as simple and powerful as an IPhone, to allow more people to get value out of optimization?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt; &#xA;A simple user interface for a GPS that allows the user to change between different objectives (speed vs. fuel) and constraints (walking vs. highways)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/2cbyc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2cbyc.png&quot; alt=&quot;GPS&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="140" LastEditorUserId="140" LastEditDate="2020-01-08T20:48:51.850" LastActivityDate="2020-01-11T03:16:42.630" Title="What are best practices to make optimization user interfaces intuitive for the user?" Tags="|reference-request|user-experience|practical-or|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3272" PostTypeId="1" CreationDate="2020-01-02T20:28:42.577" Score="9" ViewCount="100" Body="&lt;p&gt;I am solving a scheduling problem-to find shifts and task schedules- using column generation. In essence, it is a set covering problem with additional constraints. The problem seems to be that the duals used to find task schedule columns do not provide much information regarding shifts schedules, e.g., tasks are scheduled in periods where shifts coverage is not allowed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to heuristically adjust the duals in such a way that information such as shifts coverage is incorporated in the reduced cost and thus used when finding new task schedule columns? How can we find &quot;better&quot; duals?&lt;/p&gt;&#xA;" OwnerUserId="2489" LastEditorUserId="2489" LastEditDate="2020-01-02T20:47:24.630" LastActivityDate="2020-01-02T20:47:24.630" Title="Adjusting duals heuristically" Tags="|column-generation|set-covering|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3273" PostTypeId="2" ParentId="3245" CreationDate="2020-01-03T13:05:12.647" Score="7" Body="&lt;p&gt;I think in convex functions and epigraphs, so I hope you don't mind me deriving a DCP representation of the inequality&#xA;&lt;span class=&quot;math-container&quot;&gt;$$t \geq -x \sqrt{1-x},$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;on &lt;span class=&quot;math-container&quot;&gt;$x \in (-∞, 1]$&lt;/span&gt;, which I rewrite to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$t \geq (1-x) \sqrt{1-x} - \sqrt{1-x} = r^{3/2} - r^{1/2},\quad r = 1-x \geq 0.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should now be easy to input into your DCP framework. In &lt;a href=&quot;https://mosek.com&quot; rel=&quot;noreferrer&quot;&gt;MOSEK&lt;/a&gt;, it could be represented using two &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/powo.html#powers&quot; rel=&quot;noreferrer&quot;&gt;power cones&lt;/a&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ t \geq p - q,\quad p \geq |r|^{3/2},\quad |q| \leq \sqrt{r}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2020-01-03T13:10:33.640" LastActivityDate="2020-01-03T13:10:33.640" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3275" PostTypeId="2" ParentId="3271" CreationDate="2020-01-04T07:56:22.650" Score="6" Body="&lt;p&gt;I think it's a bit of general question. AFAIK, this subject can be surveyed in many aspects. Designing of an optimization software depends on its specific and related field. For example, architecting and developing of the mathematical programming software like CPLEX or Gurobi is quite different from developing navigation software. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on what problem you are trying to optimize and propose to develop its software solution, you might need to determine which kind of algorithms (exact or (meta)heuristic) could be applied.  It may affect your software architecting, Specifically, on the software development and services level price. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To users/clients, it is so important to use the software easy and flexible. As you said, clients may not have any experience or educational background about that. It's about, input data, easy modifying, easy adjusting, flexible output based on what clients looking for and finally, having a nice user interface would be attractive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I am interested in planning and scheduling, specifically in industries and real situation, I try representing two optimization software (Indeed, I am aware many examples could be represented by others.). One, based on academic works and the other commercial software:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;based on academic work: LAKIN&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It was developed by &lt;a href=&quot;http://web-static.stern.nyu.edu/om/software/lekin/&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;Prof. Michael Pinedo and his team at the Stern School of Business, NYU&lt;/strong&gt;&lt;/a&gt;. It has a nice interface and using some rules and heuristics to solve the scheduling problems. It enables users to modify and adjust planning after solving the model and easily reoptimize the problem. I really enjoy it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TGqo4.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TGqo4.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Commercial: (Disclaimer: this is to introduce for academic.)&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Much commercial software could be applied in practice but, I would like to represent a simulation software, ARENA. It has a flowchart interface which clients can use it easily. It has many specific features to modify and reoptimize the model. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IlkxY.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IlkxY.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;It would be considered, Developing an optimization software may fail. One of the nice topics could be found &lt;a href=&quot;https://or.stackexchange.com/questions/2953/what-are-the-reasons-or-industry-projects-fail&quot;&gt;here on or.stackexchange&lt;/a&gt;.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, there are many academic and practical papers on the commercial software host like &lt;a href=&quot;https://www.gurobi.com/resources/?category-filter=case-study&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; or &lt;a href=&quot;https://www.arenasimulation.com/industry-solutions/case-studies/logistics-simulation-software&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; to use and benchmark.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2020-01-04T09:39:24.117" LastActivityDate="2020-01-04T09:39:24.117" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3276" PostTypeId="1" CreationDate="2020-01-04T11:50:13.263" Score="8" ViewCount="191" Body="&lt;p&gt;I am minimizing &lt;span class=&quot;math-container&quot;&gt;$f(x_1,x_2) = 100(x_2-x_1^2)^2  + (1-x_1)^2$&lt;/span&gt;, where I try many algorithms to compare with each other. All of the algorithms find the optimal solution &lt;span class=&quot;math-container&quot;&gt;$(1,1)$&lt;/span&gt; quickly, so I am not bothered with asymptotics right now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x = (x_1,x_2)^\top$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; define the optimal solution. We know that &lt;span class=&quot;math-container&quot;&gt;$\epsilon= \|x_k - x^*\|$&lt;/span&gt; is the error of iteration &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; compared to the optimal solution, and in convergence we are usually interested in the relation between &lt;span class=&quot;math-container&quot;&gt;$\epsilon_k, \epsilon_{k+1}$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is very simple. Which one is the best option here, to plot &lt;span class=&quot;math-container&quot;&gt;$\dfrac{\epsilon_{k+1}}{\epsilon_{k}}$&lt;/span&gt; for each algorithm, or to plot &lt;span class=&quot;math-container&quot;&gt;$\epsilon_{k+1} - \epsilon_{k}$&lt;/span&gt;? The first one is usually studied in asymptotic convergence, so I'm not sure whether it really makes sense for my simple Rosenbrock minimization.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="123" LastEditDate="2020-01-04T13:22:09.847" LastActivityDate="2020-01-07T08:30:01.540" Title="Speed of convergence for minimizing Rosenbrock's function" Tags="|optimization|algorithms|unconstrained-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3278" PostTypeId="1" AcceptedAnswerId="3287" CreationDate="2020-01-04T20:53:51.223" Score="9" ViewCount="99" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$c \in \mathbb{R}^n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M \subseteq \mathbb{R}^n$&lt;/span&gt; such that the problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}P:\quad\min_{x \in \mathbb{R}^n}&amp;amp;\quad c^\intercal x\\\textrm{s.t.}&amp;amp;\quad x \in M\end{align}&lt;/span&gt; is solvable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a subset &lt;span class=&quot;math-container&quot;&gt;$X \subseteq M$&lt;/span&gt; is &lt;em&gt;nonempty&lt;/em&gt;, &lt;em&gt;closed&lt;/em&gt; and &lt;em&gt;convex&lt;/em&gt;, does it follow that the subproblem &lt;span class=&quot;math-container&quot;&gt;\begin{align}P:\quad\min_{x \in \mathbb{R}^n}&amp;amp;\quad c^\intercal x\\\textrm{s.t.}&amp;amp;\quad x \in X\end{align}&lt;/span&gt; is also solvable?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Thoughts:&lt;/strong&gt; I know this is not true if &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is only assumed to be closed: an epigraph reformulation of &lt;a href=&quot;https://math.stackexchange.com/a/2389106/369800&quot;&gt;this&lt;/a&gt; is a counterexample.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By &lt;em&gt;solvable&lt;/em&gt; I mean that the problem is feasible and the infimum is achieved.&lt;/p&gt;&#xA;" OwnerUserId="2868" LastEditorUserId="2868" LastEditDate="2020-01-05T20:13:19.250" LastActivityDate="2020-01-05T21:14:10.187" Title="Problem solvable $\Rightarrow$ subproblems solvable if feasible region closed, convex?" Tags="|optimization|convexity|global-optimality|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3279" PostTypeId="1" CreationDate="2020-01-05T01:02:27.360" Score="5" ViewCount="2158" Body="&lt;p&gt;I work almost exclusively in R and Rstudio, and have found it to be an excellent ecosystem for data analysis and OR, including discrete event simulation, Monte Carlo simulation, MILP, and the Traveling Salesman Problem. The ONLY gap I see is, no library for the Vehicle Routing Problem and variants. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anybody know of a VRP package in R?  I may need to undertake writing functions implementing VRP if I can't find a ready package.&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="491" LastEditDate="2020-01-06T11:43:09.953" LastActivityDate="2021-11-01T12:48:24.160" Title="VRP package for R" Tags="|vehicle-routing|r|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3280" PostTypeId="2" ParentId="3271" CreationDate="2020-01-05T05:05:45.610" Score="5" Body="&lt;p&gt;You mentioned: &quot;Often, a planner will not have an operations research background and the software needs to be easy and intuitive so the user (and organization)...&quot;. So, I assume by optimization software you mean software with an OR algorithm in the background for an end-user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I include two screenshots from some searches. I got the screenshots from their videos and I have not tested any of these myself. But their videos looked to have intuitive user-interface and I don't think it's very hard for someone to get a demo of them.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A &lt;a href=&quot;https://www.easycargo3d.com/en/&quot; rel=&quot;noreferrer&quot;&gt;container loading software&lt;/a&gt; that one can assume should be based on solutions of (3D) bin packing problems:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/TqKdf.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TqKdf.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;A &lt;a href=&quot;https://www.youtube.com/watch?v=1x2xVfPxuLA&quot; rel=&quot;noreferrer&quot;&gt;routing app&lt;/a&gt;:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7d42d.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7d42d.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And in regards to good principles to use when building the user interface: you mentioned the right keywords yourself &quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Principles_of_user_interface_design&quot; rel=&quot;noreferrer&quot;&gt;principles of user interface design&lt;/a&gt;&quot; or &quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/User_interface_design&quot; rel=&quot;noreferrer&quot;&gt;user interface design&lt;/a&gt;&quot;. These are just Wikipedia links, but there are many great Youtube videos that talk about these design principles in action (for example, check Apple videos on Youtube).&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2020-01-05T05:05:45.610" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3281" PostTypeId="2" ParentId="3279" CreationDate="2020-01-05T09:28:47.597" Score="6" Body="&lt;p&gt;The package &lt;a href=&quot;https://www.rdocumentation.org/packages/netgen/versions/1.3&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;netgen&lt;/code&gt;&lt;/a&gt; (v1.3) can be used to generate networks and benchmark instances of VRP and TSP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://www.linkedin.com/pulse/r-shiny-application-capacitated-vehicle-routing-problem-shevade&quot; rel=&quot;noreferrer&quot;&gt;this article&lt;/a&gt; shows it is also possible to solve a variant of VRP (CVRP) in R Shiny, which is another package used for interactive modelling/applications.&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2020-01-05T09:28:47.597" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3282" PostTypeId="1" AcceptedAnswerId="4721" CreationDate="2020-01-05T10:52:09.687" Score="12" ViewCount="312" Body="&lt;p&gt;I am looking for ways or tips to connect a solver with the JuMP package. I started reading the manual of Math Opt Interface — I don't know the right terms, but I'll call it the backend of JuMP. Also, I am trying to understand the codes of a solver fully written in Julia that has this connection with JuMP, but I still don't know if it's a good way to learn how to do it and I'm having trouble understanding some parts of the code. I think it will take much time if I continue like this.&lt;/p&gt;&#xA;" OwnerUserId="2900" LastEditorUserId="8" LastEditDate="2022-12-26T22:07:00.563" LastActivityDate="2022-12-26T22:07:00.563" Title="Connection between solver and Julia's JuMP" Tags="|solver|julia|jump|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3284" PostTypeId="1" CreationDate="2020-01-05T13:33:53.053" Score="0" ViewCount="194" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/s1wkH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/s1wkH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jYuYR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jYuYR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone please explain what is the point of this added cut? Also how was it deduced? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone please give some examples of this sort? As I've been searching for such examples but did not find any on the internet.&lt;/p&gt;&#xA;" OwnerUserId="1117" LastActivityDate="2020-01-05T13:33:53.053" Title="Branch and Cut algorithm" Tags="|branch-and-cut|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3285" PostTypeId="1" CreationDate="2020-01-05T14:14:29.223" Score="8" ViewCount="284" Body="&lt;p&gt;I have a regular grid of cells, maybe square, maybe hexagonal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each cell has a numeric value associated with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I find a subset of cells that are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a connected, compact set and&lt;/li&gt;&#xA;&lt;li&gt;have an optimally high sum of values and&lt;/li&gt;&#xA;&lt;li&gt;made of a number &lt;em&gt;n&lt;/em&gt; cells&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;using OR methods or models?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/on8Mm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/on8Mm.png&quot; alt=&quot;example of grid with value labels&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2901" LastEditorUserId="2901" LastEditDate="2020-01-05T17:06:00.207" LastActivityDate="2020-01-05T17:06:00.207" Title="Finding the optimal, spatially compact set of grid cells" Tags="|optimization|mixed-integer-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3286" PostTypeId="2" ParentId="3285" CreationDate="2020-01-05T14:59:22.933" Score="5" Body="&lt;p&gt;This problem occurs, in particular, as a subproblem is districting problems. You can represent your problem as a node weighted graph, where there is a node for each cell that receives the respective weight. Then you look for a maximum weight connected subgraph with compactness constraints. The (spatial) compactess is a huge topic in itself and you may find hints when looking into the political districting literature.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="123" LastEditDate="2020-01-05T16:50:18.830" LastActivityDate="2020-01-05T16:50:18.830" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3287" PostTypeId="2" ParentId="3278" CreationDate="2020-01-05T17:24:59.230" Score="8" Body="&lt;p&gt;In your question, you call a problem 'solvable' if there exists an &lt;span class=&quot;math-container&quot;&gt;$\hat{x} \in M$&lt;/span&gt; such that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}c^\top\hat{x} = \inf_{x \in \mathbb{R}^n}&amp;amp;\quad c^\intercal x\\\textrm{s.t.}&amp;amp;\quad x \in M.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following example shows that the answer to your question is &lt;em&gt;no&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$n = 2$&lt;/span&gt; and take &lt;span class=&quot;math-container&quot;&gt;$c = (0,1)^\top$&lt;/span&gt;. Furthermore, let &lt;span class=&quot;math-container&quot;&gt;$$M = \{x \in \mathbb{R}^2 ~\vert~ x_2 \ge 0\}$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$X = \{x \in \mathbb{R}^2 ~\vert~ x_2 \ge e^{x_1}\}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that indeed &lt;span class=&quot;math-container&quot;&gt;$X \subseteq M$&lt;/span&gt;, because &lt;span class=&quot;math-container&quot;&gt;$x_2 \ge e^{x_1}$&lt;/span&gt; implies that &lt;span class=&quot;math-container&quot;&gt;$x_2 \ge 0$&lt;/span&gt;. Furthermore, it is easy to verify that &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is closed and convex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The minimization problem over &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is given by&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\inf_{x \in \mathbb{R}^2}&amp;amp;\quad x_2\\\textrm{s.t.}&amp;amp;\quad x_2 \ge 0.\end{align}&lt;/span&gt;&#xA;Clearly, the minimum is attained by &lt;span class=&quot;math-container&quot;&gt;$\hat{x} = (0,0)^\top$&lt;/span&gt;, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the other optimization problem, we have&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\inf_{x \in \mathbb{R}^2}&amp;amp;\quad x_2\\\textrm{s.t.}&amp;amp;\quad x_2 \ge e^{x_1}.\end{align}&lt;/span&gt;&#xA;The infimum is equal to zero, which results from taking the limit &lt;span class=&quot;math-container&quot;&gt;$x_1 \rightarrow -\infty$&lt;/span&gt; and setting &lt;span class=&quot;math-container&quot;&gt;$x_2 = e^{x_1}$&lt;/span&gt;. However, this value cannot be attained by any &lt;span class=&quot;math-container&quot;&gt;$\hat{x} \in X$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Final note: if you additionally assume that &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is bounded (or &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is bounded), then the &lt;a href=&quot;https://en.wikipedia.org/wiki/Extreme_value_theorem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Weierstrass theorem&lt;/a&gt; ensures that the minimum can be attained. No convexity is necessary.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2020-01-05T21:14:10.187" LastActivityDate="2020-01-05T21:14:10.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3288" PostTypeId="1" AcceptedAnswerId="3289" CreationDate="2020-01-07T01:09:18.450" Score="16" ViewCount="5097" Body="&lt;p&gt;Branch and Bound (B&amp;amp;B) is a general solution approach to solve combinatorial optimisation problems. I was wondering how B&amp;amp;B is implemented in practice. Although it may be relevant, but I am not looking for an explanation of why/how B&amp;amp;B works. Instead, I am interested in learning how this is normally implemented in a programming language (Python, Java, C++ etc), what data structures are better to use and why. Any information regarding the standard practice is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2020-05-28T18:14:39.127" Title="Branch and Bound Implementation" Tags="|branch-and-bound|implementation|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3289" PostTypeId="2" ParentId="3288" CreationDate="2020-01-07T05:38:23.657" Score="21" Body="&lt;p&gt;Read the &lt;a href=&quot;https://depositonce.tu-berlin.de/handle/11303/1931&quot; rel=&quot;noreferrer&quot;&gt;ph.d. thesis&lt;/a&gt; of Tobias Achterberg where he describes the solver Scip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have fun.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="500" LastEditDate="2020-05-28T16:21:59.160" LastActivityDate="2020-05-28T16:21:59.160" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3290" PostTypeId="2" ParentId="3288" CreationDate="2020-01-07T07:28:34.473" Score="10" Body="&lt;p&gt;Check &lt;a href=&quot;https://github.com/coin-or/CHiPPS-ALPS&quot; rel=&quot;noreferrer&quot;&gt;COIN-OR ALPS code&lt;/a&gt; (in C++) and &lt;a href=&quot;https://coral.ie.lehigh.edu/~ted/files/papers/YanXuDissertation07.pdf&quot; rel=&quot;noreferrer&quot;&gt;Yan Xu's dissertation&lt;/a&gt; for explanation. He explains a scalable parallel branch and bound algorithm and presents experiments solving Knapsack instances with up to 2048 cores. You can ignore the parallelization related parts in code and the text if not interested.&lt;/p&gt;&#xA;" OwnerUserId="2904" LastActivityDate="2020-01-07T07:28:34.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3291" PostTypeId="2" ParentId="3288" CreationDate="2020-01-07T07:41:44.583" Score="10" Body="&lt;p&gt;What makes any branch-and-bound implementation tick is the heuristics that accompany the algorithm, not branch-and-bound itself. I start by explaining branch-and-bound to frame why we need the heuristics, but if you are interested in implementation, you can skip to the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why branch-and-bound works&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For simplicity I will assume bisection branch and bound on a single variable, i.e., each branching action creates two new nodes the union of which is equivalent to the parent domain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now let's also assume that all our variables are binary. If the problem has a feasible solution, there is at least one binary combination which yields the best objective value. To prove global optimality, we need to not only locate this combination, but also to prove that no better solution exists anywhere else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we start fixing variables successively through branching, the result is a binary tree where each leaf node represents a unique variable combination. For a full binary problem that's &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; combinations (btw for continuous branch-and-bound that's actually infinity), which is also the worst-case complexity in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Branch-and-bound is a heuristic method  that allows us to prove global optimality (or to simply find a feasible solution) without necessarily having to create and explore all &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; nodes. This is possible if we have two things: the ability to derive rigorous bounds on the value of the objective function after each branching action, and a feasible solution to the actual problem. Using those two pieces of information we can eliminate a massive number of nodes from the search because, through the bounds, we can prove that certain binary combinations cannot possibly give us a better objective than the feasible solution we already have. Crucially, this also means that we need good enough primal heuristics to find feasible solutions for branch-and-bound to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Overall, this is amazing, because with good primal and acceleration heuristics, it is possible to achieve polynomial (or even almost linear in some cases) average runtime complexity. This beats the alternative, which is to always explore exponentially many nodes. The counterpoint is that, without good heuristics, branch-and-bound can take centuries to converge instead of seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;W.r.t. data structures, it doesn't really matter to be honest, because the cost of managing the tree is insignificant compared to the cost of everything else in a branch-and-bound algorithm, especially in C++. You will only see the cost of sorting or inserting nodes if you are solving 1-2 variable problems, and even then it will be very small.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is interesting instead is the spatial complexity of tree management. If we have, say, 1m variables, the naive way is to copy the bounds of all variables to represent each new node created. That's a lot of memory. Instead many implementations (e.g., MINOTAUR), represent each node as a modification compared to its parent (kinda like Git). This means that instead of storing 2m new values, we only need to store 2. The drawback of course is slower lookup speed to retrieve all bounds for each node, but as I mentioned earlier that's not really significant in the grand scheme of things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Professional tip: we typically use more than one data structure to store information in a high performance solver, and switch between structures on the fly when a structure starts scaling badly (similar to the small string optimisation in C++). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Heuristics-wise there are literally thousands. The most important by far are domain reduction methods, followed by branching variable selection heuristics. Beyond those, we also need a local solver/primal heuristic capable of actually finding the global solution without us having to actually fix all variables. This last bit is by far the most challenging for difficult problems.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="123" LastEditDate="2020-01-07T09:18:35.927" LastActivityDate="2020-01-07T09:18:35.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3292" PostTypeId="2" ParentId="3276" CreationDate="2020-01-07T08:25:00.773" Score="2" Body="&lt;p&gt;Considering that all your plots will be for the same problem you don't need to normalise by using relative error, so you can use either representation as long as you use it consistently for everything. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing I would consider foremost is the readability of the charts, so I would suggest to plot both and see which representation is better scaled to actually be easy to observe in a plot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that, the difference between the two ways you are considering is basically whether to plot convergence, or the rate of convergence. Personally, I find convergence (i.e., the difference of values) to be more intuitive because I can tell the rate from the slope of the graph.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-01-07T08:30:01.540" LastActivityDate="2020-01-07T08:30:01.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3293" PostTypeId="1" AcceptedAnswerId="3294" CreationDate="2020-01-07T11:12:22.500" Score="11" ViewCount="449" Body="&lt;p&gt;Many papers formulate their (NP-hard) problem as ILP or MILP and then show Cplex/Gurobi are unable to solve instances of a certain size. Then they introduce a meta-heuristic solution approach to solve these large instances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: have there been any attempts to build a meta-heuristic solver that can be directly applied to any MIP-formulation? If not, why not?&lt;/p&gt;&#xA;" OwnerUserId="405" LastActivityDate="2020-01-07T13:05:20.803" Title="Metaheuristic to solve general MIPs" Tags="|mixed-integer-programming|reference-request|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3294" PostTypeId="2" ParentId="3293" CreationDate="2020-01-07T11:20:10.143" Score="14" Body="&lt;p&gt;I believe there are long answers to this question, but a very short one is: yes. Here is an example that originated not from the use case you describe, but I believe that they can directly apply their local search to a MIP: &lt;a href=&quot;https://www.localsolver.com/&quot; rel=&quot;noreferrer&quot;&gt;LocalSolver&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="123" LastEditDate="2020-01-07T13:05:20.803" LastActivityDate="2020-01-07T13:05:20.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3295" PostTypeId="2" ParentId="3022" CreationDate="2020-01-07T18:20:01.730" Score="4" Body="&lt;p&gt;For the following I did not check in depth the rules related to end-of-period/beginning of period, so this is something you should carefully check for your problem. However, the approach does not differ much if this is incorrect (but your numbers may end up different). Sanity checks are definitely in order before you take this answer for granted!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think your state variable is a bit strange. Given the problem, I would be inclined to define &lt;span class=&quot;math-container&quot;&gt;$p_{i,j}$&lt;/span&gt; as the cumulative profit in years periods from &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; up to and including period &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, assuming there is currently a machine with age &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in time period &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We first need to define recurrent relationships on the state variables &lt;span class=&quot;math-container&quot;&gt;$p_{i,j}$&lt;/span&gt;. For the first period, where &lt;span class=&quot;math-container&quot;&gt;$i=1$&lt;/span&gt;, we can do so as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p_{1,j} = \left\{ \begin{array}{ll} 5 &amp;amp; \mbox{ if } j=2 \\&#xA;                                    -\infty &amp;amp; \mbox{ otherwise }&#xA;                  \end{array}\right.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea here is that we have a profit of &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; (thousand) for the state where we have a two year old machine at the end of the first year.&#xA;Since it is not possible to have any other machine at the end of the first year, the states related to that situation have&#xA;&lt;span class=&quot;math-container&quot;&gt;$-\infty$&lt;/span&gt; profit, as this value will be discarded by the consecutive steps of the recurrence relation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the later periods, where &lt;span class=&quot;math-container&quot;&gt;$i \geq 2$&lt;/span&gt;, we can compute the best possible profit based on the previous period by means of the following&#xA;recurrence relation&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p_{i,j} = \left\{ \begin{array}{ll}&#xA;\max_{k \in \{0,\dots,3\}} p_{i-1,k} + 10 - 6   &amp;amp; \mbox{ if } j=0 \\&#xA;p_{i-1,j-1} + 7  &amp;amp; \mbox{ if } j=1 \\&#xA;p_{i-1,j-1} + 5  &amp;amp; \mbox{ if } j=2 \\&#xA;p_{i-1,j-1} + 1  &amp;amp; \mbox{ if } j=3 \\&#xA;\end{array} \right.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the idea is that if in a later period the age of the machine is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, it means we must have bought a new machine in&#xA;the previous period. Since multiple machine states were possible in the previous period, we should do so in the state&#xA;that yields maximum profit. This is where we apply the Bellman optimality principle. In case we have a machine with a&#xA;greater age, we know for certain that we had a machine with one age smaller in the previous period and therefore, there&#xA;is nothing to optimize.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can construct a table for these recurrence relations. The following python code does this in a bit of a quick-and-dirty way, and hasn't been carefully checked.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;# Problem constants&#xA;profits = {0: 10, 1: 7, 2: 5, 3: 1}&#xA;cost = 6&#xA;&#xA;def dp(i,j,table={}):&#xA;    if (i,j) in table:&#xA;      return table[(i,j)]&#xA;    # Deal with the base case&#xA;    if i==1:&#xA;        if j==2:&#xA;            table[(i,j)] = 5&#xA;        else:&#xA;          table[(i,j)] = float('-inf')&#xA;    # Deal with the recurrent case&#xA;    elif j==0:&#xA;        # If we have a new machine, determine in which state it could best be bought&#xA;        best = dp(i-1,0,table)&#xA;        for k in range(1,4):&#xA;            val = dp(i-1,k,table)&#xA;            if val &amp;gt; best:&#xA;                best = val&#xA;        table[(i,j)] = best + profits[0] - cost&#xA;    # If we don't have new machine, just add the profit&#xA;    elif j in profits:&#xA;        table[(i,j)] = dp(i-1,j-1,table) + profits[j]&#xA;    # We should now have a value for the state&#xA;    if (i,j) in table:&#xA;      return table[(i,j)]&#xA;    raise ValueError&#xA;&#xA;table = {}&#xA;for k in range(0,4):&#xA;    ans = dp(5,k, table)&#xA;    print(k, ans)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This prints the following numbers:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;0 &amp;amp; 25 \\&#xA;1 &amp;amp; 27 \\&#xA;2 &amp;amp; 25 \\&#xA;3 &amp;amp; 22&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which are based on the following numbers stored in the &lt;code&gt;table&lt;/code&gt; dictionary:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{l|rrrrr}&#xA; &amp;amp; 1 &amp;amp; 2 &amp;amp; 3 &amp;amp; 4 &amp;amp; 5 \\&#xA;\hline&#xA;0 &amp;amp; -\infty &amp;amp; 9 &amp;amp; 13 &amp;amp; 20 &amp;amp; 25 \\&#xA;1 &amp;amp; -\infty &amp;amp; -\infty &amp;amp; 16 &amp;amp; 20 &amp;amp; 27 \\&#xA;2 &amp;amp; 5 &amp;amp; -\infty &amp;amp; -\infty &amp;amp; 21 &amp;amp; 25 \\&#xA;3 &amp;amp; -\infty &amp;amp; 6 &amp;amp; -\infty &amp;amp; -\infty &amp;amp; 22 \\&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which suggests that the maximum profit is obtained if you end with a 1 period old machine, and make a profit of 27000. If you want to obtain the exact policy, you would need to keep track of the predecessor states, possibly via an additional table.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastEditorUserId="123" LastEditDate="2020-01-08T06:15:55.657" LastActivityDate="2020-01-08T06:15:55.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3296" PostTypeId="5" CreationDate="2020-01-07T22:34:56.543" Score="0" Body="" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2020-01-07T22:34:56.543" LastActivityDate="2020-01-07T22:34:56.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3297" PostTypeId="4" CreationDate="2020-01-07T22:34:56.543" Score="0" Body="For questions about solving Operations Research problems using the Julia programming language." OwnerUserId="36" LastEditorUserId="36" LastEditDate="2020-01-07T22:34:56.543" LastActivityDate="2020-01-07T22:34:56.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3298" PostTypeId="1" AcceptedAnswerId="3649" CreationDate="2020-01-07T22:51:49.830" Score="14" ViewCount="494" Body="&lt;p&gt;I want to start learning Stochastic Programming, beginning with SAA (Sample Average Approximation) and keeping a practitioner's perspective in mind, i.e. I would like my sources to collectively cover intuition, background theory and the topics one should keep in mind when applying SAA. I know about Shapiro et al's book,&lt;sup&gt;1&lt;/sup&gt; but I'm also interested in the application-focused topics, which apparently aren't part of the book's focus. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found a tutorial by Shapiro and Philpott.&lt;sup&gt;2&lt;/sup&gt; I know I could just start reading many publications like &lt;sup&gt;3&lt;/sup&gt; and &lt;sup&gt;4&lt;/sup&gt;, presentations like &lt;a href=&quot;https://www.ima.umn.edu/materials/2015-2016/ND8.1-12.16/25374/morton_ima.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one by Morton&lt;/a&gt;, or class notes from universities like &lt;a href=&quot;https://sites.google.com/site/jhu625743/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this JHU 2019 class&lt;/a&gt; or &lt;a href=&quot;http://homepages.cae.wisc.edu/~linderot/classes/ie495/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jeff Linderoth's 2003 course notes&lt;/a&gt; (I guess the content covered could be slightly outdated because of last 2 decades' newer advances in the field). The problem with the former approach is that I could get easily lost in the abundance of alternatives. Are there other sources you'd recommend optimization practitioners to read as an introduction to the topic? My priority is to know how to use and model real-world problems, keeping in mind mathematical rigor and computational issues/tractability regarding sampling procedures and approximations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help in building a learning path will be highly appreciated, be it considering the former references, a different set or additional sources. Consider the reader to have Master's degree knowledge level of Applied Math and OR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1 Shapiro, A., Dentcheva, D., &amp;amp; Ruszczyński, A. (2014). Lectures on stochastic programming: modeling and theory. Society for Industrial and Applied Mathematics.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;2 Shapiro, A., &amp;amp; Philpott, A. (2007). A tutorial on stochastic programming. Manuscript. Available at www2. isye. gatech. edu/ashapiro/publications. html, 17.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;3 Verweij, B., Ahmed, S., Kleywegt, A. J., Nemhauser, G., &amp;amp; Shapiro, A. (2003). The sample average approximation method applied to stochastic routing problems: a computational study. Computational Optimization and Applications, 24(2-3), 289-333.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;4 Kim, S., Pasupathy, R., &amp;amp; Henderson, S. G. (2015). A guide to sample average approximation. In Handbook of simulation optimization (pp. 207-243). Springer, New York, NY.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="123" LastEditDate="2020-03-05T21:50:44.500" LastActivityDate="2020-03-05T22:56:20.460" Title="Sources to learn about Sample Average Approximation for practitioners" Tags="|reference-request|stochastic-programming|practical-or|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3299" PostTypeId="1" AcceptedAnswerId="3300" CreationDate="2020-01-08T02:13:44.570" Score="3" ViewCount="1173" Body="&lt;p&gt;I have a model for the no-wait flow shop scheduling problem, that utilizes the linear ordering variables, and there is a constraint with big-M. When I implement the model in &lt;code&gt;CPLEX OPL&lt;/code&gt;, the model assigns zero to all linear ordering variables. I guess the problem is with the big-M constraint, but I don't know how to fix it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my implementation of the two main constraints in &lt;code&gt;CPLEX OPL&lt;/code&gt;. The variable &lt;code&gt;X[i][j]&lt;/code&gt; takes 1 if job &lt;code&gt;j&lt;/code&gt; is processed after job &lt;code&gt;i&lt;/code&gt; in the sequence. The variable &lt;code&gt;C[i][k]&lt;/code&gt; shows the completion time of job &lt;code&gt;i&lt;/code&gt; on machine &lt;code&gt;k&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the second constraint (c2) I put 10000 as the big-M (the same value I use in other solvers). The answer turns out to be infeasible due to constraint 1 (c1), since the solver puts all &lt;code&gt;X&lt;/code&gt; variables equal to zero (hence violating c1 since 0 = 1).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int NumofJobs = 2;&#xA;int NumofMachines = 3;&#xA;&#xA;range n = 1..NumofJobs;&#xA;range m = 1..NumofMachines;&#xA;dvar boolean X[n][n];&#xA;dvar int+ C[n][m];&#xA;&#xA;int TaskTime[n][m] = [[5,6,3], [2,8,9]];;&#xA;&#xA;&#xA; minimize (sum (i in n) (C[i][NumofMachines]));&#xA;&#xA; subject to {&#xA;&#xA;   forall (i in n)&#xA;    forall (j in n: j &amp;gt; i)             &#xA;      c1: X[i][j] + X[j][i] == 1;&#xA;&#xA;   forall (i in n)&#xA;     forall (j in n: j != i)&#xA;        forall (k in m)&#xA;          c2: C[i][k] + TaskTime[j][k] &amp;lt;= C[j][k] + 10000 * (1 - X[i][j]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have implemented the same model in other solvers and the problem is solved without any issue.&lt;/p&gt;&#xA;" OwnerUserId="660" LastActivityDate="2020-01-08T11:25:25.177" Title="Problem with big-M in CPLEX OPL" Tags="|cplex|big-m|implementation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3300" PostTypeId="2" ParentId="3299" CreationDate="2020-01-08T02:46:45.383" Score="6" Body="&lt;p&gt;It is numerically safer to use a (small) data-dependent value for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;.  For your case, rewrite as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;C[i][k] + TaskTime[j][k] - C[j][k] &amp;lt;= M[i][j][k] * (1 - X[i][j]);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want to choose &lt;span class=&quot;math-container&quot;&gt;$M_{i,j,k}$&lt;/span&gt; to be a (small) upper bound on the left hand side when &lt;span class=&quot;math-container&quot;&gt;$X_{i,j}=0$&lt;/span&gt;.  A good choice is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$M_{i,j,k} = U_{i,k} + T_{j,k} - L_{j,k},$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$U_{i,k}$&lt;/span&gt; is a good upper bound on &lt;span class=&quot;math-container&quot;&gt;$C_{i,k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L_{j,k}$&lt;/span&gt; is a good lower bound  (0?) on &lt;span class=&quot;math-container&quot;&gt;$C_{j,k}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-01-08T02:46:45.383" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3301" PostTypeId="1" CreationDate="2020-01-08T03:23:38.133" Score="7" ViewCount="131" Body="&lt;p&gt;When one is interested in solving a problem but considering different objective functions the choice is easy, a class for problem, a class for solution and a class by algorithm then in the main function (or file) we just need to call the appropriate one. The reason for that is that the different problems has the same feasible region thus they can share a common problem and solution classes&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What to do in the case of having a problem and I need to do the following :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;solve it &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;find an bound using a relaxation (Lagrangian for instance)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;find an bound using a reformulation (Dantzig-Wolfe and column generation). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What is the best idea to structure the code ?&lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2020-01-08T13:59:26.013" LastActivityDate="2020-01-08T18:42:55.897" Title="Design choices on how to implement several algorithms for the same problem" Tags="|algorithms|applications|implementation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3302" PostTypeId="2" ParentId="3299" CreationDate="2020-01-08T11:25:25.177" Score="4" Body="&lt;p&gt;with CPLEX 12.10 your model gives a solution with objective 3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you prefer not to use big M, you could use logical constraints and rewrite&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;forall (k in m)&#xA;          c2: C[i][k] + TaskTime[j][k] &amp;lt;= C[j][k] + 10000 * (1 - X[i][j]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;forall (k in m)&#xA;          c2b:(X[i][j]==1) =&amp;gt; (C[i][k] + TaskTime[j][k] &amp;lt;= C[j][k]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But even better, within OPL CPLEX I encourage you to have a look at the &lt;a href=&quot;https://www.slideshare.net/PhilippeLaborie/introduction-to-cp-optimizer-for-scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPOptimizer&lt;/a&gt; solver that could tackle your problem even faster.&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-01-08T11:25:25.177" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3303" PostTypeId="1" AcceptedAnswerId="3304" CreationDate="2020-01-08T16:53:12.700" Score="6" ViewCount="347" Body="&lt;p&gt;I would like to code some IP/MIP models in python and test them with an open-source solver. As of now, I only know the &lt;strong&gt;Cbc - COIN-OR&lt;/strong&gt; open-source solver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already tried the or-tools interface, unfortunately, its capabilities are restricted (e.g., linear expressions are not possible).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried to install the &lt;strong&gt;COIN-OR CyLP&lt;/strong&gt; Interface both in Win10 and Linux Ubuntu without any success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any interfaces that offer an &lt;strong&gt;OR-Tools&lt;/strong&gt; similar experience?&lt;/p&gt;&#xA;" OwnerUserId="456" LastEditorUserId="981" LastEditDate="2023-12-22T14:43:59.420" LastActivityDate="2023-12-22T14:43:59.420" Title="Interface for Cbc - COIN-OR" Tags="|mixed-integer-programming|python|or-tools|open-source|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3304" PostTypeId="2" ParentId="3303" CreationDate="2020-01-08T17:19:47.480" Score="8" Body="&lt;p&gt;There are several packages I can think of with an interface to CBC:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/solving_pyomo_models.html&quot; rel=&quot;noreferrer&quot;&gt;Pyomo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pythonhosted.org/PuLP/&quot; rel=&quot;noreferrer&quot;&gt;PuLP&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://python-mip.readthedocs.io/en/latest/&quot; rel=&quot;noreferrer&quot;&gt;MIP&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="36" LastActivityDate="2020-01-08T17:19:47.480" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3305" PostTypeId="1" AcceptedAnswerId="3333" CreationDate="2020-01-08T18:19:53.600" Score="5" ViewCount="923" Body="&lt;p&gt;I am trying to run the following optimization problem at Python by using the CPLEX API:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min \{x_1 + x_2\ | \ x_1 \geq 3, x_2 \geq 2, 2x_1 + x_2 \geq 9\} $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want to give a matrix of coefficients and implement the problem as simple as possible. However, the easiest way I was able to do was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import cplex&#xA;my_prob = cplex.Cplex()&#xA;my_obj = [1,1]&#xA;rows = [[[&quot;x1&quot;,&quot;x2&quot;],[-1, 0]], [[&quot;x1&quot;,&quot;x2&quot;],[0, -1]], [[&quot;x1&quot;,&quot;x2&quot;],[-2,-1]]]&#xA;my_colnames = [&quot;x1&quot;, &quot;x2&quot;]&#xA;my_rhs = [-3, -2, -9]&#xA;my_prob.variables.add(obj = my_obj, names = my_colnames)&#xA;my_prob.objective.set_sense(my_prob.objective.sense.minimize)&#xA;my_prob.linear_constraints.add(lin_expr = rows, senses = [&quot;LLL&quot;], rhs = my_rhs)&#xA;my_prob.solve()&#xA;my_prob.solution.get_values()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I really don't want to define each constraint of form &lt;code&gt;[[&quot;x1&quot;,&quot;x2&quot;],[1,0]]&lt;/code&gt;, is there any way I  can get rid of the naming? Because I will give huge matrices to CPLEX and I just want to have all the coefficients! I mean, my matrix will include all the variables' coefficients, so I really don't need to give which coefficient is for which variable.&lt;/li&gt;&#xA;&lt;li&gt;I don't want to give &lt;code&gt;senses[&quot;LLL&quot;]&lt;/code&gt; all the time, but default should stay &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Edit for the first case, obviously I can define &lt;code&gt;my_colnames&lt;/code&gt; in the beginning and all &lt;code&gt;[&quot;x1&quot;,&quot;x2&quot;]&lt;/code&gt; can be replaced by &lt;code&gt;my_colnames&lt;/code&gt;. But still...&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2020-01-08T18:55:23.767" LastActivityDate="2020-01-15T09:45:55.817" Title="CPLEX Python API" Tags="|linear-programming|cplex|python|cplex-python-api|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3306" PostTypeId="2" ParentId="3301" CreationDate="2020-01-08T18:35:18.103" Score="4" Body="&lt;p&gt;It depends on how you choose to solve your master and slave problems (for your Lagrangian and Dantzig-Wolfe decompositions). Theoretically, you can solve everything with linear programs. In this case your usual favorite structures and classes can be used as is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using a package such as PuLP (python), you have a class for the problem (pulp.LpProblem), and you solve it by calling your favorite available solver with the pulp.LpProblem.solve() command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, for the two other options (Lagrange and Dantzig-Wolfe), you can exploit the fact that they both require master and slave problems. In fact, the slave problems are identical, and the master problems are duals of one another. This is something that I would take advantage of. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Column generation and Lagrangian relaxation have the following pseudo-code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Initialize your set of variables V&#xA;Initialize the &quot;continue&quot; parameter to True&#xA;While continue is True :&#xA;   relaxed_objective, duals = MasterProblem(V)&#xA;   v, continue = SlaveProblem(duals)&#xA;   if v has negative reduced cost (for minimization problem) :&#xA;      Add v to V&#xA;   else :&#xA;      continue = False&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, the slave problems are identical so a same class can be used. Depending on how you solve your slave problem, you might need an appropriate class. If you are solving it as a linear problem, the pulp.LpProblem class works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the Master problem, for column generation, it is a linear problem, so in terms of PuLP it falls in the pulp.LpProblem class as well. As for Lagrange, it depends on how you choose to tackle it. Since it is the dual of Dantzig's formulation, you can, again, use the pulp.LpProblem class (or any other problem class if you are using another package). If you choose to solve it with a sub-gradient method, you would need an ad hoc class. &lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-01-08T18:42:55.897" LastActivityDate="2020-01-08T18:42:55.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3307" PostTypeId="2" ParentId="1508" CreationDate="2020-01-08T19:56:49.383" Score="4" Body="&lt;p&gt;The Python syntax could be like this:  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;model.addConstr(sum(x[i,j] for i in A for j in A if i != j) &amp;lt;= 10,  &quot;firstConstraint&quot;)&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;model.addConstrs(sum(x[i,j] for i in A if i != j) &amp;lt;= 10 for j in B,  &quot;secondConstraintClass&quot;)&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;model.addConstr(x[i,j] &amp;lt;= 10 for i in A for j in B if i != j,  &quot;thirdConstraintClass&quot;)&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;model&lt;/code&gt; is the gurobi API object in your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;addConstrs&lt;/code&gt; is for the case when you add many similar constraints indexed by a set, while &lt;code&gt;addConstr&lt;/code&gt; is for when you add only one constraint at the time (note the &lt;code&gt;for j in B&lt;/code&gt; after the inequality and  before the comma in the second constraint where &lt;code&gt;addConstrs&lt;/code&gt; is used).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check more about the &lt;code&gt;addConstrs&lt;/code&gt; method in its &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/py_model_addconstrs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt;, including some examples and use cases. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For sums over large arrays or linear products, or when adding a linear product where the coefficients could be sparse, I'd recommend reading about the &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/py_quicksum.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;quicksum&lt;/a&gt; and &lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/py_linexpr2.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;LinExpr&lt;/a&gt; methods which can yield further efficiency.&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="123" LastEditDate="2020-01-08T20:15:31.310" LastActivityDate="2020-01-08T20:15:31.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3308" PostTypeId="1" CreationDate="2020-01-08T20:14:29.150" Score="10" ViewCount="1567" Body="&lt;p&gt;In many of vehicle routing problems variant (VRP), which can be formulated using MIPs, to avoid creating sub tour, we need to use sub tour elimination constraints (SEC). One of the known SEC is (I also know there are other types):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;u_{k}-u_{l}+|H| z_{k l} \leq|H|-1, \quad \forall k, l \in H, l \neq 1, l \neq k&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is interesting is that, in some of MIP models, these constraints are removed and replaced by other constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know, is there any principle to replace such constraints with other inequalities and also any guarantee to do better performance using them?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2020-01-08T20:19:48.587" LastActivityDate="2020-01-10T11:14:36.810" Title="How to remove or replace sub tour elimination constraints in the VRP variant models?" Tags="|optimization|mixed-integer-programming|vehicle-routing|subtour-elimination|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3309" PostTypeId="1" AcceptedAnswerId="3314" CreationDate="2020-01-08T22:51:04.537" Score="9" ViewCount="684" Body="&lt;p&gt;Could someone please comment and answer on the complexity of purely binary linear programming (BLP) and mixed-integer linear programming (MILP)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In MILP, we have both binary and continuous variables while in BLP we have only binary variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the complexity perspective, which one is easier to solve? I believe both are NP-hard problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do the mixed binary and continuous variables make it harder to solve?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="2477" LastEditDate="2020-01-08T23:06:21.557" LastActivityDate="2020-01-09T23:25:32.757" Title="Complexity comparision between purely BLP and MILP problems?" Tags="|mixed-integer-programming|computational-complexity|binary-variable|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3310" PostTypeId="2" ParentId="3271" CreationDate="2020-01-08T23:33:37.713" Score="4" Body="&lt;p&gt;As well as the visual design, discussed in other answers, it's worth thinking about how back-end choices in the optimisation model can make for a more intuitive system. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing that can sometimes be helpful is to consider how the system will react to user decisions, and to try to make that as intuitive as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, a couple of years ago I implemented an optimisation-based solution to an economic accounts balancing problem:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We have tables containing tens of thousands of economic data points.&lt;/li&gt;&#xA;&lt;li&gt;This data &lt;em&gt;should&lt;/em&gt; satisfy certain consistency rules (if you add up how much every economic sector spends &lt;em&gt;buying&lt;/em&gt; cars, and add up how much every sector gets from &lt;em&gt;selling&lt;/em&gt; cars, those should be the same number)&lt;/li&gt;&#xA;&lt;li&gt;Because of various measurement error issues, the initial estimates don't satisfy those rules.&lt;/li&gt;&#xA;&lt;li&gt;Subject matter experts resolve major discrepancies manually, but we need to remove thousands of small discrepancies by automated adjustment.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So the optimisation problem is &quot;find values that satisfy consistency constraints (mostly linear) while minimising changes from the initial values&quot;. The big challenge here is that &quot;minimising changes&quot; is fuzzily defined:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do we use an absolute-value (linear) measure of change, or squared change (quadratic) for our OF?&lt;/li&gt;&#xA;&lt;li&gt;We need to weight these adjustments, because some values are more reliable than others, but this information isn't written down - we can set some reasonable default values but the end users (economic subject matter experts) will need to be able to fine-tune these weights when they spot unreasonable behaviour.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So I wanted to design the system in a way that would make it as intuitive as possible for the users in understanding how their weighting choices would affect the outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has a couple of implications:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a usability perspective, a quadratic OF is better than a linear (abs-value) OF here. With a linear OF, solutions will always lie on the vertices of the feasible region. This means that when you make changes to the objective function weights, you might see no change at all to the solution. Or you might see a very large change as the solution moves from one vertex to another, even in response to a very small change in the weights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By contrast, with a quadratic OF, solutions move gradually as you change the weights. In general, a small change in weights will result in a small but non-zero change to the outputs, and larger changes in weights will drive larger changes to the outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This makes the quadratic OF much more intuitive for a user whose interest is &quot;how do my decisions about the weights affect the final results?&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(There are other good reasons for using a quadratic OF in this problem, but those don't relate to usability.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next question is, how should weights be specified? Some back-of-the-envelope work suggests that on average, adjustments to an item will be roughly in proportion to 1/weight for that item. Since my users are more likely to think in terms of &quot;how much can we adjust this?&quot; than &quot;how much should an adjustment cost?&quot; I set things up so that they provide the weighting info in terms of &quot;adjustability&quot; and this is internally transformed into a weight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Baking these choices into the optimisation model made it a lot easier to provide users with an intuitive interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously, there will be many problems where you don't have the luxury of letting usability considerations influence the objective function, but when you do it's worth exploring!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: as requested, some more info on weighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The data in question is a system of interrelated tables. The full representation is about five dimensions, but users are normally looking at a two-dimensional slice of the problem. Rows = products (different kinds of goods and services), columns = economic sectors (household, government, export/import, non-profits, 67 different industries, etc. etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each cell represents the total value bought or sold for that product for that sector in the reference period. In any one of these two-dimensional slices, there are about 24,000 cells, each of which needs a weight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Our users are familiar with spreadsheets, so that's how they interact with this. For each cell, they specify an &quot;adjustability rating&quot; indicating what they would consider a reasonable adjustment, in percentage terms, relative to the unadjusted value. (Rather than specifying 24,000 values individually, a lot of this is filled in by general rules - &quot;all data from this source gets 10% adjustability&quot;, that sort of thing - with the most significant cells getting closer attention.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A heatmap visualisation of adjustability ratings makes it easier to eyeball the weighting information and see a general pattern of weighting choices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A macro then converts all the data from the spreadsheet to something the optimisation code can work with. &quot;Percentage adjustability&quot; is multiplied by the unadjusted value to get adjustability in dollars, and then weights are set as 1/adjustability. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a simple system where we have one constraint &lt;span class=&quot;math-container&quot;&gt;$x_1+...+x_n=c$&lt;/span&gt;, and our objective function is a sum of &lt;span class=&quot;math-container&quot;&gt;$w_ih_i^2$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt; is the adjustment made to each value, the &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt; will be in proportion to &lt;span class=&quot;math-container&quot;&gt;$1/w_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this complex economic system, any one cell is involved in several different constraints, so this relationship doesn't hold exactly, but it's good enough for an order-of-magnitude approximation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the optimisation is done, we can then &quot;score&quot; the actual adjustments relative to expected adjustments, and then use another heat-map visualisation to give the big picture on what's going on in the table. For example, if we see a prominent horizontal red stripe, that means we're making a lot of big adjustments for one product (rows = products), so our analysts might want to double-check that product and see if anything weird is going on - for instance, there might be some issue that requires manual intervention. OTOH, a vertical stripe means something going on within the &lt;em&gt;sector&lt;/em&gt; rather than the product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Along with that, we do produce a list of unusually large adjustments at sector x product level. But often these are driven by something happening elsewhere, so the heat-map visualisation is helpful in understanding how these individual adjustments relate to the big picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I approached weighting is to ask users to indicate what they would consider a &quot;reasonable adjustment&quot; for each of these cells, as a percentage of the original value. . &lt;/p&gt;&#xA;" OwnerUserId="546" LastEditorUserId="546" LastEditDate="2020-01-11T03:16:42.630" LastActivityDate="2020-01-11T03:16:42.630" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3311" PostTypeId="1" AcceptedAnswerId="3313" CreationDate="2020-01-09T07:04:22.573" Score="7" ViewCount="231" Body="&lt;p&gt;I'm looking to identify a problem in the literature that I'm currently solving. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a set of jobs each having a set of operations. Each operation has a duration. An operation may be done by a machine, from a set of machines, that can process the operation type. Machines only process one type of operation and have a run-time capacity. Operations of each job may be done in any order.  Of course each machine may only do one operation at a time.  The objective is to find a feasible allocation of operations to machines so as to finish all jobs within an allotted maximum time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd appreciate help identifying the problem and references to papers you know of. &lt;/p&gt;&#xA;" OwnerUserId="2916" LastEditorUserId="491" LastEditDate="2020-01-10T13:37:37.273" LastActivityDate="2020-01-10T13:37:37.273" Title="Variant of job shop scheduling problem" Tags="|optimization|reference-request|scheduling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3312" PostTypeId="1" CreationDate="2020-01-09T14:29:41.547" Score="10" ViewCount="282" Body="&lt;p&gt;I'm working on a resource‐constrained project scheduling problem (RCPSP) in Minizinc but I have problems with the running times when the dataset is big (like 400 jobs, 2 resources, 1,000 precedences, and maximum time of 30). With Gecode, after two hours, the model is still running (for the smaller datasets we get the correct result). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it could be that the restrictions aren't the best to model this problem with constraint programming. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm working with binary variables &lt;code&gt;x[j,t]&lt;/code&gt; that is 1 iff the job &lt;code&gt;j&lt;/code&gt; starts in time &lt;code&gt;t&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the resource constraint, I'm using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;constraint forall(k in RESOURCE) (&#xA;             forall(t in TIME) &#xA;                   (sum(j in TASK)(res[k,j]*(sum(s in max(t-d[j]+1,0)..t)(x[j,s])))  &amp;lt;=L[k])&#xA;                   ); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;res[k,j]&lt;/code&gt; is the amount of resource &lt;code&gt;k&lt;/code&gt; used by job &lt;code&gt;j&lt;/code&gt; in each period (assume it is constant for all times that &lt;code&gt;j&lt;/code&gt; is activated). The &lt;code&gt;max&lt;/code&gt; operator is to avoid troubles with the index of &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And for the precedencies constraint, I'm using the constraint &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x[j_2,t]\leq x[j_1,t-d_{j_1}],\quad\forall t \in[0,\dots,T_{\max}],\forall(j_1,j_2)$$&lt;/span&gt; &#xA;where &lt;span class=&quot;math-container&quot;&gt;$j_1$&lt;/span&gt; is predecessor of &lt;span class=&quot;math-container&quot;&gt;$j_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_{j_1}$&lt;/span&gt; is the duration of &lt;span class=&quot;math-container&quot;&gt;$j_1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The goal is to optimize the net present value (not makespan, like almost all implementations I have found).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any recommendations? I'm not using the classical model constraint for index problem, but I'm not sure about this formulation.&lt;/p&gt;&#xA;" OwnerUserId="2921" LastEditorUserId="123" LastEditDate="2020-01-09T15:50:53.573" LastActivityDate="2020-01-09T19:53:49.263" Title="RCPSP minizinc model" Tags="|constraint-programming|minizinc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3313" PostTypeId="2" ParentId="3311" CreationDate="2020-01-09T19:34:59.470" Score="2" Body="&lt;p&gt;This is a production planning/production scheduling problem (Google scholar these for many relevant hits), some nice references to get you started include &lt;a href=&quot;https://pubs.acs.org/doi/abs/10.1021/ie100790t&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt; and &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S037722171000408X&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-01-09T19:34:59.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3314" PostTypeId="2" ParentId="3309" CreationDate="2020-01-09T19:44:32.087" Score="4" Body="&lt;p&gt;Any (M)ILP can be transformed to an equivalent (M)BLP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are multiple methods to do so, some described in &lt;a href=&quot;https://books.google.co.uk/books/about/Nonlinear_and_Mixed_Integer_Optimization.html?id=OhTfOjSkq18C&quot; rel=&quot;nofollow noreferrer&quot;&gt;this book&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pure discrete problems are NP-hard just like their mixed integer cousins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One method is to replace integers by a sum of binary variables per integer, the cardinality of which depends on each integer's span.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In practice, BLPs tend to be slightly easier to solve because binaries allow us to take many algorithmic shortcuts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mixed-integer/mixed-binary problems are of the same complexity. In practice, they are often harder to solve because we can't use the same reformulations that apply to pure discrete problems, and the complexity of branching on continuous variables is much worse than creating branch-and-bound trees of discrete variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note however that &quot;harder&quot; here is ambiguous and should be taken with a grain of salt. A problem with 49,999 continuous variables and 1 binary is much easier to solve than a problem with 50,000 binaries.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-01-09T23:25:32.757" LastActivityDate="2020-01-09T23:25:32.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3315" PostTypeId="2" ParentId="3312" CreationDate="2020-01-09T19:53:49.263" Score="5" Body="&lt;p&gt;With constraint solvers, I think it is generally desirable to exploit global constraints as much as is possible. As an alternative to your resource constraint, have a look at the section on the &quot;cumulative&quot; constraint (and the example using it) in the &lt;a href=&quot;https://www.minizinc.org/doc-2.4.1/en/predicates.html#cumulative&quot; rel=&quot;noreferrer&quot;&gt;MiniZinc Handbook&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-01-09T19:53:49.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3316" PostTypeId="2" ParentId="3308" CreationDate="2020-01-10T07:58:27.063" Score="6" Body="&lt;p&gt;The inequalities you have included in your post are the so-called MTZ SEC's which are known to be very weak. That is, they do not provide a very tight approximation of the convex hull of integer feasible solutions. There are tons of papers providing polynomial-sized sets of SEC's (see for instance &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S037722171300619X#!&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bektaş and Gouveia (2014)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; for stronger versions of the MTZ or &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221718305253&quot; rel=&quot;nofollow noreferrer&quot;&gt;Letchford and Salazar-González (2019)&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt; for (multi-)commodity flow-based formulations of the SEC's).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in practice, for problems consisting of more than say 20-30 customers, it usually works better to separate stronger SEC's from families of inequalities of exponential sizes. For example, for the CVRP, there is the set of &quot;rounded capacity inequalities&quot; given by&#xA;\[&#xA;\sum_{i\in S}\sum_{j\not\in S}z_{ij} \geq \left\lceil \frac{\sum_{i\in S}q_i}{Q}\right\rceil,\qquad \forall S\subseteq \{1,\dots,n\}&#xA;\]&#xA;where &lt;span class=&quot;math-container&quot;&gt;$q_i$&lt;/span&gt; is the demand of customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is the capacity of the vehicles (for information on the strength of different types of SEC's you can take a look at the very nice paper by &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-005-0652-x&quot; rel=&quot;nofollow noreferrer&quot;&gt;Letchford and Salazar-González (2006)&lt;/a&gt;)&lt;sup&gt;3&lt;/sup&gt;.&#xA;I believe that the state-of-the-art solvers for vehicle routing problems combine the agility of strong cutting planes with the strength of the LP bound obtained from the relaxation of a set-partitioning based formulation of the VRP in question. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Bektaş, T., Gouveia, L. (2014). &lt;em&gt;Requiem&lt;/em&gt; for the Miller-Tucker-Zemlin subtour elimination constraints? &lt;em&gt;European Journal of Operational Research.&lt;/em&gt; 236(3):820-832. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] Letchford, A. N., Salazar-González, J-J. (2019). The Capacitated Vehicle Routing Problem: Stronger bounds in pseudo-polynomial time. &lt;em&gt;European Journal of Operational Research.&lt;/em&gt; 272(1):24-31. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [3] Letchford, A. N., Salazar-González, J-J. (2006). Projection results for vehicle routing. &lt;em&gt;Mathematical Programming.&lt;/em&gt; 105(2-3):251-274. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="123" LastEditDate="2020-01-10T11:14:36.810" LastActivityDate="2020-01-10T11:14:36.810" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3317" PostTypeId="1" AcceptedAnswerId="3329" CreationDate="2020-01-10T21:29:30.957" Score="17" ViewCount="1023" Body="&lt;p&gt;I am looking for references that used customer aggregation to solve large-scale Vehicle Routing Problems. By aggregation, I mean clustering the customers together and representing them with one node in the network. I found some related studies but they are not exactly what I am looking for. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- I am aware of cluster-first route-second methods to solve the VRP however, these approaches normally cluster the customers to be visited by one vehicle and then solve a TSP for each cluster. What I want is the cases that the vehicle's capacity is enough to visit multiple clusters and a VRP should be solved after the clustering. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2- Clustered vehicle routing problem (CLuVRP), in which customers are grouped into predefined clusters, and all customers in a cluster must be served consecutively by the same vehicle. This is the closest problem to what I am looking for except that I aim to use clustering to scale down the problem search space and most proposed approaches for CLuVRP won't do that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;3- Districting for VRP, these types of studies focus on building the districts (clusters) not the routing decisions or questions such as how to calculate the parameters (e.g. distances and time windows for an aggregated network), how to find the actual sequence of the customers after finding the sequence of clusters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;4- I only was able to found two studies by A. Campbell that use customer clustering to reduce the size of VRP.&lt;br&gt;&#xA;- &quot;Aggregation for the probabilistic traveling salesman problem&quot;&lt;br&gt;&#xA;- &quot;Runtime reduction techniques for the probabilistic traveling salesman problem with deadlines&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Surprisingly, I couldn't find more references on this. If you know any relevant sources I would be grateful if you could share them.&lt;/p&gt;&#xA;" OwnerUserId="172" LastActivityDate="2021-03-28T21:26:32.737" Title="Customer clustering to solve very large-scale VRPs" Tags="|reference-request|vehicle-routing|clustering|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3318" PostTypeId="1" CreationDate="2020-01-11T13:43:08.547" Score="7" ViewCount="79" Body="&lt;p&gt;I am novice to constraint programming and I need to implement the following algorithms.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Backtacking &lt;/li&gt;&#xA;&lt;li&gt;Conflict-based backjumping&lt;/li&gt;&#xA;&lt;li&gt;AC partial lookahead&lt;/li&gt;&#xA;&lt;li&gt;MAC&lt;/li&gt;&#xA;&lt;li&gt;Forward checking&lt;/li&gt;&#xA;&lt;li&gt;Forward checking + dom &lt;/li&gt;&#xA;&lt;li&gt;Forward checking + LCV'&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is it easy to extensible with available constraint solvers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or should I implement from start to end?&#xA;Is there any solver that includes those algorithms?&lt;/p&gt;&#xA;" OwnerUserId="2930" LastEditorUserId="2930" LastEditDate="2020-01-11T13:52:08.980" LastActivityDate="2020-01-11T13:52:08.980" Title="Which Constraint solver is extensible to CSP algorithms?" Tags="|solver|constraint-programming|java|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3319" PostTypeId="1" CreationDate="2020-01-11T15:05:45.500" Score="11" ViewCount="664" Body="&lt;p&gt;I am trying to model a grouping algorithm as k-means clustering problem, by referring to the general definition as mentioned in &lt;a href=&quot;https://en.wikipedia.org/wiki/K-means_clustering#Description&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my system, I have &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; nodes that I want to group in &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; groups, based on the peer-to-peer distance &lt;span class=&quot;math-container&quot;&gt;$D_{i,j}$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$D_{i,j}$&lt;/span&gt; are known (i.e. inputs) for the optimization problem. For this purpose, I define these decision variables:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L_i^k$&lt;/span&gt;        : Boolean variable equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the leader of group &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;; &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{i,j}^k$&lt;/span&gt; : Boolean variable equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the leader of &#xA;        node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in group &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;; &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_k$&lt;/span&gt;: Average distance of group &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$D_k = \mathop{{}\mathbb{E}} [ L_i^k D_{i,j} \quad / i = L \cap G_k, \ j \in G_k, j \neq i ]$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;such as &lt;span class=&quot;math-container&quot;&gt;$i,j \in \lbrace 1, N \rbrace$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$k \in \lbrace 1,m \rbrace$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$G_k$&lt;/span&gt; is the set of elements in group &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following constraint aims at selecting the members of the same group such as the distance variance does not exceed &lt;span class=&quot;math-container&quot;&gt;$\sigma_D$&lt;/span&gt; (known):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{split}&#xA;&amp;amp;\forall k \in \lbrace 1,  m \rbrace , \forall i\in \left\{2, N\right\}: \\&#xA;&amp;amp;\sum_{j=1, j \neq i}^{N} L_i^k \times {\left\Vert X_{i,j}^k \times D_{i,j} - D_k\right\Vert}^2\leq \sigma_D&#xA;\end{split}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how to solve the optimization problem using a solver? Namely, I have implemented my optimization problem using CPLEX Java API, but I am a little stuck in this constraint. I am thinking of linearizing it but I can't figure out yet if it is a good option since I have already linearized some constraints (by introducing a new decision variable &lt;span class=&quot;math-container&quot;&gt;$Z_{i,j}^k = L_i^k \times X_{i,j}^k$&lt;/span&gt; and adding equivalent linearization constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any guidance to build an efficient implementation is very welcome!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The updated formulation of the k-medoids constraints, expressed as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Average distance to the leader:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\forall k \in \lbrace 1,  m \rbrace: D_k \leq D^*&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Max distance to the leader:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\forall k \in \lbrace 1,  m \rbrace, \forall i\in \left\{2, N\right\}: &#xA;\max_{j=1, j \neq i} ( L_i^k \times X_{i,j}^k \times D_{i,j} ) \leq D^{**} &#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;such as &lt;span class=&quot;math-container&quot;&gt;$D^{*}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D^{**}$&lt;/span&gt; are thrshold distances on average and max distances to the leader, respectivly. In this case, it is straithforward tomiplement it in CPLEX using java.&lt;/p&gt;&#xA;" OwnerUserId="2599" LastEditorUserId="2599" LastEditDate="2020-01-26T22:38:26.803" LastActivityDate="2020-01-26T22:38:26.803" Title="k-means/k-medoids Clustering Implementation in CPLEX Java" Tags="|mixed-integer-programming|cplex|linearization|java|clustering|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="3320" PostTypeId="1" AcceptedAnswerId="3420" CreationDate="2020-01-11T18:57:37.650" Score="6" ViewCount="684" Body="&lt;p&gt;(For Linear Programming) I am aware of CPLEX's reoptimize methods. If I am not wrong, if you solve a problem and after that you add a new constraint, then you can call the reoptimize method for not to start a whole solution from the beginning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These kind of methods select the dual simplex method as solution algorithm and the Branch &amp;amp; Bound methods usually follow this method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, is there such a feature in GUROBI. If yes, could you please provide links with me? An implementation example in C++ would be awesome.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2020-01-27T18:00:40.357" Title="GUROBI Re-optimize a model" Tags="|optimization|linear-programming|gurobi|c++|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3321" PostTypeId="2" ParentId="3319" CreationDate="2020-01-11T19:34:50.890" Score="5" Body="&lt;p&gt;Here is how I would do this: you essentially have a &lt;em&gt;facility location&lt;/em&gt; problem, every data point is a potential facility and you decide whether you open it or not (i.e., whether it is the leader of its group). Same goes for the other points, will they be served by the opened facility or not (i.e., will they belong to its group).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Standard MILP models don't scale well and I would formulate this as a set covering model, one variable for each (!) potential cluster, and solve that one by branch-and-price. I would use the left hand side of the non-linear constraint as objective function in the pricing problem and use some tailored algorithm to find the minimum reduced cost clusters. In the master problem I would minimize the maximum of the selected clusters' costs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solving the master problem (a linear program) can be done in CPLEX, also the tailored pricing problem can be done in your Java code, however you would not be able to have a tailored branching which you might need to solve the model to integer optimality.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="123" LastEditDate="2020-01-12T10:16:28.357" LastActivityDate="2020-01-12T10:16:28.357" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3322" PostTypeId="1" CreationDate="2020-01-11T20:07:10.910" Score="10" ViewCount="398" Body="&lt;p&gt;What are some current issue of interest in Operations Research?  I am interested in current topics that experts in the field are interested in researching.&lt;/p&gt;&#xA;" OwnerUserId="2934" LastActivityDate="2020-01-21T08:08:13.887" Title="Current Issues of Interest" Tags="|optimization|combinatorial-optimization|queuing-theory|" AnswerCount="2" CommentCount="8" CommunityOwnedDate="2020-02-09T13:58:45.160" ContentLicense="CC BY-SA 4.0" />
  <row Id="3323" PostTypeId="2" ParentId="3322" CreationDate="2020-01-13T13:41:23.107" Score="7" Body="&lt;p&gt;This is an attempt at an answer, based on my current understanding:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Operations Research is an interdisciplinary field. You go from business administration and economics to theoretical computer science and mathematics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In practice, you observe a real-world situation, model it, solve the model (or develop a method for solving general instances), and then implement the solution to the model in the real world, evaluate and repeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In each of these steps, there is active research.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) If you work mostly empirically, and research how actors solve these problems in the real world, you go into behavioral OR or case studies that would be published in journals like &quot;INFORMS Journal of applied analytics&quot;. &#xA;An example of such a study would be: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;We formulate the omni-channel fulfillment problem as an online&#xA;  optimization problem. We propose a novel algorithm for this problem&#xA;  based on the primal–dual schema. Our algorithm is robust: It does not&#xA;  require explicit demand forecasts. This is an important practical&#xA;  advantage in the apparel-retail setting, where demand is volatile and&#xA;  unpredictable. We provide a performance analysis establishing that our&#xA;  algorithm admits optimal performance guarantees in the face of&#xA;  adversarial demand. We describe a large-scale implementation of our&#xA;  algorithm at Urban Outfitters, Inc. This implementation processes on&#xA;  average 18,000 customer orders a day and as many as 100,000 orders on&#xA;  peak demand days. The system has resulted in substantial savings&#xA;  relative to an incumbent industry-standard fulfillment optimization&#xA;  implementation through optimal order-fulfillment decisions that&#xA;  simultaneously increase turn and lower shipping costs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1287/inte.2019.1013&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1287/inte.2019.1013&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Scientists working in that area are often organized by the field of business, that they are interested in. (e.g. warehousing...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) When only improving solution methods you get into mathematics, and journals like &quot;Mathematical Programming&quot;. Here look at the most abstracted problems and try to prove general abstract results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example would be:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;We show that the classical LP relaxation of the asymmetric traveling&#xA;  salesman path problem (ATSPP) has constant integrality ratio. If &lt;span class=&quot;math-container&quot;&gt;$\rho_{\rm ATSP}$&lt;/span&gt;&#xA;  and &lt;span class=&quot;math-container&quot;&gt;$\rho_{\rm ATSPP}$&lt;/span&gt; denote the integrality ratios for the asymmetric TSP and&#xA;  its path version, then &lt;span class=&quot;math-container&quot;&gt;$\rho_{\rm ATSPP}\le4\rho_{\rm ATSP}-3$&lt;/span&gt;. We prove an even better bound&#xA;  for node-weighted instances: if the integrality ratio for ATSP on&#xA;  node-weighted instances is &lt;span class=&quot;math-container&quot;&gt;$\rho_{\rm ATSP}^{\textrm N\,\,W}$&lt;/span&gt;, then the integrality ratio for&#xA;  ATSPP on node-weighted instances is at most &lt;span class=&quot;math-container&quot;&gt;$2\rho_{\rm ATSP}^{\textrm N\,\,W}-1$&lt;/span&gt;. Moreover, we&#xA;  show that for ATSP node-weighted instances and unweighted digraph&#xA;  instances are almost equivalent. From this we deduce a lower bound of&#xA;  &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; on the integrality ratio of unweighted digraph instances.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1007/s10107-019-01450-8&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1007/s10107-019-01450-8&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Scientists working in that area are often organized around the kind of mathematics they use. (e.g. polyhedral theory)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) There is obviously a lot of stuff in between very relevant to practice, and high applicability; and purely theoretic results for very abstract models. And often a single paper might cover both a new real-world example and contain novel methods. Much of that work transfers ideas from one of the extremes in the direction of the other. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a trend in better models for practice, there will be a tendency to find common mathematical features and find a more abstract model. Then people will work on the more abstract model and improve the understanding of these models. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a big new result in theory, or a new method, people will try to extend it so that it can be applied to real-world problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Actual answer&lt;/strong&gt; (kind of): On the more mathematical side you often have &lt;em&gt;big&lt;/em&gt; open questions, like: What is the best possible approximation ratio for the asymmetric traveling salesperson problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: very rarely does someone just solve a long open problem. Rather there are small improvements for special cases like: if all distances for the TSP are 1 or 2 we have a new algorithm that has an approximation ratio of 1.28953 instead of 1.3. Aka, don't be intimidated by the weird cult of genius in mathematics.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the more applied side, you are more or less driven by the real world. The best way to look at what is happening in your area of interest is literature reviews. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; Here &lt;a href=&quot;https://doi.org/10.1016/J.SORMS.2016.05.002&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1016/J.SORMS.2016.05.002&lt;/a&gt; is a literature review of literature reviews in OR. It contains more than 300 literature reviews, and they typically contain a section with suggestions for future research.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck, stay curious and research these operations;)&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2020-01-13T16:02:49.977" LastActivityDate="2020-01-13T16:02:49.977" CommentCount="1" CommunityOwnedDate="2020-02-09T13:58:45.160" ContentLicense="CC BY-SA 4.0" />
  <row Id="3324" PostTypeId="2" ParentId="3317" CreationDate="2020-01-13T13:53:21.063" Score="9" Body="&lt;p&gt;You might find some interesting points in the following two papers&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;C. Walshaw, 2002, A Multilevel Approach to the Travelling Salesman Problem, &lt;em&gt;Operations Research&lt;/em&gt;, Vol. 50, nr. 5, pages 862-877. In this paper they present a method which first simplifies the problem by aggregating customers until you have a very simple graph. After the simplification phase, the method alternates between a refinement step and an &quot;unpacking&quot; step. The refinement phase improves the route found on the simplified graph while the unpacking step expands the simple to a slightly more complex one. This procedure continues until one has created a solution to the original problem.&lt;/li&gt;&#xA;&lt;li&gt;J. Oppen and A. Løkketangen, 2006, &quot;Arc routing in a node routing environment&quot;, &lt;em&gt;Computers &amp;amp; operations research&lt;/em&gt;, Vol. 33, nr. 4, pages 1033--1055. In this paper aggregation on 4 different &quot;levels&quot; is discussed for the stringed VRP. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Maybe these papers or references therein can point in a helpful direction.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="123" LastEditDate="2020-01-13T15:59:13.760" LastActivityDate="2020-01-13T15:59:13.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3325" PostTypeId="1" CreationDate="2020-01-13T15:12:05.427" Score="10" ViewCount="1576" Body="&lt;p&gt;I'm trying to solve an RCPSPDc model (maximizing the net present value instead of a makespan). The objective function is: &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{j \in \text{Tasks}} e^{-\theta\cdot s_{j}}\cdot p_{j}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$s_{j}$&lt;/span&gt; is a decision variable that for each job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; we save the time that it begins (an integer), &lt;span class=&quot;math-container&quot;&gt;$p_{j}$&lt;/span&gt; is the profit of the job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\theta_{j}$&lt;/span&gt; is a discount factor.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;# Define objective&#xA;    model.Maximize(sum(np.exp(-delta*s[j])*pro[j] for j in range(n)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, when I run my model I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;Traceback (most recent call last):&#xA;  File &quot;example_python.py&quot;, line 199, in &amp;lt;module&amp;gt;&#xA;    rcpsp_solver()&#xA;  File &quot;example_python.py&quot;, line 191, in rcpsp_solver&#xA;    model.Maximize(sum(np.exp(-delta*s[j])*pro[j] for j in range(n)))&#xA;  File &quot;example_python.py&quot;, line 191, in &amp;lt;genexpr&amp;gt;&#xA;    model.Maximize(sum(np.exp(-delta*s[j])*pro[j] for j in range(n)))&#xA;  File &quot;/home/diego/.local/lib/python2.7/site-packages/ortools/sat/python/cp_model.py&quot;, line 229, in __rmul__&#xA;    cp_model_helper.AssertIsInt64(arg)&#xA;  File &quot;/home/diego/.local/lib/python2.7/site-packages/ortools/sat/python/cp_model_helper.py&quot;, line 30, in AssertIsInt64&#xA;    raise TypeError('Not an integer: %s' % x)&#xA;TypeError: Not an integer: -0.09&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and 0.09 is my discount rate.&#xA;So I've been switching from other solvers to this one because the same problem (Gecode, Chuffed, etc), hoping that ORtools could work. Is there a way to compute the real value (float) and solve? Actually i'm thinking that most of the Constraint programming solvers have the same issue (in addition, all mazimize makespan that has an integer objective in their examples).&#xA;I'm using the python API.&lt;/p&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="981" LastEditDate="2024-01-21T07:38:34.450" LastActivityDate="2024-01-21T07:38:34.450" Title="Floating points in OR-Tools" Tags="|python|constraint-programming|or-tools|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3326" PostTypeId="2" ParentId="3325" CreationDate="2020-01-13T15:48:15.553" Score="7" Body="&lt;p&gt;In many of its solvers, OR-Tools only accept integers (see Laurent Perron's comment below).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model.Maximize(  int(round(  sum(np.exp(-delta*s[j])*pro[j] for j in range(n))  ))  )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will probably work (I haven't tried), but you might lose some precision. The usual solution is to multiply each value by a power of 10 and divide the result by the same amount.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. if you want a precision of &lt;span class=&quot;math-container&quot;&gt;$10^{-3}$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model.Maximize(  int(round(  sum(np.exp(-delta*s[j])*pro[j] for j in range(n))  *1000))  )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and divide the final result by 1000.&lt;/p&gt;&#xA;" OwnerUserId="132" LastEditorUserId="132" LastEditDate="2020-01-14T09:28:53.160" LastActivityDate="2020-01-14T09:28:53.160" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3327" PostTypeId="1" AcceptedAnswerId="3332" CreationDate="2020-01-13T20:30:44.440" Score="11" ViewCount="331" Body="&lt;p&gt;I am using CPLEX 12.9 to solve a mixed integer linear programming problem. Some of my constraints are enforced through a legacy LazyConstraintCallback. Heuristic solutions are inserted through a legacy HeuristicCallback. My implementation is in C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To insert a heuristic solution, I use the following function:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;public void &lt;strong&gt;setSolution&lt;/strong&gt;(const IloIntVarArray vars, const IloNumArray vals)&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;For each variable in the array vars, this method uses the value in the corresponding element of the array vals to define a heuristic solution to be considered as a new incumbent.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If the user heuristic was successful in finding a new candidate for an incumbent, setSolution can be used to pass it over to IloCplex. IloCplex then analyzes the solution and, if it is both feasible and better than the current incumbent, uses it as the new incumbent. A solution is specified using arrays vars and vals, where vals[i] specifies the solution value for vars[i].&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Do not call this method multiple times. Calling it again will overwrite any previously specified solution.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.ide.help/refcppopl/html/classes/IloCplex_HeuristicCallbackI.html#method_setSolution&quot; rel=&quot;noreferrer&quot;&gt;CPLEX documentation&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To my surprise, CPLEX will accept solutions that satisfy the current constraints, but &lt;em&gt;violate&lt;/em&gt; the lazy constraints. For my application, this is actually very convenient, because I can guarantee that my solutions satisfy the lazy constraints, and skipping the verification saves time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I do have the following questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is it intentional that the LazyConstraintCallback is not called to verify a manually provided solution?&lt;/li&gt;&#xA;&lt;li&gt;Is it guaranteed that the LazyConstraintCallback is never called for a manually provided solution?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="145" LastActivityDate="2020-01-14T21:34:09.447" Title="CPLEX allows manually inserted solutions to violate lazy constraints" Tags="|mixed-integer-programming|cplex|callback|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3328" PostTypeId="1" CreationDate="2020-01-14T14:43:07.193" Score="3" ViewCount="193" Body="&lt;p&gt;I'm working with OR Tools in Python and I need to define the objective function an expression of the variables. In particular, the objective function is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{c_j}{1.7^{s_j}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; constants and &lt;span class=&quot;math-container&quot;&gt;$s_j$&lt;/span&gt; the model's variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read there is a &lt;code&gt;MakePower(exp,float)&lt;/code&gt; function that makes a IntExp (&lt;span class=&quot;math-container&quot;&gt;$exp^{float}$&lt;/span&gt;) in C++ but I havent found an equivalent for Python, there exist such a function that allow to create these expresssions of variables? (I found sum and product, but nothing else implemented for Python).&lt;/p&gt;&#xA;" OwnerUserId="2921" LastEditorUserId="123" LastEditDate="2020-01-14T15:47:11.257" LastActivityDate="2020-01-14T15:47:11.257" Title="Power of variable or tools" Tags="|python|constraint-programming|or-tools|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3329" PostTypeId="2" ParentId="3317" CreationDate="2020-01-14T15:46:48.487" Score="7" Body="&lt;p&gt;You can check the following papers:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221705008672&quot; rel=&quot;noreferrer&quot;&gt;A cluster-based optimization approach for the multi-depot heterogeneous fleet vehicle routing problem with time windows&lt;/a&gt;. From the abstract:&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Phase I aims to identifying a set of cost-effective feasible clusters while Phase II assigns clusters to vehicles and sequences them on each tour by&#xA;  using the cluster-based MILP formulation. Ordering nodes within clusters and scheduling vehicle arrival times at customer locations for each tour through solving a small MILP model is finally performed at Phase III.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can see in their figures that they touch on your question, i.e. a vehicle visits multiple clusters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note that I got the image below from the version available on &lt;a href=&quot;https://s3.amazonaws.com/academia.edu.documents/42281937/A_cluster-based_optimization_approach_fo20160207-12785-n36u4r.pdf?response-content-disposition=inline%3B%20filename%3DA_cluster-based_optimization_approach_fo.pdf&amp;amp;X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;amp;X-Amz-Credential=AKIAIWOWYYGZ2Y53UL3A%2F20200114%2Fus-east-1%2Fs3%2Faws4_request&amp;amp;X-Amz-Date=20200114T153000Z&amp;amp;X-Amz-Expires=3600&amp;amp;X-Amz-SignedHeaders=host&amp;amp;X-Amz-Signature=bf7bfa9552dda6c7319e3c56ca7d28fa5ab03fbf4776d375493086217deccdb4&quot; rel=&quot;noreferrer&quot;&gt;academia.edu&lt;/a&gt;&lt;/em&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/kywuk.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kywuk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.tandfonline.com/doi/abs/10.1080/00207543.2016.1220685&quot; rel=&quot;noreferrer&quot;&gt;Modelling and solution of a large-scale vehicle routing problem at GE appliances &amp;amp; lighting&lt;/a&gt;. (&lt;em&gt;Disclaimer: I'm one of the authors&lt;/em&gt;). The figure below, which is the network illustration, shows that the nodes (small circles) are divided into macro-nodes (the outermost circles) and inside of them, are clusters (the dotted circles). A vehicle can go from one cluster to another and from one macro-node to another.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/k83em.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/k83em.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2020-01-14T15:46:48.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3330" PostTypeId="1" CreationDate="2020-01-14T16:33:46.993" Score="4" ViewCount="310" Body="&lt;p&gt;I have the constraint &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad\gamma\\\text{s.t.}&amp;amp;\quad a\ge\gamma b\\&amp;amp;\quad\gamma\le 1\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; is an optimization variable and &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is a function of some other variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, can I just write &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad\gamma\\\text{s.t.}&amp;amp;\quad a\le b\end{align}&lt;/span&gt; instead?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="123" LastEditDate="2020-01-14T17:14:07.423" LastActivityDate="2020-01-14T17:23:11.413" Title="How to express this constraint?" Tags="|optimization|linear-programming|convexity|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3331" PostTypeId="2" ParentId="3330" CreationDate="2020-01-14T17:16:10.253" Score="7" Body="&lt;p&gt;No. The constraint &lt;span class=&quot;math-container&quot;&gt;$a\ge\gamma b$&lt;/span&gt; sets no upper bound on &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; so it cannot be bounded above by &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; as your second formulation suggests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few posts here on the linearisation of the product of two variables; e.g.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/180/how-to-linearize-the-product-of-two-continuous-variables?rq=1&quot;&gt;How to linearize the product of two continuous variables?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables?rq=1&quot;&gt;How to linearize the product of two binary variables?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/39/how-to-linearize-the-product-of-a-binary-and-a-non-negative-continuous-variable?rq=1&quot;&gt;How to linearize the product of a binary and a non-negative continuous variable?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2020-01-14T17:23:11.413" LastActivityDate="2020-01-14T17:23:11.413" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3332" PostTypeId="2" ParentId="3327" CreationDate="2020-01-14T21:34:09.447" Score="5" Body="&lt;p&gt;I think the answers to both questions are yes. The documentation for LazyConstraintCallback.getSolutionSource says the following: &quot;Note that lazy constraint callbacks are not invoked for solutions provided by a heuristic callback.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I vaguely recall discussing this someplace (possibly on a forum, but not recently, and I can't find the discussion) and being told the logic in essence is that if the user has a feasibility &quot;oracle&quot; (the lazy constraint callback) and the user provides a solution, the user should be responsible for testing it before injecting it. That makes sense to me.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-01-14T21:34:09.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3333" PostTypeId="2" ParentId="3305" CreationDate="2020-01-15T09:45:55.817" Score="5" Body="&lt;p&gt;with the cplex docplex API you may write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;mdl = Model(name='test')&#xA;&#xA;x1 = mdl.continuous_var(name='x1')&#xA;x2 = mdl.continuous_var(name='x2')&#xA;&#xA;mdl.add_constraint(x1&amp;gt;=3, 'ct1')&#xA;mdl.add_constraint(x2&amp;gt;=2, 'ct2')&#xA;mdl.add_constraint(2*x1+x2&amp;gt;=9, 'ct3')&#xA;&#xA;mdl.minimize(x1+x2)&#xA;&#xA;mdl.solve()&#xA;&#xA;for v in mdl.iter_continuous_vars():&#xA;    print(v,&quot; = &quot;,v.solution_value) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x1  =  3.5&#xA;x2  =  2.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-01-15T09:45:55.817" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3334" PostTypeId="1" CreationDate="2020-01-15T16:54:58.597" Score="7" ViewCount="185" Body="&lt;p&gt;This &lt;a href=&quot;https://arxiv.org/pdf/1708.04527.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;article&lt;/a&gt; presents the following formulation of the &lt;em&gt;best subset selection problem&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{\|\beta\|_0\leq k}\frac{1}{2}\|y-X\beta\|^2_2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I wonder where the &lt;span class=&quot;math-container&quot;&gt;$1/2$&lt;/span&gt; comes from. Help appreciated.&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-01-15T19:43:33.137" Title="Why is there a constant in the objective function of the *best subset selection problem*?" Tags="|mixed-integer-programming|quadratic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3336" PostTypeId="2" ParentId="3334" CreationDate="2020-01-15T17:45:46.050" Score="9" Body="&lt;p&gt;The factor of &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2}$&lt;/span&gt; is just for convenience, so that the Hessian of the objective does not have a factor of two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The argmin (optimal value of &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;) is the same, whether or not the factor &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2}$&lt;/span&gt; is included.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that rather than &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2}$&lt;/span&gt;, some &quot;authors&quot; use &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2n}$&lt;/span&gt;, This also does not affect the argmin.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-01-15T17:45:46.050" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3337" PostTypeId="1" AcceptedAnswerId="3352" CreationDate="2020-01-16T14:02:43.670" Score="7" ViewCount="326" Body="&lt;p&gt;&lt;sub&gt; I've asked this question also on &lt;a href=&quot;https://math.stackexchange.com/questions/3505141/custom-nurse-rostering-problem&quot;&gt;Math Stack Exchange&lt;/a&gt;. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a custom nurse rostering problem:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is a set of nurses;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is the set of shift-type (morning, afternoon, night, rest)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$n_\mathrm{Morning}$&lt;/span&gt; is the number of nurses required every day to cover a morning;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$n_\mathrm{Afternoon}$&lt;/span&gt; is the number of nurses required every day to cover an afternoon;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$n_\mathrm{Night}$&lt;/span&gt; is the number of nurses required every day to cover a night;&lt;/li&gt;&#xA;&lt;li&gt;Every shift lasts &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; hours;&lt;/li&gt;&#xA;&lt;li&gt;Every nurse can work only for one shift in a day;&lt;/li&gt;&#xA;&lt;li&gt;After every night a nurse must have a rest day;&lt;/li&gt;&#xA;&lt;li&gt;Rest at the weekend and on holiday have to be balanced between all nurses;&lt;/li&gt;&#xA;&lt;li&gt;I would like that after every morning there will be an afternoon, after an afternoon a night and after a night a rest day.&lt;/li&gt;&#xA;&lt;li&gt;I would like to plan shifts with a month frequency.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What are the decision variables and the objective function that I have to use?&#xA;Can anyone help me to write it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can define the quantity &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1$&lt;/span&gt;, if nurse &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; works on shift &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; elsewhere. But how can I balance holiday and rest days between other nurses? &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;UPDATE (16/01/2020)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the actual model that I have formulated, is this right for covering constraints &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is an element of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, coded as: &lt;span class=&quot;math-container&quot;&gt;$0=\rm Morning$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$1=\rm Afternoon$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$2=\rm Night$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is an element of the set of days of January.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\min&amp;amp;\quad\sum_{i=0}^n\sum_{j=0}^2\sum_{k=1}^{31}x_{ijk}\\\text{s.t.}&amp;amp;\quad\sum_{i=0}^nx_{i0k}=n_{\rm Morning}&amp;amp;\quad\forall k\\&amp;amp;\quad\sum_{i=0}^nx_{i1k}=n_{\rm Afternoon}&amp;amp;\quad\forall k\\&amp;amp;\quad\sum_{i=0}^nx_{i2k}=n_{\rm Night}&amp;amp;\quad\forall k\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;UPDATE (17/01/2020) - Thanks to @lonzaleggiera on Math Stack Exchange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; be a set of weekend days and &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; be a set of holidays. The actual model is given by &lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\min&amp;amp;\quad\sum_{j=0}^1\sum_{i=0}^n\sum_{k=1}^{30}x_{ijk}\left(1-x_{i(j+1)(k+1)}\right)\\\text{s.t.}&amp;amp;\quad\sum_{i=0}^nx_{i0k}=n_\text{Morning}&amp;amp;\forall k\\&amp;amp;\quad\sum_{i=0}^nx_{i1k}=n_\text{Afternoon}&amp;amp;\forall k\\&amp;amp;\quad\sum_{i=0}^nx_{i2k}=n_\text{Night}&amp;amp;\forall k\\&amp;amp;\quad\sum_{j=0}^2x_{ijk}\leq1&amp;amp;\forall i,k\\&amp;amp;\quad x_{i2k}+\sum_{j=0}^2x_{ij(k+1)}\leq1&amp;amp;\forall i,k\\&amp;amp;\quad\sum_{k\in W}\left(1-\sum_{j=0}^2x_{i_1jk}\right)=\sum_{k\in W}\left(1-\sum_{j=0}^2x_{i_2jk}\right)&amp;amp;\forall i_1,i_2\\&amp;amp;\quad\sum_{k\in H}\left(1-\sum_{j=0}^2x_{i_1jk}\right)=\sum_{k\in H}\left(1-\sum_{j=0}^2x_{i_2jk}\right)&amp;amp;\forall i_1,i_2.\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are my current doubts:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;For the last two hard constraints to balance weekend and holidays, the problem will probably become infeasible. To integrate them in the current objective function, do I have to multiply the current objective function with the maximum difference between the two sides? &lt;/li&gt;&#xA;&lt;li&gt;If I find an empty polyhedron replacing the two hard constraints can I replace &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; (points &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;) with &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;$&lt;/span&gt;?&lt;/li&gt;&#xA;&lt;li&gt;If I solve this model every month, how can I remember the past decisions to have continuous balancing?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2949" LastEditorUserId="123" LastEditDate="2020-01-18T19:45:55.410" LastActivityDate="2020-01-19T20:12:10.230" Title="Custom Nurse Rostering Problem" Tags="|optimization|modeling|integer-programming|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3338" PostTypeId="1" CreationDate="2020-01-16T17:35:22.607" Score="6" ViewCount="101" Body="&lt;p&gt;Given a minimum-cost flow problem, how could I go about demonstrating that a specific solution (as sets of basic and non-basic (!) arcs that build a rooted spanning tree for a given graph) is basic and feasible for the problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: the MCF problem has a variable number of divergences, for the nodes – some require more flow than others, some generate it and through the remaining ones the flow only transit. Also, how does proving the feasibility of a solution and whether or not it is basic change with and without bound constraints? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per the feasibility, I figure it could be pretty straightforward: a solution is feasible as long as it satisfies all constraints, I may dare saying for any Operation Research problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a MCF problem, as long as the strongly connected graph built with the arcs in the given solution create a rooted spanning tree free of any cycles, I would claim the solution is indeed feasible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about proving the given solution is basic, however?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given a linear problem, a solution is basic if it is indeed possible to build a matrix &lt;span class=&quot;math-container&quot;&gt;$B \subset A$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; being the matrix of technological coefficients) with at least &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is the number of constraints for the given LP) linearly independent columns. &#xA;Since the network simplex works similarly to the &quot;classical&quot; simplex, would the statement above be sufficient to prove a solution is indeed basic?&lt;/p&gt;&#xA;" OwnerUserId="2559" LastEditorUserId="2559" LastEditDate="2020-01-16T22:51:53.297" LastActivityDate="2020-01-16T22:51:53.297" Title="Demonstrating a given solution is basic for a MCFP?" Tags="|simplex|network-flow|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3339" PostTypeId="1" AcceptedAnswerId="3343" CreationDate="2020-01-17T04:11:13.983" Score="5" ViewCount="166" Body="&lt;p&gt;I am using Knitro to solve an MINLP using branch-and-bound and I want to know about the reference or technique they are adopting to code their algorithm. I know that there are many applications of branch-and-bound to tackle MINLP but I couldn't find which technique they are adopting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.artelys.com/docs/knitro/2_userGuide/minlp.html#algorithms-methods&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here is a link to Knitro's manual.&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="2854" LastEditorUserId="123" LastEditDate="2020-01-17T07:17:20.583" LastActivityDate="2020-01-17T16:24:46.143" Title="What is the technique of branch-and-bound used in Knitro to solve MINLP?" Tags="|branch-and-bound|minlp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3340" PostTypeId="2" ParentId="3339" CreationDate="2020-01-17T12:26:48.710" Score="3" Body="&lt;p&gt;As KNITRO's manual says, it's vanilla branch-and-bound: the integer variables are relaxed to continuous, and solving that relaxed problem provides the bound for branch and bound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since in this case the relaxation of the problem is the problem itself made continuous, this bound is only valid if the problem is convex: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It is primarily designed for convex models, and in this case the integrality gap measure can be trusted. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-01-17T12:26:48.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3341" PostTypeId="1" AcceptedAnswerId="3348" CreationDate="2020-01-17T15:51:27.423" Score="5" ViewCount="279" Body="&lt;p&gt;As a task, I want to produce three products &lt;span class=&quot;math-container&quot;&gt;$x,y,z$&lt;/span&gt; in different quantities &lt;span class=&quot;math-container&quot;&gt;$a,b,c&amp;gt;0$&lt;/span&gt; respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not always possible to produce the full amount of each product, because of a lack of resources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to set an objective keeping the percentage between &lt;span class=&quot;math-container&quot;&gt;$a^*/a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b^*/b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c^*/c$&lt;/span&gt; as similar as possible with &lt;span class=&quot;math-container&quot;&gt;$a^*,b^*,c^*$&lt;/span&gt; being the &lt;strong&gt;decision variables&lt;/strong&gt; for the actual amount of produced numbers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover the following attributes have to hold: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$a^* \leq a,b^*\leq b,c^*\leq c$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$a^* + b^* + c^* \leq |\rm resources|$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My thoughts on this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I thought that by maximizing the sum of &lt;span class=&quot;math-container&quot;&gt;$a^*/a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b^*/b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c^*/c$&lt;/span&gt; would have the wanted effect which is not the case.&lt;/li&gt;&#xA;&lt;li&gt;A way to do so would be to write an objective in the following way: &lt;span class=&quot;math-container&quot;&gt;$$\min\ \left|\frac{a^*}{a}-\frac{b^*}{b}\right| + \left|\frac{b^*}{b}-\frac{c^*}{c}\right| + \left|\frac{a^*}{a}-\frac{c^*}{c}\right| $$&lt;/span&gt; which is &lt;strong&gt;not linear&lt;/strong&gt; and perhaps not the best way to formulate.&lt;/li&gt;&#xA;&lt;li&gt;Is there a better objective function without having to linearize the upper part?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="456" LastEditorUserId="456" LastEditDate="2020-01-17T18:53:36.223" LastActivityDate="2020-01-18T14:52:32.737" Title="MIP for similar production percentages in production planning" Tags="|mixed-integer-programming|linear-programming|modeling|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3342" PostTypeId="2" ParentId="3341" CreationDate="2020-01-17T16:01:45.920" Score="5" Body="&lt;p&gt;You could let decision variable &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; represent the desired common percentage, and penalize the absolute differences by minimizing &lt;span class=&quot;math-container&quot;&gt;$$\left|\frac{a^*}{a}-t\right|+\left|\frac{b^*}{b}-t\right|+\left|\frac{c^*}{c}-t\right|,$$&lt;/span&gt;&#xA;which you can linearize by minimizing &lt;span class=&quot;math-container&quot;&gt;$e_a + e_b + e_c$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;-e_a \le \frac{a^*}{a}-t &amp;amp;\le e_a\\&#xA;-e_b \le \frac{b^*}{b}-t &amp;amp;\le e_b\\&#xA;-e_c \le \frac{c^*}{c}-t &amp;amp;\le e_c&#xA;\end{align}&lt;/span&gt;&#xA;and your other constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without some constraint that forces production, an optimal solution will be &lt;span class=&quot;math-container&quot;&gt;$$a^*=b^*=c^*=t=e_a=e_b=e_c=0.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-01-18T14:39:07.743" LastActivityDate="2020-01-18T14:39:07.743" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3343" PostTypeId="2" ParentId="3339" CreationDate="2020-01-17T16:24:46.143" Score="4" Body="&lt;p&gt;Knitro offers two variations of branch-and-bound for mixed-integer nonlinear programs.  The first (and default method) is a standard branch-and-bound method that solves a continuous nonlinear optimization problem at each node by relaxing the integer variables. The second (the Quesada-Grossmann approach) solves linear programming subproblems at most nodes and only solves continuous nonlinear subproblems at select nodes.  This method has easier/faster node solves, but typically requires many more nodes to prove optimality.  A reference to this approach can be found in the bibliography section of the Knitro User's Manual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both approaches are designed for convex MINLP models and are only heuristics in the non-convex case.  The choice of method is controlled through the &quot;mip_method&quot; user option. The Knitro branch-and-bound approach also includes heuristics for finding integer feasible points and a variety of cuts, branching strategies, etc. that can be controlled through user options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information can be found in the User's Manual &lt;a href=&quot;https://www.artelys.com/docs/knitro/2_userGuide/minlp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.artelys.com/docs/knitro/2_userGuide/minlp.html&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2953" LastActivityDate="2020-01-17T16:24:46.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3344" PostTypeId="2" ParentId="3341" CreationDate="2020-01-17T18:06:06.420" Score="1" Body="&lt;p&gt;You could try this: Adding three auxiliary variables for the absolute values of the difference of the percentages: &lt;span class=&quot;math-container&quot;&gt;$s_{ab}, s_{bc}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s_{ac}$&lt;/span&gt;. Adding additional constraints to the model:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}s_{ab}&amp;amp;\geq\frac{a^*}a - \frac{b^*}b\\s_{ab}&amp;amp;\geq\frac{b^*}b - \frac{a^*}a\\s_{bc}&amp;amp;\geq\frac{b^*}b - \frac{c^*}c\\s_{bc}&amp;amp;\geq\frac{c^*}c - \frac{b^*}b\\s_{ac}&amp;amp;\geq\frac{c^*}c - \frac{a^*}a\\s_{ac}&amp;amp;\geq\frac{a^*}a - \frac{c^*}c\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the following objective function: &lt;span class=&quot;math-container&quot;&gt;$$\min   s_{ab}+s_{bc} + s_{ca},$$&lt;/span&gt; which yields a linear objective function and constraints, and minimizing it drives more similar value of the fractions &lt;span class=&quot;math-container&quot;&gt;$\frac{a^*}a, \frac{b^*}b, \frac{c^*}c$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="123" LastEditDate="2020-01-17T19:36:37.537" LastActivityDate="2020-01-17T19:36:37.537" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3345" PostTypeId="1" CreationDate="2020-01-17T18:58:56.770" Score="4" ViewCount="171" Body="&lt;p&gt;I was reading &lt;a href=&quot;https://doi.org/10.1109/TSG.2017.2672801&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; by Cerna &lt;em&gt;et al.&lt;/em&gt; (2018)&lt;sup&gt;1&lt;/sup&gt;. In the paper there are only CPLEX-solvable equations given by the authors and the results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How valuable is this paper, and what is its quality? Can we just provide equations,  tests, and results in a problem and publish a paper in a good journal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doesn't it require to prove the correctness of these equations related to the problem?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Cerna, F. V. &lt;em&gt;et al&lt;/em&gt;. (2018). Optimal Delivery Scheduling and Charging of EVs in the Navigation of a City Map. &lt;em&gt;IEEE Transactions on Smart Grid.&lt;/em&gt; 9(5):4815-4827. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="71" LastEditDate="2020-01-21T08:46:48.543" LastActivityDate="2020-01-21T08:46:48.543" Title="Publishing paper that uses LP solver to solve equation" Tags="|mixed-integer-programming|linear-programming|modeling|journals|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3346" PostTypeId="2" ParentId="3341" CreationDate="2020-01-17T22:41:35.983" Score="5" Body="&lt;p&gt;Here's one option:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad d\\\mathrm{s.t.}&amp;amp;\quad-d\le\frac{a^{*}}{a}-\frac{b^{*}}{b}\le d\\&#xA;&amp;amp;\quad-d\le\frac{a^*}a-\frac{c^*}c\le d\\&#xA;&amp;amp;\quad-d\le\frac{b^*}b-\frac{c^*}c\le d\\&#xA;&amp;amp;\quad R_\min\le a^*+b^*+c^*\le R_\max\\&#xA;&amp;amp;\quad0\le a^*\le a\\&#xA;&amp;amp;\quad0\le b^*\le b\\&#xA;&amp;amp;\quad0\le c^*\le c\\&#xA;&amp;amp;\quad d\ge0\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$R_\min$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R_\max$&lt;/span&gt; are respectively the minimum and maximum acceptable resource expenditures (both parameters). This is basically working with the absolute differences of the ratios. Forcing the decision maker to use at least some minimal amount of resources avoids the trivial solution (do nothing) being optimal, a risk Rob Pratt pointed out. An alternative to using &lt;span class=&quot;math-container&quot;&gt;$R_{min}$&lt;/span&gt; is to change the lower bounds of the three starred variables from &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to some multiple of their respective upper bounds (e.g., &lt;span class=&quot;math-container&quot;&gt;$\lambda a\le a^*\le a$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\lambda(a+b+c)\le R_\max$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="123" LastEditDate="2020-01-18T09:25:57.107" LastActivityDate="2020-01-18T09:25:57.107" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3347" PostTypeId="1" AcceptedAnswerId="5090" CreationDate="2020-01-18T10:55:17.000" Score="15" ViewCount="1055" Body="&lt;p&gt;For teaching purposes, I would like to solve the &lt;a href=&quot;https://en.wikipedia.org/wiki/Travelling_salesman_problem&quot; rel=&quot;noreferrer&quot;&gt;Travelling Salesman Problem&lt;/a&gt; with a column generation approach. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the academic literature, an approach is proposed (&lt;a href=&quot;https://docs.lib.purdue.edu/dissertations/AAI9939324/&quot; rel=&quot;noreferrer&quot;&gt;for example here&lt;/a&gt;), where columns are either &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;-trees or &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;-matchings. I don't find this approach very intuitive for teaching (but maybe I need to re-read it !). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the &lt;a href=&quot;https://en.wikipedia.org/wiki/Vehicle_routing_problem&quot; rel=&quot;noreferrer&quot;&gt;Vehicle Routing Problem&lt;/a&gt;, which obviously generalizes the TSP, there is the following classical (?) formulation :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; be the set of nodes.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; be the set of feasible routes (vehicles are assumed identical).&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$y_r$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if route &lt;span class=&quot;math-container&quot;&gt;$r \in R$&lt;/span&gt; with cost &lt;span class=&quot;math-container&quot;&gt;$c_r$&lt;/span&gt; is selected. So you want to minimize &#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{r\in R} c_r y_r&#xA;$$&lt;/span&gt;&#xA;subject to &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Each node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is visited exactly once :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{r \in R \mid v \in r} y_r = 1 \quad \forall v \in V&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;You cannot use more than say &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; vehicles :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{r \in R } y_r \le k&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This formulation is very intuitive. When relaxing the binary variables, you have your master problem. And your subproblem boils down to finding routes/columns/paths with minimum cost based on the duals of the solved relaxed master problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I find hard to explain is that this formulation is no longer relevant (or is it ?) if you only have &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; vehicle (in other words if you are solving the TSP). In this case, the formulation becomes :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \quad \sum_{r\in R} c_r y_r&#xA;$$&lt;/span&gt;&#xA;subject to &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{r \in R \mid v \in r} y_r &amp;amp;= 1 \quad \forall v \in V \\&#xA;\sum_{r \in R } y_r &amp;amp;= 1&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case a feasible route is a tour is visiting all nodes. And so the first constraint becomes useless and the master problem becomes equivalent to selecting the column with minimum cost. The whole problem is basically left to the sub-problem, where you need to find a Hamiltonian path with minimum cost. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So here are my questions&lt;/strong&gt; :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Am I correct to say that the VRP formulation is not relevant for the TSP ?&lt;/li&gt;&#xA;&lt;li&gt;Is there a similar approach that would work for the TSP ?&lt;/li&gt;&#xA;&lt;li&gt;Do you think the first approach (where columns are &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;-trees or &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;-matchings) is a good one (for teaching purposes primarily)?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2020-01-18T11:30:27.590" LastActivityDate="2021-06-07T18:06:16.470" Title="Column generation for TSP" Tags="|modeling|column-generation|traveling-salesman|dantzig-wolfe-decomposition|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3348" PostTypeId="2" ParentId="3341" CreationDate="2020-01-18T14:52:32.737" Score="3" Body="&lt;p&gt;Based on your comments, I have an alternative suggestion.  You had tried maximizing the &lt;em&gt;sum&lt;/em&gt; of &lt;span class=&quot;math-container&quot;&gt;$a^*/a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b^*/b$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$c^*/c$&lt;/span&gt;.  Maybe instead maximize the &lt;em&gt;minimum&lt;/em&gt; of these, which you can do linearly by introducing a new variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to be maximized, with additional constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z&amp;amp;\le a^*/a\\&#xA;z&amp;amp;\le b^*/b\\&#xA;z&amp;amp;\le c^*/c&#xA;\end{align}&lt;/span&gt;&#xA;This approach will not necessarily make the ratios similar, but it will try to prevent any of them from being small.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-01-18T14:52:32.737" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3349" PostTypeId="1" AcceptedAnswerId="3554" CreationDate="2020-01-18T18:47:00.713" Score="12" ViewCount="257" Body="&lt;p&gt;Given a list of (absolute valued) pair differences ordered and with duplicates removed, how can we recover/reconstruct the list that generated these differences? We do not know anything about the generating list, not the individual values and not its length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, the objective is to find the shortest possible generating list, but also to find all solutions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example: Given the (absolute valued) difference list of &lt;span class=&quot;math-container&quot;&gt;$$[1,6,7,8,12,13,14,15,19,20,21,26,27,33,34]$$&lt;/span&gt; we find the following solutions, i.e. lists that could have generated these pair differences: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$[1,2,9,16,22,28,35],[1,8,14,20,27,34,35],[1,2,8,16,22,28,35],[1,8,14,20,28,34,35]$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These solutions are &quot;normalized&quot; in that they always start with &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and end with &lt;span class=&quot;math-container&quot;&gt;$1+\max(\text{difference list})$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference list was actually generated by the list &lt;span class=&quot;math-container&quot;&gt;$[5,12,18,24,31,32,38,39]$&lt;/span&gt;. It is &quot;normalized&quot; (all numbers are subtracted by some constant integer) to &lt;span class=&quot;math-container&quot;&gt;$[1,8,14,20,27,28,34,35]$&lt;/span&gt; which happens to be one of the found solutions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have thought about this for some days now and written:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;a Picat (constraint programming) &lt;a href=&quot;http://hakank.org/picat/linear_combinations.pi&quot; rel=&quot;nofollow noreferrer&quot;&gt;model with some experiments&lt;/a&gt;. The model also handles cases where there are duplicates in the difference lists.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;a &lt;a href=&quot;http://hakank.org/minizinc/linear_combinations.mzn&quot; rel=&quot;nofollow noreferrer&quot;&gt;MiniZinc model&lt;/a&gt; implementing the base version. Here is a &lt;a href=&quot;http://hakank.org/minizinc/linear_combinations.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;MiniZinc-Python program&lt;/a&gt; for experimenting with the MiniZinc model.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;a draft describing the problem and &lt;a href=&quot;http://hakank.org/picat/Recover_origin_of_pair_differences.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;some experiments/findings/invariants&lt;/a&gt;. Unfortunately, right now it's not as &quot;formal&quot; as I would want it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;base model&lt;/strong&gt; that is described below has been implemented in the Picat model (link above). The description uses constraint programming parlance.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;origin&quot; list (generator): This &quot;origin&quot; list is not really in the model but it is essential to understand the model. The &quot;origin&quot; is the list that generates the list of pair differences that is the input of the model. The origin list is not known by the model and we don't know either its length or any of its elements (integers). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;objective of the model&lt;/strong&gt; is to find out what this origin list is, or rather some variant of it since in real use we don't know what the origin list is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let us call this origin list &lt;code&gt;L&lt;/code&gt; with length &lt;code&gt;Len&lt;/code&gt;. Then the difference list is calculated as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Get all the pair differences of &lt;code&gt;L&lt;/code&gt;: &lt;code&gt;L2 = [abs([L[I]-L[J]) : I in 1..Len, J in I+1..Len]&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sorting the pair difference list &lt;code&gt;L2&lt;/code&gt; and removing the duplicates give the sorted difference list: &lt;code&gt;Diffs = L2.sort_remove_dups&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note: This part is used in the model just to generate difference lists to test. The input to the model is the difference list.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;normalization&quot; of the origin: Each origin list can be normalized to a list which starts with &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. Let &lt;code&gt;L2&lt;/code&gt; be the sorted version of &lt;code&gt;L&lt;/code&gt; and with length &lt;code&gt;LLen&lt;/code&gt;. Then the normalized version is &lt;code&gt;[L2[I] - L2[1] + 1 : I in 1..LLen]&lt;/code&gt;, i.e. subtract all integers in the list &lt;code&gt;L2&lt;/code&gt; with the first value of the list and add &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; (the start value of the normalized list). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Instead of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; as the start value, we could use &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; instead (or any other value), but I tend to prefer that the list start with &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The concept of normalization is important since the solution of the model can be seen as a normalized version of the origin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;input&lt;/strong&gt; of the model is&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;diffs&lt;/code&gt;: The difference list that is generated by the (unknown) origin list as described above: it is an ordered list of distinct integers. It has length &lt;code&gt;len&lt;/code&gt; and a maximum value (the last value) &lt;code&gt;max_val&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;model&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The model loops through a value of lengths of the solution list, starting with &lt;code&gt;min_len&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;min_len&lt;/code&gt;: The minimum length of a possible solution. This value is calculated as &lt;span class=&quot;math-container&quot;&gt;$$\min\_\text{len}=\left\lfloor1+\frac{\sqrt{1+8\cdot\text{len}}}2\right\rfloor.$$&lt;/span&gt; The formula is based on the calculation of the number of difference pairs in a given list of length &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, which is given by &lt;span class=&quot;math-container&quot;&gt;$n(n-1)/2$&lt;/span&gt;. &#xA;Thus, given the length of the difference list (&lt;code&gt;len&lt;/code&gt;), the minimum length is &lt;code&gt;min_len&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For finding one of the shortest solutions, we loop over the the possible lengths (&lt;code&gt;n&lt;/code&gt;) of the solution list, from the minimum length &lt;code&gt;min_len&lt;/code&gt; to some (arbitrary) upper length. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I have not found a way of calculating this upper value given the inputs of the model. The upper value of the length of the solution is actually the length of the origin list, but in the model we don't know anything about the origin list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note 2: In most cases, the length of the solution is &lt;code&gt;min_length&lt;/code&gt; or some value slightly larger than that.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each loop of possible length &lt;code&gt;n&lt;/code&gt; (from &lt;code&gt;min_length&lt;/code&gt;) does the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;creates the list of decision variables &lt;code&gt;x&lt;/code&gt; of length &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;the minimum value of &lt;code&gt;x&lt;/code&gt; is 1 and the upper value is &lt;code&gt;max_val + 1&lt;/code&gt;, i.e. the domain is &lt;span class=&quot;math-container&quot;&gt;$\{1,\cdots,\max\_\text{val}+1\}$&lt;/span&gt;. The reason behind this upper value is that if the solution starts with &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, then the largest possible difference must be the largest difference value &lt;span class=&quot;math-container&quot;&gt;${}+ 1$&lt;/span&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The solution is thus thought of as a &quot;normalized&quot; version of the origin list, or rather a possible variant since there might be many different solutions where only one of then might be the same as the normalized version of the origin list.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;add constraints of the list &lt;code&gt;x&lt;/code&gt; as described below.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if we find a solution then it is a shortest solution. Normally the model is finished after this. But there are cases where we continue to find all the solutions or perhaps all the shortest solutions. (The Picat model does quite a few experiments with this.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;constraints&lt;/strong&gt; in the model are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;all_different(x)&lt;/code&gt;: Ensures that all the decision variables are distinct. Note that this is not really necessary since the next constraint &lt;code&gt;increasing_strict(x)&lt;/code&gt; ensures this as well. For constraint programming solvers, adding this constraint seems to speed up the model.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;increasing_strict(x)&lt;/code&gt;: Ensures that the decision variables are strictly ordered, i.e. distinct and sorted. The ordering part can be seen as a symmetry breaking to reduce a lot of symmetric solutions. The strict part is necessary for the model though. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note: In some experiments, the strict part is skipped so we can study origin lists and difference lists that contain duplicates. This is not discussed further here.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;x[1] = 1&lt;/code&gt;: the first element is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. This is to make the solution &quot;normalized&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;x[n] = max_val&lt;/code&gt;: the last element is &lt;code&gt;max_val&lt;/code&gt;, i.e. &lt;code&gt;1 + max(diffs)&lt;/code&gt;.  These two constraints make sure that the solution is &quot;normalized&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;All the pair differences in the solution &lt;code&gt;x&lt;/code&gt; must be in the difference list &lt;code&gt;diffs&lt;/code&gt;. The pseudo code for this is:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foreach(i in 1..n, j in i+1..n)&#xA;   abs(X[I]-X[J]) in diffs&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i.e. All possible pair differences in &lt;code&gt;x&lt;/code&gt; must be in the difference list.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ensure that we cover &lt;strong&gt;all&lt;/strong&gt; the differences in the difference list &lt;code&gt;diffs&lt;/code&gt;. Pseudo code:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foreach(d in diffs)&#xA;   % Create the indices i,j where I &amp;lt; J&#xA;   i in 1..n,&#xA;   j :: 1..n,&#xA;   i &amp;lt; j,&#xA;   d = abs(x[i]-x[j])&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;j&lt;/code&gt; are decision variables with domain &lt;span class=&quot;math-container&quot;&gt;$\{1,\cdots,n\}$&lt;/span&gt;. For all differences &lt;code&gt;d&lt;/code&gt; in the difference list, we try to find some indices &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;j&lt;/code&gt; (with &lt;code&gt;i &amp;lt; j&lt;/code&gt;) such that &lt;code&gt;d = abs(x[i]-x[j])&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two constraints above ensure that the solution list &lt;code&gt;x&lt;/code&gt; generates &lt;strong&gt;all&lt;/strong&gt; the differences in difference list &lt;code&gt;diffs&lt;/code&gt; as well as &lt;strong&gt;only&lt;/strong&gt; those differences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the &lt;strong&gt;end of the base model&lt;/strong&gt;. It is - as mentioned above - implemented in Picat and it works quite well. However, it would be interesting to know alternative approaches for solving this problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't found much about this, but perhaps the terms I searched for were not the proper ones. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One vaguely related paper is a paper by &lt;a href=&quot;https://arxiv.org/pdf/1410.6396.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;De Biasi (2014)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; about reconstruction permutations of length &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; given a permutation of differences of length &lt;span class=&quot;math-container&quot;&gt;$N-1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it only handles difference lists that are permutations, but I am interested in any difference lists, not just permutations. Also, the objective of the paper is to prove that the problem is NP-complete which is not my goal here. (Here is a &lt;a href=&quot;http://hakank.org/picat/reconstruction_permutations.pi&quot; rel=&quot;nofollow noreferrer&quot;&gt;Picat model&lt;/a&gt; that solves these kind of problems.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One other related thing is &lt;a href=&quot;https://oeis.org/wiki/User:Peter_Luschny/PerfectRulers&quot; rel=&quot;nofollow noreferrer&quot;&gt;perfect rulers&lt;/a&gt; where the difference lists are the full list of integers &lt;span class=&quot;math-container&quot;&gt;$1,\cdots,N$&lt;/span&gt;:    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perfect rulers might be seen as a special case of what I am interested in, but the general case of difference lists is that they may be non-contiguous. And the objective is not the same: I want to recover the list that generated the differences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have more information about this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] De Biasi, M. (2014). Permutation Reconstruction from Differences. &lt;em&gt;The Electronic Journal of Combinatorics.&lt;/em&gt; 21(4):P4.3. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="260" LastEditorUserId="123" LastEditDate="2020-01-20T19:17:41.790" LastActivityDate="2020-02-16T23:10:03.173" Title="Restoring a list from differences" Tags="|combinatorial-optimization|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="3350" PostTypeId="1" CreationDate="2020-01-19T14:48:36.507" Score="6" ViewCount="90" Body="&lt;p&gt;Until now, I have used the Gurobi, CPLEX and OR-Tools &lt;strong&gt;(GCO)&lt;/strong&gt; interface to formulate mixed-integer-programming models.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently, I have discovered MiniZinc and want to utilize it to formulate big models.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With GCO I would only initialize the decision variables I need and only give the data without all non-existent index combinations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Scheduling Example&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indices:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;: employee&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;: day&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;: shift&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;: skill&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This means, there are different employees, that can work on different days and different shifts within each day and the employees may also have different skills.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I visualize the data is in a &lt;strong&gt;2D matrix&lt;/strong&gt;. The &lt;strong&gt;row&lt;/strong&gt; has the &lt;strong&gt;employee index&lt;/strong&gt; and the &lt;strong&gt;column&lt;/strong&gt; the tuple of indices &lt;span class=&quot;math-container&quot;&gt;$(d,s,z)$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the employee Bob, is available on Monday, for the shift 2 pm to 8 pm and has the skill bartender he gets the value 1 otherwise 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid saving 0-values, I would construct Lists/HashMaps/Dictionaries that only contain non-zero elements. If for a certain index combination there is no entry within the lists then I do not construct any constraint with it or take it in consideration, hopefully saving computing time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure if this is the best way to optimize running-time, but after implementing this method it was much faster than giving the solver the whole matrix with 0 values (non-existent index combinations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I would like to implement something similar, within MiniZinc using Python. This means I have to somehow give the data in such a form to hopefully make the solver run faster, instead of giving a large 2D matrix with many 0-values.&lt;/p&gt;&#xA;" OwnerUserId="456" LastEditorUserId="981" LastEditDate="2023-12-22T14:48:11.620" LastActivityDate="2023-12-22T14:48:11.620" Title="Data Formulation for Mixed-Integer-Programming Models" Tags="|mixed-integer-programming|modeling|or-tools|data|minizinc|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3351" PostTypeId="1" AcceptedAnswerId="3417" CreationDate="2020-01-19T17:38:38.800" Score="6" ViewCount="295" Body="&lt;p&gt;I'm solving a large instance using Gurobi 7.0, 64-bit version on machine with 16GB of RAM. Gurobi is stuck at the start and all the memory is exhausted. Here is the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5378534 variables, all binary&#xA;16140318 constraints, all linear; 319218593 nonzeros&#xA;        77 equality constraints&#xA;        16140241 inequality constraints&#xA;1 linear objective; 4842072 nonzeros.&#xA;&#xA;#presolve       75.2705         1006633000      20529205440&#xA;#output         200.524         268435464       20797640904&#xA;Gurobi 7.0.0: timelim=3600&#xA;threads=2&#xA;nodefilestart=0.5&#xA;outlev 1&#xA;Optimize a model with 16140318 rows, 5378534 columns and 319218593 nonzeros&#xA;Variable types: 0 continuous, 5378534 integer (5378534 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [1e+00, 1e+03]&#xA;  Objective range  [1e+00, 4e+03]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [1e+00, 7e+04]&#xA;Found heuristic solution: objective -0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was expecting out of memory error, but Gurobi is just stuck for hours, and CPU usage is 0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this normal behavior for this instance size? Why am I not getting any errors? &lt;/p&gt;&#xA;" OwnerUserId="2961" LastEditorUserId="123" LastEditDate="2020-01-19T20:09:31.760" LastActivityDate="2020-01-27T14:15:00.477" Title="Gurobi stuck at start - 16GB RAM exhausted" Tags="|integer-programming|gurobi|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3352" PostTypeId="2" ParentId="3337" CreationDate="2020-01-19T18:55:18.087" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You could rewrite the two last constraints as &#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f(i_1,i_2)-g(i_1,i_2) = e_{i_1i_2}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$e_{i_1i_2}\in \mathbb{R}^+$&lt;/span&gt; is a continuous variable that equals the difference between the left hand term and right hand term (and so &lt;span class=&quot;math-container&quot;&gt;$f(i_1,i_2)$&lt;/span&gt; is your left hand term, and &lt;span class=&quot;math-container&quot;&gt;$g(i_1,i_2)$&lt;/span&gt; your right hand term), and then minimize this variable in the objective function (eventually multiplied by a coefficient).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;No, if you are working with linear programming, you cannot use the &lt;span class=&quot;math-container&quot;&gt;$\{&amp;lt;,&amp;gt;\}$&lt;/span&gt; signs.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I think you need to work on a rolling horizon, that is, write your model for the the first month, and after week &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, re-solve it. After week &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;, solve it again, and so forth. This of course implies that when you solve your problem, only the first week is definitely set. The other weeks are temporary and may change if balancing is required. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Although your model looks correct, have you considered other formulations such as a Dantzig-Wolfe decomposition? They fit your problem quite well : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}$&lt;/span&gt; be the set of feasible shifts (e.g., over a week, or why not a month if it is relevant), and let &lt;span class=&quot;math-container&quot;&gt;$y_s$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if shift &lt;span class=&quot;math-container&quot;&gt;$s\in \mathcal{S}$&lt;/span&gt; is selected. Your problem then requires that :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;shifts are satisfied each day :&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{s \in \mathcal{S} \mid j \in s, t\in s} y_s = n_{j} \quad \forall j \in \{\mbox{morning},\mbox{afternoon},\mbox{night}\}, \quad \forall t=1,\dots,7&#xA;$$&lt;/span&gt;&#xA;(this means that for each day, and each shift type, you only sum on the shifts that have a working period on that day, for that shift type)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you cannot have more than &lt;span class=&quot;math-container&quot;&gt;$\mid N \mid$&lt;/span&gt; shifts (&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; shift per nurse per week) :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{s \in \mathcal{S} } y_s \le|N|&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To balance the shifts, you could define a coefficient &lt;span class=&quot;math-container&quot;&gt;$c_{s_is_j}$&lt;/span&gt; for each pair of shifts that is more or less important if the shifts are pairwise balanced (e.g., &lt;span class=&quot;math-container&quot;&gt;$c_{s_is_j}=0$&lt;/span&gt; if the shifts are balanced, &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if they are moderately unbalanced and &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; if they are unbalanced). And so you could minimize &#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{s_i \in \mathcal{S}}\sum_{s_j \in \mathcal{S}} c_{s_is_j} \delta_{s_is_j}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\delta_{s_is_j}$&lt;/span&gt; is another binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if shifts &lt;span class=&quot;math-container&quot;&gt;$s_i, s_j$&lt;/span&gt; are both selected (so you would have to add &lt;span class=&quot;math-container&quot;&gt;$y_{s_i}+y_{s_j} \le \delta_{s_is_j} +1$&lt;/span&gt; to the model).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course this implies that you have generated your feasible shifts before hand (this is not too difficult). Alternatively, you could generate them dynamically if you are familiar with column generation. &lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2020-01-19T20:12:10.230" LastActivityDate="2020-01-19T20:12:10.230" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3353" PostTypeId="1" AcceptedAnswerId="3367" CreationDate="2020-01-19T19:31:05.067" Score="8" ViewCount="431" Body="&lt;p&gt;I am trying to solve Exercise 2.39 at Boyd and Vandenberghe's Convex Optimization book. In one &lt;a href=&quot;http://egrcc.github.io/docs/math/cvxbook-solutions.pdf&quot; rel=&quot;noreferrer&quot;&gt;source&lt;/a&gt;, the answer is given as:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;2.39&lt;/strong&gt; &lt;em&gt;Separation of cones.&lt;/em&gt; Let &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\tilde K$&lt;/span&gt; be two convex cones whose interiors are nonempty and disjoint. Show that there is a nonzero &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$y\in K^*$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$-y\in\tilde K^*$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Solution.&lt;/strong&gt; Let &lt;span class=&quot;math-container&quot;&gt;$y\ne0$&lt;/span&gt; be the normal vector of a separating hyperplane separating the interiors: &lt;span class=&quot;math-container&quot;&gt;$y^\top x\ge\alpha$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$x\in\boldsymbol{\operatorname{int}}K_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^\top x\le\alpha$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$x\in\boldsymbol{\operatorname{int}}K_2$&lt;/span&gt;. We must have &lt;span class=&quot;math-container&quot;&gt;$\alpha=0$&lt;/span&gt; because &lt;span class=&quot;math-container&quot;&gt;$K_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$K_2$&lt;/span&gt; are cones, so if &lt;span class=&quot;math-container&quot;&gt;$x\in\boldsymbol{\operatorname{int}}K_1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$tx\in\boldsymbol{\operatorname{int}}K_1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$t&amp;gt;0$&lt;/span&gt;. This means that &lt;span class=&quot;math-container&quot;&gt;$$y\in(\boldsymbol{\operatorname{int}}K_1)^*=K_1^*,\quad-y\in(\boldsymbol{\operatorname{int}}K_2)^*=K_2^*.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I don't get the final part &lt;span class=&quot;math-container&quot;&gt;$(\boldsymbol{\operatorname{int}}K)^* = K^*$&lt;/span&gt;. Why is this a valid equality? My idea is because if a boundary point of &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$y^\top x &amp;lt; 0$&lt;/span&gt; this would contradict &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{\operatorname{int}}K$&lt;/span&gt; being an open set, but I can not formalize this.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-01-21T07:37:06.357" Title="Convex Optimization: Separation of Cones" Tags="|convexity|convex-optimization|cone|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3355" PostTypeId="1" AcceptedAnswerId="3356" CreationDate="2020-01-20T11:50:22.623" Score="4" ViewCount="160" Body="&lt;p&gt;I am working on an LP problem where I have to model a constraint as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;The total number of units of product A and B should be shipped in multiples of &lt;span class=&quot;math-container&quot;&gt;$1200$&lt;/span&gt;&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. &lt;span class=&quot;math-container&quot;&gt;$700\text{(product A)} + 500\text{(product B)} = 1200\times1 = 1200$&lt;/span&gt;&#xA;or&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1800\text{(product A)} + 600\text{(product B)} = 1200\times2 = 2400$&lt;/span&gt;&#xA;or &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$2000\text{(product A)} + 1600\text{(product B)} = 1200\times3 = 3600$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;like that maximum shipment should be &lt;span class=&quot;math-container&quot;&gt;$6000$&lt;/span&gt; units &lt;span class=&quot;math-container&quot;&gt;$(1200\times5)$&lt;/span&gt;, or I can say in other words as I can only ship &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; batches of &lt;span class=&quot;math-container&quot;&gt;$1200$&lt;/span&gt; units each.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can somebody please help me to write such a constraint in algebraic form: &#xA;&lt;span class=&quot;math-container&quot;&gt;$Xa + Xb = $&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2780" LastEditorUserId="123" LastEditDate="2020-01-20T19:11:07.020" LastActivityDate="2020-01-20T19:11:07.020" Title="How to model shipment size constraint?" Tags="|linear-programming|modeling|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3356" PostTypeId="2" ParentId="3355" CreationDate="2020-01-20T12:37:49.617" Score="7" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_p$&lt;/span&gt; denotes the quantity of product &lt;span class=&quot;math-container&quot;&gt;$p\in P$&lt;/span&gt; that is shipped :&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{p\in P}x_p &amp;amp;= 1200 k \\&#xA;k &amp;amp;\in \mathbb{N} \\&#xA;x_p &amp;amp;\in \mathbb{R}^+&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2020-01-20T19:09:49.467" LastActivityDate="2020-01-20T19:09:49.467" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3357" PostTypeId="1" CreationDate="2020-01-20T14:17:07.677" Score="16" ViewCount="1892" Body="&lt;p&gt;Are there any books on Operations Research subjects by world-famous authors which have been made available for free access on the web, despite never having been &amp;quot;completed&amp;quot; to the standard to which the authors aspired?&lt;/p&gt;&#xA;&lt;p&gt;I would also accept completed books as well.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="491" LastEditDate="2021-02-08T17:13:04.343" LastActivityDate="2021-02-12T04:34:45.730" Title="Are there Operations Research books by world-famous authors made available on the web?" Tags="|online-resources|books|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3358" PostTypeId="2" ParentId="3357" CreationDate="2020-01-20T14:17:07.677" Score="13" Body="&lt;p&gt;Just posted on January 16, 2020:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/ftp/arxiv/papers/2001/2001.06005.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Elements of Scheduling, collected and edited by Jan Karel Lenstra and David B. Shmoys&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This {pdf file} presents the fragments of a book on machine scheduling.&#xA;Work on the book started in 1977 but was never completed. The existing&#xA;material is now made available for teaching purposes.&lt;/p&gt;&#xA;&lt;p&gt;In the winter of 1976, Alexander Rinnooy Kan and Jan Karel Lenstra&#xA;defended their PhD theses at the University of Amsterdam. Gene Lawler&#xA;was on their committees. It was a natural idea to turn the theses into&#xA;a textbook on scheduling. They set out to compile a survey with Ron&#xA;Graham (1979), but progress on the book was hampered by the many&#xA;research opportunities offered by the field. After David Shmoys joined&#xA;the team in the mid 1980's, several chapters were drafted, and the&#xA;survey was rewritten (1993). Gene passed away in 1994. Colleagues were&#xA;asked to contribute chapters or to complete existing drafts. However,&#xA;by the turn of the century the project was losing its momentum, and&#xA;finite convergence to completion fell beyond our reach. Over the&#xA;years, several chapters have been used in the classroom. We continue&#xA;to receive requests from colleagues who look for a text on the&#xA;elements of scheduling at an advanced undergraduate or early graduate&#xA;level. This document is a compilation of what currently exists. We&#xA;have made a marginal effort in patching it up at some places but is&#xA;essentially what was written long ago. We did make an attempt to&#xA;include most of the citations in the bibliography.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Completed books:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Convex Optimization, by Boyd and Vandenberghe&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="491" LastEditDate="2021-02-03T18:16:28.917" LastActivityDate="2021-02-03T18:16:28.917" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3359" PostTypeId="1" AcceptedAnswerId="3361" CreationDate="2020-01-20T14:17:11.590" Score="8" ViewCount="475" Body="&lt;p&gt;I'm trying to write this constraint in C++ and add it to my model (&lt;code&gt;addLessOrEqual&lt;/code&gt;):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{start}_{i}+\text{duration}_{i}\le\text{start}_{j}$$&lt;/span&gt; for an &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; arc of precedence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starts (&lt;code&gt;IntVar&lt;/code&gt;) and durations (&lt;code&gt;int&lt;/code&gt;) are part of an &lt;code&gt;IntervalVar&lt;/code&gt;. The problem is that I can't operate &lt;span class=&quot;math-container&quot;&gt;$+$&lt;/span&gt; with &lt;code&gt;IntVar&lt;/code&gt; and &lt;code&gt;Int&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using C++ and i get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    error: no match for ‘operator+’ (operand types are &#xA;‘__gnu_cxx::__alloc_traits&amp;lt;std::allocator&amp;lt;operations_research::sat::IntVar&amp;gt; &#xA;&amp;gt;::value_type {aka operations_research::sat::IntVar}’ and &#xA;‘__gnu_cxx::__alloc_traits&amp;lt;std::allocator&amp;lt;int&amp;gt; &amp;gt;::value_type {aka int}’)&#xA;                 cp_model.AddLessOrEqual(starts[j]+durations[j],starts[succ[j][s]])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What can I do to sum and get the expression? Is there another predefined constraint that does the same?&#xA;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="123" LastEditDate="2020-01-20T19:14:15.663" LastActivityDate="2020-01-20T19:14:15.663" Title="Precedence Constraint in OR-Tools" Tags="|constraint-programming|or-tools|c++|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3360" PostTypeId="2" ParentId="3357" CreationDate="2020-01-20T15:04:49.703" Score="16" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;a href=&quot;https://www.warehouse-science.com/book/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Warehouse &amp;amp; Distribution Science&lt;/a&gt; by John J. Bartholdi III and Steven T. Hackman. From their site:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This book is a work-in-progress. We are still revising and extending the material and suggest you print only what you need as you need it.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Version 0.98.1, released 17 August 2019&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Although the question was about books not being completed, I also list the following books that are available online for free and they are from famous authors, in case someone finds them useful.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Several books by Dimitri P. Bertsekas which their pdf copies can be accessed from &lt;a href=&quot;http://www.mit.edu/~dimitrib/books.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt; including:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Network Optimization: Continuous and Discrete Models (&lt;a href=&quot;http://web.mit.edu/dimitrib/www/net.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Convex Optimization Theory (&lt;a href=&quot;http://web.mit.edu/dimitrib/www/Convex_Alg_Chapters.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Constrained Optimization and Lagrange Multiplier Methods (&lt;a href=&quot;http://web.mit.edu/dimitrib/www/lagr_mult.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2020-02-05T18:57:53.803" LastActivityDate="2020-02-05T18:57:53.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3361" PostTypeId="2" ParentId="3359" CreationDate="2020-01-20T15:44:11.820" Score="8" Body="&lt;p&gt;What you want is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AddLessOrEqual(LinearExpr(starts[j]).AddConstant(durations[j]), starts[succ[j][s]])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might also want to take a look at the examples (ending with &lt;code&gt;_sat.cc&lt;/code&gt;) to be more familiar with the c++ methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/google/or-tools/tree/master/examples/cpp&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/google/or-tools/tree/master/examples/cpp&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="991" LastActivityDate="2020-01-20T15:44:11.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3362" PostTypeId="1" AcceptedAnswerId="3363" CreationDate="2020-01-20T16:56:04.640" Score="5" ViewCount="2605" Body="&lt;p&gt;I'm trying to solve an rcpsp model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find documentation for the &lt;code&gt;AddCumulative&lt;/code&gt; function of OR-Tools. How should this function be used?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to write this constraint in C++:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\forall k \in R,\quad\text{cumulative}(s, p_{j}, [r_{jk}\mid j\in J\mid R_{k}])$$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is my decision variable, a vector that saves the period of when the job begins, &lt;span class=&quot;math-container&quot;&gt;$p_{j}$&lt;/span&gt; is the duration of activity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$r_{jk}$&lt;/span&gt; is the amount of resource used by activity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R_{k}$&lt;/span&gt; is the capacity of the resource &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; each day), but the OR-Tools module apparently takes only one argument, although I've seen some examples where it takes 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, if I give the function the parameter RHS, which is the resource capacity (what it is asking for), I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;no matching function for call to ‘operations_research::sat::CpModelBuilder::AddCumulative(int*&amp;amp;)’&#xA;     cp_model.AddCumulative(rhs);&#xA;                               ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In addition, the command prompt says that RHS must be &lt;code&gt;IntVar&lt;/code&gt; but is &lt;code&gt;int&lt;/code&gt;.&#xA;So, my question is, what is the capacity that the function must take? And what happens with the other values like &lt;code&gt;IntervalVar&lt;/code&gt; and resource consumption by job?&lt;/p&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="123" LastEditDate="2020-01-20T19:21:20.000" LastActivityDate="2020-01-21T15:17:12.970" Title="Cumulative Constraint OR-Tools" Tags="|constraint-programming|or-tools|c++|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3363" PostTypeId="2" ParentId="3362" CreationDate="2020-01-20T19:04:58.630" Score="7" Body="&lt;p&gt;If you look at &lt;a href=&quot;http://google.github.io/or-tools/cpp_sat/classoperations__research_1_1sat_1_1CpModelBuilder.html#a7eaa53689ca6adc2a83db42dfb81e2ed&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR-Tools: CumulativeConstraint&lt;/a&gt;, &lt;code&gt;AddCumulative&lt;/code&gt; takes a variable as argument, so if it is constant, create a variable with a fixed domain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It returns a &lt;code&gt;CumulativeConstraint&lt;/code&gt; with a method to add (&lt;code&gt;IntervalVar&lt;/code&gt;, &lt;code&gt;DemandVar&lt;/code&gt;) pairs to the constraint. See &lt;a href=&quot;http://google.github.io/or-tools/cpp_sat/classoperations__research_1_1sat_1_1CumulativeConstraint.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR-Tools 7.4: C++ Reference (CumulativeConstraint)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the rcpcp solver is implemented in python &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/python/rcpsp_sat.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a C++ code snippet with the cumulative constraint:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  const IntervalVar x = cp_model.NewIntervalVar(cp_model.NewIntVar({0, 20}),&#xA;                                                cp_model.NewConstant(5),&#xA;                                                cp_model.NewIntVar({0, 20}));&#xA;  const IntervalVar y = cp_model.NewIntervalVar(cp_model.NewIntVar({0, 20}),&#xA;                                                cp_model.NewConstant(5),&#xA;                                                cp_model.NewIntVar({0, 20}));&#xA;  const IntVar a = cp_model.NewIntVar({5, 10});&#xA;  const IntVar b = cp_model.NewIntVar({5, 10});&#xA;  const IntVar c = cp_model.NewIntVar({5, 10});&#xA;&#xA;  CumulativeConstraint cumul = cp_model.AddCumulative(a);&#xA;  cumul.AddDemand(x, b);&#xA;  cumul.AddDemand(y, c);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2020-01-21T15:17:12.970" LastActivityDate="2020-01-21T15:17:12.970" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3364" PostTypeId="1" CreationDate="2020-01-20T19:47:34.083" Score="13" ViewCount="992" Body="&lt;p&gt;Reading gurobi reference manual I found this:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;We have also found that certain classes of MIP models benefit from reducing the thread count, often all the way down to one thread. Starting multiple threads introduces contention for machine resources. For classes of models where the first solution found by the MIP solver is almost always optimal, and that solution isn't found at the root, it is often better to allow a single thread to explore the search tree uncontended.&lt;/p&gt;&#xA;&lt;p&gt;Another situation where reducing the thread count can be helpful is when memory is tight. Each thread can consume a significant amount of memory.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In the past, when I used a shared server, users were requested by IT to manually limit our thread limit to 1. Now I am working on a dedicated server with 8 threads available.&lt;/p&gt;&#xA;&lt;p&gt;As we can see from gurobi's manual, one could choose which thread limit benefits your goals (for worse or better), so that the maximum number might not be the case for better/faster results.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The Question&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For an academic research and publishing, what is the fair practice when comparing comercial solver results with non parallelized heuristics?&lt;/p&gt;&#xA;" OwnerUserId="2397" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-01-21T07:37:58.237" Title="How fair is limit solver threads when publishing?" Tags="|solver|academia|computational-experiments|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3365" PostTypeId="2" ParentId="3364" CreationDate="2020-01-20T22:23:41.443" Score="7" Body="&lt;p&gt;The problem is, even if you use the same number of threads, a 'rigorous' comparison of different implementations in different programming languages - for example, in terms of running time or of the quality of the solution found in the same time limit - can be quite challenging or tricky. Citing Chapter 18 of Ahuja, Magnanti &amp;amp; Orlin&lt;sup&gt;1&lt;/sup&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;The existing literature on computational testing has a  tendency to overrely on CPU time as the primary measure of performance. CPU time depends greatly on subtle details of the computational environment and the test problems such as (1) the chosen programming language, compiler, and computer; (2) the implementation style and skill of the programmer; (3) network generators used to generate the random test problems; (4) combinations of input size parameters; and (5) the particular programming environment (e.g., the use of the computer system by other users). Be-cause of the multiple sources of variabilities, CPU times are often difficult to replicate, which is contrary to the spirit of scientific investigation. Another drawback of the use of CPU time is that it is an aggregate measure of empirical performance and does not provide much insight about an algorithm's behavior. For example, an algorithm generally performs some fundamental operations repeatedly, and a typical CPU time analysis does not help us to identify these &quot;bottleneck&quot; operations. Identifying the bottleneck operations of an algorithm can provide useful guidelines for where to direct future efforts to understand and subsequently improve an algorithm.&quot; &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From the last citation, most likely points (1) and (2) - and probably (3) - will affect comparison of optimization algorithm performance and should be taken into account. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To the best of my knowledge - what I remember after being to talks of academics reading publications -, they tend to mention reducing the number of cores to 1 (in case of comparing to non-parallelized heuristics) and more importantly turning off all kind of additional &lt;em&gt;intelligence&lt;/em&gt; the commercial solver may include (e.g. presolve, automatic cutting plane generation), in order to the performance comparison to be as fair and unbiased as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; Ahuja, R. K., Magnanti, T. L., &amp;amp; Orlin, J. B. (1988). Network flows.&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="123" LastEditDate="2020-01-21T07:37:58.237" LastActivityDate="2020-01-21T07:37:58.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3366" PostTypeId="2" ParentId="3364" CreationDate="2020-01-20T23:56:49.183" Score="6" Body="&lt;p&gt;Personal opinion: I think it is fair to use as many threads as makes sense in context. For instance, when I use CPLEX I believe it defaults to four threads (one per core on my PC). If I'm solving a problem that is a particular memory hog, I may throttle back to three or even two threads to avoid memory problems. I have no compunction about comparing any of those runs (2, 3 or 4 threads) to a single-threaded heuristic, provided that I document that the heuristic was single threaded and CPLEX was not (or at least document that CPLEX was using default parameter settings, which would imply multiple threads).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, I have no objection to someone comparing a single-threaded heuristic to a commercial solver limited to a single thread, provided that they state the limitation on the commercial solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I do not think it is typical to pit a heuristic against a commercial solver in a speed test. In addition to the comparability problems alluded to in dhasson's answer (CPLEX: highly optimized C/C++ code written by experts; heuristic: crappy Java code written by an amateur, i.e., me), it's a bit of an apples-oranges comparison because solvers produce proof of optimality (or at least gap measurements) and heuristics generally do not. You can use CPLEX, Gurobi or some other solver in &quot;heuristic mode&quot; (use parameter settings to maximize the chance of improving the primal bound, ignore the dual bound), in which case it's more of an apples-to-apples comparison. &lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-01-20T23:56:49.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3367" PostTypeId="2" ParentId="3353" CreationDate="2020-01-21T00:29:12.713" Score="2" Body="&lt;p&gt;Ok, after seeing the wrong attempt below which has been edited multiple times, I believe it is time to close this question. I will just leave my attempt:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume &lt;span class=&quot;math-container&quot;&gt;$K^* \neq (\operatorname{int}K)^*$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$\exists x_0 \in \operatorname{bd} K: \ x_0^\top y &amp;lt; 0$&lt;/span&gt;. Because of the strict inequality, we know that we can take a very small ball around &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt;, say &lt;span class=&quot;math-container&quot;&gt;$B(x_0)$&lt;/span&gt; and all the points &lt;span class=&quot;math-container&quot;&gt;$x' \in B(x_0)$&lt;/span&gt; will have &lt;span class=&quot;math-container&quot;&gt;$x'^\top y &amp;lt; 0$&lt;/span&gt;. By the definition of the boundary, we have &lt;span class=&quot;math-container&quot;&gt;$(B(x_0) \cap \operatorname{int} K)\neq \emptyset $&lt;/span&gt; hence for some &lt;span class=&quot;math-container&quot;&gt;$x \in \operatorname{int}K$&lt;/span&gt; we have &lt;span class=&quot;math-container&quot;&gt;$x^\top y &amp;lt; 0$&lt;/span&gt;, which is a contradiction. Hence &lt;span class=&quot;math-container&quot;&gt;$K^* = \operatorname{int}K^*$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="123" LastEditDate="2020-01-21T07:37:06.357" LastActivityDate="2020-01-21T07:37:06.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3368" PostTypeId="2" ParentId="3353" CreationDate="2020-01-21T00:38:14.370" Score="1" Body="&lt;p&gt;A new approach focusing only on &lt;span class=&quot;math-container&quot;&gt;$(\boldsymbol{\operatorname{int}}K)^* = K^*$&lt;/span&gt;, since that seems to be the biggest problem to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From section 2.6 of Convex Optimization (Boyd, Vanderberghe) we have that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(3) &lt;span class=&quot;math-container&quot;&gt;$K^*$&lt;/span&gt; is closed and convex.&lt;/li&gt;&#xA;&lt;li&gt;(1) &lt;span class=&quot;math-container&quot;&gt;$K^{**}$&lt;/span&gt; is the closure of the convex hull. &lt;/li&gt;&#xA;&lt;li&gt;(2) For &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; convex and closed, &lt;span class=&quot;math-container&quot;&gt;$K^{**} = K$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I will add a conjecture:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(X) The dual cone of a closed and convex cone is unique.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now, we know that &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is the closure of the convex hull of &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{\operatorname{int}}K $&lt;/span&gt;, that is, &lt;span class=&quot;math-container&quot;&gt;$(\boldsymbol{\operatorname{int}}K)^{**}=K $&lt;/span&gt; (1).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is convex and closed, such that &lt;span class=&quot;math-container&quot;&gt;$ K = K^{**} =  (\boldsymbol{\operatorname{int}}K)^{**} $&lt;/span&gt; (2). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both &lt;span class=&quot;math-container&quot;&gt;$ K^{*}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$  (\boldsymbol{\operatorname{int}}K)^{*} $&lt;/span&gt; are closed and convex (3), therefore, &lt;span class=&quot;math-container&quot;&gt;$K^{**} =  (\boldsymbol{\operatorname{int}}K)^{**} \iff K^{*} =  (\boldsymbol{\operatorname{int}}K)^{*}$&lt;/span&gt; (X).&lt;/p&gt;&#xA;" OwnerUserId="2850" LastEditorUserId="123" LastEditDate="2020-01-21T07:34:04.527" LastActivityDate="2020-01-21T07:34:04.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3369" PostTypeId="1" CreationDate="2020-01-21T03:47:30.760" Score="7" ViewCount="134" Body="&lt;p&gt;How to express a chain of boolean If-then as MIP such as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$(x_{10} \ge b_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{11} \le b_1)$&lt;/span&gt; AND &lt;span class=&quot;math-container&quot;&gt;$(x_{20} \ge b_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{21} \le b_2)$&lt;/span&gt;... AND... then &lt;span class=&quot;math-container&quot;&gt;$y_1 = 1$&lt;/span&gt; else &lt;span class=&quot;math-container&quot;&gt;$y_1 = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically, if constants are between values of different &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; (lower and upper bounds for every constant) then &lt;span class=&quot;math-container&quot;&gt;$y = 1$&lt;/span&gt;, if at least one constant is out of bound then &lt;span class=&quot;math-container&quot;&gt;$y = 0$&lt;/span&gt;. &#xA;I need to maximize sum of all &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2966" LastEditorUserId="2477" LastEditDate="2020-01-21T07:29:18.053" LastActivityDate="2020-01-21T13:53:13.333" Title="Expressing a chain of boolean if-then with logical ANDs using MIP" Tags="|optimization|mixed-integer-programming|modeling|logical-constraints|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3370" PostTypeId="1" CreationDate="2020-01-21T05:53:12.193" Score="11" ViewCount="239" Body="&lt;p&gt;I am willing to work on queuing models but in classical queuing models, it is assumed the probability distributions of arrival and service are known or at least the rate is known. However, I am willing to work on the case when there is not complete information about parameters and they are learned over time. Can I know if it is possible to model this problem? Moreover, how is it possible to use machine learning algorithms in queuing models?&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2020-01-22T01:01:03.927" Title="Queuing Theory with Learning Perspective" Tags="|machine-learning|queuing-theory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3371" PostTypeId="2" ParentId="3322" CreationDate="2020-01-21T08:08:13.887" Score="4" Body="&lt;p&gt;On the solving side, some hot topics include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;presolving techniques&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;GPU-powered algorithms&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;algorithms designed for problems that consume a lot of memory&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;algorithms for distributed architectures&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;decompositions&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;quantum computing optimisation algorithms&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;large-scale factorisation algorithms/implementation&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;domain reduction techniques&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;automatic differentiation algorithms, especially for spatially challenging problems and gray-box problems&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;improving numerical stability, either by using non-floating point numbers, or by using specialised hardware, or both&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;graph manipulation algorithms/implementations&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-01-21T08:08:13.887" CommentCount="0" CommunityOwnedDate="2020-02-09T13:58:45.160" ContentLicense="CC BY-SA 4.0" />
  <row Id="3373" PostTypeId="2" ParentId="3370" CreationDate="2020-01-21T13:38:45.747" Score="8" Body="&lt;p&gt;Certainly, and to take the problem's structure into account, one could model the queue knowing - or guessing - prior information about the queue's structure and/or parameter distribution and use Bayesian inference. See for example the following sources and their references:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Armero, C., &amp;amp; Bayarri, M. J. (1994). Bayesian prediction in M/M/1 queues. Queueing Systems, 15(1-4), 401-417.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Ausın, M. C., Wiper, M. P., &amp;amp; Lillo, R. E. (2004). Bayesian estimation for the M/G/1 queue using a phase-type approximation. Journal of Statistical Planning and Inference, 118(1-2), 83-101.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Bingham, N. H., &amp;amp; Pitts, S. M. (1999). Nonparametric inference from M/G/l busy periods. Stochastic Models, 15(2), 247-272.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Hansen, M. B., &amp;amp; Pitts, S. M. (2006). Nonparametric inference from the M/G/1 workload. Bernoulli, 12(4), 737-759.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Muddapur, M. V. (1972). Bayesian estimates of parameters in some queueing models. Annals of the Institute of Statistical Mathematics, 24(1), 327-331.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Rohrscheidt, F. M. V. (2017). Bayesian Nonparametric Inference for Queueing Systems (Doctoral dissertation). &lt;a href=&quot;https://archiv.ub.uni-heidelberg.de/volltextserver/23131/1/Dissertation%20FM%20von%20Rohrscheidt.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Available online here&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Shestopaloff, A. Y., &amp;amp; Neal, R. M. (2014). On Bayesian inference for the M/G/1 queue with efficient MCMC sampling. arXiv preprint arXiv:1401.5548.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sutton, C. A., &amp;amp; Jordan, M. I. (2008, December). Probabilistic inference in queueing networks. In SysML.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I know you mentioned Machine Learning, but as you want to pay attention to incomplete information regarding the parameters and learning over time, I think classic Bayesian Modelling should to be given a try. Moreover: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The above publication by Hansen &amp;amp; Pitts studies sufficient conditions for the empirical process to converge weakly to a Gaussian Process (Gaussian Processes are considered a probabilistic approach to learning in kernel machines - like a probabilistic counterpart to Support Vector Machines). In the final sections they provide experimental results for different service time distributions.&lt;/li&gt;&#xA;&lt;li&gt;The one by Sutton &amp;amp; Jordan considers Gibbs sampling and Expectation Maximization, which are again related to Machine Learning (its authors are also quite renowned in the Machine Learning field).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="2477" LastEditDate="2020-01-22T01:01:03.927" LastActivityDate="2020-01-22T01:01:03.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3374" PostTypeId="2" ParentId="3369" CreationDate="2020-01-21T13:42:20.807" Score="7" Body="&lt;p&gt;Because you are maximizing the sum of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, as long as each &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; appears in no other constraints, you can get by with enforcing only one direction of the implication, namely &lt;span class=&quot;math-container&quot;&gt;$$y_1=1\implies (x_{10}\ge b_1 \land x_{11}\le b_1 \land \dots).$$&lt;/span&gt; You can do this with one big-M constraint for each inequality, where &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; are (constant) lower and upper bounds on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;b_1-x_{10}&amp;amp;\le (b_1-\ell_{10})(1-y_1)\\&#xA;x_{11}-b_1&amp;amp;\le (u_{11}-b_1)(1-y_1)\\&#xA;b_2-x_{20}&amp;amp;\le (b_2-\ell_{20})(1-y_1)\\&#xA;x_{21}-b_2&amp;amp;\le (u_{21}-b_2)(1-y_1)\\&#xA;&amp;amp;\dots&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-01-21T13:53:13.333" LastActivityDate="2020-01-21T13:53:13.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3375" PostTypeId="1" CreationDate="2020-01-21T14:15:55.723" Score="5" ViewCount="1529" Body="&lt;p&gt;Question:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A set &lt;span class=&quot;math-container&quot;&gt;$S \subset \mathbb{R}^m \times \mathbb{R}^n$&lt;/span&gt; is convex. &lt;strong&gt;Using the fact that affine maps preserves convexity&lt;/strong&gt; prove that &lt;span class=&quot;math-container&quot;&gt;$S(y) = \{x \in \mathbb{R}^m\mid (x,y)\in S \}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\hat{S} = \{ x \in \mathbb{R}^m \mid \exists y \in \mathbb{R}^n, \ (x,y) \in S  \}$&lt;/span&gt; are convex sets.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In Boyd's book, Chapter 2.3.2. says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The &lt;em&gt;projection&lt;/em&gt; of a convex set onto some of its coordinates is convex: if &lt;span class=&quot;math-container&quot;&gt;$S \subseteq \mathbb{R}^m \times \mathbb{R}^n$&lt;/span&gt; is convex, then &lt;span class=&quot;math-container&quot;&gt;$$T = \{x_1 \in \mathbb{R}^m\mid(x_1,x_2)\in S \text{ for some } x_2 \in \mathbb{R}^n \} $$&lt;/span&gt; is convex.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Does this mean the question I have is somehow showing a projection can be written as an affine map? Is this very straightforward, or am I missing something?&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="123" LastEditDate="2020-01-21T16:22:26.940" LastActivityDate="2020-01-21T16:22:26.940" Title="Convexity of the projection of a convex set" Tags="|convexity|convex-optimization|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3377" PostTypeId="5" CreationDate="2020-01-21T17:37:34.357" Score="0" Body="&lt;p&gt;The General Algebraic Modeling System (&lt;a href=&quot;http://en.wikipedia.org/wiki/General_Algebraic_Modeling_System&quot; rel=&quot;nofollow noreferrer&quot;&gt;GAMS&lt;/a&gt;) is a high-level modeling system for mathematical optimization. GAMS is designed for modeling and solving linear, nonlinear, and mixed-integer optimization problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/General_Algebraic_Modeling_System&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gams.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GAMS Development Corporation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gams.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GAMS Software GmbH&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gamsworld.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GAMS World&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="2477" LastEditDate="2020-01-21T18:08:08.570" LastActivityDate="2020-01-21T18:08:08.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3378" PostTypeId="4" CreationDate="2020-01-21T17:37:34.357" Score="0" Body="For questions related to GAMS (General Algebraic Modeling System), a high-level modeling system for mathematical optimization." OwnerUserId="2477" LastEditorUserId="2477" LastEditDate="2020-01-21T20:38:17.160" LastActivityDate="2020-01-21T20:38:17.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3379" PostTypeId="1" CreationDate="2020-01-21T18:46:49.900" Score="6" ViewCount="165" Body="&lt;p&gt;I want to turn this objective function    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max \sum_{i=1}^{N-1} \sum_{j=i+1}^N |TX_i^T - TX_j^T|$$&lt;/span&gt;   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is just a vector with increasing integers (e.g &lt;span class=&quot;math-container&quot;&gt;$[1 \ 2]$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt; is a vector with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables like &lt;span class=&quot;math-container&quot;&gt;$[x_{11} \ x_{12}]$&lt;/span&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to turn this objective function into a linear form?&lt;br&gt;&#xA;And how can I do that?&lt;br&gt;&#xA; My problem is that I don't quite fully understand it when I have to &lt;em&gt;maximize&lt;/em&gt; the objective function.&lt;/p&gt;&#xA;" OwnerUserId="2970" LastEditorUserId="123" LastEditDate="2020-01-22T08:06:43.057" LastActivityDate="2020-01-22T08:06:43.057" Title="Linearizing objective function with absolute differences" Tags="|linear-programming|linearization|absolute-value|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3380" PostTypeId="2" ParentId="3226" CreationDate="2020-01-21T19:35:47.873" Score="4" Body="&lt;p&gt;Other options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Run your model from the command line using &lt;code&gt;oplrun&lt;/code&gt;. Using option &lt;code&gt;-d&lt;/code&gt; you can specify to dump your model into a &lt;code&gt;cpo&lt;/code&gt; file.&lt;/li&gt;&#xA;&lt;li&gt;Specify environment variable &lt;code&gt;ILC_MODEL_DUMP_FILE&lt;/code&gt;. Before solving the model CP Optimizer tests this variable and if present it dumps the current model into the specified file (the variable can also specify the path to the file). It works for all applications that are using CP Optimizer, not only for OPL.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2971" LastEditorUserId="354" LastEditDate="2020-01-21T20:37:47.803" LastActivityDate="2020-01-21T20:37:47.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3381" PostTypeId="2" ParentId="3379" CreationDate="2020-01-21T19:55:04.083" Score="4" Body="&lt;p&gt;Introduce a new variable &lt;span class=&quot;math-container&quot;&gt;$z_{i,j}$&lt;/span&gt; to represent the summand, and apply the linearization of &lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; described &lt;a href=&quot;https://or.stackexchange.com/questions/711/how-to-formulate-maximum-function-in-a-constraint/712#712&quot;&gt;here&lt;/a&gt;.  Explicitly, the problem is to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{N-1} \sum_{j=i+1}^N z_{i,j}$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z_{i,j} &amp;amp;\ge T X_i^T-T X_j^T\\&#xA;z_{i,j} &amp;amp;\ge -T X_i^T+T X_j^T\\&#xA;z_{i,j} &amp;amp;\le T X_i^T-T X_j^T + M_{i,j}^1 (1-y_{i,j})\\&#xA;z_{i,j} &amp;amp;\le -T X_i^T+T X_j^T+ M_{i,j}^2 y_{i,j}\\&#xA;y_{i,j} &amp;amp;\in \{0,1\}&#xA;\end{align}&lt;/span&gt;&#xA;Here, &lt;span class=&quot;math-container&quot;&gt;$M_{i,j}^1$&lt;/span&gt; is a small upper bound on &lt;span class=&quot;math-container&quot;&gt;$z_{i,j} - T X_i^T + T X_j^T$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$M_{i,j}^2$&lt;/span&gt; is a small upper bound on &lt;span class=&quot;math-container&quot;&gt;$z_{i,j} + T X_i^T - T X_j^T$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is that &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}=1$&lt;/span&gt; forces &lt;span class=&quot;math-container&quot;&gt;$z_{i,j} = T X_i^T-T X_j^T$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}=0$&lt;/span&gt; forces &lt;span class=&quot;math-container&quot;&gt;$z_{i,j} = -T X_i^T+T X_j^T$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-01-21T19:55:04.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3382" PostTypeId="2" ParentId="2881" CreationDate="2020-01-21T20:25:29.717" Score="4" Body="&lt;p&gt;I think that you're looking for function &lt;code&gt;IloCP::typeOfPrev&lt;/code&gt;. Its documentation is for example &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.10.0/ilog.odms.ide.help/refjavaopl/html/ilog/cp/IloCP.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, the description of the general concept is &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.10.0/ilog.odms.cplex.help/refcppcplex/html/interval_sequence.html#66&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, each interval participating in sequence variable can have a type. By default each interval has different type counted from 0 in the order as they are specified in the sequence variable. So type of the previous interval is the index into the array that was used to create the sequence variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;IloCP::typeOfPrev&lt;/code&gt; returns an expression, not a constant. That's because the value is not known, it depends on the particular solution. There are also similar functions, e.g. &lt;code&gt;IloCP::endOfPrev&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2971" LastActivityDate="2020-01-21T20:25:29.717" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3384" PostTypeId="1" CreationDate="2020-01-22T04:26:32.937" Score="4" ViewCount="1445" Body="&lt;p&gt;The following code works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;import cvxpy as cp&#xA;ci = np.array([10,7,6,3])&#xA;x = cp.Variable(len(ci),boolean=True)&#xA;objective = cp.Minimize(cp.sum_squares(ci@(2*x-1)))&#xA;problm = cp.Problem(objective)&#xA;_ = problm.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I pass a larger ci array, it doesn't work. Per recommendation &lt;a href=&quot;https://github.com/cvxgrp/cvxpy/issues/631&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, I want to try GLPK instead. So, I change the last line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_ = problm.solve(solver=cp.GLPK_MI)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This leads to the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SolverError: Either candidate conic solvers (['GLPK_MI']) do not support the cones output by the problem (SOC), or there are not enough constraints in the problem.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it the way I'm specifying constraints works for the default solver but not for GLMK_MI?&lt;/p&gt;&#xA;" OwnerUserId="2436" LastEditorUserId="8" LastEditDate="2020-09-01T16:08:45.940" LastActivityDate="2020-09-01T16:08:45.940" Title="cvxpy: Code that works for default solver doesn't work for cp.GLPK_MI" Tags="|optimization|mixed-integer-programming|cvxpy|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3385" PostTypeId="1" CreationDate="2020-01-22T14:48:28.770" Score="4" ViewCount="106" Body="&lt;p&gt;I'm trying to solve an RCPSPDc problem in OR-Tools with CP-SAT solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my RCPSPDc model (with discount rate) i want to set this objective:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max_{s}\sum_{j\in J}\text{profit}_{j}\cdot \frac{1}{(1+\alpha)^{s_{j}}}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is my vector of variables, each element saves the value where the job &lt;span class=&quot;math-container&quot;&gt;$j\in J$&lt;/span&gt; begins, i'm modeling this as an interval variable. &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is the discount rate. &#xA;Actually, I can't use float values in the objective and can't power values to an IntVar (OR-Tools don't permit), so I'm following a similar approach to the model with binary variable, but using the same variable &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, and rounding the values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to create a vector &lt;span class=&quot;math-container&quot;&gt;$\rm obj$&lt;/span&gt; of size &lt;span class=&quot;math-container&quot;&gt;$N_{jobs}\cdot t_\max$&lt;/span&gt; (number of jobs and horizon) and save as &lt;code&gt;IntVar&lt;/code&gt; the precomputed expression &lt;span class=&quot;math-container&quot;&gt;$\textbf{w}$&lt;/span&gt; of the sum with a boolean expression: &lt;code&gt;s[j]==t&lt;/code&gt;, so it can be activated only in that case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; std::vector&amp;lt;IntVar&amp;gt; obj_final(nbTasks*tmax);&#xA;    for (int j = 0; j &amp;lt; nbTasks; ++j)&#xA;    {&#xA;        for (int t = 0; i &amp;lt; tmax; ++t)&#xA;        {&#xA;            const IntVar expr = cp_model.NewIntVar(Domain(-1000000000000000000,10000000000000000));&#xA;            const BoolVar bl = cp_model.NewBoolVar();&#xA;            cp_model.AddEquality(bl, starts[j]==actual_t);&#xA;            cp_model.AddEquality(round(w[j][i],expr).OnlyEnforceIf(bl);&#xA;            obj_final.push_back(expr);&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but obviously it doesn't work because of the constraint of &lt;code&gt;starts[j]==t&lt;/code&gt; (start of the interval variable &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to enforce it in that way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;cp_model.AddEquality(round(w[j][i],expr).OnlyEnforceIf(s[j]==t);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but &lt;code&gt;OnlyEnforceIf&lt;/code&gt; takes only &lt;code&gt;BoolVars&lt;/code&gt; and not bool.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I assign a value to a &lt;code&gt;BoolVar&lt;/code&gt; as we do with &lt;code&gt;IntVar -&amp;gt; cp_model.NewConstant()&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make it to finally set as an objective the sum of all the elements in the vector that I created?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for reading.&lt;/p&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="981" LastEditDate="2023-12-22T15:12:56.213" LastActivityDate="2023-12-22T15:12:56.213" Title="Modelling issue with rcpsp and boolean expressions" Tags="|modeling|constraint-programming|or-tools|c++|cp-sat|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3386" PostTypeId="1" CreationDate="2020-01-22T17:25:29.900" Score="8" ViewCount="581" Body="&lt;p&gt;I have an application where I am solving millions of ILP instances that differ from each other only on one constraint. The instances, of course, are relatively easy to solve or otherwise this would be hopeless. Their size is less than 1000 variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What ILP solvers would be good for this application? What CPLEX settings would be good for this application?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I have used the CPLEX C++ API. I use &lt;code&gt;IloModel::add()&lt;/code&gt; and &lt;code&gt;IloModel::remove()&lt;/code&gt; to add and remove the differing constraint every time. With this approach, I am able to solve 100,000 instances in about 40 seconds. However, I'm not sure if this is the best I can do. I have also observed that the model is very unstable: adding a constraint saying &lt;code&gt;objective &amp;lt;= upper_bound&lt;/code&gt;, where &lt;code&gt;upper_bound&lt;/code&gt; is an external upper bound, made the solving more than 10 times slower.&lt;/p&gt;&#xA;" OwnerUserId="2706" LastEditorUserId="36" LastEditDate="2020-01-22T17:57:09.613" LastActivityDate="2020-01-23T00:17:01.013" Title="Solving multiple easy ILP instances" Tags="|mixed-integer-programming|cplex|c++|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3387" PostTypeId="2" ParentId="3386" CreationDate="2020-01-22T18:15:07.707" Score="9" Body="&lt;p&gt;in order to increase the throughput you could&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Not only rely on add and remove in &quot;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/OverviewAPIs/topics/Modify.html&quot; rel=&quot;noreferrer&quot;&gt;modifying problems&lt;/a&gt;&quot; options but on smaller changes.&lt;/li&gt;&#xA;&lt;li&gt;Try to run the instances in parallel&lt;/li&gt;&#xA;&lt;li&gt;Instead of adding a constraint on the objective use the setting IloCplex::Param::MIP::Tolerances::UpperCutoff or IloCplex::Param::MIP::Tolerances::LowerCutoff&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2020-01-22T18:20:57.483" LastActivityDate="2020-01-22T18:20:57.483" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3388" PostTypeId="1" AcceptedAnswerId="3391" CreationDate="2020-01-22T20:54:52.797" Score="8" ViewCount="171" Body="&lt;p&gt;Given a city map (a graph) &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b_{i,j}$&lt;/span&gt; is a Boolean variable for whether or not edge &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;,&lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is allocated, &lt;span class=&quot;math-container&quot;&gt;$d_{i,j}$&lt;/span&gt; denotes the distance between &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;,&lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The objective is to move from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; in minimum time. (I am trying an add intermediate stop point with a time limit)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j} b_{i,j} \times d_{i,j}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The journey starts from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and ends at &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i} b_{i,s} - \sum_{k} b_{s,k} = -1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above equation ensures no incoming edges at &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, i.e., exactly one edge leaves the starting point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i} b_{i,j} - \sum_{k} b_{j,k} = 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above equation ensures the equal number of edges going in and out, i.e., flow conservation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i} b_{i,e} - \sum_{k} b_{e,k} = 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above equation ensures no outgoing edges at &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;, i.e., exactly one edge enters the target node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To calculate the time at &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; I can use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{time}_{e} = \frac{\sum_{i,j} b_{i,j} \times d_{i,j}}{\text{speed}} + \text{time}_{s}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how can I force the solver to take an intermediate node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; forcefully into its path with time limit constraint, i.e., time-bound to reach there?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example if there is a path from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; then:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{time}_j &amp;amp;= \sum_{i} b_{i,j} \times \left( \frac{d_{i,j}}{\text{speed}} + \text{time}_i\right)\\\text{time}_j &amp;amp;\leq c\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is a constant value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the solver doesn't accept the above formulation.&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="123" LastEditDate="2020-01-26T10:17:49.887" LastActivityDate="2020-01-26T10:17:49.887" Title="Bounding arrival time at a node in a resource-constrained shortest path problem" Tags="|mixed-integer-programming|linear-programming|modeling|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3389" PostTypeId="2" ParentId="3386" CreationDate="2020-01-23T00:17:01.013" Score="3" Body="&lt;p&gt;If I recall correctly, adding a constraint on the primal objective function causes degeneracy in the dual LPs, which could account for at least part of the speed decrease you noted. In addition to Alex's suggestion about using the upper and lower cutoff parameters, you could add a new variable (call it &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;), constraint it to equal the original objective function, then minimize or maximize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. When you want to bound the objective value, you can change the lower or upper bound of the &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; variable. I think this avoids at least some of the degeneracy-related problems.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-01-23T00:17:01.013" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3390" PostTypeId="1" CreationDate="2020-01-23T08:19:18.360" Score="12" ViewCount="230" Body="&lt;p&gt;I am trying to create a mixed integer model that has as an objective to schedule routes for a single vehicle within its timeline. &#xA;Let me try to elaborate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say we have a single vehicle vrp and 6 customers and these customers have time windows. In order to facilitate the problem, let's say that with a certain algorithm we created the routes, taking into consideration the time windows and capacity constraints and post process, we need to reschedule these routes within the vehicle's working hours, in order find the best fit (start as soon as possible). &#xA;So if the vehicle's working hours are 05:00 - 23:00, the first route should start as closely to 05:00 as possible, the second should start after the expected return of the first, and the third should start after the expected return of the second. The start of the first route must be after the vehicle's start working hours and the end of the last route must be before the vehicle's end working hours. Customer's time windows must be taken into consideration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a possible timeline would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;         Customer's Time windows&#xA;1st route: [6-12, 6-12, 6-22]      load time: 05:00      ETA: 10:15&#xA;2nd route: [6-12, 12-18,12-18]     load time: 10:30      ETA: 14:30&#xA;3rd route: [12-18, 6-22,6-22]      load time: 15:00      ETA: 18:00 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a known math model that schedules time windowed routes (but doesn't create them).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It kind of sounds like a job shop scheduling problem that each route is a job that needs to be done and each job has a several amount of tasks (customers) and we have one machine (the vehicle).  Can the tasks of a job have time windows in job shop scheduling?&lt;/p&gt;&#xA;" OwnerUserId="1243" LastEditorUserId="1243" LastEditDate="2020-01-23T08:49:04.083" LastActivityDate="2020-06-14T11:28:16.397" Title="Is there a known MILP to schedule routes after routes are made" Tags="|optimization|mixed-integer-programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3391" PostTypeId="2" ParentId="3388" CreationDate="2020-01-23T09:47:46.287" Score="6" Body="&lt;p&gt;Your update of the &lt;span class=&quot;math-container&quot;&gt;$\text{time}_j$&lt;/span&gt; variable results in a non-linear equation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The propagation of the time value along an edge is like &lt;span class=&quot;math-container&quot;&gt;$$b_{i,j} = 1 \implies \text{time}_i + \frac{d_{i,j}}{\text{speed}} \leq \text{time}_j$$&lt;/span&gt; and you can linearize it like &lt;span class=&quot;math-container&quot;&gt;$$\text{time}_i + \frac{d_{i,j}}{\text{speed}} \leq \text{time}_j + M(1-b_{i,j})$$&lt;/span&gt; with a &quot;large&quot; constant &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. Ugly, I know, but it should work. &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; can be an upper bound on the latest arrival time in the target node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to force the flow/path to visit a certain node, you put a special flow conservation constraint to that node just like you do for the start/target node of the path: enforce that one unit of flow leaves that node you wish to visit (see &lt;a href=&quot;https://or.stackexchange.com/a/3392/354&quot;&gt;Simon&lt;/a&gt;'s answer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A note on elementarity: You get this &quot;for free&quot; when &lt;span class=&quot;math-container&quot;&gt;$d_{i,j}&amp;gt;0$&lt;/span&gt; what I assume to be true in this case.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="123" LastEditDate="2020-01-23T13:50:17.493" LastActivityDate="2020-01-23T13:50:17.493" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3392" PostTypeId="2" ParentId="3388" CreationDate="2020-01-23T12:47:24.627" Score="6" Body="&lt;p&gt;Adding to &lt;a href=&quot;https://or.stackexchange.com/a/3391/2791&quot;&gt;Marco's&lt;/a&gt; answer on enforcing a visit to a node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For enforcing a visit to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; you can add either&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i} b_{i,j} = 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{k} b_{j,k} = 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to your model.&lt;/p&gt;&#xA;" OwnerUserId="2791" LastActivityDate="2020-01-23T12:47:24.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3393" PostTypeId="1" CreationDate="2020-01-23T14:27:05.790" Score="12" ViewCount="174" Body="&lt;p&gt;I'm solving an assignment-alike problem with a Logic-based Benders decomposition-alike (LBBD) method. The master problem provides an assignment, which is checked in the sub-problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Define the set of binary variables &lt;span class=&quot;math-container&quot;&gt;$x_i \in \{ 0, 1 \}$&lt;/span&gt; representing the assignment of entities &lt;span class=&quot;math-container&quot;&gt;$i \in X$&lt;/span&gt; in the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Benders sub-problem generates various (feasibility) cuts &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in S} x_i \leq k$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$1 &amp;lt; k \in \mathbb N$&lt;/span&gt; some constant, where &lt;span class=&quot;math-container&quot;&gt;$S \subseteq X$&lt;/span&gt; is a subset of entities featured in the sub-problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These generated cuts are often not strong, because they are too specific on a small set of entities, of which many may exist. This slows down the convergence of the method significantly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have external information regarding the sizes of the entities, which is not yet captured in the master problem.&#xA;For every pair of entities &lt;span class=&quot;math-container&quot;&gt;$i, j \in X$&lt;/span&gt; it is known which is the larger entity. Being &quot;larger&quot; (&lt;span class=&quot;math-container&quot;&gt;$\succeq$&lt;/span&gt;) is a transitive relation.&#xA;Given a constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in S} x_i \leq k$&lt;/span&gt; it is possible to interchange variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; (or a set of variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;) with variables &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$j \succeq i$&lt;/span&gt;, as long as &lt;span class=&quot;math-container&quot;&gt;$j \notin S$&lt;/span&gt;. This gives a new valid cut. The problem is that there may exist too many of these to add them practically.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As an example: If I have a certain cut &lt;span class=&quot;math-container&quot;&gt;$x_1 + x_2 + x_3 \leq 1$&lt;/span&gt; and know that &lt;span class=&quot;math-container&quot;&gt;$1 \prec 2 \prec 3 \prec 4$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$3 \prec 5$&lt;/span&gt;, then the following cuts are also valid:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{gather}&#xA;x_1 + x_2 + x_3 \leq 1 \\&#xA;x_2 + x_3 + x_4 \leq 1 \\&#xA;x_1 + x_2 + x_5 \leq 1 \\&#xA;x_1 + x_4 + x_5 \leq 1 \\&#xA;\dots&#xA;\end{gather}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Because from a single generated sub-problem cut many other cuts can be generated, I am looking for a method to capture adding general cuts in the master problem without adding them explicitly.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My attempt was to introduce new variables &lt;span class=&quot;math-container&quot;&gt;$\xi_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i \in X$&lt;/span&gt; that impose an upper bound on the variables &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$i \preceq j$&lt;/span&gt; in some way. Then the cuts are added on the &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt;-variables rather than the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;-variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest master problem constraint &lt;span class=&quot;math-container&quot;&gt;$x_j \leq \xi_i$&lt;/span&gt; does certainly not work, because if &lt;span class=&quot;math-container&quot;&gt;$1 \prec 2$&lt;/span&gt; the cut &lt;span class=&quot;math-container&quot;&gt;$\xi_1 + \xi_2 \leq 1$&lt;/span&gt; implies &lt;span class=&quot;math-container&quot;&gt;$2x_2 \leq 1 \Rightarrow x_2 = 0$&lt;/span&gt;. Simple extensions like &lt;span class=&quot;math-container&quot;&gt;$x_j \leq \xi_i + x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i \leq \xi_i$&lt;/span&gt; introduce other limitations.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I would be helped with suggestions in the following directions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In many papers applying LBBD such symmetry breaking is not discussed. Is there any name for such symmetry breaking that I can look at in other literature?&lt;/li&gt;&#xA;&lt;li&gt;Is there a structure that I can use?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2952" LastActivityDate="2020-01-23T21:03:10.850" Title="Improving cuts from sub-problem with problem-specific hierarchical information" Tags="|mixed-integer-programming|linear-programming|scheduling|benders-decomposition|cutting-planes|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3394" PostTypeId="1" CreationDate="2020-01-23T14:44:17.193" Score="3" ViewCount="193" Body="&lt;p&gt;I'm trying to validate my model, this is the relevant part of my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    cp_model.Maximize(LinearExpr::Sum(obj_final));&#xA;&#xA;    SatHelper::ValidateModel(cp_model);&#xA;    //solve&#xA;    Model model;&#xA;    //&#xA;    // Sets a time limit of 10 seconds.&#xA;&#xA;    SatParameters parameters;&#xA;    parameters.set_max_time_in_seconds(10.0);&#xA;    model.Add(NewSatParameters(parameters));&#xA;&#xA;    // Solve.&#xA;&#xA;    const CpSolverResponse response = SolveCpModel(cp_model.Build(), &amp;amp;model);&#xA;    LOG(INFO) &amp;lt;&amp;lt; CpSolverResponseStats(response);&#xA;&#xA;    if (response.status() == CpSolverStatus::FEASIBLE) {&#xA;        for (int j = 0; j &amp;lt; nbTasks; ++j)&#xA;        {&#xA;            LOG(INFO) &amp;lt;&amp;lt; &quot;  x = &quot; &amp;lt;&amp;lt; SolutionIntegerValue(response, starts[j]);&#xA;        }}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason my model is invalid and I want to validate it to get detailed information about it. But I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; error: no matching function for call to ‘operations_research::sat::SatHelper::ValidateModel(operations_research::sat::Model&amp;amp;)’&#xA;     SatHelper::ValidateModel(model);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and suggests: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;note: candidate: static std::__cxx11::string operations_research::sat::SatHelper::ValidateModel(const operations_research::sat::CpModelProto&amp;amp;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, what is a &lt;code&gt;CpModelProto&lt;/code&gt;? I read the documentation but it is hard to understand. I've seen most of the c++ examples of or-tools and I haven't found any &lt;code&gt;CpModelProto&lt;/code&gt; in the solving part. And finally, what can I do to validate my model and check where the problem is?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, if someone can give me a nice explanation of how to print/solve and setting parameters, it will be nice, because the examples use FLAGS and LOG and they are confusing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="981" LastEditDate="2023-12-29T10:50:02.387" LastActivityDate="2023-12-29T10:50:02.387" Title="ValidateModel or tools in c++ and proto problems" Tags="|constraint-programming|or-tools|c++|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3395" PostTypeId="2" ParentId="3394" CreationDate="2020-01-23T15:28:41.180" Score="4" Body="&lt;p&gt;&lt;code&gt;CpModelProto&lt;/code&gt; is a &lt;a href=&quot;https://developers.google.com/protocol-buffers&quot; rel=&quot;nofollow noreferrer&quot;&gt;protobuf&lt;/a&gt; representation of your model in ortools.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You create it by using the &lt;code&gt;CpModelBuilder&lt;/code&gt; class (your &lt;code&gt;cp_model&lt;/code&gt;), and calling its &lt;code&gt;Build()&lt;/code&gt; method, the &lt;a href=&quot;https://google.github.io/or-tools/cpp_sat/namespaceoperations__research_1_1sat.html#a9d67b9c66f1cb9c1dcc3415cd5af11bf&quot; rel=&quot;nofollow noreferrer&quot;&gt;SolveCpModel&lt;/a&gt; function that you are using actually also takes a &lt;code&gt;CpModelProto&lt;/code&gt; as its first argument.&lt;/p&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2020-01-23T16:58:08.707" LastActivityDate="2020-01-23T16:58:08.707" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3396" PostTypeId="1" AcceptedAnswerId="3477" CreationDate="2020-01-23T17:15:56.797" Score="12" ViewCount="497" Body="&lt;p&gt;It is well known that job shop scheduling problems are notoriously hard from a computational point of view. Many papers exist for the &lt;strong&gt;makespan&lt;/strong&gt; objective, and some report on &lt;strong&gt;min sum&lt;/strong&gt; objectives (like minimize weighted completion time, minimize earliness/tardiness penalties etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question: does anyone know whether makespan or min sum objectives are &lt;strong&gt;computationally&lt;/strong&gt; more difficult when using MILP approaches?&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="123" LastEditDate="2020-01-23T19:49:53.690" LastActivityDate="2023-03-15T13:39:31.417" Title="Job Shop Scheduling: what objectives are harder?" Tags="|scheduling|computational-experiments|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="3397" PostTypeId="1" CreationDate="2020-01-23T19:23:41.630" Score="6" ViewCount="163" Body="&lt;p&gt;I'm trying to solve an RCPSPDc model It is infeasible, although Ilog Cplex solves it, so I think I have a modelling issue. I have more constraints but the precedence is the one that makes it infeasible.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    //Inicializar Modelo&#xA;    CpModelBuilder cp_model;&#xA;    const int nbTasks = njobs;&#xA;    const int nbResources = nresources;&#xA;&#xA;    // DEFINE VARIABLES&#xA;    std::vector&amp;lt;IntVar&amp;gt; starts(nbTasks);&#xA;    std::vector&amp;lt;IntVar&amp;gt; durations(nbTasks);&#xA;    std::vector&amp;lt;IntVar&amp;gt; ends(nbTasks);&#xA;    std::vector&amp;lt;BoolVar&amp;gt; actives(nbTasks);&#xA;    std::vector&amp;lt;IntervalVar&amp;gt; Intervals(nbTasks);&#xA;&#xA;    for (int j=0; j&amp;lt;nbTasks; j++) &#xA;    {   &#xA;        const IntVar start = cp_model.NewIntVar(Domain(0, tmax));       // generamos una variable intervalo&#xA;        const IntVar end = cp_model.NewIntVar(Domain(0, tmax));         // para cada job&#xA;        const BoolVar active = cp_model.NewBoolVar();&#xA;        const IntVar size = cp_model.NewConstant(duration[j]); &#xA;        /*if(duration[j])&#xA;        {&#xA;            const IntVar size = cp_model.NewConstant(duration[j]); &#xA;        }&#xA;        else&#xA;        {&#xA;            const IntVar size = cp_model.NewConstant(1);&#xA;        }&#xA;        */&#xA;        const IntervalVar interval = cp_model.NewOptionalIntervalVar(start, size, end, active);&#xA;&#xA;        starts.push_back (start);        // añadimos las variables a sus&#xA;        durations.push_back(size);      // diccionarios respectivos&#xA;        ends.push_back(end);&#xA;        actives.push_back(active);&#xA;        Intervals.push_back(interval);&#xA;    }&#xA;&#xA;    // DEFINE PRECEDENCE CONSTRAINTS&#xA;    for (int j = 0; j &amp;lt; nbTasks; ++j)&#xA;    {&#xA;        const int nbSucc = nsucc[j];&#xA;        for (int s = 0; s &amp;lt; nbSucc; ++s)&#xA;        {&#xA;            cp_model.AddLessOrEqual(LinearExpr(ends[j]).AddConstant(lag[j][s]), LinearExpr(starts[succ[j][s]]));&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't see where the problem is. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;nsucc[j]&lt;/code&gt; is the number of successors from a job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;lag[j][s]&lt;/code&gt; is the time successor activity &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; must wait to start after predecessor activity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;succ[j][s]&lt;/code&gt; is the &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;-successor of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;; &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;code&gt;succ[j][s]&lt;/code&gt; represent the same but reference different vectors. For example, &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is the second successor of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, but &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is the job &lt;span class=&quot;math-container&quot;&gt;$343$&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'll be thankful for any help.&lt;/p&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="981" LastEditDate="2023-12-29T10:50:28.763" LastActivityDate="2023-12-29T10:50:28.763" Title="Modelling issue with precedence constraint in OR-Tools" Tags="|scheduling|constraint-programming|or-tools|c++|cp-sat|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3398" PostTypeId="2" ParentId="3393" CreationDate="2020-01-23T21:03:10.850" Score="5" Body="&lt;p&gt;The implied cuts may not be worth adding. Depending on how the solution process goes (solving the master to &quot;optimality&quot; each time before solving the subproblem, versus a &quot;one tree&quot; approach), it might be better to just let the master problem identify the relevant cuts (by generating solutions that violate them).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, if you are using a solver, it may have some provision for adding extra cuts to a pool, where they are used to test solutions (before the solutions are passed to your subproblem) but are not part of the matrix calculations until they become relevant. CPLEX, for instance, has &quot;lazy constraints&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your subproblem is moderately slow to solve, you might cache the cuts it produces (along with the transitive relation) in your code. When your code receives a solution from the master problem, it can test whether the combination of dominance and a previous cut blocks the solution, and if so return the corresponding cut without actually solving the subproblem. Testing all possible &quot;dominating&quot; combinations could be pretty slow, in which case perhaps some compromise would be best (e.g., try up to five dominating combinations, and if none produce violated cuts, go ahead and solve the subproblem).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-01-23T21:03:10.850" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3399" PostTypeId="1" CreationDate="2020-01-24T14:06:38.550" Score="7" ViewCount="293" Body="&lt;p&gt;Most descriptions of the Dantzig-Wolfe decomposition, I have seen end up with subproblems like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x_j \in \mathbb{R}^n} \{ (\pi A_j - c_j)x_j \mid x_j \in P_j \}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They argue that &lt;span class=&quot;math-container&quot;&gt;$P_j$&lt;/span&gt; can be described with a finite number of extreme points and extreme rays, so the process of repeatedly generating columns as optimal solutions of the subproblems will terminate eventually. However, most of these descriptions make the assumption that the variables &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; are bounded (non-negative) or that &lt;span class=&quot;math-container&quot;&gt;$P_j$&lt;/span&gt; is bounded. I understand that a free variable can be replaced by the difference of two non-negative ones and this seems to be a standard way to satisfy this assumption; for example in &lt;a href=&quot;http://eaton.math.rpi.edu/CourseMaterials/PreviousSemesters/Spring08/JM6640/tebboth.pdf&quot; rel=&quot;noreferrer&quot;&gt;[Teb01]&lt;/a&gt;. In my case it would be simpler to think about free variables, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is about the case where all variables &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; are free, so we did not do the transformation to bounded variables. Is the algorithm of repeatedly adding a column to the master problem still finite, if the added column is either (1) an extreme point of &lt;span class=&quot;math-container&quot;&gt;$P_j$&lt;/span&gt;, or (2) a ray (but not necessarily an extreme ray) of &lt;span class=&quot;math-container&quot;&gt;$P_j$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$(\pi A_j - c_j)x_j &amp;lt; 0$&lt;/span&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked in the original paper &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/opre.8.1.101&quot; rel=&quot;noreferrer&quot;&gt;[DW60]&lt;/a&gt; where Theorem 3 seems to say as much but I don't understand it sufficiently well to be sure that there are no addition assumptions about &lt;span class=&quot;math-container&quot;&gt;$P_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [Teb01] James R. Tebboth, &lt;em&gt;A Computational Study of Dantzig-Wolfe Decomposition&lt;/em&gt;, Ph.D. thesis, University of Buckingham, 2001. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [DW60] George B. Dantzig and Philip Wolfe. &lt;em&gt;Decomposition Principle for Linear Programs&lt;/em&gt;, Operations Research 8 (1960), no. 1, 101-111. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="1180" LastEditorUserId="1180" LastEditDate="2020-01-24T14:57:42.940" LastActivityDate="2020-01-24T15:38:06.260" Title="Is Dantzig-Wolfe decomposition finite if variables are unbounded?" Tags="|linear-programming|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3400" PostTypeId="2" ParentId="3399" CreationDate="2020-01-24T15:38:06.260" Score="6" Body="&lt;p&gt;The assumption that the subproblem polyhedron &lt;span class=&quot;math-container&quot;&gt;$P_j$&lt;/span&gt; is bounded is for simplicity of exposition (or implementation).  Whether or not the variables themselves have explicit bounds, if &lt;span class=&quot;math-container&quot;&gt;$P_j$&lt;/span&gt; is bounded, then extreme points suffice, and you do not need extreme rays.  In practical applications, all variables have implicit bounds that are implied either by the explicit constraints or by the fact that there aren't enough people on Earth to buy &lt;span class=&quot;math-container&quot;&gt;$10^{100}$&lt;/span&gt; widgets even if you had the ability to produce them.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-01-24T15:38:06.260" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3401" PostTypeId="1" AcceptedAnswerId="3402" CreationDate="2020-01-24T15:44:33.603" Score="6" ViewCount="839" Body="&lt;p&gt;I have a weird planning problem. I think it falls under the &lt;a href=&quot;https://en.wikipedia.org/wiki/Assignment_problem&quot; rel=&quot;noreferrer&quot;&gt;assignment&lt;/a&gt; category, but I'm not sure because I'm not familiar with assignment problems, and also because there is a &quot;temporal&quot; angle to it, which maybe makes it a bit different from classical assignment problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; workers &lt;span class=&quot;math-container&quot;&gt;$\{W_1,\dots,W_k\}$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$k=2$&lt;/span&gt; currently, but it could change in the future), and a sequence of tasks of different value &lt;span class=&quot;math-container&quot;&gt;$L=[v_1,\dots,v_n \mid v_i\in Z^{\neq}]$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$V=\sum_iv_i$&lt;/span&gt;. I want to assign tasks to each worker in such a way that &lt;span class=&quot;math-container&quot;&gt;$\sum v_{iW_1}=0.3V$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum v_{iW_2}=0.7V$&lt;/span&gt;, i.e., minimizing the cost&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$L=\left(\sum v_{iW_2}-0.7V\right)^2$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the tasks are assigned in order (i.e., task &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; is assigned before task &lt;span class=&quot;math-container&quot;&gt;$v_{i+1}$&lt;/span&gt;) and for some reason, the number of &quot;switches&quot; &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is to be minimized. With switch, I mean the action of assigning task &lt;span class=&quot;math-container&quot;&gt;$v_{i+1}$&lt;/span&gt; to a different worker than the one to which I assigned task &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt;. Obviously &lt;span class=&quot;math-container&quot;&gt;$m\geq1$&lt;/span&gt;. The overall number of switches should be minimized, and a &quot;batched assignment&quot; solution would be preferred: say, assign at least 3 consecutive tasks to the same worker.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand the problem is underspecified: the internal customer I'm doing this for, doesn't really know what they want. For example, rather than saying &quot;don't switch too often&quot;, they should actually quantify the cost of switching from a worker to another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even then, I think there should be a way to find a solution which is &quot;optimal&quot; in some sense, like for example minimizing both the cost and the number of switches:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$L'=\left(\sum v_{iW_2}-0.7V\right)^2+cm^2,\ c&amp;gt;0$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2981" LastEditorUserId="123" LastEditDate="2020-01-24T17:03:27.500" LastActivityDate="2020-01-27T13:46:41.177" Title="Assignment problem where assignments must be done sequentially" Tags="|optimization|quadratic-programming|assignment-problem|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3402" PostTypeId="2" ParentId="3401" CreationDate="2020-01-24T15:59:58.190" Score="6" Body="&lt;p&gt;You can model this with a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; to indicate whether task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; to indicate whether task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the first task assigned to worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in the current batch.  The number of switches is then &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\ge 2} \sum_j y_{i,j}$&lt;/span&gt; because this sum counts the number of times that any worker starts a new batch of tasks (except the first batch that contains task &lt;span class=&quot;math-container&quot;&gt;$i=1$&lt;/span&gt;).  The constraints are:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j x_{i,j} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$}\\&#xA;x_{1,j} &amp;amp;= y_{1,j} &amp;amp;&amp;amp;\text{for all $j$} \\&#xA;x_{i,j} - x_{i-1,j} &amp;amp;\le y_{i,j} &amp;amp;&amp;amp;\text{for $i\ge 2$ and all $j$} \\&#xA;y_{i,j} &amp;amp;\le x_{i+k,j} &amp;amp;&amp;amp;\text{for $k\in\{0,1,2\}$}\\&#xA;\end{align}&lt;/span&gt;&#xA;The first constraint assigns each task to exactly one worker.  The second constraint forces task 1 to start a new batch.  The third constraint enforces the logical implication that, if task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and task &lt;span class=&quot;math-container&quot;&gt;$i-1$&lt;/span&gt; is assigned to a different worker, then task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; starts a new batch for worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;; that is, &lt;span class=&quot;math-container&quot;&gt;$(x_{i,j}=1 \land x_{i-1,j}=0) \implies y_{i,j}=1$&lt;/span&gt;. The fourth constraint enforces the logical implication that, if task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; start a new batch for worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, then tasks &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; through &lt;span class=&quot;math-container&quot;&gt;$i+2$&lt;/span&gt; (3 consecutive tasks) must be assigned to worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;; that is, &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}=1 \implies x_{i+k,j}=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You specified a quadratic objective, so you could use an MIQP solver.  Or you could change the objective to &#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left|\sum_i v_i x_{i,2} - 0.7V\right| + c \cdot m,$$&lt;/span&gt;&#xA;linearize the absolute value and use an MILP solver.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-01-24T18:37:26.670" LastActivityDate="2020-01-24T18:37:26.670" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3403" PostTypeId="2" ParentId="3401" CreationDate="2020-01-25T00:47:50.037" Score="2" Body="&lt;p&gt;When you have two objective functions, and your client can't articulate exactly how the two are to be weighed against one another, sometimes the easiest solution is to avoid making that decision. Instead of trying to figure out the client's priorities and find the single best solution, you can present them with a small list of options guaranteed to contain the best solution, and then let them choose from that list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A solution is called &quot;nondominated&quot; or &quot;Pareto efficient&quot; if there's no way to improve one objective without worsening another. The Pareto front is the set of all nondominated solutions. It follows that no matter how heavily your client weights cost vs. switches, or vice versa, their best solution will lie somewhere in the Pareto front.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's one way to calculate the solutions on that front. Letting &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; stand for the two objective functions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Solve the problem, optimising only for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, and record this solution &lt;span class=&quot;math-container&quot;&gt;$S_0$&lt;/span&gt;. Let the resulting objective values be &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Solve the problem again, adding a constraint that &lt;span class=&quot;math-container&quot;&gt;$y&amp;lt;y_0$&lt;/span&gt;. Record the solution &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt; and OF values &lt;span class=&quot;math-container&quot;&gt;$x_1, y_1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Solve again, with the constraint that &lt;span class=&quot;math-container&quot;&gt;$y&amp;lt;y_1$&lt;/span&gt;...&lt;/li&gt;&#xA;&lt;li&gt;Keep going until the problem becomes infeasible.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You will now have a set of solutions where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; decreases as &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; increases. Any solution outside this set will be worse than some solution within it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Strictly speaking, this set might contain a few non-Pareto-efficient ones too, e.g. if the first one gives &lt;span class=&quot;math-container&quot;&gt;$x=100, y=200$&lt;/span&gt;, the second one could have &lt;span class=&quot;math-container&quot;&gt;$x=100, y=199$&lt;/span&gt;, in which case the first solution is dominated by the second and could be discarded. So if you want to be really rigorous, you should go back through the results and cull any of those dominated solutions. Alternately, instead of optimising on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, you could optimise on something like &lt;span class=&quot;math-container&quot;&gt;$x+0.00001*y$&lt;/span&gt; to avoid these &quot;almost-Pareto-efficient&quot; solutions.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you like, you can then plot the x- and y-values for each solution and let your client pick off the chart. It's often much easier for people to choose between options than to explain their general rule for choosing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're feeling bold you can then use their preferred solutions to deduce how much priority they put on each of the two objective functions, and use that to construct a single OF to use next time around.&lt;/p&gt;&#xA;" OwnerUserId="546" LastEditorUserId="546" LastEditDate="2020-01-27T13:46:41.177" LastActivityDate="2020-01-27T13:46:41.177" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3405" PostTypeId="1" CreationDate="2020-01-25T09:25:48.443" Score="6" ViewCount="275" Body="&lt;p&gt;I'm working on an optimization problem regarding a directed acyclic graph. The constraint looks in &lt;code&gt;pyomo&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;model.K = RangeSet(0,n_edges)&#xA;model.con_part=ConstraintList()&#xA;    for k in model.K:&#xA;        model.con_part.add(model.x[edge_list['from_i'][k]] &amp;lt;= model.x[edge_list['to_i'][k]])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;x&lt;/code&gt; is a binary variable. Mathematically, I would write something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_1\le x_2\quad\forall e_k(x_1,x_2)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$e_k$&lt;/span&gt; is an edge which goes form &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt; which are all the edges of the graph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to express this nicely?&lt;/p&gt;&#xA;" OwnerUserId="2984" LastEditorUserId="123" LastEditDate="2020-01-25T09:54:57.863" LastActivityDate="2020-01-26T18:22:30.643" Title="How to write a constraint for a directed graph?" Tags="|optimization|modeling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3407" PostTypeId="2" ParentId="443" CreationDate="2020-01-25T10:29:24.203" Score="2" Body="&lt;p&gt;I think the answer of Rob can be developed into an exact answer, if we can ascertain apriori that the fractional part &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; can be no larger than a given bound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to be the floor  of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. Further assume we can guarantee that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; does not lie in the following range (Integer + &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt;, Integer+1] for any Integer. This assumption can be stated also as: &lt;span class=&quot;math-container&quot;&gt;$0 \le \delta &amp;lt;1$&lt;/span&gt; is the largest possible value for the fractional part of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Of course this is a hard condition to satisfy, but for many problems it can be easy. For example, consider this question: &lt;a href=&quot;https://math.stackexchange.com/questions/3520916/proof-for-an-easy-empirical-result-on-fractions-and-ceilings&quot;&gt;https://math.stackexchange.com/questions/3520916/proof-for-an-easy-empirical-result-on-fractions-and-ceilings&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then &lt;span class=&quot;math-container&quot;&gt;$x-\delta \le y \le x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y \in Z^+$&lt;/span&gt; model the floor exactly. &lt;/p&gt;&#xA;" OwnerUserId="2978" LastActivityDate="2020-01-25T10:29:24.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3408" PostTypeId="1" AcceptedAnswerId="3409" CreationDate="2020-01-25T10:32:01.883" Score="6" ViewCount="172" Body="&lt;p&gt;I have an adjacency matrix &lt;span class=&quot;math-container&quot;&gt;$G_{i,j}$&lt;/span&gt; that tells the distance between &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (between 0 to 1) if there is no edge between &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; I am putting a large integer &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/3388/bounding-arrival-time-at-a-node-in-a-ressource-constrained-shortest-path-problem&quot;&gt;This is my previous question related to it.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to linearize the following equation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is the starting point, &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; is the ending point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{time}_j = \sum_i b_{i,j}\times \text{time}_i + G_{i, j} $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My linearization is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{time}_s&amp;amp;= 3.0\\\text{time}_j&amp;amp;\geq\text{time}_i + G_{i, j} - M \times(1 - b_{i, j})\\\text{time}_j&amp;amp;\leq\text{time}_i + G_{i, j}\\\text{time}_j&amp;amp;\geq 0\\\text{time}_j&amp;amp;\leq M \times b_{i, j}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Value of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is also &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt;. Solver can't find the solution for this. If I remove the last 3 equations from linearization it finds the solution but for some node value of &lt;span class=&quot;math-container&quot;&gt;$\text{time}_j$&lt;/span&gt; reaches to limit value &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the answer of @prubin:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{time}_s&amp;amp;= 3.0\\&#xA;\text{time}_j&amp;amp;\geq\text{time}_i + G_{i, j} - M \times(1 - b_{i, j})\\&#xA;\text{time}_j&amp;amp;\leq\text{time}_i + G_{i, j} + M \times(1 - b_{i, j})\\&#xA;\text{time}_j&amp;amp;\geq 0\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The value of &lt;span class=&quot;math-container&quot;&gt;$time_j$&lt;/span&gt; is depending on  &lt;span class=&quot;math-container&quot;&gt;$time_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_{i,j}$&lt;/span&gt; I can only decide whether value of &lt;span class=&quot;math-container&quot;&gt;$time_j$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or dependent on &lt;span class=&quot;math-container&quot;&gt;$time_i$&lt;/span&gt; when I have seen value of all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$b_{i,j}$&lt;/span&gt; i.e, &lt;span class=&quot;math-container&quot;&gt;$time_j$&lt;/span&gt; = 0  if &lt;span class=&quot;math-container&quot;&gt;$\sum _i b_{i,j} = 0$&lt;/span&gt; otherwise it is &lt;span class=&quot;math-container&quot;&gt;$time_j = time_i + G_{i, j}$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$\sum_i b_{i,j} = 1$&lt;/span&gt; now the important thing to note here is that same &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; should be used in &lt;span class=&quot;math-container&quot;&gt;$time_i$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$b_{i,j} = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now with the above two equations, I iterate through all values of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and if it is &lt;span class=&quot;math-container&quot;&gt;$b_{i,j} = 0$&lt;/span&gt; range of &lt;span class=&quot;math-container&quot;&gt;$time_j$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$[-M, +M]$&lt;/span&gt; whenever I find the &lt;span class=&quot;math-container&quot;&gt;$b_{i,j} = 1$&lt;/span&gt; value of &lt;span class=&quot;math-container&quot;&gt;$time_j =  time_i + G_{i, j}$&lt;/span&gt; which is correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that when I don't find any &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$b_{i,j} = 1$&lt;/span&gt; i.e., &lt;span class=&quot;math-container&quot;&gt;$\sum_i b_{i,j} = 0$&lt;/span&gt; in that case the value range of &lt;span class=&quot;math-container&quot;&gt;$time_j$&lt;/span&gt; is still &lt;span class=&quot;math-container&quot;&gt;$[-M, +M]$&lt;/span&gt; but due to third equation it becomes &lt;span class=&quot;math-container&quot;&gt;$[0, +M]$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how that can be brought to the range &lt;span class=&quot;math-container&quot;&gt;$[0,0]$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$\sum_i b_{i,j} = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{time}_s&amp;amp;= 3.0\\&#xA;\text{time}_j&amp;amp;\geq\text{time}_i + G_{i, j} - M \times(1 - b_{i, j})\\&#xA;\text{time}_j&amp;amp;\leq\text{time}_i + G_{i, j} + M \times(1 - b_{i, j})\\&#xA;\text{time}_j&amp;amp;\geq 0\\&#xA;\text{time}_j&amp;amp;\leq M \times \sum_i b_{i,j}\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="700" LastEditDate="2020-01-28T08:15:47.140" LastActivityDate="2020-01-28T08:15:47.140" Title="How to propagate time using linear inequalities?" Tags="|mixed-integer-programming|linear-programming|linearization|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3409" PostTypeId="2" ParentId="3408" CreationDate="2020-01-25T19:20:09.260" Score="6" Body="&lt;p&gt;The constraint &lt;span class=&quot;math-container&quot;&gt;$\mathrm{time}_j \le \mathrm{time}_i + G_{i,j}$&lt;/span&gt; is incorrect. It bounds &lt;span class=&quot;math-container&quot;&gt;$\mathrm{time}_j$&lt;/span&gt; regardless of whether node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; follows node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; or not. Add the same &quot;big M&quot; term that you subtracted in the previous constraint.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-01-25T19:20:09.260" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3410" PostTypeId="1" CreationDate="2020-01-26T03:07:02.133" Score="1" ViewCount="81" Body="&lt;p&gt;I have a problem with a nonlinear objective function which is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad Z_j\cdot(N_j)^{0.5}\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is the index.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know how can I turn it into a linear programming problem.&lt;/p&gt;&#xA;" OwnerUserId="2988" LastEditorUserId="123" LastEditDate="2020-01-26T09:41:05.290" LastActivityDate="2020-01-26T09:41:05.290" Title="Converting Nonlinear Program into an LP" Tags="|mixed-integer-programming|linearization|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3412" PostTypeId="1" CreationDate="2020-01-26T18:04:27.143" Score="6" ViewCount="142" Body="&lt;p&gt;In stochastic inventory control, it is very important to model the demand appropriate to set e.g. order levels. Demand can be fit to a certain probability distribution via many means (e.g. a goodness of fit test). However, following common literature of stochastic inventory control (eg Axsäter, 2006; Silver, 1998), probability distributions are assigned to a set of demand points based on:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Demand volume: high or low demand&lt;/li&gt;&#xA;&lt;li&gt;Variability: using the first two statistical moments to determine a coefficient that tells us something about the stability in demand patterns.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Demand in most practical situations is nonnegative integers and when you have relatively low demand, it is natural to use a discrete demand model. When the demand is relatively high, it is better to use a continuous one. But also within the discrete demand models, you can have multiple probability distributions, as well as within the continuous models. The choice of specific distributions within these classes (discrete and continuous) depend then on a certain variation coefficient. The discrete models that show up the most are the Poisson distribution and a compounding (logarithmic) distribution (i.e. a negative binomial distribution), where for the continuous models, the normal and gamma distribution show up the most. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this approach is far more practical and is often a good theoretical approach as well, as long as you use the right boundaries to separate volume &amp;amp; variability in demand patterns. At least it looks that way, when certain authorities in the field say it.&#xA;But also a lot of software packages use this classification to assign distributions to model the demand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, assuming you have an optimal threshold that distinct demand patterns based on demand volume and variability described by the first two statistical moments of the demand points, I have a strong feeling that the following and former mentioned four probability distributions (or a combination) are sufficient to approximate every demand distribution in practice with an acceptable accuracy:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The pure Poisson distribution (relatively low demand &amp;amp; relatively stable (low variability) demand patterns)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The negative binomial distribution (relatively low demand &amp;amp; relatively unstable (high variability) demand patterns)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The normal distribution (relatively high demand &amp;amp; relatively stable (low variability) demand patterns)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The gamma distribution (relatively high demand &amp;amp; relatively unstable (high variability) demand patterns)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This feeling I got is purely based on literature and my own experiences as a research scientist in the field. And with accuracy I mean: what is the accuracy of the CDF from random samples of one the four distributions (or a combination) against samples from the 'correct' distribution. Let's say an acceptable accuracy is &lt;span class=&quot;math-container&quot;&gt;$95\%$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now the question is: has any research been done on this and if yes, could someone provide me with information on this research that could evidence my feeling or reject it? Or just any comments, thoughts on this are more than welcome!&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2020-01-26T20:39:26.180" LastActivityDate="2020-01-26T20:39:26.180" Title="Can demand be modeled by a limited amount of probability distributions?" Tags="|inventory|literature-research|stochastic-process|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3413" PostTypeId="2" ParentId="3405" CreationDate="2020-01-26T18:22:30.643" Score="3" Body="&lt;p&gt;Mathematically, you could write the following.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$V = \{1,2,\dots,n\}$&lt;/span&gt; be the set of vertices. Each directed arc from &lt;span class=&quot;math-container&quot;&gt;$i \in V$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j \in V$&lt;/span&gt; is denoted by &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;. The set &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is the set of all arcs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The constraint can then be stated as &#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i\le x_j\quad\forall (i,j) \in E.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is more natural, because &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; now always refers to vertex &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, where the current definition uses &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; as placeholders.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2020-01-26T18:22:30.643" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3415" PostTypeId="1" CreationDate="2020-01-27T12:43:05.720" Score="4" ViewCount="71" Body="&lt;p&gt;I have made some progress on my previous question (&lt;a href=&quot;https://or.stackexchange.com/questions/3390/is-there-a-known-milp-to-schedule-routes-after-routes-are-made&quot;&gt;Is there a known MILP to schedule routes after routes are made&lt;/a&gt;).&lt;br&gt;&#xA;I have derived the sets of the problem, which are:&lt;br&gt;&#xA;1) Itineraries of vehicle: &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt;&lt;br&gt;&#xA;2) Customer &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in itinerary &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$c_{ij} \in C$&lt;/span&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the following Parameters.&lt;br&gt;&#xA;1) Start of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;-th time window of itinerary &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$tws_{ij}$&lt;/span&gt;&lt;br&gt;&#xA;2) End of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;-th time window of itinerary &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$twe_{ij}$&lt;/span&gt;&lt;br&gt;&#xA;3) Duration of travel from customer &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to customer &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; of itinerary &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;:  &lt;span class=&quot;math-container&quot;&gt;$d_{ijk}$&lt;/span&gt;&lt;br&gt;&#xA;4) Processing Time of customer &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; of itinerary &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$P_{ij}$&lt;/span&gt;&lt;br&gt;&#xA;5) Waiting time: &lt;span class=&quot;math-container&quot;&gt;$wt$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With decision variables:&lt;br&gt;&#xA;1) &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt;: Start of service at customer &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; of itinerary &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The certain constraints up to now are:&lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}c_{ij} + P_{ij} + d_{ij(j+1)} - c_{i(j+1)} &amp;amp;\leqslant 0, &amp;amp;&amp;amp;\forall i\in I,j\in C\\c_{ij} + wt &amp;amp;\geqslant tws_{ij} , &amp;amp;&amp;amp;\forall i\in I,j\in C\\c_{ij} &amp;amp;\leqslant twe_{ij}, &amp;amp;&amp;amp;\forall i\in I,j\in C\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These three sets of constraints ensure the time windows violations for each itinerary, and the ban of overlapping customers within an itinerary. My question is the following. How can I ensure the ban of overlapping for each itinerary with the other?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much!&lt;/p&gt;&#xA;" OwnerUserId="1243" LastEditorUserId="1243" LastEditDate="2020-01-28T08:00:54.163" LastActivityDate="2020-01-28T08:00:54.163" Title="Continue on &quot;Is there a known MILP to schedule routes after routes are made&quot;" Tags="|optimization|mixed-integer-programming|linear-programming|integer-programming|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3416" PostTypeId="1" AcceptedAnswerId="3424" CreationDate="2020-01-27T13:21:15.423" Score="9" ViewCount="1804" Body="&lt;p&gt;Following the accepted answer to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/3401/assignment-problem-where-assignments-must-be-done-sequentially/&quot;&gt;Assignment problem where assignments must be done sequentially&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to write a Python script which can solve the problem defined there. It's a Mixed Integer Linear Programming problem, thus I need an Open Source MILP solver, and a modeler. The constraints are probably very simple for you guys, but since I'm not familiar with MILP, it would be great if the modeler had an intuitive, easy to use API. Can you indicate me a Python modeler and solver which I can use to solve the problem? If you could also help me describing the MILP problem in the question above, using the modeler API, that would be great.&lt;/p&gt;&#xA;" OwnerUserId="2981" LastEditorUserId="2981" LastEditDate="2020-01-28T13:00:16.123" LastActivityDate="2020-01-30T18:18:38.213" Title="Open Source MILP software for Python with user-friendly API to define the optimization problem" Tags="|mixed-integer-programming|linear-programming|python|assignment-problem|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3417" PostTypeId="2" ParentId="3351" CreationDate="2020-01-27T14:15:00.477" Score="4" Body="&lt;p&gt;It might very well be the case that your machine is starting to &quot;swap&quot;, i.e. the hard drive is used for additional memory since the RAM is already exhausted. This will also dramatically increase IO time so your CPU is barely working because it takes too long to read/write new data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See here for more info: &lt;a href=&quot;https://en.wikipedia.org/wiki/Paging&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Paging&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For such a huge model, you should definitely look for a machine with a lot more memory. And even then you should be prepared to wait a while until you see some progress.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend you try to find a different way to model your problem - maybe there is a way to decompose it into smaller problems.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2020-01-27T14:15:00.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3418" PostTypeId="1" AcceptedAnswerId="3422" CreationDate="2020-01-27T15:09:38.390" Score="9" ViewCount="961" Body="&lt;p&gt;Currently, I am working on the &lt;strong&gt;implementation&lt;/strong&gt; of a formulation for an optimization problem, at the moment I already have the MIP formulation implemented in &lt;strong&gt;C++&lt;/strong&gt; using &lt;strong&gt;Cplex studio 12.10&lt;/strong&gt; with the &lt;strong&gt;Concert technology&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However&lt;/strong&gt;, for a given instance, the current implementation can not find any &lt;strong&gt;integer&lt;/strong&gt; feasible solution, although that the instance is feasible (I checked it using a heuristic approach to find a feasible solution to the instance).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I was thinking about the possibility of &lt;strong&gt;some set of constraints&lt;/strong&gt; is making the &lt;strong&gt;formulation invalid&lt;/strong&gt;, i.e., some set of constraints is making the formulation not find an &lt;strong&gt;integer feasible solution&lt;/strong&gt;. After hours of &lt;strong&gt;code debugging&lt;/strong&gt;, checking if the formulation was implemented right, and I could not find any error in the code, also, the formulation (&lt;strong&gt;theoretically&lt;/strong&gt;) is right. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, currently, I am trying to use the &lt;strong&gt;MIP Start&lt;/strong&gt; strategy to input the instance feasible solution (achieved through the heuristic method) in the solver, and then in someway detect which constraints are being violated by the given solution. I know that I can give a solution to the Cplex solver using the function &lt;code&gt;cplex.addMIPStart(x_var, x_val, effort_level)&lt;/code&gt;, also I know very vaguely that I can use the &lt;strong&gt;conflict refiner&lt;/strong&gt; strategy to find the unrespected constraints (if they exist). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am here to ask for help in the second strategy, the &lt;strong&gt;conflict refiner&lt;/strong&gt;, I know some &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/pt/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/infeas_unbd/conflict_refiner/24_eg_chg_ilomipex2_cpp.html&quot; rel=&quot;noreferrer&quot;&gt;links&lt;/a&gt; on the IBM Cplex resources web page, however at the moment I could not find any resource that approaches the using of &lt;strong&gt;MIP Start&lt;/strong&gt; with &lt;strong&gt;conflict refiner&lt;/strong&gt; to find which constraints of the model are not being respected. Hence, I would like to know if someone worked wit this before, and I could help me with this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastActivityDate="2020-01-27T20:38:23.233" Title="Check which constraints are violated (Concert - Cplex Studio 12.10 - C++)" Tags="|mixed-integer-programming|cplex|c++|implementation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3419" PostTypeId="1" CreationDate="2020-01-27T15:33:48.053" Score="9" ViewCount="1366" Body="&lt;p&gt;Using CPLEX via its Python API, I encountered a &quot;weird&quot; behavior. &#xA;For some instances, with a limited number of threads (10 in my tests), the instances cannot be solved after 10 days (afterwards, the memory is full). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when relaunching the solver on the same instance but without thread limitation (14 on my machine), the same instance is solved within a few seconds!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no objective function in my MIP (I just want the satisfaction of the constraints). I know that it could be &quot;luck&quot; in the enumeration, but I found it quite strange that allowing a few more threads totally changes the solving time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it something &quot;normal&quot;? Is there a reason of such behavior? &#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="2990" LastEditorUserId="123" LastEditDate="2020-01-27T19:40:22.127" LastActivityDate="2020-01-29T01:43:13.247" Title="CPLEX, number of threads and solving time" Tags="|cplex|parallel-computing|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3420" PostTypeId="2" ParentId="3320" CreationDate="2020-01-27T18:00:40.357" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/examples/modify_a_model.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt; that @EhsanK posted already covers the question pretty well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In such a case, Gurobi should choose the best suited algorithm on its own. Check out this little example, where I read and optimize a linear model, add a new constraint, and optimize again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In [20]: m = gp.read('C:/gurobi900/win64/examples/data/afiro.mps')&#xA;Read MPS format model from file C:/gurobi900/win64/examples/data/afiro.mps&#xA;Reading time = 0.01 seconds&#xA;AFIRO: 27 rows, 32 columns, 83 nonzeros&#xA;&#xA;In [21]: m.optimize()&#xA;Gurobi Optimizer version 9.0.0 build v9.0.0rc2 (win64)&#xA;Optimize a model with 27 rows, 32 columns and 83 nonzeros&#xA;Model fingerprint: 0x0e972b37&#xA;Coefficient statistics:&#xA;  Matrix range     [1e-01, 2e+00]&#xA;  Objective range  [3e-01, 1e+01]&#xA;  Bounds range     [0e+00, 0e+00]&#xA;  RHS range        [4e+01, 5e+02]&#xA;Presolve removed 18 rows and 20 columns&#xA;Presolve time: 0.01s&#xA;Presolved: 9 rows, 12 columns, 32 nonzeros&#xA;&#xA;Iteration    Objective       Primal Inf.    Dual Inf.      Time&#xA;       0   -5.9751945e+02   5.541356e+01   0.000000e+00      0s&#xA;       6   -4.6475314e+02   0.000000e+00   0.000000e+00      0s&#xA;&#xA;Solved in 6 iterations and 0.01 seconds&#xA;Optimal objective -4.647531429e+02&#xA;&#xA;In [22]: obj = m.getObjective()&#xA;&#xA;In [23]: m.addConstr(obj &amp;gt;= -460)&#xA;Out[23]: &amp;lt;gurobi.Constr *Awaiting Model Update*&amp;gt;&#xA;&#xA;In [24]: m.optimize()&#xA;Gurobi Optimizer version 9.0.0 build v9.0.0rc2 (win64)&#xA;Optimize a model with 28 rows, 32 columns and 88 nonzeros&#xA;Coefficient statistics:&#xA;  Matrix range     [1e-01, 1e+01]&#xA;  Objective range  [3e-01, 1e+01]&#xA;  Bounds range     [0e+00, 0e+00]&#xA;  RHS range        [4e+01, 5e+02]&#xA;Iteration    Objective       Primal Inf.    Dual Inf.      Time&#xA;       0   -4.6475314e+02   5.941429e-01   0.000000e+00      0s&#xA;       1   -4.6000000e+02   0.000000e+00   0.000000e+00      0s&#xA;&#xA;Solved in 1 iterations and 0.01 seconds&#xA;Optimal objective -4.600000000e+02&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, the second model is solved almost immediately within one iteration, by re-using the previous solution.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2020-01-27T18:00:40.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3421" PostTypeId="2" ParentId="3419" CreationDate="2020-01-27T20:35:34.530" Score="8" Body="&lt;p&gt;I wouldn't call this &quot;normal&quot;, but then I rarely use the term &quot;normal&quot; for anything involving MIPs. If the optimal solution from the quick run is close to the best bound from the long run, then yes, this could just be luck (the 14 thread run happened to stumble on the optimal solution quickly). If the 10 day best bound is significantly inferior, then it's a bit less clear that we are looking at luck ... but it is still possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Among other things, I think CPLEX will turn several different algorithms loose on the root node in parallel, with whichever one solves the root node first the &quot;winner&quot; (meaning branch-and-cut will use the root solution it got). I'm not sure how changing from 10 to 14 threads would influence that, but you could conceivably wind up with a different initial basis (particularly since your objective function is constant, so all basic feasible solutions are &quot;optimal&quot;). That in turn could result in different cuts and bound tightening results, altering the search tree quite a bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the default setting for the parallel mode switch is &quot;auto&quot;, meaning CPLEX will choose between deterministic and opportunistic use of parallel threads (with the latter, as you would expect, not being particularly deterministic). You could try running both 10 and 14 threads in deterministic mode (not running the 10 thread version too long, of course) and see if things change.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-01-27T20:35:34.530" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3422" PostTypeId="2" ParentId="3418" CreationDate="2020-01-27T20:38:23.233" Score="6" Body="&lt;p&gt;You don't actually need to use the MIP start approach. Fix the upper and lower bounds for all your discrete variables to their values in the heuristic solution, then try to solve the model. Assuming CPLEX asserts that the modified model is infeasible, invoke the conflict refiner to see which constraints (in addition to at least some of your modified bounds) contribute to infeasibility.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-01-27T20:38:23.233" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3423" PostTypeId="2" ParentId="3416" CreationDate="2020-01-27T20:47:08.603" Score="7" Body="&lt;p&gt;I'm not a Python user, but I've heard good things about &lt;a href=&quot;http://www.pyomo.org/&quot; rel=&quot;noreferrer&quot;&gt;Pyomo&lt;/a&gt;, which is an open-source modeling language. In addition to Pyomo, you would need a solver program (from among those they support), but you would not need to worry about any syntax issues related to the solver.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-01-27T20:47:08.603" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3424" PostTypeId="2" ParentId="3416" CreationDate="2020-01-27T21:19:45.753" Score="7" Body="&lt;p&gt;I find Pulp is extremely easy to use, versatile and has good performance. Check it out here: &lt;a href=&quot;https://pythonhosted.org/PuLP/solvers.html&quot; rel=&quot;noreferrer&quot;&gt;https://pythonhosted.org/PuLP/solvers.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="33" LastActivityDate="2020-01-27T21:19:45.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3425" PostTypeId="2" ParentId="3419" CreationDate="2020-01-27T23:02:41.347" Score="14" Body="&lt;p&gt;What you encounter is called &lt;strong&gt;performance variability&lt;/strong&gt;, it was first (?) observed by &lt;a href=&quot;http://coral.ie.lehigh.edu/mip-2008/talks/danna.pdf&quot; rel=&quot;noreferrer&quot;&gt;Emilie Danna&lt;/a&gt;. Yes, B&amp;amp;B is an exact method, but during the run, a lot of heuristic decisions are taken, which variable to branch on, which node to select, which primal heuristic to run... Many of these decisions are based on some sort of &lt;em&gt;score&lt;/em&gt;. When several entities (like fractional variables) have the same score, it is &quot;implementation dependent&quot; what happens; it may depend e.g., on the order in which items are stored in a data structure, which in turn may depend on the order in which the model is read etc. etc. etc. It was depressing in the beginning because it means that some speedups or slowdowns may actually be only noise. Then, people started to make use of this phaenomenon, like here by &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/educ.2013.0112&quot; rel=&quot;noreferrer&quot;&gt;Andrea Lodi and Andrea Tramontani&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2020-01-27T23:02:41.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3426" PostTypeId="1" AcceptedAnswerId="3427" CreationDate="2020-01-28T07:34:17.697" Score="10" ViewCount="1046" Body="&lt;p&gt;I was hoping to get some help in modelling the following logic as an MIP Constraint &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$X_{ij}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\text{SDV}_{ikj}=1$&lt;/span&gt; for a particular index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\text{SOC}^L_i=100$&lt;/span&gt;, else &lt;span class=&quot;math-container&quot;&gt;$\text{SOC}^L_i$&lt;/span&gt; can take any value.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\text{SDV}_{ikj}$&lt;/span&gt; are binary decision variables, while &lt;span class=&quot;math-container&quot;&gt;$\text{SOC}^L_i$&lt;/span&gt; is a system variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured it would use some kind of Big M formulation but I am not sure how. Thank you in advance!&lt;/p&gt;&#xA;" OwnerUserId="2995" LastEditorUserId="123" LastEditDate="2020-01-28T08:00:45.187" LastActivityDate="2020-01-28T19:37:45.373" Title="Modelling an if-then-else logic in MIP" Tags="|mixed-integer-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3427" PostTypeId="2" ParentId="3426" CreationDate="2020-01-28T08:07:03.730" Score="8" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{SOC}_i^L \ge 100 - M \times (1- X_{i,j}) - M \times (1- \text{SDV}_{i,k,j})$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{SOC}_i^L \le 100 + M \times (1- X_{i,j}) + M \times (1- \text{SDV}_{i,k,j})$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When &lt;span class=&quot;math-container&quot;&gt;$X_{i,j} = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$SDV_{i,k,j} = 1$&lt;/span&gt; the two equations above will end up becoming:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{SOC}_i^L \ge 100 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{SOC}_i^L \le 100 $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, the range of &lt;span class=&quot;math-container&quot;&gt;$\text{SOC}_i^L$&lt;/span&gt; will be &lt;span class=&quot;math-container&quot;&gt;$[-M, +M]$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="123" LastEditDate="2020-01-28T19:37:45.373" LastActivityDate="2020-01-28T19:37:45.373" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3428" PostTypeId="1" AcceptedAnswerId="3429" CreationDate="2020-01-28T09:52:12.547" Score="12" ViewCount="561" Body="&lt;p&gt;Suppose you are solving a minimization problem with a column generation procedure, and that you have &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; sub-problems. At some point, one of the &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; sub-problems is no longer able to generate a column with negative reduced cost. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does this sub-problem never have to be solved again ? Or is it possible that a few iterations later, given the interaction with new columns from the other sub-problem, it is possible that a new column may be found ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks !&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-01-28T10:08:49.770" Title="When using column generation, can a sub-problem be ignored once and for all once it fails to generate a new column?" Tags="|column-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3429" PostTypeId="2" ParentId="3428" CreationDate="2020-01-28T09:55:04.667" Score="16" Body="&lt;p&gt;You can only stop when &lt;em&gt;all&lt;/em&gt; subproblems fail to find a negative reduced cost column. So, &lt;strong&gt;no&lt;/strong&gt;, when one subproblem does not find a column in one iteration you cannot conclude that you need not call it again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below you see an instance with 40+ subproblems (one for each color). Over the iterations, in fact most subproblems are unsuccessful, but later still find columns. This plot shows the initial Farkas pricing (when the RMP is still infeasible), the root node, and the remainder of the tree.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/OY7s3.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OY7s3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="354" LastEditDate="2020-01-28T10:08:49.770" LastActivityDate="2020-01-28T10:08:49.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3431" PostTypeId="1" CreationDate="2020-01-28T14:21:11.373" Score="6" ViewCount="181" Body="&lt;p&gt;I was reading Tobias Achterberg's &lt;a href=&quot;https://opus4.kobv.de/opus4-zib/files/1112/Achterberg_Constraint_Integer_Programming.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;thesis&lt;/a&gt;, and on page 138 he mentions the following presolving technique for linear equations (I'm slightly paraphrasing Example 10.2):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Consider the equation &lt;span class=&quot;math-container&quot;&gt;$4x_1+7x_2+3x_3+s=20$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$s\geq0$&lt;/span&gt;, and assume that &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; does not appear in other constraints. Then, we replace the equation with the inequality &lt;span class=&quot;math-container&quot;&gt;$4x_1+7x_2+3x_3\leq20$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What are the benefits of doing this? Sure, this way we remove a variable from the problem, but won't an equivalent variable just be added back in when we bring the MIP to canonical form in order to apply dual simplex?&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-01-28T15:54:24.850" LastActivityDate="2020-01-28T15:54:24.850" Title="Benefits of removing slack variables during presolve" Tags="|mixed-integer-programming|linear-programming|presolve-preprocessing|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3432" PostTypeId="2" ParentId="3426" CreationDate="2020-01-28T15:01:30.303" Score="8" Body="&lt;p&gt;More generally, if &lt;span class=&quot;math-container&quot;&gt;$s\in[L,U]$&lt;/span&gt;, you can model &lt;span class=&quot;math-container&quot;&gt;$(x=1 \land y=1) \implies s=C$&lt;/span&gt; (constant &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;) as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x + y - 1 \le z\\&#xA;(L-C)(1-z) \le s - C \le (U-C)(1-z)\\&#xA;z\in\{0,1\} &#xA;$$&lt;/span&gt;&#xA;This approach introduces an additional binary variable and constraint beyond @anoopyadav's model but avoids &lt;span class=&quot;math-container&quot;&gt;$2M$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-01-28T16:40:37.140" LastActivityDate="2020-01-28T16:40:37.140" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3433" PostTypeId="1" CreationDate="2020-01-28T19:17:44.047" Score="3" ViewCount="65" Body="&lt;p&gt;I have a continuous variable &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; which has value in between &lt;span class=&quot;math-container&quot;&gt;$[-R, +R]$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to create a boolean variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x = 1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$c = 1.0$&lt;/span&gt; otherwise &lt;span class=&quot;math-container&quot;&gt;$x = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In more general form:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x = 1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$c \in [-k, +k]$&lt;/span&gt; otherwise &lt;span class=&quot;math-container&quot;&gt;$x = 0$&lt;/span&gt; here &lt;span class=&quot;math-container&quot;&gt;$[-k, +k]$&lt;/span&gt; is a new range inside &lt;span class=&quot;math-container&quot;&gt;$[-R, +R]$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="700" LastActivityDate="2020-01-28T19:17:44.047" Title="Extract binary value from continuous variable" Tags="|mixed-integer-programming|linear-programming|linearization|" AnswerCount="0" CommentCount="0" ClosedDate="2020-01-28T19:41:59.650" ContentLicense="CC BY-SA 4.0" />
  <row Id="3434" PostTypeId="1" AcceptedAnswerId="3437" CreationDate="2020-01-28T20:38:55.123" Score="14" ViewCount="383" Body="&lt;p&gt;I'm currently working on the following problem (a variant of maximal k-covering problem):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max&amp;amp;\quad z =\sum\limits_{\omega\in \Omega}x_{\omega}&#xA;\label{imbip3a} \\&#xA;\text{s.t.}&amp;amp;\quad &#xA;\sum\limits_{i\in \mathcal{V}}y_{i} = k &amp;amp;&#xA;\label{imbip3b} \\&#xA;&amp;amp;\quad x_{\omega}\leq\sum\limits_{j\in P_\omega}y_{j} &amp;amp; \: \omega \in \Omega &#xA;\label{imbip3c} \\&#xA;&amp;amp;\quad x_{\omega}, y_i \in \left\{0,1\right\} &amp;amp; \:i\in \mathcal{V}, \omega \in \Omega&#xA;\label{imbip3d}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My instances are typically very large with millions of variables so commercial solvers are usually get stuck. For this reason I'm using Lagrangian Relaxation where I relax the second set of constraints to obtain the following sub-problem :&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max&amp;amp;\quad z_{\rm LR} =\sum\limits_{\omega\in \Omega}\left(1-\lambda_{\omega}\right)x_{\omega} &#xA;+ \left(\sum\limits_{\omega\in \Omega_i} \lambda_{\omega} \right)y_i&#xA;\label{imbip5a} \\&#xA;\text{s.t.}&amp;amp;\quad&#xA;\sum\limits_{i\in \mathcal{V}}y_{i} = k&#xA;\label{imbip5b} \\&amp;amp;\quad &#xA;x_{\omega}, y_i \in \left\{0,1\right\},\quad i\in \mathcal{V}, \omega \in \Omega&#xA;\label{imbip5d}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relaxed problem can be solved by inspection: if &lt;span class=&quot;math-container&quot;&gt;$1-\lambda_{\omega}\geq 0$&lt;/span&gt;, we set &lt;span class=&quot;math-container&quot;&gt;$x_{\omega}$&lt;/span&gt; to one and zero otherwise.&#xA;Similarly, we compute &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{\omega\in \Omega_i} \lambda_{\omega}$&lt;/span&gt; values for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and then rank them in a descending order and pick top &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; of them and set the corresponding &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; to one.&#xA;Together with subgradient optimization to update the Lagrangian parameters &lt;span class=&quot;math-container&quot;&gt;$\lambda_{\omega}$&lt;/span&gt; a scalable algorithm is obtained with no need for a commercial solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm applying the classical (basic) sub-gradient method where I face a lot of zigzagging and slow convergence. I've been checking the LR and sub-gradient optimization literature and I've seen various methods to speed-up and avoid zigzagging, such as using deflected directions, bundle methods, incremental subgradients, surrogate LR..etc. I'm not sure which would help me the best and before diving to the details of each of these methods (and coding them) I would like to ask the community. So if you have any experience on these speeding methods, what would you recommend?&lt;/p&gt;&#xA;" OwnerUserId="632" LastEditorUserId="123" LastEditDate="2020-01-28T20:43:21.223" LastActivityDate="2020-01-29T14:31:21.860" Title="How to Speed Up the subgradient optimization procedure in a Lagrangian Relaxation Scheme" Tags="|lagrangian-relaxation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3435" PostTypeId="2" ParentId="3416" CreationDate="2020-01-29T01:27:35.457" Score="2" Body="&lt;p&gt;As suggested above, PULP is one of the open source solver. Apart from this, the best MILP solver available in open source is preferably offered in SCIP optimization suite. I think Google OR tools are built using SCIP only. Moreover, you can refer to &lt;a href=&quot;https://www.coin-or.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;COIN-OR&lt;/a&gt; where researchers from ORMS society have maintained their projects.&lt;/p&gt;&#xA;" OwnerUserId="2999" LastEditorUserId="123" LastEditDate="2020-01-29T07:41:22.777" LastActivityDate="2020-01-29T07:41:22.777" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3436" PostTypeId="2" ParentId="3419" CreationDate="2020-01-29T01:43:13.247" Score="3" Body="&lt;p&gt;I had a similar observation while running my developed optimization framework (based on column generation) on different machines. Being new to this phenomenon, I was confused for days to see these performance variations even after fixing random number seeds from different packages. Later, I found that the LP solver is giving a slightly different answer in each iteration of a Column Generation approach which is because of the fact that the order of input variables to LP are changing due to usage of multiprocessing techniques while generation of these variables. Hence, the order of variables/constraints or any other change in model may bring such performance variations.&lt;/p&gt;&#xA;" OwnerUserId="2999" LastActivityDate="2020-01-29T01:43:13.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3437" PostTypeId="2" ParentId="3434" CreationDate="2020-01-29T14:31:21.860" Score="5" Body="&lt;p&gt;In my experience, this sort of thing just requires a lot of trial and error. An SO variant that works well for one problem may not work as well for another, so you just have to implement and test a lot of stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, one important thing to determine is how good the (upper) bound is. That is, if you &lt;em&gt;could&lt;/em&gt; find the optimal multipliers, how tight would the bound that they provide be? Your subproblem has the integrality property, so the bound will be the same as the LP relaxation bound. So you can test the LR bound just by solving the LP relaxation and comparing it to the known optimal IP solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the LR bound is weak, then no amount of SO tweaking is going to help you too much. You'll have to focus instead on tightening the bound, or finding a good branching scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Actually, I suspect that your bound is relatively tight, since the max covering problem usually has tight LP bounds, and your problem is basically identical to a max-cover problem if you interpret the scenarios as customers.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably already know, but &lt;a href=&quot;https://doi.org/10.1016/0377-2217(94)00159-6&quot; rel=&quot;noreferrer&quot;&gt;Galvao and ReVelle (&lt;em&gt;EJOR&lt;/em&gt; 1996)&lt;/a&gt; propose exactly the LR algorithm you are discussing. I haven't read that paper in a long time and I can't remember if they discuss solving large instances, but you could check.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-01-29T14:31:21.860" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3438" PostTypeId="1" AcceptedAnswerId="3439" CreationDate="2020-01-29T15:06:00.430" Score="7" ViewCount="1574" Body="&lt;p&gt;The question says it all. I am having difficulties formulating general problems (meaning no numbers just variables). When I read the solution, I understand but I can't figure how to formulate myself in new problems. I need some tips or what to look for, some guidance in general. By formulation I mean finding the objective to be minimized/maximized and the constraints. Here is an example with the solution (you can just look at the solution to understand what I mean):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Formulate   the   problem   of   finding   an   optimal timetable  for  a  school.   The  timetable  is  represented  by variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,k} \in \{0,1\}$&lt;/span&gt;.  The index &lt;span class=&quot;math-container&quot;&gt;$i\in \{1, ...,6\}$&lt;/span&gt; stands for the timeslot (with the duration of one lesson) on a day from  the  morning  to  the  late  afternoon.   The  index &lt;span class=&quot;math-container&quot;&gt;$j=\{1, ...,5\}$&lt;/span&gt; stands for a weekday.  The index &lt;span class=&quot;math-container&quot;&gt;$k\in \{1, ...,6\}$&lt;/span&gt; stands for the subject.  The index &lt;span class=&quot;math-container&quot;&gt;$\in \{1,2,3\}$&lt;/span&gt; stands for the classroom.The decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,k}$&lt;/span&gt; is set equal to 1 if subject &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is given in timeslot &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.  Otherwise &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,k}$&lt;/span&gt; is set equal to 0. Formulate the mathematical program under the following constraints:  (C1) Subject 1,2 and 3 are given 6 timeslots per week, subjects 4, 5 and 6 only 3 timeslots per week. (C2)  At  every  time,  a  classroom  can  be  used  only  for  one  subject.   (C3)  The  same subject cannot be taught in parallel at the same time.  (C4) the same subject should not be taught more than two times per day.  Moreover, the total number of lessons taught in timeslots 1, 5 and 6 should be minimized.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The image has the solution)&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/gIpT2.png&quot; alt=&quot;Link for solution&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3001" LastEditorUserId="491" LastEditDate="2020-01-29T18:05:22.627" LastActivityDate="2020-01-29T19:05:24.580" Title="How to formulate problems in the language of mathematical programming?" Tags="|optimization|linear-programming|modeling|integer-programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3439" PostTypeId="2" ParentId="3438" CreationDate="2020-01-29T15:21:52.753" Score="12" Body="&lt;p&gt;This is quite a broad question, and I'm not sure you'll get the answers you need here. To learn how to formulate mathematical optimization problems takes learning and practice, and there's no concrete answer that we can provide on a Q&amp;amp;A site like this. Your best bet is to take a class that teaches or uses optimization modeling, or to learn from a good book.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, there are some relevant Q&amp;amp;As on this site that might help you:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/869/what-are-good-reference-books-for-introduction-to-operations-research&quot;&gt;What are good reference books for introduction to operations research?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/117/recommended-books-materials-for-practical-applications-of-operations-research-in&quot;&gt;Recommended books/materials for practical applications of Operations Research in industry&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/2605/ive-formulated-my-optimization-model-now-what&quot;&gt;I&amp;#39;ve formulated my optimization model; now what?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can also check out the questions tagged &lt;a href=&quot;/questions/tagged/modeling&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;modeling&amp;#39;&quot; rel=&quot;tag&quot;&gt;modeling&lt;/a&gt;. Good luck!&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-01-29T15:21:52.753" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3440" PostTypeId="2" ParentId="117" CreationDate="2020-01-29T15:33:15.157" Score="6" Body="&lt;p&gt;Another good reference in my opinion : &lt;a href=&quot;https://mitmgmtfaculty.mit.edu/jorlin/network-flows/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Network Flows&lt;/a&gt; by Ahuja et al.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It focuses on ... networks as hinted by the title, but it is incredible all the problems that can be tackled with such structures. Solutions of odd numbered exercises are also available, which is helpful when learning on your own.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2020-01-29T20:10:32.147" LastActivityDate="2020-01-29T20:10:32.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3441" PostTypeId="1" AcceptedAnswerId="3619" CreationDate="2020-01-29T17:50:22.070" Score="10" ViewCount="1528" Body="&lt;p&gt;I had a number of students claim on their homework that &quot;All &lt;span class=&quot;math-container&quot;&gt;$z_j-c_j$&lt;/span&gt; values are positive, therefore the solution is optimal.&quot; Of course, I noted that they should say &quot;non-negative&quot; instead of &quot;positive&quot; or restrict their statement to just the non-basic variables, but this started me thinking: could we have a case where &lt;strong&gt;all&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$z_j -c_j$&lt;/span&gt; values are (strictly) positive?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The homework problem originally was for a maximization problem, but here I'll pose it for a minimization problem, so now we want &lt;span class=&quot;math-container&quot;&gt;$c_j - z_j &amp;gt; 0$&lt;/span&gt;.  Consider a linear program &lt;span class=&quot;math-container&quot;&gt;$$\begin{align*} \min &amp;amp;\quad  \mathbf{cx} \\ \textrm{s.t. } &amp;amp;\quad A\mathbf{x} \geq \mathbf{b}, \end{align*}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{m \times n}$&lt;/span&gt; has full row-rank, and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{c}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}$&lt;/span&gt; are of corresponding dimensions. In most cases, we have &lt;span class=&quot;math-container&quot;&gt;$c_j - \mathbf{c}_B B^{-1}\mathbf{a}_j = c_j - z_j = 0$&lt;/span&gt; for all basic columns due to complementary slackness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2&lt;/strong&gt;: Prubin's answer points out that using the above formula cannot give strictly positive reduced costs, since the dual variables in the Simplex algorithm are always basic: &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w} = \mathbf{c}_B B^{-1}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At a degenerate optimal solution, where a variable &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; corresponds to constraint &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, so that &lt;span class=&quot;math-container&quot;&gt;$a_{ij}x_j = b_i$&lt;/span&gt;, we might conceivably have &lt;span class=&quot;math-container&quot;&gt;$c_j - z_j \neq 0$&lt;/span&gt; and still maintain complementary slackness.  Of course, in this case the dual problem has alternative optimal solutions.  I conjecture that in this degenerate case, we might obtain a non-basic dual solution such that all &lt;span class=&quot;math-container&quot;&gt;$c_j - z_j \neq 0$&lt;/span&gt;, but even then, we will be attracted to some basis.  However, I can't seem to build a proof for this.  On the flip side, we know there are cases of cycling in higher dimensions; could the case where all reduced costs are positive be an example of &quot;anti-cycling&quot; (rather than cycling between attractive directions, we cycle between unattractive ones)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can think of three possible answers to my question:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Prove that &lt;span class=&quot;math-container&quot;&gt;$c_j - z_j \neq 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$j=1,\ldots,n$&lt;/span&gt; is impossible at optimality.&lt;/li&gt;&#xA;&lt;li&gt;Prove that if &lt;span class=&quot;math-container&quot;&gt;$c_j - z_j \neq 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$j=1,\ldots,n$&lt;/span&gt; then there must exist some &lt;span class=&quot;math-container&quot;&gt;$c_j - z_j &amp;lt; 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Find a counter example, where &lt;span class=&quot;math-container&quot;&gt;$c_j - z_j &amp;gt; 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$j = 1,\ldots,n$&lt;/span&gt; at an optimal solution.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="324" LastEditorUserId="324" LastEditDate="2020-04-24T19:19:33.440" LastActivityDate="2020-04-24T19:19:33.440" Title="Can we have all reduced costs (strictly) positive?" Tags="|linear-programming|duality|reduced-costs|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3442" PostTypeId="1" AcceptedAnswerId="3443" CreationDate="2020-01-29T18:15:03.550" Score="8" ViewCount="739" Body="&lt;p&gt;I am reading about extensions on plain vanilla B&amp;amp;B and heuristics for smaller trees/better branching. I have come across diving heuristics, which on the SCIP &lt;a href=&quot;https://scip.zib.de/doc-4.0.1/html/DIVINGHEUR.php&quot; rel=&quot;noreferrer&quot;&gt;site&lt;/a&gt; is defined as: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A diving heuristic explores a single probing path down the search tree&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What I understand reading this is that it branches using a depth-first-search rule. &#xA;Does this make sense? If not, what does this mean, especially a single probing path?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, my other question is: when do we use this or other kinds of heuristics?&#xA;I understand that heuristics can be used to find which variable to branch on (for example the most fractional), but how would I know when to explore a single path and when not to?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In another document, driving heuristics were under a section named &quot;start heuristics&quot;. Does it mean that they are used to quickly find a feasible integer solution?&lt;/p&gt;&#xA;" OwnerUserId="3002" LastEditorUserId="36" LastEditDate="2020-01-29T18:48:49.893" LastActivityDate="2020-01-29T18:48:49.893" Title="Diving heuristics in branch and bound" Tags="|branch-and-bound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3443" PostTypeId="2" ParentId="3442" CreationDate="2020-01-29T18:35:45.177" Score="9" Body="&lt;p&gt;Diving heuristics are primarily used to find feasible points, and are more common in problems with integer variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Diving heuristics go down some branch of the tree until they (i) hit infeasibility, (ii) hit a pre-specified tree depth, or (iii) find a feasible point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In cases (i) and (ii) the algorithm will backtrack and repeat the diving process down a different path, either from the root or some other pre-specified tree depth. Backtracking is also done sometimes in case (iii) in an attempt to find feasible points with even better objective values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Diving can also be used to probe the results of branching and find an optimal variable selection sequence. This works by calculating the lower bounds for each node we explore. After we try &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; paths, we then chose the branching sequence that produces the best bound after a pre-set number of branching operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My experience however has been that this tends not to be very efficient - in practice we prefer strong branching in the first few nodes of the tree, and then switch to a cheaper heuristic, such as pseudo-costs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regardless of the method used, it is well established that good branching choices in the beginning of the algorithm can reduce the total number of nodes we will have to explore significantly, therefore we are usually more than happy to spend some extra computing time in the beginning to run expensive heuristics.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-01-29T18:35:45.177" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3444" PostTypeId="2" ParentId="3438" CreationDate="2020-01-29T19:05:24.580" Score="10" Body="&lt;p&gt;Old joke (relevant here): A tourist asks a NYC cab driver &quot;How do I get to Carnegie Hall?&quot; Reply: &quot;Practice, practice, practice&quot;. I second Larry's answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One other note: I suggest starting with small, easy models and working your way up. The mere sight of triple summations has been know to fry synapses. Start with problems where the solution has a small number of simple constraints. Formulate the model as best you can without looking at the solution (beyond a glance to ascertain that it's small / simple), then see how your model compares to the solution.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-01-29T19:05:24.580" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3445" PostTypeId="1" CreationDate="2020-01-29T19:49:08.987" Score="6" ViewCount="676" Body="&lt;p&gt;After developing the MIP model I noticed that solver is taking a lot of time to reach the solution. So, how should I approach to optimize the current model?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any visualization tools or any tools that are helpful in optimizing the model.&lt;/p&gt;&#xA;" OwnerUserId="700" LastActivityDate="2020-01-30T14:27:46.337" Title="Optimising the current model" Tags="|mixed-integer-programming|linear-programming|modeling|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3446" PostTypeId="1" CreationDate="2020-01-30T05:13:16.907" Score="7" ViewCount="112" Body="&lt;p&gt;I'm looking for an optimization model about production planning that takes the following into consideration:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Single site  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Multi products  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;One machine/resource  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sequence-dependent  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fixed batch size  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Set-up times  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;No back orders  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Capacity limitations  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I understand that no finished model takes all this into consideration. I have looked at some lot-sizing problem, but the batch size is not adjustable in my case. I have looked through the following references:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wolsey, L.,Pochet Y. (2006). &lt;em&gt;Production Planning by Mixed Integer Programming&lt;/em&gt;. Springer Seriers in Operations Research and Financial Engineering. ISBN: 978-0387-29959-4 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trigeiro, W., Thomas, L. and McClain, J. (1989). &lt;em&gt;Capacitated Lot Sizing with Setup Times.&lt;/em&gt; Management Science, 35(3), pp.353-366.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Voß, S., 2006. &lt;em&gt;Introduction To Computational Optimization Models For Production Planning In A Supply Chain&lt;/em&gt;. Springer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you guys point me in the right direction regarding references or key-words?&lt;/p&gt;&#xA;" OwnerUserId="3003" LastEditorUserId="36" LastEditDate="2020-01-30T06:18:40.437" LastActivityDate="2020-01-30T06:40:31.490" Title="Aggregate production planning" Tags="|optimization|reference-request|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3447" PostTypeId="2" ParentId="3441" CreationDate="2020-01-30T05:35:54.130" Score="0" Body="&lt;p&gt;Based on &lt;a href=&quot;https://en.wikipedia.org/wiki/Reduced_cost&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In linear programming, reduced cost, or opportunity cost, is the amount by which an objective function coefficient would have to improve (so increase for maximization problem, decrease for minimization problem) before it would be possible for a corresponding variable to assume a positive value in the optimal solution. Given a system as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*} \min &amp;amp;\quad  \mathbf{cx} \\ \textrm{s.t. } &amp;amp;\quad A\mathbf{x} \leq \mathbf{b}, \end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For maximization problem in the optimality, all non-basic variables have &lt;span class=&quot;math-container&quot;&gt;$z_j - c_j \geq 0$&lt;/span&gt;, whereas in minimization problem all non-basic variables in the optimality have &lt;span class=&quot;math-container&quot;&gt;$z_j - c_j \leq 0$&lt;/span&gt;. (All basic variables have &lt;span class=&quot;math-container&quot;&gt;$z_j - c_j = 0$&lt;/span&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-01-30T05:35:54.130" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3448" PostTypeId="2" ParentId="3445" CreationDate="2020-01-30T05:53:29.413" Score="2" Body="&lt;p&gt;To add @ Mark L. Stone mentioned:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommended you could try solving your model using a small instance. (E.g. by reducing dimensions of the model's data.). If the model is solved optimality, you could pretty sure (with the large scale data), you would solve the model in an optimal sense. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To ensure that the solution is correct, you could solve the model using other solvers like CBC or GUROBI. To debug your model (if it was infeasible) you might write your model in an LP format and check it. (AFAIK, unfortunately, PuLp can not create LP format!!!).&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-01-30T05:53:29.413" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3449" PostTypeId="2" ParentId="3446" CreationDate="2020-01-30T06:40:31.490" Score="3" Body="&lt;p&gt;The last reference you mentioned is one of the nice books (specifically, in an algebraic modelling language). I would like to add other good references like: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://onlinelibrary.wiley.com/doi/book/10.1002/9781118029114&quot; rel=&quot;nofollow noreferrer&quot;&gt;Scheduling in Supply Chains Using Mixed Integer Programming&lt;/a&gt; by Tadeusz Sawik.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/gp/book/9783540430155&quot; rel=&quot;nofollow noreferrer&quot;&gt;Planning Stability in Material Requirements Planning Systems&lt;/a&gt; by Heisig, Gerald. &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/gp/book/9781441909091&quot; rel=&quot;nofollow noreferrer&quot;&gt;Planning and Scheduling in Manufacturing and Services&lt;/a&gt; by  Pinedo, Michael.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-01-30T06:40:31.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3450" PostTypeId="1" AcceptedAnswerId="3452" CreationDate="2020-01-30T08:35:34.633" Score="5" ViewCount="102" Body="&lt;p&gt;This is my first real optimization problem I formulated and now trying to solve by using AMPL.&lt;/p&gt;&#xA;&lt;p&gt;The following objective function is from a linear 0-1 LP means all variables &lt;span class=&quot;math-container&quot;&gt;$x_i^b\in\{0,1\}$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$i\in[1,n]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; referring to the type of the node, which means &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; say a node is or is not of a certain type.&lt;/p&gt;&#xA;&lt;p&gt;The objective function is as follows with &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; a set of nodes, &lt;span class=&quot;math-container&quot;&gt;$N[a]$&lt;/span&gt; a set of all neighbours of &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; including &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; a given number of types:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min - \sum_{a\in A}f\left(\frac1n\sum\limits_{i=1}^nf\left(\sum\limits_{b\in N[a]}x_i^b\right)\right)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f:\mathbb{R}\mapsto\{0,1\}\\&#xA;f(x):=\begin{cases}0,&amp;amp;x&amp;lt;1\\1,&amp;amp;x\geq 1\end{cases}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I already heard that AMPL doesn't support the definition of functions/methods and that I have to use the &lt;a href=&quot;https://en.wikipedia.org/wiki/Big_M_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Big M method&lt;/a&gt; to create this objective function. I couldn't really figure out yet how to use the method to replace my case distinctions.&lt;/p&gt;&#xA;" OwnerUserId="2989" LastEditorUserId="491" LastEditDate="2024-02-26T12:27:16.180" LastActivityDate="2024-02-26T17:01:56.103" Title="How to formulate case distinctions in AMPLs objective function?" Tags="|mixed-integer-programming|cplex|linearization|ampl|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3451" PostTypeId="1" CreationDate="2020-01-30T09:19:30.330" Score="7" ViewCount="1220" Body="&lt;p&gt;I am observing something unusual : after solving a linear program, some basic variables have negative reduced costs (instead of &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;) :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;CPLEX&amp;gt; display which sensitivity analysis: objective *&#xA;&#xA;Variable Name      Reduced Cost            Down         Current              Up&#xA;&#xA;Path_P168                  zero       -infinity     305767.0000       +infinity&#xA;Path_P198                  zero    1764192.0000    1790688.0000       +infinity&#xA;Path_P203           -13636.0000       -infinity      58440.0000      72076.0000&#xA;Path_P204           -51212.0000       -infinity     207739.0000     258951.0000&#xA;Path_P205           -35112.0000       -infinity     247247.0000     282359.0000&#xA;&#xA;&#xA;CPLEX&amp;gt; display solution variables *&#xA;&#xA;Variable Name           Solution Value&#xA;Path_P168                     1.000000&#xA;Path_P198                     0.094203&#xA;Path_P203                     1.000000&#xA;Path_P204                     1.000000&#xA;Path_P205                     1.000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In the above sensitivity report generated by CPLEX, variable &lt;strong&gt;Path_P203&lt;/strong&gt; for example, has value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and reduced cost &lt;span class=&quot;math-container&quot;&gt;$-13636$&lt;/span&gt;. The solution status is &lt;em&gt;optimal&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I thought this was impossible (as basic variables should have reduced costs equal to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;). Can someone provide an explanation ?&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="491" LastEditDate="2023-11-09T21:07:00.127" LastActivityDate="2023-11-09T21:07:00.127" Title="Negative reduced cost for basic variable" Tags="|linear-programming|cplex|simplex|sensitivity-analysis|reduced-costs|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3452" PostTypeId="2" ParentId="3450" CreationDate="2020-01-30T09:59:40.867" Score="3" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt; be some small value.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}M \times f(x) &amp;amp;\geq x - 1 + \rho\\M \times (1 - f(x)) &amp;amp;\geq 1 - x - \rho\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the small working code in Python &lt;code&gt;pulp&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import pulp as pl&#xA;&#xA;prob = pl.LpProblem(&quot;Problem&quot;, pl.LpMinimize)&#xA;x = 1&#xA;f = pl.LpVariable(&quot;f_{0}&quot;, 0, 1, pl.LpBinary)&#xA;prob += f&#xA;M = 100&#xA;prob += M * f &amp;gt;= x - 1 + 0.001&#xA;prob += M * (1 - f) &amp;gt;= 1 - x - 0.0001&#xA;&#xA;print(prob)&#xA;prob.solve()&#xA;&#xA;for v in prob.variables():&#xA;    print(v.name, &quot;=&quot;, v.varValue)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="700" LastEditorUserId="123" LastEditDate="2020-01-30T19:55:29.757" LastActivityDate="2020-01-30T19:55:29.757" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3453" PostTypeId="2" ParentId="3451" CreationDate="2020-01-30T14:08:52.867" Score="4" Body="&lt;p&gt;My guess would be that the variable is not basic, it is non-basic but at the upper bound of 1.0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modern solvers use the generalized simplex method which allows for lower and upper bounds on a variable. If a variable is upper bounded, its optimal reduced cost needs to be non-positive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't say I fully understand the output you pasted, but it looks like this is the case here.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2020-01-30T14:08:52.867" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3454" PostTypeId="2" ParentId="3445" CreationDate="2020-01-30T14:09:25.520" Score="6" Body="&lt;p&gt;Assuming that your problem is not taking too long simply because it's too large, the most likely reason is that your formulation is not strong enough.&lt;/p&gt;&#xA;&lt;h1&gt;Tools&lt;/h1&gt;&#xA;&lt;p&gt;The best tool is the output of the solver itself. You want to monitor the behaviour of your lower and upper bounds, the size of the branching pool, the time between iterations, whether a feasible solution has been found, and how long it takes to find the first one.&lt;/p&gt;&#xA;&lt;h1&gt;&lt;strong&gt;Diagnosis&lt;/strong&gt;&lt;/h1&gt;&#xA;&lt;h3&gt;If the solver can't close the gap&lt;/h3&gt;&#xA;&lt;p&gt;The greatest indicator of a weak formulation is that your solver is generating too many nodes which are not fathomed and remain in the branching pool. This typically results in the MIP gap improving very slowly.&lt;/p&gt;&#xA;&lt;p&gt;If the gap is improving slowly, a likely reason is degeneracy in your problem (multiple/infinite global solutions). This would either manifest as your solver exploring too many nodes, &lt;em&gt;or&lt;/em&gt; the number of nodes in your branching pool remaining roughly constant and your MIP gap not really improving much.&lt;/p&gt;&#xA;&lt;p&gt;Another reason could be that the bounds of your continuous variables (if you have any) are too large.&lt;/p&gt;&#xA;&lt;h3&gt;If the lower bound improves quickly and then stops&lt;/h3&gt;&#xA;&lt;p&gt;This would behave identically to the previous case if your solver has found a feasible solution. If it hasn't however, it might be the case that it's taking too long either because (a) your problem is infeasible and it's trying to prove it, or (b) because it's having trouble finding an integer solution.&lt;/p&gt;&#xA;&lt;p&gt;Another reason could be that your solver can find &lt;em&gt;some&lt;/em&gt; primal solution fairly easily, but has trouble finding better ones, which would cause it to run forever even if the lower bound is exact.&lt;/p&gt;&#xA;&lt;h3&gt;&lt;strong&gt;If each iteration is taking too long&lt;/strong&gt;&lt;/h3&gt;&#xA;&lt;p&gt;Best explanation is that your problem is too large, your computer is too slow, or you don't have enough RAM and the solver is forced to access your swap memory, which makes it much slower.&lt;/p&gt;&#xA;&lt;p&gt;If none of the above apply, and your solver is taking much longer to iterate than you think it should, it's probably having trouble factorising the coefficient matrix.&lt;/p&gt;&#xA;&lt;h1&gt;Possible fixes&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Identify and break symmetry in your model.&lt;/li&gt;&#xA;&lt;li&gt;Make sure there are no free variables.&lt;/li&gt;&#xA;&lt;li&gt;Make sure all your variables have bounds.&lt;/li&gt;&#xA;&lt;li&gt;Tighten the bounds of as many continuous variables as you can.&lt;/li&gt;&#xA;&lt;li&gt;Apply presolving techniques to reduce problem &amp;amp; domain size if you have access to a solver with a good presolver (e.g., GUROBI, CPLEX, or our own Octeract Engine). You can also code these techniques yourself if you are up for it, a good reference can be found &lt;a href=&quot;https://opus4.kobv.de/opus4-zib/files/6037/Presolve.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If the issue is primal feasibility, relax/reformulate some of your integer constraints to make it easier for the solver to find feasible points, or instruct the solver to use a different primal heuristic.&lt;/li&gt;&#xA;&lt;li&gt;Although solvers (especially commercial ones) are typically smart enough to figure out branching on their own, in edge cases the default branching heuristic might not be a good fit for your problem. Try changing the variable selection strategy if your solver supports it.&lt;/li&gt;&#xA;&lt;li&gt;If your solver is generating too many nodes, try increasing the number of strong branching passes and depth.&lt;/li&gt;&#xA;&lt;li&gt;If iterations are slower than expected, try making your problem more sparse, switching to interior point instead of dual simplex (or vice versa), or instructing the solver to use a different factorisation algorithm/library if it supports it.&lt;/li&gt;&#xA;&lt;li&gt;Try scaling your coefficients to avoid numerical issues, especially if you are not using a commercial solver.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-01-30T14:27:46.337" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3455" PostTypeId="1" CreationDate="2020-01-30T14:33:19.967" Score="5" ViewCount="200" Body="&lt;p&gt;I have the following matrix of suppliers who are able to make a certain product, against all products in my portfolio. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/z0ZZG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/z0ZZG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way of finding the solution to &quot;the least suppliers necessary to deliver the whole portfolio&quot; - and &quot;which suppliers are necessary to deliver the whole portfolio&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally looking for a solution in R, since I have manipulated the data beforehand in order to get to this one-hot coded matrix. But generally I'm trying to understand first how to approach this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The full dataset is obviously larger - I can see myself that in this case only Sup1 and Sup7 would be required :-)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I received some great answers below. Unfortunately I cannot install the &quot;pulp&quot; module for python on my laptop (restrictions from work - I know it doesn't seem to make sense). I am trying to convert the below python script into R (ompr by @dirks user:2798441). However I struggle with the syntax. I receive an error message with below code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;require(ompr)&#xA;require(ompr.roi)&#xA;require(dplyr)&#xA;require(ROI)&#xA;require(ROI.plugin.glpk)&#xA;&#xA;&#xA;test &amp;lt;-rbind(c(),&#xA;           c(&quot;Prd1&quot;, 1, NA, NA, NA, NA, NA, NA, 1, NA, NA, NA),&#xA;           c(&quot;Prd2&quot;,1, NA, NA, NA, NA, 1, NA, NA, NA, 1, NA),&#xA;           c(&quot;Prd3&quot;,NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),&#xA;           c(&quot;Prd4&quot;,1, 1, 1, 1, NA, NA, NA, NA, NA, NA, NA),&#xA;           c(&quot;Prd5&quot;,NA, NA, NA, NA, NA, NA, 1, NA, NA, NA, NA),&#xA;           c(&quot;Prd6&quot;,1, NA, NA, NA, NA, 1, NA, NA, NA, 1, NA),&#xA;           c(&quot;Prd7&quot;,1, NA, NA, NA, 1, NA, NA, NA, 1, NA, NA),&#xA;           c(&quot;Prd8&quot;,NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),&#xA;           c(&quot;Prd9&quot;,NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA))&#xA;dims &amp;lt;- dim(test)&#xA;test &amp;lt;- as.numeric(test)&#xA;dim(test) &amp;lt;- dims  &#xA;test.df &amp;lt;- data.frame(test)&#xA;colnames(test.df) &amp;lt;- c(&quot;Product&quot;,&quot;Sup1&quot;, &quot;Sup2&quot;, &quot;Sup3&quot;, &quot;Sup4&quot;, &quot;Sup5&quot;, &quot;Sup6&quot;, &quot;Sup7&quot;, &quot;Sup8&quot;, &quot;Sup9&quot;, &quot;Sup10&quot;, &quot;Sup11&quot;)&#xA;test.df[,1] &amp;lt;- c(&quot;Prd1&quot;,&quot;Prd2&quot;,&quot;Prd3&quot;,&quot;Prd4&quot;,&quot;Prd5&quot;,&quot;Prd6&quot;,&quot;Prd7&quot;,&quot;Prd8&quot;,&quot;Prd9&quot;)&#xA;&#xA;n &amp;lt;- nrow(test.df) &#xA;m &amp;lt;- ncol(test.df)&#xA;M &amp;lt;- 100&#xA;set_n &amp;lt;- range(0,n)&#xA;set_m &amp;lt;- range(0,m)&#xA;&#xA;model &amp;lt;- MIPModel() %&amp;gt;%&#xA;  add_variable(b[i,j], i = set_n, j = set_m, type = &quot;binary&quot;) %&amp;gt;%&#xA;  add_variable(x[j], j = set_m, type = &quot;binary&quot;) %&amp;gt;%&#xA;  set_objective(sum_expr(b[i,j] * 2, i = set_n, j = set_m) - sum_expr(x[j], j = set_m)) %&amp;gt;%&#xA;  add_constraint((sum_expr(b[i,j], j = set_m)) &amp;lt;= 1) %&amp;gt;%&#xA;  add_constraint(M * x[j] &amp;gt;= sum_expr(b[i,j], i = set_n) - 1 + 0.001) %&amp;gt;%&#xA;  add_constraint(M * ( 1-  x[j]) &amp;gt;= ( 1 - sum_expr(b[i,j], i = set_n) - 0.001)) %&amp;gt;%&#xA;  solve_model(with_ROI(solver = &quot;symphony&quot;, verbosity = 1)) %&amp;gt;%&#xA;  get_solution(x[i, j]) %&amp;gt;%&#xA;  filter(value &amp;gt; 0) %&amp;gt;%&#xA;  arrange(i)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If someone has some kind of experience with ompr I would appreciate a nudge in the right direction.&lt;/p&gt;&#xA;" OwnerUserId="3004" LastEditorUserId="3004" LastEditDate="2020-02-06T15:19:21.350" LastActivityDate="2020-05-05T11:38:34.833" Title="Reducing number of suppliers for product portfolio" Tags="|linear-programming|r|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3456" PostTypeId="1" CreationDate="2020-01-30T15:41:12.180" Score="6" ViewCount="226" Body="&lt;p&gt;I'm using &lt;code&gt;OptionalIntervalVar&lt;/code&gt; and then maximizing the starts. The optimal solution is not affecting the other variables that creates the &lt;code&gt;OptionalIntervalVar&lt;/code&gt; (i mean the constraint &lt;code&gt;starts[j]+sizes[j]==ends[j]&lt;/code&gt;), so I suppose that there are not enforced, but my &lt;code&gt;CpModelStats&lt;/code&gt; says that there are all enforced, so why they are not working?&lt;/p&gt;&#xA;&lt;p&gt;This is how I create the &lt;code&gt;IntervalVars&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;        std::vector&amp;lt;IntVar&amp;gt; starts;&#xA;    std::vector&amp;lt;IntVar&amp;gt; sizes;&#xA;    std::vector&amp;lt;IntVar&amp;gt; ends;&#xA;    std::vector&amp;lt;BoolVar&amp;gt; actives;&#xA;    std::vector&amp;lt;IntervalVar&amp;gt; Intervals;&#xA;&#xA;    for (int j=0; j&amp;lt;nbTasks; j++) &#xA;    {   &#xA;        const IntVar start = cp_model.NewIntVar(Domain(0, tmax));       // generamos una variable intervalo&#xA;        const IntVar end = cp_model.NewIntVar(Domain(0, tmax));         // para cada job&#xA;        const BoolVar active = cp_model.NewBoolVar();&#xA;        const IntVar size = cp_model.NewConstant(duration[j]);&#xA;        //const IntervalVar interval = cp_model.NewIntervalVar(start, size, end); // start+size==end&#xA;        const IntervalVar interval = cp_model.NewOptionalIntervalVar(start, size, end, active);&#xA;        starts.push_back(start);       &#xA;        sizes.push_back(size);     &#xA;        ends.push_back(end);&#xA;        actives.push_back(active);&#xA;        Intervals.push_back(interval);&#xA;    }&#xA;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And the CpModelStatus:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;WARNING: Logging before InitGoogleLogging() is written to STDERR&#xA;I0130 12:29:51.027925 23261 cp_rcpsp.cpp:1028] CpSolverResponse:&#xA;status: OPTIMAL&#xA;objective: 119978&#xA;best_bound: 119978&#xA;booleans: 18&#xA;conflicts: 0&#xA;branches: 26&#xA;propagations: 4&#xA;integer_propagations: 44&#xA;walltime: 0.00252666&#xA;usertime: 0.00252667&#xA;deterministic_time: 2.44e-06&#xA;primal_integral: 0.29268&#xA;I0130 12:29:51.030489 23261 cp_rcpsp.cpp:1029] Optimization model '':&#xA;#Variables: 30 (6 in objective)&#xA; - 6 in [0,1]&#xA; - 12 in [0,20000]&#xA; - 12 constants in {0,1,2,3,20,6000,8000,8187,10000,19113,33641,50000} &#xA;#kCumulative: 2&#xA;#kInterval: 6 (#enforced: 6)&#xA;#kLinear1: 13&#xA;#kLinear2: 7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And this is my objective:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cp_model.Maximize(LinearExpr::Sum(starts));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="491" LastEditDate="2022-01-07T01:57:00.067" LastActivityDate="2022-01-07T01:57:00.067" Title="OptionalIntervalVar enforced but not working OR-TOOLS" Tags="|constraint-programming|or-tools|c++|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3457" PostTypeId="2" ParentId="3416" CreationDate="2020-01-30T18:18:38.213" Score="4" Body="&lt;p&gt;A more recent alternative is &lt;a href=&quot;https://www.python-mip.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python-MIP&lt;/a&gt;. It has built-in support of &lt;a href=&quot;https://projects.coin-or.org/Cbc&quot; rel=&quot;nofollow noreferrer&quot;&gt;COIN-OR CBC&lt;/a&gt;. In addition, right now it supports one commercial solver, namely Gurobi. According to its website, it provides access to advanced solver features like cut generation, lazy constraints, MIP starts and solution pools. Since Python-MIP is mentioned on the COIN-OR &lt;a href=&quot;https://www.coin-or.org/projects/&quot; rel=&quot;nofollow noreferrer&quot;&gt;projects webpage&lt;/a&gt;, it seems that Python-MIP is going to be open source in the long run. &lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2020-01-30T18:18:38.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3458" PostTypeId="2" ParentId="3455" CreationDate="2020-01-30T20:14:23.060" Score="8" Body="&lt;p&gt;You can model this as a set covering problem (or hitting set problem -- different terminology, same mathematical model). The (binary) decision variables would determine which suppliers you select; the constraints would be &quot;select at least one that can handle this product&quot; for each product. The objective would be to minimize the number of selections (sum of the binary variables). Note that this model does not take into account what the suppliers charge, nor their quality (other than it presumably must be adequate to be included in the matrix), nor does it consider any supplier capacity limits. It also leaves unanswered how to allocate demand among multiple suppliers if you wind up with more than covering some product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for R, you can create and solve the model in the &lt;a href=&quot;https://cran.r-project.org/web/packages/ompr/index.html&quot; rel=&quot;noreferrer&quot;&gt;ompr&lt;/a&gt; package (available on CRAN), but you will also need to install one of the solvers it supports.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-01-30T20:14:23.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3459" PostTypeId="2" ParentId="3455" CreationDate="2020-01-30T20:36:38.853" Score="3" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$b_{i,j}$&lt;/span&gt; denote product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is taken from supplier &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. and &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; denote whether supplier &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is selected once or not.&#xA;&lt;span class=&quot;math-container&quot;&gt;$i \in n$&lt;/span&gt; (product) &lt;span class=&quot;math-container&quot;&gt;$j \in m$&lt;/span&gt; (supplier)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad \sum_{i,j} b_{i,j}\times 2  - \sum_j x_j\\\text{s.t.}&amp;amp;\quad\sum_j b_{i,j} \leq 1\\&amp;amp;\quad M \times x_j \geq \sum_i b_{i,j} -1 + \delta\\&amp;amp;\quad M \times (1- x_j) \geq 1 - \sum_i b_{i,j} - \delta\\&amp;amp;\quad b_{i,j} =0 \; \forall A[i,j] = 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; is a small value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The objective function tries to maximize the number of product picked while keeping less number of suppliers. &lt;span class=&quot;math-container&quot;&gt;$A[i,j]$&lt;/span&gt; is your original matix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b_{i,j}$&lt;/span&gt; is multiplied by 2 because when &lt;span class=&quot;math-container&quot;&gt;$x_j = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_i b_{i,j} = 1$&lt;/span&gt; solver will end up ignoring it as &lt;span class=&quot;math-container&quot;&gt;$x_j - \sum_i b_{i,j} = 0$&lt;/span&gt; at that time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code but in python, you can convert it to R::&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;import pulp as pl&#xA;&#xA;p = [[1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],&#xA;     [1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0],&#xA;     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;     [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0],&#xA;     [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0],&#xA;     [1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0],&#xA;     [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0],&#xA;     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]&#xA;&#xA;p = np.array(p)&#xA;&#xA;n = 9&#xA;m = 11&#xA;set_n = range(n)&#xA;set_m = range(m)&#xA;&#xA;prob = pl.LpProblem(&quot;Problem&quot;, pl.LpMaximize)&#xA;b = {(i, j): pl.LpVariable(&quot;b_{0}_{1}&quot;.format(i, j), 0, 1, pl.LpBinary) for i in set_n for j in set_m}&#xA;x = {(j): pl.LpVariable(&quot;x_{0}&quot;.format(j), 0, 1, pl.LpBinary) for j in set_m}&#xA;&#xA;prob += pl.lpSum(b[i, j] * 2 for i in set_n for j in set_m) - pl.lpSum(x[j] for j in set_m)&#xA;&#xA;M = 100&#xA;for i in set_n:&#xA;    prob += pl.lpSum(b[i, j] for j in set_m) &amp;lt;= 1&#xA;&#xA;for j in set_m:&#xA;    prob += M * x[j] &amp;gt;= (pl.lpSum(b[i, j] for i in set_n) - 1 + 0.001)&#xA;    prob += M * (1 - x[j]) &amp;gt;= (1 - pl.lpSum(b[i, j] for i in set_n) - 0.001)&#xA;&#xA;for i in set_n:&#xA;    for j in set_m:&#xA;        if p[i, j] == 0:&#xA;            prob += b[i, j] == 0&#xA;&#xA;# print(prob)&#xA;prob.solve()&#xA;print(prob.status)&#xA;for v in prob.variables():&#xA;    if v.varValue == 1.0:&#xA;        print(v.name, &quot;=&quot;, v.varValue)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="700" LastEditorUserId="123" LastEditDate="2020-01-31T07:53:19.730" LastActivityDate="2020-01-31T07:53:19.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3460" PostTypeId="1" CreationDate="2020-01-30T20:51:34.507" Score="8" ViewCount="298" Body="&lt;p&gt;Safety stocks account for uncertainty both on demand and provider lead times, but never mention how to include the effect of incomplete orders. For example, what would happen if a provider always delivers on time but on average orders have 50% of the promised quantity?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't find any papers that include this effect.&lt;/p&gt;&#xA;" OwnerUserId="3005" LastEditorUserId="123" LastEditDate="2020-01-30T22:26:14.497" LastActivityDate="2020-01-31T02:20:41.900" Title="Safety stock when there is uncertainty in order completion" Tags="|reference-request|inventory|uncertainty|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3461" PostTypeId="2" ParentId="3460" CreationDate="2020-01-30T21:58:46.307" Score="9" Body="&lt;p&gt;What you’re describing is known as &lt;strong&gt;inventory optimization under yield uncertainty.&lt;/strong&gt; There is quite a bit of literature on it. Two relevant literature reviews are &lt;a href=&quot;https://doi.org/10.1287/opre.43.2.311&quot; rel=&quot;noreferrer&quot;&gt;Yano and Lee (&lt;em&gt;OR&lt;/em&gt; 1995)&lt;/a&gt; and &lt;a href=&quot;https://doi.org/10.1023/B:ANOR.0000012275.01260.f5&quot; rel=&quot;noreferrer&quot;&gt;Grosfeld-Nir and Gerchak (&lt;em&gt;AOR&lt;/em&gt; 2004)&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yield uncertainty is only one type of supply uncertainty. A closely related form is disruptions; my students and I wrote a review paper on this topic a few years ago (&lt;a href=&quot;http://dx.doi.org/10.1080/0740817X.2015.1067735&quot; rel=&quot;noreferrer&quot;&gt;Snyder, et al., &lt;em&gt;IIET&lt;/em&gt; 2016&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We discuss inventory models with both yield uncertainty and disruptions in &lt;a href=&quot;https://www.wiley.com/en-us/Fundamentals+of+Supply+Chain+Theory%2C+2nd+Edition-p-9781119024842&quot; rel=&quot;noreferrer&quot;&gt;our textbook&lt;/a&gt;, if that helps. &lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2020-01-31T02:20:41.900" LastActivityDate="2020-01-31T02:20:41.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3462" PostTypeId="1" AcceptedAnswerId="3464" CreationDate="2020-01-31T14:15:03.287" Score="6" ViewCount="1807" Body="&lt;p&gt;If I have an  &lt;code&gt;IntVar&lt;/code&gt; &lt;code&gt;s[j]&lt;/code&gt; stored in a vector &lt;code&gt;s&lt;/code&gt;, is it possible to iterate for (a period of time) &lt;code&gt;t&lt;/code&gt; and create a &lt;code&gt;BoolVar&lt;/code&gt; &lt;code&gt;b&lt;/code&gt; such that &lt;code&gt;b[t]&lt;/code&gt; is true if and only if &lt;code&gt;s[j]==t&lt;/code&gt;? I tried setting some restrictions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    for (int j = 0; j &amp;lt; nbTasks; ++j)&#xA;    {&#xA;        for (int t = 0; t &amp;lt; tmax; ++t)&#xA;        {&#xA;            const IntVar expr = cp_model.NewIntVar(Domain(-1000000000,100000000000));&#xA;            const IntVar actual_t = cp_model.NewConstant(t).WithName(&quot;actual_t&quot;);&#xA;            const BoolVar b = cp_model.NewBoolVar().WithName(&quot;b&quot;);&#xA;            const IntVar value = cp_model.NewConstant(w[j][t]);&#xA;&#xA;            obj_final.push_back(expr);&#xA;            actuals[j].push_back(actual_t);&#xA;            expressions[j].push_back(expr);&#xA;            values[j].push_back(value);&#xA;&#xA;            cp_model.AddEquality(b, starts[j]==actual_t);&#xA;            cp_model.AddProductEquality(expr, {value, b});&#xA;        }&#xA;    }  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I created the &lt;code&gt;BoolVar&lt;/code&gt; &lt;code&gt;b&lt;/code&gt; and then set an equality to the bool value of &lt;code&gt;s[j]==t&lt;/code&gt;, then I used the constraint &lt;code&gt;expr == value*b&lt;/code&gt; and added the expression to the vector &lt;code&gt;obj_final&lt;/code&gt;, and finally set the objective: &lt;code&gt;cp_model.Maximize(LinearExpr::Sum(obj_final));&lt;/code&gt; The problem is that my solution is optimal but the objective is zero, so I guess &lt;code&gt;b&lt;/code&gt; is always false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to assign a value to an expression if and only if &lt;code&gt;s[j]==t&lt;/code&gt;. Enforce constraints isn't what i need because the other expressions must be zero. &#xA;I'll be thankful for any help.&lt;/p&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="71" LastEditDate="2020-02-10T09:39:05.640" LastActivityDate="2020-02-10T09:39:05.640" Title="assigning values to IntVar if and only if BoolVar, else zero [or-tools]" Tags="|constraint-programming|or-tools|c++|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3463" PostTypeId="1" AcceptedAnswerId="3465" CreationDate="2020-01-31T15:09:47.473" Score="5" ViewCount="295" Body="&lt;p&gt;Is there an option in GAMS that sets the tolerance for declaring two real numbers to equal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, how can I tell GAMS or GAMS/CPLEX that &lt;span class=&quot;math-container&quot;&gt;$0.999100 = 0.99909$&lt;/span&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help!&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="36" LastEditDate="2020-01-31T16:20:51.563" LastActivityDate="2020-01-31T16:20:51.563" Title="Tolerance for equality in GAMS/CPLEX" Tags="|cplex|gams|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3464" PostTypeId="2" ParentId="3462" CreationDate="2020-01-31T15:32:05.270" Score="5" Body="&lt;p&gt;To create an intermediate boolean that is true iff &lt;code&gt;s[j] == t&lt;/code&gt; you just have to create 2 constraints:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cp_model.AddEquality(s[j], t).OnlyEnforceIf(b);&#xA;cp_model.AddNotEqual(s[j], t).OnlyEnforceIf(Not(b));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cp_model.AddEquality(b, starts[j]==actual_t);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is that &lt;code&gt;starts[j]==actual_t&lt;/code&gt; &quot;always&quot; evaluates to false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To learn more about channeling, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/sat/doc/channeling.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/ortools/sat/doc/channeling.md&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/sat/doc/integer_arithmetic.md#step-function&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/ortools/sat/doc/integer_arithmetic.md#step-function&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2020-02-03T13:52:16.887" LastActivityDate="2020-02-03T13:52:16.887" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3465" PostTypeId="2" ParentId="3463" CreationDate="2020-01-31T15:56:09.430" Score="2" Body="&lt;p&gt;Per &lt;a href=&quot;https://www.gams.com/latest/docs/S_CPLEX.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gams.com/latest/docs/S_CPLEX.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;eprhs (real): feasibility tolerance&lt;/p&gt;&#xA;&lt;p&gt;Feasibility tolerance. This specifies the degree to which a problem's basic  variables may violate their bounds. This tolerance&#xA;influences the selection of an optimal basis and can be reset to a&#xA;higher value when a problem is having difficulty maintaining&#xA;feasibility during optimization. You may also wish to lower this&#xA;tolerance after finding an optimal solution if there is any doubt that&#xA;the solution is truly optimal. If the feasibility tolerance is set too&#xA;low, Cplex may falsely conclude that a problem is infeasible.&lt;/p&gt;&#xA;&lt;p&gt;Range: [1e-009, 0.1]&lt;/p&gt;&#xA;&lt;p&gt;Default: 1e-006&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I believe this tolerance applies to assessing feasibility of bound, inequality, and equality constraints.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-01-31T15:56:09.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3466" PostTypeId="1" AcceptedAnswerId="3467" CreationDate="2020-01-31T19:25:58.773" Score="3" ViewCount="302" Body="&lt;p&gt;I have two continuous variables &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; and two binary variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Condition: if &lt;span class=&quot;math-container&quot;&gt;$A = B \wedge x = 1 \wedge y=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$z = 1$&lt;/span&gt; else &lt;span class=&quot;math-container&quot;&gt;$z = 0$&lt;/span&gt; from&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/33/in-an-integer-program-how-i-can-force-a-binary-variable-to-equal-1-if-some-cond&quot;&gt;In an integer program, how I can force a binary variable to equal 1 if some condition holds?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/76/in-an-integer-program-how-can-i-activate-a-constraint-only-if-a-decision-vari?noredirect=1&amp;amp;lq=1&quot;&gt;In an integer program, how can I “activate” a constraint only if a decision variable has a certain value?&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My current attempt is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;A-B + \delta+x+y &amp;amp;\leq 2 + M \cdot k_1\\&#xA;B - A - \delta-x-y &amp;amp;\leq - 2 + M \cdot(1 - k_1)\\&#xA;B-A + \delta+x+y &amp;amp;\leq 2 + M \cdot k_2\\&#xA;A - B - \delta-x-y &amp;amp;\leq -2 + M \cdot(1 - k_2)\\&#xA;k_1 + k_2 - 1 &amp;amp;\leq z&#xA;\\k_1 &amp;amp;\geq z&#xA;\\k_2 &amp;amp;\geq z&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$k_1, k_2$&lt;/span&gt; are boolean variables, but I am not getting the expected result.&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="700" LastEditDate="2020-01-31T21:58:40.630" LastActivityDate="2020-01-31T22:58:48.260" Title="Linearizing constraint with continuous and boolean variables" Tags="|mixed-integer-programming|linear-programming|linearization|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="3467" PostTypeId="2" ParentId="3466" CreationDate="2020-01-31T22:58:48.260" Score="3" Body="&lt;p&gt;You want to model&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z=1 \iff (A=B\land x=1 \land y=1).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To enforce &lt;span class=&quot;math-container&quot;&gt;$z=1 \implies (A=B\land x=1 \land y=1)$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;-M(1-z) \le A - B &amp;amp;\le M(1-z)\\&#xA;z &amp;amp;\le x\\&#xA;z &amp;amp;\le y&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To enforce the converse &lt;span class=&quot;math-container&quot;&gt;$(A=B\land x=1 \land y=1) \implies z=1$&lt;/span&gt;,&#xA;equivalently, &lt;span class=&quot;math-container&quot;&gt;$A&amp;gt;B\lor A&amp;lt;B\lor x=0 \lor y=0 \lor z=1$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;B-A+\delta &amp;amp;\le M_1 (1-w_1)\\&#xA;A-B+\delta &amp;amp;\le M_2 (1-w_2)\\&#xA;w_1+w_2+(1-x)+(1-y) + z&amp;amp;\ge 1\\&#xA;w_1,w_2&amp;amp;\in\{0,1\}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-01-31T22:58:48.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3468" PostTypeId="1" CreationDate="2020-02-01T05:47:00.617" Score="5" ViewCount="82" Body="&lt;p&gt;I'm trying to implement the following in AMPL:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ i \in [N], j \in[N] \backslash \{i\}, t \in [T] $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have so far written the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subject to Con{i in PP,t in TT, j in PP : j != i}:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it does not feel correct, is it?&#xA;I also have a question about implementing this:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ i \neq j,t $$&lt;/span&gt;&#xA;in a constraint, i'm only getting one to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subject to {i in PP,t in TT, j in PP : j != i}:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3003" LastEditorUserId="3003" LastEditDate="2020-02-01T06:19:57.503" LastActivityDate="2020-02-02T16:02:52.707" Title="AMPL implement constraint" Tags="|optimization|ampl|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3469" PostTypeId="1" CreationDate="2020-02-01T10:59:17.070" Score="5" ViewCount="722" Body="&lt;p&gt;I am not familiar with the inner working of the solvers. I mostly use the python &lt;code&gt;pulp&lt;/code&gt; or IBM &lt;code&gt;CPLEX&lt;/code&gt; solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For fast execution time, what should be the priority, fewer constraints and loosely bounded variables or more constraints and tightly bounded variables?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I have a variable &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; which, due to linearization, gets a value range between &lt;span class=&quot;math-container&quot;&gt;$[-M, +M]$&lt;/span&gt; and its lower bound is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, so that its bounds are &lt;span class=&quot;math-container&quot;&gt;$[0, +M]$&lt;/span&gt;. Let's say it is a minimization problem and &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is somehow used in the objective function, so the solver will end up assigning value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to it since it is the lowest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, will it be any help if  I add constraints that bound the value of &lt;span class=&quot;math-container&quot;&gt;$X \in [0,0]$&lt;/span&gt;, does solver perform better in this case than previously?&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="237" LastEditDate="2020-02-01T19:25:00.197" LastActivityDate="2020-02-02T02:06:58.833" Title="Trade off between number of constraints and bounds of a variable" Tags="|linear-programming|modeling|linearization|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3470" PostTypeId="2" ParentId="3469" CreationDate="2020-02-01T19:41:00.520" Score="7" Body="&lt;p&gt;This will depend to some extent on the specific solver you are using. Contemporary solvers have presolve stages. If you add constraints that are redundant, presolve will often weed them out. Solvers also use some form of &quot;active set&quot; technology, meaning that constraints that are not binding for most or all of the search will be held off to the side and will not slow the solver as much as constraints that are actively involved in pivoting. So I think a reasonable rule of thumb is this: be cautious adding constraints that are obviously redundant (although they do sometimes help), but do not worry too much about adding constraints that might tighten things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, if your variable X is automatically going to take value zero (appears in the objective with positive coefficient and does not appear in any constraints where a positive value of X would allow beneficial values for other variables), the presolver will likely fix it at zero. So forcing it to zero may not be helpful (and runs the risk that, if you are wrong about it being zero in an optimal solution, you might cut off the true optimum).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-02-01T19:41:00.520" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3471" PostTypeId="2" ParentId="3469" CreationDate="2020-02-02T02:06:58.833" Score="6" Body="&lt;p&gt;Tighter variable bounds are always helpful as they help restrict the search space and avoid degeneracy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More constraints are often very helpful, especially for MILPs, because they help reduce the viable number of integer combinations. Constraints are also used to tighten variable bounds through constraint propagation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are however a couple of things to watch out for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Solvers are much more efficient when solving sparse problems, i.e., problems with many small constraints, vs fewer but more dense ones. One of the reasons is that factorising sparse matrices tends to be easier.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Redundant constraints can cause numerical issues, but they are removed by the solver at the presolving stage.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If a variable is supposed to be unbounded, setting its bounds to a large number is actually worse than setting no bounds at all, because there are special presolving techniques for unbounded variables.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With respect to your question, it doesn't matter how you fix the variable if you are using a commercial solver like CPLEX. The types of constraints you describe are called singletons, and presolvers use that information to fix the variable and remove it from the problem altogether, along with the constraints. If you fix the bounds instead, the solver will do the same thing.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-02-02T02:06:58.833" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3472" PostTypeId="2" ParentId="3468" CreationDate="2020-02-02T07:00:27.730" Score="1" Body="&lt;p&gt;Try the following syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subject to cons {i in PP,t in TT, j in PP : j diff i}:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subject to cons {i in PP,t in TT, j in PP : j&amp;lt;&amp;gt;i}:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-02-02T07:00:27.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3473" PostTypeId="1" CreationDate="2020-02-02T08:21:05.283" Score="12" ViewCount="1348" Body="&lt;p&gt;I have a set of sources and a set of sinks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each source &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; can produce a set of different products &lt;span class=&quot;math-container&quot;&gt;$P_s$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The transportation inter-sources and inter-sinks are allowed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sources do not necessarily produce the same products, but they may have products in common.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same thing for sinks, a sink &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; can absorb more than a single type of product (i.e., each sink has a set &lt;span class=&quot;math-container&quot;&gt;$D_t$&lt;/span&gt; of demanded products), two sinks do not necessarily absorb exactly the same type of products, but they may have products in common though.  &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;First case:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Transportation costs on arcs&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Production costs on source nodes&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Maximal production capacity on each node&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sinks have demands.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;N.B. There are no maximal capacities on edges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The decision is 1) which quantity to produce on each source for each product and 2) on which arcs to send the produced quantities? The objective is to reduce the total cost while satisfying the demand for each sink for each product.&#xA;N.B. The transportation costs have an influence on the decision of how much quantity we produce in each source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do we call this problem in the literature? As far as I know, it's not a multi-commodity flow since in a multi-commodity flow we assume that each source(respectively sink) produce(respectively absorb) a different and unique commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, i.e, we have different pairs &lt;span class=&quot;math-container&quot;&gt;$(s_1,t_1), ..,(s_k,t_k)$&lt;/span&gt; (thus the quantity produced in each source is simply equal to the quantity demanded by the sinks for the commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; but in my problem, it's part of the decision). Is there a paper that model/solve a similar problem? How to model it? I am also curious about the different approaches to solve it(exactly or not). Feel free to suggest any approach if you have an idea. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT : The answer of @marco shows how to do some tricks in order to reduce the problem into a multi-commodity flow. (actually, a mincost flow, as the different commodities do not have a capacity on a common arc)&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Second case:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;What if the transportation costs defined on arcs and the production costs defined on source nodes are of the type fixed_cost + cost/unit instead of a cost/unit as in case 1. Is this still a multi-commodity flow problem?&#xA;I think that the transformations described by @marco are still valid since only the costs change but the problem still have the same structure. But how this change can affect the hardness of the problem?&lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2020-02-03T05:39:04.373" LastActivityDate="2020-02-03T19:34:47.827" Title="How do we call this problem in literature and how to model it?" Tags="|modeling|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3474" PostTypeId="2" ParentId="3473" CreationDate="2020-02-02T13:13:35.003" Score="12" Body="&lt;p&gt;Your &lt;strong&gt;first case&lt;/strong&gt; can be modeled as a minimum cost flow problem. You can&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;split&lt;/strong&gt; sinks with demands for more than one type into as many nodes as there are demanded types; make copies of incident arcs accordingly (this step results in sinks that have exactly one type of demand).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;split&lt;/strong&gt; source nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; into copies &lt;span class=&quot;math-container&quot;&gt;$i'$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i''$&lt;/span&gt;, connect the copies with an arc &lt;span class=&quot;math-container&quot;&gt;$(i',i'')$&lt;/span&gt; that receives the production capacity of sink &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (in mincost flow, you can only have capacities on arcs, not on nodes; this is the standard trick to transfer node to arc capacities). These arcs also receive the per unit production cost.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if there is more than one source/sink per type, introduce a &lt;strong&gt;supersource&lt;/strong&gt; that is connected to the original sources, with a supply equal to the total demand for this type. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;since you have no capacities, the problem should be solvable by sending a &lt;strong&gt;mincost flow separately for each type&lt;/strong&gt;; in particular, this is doable in polytime.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;All these are standard transformations, you can find them e.g., in the fabulous book &lt;a href=&quot;https://mitmgmtfaculty.mit.edu/jorlin/network-flows/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Network Flows: Theory, Algorithms, and Applications&lt;/a&gt; by Ahuja, Magnanti, and Orlin (1993).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your &lt;strong&gt;second case&lt;/strong&gt; makes the problem a &lt;em&gt;fixed-charge network flow problem&lt;/em&gt; which is NP-hard (see e.g., &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0167637799000048&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;), so for exact solutions you will probably resort to formulating the problem as a MILP.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="237" LastEditDate="2020-02-03T19:34:47.827" LastActivityDate="2020-02-03T19:34:47.827" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="3475" PostTypeId="2" ParentId="3468" CreationDate="2020-02-02T16:02:52.707" Score="2" Body="&lt;p&gt;This looks most like the math (and avoids checking for every &lt;span class=&quot;math-container&quot;&gt;$(i,j,t)$&lt;/span&gt; a logical condition that depends only on &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{i in PP, j in PP diff {i}, t in TT}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-02-02T16:02:52.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3476" PostTypeId="1" AcceptedAnswerId="7234" CreationDate="2020-02-02T16:20:10.823" Score="7" ViewCount="206" Body="&lt;p&gt;I'm teaching an Operations Management Class.  A long time ago, there was a simple DOS-based product called MPX. It was based on queuing theory and let you model manufacturing processes.  There was nice case that went with it call GTHUBS-- something like 5-10 SKU's going through 5-10 machines, with some different routings, set-ups, labor requirements, etc.. It was interesting to try different things to see what impact the changes had on overall cycle time.&lt;/p&gt;&#xA;&lt;p&gt;The DOS interface was ugly, but super simple.  And, students could figure it out.&lt;/p&gt;&#xA;&lt;p&gt;I can no longer find this program or case study.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone still use this?  Does anyone have a good replacement for this that they use in their classes?&lt;/p&gt;&#xA;" OwnerUserId="191" LastEditorUserId="491" LastEditDate="2022-01-12T13:58:02.557" LastActivityDate="2022-01-12T13:58:54.260" Title="MPX Queuing Software for Manufacturing with the GTHUBS Case" Tags="|queuing-theory|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3477" PostTypeId="2" ParentId="3396" CreationDate="2020-02-02T18:24:54.143" Score="6" Body="&lt;p&gt;Some observations why &lt;em&gt;min sum&lt;/em&gt; objectives are computationally more difficult than the &lt;em&gt;makespan&lt;/em&gt; objective:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For the decision problem, it can be shown that the total lateness objective is at least as general as the makespan objective: Assume we want to know if there exists a schedule with a makespan of at most &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. When setting the due dates of all jobs to &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, a schedule with a makespan of at most &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; exists if there is a schedule with a total lateness of zero. I don't see such a reduction for the other direction.&lt;/li&gt;&#xA;&lt;li&gt;Another indicator why min sum objectives are computationally more difficult is that the makespan depends only on the completion time of the latest job, whereas for min sum objectives the completion times of all jobs might have an influence. This is related to the following. In heuristics, solutions of are often represented using conjunctive graphs. In order to efficiently evaluate moves, one can estimate the impact of a move to the objective function instead of actually executing the move. Estimating the impact of a move is less complicated for the makespan in comparison to other regular criteria (such as the min sum objectives).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="377" LastEditorUserId="377" LastEditDate="2020-02-02T18:30:33.613" LastActivityDate="2020-02-02T18:30:33.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3478" PostTypeId="1" CreationDate="2020-02-03T01:26:41.500" Score="7" ViewCount="92" Body="&lt;p&gt;&lt;a href=&quot;https://academic.oup.com/forestscience/article-abstract/23/suppl_1/a0001/4675760?redirectedFrom=fulltext&quot; rel=&quot;noreferrer&quot;&gt;Scheurman's paper&lt;/a&gt; discusses Model I and model II Formulation to solve harvesting and scheduling problems. It is a specific implementation to solve multi period linear programs. Both models are also shown in &lt;a href=&quot;http://faculty.washington.edu/toths/Publications/McDill_etal_M2.pdf&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt;, if you can't access the first.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to understand how to build the model II by hand and reimplement them in a computer program. I am getting stuck on equations (12), (13), (16), and (17) on page 14 in what they mean and how to &quot;write them down&quot; of the second paper that I've linked to. &lt;/p&gt;&#xA;" OwnerUserId="2955" LastActivityDate="2020-09-26T21:27:50.340" Title="Building the Scheurman's Model II constraints for a multi period linear program" Tags="|mixed-integer-programming|linear-programming|scheduling|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3480" PostTypeId="1" CreationDate="2020-02-04T02:36:10.063" Score="6" ViewCount="58" Body="&lt;p&gt;The usual way to define a semi-definite program (SDP), e.g., as given in Boyd and Vandenberghe's convex optimization book, is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{cl}&#xA;\min &amp;amp; c^\top x \\&#xA;\mathrm{s.t.} &amp;amp; 0 \succeq x_1 F_1+ \ldots+x_nF_n + G  \\&#xA;&amp;amp; Ax = b&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$ 0 \succeq  M$&lt;/span&gt; denotes &lt;span class=&quot;math-container&quot;&gt;$0 - M$&lt;/span&gt; is a p.s.d. matrix. In the above problem &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^{n}$&lt;/span&gt; is an optimization variable, while &lt;span class=&quot;math-container&quot;&gt;$F_1,\ldots,F_n, G$&lt;/span&gt; are symmetric (known) matrices. Similarly &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{m \times n},b \in \mathbb{R}^n$&lt;/span&gt; are (known) linear equality system's matrices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, without being bothered by the standard notation as above, can we say &lt;strong&gt;any&lt;/strong&gt; problem which has all linear constraints and an additional p.s.d.-ness constraint is SDP? For example,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{cl}&#xA;\min &amp;amp; c^\top x \\&#xA;\mathrm{s.t.} &amp;amp;  \sum_{(j,k) \in S_i} Y_{j,k} = x_i,  \quad i=1,\ldots,n\\&#xA;&amp;amp; Y \succeq 0 &#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;Here, &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; is a set of indexes, and for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; we are summing the elements &lt;span class=&quot;math-container&quot;&gt;$(j,k) \in S_i$&lt;/span&gt; of matrix &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and equate it to &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I am confused is that writing &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; in the latter problem in form &lt;span class=&quot;math-container&quot;&gt;$x_1 F_1+ \ldots+x_nF_n + G$&lt;/span&gt; seems not straightforward, i.e., another linear system on &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; matrix has to be solved, etc..&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2020-02-04T02:36:10.063" Title="Semi-definite Programming, non standard notation" Tags="|optimization|convex-optimization|sdp|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3481" PostTypeId="1" CreationDate="2020-02-04T04:25:08.133" Score="11" ViewCount="1439" Body="&lt;p&gt;I have been accepted for an internship for 6 months. The aim of this internship is to implement a &quot;generic&quot; solver for scheduling/production planning problems.  This solver will bill a &lt;em&gt;small&lt;/em&gt; prototype for a saas product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware that there is a huge number of this kind of problems. It seems that this is a very ambitious (or even a non-realistic) goal to finish within only 6 months. It's frustrating and I don't know where to start, in particular because there is no OR expert in the company. So I need to really focus on a small part of the problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my questions are, 1) What to do in order to progress as much as possible, how to filter the problems to focus on? 2) What are the easiest methods to use when solving etc. (I do not need necessarily exact methods, I am thinking about metaheuristics)? 3) Is there some examples of these kind of solvers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any other suggestion/idea/advice/resource/etc. that could help making the experience less frustrating is welcome. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; The main issue that is causing the frustration is how to identify the &quot;common&quot; problem(there is far more than a single problem in scheduling), I don't know how to proceed or even where to start. &lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2020-02-08T19:33:48.567" LastActivityDate="2020-02-10T09:48:32.817" Title="How to implement a &quot;generic&quot; solver for scheduling problems?" Tags="|solver|scheduling|algorithms|software|metaheuristics|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3482" PostTypeId="1" AcceptedAnswerId="3488" CreationDate="2020-02-04T08:28:20.957" Score="13" ViewCount="160" Body="&lt;p&gt;I was wondering if someone has come across this before and/or has a smart idea for the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a directed graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; with costs &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; associated with the arcs, and I know the shortest path &lt;span class=&quot;math-container&quot;&gt;$P^G_{st} = \{s,\dots,i,j,\dots,t\}$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; between nodes &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Is there an efficient way to determine the shortest path between &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; in graph &lt;span class=&quot;math-container&quot;&gt;$G'$&lt;/span&gt;, which is equal to &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; with the exception of the cost of a single arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$P^G_{st}$&lt;/span&gt; that is now &lt;span class=&quot;math-container&quot;&gt;$c'_{ij} = c_{ij} + \alpha, \alpha &amp;gt; 0$&lt;/span&gt;? By &quot;efficient&quot; I mean something better than re-calculating from scratch the complete shortest path in &lt;span class=&quot;math-container&quot;&gt;$G'$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="578" LastEditorUserId="500" LastEditDate="2023-12-13T18:03:23.977" LastActivityDate="2023-12-13T18:03:23.977" Title="Re-calculating shortest path in slightly altered graph" Tags="|graphs|computational-complexity|warm-start|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3484" PostTypeId="2" ParentId="3481" CreationDate="2020-02-04T09:40:01.250" Score="10" Body="&lt;p&gt;As you mentioned about &quot;scheduling/production planning problems&quot;, I refer it to manufacturing planning and detailed schedule. Also, I know that there are specific methods to solve other planning and scheduling problems. (E.g. vehicle routing problem variants).&#xA;Planning and Scheduling, specifically in the real application, will need to survey from some essential aspects:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Understanding, which kind of problem you have faced? For example, in the machinery area, what is the specification of the environment? job shop, open shop, etc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) How much your problem scales?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Which one method, (exact or (meta)heuristics), could be used to solve the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) How do you want to represent your problem results?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the above questions (also there are others) you could try implementing your own/specific solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Also, it should be noted that:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If you are going to develop a mathematical program, it would be considered usually, each problem needs a specific MP and you might have to develop many models.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If your problem's scale is large and your model is straight forward, you would expect to solve the problem using open-source solvers otherwise, you should use the commercial solvers which need more cost or you will need some professional skills to use an advanced approach like decomposition method.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As per, many real problems should be solved in a reasonable time, (meta) heuristics like CP, genetic algorithm, etc can be applied.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As MSExcel is frequently used in industry and what you are looking for is based on excel, you can try developing an excel-based solver.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you are interested to develop a friendly user-interface, using a programming language (like C++, Python, etc) might be interested. Specifically, combining with the solver.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Finally, some references and related questions, which I hope to be useful, are:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/gp/book/9781441909091&quot; rel=&quot;noreferrer&quot;&gt;Planning and Scheduling in Manufacturing and Services by Professor Michael L. Pinedo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://web-static.stern.nyu.edu/om/software/lekin/&quot; rel=&quot;noreferrer&quot;&gt;Flexible Job-Shop Scheduling System&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://solverstudio.org/&quot; rel=&quot;noreferrer&quot;&gt;solver studio&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.me.utexas.edu/~jensen/ORMM/excel/library_windows.html&quot; rel=&quot;noreferrer&quot;&gt;Operations Research Models and Methods using Jensen Library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/3271/what-are-best-practices-to-make-optimization-user-interfaces-intuitive-for-the-u/3275#3275&quot;&gt;What are best practices to make optimization user interfaces intuitive for the user?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/3118/black-box-optimization-with-linear-programming/3119#3119&quot;&gt;Black-box optimization with linear programming?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-02-04T09:40:01.250" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3485" PostTypeId="2" ParentId="3481" CreationDate="2020-02-04T09:55:25.250" Score="6" Body="&lt;p&gt;Generally speaking the most generic scheduling problem is the RCPSP. However, even that tends to need extensions for many practical problems. &#xA;See &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2009.11.005&quot; rel=&quot;noreferrer&quot;&gt;Hartmann, Sönke, and Dirk Briskorn. &quot;A survey of variants and extensions of the resource-constrained project scheduling problem.&quot; European Journal of operational research 207.1 (2010): 1-14&lt;/a&gt;. for a structured overview of the extentions that have been discussed before 2010.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally speaking the more tailored to the specific problem the model and algorithm are, the better it will perform. &#xA;However, there are generic solvers, even open source versions, see &lt;a href=&quot;https://or.stackexchange.com/q/841/405&quot;&gt;List of Implementations for common OR problems&lt;/a&gt;. Their performance is typically strongly influenced by the exact model and its implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solving real world problems is to a large extend about &quot;finding the problem&quot; that means modelling, looking at where data/information lies and how it flows, where decisions are made, and what exactly can be automated. Then just using any solver / metaheuristic or even a local search will often get you 80% of the way. The 20% that remain are actually about fine tuning solution methods / exact algorithms. This is why open source solver companies still have a business model. They don't make their money with the solver, but with the consulting around it.&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2020-02-04T19:45:03.647" LastActivityDate="2020-02-04T19:45:03.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3486" PostTypeId="1" AcceptedAnswerId="3491" CreationDate="2020-02-04T11:16:57.683" Score="8" ViewCount="152" Body="&lt;p&gt;I have a graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; and the following variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b_{i,j}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; edge is taken or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_{i,j}$&lt;/span&gt; is time to travel &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A_{i}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$D_{i}$&lt;/span&gt; are arrival and departure time at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first objective is :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i,j} b_{i,j}\cdot t_{i,j} + \sum_{i} D_{i} - A_{i}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My second objective is :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min A_{e}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; is the end location of the path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is why the solver takes a long time to solve the second objective as compared to the first objective.&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="123" LastEditDate="2020-02-04T19:45:53.433" LastActivityDate="2020-02-04T19:45:53.433" Title="Choosing better objective function for vehicle routing problem" Tags="|mixed-integer-programming|linear-programming|modeling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3487" PostTypeId="1" CreationDate="2020-02-04T14:14:06.043" Score="5" ViewCount="1303" Body="&lt;p&gt;I want to solve a linear programming minimax problem  &lt;a href=&quot;http://apmonitor.com/me575/index.php/Main/MiniMax&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; mathematically without using software:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align*}&#xA;     \text{min}\ \text{max} \quad &amp;amp; \{x_1,x_2,x_3\} \\&#xA;     \text{s.t.}     \quad &amp;amp; x_1 + x_2 + x_3 = 15&#xA;\end{align*}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or it can be written&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align*}&#xA;    \text{min} \quad &amp;amp; Z \\&#xA;    \text{s.t.} \quad  &amp;amp; x_1 + x_2 + x_3 = 15 \\&#xA;          &amp;amp; Z \ge x_1 \\&#xA;          &amp;amp; Z \ge x_2 \\&#xA;          &amp;amp; Z \ge x_3 \\&#xA;\end{align*}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I was wondering if someone could help me or provide me with good lecture notes having an explanation with examples?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edited&lt;/strong&gt;: The above problem seems solvable by inspection method, but if we consider the following problem we can't get the optimal solution by inspection (optimal solution I have obtained using the software is &lt;span class=&quot;math-container&quot;&gt;$x_1=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_2=0.39216$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_3=0.29412$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_4=0.31373$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z=-1.1765$&lt;/span&gt;, but I don't know how to solve it manually/mathematically, as well):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align*}&#xA;    \text{min} \quad &amp;amp; Z \\&#xA;    \text{s.t.} \quad  &amp;amp; x_1 + x_2 + x_3+x_4 = 1 \\&#xA;          &amp;amp; Z \ge x_1-3x_2 \\&#xA;          &amp;amp; Z \ge x_1-4x_3 \\&#xA;          &amp;amp; Z \ge x_1-7x_4 \\&#xA;          &amp;amp; Z \ge x_2-5x_4 \\&#xA;          &amp;amp; Z \ge x_3-5x_4 \\&#xA;          &amp;amp; x_1,x_2,x_3,x_4\ge 0 \\&#xA;\end{align*}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2927" LastEditorUserId="491" LastEditDate="2022-03-30T12:38:48.763" LastActivityDate="2022-03-30T12:38:48.763" Title="Solving continuous Minimax Optimization problem" Tags="|optimization|linear-programming|reference-request|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3488" PostTypeId="2" ParentId="3482" CreationDate="2020-02-04T14:19:59.633" Score="9" Body="&lt;p&gt;In DP Bertsekas &lt;em&gt;Network Optimization&lt;/em&gt; (that can be &lt;a href=&quot;http://www.mit.edu/~dimitrib/home.html&quot; rel=&quot;noreferrer&quot;&gt;downloaded for free&lt;/a&gt;) there's an exercise at Page 104 (Finding an initial price vector) where you can find a method for solving shortest paths in dynamic graphs. Basically, it resorts to using the price vectors from the first iteration to warm start the method at the second. Many years ago I implemented that method to solve dynamic shortest paths on road problems under congestion. We used the price vectors given by the nominal speeds (in the absence of congestion) as starting price vectors. We saw that in a scenario of low or very local congestion, this warm start provided substantial speedups over the traditional approach of solving the SPP from scratch every time.&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2020-02-04T15:03:03.107" LastActivityDate="2020-02-04T15:03:03.107" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3489" PostTypeId="2" ParentId="3487" CreationDate="2020-02-04T14:27:13.340" Score="3" Body="&lt;p&gt;The optimal solution is 15/3 for the three variables. Any other assignment is such that at least one of the variables takes a value larger than 15/3.&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2020-02-04T14:27:13.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3490" PostTypeId="2" ParentId="3487" CreationDate="2020-02-04T14:29:40.227" Score="7" Body="&lt;p&gt;Although this is a linear programming problem, it can really be solved by inspection. Think about how you'd solve the problem if there were only two variables, i.e.:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align*}&#xA;     \text{min}\ \text{max} \quad &amp;amp; \{x_1,x_2\} \\&#xA;     \text{s.t.}     \quad &amp;amp; x_1 + x_2  = 15&#xA;\end{align*}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now can you extend your approach to handle 3 variables?&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-02-04T14:29:40.227" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3491" PostTypeId="2" ParentId="3486" CreationDate="2020-02-04T14:33:45.707" Score="5" Body="&lt;p&gt;Your first objective is a minisum objective; your second is a minimax objective. Minimax objectives are usually much harder to solve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this related question: &lt;a href=&quot;https://or.stackexchange.com/q/143/38&quot;&gt;Why are integer minimax problems hard?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an analogy, the &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median problem is a minisum facility location problem, while the &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-center problem is a minimax problem with nearly the same constraints. I once ran a test on both problems using a classic 88-node benchmark instance. CPLEX solved the &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median problem in 0.5 seconds but took more than 1600 seconds to solve the &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-center problem.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-02-04T14:33:45.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3492" PostTypeId="2" ParentId="3487" CreationDate="2020-02-04T15:57:36.893" Score="2" Body="&lt;p&gt;For a proof that the solution &lt;span class=&quot;math-container&quot;&gt;$x=(5,5,5)$&lt;/span&gt; is optimal, use a dual multiplier &lt;span class=&quot;math-container&quot;&gt;$1/3$&lt;/span&gt; for each constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\frac{1}{3}(x_1 + x_2 + x_3) &amp;amp;= \frac{1}{3}\cdot 15 \\&#xA;\frac{1}{3}Z &amp;amp;\ge \frac{1}{3}x_1 \\&#xA;\frac{1}{3}Z &amp;amp;\ge \frac{1}{3}x_2 \\&#xA;\frac{1}{3}Z &amp;amp;\ge \frac{1}{3}x_3 \\&#xA;\end{align}&lt;/span&gt;&#xA;Adding these up yields &lt;span class=&quot;math-container&quot;&gt;$Z \ge 5$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-02-04T15:57:36.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3493" PostTypeId="1" AcceptedAnswerId="3495" CreationDate="2020-02-04T18:15:55.250" Score="5" ViewCount="547" Body="&lt;p&gt;Somehow I don't get it right.&lt;/p&gt;&#xA;&lt;p&gt;I would like to model the following conditional:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$A\le B$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$Y=1$&lt;/span&gt; otherwise &lt;span class=&quot;math-container&quot;&gt;$Y=0$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A, B$&lt;/span&gt; are reals and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is binary.&lt;/p&gt;&#xA;&lt;p&gt;I can model as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Y \cdot A \le B$&lt;/span&gt; and linearise this, but then I get into trouble when &lt;span class=&quot;math-container&quot;&gt;$A = 0$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;p&gt;In this case &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; can be anything but I want it to be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="3903" LastEditDate="2020-07-28T20:01:25.397" LastActivityDate="2020-07-28T20:01:25.397" Title="How to model If $A \le B$ then $Y = 1$, otherwise $Y = 0$" Tags="|mixed-integer-programming|modeling|combinatorial-optimization|linearization|big-m|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3494" PostTypeId="1" AcceptedAnswerId="3529" CreationDate="2020-02-04T18:17:22.390" Score="4" ViewCount="751" Body="&lt;p&gt;I am completely new to OR Tools, but what I have tried so far seems very powerful. &#xA;I have, however, run into a problem that I cannot seem to figure out how to solve.&#xA;I am trying to model a TSP problem, which also includes constraints on the demand of connected nodes. &#xA;It is not the capacity on the entire tour, but rather on rolling subsets of the tour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. the demand of 3 connected nodes has to be at least (&lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt;) 6.&#xA;Or it could also be that the demand of 3 connected nodes at most (&lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt;) could be 16.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which would translate into for the min constraint: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;demand[tour_index[0]] + demand[tour_index[1]] + demand[tour_index[0]] &amp;gt;= 6 &#xA;demand[tour_index[1]] + demand[tour_index[2]] + demand[tour_index[3]] &amp;gt;= 6 &#xA;demand[tour_index[2]] + demand[tour_index[3]] + demand[tour_index[4]] &amp;gt;= 6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say I have the following data, how could I model these kinds of constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;data['distance_matrix'] = [&#xA;        [&#xA;            0, 548, 776, 696, 582, 274, 502, 194, 308, 194, 536, 502, 388, 354,&#xA;            468, 776, 662&#xA;        ],&#xA;        [&#xA;            548, 0, 684, 308, 194, 502, 730, 354, 696, 742, 1084, 594, 480, 674,&#xA;            1016, 868, 1210&#xA;        ],&#xA;        [&#xA;            776, 684, 0, 992, 878, 502, 274, 810, 468, 742, 400, 1278, 1164,&#xA;            1130, 788, 1552, 754&#xA;        ],&#xA;        [&#xA;            696, 308, 992, 0, 114, 650, 878, 502, 844, 890, 1232, 514, 628, 822,&#xA;            1164, 560, 1358&#xA;        ],&#xA;        [&#xA;            582, 194, 878, 114, 0, 536, 764, 388, 730, 776, 1118, 400, 514, 708,&#xA;            1050, 674, 1244&#xA;        ],&#xA;        [&#xA;            274, 502, 502, 650, 536, 0, 228, 308, 194, 240, 582, 776, 662, 628,&#xA;            514, 1050, 708&#xA;        ],&#xA;        [&#xA;            502, 730, 274, 878, 764, 228, 0, 536, 194, 468, 354, 1004, 890, 856,&#xA;            514, 1278, 480&#xA;        ],&#xA;        [&#xA;            194, 354, 810, 502, 388, 308, 536, 0, 342, 388, 730, 468, 354, 320,&#xA;            662, 742, 856&#xA;        ],&#xA;        [&#xA;            308, 696, 468, 844, 730, 194, 194, 342, 0, 274, 388, 810, 696, 662,&#xA;            320, 1084, 514&#xA;        ],&#xA;        [&#xA;            194, 742, 742, 890, 776, 240, 468, 388, 274, 0, 342, 536, 422, 388,&#xA;            274, 810, 468&#xA;        ],&#xA;        [&#xA;            536, 1084, 400, 1232, 1118, 582, 354, 730, 388, 342, 0, 878, 764,&#xA;            730, 388, 1152, 354&#xA;        ],&#xA;        [&#xA;            502, 594, 1278, 514, 400, 776, 1004, 468, 810, 536, 878, 0, 114,&#xA;            308, 650, 274, 844&#xA;        ],&#xA;        [&#xA;            388, 480, 1164, 628, 514, 662, 890, 354, 696, 422, 764, 114, 0, 194,&#xA;            536, 388, 730&#xA;        ],&#xA;        [&#xA;            354, 674, 1130, 822, 708, 628, 856, 320, 662, 388, 730, 308, 194, 0,&#xA;            342, 422, 536&#xA;        ],&#xA;        [&#xA;            468, 1016, 788, 1164, 1050, 514, 514, 662, 320, 274, 388, 650, 536,&#xA;            342, 0, 764, 194&#xA;        ],&#xA;        [&#xA;            776, 868, 1552, 560, 674, 1050, 1278, 742, 1084, 810, 1152, 274,&#xA;            388, 422, 764, 0, 798&#xA;        ],&#xA;        [&#xA;            662, 1210, 754, 1358, 1244, 708, 480, 856, 514, 468, 354, 844, 730,&#xA;            536, 194, 798, 0&#xA;        ],&#xA;    ]&#xA;    data['demands'] = [0, 1, 1, 2, 4, 2, 4, 8, 8, 1, 2, 1, 2, 4, 4, 8, 8]&#xA;    data['num_vehicles'] = 1&#xA;    data['depot'] = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3019" LastEditorUserId="38" LastEditDate="2020-02-06T00:25:59.163" LastActivityDate="2020-02-11T15:04:55.270" Title="TSP with constraints in OR Tools" Tags="|modeling|constraint|or-tools|traveling-salesman|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3495" PostTypeId="2" ParentId="3493" CreationDate="2020-02-04T18:31:26.667" Score="7" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$A\in[\underline{A},\overline{A}]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B\in[\underline{B},\overline{B}]$&lt;/span&gt;, the following big-M constraints enforce &lt;span class=&quot;math-container&quot;&gt;$Y=1\implies A \le B$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y=0\implies B \le A$&lt;/span&gt;, respectively:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;A - B &amp;amp;\le (\overline{A}-\underline{B})(1-Y)\\&#xA;B - A &amp;amp;\le (\overline{B}-\underline{A}) Y\\&#xA;\end{align}&lt;/span&gt;&#xA;To disambiguate the &lt;span class=&quot;math-container&quot;&gt;$A=B$&lt;/span&gt; case, you could introduce &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; in the second constraint, as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$B - A + \epsilon \le (\overline{B}-\underline{A}+\epsilon) Y$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-03-11T17:55:07.903" LastActivityDate="2020-03-11T17:55:07.903" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="3496" PostTypeId="2" ParentId="3481" CreationDate="2020-02-04T21:09:00.687" Score="7" Body="&lt;p&gt;The &quot;generic&quot; aspect of the solver might just mean that management has, um, inflated expectations. That said, and focusing on the use of metaheuristics, I'll throw out a few ideas.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Where possible, use a (well-crafted) third-party library to do the actual metaheuristic computations, rather than writing your own. It's likely to be faster than what you would produce, it will certainly save you development time, and if you are using parallel threading it may save you some sleepless nights.&lt;/li&gt;&#xA;&lt;li&gt;After ascertaining just how generic this solver is supposed to be, look for common elements among the problems it is intended to solve, and then look for metaheuristics designed for problems with those elements. As an example of what I mean, a lot of scheduling problems largely boil down to some combination of ordering a list of activities and maybe winnowing out some. There's a variant of genetic algorithms called random-key genetic algorithms that are easy to implement for problems of that type. (I don't know how their performance compares to other metaheuristics, but I do know they are fairly easy to implement.)&lt;/li&gt;&#xA;&lt;li&gt;You do not have to limit yourself to one metaheuristic. You could code the program to run metaheuristic races one each problem (e.g., one thread running simulated annealing, another thread running 2-opt or 3-opt, another thread or two doing a GA), possibly with solution swapping among the methods (restart method 1 at some point using method 2's best solution ...), and then give the user the overall winner.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-02-04T21:09:00.687" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3497" PostTypeId="1" CreationDate="2020-02-05T10:36:48.403" Score="3" ViewCount="334" Body="&lt;p&gt;I have a graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; and have a set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; which are the points in the graph to visit in a TSP manner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the length of the TSP route can't be known as it can use any number of nodes to complete the journey.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if it is possible to use &lt;code&gt;Dantzig-Fulkerson-Johnson formulation&lt;/code&gt; or only &lt;code&gt;Miller-Tucker-Zemlin formulation&lt;/code&gt; can be used.&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="38" LastEditDate="2020-02-05T13:18:38.877" LastActivityDate="2020-02-07T09:11:43.537" Title="Comparing formulation for traveling salesman" Tags="|linear-programming|modeling|traveling-salesman|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3499" PostTypeId="2" ParentId="3497" CreationDate="2020-02-05T16:34:23.113" Score="7" Body="&lt;p&gt;As suggested by Larry Snyder in the comments to your question, you can reduce your problem to a standard traveling salesman problem by means of precomputing the distances. In particular, consider the complete graph with nodes given by &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. Moreover, consider as distance between nodes &lt;span class=&quot;math-container&quot;&gt;$s_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s_2$&lt;/span&gt; the shortest path between those nodes in your original graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; (and a distance of &lt;span class=&quot;math-container&quot;&gt;$\infty$&lt;/span&gt; if no path exists). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are now left with a standard traveling salesman problem on which both types of formulations can be used. For some more information on what the best performing formulation would be, see the information in &lt;a href=&quot;https://or.stackexchange.com/questions/1207/the-rationale-to-improve-mtz&quot;&gt;this question&lt;/a&gt;. In particular, note that the Dantzig-Fulkerson-Johnson (DFJ) is generally seen as the best performing formulation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case the paths between any two nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; needs to be determined in the model (while the whole thing should still be a tour), you could adjust the DFJ formulation to account for only having to visit the nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. In particular, replace the typical constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; \sum_{j=1}^{n} x_{ij} = 1 &amp;amp;&amp;amp; \forall i \in V,\\&#xA;&amp;amp; \sum_{i=1}^{n} x_{ij} = 1 &amp;amp;&amp;amp; \forall j \in V,\\&#xA;\end{align}&lt;/span&gt;&#xA;by &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; \sum_{j=1}^{n} x_{ij} = 1 &amp;amp;&amp;amp; \forall i \in S,\\&#xA;&amp;amp; \sum_{i=1}^{n} x_{ij} = 1 &amp;amp;&amp;amp; \forall j \in S,\\&#xA;&amp;amp; \sum_{j=1}^{n} x_{ij} = \sum_{j=1}^{n} x_{ji} &amp;amp;&amp;amp; \forall i \in V \setminus S.&#xA;\end{align}&lt;/span&gt;&#xA;Note that these constraints imply that there is again a collection of tours. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the regular TSP, it is needed to include subtour elimination constraints. In particular, we want to prevent that there are subtours that include only a subset of the nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; (or subtours containing no nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;). We thus need to add a subtour elimination constraint for each &lt;span class=&quot;math-container&quot;&gt;$V' \subset V: S \nsubseteq V'$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="237" LastEditDate="2020-02-07T09:11:43.537" LastActivityDate="2020-02-07T09:11:43.537" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3500" PostTypeId="1" CreationDate="2020-02-05T18:28:59.877" Score="4" ViewCount="1289" Body="&lt;p&gt;I created &lt;code&gt;OptionalIntervals&lt;/code&gt; for a number of tasks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    std::vector&amp;lt;IntVar&amp;gt; starts;&#xA;    std::vector&amp;lt;IntVar&amp;gt; sizes;&#xA;    std::vector&amp;lt;IntVar&amp;gt; ends;&#xA;    std::vector&amp;lt;BoolVar&amp;gt; presences;&#xA;    std::vector&amp;lt;IntervalVar&amp;gt; Intervals;&#xA;&#xA;    for (int j=0; j&amp;lt;nbTasks; j++) &#xA;    {   &#xA;        const IntVar start = cp_model.NewIntVar(Domain(0, tmax)).WithName(&quot;start&quot;);       // generamos una variable intervalo&#xA;        const IntVar end = cp_model.NewIntVar(Domain(0, tmax)); &#xA;        const BoolVar presence = cp_model.NewBoolVar();&#xA;        const IntVar size = cp_model.NewConstant(duration[j]); &#xA;        const IntervalVar interval = cp_model.NewOptionalIntervalVar(start, size, end, presence);&#xA;        starts.push_back(start);       &#xA;        sizes.push_back(size);     &#xA;        ends.push_back(end);&#xA;        presences.push_back(presence);&#xA;        Intervals.push_back(interval);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to maximize a function that depends on the &lt;code&gt;start&lt;/code&gt; of each task (where some tasks could be unperformed to get a better solution). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason, all the activities are unperformed in the results even if the start of a job is 53. I mean, the present variable is 0 but it has a start date (thus the constraint &lt;code&gt;start+duration==end&lt;/code&gt; is not applied). Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess that what causes this is that the &lt;code&gt;starts&lt;/code&gt; vector is independent from the &lt;code&gt;Intervals&lt;/code&gt; vector, so when a task is unperformed the interval constraint is not applied but its start varies independently. Is there a way to avoid that? that if the task is not performed it doesn't have a start either.&lt;/p&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="38" LastEditDate="2020-02-06T00:23:47.627" LastActivityDate="2022-01-12T18:14:18.677" Title="How exactly does OptionalIntervalVar work in OR-Tools?" Tags="|constraint-programming|scheduling|or-tools|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3501" PostTypeId="2" ParentId="3500" CreationDate="2020-02-05T23:29:24.600" Score="6" Body="&lt;p&gt;In the Python API there is a pretty good &lt;a href=&quot;https://github.com/google/or-tools/blob/2cb85b4eead4c38e1c54b48044f92087cf165bce/ortools/sat/python/cp_model.py#L1617-L1621&quot; rel=&quot;nofollow noreferrer&quot;&gt;docstring&lt;/a&gt; of what an OptionalIntervalVar is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;An optional interval variable is a constraint, that is itself used in other&#xA;constraints like NoOverlap. This constraint is protected by an is_present&#xA;literal that indicates if it is active or not.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Internally, it ensures that &lt;code&gt;is_present&lt;/code&gt; implies &lt;code&gt;start + size == end&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So you would have to constraint manually what happens to &lt;code&gt;start&lt;/code&gt;, &lt;code&gt;size&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; when the presence literal is not active.&lt;/p&gt;&#xA;&lt;p&gt;Don't forget to also constraint the presence boolean properly, otherwise it won't ever be active.&lt;/p&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2022-01-12T18:14:18.677" LastActivityDate="2022-01-12T18:14:18.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3502" PostTypeId="1" CreationDate="2020-02-06T12:58:57.110" Score="8" ViewCount="687" Body="&lt;p&gt;I am currently struggling with a bin packing variant, where we have fuel and compartments of a tank truck. Some industry constraints apply, but the whole picture is that you must fit the total volume with the optimum way through the compartments.&lt;br&gt;&#xA;I have created a model, which works almost perfectly, where I try to minimize the wastage (from all the compartments, not only the used).&lt;br&gt;&#xA;Now let's say that I have a preference in using as front compartments as possible, namely if the 2nd compartment and the 8th compartment have 1000lt capacity, then I want to use the 2nd compartment. I want this to happen only when the wastage of the one solution is equal to the other. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence, If I have a solution with wastage 1100 lt and the 2nd compartment is empty, but I have another solution with wastage 1100lt and the 8th compartment is empty, I want the model to extract the second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to model preference constraints, without diverging from the original objective (minimizing wastage)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;br&gt;&#xA;Let me explain a little more about my objective. Right now the objective is  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i\sum_j(c_{j}-y_{ij})$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$c_{j}$&lt;/span&gt; is the capacity of each compartment &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; is the assigned quantity of element &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in compartment &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. If we assume that the new part of the objective function is to be found (I'm counting on you), then I can replace the function above with:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$M\cdot\sum_i\sum_j(c_{j}-y_{ij})+\mu\cdot F$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is going to be a big number and &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; a small number. &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; would be the second objective.&lt;/p&gt;&#xA;" OwnerUserId="1243" LastEditorUserId="123" LastEditDate="2020-02-06T19:25:28.510" LastActivityDate="2020-02-07T07:44:39.453" Title="Bin packing variant" Tags="|optimization|mixed-integer-programming|linear-programming|modeling|constraint|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3503" PostTypeId="2" ParentId="3481" CreationDate="2020-02-06T13:12:28.443" Score="7" Body="&lt;p&gt;Before you even start worrying about algorithms, you need to figure out the solver's architecture. You can do so by posing and answering questions such as the ones I ask below. The answers will be a function of the goals of the project, the help &amp;amp; know-how of the people who employ you and, crucially, what you can realistically do in 6 months. Keep in mind that writing an interface you've never seen before can easily take a month or two so experiment first before committing.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;what language are you going to use?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;what build system are you going to use?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;what types of OSs will you support?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;do you have a way of getting the math in the solver or so you need to write a parser?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;will you code the LP/MILP part yourself or link third party? If you code it, you'll need to identify, write an interface to, and link, a factorisation library.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if you use third party, you'll have to write the interfaces. Ideally, pick libraries with ok-ish interfaces to the language you're using.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;how is the user going to retrieve the result? What are the exit flags/convergence conditions going to be?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;are you going to use a parallel framework? If so, and you choose multithreading, are your dependencies thread-safe?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;what framework are you going to use for integration testing/unit testing?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;are you going to support non-linear functions? If so, you'll need computational graphs and ways to get derivatives.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;are you going to use a sparse container to represent your coefficient matrix? If so, which one and from what library?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;do you need to support callbacks/signal handling?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;is your software going to be use standalone or invoked as a library? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;how are you going to handle exceptions?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-02-06T13:12:28.443" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3504" PostTypeId="2" ParentId="3502" CreationDate="2020-02-06T13:33:47.497" Score="9" Body="&lt;p&gt;It sounds like you are describing what is sometimes called a &lt;em&gt;hierarchical decision-making problem&lt;/em&gt; -- we want to optimize some objective, but among all solutions that are optimal for that objective, we want to optimize some secondary objective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One approach for such problems is to put both objectives into the objective function, but with a large weight on the first objective. The weight should be large enough that a solution that's suboptimal for the first objective can't &quot;cheat&quot; its way into optimality by optimizing the second objective. This is usually possible with binary variables but might not be possible with continuous ones; I haven't thought it through.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is to first solve the problem with only the first objective (minimize waste) and without the second objective (tank preference) and get the optimal objective function value -- call it &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt;. Then add a constraint requiring the waste minimization to equal &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt;, and replace the objective function with the tank-preference objective. Now you are optimizing the tank preference but ensuring that the solution will still be optimal for the first objective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Essentially this is a special case of multi-objective optimization.)&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-02-06T13:33:47.497" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="3505" PostTypeId="1" CreationDate="2020-02-06T15:30:44.457" Score="6" ViewCount="141" Body="&lt;p&gt;I'm new to IBM CP optimizer.&lt;/p&gt;&#xA;&lt;p&gt;I want to make charging / discharging scheduling based on cost (value will change on time) and my objective function is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{t=1}^{24}\sum_{j=1}^5x(1)^{(t,j)}x(2)^{(t,j)}\cdot\text{Price}_1^{(t)}-x(3)^{(t,j)}x(4)^{(t,j)}\cdot\text{Price}_2^{(t)}$$&lt;/span&gt; where&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; means time (1 day) and machine number.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x(3)$&lt;/span&gt; means signal about charging or discharging (perhaps I can remove &lt;span class=&quot;math-container&quot;&gt;$x(3)$&lt;/span&gt; and re-write &lt;span class=&quot;math-container&quot;&gt;$(1-x(1)$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x(2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x(4)$&lt;/span&gt; means Power.&lt;/li&gt;&#xA;&lt;li&gt;I have a few constraints about the machine's maximum and minimum battery capacity.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Then, how can I make codes of the objective function and interval?&#xA;it is possible to make scheduling?&#xA;I tried several days with the CP manual and IBM website, but it's still not working well.&lt;/p&gt;&#xA;&lt;p&gt;(I will not use any API such as python, C++. I want to make in CP. )&lt;/p&gt;&#xA;" OwnerUserId="3034" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-02-27T13:47:22.450" Title="Optimal Energy Charging/discharging Scheduling Problem" Tags="|optimization|cplex|scheduling|cp-optimizer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3506" PostTypeId="2" ParentId="3502" CreationDate="2020-02-06T19:10:42.957" Score="4" Body="&lt;p&gt;If I understand you correctly (and I'm not betting on that), you could accomplish what you want using binary variables and some added constraints. Add a binary variable &lt;span class=&quot;math-container&quot;&gt;$z_j$&lt;/span&gt; for each compartment &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, together with the constraints &lt;span class=&quot;math-container&quot;&gt;$$c_j z_j \ge \sum_i y_{ij} \ge \epsilon z_j \quad \forall j$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$z_k \le z_j \quad \forall j,k: j &amp;lt; k \wedge c_j = c_k.$$&lt;/span&gt; Here &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt; is the minimum amount of cargo you would consider putting in a compartment. The first constraint forces &lt;span class=&quot;math-container&quot;&gt;$z_j=0$&lt;/span&gt; if you leave compartment &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; empty and &lt;span class=&quot;math-container&quot;&gt;$z_j=1$&lt;/span&gt; if you use it. The second constraint, restricted to pairs of compartments with equal capacity, says that you cannot use the higher index compartment unless you have used the lower index compartment. Thus compartment &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; cannot be empty unless compartment &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is also empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this deals only with the question of where empty compartments of equal capacity would go; it does not address empty compartments of differing capacities, nor the question of whether cargo in a partially full compartment &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; could be moved to a partially full compartment &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; of lower index.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-02-06T19:16:05.463" LastActivityDate="2020-02-06T19:16:05.463" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3507" PostTypeId="1" AcceptedAnswerId="3534" CreationDate="2020-02-07T05:33:58.850" Score="5" ViewCount="162" Body="&lt;p&gt;I have been using the method of fixing nonbasic variables with non-zero reduced costs to do preemptive goal programming. It works for the most part. But I have recently noticed in a certain instance of the problem, few variables have solution of 0, and their reduced cost is 0 too. I thought if the solution is 0, it is a non-basic variable. But when I used the commands available within cplex interactive optimizer, it showed me that these variables were still basic variables, but with solution 0. Since the preemptive goal programming method only fixes the non-basic variables with non zero reduced costs to 0, these variables escape the fixing, and while optimizing the next goal, the previously optimized objective deteriorates in value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I am missing something very simple here, but I am not sure. Is it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;fixing non-basic variables with non-zero variables is not enough to keep the optimality of the optimized objective? &lt;/li&gt;&#xA;&lt;li&gt;definition of nonbasic is not equal to those variables whose values are 0?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The method used here for the goal program is also known as column-dropping method. I wonder if the column-dropping approach does not work well for problems that have degenerate solutions.&lt;/p&gt;&#xA;" OwnerUserId="2748" LastEditorUserId="123" LastEditDate="2020-02-09T20:06:58.277" LastActivityDate="2020-02-11T13:45:14.727" Title="Preemptive Goal programming by fixing nonbasic variables with non-zero reduced costs" Tags="|linear-programming|simplex|reduced-costs|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3508" PostTypeId="2" ParentId="3502" CreationDate="2020-02-07T05:35:22.010" Score="2" Body="&lt;p&gt;I assume your objective minimization. This can be work&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i\sum_j m\cdot j\cdot(c_{j}-y_{ij})$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you should need fine tuning for m based on importance of waste capacity and sequence.&lt;/p&gt;&#xA;" OwnerUserId="432" LastEditorUserId="123" LastEditDate="2020-02-07T07:44:39.453" LastActivityDate="2020-02-07T07:44:39.453" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3509" PostTypeId="5" CreationDate="2020-02-07T14:31:02.300" Score="0" Body="&lt;p&gt;Convex optimization, a subfield of optimization, studies the problem of minimizing convex functions over convex sets. The convexity property can make optimization in some sense &amp;quot;easier&amp;quot; than the general case - for example, any local minimum must be a global minimum.&lt;/p&gt;&#xA;&lt;p&gt;Convex optimization has applications in automatic control systems, estimation and signal processing, communications and networks, electronic circuit design, data analysis and modeling, statistics, and finance.&lt;/p&gt;&#xA;" OwnerUserId="3040" LastEditorUserId="123" LastEditDate="2021-09-15T06:45:43.477" LastActivityDate="2021-09-15T06:45:43.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3510" PostTypeId="4" CreationDate="2020-02-07T14:31:02.300" Score="0" Body="Convex optimization, a subfield of optimization, studies the problem of minimizing convex functions over convex sets. The convexity property can make optimization in some sense &quot;easier&quot; than the general case - for example, any local minimum must be a global minimum.&#xD;&#xA;" OwnerUserId="3040" LastEditorUserId="123" LastEditDate="2021-09-15T06:45:43.477" LastActivityDate="2021-09-15T06:45:43.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3511" PostTypeId="1" CreationDate="2020-02-07T21:59:42.107" Score="13" ViewCount="1401" Body="&lt;p&gt;The state-of-art solvers like CPLEX or Gurobi and some of the open-source solvers have had the different APIs (like Python, C/C++, Java, etc.) in which users could write their MP model in own favourite programming language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK, the core of the many solvers, usually, has been written in C and other APIs are the layer to exchange the required data and results with its core (To compile the input to the core and to invoke the results from that.). Also, through the many APIs that have been developed, Python is more popular between the data analyses. Also, some of its libraries, like NumPy, have methods to deal with the matrix-based operations. (One of the new attempts could be found in Gurobi 9 Python API). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if, is there any difference between these APIs specifically in the performance and speed? (E.g. between Python and Java)?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-02-11T13:57:42.440" Title="What is the difference between optimization software APIs based on performance and speed?" Tags="|optimization|solver|api|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3512" PostTypeId="2" ParentId="3511" CreationDate="2020-02-07T22:14:30.887" Score="5" Body="&lt;p&gt;Python is a &quot;slow&quot; programming language because it is interpreted (at least CPython is), so in OR-Tools, for example, that impacts the model building speed if the model is big enough or your logic involves many loops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/issues/1663&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/issues/1663&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/issues/1020&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/issues/1020&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Edit: as others have said, this can be avoided if the API implementation is just a wrapper and leaves all the heavy work to a lower level language.&lt;/p&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2020-02-08T11:20:16.530" LastActivityDate="2020-02-08T11:20:16.530" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3514" PostTypeId="2" ParentId="3511" CreationDate="2020-02-08T10:55:51.913" Score="11" Body="&lt;p&gt;The difference between a C++ and Python API can be massive, but it also depends on the quality of the Python implementation.&lt;/p&gt;&#xA;&lt;p&gt;A key factor to consider when setting expectations, is the way the API is used to communicate information. There are two main ways to interact with APIs: (i) reading files, and (ii) creating models in the API.&lt;/p&gt;&#xA;&lt;h1&gt;Reading files&lt;/h1&gt;&#xA;&lt;p&gt;For example, our solver's Python API allows people to read a model like so:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;import libocteract&lt;/p&gt;&#xA;&lt;p&gt;m=Model()&lt;/p&gt;&#xA;&lt;p&gt;m.import_model_file(&amp;quot;path/to/my/ampl/gams/pyomo/nl/lp/mps/file&amp;quot;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;For open source formats, such as .nl or .mps, this command is a thin wrapper around the C++ library which reads the file directly.&lt;/p&gt;&#xA;&lt;p&gt;For our AMPL and GAMS interfaces, the Python command is a thin wrapper around their respective C++ APIs.&lt;/p&gt;&#xA;&lt;p&gt;In both cases, the Python overhead is minimal, because we invoke the C++ libraries directly.&lt;/p&gt;&#xA;&lt;p&gt;However, many solvers (especially open-source) will first construct the problem in Python, and then copy/pipe that object to the solver, which can be hundreds of times slower.&lt;/p&gt;&#xA;&lt;h1&gt;Building Models&lt;/h1&gt;&#xA;&lt;p&gt;This is trickier. Models are typically in some condensed format (like .nl), or are parsed by a dedicated parser (like AMPL) which transforms them to condensed format, so passing them to a solver quickly is doable.&lt;/p&gt;&#xA;&lt;p&gt;However, setting up the math through an API can't be as effective, unless a condensed format is used (which takes us back to the &amp;quot;Reading files&amp;quot; case).&lt;/p&gt;&#xA;&lt;p&gt;Say I want to add a non-linear constraint. In Octeract Engine, the binding in Python is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;m.add_constraint(&amp;quot;log(x^2)-1&amp;lt;=0&amp;quot;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Because we have a high performance parser built into the engine, we can parse the string directly, extract the variables automatically, create the computational graph, and a name for the constraint. The only overhead here is copying the string from Python to C++.&lt;/p&gt;&#xA;&lt;p&gt;In C++ however, we also allow users to create constraints directly from a syntax tree or computational graph, which is much faster.&lt;/p&gt;&#xA;&lt;p&gt;This is an important point: it's not that we can't expose the graph methods to Python for speed - we could, but forcing a user to build a complex object like that in Python defeats the purpose of using Python in the first place.&lt;/p&gt;&#xA;&lt;h1&gt;The bottomline&lt;/h1&gt;&#xA;&lt;p&gt;As long as the structures we pass to an API are high performance structures, such as a condensed file format, a sparse matrix, or a computational graph, there should be little difference between C++ and Python, as long as the Python implementation is good.&lt;/p&gt;&#xA;&lt;p&gt;If we are doing incremental changes to the model through the API, or building it piece by piece, the Python API can be considerably slower.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-02-11T13:57:42.440" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3515" PostTypeId="1" CreationDate="2020-02-09T20:05:48.293" Score="12" ViewCount="2860" Body="&lt;p&gt;I am a business student with engineering background and I am studying papers published in some journals like Management Science, Operations Research, Math of OR and they use some notations and keywords which I think are related to Pure Math.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, many papers in the stochastic optimization topic, define probability based on measure theory while they may use conventional probability theory. Or, they use some terms like Hilbert space, etc. Can I know if these are really necessary or are used to make papers more complicated?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If these are really necessary, I would be thankful if you can suggest me some references to improve my background in any branch of Math which can be helpful from probability to calculus.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="123" LastEditDate="2020-02-09T20:24:47.383" LastActivityDate="2020-02-09T21:31:10.727" Title="Is it necessary to study rigorous math courses in OR?" Tags="|optimization|reference-request|probability-theory|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3516" PostTypeId="2" ParentId="3515" CreationDate="2020-02-09T21:02:22.247" Score="18" Body="&lt;p&gt;There are multiple levels to operations research. (Before continuing, I want to apologize to anyone about to be scandalized by my omission of their favorite journals.)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For some (many?) people working in industry or government, it may be sufficient to be able to &quot;think in systems terms&quot;, identify and classify problems (&quot;this is a queuing problem, this other thing is more of an optimization problem&quot;), formulate models and use appropriate tools (open-source or commercial software) to handle the computational aspects. I would say that the math background for that is algebra, some linear algebra, maybe a bit of calculus, some probability theory and enough general understanding to know which models and algorithms work in a given context and which don't (e.g., don't try to use the simplex method on a problem with quadratic equality constraints). In journal terms, think &lt;em&gt;INFORMS Journal on Applied Analytics&lt;/em&gt; (formerly known as &lt;em&gt;Interfaces&lt;/em&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Moving up in sophistication (and roping in some academics), there is a niche where you not only need to be able to formulate models, but you need to be able to design or customize algorithms for solving them. (I'll include heuristics here.) The math (and, where applicable, probability theory) requirements are a bit more rigorous at this level. I think you need a decent appreciation of convexity (what it means, what things depend on it), for example. Measure / Banach / Hilbert spaces and other weirdness are not yet on the horizon. Journals that come to mind include &lt;em&gt;Operations Research&lt;/em&gt;, the &lt;em&gt;European Journal of Operational Research&lt;/em&gt;, the &lt;em&gt;INFORMS Journal on Optimization&lt;/em&gt;, &lt;em&gt;Decision Sciences&lt;/em&gt; etc.&lt;/li&gt;&#xA;&lt;li&gt;Finally, there are the folks who study problems and associated models with the intent of understanding the underlying mathematics. These are the folks (mainly but not exclusively academics) who work to show that certain cuts are facet-defining for the integer polytope of some discrete optimization model, or that solutions to some stochastic process model converge in probability to a well-known (to them, not to me) distribution as the problem size grows infinitely large. (Along with computer scientists, they may also obsess about questions relating to whether a particular problem is NP-obnoxious.) You may encounter the occasional Hilbert space (or worse) here. For this level, you need quite a bit of mathematical background. In journal terms, I would put &lt;em&gt;Mathematics of Operations Research&lt;/em&gt; into this category.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In summary, and without having said anything too specific about mathematical prerequisites, how much math you will need will depend on where you want to fit into the OR world. FWIW, I studied Hilbert spaces in both undergrad and graduate programs, taught some form of management science for about 30 years, and probably never once mentioned them. I definitely never mentioned them in any journal articles.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-02-09T21:02:22.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3517" PostTypeId="2" ParentId="3515" CreationDate="2020-02-09T21:31:10.727" Score="6" Body="&lt;p&gt;I would not say that knowing such concepts is necessary unless you wish to not only apply certain results to solve OR problems, but also to understand why/how the results work mathematically. For the most part the mathematics involved will not be too advanced; see @prubin's helpful answer for the hierarchical details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are really interested in how the results are derived mathematically (provided you have time), I believe a basic understanding of fields such as measure theory, and terms such as Hilbert spaces may prove very helpful in articles in journals such as &lt;em&gt;Mathematics of Operations Research&lt;/em&gt; as it does contain rather advanced mathematics (an example is &lt;a href=&quot;https://www.researchgate.net/publication/220442520_Convergence_of_a_Hybrid_Projection-Proximal_Point_Algorithm_Coupled_with_Approximation_Methods_in_Convex_Optimization&quot; rel=&quot;noreferrer&quot;&gt;Alvarez &lt;em&gt;et al.&lt;/em&gt; (2005)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;). For the specific area you mention (measure theory), I'd recommend Schilling's &lt;a href=&quot;https://books.google.co.uk/books?id=_OjSIphIrH0C&amp;amp;lpg=PP1&amp;amp;pg=PP1&amp;amp;redir_esc=y#v=onepage&amp;amp;q&amp;amp;f=false&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;Measures, Integrals and Martingales&lt;/em&gt;&lt;/a&gt; which does a great job of introducing what a measure is, and later discussing the concepts of inner product spaces and Hilbert spaces (chapters 20 - 21).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, especially given your academic background, I do not think you need to know these things right away - the materials listed above are solely for interest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. People usually don't intentionally make their publications more complicated than they should be.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Alvarez, F. &lt;em&gt;et al.&lt;/em&gt; (2005). Convergence of a Hybrid Projection-Proximal Point Algorithm Coupled with Approximation Methods in Convex Optimization. &lt;em&gt;Mathematics of Operations Research.&lt;/em&gt; 30(4):966-984. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2020-02-09T21:31:10.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3519" PostTypeId="1" CreationDate="2020-02-10T00:01:22.213" Score="4" ViewCount="86" Body="&lt;p&gt;I would like to model the following: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only one of the following equalities can hold. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$(A_1 = B_1)\quad\text{OR}\quad(A_2 = B_2)\quad\text{OR}\quad\dots\quad\text{OR}\quad(A_k = B_k)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$d_1,\dots,d_k$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if d1 = 1  then  (A1 = B1)&#xA;AND if d2 = 1  then  (A2 = B2)&#xA;      ...&#xA;AND if dk = 1  then  (Ak  = Bk)&#xA;&#xA;AND d1 + d2 + ... + dk = 1 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better way than this?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2020-02-10T09:29:23.607" LastActivityDate="2020-02-10T09:29:23.607" Title="How to model $A_i=B_i$ for only one $i$" Tags="|modeling|combinatorial-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3520" PostTypeId="2" ParentId="3519" CreationDate="2020-02-10T00:11:12.887" Score="5" Body="&lt;p&gt;What you have so far will enforce &lt;em&gt;at least&lt;/em&gt; one &lt;span class=&quot;math-container&quot;&gt;$A_i = B_i$&lt;/span&gt;. To get &lt;em&gt;exactly&lt;/em&gt; one, you need to also impose that &lt;span class=&quot;math-container&quot;&gt;$A_i = B_i$&lt;/span&gt; implies &lt;span class=&quot;math-container&quot;&gt;$d_i=1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-02-10T00:11:12.887" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3521" PostTypeId="2" ParentId="3481" CreationDate="2020-02-10T09:48:32.817" Score="4" Body="&lt;p&gt;First of all, congratulations on your internship. It is a great opportunity to put your skills into practice, and for the organization to get an understanding of what OR can be used for. But for the project to be successful, it is important that you are aligned on the problem you are solving. It currently sounds like you have a very broadly defined task which gives the huge risk that, even if you are doing a great job building the solver, that you end up with something that is different than what the company is hoping to get out of it. A solver is only valuable if it can help the company or its customers answer valuable questions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think when you have a more well-defined project, it will be easier to make the right technical choices, and there are a few other good answers around that so I will leave the technical aspects out of this answer. Here is a way to approach it:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Define what a successful project would look like&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It is very important that you understand why the management decided to do the internship. You should ask them what they are hoping to get out of it, and what the ideal outcome would be. &#xA;Since they don't have any OR-experts, a likely goal is to understand if OR can bring value to them and their customers. But it could also be some very specific challenges that are top-of-mind for them that they hope you can help with.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Define what the most important KPI's or questions to answer is&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You write that the company wants a generic solver which is very broad, so you need to find a place to start. Together with the management, you should define a very specific challenging problem either they or a customer are having. From this, you can start to understand what the most important objectives are which you then can use to decide what model you need to build. There are quite many different possibilities e.g.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Shorten the production time&lt;/li&gt;&#xA;&lt;li&gt;Minimize labor costs&lt;/li&gt;&#xA;&lt;li&gt;Increase the capacity of the system&lt;/li&gt;&#xA;&lt;li&gt;Maximize profit by choosing what to produce&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But it could also be some more strategic questions they want to answer&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How much can we increase capacity if we buy 2 more machines?&lt;/li&gt;&#xA;&lt;li&gt;How should we replan if one of our machines breaks down for 8 hours?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Understand the decision-maker and decision process&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The solver you are building needs to be used by someone. You should try to get as deep understanding of their job as possible. What are the key decisions and how does it link to the earlier defined objectives. You should ask if you can sit with the person for minimum an hour to ask them questions about their job and potentially watch them perform it while they tell what they do. This is also an opportunity to gather data you will need as input to your solver. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Start building and iterate&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You should now be able to formulate the first version of your model and can start building your solver. &#xA;I think there are other good answers around what methods you can use, but I will just highlight that it is important that you don't bury yourself into the code until the end of the project. In the end, people will care about the results they can get out of your solver, not the solver by itself. You should try to schedule some touchpoints at least once a month with the end-user where you can demo and show results and get some feedback to understand if you are moving in the right direction. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Every company and problem is different which will affect where your biggest challenges will be, but I hope they above can help you get started. Good luck!&lt;/p&gt;&#xA;" OwnerUserId="140" LastActivityDate="2020-02-10T09:48:32.817" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3524" PostTypeId="1" AcceptedAnswerId="3525" CreationDate="2020-02-10T22:44:46.303" Score="3" ViewCount="96" Body="&lt;p&gt;The problem is described as follows:&#xA;considering &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables which are continuous and bounded such that &#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_i \le x_i \le U_i\quad \forall i=1,2,\dots,n.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can i define a set of mixed integer linear inequalities such that the feasible solution will be&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y = \max(x_1,x_2,\dots,x_n).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not certain of my approach but this is what i have so far&lt;/p&gt;&#xA;&#xA;&lt;p&gt;constraint 1: &lt;span class=&quot;math-container&quot;&gt;$y \ge x_i$&lt;/span&gt;;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;constraint 2: &lt;span class=&quot;math-container&quot;&gt;$y \ge x_i + (U_i-L_i)w$&lt;/span&gt;;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$w\in\{0,1\}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2693" LastEditorUserId="500" LastEditDate="2020-02-11T00:13:58.020" LastActivityDate="2020-02-11T00:15:17.137" Title="defining Mixed integer linear inequalities for a set of variables" Tags="|optimization|mixed-integer-programming|modeling|linearization|big-m|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3525" PostTypeId="2" ParentId="3524" CreationDate="2020-02-10T23:10:56.400" Score="5" Body="&lt;p&gt;Constraint 1 is fine.  It imposes &lt;span class=&quot;math-container&quot;&gt;$y \ge \max(x_1,x_2,\dots,x_n)$&lt;/span&gt;.  For constraint 2, you need to reverse the inequality and also introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; (with the interpretation that &lt;span class=&quot;math-container&quot;&gt;$w_i=1$&lt;/span&gt; implies that &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is the maximum):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y \le x_i + M_i (1 - w_i).$$&lt;/span&gt;&#xA;We want the constraint to be redundant if &lt;span class=&quot;math-container&quot;&gt;$w_i = 0$&lt;/span&gt;, so take &lt;span class=&quot;math-container&quot;&gt;$M_i = \max(U_1,\dots,U_n) - L_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now also impose &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n w_i=1.$$&lt;/span&gt;  (Alternatively, you can relax this to &lt;span class=&quot;math-container&quot;&gt;$\ge 1$&lt;/span&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$n=2$&lt;/span&gt;, this formulation reduces to the one given &lt;a href=&quot;https://or.stackexchange.com/questions/711/how-to-formulate-maximum-function-in-a-constraint&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-02-11T00:15:17.137" LastActivityDate="2020-02-11T00:15:17.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3526" PostTypeId="1" CreationDate="2020-02-10T23:40:31.017" Score="7" ViewCount="245" Body="&lt;p&gt;In every machine learning book we see that it is roughly mentioned that the ridge regression:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$p_1^* = \min\limits_{\beta} \ \left( \mathrm{RSS} + \lambda\sum_{j=1}^p \beta_j^2 \right)$$&lt;/span&gt;&#xA;is equivalent to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ p_2^* = \min_{\beta} \left\{ RSS\,\Bigg\vert\,\sum_{j=1}^p \beta_j^2 &amp;lt; t \right\} $$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. The notation I followed is the classical notation, i.e., we have &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; predictors in a Linear Regression model, &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt; are the coefficients which we want to find, &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is the ridge penalization parameter, etc... Firstly I assume the equivalence is not on the objective values, but rather the minimizers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am now wondering this equivalence. Starting from the second formulation, obviously the Lagrangian function is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L(\beta, \lambda) = \left( \mathrm{RSS} +  \lambda \sum_{j=1}^p \beta_j^2 - \lambda \sum_{j=1}^p t \right) $$&lt;/span&gt;&#xA;for &lt;span class=&quot;math-container&quot;&gt;$\lambda \geq 0$&lt;/span&gt;. We know that the dual function lower bounds the original problem, i.e.,:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_\beta L(\beta, \lambda  \ | \ \lambda) \leq p_2^*. $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And since we are minimizing &lt;span class=&quot;math-container&quot;&gt;$L(\beta, \lambda)$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;, we can get rid of the &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; term and see that the problem is &lt;span class=&quot;math-container&quot;&gt;$p_1^*$&lt;/span&gt;. Now, the argument minimizing &lt;span class=&quot;math-container&quot;&gt;$p_1^*$&lt;/span&gt; provides a lower bound for &lt;span class=&quot;math-container&quot;&gt;$p_2^*$&lt;/span&gt;. Still, I don't see how we can use these two models &lt;strong&gt;equivalently&lt;/strong&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="123" LastEditDate="2020-02-11T08:53:30.427" LastActivityDate="2020-02-11T21:53:26.457" Title="Ridge Regression lagrange duality" Tags="|duality|convex-optimization|regression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3527" PostTypeId="1" AcceptedAnswerId="3533" CreationDate="2020-02-11T11:39:02.053" Score="5" ViewCount="219" Body="&lt;p&gt;I am trying to solve the following problem: &lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min&amp;amp;\quad f(x) = \sum_{i=1}^{n}{a_ix_i} + \sum_{i=1}^{n}{b_i\sqrt{\sum_{j=1}^{m}{\left(y_{i,j}-x_i\right)^2}}}\\\text{s.t.}&amp;amp;\quad&#xA;x_{i+1}\geq x_i \quad\forall i \in \{1,\dots,n-1\} \\&amp;amp;\quad&#xA;y_{i,j} \geq x_i \quad\forall (i,j) \in \{1,\dots,n\} \times \{1,\dots,m\} \\&amp;amp;\quad&#xA;y_{i,j} \geq c_j \quad\forall (i,j) \in \{1,\dots,n\} \times \{1,\dots,m\} \\&amp;amp;\quad&#xA;x_i \geq 0 \quad\forall i \in \{1,\dots,n\}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The parameters &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; are all positive numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is not quadratic because of the &lt;span class=&quot;math-container&quot;&gt;$\sqrt{\cdot}$&lt;/span&gt; functions in the objective. Therefore I believe mathematical programming solvers will be unable to solve this problem. Are local search methods the way to go here or is there a way to reformulate my problem that makes it easier to solve? If it's the former, are there off-the-shelf tools that I can use ? &lt;/p&gt;&#xA;" OwnerUserId="2715" LastEditorUserId="123" LastEditDate="2020-02-11T12:52:42.527" LastActivityDate="2020-02-11T13:16:31.447" Title="How to minimize a weighted sum of RMSE-like terms?" Tags="|optimization|modeling|nonlinear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3528" PostTypeId="2" ParentId="732" CreationDate="2020-02-11T12:18:21.373" Score="2" Body="&lt;p&gt;If you're looking for objective metrics, such as GitHub stars, commit rates, contributor counts, StackOverflow question count and other usage statistics, &lt;a href=&quot;https://www.libhunt.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;libhunt&lt;/a&gt; covers constraint solvers at least for Java:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://java.libhunt.com/categories/361-constraint-satisfaction-problem-solver&quot; rel=&quot;nofollow noreferrer&quot;&gt;Java constraint solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Warning: &lt;em&gt;objective metrics don't tell the entire story&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2020-02-11T12:18:21.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3529" PostTypeId="2" ParentId="3494" CreationDate="2020-02-11T12:22:08.897" Score="3" Body="&lt;p&gt;So, this is a bit complex.&#xA;You cannot use the routing library out of the box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the problem is not too big, you can use the CP-SAT solver with the circuit constraint.&#xA;A good start is &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/contrib/scheduling_with_transitions_sat.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;this example&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is for each node to maintain a few int var (sum of the last 1, sum of the last 2, sum of the last 3). Then using the transition literal to constraint the same set of variables in the head node: &lt;code&gt;transition_literal =&amp;gt; sum_2(head_nodel) = sum_1(tail_node) + contrib(tail_node)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difficulty lies in the boundary constraints. How do you make sure these constraints are valid for the first 2 nodes?&lt;/p&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2020-02-11T15:04:55.270" LastActivityDate="2020-02-11T15:04:55.270" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3530" PostTypeId="1" AcceptedAnswerId="3551" CreationDate="2020-02-11T12:33:00.463" Score="7" ViewCount="1580" Body="&lt;p&gt;Currently, I am working on the implementation of a &lt;strong&gt;MILP formulation&lt;/strong&gt; with lazy constraints for an optimization problem, and I am using the &lt;strong&gt;MIP Start&lt;/strong&gt; strategy. I am generating the &lt;strong&gt;integer feasible solution&lt;/strong&gt; to the MIP Start through a &lt;strong&gt;heuristic&lt;/strong&gt;, the solution is feasible for all possible lazy constraints. However, whenever I pass the integer solution to the MIP Start the Cplex returns the following &lt;strong&gt;warning&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Warning: No solution found from 481 MIP starts.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And the Cplex begins to solve the problem &lt;strong&gt;without&lt;/strong&gt; using the provided integer solution. In all &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.1/ilog.odms.ide.help/refcppopl/html/enumerations/IloCplex_MIPStartEffort.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIP Start effort level&lt;/a&gt;, the same behavior is presented. Also, as recommended by this &lt;a href=&quot;https://www.ibm.com/support/pages/node/416477&quot; rel=&quot;nofollow noreferrer&quot;&gt;IBM Support webpage&lt;/a&gt;, I am setting the Cplex parameters:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Presolve reduce to 1:&lt;/p&gt;&#xA;&lt;p&gt;cplex.setParam(IloCplex::Param::Preprocessing::Reduce, 1);&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Symmetry to 0.&lt;/p&gt;&#xA;&lt;p&gt;cplex.setParam(IloCplex::Param::Preprocessing::Symmetry, 0);&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;and again, the same behavior is presented. It seems that the MIP start is not accepting the provided solution. But I do not know why. I would like to know if anyone already experienced this. For more information, I am using the programming language C++ with Cplex studio 12.10 and Concert technology.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 1:&lt;/strong&gt; The approached optimization problem is a variant of the VRP, and the MILP formulation is very similar to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Vehicle_routing_problem#Vehicle_flow_formulations&quot; rel=&quot;nofollow noreferrer&quot;&gt;VRP Vehicle flow formulation&lt;/a&gt;. And regarding the feasible solution, it is composed of one customer per route.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="491" LastEditDate="2022-10-12T21:05:59.670" LastActivityDate="2022-10-12T21:06:18.863" Title="No solution found from n MIP starts" Tags="|mixed-integer-programming|cplex|c++|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3531" PostTypeId="1" AcceptedAnswerId="3532" CreationDate="2020-02-11T13:00:49.850" Score="6" ViewCount="812" Body="&lt;p&gt;I have already seen in the &lt;a href=&quot;https://docs.python-mip.com/en/latest/examples.html&quot; rel=&quot;noreferrer&quot;&gt;Python-MIP&lt;/a&gt; documentation on how to implement a variable with multiple indices. &#xA;In each example I read, this is done with the use of &lt;strong&gt;lists&lt;/strong&gt; and &lt;strong&gt;integers&lt;/strong&gt; as indices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how I implement a variable that I needed in the beginning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = [[[model.add_var(name='x({},{},{})'.format(e,s,a),var_type=INTEGER,ub = employeeDict[e].mitarbeiter_ist_formen)&#xA;   for e in employeeDict] for s in demandBelongingToShiftDict] for a in demandAppendedWithShiftDict]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But got the following error: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TypeError: list indices must be integers or slices, not str&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the index &lt;strong&gt;a&lt;/strong&gt; is a string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I know that in Python is impossible to search within a list with strings as indices. &#xA;This is why I would like to use &lt;strong&gt;dictionaries&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = {{{model.add_var(name='x({},{},{})'.format(e,s,a),var_type=INTEGER,ub = employeeDict[e].mitarbeiter_ist_formen)&#xA;   for e in employeeDict} for s in demandBelongingToShiftDict} for a in demandAppendedWithShiftDict}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I am getting the following error: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;TypeError: unhashable type: 'set'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="456" LastEditorUserId="491" LastEditDate="2020-02-11T17:39:41.093" LastActivityDate="2020-02-11T17:39:41.093" Title="Creating a Decision Variable in Python-MIP with Dictionaries" Tags="|mixed-integer-programming|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3532" PostTypeId="2" ParentId="3531" CreationDate="2020-02-11T13:06:20.940" Score="5" Body="&lt;p&gt;Haven't used python-mip but to create multi-index variables I usually do:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;x = {&#xA;    (e, s, a): model.add_var(&#xA;        name=&quot;x({},{},{})&quot;.format(e, s, a),&#xA;        var_type=INTEGER,&#xA;        ub=employeeDict[e].mitarbeiter_ist_formen,&#xA;    )&#xA;    for e in employeeDict&#xA;    for s in demandBelongingToShiftDict&#xA;    for a in demandAppendedWithShiftDict&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and access it by &lt;code&gt;x[e, s, a]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are doing &lt;code&gt;set&lt;/code&gt; instead of &lt;code&gt;dict&lt;/code&gt; comprehensions because you are not creating key-value pairs.&lt;/p&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2020-02-11T13:12:42.323" LastActivityDate="2020-02-11T13:12:42.323" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3533" PostTypeId="2" ParentId="3527" CreationDate="2020-02-11T13:16:31.447" Score="6" Body="&lt;p&gt;The square root terms are two-norms and the rest of the problem is linear. Therefore, this can be solved by a solver capable of handling Second Order Cone Problems (SOCP).  Among such solvers are CPLEX, Gurobi, Mosek, SeDuMi, SDPT3, and KNITRO, among others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem is convex, and can be solved with such solvers to global optimality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem can be expressed as a SOCP by using an epigraph formulation of norm. That is, replace the norm terms by &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt;, and introduce constraints, &lt;span class=&quot;math-container&quot;&gt;$\text{norm}(...) \le t_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a convex optimization modeling tool such as CVX, YALMIP, CVXPY, or CVXR is used, this reformulation can be handled automatically (under the hood) by the tool.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In CVX, the formulation would look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin&#xA;variables x(n) y(n,m)&#xA;minimize(a'*x + b'*norms(y - repmat(x,1,m)),2,2)&#xA;&amp;lt;incorporation of linear constraints left as straightforward exercise&amp;gt;&#xA;cvx_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;making use of &lt;code&gt;norms&lt;/code&gt;, which is a CVX function which computes a vector of norms at once from a matrix and produces a vector output. But this can be done using loops using plain old &lt;code&gt;norm&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;help norms &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;norms   Computation of multiple vector norms.&#xA;      norms( X ) provides a means to compute the norms of multiple vectors&#xA;      packed into a matrix or N-D array. This is useful for performing&#xA;      max-of-norms or sum-of-norms calculations.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;All of the vector norms, including the false &quot;-inf&quot; norm, supported&#xA;by NORM() have been implemented in the norms() command.&#xA;  norms(X,P)           = sum(abs(X).^P).^(1/P)&#xA;  norms(X)             = norms(X,2).&#xA;  norms(X,inf)         = max(abs(X)).&#xA;  norms(X,-inf)        = min(abs(X)).&#xA;If X is a vector, these computations are completely identical to&#xA;their NORM equivalents. If X is a matrix, a row vector is returned&#xA;of the norms of each column of X. If X is an N-D matrix, the norms&#xA;are computed along the first non-singleton dimension.&#xA;&#xA;norms( X, [], DIM ) or norms( X, 2, DIM ) computes Euclidean norms&#xA;along the dimension DIM. norms( X, P, DIM ) computes its norms&#xA;along the dimension DIM.&#xA;&#xA;Disciplined convex programming information:&#xA;    norms is convex, except when P&amp;lt;1, so an error will result if these&#xA;    non-convex &quot;norms&quot; are used within CVX expressions. norms is&#xA;    nonmonotonic, so its input must be affine.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-02-11T13:16:31.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3534" PostTypeId="2" ParentId="3507" CreationDate="2020-02-11T13:45:14.727" Score="1" Body="&lt;p&gt;I think I have answered my own question over the last day. I found that fixing non-basic variable with non-zero reduced was enough to keep the optimal value of higher priority goals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I was not getting the solution to retain the higher priority goal's optimality was due to a different reason. I have been using a tolerance to limit the upper bound on non-basic variables with non-zero reduced costs. The reason I was doing this was the math model that I was optimizing is highly ill-conditioned. If I did a simple column-dropping approach, I would have created an infeasibility in the models that I would optimize for left over goals. When i reduced the tolerance from current value to a lower value to bring behavior closer to column- dropping the optimum of previous objective is preserved.&lt;/p&gt;&#xA;" OwnerUserId="2748" LastActivityDate="2020-02-11T13:45:14.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3535" PostTypeId="2" ParentId="3526" CreationDate="2020-02-11T21:53:26.457" Score="3" Body="&lt;p&gt;I'm going to assume that the inequality in the second formulation is weak (&lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt;), and that &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is fixed. In terms of &quot;equivalence&quot;, it is correct to say that the two formulations have the same solution when &lt;span class=&quot;math-container&quot;&gt;$t=\sum_{j=1}^p \overline{\beta}^2$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\overline{\beta}$&lt;/span&gt; is the optimal solution to the first formulation. That observation is rather trivial: if &lt;span class=&quot;math-container&quot;&gt;$\overline{\beta}$&lt;/span&gt; is not optimal in the second formulation with that choice of &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, then there exists a different &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; that produces smaller values of both terms in the first objective function, contradicting optimality of &lt;span class=&quot;math-container&quot;&gt;$\overline{\beta}$&lt;/span&gt; there.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-02-11T21:53:26.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3536" PostTypeId="2" ParentId="3530" CreationDate="2020-02-12T01:24:17.620" Score="3" Body="&lt;p&gt;Assuming that your solution is indeed feasible and that your lazy constraints are correctly coded, the most likely explanation is that the order of your variables is inconsistent between your heuristic and CPLEX's input.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-02-12T01:24:17.620" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3537" PostTypeId="1" CreationDate="2020-02-12T03:33:48.767" Score="7" ViewCount="84" Body="&lt;p&gt;I recently have come across a problem which can be categorized as a stochastic optimization. The problem seems simple, but I haven't been able to solve it yet. It has a major impact on algorithm design for real business problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume that there is a retailer who faces a stationary/stochastic demand with a known discrete distribution. Let &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; denote the fixed cost of ordering, and &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; denote the holding and back-order cost of the retailer respectively. It can be shown that the optimal solution for this problem over an infinite horizon follows &lt;span class=&quot;math-container&quot;&gt;$(s, S)$&lt;/span&gt; policy in which whenever the inventory level of the retailer falls below &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, it brings it back to &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; by setting an order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I like to know here is, if there is any upper-bound for the value of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; (based on &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extension: The problem has two stages, and in the upper stage, there is a supplier who has to respond to the orders. Assuming &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;s, &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt;s and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;s as the setup cost of the supplier, holding and back-order costs of the supplier, and the problem is solved in an integrated manner, what is the bound for the &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2481" LastEditorUserId="38" LastEditDate="2020-02-12T13:37:51.880" LastActivityDate="2020-02-12T15:18:29.557" Title="An upper-bound on the value of $S$ in $(s,S)$ policy" Tags="|inventory|bounds|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3538" PostTypeId="2" ParentId="3530" CreationDate="2020-02-12T06:13:34.477" Score="2" Body="&lt;p&gt;Have you tried to disable all the presolve?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't remember which version it stoped, but in some early 12. versions of cplex there was a bug that did not disable some presolve function that allowed the solver to remove some constraints/variables it found unnecessary. Sometimes this could lead to infeasibility, or suboptimal solutions.&lt;/p&gt;&#xA;" OwnerUserId="2397" LastActivityDate="2020-02-12T06:13:34.477" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3539" PostTypeId="1" CreationDate="2020-02-12T08:32:03.943" Score="5" ViewCount="164" Body="&lt;p&gt;I have a following problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have some function &lt;span class=&quot;math-container&quot;&gt;$aX+bY+cZ+mD+nF$&lt;/span&gt; and I want to maximize it and have some constraints, how can I find ALL solutions for this maximum value of the function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum up: I have a function value (e.g. &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt;) and I have one optimal solution (&lt;span class=&quot;math-container&quot;&gt;$a,b,c,m,n$&lt;/span&gt; - in my case calculated by Excel solver) but I need the rest of the combination of coefficients that results in the function value (&lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I calculate that somehow?&lt;/p&gt;&#xA;" OwnerUserId="3063" LastEditorUserId="123" LastEditDate="2020-02-12T09:12:06.527" LastActivityDate="2020-02-12T09:12:06.527" Title="All optimal solutions" Tags="|solver|simplex|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3540" PostTypeId="2" ParentId="3537" CreationDate="2020-02-12T13:37:30.353" Score="3" Body="&lt;p&gt;There is (sort of) such a bound. &lt;a href=&quot;https://doi.org/10.1287/opre.39.4.654&quot; rel=&quot;nofollow noreferrer&quot;&gt;Zheng and Federgruen (1991)&lt;/a&gt; prove that for a single-node system with discrete demands and fixed costs,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$S^* \le \max\{y \ge y^*|g(y) \le g^*\},$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$g(y)$&lt;/span&gt; is the (discrete) newsvendor cost function, &lt;span class=&quot;math-container&quot;&gt;$y^*$&lt;/span&gt; is its optimizer, &lt;span class=&quot;math-container&quot;&gt;$g^* = g(s^*,S^*)$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$g(s,S)$&lt;/span&gt; is the expected cost function for the &lt;span class=&quot;math-container&quot;&gt;$(s,S)$&lt;/span&gt; problem. In other words, &lt;span class=&quot;math-container&quot;&gt;$S^*$&lt;/span&gt; cannot be larger than the largest &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$g(y) \le g^*$&lt;/span&gt;. This is not necessarily a useful bound because it requires knowledge of the optimal solution—it is not simply in terms of the policy parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, Zheng and Federgruen present this result in the context of a pretty simple algorithm for optimizing &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, which may be sufficient for your needs. (We also cover this in &lt;a href=&quot;http://coral.ise.lehigh.edu/sctheory/&quot; rel=&quot;nofollow noreferrer&quot;&gt;our book&lt;/a&gt;, if that helps.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the two-node problem: If you simply optimize the retailer first, then optimize the supplier, you can probably get a probability distribution for the order quantities placed by the retailer, and then optimize the supplier the same way you optimized the retailer (i.e., &lt;span class=&quot;math-container&quot;&gt;$(s,S)$&lt;/span&gt; policy with discrete demands). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are hoping to optimize them jointly, then the problem is harder. One paper I know of is by &lt;a href=&quot;https://doi.org/10.1287/opre.1090.0734&quot; rel=&quot;nofollow noreferrer&quot;&gt;Shang and Zhou (2010)&lt;/a&gt;; this isn't exactly the setup you're describing, but it might be a starting point.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;UPDATE: Actually, I think it should be possible to show that &lt;span class=&quot;math-container&quot;&gt;$S^*$&lt;/span&gt; is less than or equal to the largest &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; such that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$g(y) \le g(y^*) + K,$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$g(\cdot)$&lt;/span&gt; is the newsvendor cost function. I can't quite work out the details at the moment, but if this seems like a promising approach to you, I can try to work it out, or point you to the sections in our book that might contain the pieces you'd have to assemble to prove it.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2020-02-12T15:18:29.557" LastActivityDate="2020-02-12T15:18:29.557" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3541" PostTypeId="1" AcceptedAnswerId="3549" CreationDate="2020-02-12T15:46:30.797" Score="3" ViewCount="474" Body="&lt;p&gt;I am solving an LP by using GUROBI - C++ combo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume I have a variable &lt;span class=&quot;math-container&quot;&gt;$p \in \mathbb{R}^n$&lt;/span&gt;. I am adding this as a vector:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GRBEnv* env;&#xA;GRBModel* model;&#xA;vector&amp;lt;GRBVar&amp;gt; p;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I have &lt;span class=&quot;math-container&quot;&gt;$a\in\mathbb{R}^n$&lt;/span&gt; parameters, and I want to add a constraint &lt;span class=&quot;math-container&quot;&gt;$a^\top p\ \leq 0$&lt;/span&gt;, so I say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GRBLinExpr sum_expo = 0;&#xA;for (int i = 0; i &amp;lt; p.size(); i++) {// add all the coeffs given&#xA;                        sum_expo += a[i] * p[i];&#xA;}&#xA;model-&amp;gt;addConstr(sum_expo &amp;lt;= 0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, this is too inefficient. Is there a way that I can:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Define the whole &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; vector as a multivariate GRBVar, rather than having a vector with all GRBVar values&lt;/li&gt;&#xA;&lt;li&gt;Add a constraint &lt;span class=&quot;math-container&quot;&gt;$a^\top p \leq 0$&lt;/span&gt; in a single line.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="65" LastActivityDate="2020-02-17T08:29:36.637" Title="Gurobi C++: adding variables with vector" Tags="|linear-programming|gurobi|c++|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3542" PostTypeId="1" CreationDate="2020-02-12T17:29:43.433" Score="7" ViewCount="2825" Body="&lt;p&gt;I've read that in the context of the Shortest Path Problem, the use of the term &quot;relaxation&quot; (&quot;relaxing edges&quot;)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[...][the use of the term &quot;relaxation&quot;] is historical. The outcome of a relaxation step can be viewed as a relaxation&#xA;  of the constraint &lt;span class=&quot;math-container&quot;&gt;$d[v] \le d[u] + w(u, v)$&lt;/span&gt;, [...]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, I looked for the general meaning of &quot;constraint relaxation&quot; and found some examples, such as &lt;a href=&quot;https://en.wikipedia.org/wiki/Lagrangian_relaxation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lagrangian relaxation&lt;/a&gt;, but i do not see how Lagrangian relaxation would be relevant to relaxing a single constraint &lt;span class=&quot;math-container&quot;&gt;$x_j\le x_i + w_{i,j}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lagrangian relaxation and such modify the problem (making the constraints more &quot;relaxed&quot; in the process), but the relaxation used in the Shortest Path algorithms modifies a tentative solution and does not seem to modify the problem...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the general meaning of the &quot;relaxation&quot; used in the Shortest Path Problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be clear, I am asking about the relaxation step described, for example, on pages 276-277 of &lt;a href=&quot;http://jeffe.cs.illinois.edu/teaching/algorithms/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Algorithms&lt;/em&gt;&lt;/a&gt; by Jeff Erickson, Chapter 8. Here it is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Relax(u, v):&#xA;    d[v] &amp;lt;- d[u] + w(u, v)&#xA;    p[v] &amp;lt;- u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Links:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://jeffe.cs.illinois.edu/teaching/algorithms/book/08-sssp.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Shortest Paths&lt;/em&gt; chapter&lt;/a&gt; from &lt;a href=&quot;http://jeffe.cs.illinois.edu/teaching/algorithms/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Algorithms&lt;/em&gt;&lt;/a&gt;&#xA;by Jeff Erickson.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://towardsdatascience.com/algorithm-shortest-paths-1d8fa3f50769&quot; rel=&quot;nofollow noreferrer&quot;&gt;Some blog post where the term is explained.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-introduction-to-algorithms-sma-5503-fall-2005/video-lectures/lecture-18-shortest-paths-ii-bellman-ford-linear-programming-difference-constraints/lec18.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Some slides where the term is used.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3064" LastEditorUserId="3064" LastEditDate="2020-02-13T15:39:29.847" LastActivityDate="2020-02-13T18:09:03.283" Title="The general meaning of &quot;constraint relaxation&quot; in the context of the Shortest Path Problem" Tags="|constraint|algorithms|graphs|dynamic-programming|relaxation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3544" PostTypeId="1" CreationDate="2020-02-12T17:49:26.237" Score="11" ViewCount="1247" Body="&lt;p&gt;I had a linear programming problem with the following objective function&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f(x) = \sum_{j}x_jq_jp_j - \sum_{i}\left(\sum_{j}x_jq_jC_{ij} \right) c_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$q, p, C, c$&lt;/span&gt; are known.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem was easily solvable using linear programming, because it is completely linear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I now have a modified version of the objective function, where I want the last parameter &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; to vary based on the value of the summation &lt;span class=&quot;math-container&quot;&gt;$\sum_{k}x_kq_kC_{ik}$&lt;/span&gt;, which we will now call &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt;, that comes before it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More specifically, I have three &quot;buckets&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$c_i = \begin{cases}&#xA;        10 &amp;amp; \text{for } 0\leq A_i\leq 100\\&#xA;        8 &amp;amp; \text{for } 101\leq A_i\leq 200\\&#xA;        6 &amp;amp; \text{for } A_i \geq 201&#xA;        \end{cases}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I incorporate this into my objective function? My instinct tells me to somehow create three auxiliary variables which function as &quot;switching&quot; parameters for each of the buckets and are either 1 or 0. Since the value of &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; has to lie in one of the buckets, one of these weights will be 1 and the others will be 0. I then sum over the weighting parameter times the bucket value (10/8/6) and I will get the proper result. &#xA;Is something like this possible?&lt;/p&gt;&#xA;" OwnerUserId="3065" LastEditorUserId="3065" LastEditDate="2020-05-12T20:01:15.417" LastActivityDate="2020-12-21T18:55:20.127" Title="Linear programming: objective function with &quot;buckets&quot;" Tags="|optimization|linear-programming|modeling|linearization|big-m|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3545" PostTypeId="2" ParentId="3542" CreationDate="2020-02-12T18:06:22.407" Score="4" Body="&lt;p&gt;To my knowledge, the term &lt;em&gt;relaxation&lt;/em&gt; is used to indicate that a constraint (or a group of constraints) is removed from the model, rendering a model that is more loose, less constrained. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the context of &lt;em&gt;Lagrangian relaxation&lt;/em&gt;, a constraint (or group of constraints) is removed from the model, and added to the objective function with a coefficient (or more precisely, the right hand term minus the left hand term). The idea is that if this additional term has value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; in the objective function, the constraint is satisfied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The term &lt;em&gt;linear relaxation&lt;/em&gt; is also very common. It appears when integrity constraints are removed from the model (variables that have to be discrete can be continuous). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the shortest path problem, it is the same : one of the constraint that models the shortest path is removed, in some sense. You can model the shortest path problem from &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; in a graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; as follows : &#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \; d_v&#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;d_j &amp;amp;\le d_i + c_{ij} \quad \forall (i,j) \in E \\&#xA;d_u &amp;amp;= 0  &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In essence, the shortest path from &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_v$&lt;/span&gt;, is the largest value that minimizes &lt;span class=&quot;math-container&quot;&gt;$d_i+c_{iv}$&lt;/span&gt; for all predecessors &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;. The constraint &lt;span class=&quot;math-container&quot;&gt;$d_j \le d_i +c_{ij}$&lt;/span&gt; is only active when &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; is the shortest path length to node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. When it is not the case, the constraint is inactive and you can relax it from the model. This is what is done dynamically (and not through linear programming) in the slides of the link you have posted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a nice physical interpretation of this. Imagine you have some sort of web with extremities &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;. If you stretch &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; as much as possible, the tightest string from &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is the shortest path from &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;. All other strings from &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; are loose or wavy, hence the term &quot;relaxed.&quot; This is illustrated in the image below (from &lt;a href=&quot;https://en.wikipedia.org/wiki/Dynamic_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;) : &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Finding the shortest path in a graph using optimal substructure; a&#xA;  straight line indicates a single edge; a wavy line indicates a&#xA;  shortest path between the two vertices it connects (among other paths,&#xA;  not shown, sharing the same two vertices); the bold line is the&#xA;  overall shortest path from start to goal.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4Sema.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4Sema.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this particular graph, if nodes are named &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; from top to bottom, the above linear formulation yields :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \; d_{goal}&#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;d_a &amp;amp;\le d_{start}+5 \\&#xA;d_b &amp;amp;\le d_{start}+2 \\&#xA;d_c &amp;amp;\le d_{start}+11 \\&#xA;d_{goal} &amp;amp;\le d_a + 20 \\&#xA;d_{goal} &amp;amp;\le d_b + 25 \\&#xA;d_{goal} &amp;amp;\le d_c + 17 \\&#xA;d_{start} &amp;amp;= 0  \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which can easily be simplified to &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;d_a &amp;amp;\le 5 \\&#xA;d_b &amp;amp;\le 2 \\&#xA;d_c &amp;amp;\le 11 \\&#xA;d_{goal} &amp;amp;\le d_a + 20 \\&#xA;d_{goal} &amp;amp;\le d_b + 25 \\&#xA;d_{goal} &amp;amp;\le d_c + 17 &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is easy to see that the last two constraints could be removed from the model : they can be &lt;em&gt;relaxed&lt;/em&gt;. Physically, if you stretch the graph from &lt;span class=&quot;math-container&quot;&gt;$start$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$goal$&lt;/span&gt;, edges &lt;span class=&quot;math-container&quot;&gt;$(b,goal)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(c,goal)$&lt;/span&gt; end up wavy/loose/&quot;relaxed&quot;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-02-13T13:04:27.940" LastActivityDate="2020-02-13T13:04:27.940" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="3546" PostTypeId="2" ParentId="3544" CreationDate="2020-02-12T18:28:57.653" Score="8" Body="&lt;p&gt;You can add the following equations to your model :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, define your variable &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;A_i = \sum_{k}x_k C_{ik}q_k \quad \forall i&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, define binary variables &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; that take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; iff &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; is in interval &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (where interval &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$[0,100]$&lt;/span&gt;, interval &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$[101,200]$&lt;/span&gt;, and interval &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$[201, \infty[$&lt;/span&gt; :&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0 &amp;amp;\le A_i \le 100 + M (1-y_{i1}) \\&#xA;101y_{i2} &amp;amp;\le A_i \le 200 + M (1-y_{i2}) \\&#xA;201y_{i3} &amp;amp;\le A_i&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Impose that you can only be on one of the intervals :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_{i1} + y_{i2} +y_{i3} = 1\quad \forall i&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally, add the following term to your objective function :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i}(10A_iy_{i1} +8A_iy_{i2} + 6A_iy_{i3})&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this last term is not linear, so you need to linearize it : replace &lt;span class=&quot;math-container&quot;&gt;$A_i y_{ij}$&lt;/span&gt; by a variable &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; and add the following constraint :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z_{ij} \ge A_i - M(1-y_{ij})&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-02-12T20:51:15.440" LastActivityDate="2020-02-12T20:51:15.440" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3547" PostTypeId="2" ParentId="3544" CreationDate="2020-02-12T18:38:48.710" Score="11" Body="&lt;h3&gt;1. Your suggested approach : quadratic program&lt;/h3&gt;&#xA;&lt;p&gt;Here are the details of your suggested approach. It results in a quadratic objective.&lt;/p&gt;&#xA;&lt;p&gt;Let binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,b}$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; is in bucket &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$b\in\{1,2,3\}$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; be a (small) upper bound on &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The constraints are:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{b=1}^3 y_{i,b} &amp;amp;= 1\\&#xA;10 y_{i,1} + 8 y_{i,2} + 6 y_{i,3} &amp;amp;= c_i\\&#xA;0 y_{i,1} + 101 y_{i,2} + 201 y_{i,3} \le A_i &amp;amp;\le 100 y_{i,1} + 200 y_{i,2} + M_i y_{i,3}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The resulting model then has a &lt;strong&gt;quadratic function&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$\sum_i A_i c_i$&lt;/span&gt; in the objective.&lt;/p&gt;&#xA;&lt;h3&gt;2. Alternative : linear program&lt;/h3&gt;&#xA;&lt;p&gt;You can instead get a linear objective by introducing a variable &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$A_i c_i$&lt;/span&gt;, with constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{b=1}^3 y_{i,b} &amp;amp;= 1\\&#xA;0 y_{i,1} + 101 y_{i,2} + 201 y_{i,3} \le A_i &amp;amp;\le 100 y_{i,1} + 200 y_{i,2} + M_i y_{i,3}\\&#xA;-M_{i,1}(1-y_{i,1}) \le z_i - 10 A_i &amp;amp;\le M_{i,1}(1-y_{i,1})\\&#xA;-M_{i,2}(1-y_{i,2}) \le z_i - 8 A_i &amp;amp;\le M_{i,2}(1-y_{i,2})\\&#xA;-M_{i,3}(1-y_{i,3}) \le z_i - 6 A_i &amp;amp;\le M_{i,3}(1-y_{i,3})\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The resulting model then has only a &lt;strong&gt;linear function&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$\sum_i z_i$&lt;/span&gt; in the objective.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="2616" LastEditDate="2020-12-21T18:55:20.127" LastActivityDate="2020-12-21T18:55:20.127" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3548" PostTypeId="2" ParentId="3542" CreationDate="2020-02-13T18:09:03.283" Score="2" Body="&lt;p&gt;In optimisation theory, creating a relaxation refers to an operation which: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Creates a superset of an underlying set, if the operation is done on a set&lt;/li&gt;&#xA;&lt;li&gt;Produces a new set of functions that define a superset of a set associated with some original function (usually the feasible region).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For instance, if I have a nonconvex function/set, I can create a &lt;em&gt;convex relaxation&lt;/em&gt; of that function/set:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1mK5N.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1mK5N.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming that the set of interest is a feasible region, the usual way to modify the feasible region defined by a constraint is to modify the constraint itself in some way, either by replacing it with a set of different constraints, or by changing that constraint's functional form.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, a convex (and linear) relaxation of &lt;span class=&quot;math-container&quot;&gt;$-x^2\leq 0$&lt;/span&gt; is the secant of &lt;span class=&quot;math-container&quot;&gt;$-x^2$&lt;/span&gt; between the lower and upper bounds of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Furthermore, said secant (along with the original constraint) defines the &lt;em&gt;convex hull&lt;/em&gt; of that set, because that's the tightest possible superset we can produce for that feasible region that is still convex.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-02-13T18:09:03.283" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3549" PostTypeId="2" ParentId="3541" CreationDate="2020-02-14T07:59:43.930" Score="5" Body="&lt;p&gt;You can use &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/cpp_lex_addterms.html#cppmethod:GRBLinExpr::addTerms&quot; rel=&quot;nofollow noreferrer&quot;&gt;addTerms()&lt;/a&gt; to construct a linear expression in one call. According to the &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/cpp_lex.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; this is the most efficient way:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;You should avoid using expr = expr + x in a loop. It will lead to runtimes that are quadratic in the number of terms in the expression.&lt;/li&gt;&#xA;  &lt;li&gt;Using expr += x (or expr -= x) is much more efficient than expr = expr + x. Building a large expression by looping over += statements is reasonably efficient, but it isn't the most efficient approach.&lt;/li&gt;&#xA;  &lt;li&gt;The most efficient way to build a large expression is to make a single call to addTerms.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Concerning adding multiple constraints in one call (&lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/cpp_model_addconstrs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation about addConstrs&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;We recommend that you build your model one constraint at a time (using addConstr), since it introduces no significant overhead and we find that it produces simpler code. Feel free to use these methods if you disagree, though. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="141" LastEditorUserId="141" LastEditDate="2020-02-17T08:29:36.637" LastActivityDate="2020-02-17T08:29:36.637" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3550" PostTypeId="1" AcceptedAnswerId="3694" CreationDate="2020-02-14T10:49:22.800" Score="8" ViewCount="233" Body="&lt;p&gt;I was given the task to model the following problem and find a solution for it, but as I do not have any experience in this field, I already have trouble classifying it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a &lt;strong&gt;number of vehicles&lt;/strong&gt; and a (possibly much greater) &lt;strong&gt;number of transportation-tasks&lt;/strong&gt; that should be assigned to the vehicles.&lt;br&gt;&#xA;One task consists of fetching a good from one station and bringing it to another station, while there are &lt;strong&gt;multiple stations&lt;/strong&gt;, each of which can act as both a start- or an endpoint.&lt;br&gt;&#xA;There are &lt;strong&gt;different kinds of transportation tasks&lt;/strong&gt; and &lt;strong&gt;not every vehicle can do every kind of task&lt;/strong&gt;.&lt;br&gt;&#xA;Also, the &lt;strong&gt;arcs/edges&lt;/strong&gt; between the stations have a &lt;strong&gt;capacity of 1&lt;/strong&gt;, meaning that one vehicle occupies it for a specific amount of time.&lt;br&gt;&#xA;At the stations, there also is a waiting time, meaning that maybe a queue of waiting vehicles arises (let's assume the queue can have infinite length).&lt;br&gt;&#xA;One vehicle can only do &lt;strong&gt;one task at a time&lt;/strong&gt;, but can put succeeding tasks in a queue.&lt;br&gt;&#xA;And, last but not least, &lt;strong&gt;new tasks are being generated continuously&lt;/strong&gt;, so the algorithm has to work &lt;strong&gt;&quot;on-line&quot;&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The objective is to minimize the time it takes to complete all tasks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I have read so far, this could be a &lt;strong&gt;job shop scheduling problem with sequence-dependent setup time&lt;/strong&gt;, as there are multiple &quot;machines&quot; (the stations doing the on- and offloading &quot;job&quot;) and what is actually the task in real life (the transportation of the goods), could be modeled as a setup time for the job, which is dependent from the preceding task, because the end-position of the preceding task determines the time the vehicle needs to get to the new start-position.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is that correct?&lt;/li&gt;&#xA;&lt;li&gt;How do I model such a system to find a good enough solution? &lt;/li&gt;&#xA;&lt;li&gt;For the future, are there ways how I can differentiate between different problem-classes? I have the feeling that Linear Optimization, Assignment, Scheduling, Network Flows, Routing, etc. are quite similar and with some adjustments could all somehow fit the problem...&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3071" LastEditorUserId="36" LastEditDate="2020-02-14T13:59:04.637" LastActivityDate="2020-03-13T04:28:02.427" Title="How to classify and model this problem?" Tags="|optimization|modeling|scheduling|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3551" PostTypeId="2" ParentId="3530" CreationDate="2020-02-14T11:46:04.543" Score="4" Body="&lt;p&gt;After hours of internet research and coding debugging, I could finally solve the problem. The problem was on the way that I passed the solution to the Cplex MIP Start. Below follows an example of how I was passing the solution to the Cplex MIP Start, where &lt;code&gt;x_var&lt;/code&gt; is a matrix of variables, &lt;code&gt;x_start_val&lt;/code&gt; is a matrix of values, and &lt;code&gt;cplex&lt;/code&gt; is an object of class &lt;code&gt;IloCplex&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; m; ++i)&#xA;    for (int j = 0; j &amp;lt; n; ++j) &#xA;        cplex.addMIPStart(x_var[i][j], x_start_val[i][j]);&#xA;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, after carefully reading the documentation of the function &lt;code&gt;addMIPStart&lt;/code&gt; from the class &lt;code&gt;IloCplex&lt;/code&gt; in this &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.cplex.help/refcppcplex/html/classes/IloCplex.html#method_addMIPStart&quot; rel=&quot;nofollow noreferrer&quot;&gt;IBM Support Webpage&lt;/a&gt;. I found the following information:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;There is no method to create a MIP start from a multidimensional array&#xA;of variables. In order to create a MIP start from a multidimensional&#xA;array of variables, you first must copy all those variables into a&#xA;flat array.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Therefore, to pass the solution in &lt;code&gt;x_start_val&lt;/code&gt; to the MIP Start, I would need to change the previous code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;IloNumVarArray startVar(env);&#xA;IloNumArray startVal(env);&#xA;for (int i = 0; i &amp;lt; m; ++i)&#xA;    for (int j = 0; j &amp;lt; n; ++j) {&#xA;             startVar.add(x_var[i][j]);&#xA;             startVal.add(x_start_val[i][j]);&#xA;    }&#xA;cplex.addMIPStart(startVar, startVal);&#xA;startVal.end();&#xA;startVar.end();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="491" LastEditDate="2022-10-12T21:06:18.863" LastActivityDate="2022-10-12T21:06:18.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3554" PostTypeId="2" ParentId="3349" CreationDate="2020-02-16T18:33:24.840" Score="5" Body="&lt;p&gt;&lt;strong&gt;It will be useful to distinguish the problem itself from  the algorithms and data structures needed to solve it.&lt;/strong&gt;  To that end I will begin with a brief mathematical analysis, in which I will use standard mathematical notation without further apology, because all definitions are readily available elsewhere.  Non-standard terms specially coined for this analysis will be introduced within quotation marks.  Next I discuss a data structure and algorithm for solving the problem with reasonable efficiency. Some remarks about the computational costs follow. This post ends with examples and executable code.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Analysis&lt;/h3&gt;&#xA;&lt;p&gt;The difference of two subsets &lt;span class=&quot;math-container&quot;&gt;$A,B$&lt;/span&gt; of a group &lt;span class=&quot;math-container&quot;&gt;$(G, +)$&lt;/span&gt; is the set of all possible pairwise differences,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$A - B = \{a-b\mid a\in A,\; b\in B\}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The difference set of any subset &lt;span class=&quot;math-container&quot;&gt;$A\subset G$&lt;/span&gt; is just&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\Delta(A) = A - A.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; acts on its subsets &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}(G)$&lt;/span&gt; &lt;em&gt;via&lt;/em&gt; translation; the translate of any &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; by an element &lt;span class=&quot;math-container&quot;&gt;$g\in G$&lt;/span&gt; is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$A + g = \{a+g\mid a\in A\}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Because &lt;span class=&quot;math-container&quot;&gt;$\Delta(A+g) = \Delta(A)$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$g\in G,$&lt;/span&gt; we may view &lt;span class=&quot;math-container&quot;&gt;$\Delta$&lt;/span&gt; as a function defined on the orbits &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}(G)/G,$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\Delta: \mathcal{P}(G)/G \to \mathcal{P}(G).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$X\subset G,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$[X]\in\mathcal{P}(G)/G$&lt;/span&gt; represents its orbit.&lt;/p&gt;&#xA;&lt;p&gt;The problem is to invert &lt;span class=&quot;math-container&quot;&gt;$\Delta;$&lt;/span&gt; that is,&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Given &lt;em&gt;nonempty&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$D \in \mathcal{P}(G),$&lt;/span&gt; find all orbits &lt;span class=&quot;math-container&quot;&gt;$[X]\in \mathcal{P}(G)/G$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$\Delta([X]) = D.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In what follows I will focus on the case &lt;span class=&quot;math-container&quot;&gt;$G=(\mathbb{Z},+),$&lt;/span&gt; the integers with their usual addition, but little would need to change to apply the solution to other commutative groups (of which the additive real numbers and multiplicative complex numbers are likely to have interesting applications.)&lt;/p&gt;&#xA;&lt;h3&gt;An Abstract Algorithm&lt;/h3&gt;&#xA;&lt;p&gt;Throughout this section &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is fixed and all definitions are relative to &lt;span class=&quot;math-container&quot;&gt;$D.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The proposed approach builds solutions incrementally.&lt;/strong&gt;  To this end, pick once and for all a unique representative &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; for each orbit &lt;span class=&quot;math-container&quot;&gt;$[X].$&lt;/span&gt; (This is the &amp;quot;normalization&amp;quot; discussed in the question.)&lt;/p&gt;&#xA;&lt;p&gt;Let us say that &lt;span class=&quot;math-container&quot;&gt;$X^\prime$&lt;/span&gt; is a &amp;quot;partial solution&amp;quot; to the problem when &lt;span class=&quot;math-container&quot;&gt;$\Delta(X^\prime) \subset D.$&lt;/span&gt;  Solutions are partial solutions.&lt;/p&gt;&#xA;&lt;p&gt;In such a case, any &lt;span class=&quot;math-container&quot;&gt;$g\in G\setminus X^\prime$&lt;/span&gt; increases &lt;span class=&quot;math-container&quot;&gt;$X^\prime$&lt;/span&gt; to a larger partial solution, or &amp;quot;augments&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$X^\prime,$&lt;/span&gt; when including &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$X^\prime$&lt;/span&gt; still gives a partial solution.  I will call the set of all such &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; the &amp;quot;augmentors&amp;quot; of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and write it &lt;span class=&quot;math-container&quot;&gt;$\mathcal{A}_D(X).$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The import of augmentation is that &lt;em&gt;every solution can be generated as a sequence of augmentations of the empty set &lt;span class=&quot;math-container&quot;&gt;$\{\}.$&lt;/span&gt;&lt;/em&gt;  This is obvious, because if &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a solution it must be nonempty, whence there exists &lt;span class=&quot;math-container&quot;&gt;$g\in X$&lt;/span&gt; and clearly (a) &lt;span class=&quot;math-container&quot;&gt;$X^\prime=X\setminus\{g\}$&lt;/span&gt; is a partial solution and (b) &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; augments &lt;span class=&quot;math-container&quot;&gt;$X^\prime.$&lt;/span&gt;  Thus, by successively removing elements from a solution one by one, ultimately we must arrive at the empty set.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The foregoing defines a graph on the orbits &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}(G)/G.$&lt;/span&gt;&lt;/strong&gt;  Every orbit representative &lt;span class=&quot;math-container&quot;&gt;$X\subset G$&lt;/span&gt; has a (possibly empty) set of augmentors &lt;span class=&quot;math-container&quot;&gt;$\mathcal{A}_D(X).$&lt;/span&gt;  Each &lt;span class=&quot;math-container&quot;&gt;$g\in \mathcal{A}_D(X)$&lt;/span&gt; determines a directed edge from &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$X\cup \{g\}.$&lt;/span&gt;  Because the cardinality of the nodes increases by &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; along all such edges, there can be no cycles: this graph is a forest.  We may restrict our analysis to the connected component--a tree--rooted at the empty set.  &lt;em&gt;All partial solutions, and therefore all solutions, are nodes in this tree.&lt;/em&gt;  Therefore, the problem is seen to be one of finding all true solutions in this partial-solution tree.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;The obvious algorithm for finding all solutions is to traverse the tree.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;(Of course if you need only one solution you may stop the traversal upon encountering the first solution.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The traversal can be made more efficient&lt;/strong&gt; by remembering which candidates have been tried previously during the traversal.  This is readily done by sorting the augmentors and trying them in sort order in a depth-first traversal.  After exploring the partial solution &lt;span class=&quot;math-container&quot;&gt;$X^\prime$&lt;/span&gt; by following the edge determined by an augmentor &lt;span class=&quot;math-container&quot;&gt;$g,$&lt;/span&gt; we may eliminate &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; from the augmentors of all descendants of &lt;span class=&quot;math-container&quot;&gt;$X^\prime$&lt;/span&gt; when we continue the search to other children of &lt;span class=&quot;math-container&quot;&gt;$X^\prime.$&lt;/span&gt;  The augmentors of the descendants that haven't been eliminated in this fashion are &amp;quot;candidates&amp;quot; in the search for a solution.&lt;/p&gt;&#xA;&lt;p&gt;Thus, the traversal algorithm depends on the current node &lt;span class=&quot;math-container&quot;&gt;$X^\prime$&lt;/span&gt; and a set &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; of candidates for it. If &lt;span class=&quot;math-container&quot;&gt;$X^\prime$&lt;/span&gt; is a solution, output it.  To search the subtree rooted at &lt;span class=&quot;math-container&quot;&gt;$X^\prime$&lt;/span&gt;, for each candidate &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; recursively apply the algorithm to the node &lt;span class=&quot;math-container&quot;&gt;$X = X^\prime\cup\{g\}$&lt;/span&gt; and the candidate set &lt;span class=&quot;math-container&quot;&gt;$\mathcal{A}(X)\,\cap\, (C\setminus\{g\}).$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Data Structures&lt;/h3&gt;&#xA;&lt;p&gt;In searching for solutions it will be important to support various operations efficiently, including&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Representing sets, orbits, and partial solutions.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Comparing sets for equality.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Adjoining and removing elements from sets.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;As a matter of creating efficient data structures, notice&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The elements of &lt;span class=&quot;math-container&quot;&gt;$\Delta(X)$&lt;/span&gt; appear in pairs &lt;span class=&quot;math-container&quot;&gt;$\{a-b,b-a\}$&lt;/span&gt; and one of these pairs is always &lt;span class=&quot;math-container&quot;&gt;$\{0,0\}=\{0\}$&lt;/span&gt; provided &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is nonempty.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In an ordered group like &lt;span class=&quot;math-container&quot;&gt;$\mathbb Z,$&lt;/span&gt; the values &lt;span class=&quot;math-container&quot;&gt;$\pm(\max(X) - \min(X)) \in \Delta(X)$&lt;/span&gt; are the most extreme elements and therefore must agree with &lt;span class=&quot;math-container&quot;&gt;$\pm\max(D)$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$\Delta(X) = D.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Accordingly, the basis for a data structure will include an efficient representation of a set &lt;span class=&quot;math-container&quot;&gt;$\Delta(X)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$X\subset \mathbb{Z}$&lt;/span&gt; is nonempty.&lt;/p&gt;&#xA;&lt;p&gt;All the necessary information for solving this problem can be maintained in a data structure with the following elements (whose names reflect the origin of this problem in physical spectra, which represent differences between energy levels in a quantized system):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;Delta&lt;/code&gt;&lt;/strong&gt; represents the original putative difference set &lt;span class=&quot;math-container&quot;&gt;$D \subset \mathbb{Z}$&lt;/span&gt;. It need only include the positive elements of &lt;span class=&quot;math-container&quot;&gt;$D.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;Levels&lt;/code&gt;&lt;/strong&gt; represents a partial solution &lt;span class=&quot;math-container&quot;&gt;$X^\prime.$&lt;/span&gt;  It needn't begin with the empty set, because any solution must include &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;Spectrum&lt;/code&gt;&lt;/strong&gt; represents the difference set of &lt;code&gt;Levels&lt;/code&gt;, &lt;span class=&quot;math-container&quot;&gt;$D(X^\prime).$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;Candidates&lt;/code&gt;&lt;/strong&gt; represents the candidate set &lt;span class=&quot;math-container&quot;&gt;$C.$&lt;/span&gt;  It will need to be dynamically updated during the tree traversal.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&lt;p&gt;Consider &lt;span class=&quot;math-container&quot;&gt;$D = \{0,1,3,4,5,7,8,9\}.$&lt;/span&gt;  We may begin the search at &lt;span class=&quot;math-container&quot;&gt;$X^\prime = \{0,9\}$&lt;/span&gt; because &lt;span class=&quot;math-container&quot;&gt;$n=9$&lt;/span&gt; is the range of the differences &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; and I am normalizing the orbit representatives to begin at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; (rather than &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;).  The initial candidate set &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; consists of the augmentors of &lt;span class=&quot;math-container&quot;&gt;$X^\prime.$&lt;/span&gt;  These will be the integers &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; between &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$9$&lt;/span&gt; (exclusive) for which &lt;em&gt;both&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$g-0\in D$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$9-g\in D,$&lt;/span&gt; yielding &lt;span class=&quot;math-container&quot;&gt;$C = \{1,4,5,8\}.$&lt;/span&gt;  Thus the root node of the search tree is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$(X^\prime, C) = (\{0,9\},\ \{1,4,5,8\}).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the figure I have dropped the set braces and commas for brevity.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ik8F1.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ik8F1.png&quot; alt=&quot;Figure&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;This diagram of the (pruned) tree for &lt;span class=&quot;math-container&quot;&gt;$\{0,1,3,4,5,7,8,9\}$&lt;/span&gt; is rooted at the top.  The candidates &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; corresponding to the edges &lt;span class=&quot;math-container&quot;&gt;$(X^\prime;*)\to(X;*)$&lt;/span&gt; can be determined by comparing &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$X^\prime:$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is the new element in &lt;span class=&quot;math-container&quot;&gt;$X.$&lt;/span&gt;  Partial solution nodes are shown in blue and full solutions in orange.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;This is not the full tree:&lt;/strong&gt; it is the tree after it has been pruned during a depth-first, left-to-right search.  Thus, for instance, after initially searching the candidate &lt;span class=&quot;math-container&quot;&gt;$g=1$&lt;/span&gt; from the root in the leftmost branch, &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; was eliminated from the candidate lists in the subsequent branches from the root.&lt;/p&gt;&#xA;&lt;p&gt;The three solutions are, in the order found, &lt;span class=&quot;math-container&quot;&gt;$\{0,1,4,5,8,9\},$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\{0,1,4,8,9\},$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\{0,1,5,8,9\}.$&lt;/span&gt;  It is noteworthy that a larger solution was found before the shorter ones.  (This is not invariably the case, though.)&lt;/p&gt;&#xA;&lt;h3&gt;Computing Costs&lt;/h3&gt;&#xA;&lt;p&gt;&lt;strong&gt;Storage isn't a problem,&lt;/strong&gt; because the tree is constructed dynamically, at any stage of a depth-first search only a node and its ascendants are on the stack, and the depth cannot exceed &lt;span class=&quot;math-container&quot;&gt;$n-1.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Computational time is a problem.&lt;/strong&gt; When the tree is structured like the example, approximately &lt;span class=&quot;math-container&quot;&gt;$O(n^2)$&lt;/span&gt; edges need to be traversed.  But in other examples, such as &lt;span class=&quot;math-container&quot;&gt;$D=\{0,1,2,\ldots,n\},$&lt;/span&gt; the number of solutions grows exponentially with &lt;span class=&quot;math-container&quot;&gt;$n,$&lt;/span&gt; implying at least &lt;span class=&quot;math-container&quot;&gt;$O(\exp(n))$&lt;/span&gt; edges are traversed.  There is thus an unavoidably terrible worst-case computational cost.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Timing studies with random inputs suggest this problem can be efficiently solved when &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; has been generated from a set with approximately &lt;span class=&quot;math-container&quot;&gt;$\sqrt{n}$&lt;/span&gt; elements,&lt;/strong&gt; because then there tend to be only a small number of solutions.  Once the size of &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; reaches &lt;span class=&quot;math-container&quot;&gt;$1.5\sqrt{n},$&lt;/span&gt; the numbers of solutions explode exponentially and therefore so does the time taken to find them all.&lt;/p&gt;&#xA;&lt;h3&gt;Code&lt;/h3&gt;&#xA;&lt;p&gt;Because I have been using &lt;code&gt;R&lt;/code&gt; for most of my work for many years, I created a prototype in &lt;code&gt;R&lt;/code&gt; (despite its inherent inefficiencies).  The code is below.  As an example of its output, executing the commands&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;d &amp;lt;- c(1,6,7,8,12,13,14,15,19,20,21,26,27,33,34)&#xA;traverse(energy.new(d))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;produces the following output, normalized to match the start-at-1 normalization of the question:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1 2 8 9 15 16 22 28 35&#xA;1 2 8 9 16 22 28 35&#xA;1 2 8 15 16 22 28 35&#xA;1 2 8 16 22 28 35&#xA;1 2 9 15 16 22 28 35&#xA;1 2 9 16 22 28 35&#xA;1 8 14 20 21 27 28 34 35&#xA;1 8 14 20 21 27 34 35&#xA;1 8 14 20 21 28 34 35&#xA;1 8 14 20 27 28 34 35&#xA;1 8 14 20 27 34 35&#xA;1 8 14 20 28 34 35&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;These 12 solutions have from &lt;span class=&quot;math-container&quot;&gt;$7$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$9$&lt;/span&gt; elements each.  The shortest ones are the four given in the question.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;pre class=&quot;lang-R prettyprint-override&quot;&gt;&lt;code&gt;#&#xA;# (1) Create an &amp;quot;energy&amp;quot; object out of a putative difference set `x`.&#xA;#&#xA;energy.new &amp;lt;- function(x) {&#xA;  if (length(x) &amp;gt; 0) {&#xA;    #&#xA;    # Normalize the values.&#xA;    #&#xA;    x &amp;lt;- sort(unique(abs(x)))&#xA;    n &amp;lt;- setdiff(max(x), 0)&#xA;    if (x[1] == 0) x &amp;lt;- x[-1]&#xA;  } else {&#xA;    n &amp;lt;- integer(0)&#xA;  }&#xA;  Delta &amp;lt;- x&#xA;  Levels &amp;lt;- n    # Does not include 0&#xA;  Spectrum &amp;lt;- n  # Does not include 0&#xA;  Candidates &amp;lt;- Delta[(n - Delta) %in% Delta]&#xA;  obj &amp;lt;- list(Delta=Delta,&#xA;              Levels=Levels,&#xA;              Spectrum=Spectrum,&#xA;              Candidates=Candidates,&#xA;              Complete=isTRUE(all.equal(sort(Delta), sort(Spectrum))))&#xA;  class(obj) &amp;lt;- &amp;quot;energy&amp;quot;&#xA;  return(obj)&#xA;}&#xA;#&#xA;# (2) Traverse the tree.  Returns the number of solutions found.&#xA;#     Calls `emit` to output the solutions.&#xA;# Optional arguments allow some control over the traversal and the diagnostic output.&#xA;#&#xA;traverse &amp;lt;- function(e, stop.at.first=FALSE, shallow=FALSE, verbose=FALSE,&#xA;                     depth=0, offset=0) {&#xA;  n.solutions &amp;lt;- 0&#xA;  if(e$Complete &amp;amp;&amp;amp; isTRUE(stop.at.first)) return(n.solutions)&#xA;&#xA;  for(i in seq_along(e&lt;span class=&quot;math-container&quot;&gt;$Candidates)) {&#xA;    candidate &amp;lt;- e$Candidates[i]&#xA;    if(verbose) cat(rep(&quot;\t&quot;, depth+1),&#xA;                    paste0(&quot;(&quot;,paste(offset + c(0, sort(e$Levels)), collapse=&quot;,&quot;),&quot;)&quot;),&#xA;                    &quot;+&quot;, offset + candidate, &quot;\n&quot;)&#xA;    e.0 &amp;lt;- e&#xA;    e.0$Candidates &amp;lt;- e.0$Candidates[-seq_len(i)]&#xA;    e.0$Levels &amp;lt;- c(e.0$Levels, candidate)&#xA;    e.0$Spectrum &amp;lt;-  unique(c(e.0$Spectrum, candidate,&#xA;                              abs(candidate - e.0$Levels[e.0$Levels != candidate])))&#xA;    e.0$Candidates &amp;lt;- e.0$Candidates[abs(e.0$Candidates - candidate) %in% e.0$Delta]&#xA;    if(!isTRUE(e.0$Complete)) {&#xA;      e.0$Complete &amp;lt;- isTRUE(all.equal(sort(e.0$Delta), sort(e.0$Spectrum)))&#xA;    }&#xA;    if(isTRUE(e.0$Complete)) {&#xA;      emit(e.0)&#xA;      n.solutions &amp;lt;- n.solutions + 1&#xA;    }&#xA;    if(!e.0$Complete || !isTRUE(shallow)) {&#xA;      n.solutions &amp;lt;- n.solutions + traverse(e.0, stop.at.first, shallow, verbose,&#xA;                                            depth=depth+1, offset=offset)&#xA;    }&#xA;    if(n.solutions &amp;gt; 0 &amp;amp;&amp;amp; isTRUE(stop.at.first)) break&#xA;  }&#xA;  return(n.solutions)&#xA;}&#xA;#------------------------------------------------------------------------------#&#xA;#&#xA;# Helper functions.&#xA;#&#xA;spectrum &amp;lt;- function(levels) { # Compute the difference set, without zero.&#xA;  rev(sort(unique(abs(c(outer(c(0,levels), c(0,levels), `-`)))))[-1])&#xA;}&#xA;check &amp;lt;- function(e) {         # Verify a putative solution.&#xA;  isTRUE(all.equal(sort(e$Delta), sort(spectrum(e$Levels))))&#xA;}&#xA;emit &amp;lt;- function(e, offset=1) {# Output a solution.&#xA;  cat(paste(offset + c(0, sort(e$&lt;/span&gt;Levels))))&#xA;  if (check(e)) {&#xA;    cat(&amp;quot;\n&amp;quot;)&#xA;  } else {&#xA;    cat(&amp;quot; *** Invalid!\n&amp;quot;)&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="66" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-02-16T18:33:24.840" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3555" PostTypeId="2" ParentId="3349" CreationDate="2020-02-16T23:10:03.173" Score="3" Body="&lt;p&gt;I was able to generate the same four solutions using a MIP model (written in Java, solved with CPLEX 12.10). The solution time was about 35 ms. on a decent but not spectacular PC. My model uses &lt;span class=&quot;math-container&quot;&gt;$O(n)$&lt;/span&gt; binary variables and &lt;span class=&quot;math-container&quot;&gt;$O(n^2)$&lt;/span&gt; variables with domain &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the maximum difference, so it might not scale to problems with &quot;large&quot; differences.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-02-16T23:10:03.173" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3556" PostTypeId="1" AcceptedAnswerId="3657" CreationDate="2020-02-17T05:24:10.547" Score="6" ViewCount="249" Body="&lt;p&gt;What are the good text books to learn SQP? Are there any online courses that you can suggest?&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2020-02-17T07:58:37.193" LastActivityDate="2022-11-20T14:02:10.630" Title="Sequential quadratic programming source" Tags="|optimization|reference-request|nonlinear-programming|quadratic-programming|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3557" PostTypeId="1" CreationDate="2020-02-17T13:26:35.407" Score="7" ViewCount="435" Body="&lt;p&gt;I would like to create a constraint with AMPL that checks whether I am able to reach from one node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; to all other nodes of a set but I don't really know how to formulate it (especially in AMPL (+CPLEX)).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I am not interested in finding the shortest paths just a path per pair of nodes &lt;span class=&quot;math-container&quot;&gt;$(v,*)$&lt;/span&gt; (Floyd-Warshall))&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically the main goal of my optimisation is to split graphs into two subgraphs even so this extends the question itself (the objective function is untested and highly experimental):&#xA;For a connected graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E_V)$&lt;/span&gt; I'd like to find two connected subgraphs &lt;span class=&quot;math-container&quot;&gt;$SG1=(U,E_U)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$SG2=(W,E_W)$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{split}&#xA;&amp;amp; \min |\text{card}(U)-\text{card}(W)|\cdot\text{card}\left(N^+_{E_V}(U)\cap N^+_{E_V}(W)\right)\\&#xA;&amp;amp; \exists v\in U: N^+_{E_U}(v)=U \text{ therefore the first subgraph is connected}\\&#xA;&amp;amp; \exists v\in W: N^+_{E_W}(v)=W \text{ the second subgraph is connected}\\&#xA;&amp;amp; U\cap W=\emptyset\\&#xA;&amp;amp; N^+_{E} \text{ is the set of nodes that is reachable for a given set of edges}&#xA;\end{split}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2989" LastEditorUserId="2989" LastEditDate="2020-02-20T13:26:30.640" LastActivityDate="2020-02-21T04:52:17.230" Title="Constraint that checks for an undirected graph whether it is connected?" Tags="|linear-programming|ampl|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3558" PostTypeId="2" ParentId="3557" CreationDate="2020-02-17T15:16:31.020" Score="1" Body="&lt;p&gt;You may have a look at &lt;a href=&quot;https://ampl.com/MEETINGS/TALKS/2011_01_Chiang_Mai_Workshop_1b.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; presentation about network flows implementations in AMPL. In the presentation, the authors talked about new AMPL implementations of &quot;arc&quot; and &quot;node&quot; especially on page 8 they mentioned keywords like &lt;code&gt;from&lt;/code&gt; and &lt;code&gt;to&lt;/code&gt; that I think will help you design your constraints in AMPL. There is also &lt;a href=&quot;https://ampl.com/BOOK/CHAPTERS/18-network.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;AMPL book chapter&lt;/a&gt; about network linear programs that you can read more about the topic. I hope it works for you. &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2020-02-17T15:44:57.900" LastActivityDate="2020-02-17T15:44:57.900" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3559" PostTypeId="2" ParentId="3557" CreationDate="2020-02-17T17:38:19.447" Score="5" Body="&lt;p&gt;I am aware of models that model such constraints using a network-flow-type approach. The basic idea is to create a source node that send &quot;flow&quot; of an imaginary product for which all nodes have a demand of 1. There are no costs for the flows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case the problem is trickier because you would need two source nodes, and maybe two types of imaginary products, and maybe you have a constraint that each node needs one type or the other—but hopefully you can make use of this idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also suggest doing an online search for &quot;connectivity constraints&quot;. There are other approaches in the literature.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-02-17T17:38:19.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3560" PostTypeId="1" AcceptedAnswerId="3561" CreationDate="2020-02-17T18:19:42.587" Score="8" ViewCount="746" Body="&lt;p&gt;This task appears to be harder than it seems to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to create a continuous variable &lt;span class=&quot;math-container&quot;&gt;$x \in [0,1]$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test this, I did use the open-source &lt;a href=&quot;https://www.python-mip.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python-MIP&lt;/a&gt; interface which uses the &lt;a href=&quot;https://github.com/coin-or/Cbc&quot; rel=&quot;nofollow noreferrer&quot;&gt;CBC-Solver&lt;/a&gt; out of the box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a simple code example to see if the variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; will get the float value of &lt;span class=&quot;math-container&quot;&gt;$0.4$&lt;/span&gt; by doing the following: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad x\\\text{s.t.}&amp;amp;\quad x\in[0,1]\\&amp;amp;\quad a=2\\&amp;amp;\quad b=5\\&amp;amp;\quad x\le a/b\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;    from mip import Model, maximize, CONTINUOUS, CBC&#xA;&#xA;    model = Model(solver_name=CBC)&#xA;&#xA;    a = 2&#xA;    b = 5&#xA;&#xA;    x = model.add_var('x',lb = 0, ub =1, var_type=CONTINUOUS)&#xA;&#xA;    model += x &amp;lt;= a/b&#xA;&#xA;    model.objective = maximize(x)&#xA;&#xA;    model.optimize()&#xA;&#xA;    if model.num_solutions:&#xA;            for v in model.vars:&#xA;               # if v.x &amp;gt; 0:&#xA;                    print('{v.name} = {v.x}'.format(**locals()))&#xA;                    print('          ', end='')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead, I am getting a value of &lt;span class=&quot;math-container&quot;&gt;$x=0.0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Using Python-MIP package version 1.6.6&#xA;Welcome to the CBC MILP Solver &#xA;Version: Trunk&#xA;Build Date: Dec 26 2019 &#xA;&#xA;Starting solution of the Linear programming problem using Primal Simplex&#xA;&#xA;x = 0.0&#xA;          Coin0506I Presolve 0 (-1) rows, 0 (-1) columns and 0 (-1) elements&#xA;Clp0000I Optimal - objective value 0&#xA;Coin0511I After Postsolve, objective 0, infeasibilities - dual 0 (0), primal 0 (0)&#xA;Clp0032I Optimal objective 0 - 0 iterations time 0.012, Presolve 0.00, Idiot 0.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="456" LastEditorUserId="123" LastEditDate="2020-02-17T19:13:43.077" LastActivityDate="2020-02-28T22:25:14.647" Title="Creating a Continuous Decision Variable between 0 and 1 in Python-MIP Interface" Tags="|mixed-integer-programming|python|coin-or|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3561" PostTypeId="2" ParentId="3560" CreationDate="2020-02-17T21:15:45.553" Score="12" Body="&lt;p&gt;I don't know much about Python-mip but looking at the &lt;a href=&quot;https://github.com/coin-or/python-mip/blob/1.7.0/mip/model.py#L1286&quot; rel=&quot;nofollow noreferrer&quot;&gt;code&lt;/a&gt;, &lt;code&gt;maximize&lt;/code&gt; expects a &lt;code&gt;LinExpr&lt;/code&gt;, so I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;model.objective = maximize(1*x)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which gives the expected output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I also opened a &lt;a href=&quot;https://github.com/coin-or/python-mip/pull/59&quot; rel=&quot;nofollow noreferrer&quot;&gt;PR&lt;/a&gt; to allow &lt;code&gt;maximize(var)&lt;/code&gt; and &lt;code&gt;minimize(var)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: The PR has been merged, this shouldn't be a problem in &lt;code&gt;&amp;gt;1.7.2&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2020-02-28T22:25:14.647" LastActivityDate="2020-02-28T22:25:14.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3562" PostTypeId="1" AcceptedAnswerId="3564" CreationDate="2020-02-18T17:19:04.670" Score="9" ViewCount="253" Body="&lt;h2&gt;Problem statement&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I'm given a set of events &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\forall e \in E$&lt;/span&gt; also:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;a set of plausible dates on which the event can happen &lt;span class=&quot;math-container&quot;&gt;$D_e$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;importance (weight) &lt;span class=&quot;math-container&quot;&gt;$w_e$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;ideal preparation time duration &lt;span class=&quot;math-container&quot;&gt;$i_e$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I define &lt;em&gt;preparation time&lt;/em&gt; for an event to be the number of days between that event and the previous event. I'd like to schedule the events so that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;on each day, there is at maximum one event scheduled&lt;/li&gt;&#xA;&lt;li&gt;each event &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; is scheduled on some day, and that day has to be in &lt;span class=&quot;math-container&quot;&gt;$D_e$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;the preparation time of each event should be in some way proportional to its importance (the best case is for each event to have at least &lt;span class=&quot;math-container&quot;&gt;$i_e$&lt;/span&gt; preparation time)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Solution details&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I chose this topic as my semestral project for a Java class, so I'd like to implement the solution with the help of some Java library. I don't mind getting pointers for solutions in other languages as well, along the lines of &quot;I'd use X normally, but given your situation, use the java bindings for Y&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought about using an optimizing SAT solver, but maybe there's some other, better way. If I'm not mistaken, I'll have to &quot;translate&quot; my abstract constraints into linear (in)equations, in order to be able to use a SAT solver. I can &quot;linearize&quot; the first and second constraint, but I'm not sure how to formulate the objective function that's to be maximized according to the third point.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The questions&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Would you solve this with a SAT solver, or in some other way?&lt;/li&gt;&#xA;&lt;li&gt;How would you formulate the objective function, most importantly the &lt;em&gt;preparation time of event &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;&lt;/em&gt;, in such a way that it could be used in the SAT solver (or the alternative method of your choosing)?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Bonus question: Which Java library should I use to implement the [&lt;em&gt;method you recommended in the first answer&lt;/em&gt;]?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Please note that I'm a total OR newbie, not educated about linear programming, constrained optimization, and such matters. If anything is unclear, ask in the comments and I'll try my best to clarify it.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="3083" LastEditorUserId="3083" LastEditDate="2020-02-19T09:37:46.093" LastActivityDate="2020-02-19T18:46:01.530" Title="Scheduling events in order to maximize preparation time" Tags="|optimization|linear-programming|scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3563" PostTypeId="1" CreationDate="2020-02-18T18:22:08.897" Score="5" ViewCount="725" Body="&lt;p&gt;Has anyone used MIP solvers (open source or commercial) with Go language &lt;a href=&quot;https://golang.org/&quot; rel=&quot;noreferrer&quot;&gt;https://golang.org/&lt;/a&gt;? I am looking for a solver for simple linear MIPs for network flows and set cover types of problems.&lt;/p&gt;&#xA;" OwnerUserId="45" LastActivityDate="2020-02-18T18:22:08.897" Title="Solver for Go Programming Laguage" Tags="|mixed-integer-programming|solver|network-flow|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3564" PostTypeId="2" ParentId="3562" CreationDate="2020-02-18T20:52:16.143" Score="7" Body="&lt;p&gt;If you use a constraint programming (CP) solver, I do not think you will need to convert constraints into algebraic expressions (at least not linear ones). Your first requirement can be handled by an &quot;alldifferent&quot; constraint, for which every CP solver I've heard of has an implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your second constraint just becomes the definition of the domain for the variable deciding when event &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; occurs. You can try to get the ideal preparation time for every event through implication constraints&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$d_e = t \implies x_\tau = 0 \text{ for } \tau = t - i_e + 1, \dots, t - 1,$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$d_e$&lt;/span&gt; is the date of event &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_\tau$&lt;/span&gt; is 1 if an event is scheduled for day &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; and 0 if not. If you have to live with less than ideal preparation times, you can capture the deficiency in preparation time for event &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; as &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max(0, i_e - (d_e - \max(\{t &amp;lt; d_e : x_t = 1\}))),$$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and penalize it in an objective function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also formulate the problem as a mixed integer linear program (MILP) and use an appropriate solver. I can't predict whether CP would be faster than MILP or vice versa, but for small dimensions (not too many events, not too long a horizon) either should work well. I would probably try a CP model first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I do not have much experience with CP solvers, but Håkan Kjellerstrand has a &lt;a href=&quot;http://www.hakank.org/constraint_programming/&quot; rel=&quot;nofollow noreferrer&quot;&gt;page on constraint programming&lt;/a&gt; that lists a number of CP solvers with Java APIs. CP Optimizer, part of IBM's CPLEX Studio suite, is a commercial CP solver with a Java API.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-02-19T18:46:01.530" LastActivityDate="2020-02-19T18:46:01.530" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3565" PostTypeId="2" ParentId="3557" CreationDate="2020-02-19T00:41:57.063" Score="3" Body="&lt;p&gt;One possible solution (not necessarily quick or efficient) is a lazy constraint approach:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Solve your problem, ignoring the connection requirement&lt;/li&gt;&#xA;&lt;li&gt;Examine the solution and find the subgraph &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; that is connected to &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$H=G$&lt;/span&gt;, you are finished.&lt;/li&gt;&#xA;&lt;li&gt;Otherwise, add a constraint that at least one of the edges between &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; and not-&lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; is connected, and repeat.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://groups.google.com/forum/#!topic/ampl/mVsFg4mAI1c&quot; rel=&quot;nofollow noreferrer&quot;&gt;This post by Bob Fourer&lt;/a&gt; gives an example of the same approach as applied to a TSP.&lt;/p&gt;&#xA;" OwnerUserId="546" LastEditorUserId="546" LastEditDate="2020-02-21T04:52:17.230" LastActivityDate="2020-02-21T04:52:17.230" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3566" PostTypeId="1" AcceptedAnswerId="3567" CreationDate="2020-02-19T16:10:17.120" Score="7" ViewCount="99" Body="&lt;p&gt;My question is similar to &lt;a href=&quot;https://or.stackexchange.com/questions/1052/linearize-or-approximate-a-square-root-constraint&quot;&gt;this one&lt;/a&gt; though a bit more complicated. Though my question also includes indices, I am removing them to ease readability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let binary variables &lt;span class=&quot;math-container&quot;&gt;$x,y\in\{0,1\}$&lt;/span&gt;, non-negative continuous variable &lt;span class=&quot;math-container&quot;&gt;$z\in\mathbb{R}^+$&lt;/span&gt; and the parameter &lt;span class=&quot;math-container&quot;&gt;$\lambda\in\mathbb{R}^+$&lt;/span&gt;. Is there a way to linearize the below equality constraint?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\displaystyle z=\sqrt{\lambda\left(x+y\right)}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can we benefit from the fact that &lt;span class=&quot;math-container&quot;&gt;$\alpha=x+y$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\alpha \in \{0,1,2\}$&lt;/span&gt; and write additional constraints?&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="123" LastEditDate="2020-02-20T07:24:37.233" LastActivityDate="2020-02-20T07:24:37.233" Title="Linearizing the square root of two binary summations" Tags="|linearization|nonconvex-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3567" PostTypeId="2" ParentId="3566" CreationDate="2020-02-19T16:19:39.657" Score="7" Body="&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$j\in\{0,1,2\}$&lt;/span&gt;, introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt; to indicate whether &lt;span class=&quot;math-container&quot;&gt;$x+y=j$&lt;/span&gt;, and then impose the following linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{j=0}^2 w_j &amp;amp;= 1 \\&#xA;\sum_{j=0}^2 j\cdot w_j &amp;amp;= x+y \\&#xA;\sqrt{\lambda}\sum_{j=0}^2 \sqrt{j}\cdot w_j &amp;amp;= z&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-02-19T16:19:39.657" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3568" PostTypeId="1" AcceptedAnswerId="3569" CreationDate="2020-02-19T17:28:20.877" Score="6" ViewCount="241" Body="&lt;p&gt;My question is similar to &lt;a href=&quot;https://or.stackexchange.com/questions/1052/linearize-or-approximate-a-square-root-constraint&quot;&gt;this one&lt;/a&gt; and almost identical with &lt;a href=&quot;https://or.stackexchange.com/questions/3566/linearizing-the-square-root-of-two-binary-summation&quot;&gt;this&lt;/a&gt;. I am so confused due to indexing and could not make sure if I could apply the solution in &lt;a href=&quot;https://or.stackexchange.com/questions/3566/linearizing-the-square-root-of-two-binary-summation&quot;&gt;here&lt;/a&gt; to this indexed version as shown below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{ijk},y_{jik}\in\{0,1\}$&lt;/span&gt;, non-negative continuous variable &lt;span class=&quot;math-container&quot;&gt;$z_j\in\mathbb{R}^+$&lt;/span&gt;, the parameter &lt;span class=&quot;math-container&quot;&gt;$\lambda_k\in\mathbb{R}^+$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{I}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}$&lt;/span&gt; be some polynomial size sets. Given these domains, how can I linearize the following set of equality constraints?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\displaystyle z_j=\sqrt{\sum_{\substack{i\in \mathcal{I},\\k\in \mathcal{K}}}\lambda_k\left(x_{ijk}+y_{jik}\right)}\qquad j\in\mathcal{J}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution Attempt:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As in &lt;a href=&quot;https://or.stackexchange.com/questions/3566/linearizing-the-square-root-of-two-binary-summation&quot;&gt;here&lt;/a&gt;, can I say: for &lt;span class=&quot;math-container&quot;&gt;$n\in \{0,1,2\}$&lt;/span&gt;, introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$w_{ijkn}$&lt;/span&gt; to indicate whether &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}+y_{jik}=n$&lt;/span&gt;, and introduce the following constraints?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\sum_{n=0}^2w_{ijkn}&amp;amp;=1 \qquad \forall i\in \mathcal{I},j\in \mathcal{J}, k\in \mathcal{K}\\\sum_{n=0}^2 n\cdot w_{ijkn}&amp;amp;= x_{ijk}+y_{jik}\qquad \forall i\in \mathcal{I},j\in \mathcal{J}, k\in \mathcal{K}\\z_j&amp;amp;= \sum_{\substack{i\in \mathcal{I},\\k\in \mathcal{K}}}\sqrt{\lambda_k}\sum_{n=0}^2 \sqrt{n}\cdot w_{ijkn} \qquad \forall j\in \mathcal{J}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="123" LastEditDate="2020-02-20T07:26:02.717" LastActivityDate="2020-02-20T07:26:02.717" Title="Linearizing the square root of binary summations" Tags="|linearization|nonconvex-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3569" PostTypeId="2" ParentId="3568" CreationDate="2020-02-19T18:27:52.037" Score="6" Body="&lt;p&gt;Because your objective is minimization and &lt;span class=&quot;math-container&quot;&gt;$z_j$&lt;/span&gt; has a nonnegative objective coefficient, you can relax your equality constraint to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\displaystyle z_j \ge \sqrt{\sum_{\substack{i\in \mathcal{I},\\k\in \mathcal{K}}}\lambda_k\left(x_{ijk}+y_{jik}\right)}\qquad j\in\mathcal{J}$$&lt;/span&gt;&#xA;and this constraint will naturally be satisfied with equality for an optimal solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now apply one of the transformations &lt;a href=&quot;https://or.stackexchange.com/questions/1052/linearize-or-approximate-a-square-root-constraint&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-02-19T18:27:52.037" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3570" PostTypeId="1" CreationDate="2020-02-19T18:29:25.583" Score="11" ViewCount="518" Body="&lt;p&gt;I am a PhD student now and I have been curious about this question since I was an undergraduate student.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do researchers choose which journals to submit if your work do not have an obvious fit to a specific one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading some papers, I now have a brief sense, for example, I know Mathematical Programming (A) contains some solid theoretical optimization research, short papers appear in Operations Research Letters or Optimization Letters (what are their differences though?) Operations Research usually contains innovative and new models or algorithms, INFORMS Journal on Computing also contains algorithm research. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my sense correct? What about Management Science or POMS or MSOM?&lt;/p&gt;&#xA;" OwnerUserId="3085" LastEditorUserId="491" LastEditDate="2020-02-20T13:47:58.490" LastActivityDate="2020-02-20T13:47:58.490" Title="How do OR researchers choose which journal to submit and what are the differences between them?" Tags="|journals|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3571" PostTypeId="1" CreationDate="2020-02-19T21:01:08.247" Score="3" ViewCount="68" Body="&lt;p&gt;I was working on a problem in transport economics where the optimal number of trips in a given duration of time is to be found out. The profit is a function of the price vector &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and time cost &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; which is negatively related to the prices due to demand-side factors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used linear programming initially and interpreted the results stochastically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I seek to go for discrete optimization or integer programming as they seem more natural for this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have very little knowledge of these, however. While I have read some algorithms (unfortunately without proof or justification), in all such problems specific values are used (say &lt;span class=&quot;math-container&quot;&gt;$p=(1,3)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c=1$&lt;/span&gt; per trip). How do I solve discrete optimization or integer programming problems without specifying the exact value of the parameters, keeping them as general as possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And what are some good resources, books, papers, articles, videos, etc. that I can use to understand and approach such problems?&lt;/p&gt;&#xA;" OwnerUserId="3086" LastEditorUserId="36" LastEditDate="2020-02-19T21:48:02.087" LastActivityDate="2020-02-19T21:48:02.087" Title="Discrete optimization in transport economics" Tags="|optimization|mixed-integer-programming|modeling|reference-request|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3572" PostTypeId="2" ParentId="3570" CreationDate="2020-02-19T22:09:47.683" Score="11" Body="&lt;p&gt;First, I would agree with your general assessment of Math Programming, OR Letters etc. Between OR Letters and Optimization Letters, I think the main difference is that OR Letters is suitable for general OR work (including optimization) and Optimization Letters is fine for optimization but not suitable for, say, stochastic processes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to how authors choose target journals, I'm pretty sure that varies from person to person. My own (pre-retirement) criteria as an academic were the following (not necessarily in order of importance):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is the target an &quot;A&quot; journal, a &quot;B+&quot; journal or lower? (Different departments, colleges or universities will have different ideas of what constitutes an &quot;A&quot; journal.)&lt;/li&gt;&#xA;&lt;li&gt;Is the paper good enough for the journal? (Sending a semi-trivial paper to an &quot;A&quot; journal invites rejection.)&lt;/li&gt;&#xA;&lt;li&gt;Does the fundamental contribution of the paper match the journal? A paper that poses and solves a model for a previously unsolved problem may be a poor fit for a theoretical journal, while a paper that provides insight into the geometry underlying some well-known problem might be a poor fit for an applied journal.&lt;/li&gt;&#xA;&lt;li&gt;If the paper has a specific application area (marketing, logistics, human trafficking, financial wizardry), does the journal focus on that area?&lt;/li&gt;&#xA;&lt;li&gt;Have similar papers (in particular, ones I'm citing) appeared in this journal? If so, the paper is more likely to be a fit (and perhaps more likely to be well received).&lt;/li&gt;&#xA;&lt;li&gt;Have I been burned by this journal in the past? Review quality can vary from journal to journal (and submission to submission). If I've received dopey reviews from a journal more than once, I'll likely think twice about submitting to it. Note that negative reviews (major revision or rejection) are not automatically &quot;dopey&quot;.&lt;/li&gt;&#xA;&lt;li&gt;Have I had good luck with this journal in the past? I can think of one journal where previous reviews of my work were both constructive and timely. &lt;em&gt;Ceteris paribus&lt;/em&gt;, I would be happy to submit to them again.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-02-19T22:09:47.683" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3573" PostTypeId="1" AcceptedAnswerId="3574" CreationDate="2020-02-20T16:09:07.553" Score="5" ViewCount="619" Body="&lt;p&gt;I have a minimization problem minimizing &lt;span class=&quot;math-container&quot;&gt;$d_k \geq 0$&lt;/span&gt; and some other variables with all strictly positive coefficients. I leave my objective function below to better convey my goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{\mathbf{d},\mathbf{y^+},\mathbf{y^-}} \sum_{k\in\mathcal{K}} C_k d_k +\sum_{(i,j)\in\mathcal{E},k\in\mathcal{K}}P\lambda_kT_{ij}\left(y_{ijk}^+ +y_{ijk}^-\right)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To determine the value of &lt;span class=&quot;math-container&quot;&gt;$d_k$&lt;/span&gt;, I have the following constraint which can possibly become undefined due to the domains of variables associated. Simply, if all &lt;span class=&quot;math-container&quot;&gt;$y^+$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^-$&lt;/span&gt; variables are 0...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$d_k \geq \frac{\displaystyle\sum_{i\in \mathcal{I}_k}\lambda_k y_{ikk}^+}{\displaystyle\sum_{(i,j)\in\mathcal{E}} T_{ij}\left(y_{ijk}^+ +y_{ijk}^-\right)}\qquad \forall k\in \mathcal{K}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Notation Domains:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{c|c|c}&#xA; &amp;amp; \text{Domain} &amp;amp; \text{Type}\\ \hline&#xA;d_k &amp;amp; \mathbb{R}^{\geq0} &amp;amp; \text{Variable} \\ \hline&#xA;y_{ijk}^+ &amp;amp; \{0,1\} &amp;amp; \text{Variable} \\ \hline&#xA;y_{ijk}^- &amp;amp; \{0,1\} &amp;amp; \text{Variable} \\ \hline&#xA;\lambda_k &amp;amp; \mathbb{R}^{&amp;gt;0} &amp;amp; \text{Parameter} \\ \hline&#xA;T_{ij} &amp;amp; \mathbb{R}^{&amp;gt;0}&amp;amp; \text{Parameter} \\ \hline&#xA;C_k &amp;amp; \mathbb{R}^{&amp;gt;0}&amp;amp; \text{Parameter} \\ \hline&#xA;P &amp;amp; \mathbb{R}^{&amp;gt;0}&amp;amp; \text{Parameter} \\&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Sets:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sets: &lt;span class=&quot;math-container&quot;&gt;$\mathcal{I}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}$&lt;/span&gt; are some polynomial size sets and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{I}_k$&lt;/span&gt; is a subset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to deal with nonlinearity and &quot;0/0&quot;?&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="1160" LastEditDate="2020-02-21T14:15:32.957" LastActivityDate="2020-02-21T14:15:32.957" Title="How can I deal with a possibly undefined constraint?" Tags="|linear-programming|linearization|binary-variable|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3574" PostTypeId="2" ParentId="3573" CreationDate="2020-02-20T16:14:30.163" Score="8" Body="&lt;p&gt;Multiply both sides of your &lt;span class=&quot;math-container&quot;&gt;$d_k \ge$&lt;/span&gt; constraint by the denominator and then linearize &lt;span class=&quot;math-container&quot;&gt;$d_k y_{ijk}^+$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_k y_{ijk}^-$&lt;/span&gt; as described in &lt;a href=&quot;https://or.stackexchange.com/questions/39/how-to-linearize-the-product-of-a-binary-and-a-non-negative-continuous-variable&quot;&gt;this thread&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-02-20T16:14:30.163" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3575" PostTypeId="2" ParentId="120" CreationDate="2020-02-20T17:41:07.000" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://octeract.com/dgo-engine/&quot; rel=&quot;noreferrer&quot;&gt;Octeract Engine&lt;/a&gt; (the solver I develop), is a deterministic global MINLP solver that supports all trigonometric functions (including hyperbolic functions).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-02-20T17:41:07.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3576" PostTypeId="1" CreationDate="2020-02-20T18:04:05.773" Score="10" ViewCount="404" Body="&lt;p&gt;A binary array &lt;span class=&quot;math-container&quot;&gt;$t = [t_1, t_2, t_3, t_4, t_5]$&lt;/span&gt; with each element a binary integer variable taking values 0 or 1. You can think this vector as slots with 1 representing the slot being taken and 0 otherwise. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&#xA;Now 2 appointments need to be scheduled with the first one taking 1 slot and the second one taking 2 slots. The second appointment must be scheduled at or after the second slot (&lt;span class=&quot;math-container&quot;&gt;$t_2$&lt;/span&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Objective:&lt;/strong&gt;&#xA;Maximize the number of consecutive zeros in array &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.(Intend to leave a long range empty slots for future planning) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&#xA;One of the optimal solutions is to put first appointment into &lt;span class=&quot;math-container&quot;&gt;$t_1$&lt;/span&gt; and the second appointment into &lt;span class=&quot;math-container&quot;&gt;$t_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t = [1,1,1,0,0]$&lt;/span&gt;, which has a consecutive zero number 2. A feasible but non-optimal solution is to put first appointment into &lt;span class=&quot;math-container&quot;&gt;$t_1$&lt;/span&gt; and the second appointment into &lt;span class=&quot;math-container&quot;&gt;$t_3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_4$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t=[1,0,1,1,0]$&lt;/span&gt;, which has a consecutive zero number 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Optimal Constraints:&lt;/strong&gt;&#xA;How to formulate the question in a linear/integer/mixed-integer way that can be solved by an optimization solver? Constraints can be definitely formulated in a linear integer way but I am having a hard time for the objective.&lt;/p&gt;&#xA;" OwnerUserId="3090" LastEditorUserId="3090" LastEditDate="2020-02-20T18:49:52.143" LastActivityDate="2020-02-25T16:32:56.080" Title="Use integer/quadratic programming to maximize consecutive zeros in a binary array" Tags="|optimization|mixed-integer-programming|integer-programming|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3577" PostTypeId="1" AcceptedAnswerId="3611" CreationDate="2020-02-20T20:09:58.347" Score="10" ViewCount="364" Body="&lt;p&gt;I am working on a Lagrangian relaxation for a minimization MIP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything seemed to be working fine before I started to run a batch of instances. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Checking the log results for one of the instances I found out that the lower bound given by the LR algorithm was greater than my optimal objective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of my concerns, beyond wrong coding from my part, is the chance that the solver is removing columns or doing any other stuff to speed up optimization that is only feasible because of the relaxed constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw this kind of problem before when a friend was implementing a branch and cut with cplex without changing a solver parameter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any parameters set that I should deactivate, like presolve, cutting planes etc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I posted a &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360057707771-Lagrangian-Relaxation-bound-greater-than-optimal-solution&quot; rel=&quot;noreferrer&quot;&gt;copy of this question on gurobi community&lt;/a&gt;, but thought it would be good to also ask here, as here we are more active and also could find opinions from non gurobi users.&lt;/p&gt;&#xA;" OwnerUserId="2397" LastActivityDate="2020-06-26T17:03:59.817" Title="Lagrangian Relaxation bound greater than optimal solution" Tags="|algorithms|gurobi|lagrangian-relaxation|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="3579" PostTypeId="1" AcceptedAnswerId="3580" CreationDate="2020-02-20T23:37:10.560" Score="6" ViewCount="1307" Body="&lt;p&gt;Is there a way to obtain a free BARON or Knitro license? I am doing academic research and I really need these global optimization solvers (Knitro is not necessarily for global optimization, although it is pretty strong in many problems in global optimization)...&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="39" LastEditDate="2020-02-20T23:45:25.187" LastActivityDate="2022-04-08T15:23:23.803" Title="Academic Licenses of Baron &amp; Knitro" Tags="|solver|academia|baron|knitro|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3580" PostTypeId="2" ParentId="3579" CreationDate="2020-02-20T23:54:14.277" Score="9" Body="&lt;p&gt;You can use BARON and Knitro for free from the NEOS Server. Also, you have the following options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you are in the first year of graduation, you can apply for a one-year free graduate student license of AMPL which includes both solvers.&lt;/li&gt;&#xA;&lt;li&gt;If you are an individual with a CMU or UIUC email address or related to sponsors of the CAPD you can have a free academic license.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2020-02-21T00:00:44.470" LastActivityDate="2020-02-21T00:00:44.470" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="3582" PostTypeId="1" CreationDate="2020-02-21T06:24:01.337" Score="4" ViewCount="61" Body="&lt;p&gt;I want to use &lt;code&gt;LpVariable&lt;/code&gt; as an input argument to a sequential CNN network layer, which is in Keras. When I tried to call the function I got the error as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int(single_value)&#xA;&#xA;TypeError: int() argument must be a string, a bytes-like object or a number, not 'LpVariable'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can convert the &lt;code&gt;LpVariable&lt;/code&gt; to integer values, so I can input it to my CNN network?&lt;/p&gt;&#xA;" OwnerUserId="3094" LastEditorUserId="123" LastEditDate="2020-02-21T07:06:12.743" LastActivityDate="2020-02-21T16:35:44.497" Title="Access LpVariable as input to another Keras sequential network" Tags="|optimization|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3583" PostTypeId="2" ParentId="3582" CreationDate="2020-02-21T07:25:47.080" Score="2" Body="&lt;p&gt;You can use, &lt;code&gt;varValue&lt;/code&gt; to get the values of your variable. Simply code as follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int(LpVariable[i].varValue)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here is an example from &lt;a href=&quot;http://benalexkeen.com/linear-programming-with-python-and-pulp-part-4/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; link:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for var in ing_weight:&#xA;var_value = ing_weight[var].varValue&#xA;print &quot;The weight of {0} in {1} sausages is {2} kg&quot;.format(var[1], var[0], var_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://s3.amazonaws.com/assets.datacamp.com/production/course_8835/slides/chapter2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; link.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2020-02-21T16:35:44.497" LastActivityDate="2020-02-21T16:35:44.497" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3584" PostTypeId="1" AcceptedAnswerId="3585" CreationDate="2020-02-21T22:15:31.150" Score="5" ViewCount="635" Body="&lt;p&gt;After creating my model for a problem, what steps should I take to test if a change in the model is actually helpful or not?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Python, &lt;code&gt;print(solver.ResponseStats())&lt;/code&gt; returns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CpSolverResponse:&#xA;status: FEASIBLE&#xA;objective: 4661700&#xA;best_bound: 9876900&#xA;booleans: 108186&#xA;conflicts: 6415&#xA;branches: 3173794&#xA;propagations: 7757468&#xA;integer_propagations: 24021224&#xA;walltime: 21.7395&#xA;usertime: 21.7395&#xA;deterministic_time: 6.71619&#xA;primal_integral: 4.72458e+06&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some ideas that I have are (with a small problem instance):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Compare the time to solve it.&lt;/li&gt;&#xA;&lt;li&gt;Compare the number of conflicts.&lt;/li&gt;&#xA;&lt;li&gt;Compare the best objective bound given a time limit.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="991" LastActivityDate="2020-02-24T16:06:40.353" Title="How to measure model quality in OR-Tools?" Tags="|modeling|constraint-programming|or-tools|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3585" PostTypeId="2" ParentId="3584" CreationDate="2020-02-21T23:22:02.093" Score="9" Body="&lt;p&gt;Time to solve (to proven optimality) is certainly a good choice. I don't know that I would be excited about number of conflicts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could look at the ratio of objective value on that problem instance to the best known value for that problem instance (across all model variants), given a time limit. A similar ratio of best bounds to best overall bound (by problem instance) might be useful. You could also look at the fraction of problem instances reaching proven optimality (across all problem instances, again with a common time limit) for different model variants.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-02-21T23:22:02.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3586" PostTypeId="2" ParentId="3579" CreationDate="2020-02-22T17:10:58.643" Score="6" Body="&lt;p&gt;You can also download our &lt;a href=&quot;http://www.octeract.com/dgo-engine&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Engine&lt;/a&gt; - it's free for students and academic staff and solves a superset of the problem types that BARON and KNITRO do (global optimality for non convex problems + trigonometric &amp;amp; nonsmooth &amp;amp; discontinuous problems).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-07-10T18:14:33.403" LastActivityDate="2020-07-10T18:14:33.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3587" PostTypeId="2" ParentId="3576" CreationDate="2020-02-22T19:19:21.363" Score="7" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; be the dimension of your binary vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Introduce new variables &lt;span class=&quot;math-container&quot;&gt;$w_n \in [0,n]$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$n=1,\dots,N$&lt;/span&gt;. Each &lt;span class=&quot;math-container&quot;&gt;$w_n$&lt;/span&gt; will capture the number of consecutive zeros culminating at position &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. So, for instance, if &lt;span class=&quot;math-container&quot;&gt;$x=[1,0,0,1,1]$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$w=[0,1,2,0,0]$&lt;/span&gt;. Note that &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; does not need to be declared integer; the constraints will force it to be integer-valued.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, add the following constraints for each &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$w_0 = 0$&lt;/span&gt;):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;w_{n} &amp;amp; \le N(1-x_{n})\\&#xA;w_{n}-w_{n-1} &amp;amp; \le1\\&#xA;w_{n}-w_{n-1} &amp;amp; \ge1-Nx_{n}.&#xA;\end{align*}&lt;/span&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$x_n=1$&lt;/span&gt;, the first constraint forces &lt;span class=&quot;math-container&quot;&gt;$w_n=0$&lt;/span&gt; and the second and third constraints have no effect. If &lt;span class=&quot;math-container&quot;&gt;$x_n=0$&lt;/span&gt;, the first constraint has no effect, while the second and third constraints combine to force &lt;span class=&quot;math-container&quot;&gt;$w_n=w_{n-1}+1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I understand you, you now want to maximize &lt;span class=&quot;math-container&quot;&gt;$$\max_{n=1}^N w_n.$$&lt;/span&gt; To do this, you can introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$z_1,\dots,z_N$&lt;/span&gt; along with the constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{n=1}^N z_n = 1,$$&lt;/span&gt; plus a continuous variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; to represent the objective value. You will maximize &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; subject the constraints &lt;span class=&quot;math-container&quot;&gt;$$y\le w_{n}+N(1-z_{n})\quad \forall n.$$&lt;/span&gt; This last constraint is nonbinding when &lt;span class=&quot;math-container&quot;&gt;$z_n=0$&lt;/span&gt;. For exactly one &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z_n$&lt;/span&gt; will be 1 and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; will be less than or equal to &lt;span class=&quot;math-container&quot;&gt;$w_n$&lt;/span&gt;. The solver will choose the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; corresponding to the largest &lt;span class=&quot;math-container&quot;&gt;$w_n$&lt;/span&gt; and set &lt;span class=&quot;math-container&quot;&gt;$y=w_n$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-02-24T15:51:05.787" LastActivityDate="2020-02-24T15:51:05.787" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3588" PostTypeId="1" AcceptedAnswerId="3589" CreationDate="2020-02-23T17:07:59.503" Score="4" ViewCount="195" Body="&lt;p&gt;I am trying to find the amount that an item may get produced. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To produce this item I need casting-molds. A casting-mold can be used multiple times after it becomes available again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the production I have to take into consideration the following parameters:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The production period&lt;/li&gt;&#xA;&lt;li&gt;The duration a casting-mold needs to get prepared before it gets sent to production&lt;/li&gt;&#xA;&lt;li&gt;The number of casting-molds&lt;/li&gt;&#xA;&lt;li&gt;The time it gets for a casting-mold to be available again.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In this case, the quantity of this item to produce is infinite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a simple example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Production period: 10:00 - 11:00 (60 Minutes)&lt;/li&gt;&#xA;&lt;li&gt;Casting-mold preperation time: 5 Minutes&lt;/li&gt;&#xA;&lt;li&gt;Number of casting-molds: &lt;span class=&quot;math-container&quot;&gt;$|\{a,b,c,d\}| = 4$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Re-use time: 25 Minutes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Production Process:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;10:00 casting-mold &lt;span class=&quot;math-container&quot;&gt;$(a)$&lt;/span&gt; preparation&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;10:05 casting-mold &lt;span class=&quot;math-container&quot;&gt;$(a)$&lt;/span&gt; sending for production and start processing the next casting-mold &lt;span class=&quot;math-container&quot;&gt;$(b)$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;10:10 casting-mold &lt;span class=&quot;math-container&quot;&gt;$(b)$&lt;/span&gt; sending for production and start processing the next casting-mold &lt;span class=&quot;math-container&quot;&gt;$(c)$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;10:15 casting-mold &lt;span class=&quot;math-container&quot;&gt;$(c)$&lt;/span&gt; sending for production and start processing the next casting-mold &lt;span class=&quot;math-container&quot;&gt;$(d)$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;10:20 casting-mold &lt;span class=&quot;math-container&quot;&gt;$(d)$&lt;/span&gt; sending for production&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;10:20 - 10:30 Wait until the first casting-mold &lt;span class=&quot;math-container&quot;&gt;$(a)$&lt;/span&gt; gets available again&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;10:30 casting-mold &lt;span class=&quot;math-container&quot;&gt;$(a)$&lt;/span&gt; preparation (since 10:05 + 00:25 = 10:30)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;10:35 casting-mold sending &lt;span class=&quot;math-container&quot;&gt;$(a)$&lt;/span&gt; for production and start processing the next casting-mold &lt;span class=&quot;math-container&quot;&gt;$(b)$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;10:40 casting-mold &lt;span class=&quot;math-container&quot;&gt;$(b)$&lt;/span&gt; sending for production and start processing the next casting-mold &lt;span class=&quot;math-container&quot;&gt;$(c)$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;10:45 casting-mold &lt;span class=&quot;math-container&quot;&gt;$(c)$&lt;/span&gt; sending for production and start processing the next casting-mold &lt;span class=&quot;math-container&quot;&gt;$(d)$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;10:50 casting-mold &lt;span class=&quot;math-container&quot;&gt;$(d)$&lt;/span&gt; sending for production&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;End (The casting-mold &lt;span class=&quot;math-container&quot;&gt;$(a)$&lt;/span&gt; can be used at 11:00 again which is out of the production window)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In this case, the item gets produced &lt;strong&gt;8&lt;/strong&gt; times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is irrelevant which mold gets processed first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Added for clarification:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The production happens to one machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The products may get finished after the production time frame (10:00 - 11:00), e.g., the items produced at 10:40 &lt;span class=&quot;math-container&quot;&gt;$(b)$&lt;/span&gt;, 10:45 &lt;span class=&quot;math-container&quot;&gt;$(c)$&lt;/span&gt; and 10:50 &lt;span class=&quot;math-container&quot;&gt;$(d)$&lt;/span&gt; end respectively at 11:05 &lt;span class=&quot;math-container&quot;&gt;$(b)$&lt;/span&gt;, 11:10 &lt;span class=&quot;math-container&quot;&gt;$(c)$&lt;/span&gt; and 11:15 &lt;span class=&quot;math-container&quot;&gt;$(d)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you tackle such a problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to @A.Omidi for the idea of a Gantt-chart:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PJDzg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PJDzg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="456" LastEditorUserId="456" LastEditDate="2020-02-24T13:34:18.397" LastActivityDate="2020-02-24T20:36:39.663" Title="Problem Clustering and Suggestions for Solving it (Job-Shop?)" Tags="|optimization|modeling|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3589" PostTypeId="2" ParentId="3588" CreationDate="2020-02-23T18:56:25.720" Score="3" Body="&lt;p&gt;I gather that you are assuming an unlimited demand for castings. Let &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; be the number of molds, &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; be the prep time for each mold (assumed the same for all molds) and &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; the use time for a prepped mold (again assumed to be the same for all molds). Assuming no delays, each mold has a cycle time of &lt;span class=&quot;math-container&quot;&gt;$p+u$&lt;/span&gt;. As long as &lt;span class=&quot;math-container&quot;&gt;$u\ge (n-1)p$&lt;/span&gt;, there will be no delay in preparing molds as they become available (no queue at the preparation station). So every mold will be in continuous use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; be the time window. The number of times the first mold is used will be &lt;span class=&quot;math-container&quot;&gt;$\left\lfloor \frac{W}{p+u}\right\rfloor$&lt;/span&gt;, the number of times for the second mold will be &lt;span class=&quot;math-container&quot;&gt;$\left\lfloor \frac{W-p}{p+u}\right\rfloor$&lt;/span&gt;, for the third it's &lt;span class=&quot;math-container&quot;&gt;$\left\lfloor \frac{W-2p}{p+u}\right\rfloor$&lt;/span&gt;, and so on. In your case, that's 2 + 1 + 1 + 1 = 5. (The other three molds in your solution of 8 will be started within the production window but will be completed outside the window.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$u &amp;lt; (n-1)p$&lt;/span&gt;, then you have to factor in a queue at the preparation station. It's not clear to me from the question whether that case is of interest.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-02-23T18:56:25.720" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3590" PostTypeId="2" ParentId="3588" CreationDate="2020-02-24T02:58:47.330" Score="-3" Body="&lt;p&gt;You can use the Graph method of &lt;a href=&quot;https://en.wikipedia.org/wiki/Maximum_flow_problem#Multi-source_multi-sink_maximum_flow_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Maximum-Flow-Network&lt;/a&gt; to get an optimal solution.&lt;/p&gt;&#xA;" OwnerUserId="3100" LastEditorUserId="123" LastEditDate="2020-02-24T07:42:07.083" LastActivityDate="2020-02-24T07:42:07.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3591" PostTypeId="2" ParentId="3588" CreationDate="2020-02-24T13:04:02.737" Score="1" Body="&lt;p&gt;So I wrote a simple discrete algorithm, that delivers the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not found any bugs yet. I will make a few more tests and post whether the code is eligible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Caution!: I used &lt;span class=&quot;math-container&quot;&gt;$u = 35$&lt;/span&gt; and not &lt;span class=&quot;math-container&quot;&gt;$25$&lt;/span&gt; to see if it truly works.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import datetime&#xA;&#xA;n = 4 # number of molds&#xA;p = 5*60 # prep time in seconds&#xA;u = 35*60 # use time in seconds&#xA;now = datetime.datetime.now()&#xA;day = now.day&#xA;year = now.year&#xA;month = now.month&#xA;startTime = datetime.datetime(year,month,day,10,0)&#xA;endTime = datetime.datetime(year,month,day,11,0)&#xA;count = []&#xA;for i in range(n):&#xA;    newTime = startTime&#xA;    pNew = p*(i+1) # i starts from 0&#xA;    count.append(0)&#xA;    print(newTime + datetime.timedelta(seconds=pNew))&#xA;    while newTime + datetime.timedelta(seconds=pNew) &amp;lt; endTime:&#xA;        count[i] += 1&#xA;        newTime += datetime.timedelta(seconds=u) + datetime.timedelta(seconds=p)&#xA;        print(newTime + datetime.timedelta(seconds=pNew))&#xA;&#xA;for i in range(n):&#xA;    print(count[i])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2020-02-24 10:05:00&#xA;2020-02-24 10:45:00&#xA;2020-02-24 11:25:00&#xA;2020-02-24 10:10:00&#xA;2020-02-24 10:50:00&#xA;2020-02-24 11:30:00&#xA;2020-02-24 10:15:00&#xA;2020-02-24 10:55:00&#xA;2020-02-24 11:35:00&#xA;2020-02-24 10:20:00&#xA;2020-02-24 11:00:00&#xA;2&#xA;2&#xA;2&#xA;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="456" LastEditorUserId="123" LastEditDate="2020-02-24T20:36:39.663" LastActivityDate="2020-02-24T20:36:39.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3594" PostTypeId="2" ParentId="3584" CreationDate="2020-02-24T16:06:40.353" Score="-1" Body="&lt;p&gt;In information theory, perplexity is a measurement of how well a probability distribution or probability model predicts a sample. It may be used to compare probability models. A low perplexity indicates the probability distribution is good at predicting the sample.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Perplexity&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Perplexity&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3100" LastActivityDate="2020-02-24T16:06:40.353" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3595" PostTypeId="1" AcceptedAnswerId="3596" CreationDate="2020-02-24T19:00:23.807" Score="13" ViewCount="771" Body="&lt;p&gt;This question is about using correct notation while writing a research paper. Say I have a directed graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;, partitioned into &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; layers. Denote the set of nodes in layer &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$V_t$&lt;/span&gt;. Suppose, I wanted to write some constraint, one for each node in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;, then which among the following notations below are correct. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;a. Constraint involving &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall t \in [T]$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall v \in V_t$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b. Constraint involving &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall t \in [T]$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$v \in V_t$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;c. Constraint involving &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall v \in V_t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall t \in [T]$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;d. Constraint involving &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall v \in V_t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t \in [T]$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, think of the &quot;Constraint&quot; above as the flow balance constraint that we would like to enforce at every node in our graph. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I have seen papers with notation a, b, c, d and am somewhat confused as to which one is correct \ standard notation. If you feel this may not be the correct forum to ask this question, I would be happy if you can redirect me to the appropriate stack exchange. &lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="123" LastEditDate="2020-02-24T20:37:19.127" LastActivityDate="2020-02-25T12:12:08.320" Title="On using correct notation in research papers" Tags="|modeling|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3596" PostTypeId="2" ParentId="3595" CreationDate="2020-02-24T19:38:34.520" Score="9" Body="&lt;p&gt;This is a matter of personal preference, to some extent. Personally, I like &lt;em&gt;a&lt;/em&gt; and &lt;em&gt;b&lt;/em&gt; more than &lt;em&gt;c&lt;/em&gt; and &lt;em&gt;d&lt;/em&gt;, because I feel that &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is &quot;out of scope&quot; in &lt;em&gt;c&lt;/em&gt; and &lt;em&gt;d&lt;/em&gt;; in other words, you're using &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; before you introduce it. I would tend to think of &lt;em&gt;c&lt;/em&gt; and &lt;em&gt;d&lt;/em&gt; as slightly incorrect notation, though not egregiously so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of &lt;em&gt;a&lt;/em&gt; vs. &lt;em&gt;b&lt;/em&gt;, that is definitely a matter of preference—neither is right or wrong. I have used both.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-02-24T19:38:34.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3597" PostTypeId="2" ParentId="3595" CreationDate="2020-02-24T20:45:17.067" Score="4" Body="&lt;p&gt;I think the first three are OK, more so the first two. I agree with what Larry said about defining all variables first before usage and in this case it means defining &lt;span class=&quot;math-container&quot;&gt;$t\in[T]$&lt;/span&gt; first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the last one not only has the minor problem above, but it also carries some ambiguity, as &lt;span class=&quot;math-container&quot;&gt;$\forall v\in V_t,t\in[T]$&lt;/span&gt; can mean either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;for all &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$V_t$&lt;/span&gt;, and for all &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$[T]$&lt;/span&gt;, or&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;for all &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$V_t$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is in &lt;span class=&quot;math-container&quot;&gt;$[T]$&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The latter misses the 'for all' part, although I believe most people would read it in the first way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this does not apply to the second constraint as it is evident that &lt;span class=&quot;math-container&quot;&gt;$v\in V_t$&lt;/span&gt; is incorporated within &lt;span class=&quot;math-container&quot;&gt;$\forall$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2020-02-24T20:45:17.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3598" PostTypeId="1" AcceptedAnswerId="3600" CreationDate="2020-02-24T21:40:23.740" Score="3" ViewCount="277" Body="&lt;p&gt;I would like to show that this function&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$2x^2 + 8y^2$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is convex or concave by using the definition&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f(θx+(1−θ)y) \le θf(x)+(1−θ)f(y)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From my understanding, using the Hessian matrix, I believe for certain I can show that the function is positive definite and hence convex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'm not certain how to proceed on showing this using the equation shown above.&lt;/p&gt;&#xA;" OwnerUserId="2693" LastEditorUserId="1160" LastEditDate="2020-02-25T07:19:38.343" LastActivityDate="2020-03-11T19:02:16.647" Title="Convexity of a function" Tags="|optimization|convexity|linear-algebra|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3600" PostTypeId="2" ParentId="3598" CreationDate="2020-02-24T22:10:43.577" Score="6" Body="&lt;p&gt;Your function is a function of two variables so you have:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(x,y)= 2x^2 + 8y^2 \ \ \forall(x,y)$$&lt;/span&gt;&#xA;So in the definition, you need to show that for two tuples of variables like &lt;span class=&quot;math-container&quot;&gt;$z_1=(x_1, y_1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_2=(x_2,y_2)$&lt;/span&gt; the definition holds. Specifically, you can show the following, which need some algebraic calculations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f(\theta z_1+(1-\theta)z_2)\le\theta f(z_1)+(1-\theta)f(z_2)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$\theta \in[0,1]$&lt;/span&gt; convexity and for &lt;span class=&quot;math-container&quot;&gt;$\theta \in(0,1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_1 \neq z_2$&lt;/span&gt; strict convexity can be shown. See also &lt;a href=&quot;https://math.stackexchange.com/q/2780443&quot;&gt;this&lt;/a&gt; question in math SE.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2020-02-24T22:42:18.780" LastActivityDate="2020-02-24T22:42:18.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3601" PostTypeId="1" CreationDate="2020-02-25T10:21:35.637" Score="7" ViewCount="151" Body="&lt;p&gt;I am trying to model traffic in a city, &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; represents a road in a city.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; vehicles in a city they have some prescheduled set of destinations to visit, &lt;span class=&quot;math-container&quot;&gt;$A_{j,h}$&lt;/span&gt; denotes arrival time of vehicle &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; at node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D_{j,h}$&lt;/span&gt; is departure time at node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b_{i,j,h}$&lt;/span&gt; represents vehicle &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; has road &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; in its route, i.e., it travels from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. (Only one incoming and outgoing edge at each node)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Attempt to model traffic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are constants for arrival time which is not required here so I am only discussing departure time constants.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there was no traffic then:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;dt_{j,h} = at_{j,h} &#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;departure time at any node is equal to arrival time at that node no delay no traffic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check for traffic I used a binary variable &lt;span class=&quot;math-container&quot;&gt;$T_{j,h, h^{\prime}}$&lt;/span&gt; representing if there is traffic delay at node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; for vehicle &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; due to vehicle &lt;span class=&quot;math-container&quot;&gt;$h^{\prime}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current idea is if two-vehicle arrives at any node within the  time window of &lt;span class=&quot;math-container&quot;&gt;$[-\tau, +\tau]$&lt;/span&gt; then there will be some delay introduced because of that, and each node has a constant value called traffic penalty &lt;span class=&quot;math-container&quot;&gt;$TP_{j}$&lt;/span&gt; (for example 10 min or 5min penalty)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;T_{j,h, h^{\prime}} =  \sum_{\forall i \in V} b_{i,j,h} \cdot \sum_{\forall i \in V} b_{i,j,h^{\prime}}  \quad  \text{ if } \quad at_{j,h} - at_{j,h^\prime} \in [-\tau, +\tau] &#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum\limits_{\forall i \in V} b_{i,j,h} = 1$&lt;/span&gt; if vehicle &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; has node  &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in its route.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;dt_{j,h} = at_{j,h} + \sum_{\forall h^\prime in H } T_{j,h, h^{\prime}} \cdot TP_{j}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with this model is this is not a &quot;realistic model&quot;, I am looking for some suggestion to make it more accurate.&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="123" LastEditDate="2020-02-25T16:34:33.867" LastActivityDate="2020-02-25T16:34:33.867" Title="Modeling traffic in a city" Tags="|linear-programming|modeling|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3602" PostTypeId="2" ParentId="3595" CreationDate="2020-02-25T12:12:08.320" Score="2" Body="&lt;p&gt;I would personally go for readability over mathematical stenography:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Constraint involving any &lt;span class=&quot;math-container&quot;&gt;$v:v\in V_t$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$t\in [T]$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some people, &lt;span class=&quot;math-container&quot;&gt;$\forall$&lt;/span&gt; has subtly different implications than simply drawing values from a set, as it explicitly says that the statement must be true for every single element in the set. Most of the time however people will treat the two notations as interchangeable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A nice example is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\log(x),x\in \mathbb{R}$&lt;/span&gt;, vs &lt;span class=&quot;math-container&quot;&gt;$\log(x),x\in \mathbb{R}^+$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on who you talk to, the first statement can be correct or not. The set over which the function is defined is clearly &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^+$&lt;/span&gt;, but the co-domain is all real numbers, so if &lt;span class=&quot;math-container&quot;&gt;$x\in\mathbb{R}^+$&lt;/span&gt; then it also belongs to its superset &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}$&lt;/span&gt; by definition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the kind of situation where you know what you mean, they know what you mean, and people sometimes just get annoying about terminology and correctness. I have found that using plain English where appropriate can make your math far more concise and explicit, so feel free to do so if that makes sense to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember, mathematical stenography is just that: shorthands so that we don't need to write words. Early mathematical texts didn't contain any symbols and the logic was conveyed just fine.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-02-25T12:12:08.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3603" PostTypeId="2" ParentId="3576" CreationDate="2020-02-25T15:18:50.977" Score="2" Body="&lt;p&gt;I would say that this objective function would do a decent job:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i = 0}^{n} i^2 t_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the total number of available slots.&lt;/p&gt;&#xA;" OwnerUserId="194" LastEditorUserId="123" LastEditDate="2020-02-25T16:32:56.080" LastActivityDate="2020-02-25T16:32:56.080" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3604" PostTypeId="1" CreationDate="2020-02-26T09:34:44.973" Score="2" ViewCount="69" Body="&lt;p&gt;I have a freight train dataset with details like locomotive type, substations it passes through, trip date, travel miles, etc. There are 5 locomotive types in the dataset, and each type has 20-30 locos. I want to find out how many locomotives I should choose from each type, to map out the entire network (max miles under each substation). What would be the best approach for this task?&lt;/p&gt;&#xA;" OwnerUserId="3113" LastEditorUserId="38" LastEditDate="2020-02-26T15:05:54.697" LastActivityDate="2020-02-26T15:05:54.697" Title="How to find minimum number of locomotives to cover maximum miles in a network?" Tags="|optimization|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3605" PostTypeId="1" CreationDate="2020-02-26T16:05:25.300" Score="4" ViewCount="51" Body="&lt;p&gt;Suppose we have a two player, finite horizon, zero sum stochastic game (a.k.a. &quot;competitive MDP&quot;). The game is defined over a finite set of state &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. At each decision epoch &lt;span class=&quot;math-container&quot;&gt;$t\in\{1,\dots,T\}$&lt;/span&gt; (for finite &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;), each player &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,2\}$&lt;/span&gt; simultaneously chooses an action &lt;span class=&quot;math-container&quot;&gt;$a^i\in{A^i(s)}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is the current state of the game. Player &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; receives a reward &lt;span class=&quot;math-container&quot;&gt;$r^i(s,a^1,a^2)$&lt;/span&gt;, and the game then transitions to a new state &lt;span class=&quot;math-container&quot;&gt;$s'$&lt;/span&gt; with probability &lt;span class=&quot;math-container&quot;&gt;$p(s'\mid s,a^1,a^2)$&lt;/span&gt;. Because the game is zero sum, we assume &lt;span class=&quot;math-container&quot;&gt;$r^1(s,a^1,a^2)=-r^2(s,a^1,a^2)$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$s, a^1,s^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am much more familiar with standard, single-agent MDPs. Coming from that context, my intuition is to try to write down an extension of Bellman's optimality equations. Something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;v_t^1(s)=\max_{a^1\in{A^1(s)}}\min_{a^2\in{A^2(s)}}r^1(s,a^1,a^2)+\sum_{s'\in{S}}p(s'\mid s,a^1,a^2)v_{t+1}^1(s)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;v_t^2(s)=\max_{a^2\in{A^2(s)}}\min_{a^1\in{A^1(s)}}r^2(s,a^1,a^2)+\sum_{s'\in{S}}p(s'\mid s,a^1,a^2)v_{t+1}^2(s)&#xA;$$&lt;/span&gt;&#xA;In principle, given boundary conditions &lt;span class=&quot;math-container&quot;&gt;$v_T^i(s)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,2\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s\in{S}$&lt;/span&gt;, one could compute &lt;span class=&quot;math-container&quot;&gt;$v_t^i(s)$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; which would satisfy the two equations above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: what do the resulting vectors correspond to? Are they value vectors at some kind of equilibrium? Do they in any sense &quot;solve&quot; the game? Or is there something more complicated going on? I hazily think that &lt;span class=&quot;math-container&quot;&gt;$v_t^1(s)=-v_t^2(s)$&lt;/span&gt; because the game is zero sum. Is this correct?&lt;/p&gt;&#xA;" OwnerUserId="358" LastEditorUserId="123" LastEditDate="2020-02-26T17:50:52.850" LastActivityDate="2020-02-26T17:50:52.850" Title="Equilibria in two player, finite horizon, zero sum stochastic game" Tags="|markov-decision-process|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3608" PostTypeId="1" AcceptedAnswerId="3610" CreationDate="2020-02-27T08:01:30.257" Score="4" ViewCount="406" Body="&lt;p&gt;I have a non-complete graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; vertices and a set &lt;span class=&quot;math-container&quot;&gt;$D \subset V$&lt;/span&gt; that needs to be traveled by a vehicle and then return to source at last.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Binary variables &lt;span class=&quot;math-container&quot;&gt;$b_{i,j}$&lt;/span&gt; represent if the edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is taken or not. &lt;span class=&quot;math-container&quot;&gt;$G_{i,j}$&lt;/span&gt; represent the distance between node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i,j\in V}b_{i,j} \cdot G_{i,j}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below 2 constraints eliminate loops:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j\in V}b_{i,j}  \leq 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j\in V}b_{j,i} \leq 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following constraint ensures that there are only one incoming and one outgoing edges for each node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j\in V}b_{j,i} - \sum_{j\in V}b_{i,j} = 0 \ \ \ \forall j \in V$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below constraint ensures that all the nodes in &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; must be visited. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j\in V}b_{j,i} = 1 \ \ \ \forall i \in D$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MTZ. constraint:  &lt;span class=&quot;math-container&quot;&gt;$\forall (i,j) \in V$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(i,j) \neq D_0$&lt;/span&gt;, i.e., starting node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ U_i - U_j + |V| \cdot b_{i,j} \leq |V| - 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with this model is, it is slow, I am looking for some ways to make it faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I am not able to apply Danzig-Fulkerson-Johnson formulation is that the size of &lt;span class=&quot;math-container&quot;&gt;$V = 72$&lt;/span&gt; so creating all subset is not possible. Another way of doing it is to create a complete graph for &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; and then apply Danzig-Fulkerson-Johnson but I need to know the nodes that are used to reach nodes in set &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; that's why I can't create complete graph also there are other constraints that can change the route to reach nodes in set &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried Desrochers-Laporte formulation but there is no significant difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question is:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to use Danzig-Fulkerson-Johnson formulation in this or some other way to solve the problem faster.&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="123" LastEditDate="2020-02-27T20:31:55.140" LastActivityDate="2020-02-27T20:31:55.140" Title="TSP on a non-complete graph" Tags="|linear-programming|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3609" PostTypeId="2" ParentId="3505" CreationDate="2020-02-27T09:56:30.727" Score="4" Body="&lt;p&gt;I assume that you want to model your problem in OPL. Here is a sketch of the model.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;using CP;&#xA;&#xA;range Hours = 1..24;&#xA;range Machines = 1..5;&#xA;&#xA;// Data are just random:&#xA;int price1[Hours] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24];&#xA;int price2[Hours] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24];&#xA;&#xA;// The ranges are also random:&#xA;dvar int x1[Hours][Machines] in 0..1000;&#xA;dvar int x2[Hours][Machines] in 0..1000;&#xA;dvar int x3[Hours][Machines] in 0..1000;&#xA;dvar int x4[Hours][Machines] in 0..1000;&#xA;&#xA;minimize sum(t in Hours, j in Machines) (x1[t][j] * x2[t][j] * price1[t] - x3[t][j] * x4[t][j]*price2[t]);&#xA;&#xA;subject to {&#xA;  // Your constraints here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2971" LastActivityDate="2020-02-27T09:56:30.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3610" PostTypeId="2" ParentId="3608" CreationDate="2020-02-27T12:54:21.430" Score="6" Body="&lt;p&gt;You are solving a kind of a shortest path problem so you could add a generalized version of the subtour elimination constraints as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{(i,j) \in \delta^+(S)} b_{ij} \geq \sum_{(k,j) \in \delta^+(k)} b_{kj}, \; \forall k \in S, \forall S \subseteq V, |S| \geq 2  $$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\delta^+$&lt;/span&gt; represents the outgoing edges of a set of nodes. Alternatively as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$  \sum_{(i,j) \in E(S)} b_{ij} \leq \sum_{i \in S\setminus (k)} \sum_{(i,j) \in \delta^+(i)} b_{ij}, \; \forall k \in S,\forall S \subseteq V, |S| \geq 2 $$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$E(S)$&lt;/span&gt; being the edges within the node set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at the paper &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S157252861400036X&quot; rel=&quot;noreferrer&quot;&gt;A branch-and-cut algorithm for the capacitated profitable tour problem&lt;/a&gt; by Jepsen et al. for more cuts and separation details. It is for the undirected case but can be modified for the directed case.&lt;/p&gt;&#xA;" OwnerUserId="2791" LastEditorUserId="2791" LastEditDate="2020-02-27T14:37:18.390" LastActivityDate="2020-02-27T14:37:18.390" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="3611" PostTypeId="2" ParentId="3577" CreationDate="2020-02-27T13:41:56.793" Score="5" Body="&lt;p&gt;After the discussion here and a suggestion on my post at gurobi's community I'll post an answer for the forum records.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Concerning the presolve, I found out that in order to check if this is what is getting strange results some parameters to change are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'Presolve':0,&#xA;'Cuts':0,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Turns out that on my problem the issue wasn't bad code of the subgradient method, neither the presolve phase.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that I tightened too much one of the big M in the formulation and this is what produced the subproblem with a strange bound. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks everyone who asked more information and gave suggestions.&lt;/p&gt;&#xA;" OwnerUserId="2397" LastEditorUserId="123" LastEditDate="2020-02-27T20:31:08.837" LastActivityDate="2020-02-27T20:31:08.837" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3612" PostTypeId="1" CreationDate="2020-02-27T14:21:37.777" Score="2" ViewCount="298" Body="&lt;p&gt;I have this model:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad\small{(0.2(1.07)^{-1}+0.2(1.07)^{-2}+0.9(1.07)^{-3})x_A+0.4(1.07)^{-1}+0.5(1.07)^{-2}+0.3(1.07)^{-3})x_B}\\&amp;amp;\quad 0.2x_{A}+0.4x_{B}\geq300\,000&#xA;\\&amp;amp;\quad0.2x_{A}+0.5x_{B}\geq400\,000\\&amp;amp;\quad x_{A}+x_{B}=1\,000\,000 &#xA;\\&amp;amp;\quad x_{A},x_{B}\geq0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have to find &lt;span class=&quot;math-container&quot;&gt;$x_{A}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{B}$&lt;/span&gt; with Excel. How do I set up the program to use the iterative calculus?&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&lt;p&gt;After downloading the add-on, I clicked on Solver but how have I to conduct the objective? And the constraints? I tried setting an hypothetical distribution of total investment (1.000.000), that is 200.000 and 800.000...&lt;a href=&quot;https://i.stack.imgur.com/pnt0m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pnt0m.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;with 360.000=F7&lt;em&gt;G15+F8&lt;/em&gt;H15 and 440.000=G7&lt;em&gt;G15+G8&lt;/em&gt;H15.&lt;/p&gt;&#xA;&lt;p&gt;Then, I set up the Solver in this way…&#xA;&lt;a href=&quot;https://i.stack.imgur.com/CbIKn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CbIKn.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;…but I obtain:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/jm4Eb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jm4Eb.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where I wrong? Is this normal?&lt;/p&gt;&#xA;&lt;p&gt;EDIT 2:&#xA;The early spreadsheet is in my first edit. Then, applying the Solver, I obtain:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tjLxI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tjLxI.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Instead, the solution of the problem is (in all likelihood) the following:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/sYufP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sYufP.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;What I don't understand is how the professor has obtained that particular distribution of the investment (200.000 and 800.000). When I use the Solver I obtain 0 and 800.000, like you can see. It was just a coincidence that I tried, immediately, with the same distribution of the solution (200.000 and 800.000). The point is that I should have gotten the distribution concerned applying the Solver, so I don't understand where I did wrong in the setting up.&#xA;@ Prubin, are you really sure that the setting of the Solver is correct?&lt;/p&gt;&#xA;&lt;p&gt;Moreover, I see now that 200.000 and 800.000 is not the distribution that meet the aim. In fact, for this distribution we have a total revenue of &lt;span class=&quot;math-container&quot;&gt;$1.063.607$&lt;/span&gt;, while by imposing for example 220.000 and 780.000 we obtain &lt;span class=&quot;math-container&quot;&gt;$1.064.423&amp;gt;1.063.607$&lt;/span&gt;. Shouldn'te be the Solver to find, iteratively, the best possible distribution?&lt;/p&gt;&#xA;" OwnerUserId="3116" LastEditorUserId="491" LastEditDate="2023-04-12T12:10:28.067" LastActivityDate="2023-04-12T12:10:28.067" Title="Iterative calculus with Excel" Tags="|optimization|linear-programming|constraint|excel|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3613" PostTypeId="2" ParentId="3612" CreationDate="2020-02-27T16:51:49.737" Score="6" Body="&lt;p&gt;What you are looking for is the &lt;a href=&quot;https://support.office.com/en-us/article/define-and-solve-a-problem-by-using-solver-5d1a388f-079d-43ac-a7eb-f63e45925040&quot; rel=&quot;noreferrer&quot;&gt;Solver&lt;/a&gt; component of Excel. If you are willing and able to use plugins, I can recommend &lt;a href=&quot;https://opensolver.org/&quot; rel=&quot;noreferrer&quot;&gt;OpenSolver&lt;/a&gt;. In addition to a more powerful solver (which you won't need -- your problem is quite small), it adds some &quot;bells and whistles&quot; including a model visualization component.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-02-27T16:51:49.737" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3615" PostTypeId="1" CreationDate="2020-02-28T14:17:15.543" Score="3" ViewCount="46" Body="&lt;p&gt;We're being taught Industrial Engineering and Operations Research for the first time this semester. Referring to the book by Hamdy A. Taha, I noticed the mention of two formulae for swiftly obtaining the dual variable optimal solutions from the primal optimal tableau: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Method 1.&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$${\text{Optimal value of}\\dual\text{ variable }y_i}\quad=\quad{{\text{Optimal primal }z\text{-coefficient of }\\starting\text{ basic variable }x_i}\quad+\quad{Original\text{ objective}\\\text{coefficient of }x_i}}$$&lt;/span&gt; &lt;strong&gt;Method 2.&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$${\text{Optimal values}\\\text{of }dual\text{ variables}}\quad=\quad{\text{Row vector of }original\\\text{objective coefficients of}\\\text{optimal }primal\text{ basic}\\\text{variables}}\quad\times\quad{\text{Optimal }primal\text{ inverse}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Does anyone have an intuitive explanation from how these are derived?&lt;/p&gt;&#xA;" OwnerUserId="3121" LastEditorUserId="123" LastEditDate="2020-02-28T16:19:55.177" LastActivityDate="2020-02-28T16:19:55.177" Title="Derivations for two formulae for obtaining optimal dual variable values from the optimal primal tableau" Tags="|simplex|duality|global-optimality|dual-simplex|dual|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3616" PostTypeId="1" AcceptedAnswerId="3630" CreationDate="2020-02-28T01:30:01.000" Score="3" ViewCount="857" Body="&lt;p&gt;As the title says, in linear programming, is there a way to determine that the shadow price does not change linearly for a resource?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand one way is to simulate but is there a way to tell without simulation i.e.: looking at the variables or objective function, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, if I increase or decrease a certain resource linearly, the profit or cost is not going to increase/decrease linearly.  &lt;/p&gt;&#xA;" OwnerUserId="3118" OwnerDisplayName="Edv Beq" LastActivityDate="2020-03-03T21:12:32.123" Title="In Linear programming, how to determine if shadow price does not change linearly?" Tags="|simulation|linear-programming|simplex|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3617" PostTypeId="1" AcceptedAnswerId="3618" CreationDate="2020-02-29T11:48:19.433" Score="5" ViewCount="250" Body="&lt;p&gt;In TSP wiki it is said that delayed column generation method is used to solve Dantzig-Fulkerson-Johnson formulation as it has an exponential number of possible constraints. I wanted to know whether it is available in the IBM cplex tool or it is a concept needs to be implemented by self.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for some links where the delayed column generation method is implemented.&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="123" LastEditDate="2020-02-29T13:57:00.513" LastActivityDate="2020-02-29T21:14:56.667" Title="Delayed column generation in Dantzig-Fulkerson-Johnson formulation" Tags="|linear-programming|modeling|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3618" PostTypeId="2" ParentId="3617" CreationDate="2020-02-29T21:14:56.667" Score="3" Body="&lt;p&gt;I agree with others that solving TSP with DFJ constraint for subtour elimination does not require implementing a column generation-type algorithm. Instead, you need to implement a cutting plane algorithm or a branch &amp;amp; cut (B&amp;amp;C) algorithm. In the former, you start with the assignment problem formulation, solve the problem, and add the necessary DFJ cuts for the violated subtour elimination constraints. Then, you solve the resulting new problem (commonly, known as the master problem). This process is repeated until no subtour elimination constraint is violated. This process could be time-consuming as you are solving the master problem from scratch every time. The latter approach could enhance the performance as you are solving a MIP formulation using the branch and bound technique, but adding the DFJ cuts for the violated subtour elimination constraints whenever you found a new integer incumbent within the branch and bound tree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the implementation perspective, you can implement the cutting plane approach using a simple &lt;em&gt;for&lt;/em&gt; loop within a programming language. The B&amp;amp;C approach is more tricky as it requires using the callbacks in CPLEX. In older versions of CPLEX, you should use the lazy constraint callback, but you might use the generic callback in the more recent versions. I've not come across any available example for either approach on the web, but you might find it with some luck. Alternatively, you might consult the benders ATSP example within the CPLEX example repository (the corresponding list for each programming language is available from &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/homepages/examplescplex.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;). The example is discussing how to solve the asymmetric TSP using B&amp;amp;C, but adding benders decomposition-type constraint, instead. Changing the code to accommodate for DFJ cuts would be relatively easy from there. You should keep in mind that finding the violated subtour elimination constraints for TSP is equivalent to a graph connectivity problem.&lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2020-02-29T21:14:56.667" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3619" PostTypeId="2" ParentId="3441" CreationDate="2020-02-29T21:21:18.637" Score="8" Body="&lt;p&gt;This may depend on how you define &quot;reduced costs&quot;. If you mean reduced costs as computed by the simplex algorithm, then no, it is not possible that all are strictly positive due to the mechanics of the algorithm. If you mean &lt;span class=&quot;math-container&quot;&gt;$c^\prime - y^{*\prime}A$&lt;/span&gt; for the original variables and &lt;span class=&quot;math-container&quot;&gt;$y^{*\prime} I$&lt;/span&gt; for the surplus variables, where &lt;span class=&quot;math-container&quot;&gt;$y^*$&lt;/span&gt; is &lt;em&gt;any&lt;/em&gt; optimal dual solution, then I think it is possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose that &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is strictly positive in all components (&lt;span class=&quot;math-container&quot;&gt;$c \gg 0$&lt;/span&gt;) and that &lt;span class=&quot;math-container&quot;&gt;$b=0$&lt;/span&gt;. By inspection, &lt;span class=&quot;math-container&quot;&gt;$x^*=0$&lt;/span&gt; is an optimal solution to the primal problem. (I'm assuming &lt;span class=&quot;math-container&quot;&gt;$x\ge 0$&lt;/span&gt; in the primal.) The dual problem is&lt;span class=&quot;math-container&quot;&gt;$$\begin{align*} \max &amp;amp;\quad  b^\prime y \\ \textrm{s.t. } &amp;amp;\quad A^\prime y \le c, \\ &amp;amp; \quad y \ge 0\end{align*}$$&lt;/span&gt;wherein, since &lt;span class=&quot;math-container&quot;&gt;$b=0$&lt;/span&gt;, any feasible &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is optimal. Now let &lt;span class=&quot;math-container&quot;&gt;$y^*\gg 0$&lt;/span&gt; be any feasible (hence optimal) dual solution and let &lt;span class=&quot;math-container&quot;&gt;$\bar{y} = \frac{1}{2} y^* \gg 0$&lt;/span&gt;. By fixing &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and cranking up &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, you should be able to guarantee the existence of a strictly positive feasible &lt;span class=&quot;math-container&quot;&gt;$y^*$&lt;/span&gt;. It is easy to verify that (a) &lt;span class=&quot;math-container&quot;&gt;$\bar{y}$&lt;/span&gt; is feasible (hence optimal) and (b) &lt;span class=&quot;math-container&quot;&gt;$A^\prime y^* \le c \implies A^\prime \bar{y} \ll c$&lt;/span&gt;. So &lt;span class=&quot;math-container&quot;&gt;$c^\prime - \bar{y}^\prime A \gg 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{y}^\prime I \gg 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-02-29T21:21:18.637" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3620" PostTypeId="1" AcceptedAnswerId="3621" CreationDate="2020-03-01T16:23:13.803" Score="6" ViewCount="1015" Body="&lt;p&gt;I have written a small code to do a simple min variance optimisation using CVXOPT, you can see the whole code below&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By using &lt;code&gt;solvers.qp(P, q, G, h, A, b)&lt;/code&gt; in CVXOPT the code runs fine and it finds a solution&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;solvers.qp(P, q, G, h, A, b)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wanted to try a different solver too, hence I used MOSEK by solving the same problem with the following parameters&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;solvers.qp(P, q, G, h, A, b, solver='mosek') &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When using &lt;code&gt;solver='mosek'&lt;/code&gt; the code cannot run and it is giving me the following error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MOSEK error 1295: The quadratic coefficient matrix in the objective is not positive semidefinite as expected for a minimization problem&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain why I got this error (have I coded something in the wrong way?) and if there is a workaround to solve the issue I am facing with MOSEK?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;import cvxopt as opt&#xA;import mosek&#xA;from cvxopt import matrix, solvers&#xA;&#xA;def optimize_portfolio(n, Var_Cov):&#xA;        P = opt.matrix (Var_Cov)&#xA;        q = opt.matrix(np.matrix(np.zeros((n, 1))))&#xA;        G = opt.matrix(np.array(-np.identity(n)))&#xA;        h = opt.matrix(np.zeros((n,1)))             &#xA;        A = opt.matrix(1.0, (1,n))&#xA;        b = opt.matrix(1.0)&#xA;&#xA;        # Finding a solution&#xA;&#xA;        sol = solvers.qp(P, q, G, h, A, b, solver='mosek')&#xA;        return sol&#xA;&#xA;### Parameters setup&#xA;&#xA;Var_Cov = np.loadtxt('C:\VAR_COV.txt')&#xA;n = len (Var_Cov)&#xA;&#xA;### solve&#xA;solution = optimize_portfolio(n, Var_Cov)&#xA;&#xA;# Save Results&#xA;Port_Opt = np.matrix(solution['x'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3128" LastEditorUserId="123" LastEditDate="2020-03-01T19:39:13.963" LastActivityDate="2021-07-19T19:36:00.610" Title="How to run MOSEK solver in CVXOPT" Tags="|optimization|solver|python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3621" PostTypeId="2" ParentId="3620" CreationDate="2020-03-01T18:17:14.167" Score="10" Body="&lt;p&gt;As determined in the comment exchange to the question, because the matrix P has minimum eigenvalue which is negative, it is not positive semidefinite, and therefore it is a non-convex problem. Therefore, Mosek won't accept it, and as you have seen, provided an error message explaining why.&lt;/p&gt;&#xA;&lt;p&gt;Apparently, despite billing itself as a &amp;quot;software package for convex optimization&amp;quot;, CVXOPT is not checking whether the submitted Quadratic Programming problem (QP) is convex, and passes non-convex QP to the specified solver. In the case of Mosek, the solver rejected it as being non-convex. I don't know what type of solution (e.g., local optimum?) solvers.qp provides when provided a non-convex problem. I wouldn't assume it is any kind of valid solution, and I suggest you carefully examine all solvers.qp solver output to see what it says, as well as examining the solution returned.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://cvxopt.org/userguide/coneprog.html?highlight=solvers%20qp#quadratic-programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cvxopt.org/userguide/coneprog.html?highlight=solvers%20qp#quadratic-programming&lt;/a&gt; does not specifically address whether convexity is required for use of solvers.qp. It does mention Mosek as a solver option, but does not explicitly state, as it should, that Mosek requires the matrix to be positive semidefinite.&lt;/p&gt;&#xA;&lt;p&gt;If you want to optimize non-convex QPs, there are a variety of options to solve to either local optimality, or to attempt to solve to global optimality.  CPLEX, Gurobi 9.x, BARON, and some other global solvers can attempt to solve non-convex QPs to global optimality. CPLEX, MATLAB Optimization Toolbox's QUADPROG, and some other (but by no means all, as you have seen) QP solvers, as well as general non-convex nonlinear local solvers can solve for local minimum of non-convex QPs.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Looking at your code, the matrix P is labeled &lt;code&gt;Var_Cov&lt;/code&gt;, presumably meaning Variance Covariance for your portfolio assets. I.e., a covariance matrix, which should (&amp;quot;must&amp;quot;) be positive semidefinite. Given that it is not, I suggest you review the procedure used to generate the covariance matrix. it is either flat out wrong, is based on missing or inconsistent data, or has severe numerical difficulties. That might be the subject for another post at  &lt;a href=&quot;https://stats.stackexchange.com/&quot;&gt;https://stats.stackexchange.com/&lt;/a&gt; or &lt;a href=&quot;https://scicomp.stackexchange.com/&quot;&gt;https://scicomp.stackexchange.com/&lt;/a&gt; , in which case please post a link here to any such new post.  In such case, what you want to do is fix the procedure for generating the covariance matrix, or at least &amp;quot;repair&amp;quot; it to be positive semidefinite; and then use a convex QP solver, such as Mosek.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2021-07-19T19:36:00.610" LastActivityDate="2021-07-19T19:36:00.610" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3622" PostTypeId="1" CreationDate="2020-03-02T11:26:19.327" Score="3" ViewCount="67" Body="&lt;p&gt;In continuation with the previous post, I propose you another problem. &#xA;I have this model: &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad F\\\text{s.t.}&amp;amp;\quad&#xA;F-(1150x_{B_{1}}+1000x_{B_{2}}+1350x_{B_{3}}-S_{1})=430\\&amp;amp;\quad&#xA;(0,0875x_{B_{1}}+0,055x_{B_{2}}+0,1175x_{B_{3}})+1,04S_{1}-S_{2}=210\\&amp;amp;\quad&#xA;(0,0875x_{B_{1}}+0,055x_{B_{2}}+0,1175x_{B_{3}})+1,04S_{2}-S_{3}=222\\ &amp;amp;\quad&#xA;(0,0875x_{B_{1}}+0,055x_{B_{2}}+0,1175x_{B_{3}})+1,04S_{3}-S_{4}=231\\ &amp;amp;\quad&#xA;(0,0875x_{B_{1}}+0,055x_{B_{2}}+0,1175x_{B_{3}})+1,04S_{4}-S_{5}=240\\ &amp;amp;\quad&#xA;(1,0875x_{B_{1}}+0,055x_{B_{2}}+0,1175x_{B_{3}})+1,04S_{5}-S_{6}=195\\ &amp;amp;\quad&#xA;(1,055x_{B_{2}}+0,1175x_{B_{3}})+1,04S_{6}-S_{7}=225\\ &amp;amp;\quad&#xA;(1,1175x_{B_{3}})+1,04S_{7}-S_{8}=255\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Professor says only: &quot;&lt;em&gt;Solving the model with Excel we find...&lt;/em&gt; &quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OBJECTIVE FUNCTION VALUE    --&amp;gt;    1708.669    &#xA;&#xA;VARIABLE        VALUE          REDUCED COST&#xA;     F      1708.668701          0.000000&#xA;    B1       147.734344          0.000000&#xA;    B2       190.845779          0.000000&#xA;    B3       201.342285          0.000000&#xA;    S1       646.116333          0.000000&#xA;    S2       509.226654          0.000000&#xA;    S3       354.861359          0.000000&#xA;    S4       185.321487          0.000000&#xA;    S5         0.000000          0.064025&#xA;    S6         0.000000          0.012614&#xA;    S7         0.000000          0.021318&#xA;    S8         0.000000          0.670839&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Honestly, I really don't know where to put my hands, and in the manuals of Excel I can't find anything who can help me. Would you tell me where to start, at least? &lt;/p&gt;&#xA;" OwnerUserId="3116" LastEditorUserId="123" LastEditDate="2020-03-03T07:08:11.463" LastActivityDate="2020-03-03T07:08:52.493" Title="Iterative calculus with Excel - N° 2" Tags="|optimization|linear-programming|constraint|excel|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3623" PostTypeId="2" ParentId="3622" CreationDate="2020-03-02T21:52:09.133" Score="4" Body="&lt;p&gt;To do linear optimization in Excel you should use the built-in Excel Solver. Here is a good tutorial for &lt;a href=&quot;https://www.excel-easy.com/data-analysis/solver.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;installation and first steps&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be straight-forward to incorporate your problem this way (with proper values see comments). After that you want to use sensitivity analysis to access reduced costs. Find a tutorial &lt;a href=&quot;https://www.excel-easy.com/examples/sensitivity-analysis.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="33" LastEditorUserId="123" LastEditDate="2020-03-03T07:08:52.493" LastActivityDate="2020-03-03T07:08:52.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3624" PostTypeId="1" AcceptedAnswerId="3625" CreationDate="2020-03-03T03:00:08.823" Score="7" ViewCount="875" Body="&lt;p&gt;I have a scheduling problem with one machine and one job. I defined a binary variable &lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt; that is 1 iff the job is scheduled at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; (the job can be served in multiple times that are not consecutive). I would like to find the intervals where the machine is idle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if the job is scheduled at &lt;span class=&quot;math-container&quot;&gt;$t=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t=4$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t=8$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$t=11$&lt;/span&gt;, then the machine is idle between &lt;span class=&quot;math-container&quot;&gt;$t=2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t=3$&lt;/span&gt;, which gives an interval of length &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;. It is idle between &lt;span class=&quot;math-container&quot;&gt;$t=5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t=7$&lt;/span&gt;, which gives an interval of length &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;. And, it is idle between &lt;span class=&quot;math-container&quot;&gt;$t=9$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t=10$&lt;/span&gt;, which gives an interval of length &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I write this using the variable &lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt;? Say, I would like to enforce a constraint that says that the machine must be idle for intervals whose length are shorter than a threshold?&lt;/p&gt;&#xA;" OwnerUserId="3075" LastActivityDate="2020-03-03T03:40:36.537" Title="How to find the idle intervals in integer programming?" Tags="|integer-programming|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3625" PostTypeId="2" ParentId="3624" CreationDate="2020-03-03T03:10:38.987" Score="9" Body="&lt;p&gt;To disallow an idle interval of length &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, you want to enforce the logical proposition&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\neg \bigwedge_{t=s}^{s+k-1} \neg z_t,$$&lt;/span&gt;&#xA;equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\bigvee_{t=s}^{s+k-1} z_t,$$&lt;/span&gt;&#xA;for each starting time &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.&#xA;You can do this via linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{t=s}^{s+k-1} z_t \ge 1.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To instead count the number of idle intervals of length &lt;span class=&quot;math-container&quot;&gt;$\ge k$&lt;/span&gt;,&#xA;introduce another binary variable, say &lt;span class=&quot;math-container&quot;&gt;$x_s$&lt;/span&gt;, that will indicate the start of the interval.  To enforce &#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_s\implies \left(z_{s-1} \land \bigwedge_{t=s}^{s+k-1} \neg z_t\right),$$&lt;/span&gt;&#xA;impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_s &amp;amp;\le z_{s-1} &amp;amp;&amp;amp;\text{for all $s$}\\&#xA;x_s &amp;amp;\le 1- z_t &amp;amp;&amp;amp;\text{for all $s$, $t\in\{s,\dots,s+k-1\}$}\\&#xA;\end{align}&lt;/span&gt;&#xA;To enforce the converse&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left(z_{s-1} \land \bigwedge_{t=s}^{s+k-1} \neg z_t\right)\implies x_s,$$&lt;/span&gt;&#xA;impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z_{s-1} + \sum_{t=s}^{s+k-1} (1 - z_t) - k &amp;amp;\le x_s &amp;amp;&amp;amp;\text{for all $s$}&#xA;\end{align}&lt;/span&gt;&#xA;Now &lt;span class=&quot;math-container&quot;&gt;$\sum_s x_s$&lt;/span&gt; counts the number of idle intervals of length &lt;span class=&quot;math-container&quot;&gt;$\ge k$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-03-03T03:40:36.537" LastActivityDate="2020-03-03T03:40:36.537" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3626" PostTypeId="1" AcceptedAnswerId="3627" CreationDate="2020-03-03T12:14:05.797" Score="6" ViewCount="222" Body="&lt;p&gt;Given a set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; which we need to travel following TSP rules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if this sub tour elimination method is good enough or not?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$b_{i,j}$&lt;/span&gt; denote edge from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is taken or not and &lt;span class=&quot;math-container&quot;&gt;$d_{i,j} &amp;gt; 0$&lt;/span&gt; denotes distance from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_{i,j \in S} d_{i,j} \cdot b_{i,j}\\\text{s.t.}&amp;amp;\quad\sum_{j \in S} b_{j,i} - \sum_{k \in S} b_{i,k} = 0\\&amp;amp;\quad\sum_{j \in S} b_{j,i}  = 1\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$s_0$&lt;/span&gt; be the start node. Now use a continuous variable &lt;span class=&quot;math-container&quot;&gt;$DS_i$&lt;/span&gt; to store the distance at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$DS_{s_0} = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \forall j \in S \setminus \{s_0\}  \quad DS_{j} =  \sum_{i} b_{i,j} \cdot (DS_{i} + d_{i,j}) $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last constraint eliminates the sub-tour in the path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how efficient this sub tour elimination constraint is and how to calculate it. &lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="123" LastEditDate="2020-03-03T13:36:58.497" LastActivityDate="2020-03-03T13:36:58.497" Title="TSP subtour elimination by assigning distance traveled" Tags="|mixed-integer-programming|linear-programming|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3627" PostTypeId="2" ParentId="3626" CreationDate="2020-03-03T12:25:08.173" Score="8" Body="&lt;p&gt;My understanding is that you effectively mimic the Miller, Tucker, Zemlin style of subtour elimination constraints by &quot;pushing a counter along the tour&quot;, these are reportedly not the computationally strongest formulations.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="123" LastEditDate="2020-03-03T13:35:33.370" LastActivityDate="2020-03-03T13:35:33.370" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3628" PostTypeId="1" AcceptedAnswerId="3638" CreationDate="2020-03-03T15:41:07.867" Score="7" ViewCount="1080" Body="&lt;p&gt;I am experimenting around with &lt;code&gt;or-tools&lt;/code&gt; and somehow I can't get a solution for the VRPTW problem for any of the instances I have tested from Gehring &amp;amp; Homberger datasets. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The smallest dataset I have tested is with 200 nodes (+1 for the depot) and 50 vehicles. The longest I have run for is &lt;s&gt;30 minutes&lt;/s&gt; 6 hours (!) and the algorithm I am trying is &lt;code&gt;Automatic&lt;/code&gt; for the &lt;code&gt;FirstSolutionStrategy&lt;/code&gt; and &lt;code&gt;Guided_Local_Search&lt;/code&gt; for the &lt;code&gt;LocalSearchMetaheuristic&lt;/code&gt;. The status I get is &lt;code&gt;3&lt;/code&gt; indicating that the solver cannot find a solution in time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do get a solution if I remove the time window constraints, but the moment I add them back in it cannot find a solution. As far as I have been able to check the modeling and the constraints being set seems about correct. Here is the piece of code that adds the time window constraints. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See code below, note that I have omitted some code for brevity, but this is the most of it anyway. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class OrToolsProblem {&#xA;/** Time windows is  for the locations. Index 0 is that time windows of the depot*/&#xA;  private long[][] timeWindows;&#xA;  /** Array of travel times between locations. Index 0 is the travel distances from depot.*/&#xA;  private long[][] timeMatrix;&#xA;  /** Number of vehicles*/&#xA;  private int vehicleNumber;&#xA;  /** Index of depot.*/&#xA;  private int depotIndex;&#xA;&#xA;  private long[] vehicleCapacities;&#xA;  private long[] demands;&#xA;&#xA;  private RoutingModel routingModel;&#xA;  private Assignment solution;&#xA;  private RoutingIndexManager routingIndexManager;&#xA;&#xA; /* Constructor and methods to set various constraints */&#xA;&#xA;   private void setTimeWindowConstraints() {&#xA;    RoutingDimension timeDimension = routingModel.getMutableDimension(&quot;TravelTime&quot;);&#xA;&#xA;    // add time window constraints for each location except depot.&#xA;    for (int i=1; i &amp;lt; timeWindows.length; i++) {&#xA;      long index = routingIndexManager.nodeToIndex(i);&#xA;      timeDimension.cumulVar(index).setRange(timeWindows[i][0], timeWindows[i][1]);&#xA;    }&#xA;&#xA;    // add time window constraints for each vehicle's start node&#xA;    for (int i=0 ; i &amp;lt; vehicleNumber; i++) {&#xA;      long index = routingModel.start(i);&#xA;      long[] timeWindowsForDepot = timeWindows[0];&#xA;      timeDimension.cumulVar(index).setRange(timeWindowsForDepot[0], timeWindowsForDepot[1]);&#xA;    }&#xA;&#xA;    for(int i=0; i &amp;lt; vehicleNumber; i++) {&#xA;      routingModel.addVariableMinimizedByFinalizer(timeDimension.cumulVar(routingModel.start(i)));&#xA;      routingModel.addVariableMinimizedByFinalizer(timeDimension.cumulVar(routingModel.end(i)));&#xA;    }&#xA;&#xA;&#xA;  }&#xA;    private void setTravelTimeMatrix() {&#xA;    // minimise total travel time&#xA;    final int transitCallBackIndex = routingModel.registerTransitCallback(&#xA;            (long fromIndex, long toIndex) -&amp;gt; {&#xA;              // Convert from routing variable Index to user NodeIndex&#xA;              int fromNode = routingIndexManager.indexToNode(fromIndex);&#xA;              int toNode = routingIndexManager.indexToNode(toIndex);&#xA;              return timeMatrix[fromNode][toNode];&#xA;            }&#xA;    );&#xA;    routingModel.setArcCostEvaluatorOfAllVehicles(transitCallBackIndex);&#xA;    routingModel.addDimension(transitCallBackIndex, 250, Integer.MAX_VALUE, false, &quot;TravelTime&quot;);&#xA;  }&#xA;&#xA;  public void buildProblem() {&#xA;    routingIndexManager = new RoutingIndexManager(timeMatrix.length, vehicleNumber, depotIndex);&#xA;    routingModel = new RoutingModel(routingIndexManager);&#xA;    setCapacityConstrainsts();&#xA;    setTravelTimeMatrix();&#xA;    setTimeWindowConstraints();&#xA;&#xA;    // set service times&#xA;    // Or tools does not support separate service times, hence this is added to the travel time matrix.&#xA;&#xA;    // minimise number of used vehicle&#xA;    routingModel.setFixedCostOfAllVehicles(10000);&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Below is the method that runs the solver:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; public Assignment run() {&#xA;    if (uninitiatedVrpProblem == null || problemType == null)  {&#xA;      throw new NullPointerException(&quot;The variable uninitiatedVrpProblem is not yet initialised. &quot;);&#xA;    }&#xA;&#xA;    uninitiatedVrpProblem.buildProblem();&#xA;    RoutingSearchParameters searchParameters = main&#xA;        .defaultRoutingSearchParameters()&#xA;        .toBuilder()&#xA;        .setFirstSolutionStrategy(FirstSolutionStrategy.Value.AUTOMATIC)&#xA;        .setLocalSearchMetaheuristic(LocalSearchMetaheuristic.Value.GUIDED_LOCAL_SEARCH)&#xA;        .setTimeLimit(Duration.newBuilder().setSeconds(60 * 5).build())&#xA;        .build();&#xA;&#xA;    uninitiatedVrpProblem.solve(searchParameters);&#xA;    this.solvedSolution = uninitiatedVrpProblem.getSolution();&#xA;    return solvedSolution;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas what I am doing wrong, or do I need to simply give it more time? (Though I am confident 30 mins should be more than enough for a problem this small). &lt;/p&gt;&#xA;" OwnerUserId="3124" LastEditorUserId="3124" LastEditDate="2020-03-05T02:57:38.213" LastActivityDate="2020-03-05T02:57:38.213" Title="Solution time out for VRPTW in or-tools" Tags="|or-tools|vehicle-routing|java|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3629" PostTypeId="1" AcceptedAnswerId="3631" CreationDate="2020-03-03T20:25:56.187" Score="4" ViewCount="113" Body="&lt;p&gt;I have the following objective function. The variables: &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$e_{trs}\left(h_p\right), w_{trs}\left(h_p\right)$&lt;/span&gt; are all non-negative continuous. &lt;span class=&quot;math-container&quot;&gt;$T,R,S,\pi_{trs}$&lt;/span&gt; are polynomially-sized sets. All other notations are non-negative parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max\sum_{\substack{t\in T,r\in R,\\s\in S}}\left[e_{trs}\left(h_p\right)+bw_{trs}\left(h_p\right)\right],$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\tag{1} e_{trs}\left(h_p\right)=C_{trs}\left(\sum_{p\in\pi_{trs}}l_p^{trs}\frac{30}{h_p}\right)^{\beta_{trs}}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{2} w_{trs}\left(h_p\right)=\frac{C_{trs}^\prime}{2\left(1-\beta_{trs}\right)}\left[H-\left(\sum_{p\in\pi_{trs}}\frac{l_p^{trs}}{h_p}\right)^{\beta_{trs}-1}\right].$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to solve the problem by using cutting-plane method assuming (I haven't completely checked yet) both functions are convex in &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; in some feasibility domain. So, I want to represent the functions &lt;span class=&quot;math-container&quot;&gt;$e_{trs}\left(h_p\right)=a+bh_p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e_{trs}\left(h_p\right)=c+dh_p$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$a,b,c,d$&lt;/span&gt; are constants that are calculated through derivatives. I think, the barrier here is the &lt;code&gt;max&lt;/code&gt; of the objective function. If it was &lt;code&gt;min&lt;/code&gt;, I could use this approach (correct me if I am wrong) and add cuts iteratively. I thought instead of maximizing this objective, can I minimize &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; and introduce the current objective function as a constraint? See below for a solution attempt. Would these two problems be equivalent?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min\sum_{p\in\pi_{trs}}h_p$$&lt;/span&gt;&#xA;subject to (1) and (2). I feel like this is not correct. But, at the same time, I think, minimizing &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; maximizes the value of the associated functions.&lt;/p&gt;&#xA;" OwnerUserId="518" LastActivityDate="2020-03-03T21:48:09.043" Title="Dealing with a non-convex problem" Tags="|nonlinear-programming|nonconvex-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3630" PostTypeId="2" ParentId="3616" CreationDate="2020-03-03T21:12:32.123" Score="2" Body="&lt;p&gt;The shadow prices are an optimal solution to the dual problem. Adjusting the right-hand side of the primal problem is equivalent to adjusting the objective coefficients of the dual, which changes the slope of the objective hyperplane tangent to the dual feasible region at the dual optimum. Let's assume that the initial dual optimum is non-degenerate, so that the objective hyperplane is tangent to the dual feasible region at just that one point. As you tilt the objective hyperplane more and more, initially the current optimum remains the sole point of tangency. After some amount of tilting, the hyperplane may become tangent to the dual feasible region along an edge (or possibly a higher dimensional face), meaning that the original dual optimum is still optimal but so are other points. Any further tilting and the original dual optimum is no longer a point of tangency, and thus no longer optimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, short version, the shadow prices are initially unchanged as you start to futz with one of the constraint limits, then typically jump to a new dual solution (jump discontinuity). If you start at a degenerate dual optimum and tilt in the right direction, the jump (if any) is immediate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changes in some directions, though, may result in the current shadow prices sticking forever. As a trivial example, consider a maximization primal problem with &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; constraints, and suppose that at the optimum there is one constraint with positive slack (and so zero dual multiplier). If you ratchet up the right-side of that constraint, leaving the others alone, all that happens is that the slack gets bigger, so the dual multiplier for that constraint stays zero (and, for that matter, the other dual multipliers remain the same).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-03-03T21:12:32.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3631" PostTypeId="2" ParentId="3629" CreationDate="2020-03-03T21:48:09.043" Score="5" Body="&lt;p&gt;You want the two functions to be &lt;em&gt;concave&lt;/em&gt; in &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt;, since you are maximizing (convex would be correct if you were minimizing). As to whether minimizing the sum of the &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; would be equivalent, it would not (in general ... I suppose that the two problems could accidentally have the same solution for a specific set of parameters). Any immediate problem with switching to the simpler objective function is that &lt;span class=&quot;math-container&quot;&gt;$\sum_p h_p$&lt;/span&gt; remains constant if you increase one term by some amount and decrease another term by the same amount, whereas it is unlikely that change would be a wash in the original objective function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it's not clear to me that reducing &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; increases the value of the &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; function.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-03-03T21:48:09.043" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3632" PostTypeId="1" AcceptedAnswerId="3633" CreationDate="2020-03-03T22:23:30.860" Score="4" ViewCount="330" Body="&lt;p&gt;In a mathematical model, I have a set &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; of distinct jobs, and a constraint dealing with pairs of elements from the job set. Which of the following is the most accurate way to address two jobs &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j'$&lt;/span&gt; from the set &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;?&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$j,j' \in J$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(j,j') \in J$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$j,j' \in J^2$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(j,j') \in J^2$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In short, I want to know whether I need brackets, and the set should be &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;$J^2$&lt;/span&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;** Perhaps a basic question, but I want to be accurate in my writing.&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="123" LastEditDate="2020-03-04T05:51:46.893" LastActivityDate="2020-03-04T05:51:46.893" Title="How to represent multiple elements of the same set correctly?" Tags="|modeling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3633" PostTypeId="2" ParentId="3632" CreationDate="2020-03-03T22:27:27.553" Score="9" Body="&lt;p&gt;Definitely not 2 or 3.  1 is often used but a little informal.  4 is most accurate.&#xA;Two more suggestions:&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;5&quot;&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$j\in J,\ j'\in J$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$(j,j')\in J\times J$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-03-03T23:22:44.643" LastActivityDate="2020-03-03T23:22:44.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3634" PostTypeId="1" AcceptedAnswerId="3635" CreationDate="2020-03-04T00:31:23.760" Score="8" ViewCount="840" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$0\leq \beta\leq 1$&lt;/span&gt; be an objective variable. The size of &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$N\!\times\!N$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, how can I impose the following?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$\beta_{i,j}&amp;gt;0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\beta_{j,i}=0$&lt;/span&gt; &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Big M notation can be one of the possible ways, however, I am unable to proceed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;[&lt;a href=&quot;http://ask.cvxr.com/t/how-to-add-if-else-condition-for-the-objective-variable/7127&quot; rel=&quot;noreferrer&quot;&gt;post in CVX forum&lt;/a&gt;]&lt;/p&gt;&#xA;" OwnerUserId="3136" LastActivityDate="2020-03-04T00:49:09.603" Title="if-else condition for the objective variable using big M notation" Tags="|optimization|linear-programming|reference-request|linearization|big-m|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3635" PostTypeId="2" ParentId="3634" CreationDate="2020-03-04T00:44:06.600" Score="6" Body="&lt;p&gt;Introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; to indicate whether &lt;span class=&quot;math-container&quot;&gt;$\beta_{i,j}&amp;gt;0$&lt;/span&gt; and linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\beta_{i,j} &amp;amp;\le x_{i,j}\\&#xA;x_{i,j} + x_{j,i} &amp;amp;\le 1&#xA;\end{align}&lt;/span&gt;&#xA;(The big-M here is 1.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first constraint enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\beta_{i,j}&amp;gt;0 \implies x_{i,j} = 1.$$&lt;/span&gt;&#xA;The second constraint enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{i,j} = 1 \implies x_{j,i} = 0.$$&lt;/span&gt;&#xA;The first constraint enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{j,i} = 0 \implies \beta_{j,i} \le 0.$$&lt;/span&gt;&#xA;The lower bound on &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\beta_{j,i} \le 0 \implies \beta_{j,i} = 0.$$&lt;/span&gt;&#xA;So&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\beta_{i,j}&amp;gt;0 \implies \beta_{j,i} = 0,$$&lt;/span&gt;&#xA;as desired.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-03-04T00:49:09.603" LastActivityDate="2020-03-04T00:49:09.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3636" PostTypeId="1" AcceptedAnswerId="3639" CreationDate="2020-03-04T00:56:18.500" Score="3" ViewCount="958" Body="&lt;p&gt;I have a linear program in the MPS file format listing all the rows, columns, right-hand sides, etc. I can read that in Matlab and solve it using linprog. However, it seems there is no easy way to do sensitivity analysis for the right-hand side coefficients. I have to do the sensitivity analysis in Matlab as no other software is available. I would appreciate it if you could refer me to some ways I can accomplish that in Matlab.&lt;/p&gt;&#xA;" OwnerUserId="2546" LastActivityDate="2020-03-04T20:05:11.987" Title="Linear programming sensitivity analysis using Matlab" Tags="|optimization|linear-programming|matlab|sensitivity-analysis|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3638" PostTypeId="2" ParentId="3628" CreationDate="2020-03-04T15:42:37.047" Score="4" Body="&lt;p&gt;Ok so I have figured out a way to speed up the solver and have it return a solution. Key here seems to be adding the following method. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; public void setDisjunction() {                                                                                               &#xA;   long penalty = 100000;                                                                                                  &#xA;   for (int i =1; i &amp;lt; timeMatrix.length; i++) {                                                                            &#xA;     routingModel.addDisjunction(new long[] {routingIndexManager.nodeToIndex(i)}, penalty);                                &#xA;   }                                                                                                                       &#xA; }                                                                                                                         &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; public void buildProblem() {                                                                                                        &#xA;   routingIndexManager = new RoutingIndexManager(timeMatrix.length, vehicleNumber, depotIndex);                                      &#xA;   routingModel = new RoutingModel(routingIndexManager);                                                                             &#xA;   setCapacityConstrainsts();                                                                                                        &#xA;   setTravelTimeMatrix();                                                                                                            &#xA;   setTimeWindowConstraints();                                                                                                       &#xA;   setDisjunction();                                                                                                                    &#xA;   // set service times                                                                                                              &#xA;   // Or tools does not support separate service times, hence this is added to the travel time matrix.                               &#xA;&#xA;   // minimise number of used vehicle                                                                                                &#xA;   routingModel.setFixedCostOfAllVehicles(10000);                                                                                    &#xA; }                                                                                                                                   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See explanation for what &lt;code&gt;addDisjunction&lt;/code&gt; does &lt;a href=&quot;https://developers.google.com/optimization/routing/penalties#overview&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. Now I don't know the internals of or-tools that well, but my understanding is that the first solution strategy is unable to build a feasible solution as the problem has too many constraints. However, doing this I noticed it doesn't visit all nodes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll update my answer when I found out what set of parameters make it visit all nodes. &lt;/p&gt;&#xA;" OwnerUserId="3124" LastEditorUserId="123" LastEditDate="2020-03-04T20:05:30.847" LastActivityDate="2020-03-04T20:05:30.847" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3639" PostTypeId="2" ParentId="3636" CreationDate="2020-03-04T15:58:12.733" Score="2" Body="&lt;p&gt;As documented at &lt;a href=&quot;https://www.mathworks.com/help/optim/ug/linprog.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.mathworks.com/help/optim/ug/linprog.html&lt;/a&gt;, linprog returns the Lagranage multipliers via the optional 5th output argument, lambda.  What are called Lagrange Multipliers by linprog and in Nonlinear Programming (optimization) are more usually called dual values in Linear Programming. So perhaps that is why you did not realize linprog provides them.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[x,fval,exitflag,output,lambda] = linprog(___) additionally returns a&#xA;  structure lambda whose fields contain the Lagrange multipliers at the&#xA;  solution x.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;lambda is a structure which contains the fields&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lower&#xA;upper&#xA;eqlin&#xA;ineqlin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for lower bounds, upper bounds, equality constraints, and inequality constraints respectively.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2020-03-04T20:05:11.987" LastActivityDate="2020-03-04T20:05:11.987" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3640" PostTypeId="1" AcceptedAnswerId="3641" CreationDate="2020-03-04T17:43:36.460" Score="4" ViewCount="170" Body="&lt;p&gt;Sort of following up with &lt;a href=&quot;https://or.stackexchange.com/questions/3629/dealing-with-a-non-convex-problem/3631#3631&quot;&gt;this&lt;/a&gt; question. I reformulated another model to make it convex and possibly solve it with some cut generation method. I would like to double-check whether I am doing it correctly. Below is the nonlinear model due to &lt;span class=&quot;math-container&quot;&gt;$1/h_p$&lt;/span&gt;. The variable &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; is non-negative continuous and satisfies &lt;span class=&quot;math-container&quot;&gt;$H^- \leq h_p \leq H^+$&lt;/span&gt;. The parameters: &lt;span class=&quot;math-container&quot;&gt;$f_p,B_p,\tau_p,M,H^-,H^+$&lt;/span&gt; are non-negative real numbers. The set &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is polynomially-sized. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\min &amp;amp;\quad \mathbf{C} = \sum_{p\in P}\frac{h_p}{2}\tag1\\\text{s.t.}&amp;amp;\quad \frac{f_ph_p}{30}\leq B_p \qquad \forall p\in P\tag2\\&amp;amp;\quad\sum_{p\in P}\frac{\tau_p}{h_p} \leq M\tag3\\&amp;amp;\quad h_p\in \mathbb{R}^+, H^- \leq h_p \leq H^+.\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Theorem 1:&lt;/strong&gt; Assume &lt;span class=&quot;math-container&quot;&gt;$\phi_p\left(h_p\right)=\frac{\tau_p}{h_p}$&lt;/span&gt;. Then, &lt;span class=&quot;math-container&quot;&gt;$\phi_p\left(h_p\right)$&lt;/span&gt; is convex in &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; under the domains &lt;span class=&quot;math-container&quot;&gt;$h_p,\tau_p\in\mathbb{R}^+$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Proof:&lt;/strong&gt; Showing the second derivative of &lt;span class=&quot;math-container&quot;&gt;$\phi_p\left(h_p\right)$&lt;/span&gt; with respect to &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; being non-negative will prove the convexity. Since &lt;span class=&quot;math-container&quot;&gt;$\frac{d^2 \phi_p\left(h_p\right)}{dh_p^2}=\frac{2\tau_p}{h_p^3}\geq 0$&lt;/span&gt; in the domains &lt;span class=&quot;math-container&quot;&gt;$h_p,\tau_p\in\mathbb{R}^+$&lt;/span&gt;, my proof is complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will introduce &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; to represent the new definition assuming &lt;span class=&quot;math-container&quot;&gt;$\phi_p\equiv\phi_p\left(h_p\right)$&lt;/span&gt;. Due to &lt;strong&gt;Theorem 1&lt;/strong&gt;, I will say &lt;span class=&quot;math-container&quot;&gt;$a_p+b_p h_p$&lt;/span&gt; supports &lt;span class=&quot;math-container&quot;&gt;$\phi_p\left(h_p\right)$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$h_p=\tilde{h}_p$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$a_p=\phi_p\left(\tilde{h}_p\right)-b\tilde{h}_p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_p=\frac{d\phi_p\left(\tilde{h}_p\right)}{d\tilde{h}_p}$&lt;/span&gt;. So, if I introduce the cut constraint &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; to the problem &lt;span class=&quot;math-container&quot;&gt;$(1)-(2), ~(4)$&lt;/span&gt; iteratively, I expect to solution to converge to optimality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\sum_{p\in P}\phi_p&amp;amp;\leq M\,\tag4\\\phi_p &amp;amp;\geq a_p+b_p h_p.\tag5\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my planned solution procedure. Solve &lt;span class=&quot;math-container&quot;&gt;$(1)-(2),~(4)$&lt;/span&gt; with non-negativity conditions with &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; boundary and &lt;span class=&quot;math-container&quot;&gt;$\phi_p\geq 0 $&lt;/span&gt;. The solution is &lt;span class=&quot;math-container&quot;&gt;$h_p=H^-~\forall p\in P$&lt;/span&gt; due to minimization assuming &lt;span class=&quot;math-container&quot;&gt;$30B_p/f_p\geq H^-$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; is not satisfied with this solution, feed the solution &lt;span class=&quot;math-container&quot;&gt;$H^-$&lt;/span&gt; into &lt;span class=&quot;math-container&quot;&gt;$\tilde{h}_p$&lt;/span&gt;, introduce &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt;, resolve the problem...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sort of stuck with the solution procedure as I cannot really determine the termination criterion. I know I find a lower bound to &lt;span class=&quot;math-container&quot;&gt;$\mathbf{C}$&lt;/span&gt; by iteratively solving. But, how can I calculate the upper bound (call it &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat{C}}$&lt;/span&gt;)? If I could understand it, I would say while the gap between the bounds are less than a satisfactory ratio, keep adding cuts; terminate when gap satisfies the ratio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any better approach to attack solving this problem?&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="518" LastEditDate="2020-03-17T18:02:41.470" LastActivityDate="2020-03-17T18:02:41.470" Title="Cutting-planes application procedure for a specific problem" Tags="|convex-optimization|cutting-planes|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3641" PostTypeId="2" ParentId="3640" CreationDate="2020-03-04T23:28:11.887" Score="4" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$|P|$&lt;/span&gt; is not too large, you could try an integer programming formulation. Fix an integer &lt;span class=&quot;math-container&quot;&gt;$N&amp;gt;1$&lt;/span&gt; (which will control the granularity of the approximation) and let &lt;span class=&quot;math-container&quot;&gt;$\Delta=\frac{H^+ - H^-}{N}$&lt;/span&gt;. For each &lt;span class=&quot;math-container&quot;&gt;$p\in P$&lt;/span&gt; and each &lt;span class=&quot;math-container&quot;&gt;$n\in \lbrace 0,\dots, N\rbrace$&lt;/span&gt;, introduce variable &lt;span class=&quot;math-container&quot;&gt;$t_{p,n}\in [0,1]$&lt;/span&gt;. Now add the constraints&lt;span class=&quot;math-container&quot;&gt;$$\sum_{n=0}^N t_{p,n} = 1\quad \forall p$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$h_p = H^- + \sum_{n=0}^N t_{p,n} \cdot (n\Delta).$$&lt;/span&gt;Also force &lt;span class=&quot;math-container&quot;&gt;$\lbrace t_{p,0},\dots, t_{p,N}\rbrace$&lt;/span&gt; to be a &lt;a href=&quot;https://en.wikipedia.org/wiki/Special_ordered_set#Types_of_SOS&quot; rel=&quot;nofollow noreferrer&quot;&gt;type 2 special ordered set&lt;/a&gt; (SOS2), which is what makes the problem an integer program. You will need an integer programming solver that understands the SOS2 designation (or else you will need to enforce it with an alternative formulation, which is possible). In essence, what this does is discretize the interval &lt;span class=&quot;math-container&quot;&gt;$[H^-,H^+]$&lt;/span&gt; and express each &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; as a convex combination of two adjacent grid points in the interval.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we address your constraint (3). Replace the left side of (3) with &lt;span class=&quot;math-container&quot;&gt;$$\sum_{p\in P}\sum_{n=0}^N \left(\frac{\tau_p}{H^- + n\Delta}\right) t_{p,n}.$$&lt;/span&gt; This interpolates each &lt;span class=&quot;math-container&quot;&gt;$\phi_p()$&lt;/span&gt; linearly, so it's an approximation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming your solver can solve the approximate model, calculate the discrepancy if any in (3). If you can live with it, great. If not, you can try tightening the approximation of each &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; in the vicinity of its &quot;optimal&quot; value. I posed the initial approximation as a uniform grid for simplicity, but in fact you can space the grid points any way you like. So to refine your solution, you can increase the density of grid points near the values the solver chose for the &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; and optionally reduce the density elsewhere to conserve model size.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-03-04T23:28:11.887" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3642" PostTypeId="1" AcceptedAnswerId="3643" CreationDate="2020-03-05T09:11:44.920" Score="6" ViewCount="273" Body="&lt;p&gt;I am looking for a constraint to express the following: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;IF W1 = 0 AND W2 = 0 THEN Y = 1  &lt;br/&gt;&#xA;IF W1 = 0 AND W2 = 1 THEN Y = 1 &lt;br/&gt;&#xA;IF W1 = 1 AND W2 = 0 THEN Y = 0 &lt;br/&gt;&#xA;IF W1 = 1 AND W2 = 1 THEN Y &amp;lt;= 1&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Variables W1, W2, Y are binaries. &#xA;Y is determined by the aforementioned relations. &#xA;So, I am looking for an expression Y(W1,W2) =  ???    &lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2020-03-05T15:10:30.690" Title="How can this be expressed as a MILP constraint?" Tags="|mixed-integer-programming|constraint|binary-variable|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3643" PostTypeId="2" ParentId="3642" CreationDate="2020-03-05T09:58:42.980" Score="6" Body="&lt;p&gt;The following should work :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;1-\omega_1 &amp;amp;\le y \\&#xA;\omega_1 - \omega_2 &amp;amp;\le 1- y&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$\omega_1 = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\omega_2 \in \{0,1\}$&lt;/span&gt;, then the equations hold only if &lt;span class=&quot;math-container&quot;&gt;$y = 1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$\omega_1 = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\omega_2 = 0$&lt;/span&gt;, then the equations hold only if  &lt;span class=&quot;math-container&quot;&gt;$y = 0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$\omega_1 = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\omega_2 = 1$&lt;/span&gt;, then the equations hold if  &lt;span class=&quot;math-container&quot;&gt;$y \in \{ 0,1\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2020-03-05T11:29:08.667" LastActivityDate="2020-03-05T11:29:08.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3644" PostTypeId="1" AcceptedAnswerId="3655" CreationDate="2020-03-05T12:43:27.127" Score="41" ViewCount="6677" Body="&lt;p&gt;Is anyone aware of a medicine/vaccine related challenges with a good problem definition and some available input datasets, ideally related to COVID-19? What kind of constraint solving challenges would that be? &lt;a href=&quot;https://en.wikibooks.org/wiki/Structural_Biochemistry/Proteins/Protein_Folding_Problem&quot; rel=&quot;noreferrer&quot;&gt;Protein folding?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there are any such constraint solving problem, we could drop them in GitHub and maybe crowd solve them in the community. If public life gets as limited as in China and Northern Italy, we'll have plenty of time on our hands anyway :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATES&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The primary goal right now is to find &lt;strong&gt;a solid problem definition for COVID-19 protein folding&lt;/strong&gt;. The most promising references so far:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://fold.it/portal/node/2008963&quot; rel=&quot;noreferrer&quot;&gt;FoldIt&lt;/a&gt; - not investigated yet (credits: Mast)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://foldingforum.org/viewtopic.php?f=17&amp;amp;t=32261&amp;amp;e=0&quot; rel=&quot;noreferrer&quot;&gt;Folding@Home&lt;/a&gt; - asked on forum, not yet investigated further (credits: Sebastian)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gisaid.org/&quot; rel=&quot;noreferrer&quot;&gt;GISAID datasets&lt;/a&gt; - not investigated yet (credits: Joe)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you're investigating any of these to find a problem definition, add a comment below. Also edit this question with your results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Other use cases&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.kaggle.com/sudalairajkumar/novel-corona-virus-2019-dataset&quot; rel=&quot;noreferrer&quot;&gt;COVID-19 cases (Kaggle user)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="350" LastEditorUserId="51" LastEditDate="2022-05-15T19:43:39.643" LastActivityDate="2022-05-15T19:43:39.643" Title="Are there any COVID-19 (coronavirus) related optimization problems with input datasets that we can &quot;crowd solve&quot;?" Tags="|practical-or|medical-application|" AnswerCount="10" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3645" PostTypeId="2" ParentId="3642" CreationDate="2020-03-05T13:47:32.167" Score="3" Body="&lt;p&gt;@Kuifje’s answer is correct. Here’s how you can obtain the constraints via conjunctive normal form. The first two propositions can be combined, and the fourth proposition is a tautology, so we want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(\neg W_1\implies Y)\land ((W_1\land \neg W_2)\implies\neg Y).$$&lt;/span&gt;&#xA;Rewriting in conjunctive normal form yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(W_1\lor Y)\land ((\neg W_1\lor W_2)\lor\neg Y)\\&#xA;(W_1+Y\ge 1)\land (1-W_1+W_2+1-Y\ge 1)\\&#xA;(Y\ge 1-W_1)\land (1-Y\ge W_1-W_2).&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-03-05T15:10:30.690" LastActivityDate="2020-03-05T15:10:30.690" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3646" PostTypeId="1" AcceptedAnswerId="3647" CreationDate="2020-03-05T14:41:09.287" Score="-4" ViewCount="152" Body="&lt;p&gt;I am looking for a constraint to express the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IF W1 = 0 AND W2 = 0 THEN Y = 0 &lt;br/&gt;&#xA;IF W1 = 0 AND W2 = 1 THEN Y = 1 &lt;br/&gt; &#xA;IF W1 = 1 AND W2 = 0 THEN Y = 0 &lt;br/&gt;&#xA;IF W1 = 1 AND W2 = 1 THEN Y &amp;lt;= 1 &lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Variables W1, W2, Y are binaries. &#xA;Y is determined by the aforementioned relations. &lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2020-03-14T19:06:58.340" Title="How can I model this binary logic?" Tags="|mixed-integer-programming|constraint|binary-variable|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3647" PostTypeId="2" ParentId="3646" CreationDate="2020-03-05T15:17:01.957" Score="6" Body="&lt;p&gt;As in your other question, the fourth proposition is a tautology.  The other three propositions can be expressed as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;((\neg W_1 \land \neg W_2) \implies \neg Y)&#xA;\land&#xA;((\neg W_1 \land W_2) \implies Y)&#xA;\land&#xA;((W_1 \land \neg W_2) \implies \neg Y)&#xA;$$&lt;/span&gt;&#xA;More simply, combine your first and third propositions and omit the fourth one to obtain&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(\neg W_2 \implies \neg Y)&#xA;\land&#xA;((\neg W_1 \land W_2) \implies Y)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now rewrite in &lt;a href=&quot;https://en.wikipedia.org/wiki/Conjunctive_normal_form&quot; rel=&quot;nofollow noreferrer&quot;&gt;conjunctive normal form&lt;/a&gt;, by replacing &lt;span class=&quot;math-container&quot;&gt;$P \implies Q$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\neg P \lor Q$&lt;/span&gt;, pushing &lt;span class=&quot;math-container&quot;&gt;$\neg$&lt;/span&gt; inwards, and distributing &lt;span class=&quot;math-container&quot;&gt;$\lor$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$\land$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(W_2 \lor \neg Y) \land ((W_1 \lor \neg W_2) \lor Y)\\&#xA;(W_2 + (1 - Y) \ge 1) \land (W_1 + (1 - W_2) + Y \ge 1)\\&#xA;(W_2 \ge Y) \land (W_1 + Y \ge W_2)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Several other examples are &lt;a href=&quot;https://or.stackexchange.com/search?q=%22conjunctive%20normal%20form%22&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good reference for this is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Raman, R. and I.E. Grossmann, &lt;em&gt;Relation Between MILP Modelling and Logical Inference for Chemical Process Synthesis&lt;/em&gt;, &lt;strong&gt;Computers Chem. Engng.&lt;/strong&gt; 15 (1991).&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-03-05T17:57:51.530" LastActivityDate="2020-03-05T17:57:51.530" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3648" PostTypeId="2" ParentId="3644" CreationDate="2020-03-05T17:46:31.493" Score="10" Body="&lt;p&gt;I was thinking of ( no data but):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;determining which airline routes to block that will minimize the economic consequences given a very low risk of getting to the virus (like a chance constraint or robustness), kind of a stochastic edge removal problem.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;determining whom and when to vaccine first (whenever they find it). Kind of a stochastic node blocking problem with some time index to minimize the expected number of infected people.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Recently i saw these links that contain some data&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://deepmind.com/research/open-source/computational-predictions-of-protein-structures-associated-with-COVID-19&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://deepmind.com/research/open-source/computational-predictions-of-protein-structures-associated-with-COVID-19&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://science.sciencemag.org/content/early/2020/03/05/science.aba9757&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://science.sciencemag.org/content/early/2020/03/05/science.aba9757&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="632" LastEditorUserId="632" LastEditDate="2020-03-10T14:45:44.647" LastActivityDate="2020-03-10T14:45:44.647" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3649" PostTypeId="2" ParentId="3298" CreationDate="2020-03-05T22:50:56.807" Score="6" Body="&lt;p&gt;SAA is a very widely used technique for stochastic optimization problems and as far as I can see there are two frequently used approaches for the implementation of SAA. Please check &lt;a href=&quot;http://mansci-web.uai.cl/~thmello/pubs/MC%20review%20SORMS.pdf&quot; rel=&quot;noreferrer&quot;&gt;Homem-de-Mello&lt;/a&gt;'s survey paper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will give you some references on a very specific problem (Influence Maximization) where these approaches are applied. In &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0167637714001606&quot; rel=&quot;noreferrer&quot;&gt;Lee2015&lt;/a&gt;, &lt;a href=&quot;https://link.springer.com/article/10.1007%2Fs10589-017-9958-x&quot; rel=&quot;noreferrer&quot;&gt;Wu2017&lt;/a&gt;, &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2018/12/6985.pdf&quot; rel=&quot;noreferrer&quot;&gt;Guney2018b&lt;/a&gt; a single batch of scenarios is used with a sample size as large as possible.&#xA;This falls into Single Replication Procedure (SRP) category of SAA procedure as described in &lt;a href=&quot;http://mansci-web.uai.cl/~thmello/pubs/MC%20review%20SORMS.pdf&quot; rel=&quot;noreferrer&quot;&gt;Homem-de-Mello&lt;/a&gt;'s survey paper. In this case, most of the time the quality of approximations is rather not the major concern and no extra statistical information is provided (such as confidence intervals)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in &lt;a href=&quot;https://link.springer.com/article/10.1007/s12351-017-0305-x&quot; rel=&quot;noreferrer&quot;&gt;Guney2019&lt;/a&gt;, &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0020025519306504&quot; rel=&quot;noreferrer&quot;&gt;Guney2019b&lt;/a&gt;, multiple batches with smaller sample sizes are used that yield smaller integer programs which consume less memory and CPU time.&#xA;This method is named as Multiple Replication Procedure (MRP) in &lt;a href=&quot;http://mansci-web.uai.cl/~thmello/pubs/MC%20review%20SORMS.pdf&quot; rel=&quot;noreferrer&quot;&gt;Homem-de-Mello&lt;/a&gt;.&#xA;The advantage of MRP is, when the number of batches is sufficiently large (&lt;span class=&quot;math-container&quot;&gt;$\geq 20$&lt;/span&gt;), the Central Limit Theorem can be induced to provide&#xA;&lt;span class=&quot;math-container&quot;&gt;$1-\alpha$&lt;/span&gt; confidence intervals to make a statistical assessment on the quality of the approximations.&#xA;As mentioned in &lt;a href=&quot;http://mansci-web.uai.cl/~thmello/pubs/MC%20review%20SORMS.pdf&quot; rel=&quot;noreferrer&quot;&gt;Homem-de-Mello&lt;/a&gt; it is still possible to build confidence intervals with SRP, however it requires the satisfaction of additional conditions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some further reading I would recommend:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007%2Fs10479-006-6169-8&quot; rel=&quot;noreferrer&quot;&gt;Linderoth (2006)&lt;/a&gt; A very nice implementation of classical MRP&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.optimization-online.org/DB_HTML/2019/02/7068.html&quot; rel=&quot;noreferrer&quot;&gt;Pasupathy (2019)&lt;/a&gt; Optimal sample size sequence determination&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-017-1174-z&quot; rel=&quot;noreferrer&quot;&gt;Bertsimas (2017)&lt;/a&gt; Robust SAA&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In terms of implementation, the SRP is very simple, usually you create your scenarios / do the sampling and just take the average. For MRP, there are different ways. One of them is having a fixed MRP size with all equal sample sizes. Another approach is: in each replication increasing the sample size (until you are happy with your approximation quality) and just consider your last replication's results.&lt;/p&gt;&#xA;" OwnerUserId="632" LastEditorUserId="632" LastEditDate="2020-03-05T22:56:20.460" LastActivityDate="2020-03-05T22:56:20.460" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3650" PostTypeId="2" ParentId="3644" CreationDate="2020-03-06T06:51:58.927" Score="10" Body="&lt;p&gt;There is the following &lt;strong&gt;data set&lt;/strong&gt; on the number of infections in China provided by Isaac Lin from the University of Hong Kong.&#xA;&lt;a href=&quot;https://github.com/BlankerL/DXY-COVID-19-Data/blob/master/README.en.md&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/BlankerL/DXY-COVID-19-Data/blob/master/README.en.md&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure how reliable the data is, but it’s the best I could find. And from a first look, the numbers are close to what the German news are communicating. &#xA;Isaac has created a web crawler which is also available on GitHub&#xA;&lt;a href=&quot;https://github.com/BlankerL/DXY-COVID-19-Crawler/blob/master/README.en.md&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/BlankerL/DXY-COVID-19-Crawler/blob/master/README.en.md&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was made aware of this data set when looking for visualizations of time trends and model predictions of confirmed cases on his website. E.g., &lt;a href=&quot;https://ncov2020.org/en/en/predict-2020-03-05/&quot; rel=&quot;noreferrer&quot;&gt;https://ncov2020.org/en/en/predict-2020-03-05/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="670" LastActivityDate="2020-03-06T06:51:58.927" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3651" PostTypeId="1" AcceptedAnswerId="3656" CreationDate="2020-03-06T11:51:34.850" Score="3" ViewCount="389" Body="&lt;p&gt;I would like to set a stop condition combined of a timelimit and a relative MIP gap.&#xA;So I would like AMPL/CPLEX to look for the solution of my LP for an hour and if there isn't a solution stop if or as soon as a relative MIP gap of X percent has been reached.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For clarification, could you try to explain to me the exact meaning of a MIP gap? I was looking for a second stop condition to get at least somewhat close to a solution and not randomly stopping after time X has passed. I understand the relative MIP gap as an educated guess on how much the currently found solution is distant from the best possible solution therefore &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{\text{current objective function result}}{\text{best possible objective function result}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but the actual relative MIP gap seems to be a little bit more complicated&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relative tolerance for optimizing integer variables: stop if &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{abs}((\text{best bound}) - (\text{best integer})) &amp;lt; \text{mipgap} \times (1 + \text{abs}(\text{best bound})).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{Default} = 1\cdot 10^{-4}$&lt;/span&gt; must be between &lt;span class=&quot;math-container&quot;&gt;$1\cdot 10^{-9}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure how exactly best bound and best integer is defined, on the other hand I am not even close to an expert in optimisation stuff.&lt;/p&gt;&#xA;" OwnerUserId="2989" LastEditorUserId="123" LastEditDate="2020-03-06T13:25:42.540" LastActivityDate="2020-12-28T23:39:14.040" Title="How to set combined stop condition in AMPL/CPLEX?" Tags="|linear-programming|cplex|ampl|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3652" PostTypeId="1" AcceptedAnswerId="5043" CreationDate="2020-03-06T12:23:39.447" Score="3" ViewCount="175" Body="&lt;p&gt;I am using to solve my model Pyomo/CBC combination. But rarely, CBC Gap shows 1.#j and pyomo generate an error. Hence, it doesn't get solution. How can I solve this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screen output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Result - Stopped on time limit&#xA;&#xA;Objective value:                26848000.00000000&#xA;Lower bound:                    0.000&#xA;Gap:                            1.#J&#xA;Enumerated nodes:               336653&#xA;Total iterations:               620783&#xA;Time (CPU seconds):             62.14&#xA;Time (Wallclock seconds):       62.14&#xA;&#xA;Total time (CPU seconds):       62.15   (Wallclock seconds):       62.15&#xA;&#xA;ERROR:writeSql:could not convert string to float: '1.#J'&#xA;Traceback (most recent call last):&#xA;.&#xA;.&#xA;.&#xA;opt_success = opt.solve(model, tee=True)&#xA;File &quot;C:\Users\python\AppData\Local\Programs\Python\Python37\lib\site-packages&#xA;\pyomo\opt\base\solvers.py&quot;, line 605, in solve&#xA;result = self._postsolve()&#xA;File &quot;C:\Users\python\AppData\Local\Programs\Python\Python37\lib\site-packages&#xA;\pyomo\solvers\plugins\solvers\CBCplugin.py&quot;, line 870, in _postsolve&#xA;results = super(CBCSHELL, self)._postsolve()&#xA;File &quot;C:\Users\python\AppData\Local\Programs\Python\Python37\lib\site-packages&#xA;\pyomo\opt\solver\shellcmd.py&quot;, line 270, in _postsolve&#xA;results = self.process_output(self._rc)&#xA;File &quot;C:\Users\python\AppData\Local\Programs\Python\Python37\lib\site-packages&#xA;\pyomo\opt\solver\shellcmd.py&quot;, line 327, in process_output&#xA;results = self.process_logfile()&#xA;File &quot;C:\Users\python\AppData\Local\Programs\Python\Python37\lib\site-packages&#xA;\pyomo\solvers\plugins\solvers\CBCplugin.py&quot;, line 563, in process_logfile&#xA;gap = float(tokens[1])&#xA;ValueError: could not convert string to float: '1.#J'&#xA;Error &amp;lt;class 'ValueError'&amp;gt; value could not convert string to float: '1.#J' diger&#xA;&amp;lt;traceback object at 0x000000000D0F0288&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My solution is changing CBCplugin.py related line with try-except. But I can not predict potential side effects on pyomo.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My answer:&#xA;I changed CBCplugin.py, line 563:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; gap = float(tokens[1])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  try:&#xA;      gap = float(tokens[1])&#xA;  except:&#xA;      gap = 0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="432" LastEditorUserId="432" LastEditDate="2020-03-10T09:24:02.353" LastActivityDate="2020-10-15T19:28:25.310" Title="Pyomo CBC 1.#j error" Tags="|pyomo|cbc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3653" PostTypeId="1" CreationDate="2020-03-06T14:20:08.397" Score="3" ViewCount="660" Body="&lt;p&gt;I am trying to solve a scheduling problem in OR-Tools. There are lots of &quot;events&quot; that need to be scheduled to &quot;blocks&quot; (essentially half-days). I am naturally using optional intervals for the events. One of the requirements is that the &quot;run&quot; of events scheduled to a particular block needs to be consecutive, i.e. there must be no gap between the end of one interval and the start of the next. I tried defining it with a new &lt;code&gt;IntervalVar&lt;/code&gt; for each block, representing the start, duration and end of the &quot;run&quot; of events and an additional constraint that the duration is equal to the sum of lengths of the events which are active for the given block. Also a &lt;code&gt;NoOverlap&lt;/code&gt; constraint is needed to prevent collisions between the events in the run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pseudo-C# code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cs prettyprint-override&quot;&gt;&lt;code&gt;foreach (var group in events.GroupBy(e =&amp;gt; e.Block))&#xA;{&#xA;    var anyActive = _cpModel.NewBoolVar($&quot;any_active_in_block_{group.Key.Block}&quot;);&#xA;&#xA;    _cpModel.Add(LinearExpr.Sum(group.Select(i =&amp;gt; i.IsActive)) &amp;gt; 0).OnlyEnforceIf(anyActive);&#xA;    _cpModel.Add(LinearExpr.Sum(group.Select(i =&amp;gt; i.IsActive)) == 0).OnlyEnforceIf(anyActive.Not());&#xA;&#xA;    var runLength = _cpModel.NewIntVar(0, BLOCK_END - BLOCK_START, &lt;span class=&quot;math-container&quot;&gt;$&quot;run_length_in_block_{group.Key.Block}&quot;);&#xA;	var minEventStart = _cpModel.NewIntVar(BLOCK_START, BLOCK_END, $&lt;/span&gt;&quot;minimum_event_start_in_block_{group.Key.Block}&quot;);&#xA;    var maxEventEnd = _cpModel.NewIntVar(BLOCK_START, BLOCK_END, $&quot;maximum_event_end_in_block_{group.Key.Block}&quot;);&#xA;&#xA;    _cpModel.NewIntervalVar(minEventStart, runLength, maxEventEnd, $&quot;block_{group.Key.Block}_interval&quot;);&#xA;&#xA;    _cpModel.AddMinEquality(minEventStart, group.Select(e =&amp;gt; e.Start));&#xA;    _cpModel.AddMaxEquality(maxEventEnd, group.Select(e =&amp;gt; e.End));&#xA;    _cpModel.Add(runLength == LinearExpr.ScalProd(group.Select(e =&amp;gt; e.IsActive), group.Select(e =&amp;gt; e.Length))).OnlyEnforceIf(anyActive);&#xA;&#xA;    _cpModel.AddNoOverlap(group.Select(o =&amp;gt; o.Interval));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While that seems to work, it causes the complexity to explode, with over 10x the number of branches in a solution when I use this code. Is this just the consequence of the size of the search space? Or is there a better way to achieve the goal? There are obviously more constraints in the problem but this one seems to have the biggest impact on performance.&lt;/p&gt;&#xA;" OwnerUserId="3146" LastEditorUserId="36" LastEditDate="2020-03-06T14:43:55.163" LastActivityDate="2020-03-10T09:36:46.087" Title="Optimal way to ensure optional intervals are consecutive in OR-Tools" Tags="|scheduling|or-tools|c#|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3654" PostTypeId="1" CreationDate="2020-03-06T16:31:30.257" Score="8" ViewCount="222" Body="&lt;p&gt;I was wondering what types of methods can be used to strengthen QCQP relaxations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Our solver has all the standard stuff, like constraint propagation, presolving, etc., but some QCQP problems seem to be taking forever to converge to global optimality unless we throw 400 CPUs at them, even with strong branching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically for QCQPs, we are using RLT and convexity cuts to strengthen the relaxations, but it feels there might be something more to the story.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="8" LastEditDate="2020-06-04T20:09:43.610" LastActivityDate="2020-06-04T20:09:43.610" Title="Ways to strengthen QCQP relaxations" Tags="|solver|relaxation|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3655" PostTypeId="2" ParentId="3644" CreationDate="2020-03-06T17:27:50.627" Score="18" Body="&lt;p&gt;Actually, yes, and Folding@Home is doing this right now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://foldingathome.org/2020/02/27/foldinghome-takes-up-the-fight-against-covid-19-2019-ncov/&quot; rel=&quot;noreferrer&quot;&gt;https://foldingathome.org/2020/02/27/foldinghome-takes-up-the-fight-against-covid-19-2019-ncov/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;We need your help! Folding@home is joining researchers around the world working to better understand the 2019 Coronavirus (2019-nCoV) to accelerate the open science effort to develop new life-saving therapies. By downloading Folding@Home, you can donate your unused computational resources to the Folding@home Consortium, where researchers working to advance our understanding of the structures of potential drug targets for 2019-nCoV that could aid in the design of new therapies. The data you help us generate will be quickly and openly disseminated as part of an open science collaboration of multiple laboratories around the world, giving researchers new tools that may unlock new opportunities for developing lifesaving drugs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And another bit of info from the link:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;One protein from 2019-nCoV, a protease encoded by the viral RNA, has already been crystallized. Although the 2019-nCoV spike protein of interest has not yet been resolved bound to ACE2, our objective is to use the homologous structure of the SARS-CoV spike protein to identify therapeutic antibody targets.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3151" LastEditorUserId="3151" LastEditDate="2020-03-06T17:34:33.057" LastActivityDate="2020-03-06T17:34:33.057" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3656" PostTypeId="2" ParentId="3651" CreationDate="2020-03-06T22:13:05.683" Score="3" Body="&lt;p&gt;Your ratio current/best possible is not itself a gap; it is part of what you would use to compute the relative gap.&lt;/p&gt;&#xA;&lt;p&gt;The relative gap defined by CPLEX is the absolute difference between the objective solution of the best known solution (the incumbent, &amp;quot;best integer&amp;quot; in the formula you quote) and the best known bound (&amp;quot;best bound&amp;quot; in the formula), divided by the absolute value of the best known solution increased by a small amount (&lt;span class=&quot;math-container&quot;&gt;$10^{-10}$&lt;/span&gt;). The best bound will usually be the smallest objective value (in a min problem; largest in a max problem) of the node LP among all live nodes. Adding &lt;span class=&quot;math-container&quot;&gt;$10^{-10}$&lt;/span&gt; is just to avoid dividing by zero should the best node LP value be zero.&lt;/p&gt;&#xA;&lt;p&gt;You can specify both a relative gap limit and a time limit, in which case CPLEX will stop the first time either criterion applies. In other words, if it gets the relative gap below your limit before the time limit is reached, it stops. If not, it stops at the time limit. Is this what you want?&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-12-28T20:15:34.080" LastActivityDate="2020-12-28T20:15:34.080" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3657" PostTypeId="2" ParentId="3556" CreationDate="2020-03-07T13:04:42.260" Score="8" Body="&lt;p&gt;I would suggest reading &lt;a href=&quot;https://link.springer.com/book/10.1007/978-0-387-40065-5&quot; rel=&quot;noreferrer&quot;&gt;Numerical Optimization&lt;/a&gt; by Nocedal and Wright. It has a pretty neat chapter devoted to SQP methods.&lt;/p&gt;&#xA;" OwnerUserId="2452" LastEditorUserId="123" LastEditDate="2020-03-07T13:12:12.587" LastActivityDate="2020-03-07T13:12:12.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3658" PostTypeId="2" ParentId="3556" CreationDate="2020-03-07T14:45:32.027" Score="5" Body="&lt;p&gt;I agree with @fpacaud 's recommendation of the Nocedal and Wright book.&lt;/p&gt;&#xA;&lt;p&gt;Another source which is complementary to the Nocedal and Wright book, and is more in-depth in certain areas, is the 125 page long &lt;a href=&quot;https://epubs.siam.org/doi/pdf/10.1137/1.9780898719857.ch15&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chapter 15, &amp;quot;Sequential Quadratic Programming Methods&amp;quot;&lt;/a&gt; in &amp;quot;&lt;a href=&quot;https://my.siam.org/Store/Product/viewproduct/?ProductId=897&quot; rel=&quot;nofollow noreferrer&quot;&gt;Trust Region Methods&amp;quot; by Andrew R. Conn, Nicholas I. M. Gould, and Philippe L. Toint&lt;/a&gt;. In particular, that chapter can be bought as an electronic purchase of that individual chapter for \$14.95  (edit: \$19.99 as of Nov 2022, the ravages of inflation) &lt;a href=&quot;https://epubs.siam.org/doi/pdf/10.1137/1.9780898719857.ch15&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://epubs.siam.org/doi/pdf/10.1137/1.9780898719857.ch15&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-11-20T14:02:10.630" LastActivityDate="2022-11-20T14:02:10.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3659" PostTypeId="2" ParentId="3556" CreationDate="2020-03-07T15:14:41.353" Score="3" Body="&lt;p&gt;In the book &lt;em&gt;Nonlinear Optimization&lt;/em&gt; (2010) by Bomze, Demyanov, Fletcher and Telarky, there is the chapter &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-642-11339-0_3&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Sequential Quadratic Programming Method&lt;/a&gt; written by Fletcher.&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2020-03-07T15:14:41.353" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3660" PostTypeId="1" CreationDate="2020-03-08T18:44:39.610" Score="3" ViewCount="190" Body="&lt;p&gt;I have a model involving constraints of the form &lt;span class=&quot;math-container&quot;&gt;$$d(i) = a \cdot W(i) + b \cdot B(i)$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$W(i)$&lt;/span&gt; is binary and &lt;span class=&quot;math-container&quot;&gt;$d(i), B(i)$&lt;/span&gt; are positive reals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The objective function is &lt;span class=&quot;math-container&quot;&gt;$\max\sum B(i)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While solving the problem, the solver sets some &lt;span class=&quot;math-container&quot;&gt;$W(i)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; but keeps the corresponding &lt;span class=&quot;math-container&quot;&gt;$B(i)$&lt;/span&gt; at zero. In other words the solver 'prefers' to fulfill the constraint &lt;span class=&quot;math-container&quot;&gt;$d(i) = a \cdot W(i) + b \cdot 0$&lt;/span&gt;. Advancing towards the optimum is extremely slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is, how can I &quot;persuade&quot; the solver to set &lt;span class=&quot;math-container&quot;&gt;$B(i)$&lt;/span&gt; well above &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; whenever it decides to set &lt;span class=&quot;math-container&quot;&gt;$W(i)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;? Because I am asking to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum B(i)$&lt;/span&gt; I would expect that the solver does what I am asking. The solver should understand that it can only reach the optimum, if it set the values &lt;span class=&quot;math-container&quot;&gt;$B(i)$&lt;/span&gt; to appropriate values &lt;span class=&quot;math-container&quot;&gt;$&amp;gt; 0$&lt;/span&gt;. &lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2020-03-08T19:30:29.183" LastActivityDate="2021-01-31T00:58:31.130" Title="How can I direct the behaviour of a MILP Solver" Tags="|mixed-integer-programming|modeling|solver|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3661" PostTypeId="2" ParentId="3660" CreationDate="2020-03-08T21:43:49.393" Score="2" Body="&lt;p&gt;If &quot;well above 0&quot; means &lt;span class=&quot;math-container&quot;&gt;$\ge m_i$&lt;/span&gt;, you can impose the constraint &lt;span class=&quot;math-container&quot;&gt;$$B(i)\ge m_i\cdot W(i)$$&lt;/span&gt; to enforce &lt;span class=&quot;math-container&quot;&gt;$$W(i)=1 \implies B(i) \ge m_i.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-03-08T21:43:49.393" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3662" PostTypeId="1" CreationDate="2020-03-09T01:06:34.827" Score="9" ViewCount="1965" Body="&lt;p&gt;I should note that I am very new to Gurobi so apologies if this is obvious. I am working on a project for a class to maximize profit on a theoretical flight network by deciding which routes to fly at what time and with what type of plane using a linear program. However, I keep running into a problem where there aren't any feasible solutions, but it doesn't seem like there should be interfering constraints from what I can tell. I used a loop to add all of the constraints, and I suspect the problem lies with the way I set the loop up. Is there a way to output a list of all the added constraints? It would be a very helpful way to troubleshoot.&lt;/p&gt;&#xA;" OwnerUserId="3168" LastActivityDate="2020-03-09T13:28:53.523" Title="Is there a way to view added constraints in Gurobi (Python)?" Tags="|linear-programming|python|gurobi|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3663" PostTypeId="2" ParentId="3662" CreationDate="2020-03-09T01:29:36.293" Score="4" Body="&lt;p&gt;what I typically do for debugging purposes is to output the model to a file in a &quot;readable&quot; format like LP format using&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;model.write(&quot;myfile.lp&quot;)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2020-03-09T01:29:36.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3664" PostTypeId="2" ParentId="3662" CreationDate="2020-03-09T13:28:53.523" Score="6" Body="&lt;p&gt;Sometimes computing an IIS helps addressing the source of the infeasibility in the model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example Usage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model.computeIIS()&#xA;model.write(&quot;model.ilp&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/py_model_computeiis.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.0/refman/py_model_computeiis.html&lt;/a&gt;&#xA;&lt;a href=&quot;https://www.gurobi.com/documentation/9.0/examples/diagnose_and_cope_with_inf.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.0/examples/diagnose_and_cope_with_inf.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3170" LastActivityDate="2020-03-09T13:28:53.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3665" PostTypeId="2" ParentId="3644" CreationDate="2020-03-09T21:04:12.563" Score="4" Body="&lt;p&gt;I cannot write regular comments, but the BOINC platform and their Rosetta team are fighting too:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ipd.uw.edu/2020/02/rosettas-role-in-fighting-coronavirus/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ipd.uw.edu/2020/02/rosettas-role-in-fighting-coronavirus/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://boinc.bakerlab.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://boinc.bakerlab.org/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The consortium consists of the University of Washington, Howard Hughes Medical Institute and Institute for Protein Design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Feel free to add to the OP so others can help if they already use BOINC.&lt;/p&gt;&#xA;" OwnerUserId="3173" LastActivityDate="2020-03-09T21:04:12.563" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3666" PostTypeId="2" ParentId="3644" CreationDate="2020-03-10T00:31:18.243" Score="6" Body="&lt;p&gt;I'm not defining an optimization problem challenge, but providing a dataset I came across when visiting &lt;a href=&quot;https://ourworldindata.org/coronavirus&quot; rel=&quot;nofollow noreferrer&quot;&gt;our world in data&lt;/a&gt; website. There is &lt;a href=&quot;https://github.com/CSSEGISandData/COVID-19&quot; rel=&quot;nofollow noreferrer&quot;&gt;this data repository&lt;/a&gt; by Johns Hopkins Center for Systems Science and Engineering for COVID-19 cases. The data sources there are from World Health Organization (WHO) and the CDC of China, Hong Kong, US, Australia, Italy, Europe, and more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Amazon is making a public &lt;a href=&quot;https://aws.amazon.com/blogs/big-data/a-public-data-lake-for-analysis-of-covid-19-data/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AWS COVID-19 data lake&lt;/a&gt; available.&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2020-04-10T12:28:06.610" LastActivityDate="2020-04-10T12:28:06.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3667" PostTypeId="1" CreationDate="2020-03-10T03:46:28.773" Score="4" ViewCount="501" Body="&lt;p&gt;Referring to the question &lt;a href=&quot;https://or.stackexchange.com/questions/3626/tsp-subtour-elimination-by-assigning-distance-traveled&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given a set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, which we need to travel following TSP rules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if this sub tour elimination method is good enough or not?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$b_{i,j}$&lt;/span&gt; denote edge from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is taken or not and &lt;span class=&quot;math-container&quot;&gt;$d_{i,j} &amp;gt; 0$&lt;/span&gt; denotes distance from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_{i,j \in S} d_{i,j} \cdot b_{i,j}\\\text{s.t.}&amp;amp;\quad\sum_{j \in S} b_{j,i} - \sum_{k \in S} b_{i,k} = 0\\&amp;amp;\quad\sum_{j \in S} b_{j,i}  = 1\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$s_0$&lt;/span&gt; be the start node. Now use a continuous variable &lt;span class=&quot;math-container&quot;&gt;$DS_i$&lt;/span&gt; to store the distance at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$DS_{s_0} = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \forall j \in S \setminus \{s_0\}  \quad DS_{j} =  \sum_{i} b_{i,j} \cdot (DS_{i} + d_{i,j}) $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last constraint eliminates the sub-tour in the path and is similar to MTZ formulation as per the answer given. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to speed up the solver, I created a call back where I am trying to eliminate the sub tour, but the problem is due to the last constraint (MTZ equivalent) call back is not getting any sub tour to detect as it is already solved by the last constraint (MTZ equivalent), so the speed is slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the log at callback with the last constraint &lt;code&gt;ON&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The total number of nodes = 9.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--&amp;gt; lazy constraint callback called: #1&#xA;[0, 4, 1, 6, 2, 5, 8, 7, 3, 0]&#xA;--&amp;gt; lazy constraint callback called: #2&#xA;[0, 6, 3, 4, 8, 7, 5, 2, 1, 0]&#xA;--&amp;gt; lazy constraint callback called: #3&#xA;[0, 3, 6, 4, 7, 8, 5, 2, 1, 0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the log at callback with the last constraint &lt;code&gt;OFF&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The total number of nodes = 9.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--&amp;gt; lazy constraint callback called: #1&#xA;[0, 1, 2, 0]&#xA;Add violated subtour&#xA;--&amp;gt; lazy constraint callback called: #2&#xA;[0, 2, 1, 0]&#xA;Add violated subtour&#xA;--&amp;gt; lazy constraint callback called: #3&#xA;[0, 1, 2, 5, 8, 7, 4, 3, 6, 0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="700" LastEditorUserId="700" LastEditDate="2020-03-12T10:53:52.123" LastActivityDate="2021-12-08T14:34:17.597" Title="TSP subtour elimination with multiple formulations" Tags="|mixed-integer-programming|linear-programming|modeling|traveling-salesman|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3668" PostTypeId="2" ParentId="3660" CreationDate="2020-03-10T04:26:50.607" Score="1" Body="&lt;p&gt;Here is the small implementation with one extra constraint&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$B(i) \geq W(i)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import docplex.mp.model as cpx&#xA;import pandas as pd&#xA;&#xA;opt_model = cpx.Model(name=&quot;MIP Model&quot;)&#xA;set_n = range(5)&#xA;W = {i: opt_model.binary_var(name=&quot;W_{0}&quot;.format(i)) for i in set_n}&#xA;B = {i: opt_model.continuous_var(name=&quot;B_{0}&quot;.format(i)) for i in set_n}&#xA;d = {i: opt_model.continuous_var(name=&quot;d_{0}&quot;.format(i)) for i in set_n}&#xA;&#xA;a = 1&#xA;b = 5&#xA;&#xA;objective = opt_model.sum(B[i] for i in set_n)&#xA;&#xA;for i in set_n:&#xA;    opt_model.add_constraint(B[i] &amp;gt;= W[i])&#xA;&#xA;for i in set_n:&#xA;    opt_model.add_constraint(d[i] == a * W[i] + b * B[i])&#xA;&#xA;opt_model.maximize(objective)&#xA;&#xA;opt_model.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you have &lt;span class=&quot;math-container&quot;&gt;$a,b &amp;gt;0$&lt;/span&gt;, you will always get &lt;span class=&quot;math-container&quot;&gt;$B(i)$&lt;/span&gt; as 1. &lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="700" LastEditDate="2020-03-11T03:42:36.983" LastActivityDate="2020-03-11T03:42:36.983" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3669" PostTypeId="2" ParentId="3653" CreationDate="2020-03-10T09:36:46.087" Score="1" Body="&lt;p&gt;As suggested in the comments above, I went with the &lt;em&gt;circuit&lt;/em&gt; constraint. While I am not yet sure whether it helps with the performance, it certainly offers a lot more control over the relations between pairs of variables - here specifically it allows forcing a constraint that an event starts at the end of the previous event.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cs prettyprint-override&quot;&gt;&lt;code&gt;foreach (var group in events.GroupBy(e =&amp;gt; e.Block))&#xA;{&#xA;    var eventsInBlock = group.ToList();&#xA;    var anyActive = _cpModel.NewBoolVar($&quot;any_active_in_block_{group.Key.Block}&quot;);&#xA;&#xA;    _cpModel.Add(LinearExpr.Sum(group.Select(i =&amp;gt; i.IsActive)) &amp;gt; 0).OnlyEnforceIf(anyActive);&#xA;    _cpModel.Add(LinearExpr.Sum(group.Select(i =&amp;gt; i.IsActive)) == 0).OnlyEnforceIf(anyActive.Not());&#xA;&#xA;    var arcs = new List&amp;lt;Tuple&amp;lt;int, int, ILiteral&amp;gt;&amp;gt;&#xA;    {&#xA;        Tuple.Create(0, 0, anyActive.Not())&#xA;    };&#xA;&#xA;    for (int i = 0; i &amp;lt; eventsInBlock.Count; i++)&#xA;    {&#xA;        var isFirst = (ILiteral)_cpModel.NewBoolVar(&lt;span class=&quot;math-container&quot;&gt;$&quot;event_{i + 1}_is_first_in_block_{group.Key.Block}&quot;);&#xA;		var isLast = (ILiteral)_cpModel.NewBoolVar($&lt;/span&gt;&quot;event_{i + 1}_is_last_in_block_{group.Key.Block}&quot;);&#xA;&#xA;        arcs.Add(Tuple.Create(0, i + 1, isFirst));&#xA;        arcs.Add(Tuple.Create(i + 1, 0, isLast));&#xA;&#xA;        _cpModel.AddImplication(eventsInBlock[i].IsActive.Not(), isFirst.Not());&#xA;        _cpModel.AddImplication(eventsInBlock[i].IsActive.Not(), isLast.Not());&#xA;&#xA;        for (int j = 0; j &amp;lt; eventsInBlock.Count; j++)&#xA;        {&#xA;            if (i == j)&#xA;            {&#xA;                arcs.Add(Tuple.Create(i + 1, i + 1, eventsInBlock[i].IsActive.Not()));&#xA;                continue;&#xA;            }&#xA;&#xA;            var literal = (ILiteral)_cpModel.NewBoolVar($&quot;event_{i + 1}_is_before_event_{j + 1}_in_block_{group.Key.Block}&quot;);&#xA;            arcs.Add(Tuple.Create(i + 1, j + 1, literal));&#xA;&#xA;            _cpModel.AddImplication(literal, eventsInBlock[i].IsActive);&#xA;            _cpModel.AddImplication(literal, eventsInBlock[j].IsActive);&#xA;&#xA;            _cpModel.Add(eventsInBlock[i].End == eventsInBlock[j].Start).OnlyEnforceIf(literal);&#xA;        }&#xA;    }&#xA;&#xA;    _cpModel.AddCircuit(arcs);&#xA;}&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3146" LastActivityDate="2020-03-10T09:36:46.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3670" PostTypeId="1" AcceptedAnswerId="3675" CreationDate="2020-03-10T14:36:16.520" Score="10" ViewCount="820" Body="&lt;p&gt;I have just started to dive into OR world on my work. Currently we are using GAMS with Gurobi but some of us have strong programming background and would like to have more programmatic approach to OR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have heard that without GAMS you can't get fast feedback on your model, like if constraints are impossible, model can't be solved, existence of indefinite loops etc.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I am wondering is what are pros and cons for using directly Gurobi's Python API instead of doing modeling in GAMS? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If separating model from solver is good, does modeling frameworks in Python like Pyomo have also this model check option like GAMS? I managed to find that pyomo command line interface has check command but I have no clue what it does.    &lt;/p&gt;&#xA;" OwnerUserId="3175" LastEditorUserId="3175" LastEditDate="2020-05-11T12:58:25.657" LastActivityDate="2020-05-11T12:58:25.657" Title="Modeling and solvers" Tags="|python|gurobi|pyomo|gams|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3671" PostTypeId="2" ParentId="3654" CreationDate="2020-03-10T15:54:43.107" Score="6" Body="&lt;p&gt;Sometimes cuts from Boolean Quadric Polytope can help:&#xA;&lt;a href=&quot;https://link.springer.com/article/10.1007/s12532-018-0133-x&quot; rel=&quot;noreferrer&quot;&gt;https://link.springer.com/article/10.1007/s12532-018-0133-x&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="34" LastActivityDate="2020-03-10T15:54:43.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3672" PostTypeId="2" ParentId="3644" CreationDate="2020-03-10T18:18:47.580" Score="4" Body="&lt;p&gt;Data about the COVID-19 cases in Italy is available on Github from the government:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/pcm-dpc/COVID-19&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/pcm-dpc/COVID-19&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="224" LastActivityDate="2020-03-10T18:18:47.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3673" PostTypeId="2" ParentId="3670" CreationDate="2020-03-10T19:15:25.880" Score="12" Body="&lt;p&gt;I can't address the specifics of Python, Pyomo, Gurobi or GAMS, but I can address the general question of using a modeling language (such as GAMS) versus building the model directly in a general programming language (such as Python) via a solver API.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Models written in a modeling language (say GAMS) tend to be easier to read and easier to relate to a problem description than are models coded in a programming language (say Python). That implies a few potential advantages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it is easier to explain the GAMS model to a non-coder than it is to explain the Python model;&lt;/li&gt;&#xA;&lt;li&gt;the GAMS model may be less prone to errors (specifying the wrong variable, reversing the direction of an inequality, indexing errors) than the Python model would be, in part because such errors are more obvious to the human eye;&lt;/li&gt;&#xA;&lt;li&gt;similarly, it may be easier to find errors in the GAMS model (should they creep in) than in the Python model; and&lt;/li&gt;&#xA;&lt;li&gt;the GAMS model may be easier to maintain, particularly if it is handed off to someone other than the person that wrote it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To me, the main advantages of going straight to a programming language are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you only have to be proficient in one language, rather than two;&lt;/li&gt;&#xA;&lt;li&gt;your code can be used (by other people) without needing a library from the programming language (and associated license);&lt;/li&gt;&#xA;&lt;li&gt;if you are customizing an algorithm for the model (doing something beyond what the solver and GAMS directly support), you are likely going to need &quot;low level&quot; access to model components, which you may not be able to get from the GAMS model.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Your second paragraph (&quot;fast feedback&quot; etc.) does not sound at all correct to me. I use Java rather than Python and CPLEX rather than Gurobi, but I have no difficulty finding out whether a model instance is infeasible (and, if so, which constraints are involved in the infeasibility). Assuming a problem is feasible, whether it can be solved (within time and memory limits) is always an empirical question (try and see).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-03-10T19:15:25.880" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3674" PostTypeId="2" ParentId="3667" CreationDate="2020-03-10T19:26:36.497" Score="5" Body="&lt;p&gt;As you only separate SEC's when you find integer feasible solutions, and since your MTZ like constraints eliminate all integer solutions corresponding to subtours, you obviously cannot gain anything from the lazy constraint callback approach. What you however can do, is to separate SEC's from &lt;em&gt;fractional&lt;/em&gt; solutions. This require some more work compared to the integer feasible case, but it might be worth it. &lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2020-03-10T19:26:36.497" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="3675" PostTypeId="2" ParentId="3670" CreationDate="2020-03-11T09:01:06.540" Score="8" Body="&lt;p&gt;In a production environment, I have found code APIs to be superior to modelling languages in the long run. Nowadays, we also have Pyomo so we don't even need to compromise between the two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The subtlety is that if you use a solver's Python API your code is tied to that solver. Conversely, if you use a modelling environment (e.g. GAMS), you can seamlessly swap solvers but you are tied to the modelling environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though my personal preference is AMPL (simply because I like the product and the language), when we deploy projects we typically use Pyomo &amp;amp; the Octeract Reformulator API because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Clients typically don't want to pay for yet another license.&lt;/li&gt;&#xA;&lt;li&gt;Everything is natively in Python making integrations with data/csv etc. very easy.&lt;/li&gt;&#xA;&lt;li&gt;The modelling environment is not licensed therefore the code will still work even if the client decides to switch to a different solver/environment/machine later on. They tend not to, but people like to feel reassured like that.&lt;/li&gt;&#xA;&lt;li&gt;People can share the project with other people who don't have access to a licensed modelling language.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For academia on the other hand, it's a no-brainer: use software that non-academics can also access for free, otherwise no-one outside academia will ever use anything we create, and neither can we after we leave academia.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-03-11T13:55:20.160" LastActivityDate="2020-03-11T13:55:20.160" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3677" PostTypeId="2" ParentId="3644" CreationDate="2020-03-11T17:04:19.187" Score="8" Body="&lt;p&gt;We (operations research community in Italy) have just offered our availability to contribute as we can. &#xA;On our web site &lt;a href=&quot;https://webgol.dinfo.unifi.it&quot; rel=&quot;noreferrer&quot;&gt;https://webgol.dinfo.unifi.it&lt;/a&gt; we just starting collecting ideas on how to help.&#xA;We think there is much that OR can do: assignment (we have strong imbalance between available beds and patients in acute care), transportation, ambulance scheduling, triage optimization, inventory management,....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help or suggestion from the community is more than welcome. My group also worked in the past on folding and molecular design, but I think in this moment our emergency is on the logistic side, there is no time, I guess, for a molecule. I mean, a vaccine would be very welcome, but I don't think we can wait, it's simply too late. &#xA;Anyway, as we really do not know how long all of this will be, we just made available our computing resources and joined the folding@home project &lt;a href=&quot;https://foldingathome.org/&quot; rel=&quot;noreferrer&quot;&gt;https://foldingathome.org/&lt;/a&gt; who is now devoted to finding potential drugs against the virus&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Italy has taken impressive and very serious decisions to try to limit the spread; we hope other countries will follow the same path, the earlier the better for all.&lt;/p&gt;&#xA;" OwnerUserId="745" LastEditorUserId="745" LastEditDate="2020-03-17T07:48:45.003" LastActivityDate="2020-03-17T07:48:45.003" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3678" PostTypeId="2" ParentId="3493" CreationDate="2020-03-11T17:33:16.987" Score="1" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is continuous, this logical constraint cannot be represented by a finite set of linear inequalities (see old work by Bob Jeroslow). What you can do is to relax a little.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Saying &lt;span class=&quot;math-container&quot;&gt;$A\le B \implies Y=1$&lt;/span&gt; is the same as imposing &lt;span class=&quot;math-container&quot;&gt;$Y=0 \implies A &amp;gt; B$&lt;/span&gt;. If you can allow this to become &lt;span class=&quot;math-container&quot;&gt;$A \ge B+\epsilon$&lt;/span&gt; then the constraint becomes&#xA;&lt;span class=&quot;math-container&quot;&gt;$A \ge M\cdot Y + (B+\epsilon) (1-Y)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a lower bound of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is always &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course if &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is known, e.g., to be integer, than you can choose &lt;span class=&quot;math-container&quot;&gt;$\epsilon = 1$&lt;/span&gt; without loss of generality.&lt;/p&gt;&#xA;" OwnerUserId="745" LastEditorUserId="500" LastEditDate="2020-03-11T19:08:55.970" LastActivityDate="2020-03-11T19:08:55.970" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3679" PostTypeId="2" ParentId="3598" CreationDate="2020-03-11T17:39:05.293" Score="2" Body="&lt;p&gt;The sum of convex functions is convex!&lt;/p&gt;&#xA;" OwnerUserId="745" LastEditorUserId="123" LastEditDate="2020-03-11T19:02:16.647" LastActivityDate="2020-03-11T19:02:16.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3681" PostTypeId="1" AcceptedAnswerId="3689" CreationDate="2020-03-11T19:10:17.240" Score="3" ViewCount="173" Body="&lt;p&gt;I have formulated a linear optimization model and solve it using the Excel Solver. &#xA;How can I illustrate the slacks vs usage?&lt;/p&gt;&#xA;" OwnerDisplayName="user3176" LastEditorDisplayName="user3176" LastEditDate="2020-03-13T01:59:05.820" LastActivityDate="2020-03-13T01:59:05.820" Title="Graphical illustration Excel" Tags="|optimization|solver|excel|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3682" PostTypeId="1" AcceptedAnswerId="3688" CreationDate="2020-03-11T23:16:29.597" Score="5" ViewCount="296" Body="&lt;p&gt;I declare an array of binary variables as  &lt;span class=&quot;math-container&quot;&gt;$y(i), i = 1, ..., N$&lt;/span&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to model the following: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$y(i-1) + y(i) = 1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y(k) = 0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$k &amp;lt; i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y(m) = 1$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$m \geq i$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make the question clear, here is an example: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I have the following 10 binary variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y(1), y(2), y(3), y(4), y(5), y(6), y(7), y(8), y(9), y(10)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is true: &lt;span class=&quot;math-container&quot;&gt;$y(i-1) \leq y(i)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i &amp;gt; 2 $&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The optimiser is supposed to set the values of the variables in a pattern like the following: &#xA;&lt;span class=&quot;math-container&quot;&gt;$(y(1), y(2), y(3), y(4), y(5), y(6), y(7), y(8), y(9), y(10)) = ( 0,0,0,0,0,1,1,1,1,1)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I will get a pattern like the one mentioned, but I don't know when the first &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; will appear. I need to determine the variable &lt;span class=&quot;math-container&quot;&gt;$y(i)$&lt;/span&gt; that gets first the value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and then set all variables to its right to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and all variables to its left to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. So I need to determine when &lt;span class=&quot;math-container&quot;&gt;$y(i) + y(i-1) = 1$&lt;/span&gt;, knowing that this implies &lt;span class=&quot;math-container&quot;&gt;$y(i) = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y(i-1)=0$&lt;/span&gt;.   &lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="1269" LastEditDate="2020-03-12T15:36:28.913" LastActivityDate="2020-03-12T16:18:45.287" Title="How can this relationship be modelled?" Tags="|mixed-integer-programming|modeling|binary-variable|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3684" PostTypeId="2" ParentId="3682" CreationDate="2020-03-12T01:34:23.583" Score="7" Body="&lt;p&gt;You could simply write&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y(i) - y(i - 1) \ge 0, \qquad i=2,...,N$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="500" LastEditDate="2020-03-12T01:51:31.910" LastActivityDate="2020-03-12T01:51:31.910" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3686" PostTypeId="1" AcceptedAnswerId="3687" CreationDate="2020-03-12T12:30:15.637" Score="5" ViewCount="346" Body="&lt;p&gt;I have an if else condition as follows: If &lt;span class=&quot;math-container&quot;&gt;$g \ge 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$e=1$&lt;/span&gt;, else &lt;span class=&quot;math-container&quot;&gt;$e=b$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I formulated MIP constraints using big-M as follows where I am setting &lt;span class=&quot;math-container&quot;&gt;$\delta=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$g \ge 0$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2g &amp;amp;\ge -M(1-\delta)\tag1\\g &amp;amp;\le M\delta\tag2\\1-M(1-\delta) &amp;amp;\le e \le 1+M(1-\delta)\tag3\\b-M\delta &amp;amp;\le e \le b+M\delta\tag4\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is if the formulation is correct, especially the first equation.   &lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="123" LastEditDate="2020-03-12T19:36:36.340" LastActivityDate="2020-03-12T19:50:54.123" Title="Converting if else condition to MIP constraints - validation" Tags="|mixed-integer-programming|big-m|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3687" PostTypeId="2" ParentId="3686" CreationDate="2020-03-12T12:59:14.893" Score="6" Body="&lt;p&gt;Looks correct, but there is the usual ambiguity at the boundary: &lt;span class=&quot;math-container&quot;&gt;$g=0$&lt;/span&gt; allows either &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; value.  Also, if &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a constant, you can simplify by replacing (3) and (4) with a single equality:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$e=1\delta+b(1-\delta)$$&lt;/span&gt;&#xA;Note that the best values of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; in (3) and (4) yield this equality.  Explicitly:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;1-(1-b)(1-\delta) &amp;amp;\le e \le 1+(b-1)(1-\delta) \tag3\\&#xA;b-(b-1)\delta &amp;amp;\le e \le b+(1-b)\delta &amp;amp;&amp;amp;\tag4&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-03-12T19:50:54.123" LastActivityDate="2020-03-12T19:50:54.123" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3688" PostTypeId="2" ParentId="3682" CreationDate="2020-03-12T16:18:45.287" Score="2" Body="&lt;p&gt;New answer based on modified question.  If you have constraints &lt;span class=&quot;math-container&quot;&gt;$y_i \ge y_{i-1}$&lt;/span&gt;, the value of &lt;span class=&quot;math-container&quot;&gt;$y_i-y_{i-1}$&lt;/span&gt; indicates whether &lt;span class=&quot;math-container&quot;&gt;$y_i+y_{i-1}=1$&lt;/span&gt;, and this can happen only once.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-03-12T16:18:45.287" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3689" PostTypeId="2" ParentId="3681" CreationDate="2020-03-12T18:18:26.263" Score="4" Body="&lt;p&gt;I'm not sure I understand your question as well but, let me describe an example using excel. In the following tiny instance, the model has two variables and four constraints. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{5}&#xA;  \max \quad        &amp;amp; z = &amp;amp; 3x_1  &amp;amp; + &amp;amp; 2 x_2  &amp;amp;   &amp;amp;       &amp;amp;         &amp;amp;&amp;amp;\\&#xA;  \mbox{s.t.} \quad &amp;amp;     &amp;amp;  x_1  &amp;amp; + &amp;amp;   x_2  &amp;amp; \leq 9  &amp;amp;&amp;amp; \tag{constraint 1}\\&#xA;                    &amp;amp;     &amp;amp; 3x_1  &amp;amp; + &amp;amp;   x_2  &amp;amp; \leq 18 &amp;amp;&amp;amp; \tag{constraint 2}\\&#xA;                    &amp;amp;     &amp;amp;  x_1  &amp;amp;&amp;amp;&amp;amp;            \leq 7  &amp;amp;&amp;amp; \tag{constraint 3}\\&#xA;                                  &amp;amp;&amp;amp;&amp;amp;&amp;amp;    x_2  &amp;amp; \leq 6  &amp;amp;&amp;amp; \tag{constraint 4}\\&#xA;                    &amp;amp;&amp;amp;              x_1 , x_2    \geq 0&#xA;\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the model is solved, the objective function value is 22.5, and the decision variables have the value, equal to 4.5. Also, the dual and slack values will be found by the solver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1JwLz.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1JwLz.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the results, you can illustrate the data using excel chart. (E.g. the usage chart to depict the value of the decision variables or comparing RHS vales and whose slack.). However, if you are interested to use &quot;Sensitivity Analysis&quot;, you can go ahead. I hope it would be helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uJs8f.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uJs8f.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-03-12T18:18:26.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3690" PostTypeId="1" AcceptedAnswerId="3693" CreationDate="2020-03-12T21:25:22.293" Score="7" ViewCount="236" Body="&lt;p&gt;When solving a MIP with Gurobi, one can use the &lt;code&gt;cbGetNodeRel()&lt;/code&gt; function to extract the primal solution to the LP relaxation at each node in the branch and bound tree. Is there similar functionality to extract the dual solution as well? It seems theoretically possible, but I sense that it may be a difficult engineering problem due to Gurobi's extensive pre-solve routine.&lt;/p&gt;&#xA;" OwnerUserId="358" LastActivityDate="2020-03-13T07:35:54.780" Title="Gurobi: can you retrieve the dual solution from each node of the B&amp;B tree using callbacks" Tags="|gurobi|branch-and-bound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3691" PostTypeId="1" AcceptedAnswerId="3698" CreationDate="2020-03-12T23:51:30.103" Score="6" ViewCount="842" Body="&lt;p&gt;Assume we are solving &lt;span class=&quot;math-container&quot;&gt;$\min\{f(x) \ | \ x \in S \}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$f: \mathbb{R}^n \mapsto \mathbb{R}$&lt;/span&gt;  is a proper closed convex function, and &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is a non-empty closed convex set, does this imply that the above minimization problem has a non-empty solution set? Does an optimal solution always exist in such a setting?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I know is that (by Wikipedia) a proper convex function is closed if and only if it is lower semi-continuous. Moreover, if I know &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is proper closed convex, then this implies the function is lower semi-continuous. By the extension of extreme value theorem to semi-continuous functions, we know that the above minimization has a non-empty solution set since &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is lower semi-continuous. So maybe this is it...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Based on the answer to this question below, I see that such an optimal value always exists. However, in Amir Beck's first-order methods book, there is the following set of assumptions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3LHgF.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3LHgF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;Then don't (A,B,C) imply (D) anyways? Why are we also assuming (D) at all?&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2020-03-13T00:04:55.440" LastActivityDate="2020-03-14T05:18:20.083" Title="Existence of Optimal Solution" Tags="|convexity|convex-optimization|optimality-conditions|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3692" PostTypeId="2" ParentId="3691" CreationDate="2020-03-13T00:03:00.123" Score="-4" Body="&lt;p&gt;An optimal solution exists iff the KKT are satisfied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Mark Stone pointed out in the comments, the brief does not give us any guarantees on continuous differentiability, which is necessary for KKT. Without (D), there might or might not be KKT points, we can't tell. (D) imposes that we have at least one KKT point.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-03-13T14:38:44.013" LastActivityDate="2020-03-13T14:38:44.013" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="3693" PostTypeId="2" ParentId="3690" CreationDate="2020-03-13T00:16:41.447" Score="8" Body="&lt;p&gt;It is not possible, and the reason is that for them to give you the dual, they also need to give you the binding cutting planes at each node. Much of Gurobi's (and CPLEX's as well) magic relies on their proprietary cutting-planes, many of them unknown to us. So you're right, it is possible, but you will never have them give us that info.&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="123" LastEditDate="2020-03-13T07:35:54.780" LastActivityDate="2020-03-13T07:35:54.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3694" PostTypeId="2" ParentId="3550" CreationDate="2020-03-13T04:28:02.427" Score="3" Body="&lt;p&gt;Richer vehicle routing problems don't usually fall into a 'neat' academic classification and you're unlikely to find an exact classification for this one. Roughly speaking, your problem is a dynamic (a.k.a. realtime) pickup-delivery vehicle routing problem, with additional restrictions on vehicle-job assignment and a capacity limit on vehicles of one job on-board. So far, this is reasonably standard and has been covered in a few different papers. The constraint '&lt;em&gt;the arcs/edges between the stations have a capacity of 1...&lt;/em&gt;' is the particularly strange one though (probably related to container loading / docks?), and this puts the problem beyond any standard classification. I'm 99% certain no papers will have covered a model exactly like this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My advice would be to look at algorithms that solve the dynamic pickup delivery vehicle routing problem and see if any of these could be adapted to handle your 'arc capacity' constraint. Usually algorithms which solve these using a combination of heuristics and metaheuristics are more successful than exact methods (i.e. mixed integer programming) as exact methods don't tend to scale that well for vehicle routing problems. If your problem size is really small an exact method might work though.&lt;/p&gt;&#xA;" OwnerUserId="825" LastActivityDate="2020-03-13T04:28:02.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3695" PostTypeId="1" CreationDate="2020-03-13T04:36:56.640" Score="2" ViewCount="392" Body="&lt;p&gt;I have tried to implement my question asked &lt;a href=&quot;https://or.stackexchange.com/questions/3626/tsp-subtour-elimination-by-assigning-distance-traveled&quot;&gt;here&lt;/a&gt; with the help of Github code &lt;a href=&quot;https://github.com/djunglas/cplex_code_examples/blob/master/docplex/tsp.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the linearized version of the MTZ like constraint as per the answer given &lt;a href=&quot;https://or.stackexchange.com/questions/3626/tsp-subtour-elimination-by-assigning-distance-traveled&quot;&gt;here&lt;/a&gt;. Constraints below assign distance traveled from source to each node in the path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$DS_{j} \geq DS_{i} + d_{i,j} - M \times (1 - b_{i,j})$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$DS_{j} \leq DS_{i} + d_{i,j} + M \times (1 - b_{i,j})$$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import docplex.mp.model as cpx&#xA;from cplex.callbacks import LazyConstraintCallback&#xA;from docplex.mp.callbacks.cb_mixin import *&#xA;&#xA;class DOLazyCallback(ConstraintCallbackMixin, LazyConstraintCallback):&#xA;    def __init__(self, env):&#xA;        LazyConstraintCallback.__init__(self, env)&#xA;        ConstraintCallbackMixin.__init__(self)&#xA;        self.nb_lazy_cts = 0&#xA;&#xA;    def add_lazy_constraints(self, cts):&#xA;        self.register_constraints(cts)&#xA;&#xA;    @print_called('--&amp;gt; lazy constraint callback called: #{0}')&#xA;    def __call__(self):&#xA;        # fetch variable values into a solution&#xA;        sol = self.make_solution_from_vars(self.x.values())&#xA;&#xA;        history = [0]&#xA;        j = 0&#xA;        while 1:&#xA;            for i in self.set_n:&#xA;                if not i == j and sol.get_value(self.x[j, i]) == 1.0:&#xA;                    history.append(i)&#xA;                    j = i&#xA;                    break&#xA;            if j == 0:&#xA;                break&#xA;&#xA;        print(history)&#xA;        n = len(history) - 1&#xA;&#xA;        if n &amp;lt; len(self.set_n):&#xA;            tour = 0&#xA;            for i, v in enumerate(history):&#xA;                if not i == n:&#xA;                    tour += self.x[v, history[i + 1]]&#xA;            ct = tour &amp;lt;= n - 1&#xA;            cst = [ct]&#xA;&#xA;            unsats = self.get_cpx_unsatisfied_cts(cst, sol, tolerance=0)&#xA;            for ct, cpx_lhs, sense, cpx_rhs in unsats:&#xA;                print('Add violated subtour')&#xA;                self.add(cpx_lhs, sense, cpx_rhs)&#xA;&#xA;&#xA;DST = [[0, 0.238, 0.608, 0.5442, 0.6097, 1.2337, 0.5574, 0.8691, 1.3394],&#xA;       [0.238, 0, 0.37, 0.6694, 0.6039, 0.9957, 0.6826, 0.8633, 1.23],&#xA;       [0.608, 0.37, 0, 1.0394, 0.9739, 0.6257, 1.0526, 1.2333, 0.860],&#xA;       [0.5442, 0.6694, 1.0394, 0, 0.0655, 0.903, 0.0132, 0.3249, 0.7952],&#xA;       [0.6097, 0.6039, 0.9739, 0.0655, 0, 0.8375, 0.0787, 0.2594, 0.7297],&#xA;       [1.2337, 0.9957, 0.6257, 0.903, 0.8375, 0, 0.9162, 0.7046, 0.2343],&#xA;       [0.5574, 0.6826, 1.0526, 0.0132, 0.0787, 0.9162, 0, 0.3381, 0.8084],&#xA;       [0.8691, 0.8633, 1.2333, 0.3249, 0.2594, 0.7046, 0.3381, 0, 0.4703],&#xA;       [1.3394, 1.23, 0.860, 0.7952, 0.7297, 0.2343, 0.8084, 0.4703, 0]]&#xA;&#xA;n = 9&#xA;&#xA;set_n = range(9)&#xA;opt_model = cpx.Model(name=&quot;MIP Model&quot;)&#xA;&#xA;x = {(i, j): opt_model.binary_var(name=&quot;x_{0}_{1}&quot;.format(i, j)) for i in set_n for j in set_n if not i == j}&#xA;D = {i: opt_model.continuous_var(name=&quot;D_{0}&quot;.format(i)) for i in set_n}&#xA;&#xA;objective = opt_model.sum(DST[i][j] * x[i, j] for i in set_n for j in set_n if not i == j)&#xA;&#xA;for i in set_n:&#xA;    xp = opt_model.sum(x[j, i] for j in set_n if not i == j) - opt_model.sum(x[i, k] for k in set_n if not i == k)&#xA;    opt_model.add_constraint(xp == 0)&#xA;&#xA;opt_model.add_constraint(D[0] == 0)&#xA;&#xA;M = 100&#xA;&#xA;for i in set_n:&#xA;    for j in set_n:&#xA;        if not i == j and not i == 0:&#xA;            opt_model.add_constraint(D[i] &amp;lt;= D[j] + DST[i][j] + M * (1 - x[j, i]))&#xA;            opt_model.add_constraint(D[i] &amp;gt;= D[j] + DST[i][j] - M * (1 - x[j, i]))&#xA;&#xA;for j in set_n:&#xA;    opt_model.add_constraint(opt_model.sum(x[i, j] for i in set_n if not i == j) == 1)&#xA;&#xA;lazyct_cb = opt_model.register_callback(DOLazyCallback)&#xA;&#xA;lazyct_cb.x = x&#xA;lazyct_cb.set_n = set_n&#xA;lazyct_cb.D = D&#xA;lazyct_cb.DST = DST&#xA;lazyct_cb.x = x&#xA;&#xA;opt_model.lazy_callback = lazyct_cb&#xA;&#xA;opt_model.parameters.mip.tolerances.mipgap = 0&#xA;opt_model.minimize(objective)&#xA;solv = opt_model.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My aspected behavior from the code is that first, it should eliminate the sub tour by using the callback only, then it should run the above MTZ like a constraint to assign distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: There are other constraints that can change the path chosen. They should also run after the sub tour is eliminated (I think so).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing I am sure of is that I can't add MTZ like constraint as a normal constraint using &lt;code&gt;add_constraint&lt;/code&gt; since it also eliminated sub tour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried adding MTZ like constraint using &lt;code&gt;add_user_cut_constraint&lt;/code&gt; , &lt;code&gt;add_lazy_constraint&lt;/code&gt; , &lt;code&gt;register_constraint&lt;/code&gt; (&lt;code&gt;register_constraint&lt;/code&gt; is added inside the callback), for a small example of 9 node TSP. All of the above methods give the correct results, but I am not sure what is the correct method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am highly confident about &lt;code&gt;register_constraint&lt;/code&gt; as it adds constraint when the callback is called, but not sure that every time callback is called keep adding the same constraint, again and again, is a good idea or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also another method in which I can add this MTZ like constraint inside callback using method &lt;code&gt;get_cpx_unsatisfied_cts&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(pseudocode):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ct = tour &amp;lt;= n - 1&#xA;cst = [ct]&#xA;cst.append(D[i] &amp;lt;= D[j] + DST[i][j] + M * (1 - x[j, i]))&#xA;cst.append(D[i] &amp;gt;= D[j] + DST[i][j] - M * (1 - x[j, i]))&#xA;unsats = self.get_cpx_unsatisfied_cts(cst, sol, tolerance=0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="700" LastEditorUserId="123" LastEditDate="2020-03-13T07:37:59.617" LastActivityDate="2020-03-13T12:42:55.213" Title="Controlling the constraint execution sequence in docplex" Tags="|mixed-integer-programming|linear-programming|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3696" PostTypeId="2" ParentId="3695" CreationDate="2020-03-13T12:42:55.213" Score="4" Body="&lt;p&gt;First of all, calling &lt;code&gt;add_lazy_constraint&lt;/code&gt; in your code is useless. The list of constraints that this establishes is never used. This is something that comes from the original lazy constraint callback example but is now unused in your updated code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next there seems to be a misconception: There is no &quot;order&quot; of constraints. All constraints are always enforced simultaneously. So as soon as you add MTZ constraints, subtour elimination constraints will no longer be violated. Since both types of constraints aim at eliminating subtours, you should probably settle for one of the two.&lt;/p&gt;&#xA;" OwnerUserId="3179" LastActivityDate="2020-03-13T12:42:55.213" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3697" PostTypeId="2" ParentId="3654" CreationDate="2020-03-13T19:23:24.137" Score="2" Body="&lt;p&gt;Have you tried using &lt;a href=&quot;https://link.springer.com/article/10.1023%2FA%3A1025794313696&quot; rel=&quot;nofollow noreferrer&quot;&gt;SOCP relaxation&lt;/a&gt; instead of RLT? &lt;/p&gt;&#xA;" OwnerUserId="3186" LastActivityDate="2020-03-13T19:23:24.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3698" PostTypeId="2" ParentId="3691" CreationDate="2020-03-14T05:02:01.057" Score="5" Body="&lt;p&gt;No, an optimal solution need not exist. Take &lt;span class=&quot;math-container&quot;&gt;$f: \mathbb{R} \to \mathbb{R}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$f(x) = e^{x}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you restrict &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; to be compact instead of just closed, then you are guaranteed a solution. In fact, convexity is not required. For a simple proof, let &lt;span class=&quot;math-container&quot;&gt;$f(x_n) \to \inf_{x \in S} f(x)$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$x_n \in S$&lt;/span&gt; has a convergent subsequence by compactness, and let &lt;span class=&quot;math-container&quot;&gt;$x \in S$&lt;/span&gt; be its limit point. By lower semicontinuity &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; minimizes &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. Lastly, note that the infimum above must be finite because &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is proper, hence &lt;span class=&quot;math-container&quot;&gt;$f(x) \neq \pm \infty$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3066" LastEditorUserId="3066" LastEditDate="2020-03-14T05:18:20.083" LastActivityDate="2020-03-14T05:18:20.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3699" PostTypeId="1" AcceptedAnswerId="3700" CreationDate="2020-03-14T15:37:56.963" Score="3" ViewCount="609" Body="&lt;p&gt;Here is a simple example of logical operation in docplex taken from  &lt;a href=&quot;https://www.ibm.com/developerworks/community/forums/html/topic?id=b8ca2821-3f08-4cf2-a4c7-55253f5265fe&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. Code below works fine.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;m = Model(&quot;test&quot;)&#xA;&#xA;a = m.binary_var(name=&quot;a&quot;)&#xA;b = m.binary_var(name=&quot;b&quot;)&#xA;c = m.binary_var(name=&quot;c&quot;)&#xA;&#xA;m.add_constraint(m.logical_and(a, b) == c)&#xA;m.add_constraint(a == 1)&#xA;m.add_constraint(b == 0)&#xA;&#xA;if m.solve():&#xA;    m.print_solution(print_zeros=True)&#xA;else:&#xA;    print(m.solve_details)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just for the purpose of testing, I created an array of a binary variable. Code below gives compilation error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;m = Model(&quot;test&quot;)&#xA;&#xA;w = {k: m.binary_var(name=&quot;w_{0}&quot;.format(k)) for k in range(10)}&#xA;c = m.binary_var(name=&quot;c&quot;)&#xA;&#xA;m.add_constraint(m.logical_and(w[k] for k in range(10)) == c)&#xA;&#xA;if m.solve():&#xA;    m.print_solution(print_zeros=True)&#xA;else:&#xA;    print(m.solve_details)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;docplex.mp.utils.DOcplexException: Model.logical_and, arg#0: Not a logical operand: &amp;lt;generator object &amp;lt;genexpr&amp;gt; at 0x7fd373a8f410&amp;gt;. Expecting binary variable, logical expression&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="700" LastEditorUserId="123" LastEditDate="2020-03-14T20:40:13.357" LastActivityDate="2020-03-14T20:40:13.357" Title="Logical operation on an array in DOCplex" Tags="|cplex|python|logical-constraints|docplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3700" PostTypeId="2" ParentId="3699" CreationDate="2020-03-14T16:14:39.090" Score="4" Body="&lt;p&gt;The first argument in &lt;code&gt;logical_and&lt;/code&gt; is &lt;code&gt;*args&lt;/code&gt; but it's not unpacked in the subroutines inside of &lt;code&gt;logical_and&lt;/code&gt;. Your error will be gone if you change the following line from&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;m.add_constraint(m.logical_and(w[k] for k in range(10)) == c)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;m.add_constraint(m.logical_and(*(w[k] for k in range(10))) == c)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2020-03-14T16:14:39.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3701" PostTypeId="2" ParentId="3646" CreationDate="2020-03-14T18:40:37.837" Score="1" Body="&lt;p&gt;Regardless of Rob's comprehensive answer, the problem is a bit strange. The last constraint is always met, and in the others  &lt;span class=&quot;math-container&quot;&gt;$W_1$&lt;/span&gt; does not affect the result, almost. That's why I get the trivial solution &lt;span class=&quot;math-container&quot;&gt;$Y = W_2$&lt;/span&gt;. However, if &lt;span class=&quot;math-container&quot;&gt;$W_1 = W_2 = 1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; can take both 0 and 1.&lt;/p&gt;&#xA;" OwnerUserId="3186" LastEditorUserId="3186" LastEditDate="2020-03-14T19:06:58.340" LastActivityDate="2020-03-14T19:06:58.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3702" PostTypeId="2" ParentId="3556" CreationDate="2020-03-14T20:58:53.427" Score="3" Body="&lt;p&gt;The use of SQP to solve interesting technical problems can be seen in &lt;a href=&quot;http://hqp.sourceforge.net/omuses.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this work&lt;/a&gt; (pp. 26-31). In addition, a project &lt;a href=&quot;http://omuses.github.io/hqp/doc/html/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;HQP&lt;/a&gt; developed for over 20 years is available on this site free of charge.&lt;/p&gt;&#xA;" OwnerUserId="3186" LastActivityDate="2020-03-14T20:58:53.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3703" PostTypeId="1" CreationDate="2020-03-15T10:56:54.617" Score="8" ViewCount="1607" Body="&lt;p&gt;I have an &lt;code&gt;IloCplex&lt;/code&gt; object which contains a MILP. &#xA;Is there a way to obtain the objective value of its LP relaxation, without having to rewrite the entire model as an LP?&lt;/p&gt;&#xA;" OwnerUserId="766" LastActivityDate="2021-01-04T15:44:45.440" Title="Cplex 12.10: How can I solve an LP relaxation?" Tags="|mixed-integer-programming|cplex|lp-relaxation|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3704" PostTypeId="2" ParentId="3703" CreationDate="2020-03-15T20:55:22.490" Score="8" Body="&lt;p&gt;Based on @prubin's instigation, I have turned my comment into an answer:&#xA;You can add an IloConversion of each variable to you IloModel object, and then solve the resulting model using a corresponding IloCplex object. In OPL you can run the covertAllIntVars() function on your OPL model and then solve the resulting model. I am almost sure that there is no equivalent to this function in Java or C++. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can only add one IloConversion of a variable to a model, implying that you cannot add a conversion from ILOBOOL/ILOINT to ILOFLOAT, and then convert the LP relaxation back to a MIP by adding another IloConversion from ILOFLOAT to ILOBOOL/ILOINT. However, you can remove the first IloConversion by invoking the end() method on the corresponding IloExtractable.&#xA;For more information, you can check this link &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.5.0/ilog.odms.ide.help/refcppopl/html/classes/IloConversion.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.5.0/ilog.odms.ide.help/refcppopl/html/classes/IloConversion.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2020-03-18T07:58:20.237" LastActivityDate="2020-03-18T07:58:20.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3705" PostTypeId="1" AcceptedAnswerId="3706" CreationDate="2020-03-16T06:16:32.960" Score="5" ViewCount="182" Body="&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/3626/tsp-subtour-elimination-by-assigning-distance-traveled&quot;&gt;Here&lt;/a&gt; is my question where I am propagating distance through the graph, I was wondering if it is possible to do when the graph has cycles, i.e., traveling the same node multiple time then is it possible to assign current distance traveled at each instance of that node? &lt;/p&gt;&#xA;" OwnerUserId="700" LastActivityDate="2020-03-16T08:52:28.347" Title="Propagate value through a graph" Tags="|linear-programming|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3706" PostTypeId="2" ParentId="3705" CreationDate="2020-03-16T06:48:56.587" Score="7" Body="&lt;p&gt;You can make copies of each node (as many copies as times you can visit the node). Then use your constraints as before on this larger graph. This is e.g., done in some papers for the &lt;em&gt;green vehicle problem&lt;/em&gt; (see for instance &lt;a href=&quot;https://doi.org/10.1016/j.tre.2011.08.001&quot; rel=&quot;noreferrer&quot;&gt;A Green Vehicle Routing Problem&lt;/a&gt; by S. Erdoğan and E. Miller-Hooks).&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2020-03-16T08:52:28.347" LastActivityDate="2020-03-16T08:52:28.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3707" PostTypeId="1" CreationDate="2020-03-16T11:54:18.753" Score="16" ViewCount="1569" Body="&lt;p&gt;I'm doing a project about the estimation of the difficulty of mixed-integer programming problems. The MIP instances are from &lt;a href=&quot;https://miplib.zib.de/&quot; rel=&quot;noreferrer&quot;&gt;MIPLIB 2017&lt;/a&gt;. And there are three categories of MIPs provided by MIPLIB 2017, which are &quot;Easy&quot;, &quot;Hard&quot; and &quot;Open&quot;, which represent the solving difficulty of MIPs. My project aims to figure out the characteristics of MIPs in different categories and tries to build a predictive model to predict the difficulty of a MIP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I'm doing this project, I get more and more confused about the practical meaning of estimating the difficulty of a MIP. What does it help of knowing the difficulty of a MIP?&lt;/p&gt;&#xA;" OwnerUserId="3191" LastEditorUserId="279" LastEditDate="2020-03-16T22:50:40.290" LastActivityDate="2020-03-16T22:50:40.290" Title="Why do we need to measure the difficulty of mixed-integer programming problems?" Tags="|mixed-integer-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3708" PostTypeId="2" ParentId="3707" CreationDate="2020-03-16T14:07:26.487" Score="11" Body="&lt;p&gt;What you are looking for may already exist. E.g., here is a paper on &lt;a href=&quot;http://www.pitt.edu/~schaefer/papers/PredictingBranchandBound.pdf&quot; rel=&quot;noreferrer&quot;&gt;Predicting the Solution Time of Branch-and-Bound Algorithms for Mixed-Integer Programs&lt;/a&gt;, and another one on &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0004370213001082&quot; rel=&quot;noreferrer&quot;&gt;Algorithm runtime prediction: Methods &amp;amp; evaluation&lt;/a&gt;. Already years ago, researchers tried to &lt;a href=&quot;https://www.andrew.cmu.edu/user/gc0v/webpub/EarlyEstimates.pdf&quot; rel=&quot;noreferrer&quot;&gt;predict the size of the B&amp;amp;B tree&lt;/a&gt; and it has been &lt;a href=&quot;https://dl.acm.org/doi/10.5555/3171642.3171711&quot; rel=&quot;noreferrer&quot;&gt;a topic also recently&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a &lt;a href=&quot;https://www.researchgate.net/post/How_to_measure_the_difficulty_of_a_Mixed-Linear_Integer_Programming_MILP_problem&quot; rel=&quot;noreferrer&quot;&gt;thread&lt;/a&gt; about it on research gate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is not exactly what you are looking for, then these papers at least are worthwhile reading for their motivations, which then again may answer your question.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2020-03-16T14:07:26.487" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3709" PostTypeId="1" CreationDate="2020-03-16T14:49:57.147" Score="4" ViewCount="256" Body="&lt;p&gt;I am trying to model the following:&#xA;There is a shop open from xx AM to yy PM.&#xA;In each 30 min time slot, there have to be demand[timeSlot] = x employees present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. the shop is open from 08am to 10am. Then there are the slots 8am-08:30, 08:30-09:00, 09:00-09:30 and 09:30-10:00 with demand = [1,2,2,1].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a set of employees. For each employee, I want to represent their working time with an interval decision variable:&#xA;dvar interval x[e in Employees] optional size 4..8&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem now is formulating the constraint that in each time slot, the demand for employees must be met. How can I match the intervals (having start and end time) with the coverage of the time slot?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The constraint should be like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;sum(e in Employees, x[e] covers time slot s) x[e] &gt;= demand[s], for all time slots s&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in the time slot 09:00-09:30, two employees have to be present. So I need at least to decision variable intervals, which each have a starting time smaller or equal than 09:00 and endTime greater or equal than 09:30.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone understand what I am trying to do and maybe have some hint or the solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot!&lt;/p&gt;&#xA;" OwnerUserId="3192" LastEditorUserId="700" LastEditDate="2020-03-20T16:02:39.937" LastActivityDate="2020-03-20T16:02:39.937" Title="Constraint programming in OPL: intervals covering time slots" Tags="|modeling|cplex|constraint|constraint-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3710" PostTypeId="1" AcceptedAnswerId="3711" CreationDate="2020-03-16T16:02:12.577" Score="3" ViewCount="158" Body="&lt;p&gt;I am solving:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\begin{array}{rll}&#xA;y^* = \min &amp;amp; y &amp;amp; \\&#xA;\mathrm{s.t.} &amp;amp; a_i^\top x \leq y, &amp;amp; i=1,\ldots,m \\&#xA;&amp;amp; x \succeq 0,\  \mathbf{1}^\top x = 1. &amp;amp;&#xA;\end{array}&#xA;\end{align}&lt;/span&gt;&#xA;My variables are &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{R}$&lt;/span&gt;. Notice that the second line of constraints define a unit &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-dimensional simplex for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Assume the minimum value is &lt;span class=&quot;math-container&quot;&gt;$y^*$&lt;/span&gt;. Under what conditions &lt;span class=&quot;math-container&quot;&gt;$y^*$&lt;/span&gt; is still the optimal value of the following problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\begin{array}{rll}&#xA;y^{**} =\min &amp;amp; y &amp;amp; \\&#xA;\mathrm{s.t.} &amp;amp; a_i^\top x \leq y, &amp;amp; i=1,\ldots,m \\&#xA;&amp;amp; x \succeq 0,\  \mathbf{1}^\top x \leq 1. &amp;amp;&#xA;\end{array}&#xA;\end{align}&lt;/span&gt;&#xA;Notice that only the &lt;span class=&quot;math-container&quot;&gt;$\mathbf{1}^\top x =1$&lt;/span&gt; is changed to &lt;span class=&quot;math-container&quot;&gt;$\mathbf{1}^\top x \leq 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit: I refined my question thanks to Mark L. Stone.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2020-03-16T17:55:05.217" LastActivityDate="2020-03-16T20:59:24.297" Title="Minimizing a variable over the intersection of simplex and linear constraints" Tags="|optimization|linear-programming|constraint|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3711" PostTypeId="2" ParentId="3710" CreationDate="2020-03-16T16:18:29.770" Score="4" Body="&lt;p&gt;You can say it, but you'd be incorrect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the very simple counterexample, &lt;span class=&quot;math-container&quot;&gt;$n = m = 1, a_i = 1$&lt;/span&gt;. Then the solution to the first problem is &lt;span class=&quot;math-container&quot;&gt;$x^{*} = y^* = 1.$&lt;/span&gt;. And the solution to the second problem is &lt;span class=&quot;math-container&quot;&gt;$x^{**} = y^{**} = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-03-16T16:24:29.223" LastActivityDate="2020-03-16T16:24:29.223" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3712" PostTypeId="2" ParentId="3707" CreationDate="2020-03-16T16:39:40.250" Score="13" Body="&lt;p&gt;The performance of an exact (or heuristic) solver on an instance will depend on some intrinsic characteristics, normally called features. And different solvers, or different configurations of a solver, will obtain different results on instances with different characteristics. For NP-hard problems, this might mean that an instance solved by solver X in few minutes can take hours using solver Y, and the opposite situation can happen for another instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To know whether you should use X or Y to solve an instance, you can run the two algorithms in parallel and see which one terminates first, or you can try to look at the instance characteristics and predict which solver will terminate first. If you have to solve multiple instances, the second approach will make you save a lot of time (hopefully).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, by knowing that an instance is &quot;easy&quot; you can choose to use an exact solver (ideally, you'll also be able to tell which solver to choose), while for an instance that is or looks like an &quot;open&quot; one you can save time and use an heuristic approach from the start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to the links provided by Marco Lübbecke in his answer, you can take a look at the the &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0004370216300388#se0080&quot; rel=&quot;noreferrer&quot;&gt;Algorithm Selection library paper&lt;/a&gt;, this &lt;a href=&quot;https://www.mitpressjournals.org/doi/full/10.1162/evco_a_00242&quot; rel=&quot;noreferrer&quot;&gt;recent survey&lt;/a&gt; on algorithm selection, or &lt;a href=&quot;https://www.jair.org/index.php/jair/article/download/10556/25269&quot; rel=&quot;noreferrer&quot;&gt;this portfolio selector&lt;/a&gt; for SAT.&lt;/p&gt;&#xA;" OwnerUserId="224" LastActivityDate="2020-03-16T16:39:40.250" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3713" PostTypeId="2" ParentId="3710" CreationDate="2020-03-16T20:59:24.297" Score="4" Body="&lt;p&gt;To answer the revised question, &lt;span class=&quot;math-container&quot;&gt;$y^{**}=y^*$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$y^*\le 0$&lt;/span&gt;. Your original problem looks at all convex combinations of the columns of the &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; matrix. The modified problem is equivalent to looking at all convex combinations of the columns of &lt;span class=&quot;math-container&quot;&gt;$\overline{A}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\overline{A}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; augmented by a column of zeros. So think of the second problem as using &lt;span class=&quot;math-container&quot;&gt;$\overline{A}$&lt;/span&gt; (and raising the dimension of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; by one) while continuing to require the sum of the (expanded) &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; vector to equal 1. Ask yourself how &quot;diluting&quot; a solution to the original problem by &quot;mixing in&quot; a zero vector could help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For any &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; feasible in the original problem and any &lt;span class=&quot;math-container&quot;&gt;$\lambda\in [0,1]$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\left[\begin{array}{c}\lambda x\\1-\lambda\end{array}\right]$&lt;/span&gt; is feasible in the modified problem. Let &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; be optimal in the original problem, so that &lt;span class=&quot;math-container&quot;&gt;$Ax^*\le y^* e$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$e=(1,\dots,1)^\prime$&lt;/span&gt;, and choose &lt;span class=&quot;math-container&quot;&gt;$\lambda = \frac{1}{2}$&lt;/span&gt;. Then &lt;span class=&quot;math-container&quot;&gt;$$\overline{A}\left[\begin{array}{c}\frac{1}{2} x^*\\1-\frac{1}{2}\end{array}\right]=\lambda Ax^* + (1-\lambda)0\le \lambda y^* e$$&lt;/span&gt; in the revised problem, from which it follows that &lt;span class=&quot;math-container&quot;&gt;$y^{**} \le \lambda y^*$&lt;/span&gt;. So &lt;span class=&quot;math-container&quot;&gt;$$y^{**}=y^* \implies y^* \le \lambda y^* \implies y^* \le 0.$$&lt;/span&gt; That's the necessity part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sufficiency can be proved by contradiction. Assume that &lt;span class=&quot;math-container&quot;&gt;$y^* \le 0$&lt;/span&gt; and that &lt;span class=&quot;math-container&quot;&gt;$y^{**} \lt y^*$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$x^* = \left[\begin{array}{c}\hat{x}\\x_0\end{array}\right]$&lt;/span&gt; be optimal in the modified problem, meaning &lt;span class=&quot;math-container&quot;&gt;$A\hat{x} + x_0 \cdot 0\le y^{**} e$&lt;/span&gt;. Since &lt;span class=&quot;math-container&quot;&gt;$y^{**} \lt y^* \le 0$&lt;/span&gt;, clearly &lt;span class=&quot;math-container&quot;&gt;$x_0 \lt 1$&lt;/span&gt;. In that case, &lt;span class=&quot;math-container&quot;&gt;$x=\frac{1}{1-x_0}\hat{x}$&lt;/span&gt; is feasible in the original problem with &lt;span class=&quot;math-container&quot;&gt;$$Ax=\frac{1}{1-x_0}A\hat{x}\le \frac{1}{1-x_0} y^{**}e \lt \frac{1}{1-x_0}y^* e\le y^* e$$&lt;/span&gt;which contradicts the optimality of &lt;span class=&quot;math-container&quot;&gt;$y^*$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-03-16T20:59:24.297" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3714" PostTypeId="1" AcceptedAnswerId="3716" CreationDate="2020-03-17T08:54:37.173" Score="7" ViewCount="3219" Body="&lt;p&gt;I wonder if there is any list of string parameters documented.&lt;/p&gt;&#xA;&lt;p&gt;So far, I only know &lt;code&gt;max_time_in_seconds&lt;/code&gt; and &lt;code&gt;num_search_workers&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Screening code files as e.g. &lt;a href=&quot;https://google.github.io/or-tools/dotnet/CpSolver_8cs_source.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://google.github.io/or-tools/dotnet/CpSolver_8cs_source.html&lt;/a&gt; didn't provide further intel.&lt;/p&gt;&#xA;" OwnerUserId="3096" LastEditorUserId="981" LastEditDate="2023-12-22T15:11:31.827" LastActivityDate="2023-12-22T15:11:31.827" Title="CP-SAT ortools - Is there any complete list of possible/available StringParameters for the CpSolver?" Tags="|solver|constraint-programming|or-tools|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3715" PostTypeId="2" ParentId="2869" CreationDate="2020-03-17T13:47:44.890" Score="9" Body="&lt;p&gt;Graph cuts were mainly used in computer vision, where since 2011 deep neural networks have taken over the field. The decline from 2015 on is attributable to a time delay in picking up neural networks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, graph cuts were used for inferring maximum probable states in Markov Random Fields (MRF), with input costs coming from hand-tuned features. Solutions of these MRFs corresponded to some computer vision problem, be it segmentation, depth estimation in stereo, disparity estimation for optical flow etc. Currently, such tasks are solved to higher accuracy by neural networks without needing optimization, since their feature extraction part is much more sophisticated than previous pipelines which used graph cuts as a submodule.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another less important issue is parallelization. Most efficient graph cut algorithms rely on combinatorial solvers that are difficult to parallelize, like the Boykov-Kolmogorov max-flow algorithm or the newer Maximum Flow by Incremental Breadth-First Search algorithm by Goldberg et al. Running them on graphics cards is rather difficult. Hence, even for very large-scale 3d-problems which were previously approached with graph cuts, this is less the case nowadays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A third reason is that some people working on graph cuts have moved on and are now active in other fields, which are less cited than computer vision and machine learning.&lt;/p&gt;&#xA;" OwnerUserId="3199" LastActivityDate="2020-03-17T13:47:44.890" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3716" PostTypeId="2" ParentId="3714" CreationDate="2020-03-17T15:25:28.287" Score="9" Body="&lt;p&gt;As many things in Google, OR-Tools uses &lt;a href=&quot;https://developers.google.com/protocol-buffers&quot; rel=&quot;noreferrer&quot;&gt;Protocol Buffers&lt;/a&gt; to serialize data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a list of all &lt;code&gt;.proto&lt;/code&gt; files in OR-Tools: &lt;a href=&quot;https://github.com/google/or-tools/search?l=Protocol+Buffer&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/google/or-tools/search?l=Protocol+Buffer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The parameters for the CP-SAT solver are listed in the &lt;code&gt;sat_parameters.proto&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/sat/sat_parameters.proto&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/ortools/sat/sat_parameters.proto&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2020-03-17T21:18:04.720" LastActivityDate="2020-03-17T21:18:04.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3717" PostTypeId="1" CreationDate="2020-03-17T17:46:15.800" Score="9" ViewCount="559" Body="&lt;h2&gt;Problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathcal C = \{ X \in \mathbb{R}^n \mid g(X) \leq 0\}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is convex, and let &lt;span class=&quot;math-container&quot;&gt;$X_c \in \mathcal{C}$&lt;/span&gt;. Is there any algorithm to compute the distance from &lt;span class=&quot;math-container&quot;&gt;$X_c$&lt;/span&gt; to the boundary of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{C}$&lt;/span&gt; ? &#xA;This can be formulated like the following optimization problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \min_{X\in \mathbb{R}^n}  \hspace{0.5cm} (X-X_c)^\top\cdot (X - X_c) \quad \text{s.t} \quad g(X) = 0 $$&lt;/span&gt; or even worse:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \min_{X\in \mathbb{R}^n}  \hspace{0.5cm} (X-X_c)^\top\cdot (X - X_c) \quad \text{s.t} \quad g(X) \geq 0 $$&lt;/span&gt; which is a minimization of a convex function over a concave domain. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Are there any known algorithms for this problem? Is the distance from point to boundary convex in general?  &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Indeed, based on the answer of @batwing below it is enough to solve:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max &amp;amp;\quad r\\\text{s.t}&amp;amp;\quad g(X_c + r\cdot u) \leq 0\\&amp;amp;\quad\forall \|u\| \leq 1\end{align}&lt;/span&gt; which is an infinite programming problem (it has an infinity of constraints). One can reformulate this in the following way:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad r\\\text{s.t}&amp;amp;\quad g(X_c + r\cdot u) \leq 0\\&amp;amp;\quad\|u\| \leq 1\end{align}&lt;/span&gt; which is unfortunately not convex in variables &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;. &lt;/p&gt;&#xA;" OwnerUserId="3200" LastEditorUserId="123" LastEditDate="2020-03-20T15:24:51.410" LastActivityDate="2021-12-08T18:33:00.993" Title="Compute the distance from a point inside a convex set to the boundary of the set" Tags="|optimization|convexity|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3718" PostTypeId="1" CreationDate="2020-03-18T07:29:49.507" Score="4" ViewCount="883" Body="&lt;p&gt;I am trying to solve vehicle routing problem in java and I am looking for libraries for the same. I did a POC using google or-tools and it seems to be solving all my use cases. I would like to know if anyone in the community has used OR-tools libraries in production and if yes, what are the problems I have to look out for ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not google or-tools, what are the other VRP java libraries you are using and how was your experience using them in production ? I am particularly interested in jsprit/ Optaplanner/or-tools etc., w.r.t ease of use, maintainability (when new constraints have to be added) and the performance in production.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks &lt;/p&gt;&#xA;" OwnerUserId="3182" LastEditorUserId="3182" LastEditDate="2020-03-18T11:21:54.043" LastActivityDate="2020-03-21T10:10:20.020" Title="Solving vehicle routing problem in java" Tags="|or-tools|vehicle-routing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3719" PostTypeId="1" CreationDate="2020-03-18T10:49:13.520" Score="6" ViewCount="86" Body="&lt;p&gt;I'm working on a nifty little feature for our next release, i.e., to print the number of possible integer combinations left during branch and bound. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is really handy for the user because they can monitor improvement even if the optimality gap is not improving for a while.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calculating the combinations is trivial, however I'm wondering what is intuitive for people to read, especially because the numbers are way too big to just print on the terminal (e.g. &lt;span class=&quot;math-container&quot;&gt;$2^{10,000}$&lt;/span&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have 2 options in mind, but I don't think the information is conveyed very well, so I thought it would be an interesting question to ask:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Scientific notation, e.g., &lt;span class=&quot;math-container&quot;&gt;$3.\operatorname e5,138,121$&lt;/span&gt;. &#xA;This is not very good because the exponent can actually be too large to even represent on the screen, and the only way to keep it short would be to chain the exponents (e.g., &lt;span class=&quot;math-container&quot;&gt;$3.\operatorname e5\operatorname e6$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Symbolic sequence, e.g., &lt;span class=&quot;math-container&quot;&gt;$2^{9,998}+2^{9,996}+...$&lt;/span&gt; This is more readable, but of course I can only represent the first couple of terms as part of an iterative process, and even then that's a bit too much screen space.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How would you communicate numbers this large in an intuitive yet informative way?&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="123" LastEditDate="2020-03-18T15:30:37.793" LastActivityDate="2020-03-18T15:30:37.793" Title="How to communicate number of integer combinations to a user" Tags="|solver|integer-programming|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3720" PostTypeId="1" CreationDate="2020-03-18T20:16:13.007" Score="7" ViewCount="418" Body="&lt;p&gt;I am building my own CSP solver with simple backtracking, AC3 filtering and variable/value ordering heuristics. It supports non binary constraints. I've done some good progress and I'd like to benchmark it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there some benchmarks out there, like some standard/common CSP problems, or some problem data sets that researchers use for testing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I was hoping there is some standard file format of CSP problem definitions, like a csv or json or xml format, that I could import and parse with my solver. Is there such a thing?&lt;/p&gt;&#xA;" OwnerUserId="3206" LastEditorUserId="3206" LastEditDate="2020-03-19T10:19:30.357" LastActivityDate="2020-03-20T15:10:16.287" Title="Are there some benchmark problems for CSP Solvers?" Tags="|solver|constraint-programming|benchmark|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3721" PostTypeId="2" ParentId="3720" CreationDate="2020-03-18T20:21:23.410" Score="7" Body="&lt;p&gt;Here's one: &lt;a href=&quot;http://www.csplib.org/&quot; rel=&quot;noreferrer&quot;&gt;CSPLib: A problem library for constraints&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-03-18T20:21:23.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3722" PostTypeId="1" CreationDate="2020-03-18T21:43:26.737" Score="9" ViewCount="233" Body="&lt;p&gt;Since I am confined and I have some free time, I am looking for ideas of OR applications in everyday life. What I've seen so far are apps like solving VRP, Production planning etc. that are mostly used in business/industry. Any ideas of everyday life usage of OR? &#xA;I would appreciate also ideas for apps for people in needs&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I am asking for apps ideas to develop and not apps to use &lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2020-03-19T20:56:05.220" LastActivityDate="2020-03-20T10:25:11.417" Title="Operations Research Apps for everyday use" Tags="|applications|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="3723" PostTypeId="2" ParentId="3717" CreationDate="2020-03-19T02:48:15.990" Score="4" Body="&lt;p&gt;You should be able to modify the maximum volume inscribed ellipsoid within a convex set formulation provided in slide 3 of &lt;a href=&quot;https://see.stanford.edu/materials/lsocoee364a/08GeometricalProbs.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://see.stanford.edu/materials/lsocoee364a/08GeometricalProbs.pdf&lt;/a&gt; for your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The formulation can be adapted to your case as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA; \underset{ B \in S_{++}^{n}, r}{\max}&amp;amp;\quad r\\&#xA;\text{s.t.}&amp;amp;\quad \underset{\|u\|_{2} \leq 1}{\sup} I_{\mathcal{C}}(B u + X_c) \leq 0\\&#xA;&amp;amp;\quad B_{ij} = 0, i\neq j\\&#xA;&amp;amp;\quad B_{ii} = r, \forall i \in \lbrace{1, 2 , \dotsc, n \rbrace}&#xA;\end{align}&lt;/span&gt; &#xA;where &lt;span class=&quot;math-container&quot;&gt;$I_{\mathcal{C}} (\cdot)$&lt;/span&gt; is the indicator function for convex set &lt;span class=&quot;math-container&quot;&gt;$\mathcal{C}$&lt;/span&gt;. The optimal &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; corresponding to the problem above is the distance you required. The constraints on &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; basically enforce &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; to be an identity matrix scaled by &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;, to force &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; to be a euclidean ball instead of an ellipsoid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned in the link above, evaluating whether &lt;span class=&quot;math-container&quot;&gt;$Bu + X_{c} \in \mathcal{C}$&lt;/span&gt; is hard in general even for convex &lt;span class=&quot;math-container&quot;&gt;$\mathcal{C}$&lt;/span&gt;. However, if &lt;span class=&quot;math-container&quot;&gt;$\mathcal{C}$&lt;/span&gt; has a special structure or is simple enough, then you may be able to use the formulation above. &lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="123" LastEditDate="2020-03-19T07:48:46.427" LastActivityDate="2020-03-19T07:48:46.427" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3724" PostTypeId="2" ParentId="3709" CreationDate="2020-03-19T07:08:48.963" Score="3" Body="&lt;p&gt;within CPOptimizer scheduling, you could use cumul functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;using CP;&#xA;&#xA;int xx=8*2;&#xA;int yy=17*2; // time unit is 30 minutes&#xA;&#xA;{string} Employees={&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;,&quot;E&quot;,&quot;F&quot;};&#xA;&#xA;tuple demand&#xA;{&#xA;  key int time; &#xA;  int d; // demand&#xA;}&#xA;&#xA;{demand} demands={&amp;lt;8*2,1&amp;gt;,&amp;lt;8*2+1,2&amp;gt;,&amp;lt;9*2,2&amp;gt;,&amp;lt;9*2+1,1&amp;gt;};&#xA;&#xA;dvar interval it_x[e in Employees] optional in xx..yy+1  size 8..16;&#xA;&#xA;cumulFunction cumulWork=&#xA;   sum(e in Employees) pulse(it_x[e],1);&#xA;&#xA;// minimize nbr of employees we need to call   &#xA;minimize sum(e in Employees) presenceOf(it_x[e]);&#xA;subject to&#xA;{&#xA; forall(d in demands) alwaysIn(cumulWork,d.time,d.time+2,d.d,1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will call 2 employees&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you will see the gantt for employees and the graph for cumulWork.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/csZpV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/csZpV.png&quot; alt=&quot;gantt for employees&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/H5qns.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/H5qns.png&quot; alt=&quot;cumul work graph&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-03-19T07:08:48.963" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3725" PostTypeId="1" AcceptedAnswerId="3726" CreationDate="2020-03-19T19:11:10.940" Score="6" ViewCount="3935" Body="&lt;p&gt;I'm trying to model the following&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IF &lt;span class=&quot;math-container&quot;&gt;$tS = 0$&lt;/span&gt; THEN &lt;span class=&quot;math-container&quot;&gt;$Y = 1$&lt;/span&gt;, IF &lt;span class=&quot;math-container&quot;&gt;$tS \gt 0$&lt;/span&gt; THEN  &lt;span class=&quot;math-container&quot;&gt;$Y \ge 0$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$tS$&lt;/span&gt; is a positive real number and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following: &#xA;&lt;span class=&quot;math-container&quot;&gt;$tS - \epsilon \ge -M  Y$&lt;/span&gt; but this doesn't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The optimiser always sets &lt;span class=&quot;math-container&quot;&gt;$ts =  \epsilon$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y = 0$&lt;/span&gt;   &lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2020-03-19T20:08:53.920" LastActivityDate="2020-03-21T08:08:02.890" Title="IF X = 0 THEN Y = 1, IF X &gt; 0 THEN Y =&gt; 0" Tags="|mixed-integer-programming|binary-variable|big-m|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3726" PostTypeId="2" ParentId="3725" CreationDate="2020-03-19T19:29:06.260" Score="11" Body="&lt;p&gt;Your second if-then statement is always true because &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is binary.  For your first if-then statement, rewrite as its contrapositive &lt;span class=&quot;math-container&quot;&gt;$Y=0 \implies tS \ge \epsilon$&lt;/span&gt;.  The following big-M constraint enforces that:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\epsilon - tS \le MY$$&lt;/span&gt;&#xA;This is equivalent to what you tried.  Note that &lt;span class=&quot;math-container&quot;&gt;$(tS,Y)=(\epsilon,0)$&lt;/span&gt; is feasible, so if the solver always returns it, maybe it is optimal.  As a sanity check, you could fix &lt;span class=&quot;math-container&quot;&gt;$tS$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and see what happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update based on a lower bound of &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$tS$&lt;/span&gt;: you can take &lt;span class=&quot;math-container&quot;&gt;$M=\epsilon-0=\epsilon$&lt;/span&gt;, yielding &lt;span class=&quot;math-container&quot;&gt;$$tS\ge\epsilon(1-Y)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-03-20T12:43:33.460" LastActivityDate="2020-03-20T12:43:33.460" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3727" PostTypeId="2" ParentId="3722" CreationDate="2020-03-20T10:18:10.023" Score="6" Body="&lt;p&gt;A handy idea would be to write an app to schedule meetings between people's calendars (no idea if this already exists though).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than the obvious constraint to find an available slot for everyone involved, people could set other constraints, e.g., &quot;busy 60 mins before and after I meet people out of my organisation&quot;, or &quot;is there an available conference room&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way we tend to set up meetings by email is a bit of back and forth where everyone provides a range and we narrow it down, but this can be done automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could even add weights to your objective in order to make sure that the schedule attempts to fulfill people's wishes/preferences, e.g., &quot;all my meetings must be in a contiguous 3-hour block every day, if possible&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can get interesting from an OR point of view because as the number of people and constraints increases, it can quickly become non-trivial to generate the schedule.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It could also be really interactive and make suggestions, e.g., &quot;I detected that the only way to schedule this meeting this month is the 17.00-18.00 slot on Monday. Are you willing to attend a meeting after working hours?&quot;&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-03-20T10:25:11.417" LastActivityDate="2020-03-20T10:25:11.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3729" PostTypeId="2" ParentId="3720" CreationDate="2020-03-20T15:10:16.287" Score="7" Body="&lt;p&gt;The Minizinc constraint programming benchmark models are in Minzinc file format : &lt;a href=&quot;https://github.com/MiniZinc/minizinc-benchmarks&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/MiniZinc/minizinc-benchmarks&lt;/a&gt;. Each year several CP solvers compete on some problems (see here : &lt;a href=&quot;https://www.minizinc.org/challenge.html&quot; rel=&quot;noreferrer&quot;&gt;Minizinc challenge&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="3210" LastActivityDate="2020-03-20T15:10:16.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3730" PostTypeId="1" CreationDate="2020-03-20T16:38:22.883" Score="5" ViewCount="113" Body="&lt;p&gt;We know that for &lt;span class=&quot;math-container&quot;&gt;$b \geq a$&lt;/span&gt;, and some &lt;span class=&quot;math-container&quot;&gt;$s \geq 0$&lt;/span&gt;, a concave function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; satisfies:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f(a+s) - f(a) \geq f(b+s) - f(b)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is not a frequent definition of concavity, but can be found, e.g., &lt;a href=&quot;http://people.csail.mit.edu/stefje/mlss/cadiz_part1.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, what is the name of this property? Is it easy to prove without Taylor Expansions?&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2020-03-21T08:53:05.403" Title="Concavity: Definition similar to sub-modularity" Tags="|convexity|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3731" PostTypeId="2" ParentId="3730" CreationDate="2020-03-20T18:27:07.643" Score="5" Body="&lt;p&gt;The property you are referring to simply states that the directional derivative of a 1-dimensional concave function is non-increasing. You should be able to find a proof for that inequality &lt;a href=&quot;https://sites.math.washington.edu/~burke/crs/408/lectures/L5-Convexity.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. The link proves it for convex functions, for concave functions simply reverse the sign of the inequality. I was unable to find a standard name for the inequality though, and yes it is easy to prove.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="123" LastEditDate="2020-03-21T08:53:05.403" LastActivityDate="2020-03-21T08:53:05.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3732" PostTypeId="1" AcceptedAnswerId="3770" CreationDate="2020-03-20T18:48:20.240" Score="5" ViewCount="194" Body="&lt;p&gt;Given a list of items to buy on an e-commerce, generate the cheapest possible cart (which obviously includes all the items).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The items can be purchased from many sellers at different prices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sellers have a subset of your articles. (It's unlikely that a seller has all article you need.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the sellers have the same shipping cost and this is linear respect to the spending.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that this is an Integer Linear Programming problem, but I'm unable to express the shipping constraint in the canonical ILP form.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Operations Research professor told me that this is a sub partition problem, but I don't know what is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In an average use case there are about 100 articles to purchase.&lt;/p&gt;&#xA;" OwnerUserId="3212" LastEditorUserId="3212" LastEditDate="2020-03-26T12:18:54.593" LastActivityDate="2020-03-26T12:18:54.593" Title="Find the cheapest shopping cart" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="3734" PostTypeId="2" ParentId="3725" CreationDate="2020-03-21T07:49:29.877" Score="1" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$1 - M \cdot ts \leq Y$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when &lt;span class=&quot;math-container&quot;&gt;$ts = 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$1 \leq Y$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when &lt;span class=&quot;math-container&quot;&gt;$ts \gt 0 $&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$-M \leq Y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0 \leq Y$&lt;/span&gt; (because &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is binary).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the value of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; must be chosen carefully by taking into consideration the decimal precision of &lt;span class=&quot;math-container&quot;&gt;$ts$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$\forall ts \in (0,1] \quad ts\cdot M &amp;gt; 1$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="700" LastEditDate="2020-03-21T08:08:02.890" LastActivityDate="2020-03-21T08:08:02.890" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3735" PostTypeId="2" ParentId="3718" CreationDate="2020-03-21T10:10:20.020" Score="2" Body="&lt;p&gt;&lt;em&gt;I am obviously biased&lt;/em&gt;, but if you're looking to do VRP in a Java environment, do take a look at &lt;a href=&quot;https://quarkus.io/guides/optaplanner&quot; rel=&quot;nofollow noreferrer&quot;&gt;this guide for OptaPlanner that builds a JSON REST service for school timetabling from scratch&lt;/a&gt;. It supports logging, database integration and native compilation (yes, Java does that now). In general, OptaPlanner works with Maven or Gradle - Java, Kotlin or Scala - Quarkus or Spring Boot - JDK HotSpot or GraalVM: it's all good. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;OptaPlanner is heavily used for &lt;a href=&quot;https://www.optaplanner.org/learn/useCases/vehicleRoutingProblem.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;the Vehicle Routing Problem&lt;/a&gt;, including Fortune 500 customers, such as cases with tens of thousands of vehicles that privately benchmarked it against 3 other implementations (including Google OR tools) and found OptaPlanner had the best results. &lt;em&gt;Your mileage may vary, of course.&lt;/em&gt; Especially if you don't powertweak it. We should do open, independent benchmarks between vendors to confirm this and give each vendor a chance to tweak their stuff (private benchmarks aren't fair). Do note that it's a very different philosophy (OO+FP) than traditional solvers (math equations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get started with VRP, take a look at &lt;code&gt;optaplanner-examples&lt;/code&gt; which has a VRP example and &lt;code&gt;optaweb-vehicle-routing&lt;/code&gt; which has OpenStreetMap integration.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2020-03-21T10:10:20.020" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3736" PostTypeId="2" ParentId="1392" CreationDate="2020-03-22T00:10:42.233" Score="2" Body="&lt;p&gt;There are LP algorithms which do not require feasible start, and which do not use a Phase I / Phase II method. These algorithms are based on the &quot;Homogeneous Self-Dual Embedding&quot; (HSDE) approach of Ye, Todd, and Mizuno (Mathematics of Operations Research, Vol. 19, No. 1 (Feb., 1994), pp. 53-67). For suitable parameter choices, a path-following HSDE algorithm achieves the standard iteration complexity bound for interior point methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I understand, almost all conic interior-point solvers today use the Homogeneous Self-Dual Embedding. I've personally implemented that algorithm in about 200 lines of python code.&lt;/p&gt;&#xA;" OwnerUserId="797" LastActivityDate="2020-03-22T00:10:42.233" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3737" PostTypeId="1" AcceptedAnswerId="3738" CreationDate="2020-03-22T14:54:35.273" Score="5" ViewCount="792" Body="&lt;p&gt;I have a problem similar to Markowitz portfolio optimization that I would like to transform into second-order cone programming. I have a linear objective function with a quadratic constraint (assuming that I can take the square on both sides of the constraint to make it quadratic). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Assume that &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a vector of decision variables&lt;/strong&gt;. The objective function and the constraint are below. &lt;strong&gt;How can I transform it into a second-order cone constraint?&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad c^\top X\\\text{s.t.}&amp;amp;\quad\sqrt{\sum_{i,j}^n(W_i\cdot X)^2+(W_j\cdot X)^2+2\rho_{i,j}(W_i\cdot X)\cdot(W_j\cdot X)}\le b\end{align}&lt;/span&gt; where &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$W_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$W_j$&lt;/span&gt; are matrices of constant values of the same dimension as &lt;span class=&quot;math-container&quot;&gt;$c^\top$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\rho_{i,j}$&lt;/span&gt; are correlation coefficients, the matrix generated by it can be assumed to be positive semi-definite&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a constant.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For example, when &lt;span class=&quot;math-container&quot;&gt;$n=2$&lt;/span&gt;, the constraint is given by &lt;span class=&quot;math-container&quot;&gt;$$\sqrt{(W_1\cdot X)^2+(W_2\cdot X)^2+2\rho_{1,2}(W_1\cdot X)\cdot(W_2\cdot X)}\le b.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to understand this both when it is expressed in a more compact matrix form and also when written in the more simplified summation form (as in the question). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;a href=&quot;https://i.stack.imgur.com/gh2sM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gh2sM.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3217" LastEditorUserId="3217" LastEditDate="2020-03-22T20:41:42.750" LastActivityDate="2020-03-22T23:06:36.657" Title="Transforming a Quadratic constraint to SOCP" Tags="|linear-programming|linearization|quadratic-programming|cone|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3738" PostTypeId="2" ParentId="3737" CreationDate="2020-03-22T15:30:08.810" Score="4" Body="&lt;p&gt;Revamp of my answer given the example now provided.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let there be &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; VaR factors. Let &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; = &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; matrix of correlations (the 2nd matrix in your example) of the VaR factors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; = &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; vector whose ith element is &lt;span class=&quot;math-container&quot;&gt;$W_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The VaR portfolio constraint can be expressed as &lt;span class=&quot;math-container&quot;&gt;$$W^TRW \le b^2.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This constraint can be rewritten in terms of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; be the 1st matrix in your example. Then it is the case that &lt;span class=&quot;math-container&quot;&gt;$$W = MX.$$&lt;/span&gt; Using that, the VaR portfolio constraint can then be expressed as a convex quadratic inequality constraint in terms of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; (resulting in QCQP, or actually, QCLP) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$X^T(M^TRM)X \le b^2.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; be the upper triangular Cholesky factor of &lt;span class=&quot;math-container&quot;&gt;$M^TRM$&lt;/span&gt;. I.e., &lt;span class=&quot;math-container&quot;&gt;$M^TRM = F^\top F$&lt;/span&gt;. Then the quadratic inequality constraint can alternatively be expressed as a Second Order Cone Constraint&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\|FX\|_2 \le b.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is because &lt;span class=&quot;math-container&quot;&gt;$X^\top M^TRMX = X^\top F^\top FX = (FX)^\top(FX) = \|FX\|^2_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; is the upper triangular Choelsky factor of &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt;, the Second Order Cone constraint can be expressed as &lt;span class=&quot;math-container&quot;&gt;$$\|GMX\|_2 \le b.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-03-22T23:06:36.657" LastActivityDate="2020-03-22T23:06:36.657" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3739" PostTypeId="1" AcceptedAnswerId="3741" CreationDate="2020-03-22T21:51:14.677" Score="4" ViewCount="74" Body="&lt;p&gt;We have one job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and one machine. Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_i=[x_{i,1},x_{i,2},\ldots,x_{i,T}]$&lt;/span&gt; be a binary vector where &lt;span class=&quot;math-container&quot;&gt;$x_{i,t}=1\iff$&lt;/span&gt; job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is scheduled at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; be a positive number. I would like to find the idle intervals of length &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; or more. An interval &lt;span class=&quot;math-container&quot;&gt;$k=\{s,s+1,\ldots,s'\}$&lt;/span&gt; is idle if &lt;span class=&quot;math-container&quot;&gt;$x_{i,s}=x_{i,s+1}=\cdots=x_{i,s'}=0$&lt;/span&gt;. The length of the interval &lt;span class=&quot;math-container&quot;&gt;$k=\{s,s+1,\ldots,s'\}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$l_k:=s'-s+1$&lt;/span&gt;. An idle interval &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; of length &lt;span class=&quot;math-container&quot;&gt;$l_k$&lt;/span&gt;, is associated a weight &lt;span class=&quot;math-container&quot;&gt;$w_k$&lt;/span&gt;. The objective is to minimize the summation &lt;span class=&quot;math-container&quot;&gt;$\sum_{k}w_k$&lt;/span&gt;, e.g., if &lt;span class=&quot;math-container&quot;&gt;$w_k=1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, then the objective is to minimize the number of idle intervals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, for &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_i=[1,0,0,0,0,1,0,0,0,1]$&lt;/span&gt;, then, we have two idle intervals; one of length &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; (say, with weight &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;) and one of length &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; (say, with weight &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;). Thus, we count the objective as &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I write the objective using the variable &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_i$&lt;/span&gt; in linear formulation? In other words, how to find the idles intervals using &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_i$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3075" LastEditorUserId="500" LastEditDate="2020-03-23T02:18:25.223" LastActivityDate="2020-03-23T02:18:25.223" Title="Find the number of idle intervals with weights" Tags="|integer-programming|binary-variable|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3740" PostTypeId="1" CreationDate="2020-03-22T22:19:09.333" Score="4" ViewCount="158" Body="&lt;p&gt;I am studying the Duality Chapter of Convex Optimization by Boyd. Is it possible that strong duality holds for non-convex optimization? If yes, is there any specific condition? And, what is the relationship between Slater condition and strong duality? Based on the definition in the book, the Slater condition is vague to me. I would be thankful if you can explain it. &#xA;In general, what are the relationship between KKT, strong duality, Slater condition, convex and non-convex optimization?&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2020-03-22T22:19:09.333" Title="Strong Duality and Slater Condition" Tags="|nonconvex-programming|convex-optimization|kkt-conditions|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3741" PostTypeId="2" ParentId="3739" CreationDate="2020-03-22T23:12:52.200" Score="3" Body="&lt;p&gt;You can modify the formulation given in my answer to &lt;a href=&quot;https://or.stackexchange.com/questions/3624/how-to-find-the-idle-intervals-in-integer-programming&quot;&gt;your related question&lt;/a&gt;. &#xA; In terms of that formulation, refine the variable &lt;span class=&quot;math-container&quot;&gt;$x_s$&lt;/span&gt; that indicates the start at time &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; of an idle interval with variables &lt;span class=&quot;math-container&quot;&gt;$x_{s,r}$&lt;/span&gt; that indicate the start at time &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; of an idle interval of length &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;An alternative approach is to think of this in terms of a time-based network, with arc variables &lt;span class=&quot;math-container&quot;&gt;$y_{i,j,k}$&lt;/span&gt; that indicate that job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is scheduled at times &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and not in between; that is, &lt;span class=&quot;math-container&quot;&gt;$$y_{i,j,k} \iff \left(x_{i,j} \land x_{i,k} \land \bigwedge_{t=j+1}^{k-1} \neg x_{i,t}\right)$$&lt;/span&gt;&#xA;This way, you can implicitly impose constraints by omitting arcs.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-03-23T02:18:07.880" LastActivityDate="2020-03-23T02:18:07.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3742" PostTypeId="2" ParentId="3644" CreationDate="2020-03-23T10:10:22.333" Score="7" Body="&lt;p&gt;Another optimization related problem (no data) is raised in the following recent article: &lt;a href=&quot;https://www.nytimes.com/2020/03/22/opinion/health/ventilator-shortage-coronavirus-solution.html&quot; rel=&quot;noreferrer&quot;&gt;How America Can Avoid Italy’s Ventilator Crisis&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The formulation of this &lt;strong&gt;ventilator distribution problem&lt;/strong&gt; is the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Once industry rapidly scales ventilator production, where should these ventilators be delivered? Which hospitals need them most? How can we build a nimble logistics operation that can rapidly deploy these machines the moment that a shortage appears imminent?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2890" LastActivityDate="2020-03-23T10:10:22.333" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3745" PostTypeId="1" AcceptedAnswerId="3746" CreationDate="2020-03-23T23:52:51.180" Score="8" ViewCount="337" Body="&lt;p&gt;Though my title is quite general (please feel free to edit), indeed, I wonder if the following models can be solved in Gurobi or CPLEX. Model 2 is just an alternative one to Model 1. Although we discussed about an MIP reformulation applicability in &lt;a href=&quot;https://or.stackexchange.com/questions/3640/cutting-planes-application-procedure-for-a-specific-problem/3641?noredirect=1#comment4610_3641&quot;&gt;here&lt;/a&gt; for a similar version of the problem, I would like to directly solve the problem as is. If Gurobi or CPLEX cannot handle it, can you please suggest some other solvers that can handle 10,000 variables as &lt;span class=&quot;math-container&quot;&gt;$|P|\approx10000$&lt;/span&gt;. Note that all notations other than &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; (which are continuous in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^+$&lt;/span&gt;) represent some non-negative constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Model 1:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\max &amp;amp;\quad \sum_{\substack{p\in P,\\s\in S_p}}e_{ps}\left(H^+-h_p\right)\tag1\\\text{s.t.}&amp;amp;\quad \sum_{p\in P}\left(\frac{k_p\tau_p}{h_p}-\sum_{s\in S_p}e_{ps}\right)\leq \kappa\tag2\\&amp;amp;\quad\sum_{\{p\in P|d_p=t,\theta_p=j\}}\frac{\tau_p}{h_p} \leq M_{tj} \qquad \forall t\in T, j\in J\tag3\\&amp;amp;\quad f_{ps}h_p \leq B_p \qquad \forall p\in P, s\in S_p\tag4\\&amp;amp;\quad h_p\in \mathbb{R}^+, H^- \leq h_p \leq H^+.\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Model 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\max &amp;amp;\quad \sum_{\substack{p\in P,\\s\in S_p}}\frac{e_{ps}}{2}\left(30-\frac{30}{h_p}\right)\tag1\\\text{s.t.}&amp;amp;\quad \sum_{p\in P}\left(\frac{k_p\tau_ph_p}{60}-\sum_{s\in S_p}e_{ps}\right)\leq \kappa\tag2\\&amp;amp;\quad\sum_{\{p\in P|d_p=t,\theta_p=j\}}\frac{\tau_ph_p}{30} \leq M_{tj} \qquad \forall t\in T, j\in J\tag3\\&amp;amp;\quad h_p\geq \frac{e_{ps}}{B_p} \qquad \forall p\in P, s\in S_p\tag4\\&amp;amp;\quad h_p\in \mathbb{R}^+, H^- \leq h_p \leq H^+.\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="518" LastEditDate="2020-03-24T01:38:56.980" LastActivityDate="2020-03-24T01:38:56.980" Title="Can Gurobi or CPLEX handle nonlinearly constrained problems?" Tags="|optimization|solver|cplex|nonlinear-programming|gurobi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3746" PostTypeId="2" ParentId="3745" CreationDate="2020-03-24T00:44:01.387" Score="8" Body="&lt;p&gt;It appears that the only nonlinearity in either model are terms of the form {positive number}/&lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In (4), &lt;span class=&quot;math-container&quot;&gt;$h_p$&lt;/span&gt; can be moved to the RHS, resulting in a linear constraint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In all other instances, this can be handled by use of Rotated Second Order Cone constraint, which is convex, and can be handled by Gurobi and CPLEX, as well as by many front-end optimization modeling systems which call them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, for each &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; for which there is a &lt;span class=&quot;math-container&quot;&gt;$1/h_p$&lt;/span&gt; term, introduce &lt;span class=&quot;math-container&quot;&gt;$t_p$&lt;/span&gt; as a new variable, and replace &lt;span class=&quot;math-container&quot;&gt;$1/h_p$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$t_p$&lt;/span&gt;, along with adding to the model the Rotated Second Order Cone constraint &lt;span class=&quot;math-container&quot;&gt;$$\|1\|_2 \le \sqrt{h_pt_p}, t_p \ge 0, h_p \ge 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The syntax for accomplishing this depends on the interface used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In some syntaxes, the Rotated Second Order Cone constraint might look more like &lt;span class=&quot;math-container&quot;&gt;$$\|1\|^2_2 \le \ h_pt_p, t_p \ge 0, h_p \ge 0$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-03-24T00:44:01.387" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3747" PostTypeId="1" CreationDate="2020-03-24T06:32:01.337" Score="3" ViewCount="155" Body="&lt;p&gt;I am reading about simplex algorithms in a textbook titled &lt;em&gt;Algorithms&lt;/em&gt; by Dasgupta-Papadimitriou-Vairani.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;On each iteration, simplex has two tasks:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Check whether the current vertex is optimal (and if so, halt).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Determine where to move next.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;As we will see, both tasks are easy if the vertex happens to be at the&#xA;origin. And if the vertex is elsewhere, we will transform the&#xA;coordinate system to move it to the origin!&lt;/p&gt;&#xA;&lt;p&gt;First let's see why the origin is so convenient. Suppose we have some&#xA;generic LP &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad c^\top x\\\text{s.t.}&amp;amp;\quad Ax\le b\\&amp;amp;\quad x\ge0\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the vector of variables, &lt;span class=&quot;math-container&quot;&gt;$x = \begin{pmatrix}x_1&amp;amp;\cdots&amp;amp;x_n\end{pmatrix}$&lt;/span&gt;. Suppose the origin is feasible. Then it is certainly a vertex, since it is the unique point at which the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; inequalities &lt;span class=&quot;math-container&quot;&gt;$\{x_1\ge0,\cdots,x_n\ge0\}$&lt;/span&gt; are tight.&lt;/p&gt;&#xA;&lt;p&gt;Now let's solve our two tasks. For task 1, the origin is optimal if and only if all &lt;span class=&quot;math-container&quot;&gt;$c_i\le0$&lt;/span&gt;. If all &lt;span class=&quot;math-container&quot;&gt;$c_i\le0$&lt;/span&gt;, then considering the constraints &lt;span class=&quot;math-container&quot;&gt;$x\ge0$&lt;/span&gt;, we can't hope for a better objective value. Conversely, if some &lt;span class=&quot;math-container&quot;&gt;$c_i &amp;gt; 0$&lt;/span&gt;, then the origin is not optimal, since we can increase the objective function by raising &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Thus, for task 2, we can move by increasing some &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$c_i &amp;gt; 0$&lt;/span&gt;. How much can we increase it? Until we hit some other constraint. That is, we release the tight constraint &lt;span class=&quot;math-container&quot;&gt;$x_i\ge0$&lt;/span&gt; and increase &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; until some other inequality, previously loose, now becomes tight.&lt;/p&gt;&#xA;&lt;p&gt;At that point, we again have exactly &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; tight inequalities, so we are at a new vertex.&lt;/p&gt;&#xA;&lt;p&gt;For instance, suppose we're dealing with the following linear program. &lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\max&amp;amp;\quad2x_1+5x_2\\\text{s.t.}&amp;amp;\quad2x_1-x_2\le4\tag1\\&amp;amp;\quad x_1+2x_2\le9\tag2\\&amp;amp;\quad-x_1+x_2\le3\tag3\\&amp;amp;\quad x_1\ge0\tag4\\&amp;amp;\quad x_2\ge0\tag5.\end{alignat}&lt;/span&gt; The simplex can be started at the origin, which is specified by constraints &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; . To move, we release the tight constraint &lt;span class=&quot;math-container&quot;&gt;$x_2\ge0$&lt;/span&gt;. As &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; is gradually increased, the first constraint it runs into is &lt;span class=&quot;math-container&quot;&gt;$-x_1 + x_2\le3$&lt;/span&gt;, and thus it has to stop at &lt;span class=&quot;math-container&quot;&gt;$x_2 = 3$&lt;/span&gt;, at which point this new inequality is tight. The new vertex is thus given by &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So we know what to do if we are at the origin. But what if our current vertex &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; is elsewhere? The trick is to transform &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; into the origin, by shifting the coordinate system from the usual &lt;span class=&quot;math-container&quot;&gt;$(x_1,\cdots,x_n)$&lt;/span&gt; to the local view from &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;. These local coordinates consist of (appropriately scaled) distances &lt;span class=&quot;math-container&quot;&gt;$y_1,\cdots,y_n$&lt;/span&gt; to the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; hyperplanes (inequalities) that define and enclose &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Wz1jF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wz1jF.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Specifically, if one of these enclosing inequalities is &lt;span class=&quot;math-container&quot;&gt;$a_i\cdot x\le b_i$&lt;/span&gt;, then the distance from a point &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to that particular &amp;quot;wall&amp;quot; is &lt;span class=&quot;math-container&quot;&gt;$y_i = b_i - a_i \cdot x$&lt;/span&gt;. The &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; equations of this type, one per wall, define the &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;'s as linear functions of the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;'s, and this relationship can be inverted to express the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;'s as a linear function of the &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;'s. Thus we can rewrite the entire LP in terms of the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;'s. This doesn't fundamentally change it (for instance, the optimal value stays the same), but expresses it in a different coordinate frame. The revised local LP has the following three properties:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;It includes the inequalities &lt;span class=&quot;math-container&quot;&gt;$y\ge0$&lt;/span&gt;, which are simply the transformed versions of the inequalities defining &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; itself is the origin in the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;-space.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The cost function becomes &lt;span class=&quot;math-container&quot;&gt;$\max c_u + c'^\top\cdot y$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$c_u$&lt;/span&gt; is the value of the objective function at &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c'$&lt;/span&gt; is a transformed cost vector.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I am having difficulty in understanding trick in above statement mentioned below:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The trick is to transform &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; into the origin, by shifting the coordinate system from the usual &lt;span class=&quot;math-container&quot;&gt;$(x_1,\cdots,x_n)$&lt;/span&gt; to the local view from &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;. These local coordinates consist of (appropriately scaled) distances &lt;span class=&quot;math-container&quot;&gt;$y_1,\cdots,y_n$&lt;/span&gt; to the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; hyperplanes (inequalities) that define and enclose &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;What does the author mean by shifting the coordinate system to the local view from &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; in the above statement?&lt;/p&gt;&#xA;&lt;p&gt;What does &amp;quot;local coordinates consist of distances to the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; hyperplanes&amp;quot; mean?&lt;/p&gt;&#xA;" OwnerUserId="3226" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-03-24T13:04:49.837" Title="Linear programming explanation in Algorithms by Sanjoy Dasgupta" Tags="|linear-programming|algorithms|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3750" PostTypeId="2" ParentId="3747" CreationDate="2020-03-24T12:37:02.980" Score="2" Body="&lt;p&gt;For the original problem, we examine the origin, if it is optimal, we halt. Suppose not, from the origin, we know what to do. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, suppose we are at vertex &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, the passage discuss a procedure to make &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; to be the origin of the new coordinate system, we denote it using &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; rather than &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trick is look at those active constraints at &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, we can use them to define an affine transformation of the coordinate system to a new coordinate system by defining &lt;span class=&quot;math-container&quot;&gt;$y_j = b_j-a_j^\top x$&lt;/span&gt;. Since the constraints are active at &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_j-a_j^\top u=0$&lt;/span&gt; in the new coordinate system, the new coordinate at location &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; corresponds to the new origin since &lt;span class=&quot;math-container&quot;&gt;$y_j=b_j-a_j^\top u=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, previously, all the feasible points would satisfies &lt;span class=&quot;math-container&quot;&gt;$b_j-a_j^\top x \ge 0$&lt;/span&gt;, hence in the new coordinate system, &lt;span class=&quot;math-container&quot;&gt;$y_j=b_j-a_j^\top x \ge 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, consider the example that you provided:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\max&amp;amp;\quad2x_1+5x_2\\\text{s.t.}&amp;amp;\quad2x_1-x_2\le4\tag1\\&amp;amp;\quad x_1+2x_2\le9\tag2\\&amp;amp;\quad-x_1+x_2\le3\tag3\\&amp;amp;\quad x_1\ge0\tag4\\&amp;amp;\quad x_2\ge0\tag5.\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now in the first move, we have reached &lt;span class=&quot;math-container&quot;&gt;$(0,3)$&lt;/span&gt;, we want to convert this vertex to the origin of the new coordinate system.  Constraint &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; [Define &lt;span class=&quot;math-container&quot;&gt;$y_1=x_1$&lt;/span&gt;] are active. Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; is active too [Define &lt;span class=&quot;math-container&quot;&gt;$y_2=3+x_1-x_2$&lt;/span&gt;]. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can express &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in terms of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$x_1=y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2=3+y_1-y_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's compute the new objective function:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\max&amp;amp;\quad2x_1+5x_2=2y_1+5(3+y_1-y_2)=15+7y_1-5y_2\\\text{s.t.}&amp;amp;\quad2y_1-(3+y_1-y_2) \le 4\tag{6}\\&amp;amp;\quad y_1+2(3+y_1-y_2) \le 9 \tag{7}\\&amp;amp;\quad-y_1+(3+y_1-y_2) \le 3 \tag{8}\\&amp;amp;\quad y_1 \ge 0 \tag{9}\\&amp;amp;\quad 3+y_1-y_2 \ge 0 \tag{10}.\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, using the new coordinate system, we are at the origin of the new system in the format that you are familiar with and the procedure can be repeated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remark: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Usually, simplex algorithm is implemented using a tableau.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Rather than distance, I prefer calling it slack as in slack variable. Strictly speaking &lt;span class=&quot;math-container&quot;&gt;$2x\le 6$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x\le 3$&lt;/span&gt; are both equivalence inequalities &lt;span class=&quot;math-container&quot;&gt;$6-2x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$3-x$&lt;/span&gt; gives different values though. When the slack is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, the constraint is active, when the slack is negative, the constraint is violated.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="85" LastEditorUserId="123" LastEditDate="2020-03-24T13:04:49.837" LastActivityDate="2020-03-24T13:04:49.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3751" PostTypeId="2" ParentId="3091" CreationDate="2020-03-24T15:21:00.023" Score="6" Body="&lt;p&gt;About the issue you reported on the function &lt;code&gt;getNcuts()&lt;/code&gt;, we looked at it and I can confirm that we have a bug in the number of Benders cuts reported by the function &lt;code&gt;getNcuts()&lt;/code&gt; (the issue is there with all CPLEX APIs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Benders algorithm implemented in CPLEX consists of two main phases.&#xA;In the first phase, we solve the continuous relaxation of the (reformulated) problem,&#xA;by applying the so-called Benders cut loop.&#xA;In the second phase, we apply a branch-and-cut starting from the formulation that we&#xA;have at the end of the first phase (which already contains some Benders cuts).&#xA;In CPLEX 12.10, the log displays information also for the first phase (the Benders cut loop), so the two phases should be clearly visible.&#xA;If you are interested in more details on the Benders implementation in CPLEX, you can find a quite detailed description of the algorithm here: &lt;a href=&quot;http://www.optimization-online.org/DB_HTML/2019/12/7506.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.optimization-online.org/DB_HTML/2019/12/7506.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the log, the &quot;Benders cuts applied&quot; information which is reported in the end gives that total number of Benders cuts that were applied, considering both phases described above. However, due to a bug in the cut counting, from the APIs, the function &lt;code&gt;getNcuts()&lt;/code&gt; only returns the number of Benders cuts applied in the second phase.&#xA;Note that this issue only affects the counting of the Benders cuts but it has no impact on the behavior of the algorithm. Also note that, with &quot;applied cuts&quot;, we mean the cuts that were added to the problem and that were kept in the problem, so cuts that were temporarily added and removed afterwards are not counted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About your other question on the distinction between number of optimality and number of feasibility cuts, currently there is no way for the user to have separate information about optimality and feasibility Benders cuts.&lt;/p&gt;&#xA;" OwnerUserId="3230" LastEditorUserId="123" LastEditDate="2020-03-24T16:11:46.340" LastActivityDate="2020-03-24T16:11:46.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3753" PostTypeId="1" CreationDate="2020-03-24T19:56:06.847" Score="3" ViewCount="72" Body="&lt;p&gt;I have a variable declared as follows in AMPL:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var i {j in UNIT, t in PERIOD}&#xA;integer &amp;lt;= 3; &#xA;&#xA;# therefore, an integer variable is declared that can take values ...,-1,0,1,2,3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Below are the two constraints where this integer variable is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}c(j,t) &amp;amp;\le E(j,t)\cdot i(j,t)\\d(j,t)&amp;amp;\le F(j,t)\cdot i(j,t)\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The capital letters denote parameters and small letters are variables. There is a need to optimize the integer variable this way for later use in the formulation. Is there a way I can reformulate the constraints or formulate the variable condition declaration as constraint to make the execution time of the program faster?&lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="123" LastEditDate="2020-03-24T20:42:58.847" LastActivityDate="2020-03-24T20:42:58.847" Title="Integer variable optimization - decreasing execution time" Tags="|optimization|mixed-integer-programming|ampl|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3754" PostTypeId="1" CreationDate="2020-03-24T23:35:22.633" Score="4" ViewCount="65" Body="&lt;p&gt;I am attempting to solve the following optimization problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\small\min_{A,B,C} \| Y_A - AX_A \|_F + \| Y_B - BX_B \|_F + \| Y_C - CX_C \|_F + \lambda_1 \|B - A^2\|_F + \lambda_2 \|C - A^4\|_F&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$ Y_i, X_i$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$n \times m$&lt;/span&gt; known data matrices, &lt;span class=&quot;math-container&quot;&gt;$A, B, C$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt; unknown matrices (decision variables), and &lt;span class=&quot;math-container&quot;&gt;$\| \cdot \|_F$&lt;/span&gt; denotes the Frobenius norm. I've attempted to use cvxpy to solve this program, however it seems like the operation &lt;span class=&quot;math-container&quot;&gt;$\|B - A^2\|_F$&lt;/span&gt; does not follow disciplined convex programming (DCP) rules. Is anyone able to help out with how I might solve this optimization problem? I'm kind of assuming that taking matrix powers is not the right approach, but I don't know how else to formulate the problem. If anyone can help me solve the problem as is, that would be much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3233" LastEditorUserId="123" LastEditDate="2020-03-25T08:00:07.007" LastActivityDate="2020-03-25T08:00:07.007" Title="Help with constrained or regularized optimization problem involving variable matrices and powers of matrices (or perhaps matrix logarithms)" Tags="|optimization|disciplined-convex-programming|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3755" PostTypeId="1" CreationDate="2020-03-25T00:56:07.410" Score="5" ViewCount="350" Body="&lt;h2&gt;Problem description&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathcal{C} = \{X \in \mathbb{R}^n \mid g(X) \leq 0\}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$g(X)$&lt;/span&gt; a convex function. Suppose I need to solve the feasibility problem, for a given &lt;span class=&quot;math-container&quot;&gt;$r&amp;gt;0$&lt;/span&gt; &#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \exists ^?X \in \mathcal{C} \cap \{ X\in \mathbb{R}^n \mid X^T \cdot X \geq r^2\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;My attempt&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I need to solve the following optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_{x \in \mathbb{R}^n} &amp;amp;\quad g(x) \\\text{s.t}&amp;amp;\quad x^T\cdot x \geq r^2&#xA;\end{align}&lt;/span&gt; &#xA;This unfortunately is a minimization of a convex function over a concave domain. However, consider the following matrix:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ Q = \begin{bmatrix} A &amp;amp;B\\ B^T &amp;amp;C\end{bmatrix} \in \mathbb{R}^{(n+m)\times(n+m)}$$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$C \in \mathbb{R}^{m\times m}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B \in \mathbb{R}^{n\times m}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{n\times n}$&lt;/span&gt;. Then according to Schur's complement theorem one has:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ C \succeq 0 \implies \left( Q \succeq0 \iff A - B \cdot C^{-1} \cdot B^T \succeq 0\right)$$&lt;/span&gt; Therefore, because &lt;span class=&quot;math-container&quot;&gt;$\mathcal{I} \succeq 0$&lt;/span&gt; &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;r^2 - X^T\cdot X \geq 0 \iff X^T\cdot X \leq r^2 \iff \begin{bmatrix} r^2 &amp;amp;X^T\\ X &amp;amp;\mathcal{I}\end{bmatrix} \succeq 0&#xA;\end{align}&lt;/span&gt; Therefore &#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{bmatrix} r^2 &amp;amp;X^T\\ X &amp;amp;\mathcal{I}\end{bmatrix} \nsucceq 0 \Rightarrow r^2 - X^T\cdot X &amp;lt; 0 $$&lt;/span&gt;&#xA;Hence  a sufficient (but not necessary) condition for &lt;span class=&quot;math-container&quot;&gt;$X^T\cdot X \geq r^2$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$\begin{bmatrix} r^2 &amp;amp;X^T\\ X &amp;amp;\mathcal{I}\end{bmatrix} \preceq 0$&lt;/span&gt;, which is convex in &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;. It is obtained:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_{x \in \mathbb{R}^n} &amp;amp;\quad g(x) \\ &#xA;\text{s.t} &amp;amp;\quad \begin{bmatrix} r^2 &amp;amp;X^T\\ X &amp;amp;\mathcal{I}\end{bmatrix} \preceq 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Is this correct? I am afraid while the necessary condition being the matrix not to be positive definite, asking for it to be negative definite is too much! Are there any better solution? &lt;/p&gt;&#xA;" OwnerUserId="3200" LastEditorUserId="3200" LastEditDate="2020-03-25T08:25:48.953" LastActivityDate="2020-03-25T12:19:58.680" Title="Minimize a convex function over a sphere" Tags="|nonconvex-programming|convex-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3756" PostTypeId="2" ParentId="3755" CreationDate="2020-03-25T01:37:45.853" Score="3" Body="&lt;p&gt;You are trying to minimize a convex function outside (including on) a sphere. That is a non-convex constraint region, and hence a non-convex optimization problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The statement&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Hence  a sufficient condition for &lt;span class=&quot;math-container&quot;&gt;$X^T\cdot X \geq r^2$&lt;/span&gt; is&#xA;  &lt;span class=&quot;math-container&quot;&gt;$\begin{bmatrix} r^2 &amp;amp;X^T\\ X &amp;amp;\mathcal{I}\end{bmatrix} \preceq 0$&lt;/span&gt;,&#xA;  which is convex in &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is obtained:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;is convex alchemy, and is just flat out wrong. If it were correct, you would have discovered a way of turning the non-convex optimization problem into a convex SDP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you try using a global optimization solver if you want the globally optimal solution. And if the dimension is not too large, it may succeed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can use a local non-convex nonlinear optimization solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are really wedded to convex optimization, and want to spin the dice with your own crude optimization solver, which might not converge to anything, and if it does converge to something, may not even converge to a local optimum, let alone the global optimum, you can try the convex-concave procedure, as outlined in Stephen Boyd's answer at &lt;a href=&quot;http://ask.cvxr.com/t/how-to-handle-nonlinear-equality-constraints/22/4&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://ask.cvxr.com/t/how-to-handle-nonlinear-equality-constraints/22/4&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; to address your edit subsequent to my original answer.&#xA;&lt;span class=&quot;math-container&quot;&gt;$\begin{bmatrix} r^2 &amp;amp;X^T\\ X &amp;amp;\mathcal{I}\end{bmatrix} \preceq 0$&lt;/span&gt; is INFEASIBLE. Even if &lt;span class=&quot;math-container&quot;&gt;$r^2 = 0$&lt;/span&gt; it is infeasible due to &lt;span class=&quot;math-container&quot;&gt;$\mathcal{I}$&lt;/span&gt; having positive diagonal elements. You are attempting convex alchemy, and it is wrong.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-03-25T12:19:58.680" LastActivityDate="2020-03-25T12:19:58.680" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3757" PostTypeId="1" CreationDate="2020-03-25T07:40:43.230" Score="16" ViewCount="1655" Body="&lt;p&gt;Is there a website or otherwise maintained list of talks regarding mathematical optimization? This would be a big help for the community it seems. I'm most interested in those relating to integer programming.&lt;/p&gt;&#xA;" OwnerUserId="3235" LastEditorUserId="123" LastEditDate="2020-03-25T08:02:37.137" LastActivityDate="2020-04-09T21:51:50.997" Title="Does there exist an aggregation of videos on optimization?" Tags="|optimization|integer-programming|online-resources|" AnswerCount="7" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3758" PostTypeId="2" ParentId="3757" CreationDate="2020-03-25T08:06:41.143" Score="10" Body="&lt;p&gt;There are these great introductory lectures on coursera (not sure if that qualifies for your question as they are not research talks):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.coursera.org/learn/discrete-optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Discrete Optimization&lt;/a&gt;, &lt;a href=&quot;https://www.coursera.org/learn/solving-algorithms-discrete-optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Solving Algorithms&lt;/a&gt;, &lt;a href=&quot;https://www.coursera.org/learn/basic-modeling&quot; rel=&quot;nofollow noreferrer&quot;&gt;Basic Modeling&lt;/a&gt; and &lt;a href=&quot;https://www.coursera.org/learn/advanced-modeling&quot; rel=&quot;nofollow noreferrer&quot;&gt;Advanced Modeling&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are into research seminars / current topics, Aleksandr M. Kazachkov has compiled an interesting &lt;a href=&quot;https://akazachk.github.io/seminars.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;list of online seminars on optimization&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3236" LastEditorUserId="3236" LastEditDate="2020-04-09T21:51:50.997" LastActivityDate="2020-04-09T21:51:50.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3759" PostTypeId="2" ParentId="3757" CreationDate="2020-03-25T08:25:46.923" Score="10" Body="&lt;p&gt;In terms of conferences, the &lt;a href=&quot;https://www.cmu.edu/tepper/faculty-and-research/seminars-and-conferences/egon-balas-symposium/program.html&quot; rel=&quot;noreferrer&quot;&gt;Egon Balas Symposium&lt;/a&gt; in 2019 contained numerous talks on mathematical optimization. For integer programming specifically, it includes&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;the Geometric Firefighter Routing Problem (Cid de Souza)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;the Graphical Traveling Salesman Problem (Neil Simonetti).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2020-03-25T08:30:56.400" LastActivityDate="2020-03-25T08:30:56.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3760" PostTypeId="2" ParentId="3757" CreationDate="2020-03-25T09:10:15.243" Score="5" Body="&lt;p&gt;For what it's worth, the 2th part of &lt;a href=&quot;https://youtu.be/dW_b_n737TU?t=4796&quot; rel=&quot;noreferrer&quot;&gt;my talk at Devoxx Morocco&lt;/a&gt;, explains Tabu Search, Simulated Annealing and other (meta)heuristics.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2020-03-25T09:10:15.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3761" PostTypeId="2" ParentId="3757" CreationDate="2020-03-25T09:43:44.717" Score="4" Body="&lt;p&gt;In terms of online courses: &lt;a href=&quot;https://www.ima.umn.edu/2015-2016/ND8.1-12.16#schedule&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mathematical Optimization&lt;/a&gt; and &lt;a href=&quot;https://www.youtube.com/channel/UCjC9MQ2I7a5ZdWh31gFvC1A/playlists&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimization: Principles and algorithms&lt;/a&gt;, &lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2020-03-25T10:39:38.663" LastActivityDate="2020-03-25T10:39:38.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3762" PostTypeId="1" AcceptedAnswerId="5044" CreationDate="2020-03-25T10:29:30.627" Score="13" ViewCount="309" Body="&lt;p&gt;I understand from this active COVID-19 question: &lt;a href=&quot;https://or.stackexchange.com/questions/3644/are-there-any-covid-19-coronavirus-related-optimization-problems-with-input-da&quot;&gt;Are there any COVID-19 (coronavirus) related optimization problems with input datasets that we can &amp;quot;crowd solve&amp;quot;?&lt;/a&gt;  that the protein folding problem is very important in the fight against COVID-19. When I look for OR studies about the problem, I reach the &amp;quot;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0004370218305927&quot; rel=&quot;nofollow noreferrer&quot;&gt;Variable neighborhood search for graphical model energy minimization&lt;/a&gt;&amp;quot; article. &amp;quot;Computational Protein Design&amp;quot; problem is mentioned in the article. Also, there are MIP, LP and similar approaches for solving the protein design problem. The relation between folding and design is explained as &amp;quot;&lt;a href=&quot;https://reader.elsevier.com/reader/sd/pii/S1359027898000212?token=14202C17898F1A0B25D0D3D66944E03EB93AF3D7DA691C99F95CEAC63E95D35BFCB13EA0BA1CA801BDF11C7EFCF09B3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;The protein folding problem has two components:  the 'direct' folding problem (i.e. folding) and the ‘inverse’ problem  (i.e. protein design)&lt;/a&gt;&amp;quot;. I am looking for OR resources (starting point) for the problems (such as a book) and ideas about solvability of the problems from experienced researchers.&lt;/p&gt;&#xA;" OwnerUserId="432" LastEditorUserId="727" LastEditDate="2023-11-24T15:48:05.890" LastActivityDate="2023-11-24T15:48:05.890" Title="Can operations research be used for protein folding?" Tags="|optimization|reference-request|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3763" PostTypeId="2" ParentId="3757" CreationDate="2020-03-25T13:09:04.570" Score="4" Body="&lt;p&gt;Check out Gurobi's materials: &lt;a href=&quot;https://www.gurobi.com/resources/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/resources/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2020-03-25T13:09:04.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3764" PostTypeId="1" CreationDate="2020-03-25T19:45:38.797" Score="4" ViewCount="78" Body="&lt;p&gt;We have a game with infinite but countable rounds. We have one machine, that may either break down, or continue operating. For each round the machine operates, it gives cost &lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt; (so profit of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;). However, it may break down with probability &lt;span class=&quot;math-container&quot;&gt;$0.1$&lt;/span&gt; at each round. Our control policy is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Whenever the machine breaks down pay &lt;span class=&quot;math-container&quot;&gt;$c\cdot p^2$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c &amp;gt; 0$&lt;/span&gt; is a cost parameter, while &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is a variable. The selection of &lt;span class=&quot;math-container&quot;&gt;$0 \leq p \leq 1$&lt;/span&gt; gives the probability that repairing the machine will be successful and the machine will operate next round.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So there are two states for the machine: operating, out-of-order (states &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;, respectively). My goal is to find out &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; to minimize my &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;-discounted infinite time horizon cost (we can assume initial state is &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Attempt:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever we are in state &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt;, we pay &lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt; cost and go to the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;-discounted next stage. However, with probability &lt;span class=&quot;math-container&quot;&gt;$0.1$&lt;/span&gt; this stage is break-down state, and with &lt;span class=&quot;math-container&quot;&gt;$0.9$&lt;/span&gt; probability this is the operating state. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever we are in state &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;, we pay &lt;span class=&quot;math-container&quot;&gt;$c\cdot p^2$&lt;/span&gt; and go to the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;-discounted next stage. This stage will be in state &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; with probability &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and will be &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; with probability &lt;span class=&quot;math-container&quot;&gt;$1-p$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the Bellman equations are thus:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; V(O) = -1 + \alpha \left[ 0.1 V(D) + 0.9 V(O) \right] \\&#xA;&amp;amp; V(D) = c\cdot p^2 + \alpha \left[ (p )V(O) + (1-p) V(D)\right]&#xA;\end{align}&lt;/span&gt;&#xA;What I do is I re-write the second equation as &lt;span class=&quot;math-container&quot;&gt;$V(D) = \text{a function of } V(O)$&lt;/span&gt; and replace this function in the first equation whenever I see &lt;span class=&quot;math-container&quot;&gt;$V(D)$&lt;/span&gt;. Then, the final expression of &lt;span class=&quot;math-container&quot;&gt;$V(O)$&lt;/span&gt; is just a function of &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;V(O) = \frac{-1 + \alpha - \alpha p + 0.1\alpha cp^2}{(1 - 1.9\alpha + 0.9\alpha^2) + \alpha p - \alpha^2 p}&#xA;\end{align}&lt;/span&gt;&#xA;I think I should just minimize the above function with respect to &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;. My issues here are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The second derivative &lt;span class=&quot;math-container&quot;&gt;$\geq 0$&lt;/span&gt; is required for convexity (for the usage of FOCs), and the second derivative is &lt;strong&gt;massive&lt;/strong&gt;. I think I also need to constrain &lt;span class=&quot;math-container&quot;&gt;$ p \in [0,1]$&lt;/span&gt; so the KKT system is too complicated. &lt;/li&gt;&#xA;&lt;li&gt;I used a reformulation technique to obtain a convex minimization problem with linear constraint as in &lt;a href=&quot;https://math.stackexchange.com/questions/2040031/minimizing-a-quadratic-over-linear-fractional-function&quot;&gt;here&lt;/a&gt;, again it is too complicated and I am afraid if there is some easier way to find the optimal &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2020-03-25T23:17:38.000" LastActivityDate="2020-03-25T23:17:38.000" Title="Optimize probability parameter in an optimal control problem" Tags="|optimization|stochastic-process|optimal-control|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3765" PostTypeId="2" ParentId="3764" CreationDate="2020-03-25T20:07:59.543" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$V(O)$&lt;/span&gt; is simply of the form &lt;span class=&quot;math-container&quot;&gt;$\sf Q_1/L_1$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\sf Q_1$&lt;/span&gt; is a quadratic and &lt;span class=&quot;math-container&quot;&gt;$\sf L_1$&lt;/span&gt; is a linear function of &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;. This can be written as &lt;span class=&quot;math-container&quot;&gt;${\sf{L_2}}+c/\sf{L_1}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\sf L_2$&lt;/span&gt; is also linear in &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is a constant. Letting &lt;span class=&quot;math-container&quot;&gt;${\sf L_1}:=mp+n$&lt;/span&gt;, the second derivative becomes &lt;span class=&quot;math-container&quot;&gt;$$V''(O)=c[(mp+n)^{-1}]''=-cm[(mp+n)^{-2}]'=\frac{2cm^2}{(mp+n)^3}$$&lt;/span&gt; which is &lt;span class=&quot;math-container&quot;&gt;$\ge0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$c(mp+n)\ge0$&lt;/span&gt;. Matching the values of &lt;span class=&quot;math-container&quot;&gt;$c,m,n$&lt;/span&gt; is straightforward.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Experiment &lt;a href=&quot;https://www.desmos.com/calculator/ot4viid4u8&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. It seems &lt;span class=&quot;math-container&quot;&gt;$V''(O)\ge0$&lt;/span&gt; whenever &lt;span class=&quot;math-container&quot;&gt;$\alpha\ge10/9$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$p\in[0,1]$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2020-03-25T20:59:24.687" LastActivityDate="2020-03-25T20:59:24.687" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="3766" PostTypeId="1" CreationDate="2020-03-25T20:43:28.513" Score="4" ViewCount="221" Body="&lt;p&gt;I am very new to Gurobi and OR in general (I'm in my first class for it now), so apologies if this is a very obvious answer. For a project in that class, I am generating a flight schedule for a theoretical airline. I am attempting to add a logical constraint relating to flow balance across cities for crew members, which basically says if expression A is true, then expression B must be true. I was attempting to use the &lt;code&gt;model.addGenConstrIndicator&lt;/code&gt; function, but it will not allow me to input an expression for the &quot;if&quot; part of the function, only a single binary variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help on this would be greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="123" LastEditDate="2020-03-25T21:03:16.433" LastActivityDate="2020-03-25T22:17:59.583" Title="Inputting logical constraints into a binary programming model in Gurobi" Tags="|integer-programming|python|gurobi|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3767" PostTypeId="2" ParentId="3757" CreationDate="2020-03-25T21:55:34.067" Score="2" Body="&lt;p&gt;Check out the following link from the Simons Institute (they had a program on &lt;a href=&quot;https://simons.berkeley.edu/programs/optimization2017&quot; rel=&quot;nofollow noreferrer&quot;&gt;bridging continuous and discrete optimization in 2017&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the Hausdorff Institute had a &lt;a href=&quot;https://www.him.uni-bonn.de/programs/past-programs/past-trimester-programs/combinatorial-optimization-2015/recorded-talks/&quot; rel=&quot;nofollow noreferrer&quot;&gt;trimester on combinatorial optimization in 2015&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="606" LastEditorUserId="123" LastEditDate="2020-03-26T08:34:10.680" LastActivityDate="2020-03-26T08:34:10.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3768" PostTypeId="1" AcceptedAnswerId="3772" CreationDate="2020-03-25T22:08:21.063" Score="8" ViewCount="211" Body="&lt;p&gt;I have a model where there is a constraint on the sum of absolute values, and I would like to add a penalty on the shortfall from the constraint.  More specifically:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\text{maximize}\ &amp;amp; \sum a_i x_i \\&#xA;\text{subject to}\ &amp;amp; y_i \ge x_i \\&#xA;&amp;amp; y_i \ge -x_i \\&#xA;&amp;amp;\sum y_i \le \text{ABSLIMIT},&#xA;\end{align*}&lt;/span&gt;&#xA;and various linear constraints among subsets of the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;'s. (&lt;span class=&quot;math-container&quot;&gt;$\text{ABSLIMIT}$&lt;/span&gt; is a constant.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to add a penalty to the objective that would accomplish this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{maximize}\ \sum a_ix_i - K\left(\text{ABSLIMIT} - \sum |x_i|\right)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, when the &lt;span class=&quot;math-container&quot;&gt;$\text{ABSLIMIT}$&lt;/span&gt; constraint is not binding, I would like a penalty which would force the magnitudes of the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; to be as large as is feasible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions or references would be appreciated.  Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2564" LastEditorUserId="38" LastEditDate="2020-03-26T00:05:21.927" LastActivityDate="2020-03-31T01:59:52.670" Title="how to penalize a shortfall of a sum of absolute values" Tags="|linear-programming|convexity|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3769" PostTypeId="2" ParentId="3766" CreationDate="2020-03-25T22:17:59.583" Score="3" Body="&lt;p&gt;You could introduce two binary variables, say &lt;span class=&quot;math-container&quot;&gt;$x_A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_B$&lt;/span&gt;, two indicator constraints &lt;span class=&quot;math-container&quot;&gt;$x_A \iff A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_B \iff B$&lt;/span&gt;, and linear constraint &lt;span class=&quot;math-container&quot;&gt;$x_A \le x_B$&lt;/span&gt;.  The latter enforces the implication &lt;span class=&quot;math-container&quot;&gt;$x_A \implies x_B$&lt;/span&gt;, which is equivalent to &lt;span class=&quot;math-container&quot;&gt;$A \implies B$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-03-25T22:17:59.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3770" PostTypeId="2" ParentId="3732" CreationDate="2020-03-26T05:34:07.933" Score="5" Body="&lt;p&gt;You can formulate this (depending on whether you have more constraints you haven't mentioned) as an uncapacitated facility location problem. Let the &quot;location variables&quot; (&lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt;) represent whether a supplier &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is chosen and the fixed cost be the shipping costs. The &quot;allocation variables&quot; (&lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt;) represent if an item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is sourced from supplier &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; or not, and the allocation cost represents the cost of the item at the given supplier.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2020-03-26T05:34:07.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3771" PostTypeId="2" ParentId="3768" CreationDate="2020-03-26T15:11:57.107" Score="4" Body="&lt;p&gt;I am not sure I got the whole idea, this answer is just focused on the following part:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In other words, when the &lt;span class=&quot;math-container&quot;&gt;$\rm ABSLIMIT$&lt;/span&gt; constraint is not binding, I would like a penalty that would force the magnitudes of the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; to be as large as is feasible.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To do that I would try to use other constraints, and use some logic statements on those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thinking a little bit, I came with this set of constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}z &amp;amp;= 1 - \left\lfloor\frac{\sum y_i}{\rm ABSLIMIT}\right\rfloor\\\sum x_i &amp;amp;\ge Kz\\z &amp;amp;\in \{0, 1\}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, when the &lt;span class=&quot;math-container&quot;&gt;$\rm ABSLIMIT$&lt;/span&gt; constraint is not biding &lt;span class=&quot;math-container&quot;&gt;$\left(\sum y_i &amp;lt; \rm ABSLIMIT \right)$&lt;/span&gt; the value of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; will be equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; for any positive value of &lt;span class=&quot;math-container&quot;&gt;$\sum y_i$&lt;/span&gt;. And then the second constraint will be &quot;active&quot;. This constraint will make sure that &lt;span class=&quot;math-container&quot;&gt;$ \sum x_i $&lt;/span&gt; have a higher value than &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the opposite case, when &lt;span class=&quot;math-container&quot;&gt;$\rm ABSLIMIT$&lt;/span&gt; constraint is biding &lt;span class=&quot;math-container&quot;&gt;$\left(\sum y_i = \rm ABSLIMIT \right)$&lt;/span&gt; the value of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; will be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. And then the second constraint will be &quot;inactive&quot;, making &lt;span class=&quot;math-container&quot;&gt;$\sum x_i$&lt;/span&gt; unrestricted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, now we have the problem of finding a good value for &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;. It will depend deeply on the nature of your problem and it can also have a variable value if needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To implement the ceiling function in a linear problem you can use the method described in &lt;a href=&quot;https://math.stackexchange.com/a/1863895/467664&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3246" LastEditorUserId="36" LastEditDate="2020-03-31T01:59:52.670" LastActivityDate="2020-03-31T01:59:52.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3772" PostTypeId="2" ParentId="3768" CreationDate="2020-03-26T22:16:46.140" Score="10" Body="&lt;p&gt;If the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables are bounded, you can do this by introducing some binary variables (one for each &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;). Assume that &lt;span class=&quot;math-container&quot;&gt;$L_i \le x_i \le U_i$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$L_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U_i$&lt;/span&gt; are constants such that &lt;span class=&quot;math-container&quot;&gt;$L_i \le 0 \le U_i$&lt;/span&gt;. Create variables &lt;span class=&quot;math-container&quot;&gt;$y_i\ge 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_i\in \lbrace 0, 1\rbrace$&lt;/span&gt;. For each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, add the constraints &lt;span class=&quot;math-container&quot;&gt;$$0 \le y_i - x_i \le -2L_i (1-z_i)$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$0 \le y_i + x_i \le 2U_iz_i.$$&lt;/span&gt;If &lt;span class=&quot;math-container&quot;&gt;$z_i=1$&lt;/span&gt;, you get &lt;span class=&quot;math-container&quot;&gt;$x_i\ge 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_i=x_i$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$z_i=0$&lt;/span&gt;, you get &lt;span class=&quot;math-container&quot;&gt;$x_i \le 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_i = -x_i$&lt;/span&gt;. So either way &lt;span class=&quot;math-container&quot;&gt;$y_i = |x_i|$&lt;/span&gt;. Now just use &lt;span class=&quot;math-container&quot;&gt;${\rm ABSLIMIT} - \sum\limits_i y_i$&lt;/span&gt; as the term to be penalized. &lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="123" LastEditDate="2020-03-27T06:18:56.533" LastActivityDate="2020-03-27T06:18:56.533" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3773" PostTypeId="1" CreationDate="2020-03-27T02:05:44.080" Score="6" ViewCount="93" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-by-&lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; symmetric matrix whose entries are all nonnegative. &lt;span class=&quot;math-container&quot;&gt;$A_{ii} = 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. We want to find an &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-by-&lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; binary (&lt;span class=&quot;math-container&quot;&gt;$0/1$&lt;/span&gt; valued) matrix &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; that maximizes&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{ij} A_{ij} X_{ij}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;under the constraints that&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is symmetric (&lt;span class=&quot;math-container&quot;&gt;$X^\top = X$&lt;/span&gt;);&lt;/li&gt;&#xA;&lt;li&gt;Each row of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; can have at most &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; ones (the rest being zero);&lt;/li&gt;&#xA;&lt;li&gt;The total number of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is at most &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$k \le n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m \le n^2$&lt;/span&gt;. I can think of a dynamic programming solution if 2 and 3 are the only conditions. But the symmetry in condition 1 makes it much harder.  Does there exist a polynomial algorithm which can achieve multiplicatively constant approximation bound (under conditions 1, 2, 3)?  Ideally the constant is universal, not dependent on &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, is there any hope for the combination of conditions 1 and 2?  The combination of 1 and 3 is trivial to handle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Conditions 1+2 lead to a maximum weight b-matching problem, which is solvable in polynomial time. Adding condition 3, however, still makes the problem hard, necessitating an approximate solution. Any idea with a provable bound will be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="3253" LastEditorUserId="3253" LastEditDate="2020-03-27T14:42:34.180" LastActivityDate="2020-03-27T14:42:34.180" Title="Maximum weight b-matching with global cardinality constraint" Tags="|optimization|combinatorial-optimization|graphs|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3774" PostTypeId="2" ParentId="3773" CreationDate="2020-03-27T03:44:54.180" Score="2" Body="&lt;p&gt;If I understand the question correctly, both &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; matrices are symmetric. If so, you can simply ignore the lower half(or upper half) of both matrices because in your solution you should always have &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=x_{ji}$&lt;/span&gt; in addition it's known that &lt;span class=&quot;math-container&quot;&gt;$a_{ij}=a_{ji}$&lt;/span&gt; (from symmetry of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; matrix). Solve the problem using the following integer programming:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad Z/2=\sum_{i=1}^n\sum_{j=1}^n a_{ij}x_{ij} \\ &#xA;\text{s.t.}&amp;amp;\quad\sum_{i=1}^n x_{ij}\le k \quad \forall j \in \{1,\ldots, n\} \\ &#xA;&amp;amp;\quad\sum_{j=1}^n x_{ij}\le k \quad\forall i \in \{1,\ldots, n\} \\ &#xA;&amp;amp;\quad\sum_{i=1}^n\sum_{j=1}^n x_{ij}\le m \\ &#xA;&amp;amp;\quad x_{ij}\in \{0,1\}\end{align}&lt;/span&gt;&#xA;As we only considered half of the matrices, the value of objective function should be multiplied by two. In other words &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; will be your final objective function. &lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2020-03-27T06:20:48.350" LastActivityDate="2020-03-27T06:20:48.350" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3775" PostTypeId="2" ParentId="3757" CreationDate="2020-03-27T04:02:47.573" Score="3" Body="&lt;p&gt;You can find an introductory course of &lt;strong&gt;Convex Optimization&lt;/strong&gt; from &lt;em&gt;Stanford University&lt;/em&gt; taught by Professor Stephen Boyd, in this &lt;a href=&quot;https://lagunita.stanford.edu/courses/Engineering/CVX101/Winter2014/course/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-03-27T04:02:47.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3776" PostTypeId="1" AcceptedAnswerId="3779" CreationDate="2020-03-27T10:37:34.347" Score="9" ViewCount="551" Body="&lt;p&gt;We are working on a production scheduling problem that has both discrete (&quot;how much to produce from good x and where&quot;) and continuous elements (&quot;keep the workload of a production site below 0.7&quot;), &#xA;and also non-linear constraints, MIP is not applicable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since we do have a somewhat complex model already in MiniZinc (we are currently using Google OR-Tools), I am wondering which MiniZinc-compatible solver provides most support for floating decision variables (maybe interval-based). Choco, JaCoP, Gecode .... ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, what could be similar high-level modeling languages that deal with continuous problems better? AMPL?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thankful for your hints!&lt;/p&gt;&#xA;" OwnerUserId="3236" LastActivityDate="2020-03-27T18:55:22.480" Title="Which MiniZinc-compatible solvers are best suited for floating decision variables and non-linear constraints?" Tags="|constraint-programming|minizinc|continuous-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3777" PostTypeId="1" AcceptedAnswerId="3778" CreationDate="2020-03-27T11:56:39.293" Score="10" ViewCount="261" Body="&lt;p&gt;I have an MILP model to which I get an integer feasible solution as a result of a heuristic search. In this particular example, the initial solution turns out to be the optimal solution, which I prove through B&amp;amp;B after solving 3000 LPs (20 Minutes of solution time), which is frustrating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can use the value of the initial solution as a lower bound on the optimisation problem (maximization case). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I derive anything else other than a lower bound from that solution?   &lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="38" LastEditDate="2020-03-27T12:33:05.897" LastActivityDate="2020-03-29T10:09:08.223" Title="How to exploit known solution in MILP" Tags="|mixed-integer-programming|heuristics|bounds|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3778" PostTypeId="2" ParentId="3777" CreationDate="2020-03-27T14:37:07.963" Score="8" Body="&lt;p&gt;Many solvers have an option to control the &quot;emphasis&quot; (feasibility versus optimality) of the tree search.  If you suspect that your initial solution is already optimal, set this option to emphasize optimality, which will make cut generation more aggressive and do some other similar things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is to explicitly apply &lt;em&gt;reduced-cost fixing&lt;/em&gt; to fix the values of variables, without loss of optimality.  Many solvers do this automatically, but maybe not as aggressively as you could do yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A natural idea that has come up many times before is to add an explicit objective cut of the form &lt;span class=&quot;math-container&quot;&gt;$\sum_j c_j x_j \ge \hat{z}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\hat{z}$&lt;/span&gt; is the objective value of your initial solution.  The conventional wisdom is that doing this is usually a bad idea, in part because it often adds a dense constraint that causes numerical difficulty for the underlying LP solves.  But it is easy to try.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-03-27T14:37:07.963" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3779" PostTypeId="2" ParentId="3776" CreationDate="2020-03-27T17:01:06.920" Score="5" Body="&lt;p&gt;Some of the coin-or open-source solvers like &quot;couenne&quot; can be used via MiniZn. You can follow the instruction of installation in &lt;a href=&quot;https://www.minizinc.org/doc-2.3.0/en/solvers.html#non-linear-solvers&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Info about Couenne:&lt;/strong&gt;&#xA;Couenne (&lt;strong&gt;C&lt;/strong&gt;onvex &lt;strong&gt;O&lt;/strong&gt;ver and &lt;strong&gt;U&lt;/strong&gt;nder &lt;strong&gt;EN&lt;/strong&gt;velopes for &lt;strong&gt;N&lt;/strong&gt;onlinear &lt;strong&gt;E&lt;/strong&gt;stimation) is a branch&amp;amp;bound algorithm to solve Mixed-Integer Nonlinear Programming (MINLP) problems and aims at finding global optima of nonconvex MINLPs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that, you can use &lt;a href=&quot;https://minlp.com/baron&quot; rel=&quot;noreferrer&quot;&gt;BARON&lt;/a&gt; solver for free if you send your model to &lt;a href=&quot;https://neos-server.org/neos/&quot; rel=&quot;noreferrer&quot;&gt;NEOS server&lt;/a&gt;. BARON guarantees global optimal for MINLPs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Info about Baron:&lt;/strong&gt;&#xA;BARON (&lt;strong&gt;B&lt;/strong&gt;ranch &lt;strong&gt;a&lt;/strong&gt;nd &lt;strong&gt;R&lt;/strong&gt;educe &lt;strong&gt;O&lt;/strong&gt;ptimization &lt;strong&gt;N&lt;/strong&gt;avigator) revolutionized global optimization technology in 2001 when it became the first commercial optimization software to offer deterministic guarantee for global optimality of nonlinear and mixed-integer nonlinear problems. Since then, BARON has remained the most complete and robust solver in global optimization technology. &lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-03-27T17:01:06.920" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3780" PostTypeId="2" ParentId="3776" CreationDate="2020-03-27T18:55:22.480" Score="4" Body="&lt;p&gt;Of the constraint based solvers JaCoP (&lt;a href=&quot;https://github.com/radsz/jacop&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/radsz/jacop&lt;/a&gt; ) and Gecode (&lt;a href=&quot;https://www.gecode.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gecode.org/&lt;/a&gt;) has support for float decision variables combined with nonlinear constraints. Choco (&lt;a href=&quot;https://choco-solver.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://choco-solver.org/&lt;/a&gt; ) is supposed to have support for float variables but I got errors when running float variable models.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also add ECLiPSe CLP's ic solver (&lt;a href=&quot;https://eclipseclp.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://eclipseclp.org/&lt;/a&gt; ) to the list, though it's a bit extra work to make it work with the MiniZinc tool-chain (one have to create some wrappers for the output etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My personal preference right now is JaCoP which seems to be quite stable for float variables + non linear constraint problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that for solving for float variables one have to be a little careful when using the &lt;code&gt;solve :: float_search&lt;/code&gt; command. One might have to tweak the second argument (precision ) a little to get useful values (and good enough run time), e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;solve :: float_search(x, 0.001, input_order, indomain_split, complete) minimize z;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="260" LastActivityDate="2020-03-27T18:55:22.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3781" PostTypeId="1" AcceptedAnswerId="3784" CreationDate="2020-03-27T19:50:55.557" Score="9" ViewCount="483" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{r}^{j}=1\iff$&lt;/span&gt; the machine schedules job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; using resource &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;. My constraint says that: a resource cannot be used twice, i.e., if &lt;span class=&quot;math-container&quot;&gt;$x_{r}^{j}=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_{r}^{j'}=0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$j'\neq j$&lt;/span&gt;. I write this as: &lt;span class=&quot;math-container&quot;&gt;$$x_{r}^{j}+x_{r}^{j'}\leq1,\forall j\neq j', \forall r.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to formulate this?&lt;/p&gt;&#xA;" OwnerUserId="3075" LastActivityDate="2020-03-27T20:15:49.343" Title="Is there a better way to formulate this constraint?" Tags="|constraint|binary-variable|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3782" PostTypeId="2" ParentId="3781" CreationDate="2020-03-27T19:59:50.060" Score="4" Body="&lt;p&gt;That seems like the right way to formulate it. There are lots of problems that use that sort of approach to ensure that at most one of two binary variables equal 1.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-03-27T19:59:50.060" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3783" PostTypeId="2" ParentId="3781" CreationDate="2020-03-27T20:15:26.320" Score="9" Body="&lt;p&gt;Same idea, but typically formulated as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_j x_r^j \leq 1, \: \forall r$$&lt;/span&gt;&#xA;For binary &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3255" LastActivityDate="2020-03-27T20:15:26.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3784" PostTypeId="2" ParentId="3781" CreationDate="2020-03-27T20:15:49.343" Score="11" Body="&lt;p&gt;You can strengthen your &quot;conflict&quot; constraint to a &quot;clique&quot; constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_j x_r^j \le 1$$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;.&#xA;There are fewer of these, and they dominate the conflict constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-03-27T20:15:49.343" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3785" PostTypeId="1" AcceptedAnswerId="3787" CreationDate="2020-03-28T02:36:58.120" Score="5" ViewCount="221" Body="&lt;p&gt;I have a problem with a vector variable &lt;span class=&quot;math-container&quot;&gt;$w \in \mathbb{R}^n$&lt;/span&gt; and a symmetric matrix variable &lt;span class=&quot;math-container&quot;&gt;$V \in \mathbb{R^{n \times n}}$&lt;/span&gt;. I am solving a problem which is roughly like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\begin{array}{ll}&#xA;\max &amp;amp; \sqrt{\operatorname{trace}(A^\top V A)} + a^\top w + \operatorname{entropy}(w) \\&#xA;\mathrm{s.t. }&amp;amp; \text{some linear constraints over $w$, and $V$}\\&#xA;&amp;amp;  V \succeq ww^\top&#xA;\end{array}&#xA;\end{align}&lt;/span&gt;&#xA;where by Schur complement the last constraint can be:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\begin{pmatrix}&#xA;V &amp;amp; w \\ w^\top &amp;amp; 1&#xA;\end{pmatrix} \succeq 0.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I have a positive semi-definiteness constraint, some linear constraints, and the function that I am maximizing is concave because the square root of a linear function is concave, as well as the entropy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using YALMIP - MATLAB combination to call a solver. However, MOSEK cannot solve this. I know MOSEK can solve entropy maximization over some conic constraints (exponential cone solver), but this problem is not being able to solve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I using MOSEK wrongly? Would you expect MOSEK to solve this problem? If not, which convex optimization solver shall I try using?&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="123" LastEditDate="2020-03-28T09:12:03.333" LastActivityDate="2020-03-28T17:11:06.120" Title="Which solver solves PSD constrained convex non-linear problem" Tags="|optimization|solver|convex-optimization|sdp|mosek|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3787" PostTypeId="2" ParentId="3785" CreationDate="2020-03-28T03:39:30.877" Score="5" Body="&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Per comment below by YALMIP deveeloper Johan Lofberg, the bug in YALMIP was a typo, which has now been corrected and available at &lt;a href=&quot;https://github.com/yalmip/YALMIP/archive/develop.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/yalmip/YALMIP/archive/develop.zip&lt;/a&gt; .  Using this newest develop version of YALMIP, Mosek should now be able to solve the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edited to reflect YALMIP developer's acknowledgement that there is a bug in YALMIP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mosek should be able to solve this, and indeed can (see below) under CVX 2.2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a bug in YALMIP which results in an error message when entropy is used in combination with an SDP constraint with the solvers Mosek or SCS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;X=sdpvar(3,3);optimize(X&amp;gt;=0,-entropy(X(:)),sdpsettings('solver','mosek','debug',1))&#xA;&#xA;Unrecognized function or variable 'sdpDAta'.&#xA;Error in normalizeExponentialCone (line 236)&#xA;            sdpDAta(end,size(model.F_struc,2)) = 0;&#xA;Error in callmosek&amp;gt;call_mosek_lpqpsocpsdp (line 84)&#xA;[model,output] = normalizeExponentialCone(model);&#xA;Error in callmosek (line 51)&#xA;    [x,D_struc,problem,r,res,solvertime,prob] = call_mosek_lpqpsocpsdp(model);&#xA;Error in solvesdp (line 361)&#xA;    eval(['output = ' solver.call '(interfacedata);']);&#xA;Error in optimize (line 31)&#xA;[varargout{1:nargout}] = solvesdp(varargin{:}); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly with SCS as solver (which absent the YALMIP bug, also should be able to solve this).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the YALMIP forum topic &lt;a href=&quot;https://groups.google.com/forum/#!topic/yalmip/O0Qc78d9ORs&quot; rel=&quot;nofollow noreferrer&quot;&gt;Entropy + SDP constraint with Mosek and SCS: Unrecognized function or variable 'sdpDAta'&lt;/a&gt; which I just opened, to which the YALMIP developer, Johan Lofberg, has now responded, acknowledging the bug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CVX 2.2 + Mosek 9.1 as solver can handle this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin sdp&#xA;variable V(3,3) symmetric&#xA;variable w(3)&#xA;maximize(sqrt(A'*V*A)+a'*w+sum(entr(w)))&#xA;% Insert other constraints here&#xA;[V w;w' 1] &amp;gt;= 0&#xA;cvx_solver mosek&#xA;cvx_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-03-28T17:11:06.120" LastActivityDate="2020-03-28T17:11:06.120" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3789" PostTypeId="1" AcceptedAnswerId="3791" CreationDate="2020-03-28T15:23:55.803" Score="12" ViewCount="144" Body="&lt;p&gt;Suppose I want to solve a naturally MINLP problem of the following form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{x,y} \{c'x + y \mid Ax \leq b, Dx + Ey \leq f, G(x)y\leq g, x \in \mathbb{Z}, y \in \mathbb{R}^+\}&#xA;$$&lt;/span&gt;&#xA;Here &lt;span class=&quot;math-container&quot;&gt;$G(x)$&lt;/span&gt; indicates that the matrix &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; is dependent upon &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Thinking of Benders Decomposition, I would end up with a dual subproblem of the form (for a given &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt;)&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max_{y\mid \bar{x}} \{(f - D\bar{x})'u + g'v \mid E'u + G(\bar{x})'v \geq 1, \ u,v\in\mathbb{R}^+\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, now the feasible region of the subproblem depends upon &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Does this automatically implies that this approach does not make sense? I have only a basic understanding of Benders Decomposition, but I assume that there are bright minds that already have studied a setting like this in very much detail. Can someone point me in the right direction?&lt;/p&gt;&#xA;" OwnerUserId="48" LastEditorUserId="123" LastEditDate="2020-03-28T15:58:21.253" LastActivityDate="2020-03-28T19:01:51.240" Title="Benders subproblem feasible region dependent upon solution master problem" Tags="|mixed-integer-programming|nonlinear-programming|benders-decomposition|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3790" PostTypeId="1" AcceptedAnswerId="3792" CreationDate="2020-03-28T16:56:10.843" Score="6" ViewCount="495" Body="&lt;p&gt;I compare the strengths and weaknesses of paradigms and approaches within those paradigms for solving machine scheduling problems. The amount of real-world data I have is limited and (random) subsampling critically changes the characteristics of the sets so that they are no longer realistic. I do however feel it is necessary to provide a richer class of problem data as to see how different methods react to different intrinsics - as long as they are likely to be more than just theoretical. What is the most responsible and honest way to include this in my research?&lt;/p&gt;&#xA;&lt;p&gt;There are papers mentioning typical industry ranges for certain characteristics, e.g. a rate for how tight deadlines are. Therefore, my best idea so far is to do carry out a (full) factorial analysis for those parameters. Other ratios also seem interesting, such as average transition vs. execution duration, but I don't exactly find resources mentioning them or generators for creating them.&lt;/p&gt;&#xA;&lt;p&gt;I feel like I'm not being rigorous enough if I just disregard the part of research just mentioned, but at the same time, I don't want to muddy the waters by introducing irrelevant parameters. Preliminary results show that indeed, for the same problem formulation, the best result sometimes depends on the shape (and obviously, the size) of the data set.&lt;/p&gt;&#xA;" OwnerUserId="2562" LastEditorUserId="491" LastEditDate="2022-04-04T21:17:10.427" LastActivityDate="2022-04-04T21:17:10.427" Title="Scheduling problem data generation" Tags="|scheduling|literature-research|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3791" PostTypeId="2" ParentId="3789" CreationDate="2020-03-28T19:01:51.240" Score="8" Body="&lt;p&gt;I always find it helpful to look at Benders decomposition from a primal view, as detailed in &lt;a href=&quot;http://www.dei.unipd.it/~fisch/papers/slides/2017%20Lunteren%20%5BFischetti%20on%20Benders%5D.pdf&quot; rel=&quot;noreferrer&quot;&gt;this presentation&lt;/a&gt; by Matteo Fischetti.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can write&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{x,y} \{c'x + y \mid Ax \leq b, Dx + Ey \leq f, G(x)y\leq g, x \in \mathbb{Z}^n, y \in \mathbb{R}^+\}&#xA;$$&lt;/span&gt;&#xA;as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{x,y} \{c'x + \Phi(x) \mid Ax \leq b, x \in \mathbb{Z}^n\}&#xA;$$&lt;/span&gt;&#xA;with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\Phi(x) = \min_{y} \{y \mid Ey \leq f - Dx, G(x)y\leq g, y \in \mathbb{R}^+\}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In classical Benders decomposition (i.e., without the non-linear constraint &lt;span class=&quot;math-container&quot;&gt;$G(x)y \le g$&lt;/span&gt;), the function &lt;span class=&quot;math-container&quot;&gt;$\Phi(x)$&lt;/span&gt; is the value function of a linear program when the right-hand side changes. From duality theory, it follows that this function is convex. Benders cuts can then be seen as supporting hyperplanes of the epigraph of &lt;span class=&quot;math-container&quot;&gt;$\Phi(x)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the function &lt;span class=&quot;math-container&quot;&gt;$\Phi(x)$&lt;/span&gt; is not convex, classical Benders cuts cannot be used. However, because &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{Z}^n$&lt;/span&gt;, you could still use combinatorial Benders cuts, which only support the epigraph at the integer values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; (which is the only thing you are interested in). See &lt;a href=&quot;https://doi.org/10.1287/opre.50.3.415.7751&quot; rel=&quot;noreferrer&quot;&gt;Laporte et al. (2002)&lt;/a&gt; and &lt;a href=&quot;https://doi.org/10.1287/opre.1060.0286&quot; rel=&quot;noreferrer&quot;&gt;Codato &amp;amp; Fischetti (2006)&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2020-03-28T19:01:51.240" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3792" PostTypeId="2" ParentId="3790" CreationDate="2020-03-28T19:30:26.207" Score="8" Body="&lt;p&gt;It is not ideal, but sometimes I think the best you can do is utilize problem collections from published papers as benchmarks, even if their parameters are rather arbitrary (not necessarily based on industry experience). For example, there is a compendium by Oleg Shylo of experimental results for job shop problems at &lt;a href=&quot;http://optimizizer.com/jobshop.php&quot; rel=&quot;noreferrer&quot;&gt;http://optimizizer.com/jobshop.php&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-03-28T19:30:26.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3793" PostTypeId="2" ParentId="3790" CreationDate="2020-03-28T22:30:04.933" Score="5" Body="&lt;p&gt;One type of data that is likely to exist in many real-world applications is the so-called &quot;ordered&quot; data. In an ordered setting, if the processing time of a job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is larger than that of another job &lt;span class=&quot;math-container&quot;&gt;$j'$&lt;/span&gt; on machine &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;, then it is the case on all machines, that is, the jobs can be ranked based on their processing times. Also, there is the same relationship between machines and they can be ranked as well.&#xA;There is a publicly available &quot;hard&quot; benchmark for the ordered setting in the flow shop environment, that you can find it in &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0305054819301728&quot; rel=&quot;nofollow noreferrer&quot;&gt;Khatami &lt;em&gt;et al.&lt;/em&gt; (2019)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Khatami, M., Salehipour, A., Hwang, F. J. (2019). Makespan minimization for the &lt;em&gt;m&lt;/em&gt;-machine ordered flow shop scheduling problem. &lt;em&gt;Computers and Operations Research.&lt;/em&gt; 111:400-414. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="123" LastEditDate="2020-03-29T08:22:43.280" LastActivityDate="2020-03-29T08:22:43.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3795" PostTypeId="2" ParentId="3790" CreationDate="2020-03-29T09:40:46.057" Score="4" Body="&lt;p&gt;A generator of job-correlated, machine-correlated and mixed-correlated Permutation Flowshop instances is described in &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.14.2.98.120&quot; rel=&quot;nofollow noreferrer&quot;&gt;Watson et al. (2002)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; and can be found &lt;a href=&quot;https://www.cs.colostate.edu/sched/generatorNew/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. From the abstract:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;We introduce a method for generating structured flow-shop problems,&#xA;  which are modeled after features found in some real-world manufacturing&#xA;  environments.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Another list of instance benchmarks for various kinds of scheduling problems can be found &lt;a href=&quot;http://soa.iti.es/problem-instances&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. For some of them, you can find there also the binary of the generator.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Watson, J. P. &lt;em&gt;et al.&lt;/em&gt; (2002). Contrasting Structured and Random Permutation Flow-Shop Scheduling Problems: Search-Space Topology and Algorithm Performance. &lt;em&gt;INFORMS Journal on Computing.&lt;/em&gt; 14(2):98-123. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="224" LastEditorUserId="123" LastEditDate="2020-03-29T10:52:43.170" LastActivityDate="2020-03-29T10:52:43.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3796" PostTypeId="2" ParentId="3777" CreationDate="2020-03-29T10:09:08.223" Score="3" Body="&lt;p&gt;You can also submit the solution to the MILP solver. The solver should then use the bound from it automatically. Further, it might use the solution values for various improvement heuristics (e.g. neighborhood searches).&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2020-03-29T10:09:08.223" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3797" PostTypeId="1" AcceptedAnswerId="3798" CreationDate="2020-03-29T14:53:10.880" Score="5" ViewCount="215" Body="&lt;p&gt;Are there any benchmark instances for VRP with charging stations? I also have various delivery points with charging stations in the city(Multiple Vehicles). How can I compare my formulation?&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="700" LastEditDate="2020-03-29T15:09:58.093" LastActivityDate="2020-03-29T21:09:08.940" Title="VRP benchmark instances with charging stations" Tags="|vehicle-routing|benchmark|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3798" PostTypeId="2" ParentId="3797" CreationDate="2020-03-29T21:09:08.940" Score="7" Body="&lt;p&gt;&lt;a href=&quot;http://vrp-rep.org/variants/item/e-vrp-nl.html&quot; rel=&quot;noreferrer&quot;&gt;E-VRP-NL&lt;/a&gt; has been used in &lt;a href=&quot;https://hal.archives-ouvertes.fr/hal-02386167/file/The_electric_vehicle_routing_problem_with_capacitated_charging_stations-HAL.pdf&quot; rel=&quot;noreferrer&quot;&gt;The electric vehicle routing problem with capacitated&#xA;charging stations&lt;/a&gt;. Also authors in the paper mentioned by &lt;em&gt;A.Omidi&lt;/em&gt; design two new sets of benchmark instances for the E-VRPTW problem. A set of 56 large instances, each with 100 customers and 21 recharging stations, and a set of 36 small instances with 5, 10, and 15 customers per instance. All instances are created based on the benchmark instances for the VRPTW proposed by Solomon (1987).&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-03-29T21:09:08.940" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3799" PostTypeId="1" AcceptedAnswerId="3800" CreationDate="2020-03-29T21:52:19.063" Score="3" ViewCount="298" Body="&lt;p&gt;I have a time series list like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = [1.1341, 1.13421, 1.13433, 1.13412, 1.13435, 1.13447, 1.13459, 1.13452, 1.13471, 1.1348, 1.13496,1.13474,1.13483,1.1349,1.13502,1.13515,1.13526,1.13512]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to write constraints to mark after every 0.0005 change in this list using a LP/MIP (series is not sorted and order matters)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;code&gt;|a[0] - a[8]| = 0.00061 &amp;gt; 0.0005 and |a[16] - a[8]| = 0.00055 &amp;gt; 0.0005&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's possible &lt;code&gt;a[16] &amp;lt; a[8]&lt;/code&gt;. If MIP can be formulated such that output[16] = -1, it is most appreciated but just binary is also fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am expecting something like the following. Output is the control variable in LP/MIP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NRBzl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NRBzl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to solve this just with constraints and without an objective function? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to solve this in CPLEX. Ideally I would like to formulate in regular LP/MIP but constraint programming is also fine.&lt;/p&gt;&#xA;" OwnerUserId="3256" LastEditorUserId="3256" LastEditDate="2020-03-30T01:32:27.187" LastActivityDate="2020-03-31T00:40:19.890" Title="How to write a LP/MIP to mark the items in a time-series list after a fixed delta?" Tags="|optimization|mixed-integer-programming|linear-programming|modeling|constraint-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3800" PostTypeId="2" ParentId="3799" CreationDate="2020-03-30T01:10:43.283" Score="7" Body="&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; be your desired output[i].  If I understand correctly, you want &lt;span class=&quot;math-container&quot;&gt;$x_0=1$&lt;/span&gt;, and for each &lt;span class=&quot;math-container&quot;&gt;$i&amp;lt;j$&lt;/span&gt;, you want &lt;span class=&quot;math-container&quot;&gt;$$(x_i,x_{i+1},\dots,x_{j-1},x_j)=(1,0,\dots,0,1)\iff \left(\bigwedge_{k=i+1}^{j-1} (|a_i-a_k|\le 0.0005) \land |a_i-a_j|&amp;gt; 0.0005\right).$$&lt;/span&gt;&#xA;Because &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; is given, there is no decision to be made.  You can fix all &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; up front, before calling any solver:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;x[0] = 1&#xA;c = a[0]&#xA;for i = 1 to n&#xA;   if |c - a[i]| &gt; 0.0005&#xA;      x[i] = 1&#xA;      c = a[0]&#xA;   else &#xA;      x[i] = 0&#xA;   endif&#xA;endfor&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Update now that &lt;span class=&quot;math-container&quot;&gt;$0.0005$&lt;/span&gt; is replaced with decision variable &lt;span class=&quot;math-container&quot;&gt;$\delta\in [0,U]$&lt;/span&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt; be a small constant.  For each &lt;span class=&quot;math-container&quot;&gt;$i&amp;lt;j$&lt;/span&gt;, let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$z_{i,j}$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$|a_i-a_j| \le \delta$&lt;/span&gt;.&#xA;The following constraints enforce the desired relationship between &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;|a_i-a_j|z_{i,j} &amp;amp;\le \delta &amp;amp;&amp;amp;\text{for $i &amp;lt; j$}\\&#xA;-|a_i - a_j| + \delta + \epsilon &amp;amp;\le (-|a_i - a_j| + U + \epsilon)z_{i,j} &amp;amp;&amp;amp;\text{for $i &amp;lt; j$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To enforce the logical proposition&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left(x_i \land \bigwedge_{k=i+1}^{j-1} z_{i,k} \land \neg z_{i,j}\right) \implies x_j,$$&lt;/span&gt;&#xA;impose the following additional constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i + \sum_{k=i+1}^{j-1} z_{i,k} + (1 - z_{i,j}) - (j - i) \le x_j$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the problem is to minimize the longest streak length &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; subject to the above constraints and the following min-max constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$s \ge k \left(\sum_{j=i}^{i+k-1} x_j - k + 1\right)$$&lt;/span&gt;&#xA;for all &lt;span class=&quot;math-container&quot;&gt;$i\in\{0,\dots,n\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k\in\{1,\dots,n-i+1\}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-03-31T00:40:19.890" LastActivityDate="2020-03-31T00:40:19.890" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="3801" PostTypeId="1" CreationDate="2020-03-30T11:39:22.300" Score="7" ViewCount="168" Body="&lt;p&gt;We have &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; projects in parallel that require shared resources the resources has time varying capacities (i.e &lt;span class=&quot;math-container&quot;&gt;$B_{rt}$&lt;/span&gt; is the units of resource &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; available in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;). For each project there is &lt;span class=&quot;math-container&quot;&gt;$n_j$&lt;/span&gt; jobs to be scheduled. Within each project there is a generalized precedence constraints (i.e of type &lt;span class=&quot;math-container&quot;&gt;$S_{kj} \geq S_{ki} + v_{kij} \forall (i,j) \in E_k$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$S_{ki}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S_{kj}$&lt;/span&gt; denote the starting times of jobs &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; of project &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$v_{kij}$&lt;/span&gt; is a time lag that can be non-negative or non positive and &lt;span class=&quot;math-container&quot;&gt;$E_k$&lt;/span&gt; the precedence graph associated to project &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;) There is &lt;em&gt;no&lt;/em&gt; precedence relations between jobs belonging to different projects. The objective function is the weighted sum of time completion (makespan) of each project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to solve the problem? I can't find papers that treat all of these constraints simultaneously. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to think of a local search but I am struggling to define a neighborhood (the classical swip etc does not work here). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also thinking of how to decompose the problem, to deal with every project independently, but how to reassemble the solutions in order to get a feasible solution for the original problem ?   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit : I modeled the problem, I am looking for solution methods other than simply and only to write the model. The point is I have large instances and solvers are not that good for scheduling problems. &lt;/p&gt;&#xA;" OwnerUserId="1188" LastEditorUserId="1188" LastEditDate="2020-03-30T15:57:39.220" LastActivityDate="2020-03-30T21:10:56.707" Title="How to solve this variant of RCPSP" Tags="|scheduling|metaheuristics|decomposition|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3802" PostTypeId="1" CreationDate="2020-03-30T12:50:16.347" Score="2" ViewCount="90" Body="&lt;p&gt;I want to write an optimization problem then solve it, to get optimized weights to compute a final score using a weighted arithmetic mean.&lt;/p&gt;&#xA;&lt;p&gt;The problem is as follows. I have an entity (an input vector &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;) that I need to match with none/some/all others entities bases on their scores. Assuming there are &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; candidate matches for &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;, if the score from &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$C_i$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$i \in \{ 1, N \}$&lt;/span&gt; noted &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt;, is higher than a certain threshold, it is considered match, otherwise it is not. Consequently, we may end-up that none/some/all candidates are matches.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; is a final weighted score that needs to be computed based on three scores, with different weights. The three scores &lt;span class=&quot;math-container&quot;&gt;$S_i^1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$S_i^2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S_i^3$&lt;/span&gt; are outputted by a machine learning platform, each of which represents a certain attribute:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$S_i = W_i^1 S_i^1 + W_i^2 S_i^2 + W_i^3 S_i^3$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So I want to model this as an optimization problem whose decision variables are the weights. I am thinking to set the objective function as &lt;span class=&quot;math-container&quot;&gt;$\sum_i S_i$&lt;/span&gt;. Nevertheless, I am not convinced by my approach.&lt;/p&gt;&#xA;&lt;p&gt;My question is are there any state-of-art/classical problems that I could refer to refine my modeling? How could classify this problem? It is not a 100% matching problem as I have only one entry in the left part of the bipartite graph.&lt;/p&gt;&#xA;" OwnerUserId="2599" LastEditorUserId="491" LastEditDate="2022-04-04T21:17:39.377" LastActivityDate="2022-04-04T21:17:39.377" Title="Problem classification: optimal weights for Weighted Arithmetic Mean" Tags="|optimization|modeling|matching|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3803" PostTypeId="1" CreationDate="2020-03-30T14:55:26.833" Score="4" ViewCount="1610" Body="&lt;p&gt;I've been to trying to read a &lt;code&gt;.sol&lt;/code&gt; file in cplex python API before solving the problem but couldn't find any command to do so. There are analogous commands for this operation in c++, c, and Java.&lt;/p&gt;&#xA;" OwnerUserId="3265" LastEditorUserId="500" LastEditDate="2023-12-13T18:09:23.933" LastActivityDate="2023-12-13T18:09:23.933" Title="How to read a solution file (.sol) in cplex python API?" Tags="|optimization|python|cplex|warm-start|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3804" PostTypeId="2" ParentId="3803" CreationDate="2020-03-30T15:46:03.657" Score="6" Body="&lt;p&gt;First, let us see how to write a .mst file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;mdl = Model(name='buses')&#xA;nbbus40 = mdl.integer_var(name='nbBus40')&#xA;nbbus30 = mdl.integer_var(name='nbBus30')&#xA;mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;mdl.minimize(nbbus40*460 + nbbus30*360)&#xA;&#xA;sol=mdl.solve()&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&quot; = &quot;,v.solution_value)&#xA;&#xA;sol.export_as_mst(path=&quot;C:/&quot;, basename=&quot;file.mst&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;generates file.mst&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version = &quot;1.0&quot; standalone=&quot;yes&quot;?&amp;gt;&#xA;&amp;lt;?xml-stylesheet href=&quot;https://www.ilog.com/products/cplex/xmlv1.0/solution.xsl&quot; type=&quot;text/xsl&quot;?&amp;gt;&#xA;&#xA;&amp;lt;!-- This file has been generated by DOcplex version 2.4.61  --&amp;gt;&#xA;&amp;lt;CPLEXSolution version=&quot;1.0&quot;&amp;gt;&#xA; &amp;lt;header&#xA;   problemName=&quot;buses&quot;&#xA;   objectiveValue=&quot;3480&quot;&#xA;  /&amp;gt;&#xA; &amp;lt;variables&amp;gt;&#xA;  &amp;lt;variable name=&quot;nbBus40&quot; index=&quot;0&quot; value=&quot;6&quot;/&amp;gt;&#xA;  &amp;lt;variable name=&quot;nbBus30&quot; index=&quot;1&quot; value=&quot;2&quot;/&amp;gt;&#xA; &amp;lt;/variables&amp;gt;&#xA;&amp;lt;/CPLEXSolution&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then to warm start from there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;mdl = Model(name='buses')&#xA;nbbus40 = mdl.integer_var(name='nbBus40')&#xA;nbbus30 = mdl.integer_var(name='nbBus30')&#xA;mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;mdl.minimize(nbbus40*460 + nbbus30*360)&#xA;&#xA;mdl.get_cplex().MIP_starts.read(&quot;c:/file.mst&quot;)&#xA;&#xA;sol=mdl.solve(log_output=True)&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&quot; = &quot;,v.solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will display&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 of 1 MIP starts provided solutions.&#xA;MIP start 'm1' defined initial solution with objective 3480.0000.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from warmstart &lt;a href=&quot;https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-03-30T15:46:03.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3805" PostTypeId="1" AcceptedAnswerId="3807" CreationDate="2020-03-30T20:00:44.143" Score="3" ViewCount="430" Body="&lt;p&gt;I have programmed the model in &lt;a href=&quot;https://or.stackexchange.com/questions/3745/can-gurobi-or-cplex-handle-nonlinearly-constrained-problems&quot;&gt;here&lt;/a&gt; using Gurobi 9.0 in Python 3.7. To ensure playing within the boundaries of the licensing, I am trying to program it using CPLEX where we have broader flexibility under a commercial license. I have two short questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, is DoCplex the same as Cplex in Python, if not can you please refer to an example implementation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, how can I introduce the rotated second-order cone constraints in this coding? I checked Docplex functions and couldn't see something relevant.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;### BEGIN DECLARING THE MODEL ###&#xA;m= Model('Some_model')&#xA;### END DECLARING THE MODEL ###&#xA;&#xA;### BEGIN ADDING VARIABLES INTO THE MODEL m ###&#xA;freq = m.continuous_var_dict(Pattern, lb=1, ub=15, name ='freq')&#xA;invfreq = m.continuous_var_dict(Pattern, lb=1, ub=15, name ='invfreq')&#xA;### END ADDING VARIABLES INTO THE MODEL m ###&#xA;&#xA;### BEGIN INTRODUCING THE OBJECTIVE FUNCTION INTO m ###&#xA;m.maximize(m.sum(0.5*crt_ridership[pat,s]*(30-30*invfreq[pat])&#xA;                        for (pat,s) in PatternStop))&#xA;### END INTRODUCING THE OBJECTIVE FUNCTION ###&#xA;&#xA;### BEGIN ADDING CONSTRAINTS INTO m ###&#xA;m.add_constraint(m.sum(unit_cost[pat]*triptime[pat]*freq[pat]/60 for pat in Pattern)&#xA;                    - m.sum(FixedFare*crt_ridership[pat,s] for (pat,s) in PatternStop) &amp;lt;= S)&#xA;&#xA;m.add_constraints(m.sum(triptimesurrogate[pat]*freq[pat]/30 &#xA;    for pat in Pattern if(pattern_time_index[pat]==p and pattern_bus_cap[pat]==82))&#xA;    &amp;lt;= FleetAvailSmall[p] for p in Period)&#xA;m.add_constraints(m.sum(triptimesurrogate[pat]*freq[pat]/30 &#xA;    for pat in Pattern if(pattern_time_index[pat]==p and pattern_bus_cap[pat]==107))&#xA;    &amp;lt;= FleetAvailLarge[p] for p in Period)&#xA;m.add_constraints(m.sum(triptimesurrogate[pat]*freq[pat]/30 &#xA;    for pat in Pattern if(pattern_time_index[pat]==p and pattern_bus_cap[pat]==246))&#xA;    &amp;lt;= FleetAvail2Car[p] for p in Period)&#xA;m.add_constraints(m.sum(triptimesurrogate[pat]*freq[pat]/30 &#xA;    for pat in Pattern if(pattern_time_index[pat]==p and pattern_bus_cap[pat]==492))&#xA;    &amp;lt;= FleetAvail4Car[p] for p in Period)&#xA;m.add_constraints(m.sum(triptimesurrogate[pat]*freq[pat]/30 &#xA;    for pat in Pattern if(pattern_time_index[pat]==p and pattern_bus_cap[pat]==738))&#xA;    &amp;lt;= FleetAvail6Car[p] for p in Period)&#xA;m.add_constraints(m.sum(triptimesurrogate[pat]*freq[pat]/30 &#xA;    for pat in Pattern if(pattern_time_index[pat]==p and pattern_bus_cap[pat]==984))&#xA;    &amp;lt;= FleetAvail8Car[p] for p in Period)&#xA;&#xA;m.add_constraints(crt_flow[pat,s] &amp;lt;= pattern_bus_cap[pat]*freq[pat] for (pat,s) in PatternStop)&#xA;&#xA;m.add(freq[pat]*invfreq[pat] &amp;gt;= abs(1) for pat in Pattern)&#xA;### END ADDING CONSTRAINTS INTO m ###&#xA;&#xA;solution = m.solve(log_output=True)&#xA;print(solution)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="518" LastEditorUserId="518" LastEditDate="2020-03-30T21:54:54.873" LastActivityDate="2020-04-02T16:09:48.163" Title="Rotated Second-Order Cone Constraints in docplex" Tags="|python|docplex|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3806" PostTypeId="2" ParentId="3801" CreationDate="2020-03-30T20:05:31.620" Score="4" Body="&lt;p&gt;There are broadly 2 approaches for obtaining feasible solutions to your problem, namely (1) Local search, and (ii) exact approaches (i.e. using solvers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you prefer to solve using exact approaches i.e. model the problem using a solver, then your best bet may be to model the problem using a Constraint Programming solver. At least from what I gather (so take it with a pinch of salt), CP tends to be more preferable over MIP approaches for scheduling problems, especially for problems that are more complicated than a single machine scheduling problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For local search methods, it would be helpful if you precisely define which approaches you have tried. I have to admit I have no personal experience working with the time-varying capacity of resources and have not all that frequently encountered problems (in papers) of the type you mention. Below I suggest a reasonably straightforward approach to try for your problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Approach 1:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Model the problem using a disjunctive graph (just as it is done in Job Shop Problems (JSPs)), or alternative graph (if you have blocking constraints).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Assuming you have a feasible solution to your problem and that it is represented graphically on the disjunctive graph, now formulate some simple swap moves using the critical path of the current solution. Resources that may be helpful to you here are swap neighborhoods for JSPs, and problems that have buffers with capacities. Another interesting neighborhood to look at is the Job Insertion neighborhood.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Generate new neighbors in your neighborhood with those swap moves. For each neighbor, compute a schedule using the longest path algorithm with the help of a graphical representation of the solution. Suppose the new solution violates any resource capacity, then check whether inserting wait times can make your problem feasible to the resource constraints. This is perhaps doable as a simple LP. Suppose inserting wait times does not help, then a common strategy in local search is to accept the solution, but the way you measure the quality of the infeasible solution is to make it the sum of it's completion time plus some penalty terms to indicate the degree of resource violation of the solution. You can implement this simple strategy using a meta-heuristic such as late acceptance, but alternatives exist.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In summary ( perhaps more directly answers your question on decomposing the problem), implement a local search procedure that decomposes the problem into 2 stages: &#xA;(1) Resource allocation and sequencing phase, which allocates and establishes the sequence in which each resource gets allocated to the different jobs within those projects and (2) compute a schedule using say Depth-first search (DFS) or exact solver such that the solution is feasible w.r.t time-varying nature of the availability of resources. With this approach, you can iterate from one solution to another (in a local search manner) by only worrying about the way in which resources are allocated to those projects, the scheduling portion can be given to an exact solver or computed heuristically using a search procedure like DFS. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my personal experience for scheduling problems with complicated constraints, the above approach seems to outperform the best primal solution returned by CP solvers within practical time limits (like 30 mins). However bear in mind that, considerable effort may be needed on part of the heuristic designer for optimizing the many sub-components with the approach I suggested.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2020-03-30T21:10:56.707" LastActivityDate="2020-03-30T21:10:56.707" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3807" PostTypeId="2" ParentId="3805" CreationDate="2020-03-31T00:39:11.457" Score="3" Body="&lt;p&gt;&lt;strong&gt;For your first question:&lt;/strong&gt; DOCplex instead is an object-oriented modeling API. It builds either on the CPLEX Python API (for local solves) or on the DOcplexcloud service, for remote solves. It provides object-oriented modeling which is more convenient for some people. This library is composed of 2 modules:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Mathematical Programming Modeling for Python using docplex.mp (DOcplex.MP)&lt;/li&gt;&#xA;&lt;li&gt;Constraint Programming Modeling for Python using docplex.cp (DOcplex.CP)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;in &lt;a href=&quot;http://ibmdecisionoptimization.github.io/docplex-doc/mp/samples.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt; you can find plenty of examples in which problems modeled using DOcplex in python. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For the second question:&lt;/strong&gt; I did a search and found that may be Mosek can be used for rotated second-order cone constraints (&lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/cqo.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-03-31T00:39:11.457" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3808" PostTypeId="1" AcceptedAnswerId="3809" CreationDate="2020-03-31T14:58:17.847" Score="4" ViewCount="237" Body="&lt;p&gt;The problem is as follows: there are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; jobs &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}=\{J_1,\ldots, J_n\}$&lt;/span&gt;, each of which &lt;strong&gt;could&lt;/strong&gt; be done. There are &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; machines &lt;span class=&quot;math-container&quot;&gt;$M_1,\ldots,M_k$&lt;/span&gt; that work in parallel, independently of each other, and each of the jobs can be performed on any of the machines. Each of the jobs has a fixed execution time. Machine can do at most one job at any moment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The set of jobs is partitioned into two subsets, &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J} = \mathcal{J}_{\wedge}\cup  \mathcal{J}_{\vee}$&lt;/span&gt;, and each of the jobs is assigned a set of prerequisites by a function &lt;span class=&quot;math-container&quot;&gt;$P\colon \mathcal{J}\to 2^{\mathcal{J}}$&lt;/span&gt;. The interpretation of prerequisites is the following: if &lt;span class=&quot;math-container&quot;&gt;$J\in \mathcal{J}_{\wedge}$&lt;/span&gt;, then &lt;strong&gt;all&lt;/strong&gt; the jobs from &lt;span class=&quot;math-container&quot;&gt;$P(J)$&lt;/span&gt; need to be finished before &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; can be started. If &lt;span class=&quot;math-container&quot;&gt;$J\in \mathcal{J}_{\vee}$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; can be started as soon as &lt;strong&gt;at least one&lt;/strong&gt; of the jobs from &lt;span class=&quot;math-container&quot;&gt;$P(J)$&lt;/span&gt; is finished.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The goal is to schedule the jobs among the machines in such a way that the job &lt;span class=&quot;math-container&quot;&gt;$J_n$&lt;/span&gt; is done as soon as possible, while respecting the prerequisites constraints. So, we only care about the job &lt;span class=&quot;math-container&quot;&gt;$J_n$&lt;/span&gt; and want to perform only the jobs that enable doing &lt;span class=&quot;math-container&quot;&gt;$J_n$&lt;/span&gt;, while scheduling them in a way that minimizes the makespan.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have spent &lt;em&gt;some&lt;/em&gt; time looking, but I haven't found similarly formulated problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: could anyone point me to literature on similar problems? By similar I mean especially ones with the same type of prerequisites (both conjunctions and alternatives).&lt;/p&gt;&#xA;" OwnerUserId="2820" LastActivityDate="2020-04-01T08:05:29.950" Title="Is this another variant of Job Shop Scheduling Problem?" Tags="|optimization|reference-request|scheduling|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3809" PostTypeId="2" ParentId="3808" CreationDate="2020-03-31T18:20:56.623" Score="3" Body="&lt;p&gt;Without &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}_{\land}, \mathcal{J}_{\lor}$&lt;/span&gt;, the problem you described is called a Parallel machine scheduling problem in literature, and so not a Job shop scheduling problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$J \in \mathcal{J}_{\land}$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$P(J)$&lt;/span&gt; are simply precedence constraints for &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;, or sometimes referred to as AND precedence constraints. There are a lot of papers on parallel machine scheduling problems with precedence constraints, that you should easily be able to find on the web.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$J \in \mathcal{J}_{\lor}$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$P(J)$&lt;/span&gt; is referred to as OR-type constraints according to this paper: &lt;a href=&quot;https://pdfs.semanticscholar.org/584b/292a3deb7c9ac1bdb753b0a3eb891338a0f3.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pdfs.semanticscholar.org/584b/292a3deb7c9ac1bdb753b0a3eb891338a0f3.pdf&lt;/a&gt;&#xA;Personally, I could not find papers on parallel machine scheduling with AND, OR precedence constraints either, but I think you may be able to gather something useful from the papers that have cited the paper in the link above.&lt;/p&gt;&#xA;" OwnerUserId="972" LastActivityDate="2020-03-31T18:20:56.623" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3810" PostTypeId="1" AcceptedAnswerId="3815" CreationDate="2020-03-31T20:28:25.920" Score="3" ViewCount="185" Body="&lt;p&gt;In an MILP problem, I wonder if it is better to use an objective function that involves as many of the variables of the problem as possible as opposed to an objective function with only a few variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would expect that the &quot;variable rich&quot; objective is the better choice because it carries more information. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could always put variables in the objective function even if they do not belong there by penalizing them to an extend that they do not do harm. &lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="1269" LastEditDate="2020-04-01T08:08:25.573" LastActivityDate="2020-04-01T22:09:16.487" Title="How to design the objective function of an MILP problem" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3811" PostTypeId="2" ParentId="3808" CreationDate="2020-04-01T03:22:22.133" Score="2" Body="&lt;p&gt;I can refer you to two papers that you may get some hints from. The first one is by &lt;a href=&quot;https://www.tandfonline.com/doi/full/10.1080/00207543.2011.561375?casa_token=x5k_Y3t2k7MAAAAA%3AFuPWdxQsqjYZiPPZrsvlYqpKZ3R6LpKtQj0_wRZAZXWjJHavjp5IGh2JI78BAQIsZqPeZr5jOH1WWQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lee &lt;em&gt;et al.&lt;/em&gt; (2012)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;, proposing an MILP for the flexible job-shop problem with ‘AND’/‘OR’ precedence constraints, and the second one is by &lt;a href=&quot;https://link.springer.com/chapter/10.1007/11841036_58&quot; rel=&quot;nofollow noreferrer&quot;&gt;van den Akker &lt;em&gt;et al.&lt;/em&gt; (2006)&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt;, that studies a parallel machine scheduling problem with precedence constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from that, what comes to my mind is that you can force the last job to be scheduled in the following way (&lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}$&lt;/span&gt; is the set of jobs indexed by &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is the set of machines indexed by &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\min&amp;amp;\quad z = C_{max}\\\text{s.t.}&amp;amp;\quad\sum_{i \in M} x_{ij} \leq 1, \quad \forall j \in \mathcal{J} \setminus n \tag1\\&amp;amp;\quad\sum_{i \in M} x_{in} = 1 \tag2\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 1$&lt;/span&gt; means that job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is scheduled on machine &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Constraints (1) means each job can be processed by at most one machine, and constraint (2) implies the last job must be processed by one of the machines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although, probably due to the precedence constraints you need three-indexed variables.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References: &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Lee, Sanghyup, et al. &quot;Flexible job-shop scheduling problems with ‘AND’/‘OR’precedence constraints.&quot; &lt;em&gt;International Journal of Production Research&lt;/em&gt; 50.7 (2012): 1979-2001. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [2] Van den Akker, J. M., J. A. Hoogeveen, and Jules W. van Kempen. &quot;Parallel machine scheduling through column generation: Minimax objective functions.&quot; &lt;em&gt;European Symposium on Algorithms&lt;/em&gt;. Springer, Berlin, Heidelberg, 2006. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="123" LastEditDate="2020-04-01T08:05:29.950" LastActivityDate="2020-04-01T08:05:29.950" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3812" PostTypeId="1" CreationDate="2020-04-01T06:10:08.547" Score="2" ViewCount="168" Body="&lt;p&gt;Up until this point I have only solved simple LPP problems with maybe 2 to 3 variables that looked like this, using pen and paper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://www.researchgate.net/profile/Scott_Leavengood/publication/239527227/figure/tbl1/AS:669489494503428@1536630142183/Information-for-the-wooden-tables-and-chairs-linear-programming-problem.png&quot; alt=&quot;simple lpp&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to solve &#xA;&lt;a href=&quot;https://drive.google.com/open?id=12UQBWmOEzRBEar9RBnqmkpuTs1DVYlYO&quot; rel=&quot;nofollow noreferrer&quot;&gt;This Problem&lt;/a&gt; using Simplex, Dual Simplex, Big M and 2 Phase. I can use a solver for this problem, but I don't know how to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the PDF above it looks like it has all the constraints and the objective function, I assume I will have to substitute the above values and make a massive objective function.&#xA;But I don't know what I even need to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have downloaded GAMS and modeled a simple problem in it, but I am not understanding how to start modelling this one in it.&#xA;So can someone help me on how to start? I have not solved these types of problems before, so which program should I use? Any tutorials maybe on how to model my problem in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than GAMS I checked and their is an Excel Solver, some libraries for python. I am fine with any of these. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding a few images from the PDF:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://snipboard.io/DzAVwR.jpg&quot; alt=&quot;Cons&quot;&gt; &#xA;&lt;img src=&quot;https://snipboard.io/lRIF16.jpg&quot; alt=&quot;Cons1&quot;&gt;&#xA;&lt;img src=&quot;https://snipboard.io/tBiXor.jpg&quot; alt=&quot;Objective&quot;&gt;&#xA;&lt;img src=&quot;https://snipboard.io/78lhLr.jpg&quot; alt=&quot;Objective 2&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3268" LastActivityDate="2020-04-01T06:10:08.547" Title="How to solve an LPP with summation" Tags="|optimization|modeling|solver|python|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3813" PostTypeId="1" CreationDate="2020-04-01T07:37:43.813" Score="18" ViewCount="754" Body="&lt;p&gt;I have come across GUROBI's &lt;a href=&quot;https://www.gurobi.com/resource/mathematical-optimization-and-machine-learning/&quot; rel=&quot;nofollow noreferrer&quot;&gt;webinar&lt;/a&gt; &amp;quot;Mathematical optimization and machine learning&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;In essence, Mathematical Optimization (MO) and Machine Learning (ML) are different but complementary technologies. Simply put – Mixed Integer Programming (MIP) answers questions that ML cannot. Machine learning makes predictions while MIP makes decisions. They call Artificial Intelligence (AI) the combination of both technologies.&lt;/p&gt;&#xA;&lt;p&gt;More specifically :&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;ML predictions can determine the need to make a MO decision.&lt;/li&gt;&#xA;&lt;li&gt;ML predictions can be used as MO decision constraints (when the data is missing).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Other interesting examples are given &lt;a href=&quot;https://www.funartech.com/approach/hybridization#ml-and-or-blackboxes&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; by &lt;a href=&quot;https://www.funartech.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;FunArtech&lt;/a&gt;, a startup in Montreal who claim to be the future of AI. For example, they claim that &amp;quot;some research is conducted in order to predict on what variable and how to branch in search trees.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;This is interesting and leads me to asking the following (broad, I agree) questions :&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;In your personal experience, as an OR scientist, to what extent and how have you used ML for MO ?&lt;/li&gt;&#xA;&lt;li&gt;What would you recommend MO practitioners to learn in priority ? General ML techniques ? Neural networks ? Data statistics ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;And I am aware the question is broad and this may be the wrong place to ask.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Related questions :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/889/examples-of-machine-learning-applied-to-operations-research&quot;&gt;Examples of ML applied to OR&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/304/use-of-machine-learning-techniques-to-determine-parameter-values&quot;&gt;Use of ML to determine parameter values&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/q/183/2999&quot;&gt;What are the tradeoffs between “exact” and Reinforcement Learning methods for solving optimization problems&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="491" LastEditDate="2022-12-28T14:12:06.167" LastActivityDate="2022-12-28T14:12:06.167" Title="Best ways to use machine learning / AI as an OR scientist" Tags="|optimization|machine-learning|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3815" PostTypeId="2" ParentId="3810" CreationDate="2020-04-01T22:09:16.487" Score="5" Body="&lt;p&gt;If a problem has multiple optima, adding small penalties or rewards to variables that do not directly contribute to the true objective can help by breaking ties that the solver would otherwise encounter. Note that I said &quot;can&quot; help, not &quot;will&quot; help. The solver would work through those ties on its own, so the added terms only help if you get lucky in the choice of variables and coefficients. As far as I know, you can also make the solution time greater by an unlucky choice of spurious terms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you may also benefit in some cases by avoid degeneracy in the dual of the LP relaxation. Again, I believe this adheres to the old adage about bear hunting: some days you get the bear, and some days the bear gets you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing, however, is certain: if you make the coefficients of the additional terms too large, you can end up with a solution that is optimal in the modified problem but suboptimal in the original problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-04-01T22:09:16.487" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3816" PostTypeId="2" ParentId="3813" CreationDate="2020-04-01T22:15:36.863" Score="11" Body="&lt;p&gt;First, I would argue that the technologies are not necessarily complementary, but can be supplementary. A &lt;a href=&quot;http://www.optimization-online.org/DB_HTML/2020/03/7662.html&quot; rel=&quot;noreferrer&quot;&gt;paper&lt;/a&gt; uploaded to Optimization Online just last month discusses the use of machine learning to decide how to linearize MIQP models.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My answer to your first question is no doubt shaped by my being an academic, which means I rarely solve the same problem twice (other than perhaps running multiple instances before submitting the paper and moving on to something else). I never use ML for optimization, because ML requires a substantial library of solved instances for training purposes, which I never have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have an answer to your second question as a result of never having tried to use ML.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-04-01T22:15:36.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3817" PostTypeId="1" CreationDate="2020-04-02T02:03:46.680" Score="5" ViewCount="107" Body="&lt;p&gt;How to linearize difference of absolutes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$|a|\ge k|b|$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$a,b$&lt;/span&gt; are variables and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is a constant.&lt;/p&gt;&#xA;" OwnerUserId="3256" LastEditorUserId="123" LastEditDate="2020-04-02T07:34:47.863" LastActivityDate="2020-04-02T15:03:20.537" Title="How to linearize difference of absolutes?" Tags="|optimization|mixed-integer-programming|linear-programming|modeling|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3818" PostTypeId="1" CreationDate="2020-04-02T10:01:55.663" Score="2" ViewCount="135" Body="&lt;p&gt;I am testing &lt;a href=&quot;http://vrp-rep.org/variants/item/e-vrp-nl.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Montoya et al. 2017&lt;/a&gt; dataset and trying to replicate the Result from this paper &lt;a href=&quot;https://hal.archives-ouvertes.fr/hal-02386167/file/The_electric_vehicle_routing_problem_with_capacitated_charging_stations-HAL.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;The electric vehicle routing problem with capacitated charging stations&lt;/a&gt;. I am unable to replicate the exact Result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT::&#xA;Read me file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Montoya et al. 2016&#xA;Instances for the electric vehicle routing problemw with non-linear charging functions&#xA;Number of instances: 120&#xA;-------------------------------------------------------------------------------------------------------------&#xA;&amp;lt;network&amp;gt;&#xA;- the node with type=0 is the depot&#xA;- the nodes with type=1 are the customers&#xA;- the nodes with type=2 are the charging stations (CSs)&#xA;- coordinates are given in km&#xA;- nodes with type=2 define the type of charging station (slow, normal, fast) in tag &amp;lt;cs_type&amp;gt;&#xA;- computations must be done using double precision (14 decimal) Euclidean distances&#xA;&amp;lt;fleet&amp;gt;&#xA;- There is just one type of electric vehicle in the 120 instances&#xA;- Routes start and end at node 0 (the depot)&#xA;- &amp;lt;speed_factor&amp;gt; is given in km/h&#xA;- &amp;lt;consumption_rate&amp;gt; defines the energy consumption in wh/km&#xA;- &amp;lt;battery_capacity&amp;gt; defines the total capacity in wh&#xA;- &amp;lt;function cs_type=&quot;X&quot;&amp;gt; defines the charging function of the electric vehicle when charged at a station of type X&#xA;- The charging functions are piecewise linear functions with 3 break points (pus point 0,0)&#xA;- The break points are given in 2D coordinates (X:&amp;lt;charging_time&amp;gt;,Y:&amp;lt;battery_level&amp;gt;)&#xA;- &amp;lt;battery_level&amp;gt; is given in wh&#xA;- &amp;lt;charging_time&amp;gt; is given in h&#xA;&amp;lt;requests&amp;gt;&#xA;- Each customer has 1 request&#xA;- Each customer has a service time&#xA;&#xA;Instances are named using the following convention: tcAcBsCcDE, where:&#xA;- A is the method used to place the customers (i.e., 0: random uniform, 1: clustered, 2: mixture of both)&#xA;- B is the number of customers&#xA;- C is the number of the CSs, &#xA;- D is 't' if the CSs are located using a p-median heuristic and 'f' if the CSs were randomly located&#xA;- E is the number of the instance for each combination of parameters (i.e., E={0,1,2,3,4}).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example here - &lt;code&gt;tc0c10s2ct1&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&#xA;&amp;lt;instance&amp;gt;&#xA;  &amp;lt;info&amp;gt;&#xA;    &amp;lt;dataset&amp;gt;Montoya et al. 2016&amp;lt;/dataset&amp;gt;&#xA;    &amp;lt;name&amp;gt;tc0c10s2ct1&amp;lt;/name&amp;gt;&#xA;  &amp;lt;/info&amp;gt;&#xA;  &amp;lt;network&amp;gt;&#xA;    &amp;lt;nodes&amp;gt;&#xA;      &amp;lt;node id=&quot;0&quot; type=&quot;0&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;77.59&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;78.35&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;1&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;12.44&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;47.61&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;2&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;108.2&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;93.64&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;3&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;58.51&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;24.22&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;4&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;116.26&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;13.76&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;5&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;113.56&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;85.73&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;6&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;5.09&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;69.91&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;7&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;89.27&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;58.94&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;8&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;78.54&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;57.16&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;9&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;111.56&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;51.2&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;10&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;11.05&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;72.52&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;11&quot; type=&quot;2&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;20.26&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;60.26&amp;lt;/cy&amp;gt;&#xA;        &amp;lt;custom&amp;gt;&#xA;          &amp;lt;cs_type&amp;gt;fast&amp;lt;/cs_type&amp;gt;&#xA;        &amp;lt;/custom&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;12&quot; type=&quot;2&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;70.9&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;30.98&amp;lt;/cy&amp;gt;&#xA;        &amp;lt;custom&amp;gt;&#xA;          &amp;lt;cs_type&amp;gt;fast&amp;lt;/cs_type&amp;gt;&#xA;        &amp;lt;/custom&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;    &amp;lt;/nodes&amp;gt;&#xA;    &amp;lt;euclidean /&amp;gt;&#xA;    &amp;lt;decimals&amp;gt;14&amp;lt;/decimals&amp;gt;&#xA;  &amp;lt;/network&amp;gt;&#xA;  &amp;lt;fleet&amp;gt;&#xA;    &amp;lt;vehicle_profile type=&quot;0&quot;&amp;gt;&#xA;      &amp;lt;departure_node&amp;gt;0&amp;lt;/departure_node&amp;gt;&#xA;      &amp;lt;arrival_node&amp;gt;0&amp;lt;/arrival_node&amp;gt;&#xA;      &amp;lt;max_travel_time&amp;gt;10&amp;lt;/max_travel_time&amp;gt;&#xA;      &amp;lt;speed_factor&amp;gt;40&amp;lt;/speed_factor&amp;gt;&#xA;      &amp;lt;custom&amp;gt;&#xA;        &amp;lt;consumption_rate&amp;gt;125&amp;lt;/consumption_rate&amp;gt;&#xA;        &amp;lt;battery_capacity&amp;gt;16000&amp;lt;/battery_capacity&amp;gt;&#xA;        &amp;lt;charging_functions&amp;gt;&#xA;          &amp;lt;function cs_type=&quot;fast&quot;&amp;gt;&#xA;            &amp;lt;breakpoint&amp;gt;&#xA;              &amp;lt;battery_level&amp;gt;0&amp;lt;/battery_level&amp;gt;&#xA;              &amp;lt;charging_time&amp;gt;0.0&amp;lt;/charging_time&amp;gt;&#xA;            &amp;lt;/breakpoint&amp;gt;&#xA;            &amp;lt;breakpoint&amp;gt;&#xA;              &amp;lt;battery_level&amp;gt;13600&amp;lt;/battery_level&amp;gt;&#xA;              &amp;lt;charging_time&amp;gt;0.31&amp;lt;/charging_time&amp;gt;&#xA;            &amp;lt;/breakpoint&amp;gt;&#xA;            &amp;lt;breakpoint&amp;gt;&#xA;              &amp;lt;battery_level&amp;gt;15200&amp;lt;/battery_level&amp;gt;&#xA;              &amp;lt;charging_time&amp;gt;0.39&amp;lt;/charging_time&amp;gt;&#xA;            &amp;lt;/breakpoint&amp;gt;&#xA;            &amp;lt;breakpoint&amp;gt;&#xA;              &amp;lt;battery_level&amp;gt;16000&amp;lt;/battery_level&amp;gt;&#xA;              &amp;lt;charging_time&amp;gt;0.51&amp;lt;/charging_time&amp;gt;&#xA;            &amp;lt;/breakpoint&amp;gt;&#xA;          &amp;lt;/function&amp;gt;&#xA;        &amp;lt;/charging_functions&amp;gt;&#xA;      &amp;lt;/custom&amp;gt;&#xA;    &amp;lt;/vehicle_profile&amp;gt;&#xA;  &amp;lt;/fleet&amp;gt;&#xA;  &amp;lt;requests&amp;gt;&#xA;    &amp;lt;request id=&quot;1&quot; node=&quot;1&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;2&quot; node=&quot;2&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;3&quot; node=&quot;3&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;4&quot; node=&quot;4&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;5&quot; node=&quot;5&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;6&quot; node=&quot;6&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;7&quot; node=&quot;7&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;8&quot; node=&quot;8&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;9&quot; node=&quot;9&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;10&quot; node=&quot;10&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;  &amp;lt;/requests&amp;gt;&#xA;&amp;lt;/instance&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My Result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; visit   charge Left      Distance Traveled     Charge Time&#xA;    0  16000.000000000000    1.000000000000  0.000000000000&#xA;    7  13168.341640928415   23.653266872629  0.000000000000&#xA;    8  11808.761627652219   34.529906978831  0.000000000000&#xA;   11  16000.000000000000   92.892295552301  0.407119592116&#xA;   10  14083.249413069105  108.226300247712  0.000000000000&#xA;    6  13269.945003576588  114.732735523605  0.000000000000&#xA;    1  10334.939413718195  138.212780242437  0.000000000000&#xA;    3   3876.494118989694  189.880342600285  0.000000000000&#xA;   12  16000.000000000000  203.994509242359  0.461853733869&#xA;    4   9935.170550625542  252.513144837343  0.000000000000&#xA;   12  16000.000000000000  301.031780432328  0.421778989613&#xA;    9  10323.728116095881  346.441955503542  0.000000000000&#xA;    5   6000.244097101502  381.029827655526  0.000000000000&#xA;    2   4805.871222953778  390.584810648696  0.000000000000&#xA;    0    528.831870200578  424.801125470665  0.000000000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Total time travel + charging = &lt;code&gt;11.885&lt;/code&gt; + service Time(0.5*10) = &lt;code&gt;16.885&lt;/code&gt;, but in paper &lt;code&gt;tc0c10s2ct1 - 12.30&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for another example &lt;code&gt;tc0c10s2cf1&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&#xA;&amp;lt;instance&amp;gt;&#xA;  &amp;lt;info&amp;gt;&#xA;    &amp;lt;dataset&amp;gt;Montoya et al. 2016&amp;lt;/dataset&amp;gt;&#xA;    &amp;lt;name&amp;gt;tc0c10s2cf1&amp;lt;/name&amp;gt;&#xA;  &amp;lt;/info&amp;gt;&#xA;  &amp;lt;network&amp;gt;&#xA;    &amp;lt;nodes&amp;gt;&#xA;      &amp;lt;node id=&quot;0&quot; type=&quot;0&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;77.59&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;78.35&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;1&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;12.44&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;47.61&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;2&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;108.2&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;93.64&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;3&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;58.51&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;24.22&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;4&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;116.26&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;13.76&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;5&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;113.56&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;85.73&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;6&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;5.09&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;69.91&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;7&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;89.27&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;58.94&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;8&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;78.54&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;57.16&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;9&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;111.56&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;51.2&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;10&quot; type=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;11.05&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;72.52&amp;lt;/cy&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;11&quot; type=&quot;2&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;93.39&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;10.8&amp;lt;/cy&amp;gt;&#xA;        &amp;lt;custom&amp;gt;&#xA;          &amp;lt;cs_type&amp;gt;fast&amp;lt;/cs_type&amp;gt;&#xA;        &amp;lt;/custom&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;      &amp;lt;node id=&quot;12&quot; type=&quot;2&quot;&amp;gt;&#xA;        &amp;lt;cx&amp;gt;8.9&amp;lt;/cx&amp;gt;&#xA;        &amp;lt;cy&amp;gt;10.98&amp;lt;/cy&amp;gt;&#xA;        &amp;lt;custom&amp;gt;&#xA;          &amp;lt;cs_type&amp;gt;fast&amp;lt;/cs_type&amp;gt;&#xA;        &amp;lt;/custom&amp;gt;&#xA;      &amp;lt;/node&amp;gt;&#xA;    &amp;lt;/nodes&amp;gt;&#xA;    &amp;lt;euclidean /&amp;gt;&#xA;    &amp;lt;decimals&amp;gt;14&amp;lt;/decimals&amp;gt;&#xA;  &amp;lt;/network&amp;gt;&#xA;  &amp;lt;fleet&amp;gt;&#xA;    &amp;lt;vehicle_profile type=&quot;0&quot;&amp;gt;&#xA;      &amp;lt;departure_node&amp;gt;0&amp;lt;/departure_node&amp;gt;&#xA;      &amp;lt;arrival_node&amp;gt;0&amp;lt;/arrival_node&amp;gt;&#xA;      &amp;lt;max_travel_time&amp;gt;10&amp;lt;/max_travel_time&amp;gt;&#xA;      &amp;lt;speed_factor&amp;gt;40&amp;lt;/speed_factor&amp;gt;&#xA;      &amp;lt;custom&amp;gt;&#xA;        &amp;lt;consumption_rate&amp;gt;125&amp;lt;/consumption_rate&amp;gt;&#xA;        &amp;lt;battery_capacity&amp;gt;16000&amp;lt;/battery_capacity&amp;gt;&#xA;        &amp;lt;charging_functions&amp;gt;&#xA;          &amp;lt;function cs_type=&quot;fast&quot;&amp;gt;&#xA;            &amp;lt;breakpoint&amp;gt;&#xA;              &amp;lt;battery_level&amp;gt;0&amp;lt;/battery_level&amp;gt;&#xA;              &amp;lt;charging_time&amp;gt;0.0&amp;lt;/charging_time&amp;gt;&#xA;            &amp;lt;/breakpoint&amp;gt;&#xA;            &amp;lt;breakpoint&amp;gt;&#xA;              &amp;lt;battery_level&amp;gt;13600&amp;lt;/battery_level&amp;gt;&#xA;              &amp;lt;charging_time&amp;gt;0.31&amp;lt;/charging_time&amp;gt;&#xA;            &amp;lt;/breakpoint&amp;gt;&#xA;            &amp;lt;breakpoint&amp;gt;&#xA;              &amp;lt;battery_level&amp;gt;15200&amp;lt;/battery_level&amp;gt;&#xA;              &amp;lt;charging_time&amp;gt;0.39&amp;lt;/charging_time&amp;gt;&#xA;            &amp;lt;/breakpoint&amp;gt;&#xA;            &amp;lt;breakpoint&amp;gt;&#xA;              &amp;lt;battery_level&amp;gt;16000&amp;lt;/battery_level&amp;gt;&#xA;              &amp;lt;charging_time&amp;gt;0.51&amp;lt;/charging_time&amp;gt;&#xA;            &amp;lt;/breakpoint&amp;gt;&#xA;          &amp;lt;/function&amp;gt;&#xA;        &amp;lt;/charging_functions&amp;gt;&#xA;      &amp;lt;/custom&amp;gt;&#xA;    &amp;lt;/vehicle_profile&amp;gt;&#xA;  &amp;lt;/fleet&amp;gt;&#xA;  &amp;lt;requests&amp;gt;&#xA;    &amp;lt;request id=&quot;1&quot; node=&quot;1&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;2&quot; node=&quot;2&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;3&quot; node=&quot;3&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;4&quot; node=&quot;4&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;5&quot; node=&quot;5&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;6&quot; node=&quot;6&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;7&quot; node=&quot;7&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;8&quot; node=&quot;8&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;9&quot; node=&quot;9&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;    &amp;lt;request id=&quot;10&quot; node=&quot;10&quot;&amp;gt;&#xA;      &amp;lt;service_time&amp;gt;0.5&amp;lt;/service_time&amp;gt;&#xA;    &amp;lt;/request&amp;gt;&#xA;  &amp;lt;/requests&amp;gt;&#xA;&amp;lt;/instance&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My Result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; visit   charge Left      Distance Traveled     Charge Time&#xA;    0  16000.000000000000    1.000000000000  0.000000000000&#xA;    7  13168.341640928411   23.653266872629  0.000000000000&#xA;    8  11808.761627652217   34.529906978831  0.000000000000&#xA;   12  16000.000000000000  118.090196590638  0.478915082207&#xA;    1  11399.917629813544  154.890855552163  0.000000000000&#xA;   10   8281.323695842644  179.839607023983  0.000000000000&#xA;    6   7468.019286350116  186.346042299876  0.000000000000&#xA;   12  16000.000000000000  245.399077784969  0.508030819589&#xA;    3   9581.703764821985  296.745447666384  0.000000000000&#xA;   11  16000.000000000000  334.118041903363  0.398077930861&#xA;   4  13117.405411352520  357.178798612556  0.000000000000&#xA;  11  16000.000000000000  380.239555321750  0.276706518021&#xA;   9  10462.755508152066  424.537511256523  0.000000000000&#xA;   5   6139.271489157687  459.125383408507  0.000000000000&#xA;   2   4944.898615009963  468.680366401677  0.000000000000&#xA;   0    667.859262256759  502.896681223647  0.000000000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Total time travel + charging = &lt;code&gt;14.209&lt;/code&gt; + service Time(0.5*10) = &lt;code&gt;19.209&lt;/code&gt;, but in paper &lt;code&gt;tc0c10s2cf1 - 19.75&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is wrong with my Result?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My objective function minimizes distance traveled and charging time. (Not using an exact formulation from the paper, I am trying a simple formulation)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for charging time I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f = opt_model.piecewise(0, [(0, 0), (13600, 0.31), (15200, 0.39), (16000, 0.51)], 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have used simple flow and charging constraints.&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="700" LastEditDate="2020-04-03T11:25:19.323" LastActivityDate="2020-04-03T11:25:19.323" Title="Montoya et al. 2017 benchmark Results" Tags="|modeling|vehicle-routing|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3819" PostTypeId="1" CreationDate="2020-04-02T11:02:51.517" Score="4" ViewCount="55" Body="&lt;p&gt;I'm trying to solve one interesting math task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let’s imagine we have a number of instructors with different timespans during the day in which they work or they are available. We need to display to students timeslots where they can book inside the available timespan of the instructor. Within this time period we need to optimize the appointments so that there is a minimum number of &quot;idle&quot; timeslots. Once an appointment has been set we cannot move the appointment. The negotiation of an appointment must happen without negotiating with other students. Appointments have variable and unknown lengths?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas people ?&lt;/p&gt;&#xA;" OwnerUserId="3277" LastEditorUserId="123" LastEditDate="2020-04-02T12:39:57.223" LastActivityDate="2020-04-02T12:39:57.223" Title="Instructors optimized schedule task" Tags="|optimization|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3820" PostTypeId="2" ParentId="3817" CreationDate="2020-04-02T14:31:30.303" Score="2" Body="&lt;p&gt;Create some extra variables&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$AB_1, AB_2, X_1, X_2, X_3, X_4$&lt;/span&gt;, and you have &lt;span class=&quot;math-container&quot;&gt;$a,b,k$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}a &amp;amp;= X_1-X_2\\AB_1 &amp;amp;= X_1+X_2\\b &amp;amp;= X_3-X_4\\AB_2 &amp;amp;= X_3+X_4\\AB_1 &amp;amp;\geq k \cdot AB_2\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you have to minimize variable &lt;span class=&quot;math-container&quot;&gt;$X_1, X_2, X_3, X_4$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_1, X_2, X_3, X_4 \geq 0$&lt;/span&gt; &lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="123" LastEditDate="2020-04-02T15:03:20.537" LastActivityDate="2020-04-02T15:03:20.537" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3821" PostTypeId="2" ParentId="3805" CreationDate="2020-04-02T16:09:48.163" Score="1" Body="&lt;p&gt;For future reference, I solved this issue by using Pyomo modeling tool. In the end, I could solve the problem using Cplex, Gurobi, and ipopt by only stating the name of the solver.&lt;/p&gt;&#xA;" OwnerUserId="518" LastActivityDate="2020-04-02T16:09:48.163" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3822" PostTypeId="1" CreationDate="2020-04-02T23:09:01.347" Score="6" ViewCount="111" Body="&lt;p&gt;I am working on a projection problem on a very large set of highly related constraints: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_x &amp;amp; \quad\|x-x_k\|_2^2 \\&#xA;\mathrm{s.t.} &amp;amp; \quad\max_{T\in\mathcal{T}} \sum_i \frac{t_i}{x_i} - f(t)^2\leq0 \\&#xA; &amp;amp; \quad x\geq0 &amp;amp;&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is quite easy to check whether the constraints are satisfied or to compute a gradient (of either the objective function or the constraint). &lt;span class=&quot;math-container&quot;&gt;$\mathcal{T}$&lt;/span&gt; is a quite large set of points (it is a combinatorial set that can be described by &lt;span class=&quot;math-container&quot;&gt;$a^Tt\leq b$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$t\in\{0,1\}^d$&lt;/span&gt;, so with &lt;span class=&quot;math-container&quot;&gt;$\mathcal{O}(2^d)$&lt;/span&gt; points). I'd rather avoid writing out explicitly all constraints for all &lt;span class=&quot;math-container&quot;&gt;$t\in\mathcal T$&lt;/span&gt; (even though that would be a standard smooth convex program). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These tricky constraints come from bandits theory, it's a link between the decisions to take &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and the variance &lt;span class=&quot;math-container&quot;&gt;$f(t)^2$&lt;/span&gt; for the set of decisions &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem is also convex, as it can be equivalently written as: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_x &amp;amp; \quad\|x-x_k\|_2^2 &amp;amp; \\&#xA;\mathrm{s.t.} &amp;amp; \quad\sum_i \frac{t_i}{x_i} \leq f(t)^2 &amp;amp; \forall T\in\mathcal{T} \subset 2^{\{0,1\}^d} \\&#xA; &amp;amp; \quad x\geq0 &amp;amp;&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Hessian matrix of the latter constraint is: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{pmatrix}&#xA;\frac{2t_1}{x_1^3} &amp;amp; 0 &amp;amp; 0 &amp;amp; \cdots &amp;amp; 0 \\&#xA;0 &amp;amp; \frac{2t_2}{x_2^3} &amp;amp; 0 &amp;amp; \cdots &amp;amp; \vdots\\&#xA;0 &amp;amp; 0 &amp;amp; \ddots &amp;amp; \ddots &amp;amp; \vdots &amp;amp; \\&#xA;\vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp; \ddots &amp;amp; 0 \\&#xA;0 &amp;amp; \cdots &amp;amp; \cdots &amp;amp; 0 &amp;amp; \frac{2t_n}{x_n^3}&#xA;\end{pmatrix}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;span class=&quot;math-container&quot;&gt;$t_i\in\{0,1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x\geq0$&lt;/span&gt;, all eigenvalues are always nonnegative. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I need to be able to prove that I can solve this in polynomial time (i.e. reach a precision &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt; on the objective function with all constraints satisfied within &lt;span class=&quot;math-container&quot;&gt;$\mathcal{O}(d/\varepsilon)$&lt;/span&gt; time, probably with higher exponents). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is why I explored the domain of nonsmooth optimisation (which is not my cup of tea). &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I know I can use methods like an augmented Lagrangian to solve it (as proposed in &lt;a href=&quot;https://arxiv.org/pdf/1610.04514.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;The proximal augmented Lagrangian method for nonsmooth composite optimization&lt;/a&gt;, for instance). &lt;/li&gt;&#xA;&lt;li&gt;I could only find theoretical results about the convergence of the methods to the optimum point for the smooth case (for instance, in the book &lt;a href=&quot;https://epubs.siam.org/doi/book/10.1137/1.9781611973365&quot; rel=&quot;nofollow noreferrer&quot;&gt;Practical Augmented Lagrangian Methods for Constrained Optimization&lt;/a&gt;). &lt;/li&gt;&#xA;&lt;li&gt;I have found results for the unconstrained nonsmooth case with subgradients (Theorem 2.8 in &lt;a href=&quot;https://rd.springer.com/chapter/10.1007/978-3-642-82118-9_3&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Subgradient Method&lt;/a&gt;), but not yet for constrained problems. &lt;/li&gt;&#xA;&lt;li&gt;I can across strange results like in &lt;a href=&quot;http://www.math.uvic.ca/faculty/janeye/publications/papers/JOGO.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Smoothing augmented Lagrangian method for nonsmooth constrained optimization problems&lt;/a&gt; with convergence in the case the algorithm never stops… I'm not sure how this could be interesting for me. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Based on the structure of the problem and the KKT conditions, I can find a maximum value for the dual multiplier of the constraint, if this can be useful.&lt;/p&gt;&#xA;" OwnerUserId="156" LastEditorUserId="156" LastEditDate="2020-04-03T22:56:06.387" LastActivityDate="2020-04-03T23:42:32.117" Title="Nonsmooth constrained convex optimisation: convergence results?" Tags="|nonlinear-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3823" PostTypeId="1" AcceptedAnswerId="3824" CreationDate="2020-04-03T15:47:28.137" Score="7" ViewCount="460" Body="&lt;p&gt;If I obtain a relaxed version of my model using &lt;code&gt;r = model.relax()&lt;/code&gt; then add variables and constraints to the original model, will the relaxed version automatically update? Additionally, if I optimize the relaxed version, will this information be used to speed up the solution time of the original model?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, how tied together are the original and relaxed versions of the model?&lt;/p&gt;&#xA;" OwnerUserId="173" LastActivityDate="2020-04-03T16:16:36.017" Title="Updating a relaxed model in Gurobi" Tags="|gurobi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3824" PostTypeId="2" ParentId="3823" CreationDate="2020-04-03T16:16:36.017" Score="7" Body="&lt;p&gt;Calling &lt;code&gt;model.relax()&lt;/code&gt; creates a new Model instance that is not connected to the original model. If you call &lt;code&gt;relax()&lt;/code&gt; on a model that is already continuous, you would get end up with the same result as if you copied the model using &lt;code&gt;model.copy()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solving the original model does not benefit from solving the relaxed model before. You don't even apply the same presolving steps for continuous and integer models.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2020-04-03T16:16:36.017" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3825" PostTypeId="1" AcceptedAnswerId="3826" CreationDate="2020-04-03T19:55:23.653" Score="5" ViewCount="610" Body="&lt;p&gt;I am working on a problem in which I am trying to maximize the average of a variable only for the data that meet a certain condition with a constraint on the number of data that meet this condition. I am actually interested in constructing this condition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mathematically, my problem can be formulated as follows&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max &amp;amp;\quad \frac{\sum_{i}y_{i}w_{i}}{\sum_{i}w_{i}}\\\text{s.t.}&amp;amp;\quad\sum_{i}w_{i} = n\end{align}&lt;/span&gt;&#xA;where the &lt;span class=&quot;math-container&quot;&gt;$w_{i} = I(v_{i} \ge \sum_{j} x_{j} z_{ij})$&lt;/span&gt; represent the condition. I want to optimize with respect to the &lt;span class=&quot;math-container&quot;&gt;$x_{j}$&lt;/span&gt; variables. &lt;span class=&quot;math-container&quot;&gt;$v_{i}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_{i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; are available data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is then: is it possible to linearize this problem for solving as a linear program? If not, do you have any suggestion to tackle this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried actually adding the &lt;span class=&quot;math-container&quot;&gt;$w_{i}$&lt;/span&gt; as variables in the program with the constraint &lt;span class=&quot;math-container&quot;&gt;$$v_{i} - M \ge \sum_{j} x_{j} z_{ij} - Mw_{i}$$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; a value larger than the maximum of &lt;span class=&quot;math-container&quot;&gt;$v_{i}$&lt;/span&gt;. But it seems to result in a unbounded problem, although I am unsure why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also worth noting that the constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{i}w_{i} = n$&lt;/span&gt; could be relaxed as an inequality one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;" OwnerUserId="3283" LastEditorUserId="123" LastEditDate="2020-04-04T10:27:35.407" LastActivityDate="2020-04-04T21:02:28.353" Title="Linearizing objective function with variables inside an indicator function" Tags="|mixed-integer-programming|linearization|big-m|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3826" PostTypeId="2" ParentId="3825" CreationDate="2020-04-03T20:14:19.613" Score="7" Body="&lt;p&gt;The usual big-M approach would impose two sets of inequalities:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j x_j z_{i,j}-v_i &amp;amp;\le \left(\sum_j \overline{x}_j z_{i,j}-v_i\right)(1-w_i)\\&#xA;v_i+\epsilon-\sum_j x_j z_{i,j}&amp;amp;\le \left(v_i+\epsilon-\sum_j \underline{x}_j z_{i,j}\right)w_i&#xA;\end{align}&lt;/span&gt;&#xA;To linearize the objective function, replace the denominator with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-04-03T20:14:19.613" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3827" PostTypeId="2" ParentId="3822" CreationDate="2020-04-03T23:24:13.813" Score="3" Body="&lt;p&gt;This can be written as a Second Order Cone Problem (SOCP). Whatever you can say about SOCP in general, applies to this problem specifically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This approach formulates this as a standard SOCP. If it happens to have a large number of constraints, that's the way it is. However, note that it only has a number of SOC constraints equal to the dimension of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; (plus one for the objective). The &quot;combinatorial&quot; number of (sum) constraints are all linear (affine).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each &lt;span class=&quot;math-container&quot;&gt;$\frac{t_i}{x_i}$&lt;/span&gt; term can be replaced by &lt;span class=&quot;math-container&quot;&gt;$t_iz_i$&lt;/span&gt;, using a new variable, &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;, combined with the rotated SOC constraint, &lt;span class=&quot;math-container&quot;&gt;$$\|1\|^2_2 \le \ z_ix_i,  z_i\ge 0, x_i \ge 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a linear (in &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;) constraint on the sum for each T. That takes care of the max.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the objective, change that to u, and add the Second Order Cone Constraint &lt;span class=&quot;math-container&quot;&gt;$\|x-x_k\|_2 \le u$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use CVX (or similarly with CVXPY and other similar convex optimization tools), you can use inv_pos(x_i) and let CVX take care of that reformulation under the hood, as well as automatically reformulating the norm in the objective function into an SOCP constraint.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-04-03T23:42:32.117" LastActivityDate="2020-04-03T23:42:32.117" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3828" PostTypeId="1" CreationDate="2020-04-04T06:18:00.533" Score="14" ViewCount="282" Body="&lt;p&gt;As part of our department Ph.D. research methodology course, I'm going to give a short online lecture on how to review the literature effectively. As the course organizer asked us to focus on our own research experience, the focus of the talk is on OR-related studies (and logistics and SCM in particular). Also, the lecture is not targeted towards the proposal writing stage, but the whole Ph.D. research stages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I try to answer the following questions when reviewing the literature for a new project:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What is the research gap (based on the academic literature as well as the practitioner literature)?&lt;/li&gt;&#xA;&lt;li&gt;What are the most relevant studies to answer the research problem (and similar problems)?&lt;/li&gt;&#xA;&lt;li&gt;What is the best mathematical formulation for the basic version of the problem (in terms of the number of variables and constraint, LP relaxation quality, handling complex constraints, performance, etc.)?&lt;/li&gt;&#xA;&lt;li&gt;What is the state-of-the-art regarding the solution methods? &lt;/li&gt;&#xA;&lt;li&gt;Is there any problem instance widely used by the researchers? If yes, from where can I obtain them? If no, how are the random problem instances generated?&lt;/li&gt;&#xA;&lt;li&gt;What are the most important case studies on the research problem?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Are there any other questions that could be added to the list? I would also appreciate your own experience, tips, or any useful resource on the subject (either general or OR-related) and how to answer each question.&lt;/p&gt;&#xA;" OwnerUserId="119" LastEditorUserId="51" LastEditDate="2022-10-28T18:02:42.857" LastActivityDate="2022-10-28T18:02:42.857" Title="Tips on How to Review Operations Research Literature Effectively?" Tags="|reference-request|literature-research|teaching|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3829" PostTypeId="1" AcceptedAnswerId="3830" CreationDate="2020-04-04T16:09:48.430" Score="3" ViewCount="249" Body="&lt;p&gt;I have a convex objective function, e.g., minimizing the negative entropy function. My constraints are also linear. The only issue is that I also have binary variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently aware of AIMMS's outer approximation (AOA) that is said to be a good options. My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is such an outer approximation method using another solver to solve each relaxed problem? For example, if the variables were continuous, then minimizing the negative entropy function would be solved with MOSEK. Do you think solvers like AOA will still use MOSEK but will apply some sort of branch&amp;amp;bounding?&lt;/li&gt;&#xA;&lt;li&gt;What other options than AOA do I have? I prefer using MATLAB and YALMIP.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="65" LastActivityDate="2020-04-04T16:24:11.927" Title="Approximation methods for a mixed integer convex optimization problem" Tags="|solver|binary-variable|nonconvex-programming|convex-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3830" PostTypeId="2" ParentId="3829" CreationDate="2020-04-04T16:24:11.927" Score="6" Body="&lt;p&gt;Mosek 9.x can natively solve mixed-integer exponential cone problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Formulate the problem in YALMIP, specifying the binary variables as binvar, and Mosek as the solver. YALMIP will call Mosek to exploit its native  mixed-integer exponential cone capability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a mixed-integer example (mixture of binary and continuous):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = binvar(3,1); % binary&#xA;y = sdpvar(2,1); % continuous&#xA;optimize([A*[x;y] &amp;lt;= b,0 &amp;lt;= y &amp;lt;= 1],-entropy([x;y]),sdpsettings('solver','mosek'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-04-04T16:24:11.927" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3831" PostTypeId="2" ParentId="3825" CreationDate="2020-04-04T20:15:24.290" Score="3" Body="&lt;p&gt;Since Rob pointed out how to linearize the definition of the indicator variables, I'll focus on your objective, which is nonlinear. If you stick with the equality constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_i w_i =n$&lt;/span&gt;, you can just replace the denominator in the objective with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and the objective is linear. If, as is suggested in your question, you change the constraint to &lt;span class=&quot;math-container&quot;&gt;$\sum_i w_i \le n$&lt;/span&gt; (or &lt;span class=&quot;math-container&quot;&gt;$\sum_i w_i \ge n$&lt;/span&gt;), then the objective function becomes a sticking point. Depending on the size of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and the (unspecified) number of values of index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, your best bet might be to solve a sequence of problems where the &quot;budget&quot; constraint is &lt;span class=&quot;math-container&quot;&gt;$\sum_i w_i = k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is 1, then 2, ... then &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; (or counts down to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; in the &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; case).&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="500" LastEditDate="2020-04-04T21:02:28.353" LastActivityDate="2020-04-04T21:02:28.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3832" PostTypeId="2" ParentId="3828" CreationDate="2020-04-05T21:26:22.440" Score="7" Body="&lt;p&gt;Not a question, but switching to a reference management software has helped me a lot (Mendeley, in my case, but there are alternatives). In particular, the ability to tag papers with my own keywords, filter them based on my tags, and then sort them chronologically has helped me quickly get a better idea of the progress in specific areas of research. E.g. I can select all of my papers which have the tags “VRP” and “dynamic programming” together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it might be worth checking researchers’ websites (or arXiv/OO/SSRN) for preprints if they do a lot of work in the area of interest, since Google Scholar sometimes takes a little while to update. I’ve found a couple of relevant papers this way.&lt;/p&gt;&#xA;" OwnerUserId="196" LastActivityDate="2020-04-05T21:26:22.440" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3833" PostTypeId="1" CreationDate="2020-04-05T21:37:03.167" Score="4" ViewCount="178" Body="&lt;p&gt;In &lt;a href=&quot;https://or.stackexchange.com/questions/1099/how-to-innovate-in-or&quot;&gt;this post&lt;/a&gt;, Geoffrey De Smet and EhsanK pointed out the opportunities of VRP variants (e.g. mixed pick up and deliveries).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I want to build a &lt;a href=&quot;https://en.wikipedia.org/wiki/Minimum_viable_product&quot; rel=&quot;noreferrer&quot;&gt;Minimum Viable Product&lt;/a&gt; (software as a service app). My question is: Which variant to consider (which constraints and objective function)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The VRP has a lot of applications in different markets. My main concern is to cover as much &quot;markets&quot; as possible without falling in the trap of including a lot of details at the beginning. In other words, I want an incremental deployment approach rather than a &quot;big-bang&quot; approach. Thus I can implement a MVP, try to do some marketing/sales and then listen to customers to add further details. I don't want to spend a lot of time on something that will not make me money. &lt;/p&gt;&#xA;" OwnerUserId="1188" LastEditorUserId="1188" LastEditDate="2020-04-05T21:43:22.743" LastActivityDate="2020-04-07T14:43:10.637" Title="VRP app as a Minimum Viable Product" Tags="|vehicle-routing|applications|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3835" PostTypeId="1" AcceptedAnswerId="3836" CreationDate="2020-04-06T23:36:13.417" Score="5" ViewCount="150" Body="&lt;p&gt;I have three equations that are essentially the same equation defined for three time instants. The equations are basically calculating the state of energy of an energy storage facility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;e(t) &amp;amp;= e(0)-d(t)+\eta \cdot c(t);&amp;amp;&amp;amp;t=1\\&#xA;e(t) &amp;amp;= e(t-1)-d(t)+\eta\cdot c(t);&amp;amp;&amp;amp;1&amp;lt;t&amp;lt;T\\&#xA;e(t) &amp;amp;= 0.5\cdot E;&amp;amp;&amp;amp;t=T&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; are parameters; the rest are variables. The equations are defining the value for the same variable &lt;span class=&quot;math-container&quot;&gt;$e(t)$&lt;/span&gt;. My question is do I include a single variable to define the dual variables for all the equations or I need to define three separate variables with one for each equation. Therefore, if I were to write KKT conditions for the complete formulation, only one or three dual variables will show up.&lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="123" LastEditDate="2020-04-07T07:53:48.400" LastActivityDate="2020-04-07T07:53:48.400" Title="Dual variables associated with same equation for different time instants" Tags="|optimization|kkt-conditions|dual|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3836" PostTypeId="2" ParentId="3835" CreationDate="2020-04-07T02:25:14.250" Score="9" Body="&lt;p&gt;You do not have &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; constraints, you have &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; constraints. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if &lt;span class=&quot;math-container&quot;&gt;$T=5$&lt;/span&gt;, then we have &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}e(1)&amp;amp;=e(0)-d(1)+\eta\cdot  c(0)\tag{1}\\e(2)&amp;amp;=e(1)-d(2)+\eta\cdot  c(1)\tag{2}\\e(3)&amp;amp;=e(2)-d(3)+\eta\cdot  c(2)\tag{3}\\e(4)&amp;amp;=e(3)-d(4)+\eta\cdot  c(3)\tag{4}\\e(4)&amp;amp;=0.5\cdot E\tag{5}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might like to use the same symbol but index it with time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, for example introduce the dual variables &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; for the &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;-th constraint or introduce a vector &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{R}^{T}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="85" LastEditorUserId="123" LastEditDate="2020-04-07T07:53:09.503" LastActivityDate="2020-04-07T07:53:09.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3837" PostTypeId="2" ParentId="3644" CreationDate="2020-04-07T03:06:14.410" Score="3" Body="&lt;p&gt;My research group at MIT has collated a dataset of 130+ papers on COVID-19 clinical outcomes, where each paper contains aggregate demographic information/comorbidities/lab data/treatment/clinical outcomes on a group of patients &lt;a href=&quot;http://www.covidanalytics.io/dataset&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.covidanalytics.io/dataset&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since we ultimately want to make decisions to combat the spread of COVID, we're currently in the process of using this data and an epidemiological model predicting COVID's spread to define and solve some optimization problems; I'll update this answer with some more details once we finalize these models and make them public. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We'd love to hear if anyone has suggestions for other optimization problems we can solve with this data.&lt;/p&gt;&#xA;" OwnerUserId="43" LastActivityDate="2020-04-07T03:06:14.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3838" PostTypeId="1" CreationDate="2020-04-07T03:10:11.253" Score="4" ViewCount="315" Body="&lt;p&gt;According to my understanding, we should put a slack variable to equate an inequality constraint by inserting the slack variable in the side that is less than the other side. For example, if we have &lt;span class=&quot;math-container&quot;&gt;$4x+2&amp;lt;2$&lt;/span&gt; this will be &lt;span class=&quot;math-container&quot;&gt;$4x+2+\text{slack_variable}=2$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in the example section of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Slack_variable&quot; rel=&quot;noreferrer&quot;&gt;Slack Variable Wikipedia&lt;/a&gt;, it says the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;By introducing the slack variable &lt;span class=&quot;math-container&quot;&gt;$y\ge0$&lt;/span&gt;, the inequality &lt;span class=&quot;math-container&quot;&gt;$Ax\le b$&lt;/span&gt; can be converted to the equation &lt;span class=&quot;math-container&quot;&gt;$y-Ax+b = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which means that the slack variable is inserted on the bigger side! Please someone explain this confusion.&lt;/p&gt;&#xA;" OwnerUserId="3293" LastEditorUserId="36" LastEditDate="2020-04-07T03:58:44.197" LastActivityDate="2020-04-07T03:58:44.197" Title="Confused in how to insert a slack variable in a constraint inequality" Tags="|optimization|constraint|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3840" PostTypeId="1" AcceptedAnswerId="3847" CreationDate="2020-04-07T08:20:32.207" Score="4" ViewCount="435" Body="&lt;p&gt;I checked the Hessian which is &lt;span class=&quot;math-container&quot;&gt;$\begin{bmatrix}-2&amp;amp;0\\0&amp;amp;0\end{bmatrix}$&lt;/span&gt; which is negative semidefinite but according to the sketch of the function it is convex. What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="530" LastEditorUserId="123" LastEditDate="2020-04-07T10:31:43.287" LastActivityDate="2020-04-07T15:07:15.250" Title="How to check for convexity of the inequality constraint $−x^2+y−1\ge0$ for a minimization objective function?" Tags="|convex-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3841" PostTypeId="2" ParentId="3833" CreationDate="2020-04-07T12:13:19.657" Score="9" Body="&lt;p&gt;For what it's worth...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have an out-of-the-box open source &lt;a href=&quot;https://github.com/kiegroup/optaweb-vehicle-routing&quot; rel=&quot;noreferrer&quot;&gt;VRP application in Java&lt;/a&gt;, yet it always needs to be customized to meet a user's or customer's needs. Although many VRP variants can use the same model, many other variations don't fit the same model. For example, VRP with pickup and deliveries are fundamentally different from CVRP's (with or without timewindows). Just find your niche.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I once believed that if you build a great app, end users will automatically use it. That's naive. Sales/marketing are just as vital as having a great product. Basically, it's a multiplication. If either side is zero, the result is zero. However there's a lot of marketing that can be done without a budget.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's an annoying Catch 22 in this game: to build a product that can sell, there are 3 things you need to do: talk to users, talk to users and talk to users. But users won't talk to you if you can't show them a demo that looks like it will solve their problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't let that stop you though :) The road to success is paved with failures. Good luck!&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2020-04-07T12:13:19.657" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3842" PostTypeId="1" CreationDate="2020-04-07T12:28:45.537" Score="5" ViewCount="79" Body="&lt;p&gt;I am looking to optimize the blending of different types of coal for the coke making process of a steel plant. I want to take into account the statistical variation of each coal’s qualities, so for this reason I looked at a chance constrained model. I also want to have multiple objectives, one to minimize cost and another to maximize yield, and possibly a third to maximize coke quality. So I have thought about doing a chance constrained multiple objective model, but I am not very experienced in this area.&lt;/p&gt;&#xA;&lt;p&gt;Is there any advice or recommendations for literature to read about this problem?&lt;/p&gt;&#xA;" OwnerUserId="3295" LastEditorUserId="491" LastEditDate="2022-12-20T14:25:28.020" LastActivityDate="2022-12-20T14:25:28.020" Title="Best method to optimize the blending of different types of coal to ensure all quality parameters are met at the lowest possible price?" Tags="|optimization|stochastic-process|multi-objective-optimization|chance-constraints|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3843" PostTypeId="1" AcceptedAnswerId="3845" CreationDate="2020-04-07T13:42:55.730" Score="10" ViewCount="1180" Body="&lt;p&gt;I am attempting to solve a linear program via Dantzig-Wolfe decomposition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is the first time I implement this method. Before the pricing iterations start, I need to provide an initial set of columns to the Restricted Master Problem. I know I can probably just feed a number of random columns initially. However, is there a &lt;em&gt;smarter way&lt;/em&gt; of doing it?&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="1160" LastEditDate="2020-04-09T07:36:39.703" LastActivityDate="2020-04-09T07:36:39.703" Title="How can I initialize the Restricted Master Problem in Dantzig-Wolfe decomposition?" Tags="|dantzig-wolfe-decomposition|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3844" PostTypeId="2" ParentId="3843" CreationDate="2020-04-07T13:57:18.083" Score="5" Body="&lt;p&gt;One natural approach to generate initial columns is to solve each subproblem using the original cost (instead of reduced cost) as the objective.  This is equivalent to taking all master dual variables equal to 0.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-04-07T13:57:18.083" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3845" PostTypeId="2" ParentId="3843" CreationDate="2020-04-07T14:19:26.527" Score="10" Body="&lt;p&gt;As Rob said, one option is to initialize your CG with a set of columns coming from a feasible solution. The rationale behind is to start from a set of near-optimal (from a MP perspective!) columns. Assuming the dual bound you get from your CG is sufficiently tight, a set of columns coming from a near-optimal feasible solution to your problem should be sufficiently good for the MP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possibility is to add slack variables to all of your constraints, with very high cost coefficients, so your RMP is always feasible. Actually, adding such slack variables is even NECESSARY if you embed your CG within branch-and-price later on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is much more than just this (stabilization, cutting planes, DOIs, etc), but for a beginner these two observations should suffice to have a first implementation of CG.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for tutorials, you may first go and read &quot;A primer on column generation&quot; by J Desrosiers and M Lubbecke. &lt;a href=&quot;https://link.springer.com/book/10.1007/b135457&quot; rel=&quot;noreferrer&quot;&gt;The book containing it&lt;/a&gt; (Column generation, G Desaulniers, J Desrosiers and MM Solomon, Eds.) is a great source for beginners. If you are into CG for vehicle routing, there is a &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/trsc.2018.0878&quot; rel=&quot;noreferrer&quot;&gt;recent survey&lt;/a&gt; that we (L Costa, C Contardo and G Desaulniers) wrote in the spirit of make the life of students giving their first steps in CG for VRP less painful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best regards&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2020-04-07T15:57:09.170" LastActivityDate="2020-04-07T15:57:09.170" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3846" PostTypeId="2" ParentId="3833" CreationDate="2020-04-07T14:43:10.637" Score="6" Body="&lt;p&gt;I totally agree with what @Geoffrey De Smet and @Renaud M. said. I only add my two cents here so it hopefully helps you to think about what you're creating:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You know it already that it's best to start simple for an MVP and then add more features to it. Although I can suggest that the first pass can be CVRP with time windows, there is another important step before this and that's the market you like to target (no holy grail solution. Another MVP is the narrowing down the market IMO)! Think about it. The problem that UPS last-mile delivery needs to solve with tens or hundreds of stops in a day, can be very different from what a mover company does (e.g. think of those movers that drop their trailers for you to partially fill the truck and then they repeat this until the truck is full) or even what Uber eat does! You may put them all in the same category but the difference between the constraints and their planning horizon can totally change how you design your solution. So, first stop, what's the market?&lt;/li&gt;&#xA;&lt;li&gt;Now that you know the market, you see that your MVP is totally linked to that market and may no longer be CVRP. You may even realize that in some markets you always have Open VRP (your vehicle/salesman/driver doesn't need to return to the origin after ending service). That, again, changes the solution you design. So, we're back to &quot;what's the market?&quot;&lt;/li&gt;&#xA;&lt;li&gt;Since you know the market, one other obvious step is to search how the problems in that market are already solved and what your potential solution can offer that's not in the market. The worst-case scenario is to create something that will cost more and is less sophisticated than the current approach (sophisticated here means closer to the real-life constraints). This may be a step easier said than done. However, as you know there is a balance. You may offer something less sophisticated but much more user-friendly, faster, and cheaper and that can be a selling point. &lt;/li&gt;&#xA;&lt;li&gt;If not obvious, when you decide your market, you know the most common type of constraints in that market. But don't fall for some of the simplifying assumptions that you may find in some academic papers. There are pieces that you may not consider as a constraint up-front but they may consume a lot of time for you later. For example, &quot;let's assume that the cost to go from A to B depends on the distance...&quot;. Well, ok but are you sure you're solving a problem that this assumption is valid? If you deal with small vans and parcels, I'm afraid this assumption won't make your users very happy.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'll edit this if more comes to my mind. Good luck and I hope this helps you in your path!&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2020-04-07T14:43:10.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3847" PostTypeId="2" ParentId="3840" CreationDate="2020-04-07T15:07:15.250" Score="11" Body="&lt;p&gt;I think you are trying to use the following property:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\{x:g(x) \le 0\}$&lt;/span&gt; is convex if &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is convex. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note the direction of the inequality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\{(x,y): -x^2+y-1  \ge 0\}&amp;amp;=\{(x,y): -(-x^2+y-1 ) \le 0\} \\&#xA;&amp;amp;=\{(x,y): x^2-y+1  \le 0\} \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you compute the Hessian of &lt;span class=&quot;math-container&quot;&gt;$x^2-y+1$&lt;/span&gt;, you will obtain &lt;span class=&quot;math-container&quot;&gt;$\begin{bmatrix} 2 &amp;amp; 0 \\ 0 &amp;amp; 0\end{bmatrix} \succeq 0$&lt;/span&gt;, hence the corresponding region is a convex set.&lt;/p&gt;&#xA;" OwnerUserId="85" LastActivityDate="2020-04-07T15:07:15.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3848" PostTypeId="1" AcceptedAnswerId="3857" CreationDate="2020-04-07T15:18:39.740" Score="3" ViewCount="295" Body="&lt;p&gt;I am working on a chance-constrained optimisation model that takes into account uncertainty. I am aware of how to convert constraints that are of a probabilistic nature into the equivalent deterministic one, but only when the parameter follows a normal distribution. The majority of my constraints do follow a normal distribution, but I have a constraint that follows a gamma distribution with parameters &lt;span class=&quot;math-container&quot;&gt;$k = 3.11$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\theta = 9.86$&lt;/span&gt;. How would I then convert this to the equivalent deterministic form? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The formulation I used to convert the probabilistic constraints is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are three coal types, &lt;span class=&quot;math-container&quot;&gt;$i = 1,2,3$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each coal type's ash percentage, denoted by &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;, follows a normal distribution, &lt;span class=&quot;math-container&quot;&gt;$a_i \sim N(\mu_i,\sigma_{i}^2)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall i$&lt;/span&gt;. Each coal's ash percentage is independent. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The blend has a maximum allowable ash percentage of &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\alpha = 0.025$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; be the proportion of coal type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to be used in the blend.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;P\bigg\{\sum_{i=1}^{3} a_ix_i \leq 10\bigg\} \geq 1 -\alpha, \quad x_i \geq 0 \quad \forall i&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;P\Bigg\{\dfrac{\sum_{i=1}^{3} a_ix_i - \sum_{i=1}^{3} \mu_ix_i}{\sqrt{\sum_{i=1}^{3} \sigma_i^2x_i^2}} \leq \dfrac{10 - \sum_{i=1}^{3} \mu_ix_i}{\sqrt{\sum_{i=1}^{3} \sigma_i^2x_i^2}}\Bigg\} \geq 1 -\alpha&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$\quad$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\dfrac{\sum_{i=1}^{3} a_ix_i - \sum_{i=1}^{3} \mu_ix_i}{\sqrt{\sum_{i=1}^{3} \sigma_i^2x_i^2}}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\quad$&lt;/span&gt; represents the standard normal variant with mean &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and variance of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following inequality is then formed:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\phi\Bigg(\dfrac{10 - \sum_{i=1}^{3} \mu_ix_i}{\sqrt{\sum_{i=1}^{3} \sigma_i^2x_i^2}}\Bigg) \geq \phi(K_{1-a})&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$\phi(K_{1-a}) = 1 - \alpha$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\phi()$&lt;/span&gt; represents the standard normal cumulative distribution function. This gives the following deterministic constraint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i=1}^{3}\mu_ix_i + K_{1-\alpha}&#xA;*\sqrt{\sum_{i=1}^{3}\sigma_i^2x_i^2} \leq 10&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3295" LastEditorUserId="3295" LastEditDate="2020-04-09T15:05:36.143" LastActivityDate="2024-01-30T21:37:21.337" Title="How to convert non-normal probabilistic constraints to deterministic ones for mathematical modelling?" Tags="|optimization|modeling|constraint|constraint-programming|nonlinear-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3849" PostTypeId="2" ParentId="3843" CreationDate="2020-04-07T18:39:47.177" Score="10" Body="&lt;p&gt;Besides the options mentioned by Rob and Claudio, a third one is to use &lt;em&gt;Farkas Pricing&lt;/em&gt;. In this approach, which is based on &lt;a href=&quot;https://en.wikipedia.org/wiki/Farkas%27_lemma&quot; rel=&quot;noreferrer&quot;&gt;Farkas' Lemma&lt;/a&gt;, we do not include any initial columns or slack variables, but instead solve a sub-problem similar to the typical pricing problem. First, we retrieve Farkas duals from the master problem, which represent a proof of infeasibility (I believe most solvers have such a functionality). Then, we search for a column in the sub-problem that &quot;corrupts&quot; this proof of infeasibility. The sub-problem is the same as the regular pricing problem, except for a change in the objective. We add the column to the master and iterate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage of Farkas Pricing is that you do not need to worry about guaranteeing that your master problem will always be feasible using slack variables or initial columns. Especially if you apply branch-and-price, this can be cumbersome. For some more details, I refer to &lt;a href=&quot;http://www.zib.de/gamrath/publications/gamrath2010_genericBCP.pdf&quot; rel=&quot;noreferrer&quot;&gt;this thesis&lt;/a&gt; about the GCG solver.&lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2020-04-07T18:39:47.177" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3850" PostTypeId="1" AcceptedAnswerId="3851" CreationDate="2020-04-07T18:56:22.347" Score="4" ViewCount="129" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{m \times n}$&lt;/span&gt; is an arbitrary data matrix. Moreover, &lt;span class=&quot;math-container&quot;&gt;$w \in \mathbb{R}^m$&lt;/span&gt; is a data vector which is a probability vector, i.e., &lt;span class=&quot;math-container&quot;&gt;$w\succeq 0, \sum_{i=1}^m w_i = 1$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have  a symmetric matrix variable &lt;span class=&quot;math-container&quot;&gt;$V \in \mathbb{S}^{m \times m}$&lt;/span&gt; and I am solving:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;    \begin{array}{cll}&#xA;    \max \limits_{V \in \mathbb{S}^{n\times n}} &amp;amp;  \mathrm{tr}(A^\top V A) &amp;amp; \\&#xA;    \mathrm{s.t.}&amp;amp; \sum \limits_{j=1}^m V_{ij} = \sum\limits_{j=1}^m V_{ji} = w_i, &amp;amp; i=1,\ldots,m \\[0.2cm]&#xA;        &amp;amp; \sum\limits_{i=1}^m \sum\limits_{j=1}^m V_{ij} =1 &amp;amp;\\&#xA;&amp;amp; V_{i,j} \geq 0, &amp;amp; i=1,\ldots,m, j=1,\ldots,m.&#xA;    \end{array}&#xA;\end{align*}&lt;/span&gt;&#xA;So we can see that the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th row and column of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; should sum to &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; from the first constraint. The second constraint also implies that the elements of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; should sum to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. Last constraint says the elements of &lt;span class=&quot;math-container&quot;&gt;$V_{i,j}$&lt;/span&gt; are nonnegative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is, in my various numerical experiments, I always have &lt;span class=&quot;math-container&quot;&gt;$V = \mathrm{Diag}(w)$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is a diagonal matrix where &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th diagonal element is &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt;. Is this also observable from this maximization problem above (without any assumptions on &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MATLAB code to observe this with various data (thanks to the improvement of Mark L. Stone) is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n = 5;&#xA;m = 5;&#xA;A = rand(m,n)2; $generate whatever you like&#xA;w = [0.1;0.3;0.5;0.05; 0.05]; %sums to 1&#xA;V = sdpvar(m); %symmetric&#xA;Objective = trace(A'*V*A);&#xA;Constraints = [V(:) &amp;gt;= 0, sum(V(:)) == 1];&#xA;Constraints = [Constraints, sum(V,2)==w]; &#xA;soltn = optimize(Constraints, -Objective, sdpsettings('solver', 'cplex'))&#xA;V = value(V)&#xA;w = value(w)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My attempt:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\mathrm{tr}(A^\top V A) = \mathrm{tr}( (AA^\top) V) = \sum_{i=1}^m \sum_{j=1}^m (AA^\top)_{i,j}V_{i,j}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and if I can show that the coefficient of &lt;span class=&quot;math-container&quot;&gt;$V_{ii}$&lt;/span&gt; which is &lt;span class=&quot;math-container&quot;&gt;$(AA^\top)_{ii}$&lt;/span&gt; is larger than &lt;span class=&quot;math-container&quot;&gt;$(AA^\top)_{ij}$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; then I guess we are done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I proved it. It is a bit tedious, but I will type it soon.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2020-04-08T17:29:37.683" LastActivityDate="2020-04-08T17:29:37.683" Title="Analytically finding the maximizer of a trace optimization problem" Tags="|optimization|linear-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3851" PostTypeId="2" ParentId="3850" CreationDate="2020-04-08T00:47:19.343" Score="6" Body="&lt;p&gt;Consider a feasible matrix &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$V \neq \text{Diag}(w)$&lt;/span&gt;. Then there exist indices &lt;span class=&quot;math-container&quot;&gt;$i \neq j$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$V_{ij} = V_{ji} &amp;gt; 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now construct a new matrix &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; which is equal to &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;, except for the following four elements:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$W_{ij} = W_{ji} = 0$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$W_{ii} = V_{ii} + V_{ij}$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$W_{jj} = V_{jj} + V_{ij}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It is straightforward to verify that &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is feasible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By changing &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt;, the change in objective value is &lt;span class=&quot;math-container&quot;&gt;$$-2 (AA^\top)_{ij} + (AA^\top)_{ii} + (AA^\top)_{jj}.$$&lt;/span&gt; Because &lt;span class=&quot;math-container&quot;&gt;$AA^\top$&lt;/span&gt; is positive semi-definite, this value is non-negative, and the solution &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is not worse than &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;. By repeating this argument, it follows that &lt;span class=&quot;math-container&quot;&gt;$\text{Diag}(w)$&lt;/span&gt; is optimal.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2020-04-08T00:47:19.343" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3852" PostTypeId="1" AcceptedAnswerId="3859" CreationDate="2020-04-09T09:47:38.737" Score="8" ViewCount="224" Body="&lt;p&gt;Suppose you have a set of points &lt;span class=&quot;math-container&quot;&gt;$v_1,\ldots,v_n$&lt;/span&gt;, which are the vertices of the polytope &lt;span class=&quot;math-container&quot;&gt;$P=\operatorname{conv}\{v_1,\ldots,v_n\}$&lt;/span&gt; and a linear inequality &lt;span class=&quot;math-container&quot;&gt;$a^\top v \leq b$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be a linear program (or integer program if this is needed) that is feasible if and only if &lt;span class=&quot;math-container&quot;&gt;$a^\top v \leq b$&lt;/span&gt; is a facet of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="3305" LastEditDate="2020-04-09T11:36:46.010" LastActivityDate="2020-04-10T15:50:48.260" Title="Modeling Linear Program to decide if an inequality is facet" Tags="|optimization|mixed-integer-programming|linear-programming|modeling|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3854" PostTypeId="2" ParentId="3852" CreationDate="2020-04-09T13:24:19.900" Score="2" Body="&lt;p&gt;I doubt whether it is possible check whether an inequality is a facet using an (integer) linear program, because it requires counting the number of affinely independent points in some set. The reason why I suspect this cannot be done is that in the least you would need to be able to check whether a set of points &lt;span class=&quot;math-container&quot;&gt;$\{v_1,v_2,...,v_m\}$&lt;/span&gt; is linearly independent. To do so, you would need to check whether the equation &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_1v_1+x_2v_2+...+x_mv_m = \mathbf{0}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;has a non-trivial solution, which translates to &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}\neq 0$&lt;/span&gt;. Such &quot;not equal&quot; constraints cannot be expressed in integer linear programs. &lt;/p&gt;&#xA;" OwnerUserId="764" LastEditorUserId="764" LastEditDate="2020-04-09T15:07:45.940" LastActivityDate="2020-04-09T15:07:45.940" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3855" PostTypeId="1" AcceptedAnswerId="3864" CreationDate="2020-04-09T15:32:17.217" Score="6" ViewCount="631" Body="&lt;p&gt;I am currently trying to speed up an MIP. An approach I was considering was to implement a cut callback heuristic with PuLP (one which rounds relaxed integer variables greater than .9 to 1). Unfortunately, I do not believe PuLP has such a function to call, and I have looked into the mip module as well as dippy, but I don't feel like jumping to those. So, as a side note, if anyone knows how this can be done natively with PuLP let me know...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This leads me to my main question. Since PuLP is a wrapper and can be used with other solvers, I did see that Gurobi has such a function, and was able to call the code to Gurobi from PuLP with the code below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lp_prob = plp.LpProblem('Problem', plp.LpMinimize) &#xA;sd = plp.solvers.GUROBI(mip=True)&#xA;sd.actualSolve(Lp_prob, callback=mycallback)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the function I am trying to call: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def mycallback(model, where):&#xA;    model._vars = model.getVars()&#xA;    if where == GRB.Callback.MIPNODE:&#xA;        for x in model._vars:&#xA;            if model.cbGetNodeRel(x) &amp;gt; 0.9 and model.cbGetNodeRel(x) &amp;lt; 1.0:&#xA;                model.cbSetSolution(x, 1.0)&#xA;    else:&#xA;        return&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, after running a couple of times, the heuristic doesn't quite speed things up, in fact it kind of slows it down. I was wondering if this was implemented correctly, or if I were missing something. Any help or suggestions would be greatly appreciated. &lt;/p&gt;&#xA;" OwnerUserId="3309" LastActivityDate="2020-04-10T14:31:03.353" Title="Advanced Heuristics for MIP vehicle routing problem in PuLP" Tags="|mixed-integer-programming|python|gurobi|vehicle-routing|pulp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3856" PostTypeId="1" AcceptedAnswerId="3862" CreationDate="2020-04-09T15:56:51.393" Score="0" ViewCount="252" Body="&lt;p&gt;Hiring company has the following requirement within a year;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;week 1 to 5: 20&lt;/p&gt;&#xA;&#xA;&lt;p&gt;week 6 to 20: 40&lt;/p&gt;&#xA;&#xA;&lt;p&gt;week 21 to 40: 35&lt;/p&gt;&#xA;&#xA;&lt;p&gt;week 41 to 60: 55&lt;/p&gt;&#xA;&#xA;&lt;p&gt;week 61 to 80:75&lt;/p&gt;&#xA;&#xA;&lt;p&gt;week 81 to 100: 60&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Training time for an employee is 4 weeks and they are unproductive at times. &lt;/li&gt;&#xA;&lt;li&gt;An employee can work up to 20% overtime and 10% undertime in a week. &lt;/li&gt;&#xA;&lt;li&gt;Overtime cost is 1.5 times the regular cost. &lt;/li&gt;&#xA;&lt;li&gt;The regular cost is 10 per hour. &lt;/li&gt;&#xA;&lt;li&gt;The hiring cost is $2000 per employee. &lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In week 1, the company has 20 employees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1]: &lt;a href=&quot;https://i.stack.imgur.com/2rjJ1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/2rjJ1.png&lt;/a&gt;&lt;img src=&quot;https://i.stack.imgur.com/nTs8d.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2958" LastEditorUserId="2958" LastEditDate="2020-04-10T05:32:20.073" LastActivityDate="2020-10-22T02:35:45.510" Title="How to form math model to solve this problem using cplex" Tags="|mixed-integer-programming|linear-programming|cplex|inventory|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3857" PostTypeId="2" ParentId="3848" CreationDate="2020-04-09T16:53:23.310" Score="3" Body="&lt;p&gt;Your constraint says that the &lt;span class=&quot;math-container&quot;&gt;$(1-\alpha)$&lt;/span&gt;th fractile of the normal distribution must be &lt;span class=&quot;math-container&quot;&gt;$\le 10$&lt;/span&gt;. The particular normal distribution that you are bounding depends on the values of the decision variables. In general, the &lt;span class=&quot;math-container&quot;&gt;$(1-\alpha)$&lt;/span&gt;th fractile of a &lt;span class=&quot;math-container&quot;&gt;$N(\mu,\sigma^2)$&lt;/span&gt; distribution is &lt;span class=&quot;math-container&quot;&gt;$\mu + z_{1-\alpha}\sigma$&lt;/span&gt;, hence the particular form in your constraint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But any distribution has a &lt;span class=&quot;math-container&quot;&gt;$(1-\alpha)$&lt;/span&gt;th fractile. So your constraint just needs to say that the &lt;span class=&quot;math-container&quot;&gt;$(1-\alpha)$&lt;/span&gt;th fractile is &lt;span class=&quot;math-container&quot;&gt;$\le 10$&lt;/span&gt;. The fractile itself will depend on your distribution, as well as on the values of the decision variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that in general, the &lt;span class=&quot;math-container&quot;&gt;$(1-\alpha)$&lt;/span&gt;th fractile of a distribution is &lt;span class=&quot;math-container&quot;&gt;$F^{-1}(1-\alpha)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$F(\cdot)$&lt;/span&gt; is the cdf.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-04-09T16:53:23.310" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3859" PostTypeId="2" ParentId="3852" CreationDate="2020-04-10T06:13:03.147" Score="5" Body="&lt;p&gt;I will assume that &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; strictly contains the origin, if not we can simply translate all the vertices of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; appropriately. This is possible since one of the comments said that we can assume that &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is also full-dimensional. Consider the polar polytope of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; denoted by &lt;span class=&quot;math-container&quot;&gt;$P^0$&lt;/span&gt;, then &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;P^0 = \lbrace{ x \mid v_i^\top x \leq 1, \, \forall i = 1, 2 , \dotsc, n \rbrace}&#xA;\end{equation}&lt;/span&gt; &#xA;If my memory serves me correctly, there is a result concerning polar polyhedra that says that there is a 1:1 correspondence between facets of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and vertices of &lt;span class=&quot;math-container&quot;&gt;$P^0$&lt;/span&gt; (due to the lockdown I could not find a good reference to post here). &#xA;This means that it reduces to check whether the &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; in the inequality &lt;span class=&quot;math-container&quot;&gt;$a^\top v \leq b$&lt;/span&gt; in OP corresponds to a vertex of &lt;span class=&quot;math-container&quot;&gt;$P^0$&lt;/span&gt;. Of course, some scaling issues would need to be handled. If &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is a vertex, the also check whether &lt;span class=&quot;math-container&quot;&gt;$b = \underset{x \in P}{\text{max}} \,\, a^\top x$&lt;/span&gt;, otherwise the inequality does not touch &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you can refer to my earlier answer to a question (&lt;a href=&quot;https://or.stackexchange.com/questions/1342/quadratic-programming-using-cplex-how-to-check-whether-candidate-is-an-extreme/1347#1347&quot;&gt;Quadratic programming using CPLEX: how to check whether candidate is an extreme point?&lt;/a&gt;) on how to pose the problem of determining whether a given point is a vertex as a sequence of linear optimization problems. &lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2020-04-10T15:50:48.260" LastActivityDate="2020-04-10T15:50:48.260" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3860" PostTypeId="1" AcceptedAnswerId="3863" CreationDate="2020-04-10T06:58:31.117" Score="7" ViewCount="13010" Body="&lt;p&gt;There is a method of solving a minimization problem using the simplex method where you just need to multiply the objective function by -ve sign and then solve it using the simplex method. All you need to do is to multiply the max value found again by -ve sign to get the required max value of the original minimization problem. My question is there is any condition that must be satisfied on the constraints of the optimization problem to use this method?&lt;/p&gt;&#xA;" OwnerUserId="3293" LastEditorUserId="3293" LastEditDate="2020-04-10T07:41:33.773" LastActivityDate="2020-04-10T19:52:10.063" Title="Solving a minimization problem using a Simplex method" Tags="|linear-programming|simplex|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3861" PostTypeId="2" ParentId="3860" CreationDate="2020-04-10T09:36:27.487" Score="4" Body="&lt;p&gt;The only requirements for the constraints, that I am aware of, when using the simplex algorithm to solve a minimization (and maximization) problem is to include the slack and surplus variables where needed, and the decision variables have to be non-negative. Below is an example to illustrate how to formulate a problem to be solved using the simplex algorithm and how to include slack and surplus variables into your formulation. &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad z = 2x_1 - 3x_2\\\text{s.t.}&amp;amp;\quad x_1+x_2 \leq 4\\&amp;amp;\quad x_1-x_2 \geq 6\\&amp;amp;\quad x_1,x_2 \geq 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The optimal solution to this would be where &lt;span class=&quot;math-container&quot;&gt;$ z = 2x_1-3x_2$&lt;/span&gt; is the smallest, but equivalently it can be said that the optimal solution would be where &lt;span class=&quot;math-container&quot;&gt;$ -z = -2x_1+3x_2$&lt;/span&gt; is the largest. This is done as the simplex algorithm is used to solve maximization problems, and the formulation now becomes &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad-z = -2x_1 + 3x_2\\\text{s.t.}&amp;amp;\quad x_1+x_2 \leq 4\\&amp;amp;\quad x_1-x_2 \geq 6\\&amp;amp;\quad x_1,x_2 \geq 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We add a slack variable &lt;span class=&quot;math-container&quot;&gt;$s_1$&lt;/span&gt; to the first constraint, which now becomes &lt;span class=&quot;math-container&quot;&gt;$x_1 +x_2 +s_1 = 4$&lt;/span&gt;. Similarly for the second constraint, we add the surplus variable &lt;span class=&quot;math-container&quot;&gt;$s_2$&lt;/span&gt;, and the constraint now becomes &lt;span class=&quot;math-container&quot;&gt;$x_1-x_2 + s_2= 6$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The formulation, which is now in standard form to be solved using the simplex algorithm, is as follows: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad-z = -2x_1 + 3x_2\\\text{s.t.}&amp;amp;\quad x_1 +x_2 +s_1 = 4\\&amp;amp;\quad x_1-x_2 + s_2= 6\\&amp;amp;\quad x_1,x_2 \geq 0\\&amp;amp;\quad s_1,s_2 \geq 0.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3295" LastEditorUserId="123" LastEditDate="2020-04-10T12:32:07.610" LastActivityDate="2020-04-10T12:32:07.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3862" PostTypeId="2" ParentId="3856" CreationDate="2020-04-10T09:40:13.217" Score="6" Body="&lt;p&gt;In general it's good to write some equations before. But when you rely on an &lt;a href=&quot;https://www.linkedin.com/pulse/optimization-aka-prescriptive-analytics-should-we-write-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;algebraic  modeling language&lt;/a&gt; like OPL you may also directly try your ideas.&lt;/p&gt;&#xA;&lt;p&gt;Disclosure: I am the author of the linked article.&lt;/p&gt;&#xA;&lt;p&gt;Let me share a starting point with OPL CPLEX&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;execute&#xA;{&#xA;  cplex.optimalitytarget=3;&#xA;}&#xA;&#xA;range weeks=1..100;&#xA;&#xA;tuple need&#xA;{&#xA;  int startweek;&#xA;  int endweek;&#xA;  int quantity;&#xA;}&#xA;&#xA;{need} needs={&amp;lt;1,5,20&amp;gt;,&amp;lt;6,20,40&amp;gt;,&amp;lt;21,40,35&amp;gt;,&#xA;  &amp;lt;41,60,55&amp;gt;,&amp;lt;61,80,75&amp;gt;,&amp;lt;81,100,60&amp;gt;};&#xA;&#xA;int demand[w in weeks]=&#xA;  first({n | n in needs : n.startweek&amp;lt;=w &amp;amp;&amp;amp; w&amp;lt;=n.endweek}).quantity;&#xA;&#xA;int trainingTime=4;&#xA;float overtime=0.2;&#xA;float undertime=-0.1;&#xA;float overtimecost=1.5;&#xA;float cost=10;&#xA;float hiringcost=2000;&#xA;int startEmployees=20;&#xA;int nbhours=8;&#xA;&#xA;dvar int+ hire[weeks];&#xA;dvar int+ nbEmployees[weeks];&#xA;dvar float underover[weeks];&#xA;&#xA;dexpr float hiringCost=hiringcost*sum(w in weeks) hire[w];&#xA;dexpr float salaryCost=nbhours*cost*sum(w in weeks)nbEmployees[w];&#xA;dexpr float underovertimeCost=nbhours*cost*&#xA;  sum(w in weeks) (overtimecost*(underover[w]&amp;gt;=0)*underover[w]+&#xA;  (underover[w]&amp;lt;=0)*underover[w]);&#xA;&#xA;minimize hiringCost+salaryCost+underovertimeCost;&#xA;  &#xA;subject to&#xA;{&#xA;  // stating point&#xA;  forall(i in 1..trainingTime)nbEmployees[i]==startEmployees;&#xA;  &#xA;  // satisfy demand&#xA;  forall(w in weeks) &#xA;  {&#xA;    nbEmployees[w]+underover[w]&amp;gt;=demand[w];&#xA;    nbEmployees[w]+underover[w]&amp;lt;=demand[w];&#xA;  }  &#xA;  &#xA;  // undertime and overtime&#xA;  forall(w in weeks) &#xA;  {&#xA;    underover[w]&amp;lt;=overtime*nbEmployees[w];&#xA;    underover[w]&amp;gt;=undertime*nbEmployees[w];&#xA;  }&#xA;  &#xA;  // hiring employees&#xA;  forall(i in weeks:(i+trainingTime) in weeks ) &#xA;      nbEmployees[i+trainingTime]==nbEmployees[i+trainingTime-1]+hire[i];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastEditorUserId="491" LastEditDate="2020-10-22T02:35:45.510" LastActivityDate="2020-10-22T02:35:45.510" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3863" PostTypeId="2" ParentId="3860" CreationDate="2020-04-10T11:27:06.160" Score="16" Body="&lt;p&gt;It has nothing to do even with linear programming. It's a simple mathematical fact:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \left( f \left( x \right) \right) = - \max \left( -f \left( x \right) \right)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which still holds when you restrict the domain of the function by the constraints (actually to a convex polyhedron in case of LP).&lt;/p&gt;&#xA;" OwnerUserId="3314" LastEditorUserId="3314" LastEditDate="2020-04-10T19:52:10.063" LastActivityDate="2020-04-10T19:52:10.063" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3864" PostTypeId="2" ParentId="3855" CreationDate="2020-04-10T14:31:03.353" Score="3" Body="&lt;p&gt;It is difficult to tell from this information. You need the examine the logs of the solver if your primal bound (how good are the solutions) or dual bound (how good is the relaxation) is not moving as fast as you wish it would be. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would try to run this heuristic not at every node, but maybe at every 50 (the correct value of this needs to be benchmarked) or so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use something like this for it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if model.cbGet(GRB.Callback.MIP_NODCNT) % 50 == 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would also evaluate how good this heuristic is, by for example printing the objective value of the suggested solutions and seeing how often it is better than what gurobi found. If this is not often the case than you need to design probably a better heuristic. &lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2020-04-10T14:31:03.353" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3865" PostTypeId="1" AcceptedAnswerId="3892" CreationDate="2020-04-10T18:43:59.870" Score="8" ViewCount="241" Body="&lt;p&gt;I'm doing a Traveling Salesman Problem (TSP) homework for a &lt;a href=&quot;https://www.coursera.org/learn/discrete-optimization/&quot; rel=&quot;noreferrer&quot;&gt;coursera optimization course&lt;/a&gt;. My first attempt was a regular naive greedy approach, from each point, moving to the closest node (that hadn't yet been selected). The second algorithm I tried was heuristic search, as described by &lt;a href=&quot;http://www.andrew.cmu.edu/course/10-703/textbook/BartoSutton.pdf&quot; rel=&quot;noreferrer&quot;&gt;Sutton and Barto Sec 8.9&lt;/a&gt;. I build a planning tree to consider possible paths looking several steps forward, then choose the first step along the shortest potential path. Very surprisingly to me, this second approach does consistently worse than regular naive greedy. (In fact the second approach can be reduced to regular greedy, by running it with &lt;code&gt;--depth 1&lt;/code&gt; or &lt;code&gt;--breadth 1&lt;/code&gt;).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was sure at first this was due to a bug in my implementation, but after tons of time stepping through results, it seems not to be? e.g. It finds the global optimum on small enough problems it can plan through to the end, as expected. I also hired a tutor to re-implement heuristic search a different way(recursively), he got the same results (deeper planning worse than greedy, across a variety of tree depth/breadths and problems), which he also didn't understand. It seems obvious one should be able to contrive examples where the foresight performs worse than naive greedy, but I don't understand why it's so consistently doing worse, across different tree depths/breadths and across different problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One final note: I'm not asking how to get a better solution to the TSP. I have alternative approaches that do much better. What is bothering me is that I can't grok why this particular algorithm is consistently worse than naive greedy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is a reproducible example of my issue; my code, and a sample dataset, along with examples of running it from shell. Code below can be run with dataset provided below as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(tspenv) ~/.../tsp$ python solver.py data/tsp_51_1 --depth 8 --breadth 3&#xA;&#xA;565.68 0&#xA;0 33 22 1 25 20 37 21 43 29 42 11 40 19 7 35 23 34 24 41 3 45 28 2 47 26 6 36 12 30 18 16 44 15 38 50 39 49 17 32 48 5 10 9 27 46 8 4 13 14 31```&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as compared to e.g. much better solution (total distance 506 vs 565 above) for regular-greedy (no planning tree):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(tspenv) ~/.../tsp$ python solver.py data/tsp_51_1 --depth 1 --breadth 1&#xA;506.36 0&#xA;0 33 5 2 28 45 9 10 3 46 24 34 23 12 36 6 26 47 27 41 8 4 35 13 7 19 40 18 11 42 29 43 21 37 20 25 1 22 31 39 50 38 15 44 16 14 30 48 32 17 49&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;solver.py&lt;/code&gt; can also be run with &lt;code&gt;--debug&lt;/code&gt; CLI flag to pause (prompt for user to input 'Enter') after each next-node selection, and print out some helpful info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My program below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import argparse&#xA;from anytree import Node, RenderTree&#xA;import math&#xA;import numpy as np&#xA;import random&#xA;from sklearn.metrics import pairwise_distances&#xA;import subprocess&#xA;import sys&#xA;import pandas as pd&#xA;from pprint import PrettyPrinter&#xA;from tqdm import tqdm&#xA;&#xA;&#xA;def unique_l(l):&#xA;    return list(set(l))&#xA;&#xA;&#xA;def get_dist_matrix(input_data):&#xA;    &quot;&quot;&quot;input_data comes in as raw multiline text string&quot;&quot;&quot;&#xA;    lines = input_data.split('\n')&#xA;    xypairs = [i.split() for i in lines[1:-1]]  # first line is num-points, last line is blank&#xA;    dist_matrix = pairwise_distances(xypairs, metric='euclidean')&#xA;    return dist_matrix&#xA;&#xA;def get_closest_nodes(current_pt, dist_matrix, n, exclude=[], verbose=False):&#xA;    dist_to_alternatives = dist_matrix[current_pt].copy()&#xA;&#xA;    # don't consider as neighbors any points already visited&#xA;    dist_to_alternatives[unique_l(exclude + [current_pt])] = np.inf&#xA;    n_valid = min(n, np.isfinite(dist_to_alternatives).sum())&#xA;&#xA;    neighbors_idx = np.argpartition(dist_to_alternatives, n_valid)[:n_valid]  # argpartition like an argmin to return n smallest&#xA;    return neighbors_idx&#xA;&#xA;&#xA;def calc_tour_dist(tour_order, dist_matrix):&#xA;&#xA;    # dist-matrix entry between each consecutive pair of stops in tour_order.&#xA;    # (plus last-entry back to first)&#xA;    total_dist = sum([dist_matrix[i,j] for i,j in zip(tour_order[:-1], tour_order[1:])])&#xA;    total_dist += dist_matrix[tour_order[-1], tour_order[0]]&#xA;    return total_dist&#xA;&#xA;&#xA;def heuristic_search_salesman(distance_matrix, &#xA;                              startnode=0, &#xA;                              breadth=3, &#xA;                              depth=3, &#xA;                              verbose=False, &#xA;                              debug=False):&#xA;    ''' Build out a heuristic search tree considering possible paths forward. &#xA;        Take first step along shortest planned path.&#xA;        See for ref Sec 8.9 &quot;Reinforcement Learning,&quot; by Sutton and Barto: &#xA;        http://www.andrew.cmu.edu/course/10-703/textbook/BartoSutton.pdf&#xA;&#xA;        (Note: if depth or breadth is 1, this reduces to regular greedy search)&#xA;&#xA;    params&#xA;    ------&#xA;    distance_matrix: square matrix of distance from each point to each other point&#xA;    startnode:       node the TSP starts from &#xA;    breadth:         breadth of the search tree (how many next-steps considered from each step)&#xA;    depth:           depth of the search tree (how many steps forward to plan)&#xA;    '''&#xA;    print(f&quot;Starting Heuristic Search Salesman for depth={depth} &amp;amp; breadth={breadth}&quot;)&#xA;&#xA;    visit_order = [startnode]&#xA;    for i in tqdm(range(distance_matrix.shape[0]-1)):  # i is the tour position we're deciding now&#xA;        current_pt = visit_order[-1]&#xA;&#xA;        # From current point, create a tree gaming out paths moving forward&#xA;        root = Node(str(current_pt))&#xA;&#xA;        # first level of planning tree: candidates for next-move from current point&#xA;        candidates = get_closest_nodes(current_pt, distance_matrix, breadth, exclude=visit_order)&#xA;        nodes_by_tree_lvl = {k:[] for k in range(depth+1)}&#xA;        nodes_by_tree_lvl[0] = [Node(str(c), parent=root) for c in candidates]&#xA;&#xA;        # fill out rest of planning tree in a loop&#xA;        for level in range(1, depth):&#xA;            for candidate in nodes_by_tree_lvl[level-1]:&#xA;                candidate_ancestors = [int(a.name) for a in candidate.ancestors]&#xA;                exclude = unique_l(visit_order + candidate_ancestors)&#xA;                next_candidates = get_closest_nodes(int(candidate.name), distance_matrix, breadth, exclude=exclude)&#xA;                nodes_by_tree_lvl[level] = nodes_by_tree_lvl[level] + [Node(str(nc), parent=candidate) for nc in next_candidates]&#xA;&#xA;        # Now that the heuristic search tree is constructed, calculate full distance for each potential path,&#xA;        # next-step will be first-step along shortest planned path&#xA;        next_step = np.nan&#xA;        shortest_dist = np.inf&#xA;        for possible_path in root.leaves:&#xA;            nodes = [n.name for n in possible_path.ancestors] + [possible_path.name]&#xA;            dist = sum(distance_matrix[int(i),int(j)] for i,j in zip(nodes[0:-1],nodes[1:]))&#xA;&#xA;            # if nodes already visited + depth of planning tree extends to all nodes, need&#xA;            # to include distance back to start to complete circuit in path's planned dist&#xA;            if len(visit_order) + len(nodes)-1 == distance_matrix.shape[0]:&#xA;                distance_back_to_start = distance_matrix[startnode, int(nodes[-1])]&#xA;                dist = dist + distance_back_to_start&#xA;&#xA;            if verbose:&#xA;                print(f&quot;distance for {nodes} is {dist}&quot;)&#xA;            if dist &amp;lt; shortest_dist:&#xA;                shortest_dist = dist&#xA;                next_step = int(nodes[1])  # nodes[0] is current-point. so nodes[1] is next step&#xA;&#xA;        visit_order.append(next_step)&#xA;        if verbose:&#xA;            print(f&quot;{visit_order}, cumulative distance: {sum([distance_matrix[i,j] for i,j in zip(visit_order[:-1], visit_order[1:])])}&quot;)&#xA;        if debug:&#xA;            input(&quot;Press Enter to continue...&quot;)&#xA;&#xA;    return visit_order&#xA;&#xA;&#xA;def solve_it(input_data, &#xA;             depth=3, &#xA;             breadth=3, &#xA;             verbose=False, &#xA;             debug=False):&#xA;    &quot;&quot;&quot; Run python solver.py -h from shell for explanations of parameters &quot;&quot;&quot;&#xA;&#xA;    # Calculate distance matrix. Optionally save to csv disk for debugging&#xA;    distance_matrix = get_dist_matrix(input_data)&#xA;    if verbose ==1:&#xA;        print(&quot;Saving Distance-Matrix for distances among all nodes to each other to distance_matrix.csv\n&quot;)&#xA;        pd.DataFrame(distance_matrix, columns=[[str(i) for i in range(len(distance_matrix))]]).to_csv('distance_matrix.csv')&#xA;&#xA;    # Conduct heuristic search. Breadth or Depth of 1 reduces to regular greedy search&#xA;    start = 0&#xA;    tour = heuristic_search_salesman(distance_matrix, &#xA;                                     startnode=start, &#xA;                                     breadth=breadth,&#xA;                                     depth=depth, &#xA;                                     verbose=verbose,&#xA;                                     debug=debug)  &#xA;    tour_dist = calc_tour_dist(tour, distance_matrix)&#xA;&#xA;    # Format output as desired by course grader&#xA;    proved_opt=0&#xA;    output_data = f'{tour_dist:.2f} {proved_opt}\n'&#xA;    output_data += ' '.join(map(str, tour))&#xA;    return output_data&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    # CLI Argument Parser&#xA;    parser = argparse.ArgumentParser()&#xA;    parser.add_argument('datafile', type=str, help = &quot;path to data file. required&quot;)&#xA;    parser.add_argument('-d', '--depth', type=int, default='3', &#xA;                        help='Number of Levels to plan forward in heuristic search tree. 1 means regular greedy search')&#xA;    parser.add_argument('-b', '--breadth', type=int, default='3', &#xA;                        help='Number of closest nodes to consider at each level of the heuristic search tree')&#xA;    parser.add_argument('-v', '--verbose', action=&quot;store_true&quot;, help=&quot;Show extra print statements&quot;)&#xA;    parser.add_argument('--debug', action=&quot;store_true&quot;, &#xA;                        help=&quot;Pause execution until keypress after each next-step selection. Sets verbose to True as well&quot;)&#xA;&#xA;    # Parse CLI args and call solver &#xA;    args = parser.parse_args()&#xA;&#xA;    with open(args.datafile, 'r') as input_data_file:&#xA;        input_data = input_data_file.read()&#xA;&#xA;    print(solve_it(input_data,  &#xA;                  depth=args.depth, &#xA;                  breadth=args.breadth,&#xA;                  verbose=max(args.verbose,args.debug),  # no point calling debug w/o verbose&#xA;                  debug=args.debug))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sample Dataset:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;51&#xA;27 68&#xA;30 48&#xA;43 67&#xA;58 48&#xA;58 27&#xA;37 69&#xA;38 46&#xA;46 10&#xA;61 33&#xA;62 63&#xA;63 69&#xA;32 22&#xA;45 35&#xA;59 15&#xA;5 6&#xA;10 17&#xA;21 10&#xA;5 64&#xA;30 15&#xA;39 10&#xA;32 39&#xA;25 32&#xA;25 55&#xA;48 28&#xA;56 37&#xA;30 40&#xA;37 52&#xA;49 49&#xA;52 64&#xA;20 26&#xA;40 30&#xA;21 47&#xA;17 63&#xA;31 62&#xA;52 33&#xA;51 21&#xA;42 41&#xA;31 32&#xA;5 25&#xA;12 42&#xA;36 16&#xA;52 41&#xA;27 23&#xA;17 33&#xA;13 13&#xA;57 58&#xA;62 42&#xA;42 57&#xA;16 57&#xA;8 52&#xA;7 38&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2806" LastEditorUserId="2806" LastEditDate="2020-04-10T20:48:24.480" LastActivityDate="2020-04-15T18:05:32.170" Title="Heuristic Search Planning Tree Leading to Worse TSP Solutions than Naive Greedy" Tags="|optimization|python|combinatorial-optimization|traveling-salesman|heuristics|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3866" PostTypeId="1" AcceptedAnswerId="3868" CreationDate="2020-04-11T16:10:57.657" Score="2" ViewCount="192" Body="&lt;p&gt;How to write the following constraint in cplex? &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;the cost for full truck load is $700    &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and the cost of fractional truck load is \$800 *fraction up to $700 &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2958" LastEditorUserId="123" LastEditDate="2020-04-11T18:59:03.410" LastActivityDate="2020-04-11T18:59:03.410" Title="How to formulate logical or constraint in cplex?" Tags="|mixed-integer-programming|linear-programming|cplex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3867" PostTypeId="1" CreationDate="2020-04-11T16:31:04.903" Score="4" ViewCount="77" Body="&lt;p&gt;The following relationship is part of my optimization model (&lt;span class=&quot;math-container&quot;&gt;$W_k$&lt;/span&gt; denotes a binary variable)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$W_{1} \le \cdots \le W_{k-1} \le  W_{k}  \le W_{k+1} \le \cdots \le W_{k^{\max}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, do I win anything from adding to the model the following, redundant, constraint? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$W_{k-2} \le W_{k-1} - W_{k} + 1.0$$&lt;/span&gt;   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This constraint says that if &lt;span class=&quot;math-container&quot;&gt;$W_k = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$W_{k-1} = 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$W_{k-2} = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2020-04-11T18:58:22.127" LastActivityDate="2020-04-11T18:58:22.127" Title="Adding redundant inequality to a model" Tags="|mixed-integer-programming|modeling|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3868" PostTypeId="2" ParentId="3866" CreationDate="2020-04-11T17:04:38.877" Score="5" Body="&lt;pre&gt;&lt;code&gt;//the cost for full truck load is &lt;span class=&quot;math-container&quot;&gt;$700&#xA;    // the cost of fractional truck load is $&lt;/span&gt;800 *fraction up to 700&#xA;&#xA;float truckCost=700;&#xA;float truckPartialCost=800;&#xA;&#xA;range r=1..3;&#xA;&#xA;float values[r]=[5,6.5,6.9];&#xA;dvar float nbTruck[r];&#xA;dvar float cost[r];&#xA;&#xA;// computation&#xA;dvar int intNbTruck[r];&#xA;dvar float floatNbTruck[r] in 0..0.99;&#xA;&#xA;subject to&#xA;{&#xA;  forall(i in r) &#xA;  {&#xA;    nbTruck[i]==values[i];&#xA;    nbTruck[i]==intNbTruck[i]+floatNbTruck[i];&#xA;    cost[i]==intNbTruck[i]*truckCost+minl(truckCost,floatNbTruck[i]*truckPartialCost);&#xA;  }&#xA;}&#xA;&#xA;execute&#xA;{&#xA;  writeln(cost);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[3500 4600 4900]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nb: Some more info &lt;a href=&quot;https://www.linkedin.com/pulse/how-opl-alex-fleischer/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-04-11T17:04:38.877" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3869" PostTypeId="1" AcceptedAnswerId="3870" CreationDate="2020-04-11T18:26:26.320" Score="5" ViewCount="688" Body="&lt;p&gt;I find it hard to form math models for real life operations research problems, how can I learn this? Any books, tutorials available?&lt;/p&gt;&#xA;" OwnerUserId="2958" LastEditorUserId="123" LastEditDate="2020-04-11T19:00:00.387" LastActivityDate="2021-08-09T00:27:14.077" Title="Where can I find resources to learn mathematical modelling for real life operation research problems like combinatorial optimization?" Tags="|mixed-integer-programming|linear-programming|cplex|combinatorial-optimization|books|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3870" PostTypeId="2" ParentId="3869" CreationDate="2020-04-11T20:55:34.017" Score="15" Body="&lt;p&gt;you may get many different answers but the one I have used for 20+ years is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Model Building in Mathematical Programming&lt;/strong&gt; by H.P.Williams&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many models are in the OPL CPLEX examples and some other &lt;a href=&quot;https://www.linkedin.com/pulse/model-building-oplcplex-alex-fleischer/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-04-11T20:55:34.017" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3871" PostTypeId="1" AcceptedAnswerId="3872" CreationDate="2020-04-11T22:27:58.810" Score="3" ViewCount="494" Body="&lt;p&gt;I would like to know how if condition statements in linear programming can be reformulated using indicator constraints, and hence solved as a mixed integer linear program. Specifically:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. Is it possible to formulate the problem below using indicators constraints, without using big-M? If so, how? I know that some solvers do it automatically but I am interested in doing it manually&lt;/strong&gt;&lt;br&gt;&#xA; &lt;strong&gt;2. How to formulate it using big-M?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume that the problem is given by:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/DpYDk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DpYDk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a more detailed example, assume that you have certain obligation at times 1, 2 and 3. You have 10 assets. First you want to see if you can meet the obligations by the first 5 assets before considering the remaining 5. The objective is to find the minimum amount of asset that you can invest in to meet the obligations.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Wf5cS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wf5cS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SUbZq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SUbZq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;  &lt;/p&gt;&#xA;" OwnerUserId="3217" LastEditorUserId="3217" LastEditDate="2020-04-12T14:55:23.970" LastActivityDate="2020-04-12T14:55:23.970" Title="Mocking up conditional statements in LP" Tags="|mixed-integer-programming|integer-programming|linearization|big-m|indicator-constraints|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3872" PostTypeId="2" ParentId="3871" CreationDate="2020-04-12T00:18:21.827" Score="3" Body="&lt;p&gt;It sounds like you want to enforce the following logical proposition:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\bigvee_{i=6}^{10} (x_i&amp;gt;0) \implies \bigwedge_{j=1}^{5} (x_j=1)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can model this by introducing a binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_i &amp;amp;\le y&amp;amp;&amp;amp;\text{for $i\in\{6,\dots,10\}$}\\&#xA;y&amp;amp;\le x_j &amp;amp;&amp;amp;\text{for $j\in\{1,\dots,5\}$}\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-04-12T01:43:10.553" LastActivityDate="2020-04-12T01:43:10.553" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3873" PostTypeId="2" ParentId="3871" CreationDate="2020-04-12T00:35:14.413" Score="3" Body="&lt;p&gt;The answer to the first part is yes, provided that you are using a solver that supports indicator constraints. As far as I know, there is no &quot;standard&quot; notation for it. Something like &lt;span class=&quot;math-container&quot;&gt;$$a_1 x_1 \le b \implies x_2 = 0$$&lt;/span&gt;would seem reasonable to me. The &quot;else&quot; part is tricky, since it deals with the case &lt;span class=&quot;math-container&quot;&gt;$a_1 x_1 &amp;gt; b$&lt;/span&gt; and strict inequalities are a no-no. You could approximate it by &lt;span class=&quot;math-container&quot;&gt;$$a_1 x_1 \ge b + \epsilon \implies x_1 = (1,\dots,1)^\prime$$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; is some small tolerance value. Note that this would make any solution with &lt;span class=&quot;math-container&quot;&gt;$b &amp;lt; a_1 x_1 &amp;lt; b + \epsilon$&lt;/span&gt; infeasible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A big-M formulation for the simplified version might look like the following, where &lt;span class=&quot;math-container&quot;&gt;$y\in\lbrace 0, 1\rbrace$&lt;/span&gt; is a new binary variable, &lt;span class=&quot;math-container&quot;&gt;$M_1$&lt;/span&gt; is a valid upper bound on &lt;span class=&quot;math-container&quot;&gt;$a_1x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_2$&lt;/span&gt; is a valid upper bound on &lt;span class=&quot;math-container&quot;&gt;$b+\epsilon - a_1x_1$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation*}&#xA;a_1 x_1 + a_2 x_2 \le b \\&#xA;a_1 x_1 \le b + M_1y \\&#xA;a_1 x_1 \ge b + \epsilon - M_2(1-y) \\&#xA;x_2 \le y \\&#xA;x_1 \ge y \\&#xA;0 \le x_1, x_2 \le 1.&#xA;\end{equation*}&lt;/span&gt;&#xA;There is one important catch here. This only works if &lt;span class=&quot;math-container&quot;&gt;$a_1 \ge b+\epsilon$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-04-12T00:35:14.413" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3874" PostTypeId="2" ParentId="506" CreationDate="2020-04-13T07:03:31.133" Score="8" Body="&lt;p&gt;A very interesting paper entitled: &lt;em&gt;Analysis of flow shop scheduling anomalies&lt;/em&gt; has been recently published by &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0377221719305363?casa_token=arosgkJc1J8AAAAA:jSJ_MyyyGR-N0ohgy6c5VUHK0CVZkYDPNJo8PmIs5oxGslUyyI1yPfnTcOFimgNIxQiM91eGWdI&quot; rel=&quot;noreferrer&quot;&gt;Panwalkar &amp;amp; Koulamas (2020)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;, that introduces the following anomalies:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1-&lt;/strong&gt; Type 1 Anomaly: An increase of the processing time of a single operation in an optimal schedule causes a reduction in the optimal objective function value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2-&lt;/strong&gt; Type 2 Anomaly: Adding a job causes a reduction in the optimal objective function value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3-&lt;/strong&gt; Type 3 Anomaly: Adding a machine with positive processing time for at least one job causes a reduction in the optimal objective function value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The authors discuss those anomalies in certain variants of the flow shop scheduling problem, and give insightful results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References: &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Panwalkar, S. S., and Christos Koulamas. &quot;Analysis of flow shop scheduling anomalies.&quot; &lt;em&gt;European Journal of Operational Research&lt;/em&gt; 280.1 (2020): 25-33. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-04-13T10:06:49.180" LastActivityDate="2020-04-13T10:06:49.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3875" PostTypeId="1" AcceptedAnswerId="3909" CreationDate="2020-04-13T20:37:40.967" Score="7" ViewCount="324" Body="&lt;p&gt;When using a generic callback in the &amp;quot;relaxation&amp;quot; context, it is fairly clear how to get values of the primal variables in the LP relaxation (along with a bunch of other stuff), but I can't seem to find a mechanism (at least in the Java API) for getting the values of the dual variables in the LP relaxation. If we need duals for node LPs, do we have to go back to legacy callbacks?&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="491" LastEditDate="2022-02-08T05:58:41.857" LastActivityDate="2022-02-08T05:58:41.857" Title="Duals in CPLEX generic callback" Tags="|cplex|callback|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3876" PostTypeId="1" CreationDate="2020-04-14T00:40:24.627" Score="3" ViewCount="371" Body="&lt;p&gt;The exercise is as follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ACI has decided to put an order for golf shoes twice every year and&#xA;  expects to receive one shipment of &lt;span class=&quot;math-container&quot;&gt;$960$&lt;/span&gt; pallets of shoes by the&#xA;  beginning of January and another shipment of &lt;span class=&quot;math-container&quot;&gt;$1250$&lt;/span&gt; pallets of shoes&#xA;  by July. Each pallet contains &lt;span class=&quot;math-container&quot;&gt;$20$&lt;/span&gt; cartons of shoes. Upon arrival to&#xA;  Canada, CBSA takes custody of the shoes. The company should decide how&#xA;  many cartons of shoes to release each month from Customs to supply all&#xA;  their demand while maintaining the lowest cost. For the amount of&#xA;  shoes that are released from Customs, the company needs to pay their&#xA;  duty cost. Because of the time value of money, it costs the company&#xA;  more to clear the shoes sooner than it does to release them later. So,&#xA;  the company might decide to delay releasing some of the shoes by a few&#xA;  months. All the shoes however should be released by the end of&#xA;  December. If we consider the value of shoes, the &lt;span class=&quot;math-container&quot;&gt;$19$&lt;/span&gt; percent duty&#xA;  cost and the company’s goal to return &lt;span class=&quot;math-container&quot;&gt;$13$&lt;/span&gt; percent on their&#xA;  investment, the cost of releasing one carton in each month along with&#xA;  the expected amount of demand for each month is listed in the table.&#xA;  Note that the duty cost and the return rate are already considered and&#xA;  you do not need to account for them. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The company can choose to delay releasing some of the shoes and keep&#xA;  them in the CBSA storage facilities. In this case, the company will&#xA;  not have to pay duty until the time the shoes are released but will&#xA;  have to pay &lt;span class=&quot;math-container&quot;&gt;$\$0.36$&lt;/span&gt; per month for each carton that is being held in&#xA;  the storage facilities. Formulate a linear programming model for the&#xA;  problem that minimizes the company’s overall cost. Define the three&#xA;  linear programming elements of the model and write down the&#xA;  formulation.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;(a) Write the model in Excel using color-coded and clearly-defined&#xA;  cells, then solve the model using Excel solver. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;(b) Observe the solutions, and very briefly describe your observations.&#xA;  This can include a brief description of what the company should do in&#xA;  plain words. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;(c) Now, assume that CBSA storage facilities will not store more than&#xA;  &lt;span class=&quot;math-container&quot;&gt;$4000$&lt;/span&gt; cartons at a time. The company however, has an internal storage&#xA;  capacity that can store the rest of the shoes that are not sold and&#xA;  are already released from Customs. There is a &lt;span class=&quot;math-container&quot;&gt;$\$0.1$&lt;/span&gt; cost for storing&#xA;  one carton of  shoes for one month internally.  Note that in order for&#xA;  the company to store the shoes in the internal storage facilities, the&#xA;  shoes must have been released (i.e. the duty cost must have been&#xA;  paid). Write a linear programming model for this problem. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;(d) Write the model described in (c) in Excel and use Excel Solver to&#xA;  solve it. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;(e) Describe your observations from the solutions.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4oo4Z.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4oo4Z.png&quot; alt=&quot;demand + duty costs by month&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I am having explicit trouble with my solution for (d) as well as suspicions about my solution for part (a). Here's what I did:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_i = $&lt;/span&gt; the number of cartons of shoes released in month &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (month &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; is January, month &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; is February, etc.). Then the constraints on my objective functions are as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\cdot \ x_1 + x_2 + x_3 + x_4 + x_5 + x_6 \leq 19200$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\cdot \ x_1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7 + x_8 + x_9 + x_{10} + x_{11} + x_{12} = 19200 + 25000 = 44200 $&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\cdot \ x_1 \geq 7000, \ x_2 \geq 6600, \ x_3 \geq 2800, \ x_4 \geq 1200, \ x_5 \geq 0, \ x_6 \geq 1600, \ x_7 \geq 2800, \ x_8 \geq 4000, \ x_9 \geq 4400, \ x_{10} \geq 4400, \ x_{11} \geq 4600, \ x_{12} \geq 4800$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\cdot \ x_i \in \mathbb{N_0}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Letting &lt;span class=&quot;math-container&quot;&gt;$Z =$&lt;/span&gt; total cost:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Z = 1824x_1 + 1787.52x_2 + 1751.77x_3 + 1716.73x_4 + 1682.4x_5 + 1648.75x_6 + 1824x_7 + 1787.52x_8 + 1751.7696x_9 + 1716.73421x_{10} + 1682.39952x_{11} + 1648.75153x_{12} + (19200-x_1)(.36) + (19200 - (x_1 + x_2))(.36) + \cdot \cdot \cdot + (19200 - (x_1 + x_2 + x_3 + x_4 + x_5 + x_6))(.36) + (44200 - (x_1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7))(.36) + \cdot \cdot \cdot + (44200 - \left(\sum_{i=1}^{12}x_i\right))(.36) \\&#xA;= 1824x_1 + 1787.52x_2 + 1751.77x_3 + 1716.73x_4 + 1682.4x_5 + 1648.75x_6 + 1824x_7 + 1787.52x_8 + 1751.7696x_9 + 1716.73421x_{10} + 1682.39952x_{11} + 1648.75153x_{12} + .36((12*19200 + 6*25000) - (12x_1 + 11x_2 + 10x_3 + 9x_4 + 8x_5 + 7x_6 + 6x_7 + 5x_8 + 4x_9 + 3x_{10} + 2x_{11} + x_{12}))$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My objective is to minimize &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;. I will do this using a linear program solver in Microsoft Excel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ynthw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ynthw.png&quot; alt=&quot;part a w/ formulas&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jV4st.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jV4st.png&quot; alt=&quot;part a solver&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/egb2v.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/egb2v.png&quot; alt=&quot;part a solved&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I am suspicious of this solution is that it seems trivial. It's not unbelievable, but it does seem slightly odd that this would be the answer. But okay, on to part (c).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The new constraints on our model are as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\cdot \ 19200 - x_1 \leq 4000$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\cdot \ 44200 - \sum_{i=1}^7x_i \leq 4000$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe these are sufficient to represent the new scenario, because if we don't have overflow in the CBSA storage in January and July, then we won't have overflow at any other time because those are the only times we have new supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$d_i =$&lt;/span&gt; demand in month &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$Y =$&lt;/span&gt; the new cost. Then&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Y = Z + .1(x_1 - d_1) + .1(x_1 + x_2 - (d_1 + d_2)) + ... + .1(\sum_{i=1}^{12}x_i - \sum_{i=1}^{12}d_i)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$= 1824x_1 + 1787.52x_2 + 1751.77x_3 + 1716.73x_4 + 1682.4x_5 + 1648.75x_6 + 1824x_7 + 1787.52x_8 + 1751.7696x_9 + 1716.73421x_{10} + 1682.39952x_{11} + 1648.75153x_{12} + .36((12*19200 + 6*25000) - (12x_1 + 11x_2 + 10x_3 + 9x_4 + 8x_5 + 7x_6 + 6x_7 + 5x_8 + 4x_9 + 3x_{10} + 2x_{11} + x_{12})) + .1(12(x_1 - 7000) + 11(x_2 - 6600) + 10(x_3 - 2800) + 9(x_4 - 1200) +8x_5 + 7(x_6 - 1600) + 6(x_7 - 2800) + 5(x_8 - 4000) + 4(x_9 - 4400) + 3(x_{10} - 4400) + 2(x_{11} - 4600) + (x_{12} - 4800))$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZQzsO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZQzsO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/X1XVm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/X1XVm.png&quot; alt=&quot;![enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally, here is where I have an error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7m4qf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7m4qf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I suppose I must have made an error somewhere. I cannot find it. I know the problem is extremely long - I guess that's the nature of these linear programming problems - so I thank you infinitely for the help.&lt;/p&gt;&#xA;" OwnerUserId="3333" LastEditorUserId="3333" LastEditDate="2020-04-14T01:01:16.693" LastActivityDate="2020-04-14T20:28:49.737" Title="Problem solving a linear program using Excel" Tags="|linear-programming|solver|integer-programming|excel|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="3877" PostTypeId="1" AcceptedAnswerId="3882" CreationDate="2020-04-14T08:14:10.137" Score="4" ViewCount="222" Body="&lt;p&gt;I have four binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{h}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{h'}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_h$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{h'}$&lt;/span&gt;. I need to have the following relationships satisfied between the variables:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;1- If &lt;span class=&quot;math-container&quot;&gt;$y_h = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{h'} = 1$&lt;/span&gt;, then exactly one of &lt;span class=&quot;math-container&quot;&gt;$x_h$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{h'}$&lt;/span&gt; should be equal to 1 (&lt;span class=&quot;math-container&quot;&gt;$y_h + y_{h'} = 2 \implies x_h + x_{h'} = 1$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;2- If exactly one of &lt;span class=&quot;math-container&quot;&gt;$y_h$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{h'}$&lt;/span&gt; is equal to 1, then both &lt;span class=&quot;math-container&quot;&gt;$x_h$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{h'}$&lt;/span&gt; should be equal to 0 (&lt;span class=&quot;math-container&quot;&gt;$y_h + y_{h'} = 1 \implies x_h + x_{h'} = 0$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;3- If both &lt;span class=&quot;math-container&quot;&gt;$y_h$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{h'}$&lt;/span&gt; are equal to 0, again both &lt;span class=&quot;math-container&quot;&gt;$x_h$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{h'}$&lt;/span&gt; should be equal to 0 (&lt;span class=&quot;math-container&quot;&gt;$y_h + y_{h'} = 0 \implies x_h + x_{h'} = 0$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I was thinking of a constraint like &lt;span class=&quot;math-container&quot;&gt;$$y_h + y_{h'} = 2 (x_h + x_{h'}),$$&lt;/span&gt;&#xA;however, it only considers relations 1 and 3.&lt;/p&gt;&#xA;&lt;p&gt;How can I formulate this?&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-04-15T13:05:44.620" Title="Formulate relationship between four binary variables" Tags="|mixed-integer-programming|modeling|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3878" PostTypeId="2" ParentId="3877" CreationDate="2020-04-14T09:10:42.413" Score="2" Body="&lt;p&gt;Oh, I got the solution!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I add the constraint &lt;span class=&quot;math-container&quot;&gt;$$y_h + y_{h'} = x_h + x_{h'} + 1 - z.$$&lt;/span&gt;&#xA;Now, I should enforce &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to be 1 if &lt;span class=&quot;math-container&quot;&gt;$y_h + y_{h'} = 0$&lt;/span&gt;, and 0 otherwise. For that I add:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y_h + y_{h'} \leq M(1 - z),$$&lt;/span&gt;&#xA;where M is a sufficiently large number (I think 2 is enough!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't remove the question since it may help someone sometime!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;BTW, is there a better way to do this, possibly in a single constraint?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-04-14T09:28:46.550" LastActivityDate="2020-04-14T09:28:46.550" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3879" PostTypeId="2" ParentId="3877" CreationDate="2020-04-14T09:34:54.893" Score="3" Body="&lt;p&gt;How about:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_h + x_{h'} = y_h \times y_{h'},$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it is not linear anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As suggested by &lt;a href=&quot;https://or.stackexchange.com/users/123/thesimplifire&quot;&gt;TheSimpliFire&lt;/a&gt; (in a comment to my answer), you can refer to &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;How to linearize the product of two binary variables?&lt;/a&gt; to linearize it.&lt;/p&gt;&#xA;" OwnerUserId="2599" LastEditorUserId="2599" LastEditDate="2020-04-14T09:52:25.083" LastActivityDate="2020-04-14T09:52:25.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3880" PostTypeId="1" CreationDate="2020-04-14T10:52:10.200" Score="4" ViewCount="173" Body="&lt;p&gt;I am looking to solve a multi-objective chance-constrained blending problem. Are there any suggestions about the software to use to try and solve a problem like this?&lt;/p&gt;&#xA;" OwnerUserId="3295" LastEditorUserId="38" LastEditDate="2020-04-14T13:18:14.520" LastActivityDate="2020-04-16T20:19:56.453" Title="Software for multi-objective optimization" Tags="|nonlinear-programming|software|multi-objective-optimization|chance-constraints|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3881" PostTypeId="1" AcceptedAnswerId="3905" CreationDate="2020-04-14T11:56:07.160" Score="5" ViewCount="182" Body="&lt;p&gt;I need to solve the following problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad x_1/x_2\\\text{s.t.}&amp;amp;\quad Ax \leq b\\&amp;amp;\quad x &amp;gt; 0\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a positive matrix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best thing I can think of is to put &lt;span class=&quot;math-container&quot;&gt;$x_1 = e^{z_1}, x_2 = e^{z_2}$&lt;/span&gt;. Then the objective becomes a convex function &lt;span class=&quot;math-container&quot;&gt;$e^{z_1 - z_2}$&lt;/span&gt; and the constraints are convex because of the positive nature of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something better for this kind of problem? &lt;/p&gt;&#xA;" OwnerUserId="3335" LastEditorUserId="500" LastEditDate="2020-04-16T21:14:25.643" LastActivityDate="2020-04-16T23:27:42.917" Title="Minimizing $x_1/x_2$ over a simplex in the positive orthant" Tags="|optimization|linearization|nonlinear-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3882" PostTypeId="2" ParentId="3877" CreationDate="2020-04-14T12:32:25.630" Score="4" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}x_h + x_{h'} &amp;amp;\geq  y_h + y_{h'} -1\\2 (x_h + x_{h'}) &amp;amp;\leq y_h + y_{h'}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2020-04-14T15:24:24.840" LastActivityDate="2020-04-14T15:24:24.840" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3883" PostTypeId="1" AcceptedAnswerId="3886" CreationDate="2020-04-14T20:05:57.223" Score="4" ViewCount="1650" Body="&lt;p&gt;I changed jobs recently to a manufacturing firm. Job shop scheduling is made 100% manually and intuitively in Excel. Very time consuming and they have no idea if the schedule made is something close to best solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The production consists of multiple processes (in total 4). End product is made of 2 parts. Both parts are individually molded, then one of the parts are printed, part 1 and part 2 are assembled and then packed. Number of work centers available in each process is 23,15,15,5 respectively. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is that if I would be able to manage production scheduling in Excel solver by assigning orders to machines while maintaining a min OEE and limited tardiness and visualize it with a gantt chart. I have searched the web but did not find much so if you can point me to the right direction I would be very thankful. &lt;/p&gt;&#xA;" OwnerUserId="3334" LastEditorUserId="660" LastEditDate="2020-04-17T10:19:32.013" LastActivityDate="2022-01-15T02:34:43.953" Title="Job shop scheduling advice" Tags="|scheduling|excel|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3884" PostTypeId="2" ParentId="3876" CreationDate="2020-04-14T20:28:49.737" Score="4" Body="&lt;p&gt;Try to come up with a feasible (not necessarily optimal) solution, plug it into cells F2 to F13, and see if any of your constraints are violated. If so, and assuming your solution is really feasible, those are the constraints to fix. If not, meaning all constraints are satisfied, then possibly there is an issue with how the model was plugged into Solver.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-04-14T20:28:49.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3885" PostTypeId="2" ParentId="3883" CreationDate="2020-04-14T20:38:40.443" Score="8" Body="&lt;p&gt;It should be possible to model the production process using an integer or mixed-integer linear program. There is a lot of literature out there about MIP models for job shop scheduling. The data would fit in Excel, but the dimensions of the problem might be a bit much for the version of Solver included in Excel. There are some solver alternatives for Excel (such as &lt;a href=&quot;https://opensolver.org/&quot; rel=&quot;noreferrer&quot;&gt;OpenSolver&lt;/a&gt;) that might do the trick, but you might end up needing a commercial solver. If so, it might be easier to build and solve the model outside Excel (possibly pulling demand data etc. from Excel) and then push the solution into an Excel spreadsheet.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-04-14T20:38:40.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3886" PostTypeId="2" ParentId="3883" CreationDate="2020-04-14T23:32:26.193" Score="4" Body="&lt;p&gt;The scheduling models in the real application are a bit different from the academic problems. For example, in a real situation, there are multi objectives/complicated constraints that should be satisfied. Another important thing is, which kind of scheduling model (parallel scheduling, job shop, etc.) you have faced in your machinery area. To achieve your desired goals you have many options. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If you are interested to develop a mathematical formulation based on MIPs, as @prubin mentioned, and your problem scale is not too large, you can implement your model in an excel-based solver like OpenSolver or &lt;a href=&quot;https://solverstudio.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;solver studio&lt;/a&gt; (if you have to use excel). Also, you can interpret your model in the Python-based solvers like &lt;a href=&quot;http://www.pyomo.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo&lt;/a&gt; or &lt;a href=&quot;https://coin-or.github.io/pulp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PulP&lt;/a&gt; for using the programming language benefits.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you are going to use the heuristic methods, you can use &lt;a href=&quot;http://web-static.stern.nyu.edu/om/software/lekin/&quot; rel=&quot;nofollow noreferrer&quot;&gt;LEKIN&lt;/a&gt;, excel-based &lt;a href=&quot;https://www.me.utexas.edu/~jensen/ORMM/excel/library_windows.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jensen Library&lt;/a&gt; and &lt;a href=&quot;https://www.optaplanner.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner&lt;/a&gt;. They have provided some useful Gantt chart facilities. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you want to try commercial advanced scheduling software, I recommended using &lt;a href=&quot;https://www.asprova.com/en/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ASPROVA&lt;/a&gt; to learn about advanced software with dozens of features. Also, other web-based scheduling software could be found by googling.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Finally, it would be considered excel is not a strong scheduling software and it needs more time to provide/modify production data. By using optimization software, you can save your time and uses it to increase the firm's productivity. Therefore, I recommended you to start with one of the above fields and tried to figure out what you are looking for. I hope they would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2020-04-14T23:39:35.313" LastActivityDate="2020-04-14T23:39:35.313" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3887" PostTypeId="1" CreationDate="2020-04-15T03:16:36.510" Score="3" ViewCount="186" Body="&lt;p&gt;I am trying to solve an NLP using the Knitro solver, but I am beginning to think that I will not be able to solve the model because it is too complex. I have heard that &quot;rolling horizons&quot; can be used to help alleviate the challenges of large models, but I am not sure how you would go about using a rolling horizon in Knitro? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that my understanding of the rolling horizon method is not the best, but from what I have read it might be as simple as just solving the model for a sub period. Taking all of the results, and then re inputting those as initial values for the next period, and then solving them like that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question: How can a rolling horizon approach be implemented if I am using the Knitro solver?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="547" LastActivityDate="2020-04-15T09:57:45.830" Title="Rolling Horizon Methods in Knitro" Tags="|nonlinear-programming|knitro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3888" PostTypeId="2" ParentId="3887" CreationDate="2020-04-15T08:47:01.833" Score="6" Body="&lt;p&gt;Rolling horizon methods often arise in the world of optimal control, when you want to solve &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;(P)\qquad\min_{x,u}&amp;amp;\quad\sum_{t=0}^T c_t(x_t, u_t)\\&#xA;\text{s.t.}&amp;amp;\quad x_{t+1} = f_t(x_t, u_t) &amp;amp; \forall t=0, \cdots, T\\&#xA;&amp;amp;\quad x_t \in X_t, \; u_t\in U_t &amp;amp;\forall t =0, \cdots, T&#xA;\end{aligned}&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; denoting the time (&lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; being the final time), &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; the state at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$u_t$&lt;/span&gt; the control, &lt;span class=&quot;math-container&quot;&gt;$c_t$&lt;/span&gt; a cost function penalizing &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u_t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$X_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U_t$&lt;/span&gt; the admissible sets and &lt;span class=&quot;math-container&quot;&gt;$f_t$&lt;/span&gt; a dynamics function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rolling horizon method (for a reference, see e.g. Bertsekas, Dimitri P. &lt;em&gt;Dynamic programming and optimal control&lt;/em&gt;) is a method to solve &lt;em&gt;approximately&lt;/em&gt; problem &lt;span class=&quot;math-container&quot;&gt;$(P)$&lt;/span&gt;, in an iterative fashion. Starting from an initial position &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt;, proceed as follow.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Fix an horizon &lt;span class=&quot;math-container&quot;&gt;$h \in \mathbb{N}$&lt;/span&gt;. &lt;/li&gt;&#xA;&lt;li&gt;At time &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, starting from a position &lt;span class=&quot;math-container&quot;&gt;$\tilde x_k$&lt;/span&gt;, solve the optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;(\tilde P_k)\quad\min_{x,u} &amp;amp;\quad \sum_{t=k}^{k+h} c_t(x_t, u_t)\\&#xA;\text{s.t.}&amp;amp;\quad x_{t+1} = f_t(x_t, u_t) &amp;amp;\forall t=k, \cdots, k+h \\&#xA;&amp;amp; x_t \in X_t, \; u_t\in U_t &amp;amp; \forall t =k, \cdots, k+h \\&#xA;&amp;amp; x_k = \tilde x_k&#xA;\end{aligned}&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Once problem &lt;span class=&quot;math-container&quot;&gt;$(\tilde P_k)$&lt;/span&gt; solved, recover in the solution the next position &lt;span class=&quot;math-container&quot;&gt;$\tilde x_{k+1}$&lt;/span&gt; and the control &lt;span class=&quot;math-container&quot;&gt;$\tilde u_k$&lt;/span&gt;. Reiterate the procedure at time &lt;span class=&quot;math-container&quot;&gt;$k+1$&lt;/span&gt;, this time starting from position &lt;span class=&quot;math-container&quot;&gt;$\tilde x_{k+1}$&lt;/span&gt;. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;At the end, your approximate solution is given by the states &lt;span class=&quot;math-container&quot;&gt;$\tilde x_0, \cdots, \tilde x_k, \cdots, \tilde x_T$&lt;/span&gt; and the controls &lt;span class=&quot;math-container&quot;&gt;$\tilde u_0, \cdots, \tilde u_k, \cdots, \tilde u_T$&lt;/span&gt; you gathered during the previous procedure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum up, you have to solve a collection of non-linear problems &lt;span class=&quot;math-container&quot;&gt;$(\tilde P_k)$&lt;/span&gt;, in an iterative fashion. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the problem &lt;span class=&quot;math-container&quot;&gt;$(\tilde P_{k+1})$&lt;/span&gt; is similar as problem &lt;span class=&quot;math-container&quot;&gt;$(\tilde P_k)$&lt;/span&gt;, you may want to use Knitro so as to warmstart the resolution of &lt;span class=&quot;math-container&quot;&gt;$(\tilde P_{k+1})$&lt;/span&gt; with the solution of &lt;span class=&quot;math-container&quot;&gt;$(\tilde P_k)$&lt;/span&gt;. The ideal would be to instantiate only a single instance of Knitro in memory, and then update this instance inline to reformulate a problem &lt;span class=&quot;math-container&quot;&gt;$(\tilde P_k)$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. Since the introduction of an incremental API in Knitro 11.0, doing so is not that difficult.&lt;/li&gt;&#xA;&lt;li&gt;Interior points algorithms are not that efficient when warm-started. You may want to tune Knitro to use the SQP algorithm (&lt;code&gt;algorithm=4&lt;/code&gt; in the option).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you target to solve generic optimal control problems, I recommend you having a look at &lt;a href=&quot;https://web.casadi.org/&quot; rel=&quot;noreferrer&quot;&gt;Casadi&lt;/a&gt;, which is a good library to formulate non-linear model predictive control (NMPC) problems and has a wrapper to Knitro.&lt;/p&gt;&#xA;" OwnerUserId="2452" LastEditorUserId="123" LastEditDate="2020-04-15T09:57:45.830" LastActivityDate="2020-04-15T09:57:45.830" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3889" PostTypeId="1" AcceptedAnswerId="3890" CreationDate="2020-04-15T11:08:48.547" Score="0" ViewCount="400" Body="&lt;p&gt;I tried solving this problem &lt;a href=&quot;https://i.stack.imgur.com/6qWX3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6qWX3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my cplex code&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ude1T.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ude1T.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have mentioned stored[month] as float+ but in the final result I get negative values. What is wrong with my model? &lt;a href=&quot;https://i.stack.imgur.com/sHOSz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sHOSz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2958" LastEditorUserId="123" LastEditDate="2020-04-15T18:04:39.723" LastActivityDate="2020-04-15T18:04:39.723" Title="What is wrong with my linear programming model?" Tags="|linear-programming|modeling|cplex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3890" PostTypeId="2" ParentId="3889" CreationDate="2020-04-15T11:32:57.100" Score="7" Body="&lt;p&gt;you get negative values because your model is relaxed by cplex since it is not feasible.&#xA;You should debug it.&#xA;Your &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (i==i)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;looks very strange, I would change one i into 1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plus to get help try to copy / paste code instead of screenshots&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-04-15T11:32:57.100" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3891" PostTypeId="1" AcceptedAnswerId="3893" CreationDate="2020-04-15T17:25:57.980" Score="5" ViewCount="112" Body="&lt;p&gt;I'm trying to formulate a MILP for scheduling service jobs for multiple devices. Let's assume that each device &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; has a life &lt;span class=&quot;math-container&quot;&gt;$\ell_i$&lt;/span&gt; and that I have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; total service visits to allocate at times &lt;span class=&quot;math-container&quot;&gt;$\{M_1,\ldots,M_n\}$&lt;/span&gt;.  Each device must be serviced.  I would like to maximize the average time of service per device -- understanding that some devices will share a service (think 2 service visits for 5 devices).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, I have &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Objective&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$$\max \sum_j \sum_i M_j x_{ij}\tag1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_j x_{ij} = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall i$&lt;/span&gt; (every device is serviced once)  (2)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_i x_{ij} \geq 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall j$&lt;/span&gt; (every job services one or more devices) (3)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$M_j x_{ij} \leq \ell_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall i,j$&lt;/span&gt; (each device has a service before the end of life) (4)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M_j \geq 0$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall j$&lt;/span&gt;, &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij} \in \{0,1\}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i,j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I realize that &lt;span class=&quot;math-container&quot;&gt;$M_j x_{ij}$&lt;/span&gt; is nonlinear.  I can rearrange (4) to make it linear (&lt;span class=&quot;math-container&quot;&gt;$M_j \leq \ell_i (1+c(1-x_{ij})$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is very large), but I'm still stuck with the nonlinear term in the objective. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to restate the objective, so I can use a MILP solver?  Or perhaps a better way to formulate the entire problem?  I don't have a background in integer programming, so even suitable problem classes are a bit of a mystery to me. &lt;/p&gt;&#xA;" OwnerUserId="381" LastEditorUserId="123" LastEditDate="2020-04-15T18:07:46.367" LastActivityDate="2020-04-15T18:07:46.367" Title="Help with a MILP formulation for service scheduling" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3892" PostTypeId="2" ParentId="3865" CreationDate="2020-04-15T17:45:41.703" Score="3" Body="&lt;p&gt;It seems that heuristic search prioritizes searching in the middle at versus greedy search, which is especially problematic to minimizing the cost function of TSP. Searching in the middle is bad because this often cuts the graph in half which leads to suboptimal solutions (where the final path crosses each other).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason why heuristic search cuts to the center is because the point density is higher in the middle of the graph and often, these dense points in the center will always lead to a lower path length when heuristic searching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this leads the underlying reason why search isn't the optimal solution for TSP here because the heuristic objective function is not a great approximation for the true Hamiltonian cycle objective function. I would conclude here that minimizing the path for the next 5 nodes does not take into account that Hamiltonian path length is a function of all the nodes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that greedy pathing is better because it avoids this middle cutting behavior.&lt;/p&gt;&#xA;" OwnerUserId="3346" LastEditorUserId="123" LastEditDate="2020-04-15T18:05:32.170" LastActivityDate="2020-04-15T18:05:32.170" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3893" PostTypeId="2" ParentId="3891" CreationDate="2020-04-15T17:46:57.873" Score="6" Body="&lt;p&gt;There is a way to formulate the problem with everything linear. (You can decided if it is better.) Set a time horizon &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; (could be the last end-of-life epoch among the devices). Let &lt;span class=&quot;math-container&quot;&gt;$x_{it}$&lt;/span&gt; be 1 if device &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is serviced at time &lt;span class=&quot;math-container&quot;&gt;$t\in \lbrace 1,\dots, T\rbrace$&lt;/span&gt;, 0 if not. Let &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; be 1 if there is a service visit at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, 0 if not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the following model:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max&amp;amp;\quad\sum_{i}\sum_{t}tx_{it}\\&#xA;\textrm{s.t. }&amp;amp;\quad\sum_{t}x_{it}=1&amp;amp;\forall i\\&#xA;&amp;amp;\quad\sum_{t}tx_{it}\le\ell_{i}&amp;amp;\forall i\\&#xA;&amp;amp;\quad x_{it}\le y_{t}&amp;amp;\forall i,t\\&#xA;&amp;amp;\quad y_{t}\le\sum_{i}x_{it}&amp;amp;\forall t\\&#xA;&amp;amp;\quad \sum_{t}y_{t}=n.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The objective maximizes the sum of the service dates. The first constraint ensures every device is serviced once. The second constraint requires each device be serviced before it dies. The third constraint ensures that devices are only serviced during visits, the fourth prevents idle visits, and the fifth forces exactly &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; visits. (You might want to consider making the last constraint an inequality, in case not all &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; visits are needed.) This assumes that there is no limit on how many devices can be serviced at any one time.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="123" LastEditDate="2020-04-15T18:06:58.377" LastActivityDate="2020-04-15T18:06:58.377" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3894" PostTypeId="1" CreationDate="2020-04-15T22:47:48.010" Score="7" ViewCount="346" Body="&lt;p&gt;I am wondering if optimality cuts in Benders algorithm exclude the possibility to have the same solutions and as a result, have the same optimality cut? I don't know why it is not possible to have the same cuts in different iterations of Benders decomposition algorithm.&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2020-04-16T16:20:55.057" Title="Do Benders cuts exclude current solutions?" Tags="|mixed-integer-programming|benders-decomposition|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3895" PostTypeId="2" ParentId="3894" CreationDate="2020-04-15T22:51:10.950" Score="8" Body="&lt;p&gt;It depends on whether you consider the master variable &lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt; to be part of the solution.  You can get the same master &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; with a different &lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt; after adding an optimality cut, but then the Benders decomposition algorithm would terminate because the solution is optimal to the original problem.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-04-15T22:51:10.950" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3896" PostTypeId="1" AcceptedAnswerId="3900" CreationDate="2020-04-15T23:47:52.553" Score="7" ViewCount="127" Body="&lt;p&gt;Let us assume that an optimization algorithm requires &lt;span class=&quot;math-container&quot;&gt;$\mathcal{O}(n^{\log1/\epsilon})$&lt;/span&gt; flops to find a solution &lt;span class=&quot;math-container&quot;&gt;$\bar{X}$&lt;/span&gt; such that &#xA;&lt;span class=&quot;math-container&quot;&gt;$$\| \bar{X} - X^{\star}\| \leq \epsilon$$&lt;/span&gt;  where &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;lt; 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X^{\star}$&lt;/span&gt; is the true optimum point.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What kind of algorithm is this? Can it be considered polynomial?  &lt;/p&gt;&#xA;" OwnerUserId="3200" LastEditorUserId="123" LastEditDate="2020-04-16T08:38:57.077" LastActivityDate="2020-04-16T15:00:41.410" Title="Can this algorithm be considered polynomial?" Tags="|computational-complexity|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3897" PostTypeId="1" CreationDate="2020-04-16T02:33:59.383" Score="6" ViewCount="292" Body="&lt;p&gt;EDIT #2 5/17/2020: I re-phrased my question once more. My original question is still at the end. Thanks for the feedback. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know if it's possible to maximize the sum of cumulative distribution functions for independent normal distributions in Excel using OpenSolver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{maximize } \Phi(\sum_i x_ip_i) + \Phi(\sum_i x_iq_i)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{ s.t.} \sum_ix_i=3 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i=1 \text{ or } 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\Phi(\cdot)$&lt;/span&gt; is the standard normal cdf (or &lt;code&gt;NORM.DIST&lt;/code&gt; in Excel). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;ORIGINAL:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a snapshot of the workbook: &lt;a href=&quot;https://i.stack.imgur.com/QqIKC.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/QqIKC.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the formulas: &lt;a href=&quot;https://i.stack.imgur.com/4x6X0.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/4x6X0.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to maximize a cell that is the sum of other cells that are not linear. I have Z scores for categories I and II (I hardcoded in a mean of 30, and stdev of 15 for category I and 40 and 20 for category II).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to maximize the sum of their normdist values in Row 13 (G13 and H13). Clearly, solver won't find a linear solution since the normdist function isn't linear. I have heard there was a way to get around this by doing piecewise-linear approximation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Columns B and C contains raw data - no formulas&lt;/li&gt;&#xA;&lt;li&gt;Column E is made up of 1s and 0s that are the variable cells determined by Solver&lt;/li&gt;&#xA;&lt;li&gt;G2:H6 will return the raw data found in columns B and C if column E displays a 1&lt;/li&gt;&#xA;&lt;li&gt;The sum of E2:E6 must equal 3&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;This is very scaled down from the real problem I'm trying to solve, so no brute force methods will suffice.&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3350" LastEditorUserId="3350" LastEditDate="2020-05-17T23:27:42.033" LastActivityDate="2020-05-18T01:03:03.463" Title="How can I maximize the sum of norm.dist values using solver?" Tags="|solver|excel|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3898" PostTypeId="1" CreationDate="2020-04-16T13:11:01.427" Score="6" ViewCount="1034" Body="&lt;p&gt;I am building my first optimization model, it is quite large and also a non-linear problem. I have had my model solving on the NEOS Optimization Server and after 8 hours of trying to solve, the server cut out because it reached a time limit. So what I am wondering is if it's abnormal for models to run over 8 hours or if this is a fairly normal occurrence. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the NEOS server because it is free and the solver I am using (KNITRO) is quite expensive. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I will be updating this problem later today. &lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="547" LastEditDate="2020-04-17T20:07:14.000" LastActivityDate="2020-04-17T20:07:14.000" Title="Is it abnormal for a model to take 8+ hours to solve?" Tags="|solver|nonlinear-programming|neos|knitro|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="3899" PostTypeId="2" ParentId="3898" CreationDate="2020-04-16T13:46:42.883" Score="5" Body="&lt;p&gt;It is highly dependent to the problem, and to the size of the instance you are solving. For example, in many scheduling problems I have dealt with, the optimal solution cannot be found within 8 hours for medium-sized instances. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently, I have been using NEOS server since I didn't have access to my uni PC as a result of quarantine! I had an MILP model for a certain type of single machine scheduling problem, where NEOS was unable to optimally solve the instances with 15 jobs within 8 hours (I tried both CPLEX and Gurobi).&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-04-16T13:52:51.543" LastActivityDate="2020-04-16T13:52:51.543" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3900" PostTypeId="2" ParentId="3896" CreationDate="2020-04-16T14:10:27.497" Score="4" Body="&lt;p&gt;It is a polynomial-time approximation scheme (see &lt;a href=&quot;https://en.wikipedia.org/wiki/Polynomial-time_approximation_scheme&quot; rel=&quot;nofollow noreferrer&quot;&gt;Polynomial-time Approximation Scheme&lt;/a&gt;). This can be seen since when you fix &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;, the running time is polynomial in &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. It is however no FPTAS, since this would require that its running time is in &lt;span class=&quot;math-container&quot;&gt;$O((n/\epsilon)^C)$&lt;/span&gt;  for some fixed constant &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; (see &lt;a href=&quot;https://cs.stackexchange.com/questions/51495/ptas-definition-vs-fptas&quot;&gt;this post&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2020-04-16T15:00:41.410" LastActivityDate="2020-04-16T15:00:41.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3901" PostTypeId="2" ParentId="3897" CreationDate="2020-04-16T16:13:38.767" Score="5" Body="&lt;p&gt;You can approximate any nonlinear function via a piecewise-linear function using binary variables (or, if your solver supports them, type 2 special ordered sets). I have an old &lt;a href=&quot;https://orinanobworld.blogspot.com/2014/11/linearize-that.html&quot; rel=&quot;noreferrer&quot;&gt;blog post&lt;/a&gt; explaining how to do this with SOS2. As to how accurate it is, your mileage will vary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The version of Solver in Excel is fairly limited. You might want to consider the &lt;a href=&quot;https://opensolver.org/&quot; rel=&quot;noreferrer&quot;&gt;OpenSolver&lt;/a&gt; or &lt;a href=&quot;https://solverstudio.org/&quot; rel=&quot;noreferrer&quot;&gt;SolverStudio&lt;/a&gt; add-ins for Excel (both open source), which can handle larger models and tend to be more powerful. At least some of the solvers they support can handle SOS2 constraints, but I don't know if their interfaces have provisions for specifying SOS2. If not, you could definitely fall back to using binary variables.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-04-16T16:13:38.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3902" PostTypeId="2" ParentId="3894" CreationDate="2020-04-16T16:20:55.057" Score="4" Body="&lt;p&gt;If I understand the question correctly, it is not possible to have the same optimality cut generated twice because (a) cuts are cumulative and (b) an optimality cut is only generated when an allegedly integer-feasible solution would violate the generated cut. So if you get solution 1, use it to generate cut 1 (which is added to the master), then get solution 2 which is feasible in the current master, solution 2 must satisfy cut 1. It may still incorrectly estimate the objective contribution of the subproblem, leading to another optimality cut (call it cut 2), but that cut will be different from cut 1 because solution 2 will satisfy cut 1 but violate cut 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are adding cuts on the fly via callback (rather than solving the master all the way, adding a cut, then solving the master again), and if you are using multiple threads, it might be possible for two different threads to trigger generation of the same cut before the cut makes it into the master (and is propagated to the various child processes). That would be fairly rare. Also, and again referring to the &quot;one tree&quot; approach, some solvers will let you allow cuts to expire. (CPLEX, for instance, refers to such cuts as &quot;purgeable&quot;.) If you add optimality cuts that can and in some cases do expire, you run the risk to see them generated anew. Again, this would be pretty rare.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-04-16T16:20:55.057" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3903" PostTypeId="2" ParentId="3881" CreationDate="2020-04-16T18:58:08.560" Score="0" Body="&lt;p&gt;I think that you have choose a good way to solve this problem. In a problem with real variables and nonlinear optimization, the model that you can use are the &lt;a href=&quot;https://en.wikipedia.org/wiki/Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions&quot; rel=&quot;nofollow noreferrer&quot;&gt;Karush-Kuhn-Tucker conditions&lt;/a&gt;. This algorithm give you the necessary and sufficient conditions for an optimal solution. I would use the following strategy:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Perform the variable change from &lt;span class=&quot;math-container&quot;&gt;$x=(x_1, x_2)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$z=(z_1, z_2)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Use the Karush-Kuhn-Tucker conditions to find a solution.&lt;/p&gt;&#xA;" OwnerUserId="3357" LastActivityDate="2020-04-16T18:58:08.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3904" PostTypeId="2" ParentId="3880" CreationDate="2020-04-16T20:19:56.453" Score="7" Body="&lt;p&gt;You may be interested in the following paper because it uses chance-constrained programming and bi-objective optimization together in a transportation application:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s10288-019-00429-7&quot; rel=&quot;noreferrer&quot;&gt;https://link.springer.com/article/10.1007/s10288-019-00429-7&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest to do the followings for your problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- If you have bi-linear terms in your formulation then try to linearize them using for example &quot;Piecewise mccormick relaxation&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2-   Generate a reasonable (and tractable) number of scenarios to generate/expand the chance constraint(s) in your formulation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3-1- If your problem has two 2 objective functions then you can pass your formulation to &#xA;the &quot;triangle splitting method&quot; (which is an exact method) embedded in the following julia package to solve it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/alvsierra286/OOESAlgorithm.jl&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/alvsierra286/OOESAlgorithm.jl&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1111/itor.12692&quot; rel=&quot;noreferrer&quot;&gt;https://onlinelibrary.wiley.com/doi/abs/10.1111/itor.12692&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3-2- If your problem has more than two objective functions then you can pass your formulation to the following julia generic heuristic package to solve it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/aritrasep/FPBH.jl&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/aritrasep/FPBH.jl&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0305054819301947&quot; rel=&quot;noreferrer&quot;&gt;https://www.sciencedirect.com/science/article/abs/pii/S0305054819301947&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3358" LastActivityDate="2020-04-16T20:19:56.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3905" PostTypeId="2" ParentId="3881" CreationDate="2020-04-16T21:10:14.027" Score="4" Body="&lt;p&gt;As mentioned by @user3680510, your problem is a linear-fractional programming problem, and can be reformulated as a linear programming problem through the Charnes-Cooper transformation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My answer will be specific to your problem, but the more general transformation can be found on the linear-fractional programming &lt;a href=&quot;https://en.wikipedia.org/wiki/Linear-fractional_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia page&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start from your formulation and divide all constraints by &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;. This is allowed, as &lt;span class=&quot;math-container&quot;&gt;$x_2 &amp;gt; 0$&lt;/span&gt;. We get the equivalent problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad x_1/x_2\\\text{s.t.}&amp;amp;\quad A(x/x_2) \leq b(1/x_2)\\&amp;amp;\quad x &amp;gt; 0.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is straightforward to show that &lt;span class=&quot;math-container&quot;&gt;$$x &amp;gt; 0 \iff (x/x_2) &amp;gt; 0 \textrm{ and } (1/x_2) &amp;gt; 0,$$&lt;/span&gt;&#xA;which gives the equivalent problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad x_1/x_2\\\text{s.t.}&amp;amp;\quad A(x/x_2) \leq b(1/x_2)\\&amp;amp;\quad (x/x_2) &amp;gt; 0\\&amp;amp;\quad (1/x_2) &amp;gt; 0.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, we will substitute &lt;span class=&quot;math-container&quot;&gt;$y=x/x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t = 1/x_2$&lt;/span&gt; to obtain a linear program. We do have to be careful that we only allow the variables &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; to take on values for which a corresponding &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a feasible &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, we immediately have that &lt;span class=&quot;math-container&quot;&gt;$x_2 = 1/t$&lt;/span&gt; is feasible. The value &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\neq 2$&lt;/span&gt; represents &lt;span class=&quot;math-container&quot;&gt;$x_i/x_2$&lt;/span&gt;. Because we already know the value for &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;, we have that &lt;span class=&quot;math-container&quot;&gt;$x_i = y_i x_2 = y_i/t$&lt;/span&gt;. The value &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; represents &lt;span class=&quot;math-container&quot;&gt;$x_2/x_2 = 1$&lt;/span&gt;. Hence, we will have to enforce that &lt;span class=&quot;math-container&quot;&gt;$y_2 = 1$&lt;/span&gt;, or the solution cannot be translated back to the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It follows that the original problem can be solved by solving:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad y_1\\\text{s.t.}&amp;amp;\quad Ay \leq bt\\&amp;amp;\quad y_2 = 1\\&amp;amp;\quad y &amp;gt; 0\\&amp;amp;\quad t &amp;gt; 0,\end{align}&lt;/span&gt;&#xA;and taking &lt;span class=&quot;math-container&quot;&gt;$x = y/t$&lt;/span&gt; (which includes &lt;span class=&quot;math-container&quot;&gt;$x_2 = y_2/t = 1/t$&lt;/span&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The linear program above is not standard, in the sense that you have strict inequality constraints. More about this can be found in &lt;a href=&quot;https://or.stackexchange.com/questions/3166/does-it-make-sense-to-use-strict-equality-constraint-in-optimization/&quot;&gt;this OR.SE question&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2020-04-16T23:27:42.917" LastActivityDate="2020-04-16T23:27:42.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3906" PostTypeId="2" ParentId="3898" CreationDate="2020-04-17T03:42:00.380" Score="2" Body="&lt;p&gt;It is totally normal for some instances to take more than hours to be solved(and that's why NEOS Server has the limitation of 8 hours for each instance to be able to serve more users). The thing that you can try is starting your solving process with multi-start(which is one of many options that are available with Knitro on NEOS). &lt;code&gt;'ms_enable'=1&lt;/code&gt; is the option to activate multi-start in Knitro. More information about it can be found &lt;a href=&quot;https://www.artelys.com/docs/knitro/2_userGuide/multistart.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. Hope this works for your problem. &lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-04-17T03:42:00.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3907" PostTypeId="2" ParentId="3898" CreationDate="2020-04-17T04:07:00.443" Score="2" Body="&lt;p&gt;In my experience I have run some very large scale problems for 8+ hours with over 500K+ binary variables due computational issues because of not having larger RAMs. In around 2008, cloud computing was just starting and availability of machines with huge RAMs was hard to find unlike these days where we can just swipe a credit card on AWS. I would be surprised still if a model is running that long. I would solve smaller instances to check, understand the logs, linearize the math formulation if possible and fine tune KNITRO parameters as some users are suggesting.  &lt;/p&gt;&#xA;" OwnerUserId="3360" LastActivityDate="2020-04-17T04:07:00.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3908" PostTypeId="2" ParentId="3883" CreationDate="2020-04-17T04:27:21.823" Score="3" Body="&lt;p&gt;In the industry a lot of decision making is done via Excel based modeling. This is usually a start and some problems outgrow very quickly especially scheduling problems given their combinatorial nature. Lot of folks have given good advice above wrt modeling. I would suggest seeing if you can mimic the intuitive method used to create a simple constructive heuristic with metrics you need using VBScript or Python (if you are familiar with programming). After that trying to do a simple local search moves to see if you can come up with a better solution. A good reference for this kind of work in scheduling is here:&#xA;&lt;a href=&quot;https://www.gerad.ca/~alainh/Scheduling.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gerad.ca/~alainh/Scheduling.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3360" LastActivityDate="2020-04-17T04:27:21.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3909" PostTypeId="2" ParentId="3875" CreationDate="2020-04-17T12:03:32.727" Score="7" Body="&lt;p&gt;At the moment (CPLEX 12.10) querying duals in a relaxation context is not supported. You may want to file a request for enhancement for CPLEX to try to get this into one of the next versions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is however something that may be more difficult than it seems at first glance. For example, duals would have to be provided for the &lt;em&gt;original&lt;/em&gt; model and there a number of presolve reductions that will make uncrushing duals very hard or even impossible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: In fact, you will never be able to get duals for the original model since that would require forming the dual of a MIP. So the best you could ever get are duals for the &lt;em&gt;presolved&lt;/em&gt; model.&lt;/p&gt;&#xA;" OwnerUserId="3179" LastActivityDate="2020-04-17T12:03:32.727" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3910" PostTypeId="1" AcceptedAnswerId="3914" CreationDate="2020-04-17T12:45:43.817" Score="5" ViewCount="539" Body="&lt;p&gt;In the image below, the cost matrix of customers and supplier has several dashes which indicates the impossibility of certain suppliers with certain customers. How can I represent these dashes in CPLEX?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/we9cW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/we9cW.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2958" LastEditorUserId="1160" LastEditDate="2020-04-19T08:08:44.867" LastActivityDate="2020-04-19T08:08:48.450" Title="How can I represent null or dashes in a cost matrix or incidence matrix in CPLEX?" Tags="|mixed-integer-programming|linear-programming|cplex|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3911" PostTypeId="2" ParentId="3910" CreationDate="2020-04-17T13:10:57.027" Score="9" Body="&lt;p&gt;The dashes are just a visual representation of the fact that certain suppliers cannot serve certain customers. So you are not really &quot;representing&quot; these dashes in CPLEX, but rather you are representing the idea behind those dashes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a mathematical optimization model (whether it's in CPLEX or elsewhere), you have two choices: (1) set the costs to something very large (so the solution will not use those pairs), or (2) explicitly prohibit those suppliers from serving those customers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer (2) because setting some large costs in (1) might lead to scaling issues, and because you are allowing non-zero decision variables but the solver will have to &quot;figure out&quot; that it should not use those variables. Modern solvers (like CPLEX) are probably smart enough to do this without much trouble, but I still feel (2) is safer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I'd add a new parameter like &lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt; that equals 1 if supplier &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is allowed to serve customer &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and 0 otherwise, and then use this parameter in your model to prohibit disallowed assignments.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-04-17T13:10:57.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3912" PostTypeId="1" CreationDate="2020-04-17T13:22:16.960" Score="2" ViewCount="101" Body="&lt;p&gt;I don't know if this is the correct community to ask this question, but I did not find a community directly related to lean manufacturing.&lt;/p&gt;&#xA;&lt;p&gt;Recently I came across a term I haven't heard before: BVA (Business Value Added). I am writing my Master's Thesis, and I didn't come across this term during my literature review. However, this is relevant to the scope of my work, and I need to find a good book related to BVA.&#xA;My review covered a lot of the &amp;quot;old bibles&amp;quot;: &lt;em&gt;The Toyota Way&lt;/em&gt;, &lt;em&gt;Lean Thinking&lt;/em&gt;, etc.. And none of them mentions it.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone know of a useful reference covering BVA?&lt;/p&gt;&#xA;" OwnerUserId="3362" LastEditorUserId="491" LastEditDate="2020-10-28T13:59:42.720" LastActivityDate="2020-10-28T13:59:42.720" Title="Literature on Business Value Added (BVA)" Tags="|literature-research|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3913" PostTypeId="2" ParentId="3910" CreationDate="2020-04-17T13:22:32.790" Score="8" Body="&lt;p&gt;Adding to @LarrySnyder610's answer, I prefer option (3): you do not define the &quot;non-existing&quot; options in the first place. When there are &lt;span class=&quot;math-container&quot;&gt;$x_{ij}\in\{0,1\}$&lt;/span&gt; variables to be defined for the assignment (or integer variables for quantities...), you can define them &quot;from everywhere to everywhere&quot;, and then use options (1) or (2); or you modify option (2) to define a set &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; of allowed pairs and only define the variables for pairs in this set &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;. Why define something wrong and correct it later, when you can define it right in the first place? This is certainly a matter of taste.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2020-04-17T13:22:32.790" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3914" PostTypeId="2" ParentId="3910" CreationDate="2020-04-17T13:24:13.047" Score="6" Body="&lt;p&gt;This looks like problem 19 in &lt;a href=&quot;https://www.linkedin.com/pulse/model-building-oplcplex-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;HP Williams Model Building&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see below, the &quot;-&quot; are not in the tuple set for costs&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;.mod&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{string} factories=...;&#xA;{string} depots=...;&#xA;{string} customers=...;&#xA;&#xA;int monthlyCapacity[factories]=...;&#xA;int monthlyMaxThroughput[depots]=...;&#xA;int monthlyRequirement[customers]=...;&#xA;&#xA;tuple cost&#xA;{&#xA;key string origin;&#xA;key string destination;&#xA;float price;&#xA;}&#xA;&#xA;tuple preference&#xA;{&#xA;&#xA;string origin;&#xA;string destination;&#xA;}&#xA;&#xA;{cost} costFactoryToDepot with origin in factories,destination in depots=...;&#xA;{cost} costDepotToCustomer with origin in depots,destination in customers=...;&#xA;{cost} costFactoryToCustomer with origin in factories,destination in customers=...;&#xA;&#xA;{string} origins=factories union depots;&#xA;&#xA;{preference} preferences with origin in origins=...;&#xA;&#xA;{string} customersWithPreferences={p.destination | p in preferences};&#xA;&#xA;dvar float+ x[factories][depots];&#xA;dvar float+ y[factories][customers];&#xA;dvar float+ z[depots][customers];&#xA;&#xA;dvar float totalCost;&#xA;dvar float unmetPreferences;&#xA;&#xA;minimize totalCost;&#xA;subject to&#xA;{&#xA;&#xA;&#xA;&#xA;&#xA;totalCost==&#xA;sum(c in costFactoryToDepot) c.price*x[c.origin][c.destination]&#xA;+sum(c in costDepotToCustomer) c.price*z[c.origin][c.destination]&#xA;+sum(c in costFactoryToCustomer) c.price*y[c.origin][c.destination]&#xA;;&#xA;&#xA;// Links with no cost do not exist&#xA;forall(o in factories,d in depots:0== (&amp;lt;o,d&amp;gt;  in costFactoryToDepot)) x[o][d]==0;&#xA;forall(o in factories,d in customers: 0 == (&amp;lt;o,d&amp;gt; in costFactoryToCustomer)) y[o][d]==0;&#xA;forall(o in depots,d in customers: (0==&amp;lt;o,d&amp;gt;  in costDepotToCustomer)) z[o][d]==0;&#xA;&#xA;forall(i in factories)&#xA;    ctFactoryCapacity:&#xA;        sum(j in depots) x[i][j]+sum(k in customers) y[i][k]&amp;lt;=monthlyCapacity[i];&#xA;&#xA;forall(j in depots)&#xA;    ctInDepots:&#xA;        sum(i in factories) x[i][j]&amp;lt;=monthlyMaxThroughput[j];&#xA;&#xA;forall(j in depots)&#xA;    ctOutDepots:&#xA;        sum(i in factories) x[i][j]==sum(k in customers) z[j][k];&#xA;&#xA;forall(k in customers)&#xA;      ctCustomerRequirement:&#xA;          sum(i in factories) y[i][k] + sum(j in depots) z[j][k] == monthlyRequirement[k];&#xA;&#xA;ctUnMetPrefs:unmetPreferences==sum(k in customersWithPreferences)&#xA;&#xA;    (monthlyRequirement[k]&#xA;        -sum(p in preferences:p.destination==k &amp;amp;&amp;amp; p.origin in factories)    y[p.origin][k]    -&#xA;        sum(p in preferences:p.destination==k &amp;amp;&amp;amp; p.origin in depots)    z[p.origin][k])    ;&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;execute&#xA;{&#xA;writeln(&quot;total cost = &quot;,totalCost);&#xA;&#xA;for(var f in factories) for(var d in depots) if (x[f][d]&amp;gt;0) writeln(f,&quot; --&amp;gt; &quot;,d,&quot; : &quot;,x[f][d]);&#xA;for(var f in factories) for(var c in customers) if (y[f][c]&amp;gt;0) writeln(f,&quot; --&amp;gt; &quot;,c,&quot; : &quot;,y[f][c]);&#xA;for(var d in depots) for(var c in customers) if (z[d][c]&amp;gt;0) writeln(d,&quot; --&amp;gt; &quot;,c,&quot; : &quot;,z[d][c]);&#xA;}&#xA;&#xA;main&#xA;{&#xA;thisOplModel.generate();&#xA;cplex.solve();&#xA;thisOplModel.postProcess();&#xA;&#xA;writeln();&#xA;writeln(&quot;And now with taking into account preferences as much as possible&quot;);&#xA;writeln();&#xA;&#xA;cplex.setObjCoef(thisOplModel.unmetPreferences,1000000);&#xA;cplex.solve();&#xA;thisOplModel.postProcess();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;.dat&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;factories= {Liverpool,Brighton};&#xA;depots = {Newcastle, Birmingham, London, Exeter};&#xA;customers = {c1, c2, c3, c4, c5, c6};&#xA;&#xA;monthlyCapacity=[150000,200000];&#xA;monthlyMaxThroughput= [70000,50000,100000,40000];&#xA;monthlyRequirement=[50000,10000,40000,35000,60000,20000];&#xA;&#xA;costFactoryToDepot={&#xA;&amp;lt;Liverpool, Newcastle,   0.5,&amp;gt;&#xA;&amp;lt;Liverpool, Birmingham,  0.5,&amp;gt;&#xA;&amp;lt;Liverpool, London,      1.0,&amp;gt;&#xA;&amp;lt;Liverpool, Exeter ,     0.2,&amp;gt;&#xA;&amp;lt;Brighton,  Birmingham,  0.3,&amp;gt;&#xA;&amp;lt;Brighton,  London ,     0.5,&amp;gt;&#xA;&amp;lt;Brighton,  Exeter ,     0.2&amp;gt;&#xA;};&#xA;&#xA;costDepotToCustomer=&#xA;{&#xA;&amp;lt;Newcastle , c2 ,1.5&amp;gt;,&#xA;&amp;lt;Newcastle , c3, 0.5&amp;gt;,&#xA;&amp;lt;Newcastle , c4 ,1.5&amp;gt;,&#xA;&amp;lt;Newcastle , c6, 1.0&amp;gt;,&#xA;&amp;lt;Birmingham ,c1, 1.0&amp;gt;,&#xA;&amp;lt;Birmingham, c2 ,0.5&amp;gt;,&#xA;&amp;lt;Birmingham, c3 ,0.5&amp;gt;,&#xA;&amp;lt;Birmingham, c4, 1.0&amp;gt;,&#xA;&amp;lt;Birmingham ,c5, 0.5&amp;gt;,&#xA;&amp;lt;London ,    c2, 1.5&amp;gt;,&#xA;&amp;lt;London,     c3 ,2.0&amp;gt;,&#xA;&amp;lt;London ,    c5, 0.5&amp;gt;,&#xA;&amp;lt;London ,    c6 ,1.5&amp;gt;,&#xA;&amp;lt;Exeter,     c3 ,0.2&amp;gt;,&#xA;&amp;lt;Exeter,     c4 ,1.5&amp;gt;,&#xA;&amp;lt;Exeter,     c5 ,0.5&amp;gt;,&#xA;&amp;lt;Exeter,     c6 ,1.5&amp;gt;&#xA;};&#xA;&#xA;costFactoryToCustomer=&#xA;{&#xA;&amp;lt;Liverpool c1 1.0&amp;gt;,&#xA;&amp;lt;Liverpool c3 1.5&amp;gt;,&#xA;&amp;lt;Liverpool c4 2.0&amp;gt;,&#xA;&amp;lt;Liverpool c6 1.0&amp;gt;,&#xA;&amp;lt;Brighton  c1 2.0&amp;gt;&#xA;};&#xA;&#xA;preferences=&#xA;{&#xA;&amp;lt;Liverpool, c1&amp;gt;,&#xA;&amp;lt;Newcastle, c2&amp;gt;,&#xA;&amp;lt;Birmingham,c5&amp;gt;,&#xA;&amp;lt;Exeter,c6&amp;gt;,&#xA;&amp;lt;London,c6&amp;gt;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;total cost = 198500&#xA;Liverpool --&amp;gt; Exeter : 40000&#xA;Brighton --&amp;gt; Birmingham : 50000&#xA;Brighton --&amp;gt; London : 55000&#xA;Liverpool --&amp;gt; c1 : 50000&#xA;Liverpool --&amp;gt; c6 : 20000&#xA;Birmingham --&amp;gt; c2 : 10000&#xA;Birmingham --&amp;gt; c4 : 35000&#xA;Birmingham --&amp;gt; c5 : 5000&#xA;London --&amp;gt; c5 : 55000&#xA;Exeter --&amp;gt; c3 : 40000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now with taking into account preferences as much as possible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;total cost = 246000&#xA;Liverpool --&amp;gt; Newcastle : 10000&#xA;Liverpool --&amp;gt; Exeter : 40000&#xA;Brighton --&amp;gt; Birmingham : 50000&#xA;Brighton --&amp;gt; London : 30000&#xA;Liverpool --&amp;gt; c1 : 50000&#xA;Liverpool --&amp;gt; c4 : 35000&#xA;Newcastle --&amp;gt; c2 : 10000&#xA;Birmingham --&amp;gt; c5 : 50000&#xA;London --&amp;gt; c5 : 10000&#xA;London --&amp;gt; c6 : 20000&#xA;Exeter --&amp;gt; c3 : 40000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastEditorUserId="1160" LastEditDate="2020-04-19T08:08:48.450" LastActivityDate="2020-04-19T08:08:48.450" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3915" PostTypeId="1" CreationDate="2020-04-17T18:30:38.083" Score="1" ViewCount="70" Body="&lt;p&gt;I am trying to create an optimization model for a problem that involves two different types of queues. Given Poisson demand (for both), there is a queue with constant service time and another queue with another constant service time that allows the service of the first queue to be performed. Please see the following example for clarification. My question is what queueing formulation would represent such a system? My goal is to find a closed-form formulation to calculate the average system waiting time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume there is a battery swapping station for electric vehicles and owns only a single battery swapping machine (i.e., single server). The demand follows Poisson distribution. The station replaces batteries with an FCFS fashion. The service time for battery swapping is deterministic leading to an &lt;em&gt;M&lt;/em&gt;/&lt;em&gt;D&lt;/em&gt;/1 queue for the &lt;em&gt;swapping service&lt;/em&gt;. However, the battery is swapped &lt;strong&gt;only if&lt;/strong&gt; there is a fully-charged battery available at the station. Empty or less-than-fully-charged batteries are charged at the station with an FCFS fashion and a single server (i.e., charger) as well. Assume, the state of the charge for batteries coming into the station is known (because we know where the vehicles are coming from). Hence, the charging time is also deterministic leading to another &lt;em&gt;M&lt;/em&gt;/&lt;em&gt;D&lt;/em&gt;/1 queue for the &lt;em&gt;charging service&lt;/em&gt;. Is there any closed-form solution to find the average waiting time or queue length for these vehicles in such a system?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My interpretation: The closest queue seems to be a semi-open queue (&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/opre.1080.0627?casa_token=AvVBjhp7FqUAAAAA:ZoyDcpdzxa4fSfxDOjTkgC8fcNoWWa_5eC9OLy_FIWdDc3ORZ31lg6G5oYqwtbmrAJfjMkv3k1fN&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jia and Heragu, 2009&lt;/a&gt;). Another alternative is (&lt;a href=&quot;https://s3.amazonaws.com/academia.edu.documents/41647839/On_MD1_queue_with_general_server_vacatio20160127-10122-148vqdx.pdf?response-content-disposition=inline%3B%20filename%3DOn_M_D_1_queue_with_general_server_vacat.pdf&amp;amp;X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;amp;X-Amz-Credential=ASIATUSBJ6BAPSYFPVAT%2F20200417%2Fus-east-1%2Fs3%2Faws4_request&amp;amp;X-Amz-Date=20200417T182617Z&amp;amp;X-Amz-Expires=3600&amp;amp;X-Amz-Security-Token=IQoJb3JpZ2luX2VjEKr%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJIMEYCIQDPztF2ON1IS6nv7tzOnOyGsry1DyMgR%2FlZrCnAKnT%2FuQIhAIqkEQciyU3E12WyyhLpIwvCpifHVi9y9vof1GbPgDX9Kr0DCMP%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQABoMMjUwMzE4ODExMjAwIgzn%2Figx%2FrCLhkO0S3EqkQOTQ6hj8TWTIfTFk%2BhUq608r%2F1Qj6WSY%2BXOy%2FstOtOM0FIBywn%2F2D2hQ%2BYnATbt5%2Bxdokogu03Ee%2FvwrubZcPtKIeta5aYfz37XmDfPLq3v1nqAPfGXy0qwmq%2BWFpT48jiBaZeXZl5e%2B%2B2iX7yfWNSnFRisYysTVucAeL7IgfkzIxrRjGIncPdZgSDGqlCCT%2BOQiSW7oNyEMP98As2UTvnTaw9sJHvnm4Jnoz%2FWFQ1c0uiUHczPIjbOQVQznkqRhvVU%2Buf1D1bzCgYsa%2B2e%2BhmqYs3w9cNe9XNmja%2FMeLbVvCs5Bck5PwOegRDH5SFiSR3yC94AQ5zIOVxinOODOD48aSURPSO%2BVlzm2C6GyEZWbbr4axd1y40qfvL07ywSxJHlfeU5cZ37l9xJYoDIDIun%2B15wQdkvslKj3je3I4MP4mBc4lyfGQcb4t0m%2FUoyOPOlDIm7r1%2FhF74VEfs9dKaiLzItLhN8qEjW5qIkG77AZ05ykafI2zgbS2jXnucxC1zguE1JwT8s1YlmhmBhexwQPTCQ2uf0BTrqAXB8xLvNJUFPwI6hUURFB8OmNkkYzFv3vhoAAANAo3mbhatnQMWC3DDXIRfkbwRb2tk6tLD%2BJHyfzta7vipN9tWBU7vzLJi9IgUmh%2Fe6%2FCgKh7Ui5m3EYnNyZeVtkOV4jDF69grVmYnJ6CnMM9rX6QUXtMaDHA47xP1L2pBaZW%2FUysgbPtO72tMx8FxMyWRC8XdXhfoAxldaPJvHED9DvgWGDYkr9v0FL%2BT1tXO6UVEWt1H%2B4d3SnjLXMS3xLELj6PX4kar8b%2B0mYtK6TlGG3hglQ7oDCdHwc%2BGhdqd7wBadgtP%2F1ut4bekNGg%3D%3D&amp;amp;X-Amz-SignedHeaders=host&amp;amp;X-Amz-Signature=1cd98cbf48649b2e8527c206d63c260bd837e78230e76d2bf5e242a0613fe063&quot; rel=&quot;nofollow noreferrer&quot;&gt;Madan and Saleh, 2001, pp. 35, Case 3&lt;/a&gt;). In the semi-open queue, I couldn't find a closed-form formulation. In the alternative one, the problem would be modeled somewhat differently as we introduce a probabilistic approach to whether there is a battery available or not at each swapping visit, which is not really matching our problem one-to-one. Can you please advise?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, please feel free to change my question title if you come up with a better one.&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="518" LastEditDate="2020-04-17T22:11:15.740" LastActivityDate="2020-04-17T22:11:15.740" Title="Combining Two Different Queues" Tags="|optimization|queuing-theory|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3916" PostTypeId="1" AcceptedAnswerId="3918" CreationDate="2020-04-17T19:00:01.610" Score="3" ViewCount="281" Body="&lt;p&gt;We have a simple problem, namely minimizing:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(x) =  x_1^2 + x_2^2 - x_1.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The gradient is &lt;span class=&quot;math-container&quot;&gt;$$\nabla f(x) = \begin{bmatrix} 2x_1 - 1 \\ 2x_2 \end{bmatrix},$$&lt;/span&gt;&#xA;hence the unique stationary point is: &lt;span class=&quot;math-container&quot;&gt;$x_* = (\frac{1}{2}, 0)$&lt;/span&gt;. Now, I have  a simple introduction to OR level question asking me why this is globally  optimal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My typical answer is to show that &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is convex, e.g.,:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \nabla^2 f(x) = \begin{bmatrix} 2 &amp;amp; 0 \\ 0 &amp;amp; 2 \end{bmatrix} \succ 0,$$&lt;/span&gt;&#xA;therefore a local minimizer is a global minimizer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in some engineering course-notes, the proof of global  optimality is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It is also a global minimizer since the function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$C^1$&lt;/span&gt; and radially unbounded, therefore the global minimizer is a stationary point.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;What is &lt;span class=&quot;math-container&quot;&gt;$C^1$&lt;/span&gt;?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What does radial unboundedness imply here?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Can anyone, please, enlighten me?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: I think they are using the fact that &lt;span class=&quot;math-container&quot;&gt;$\lim\limits_{k \to \infty} \|x_k\|=\infty \implies \lim\limits_{k \to \infty} f(x_k) = \infty$&lt;/span&gt;. Hence, all level sets of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; are compact. Hence the global minimum exists in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^2$&lt;/span&gt;. And the unique stationary point is also globally optimum. But the main question is, &lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Why not show convexity and go in this way?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="65" LastEditorUserId="123" LastEditDate="2020-04-17T19:41:57.990" LastActivityDate="2020-08-10T08:49:48.803" Title="Radial unboundedness vs convexity" Tags="|optimization|global-optimality|local-minimum|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3917" PostTypeId="2" ParentId="3912" CreationDate="2020-04-17T19:26:54.240" Score="3" Body="&lt;p&gt;I think the Business Value Added is a general concept and could be translated as a specific term/definition in the manufacturing, services or another real-applications era. For example, in the manufacturing field, it might be defined as, any improvement in each step of producing a product. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it can be represented as, value-added, measures the amount of wealth created by a company and it is important since it reflects the ability of companies to provide their customers with what they want and are prepared to pay for. It provides a broader perspective on a company's economic contribution than operating profit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope the below references would be helpful. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/gp/book/9789401042550?utm_campaign=3_pier05_buy_print&amp;amp;utm_content=en_08082017&amp;amp;utm_medium=referral&amp;amp;utm_source=google_books#otherversion=9789401105774&quot; rel=&quot;nofollow noreferrer&quot;&gt;Value-added Management with Design of Experiments&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.amazon.com/s?k=9783640901791&amp;amp;i=stripbooks&amp;amp;linkCode=qs&quot; rel=&quot;nofollow noreferrer&quot;&gt;Value Added Scoreboard - Definition and Calculation of Value Added Business Performance&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-04-17T19:26:54.240" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3918" PostTypeId="2" ParentId="3916" CreationDate="2020-04-17T19:33:19.600" Score="4" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The notation &lt;span class=&quot;math-container&quot;&gt;$C^1$&lt;/span&gt; means &lt;span class=&quot;math-container&quot;&gt;$f'$&lt;/span&gt; is continuous (on &lt;span class=&quot;math-container&quot;&gt;$\Bbb R$&lt;/span&gt; as the interval is not stated). In general &lt;span class=&quot;math-container&quot;&gt;$C^k(a,b]$&lt;/span&gt; means that all of &lt;span class=&quot;math-container&quot;&gt;$f',f'',\cdots,f^{(k)}$&lt;/span&gt; are continuous on &lt;span class=&quot;math-container&quot;&gt;$(a,b]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You are correct that radial unboundedness means that &lt;span class=&quot;math-container&quot;&gt;$f\to\infty$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$\|x\|\to\infty$&lt;/span&gt;. This method is essentially that for &lt;a href=&quot;https://en.wikipedia.org/wiki/Lyapunov_stability#Lyapunov%27s_second_method_for_stability&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lyapunov stability&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2018/03/6503.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ahmadi and Jungers (2018)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; proved that if a function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; satisfies &lt;span class=&quot;math-container&quot;&gt;$f(0)=0$&lt;/span&gt; and is positive for all &lt;span class=&quot;math-container&quot;&gt;$x_i\ne0$&lt;/span&gt; then its convexity implies its radial unboundedness. However, notice that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is not always positive for all &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2\ne0$&lt;/span&gt; (choose &lt;span class=&quot;math-container&quot;&gt;$x_1=1/2$&lt;/span&gt; and any &lt;span class=&quot;math-container&quot;&gt;$|x_2|&amp;lt;x_1$&lt;/span&gt;) so the second criterion is not satisfied.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Ahmadi, A. A., Jungers, R. M. (2018). SOS-Convex Lyapunov Functions and Stability of Difference Inclusions. CoRR abs/1803.02070. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2020-08-10T08:49:48.803" LastActivityDate="2020-08-10T08:49:48.803" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3919" PostTypeId="1" CreationDate="2020-04-17T21:21:27.220" Score="4" ViewCount="216" Body="&lt;p&gt;I am trying to build my model up and keep running into this output from BARON: &lt;code&gt;Clp0019I {x} variables/rows fixed as scaled bounds too close&lt;/code&gt;. I checked the BARON manual but I wasn't able to find anything that mentions this issue. I found another question where somebody had the &lt;a href=&quot;http://ampl.996311.n3.nabble.com/AMPL-17099-Setting-presolve-fixeps-td18218.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;exact same issue &lt;/a&gt; but I wasn't able to really solve the issue after studying that question for a little while. When I initiate the solve, the BARON output will spam me with that message until I manually stop the solver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using PYOMO and the BARON solver, and below I have generated a minimal reproducible example ready to be copy-pasted, the output from BARON is also listed below. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I &lt;em&gt;do not&lt;/em&gt; include the second constraint, the model is able to solve and I do not run into any problems. However, once this constraint is introduced then I get the problem from above. If anybody can maybe shine some light on why this is occurring that would be great. There are also a couple of things that might be relevant to the error which I will note below: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The model upper bound is 1E+52 --&gt; This could be problematic and a red flag, but I also am not confident that this means anything in particular to the error that is occurring. &lt;/li&gt;&#xA;&lt;li&gt;If you remove the second constraint and solve the model, the solver is able to complete the solve during preprocessing --&gt; This is just something I have noticed, I don't know if it's significant to the problem at hand. &lt;/li&gt;&#xA;&lt;li&gt;There might also be something going on with how I have formulated the second constraint that seems to not sit well with the solver. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Minimal Reproducible Example&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from __future__ import division&#xA;from pyomo.environ import *&#xA;from MPBFunctions import *&#xA;from pyomo import environ as pym&#xA;from pyomo.util.infeasible import *&#xA;import pandas as pd&#xA;import time&#xA;#import math&#xA;&#xA;model = ConcreteModel()&#xA;########################################################################################################################&#xA;# Set Declaration&#xA;########################################################################################################################&#xA;Imax = 3&#xA;Jmax = 3&#xA;Tmax = 1&#xA;&#xA;model.Iset = RangeSet(1, Imax)&#xA;model.Jset = RangeSet(1, Jmax)&#xA;model.Tset = RangeSet(0, Tmax)&#xA;model.Tset2 = RangeSet(1, Tmax)&#xA;&#xA;########################################################################################################################&#xA;# Parameter Declaration&#xA;########################################################################################################################&#xA;model.p = Param(initialize = 203.84)&#xA;model.tau = Param(initialize = 0.05)&#xA;model.hfee = Param(initialize = 10.69)&#xA;model.dfee = Param(initialize = 9.74)&#xA;model.c = Param(initialize=137)&#xA;model.c0 = Param(initialize = 0.0000349)&#xA;model.c1 = Param(initialize = 4)&#xA;model.alpha = Param(model.Iset, model.Jset, initialize = {(1, 1): 0.313876345630547,&#xA;                                                         (1, 2): 0.300292323327834,&#xA;                                                         (1, 3): 0.348387132466427,&#xA;                                                         (2, 1): 0.295435707228957,&#xA;                                                         (2, 2): 0.28522932311189,&#xA;                                                         (2, 3): 0.287451178160919,&#xA;                                                         (3, 1): 0.317860171471026,&#xA;                                                         (3, 2): 0.27807922348595,&#xA;                                                         (3, 3): 0.275393916055552})&#xA;&#xA;model.TotalVol = Param(model.Iset, model.Jset, initialize = {(1, 1): 2190.59783126487,&#xA;                                                             (1, 2): 1207.90298253892,&#xA;                                                             (1, 3): 1050.0053718149,&#xA;                                                             (2, 1): 704.123722773656,&#xA;                                                             (2, 2): 1804.76078561487,&#xA;                                                             (2, 3): 443.906913433536,&#xA;                                                             (3, 1): 329.654678511934,&#xA;                                                             (3, 2): 278.458426872543,&#xA;                                                             (3, 3): 781.01472605762} )&#xA;&#xA;def volume_sum(model):&#xA;    return sum(sum(model.TotalVol[i,j] for i in model.Iset) for j in model.Jset)&#xA;model.InitialVol = Param(initialize=volume_sum)&#xA;&#xA;########################################################################################################################&#xA;# Variable Declaration&#xA;########################################################################################################################&#xA;&#xA;# Control Variable &amp;amp; Initial Guess of Variable&#xA;&#xA;model.L = Var(model.Iset, model.Jset, model.Tset, bounds = (0,1), initialize = {(1, 1, 1): 0.5,&#xA;                                                                                 (1, 2, 1): 0.24,&#xA;                                                                                 (1, 3, 1): 0.2,&#xA;                                                                                 (2, 1, 1): 0.3,&#xA;                                                                                 (2, 2, 1): 0.09,&#xA;                                                                                 (2, 3, 1): 0.4,&#xA;                                                                                 (3, 1, 1): 0.1,&#xA;                                                                                 (3, 2, 1): 0.14,&#xA;                                                                                 (3, 3, 1): 0.8})&#xA;&#xA;model.incell_weight = Var(model.Iset, model.Jset, model.Tset, bounds=(0,1), initialize=None)&#xA;&#xA;# State Variables - Initially fixed, but governed by biological constraints&#xA;&#xA;model.susceptible = Var(model.Iset, model.Jset, model.Tset, bounds=(0,8000), initialize =   {(1, 1, 0): 6979.1746391853,&#xA;                                                                                             (1, 2, 0): 4022.4237807779,&#xA;                                                                                             (1, 3, 0): 3013.90399921295,&#xA;                                                                                             (2, 1, 0): 2383.33994688046,&#xA;                                                                                             (2, 2, 0): 6327.40268751015,&#xA;                                                                                             (2, 3, 0): 1544.28628984443,&#xA;                                                                                             (3, 1, 0): 1037.10596073212,&#xA;                                                                                             (3, 2, 0): 1001.36365234999,&#xA;                                                                                             (3, 3, 0): 2835.9912130378})&#xA;&#xA;&#xA;model.G_PostTreatment = Var(model.Iset, model.Jset, model.Tset, bounds=(0,200), initialize =    {(1, 1, 0): 0.0,&#xA;                                                                                                 (1, 2, 0): 0.0,&#xA;                                                                                                 (1, 3, 0): 14.0,&#xA;                                                                                                 (2, 1, 0): 14.0,&#xA;                                                                                                 (2, 2, 0): 0.0,&#xA;                                                                                                 (2, 3, 0): 3.0,&#xA;                                                                                                 (3, 1, 0): 9.0,&#xA;                                                                                                 (3, 2, 0): 0.0,&#xA;                                                                                                 (3, 3, 0): 0.0})&#xA;&#xA;model.G_NewGrowth = Var(model.Iset, model.Jset, model.Tset, bounds=(0,200), initialize =    {(1, 1, 0): 0.0,&#xA;                                                                                             (1, 2, 0): 0.0,&#xA;                                                                                             (1, 3, 0): 14.0,&#xA;                                                                                             (2, 1, 0): 14.0,&#xA;                                                                                             (2, 2, 0): 0.0,&#xA;                                                                                             (2, 3, 0): 3.0,&#xA;                                                                                             (3, 1, 0): 9.0,&#xA;                                                                                             (3, 2, 0): 0.0,&#xA;                                                                                             (3, 3, 0): 0.0})&#xA;&#xA;&#xA;# Fix State Variables&#xA;&#xA;[model.susceptible[i,j,0].fix() for i in model.Iset for j in model.Jset]&#xA;[model.G_PostTreatment[i,j,0].fix() for i in model.Iset for j in model.Jset]&#xA;[model.G_NewGrowth[i,j,0].fix() for i in model.Iset for j in model.Jset]&#xA;&#xA;# Variables without initial values. &#xA;&#xA;model.incell_weight = Var(model.Iset, model.Jset, model.Tset, bounds=(0,1))&#xA;&#xA;########################################################################################################################&#xA;# Objective Function&#xA;########################################################################################################################&#xA;def objective_rule(model):&#xA;    return (model.p * model.tau + model.hfee)*model.InitialVol - \&#xA;           sum (sum (sum ((model.dfee*model.alpha[i, j])*model.G_PostTreatment[i, j, t] + model.c*model.L[i, j, t]*model.G_NewGrowth[i, j, t] \&#xA;                          for i in model.Iset ) for j in model.Jset ) for t in model.Tset2 )&#xA;model.damages = Objective(rule=objective_rule, sense=minimize)&#xA;&#xA;#########################################################################################################################&#xA;## Constraint Declaration&#xA;#########################################################################################################################&#xA;&#xA;def susceptible_rule(model,i,j,t):&#xA;    if t == 0:&#xA;        return Constraint.Skip&#xA;    else:&#xA;        return model.susceptible[i,j,t] == model.susceptible[i,j,t-1] - model.G_NewGrowth[i,j,t-1]&#xA;model.susceptible_constraint = Constraint(model.Iset, model.Jset, model.Tset, rule = susceptible_rule)&#xA;&#xA;def incell_weight_rule(model,i,j,t):&#xA;    if t == 0:&#xA;        return Constraint.Skip&#xA;    else:&#xA;        return model.incell_weight[i,j,t] == 1 - exp( -1 * (model.c0 * model.susceptible[i,j,t])**model.c1 )&#xA;model.incell_weight_rules = Constraint(model.Iset, model.Jset, model.Tset, rule = incell_weight_rule)&#xA;&#xA;########################################################################################################################&#xA;# Solving The Model &#xA;########################################################################################################################&#xA;solver = SolverFactory('baron')&#xA;results = solver.solve(model, tee=True)&#xA;model.pprint()&#xA;print(results)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Expected Output&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;===========================================================================&#xA; BARON version 20.4.14. Built: WIN-64 Tue Apr 14 21:23:22 EDT 2020&#xA;&#xA; BARON is a product of The Optimization Firm.&#xA; For information on BARON, see https://minlp.com/about-baron&#xA; Changing option LPSol to 8 (CLP) and continuing.&#xA;&#xA; If you use this software, please cite publications from&#xA; https://minlp.com/baron-publications, such as: &#xA;&#xA; Khajavirad, A. and N. V. Sahinidis,&#xA; A hybrid LP/NLP paradigm for global optimization relaxations,&#xA; Mathematical Programming Computation, 10, 383-421, 2018.&#xA;===========================================================================&#xA; This BARON run may utilize the following subsolver(s)&#xA; For LP/MIP/QP: CLP/CBC                                         &#xA; For NLP: IPOPT, FILTERSD, FILTERSQP&#xA;===========================================================================&#xA; Doing local search&#xA; Unable to find/load CPLEX library cplex12100.dll.&#xA; Unable to find/load CPLEX library cplex1290.dll.&#xA; Solving bounding LP&#xA; Starting multi-start local search&#xA; Done with local search&#xA;===========================================================================&#xA;  Iteration    Open nodes         Time (s)    Lower bound      Upper bound&#xA;          1             1             0.06    -68301.8         0.100000E+52&#xA;Clp0019I 1 variables/rows fixed as scaled bounds too close&#xA;&#xA;....&#xA;....&#xA;&#xA;Clp0019I 36 variables/rows fixed as scaled bounds too close&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="547" LastEditorUserId="547" LastEditDate="2020-04-17T21:27:08.553" LastActivityDate="2020-04-20T12:21:10.760" Title="BARON Error: variables/rows fixed as scaled bounds too close" Tags="|pyomo|baron|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3921" PostTypeId="1" CreationDate="2020-04-18T09:54:42.277" Score="1" ViewCount="105" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gnR0a.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gnR0a.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://i.stack.imgur.com/IVtq7.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IVtq7.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: updated my solution for linear programming&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain the following passage?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Both semiconductors and power generation industries also want to buy as many of the remaining units as possible&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How should I formulate the linear program with that?&lt;/p&gt;&#xA;" OwnerUserId="3369" LastEditorUserId="3369" LastEditDate="2020-04-18T12:02:47.270" LastActivityDate="2020-04-18T12:02:47.270" Title="Need help in formulating linear program" Tags="|linear-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3922" PostTypeId="1" CreationDate="2020-04-18T10:26:41.463" Score="7" ViewCount="273" Body="&lt;h1&gt;Idea&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Sometimes I encounter problems where Simplex spends many iterations for final convergence to the optimal objective value. Let's suppose, this happens when solving branch and bound-tree nodes as well. Could it be worthwhile to solve the dual of the node instead and limit the number of simplex iterations?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Expected results&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;If&lt;/em&gt; my thinking is correct, this could give you some useful information and increase the node throughput in pathological cases. While the non-optimal objective could be used as bound, we'd end up with lots of primal-infeasible solutions to nodes. Perhaps it's possible to completely solve only a subset?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Is this idea workable or did I miss something? Do you know of research in this direction?&lt;/p&gt;&#xA;" OwnerUserId="69" LastActivityDate="2020-04-18T17:53:36.717" Title="Is the iteration-limited Simplex dual solution of a MIP node useful?" Tags="|mixed-integer-programming|simplex|duality|literature-research|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3923" PostTypeId="2" ParentId="3922" CreationDate="2020-04-18T12:41:22.187" Score="6" Body="&lt;p&gt;Yes, you can solve the dual and use that as a (weaker) bound than the optimal solution of the LP. This leads to the trade off between faster processing nodes vs processing more nodes. This approach is often exemplified in the choice between Lagrangean relaxation and Dantzig Wolfe decomposition. In its pure form you need to solve the DW to optimality in order to get a valid bound (as the solution is obtained in primal space). In Lagrangean relaxation you always have a valid bound at hand and you do thus not need to solve the dual to optimality to get a valid bound. Stopping prematurely might however lead to a weak bound. &lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="123" LastEditDate="2020-04-18T13:34:24.320" LastActivityDate="2020-04-18T13:34:24.320" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3924" PostTypeId="2" ParentId="3922" CreationDate="2020-04-18T17:53:36.717" Score="6" Body="&lt;p&gt;It is common practice for MIP solvers to solve node LPs (other than at the root node) via dual simplex. I can't say with certainty that they terminate dual simplex prematurely if the objective value becomes inferior to the current incumbent, but I would think it likely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That does not address the question of stopping dual simplex early when the bound is weaker than the incumbent. If the node LPs are chewy, an alternative is to use some other algorithm (perhaps interior point) at nodes. Stopping dual simplex early not only would leave nodes lying around that could be pruned, but since you would be stopping with a primal-infeasible solution, it would leave unanswered the question of how the solver would make branching decisions at those nodes.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-04-18T17:53:36.717" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3926" PostTypeId="1" CreationDate="2020-04-19T06:43:29.653" Score="1" ViewCount="116" Body="&lt;p&gt;I have the following 2 stage Stochastic Programming program:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_x&amp;amp; \quad x+\sum_{s=1}^{3}p_sQ_s(x)\\\text{s.t.}&amp;amp;\quad x\in\Bbb R\\&amp;amp;\quad Q_s(x)=\min\left[\begin{pmatrix}1&amp;amp;6&amp;amp;−2\end{pmatrix}y_s\right]\\&amp;amp;\quad\text{s.t.}\quad\begin{pmatrix}2 &amp;amp; 0 &amp;amp;0 &amp;amp;\\1 &amp;amp;0 &amp;amp;−4\end{pmatrix}y_s=b_s−\begin{pmatrix}−2\\ 1\end{pmatrix}x\\&amp;amp;\qquad\qquad y_s\ge0,y_s\in\Bbb R^3.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$b_1=\begin{pmatrix}1 \\0 \end{pmatrix},b_2=\begin{pmatrix}0 \\ 1\end{pmatrix},b_3=\begin{pmatrix}−1 \\1\end{pmatrix}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_1=p_2=p_3=1/3$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I find the extreme rays and points in order to do Benders Decomposition? I really appreciate the help I can get! Thank you :)&lt;/p&gt;&#xA;" OwnerUserId="3366" LastEditorUserId="3366" LastEditDate="2020-04-19T08:35:16.250" LastActivityDate="2020-04-19T08:35:16.250" Title="How do I find the extreme rays and points for a stochastic programming problem" Tags="|optimization|stochastic-programming|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3927" PostTypeId="1" AcceptedAnswerId="3928" CreationDate="2020-04-19T23:46:57.063" Score="5" ViewCount="150" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$f:\mathbb{R}^n \mapsto \mathbb{R}$&lt;/span&gt; be a differentiable function. Suppose &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is a local minimizer of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; along every line that passes through &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;. This means that the function &lt;span class=&quot;math-container&quot;&gt;$$g(\alpha) = f(x^* + \alpha d)$$&lt;/span&gt; is being minimized for &lt;span class=&quot;math-container&quot;&gt;$\alpha = 0$&lt;/span&gt; for any direction &lt;span class=&quot;math-container&quot;&gt;$d \in \mathbb{R}^n$&lt;/span&gt;. It is easy to show that this implies &lt;span class=&quot;math-container&quot;&gt;$\nabla f(x^*) = 0$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; a local minimizer of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The answer is, it can be a local minimizer, maximizer, or a saddle point. I really don't get the reason. We are given that, for sufficiently small &lt;span class=&quot;math-container&quot;&gt;$\alpha&amp;gt;0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f(x^*) \leq f(x^* + \alpha d), \forall d \in \mathbb{R}^n$&lt;/span&gt;. Doesn't this also imply that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is a local minimizer?&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2020-04-20T14:15:32.390" Title="Local minimization of a function over a line" Tags="|optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3928" PostTypeId="2" ParentId="3927" CreationDate="2020-04-20T04:53:10.170" Score="6" Body="&lt;p&gt;Here is a counterexample:&lt;/p&gt;&#xA;&lt;p&gt;Consider &lt;span class=&quot;math-container&quot;&gt;$n=2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f(x,y)=(y+x^2)(y+2x^2)$&lt;/span&gt; where  and consider &lt;span class=&quot;math-container&quot;&gt;$(x^*, y^*)=(0,0)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}g_d(\alpha)&amp;amp;=f(\alpha d_1, \alpha d_2)\\&amp;amp;= (\alpha d_2 + (\alpha d_1)^2)(\alpha d_2 + 2(\alpha d_1)^2)\\&#xA;&amp;amp;= \alpha^2(d_2+\alpha d_1^2)(d_2+2\alpha d_1^2)\\&#xA;&amp;amp;= \alpha^2(2d_1^4\alpha^2 + 3d_2d_1^2\alpha+d_2^2) \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We know that &lt;span class=&quot;math-container&quot;&gt;$g_d(0)=0$&lt;/span&gt;, let's study what happens when &lt;span class=&quot;math-container&quot;&gt;$\alpha \ne 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$d_2=0$&lt;/span&gt;, then we have &lt;span class=&quot;math-container&quot;&gt;$g_d(\alpha ) \ge 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$d_2 \ne 0$&lt;/span&gt;, note that &lt;span class=&quot;math-container&quot;&gt;$2d_1^4\alpha^2 + 3d_2d_1^2\alpha + d_2^2&amp;gt;0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is small but non-zero, hence &lt;span class=&quot;math-container&quot;&gt;$g_d(\alpha)\ge 0$&lt;/span&gt; near the zero neighborhood.&lt;/p&gt;&#xA;&lt;p&gt;Hence &lt;span class=&quot;math-container&quot;&gt;$(0,0)$&lt;/span&gt; is a local minimizer of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; along every line.&lt;/p&gt;&#xA;&lt;p&gt;However,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f\left(x, -\frac32x^2\right) = \left(-\frac32x^2+x^2\right) \left(-\frac32x^2+2x^2\right)=-\frac14x^4\le 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In particular, we can let &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; be arbitarily small and non-zero.&lt;/p&gt;&#xA;&lt;p&gt;Hence &lt;span class=&quot;math-container&quot;&gt;$(0,0)$&lt;/span&gt; is not a local minimum.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YgHfJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YgHfJ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="85" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-04-20T14:15:32.390" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3929" PostTypeId="2" ParentId="3919" CreationDate="2020-04-20T11:11:05.267" Score="2" Body="&lt;p&gt;BARON is having trouble finding a feasible local solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$0.100000E+52$&lt;/span&gt; number is the default number used before the first feasible solution is found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The word &quot;scaled&quot; can be misleading here, Clp's output hints that your model's constraints are likely overdefined, which causes numerical instability in both the linear and non-linear solvers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fact that both solvers have trouble further indicates that the issue is with your linear constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is typically easily resolved by presolving the problem, although I don't know what linear presolving techniques are implemented in BARON (if any).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have access to BARON through AMPL or AIMMS, they will do the linear presolving for you before passing the problem to BARON. Since you are using PYOMO I'm guessing you don't, so your other option would be to try and do some of it yourself - AIMMS &lt;a href=&quot;https://download.aimms.com/aimms/download/references/AIMMS-Whitepaper-Presolver.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;have documented the basic algorithms quite nicely&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a first-order approach, just try the most basic thing first, which is called Singleton reduction. Detect if a variable is fixed (or nearly fixed), remove that variable from your model completely, and substitute it for that number everywhere in the problem. You should also save the number you used because, at the end of the solving process, you'll have to restore the problem to its original dimensionality to retrieve your solution.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-04-20T12:21:10.760" LastActivityDate="2020-04-20T12:21:10.760" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3930" PostTypeId="1" CreationDate="2020-04-20T21:32:40.100" Score="2" ViewCount="94" Body="&lt;p&gt;Is it possible that the binary variables below be modeled as continuous variables?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\max&amp;amp;\quad\sum _{{e\in E}}w(e_{j})\cdot y_{j}\\\text{s.t.}&amp;amp;\quad\sum {x_{i}}\leq k,\quad&amp;amp;(\text{no more than}\,\,k\,\,\text{sets are selected})\\&amp;amp;\quad{\sum _{e_{j}\in S_{i}}x_{i}\geq y_{j}},\quad&amp;amp;(\text{if}\,\,y_{j}&amp;gt;0\,\,\text{then at least one set}\,\,e_{j}\in S_{i}\,\,\text{is selected})\\&amp;amp;\quad{y_{j}\in \{0,1\}},\quad&amp;amp;(\text{if}\,\,y_{j}=1\,\,\text{then}\,\,e_{j}\,\,\text{is covered})\\&amp;amp;\quad{x_{i}\in \{0,1\}},\quad&amp;amp;(\text{if}\,\,x_{i}=1\,\,\text{then}\,\,S_{i}\,\,\text{is selected for the cover})\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3381" LastEditorUserId="3381" LastEditDate="2020-04-21T19:28:54.203" LastActivityDate="2020-04-22T00:12:12.747" Title="How to linearize a weighted maximum coverage problem?" Tags="|linearization|set-covering|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="3931" PostTypeId="2" ParentId="3930" CreationDate="2020-04-21T00:09:29.307" Score="2" Body="&lt;p&gt;I think there is no continuous form of the maximal covering location problem (MCLP) with a guarantee of providing the same optimal solution as the integer program. However, in addition to the formulation OP presented, &lt;a href=&quot;https://rsaiconnect.onlinelibrary.wiley.com/doi/10.1111/j.1435-5597.1974.tb00902.x&quot; rel=&quot;nofollow noreferrer&quot;&gt;Church &amp;amp; ReVelle (1974)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;&#xA; proposed a second formulation for the problem in their breakthrough paper, that is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}4 &#xA;\min &amp;amp;\quad z = \sum_{{j\in J}}w_j\cdot \bar y_{j}\\\text{s.t.}&amp;amp;\quad &#xA;\sum_{i \in N_j} {x_{i}} + \bar y_{j} \geq 1, \qquad \forall j \in J;\tag1\\&amp;amp;\quad &#xA;\sum_{i \in I} x_{i} = k; \tag2\\&amp;amp;\quad &#xA;{x_{i} \in \{0,1\}}, \qquad \forall i \in I;\tag3\\&amp;amp;\quad&#xA;{\bar y_{j} \in \{0,1\}}, \qquad \forall j \in J. \tag4\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and stated that this problem can be solved with continuous variables where both &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar y_{j}$&lt;/span&gt; are defined as non-negative. That way, in 80% of the cases the optimal solution of the linear program was equal to the zero-one solution in their computations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. In this formulation &lt;span class=&quot;math-container&quot;&gt;$N_j = \{i \in I | d_{ij} \leq S\}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\bar y_j = 1 - y_j$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; References: &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Church, Richard, and Charles ReVelle. &quot;The maximal covering location problem.&quot; Papers of the regional science association. Vol. 32. No. 1. Springer-Verlag, 1974. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-04-22T00:12:12.747" LastActivityDate="2020-04-22T00:12:12.747" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3932" PostTypeId="1" CreationDate="2020-04-21T01:42:03.560" Score="3" ViewCount="199" Body="&lt;p&gt;I've been doing a bit of inventory theory, and just wanted to know if I could interpret:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Tim has decided to keep enough safety stock to prevent a shortage before the delivery arrives during 95 percent of the order cycles.” as “Tim wanting to meet demand 95% of the time”?&lt;/p&gt;&#xA;" OwnerUserId="3366" LastEditorUserId="491" LastEditDate="2021-12-16T20:19:20.400" LastActivityDate="2021-12-16T20:19:20.400" Title="Inventory Theory" Tags="|inventory|rq-inventory-model|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3933" PostTypeId="1" CreationDate="2020-04-21T07:18:00.320" Score="9" ViewCount="695" Body="&lt;p&gt;I want to model a multiobjective TSP where the salesman can choose between a flight, train and bus to go from city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to city &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. The aim of this multiobjective optimization problem is to minimize the cost (ticket prices), travel time and carbon emissions. (After getting the modeling right, I want to solve this problem with multiobjective evolutionary algorithms like NSGA-II and MOEA-D.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem is applicable to tourists who are concerned about their carbon footprint while keeping their trip within budget and as comfortable as possible. For instance, a tourist doing a trip through Europe could choose whether to go by plane (short travel time, high carbon footprint) or by bus (the opposite) from city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to city &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, I have come up with the following model:&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$B_{ij}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$F_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T_{ij}$&lt;/span&gt; are all binary, and equal &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if a bus/flight/train (respectively) is taken from city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to city &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Indices&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is the number of cities/locations to be visited;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt; are the indices of cities that can take integer values from &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{{B}_{ij}}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p_{{T}_{ij}}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p_{{F}_{ij}}$&lt;/span&gt; are the prices in EUR for the bus/train/flight ticket respectively;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$e_{{B}_{ij}}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$e_{{T}_{ij}}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$e_{{F}_{ij}}$&lt;/span&gt; are the carbon dioxide levels emitted in kilograms by taking a bus/train/flight respectively to get from city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to city &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_{{B}_{ij}}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t_{{T}_{ij}}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t_{{F}_{ij}}$&lt;/span&gt; are the traveling times in minutes by taking a bus/train/flight respectively from city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to city &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Objective Functions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Minimize the cost &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min\sum_{i=1}^{N}\sum_{j=1}^{N}{\left(p_{B_{ij}}\cdot B_{ij}\right)+\left(p_{F_{ij}}\cdot T_{ij}\right)+\left(p_{T_{ij}}\cdot F_{ij}\right)}\tag1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Minimize carbon dioxide emissions &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min\sum_{i=1}^{N}\sum_{j=1}^{N}{\left(e_{B_{ij}}\cdot B_{ij}\right)+\left(e_{F_{ij}}\cdot T_{ij}\right)+\left(e_{T_{ij}}\cdot F_{ij}\right)}\tag2$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Minimize the traveling time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min\sum_{i=1}^{N}\sum_{j=1}^{N}{\left(t_{B_{ij}}\cdot B_{ij}\right)+\left(t_{F_{ij}}\cdot T_{ij}\right)+\left(t_{T_{ij}}\cdot F_{ij}\right)}\tag3$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\sum_{j=1\mid j\neq i}^NF_{ij}/T_{ij}/B_{ij}&amp;amp;=1,&amp;amp;\forall i=1,\ldots,N\tag4\\\sum_{i=1\mid i\neq j}^NF_{ij}/T_{ij}/B_{ij}&amp;amp;=1,&amp;amp;\forall j=1,\ldots,N\tag5\\\sum_{i,j\in S}F_{ij}/T_{ij}/B_{ij}&amp;amp;\le\left|S\right|-1,&amp;amp;\forall S\nsubseteq N\tag6\\F_{ij}/T_{ij}/B_{ij}&amp;amp;\in\left\{0,1\right\},&amp;amp;\forall i,j=1,\ldots,N\tag7\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Basically, I just adapted the classic TSP model and extended it by two more decision variables. But I am not sure if this would work, especially with the sub-tour elimination constraint (second last).&lt;/p&gt;&#xA;" OwnerUserId="3385" LastEditorUserId="3385" LastEditDate="2020-04-21T12:38:26.523" LastActivityDate="2020-04-25T02:09:23.507" Title="How to model a TSP where the salesman can choose between flight, train and bus for every single connection?" Tags="|traveling-salesman|multi-objective-optimization|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3934" PostTypeId="2" ParentId="3932" CreationDate="2020-04-21T12:05:42.227" Score="1" Body="&lt;p&gt;Yes, I believe you can interpret it like this. The term service level describes it well:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Service level is the probability that the amount of inventory on hand during the lead time is sufficient to meet expected demand – that is, the probability that a stockout will not occur.&#xA;  &lt;a href=&quot;https://www.skuvault.com/blog/safety-stock-formula/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Service Level&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Assuming we want to be able to meet 99.9% of the demand would require an disproportionately high safety stock which is not economical for any business. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2P8Uf.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2P8Uf.jpg&quot; alt=&quot;Relationship between safety stock increase and achieved service level&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This exponential relationship comes from the formula&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$SS = Z_\alpha \times \sqrt{L} \times \sigma$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$SS$&lt;/span&gt; is the safety stock, &lt;span class=&quot;math-container&quot;&gt;$Z_\alpha$&lt;/span&gt; is the inverse of the standard normal distribution for &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is the lead time (in weeks) and &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; is the cycle service level.&lt;/p&gt;&#xA;" OwnerUserId="3385" LastEditorUserId="123" LastEditDate="2020-04-21T15:20:22.820" LastActivityDate="2020-04-21T15:20:22.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3935" PostTypeId="1" AcceptedAnswerId="3941" CreationDate="2020-04-21T13:17:08.317" Score="6" ViewCount="156" Body="&lt;p&gt;Given two ellipsoids &lt;span class=&quot;math-container&quot;&gt;\begin{align}\mathcal{E}_1 &amp;amp;= \{ X \mid X^\top A_1 X + 2B_1^\top X + C_1 \leq 0\}\\\mathcal{E}_2 &amp;amp;= \{ X \mid X^\top A_2 X + 2 B_2^\top X + C_2 \leq 0\}\end{align}&lt;/span&gt; are both non-empty, it is possible to test if &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}_1 \subseteq \mathcal{E}_2$&lt;/span&gt;. Indeed, by the use of the so called &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;-procedure, &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}_1 \subseteq \mathcal{E}_2\iff\exists \lambda &amp;gt; 0$&lt;/span&gt; such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{bmatrix} A_2 &amp;amp;B_2\\ B_2^\top &amp;amp;C_2\end{bmatrix} \preceq \lambda \begin{bmatrix} A_1 &amp;amp;B_1 \\ B_1^\top &amp;amp;C_1\end{bmatrix}$$&lt;/span&gt;&#xA;See &lt;a href=&quot;https://web.stanford.edu/~boyd/cvxbook/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://web.stanford.edu/~boyd/cvxbook/&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Assume that &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}_1 \not\subseteq \mathcal{E}_2$&lt;/span&gt;. I want to find a point in &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}_1 \setminus \mathcal{E}_2$&lt;/span&gt;. How can I do that? I think one should follow the proof of the &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;-procedure (the necessity part) and eventually construct one on those lines. Can someone help?  &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Edit&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This paper might have an answer: Ye, Y. (n.d.). Quadratic Programming Over an Ellipsoid. Encyclopedia of Optimization, 2112–2116. doi:10.1007/0-306-48332-7_408&lt;/p&gt;&#xA;" OwnerUserId="3200" LastEditorUserId="3200" LastEditDate="2020-04-23T09:39:09.000" LastActivityDate="2020-04-25T07:16:23.297" Title="Find a point inside non-empty difference of ellipsoids" Tags="|algorithms|convex-optimization|feasible-points|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3936" PostTypeId="2" ParentId="3933" CreationDate="2020-04-21T15:51:12.007" Score="6" Body="&lt;p&gt;You can create three nodes for one city. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, &#xA;You create a bus station, train station, airport in one city. &#xA;If you arrive in city A with a train but leave with a plane, you have to move from the train station to Airport.&#xA;And then you can assign 0 (or appropriate quantities, emission or time) for moving between any of them within the same city. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There could be a better way to formulate because the number of nodes becomes 3 times in this way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And Multi-objective part, You cannot solve the problem with three objectives, like LP or MIP. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The multi-objective problem can be solved in several different ways. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Create one measure, You can add three numbers, with weights. &#xA;for example, you can create a measure, 20% of emission + 40% of time + 40% of the cost. and then Minimize the measure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Set two of them as constraints and minimize one. &#xA;For example, limit the amount of emission. Total emission should be less than a certain amount. And total cost should be less than $5000. and Minimize the travel time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Find Pareto optimal solutions. (Find Efficiency frontier)&#xA;Find solutions that are not dominated by any other solutions. &#xA;Let the decision-maker to choose the solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a lot more in detail. Take a course or read a book in &quot;Multi-Objective Optimization&quot;&lt;/p&gt;&#xA;" OwnerUserId="217" LastEditorUserId="217" LastEditDate="2020-04-21T16:05:46.500" LastActivityDate="2020-04-21T16:05:46.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3937" PostTypeId="2" ParentId="3935" CreationDate="2020-04-21T16:26:46.077" Score="1" Body="&lt;p&gt;This is a feasibility problem, find &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$$X^TA_1 X + 2B_1^TX + C_1 \leq 0, X^T A_2 X + 2 B_2^T X + C_2 \gt 0$$&lt;/span&gt;.In general it will be non-convex (although it is convex if &lt;span class=&quot;math-container&quot;&gt;$A_1$&lt;/span&gt; is positive semidefinite and &lt;span class=&quot;math-container&quot;&gt;$A_2$&lt;/span&gt; is negative semidefinite; however, given mention of &quot;ellipsoid&quot;, it seems reasonable to presume that &lt;span class=&quot;math-container&quot;&gt;$A_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_2$&lt;/span&gt; are both positive semidefinite). It's also a bit tricky due to the strict inequality in the 2nd constraint. In practice, you will need to change that to &lt;span class=&quot;math-container&quot;&gt;$$X^T A_2 X + 2 B_2^T X + C_2 +\text{small_positive_number} \ge 0,$$&lt;/span&gt;and deal with the possibility of the only (what should be) feasible point requiring a smaller positive number. Alternatively, you could solve a QCQP which is to maximize the LHS (without small_positive_number) of the 2nd constraint, subject to the first constraint; and determine the original problem to be solved if this problem has positive optimal objective function - but this generally involves more computing than solving the original feasibility problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the convex case (&lt;span class=&quot;math-container&quot;&gt;$A_1$&lt;/span&gt; positive semidefinite and &lt;span class=&quot;math-container&quot;&gt;$A_2$&lt;/span&gt; negative semidefinite, which given my previous remark, seems unlikely to occur, unless &lt;span class=&quot;math-container&quot;&gt;$A_2$&lt;/span&gt; is degenerate), you can use a convex QCQP or SOCP solver, and can formulate the problem using a convex optimization tool.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the non-convex case (which from a practical perspective, you should always be in), you can always try using a local optimizer, and if it succeeds, you're done. However, it could fail even when there truly is a feasible point. In order to &quot;guarantee&quot; finding a feasible value if one exists, you should use a global solver, such as BARON or Gurobi 9.x (which can find global optimum of non-convex quadratics) or CPLEX with optimalitytarget = 3 (if the alternative optimization formulation is used, because that moves the non-convexity from the constraints to the objective function, where it is allowed by CPLEX).&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-04-21T18:35:35.783" LastActivityDate="2020-04-21T18:35:35.783" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3938" PostTypeId="1" AcceptedAnswerId="3948" CreationDate="2020-04-22T00:15:34.013" Score="5" ViewCount="93" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{j}(t)=1$&lt;/span&gt; iff job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is scheduled at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. I want to say that if the job is scheduled at all, then it is scheduled at &lt;span class=&quot;math-container&quot;&gt;$n_j$&lt;/span&gt; slots. I wrote this as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{j}(t)\sum_{s=1}^{T}x_{j}(s)=n_jx_{j}(t).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to write this as linear constraints?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I am maximizing the number of jobs to be scheduled, can we do any better?&lt;/p&gt;&#xA;" OwnerUserId="3075" LastEditorUserId="3075" LastEditDate="2020-04-22T02:20:34.267" LastActivityDate="2020-04-22T19:08:26.567" Title="Requiring exactly $n_j$ slots for job $j$ (if scheduled)" Tags="|linear-programming|integer-programming|binary-variable|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3939" PostTypeId="2" ParentId="3938" CreationDate="2020-04-22T00:57:49.037" Score="6" Body="&lt;p&gt;Introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; to indicate whether &lt;span class=&quot;math-container&quot;&gt;$x_j(t)&amp;gt;0$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, and impose linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{t=1}^T x_j(t) = n_j y_j$$&lt;/span&gt; &lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-04-22T00:57:49.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3940" PostTypeId="2" ParentId="3938" CreationDate="2020-04-22T01:07:20.983" Score="5" Body="&lt;p&gt;We need an indicator of whether a job is ever scheduled at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y_j=\begin{cases} 1, &amp;amp; \sum\limits_{t=1}^Tx_j(t)&amp;gt;0 \\ 0, &amp;amp;\sum\limits_{t=1}^Tx_j(t)=0\end{cases}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{t=1}^T x_j(t) = n_jy_j$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, you want to maximize the number of jobs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad\sum_j y_j\\\text{s.t.}&amp;amp;\quad\sum_{t=1}^T x_j(t) = n_jy_j\\&amp;amp;\quad x_j(t), y_j \in \{0,1\}.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="85" LastEditorUserId="123" LastEditDate="2020-04-22T07:56:50.077" LastActivityDate="2020-04-22T07:56:50.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3941" PostTypeId="2" ParentId="3935" CreationDate="2020-04-22T05:38:16.210" Score="5" Body="&lt;p&gt;Define quadratic functions &lt;span class=&quot;math-container&quot;&gt;$g_1(X)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_2(X)$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;\begin{align}\mathcal{E}_1 &amp;amp;= \{ X \mid g_1(X) \le 0\}\\\mathcal{E}_2 &amp;amp;= \{ X \mid g_2(X) \le 0\}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It follows from the definition that you can find a point in &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}_1 \setminus \mathcal{E}_2$&lt;/span&gt; by solving&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align} \min &amp;amp;\quad -g_2(X)\\\text{s.t.} &amp;amp;\quad g_1(X) \le 0.\end{align}$$&lt;/span&gt;&#xA;Informally, you find the point in &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}_1$&lt;/span&gt; with the maximum (scaled) distance from the center of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}_2$&lt;/span&gt;. If the optimal value of &lt;span class=&quot;math-container&quot;&gt;$-g_2(X) &amp;lt; 0$&lt;/span&gt;, then this point is not in &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}_2$&lt;/span&gt;, as required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem above is not obviously convex: if &lt;span class=&quot;math-container&quot;&gt;$g_1(X)$&lt;/span&gt; is convex, then the objective &lt;span class=&quot;math-container&quot;&gt;$-g_1(X)$&lt;/span&gt; is typically not convex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in this special case (and under some technical assumptions) the S-lemma can be used to reformulate this problem as a convex problem!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For details, see Theorem 2.2 in the &lt;a href=&quot;https://doi.org/10.1137/S003614450444614X&quot; rel=&quot;nofollow noreferrer&quot;&gt;survey by Pólik and Terlaky&lt;/a&gt;, for example. I personally find the lecture notes of lecture 12 &lt;a href=&quot;http://aaa.princeton.edu/orf523&quot; rel=&quot;nofollow noreferrer&quot;&gt;provided here&lt;/a&gt; very helpful.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; As pointed out by C Marius and Mark L. Stone, the approach above does not actually result in a point &lt;span class=&quot;math-container&quot;&gt;$X \in \mathcal{E}_1 \setminus \mathcal{E}_2$&lt;/span&gt;. Instead, it answers whether such a point exists. I looked further into this, and it turns out you can actually recover a point &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; after solving the reformulated problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1007/s10898-012-9917-0&quot; rel=&quot;nofollow noreferrer&quot;&gt;In this paper&lt;/a&gt;, Tuy and Tuan present the S-lemma as a strong duality theorem for specific non-convex problems, including the one above. In this specific case, we have (ignoring some technical details):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\inf_{X\in \mathbb{R}^n} \sup_{\lambda\ge 0} \{-g_2(X) + \lambda g_1(X)\} = \sup_{\lambda\ge 0} \inf_{X\in \mathbb{R}^n} \{-g_2(X) + \lambda g_1(X)\}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The left-hand side is the &lt;em&gt;primal problem&lt;/em&gt;, which is equivalent to the optimization problem stated at the top (&lt;span class=&quot;math-container&quot;&gt;$g_1(X) \le 0$&lt;/span&gt; is optimal, because otherwise &lt;span class=&quot;math-container&quot;&gt;$\lambda \rightarrow \infty$&lt;/span&gt; would send the objective to &lt;span class=&quot;math-container&quot;&gt;$+\infty$&lt;/span&gt;). The right-hand side is the &lt;em&gt;dual problem&lt;/em&gt;, which is equivalent to the convex reformulation mentioned above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After solving the dual problem (the convex reformulation), we obtain an optimal dual value &lt;span class=&quot;math-container&quot;&gt;$\bar{\lambda}$&lt;/span&gt;. You then recover a primal solution in a similar way as for linear programming: by using the optimality conditions (Tuy and Tuan, Theorem 3):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$-\nabla g_2(X) + \bar{\lambda} \nabla g_1(X) = 0 \wedge \bar{\lambda} g_1(X) = 0 \wedge g_1(X) \le 0.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; Consider two ellipses, given by &lt;span class=&quot;math-container&quot;&gt;$A_1 = I$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B_1 = (-1, 0)^\top$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$C_1 = 0$&lt;/span&gt; (blue circle), and &lt;span class=&quot;math-container&quot;&gt;$A_2 = I$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B_1 = 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$C_2 = -1$&lt;/span&gt; (red circle)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cQzBy.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cQzBy.gif&quot; alt=&quot;Ellipse example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The dual is given by&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align} \max_{V, \lambda} &amp;amp;\quad V\\&#xA;\text{s.t.} &amp;amp;\quad \begin{bmatrix} \lambda A_1 - A_2 &amp;amp; \lambda B_1 - B_2 \\ (\lambda B_1 - B_2)^\top &amp;amp; \lambda C_1 - C_2 - V \end{bmatrix} \succeq 0 \\&#xA;~&amp;amp;~\lambda \ge 0.\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solving this SDP yields the solution &lt;span class=&quot;math-container&quot;&gt;$V = -3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{\lambda} = 2$&lt;/span&gt;. As &lt;span class=&quot;math-container&quot;&gt;$V &amp;lt; 0$&lt;/span&gt;, there exists an &lt;span class=&quot;math-container&quot;&gt;$X \in \mathcal{E}_1 \setminus \mathcal{E}_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we use the first of the optimality conditions, we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-\nabla g_2(X) + \bar{\lambda} \nabla g_1(X) = 2 (\bar{\lambda}  A_1 - A_2)X + 2(\bar{\lambda} B_1 - B_2) = 2IX - (-4, 0)^\top = 0,$$&lt;/span&gt;&#xA;which solves for &lt;span class=&quot;math-container&quot;&gt;$\bar{X} = (2,0)^\top$&lt;/span&gt;. It is easy to check that the other conditions are also satisfied, which means that &lt;span class=&quot;math-container&quot;&gt;$\bar{X}$&lt;/span&gt; is a primal optimal solution. Indeed, &lt;span class=&quot;math-container&quot;&gt;$\bar{X} \in \mathcal{E}_1 \setminus \mathcal{E}_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the picture, the yellow circle corresponds to the ellipse &lt;span class=&quot;math-container&quot;&gt;$g_2(X) = -V$&lt;/span&gt;. This ellipse intersects &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}_1$&lt;/span&gt; at the maximum (weighted) distance from the center of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}_2$&lt;/span&gt;. Their intersection is exactly the point &lt;span class=&quot;math-container&quot;&gt;$\bar{X}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have omitted various technical details, for which I refer to the references.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="123" LastEditDate="2020-04-25T07:16:23.297" LastActivityDate="2020-04-25T07:16:23.297" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3942" PostTypeId="1" AcceptedAnswerId="3943" CreationDate="2020-04-22T10:43:17.827" Score="4" ViewCount="596" Body="&lt;p&gt;Suppose you are writing a paper about a certain new problem class. You have certain problem instances of different size (real-world as well as random) given. You developed different integer programming problem formulations for this problem and want to compare the performance of these models in the paper. (I would also be interested if something changes if we compare different algorithms, i.e. Benders Decomposition vs naive MIP formulation)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you want to present statistics to compare the performance of the different models.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An incomplete list of some things come to my mind are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Value of LP Relaxation&lt;/li&gt;&#xA;&lt;li&gt;Gap&lt;/li&gt;&#xA;&lt;li&gt;Time to first solution&lt;/li&gt;&#xA;&lt;li&gt;Gap of first solution to optimal solution&lt;/li&gt;&#xA;&lt;li&gt;when is the optimal solution found&lt;/li&gt;&#xA;&lt;li&gt;Time to solve the model&lt;/li&gt;&#xA;&lt;li&gt;Number of solved models&lt;/li&gt;&#xA;&lt;li&gt;Performance profiles&lt;/li&gt;&#xA;&lt;li&gt;Number of branch and bound nodes&lt;/li&gt;&#xA;&lt;li&gt;Primal/Dual integral&lt;/li&gt;&#xA;&lt;li&gt;....&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and there are many more, but what are the most important statistics which you want to display (and in what form) to give a convincing picture of the performance of the different models without overloading it with too much statistic.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2020-04-23T00:20:35.580" Title="What are the most useful evaluation metrics when comparing the performance of different model formulations" Tags="|optimization|mixed-integer-programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3943" PostTypeId="2" ParentId="3942" CreationDate="2020-04-22T15:14:03.157" Score="8" Body="&lt;p&gt;After 20 years of practice of ORMS (= serving industrial and business clients), we observe that 99% of users of optimization software are &lt;em&gt;first&lt;/em&gt; interested in the best solution found in K seconds, with K being on average 60. This is the must have. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having good lower bounds (even with longer running times, minutes or hours) is a nice to have, mostly in the development and early production phases, to reassure the stakeholders - in particular the users - about the quality of solutions delivered. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it often appears that solutions mathematically proved to be optimal are not good for the users. This is just because the mathematical optimization model is well not in line with the business needs. This is why in the practice of ORMS &quot;modeling remains the master and computation the servant&quot; as John N. Hooker well said. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this is just what (we observe and then think that) people want in real life. For research purposes, we let the researchers express themselves.  &lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-04-22T15:14:03.157" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="3944" PostTypeId="2" ParentId="3933" CreationDate="2020-04-22T15:52:18.120" Score="0" Body="&lt;p&gt;Your problem can be modeled in a different way that the one you proposed above, by following a set-based modeling approach instead of the classical Boolean modeling approach. This is a modeling approach offered by LocalSolver, a new kind of solver, different from traditional MILP solvers. Please note that LocalSolver is a commercial software. Nevertheless, it is free for faculty and students. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the code snippet to model the classical TSP problem in Python:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;    # Open the optimization model&#xA;    model = ls.model&#xA;&#xA;    # List variable: cities[i] is the index of the ith city in the tour&#xA;    cities = model.list(nb_cities) &#xA;&#xA;    # Constraint: all cities must be visited&#xA;    model.constraint(model.count(cities) == nb_cities)&#xA;&#xA;    # Array to store the distance matrix&#xA;    distance_array = model.array(distance_weight)&#xA;&#xA;    # Objective: minimize the total traveled distance&#xA;    dist_selector = model.lambda_function(&#xA;        lambda i: model.at(distance_array, cities[i-1], cities[i]))&#xA;    obj = (model.sum(model.range(1, nb_cities), dist_selector)&#xA;        + model.at(distance_array, cities[nb_cities - 1], cities[0]))&#xA;    model.minimize(obj)&#xA;&#xA;    # Close the optimization model&#xA;    model.close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The complete code, as well as the corresponding codes for Java, C#, C++ are given here:  &lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/tsp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.localsolver.com/docs/last/exampletour/tsp.html&lt;/a&gt;. Having followed this modeling approach, LocalSolver finds quality solutions (optimality gap less than 1%) in a few minutes on a standard computer for TSP instances with 1,000 cities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an introduction to set/list-based modeling approach for combinatorial optimization, have a look to &lt;a href=&quot;https://www.localsolver.com/docs/last/advancedfeatures/collectionvariables.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.localsolver.com/docs/last/advancedfeatures/collectionvariables.html&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2020-04-23T22:38:41.797" LastActivityDate="2020-04-23T22:38:41.797" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3945" PostTypeId="2" ParentId="3932" CreationDate="2020-04-22T16:18:01.197" Score="2" Body="&lt;p&gt;I think the two ways of phrasing it are slightly different:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;prevent a shortage before the delivery arrives during 95 percent of the order cycles&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;means that in the long run, there will be a stockout in 5% of the order cycles, whereas&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;meet demand 95% of the time&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;is a little ambiguous, but to me it suggests you want to meet 95% of the demands, i.e., stock out for 5% of the demands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first measure is the &lt;strong&gt;type-1 service level&lt;/strong&gt; (or cycle service level), while the second is the &lt;strong&gt;type-2 service level&lt;/strong&gt; (or fill rate). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two are not the same. For example, if you have 1,000,000 demands per order cycle and you stock out on exactly 1 of them per order cycle, then your type-1 SL is 0% (because you have a stockout in &lt;em&gt;every&lt;/em&gt; cycle) while your type-2 SL is nearly 100% (because you meet virtually every demand from stock).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The formula that @KevinG included is the safety stock required to meet the type-1 service level (which, it seems, is the service level that the original statement was referring to). But I disagree that the two statements in your original question are equivalent.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-04-22T16:18:01.197" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3947" PostTypeId="1" CreationDate="2020-04-22T18:56:38.290" Score="4" ViewCount="87" Body="&lt;p&gt;Suppose we are minimizing &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;. The first order necessary condition of &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; being local minmum is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\nabla f(x^*)= \mathbf{0}.$$&lt;/span&gt;&#xA;For sufficiency, we check if also &lt;span class=&quot;math-container&quot;&gt;$\nabla^2f(x^*) \succ 0$&lt;/span&gt;, i.e., the Hessian is positive definite at &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;. I know that if &lt;span class=&quot;math-container&quot;&gt;$\nabla^2f(x^*) \prec 0$&lt;/span&gt; then this is a local maximizer. Moreover, if it is indefinite, &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is a saddle point. Finally, the sufficiency condition fails to classify if &lt;span class=&quot;math-container&quot;&gt;$\nabla^2 f(x^*) \succeq 0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\nabla^2f(x^*)\preceq 0$&lt;/span&gt; but not strictly positive/negative definite. So &lt;strong&gt;semi-&lt;/strong&gt; definiteness makes it not possible to conclude.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I want to see such a situation in constrained optimization. Assume we are minimizing &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; over some &lt;span class=&quot;math-container&quot;&gt;$h(x) \leq 0, \ g(x) =0$&lt;/span&gt;. The necessary condition of &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; being a local minimum is (given that this point is a regular point) satisfying the KKT conditions. It is known that a regular point &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; satisfying KKT conditions is local minimizer if it also satisfies:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$s^\top \nabla_{xx}^2 L(x^*, \lambda^*, \rho^*)s &amp;gt;0 $$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$s \neq 0$&lt;/span&gt; such that:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{bmatrix} \frac{\partial g(x^*)}{\partial x} \\ \frac{\partial h_a(x^*)}{\partial x} \end{bmatrix} s = \mathbf{0}.$$&lt;/span&gt;&#xA;Here, &lt;span class=&quot;math-container&quot;&gt;$h_a$&lt;/span&gt; denotes the set of active inequality constraints at &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;. Also &lt;span class=&quot;math-container&quot;&gt;$\lambda^*, \rho^*$&lt;/span&gt; are the optimal Lagrange multipliers corresponding to the inequality and equality constraints (but unnecessary detail here).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, for all &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; satisfying the second condition if we have &lt;span class=&quot;math-container&quot;&gt;$s^\top \nabla_{xx}^2 L(x^*, \lambda^*, \rho^*)s &amp;lt;0 $&lt;/span&gt; then we have a local maximizer. My question is, is there any way to conclude 'saddle point' or 'not enough evidence to classify' as in the unconstrained case? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I say if for some of the &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; values we have &lt;span class=&quot;math-container&quot;&gt;$s^\top \nabla_{xx}^2 L(x^*, \lambda^*, \rho^*)s &amp;gt;0$&lt;/span&gt; and for some others we have &lt;span class=&quot;math-container&quot;&gt;$s^\top \nabla_{xx}^2 L(x^*, \lambda^*, \rho^*)s = 0 $&lt;/span&gt; is this non-concludable? And similarly, if we have some &lt;span class=&quot;math-container&quot;&gt;$s^\top \nabla_{xx}^2 L(x^*, \lambda^*, \rho^*)s &amp;gt; 0 $&lt;/span&gt; and some &lt;span class=&quot;math-container&quot;&gt;$s^\top \nabla_{xx}^2 L(x^*, \lambda^*, \rho^*)s &amp;lt; 0 $&lt;/span&gt;, is this definitely something like a constrained saddle point?&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2020-04-22T18:56:38.290" Title="Identifying saddle point in constrained optimization" Tags="|optimization|nonlinear-programming|kkt-conditions|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3948" PostTypeId="2" ParentId="3938" CreationDate="2020-04-22T19:08:26.567" Score="2" Body="&lt;p&gt;If you need consecutive slots, one way to model it is to redefine &lt;span class=&quot;math-container&quot;&gt;$x_j(t)$&lt;/span&gt; to indicate the start at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$n_h$&lt;/span&gt; consecutive slots occupied by &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. The &quot;&lt;span class=&quot;math-container&quot;&gt;$n_j$&lt;/span&gt; or none&quot; constraint then becomes &lt;span class=&quot;math-container&quot;&gt;$$\sum_{t=1}^{T-n_j+1} x_j(t)\le 1\quad\forall j$$&lt;/span&gt;or, if you need a binary indicator &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; for whether &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; gets scheduled, &lt;span class=&quot;math-container&quot;&gt;$$\sum_{t=1}^{T-n_j+1}x_j(t)=y_j\quad\forall j.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-04-22T19:08:26.567" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3949" PostTypeId="1" AcceptedAnswerId="3951" CreationDate="2020-04-22T20:36:01.153" Score="3" ViewCount="240" Body="&lt;p&gt;For the following function, I am testing the convexity in &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;. All parameters are in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^+$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{\left(- \lambda \left(b + \frac{p}{\beta}\right) + 1\right) \left(\left(1 + \frac{p}{\beta}\right) \left(b^{2} \lambda^{2} + \frac{2 b \lambda^{2} p}{\beta} + \frac{2 \lambda^{2} p}{\beta^{2}}\right) + \left(2 b \lambda \left(1 + \frac{p}{\beta}\right) + 2 \lambda p \left(\frac{1}{\beta} + \frac{1}{\beta^{2}}\right)\right) \left(- b \lambda + 1 - \frac{\lambda p}{\beta}\right)\right)}{2 \left(1 + \frac{p}{\beta}\right) \left(- b \lambda + 1 - \frac{\lambda p}{\beta}\right)^{2}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used Sympy to see the second derivative with respect to &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; as follows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$- \frac{\beta \left(b^{2} \beta^{2} + 2 b \beta p + 2 p\right)}{b^{3} \beta^{3} \lambda^{3} - 3 b^{2} \beta^{3} \lambda^{2} + 3 b^{2} \beta^{2} \lambda^{3} p + 3 b \beta^{3} \lambda - 6 b \beta^{2} \lambda^{2} p + 3 b \beta \lambda^{3} p^{2} - \beta^{3} + 3 \beta^{2} \lambda p - 3 \beta \lambda^{2} p^{2} + \lambda^{3} p^{3}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since there are lots of terms, it is not easy to understand whether it is &lt;span class=&quot;math-container&quot;&gt;$\geq 0$&lt;/span&gt; or not. I set some values for &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; to see how it goes. When &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is very small (e.g., &lt;span class=&quot;math-container&quot;&gt;$p=0.00001$&lt;/span&gt;), &lt;span class=&quot;math-container&quot;&gt;$\beta = 0.021$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$b=0.0021$&lt;/span&gt;, it seems to be convex. But, is there any way to make sure convexity (if true) without setting values to other parameters?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have a condition for the domain of the parameters: &lt;span class=&quot;math-container&quot;&gt;$\frac{\lambda \left(b + \frac{p}{\beta}\right)}{1 + \frac{p}{\beta}}&amp;lt;1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the answer, I minimized the second derivative subject to non-negativity constraint and the condition with the following code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.environ import *&#xA;&#xA;m= ConcreteModel('Convexity')&#xA;&#xA;m.lmbda = Var(domain=NonNegativeReals)&#xA;m.beta = Var(domain=NonNegativeReals)&#xA;m.b = Var(domain=NonNegativeReals)&#xA;m.p = Var(domain=NonNegativeReals)&#xA;&#xA;m.OBJ = Objective(expr = (-m.beta*(m.b**2*m.beta**2 &#xA;+ 2*m.b*m.beta*m.p + 2*m.p)/&#xA;                         (m.b**3*m.beta**3*m.lmbda**3 - &#xA;                        3*m.b**2*m.beta**3*m.lmbda**2 + &#xA;                          3*m.b**2*m.beta**2*m.lmbda**3*m.p + &#xA;                        3*m.b*m.beta**3*m.lmbda &#xA;                        - 6*m.b*m.beta**2*m.lmbda**2*m.p &#xA;                        + 3*m.b*m.beta*m.lmbda**3*m.p**2 &#xA;                          - m.beta**3 + 3*m.beta**2*m.lmbda*m.p &#xA;                        - 3*m.beta*m.lmbda**2*m.p**2 + m.lmbda**3*m.p**3)), &#xA;                        sense=minimize)&#xA;&#xA;def Traffic(m):&#xA;    return ((m.lmbda*(m.b+m.p/m.beta))/(1+m.p/m.beta) &amp;lt;= 0.99999999999)&#xA;&#xA;m.AxbConstraint = Constraint(rule=Traffic)&#xA;&#xA;opt = SolverFactory('ipopt', tee=True)&#xA;print(opt.solve(m))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output log and the objective value is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Problem: &#xA;- Lower bound: -inf&#xA;  Upper bound: inf&#xA;  Number of objectives: 1&#xA;  Number of constraints: 1&#xA;  Number of variables: 4&#xA;  Sense: unknown&#xA;Solver: &#xA;- Status: ok&#xA;  Message: Ipopt 3.11.1\x3a Optimal Solution Found&#xA;  Termination condition: optimal&#xA;  Id: 0&#xA;  Error rc: 0&#xA;  Time: 0.18944215774536133&#xA;Solution: &#xA;- number of solutions: 0&#xA;  number of solutions displayed: 0&#xA;&#xA;Objective Value: 3.302498039268864e-09&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="518" LastEditorUserId="518" LastEditDate="2020-04-23T01:44:27.243" LastActivityDate="2020-04-23T01:44:27.243" Title="Convexity Analysis" Tags="|python|convexity|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3950" PostTypeId="2" ParentId="3942" CreationDate="2020-04-23T00:13:35.757" Score="1" Body="&lt;p&gt;The most powerful metric is to prove the power of a formulation theoretically, e.g., that the relaxation of formulation A will always be at least as tight as the relaxation of formulation B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solvers use a lot of black magic, so in order for an empirical comparison to be scientifically valid you want to eliminate any factors that are implementation-sensitive, or dependent on design choices such as primal heuristics, or acceleration heuristics. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also not rigorous to use a solver that you didn't write yourself (or is open source) to make such comparisons, unless you can justify with certainty what the solver is doing and why it's producing the behaviour that you are observing. Otherwise, what you are publishing is only really useful for that solver's developers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Metrics that are &lt;em&gt;less&lt;/em&gt; implementation-sensitive&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Relaxation lower bound at the root node (assuming minimisation problem)&lt;/li&gt;&#xA;&lt;li&gt;Size of the relaxation&lt;/li&gt;&#xA;&lt;li&gt;Size of presolved model&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Metrics that are &lt;em&gt;very&lt;/em&gt; implementation-sensitive&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Convergence rate&lt;/li&gt;&#xA;&lt;li&gt;Optimality gap&lt;/li&gt;&#xA;&lt;li&gt;Time/ability to find a feasible point&lt;/li&gt;&#xA;&lt;li&gt;Number of nodes explored&lt;/li&gt;&#xA;&lt;li&gt;Performance profiles&lt;/li&gt;&#xA;&lt;li&gt;Solution time&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Most of the latter are dependent on the choice of branching strategy, acceleration heuristics, primal heuristics, scalability of algorithms used in the solver, and whether a certain formulation is triggering a bottleneck inside the solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can run statistical analysis on large problem test sets and test solver behavior on one formulation vs another, and then any metric goes really because you enter number-fudging territory. In this case beware, because all this comparison is telling you is how the change in formulation affected that specific solver in that specific problem set, &lt;strong&gt;unless you can credibly justify the solver's behavior&lt;/strong&gt;. Even if your formulation is on average 100 times faster, you can not attribute that to the formulation unless you know what exactly the solver is (or is not) doing.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-04-23T00:20:35.580" LastActivityDate="2020-04-23T00:20:35.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3951" PostTypeId="2" ParentId="3949" CreationDate="2020-04-23T00:51:16.573" Score="5" Body="&lt;p&gt;Proving convexity is a global optimisation problem. In this case you are fortunate in that there is only one variable in your function so you can get the second derivative analytically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The practical way to get an answer for this is to define ranges for all your parameters (which will now be variables), and solve the second derivative formula as a global optimisation problem, subject to your parameter constraint. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any decent global optimisation solver should solve this instantly - if the solution is greater than zero, you have your answer for that parameter range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a theoretical point of view, that function is only positive iff the denominator is negative, which is not true in general, but might be true for specific ranges of &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and your parameters.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-04-23T00:51:16.573" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="3952" PostTypeId="1" CreationDate="2020-04-23T08:29:37.310" Score="52" ViewCount="13737" Body="&lt;p&gt;I am giving a small computer exercise that aims at teaching students the basics of a modelling language to model small optimization problems. So far I have been using the modelling language GAMS as this is used in many companies in industry.&lt;/p&gt;&#xA;&lt;p&gt;To be totally honest, I have never been a big fan of GAMS mainly because I'd prefer to use a general-purpose programming language for optimization instead of a pure modelling language. Now I am thinking about using either Python or Julia for teaching.&lt;/p&gt;&#xA;&lt;p&gt;The problem is that I really do not know if Julia or Python are used in the industry for optimization. So the question is not if those programming languages are generally used (of course, I know about the Python hype), it is about whether those languages are also used for operations research in industry. In fact on the webpage of Julia &lt;a href=&quot;https://juliacomputing.com/case-studies/&quot; rel=&quot;noreferrer&quot;&gt;several case studies are listed&lt;/a&gt;, however I could not find many case studies from industry for Python.&lt;/p&gt;&#xA;&lt;p&gt;What is your opinion towards this and what experience have you made? If I choose to use Python or Julia, can I tell students that they are (strongly) used in industry to motivate them? Which of those would you choose (or just proceed with GAMS)?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="8" LastEditDate="2020-09-04T09:43:28.160" LastActivityDate="2024-04-04T02:40:35.940" Title="Are Python and Julia used for optimization in industry?" Tags="|python|gams|julia|industry|" AnswerCount="15" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3953" PostTypeId="1" CreationDate="2020-04-23T08:37:24.070" Score="4" ViewCount="804" Body="&lt;p&gt;I am working on a rail scheduling problem that moves product from a production plant to a storage facility to satisfy demand. I am new to PuLP so finding this difficult to understand why this isn't working, and unfortunately there is very little documentation on the subject.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are three decision variables to monitor:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The availability/inventory of product at each plant - note each plant can manufacture different products.&lt;/li&gt;&#xA;&lt;li&gt;Rail - how much to move of each product from each plant. Each train can move 8400 tons.&lt;/li&gt;&#xA;&lt;li&gt;The inventory of product at the storage facility. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Upon running the program, the rail decision variable works correctly i.e. the output is as expected, however the inventory at the plant and storage facility is not showing the amount removed and subsequently added by the rail. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Data as per below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#rail capacity df (plant: no_trains_per_day)&#xA;rail_capacity_df_daily = {'ABC': 3,&#xA;'DEF':1}&#xA;&#xA;# facilities_df&#xA;facilities_inventory = {'BZL': 98057,&#xA; 'AFM': 8663,&#xA; 'PRE': 28997}&#xA;&#xA;facilities_max = {'BZL': 210000,&#xA; 'AFM': 190000,&#xA; 'PRE': 245000}&#xA;&#xA;# plants_df&#xA;plant_df_inventory = {('ABC', 'PRE'): 196710,&#xA; ('ABC', 'AFM'): 197940,&#xA; ('DEF', 'BZL'): 294750,&#xA; ('DEF', 'PRE'): 129180}&#xA;&#xA;# Plant production daily&#xA;plants_production_daily = {('ABC', 'PRE'): 6000,&#xA;     ('ABC', 'AFM'): 1000,&#xA;     ('DEF', 'BZL'): 5000,&#xA;     ('DEF', 'PRE'): 4000} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# PLANNING HORIZON PARAMS  &#xA;_current_date = pd.to_datetime(datetime.datetime.today().strftime('%Y%m%d'))&#xA;planning_horizon_max = datetime.datetime.today() + datetime.timedelta(30)&#xA;planning_horizon_max = pd.to_datetime(planning_horizon_max.strftime('%Y%m%d'))&#xA;&#xA;# COMBINATION VARS&#xA;dates = [d.strftime('%F') for d in pd.date_range(_current_date,planning_horizon_max)]&#xA;&#xA;# INVENTORY &#xA;# Initial Storage Inventory&#xA;storage_inv = dict(zip(facilities_df.index, &#xA;                       facilities_df['current']))&#xA;# Initial Plant Inventory&#xA;plant_current_inventory = dict(zip(plant.index, plant.inventory))&#xA;&#xA;# DECISION VARIABLES&#xA;# Plant facility vars&#xA;plant_inventory_vars = pulp.LpVariable.dicts(&#xA;    'Plant Inventory',&#xA;    ((date, plant, product) for date in dates for (plant, product) in plant_combinations),&#xA;    cat='Integer',&#xA;    lowBound=0) &#xA;&#xA;# Storage Facility Vars&#xA;storage_facility_vars = pulp.LpVariable.dicts(&#xA;    'Storage Inventory',&#xA;    ((d, p) for d in dates for p in products),&#xA;    cat='Integer',&#xA;    lowBound=0)&#xA;&#xA;# Total train capacity per plant dict&#xA;  train_load_limit_daily = dict(zip(rail_capacity_df.index, &#xA;                                    rail_capacity_df.capacity_per_day))&#xA;&#xA;# Decision Vars: date, plant, product&#xA;train_consignment_variables = pulp.LpVariable.dicts(&#xA;    'Rail Loadings From plant',&#xA;    ((date, plant, product) for date in dates for (plant, product) in plant_combinations),&#xA;    cat='Integer',&#xA;    lowBound=0) &#xA;&#xA;&#xA;# OPTIMISATION&#xA;# Objective Function&#xA;model += pulp.lpSum(stockpile_max[product] &#xA;    - inventory_vars[(date, product)] for (date, product) in inventory_vars), 'Minimise stockpile shortfalls'&#xA;&#xA;   # PLANT INVENTORY&#xA;for date in dates:&#xA;  current_date = datetime.date.today().strftime('%F')&#xA;  date_t_minus_one = datetime.datetime.strptime(date, '%Y-%m-%d') - datetime.timedelta(days=1)&#xA;  date_t_minus_one = date_t_minus_one.strftime('%F')&#xA;  for plant, product in plant_combinations:&#xA;    if date == current_date:&#xA;      # Set current inventory&#xA;      plant_inventory_vars[(date, plant, product)] = plant_current_inventory[(plant, product)] + plant_daily_production[(plant, product)]&#xA;    else:&#xA;      # Get inventory from t-1&#xA;      plant_inventory_vars[(date, plant, product)] = plant_inventory_vars[(f'{date_t_minus_one}', wplant, product)] + plant_daily_production[(plant, product)]&#xA;    model += pulp.lpSum(plant_inventory_vars[(date, plant, product)]) - pulp.lpSum(train_consignment_variables[(date, plant, product)])&#xA;&#xA;# Trains: Daily Rail Out Constraint &#xA;for date in dates:&#xA;  for plant in plants:&#xA;    plant_product_combination = [tup for tup in plant_combinations if tup[0] == plant]&#xA;    variable_list = []&#xA;    for (plant_, product_) in plant_product_combination:&#xA;      variable = train_consignment_variables[(date, plant_, product_)]&#xA;      variable_list.append(variable)&#xA;    model += pulp.lpSum(var for var in variable_list) == train_load_limit[plant] * 8400&#xA;&#xA;# STORAGE FACILITY &#xA;for date in dates:&#xA;  current_date = datetime.date.today().strftime('%F')&#xA;  date_t_minus_one = datetime.datetime.strptime(date, '%Y-%m-%d') - datetime.timedelta(days=1)&#xA;  date_t_minus_one = date_t_minus_one.strftime('%F')&#xA;  for product in products:&#xA;    if date == current_date:&#xA;      storage_facility_vars[(date, product)] = plant_current_inv[product] &#xA;    else:&#xA;      port_inventory_vars[(date, product)] = port_inventory_vars[(f'{date_t_minus_one}', product)] &#xA;    model += pulp.lpSum(port_inventory_vars[(date, product)]) + pulp.lpSum(train_consignment_variables[(date, plant, product)] for plant, product in plant_combinations)&#xA;&#xA;# Run solver&#xA;model.solve(solver)&#xA;pulp.LpStatus[model.status]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I access the outputs of each decision variable:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;train_consignment_vars.varValue&lt;/code&gt; =  output ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For both plant and storage facilities I get the following: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;storage_facility_vars.varValue = AttributeError: 'float' object has no attribute 'value'.&lt;/code&gt; &#xA;If I don't call &lt;code&gt;.varValue&lt;/code&gt;, I simply get the dictionary values without accounting for the amount added/removed by rail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help greatly appreciated, thank you.&lt;/p&gt;&#xA;" OwnerUserId="3395" LastEditorUserId="279" LastEditDate="2020-05-21T20:04:03.833" LastActivityDate="2020-05-23T09:14:14.560" Title="PuLP Transport Problem - How to add outcomes of decision variables together" Tags="|optimization|linear-programming|python|pulp|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="3954" PostTypeId="2" ParentId="3952" CreationDate="2020-04-23T08:47:48.817" Score="13" Body="&lt;p&gt;I personnaly use Python for optimizing industrial problems every day. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know &lt;a href=&quot;https://polymathian.com/&quot; rel=&quot;noreferrer&quot;&gt;Polymathian&lt;/a&gt; also use Python for their &lt;a href=&quot;https://polymathian.com/products-solutions/tropofy/&quot; rel=&quot;noreferrer&quot;&gt;Tropofy&lt;/a&gt; platform. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;GUROBI has a &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/quickstart_mac/py_python_interface.html&quot; rel=&quot;noreferrer&quot;&gt;python API&lt;/a&gt;, which I think is quite popular (although I cannot prove it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that since Python is one of the most popular languages out there, mechanically it is used for optimization. However, I think it also depends on what you mean by optimization. Are you talking about software development, an industrial study, consulting, etc ? I think for software development, Python is often used with other low level languages such as C. For consulting or studies, Python is very appropriate in my experience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think Julia is promising, but too young to be compared to Python or any other language in fact. This being said, &lt;a href=&quot;https://atoptima.com/&quot; rel=&quot;noreferrer&quot;&gt;Atoptima&lt;/a&gt; solve their optimization problems with a branch and price framework implemented in Julia. I would not be surprised if in the coming years, Julia becomes more and more popular in the optimization community.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to sum up, I would say that YES, Python is appropriate for what you need. And if someone learns Python, the learning curve for Julia should not be too steep.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS : this is a personal opinion and I am curious to see some other answers :) &lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-04-23T08:54:23.740" LastActivityDate="2020-04-23T08:54:23.740" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3955" PostTypeId="2" ParentId="3952" CreationDate="2020-04-23T08:59:47.723" Score="20" Body="&lt;p&gt;The feed back we get from our customers at &lt;a href=&quot;https://mosek.com]&quot; rel=&quot;noreferrer&quot;&gt;Mosek&lt;/a&gt; is Python is used extensively in the financial industry for doing portfolio optimization and lot of other operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those customers like to use &lt;a href=&quot;https://cvxpy.org&quot; rel=&quot;noreferrer&quot;&gt;Cvxpy&lt;/a&gt; or Mosek Fusion to interface the optimizer. You can see some Python notebooks at our &lt;a href=&quot;https://github.com/MOSEK/Tutorials&quot; rel=&quot;noreferrer&quot;&gt;Github tutorial page&lt;/a&gt;. This &lt;a href=&quot;https://github.com/robertmartin8/PyPortfolioOpt&quot; rel=&quot;noreferrer&quot;&gt;portfolio construction framework&lt;/a&gt; also provides a good example of what the financial industry are doing with Python and optimization&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Our feeling regarding Julia which we also have an interface for is it much less used than Python in industry at this moment time. It is very popular among academics though.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2020-04-23T08:59:47.723" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3956" PostTypeId="2" ParentId="3952" CreationDate="2020-04-23T09:05:13.827" Score="9" Body="&lt;p&gt;Yes, Python is used in the industry is the simple answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are &lt;a href=&quot;http://www.optimeeringaqua.com&quot; rel=&quot;noreferrer&quot;&gt;Optimeering Aqua&lt;/a&gt; and our sister company &lt;a href=&quot;http://www.optimeering.com&quot; rel=&quot;noreferrer&quot;&gt;Optimeering&lt;/a&gt; use Python and the (Fico) Xpress Python- API. We were alpha and beta users. For us this has been working well. We very early on used Fico's Mosel language, but found moving to a general programming language to have lots of advantages, with few disadvantages. I think there has been many debates on general purpose languages vs domain specific languages, so will not repeat that here.&lt;/p&gt;&#xA;" OwnerUserId="3398" LastEditorUserId="279" LastEditDate="2020-04-23T11:06:40.983" LastActivityDate="2020-04-23T11:06:40.983" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3957" PostTypeId="2" ParentId="3952" CreationDate="2020-04-23T09:17:35.753" Score="15" Body="&lt;p&gt;&lt;a href=&quot;https://blog.staffjoy.com/&quot; rel=&quot;noreferrer&quot;&gt;Staffjoy&lt;/a&gt; was an early user of Julia and JuMP for their start up providing workforce scheduling. They also release all of their internal software as open-source after they shut-down. See for example the &lt;a href=&quot;https://github.com/Staffjoy/autoscheduler&quot; rel=&quot;noreferrer&quot;&gt;autoscheduler&lt;/a&gt; based on JuMP.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2020-04-23T09:17:35.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3958" PostTypeId="2" ParentId="3952" CreationDate="2020-04-23T09:48:36.957" Score="14" Body="&lt;p&gt;Although I personally think Julia is glorious, nearly no-one outside academia uses it for numerous reasons, including:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Missing out on all the Python packages&lt;/li&gt;&#xA;&lt;li&gt;Julia programmers being much harder to find than Python programmers, and &lt;/li&gt;&#xA;&lt;li&gt;Julia being much harder than Python to integrate to other things.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;JuMP can offer performance benefits, but for commercial use that's rarely an issue as most companies will simply buy an AMPL license if that's a bottleneck and use its Python interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it comes to interfacing, Python is the king, and that is true of optimisation solvers as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from our personal experience at Octeract, this is also reflected by the languages' &lt;a href=&quot;https://www.nature.com/articles/d41586-019-02310-3&quot; rel=&quot;noreferrer&quot;&gt;popularities&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the 2019 index ranks Julia 50th, and Python 3rd&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-04-25T02:18:49.250" LastActivityDate="2020-04-25T02:18:49.250" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3959" PostTypeId="1" CreationDate="2020-04-23T10:50:26.690" Score="2" ViewCount="45" Body="&lt;p&gt;I would like to understand and solve Tanaka's fuzzy house price problem (Table III). Unfortunately I couldn't able to build the problem structure and restrictions here (according to (19)). Anyone have face it before?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To double check, answers are below in Table-IV.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6AfGe.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6AfGe.jpg&quot; alt=&quot;Tanaka&amp;#39;s House Price Problem&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3399" LastActivityDate="2020-04-23T10:50:26.690" Title="Tanaka's Fuzzy House Price Problem" Tags="|regression|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3960" PostTypeId="2" ParentId="3952" CreationDate="2020-04-23T11:54:46.707" Score="13" Body="&lt;p&gt;My answer will be focused on teaching, and I'll give you my perspective from Georgia Tech ISyE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Yes, you should teach your students optimization using Python&lt;/strong&gt;. For simple models, one simple open-source platform you could introduce is PuLP. It is solver-agnostic, and will work both with commercial solvers as well as open source (including COIN-OR stuff). For more complex stuff, you could teach the gurobipy interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Julia is also useful, but I would suggest for now that it is best for research students like those pursuing a Ph.D.&lt;/p&gt;&#xA;" OwnerUserId="105" LastEditorUserId="105" LastEditDate="2020-04-23T12:16:46.520" LastActivityDate="2020-04-23T12:16:46.520" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3961" PostTypeId="1" CreationDate="2020-04-23T12:07:00.673" Score="2" ViewCount="103" Body="&lt;p&gt;I'm trying to get up to speed on the Weber problem. I'm very much not an expert, unfortunately. I would really appreciate recent literature recommendations / surveys / potted histories, however incomplete. And more specifically:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there a solution for rectilinear space?&lt;/li&gt;&#xA;&lt;li&gt;Are there multi-dimensional, rather than planar, solutions?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3401" LastActivityDate="2020-04-24T05:16:12.033" Title="What is the state of the art on the Weber problem?" Tags="|optimization|facility-location|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3962" PostTypeId="2" ParentId="3952" CreationDate="2020-04-23T12:42:37.820" Score="49" Body="&lt;p&gt;Despite being a great fan of Julia (and JuMP) I must admit that Python is most widely adopted in industry. I won't recommend PuLP however, which tends to be too slow. As alternatives, I would consider&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pyomo is a great package, with various interesting extensions (for stochastic programming, MPEC, bilevel optimization, ...). &lt;/li&gt;&#xA;&lt;li&gt;Cvxpy is a game changer if you are dealing with convex problems, and is fast. As cvxpy is still actively maintained by some students of Boyd, you could expect using state-of-the-art code when using this package (e.g. &lt;a href=&quot;https://github.com/cvxgrp/cvxpylayers&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/cvxgrp/cvxpylayers&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Most optimization solvers come with a Python interface.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My experience in Artelys, a firm specialized in optimization, is that most people are using Python nowadays, and prefer to stick to this language. We have some prototypes in Julia, but none of them have been industrialized. However, they do provide support for the Julia interface of the solver Knitro (but mostly used by academics so far). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I won't be so definitive as others about Julia, though. JuMP is really a game changer. For non-linear programming, the performance of JuMP AD backend is closed to those of AMPL (between 3x and 5x slower in my experience, which is way better than Pyomo). My bet is that the gap will close in the next years, with the current focus on AD in Julia. That's the reason why I prefer to use Julia for my teachings so far (having built-in linear algebra is gold to me). Also if you choose to use Julia, you could experiment cutting-edge packages developed by the JuliaOpt community. For instance, I do not know any equivalent of &lt;a href=&quot;https://github.com/JuliaOpt/Dualization.jl&quot; rel=&quot;noreferrer&quot;&gt;Dualization.jl&lt;/a&gt; (a package computing automatically the dual of an optimization problem) in other languages.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Nearly no-one outside academia uses Julia in production&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I beg to differ on this one. &lt;a href=&quot;https://juliacomputing.com/case-studies/psr.html&quot; rel=&quot;noreferrer&quot;&gt;PSR&lt;/a&gt;, another firm specialized in optimization, is using Julia extensively for their studies, with success so far. &lt;/p&gt;&#xA;" OwnerUserId="2452" LastEditorUserId="123" LastEditDate="2020-04-23T12:54:14.087" LastActivityDate="2020-04-23T12:54:14.087" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3963" PostTypeId="2" ParentId="3952" CreationDate="2020-04-23T13:42:37.580" Score="25" Body="&lt;p&gt;We use Julia in production for optimization at &lt;a href=&quot;https://www.invenia.ca/labs/&quot; rel=&quot;noreferrer&quot;&gt;Invenia&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We use &lt;a href=&quot;https://github.com/JuliaOpt/Convex.jl&quot; rel=&quot;noreferrer&quot;&gt;Convex.jl&lt;/a&gt;, and &lt;a href=&quot;https://github.com/JuliaOpt/jump.jl&quot; rel=&quot;noreferrer&quot;&gt;JuMP.jl&lt;/a&gt;, and have found them to be excellent.&lt;/p&gt;&#xA;" OwnerUserId="3402" LastActivityDate="2020-04-23T13:42:37.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3964" PostTypeId="2" ParentId="3952" CreationDate="2020-04-23T15:30:11.463" Score="6" Body="&lt;p&gt;Python is well ahead of specific modelling languages. Many of solvers such as Gurobi, Cplex etc. have python interface. You can encounter small problems. For example for modelling problems, which package you will teach. You will have alternatives pyomo, pulp, &lt;a href=&quot;https://www.python-mip.com/&quot; rel=&quot;noreferrer&quot;&gt;python-mip&lt;/a&gt; or solver interface. I prefer pyomo which can be used with lots of commercial or free solvers. Also you can find heuristic and constraint programming packages for python such as google OR tools. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, you should examine following links, they will give idea.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;python wiki for OR packages: &lt;a href=&quot;https://wiki.python.org/moin/PythonForOperationsResearch&quot; rel=&quot;noreferrer&quot;&gt;https://wiki.python.org/moin/PythonForOperationsResearch&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Famous scipy package optimization module: &lt;a href=&quot;https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html&quot; rel=&quot;noreferrer&quot;&gt;https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Python PSO package: &lt;a href=&quot;https://pyswarms.readthedocs.io/en/latest/&quot; rel=&quot;noreferrer&quot;&gt;https://pyswarms.readthedocs.io/en/latest/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="432" LastEditorUserId="123" LastEditDate="2020-04-23T16:00:27.610" LastActivityDate="2020-04-23T16:00:27.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3965" PostTypeId="1" CreationDate="2020-04-23T15:56:56.817" Score="2" ViewCount="170" Body="&lt;p&gt;I am trying to figure out how one could write a rolling horizon algorithm in PYOMO to speed up the solution of a model that I am building. My understanding of the Rolling Horizon Algorithm is that you simply want to update your model each time period with the values from the previous period, but I have also read that there needs to be some type of overlap in the model runs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not have any code to share at the moment because using the Rolling Horizon Approach was meant to be something of a last resort for my model. Even a basic script just to illustrate how the algorithm would work would probably be a huge help. &lt;/p&gt;&#xA;" OwnerUserId="547" LastActivityDate="2020-04-23T15:56:56.817" Title="Rolling Horizon in Pyomo" Tags="|algorithms|pyomo|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3966" PostTypeId="1" CreationDate="2020-04-23T21:56:19.813" Score="13" ViewCount="626" Body="&lt;p&gt;I currently have a complex Mixed Integer Program (a sort of vehicle routing problem variant, with multiple vehicle types and without assigned pickup -&gt; delivery routes, among other complications) implemented in PuLP, which is taking far too long for CBC too solve. However,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Getting a feasible solution is trivial.&lt;/li&gt;&#xA;&lt;li&gt;I don't need the optimal solution -- something within 10 % of optimality is just fine.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Are there any easy to implement, open-source heuristic tools to give me solutions? It looks like &lt;a href=&quot;https://or.stackexchange.com/questions/3855/advanced-heuristics-for-mip-vehicle-routing-problem-in-pulp&quot;&gt;Gurobi&lt;/a&gt; has such tools, but it's quite pricey.&lt;/p&gt;&#xA;" OwnerUserId="3406" LastActivityDate="2020-04-25T02:38:37.590" Title="&quot;Out of the box&quot; Mixed Integer Programming Heuristics" Tags="|mixed-integer-programming|heuristics|open-source|pulp|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3967" PostTypeId="2" ParentId="3952" CreationDate="2020-04-23T22:09:26.850" Score="11" Body="&lt;p&gt;Our, KLM, current optimizer products' codebases are all in python. The main reason for this is python is extremely powerful for fast prototyping. However, when it comes to the necessity of implementing more advanced techniques such as column generation and own branch-and-price algorithm, then python start lacking the performance you're looking for. In that case, python is again powerful since that part of your code can then well be implemented in c++ still within your codebase. &#xA;Last but not least, the immense support with packages from the community makes it extremely handy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding Julia, I personally started experimenting and it seems quite nice. However, having no community support as much as python is an important fallback. Moreover, most commercial solvers do not have an official API for it. Maybe not a showstopper but certainly an issue to be thoroughly discussed.&lt;/p&gt;&#xA;" OwnerUserId="3407" LastActivityDate="2020-04-23T22:09:26.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3968" PostTypeId="2" ParentId="3966" CreationDate="2020-04-24T01:12:45.133" Score="10" Body="&lt;p&gt;You can solve your model via the &lt;a href=&quot;https://neos-server.org/neos/&quot; rel=&quot;noreferrer&quot;&gt;NEOS server&lt;/a&gt; which provides Gurobi, Cplex, and other solvers for free if it is the matter of not having a solver. I am not familiar with PuLP but I know it is easy to implement the solvers in NEOS if you model the problem in Pyomo. May it helps you to find PuLP syntax for it, I provide lines of code written for Pyomo using NEOS:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;solver_manager = SolverManagerFactory('neos')&#xA;solution = solver_manager.solve(model, solver='gurobi', tee = True). &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also you may have a look on this &lt;a href=&quot;https://github.com/topics/vehicle-routing-problem?l=python&quot; rel=&quot;noreferrer&quot;&gt;Github link&lt;/a&gt;. For example, a tabu search metaheuristic for Vehicle Routing Problems with Cross-Docking written in Python is given &lt;a href=&quot;https://github.com/theosotr/tabu_search-vrpcd&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2020-04-24T01:17:52.937" LastActivityDate="2020-04-24T01:17:52.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3969" PostTypeId="2" ParentId="3961" CreationDate="2020-04-24T05:16:12.033" Score="4" Body="&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Weber_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fermat-Weber&lt;/a&gt; problem can be formulated as a conic quadratic problem (aka. SOCP). These problems can be solved in polynomial complexity using an interior-point method.&#xA;See the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek modelling cookbook&lt;/a&gt; for information about conic optimization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://mosek.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek&lt;/a&gt; to solve those problems.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2020-04-24T05:16:12.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3970" PostTypeId="2" ParentId="3933" CreationDate="2020-04-24T09:43:08.923" Score="5" Body="&lt;p&gt;I suggest to start with the classical TSP formulation using &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; variables that are 1 if you go to city &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; directly after city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and then add the constraints that &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = B_{ij}+F_{ij}+T_{ij}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt;. This allows you to to use all standard TSP machinery (e.g. sub-tour elimination constraints) via the &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; variables, without having to overcomplicate your model. &lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2020-04-24T09:43:08.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3973" PostTypeId="1" CreationDate="2020-04-24T11:36:16.753" Score="4" ViewCount="161" Body="&lt;p&gt;I constructed an optimisation model which objective is to find highest return on available stocks. Now want to add a constraint that allows to buy stocks only in $2000 increments, how can I do it? i.e buy stocks only in multiples of 2000. It should be a mathematical expression.&lt;/p&gt;&#xA;" OwnerUserId="3416" LastEditorUserId="38" LastEditDate="2020-04-24T15:04:50.827" LastActivityDate="2020-04-24T15:04:50.827" Title="Buying shares in increments" Tags="|modeling|constraint|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3974" PostTypeId="2" ParentId="3973" CreationDate="2020-04-24T11:56:39.633" Score="5" Body="&lt;p&gt;Declare &lt;span class=&quot;math-container&quot;&gt;$I_i$&lt;/span&gt; as an integer variable, which is the number of \$2000 increments to buy of stock &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then let &lt;span class=&quot;math-container&quot;&gt;$q_i = 2000 I_i$&lt;/span&gt; be the dollar value purchased of stock i.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the portfolio is long only, constrain &lt;span class=&quot;math-container&quot;&gt;$I_i$&lt;/span&gt; to be nonnegative.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-04-24T13:37:13.480" LastActivityDate="2020-04-24T13:37:13.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3975" PostTypeId="1" AcceptedAnswerId="3976" CreationDate="2020-04-24T12:14:57.167" Score="2" ViewCount="296" Body="&lt;p&gt;I have thought I had found the answer here: &lt;a href=&quot;https://or.stackexchange.com/questions/2903/how-to-linearize-the-multiplication-of-an-integer-and-a-binary-integer-variable&quot;&gt;How to linearize the multiplication of an integer and a binary integer variable?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the answers to that questions didn't help me find a solution for my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following constraints&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\sum_{i=1}^{N}\sum_{k=1}^{M}{{(x_{i,k,t}\cdot r_i)}}&amp;amp;\le C_t\\&#xA;r_i&amp;amp;\le R_i&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$r_i\ge 0$&lt;/span&gt; is an integer variable, &lt;span class=&quot;math-container&quot;&gt;$x_{i, k, t}\in\{0,1\}$&lt;/span&gt; is a binary variable, &lt;span class=&quot;math-container&quot;&gt;$C_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R_i$&lt;/span&gt; are known numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I linearize this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some background: At period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; I have a capacity of &lt;span class=&quot;math-container&quot;&gt;$C_t$&lt;/span&gt; for the resources. A certain number of resources &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; perform job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$x_{i,k,t}$&lt;/span&gt; tells us, if job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is performed at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; with a different type of resource &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3418" LastEditorUserId="3418" LastEditDate="2020-04-24T13:34:50.447" LastActivityDate="2020-04-24T13:34:50.447" Title="Inequality Constraint Linearization of a product of an integer and a binary variable" Tags="|linear-programming|integer-programming|linearization|binary-variable|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3976" PostTypeId="2" ParentId="3975" CreationDate="2020-04-24T12:44:45.957" Score="4" Body="&lt;p&gt;The linked answer depends on an equality constraint that doesn’t appear here. You can still use the same idea of introducing a nonnegative variable, say &lt;span class=&quot;math-container&quot;&gt;$y_{i,k,t}$&lt;/span&gt;, to represent the product. Because your constraint is &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt;, you need to enforce only that &lt;span class=&quot;math-container&quot;&gt;$$x_{i,k,t}=1\implies y_{i,k,t}\ge r_i,$$&lt;/span&gt; which you can do with a big-M constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$r_i-y_{i,k,t}\le R_i (1-x_{i,k,t})$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-04-24T12:44:45.957" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3977" PostTypeId="2" ParentId="3933" CreationDate="2020-04-24T15:17:43.167" Score="3" Body="&lt;p&gt;As basically a variant to what Rolf van Lieshout proposed, you could also add another index to your standard TSP variable: &lt;span class=&quot;math-container&quot;&gt;$x^t_{ij}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is the transport mode &lt;span class=&quot;math-container&quot;&gt;$t \in \{B, T, F\}$&lt;/span&gt;. You basically add &lt;span class=&quot;math-container&quot;&gt;$\sum_{t \in T}$&lt;/span&gt; to most of your TSP constraints and of course need to limit the potentially chosen arcs between each city to one: &lt;span class=&quot;math-container&quot;&gt;$\sum_{t \in T}\sum_{i,j \in A} x^t_{ij} \le 1, \forall i,j \in A$&lt;/span&gt;. The basics of the TSP do not change with adding multiple arcs between cities.&lt;/p&gt;&#xA;" OwnerUserId="296" LastActivityDate="2020-04-24T15:17:43.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3978" PostTypeId="1" CreationDate="2020-04-24T15:42:04.223" Score="10" ViewCount="886" Body="&lt;p&gt;I am relatively new to the world of OR as my first foray into this field has me solving a MINLP. Unfortunately, my model is unable to solve because it is too complex, and so my supervisor has suggested that they could help me to code it up in MATLAB instead of PYOMO (I use PYOMO), and I am assuming that the reason for suggesting that is because they believe that coding it in MATLAB will speed up the convergence of the solver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To my understanding, regardless of the platform used to code up the model (MATLAB, JuMP, PYOMO, GAMS, etc), it is the solver that is unable to handle the problem. Am I wrong to think that simply recoding the problem in a different modelling platform will not help to solve the problem, or is there some merit into changing the platform?&lt;/p&gt;&#xA;" OwnerUserId="547" LastActivityDate="2020-04-25T02:04:22.120" Title="Does The Modelling Software Make A Difference Regarding A Solution?" Tags="|software|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3979" PostTypeId="1" CreationDate="2020-04-24T15:55:21.067" Score="4" ViewCount="161" Body="&lt;p&gt;I have a constraint of the following form that describes the growth of trees, where the population of trees in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is the previous period's population minus some trees infected with a virus: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ S_{t}^{ij} = S_{t-1}^{ij} - I_{t-1}^{ij} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ S_{t}\ge0,I_{t} \ge 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From this constraint, you can see that it is possible for &lt;span class=&quot;math-container&quot;&gt;$ I_{t-1}^{ij}  $&lt;/span&gt; to be larger than &lt;span class=&quot;math-container&quot;&gt;$S_{t-1}^{ij}$&lt;/span&gt; , but I need to be able to incorporate the fact that in any period &lt;span class=&quot;math-container&quot;&gt;$S_{t}^{ij} $&lt;/span&gt; can never be less than 0 because you cannot have negative trees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am wondering if there is any way to incorporate this besides including a max constraint of the form :&lt;span class=&quot;math-container&quot;&gt;$$ S_{t}^{ij} = \max\{S_{t-1}^{ij} - I_{t-1}^{ij}, 0 \}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I include the max constraint and then linearize it, my problem becomes very challenging to solve, so I am wondering if there's maybe some other way I can try to reformulate the constraint so to avoid the binary variables. &lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="123" LastEditDate="2020-04-24T19:02:58.620" LastActivityDate="2020-04-24T19:02:58.620" Title="Is There Another Way To Code The Idea of a MAX Constraint Without The Use of Binary Variables?" Tags="|nonlinear-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3980" PostTypeId="2" ParentId="3978" CreationDate="2020-04-24T16:03:08.367" Score="2" Body="&lt;p&gt;I find this question quite interesting and wrote my most popular linkedin article about this: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/pulse/optimization-aka-prescriptive-analytics-should-we-write-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimization (aka prescriptive analytics) : Should we write the model in a modeling language or a general programming language ?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to believe we should all write optimization models in efficient programming languages like C++ but that was 20 years ago. High level modeling languages like MATLAB or OPL offer many advantages:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, the ability to share your model to get some help from a colleague or an expert. Not to mention, the flexibility you will get if you want to try new ideas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way you model a problem has a strong impact on performances so it's key to be able to try new ideas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to rewrite my &lt;a href=&quot;https://medium.com/@alexfleischer_84755/optimization-simply-do-more-with-less-zoo-buses-and-kids-66940178db6&quot; rel=&quot;nofollow noreferrer&quot;&gt;bus and zoo example&lt;/a&gt; with &lt;a href=&quot;https://medium.com/@alexfleischer_84755/optimization-simply-do-more-with-less-zoo-buses-and-kids-part2-python-java-c-cc04558e49b5&quot; rel=&quot;nofollow noreferrer&quot;&gt;many APIs&lt;/a&gt; to make this easy to see.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to me you re wrong when you say: &quot; Am I wrong to think that simply recoding the problem in a different modelling platform will not help to solve the problem, or is there some merit into changing the platform? &quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will help, as it helped many. You will need less human brain power to get to the same result.&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-04-24T16:03:08.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3981" PostTypeId="2" ParentId="3952" CreationDate="2020-04-24T16:04:21.980" Score="8" Body="&lt;p&gt;Interesting that you ask - I've actually seen both julia and python used in industry. On the python side, I'd highly recommend &lt;a href=&quot;https://www.cvxpy.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;cvxpy&lt;/a&gt; (for convex optimization). It was pretty easy to get started with, and it integrates well with other popular python numerical libraries. The stuff I've seen in julia was custom work, so I can't really comment on ease of use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: I will say, though, that Julia makes linear algebra easy and, dare I say even beautiful :)&lt;/p&gt;&#xA;" OwnerUserId="3421" LastEditorUserId="3421" LastEditDate="2020-04-29T11:49:46.083" LastActivityDate="2020-04-29T11:49:46.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3982" PostTypeId="2" ParentId="3979" CreationDate="2020-04-24T16:23:16.800" Score="5" Body="&lt;p&gt;Why not just impose &lt;span class=&quot;math-container&quot;&gt;$S_t^{ij} \ge 0$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-04-24T16:23:16.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3983" PostTypeId="2" ParentId="3979" CreationDate="2020-04-24T16:31:32.430" Score="3" Body="&lt;p&gt;As @RobPratt states why not impose &lt;span class=&quot;math-container&quot;&gt;$S^{ij}_t\geq0$&lt;/span&gt;? Especially it seems rather reasonable to inforce this through &lt;span class=&quot;math-container&quot;&gt;$S^{ij}_t\geq I^{ij}_t $&lt;/span&gt; given that there probably cannot be more infected trees than there are trees.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2020-04-24T16:31:32.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3984" PostTypeId="2" ParentId="3978" CreationDate="2020-04-24T19:21:33.777" Score="10" Body="&lt;p&gt;I did not want to answer here, but Alex challenged me :) I agree on all the benefits of using a modeling language (as Alex indicates) and totally on the importance of finding a &quot;good&quot; model (as Alex also indicates), but neither answers your question which, in my understanding, pertains to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;regardless of the platform used to code up the model [...], it is the solver that is unable to handle the problem.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would say: in most cases this is correct. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen cases where the modeling language was (for memory/performance reasons) unable to generate large models while other modeling languages did not struggle. This is rare in my experience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, yes, regardless of the system, in simple terms, you write out an &lt;code&gt;LP&lt;/code&gt; or &lt;code&gt;MPS&lt;/code&gt; file, and feed it to a solver. When the two modeling languages you test use different default solvers, then the difference in performance comes from the different solvers, exactly as you say.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My very very very personal remark: I would never switch away from Python to ...&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2020-04-24T19:21:33.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3985" PostTypeId="2" ParentId="3978" CreationDate="2020-04-24T20:19:11.220" Score="5" Body="&lt;p&gt;I agree with the answers by @Alex Fleischer and @Marco Lübbecke as essays in their own right, divorced from the question which was asked. However, neither of them directly address the question as asked, which is specifically about MINLP - Mixed-Integer Nonlinear Program, and not about LP or MILP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MINLP solvers (not counting convex conic MINLP solvers) generally employ derivatives (gradient and maybe Hessian of Lagrangian, Jacobian and maybe Hessians of constraints).  Solvers may have various derivative options (forward or central finite difference), &quot;exact&quot; (analytical or automatic differentiation).  Different modeling systems may provide different derivatives to the solver - some only utilize whatever is provided by the user, and may default to finite difference if none are provided; whereas others, such as AMPL, automatically compute and provide automatic derivatives to the solver, and yet others, such as YALMIP, automatically provide first derivatives (gradient and Jacobian), but no 2nd derivatives, and no option to provide 2nd derivatives. The derivative options (leaving aside the possibility of coding errors) can have a large impact on (MI)NLP performance (for example, finite difference Quasi-Newton vs. Quasi-Newton vs. Newton for continuous relaxations). Note that some MINLP solvers, such as BARON, automatically compute derivatives internally, in which case modeling system derivative options are irrelevant to solver performance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, modeling systems may differ in the type and amount, if any, of pre-solve performed by the modeling system prior to providing a problem to the solver. The pre-solve performed by the modeling system can have a large impact on MINLP solver performance, and may not be the same as the pre-solve which would have been performed by the solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, note that there may be different default starting (initial) values provided for the variables, depending on the modeling system (and its pre-solve).  Generally, a user is allowed to provide starting values; but if not, the modeling system default can have a big impact (do you know how often the all zero vector is provided as default starting value, and there is either a model singularity there or non-local optimum stationary point?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Default values of other solver algorithm and parameter choices may also differ by modeling system, and have a large impact on performance.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-04-24T20:19:11.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3986" PostTypeId="2" ParentId="3978" CreationDate="2020-04-25T00:28:14.947" Score="5" Body="&lt;p&gt;Short answer: yes it can make a huge difference. The degree to which it will make a difference depends on the combination of modelling software &amp;amp; solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are 3 main things a modelling environment can do, other than represent &amp;amp; pass your math to a solver:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Presolve&lt;/li&gt;&#xA;&lt;li&gt;Compute derivatives&lt;/li&gt;&#xA;&lt;li&gt;Reformulate&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This will mostly affect users of non-linear technology because, historically, local NLP solvers don't do any of the above as they rely on callbacks. AFAIK there is no local NLP solver which does symbolic manipulation, so modelling software attempts to be clever and improve on what the NLP solvers can do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Deterministic global optimisation solvers such as BARON, ANTIGONE, and Octeract Engine, are different in that we do symbolic manipulation internally, so we do all of the above regardless of how the user interacts with the solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One important exception here is if you are using CLP/CBC, as their presolve is not nearly as extensive as CPLEX/GUROBI's. In this case, a commercial modelling software such as AIMMS can improve performance due to its presolve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some examples that you might find interesting include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;AMPL has incredibly fast automatic differentiation code. People get papers accepted by claiming they managed to get within a factor of 5 of AMPL's speed.&lt;/li&gt;&#xA;&lt;li&gt;AMPL will perform Singleton reduction, but not Doubleton reduction.&lt;/li&gt;&#xA;&lt;li&gt;AIMMS will perform Doubleton reduction as well.&lt;/li&gt;&#xA;&lt;li&gt;GAMS will reformulate your problem to have the objective function as a constraint.&lt;/li&gt;&#xA;&lt;li&gt;PYOMO uses AMPL's automatic differentiation code, but does not presolve nor reformulate.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With respect to what you actually want to know, I strongly advise against using MATLAB if you can use PYOMO instead:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MATLAB is not open source, so anything you develop will need a MATLAB license for anyone to use. This includes you once/if you leave academia. One of my employees developed an entire MATLAB framework in his PhD, and words cannot describe how annoyed he is that he can not use it now that he's left academia.&lt;/li&gt;&#xA;&lt;li&gt;MATLAB is much harder to interface with than Python is.&lt;/li&gt;&#xA;&lt;li&gt;MATLAB's multiprocessing toolbox is very expensive, whereas Python's is free.&lt;/li&gt;&#xA;&lt;li&gt;MATLAB will be slower than Python in most cases that can be relevant here, including symbolic manipulation. The speed difference between SymPy &amp;amp; MuPad is not even funny. &lt;/li&gt;&#xA;&lt;li&gt;AFAIK MATLAB also doesn't use the ASL automatic differentiation code that PYOMO does, which means your problem will be much slower if you are using a local NLP/MINLP solver.&lt;/li&gt;&#xA;&lt;li&gt;PYOMO is a modelling environment specifically designed for optimisation, whereas MATLAB is not. If, as you describe, you main problem is in getting your model right, then your chances of success are much higher if you use PYOMO because it's much closer to the logic you are trying to capture.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am guessing that your supervisor is suggesting MATLAB because that's what they know so they can help you with the actual code. This means that you got lucky, as most supervisors will not do that for you, but in the grand scheme of things PYOMO does offer many advantages so you have an interesting decision to make.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-04-25T02:04:22.120" LastActivityDate="2020-04-25T02:04:22.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3987" PostTypeId="2" ParentId="3933" CreationDate="2020-04-25T02:09:23.507" Score="2" Body="&lt;p&gt;I think all of the above-suggested models (by You, S. Phil Kim, Rolf van Lieshout, lvenhofen) have same number of nodes and arcs, correctly representing the problem to be modeled. However, one can reduce the number of variables as well as constraints in these models by representing either of ,, binary variables in terms of other two variables, i.e.,  /  /  = 1 - ( /  /  +  /  / ), respectively. This might help you speed up the computations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A multi (many) -objective optimization problem has 2 or 3 (&gt;3) conflicting objectives, respectively. Hence, to model it as a multi-objective problem, first, one needs to identify the nature of these objective functions. If they are conflicting in nature, then you could solve them using MOEAs such as NSGA-II/III, MOEA-D, SPEA-R, etc. If the objectives are non-conflicting, the scalarization technique could be used, i.e., objectives could be combined using weights (as suggested by S. Phil Kim) but these weights need to be tuned. Intuitively, the objective functions to minimize time and cost shall be correlated (non-conflicting).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From my past experience, solving a single-objective NP-hard combinatorial optimization problem using Genetic Algorithms requires a lot of customizations, let alone solving this difficult version of TSP using MOEAs. Examples of such customizations are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;enhanced initialization, i.e., to generate at least one feasible solution in the initial population instead of all randomized ones,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;retaining poor/infeasible solutions to maintain diversity in the population,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;enhanced crossover/mutation operators,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;infeasibility repair operators, etc.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Some useful articles for such customizations are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;J. E. Beasley, P. C. Chu, A genetic algorithm for the set covering problem, European journal of operational research 94 (2) (1996) 392–404.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;D. Aggarwal, D. K. Saxena, T. Bäck, M. Emmerich, Real-World Airline Crew&#xA;Pairing Optimization: Customized Genetic Algorithm versus Column Generation&#xA;Method, arXiv:2003.03792 [cs.NE] (Unpublished).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2999" LastActivityDate="2020-04-25T02:09:23.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3988" PostTypeId="2" ParentId="3966" CreationDate="2020-04-25T02:38:37.590" Score="3" Body="&lt;p&gt;I have some experience in solving large-scale airline crew pairing combinatorial optimization problems (an NP-hard problem) with difficulty similar to vehicle routing problems. Yes, solving such problems using standard open-source IP solvers is extremely time-consuming. You could customize/parallelize heuristics (such as Simulated Annealing, Variable Neighbourhood Search) and meta-heuristics (such as Genetic Algorithms) to solve your problem (if the problem-scale is not huge). If the problem-scale is huge (search space of million/billion-plus variables), then I would suggest you solving it using mathematical programming, particularly the Column Generation technique in which only the variables/columns promising objective gain are generated during the optimization in the continuous-domain (a relaxed form of the original IP). Useful articles-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lübbecke, M. E., &amp;amp; Desrosiers, J. (2005). Selected topics in column generation. Operations research, 53(6), 1007-1023.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lübbecke, M. E. (2010). Column generation. Wiley encyclopedia of operations research and management science.&lt;/p&gt;&#xA;" OwnerUserId="2999" LastActivityDate="2020-04-25T02:38:37.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3989" PostTypeId="1" AcceptedAnswerId="5276" CreationDate="2020-04-25T06:25:32.340" Score="7" ViewCount="854" Body="&lt;p&gt;Suppose we have a graph &lt;strong&gt;G&lt;/strong&gt;. Consider the minimum vertex cover problem of &lt;strong&gt;G&lt;/strong&gt; formulated as a linear programming problem, that is for each vertex &lt;span class=&quot;math-container&quot;&gt;$v_{i}$&lt;/span&gt; we have the variable &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt;, for each edge &lt;span class=&quot;math-container&quot;&gt;$v_{i}v_{j}$&lt;/span&gt; we have the constraint &lt;span class=&quot;math-container&quot;&gt;$x_{i}+x_{j}\geq 1$&lt;/span&gt;, for each variable we have &lt;span class=&quot;math-container&quot;&gt;$0\leq x_{i}\leq 1$&lt;/span&gt; and we have the objective function &lt;span class=&quot;math-container&quot;&gt;$\min \sum\limits_{1}^{n}{x_{i}}$&lt;/span&gt;. We call such a linear programming problem &lt;em&gt;LP&lt;/em&gt;. Note that it is NOT an integer linear programming problem.&lt;/p&gt;&#xA;&lt;p&gt;We find a &lt;a href=&quot;https://en.wikipedia.org/wiki/Vertex_cover&quot; rel=&quot;nofollow noreferrer&quot;&gt;half integral optimal solution&lt;/a&gt; of &lt;em&gt;LP&lt;/em&gt; that we call &lt;span class=&quot;math-container&quot;&gt;$S_{hi}$&lt;/span&gt;. For each variable &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; that takes value &lt;em&gt;0&lt;/em&gt; in &lt;span class=&quot;math-container&quot;&gt;$S_{hi}$&lt;/span&gt;, we add the constraint &lt;span class=&quot;math-container&quot;&gt;$x_{i}=0$&lt;/span&gt; to &lt;em&gt;LP&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For each odd cycle of &lt;strong&gt;G&lt;/strong&gt;, add to &lt;em&gt;LP&lt;/em&gt; the constraint &lt;span class=&quot;math-container&quot;&gt;$x_{a}+x_{b}+x_{c}+...+x_{i}\geq \frac{1}{2}(k+1)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_{a},x_{b},x_{c},...,x_{i}$&lt;/span&gt; are the vertices of the cycle and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is the number of vertices of the cycle. We find a new optimal solution of &lt;em&gt;LP&lt;/em&gt; that we call &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; is a variable that takes value &lt;span class=&quot;math-container&quot;&gt;$0.5$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$S_{hi}$&lt;/span&gt; and value &lt;span class=&quot;math-container&quot;&gt;$\gt 0.5$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, can we say that there is at least a minimum vertex cover of &lt;strong&gt;G&lt;/strong&gt; that contains the vertex associated to &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3221" LastEditorUserId="3221" LastEditDate="2020-08-09T17:52:09.547" LastActivityDate="2020-12-19T14:25:54.187" Title="Minimum vertex cover and linear programming" Tags="|combinatorial-optimization|graphs|combinatorics|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3990" PostTypeId="2" ParentId="43" CreationDate="2020-04-25T06:25:53.993" Score="4" Body="&lt;p&gt;While these equations have many interpretations in OR (e.g. robust optimization), in this case I like to understand what happens here using a Game Theory perspective. These two equations can be interpreted as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Stackelberg_competition&quot; rel=&quot;nofollow noreferrer&quot;&gt;Stackelberg game&lt;/a&gt;, sometimes referred two as leader follower games. Consider a two player zero sum game, where player 1 has to pick an element from &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; maximizing the outcome and player 2 has to pick an element from &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; minimizing the outcome. Let's say we have the following game matrix where &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is the set of rows and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is the set of columns:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left[ \begin{array}{cc} a &amp;amp; 0 \\ 0 &amp;amp; b \end{array} \right]$$&lt;/span&gt;&#xA;We assume w.l.o.g. that &lt;span class=&quot;math-container&quot;&gt;$a &amp;gt; b &amp;gt; 0$&lt;/span&gt;. Now we have that &lt;span class=&quot;math-container&quot;&gt;$$\max_{x\in X}\min_{y \in Y} f(x,y) = 0$$&lt;/span&gt; as this corresponds to the situation where player 1 picks first and player 2 responds, and player 2 can always choose the column such that the outcome is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. On the right hand side, we get &lt;span class=&quot;math-container&quot;&gt;$$\min_{y \in Y}\max_{x \in X} f(x,y) = b$$&lt;/span&gt; as now player 2 gets to pick first and player 1 responds. Obviously, player 2 prefers &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, but can't prevent the first player from getting a positive outcome. Since we can pick &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; arbitrarily large, this gap is clearly unbounded, both in a relative and absolute sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These kind of problems are particularly nasty if you are not able to exploit any special structure of your function, which is only possible if you are somewhat lucky, e.g. you can apply a strong duality results somewhere or have additional information that you can use to bound &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;. In fact, these problems are widely believed to be more difficult than NP-hard problems. Gerhard Woeginger gave a really good keynote on the difficulty of these multilevel problems at EURO2018 in Valencia from a computational complexity perspective (he talks mostly about universal and existential quantors, but the idea is the same). He mentions a few rare cases where you end up being lucky, and others where basically no-one knows what to do. There is a &lt;a href=&quot;http://euro2018valencia.com/plenaries-and-key-notes/#Gerhard_Woeginger&quot; rel=&quot;nofollow noreferrer&quot;&gt;video available on the EURO2018 website&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastActivityDate="2020-04-25T06:25:53.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3991" PostTypeId="1" CreationDate="2020-04-25T19:16:19.113" Score="2" ViewCount="1064" Body="&lt;p&gt;I have the following sets, variables, and parameters in a GAMS model.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set \quad h/1*3/;&#xA;alias (h,t);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Positive variables are &lt;span class=&quot;math-container&quot;&gt;$p_d(h)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p_c(h)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e(h)$&lt;/span&gt;. Parameters are &lt;span class=&quot;math-container&quot;&gt;$\eta = 0.9$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e(0) = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I want to write the following equation in GAMS: &lt;span class=&quot;math-container&quot;&gt;$$e(h) = e(0)-\sum_{t=1}^h p_d(t)+\eta\cdot\sum_{t=1}^hp_c(t).$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="123" LastEditDate="2021-05-04T07:52:09.320" LastActivityDate="2021-10-19T14:06:40.453" Title="GAMS Sum over a subset" Tags="|gams|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3992" PostTypeId="1" CreationDate="2020-04-26T03:57:58.633" Score="3" ViewCount="268" Body="&lt;p&gt;I have a set partitioning formulation with each constraint being an equality constraint to meet the given demand (right-hand side of the constraint).&#xA;For each constraint, I have a slack and a surplus variables to penalize under- and over-coverage in the objective function.&#xA;The presence of slack and surplus variables makes initial basis readily available to start simplex algorithm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When solving this formulation with coin-or lp solver CLP, I would like to indicate this initial basis.&#xA;I tried to set ClpSimplex::setColumnStatus(), but the subsequent call of ClpSimplex::primal() seems to ignore such a suggestion, introduces an auxiliary variable for each constraint, and creates additional degeneracy.&#xA;Moreover, for some constraints with both slack and surplus variables equal to zero in the found optimal solution, the corresponding auxiliary variable is still part of the found optimal basis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to manually indicate initial basis in CLP so that the solver does not introduce auxiliary variables?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not tried other solvers like CPLEX or Gurobi.&#xA;Do they provide the possibility to manually indicate initial basis?&lt;/p&gt;&#xA;" OwnerUserId="3428" LastActivityDate="2020-04-28T10:43:36.633" Title="Manually indicate initial basis for coin-or lp solver CLP" Tags="|linear-programming|simplex|coin-or|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3993" PostTypeId="1" AcceptedAnswerId="3994" CreationDate="2020-04-26T15:42:38.620" Score="6" ViewCount="210" Body="&lt;p&gt;I am solving a minimization problem with a column generation procedure. The master problem is of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \sum_{i\in \Omega}c_i \lambda_i&#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i\in \Omega \mid v \in i } \lambda_i = 1 \quad \forall v \in V&#xA;$$&lt;/span&gt;&#xA;Columns &lt;span class=&quot;math-container&quot;&gt;$\lambda_i$&lt;/span&gt; represent paths with nodes belonging to set &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\pi_v$&lt;/span&gt; denote the dual variable associated with each constraint. In my subproblem, I am looking for columns that have smallest marginal cost :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\hat{c}_i = c_i - \sum_{v\in V, v \in i} \pi_v&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, if &lt;span class=&quot;math-container&quot;&gt;$\pi_v &amp;lt;0$&lt;/span&gt;, can I safely delete node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; from the subproblem (as passing through &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; will increase the global cost) ? Or do I have to keep it, in case passing through &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is the only way to access other nodes that together have a potential negative reduced cost ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More generally, is there a strategy to delete useless nodes or edges from the subproblem to speed up computation ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/037722179190319Q&quot; rel=&quot;noreferrer&quot;&gt;this article&lt;/a&gt; by Francois Soumis et al (a VRP variant solved with column generation), edges and nodes are eliminated heuristically from the sunproblem: [p.15, section 4.3]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/k4N9Qm.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/k4N9Qm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They refer the reader to another paper ([14]) for the details of these &quot;heuristics,&quot; but the paper is nowhere to be found. I am interested in such techniques as my problem is also a VRP variant (my subproblem also consists in finding some sort of shortest path).&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-04-26T17:54:38.100" LastActivityDate="2020-04-27T18:56:48.087" Title="When using column generation, can I delete a node with negative reduced cost from my subproblem?" Tags="|duality|column-generation|reduced-costs|branch-and-price|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3994" PostTypeId="2" ParentId="3993" CreationDate="2020-04-26T19:59:30.900" Score="4" Body="&lt;p&gt;If your sub-problem is a shortest path problem on a complete graph, without resource constraints, you can delete vertices which don't decrease the reduced cost. Indeed, for any path containing such a vertex, removing the vertex gives another path which is both feasible for the sub-problem and which corresponds to a master problem column with smaller reduced cost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the graph is not complete, in general you cannot delete vertices because you might even disconnect the graph. Analogously, if you have resource constraints, removing a vertex might (in the extreme case) disallow the only resource-feasible paths. Whether you can do vertex removal under special circumstances is, I think, problem-dependent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://santini.in/files/papers/santini-plum-ropke-2017.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;my experience&lt;/a&gt;, &lt;em&gt;heuristic&lt;/em&gt; vertex or arc removal can give good results. Especially if your sub-problem has high complexity, say pseudo-polynomial or worse. Just make sure that you solve the sub-problem exactly (i.e., with no heuristics) at the end of the exploration of each node, to make sure that there are no more negative-reduced-cost columns.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2020-04-27T18:56:48.087" LastActivityDate="2020-04-27T18:56:48.087" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3995" PostTypeId="1" CreationDate="2020-04-27T17:03:01.103" Score="1" ViewCount="841" Body="&lt;p&gt;Apologies for my basic question, but I am kinda new to optimization methods, and I am bumping into the optimization problem below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min_{x} (c_1 \cdot u_1 + c_2 \cdot u_2)\\&#xA;	\mbox{subject to:}\\&#xA;	u_1 \geq  f(x) \\&#xA;	u_2 \geq  g(x) \\&#xA;	u_1, u_2 \geq 0&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, I would like to minimize the cost function with decision variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. However, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; does not exist in my objective function but instead is hidden in two constraints. &lt;span class=&quot;math-container&quot;&gt;$f(x), g(x)$&lt;/span&gt; are two functions of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, which can be any functions. In the simplest case, it can be just a linear function such as &lt;span class=&quot;math-container&quot;&gt;$w^Tx$&lt;/span&gt;; however, it can be altered to any more complicated function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is this a linear or non-linear problem? I think it is a non-linear problem but I am not so sure.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Do you know any solver that I can use to solve this problem and which methods to use? Would be nice if I can directly use it with Python. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any suggestion/hint would be highly appreciated. Thank you in advance. &lt;/p&gt;&#xA;" OwnerUserId="3437" LastEditorUserId="38" LastEditDate="2020-04-27T17:40:34.490" LastActivityDate="2020-04-27T20:26:57.510" Title="Solving a (Non-)Linear Programming Problem" Tags="|optimization|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3996" PostTypeId="2" ParentId="3995" CreationDate="2020-04-27T19:13:02.373" Score="7" Body="&lt;p&gt;The problem is to minimize with respect to &lt;span class=&quot;math-container&quot;&gt;$x, u_1$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$u_2$&lt;/span&gt; (i.e., those are the decision, a.k.a. optimization, variables).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; are both linear, this is a Linear Programming (LP) problem; otherwise it is a Nonlinear Programming (NLP) problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is a Linear Programming problem, then use an LP solver. There are many optimization modeling systems, tools, and solvers available under Python, essentially all of which should be able to handle LPs, and which can be found by searching this site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is a Nonlinear Programming problem, you will need an NLP solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to what NLP solver  to use, that depends on the form and properties of &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt;, such as continuity, differentiability, availability of derivatives, convexity, special form such as (convex) quadratic (QCQP), or second order cone (SOCP)), etc.  There are many optimization modeling systems, tools, and solvers available under Python, many of which can handle either somewhat general NLPs, or perhaps special cases, such as QCQP and SOCP. Solvers specialized for special cases may perform better and be easier to use for those cases. If you use a fairly general optimization tool, you may be able to handle variations on &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; of the type which change the problem class. &lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-04-27T19:13:02.373" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3997" PostTypeId="2" ParentId="3995" CreationDate="2020-04-27T20:19:42.417" Score="1" Body="&lt;p&gt;The answer by Mark L. Stone is to the point. In addition to it, I would suggest you read about metaheuristics, especially Genetic Algorithms. Some useful links for it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] Goldberg, D. E. (2006). Genetic algorithms. Pearson Education India.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] Bäck, T., Fogel, D. B., &amp;amp; Michalewicz, Z. (1997). Handbook of evolutionary computation. CRC Press.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[3] &lt;a href=&quot;https://towardsdatascience.com/introduction-to-genetic-algorithms-including-example-code-e396e98d8bf3&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://towardsdatascience.com/introduction-to-genetic-algorithms-including-example-code-e396e98d8bf3&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[4] &lt;a href=&quot;https://towardsdatascience.com/introduction-to-optimization-with-genetic-algorithm-2f5001d9964b&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://towardsdatascience.com/introduction-to-optimization-with-genetic-algorithm-2f5001d9964b&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The GAs are population-based randomized search heuristics, inspired by the theory of genetics and natural selection, whose search is not strictly dependent on the nature (linear/non-linear) of the optimization problem. One thing I have experienced about GAs is that the GA-search can be as powerful/efficient as you could design it by customizing operators using the problem's domain knowledge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For its code in python, you could refer to the GA-code uploaded by Prof. K. Deb:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] &lt;a href=&quot;https://pymoo.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pymoo.org/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] Blank, J., &amp;amp; Deb, K. (2020). pymoo: Multi-objective Optimization in Python. arXiv preprint arXiv:2002.04504.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples of customized operators in GA are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] enhanced initialization, i.e., to generate at least one feasible solution in the initial population instead of all randomized ones,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] retaining poor/infeasible solutions to maintain diversity in the population,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[3] enhanced crossover/mutation operators,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[4] infeasibility repair operators, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some useful articles for such customizations are (though the problem formulations might be different, you will get some idea about it):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] J. E. Beasley, P. C. Chu, A genetic algorithm for the set covering problem, European journal of operational research 94 (2) (1996) 392–404.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] Deb, K., &amp;amp; Myburgh, C. (2016, July). Breaking the billion-variable barrier in real-world optimization using a customized evolutionary algorithm. In Proceedings of the Genetic and Evolutionary Computation Conference 2016 (pp. 653-660). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;[3] D. Aggarwal, D. K. Saxena, T. Bäck, M. Emmerich, Real-World Airline Crew Pairing Optimization: Customized Genetic Algorithm versus Column Generation Method, arXiv:2003.03792 [cs.NE] (Unpublished).&lt;/p&gt;&#xA;" OwnerUserId="2999" LastEditorUserId="2999" LastEditDate="2020-04-27T20:26:57.510" LastActivityDate="2020-04-27T20:26:57.510" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3998" PostTypeId="1" AcceptedAnswerId="4000" CreationDate="2020-04-28T01:10:47.287" Score="3" ViewCount="245" Body="&lt;p&gt;I am trying to represent the following inequality: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{x}{1-x} \leq y \qquad\mathrm{with}\qquad 0&amp;lt;x&amp;lt;1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function on the left is convex (its second derivative is always positive over the domain &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;x&amp;lt;1$&lt;/span&gt;), meaning that the described set is convex. (Without the domain constraint, however, the domain is far from convex…) Drawing it gives the same conclusion: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8qgxu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8qgxu.png&quot; alt=&quot;The set described by this inequality&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I cannot find a DCP representation of this set (even using nonstandard cones). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can do it with a slight modification (replacing &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt;, two quad-over-lin constraints do the trick, CVX also accepts the constraint as &lt;span class=&quot;math-container&quot;&gt;$y\geq\frac{x^2}{z}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z\leq 1-x^2$&lt;/span&gt;), but it is not describing the same set, and the difference is really significant in my case. &lt;/p&gt;&#xA;" OwnerUserId="156" LastActivityDate="2020-04-28T13:02:57.917" Title="DCP representation of a convex quotient of affine functions" Tags="|convex-optimization|disciplined-convex-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3999" PostTypeId="2" ParentId="3998" CreationDate="2020-04-28T02:47:43.277" Score="5" Body="&lt;p&gt;You can model your constraint with the second order cone constraint &lt;span class=&quot;math-container&quot;&gt;$$\sqrt{2^2 + (x+y)^2} \le 2-x+y,$$&lt;/span&gt; and a lower bound on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this by first multiplying both sides by &lt;span class=&quot;math-container&quot;&gt;$1-x$&lt;/span&gt; to obtain &lt;span class=&quot;math-container&quot;&gt;$(1-x)y - x &amp;gt;= 0$&lt;/span&gt;. As we have a quadratic inequality with a convex feasible region, this hints to a quadratic or second order cone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rewriting this constraint gives &lt;span class=&quot;math-container&quot;&gt;$(1-x)(1+y) \ge 1$&lt;/span&gt;. Then I used Equation (7) in &lt;a href=&quot;https://doi.org/10.1016/S0024-3795(98)10032-0&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; to turn the constraint into a second order cone constraint.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2020-04-28T13:02:57.917" LastActivityDate="2020-04-28T13:02:57.917" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4000" PostTypeId="2" ParentId="3998" CreationDate="2020-04-28T05:38:56.790" Score="5" Body="&lt;p&gt;Here is an alternative answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clearly, the problem is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rcl}&#xA;\frac{1-t}{t} &amp;amp; \leq &amp;amp; y \\&#xA;1-x           &amp;amp; =    &amp;amp; t \\&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;which in turn is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rcl}&#xA;\frac{1}{t}  -1 &amp;amp; \leq &amp;amp; y \\&#xA;1-x             &amp;amp; =    &amp;amp; t \\&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;This is clearly SOCP representable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should end up with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rcl}&#xA;2 (1-x) (1+y) &amp;amp; \geq &amp;amp; \sqrt{2}^2 \\&#xA;1-x           &amp;amp; \geq &amp;amp; 0 \\&#xA;1+y           &amp;amp; \geq &amp;amp; 0 \\   &#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;which is the same as saying&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left [&#xA;\begin{array}{c}&#xA;1-x \\&#xA;1+y \\&#xA;\sqrt{2} \\&#xA;\end{array}&#xA;\right ] \in RQ&#xA;$$&lt;/span&gt;&#xA;where RQ is a rotated quadratic cone as defined in the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;noreferrer&quot;&gt;Mosek modelling cook book&lt;/a&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2020-04-28T07:07:57.463" LastActivityDate="2020-04-28T07:07:57.463" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4001" PostTypeId="1" AcceptedAnswerId="4003" CreationDate="2020-04-28T08:21:59.570" Score="5" ViewCount="226" Body="&lt;p&gt;Given that you have identified a new class of valid inequalities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are some guidelines on when and how many and which of the violated user cuts you add to the model?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that this involves a lot of benchmarking, but are there some common wisdom? What are the first things you try?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I saw that adding too many cuts slows down the processing of the nodes in the branch-and-bound tree and I think that will fall under the &quot;Conventional wisdom&quot;.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2020-04-28T08:38:14.010" LastActivityDate="2020-04-28T12:50:17.903" Title="Guidelines for adding user cuts to models" Tags="|gurobi|valid-inequalities|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4002" PostTypeId="2" ParentId="3992" CreationDate="2020-04-28T10:43:36.633" Score="2" Body="&lt;p&gt;in CPLEX you can use warmstart with all APIs. Let me show you in OPL:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;.mod&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int nbKids=300;&#xA;&#xA;// a tuple is like a struct in C, a class in C++ or a record in Pascal&#xA;tuple bus&#xA;{&#xA; key int nbSeats;&#xA; float cost;&#xA;}&#xA;&#xA;&#xA;// This is a tuple set&#xA;{bus} pricebuses=...;&#xA;&#xA;// asserts help make sure data is fine&#xA;assert forall(b in pricebuses) b.nbSeats&amp;gt;0;assert forall(b in pricebuses) b.cost&amp;gt;0;&#xA;&#xA;&#xA;// To compute the average cost per kid of each bus&#xA;// you may use OPL modeling language&#xA;&#xA;float averageCost[b in pricebuses]=b.cost/b.nbSeats;&#xA;&#xA;// Let us try first with a naïve computation, use the cheapest bus&#xA;&#xA;float cheapestCostPerKid=min(b in pricebuses) averageCost[b];&#xA;int cheapestBusSize=first({b.nbSeats | b in pricebuses : averageCost[b]==cheapestCostPerKid});&#xA;int nbBusNeeded=ftoi(ceil(nbKids/cheapestBusSize));&#xA;&#xA;float cost0=item(pricebuses,&amp;lt;cheapestBusSize&amp;gt;).cost*nbBusNeeded;&#xA;execute DISPLAY_Before_SOLVE&#xA;{&#xA;  writeln(&quot;The naïve cost is &quot;,cost0);&#xA;  writeln(nbBusNeeded,&quot; buses &quot;,cheapestBusSize, &quot; seats&quot;);&#xA;  writeln();&#xA;}&#xA;&#xA;int naiveSolution[b in pricebuses]=&#xA;  (b.nbSeats==cheapestBusSize)?nbBusNeeded:0;&#xA;&#xA;&#xA;// decision variable array&#xA;dvar int+ nbBus[pricebuses];&#xA;&#xA;// objective&#xA;minimize&#xA;  sum(b in pricebuses) b.cost*nbBus[b];&#xA;&#xA;// constraints&#xA;subject to&#xA;{&#xA;  sum(b in pricebuses) b.nbSeats*nbBus[b]&amp;gt;=nbKids;&#xA;}&#xA;&#xA;float cost=sum(b in pricebuses) b.cost*nbBus[b];&#xA;execute DISPLAY_After_SOLVE&#xA;{&#xA; writeln(&quot;The minimum cost is &quot;,cost);&#xA; for(var b in pricebuses) writeln(nbBus[b],&quot; buses &quot;,b.nbSeats, &quot; seats&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;main&#xA;{&#xA;thisOplModel.generate();&#xA;// Warm start the naïve solution&#xA;cplex.addMIPStart(thisOplModel.nbBus,thisOplModel.naiveSolution);&#xA;cplex.solve();&#xA;thisOplModel.postProcess();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.dat&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pricebuses={&amp;lt;40,500&amp;gt;,&amp;lt;30,400&amp;gt;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then we get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The naïve cost is 4000&#xA;8 buses 40 seats&#xA;&#xA;The minimum cost is 3800&#xA;6 buses 40 seats&#xA;2 buses 30 seats&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in the cplex log we see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 of 1 MIP starts provided solutions.&#xA;MIP start 'm1' defined initial solution with objective 4000.0000.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The warmstart is in the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Warm start the naïve solution&#xA;cplex.addMIPStart(thisOplModel.nbBus,thisOplModel.naiveSolution);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and many other similar tiny examples at &lt;a href=&quot;https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-04-28T10:43:36.633" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4003" PostTypeId="2" ParentId="4001" CreationDate="2020-04-28T11:34:31.340" Score="5" Body="&lt;p&gt;Performance-wise, there are two main classes of cuts: (i) normal cuts, and (ii) global or &quot;deep&quot; cuts (definitions may vary between fields, this is what we use in deterministic global optimisation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Deep cuts are globally valid, i.e., they are valid at every node of a branch-and-bound tree. This is usually the most desirable type of cut, because we don't have to change the coefficient matrix too much (or at all) when we create a new node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every cut that is not deep, is normal, and not necessarily globally valid. These are situational, but often crucial to close the last few % of the optimality gap and converge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cuts are nearly always good from a theoretical point of view, the problem is that they make relaxations harder to solve so there's always a tradeoff. The rule of thumb is to add as many deep cuts as you can afford in the beginning (you can measure the tradeoff by resolving at the root node a few times with more cuts), and then add other cuts where necessary. This can be done dynamically by creating and keeping track of a pool of cuts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ruth Misener has documented the dynamic approach very well on her papers about the &lt;a href=&quot;https://link.springer.com/article/10.1007/s10898-012-9874-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;GloMIQO&lt;/a&gt; solver.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-04-28T12:50:17.903" LastActivityDate="2020-04-28T12:50:17.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4004" PostTypeId="1" AcceptedAnswerId="4007" CreationDate="2020-04-28T13:05:22.390" Score="7" ViewCount="170" Body="&lt;p&gt;Suppose a MILP model includes the following constraint: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA;\begin{gather*}&#xA;B_{1} + B_{2} + B_{3} \le 100&#xA;\end{gather*}&#xA;$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$B_{1},B_{2},B_{3}$&lt;/span&gt; are nonnegative reals.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose that &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{gather*}&#xA;(B_{1},B_{2},B_{3}) = (10,30,60) \\  &#xA;(B_{1},B_{2},B_{3}) = (20,60,20)\\&#xA;(B_{1},B_{2},B_{3}) = (80,10,10) \\&#xA;(B_{1},B_{2},B_{3}) = (60,10,10) \\&#xA;\cdots&#xA;\end{gather*}&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;are optimal solution vectors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to tell the solver to prefer one of these solution vectors over the others? For example, is it possible to formulate a constraint that tells the solver to prefer an optimal solution with increasing values (if it exists?)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I need to clarify the purpose of the approach I am looking for. The purpose is not really to find a &quot;preferred&quot; solution but to help the B&amp;amp;B to get faster to the optimal solution by cutting off solutions that have the same value as the &quot;preferred&quot;. So I don't want to determine all alternative solutions and then choose one, I want to get as fast as possible to a solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding constraints &lt;span class=&quot;math-container&quot;&gt;$B_{1} \le B_{2} \le B_{3} ... $&lt;/span&gt; would help if I knew that there exists an optimal solution that satisfies these constraints, but I don't know this. &lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="1269" LastEditDate="2020-04-29T08:53:05.187" LastActivityDate="2020-04-29T08:53:05.187" Title="How can preferences be modelled in MILPs?" Tags="|mixed-integer-programming|modeling|symmetry|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4005" PostTypeId="2" ParentId="1117" CreationDate="2020-04-28T13:20:31.630" Score="4" Body="&lt;p&gt;This is my job so I can write an essay on this, but I'll give you the highlights:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open source solvers have just enough bugs that you can't charge money for them. The most vexing thing about them is that they can't be trusted to return the right flags so it's not really viable to use them as dependencies.&lt;/li&gt;&#xA;&lt;li&gt;You will bleed before you get open source to build on Windows. I hired a pro to do this and it took him 3 months.&lt;/li&gt;&#xA;&lt;li&gt;If you use open source, you have a lot of license limitations to worry about, on top of making sure your dependencies don't break. &lt;/li&gt;&#xA;&lt;li&gt;GPL software must be avoided like the plague, unless there's a runtime exception. Even then, link at your own peril.&lt;/li&gt;&#xA;&lt;li&gt;Due to license limitations you can't statically compile most dependencies into your binary, which means that you need professional-level skills to make sure that your binary doesn't link to the wrong library when deployed to a customer.&lt;/li&gt;&#xA;&lt;li&gt;Compile everything at the lowest version of GLIBC that you can afford to, as it's not backward compatible and will break between different Linux systems.&lt;/li&gt;&#xA;&lt;li&gt;Be mindful of the fact that shared libraries have dependencies of their own, that don't necessarily match those of your code.&lt;/li&gt;&#xA;&lt;li&gt;Have something that works on Windows, that's what most people use.&lt;/li&gt;&#xA;&lt;li&gt;You can use Docker for fool-proof compatibility/deployment, but customers don't like installing Docker just to run 1 thing. Ideally, use a native Windows build or deploy over a Web API.&lt;/li&gt;&#xA;&lt;li&gt;If you do use the Web API, try a Linux server and Flask + React, it works like a charm on every system.&lt;/li&gt;&#xA;&lt;li&gt;Don't worry about providing a GUI unless you absolutely have to. GUIs are very complex to debug and to set up quality control.&lt;/li&gt;&#xA;&lt;li&gt;Use continuous integration. This is the first thing you should do.&lt;/li&gt;&#xA;&lt;li&gt;Come to terms with the unfortunate fact that deploying a solution that works and getting paid for it in this space requires a team of people who know what they are doing, because the overwhelming majority of open source OR code is just not at the quality level where it can be used out of the box by anyone who is not the author of that software.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As a final thought, if you want to learn how new software is deployed correctly and reliably, get a job at a software startup that is at that stage. Crucially, make sure there's at least one person there who know what they're doing, otherwise you won't learn much and the company will flop. Deployment is one of the toughest things to execute correctly in software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few months in that environment will give you a lifetime of experience.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-04-29T02:19:44.340" LastActivityDate="2020-04-29T02:19:44.340" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4006" PostTypeId="1" CreationDate="2020-04-28T14:42:29.420" Score="5" ViewCount="63" Body="&lt;p&gt;I am running a fairly complex and dynamic(multi-period) model, and as a result of the complexity, solvers are not able to solve the problem in a reasonable time frame. I have since discovered the rolling-horizon method which could help to alleviate the time that it takes to get to a solution. My supervisor has advised me to &lt;em&gt;not&lt;/em&gt; use a rolling-horizon method specifically because the model is dynamic, and after a brief conversation about the rolling-horizon optimization approach, I left more confused. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am hoping that somebody might be able to explain why the rolling-horizon algorithm is not suitable for a dynamic model so that I can try and get a different perspective on why the approach is not good to use in the case of dynamic systems. &lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="547" LastEditDate="2020-04-28T17:35:55.533" LastActivityDate="2020-04-28T17:35:55.533" Title="Relative Weakness of Rolling Horizon Optimization" Tags="|algorithms|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4007" PostTypeId="2" ParentId="4004" CreationDate="2020-04-28T15:37:04.133" Score="4" Body="&lt;p&gt;An alternative to @Mark L. Stone's comment would be to define new variables &lt;span class=&quot;math-container&quot;&gt;$\delta_i \in \{0,1\}$&lt;/span&gt; and add the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;B_i \le B_{i+1} + M \delta_i\quad \forall i&#xA;$$&lt;/span&gt;&#xA;and then penalize the activation of &lt;span class=&quot;math-container&quot;&gt;$\delta_i$&lt;/span&gt; in the objective function by adding a term such as &lt;span class=&quot;math-container&quot;&gt;$\sum_{i}\omega_i \delta_i$&lt;/span&gt;. In your example, &lt;span class=&quot;math-container&quot;&gt;$M:=100$&lt;/span&gt; is suitable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way, if there exists a solution with increasing values of &lt;span class=&quot;math-container&quot;&gt;$B_i$&lt;/span&gt;, it will be returned, with &lt;span class=&quot;math-container&quot;&gt;$\delta_i =0$&lt;/span&gt;. Otherwise, the constraint is deactivated, at the expense of a penalty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note however that this approach may disrupt your initial objective function, you will have to choose proper weights &lt;span class=&quot;math-container&quot;&gt;$\omega_i$&lt;/span&gt; for variables &lt;span class=&quot;math-container&quot;&gt;$\delta_i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2020-04-28T16:49:06.907" LastActivityDate="2020-04-28T16:49:06.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4008" PostTypeId="2" ParentId="4004" CreationDate="2020-04-28T17:18:10.757" Score="2" Body="&lt;p&gt;The following is solver-specific. CPLEX has a &quot;solution pool&quot; feature. By setting certain parameters, you can tell CPLEX to accumulate many or possibly all optimal solutions. Once CPLEX has terminated, you can scan through the optimal solutions using code you wrote that picks the solution you most prefer. I don't which, if any, other solvers have a solution pool feature.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-04-28T17:18:10.757" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4009" PostTypeId="1" CreationDate="2020-04-29T04:35:06.937" Score="4" ViewCount="823" Body="&lt;p&gt;Suppose I have made a Gurobi model in Python &lt;code&gt;model = Model()&lt;/code&gt;, defined variables, constraints, objective function, and solved it. However, I want to make a deepcopy of &lt;code&gt;model&lt;/code&gt; denoted as &lt;code&gt;new_model&lt;/code&gt;. How should I make a deepcopy of this model? I have tried &lt;code&gt;new_model = copy.deepcopy(model)&lt;/code&gt;, but it causes an error &lt;code&gt;KeyError: '__deepcopy__'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2020-04-29T07:41:56.523" Title="How to make a copy of a Gurobi model in Python?" Tags="|python|gurobi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4010" PostTypeId="2" ParentId="4009" CreationDate="2020-04-29T07:41:56.523" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/37307643&quot;&gt;This&lt;/a&gt; question and answer are directly related to your question. But you can also look at Gurobi's discussion about copying a model in its own &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360051091912-Can-model-copy-also-copy-my-own-data-structures-of-variables-in-the-original-model-in-Python-&quot; rel=&quot;nofollow noreferrer&quot;&gt;website&lt;/a&gt;, or &lt;a href=&quot;https://groups.google.com/forum/#!topic/gurobi/Q_d0Qdk_sFk&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; google group. In summary, you need to name your variable, and after copying the model remap your variable with those names(which need to be saved before).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from gurobipy import Model&#xA;# A model with 10 variables...&#xA;variable_names = {}&#xA;model = Model(&quot;test&quot;)&#xA;variables = {}&#xA;for i in range(10):&#xA;    variable_names[i] = &quot;var{0}&quot;.format(i)&#xA;    variables[i] = model.addVar(lb=-1, ub=1, name=variable_names[i])&#xA;model.update()&#xA;&#xA;new_model = model.copy()&#xA;new_var = {}&#xA;for i in range(10):&#xA;    model.addConstr(variables[i] &amp;lt;= 0)&#xA;    new_var[i] = new_model.getVarByName(variable_names[i])&#xA;    new_model.addConstr(new_var[i] &amp;gt;= 0)&#xA;model.update()&#xA;new_model.update()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-04-29T07:41:56.523" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4011" PostTypeId="1" AcceptedAnswerId="4012" CreationDate="2020-04-29T10:44:46.420" Score="14" ViewCount="246" Body="&lt;p&gt;Consider a linear program &#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(b)=\min_{x}\{c^\top x: A x = b, x\geq 0\}$$&lt;/span&gt;&#xA;(assume it is feasible and bounded for all &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;). My understanding is that &lt;span class=&quot;math-container&quot;&gt;$f(b)$&lt;/span&gt; is a convex piecewise linear function of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; (can be shown taking the dual of the LP, see below).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;My question&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Can I also say that &lt;span class=&quot;math-container&quot;&gt;$f(b)$&lt;/span&gt; is continuous? Or when can I say that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below my attempts to workout a proof, though I strongly believe someone has done that already.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Proof that &lt;span class=&quot;math-container&quot;&gt;$f(b)$&lt;/span&gt; is convex and piecewise linear&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;By strong duality&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(b)=\min_{x}\{c^\top x: A x = b, x\geq 0\}=\max_\pi\{\pi b:\pi A\leq c\}$$&lt;/span&gt;&#xA;If we let &lt;span class=&quot;math-container&quot;&gt;$\pi_1,\ldots,\pi_K$&lt;/span&gt; be the extreme points of &lt;span class=&quot;math-container&quot;&gt;$\{\pi A\leq c\}$&lt;/span&gt; we can rewrite the dual as &#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(b)=\max_{\pi_1,\ldots,\pi_K}\{\pi_i b\}$$&lt;/span&gt;&#xA;This gives us a piecewise linear function in &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. Furthermore, the pointwise max of a set of linear functions is convex, hence &lt;span class=&quot;math-container&quot;&gt;$f(b)$&lt;/span&gt; is convex and piecewise linear in &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Working out a proof&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Assume we take &lt;span class=&quot;math-container&quot;&gt;$b\in B$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, loosely speaking is the set of vectors &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; for which the linear program has a finite optimal solution, i.e. &lt;span class=&quot;math-container&quot;&gt;$f(b)$&lt;/span&gt; is defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, since linear functions are continuous, if the pointwise maximum of continuous functions is continuous the proof is done (but I do not know if that holds). I will try in another way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a sequence &lt;span class=&quot;math-container&quot;&gt;$(b_n)$&lt;/span&gt; converging to &lt;span class=&quot;math-container&quot;&gt;$b_0$&lt;/span&gt; (assume &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is closed). I need to show that &lt;span class=&quot;math-container&quot;&gt;$\lim f(b_n)=f(b_0)$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\lim f(b_n) =&amp;amp; \lim\max_{\pi_1,\ldots,\pi_K}\{\pi_i b_n\}\\&#xA;=&amp;amp;\max_{\pi_1,\ldots,\pi_K}\{\lim\pi_i b_n\}\\&#xA;=&amp;amp;\max_{\pi_1,\ldots,\pi_K}\{\pi_i\lim b_n\}\\&#xA;=&amp;amp;\max_{\pi_1,\ldots,\pi_K}\{\pi_i b_0\}\\&#xA;=&amp;amp;f(b_0)&#xA;\end{align}$$&lt;/span&gt;&#xA;Hence &lt;span class=&quot;math-container&quot;&gt;$f(b)$&lt;/span&gt; is continuous. But I am walking on thin ice when I say that the limit of the maximum is equal to the maximum of the limit (second line).&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="766" LastEditDate="2020-04-29T13:45:44.890" LastActivityDate="2020-04-29T15:03:20.720" Title="Is the optimal objective of a linear program continuous in its right-hand-side?" Tags="|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4012" PostTypeId="2" ParentId="4011" CreationDate="2020-04-29T14:45:20.850" Score="5" Body="&lt;p&gt;If the linear program is feasible and bounded for all &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$f(b)$&lt;/span&gt; is finite, i.e. &lt;span class=&quot;math-container&quot;&gt;$-\infty &amp;lt; f(b) &amp;lt; +\infty$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$b \in \mathbb{R}^m$&lt;/span&gt;. By strong duality, &lt;span class=&quot;math-container&quot;&gt;$f(b)$&lt;/span&gt; is also convex, as you have shown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a classical result that all convex functions finite on &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^m$&lt;/span&gt; are continuous. See for example the book &lt;em&gt;Convex Analysis&lt;/em&gt; by Rockafellar, Corollary 10.1.1. To demonstrate the usefulness of the corollary, an example about the pointwise supremum of convex functions is given, which is very similar to your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things might be a little bit more complicated if there exist &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$f(b) \in \{-\infty,+\infty\}$&lt;/span&gt;, but for this case, &lt;em&gt;Convex Analysis&lt;/em&gt; should also be a good resource.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Rockafellar, R. T. (1970). Convex analysis (No. 28). Princeton university press.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2020-04-29T15:03:20.720" LastActivityDate="2020-04-29T15:03:20.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4013" PostTypeId="1" AcceptedAnswerId="4014" CreationDate="2020-04-29T17:21:33.393" Score="2" ViewCount="660" Body="&lt;p&gt;I am trying to implement an employee (nurse) scheduling problem and seek some advice on how to implement a specific constraint.The problem is as follows: There is a set of employees and days (both labeled by integer numbers). Each employee can be assigned a day shift &lt;code&gt;D[(i, j)]&lt;/code&gt; , nightshift &lt;code&gt;N[(i, j)]&lt;/code&gt; or a day off &lt;code&gt;V[(i, j)]&lt;/code&gt;. These are my decision variables:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;D = LpVariable.dicts(name=&amp;quot;Dagdienst&amp;quot;, indexs=[(i, j) for i in employees for j in days], cat='Binary')&#xA;N = LpVariable.dicts(name=&amp;quot;Nachtdienst&amp;quot;, indexs=[(i, j) for i in employees for j in days], cat='Binary')&#xA;V = LpVariable.dicts(name=&amp;quot;Vrij&amp;quot;, indexs=[(i, j) for i in employees for j in days], cat='Binary')&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;An example constraint to enforce either a dayshift, nightshift or day-off for each day and each employee is the following.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in employees:&#xA;    for j in days:&#xA;        m += D[(i, j)] + N[(i, j)] + V[(i, j)] == 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To give you some idea what I'm working with, two other constraints are the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in employees:&#xA;    for j in range(1, len(days)-1):&#xA;        m += N[(i, j)] + D[(i, (j + 1))] &amp;lt;= 1&#xA;        m += N[(i, j)] + D[(i, (j + 2))] &amp;lt;= 1&#xA;&#xA;max_consecutive_days = 4&#xA;for i in medewerkers:&#xA;    for j in range(1, (len(days)+1 - max_consecutive_days)):&#xA;        m += D[(i, j)] + D[(i, j + 1)] + D[(i, j + 2)] + D[(i, j + 3)]+ D[(i, j + 4)] &amp;lt;= max_consecutive_days&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The first constraint enforces two days off after a night shift and the second one makes sure an employee cannot be assigned more than 4 consecutive day shifts. I hope the implementation of the aforementioned constraint speak for themselves, if not please ask.&lt;/p&gt;&#xA;&lt;p&gt;In the same fashion I am trying to implement a constraint that ensures a break (a break is a series of day-offs) always has a minimum length of 2 days. It must enforce something like the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in medewerkers:&#xA;    for j in range(1, len(days):&#xA;        m += (V[(i, j)] + V[(i, j + 1)]) mod 2 == 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, taking the modulo is not allowed here and this conditional constraint must be formulated in a different way.&lt;/p&gt;&#xA;&lt;p&gt;How do I do this?&lt;/p&gt;&#xA;" OwnerUserId="3442" LastEditorUserId="491" LastEditDate="2022-01-10T22:11:42.300" LastActivityDate="2022-01-10T22:11:42.300" Title="How to enforce this specific constraint in PuLP?" Tags="|linear-programming|modeling|python|pulp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4014" PostTypeId="2" ParentId="4013" CreationDate="2020-04-29T17:32:14.150" Score="6" Body="&lt;p&gt;In other words, you want to avoid a pattern of 010.  As a logical proposition:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\neg (\neg V_{i,j} \land V_{i,j+1} \land \neg V_{i,j+2}),$$&lt;/span&gt;&#xA;which you can write in conjunctive normal form as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V_{i,j} \lor \neg V_{i,j+1} \lor V_{i,j+2}.$$&lt;/span&gt;&#xA;The corresponding linear constraint is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V_{i,j} + (1 - V_{i,j+1}) + V_{i,j+2} \ge 1,$$&lt;/span&gt;&#xA;equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V_{i,j} - V_{i,j+1} + V_{i,j+2} \ge 0.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the boundary cases, treat &lt;span class=&quot;math-container&quot;&gt;$V_{i,j}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$V_{i,j+2}$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-04-29T17:32:14.150" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4015" PostTypeId="1" AcceptedAnswerId="5608" CreationDate="2020-04-29T20:05:08.937" Score="1" ViewCount="320" Body="&lt;p&gt;I implemented a branch-and-price tree in python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to stop the process after 5 hours and return the gap in % between the best integer solution found so far and the optimal solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I give a value to SCIP and ask how far in % is that from the optimal value?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: To those interested the question can now be found on:&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/61522580/stop-branch-and-price-tree-and-return-gap&quot;&gt;https://stackoverflow.com/questions/61522580/stop-branch-and-price-tree-and-return-gap&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3443" LastEditorUserId="354" LastEditDate="2021-01-26T14:12:06.683" LastActivityDate="2021-01-26T15:29:45.460" Title="Branch-and-Price: return gap using SCIP" Tags="|python|solver|branch-and-bound|branch-and-price|scip|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4016" PostTypeId="1" CreationDate="2020-04-29T20:23:40.043" Score="6" ViewCount="425" Body="&lt;p&gt;Suppose you want to solve a MIP with Benders decomposition and the binary variables (&lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;) are fixed in the master problem but these variables are used in the sub-problem with bigM like &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \le M.y_i \quad \lambda_{ij}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\lambda_{ij}$&lt;/span&gt; is the dual variable of these constraints. What is the best way to define dual problem and generate optimality and feasibility cuts? If &lt;span class=&quot;math-container&quot;&gt;$y_i=0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=0$&lt;/span&gt;, while if &lt;span class=&quot;math-container&quot;&gt;$y_i=1$&lt;/span&gt;, the constraint &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \le M.y_i $&lt;/span&gt; will be redundant. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2020-04-29T22:11:01.647" Title="How to handle bigM in sub-problem of benders decomposition?" Tags="|big-m|benders-decomposition|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4017" PostTypeId="2" ParentId="4016" CreationDate="2020-04-29T21:08:05.780" Score="3" Body="&lt;p&gt;For classical Benders decomposition, where the integer variables appear in the master and the continuous variables appear in the subproblem, you can use the LP subproblem duals to generate the optimality and feasibility cuts.  In that case, you can treat the big-M constraints like any other subproblem constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative approach to avoid explicit big-M constraints in the subproblem is to use &lt;em&gt;combinatorial (or logic-based) Benders decomposition&lt;/em&gt; in which the feasibility cuts are &quot;no-good&quot; cuts of the form &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in S} y_i \le |S|-1$&lt;/span&gt;.  If you require optimality cuts (because the original objective involves &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt;), they become big-M constraints in the master problem.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-04-29T21:08:05.780" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4018" PostTypeId="2" ParentId="4016" CreationDate="2020-04-29T22:11:01.647" Score="3" Body="&lt;p&gt;The following paper discusses this sort of constraint:&#xA;Codato, G. &amp;amp; Fischetti, M. (2006) &quot;Combinatorial Benders' Cuts for Mixed-Integer Linear Programming&quot;. &lt;em&gt;Operations Research&lt;/em&gt;, &lt;strong&gt;54&lt;/strong&gt;, 756-766&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-04-29T22:11:01.647" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4019" PostTypeId="1" AcceptedAnswerId="4020" CreationDate="2020-04-30T00:20:38.820" Score="2" ViewCount="597" Body="&lt;p&gt;In a linear program, I would like some variables to:&#xA;1.  Take the same values &#xA;2.  Group some variables i.e. some variables should take same values or lie within certain percentage.&#xA;3.  All different values&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The objective function is given by:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/c420X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/c420X.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3217" LastActivityDate="2020-04-30T01:00:01.983" Title="Same values constraint and grouping of variables" Tags="|linear-programming|combinatorial-optimization|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4020" PostTypeId="2" ParentId="4019" CreationDate="2020-04-30T01:00:01.983" Score="4" Body="&lt;p&gt;(1) This is correct, and there's nothing wrong with having a whole lot of constraints that each require &lt;span class=&quot;math-container&quot;&gt;$x_6 = x_j$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. But if you know in advance that these variables will all equal each other, why not just define a new variable that equals all of them? That is, create a variable &lt;span class=&quot;math-container&quot;&gt;$x_{6-10}$&lt;/span&gt; that equals &lt;span class=&quot;math-container&quot;&gt;$x_6$&lt;/span&gt; through &lt;span class=&quot;math-container&quot;&gt;$x_{10}$&lt;/span&gt; and use this variable everywhere any of the &lt;span class=&quot;math-container&quot;&gt;$x_6$&lt;/span&gt; through &lt;span class=&quot;math-container&quot;&gt;$x_{10}$&lt;/span&gt; variables appear?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) Using the logic described &lt;a href=&quot;https://or.stackexchange.com/questions/33/in-an-integer-program-how-i-can-force-a-binary-variable-to-equal-1-if-some-cond&quot;&gt;here&lt;/a&gt;, you can create a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_6$&lt;/span&gt; that equals 1 if &lt;span class=&quot;math-container&quot;&gt;$x_6 \ge 0$&lt;/span&gt;, and another binary variable &lt;span class=&quot;math-container&quot;&gt;$y_8$&lt;/span&gt; that equals 1 if &lt;span class=&quot;math-container&quot;&gt;$x_8 \ge 0$&lt;/span&gt;. Then you can enforce the &quot;if-then&quot; implications using the logic described &lt;a href=&quot;https://or.stackexchange.com/questions/76/in-an-integer-program-how-can-i-activate-a-constraint-only-if-a-decision-vari&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(3) Some solvers have a built-in feature that allows you to specify that certain variables must be different from each other; see &lt;a href=&quot;https://or.stackexchange.com/questions/2896/matrix-in-ampl-constraint-that-the-values-are-all-different&quot;&gt;Matrix in ampl: constraint that the values ​are all different&lt;/a&gt;. But I think this only works for integer variables. For continuous variables, I think you need to use big-Ms for this, although maybe others will chime in with better ideas.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-04-30T01:00:01.983" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4021" PostTypeId="1" CreationDate="2020-04-30T11:04:52.367" Score="2" ViewCount="223" Body="&lt;p&gt;How can I algorithmically detect whether an (MI)NLP problem is unbounded or not? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finding a source for this has proven tricky, because people in the literature seem to talk a lot about what to do if a problem is unbounded, but rarely about how to algorithmically detect that it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have considered checking whether the dual of the linear relaxation is proven to be infeasible, but linear solvers do not seem to report this very reliably, so that won't work for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also considered the trivial case where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have an unbounded variable in the objective which does not appear anywhere else, and &lt;/li&gt;&#xA;&lt;li&gt;the case where a higher-order convex term containing that var in the objective is cancelling out the unboundedness.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What I'm not sure about is how to handle unbounded variables which are also present in constraints. Are you aware of a source with a set of rules (e.g., when foo and bar happen then the problem is unbounded) or something similar?&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-04-30T18:51:40.300" Title="How to detect unbounded problems" Tags="|reference-request|nonlinear-programming|presolve-preprocessing|unboundedness|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4022" PostTypeId="2" ParentId="3952" CreationDate="2020-04-30T13:32:13.650" Score="5" Body="&lt;p&gt;We have worked in OR for 20 years and have observed the huge rise of Python in the industry over the last 10 years. Many engineers and analysts have moved to Python, especially in scientific fields like data science and operations research.&lt;/p&gt;&#xA;&lt;p&gt;At Hexaly, 90% of our industrial clients use the Hexaly Python API to develop optimization solutions. Especially during the early, prototyping phases, but also more and more for deployment as well.&lt;/p&gt;&#xA;&lt;p&gt;Until now, the preferred languages of our clients were Java and C# because they were the main stacks used by IT services to build business applications that embed optimization engines. C++ is still used in some companies, particularly software editors, but it has become rare.&lt;/p&gt;&#xA;&lt;p&gt;Until now, we have observed no demand for Julia in the industry.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T02:40:35.940" LastActivityDate="2024-04-04T02:40:35.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4023" PostTypeId="2" ParentId="3897" CreationDate="2020-04-30T14:25:51.240" Score="1" Body="&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; This answer was written to respond to an earlier version of the question, which used a different form of the objective function. This answer is incorrect for the new version but I’m leaving it here in case it’s useful to anyone. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I think this problem can be reformulated in a much simpler way. You are trying to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{maximize} \quad \sum_i \left[ \Phi\left(\frac{x_ip_i-30}{15}\right) + \Phi\left(\frac{x_iq_i-40}{20}\right)\right] $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\Phi(\cdot)$&lt;/span&gt; is the standard normal cdf (or &lt;code&gt;NORM.DIST&lt;/code&gt; in Excel). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why not just calculate these terms for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and then use the result as the coefficients for &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;? What I mean is, let&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$a_i = \Phi\left(\frac{p_i-30}{15}\right)+ \Phi\left(\frac{q_i-40}{20}\right).$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then your objective function is just&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{maximize} \quad \sum_i a_ix_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and the constraints remain as you formulated them originally. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this approach only works because the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are binary. If they were continuous (or general integer, for that matter) it would not work.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2020-05-18T01:03:03.463" LastActivityDate="2020-05-18T01:03:03.463" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="4024" PostTypeId="2" ParentId="4021" CreationDate="2020-04-30T14:54:47.227" Score="2" Body="&lt;p&gt;Here some quick thoughts for linear programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets assume &lt;span class=&quot;math-container&quot;&gt;$v_1,\ldots,v_n$&lt;/span&gt; are unbounded variables in your problem and we are maximizing.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Then look if there are only constraints (where &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; is separable) of the form &lt;span class=&quot;math-container&quot;&gt;$... \leq v_i$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; has only a positive linear coefficient.&lt;/li&gt;&#xA;&lt;li&gt;Dominating columns with the right objective coefficients&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Of course for all these methods you need at least one feasible point to come to an conclusion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you can extend both methods also for MINLPs.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;works for any constraint and if you know that the objective is&#xA;monotone increasing in &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;maybe you can detect also dominating non-linear terms&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I would look at examples from a MINLP library, solve unbounded instances and look at the terms the unbounded variables appears in, maybe you see additional cases there.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2020-04-30T18:51:40.300" LastActivityDate="2020-04-30T18:51:40.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4025" PostTypeId="1" CreationDate="2020-04-30T14:58:47.067" Score="1" ViewCount="89" Body="&lt;pre&gt;&lt;code&gt; int nbPilots = 50;&#xA; int nbLocations = 7;&#xA; int nbDays = 30;&#xA;&#xA; range pilots = 1..nbPilots;&#xA; range days = 1..nbDays; &#xA; range locations = 1..nbLocations;&#xA;&#xA;&#xA;&#xA; /*decision variable*/&#xA; dvar boolean assign [pilots][days][locations] ;&#xA; dvar boolean rest [pilots][days][locations];&#xA;&#xA; /*objective*/&#xA; minimize sum(i in pilots, j in days, l in locations)assign[i][j][l];&#xA;&#xA; /*constraints*/&#xA; subject to{&#xA;&#xA;&#xA;   //Kısıt-2: Her pilotun art arda gelen 6 gün içerisinde asgari 1 gün boş bırakılması kısıtı&#xA;   //forall(i in pilots, j in days, l in locations)(rest[i][j][l]+rest[i][j+1][l]+rest[i][j+2][l]+rest[i][j+3][l]+rest[i][j+4][l]+rest[i][j+5][l]+rest[i][j+6][l]&amp;gt;=1);&#xA;&#xA;   forall(i in pilots, j in days, l in locations)(assign[i][j][l]+assign[i][j+1][l]+assign[i][j+2][l]+assign[i][j+3][l]+assign[i][j+4][l]+assign[i][j+5][l]+assign[i][j+6][l]+rest[i][j+7][l]+rest[i][j+8][l] == 9);&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;how can i handle that [j+8] is also in days &amp;lt;=30&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="3447" LastEditorUserId="36" LastEditDate="2020-04-30T17:51:48.630" LastActivityDate="2020-04-30T17:51:48.630" Title="ILOG Cplex out of scope" Tags="|cplex|assignment-problem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4026" PostTypeId="2" ParentId="4025" CreationDate="2020-04-30T16:50:14.510" Score="2" Body="&lt;pre&gt;&lt;code&gt;      int nbPilots = 50; &#xA;int nbLocations = 7; &#xA;int nbDays = 30;&#xA;&#xA;range pilots = 1..nbPilots; range days = 1..nbDays; range locations = 1..nbLocations;&#xA;&#xA;//decision variable/ &#xA;&#xA;dvar boolean assign [pilots][days][locations] ; dvar boolean rest [pilots][days][locations];&#xA;&#xA;//objective/ &#xA;&#xA;minimize sum(i in pilots, j in days, l in locations)assign[i][j][l];&#xA;&#xA;//constraints/&#xA; subject to{&#xA;&#xA;&#xA;forall(i in pilots, j in days, l in locations:(j+8) in days)&#xA;  (assign[i][j][l]+assign[i][j+1][l]+assign[i][j+2][l]+assign[i][j+3][l]+&#xA;  assign[i][j+4][l]+assign[i][j+5][l]+assign[i][j+6][l]+rest[i][j+7][l]+rest[i][j+8][l] == 9);&#xA;&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works better&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-04-30T16:50:14.510" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4027" PostTypeId="1" AcceptedAnswerId="4035" CreationDate="2020-05-01T12:52:12.423" Score="2" ViewCount="593" Body="&lt;p&gt;I'm trying to solve a scheduling problem using OPL/CPLEX. In the model, there are nine tasks in which each task has its specific precedence. the precedence relationship is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[{1}, {1}, {1,2}, {1,2,3}, {4,7}, {6}, {6}, {5}, {8}];​&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where, for example, tasks {1,2,3} are the precedence of task four. I have defined two ways to create this relationship. First, by using a nested tuple set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tuple link{&#xA;   {int} task;&#xA;};&#xA;{link} relations[tasks]=&#xA;[{&amp;lt;{1}&amp;gt;}, {&amp;lt;{1}&amp;gt;}, {&amp;lt;{1,2}&amp;gt;}, {&amp;lt;{1,2,3}&amp;gt;}, {&amp;lt;{4,7}&amp;gt;}, {&amp;lt;{6}&amp;gt;}, {&amp;lt;{6}&amp;gt;}, {&amp;lt;{5}&amp;gt;}, {&amp;lt;{8}&amp;gt;}];​&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second, by nested set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setof(int) operations[tasks] = [{1}, {1}, {1,2}, {1,2,3}, {4,7}, {6}, {6}, {5}, {8}];​&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I would like to use this relationship in the following constraint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\sum_{h \in H} \sum_{i \in I} i . x_{i h j} \leq \sum_{h \in H} \sum_{i \in I} i . x_{i h t} \forall j, t \in N, j&amp;lt;t\end{equation}&lt;/span&gt;​&#xA;Where, &lt;span class=&quot;math-container&quot;&gt;${i \in workstation}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;${h \in workers}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;${j,t \in tasks}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The OPL code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  e4: forall(j,t in tasks: j&amp;lt;t)&#xA;    sum(h in workers, i in workstation) i*x[i,h,j] &amp;lt;= &#xA;        sum(h in workers, i in workstation) i*x[i,h,t];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if, which one of these methods can be applied to the constraint and how can I fix this issue?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-05-03T08:03:40.360" Title="Nested set in OPL/CPLEX" Tags="|mixed-integer-programming|solver|cplex|scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4028" PostTypeId="2" ParentId="117" CreationDate="2020-05-01T14:05:59.890" Score="4" Body="&lt;p&gt;For Operations Research in the power industry, I recommend the following five introductory books, covering short-term trading, stochastic programming, decomposition algorithms, complementarity and long-term investment. These OR models are data hungry, thus summarized as data-driven decision making under uncertainty. These videos &lt;a href=&quot;https://www.youtube.com/playlist?list=PLKLR7D59yU0dPnB5EEmDd-2O2Rpjx9Uu6&quot; rel=&quot;nofollow noreferrer&quot;&gt;DTU CEE Summer School 2019: Data-Driven Analytics and Optimization for Energy Systems&lt;/a&gt; provide an overview.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Morales, J. M., Conejo, A. J., Madsen, H., Pinson, P., &amp;amp; Zugno, M. (2013). Integrating renewables in electricity markets: operational problems (Vol. 205). Springer Science &amp;amp; Business Media.&lt;/li&gt;&#xA;&lt;li&gt;Conejo, A. J., Carrión, M., &amp;amp; Morales, J. M. (2010). Decision making under uncertainty in electricity markets (Vol. 1). New York: Springer.&lt;/li&gt;&#xA;&lt;li&gt;Conejo, A. J., Castillo, E., Minguez, R., &amp;amp; Garcia-Bertrand, R. (2006). Decomposition techniques in mathematical programming: engineering and science applications. Springer Science &amp;amp; Business Media.&lt;/li&gt;&#xA;&lt;li&gt;Gabriel, S. A., Conejo, A. J., Fuller, J. D., Hobbs, B. F., &amp;amp; Ruiz, C. (2012). Complementarity modeling in energy markets (Vol. 180). Springer Science &amp;amp; Business Media.&lt;/li&gt;&#xA;&lt;li&gt;Conejo, A. J., Baringo, L., Kazempour, S. J., &amp;amp; Siddiqui, A. S. (2016). Investment in electricity generation and transmission. Cham Zug, Switzerland: Springer International Publishing, 106.&lt;/li&gt;&#xA;&lt;li&gt;Kovacevic, R. M., Pflug, G. C., &amp;amp; Vespucci, M. T. (2013). Handbook of risk management in energy production and trading (Vol. 199). New York: Springer.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Besides, OR for networks is essential in energy industries. Following books are used in the graph theory course by Carsten Thomassen at Technical University of Denmark. They are both theoretical and practical.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bondy, J. A., &amp;amp; Murty, U. S. R. (1976). Graph theory with applications (Vol. 290). London: Macmillan.&lt;/li&gt;&#xA;&lt;li&gt;Ahuja, R. K., Magnanti, T. L., &amp;amp; Orlin, J. B. (1988). Network flows.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It's easier to grasp them in some real-world context, and apply them to other industries, especially when they share many common features. For example, the power system is a special kind of supply chains, with more strict requirements. So techniques from the optimal flows, newsvendor's problem, unit commitments, capacity/network investments, market design, etc have been widely applied in the power industry.&lt;/p&gt;&#xA;" OwnerUserId="3163" LastEditorUserId="3163" LastEditDate="2020-05-03T08:38:30.740" LastActivityDate="2020-05-03T08:38:30.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4029" PostTypeId="1" CreationDate="2020-05-02T01:05:35.603" Score="5" ViewCount="42" Body="&lt;p&gt;I have an m/m/1 queue and a set of arrival rate &lt;span class=&quot;math-container&quot;&gt;$\{\lambda_{t_1}, \lambda_{t_2} ...., \lambda_{t_n}\}$&lt;/span&gt; and a fixed service rate &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;. I want to calculate the average waiting time during each time interval. On the book &quot;Operations research algorithms and applications&quot; by Wayne L. Winston, they solve a similar problem by simulating it. I was wondering if there any closed equation for approximating this value. &#xA;One similar note, given an initial number of people in the queue and a fixed arrival rate and service rate and a finite time length, is there any good closed equation for approximating average writing time.&#xA;And if there is no such equation what is the fastest way to approximate this?   &lt;/p&gt;&#xA;" OwnerUserId="3453" LastActivityDate="2020-05-02T01:05:35.603" Title="Approximate average waiting time when a m\m\1 queue shows transient behavior" Tags="|queuing-theory|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4030" PostTypeId="2" ParentId="117" CreationDate="2020-05-02T02:46:10.190" Score="1" Body="&lt;p&gt;In addition to all of the above, the applications of operations research techniques in the airline industry could be found in:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Barnhart, C., Belobaba, P., &amp;amp; Odoni, A. R. (2003). Applications of operations research in the air transport industry. Transportation science, 37(4), 368-391.[&lt;a href=&quot;https://pubsonline.informs.org/doi/pdf/10.1287/trsc.37.4.368.23276&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt;]&lt;/li&gt;&#xA;&lt;li&gt;Yu, G. (Ed.). (2012). Operations research in the airline industry (Vol. 9). Springer Science &amp;amp; Business Media. [&lt;a href=&quot;https://link.springer.com/content/pdf/bfm%3A978-1-4615-5501-8%2F1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt;]&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For airline disruption management, read:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Wu, C. L. (2016). Airline operations and delay management: insights from airline economics, networks and strategic schedule planning. Routledge.&lt;/li&gt;&#xA;&lt;li&gt;Clausen, J., Larsen, A., Larsen, J., &amp;amp; Rezanova, N. J. (2010). Disruption management in the airline industry—Concepts, models and methods. Computers &amp;amp; Operations Research, 37(5), 809-821.&lt;/li&gt;&#xA;&lt;li&gt;Kohl, N., Larsen, A., Larsen, J., Ross, A., &amp;amp; Tiourine, S. (2007). Airline disruption management—perspectives, experiences and outlook. Journal of Air Transport Management, 13(3), 149-162.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2999" LastActivityDate="2020-05-02T02:46:10.190" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4031" PostTypeId="2" ParentId="3703" CreationDate="2020-05-02T08:56:01.297" Score="3" Body="&lt;p&gt;I think the standard method is to stop just after the root node has been solved.&#xA;For example, using the C++ API:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Uncomment the following line to disable CPLEX cuts:&#xA;// cplex.setParam(IloCplex::NumParam::CutsFactor, 0.0);&#xA;&#xA;cplex.setParam(IloCplex::IntParam::NodeLim, 0);&#xA;cplex.solve();&#xA;&#xA;const auto linear_relaxation_obj = cplex.getBestObjValue();&#xA;&#xA;// If you want to continue solving the MILP via branch-and-bound:&#xA;// cplex.setParam(IloCplex::NumParam::CutsFactor, -1.0);&#xA;cplex.setParam(IloCplex::IntParam::NodeLim, 999999999);&#xA;&#xA;if(cplex.solve()) {&#xA;    // Fully solved the MILP&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;NodeLim&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt; means CPLEX will stop after the root node is fully explored.&#xA;Setting it to &lt;code&gt;1&lt;/code&gt; will also perform branching and select the next node to explore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;CutsFactor&lt;/code&gt; to a value between &lt;code&gt;0.0&lt;/code&gt; and &lt;code&gt;1.0&lt;/code&gt;, CPLEX won't generate any cuts, thereby solving the linear relaxation of your original model.&#xA;With &lt;code&gt;CutsFactor&lt;/code&gt; at its default value &lt;code&gt;-1.0&lt;/code&gt;, or at a value strictly larger than &lt;code&gt;1.0&lt;/code&gt;, CPLEX might add cuts at the root node, thus giving a tighter dual bound that you might have if solving the linear relaxation of the model.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2020-05-02T12:38:02.473" LastActivityDate="2020-05-02T12:38:02.473" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4032" PostTypeId="1" CreationDate="2020-05-02T12:15:30.480" Score="4" ViewCount="130" Body="&lt;p&gt;I have the following model &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad B_{1} + B_{2}\\\text{s.t.}&amp;amp;\quad&#xA;0 \leq B_{1} \leq c_{1}\cdot Y_{1} \\&amp;amp;\quad&#xA;0 \leq B_{2} \leq c_{2}\cdot Y_{2}  \\&amp;amp;\quad&#xA;\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$B_{1}, B_{2}$&lt;/span&gt; are reals, &lt;span class=&quot;math-container&quot;&gt;$Y_{1}, Y_{2}$&lt;/span&gt; are binary, and &lt;span class=&quot;math-container&quot;&gt;$c_{1}, c_{2}$&lt;/span&gt; are positive constants.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the following transformation of advantage when thinking about speeding up B&amp;amp;B?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad B_{1} + B_{2} - M_{1} - M_{2}\\\text{s.t.}&amp;amp;\quad B_{1} + M_{1} = c_{1}\cdot Y_{1} \\&amp;amp;\quad&#xA;B_{2} + M_{2} = c_{2}\cdot Y_{2}  \\&amp;amp;\quad\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$B_{1}, B_{2},M_{1}, M_{2}$&lt;/span&gt; are reals, &lt;span class=&quot;math-container&quot;&gt;$Y_{1}, Y_{2}$&lt;/span&gt; are binary, and &lt;span class=&quot;math-container&quot;&gt;$c_{1}, c_{2}$&lt;/span&gt; are positive constants.&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2020-05-02T12:45:48.220" LastActivityDate="2020-05-02T21:58:47.430" Title="Is working with equations in an MILP more efficient than working with inequaltities?" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4035" PostTypeId="2" ParentId="4027" CreationDate="2020-05-02T17:39:50.980" Score="2" Body="&lt;p&gt;Why not writing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{int} tasks=asSet(1..9);&#xA;{int} workstation={1,2};&#xA;{int} workers={1,2};&#xA;setof(int) operations[tasks]=[{1},{1}, {1,2}, {1,2,3}, {4,7}, {6}, {6}, {5}, {8}];&#xA;&#xA;dvar boolean x[workers,tasks,tasks];&#xA;&#xA;subject to&#xA;{&#xA;  e4: forall(j,t in tasks: j in operations[t])&#xA;sum(h in workers, i in workstation)i*x[i,h,j] &amp;lt;= &#xA;sum(h in workers,i in workstation)i*x[i,h,t];}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and later on you asked for the same with tuple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{int} tasks=asSet(1..9);&#xA;{int} workstation={1,2};&#xA;{int} workers={1,2};&#xA;//setof(int) operations[tasks]=[{1},{1}, {1,2}, {1,2,3}, {4,7}, {6}, {6}, {5}, {8}];&#xA;tuple link{&#xA;   {int} task;&#xA;};&#xA;link relations[tasks]=&#xA;[&amp;lt;{1}&amp;gt;,&amp;lt;{1}&amp;gt;, &amp;lt;{1,2}&amp;gt;, &amp;lt;{1,2,3}&amp;gt;, &amp;lt;{4,7}&amp;gt;, &amp;lt;{6}&amp;gt;, &amp;lt;{6}&amp;gt;, &amp;lt;{5}&amp;gt;, &amp;lt;{8}&amp;gt;];;&#xA;dvar boolean x[workers,tasks,tasks];&#xA;&#xA;subject to&#xA;{&#xA;  e4: forall(j,t in tasks: j in relations[t].task)&#xA;sum(h in workers, i in workstation)i*x[i,h,j] &amp;lt;= &#xA;sum(h in workers,i in workstation)i*x[i,h,t];}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2020-05-03T08:03:40.360" LastActivityDate="2020-05-03T08:03:40.360" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4036" PostTypeId="2" ParentId="2922" CreationDate="2020-05-02T19:08:35.040" Score="1" Body="&lt;p&gt;If the newsvendor model is needed, the asset is assumed to have a short selling season and forward procurement is required. Usually, one-time procurement with fixed lead time is considered in newsvendor problems, so the primary concern is to decide the quantity. When there are multiple procurement opportunities, the dynamic procurement strategy can be beneficial in many ways. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The newsvendor can place multiple orders with increasing ordering cost over time to satisfy demand that realizes at the end of the planning horizon. [wang2012multiordering]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In general, you must balance the precision of your demand forecasts and procurement costs. Usually, as lead time decreasing, you have more accurate forecasts and face higher costs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many types of dynamic procurement problems with different forecasts, costs, supply modes. For example, in [wang2012multiordering], future costs are known in advance for sure. While in power systems [nair2014energy] [secomandi2014optimal], your future costs are unknown and correlated. In [zheng2015newsvendor], optimal one-time procurement with flexible lead times is discussed in two supply modes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;[wang2012multiordering]: Wang, T., Atasu, A., &amp;amp; Kurtuluş, M. (2012). A multiordering newsvendor model with dynamic forecast evolution. Manufacturing &amp;amp; Service Operations Management, 14(3), 472-484.&lt;/li&gt;&#xA;&lt;li&gt;[nair2014energy]: Nair, J., Adlakha, S., &amp;amp; Wierman, A. (2014, June). Energy procurement strategies in the presence of intermittent sources. In The 2014 ACM international conference on Measurement and modeling of computer systems (pp. 85-97).&lt;/li&gt;&#xA;&lt;li&gt;[secomandi2014optimal]: Secomandi, N., &amp;amp; Kekre, S. (2014). Optimal energy procurement in spot and forward markets. Manufacturing &amp;amp; Service Operations Management, 16(2), 270-282.&lt;/li&gt;&#xA;&lt;li&gt;[zheng2015newsvendor]: Zheng, M., Wu, K., &amp;amp; Shu, Y. (2016). Newsvendor problems with demand forecast updating and supply constraints. Computers &amp;amp; Operations Research, 67, 193-206.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3163" LastEditorUserId="3163" LastEditDate="2020-05-03T02:20:54.373" LastActivityDate="2020-05-03T02:20:54.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4037" PostTypeId="2" ParentId="4032" CreationDate="2020-05-02T21:58:47.430" Score="5" Body="&lt;p&gt;The solver will insert slack variables in the inequalities, so effectively all you are doing is penalizing the slacks. That can result in a suboptimal solution if you are not careful, and I can't think of any reason that it would make the problem faster to solve.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-02T21:58:47.430" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4038" PostTypeId="1" AcceptedAnswerId="4039" CreationDate="2020-05-02T22:28:47.647" Score="3" ViewCount="171" Body="&lt;p&gt;I'm trying to develop a heuristic to solve a scheduling problem. The difficult for me is to treat the time as a variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are 2 variables related to time, &lt;span class=&quot;math-container&quot;&gt;$b_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_{ij}$&lt;/span&gt;, being the time that the machine j begin and end the job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; respectively. It's used like this because the model has a demand constraint (see below), that is attended with the time that the machines do job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and each machine has a specific capacity (&lt;span class=&quot;math-container&quot;&gt;$q_j$&lt;/span&gt;). There is also in the model a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; that says if the machine &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; do the job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_j \bigg((f_{ij} - b_{ij}) * q_j * x_{ij}\bigg) \geq Demand_i, \forall i$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this problem, all the jobs needs to be processed only one time by whatever machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone knows which kind of scheduling problem it is... It'll be a great help.&lt;/p&gt;&#xA;" OwnerUserId="2900" LastEditorUserId="358" LastEditDate="2020-05-03T19:26:54.607" LastActivityDate="2020-05-03T19:26:54.607" Title="What type of scheduling problem is this?" Tags="|scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4039" PostTypeId="2" ParentId="4038" CreationDate="2020-05-03T00:55:29.633" Score="2" Body="&lt;p&gt;I think it is similar to the Flexible Job Shop Scheduling Problem as one of the students in my research collaborators group discussed a similar model with me, while developing a customized MOEA for solving the multi-objective flexible job-shop scheduling problem (FJSP). Please refer to the following preprint and see if it is helpful for you:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wang, Y., van Stein, B., Emmerich, M., &amp;amp; Bäck, T. (2020). A Tailored NSGA-III Instantiation for Flexible Job Shop Scheduling. arXiv preprint arXiv:2004.06564. [&lt;a href=&quot;https://arxiv.org/abs/2004.06564&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt;]&lt;/p&gt;&#xA;" OwnerUserId="2999" LastActivityDate="2020-05-03T00:55:29.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4041" PostTypeId="1" CreationDate="2020-05-04T02:25:34.883" Score="4" ViewCount="86" Body="&lt;p&gt;PS: I am familiar with &lt;em&gt;performance variability&lt;/em&gt; encountered while solving large-scale MIPs. My question may not be explicitly related to it but maybe to the inefficiency of python packages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have developed a &lt;em&gt;Python&lt;/em&gt;-code to solve the LP-relaxation of a large-scale airline crew pairing optimization problem (an SCP/SPP formulation) using a heuristic-implementation of the Column Generation technique. First, I generate an initial feasible solution to initialize this CG-heuristic. Subsequently, in each of the iterations of CG-heuristic,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The resulting LP is solved for dual variables using GUROBI.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;These dual variables along with information of existing flight-connections are used to construct partial pricing subproblems as the full-scale network is intractable. From this, I only generate the columns/variables with negative reduced cost. To speed up this part, I have decomposed the problem into independent subprocesses and executes them in parallel (on a 16-core processor) using &lt;em&gt;Multiprocessing Python's library&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My question is related to the runtime-performance of Step 2. In that, whenever I run the code on a system that has been ideal for some time, it takes multiple (at least thrice) reruns (at least till 4-5 CG-iterations) in order to get an acceptable runtime-performance. In these initial reruns, the runtime-performance until Step 1. is the same. However, when Step 2. executes, the CPUs History chart in task manager shows that the system takes a long time to start it, i.e., no process runs for some time. This takes a lot of manual efforts (stopping and re-running the code again and again). Has anyone faced a similar issue or has a clue about why this is happening? Is this because of the &lt;em&gt;Multiprocessing&lt;/em&gt; library of &lt;em&gt;Python&lt;/em&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2999" LastEditorUserId="354" LastEditDate="2020-05-04T09:13:26.310" LastActivityDate="2020-05-04T09:13:26.310" Title="Problem related to machine's performance while solving an LP-relaxation of a set-covering problem using the Column Generation" Tags="|python|column-generation|lp-relaxation|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4042" PostTypeId="1" AcceptedAnswerId="4048" CreationDate="2020-05-04T11:45:40.650" Score="9" ViewCount="676" Body="&lt;p&gt;This is a rather simple question. Can a &lt;em&gt;solution&lt;/em&gt; to a linear programming problem be dependent on the order in which the data is read/presented/stored? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know, that the time it takes to solve the problem can depend heavily on the ordering of the data, and if there a multiple optimal solutions to an LP, the ordering of the data can result in the algorithm finding another optimal solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, can the solution itself &lt;em&gt;and&lt;/em&gt; the corresponding optimal objective function value change depending on the ordering of the data? Does there exist models which are &quot;data sensitive&quot; in this respect?&lt;/p&gt;&#xA;" OwnerUserId="609" LastEditorUserId="123" LastEditDate="2020-05-04T14:36:00.743" LastActivityDate="2020-05-04T18:48:42.040" Title="LP dependent on the ordering of the data" Tags="|linear-programming|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4043" PostTypeId="2" ParentId="4042" CreationDate="2020-05-04T11:59:21.277" Score="12" Body="&lt;p&gt;In theory no. In practice this can happen, because everything is done in floating point arithmetic. (See also this post &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/tolerances_and_ill_conditi.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.0/refman/tolerances_and_ill_conditi.html&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this happens i would look at the optimality certificates of the solutions. They might mention a large violation, even though the solver has terminated with this solution.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2020-05-04T11:59:21.277" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4044" PostTypeId="2" ParentId="4042" CreationDate="2020-05-04T13:08:00.053" Score="6" Body="&lt;p&gt;I have faced a similar issue. The above answer is up to the point but in addition to it, read the answer by Prof. Marco (&lt;a href=&quot;https://or.stackexchange.com/a/3425/2999&quot;&gt;link&lt;/a&gt;). The paper cited by him (&lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/educ.2013.0112&quot; rel=&quot;noreferrer&quot;&gt;pdf&lt;/a&gt;) helped me a lot in understanding the &lt;strong&gt;performance variability&lt;/strong&gt; phenomenon. While solving MIPs, various algorithmic choices are influenced by the ordering of the variables, constraints in the input MIP model, leading to alternate optimal solutions. These solutions could have the same or different objective values depending upon the tolerance limit of floating-point arithmetics set by you but definitely the corresponding variables would be different. Not fixing the ordering of variables will also lead to variations in performance when the same code is run again on the same or a different machine.&lt;/p&gt;&#xA;" OwnerUserId="2999" LastActivityDate="2020-05-04T13:08:00.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4045" PostTypeId="1" AcceptedAnswerId="4046" CreationDate="2020-05-04T14:15:09.293" Score="5" ViewCount="832" Body="&lt;p&gt;I came across this example on how to model your lead time demand as a log-normal distribution and calculate the safety stock.&#xA;&lt;a href=&quot;https://www.linkedin.com/pulse/why-you-keep-missing-your-service-level-targets-stefan-de-kok/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.linkedin.com/pulse/why-you-keep-missing-your-service-level-targets-stefan-de-kok/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I don't understand the part where the author calculates 78 units of safety stock when modelling the demand as log-normal with &lt;span class=&quot;math-container&quot;&gt;$\mu = 2.645$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sigma = 0.83255$&lt;/span&gt; nor the part where he uses a cauterized normal distribution. Can someone help me out with this?&lt;/p&gt;&#xA;" OwnerUserId="3458" LastEditorUserId="491" LastEditDate="2021-01-12T19:21:14.710" LastActivityDate="2021-01-12T19:21:14.710" Title="Safety stock for log-normal distribution demand" Tags="|inventory|probability-distributions|rq-inventory-model|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4046" PostTypeId="2" ParentId="4045" CreationDate="2020-05-04T16:36:37.953" Score="6" Body="&lt;p&gt;To calculate the base-stock to meet a 99% type-1 service level, we need the 0.99 fractile of the demand distribution. The safety stock level is the base-stock level minus the mean demand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the lognormal case, the author has fit a lognormal distribution and found that the parameters are &lt;span class=&quot;math-container&quot;&gt;$\mu=2.645$&lt;/span&gt;  and &lt;span class=&quot;math-container&quot;&gt;$\sigma=0.83255$&lt;/span&gt;. (Note that for a lognormal distribution, &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; are not the mean and SD.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a lognormal distribution with those parameters, the mean is 19.9169 and the 99th quantile is 97.6902. The difference between the two is the safety stock (approx. 78).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some Python code to calculate all of this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from scipy.stats import lognorm&#xA;import numpy as np&#xA;&#xA;mu = 2.645&#xA;sigma = 0.83255&#xA;&#xA;s = sigma&#xA;scale = np.exp(mu)&#xA;&#xA;mean_demand = lognorm(s=s, scale=scale).mean()&#xA;# 19.916922579681707&#xA;base_stock = lognorm(s=s, scale=scale).ppf(0.99)&#xA;# 97.69016830710534&#xA;base_stock - mean_demand&#xA;# 77.77324572742363&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(For more on the parameters of &lt;code&gt;lognorm&lt;/code&gt;, see &lt;a href=&quot;https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.lognorm.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.)&#xA;I didn't work through the &quot;cauterized normal&quot; case in detail, but roughly speaking the logic should be the same. When he says &quot;cauterized normal&quot; I think he means that we take the probability in the tail below 0 and add a probability mass at 0, with that probability.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-05-04T16:36:37.953" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4047" PostTypeId="1" CreationDate="2020-05-04T17:23:18.547" Score="3" ViewCount="305" Body="&lt;p&gt;I created a graph coloring &lt;a href=&quot;http://ibmdecisionoptimization.github.io/docplex-doc/cp/refman.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOcplex.CP&lt;/a&gt; model inspired by &lt;a href=&quot;https://github.com/IBMDecisionOptimization/docplex-examples/blob/master/examples/cp/basic/color.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;this example&lt;/a&gt;.&#xA;However, I do not know the number of colors in advance.&#xA;The goal is to minimize the number of colors (i.e., get as close as possible to the graph chromatic number):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import docplex&#xA;import itertools&#xA;&#xA;graph_edges = [(0, 1), (0, 2), (1, 3), (2, 4)]&#xA;num_nodes = max(itertools.chain.from_iterable(graph_edges)) + 1&#xA;&#xA;mdl = docplex.cp.model.CpoModel()&#xA;&#xA;color_vars = mdl.integer_var_list(num_nodes, min=0)&#xA;for n1, n2 in graph_edges:&#xA;    mdl.add(color_vars[n1] != color_vars[n2])&#xA;mdl.minimize(mdl.max(color_vars))&#xA;&#xA;msol = mdl.solve(TimeLimit=120.0)&#xA;&#xA;colors = [msol[color_var] for color_var in color_vars]&#xA;print(str(colors))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I noticed that for rather small graphs (&lt;a href=&quot;https://github.com/discreteoptimization/assignment/blob/master/coloring/data/gc_20_9&quot; rel=&quot;nofollow noreferrer&quot;&gt;~20 nodes, ~200 edges&lt;/a&gt;) my own very simple graph coloring constraint programming algorithm works way faster than this model and proves optimality more often.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to fix one variable in this model (in order to break the symmetry), and that improved the model performance. I have a couple of other similar basic techniques in mind that I could apply to the &lt;em&gt;model.&lt;/em&gt; (I mean, such techniques do not depend on a specific solver.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But is that possible to somehow tune the DOcplex.CP &lt;em&gt;solver&lt;/em&gt; itself or provide it some meta-information about the problem? i.e., help the solver to recognize the problem? (The way the CPLEX network optimizer &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/cont_optim/simplex/08_network.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;recognizes&lt;/a&gt; the problems with network structure.)&lt;/p&gt;&#xA;" OwnerUserId="3297" LastEditorUserId="36" LastEditDate="2020-05-05T11:28:39.890" LastActivityDate="2020-05-09T12:56:05.067" Title="Could DOcplex.CP recognize that it solves the graph coloring minimization problem?" Tags="|constraint-programming|combinatorial-optimization|graphs|docplex|cp-optimizer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4048" PostTypeId="2" ParentId="4042" CreationDate="2020-05-04T18:48:42.040" Score="6" Body="&lt;p&gt;I know it's a bit of a stretch, but in some sense the answer is yes. I apologize in advance for the self-promotion as the following is based on a &lt;a href=&quot;https://doi.org/10.1016/j.dam.2020.02.012&quot; rel=&quot;noreferrer&quot;&gt;paper&lt;/a&gt; I have co-authored. Also I apologize for the rather lengthy reply.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The Capacitated Vehicle Routing Problem (CVRP) can be defined as follows . Let &lt;span class=&quot;math-container&quot;&gt;$G = (V, E)$&lt;/span&gt; be an undirected graph with node set &lt;span class=&quot;math-container&quot;&gt;$V = \{0, . . . , n\}$&lt;/span&gt; and edge set &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;. Node 0 represents a depot, whereas each of the nodes in &lt;span class=&quot;math-container&quot;&gt;$V_c = {1, . . . , n}$&lt;/span&gt; represents a customer. The &lt;em&gt;symmetric&lt;/em&gt; cost of travel between nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is denoted by &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt;. A number &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;   of identical vehicles, each of capacity &lt;span class=&quot;math-container&quot;&gt;$Q &amp;gt; 0$&lt;/span&gt;, is available. Each customer &lt;span class=&quot;math-container&quot;&gt;$i \in V_c$&lt;/span&gt;, has an integer demand &lt;span class=&quot;math-container&quot;&gt;$q_i$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$q_0=0$&lt;/span&gt;). Each customer must be served by a single vehicle and and the vehicles' capacities must be respected. The task is to find a set of vehicle routes of minimum cost, where each vehicle used leaves from and returns to the depot. In the paper, we propose a formulation of the CVRP based on decomposing each route into two paths leaving the depot and meeting up in the customer having the largest index on the route. To do so, we introduce the following sets of variables:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For each &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in A$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 1$&lt;/span&gt; if a vehicle travels along arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For each &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in \in A$&lt;/span&gt;, if a vehicle travels along arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$f_{ij}$&lt;/span&gt; denotes the total quantity delivered on the path when the vehicle leaves vertex &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$f_{ij} = 0$&lt;/span&gt;. &lt;/li&gt;&#xA;&lt;li&gt;For each &lt;span class=&quot;math-container&quot;&gt;$i\in V_c\setminus\{n\}$&lt;/span&gt;, the variable &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; denotes the largest customer index visited on the path from the depot to and including customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$u_n=n$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For each &lt;span class=&quot;math-container&quot;&gt;$i\in V_c$&lt;/span&gt;, the variable &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; denotes whether or not node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the customer with the largest index on a route. &lt;span class=&quot;math-container&quot;&gt;$p_n=1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For each &lt;span class=&quot;math-container&quot;&gt;$i\in V_c$&lt;/span&gt;, if &lt;span class=&quot;math-container&quot;&gt;$p_i = 1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt; represents the total demand on the route which services node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$t_i = 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the paper we propose the following formulation of CVRP&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;		\min            	&amp;amp; \sum_{(i,j) \in A} c_{ij} x_{ij} \label{eq:our_obj} &amp;amp;  &amp;amp;                                                                             &amp;amp;  \\&#xA;\text{s.t.:}  	&amp;amp; x(\delta^+(i)) + p_i  = 1 &amp;amp;  &amp;amp; \forall i \in V_c  &amp;amp;  \\&#xA;							&amp;amp; x(\delta^-(i)) - p_i  = 1                           &amp;amp;  &amp;amp; \forall i \in V_c                                  &amp;amp;  \\&#xA;							&amp;amp; t_i + f(\delta^+(i)) = f(\delta^-(i)) + q_i         &amp;amp;  &amp;amp; \forall i \in V_c                                 &amp;amp;  \\&#xA;							&amp;amp; q_i x_{ij} \leq f_{ij} \leq (Q-q_j) x_{ij}          &amp;amp;  &amp;amp; \forall (i,j) \in A_c                                 &amp;amp;  \\&#xA;							&amp;amp; q_i p_i \leq t_i \leq Q p_i                         &amp;amp;  &amp;amp; \forall i \in V_c                               &amp;amp;  \\&#xA;							&amp;amp; x(\delta^+(0)) = 2K                                 &amp;amp;  &amp;amp;                                             &amp;amp;  \\&#xA;							&amp;amp; \sum_{i \in V_c} p_i = K                            &amp;amp;  &amp;amp;                                                       &amp;amp;  \\&#xA;							&amp;amp; i \leq u_i \leq i p_i + (n-1) (1-p_i)               &amp;amp;  &amp;amp; \forall i \in V_c \setminus \{n\}                &amp;amp;  \\&#xA;							&amp;amp; u_i-u_j +(n-j-1)x_{ij} + (n-\max\{i,j\}-1) x_{ji} \leq n-j-1                 &amp;amp;  &amp;amp; \forall i,j \in V_c \setminus \{n\}, \ i \not= j  &amp;amp;  \\&#xA;&amp;amp;\sum_{i \in S_j} p_i \geq \bigl \lceil \sum_{i \in S_j} q_i / Q \bigr \rceil &amp;amp;&amp;amp;\forall j=1,\ldots,n&amp;amp;\\&#xA;							&amp;amp; x_{ij} \in \{0,1\}                                  &amp;amp;  &amp;amp; \forall (i,j) \in A_c                                   &amp;amp;  \\&#xA;							&amp;amp; x_{0j} \in \{0,1,2\}                                &amp;amp;  &amp;amp; \forall j \in V_c                                        &amp;amp;  \\&#xA;							&amp;amp; p_{i} \in \{0,1\}                                   &amp;amp;  &amp;amp; \forall i \in V_c                                        &amp;amp;&#xA;	\end{align}&lt;/span&gt;&#xA;For a detailed description of the constraint sets, please see the paper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, when we did the research, the goal was to get rid of the symmetry that comes from the fact that for the symmetric CVRP, it does not matter in which direction you traverse a route. As a by-product of this, we noticed, that the LP relaxation of this formulation was very dependent on the &lt;em&gt;ordering of the customers&lt;/em&gt;. To illustrate this, consider the following small example with 6 customers:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/32S5Z.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/32S5Z.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The number of vehicles is set to &lt;span class=&quot;math-container&quot;&gt;$K=2$&lt;/span&gt;, the vehicle capacity to &lt;span class=&quot;math-container&quot;&gt;$Q=47$&lt;/span&gt;, and the &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt;'s are the rounded Euclidean distances between the coordinates. If one solves the LP-relaxation of the above program, the optimal objective function value is &lt;span class=&quot;math-container&quot;&gt;$z^*=54.786$&lt;/span&gt;. If, on the other hand, one sorts the customers according to non-increasing distance to the depot, the optimal objective function value of the LP relaxation is &lt;span class=&quot;math-container&quot;&gt;$z^*=49.987$&lt;/span&gt;. Obviously, the optimal solution value of the IP is independent of the ordering and is in this case equal to 61. We noticed that sorting the customers in non-decreasing distance to the depot worked well in general, however we were not able to come up with a provable optimal ordering in general.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2020-05-04T18:48:42.040" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4049" PostTypeId="2" ParentId="3455" CreationDate="2020-05-05T11:17:58.403" Score="1" Body="&lt;p&gt;Please try the below code. I modified the way you import &lt;code&gt;i, j&lt;/code&gt; vectors. Also, check the initial matrix on how products are linked with suppliers, there are suppliers with no product and vice versa. Then you should fix some &lt;code&gt;b[i,j]&lt;/code&gt; values accordingly when NA in initial matrix 0 in &lt;code&gt;b[i,j]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; model &amp;lt;- MIPModel() %&amp;gt;%&#xA;  add_variable(b[i,j], i = 1:n, j = 1:m, type = &quot;binary&quot;) %&amp;gt;%&#xA;  add_variable(x[j], j = 1:m, type = &quot;binary&quot;) %&amp;gt;%&#xA;  set_objective(sum_expr(b[i,j] * 2, i = 1:n, j = 1:m) - sum_expr(x[j], j = 1:m)) %&amp;gt;%&#xA;  add_constraint((sum_expr(b[i,j], j = 1:m)) &amp;lt;= 1, i = 1:n) %&amp;gt;%&#xA;  add_constraint(M * x[j] &amp;gt;= sum_expr(b[i,j], i = 1:n) - 1 + 0.001, j = 1:m) %&amp;gt;%&#xA;  add_constraint(M * ( 1-  x[j]) &amp;gt;= ( 1 - sum_expr(b[i,j], i = 1:n) - 0.001), j = 1:m) %&amp;gt;%&#xA;&#xA;  solve_model(with_ROI(solver = &quot;symphony&quot;, verbosity = 1))&#xA;&#xA;get_solution(model,b[i,j])&#xA;get_solution(model,x[j])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3463" LastEditorUserId="3463" LastEditDate="2020-05-05T11:38:34.833" LastActivityDate="2020-05-05T11:38:34.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4050" PostTypeId="1" AcceptedAnswerId="4051" CreationDate="2020-05-05T21:06:56.030" Score="3" ViewCount="798" Body="&lt;p&gt;I am trying to implement an employee (nurse) scheduling problem and seek some advice on how to implement a specific constraint.The problem is as follows: There is a set of employees and days (both labeled by integer numbers). Each employee can be assigned a day shift D[(i, j)] , nightshift N[(i, j)] or a day off V[(i, j)]. These are my decision variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;D = LpVariable.dicts(name=&quot;Dagdienst&quot;, indexs=[(i, j) for i in employees for j in days], cat='Binary')&#xA;N = LpVariable.dicts(name=&quot;Nachtdienst&quot;, indexs=[(i, j) for i in employees for j in days], cat='Binary')&#xA;V = LpVariable.dicts(name=&quot;Vrij&quot;, indexs=[(i, j) for i in employees for j in days], cat='Binary')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An example constraint to enforce either a dayshift, nightshift or day-off for each day and each employee is the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in employees:&#xA;    for j in days:&#xA;        m += D[(i, j)] + N[(i, j)] + V[(i, j)] == 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To give you some idea what I'm working with, two other constraints are the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in employees:&#xA;    for j in range(1, len(days)-1):&#xA;        m += N[(i, j)] + D[(i, (j + 1))] &amp;lt;= 1&#xA;        m += N[(i, j)] + D[(i, (j + 2))] &amp;lt;= 1&#xA;&#xA;max_consecutive_days = 4&#xA;for i in employees:&#xA;    for j in range(1, (len(days)+1 - max_consecutive_days)):&#xA;        m += D[(i, j)] + D[(i, j + 1)] + D[(i, j + 2)] + D[(i, j + 3)]+ D[(i, j + 4)] &amp;lt;= max_consecutive_days&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to model two additional constraints. The first one should be fairly simple I hope. If an employee works on saturday (6th day of the week), he/she must also work on sunday (7th day of the week). The idea is that one either works all weekend, or is free all weekend. I tried the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in employees:&#xA;    m += N[(i, 6)] - N[(i, 7)] &amp;gt;= 0&#xA;    m += N[(i, 7)] - N[(i, 6)] &amp;gt;= 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But these constraints turn out to be non-binding of course because when &lt;code&gt;N[(i, 6)] = 0&lt;/code&gt; and &lt;code&gt;N[(i, 7)] = 0&lt;/code&gt; the constraints are also satisfied. &lt;strong&gt;First question:&lt;/strong&gt; how do I rewrite these constraints?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, on top of that I also want to implement a way to make sure that employees can only work odd or even weekends but don't really know where to start. I assume I must introduce two extra decision variables &quot;works even-weekends&quot; and &quot;works odd-weekends&quot; and set some constraints to enforce these. So the &lt;strong&gt;second question&lt;/strong&gt; is: how could I implement this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I'd rather be able to help myself with these kind of questions so reading materials (specific chapters/sections would be nice) are very welcome as well!&lt;/p&gt;&#xA;" OwnerUserId="3442" LastEditorUserId="500" LastEditDate="2020-05-05T21:45:37.863" LastActivityDate="2020-05-05T21:45:37.863" Title="How to set these constraints in a linear optimization problem (PuLP)?" Tags="|linear-programming|modeling|integer-programming|python|pulp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4051" PostTypeId="2" ParentId="4050" CreationDate="2020-05-05T21:43:35.517" Score="6" Body="&lt;p&gt;The rule &quot;works on Saturday implies works on Sunday&quot; can be expressed as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(D_{i,6} \lor N_{i,6}) \implies (D_{i,7} \lor N_{i,7}),$$&lt;/span&gt;&#xA;which can be rewritten in conjunctive normal form as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\neg (D_{i,6} \lor N_{i,6}) \lor (D_{i,7} \lor N_{i,7}) \\&#xA;(\neg D_{i,6} \land \neg N_{i,6}) \lor (D_{i,7} \lor N_{i,7}) \\&#xA;(\neg D_{i,6} \lor D_{i,7} \lor N_{i,7}) &#xA;\land (\neg N_{i,6} \lor D_{i,7} \lor N_{i,7}),&#xA;\end{equation}&lt;/span&gt;&#xA;yielding linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(1- D_{i,6} + D_{i,7} + N_{i,7}) \ge 1)&#xA;\land (1- N_{i,6} + D_{i,7} + N_{i,7} \ge 1),$$&lt;/span&gt;&#xA;equivalently&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(D_{i,6} \le D_{i,7} + N_{i,7})&#xA;\land (N_{i,6} \le D_{i,7} + N_{i,7}).$$&lt;/span&gt;&#xA;Because &lt;span class=&quot;math-container&quot;&gt;$D_{i,6}+N_{i,6} \le 1$&lt;/span&gt;, you can strengthen these as a single constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$D_{i,6} + N_{i,6} \le D_{i,7} + N_{i,7}. \tag1$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More simply, you can rewrite&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\neg V_{i,6} \implies \neg V_{i,7}$$&lt;/span&gt;&#xA;in conjunctive normal form as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V_{i,6} \lor \neg V_{i,7},$$&lt;/span&gt;&#xA;yielding linear constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V_{i,6} + 1 - V_{i,7} \ge 1,$$&lt;/span&gt;&#xA;equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V_{i,6} \ge V_{i,7},$$&lt;/span&gt;&#xA;which is just the complement of &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your description sounds like you might also want the converse that working Sunday implies working Saturday.  If so, that is &lt;span class=&quot;math-container&quot;&gt;$$V_{i,7} \ge V_{i,6},$$&lt;/span&gt; so if you want both implications, just impose &lt;span class=&quot;math-container&quot;&gt;$$V_{i,6} = V_{i,7}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your second question, I think you just want some conflict constraints of the form &lt;span class=&quot;math-container&quot;&gt;$\text{Odd}_i + \text{Even}_i \le 1,$&lt;/span&gt;&#xA;together with&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;1 - V_{i,j} &amp;amp;\le \text{Odd}_i  &amp;amp;&amp;amp;\text{for $j$ in odd weekend}\\&#xA;1 - V_{i,j} &amp;amp;\le \text{Even}_i &amp;amp;&amp;amp;\text{for $j$ in even weekend}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-05-05T21:43:35.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4052" PostTypeId="1" AcceptedAnswerId="4055" CreationDate="2020-05-06T02:54:57.797" Score="5" ViewCount="88" Body="&lt;p&gt;If we prove that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The existance of a &lt;span class=&quot;math-container&quot;&gt;$(2-\epsilon)$&lt;/span&gt;-approximation algorithm for Problem P1 implies &lt;span class=&quot;math-container&quot;&gt;$P = NP$&lt;/span&gt;&lt;/em&gt;,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;can we conclude:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;There exists no PTAS for Problem P1, and so P1 is APX-hard&lt;/em&gt;?&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-05-06T04:17:39.890" LastActivityDate="2020-05-06T07:29:03.613" Title="If a problem is inapproximable for $(2-\epsilon)$, can we conclude there exists no PTAS for it?" Tags="|computational-complexity|approximation-algorithms|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4053" PostTypeId="5" CreationDate="2020-05-06T04:19:17.670" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2020-05-06T04:19:17.670" LastActivityDate="2020-05-06T04:19:17.670" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4054" PostTypeId="4" CreationDate="2020-05-06T04:19:17.670" Score="0" Body="For questions asking about approximation algorithms. Also includes approximation schemes, PTAS and FPTAS." OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-05-06T07:50:23.247" LastActivityDate="2020-05-06T07:50:23.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4055" PostTypeId="2" ParentId="4052" CreationDate="2020-05-06T05:53:47.347" Score="3" Body="&lt;p&gt;You can conclude &lt;strong&gt;There exists no PTAS for Problem P1 if &lt;span class=&quot;math-container&quot;&gt;$P \neq NP$&lt;/span&gt;&lt;/strong&gt;, but you can &lt;strong&gt;NOT&lt;/strong&gt; conclude &lt;em&gt;P1 is APX-hard&lt;/em&gt;. Precisely:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If someone proofs &lt;span class=&quot;math-container&quot;&gt;$P = NP$&lt;/span&gt; you get a trivial PTAS;&lt;/li&gt;&#xA;&lt;li&gt;Assumung &lt;span class=&quot;math-container&quot;&gt;$P \neq NP$&lt;/span&gt;, it still could be APX-intermediate (see &lt;a href=&quot;https://en.wikipedia.org/wiki/APX#APX-intermediate&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/APX#APX-intermediate&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="660" LastEditDate="2020-05-06T07:29:03.613" LastActivityDate="2020-05-06T07:29:03.613" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4056" PostTypeId="5" CreationDate="2020-05-06T08:06:53.577" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2020-05-06T08:06:53.577" LastActivityDate="2020-05-06T08:06:53.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4057" PostTypeId="4" CreationDate="2020-05-06T08:06:53.577" Score="0" Body="For questions asking about approximation algorithms. Also includes approximation schemes, PTAS and FPTAS." OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-05-06T09:13:37.653" LastActivityDate="2020-05-06T09:13:37.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4058" PostTypeId="2" ParentId="4047" CreationDate="2020-05-06T12:35:28.410" Score="2" Body="&lt;p&gt;within 4s with your data set CPLEX both MIP and Constraint Programming prove optimality&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OP&lt;/a&gt;L&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int n1=164;&#xA;    int n2=2;&#xA;    range r1=1..n1;&#xA;    range r2=1..n2;&#xA;&#xA;    int values[i in r1][j in r2]=0;&#xA;&#xA;    execute&#xA;    {&#xA;&#xA;    // Read in file the 2D array values with seperator sep and ranges range1 and range2&#xA;    function read2D(file,range1,range2,values,sep)&#xA;    {&#xA;    for(var i in r1)&#xA;    {&#xA;       line=file.readline();&#xA;       var ar=line.split(sep);&#xA;       var k=0;&#xA;       for(var j in r2)&#xA;       {&#xA;          values[i][j]=ar[k];&#xA;          k++;   &#xA;       }&#xA;    }&#xA;&#xA;    }&#xA;    }&#xA;&#xA;&#xA;&#xA;&#xA;    execute&#xA;    {&#xA;    var f= new IloOplInputFile(&quot;input&quot;);&#xA;    read2D(f,r1,r2,values,&quot; &quot;);&#xA;    f.close();&#xA;&#xA;    writeln(&quot;values = &quot;,values);&#xA;    }&#xA;&#xA;&#xA;    int mini=min(i in r1,j in r2) values[i,j]; &#xA;int maxi=max(i in r1,j in r2) values[i,j];   &#xA;&#xA;//using CP; // Whether to use CPOptimizer or CPLEX is we comment using CP;&#xA;&#xA;execute&#xA;{&#xA;if (thisOplModel.modelDefinition.isUsingCP()) &#xA;{&#xA; cp.param.timelimit=4;&#xA; cp.param.AllDiffInferenceLevel=6;&#xA; }&#xA;else &#xA;{&#xA;  cplex.tilim=4;&#xA;} &#xA;}  &#xA;&#xA;&#xA;&#xA;range nodes=mini..maxi;&#xA;&#xA;dvar int color[nodes] in nodes;&#xA;&#xA;minimize 1+max(n in nodes) color[n];&#xA;&#xA;subject to&#xA;{&#xA;// break sym&#xA;color[mini]==mini;&#xA; forall(i in r1) color[values[i][1]]!=color[values[i][2]];&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives a solution both with using CP; and without&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The setting &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cp.param.AllDiffInferenceLevel=6; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;helps&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-05-06T12:35:28.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4059" PostTypeId="2" ParentId="4047" CreationDate="2020-05-06T12:45:18.490" Score="3" Body="&lt;p&gt;The automatic search of CP Optimizer does not try to recognize a graph colouring problem. As you notice, fixing the colour of one variable to get rid of some symmetries in the model may help. Extending this idea and fixing the colours of one clique may further help. Such dominance rules are not automatically inferred in CP Optimizer but are let to the user to add them to the model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For giving hints to the solver besides model changes, one can define &quot;search phases&quot; for ordering variables and values (in the Python API, look for the &lt;a href=&quot;https://ibmdecisionoptimization.github.io/docplex-doc/cp/docplex.cp.modeler.py.html#docplex.cp.modeler.search_phase&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;search_phase()&lt;/code&gt;&lt;/a&gt; function).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, the search can be entirely defined by the user through the concept of &quot;goals&quot; (only with the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cpo.help/CP_Optimizer/Advanced_user_manual/topics/extend_api_goals.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;C++ API&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another remark is that the solver has different parameters that have default values and that a user can change. The default values are expected to work correctly for very different kinds of problems, but when targeting a given family of problems, specific parameters can be much better. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A related feature is the possibility to inject a starting solution (possibly partial). The solver tries to improve it (see &lt;a href=&quot;https://ibmdecisionoptimization.github.io/docplex-doc/cp/docplex.cp.model.py.html?highlight=set_starting_point#docplex.cp.model.CpoModel.set_starting_point&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;set_starting_point()&lt;/code&gt;&lt;/a&gt; in Python).&lt;/p&gt;&#xA;" OwnerUserId="3466" LastEditorUserId="3297" LastEditDate="2020-05-09T12:56:05.067" LastActivityDate="2020-05-09T12:56:05.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4060" PostTypeId="1" CreationDate="2020-05-06T12:53:19.950" Score="3" ViewCount="101" Body="&lt;p&gt;I'm working on an optimization problem in PuLP and I have to enforce a daily minimum of shifts and a daily maximum of assigned shifts. I have the following constraints to ensure each day has a minimum and maximum of employees assigned on day shifts and night shifts (&lt;span class=&quot;math-container&quot;&gt;$D_{i,j}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N_{i,j}$&lt;/span&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for j in days:&#xA;    m += lpSum(D[(i, j)] for i in employees) &amp;gt;= b_d           &#xA;    m += lpSum(D[(i, j)] for i in employees) &amp;lt;= b_d_max       &#xA;    m += lpSum(N[(i, j)] for i in employees) &amp;gt;= b_n           &#xA;    m += lpSum(N[(i, j)] for i in employees) &amp;lt;= b_n_max       &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to write both these constraints in a single line as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for j in days:&#xA;    m += b_d &amp;lt;= lpSum(D[(i, j)] for i in employees) &amp;lt;= b_d_max  &#xA;    m += b_n &amp;lt;= lpSum(N[(i, j)] for i in employees) &amp;lt;= b_n_max&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the lower limit is not enforced now. Am I doing something wrong or is it just not possible to write the constraints like this in a single line? &lt;/p&gt;&#xA;" OwnerUserId="3442" LastEditorUserId="38" LastEditDate="2020-05-06T17:15:16.953" LastActivityDate="2020-05-06T17:15:16.953" Title="Constraint equivalence in PuLP" Tags="|optimization|linear-programming|python|pulp|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4061" PostTypeId="1" AcceptedAnswerId="4064" CreationDate="2020-05-06T15:18:40.127" Score="2" ViewCount="108" Body="&lt;p&gt;Assume one have an integer problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the master problem in the column generation algorithm the original integer problem, or its linear relaxation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="3443" LastEditorUserId="2556" LastEditDate="2020-05-06T15:31:48.903" LastActivityDate="2020-05-06T17:55:55.187" Title="General question regarding column generation" Tags="|column-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4062" PostTypeId="1" CreationDate="2020-05-06T15:54:09.040" Score="12" ViewCount="3544" Body="&lt;p&gt;Using GUROBI with python. When solving a MILP, I notice that the incumbent is very early (25sec) at the optimal point but the best bound is so slow to fall (maximization problem) that it takes ages (2000sec+) for reaching the optimal solution. Any suggestions for changing the parameters that could make it happen faster? &lt;/p&gt;&#xA;" OwnerUserId="3467" LastActivityDate="2020-07-08T13:27:40.613" Title="Settings for a faster solution of a MILP (GUROBI, python)" Tags="|mixed-integer-programming|python|gurobi|branch-and-bound|dual-simplex|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4063" PostTypeId="2" ParentId="4062" CreationDate="2020-05-06T16:09:57.990" Score="11" Body="&lt;p&gt;You could try changing the parameter mipfocus to 2 or 3 (&lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/mipfocus.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.0/refman/mipfocus.html&lt;/a&gt;) in order to let Gurobi focus more on improving the bound or proving optimality. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also try to set Cuts (&lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/cuts.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.0/refman/cuts.html&lt;/a&gt;) to 2 in order to let Gurobi be more aggressive with the Cuts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you need to examine the Log and see if the problem is primarily solved with Cuts or Branching or both.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2020-05-06T18:46:28.017" LastActivityDate="2020-05-06T18:46:28.017" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4064" PostTypeId="2" ParentId="4061" CreationDate="2020-05-06T17:55:55.187" Score="7" Body="&lt;p&gt;&lt;em&gt;As suggested by @LarrySnyder610, I am pasting my comment as an answer :&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neither one ! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is the linear relaxation of the original integer problem, after applying a Dantzig-Wolfe decomposition, which in essence, consists in reformulating variables as a convex combination of the extreme points of the polytope defined by the constraints of the original problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check &lt;a href=&quot;https://optimization.mccormick.northwestern.edu/index.php/Column_generation_algorithms&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt;, and the references mentioned there. It shows you an example of the original formulation, the master problem and the subproblem for the well known cutting stock problem.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-05-06T17:55:55.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4065" PostTypeId="2" ParentId="3644" CreationDate="2020-05-06T18:31:03.613" Score="1" Body="&lt;p&gt;We've recently been working on &lt;a href=&quot;https://www.optaplanner.org/learn/useCases/employeeRostering.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;hospital staff rostering&lt;/a&gt; with covid-19 specific constraints, such as these:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VrEvN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VrEvN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a working demo on &lt;a href=&quot;https://github.com/kiegroup/optaweb-employee-rostering/tree/covid-19&quot; rel=&quot;nofollow noreferrer&quot;&gt;this branch&lt;/a&gt; on github. It's open source in java.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2020-05-06T18:31:03.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4066" PostTypeId="2" ParentId="4062" CreationDate="2020-05-06T20:45:32.280" Score="9" Body="&lt;p&gt;If you have a recent enough version of Gurobi, there is a tuning tool that tries to find better parameter sets than the default settings. For best results, run it for a while (at least overnight) and run it with a few different instances of your problem. Here is some example code you can use to run it.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def tune(model, time_limit=-1, trials_per_setting=3):&#xA;    &amp;quot;&amp;quot;&amp;quot;Tunes a Gurobi model with basic settings. Parameter sets that&#xA;    Gurobi sees as an improvement are saved to tune0.prm, tune1.prm,&#xA;    etc. Parameter sets are stored in order of decreasing quality, with&#xA;    parameter set 0 being the best.&#xA;&#xA;    Args:&#xA;        model: an instance of a Gurobi model&#xA;        time_limit: total number of seconds to spend tuning. Default of&#xA;          -1 will choose a time limit automatically.&#xA;        trials_per_setting: number of trials to use per parameter set to &#xA;          reduce the effects of randomness. Default is 3.&#xA;    &amp;quot;&amp;quot;&amp;quot;&#xA;    model.setParam('TuneTimeLimit', time_limit)&#xA;    model.setParam('TuneTrials', trials_per_setting)&#xA;    model.update()&#xA;    model.tune()&#xA;    for i in range(model.tuneResultCount):&#xA;        model.getTuneResult(i)&#xA;        model.write('tune'+str(i)+'.prm')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For more information, see the documentation: &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/parameter_tuning_tool.html#sec:Tuning&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.0/refman/parameter_tuning_tool.html#sec:Tuning&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3319" LastEditorUserId="3319" LastEditDate="2020-07-08T03:38:35.957" LastActivityDate="2020-07-08T03:38:35.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4067" PostTypeId="2" ParentId="4062" CreationDate="2020-05-07T03:51:08.277" Score="7" Body="&lt;p&gt;In addition to the above answers:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It depends on what you want from the MIP-run. If you want to your run to find feasible solutions quickly, then keep &lt;code&gt;model.params.MIPFocus=1&lt;/code&gt;; if you are not facing difficulty in finding feasible solutions but want to focus on proving the optimality of these solutions, then keep &lt;code&gt;model.params.MIPFocus=2&lt;/code&gt;; or if you want your run to improve the best-objective bound, then keep &lt;code&gt;model.params.MIPFocus=3&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this &lt;a href=&quot;https://groups.google.com/forum/#!topic/gurobi/AOtWXoH3L5E&quot; rel=&quot;noreferrer&quot;&gt;thread&lt;/a&gt; on Google's Gurobi discussion group useful. The other parameters that affect the performance of a MIP-run are (&lt;a href=&quot;https://www.gurobi.com/documentation/8.1/refman/parameters.html#sec:Parameters&quot; rel=&quot;noreferrer&quot;&gt;documentation&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;model.params.Method&lt;/code&gt; &lt;a href=&quot;https://www.gurobi.com/documentation/7.5/refman/method.html#parameter:Method&quot; rel=&quot;noreferrer&quot;&gt;link&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;model.params.ConcurrentMIP&lt;/code&gt; &lt;a href=&quot;https://www.gurobi.com/documentation/7.5/refman/concurrentmip.html#parameter:ConcurrentMIP&quot; rel=&quot;noreferrer&quot;&gt;link&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;model.params.Cuts&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;model.params.NoRelHeuristic&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;model.params.Heuristics&lt;/code&gt; &lt;a href=&quot;https://www.gurobi.com/documentation/7.5/refman/heuristics.html#parameter:Heuristics&quot; rel=&quot;noreferrer&quot;&gt;link&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;model.params.RINS&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;model.params.ImproveStartNodes&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;model.params.ImproveStartTime&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could also run &lt;code&gt;grbtune&lt;/code&gt; tool as suggested above to tune the settings of the above parameters.&lt;/p&gt;&#xA;" OwnerUserId="2999" LastActivityDate="2020-05-07T03:51:08.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4068" PostTypeId="1" CreationDate="2020-05-07T07:57:45.163" Score="3" ViewCount="418" Body="&lt;p&gt;I am working on developing a column generation (CG) based optimization framework for a large-scale airline crew pairing problem (a set-covering problem). First, I generate an initial feasible solution to initialize the CG-heuristic. Subsequently, in each of the CG-iterations,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The restricted master problem (RMP) is solved for the LP-solution and the optimal dual vector.&lt;/li&gt;&#xA;&lt;li&gt;These dual variables along with information of existing flight-connections are used to construct partial pricing subproblems as the full-scale network is intractable. From this, I only generate the columns/variables with negative reduced cost.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My questions are related to Step 1. From the RMP, it is required to generate a:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;primal-solution (optimal primal vector with continuous variables &lt;span class=&quot;math-container&quot;&gt;$\in [0,1]$&lt;/span&gt; corresponding to each column/pairing in the input set), and&lt;/li&gt;&#xA;&lt;li&gt;a dual-solution (optimal dual vector with non-negative dual variables corresponding to each input constraint/flight).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In every CG-iteration, the input to the RMP consists of ~0.5 million columns/pairings and ~4500 constraints/flights. To solve the RMP, first, I formulate the primal using the above-sized input, and solve it using the Simplex algorithm to get the primal-optimal solution (having ~50k non-zero variables). Using this primal-solution, i.e, only non-zero variables as the search space, I formulate the dual of the problem and solve it. Questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;To solve the primal, which simplex method is the best method for such problems (currently, I use Gurobi and in that, I have empirically found the barrier method to the most effective in comparison to the primal simplex &amp;amp; dual simplex)? Is there a scientific survey on how the simplex method evolved and what are the associated advantages/disadvantages of the evolved methods?&lt;/li&gt;&#xA;&lt;li&gt;Is it advisable to formulate dual in the above-mentioned way, i.e., only using the optimal columns/pairings from the primal (~50k), or shall it be formulated using the whole input set of columns (~0.5 million) (I did it to reduce the solutioning-time of the dual)? Is it correct to assume that the optimal dual-solution of the former version of the dual will be the same as that of the latter version?&lt;/li&gt;&#xA;&lt;li&gt;Is there scientific evidence suggesting that solving the dual in CG using the interior-point methods can lead to better convergence than the simplex methods? &lt;/li&gt;&#xA;&lt;li&gt;For stabilization of CG, how to decide among the different interior-point methods available? (I have empirically found that the SciPy's interior-point method leads to better convergence than the Gurobi's barrier method for this optimization problem)  &lt;/li&gt;&#xA;&lt;li&gt;Is it possible to extract/derive the dual-solution from the primal-solution w/o solving the dual of the RMP or vice-versa, eliminating the need to solve both primal &amp;amp; dual in each CG-iteration?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2999" LastActivityDate="2020-05-07T07:57:45.163" Title="On solving the Restricted Master Problem in Column Generation technique" Tags="|linear-programming|simplex|column-generation|set-covering|interior-point-method|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4069" PostTypeId="1" CreationDate="2020-05-07T10:19:02.140" Score="6" ViewCount="362" Body="&lt;p&gt;I have a two-stage stochastic program as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad f^\top y+\sum_{s}p_sc_s^\top x_s\\\text{s.t.}&amp;amp;\quad&#xA;Ay=b\\&amp;amp;\quad&#xA;W_sX_s+Ty \le h_s \quad \forall s \in S \\&amp;amp;\quad&#xA;P_sx_s \le q_s \quad \forall s \in S \\&amp;amp;\quad&#xA;x_s \ge 0\\&amp;amp;\quad&#xA;y\in \{0,1\}&amp;amp;\quad\end{align}&lt;/span&gt;&#xA;and I want to solve it with Lagrangian relaxation. I relaxed the constraints &lt;span class=&quot;math-container&quot;&gt;$$W_sX_s+Ty \le h_s \quad \forall s \in S,$$&lt;/span&gt; and it is decomposed to a first-stage problem and &lt;span class=&quot;math-container&quot;&gt;$|S|$&lt;/span&gt; sub-problems related to the second stage. I solved the problem but there is a huge gap between lower and upper bounds. I think I correctly applied the algorithm (Gurobi+Python), but I do not know why it happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/87RZ9m.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/87RZ9m.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I have used Benders decomposition to solve this problem and because the coupling constraints are related to capacity constraints and because these constraints are not active in the optimal solution, the dual variables corresponding to these constraints are mostly zero and in generated cuts, most &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables have coefficients &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and it does not converge (or at least in a reasonable number of iterations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also used combinatorial Benders decomposition but it just excludes each solution and works like enumeration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be thankful if someone has a similar experience and let me know what I can do.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="123" LastEditDate="2020-05-07T13:21:26.063" LastActivityDate="2020-05-08T10:49:28.030" Title="Lagrangian Relaxation for Two-Stage Stochastic Program" Tags="|benders-decomposition|lagrangian-relaxation|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4070" PostTypeId="2" ParentId="4069" CreationDate="2020-05-07T21:14:23.163" Score="4" Body="&lt;p&gt;I'll comment on the Lagrangian relaxation question and leave the Benders question for someone else to comment on. (You might want to consider splitting your question into two, one for LR and one for BD.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my experience, this sort of gap is common. (And frustrating.) There are a few avenues you could go down in order to try to diagnose and maybe fix the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, remember that there is no guarantee that the Lagrangian bound will be tight, i.e., will equal the optimal objective function value of the original problem, even if you have the optimal Lagrange multipliers. There is a duality gap, and it might be non-zero. So, it's possible you did everything right but the bounds are just inherently far apart.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, it looks like you're running for ~50 iterations. In my experience it usually requires a few hundred to several hundred iterations before you can be confident that the bounds are close to where they should be. That's one reason why it's important to have subproblems that are easy to solve. (Are you solving your subproblem using Gurobi? If so, that might be a signal that LR is going to take too long to converge.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third, how are you updating the Lagrange multipliers? If you're using subgradient optimization, there are several parameters you can play around with. In addition, you can consider using other types of methods (bundle methods, etc.) in place of subgradient optimization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fourth, the initial multipliers that you feed the algorithm can have a large effect on convergence. If you can find a way to easily identify multipliers that might be in the ballpark, you can use these as your initial multipliers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end, this sort of thing just requires a lot of experimentation and trial-and-error.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-05-07T21:14:23.163" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4071" PostTypeId="1" CreationDate="2020-05-08T10:19:39.130" Score="5" ViewCount="262" Body="&lt;p&gt;I would like to create non-linear violation costs in my VRP. I already created my whole VRP with time windows in which I have these decision variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dvar float+ w[N][D]; // violation time for late arrivals for every node and every day&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These dvars are working, but now I want to make a link with the violation costs decision variables, which are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dvar boolean a1[N][D];// no violation &#xA;dvar boolean a2[N][D];// soft violation of 0-5 minutes&#xA;dvar boolean a3[N][D];// soft violation of 6-10 minutes&#xA;dvar boolean a4[N][D];// soft violation of 11 -15 minutes &#xA;dvar boolean a5[N][D];// soft violation of 15+ minutes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to force:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a1[N][D] to be 1, when w[N][D] &amp;lt;=0, 0 otherwise&#xA;a2[N][D] to be 1, when w[N][D] &amp;gt;0 &amp;amp; &amp;lt;=5, 0 otherwise&#xA;a3[N][D] to be 1, when w[N][D] &amp;gt;5 &amp;amp; &amp;lt;=10, 0 otherwise&#xA;a4[N][D] to be 1, when w[N][D] &amp;gt;10 &amp;amp; &amp;lt;=15, 0 otherwise&#xA;a5[N][D] to be 1, when w[N][D] &amp;gt;=16, 0 otherwise&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  forall(i in N, d in D)&#xA;  (a1[i][d] + a2[i][d] + a3[i][d] + a4[i][d] + a5[i][d]) == 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is still something wrong with these constraints though.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;forall(i in N, d in D)&#xA;  (a1[i][d] + a2[i][d] + a3[i][d] + a4[i][d] + a5[i][d]) == 1; //sum of all a's = 1&#xA;&#xA;forall(i in N, d in D)&#xA;  w[n][d]&amp;lt;= (5*a2[i][d]) + 1000*(1-a2[i][d]); // a2 == 1 when w[n][d]&amp;gt;0 &amp;amp; &amp;lt;=5&#xA;&#xA;forall(i in N, d in D)&#xA;  (6*a3[i][d] - 1000*(a3[i][d]-1))&amp;lt;= w[i][d]; // a3&#xA;&#xA;forall(i in N, d in D)&#xA;   w[i][d] &amp;lt;= (10*a3[i][d]) + 1000*(1-a3[i][d]); // a3&#xA;&#xA;forall(i in N, d in D)&#xA;  (11*a4[i][d] - 1000*(a4[i][d]-1))&amp;lt;= w[i][d]; //a4&#xA;&#xA;forall(i in N, d in D)&#xA;   w[i][d] &amp;lt;= (15*a4[i][d]) + 1000*(1-a4[i][d]); // a4&#xA;&#xA;forall(i in N, d in D)&#xA;  (16*a5[i][d] - 1000*(a5[i][d]-1))&amp;lt;= w[i][d]; //a5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it sets a5==1 for all constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, w is used in the model as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;forall (i in N, d in D:q[i][d]&amp;gt;=1)&#xA;y[i][d] - w[i][d] &amp;lt;= sl[i][d]; // late arrival time soft&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where y[i][d] is the arrival time variable and sl the soft time window&lt;/p&gt;&#xA;" OwnerUserId="3479" LastEditorUserId="3479" LastEditDate="2020-05-12T09:09:17.120" LastActivityDate="2020-05-12T09:09:17.120" Title="Problem with binary decision variable constraints in VRP" Tags="|mixed-integer-programming|solver|cplex|linearization|vehicle-routing|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4072" PostTypeId="2" ParentId="4071" CreationDate="2020-05-08T10:39:56.933" Score="3" Body="&lt;p&gt;You can impose&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;a_{nd} + b_{nd} + f_{nd} + g_{nd} =1&#xA;$$&lt;/span&gt;&#xA;And link these variables with &lt;span class=&quot;math-container&quot;&gt;$\omega_{nd}$&lt;/span&gt; as follows :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA; &amp;amp;\omega_{nd} \le 5 a_{nd} +M(1-a_{nd})\\&#xA;6 b_{nd} - M(1-b_{nd}) \le &amp;amp; \; \omega_{nd} \le 10 b_{nd} +M(1-b_{nd})\\&#xA;11 f_{nd}  - M(1-f_{nd}) \le &amp;amp; \; \omega_{nd} \le 15 f_{nd} +M(1-f_{nd}) \\&#xA; 16 g_{nd}  - M(1-g_{nd}) \le &amp;amp; \; \omega_{nd}  \\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if &lt;span class=&quot;math-container&quot;&gt;$\omega_{nd}=1$&lt;/span&gt;, only the first constraint will be active with &lt;span class=&quot;math-container&quot;&gt;$a_{nd} = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\omega_{nd}=7$&lt;/span&gt;, only the second one will be active with &lt;span class=&quot;math-container&quot;&gt;$b_{nd} = 1$&lt;/span&gt;, and so forth.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-05-08T10:45:07.277" LastActivityDate="2020-05-08T10:45:07.277" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="4073" PostTypeId="2" ParentId="4069" CreationDate="2020-05-08T10:49:28.030" Score="2" Body="&lt;p&gt;Larry Snyder explained very well. Few items to check/add for the Lagrangean Relaxaiton part:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make sure your lowerbounds- i.e. the feasible solution (most probably depending on fixed first stage variables)- are computed correctly. I usually do it with a very small instance and double check it with hand calculations&lt;/li&gt;&#xA;&lt;li&gt;Similarly double-check you upperbound computations (optimal LR solution).&lt;/li&gt;&#xA;&lt;li&gt;Are you using subgradient optimization to update LR multipliers? If so you should double check the subgradient computations and then the multiplier computations. Usually it is where most of the mistakes occur.&lt;/li&gt;&#xA;&lt;li&gt;As Larry highlighted, you should have larger number of iterations. Actually the best way is, for a very small instance, set your stopping criteria to a very tight value like 0.00000001 and also set your iteration limits to thousands. So that you can be almost sure that you find the optimal solution (LB). Of course if you can compare this with the exact solution it would be even better.&lt;/li&gt;&#xA;&lt;li&gt;You can check if the LR problem has integrality property by either proving/disproving it or by solving the LP relaxation of your original problem. If your UBs converge to the LP relaxation (again you should run many iterations) then you have the curse of integrality property, where your UB can never be better than the LP relaxation.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="632" LastActivityDate="2020-05-08T10:49:28.030" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4075" PostTypeId="1" AcceptedAnswerId="4076" CreationDate="2020-05-08T11:26:34.373" Score="5" ViewCount="923" Body="&lt;p&gt;In a simple transportation problem like below image, how to model a constraint for shipment discount e.g. if quantity transported from any origin to any destination is more than 100 unit then the supplier will offer 10% discount in the cost of transportation or if quantity transported from any origin to any destination is more than 200 then the supplier will offer 20% discount in the cost of transportation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5rLgS.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5rLgS.png&quot; alt=&quot;**problem**&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1279" LastEditorUserId="36" LastEditDate="2020-05-08T12:56:04.163" LastActivityDate="2020-05-08T12:56:04.163" Title="How to write quantity discount constraint?" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4076" PostTypeId="2" ParentId="4075" CreationDate="2020-05-08T12:29:03.120" Score="6" Body="&lt;p&gt;There are many ways to do this. Here is one. In what follows, &lt;span class=&quot;math-container&quot;&gt;$x=x_{ij}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is a given edge (in other words it is only valid for one edge). You have to apply the same technique for the rest of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your cost function is of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(x) = \left\{\begin{matrix}&#xA;cx, &amp;amp; 0 \le x &amp;lt; 100\\ &#xA;90\%\;cx, &amp;amp; 100 \le x &amp;lt; 200\\ &#xA;80\%\;cx, &amp;amp; 200 \le x &amp;lt; 300&#xA;\end{matrix}\right.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can write the objective function as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f(x_1,x_2,x_3)=cx_1 +90\%\;cx_2+80\%\;cx_3&#xA;$$&lt;/span&gt;&#xA;with constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0 \le x_1 \le 100y_1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$100y_2 \le x_2 \le 200y_2$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$200y_3 \le x_3 \le 300y_3$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_1+y_2+y_3=1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_1, y_2, y_3 \in \{0,1\}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_1,x_2,x_3 \ge 0$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-05-08T12:29:03.120" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4077" PostTypeId="2" ParentId="4071" CreationDate="2020-05-08T13:45:55.100" Score="6" Body="&lt;p&gt;Here's a stronger formulation that uses the same variables and fewer constraints, assuming &lt;span class=&quot;math-container&quot;&gt;$L \le w_{i,d} \le U$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{k=1}^5 a_{k,i,d} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$ and $d$}\\ &#xA;L a_{1,i,d} + 1 a_{2,i,d} + 6 a_{3,i,d} + 11 a_{4,i,d} + 16 a_{5,i,d} &#xA;&amp;amp;\le w_{i,d}&#xA;&amp;amp;&amp;amp;\text{for all $i$ and $d$}\\ &#xA;0 a_{1,i,d} + 5 a_{2,i,d} + 10 a_{3,i,d} + 15 a_{4,i,d} + U a_{5,i,d} &#xA;&amp;amp;\ge w_{i,d}&#xA;&amp;amp;&amp;amp;\text{for all $i$ and $d$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-05-08T14:02:16.423" LastActivityDate="2020-05-08T14:02:16.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4078" PostTypeId="1" CreationDate="2020-05-08T18:15:57.253" Score="3" ViewCount="169" Body="&lt;p&gt;Suppose you are developing an optimization software.&#xA;You read in some data files, build some optimization model with a solver (like Gurobi), then write back some data files with your solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What kind of test do you write in order to validate the solution/behaviour of your optimization model? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you first create like small examples, where you calculate the solution by hand?&#xA;Do you write a routine, that rechecks the constraints without the solver?&#xA;....?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2020-05-08T18:15:57.253" Title="How do you test your optimization models?" Tags="|software|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4079" PostTypeId="1" AcceptedAnswerId="4080" CreationDate="2020-05-08T20:49:55.703" Score="1" ViewCount="131" Body="&lt;p&gt;I am dealing with a multi-travelling passenger problem.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; is a binary variable that allocate a passenger &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to a vehicle &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, every vehicle can carry only &lt;span class=&quot;math-container&quot;&gt;$n_{pv}$&lt;/span&gt; passenger where &lt;span class=&quot;math-container&quot;&gt;$i \in \{1,2,\dots,n\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j \in \{1,2,\cdots,n_v\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(n_v = n/n_{pv})$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the number of passengers, &lt;span class=&quot;math-container&quot;&gt;$n_v$&lt;/span&gt; is the number of vehicles and &lt;span class=&quot;math-container&quot;&gt;$n_{pv}$&lt;/span&gt; is the number of passenger per vehicle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mathematical model to allocate each passenger to a vehicle to minimize the total cost. The decision variable is &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; where &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}x_{i,j}=\begin{cases} 1 &amp;amp;&amp;amp;\text{if passenger $i$ is allocated to vehicle $j$}\\0 &amp;amp;&amp;amp;\text{otherwise.}\end{cases}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The objective is &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_i \sum_j c_{i,j}\cdot x_{i,j} &amp;amp;&amp;amp;\text{$c_{i,j}$ is the cost of travelling passenger $i$ by vehicle $j$}\\\text{s.t.}&amp;amp;\quad\sum_j x_{i,j}= 1 &amp;amp;&amp;amp;\text{for each $i$}\\&amp;amp;\quad\sum_i x_{i,j} = n_{pv} &amp;amp;&amp;amp;\text{for each $j$}.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The passengers are allocated by the order of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;; i.e. &lt;span class=&quot;math-container&quot;&gt;$i = 1$&lt;/span&gt; will be allocated before &lt;span class=&quot;math-container&quot;&gt;$i = 2$&lt;/span&gt; and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to formulate a decision variable indicating the order of passengers in each vehicle denoted by &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;; i.e. &lt;span class=&quot;math-container&quot;&gt;$y_i = 1$&lt;/span&gt; if he is the first passenger assigned to his vehicle, &lt;span class=&quot;math-container&quot;&gt;$y_i = 2$&lt;/span&gt; if he is the second assigned to his vehicle and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example if we have &lt;span class=&quot;math-container&quot;&gt;$n = 9$&lt;/span&gt; passengers and &lt;span class=&quot;math-container&quot;&gt;$n_{pv} = 3$&lt;/span&gt;, if the values of the decision variables were &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{1,1} = 1, &amp;amp;&amp;amp;x_{1,2} = 0, &amp;amp;&amp;amp;x_{1,3} = 0 \\&#xA;x_{2,1} = 1, &amp;amp;&amp;amp;x_{2,2} = 0, &amp;amp;&amp;amp;x_{2,3} = 0 \\&#xA;x_{3,1} = 0, &amp;amp;&amp;amp;x_{3,2} = 1, &amp;amp;&amp;amp;x_{3,3} = 0 \\&#xA;x_{4,1} = 0, &amp;amp;&amp;amp;x_{4,2} = 0, &amp;amp;&amp;amp;x_{4,3} = 1 \\&#xA;x_{5,1} = 1, &amp;amp;&amp;amp;x_{5,2} = 0, &amp;amp;&amp;amp;x_{5,3} = 0 \\&#xA;x_{6,1} = 0, &amp;amp;&amp;amp;x_{6,2} = 0, &amp;amp;&amp;amp;x_{6,3} = 1 \\&#xA;x_{7,1} = 0, &amp;amp;&amp;amp;x_{7,2} = 1, &amp;amp;&amp;amp;x_{7,3} = 0 \\&#xA;x_{8,1} = 0, &amp;amp;&amp;amp;x_{8,2} = 0, &amp;amp;&amp;amp;x_{8,3} = 1 \\&#xA;x_{9,1} = 0, &amp;amp;&amp;amp;x_{9,2} = 1, &amp;amp;&amp;amp;x_{9,3} = 0&#xA;\end{align}&lt;/span&gt; then the values of &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;s will be &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_1 &amp;amp;= 1\\&#xA;y_2 &amp;amp;= 2\\&#xA;y_3 &amp;amp;= 1\\&#xA;y_4 &amp;amp;= 1\\&#xA;y_5 &amp;amp;= 3\\&#xA;y_6 &amp;amp;= 2\\&#xA;y_7 &amp;amp;= 2\\&#xA;y_8 &amp;amp;= 3\\&#xA;y_9 &amp;amp;= 3.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I derive the values of &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;s through linear equations? I have a previous generous answer for another model, I used the same concept to derive the vehicle number for each passenger &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; using &lt;span class=&quot;math-container&quot;&gt;\begin{align}\sum_j j\cdot x_{i,j} = v_i\quad\forall i\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$v_i \in \{1,2,\dots,n_v\}$&lt;/span&gt; but I don't know if that is the right way to derive &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appreciate your help.&lt;/p&gt;&#xA;" OwnerUserId="3480" LastEditorUserId="123" LastEditDate="2020-05-09T08:53:47.253" LastActivityDate="2020-05-09T08:53:47.253" Title="Derived variables of when a decision variable appears?" Tags="|mixed-integer-programming|constraint-programming|combinatorial-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4080" PostTypeId="2" ParentId="4079" CreationDate="2020-05-08T22:18:10.773" Score="3" Body="&lt;p&gt;You want to enforce &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=1 \implies y_i=\sum_{k \le i} x_{k,j}$&lt;/span&gt;.  One way to do that is as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-\min(n_{pv},i)(1-x_{i,j}) \le y_i - \sum_{k \le i} x_{k,j} \le \min(n_{pv},i)(1-x_{i,j})$$&lt;/span&gt;&#xA;for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&#xA;Here, we have used big-M values based on &lt;span class=&quot;math-container&quot;&gt;$0 \le y_i \le \min(n_{pv},i)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0 \le \sum_{k \le i} x_{k,j}\le \min(n_{pv},i)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-05-08T22:18:10.773" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4081" PostTypeId="1" CreationDate="2020-05-09T04:37:12.193" Score="6" ViewCount="748" Body="&lt;p&gt;I have a constraint in my formulation that contains multiplication of an integer variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and a continuous variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, which is &lt;span class=&quot;math-container&quot;&gt;$xy=q$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is the number of units in which &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; gets equally divided to get the quantity &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in each unit. Is McCormick envelope a correct way to relax this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My attempts give me a solution in which the original constraint is violated. Is there any way/algorithm to iteratively update McCormick relaxation for such problems?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Baron 20.4.14 with GAMS. Do I need to include relaxation?&lt;/p&gt;&#xA;" OwnerUserId="57" LastEditorUserId="123" LastEditDate="2020-05-09T08:57:52.970" LastActivityDate="2020-05-09T18:16:52.703" Title="Linearize a product of an integer variable (not just binary) and a continuous variable?" Tags="|integer-programming|linearization|relaxation|baron|mccormick|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4082" PostTypeId="1" CreationDate="2020-05-09T15:34:03.990" Score="2" ViewCount="119" Body="&lt;p&gt;I was trying to apply Dantzig Decomposition followed by Column Generation. The following is how I was taught.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{l}&#xA;\text { Minimize }-10 x_1-2 x_{2}-4 x_{3} \\&#xA;\text { subject to: } x_{1}+x_{3} \leq 15  \text{........ I}\\&#xA;x_{1}+2 x_{2} \leq 10 \text{........II}\\&#xA;2 x_{3}+x_{4} \leq 20 \text{........III}&#xA;\end{array}&lt;/span&gt;&#xA;Considering I as the link constraint and II as a constraint for segment 1 and III for segment 2&#xA;&lt;br/&gt;&#xA;Next we trasform the lp for convex combination of extreme points from the disjoint constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$c=\left[\begin{array}{llll}&#xA;-10 &amp;amp; -2 &amp;amp; -4 &amp;amp; 0&#xA;\end{array}\right], A=\left[\begin{array}{lll}&#xA;1 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0&#xA;\end{array}\right]$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\begin{aligned}&#xA;M_{\text {inimize }} &amp;amp; \sum \lambda_{j} C X_{j} \\&#xA;&amp;amp; \sum \lambda_{j} A X_{j}+s=15 \text{.....IV} \\&#xA;&amp;amp; \sum \lambda_{j}=1 \text{.....V}&#xA;\end{aligned}\end{equation}&lt;/span&gt;&#xA;&lt;br/&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\pi_1 and \pi_2$&lt;/span&gt; be the dual variables associated with IV and V respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$X_j$&lt;/span&gt; is corner point for I and II&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\begin{array}{l}&#xA;\text { Initial Solution} =&amp;gt;X_{1}=[0 \quad 0 \quad 0 \quad 0], \lambda_{1}=1 \\&#xA;\quad \text { Basis } \rightarrow s_{1} , \lambda_{1}&#xA;\end{array}\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\begin{array}{c|cc|c} &#xA;&amp;amp; s &amp;amp; \lambda_{1} &amp;amp; R_{15} \\&#xA;\hline s &amp;amp; 1 &amp;amp; 0 &amp;amp; 15 \\&#xA;\lambda_{1} &amp;amp; 0 &amp;amp; 1 &amp;amp; 1 \\&#xA;\hline z_j-c_{j} &amp;amp; 0 &amp;amp; 0 &amp;amp; 0&#xA;\end{array}\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, we check which &lt;span class=&quot;math-container&quot;&gt;$\lambda_j$&lt;/span&gt; satisfies to ender into the basis:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\begin{array}{c}&#xA;z_{i}-c_{j} \geqslant 0 \\&#xA;z_{j}=\pi P_{j}&#xA;\end{array}\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; is the dual vector, &lt;span class=&quot;math-container&quot;&gt;$P_j $&lt;/span&gt; is the entering column&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}P_{j}=\left[\begin{array}{c}&#xA;A X_{j} \\&#xA;1&#xA;\end{array}\right], C_{j}=C X_{j}\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\begin{array}{l}&#xA;{\left[\pi_{1} \pi_{2}\right]\left[\begin{array}{c}&#xA;A X_{j} \\&#xA;1&#xA;\end{array}\right]-c x_{j} \geqslant 0} \\&#xA;\left(\pi_{1} A-c\right) x_{j}+\pi_{2} \geqslant 0 \\&#xA;\pi_{1}=0,\pi_{2}=0 \text{He said that in the absence of artificial variables, the values under the initial basis are the values for the dual variables.}&#xA;\end{array}\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;New Objective: Maximize &lt;span class=&quot;math-container&quot;&gt;$-CX_j$&lt;/span&gt;,&#xA;&lt;br/&gt; where &lt;span class=&quot;math-container&quot;&gt;$X_j$&lt;/span&gt; belongs to the corner points of I and II together.&#xA;&lt;br/&gt; Next, we decompose the objective into two subproblems.&#xA;&lt;br/&gt; First:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\begin{array}{l}&#xA;\text { Maximize } x_{1}+2 x_{2} \\&#xA;\text{subject to}: x_{1}+2 x_{2} \leq 10&#xA;\end{array}\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This gives &lt;span class=&quot;math-container&quot;&gt;$x_1=10,x_2=0, z=100$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt; Second:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\begin{array}{l}&#xA;\text { Maximize }4 x_{3} \\&#xA;\text{subject to}: 2x_{3}+ x_{4} \leq 20&#xA;\end{array}\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This gives &lt;span class=&quot;math-container&quot;&gt;$x_3=10,x_4=0, z=40$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt; &lt;span class=&quot;math-container&quot;&gt;$X_2 =[10 \quad 0 \quad 10 \quad 0]$&lt;/span&gt;&#xA;&lt;br/&gt;&lt;span class=&quot;math-container&quot;&gt;$Z=100+40=140$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\begin{aligned}&#xA;\bar{P}_{2} &amp;amp;=B^{-1} P_{2} \\&#xA;&amp;amp;=P_{2} \text{  as B=I}\\&#xA;&amp;amp;=\left[\begin{array}{c}&#xA;AX_2 \\&#xA;1&#xA;\end{array}\right] \\&#xA;&amp;amp;=\left[\begin{array}{c}&#xA;20 \\&#xA;1&#xA;\end{array}\right]&#xA;\end{aligned}\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\begin{array}{c|ccc|cc} &#xA;&amp;amp; s &amp;amp; \lambda_{1} &amp;amp; \lambda_{2} &amp;amp; \text { RHS } &amp;amp; \theta \\&#xA;\hline s &amp;amp; 1 &amp;amp; 0 &amp;amp; (20) &amp;amp; 15 &amp;amp; 15 / 20 \\&#xA;\lambda_{1} &amp;amp; 0 &amp;amp; 1 &amp;amp; 1 &amp;amp; 1 &amp;amp; 1 / 1 \\&#xA;\hline &amp;amp; 0 &amp;amp; 0 &amp;amp; 140 &amp;amp;0 &amp;amp;&#xA;\end{array}\end{equation}&lt;/span&gt;&#xA;With &lt;strong&gt;20&lt;/strong&gt; as pivot, we get&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\begin{array}{c|ccc|c} &#xA;&amp;amp; s &amp;amp; \lambda_{1} &amp;amp; \lambda_{2} &amp;amp; RHS\\&#xA;\hline \lambda_2 &amp;amp; 1 / 20 &amp;amp; 0 &amp;amp; 1 &amp;amp; 15 / 20 \\&#xA;\lambda_{1} &amp;amp; -1 / 20 &amp;amp; 1 &amp;amp; 0 &amp;amp; 5 / 20 \\&#xA;\hline &amp;amp; -140 &amp;amp; 0 &amp;amp; 0 &amp;amp; -105&#xA;\end{array}\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\text { current sol }=\frac{15}{20}\left[\begin{array}{c}&#xA;0 \\&#xA;0 \\&#xA;0 \\&#xA;0&#xA;\end{array}\right]+\frac{5}{20}\left[\begin{array}{c}&#xA;10 \\&#xA;0 \\&#xA;10 \\&#xA;0&#xA;\end{array}\right]\end{equation}&lt;/span&gt;&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=QxZM8qARos4&quot; rel=&quot;nofollow noreferrer&quot;&gt;The video lecture that I am following&lt;/a&gt;&#xA;&lt;br/&gt;&#xA;&lt;br/&gt; I am facing trouble applying the same method to the same problem if all constraints are equality. I need to know how things change in the presence of artificial variables. Also, he took [0 0 0 0] as the initial solution which made things easy. In case we do not know any initial solution, we will have to add another artificial variable.&#xA;&lt;br/&gt; How do we get the values for the dual variables in the presence of artificial variables.&#xA;&lt;br/&gt; It would be really helpful if someone could show one iteration inline with the way I have shown.&#xA;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt; PS. I don't have very in-depth knowledge of the simplex method so some of my doubts may be stupid.&lt;/p&gt;&#xA;" OwnerUserId="3481" LastEditorUserId="3481" LastEditDate="2020-05-09T16:53:31.353" LastActivityDate="2020-05-09T16:53:31.353" Title="Dantzig decomposition and Column Generation for equality constraints" Tags="|linear-programming|column-generation|dantzig-wolfe-decomposition|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4083" PostTypeId="2" ParentId="4081" CreationDate="2020-05-09T18:16:52.703" Score="9" Body="&lt;p&gt;The McCormick envelope is one possible approach. Another, if the domain of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is not too large, is to use a type 1 Special Ordered Set. Assume that &lt;span class=&quot;math-container&quot;&gt;$y\in\lbrace 1,\dots,N\rbrace$&lt;/span&gt;. Replace &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; with&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=1}^N j\cdot z_j$$&lt;/span&gt;where the &lt;span class=&quot;math-container&quot;&gt;$z_j$&lt;/span&gt; are binary variables, and replace the equation &lt;span class=&quot;math-container&quot;&gt;$xy=q$&lt;/span&gt; with&lt;span class=&quot;math-container&quot;&gt;$$x=\sum_{j=1}^N\frac{q}{j}z_j.$$&lt;/span&gt;Add the constraint&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=1}^N z_j = 1.$$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; is constant, you're done. If &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; is a variable, you need to do another linearization, replacing &lt;span class=&quot;math-container&quot;&gt;$q/j \cdot z_j$&lt;/span&gt; with yet another variable &lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt; and adding the constraints&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;w_{j} &amp;amp; \le Qz_{j}\\&#xA;w_{j} &amp;amp; \le\frac{q}{j}\\&#xA;w_{j} &amp;amp; \ge\frac{q}{j}-\frac{Q}{j}\left(1-z_{j}\right)&#xA;\end{align*}&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is an upper bound on &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-09T18:16:52.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4084" PostTypeId="1" CreationDate="2020-05-09T22:16:00.200" Score="2" ViewCount="113" Body="&lt;p&gt;I’m hoping someone would be able to help with insight to a normalization approach, I am tasked with identifying the relative difficulty between stages in a manufacturing process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The processes can be multi dimensional, where you might have steps 1,2,3 but within these steps there are different types of variants that can be produced. Each manufacturing process may consists of difference steps and variant combinations (not all steps need to be performed and each process may have different step, variant combinations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally. the output data may be reported in different unit of measures, e.g. early steps may be in KGs where later steps in piece counts (# no. of units).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am trying to do is create a relative difficulty analysis that will tell me how much more or less difficult {step 1 variant 1} is compared to any other step, e.g. {step 1 variant 2} or {step 3 variant 3} for what ever process is being run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I can easily say {step 1 variant 1} is +/- difficult than {step 4 variant 6}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a large data set of historical output performance, e.g kg/hour, units/hour etc. for each step and variant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I have been able to normalize the variants within the steps but the difficulty is with comparing the variants across the steps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any previous experience with an approach that could work here or any existing libraries/algorithms that could work? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/L1Urg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/L1Urg.png&quot; alt=&quot;data layout&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3483" LastActivityDate="2020-05-10T00:46:50.627" Title="Normalization approaches to manufacturing data" Tags="|optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4085" PostTypeId="2" ParentId="4084" CreationDate="2020-05-10T00:46:50.627" Score="1" Body="&lt;p&gt;If I understood your question correctly, you are trying to find the relative weight of each individual process-variant combination. It reminds me of the Analytical Hierarchy Process(AHP) in which we try to choose the best option(out of a given set of options) based on the importance or value of the options. In AHP a matrix of relative weights for each attribute has been calculated and using those matrices the decision-maker proceeds the process. You can easily find details of the process, for example in (1). Another approach that you can try (I doubt if it's technically feasible) is &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-319-91648-4_1&quot; rel=&quot;nofollow noreferrer&quot;&gt;TOPSIS&lt;/a&gt; in which all the options are ranked based on their similarity to the ideal option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, you can normalize whatever weight you calculated to avoid dealing with the units.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) Goepel, Klaus D. &quot;Implementing the analytic hierarchy process as a standard method for multi-criteria decision making in corporate enterprises–a new AHP excel template with multiple inputs.&quot; Proceedings of the international symposium on the analytic hierarchy process. Vol. 2013. Creative Decisions Foundation Kuala Lumpur, 2013.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-05-10T00:46:50.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4086" PostTypeId="1" AcceptedAnswerId="4087" CreationDate="2020-05-10T01:42:12.057" Score="3" ViewCount="298" Body="&lt;p&gt;I am working on a large NLP model with equilibrium equations in which the variables are defined in the following form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i \in [L_B, U_B] \cup\{0\} \quad \text{where} \quad L_B \ \&amp;amp; \ U_B \in\Bbb R^+ \quad \text{and } \quad 0&amp;lt;L_B&amp;lt;U_B$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to define such a hybrid (mixed discrete, continuous) domain for variables in &lt;strong&gt;Pyomo&lt;/strong&gt; or &lt;strong&gt;Ampl&lt;/strong&gt;? I know that it's possible to define binary variables as indicators but this approach added a big number of binary variables to the model which is already hard to be solved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One idea is to implement something like an MPEC or variational inequalities (mpec package of Pyomo) approach where &lt;strong&gt;&lt;em&gt;XOR&lt;/em&gt;&lt;/strong&gt; has been defined for sets of constraints. But is it possible for variables?&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2020-05-10T08:43:42.713" LastActivityDate="2020-05-10T15:22:18.697" Title="How to define hybrid variables without using additional binary variables?" Tags="|modeling|binary-variable|pyomo|ampl|minlp|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4087" PostTypeId="2" ParentId="4086" CreationDate="2020-05-10T04:47:04.660" Score="3" Body="&lt;p&gt;An alternative approach to binary variables or semicontinuous variables is the following cubic polynomial inequality:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x(x-L_B)(U_B-x)\ge 0$$&lt;/span&gt;&#xA;Because &lt;span class=&quot;math-container&quot;&gt;$x \ge 0$&lt;/span&gt;, this constraint enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(x = 0) \lor (x - L_B \ge 0 \land U_B - x \ge 0),$$&lt;/span&gt;&#xA;as desired.&#xA;The case &lt;span class=&quot;math-container&quot;&gt;$(x - L_B \le 0 \land U_B - x \le 0)$&lt;/span&gt; is prevented by &lt;span class=&quot;math-container&quot;&gt;$L_B &amp;lt; U_B$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After further consideration, I realized that a quadratic constraint and simple bounds are enough.  We want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(x = 0) \lor (x \ge L_B \land x \le U_B).$$&lt;/span&gt;&#xA;Distribute the &lt;span class=&quot;math-container&quot;&gt;$\lor$&lt;/span&gt; to rewrite in conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(x = 0 \lor x \ge L_B) \land (x = 0 \lor x \le U_B).$$&lt;/span&gt;&#xA;Because &lt;span class=&quot;math-container&quot;&gt;$U_B &amp;gt; 0$&lt;/span&gt;, this reduces to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(x = 0 \lor x \ge L_B) \land (x \le U_B),$$&lt;/span&gt;&#xA;which you can enforce via&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x(x-L_B) &amp;amp;\ge 0 \\&#xA;0 \le x &amp;amp;\le U_B&#xA;\end{align}&lt;/span&gt;&#xA;(For comparison, the usual big-M approach instead would replace the quadratic constraint with a binary variable and linear constraints to enforce the disjunction.)&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-05-10T15:22:18.697" LastActivityDate="2020-05-10T15:22:18.697" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4088" PostTypeId="1" CreationDate="2020-05-10T15:36:04.690" Score="2" ViewCount="189" Body="&lt;p&gt;I am struggling to find a representative problem formulation for this optimization challenge. I have implemented a MILP in Matlab, but the run time is taking more then a day. My goal is to see if it fits the methods of some other common problems, where I may be able to apply some well known heuristics. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given a set , &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; discrete items, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;,  and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; subsets, &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; &#xA;&lt;span class=&quot;math-container&quot;&gt;$$ S :=\{i_1,i_2,i_3\dots,i_n\} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ M_{1,2,3,\dots k} \subseteq S $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Choose exactly &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; subsets &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$$X &amp;lt; k$$&lt;/span&gt; to minimize the number of items &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; that are in 2 or more of the &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; subsets. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ADDT'L Notes&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There is no extra value if the items &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; are selected 0 or 1 times, just less then 2 &lt;/li&gt;&#xA;&lt;li&gt;Every item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; &lt;strong&gt;IS NOT&lt;/strong&gt; required to be selected&lt;/li&gt;&#xA;&lt;li&gt;Each subset is predefined, and pseudo random&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ ---- Below is just a different attempt at formulation---- $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to keep it more math definition oriented above,  but the other way I simplified the problem is (using my some programming aspects):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) I have a logical matrix , M ( i rows, j col) , where the rows represent the population and the columns represent the available subsets. &#xA;2) Goal is to optimize F, a column vector ( j , 1), that represents the choice of each subset (columns of M) to minimize the number of elements of M x F that are &gt;= 2;&#xA;3) F is subject to you are required to choose exactly X subsets. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Need to define a column logical vector F (j rows, 1 columns) such that F has K true entries (representing the sub set choices) and the rest are false&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i = 1e6;&#xA;j = 150;&#xA;X = 140&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set_Matrix = randi( [0 1], i , j );&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Optimize F as to &#xA;Minimize : sum(sum(Set_Matrix * F) &gt;= 2)&#xA;Where  sum(F) == X (I.e pick 140 of the 150 subsets)&lt;/p&gt;&#xA;" OwnerUserId="3486" LastActivityDate="2020-05-10T15:59:52.823" Title="Does this problem fall into any common problem definition....Knapsack maybe?" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|knapsack|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4089" PostTypeId="2" ParentId="4088" CreationDate="2020-05-10T15:55:52.593" Score="4" Body="&lt;p&gt;Here is a MILP formulation, in case you did something different.  Let binary variable &lt;span class=&quot;math-container&quot;&gt;$F_j$&lt;/span&gt; indicate whether subset &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is chosen.  Let binary variable &lt;span class=&quot;math-container&quot;&gt;$T_i$&lt;/span&gt; indicate whether item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; appears in two or more of the chosen subsets.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_i T_i$&lt;/span&gt; subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j F_j &amp;amp;= 140 \tag1 \\&#xA;\sum_j M_{i,j} F_j - 1 &amp;amp;\le 149 T_i &amp;amp;&amp;amp;\text{for all $i$} \tag2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; is the cardinality constraint.  Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$\sum_j M_{i,j} F_j \ge 2 \implies T_i = 1$&lt;/span&gt;.  If most of these constraints are naturally satisfied anyway, you could generate them dynamically only if they are violated.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-05-10T15:59:52.823" LastActivityDate="2020-05-10T15:59:52.823" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4093" PostTypeId="1" CreationDate="2020-05-11T02:46:51.060" Score="5" ViewCount="125" Body="&lt;p&gt;I'm trying to help out a relative of mine who runs a small highly seasonal business in the clothing/textiles industry. 80% of sales are in Q1 of every year, and the purchasing and manufacturing decisions must usually be placed around May-July given lead time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Their usual process is to assume a 5% yearly demand increase, so they calculate per-SKU inventory on April and ensure they're ordering enough to reach 105% inventory compared to previous year. Given the variability (and lot's of SKUs), it's not optimal, but simple enough and usually works well for them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the high uncertainty of coronavirus, demand is highly uncertain as many of their customers are affected and would cut orders. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to dust-off my Operations Research background from engineering undergrad to provide help that is slightly better than a hand-wavy guess. Right now the guess it to roughly cut all order by 20-40%. Which is obviously a very broad range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems like a newsvendor-type problem, with uncertain demand. I do have access to 5yr historical sales &amp;amp; inventory levels, so can run to estimate the demand distribution. But I have no idea on how to go about estimating future demand, and obtaining and a better Q (order quantity). I also have access to the price &amp;amp; cost of SKUs.&#xA;I assume a simple newsvendor isn't the right path forward, as D (demand) is highly uncertain (mean decreasing and std likely increasing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any recommendations of good pointers and/or practical examples to apply? I hope this is't too practical for this stackexchange.&lt;/p&gt;&#xA;" OwnerUserId="3488" LastActivityDate="2020-05-11T22:46:38.683" Title="Estimating optimal inventory in times of high uncertainty due to coronavirus" Tags="|inventory|demand-distribution|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4094" PostTypeId="2" ParentId="4093" CreationDate="2020-05-11T03:29:38.640" Score="4" Body="&lt;p&gt;This is indeed a newsvendor problem. The fact that D is very uncertain only makes it more so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we were in normal times, the standard approach would be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use your historical data to calculate &lt;span class=&quot;math-container&quot;&gt;$\hat{\mu}$&lt;/span&gt;, an estimate for the mean demand. (Sounds like &lt;span class=&quot;math-container&quot;&gt;$\hat{\mu} = 1.05[\text{last year's demand}]$&lt;/span&gt; is the go-to estimate for your relative.)&lt;/li&gt;&#xA;&lt;li&gt;If your historical data contains both forecasts and actuals, then calculate &lt;span class=&quot;math-container&quot;&gt;$\hat{\sigma}_e$&lt;/span&gt;, an estimate for the standard deviation of the &lt;em&gt;forecast error&lt;/em&gt; of the demand. If your historical data doesn't contain forecasts, then approximate &lt;span class=&quot;math-container&quot;&gt;$\hat{\sigma}_e$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$\hat{\sigma}$&lt;/span&gt;, the standard deviation of the observed demands.&lt;/li&gt;&#xA;&lt;li&gt;(The reason for using &lt;span class=&quot;math-container&quot;&gt;$\hat{\sigma}_e$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$\hat{\sigma}$&lt;/span&gt; is, roughly speaking, that it's not the volatility in the demand that requires us to hold safety stock, it's our inaccuracy in forecasting that volatility.)&lt;/li&gt;&#xA;&lt;li&gt;Set &#xA;&lt;span class=&quot;math-container&quot;&gt;$$Q = \hat{\mu} + z_\alpha\hat{\sigma}_e,$$&lt;/span&gt; &#xA;where &lt;span class=&quot;math-container&quot;&gt;$\alpha = p/(p+h)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is the stockout cost per unit, and &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; is the holding cost per unit. (Alternately, choose a service level &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; and use it directly.) &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But of course, these are not normal times. Your historical data will be unreliable at best, and either of your estimates &lt;span class=&quot;math-container&quot;&gt;$\hat{\mu}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\hat{\sigma}_e$&lt;/span&gt; will be subject to lots of inaccuracies. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess I've basically just restated your question. But maybe thinking about the problem in these terms—especially the point about &lt;span class=&quot;math-container&quot;&gt;$\hat{\sigma}_e$&lt;/span&gt;—will help structure your thoughts about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's very hard here is that in normal years, your relatively probably has &lt;span class=&quot;math-container&quot;&gt;$\mu \gg \sigma$&lt;/span&gt;, which means the newsvendor logic—basically the &lt;span class=&quot;math-container&quot;&gt;$z_\alpha\hat{\sigma}_e$&lt;/span&gt; term—adds a lot of value. Next year your relative's (and everybody else's) ability to estimate &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; is going to have inaccuracies that are larger than &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt;. So newsvendor logic might not be too useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I had to choose between (a) being given a solid estimate for &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;, but I had to order exactly &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;, or (b) using a rule-of-thumb to estimate &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;, but I was allowed to use newsvendor logic, I'd probably choose (a). It hurts me to say it, because I'm an inventory-theory afficionado, but it's hard to get around it this year.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-05-11T03:29:38.640" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4095" PostTypeId="1" AcceptedAnswerId="4100" CreationDate="2020-05-11T04:04:52.287" Score="2" ViewCount="144" Body="&lt;p&gt;The problem below aims to find to most optimal way to transport the fuel :&lt;/p&gt;&#xA;&lt;p&gt;A company Er must transport a type of fuel from its two refineries Ra and Rb to its two points of sale PV1 and PV2. The quantities that can be produced on sites A and B can reach a maximum of 100 and 20 units respectively, while the demand for PV1 and PV2 is 40 and 80 units respectively. The unit cost of transport from each factory to each point of sale is indicated in the table below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;        PV1        PV2  &#xA;Ra      3          4&#xA;Rb      1          3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The company wants to know how to transport the merchant produced while minimizing the total cost of transport.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Formulate this problem in the form of a linear program (P).&lt;/li&gt;&#xA;&lt;li&gt;Formulate the combined dual linear program.&lt;/li&gt;&#xA;&lt;li&gt;Give an economic interpretation of the dual and its variables.&lt;/li&gt;&#xA;&lt;li&gt;Solve by the simplex algorithm the LP (P).&lt;/li&gt;&#xA;&lt;li&gt;Solve by LP transport algorithm (P).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;The linear problem&lt;/strong&gt; can be found below as :&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad z=3\cdot X_{11}+4\cdot X_{12}+X_{21}+3\cdot X_{22}\\\text{s.t.}&amp;amp;\quad X_{11}+X_{12}=100\\&amp;amp;\quad X_{21}+X_{22}=20\\&amp;amp;\quad X_{11}+X_{21}=40\\&amp;amp;\quad X_{12}+X_{22}=80.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;The Question Part&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm doing well with the first three questions but I'm struggling with the 4th question, so far I have to solve the 4th question with the two-phase simplex algorithm due to its canonical form. I have found some resources on how to process with the two-phase simplex algorithm but I can't figure out how to apply it on my given example.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;NOTE :&#xA;Basically, the symbol &amp;quot;=&amp;quot; is either &amp;quot;&amp;gt;=&amp;quot; or &amp;quot;&amp;lt;=&amp;quot;; it depends on the demand and the offer, but to be able to work with the two-phase simplex method we make the demand equal to the offer – the teacher said so. This way all our constraints become equal, we can add artificial variables but I don't know how to proceed from here to solve this problem.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraints before to make them equal :&lt;/p&gt;&#xA;&lt;p&gt;Offer constraints :&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\quad X_{11}+X_{12}&amp;lt;=100\\ X_{21}+X_{22}&amp;lt;=20.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Demand constraints :&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\quad X_{11}+X_{21}&amp;gt;=40\\ X_{12}+X_{22}&amp;gt;=80.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3487" LastEditorUserId="279" LastEditDate="2020-09-20T15:29:48.103" LastActivityDate="2020-09-20T15:29:48.103" Title="Specific usecase of two-phase simplex algorithm" Tags="|optimization|linear-programming|simplex|dual-simplex|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4096" PostTypeId="2" ParentId="4071" CreationDate="2020-05-11T13:19:12.923" Score="1" Body="&lt;p&gt;You could use logical constraints instead of big M with hard coded 1000&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;range N=1..2;&#xA;range D=1..3;&#xA;&#xA;dvar boolean a1[N][D];&#xA;dvar int w[N][D] in -10..10;&#xA;&#xA;subject to&#xA;{&#xA;// a1[N][D] to be 1, when w[N][D] &amp;lt;=0, 0 otherwise&#xA;forall(n in N,d in D) a1[n][d]==(w[n][n] &amp;lt;=0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-05-11T13:19:12.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4097" PostTypeId="1" AcceptedAnswerId="4110" CreationDate="2020-05-11T14:52:55.610" Score="2" ViewCount="144" Body="&lt;p&gt;I need to solve an LP-relaxation of an airline crew pairing optimization problem (CPOP). The problem formulation is a modified SCP and is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Primal of the CPOP:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_{j=1}^{P} c_j x_j +\sum_{i=1}^{F}\left(\sum_{j=1}^{P}  a_{ij} x_{j} - 1 \right)\times P_{Dhd}\\\text{s.t.}&amp;amp;\quad \sum_{j=1}^{P} a_{ij} x_{j} \geq 1,~~~~\forall i \in \{1,2,...,F\}\\&amp;amp;\quad x_j \in [0, 1],~~~~~~\forall j \in \{1,2,...,P\}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;: size of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$|\mathcal{P}|$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt;: size of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{F}$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$|\mathcal{F}|$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt;: cost of a pairing &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P_{Dhd}$&lt;/span&gt;: pre-defined parameter which penalizes the number of deadhead flights in the solution;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if flight &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; is covered in pairing &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt; and is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; is a relaxed binary decision variable which represents the fractional-contribution of a pairing &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt; in the corresponding LP-solution.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;I have formulated the following dual for the above primal:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad\sum_{i=1}^{F} y_i\\\text{s.t.}&amp;amp;\quad\sum_{i=1}^{F} a_{ij} y_i \leq c_j + P_{Dhd} \times \left( \sum_{i=1}^{F} \left(a_{ij} - nd_{ij}\right) \right),~~~~\forall j \in \{1,2,...,P\}\\&amp;amp;\quad\sum_{j=1}^{P} nd_{ij} = 1,~~~~~~~~\forall i \in \{1,2,...,F\}\\&amp;amp;\quad y_i \in \mathbb{R}_{\geq 0},~~~\forall i \in \{1,2,...,F\}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$nd_{ij}$&lt;/span&gt;: binary auxiliary variable which is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if flight &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; is not a deadhead flight in pairing &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt; and is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;: dual variable which represents a shadow price to cover flight &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; in the respective manner.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is the above dual correct?&#xA;Is it right to introduce new binary variables (such as &lt;span class=&quot;math-container&quot;&gt;$nd_{ij}$&lt;/span&gt; in this case) and constraints for them while formulating dual from primal?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="2999" LastEditorUserId="123" LastEditDate="2021-05-01T09:40:36.753" LastActivityDate="2021-05-01T09:40:36.753" Title="On dual-formulation of a given primal for a set-covering problem" Tags="|linear-programming|duality|set-covering|dual|primal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4098" PostTypeId="1" CreationDate="2020-05-11T15:23:12.327" Score="1" ViewCount="272" Body="&lt;p&gt;I have an optimization model that I have developed within the PYOMO framework and I am unable to solve the model in a reasonable amount of time using the BARON solver. I have been instructed not to use heuristic methods to solve the problem and instead &quot;simulate&quot; the system of equations by using pre-assigned values for the control variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to solve the system of equations that I have right now, with no optimization, but by still using the equations created in PYOMO. The way that I thought about doing this initially was to assign the objective function value to 0 and then by sending the system to the BARON solver, the various constraints would themselves solve to a given value depending on the inputs I have assigned. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To summarize, I want to use the equations that I have coded in PYOMO to numerically solve a system of equations without doing any optimization. The problem that I have would essentially pre-assign values to the control variables and then let the constraints evolve. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am more interested in the variable values that result from the equations than I am in the optimal values. This method was communicated to me as &quot;simulation&quot;, but I am not sure if this is the appropriate terminology within OR.  &lt;/p&gt;&#xA;" OwnerUserId="547" LastEditorUserId="547" LastEditDate="2020-05-11T17:21:26.483" LastActivityDate="2020-05-11T18:09:12.073" Title="Model Simulation in PYOMO" Tags="|pyomo|simulation|baron|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4099" PostTypeId="1" AcceptedAnswerId="4104" CreationDate="2020-05-11T15:41:24.947" Score="4" ViewCount="125" Body="&lt;p&gt;I have come across the &lt;a href=&quot;https://arxiv.org/pdf/math/0212212.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt; that deals with spatial positioning of mobile sensors to optimally detect sound source, or position mobile cellphone towers to maximize the coverage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The region &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is partitioned into mutually exclusive &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; Voronoi polytopes &lt;span class=&quot;math-container&quot;&gt;$W=\{ W_1,..,W_n \}$&lt;/span&gt;. A function &lt;span class=&quot;math-container&quot;&gt;$\phi :Q \to \mathbb{R}_+$&lt;/span&gt; assigns probability density that a certain event (here sound source) has happened over &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;. There are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; sensors to be distributed &lt;span class=&quot;math-container&quot;&gt;$P=(p_1,..p_n)$&lt;/span&gt; over each Voronoi partition that satisfies the following equation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$H(P,W)=\min\sum_{i=1}^n \int_{W_i} f(\| q-p_i\|)\,d \phi(q)$$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quality of observation at point &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; from sensor &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; is the distance of the point &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; from the sensor &lt;span class=&quot;math-container&quot;&gt;$f(\| q-p_i\|)$&lt;/span&gt; which makes sense. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain why are we multiplying &lt;span class=&quot;math-container&quot;&gt;$(q)$&lt;/span&gt; after &lt;span class=&quot;math-container&quot;&gt;$d\phi$&lt;/span&gt; in the objective formula? &lt;/p&gt;&#xA;" OwnerUserId="3491" LastEditorUserId="123" LastEditDate="2020-05-11T19:14:19.303" LastActivityDate="2020-05-11T19:18:36.780" Title="Mobile Sensor Placement for Optimal Coverage" Tags="|optimization|facility-location|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4100" PostTypeId="2" ParentId="4095" CreationDate="2020-05-11T18:08:29.023" Score="3" Body="&lt;p&gt;The point of the 2-phase simplex is to find a feasible initial solution (a starting point for the &quot;normal&quot; simplex). Indeed finding a set of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; values that satisfy the constraints can be hard (manually). This is not a problem when you have constraints of the form &lt;span class=&quot;math-container&quot;&gt;$Ax\le b$&lt;/span&gt;, as &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; is a trivial possibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this you introduce one artificial variable per constraint :&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;X_{11}+X_{12} +a_1=100\\&#xA;&amp;amp;X_{21}+X_{22}+a_2=20\\&#xA;&amp;amp;X_{11}+X_{21}+a_3=40\\&amp;amp;&#xA; X_{12}+X_{22}+a_4=80&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you minimise &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^4 a_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it is easy to find an initial solution for this first phase: just set &lt;span class=&quot;math-container&quot;&gt;$X=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a_1=100$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a_2=20$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a_3=40$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a_4=80.$&lt;/span&gt; If you find an optimal solution with &lt;span class=&quot;math-container&quot;&gt;$a_1=a_2=a_3=a_4=0$&lt;/span&gt;, it means that you have found values of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; that satisfy your initial constraints. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then use these values of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; for phase &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; as a starting point. &lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-05-11T18:08:29.023" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4101" PostTypeId="2" ParentId="4098" CreationDate="2020-05-11T18:09:12.073" Score="1" Body="&lt;p&gt;By reading your edited question, I think you are trying to get feasible solutions(values for the variables that satisfy the system of equations). If it's true, you can simply fix the objective function and use BARON to get the values for the variables. In PYOMO:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.util.infeasible import log_infeasible_constraints&#xA;# ...your model M...&#xA;# ...Lines of your code...&#xA;# ...your solving step...&#xA;log_infeasible_constraints(M)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the above code will give you the list of constraints that cause the model infeasibility if there is any.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-05-11T18:09:12.073" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4102" PostTypeId="1" CreationDate="2020-05-11T18:27:00.613" Score="1" ViewCount="228" Body="&lt;p&gt;I can't get my head around how to implement different subproblems in a column generation procedure with only one master problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say the computer found a resource constraint shortest path for each unique subproblem at some iteration in the column generation procedure.&#xA;Then what? Should all shortest paths be added to the set of paths?&#xA;And when the path(s) is/are added to the restricted master problem, how does the computer know exactly which person/vehicle to allocate the path?&lt;/p&gt;&#xA;" OwnerUserId="3443" LastActivityDate="2020-05-11T19:16:00.733" Title="Column generation" Tags="|column-generation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4103" PostTypeId="2" ParentId="4102" CreationDate="2020-05-11T19:16:00.733" Score="2" Body="&lt;p&gt;Adding multiple columns (in your case, paths) with negative reduced costs instead of a single column with most negative reduced cost is called &lt;em&gt;multiple pricing&lt;/em&gt; and is useful in problems that require large-number of CG-iterations to achieve an exact/near-optimal LP-bound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover, you need to solve as many subproblems as you could possibly extract from the Dantzig-Wolfe decomposition of the LP-relaxation of the master problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it is not necessary that if a subproblem did not result in a new column (with negative reduced cost) in some CG-iteration then it won't be useful again in any subsequent CG-iteration. Check the &lt;a href=&quot;https://or.stackexchange.com/a/3429/2999&quot;&gt;answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the new paths are added to the RMP, the computer will allocate these paths to the person/vehicle according to the new primal-solution which you will get after solving the updated RMP.&lt;/p&gt;&#xA;" OwnerUserId="2999" LastActivityDate="2020-05-11T19:16:00.733" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4104" PostTypeId="2" ParentId="4099" CreationDate="2020-05-11T19:18:36.780" Score="5" Body="&lt;p&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; is a function of &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; so &lt;span class=&quot;math-container&quot;&gt;$d\phi(q)$&lt;/span&gt; is interpreted as w.r.t. &lt;span class=&quot;math-container&quot;&gt;$\phi(q)$&lt;/span&gt;, which is the same as &lt;span class=&quot;math-container&quot;&gt;$d\phi$&lt;/span&gt;. This is just shorthand for &lt;span class=&quot;math-container&quot;&gt;$\phi'(q)\,dq$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2020-05-11T19:18:36.780" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4105" PostTypeId="1" AcceptedAnswerId="4108" CreationDate="2020-05-11T20:40:24.710" Score="4" ViewCount="767" Body="&lt;p&gt;Suggest me some good books with implementation of heuristics using python to solve operations research problems&lt;/p&gt;&#xA;" OwnerUserId="2958" LastEditorUserId="39" LastEditDate="2020-05-11T21:57:50.050" LastActivityDate="2020-05-12T15:11:10.923" Title="Suggest me good books to learn heuristics to solve Operations Research problems using python" Tags="|linear-programming|python|reference-request|heuristics|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4106" PostTypeId="1" AcceptedAnswerId="4136" CreationDate="2020-05-11T21:10:29.690" Score="12" ViewCount="3361" Body="&lt;p&gt;&lt;a href=&quot;https://www.localsolver.com/&quot; rel=&quot;noreferrer&quot;&gt;LocalSolver&lt;/a&gt; is a company which provides a global optimization solver, combining exact and heuristic techniques.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.localsolver.com/benchmarks.html&quot; rel=&quot;noreferrer&quot;&gt;benchmarks&lt;/a&gt; on their website are quite impressive. For example, they claim they can solve large TSPs within 10 seconds with gaps smaller than 5% in average :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aK338.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aK338.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Does anyone have any experience with LocalSolver, and what are the pro's and con's ?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Are there any peer reviewed publications where these benchmarks can be found ? It would be interesting to see if there are any comparisons with heuristics and metaheuristics. Localsolver performs local search after all !&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-05-12T08:12:52.520" LastActivityDate="2024-04-04T04:41:01.370" Title="What are the pros and cons of LocalSolver?" Tags="|optimization|solver|literature-research|benchmark|user-experience|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4107" PostTypeId="1" AcceptedAnswerId="4109" CreationDate="2020-05-11T21:51:37.597" Score="1" ViewCount="105" Body="&lt;p&gt;I want to enforce the following ranges for a set of variables, where the ranges for each variable are discontinuous. For example, I have two sets of ranges for each variable,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\sf LB_1 &amp;amp;\le \sf variable\,1 \le UB1\\\sf LB_2 &amp;amp;\le\sf variable\,1 \le UB2\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\sf LB$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sf UB$&lt;/span&gt; are the lower and upper bounds respectively. As an example, for a variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, I have the following ranges&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}0&amp;amp;\le x \le 20\\31&amp;amp;\le x \le 59.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I can introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; and write the following constraint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$U\times{\sf LB_1}+(1-U)\times{\sf LB_2} \le x \le U\times\sf{UB_1}+(1-U)\times {\sf UB_2}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I have three ranges, where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; can be 0 or &lt;span class=&quot;math-container&quot;&gt;$2\le x\le 11$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$45\le x\le 79$&lt;/span&gt;, how do I write a constraint for three ranges for a single variable?&lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="123" LastEditDate="2020-05-12T07:41:06.447" LastActivityDate="2020-05-12T07:41:06.447" Title="Enforcing discontinuous range for a variable" Tags="|optimization|mixed-integer-programming|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4108" PostTypeId="2" ParentId="4105" CreationDate="2020-05-11T21:57:26.187" Score="2" Body="&lt;p&gt;Chapter 7 of the book called &lt;strong&gt;Artificial Intelligence with Python&lt;/strong&gt; by &lt;em&gt;Patreek Joshi&lt;/em&gt; focuses on the heuristic search methods. Other than that, the following list of references can be considered for more details on Metaheuristics:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Clever Algorithms: Nature-Inspired Programming Recipes (by Jason Brownlee)&lt;/li&gt;&#xA;&lt;li&gt;Essentials of Metaheuristics (by Sean Luke)&lt;/li&gt;&#xA;&lt;li&gt;Hands-On Genetic Algorithms with Python: Applying genetic algorithms to solve real-world deep learning and artificial intelligence problems (by Eyal Wirsansky).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also, there is an online course in Udemy: &lt;strong&gt;Optimization with Metaheuristics in Python&lt;/strong&gt; which covers some of the well-known metaheuristics such as, SA, GA, Tabu search, and Evolutionary strategies. I think this online course will be a good point to start.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-05-11T21:57:26.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4109" PostTypeId="2" ParentId="4107" CreationDate="2020-05-11T22:13:58.170" Score="5" Body="&lt;p&gt;Introduce three binary variables &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; and the following linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i u_i &amp;amp;= 1\\&#xA;0 u_1 + 2 u_2 + 45 u_3 \le x &amp;amp;\le 0 u_1 + 11 u_2 + 79 u_3&#xA;\end{align}&lt;/span&gt;&#xA;If you prefer, you can omit &lt;span class=&quot;math-container&quot;&gt;$u_1$&lt;/span&gt; and replace the first constraint with &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;u_2 + u_3 &amp;amp;\le 1\\&#xA;2 u_2 + 45 u_3 \le x &amp;amp;\le 11 u_2 + 79 u_3&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-05-11T22:24:46.203" LastActivityDate="2020-05-11T22:24:46.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4110" PostTypeId="2" ParentId="4097" CreationDate="2020-05-11T22:28:49.633" Score="3" Body="&lt;p&gt;It does not look correct, and in particular the dual of an LP is an LP, so it makes no sense to have a binary variable in the dual. I suspect what led you astray was a misunderstanding of the penalty portion of the primal objective. You can rewrite the primal objective as &lt;span class=&quot;math-container&quot;&gt;\begin{gather*}&#xA;\sum_{j=1}^{P}c_{j}x_{j}+P_{Dhd}\left[\sum_{i=1}^{F}\sum_{j=1}^{P}a_{ij}x_{j}-\sum_{i=1}^{F}1\right]\\&#xA;=\sum_{j=1}^{P}\left(c_{j}+P_{Dhd}\sum_{i=1}^{F}a_{ij}\right)x_{j}-F\times P_{Dhd}.&#xA;\end{gather*}&lt;/span&gt;The last term is a constant term and can be ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meanwhile, you need to account for the dual variable (call it &lt;span class=&quot;math-container&quot;&gt;$z_j$&lt;/span&gt;) of the upper bound (1) for &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt;. If you rewrite the primal to include &lt;span class=&quot;math-container&quot;&gt;$-x_j \ge -1 \, \forall j$&lt;/span&gt; and make the domain of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; just &lt;span class=&quot;math-container&quot;&gt;$x\ge 0$&lt;/span&gt;, you'll see that the dual constraints should be &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^F a_{ij} y_i - z_j \le c_j + P_{Dhd} \sum_{i=1}^F a_{ij} \quad \forall j$$&lt;/span&gt;and the dual objective is &lt;span class=&quot;math-container&quot;&gt;$$\max \left(\sum_{i=1}^F y_i - \sum_{j=1}^P z_j\right).$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-11T22:28:49.633" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4111" PostTypeId="2" ParentId="4093" CreationDate="2020-05-11T22:46:38.683" Score="2" Body="&lt;p&gt;There are quite a few wrinkles here, specific to the current sources of uncertainty. Will the suppliers be giving discounts (to get orders after coming off a shutdown)? Discounts would reduce the risk of over-ordering. What normally happens with excess inventory (hold it, sell it at a discount, scrap or donate it, ...)? If they sell off the excess to a secondary market, will that market be there this coming year? Is this a luxury/optional purchase (swimwear) or a necessity (baby clothes ... I'm guessing not that, given the seasonality, but it's just an example). The answer relates to the issue of how much discretionary spending customers will do given the projected deep recession. How are stock-out costs calculated? If loss of customers to competitors is part of that calculation, will all the competitors be back and have inventory this time around?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the demand forecasting side, it might be possible to find industry-wide sales figures for similar goods (swimsuits, school uniforms, whatever this is) in the aftermath of previous economic downturns (the &quot;Great Depression&quot; here, the 2008 recession, ...). That data won't translate directly into forecasts, but it might provide an idea of how quickly sales of like items have bounced back in the past.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given all the uncertainty, and the unprecedented nature of the situation, I'm with Larry in doubting that the data is there to let a newsvendor model (let alone anything more complex) work well.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-11T22:46:38.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4112" PostTypeId="1" CreationDate="2020-05-11T22:56:07.607" Score="4" ViewCount="1148" Body="&lt;p&gt;It might be somewhat irrelevant to this forum but I think that many people here are familiar with this concept. I have seen that many papers assume that customers' valuation (&lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt;) is a monotone hazard rate (MHR) distribution, that is, the hazard rate &lt;span class=&quot;math-container&quot;&gt;$\frac{f(v)}{1-F(v)}$&lt;/span&gt; is non-decreasing in &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;. What does this assumption implicate from a business perspective? Moreover, what is the impact of this assumption on optimization procedures?&lt;/p&gt;&#xA;&lt;p&gt;Many papers in Revenue Management and Dynamic Pricing use hazard rate, but what does it mean in these contexts?&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="39" LastEditDate="2020-06-23T18:32:55.983" LastActivityDate="2020-09-04T13:07:47.950" Title="What is the meaning of monotone hazard rate (MHR) distribution?" Tags="|probability-distributions|terminology|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4113" PostTypeId="1" AcceptedAnswerId="4117" CreationDate="2020-05-12T06:29:12.840" Score="0" ViewCount="557" Body="&lt;p&gt;I want to enforce &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=x_{k,j}\implies z_i \neq z_k$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$k = i-1$&lt;/span&gt; so I used &lt;span class=&quot;math-container&quot;&gt;\begin{align}z_k + 1 - (x_{i,j} - x_{k,j})) \leq z_i \leq z_k - 1 - (x_{i,j} - x_{k,j})\quad\text{for each $j$}\end{align}&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is an integer variable where &lt;span class=&quot;math-container&quot;&gt;$x \in \{{0,1}\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is an integer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this on an example but I kept getting errors for the &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; values&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align} &#xA;x_{1,1} = 0,  &amp;amp;&amp;amp;x_{1,2} = 1,\\&#xA;x_{2,1} = 0, &amp;amp;&amp;amp;x_{2,2} = 1, \\&#xA;x_{3,1} = 1, &amp;amp;&amp;amp;x_{3,2} = 0, \\&#xA;x_{4,1} = 1, &amp;amp;&amp;amp;x_{4,2} = 0, \\&#xA;\text{and }&amp;amp;&amp;amp;1 \leq z\leq 2&#xA;\end{align}&lt;/span&gt;&#xA;so &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z_1 + 1 - (x_{2,1} - x_{1,1})) &amp;amp;\leq z_2 \leq z_1 - 1 - (x_{2,1} - x_{1,1})\\&#xA;z_1 + 1 - (x_{2,2} - x_{1,2})) &amp;amp;\leq z_2 \leq z_1 - 1 - (x_{2,2} - x_{1,2})\\&#xA;z_2 + 1 - (x_{3,1} - x_{2,1})) &amp;amp;\leq z_3 \leq z_2 - 1 - (x_{3,1} - x_{2,1})\\&#xA;z_2 + 1 - (x_{3,2} - x_{2,2})) &amp;amp;\leq z_3 \leq z_2 - 1 - (x_{3,2} - x_{2,2})\\&#xA;z_3 + 1 - (x_{4,1} - x_{3,1})) &amp;amp;\leq z_4 \leq z_3 - 1 - (x_{4,1} - x_{3,1})\\&#xA;z_3 + 1 - (x_{4,2} - x_{3,2})) &amp;amp;\leq z_4 \leq z_3 - 1 - (x_{4,2} - x_{3,2}).&#xA;\end{align}&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the error?&lt;/p&gt;&#xA;" OwnerUserId="3480" LastEditorUserId="500" LastEditDate="2020-05-12T14:10:10.860" LastActivityDate="2020-05-12T14:10:10.860" Title="Using big M values for a constraint" Tags="|mixed-integer-programming|modeling|constraint|combinatorial-optimization|big-m|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4114" PostTypeId="2" ParentId="4113" CreationDate="2020-05-12T07:23:03.390" Score="4" Body="&lt;p&gt;in CPLEX with all APIs you can use logical constraints that will help you to model that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dvar int x;&#xA;dvar int y;&#xA;dvar int z;&#xA;dvar int t;&#xA;&#xA;subject to&#xA;{&#xA;  (x==y) =&amp;gt; (z!=t);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;a href=&quot;https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OPL&lt;/a&gt; for instance. But you can write the same with C++, java, python ...&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-05-12T07:23:03.390" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4115" PostTypeId="1" CreationDate="2020-05-12T13:03:00.827" Score="1" ViewCount="60" Body="&lt;p&gt;I had a linear programming problem where I am optimizing some function &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f(x) = \sum_{j}x_jq_jp_j - \sum_{i}\left(\sum_{j}x_jq_jC_{ij} \right) c_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$q, p, C, c$&lt;/span&gt; are known.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I now want to extend this problem to something where my &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; vector depends on the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; vector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, I want to change the value of &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt; depending on the &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; and original &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt;. In particular, I want to do it in the following way. Let's take the example where:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x =  [1,0,1]^T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p=[30,20,50]^T$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, I would like my vector &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; to be altered using the following rule: redistribute the % lost in &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; following the multiplication with &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; over all other &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;. So in this case, because the second element of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is 0, I want to redistribute the 20/100 lost over the other &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$p_{new} = [36,0,60]$&lt;/span&gt; (the other elements became 20% higher)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure how to incorporate this logic into my linear programming problem.&lt;/p&gt;&#xA;" OwnerUserId="3065" LastEditorUserId="3065" LastEditDate="2020-05-12T19:37:16.417" LastActivityDate="2020-05-12T19:37:16.417" Title="Linear programming with correction term based on decision vector" Tags="|linear-programming|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4116" PostTypeId="2" ParentId="4113" CreationDate="2020-05-12T13:56:41.153" Score="1" Body="&lt;p&gt;Thank to Dr @RobPratt &#xA;I think the answer will be to introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$w_{i,j}$&lt;/span&gt; to indicate whether &lt;span class=&quot;math-container&quot;&gt;$z_i=j$&lt;/span&gt;. in other words to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j} = x_{k,j} \implies w_{i,j} + w_{k,j} = 1 $&lt;/span&gt; while &#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align} &#xA;\sum_j w_{i,j} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$}\\&#xA;\sum_j j w_{i,j} &amp;amp;= z_i &amp;amp;&amp;amp;\text{for all $i$}\\&#xA;\end{align}&lt;/span&gt; &lt;/p&gt;&#xA;" OwnerUserId="3480" LastEditorUserId="3480" LastEditDate="2020-05-12T14:02:53.653" LastActivityDate="2020-05-12T14:02:53.653" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="4117" PostTypeId="2" ParentId="4113" CreationDate="2020-05-12T13:57:04.843" Score="4" Body="&lt;p&gt;Introduce three binary variables &lt;span class=&quot;math-container&quot;&gt;$y_{i,k,s}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$s\in\{1,2,3\}$&lt;/span&gt;, to indicate whether &lt;span class=&quot;math-container&quot;&gt;$z_i &amp;lt; z_k$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z_i = z_k$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;$z_i &amp;gt; z_k$&lt;/span&gt;, respectively. The constraints are then:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_s y_{i,k,s} &amp;amp;= 1 \tag1 \\&#xA;z_i + 1 - z_k &amp;amp;\le M_1(1-y_{i,k,1}) \tag2 \\&#xA;-(1-y_{i,k,2}) \le x_{i,j} + x_{k,j} - 1 &amp;amp;\le 1-y_{i,k,2} \tag3\\&#xA;z_k + 1 - z_i &amp;amp;\le M_3(1-y_{i,k,3}) \tag4 &#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; selects one of the three cases.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y_{i,k,1} = 1 \implies z_i &amp;lt; z_k$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y_{i,k,2} = 1 \implies x_{i,j} + x_{k,j} = 1$&lt;/span&gt;, which is the same as &lt;span class=&quot;math-container&quot;&gt;$x_{i,j} \ne x_{k,j}$&lt;/span&gt; because &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is binary.  This is the contrapositive of your desired implication.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y_{i,k,3} = 1 \implies z_i &amp;gt; z_k$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-05-12T14:07:07.237" LastActivityDate="2020-05-12T14:07:07.237" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4118" PostTypeId="2" ParentId="4105" CreationDate="2020-05-12T15:06:01.077" Score="3" Body="&lt;p&gt;The book [burke2005search] provides a good starting points for different heuristics algorithms. Identify the techniques you need first. Most likely, you can find a reliable open source package.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;[burke2005search] Burke, E. K., &amp;amp; Kendall, G. (2005). Search methodologies (pp. 1-17). Springer Science+ Business Media, Incorporated.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3163" LastEditorUserId="3163" LastEditDate="2020-05-12T15:11:10.923" LastActivityDate="2020-05-12T15:11:10.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4119" PostTypeId="1" AcceptedAnswerId="4126" CreationDate="2020-05-12T18:41:18.003" Score="7" ViewCount="2916" Body="&lt;p&gt;I am working in an integer optimization problem. All of the decision variables are binary, and the objective is to minimize some cost function. I currently am implementing CBC, but I have been reading that there are some benefits that can come from implementing a CP-SAT solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My primary concern is that CP-SAT seems applicable to finding all feasible options, where as CBC is actually geared towards feasible and an objective. &lt;/p&gt;&#xA;" OwnerUserId="3486" LastEditorUserId="981" LastEditDate="2023-12-22T15:09:52.660" LastActivityDate="2023-12-22T15:09:52.660" Title="CP-SAT over CBC for MIP, is it worthwhile?" Tags="|or-tools|cp-sat|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4120" PostTypeId="2" ParentId="4119" CreationDate="2020-05-12T19:11:39.547" Score="7" Body="&lt;p&gt;CP solvers can find optimal solutions (given enough time and memory). Essentially, like the &quot;bound&quot; part of branch-and-bound, each time you find a feasible solution you redefine feasibility to include &quot;better than the incumbent&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whether you would be better off with a MIP approach or a CP approach depends a lot on the specific nature of your problem (and the merits of your respective MIP and CP solvers). CP solvers tend to include special purpose &quot;global constraints&quot;, such as &quot;all-different&quot; (no two variables in a group take the same value) or &quot;nonoverlap&quot; (two intervals, such as running times for jobs, do not overlap). In my limited experience, the more your problem contains features that can be modeled by those global constraints, the more likely you are to benefit from switching to CP. With a scheduling problem, I would take a serious look at CP. With a set covering problem, I'm not so sure. &lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-12T19:11:39.547" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4121" PostTypeId="1" AcceptedAnswerId="4125" CreationDate="2020-05-12T19:26:47.950" Score="4" ViewCount="77" Body="&lt;p&gt;I am trying to understand the (Q,R) inventory policy with a type 1 service level and demand and lead time modelled as normal distributions. As far as I have understood, the assumption is that the quantity Q that we order is completely delivered when the order arrives, i.e., no allowance is made for defective products or disruptions from the supplier's side. The policy inherently assumes that an order can be placed whenever the reorder point is reached and a quantity Q will be delivered after a certain lead time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there models or case studies for calculating safety stock that take into account supplier-induced disruptions such as defective batches or probability of failure of manufacturing equipment?&lt;/p&gt;&#xA;" OwnerUserId="3458" LastActivityDate="2020-05-12T20:33:59.917" Title="(Q,R) inventory policy with supplier disruptions" Tags="|inventory|rq-inventory-model|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4122" PostTypeId="1" AcceptedAnswerId="4123" CreationDate="2020-05-12T19:30:31.453" Score="3" ViewCount="438" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$x_{1},x_{2}, \cdots ,x_{n}$&lt;/span&gt; are binaries. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to model the following: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;IF &lt;span class=&quot;math-container&quot;&gt;$x_{1} + x_{2}+ \cdots +x_{n} \ge 2$&lt;/span&gt; THEN &lt;span class=&quot;math-container&quot;&gt;$x_{1} + x_{2} = 2$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;IF &lt;span class=&quot;math-container&quot;&gt;$x_{1} + x_{2}+ \cdots +x_{n} \ge 3$&lt;/span&gt; THEN &lt;span class=&quot;math-container&quot;&gt;$x_{1} + x_{2} + x_{3}= 3$&lt;/span&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and so on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way than asking for the following &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(x_{1} \ge 1) \lor (x_{1} + x_{2} \ge 2) \lor (x_{1} + x_{2} + x_{3} \ge 3) \cdots $&lt;/span&gt;, which then requires the introduction of additional binaries? &lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="8" LastEditDate="2020-05-13T08:06:55.130" LastActivityDate="2020-05-13T08:06:55.130" Title="Modeling the sum of binary variables" Tags="|mixed-integer-programming|modeling|binary-variable|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4123" PostTypeId="2" ParentId="4122" CreationDate="2020-05-12T19:50:58.360" Score="5" Body="&lt;p&gt;Does &lt;span class=&quot;math-container&quot;&gt;$x_i \ge x_{i+1}$&lt;/span&gt; do what you want?&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-05-12T19:50:58.360" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4124" PostTypeId="1" CreationDate="2020-05-12T20:33:44.453" Score="4" ViewCount="260" Body="&lt;p&gt;I have a project that requires programming code for the simplex algorithm and criss-cross algorithm. The purpose of this project is to compare the two methods. I've tried to find it, but the programming code for the criss-cross algorithm is very difficult to find. Maybe someone can help me find the source or someone already has it. Or if you have another source that has it, please simply drop the link below. I'll use the programming code to solve linear programming problems. Any program doesn't matter as long as it can solve the problem of the linear program. Thank you very much. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For those who don't know about the Criss Cross algorithm I'm referring to, you can visit this link &lt;a href=&quot;https://en.wikipedia.org/wiki/Criss-cross_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Criss-cross_algorithm&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3495" LastEditorUserId="3495" LastEditDate="2020-05-15T12:31:13.460" LastActivityDate="2020-05-15T12:31:13.460" Title="Does anyone have the criss cross algorithm programming code to solve linear programming problems?" Tags="|linear-programming|python|algorithms|simplex|matlab|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4125" PostTypeId="2" ParentId="4121" CreationDate="2020-05-12T20:33:59.917" Score="4" Body="&lt;p&gt;Yes, there are such models. On (Q,R) specifically, see &lt;a href=&quot;https://doi.org/10.1080/03155986.1996.11732293&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gupta (1996)&lt;/a&gt;, &lt;a href=&quot;https://doi.org/10.1016/S0377-2217(96)00165-8&quot; rel=&quot;nofollow noreferrer&quot;&gt;Parlar (1997)&lt;/a&gt;, &lt;a href=&quot;https://doi.org/10.1016/S0305-0548(01)00108-3&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mohebbi (2003)&lt;/a&gt;, and others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many papers on other inventory models (not necessarily (Q,R)) under disruptions. My students and I wrote a literature review paper on these and other supply chain models with disruptions; see &lt;a href=&quot;https://doi.org/10.1080/0740817X.2015.1067735&quot; rel=&quot;nofollow noreferrer&quot;&gt;Snyder, et al. (2016)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that these &quot;disruption&quot; models are different from stochastic lead times, which you mention in your question. But I think this is what your question is asking for.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-05-12T20:33:59.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4126" PostTypeId="2" ParentId="4119" CreationDate="2020-05-12T21:29:01.330" Score="8" Body="&lt;p&gt;CP-SAT is a full fledged (non-mixed) integer programming solver (linear relaxation, presolve, cuts, branching heuristics). It is geared towards optimization, and is actually not very good at enumerating all feasible solution, compared to a tree search based CP solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also a CP solver, and a damn good one, and a SAT solver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In our tests, it is on average better than CBC and on par with SCIP on pure integer problems. Still, it misses a few advanced techniques (like tuning how to best use implied bounds in some MIR cuts), and maybe one or two variations on presolve. This translates into CP-SAT being worse that SCIP on a minority of problems, while it is consistently faster on a majority of them).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the best answer is that you should try. Make sure that you use 8 threads when using CP-SAT for improved performance.&lt;/p&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2020-05-13T08:30:27.647" LastActivityDate="2020-05-13T08:30:27.647" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4127" PostTypeId="1" AcceptedAnswerId="4130" CreationDate="2020-05-13T00:40:03.333" Score="9" ViewCount="2255" Body="&lt;p&gt;I have a problem that I have already posted elsewhere in OR.stack, but the question is focused around a large binary MILP (about 1 million decision variables). Ultimately, I am more time constrained than optimality constrained. I have an academic version of gurobi and it is able to provide feasible, good enough solutions quite fast (a few minutes). I am looking for a solver that I can use in python that will return the best solution once it hits a max time limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been using google ORtools with the CBC and SAT integer solvers, but any time I try to invoke a time limit it starts solving and then either ignores the time limit or when it hits, because it hasn’t found the “optimal” solution it returns no solution.&lt;/p&gt;&#xA;" OwnerUserId="3486" LastEditorUserId="981" LastEditDate="2023-03-04T00:16:18.167" LastActivityDate="2023-03-04T00:16:18.167" Title="Open source MILP solver for quick “good enough” solution" Tags="|optimization|mixed-integer-programming|python|integer-programming|or-tools|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="4128" PostTypeId="1" AcceptedAnswerId="4129" CreationDate="2020-05-13T06:25:01.893" Score="7" ViewCount="4494" Body="&lt;p&gt;I am trying to solve a valued n-queens problem, in which queens in black squares worth double of those in white squares.&#xA;I solved it in AMPL just fine, but I would like to try that in Python using a different approach. I tried to simplify that by using a variable &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; in an if statement, such that if &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is odd then 1 (white square) and if &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is even then &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; (black square) (Obs: &lt;span class=&quot;math-container&quot;&gt;$k = N - i - j$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is the size of the chessboard, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; represents rows and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; represents columns). However I am getting this error: Non-constant expressions cannot be multiplied&quot;. I understand where the problem is but do not know how to overcome it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Objective function &#xA;&lt;span class=&quot;math-container&quot;&gt;$$ &#xA;\max z = \sum x_{ij} w_{ij} &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Subject to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 queen per row&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum x_{ij} = 1 \; \forall  j \; \{j \in \mathbb{N}, j \leq 8 \} $$&lt;/span&gt; &#xA;1 queen per column&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum x_{ij} = 1 \; \forall  i \; \{i \in \mathbb{N}, i \leq 8 \} $$&lt;/span&gt; &#xA;1 queen per diagonal type 1 &#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum x_{ij} \leq 1 \; \forall k \; \{ k=i+j | k \in \mathbb{N}, k &amp;lt; 16 \} $$&lt;/span&gt; &#xA;1 queen per diagonal type 2&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum x_{ij} \leq 1 \; \forall k \; \{ k=i-j | k \in \mathbb{Z}, -7 &amp;lt; k &amp;lt; 7 \} $$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_{ij} \in \{0,1\} $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import *&#xA;N = 8&#xA;nums = list(range(1, N+1)) #list from 1 to N&quot;,&#xA;numsC = list(range(1, N+1)) #list from 1 to N&quot;,&#xA;numsL = list(range(1, N+1)) #list from 1 to N&quot;,&#xA;&#xA;vars = {}&#xA;r = {}&#xA;&#xA;model = LpProblem('Damas', LpMaximize)&#xA;&#xA;# Decison Variables&#xA;for i in nums:&#xA;    for j in nums: # create a binary variable&#xA;        vars[i, j] = LpVariable('x{},{}'.format(i, j), cat='Binary')&#xA;&#xA;for i in numsC:&#xA;    for j in numsL:&#xA;        k = N - i - j&#xA;        if k % 2 == 0:&#xA;            r[i,j] = 2&#xA;            r[i, j] = LpVariable('r', 'LowBound=0', cat='Integer')&#xA;        else:&#xA;            r[i,j] = 1&#xA;            r[i,j] = LpVariable('r','LowBound=0', cat='Integer')&#xA;&#xA;# Objective function&#xA;model += sum(vars[i, j] for i in nums for j in nums) * sum(r[i,j] for i in numsC for j in numsL)&#xA;&#xA;# Restrições&#xA;# 1 queen per row&#xA;for i in nums:&#xA;    model += sum(vars[i, j] for j in nums) &amp;lt;= 1&#xA;# 1 queen per column&#xA;for j in nums:&#xA;    model += sum(vars[i, j] for i in nums) &amp;lt;= 1&#xA;# 1 queen per diagonal 1&#xA;for k in range(2, 2*N+1):&#xA;    model += sum(vars[i, j] for i in nums for j in nums if i+j == k) &amp;lt;= 1&#xA;# 1 queen per diagonal 2&#xA;for k in range(-(N-2),(N-2)+1):&#xA;    model += sum(vars[i, j] for i in nums for j in nums if i-j == k) &amp;lt;= 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3381" LastEditorUserId="85" LastEditDate="2020-05-13T10:40:14.967" LastActivityDate="2020-05-15T02:02:31.993" Title="Non-constant expressions cannot be multiplied" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4129" PostTypeId="2" ParentId="4128" CreationDate="2020-05-13T10:23:05.403" Score="5" Body="&lt;p&gt;Here are some problems in your code:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I don't think you need &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;r[i, j] = LpVariable('r', 'LowBound=0', cat='Integer')&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;in your code. &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; has been defined to be either &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; in the line above. &lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Also, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model += sum(vars[i, j] for i in nums for j in nums) * sum(r[i,j] for i in numsC for j in numsL&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;is not correct, you are performing the sum separately and then multiplied them together. Try the following list comprehension. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sum(vars[i, j] * r[i,j] for i in nums for j in nums)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have fixed your code, I will leave the final formatting to you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import *&#xA;N = 8&#xA;nums = list(range(1, N+1)) #list from 1 to N&quot;,&#xA;numsC = list(range(1, N+1)) #list from 1 to N&quot;,&#xA;numsL = list(range(1, N+1)) #list from 1 to N&quot;,&#xA;&#xA;vars = {}&#xA;r = {}&#xA;&#xA;model = LpProblem('Damas', LpMaximize)&#xA;&#xA;# Decison Variables&#xA;for i in nums:&#xA;    for j in nums: # create a binary variable&#xA;        vars[i, j] = LpVariable('x{},{}'.format(i, j), cat='Binary')&#xA;&#xA;for i in numsC:&#xA;    for j in numsL:&#xA;        k = N - i - j&#xA;        if k % 2 == 0:&#xA;            r[i,j] = 2&#xA;        else:&#xA;            r[i,j] = 1&#xA;&#xA;# Objective function&#xA;model += sum(vars[i, j] * r[i,j] for i in nums for j in nums) &#xA;&#xA;# Restrições&#xA;# 1 queen per row&#xA;for i in nums:&#xA;    model += sum(vars[i, j] for j in nums) &amp;lt;= 1&#xA;# 1 queen per column&#xA;for j in nums:&#xA;    model += sum(vars[i, j] for i in nums) &amp;lt;= 1&#xA;# 1 queen per diagonal 1&#xA;for k in range(2, 2*N+1):&#xA;    model += sum(vars[i, j] for i in nums for j in nums if i+j == k) &amp;lt;= 1&#xA;# 1 queen per diagonal 2&#xA;for k in range(-(N-2),(N-2)+1):&#xA;    model += sum(vars[i, j] for i in nums for j in nums if i-j == k) &amp;lt;= 1&#xA;&#xA;model.solve()&#xA;for variable in model.variables():&#xA;    print(&quot;{} = {}&quot;.format(variable.name, variable.varValue))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="85" LastEditorUserId="85" LastEditDate="2020-05-15T02:02:31.993" LastActivityDate="2020-05-15T02:02:31.993" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4130" PostTypeId="2" ParentId="4127" CreationDate="2020-05-13T10:39:26.063" Score="8" Body="&lt;p&gt;When I use CBC from time to time, it returns the best solution it has found even if it runs into the time limit. I guess, in your case, it has not even found a feasible solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I call it this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cbc file.lp sec 600 solve printi csv solu mysolution.csv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On difficult binary problems, I had some success enabling zero-half cuts or adding more cuts then by default. Have you tried that?&lt;/p&gt;&#xA;" OwnerUserId="3501" LastActivityDate="2020-05-13T10:39:26.063" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4131" PostTypeId="2" ParentId="4127" CreationDate="2020-05-13T10:52:08.523" Score="7" Body="&lt;p&gt;Interestingly enough, one of the best source-open (!= open source) solvers is often overlooked: SCIP (download &lt;a href=&quot;https://scip.zib.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;); there is a Python interface (&lt;a href=&quot;https://github.com/SCIP-Interfaces/PySCIPOpt&quot; rel=&quot;nofollow noreferrer&quot;&gt;PySCIPOpt&lt;/a&gt;), too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The parameter you need is &lt;code&gt;limits/time&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt;: right, SCIP comes with a license and is not entirely free. AFAIK, the price tag is small when you use it commercially, the revenues are used mainly to directly support and sustain the research and development. &lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="354" LastEditDate="2020-05-14T07:49:36.287" LastActivityDate="2020-05-14T07:49:36.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4132" PostTypeId="1" AcceptedAnswerId="4133" CreationDate="2020-05-13T11:32:08.973" Score="3" ViewCount="574" Body="&lt;p&gt;How can I formulate the following conditional constraint to a linear constraint using indicator variables? Please note that all variables are continuous and &lt;span class=&quot;math-container&quot;&gt;$c \ge 0$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{1: if} \ c=0 \ \&amp;amp; \ w \geq 0 \quad \text{then} \; u=w; d=0\\&#xA;\text{2: if} \ c=0 \ \&amp;amp; \ w &amp;lt; 0 \quad \text{then} \; u=0; d=0\\&#xA;\text{3: if} \ c &amp;gt; 0 \ \&amp;amp; \ w \geq c \quad \text{then} \ u=w-c; d=0 \\&#xA;\text{4: if} \ c&amp;gt;0 \ \&amp;amp; \ w&amp;lt;c \quad \text{then} \ d=0, d=c-w\\$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The decision variables d and u are directly appeared with a negative and positive coefficients in the objective function. Also, the abs of coefficient d is greater than the coefficient of u &lt;span class=&quot;math-container&quot;&gt;$(e.g.  -40 d + 30 u)$&lt;/span&gt;.   Therefore, the following constraint satisfies conditions 1,3 and 4. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c-w - d + u = 0;\\&#xA;c, d, u \geq 0;\\$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nevertheless, I am still wonder how to include condition 2 as a linear constraint in my model.&lt;/p&gt;&#xA;" OwnerUserId="3500" LastEditorUserId="3500" LastEditDate="2020-05-13T15:31:32.867" LastActivityDate="2020-05-13T19:46:44.220" Title="How to fomulate the following conditional constraint in MILP?" Tags="|mixed-integer-programming|linearization|big-m|logical-constraints|indicator-constraints|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4133" PostTypeId="2" ParentId="4132" CreationDate="2020-05-13T15:28:02.343" Score="5" Body="&lt;p&gt;Here's a big-M formulation that does not depend on the objective.  (Minimization with positive objective coefficients for &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; could be exploited, but you don't have that here.)  Let &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; be a small tolerance for positivity of &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.  Let &lt;span class=&quot;math-container&quot;&gt;$\underline{c}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\overline{c}$&lt;/span&gt; be bounds for &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, with similar notation for &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$c&amp;gt;0$&lt;/span&gt;, and let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$c&amp;gt;w$&lt;/span&gt;.  The constraints are:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\epsilon x \le c &amp;amp;\le \overline{c} x \\&#xA;0 \le d &amp;amp;\le \overline{d} x \\&#xA;c-w &amp;amp;\le (\overline{c}-\underline{w}) y \\&#xA;0 \le u - (w-c) &amp;amp;\le (0-\underline{w}+\overline{c})y \\&#xA;0 \le d &amp;amp;\le \overline{d} y \\&#xA;w-c &amp;amp;\le (\overline{w}-\underline{c})(1-y) \\&#xA;0 \le u &amp;amp;\le \overline{u} (1-y) \\&#xA;(0-\overline{c}+\underline{w})(2-x-y) \le d - (c-w) &amp;amp;\le (0-\underline{c}+\overline{w})(2-x-y)&#xA;\end{align}&lt;/span&gt;&#xA;Just check the four cases for &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-05-13T19:46:44.220" LastActivityDate="2020-05-13T19:46:44.220" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4134" PostTypeId="2" ParentId="4127" CreationDate="2020-05-13T16:52:02.897" Score="3" Body="&lt;p&gt;Depending on your time window, you could try compiling and running CBC in threaded mode. Time is key here because although CBC is many times faster in threaded mode, it takes forever to initialize each new thread, especially for problems that size. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your time window is enough to account for the generation overhead, CBC could do the trick. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be honest, however, once we start going to 1m+ variables, that's really pushing the limits of what open source is capable of.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-05-13T16:52:02.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4135" PostTypeId="1" CreationDate="2020-05-13T18:50:20.783" Score="0" ViewCount="2916" Body="&lt;p&gt;I was going through the course contents of Optimization with Metaheuristics in Python in udemy , where they have solved a quadratic assignment problem using Simulated annealing in python , i was trying to implement the same concept for a knapsack problem I couldnot do it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;from matplotlib import pyplot as plt&#xA;import pandas as pd&#xA;&#xA;Dist = pd.DataFrame([[0,1,2,3,1,2,3,4],[1,0,1,2,2,1,2,3],[2,1,0,1,3,2,1,2],&#xA;                      [3,2,1,0,4,3,2,1],[1,2,3,4,0,1,2,3],[2,1,2,3,1,0,1,2],&#xA;                      [3,2,1,2,2,1,0,1],[4,3,2,1,3,2,1,0]],&#xA;                    columns=[&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;,&quot;E&quot;,&quot;F&quot;,&quot;G&quot;,&quot;H&quot;],&#xA;                    index=[&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;,&quot;E&quot;,&quot;F&quot;,&quot;G&quot;,&quot;H&quot;])&#xA;&#xA;Flow = pd.DataFrame([[0,5,2,4,1,0,0,6],[5,0,3,0,2,2,2,0],[2,3,0,0,0,0,0,5],&#xA;                      [4,0,0,0,5,2,2,10],[1,2,0,5,0,10,0,0],[0,2,0,2,10,0,5,1],&#xA;                      [0,2,0,2,0,5,0,10],[6,0,5,10,0,1,10,0]],&#xA;                    columns=[&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;,&quot;E&quot;,&quot;F&quot;,&quot;G&quot;,&quot;H&quot;],&#xA;                    index=[&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;,&quot;E&quot;,&quot;F&quot;,&quot;G&quot;,&quot;H&quot;])&#xA;&#xA;&#xA;T0 = 1500&#xA;M = 250&#xA;N = 20&#xA;alpha = 0.9&#xA;&#xA;X0 = [&quot;B&quot;,&quot;D&quot;,&quot;A&quot;,&quot;E&quot;,&quot;C&quot;,&quot;F&quot;,&quot;G&quot;,&quot;H&quot;]&#xA;&#xA;&#xA;# Make a dataframe of the initial solution&#xA;&#xA;New_Dist_DF = Dist.reindex(columns=X0, index=X0)&#xA;New_Dist_Arr = np.array(New_Dist_DF)&#xA;&#xA;&#xA;# Make a dataframe of the cost of the initial solution&#xA;&#xA;Objfun1_start = pd.DataFrame(New_Dist_Arr*Flow)&#xA;Objfun1_start_Arr = np.array(Objfun1_start)&#xA;&#xA;&#xA;sum_start = sum(sum(Objfun1_start_Arr))&#xA;&#xA;print(sum_start)&#xA;&#xA;&#xA;Temp = []&#xA;Min_Cost = []&#xA;&#xA;for i in range(M):&#xA;    for j in range(N):&#xA;        ran_1 = np.random.randint(0,len(X0))&#xA;        ran_2 = np.random.randint(0,len(X0))&#xA;&#xA;        while ran_1==ran_2:&#xA;            ran_2 = np.random.randint(0,len(X0))&#xA;&#xA;        xt = []&#xA;        xf = []&#xA;&#xA;        # [&quot;B&quot;,&quot;D&quot;,&quot;A&quot;,&quot;E&quot;,&quot;C&quot;,&quot;F&quot;,&quot;G&quot;,&quot;H&quot;]&#xA;&#xA;&#xA;        A1 = X0[ran_1]&#xA;        A2 = X0[ran_2]&#xA;&#xA;        # Make a new list of the new set of departments&#xA;&#xA;        w = 0&#xA;        for i in X0:&#xA;            if X0[w]==A1:&#xA;                xt = np.append(xt,A2)&#xA;            elif X0[w]==A2:&#xA;                xt = np.append(xt,A1)&#xA;            else:&#xA;                xt=np.append(xt,X0[w])&#xA;            w = w+1&#xA;&#xA;&#xA;&#xA;        new_dis_df_init = Dist.reindex(columns=X0, index=X0)&#xA;        new_dis_init_arr = np.array(new_dis_df_init)&#xA;&#xA;&#xA;        new_dis_df_new = Dist.reindex(columns=xt, index=xt)&#xA;        new_dis_new_arr = np.array(new_dis_df_new)&#xA;&#xA;&#xA;        # Make a adatframe of the current solution&#xA;        objfun_init = pd.DataFrame(new_dis_init_arr*Flow)&#xA;        objfun_init_arr = np.array(objfun_init)&#xA;&#xA;        # Make a adatframe of the new solution&#xA;        objfun_new = pd.DataFrame(new_dis_new_arr*Flow)&#xA;        objfun_new_arr = np.array(objfun_new)&#xA;&#xA;        sum_init = sum(sum(objfun_init_arr))&#xA;        sum_new = sum(sum(objfun_new_arr))&#xA;&#xA;        rand1 = np.random.rand()&#xA;        form = 1/(np.exp(sum_new-sum_init)/T0)&#xA;&#xA;        if sum_new&amp;lt;=sum_init:&#xA;            X0=xt&#xA;        elif rand1&amp;lt;=form:&#xA;            X0=xt&#xA;        else:&#xA;            X0=X0&#xA;&#xA;    Temp.append(T0)&#xA;    Min_Cost.append(sum_init)&#xA;&#xA;    T0 = alpha*T0&#xA;&#xA;print()&#xA;print(&quot;Final Solution:&quot;,X0)&#xA;print(&quot;Minimized Cost:&quot;,sum_init)&#xA;&#xA;&#xA;plt.plot(Temp,Min_Cost)&#xA;plt.title(&quot;Cost vs. Temp.&quot;, fontsize=20,fontweight='bold')&#xA;plt.xlabel(&quot;Temp.&quot;, fontsize=18,fontweight='bold')&#xA;plt.ylabel(&quot;Cost&quot;, fontsize=18,fontweight='bold')&#xA;plt.xlim(1500,0)&#xA;&#xA;plt.xticks(np.arange(min(Temp),max(Temp),100),fontweight='bold')&#xA;plt.yticks(fontweight='bold')&#xA;plt.show()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;how to use this code for a knapsack problem where v is a list of value of items , w being list of weights and k value be the capacity of knapsack, i have tried the following code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;from matplotlib import pyplot as plt&#xA;import pandas as pd&#xA;v=[1945,321,2945,4136,1107,1022,1101,2890,962,1060,805,689,1513,3878,13504,1865,667,1833,16553]&#xA;w= [4990.0 ,1142.0, 7390.0, 10372.0 ,3114.0, 2744.0, 3102.0, 7280.0, 2624.0, 3020.0, 2310.0, 2078.0, 3926.0, 9656.0, 32708.0, 4830.0, 2034.0, 4766.0, 40006.0]          &#xA;T0 = 1500&#xA;M = 250&#xA;N = 20&#xA;alpha = 0.9&#xA;k=31181&#xA;X0=[0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0]&#xA;&#xA;&#xA;&#xA;Objfun1_start=0&#xA;for i in range(0,19):&#xA;    Objfun1_start = (X0[i]*v[i])+Objfun1_start&#xA;    Objfun1_start_Arr = np.array(Objfun1_start)&#xA;&#xA;# Make a dataframe of the cost of the initial solution&#xA;&#xA;&#xA;&#xA;&#xA;sum_start = Objfun1_start_Arr&#xA;&#xA;print(sum_start)&#xA;&#xA;&#xA;Temp = []&#xA;Min_Cost = []&#xA;&#xA;for i in range(M):&#xA;    for j in range(N):&#xA;        ran_1 = np.random.randint(0,len(X0))&#xA;        ran_2 = np.random.randint(0,len(X0))&#xA;&#xA;        while ran_1==ran_2:&#xA;            ran_2 = np.random.randint(0,len(X0))&#xA;&#xA;        xt = []&#xA;        xf = []&#xA;&#xA;&#xA;&#xA;        A1 = X0[ran_1]&#xA;        A2 = X0[ran_2]&#xA;&#xA;        # Make a new list of the new set of departments&#xA;&#xA;        w = 0&#xA;        for i in X0:&#xA;            if X0[w]==A1:&#xA;                xt = np.append(xt,A2)&#xA;            elif X0[w]==A2:&#xA;                xt = np.append(xt,A1)&#xA;            else:&#xA;                xt=np.append(xt,X0[w])&#xA;            w = w+1&#xA;&#xA;&#xA;&#xA;        new_dis_df_init = v&#xA;        new_dis_init_arr = np.array(new_dis_df_init)&#xA;&#xA;&#xA;        new_dis_df_new = v&#xA;        new_dis_new_arr = np.array(new_dis_df_new)&#xA;&#xA;&#xA;        # Make a adatframe of the current solution&#xA;        for i in range(0,19):&#xA;&#xA;                objfun_init[i] = (v[i]*X0[i])&#xA;                objfun_init_arr = np.array(objfun_init)&#xA;&#xA;        # Make a adatframe of the new solution&#xA;        for i in range(0,19):&#xA;                objfun_new[i] = (v[i]*X0[i])&#xA;                objfun_new_arr = np.array(objfun_new)&#xA;&#xA;        sum_init = (objfun_init_arr)&#xA;        sum_new = (objfun_new_arr)&#xA;&#xA;        rand1 = np.random.rand()&#xA;        form = 1/(np.exp(sum_new-sum_init)/T0)&#xA;&#xA;        if sum_new.any()&amp;lt;=sum_init.any():&#xA;            X0=xt&#xA;        elif rand1&amp;lt;=form:&#xA;            X0=xt&#xA;        else:&#xA;            X0=X0&#xA;&#xA;    Temp.append(T0)&#xA;    Min_Cost.append(sum_init)&#xA;&#xA;    T0 = alpha*T0&#xA;&#xA;print()&#xA;print(&quot;Final Solution:&quot;,X0)&#xA;print(&quot;maximum value:&quot;,sum_init)&#xA;&#xA;&#xA;plt.plot(Temp,Min_Cost)&#xA;plt.title(&quot;value vs. Temp.&quot;, fontsize=20,fontweight='bold')&#xA;plt.xlabel(&quot;value.&quot;, fontsize=18,fontweight='bold')&#xA;plt.ylabel(&quot;Cost&quot;, fontsize=18,fontweight='bold')&#xA;plt.xlim(1500,0)&#xA;&#xA;plt.xticks(np.arange(min(Temp),max(Temp),100),fontweight='bold')&#xA;plt.yticks(fontweight='bold')&#xA;plt.show()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2958" LastEditorUserId="2958" LastEditDate="2020-05-14T07:01:52.920" LastActivityDate="2020-05-14T11:12:15.590" Title="How to solve knapsack problem with simulated annealing?" Tags="|python|metaheuristics|knapsack|simulated-annealing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4136" PostTypeId="2" ParentId="4106" CreationDate="2020-05-13T22:18:07.693" Score="13" Body="&lt;p&gt;Here is a quick summary of the pros and cons of &lt;a href=&quot;https://www.hexaly.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hexaly (formerly LocalSolver)&lt;/a&gt;, a global optimization solver combining exact and heuristic techniques. Please note that this summary is written by the Hexaly team, as asked by &lt;a href=&quot;https://or.stackexchange.com/users/2556/kuifje&quot;&gt;Kuifje&lt;/a&gt; in the comment above.&lt;/p&gt;&#xA;&lt;p&gt;Pros:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You will model your problem using nonlinear and set-based mathematical modeling APIs. Then, your math model will be closer to the real-life problem, more concise, and easier to maintain. For an example of what &amp;quot;set-based modeling&amp;quot; means, have a look at the TSP model described &lt;a href=&quot;https://or.stackexchange.com/questions/3933/how-to-model-a-tsp-where-the-salesman-can-choose-between-flight-train-and-bus-f/3944#3944&quot;&gt;here&lt;/a&gt;. Hexaly also supports external functions in your model (black-box optimization) and offers multiobjective modeling features.&lt;/li&gt;&#xA;&lt;li&gt;Having modeled your problem for Hexaly, you will get solutions faster, and your model will be more scalable than MILP solvers, thanks to innovative heuristics. In addition, Hexaly offers (global) dual bounds.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Cons:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You must reformulate your problem by using the appropriate Hexaly modeling constructs and following Hexaly modeling best practices.&lt;/li&gt;&#xA;&lt;li&gt;Don't give MILP-like models to Hexaly, especially LP or MPS files, in hopes of getting good results.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;State-of-the-art MIP solvers remain better than Hexaly when solving pure linear problems and nearly linear problems (that is, problems that allow good linear approximations). Because the LP codes (simplex, interior-point) used inside these MIP solvers are still stronger than those inside Hexaly (note that we work hard to decrease this gap each year). This performance gap is noticeable for large-scale, ill-posed linear programs. Now, when problems become more combinatorial (in particular: routing, scheduling, packing, assignment) or more nonlinear/nonconvex/nonsmooth in the continuous space, Hexaly is a tool of choice that deserves to be considered for your optimization project.&lt;/p&gt;&#xA;&lt;p&gt;Additional non-technical strengths of Hexaly that our users mention: the dedicated and reactive support offered by the R&amp;amp;D team to model and solve at best your problems using Hexaly; an aggressive roadmap with two new releases per year with constant performance improvements and new features; a simple, competitive, flexible licensing &amp;amp; pricing.&lt;/p&gt;&#xA;&lt;p&gt;For examples of problems modeled using Hexaly, have a look at &lt;a href=&quot;https://www.hexaly.com/docs/last/exampletour/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.hexaly.com/docs/last/exampletour/index.html&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Check out &lt;a href=&quot;https://www.hexaly.com/benchmarks&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt; for some benchmarks against MIP solvers. You can reproduce the results in these benchmarks by &lt;a href=&quot;https://www.hexaly.com/registration&quot; rel=&quot;nofollow noreferrer&quot;&gt;registering&lt;/a&gt; and asking for free trial licenses on the Hexaly website.&lt;/p&gt;&#xA;&lt;p&gt;Note that the technical papers on Hexaly you can find online are largely outdated. We haven't published about Hexaly for several years (for evident confidentiality reasons).&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T04:41:01.370" LastActivityDate="2024-04-04T04:41:01.370" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4137" PostTypeId="1" CreationDate="2020-05-14T00:18:42.557" Score="4" ViewCount="618" Body="&lt;p&gt;I went through the &lt;a href=&quot;https://developers.google.com/optimization/routing/vrp&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vehicle Routing Problem&lt;/a&gt; example and was able to replicate it. On the example, there is a constraint added for vehicle maximum distance as shown below:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;dimension_name = 'Distance'&#xA;routing.AddDimension(&#xA;    transit_callback_index,&#xA;    0,  # no slack&#xA;    3000,  # vehicle maximum travel distance&#xA;    True,  # start cumul to zero&#xA;    dimension_name)&#xA;distance_dimension = routing.GetDimensionOrDie(dimension_name)&#xA;distance_dimension.SetGlobalSpanCostCoefficient(100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Similar to the &lt;a href=&quot;https://developers.google.com/optimization/routing/cvrp&quot; rel=&quot;nofollow noreferrer&quot;&gt;CVRP&lt;/a&gt;, how do I modify the constraint for the number of locations that each vehicle can visit (either global or by each vehicle) rather than the demand?&lt;/p&gt;&#xA;" OwnerUserId="3506" LastEditorUserId="491" LastEditDate="2021-01-12T19:20:37.643" LastActivityDate="2021-01-12T19:20:37.643" Title="Adding a hard and soft upper bound constraint of number of locations to visit (VRP)" Tags="|python|or-tools|vehicle-routing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4138" PostTypeId="1" CreationDate="2020-05-14T05:32:50.493" Score="5" ViewCount="279" Body="&lt;p&gt;I'm running CBC on problems for which not always an integer solution can be found in a given time, so the command line option &lt;code&gt;sec 120&lt;/code&gt; is set (2 minutes maximum). The random seeds are also set to avoid that the same run returns different results (&lt;code&gt;randomCbcSeed 42 randomSeed 42&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I found that this still returns non-deterministic results as the the 2min timeout is pretty sensitive to CPU load (~CPU time ~solve time). In fact, I noticed that when running lots of independent CBC runs in parallel (on a CI server which is also shared across other users), this issue is exacerbated. Slower hardware may also return different results than faster hardware which is also a problem for my use case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any another definitely deterministic way to terminate CBC prematurely so that it always returns the same results (I don't mind if it's a few seconds or minutes more or less than the specified timeout, but stable results are pretty essential for me)?&lt;/p&gt;&#xA;" OwnerUserId="3507" LastActivityDate="2020-06-13T10:03:05.507" Title="Deterministic termination criteria for CBC" Tags="|coin-or|cbc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4139" PostTypeId="2" ParentId="4137" CreationDate="2020-05-14T07:53:22.107" Score="6" Body="&lt;p&gt;Crossposted from: &lt;a href=&quot;https://stackoverflow.com/questions/61786554/adding-a-hard-and-soft-upper-bound-constraint-of-number-of-locations-to-visit-v&quot;&gt;Stack Overflow&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to create another dimension ('visit') that is incremented by 1 on each visit.&#xA;Then use &lt;code&gt;SetCumulVarSoftUpperBound&lt;/code&gt; on the cumul variable of that dimension at the end of each route.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2020-05-14T07:53:22.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4140" PostTypeId="2" ParentId="4138" CreationDate="2020-05-14T09:37:01.307" Score="2" Body="&lt;p&gt;Use different parameter such as maximum number of nodes to be checked during branching, regardless the time of execution. Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="3463" LastActivityDate="2020-05-14T09:37:01.307" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4141" PostTypeId="2" ParentId="4135" CreationDate="2020-05-14T11:12:15.590" Score="5" Body="&lt;p&gt;Simulated annealing is just a (meta)heuristic strategy to help local search to better escape local optima. Local search for combinatorial optimization is conceptually simple: move from a solution to another one by changing some (generally a few) decisions, and then evaluate if this new solution is better or not than the previous one. For an introduction to this algorithmic technique, have a look to &lt;a href=&quot;https://dl.acm.org/doi/book/10.5555/549160&quot; rel=&quot;noreferrer&quot;&gt;https://dl.acm.org/doi/book/10.5555/549160&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consequently, first you have to implement a local search approach for the knapsack problem. What are the decisions of the problem to solve? To decide if an item is taken in the bag or not. What is a possible representation of a solution of the problem? The list of items stored in the bag. In a first attempt, the moves can basically be: take an item outside the bag and put it inside (insertion), take an item inside the bag and put it outside (deletion), take an item inside the bag and replace it with an item outside (exchange). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For each move, you have to implement a method to evaluate the impact of the move on the quality of the solution: does the new solution, obtained after the move, satisfy the constraints (here the sum of the weights of items in the bag must be lower than the knapsack bound)? does the new solution have a better objective value (here the sum of the prices of the items in the bag has to be maximized)? The evaluation can be done in constant time, that is, very fast, thanks to an incremental computation (store and update the sum of weights and the sum of prices for the items in the bag). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To go further, you can add a simulated annealing strategy, as described in the code given to solve the quadratic assignment problem, to help the local search to escape local optima. The idea is to accept with a certain probability (that becomes lower and lower along the resolution time is running) some moves which deteriorate the quality of the incumbent solution. On our side, we always prefer first to enrich/enlarge the moves (for example, exchanges K items inside the bag with K' items outside) instead of implementing such &quot;meta&quot; strategies that require to tune several parameters.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-05-14T11:12:15.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4143" PostTypeId="1" CreationDate="2020-05-14T13:58:37.180" Score="2" ViewCount="110" Body="&lt;p&gt;Is there a better way than the code below to the rescaling of variable in a model after the model has been build with Gurobi? Like some build in function or a direct manipulation of the column object? I am using the python api of Gurobi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MWE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from gurobipy import *&#xA;&#xA;m = Model()&#xA;&#xA;x = m.addVar()&#xA;x.UB = 2&#xA;x.LB = 1&#xA;cstr0 = m.addConstr(3*x &amp;lt;= 3)&#xA;m.update()&#xA;print &quot;before&quot;, m.getRow(cstr0), x.LB, x.UB&#xA;&#xA;scaling_factor = 1/3.0&#xA;col = m.getCol(x)&#xA;for i in xrange(col.size()):&#xA;    cstr = col.getConstr(i)&#xA;    coeff = col.getCoeff(i)&#xA;    m.chgCoeff(cstr, x, scaling_factor*coeff)&#xA;&#xA;x.UB = x.UB * 1/float(scaling_factor)&#xA;x.LB = x.LB * 1/float(scaling_factor)&#xA;m.update()&#xA;print &quot;after&quot;, m.getRow(cstr0), x.LB, x.UB&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="3305" LastEditDate="2020-05-14T15:57:10.697" LastActivityDate="2020-05-14T15:57:10.697" Title="Efficient way to do user rescaling of variable in Gurobi" Tags="|modeling|python|gurobi|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4144" PostTypeId="1" AcceptedAnswerId="4154" CreationDate="2020-05-14T14:12:20.623" Score="1" ViewCount="211" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qtoxN.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimization of a simple expansion problem&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;minimise:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{t=1}^{5}\left[\sum_{i=1}^{2}x_{i,t}CC_i\left(\frac{1+EIC}{1+r}\right)^t+UE_t*C_{UE}\right]&#xA;$$&lt;/span&gt;&#xA;subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;0 \leq x_{i,t} \leq 5 \\&#xA;ED_B(I+\alpha)^t=\sum_{i=1}^{2}\sum_{j=1}^{t}x_{ij}G_{ij}+UE_t\\&#xA;ED_B,\alpha\in\Bbb{R}\\&#xA;UE=[\;4.5,4.8,4.2,4.0,5.0\;]\;kWH\\&#xA;C_{UE}=0.05$ \\ (Escalation\;in\;CC)\;EIC=4\;\% \\ (Annual\;Discount)\;r=5\;\%&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to minimize a cost function accumulating over 5 years with some constraints on energy balance and bounds on the integer variables.&#xA;It could be a mixed-integer problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to formulate in MatLab or any other tools that I can use to write and solve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CVX tutorial for such a problem is highly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qtoxN.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Problem&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3511" LastEditorUserId="38" LastEditDate="2020-05-15T01:48:47.147" LastActivityDate="2024-04-04T04:47:10.360" Title="How do I solve this Optimization problem?" Tags="|optimization|nonlinear-programming|matlab|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4145" PostTypeId="1" AcceptedAnswerId="4150" CreationDate="2020-05-14T14:18:00.597" Score="8" ViewCount="1271" Body="&lt;p&gt;I am trying to calculate the reorder point and safety stock for a pharmaceutical product. I am using this formula&#xA;&lt;span class=&quot;math-container&quot;&gt;$$r = \mu_{LTD} + z_\alpha\sigma_{LTD}. $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$SS = z_\alpha\sigma_{LTD}. $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\mu_{LTD} = \mu_D\mu_L$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sigma^2_{LTD} = \mu_L\sigma_D^2 + \mu_D^2\sigma_L^2$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say I take a time granularity of 1 month. That means my calculations for the mean and standard deviations of demand (&lt;span class=&quot;math-container&quot;&gt;$\mu_D$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sigma_D$&lt;/span&gt;) will be done on a monthly basis. I get these values as &lt;span class=&quot;math-container&quot;&gt;$26000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$6350$&lt;/span&gt; per month, respectively. The lead time for my product is &lt;span class=&quot;math-container&quot;&gt;$\mu_L = 75$&lt;/span&gt; days or &lt;span class=&quot;math-container&quot;&gt;$2.5$&lt;/span&gt; months. The standard deviation of lead time is assumed to be 20% of the mean lead time so that &lt;span class=&quot;math-container&quot;&gt;$\sigma_L = 0.5$&lt;/span&gt;. I also assume a Type 1 service level of 99% to get &lt;span class=&quot;math-container&quot;&gt;$z = 2.33$&lt;/span&gt;. Putting these values directly in the above formula I get the safety stock as &#xA;&lt;span class=&quot;math-container&quot;&gt;$$SS = 38,000$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$r = 103,000$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The values I got from the formula seem absurdly high to me. The company typically orders about 25000 units of the product with each order. I will have to place 4 orders just to reach the reorder point and once all of those orders arrive, the amount of inventory I would be holding will be tremendous. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question:&lt;/strong&gt; Does the formula mandate that the lead time be shorter than the time granularity considered? Another way I thought about it was that since there are &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; complete cycles in each lead time period, placing an order &lt;span class=&quot;math-container&quot;&gt;$2.5$&lt;/span&gt; months back would be the same as placing it &lt;span class=&quot;math-container&quot;&gt;$0.5$&lt;/span&gt; months back, which would yield an effective &lt;span class=&quot;math-container&quot;&gt;$\mu_L = 0.5$&lt;/span&gt;. I think the second approach should yield some reasonable numbers but I am not sure if it is correct. Any help is appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I thought about this some more and came up with another approach. Suppose I assumed &lt;span class=&quot;math-container&quot;&gt;$\mu_L$&lt;/span&gt; to be the &lt;strong&gt;&quot;hypothetical lead time&quot;&lt;/strong&gt; of say &lt;span class=&quot;math-container&quot;&gt;$1.5$&lt;/span&gt; months. If I do the calculations taking &lt;span class=&quot;math-container&quot;&gt;$\mu_L = 0.5$&lt;/span&gt; (other parameters remaining same), I get &lt;span class=&quot;math-container&quot;&gt;$SS = 35,000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r = 74,000$&lt;/span&gt;. Since this is a &lt;strong&gt;&quot;hypothetical reorder point&quot;&lt;/strong&gt;, I would actually place the order &lt;strong&gt;1 month back&lt;/strong&gt;. So if the reorder point suggests placing an order on 20th May, I would actually place an order on 20th April. The caveats I can see with this approach are that I would need to forecast the demand well to plan placing orders ahead of time. Again, not sure if this approach is any good.   &lt;/p&gt;&#xA;" OwnerUserId="3458" LastEditorUserId="3458" LastEditDate="2020-05-14T16:46:30.830" LastActivityDate="2024-01-31T18:46:21.753" Title="Lead time longer than cycle time" Tags="|inventory|rq-inventory-model|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4146" PostTypeId="1" CreationDate="2020-05-14T15:53:12.750" Score="5" ViewCount="114" Body="&lt;p&gt;What is the best complexity for the worst case scenario and the algorithm associated with it to determine if a linear programming (LP) is infeasible ? Further, what if we consider a mixed integer programming (MIP) ? Note that I only would like to know whether the problem is infeasible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, I believe the worst case scenario would be a NP-Hard problem modeled as either a LP or MIP and, determining whether our model is infeasible, would be NP-Hard as well, i. e. complexity of O(2&lt;sup&gt;n&lt;/sup&gt;) where &lt;code&gt;n&lt;/code&gt; is the number of variables in our model.&lt;/p&gt;&#xA;" OwnerUserId="3512" LastActivityDate="2020-05-14T15:53:12.750" Title="Complexity of determining whether a LP or MIP is infeasible" Tags="|mixed-integer-programming|linear-programming|computational-complexity|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4147" PostTypeId="1" CreationDate="2020-05-14T17:00:41.210" Score="7" ViewCount="1218" Body="&lt;p&gt;I would like to know of a method in which if provided say 10 routes with details regarding which route intersects with which another route, we can use the least number of colours to colour the routes, without the intersecting routes having the same colour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, say Route 1 intersects with Route 2,3,6,7,9.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Route 2 intersects with Route 1,3,5,7 and so on...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One can use the same colour again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should one go about assigning colours to each route and also minimize the number of colours used?&lt;/p&gt;&#xA;" OwnerUserId="3513" LastActivityDate="2020-05-14T22:20:16.643" Title="How to use the least number of colours to colour different routes of a bus route such that no two intersecting routes will have the same colour" Tags="|optimization|integer-programming|constraint-programming|scheduling|graphs|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4148" PostTypeId="2" ParentId="4147" CreationDate="2020-05-14T17:48:13.853" Score="14" Body="&lt;p&gt;Recognize that each route can be viewed as being a node on a graph. Edges connect nodes if the routes the nodes represent intersect. This is the canonical &lt;a href=&quot;https://en.wikipedia.org/wiki/Graph_coloring#Algorithms&quot; rel=&quot;noreferrer&quot;&gt;graph coloring problem&lt;/a&gt; for which there are a &lt;a href=&quot;https://mathworld.wolfram.com/MinimumVertexColoring.html&quot; rel=&quot;noreferrer&quot;&gt;number&lt;/a&gt; of exact and approximate algorithms. Specifically, you're trying to find a constructive algorithm for determining the &lt;a href=&quot;https://mathworld.wolfram.com/ChromaticNumber.html&quot; rel=&quot;noreferrer&quot;&gt;chromatic number&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For 10 routes and low recalculation volume, I'd suggest building a simple brute-force algorithm as the quickest way of getting an answer.&lt;/p&gt;&#xA;" OwnerUserId="886" LastEditorUserId="886" LastEditDate="2020-05-14T17:56:26.787" LastActivityDate="2020-05-14T17:56:26.787" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4150" PostTypeId="2" ParentId="4145" CreationDate="2020-05-15T01:46:56.093" Score="2" Body="&lt;p&gt;There is no contradiction or inconsistency in having the lead time be longer than the time unit* for the model. The important thing to remember here is that the reorder point &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; refers to the &lt;strong&gt;inventory position&lt;/strong&gt; (IP), not the inventory &lt;em&gt;level&lt;/em&gt; (L). The inventory position equals the on-hand inventory &lt;em&gt;plus the on-order inventory&lt;/em&gt; (minus backorders, if any). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, setting &lt;span class=&quot;math-container&quot;&gt;$r = 103{,}000$&lt;/span&gt; means you place an order when there are 103,000 on hand and on order (combined). If &lt;span class=&quot;math-container&quot;&gt;$Q = 25{,}000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu_{LTD} = 26{,}000 \times 2.5 = 65{,}000$&lt;/span&gt;, then you always have a few orders outstanding. So a good portion of the 103,000 units in the IP are really on order, not on hand. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically you don't pay holding cost on on-order inventory, so these units don't cost us anything until they arrive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To take a simpler example, suppose &lt;span class=&quot;math-container&quot;&gt;$\mu=25{,}000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sigma=0$&lt;/span&gt; (so the demands are deterministic), &lt;span class=&quot;math-container&quot;&gt;$L=2.5$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$r=100{,}000$&lt;/span&gt; (to keep the numbers simpler), and &lt;span class=&quot;math-container&quot;&gt;$Q=25{,}000$&lt;/span&gt;. Then the inventory position (red curve) and inventory level (blue curve) look like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GPhdw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GPhdw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I assumed that at time 0 we have 50,000 units on hand and nothing on order, but you could assume any other numbers and the curves would eventually look the same once we reach steady state.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The on-hand inventory fluctuates between 37,500 and 62,500, which seems roughly in line with the numbers you are describing in practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another reason you might be seeing a discrepancy is your choice of a 99% type-1 service level. This is a reasonable target but if the company is using something smaller (or, more likely, isn't really using any formula at all and is just winging it), you might see lower inventory levels in practice. For example, if the service level is 95%, then &lt;span class=&quot;math-container&quot;&gt;$r \approx 92,000$&lt;/span&gt;, and all the inventory levels/positions will be about 10% lower than the ones you calculated.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;*It's not really a &lt;em&gt;cycle time&lt;/em&gt;, unless it's actually a periodic-review model and the firm can only order, say, once per month. But in that case you can get yourself into trouble because you have a lead time that's not an integer multiple of the period length, and things are even worse if the lead time is stochastic. So I'm assuming you're operating in continuous review.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2020-05-15T12:34:54.907" LastActivityDate="2020-05-15T12:34:54.907" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4151" PostTypeId="1" AcceptedAnswerId="4152" CreationDate="2020-05-15T02:02:49.530" Score="3" ViewCount="653" Body="&lt;p&gt;The problem below aims to minimize the cutting leftovers from each cut :&lt;/p&gt;&#xA;&lt;p&gt;A company manufactures desks for kids gardens and primary schools, colleges and high schools. The leg of these desks all have the same diameter, but are of different lengths: &lt;strong&gt;40cm&lt;/strong&gt; for the smallest, &lt;strong&gt;60cm&lt;/strong&gt; for the medium and &lt;strong&gt;70cm&lt;/strong&gt; for the large.&#xA;They are cut from &lt;strong&gt;1.5m&lt;/strong&gt; or &lt;strong&gt;2m&lt;/strong&gt; long steel bars.&lt;/p&gt;&#xA;&lt;p&gt;This company receives an order from &lt;strong&gt;108 small&lt;/strong&gt; desks, &lt;strong&gt;125 medium&lt;/strong&gt; and &lt;strong&gt;100 large&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How to carry out this order while minimizing the leftovers. &lt;br&gt;&#xA;A. Formulate this optimization problem using an integer number linear program.&lt;br&gt;&#xA;B. Use the Cplex solver to solve it.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Modeling the problem :&lt;/strong&gt;&#xA;The tables below represent every method and possibility for each leg length:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Cutting cases and leftovers using 1.5m -150cm- steel bar :&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;| Case # /Leg length | --1--  | --2-- | --3--  | --4--  | --5--  | --6--  | Order |&lt;br&gt;&#xA;|---------------------------|-------|-------|-------|--------|-------|--------|---------|&lt;br&gt;&#xA;| Leg 1 -40cm---------      |..  3  ..|.. 2 ..|.. 0  ...|.. 2  ....|.. 0  ..|.. 0  ....|.. 432   |&lt;br&gt;&#xA;| Leg 2 -60cm---------      |.. 0  ..|.. 0 ..|.. 2  ...|.. 1  ....|.. 1  ..|.. 0  ....|.. 500   |&lt;br&gt;&#xA;| Leg 3 -70cm---------      |.. 0  ..|.. 1 ..|.. 0  ...|.. 0  ....|.. 1  ..|.. 2  ....|.. 400   |&lt;br&gt;&#xA;| Falls in cm-----------       |.. 30 |.. 0 ..|.. 30 .|.. 10 ..|.. 20 |.. 10 ..|--------       |&lt;br&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;For example : &lt;br&gt;&#xA;The first column -case #1- means that with a 1.5m steel bar we can cut 3 legs of 40cm each with 30cm leftover. &lt;br&gt;&#xA;The second column -case #2- means that with one bar steel of 1.5m we can cut 2 legs of 40cm and 1 leg of 70cm with no leftovers.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Cutting cases and leftovers using 2m -200cm- steel bar :&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;| Case # /Leg length | --1--  | --2-- | --3--  | --4--  | --5--  | --6--  | --7--  | --8--  | --9-------  | Order |&lt;br&gt;&#xA;|---------------------------|-------|-------|-------|--------|-------|--------|---------|---------|---------|---------|&lt;br&gt;&#xA;| Leg 1 -40cm---------      |..  5  ..|.. 0 ..|.. 2  ...|.. 0  ....|.. 0  ..|.. 1  ....|.. 3  ....|.. 3  ....|..  1 ....|.. 432   |&lt;br&gt;&#xA;| Leg 2 -60cm---------      |.. 0  ..|.. 3 ..|.. 2  ...|.. 2  ....|.. 1  ..|.. 0  ....|.. 0  ....|.. 1  ....|.. 1  ....|.. 500   |&lt;br&gt;&#xA;| Leg 3 -70cm---------      |.. 0  ..|.. 0 ..|.. 0  ...|.. 1  ....|.. 2  ..|.. 2  ....|.. 1  ....|.. 0  ....|.. 1  ....|.. 400   |&lt;br&gt;&#xA;| Falls in cm-----------       |.. 0 |.. 20 ..|.. 0 .|.. 10 ..|.. 20 |.. 10 ..|.. 10 ..|.. 20 ..|.. 30 ..|--------       |&lt;br&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Cplex code&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;//Variables definition : &#xA;// x = a case that could be from both tables above &#xA;// i = [1,2] : 1 =&amp;gt; when we use the 1.5m steel bar, 2 =&amp;gt; when we use 2m steel bar; &#xA;// j = [1..9] : for every case from the tables above -for i=1; j=[1..6] | for i=2; j=[1..9]; &#xA;// z = My objective function; &#xA;// contrLEG* = constraints for each leg; &#xA;&#xA;dvar int x11;&#xA;dvar int x12;&#xA;dvar int x13;&#xA;dvar int x14;&#xA;dvar int x15;&#xA;dvar int x16;&#xA;dvar int x21;&#xA;dvar int x22;&#xA;dvar int x23;&#xA;dvar int x24;&#xA;dvar int x25;&#xA;dvar int x26;&#xA;dvar int x27;&#xA;dvar int x28;&#xA;dvar int x29;&#xA;&#xA;dexpr int  z=30*x11+30*x13+10*x14+20*x15+10*x16+20*x22+10*x24+20*x26+10*x27+20*x28+30*x29;&#xA;&#xA;minimize z;&#xA;&#xA;subject to {&#xA;  contrLEG1:&#xA;   3*x11+2*x12+2*x14+5*x21+2*x23+x26+3*x27+3*x28+x29 &amp;gt;= 432;&#xA;   &#xA;  contrLE2:&#xA;  2*x13+x14+x15+3*x22+2*x23+2*x24+x25+x28+x29 &amp;gt;= 500;&#xA;  &#xA;  contrLEG3: &#xA;  x12+x15+2*x16+x24+2*x25+2*x26+x27+x29 &amp;gt;=400;&#xA;&#xA;//Cplex is returning the following values :&#xA;// X=200; &#xA;// Y = 600; &#xA;// Z = 36000;&#xA;  &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question part&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Can anyone tells me if I'm doing it the right way?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can anyone confirm the values returned by Cplex?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Does 200 and 600 means that the manufacturer needs 200 steel bar of 1.5m and 600 steel bar of 2m?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3487" LastEditorUserId="51" LastEditDate="2024-02-21T11:18:38.053" LastActivityDate="2024-02-21T11:18:38.053" Title="Cplex : The cutting stock problem" Tags="|optimization|cplex|cutting-planes|cutting-stock|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4152" PostTypeId="2" ParentId="4151" CreationDate="2020-05-15T11:06:08.933" Score="2" Body="&lt;p&gt;I think you have some errors when you wrote&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cutting method and falls using 2m -200cm- steel bar&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The model is small enough for a naïve model without pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;range R=1..3;&#xA;&#xA;int sizes[R]=[40,60,70];&#xA;int demand[R]=[108,125,100];&#xA;&#xA;&#xA;range M=1..2;&#xA;int steelbars[M]=[150,200];&#xA;&#xA;int nbMaxBarOfEach=200;&#xA;range B=1..nbMaxBarOfEach;&#xA;&#xA;// how many shape r in R do we cut in bar b in B of size m in M&#xA;dvar int+ cut[M][B][R];&#xA;// leftover on bar b in B size m in M&#xA;dvar int+ leftOver[M][B];&#xA;// total leftover&#xA;dvar int totalLeftOver;&#xA;&#xA;minimize totalLeftOver;&#xA;subject to&#xA;{&#xA;&#xA;  totalLeftOver==sum(m in M,b in B) leftOver[m][b]-sum(m in M) steelbars[m]*sum(b in B) (0==sum(r in R)cut[m][b][r]) ;&#xA;&#xA;  forall(m in M,b in B) ctBar:leftOver[m][b]+sum(r in R)sizes[r]*cut[m][b][r]&amp;gt;=steelbars[m];&#xA;&#xA;  forall(r in R) ctDemand:sum(m in M, b in B) cut[m][b][r]==demand[r];&#xA;}&#xA;&#xA;int isUsed[m in M][b in B]=(0!=sum(r in R)cut[m][b][r]);&#xA;&#xA;execute display&#xA;{&#xA;  for(var m in M)&#xA;  {&#xA;    writeln();&#xA;    writeln(&quot;For size &quot;,m);&#xA;    for (var b in B) if (isUsed[m][b])&#xA;    {&#xA;      writeln();&#xA;      for(var r in R) if (cut[m][b][r]!=0) write(cut[m][b][r], &quot; times &quot;,sizes[r],&quot; &quot;);&#xA;    }&#xA;    writeln();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which gives 0 as the minimum leftover&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your model&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dvar int+ x11;&#xA;dvar int+ x12;&#xA;dvar int+ x13;&#xA;dvar int+ x14;&#xA;dvar int+ x15;&#xA;dvar int+ x16;&#xA;dvar int+ x21;&#xA;dvar int+ x22;&#xA;dvar int+ x23;&#xA;dvar int+ x24;&#xA;dvar int+ x25;&#xA;dvar int+ x26;&#xA;dvar int+ x27;&#xA;dvar int+ x28;&#xA;dvar int+ x29;&#xA;&#xA;dexpr int  z=30*x11+30*x13+10*x14+20*x15+10*x16+20*x22+10*x24+10*x26+10*x27+20*x28+30*x29;&#xA;&#xA;minimize z;&#xA;&#xA;subject to {&#xA;&#xA;&#xA;&#xA;&#xA;  contrLEG1:&#xA;   3*x11+2*x12+2*x14+5*x21+2*x23+x26+3*x27+3*x28+x29 &amp;gt;= 108;&#xA;&#xA;  contrLE2:&#xA;  2*x13+x14+x15+3*x22+2*x23+2*x24+x25+x28+x29 &amp;gt;= 125;&#xA;&#xA;  contrLEG3: &#xA;  x12+x15+2*x16+x24+2*x25+2*x26+x27+x29 &amp;gt;=100;&#xA;&#xA;&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;also gives 0 leftover&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you could do is minimize the number of bars.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that you may use lexicographic multiobjective:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;minimize z;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;minimize staticLex(z,x11+x12+x13+x14+x15+x16+x21+x22+x23+x24+x25+x26+x27+x28+x29);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you could also be a bit more generic if you generate the patterns in the CPLEX model:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// 3 sizes&#xA;range R=1..3;&#xA;&#xA;int sizes[R]=[40,60,70];&#xA;int demand[R]=[108,125,100];&#xA;&#xA;// 2 bars&#xA;range M=1..2;&#xA;int steelbars[M]=[150,200];&#xA;&#xA;tuple pattern&#xA;{&#xA;  int a;&#xA;  int b;&#xA;  int c;&#xA;  int leftover;&#xA;}&#xA;&#xA;int K=max(m in M) steelbars[m] div min(r in R) sizes[r];&#xA;&#xA;{pattern} patterns[m in M]={&amp;lt;a,b,c,steelbars[m]-a*sizes[1]-b*sizes[2]-c*sizes[3]&amp;gt; | a,b,c in 0..K&#xA; : 0&amp;lt;=steelbars[m]-a*sizes[1]-b*sizes[2]-c*sizes[3] &amp;lt; 40};&#xA;&#xA;{pattern} allPatterns=union(m in M) patterns[m]; &#xA;int qty[p in allPatterns][r in R]=(r==1)?p.a:((r==2)?p.b:p.c);&#xA;&#xA;tuple option&#xA;{&#xA;  int m;&#xA;  pattern p;&#xA;}&#xA;&#xA;&#xA;{option} options={&amp;lt;m,p&amp;gt; | m in M,p in patterns[m]};&#xA;&#xA;dvar int+ cut[options];&#xA;&#xA;dexpr int leftover=sum(o in options) cut[o]*o.p.leftover;&#xA;&#xA;minimize staticLex(leftover,sum(o in options) cut[o]);&#xA;&#xA;subject to&#xA;{&#xA;  forall(r in R) demand[r]&amp;lt;=sum(o in options)cut[o]*qty[o.p][r];&#xA;} &#xA;&#xA;execute display&#xA;{&#xA;  for(var o in options) if (cut[o]!=0) &#xA;  {&#xA;    write(cut[o],&quot; patterns - &quot;);&#xA;    for(var r in R)  if (qty[o.p][r]!=0) write(qty[o.p][r],&quot; * &quot;,sizes[r],&quot; - &quot;);&#xA;    write(&quot; in &quot;,steelbars[o.m]);&#xA;    writeln();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2020-05-16T08:48:55.957" LastActivityDate="2020-05-16T08:48:55.957" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4153" PostTypeId="1" CreationDate="2020-05-15T11:33:58.687" Score="3" ViewCount="77" Body="&lt;p&gt;Is there some MPS files with semi-continuous variables public available anywhere?&lt;/p&gt;&#xA;&lt;p&gt;To me it seems MIPLIB does not contain any.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="491" LastEditDate="2022-12-16T15:46:23.320" LastActivityDate="2022-12-16T15:46:23.320" Title="Public available MPS files with semi-continuous variables" Tags="|linear-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4154" PostTypeId="2" ParentId="4144" CreationDate="2020-05-15T13:09:47.680" Score="3" Body="&lt;p&gt;You can write the model using &lt;a href=&quot;https://www.hexaly.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hexaly&lt;/a&gt;, our global optimization solver. Please note that Hexaly is a commercial software like MATLAB. Nevertheless, you can benefit from a free trial or academic license.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function model() {&#xA;  x[i in 1..2][t in 1..5] &amp;lt;- int(0, 5);&#xA;  EDB &amp;lt;- float(-1e3, 1e3);&#xA;  alpha &amp;lt;- float(-1e3, 1e3);&#xA;&#xA;  for[t in 1..5] {&#xA;    constraint EDB * pow(1 + alpha, t) == sum[i in 1..2][j in 1..t](x[i][j] * G[i][j]) + UE[t];&#xA;  }&#xA;&#xA;  minimize sum[t in 1..5][i in 1..2](x[i][t] * CC[i] * pow((1 + EIC) / (1 + r), t) + UE[t] * Cue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To make it work, you have to add the input data like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function input() {&#xA;  // we skip t = 0&#xA;  UE = {0, 4.5, 4.8, 4.2, 4.0, 5.0};&#xA;  Cue = 0.05;&#xA;  EIC = 0.04;&#xA;  r = 0.05;&#xA;&#xA;  // Dummy data for G_ij&#xA;  G = {&#xA;    {}, //skip index 0&#xA;    {0, 0.42, 0.63, 0.18, 0.78, 0.44},&#xA;    {0, 0.06, 0.65, 0.92, 0.71, 0.98}&#xA;  };&#xA;&#xA;  // Dummy data for CC_i&#xA;  CC = {0, 0.5, 0.5};&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As shown above, we have tried to complete the missing data with some values. Using this data, the model is unfeasible (no surprise).&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T04:47:10.360" LastActivityDate="2024-04-04T04:47:10.360" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4155" PostTypeId="1" CreationDate="2020-05-15T19:49:38.607" Score="2" ViewCount="69" Body="&lt;p&gt;So I am very familiar with the WTAP it the static case. What I am wondering, is there a formulation that has &quot;time windows&quot; as well? Let's say you have some weapons and some targets, you know the probabilities of kill and the probabilities of that target avoiding. On top of that you also know available time windows in which each weapon can access each target.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a simultaneous problem, or should it be a WTPA, followed by a scheduling problem?&lt;/p&gt;&#xA;" OwnerUserId="3486" LastEditorUserId="123" LastEditDate="2020-05-16T08:28:31.333" LastActivityDate="2020-05-16T08:28:31.333" Title="Weapon Target Assignment Problem + Time Windows" Tags="|optimization|linear-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4156" PostTypeId="1" CreationDate="2020-05-15T21:47:56.077" Score="2" ViewCount="199" Body="&lt;p&gt;I am trying to develop algorithm to solve following basic version of the problem.&#xA;1) I would like to know what this problem is called in literature so that I can look it up&#xA;2) What are efficient methods to solve this problem that I can look at &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please provide name of the methods/references if you can. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are &lt;span class=&quot;math-container&quot;&gt;$N - \{1 \ldots N\}$&lt;/span&gt; jobs, each with processing time &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt;, to be scheduled on &lt;span class=&quot;math-container&quot;&gt;$M - \{1 \ldots M\}$&lt;/span&gt; machines over span of &lt;span class=&quot;math-container&quot;&gt;$D - \{1 \ldots D\}$&lt;/span&gt; days and while working &lt;span class=&quot;math-container&quot;&gt;$T - \{1 \ldots E \ldots T\}$&lt;/span&gt; hours at most each day. You can have factory working overtime after time period &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; (5 pm), at extra cost but not after &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;. To use a machines, there is a fixed cost per day. No cost is incurred if you choose not to use the machine. If the job is scheduled on a machine, there is a constraint to ensure that machine is used. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The goal is to schedule each job so that  1) you can reduce the cost of working overtime 2) reduce the fixed cost. &lt;strong&gt;Note that schedule specifies the job, the machine it is assigned to, time slot when it should start, and the day on which it should be scheduled.&lt;/strong&gt;  This could be very standard problem in literature as I have seen similar problems solved for one day scheduling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference between my problem and other problems is that, there is a &lt;strong&gt;penalty&lt;/strong&gt; / &lt;strong&gt;reward&lt;/strong&gt; for starting the job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at a particular time slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; between &lt;span class=&quot;math-container&quot;&gt;$\{1 \ldots T\}$&lt;/span&gt; on machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, for each day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;. Basically, there exist a penalty or reward cost for starting a job. I have gone through several articles but have not found anything that consider this additional penalty term for starting in a particular time slot. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose schedule is defined by binary variable &#xA;&lt;span class=&quot;math-container&quot;&gt;$X_{idtm}$&lt;/span&gt; = 1 if job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; and starts in time slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, 0 otherwise. &#xA; There is penalty term in addition to fixed machine cost and overtime cost,&#xA;&lt;span class=&quot;math-container&quot;&gt;$(+ \alpha_{idtm} * X_{idtm})$&lt;/span&gt; where  &lt;span class=&quot;math-container&quot;&gt;$\alpha_{idtm}$&lt;/span&gt; can be positive or negative. Note that  &lt;span class=&quot;math-container&quot;&gt;$\alpha_{idtm}$&lt;/span&gt; is a parameter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All jobs must be scheduled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a formulation. I am trying to find if similar scheduling problems have been solved. What the problem is called, what are the algorithms used to solve such a problem. &lt;/p&gt;&#xA;" OwnerUserId="3520" LastActivityDate="2020-05-16T05:44:37.193" Title="What kind of scheduling problem is this?" Tags="|optimization|mixed-integer-programming|modeling|integer-programming|scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4157" PostTypeId="1" AcceptedAnswerId="4160" CreationDate="2020-05-16T03:44:27.213" Score="4" ViewCount="158" Body="&lt;p&gt;Can anyone please refer/suggest me some accessible papers, works, books, websites, documentation related to The Maximum Flow Problem. &lt;/p&gt;&#xA;" OwnerUserId="3487" LastEditorUserId="2556" LastEditDate="2020-05-16T12:20:19.190" LastActivityDate="2020-05-16T18:20:33.707" Title="Maximum Flow Problem : Can someone refer me to accessible valuable resources" Tags="|optimization|reference-request|graphs|network-flow|books|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4158" PostTypeId="2" ParentId="4156" CreationDate="2020-05-16T05:44:37.193" Score="1" Body="&lt;p&gt;Is there any specific route for each job or they can be performed on each machine when the machine is available? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the first case, the problem can be interpreted as a job shop (or hybrid), other else you would formulate the problem as a resource-constrained project schedule. About the penalty/reward, as you mentioned, in the real application JIT (just in time) objective function is frequently used in the industry specifically in the APSs (Advanced Planning and scheduling software). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;About the algorithms used to solve such a problem, you have many options. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can formulate the model as a mixed-integer program and solve it by using the appropriate software like CPLEX. &lt;/li&gt;&#xA;&lt;li&gt;If you are interested to use CP, you can check and find many examples to do that. &lt;/li&gt;&#xA;&lt;li&gt;Also, as excel is a basic software in the industry, there are excel-based optimization software like &lt;a href=&quot;https://solverstudio.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;solverstudio&lt;/a&gt; which can be used to solve your problem. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-05-16T05:44:37.193" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4159" PostTypeId="1" AcceptedAnswerId="4167" CreationDate="2020-05-16T07:52:08.537" Score="2" ViewCount="161" Body="&lt;p&gt;I want to solve the following two-variate nonlinear programming using KKT conditions:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{align} \begin{split}&#xA;    \max \quad &amp;amp; 15 \sqrt{x_{1}} + 16 \sqrt{x_{2}} \\&#xA;    \text{s.t.} \quad &amp;amp; x_{1} + x_{2} \leq 120 \\&#xA;    &amp;amp; x_{1}, x_{2} \in \mathbb{R}^+&#xA;\end{split} \end{align} $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two parts in the function &lt;span class=&quot;math-container&quot;&gt;$L(x_{1}, x_{2}, \lambda)$&lt;/span&gt; are monotonically increasing, so the function is strictly concave. It is obvious that the decision variables belong to a convex set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Point (1, 1) is a slater point, so the problem satisfies Slater's condition. The strong duality holds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Lagrangian function is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{align} \begin{split}&#xA;  L(x_{1}, x_{2}, \lambda) = 15 \sqrt{x_{1}} + 16 \sqrt{x_{2}} - \lambda (x_{1} + x_{2} - 120)&#xA;\end{split} \end{align} $$&lt;/span&gt;&#xA;whose derivatives are:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{align} \begin{split}&#xA;  \frac{\partial L}{\partial x_{1}} &amp;amp;= \frac{15}{2 \sqrt{x_{1}}} - \lambda \\&#xA;  \frac{\partial L}{\partial x_{2}} &amp;amp;= 8 / \sqrt{x_{2}} - \lambda \\&#xA;  \frac{\partial L}{\partial \lambda} &amp;amp;= 120 - x_{1} - x_{2}&#xA;\end{split} \end{align} $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{align}&#xA;  x_1, x_2 \geq 0 \\&#xA;  \lambda \geq 0&#xA;\end{align} $$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Critical points can be calculated by the symbolic math toolbox in MATLAB:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-matlab prettyprint-override&quot;&gt;&lt;code&gt;syms x1 x2 lbd&#xA;eq(1) = lbd * (120 - x1 - x2) == 0;&#xA;eq(2) = x1 * (15/2/sqrt(x1) - lbd) == 0;&#xA;eq(3) = x2 * (8/sqrt(x2) - lbd) == 0;&#xA;sol = solve(eq)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results are (0, 0, 0), (120, 0, 0.6847), (0, 120, 0.7303), and (56.133, 63.867, 1.0010), and corresponding values of the objective function are 0, 164.3168, 175.2712, and 240.2499. So the point (56.133, 63.867, 1.0010) is chosen as the optimal solution.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Specifically, I have three questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is my writing good enough?&lt;/li&gt;&#xA;&lt;li&gt;Do I have to solve KKT conditions regarding inequality? MATLAB can't solve the following system of equations because of &lt;code&gt;Division by zero&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;eq(1) = lbd1 * (120 - x1 - x2) == 0;&#xA;eq(2) = x1 + x2 - 120 &amp;lt;= 0&#xA;eq(3) = x1 * (15/2/sqrt(x1) - lbd1) == 0;&#xA;eq(4) = 15/2/sqrt(x1) - lbd1 &amp;lt;= 0;&#xA;eq(5) = x2 * (8/sqrt(x2) - lbd1) == 0;&#xA;eq(6) = 8/sqrt(x2) - lbd1 &amp;lt;= 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;What if the problem becomes complicated? Are there any softwares to analyse NLPs this way?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Two minor errors pointed out by @prubin and @dhasson are not the primary issue of this post, so I have corrected them. Much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3163" LastEditorUserId="3163" LastEditDate="2020-05-17T09:25:34.900" LastActivityDate="2020-05-17T09:25:34.900" Title="Simple nonlinear programming using convexity analysis and KKT" Tags="|nonlinear-programming|convexity|duality|kkt-conditions|lagrange-multipliers|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4160" PostTypeId="2" ParentId="4157" CreationDate="2020-05-16T07:59:19.833" Score="6" Body="&lt;p&gt;&lt;a href=&quot;http://cs.yazd.ac.ir/hasheminezhad/STSCS4R1.pdf&quot; rel=&quot;noreferrer&quot;&gt;Here&lt;/a&gt; is one suggestion : &lt;strong&gt;Network Flows: Theory, Algorithms, and Applications&lt;/strong&gt; by Ahuja, Magnanti, Orli.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;maximum flow problem&lt;/em&gt; is delt with in chapters 6-8, but I suggest you read the ones before if you are not familiar with flows in general. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, James Orlin (one of the authors, teaches at MIT) has a &lt;a href=&quot;https://mitmgmtfaculty.mit.edu/jorlin/network-flows/&quot; rel=&quot;noreferrer&quot;&gt;webpage&lt;/a&gt; where you can find solutions to some of the exercises. &lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-05-16T08:33:10.297" LastActivityDate="2020-05-16T08:33:10.297" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4161" PostTypeId="2" ParentId="96" CreationDate="2020-05-16T12:01:32.260" Score="2" Body="&lt;p&gt;[taylor2015convex] provides a holistic view on economic dispatch, unit commitment, and optimal power flow. The continuous operation of power systems requires multi-period optimal power flow, which is discussed in chapter 4. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The decision concerning long-term investments is the most complicated programming problems in power systems, which is discussed in chapter 5, based on multi-period OPF.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are mature algorithms to handle power flow (or load flow) problems, but they are fundamentally different from the lift-and-project relaxation for OPF used in the book.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Taylor, J. A. (2015). Convex optimization of power systems. Cambridge University Press.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3163" LastActivityDate="2020-05-16T12:01:32.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4162" PostTypeId="1" AcceptedAnswerId="4164" CreationDate="2020-05-16T15:43:07.080" Score="5" ViewCount="1643" Body="&lt;p&gt;Is it possible for a linear programming model to be non-convex ? If it is, please, provide a simple 2 variables example and explain why it is non-convex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 1:&#xA;I have been wondering, maybe the following constraints are non-convex:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}x+y&amp;amp;\ge3\\0.5x+y&amp;amp;\le3.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3522" LastEditorUserId="123" LastEditDate="2020-05-16T16:05:26.650" LastActivityDate="2020-05-17T22:02:19.553" Title="Linear programming convexity" Tags="|linear-programming|convexity|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4163" PostTypeId="2" ParentId="4162" CreationDate="2020-05-16T15:59:23.270" Score="7" Body="&lt;p&gt;No, linear programming is convex, which you can prove directly from the definition.  If &lt;span class=&quot;math-container&quot;&gt;$A x \le b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A y \le b$&lt;/span&gt;, then for arbitrary &lt;span class=&quot;math-container&quot;&gt;$\alpha\in[0,1]$&lt;/span&gt;, we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A (\alpha x+(1-\alpha)y) = \alpha A x+(1-\alpha)Ay \le \alpha b+(1-\alpha)b = b.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-05-17T22:02:19.553" LastActivityDate="2020-05-17T22:02:19.553" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4164" PostTypeId="2" ParentId="4162" CreationDate="2020-05-16T16:01:22.187" Score="9" Body="&lt;p&gt;A linear problem is always convex, because anything linear is convex. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As pointed out by @Marco Lübbecke, any linear function is also concave. But polygons (feasible sets of linear programs) are only convex (and not concave).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out &lt;a href=&quot;https://www.solver.com/convex-optimization&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; link, it is well explained, or &lt;a href=&quot;https://math.stackexchange.com/questions/611633/is-linear-function-convex-or-concave&quot;&gt;this&lt;/a&gt; one for an algeabraic proof.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your example has only one feasible point (assuming &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are positive) : &lt;span class=&quot;math-container&quot;&gt;$(0,3)$&lt;/span&gt;. I suspect you were maybe thinking of an example such as &lt;span class=&quot;math-container&quot;&gt;$y\le 1$&lt;/span&gt; OR &lt;span class=&quot;math-container&quot;&gt;$y\ge 2$&lt;/span&gt;. This indeed is not convex. Both constraints are linear, but the OR operations kills the convexity.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-05-16T16:29:22.523" LastActivityDate="2020-05-16T16:29:22.523" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4166" PostTypeId="1" AcceptedAnswerId="4168" CreationDate="2020-05-16T16:44:16.487" Score="3" ViewCount="376" Body="&lt;p&gt;Consider any linear programming model of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; constraints which has multiple optimum solutions. If it is possible, I'd like to know the lower and upper limits (in terms of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; and possibly other elements as well) for the number of vertices from the feasible polyhedron that belongs to the set of optimum solutions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came to believe, that as long as the feasible polyhedron contains more than a single point, there would be at least 2 different vertices that belong to the set of optimum solutions. However, for the upper limit, I have no clue, except that the total number of vertices in a feasible polyhedron (which are not necessarily optimum) is at most &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if my thoughts on this subject are correct, and maybe it's not possible to have a good estimation at all on this matter.&lt;/p&gt;&#xA;" OwnerUserId="3522" LastEditorUserId="500" LastEditDate="2020-05-16T22:22:08.827" LastActivityDate="2020-05-16T22:22:08.827" Title="Estimation of the number of optimum vertices" Tags="|linear-programming|feasible-points|polyhedra|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4167" PostTypeId="2" ParentId="4159" CreationDate="2020-05-16T17:35:45.933" Score="6" Body="&lt;p&gt;You should use the KKT conditions (turning the sign restrictions on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; into constraints), but it turns out they will not affect the results. First, let me point out that &lt;span class=&quot;math-container&quot;&gt;$\partial L/\partial x_1$&lt;/span&gt; is undefined when &lt;span class=&quot;math-container&quot;&gt;$x_1=0$&lt;/span&gt;, so you need to deal with the case &lt;span class=&quot;math-container&quot;&gt;$x_1=0$&lt;/span&gt; (and the case &lt;span class=&quot;math-container&quot;&gt;$x_2=0$&lt;/span&gt;) separately. Given the monotonicity of &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;, you can easily show that if &lt;span class=&quot;math-container&quot;&gt;$x_1=0$&lt;/span&gt; in an optimal solution then necessarily &lt;span class=&quot;math-container&quot;&gt;$x_2=120$&lt;/span&gt; and vice versa. Having disposed of those cases, you can now assume that &lt;span class=&quot;math-container&quot;&gt;$x_1\gt 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2\gt 0$&lt;/span&gt;. In that case, the KKT multipliers for the sign restrictions will be 0 by complementary slackness, and you end up with the same solution you found above.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-16T17:35:45.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4168" PostTypeId="2" ParentId="4166" CreationDate="2020-05-16T17:42:21.167" Score="6" Body="&lt;p&gt;Your belief that there will be two different vertices in the set of optimal solutions as long as the feasible polyhedron contains more than a single point is incorrect. In practice, most LPs have unique solutions. As far as an upper bound on the number of optimal vertices, let's assume that you have &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; constraints &lt;em&gt;including sign restrictions&lt;/em&gt; on the variables. For simplicity, let's also assume that &lt;span class=&quot;math-container&quot;&gt;$m&amp;gt;n$&lt;/span&gt; (which need not be the case if you have sign-unrestricted variables). Since a vertex is the intersection of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; affinely independent constraint hyperplanes, in the worst case you would have &lt;span class=&quot;math-container&quot;&gt;$\binom{m}{n}$&lt;/span&gt; vertices, all of which would be optimal if the objective function were constant. Under the given assumptions, that bound is valid, but I don't know that it is &quot;good&quot; if &quot;good&quot; means useful.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-16T17:42:21.167" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4169" PostTypeId="2" ParentId="4157" CreationDate="2020-05-16T18:20:33.707" Score="3" Body="&lt;p&gt;A group of undergraduate students at Berkeley have a fantastic reading group on topics in TCS, and they are currently reading Max Flow. They have a &lt;a href=&quot;https://ugtcs.berkeley.edu/reading-groups/sp20/maxflow/&quot; rel=&quot;nofollow noreferrer&quot;&gt;webpage&lt;/a&gt; where they've curated recent papers with progress on the problem. &lt;/p&gt;&#xA;" OwnerUserId="3523" LastActivityDate="2020-05-16T18:20:33.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4170" PostTypeId="1" AcceptedAnswerId="4174" CreationDate="2020-05-17T16:22:23.123" Score="33" ViewCount="15066" Body="&lt;p&gt;I am a beginning PhD student in math, and I would like to focus on &lt;em&gt;optimization&lt;/em&gt;. I am learning programming for the first time, and I have written out some rudimentary optimization algorithms in both &lt;a href=&quot;https://en.wikipedia.org/wiki/Python_%28programming_language%29&quot; rel=&quot;noreferrer&quot;&gt;Python&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/MATLAB&quot; rel=&quot;noreferrer&quot;&gt;MATLAB&lt;/a&gt;. From my very limited experience, MATLAB was a whole lot easier to use than Python. Being able to do matrix and vector operations directly in MATLAB (rather than having to go through &lt;a href=&quot;https://en.wikipedia.org/wiki/NumPy&quot; rel=&quot;noreferrer&quot;&gt;NumPy&lt;/a&gt; in Python) was extremely nice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw &lt;a href=&quot;https://or.stackexchange.com/questions/3952/are-python-and-julia-used-for-optimization-in-the-industry&quot;&gt;this question&lt;/a&gt;, and it appears that Python is extremely popular in industry, at least in optimization. I was wondering if, to maximize my job prospects, I should learn Python or MATLAB? I would be interested in answers from any field, not only optimization.&lt;/p&gt;&#xA;" OwnerUserId="3527" LastEditorUserId="8" LastEditDate="2020-09-04T09:43:23.863" LastActivityDate="2022-04-01T02:57:12.683" Title="MATLAB vs. Python in industry" Tags="|optimization|python|matlab|industry|" AnswerCount="12" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="4171" PostTypeId="1" AcceptedAnswerId="4173" CreationDate="2020-05-17T17:55:35.160" Score="2" ViewCount="342" Body="&lt;p&gt;I was able to numerically &quot;show&quot; that an M/M/n queue is concave increasing in the number for &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; servers, which makes intuitive sense. However is there a formal analytical proof for it? Where can I find it?&lt;/p&gt;&#xA;" OwnerUserId="3530" LastEditorUserId="123" LastEditDate="2020-05-17T19:10:47.757" LastActivityDate="2020-05-17T19:50:45.417" Title="Waiting time in M/M/n queue" Tags="|queuing-theory|sensitivity-analysis|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4172" PostTypeId="2" ParentId="4171" CreationDate="2020-05-17T19:08:48.953" Score="1" Body="&lt;p&gt;You can derive them from the balance equations. If you check Taha's or Lieberman's Introduction to OR books, you can find the proofs.&lt;/p&gt;&#xA;" OwnerUserId="632" LastActivityDate="2020-05-17T19:08:48.953" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4173" PostTypeId="2" ParentId="4171" CreationDate="2020-05-17T19:33:43.937" Score="4" Body="&lt;p&gt;&lt;a href=&quot;https://pubsonline.informs.org/doi/pdf/10.1287/mnsc.23.9.1019&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dyer and Proll (1977)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; showed that for an &lt;em&gt;M/M/c&lt;/em&gt; queue, the mean waiting time is a strictly decreasing and convex function of &lt;em&gt;c&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt; [1] Dyer, M. E., Proll, L. G. (1977). On the Validity of Marginal Analysis for Allocating Servers in &lt;em&gt;M/M/c&lt;/em&gt; Queues. &lt;em&gt;Management Science.&lt;/em&gt; 23(9):1019-1022. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2020-05-17T19:50:45.417" LastActivityDate="2020-05-17T19:50:45.417" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4174" PostTypeId="2" ParentId="4170" CreationDate="2020-05-17T21:36:25.253" Score="53" Body="&lt;p&gt;Regardless of what completes the phrase &quot;Python vs ...&quot;, the answer is always going to be Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very few people who are serious about using optimisation in production use MATLAB, and the ones who do can't wait to move away from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to why, there are plenty of reasons. MATLAB is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;licensed&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;closed source&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;not object-oriented friendly, so it's a very bad choice for complex software&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;hard to distribute computations, and has a very expensive license for doing so&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;very hard to interface with&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;not scalable &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;nigh-impossible to hire professional programmers for&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Seriously, if you want to be able to use your own code after your PhD, don't use commercial packages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a programming perspective, I have personal experience in the bottlenecks. I wrote the very first version of my solver in MATLAB, and I could solve problems of ~5 variables in reasonable time. Moving to C++ increased that to 200 variables. Rewriting the solver in C++ once I had experience increased that to 100,000 variables, and hiring professional developers increased that to &gt;1,000,000 variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's interesting here is that with the experience I have now, 10 years later, I know there's no way I could have ever scaled our software beyond 100 variables in MATLAB, but I could have in Python.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-05-17T21:49:25.183" LastActivityDate="2020-05-17T21:49:25.183" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="4175" PostTypeId="2" ParentId="4170" CreationDate="2020-05-17T21:52:03.593" Score="20" Body="&lt;p&gt;I agree with everything Nikos said and I add some colors to some of the reasons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Python is free and open-source but Matlab is not. Anyone can write codes in Python and share it with others who can easily run that code (as it's free software) but your Matlab codes can be run only by those who have a license.&lt;/li&gt;&#xA;&lt;li&gt;Just because Python is open-source and free, it means it's widely available to a larger audience. And when you're talking about projects in industry, spending money on a piece of software, IMO, is not justifiable when there is a widely accessible alternative.&lt;/li&gt;&#xA;&lt;li&gt;It makes more sense not to tie a piece of code to a person. Since there are more and more Python users, almost anyone can read and modify your Python code in a company, but if you leave a place and there are not many proficient in Matlab, that's a big loss for the company. It can be easily avoided by using general-purpose programming languages such as Python.&lt;/li&gt;&#xA;&lt;li&gt;Remember that the work in the industry is not just focused on matrix and vector operations. So, my suggestion: gradually start getting out of Matlab comfort zone.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="36" LastActivityDate="2020-05-17T21:52:03.593" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4176" PostTypeId="2" ParentId="4162" CreationDate="2020-05-17T21:56:20.233" Score="3" Body="&lt;p&gt;The others have already given nice answers, but perhaps you posted your edit after their answers, so I'd like to address that. Your constraints are still convex. To see this, first note that any halfspace is convex; next, note that the intersection of any two convex sets is also convex. Since your feasible set is made up of the intersection of two halfspaces (each of your inequalities represents a halfspace regardless of the direction of the inquality), the overall set is also convex. See Boyd and Vandenberghe's textbook, Chapter 2, for more details (the pdf is available for free online). &lt;/p&gt;&#xA;" OwnerUserId="3523" LastActivityDate="2020-05-17T21:56:20.233" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4177" PostTypeId="1" AcceptedAnswerId="4197" CreationDate="2020-05-17T23:06:57.633" Score="5" ViewCount="1161" Body="&lt;p&gt;I was recently asked to physically interpret a &lt;em&gt;dual&lt;/em&gt; of an LP for an audience who does not know mathematics/OR (without LP, dual, bounds, etc.). Though I attempted it and was very close to what the person wanted to hear (he said that), I did not meet his exact expectations (I am assuming). I am curious to know such possible interpretation(s). Please try to answer without maths and as short as possible. Also, is it possible to explain the dual without using the meaning of primal, i.e., does the dual makes any physical-sense if the primal is not present? If yes, what is it that we are minimizing in the following dual and what do the following dual constraints represent?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The optimization problem at hand:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A person has two products, A &amp;amp; B, with per unit cost &lt;span class=&quot;math-container&quot;&gt;$C_A$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$C_B$&lt;/span&gt;, respectively. The person has total investment capital &lt;span class=&quot;math-container&quot;&gt;$C_T$&lt;/span&gt;. It is necessary to purchase at least &lt;span class=&quot;math-container&quot;&gt;$A_m$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$B_m$&lt;/span&gt; units of the respective products. The optimization problem is to maximize the units that can be purchased while satisfying the above requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just for reference, I formulated the following &lt;em&gt;primal&lt;/em&gt; &amp;amp; &lt;em&gt;dual&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Primal:&lt;/strong&gt;&#xA;Let us assume the primal variables be &lt;span class=&quot;math-container&quot;&gt;$x_A$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$x_B$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;maximize &lt;span class=&quot;math-container&quot;&gt;$(x_A + x_B)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;s.t.:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_A &amp;amp;\geq A_m \tag1\\&#xA;x_B &amp;amp;\geq B_m \tag2\\&#xA;C_A.x_A + C_B.x_B &amp;amp;\leq C_T \tag3\\&#xA;A_m, B_m &amp;amp;\ge 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Dual:&lt;/strong&gt; Let us assume the dual variables corresponding to constraints (1), (2), (3) be &lt;span class=&quot;math-container&quot;&gt;$y_A, y_B, y_T$&lt;/span&gt;, respectively&lt;/p&gt;&#xA;&#xA;&lt;p&gt;minimize &lt;span class=&quot;math-container&quot;&gt;$(C_T.y_T - A_m.y_A - B_m.y_B)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;s.t.:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;C_A.y_T - y_A &amp;amp;\geq 1 \tag4\\&#xA;C_B.y_T - y_B &amp;amp;\geq 1 \tag5\\&#xA;y_A, y_B, y_T &amp;amp;\geq 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2999" LastEditorUserId="500" LastEditDate="2020-05-17T23:42:54.860" LastActivityDate="2020-05-18T20:45:24.260" Title="Physical Interpretation of a dual of an LP" Tags="|linear-programming|duality|dual|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4178" PostTypeId="2" ParentId="4170" CreationDate="2020-05-18T05:42:20.257" Score="17" Body="&lt;p&gt;Nikos Kazazakis and EhsanK have given you great reasons for using Python. I will focus on the point from you about needing to use an additional package/library in Python for matrix and vector operations.&#xA;In industry projects you will encounter many challenges and things you want to do, but you don't want to (and shouldn't) implement. Currently I work on a route planning software, most of what I do is sadly not core optimization work, but everything needed to making it useful for customers. Make imports from various data sources, integrating the data into objects (doing this in a non object oriented language would be annoying), make your product available via an API, and so on. This is to say I use a lot of things that come not out of the box. Adding numpy to that list of imports for the optimization work won't break the camel's back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All this is to say: needing to import an additional library for functionality shouldn't be used to determine usefulness of a language most of the time ;).&lt;/p&gt;&#xA;" OwnerUserId="296" LastEditorUserId="296" LastEditDate="2020-05-18T05:47:36.790" LastActivityDate="2020-05-18T05:47:36.790" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4179" PostTypeId="1" CreationDate="2020-05-18T08:32:39.587" Score="4" ViewCount="2298" Body="&lt;p&gt;I want to solve an integer programming problem using the &lt;strong&gt;branch and bound&lt;/strong&gt; method, but I'm having trouble finding the programming code. From what I saw, almost all algorithms use it for traveling salesman problems or job assignment cases. I need the branch and bound algorithm code to solve the problem of integer programming for &lt;strong&gt;optimization&lt;/strong&gt; cases, with the aim of &lt;strong&gt;maximization&lt;/strong&gt; or &lt;strong&gt;minimization&lt;/strong&gt;. Does anyone have a source regarding branch and bound code for the optimization case? Or can anyone suggest where I can find the code? If anyone has it, please let me know. Any programming language doesn't matter as long as it can solve the problem of maximization or minimization in integer programming problems. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="3495" LastActivityDate="2020-11-18T16:57:55.263" Title="Branch and bound algorithm programming code" Tags="|optimization|python|integer-programming|branch-and-bound|matlab|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4180" PostTypeId="2" ParentId="4170" CreationDate="2020-05-18T10:45:52.210" Score="15" Body="&lt;p&gt;I work for a company that offers a commercial optimization solver. The solver offers interfaces to both MATLAB and Python for solving problems defined in those languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We only get one or two queries about MATLAB interfacing with our product per year, but we get many times that amount of questions on interfacing Python with our product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many bluechip and non B.C companies already have Python in heavy use.&#xA;If I were you, I would concentrate on becoming knowledgeable with Python, not just for optimization purposes, but it's very useful in other areas of computing too. &lt;/p&gt;&#xA;" OwnerUserId="3537" LastEditorUserId="1160" LastEditDate="2020-05-18T19:35:18.960" LastActivityDate="2020-05-18T19:35:18.960" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4181" PostTypeId="2" ParentId="4179" CreationDate="2020-05-18T11:07:10.013" Score="5" Body="&lt;p&gt;There are several open-source software packages that use branch-and-bound to solve integer programming, for example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GLPK: &lt;a href=&quot;https://www.gnu.org/software/glpk&quot; rel=&quot;noreferrer&quot;&gt;https://www.gnu.org/software/glpk&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;CBC: &lt;a href=&quot;https://github.com/coin-or/Cbc&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/coin-or/Cbc&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="126" LastActivityDate="2020-05-18T11:07:10.013" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4182" PostTypeId="1" AcceptedAnswerId="4208" CreationDate="2020-05-18T12:49:38.587" Score="1" ViewCount="1355" Body="&lt;p&gt;I am currently modelling a supply problem that attempts to optimise a rail schedule which moves products from a production plant, to a warehouse to satisfy sales.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The model is working fine (thanks in part to OR!) however I would like to create a variable that shows the extent of a supply shortfall. Currently if the current inventory is 0, and demand is &gt; 0, then the model is unable to satisfy the constraints and returns 'Infeasible'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to define a slack/soft constraint that captures the shortfall so that the end result is always 'optimal' even though a shortfall is realised, and shows this extent. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately my current soft constraint is not recognised by the model and the output is still 'infeasible'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Desired outcome&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;desired_output_df.head(10)&#xA;&#xA;&amp;gt;&amp;gt;&amp;gt;&#xA;&#xA;date            product      current_inventory     sales_demand     inventory_shortfall&#xA;'2020-01-01'    'AFM'        10000                 5000             0&#xA;'2020-01-02'    'AFM'        5000                  5000             0&#xA;'2020-01-03'    'AFM'        0                     6000             6000&#xA;&#xA;&#xA;# Sales Demand&#xA;# Storage levels must meet sales demand&#xA;for date, grade in storage_inventory_vars:&#xA;  model += storage_inventory_vars[date, product] \&#xA;      + insufficient_storage_supply[(date, product)] \&#xA;      &amp;gt;= sales_demand[date][product]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The variable &lt;code&gt;insufficient_supply[(date, product)]&lt;/code&gt; is the key slack constraint here that I would like to measure as it should prevent an infeasible solution (owing to insufficient supply to meet demand). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can observe in the sales demand data on the 2020-05-18 and 19 that there is a very large spike in demand for AFE so that it greatly exceeds supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, if &lt;code&gt;storage_inventory_vars['2020-05-18, 'AFE']&lt;/code&gt; == 50,000 then &lt;code&gt;insufficient_supply[('2020-05-18, 'AFE')]&lt;/code&gt; should == -50,000. The sum should then produce an optimal solution is the sum is greater than the demand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All help very gratefully received, thank you.&lt;/p&gt;&#xA;" OwnerUserId="3395" LastEditorUserId="3395" LastEditDate="2020-05-19T09:40:13.580" LastActivityDate="2020-05-19T09:40:13.580" Title="Pulp: slack variable to identify &amp; measure extent infeasible in supply problem" Tags="|optimization|mixed-integer-programming|linear-programming|python|pulp|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4183" PostTypeId="2" ParentId="4179" CreationDate="2020-05-18T14:40:32.673" Score="5" Body="&lt;p&gt;Depending on the type of your MIP, there are numerous open-source options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MILP: &lt;a href=&quot;https://github.com/coin-or/Cbc&quot; rel=&quot;noreferrer&quot;&gt;CBC&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Convex MINLP: &lt;a href=&quot;https://github.com/coin-or/Bonmin&quot; rel=&quot;noreferrer&quot;&gt;Bonmin&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Non-convex MINLP: &lt;a href=&quot;https://github.com/coin-or/Couenne&quot; rel=&quot;noreferrer&quot;&gt;Couenne&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All of the above: &lt;a href=&quot;https://scip.zib.de/&quot; rel=&quot;noreferrer&quot;&gt;SCIP&lt;/a&gt; (free for academics)&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-05-18T14:40:32.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4184" PostTypeId="1" CreationDate="2020-05-18T15:18:15.990" Score="2" ViewCount="70" Body="&lt;p&gt;There are &lt;span class=&quot;math-container&quot;&gt;$N - \{1 \ldots N\}$&lt;/span&gt; jobs, each with processing time &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt;, to be scheduled on &lt;span class=&quot;math-container&quot;&gt;$M - \{1 \ldots M\}$&lt;/span&gt; machines over span of &lt;span class=&quot;math-container&quot;&gt;$D - \{1 \ldots D\}$&lt;/span&gt; days and while working &lt;span class=&quot;math-container&quot;&gt;$T - \{1 \ldots E \ldots T\}$&lt;/span&gt; hours at most each day. You can have factory working overtime after time period &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; (5 pm), at extra cost but not after &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;. To use a machines, there is a fixed cost per day per machine. No cost is incurred if you choose not to use the machine. If the job is scheduled on a machine, there is a constraint to ensure that machine is used. There is a &lt;strong&gt;penalty&lt;/strong&gt; / &lt;strong&gt;reward&lt;/strong&gt; for starting the job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at a particular time slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; between &lt;span class=&quot;math-container&quot;&gt;$\{1 \ldots T\}$&lt;/span&gt; on machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, for each day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;. Basically, there exist a penalty or reward cost for starting a job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The goal is to schedule each job so that  1) you can reduce the cost of working overtime 2) reduce the fixed cost 3) You want to reduce penalty cost. Note that schedule specifies the job, the machine it is assigned to, time slot when it should start, and the day on which it should be scheduled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{idtm}$&lt;/span&gt; = 1 if job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; and starts in time slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, 0 otherwise. &#xA;&lt;span class=&quot;math-container&quot;&gt;$Q_{dm} \in \{0,1\}$&lt;/span&gt; captures if machine is used or not each day. &lt;span class=&quot;math-container&quot;&gt;$C_f$&lt;/span&gt; is fixed cost.&#xA;&lt;span class=&quot;math-container&quot;&gt;$O_{dm} \in \{0,1\}$&lt;/span&gt; captures if overtime was used in the machine.&lt;span class=&quot;math-container&quot;&gt;$C_o$&lt;/span&gt; is overtime cost&#xA;There is penalty term in addition to fixed machine cost and overtime cost,&#xA;&lt;span class=&quot;math-container&quot;&gt;$(+ \alpha_{idtm} * X_{idtm})$&lt;/span&gt; where  &lt;span class=&quot;math-container&quot;&gt;$\alpha_{idtm}$&lt;/span&gt; can be positive or negative. Note that  &lt;span class=&quot;math-container&quot;&gt;$\alpha_{idtm}$&lt;/span&gt; is a parameter. &#xA;&lt;span class=&quot;math-container&quot;&gt;$Y_{idtm} \in \{0,1\}$&lt;/span&gt; this variable keeps machine busy for &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt; duration from time t if job is started at time t. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is, as I increase the problem size, this model takes hours. I would like to know what my options are to speed things up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) I have one constraint to break symmetry to open machines in order as shown below (used by Denton et al.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Q_{dm} \geq Q_{dm'} \quad \forall m \in M, \qquad \forall m' &amp;gt; m \qquad  \forall m' \in M, \qquad \forall d \in \delta $&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) I have constraint to not schedule jobs if it goes beyond time T, i.e. fixing some of &lt;span class=&quot;math-container&quot;&gt;$X_{idtm} = 0 $&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are few other questions,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) What are other things that I am missing on? The model provides me solution fairly quickly if I am scheduling 10 jobs or so, how can I speed it up,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Is there any advantage of discretizing time slot as I have done with &lt;span class=&quot;math-container&quot;&gt;${idtm}$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can please point me to right references,&lt;/p&gt;&#xA;" OwnerUserId="3520" LastEditorUserId="3520" LastEditDate="2020-05-18T19:22:44.440" LastActivityDate="2020-05-18T19:22:44.440" Title="What are the efficient ways to model this scheduling problem and ways to improve running time" Tags="|optimization|mixed-integer-programming|modeling|combinatorial-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4185" PostTypeId="1" CreationDate="2020-05-18T15:22:45.613" Score="23" ViewCount="3167" Body="&lt;p&gt;I am looking for applications of OR for &lt;em&gt;good causes&lt;/em&gt;, possibly with some literature. I intend a &lt;em&gt;good cause&lt;/em&gt; loosely defined in the sense that the scope is that of improving the well-being of others, e.g., fighting poverty, raising charity funds, ethical use of resources, fighting hunger, saving lives, or similar scopes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware of the risk of this question being too vague. Nevertheless, I believe there are good resources out there. &lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="766" LastEditDate="2020-05-21T13:08:32.803" LastActivityDate="2020-05-21T13:08:32.803" Title="What are Operations Research applications for 'good causes'?" Tags="|optimization|reference-request|applications|" AnswerCount="9" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4186" PostTypeId="2" ParentId="4185" CreationDate="2020-05-18T15:51:57.850" Score="18" Body="&lt;p&gt;A great cause would be supply chain in countries/regions with poor infrastructure and/or uncertain supply and high price fluctuations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is particularly important in many developing countries, because getting supplies to their destination and being able to do so on time is not straightforward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another amazing cause is to formulate &amp;amp; solve travelling salesman problems in order to figure out how medical personnel can effectively vaccinate a population, both before &amp;amp; during an outbreak.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These problems have absolutely unique constraints and dynamics, e.g., figuring out how to create herd immunity whilst avoiding a certain peninsula because warlords have been at war with each other &amp;amp; raiding villages for the last 3 months.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can imagine, niche technical expertise is not easy to find in NGOs &amp;amp; charities, and neither is specialised software for their unique needs, so these kinds of technical contributions can have massive impact in improving people's lives.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are numerous ways to participate, e.g. through student initiatives, clubs, and internships for our younger people, or pro-bono work for the professionals. A notable factor here is the Bill &amp;amp; Melinda Gates Foundation, which has been instrumental in funding technological solutions in developing &amp;amp; developed countries alike - it's worth checking out their full range of activities for more details.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-05-18T15:51:57.850" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4188" PostTypeId="2" ParentId="4185" CreationDate="2020-05-18T16:49:54.727" Score="11" Body="&lt;p&gt;A new webinar series was just started: &lt;a href=&quot;https://connect.informs.org/communities/community-home/digestviewer/viewthread?MessageKey=f1281d62-2255-47ab-90df-05402146913c&quot; rel=&quot;noreferrer&quot;&gt;Analytics for a Better World&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first two presentations cover health care (ventilator distribution for COVID-19) and the poverty (food distribution).&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2020-05-18T16:49:54.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4189" PostTypeId="2" ParentId="4185" CreationDate="2020-05-18T18:59:26.680" Score="7" Body="&lt;p&gt;Partially overlapping with the other answers, but healthcare is a field where OR has many applications. See for example the &lt;a href=&quot;https://www.journals.elsevier.com/operations-research-for-health-care&quot; rel=&quot;noreferrer&quot;&gt;Operations Research in Healtcare Journal&lt;/a&gt;, or &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/pdf/10.1111/j.1475-3995.2010.00767.x?casa_token=mwRNEtnIgHQAAAAA:30XrYYl1Y8_OKS9PI4EAGdR8JwIMSwdMZoaQNg-bdu3_nW70ik3aC1Xp0Wwmw_D3naLPokzfg-mg9D2gzQ&quot; rel=&quot;noreferrer&quot;&gt;this survey&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;References&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;Rais, A. and Viana, A., 2011. Operations research in healthcare: a survey. International transactions in operational research, 18(1), pp.1-31.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="224" LastActivityDate="2020-05-18T18:59:26.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4190" PostTypeId="2" ParentId="4182" CreationDate="2020-05-18T19:17:47.103" Score="3" Body="&lt;p&gt;The following constraints are infeasible :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; _C129: Rail_Loadings_From_Washplant_('2020_05_22',_'ABC',_'PRE')&#xA;        + Rail_Loadings_From_Washplant_('2020_05_22',_'ABC',_'ZBF')  = 25200&#xA;&#xA; _C134: Rail_Loadings_From_Washplant_('2020_05_23',_'ABC',_'PRE')&#xA;        + Rail_Loadings_From_Washplant_('2020_05_23',_'ABC',_'ZBF')  = 25200&#xA;&#xA; _C161: Rail_Loadings_From_Washplant_('2020_05_22',_'ABC',_'ZBF')&#xA;        + Port_Inventory_Levels_('2020_05_21',_'ZBF')&#xA;        - Port_Inventory_Levels_('2020_05_22',_'ZBF')  = 200000&#xA;&#xA; _C165: Rail_Loadings_From_Washplant_('2020_05_23',_'ABC',_'ZBF')&#xA;        + Port_Inventory_Levels_('2020_05_22',_'ZBF')&#xA;        - Port_Inventory_Levels_('2020_05_23',_'ZBF')  = 200000&#xA;&#xA; _C241: Port_Inventory_Levels_('2020_05_21',_'ZBF') &amp;lt;= 200000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think there is a problem with your inventory equations. Not exactly sure where yet. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finding the exact error is not that easy. Either there is a typo, either the model is not written correctly. My suggestion : back to basics, write the equations of the linear problem, and before anything, lets see if the model is properly written. &lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-05-18T19:17:47.103" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4192" PostTypeId="1" AcceptedAnswerId="4194" CreationDate="2020-05-18T19:52:40.837" Score="21" ViewCount="2962" Body="&lt;p&gt;I think that the shortest path problem is probably the problem that is solved most often. But if we move to problems where we need more complicated solvers, like Gurobi, Cplex, and Baron? What are the problems which are solved most often in industry (or people deploy the solution)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By problems I mean something like vehicle-routing-problems, scheduling problems, etc. It would also be great to know why these types of problems are solved most often (easy to implement, easy to deploy, most money involved, ...).&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="-1" LastEditDate="2020-05-19T21:14:41.183" LastActivityDate="2023-11-23T14:43:22.320" Title="What kind of optimization problems are solved most often in practice?" Tags="|optimization|" AnswerCount="9" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4193" PostTypeId="2" ParentId="4185" CreationDate="2020-05-18T20:16:08.657" Score="5" Body="&lt;p&gt;OR also has applications in &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-319-94767-9_2&quot; rel=&quot;noreferrer&quot;&gt;voting theory&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Fair_cake-cutting&quot; rel=&quot;noreferrer&quot;&gt;fair divisions&lt;/a&gt; (best way to cut a cake).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;a href=&quot;http://www.science4all.org/article/fair-division/&quot; rel=&quot;noreferrer&quot;&gt;guy&lt;/a&gt; did his PhD on fairness (envy-freeness), applied to scheduling for employees.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-05-18T20:16:08.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4194" PostTypeId="2" ParentId="4192" CreationDate="2020-05-18T20:18:36.590" Score="22" Body="&lt;p&gt;The two problems that come to my mind are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Vehicle routing problem:&lt;/strong&gt; solved tens of thousands of times per day by UPS/FedEx/other package carriers&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Optimal power flow problem:&lt;/strong&gt; solved every 5-15 minutes by nearly every independent system operator (ISO) in every modern power grid&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-05-18T20:18:36.590" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4195" PostTypeId="2" ParentId="4185" CreationDate="2020-05-18T20:26:34.487" Score="5" Body="&lt;p&gt;There's not much documentation (and no literature), and the applications are pretty basic, but you can find blurbs on several projects with nonprofits at the INFORMS Pro Bono Analytics &quot;&lt;a href=&quot;https://connect.informs.org/probonoanalytics/our-work&quot; rel=&quot;noreferrer&quot;&gt;Our Work&lt;/a&gt;&quot; page. The Operational Research Society's &lt;a href=&quot;https://www.theorsociety.com/get-involved/pro-bono-or/&quot; rel=&quot;noreferrer&quot;&gt;Pro Bono OR&lt;/a&gt; page also has links to examples of their work.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-18T20:26:34.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4196" PostTypeId="2" ParentId="4179" CreationDate="2020-05-18T20:36:55.803" Score="5" Body="&lt;p&gt;If you want to work inside Excel (or LibreOffice), you might look at &lt;a href=&quot;https://opensolver.org/&quot; rel=&quot;noreferrer&quot;&gt;OpenSolver&lt;/a&gt;. Google's &lt;a href=&quot;https://developers.google.com/optimization&quot; rel=&quot;noreferrer&quot;&gt;OR-Tools&lt;/a&gt; includes the CBC solver and the option to use GLPK, SCIP or Gurobi. (Gurobi is commercial software with a free academic license.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-18T20:36:55.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4197" PostTypeId="2" ParentId="4177" CreationDate="2020-05-18T20:45:24.260" Score="5" Body="&lt;p&gt;The dual variables represent the marginal effect on the primal objective (total units purchased) per unit change in each primal constraint limit. So increasing (decreasing) the required amount &lt;span class=&quot;math-container&quot;&gt;$A_m$&lt;/span&gt; of product &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; by a small amount will reduce (increase) the total purchase quantity (TPQ to save me future typing) by &lt;span class=&quot;math-container&quot;&gt;$y_A$&lt;/span&gt; times the change. The interpretation of &lt;span class=&quot;math-container&quot;&gt;$y_B$&lt;/span&gt; is similar. Increasing (decreasing) the total capital &lt;span class=&quot;math-container&quot;&gt;$C_T$&lt;/span&gt; will increase (decrease) the TPQ by &lt;span class=&quot;math-container&quot;&gt;$y_T$&lt;/span&gt; times the change in capital. All these statements apply only for changes in each parameter within some range (which you can determine from the final primal solution).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can think of the dual as a &quot;pricing&quot; problem, in which you are calculating marginal values (in TPQ) of a unit of each &quot;resource&quot; (required minimum, total capital). The constraints ensure that your prices sufficiently explain the primal objective; the dual objective (minimization) prevents you from &quot;overpricing&quot; resources.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-18T20:45:24.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4198" PostTypeId="1" CreationDate="2020-05-18T22:11:58.333" Score="2" ViewCount="433" Body="&lt;p&gt;I looking to learn to use bpcolumn generation techniques in c++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does any body know of GitHub repository or any other site where I can find some code And learn about it...&#xA;The application can be anything like a vrp....&lt;/p&gt;&#xA;" OwnerUserId="899" LastActivityDate="2020-05-18T23:14:30.460" Title="C++ code for branch and price" Tags="|column-generation|c++|branch-and-price|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4199" PostTypeId="2" ParentId="4185" CreationDate="2020-05-18T23:07:13.537" Score="10" Body="&lt;p&gt;Ifors has an &lt;a href=&quot;http://ifors.org/developing_countries/index.php/Main_Page&quot; rel=&quot;noreferrer&quot;&gt;entire page&lt;/a&gt; titled &quot;Developing Countries OR Resources&quot;, where they list resources in topics such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Agriculture&lt;/li&gt;&#xA;&lt;li&gt;Communication&lt;/li&gt;&#xA;&lt;li&gt;Community OR&lt;/li&gt;&#xA;&lt;li&gt;Current Events&lt;/li&gt;&#xA;&lt;li&gt;Education&lt;/li&gt;&#xA;&lt;li&gt;Energy&lt;/li&gt;&#xA;&lt;li&gt;Environment&lt;/li&gt;&#xA;&lt;li&gt;Health&lt;/li&gt;&#xA;&lt;li&gt;Industry&lt;/li&gt;&#xA;&lt;li&gt;Infrastructure&lt;/li&gt;&#xA;&lt;li&gt;Labour&lt;/li&gt;&#xA;&lt;li&gt;Law Enforcement&lt;/li&gt;&#xA;&lt;li&gt;Safety&lt;/li&gt;&#xA;&lt;li&gt;General Articles&lt;/li&gt;&#xA;&lt;li&gt;Finance&lt;/li&gt;&#xA;&lt;li&gt;Transportation&lt;/li&gt;&#xA;&lt;li&gt;Free OR Software&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="136" LastActivityDate="2020-05-18T23:07:13.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4200" PostTypeId="2" ParentId="4198" CreationDate="2020-05-18T23:14:30.460" Score="4" Body="&lt;p&gt;Out of the multiple options, the open-source option is Coin-OR's BCP (Branch-Cut-Price) [&lt;a href=&quot;https://github.com/coin-or/Bcp&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;]. SCIP also offers branch-and-price via its GCG    (generic branch-cut-and-price) solver [&lt;a href=&quot;https://gcg.or.rwth-aachen.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;].&lt;/p&gt;&#xA;" OwnerUserId="2999" LastActivityDate="2020-05-18T23:14:30.460" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4201" PostTypeId="2" ParentId="4185" CreationDate="2020-05-18T23:29:18.243" Score="7" Body="&lt;p&gt;The journal &lt;a href=&quot;https://www.journals.elsevier.com/socio-economic-planning-sciences&quot; rel=&quot;noreferrer&quot;&gt;Socio-Economic Planning Sciences&lt;/a&gt; often publishes such OR papers. Some recent examples include papers on &lt;a href=&quot;https://doi.org/10.1016/j.seps.2017.09.001&quot; rel=&quot;noreferrer&quot;&gt;public school districting&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; and &lt;a href=&quot;https://doi.org/10.1016/j.seps.2018.03.002&quot; rel=&quot;noreferrer&quot;&gt;facility location for humanitarian relief&lt;/a&gt;.&lt;sup&gt;2&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;INFORMS has a paper competition on &quot;&lt;a href=&quot;https://www.informs.org/Recognizing-Excellence/INFORMS-Prizes/Doing-Good-with-Good-OR-Student-Paper-Competition&quot; rel=&quot;noreferrer&quot;&gt;Doing Good with Good OR&lt;/a&gt;,&quot; which has included work related to &lt;a href=&quot;https://doi.org/10.1287/inte.1110.0570&quot; rel=&quot;noreferrer&quot;&gt;managing volunteers&lt;/a&gt;&lt;sup&gt;3&lt;/sup&gt; and &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/inte.1100.0511&quot; rel=&quot;noreferrer&quot;&gt;Hepatitis B interventions&lt;/a&gt;.&lt;sup&gt;4&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also included a couple of literature reviews&lt;sup&gt;5, 6&lt;/sup&gt; which you might find interesting.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;(1) E. Bouzarth et al. &quot;Assigning students to schools to minimize both transportation costs and socioeconomic variation between schools.&quot; &lt;em&gt;Socio-Economic Planning Sciences&lt;/em&gt; 64: 1-8, 2018. &lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;(2) N. Cotes and V. Cantillo. &quot;Including deprivation costs in facility location models for humanitarian relief logistics.&quot; &lt;em&gt;Socio-Economic Planning Sciences&lt;/em&gt; 65: 89-100, 2019. &lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;(3) M. Falasca et al. &quot;Helping a small development organization manage volunteers more efficiently.&quot; &lt;em&gt;Interfaces&lt;/em&gt; 41(3): 254-262, 2011.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;(4) D. Hutton et al. &quot;Doing good with good OR: supporting cost-effective Hepatitis B interventions.&quot; &lt;em&gt;Interfaces&lt;/em&gt; 41(3): 289-300, 2011.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;(5) M. Johnson et al. &quot;&lt;a href=&quot;https://doi.org/10.1016/j.ejor.2017.11.032&quot; rel=&quot;noreferrer&quot;&gt;Emerging trends and new frontiers in community operational research&lt;/a&gt;.&quot; &lt;em&gt;European Journal of Operational Research&lt;/em&gt; 268(3): 1178-1191, 2018. &lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;(6) P. Leclerc et al. &quot;&lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-1-4614-0806-2_4&quot; rel=&quot;noreferrer&quot;&gt;Modeling equity for allocating public resources&lt;/a&gt;.&quot; In &lt;em&gt;Community-Based Operations Research&lt;/em&gt;: 91-118, 2011. &lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="196" LastActivityDate="2020-05-18T23:29:18.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4202" PostTypeId="2" ParentId="4192" CreationDate="2020-05-18T23:54:52.777" Score="5" Body="&lt;p&gt;Staff scheduling problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Knapsack problem: Allocation of resource/time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Location allocation.&lt;/p&gt;&#xA;" OwnerUserId="1219" LastEditorUserId="1219" LastEditDate="2020-05-20T20:29:10.287" LastActivityDate="2020-05-20T20:29:10.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4203" PostTypeId="2" ParentId="4185" CreationDate="2020-05-18T23:57:28.737" Score="4" Body="&lt;p&gt;Boston school bus routing and bell time optimization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gsb.stanford.edu/sites/gsb/files/jmp_sebastien-martin.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gsb.stanford.edu/sites/gsb/files/jmp_sebastien-martin.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1219" LastActivityDate="2020-05-18T23:57:28.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4204" PostTypeId="1" CreationDate="2020-05-19T00:52:44.377" Score="1" ViewCount="208" Body="&lt;p&gt;I'm modeling a CVRPTW with some features:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Each type of vehicle has a cost per km and a fixed cost per trip. To calculate these costs, I am using these methods for this:&#xA;&lt;code&gt;setSpanCostCoefficientForVehicle&lt;/code&gt; and &lt;code&gt;setFixedCostOfVehicle&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each customer has a time window where they can be visited. I'm using this method for this:&#xA;&lt;code&gt;solver.addConstraint(solver.makeNotMemberCt(transitTimeDimensionCumulVar, forbiddenWindow.starts, forbiddenWindow.ends)&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So far, everything is working correctly but now, a requirement has arisen to add an extra fixed cost if a vehicle has been idle(slacking) for more than 4 hours at a customer. A vehicle can wait for the opening time of the next customer before leaving.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm in doubt about how I can add a fixed cost for SlackVar on each node or something like &lt;code&gt;setSlackVarSoftUpperBound&lt;/code&gt;.&#xA;Is it possible to add a fixed cost associated with each customer's SlackVar? This cost does not apply to waiting at the depot. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using ORTools 7.6 with Java&lt;/p&gt;&#xA;" OwnerUserId="3561" LastActivityDate="2022-10-01T06:30:38.667" Title="Fixed cost associated to SlackVar(waiting time cost) [CVRPTW]" Tags="|constraint-programming|or-tools|vehicle-routing|java|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4205" PostTypeId="2" ParentId="4192" CreationDate="2020-05-19T04:11:22.353" Score="17" Body="&lt;ul&gt;&#xA;&lt;li&gt;Variations of bin packing problem (2D or 3D), when dealing with putting items in trucks or putting items in boxes (think of the times you order several items online and they all arrive in one big box)&lt;/li&gt;&#xA;&lt;li&gt;Network design and flow problems, especially for making strategic decisions: where to locate warehouses to serve customers from different plants; during a pandemic or disaster, which plant or warehouse to shut down and where to allocate its loads, etc.&lt;/li&gt;&#xA;&lt;li&gt;Many applications in the airline industry such as flight/crew scheduling and revenue management&lt;/li&gt;&#xA;&lt;li&gt;Many applications in the railroad such as routing, train scheduling, freight car assignment, and capacity optimization&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;About the reasons for why they are solved most often: Saving cost, maximizing profit, improve customer service, mitigate risks, ... essentially whatever is your objective function in that specific industry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good source for OR applications in practice is &lt;a href=&quot;https://www.informs.org/Publications/INFORMS-Journals/INFORMS-Journal-on-Applied-Analytics&quot; rel=&quot;noreferrer&quot;&gt;INFORMS Journal on Applied Analytics&lt;/a&gt; (formerly, Interfaces). Also, there are some good answers about good-cause OR applications in &lt;a href=&quot;https://or.stackexchange.com/questions/4185/what-are-operation-research-applications-for-good-causes&quot;&gt;this&lt;/a&gt; question. I suggest that you search for an industry that you're interested in to find more about OR applications there.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2020-05-19T04:11:22.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4206" PostTypeId="2" ParentId="4192" CreationDate="2020-05-19T06:23:41.083" Score="17" Body="&lt;p&gt;In finance the Markowitz portfolio optimization problem and variants thereof solved a huge number of times every day in (semi) automatic trading systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Traditionally these problems is formulated as a convex QP but these days they are often formulated as a conic optimization problem. &lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2020-05-19T06:23:41.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4207" PostTypeId="2" ParentId="4170" CreationDate="2020-05-19T09:18:48.877" Score="8" Body="&lt;p&gt;I did my PhD on a topic involving numerical simulations of mechanical systems. I worked primarily in MATLAB, which I already had experience in and seemed to have some good 'out of the box' optimisation algorithms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking back, I wish I did my work in Python. I work in Software Engineering now and Python is a lot more applicable to other languages and looks better on a CV. Also - as mentioned by others here - Python is open source. This means that your results would be more accessible by others and easier to reproduce (a big plus for research).&lt;/p&gt;&#xA;" OwnerUserId="3573" LastActivityDate="2020-05-19T09:18:48.877" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4208" PostTypeId="2" ParentId="4182" CreationDate="2020-05-19T09:39:40.930" Score="1" Body="&lt;p&gt;I found the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- The storage inventory definition is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model += storage_stockpile_current[product] \&#xA;              + pulp.lpSum(&#xA;                    train_consignment_variables[(date, plant, product)] &#xA;                    for plant in _plants_combo) \&#xA;              - sales_demand[date][product] \&#xA;              == storage_inventory_vars[(date, product)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2 - Given the addition of the slack constraint:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for date, grade in storage_inventory_vars:&#xA;  model += storage_inventory_vars[date, product] \&#xA;      + insufficient_storage_supply[(date, product)] \&#xA;      &amp;gt;= sales_demand[date][product]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whenever sales_demand greatly exceeds the storage variable, the equation becomes inbalanced, because it has a lower bound of 0, i.e. cannot be negative. Therefore the definition needs to reflect this slack constraint:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model += storage_stockpile_current[product] \&#xA;              + pulp.lpSum(&#xA;                    train_consignment_variables[(date, plant, product)] &#xA;                    for plant in _plants_combo) \&#xA;              - sales_demand[date][product] \&#xA;              + insufficient_storage_supply[(date, product)] \&#xA;              == storage_inventory_vars[(date, product)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A big thank you to Kuifje for their help.&lt;/p&gt;&#xA;" OwnerUserId="3395" LastActivityDate="2020-05-19T09:39:40.930" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4209" PostTypeId="1" CreationDate="2020-05-19T11:14:14.883" Score="2" ViewCount="193" Body="&lt;p&gt;The conditional constraints A and B can be transformed to a set of linear integer constraints as follows: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A) &lt;span class=&quot;math-container&quot;&gt;$\text{if} \ x_1=0 \ \text{then} \ d_1=1 \ \text{else} \ d_1= 0\\ x_1\in {\rm I\!R}^{\geq 0} , d_1 \in \{0,1\}, M=10^6, m=10^{-6}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;transformed to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\qquad \text{A1)} \quad m(1-d_1) \leq x_1 \leq M(1-d_1)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;B) &lt;span class=&quot;math-container&quot;&gt;$\text{if} \ x_2 &amp;lt; K \ \text{then} \ y= x_2 \ \text{else} \ y \leq K;\\ x_2,y \in {\rm I\!R}^{\geq 0}, d_2 \in \{0,1\}, \\ K \text{ is positive constant}$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;transformed to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\qquad \text{B1)}\ y \leq K $&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\qquad \text{B2)}\ {-M} \cdot (1-d_2) \leq x_2 - K \leq M \cdot d_2$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\qquad \text{B3)}\ {-M} \cdot d_2 \leq x_2 - y \leq M \cdot d_2 $&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Q1) Is the above transformation correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q2) How can I formulate A and B in a more efficient way (such as convex-hull) rather than the big-M method ?&lt;/p&gt;&#xA;" OwnerUserId="3500" LastEditorUserId="1198" LastEditDate="2020-05-20T19:56:21.137" LastActivityDate="2020-05-20T19:56:21.137" Title="How to transform these conditional constraints to linear integer ones in a more efficient way?" Tags="|optimization|big-m|indicator-constraints|convex-hull|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4210" PostTypeId="1" AcceptedAnswerId="4212" CreationDate="2020-05-19T11:43:18.690" Score="3" ViewCount="1136" Body="&lt;p&gt;Any one had the chance to use pyomo with free/open-source solvers that handle quadratic optimization problems, which they could be convex or not, but preferably as general as possible.&lt;/p&gt;&#xA;" OwnerUserId="2599" LastEditorUserId="500" LastEditDate="2023-05-25T16:13:48.837" LastActivityDate="2023-05-25T16:13:48.837" Title="Supported pyomo free solvers for (non-convex) quadratic programming" Tags="|solver|pyomo|quadratic-programming|nonconvex-programming|open-source|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4211" PostTypeId="1" AcceptedAnswerId="4219" CreationDate="2020-05-19T12:31:27.240" Score="3" ViewCount="112" Body="&lt;p&gt;Let us first define a simplified facility location problem as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i=1}^{n}\sum_{j=1}^{m}d(i,j)x_{i.j}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;subjected to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{n} x_{i,j}\geq1, \forall j$$&lt;/span&gt;&#xA;(Every customer should be served by at least one facility)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{i,j} \leq y_{j}, \forall i,j$$&lt;/span&gt;&#xA;(If a customer is assigned to a facility, then the facility should be open)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j} y_{j} \leq 5$$&lt;/span&gt;&#xA;(Maximum number of facilities that can be opened should be less than &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{i,j} \in \{0,1\}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{j} \in \{0,1\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=1$&lt;/span&gt; if and only if customer &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is served by facility &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{i}=1$&lt;/span&gt; if and only if facility &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem that I am having is actually how to define the objective function to make it more &quot;robust&quot;. Obviously this objective function takes into account every customer and weights it as equally important. However, what I would like is to define the objective function such that customers that are very far from other customers should be weighted a bit less important. We can do this in several ways:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Define the function &lt;span class=&quot;math-container&quot;&gt;$d(i,j)$&lt;/span&gt; such that customers living more than &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt;km from the facility location have really low weights. But the &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt;km is just an arbitrary number. The problem with this method is actually determining the arbritrary number of &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt;km. What would be a good number / how would we get a good number?&lt;/li&gt;&#xA;&lt;li&gt;Similary to solution 1, we can also weigh the customers, but I am not sure how we should assign the weights.&lt;/li&gt;&#xA;&lt;li&gt;Instead of calculating the total distance, we can also compute the average distance as the objective function. Following along this idea, we can also use the median. However, I am not sure whether commercial solvers like CPLEX or Gurobi can handle a median.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My question is therefore, how can we formulate the objective function such that it is more robust to customers living really far away? What would be the best approach?&lt;/p&gt;&#xA;" OwnerUserId="563" LastActivityDate="2020-05-20T01:29:37.227" Title="Adding robustness to the objective function of the facility location problem" Tags="|facility-location|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4212" PostTypeId="2" ParentId="4210" CreationDate="2020-05-19T12:32:06.210" Score="2" Body="&lt;p&gt;For guaranteed solutions, BONMIN can solve convex MINLPs, and COUENNE can solve general non-convex MINLPs. Both use the ASL (.nl) format, so they work out of the box with Pyomo. IPOPT can also find local optima for non-convex NLP (including quadratic) problems.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-05-19T12:41:46.047" LastActivityDate="2020-05-19T12:41:46.047" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4213" PostTypeId="1" CreationDate="2020-05-19T13:19:06.580" Score="2" ViewCount="294" Body="&lt;p&gt;I am trying to solve Logarithmic Fuzzy Preference Programming (LFPP) for criteria weight evaluation, based on fuzzy comparisons between criteria, and I am solving it with Gurobi in Python 2.7. It is a basic operational research thing.&#xA;The model that solves this kind of problems is very simple (&lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the number of the criteria):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/8GtLV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8GtLV.png&quot; alt=&quot;MP model&quot; /&gt;&lt;/a&gt;&#xA;The problem is that Gurobi isn't able to solve this accurately. I have some proven solutions for a specific configuration, but my program does not yield the adequate solution. Here is the literature example that i am trying to solve:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/wSLEH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wSLEH.png&quot; alt=&quot;example from literature&quot; /&gt;&lt;/a&gt;&#xA;The &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; values from my models' output are very large (for example 420699.256539 instead of 0.6). Does anyone has an advice how to approach this? I have solved many complex and more complicated MILP, MIQP and MP problems so far, but never had an issue like this.&lt;/p&gt;&#xA;" OwnerUserId="3578" LastEditorUserId="491" LastEditDate="2021-01-16T14:36:04.170" LastActivityDate="2021-01-16T14:36:04.170" Title="Gurobi is unable to give an optimal solution even when it exists" Tags="|python|nonlinear-programming|gurobi|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4214" PostTypeId="2" ParentId="4185" CreationDate="2020-05-19T15:17:06.067" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Effective_altruism&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Effective Altruism&lt;/em&gt;&lt;/a&gt; movement aims for finding the best charities (among other things like finding the right profession). This naturally has plenty of applications of OR techniques. In the EA community, we want to find ways to save the most lives per dollar (actually, a bit more sophisticated, the most &lt;a href=&quot;https://en.wikipedia.org/wiki/Quality-adjusted_life_year&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;quality adjusted life years (QALYs)&lt;/em&gt;&lt;/a&gt; per dollar).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Out of this movement, charity evaluations have evolved (e.g. &lt;a href=&quot;https://www.givewell.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GiveWell&lt;/a&gt;). But also after such an evaluation, there are problems to solve. For example, while one charity A is better regarding cost-effectiveness. For you, the donator, it might be better to give your money to some other charity B because your donation there is tax-deducible for your country and therefore you might be able to donate more money to B, which saves more lives. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a primer, you maybe want to check out Peter Singer's book &lt;a href=&quot;https://www.thelifeyoucansave.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;The Life You Can Save&lt;/em&gt;&lt;/a&gt;, which is available as a free download. Singer is one of the leading minds of EA.&lt;/p&gt;&#xA;" OwnerUserId="130" LastEditorUserId="123" LastEditDate="2020-05-20T07:25:34.337" LastActivityDate="2020-05-20T07:25:34.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4215" PostTypeId="1" CreationDate="2020-05-19T15:23:13.677" Score="2" ViewCount="85" Body="&lt;p&gt;I had a linear programming problem with the following objective function&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f(x) = \sum_{j}x_jq_jp_j - \sum_{i}\left(\sum_{j}x_jq_jC_{ij} \right) c_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$q, p, C, c$&lt;/span&gt; are known. Let the term within parentheses be called &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then had three buckets to represent&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$c_i = \begin{cases}&#xA;        10 &amp;amp; \text{for } 0\leq A_i\leq 100\\&#xA;        8 &amp;amp; \text{for } 101\leq A_i\leq 200\\&#xA;        6 &amp;amp; \text{for } A_i \geq 201&#xA;        \end{cases}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution (provided by RobPratt) was given as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the details of your suggested approach.  Let binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,b}$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; is in bucket &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$b\in\{1,2,3\}$&lt;/span&gt;.  Let &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; be a (small) upper bound on &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt;.  The constraints are:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{b=1}^3 y_{i,b} = 1\\&#xA;10 y_{i,1} + 8 y_{i,2} + 6 y_{i,3} = c_i\\&#xA;0 y_{i,1} + 101 y_{i,2} + 201 y_{i,3} \le A_i \le 100 y_{i,1} + 200 y_{i,2} + M_i y_{i,3}&#xA;$$&lt;/span&gt;&#xA;The resulting model then has a quadratic function &lt;span class=&quot;math-container&quot;&gt;$\sum_i A_i c_i$&lt;/span&gt; in the objective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can instead get a linear objective by introducing a variable &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$A_i c_i$&lt;/span&gt;, with constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{b=1}^3 y_{i,b} = 1\\&#xA;0 y_{i,1} + 101 y_{i,2} + 201 y_{i,3} \le A_i \le 100 y_{i,1} + 200 y_{i,2} + M_i y_{i,3}\\&#xA;-M_{i,1}(1-y_{i,1}) \le z_i - 10 A_i \le M_{i,1}(1-y_{i,1})\\&#xA;-M_{i,2}(1-y_{i,2}) \le z_i - 8 A_i \le M_{i,2}(1-y_{i,2})\\&#xA;-M_{i,3}(1-y_{i,3}) \le z_i - 6 A_i \le M_{i,3}(1-y_{i,3})\\&#xA;$$&lt;/span&gt;&#xA;The resulting model then has a linear function &lt;span class=&quot;math-container&quot;&gt;$\sum_i z_i$&lt;/span&gt; in the objective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This worked perfectly. I now want to further extend the problem to the case where &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; not only depends on the summation but is multiplied by some correction factor &lt;span class=&quot;math-container&quot;&gt;$V_i$&lt;/span&gt;, subject to the following constraint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i}\left(\sum_{j}x_jC_{ij} \right) V_i = (1-WR)\cdot \sum_{i}\left(\sum_{j}C_{ij} \right) + WR \sum_{i}\left(\sum_{j}x_jC_{ij}\right)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where WR (and C) are constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem here seems to be that this constraint is non-linear (because we are multiplying &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$V_i$&lt;/span&gt; on the left hand side) and that the multiplication &lt;span class=&quot;math-container&quot;&gt;$A_iV_i$&lt;/span&gt; is also non linear. Is there a way to somehow linearize this problem?&lt;/p&gt;&#xA;" OwnerUserId="3065" LastEditorUserId="3065" LastEditDate="2020-05-19T15:28:58.093" LastActivityDate="2020-05-19T15:28:58.093" Title="Linear programming: extending problems yields non linearity" Tags="|linear-programming|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4217" PostTypeId="1" CreationDate="2020-05-19T16:32:44.013" Score="3" ViewCount="68" Body="&lt;p&gt;&lt;strong&gt;Given:&lt;/strong&gt; I have 2D non-parametric formula that provides instantaneous intensity at certain (x,y) location.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Required:&lt;/strong&gt; I want to en-circle a region where the density is high via optimization. In other words fitting a circle whose radius must be optimized such that the density is maximum at certain region. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Analogy:&lt;/strong&gt; Consider an oil spill in water (assume stationary). I want to find an area enclosed inside a circle that constitutes highest density. It is to identify most important spots that require cleaning fast. So less dense area is not cleaned first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The density can be computed by performing monte-carlo integration of the intensity values inside the a circle (size of which has to be optimized) and then dividing by the area of the circle. So if the size of circle grows so is its area. The outcome of optimization is the value of the radius of the circle and its position.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Now considering the area is huge, and the problem cannot be solved analytically, what are some of the approaches/heuristics that I can use to solve the problem? &lt;/p&gt;&#xA;" OwnerUserId="3491" LastEditorUserId="3491" LastEditDate="2020-05-20T17:02:04.703" LastActivityDate="2020-05-20T17:02:04.703" Title="Density Optimization by Fitting an Circle to a Field - Monte Carlo Method" Tags="|optimization|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="4218" PostTypeId="2" ParentId="4209" CreationDate="2020-05-19T20:59:09.900" Score="2" Body="&lt;p&gt;I don't think you can improve on A1 (which looks correct), other than perhaps tightening the bounds &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; (which would be dependent on the specifics of the problem). Regarding B, would the solver prefer larger values of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; over smaller values? (Again, this is problem dependent.) If so, you could eliminate the use of a binary variable and just use the constraints &lt;span class=&quot;math-container&quot;&gt;\begin{equation*}y\le x_2\\y \le K\end{equation*}&lt;/span&gt;(in which I'm assuming that your &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; are the same thing). If not, I think you need a big-M formulation, and yours looks correct.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-19T20:59:09.900" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4219" PostTypeId="2" ParentId="4211" CreationDate="2020-05-19T21:28:20.570" Score="5" Body="&lt;p&gt;First off, you notion of &quot;far&quot; is unavoidably subjective, so I don't think you are going to find a totally objective approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your solution 1 really looks at whether customers are far from their assigned facilities, not far from other customers. If you are going to go that route, you might consider basing it on distance to the nearest possible facility (&lt;span class=&quot;math-container&quot;&gt;$\min_j d(i,j)$&lt;/span&gt;) rather than distance to any specific facility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possibility for looking at customers' distances to other customers would be to simply compute the distance from each customer to the closest other customer, then reduce objective weights for customers far from their nearest neighbors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another would be to cluster your customers into as many clusters as the maximum number of facilities (so 5 in this case), and then compute for each customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; the ratio &lt;span class=&quot;math-container&quot;&gt;$\rho_i$&lt;/span&gt; of its distance from the cluster center to the mean or median distance from center of all customers in the cluster. If &lt;span class=&quot;math-container&quot;&gt;$\rho_i \le 1$&lt;/span&gt;, leave the coefficients of &lt;span class=&quot;math-container&quot;&gt;$x_{i,\cdot}$&lt;/span&gt; alone. If &lt;span class=&quot;math-container&quot;&gt;$\rho_i &amp;gt; 1$&lt;/span&gt;, divide &lt;span class=&quot;math-container&quot;&gt;$d(i,j)$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$\rho_i$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. You could also use the standard deviation of distances to cluster center, penalizing customers more than 1.5 or 2 (or whatever) standard deviations from the cluster center.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whatever route you take, you can do a kind of sensitivity analysis by gradually reducing objective weights for customers that meet your remoteness criterion until the number of open facilities decreases. Then you can compute the original (unweighted) distance functions for the solutions and present some options, where &quot;you save the cost of this facility by tolerating this much more distance, absorbed mostly by customers who are 'remote' from other customers&quot; (or from the nearest facility if you go the first route).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-19T21:28:20.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4220" PostTypeId="2" ParentId="4170" CreationDate="2020-05-19T21:38:43.663" Score="4" Body="&lt;p&gt;Sounds like you are intending to build solvers. You will be better off in MATLAB. As you noted, matrix and vector operations are part of the language. You'll need matrix decompositions and maybe eigenvalue solvers to build your solvers, probably for dense and sparse matrices, and MATLAB has all of those. If you find that there's a library you need in some other language, you can call it from MATLAB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are lots of solvers written in MATLAB, for example, SDPT3 and SeDuMi, the solvers inside of CVX. Besides github, look on the MATLAB File Exchange to see more. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full disclosure: I work at MathWorks. But was using MATLAB a long time before that!&lt;/p&gt;&#xA;" OwnerUserId="497" LastEditorUserId="497" LastEditDate="2020-05-22T20:53:31.303" LastActivityDate="2020-05-22T20:53:31.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4221" PostTypeId="1" CreationDate="2020-05-19T21:54:44.170" Score="6" ViewCount="95" Body="&lt;p&gt;Using the Dantzig's pivoting rule, can it be proven that the leaving variable of one round cannot be selected as the entering variable in the next round?&lt;/p&gt;&#xA;" OwnerUserId="3595" LastActivityDate="2020-05-19T21:54:44.170" Title="Proof that the leaving variable cannot be selected as the entering one in the next round" Tags="|linear-programming|simplex|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4222" PostTypeId="1" CreationDate="2020-05-19T22:55:48.997" Score="7" ViewCount="209" Body="&lt;p&gt;This question might be somewhat general and not completely relevant to this forum but I think here is the most relevant place to ask the question. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, deep learning, RL and generally black-box approaches are gaining much attention and many practitioners and academia are using these problems to solve their optimization problems. For example, in real-world prediction problems, LSTM artificial neural networks (ANNs) are common which are black-box algorithms with good accuracy but in many cases, there is no proof of convergence. However, in the field of OR/MS, the most common approaches are Time Series approaches like ARIMA. etc. Or, for example, decision trees are more popular in OR/MS because they are interpretable but with lower accuracy compared to deep learning. In this situation, AI algorithms enable researchers to use different sources of data like historical data, crawling webpages, reading news, etc. and use all of them to predict while conventional approaches in OR/MS do not let us to this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To my view, the computer science community is using approaches that are more acceptable in the industry and more applicable while OR/MS is sacrificing applicability in real-world cases to solve problems with convergence proof. For example, many papers use linear regression with unknown coefficients because they can prove that their algorithm can converge to the true values of coefficients (if the true model is also linear). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are my views based on papers published in Management Science, Operations Research, and M&amp;amp;SOM. Some people may consider this question a subjective one and wants to close this question but it is really confusing question that I cannot find the justification for some times.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="123" LastEditDate="2021-02-16T15:48:52.913" LastActivityDate="2021-02-17T16:39:35.117" Title="Interpretability Vs Accuracy in Operations Research and Management Science Community" Tags="|optimization|machine-learning|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4223" PostTypeId="2" ParentId="4211" CreationDate="2020-05-20T01:29:37.227" Score="2" Body="&lt;p&gt;I agree with @prubin's suggestions. I would also add that there are already facility location models that try to do things similar to what you are describing. For example, &quot;coverage&quot;-based models (set covering location problem, maximal coverage location problem) define a customer as &quot;covered&quot; if it is within some radius of an open facility. It's not quite the same as what you are describing, but it is similar enough that you might want to check it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you say &quot;customers that are very far from other customers&quot; do you really mean &quot;customers that are very far away from their assigned facilities&quot;? The two might be related in many cases (both will mean &quot;remote&quot; customers), but you will have to pick one approach or the other for your model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, you are going to have to make some arbitrary choices—the coverage radius, the weight threshold (e.g., 50 km), etc.—and there is probably no scientific way to choose these numbers. I agree with @prubin's suggestion to rely on sensitivity analysis to deal with that issue.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-05-20T01:29:37.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4224" PostTypeId="1" CreationDate="2020-05-20T01:29:48.477" Score="2" ViewCount="271" Body="&lt;p&gt;What are the ways to improve lower bounds while solving a minimization problem (MILP)?&lt;/p&gt;&#xA;" OwnerUserId="771" LastActivityDate="2023-12-02T01:56:32.537" Title="Ways to improve lower bounds while solving MIPs" Tags="|optimization|mixed-integer-programming|cplex|gurobi|bounds|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4226" PostTypeId="1" AcceptedAnswerId="4227" CreationDate="2020-05-20T09:25:29.193" Score="8" ViewCount="72" Body="&lt;p&gt;I have this problem described in natural language, and I was wondering whether it is relatable to any known problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a directed acyclic graph. Each node can host a &quot;probe&quot;. If node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; hosts a probe, then node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and all the nodes connected to &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; are considered &quot;probed&quot;. I have to place a number &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; of probes to maximize the number of probed nodes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It reminds me of a covering problem, but on a network: so I was wondering if there is something more specific about this or it is just a matter of abstracting the natural language description. I am mainly interested in MILP formulations, but other pointers are welcome as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="459" LastActivityDate="2020-05-20T10:21:37.690" Title="Covering problem on a network (?)" Tags="|optimization|modeling|reference-request|graphs|academia|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4227" PostTypeId="2" ParentId="4226" CreationDate="2020-05-20T09:48:37.787" Score="2" Body="&lt;p&gt;Define a binary variable &lt;span class=&quot;math-container&quot;&gt;$p_{iv}$&lt;/span&gt; for each node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if it is probed by probe &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, a binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta_{iv}$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if probe &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is located on node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, and a binary variable &lt;span class=&quot;math-container&quot;&gt;$\omega_v$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is probed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want to maximize the number of probed nodes :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \; \sum_{v} \omega_{v}&#xA;$$&lt;/span&gt;&#xA;subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\delta_{iv}+ p_{iu} &amp;amp;\le 1 &amp;amp;\forall v, \;\forall u \notin N_v , \; \forall i\\&#xA;\sum_v \delta_{iv} &amp;amp;=1 \quad &amp;amp;\forall i\\&#xA;\omega_v &amp;amp;\le \sum_i p_{iv} \quad &amp;amp;\forall v\\&#xA;p_{iv}, \delta_{iv}, \omega_v &amp;amp;\in \{0,1\} \quad &amp;amp;\forall v, \; \forall i\\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first constraint models the fact that if probe &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is located on node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, then it cannot probe all vertices that are not adjacent to &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$N_v$&lt;/span&gt; denotes &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; and its neighbors). The second constraint states that a probe can only take one location. The last constraint links variables &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\omega$&lt;/span&gt;: a node is probed if it is probed by at least one probe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are probably better formulations.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-05-20T10:21:37.690" LastActivityDate="2020-05-20T10:21:37.690" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4228" PostTypeId="1" CreationDate="2020-05-20T09:50:47.880" Score="4" ViewCount="296" Body="&lt;p&gt;I need to formulate a conditional constraint for a binary variable z defined as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{i,j,k}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\ \ i=1:10 \ , \ j=1:5 \ , \ k=1:3$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If any &lt;span class=&quot;math-container&quot;&gt;$z_{i,j,3} = 1$&lt;/span&gt; then  &lt;span class=&quot;math-container&quot;&gt;$z_{i,j,1} + z_{i,j,2} = 0 \ \  \forall i,j$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3463" LastEditorUserId="3463" LastEditDate="2020-05-20T09:55:58.097" LastActivityDate="2020-05-20T14:11:49.067" Title="Conditional Constraint in MIP" Tags="|binary-variable|logical-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4229" PostTypeId="2" ParentId="4170" CreationDate="2020-05-20T10:31:59.653" Score="4" Body="&lt;p&gt;My first language I have learned was MATLAB. After learning C++ I realized MATLAB is bad for really learning about programming in such. I would recommend you also Python as language because it is easier to switch from Python to MATLAB then in the other direction. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides the downturns of commercial and closed software you should also keep in mind that MATLAB is a working universe in itself. For example you can really quick do a program for image pattern recognition without having (to much) knowledge about image processing and link your code into another toolbox for autonomous driving (just as an example, because that is something people like to forget about MATLAB).&#xA;Python has a little bit steeper learning curve but for your case it is much worther I think. &lt;/p&gt;&#xA;" OwnerUserId="3603" LastActivityDate="2020-05-20T10:31:59.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4230" PostTypeId="2" ParentId="4228" CreationDate="2020-05-20T11:11:29.317" Score="6" Body="&lt;p&gt;How about &lt;span class=&quot;math-container&quot;&gt;$z_{i,j,1} + z_{i,j,2} \leq 2 \cdot (1 - z_{i,j,3}) \quad \forall i,j$&lt;/span&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more context, I refer you to &lt;a href=&quot;https://cs.stackexchange.com/a/12118/64655&quot;&gt;this excellent self-answer by user D.W. on CS.SX&lt;/a&gt;, which includes a link to a helpful &lt;a href=&quot;http://faculty.nps.edu/dell/docs/Formulettes060425.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;gallery of such common &quot;building blocks&quot;&lt;/a&gt;, all with practical examples stated in prose.&lt;/p&gt;&#xA;" OwnerUserId="1198" LastEditorUserId="1198" LastEditDate="2020-05-20T12:41:13.273" LastActivityDate="2020-05-20T12:41:13.273" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4231" PostTypeId="2" ParentId="4228" CreationDate="2020-05-20T14:11:49.067" Score="6" Body="&lt;p&gt;For simplicity, I will omit the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; subscripts.&#xA;Rewriting your logical proposition in conjunctive normal form somewhat automatically yields two linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;z_3 \implies (\neg z_1 \land \neg z_2) \\&#xA;\neg z_3 \lor (\neg z_1 \land \neg z_2) \\&#xA;(\neg z_3 \lor \neg z_1) \land (\neg z_3 \lor \neg z_2) \\&#xA;((1- z_3) + (1- z_1) \ge 1) \land ((1- z_3) + (1- z_2) \ge 1) \\&#xA;(z_3 + z_1 \le 1) \land (z_3 + z_2 \le 1)&#xA;\end{equation}&lt;/span&gt;&#xA;Note that the big-M constraint &lt;span class=&quot;math-container&quot;&gt;$$z_1 + z_2 \le 2(1-z_3)$$&lt;/span&gt; is weaker, being an aggregation of the previous two constraints.  For example, the big-M constraint does not cut off &lt;span class=&quot;math-container&quot;&gt;$z=(3/4,1/4,1/2)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-05-20T14:11:49.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4232" PostTypeId="2" ParentId="291" CreationDate="2020-05-20T14:39:18.107" Score="2" Body="&lt;p&gt;Column generation has been used for beam angle selection for radiation treatment planning (specifically for non-coplanar IMRT). Here's an example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S1879850013003470&quot; rel=&quot;nofollow noreferrer&quot;&gt;Feasibility of prostate robotic radiation therapy on conventional C-arm linacs&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="270" LastActivityDate="2020-05-20T14:39:18.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4233" PostTypeId="2" ParentId="4222" CreationDate="2020-05-20T23:07:33.343" Score="5" Body="&lt;p&gt;[Fair warning: old guy rant follows.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure that the computer science community's reliance on ML models (to the extent that generalization holds) is necessarily a good thing.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I've seen references to published research (can't recall any details now) on retrofitting interpretability to ML models, ostensibly because industry people are uncomfortable with the models if they cannot understand at some level the model logic.&lt;/li&gt;&#xA;&lt;li&gt;A growing issue in industry (and government) is model bias. My impression is that model bias is easier to detect and either fix or justify (as not really being bias) with interpretable models.&lt;/li&gt;&#xA;&lt;li&gt;ML models can be prone to overfitting. With an interpretable model, you can get a clue that overfitting occurred when the interpretation defies common sense / logic / the &quot;sniff&quot; test. With an ML model, you can put in penalty terms or something to try to combat overfitting, but it's a guessing game (add a lasso term and hope for the best).&lt;/li&gt;&#xA;&lt;li&gt;Sometimes, in the real world, you don't have a ton of (reliable) data. My trust in a statistical model is based on a combination of the plausibility of the assumptions (normality, IID observations, whatever) and having a &quot;decent&quot; sample size. My trust in an ML model (to the extent I have any) is based on it being trained on a really, really big sample.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-20T23:07:33.343" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4234" PostTypeId="2" ParentId="4192" CreationDate="2020-05-21T08:39:55.657" Score="4" Body="&lt;p&gt;Even though Logistics applications (ranging from simple Economic Order Quantity (EOQ), to the more complicated Multi-Indenture Multi-Echelon (MIME)) are asked to produce suggestions to practitioners very frequently, given that they are already formulated, their solutions are not quoted or cited; they are part of the management process. Nevertheless, the insight that one can get by understanding their formulation and assumptions can be a game changer.&lt;/p&gt;&#xA;" OwnerUserId="515" LastActivityDate="2020-05-21T08:39:55.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4235" PostTypeId="1" CreationDate="2020-05-21T15:14:17.550" Score="7" ViewCount="173" Body="&lt;p&gt;Assume I have a matrix &lt;span class=&quot;math-container&quot;&gt;$(d_{ji})_{ij}$&lt;/span&gt; of distances between points &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. These distances could be anything fulfilling the triangle inequality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I would like to find coordinates &lt;span class=&quot;math-container&quot;&gt;$(x_i,y_i)$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, so that the Euclidean distances are always less or equal to the real ones:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \varepsilon_{ij} = d_{ij} - \sqrt{(x_i-x_j)^2 + (y_i-y_j)^2} \geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, the sum &lt;span class=&quot;math-container&quot;&gt;$\sum_{ij} \varepsilon_{ij}$&lt;/span&gt; should be minimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could one approach such a non-linear problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I would also be interested in other, similar objective functions that somehow minimize the &lt;span class=&quot;math-container&quot;&gt;$\varepsilon_{ij}$&lt;/span&gt;. The important for me is that the &quot;approximation&quot; fulfils the inequalities stated above.&lt;/p&gt;&#xA;" OwnerUserId="50" LastEditorUserId="50" LastEditDate="2020-05-22T13:52:11.123" LastActivityDate="2020-05-23T17:59:10.920" Title="Find Euclidean sub-distances for a given distance matrix" Tags="|nonlinear-programming|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4236" PostTypeId="2" ParentId="4235" CreationDate="2020-05-21T16:06:41.647" Score="4" Body="&lt;p&gt;Your problem seems to be similar to &lt;a href=&quot;https://en.wikipedia.org/wiki/Multidimensional_scaling&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multidimensional Scaling (MDS)&lt;/a&gt;. In MDS, the goal is to represent multidimensional data as good as possible in fewer dimensions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If high-dimensional distances are represented in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^2$&lt;/span&gt;, classical MDS corresponds to the problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x,y} \sum_{ij} \varepsilon_{ij}^2,$$&lt;/span&gt;&#xA;using your definition of &lt;span class=&quot;math-container&quot;&gt;$\varepsilon_{ij}$&lt;/span&gt;. This problem allows for a closed-form solution based on eigendecomposition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, there are two differences. First, you have the additional constraints &lt;span class=&quot;math-container&quot;&gt;$\varepsilon_{ij} \ge 0$&lt;/span&gt;, which are convex in terms of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. Second, you have a different objective, which is not convex in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. I don't know if there are MDS generalizations that specifically consider these things, but it could be a good starting point.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2020-05-21T16:13:23.043" LastActivityDate="2020-05-21T16:13:23.043" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4237" PostTypeId="1" AcceptedAnswerId="5096" CreationDate="2020-05-21T18:53:53.360" Score="8" ViewCount="241" Body="&lt;p&gt;Out of curiosity, since I read this question &lt;a href=&quot;https://or.stackexchange.com/questions/4185/what-are-operations-research-applications-for-good-causes&quot;&gt;What are Operations Research applications for &amp;#39;good causes&amp;#39;?&lt;/a&gt; and thought it might be a good addition to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are Operations Research applications, where ethical/moral stakes are involved?&#xA;I mean applications that lead to ethical questions that go beyond the initial purpose of the application and people would eventually refuse to work on this because of ethical reasons.&#xA;At first I wanted to use the term &quot;bad causes&quot;, but this is too subjective and I tried to phrase the question as neutral as possible.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2020-05-21T20:06:21.883" LastActivityDate="2024-04-04T02:35:45.587" Title="What are Operations Research applications for 'morally discussable causes'?" Tags="|optimization|reference-request|applications|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4238" PostTypeId="1" AcceptedAnswerId="4245" CreationDate="2020-05-21T19:57:43.427" Score="3" ViewCount="693" Body="&lt;p&gt;I am running a MILP formulation (implemented in C++) with the Cplex Concert Technology 12.10, and I am trying to get the total elapsed time. So till the moment, I have tried three approaches:&#xA;Be &lt;code&gt;cplex&lt;/code&gt; my IloCplex object.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Using the &lt;code&gt;clock()&lt;/code&gt; function from the &lt;code&gt;time.h&lt;/code&gt; C++ library:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;    cplex.setParam(IloCplex::Param::TimeLimit, time_limit);&#xA;    time_t start = clock();&#xA;    cplex.solve();&#xA;    double total_time = (double) (clock() - start) / (double) CLOCKS_PER_SEC;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Using the Cplex Concert function &lt;code&gt;getTime()&lt;/code&gt;:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;    cplex.setParam(IloCplex::Param::TimeLimit, time_limit);&#xA;    cplex.solve();&#xA;    double total_time = cplex.getTime();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Using the Cplex Concert parameter &lt;code&gt;ClockType&lt;/code&gt;:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;    cplex.setParam(IloCplex::Param::TimeLimit, time_limit);&#xA;    cplex.setParam(IloCplex::Param::ClockType, 2);&#xA;    cplex.solve();&#xA;    double total_time = cplex.getTime();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My code &lt;strong&gt;does not&lt;/strong&gt; make use of any callbacks (informational callback neither), and does not set any value to the Cplex Concert parameter &lt;code&gt;Threads&lt;/code&gt;, i.e., the piece of code &lt;code&gt;cplex.setParam(IloCplex::Param::Threads, n);&lt;/code&gt; is not executed. Since such piece of code is not executed, then (according to the Cplex Concert official &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/Threads.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt;) my code is using all available threads:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When this parameter is at its default setting 0 (zero), and your&#xA;application includes no callbacks or only an informational callback,&#xA;CPLEX can use all available threads.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The problem that I am facing is that in all these three approaches the &lt;code&gt;total_time&lt;/code&gt; presents a wrong value. For example, if I set the variable &lt;code&gt;time_limit&lt;/code&gt; to &lt;code&gt;120&lt;/code&gt;, i.e., set the optimization time limit to &lt;code&gt;120&lt;/code&gt; seconds, then the variable &lt;code&gt;total_time&lt;/code&gt; presents a value much bigger than the expected one, such as &lt;code&gt;892.322&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So, I'd like to know if anyone already faced this problem before.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="123" LastEditDate="2021-11-20T14:58:34.400" LastActivityDate="2021-11-20T14:58:34.400" Title="Why does the getTime() function from cplex concert returns wrong value?" Tags="|mixed-integer-programming|cplex|concert|runtime|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4239" PostTypeId="1" AcceptedAnswerId="4240" CreationDate="2020-05-22T00:02:53.743" Score="4" ViewCount="143" Body="&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt; We are solving a large scale vehicle to person ride-matching problem. The problem is essentially simple (match every person with a vehicle, if possible), yet the problem size is quite large, e.g., 200,000 vehicles and 200,000 people. The problem network has already been divided into 2,000 zones based on geographic attributes, but the zone level assignment is too restrictive as zones are so small and enough number of vehicles may not always be found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The question:&lt;/strong&gt; How can we combine zones into clusters such that the deviation between the number of vehicles and the number of people within each cluster is minimized and adjacent zones are clustered (i.e., zones far apart from each other would not fall into the same cluster)? We may assume we would like &lt;em&gt;n&lt;/em&gt;-clusters and are not interested in optimizing &lt;em&gt;n&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My failed attempt:&lt;/strong&gt; Let &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; be a set of zones and &lt;span class=&quot;math-container&quot;&gt;$C=\{0,1,2,...,n\}$&lt;/span&gt; be a set of clusters. The binary variable, &lt;span class=&quot;math-container&quot;&gt;$y_{ic}=1$&lt;/span&gt;, if zone &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to cluster &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$T_{ij}$&lt;/span&gt; denote the zonal (euclidean) travel time between zone &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; and zone &lt;span class=&quot;math-container&quot;&gt;$j\in I$&lt;/span&gt; (considering their centroids). Let &lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V_i$&lt;/span&gt;, respectively, denote the number of people and the number of vehicles in zone &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt;. Finally, let &lt;span class=&quot;math-container&quot;&gt;$\epsilon\in\mathbb{R}^+$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u\in [0,1]$&lt;/span&gt; be the maximum allowed deviation between the number of vehicles and people, and the uniformity ratio (i.e., how uniform we want the cluster sizes to be), respectively. I have the following model that I know so far away (indeed, wrong) from what I want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\min &amp;amp;\quad \sum_{\substack{i,j\in I,\\c\in C}}T_{ij}y_{ic}\tag1\\\text{s.t.}&amp;amp;\quad \sum_{c\in C}y_{ic}=1 \qquad\forall i\in I\tag2\\&amp;amp;\quad\sum_{i\in I}y_{ic} \leq (1+u)\frac{|I|}{|C|} \qquad \forall c\in C\tag3\\&amp;amp;\quad \sum_{i\in I}\left(P_i-V_i\right)y_{ic} \leq \epsilon \qquad \forall c\in C\tag4\\&amp;amp;\quad y_{ic}\in \{0,1\}.\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I expected the above model to collect the zones that are close to each other, but surely it didn't. I have the implementation of the above (ignoring (4)) on a dummy sample (&lt;span class=&quot;math-container&quot;&gt;$|I|=20$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$|C|=2$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$u=0$&lt;/span&gt;) and produces the below output. Different colors indicate which cluster the zone is assigned. In this case (where constraint (4) is ignored), I would at least expect to see a nice partition where no zones on the upper side are red and no zones below are blue. Can the correct objective be &lt;span class=&quot;math-container&quot;&gt;${\displaystyle\min\sum_{\substack{i,j\in I,\\c\in C}}|T_{ij}y_{ic}-T_{ji}y_{jc}|^2}$&lt;/span&gt; ? If yes, any way to linearize this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wVdQK.png?s=256&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wVdQK.png?s=256&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Alternative solutions:&lt;/strong&gt; I also searched for algorithmic solutions and ended up finding &lt;a href=&quot;https://en.wikipedia.org/wiki/Ward%27s_method&quot; rel=&quot;noreferrer&quot;&gt;Ward's method&lt;/a&gt; of hierarchical clustering and implemented the code following Example 1 in &lt;a href=&quot;https://stackabuse.com/hierarchical-clustering-with-python-and-scikit-learn/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. It partitions the zones perfectly from a visual standpoint (see below plot) but does not allow factoring in constraints (3)–(4). I have also seen &lt;a href=&quot;https://or.stackexchange.com/questions/2987/two-stage-k-means-clustering&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/questions/3317/customer-clustering-to-solve-very-large-scale-vrps&quot;&gt;that&lt;/a&gt; which does not exactly help me. Any suggestion?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kBxEa.png?s=256&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kBxEa.png?s=256&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="518" LastActivityDate="2020-05-22T12:57:22.383" Title="Clustering a large ride-matching problem" Tags="|optimization|graphs|clustering|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4240" PostTypeId="2" ParentId="4239" CreationDate="2020-05-22T00:20:53.013" Score="4" Body="&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$i&amp;lt;j$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$z_{i,j} \ge 0$&lt;/span&gt; indicate whether zones &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are assigned to the same cluster.  You want to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i&amp;lt;j} T_{i,j} z_{i,j}$&lt;/span&gt;, with additional constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{i,c} + y_{j,c} - 1 \le z_{i,j} \quad \text{for $i&amp;lt;j$ and $c\in C$}$$&lt;/span&gt;&#xA;Note that &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; will automatically be integer-valued without explicitly declaring it to be binary.  Because there are &lt;span class=&quot;math-container&quot;&gt;$\binom{|I|}{2}|C|$&lt;/span&gt; of these constraints, you might want to introduce them dynamically only if they are violated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding constraint &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt;, do you also want &lt;span class=&quot;math-container&quot;&gt;$\ge -\epsilon$&lt;/span&gt;?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you might think of this in terms of political districting, as in the recent paper &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2020/01/7582.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Imposing contiguity constraints in political districting models&lt;/em&gt;&lt;/a&gt;.  For &lt;span class=&quot;math-container&quot;&gt;$i,j\in I$&lt;/span&gt;, binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; indicates whether zone &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to zone &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$x_{j,j}=1$&lt;/span&gt; means that zone &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is the &quot;capital&quot; of the resulting district.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-05-22T12:57:22.383" LastActivityDate="2020-05-22T12:57:22.383" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4241" PostTypeId="1" CreationDate="2020-05-22T07:28:52.420" Score="1" ViewCount="93" Body="&lt;p&gt;If the constrained optimization problem is a quadratically constrained quadratic program of the form &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad x^HQx-a(x+x^H)+b|z^Hx|^2\\\text{s.t.}&amp;amp;\quad\|x\|^2\le1\end{align}&lt;/span&gt; where&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the unknown complex vector&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is a positive semidefinite matrix&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is a scalar&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a scalar&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is a known complex vector&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What implication does a changing &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; have on the optimal value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, i.e., what kind of change in &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; will result in a different value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;? Because even as &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; changes I am not able to see any change in &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="3619" LastEditorUserId="123" LastEditDate="2020-05-22T08:22:20.610" LastActivityDate="2020-05-22T08:22:20.610" Title="Question on quadratically constrained quadratic program" Tags="|constraint|constraint-programming|convexity|quadratic-programming|convex-optimization|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4242" PostTypeId="2" ParentId="4235" CreationDate="2020-05-22T17:19:00.657" Score="1" Body="&lt;p&gt;Your constraint defines a &lt;a href=&quot;https://en.wikipedia.org/wiki/Second-order_cone_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;second order cone&lt;/a&gt;, which means it is convex. You can solve it with a specialized solver (for example one listed on the Wikipedia page), although any convex solver might work if the problem is not too hard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The equivalent SOCP formulation would be:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp; \quad\sum_{ij} \varepsilon_{ij}\\\text{s.t.}&amp;amp; \quad\lVert X_i - X_j \rVert_2 \leq d_{ij} - \varepsilon_{ij}\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$X = (x, y)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: There is nothing in the above formulation that forces &lt;span class=&quot;math-container&quot;&gt;$\varepsilon_{ij}$&lt;/span&gt; to be equal to &lt;span class=&quot;math-container&quot;&gt;$d_i - \lVert X_i - X_j \rVert_2 \leq d_{ij}$&lt;/span&gt;: it doesn't match the original problem. Such a constraint would make it non-convex. Thanks to Mark L. Stone and Paul Rubin for pointing it out in the comments.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2020-05-23T17:59:10.920" LastActivityDate="2020-05-23T17:59:10.920" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="4244" PostTypeId="2" ParentId="3813" CreationDate="2020-05-22T20:28:56.200" Score="2" Body="&lt;p&gt;I would refer interested readers to the answer &lt;a href=&quot;https://or.stackexchange.com/a/896/2999&quot;&gt;here&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://or.stackexchange.com/a/197/2999&quot;&gt;here&lt;/a&gt; (by @Marco Lübbecke). My recent applied research work (at the intersection of ML and OR) [&lt;a href=&quot;https://arxiv.org/abs/2004.13714&quot; rel=&quot;nofollow noreferrer&quot;&gt;preprint&lt;/a&gt;] is based on a similar thought. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been doing research in the development of an airline crew pairing optimization framework for large-scale and complex flight networks (named as &lt;em&gt;&lt;a href=&quot;https://arxiv.org/abs/2003.03994&quot; rel=&quot;nofollow noreferrer&quot;&gt;AirCROP&lt;/a&gt;&lt;/em&gt;). Its kernel is a Column Generation (CG)-based heuristic [&lt;a href=&quot;https://arxiv.org/abs/2005.08636&quot; rel=&quot;nofollow noreferrer&quot;&gt;preprint&lt;/a&gt;]. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One day, the industry's contact manager asked me if there is a way to build intelligence in the framework, i.e., is it possible to learn something from previous runs to enhance the performance of a future run, or is it possible to do the same among the iterations of a single run itself? Though I have some ideas regarding the former (for future), I have worked on the latter in the above-mentioned preprint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the above work, I have attempted to learn some important flight-connections that got rejected in the previous CG-iterations but could be useful in the future iterations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this, I have developed an online-learning framework to learn such flight-connections in an unsupervised manner using a Variational Graph Autoencoder (VGAE, a Graph Neural Network) and use them &lt;em&gt;on-the-fly&lt;/em&gt; for creating new columns so as to enhance the CG-convergence and/or decrease the required CG-iterations. It has shown significant improvements but the solution-ing time of the overall framework has increased a lot, almost doubled, due to the addition of the learning time of VGAE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I have an intuition and is developing a strategy to replace the ML part so that I am still able to do the same but in lesser time.&lt;/p&gt;&#xA;" OwnerUserId="2999" LastEditorUserId="2999" LastEditDate="2020-05-22T20:47:23.090" LastActivityDate="2020-05-22T20:47:23.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4245" PostTypeId="2" ParentId="4238" CreationDate="2020-05-23T01:18:41.443" Score="2" Body="&lt;p&gt;A solution can be found here &lt;a href=&quot;https://stackoverflow.com/questions/2962785/c-using-clock-to-measure-time-in-multi-threaded-programs&quot;&gt;c-using-clock-to-measure-time-in-multi-threaded-programs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you do not limit the threads, Cplex will span as many as there are cores. &#xA;You are counting the cpu time (and since each core contributes all of its running time) you see a much larger value. I think you are interested in the wall-time of the process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$892/120 \approx 7.4$&lt;/span&gt;. So i guess you have 8 cores (or 4 with hyperthreading). &#xA;When you limit the threads to 1 you should see a value of about 120.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2020-05-23T01:18:41.443" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4246" PostTypeId="2" ParentId="3953" CreationDate="2020-05-23T09:14:14.560" Score="1" Body="&lt;p&gt;I don't see any part that &quot;storage_facility_vars&quot; is added to your model in your code. You use it only after define as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; storage_facility_vars[(date, product)] = plant_current_inv[product] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please check it. Also &quot;plant_current_inv[product]&quot; is used only above row, never defined or initialized.&lt;/p&gt;&#xA;" OwnerUserId="432" LastActivityDate="2020-05-23T09:14:14.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4247" PostTypeId="1" CreationDate="2020-05-23T13:38:58.537" Score="2" ViewCount="526" Body="&lt;p&gt;the constraints in the photo ,I need to translate to the closed-form I don't know how can I do this.&#xA;Can you help?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/vNgsn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vNgsn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uc5w4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uc5w4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CXxP5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CXxP5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to write the mod file and dat file in Cplex for this problem&lt;/p&gt;&#xA;" OwnerUserId="3627" LastEditorUserId="3627" LastEditDate="2020-05-23T14:09:11.887" LastActivityDate="2020-05-23T15:47:37.077" Title="shortest path problem,I want to write constraints in closed form" Tags="|modeling|cplex|network-flow|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4248" PostTypeId="1" AcceptedAnswerId="4259" CreationDate="2020-05-23T15:19:03.547" Score="8" ViewCount="1072" Body="&lt;p&gt;I have a linear optimization problem for which I am looking for a suitable optimization solution that can fulfill my requirements. Here is an explanation of the optimization problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of &lt;code&gt;n&lt;/code&gt; variables &lt;code&gt;x1, x2, .., xn&lt;/code&gt; relevant for the optimization. They contain a value between 0 and 100, whereby the sum of the variables is always 100%. The variables are used as multiplication coefficient for their respective vector with &lt;code&gt;m&lt;/code&gt; entries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are different functions for determining the cost value for the variables depending on the optimization goal. One of them is shown below as a pseudo code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cost_function(x1, x2, .., xn)&#xA;       i = 0&#xA;       min_value = 0&#xA;       **while** i &amp;lt; m&#xA;           e = x0 * E0_i + x1 * E1_i + .. + xn * EN_i&#xA;           v = (s0 * E0_i + s1 * E1_i + .. + sn * EN_i) / e&#xA;           minimize_value += min(-C_i, e) * (P_i - v)&#xA;       **return** minimize_value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the bold characters represent vectors and the other scalar values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The diagram shows the state space with three variables &lt;code&gt;x1&lt;/code&gt;, &lt;code&gt;x2&lt;/code&gt; and &lt;code&gt;x3&lt;/code&gt;, where darker is better:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/g6Z3L.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/g6Z3L.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I use Simulated Annealing for this optimization problem, but the state &lt;code&gt;s'&lt;/code&gt; is only accepted as new state if it is better than &lt;code&gt;s&lt;/code&gt;, because it would be counterproductive to have a probability to take over worse states in a linear optimization problem.&#xA;From a scientific point of view, the use of Simulated Annealing is probably not appropriate for the application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would linear programming still be recommended in this case? Or is there an alternative to Simulated Annealing for linear optimization problems?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A minimum working example of the problem can be found &lt;a href=&quot;https://github.com/emmaparker96/WorkingExampleForStackExchange/blob/master/Example_SLSQP.py&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result of the variables should be: &lt;code&gt;[0.17023975 0.19532928 0.64296507]&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2756" LastEditorUserId="2756" LastEditDate="2020-05-29T14:18:56.657" LastActivityDate="2023-12-05T02:57:38.573" Title="Linear optimization problem with user-defined cost function" Tags="|linear-programming|simplex|simulated-annealing|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="4249" PostTypeId="2" ParentId="4247" CreationDate="2020-05-23T15:38:22.540" Score="2" Body="&lt;p&gt;In OPL to get the shortest path you could use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;.mod&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tuple edge&#xA;{&#xA;   key int o;&#xA;   key int d;&#xA;   int weight;&#xA;}&#xA;&#xA;{edge} edges=...;&#xA;&#xA;{int} nodes={i.o | i in edges} union {i.d | i in edges};&#xA;int st=1; // start&#xA;int en=8; // end&#xA;&#xA;dvar int obj; // distance&#xA;dvar boolean x[edges]; // do we use that edge ?&#xA;&#xA;minimize obj;&#xA;&#xA;subject to&#xA;{&#xA;obj==sum(e in edges) x[e]*e.weight;&#xA;&#xA;forall(i in nodes)&#xA;    sum(e in edges:e.o==i) x[e]&#xA;    -sum(e in edges:e.d==i) x[e]    &#xA;    ==&#xA;    ((i==st)?1:((i==en)?(-1):0));&#xA;}&#xA;&#xA;{edge} shortestPath={e | e in edges : x[e]==1};&#xA;&#xA;execute&#xA;{&#xA;writeln(shortestPath);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.dat&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;edges=&#xA;{&#xA;&amp;lt;1,2,9&amp;gt;,&#xA;&amp;lt;1,3,9&amp;gt;,&#xA;&amp;lt;1,4,8&amp;gt;,&#xA;&amp;lt;1,10,18&amp;gt;,&#xA;&amp;lt;2,3,3&amp;gt;,&#xA;&amp;lt;2,6,6&amp;gt;,&#xA;&amp;lt;3,4,9&amp;gt;,&#xA;&amp;lt;3,5,2&amp;gt;,&#xA;&amp;lt;3,6,2&amp;gt;,&#xA;&amp;lt;4,5,8&amp;gt;,&#xA;&amp;lt;4,7,7&amp;gt;,&#xA;&amp;lt;4,9,9&amp;gt;,&#xA;&amp;lt;4,10,10&amp;gt;,&#xA;&amp;lt;5,6,2&amp;gt;,&#xA;&amp;lt;5,7,9&amp;gt;,&#xA;&amp;lt;6,7,9&amp;gt;,&#xA;&amp;lt;7,8,4&amp;gt;,&#xA;&amp;lt;7,9,5&amp;gt;,&#xA;&amp;lt;8,9,1&amp;gt;,&#xA;&amp;lt;8,10,4&amp;gt;,&#xA;&amp;lt;9,10,3&amp;gt;,&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;whicg gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&amp;lt;1 4 8&amp;gt; &amp;lt;4 7 7&amp;gt; &amp;lt;7 8 4&amp;gt;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2020-05-23T15:47:37.077" LastActivityDate="2020-05-23T15:47:37.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4250" PostTypeId="1" CreationDate="2020-05-23T23:01:56.080" Score="10" ViewCount="1486" Body="&lt;p&gt;I'm finding myself needing to learn about operations research. I'm planning to just find a textbook (or some other medium, such as an online course) on OR and learn from there. But I don't think I have the needed foundations to even start learning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a good amount of combinatorics, linear algebra, vector calculus, and differential equations under my belt, but am lacking in statistics knowledge. I assume OR is largely a matter of statistics, so that's my main concern. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of statistics knowledge, where should I start and what should I be trying to work towards with the goal of eventually learning about OR?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side question, if you have any recommendations for textbooks or other sources I can learn from I'd much appreciate it!&lt;/p&gt;&#xA;" OwnerUserId="3631" LastEditorUserId="123" LastEditDate="2021-02-09T21:10:35.060" LastActivityDate="2022-09-10T17:42:40.503" Title="What are the prerequisites for learning about operations research?" Tags="|reference-request|books|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4252" PostTypeId="1" CreationDate="2020-05-24T08:12:54.707" Score="5" ViewCount="130" Body="&lt;p&gt;Could you OR whizkids please help me out with this one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/61854621/a-good-memoryless-elevator-strategy&quot;&gt;https://stackoverflow.com/questions/61854621/a-good-memoryless-elevator-strategy&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Surely somebody has solved this before. How do you classify this problem? A 1D transportation problem? A routing problem? What methods do you recommend for solving it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that the task isn't given at the outset: People keep arriving all the time pushing buttons saying &quot;come here, I want to go there&quot;. Notice also that there is only one elevator. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The object is of course to bring people to their destinations as quickly as possible. The individual shouldn't be trampled down: Each customer must be served within a reasonable time, even if he or she travels in an unusual way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are simple evident strategies in common use in old elevators, but they cannot be optimal. I wonder how much room there is for improvement. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all I'm looking for a memoryless strategy: The decision should only depend on the current list of orders. The next step will be to explore if you can improve on this by learning from experience. &lt;/p&gt;&#xA;" OwnerUserId="3623" LastEditorUserId="123" LastEditDate="2021-02-09T21:10:59.153" LastActivityDate="2021-02-09T21:10:59.153" Title="A good memoryless elevator strategy?" Tags="|optimization|algorithms|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4253" PostTypeId="1" CreationDate="2020-05-24T17:35:36.993" Score="2" ViewCount="124" Body="&lt;p&gt;My first naive approach is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Given N number of salesmen. Cluster an area to be N clusters with almost equal number of clients [1] with some kind of same-size clustering/facility location algorithm&lt;/li&gt;&#xA;&lt;li&gt;Assign 1 salesman to 1 territory (one-to-one assignment)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The question is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How should we divide the territory gracefully if the number of salesmen increase/decrease from N=10 to N=9, N=11, or N=20?&lt;/li&gt;&#xA;&lt;li&gt;Is one-to-one assignment is doomed to fail? What are the alternatives for designing and scaling sales territory?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the location of centroids could be very different between N=9, N=10, N=11. It can make the territories very different.&lt;/li&gt;&#xA;&lt;li&gt;increase of salesman from N=10 to N=20 will shrink the area of previous territory&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Out of scope for this question:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Routing (TSP/VRP). TSP with Time Window would be done after sales territory, but it's out of this question scope. This question is more about designing/scaling the sales territory itself.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] We could use equal expected sales amount, but for argument sake let's use number of clients.&lt;/p&gt;&#xA;" OwnerUserId="2704" LastEditorUserId="2704" LastEditDate="2020-05-25T21:31:57.273" LastActivityDate="2020-05-25T21:31:57.273" Title="How to design and scale sales territory?" Tags="|facility-location|clustering|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4254" PostTypeId="2" ParentId="4250" CreationDate="2020-05-24T19:31:51.203" Score="9" Body="&lt;p&gt;I would recommend starting with OR books/courses right away. You can learn a lot (e.g linear programming, integer programming, convex optimization) without a working knowledge of statistics. &#xA;However, if you want to dig into stochastic programming, queuing theory, inventory theory you will need some knowledge of probability and statistics. I would advise starting with linear and integer programming first before considering those fields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S: It could be useful if you precise why you need to learn OR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I suggest starting with &lt;a href=&quot;https://courses.edx.org/courses/course-v1:GTx+ISYE6669+2T2018/course/&quot; rel=&quot;noreferrer&quot;&gt;this course&lt;/a&gt; and &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/B00DZ0NS1A&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;this book&lt;/a&gt;. They are theoretic-oriented. Basically, it will teach you how solvers work. For more a more practical approach, take a look at &lt;a href=&quot;https://github.com/rkimura47/cmu-comp-or/tree/master/Modules&quot; rel=&quot;noreferrer&quot;&gt;these lecture notes&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2020-05-27T19:01:52.367" LastActivityDate="2020-05-27T19:01:52.367" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4255" PostTypeId="1" CreationDate="2020-05-24T20:08:39.213" Score="2" ViewCount="70" Body="&lt;p&gt;I have a variable &lt;span class=&quot;math-container&quot;&gt;$e(h)$&lt;/span&gt;, and below is the part of the Lagrangian equation where I am taking the derivative with respect to &lt;span class=&quot;math-container&quot;&gt;$e(h)$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{\partial }{\partial e(h)} \hspace{.2cm}\mu_1(h)(e(h)-\bar{E})+\mu_2(h)(e(h)-e(h-1))$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\bar{E}$&lt;/span&gt; is a parameter and the rest are variables. &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; defines the time steps in hours. Please let me know how to take the derivative to derive the KKT especially the part where the &lt;span class=&quot;math-container&quot;&gt;$e(h-1)$&lt;/span&gt; is present.&lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="2546" LastEditDate="2020-05-24T20:41:48.727" LastActivityDate="2020-05-24T20:41:48.727" Title="Deriving KKT Conditions for time-step equations" Tags="|kkt-conditions|dual|lagrange-multipliers|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4256" PostTypeId="2" ParentId="4253" CreationDate="2020-05-24T22:07:33.430" Score="2" Body="&lt;p&gt;An approach sometimes used in other contexts is to start with an &quot;optimal&quot; assignment. If the number of sales people increases by one or two, solve a separate model (say a MIP model) that selectively reallocates some territories to the new sales people with constraints on how many they get, how much territory their clientele span, and how many clients each original sales person loses. (One of those likely becomes your objective function, with limits on the others.) Similarly, if the number of salespeople decreases, you solve yet another MIP model to reallocate portions of their territories to remaining sales people, again with &quot;equity&quot; constraints and some criterion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key here is that after a few reallocations, you go back to the original model and start over, getting an &quot;optimal&quot; solution for the new landscape. How often you start fresh will likely depend on how ragged the tweaked former solution gets and how grumpy people are about reallocations.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-05-24T22:07:33.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4257" PostTypeId="1" AcceptedAnswerId="4258" CreationDate="2020-05-25T06:20:34.137" Score="6" ViewCount="440" Body="&lt;p&gt;I'm given two matrices:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, an &lt;span class=&quot;math-container&quot;&gt;$n\times n$&lt;/span&gt; adjacency matrix of a graph. The graph is unweighted, undirected and has no self-edges or multi-edges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, an &lt;span class=&quot;math-container&quot;&gt;$n\times n$&lt;/span&gt; symmetric matrix of edge weights for items &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n$&lt;/span&gt; where entry &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; denotes the edge weight between item &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt;, if that edge eventually exists. Edge weights are real numbers between -5 and +5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The items &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n$&lt;/span&gt; are assigned to exactly one node each, the objective being to assign items to nodes to maximise the total sum of edge weights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it might be a variation of the assignment problem, but with the cost of assignments dependent on the graph structure I'm uncertain how this would be formulated.&#xA;So far I've tried a greedy heuristic algorithm which randomly assigns items to nodes, swaps the nodes which most increases the total edge weight sum, and repeats until no swap will increase the sum further. This frequently gives far from optimal solutions though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a name for this sort of problem, and what might be the best solution method?&lt;/p&gt;&#xA;" OwnerUserId="3636" LastActivityDate="2020-05-26T08:28:53.183" Title="Is there a name for this variation of the assignment problem?" Tags="|optimization|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4258" PostTypeId="2" ParentId="4257" CreationDate="2020-05-25T09:00:10.693" Score="9" Body="&lt;p&gt;It is the quadratic assignment problem.&#xA;A survey is given here &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221705008337&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sciencedirect.com/science/article/abs/pii/S0377221705008337&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A formulation would be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Decision variables &lt;span class=&quot;math-container&quot;&gt;$ y_{ij} \in \{0,1\}$&lt;/span&gt; that is 1 if &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is assigned to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&#xA;The objective is then &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j,k,p} A_{k,p}X_{i,j}y_{ik}y_{jp}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$A_{k,p}$&lt;/span&gt; is 1 if the edge between &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; exists, otherwise zero and &lt;span class=&quot;math-container&quot;&gt;$X_{i,j}$&lt;/span&gt; is the cost between &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you need the assignment constraints.&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_i y_{ij} = 1\quad\forall j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_j y_{ij}= 1\quad\forall i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2020-05-26T08:28:53.183" LastActivityDate="2020-05-26T08:28:53.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4259" PostTypeId="2" ParentId="4248" CreationDate="2020-05-25T14:56:37.147" Score="14" Body="&lt;p&gt;First, the problem is not a linear optimization problem, at least not for the objective function shown (which is nonlinear due the conditional portion in lines 10-13 and particularly the division by E_ges_i in line 13. Simulated annealing might be fine as a heuristic approach, but given the nonlinear objective, only accepting improving steps might or might not be appropriate. If the objective is unimodal, I think skipping steps that make the objective worse might be okay. Then again, if the heat map is unimodal, constrained gradient descent might work just as well or better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sticking to the objective function shown, another possibility would be to treat the problem as a mixed integer linear program, using a piecewise linear approximation to the objective function. Since an approximation is involved, you might want to try gradient descent or other local search from the model's solution to see if you can improve it, or alternatively refine the approximation near the model solution and solve the revised model (ad nauseum).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ADDENDUM&lt;/strong&gt;: I just hacked a little R code, using the objective function posted on GitHub. The algorithm I used is the Nelder-Mead polytope algorithm, as described in &lt;a href=&quot;https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;. The Nelder-Mead algorithm, published in 1965, was a modification of an earlier algorithm (by Spendley, Hext and Himsworth in 1962, according to &lt;a href=&quot;https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;) and has likely been improved upon in turn since the '60s. The attraction of the Nelder-Mead algorithm (or its relatives) here is that it starts with a simplex as the search region and progressively shrinks to smaller and smaller simplices, all of which are subsets of the original. So if we use N-M starting with the unit simplex, the constraints are always satisfied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did not put in much care in the coding, did not code all the possible adjustments (such as random restarts), and picked the expansion, contraction and reflection parameters out of thin air. That said, it converged (or at least stopped) after seven iterations on the test problem, with a solution of (0.0126960, 0.2461336, 0.7411704) and an objective value of -4675913 -- not optimal, but I think not too shabby (particularly since I did not code restarts or other more recent tweaks to Nelder-Mead). It's not hard to code, and it does not require derivatives, just function evaluations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt; P. Gill, W. Murray and M. Wright, &lt;strong&gt;Practical Optimization&lt;/strong&gt; (Academic Press, 1981).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ADDENDUM 2&lt;/strong&gt; I updated my R code to use the simplified version of the cost function from the GitHub repository (which is a bit better behaved when an argument is zero). I also switched from the Nelder-Mead algorithm as present in Gill, Murray and Wright to the version on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia page&lt;/a&gt;, and adjusted the parameter values to the ones they recommend. I have to qualify my earlier comment about Nelder-Mead automatically maintaining feasibility. The condition that the weights sum to 1 is automatically maintained. Nonnegativity of the weights requires occasionally shrink a proposed step, which is easily handled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the modified code and the parameter values from the Wikipedia page, I get a final solution of (0, 0.2885719, 0.7114281) with an objective value of -4,683,095.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ADDENDUM 3&lt;/strong&gt; Hopefully this will be my final addendum. :-) I also tried a genetic algorithm (in R). The solution from a GA is inherently random, but with the parameters and random seed that I chose I got a final solution of (0.001182725, 0.2869361, 0.7118812) with objective value -4,683,175, which is slightly better than both what I got with Nelder-Mead and what LocalSolver reported.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My R code for both Nelder-Mead and the GA (using the &lt;code&gt;genalg&lt;/code&gt; R library) are available in an &lt;a href=&quot;http://rubin.msu.domains/blog/neldermead.nb.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;R notebook&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-05-31T20:39:38.313" LastActivityDate="2020-05-31T20:39:38.313" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="4261" PostTypeId="1" AcceptedAnswerId="4262" CreationDate="2020-05-26T12:13:40.917" Score="6" ViewCount="198" Body="&lt;p&gt;I have seen some papers claiming that their proposed model is &lt;em&gt;integer-friendly&lt;/em&gt;. I would like to get more information about what type of constraints we can call integer-friendly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably, it can be better understood if I have some examples. Here is part of a model in the context of location covering:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&amp;amp;z= \max\sum_i v_i \\\text{s.t}\quad&amp;amp;v_i \geq c_{ij}x_{ij},\quad \forall i \in N, j \in M\tag1\\\quad&amp;amp;v_i \geq 0\\\quad&amp;amp;x_{ij} \in \{0,1\}.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; are some positive non-integer constants. My question is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Why constraint set (1) is NOT integer-friendly, and how can I improve this constraint? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I define the &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; variables to be continuous in &lt;span class=&quot;math-container&quot;&gt;$[0, 1]$&lt;/span&gt;, they will be always 0 or 1. Does it help to some extent?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="660" LastEditorUserId="123" LastEditDate="2020-05-26T19:26:22.323" LastActivityDate="2020-05-29T13:54:57.657" Title="What is the definition for an integer-friendly constraint?" Tags="|mixed-integer-programming|modeling|terminology|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4262" PostTypeId="2" ParentId="4261" CreationDate="2020-05-26T12:16:53.237" Score="3" Body="&lt;p&gt;Don't know if there's a definition per se, but for any constraint that consists of solely integer variables, it is highly beneficial for all the coefficients to be integral as well, because that allows us to easily apply integer cuts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the coefficients are not naturally integral, we can impose that by applying GCD rounding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this example, you have a mixed-binary constraint, which is not very good. Assuming all your coefficients and constants are integral, you can use an integer variable instead, or, more commonly, an integer cut.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-05-26T12:29:05.793" LastActivityDate="2020-05-26T12:29:05.793" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4263" PostTypeId="1" AcceptedAnswerId="4265" CreationDate="2020-05-26T14:03:54.653" Score="11" ViewCount="805" Body="&lt;p&gt;For integer programs solvers (like Gurobi, Cplex, ...) report the value of the linear programming relaxation for integer programs, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Root relaxation: objective 2.648400e+02, 233 iterations, 0.01 seconds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this value independent of the presolve reductions? Is this value always the same for all solvers/versions (if we ignore numerical problems)?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2020-05-27T16:44:10.710" Title="Can presolve reductions change the value of the linear programming relaxation?" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4264" PostTypeId="1" CreationDate="2020-05-26T14:18:19.647" Score="2" ViewCount="879" Body="&lt;p&gt;I have algorithms that get me a tight upper (UB) and lower (LB) bound to a maximization binary integer program (a routing problem). My formulation is non-compact and requires the addition of sub-tour elimination constraints (SEC) dynamically. I am using CPLEX branch-and-bound and add these constraints via the callback mechanism. The LB solution is provided as incumbent (warm start) and that works fine but as soon as I add the constraint: objective function value &amp;lt;= UB, the CPLEX branch-and-bound seems to add a huge number of SECs and takes much longer time to improve the given UB further and finally to converge.&lt;/p&gt;&#xA;&lt;p&gt;I thought with a tight UB and LB, the optimal solution could be found faster than usual but it is behaving the other way round. I have no idea what actually is going on. How can I effectively use the bound information to get to the optimal solution using CPLEX branch-and-bound/branch-and-cut?&lt;/p&gt;&#xA;" OwnerUserId="3640" LastEditorUserId="491" LastEditDate="2024-03-18T12:39:50.160" LastActivityDate="2024-03-18T12:39:50.160" Title="How to use tight upper and lower bounds to get to the optimal value via branch and bound?" Tags="|cplex|vehicle-routing|branch-and-bound|bounds|branch-and-cut|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4265" PostTypeId="2" ParentId="4263" CreationDate="2020-05-26T14:35:27.320" Score="17" Body="&lt;p&gt;the answer is even worse than &quot;no&quot;; I recently used &lt;code&gt;SCIP&lt;/code&gt; to compute an LP relaxation, and the outcome (the value of the dual bound) depended on the branching rule I activated (even though I never branched!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How come?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had strong branching activated by default, so some conflicts were evaluated, and once these were known to the solver, it used them to strengthen the dual bound in the root node. Very smart, but if you are really interested in the LP value of your integer program, you need to deactive &quot;a lot&quot; (I ended up asking a pure LP solver).&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2020-05-26T14:35:27.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4266" PostTypeId="2" ParentId="4263" CreationDate="2020-05-26T15:50:48.043" Score="8" Body="&lt;p&gt;Adding to Marco's answer, the value is most definitely affected. The way problem reduction algorithms work is that we often exploit problem information as it's processed to tighten variable bounds in real time, which of course affects the relaxation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This not only means that problem reduction will often change variable bounds, but the exact changes depend on the reduction algorithms used and on the order in which the calculations were performed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;W.r.t. your second question, this value generally varies wildly, even among different versions of the same solver, because it's affected by many many things, e.g., domain reduction algorithms, convexity/integer cuts, whether the solver defaults to a non-linear relaxation (for MINLPs) etc.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-05-27T16:44:10.710" LastActivityDate="2020-05-27T16:44:10.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4267" PostTypeId="1" AcceptedAnswerId="4270" CreationDate="2020-05-26T18:35:33.550" Score="5" ViewCount="705" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hckrk.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hckrk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a product for which the monthly demand pattern for the last year looks like the following. The product is ordered only 22 days out of 366 days in batch sizes of &lt;strong&gt;272&lt;/strong&gt; kgs. Since there are so many months with 0 demand, the demand distribution is heavily skewed. The mean and standard deviation come out to be &lt;strong&gt;634&lt;/strong&gt; and &lt;strong&gt;1167&lt;/strong&gt; (rounded off), respectively. I have been using this formula (which is the most widely used, I believe) for calculating the safety stock-&#xA;&lt;span class=&quot;math-container&quot;&gt;$$SS = z_\alpha\sigma_{LTD} $$&lt;/span&gt;&#xA;where-&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sigma^2_{LTD} = \mu_L\sigma_D^2$$&lt;/span&gt;&#xA;Taking a lead time of &lt;strong&gt;2.8 months&lt;/strong&gt; and &lt;strong&gt;z = 2.33&lt;/strong&gt; (99% Service Level), I get &lt;strong&gt;SS = 4550 kgs&lt;/strong&gt;. Now it doesn't make sense to hold 4550 kgs of inventory when the demand is so lumpy. I know that the above formula is best suited for demands that are approximately normally distributed and understandably results in really high SS values. This is a problem I have been facing with multiple products for which there are several months with very little demand or 0 demand. What is the best way to optimize the inventory for items with lumpy/erratic demand and calculate the safety stock and reorder points for the future?  &lt;/p&gt;&#xA;" OwnerUserId="3458" LastEditorUserId="3458" LastEditDate="2020-05-26T18:43:22.523" LastActivityDate="2020-05-27T01:45:05.330" Title="Safety stock for lumpy demand" Tags="|inventory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4268" PostTypeId="2" ParentId="4264" CreationDate="2020-05-26T19:27:58.840" Score="2" Body="&lt;p&gt;In addition to the issues it creates (covered by the link @RobPratt provided), it's worth nothing that the upper bound probably contributes nothing to the solver's performance. It will possibly give you a more realistic gap measure (if the solver uses it), but I don't see it guiding the solver's behavior in a useful way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to test this, introduce a variable z to represent your objective function, maximize z, add a constraint z = original objective function, and use the a priori upper bound as an upper bound on the z variable. I &lt;em&gt;think&lt;/em&gt; this will cause fewer problems than the constraint  &amp;lt;= UB would cause.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-05-27T20:39:26.013" LastActivityDate="2020-05-27T20:39:26.013" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4269" PostTypeId="2" ParentId="4264" CreationDate="2020-05-27T01:23:01.850" Score="2" Body="&lt;p&gt;To add to the linked answers: if the upper bound is obtained by taking a convex relaxation (e.g. a semidefinite relaxation), you could strengthen the formulation by running a cutting-plane method to solve the continuous relaxation and applying the cuts generated from the relaxation before branching. If you do this your initial upper bound should match the relaxation's bound, and the bound will be informative (while applying &lt;span class=&quot;math-container&quot;&gt;$\theta \leq UB$&lt;/span&gt; wouldn't help the solver decide how to branch). That said, solving the relaxation via a cutting-plane method might be time consuming, especially if there isn't a &quot;nice&quot; way of cheaply generating a cut from the relaxation, so this might do more harm than good (it depends on the problem).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This idea has been explored by Fischetti et. al. (see section 4.2 of &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/mnsc.2016.2461&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pubsonline.informs.org/doi/10.1287/mnsc.2016.2461&lt;/a&gt;), who showed that it works &lt;em&gt;really&lt;/em&gt; well for facility location problems.&lt;/p&gt;&#xA;" OwnerUserId="43" LastActivityDate="2020-05-27T01:23:01.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4270" PostTypeId="2" ParentId="4267" CreationDate="2020-05-27T01:45:05.330" Score="5" Body="&lt;p&gt;Just like any other demand distribution (e.g., &lt;a href=&quot;https://or.stackexchange.com/q/4045/38&quot;&gt;this one&lt;/a&gt;), you want to set the &lt;em&gt;base-stock level&lt;/em&gt; (&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;) equal to &lt;span class=&quot;math-container&quot;&gt;$F^{-1}(\alpha)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$F(\cdot)$&lt;/span&gt; is the cdf of the lead-time demand distribution and &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is the desired service level; and then the &lt;em&gt;safety stock&lt;/em&gt; is given by &lt;span class=&quot;math-container&quot;&gt;$SS = S - \mu_{LTD}$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In the case of normal demand, as in your question, &lt;span class=&quot;math-container&quot;&gt;$F^{-1}(\alpha) = \mu_{LTD} + z_\alpha\sigma_{LTD}$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$SS = z_\alpha\sigma_{LTD}$&lt;/span&gt;, as you said.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my recommendation is to fit a distribution &lt;span class=&quot;math-container&quot;&gt;$\hat{F}$&lt;/span&gt; to your demand data and then set &lt;span class=&quot;math-container&quot;&gt;$S = \hat{F}^{-1}(\alpha)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$SS = S - \mu_{LTD}$&lt;/span&gt;. In your case, the demand distribution will have a point mass at 0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can set &lt;span class=&quot;math-container&quot;&gt;$\mu_{LTD} = L \mu_D$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sigma_{LTD}^2 = L\sigma^2_D$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$\mu_D$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sigma_D$&lt;/span&gt; are the mean and SD of the demand per period and &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is the lead time). But you could also try to estimate these directly from the data, e.g., estimate the mean and SD of the demand over an &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;-period stretch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, there is some literature on this topic. A Google search for &quot;inventory optimization lumpy demand&quot; or something similar will turn up some hits that are probably more rigorous and general than my approach.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-05-27T01:45:05.330" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="4271" PostTypeId="2" ParentId="4248" CreationDate="2020-05-27T20:08:37.533" Score="6" Body="&lt;p&gt;If you want to implement an algorithm on your own, then we suggest a randomized, derivative-free search, even simpler than a Nelder-Mead approach. Given a feasible solution (respecting the sum equal to 1), move randomly the values of the variables by an epsilon while maintaining the constraint feasible. If the solution is better, keep it; otherwise, throw it away. Start with this simple approach. To go further, tune how you choose the epsilons to move, accept less good solutions along the search to diversify (as done in simulated annealing), and restart the search.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.hexaly.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hexaly (ex LocalSolver)&lt;/a&gt;, our global optimization solver, combines several optimization techniques under the hood. Here, the above essentially allows Hexaly to perform very well on your problem. Thanks to the small number of dimensions (only 3 variables), there is no need to use derivatives (even approximated) to guide and speed up the search. In the same way, there is no need for surrogate modeling of the cost function because this one is extremely fast to evaluate (about 10,000 calls per second).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; Hexaly is commercial software. You can try it for free for 1 month. In addition, Hexaly is free for basic research and teaching.&lt;/p&gt;&#xA;&lt;p&gt;Please find below the results obtained by Hexaly using your cost function as &lt;a href=&quot;https://www.hexaly.com/docs/last/advancedfeatures/externalfunctions.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;external function&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function model() {&#xA;    X[0..2] &amp;lt;- float(0,1);&#xA;    constraint sum[i in 0..2](X[i]) == 1;&#xA;    func &amp;lt;- doubleExternalFunction(cost);&#xA;    obj &amp;lt;- call(func, X);&#xA;    minimize obj;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Having declared the cost function, Hexaly solves the problem as is. Here &amp;quot;solve&amp;quot; means that Hexaly will try to find the best feasible solution to the problem. You can also specify lower and upper bounds for the cost function so that Hexaly computes an optimality gap and then possibly proves the optimality of the solution found.&lt;/p&gt;&#xA;&lt;p&gt;You can write your model using the &lt;a href=&quot;https://www.hexaly.com/docs/last/quickstart/quicktourmodeler.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hexaly modeling language&lt;/a&gt; (namely LSP) or using &lt;a href=&quot;https://www.hexaly.com/docs/last/quickstart/quicktourapis.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python, Java, C#, or C++ APIs&lt;/a&gt;. Here is the link to download the LSP file: &lt;a href=&quot;https://www.hexaly.com/misc/emma.lsp&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.hexaly.com/misc/emma.lsp&lt;/a&gt;. Having installed Hexaly, you can run it using the command &amp;quot;hexaly emma.lsp&amp;quot; in console. The best solution found by Hexaly after a few seconds on a basic laptop is:&lt;/p&gt;&#xA;&lt;p&gt;cost = -4683181.09020784, X0 = 0.00106356929433748, X1 = 0.287235884100486, X2 = 0.711702039130129&lt;/p&gt;&#xA;&lt;p&gt;The sum over the X equals 1.00000149252495, slightly above 1, because Hexaly uses a tolerance to satisfy constraints. If you wish the sum over the X to be surely lower than 1, then you can set &amp;quot;&amp;lt; 1&amp;quot; in the above model instead of &amp;quot;== 1&amp;quot;. In this case, you will find the following solution:&lt;/p&gt;&#xA;&lt;p&gt;cost = -4683175.50600612, X0 = 0.00111513425966878, X1 = 0.286966585180356, X2 = 0.711915927974678&lt;/p&gt;&#xA;&lt;p&gt;Now, the sum over the X is equal to 0.999997647414703.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nD5UA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nD5UA.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2023-12-05T02:57:38.573" LastActivityDate="2023-12-05T02:57:38.573" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4272" PostTypeId="2" ParentId="3288" CreationDate="2020-05-28T16:04:35.893" Score="3" Body="&lt;p&gt;This &lt;a href=&quot;https://github.com/Parthghadge/VRP-Branch-and-Bound&quot; rel=&quot;nofollow noreferrer&quot;&gt;Github repository&lt;/a&gt; has the Java implementation of the Branch and Bound for solving VRP.&lt;/p&gt;&#xA;" OwnerUserId="3651" LastEditorUserId="36" LastEditDate="2020-05-28T18:14:39.127" LastActivityDate="2020-05-28T18:14:39.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4273" PostTypeId="1" CreationDate="2020-05-28T17:40:11.280" Score="2" ViewCount="159" Body="&lt;p&gt;The Network - Maximum flow problem below aims to find the maximum flow using simplex method :&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/60daO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/60daO.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;With the LP as follow :&lt;/p&gt;&#xA;&lt;p&gt;LP : &lt;span class=&quot;math-container&quot;&gt;\begin{Bmatrix}&#xA;Z(Max) = \sum_{i=1}^{m} fi \\ &#xA;Af =0 &#xA;\end{Bmatrix}&lt;/span&gt;&#xA;&lt;br&gt;&lt;br&gt;&lt;/p&gt;&#xA;&lt;p&gt;Incidence Matrix : &lt;br&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Dw1mc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Dw1mc.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;br&gt;&#xA;&lt;em&gt;With arcs indexed {1,2,3,4,5} in red.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question part&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;As mentioned above, I need to get the Maximum Flow using the simplex method. &lt;br&gt;&#xA;Can someone please solve it, and explain to me how to they did.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit :&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;To solve this problem using the simplex method I had to add artificial variables, which gave me the following LP : &lt;br&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{Bmatrix}&#xA;f_{1} + f_{2} - f_{5} = 0\\ &#xA;f_{1} + f_{3} = 0\\ &#xA;-f_{2} + f_{4} = 0\\ &#xA;-f_{3} -f_{4} + f_{5} = 0\\ &#xA;\\&#xA;f_{1}\leq 4\\ &#xA;f_{2}\leq 4\\ &#xA;f_{3}\leq 2\\ &#xA;f_{4}\leq 3&#xA;\end{Bmatrix}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3487" LastEditorUserId="491" LastEditDate="2021-04-14T15:09:48.880" LastActivityDate="2021-04-14T15:09:48.880" Title="Simplex - Network flow problem : Arc from 1 to P with infinite capacity" Tags="|optimization|simplex|graphs|network-flow|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4274" PostTypeId="2" ParentId="4261" CreationDate="2020-05-29T13:54:57.657" Score="2" Body="&lt;p&gt;In (1): &quot;The SPLP formulation of Balinski(2) has been characterized as integer friendly &lt;strong&gt;because of the frequency of direct 0,1 solutions, and because the amount of branching and bounding to resolve fractional solutions is often minimal&lt;/strong&gt; (&lt;em&gt;see ReVelle, 1993&lt;/em&gt;(3))&quot;. Unfortunately, I don't have access to the paper that is mentioned in the above paragraph but I give the references below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) Brimberg, Jack, and Charles ReVelle. &quot;Solving the plant location problem on a line by linear programming.&quot; Top 6.2 (1998): 277-286.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) Balinski, M. (1965). Integer programming: methods, uses, computation. Management Science, 12, 254-313&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(3) ReVelle, Charles. &quot;Facility siting and integer-friendly programming.&quot; European Journal of Operational Research 65.2 (1993): 147-158.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-05-29T13:54:57.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4275" PostTypeId="2" ParentId="3813" CreationDate="2020-05-29T20:17:48.860" Score="6" Body="&lt;p&gt;OK, let's try to answer this better. I'm not going to illustrate or point to the right references. I just want to throw some pointers. Beside, I write about my vision which is not mainstream (and I believe it is not possible not to be personal about this: experts do not agree for the moment).&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;In essence, Mathematical Optimization (MO) and Machine Learning (ML)&#xA;are different but complementary technologies.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Yes and no. A few years back, ML (or parts of ML) was considered as a sub field of MO... ML uses MO to optimize its predictions (for instance, to minimize the discrepancy between its predictions and the reality (supervised learning)). But yes, they are complementary to say the least as one (ML) predicts, the other (MO) optimizes. The frontier between both is blurry.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;Simply put – Mixed Integer Programming (MIP) answers questions that&#xA;ML cannot. Machine learning makes predictions while MIP makes&#xA;decisions. They call Artificial Intelligence (AI) the combination of&#xA;both technologies.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Exactly, except that some AI experts kicked MO out of AI. And that AI is much broader than that.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;More specifically :&lt;/p&gt;&#xA;&lt;p&gt;ML predictions can determine the need to make a MO decision. ML&#xA;predictions can be used as MO decision constraints (when the data is&#xA;missing).&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Sorry, but I don't understand this. ML is able to find patterns in your data and reproduces up to a point the &amp;quot;past&amp;quot; (it can be used to innovate and optimize but it is not its strongest point: my view). If you want to be pro-active and make decisions based on optimization (and not observations) then you use MO. If you want to make decisions based on observations (and not optimization) you use ML. At Funartech, we combine both to take decisions. ML methods are data resources hungry, i.e. it is almost impossible to use ML if you do not have (clean) data. And most of the time, you need huge amounts of data.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;Other interesting examples are given here by FunArtech, a startup in&#xA;Montreal who claim to be the future of AI. For example, they claim&#xA;that &amp;quot;some research is conducted in order to predict on what variable&#xA;and how to branch in search trees.&amp;quot;&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;We do claim so because we have better practical and theoretical results. Yes we do.&lt;/p&gt;&#xA;&lt;p&gt;In a very basic and scholar approach, you could divide the use of ML and MO in four categories:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;the combination of ML and MO as two black boxes used separately. This has become mainstream in Québec (but not in Silicon Valley for instance) and other parts of the world. There are several examples on our website (&lt;a href=&quot;https://www.funartech.com/approach/use-cases&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.funartech.com/approach/use-cases&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and 3. You can use one to improve the other. MO can be used to optimize and improve ML (this IS ML...) and it goes the other way too: ML can be used to improve MO algorithms. The use of ML to branch in a search tree is one such example.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;we have found a new hybridization of both fields with new algorithms. This is an industrial secret for the moment.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;This is interesting and leads me to asking the following (broad, I&#xA;agree) questions :&lt;/p&gt;&#xA;&lt;p&gt;In your personal experience, as an OR scientist, to what extent and&#xA;how have you used ML for MO ?&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I my personal experience, I mix both all the time.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;What would you recommend MO practitioners to learn in priority ?&#xA;General ML techniques ? Neural networks ? Data statistics ?&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I would recommend to first figure out what type of problems you want to solve and to dig the corresponding ML/MO parts needed to solve such problems. ML is not easy but as a MO practitioner you have a base knowledge that will help you understand the mathematics of ML better than most ML experts that don't have such a mathematical background. Even if the ML field is broad (huge!), the basic principles and ideas are &amp;quot;small&amp;quot;. The level of mathematics required is the one of a first year student at university, so totally accessible.&lt;/p&gt;&#xA;" OwnerUserId="3622" LastEditorUserId="491" LastEditDate="2022-02-11T12:59:22.040" LastActivityDate="2022-02-11T12:59:22.040" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4276" PostTypeId="1" AcceptedAnswerId="4279" CreationDate="2020-06-01T10:43:18.220" Score="3" ViewCount="160" Body="&lt;p&gt;I'm studying an MIP model with a scheduling problem and I'm wondering if the space constraint is correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is space in the factory at that time, the block can be processed, where&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the block number&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$C_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt; are the strat time, completion time and processing time of block &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; respectively&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{i,j,f}=\begin{cases}1\quad\text{if}\,i\,\text{process before}\,j\,\text{at factory}\,f\\0\quad\text{otherwise}\end{cases}$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{i,f}=\begin{cases}1\quad\text{if}\,i\,\text{process at factory}\,f\\0\quad\text{otherwise}\end{cases}$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a big number&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$sp_i$&lt;/span&gt; is the required space of block &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{f,t}$&lt;/span&gt; is the available space of factory &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}S_i -M(1-y_{i,j,f}) &amp;amp;\le S_j\quad\forall i,j,f\\S_i + P_i &amp;amp;= C_i\quad \forall i\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The space constraint is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$sp_i \cdot y_{i,f} \le c_{f,t}\quad\forall i,j\quad\text{and}\quad t=S_i,\cdots,C_i.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3663" LastEditorUserId="3663" LastEditDate="2020-06-02T01:00:12.787" LastActivityDate="2020-06-02T01:00:12.787" Title="Space constraint in scheduling problem" Tags="|constraint|scheduling|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4277" PostTypeId="1" AcceptedAnswerId="4278" CreationDate="2020-06-01T15:14:36.087" Score="3" ViewCount="811" Body="&lt;p&gt;I am interested in OR, and I am looking for self-study resources targetted towards beginners.  If it helps, I am looking for something similar to the &lt;a href=&quot;https://www.google.com/books/edition/Schaum_s_Outline_of_Operations_Research/16sK1voVookC?hl=en&amp;amp;gbpv=1&amp;amp;printsec=frontcover&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Schaum's Outline of Operations Research&quot;&lt;/a&gt;, or a self-study resource where the theory is accompanied by many solved examples.&lt;/p&gt;&#xA;" OwnerUserId="3665" LastEditorUserId="123" LastEditDate="2021-02-16T15:49:48.800" LastActivityDate="2021-02-16T15:49:48.800" Title="Operations Research self-study resources for beginners" Tags="|books|" AnswerCount="2" CommentCount="3" ClosedDate="2020-06-02T02:11:15.977" ContentLicense="CC BY-SA 4.0" />
  <row Id="4278" PostTypeId="2" ParentId="4277" CreationDate="2020-06-01T16:07:13.043" Score="9" Body="&lt;p&gt;The book &quot;Model Building in Mathematical Programming&quot; by H. Paul Williams is a great resource. The first part is a practical approach to methods and the second part is all problems with description, formulation and solution.&lt;/p&gt;&#xA;" OwnerUserId="61" LastActivityDate="2020-06-01T16:07:13.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4279" PostTypeId="2" ParentId="4276" CreationDate="2020-06-01T17:15:34.117" Score="4" Body="&lt;p&gt;No, your space constraint is incorrect. There are multiple problems, including the fact that the range of the index &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; depends on variables &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_i$&lt;/span&gt;. Note that your current space constraint would not stop two jobs from using the same capacity simultaneously. (Your precedence constraint forces one job to start before another, but does not force the second job to wait until the first job has completed.) Also, your precedence constraint should be &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt;, not &lt;span class=&quot;math-container&quot;&gt;$\lt$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-06-01T17:15:34.117" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4280" PostTypeId="2" ParentId="4277" CreationDate="2020-06-01T17:56:53.173" Score="2" Body="&lt;p&gt;There are quite a few online courses (MOOCs) and other free video resources. You'll need to do a search to find them all.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-06-01T17:56:53.173" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4281" PostTypeId="1" AcceptedAnswerId="4284" CreationDate="2020-06-01T18:12:21.253" Score="21" ViewCount="6394" Body="&lt;p&gt;What are Operations Research problems which occur in your everyday life?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things that come to mind are for example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;driving to work: shortest path problem &lt;/li&gt;&#xA;&lt;li&gt;packing your backpack for vacation: knapsack problem or bin-packing &lt;/li&gt;&#xA;&lt;li&gt;planning for every weather condition: robust optimization&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When introducing non-math people to OR, I find it helpful to start with applications from everyday life and then explain that these question also companies have in larger dimensions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example packing your backpack is a everyday problem and packing trucks, ships, planes is a generalized problem which is industry-relevant.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2020-06-01T18:52:27.310" LastActivityDate="2020-06-06T13:18:07.237" Title="What are Operations Research problems which occur in everyday life?" Tags="|optimization|" AnswerCount="10" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4282" PostTypeId="2" ParentId="4281" CreationDate="2020-06-01T19:51:40.997" Score="10" Body="&lt;p&gt;Leaving home, running errands, and returning home: TSP, possibly with time windows.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-06-01T19:51:40.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4283" PostTypeId="2" ParentId="4281" CreationDate="2020-06-01T22:15:21.270" Score="13" Body="&lt;p&gt;Shopping for clothing, furniture, automobiles: decision making with multiple criteria.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Choosing a check-out lane at a store: queuing theory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bagging your own groceries: bin packing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Washing bird crap off your car: complexity theory (meaning it and trying to prove P = NP are equally futile).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-06-01T22:15:21.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4284" PostTypeId="2" ParentId="4281" CreationDate="2020-06-01T23:22:40.523" Score="1" Body="&lt;p&gt;Every morning, I update and (warm start) solve my Nonlinear Multivariate Dynamic Stochastic Optimal Control problem to figure out what to do that day.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-06-01T23:22:40.523" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4286" PostTypeId="2" ParentId="4281" CreationDate="2020-06-02T13:37:29.213" Score="12" Body="&lt;p&gt;Cutting your lasagna sheets to fit your baking tray with as little waste as possible is a version of the cutting stock problem &lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2020-06-02T13:37:29.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4287" PostTypeId="1" AcceptedAnswerId="4288" CreationDate="2020-06-02T13:55:54.213" Score="1" ViewCount="246" Body="&lt;p&gt;I'm trying to simplify a linear problem by removing &quot;useless&quot; variables and constraints.&#xA;After simplifying my initial problem and solving both instances with &lt;strong&gt;Cplex&lt;/strong&gt;, it seems like the results differ but are still really close.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Initial problem&lt;/strong&gt;&lt;br&gt;&#xA;objectiveValue =&quot;-606445.47942015168&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also interested in a dual value of some constraint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;dual=&quot;-17.47725841435172&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Simplified Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;objectiveValue=&quot;-606445.47942014073&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;dual=&quot;-17.6343&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to understand what I was doing wrong, I tried to simplify the original problem step by step.&#xA;After some simplification steps which didn't modify the solution, I'm facing this simple constraint : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;QStockeeContrat_(2)(Sc0)(ATS_SereneAtlantique)(07d03d2020)#1&#xA;- qStockee_(8)(Sc0)(PITS_SereneAtlantique)(07d03d2020)#7&#xA; = 0&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I decide to replace qStockee_(8)(Sc0)(PITS_SereneAtlantique)(07d03d2020)#7 variable by QStockeeContrat_(2)(Sc0)(ATS_SereneAtlantique)(07d03d2020)#1 variable in every constraint and in the objective function.&#xA;However the results before and after this change are different as I mentionned before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain to me why that is happening ?&lt;/p&gt;&#xA;" OwnerUserId="3671" LastActivityDate="2020-06-02T14:49:42.490" Title="Cplex giving different solutions for equivalent Linear problems" Tags="|linear-programming|cplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4288" PostTypeId="2" ParentId="4287" CreationDate="2020-06-02T14:29:56.663" Score="5" Body="&lt;p&gt;Cplex checks the feasiblity and optimality of the solution in floating point arithmetic. The default tolerance is &lt;span class=&quot;math-container&quot;&gt;$1e-6$&lt;/span&gt;, which means that a solution can violate the constraints by up to &lt;span class=&quot;math-container&quot;&gt;$1e-6$&lt;/span&gt; and the solution is still considered feasible. This also holds for the optimality certificates of the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So probably both solutions are optimal according to the tolerances, and you see a difference because by removing redundant constraints cplex will likely do different simplex iterations and arrive at a different solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further read:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/support/pages/node/460195&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/support/pages/node/460195&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/support/pages/node/456197&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/support/pages/node/456197&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/tolerances_and_ill_conditi.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.0/refman/tolerances_and_ill_conditi.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2020-06-02T14:49:42.490" LastActivityDate="2020-06-02T14:49:42.490" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4289" PostTypeId="1" AcceptedAnswerId="4291" CreationDate="2020-06-02T14:57:23.690" Score="2" ViewCount="113" Body="&lt;p&gt;In a mathematical integer optimization problem, if the objective function is represented as &lt;span class=&quot;math-container&quot;&gt;$\sum x_k \cdot M_k$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$M_k$&lt;/span&gt; is a non-linear function whose value is known and just plugged in to the objective function, thus acting as constant coefficients, is the objective function linear, since there are no product of variables are involved? When I try to feed in such a problem to an ILP solver, it doesn't complain of being not linear. What would be the explanation?&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="123" LastEditDate="2020-06-02T15:28:00.520" LastActivityDate="2020-06-03T19:49:45.673" Title="Linearity of an optimization problem which comprises the product of variables with constant values from a non-linear function" Tags="|optimization|linear-programming|integer-programming|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4290" PostTypeId="2" ParentId="4289" CreationDate="2020-06-02T15:01:32.350" Score="3" Body="&lt;p&gt;As you say:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&quot;If the value of &lt;span class=&quot;math-container&quot;&gt;$M_k$&lt;/span&gt; value is known and just plugged in to the objective function, thus acting as constant coefficients&quot;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you are summing variables multiplied by constant terms, which is linear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So all is good.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-06-02T15:01:32.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4291" PostTypeId="2" ParentId="4289" CreationDate="2020-06-02T15:01:43.873" Score="4" Body="&lt;p&gt;Yes, &lt;span class=&quot;math-container&quot;&gt;$\sum_k M_k x_k$&lt;/span&gt; is linear if each &lt;span class=&quot;math-container&quot;&gt;$M_k$&lt;/span&gt; is constant and &lt;span class=&quot;math-container&quot;&gt;$x_k$&lt;/span&gt; is a variable.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-06-02T15:01:43.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4292" PostTypeId="2" ParentId="4281" CreationDate="2020-06-02T16:51:19.367" Score="8" Body="&lt;p&gt;I have always thought of getting everything on the grocery list at the store is somewhat of a TSP problem.  I think most people (unknowingly) are trying to come up with a solution to the TSP grocery route in their head.&lt;/p&gt;&#xA;" OwnerUserId="3255" LastActivityDate="2020-06-02T16:51:19.367" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4294" PostTypeId="1" CreationDate="2020-06-03T05:46:44.940" Score="4" ViewCount="119" Body="&lt;p&gt;There is a lot of resources talking about the applications of  scheduling in business in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know about the applications of the particular case of single machine scheduling.&#xA;Any article or software will be appreciated. &lt;/p&gt;&#xA;" OwnerUserId="1188" LastActivityDate="2020-06-03T22:30:08.770" Title="Business/industrial applications of the single machine scheduling problem" Tags="|scheduling|applications|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4295" PostTypeId="2" ParentId="4281" CreationDate="2020-06-03T06:00:18.887" Score="6" Body="&lt;p&gt;Hanging up laundry to dry is a form of online bin packing.&#xA;I usually pick largest items first and pick a &quot;line&quot; with the smallest remaining capacity (&quot;best fit&quot;?)/&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2020-06-03T06:00:18.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4296" PostTypeId="2" ParentId="4289" CreationDate="2020-06-03T09:25:37.933" Score="2" Body="&lt;p&gt;What does it mean for a function to be linear?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is actually short for the function is linear in its variables. One way to define linearity is to say, that the derivative is constant. &#xA;For example &lt;span class=&quot;math-container&quot;&gt;$F(x)=5x+3$&lt;/span&gt; is linear in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$F'(x)=5$&lt;/span&gt;. Is it linear in &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;? Well you can write it as &lt;span class=&quot;math-container&quot;&gt;$F(y) = 0y+5x+3$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$F'(y)=0$&lt;/span&gt;. Because we treat &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; as a constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how do you know with respect to which variables you have to take the derivative? &#xA;Well, the solver (e.g. Cplex) get a list of variables from you. These are your variables. The other term might be computed, but as your solver sees it, are just numbers, no matter how you came up with them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So think about &lt;span class=&quot;math-container&quot;&gt;$M'_k(x)$&lt;/span&gt;. Is it constant? I think, this will answer your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck and keep on solving problems:)&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2020-06-03T19:49:45.673" LastActivityDate="2020-06-03T19:49:45.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4297" PostTypeId="1" CreationDate="2020-06-03T09:30:41.903" Score="4" ViewCount="103" Body="&lt;p&gt;The &lt;strong&gt;profitable tour problem&lt;/strong&gt; (PTP) is defined on a graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$|V|=n$&lt;/span&gt;, where each vertex &lt;span class=&quot;math-container&quot;&gt;$i \in V$&lt;/span&gt; has an associated prize &lt;span class=&quot;math-container&quot;&gt;$m_i \geq 0$&lt;/span&gt; and each edge &lt;span class=&quot;math-container&quot;&gt;$e \in E$&lt;/span&gt; has an associated cost &lt;span class=&quot;math-container&quot;&gt;$c_e \geq 0$&lt;/span&gt;.&#xA;The problem asks to find a subset of vertices and a tour visiting them, maximising the difference between prizes collected and travel costs paid.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{y} \in \{0,1\}^n$&lt;/span&gt; be a vector whose &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th entry is 1 iff vertex &lt;span class=&quot;math-container&quot;&gt;$i \in V$&lt;/span&gt; is included in the tour, and let &lt;span class=&quot;math-container&quot;&gt;$\text{TSP}(\mathbf{y})$&lt;/span&gt; denote the cost of the shortest tour over the vertices included by &lt;span class=&quot;math-container&quot;&gt;$\mathbf{y}$&lt;/span&gt;.&#xA;Furthermore denote the vector of profits as &lt;span class=&quot;math-container&quot;&gt;$\mathbf{m} = (m_1, \ldots, m_n)$&lt;/span&gt;.&#xA;Then one can write the PTP as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \max_{\mathbf{y} \in \{0,1\}^n} \big\{ \mathbf{m}^\intercal \mathbf{y} - \text{TSP}(\mathbf{y}) \big\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a problem which is, in some informal sense, &lt;em&gt;dual&lt;/em&gt; to the PTP.&#xA;My problem can be written as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \max_{\mathbf{y} \in \{0,1\}^n} \big\{ \text{TSP}(\mathbf{y}) - \mathbf{m}^\intercal \mathbf{y} \big\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, I am looking for a subset of vertices of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; over which the shortest tour is longest but, to include a vertex &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in my tour, I have to pay a penalty &lt;span class=&quot;math-container&quot;&gt;$m_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been thinking about it for a while, but I feel like the opposite optimisation direction between the outer maximisation problem and the inner minimisation (hidden in &lt;span class=&quot;math-container&quot;&gt;$\text{TSP}$&lt;/span&gt;) makes it hard to tackle this problem simply with a transformation from an existing &lt;a href=&quot;https://or.stackexchange.com/a/3067/136&quot;&gt;TSP with profits&lt;/a&gt;, such as the PTP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something obvious? Is there a straightforward transformation to a well-known problem that I don't see?&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2020-06-04T06:38:16.430" LastActivityDate="2020-06-04T06:38:16.430" Title="Can this problem be modelled with a transformation from a known TSP with profits?" Tags="|modeling|combinatorial-optimization|traveling-salesman|" AnswerCount="0" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="4298" PostTypeId="2" ParentId="4289" CreationDate="2020-06-03T10:57:53.330" Score="2" Body="&lt;p&gt;&lt;strong&gt;Assuming that &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; depends on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;&lt;/strong&gt;, your function is non-linear. If not, it is linear and all is well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the dependency does exist, just because a linear solver doesn't support the proper input, that doesn't make the function linear, although sometimes people find that assumption good enough for some specific application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The correct way to solve a problem like this is to use an MINLP solver that supports callbacks, such as Knitro, our own Octeract Engine (v 1.14 and above), and, if memory serves, BONMIN.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If (part of) the problem is treated as black box, then the solver will keep updating the values of your objective (through the callbacks) and its derivatives and &lt;strong&gt;use new constants for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; in every iteration&lt;/strong&gt;, which will most likely result in a different answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is vastly different than classic solver behaviour where the problem is defined in the beginning and can't be changed during the solving process.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-06-03T15:30:44.637" LastActivityDate="2020-06-03T15:30:44.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4299" PostTypeId="2" ParentId="4281" CreationDate="2020-06-03T11:43:58.397" Score="20" Body="&lt;p&gt;This is literally every conversation I have with investors, so here's my $.02.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Others have described great examples, so I will cover a different aspect:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found the use of (everyday) examples makes things more difficult, so I tend to avoid it like the plague.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason is that, for a non-math person, once we describe a single application their mind will latch on to that and never let go, especially if they are an authority in something else (e.g. business). If you describe a TSP, then this is suddenly all that OR is about, and that's it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have consistently found it excruciatingly difficult to overwrite that idea once it has taken hold. This is very nasty because it can happen in 5 seconds and can consume an entire meeting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My strategy is to (i) refuse to name applications, or (ii) name at least 20 in a rapid sequence to make the point that the same technology is used for all of these things. In the latter case, I will specifically refuse to go back to any of those 20 examples and describe that in more detail, because I will politely tell my fellow human &quot;that is not what this conversation is about. We can discuss that in another meeting if you want&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Non-math people are often smarter than us, so it's unfair to assume they have to be spoon fed. As long as we don't overwhelm them with jargon, they can keep up just fine, it just takes more skill to bridge the gap seamlessly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I typically do it is to force people to think, so I say things like: &quot;optimisation is a decision-making science. The results of optimisation tell us exactly how to run complex systems. Think about that for a minute&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then build the conversation based on how they respond. This works because it's suddenly about them, not me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once we make a statement, people's mind will seek out the closest thing they know, e.g., &quot;oh so is this like machine learning?&quot;. &quot;No&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can go on for quite a while, and we have to stick to our guns so that people become open to the idea that we are describing a truly new concept, so they can't be &quot;lazy&quot; and reuse their existing knowledge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is only after they are able to describe said concept in their own words that I feel safe describing any examples in detail.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-06-03T11:43:58.397" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4300" PostTypeId="2" ParentId="4281" CreationDate="2020-06-03T13:20:45.987" Score="7" Body="&lt;p&gt;Woodworking: stock cutting/bin packing.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1D for cutting e.g. 1x, 2x dimensional to required length, optimizing for lowest cost - typically priced by volume, but longer stock of equivalent quality can be significantly more expensive&lt;/li&gt;&#xA;&lt;li&gt;2D, guillotine cuts: sheet goods, e.g. cutting plywood to size. Easier to make edge-to-edge cuts, but may waste more material vs. more difficult stopped cuts with less waste&lt;/li&gt;&#xA;&lt;li&gt;3D: cutting and milling smaller 3d parts out of bigger hunks of wood&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is applicable to personal projects (I use it all the time and have written programs specifically to extract reports from SketchUp and optimize my purchases), and is also directly applicable to production-line manufacturing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then there is optimizing the order of operations: cutting (tools, order of cuts, switching tools), assembly, prep work, finishing. e.g. can you do some finishing work (e.g. sealing faces of sheet goods) first and start cuts on other stock while it cures?&lt;/p&gt;&#xA;" OwnerUserId="3042" LastActivityDate="2020-06-03T13:20:45.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4301" PostTypeId="1" AcceptedAnswerId="4304" CreationDate="2020-06-03T15:05:29.603" Score="5" ViewCount="2033" Body="&lt;p&gt;I am using Monte-Carlo simulations in Microsoft Excel to determine optimum reorder points and safety stock levels. I have the demand patterns of the last one year of the product. Using that I can construct a cumulative distribution function of the demand to draw random samples from and construct a table of demand on each day for a whole year.&lt;/p&gt;&#xA;&lt;p&gt;One problem that I found was that the simulation is based on demand patterns alone. That is, if the company did not forecast at all, then the individual runs of the simulation would generate the demand pattern that they can expect in a year. However, if the company is able to forecast demand with 100% accuracy, then there would be no need to keep a safety stock (or very little of it). Forecast accuracy is something I am not sure how to incorporate in my model. There are formulas for calculating safety stock such as using the Mean Absolute Deviation from the forecasted demand but I would like to develop a simulation model that takes into account forecast accuracy.&lt;/p&gt;&#xA;" OwnerUserId="3458" LastEditorUserId="491" LastEditDate="2022-01-04T16:26:48.373" LastActivityDate="2022-01-04T16:26:48.373" Title="Monte-Carlo Simulations in inventory management" Tags="|inventory|simulation|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4302" PostTypeId="1" CreationDate="2020-06-03T15:12:33.440" Score="3" ViewCount="62" Body="&lt;p&gt;I am trying to linearise the following expresssion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C(k) = B(k) e^{-d(k)}, B(k) \ge 0 , d(k) \ge 0 $&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to do this by using SOS2 sets. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set &lt;span class=&quot;math-container&quot;&gt;$X(k) = e^{-d(k)}$&lt;/span&gt; and I get &lt;span class=&quot;math-container&quot;&gt;$C(k) = B(k) X(k)$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By setting &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA;u_{1}(k) = 0.5 (B(k) + X(k)) \\&#xA;u_{2}(k) = 0.5 (B(k) - X(k))&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C(k) = u_{1}(k)^2 - u_{2}(k)^2 \\ &#xA; u_{1}(k) = 0.5 (B(k) + X(k)) \\&#xA; u_{2}(k) = 0.5 (B(k) - X(k)) \\&#xA; X(k) = e^{-d(k)}&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;span class=&quot;math-container&quot;&gt;$y_{1}(k) = u_{1}^2, y_{2}(k) = u_{2}^2, step = 0.1$&lt;/span&gt; I can linearise for &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; points  as follows: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA;y_{1}(k) = \sum_{i=1}^N (step (i-1))^2 \lambda_{k}^{u1}(i) \\&#xA;u_{1}(k) = \sum_{i=1}^N step (i-1) \lambda_{k}^{u1}(i)\\&#xA;\sum_{i=1}^N \lambda_{k}^{u1}(i) = 1.0 &#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA;y_{2}(k) = \sum_{i=1}^N (step (i-1))^2 \lambda_{k}^{u2}(i)\\&#xA;u_{2}(k) = \sum_{i=1}^N step (i-1) \lambda_{k}^{u2}(i) \\&#xA;\sum_{i=1}^N \lambda_{k}^{u2}(i) = 1.0 &#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X(k) = e^{-d(k)}$&lt;/span&gt; is linearised as follows: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA;X(k) = \sum_{i=1}^N e^{step (i-1)} \lambda_{k}^{d}(i) \\&#xA;d(k) = \sum_{i=1}^N step (i-1) \lambda_{k}^{d}(i) \\&#xA;\sum_{i=1}^N \lambda_{k}^{d}(i) = 1.0 &#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So finally, the  model becomes linearised to: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA;C(k) = y_{1}(k) - y_{2}(k) \\ &#xA;y_{1}(k) = \sum_{i=1}^N (step (i-1))^2 \lambda_{k}^{u1}(i) \\&#xA;u_{1}(k) = \sum_{i=1}^N step (i-1) \lambda_{k}^{u1}(i)\\&#xA;\sum_{i=1}^N \lambda_{k}^{u1}(i)) = 1.0  \\ &#xA;y_{2}(k) = \sum_{i=1}^N (step (i-1))^2 \lambda_{k}^{u2}(i)\\&#xA;u_{2}(k) = \sum_{i=1}^N step (i-1) \lambda_{k}^{u2}(i) \\&#xA;\sum_{i=1}^N \lambda_{k}^{u2}(i)) = 1.0  \\ &#xA;u_{1}(k) = 0.5 (B(k) + X(k)) \\&#xA;u_{2}(k) = 0.5 (B(k) - X(k)) \\ &#xA;X(k) = \sum_{i=1}^N e^{step (i-1)} \lambda_{k}^{d}(i) \\&#xA;d(k) = \sum_{i=1}^N (step (i-1)) \lambda_{k}^{d}(i) \\&#xA;\sum_{i=1}^N \lambda_{k}^{d}(i) = 1.0 &#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Is what I have done correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Do I have to distinguish between different lamdas or  do they have to be the same?  (&lt;span class=&quot;math-container&quot;&gt;$\lambda_{k}^{u2}(i)$&lt;/span&gt; the same as &lt;span class=&quot;math-container&quot;&gt;$\lambda_{k}^{u1}(i)$&lt;/span&gt; the same as &lt;span class=&quot;math-container&quot;&gt;$\lambda_{k}^{d}(i)$&lt;/span&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2020-06-03T15:12:33.440" Title="Linearisation using SOS2" Tags="|mixed-integer-programming|nonlinear-programming|linearization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4303" PostTypeId="2" ParentId="4301" CreationDate="2020-06-03T18:34:10.627" Score="6" Body="&lt;p&gt;Why not build the forecasting directly into your simulation? So, in each period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, you generate a forecast &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; using whatever method you want (moving average, exponential smoothing, etc.), and choose an order quantity based on the forecast and the current estimate of the standard deviation of the forecast error. Then generate the random demand, calculate the forecast error, and update the estimates of the SD of the FE.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-06-03T18:34:10.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4304" PostTypeId="2" ParentId="4301" CreationDate="2020-06-03T20:17:47.647" Score="7" Body="&lt;p&gt;I'm in general agreement with Larry's answer, but with one qualification. If you are generating random demand quantities from the sample CDF for a year, your demands will not conform to any trends or seasonal patterns (or even just short-term autocorrelation) in the historical data. If you then generate forecasts from the &lt;em&gt;randomly sampled&lt;/em&gt; observations, the forecasts will also not contain trend or seasonality (and perhaps not autocorrelation, or the wrong autocorrelations), so you will be missing a chance for greater accuracy. If you use rolling forecasts from the &lt;em&gt;historical&lt;/em&gt; data, then there will be a mismatch between forecasts and &quot;actual&quot; (meaning sampled) demand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to mitigate this is to first analyze the historical data and see if you can suss out any patterns. Use them to build a model for the demand process. In the simulation, obtain demand observations from this model (using it to predict the current observation, then adding a bit of noise). Simultaneously use forecasts obtained from the simulated data (possibly using the same model, possibly using something similar such as exponential smoothing, perhaps with a seasonal component).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-06-03T20:17:47.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4305" PostTypeId="1" AcceptedAnswerId="4326" CreationDate="2020-06-03T21:19:34.193" Score="3" ViewCount="171" Body="&lt;p&gt;Given that R possesses superior data pre-processing and post-processing packages, I am thinking of coding a matheuristic using R for publishing in an academic research journal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am unable to locate papers which mention the use of R whether in formulating exact MIP formulations (using the R APIs of either CPLEX, Gurobi) or coding pure heuristics or metaheuristics. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess it might be due to its inherent slower processing speed than C++ or Java or even Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, R seems easier to code than C++ or Java when pre-processing data or adding constraints and fixing variables, thus I would like to enquire the chances of getting published via using R instead of C++ or Java or even Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Greatly appreciate your kind inputs!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="3682" LastEditDate="2020-06-03T22:35:48.073" LastActivityDate="2020-06-06T10:41:19.403" Title="Using R for coding Matheuristic for Research Publication" Tags="|solver|cplex|gurobi|academia|r|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4306" PostTypeId="2" ParentId="4294" CreationDate="2020-06-03T22:30:08.770" Score="1" Body="&lt;p&gt;As for performance analysing, many production systems give rise to single machine models. For instance, if there is a single bottleneck in a multi-machine environment, then the job sequence at the bottleneck typically determines the performance of the entire system. In such a case, it makes sense to schedule the bottleneck first and all other operations afterwards. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As detailed scheduling, by defining a suitable objective function we can reduce WIP inventory in the production line or implying just-in-time function to decrease the late deliveries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As CPU Scheduling, in a simple system running a single process, the time spent waiting for I/O is wasted, and those CPU cycles are lost forever. A scheduling system allows one process to use the CPU while another is waiting for I/O, thereby making full use of otherwise lost CPU cycles. The challenge is to make the overall system as &quot;efficient&quot; and &quot;fair&quot; as possible, subject to varying and often dynamic conditions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, many other applications could be found in the papers or scheduling software host.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-06-03T22:30:08.770" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4307" PostTypeId="2" ParentId="4305" CreationDate="2020-06-03T22:56:22.850" Score="7" Body="&lt;p&gt;You mention data pre-/post-processing. If what you propose to do is in the context of data science (for instance, a matheuristic for outlier identification to be embedded in some statistical data-torturing exercise), I don't see any problem at all. If what you propose to do is not specifically related to data science (for instance, a heuristic for solving traveling salesperson problems with regularly spaced bathroom breaks), then I suspect it will come down to how you benchmark your heuristic. As a reviewer, if most of the work is done in a separate solver (CPLEX, Gurobi, SCIP, ...), I don't see a problem. If your R code does a significant amount of work, and if you are benchmarking against some published alternatives that you have coded in R, I &lt;em&gt;probably&lt;/em&gt; wouldn't have a problem, provided that I was fairly confident the difference between your method and the benchmark (your method presumably being faster) was not due to some inefficiency in how R does something (i.e., some &quot;gotcha&quot; afflicting the benchmark that wouldn't happen if you wrote the benchmark in C++ or Java or ...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's one other wrinkle: if your matheuristic &lt;em&gt;needs&lt;/em&gt; R for some reason (cannot be translated to Python or whatever the current trendy language is), it makes the matheuristic somewhat less generally useful, and reviewers may view that as a drawback.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclaimer: I use R for some things, so I'm not prone to fainting at the mention of it. People (meaning reviewers) who do optimization only will have heard of it but may not be familiar with it, so in the first round they may ask &quot;Why R?&quot; unless you explain why in the paper.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-06-03T22:56:22.850" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4308" PostTypeId="2" ParentId="4281" CreationDate="2020-06-03T23:37:34.153" Score="7" Body="&lt;p&gt;To me, everything looks like a newsvendor problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How many apples to buy at the grocery store? Newsvendor!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How much money to contribute to your healthcare savings account? Newsvendor!&lt;/li&gt;&#xA;&lt;li&gt;How much time to allocate for a meeting you're scheduling? Newsvendor!&lt;/li&gt;&#xA;&lt;li&gt;How much data to buy in your cell phone plan? Newsvendor!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Pretty much any time you're trying to match an unknown quantity, and the per-unit penalty is different if you're too high vs. too low, it can be modeled as a newsvendor problem.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-06-03T23:37:34.153" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4309" PostTypeId="1" AcceptedAnswerId="4310" CreationDate="2020-06-04T02:52:26.937" Score="4" ViewCount="2663" Body="&lt;p&gt;I am trying to solve a model with Pyomo and struggling with indexing. Below is a simple problem instance, where you can also see the error. The message is straightforward and self-explanatory but failed to resolve the issue. It stems from using the &lt;code&gt;k_nearest_vehicles&lt;/code&gt; dictionary which is keyed by the items of the &lt;code&gt;Riders&lt;/code&gt; list. I tried to use &lt;code&gt;Xindex&lt;/code&gt; as solution but didn't quite work. Please let me know where I am doing wrong.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pio&#xA;M_threshold = 30&#xA;Riders = [(1926.0, 0, 0)]&#xA;k_nearest_vehicles = {(1926.0, 0, 0): [(913.0, 0, 36), (913.0, 0, 37), (917.0, 0, 0)]}&#xA;zone_to_zone_tt = {(913.0, 1926.0): 27.523453,&#xA;                  (917.0, 1926.0): 29.937351}&#xA;&#xA;m= pio.ConcreteModel('Transportation_Problem')&#xA;Xindex = [(i,j) for j in Riders for i in k_nearest_vehicles[j]]&#xA;m.x = pio.Var([i for i in k_nearest_vehicles[j] for j in Riders],&#xA;              [j for j in Riders],domain=pio.NonNegativeReals)&#xA;m.OBJ = pio.Objective(expr = (sum((zone_to_zone_tt[i[0],j[0]]-M_threshold)*m.x[i,j] &#xA;                        for (i,j) in Xindex)), sense=pio.minimize)&#xA;def Cons1(m,i):&#xA;    return (sum(m.x[i,j] for j in Riders) &amp;lt;= 1)&#xA;m.AxbConstraint1 = pio.Constraint([i for i in k_nearest_vehicles[j] for j in Riders], rule=Cons1)&#xA;&#xA;def Cons2(m,j):&#xA;    return (sum(m.x[i,j] for i in k_nearest_vehicles[j]) &amp;lt;= 1)&#xA;m.AxbConstraint2 = pio.Constraint(Riders, rule=Cons2)&#xA;&#xA;opt = pio.SolverFactory()&#xA;results = opt.solve(m, tee=True)&#xA;&#xA;&#xA;ERROR: Rule failed when generating expression for constraint AxbConstraint1&#xA;    with index (913.0, 0, 36): TypeError: Cons1() takes 2 positional arguments&#xA;    but 4 were given&#xA;ERROR: Constructing component 'AxbConstraint1' from data=None failed:&#xA;    TypeError: Cons1() takes 2 positional arguments but 4 were given&#xA;---------------------------------------------------------------------------&#xA;TypeError                                 Traceback (most recent call last)&#xA;~/anaconda3/lib/python3.7/site-packages/pyomo/core/base/misc.py in apply_indexed_rule(obj, rule, model, index, options)&#xA;     56             if index.__class__ is tuple:&#xA;---&amp;gt; 57                 return rule(model, *index)&#xA;     58             elif index is None and not obj.is_indexed():&#xA;&#xA;TypeError: Cons1() takes 2 positional arguments but 4 were given&#xA;&#xA;During handling of the above exception, another exception occurred:&#xA;&#xA;TypeError                                 Traceback (most recent call last)&#xA;~/anaconda3/lib/python3.7/site-packages/pyomo/core/base/misc.py in apply_indexed_rule(obj, rule, model, index, options)&#xA;     71             if options is None:&#xA;---&amp;gt; 72                 return rule(model)&#xA;     73             else:&#xA;&#xA;TypeError: Cons1() missing 1 required positional argument: 'i'&#xA;&#xA;During handling of the above exception, another exception occurred:&#xA;&#xA;TypeError                                 Traceback (most recent call last)&#xA;&amp;lt;ipython-input-62-353b262f79fa&amp;gt; in &amp;lt;module&amp;gt;&#xA;     14 def Cons1(m,i):&#xA;     15     return (sum(m.x[i,j] for j in Riders) &amp;lt;= 1)&#xA;---&amp;gt; 16 m.AxbConstraint1 = pio.Constraint([i for i in k_nearest_vehicles[j] for j in Riders], rule=Cons1)&#xA;     17 &#xA;     18 def Cons2(m,j):&#xA;&#xA;~/anaconda3/lib/python3.7/site-packages/pyomo/core/base/block.py in __setattr__(self, name, val)&#xA;    576                 # Pyomo components are added with the add_component method.&#xA;    577                 #&#xA;--&amp;gt; 578                 self.add_component(name, val)&#xA;    579             else:&#xA;    580                 #&#xA;&#xA;~/anaconda3/lib/python3.7/site-packages/pyomo/core/base/block.py in add_component(self, name, val)&#xA;   1129                              _blockName, str(data))&#xA;   1130             try:&#xA;-&amp;gt; 1131                 val.construct(data)&#xA;   1132             except:&#xA;   1133                 err = sys.exc_info()[1]&#xA;&#xA;~/anaconda3/lib/python3.7/site-packages/pyomo/core/base/constraint.py in construct(self, data)&#xA;    777                                              _init_rule,&#xA;    778                                              _self_parent,&#xA;--&amp;gt; 779                                              ndx)&#xA;    780                 except Exception:&#xA;    781                     err = sys.exc_info()[1]&#xA;&#xA;~/anaconda3/lib/python3.7/site-packages/pyomo/core/base/misc.py in apply_indexed_rule(obj, rule, model, index, options)&#xA;     78             if options is None:&#xA;     79                 if index.__class__ is tuple:&#xA;---&amp;gt; 80                     return rule(model, *index)&#xA;     81                 elif index is None and not obj.is_indexed():&#xA;     82                     return rule(model)&#xA;&#xA;TypeError: Cons1() takes 2 positional arguments but 4 were given&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also wanted to share the Gurobi way of modeling, which works like a champ. But, I am trying to re-write this in Pyomo to be able to use open source solvers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from gurobipy import *&#xA;m = Model(&quot;My_problem&quot;)&#xA;x = {(i,j):m.addVar(vtype=GRB.CONTINUOUS, name= &quot;x%s&quot;%str([i,j]))&#xA;                    for j in Riders for i in k_nearest_vehicles[j]}&#xA;m.setObjective(quicksum((zone_to_zone_tt[i[0],j[0]]-M_threshold)*x[i,j] &#xA;                        for (i,j) in x.keys()), GRB.MINIMIZE)&#xA;for i in Vehicles:&#xA;    m.addConstr(quicksum(x[i,j] for j in Riders if (i,j) in x.keys()) &amp;lt;= 1,&#xA;               name=&quot;each_vehicle_to_at_most_one_rider%s&quot;%([i]))&#xA;for j in Riders:&#xA;    m.addConstr(quicksum(x[i,j] for i in Vehicles if (i,j) in x.keys()) &amp;lt;= 1,&#xA;               name=&quot;each_rider_to_at_most_one_vehicle%s&quot;%([j]))&#xA;m.update()&#xA;m.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="518" LastEditorUserId="518" LastEditDate="2020-06-04T05:44:47.540" LastActivityDate="2020-06-04T06:15:39.400" Title="Pyomo add constraint error: Rule failed when generation expression for constraint" Tags="|optimization|linear-programming|pyomo|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4310" PostTypeId="2" ParentId="4309" CreationDate="2020-06-04T06:15:39.400" Score="2" Body="&lt;p&gt;In Pyomo, indexes are sets and variables defined over those sets. In your problem, you need to define a set of all members of &lt;strong&gt;Riders&lt;/strong&gt; and all members of &lt;strong&gt;k_nearest_vehicles&lt;/strong&gt;. To define an index set for the combination of these two sets, in Pyomo you can indicate that the members of a set are restricted to be in the cross product of two other sets, you can use the within keyword:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model.combination = Set(within=m.Vehicles * m.Riders)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also if you can preprocess (as you also mentioned) your driver and vehicles it will make your model easy to understand. The following is a simplified form of your problem (based on my understanding) which I could solve to optimality using Cplex and glpk.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pio&#xA;M_threshold = 30&#xA;Riders = [1926.0]&#xA;k_nearest_vehicles = {1926.0: [913.0,917.0]}&#xA;&#xA;zone_to_zone_tt = {(913.0, 1926.0): 27.523453, (917.0, 1926.0): 29.937351}&#xA;&#xA;m = pio.ConcreteModel('Transportation_Problem')&#xA;m.Riders_ind = set(range(len(Riders)))&#xA;m.KNV_ind = set(range(len(k_nearest_vehicles[1926.0])))&#xA;m.x = pio.Var(m.KNV_ind,m.Riders_ind,domain=pio.NonNegativeReals)&#xA;m.OBJ = pio.Objective(expr = (sum((zone_to_zone_tt[k_nearest_vehicles[1926.0][i],Riders[j]]-M_threshold)*m.x[i,j] for i in m.KNV_ind for j in m.Riders_ind)),sense=pio.minimize)&#xA;def Cons1(m,i):&#xA;return (sum(m.x[i,j] for j in m.Riders_ind) &amp;lt;= 1)&#xA;m.AxbConstraint1 = pio.Constraint([i for i in m.KNV_ind for j in m.Riders_ind],rule=Cons1)&#xA;&#xA;def Cons2(m,j):&#xA;return (sum(m.x[i,j] for i in m.KNV_ind) &amp;lt;= 1)&#xA;m.AxbConstraint2 = pio.Constraint(m.Riders_ind, rule=Cons2)&#xA;&#xA;opt = pio.SolverFactory('cplex')&#xA;results = opt.solve(m, tee=True)&#xA;print(results)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GLPSOL: GLPK LP/MIP Solver, v4.65&#xA;Parameter(s) specified in the command line:&#xA;--write C:\TEMP\tmpfm31ikz2.glpk.raw --wglp C:\TEMP\tmpi5vh_ads.glpk.glp&#xA;--cpxlp C:\TEMP\tmp4niztoc0.pyomo.lp&#xA;Reading problem data from 'C:\TEMP\tmp4niztoc0.pyomo.lp'...&#xA;4 rows, 3 columns, 5 non-zeros&#xA;29 lines were read&#xA;Writing problem data to 'C:\TEMP\tmpi5vh_ads.glpk.glp'...&#xA;21 lines were written&#xA;GLPK Simplex Optimizer, v4.65&#xA;4 rows, 3 columns, 5 non-zeros&#xA;Preprocessing...&#xA;1 row, 2 columns, 2 non-zeros&#xA;Scaling...&#xA; A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00&#xA;Problem data seem to be well scaled&#xA;Constructing initial basis...&#xA;Size of triangular part is 1&#xA;*     0: obj =   0.000000000e+00 inf =   0.000e+00 (2)&#xA;*     2: obj =  -2.476547000e+00 inf =   0.000e+00 (0)&#xA;OPTIMAL LP SOLUTION FOUND&#xA;Time used:   0.0 secs&#xA;Memory used: 0.0 Mb (40400 bytes)&#xA;Writing basic solution to 'C:\TEMP\tmpfm31ikz2.glpk.raw'...&#xA;16 lines were written&#xA;&#xA;Problem: &#xA;- Name: unknown&#xA;  Lower bound: -2.476547&#xA;  Upper bound: -2.476547&#xA;  Number of objectives: 1&#xA;  Number of constraints: 4&#xA;  Number of variables: 3&#xA;  Number of nonzeros: 5&#xA;  Sense: minimize&#xA;Solver: &#xA;- Status: ok&#xA;  Termination condition: optimal&#xA;  Statistics: &#xA;    Branch and bound: &#xA;      Number of bounded subproblems: 0&#xA;      Number of created subproblems: 0&#xA;  Error rc: 0&#xA;  Time: 0.2938816547393799&#xA;Solution: &#xA;- number of solutions: 0&#xA;  number of solutions displayed: 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-06-04T06:15:39.400" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4311" PostTypeId="1" AcceptedAnswerId="4314" CreationDate="2020-06-04T08:32:34.517" Score="13" ViewCount="708" Body="&lt;p&gt;Developing operation research applications for industry clients is often very costly since it is in my experience often a custom special development for the client. The cost of developing a running system is often far beyond 100k $/€/... and then there is also maintenance and if you need commercial solvers, then there are also a lot of repetitive costs for licensing, etc. while in production.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I estimate the savings a potential operations research application has? (Maybe one can break this down into the maintenance costs/development costs/savings)&lt;/li&gt;&#xA;&lt;li&gt;It would be also interesting to differentiate before/after you developed the solution and it is running in production? (Since also after it is running it is difficult to measure the improvement.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some thoughts:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A critical topic is always when people at the company solving this problem (or part of the problem) currently as their jobs. Then, maybe you estimate that instead of two people doing this job, now maybe one person can do the job. Then one could estimate based on their salaries that they might save this money per year.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There the before/after effects are in general good measures after the system is running in production for some time. But it is a highly sensitive topic, because we do not want anybody to lose their jobs. This is a complicated topic that might be in itself a separate question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second potential savings is that the solution obtained by the tool is far superior to the current heuristic solution done by the people. However, this is difficult to estimate before and even after you are running your solution. Because most often you are only solving optimally a small frame of large problem and if there are a lot of soft constraints and, in the end, the solution is not taken as it is and analyzed, and different solutions are compared by the people working, then how an I access the benefit of the solution vs. the solution before?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="1160" LastEditDate="2020-06-05T17:54:42.500" LastActivityDate="2020-06-05T17:54:42.500" Title="How can I estimate the monetary savings of a operation research application?" Tags="|optimization|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4312" PostTypeId="2" ParentId="4311" CreationDate="2020-06-04T08:51:18.310" Score="9" Body="&lt;p&gt;I think this is easiest for applications where cost reduction is an explicit goal of the model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say a company is in the delivery business and uses some specific method / heuristic to assess routes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your solution finds better routes and you can compare them directly, you could compute something like 10% reduction in delivery cost and translate that in monetary savings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other kinds of improvements (e.g. reduced risks) always have to be translated into a common (monetary) unit, I guess.&lt;/p&gt;&#xA;" OwnerUserId="126" LastEditorUserId="123" LastEditDate="2020-06-04T13:43:19.753" LastActivityDate="2020-06-04T13:43:19.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4313" PostTypeId="2" ParentId="3654" CreationDate="2020-06-04T09:42:10.940" Score="2" Body="&lt;p&gt;Gurobi has some slides on what they did in the recent 9.0 version, which added the support for qcqp. It is not much and highlevel, but it might be still beneficial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://pages.gurobi.com/rs/181-ZYS-005/images/2020-01-14_Non%20Convex%20Quadratic%20Optimization%20in%20Gurobi%209.0%20Webinar.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pages.gurobi.com/rs/181-ZYS-005/images/2020-01-14_Non%20Convex%20Quadratic%20Optimization%20in%20Gurobi%209.0%20Webinar.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is even a video for the slides:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/de/resource/non-convex-quadratic-optimization/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/de/resource/non-convex-quadratic-optimization/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2020-06-04T09:42:10.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4314" PostTypeId="2" ParentId="4311" CreationDate="2020-06-04T16:08:38.820" Score="5" Body="&lt;p&gt;Your application is either replacing some other application (including tasks that are done manually), enhances an existing solution, or it's just a new application altogether. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although monetary metrics such as the amount of savings, added revenue due to better handling of requests, shorter run time, better results, and so on are more tangible, depending on the type of application, you may need to talk about savings in terms of non-monetary metrics too. So, let me share two cases where non-monetary discussions can help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose you have an application that helps people plan their days better (call it scheduler). You may just help the planners to be more productive and have larger uninterrupted stretches of time. What are the benefits? Maybe you can find studies that show how much time is wasted on average in a normal day of a planner by just doing very routine and non-value-added tasks, and then discuss how much of those times can be saved by your application and be used better (not an OR application but think of Slack or MS Teams).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or maybe you have an application that is opening a type of market to the business that was not even possible. To add to Robert's delivery business, consider an application that allows a business to enter a market that they've not sought before. Maybe one is a company doing linehaul but with your application, they can also handle less-than-truckload. Obviously, one needs to do a thorough study to forecast how much of the market one can get but sometimes, you can just talk about the possibilities and let the client's decision-makers' minds do the job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now about your last point, regarding applications that can solve a small frame of problem optimally but may fail as more constraints are added. I think that's another problem. Because, when you talk about an application, you should make sure you cover a range of different scenarios and be up-front about its limitations. Think of this similar to writing unit tests for your code! You should know what each function does and what it can't do and you should have proper testing and messages in place to let the user know what they can and can't expect from your application.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2020-06-04T16:08:38.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4315" PostTypeId="1" CreationDate="2020-06-04T18:18:49.297" Score="3" ViewCount="3242" Body="&lt;p&gt;I am implementing a NLP problem in pyomo, and I am getting some issues for this constraint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\forall i \in \lbrace 1,  N \rbrace , \forall j \in \left\{1, M \right\}:  Y_{i,j} \cdot S_{i,j} = \max_{k} \big(p_{i,k} \cdot S_{i,k} \big) &#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Y_{i,j}$&lt;/span&gt; is a binary decision variable equal to 1 if element j is a match to i, 0 otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_{i,j}$&lt;/span&gt; is a continous decision variable such as &lt;span class=&quot;math-container&quot;&gt;$0 \leq S_{i,j} \leq 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{i,j}$&lt;/span&gt; is a binary parameter equal to 1 if j is a candidate of i, 0 otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, this constraint is to select j for i such as &lt;span class=&quot;math-container&quot;&gt;$S_{i,j}$&lt;/span&gt; is the maximum value. Eventually, I have another constraint to ensure the unicity of the selected match:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\forall i \in \lbrace 1,  N \rbrace :  \sum_{j=1}^M Y_{i,j} = 1&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to implement the former constraint in pyomo, I have tried this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    def pred_selection_rule(model, i, j):&#xA;        return (model.Yij[i,j] * model.Sij[i,j] == max(model.pij[i,k] * model.Sij[i,k] for k in model.M))&#xA;    model.pred_selection = Constraint(model.N, model.M, rule=pred_selection_rule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I got this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ERROR: Rule failed when generating expression for constraint pred_selection&#xA;    with index (1, 1): TypeError: Cannot create a compound inequality with&#xA;    identical upper and lower&#xA;        bounds using strict inequalities: constraint infeasible: 0.0  &amp;lt;&#xA;        Sij[1,40] and Sij[1,40] &amp;lt; 0.0&#xA;ERROR: Constructing component 'pred_selection' from data=None failed:&#xA;        TypeError: Cannot create a compound inequality with identical upper&#xA;        and lower&#xA;        bounds using strict inequalities: constraint infeasible: 0.0  &amp;lt;&#xA;        Sij[1,40] and Sij[1,40] &amp;lt; 0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have also tried to replace the constraint coding (i.e. second line) by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        return  inequality(0.0, (model.pij[i,k] * model.Sij[i,k] for k in model.M), model.Yij[i,j] * model.Sij[i,j])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is even worse as the problem cannot be instantiated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;any suggestion on how to fix it?&lt;/p&gt;&#xA;" OwnerUserId="2599" LastActivityDate="2020-06-04T19:36:52.200" Title="how to implement a constraint with max/min function in pyomo" Tags="|pyomo|minlp|minimax|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4316" PostTypeId="2" ParentId="4315" CreationDate="2020-06-04T19:36:52.200" Score="1" Body="&lt;p&gt;Maybe you can replace your equality constraint with two inequality &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; constraints. Also, have a look at &lt;a href=&quot;https://github.com/Pyomo/pyomo/issues/821&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; link&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-06-04T19:36:52.200" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4317" PostTypeId="2" ParentId="4311" CreationDate="2020-06-04T19:57:59.010" Score="5" Body="&lt;p&gt;Complementing the other answers, I'd like to add you can design experiments trying to isolate the application's effect in order to measure it easier. One could start by using the new solution on a subset&lt;sup&gt;1&lt;/sup&gt; of instances. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if it's related to geographically isolated problems/models, choose some of them to apply change while the other ones keep working business as usual&lt;/li&gt;&#xA;&lt;li&gt;if it's a new personalized model (e.g. for pricing), choose the treatment and control group to see how different users react.&lt;/li&gt;&#xA;&lt;li&gt;and so on.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are several resources to learn about experiment design, causality analysis and A/B testing, among them:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/1108724264&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Trustworthy Online Controlled Experiments: A Practical Guide to A/B Testing&lt;/a&gt;, a recent book by Kohavi, Tang and Xu. The authors have a ton of experience running experiments at large companies.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you prefer online courses, there's &lt;a href=&quot;https://www.udacity.com/course/ab-testing--ud257&quot; rel=&quot;nofollow noreferrer&quot;&gt;a free one by Google at Udacity&lt;/a&gt; on the topic, and &lt;a href=&quot;https://www.coursera.org/learn/designexperiments&quot; rel=&quot;nofollow noreferrer&quot;&gt;another one offered by UC San Diego at Coursera&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've been reading the book and it shares several insights to take into account. Never attended the online courses so can't speak about their quality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I think the earlier you (and the relevant stakeholders) define the project's goal and metrics for measuring success, the better for experimentation, development, implementation and final impact. In my opinion, defining impact goals clearly&lt;sup&gt;2&lt;/sup&gt; and correctly designing experiments are both relevant steps to ensure success in this kind of application.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sup&gt;1&lt;/sup&gt; Ideally a representative subset, whenever real-world conditions allow it.&lt;/sup&gt;&lt;br&gt;&#xA;&lt;sup&gt;&lt;sup&gt;2&lt;/sup&gt; Including how the experiment will be measured, and how this goal relates to the project's &quot;big picture&quot; main objective as a whole.&lt;/sup&gt;  &lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="2477" LastEditDate="2020-06-04T20:59:33.093" LastActivityDate="2020-06-04T20:59:33.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4318" PostTypeId="1" CreationDate="2020-06-05T04:28:10.363" Score="4" ViewCount="81" Body="&lt;p&gt;I recently stumbled across the concept of Multidisciplinary Design Optimization (MDO), sometimes referred to as Multi-Disciplinary Optimization or Multidisciplinary Systems Design Optimization (MSDO), as someone I know was sharing about the applications of Linear Programming, Quadratic Programming etc...to Aerospace Engineering (I am a demand forecasting person, who recently started venturing into the area of supply chain optimization).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It struck me that the concept of MDO and MDO Architectures, and especially the concept of Collaborative Optimization Architectures would be widely applicable in just about any situation where there is a complex organization with multiple interconnected parts, e.g.: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A supply chain organization where high level financial decisions need to be optimized, as well as tactical planning and logistics considerations, and operational decisions inside shipping and distribution centers. &lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A online business where marketing targets need to be reconciled with user experience decisions, system capacity constraints, trends in social media and public sentiment, etc...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;And organization with a large geographical distribution where local decisions, regional decisions, and local decisions need to be reconciled. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;...basically any line of business where there are global optimization objectives that need to be reconciled with possibly conflicting local optimization objectives, and these optimization problems involve different teams with different skill sets and domain knowledge. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet a search on Google and on Google scholar reveals that MDO seems to be used almost exclusively in the mechanical engineering design context, and nowhere else. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am missing something? Am I misunderstanding the uses cases that MDO and Collaborative Optimization can solve? or is it just a weird historical accident that other industries haven't caught on to those ideas yet? &lt;/p&gt;&#xA;" OwnerUserId="1315" LastEditorUserId="1315" LastEditDate="2020-06-05T08:57:46.617" LastActivityDate="2020-06-05T08:57:46.617" Title="Is Multidisciplinary Design Optimization / Collaborative Optimization used anywhere outside of the Mechanical Engineering context?" Tags="|optimization|global-optimality|multi-objective-optimization|supply-chain|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4319" PostTypeId="2" ParentId="4318" CreationDate="2020-06-05T06:26:14.387" Score="2" Body="&lt;p&gt;As a student I am doing research in this field, I found &lt;a href=&quot;https://en.wikipedia.org/wiki/Multidisciplinary_design_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;'s explanation very useful. You are right, most of the applications of MDO are in the field of design for aerospace and mechanical engineering (they may design product, not systems). In these fields, the reconciliation of different teams in the design process completely follows well-known formulas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example in a design project of light-weight structure, you need to consider specific mechanical properties(yield stress, buckling, load, internal forces, bending, etc.) which are important for various teams, yet are related through principal laws of mechanics. All these relations can be considered as &lt;strong&gt;constraints&lt;/strong&gt; of a mathematical model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope it helps in explaining the difference (in my opinion and based on my understanding) between MDO and &lt;em&gt;system design optimization&lt;/em&gt;.      &lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-06-05T06:26:14.387" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4320" PostTypeId="1" AcceptedAnswerId="4321" CreationDate="2020-06-05T14:10:54.843" Score="2" ViewCount="445" Body="&lt;p&gt;I am working with a &lt;strong&gt;MILP&lt;/strong&gt; formulation of a routing problem using &lt;strong&gt;Concert CPLEX 12.10&lt;/strong&gt;. And I am implementing a &lt;strong&gt;greedy heuristic&lt;/strong&gt; that uses the variables fractional values to attempt to construct an integer feasible solution. By what I have read in forums, the CPLEX class &lt;code&gt;IloCplex::HeuristicCallbackI&lt;/code&gt; can be used for this purpose, the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.ide.help/refcppopl/html/classes/IloCplex_HeuristicCallbackI.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;class documentation webpage&lt;/a&gt; confirms this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In short, this callback allows you to attempt to construct an integer&#xA;  feasible solution at a node and pass it to the invoking instance of&#xA;  IloCplex to use as its new incumbent.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, this type of callback is executed even when the branch and bound (B&amp;amp;B) node already contains an integral solution, i.e, when the B&amp;amp;B finds an integer feasible solution. And in my experiments, I want to count the number of times that the greedy heuristic succeeds, i.e., the number of times that the heuristic could find an integer feasible solution by using the fractional values. So, I've tried to use the following functions to solve this problem:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.ide.help/refcppopl/html/classes/IloCplex_HeuristicCallbackI.html#method_getCplexStatus&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;IloCplex::HeuristicCallbackI::getCplexStatus()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.ide.help/refcppopl/html/classes/IloCplex_HeuristicCallbackI.html#method_getStatus&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;IloCplex::HeuristicCallbackI::getStatus()&lt;/code&gt;&lt;/a&gt;. Nevertheless, both functions return the &lt;code&gt;Optimal&lt;/code&gt; status at every fractional and integer B&amp;amp;C node. &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.ide.help/refcppopl/html/classes/IloCplex_MIPInfoCallbackI.html#method_hasIncumbent&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;IloCplex::MIPInfoCallbackI::hasIncumbent()&lt;/code&gt;&lt;/a&gt;, it returned &lt;code&gt;true&lt;/code&gt; at every fractional and integer B&amp;amp;B node soon after the first integer solution was found.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.ide.help/refcppopl/html/classes/IloCplex_ControlCallbackI.html#method_getFeasibility&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;IloCplex::ControlCallbackI::getFeasibility(my_var)&lt;/code&gt;&lt;/a&gt;, and it always returns &lt;code&gt;Infeasible&lt;/code&gt; (indeed it returns 1, which stands for &lt;a href=&quot;https://www.tu-chemnitz.de/mathematik/discrete/manuals/cplex/doc/advrefman/html/getcallbacknodeintfeas.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Infeasible&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also, I took a look at the &lt;code&gt;IloCplex::NodeCallbackI&lt;/code&gt; class &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.ide.help/refcppopl/html/classes/IloCplex_NodeCallbackI.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;webpage&lt;/a&gt; to check if there is any function to do that, however, I couldn't find anything for my case. I would like to know if there is any way to determine whether the current B&amp;amp;B node is integer feasible.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastActivityDate="2020-06-05T17:24:38.293" Title="How to determine whether the solution is integer feasible in a CPLEX heuristic callback?" Tags="|mixed-integer-programming|cplex|callback|concert|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4321" PostTypeId="2" ParentId="4320" CreationDate="2020-06-05T17:24:38.293" Score="4" Body="&lt;p&gt;Once you have gotten the values (in the node LP solution) for all variables, you can loop through the integer variables, computing the absolute difference between the value and the nearest integer. If any absolute difference exceeds the integrality tolerance (IloCplex::Param::MIP::Tolerances::Integrality), break out of the loop and treat the solution as not integer feasible. If you get through the loop with no violations, treat it as integer feasible.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-06-05T17:24:38.293" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4322" PostTypeId="1" CreationDate="2020-06-05T21:26:05.133" Score="5" ViewCount="1075" Body="&lt;p&gt;(&lt;em&gt;I apologize. I saw this &lt;a href=&quot;https://or.stackexchange.com/questions/4263/can-presolve-reductions-change-the-value-of-the-linear-programming-relaxation&quot;&gt;question&lt;/a&gt; but, I do not know these may be the same or not.&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to solve a MIP problem and have an issue about that. The problem's LP relaxation has the objective value about &lt;span class=&quot;math-container&quot;&gt;$63$&lt;/span&gt; but, when the problem is solved by MIP solvers like CPLEX, Gurobi and SCIP, the relax solution is reported &lt;span class=&quot;math-container&quot;&gt;$59$&lt;/span&gt;. &lt;strong&gt;(even though I disable pre-solving, cuts and heuristics).&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Root relaxation: objective 5.900000e+01&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In all of the cases, the value of the variables are the same and the problem is solved optimality. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if, is there any way to get the root relaxation value equal to &lt;span class=&quot;math-container&quot;&gt;$63$&lt;/span&gt; by using MIP solvers or this is an advanced technique in which the solvers use to speed up the solving time?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-06-05T21:26:05.133" Title="What is the difference between root relaxation and LP relaxation" Tags="|optimization|mixed-integer-programming|solver|lp-relaxation|" AnswerCount="0" CommentCount="19" ContentLicense="CC BY-SA 4.0" />
  <row Id="4323" PostTypeId="1" AcceptedAnswerId="4324" CreationDate="2020-06-05T21:46:13.767" Score="8" ViewCount="291" Body="&lt;p&gt;What do I mean by scaling?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say you developed a software for an operations research application for an industry client. Now you want to make a product out of this and sell it for other clients.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They all may share the same basic problem. However in my experience each new client has probably new additional constraints/different data landscapes, which require much overhead for each new customer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the contrast for example selling a solver (like Gurobi, &#xA;Cplex, ...) can scale pretty good, because new customers do not necessarily create large overhead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the question is can we build software for Operations Research applications that scale and if yes how and are there examples that achieved this?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2020-06-06T09:09:33.507" LastActivityDate="2020-06-06T09:09:33.507" Title="Can Operations Research applications scale?" Tags="|optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4324" PostTypeId="2" ParentId="4323" CreationDate="2020-06-05T22:22:52.490" Score="11" Body="&lt;p&gt;Yes we can, depending on the context and objective, and several companies are successful at doing it with hundreds of customers across the globe. An important disclaimer here is &lt;strong&gt;how specific problems you want your solution be able to solve.&lt;/strong&gt; There's a tradeoff between developing general OR software vs. doing consulting or creating custom-made models that might only apply for a specific context&lt;sup&gt;1&lt;/sup&gt; and most likely need work adapting for another case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some examples of general OR software with some problem-specific capabilities (for common constraints and models needed by organizations, like scheduling or routing) are: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://developers.google.com/optimization/introduction/overview&quot; rel=&quot;noreferrer&quot;&gt;Google OR-Tools&lt;/a&gt; has several specific modelling capabilities implemented, such as routing, scheduling, network flows and bin packing.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cpo.help/CP_Optimizer/User_manual/topics/constraints.html&quot; rel=&quot;noreferrer&quot;&gt;IBM CPLEX Optimization Studio&lt;/a&gt; provides the ability to model specific constraints useful for applications, such as precedence constraints or sequence constraints.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;While there are lots of examples for problem-specific, software, especially vehicle routing:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://llamasoft.com/&quot; rel=&quot;noreferrer&quot;&gt;Llamasoft&lt;/a&gt; sells a couple of solutions for the supply chain (simulation, capacity planning, demand modeling among others).&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.optibus.com/&quot; rel=&quot;noreferrer&quot;&gt;Optibus&lt;/a&gt; provides planning and scheduling capabilities for mass transit.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There will always be a sort of 80-20 situation here, where if you want to model all the context of a real-world process, you might need to extend these APIs - which may be impossible for proprietary software - or create your code from scratch (instead of using a prepackaged software). For example, you might want to route in a periodic sense, or coupling several days instead of daily, or according to additional rules, and that's a feature not all commercial routing software will have. There's certainly relevance on how much the different companies invest in R&amp;amp;D teams, customer support and implementation consulting. Or if you develop a staff scheduling solution for a specific industry, it's almost certain that you'll need to adapt, or activate/deactivate a set of constraints or parameters, just because of legislation or contract dynamics. That's certainly an interesting conversation about software design and modularity to keep in mind.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; Like many case studies on Operations Research practice published in &lt;a href=&quot;https://www.informs.org/Publications/INFORMS-Journals/INFORMS-Journal-on-Applied-Analytics&quot; rel=&quot;noreferrer&quot;&gt;INFORMS Journal on Applied Analytics&lt;/a&gt;, formerly known as &lt;em&gt;Interfaces&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="2477" LastEditDate="2020-06-06T00:01:59.707" LastActivityDate="2020-06-06T00:01:59.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4325" PostTypeId="1" CreationDate="2020-06-06T08:38:37.213" Score="28" ViewCount="2966" Body="&lt;p&gt;I am doing an internship in a company. The aim is to solve scheduling problems in the industry (a variant of the resource-constrained project scheduling problem). By the end of the internship, they will offer me a job opportunity. I will need to treat other constraints and different objective functions. I am a little bit hesitant to accept.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the company has no experience in operations research, maths, or even algorithms. Basically, it's a web development company. The challenge is that managers are totally unaware of the complexity of the work I am doing. They think that adding a constraint is as easy as adding a button in an interface. For example, adding the multi-skill or multi-site details is not so straightforward. Sometimes, we need to restart from scratch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am concerned that instead of understanding that the problems are of a complex nature (especially with large scale data), I will be judged unfairly. They are tending to measure the efficiency of delivering work by comparing me to web developers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I deal with similar situations? How can I convince people with no operations research/math/algorithm background that things are not as simple as they thought?&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;A user stated that this site is not for career advice. Unfortunately, users of other career advice sites will not understand the challenges I am facing. I hope the post will be maintained.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I am &lt;strong&gt;not&lt;/strong&gt; saying that web development is a &quot;stupid&quot; thing or anything like that. I am saying that it seems like adding things in web development is way simpler.   &lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2020-06-09T15:40:42.887" LastActivityDate="2020-06-17T12:42:49.743" Title="How can I deal with non-operations research managers?" Tags="|job-market|or-careers|" AnswerCount="6" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="4326" PostTypeId="2" ParentId="4305" CreationDate="2020-06-06T10:29:57.147" Score="3" Body="&lt;p&gt;A couple of years ago we had a student who wanted to call CPLEX from R and I think after spending a lot of time with a colleague they couldn't get it to work. The situation may have been improved, but back then Gurobi was a lot easier to call from R, and these kinds of struggles may be one reason why R is not very popular in papers that focus on MIPs. There are also not many tools available in R that can help you use commercial solvers in a convenient way. In one of our postgraduate courses we actually developed a small R-script that makes it a lot easier to manage variables and constraints on top of the standard Gurobi API. Python has packages that make those kinds of things easier, and with CPLEX you can use Concert technology in most supported languages that makes those kinds of things a lot easier as well. The lack of such technologies may be a second reason why R is not so popular for MIP papers, although this is a situation that may get better and better as time passes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, as you mentioned, for iterative computations the standard GNU R interpreter is really slow. There are some efforts to create faster alternative implementations of the R language, mostly based on Java technology, such as the &lt;a href=&quot;https://github.com/oracle/fastr&quot; rel=&quot;nofollow noreferrer&quot;&gt;experimental FastR interpreter by Oracle&lt;/a&gt;. The language itself was designed for statistics and I think ease of use for statistical usage is a much more important goal of the language than efficiency of arbitrary algorithms written in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the speed of your math heuristic is a concern, in particular if it must make as many iterations as possible, R's speed is something to consider. Many core parts and popular packages of R are contain parts writte in C or Fortran to keep stuff under the hood efficient. If your heuristic is not really about iterations, i.e. you do a single preprocessing step, solve a MIP once, then do a postprocessing step, it is only important whether R is &quot;fast enough&quot;. If the pre and postprocessing take 10 seconds in R, no one will complain that you can do it in 0.1 seconds in some other language (unless you want to run this heuristic millions of times).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it really depends on the story you want to tell with your paper: if you solve a problem from practice and intend to investigate how you can improve some process with optimization techniques, it is usually enough to show you can solve it fast enough to be useful and focus on the objective values that come out. If you want to argue that your new method is faster than the state of the art for a problem that has seen a lot of research already, it becomes a greater concern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, be aware that no one forces you write all code of a project in a single language. Personally I like to do most computational expensive stuff in Java, but I often use Python scripts to do some data transformations or stuff that other people probably like to do in Excel. For some types of visualization and statistical analysis I sometimes use R as well, if that is more convenient than Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the main reason you like R is the built-in dataframe but R's speed is an issue, you can look at dataframe packages for other languages. Python has the extremely popular &lt;a href=&quot;https://pandas.pydata.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;pandas package&lt;/a&gt; and for Java there are also packages that aim to provide a more easy to use data frame, for example &lt;a href=&quot;https://github.com/jtablesaw/tablesaw&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tablesaw&lt;/a&gt; (but I'm not sure how popular that one actually is).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While data frames are nice to process tabular data, I really dislike dealing with more complex hierarchical object data in R. Navigating an XML-tree or accessing particular document elements of an HTML page in R always feels cumbersome to me compared to other languages. The ease of data processing in R thus also depends on the kind of data processing you intend to do.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastEditorUserId="123" LastEditDate="2020-06-06T10:41:19.403" LastActivityDate="2020-06-06T10:41:19.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4328" PostTypeId="2" ParentId="4281" CreationDate="2020-06-06T13:18:07.237" Score="4" Body="&lt;p&gt;If you use public transport to get to and from work you might have several options on from where you board the transit system, where you get off, and what line you take, with a variety of uncertainties regarding the transit system's punctuality and the distance from your home or workplace to the nearest transit stop. There are plenty of optimization problems to think of in this situation - you may want to not walk very far to or from the transit stop, or you want to minimize the risk of missing a connection...&lt;/p&gt;&#xA;" OwnerUserId="3700" LastActivityDate="2020-06-06T13:18:07.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4329" PostTypeId="2" ParentId="4325" CreationDate="2020-06-06T13:35:40.907" Score="12" Body="&lt;p&gt;From what I could understand, here is my recommendation for you. Suppose I was on your place starting intern, then I would be setting up my few initial sessions with the manager or team lead to clear out the deliverables. For me, this includes: scoping out the problem, setting solution domain, listing out possible challenges in solving and finally the applicability of deployed solution all of this with the &lt;strong&gt;timeline&lt;/strong&gt; that aligns between both of you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This kind of planning can help you tackle any later unexpected challenges that you may not wish to encounter.    &lt;/p&gt;&#xA;" OwnerUserId="3700" LastEditorUserId="3700" LastEditDate="2020-06-07T09:44:30.320" LastActivityDate="2020-06-07T09:44:30.320" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4331" PostTypeId="2" ParentId="4325" CreationDate="2020-06-06T17:13:06.373" Score="31" Body="&lt;p&gt;First, I understand the question, and I personally think it is appropriate for this forum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, if they do offer you a job, there should be some discussion of compensation, duties and so on. That would be the time to explain to them that seemingly small, benign changes to an optimization model can have drastic effects on run time, possibly warranting a fundamentally different approach. If possible, you might come armed with one or two published examples, or testimonials from optimization pros, preferably consultants or software designers (&quot;real people&quot;) as opposed to academics. If the conversation leaves you thinking that they still have unrealistic expectations about changes, I would suggest sitting on their offer for as long as possible while looking for a better job. Ultimately, though, a job is better than no job, and if you accept the job and they do heap unreasonable expectations on you, you can always opt to leave voluntarily and take a different job.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-06-06T17:13:06.373" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4332" PostTypeId="1" AcceptedAnswerId="4354" CreationDate="2020-06-06T20:56:25.843" Score="3" ViewCount="2429" Body="&lt;p&gt;Let's say nurses normally do 1 shift&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for d in all_days:&#xA;    for s in all_shifts:&#xA;        model.Add(sum(shifts[(n, d, s)] for n in all_nurses) == 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I want to make nurses either do 1 shift or 3 shifts (but no 2 shifts). How do I combine between&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        model.Add(sum(shifts[(n, d, s)] for n in all_nurses) == 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        model.Add(sum(shifts[(n, d, s)] for n in all_nurses) == 3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2704" LastEditorUserId="500" LastEditDate="2020-06-06T21:14:47.233" LastActivityDate="2020-06-08T23:27:42.537" Title="How to add logical OR constraint in OR-Tools?" Tags="|integer-programming|scheduling|or-tools|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4333" PostTypeId="2" ParentId="4332" CreationDate="2020-06-06T21:12:21.820" Score="8" Body="&lt;p&gt;Introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{d,s}$&lt;/span&gt; and change the right hand side to &lt;span class=&quot;math-container&quot;&gt;$1+2x_{d,s}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-06-06T21:12:21.820" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4335" PostTypeId="1" CreationDate="2020-06-07T06:57:40.867" Score="2" ViewCount="400" Body="&lt;p&gt;I have previously asked this problem here-&lt;a href=&quot;https://or.stackexchange.com/questions/4145/lead-time-longer-than-cycle-time&quot;&gt;Lead time longer than cycle time&lt;/a&gt;, but I keep getting more confused the more I think about it. Using the Q,R inventory model, suppose my mean monthly demand &lt;span class=&quot;math-container&quot;&gt;$\mu = 4000, \sigma_D = 1500$&lt;/span&gt;, Order quantity &lt;span class=&quot;math-container&quot;&gt;$Q = 6000$&lt;/span&gt; and lead time &lt;span class=&quot;math-container&quot;&gt;$L = 3$&lt;/span&gt;(months). Choosing &lt;span class=&quot;math-container&quot;&gt;$\alpha = 2.33$&lt;/span&gt;, I get &lt;span class=&quot;math-container&quot;&gt;$SS \approx 6000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ROP \approx 18000$&lt;/span&gt;. ROP is interpreted as the inventory position here. The values seem reasonable enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now suppose I take &lt;span class=&quot;math-container&quot;&gt;$L = 10$&lt;/span&gt;, the safety stock value shoots up to &lt;span class=&quot;math-container&quot;&gt;$SS = 11,000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ROP = 51,000$&lt;/span&gt; This definitely seems absurdly high to me. I don't get why we use the lead time as it is in the formula because at a steady-state, and assuming the demands are normally distributed, we will be receiving an order every &lt;span class=&quot;math-container&quot;&gt;$Q/\mu = 6000/4000 = 1.5$&lt;/span&gt; months on an average. Why, then, does the formula say that we need to use the lead time L = 10, when we know that the inventory would be replenished much before that? In my opinion, we only need to cover-up for fluctuations in demand in that 1.5 month period. I couldn't find any text that clearly explains this dichotomy between Inventory Position and Inventory Level and any help is appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;a href=&quot;https://i.stack.imgur.com/DV5oE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DV5oE.png&quot; alt=&quot;Inventory Position and Levels&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3458" LastEditorUserId="3458" LastEditDate="2020-06-08T05:58:53.587" LastActivityDate="2020-06-08T05:58:53.587" Title="Reorder point and safety stock for very long lead times" Tags="|inventory|rq-inventory-model|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4336" PostTypeId="2" ParentId="4325" CreationDate="2020-06-07T15:31:59.677" Score="21" Body="&lt;p&gt;I'll answer this from an employer's perspective. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Technical ability is a necessary but not sufficient condition - the skill I value the most in my employees is their ability to manage expectations. I am also very mindful of the fact that most people can't do this well at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;People higher up the chain have better oversight of what needs to be done, why, and &lt;strong&gt;by when&lt;/strong&gt;. It is perfectly ok for something to take a long time, it is definitely not ok for management to be blindsided by this. If a task is going to take longer than expected, management needs to know asap, because they have oversight of the entire project. Some things they might choose to do if they do know:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Hire more people&lt;/li&gt;&#xA;&lt;li&gt;Reassign more people to work on the project&lt;/li&gt;&#xA;&lt;li&gt;Hire an experienced contractor for a short time to help out&lt;/li&gt;&#xA;&lt;li&gt;Cut features to meet the deadline&lt;/li&gt;&#xA;&lt;li&gt;Postpone the project until more critical things are completed&lt;/li&gt;&#xA;&lt;li&gt;Cancel the project altogether&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These are all management-level decisions that can only be made if management is aware of the reality of a situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The macro-level problem here is that employees typically think that their responsibility is to come up with a &quot;how&quot;, but this is not the case. Management &amp;amp; employees are supposed to work together to come up with a &quot;how&quot; that fits the &quot;what&quot; and the &quot;when&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A sign of a good manager is that they understand how hard this is, and they are upfront with you about how this is going to work, what exactly is expected of you, and how they are going to evaluate your progress. You will agree on time estimates, in the beginning you will get it wrong, you will have honest conversations about why, and a good manager will help you understand how to manage your time and expectations better. A bad manager will tell you &quot;make sure this never happens again or else&quot;, without telling you what to do about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, when I need something done, I will sit down with the person who will be responsible for it, we will discuss to define what work will be done exactly (or what work needs to be done to figure out what to do in the first place), and at the end I will ask them how long they think it's going to take. I will also give them an idea of the greater picture by letting them know how their task fits into the greater sequence of tasks that other people are doing, and how other crucial things done by other people depend on the timely completion of their work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a rule of thumb, for junior people I will assume it will take at least 3-5 times their estimate (sometimes 10x), for senior people about 2x, and for team leads it's usually done about as quickly as they predict, because they add the multiplier themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should also point out that this is the part of the job most people struggle with the most, as being able to manage time and expectations well is not something universities prepare us for - it typically comes with experience. This is a very high-level skill, even experienced people can be shockingly bad at this. In industry terms, this makes the difference between a team lead and a senior person.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, from a practical point of view, what does this tell us about your situation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Managing expectations is 100% your responsibility, especially if you are the only person at the company with a particular skillset. No-one has the knowledge to set proper timelines except for you.&lt;/li&gt;&#xA;&lt;li&gt;You are most definitely &lt;strong&gt;not&lt;/strong&gt; expected to be able to do this well straight out of uni. You are however expected to be proactive in improving your ability to do this well. Just be mindful that this is a life-long process, it doesn't happen overnight, and that's ok.&lt;/li&gt;&#xA;&lt;li&gt;It 100% ok to tell your manager that you don't believe you can do what they ask in the time they want you to do it. A good employee does this routinely, and a great employee will suggest how to adjust the project's objectives to fit the management's timeline.&lt;/li&gt;&#xA;&lt;li&gt;You will only be judged unfairly in two cases: (i) if you don't manage expectations well, which is up to you, and (ii) if you have a bad manager, in which case you should probably find a different job.&lt;/li&gt;&#xA;&lt;li&gt;As a junior professional, always multiply the time you think you need by 5, until you start to feel confident about your ability to estimate time well.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Finally, to answer the OR-specific part of your question, unfortunately it's unlikely that you'll be able to communicate the complexity to a non-optimisation person. You should of course try to communicate that this is complicated stuff, but at the end of the day the people employing you should trust you, especially if you are the only person with the know-how, which by definition makes you the resident expert. If the expert says X needs two months, and they do deliver X in two months, everyone is happy. If management says &quot;we don't have two months for X, we have 1 week&quot;, then it is the expert's job to stick to their guns and suggest alternatives. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, despite your efforts, management is still being unreasonable, it's time to find a new job.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-06-08T14:55:59.947" LastActivityDate="2020-06-08T14:55:59.947" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4337" PostTypeId="2" ParentId="4335" CreationDate="2020-06-07T19:45:43.837" Score="1" Body="&lt;p&gt;You seem to be conflating two ordering systems. You say you will be receiving an order every 1.5 months on average. The only way that could happen with a lead time of 10 months would be if you had more than one order outstanding at a time. This ties to your use of &lt;span class=&quot;math-container&quot;&gt;$Q=6,000$&lt;/span&gt; in the second paragraph. That's the order quantity when &lt;span class=&quot;math-container&quot;&gt;$L=3$&lt;/span&gt;, not when &lt;span class=&quot;math-container&quot;&gt;$L=10$&lt;/span&gt;. So if you are going to stick to an ROP/ROQ system (order when you hit the ROP, then not again until after that order arrives), you'll order &lt;span class=&quot;math-container&quot;&gt;$Q=40,000$&lt;/span&gt; units, which is 10 months of demand. If, instead, you decide to stick with &lt;span class=&quot;math-container&quot;&gt;$Q=6,000$&lt;/span&gt;, you're moving from an ROP system to what looks more like an EOQ system ... or at least you'll be ordering at more than one reorder point.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-06-07T19:45:43.837" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4338" PostTypeId="1" AcceptedAnswerId="4339" CreationDate="2020-06-07T20:55:41.090" Score="2" ViewCount="796" Body="&lt;p&gt;I'm currently working on a case for a food delivery service and wondered whether my notion of &quot;driver utilization&quot; makes any sense. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My data set contains an hourly overview of the &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;number of active delivery drivers, &lt;/li&gt;&#xA;&lt;li&gt;their online hours, &lt;/li&gt;&#xA;&lt;li&gt;number of delivery drivers with an order, &lt;/li&gt;&#xA;&lt;li&gt;number of delivery drivers waiting for delivery, &lt;/li&gt;&#xA;&lt;li&gt;number of drivers delivering food, &lt;/li&gt;&#xA;&lt;li&gt;hours per active delivery driver, &lt;/li&gt;&#xA;&lt;li&gt;delivery rides per online hour, &lt;/li&gt;&#xA;&lt;li&gt;total completed rides that hour, &lt;/li&gt;&#xA;&lt;li&gt;users that DON'T see delivery availability, and &lt;/li&gt;&#xA;&lt;li&gt;user that DO see delivery availability.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PLEASE NOTE:&lt;/strong&gt; 9. and 10. can overlap (double count).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With those types of information, how would you describe &quot;under/over utilization&quot;? &lt;/p&gt;&#xA;" OwnerUserId="3707" LastActivityDate="2020-06-08T09:11:52.807" Title="Defining and comparing utilization rates for delivery service" Tags="|optimization|multi-objective-optimization|implementation|minimax|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4339" PostTypeId="2" ParentId="4338" CreationDate="2020-06-07T21:53:48.707" Score="5" Body="&lt;p&gt;One possibility is to look at idle time (time a driver spends waiting for the next order). If the drivers are on your payroll (as opposed to working on commission, i.e., doing &quot;gig&quot; work), idle time has a direct cost. If the drivers are gig workers, a relatively even distribution of idle time might be perceived as &quot;fairer&quot; and might contribute to driver retention. (A better measure in the gig case might be driver revenue per hour, adjusted for mileage costs, but your data does not suggest any measure of revenue, or of mileage for that matter.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we use idle time, then &quot;under-utilization&quot; (&quot;over-utilization&quot;) would mean more (less) idle time per shift than some standard. (The standard would likely be time-dependent, since people are more likely to order food at some times than at others.) You could make the standard either absolute (more than 20 minutes idle per hour is under-utilized, less than 5 minutes per hour is over-utilized) or relative (if you idle time is 1.5 standard deviations below the average for a certain time span, you're over-utilized, etc.), where the standard deviation and mean would be sample-based. Note that the sample-based approach does not detect over- or under-staffing as well as the absolute standard approach (assuming you pick your absolute standards wisely).&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="123" LastEditDate="2020-06-08T09:11:52.807" LastActivityDate="2020-06-08T09:11:52.807" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4340" PostTypeId="2" ParentId="2953" CreationDate="2020-06-08T06:14:50.413" Score="5" Body="&lt;p&gt;&lt;strong&gt;Lack of Effective Communication and Challenge Discussions&lt;/strong&gt;. When you are involved as a technical person leading model development in an optimization project, sometimes lack of communication between you and your clients can affect your model results and ultimately the applicability in real life. You miss one simple constraint and your results become impractical. This is especially true if you are new to the business and you have little experience of how the processes works on your client side. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In such cases, the best way is to ask as many questions as possible, even if they might feel naive to other people. Do not be afraid to use simple terminologies because its often the case that plant engineers or process engineers have little to no experience of operations research. Right effort at right time can save you from a lot of pain later. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be open and be 100% prepared for the actual outcomes to deviate from what you see in your computer and not to succeed in your first few iterations while you would ideally expect to. Solving optimization problems on computer is one thing and bringing optimization models to life is another.  &lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="113" LastEditDate="2020-06-10T05:15:50.150" LastActivityDate="2020-06-10T05:15:50.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4341" PostTypeId="1" AcceptedAnswerId="4342" CreationDate="2020-06-08T09:17:11.307" Score="5" ViewCount="545" Body="&lt;p&gt;How to convert this if-then constraint to MIP constraint?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{if } a \geq 0 \text{ then } b=K_1 \text{ else(a &amp;lt;0 ) } \ b =K_2$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3500" LastActivityDate="2020-06-08T10:20:16.147" Title="How to convert this if-then constraint to MIP constraint?" Tags="|mixed-integer-programming|logical-constraints|indicator-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4342" PostTypeId="2" ParentId="4341" CreationDate="2020-06-08T09:46:16.993" Score="7" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a \geq M_1x$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a \leq M_2 - (M_2+eps)x$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b = K_1 + (K_2-K_1)x$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$M_1 &amp;lt; 0$&lt;/span&gt; bigM for the lower bound on &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$M_2 &amp;gt; 0$&lt;/span&gt; bigM for the upper bound on &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; binary variable equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$a &amp;lt; 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise (i.e. &lt;span class=&quot;math-container&quot;&gt;$a \geq 0$&lt;/span&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$eps$&lt;/span&gt; tolerance&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="2599" LastEditDate="2020-06-08T10:20:16.147" LastActivityDate="2020-06-08T10:20:16.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4343" PostTypeId="2" ParentId="4341" CreationDate="2020-06-08T10:04:48.793" Score="4" Body="&lt;p&gt;I would like to remind that CPLEX can handle &quot;if then&quot; directly through logical constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OPL for example&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int nbKids=300;&#xA;float costBus40=500;&#xA;float costBus30=400;&#xA;&#xA;dvar int+ nbBus40;&#xA;dvar int+ nbBus30;&#xA;minimize&#xA; costBus40*nbBus40  +nbBus30*costBus30;&#xA;&#xA;subject to&#xA;{&#xA; 40*nbBus40+nbBus30*30&amp;gt;=nbKids;&#xA;&#xA; // with if nb buses 40 more than 3  then nb buses30 more than 7&#xA;&#xA; (nbBus40&amp;gt;=3)=&amp;gt;(nbBus30&amp;gt;=7);&#xA; //(nbBus40&amp;gt;=3)&amp;lt;=(nbBus30&amp;gt;=7); //equivalent&#xA;}&#xA;&#xA;/*&#xA;which gives&#xA;&#xA;nbBus40 = 0;&#xA;nbBus30 = 10;&#xA;&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-06-08T10:04:48.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4345" PostTypeId="1" CreationDate="2020-06-08T13:06:04.477" Score="3" ViewCount="93" Body="&lt;p&gt;I am wondering if there is any attempts of combining OR and ML in the following way. Priority-based rules are widely used in Resource Constrained Project Scheduling Problems. &#xA;Is there a way to train a ML model to choose which priority rule to use? This may be done in advance depending on the structure of the input data or even while scheduling (i.e first using a priority rule then make a partial schedule using it then changing the priority rule etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's the case, could you provide a link to papers and, if possible, a brief description of the idea behind (I am not familiar with ML at all) &lt;/p&gt;&#xA;" OwnerUserId="3711" LastEditorUserId="123" LastEditDate="2020-06-08T13:23:54.107" LastActivityDate="2020-06-08T13:23:54.107" Title="Combining Machine learning and Operations research on a scheduling problem" Tags="|reference-request|scheduling|applications|machine-learning|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4347" PostTypeId="1" AcceptedAnswerId="4348" CreationDate="2020-06-08T14:28:41.657" Score="9" ViewCount="2237" Body="&lt;p&gt;When talking to people who are not familiar with what OR is and what it is about, and you want to convince them that it might be useful for them/their industry, what do you tell them in order to convince them to do a project with you? Or if you have slides what do you show on these slides?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2020-06-08T17:32:10.777" Title="How to convince people that OR can help them?" Tags="|optimization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4348" PostTypeId="2" ParentId="4347" CreationDate="2020-06-08T15:18:15.080" Score="13" Body="&lt;p&gt;It depends on the situation, but I assume what you have in mind is business.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adopting a new technology stack is a business decision, even if you are talking to a technical person (the &quot;User&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can tell you from experience that technical discussions will contribute absolutely nothing to your cause. What works is to tell the User how using OR will benefit their business.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Examples of what not to tell people&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The new presolver is 3% more efficient&lt;/li&gt;&#xA;&lt;li&gt;We use an innovative branching strategy which explores 30% fewer nodes on average&lt;/li&gt;&#xA;&lt;li&gt;Using OR we can create schedules that are 5% better than your current schedules&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These statements mean absolutely nothing to anyone who does not know OR. Even for OR people, these statements are still meaningless w.r.t. what this means &lt;strong&gt;for them&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Examples of what to tell people&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We estimate that this new framework can create better schedules, which can reduce your gross annual cost by up to 35%.&lt;/li&gt;&#xA;&lt;li&gt;This technology can be used for superior real-time control, which can improve process efficiency by 12%. This translates to $2.5m/year.&lt;/li&gt;&#xA;&lt;li&gt;Adopting OR can automate this part of your workflow. If widely adopted, that's 3.5m work-hours/year.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Even though the reasons to make these statements can be the counterexamples I wrote just above, this phrasing makes all the difference. It is now something a business person will be interested in, and it is also something the User can easily take to their boss and ask for approval subject to technical review.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-06-08T15:27:01.060" LastActivityDate="2020-06-08T15:27:01.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4350" PostTypeId="2" ParentId="4347" CreationDate="2020-06-08T17:32:10.777" Score="7" Body="&lt;ul&gt;&#xA;&lt;li&gt;I suspect it helps if you come equipped with a few success stories from their industry.&lt;/li&gt;&#xA;&lt;li&gt;It's nice to be able to say that &quot;XYZ Megacorp saved twice the GDP of Rhode Island using a truck scheduling model&quot;, but you'll also want to make it clear that they don't need to be the size of XYZ Megacorp in order to benefit.&lt;/li&gt;&#xA;&lt;li&gt;When thinking of OR applications, many of us gravitate toward some of the more mathematical models (optimization, simulation, maybe machine learning). There are also techniques having to do with group decision making, decision making with multiple criteria, etc. that might be of interest. So an example of a group decision (perhaps whether to pursue a new product, whether to open a new facility, whether to acquire a competitor) where competing fiefdoms in the company have divergent opinions and competing interests, along with an OR/MS technique for facilitating the decision (analytic hierarchy process comes to mind as one possibility) might get them interested.&lt;/li&gt;&#xA;&lt;li&gt;Bottom line: You can lead a horse to water, but you can't make him drink.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-06-08T17:32:10.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4351" PostTypeId="1" AcceptedAnswerId="4361" CreationDate="2020-06-08T17:53:01.377" Score="1" ViewCount="1040" Body="&lt;p&gt;In the Hungarian Algorithm, the assignment for a bipartite graph considers the restriction of assigning a single job to a single person for example. Can this restriction be relaxed? I would like to Minimize the overall cost, while allowing multiple jobs to be assigned to the same person.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have a bipartite graph &lt;span class=&quot;math-container&quot;&gt;$W = W_1, W_2, \ldots W_n$&lt;/span&gt; representing workers, and &lt;span class=&quot;math-container&quot;&gt;$J = J_1, J_2, \ldots, J_m$&lt;/span&gt;. We are given an &lt;span class=&quot;math-container&quot;&gt;$m \times n$&lt;/span&gt; matrix which represents &lt;span class=&quot;math-container&quot;&gt;$C_{i,j}$&lt;/span&gt;, the cost of assigning job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. Multiple jobs can be assigned to a single worker designated by the cost according to the cost matrix. What would be the minimum cost assignment for such a scenario?&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="584" LastEditDate="2020-06-09T14:46:22.513" LastActivityDate="2020-06-09T19:09:09.440" Title="How to allow multiple assignments for jobs in Hungarian Algorithm?" Tags="|optimization|assignment-problem|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4352" PostTypeId="1" CreationDate="2020-06-08T20:26:58.703" Score="1" ViewCount="65" Body="&lt;p&gt;I have a constraint as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_i {r_i} \geq \max \{g_j, B_j\} $&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where, &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$g_j$&lt;/span&gt; are variables and &lt;span class=&quot;math-container&quot;&gt;$B_j$&lt;/span&gt; is a parameter. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;How do I linearize the constraint (I suppose using big-M method)? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Since, I have a lot of elements under the set &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, I would like to have the option of big-M. However, another option I was thinking is to use the following two constraints:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_i {r_i} \geq g_j$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_i {r_i} \geq B_j$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, the bigger of the &lt;span class=&quot;math-container&quot;&gt;$g_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_j$&lt;/span&gt; will be selected for the minimization problem and the other will be redundant. For example, for a minimization problem if we have &lt;span class=&quot;math-container&quot;&gt;$x \geq 2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x \geq 5$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x \geq 2$&lt;/span&gt; will be a redundant constraint.&lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="500" LastEditDate="2020-06-08T23:19:58.180" LastActivityDate="2020-06-08T23:19:58.180" Title="Linearize max function in a constraint" Tags="|mixed-integer-programming|linear-programming|linearization|big-m|" AnswerCount="0" CommentCount="1" ClosedDate="2020-06-08T21:04:23.243" ContentLicense="CC BY-SA 4.0" />
  <row Id="4354" PostTypeId="2" ParentId="4332" CreationDate="2020-06-08T21:53:04.050" Score="3" Body="&lt;p&gt;You can also do:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;model.AddLinearExpressionInDomain(sum(variables), cp_model.Domain.FromValues([1, 3]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;for d in all_days:&#xA;    for s in all_shifts:&#xA;        b = model.NewBoolVar(&quot;&quot;)&#xA;        model.Add(sum(shifts[(n, d, s)] for n in all_nurses) == 1).OnlyEnforceIf(b)&#xA;        model.Add(sum(shifts[(n, d, s)] for n in all_nurses) == 3).OnlyEnforceIf(b.Not())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Let's say nurses normally do 1 shift&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Wouldn't that be:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;for n in all_nurses:&#xA;    model.Add(sum(shifts[(n, d, s)] for d in all_days for s in all_shifts) == 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2020-06-08T23:27:42.537" LastActivityDate="2020-06-08T23:27:42.537" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4355" PostTypeId="2" ParentId="4325" CreationDate="2020-06-09T03:37:07.833" Score="7" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I want to point out that since the company is a web development one, there are probably some computer engineering or computer science graduates in the workforce (perhaps, even in the top-level management). A common area between computer engineering/science with operations research is algorithms and the theory of complexity. Hence, while many computer engineering/science have no background in OR, they understand many OR concepts and tools such as branch and bound, dynamic programming, and metaheuristics, to name a few. Since you are working on scheduling problems, you have a good chance that there is a body of knowledge on the theoretical performance of algorithms and the complexity of the problem under investigation. I suggest you discuss these common grounds over coffee breaks and technical meetings to familiarize people with what you do.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Please note that operations research has a very versatile set of tools. If you want fast solutions, you have both metaheuristics and constraint programming at your disposal. Both methodologies are very common for solving scheduling problems.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I believe web development is the gateway to many projects in other fields. Many companies think that they have a process or database problem and they want to solve it (automate the process or have access to data) with a web-based solution. However, often there are other problems, which might require other disciplines such as operations research, analytics, industrial engineering, business analysis, etc. So unless the company is just working on web design for sites, I would not be worried about the relevance or importance of your job there.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="119" LastEditorUserId="119" LastEditDate="2020-06-09T11:14:20.983" LastActivityDate="2020-06-09T11:14:20.983" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4356" PostTypeId="2" ParentId="4325" CreationDate="2020-06-09T04:34:10.150" Score="2" Body="&lt;p&gt;Being just out of college and the only one in an organization with knowledge in a field is scary.  Your bosses will not understand what is hard and what is easy about your job.  The other posts about managing expectations are excellent in this regard.  You will not get guidance from somebody experienced in the area, which is important to learn what is really important on the job as opposed to what is taught in school.  You have also said this is not a core competency for the company.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is an opportunity to fail spectacularly or to grow spectacularly.  You are essentially working in a startup within the company.  If nothing blows up in your face in the next few years you will have a lot wider experience than others in your field at your age.  If the area becomes more important to the company, you might have a large staff reporting to you.  If something does blow up in your face you may be fired, but you will have attractive things on your resume.  Be on the lookout for opportunities for training, both within your field and in management, as you will be doing that and it isn't taught in technical school.&lt;/p&gt;&#xA;" OwnerUserId="3717" LastActivityDate="2020-06-09T04:34:10.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4357" PostTypeId="1" AcceptedAnswerId="4360" CreationDate="2020-06-09T05:55:42.487" Score="6" ViewCount="510" Body="&lt;p&gt;I have the following optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mbox{maximize } j^{*} \mbox{ subject to:} \sum_{j^{*}\leq j\leq J} \min({\bf A}_j,{\bf B}_j) \geq \lambda, \lambda \in \mathbb{R} \mbox{ and } {\bf A}_j,{\bf B}_j &amp;gt; 0 \forall j&#xA;$$&lt;/span&gt;&#xA;where the values of &lt;span class=&quot;math-container&quot;&gt;$\bf A \in \mathbb{R}^n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bf B \in \mathbb{R}^n$&lt;/span&gt; (constants) are dependent on their index &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in an arbitrary relationship (i.e. their values are arbitrarily predefined). &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; here is a constant and independent of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$j^*$&lt;/span&gt;. I am looking for an approach to convert this into a series of linear constraints if it is possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have came across &lt;a href=&quot;https://or.stackexchange.com/questions/1160/how-to-linearize-min-function-as-a-constraint&quot;&gt;this question&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/questions/711/how-to-formulate-linearize-a-maximum-function-in-a-constraint?noredirect=1&amp;amp;lq=1&quot;&gt;this question&lt;/a&gt; which deals with the conversion of constraints containing minimum or maximum functions. However I am not sure if a similar method is possible when the summation function is wrapped over the minimum function, or whether the lack of knowledge on the nature of the entries of &lt;span class=&quot;math-container&quot;&gt;$\bf A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bf B$&lt;/span&gt; mean that any attempt would not be possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(One point that might be worth nothing is that the constraint might be relaxed because it can be inferred that:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min\left\{\sum_{j^{*}\leq j\leq J} {\bf A}_j, \sum_{j^{*}\leq j\leq J} {\bf B}_j\right\}&#xA;\geq \sum_{j^{*}\leq j\leq J} \min({\bf A}_j,{\bf B}_j)&#xA;$$&lt;/span&gt;&#xA;from which a conversion to linear constraints is indeed possible, from which feasible but suboptimal solutions can still be found. However in the context of my problem this constraint is best not to be relaxed.)&lt;/p&gt;&#xA;" OwnerUserId="3719" LastEditorUserId="3719" LastEditDate="2020-06-10T14:39:13.840" LastActivityDate="2020-06-10T14:39:13.840" Title="Convert summation of min functions into linear constraints for optimization" Tags="|optimization|mixed-integer-programming|linearization|logical-constraints|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="4358" PostTypeId="1" AcceptedAnswerId="4359" CreationDate="2020-06-09T07:33:24.447" Score="5" ViewCount="385" Body="&lt;p&gt;I am dealing with a problem having two types of variables: binary variables, and continuous variables.&lt;/p&gt;&#xA;&lt;p&gt;In some cases, the continuous variables are not used, and so the problem contains those binary variables only. These cases are then very easy to solve with the commercial solvers. For example, a problem with 1000 variables can be optimally solved within 4 seconds on a PC.&lt;/p&gt;&#xA;&lt;p&gt;What I am looking for is to find out whether the resulting zero-one problem is polynomially solvable. I would like to know what special cases of zero-one programming problems are polynomially solvable.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; My thanks to @MarcoLubbecke. The model I am working on is as follows. There is a set &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; of nodes, where every node &lt;span class=&quot;math-container&quot;&gt;$i \in N$&lt;/span&gt; is associated with a positive integer weight &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;, and the distance between two nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is represented by &lt;span class=&quot;math-container&quot;&gt;$d(i,j)$&lt;/span&gt; (also positive integers). The problem is to select &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; nodes, where the distance between each two selected nodes should not be less than a pre-specified integer &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA; z = \min&amp;amp;\quad\sum_i c_i x_i \\&#xA;\text{s.t.}&amp;amp;\quad  x_i + x_j \leq 1, \quad d(i,j) &amp;lt;u,  \quad \forall (i,j) \in N^2, \tag1 \\&#xA;&amp;amp;\quad\sum_i x_i = p \tag2 \\&#xA;&amp;amp;\quad x_{i} \in \{0,1\}.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-07-20T02:01:00.013" LastActivityDate="2020-07-20T02:01:00.013" Title="Polynomially solvable cases of zero-one programming" Tags="|reference-request|binary-variable|computational-complexity|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4359" PostTypeId="2" ParentId="4358" CreationDate="2020-06-09T07:55:27.043" Score="13" Body="&lt;p&gt;First of all, I would say that &quot;fast solvable in practice&quot; is possible also when your remaining problem still is NP-hard. But since you ask specifically for polytime solvability, there are some cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most well-known is probably &quot;TU-ness&quot; of your matrix. When you solve a MIP &lt;span class=&quot;math-container&quot;&gt;$$\min\{c^tx \mid Ax\geq b, x\in Z^n\times Q^q\}$$&lt;/span&gt;&#xA;then you will obtain an integer solution to the LP relaxation if your matrix is &lt;a href=&quot;https://en.wikipedia.org/wiki/Unimodular_matrix&quot; rel=&quot;noreferrer&quot;&gt;totally unimodular&lt;/a&gt; and your right hand side &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is integer (this would imply that you only need to solve the LP, which is doable -- in theory -- in polynomial time). E.g., optimization problems on (undirected) bipartite graphs and flow problems on directed graphs lead to models of this structure. This is one case of the more general situation that your underlying polyhedron is integer (i.e., every face, in particular the vertices, contain an integer point), and there are other criteria for this to happen (check also &lt;a href=&quot;https://en.wikipedia.org/wiki/Total_dual_integrality&quot; rel=&quot;noreferrer&quot;&gt;TDI systems&lt;/a&gt;); in fact, it is sufficient if you could show that your optimal face is always integral, or even only that the optimal face always contains an integer point (&lt;a href=&quot;https://link.springer.com/chapter/10.1007/BFb0028569&quot; rel=&quot;noreferrer&quot;&gt;here is an example&lt;/a&gt; where people do this for half-integrality). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this is not exhaustive; it is possible that your model does not possess this property and you can still solve it polynomially. It may happen that your particular problem structure is a polynomial special case of an NP-hard problem; e.g., you solve a maximum clique problem, hard in general, but on, let's say, interval graphs, this is &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1002/net.3230120410&quot; rel=&quot;noreferrer&quot;&gt;super easy&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then again, your structure may not be one of those &quot;special ones&quot; where polynomial time solvability is known, but your data is so restricted that a (new?) polynomial special case results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Saying this, it would be nice to see your particular problem/model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; after you added your model; this is a stable set/independent set problem, where you are looking for a minimum weight stable set. This would be typically: selecting no vertex at all. However, you have this cardinality constraint forcing you to select vertices. I don't know the status of this problem, but it may be that there are &quot;fixed parameter&quot; algorithms for stable set, where the parameter is the size of the solution (which is fixed to &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; in your case). In principle, you could enumerate all &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-subsets of vertices and pick a cheapest set; there are &lt;span class=&quot;math-container&quot;&gt;$n \choose p$&lt;/span&gt; such subsets, and when &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is fixed this is polytime :) [you see, that I answered my question about complexity status while writing...]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have one more special property: assuming that your distances are metric, your conflict graph is a unit disk graph: you have an edge iff the distance between two nodes is smaller than a (unit) distance. The stable set problem is &lt;a href=&quot;http://webdoc.sub.gwdg.de/ebook/serien/ah/UU-CS/2004-066.pdf&quot; rel=&quot;noreferrer&quot;&gt;easier to approximate on unit disk graphs&lt;/a&gt;, so it may be &quot;easier&quot; also computationally (that brings me back to my initial sentence :)).&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="354" LastEditDate="2020-06-09T09:37:15.610" LastActivityDate="2020-06-09T09:37:15.610" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4360" PostTypeId="2" ParentId="4357" CreationDate="2020-06-09T14:38:57.927" Score="4" Body="&lt;p&gt;This becomes easier if you reformulate your expression as &lt;span class=&quot;math-container&quot;&gt;$$\sum_{0\leq j\leq J} \min({\bf A}_j,{\bf B}_j) \text{ if } j \geq j^{*} \text{ else } 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can linearize each operation separately using indicator constraints or the big-M methods described in the answers you linked. I.e. you can define a boolean variable equal to &lt;span class=&quot;math-container&quot;&gt;$j \geq j^{*}$&lt;/span&gt; and a variable that will be equal to &lt;span class=&quot;math-container&quot;&gt;$\min({\bf A}_j,{\bf B}_j)$&lt;/span&gt; as described in your links, and add similar big-M constraints for the if-else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that some solvers and modelers can handle the above formula directly, with &lt;span class=&quot;math-container&quot;&gt;$\min$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\text{if}$&lt;/span&gt;/&lt;span class=&quot;math-container&quot;&gt;$\text{else}$&lt;/span&gt;, which will be much simpler than writing all big-M constraints yourself.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2020-06-09T14:38:57.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4361" PostTypeId="2" ParentId="4351" CreationDate="2020-06-09T16:53:09.233" Score="8" Body="&lt;p&gt;For each row, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (job), assign it to the worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; which minimizes &lt;span class=&quot;math-container&quot;&gt;$C_{i,j}$&lt;/span&gt;. I.e., assign the job to the cheapest worker. For this problem the greedy algorithm is simple and optimal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm an American, so you can call it the American algorithm.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2020-06-09T19:09:09.440" LastActivityDate="2020-06-09T19:09:09.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4362" PostTypeId="1" CreationDate="2020-06-09T23:07:17.500" Score="6" ViewCount="680" Body="&lt;p&gt;I used the &lt;a href=&quot;https://developers.google.com/optimization/routing/vrp&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vehicle Routing Problem&lt;/a&gt; example that has the objective of minimizing total distance traveled for each vehicle.&lt;/p&gt;&#xA;&lt;p&gt;Suppose that each order to pick up for each vehicle at each node has a priority list, i.e. expedited vs standard. How can I minimize the distance (main objective) but also &amp;quot;soft&amp;quot; respect the priority list if possible?&lt;/p&gt;&#xA;&lt;p&gt;Note that the priority at each node can change depending on the type of the order that exists at each node.&lt;/p&gt;&#xA;&lt;p&gt;An example would be let's say we have 3 vehicles to deliver 10 packages each where we have 10 expedited packages and 20 standard packages. The optimal solution given the objective value would perhaps be the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vehicle 1: 5 expedited packages, 5 standard packages&lt;/li&gt;&#xA;&lt;li&gt;Vehicle 2: 2 expedited packages, 8 standard packages&lt;/li&gt;&#xA;&lt;li&gt;Vehicle 3: 3 expedited packages, 7 standard packages&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Yes, we are prioritizing the expedited packages but if having 1 vehicle delivering all of the 10 expedited packages yield higher distance traveled then truly it is not optimal.&lt;/p&gt;&#xA;" OwnerUserId="3506" LastEditorUserId="491" LastEditDate="2022-01-14T16:55:43.827" LastActivityDate="2022-01-14T16:55:43.827" Title="Priority List Constraint" Tags="|python|or-tools|vehicle-routing|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4363" PostTypeId="2" ParentId="4362" CreationDate="2020-06-10T07:41:54.437" Score="6" Body="&lt;p&gt;If I understand your problem correctly, you have a standard CVRP and a second (soft) objective. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are therefore in the wonderful world of &lt;strong&gt;multi-objective optimization&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically what you do is try to turn this problem into a problem with a well defined optimal solution. There are some ways to do this: &lt;em&gt;lexicographical ordering&lt;/em&gt; of objectives (Cplex calls this &lt;em&gt;lexicographic objective&lt;/em&gt;),&lt;em&gt;goal programming&lt;/em&gt;, using a &lt;em&gt;linear combination&lt;/em&gt; of the objective functions (Cplex calls this &lt;em&gt;blended objective&lt;/em&gt;), &lt;em&gt;attainment levels&lt;/em&gt; or a combination of these techniques. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the context you might want to generate a list of good solutions and have someone pick the best one by hand. What you want your algorithm to do then is called listing the &lt;em&gt;pareto efficient solutions&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I understand your question correctly, you want the distance objective to be optimal and then among the optimal solutions you want the one with the best value for your secondary objective. You should therefore look into the &lt;em&gt;lexicographical ordering&lt;/em&gt; of your objectives. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also be in the world of &lt;strong&gt;soft constraints/objectives&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally you want to allow the soft constraint to be allowed to be violated, add a variable that measures the violation, and add the minimization of that variable as objective. depending on your problem you then use the multi-objective optimizaion techniques to turn the problem well defined again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this helps, good luck and keep on solving problems!&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2020-06-10T08:29:42.400" LastActivityDate="2020-06-10T08:29:42.400" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4365" PostTypeId="1" AcceptedAnswerId="4373" CreationDate="2020-06-10T17:46:52.010" Score="2" ViewCount="549" Body="&lt;p&gt;I am working on a shipping optimisation problem that aims to minimise demurrage charges as a result of low/insufficient inventory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have daily vessel requirement (sales) data in the format &lt;code&gt;sales[vessel_start_date][vessel][product_required_tonnes]&lt;/code&gt;. I also have the daily stock inventory level in the form &lt;code&gt;port_inventory[date][product_availability_tonnes]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Demurrage is defined as: (total_days_in_port - laycan_days) * per_diem_charge. It is incurred when there is insufficient material at the port to load the vessel and the vessel's laycan period (vessel_start_date plus 10 days) has expired. &lt;/li&gt;&#xA;&lt;li&gt;Each vessel takes two days to load.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would be very grateful if anyone could help me formulate this expression in pulp, or give me a steer. Many thanks.&lt;/p&gt;&#xA;" OwnerUserId="3395" LastActivityDate="2020-06-12T17:59:06.473" Title="Pulp Python: How to formulate a time-based variable for shipping demurrage" Tags="|optimization|linear-programming|python|pulp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4366" PostTypeId="1" AcceptedAnswerId="4368" CreationDate="2020-06-10T18:09:44.243" Score="2" ViewCount="8049" Body="&lt;p&gt;I have just installed Anaconda and am intending to use Spyder as it is able to display variable, parameter values for debugging. After which, I am planning to use Pyomo to code my MIP model and invoke CPLEX from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to install Pyomo from the instructions from the &lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/installation.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo Documentation site&lt;/a&gt;, but am stuck at the CPLEX portion as it is not mentioned within the site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having trawled the net, to the best of my knowledge, I am unable to locate any comprehensive instructions on it. I would specifically like to enquire about the following (Kindly correct me if I am wrong):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I understand the Academic Version of CPLEX is downloadable, and that one needs to just download and click for installation.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Cplex executable is different from the API as the API is just a wrapper that translated Python instructions into C instructions during execution, and the Cplex executable is invoked specifically by Pyomo.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;One can either set the path within windows so that Pyomo would automatically locate the Cplex executable upon being invoked by the SolverFactory, or one can code the path within code itself. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I would like to enquire if the instructions found from the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/GettingStarted/topics/set_up/Windows.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;IBM support site&lt;/a&gt; is sufficient for setting up the Cplex executable.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;With regards to 3 and 4, how does one invoke Cplex from Pyomo via coding the path with the code itself? On the other hand, even without explicitly coding the path, is invoking the SolverFactory sufficient? Or is it necessary to set the path via the Anaconda Prompt?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Greatly appreciate your kind advice on the above!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="2599" LastEditDate="2020-06-11T20:31:25.627" LastActivityDate="2021-11-12T03:39:42.287" Title="Downloading and setting up CPLEX for Pyomo" Tags="|solver|python|cplex|pyomo|software|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4367" PostTypeId="1" AcceptedAnswerId="4369" CreationDate="2020-06-10T19:19:05.207" Score="6" ViewCount="882" Body="&lt;p&gt;I wonder how systems like CPLEX, GUROBI, etc implement indicator constraints. Do they just implement Big M equivalents? If yes, what is then the justification for using them? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question does not concern when to prefer using BigM constraints vs Indicator constraints. The question is if the developers of the solver coded the idea of an indicator constraint by coding its equivalent BigM constraint. &lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="1269" LastEditDate="2020-06-10T19:54:49.307" LastActivityDate="2020-06-11T05:42:06.790" Title="How are indicator constraints implemented?" Tags="|mixed-integer-programming|indicator-constraints|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ClosedDate="2020-06-11T07:33:52.510" ContentLicense="CC BY-SA 4.0" />
  <row Id="4368" PostTypeId="2" ParentId="4366" CreationDate="2020-06-11T00:13:51.690" Score="3" Body="&lt;p&gt;At the end of the academic version installation, IBM ILOG asks you whether you want to add CPLEX to the system PATH. The only thing that you need to do is to confirm this question. Once it has been added to the system Path it will be visible for Pyomo after following steps: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;open a command prompt&lt;/li&gt;&#xA;&lt;li&gt;go to the location that IBM/ILOG installed&lt;/li&gt;&#xA;&lt;li&gt;Locate &lt;strong&gt;CPLEX_Studio1210&lt;/strong&gt; folder&lt;/li&gt;&#xA;&lt;li&gt;inside that folder, you will find another folder named python&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;once you are there, in command prompt type the following line and hit enter:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;C:\Program Files\IBM\ILOG\CPLEX_Studio1210\python&gt;python setup.py install&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you have your model &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;opt = SolverFactory('cplex')&#xA;solution = opt.solve(m)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2020-06-11T00:55:24.177" LastActivityDate="2020-06-11T00:55:24.177" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4369" PostTypeId="2" ParentId="4367" CreationDate="2020-06-11T05:42:06.790" Score="7" Body="&lt;p&gt;You can have a look at SCIP's implementation in &lt;a href=&quot;https://www.scipopt.org/doc-7.0.0/html/cons__indicator_8h.php&quot; rel=&quot;noreferrer&quot;&gt;cons_indicator&lt;/a&gt;. They say that:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;An indicator constraint is given by a binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and an inequality &lt;span class=&quot;math-container&quot;&gt;$ax \le b$&lt;/span&gt;. It states that if &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$ax \le b$&lt;/span&gt; holds.&lt;/p&gt;&#xA;&lt;p&gt;This constraint is handled by adding a slack variable &lt;span class=&quot;math-container&quot;&gt;$s: ax−s \le b$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$s \le 0$&lt;/span&gt;. The constraint is enforced by fixing &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This constraint is equivalent to a linear constraint &lt;span class=&quot;math-container&quot;&gt;$ax−s \le b$&lt;/span&gt; and an SOS1 constraint on &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; (at most one should be nonzero). In the indicator context we can, however, separate more inequalities.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="126" LastEditorUserId="-1" LastEditDate="2020-06-18T08:36:45.613" LastActivityDate="2020-06-11T05:42:06.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4370" PostTypeId="2" ParentId="4366" CreationDate="2020-06-11T08:56:04.137" Score="4" Body="&lt;p&gt;First of all, you need to be able to use CPLEX from Python scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After installation of CPLEX in your machine, you have two ways to install CPLEX-Python modules:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. Use &lt;code&gt;setup.py&lt;/code&gt; script&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open a &lt;code&gt;cmd&lt;/code&gt; and navigate to &lt;code&gt;yourCplexhome/python/pythonVERSION/PLATFORM&lt;/code&gt; (it should be like &lt;code&gt;C:\Program Files\IBM\ILOG\CPLEX_Studio129\cplex\python\3.7\x64_win64&lt;/code&gt;, there should be the script &lt;code&gt;setup.py&lt;/code&gt;; simply run this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python setup.py install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;OR&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. Set environement variable &lt;code&gt;PYTHONPATH&lt;/code&gt;&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In the windows &lt;em&gt;Start Search&lt;/em&gt;, type &quot;env&quot; and select &quot;Edit the system environment variables&quot; then click &quot;Environment Variables&quot;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;code&gt;PYTHONPATH&lt;/code&gt;is among the variable, edit it, otherwise create a new varaible and name it &quot;PYTHONPATH&quot;&lt;/li&gt;&#xA;&lt;li&gt;In the variable name, add &lt;code&gt;yourCplexhome/python/pythonVERSION/PLATFORM&lt;/code&gt;. If the variable already contains a path, add a semicolumn &lt;code&gt;;&lt;/code&gt; before adding the cplex path, otherwise, just copy-paste the cplex location to the newly created varaible value.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To check if CPLEX is now available in Python, open a command line and type &lt;code&gt;python&lt;/code&gt;, then &lt;code&gt;import cplex&lt;/code&gt;, you should not have any error message saying that &quot;there is no module named cplex&quot; if CPLEX is recognized in Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Pyomo, don't forget to &lt;code&gt;import cplex&lt;/code&gt;, then call cplex as a solver:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;opt = SolverFactory('cplex') &#xA;results = opt.solve(concreteModel)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may refer to &lt;strong&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/GettingStarted/topics/set_up/Python_setup.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Setting up the Python API in CPLEX&lt;/a&gt;&lt;/strong&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="2599" LastEditorUserId="2599" LastEditDate="2020-06-11T12:58:28.100" LastActivityDate="2020-06-11T12:58:28.100" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4371" PostTypeId="1" AcceptedAnswerId="4372" CreationDate="2020-06-11T19:37:28.480" Score="4" ViewCount="384" Body="&lt;p&gt;A water tank needs to be refilled with an electric pump when the water level gets below a certain level. The pump can operate at variable flow rates. Further, there is a time-variant electric billing during different times of the day. We need to quickly fill the tank with the minimum electricity bill.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've devised the following solution &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_{t=1}^{24}\gamma \cdot Q_p(\alpha)\cdot t\cdot C_t\cdot U_i(s)\\\text{s.t}&amp;amp;\quad p_{\min} \le P_{t} \le p_{\max}\\&amp;amp;\quad l_{\min} \le l_{t} \le l_{\max}\end{align}&lt;/span&gt; where &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; is a coefficient to demonstrate that the power consumption is proportional to flow rate &lt;span class=&quot;math-container&quot;&gt;$Q_p(\alpha)$&lt;/span&gt;;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;energy cost is represented as &lt;span class=&quot;math-container&quot;&gt;$t\cdot C_t$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$C_t$&lt;/span&gt; is cost of electricity at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$U_i(s)$&lt;/span&gt; is the status of the pump where &lt;span class=&quot;math-container&quot;&gt;$U_i(s)\in[0,1] $&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; means inactive and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; means active; &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{\min}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_{\max}$&lt;/span&gt; are the minimum and maximum pressure levels respectively;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$l_{\min}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$l_{\max}$&lt;/span&gt; are the minimum and maximum threshold levels respectively.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So far I've achieved the above mathematical formulation as per my understanding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am unable to add a constraint where the problem states that if the tank level drops below a threshold, then it is compulsory to refill the tank and I'd want to then change the pump status represented by &lt;span class=&quot;math-container&quot;&gt;$U_i(s)$&lt;/span&gt; to be equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. How can a add that constraint?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my above problem formulation correct or is there any other error?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Task&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Formulate the given problem and suggest an optimisation problem (No  implementation required)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem Description: Consider a water tank on a roof top that needs to be refilled with an electric pump when water level in the tank gets below certain threshold. The electric pump can operate with variable flow rate and its power consumption is directly promotional to flow rates. Furthermore, we also consider time variant pricing for electricity billing i.e. same power consumption during different day time will be charged differently. Assume peak pricing policy around mid-day time and gradual decrease in pricing near morning and evening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The home user need is to quickly refill the tank with minimum electricity bill. Your task is to formulate the given problem and suggest an optimisation formula to full-fill given user requirements. You need to consider three parameters (a) tank water level (b) pump flow rate (c) pricing rate at current time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider any further relevant assumptions or constraints if needed. Your assumptions or constraints must be valid in given problem scenario. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2nd Attempt&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After looking at answer and comments I've tried to improve my objective function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$in_t = Q_p(t,\alpha)$&lt;/span&gt; will make inflow dependent on both time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and pressure &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$power = \gamma . Q_p(t,\alpha)$&lt;/span&gt; Since power consumption is proportional to inflow rate &lt;span class=&quot;math-container&quot;&gt;$Q_p(t,\alpha)$&lt;/span&gt; I've multiplied it with factor &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$U(t)$&lt;/span&gt; is status of pump at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. It would be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if inactive or active respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since electricity cost is time variant therefore &lt;span class=&quot;math-container&quot;&gt;$C(t)$&lt;/span&gt; would represent cost of electricity at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Factoring all the above cost I've developed the following cost function:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_{t=1}^{24} Min: \gamma \cdot Q_p(t,\alpha) \cdot C(t) \cdot U(t)\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ s.t.$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}l_{min} \le l_t - out_t - Q_p(t, \alpha) \le l_{max} \end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align} P_{min} \le \alpha \le P_{max} \end{align}&lt;/span&gt;&#xA;I am not sure but I think if &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; represent the pressure then limiting it from &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$p_{max}$&lt;/span&gt; would help us get rid of incorporating pump status &lt;span class=&quot;math-container&quot;&gt;$U(t)$&lt;/span&gt; since if pump is not operational pressure would be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q_p(t,\alpha)$&lt;/span&gt; would eventually equate to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe the above constraint do take into account the tracking of tank level. However, the question states &quot;refilling takes place if the level drops below a certain threshold&quot; &amp;amp; I believe that I haven't taken that into account and there should be constraint for that as well. I believe it should be that &lt;span class=&quot;math-container&quot;&gt;$\alpha \ge 0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$l_t \le l_{thres}$&lt;/span&gt;. &#xA;Where &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; represents pressure and &lt;span class=&quot;math-container&quot;&gt;$l_{thres}$&lt;/span&gt; is the level threshold after which the filling starts.&#xA;If this is correct how would I write a constraint for it?&lt;/p&gt;&#xA;" OwnerUserId="3735" LastEditorUserId="2556" LastEditDate="2020-06-16T11:31:50.160" LastActivityDate="2020-06-16T11:31:50.160" Title="Creating an Optimisation Problem to Optimise Water Flow" Tags="|optimization|modeling|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4372" PostTypeId="2" ParentId="4371" CreationDate="2020-06-12T07:47:35.670" Score="3" Body="&lt;h2&gt;This was my answer to the initial question which has been edited since:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First you need to add equations to model the evolution of the tank's level:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;l_{t+1}=l_t - \mbox{out}_t + \mbox{in}_t&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mbox{out}_t$&lt;/span&gt; is the volume that is pumped out of the tank at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\mbox{in}_t$&lt;/span&gt; is the volume that is pumped in. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mbox{in}_t$&lt;/span&gt; is a variable that takes a positive value only when the tank reaches the minimum threshold. And this value cannot be lower than &lt;span class=&quot;math-container&quot;&gt;$l_{\max}-l_{\min}$&lt;/span&gt;, so that the tank is refilled properly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\mbox{in}_t &amp;amp;\ge (l_{\max}-l_{\min}) \delta_t \\&#xA;\delta_t &amp;amp;\in \{0,1\}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$l_t - \mbox{out}_t &amp;gt; l_{\min}$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\mbox{in}_t$&lt;/span&gt; has to take value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, otherwise we would have &lt;span class=&quot;math-container&quot;&gt;$l_{t+1} &amp;gt; l_{\max}.$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And to activate &lt;span class=&quot;math-container&quot;&gt;$U_i(s)$&lt;/span&gt;: &#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\delta_t \le U_i(s)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am pretty sure your cost function is not well defined though.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Addendum 1:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is how I would model the problem given the (new) &lt;strong&gt;Task&lt;/strong&gt; paragraph:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1) Parameters:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Tank volume : &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Tank minimum threshold (safety volume) : &lt;span class=&quot;math-container&quot;&gt;$V_s$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Time span : &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Step time : &lt;span class=&quot;math-container&quot;&gt;$\Delta t$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Proportionality constant between inflow and power: &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Pricing rate [\$/watt] at time &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt; : &lt;span class=&quot;math-container&quot;&gt;$c_t$&lt;/span&gt; &lt;/li&gt;&#xA;&lt;li&gt;Outflow volume at time &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\mbox{out}_t$&lt;/span&gt;. I consider that this parameter is known or estimated, for example with a sensor on the tank.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2) Variables:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mbox{in}_t \in \mathbb{R}^+$&lt;/span&gt;: volume pumped in at time &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$v_t \in \mathbb{R}^+ $&lt;/span&gt; : tank water level at time &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt; (volume, same dimension as &lt;span class=&quot;math-container&quot;&gt;$\mbox{in}_t$&lt;/span&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p_t \in \mathbb{R}^+$&lt;/span&gt;: power consumption at time &lt;span class=&quot;math-container&quot;&gt;$t\in T$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3) Objective function:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are minimizing power consumption (the electricity bill):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \quad  \sum_{t \in T} c_t \; p_t&#xA;$$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;4) Constraints:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;power consumption definition: &#xA;&lt;span class=&quot;math-container&quot;&gt;$$p_t \; \Delta t= k \; \mbox{in}_t \quad \forall t \in T$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note: power is proportional to rate, which is the volume divided by the step time.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;tank level:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;v_{t+1} &amp;amp;= v_t - \mbox{out}_t + \mbox{in}_t \quad &amp;amp;\forall t \in T \\&#xA;V_s &amp;amp; \le v_t \le V \quad &amp;amp;\forall t \in T&#xA;\end{align*}&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;5) Possible additional constraints:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As suggested by OP: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Maximum power &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p_t \le P \quad \forall t \in T&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To me it is not explicit that the tank must necessarily be refilled when the pump is active. If it is, see initial answer.&#xA;Also, the binary status of the pump is not necessary. If the pump is not pumping, &lt;span class=&quot;math-container&quot;&gt;$p_t = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-06-15T16:31:13.603" LastActivityDate="2020-06-15T16:31:13.603" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="4373" PostTypeId="2" ParentId="4365" CreationDate="2020-06-12T17:59:06.473" Score="3" Body="&lt;p&gt;I have created a model that I believe addresses your objective of minimizing demurrage charges. It utilizes indicator variables for each day and vessel showing when each vessel is finally loaded. The factors for the variables in the objective function are to be calculated based on the demurrage formula you provided. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing to do with this model is to ensure that you have the port inventory working correctly, then add the demurrage calculation for the objective. The formulation I have provided does not deal with the two day loading period. You'll want to fill in details on how inventory increases at the port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this is helpful.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vessels = ['a', 'b']&#xA;sales_days = list(range(20))&#xA;sales = {1: {&quot;a&quot;: 10}, 3: {&quot;b&quot;: 10}}&#xA;vessel_qty = {&quot;a&quot;: 10, &quot;b&quot;: 10}&#xA;per_diem_charge = 100&#xA;laycan_days = 10&#xA;initial_port_inventory = 2&#xA;daily_inventory_increase = 1&#xA;model = pulp.LpProblem(&quot;PortDemurrage&quot;)&#xA;day_port_inventory = pulp.LpVariable.dict(&quot;port_inventory&quot;, sales_days, &#xA;  lowBound=0, cat=&quot;Integer&quot;)&#xA;# set initial inventory&#xA;model += day_port_inventory[0] == initial_port_inventory&#xA;vessel_start_dates = {vessel: day for day in sales for vessel in sales[day]}&#xA;# denote the vessel sales by day the vessel is finally loaded&#xA;vessel_sales = pulp.LpVariable.dicts(&quot;vessel_sales&quot;, [f&quot;{vessel}_{day}&quot; for &#xA;  vessel in vessels for day in sales_days[vessel_start_dates[vessel]:]], &#xA;  lowBound=0, cat=&quot;Integer&quot;)&#xA;for day in sales_days[1:]:&#xA;    day_sales = 0&#xA;    for vessel in vessels:&#xA;        if vessel_start_dates[vessel] &amp;lt;= day:&#xA;            day_sales += vessel_sales[f&quot;{vessel}_{day}&quot;]&#xA;    model += day_port_inventory[day] == day_port_inventory[day - 1] + &#xA;daily_inventory_increase - day_sales&#xA;&#xA;for vessel in vessels:&#xA;    vessel_start_date = vessel_start_dates[vessel]&#xA;    possible_days = sales_days[vessel_start_date:]&#xA;    model += sum(vessel_sales[f&quot;{vessel}_{day}&quot;] for day in possible_days) == &#xA;vessel_qty[vessel]&#xA;&#xA;obj = 0&#xA;final_day_vars = []&#xA;for vessel in vessels:&#xA;    demurrage_day_start = vessel_start_dates[vessel]+laycan_days+1&#xA;    vessel_start_date = vessel_start_dates[vessel]&#xA;    for day in sales_days[vessel_start_date:]:&#xA;        vessel_day_var = pulp.LpVariable(f&quot;{vessel}_sales_day_{day}&quot;, &#xA;          lowBound=0, upBound=1, cat=&quot;Integer&quot;)&#xA;        final_day_vars.append(vessel_day_var)&#xA;        if day &amp;gt;= demurrage_day_start:&#xA;            obj += vessel_day_var * (per_diem_charge * (day - &#xA;              vessel_start_dates[vessel] - laycan_days))&#xA;    model += vessel_sales[f&quot;{vessel}_{day}&quot;] &amp;lt;= vessel_day_var * &#xA;      vessel_qty[vessel]&#xA;model += sum(final_day_vars) == len(vessels)&#xA;model += obj, &quot;minimize demurrage charge&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Solving this model produces a solution where vessel a is finally loaded on day 8 and vessel b is finally loaded on day 18. The objective value of this solution is 500, since vessel b needs to wait 15 days after arrival.&lt;/p&gt;&#xA;" OwnerUserId="61" LastActivityDate="2020-06-12T17:59:06.473" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4374" PostTypeId="1" CreationDate="2020-06-13T08:46:45.260" Score="3" ViewCount="90" Body="&lt;p&gt;Suppose in a model I have the expression &lt;span class=&quot;math-container&quot;&gt;$y_{1}(x) = 10 + 5 x^2$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x \in [0,20]$&lt;/span&gt; is a continuous variable. In order to be able to use an MILP solver, I piecewise linearise &lt;span class=&quot;math-container&quot;&gt;$z_{1} = x^2$&lt;/span&gt;, by choosing &lt;span class=&quot;math-container&quot;&gt;$\{0,5,10,20\}$&lt;/span&gt; as arbitrary values for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, as follows: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA;x = 0 \lambda_{1} + 5 \lambda_{2}  + 10 \lambda_{3}  +  20 \lambda_{4}  \\&#xA;z_{1} =0 \lambda_{1} + 25 \lambda_{2}  + 100 \lambda_{3}  +  400 \lambda_{4}  \\&#xA;\lambda_{1} + \lambda_{2}  + \lambda_{3}  + \lambda_{4} = 1 &#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the same model, I have to deal with the function:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{2}(x,d) = 20 + 5 (x-d)^2, d \ge 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is a variable &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to express &lt;span class=&quot;math-container&quot;&gt;$(x-d)^2$&lt;/span&gt; in a linearised form in terms of &lt;span class=&quot;math-container&quot;&gt;$\lambda_{1}, \lambda_{2}, \lambda_{3}, \lambda_{4}$&lt;/span&gt;?   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please consider that &lt;span class=&quot;math-container&quot;&gt;$y_{1}(x)$&lt;/span&gt; could be any nonlinear function, the quadratic form stated here is just an example.  &lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="39" LastEditDate="2020-06-14T20:54:23.433" LastActivityDate="2020-06-14T20:54:23.433" Title="Linearization of the shifted copy of a function" Tags="|mixed-integer-programming|linearization|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4375" PostTypeId="2" ParentId="4362" CreationDate="2020-06-13T18:17:58.110" Score="1" Body="&lt;p&gt;Given that we have expedited and standard packages to be delivered at the start of the planning, I am assuming that if you have limited capacity to fit all orders in a trucks, pick a solution where expedited orders are in the solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:100 packages to deliver, with 10 trucks with 50 standard and 50 expedited. Say in this case, we can have 2 solutions: Sol1 (50 standard, 45 expedited), Sol2 ( 45 standard , 50 expedited).  Pick Sol 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a way we do not want to miss planning any expedited orders but while doing so do minimize the distance traveled. For a typical CVRP MIP formulation, for all orders I will have a binary variable indicating whether I can fit this order in a truck. This binary variable will go in the constraint &quot;all orders have to either in a truck or not planned&quot; constraint. I will put a high penalty for all expedited orders binary variables in the objective function.&lt;/p&gt;&#xA;" OwnerUserId="3360" LastActivityDate="2020-06-13T18:17:58.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4376" PostTypeId="2" ParentId="3390" CreationDate="2020-06-13T23:55:28.257" Score="3" Body="&lt;p&gt;For large scale Rich VRP problems like yours, creating routes and then using column generation methodology is one approach I have implemented in the past. Typically we create routes and then assign to drivers whose start and end time are different as you mention in your problem setting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not intimately familiar with all aspects of job scheduling, but you can create your own formulation. I am providing below a high-level methodology of how to create your own formulation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am assuming you will create routes by grouping customers into these routes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say we have routes with index &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_r = 1$&lt;/span&gt; if route &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; is selected else &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$st =$&lt;/span&gt; &lt;code&gt;start_time&lt;/code&gt; of the resource.&lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$et =$&lt;/span&gt; &lt;code&gt;end_time&lt;/code&gt; of the resource.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Parameters:&lt;br&gt;&#xA;&lt;code&gt;resource_start_time&lt;/code&gt; = when resource (vehicle) is available to start&lt;br&gt;&#xA;&lt;code&gt;resource_end_time&lt;/code&gt; = when resource (vehicle) clocks off&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Route &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; has [&lt;code&gt;customers_list&lt;/code&gt;, &lt;code&gt;start_route_time&lt;/code&gt;, &lt;code&gt;end_route_time&lt;/code&gt;]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Objective: &lt;span class=&quot;math-container&quot;&gt;$\text{maximize}\quad (et - st)$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Each customer is selected once. [like a set partitioning constraint]&lt;/li&gt;&#xA;&lt;li&gt;Add time window constraints for all routes &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; to fit [&lt;code&gt;resource_start_time&lt;/code&gt;, &lt;code&gt;resource_end_time&lt;/code&gt;] and link them with &lt;span class=&quot;math-container&quot;&gt;$st$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$et$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Hope the methodology helps. &lt;/p&gt;&#xA;" OwnerUserId="3360" LastEditorUserId="36" LastEditDate="2020-06-14T03:49:57.580" LastActivityDate="2020-06-14T03:49:57.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4377" PostTypeId="2" ParentId="3390" CreationDate="2020-06-14T11:28:16.397" Score="4" Body="&lt;p&gt;From your description, this just sounds like the multitrip vehicle routing problem. If so, there's many papers out there on the multitrip problem - e.g. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.researchgate.net/publication/221704651_The_Multi-Trip_Vehicle_Routing_Problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.researchgate.net/publication/221704651_The_Multi-Trip_Vehicle_Routing_Problem&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bear in mind that MILP solutions to vehicle routing problems generally don't scale as well as combinations of heuristics and metaheuristics.&lt;/p&gt;&#xA;" OwnerUserId="825" LastActivityDate="2020-06-14T11:28:16.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4378" PostTypeId="1" AcceptedAnswerId="4379" CreationDate="2020-06-14T11:57:40.110" Score="12" ViewCount="2589" Body="&lt;p&gt;There is a quote from John Tukey in one of his papers on data analysis&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Far better an approximate answer to the right question, which is often&#xA;  vague, than an exact answer to the wrong question, which can always be&#xA;  made precise.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Does something similar hold in the OR community as well, in general?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, suppose a complex problem which is hard to model and optimize, is it better to try and get an approximate solution of the exact problem, or is it better to try and simplify/approximate the problem such that it can be solved exactly?&lt;/p&gt;&#xA;" OwnerUserId="2550" LastActivityDate="2020-06-14T16:18:06.743" Title="An approximate answer to the right question or an exact answer to the wrong question" Tags="|optimization|modeling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4379" PostTypeId="2" ParentId="4378" CreationDate="2020-06-14T13:34:34.323" Score="19" Body="&lt;p&gt;Yes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe the same analysis can be made for OR. In the industry, it is far more important to solve the actual problem as well as you can than to obtain the perfect result on a different problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The business objective is often vaguely defined, and the data is not perfectly accurate. Stated otherwise, it is important to make sure that you are solving the right problem with the right data, rather than solve it perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there are a few caveats:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;you do not need an exact model of reality either, just something close enough for the business needs&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;solving a different problem exactly may be the best way to obtain good candidate solutions (or yield a starting point for a heuristic) &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;giving a lower bound on your solution's quality, or an optimality proof, even on a slightly different problem, may be the best way to convince some stakeholders&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;this does not apply to most academic publications, as the problem to be solved is usually well defined from the start&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2020-06-14T16:18:06.743" LastActivityDate="2020-06-14T16:18:06.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4380" PostTypeId="1" AcceptedAnswerId="4381" CreationDate="2020-06-15T06:21:31.880" Score="3" ViewCount="199" Body="&lt;p&gt;My question is how to model a resource constraint with MIP model&#xA;(how should I modify it?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A factory is making blocks. If there is space left at that time, the block can be assembled.&#xA;(If the factory has space, it can do multiple tasks at the same time.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm asking this question because I don't know how to formulate it even though I've been thinking about it after getting feedback in the comments from &lt;a href=&quot;https://or.stackexchange.com/users/67/prubin&quot;&gt;prubin&lt;/a&gt; to my previous question: &lt;a href=&quot;https://or.stackexchange.com/questions/4276/space-constraint-in-scheduling-problem/4279?noredirect=1#comment6982_4279&quot;&gt;Space constraint in scheduling problem&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are my notations:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Index&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt; is the block number&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is factory number&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is time&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{i,f}=\begin{cases}1\quad\text{if}\,i\,\text{process at factory}\,f\\0\quad\text{otherwise}\end{cases}$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$sp_i$&lt;/span&gt; is required area for each block&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_f$&lt;/span&gt; is available space of factory f&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt; is procees time of each block&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a big number&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$C_i$&lt;/span&gt; the start time, completion time of block &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; respectively&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{i,j,f}=\begin{cases}1\quad\text{if}\,i\,\text{process before}\,j\,\text{at factory}\,f\\0\quad\text{otherwise}\end{cases}$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{i,f,t}=\begin{cases}1\quad\text{if}\,i\,\text{start at factory }\,f\text{ at time t }\quad\\0\quad\text{otherwise}\end{cases}$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s2_{i,f,t}=\begin{cases}1\quad\text{if}\,i\,\text{process at factory }\,f\text{ at time t }\quad\\0\quad\text{otherwise}\end{cases}$&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{f=1}\sum_{t=1} (y_{i,f} \cdot s_{i,f,t}) =1\quad\forall i \quad (1)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{f=1}\sum_{t=1}(t \cdot s_{i,f,t}) = S_i \quad \forall  i \quad (2)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ S_i+p_i = C_{i}\quad\quad \forall i \quad (3)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ S_i-M(1-y_{i,j,f}) \le S_{j} \quad\quad \forall i,j,f \quad (4)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this part is the problem because &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; depends on variables &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt;,&lt;span class=&quot;math-container&quot;&gt;$C_i$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure why Problems running when running with gurobi.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{t=S_i}^{C_i}  s2_{i,f,t} = p_{i}\quad\forall f\quad (5)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i} sp_i \cdot s2_{i,f,t} \le c_{f}\quad\forall f,t\quad (6)$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks for your reading&lt;/p&gt;&#xA;" OwnerUserId="3663" LastEditorUserId="3663" LastEditDate="2020-06-16T04:48:12.117" LastActivityDate="2020-06-16T09:27:27.583" Title="Resource constraint with MIP model" Tags="|optimization|mixed-integer-programming|scheduling|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4381" PostTypeId="2" ParentId="4380" CreationDate="2020-06-15T08:01:40.957" Score="4" Body="&lt;p&gt;I think this inequality is a problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{t=S_i}^{C_i}  s2_{i,f,t} = p_{i}\quad\forall f\quad .$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The index of your summation cannot depend on variables. You should therefore delete it. Then you can do the following to repair your model:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add a variable to end the job: &lt;span class=&quot;math-container&quot;&gt;$c_{i,f,t}=\begin{cases}1\quad\text{if}\,i\,\text{start at factory }\,f\text{ at time t }\quad\\0\quad\text{otherwise}\end{cases}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;add these inequality&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{t}t \cdot c_{i,f,t} = C_i \quad \forall  i,f \tag7$$&lt;/span&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ s2_{i,f,t} \ge s_{i,f,t}  \forall  i,f,t \tag8$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the s2 variables are used to indicate, that the job i is taken processed at time t at machine f, and s indicated the start of the job, we know that when the job starts, it also needs to take place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ s2_{i,f,t} \ge s2_{i,f,t-1} - c_{i,f,t-1} \forall  i,f,t \tag9$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This inequality tell us, that if we were processing job i at f during time t-1 we also process it at time t, unless time t-1 was also the completion time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This model is not nice, but i think it works and is a starting point. You might want to look into machine scheduling and resource constraint project scheduling literature for better ideas.&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2020-06-16T09:27:27.583" LastActivityDate="2020-06-16T09:27:27.583" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4382" PostTypeId="1" CreationDate="2020-06-15T17:32:10.347" Score="1" ViewCount="69" Body="&lt;p&gt;I have some data that looks almost linear. I need to make a fit in order to evaluate the slope.&#xA;The thing is, the slope is changing if I change the fit range (not all the data is linear so I need to choose myself the range) I wondered how would you suggest to evaluate the added error from the arbitrary selection of the range. For example, maybe I should make a few fits for a few ranges, and take the &amp;quot;range of slopes&amp;quot;/stdv as the added uncertainty?&lt;br /&gt;&#xA;thanks&lt;/p&gt;&#xA;" OwnerUserId="3743" LastEditorUserId="36" LastEditDate="2020-07-18T13:46:07.330" LastActivityDate="2020-07-18T13:46:07.330" Title="Error evalution for linear fits" Tags="|fitting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4383" PostTypeId="2" ParentId="4382" CreationDate="2020-06-15T18:02:57.560" Score="3" Body="&lt;p&gt;There exist methods for fitting a piece-wise linear function to data in an optimal way, for various interpretations of what it means for this fit to be optimal. These methods may still require you to specify the number of segments in advance, but playing around with the number of segments seems less arbitrary to me than selecting the ranges by yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/29382903/how-to-apply-piecewise-linear-fit-in-python&quot;&gt;This question on StackOverflow&lt;/a&gt; discusses Python libraries to do piece-wise linear fitting, including &lt;a href=&quot;https://pypi.org/project/pwlf/&quot; rel=&quot;nofollow noreferrer&quot;&gt;pwlf&lt;/a&gt;. You may also have a look at the Wikipedia entry for &lt;a href=&quot;https://en.wikipedia.org/wiki/Segmented_regression&quot; rel=&quot;nofollow noreferrer&quot;&gt;Segmented regression&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2020-06-15T18:02:57.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4384" PostTypeId="2" ParentId="437" CreationDate="2020-06-15T20:56:28.410" Score="2" Body="&lt;p&gt;The new release of Octeract Engine (full disclosure: I own that company) comes with the &lt;a href=&quot;https://octeract.com/simple-solving-the-reformulator-api/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Reformulator&lt;/a&gt; API, which allows users to code, share, and reuse reformulations in the form of simple Python scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are still setting up the web infrastructure around it so it's still a bit hush-hush, but we will have a user hub for people to share reformulations, pretty much like people can download MATLAB toolboxes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We developed that language specifically to write parallel optimisation solvers, so the syntax is extremely powerful. Octeract Engine is basically a tech demo of the Octeract Reformulation Language (the Reformulator being the compiler).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The philosophy is that the mathematical logic is abstracted, so people define the logic and the compiler takes care of applying it to the problem at hand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, this is the Octeract Reformulator script to linearise a Binary Bilinear Term:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;trigger = Match('C(n)*V(y1)*V(y2)')&#xA;filters = (IsBinary('y1') &amp;amp; IsBinary('y2'))&#xA;action = Track('V(y1)*V(y2)',AddBinaryVariable('w_yy') \&#xA;           +AddConstraint('con1','y1+y2-w_yy-1&amp;lt;=0') \&#xA;           +AddConstraint('con2','w_yy-y1&amp;lt;=0') \&#xA;           +AddConstraint('con3','w_yy-y2&amp;lt;=0'))&#xA;mod = action + SubWith('n*w_yy')&#xA;rule = (trigger &amp;amp; filters).then(mod)&#xA;m.apply_mod(rule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We first define a symbolic &lt;code&gt;Match&lt;/code&gt;, which is our trigger. We can then apply all sorts of filters, in this case &lt;code&gt;IsBinary&lt;/code&gt; for both variables. We then define actions on how to modify the problem when these conditions are met, in this case to add a new auxiliary variable and three constraints. We can also define &lt;code&gt;Track&lt;/code&gt;, which lets the compiler know to only do this for the first instance of each Match, i.e., if &lt;span class=&quot;math-container&quot;&gt;$xy$&lt;/span&gt; appears 100 times in the problem, with &lt;code&gt;Track&lt;/code&gt; the compiler will generate a unique auxiliary variable the first time it sees &lt;span class=&quot;math-container&quot;&gt;$xy$&lt;/span&gt;, and re-use that variable for all other occurrences. It will also only add the set of constraints once per unique auxiliary variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once we have defined that info, we can build problem modification rules using simple operators, e.g. &lt;code&gt;rule = (trigger &amp;amp; filters).then(mod)&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of this information is fully reusable and can be mixed &amp;amp; matched, e.g., the same trigger can be used with other filters and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two things that are really interesting here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;People can read this code and understand the mathematical logic being applied.&lt;/li&gt;&#xA;&lt;li&gt;This code only needs to be written once. It can then be reused to apply this reformulation for any problem, by anyone. The names you see are just user-defined handles for the language, e.g., the variables in the model don't need to actually be named &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; for that exact code to work. The names are only used internally by the compiler to match each variable to other rules later on.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-06-15T20:56:28.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4386" PostTypeId="1" AcceptedAnswerId="4388" CreationDate="2020-06-16T08:00:30.340" Score="5" ViewCount="1407" Body="&lt;p&gt;The Transportation Problem can be solved with a simplex algorithm, but it's time-consuming.&lt;/p&gt;&#xA;&lt;p&gt;I'm wondering if there exists a specific Python-implemented algorithm with low complexity.&lt;/p&gt;&#xA;" OwnerUserId="3733" LastEditorUserId="500" LastEditDate="2022-09-09T23:59:53.107" LastActivityDate="2022-09-09T23:59:53.107" Title="Fast algorithm for Transportation Problem in Python?" Tags="|optimization|python|network-flow|computational-complexity|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4387" PostTypeId="2" ParentId="4386" CreationDate="2020-06-16T09:00:20.580" Score="2" Body="&lt;p&gt;You can try &lt;a href=&quot;https://github.com/coin-or/Cbc&quot; rel=&quot;nofollow noreferrer&quot;&gt;CBC&lt;/a&gt; which uses Dual Simplex (the same algorithm CPLEX &amp;amp; GUROBI use). The easiest way to use that through Python is &lt;a href=&quot;http://www.pyomo.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-06-16T09:00:20.580" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4388" PostTypeId="2" ParentId="4386" CreationDate="2020-06-16T09:25:11.287" Score="9" Body="&lt;p&gt;You could try to solve it as a min cost flow problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NetworkX is a package for graph algorithms and has algorithms for this implemented.&#xA;It can easily be installed via &lt;code&gt;pip install networkx&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An minimal working example is given at the bottom of this link:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://networkx.github.io/documentation/networkx-2.4/reference/algorithms/generated/networkx.algorithms.flow.min_cost_flow.html#networkx.algorithms.flow.min_cost_flow&quot; rel=&quot;noreferrer&quot;&gt;https://networkx.github.io/documentation/networkx-2.4/reference/algorithms/generated/networkx.algorithms.flow.min_cost_flow.html#networkx.algorithms.flow.min_cost_flow&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="3305" LastEditDate="2020-06-16T10:05:54.973" LastActivityDate="2020-06-16T10:05:54.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4389" PostTypeId="1" CreationDate="2020-06-16T11:14:25.173" Score="1" ViewCount="173" Body="&lt;p&gt;I am trying to model an Electric Vehicle scheduling to minimise the electricity bill. Of course, the EV will only be able to charge every time that is plugged into a charging station (i.e. it cannot charge when the vehicle is driving). Basically, it is a stationary battery that can be disconnected and connected again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already managed to model a stationary battery scheduling before and is working well as I expected, however, I am having a hard time setting up a constraint to connect and disconnect the battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the dataset that I am using the vehicle is plugged in at certain periods of time, and I am using a dictionary like this &lt;code&gt;availDict = dict(enumerate(df[avail]))&lt;/code&gt; that contains values &lt;code&gt;1 = plugged&lt;/code&gt; and &lt;code&gt;0 = not plugged&lt;/code&gt; at different times of the day.  For example, assuming that when the vehicle is plugged when is not driving then, from 7am to 9am is not plugged as the vehicle is driving, from 9am to 6pm is plugged as the vehicle is not driving, from 6pm to 8pm is not plugged as the vehicle is driving and from 8pm to 7am is plugged as the vehicle is not driving.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment I have tried to model the constraint as a boolean like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model.avail_bool = en.Var(model.Time, within=en.Boolean, initialize=1)&#xA;&#xA;model.not_avail_bool = en.Var(model.Time, within=en.Boolean)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was thinking to use BigM to force the model to constraint the vehicle from charging during that time, but I am having a hard time setting this up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For further explanation, these are the equations that I am trying to model that I found in a paper:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SOCmin(t) &amp;lt;= SOC(t) &amp;lt;= SOCmax(t)&#xA;&#xA;if avail = 0 (not plugged)&#xA;&#xA;SOCmin(t) = SOCmax(t) = 0&#xA;&#xA;if avail = 1 (plugged) but idle&#xA;&#xA;SOCmin(t) = 0 and SOCmax(t) = SOC&#xA;&#xA;if avail = 1 (plugged) and needed by time (t)&#xA;&#xA;SOCmin(t) = SOCmax(t) = SOC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope that I explained my problem properly and hopefully, you are able to understand what I meant. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is another suggestion or you need more information please let me know so I can provide it as soon as possible.&lt;/p&gt;&#xA;" OwnerUserId="3746" LastEditorUserId="39" LastEditDate="2020-06-16T16:33:08.280" LastActivityDate="2020-06-16T16:33:08.280" Title="Pyomo: Struggling to get a constraint to work" Tags="|mixed-integer-programming|python|constraint|pyomo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4390" PostTypeId="2" ParentId="4389" CreationDate="2020-06-16T16:32:38.247" Score="1" Body="&lt;p&gt;First assumption:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume that &lt;em&gt;Socmin(t)&lt;/em&gt; and &lt;em&gt;Socmax(t)&lt;/em&gt; are time-dependent parameters of the model. Define the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall t \in model.Time \quad model.idle(t) =  \begin{cases} 0 &amp;amp; \text{if not iodle}\\ 1 &amp;amp; \text{if idle} \end{cases}$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then add the following constraints to the model(it can be easily done by using the constraints list concept in Pyomo):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ Socmin(t) \times (avail-idle) \leq Soc(t) \leq Socmax(t) \times avail$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ idle(t) \leq avail(t) \ \ \forall t \in model.time$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second assumption:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume that &lt;span class=&quot;math-container&quot;&gt;$\forall t \in model.Time \ \ \exists \ \ Soc(t)$&lt;/span&gt;, which is a parameter and then &lt;em&gt;Socmin(t)&lt;/em&gt; and &lt;em&gt;Socmax(t)&lt;/em&gt; are variables:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ Socmax(t) = Soc(t) \times avail$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ Soc(t) \times (avail-idle) \leq Socmin(t) \leq Soc(t) \times avail$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$idle(t) \leq avail(t) \ \ \forall t \in model.time$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;model.cons = ConstraintList()&#xA;for t in model.Time:&#xA;    model.cons.add('Your Constraints')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-06-16T16:32:38.247" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4391" PostTypeId="1" CreationDate="2020-06-16T18:15:19.060" Score="2" ViewCount="62" Body="&lt;p&gt;I'm researching a subject of balancing the load between two black-box systems (with some twists). I thought that I could record latest response time log from each of those systems and process such a log to dynamically make decisions on how to balance the load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. if we start with system A handling 100% of the current load with 100ms 90p latency from some recent time window and the load grows so the latency grows to 150ms we should make a decision to duplicate some of those requests to system B so it warms up and eventually spread the load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I don't really know where to start in looking for suitable algorithms that I could modify to suit this problem. I'd rather avoid ML, but I'm sure there are some other solutions to this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you could point me to some algorithms or even keywords to further research it'd be great. Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: I've looked at Markov Decision Process but it seems that it's not suited to problems where effects of an action depend not only on the current state, but also on history. Unless there would be a way to model some recent history window as a single state...&lt;/p&gt;&#xA;" OwnerUserId="3747" LastActivityDate="2020-06-16T18:15:19.060" Title="Decision-making algorithm for dynamic load balancing" Tags="|optimization|algorithms|stochastic-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4392" PostTypeId="1" CreationDate="2020-06-16T20:38:14.410" Score="7" ViewCount="164" Body="&lt;p&gt;There are many modeling languages and APIs around. One or more per solver, plus many that target multiple solvers: AMPL, GAMS, PuLP, JuMP, Pyomo...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Among all these possibilities, why did you pick a given modeling tool? Which criteria did you apply? In general, which features do you like to have?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Possible factors&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Some of the reasons I can think of:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;More user friendly language or API&lt;/li&gt;&#xA;&lt;li&gt;Independence from the underlying solver&lt;/li&gt;&#xA;&lt;li&gt;Commercial support, price&lt;/li&gt;&#xA;&lt;li&gt;Better interface to your programming language and datasources&lt;/li&gt;&#xA;&lt;li&gt;Availability of analysis and visualization tools&lt;/li&gt;&#xA;&lt;li&gt;Reformulation features (linearization, branch-and-price, ...), or abstraction around a barebone solver (automated differentiation, ...)&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In my personal experience, for example, ease of integration with the existing environment has often been a determining factor to pick the underlying optimization software.&#xA;But there are so many different situations in OR that a single point of view is quite anecdotal. So, what is your opinion?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Context&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I am writing a modeling API. Although the overall architecture is built to suit my needs - concrete modeling with simple reformulations, multi-solver and multi-language - I'd like to broaden my view about modelers in general for future developments.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="123" LastEditDate="2020-06-17T07:11:39.740" LastActivityDate="2020-06-17T07:11:39.740" Title="Modelers and modeling languages: how do you choose, and which features do you use?" Tags="|modeling-languages|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4393" PostTypeId="2" ParentId="4325" CreationDate="2020-06-17T09:54:44.083" Score="5" Body="&lt;p&gt;First of all, if they want to offer you a job it is because they see value in what you are doing, well done!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are the only one with your background it is important that you see yourself as your own &quot;project manager&quot;, which requires you to build additional skills besides the pure OR skills. Those skills will also be very valuable for you to create value using OR in the future. I will focus on the part in your question around handling the complexity of OR. &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Communicate the risk&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Operations Research work is more &quot;riskier&quot; than most web development, which also makes it different to manage. There are more uncertainties which makes it more difficult to make estimates and plan further out in time. You should identify and communicate what the current risks in your project are.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Computational risk&lt;/strong&gt;: You add something to the model that significantly influences the computation time in a way that would make the tool unusable and you need to find a way to speed it up. &lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Problem risk&lt;/strong&gt;: Are you solving the right problem, so the solutions are valuable for the users. For example, if you add a new constraint you need to understand if that always is the case that this constraint is valid, or there are situations where you want to violate it.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Value risk&lt;/strong&gt;: Will the solution create the value expected. Can the customer capture the value, and will the solution fit into their current decision processes.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Mitigate the risk&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;When you have identified the risks you also need to show a clear plan on how you are mitigating it and ongoingly communicate how you will spend your time. Having a &quot;roadmap&quot; that is aligned with your stakeholders will help you create buy-in and avoid having to answer again and again when they can expect some work to be done.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;De-risking&lt;/strong&gt;: See how you can remove the risks by diving further into the problem. It could be building a proof of concept (POC) of a new addition to the model, conducting user interviews, or talking to experts.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Research vs. development:&lt;/strong&gt; Be explicit around when you are de-risking and exploring if something will work, vs. making code production-ready and doing more standard development work such as reading data or coding a front-end. When you have a task around adding a new constraint, you can split it a task around understanding the implications on the model e.g. building a proof-of-concept, and another task of making it production-ready, adding unit-tests, etc. It can be difficult to estimate the research work, but you should be able to create good estimates of the remaining work.     &lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Proactively communicate delays in a roadmap:&lt;/strong&gt; If a task grows, you should communicate as early as possible. If you have highlighted the risks upfront this will also be easier. When there is a delay you will need to postpone other tasks, and you should ensure to align the priorities with your stakeholders so you have buy-in.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Finally, I would suggest trying to find some internal project managers who can support you in how to deal with your stakeholders and communicate around the work you are doing. You might also be able to create some interesting analyses along the way that will create value for your company or its customers. Having some of these &quot;wins&quot; along the way can help you create momentum and an understanding of the value you are bringing. Best of luck!&lt;/p&gt;&#xA;" OwnerUserId="140" LastEditorUserId="36" LastEditDate="2020-06-17T12:42:49.743" LastActivityDate="2020-06-17T12:42:49.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4394" PostTypeId="1" AcceptedAnswerId="4397" CreationDate="2020-06-17T11:26:40.337" Score="2" ViewCount="317" Body="&lt;p&gt;I am working on an optimisation problem that involves minimising shipping demurrage. I am struggling to model how to represent the difference, (x-y) between dates where the ship &lt;strong&gt;is ready to be loaded&lt;/strong&gt; and when the ship is &lt;strong&gt;actually loaded&lt;/strong&gt;. This difference, in days, is where demurrage charges are incurred (if applicable).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;How can I calculate this difference in pulp and model the 'vessel_ready_to_load' date vs the 'vessel_start_load' date?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Code below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;planning_horizon_dates ['2020-01-01', '2020-01-02', '2020-01-03']&#xA;&#xA;# Port inventory&#xA;port_stock_inventory = {&#xA;    'RBL': {'current': 200000, &#xA;            'target': 180000, # Note targets are set by separate opt.&#xA;            'max': 200000}, &#xA;    'RB2': {'current': 200000, &#xA;            'target': 180000, &#xA;            'max': 200000},&#xA;    'PRE': {'current': 200000, &#xA;            'target': 180000, &#xA;            'max': 200000},&#xA;    'AFL': {'current': 200000,&#xA;            'target': 180000,&#xA;            'max': 200000},&#xA;    'ACA': {'current': 200000,&#xA;            'target': 180000,&#xA;            'max': 200000}}&#xA;&#xA;sales_demand_by_vessel ={&#xA;    '2020-01-01': {&#xA;        'CEYLON': {&#xA;            'MAF': 0, 'PRE': 40000, 'ZBL': 0, 'AFE': 10000, 'AAC': 70000&#xA;            },&#xA;        'KONOS': {&#xA;            'MAF': 0, 'PRE': 100000, 'ZBL': 0, 'AFE': 0, 'AAC': 0&#xA;            },&#xA;        'BULK JAPAN': {&#xA;            'MAF': 30000, 'PRE': 0, 'ZBL': 70000, 'AFE': 0, 'AAC': 0&#xA;            },&#xA;        'XIN FA HAI': {&#xA;            'MAF': 0, 'PRE': 0, 'ZBL': 9000, 'AFE': 20000, 'AAC': 0&#xA;        }&#xA;    },&#xA;    '2020-01-02': {&#xA;        'PACIFIC MAJOR': {&#xA;            'MAF': 50000, 'PRE': 0, 'ZBL': 60000, 'AFE': 10000, 'AAC': 0&#xA;            },&#xA;        'CCSC YASA JING': {&#xA;            'MAF': 10000, 'PRE': 0, 'ZBL': 0, 'AFE': 0, 'AAC': 60000&#xA;            },&#xA;        'XIAOMING HAO HAI': {&#xA;            'MAF': 30000, 'PRE': 0, 'ZBL': 70000, 'AFE': 0, 'AAC': 0&#xA;            },&#xA;        'ROBUSTA': {&#xA;            'MAF': 0, 'PRE': 0, 'ZBL': 0, 'AFE': 50000, 'AAC': 0&#xA;        }&#xA;    },&#xA;    '2020-01-03': {&#xA;        'AQUA': {&#xA;            'MAF': 0, 'PRE': 0, 'ZBL': 0, 'AFE': 10000, 'AAC': 70000&#xA;            },&#xA;        'ARUN': {&#xA;            'MAF': 0, 'PRE': 0, 'ZBL': 50000, 'AFE': 0, 'AAC': 0&#xA;            },&#xA;        'HARALL': {&#xA;            'MAF': 30000, 'PRE': 0, 'ZBL': 70000, 'AFE': 0, 'AAC': 0&#xA;            },&#xA;        'MAMBO': {&#xA;            'MAF': 0, 'PRE': 0, 'ZBL': 9000, 'AFE': 20000, 'AAC': 0&#xA;        }&#xA;    },&#xA;}&#xA;&#xA;&#xA;# DECISION VARIABLES&#xA;&#xA;# Binary indicators for all possible vessel load dates after NOR date.&#xA;vessel_load_start_date = pulp.LpVariable.dicts(&#xA;    'Vessel Load Start Date', &#xA;    ((vessel, date) for vessel, date in load_start_dates.index),&#xA;    lowBound=0, &#xA;    cat='Binary')&#xA;&#xA;# Vessel Sales Demand&#xA;vessel_sales_demand_vars = pulp.LpVariable.dicts(&#xA;    'Vessel Sales Complete',&#xA;    ((vessel, product, date) for product in products for vessel, date in load_start_dates.index),&#xA;    lowBound=0,&#xA;    cat='Continuous'&#xA;)&#xA;&#xA;# Vessel grade requirements&#xA;vessel_product_requirements = pulp.LpVariable.dicts(&#xA;    &amp;quot;Vessel-Grade Requirement Tonnes&amp;quot;, &#xA;    ((vessel, product) for vessel in vessels for product in products),&#xA;    lowBound=0, &#xA;    cat='Continuous')&#xA;&#xA;# Model&#xA;model = pulp.LpProblem('Demurrage Optimisation', pulp.LpMinimize)&#xA;&#xA;&#xA;# Objective Function&#xA;model += pulp.lpSum([&#xA;    demurrage_charge_vars[vessel]&#xA;    for vessel in demurrage_charge_vars])&#xA;&#xA;# Vessel can ONLY begin loading if there is sufficient supply of each product&#xA;for vessel in vessels:&#xA;  model += port_inventory[date][product] &amp;gt;= sales_demand_by_vessel[date][vessel][product] == &#xA;  load_start_date[vessel]&#xA;&#xA;# Vessel loading can only on or after notification of readiness&#xA;for vessel in vessels:&#xA;  model += load_start_date[vessel] &amp;gt;= readiness_date_dict[vessel]&#xA;  model += load_start_date_dict[vessel] - readiness_date_dict[vessel]  * daily_dem_rate == demurrage_charge_vars[date][vessel]&#xA;&#xA;&#xA;# Control vessel loading&#xA;for product in products:&#xA;  for vessel, date in vessel_load_start_date:&#xA;    vessel_sales_demand_vars[(vessel, product, date)] - vessel_product_requirements[vessel, product] * load_start_date[vessel, date] &amp;lt;= 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Any help very gratefully received!&lt;/p&gt;&#xA;" OwnerUserId="3395" LastEditorUserId="3395" LastEditDate="2020-06-19T18:09:58.957" LastActivityDate="2020-06-19T18:09:58.957" Title="Representing Date Variables in Pulp" Tags="|optimization|mixed-integer-programming|linear-programming|python|pulp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4395" PostTypeId="1" AcceptedAnswerId="4408" CreationDate="2020-06-17T20:22:01.903" Score="1" ViewCount="314" Body="&lt;p&gt;I have a centralized optimization problem for a residential area in the context of a smart grid and load flexibility. So let's say I have 10 buildings and each of them has an electric heating device. Further each building has a photovoltaic PV system that generates renewable energy. Now the goal of the centralized optimization problem is to schedule the heating activities of all buildings such that the overall usage of the total reneable energy (sum of all the PV generation of all buildings) is maximized.&lt;/p&gt;&#xA;&lt;p&gt;Basically every building has 24 decision variables (one for each hour): x_1, ..., x_24&#xA;The quantiy the (continious) power consumption of the electric heating device in each hour. Of course we also have some thermal constraints for the room temperature such that it is not possible to heat with full power during all hours. Moreover, each building has a PV generation that is given exogeneously meaning that this is a parameter: PV_1, ..., PV_24&lt;/p&gt;&#xA;&lt;p&gt;So the goal of the centralized optimizer is to choose x_1, ..., x_24 for all 10 buildings such that the PV self consumption rate, is maximized. The total electrical power P_total for the residential area for one timeslot is just the sum of the x_1s, ..., x_24s for all buildings. The same is valid for the total PV generation PV_total of the residential area. Now we want to minimize the sum of PV_total - P_total over all 24 hours of the day (this maximizes the self-consumption rate of PV).&lt;/p&gt;&#xA;&lt;p&gt;I hope you have understood the basics of this problem (if not I can give you more information). My fundamental question now is, whether I can use one of the following decomposition methods to transform this centralized large optimization problem into distributed smaller problems that could be solved by the buildings themselves. Basically I would like to know if I can use one of these methods:&lt;/p&gt;&#xA;&lt;p&gt;ADMM: Alternating methods of multipliers&lt;/p&gt;&#xA;&lt;p&gt;Dual decomposition&lt;/p&gt;&#xA;&lt;p&gt;Dantzig-Wolfe decomposition&lt;/p&gt;&#xA;&lt;p&gt;Benders decomposition&lt;/p&gt;&#xA;&lt;p&gt;I'd appreciate every comment.&lt;/p&gt;&#xA;&lt;p&gt;Update: Here is the complete optimization problem&lt;a href=&quot;https://i.stack.imgur.com/PFz3J.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PFz3J.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;x_t_b and y_t_b are the decision variables for all timeslots t and all buildings b. The objective is to minimize the surplus power in the residential area. The surplus power is calculated by subtracting the total electrical deamand of the area from the total PV geneartion. But only the positive surplus power should be minimized. I use the Big-M approach to incorporate this into the model with the two big M parameters and an auxillary binary variable h^positive. I have two thermal storage systems (modelled by T^UFH and V^DHWuse) which have upper and lower limits. x_t_b is the decision variable for heating up the T^UFH_b and y_t_b the decision variables for heating up the V^DHWuse_b. Only on of them can be heated up at one time slot. To model this I use a binary auxilliary variable h^Aux for each building and each time slot. The total demand P^total comprises the electrical demand of the heat pumps and the inflexible demand P^Demand that is a parameter.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2020-06-18T17:26:55.880" LastActivityDate="2020-06-28T05:52:52.153" Title="Can I apply decomposition methods for this scheduling problem" Tags="|scheduling|benders-decomposition|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="4396" PostTypeId="1" AcceptedAnswerId="4398" CreationDate="2020-06-17T22:42:09.537" Score="4" ViewCount="132" Body="&lt;p&gt;A manufacturing company from Eastern Finland will have to decide on the machines to use in order to produce 2800 units of a given item. Each machine has some given characteristics: a setup cost if it is used, a cost per produced unit and a maximum number of units which can be produced.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{cccc}  \hline&#xA;    \text{Machine} &amp;amp; \text{Setup cost} &amp;amp; \text{Cost per unit} &amp;amp; \text{Maximum production (in pieces)}\\ \hline&#xA;    1       &amp;amp; 500        &amp;amp; 2.00          &amp;amp; 1500 \\&#xA;    2       &amp;amp; 800        &amp;amp; 0.50          &amp;amp; 1200 \\&#xA;    3       &amp;amp; 200        &amp;amp; 3.00          &amp;amp; 800 \\&#xA;    4       &amp;amp; 50         &amp;amp; 5.00          &amp;amp; \text{unbounded}\\\hline                   &#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Moreover, given the lack of operators, at most three machines can be chosen. Now how can I formulate an optimization problem to determine how many units each machine should produce to minimize the total cost?&lt;/p&gt;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="3752" LastEditorUserId="3752" LastEditDate="2020-06-20T13:49:40.813" LastActivityDate="2020-06-20T13:49:40.813" Title="Formulation of Machine allocation as an optimization problem" Tags="|modeling|integer-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4397" PostTypeId="2" ParentId="4394" CreationDate="2020-06-17T22:53:34.657" Score="4" Body="&lt;p&gt;You don't want to create a variable representing a date in pulp. You want to utilize zero-one indicator variables for each option. In this case your options are the vessel-date combinations. Index the variables by vessel and date.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose the value of the difference between the &lt;strong&gt;actually loaded date&lt;/strong&gt; and the &lt;strong&gt;ready to be loaded date&lt;/strong&gt; is to be used in the objective or a constraint. Then you need to determine the possible set of dates &lt;span class=&quot;math-container&quot;&gt;$T_i$&lt;/span&gt; each vessel &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; can be finally loaded and create indicator variables &lt;span class=&quot;math-container&quot;&gt;$y_{it}$&lt;/span&gt; for each possibility. Utilize the constraint set &lt;span class=&quot;math-container&quot;&gt;$x_{ijt} - c_{ij}y_{it} &amp;lt;= 0 \space \forall \space i\in V,\space j\in P,\space t\in T_i$&lt;/span&gt; to indicate that a vessel &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is finally loaded with &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; quantity of product &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on a particular day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. This gives you the ability to restrict loading to particular days or to calculate charges based on options for loading through the use of the variables &lt;span class=&quot;math-container&quot;&gt;$y_{it}$&lt;/span&gt; and control the port inventory through the variables &lt;span class=&quot;math-container&quot;&gt;$x_{ijt}$&lt;/span&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the total demurrage charge, instead of an expression like &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in V} c_i t_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; is the daily demurrage charge and &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt; is the number of days of demurrage, you have &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in V, t\in T_i}c_{it}y_{it}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c_{it}$&lt;/span&gt; is the charge if vessel &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; days of demurrage and &lt;span class=&quot;math-container&quot;&gt;$y_{it}=1$&lt;/span&gt; indicates the outcome of the finally loaded date.&lt;/p&gt;&#xA;" OwnerUserId="61" LastActivityDate="2020-06-17T22:53:34.657" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="4398" PostTypeId="2" ParentId="4396" CreationDate="2020-06-17T23:09:13.820" Score="3" Body="&lt;p&gt;Your &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; constraint should just be &lt;span class=&quot;math-container&quot;&gt;$x_1+x_2+x_3+x_4 \ge 2800$&lt;/span&gt;.  The maximum production values are upper bounds, like &lt;span class=&quot;math-container&quot;&gt;$x_1 \le 1500$&lt;/span&gt;.  You have also not accounted for the setup costs, and for that purpose (and to enforce the &quot;at most three machines&quot; rule) you might find it useful to introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; to indicate whether &lt;span class=&quot;math-container&quot;&gt;$x_j &amp;gt; 0$&lt;/span&gt;.  For example, &lt;span class=&quot;math-container&quot;&gt;$x_1 \le 1500 y_1$&lt;/span&gt; enforces the implication &lt;span class=&quot;math-container&quot;&gt;$x_1&amp;gt;0 \implies y_1=1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-06-18T02:07:46.590" LastActivityDate="2020-06-18T02:07:46.590" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4399" PostTypeId="1" AcceptedAnswerId="4400" CreationDate="2020-06-17T23:26:55.153" Score="2" ViewCount="172" Body="&lt;p&gt;In the anti-tumor treatment with radiotherapy, it is possible to irradiate the tumoral mass from different positions with different intensities. For each of these possibilities, however, one has to take into account the harmful side effects that the treatment causes to the adjacent organs.&#xA;Suppose you have a discrete set of positions from which the tumor can be irradiated and want to decide with what level of intensity to irradiate the tumor from each position. You must consider a number of adjacent organs to preserve and for every possible position you have&#xA;the data expressing the percentage of radiation that would affect the tumor and the percentage of radiation that would strike each of the adjacent organs. In fact, the following table shows the percentage of radiation going from each position (on the columns) to the tumor and to the adjacent organs (on the rows).&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{cccccc} \hline&#xA;&amp;amp; 1&amp;amp; 2&amp;amp;3&amp;amp;4&amp;amp;5 \\ \hline&#xA; \text{Tumor}   &amp;amp; 0.4 &amp;amp; 0.3 &amp;amp; 0.25 &amp;amp; 0.7 &amp;amp; 0.5 \\ &#xA;    \text{Organ 1} &amp;amp; 0.1 &amp;amp; 0   &amp;amp; 0    &amp;amp; 0.1 &amp;amp; 0.2 \\&#xA;    \text{Organ 2} &amp;amp; 0.1 &amp;amp; 0   &amp;amp; 0.15 &amp;amp; 0   &amp;amp; 0.1 \\&#xA;    \text{Organ 3} &amp;amp; 0   &amp;amp; 0.1 &amp;amp; 0    &amp;amp; 0   &amp;amp; 0 \\&#xA;    \text{Organ 4} &amp;amp; 0   &amp;amp; 0.2 &amp;amp; 0.1  &amp;amp; 0.1 &amp;amp; 0 \\ \hline&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The intensity of radiation which can be used in the treatment is limited to 60 Gray and there are upper bounds on the quantity of radiations coming from each position as follows&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{cc} \hline&#xA;\text{Position} &amp;amp; \text{Upper limit} \\ \hline&#xA;  1        &amp;amp; 12 \\&#xA;    2        &amp;amp; 13\\&#xA;    3        &amp;amp; 10\\&#xA;    4        &amp;amp; 15\\&#xA;    5        &amp;amp; 15\\ \hline&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You want to maximize the quantity of radiations affecting the tumor but also respect the following tolerance levels for each adjacent organ&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{cc} \hline&#xA;\text{Organ #} &amp;amp; \text{Max Gray per organ} \\ \hline&#xA;  1        &amp;amp; 5.5 \\&#xA;    2        &amp;amp; 9.0\\&#xA;    3        &amp;amp; 6.0\\&#xA;    4        &amp;amp; 2.4\\ \hline&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How to formulate the above problem as a linear optimization problem to find the quantity or radiation which has to be supplied from each position in order to maximize the quantity received by the target tumor, but respecting the limit of radiation per organ?&lt;/p&gt;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="3752" LastEditorUserId="3752" LastEditDate="2020-06-20T14:14:52.853" LastActivityDate="2020-06-20T14:14:52.853" Title="Formulation of assignment problem as Linear Optimization" Tags="|modeling|integer-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4400" PostTypeId="2" ParentId="4399" CreationDate="2020-06-18T02:04:19.147" Score="5" Body="&lt;p&gt;It is not an assignment problem.&lt;/p&gt;&#xA;&lt;p&gt;You get to decide the intensity of each position. Suppose &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; is the intensity from position &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; that you decide to apply, then the quantity of treatment of tumor that we want to maximize is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_y0.4y_1+0.3y_2+0.25y_3+0.7y_4+0.5y_5$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also you need to limit the total intensity, hence &lt;span class=&quot;math-container&quot;&gt;$$\sum_i y_i \le 60$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Exercises left for you:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Also you have to limit the intensity from each angle. I will leave this task to you. For the first treatment. &lt;span class=&quot;math-container&quot;&gt;$y_1 \le 12$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Also, note that we have to consider the tolerance level of each organ. I will also leave this task for you. For the first organ, the constraint is &lt;span class=&quot;math-container&quot;&gt;$0.1y_1+0.1y_4+0.2y_5 \le 5.5.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Don't forget the nonnegative constraint too.&lt;/p&gt;&#xA;" OwnerUserId="85" LastEditorUserId="85" LastEditDate="2020-06-18T10:41:39.027" LastActivityDate="2020-06-18T10:41:39.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4401" PostTypeId="1" CreationDate="2020-06-18T03:47:19.607" Score="5" ViewCount="504" Body="&lt;p&gt;Is it possible to solve VRP using OR-Tools CpModel, instead of RoutingModel? I want to do synchronized VRP, which is combining vehicle routing and scheduling constraints&lt;/p&gt;&#xA;" OwnerUserId="2704" LastEditorUserId="123" LastEditDate="2020-06-18T07:47:07.837" LastActivityDate="2020-06-18T10:42:03.820" Title="Is it possible to solve VRP using OR-Tools CpModel, instead of RoutingModel?" Tags="|scheduling|or-tools|vehicle-routing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4402" PostTypeId="1" AcceptedAnswerId="4404" CreationDate="2020-06-18T09:32:09.173" Score="2" ViewCount="161" Body="&lt;p&gt;Given the table&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|------------|-----------------|-----------------|-----------------|&#xA;| Customers  |    Product A    |   Product B     |   Product C     |&#xA;|------------|-----------------|-----------------|-----------------|&#xA;|    a       |       1.0       |       0.7       |       0.2       |&#xA;|------------|-----------------|-----------------|-----------------|&#xA;|    b       |       0.3       |       0.7       |       0.8       |&#xA;|------------|-----------------|-----------------|-----------------|&#xA;|    c       |       0.9       |       0.9       |       0.9       |&#xA;|------------|-----------------|-----------------|-----------------|&#xA;|    d       |       0.7       |       0.2       |       0.2       |&#xA;|------------|-----------------|-----------------|-----------------|&#xA;|    e       |       0.3       |       0.5       |       0.4       |&#xA;|------------|-----------------|-----------------|-----------------|&#xA;|    f       |       0.5       |       1.0       |       1.0       |&#xA;|------------|-----------------|-----------------|-----------------|&#xA;|    g       |       0.2       |       0.2       |       0.4       |&#xA;|------------|-----------------|-----------------|-----------------|&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;each customer's row contains the probability of purchasing the specific product.&lt;/p&gt;&#xA;&lt;p&gt;I would like contact the least number of customers and achieving some (expected) number of sales for products A, B and C.&lt;/p&gt;&#xA;&lt;p&gt;For example: given the table and the following requests&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Target for Product A: 1&lt;/li&gt;&#xA;&lt;li&gt;Target for Product B: 1&lt;/li&gt;&#xA;&lt;li&gt;Target for Product C: 2&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;would lead to the following solution:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a -&amp;gt; Product A&lt;/li&gt;&#xA;&lt;li&gt;f -&amp;gt; Product B&lt;/li&gt;&#xA;&lt;li&gt;b, c, e -&amp;gt; Product C&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;so that out of 7 customers I could select just 5 of them and achieving the (expected) sales.&lt;/p&gt;&#xA;&lt;p&gt;With several thousand of customers and more products the standard tools (I mainly used PuLP library) demand way too much time.&lt;/p&gt;&#xA;&lt;p&gt;So my question is: given the special form of the problem are there faster algorithms for solving it or ways of solving the problem more efficiently?&lt;/p&gt;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="3733" LastEditorUserId="3733" LastEditDate="2020-06-18T14:32:46.623" LastActivityDate="2020-06-18T14:32:46.623" Title="A more efficient way of solving an peculiar optimization problem" Tags="|optimization|linear-programming|set-covering|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4403" PostTypeId="1" CreationDate="2020-06-18T09:51:25.783" Score="10" ViewCount="178" Body="&lt;p&gt;I have seen this question &lt;a href=&quot;https://or.stackexchange.com/questions/168/how-to-avoid-having-your-optimization-models-rusting&quot;&gt;How to avoid having your optimization models rusting?&lt;/a&gt;, which is kind of related, but I am more curious about the actual monitoring and the initial design of the software in order to be able to find bugs/problems in a production environment.&lt;/p&gt;&#xA;&lt;p&gt;Assume you have a software running in production (so it is running without your interaction on a server/ or at the user), which is built on top of MIP solver (i.e. Gurobi,...). What kind of data do you collect and at what point in order to be able to:&lt;/p&gt;&#xA;&lt;p&gt;a) identify critical instances (like numerical troubles) or when it is difficult to solve in general, or models become infeasible if they should not, or there is a bug in the solver itself?&lt;/p&gt;&#xA;&lt;p&gt;b) debug your model afterwards?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Some thoughts:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;It might be useful to always save the log file to a database and build statistics about the average runtime or grep for numerical troubles lines in the log and send like an alert or monitor the database from time to time. In order to debug the problem one needs in general at least an lp-file or better all the data that went into the model. This is kind of memory sensitive, because you can not write an lp file every time the application is running. If one wants the raw data that went into the model one needs to write an intermediate layer between the database (at the user) and your optimization model in order to be able to write down the data to the memory.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="2599" LastEditDate="2020-06-19T15:31:03.570" LastActivityDate="2020-06-19T15:31:03.570" Title="How to monitor/debug an optimization model in a production environment professionally?" Tags="|software|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4404" PostTypeId="2" ParentId="4402" CreationDate="2020-06-18T10:26:35.100" Score="4" Body="&lt;p&gt;This problem is actually not an assignment problem but a set covering problem.&lt;/p&gt;&#xA;&lt;p&gt;Let's say that choosing customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is represented by &lt;span class=&quot;math-container&quot;&gt;$x_i=1$&lt;/span&gt; when chosen, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&#xA;Let's say &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt; are the sales targets for your products and &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; is the &amp;quot;demand&amp;quot; or probability to sell product &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min&amp;amp;\quad\sum_i x_i \\&#xA;\text{s.t.}&amp;amp;\quad \sum_i d_{ij} x_i \geq s_j \quad\forall j\\&#xA;&amp;amp;\quad x_i\in\{0,1\} \quad\forall i&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective tells us you want to minimize the customers you contact. The last line tells us that you can either contact or not contact a customer, but you cannot contact them 50%. The middle constraint tells us, that the sum of the probabilities of buying of the contacted customers are at least your sales targets.&lt;/p&gt;&#xA;&lt;p&gt;This problem is NP-hard. (Choose &lt;span class=&quot;math-container&quot;&gt;$s_j = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_{ij} \in \{0,1\}$&lt;/span&gt; for a reduction to set covering.) It is therefore not a transportation problem, cannot be solved with the simplex algorithm because of the last condition, and any polynomial time algorithm is unlikely to exist. However, any MIP solver (CPLEX, Gurobi, SCIP) can handle even large instances of any set covering problem.&lt;/p&gt;&#xA;&lt;p&gt;It is NP-hard to approximate with a factor better than &lt;span class=&quot;math-container&quot;&gt;$\mathcal O(\log n)$&lt;/span&gt;. There is an easy greedy algorithm that achieves that ratio:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Start with an empty solution and add customers one by one until your sales targets are satisfied. Always pick the customer that covers the most uncovered demands.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Given the demands &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt; you already have for each product, the uncovered demand for a customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; can be computed by &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_j \max\{\min\{d_{ij}, s_j\}-p_j,0\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2020-06-18T13:17:05.120" LastActivityDate="2020-06-18T13:17:05.120" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4405" PostTypeId="2" ParentId="4401" CreationDate="2020-06-18T10:42:03.820" Score="4" Body="&lt;p&gt;The answer is yes. Is it worthwhile ? it depends.&lt;/p&gt;&#xA;&lt;p&gt;If you just want to have two persons visit the same virtual place (2 duplicated nodes) at the same time, you can force the time cumul var to be equal when using the routing library.&lt;/p&gt;&#xA;&lt;p&gt;This will probably more efficient than the CP-SAT VRP code as the routing library is highly tuned.&lt;/p&gt;&#xA;&lt;p&gt;If you want more complex constraints, you can try CP-SAT.&#xA;You can look at ortools/constraint_solver/routing_sat.cc to get some ideas.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2020-06-18T10:42:03.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4406" PostTypeId="1" CreationDate="2020-06-18T11:32:13.513" Score="7" ViewCount="116" Body="&lt;p&gt;I have a standard CVRPTW (capacitated vehicle routing problem with time windows). The instance is given by a (not complete) graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; with weighted &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; directed edges &lt;span class=&quot;math-container&quot;&gt;$e \in E$&lt;/span&gt;, and I have a limited number of vehicles &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; with a capacity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and costumers &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; with demands &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; and time windows &lt;span class=&quot;math-container&quot;&gt;$[t_i^l,t_i^u]$&lt;/span&gt; where they are able to be serviced at some nodes of the graph &lt;span class=&quot;math-container&quot;&gt;$c_i\in V(G)$&lt;/span&gt;. I want to visit all customers with tours not exceeding the capacity in demand and minimize the total distance travelled.&#xA;So far this is a well known problem.&lt;/p&gt;&#xA;&lt;p&gt;THE NEW CONSTRAINT: in my situation this is all on company premises and there are many roads that have only one lane or that are dead ends. So there might be a situation where multiple cars take the same one lane road in opposite directions at the same time and then they black each other.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to deal with this or similar constraints, where the vehicles might interfere with each other? (I know, I could make one lane roads directed and contract dead ends and make them into one customer, but that is not what I want to do.)&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2020-06-18T13:17:50.880" LastActivityDate="2020-06-19T09:11:23.560" Title="CVRP with vehicles blocking each other" Tags="|modeling|scheduling|vehicle-routing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4407" PostTypeId="2" ParentId="4406" CreationDate="2020-06-18T13:57:07.917" Score="5" Body="&lt;p&gt;These constraints should be treated in a &amp;quot;dynamic fashion&amp;quot;. First you ignore them. Then you check whether your solution satisfies them or not (possibly some timing in your solution should be changed without changing routes themselves). I suppose that most of the time these constraints will be satisfied. If not, you need to find a minimal subset of arcs in your solution which are &amp;quot;responsible&amp;quot; for the conflict with the additional constraints. Then you add the constraint that at least one of these arcs should not participate in the solution (constraints of this kind are called &amp;quot;no-good&amp;quot; in the literature).&lt;/p&gt;&#xA;" OwnerUserId="835" LastEditorUserId="123" LastEditDate="2020-06-19T09:11:23.560" LastActivityDate="2020-06-19T09:11:23.560" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4408" PostTypeId="2" ParentId="4395" CreationDate="2020-06-18T20:32:17.047" Score="5" Body="&lt;p&gt;Thank you for adding the formulation.  Assuming &lt;span class=&quot;math-container&quot;&gt;$\Delta t$&lt;/span&gt; is a nonnegative coefficient, you can simplify the formulation by omitting &lt;span class=&quot;math-container&quot;&gt;$h_t^\text{positive}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$P_t^{\text{Surplus}^-}$&lt;/span&gt;, and the associated constraints.  Instead, you need only impose&#xA;&lt;span class=&quot;math-container&quot;&gt;$$P_t^{\text{Surplus}^+} \ge P_t^\text{PVtotal} - P_t^\text{total} \quad \text{for all $t$} \tag 1$$&lt;/span&gt;&#xA;to get the desired behavior of minimizing the positive surplus.&lt;/p&gt;&#xA;&lt;p&gt;It looks like you still need some constraints to enforce the relationships between &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; and the rest of the model.  Currently, &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; appear by themselves.&lt;/p&gt;&#xA;&lt;p&gt;If you substitute the expressions for &lt;span class=&quot;math-container&quot;&gt;$P_t^\text{PVtotal}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_t^\text{total}$&lt;/span&gt; (or use implicit/defined variables) and treat &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; as the linking/complicating constraints, the rest of the problem decomposes by building, so you might benefit from applying Dantzig-Wolfe decomposition with one block per building.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Update to answer your additional questions:&lt;/p&gt;&#xA;&lt;p&gt;By substitution, I meant replacing &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$P_t^{\text{Surplus}^+} \ge \sum_{b=1}^B P_{t,b}^\text{PV} - \sum_{b=1}^B \left((x_{t,b}+y_{t,b})P_b^\text{HPmax}+P_{t,b}^\text{Demand}\right) \quad \text{for all $t$} \tag{1$'$}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To treat &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$(1')$&lt;/span&gt; as linking constraints, some automated Dantzig-Wolfe implementations allow you to specify the block-angular structure by using constraint attributes.  For example, see &lt;a href=&quot;https://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetVersion=15.1&amp;amp;docsetTarget=ormpug_decomp_gettingstarted.htm&amp;amp;locale=en&quot; rel=&quot;nofollow noreferrer&quot;&gt;this Getting Started example&lt;/a&gt; from the SAS documentation.&lt;/p&gt;&#xA;&lt;p&gt;Dantzig-Wolfe decomposition applies when you have a set of linking/complicating constraints whose omission makes the resulting problem much easier.&#xA;In contrast, Benders decomposition applies when you have a set of linking/complicating variables such that fixing the values of these variables makes the problem much easier.  In principle, either decomposition algorithm can be used for any subset you choose, but the best performance is obtained when your problem has some structure where only a small percentage of constraints or variables are complicating.  The Dantzig-Wolfe decomposition I suggested seems the most natural for your problem, and it matches your intuition of wanting to solve the buildings separately.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-06-21T15:42:20.563" LastActivityDate="2020-06-21T15:42:20.563" CommentCount="19" ContentLicense="CC BY-SA 4.0" />
  <row Id="4409" PostTypeId="1" AcceptedAnswerId="4420" CreationDate="2020-06-19T07:00:18.467" Score="5" ViewCount="313" Body="&lt;p&gt;Given the following problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} &#xA;&amp;amp; z=\min \sum_{ij} x_{ij}\\&#xA;\text{s.t.} &amp;amp; \quad \sum_i d_{ij} x_{ij} \ge s_j, \quad \forall j \tag1 \\&#xA;&amp;amp; \quad \sum_j x_{ij} \le 1, \quad \forall i \tag2 \\&#xA;&amp;amp; \quad x_{ij} \in \left\{0, 1\right\}, \quad \forall i,j \tag3 \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with known &lt;span class=&quot;math-container&quot;&gt;$d_{ij}, s_j$&lt;/span&gt;, is there an algorithm that solves it in polinomial time? If not, is there an approximate one?&lt;/p&gt;&#xA;" OwnerUserId="3733" LastEditorUserId="660" LastEditDate="2020-06-19T08:58:58.480" LastActivityDate="2020-06-21T09:39:39.537" Title="Polynomial algorithm for a special ILP problem" Tags="|linear-programming|computational-complexity|set-covering|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4410" PostTypeId="1" CreationDate="2020-06-19T10:32:22.387" Score="0" ViewCount="99" Body="&lt;p&gt;The specific linear programme has an optimal solution as &lt;span class=&quot;math-container&quot;&gt;$x_1 = 0.66$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_2 = 1.33$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_3 = 12.2$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_4 = 0.0$&lt;/span&gt; and the objective value is &lt;span class=&quot;math-container&quot;&gt;$33.3$&lt;/span&gt;. While the problem is solved by D-W decomposition method, in the specific iteration (defining two sub-problems in which, &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; are defined in the first and the rest are in the second), reduced cost of the second sub-problem is zero and the first has a negative reduced cost.&lt;/p&gt;&#xA;&lt;p&gt;When we add columns based on the reduced cost, the objective value of the master problem will be &lt;span class=&quot;math-container&quot;&gt;$33.3$&lt;/span&gt; and convergence has been attained. The solutions of the problem by using D-W are &lt;span class=&quot;math-container&quot;&gt;$x_1 = 0.66$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_2 = 1.33$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_3 = 8$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_4 = 0.0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The small example of the problem is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\begin{array}{rrrrrr}&#xA;\text { Minimize } &amp;amp; -x_{1} &amp;amp; - &amp;amp; 2 x_{2} &amp;amp; +3 x_{3} &amp;amp; +x_{4} &amp;amp; \\&#xA;\text { subject to } &amp;amp; x_{1} &amp;amp; + &amp;amp; 2 x_{2} &amp;amp; +3 x_{3} &amp;amp; +x_{4} &amp;amp; \geq 40 \\&#xA;&amp;amp; x_{1} &amp;amp; + &amp;amp; x_{2} &amp;amp; &amp;amp; &amp;amp; \leq 2 \\&#xA;&amp;amp; -x_{1} &amp;amp; + &amp;amp; 2 x_{2} &amp;amp; &amp;amp; &amp;amp; \leq 2 \\&#xA;&amp;amp; &amp;amp; &amp;amp; x_{3} &amp;amp; + &amp;amp; x_{4} &amp;amp; \geq 8 \\&#xA;&amp;amp; x_{1}, &amp;amp; &amp;amp; x_{2}, &amp;amp; x_{3}, &amp;amp; x_{4} \geq 0&#xA;\end{array}\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm wondering if,&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What is the reason(s) to obtain the different value of the variable &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Is there any specific issue to deal with the sub-problem with zero reduced cost while another has a negative value?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2020-06-19T13:34:47.067" LastActivityDate="2020-06-19T13:34:47.067" Title="How to deal with the sub-problem with zero reduced cost in D-W decomposition" Tags="|optimization|linear-programming|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4411" PostTypeId="2" ParentId="4410" CreationDate="2020-06-19T10:52:09.440" Score="2" Body="&lt;p&gt;It would help to see the entire model (I assume &lt;span class=&quot;math-container&quot;&gt;$c_3=0$&lt;/span&gt;?); when I understand correctly (first question) you have multiple optimal solutions (which happens) and the algorithm needs to iterate until optimality is proven (which apparently was not the case yet). In that sense there is no &amp;quot;reason&amp;quot; for a different value of &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;. Column generation terminates when &lt;strong&gt;all&lt;/strong&gt; subproblems return that their minimum reduced cost is non-negative (second question).&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2020-06-19T10:52:09.440" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4412" PostTypeId="2" ParentId="4409" CreationDate="2020-06-19T11:48:08.940" Score="5" Body="&lt;p&gt;The problem is NP-hard because it can be used to solve the subset-sum problem:&lt;/p&gt;&#xA;&lt;p&gt;Subset-sum: given a set of numbers &lt;span class=&quot;math-container&quot;&gt;$a_k\forall k\in K$&lt;/span&gt; and a special number &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is there a subset of numbers &lt;span class=&quot;math-container&quot;&gt;$K' \subset K$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\sum_ {k\in K'} a_k =b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Reduction: let &lt;span class=&quot;math-container&quot;&gt;$j \in \{1,2\}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$s_1=b$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$d_{k,j} = a_k \forall k,j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s_2=\sum_i a_i - b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I don't know of any approximation algorithms.&lt;/p&gt;&#xA;" OwnerUserId="405" LastActivityDate="2020-06-19T11:48:08.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4413" PostTypeId="1" CreationDate="2020-06-19T12:32:25.067" Score="3" ViewCount="160" Body="&lt;p&gt;The minimizing problem is the following :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \underset{w}{\operatorname{argmin}} \sum_{i=1}^{n}\left[w_{i}\times (\frac{Vw}{\sigma})_{i} - b_{i}\right]^{2}$$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; a &lt;span class=&quot;math-container&quot;&gt;$n\times n$&lt;/span&gt; matrix (covariance matrix) which depends on the vector &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; of size &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; is a scalar which is equal to &lt;span class=&quot;math-container&quot;&gt;$\sigma = \sqrt{w^\top Vw}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,n$&lt;/span&gt;, the quantity &lt;span class=&quot;math-container&quot;&gt;$w_{i}\times\left(\frac{Vw}{\sigma}\right)_{i}$&lt;/span&gt; has a meaning in finance and I want the vector to be as close as possible to the target vector &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. That's why I am minimizing this function.&lt;/p&gt;&#xA;&lt;p&gt;I have a function that uses scipy.minimize to solve this problem and it returns the optimal weights &lt;span class=&quot;math-container&quot;&gt;$\tilde{w}=(w_{i})$&lt;/span&gt; of a portfolio of 500+ stocks. However, some of these weights are very low and I would like the weights &lt;span class=&quot;math-container&quot;&gt;$w_{j}$&lt;/span&gt; that are under a certain thresold &lt;span class=&quot;math-container&quot;&gt;$\rm thr$&lt;/span&gt; to be set to 0.&lt;/p&gt;&#xA;&lt;p&gt;One way to have this would be to run my function, then manually set such weights to 0 with if conditions, and finally rescale the weights so the sum equals one. The problem with this method is that the final vector &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; will not be the optimal vector &lt;span class=&quot;math-container&quot;&gt;$\tilde{w}$&lt;/span&gt; anymore.&lt;/p&gt;&#xA;&lt;p&gt;Do you know any way to minimize a function while having such conditions ?&lt;/p&gt;&#xA;" OwnerUserId="3756" OwnerDisplayName="FredNgu" LastEditorUserId="123" LastEditDate="2020-06-19T14:35:44.260" LastActivityDate="2020-06-19T14:35:44.260" Title="How to optimize with &quot;if&quot; constraints" Tags="|optimization|indicator-constraints|" AnswerCount="1" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4414" PostTypeId="2" ParentId="4413" CreationDate="2020-06-19T13:26:08.307" Score="1" Body="&lt;p&gt;with optimization engines like CPLEX you can model this if with logical constraints:&lt;/p&gt;&#xA;&lt;p&gt;For instance, (x&amp;lt;=2) implies (y&amp;gt;=3) can be written in OPL, which is one of CPLEX APIs&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(x&amp;lt;=2) =&amp;gt; (y&amp;gt;=3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now for your portfolio example if you start with the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.ide.help/examples/html/opl/models/Portfolio/portfolio.mod.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;standard Markowitz example&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;you may easily add if constraints or logical constraints:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{string} Investments = ...;&#xA;float Return[Investments] = ...;&#xA;float Covariance[Investments][Investments] = ...;&#xA;float Wealth = ...;&#xA;float Rho = ...;  // Variance Penalty (increasing rho from 0.001 to 1.0 &#xA;                  //                   produces a distribution of funds &#xA;                  //                   with smaller and smaller variability).&#xA;&#xA;/******************************************************************************&#xA; * MODEL DECLARATIONS&#xA; ******************************************************************************/&#xA;&#xA;range float FloatRange = 0.0..Wealth;&#xA;&#xA;dvar float  Allocation[Investments] in FloatRange;  // Investment Level&#xA;&#xA;&#xA;/******************************************************************************&#xA; * MODEL&#xA; ******************************************************************************/&#xA;&#xA;// Minimal Investment&#xA;float minimalInvestment=0.01;&#xA;// max nb assets&#xA;float nbAssetsMax=5;&#xA;&#xA;&#xA;dexpr float Objective =&#xA;  (sum(i in Investments) Return[i]*Allocation[i])&#xA;    - (Rho/2)*(sum(i,j in Investments) Covariance[i][j]*Allocation[i]*Allocation[j]);&#xA;&#xA;maximize Objective;&#xA;&#xA;subject to {&#xA;  // sum of allocations equals amount to be invested&#xA;  allocate: (sum (i in Investments) (Allocation[i])) == Wealth;&#xA;  &#xA;  sum(i in Investments) (Allocation[i]&amp;gt;=minimalInvestment)&amp;lt;=nbAssetsMax;&#xA;  &#xA;  forall(i in Investments) (Allocation[i]&amp;gt;=minimalInvestment) || (Allocation[i]==0);&#xA;  &#xA;  &#xA;  &#xA;}&#xA;&#xA;tuple AllocationSolutionT{ &#xA;    string Investments; &#xA;    float value; &#xA;};&#xA;{AllocationSolutionT} AllocationSolution = {&amp;lt;i0,Allocation[i0]&amp;gt; | i0 in Investments};&#xA;&#xA;&#xA;float TotalReturn = sum(i in Investments) Return[i]*Allocation[i];&#xA;float TotalVariance = sum(i,j in Investments) Covariance[i][j]*Allocation[i]*Allocation[j];&#xA;&#xA;execute DISPLAY {&#xA;  writeln(&amp;quot;Total Expected Return: &amp;quot;, TotalReturn);&#xA;  writeln(&amp;quot;Total Variance       : &amp;quot;, TotalVariance);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;in particular&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;forall(i in Investments) (Allocation[i]&amp;gt;=minimalInvestment) || (Allocation[i]==0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;makes sure that an allocation is either 0 or more than a minimum level&lt;/p&gt;&#xA;&lt;p&gt;NB:&lt;/p&gt;&#xA;&lt;p&gt;I gave an example in OPL but that 's the same in C, python, java ...&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-06-19T13:26:08.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4415" PostTypeId="1" AcceptedAnswerId="4417" CreationDate="2020-06-19T13:53:43.817" Score="3" ViewCount="388" Body="&lt;p&gt;&lt;strong&gt;Notation:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have an optimisation problem with objective function: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad\sum_n Q_n\\\text{s.t.}&amp;amp;\quad Q_n=x_{ij}^{nk}(y_i^{nk}-c_n), \forall n \in N, k \in K, (i,j) \in P.\end{align}&lt;/span&gt; Decision variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are binary, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is continuous and non-negative, and &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is a constant.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I wish to linearize this objective function. A product term &lt;span class=&quot;math-container&quot;&gt;$xy$&lt;/span&gt; of a binary and continuous variable may be replaced by &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and some additional constraints as is &lt;a href=&quot;https://www.leandro-coelho.com/linearization-product-variables&quot; rel=&quot;nofollow noreferrer&quot;&gt;mentioned here&lt;/a&gt;. The example provided is about a standalone product term. Is this approach still valid in a summation?&lt;/p&gt;&#xA;&lt;p&gt;Assuming it is, I have split the two terms within the sum:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_n Q_n  = \sum_n x_{ij}^{nk}y_i^{nk} - \sum_n x_{ij}^{nk}c_n$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then I applied the approach cited above only to replace product in the first sum with &lt;span class=&quot;math-container&quot;&gt;$$z_n=x_{ij}^{nk}y_i^{nk}, \forall n \in N, k \in K, (i,j) \in P$$&lt;/span&gt; and adding four inequalities of the Big-M method:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2z_n &amp;amp;\geq y_i^{nk}-(1-x_{ij}^{nk})M,\quad &amp;amp;\forall  n \in N, \in K, (i,j) \in P\\z_n &amp;amp;\leq Mx_{ij}^{nk}, &amp;amp;\forall  n \in N, \in K, (i,j) \in P\\z_n &amp;amp;\leq y_i^{nk}, &amp;amp;\forall  n \in N, \in K, (i,j) \in P\\z_n &amp;amp;\geq 0\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is it valid to approach the split terms separately, and substitute &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; back into the objective function?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_n Q_n  = \sum_n z_n - \sum_n x_{ij}^{nk}c_n = \sum_n( z_n - x_{ij}^{kn}c_n), k \in K, (i,j) \in P $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or do I somehow need to take the &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^{nk}c_n$&lt;/span&gt; term in &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; also into account when linearizing?&lt;/p&gt;&#xA;" OwnerUserId="3758" LastEditorUserId="3758" LastEditDate="2020-06-19T17:39:10.923" LastActivityDate="2020-06-19T17:39:10.923" Title="Linearize sum of product in objective function" Tags="|mixed-integer-programming|linearization|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4417" PostTypeId="2" ParentId="4415" CreationDate="2020-06-19T14:48:59.553" Score="3" Body="&lt;p&gt;Replace each product term by the linearized (replacement) variable, &lt;span class=&quot;math-container&quot;&gt;$z_n$&lt;/span&gt;, and add the constraints for that linearization.  You can then add, subtract, and sum these &lt;span class=&quot;math-container&quot;&gt;$z_n$&lt;/span&gt; to your heart's content. You are also still free to use the original variables, which appeared in the product terms, in any linear manner in the model; so &lt;span class=&quot;math-container&quot;&gt;$c_n x_{ij}^{nk}$&lt;/span&gt; terms are fine.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$z_n$&lt;/span&gt; are new (additional) variables, but you still have use of the &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^{nk}$&lt;/span&gt; which remain as optimization (decision) variables in your model, and indeed they appear in the linearization constraints.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-06-19T14:54:24.653" LastActivityDate="2020-06-19T14:54:24.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4418" PostTypeId="1" AcceptedAnswerId="4450" CreationDate="2020-06-20T00:37:51.400" Score="5" ViewCount="372" Body="&lt;p&gt;I am trying to run this constraint problem but the memory runs out, &lt;span class=&quot;math-container&quot;&gt;$$S_{i}$$&lt;/span&gt; are 1975 Students that need to be assigned to one of 188 teacher assistants classes, each teacher assistant has to chose a time slot &lt;span class=&quot;math-container&quot;&gt;$$TA_{j}$$&lt;/span&gt; from out of 8. Each Teacher assistant and Student have their expressed time slots in &lt;code&gt;dfTA&lt;/code&gt; and &lt;code&gt;dfS&lt;/code&gt; data frames.&lt;/p&gt;&#xA;&lt;p&gt;The idea is to assign a teacher assistant to each student and a time slot to each teacher assistant. Of course all students in a class must be able to take that class as well as the teacher assistant to give it.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import constraint&#xA;problem = constraint.Problem()&#xA;for i in range(0,1974):&#xA;    problem.addVariable(f'S_{i}', range(0,187))&#xA;for i in range(0,187):&#xA;    problem.addVariable(f'TA_{i}', range(0,8))&#xA;for S in range(0,1974):&#xA;    for TA in range(0,187):&#xA;        exec(f&amp;quot;&amp;quot;&amp;quot;def timezone{S}_{TA}(s,t):&#xA;                if s!=TA:&#xA;                    return True&#xA;                if s==TA and (dfS.iloc[S,1+t]&amp;gt;0)*(dfTA.iloc[TA,t]&amp;gt;0):&#xA;                    return True&#xA;                else:&#xA;                    return False&#xA;problem.addConstraint(timezone{S}_{TA}, ['S_{S}','TA_{TA}'])&amp;quot;&amp;quot;&amp;quot;)&#xA;problem.getSolutions()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If anyone knows how to solve this or optimize this it would be of great use.&lt;/p&gt;&#xA;&lt;p&gt;Link to a Colab notebook:&#xA;&lt;a href=&quot;https://colab.research.google.com/drive/1pb9qM13S2GmpjHAWIAEUCRwYwvyF68IT?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://colab.research.google.com/drive/1pb9qM13S2GmpjHAWIAEUCRwYwvyF68IT?usp=sharing&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And data:&#xA;&lt;a href=&quot;https://drive.google.com/drive/folders/1J6yAfXIKcn0NZrT6xtluxt71nyhuR0ak?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://drive.google.com/drive/folders/1J6yAfXIKcn0NZrT6xtluxt71nyhuR0ak?usp=sharing&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3762" LastEditorUserId="3762" LastEditDate="2020-06-22T13:16:29.613" LastActivityDate="2020-06-29T11:10:18.240" Title="How can I optimize this integer programming constraint problem without running out of memory?" Tags="|python|integer-programming|constraint-programming|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4419" PostTypeId="2" ParentId="4418" CreationDate="2020-06-20T08:21:55.017" Score="8" Body="&lt;p&gt;Be sure that your code reaches the &lt;em&gt;getSolutions&lt;/em&gt; line. As of now, you are not sure that it does.&lt;/p&gt;&#xA;&lt;p&gt;Your Python code is creating more than 3000000 functions! There is a good chance that is what is causing your memory issues. Don't use &lt;em&gt;exec&lt;/em&gt;, and create a single &lt;em&gt;timezone&lt;/em&gt; function instead with S and TA as additional parameters. You can use a lambda to pass it to &lt;em&gt;addConstraint&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then you want to make sure your model works. Use a smaller problem size - the current one is way too big, and you won't be able to debug the issues you run into. Try to state each constraint in words and explain what it does and why - it helps.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2020-06-20T08:35:26.283" LastActivityDate="2020-06-20T08:35:26.283" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4420" PostTypeId="2" ParentId="4409" CreationDate="2020-06-21T09:30:35.857" Score="5" Body="&lt;p&gt;Let us get some additional insights by assuming &lt;span class=&quot;math-container&quot;&gt;$d_{ij} \in \{0,1\}$&lt;/span&gt; and interpreting the data as a directed graph. For now we assume the number of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;'s and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;'s is the same, but I don't think it will be difficult to generalize that assumption. We say there is an arc from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; iff &lt;span class=&quot;math-container&quot;&gt;$d_{ij} \neq 0$&lt;/span&gt;. Now for each vertex &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$s_j \neq 0$&lt;/span&gt;, we have to select at least &lt;span class=&quot;math-container&quot;&gt;$\lceil s_j \rceil$&lt;/span&gt; incoming arcs. Selecting an arcs that ends in &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; can only help to cover the particular constraint of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and thus if we ignore Constraints &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, variables only occur in a single constraint and the optimal objective would be &lt;span class=&quot;math-container&quot;&gt;$\sum_{j} \lceil s_j \rceil $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If we do consider Constraints &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, we get the constraint that for every vertex at most one outgoing arc can be selected. This problem can be formulated as a min-cost flow with demands. Construct a flow graph with a source and a sink, and two intermediate layers with nodes for indices &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. From the source to each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, add an arc with capacity &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to impose Constraints &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; and give them costs &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to represent the objective function. From each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; add an arc with capacity &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and costs zero iff &lt;span class=&quot;math-container&quot;&gt;$d_{ij} = 1$&lt;/span&gt;. Finally, add arcs from &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to the sink with demand &lt;span class=&quot;math-container&quot;&gt;$s_j$&lt;/span&gt; and costs zero. Computing a min-cost flow that adheres to the demands gives you an optimal solution in polynomial time for this special case.&lt;/p&gt;&#xA;&lt;p&gt;As &lt;a href=&quot;https://or.stackexchange.com/a/4412/1047&quot;&gt;Luke599999&lt;/a&gt; pointed out, for the general case you can easily reduce a subset sum problem to this problem, which makes it weakly NP-hard. In fact, you can even reduce from 3-Partition to prove it is strongly NP-hard. Take a 3-partition instance where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; partitions of size &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; must be constructed and each number &lt;span class=&quot;math-container&quot;&gt;$n_i$&lt;/span&gt; is between &lt;span class=&quot;math-container&quot;&gt;$\frac{B}{4}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\frac{B}{2}$&lt;/span&gt; and all numbers add up to &lt;span class=&quot;math-container&quot;&gt;$kB$&lt;/span&gt;. Define &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; entries &lt;span class=&quot;math-container&quot;&gt;$s_j = B$&lt;/span&gt; for each partition that must be constructed, and define &lt;span class=&quot;math-container&quot;&gt;$d_{ij} = n_i$&lt;/span&gt; for each number &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Constraints &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces that every number will be used at most once, and Constraints &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforce that each partition is at least &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;. Now the only feasible solution would correspond to a valid 3-partition.&lt;/p&gt;&#xA;&lt;p&gt;In practice, it should not be too difficult to construct a useful lower bound for your problem. For each of the Constraints &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, solve a subset sum problem using dynamic programming to determine the minimum number of arcs you must select to fulfill that constraint. This is a pseudo-polynomial algorithm which can be solved fast in practice if your numbers are small. If you sum this up over all these constraints you get a lower bound on the number of arcs that must be selected and thus of the objective value. Constraints &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; gives you a simple upper bound: you can never select more arcs than the number of nodes.&lt;/p&gt;&#xA;&lt;p&gt;As it is NP-hard to determine whether an instance is feasible, any approximation that guarantees to find a feasible solution is also NP-hard. The special case with &lt;span class=&quot;math-container&quot;&gt;$d_{ij} \in \{0,1\}$&lt;/span&gt; is solvable in polynomial time. Perhaps other special cases can be solved in polynomial time, but it will require you to exploit additional structure of your input data.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastEditorUserId="1047" LastEditDate="2020-06-21T09:39:39.537" LastActivityDate="2020-06-21T09:39:39.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4421" PostTypeId="1" CreationDate="2020-06-22T00:44:58.260" Score="2" ViewCount="66" Body="&lt;p&gt;The problem I am trying to solve is the 2014 RAS problem. The link is the following&#xA;&lt;a href=&quot;https://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;url=https://higherlogicdownload.s3.amazonaws.com/INFORMS/e52cec4c-eedb-4c3b-a379-8408d89f8fc9/UploadedImages/2014_RAS_ProblemCompetition.pdf&amp;amp;ved=2ahUKEwiD4uuxkJTqAhVmzjgGHRXkAf8QFjABegQIARAI&amp;amp;usg=AOvVaw1_tSGP3NfmqHFyzF4Mc8I2&quot; rel=&quot;nofollow noreferrer&quot;&gt;The problem&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Trains come to the humpyard where each compartment of a train gets humped or disassembled and then each compartment is assigned to a track of classification bowl. The classification bowl is a set of parallel tracks. Each compartment from the incoming trains has a specific destination which is preassigned. Each outbound train have a departure time and some specified destinations where it will visit. When a outbound train leaves, the train takes available compartments from the classification bowl. The outbound trains have to be sorted by the destination order, so that when it reaches a destination the compartments can be disassembled from the outbound train with minimal effort. There are several restrictions such as, length of the tracks in classification bowl is limited, only one train can be humped at a time, the outbound train preparation can be started at a certain time etc. The aim is to minimize the total time taken for this whole process to finish.&lt;/p&gt;&#xA;&lt;p&gt;So this problem was previously approached, and solved with a certain manner. Here is a link of the research which won the prize that year.&#xA;&lt;a href=&quot;https://orbit.dtu.dk/files/106894424/A_Matheuristic_Approach.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Approach&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now I was wondering if this problem can be solved heuristically or by using certain Local Search idea. I thought of a vague process. First we divide the whole process by 2/3 hour segments. We consider random assignment of the compartments of trains which arrive in that time segment. Then we do a local search procedure to find a good solution. Then we depart trains and remove the compartments from classification track which departed. To notice certain properties of a compartment in the classification track. Each compartment must follow the insertion sequence i.e. if compartment x is disassembled before compartment y in humpyard, then compartment y cannot appear before compartment x in the classification track. Also, the compartments in the classification track should follow the outbound train sequence and destination order. So we try to do a neighborhood search which minimize number of violations. For the neighborhood we can consider swapping two compartments, and/or taking one compartment and inserting in a random space. But there are certain flaws in this approach, I can feel it, but can't find a way out. Also I think this neighborhood search will take a lot of time. We can implement tabu search if we get the basics done, but the basics are really hard. The main reason being there are so many constrains. Can anyone point me in the right direction?&lt;/p&gt;&#xA;" OwnerUserId="3770" LastActivityDate="2020-06-22T00:44:58.260" Title="Algorithm for Trainyard Marshall optimization problem" Tags="|optimization|constraint-programming|multi-objective-optimization|experimental-optimization|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4422" PostTypeId="1" CreationDate="2020-06-22T03:53:20.133" Score="8" ViewCount="759" Body="&lt;p&gt;Given that tomorrow Apple will likely announce the first ARM Macs (&lt;a href=&quot;https://www.bloomberg.com/news/articles/2020-06-20/apple-to-sell-developers-on-building-new-apps-amid-pushback&quot; rel=&quot;nofollow noreferrer&quot;&gt;per bloomberg&lt;/a&gt;), I was wondering what the current status of ARM support in optimization software. For instance, does anyone know if Gurobi or CPLEX plan on supporting ARM? Is there any current optimization solver that can be compiled for ARM?&lt;/p&gt;&#xA;" OwnerUserId="173" LastEditorUserId="491" LastEditDate="2022-01-18T12:39:25.063" LastActivityDate="2022-01-19T02:15:25.063" Title="Optimization software for ARM Architecture" Tags="|cplex|gurobi|" AnswerCount="1" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4423" PostTypeId="1" CreationDate="2020-06-22T12:08:38.470" Score="3" ViewCount="150" Body="&lt;p&gt;I am dealing with the following nonconvex fractional quadratic optimization problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  &amp;amp; \min_{\boldsymbol{x}} &amp;amp;&amp;amp; \max_{t \in \mathcal{T}} \frac{\boldsymbol{a}_t^T \boldsymbol{x}}{\boldsymbol{x}^T \boldsymbol{Q}_t\boldsymbol{x}}&amp;amp; \\&#xA;   &amp;amp; &amp;amp;&amp;amp; x_j\in\{0,1\},  &amp;amp; j = 1,\dots,N&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{x}=[x_1,\dots,x_N]^T$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{a}_t = [a_{1t},\dots,a_{Nt}]^T\, \forall t \in \mathcal{T}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{Q}_t \in \mathbb{R}_+^{N \times N} \, \forall t \in \mathcal{T}$&lt;/span&gt; is a stricly lower triangular (positive semidefinite) matrix.&#xA;By applying the SDP relaxation together with the linearization of the binary constraint, I get the following&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  &amp;amp; \min_{\boldsymbol{X}} &amp;amp;&amp;amp; \max_{t \in \mathcal{T}} \frac{\text{Tr}(\boldsymbol{X} \odot \text{diag}(\boldsymbol{a}_t))} {\text{Tr}(\boldsymbol{Q}_t\boldsymbol{X})} &amp;amp; \\&#xA;   &amp;amp; &amp;amp;&amp;amp; \boldsymbol{X} \succeq \boldsymbol{x}\boldsymbol{x}^T\\&#xA;   &amp;amp; &amp;amp;&amp;amp; X_{jj} \in [0, 1]  &amp;amp; j = 1,\dots,N &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$\text{Tr}$&lt;/span&gt; being the trace of a square matrix, &lt;span class=&quot;math-container&quot;&gt;$\text{diag}$&lt;/span&gt; indicating a diagonal matrix whose diagonal is made out of the function argument and &lt;span class=&quot;math-container&quot;&gt;$\odot$&lt;/span&gt; denoting the Hadamard product. To write the numerator, I exploit the property &lt;span class=&quot;math-container&quot;&gt;$X_{jj} = x_j$&lt;/span&gt;, being &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; binary in the original problem.&lt;/p&gt;&#xA;&lt;p&gt;The relaxed problem can be solved by means of the bisection method, so I can write a series of feasibility problems for decreasing values of a predefined threshold &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and solve them until the problem gets infeasible. I use CVX for this task.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  &amp;amp; \text{Find} &amp;amp;&amp;amp; \boldsymbol{X} &amp;amp;&amp;amp; \\&#xA;   &amp;amp; &amp;amp;&amp;amp; \text{Tr}(\boldsymbol{X} \odot \text{diag}(\boldsymbol{a}_t)) \leq z\, \text{Tr}(\boldsymbol{Q}_t\boldsymbol{X}) &amp;amp; \forall t \in \mathcal{T}\\&#xA;   &amp;amp; &amp;amp;&amp;amp; \boldsymbol{X} \succeq \boldsymbol{x}\boldsymbol{x}^T\\&#xA;   &amp;amp; &amp;amp;&amp;amp; X_{jj} \in [0, 1]  &amp;amp; j = 1,\dots,N &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I pick the last feasible solution &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{X}^*$&lt;/span&gt; as solution of the SDP relaxation. For simplicity, I use the Eigenvalue Decomposition (EVD) procedure to derive a rank-1 solution &lt;span class=&quot;math-container&quot;&gt;$\hat{\boldsymbol{x}}$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{X}^*$&lt;/span&gt;. In particular, after approximating &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{X}^*$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$\lambda_1 \boldsymbol{q}_1 \boldsymbol{q}_1^T$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\lambda_1$&lt;/span&gt; is its highest eigenvalue and &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{q}_1$&lt;/span&gt; the corresponding eigenvector, I set &lt;span class=&quot;math-container&quot;&gt;$\hat{\boldsymbol{x}} = \sqrt{\lambda_1}\boldsymbol{q}_1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To enforce constraints &lt;span class=&quot;math-container&quot;&gt;$x_j &amp;lt; 1$&lt;/span&gt;, I would perform the normalization &lt;span class=&quot;math-container&quot;&gt;$\hat{\boldsymbol{x}}/\max_j \sqrt{|\hat{x_j}|}$&lt;/span&gt; and then obtain a binary solution &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{x}^*$&lt;/span&gt; by quantization.&lt;/p&gt;&#xA;&lt;p&gt;It is not clear to me if I am ignoring constraints &lt;span class=&quot;math-container&quot;&gt;$x_j &amp;gt; 0$&lt;/span&gt; or if not, why. Moreover, in another version of this problem, I have a constraint of type &lt;span class=&quot;math-container&quot;&gt;$\text{Tr}(\boldsymbol{X}) \ge n, \, k\in \mathbb{N}$&lt;/span&gt;, which is a greater-than constraint. How is it to be treated with respect to the other constraints? How would you treat greater-than and less-than constraints if present at the same time? Thank you.&lt;/p&gt;&#xA;" OwnerUserId="3771" LastEditorUserId="3771" LastEditDate="2020-06-24T20:47:47.640" LastActivityDate="2020-06-24T20:47:47.640" Title="SDP relaxation with greater-than and less-than inequalities at the same time" Tags="|constraint|quadratic-programming|nonconvex-programming|relaxation|sdp|" AnswerCount="0" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="4424" PostTypeId="1" CreationDate="2020-06-22T17:11:30.840" Score="3" ViewCount="167" Body="&lt;p&gt;I have been working with a model for the past couple of weeks, but I am not sure what am I doing wrong as every time Pyomo returns that is &lt;code&gt;infeasible&lt;/code&gt; or &lt;code&gt;unbounded&lt;/code&gt;. I am trying to model an Electric Vehicle scheduling to minimise the electricity bill of a house. The house has a PV generation system connected as well. The EV is able to charge and give energy to the house if required everytime that is plugged, i.e. &lt;code&gt;avail = 1&lt;/code&gt; and and only discharge when is driving, i.e. &lt;code&gt;avail=0&lt;/code&gt;. The model is capable to sell energy back to the grid as well which also helps to reduce the electricity bill even more.&lt;/p&gt;&#xA;&lt;p&gt;I already figured out how to prevent charging when &lt;code&gt;avail=0&lt;/code&gt; (driving) in another question &lt;a href=&quot;https://stackoverflow.com/questions/62406319/pyomo-struggling-to-get-a-constraint-to-work/62406945#62406945&quot;&gt;https://stackoverflow.com/questions/62406319/pyomo-struggling-to-get-a-constraint-to-work/62406945#62406945&lt;/a&gt; which is great. But now the problem is that because the model is considering that the energy used when driving is the same as if it was selling it back to the grid, the results are not realistic at all.&lt;/p&gt;&#xA;&lt;p&gt;Also I am not sure if the optimisation is correct as the model is ignoring the house demand when the EV is not available (&lt;code&gt;avail=0&lt;/code&gt;). As I explained in my previous question, I am considering this model as a stationary battery that connects and disconnects, however, at this point I am not sure if it is correct that way.&lt;/p&gt;&#xA;&lt;p&gt;At the moment, &lt;code&gt;load&lt;/code&gt; contains both the house and EV demand.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;net_demand = load-PV&#xA;posLoad = np.copy(load-PV)&#xA;negLoad = np.copy(load-PV)&#xA;for j, e in enumerate(net):&#xA;    if e &amp;gt;= 0:&#xA;        negLoad[j] = 0&#xA;    else:&#xA;        posLoad[j] = 0&#xA;&#xA;posLoadDict = dict(enumerate(posLoad))&#xA;negLoadDict = dict(enumerate(negLoad))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I would like to keep them each in separate dictionaries, which I guess it will help me to keep the house drawing energy from the grid or PV even if the EV is driving (&lt;code&gt;avail=0&lt;/code&gt;) but I am not sure how to formulate it.&lt;/p&gt;&#xA;&lt;p&gt;Here is the rest of the code so far:&lt;/p&gt;&#xA;&lt;p&gt;As I mentioned, &lt;code&gt;availDict = dict(enumerate(df[avail]))&lt;/code&gt; has values &lt;code&gt;avail=1 (plugged)&lt;/code&gt; and &lt;code&gt;avail=0 (not plugged and driving)&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I hope that I explained my problem properly and hopefully you are able to understand what I meant.&lt;/p&gt;&#xA;&lt;p&gt;If there is another suggestion or you need more information please let me know so I can provide it as soon as possible.&lt;/p&gt;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="3746" LastEditorUserId="3746" LastEditDate="2020-06-28T16:10:22.483" LastActivityDate="2020-06-28T16:10:22.483" Title="Pyomo: Help setting up my model" Tags="|mixed-integer-programming|python|constraint|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4425" PostTypeId="1" AcceptedAnswerId="4427" CreationDate="2020-06-23T08:52:29.093" Score="3" ViewCount="260" Body="&lt;p&gt;Here is a scheduling problem I need to solve. Given the demand for 2 positions in 1 week with 3 shifts per position, I need to allocate the employees accordingly with some extra operational constraints. Note that each employee can work at any position but only one shift per day totally.The main objective here is to minimize the total shift switches within week.  First I shall introduce my variables and the constarints and then how I formulated it mathematically.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Binary variables&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Employee: &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt;,  i=1:N&lt;/li&gt;&#xA;&lt;li&gt;Working day per employee: &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt;,  i=1:N | j=1:7&lt;/li&gt;&#xA;&lt;li&gt;Wroking day/shift/position per employee: &lt;span class=&quot;math-container&quot;&gt;$z_{i,j,k,l}$&lt;/span&gt;, i=1:N | j=1:7 | k = 1:3 | l = 1:2&lt;/li&gt;&#xA;&lt;li&gt;Shift switch per employee per day: &lt;span class=&quot;math-container&quot;&gt;$s_{i,j,k}$&lt;/span&gt;, i=1:N | j=1:7 | k = 1:3&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;One shift per day per employee: &lt;span class=&quot;math-container&quot;&gt;$\sum_{k,l} z_{i,j,k,l} \leqslant y_{i,j} \ \   \forall i,j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;One position per day per employee: &lt;span class=&quot;math-container&quot;&gt;$z_{i,j,k,1}+ z_{i,j,k,2} \leqslant1 \ \     \forall i,j,k$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Maximum working days per employee (6 days): &lt;span class=&quot;math-container&quot;&gt;$\sum_{j} y_{i,j} \leq x_{i}\cdot D_{max} \ \ \forall i=1:N$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Minimum working days per employee (5 days): &lt;span class=&quot;math-container&quot;&gt;$\sum_{j} y_{i,j} \geq x_{i}\cdot D_{min} \ \ \forall i=1:N$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Comply with weekly demand (D): &lt;span class=&quot;math-container&quot;&gt;$\sum_{i} z_{i,j,k} = D_{j,k,l} \ \  \forall j,k,l$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Detect any shift switch day over day:  &lt;span class=&quot;math-container&quot;&gt;$\sum_{l}z_{i,j,k,l}- \sum_{l}z_{i,j-1,k,l} \leqslant s_{i,j,k} \ \  \forall i,j=2:7,k$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I followed &lt;a href=&quot;https://math.stackexchange.com/questions/1591733/milp-optimization-constraint-formulation&quot;&gt;this&lt;/a&gt; method to introduce continuity in shift assignment and reduce switches&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;Minimize shift switches day over day across all employees:&lt;span class=&quot;math-container&quot;&gt;$min \sum_{i,j,k}s_{i,j,k} \ \  \forall i,j=2:7,k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Running this in R with ompr package I get this results:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zr2hE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zr2hE.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Employees are placed to rows and columns depict the day of the week. Values denote the shift an employee is assigned to. Missing values (NA) correspond to employee's day off according to the constraints.&lt;/p&gt;&#xA;&lt;p&gt;This is not the best solution, at first glance, this can be solved with very few employees having shift change within week and the rest to be assigned to a single shift throughout the week. I guess this is due to the fact that any day off followed by a shift assignment is considered as change.  Any thoughts?&lt;/p&gt;&#xA;" OwnerUserId="3463" LastEditorUserId="3463" LastEditDate="2020-06-24T08:39:33.760" LastActivityDate="2020-06-30T11:12:34.143" Title="Limit number of switches in employee scheduling problem" Tags="|optimization|mixed-integer-programming|constraint-programming|combinatorial-optimization|scheduling|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4426" PostTypeId="2" ParentId="4424" CreationDate="2020-06-23T10:56:13.057" Score="1" Body="&lt;p&gt;Solvers struggle a lot with unbounded problems. Make sure that the variables in your objective are properly bounded from both sides, with bounds that are not too large. Also check your Lagrange multipliers to make sure that the constraints that are supposed to bound your variables are active at the solution.&lt;/p&gt;&#xA;&lt;p&gt;Another numerical issue might also arise from your big-M value, which may be a bit too large. Try using a smaller big-M or, ideally, a convex hull formulation.&lt;/p&gt;&#xA;&lt;p&gt;If, despite those steps, your problem is now, ideally, infeasible rather than unbounded, you can find the culprit by disabling all constraints and enabling them back one at a time, until your problem suddenly becomes infeasible. Since you are using Pyomo you can actually write a small script to do this automatically for you.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-06-23T10:56:13.057" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4427" PostTypeId="2" ParentId="4425" CreationDate="2020-06-23T12:43:23.793" Score="3" Body="&lt;p&gt;You can omit constraint 2 because it is dominated by constraint 1.&lt;/p&gt;&#xA;&lt;p&gt;Constraint 6 is not correct. For consecutive days, you want&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_l z_{i,j,k,l}+\sum_l z_{i,j-1,k_2,l}-1\le s_{i,j,k},$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$k\not= k_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For a day off in between, you want&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_l z_{i,j,k,l}+(1-y_{i,j-1})+\sum_l z_{i,j-2,k_2,l}-2\le s_{i,j,k},$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$k\not= k_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For two days off in between, you want&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_l z_{i,j,k,l}+(1-y_{i,j-1})+(1-y_{i,j-2})+\sum_l z_{i,j-3,k_2,l}-3\le s_{i,j,k},$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$k\not= k_2$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-06-23T12:43:23.793" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4428" PostTypeId="2" ParentId="4422" CreationDate="2020-06-24T06:37:39.727" Score="4" Body="&lt;p&gt;CPLEX does not provide ARM support yet but there is a request for enhancement at&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&amp;amp;CR_ID=126844&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&amp;amp;CR_ID=126844&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and you may vote for this&lt;/p&gt;&#xA;" OwnerUserId="627" LastEditorUserId="491" LastEditDate="2022-01-19T02:15:25.063" LastActivityDate="2022-01-19T02:15:25.063" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4429" PostTypeId="2" ParentId="4425" CreationDate="2020-06-24T08:45:51.490" Score="1" Body="&lt;p&gt;@RobPratt, thank for the clarification. I tried to incorporate the above into my MILP model but I do not get a feasible solution even after half an hour of searching which is strange. Following your explanation, I ended up with something different that returns a feasible solution quickly. Here it is:&#xA;Introduce decision variable: &lt;span class=&quot;math-container&quot;&gt;$s_{i,k}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;and this is the constraint I propose:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j,l} z_{i,j,k,l} \le 7\cdot s_{i,k}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the shift is assigned at least one day then the corresponding decision variable is enabled. Since I want the minimum number of switches I need an objective that is responsible to assign a single shift per employee as much as possible.&lt;/p&gt;&#xA;&lt;p&gt;Objective function can be altered to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{\min} s_{i,k}$$&lt;/span&gt;&#xA;This way I can minimize switches in terms of shift regardless of what happens within the week. What is your opinion?&lt;/p&gt;&#xA;" OwnerUserId="3463" LastEditorUserId="500" LastEditDate="2020-06-30T11:12:34.143" LastActivityDate="2020-06-30T11:12:34.143" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4430" PostTypeId="1" AcceptedAnswerId="4487" CreationDate="2020-06-24T15:26:41.813" Score="4" ViewCount="722" Body="&lt;p&gt;I am working on a shipping demurrage problem that uses a binary variable to denote the date a specific vessel can be loaded (I have been kindly helped by Wesley on OR before with this).&lt;/p&gt;&#xA;&lt;p&gt;I am confident that the rest of the model works fine, however when using the binary to determine the load dates, the model is unable to find a solution i.e. is 'infeasible' and the output of the variable is either &lt;code&gt;1.0&lt;/code&gt; or &lt;code&gt;10000.0&lt;/code&gt; which is clearly incorrect (and non-binary).&lt;/p&gt;&#xA;&lt;p&gt;Question: Do I need to linearize the binary variable, &lt;code&gt;vessel_load_start_date[vessel, date]&lt;/code&gt; in some way?&lt;/p&gt;&#xA;&lt;p&gt;Code &amp;amp; Descriptions below:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;port_inventory_vars&lt;/code&gt; = &lt;strong&gt;Variable&lt;/strong&gt;: the inventory on the specified date&#xA;of each product grade.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vessel_grade_demand_tonnes&lt;/code&gt; = &lt;strong&gt;Constant&lt;/strong&gt;: the required amount, in&#xA;tonnes of each grade required by each vessel.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vessel_sales_demand_vars[(vessel, grade, date)]&lt;/code&gt; = &lt;strong&gt;Variable&lt;/strong&gt;. The date&#xA;a vessels demand requirements are fully satisfied.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vessel_load_start_date[vessel, date]&lt;/code&gt; = &lt;strong&gt;Binary&lt;/strong&gt;: The date&#xA;indicating when a vessel can be loaded. NOTE a vessel can only load&#xA;if the total amount it requires is available in the port inventory,&#xA;&lt;code&gt;port_inventory_vars[date, grade]&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;demurrage_rates[vessel, date]&lt;/code&gt; = &lt;strong&gt;Constant&lt;/strong&gt;: The daily demurrage rates per vessel.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;demurrage_charge_vars[vessel, date]&lt;/code&gt; = &lt;strong&gt;Decision variable&lt;/strong&gt;: The demurrage charged.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;    # PORT STOCKPILE: Port Stockpile Inventory&#xA;    for date in dates:&#xA;      current_date = PLAN_START_DATE&#xA;      date_t_minus_one = datetime.datetime.strptime(date, '%Y-%m-%d') \&#xA;          - datetime.timedelta(days=1)&#xA;      date_t_minus_one = date_t_minus_one.strftime('%F')&#xA;      for grade in grades:&#xA;        # Filter plants&#xA;        _plants_combo = [&#xA;            plant for plant in plants &#xA;            if (plant, grade) in plant_combinations]&#xA;        # Get vessel demands for requisite date&#xA;        _vessel_demands_combination = [&#xA;            (vessel, date) for vessel in vessels for date in dates&#xA;            if (vessel, date) in vessel_load_start_date&#xA;        ]&#xA;        if date == current_date:&#xA;          # Current Inv == current inventory + train in - sales demand&#xA;          model += port_stockpile_current[grade] \&#xA;              + pulp.lpSum(&#xA;                    train_consignment_variables[(date, plant, grade)] &#xA;                    for plant in _plants_combo) \&#xA;              - pulp.lpSum(&#xA;                    vessel_sales_demand_vars[(vessel, grade, date)]&#xA;                    for vessel, date in _vessel_demands_combination) \&#xA;              + insufficient_port_supply[(date, grade)] \&#xA;              == port_inventory_vars[(date, grade)]&#xA;        else:&#xA;          model += port_inventory_vars[(f'{date_t_minus_one}', grade)] \&#xA;              + pulp.lpSum(&#xA;                    train_consignment_variables[(date, plant, grade)] &#xA;                    for plant in _plants_combo) \&#xA;              - pulp.lpSum(&#xA;                    vessel_sales_demand_vars[(vessel, grade, date)]&#xA;                    for vessel, date in _vessel_demands_combination) \&#xA;              + insufficient_port_supply[(date, grade)] \&#xA;              == port_inventory_vars[(date, grade)]&#xA;&#xA;    # Port stockpile total inventory tonnage must be &amp;lt;= 2.1M tonnes&#xA;    for date, grade in port_inventory_vars:&#xA;      model += pulp.lpSum(port_inventory_vars[(date, grade)]) &amp;lt;= 2100000&#xA;    &#xA;    # Control vessel loading&#xA;    for grade in grades:&#xA;      for vessel, date in vessel_load_start_date:&#xA;        model += vessel_sales_demand_vars[(vessel, grade, date)] - vessel_grade_demand_tonnes[vessel, grade] * vessel_load_start_date[vessel, date] &amp;lt;= 0&#xA;        model += vessel_sales_demand_vars[(vessel, grade, date)] &amp;lt;= vessel_load_start_date[vessel, date] * vessel_grade_demand_tonnes[vessel, grade] &#xA;    &#xA;    # Vessel sales requirements must be satisfied by sales vars&#xA;    for vessel, grade in vessel_grade_requirements:&#xA;      for vessel, date in vessel_load_start_date:&#xA;        _dates = [&#xA;            tup[1] for tup in vessel_load_start_date&#xA;            if tup[0] == vessel &#xA;        ] &#xA;      model += pulp.lpSum(vessel_sales_demand_vars[vessel, grade, date] for date in _dates) == vessel_grade_demand_tonnes[vessel, grade] &#xA;     &#xA;    # Demurrage charges per vessel&#xA;    for vessel, date in vessel_load_start_date:&#xA;      model += vessel_load_start_date[vessel, date] * demurrage_rates[vessel, date] == demurrage_charge_vars[vessel, date]&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Current Model Outputs&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    # Vessel load start date vars&#xA;&amp;gt;&amp;gt;&amp;gt; for vessel, date in vessel_load_start_date:&#xA;      print(vessel, date, ':', vessel_load_start_date[vessel, date].varValue&#xA;&#xA;CEYLON BREEZE 2020-05-28 : 1.0&#xA;CEYLON BREEZE 2020-05-29 : 0.0&#xA;CEYLON BREEZE 2020-05-30 : 0.0&#xA;&#xA;    # Demurrage Vars&#xA;&amp;gt;&amp;gt;&amp;gt; for vessel in demurrage_charge_vars:&#xA;      print(vessel, ':', demurrage_charge_vars[vessel].varValue)&#xA;&#xA;CEYLON BREEZE : 0.0&#xA;&#xA;# vessel sales demand vars&#xA;&amp;gt;&amp;gt;&amp;gt; for vessel, grade, date in vessel_sales_demand_vars:&#xA;      print(vessel, grade, date,':', vessel_sales_demand_vars[vessel, grade, date].varValue)&#xA;&#xA;CEYLON BREEZE ZBL 2020-05-28 : 10000.0&#xA;CEYLON BREEZE ZBL 2020-05-29 : 0.0&#xA;CEYLON BREEZE ZBL 2020-05-30 : 0.0&#xA;CEYLON BREEZE MFA 2020-05-28 : 0.0&#xA;CEYLON BREEZE MFA 2020-05-29 : 0.0&#xA;CEYLON BREEZE MFA 2020-05-30 : 0.0&#xA;CEYLON BREEZE PRE 2020-05-28 : 0.0&#xA;CEYLON BREEZE PRE 2020-05-29 : 0.0&#xA;CEYLON BREEZE PRE 2020-05-30 : 0.0&#xA;CEYLON BREEZE AAE 2020-05-28 : 0.0&#xA;CEYLON BREEZE AAE 2020-05-29 : 0.0&#xA;CEYLON BREEZE AAE 2020-05-30 : 0.0&#xA;CEYLON BREEZE ACC 2020-05-28 : 10000.0&#xA;CEYLON BREEZE ACC 2020-05-29 : 0.0&#xA;CEYLON BREEZE ACC 2020-05-30 : 0.0&#xA;&#xA;&amp;gt;&amp;gt;&amp;gt; for (date, grade) in port_inventory_vars:&#xA;      print(date, grade, ':', port_inventory_vars[(date, grade)].varValue)&#xA;2020-05-28 ZBL : 215200.0&#xA;2020-05-28 MFA : 216800.0&#xA;2020-05-28 PRE : 222000.0&#xA;2020-05-28 AAE : 200000.0&#xA;2020-05-28 ACC : 10000.0&#xA;2020-05-29 ZBL : 205200.0&#xA;2020-05-29 MFA : 216800.0&#xA;2020-05-29 PRE : 306000.0&#xA;2020-05-29 AAE : 200000.0&#xA;2020-05-29 ACC : 0.0&#xA;2020-05-30 ZBL : 195200.0&#xA;2020-05-30 MFA : 216800.0&#xA;2020-05-30 PRE : 306000.0&#xA;2020-05-30 AAE : 200000.0&#xA;2020-05-30 ACC : 32000.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Any help gratefully received as I have been scratching my head on why the solution is infeasible. I am using dummy data and over a very short timeframe to help troubleshoot this issue.&lt;/p&gt;&#xA;" OwnerUserId="3395" LastEditorUserId="3395" LastEditDate="2020-07-06T21:48:22.480" LastActivityDate="2020-07-06T21:48:22.480" Title="Output of binary variable greater than one" Tags="|optimization|mixed-integer-programming|linear-programming|python|pulp|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="4431" PostTypeId="1" AcceptedAnswerId="4434" CreationDate="2020-06-24T17:40:16.497" Score="3" ViewCount="434" Body="&lt;p&gt;I would like to linearize &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt; term in my objective function. I understand this can be solved using quadratic programming solver; however, for my use case linearization is necessary to convert it to MIP if possible. Any help is much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2546" LastActivityDate="2020-06-24T19:54:21.153" Title="Linearizing power term in objective function" Tags="|mixed-integer-programming|linearization|quadratic-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4432" PostTypeId="1" AcceptedAnswerId="4438" CreationDate="2020-06-24T18:00:50.390" Score="4" ViewCount="218" Body="&lt;p&gt;I want to make a term in an objective function I am working with fit into DCP for CVXPY.&lt;/p&gt;&#xA;&lt;p&gt;I am working on replicating this &lt;a href=&quot;https://bmvc2019.org/wp-content/uploads/papers/1067-paper.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;research paper&lt;/a&gt; for an active learning problem. Specifically equations 5 is what I am trying to implement in CVXPY.&lt;/p&gt;&#xA;&lt;p&gt;A bit of an explanation. I have a set of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; vectors &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, each representing one piece of unlabeled data, that I want to get labeled into one of &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; classes. But the difficulty is that I know that for a few of the classes that they are infrequent, so instead of taking random samples to be labeled, we want to make smart selections as to what should get labeled.&lt;/p&gt;&#xA;&lt;p&gt;If I have a matrix &lt;span class=&quot;math-container&quot;&gt;$P_{ij}$&lt;/span&gt;, where for each row &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; for each unlabeled data point, I have a confidence score in each column &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; for each class. A high confidence score means that we are more certain that that data point belongs to that class, a lower one means we are less confident.&lt;/p&gt;&#xA;&lt;p&gt;I also have a redundancy matrix &lt;span class=&quot;math-container&quot;&gt;$R_{ij}$&lt;/span&gt;, which calculated by  &lt;span class=&quot;math-container&quot;&gt;$R_{ij}=\max(0,\cos(x_i,x_j))$&lt;/span&gt;. This is used to identify pairs of data points that are likely very similar, and not select them to both be labeled.&lt;/p&gt;&#xA;&lt;p&gt;What the optimization problem is trying to solve for is a matrix &lt;span class=&quot;math-container&quot;&gt;$M_{ij}$&lt;/span&gt; , where each row &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; represents a data point, and each columns &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; represents a class. For each for we either want to assign a 1 to one of the columns and all the other values remain 0 to designate a data poi t to label, or all the values remain zero to designate select no data points.&lt;/p&gt;&#xA;&lt;p&gt;I have followed equation 5 because it looks fairly straight forward to calculate, but the difficulty I am encountering it that CVXPY does not like the  &lt;span class=&quot;math-container&quot;&gt;$(Me)^TR(Me)$&lt;/span&gt;(e is a vector of ones with as many elements as there are classes) term due to it not fitting in to the rules of DCP, but the authors of the paper proved that its a linear program. When I write it in terms of the equivalent 7 in equation I run into the same issue.&lt;/p&gt;&#xA;&lt;p&gt;What resources or hints are there for translating the redundancy term in the objective function  in equation 5 and 7 in the paper into something that CVXPY will accept as compliant with DCP? I am not very familiar with how to classify the exact type of optimization that this might be, so please excuse me if I missed something that would have answered my own question.&lt;/p&gt;&#xA;" OwnerUserId="3784" LastEditorUserId="8" LastEditDate="2020-09-01T16:07:58.463" LastActivityDate="2020-09-01T19:49:04.303" Title="Make Optimization term fit into DCP rules" Tags="|integer-programming|disciplined-convex-programming|cvxpy|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4433" PostTypeId="1" CreationDate="2020-06-24T19:22:21.120" Score="3" ViewCount="69" Body="&lt;p&gt;I am wondering whether there exists some general insight for when the optimal solution to the warehouse location problem is still optimal for a given subset of customers. For example:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Does the optimal solution also hold if I remove the customer that is considered an outlier (i.e. the customer that is the further from the warehouse that it's assigned to) from the set of customers?&lt;/li&gt;&#xA;&lt;li&gt;What conditions are placed for the possible warehouse locations that are not selected in order for the optimal solution to remain optimal for the subset?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Please note, I am wondering about the case when the objective function simply minimises the distance between the warehouse location and its customers. There are no cost functions related to opening or closing a warehouse. Only the number of warehouses selected is fixed.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;As indicated by the comment earlier. Perhaps to avoid the ambiguity, I would like to define the objective function to my problem as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i=1}^{n}\sum_{j=1}^{m}d(i,j)x_{i,j}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where there are &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; possible warehouse locations, &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; customers.&lt;/p&gt;&#xA;" OwnerUserId="563" LastEditorUserId="563" LastEditDate="2020-06-25T19:55:57.253" LastActivityDate="2020-06-25T19:55:57.253" Title="Under what conditions is the optimal solution to the warehouse location problem the same for a subset of customers?" Tags="|facility-location|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4434" PostTypeId="2" ParentId="4431" CreationDate="2020-06-24T19:54:21.153" Score="6" Body="&lt;p&gt;There are two possibilities that come to mind, assuming that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a continuous variable. One is to do a piecewise-linear approximation (leading to an answer that is, well, approximate). The other is to replace &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt; with a new variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and then, on the fly, add constraints of the form &lt;span class=&quot;math-container&quot;&gt;$z \ge x_0^2 + 2x_0(x-x_0)$&lt;/span&gt; when a solution is obtained containing &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_0$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$z_0 \lt x_0^2$&lt;/span&gt;. The latter method is potentially useful if the nature of the model precludes the solver choosing &lt;span class=&quot;math-container&quot;&gt;$z \gt x^2$&lt;/span&gt;. With CPLEX, you can add these constraints in a lazy constraint callback. With a solver that lacks the needed callback structure, you would be in a solve - cut - solve cycle until you got an optimal solution needing no further cuts.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-06-24T19:54:21.153" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4435" PostTypeId="1" AcceptedAnswerId="4436" CreationDate="2020-06-25T09:43:16.830" Score="2" ViewCount="99" Body="&lt;p&gt;I have three variables &lt;span class=&quot;math-container&quot;&gt;$x_{1},x_{2},x_{3}$&lt;/span&gt; and a function &lt;span class=&quot;math-container&quot;&gt;$f :  D \rightarrow \mathbb{R}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is defined as such :&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$D = (x_{1},x_{2},x_{3})$$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$$x_{1}+x_{2}+x_{3}=1$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$x_{1}&amp;gt;x_{2}&amp;gt;x_{3}$$&lt;/span&gt;&#xA;Therefore, D is the intersection of a plane and a box, and hence is a plane.&lt;/p&gt;&#xA;&lt;p&gt;The objective is to find &lt;span class=&quot;math-container&quot;&gt;$(x_{1},x_{2},x_{3}) \in D$&lt;/span&gt; such as &lt;span class=&quot;math-container&quot;&gt;$f(x_{1},x_{2},x_{3}) = c \in \mathbb{R}$&lt;/span&gt;. The function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is injective and so for a fixed &lt;span class=&quot;math-container&quot;&gt;$c \in \mathbb{R}$&lt;/span&gt;, there can be multiple solutions  &lt;span class=&quot;math-container&quot;&gt;$(x_{1},x_{2},x_{3})$&lt;/span&gt;. Among all the solutions, I want to find the one that has the highest &lt;span class=&quot;math-container&quot;&gt;$x_{1}$&lt;/span&gt;, and then once the highest &lt;span class=&quot;math-container&quot;&gt;$x_{1}$&lt;/span&gt; is found, the highest &lt;span class=&quot;math-container&quot;&gt;$x_{2}$&lt;/span&gt;. How do I specify this constraint ?&lt;/p&gt;&#xA;&lt;p&gt;Note that the function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; doesn't have a closed-form solution and I am using minimize from scipy to find the &lt;span class=&quot;math-container&quot;&gt;$(x_{1},x_{2},x_{3})$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3756" LastActivityDate="2020-06-25T10:04:20.367" Title="Specify the criteria of the optimal solution" Tags="|optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4436" PostTypeId="2" ParentId="4435" CreationDate="2020-06-25T10:04:20.367" Score="3" Body="&lt;p&gt;If I understood your problem correctly, you want to find &lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2,x_3)$&lt;/span&gt; such that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2,x_3) \in D$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f(x_1,x_2,x_3) = c$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is a given parameter&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1&amp;gt;x_2 &amp;gt;x_3$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also, you want to maximize &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;, but &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; has &amp;quot;priority&amp;quot; over &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;. So you can use the following objective function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \; \omega_1 x_1 + \omega_2 x_2&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\omega_1$&lt;/span&gt; is weight larger than &lt;span class=&quot;math-container&quot;&gt;$\omega_2$&lt;/span&gt;, e.g., &lt;span class=&quot;math-container&quot;&gt;$\omega_1 = 10 \omega_2$&lt;/span&gt;. Choosing adequate values for &lt;span class=&quot;math-container&quot;&gt;$\omega_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\omega_2$&lt;/span&gt; depends on &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-06-25T10:04:20.367" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4437" PostTypeId="1" CreationDate="2020-06-25T14:48:16.893" Score="2" ViewCount="176" Body="&lt;p&gt;Here is my problem. A store has &lt;strong&gt;X&lt;/strong&gt; = 15 electical devices with the ability to work non-stop, fully charged, up to 8 hours. Their battery charge lasts 2 hours and the operating hours of the store differ day over day, fortunately, this does not affect their charging. The number of chargers, &lt;strong&gt;Y&lt;/strong&gt; = 4, most likely will be less than devices number. When the store remains closed charging takes place normally. Every device that is fully charged, remains charged if does not operate.Store remains open/closed according to operating hours (loo at the end)&lt;/p&gt;&#xA;&lt;p&gt;Is their any way to formulate this problem into LP/MILP so as to achieve device operation hours maximization, for the indicated circular schedule?&lt;/p&gt;&#xA;&lt;p&gt;Update - 7/6/2020&lt;/p&gt;&#xA;&lt;p&gt;Following to @Richard' comment I trie to reduce the post and also share data to make possible any attempt for replication. I used R to formulate and get a first iteration.And &lt;code&gt;ompr&lt;/code&gt; package to solve this.&lt;/p&gt;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;library(data.table)&#xA;library(stringr)&#xA;Test = data.table(permutations(n = 2,r = 12,v = c(&amp;quot;b&amp;quot;,&amp;quot;s&amp;quot;),repeats.allowed = T))&#xA;Test[, names(Test) := lapply(.SD, function(x) gsub(&amp;quot;b&amp;quot;, &amp;quot;0,0&amp;quot;, x))]&#xA;Test[, names(Test) := lapply(.SD, function(x) gsub(&amp;quot;s&amp;quot;, &amp;quot;1,1&amp;quot;, x))]&#xA;Test[, key := do.call(paste, c(.SD, sep = &amp;quot;,&amp;quot;)), .SDcols = names(Test)]&#xA;Conf = lapply(unique(Test$key),FUN = function(x) as.integer(str_split(x,&amp;quot;,&amp;quot;)[[1]]))&#xA;&#xA;ConfDT = as.data.table(Conf)&#xA;ConfDT[, Hour := seq_len(.N)]&#xA;ConfDTMelt = melt(ConfDT,id.vars = &amp;quot;Hour&amp;quot;,variable.name = &amp;quot;k&amp;quot;,variable.factor = F,value.factor = F)&#xA;ConfDT[, Hour := NULL]&#xA;ConfDTMelt[, Change := rleid(value), .(k)]&#xA;ConfDTMelt[, CumValue := cumsum(value), .(k,Change)]&#xA;ConfDTMelt[, ValueLead :=shift(value,n = 1,&amp;quot;lead&amp;quot;,fill = NA_real_), by = .(k)]&#xA;RmvCases = unique(c(ConfDTMelt[(Change &amp;gt; 1 &amp;amp; value == 1 &amp;amp; ValueLead == 0 &amp;amp; CumValue&amp;lt;8 &amp;amp; CumValue&amp;gt;0) | CumValue&amp;gt;8,k],ConfDTMelt[, .(Sum = sum(value)), by = .(k)][Sum == 0, k]))&#xA;ConfDT = ConfDT[, setdiff(names(ConfDT),RmvCases), with = F]&#xA;colnames(ConfDT) = paste0(&amp;quot;V&amp;quot;,seq_len(ncol(ConfDT)))&#xA;ConfDT[, Hour := seq_len(.N)]&#xA;ConfDTMelt = melt(ConfDT,id.vars = &amp;quot;Hour&amp;quot;,variable.name = &amp;quot;k&amp;quot;,value.name = &amp;quot;Work&amp;quot;)&#xA;ConfDTMelt[, k:=as.integer(str_remove(k,&amp;quot;V&amp;quot;))]&#xA;ConfDT[, Hour := NULL]&#xA;Conf = as.list(ConfDT)&#xA;&#xA;ConfDTComb = data.table(rbind(as.matrix(ConfDT[, c(CJ(1:ncol(ConfDT),1:ncol(ConfDT))&lt;span class=&quot;math-container&quot;&gt;$V1), with = F]),&#xA;                              as.matrix(ConfDT[, c(CJ(1:ncol(ConfDT),1:ncol(ConfDT))$&lt;/span&gt;V2), with = F])))&#xA;colnames(ConfDTComb) = paste0(&amp;quot;Col&amp;quot;,c(1:ncol(ConfDTComb)))&#xA;ConfDTComb[, Row := seq_len(.N)]&#xA;ConfDTCombMelt = melt(ConfDTComb,id.vars = &amp;quot;Row&amp;quot;,variable.name = &amp;quot;Combination&amp;quot;,value.name = &amp;quot;value&amp;quot;)&#xA;ConfDTCombMelt[, Change := rleid(value), .(Combination)]&#xA;ConfDTCombMelt[, CumValue := cumsum(value), .(Combination,Change)]&#xA;ConfDTCombMelt[, ValueLead :=shift(value,n = 1,&amp;quot;lead&amp;quot;,fill = NA_real_), by = .(Combination)]&#xA;ForbiddenCases = CJ(1:ncol(ConfDT),1:ncol(ConfDT))[as.numeric(str_remove(unique(ConfDTCombMelt[CumValue&amp;gt;8 | (CumValue&amp;lt;8 &amp;amp; ValueLead == 0 &amp;amp; CumValue &amp;gt;0 &amp;amp; Change&amp;gt;1),Combination]),&amp;quot;Col&amp;quot;)),]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In the beginning I tried to get all possible permutations of c(0,1), which actually denotes when a devices is working or not. In order to reduce the total number of permutations I get the permutations for pairs of 0's and 1's. Finally I kept only the meaningful ones, so cases such as totally disabled/enabled devices or consecutive 0,1 where removed and I ended up with 105 configurations.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Model&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Fun1 = function(j,k){mapply(function(x,y) sum(unlist(Conf[y])*unlist(Rest[x])),j, k)}&#xA;ForbiddenCasesFun = function(k,kk){mapply(function(x,y) nrow(ForbiddenCases[V1 == x &amp;amp; V2 == y])==1 ,k, kk)}&#xA;ChargingHoursFun = function(k,h){mapply(function(x,y) unlist(Conf[x])[y] == 1,k, h)}&#xA;&#xA;model = MILPModel() %&amp;gt;%&#xA;  # device- Day &#xA;  add_variable(x[i,j], i = 1:15 , j = 1:7, type = &amp;quot;binary&amp;quot;) %&amp;gt;%&#xA;  # device- Day - Configuration&#xA;  add_variable(y[i,j,k], i = 1:15, j = 1:7, k = 1:length(Conf), type = &amp;quot;binary&amp;quot;) %&amp;gt;%&#xA;  # device- Day - Configuration - Hour charging&#xA;  add_variable(z[i,j,k,h], i = 1:15, j = 1:7, k = 1:length(Conf), h = 1:24,type = &amp;quot;binary&amp;quot;) %&amp;gt;%&#xA;  # Single Configuration per device/Day&#xA;  add_constraint(sum_expr(y[i,j,k], k = 1:length(Conf)) &amp;lt;= x[i,j], i = 1:15, j = 1:7) %&amp;gt;% &#xA;  # Day over Day forbidden adjacent configurations&#xA;  add_constraint(y[i,j-1,k] + y[i,j,kk] &amp;lt;= 1, i = 1:15, j = 2:7, k = 1:ncol(ConfDT),kk =  1:ncol(ConfDT),ForbiddenCasesFun(k,kk)) %&amp;gt;% &#xA;  # Week over week forbidden adjacent configurations&#xA;  add_constraint(y[i,7,k] + y[i,1,kk] &amp;lt;= 1, i = 1:15, k = 1:ncol(ConfDT),kk =  1:ncol(ConfDT),ForbiddenCasesFun(k,kk)) %&amp;gt;% &#xA;  # Charging can not be placed when devices operates according to the configuration  &#xA;  add_constraint(z[i,j,k,h] == 0, i = 1:15,j = 1:7, k = 1:ncol(ConfDT), h = 1:24, ChargingHoursFun(k,h)) %&amp;gt;%&#xA;  # single charging hour per configuration&#xA;  add_constraint(sum_expr(z[i,j,k,h],h = 1:24) == y[i,j,k], i = 1:15, j = 1:7, k = 1:length(Conf)) %&amp;gt;% &#xA;  # Maximum number of devicescharging per hour&#xA;  add_constraint(sum_expr(z[i,j,k,h],i = 1:15, j = 1:7, k = 1:length(Conf)) &amp;lt;= 4, h = 1:24)&#xA;model = model %&amp;gt;%&#xA;  set_objective(sum_expr(y[i,j,k]*colwise(Fun1(j,k)),  i = 1:15, j = 1:7, k = 1:length(Conf))) %&amp;gt;%&#xA;  solve_model(with_ROI(solver = &amp;quot;symphony&amp;quot;, control = list(verbosity = -1,time_limit = 500)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{\max} x_{i,j,k}\cdot \sum_{j,k} Conf_{k}\cdot Restr_{j} \ \ \ \forall i,j,k$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Data Info&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Operating Hours:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    Hour Mon Tue Wed Thu Fri Sat Sun&#xA; 1:    1   1   1   1   1   1   1   1&#xA; 2:    2   1   1   1   1   1   1   1&#xA; 3:    3   1   1   1   1   1   1   1&#xA; 4:    4   1   1   1   1   1   1   1&#xA; 5:    5   1   1   1   1   1   1   1&#xA; 6:    6   0   0   0   0   0   0   1&#xA; 7:    7   0   0   0   0   0   0   1&#xA; 8:    8   0   0   0   0   0   0   1&#xA; 9:    9   0   0   0   0   0   0   1&#xA;10:   10   0   0   0   0   0   0   1&#xA;11:   11   0   0   0   0   0   0   1&#xA;12:   12   1   1   1   1   0   0   1&#xA;13:   13   1   1   1   1   0   0   1&#xA;14:   14   1   1   1   1   0   0   1&#xA;15:   15   1   1   1   1   0   0   1&#xA;16:   16   1   1   1   1   0   0   1&#xA;17:   17   1   1   1   1   0   0   1&#xA;18:   18   1   1   1   1   0   0   1&#xA;19:   19   1   1   1   1   0   0   1&#xA;20:   20   1   1   1   1   0   0   1&#xA;21:   21   1   1   1   1   0   0   1&#xA;22:   22   1   1   1   1   0   0   1&#xA;23:   23   1   1   1   1   1   1   1&#xA;24:   24   1   1   1   1   1   1   1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What I see is that the problem is really heavy, even model building is highly time consuming. What I have not figure out yet is how is that even possible to define a configuration-based charging. If configuration starts with 1's then the charging should take place in the previous day's configuration. And if we set different charging properties due to the load consumption how can this be formulated. Charging may last longer in the noon where light and A/C are on and capacity remains the same, then charging may last 2-3 hours. Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="3463" LastEditorUserId="3463" LastEditDate="2020-07-06T15:26:46.347" LastActivityDate="2020-07-06T15:26:46.347" Title="Operation hours optimization for circular schedule" Tags="|optimization|mixed-integer-programming|integer-programming|constraint-programming|scheduling|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4438" PostTypeId="2" ParentId="4432" CreationDate="2020-06-25T15:42:54.480" Score="3" Body="&lt;p&gt;Formulation (7) on p. 6 of the linked paper is very explicitly linear in the matrix variable &lt;code&gt;M&lt;/code&gt; and the newly introduced matrix variable &lt;code&gt;V&lt;/code&gt;. MIDCP systems, such as CVXPY (CVX and others) allow programs which are DCP compliant but for binary or integer constraints. Formulation (7) falls into that category, and is just a &amp;quot;plain Jane&amp;quot; MILP; therefore is easily entered into any such system.&lt;/p&gt;&#xA;&lt;p&gt;Perhaps you are trying to explicitly include the first half of equation (6)&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V_{ijab} = M_{ia}M_{jb}$$&lt;/span&gt; as a constraint or expression assignment in CVXPY. Do NOT do that. Declare both &lt;code&gt;M&lt;/code&gt; and &lt;code&gt;V&lt;/code&gt; as matrix variables, and include only the objective function and constraints in (7). The last constraint in (7) is the last half of equation (6), and is how the first half of equation (6) gets enforced in the optimization problem formulation (7). That is because as equation (6) shows, the last constraint in (7) is equivalent to the first half of equation (6).&lt;/p&gt;&#xA;&lt;p&gt;Your apparent mistake is very similar to one I addressed in my answer at &lt;a href=&quot;https://scicomp.stackexchange.com/questions/27206/imposing-special-structure-on-positive-semi-definite-matrix/27207#27207&quot;&gt;https://scicomp.stackexchange.com/questions/27206/imposing-special-structure-on-positive-semi-definite-matrix/27207#27207&lt;/a&gt; . In that question, the O.P. violated DCP rules when entering a semdefinite relaxation of a non-convex quadratic constraint, by making the mistake of entering the original non-convex quadratic constraint in addition to the semidefinite constraint, which was its convex relaxation.&lt;/p&gt;&#xA;&lt;p&gt;To address @Richard 's comment: The paper incorrectly refers to (7) as being a Linear Programming problem (LP). It is not; it is a Mixed-Integer Linear Programming problem (MILP); actually, it is a pure Binary (Integer) LP, because there are no continuous variables. MILP 's fall within the MIDCP rules, which CVXPY supports.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-09-01T19:49:04.303" LastActivityDate="2020-09-01T19:49:04.303" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4440" PostTypeId="1" AcceptedAnswerId="4441" CreationDate="2020-06-26T02:13:47.827" Score="2" ViewCount="54" Body="&lt;p&gt;I am trying to define an edge set as follows: &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}=\{(i,j)|i,j\in\mathcal{V}\land T_{ij}\leq R \land \text{$i$ and $j$ are not jointly in $\mathcal{K}$\}}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{V}$&lt;/span&gt; is the set of vertices, &lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}$&lt;/span&gt; is a subset of vertices &lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}\subset\mathcal{V}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$T_{ij}$&lt;/span&gt; is the travel time between &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; is a travel time threshold. So, I would like to create an edge including all edges satisfying the travel time condition and &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; cannot be both in &lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}$&lt;/span&gt; at the same time. To better convey, if &lt;span class=&quot;math-container&quot;&gt;$i\in\mathcal{K}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j\in\mathcal{K}$&lt;/span&gt;, regardless of the travel time condition (&lt;span class=&quot;math-container&quot;&gt;$T_{ij}\leq R$&lt;/span&gt;), &lt;span class=&quot;math-container&quot;&gt;$(i,j)\notin\mathcal{E}$&lt;/span&gt;. How can I properly write this notation?&lt;/p&gt;&#xA;&lt;p&gt;While writing the question, I realized the following can be right, can it?  &lt;span class=&quot;math-container&quot;&gt;$\mathcal{E}=\{(i,j)|i,j\in\mathcal{V}\land T_{ij}\leq R\}\setminus\{(i,j)|i,j\in\mathcal{V}\land i,j\in\mathcal{K}\}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="518" LastActivityDate="2020-06-26T02:20:43.077" Title="How to properly define an edge set with an uncommon condition" Tags="|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4441" PostTypeId="2" ParentId="4440" CreationDate="2020-06-26T02:20:43.077" Score="4" Body="&lt;p&gt;Yes, that looks correct, although you can simplify a bit because &lt;span class=&quot;math-container&quot;&gt;$\mathcal{K} \subset \mathcal{V}$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\mathcal{E}=\{(i,j)|i,j\in\mathcal{V}\land T_{ij}\leq R\} \setminus &#xA;\{(i,j)|i,j\in\mathcal{K}\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here are two other ways:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\mathcal{E}=\{(i,j)|i,j\in\mathcal{V}\land T_{ij}\leq R\land \neg(i\in\mathcal{K} \land j\in\mathcal{K})\}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\mathcal{E}=\{(i,j)|i,j\in\mathcal{V}\land T_{ij}\leq R\land (i\notin\mathcal{K} \lor j\notin\mathcal{K})\}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-06-26T02:20:43.077" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4443" PostTypeId="1" AcceptedAnswerId="4444" CreationDate="2020-06-26T20:02:36.727" Score="4" ViewCount="588" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; be an integer variable that takes the values &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; be binary variables.&lt;/p&gt;&#xA;&lt;p&gt;I want to express the two following logical constraints:&lt;/p&gt;&#xA;&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$x=2$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y_1=1$&lt;/span&gt;&#xA;if &lt;span class=&quot;math-container&quot;&gt;$x=3$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y_2=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;That's all. I have looked around here but usually the constraints are inequalities or continuous variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have come up with the following solutions:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$-1y_1=(x-1)(x-3)$&lt;/span&gt;&lt;br /&gt;&#xA;when &lt;span class=&quot;math-container&quot;&gt;$x=1 \rightarrow y_1=0$&lt;/span&gt;,&lt;br /&gt;&#xA;when &lt;span class=&quot;math-container&quot;&gt;$x=3 \rightarrow y_1=0$&lt;/span&gt;,&lt;br /&gt;&#xA;when &lt;span class=&quot;math-container&quot;&gt;$x=2 \rightarrow y_1=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$2y_2=(x-1)(x-2)$&lt;/span&gt;&lt;br /&gt;&#xA;when &lt;span class=&quot;math-container&quot;&gt;$x=1 \rightarrow y_2=0$&lt;/span&gt;,&lt;br /&gt;&#xA;when &lt;span class=&quot;math-container&quot;&gt;$x=2 \rightarrow y_2=0$&lt;/span&gt;,&lt;br /&gt;&#xA;when &lt;span class=&quot;math-container&quot;&gt;$x=3 \rightarrow y_2=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It breaks the linearity, but the constraints are in a Mixed Integer Nonlinear Programming problem.&lt;/p&gt;&#xA;&lt;p&gt;Could be that a valid solution?&lt;/p&gt;&#xA;" OwnerUserId="3797" LastEditorUserId="491" LastEditDate="2021-04-14T15:10:55.447" LastActivityDate="2021-04-14T15:10:55.447" Title="Indicator function in math programming" Tags="|modeling|integer-programming|indicator-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4444" PostTypeId="2" ParentId="4443" CreationDate="2020-06-26T20:14:57.793" Score="7" Body="&lt;p&gt;Introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$y_0$&lt;/span&gt; and linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_0 + y_1 + y_2 &amp;amp;= 1\\&#xA;1y_0 + 2y_1 + 3y_2 &amp;amp;= x&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Equivalently, eliminating &lt;span class=&quot;math-container&quot;&gt;$y_0$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_1 + y_2 &amp;amp;\le 1\\&#xA;1 + y_1 + 2y_2 &amp;amp;= x&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-06-26T20:14:57.793" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4445" PostTypeId="1" CreationDate="2020-06-26T22:16:44.073" Score="8" ViewCount="94" Body="&lt;p&gt;I teach a &lt;strong&gt;discrete-event system simulation course&lt;/strong&gt; in &lt;strong&gt;Fall 2020.&lt;/strong&gt; As with most DES simulation courses, students have term projects that involve gathering real-world data and building stochastic input models that they can use to do a simulation study of the system.&lt;/p&gt;&#xA;&lt;p&gt;In the past, students would frequently choose to study the operations of local restaurants (for example) or traffic intersections, primarily because the data was easy to gather. This fall, due to COVID-19, I am uncomfortable asking them to do this. Furthermore, some students may be attending from remote, and the local data sources may not be as rich as they usually are.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;So I am looking for alternatives.&lt;/strong&gt; For example, I have considered some of the many repositories of webcam's on the Internet that might be observed. I would like to avoid generating synthetic data; I would especially like to avoid students generating synthetic data (and then having to do input models of the data they just generated). There are simulation competitions (such as IISE/Arena), but I do not think it is feasible to have the whole class work on the same competition/competitions (and last year's IISE/Arena competition provided input models for the students, which meant that students choosing that experience were able to skip a major component of simulation modeling).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Does anyone here have any suggestions for real-world simulation activities appropriate for term projects for small groups of students who might be attending class virtually?&lt;/strong&gt; Again, the goal is to not ask them to subject themselves to additional exposure risk just to complete the project.&lt;/p&gt;&#xA;" OwnerUserId="3798" LastActivityDate="2020-06-27T20:50:02.850" Title="Alternatives for real-world data collection in simulation courses for Fall 2020" Tags="|simulation|academia|teaching|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4446" PostTypeId="2" ParentId="4445" CreationDate="2020-06-27T00:41:41.540" Score="3" Body="&lt;p&gt;Many real-world datasets can be found using the google search engine dedicated to the dataset search in &lt;a href=&quot;https://datasetsearch.research.google.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; web address. For example, you can use the datasets about the airports instead of restaurants, or you can search for &lt;em&gt;'Simulation Data'&lt;/em&gt; to find interesting datasets ready to be used in a simulation project.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-06-27T00:41:41.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4447" PostTypeId="2" ParentId="4445" CreationDate="2020-06-27T20:50:02.850" Score="4" Body="&lt;p&gt;Someone recently pointed me to a &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/mksc.1080.0402&quot; rel=&quot;nofollow noreferrer&quot;&gt;journal article&lt;/a&gt; about the movement of shoppers in a supermarket. A point of interest is that markets apparently use RFID technology to track shopper movements. If you could get a market (or market chain) to provide you with anonymized movement data and maybe store layouts, you might be able to have the students simulate something related to shoppers. I'm particularly curious whether the one-way lanes instituted in stores actually reduce COVID transmission (because you are less likely to pass someone face to face), increase it (because obeying the rules means rolling the cart over extra distances to get to the end of an aisle where you are allowed to enter) or neither.&lt;/p&gt;&#xA;&lt;p&gt;An &lt;a href=&quot;https://pubsonline.informs.org/do/10.1287/orms.2020.03.11p/full/&quot; rel=&quot;nofollow noreferrer&quot;&gt;episode&lt;/a&gt; of the INFORMS Resounding Human podcast dealt with using simulation models to help hospitals develop policies for diverting/reassigning beds and personnel when something happens (such as a cluster of COVID patients needing care). I suspect that you could get information on department sizes, bed counts and ballpark arrival rates either from some local hospital or from an academic who studies hospital management. The students could then experiment with &amp;quot;shocks&amp;quot; to the system where either you or they could arbitrarily pick parameter values within reason. For instance, what is a good response to an increase of 2 COVID patients per day, or an increase of 10 per day, or an outbreak of the seasonal flu, or a mass casualty event?&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-06-27T20:50:02.850" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4449" PostTypeId="1" AcceptedAnswerId="4451" CreationDate="2020-06-28T10:30:58.733" Score="23" ViewCount="4759" Body="&lt;p&gt;I would like to know whether stochastic optimization and robust optimization are the same and if not, what is the main difference between them. I did an Internet search and I found the following conversation:&#xA;&lt;a href=&quot;https://www.quora.com/What-are-the-main-differences-between-stochastic-optimization-and-robust-optimization&quot; rel=&quot;noreferrer&quot;&gt;https://www.quora.com/What-are-the-main-differences-between-stochastic-optimization-and-robust-optimization&lt;/a&gt;&#xA;Here some say it is in fact the same and others say it is not.&lt;/p&gt;&#xA;&lt;p&gt;My guess would be that in stochastic optimization the distribution of input parameters are known or can be estimated while in robust optimization this is generally not the case. At least you do not use random variables with certain distributions when defining the optimization problem. The goal of robust optimization is that the solutions should remain feasible even if the input parameters of the model vary.&lt;/p&gt;&#xA;&lt;p&gt;I know from Wikipedia (&lt;a href=&quot;https://en.wikipedia.org/wiki/Robust_optimization&quot; rel=&quot;noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Robust_optimization&lt;/a&gt;) that there is also something called &amp;quot;Probabilistically robust optimization models&amp;quot;. This can be basically regarded as stochastic optimization so the borders between stochastic and robust optimization are not fully clear.&lt;/p&gt;&#xA;&lt;p&gt;What are your takes on that?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="491" LastEditDate="2021-02-23T14:43:40.183" LastActivityDate="2021-08-04T14:14:36.333" Title="Difference between stochastic optimization and robust optimization" Tags="|stochastic-programming|robust-optimization|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4450" PostTypeId="2" ParentId="4418" CreationDate="2020-06-28T17:27:13.047" Score="2" Body="&lt;p&gt;You could try using Z3, like so:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;#!/usr/bin/env python3&#xA;&#xA;import itertools&#xA;&#xA;import pandas as pd&#xA;import z3&#xA;&#xA;#Read data&#xA;df   = pd.read_csv('constraints.csv')&#xA;dfTA = pd.read_csv('ta_timezone.csv')&#xA;dfS  = pd.read_csv('student_timezone.csv')&#xA;&#xA;problem = z3.Solver()&#xA;&#xA;number_of_students  = 1974&#xA;number_of_tas       = 187&#xA;number_of_timeslots = 9&#xA;&#xA;student_to_ta = []&#xA;for i in range(number_of_students):&#xA;  temp = z3.Int(f&amp;quot;S_{i}&amp;quot;)&#xA;  student_to_ta.append(temp)&#xA;  problem.add(0&amp;lt;=temp)&#xA;  problem.add(temp&amp;lt;number_of_tas)&#xA;&#xA;#Assign TAs to timeslots&#xA;ta_to_timeslot = []&#xA;for i in range(number_of_tas):&#xA;  temp = z3.Int(f&amp;quot;TA_{i}&amp;quot;)&#xA;  ta_to_timeslot.append(temp)&#xA;  problem.add(0&amp;lt;=temp)&#xA;  problem.add(temp&amp;lt;number_of_timeslots)&#xA;  for t in range(number_of_timeslots): #TA must like this time slot&#xA;    problem.add(z3.Implies(temp==t, bool(dfTA.iloc[i,t]&amp;gt;0)))&#xA;&#xA;#Assign students to TAs&#xA;for s, ta, t in itertools.product(range(0,number_of_students), range(0,number_of_tas), range(number_of_timeslots)):&#xA;  #If (student is assigned to TA and TA is assigned to this timeslot) then (student must like this time slot)&#xA;  problem.add(z3.Implies(z3.And(student_to_ta[s]==ta, ta_to_timeslot[ta]==t), bool(dfS.iloc[s,1+t]&amp;gt;0)))&#xA;&#xA;if problem.check()!=z3.sat:&#xA;  print(&amp;quot;Problem could not be solved!&amp;quot;)&#xA;else:&#xA;  solution = problem.model()&#xA;  print(&amp;quot;Students to TAs: &amp;quot;, [solution[x] for x in student_to_ta])&#xA;  print(&amp;quot;TAs to Timeslots: &amp;quot;, [solution[x] for x in ta_to_timeslot])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, the problem is big and Python is slow, so this formulation may also be problematic. Moving to C++ might be a more robust option for a problem of this size. I'd suggest Julia, but its Z3 package is 5 years old and doesn't work any more.&lt;/p&gt;&#xA;" OwnerUserId="886" LastActivityDate="2020-06-28T17:27:13.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4451" PostTypeId="2" ParentId="4449" CreationDate="2020-06-28T20:33:20.870" Score="15" Body="&lt;p&gt;I think there is no single, uniformly accepted answer. But there are two main factors that distinguish them:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;In stochastic optimization, it is nearly always assumed that we know the probability distribution (possibly in the form of discrete probabilities of each scenario) of the random parameters. In robust optimization it is usually (but not always) assumed that we do not know the distribution.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In stochastic optimization, the goal is usually to optimize the expected value of the objective function (min expected cost, max expected profit, etc.). In robust optimization, because we don't know the probabilities, we instead optimize some other measure. Common measures are to optimize the worst-case outcome -- e.g., minimize the maximum cost, maximize the minimum profit, etc. -- sometimes over only a subset of the possible scenarios. There are lots of other common objectives, too.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Although it's often true that in robust optimization feasibility is required in every scenario, this is often true in stochastic optimization, as well, so I wouldn't consider this to be a major distinguishing factor.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-06-28T20:33:20.870" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4452" PostTypeId="2" ParentId="4449" CreationDate="2020-06-29T11:00:34.517" Score="4" Body="&lt;p&gt;As Larry said, there is no single, uniformly accepted answer, so I'll make things even more interesting. In mechanical engineering, specifically in aircraft design where I used to work, we used the following terminology:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Stochastic optimisation was to solve problems using any non-deterministic methods, e.g., particle swarm algorithms or evolutionary algorithms.&lt;/li&gt;&#xA;&lt;li&gt;Robust optimisation was to optimise for stability, i.e., to minimise the second derivatives of certain flow properties so that wings will behave roughly the same even under fluctuating conditions. The tradeoff for that was huge in other nominal properties of the aircraft such as range, weight, maximum speed, etc. This is solved as a multiobjective problem.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;What's fascinating here is that we can really see how in different fields we adapt terminology depending on the nature of the problems we are solving. In aircraft design, computational cost is orders of magnitude beyond most OR problems, e.g., a single evaluation of &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; for the flow equations could take 1-2 &lt;strong&gt;weeks&lt;/strong&gt;. Thus, the term &amp;quot;robust&amp;quot; that we use to describe simulating multiple scenarios in other OR fields becomes meaningless because it's impossible to do that. Nevertheless, the concept of &amp;quot;robustness&amp;quot; is universal, so people still use the term, just in a way that is meaningful for the use-case.&lt;/p&gt;&#xA;&lt;p&gt;It's also quite interesting that these are possibly the original meanings of these terms as, historically, aircraft design was among the very first real-world applications of optimisation methods.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-06-29T11:00:34.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4453" PostTypeId="2" ParentId="4418" CreationDate="2020-06-29T11:10:18.240" Score="2" Body="&lt;p&gt;The problem here is that you are generating way more variables &amp;amp; functions than Pyomo can normally handle. However, I am guessing that you don't strictly &lt;em&gt;need&lt;/em&gt; all of them, i.e., it's possible that there is inherent sparsity and/or symmetry in the problem that you are not exploiting. My suggestion would be do add &lt;code&gt;if&lt;/code&gt; statements in your definitions to skip the generations of variables &amp;amp; functions that are redundant.&lt;/p&gt;&#xA;&lt;p&gt;If that is not possible in your case, even though Pyomo is great, it does have its limitations so you can try using commercial modelling software such as AMPL, which would most likely blaze through that problem.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-06-29T11:10:18.240" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4454" PostTypeId="1" AcceptedAnswerId="4455" CreationDate="2020-06-29T14:27:23.440" Score="6" ViewCount="97" Body="&lt;p&gt;I am working on a project where the customer requested to change the current objective function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; to another function &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; (both linear). It is easy to prove that &lt;span class=&quot;math-container&quot;&gt;$f \le g$&lt;/span&gt; and as both are linear funcions &lt;strong&gt;my guess&lt;/strong&gt; is that the hyperplane each define are parallel so there is no need to replace the current objective function to &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; as the solution to the problem should be the same. Is this right?&lt;/p&gt;&#xA;" OwnerUserId="3804" LastEditorUserId="36" LastEditDate="2020-06-29T14:40:35.697" LastActivityDate="2020-06-29T16:54:08.217" Title="Can I replace the objective function $f$ with $g$ if $g \ge f$?" Tags="|linear-programming|modeling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4455" PostTypeId="2" ParentId="4454" CreationDate="2020-06-29T16:54:08.217" Score="6" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$g=f+c$&lt;/span&gt; for some constant &lt;span class=&quot;math-container&quot;&gt;$c \ge 0$&lt;/span&gt;, then the optimal solutions will be the same, and this does not depend on linearity of either function.  But if &lt;span class=&quot;math-container&quot;&gt;$f \le g$&lt;/span&gt; just in the feasible region and maybe not elsewhere, optimizing &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is not necessarily equivalent to optimizing &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-06-29T16:54:08.217" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4456" PostTypeId="1" AcceptedAnswerId="5827" CreationDate="2020-06-29T18:23:45.993" Score="1" ViewCount="152" Body="&lt;p&gt;The problem below aims to find the minimum cost for the network architecture:&lt;/p&gt;&#xA;&lt;p&gt;We want to build a network where client terminals are connected to servers by cabling which is very expensive. The network architecture should be designed to minimize the total cost of the cabling used.&lt;/p&gt;&#xA;&lt;p&gt;It is assumed that &lt;span class=&quot;math-container&quot;&gt;$T=\{T_1,\ldots,T_n\}$&lt;/span&gt; is the set of terminals. Cabling costs are known.&lt;/p&gt;&#xA;&lt;p&gt;Show that it is possible to model this problem with a graph theory tool.&lt;/p&gt;&#xA;&lt;p&gt;Can someone please help to initialize and how to process to solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="3806" LastEditorUserId="123" LastEditDate="2020-06-29T19:03:48.997" LastActivityDate="2021-03-01T16:42:15.120" Title="Find minimum cost problem" Tags="|optimization|graphs|network-flow|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4457" PostTypeId="1" CreationDate="2020-06-29T18:50:11.270" Score="4" ViewCount="95" Body="&lt;p&gt;It is well-known that when we maximize a 1-norm, e.g., &lt;span class=&quot;math-container&quot;&gt;$\|Ax\|_1$&lt;/span&gt;, we can use binary variables and obtain a mixed-integer convex problem (otherwise maximizing 1-norm is non-convex). I am mentioning this in a report, but I need a reference. I checked YALMIP logical programming post on &lt;a href=&quot;https://yalmip.github.io/tutorial/logicprogramming/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; page, it is relevant but not fully the same.&lt;/p&gt;&#xA;&lt;p&gt;Do you know which source I can cite? I am using YALMIP to solve such a problem, and it automatically reformulates as explained.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="123" LastEditDate="2020-06-29T19:04:31.613" LastActivityDate="2020-06-30T02:18:57.307" Title="Maximizing 1-norm: using binary variables to relax non-convexity" Tags="|reference-request|binary-variable|logical-constraints|nonconvex-programming|yalmip|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4458" PostTypeId="2" ParentId="3952" CreationDate="2020-06-29T23:53:08.767" Score="3" Body="&lt;p&gt;Since Python is dominant in the industry, pyomo gained its popularity.&#xA;I personally prefer the JuMP's implementation.&#xA;Check these&#xA;&lt;a href=&quot;https://medium.com/@vanstark88/construction-speed-in-popular-open-source-math-modeling-tools-712fd841fc50&quot; rel=&quot;nofollow noreferrer&quot;&gt;Constrction Speed&lt;/a&gt;&#xA;&lt;a href=&quot;https://github.com/shuaiwang88/optimization_modeling_class_using_R_Pyomo&quot; rel=&quot;nofollow noreferrer&quot;&gt;R and Python Modeling&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For R users, I recently used a package &lt;a href=&quot;https://github.com/dirkschumacher/ompr&quot; rel=&quot;nofollow noreferrer&quot;&gt;OMPR&lt;/a&gt; with CBC solver in the production environment.&lt;/p&gt;&#xA;&lt;p&gt;It works well if your model is relatively small. The author is trying to make it faster.&lt;/p&gt;&#xA;" OwnerUserId="1219" LastEditorUserId="1219" LastEditDate="2020-06-29T23:58:40.807" LastActivityDate="2020-06-29T23:58:40.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4459" PostTypeId="1" CreationDate="2020-06-30T00:13:27.997" Score="2" ViewCount="57" Body="&lt;p&gt;Let's say an online-only retailer (specialized market/without own brand) trying to play with the price of the product.&lt;/p&gt;&#xA;&lt;p&gt;If only matching amazon's price, it might end up not making much profit, since the cost from the vendor is higher than amazon's.&lt;/p&gt;&#xA;&lt;p&gt;Are traditional approaches such as Thomson Sampling still useable for this case? I guess the discrete price (Multi-Armband) is within 30 cents (10 cents -/+) based on amazon's.&lt;/p&gt;&#xA;&lt;p&gt;I've heard of pricing based on customer demographic(ex, mac users pay more).&lt;/p&gt;&#xA;&lt;p&gt;One stragey I can think of is: if it's priced cheaper, it might have chances to get more customers?&lt;/p&gt;&#xA;&lt;p&gt;What are the different strategies or objectives out there?&lt;/p&gt;&#xA;" OwnerUserId="1219" LastActivityDate="2020-06-30T00:13:27.997" Title="dynamic pricing considering competitor's price" Tags="|revenue|pricing|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4460" PostTypeId="2" ParentId="4457" CreationDate="2020-06-30T02:18:57.307" Score="5" Body="&lt;p&gt;Provide the standard citation for YALMIP&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@inproceedings{Lofberg2004,&#xA;address = {Taipei, Taiwan},&#xA;author = {L{\&amp;quot;{o}}fberg, J.},&#xA;booktitle = {In Proceedings of the CACSD Conference},&#xA;title = {YALMIP : A Toolbox for Modeling and Optimization in MATLAB},&#xA;year = {2004}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which is shown at &lt;a href=&quot;https://yalmip.github.io/reference/lofberg2004/&quot; rel=&quot;noreferrer&quot;&gt;https://yalmip.github.io/reference/lofberg2004/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then perhaps you can also reference the relevant YALMIP wiki page for your problem, namely &lt;a href=&quot;https://yalmip.github.io/tutorial/logicprogramming/&quot; rel=&quot;noreferrer&quot;&gt;YALMIP Logics and integer-programming representations&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-06-30T02:18:57.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4461" PostTypeId="1" AcceptedAnswerId="4468" CreationDate="2020-06-30T03:57:42.090" Score="5" ViewCount="610" Body="&lt;p&gt;I am trying to linearize the constraint set (2) in the following simplified program. The parameters: &lt;span class=&quot;math-container&quot;&gt;$A,C,D,T\in\mathbb{R}^+$&lt;/span&gt;. The set &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}$&lt;/span&gt; is polynomially-sized.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2\min &amp;amp;\quad \sum_{j\in\mathcal{J}}\left(Cb_j+D\lambda_j\right)\tag1\\&#xA;\text{s.t.}&amp;amp;\quad b_j\geq T\lambda_j+A\sqrt{T\lambda_j}\qquad j\in\mathcal{J}\tag2\\&#xA;&amp;amp;\quad \lambda_j,b_j\in \mathbb{R}^+.\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Seeing &lt;a href=&quot;https://or.stackexchange.com/questions/1052/linearize-or-approximate-a-square-root-constraint&quot;&gt;this post&lt;/a&gt; and the McCormick Envelope, I tried to implement it but did not seem to work as expected. Can you please help me debug where I am doing wrong? First, I re-write (2) as &lt;span class=&quot;math-container&quot;&gt;$b_j\geq T\lambda_j+Ae_j$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$e_j=\sqrt{T\lambda_j}$&lt;/span&gt;. Then, squaring both sides, I get &lt;span class=&quot;math-container&quot;&gt;$f_j=T\lambda_j$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$f_j=e_j^2$&lt;/span&gt;. Under these conditions and assuming &lt;span class=&quot;math-container&quot;&gt;$-M_j\leq e_j \leq M_j$&lt;/span&gt;, I replace (2) with the following set of constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}2 &amp;amp;\quad b_j\geq T\lambda_j+Ae_j\qquad j\in\mathcal{J}\tag3\\&#xA;&amp;amp;\quad M_je_j\geq f_j\qquad j\in\mathcal{J}\tag4\\&#xA;&amp;amp;\quad f_j\geq T\lambda_j\qquad j\in\mathcal{J}\tag5\\&#xA;&amp;amp;\quad M_j^2\geq f_j\qquad j\in\mathcal{J}\tag6\\&#xA;&amp;amp;\quad f_j\geq 2M_je_j-M_j^2\qquad j\in\mathcal{J}\tag7\\&#xA;&amp;amp;\quad e_j\leq M_j\qquad j\in\mathcal{J}\tag8\\&#xA;\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Although I defined &lt;span class=&quot;math-container&quot;&gt;$M_j$&lt;/span&gt;, I cannot define a strict big number for a specific index &lt;span class=&quot;math-container&quot;&gt;$j\in\mathcal{J}$&lt;/span&gt;. So, I assume &lt;span class=&quot;math-container&quot;&gt;$M=M_j$&lt;/span&gt;. Moreover, I use Gurobi to solve this problem and I am open to a quadratic constraint. Indeed, I also tried defining &lt;span class=&quot;math-container&quot;&gt;$e_j e_j \geq T\lambda_j$&lt;/span&gt; in Gurobi and it also did not work. I assume I made a mistake in that definition.&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="518" LastEditDate="2020-06-30T16:37:25.740" LastActivityDate="2020-06-30T17:47:46.897" Title="Linearizing a constraint with square root of a variable" Tags="|linear-programming|linearization|mccormick|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4462" PostTypeId="1" AcceptedAnswerId="4466" CreationDate="2020-06-30T09:44:39.480" Score="6" ViewCount="1289" Body="&lt;p&gt;So I noticed, that a lot of students taking OR-classes come from non-computer science backgrounds (e.g. buissiness administration). They typically had only one other class in their first semester where they had to write (typically java) code, and therefore their code is very &amp;quot;hacky&amp;quot;. It works, but I wouldn't want to hire them as software devellopers, or have them write code that actually is used anywhere and needs to be maintained.&lt;/p&gt;&#xA;&lt;p&gt;So my questions would be:&lt;/p&gt;&#xA;&lt;p&gt;a) Is the expectation for entry level positions, that the applicant is able to produce high quality code, or is that something that would be learned on the job?&lt;/p&gt;&#xA;&lt;p&gt;b) What are some good self-study resources to improve the quality of code I can recommend to my students?&lt;/p&gt;&#xA;&lt;p&gt;c) Are there some reference codes, that would be good examples for high quality code?&lt;/p&gt;&#xA;" OwnerUserId="405" LastActivityDate="2020-07-01T12:24:49.927" Title="How to improve the quality of code in OR?" Tags="|reference-request|software|or-careers|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4463" PostTypeId="2" ParentId="4462" CreationDate="2020-06-30T10:09:51.963" Score="5" Body="&lt;p&gt;I can really only answer one point:&lt;/p&gt;&#xA;&lt;p&gt;b) Clean Code: A Handbook of Agile Software Craftsmanship&#xA;I think the examples in the book are even for Java, but it is applicable for other languages as well. (This is the entry book, there are follow up books in this series)&lt;/p&gt;&#xA;&lt;p&gt;What helped me a lot is taking a piece of code i have written and then taking one concept of the book like &amp;quot;a function should only have one purpose&amp;quot; and then refactoring this code and then comparing the two versions. With time you do more of the stuff immediately.&lt;/p&gt;&#xA;&lt;p&gt;What i think is important is that you do not only read books or other code, but you need to do this for you own code.&lt;/p&gt;&#xA;&lt;p&gt;It is also important to tell the students, that you often first write code that works, but is not really of good maintainble quality and then you do a refactoring to make it more maintainable/better readable. This second step is something that requires discipline, because the code already works and there are only immediate costs involved in refactoring, but it bites back in the long run if you don't do it.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="3305" LastEditDate="2020-06-30T10:18:05.603" LastActivityDate="2020-06-30T10:18:05.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4464" PostTypeId="2" ParentId="4462" CreationDate="2020-06-30T10:57:48.643" Score="9" Body="&lt;p&gt;Unfortunately writing high quality OR code is beyond the reach of most academic settings. This is mainly because:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Writing high quality code is very time consuming.&lt;/li&gt;&#xA;&lt;li&gt;The scope of OR code is much better suited to teams of people rather than a lone wolf trying to do everything alone.&lt;/li&gt;&#xA;&lt;li&gt;Because it's time consuming, there's never enough time in academia to do this properly, as priorities are different (publish or perish).&lt;/li&gt;&#xA;&lt;li&gt;Academia is a place to learn by doing things wrong. Industry is the place we go to after we've learned stuff.&lt;/li&gt;&#xA;&lt;li&gt;Production code is the domain of professional developers. I thought I was pretty good at coding after my PhD, and all my developers put me to shame. Most of them are 10 years younger than me.&lt;/li&gt;&#xA;&lt;li&gt;In most academic groups, even if a person who does things properly shows up from time to time their know-how leaves the group when they do.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Academia really needs to move away from the notion that a talented student can  just &amp;quot;do things&amp;quot; alone. This is simply not true in software in any production setting. People need teams, support, infrastructure, and senior leads to guide development.&lt;/p&gt;&#xA;&lt;p&gt;The remedy would be for academic groups to start employing professional developers full-time to support the researchers. This would have the nice side effect of training them to do things properly while they do research.&lt;/p&gt;&#xA;&lt;p&gt;All this means that requirements are not really high from a coding point of view. This is dangerous because supervisors tend to accept candidates who simply don't have the background to do the work necessary. My advice for entry-level applicants is to really look into who is in the group, and how long the people who know what they're doing are going to be there after you join. If they don't have a computer science background they should be prepared to do a lot of work to catch up if you want to write good code.&lt;/p&gt;&#xA;&lt;p&gt;A red flag is if the group doesn't have a repository to inherit code between students. If they have code, people should read that code before they join. Does the group have continuous integration? Does the code have unit tests? Are there 15 forks or does everything eventually get merged into the master branch? Is there a person responsible for maintaining the codebase? Who is that person? If they leave, are there plans to replace them?&lt;/p&gt;&#xA;&lt;p&gt;My experience is that unless new applicants can get good answers to such questions the group is unlikely to have the culture to provide the support people need to write high-quality code.&lt;/p&gt;&#xA;&lt;p&gt;For industrial entry-level positions it depends on the company - for instance at Octeract we have very high standards for C++, but we also don't have entry-level positions. We still do a lot of training, but mostly on advanced things.&lt;/p&gt;&#xA;&lt;p&gt;Commercial solvers are of course not the only applications of OR, in other settings standards are lower and entry-level jobs are available.&lt;/p&gt;&#xA;&lt;p&gt;The best open source OR code I've seen is &lt;a href=&quot;https://github.com/minotaur-solver/minotaur&quot; rel=&quot;noreferrer&quot;&gt;MINOTAUR&lt;/a&gt;, but even that is a far cry from production-level OR code.&lt;/p&gt;&#xA;&lt;p&gt;Good resources for students are predominantly to start using the tooling we use in the industry. They should learn how to use Git, Jenkins, and the Clang tools. They should read the Google style guide on how to format code properly. The should learn how to use static analysis tools, profilers, and Valgrind to diagnose the state of their code. They should get into the habit of writing unit tests for their code (Catch! is a good testing framework for C++). They should use Doxygen to automatically map and document the codebase.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-06-30T10:57:48.643" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4466" PostTypeId="2" ParentId="4462" CreationDate="2020-06-30T15:23:32.313" Score="8" Body="&lt;p&gt;Disclaimer: I have worked for 3 years as an optimization software developer at a utility company and now work for Gurobi.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Is the expectation for entry level positions, that the applicant is able to produce high quality code, or is that something that would be learned on the job?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There is no expectation because it is often not the case (as Nikos said). However, a candidate who is capable of decent coding is going to have much better chances, as very advanced theoretical knowledge is often not the most important hiring decision. Please encourage your students to have a github profile and post some stuff there; I always looked at that when we got applications in.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;What are some good self-study resources to improve the quality of code I can recommend to my students?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There is a distinction to make here: for general coding the best book in my opinion is &amp;quot;&lt;a href=&quot;https://www.amazon.co.uk/dp/0201633612/ref=as_li_ss_tl?s=books&amp;amp;keywords=design+patterns&amp;amp;language=en_US&amp;amp;sr=1-1&amp;amp;linkCode=gs2&amp;amp;linkId=367fa9e050c9ec6a623e2b0272c03259&amp;amp;tag=daolf0c-21&quot; rel=&quot;nofollow noreferrer&quot;&gt;Design Patterns&lt;/a&gt;&amp;quot; by the Gang of Four. Beyond that, code review is your biggest resource (you can even hire people online for $5), because that way you get feedback from someone else about your code.&lt;/p&gt;&#xA;&lt;p&gt;As for OR-specific code: there are unfortunately no guidelines on this whatsoever. I wrote up some on &lt;a href=&quot;https://www.linkedin.com/pulse/writing-clean-optimization-code-here-some-simple-rules-oberdieck/&quot; rel=&quot;nofollow noreferrer&quot;&gt;LinkedIn&lt;/a&gt; a year or so ago (and writing this up in a book is still on my to-do), but I don't know of anything else. If you come across something, let me know.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Are there some reference codes, that would be good examples for high quality code?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;For general software, just check out GitHub and off you go. You will recognize good code pretty quickly.&lt;/p&gt;&#xA;&lt;p&gt;For OR-specific things, I did not find much (as Nikos said). For fun I implemented the rules I set out publicly in &lt;a href=&quot;https://github.com/RichardOberdieck/BarMeUp_Opt&quot; rel=&quot;nofollow noreferrer&quot;&gt;this repo&lt;/a&gt; about optimizing which drinks to buy for your bar. But it is far from perfect. It should though give an idea of how one can do it.&lt;/p&gt;&#xA;" OwnerUserId="133" LastEditorUserId="36" LastEditDate="2020-07-01T12:24:49.927" LastActivityDate="2020-07-01T12:24:49.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4467" PostTypeId="1" CreationDate="2020-06-30T16:02:54.450" Score="14" ViewCount="227" Body="&lt;p&gt;We often hear that in practice, not enough data of sufficient quality, consistency, recency, etc. is available for feeding into mathematical optimization models. Example: my university wanted to plan/optimize their weekly timetable using an integer program, but they did not know the number of rooms (let alone capacities, availabilities, equipment, location, etc.), they did not know the preferences of professors, nor which courses they actually taught (the system listed them as &amp;quot;responsible&amp;quot; for a course which did not imply that they were actually teaching that course!); they didn't know the number of students to expect in a course. I could contribute a lot of such stories.&lt;/p&gt;&#xA;&lt;p&gt;Now, many companies (truthfully) claim that they collect data. E.g., sensor data from production, temperatures, filling rates, number of faulty products per hour, web clicks, customer orders, energy prices, etc., etc. I can't really grasp what makes we reject such data as &amp;quot;suitable&amp;quot; for optimization, and I am looking for a definition of what &amp;quot;different kind of data&amp;quot; needs to be collected in order to feed a typical mathematical program for e.g., timetabling, production planning, facility layout, or designing tariff zones. I thought for a while that the notion I am looking for is &amp;quot;actionable&amp;quot;, but this doesn't capture it. Ideally, I would like to contrast this &amp;quot;optimization data&amp;quot; to data that is typically fed into machine learning algorithms (which extrapolate, cluster, predict, find trends, anomalies, patterns, etc.).&lt;/p&gt;&#xA;&lt;p&gt;How would you call the number of students in a course, the availabilities of teachers, the capacities of rooms, the data that a course belongs to a certain curriculum?&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="36" LastEditDate="2020-07-04T13:38:14.753" LastActivityDate="2020-08-20T19:51:59.453" Title="How would you characterize &quot;optimization data?&quot;" Tags="|optimization|machine-learning|data|practical-or|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4468" PostTypeId="2" ParentId="4461" CreationDate="2020-06-30T17:47:46.897" Score="3" Body="&lt;p&gt;Define &lt;span class=&quot;math-container&quot;&gt;$\mu_i = \sqrt{\lambda_i}$&lt;/span&gt; and the problem is  a convex quadratically constrained problem in &lt;span class=&quot;math-container&quot;&gt;$(b,\mu)$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2020-06-30T17:47:46.897" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4469" PostTypeId="2" ParentId="4467" CreationDate="2020-06-30T18:09:24.013" Score="7" Body="&lt;p&gt;I would call them decision-relevant data, because most optimization problems in practice help people do decisions better, which they already do in a heuristic fashion. This puts the focus on the decision and what is needed to effectively make this decision.&lt;/p&gt;&#xA;&lt;p&gt;Alternatives would be system-describing data/system-boundary data, because the data defines the boundaries of the feasible states of the system/the boundaries of feasible decision.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand the data in machine learning i would call historical observational data, because you often have observable states of the system from the past.&lt;/p&gt;&#xA;&lt;p&gt;I find it difficult to draw a line, that this data is for optimization and that data is for machine learning, because often data can be used for both.&#xA;In your example with the timetable for the university courses you could for example not have the capacity of each room, but instead the average number of students per room for each day in the last year. This data would at a first glance be rather machine learning data, but you could use it to derive an estimate for the capacity to feed it to your optimization model.&lt;/p&gt;&#xA;&lt;p&gt;I agree that pure observable data is often useless for optimization problems, because you only observe feasible states, but have no data on how much you can deviate from these and what are the effects on the deviation and optimizing is basically putting the system in an unseen state than before.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2020-06-30T19:37:47.343" LastActivityDate="2020-06-30T19:37:47.343" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4470" PostTypeId="1" AcceptedAnswerId="4475" CreationDate="2020-06-30T19:57:35.267" Score="3" ViewCount="107" Body="&lt;p&gt;I need to optimise the end-to-end latency for a multi-service application while distributing it on multiple devices. The application is a series of services interconnected to each other. The goal is to use some online optimisation algorithm to find the optimal cut point in a series of services connected of multi-service application, after the cut point the half part of the collection of services will run on one device and the intermediate result will be sent to another device considering bandwidth and resource capacity of the device, taking into account the modification of the initial assignment to deal with events such as load changes. The input to the algorithm is the latency to execute the services on two different devices, the bandwidth to send the intermediate the result, and application latency to optimise against. The output is the optimal point to divide the application into two different parts.&lt;/p&gt;&#xA;&lt;p&gt;From reading different research papers and the majority of the papers have used deep Reinforcement learning (DRL), I could understand but I am unable to take a start point.  What is the best way to solve the above problem other than using a linear search algorithm that would return the lowest end-to-end latency from the search space? Using linear search only returns the lowest end-to-end latency from the search space while not considering resource constraint or bandwidth constraint. Any help is highly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3811" LastEditorUserId="36" LastEditDate="2020-06-30T21:57:18.890" LastActivityDate="2020-07-01T13:25:33.413" Title="Can Deep RL be used to find optimal division point in an application?" Tags="|optimization|modeling|scheduling|multi-objective-optimization|reinforcement-learning|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4471" PostTypeId="1" CreationDate="2020-07-01T09:36:46.650" Score="6" ViewCount="573" Body="&lt;p&gt;Say that I have a binary IP&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z=\max_x \{c^\top x: Ax=b, x\in B^n\}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$B^n$&lt;/span&gt; is the set of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-dimensional &lt;span class=&quot;math-container&quot;&gt;$0-1$&lt;/span&gt; vectors.&#xA;Its LP relaxation will be&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z^{LP}=\max_x \{c^\top x: Ax=b, 0\leq x\leq 1\}$$&lt;/span&gt;&#xA;I empirically observe that &lt;span class=&quot;math-container&quot;&gt;$z^{LP}=z$&lt;/span&gt; and the LP solves to a binary solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;How can I structure a proof to show that &lt;span class=&quot;math-container&quot;&gt;$z^{LP}=z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x^{LP}\in B^n$&lt;/span&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="8" LastEditDate="2020-07-01T12:19:12.307" LastActivityDate="2020-07-14T19:53:09.047" Title="What is a general procedure to prove that the LP relaxation of an IP delivers the optimal IP solution?" Tags="|linear-programming|integer-programming|lp-relaxation|relaxation|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4473" PostTypeId="2" ParentId="4471" CreationDate="2020-07-01T12:05:46.417" Score="3" Body="&lt;p&gt;If I'm understanding your question properly, this is not true in general. What you can prove is that this can be solved to integrality algorithmically, by adding Gomory cuts. Once enough cuts are added, the optimal vertex of the LP has to give an integer solution.&lt;/p&gt;&#xA;&lt;p&gt;This is known as the &lt;a href=&quot;https://en.wikipedia.org/wiki/Cutting-plane_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;cutting plane method&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In your case, you can use this to show that once no more Gomory cuts can be found, &lt;span class=&quot;math-container&quot;&gt;$z^{LP}$&lt;/span&gt; has to be equal to &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; (this happens much sooner in practice, but for the purposes of a proof it's fine to consider the worst-case scenario).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-07-01T12:46:30.400" LastActivityDate="2020-07-01T12:46:30.400" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4474" PostTypeId="1" AcceptedAnswerId="4483" CreationDate="2020-07-01T12:36:54.760" Score="3" ViewCount="1453" Body="&lt;p&gt;I have an error function &lt;span class=&quot;math-container&quot;&gt;$f : w \rightarrow f(w)$&lt;/span&gt; that I want to minimize, &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; being a vector of length 211. There are some constraints on &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I managed to compute the jacobian &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; and even with it the optimization is quite slow. I think this is due to this : when I print the iteration number in the optimization loop and the value of the error function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, the Python shell shows this :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;number of iteration / value of the error function&#xA;1   0.035415193666127553&#xA;214 0.3451666379304012&#xA;215 0.021196928080386743&#xA;428 0.23868912897157107&#xA;429 0.015584337890888374&#xA;642 0.12928511710763613&#xA;643 0.010336203822412956&#xA;856 0.1488892149935437&#xA;857 0.007432756773027516&#xA;1070 0.14502939575869633&#xA;1071 0.005535691799374814&#xA;... and so on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It seems like the algorithm took 213 iterations to estimate the jacobian and compute the next &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; at each computation of the error function, whereas since I gave it the jacobian of the error function I expected it to directly be able to compute in one iteration only (with the formula of gradient descent for example).&#xA;I guess this slows down the algorithm a lot since the constraints will be tested on a lot more vector weights &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To be more precise, I expected this :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;number of iteration / value of the error function&#xA;1 0.035415193666127553&#xA;2 0.3451666379304012&#xA;3 0.021196928080386743&#xA;4 0.23868912897157107&#xA;5 0.015584337890888374&#xA;6 0.12928511710763613&#xA;7 0.010336203822412956&#xA;8 0.1488892149935437&#xA;9 0.007432756773027516&#xA;10 0.14502939575869633&#xA;11 0.005535691799374814&#xA;...&#xA; and so on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am using the &lt;code&gt;minimize&lt;/code&gt; function from scipy library.&#xA;My dataset &lt;code&gt;data&lt;/code&gt; has the following dataframe format :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Name of the company | Sector of the company | Weight&#xA;       APPLE              TECHNOLOGIES         0.04&#xA;      WALMART            CONSUMER GOODS        0.06&#xA;     MICROSOFT            TECHNOLOGIES         0.03&#xA;       ...                     ...             ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And the constraints are the following :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^{211}w_{i} = 1,$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \forall i, w_{i} \geq 0,$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \forall ~sector, ~w_{sector}^{min} \leq w_{sector} \leq w_{sector}^{max}.$$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$w_{sector} = \sum_{i \in sector}w_{i}$&lt;/span&gt;. This quantity is obtained via the following function :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def get_weight_sectors(w):&#xA;    weight_sectors=pd.Series(index=list_of_all_sectors)&#xA;    for sector in weight_sectors.index:&#xA;        weight_sector=data['Weight'].loc[data['Sector of the company']==sector].sum()&#xA;        weight_sectors.loc[sector]=weight_sector&#xA;    return weight_sectors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So my constraints in the &lt;code&gt;minimize&lt;/code&gt; function are :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def constraint_sum_weights(w,k): #k is the number of the iteration&#xA;    k+=1                         #that allows to keep track within the loop&#xA;    return w.sum()-1.0&#xA;&#xA;def long_only_constraint(w):&#xA;    return w&#xA;&#xA;def constraint_sector_min(w):&#xA;    weight_sectors=get_weight_sectors(w)&#xA;    return weight_sectors-weight_sector_min&#xA;&#xA;def constraint_sector_min(w):&#xA;    weight_sectors=get_weight_sectors(w)&#xA;    return weight_sector_max-weight_sectors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The function to minimize is :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def function_to_minimize(w,k): #k is the number of the iteration&#xA;    #computation of the function&#xA;    f = ...&#xA;    print(k,f)                 #that is what was shown on the Python shell earlier&#xA;    return f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And finally the solving function is :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def find_weight():&#xA;    k=0&#xA;    init=...&#xA;    cons=...&#xA;    res=minimize(function_to_minimize,init,args=(k,),method='SLSQP',jac=jacobian,constraints=cons,tol=1E-4)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3756" LastEditorUserId="3756" LastEditDate="2020-07-02T10:57:23.797" LastActivityDate="2020-07-04T14:50:52.437" Title="SLSQP Optimisation loop takes several iterations to compute error function despite jacobian" Tags="|optimization|constraint|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="4475" PostTypeId="2" ParentId="4470" CreationDate="2020-07-01T13:25:33.413" Score="1" Body="&lt;p&gt;This is a clustering problem, i.e., you want split your services into two clusters, each of which will run on a different device.&lt;/p&gt;&#xA;&lt;p&gt;The way you would do this with RL is to use the goals an objective that includes weighted constraints.&lt;/p&gt;&#xA;&lt;p&gt;This of course assumes you have the right data/setup to train the algorithm.&lt;/p&gt;&#xA;&lt;p&gt;After enough training, your system will be able to predict the right clustering such that your constraints are obeyed, and your other goals are relatively minimal (assuming you're minimising).&lt;/p&gt;&#xA;&lt;p&gt;It's important to be aware of the fact that this will not work properly 100% of the time, i.e., some of the time the predicted result is likely to violate your constraints. How often this happens and by how much, depends on how well you train the RL model.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-07-01T13:25:33.413" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4476" PostTypeId="1" CreationDate="2020-07-01T13:58:52.760" Score="1" ViewCount="70" Body="&lt;p&gt;I am trying to find a minimal viable product for house building company.&#xA;I don't know what are the commonly used constraints. Intuitively, I would say that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There is a set of tasks. Each task has a processing time. Each task need a set of skills.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There is precedence constraints (maybe with time lags) between some tasks.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A set of workers. Each worker has a calendar and a set of skills.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The problem consists of assigning starting dates and workers to tasks.&lt;/p&gt;&#xA;&lt;p&gt;If I want to make an app to solve this kind of problems, what papers/ existing apps/ methods should I know?&lt;/p&gt;&#xA;&lt;p&gt;Edit: I read some papers about the multi-skill variant of the resource constrained project scheduling problem but I am not sure it will be a good model for such an MVP. I am not sure how it will scale with large-size instances.&lt;/p&gt;&#xA;" OwnerUserId="3711" LastEditorUserId="3711" LastEditDate="2020-07-01T14:54:31.777" LastActivityDate="2020-07-01T14:54:31.777" Title="How to identify an MVP for house building?" Tags="|scheduling|applications|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4477" PostTypeId="2" ParentId="4467" CreationDate="2020-07-01T20:12:18.807" Score="7" Body="&lt;p&gt;I would just call it &amp;quot;planning data&amp;quot;. I think it might be easier to convince an administrator that &amp;quot;planning data&amp;quot; needs to be recorded/captured than to sell them on &amp;quot;&amp;lt;insert techno-jargon phrase here&amp;gt; data&amp;quot;. Administrators grasp what planning is (whether or not they are adept at doing it), and at some visceral level they probably realize that &lt;em&gt;not&lt;/em&gt; planning is bad (which might make them a bit more inclined to make an effort to collect the data). If &amp;quot;planning data&amp;quot; does not do much to distinguish this sort of data from other sorts (salary data, student/faculty ratio, ...), perhaps that's a good thing. They already understand the relevance of the other data, and that it needs to be collected, so by association they might realize this data is also important.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="123" LastEditDate="2020-07-02T07:55:15.060" LastActivityDate="2020-07-02T07:55:15.060" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4478" PostTypeId="2" ParentId="4430" CreationDate="2020-07-02T08:19:45.187" Score="2" Body="&lt;p&gt;When dealing with infeasibility, I like to do two things:&lt;/p&gt;&#xA;&lt;p&gt;a) Create the Irreducible Infeasible Subset (IIS). I don't think PuLP directly allows you to create that, however you could export your model instance and then use a (commercial) solver (e.g. Gurobi) to do so (see &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/py_model_computeiis.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for docs). This will allow you to narrow down where the infeasibility lies.&lt;/p&gt;&#xA;&lt;p&gt;b) Add slack variables to your constraints: slack variables are &amp;quot;dummy&amp;quot; variables that you add to a constraint to ensure that it can be feasible. Consider this inequality constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x + y \leq 5$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$x,y\geq 3$&lt;/span&gt;. This would of course be infeasible. Now however you can add a slack variable &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; such that:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x + y \leq 5 + s$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This will make the problem feasible for &lt;span class=&quot;math-container&quot;&gt;$s\geq 1$&lt;/span&gt;. Note that slack variables typically have very high coefficients in the objective function to force them to be as small as possible. This is actually also implemented in Gurobi (see here), and you may find &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360029969391-Managing-Infeasibility&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt; as well as &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/examples/diagnose_and_cope_with_inf.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt; about it also helpful.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2020-07-02T08:19:45.187" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4479" PostTypeId="1" AcceptedAnswerId="4484" CreationDate="2020-07-02T12:56:00.610" Score="3" ViewCount="623" Body="&lt;p&gt;We need to maintain as quickly as possible a complex system. In particular, we need to replace six of its components &lt;span class=&quot;math-container&quot;&gt;$\{P_1,\ldots,P_6\}$&lt;/span&gt;. We have three 3D printers &lt;span class=&quot;math-container&quot;&gt;$\{M_1,M_2,M_3\}$&lt;/span&gt; which we can use to fabricate the six components. The following table/matrix states how long it takes (in minutes) the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;th printer to print the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;th component:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{ccccccc} \hline&#xA;&amp;amp; P_1&amp;amp; P_2&amp;amp;P_3&amp;amp;P_4&amp;amp;P_5&amp;amp;P_6 \\ \hline&#xA;    M_1 &amp;amp; 23 &amp;amp; 42   &amp;amp; 12   &amp;amp; 32 &amp;amp; 47 &amp;amp; 60\\&#xA;    M_2 &amp;amp; 25&amp;amp; 37&amp;amp; 13&amp;amp; 37&amp;amp; 51&amp;amp; 64\\&#xA;    M_3 &amp;amp; 27 &amp;amp;51 &amp;amp;15&amp;amp; 41 &amp;amp;57 &amp;amp;55\\ \hline&#xA;    \end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The complex system will work again only when all the components have been printed. Clearly more components can (and have to be) assigned to single machines and they are made in a sequence, one after the other, and 3D printers can work in parallel.&#xA;However, you have only two operators and therefore you can only use two machines.&#xA;How to formulate the problem as a linear (but combinatorial) optimization problem to allocate components to (two out of three) 3D printers so that the maintenance time is minimized.&lt;/p&gt;&#xA;&lt;p&gt;So far I have tried the following, but I am not quite sure (Please I need help if I was mistaken):&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{ij}= 1$&lt;/span&gt; if machine &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to component &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise. The model is &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad23x_{11}+42x_{12}+...+55x_{36}\\\text{s.t.}&amp;amp;\quad x_{11}+x_{12}+x_{13}+x_{14}+x_{15}+x_{16} = 2\\&amp;amp;\quad x_{21}+x_{22}+x_{23}+x_{24}+x_{25}+x_{26} = 2\\&amp;amp;\quad x_{31}+x_{32}+x_{33}+x_{34}+x_{35}+x_{36} = 2\\&amp;amp;\quad x_{11}+x_{21}+x_{31} \ge 1\\&amp;amp;\quad x_{12}+x_{22}+x_{32} \ge 1\\&amp;amp;\quad x_{13}+x_{23}+x_{33} \ge 1\\&amp;amp;\quad x_{14}+x_{24}+x_{34} \ge 1\\&amp;amp;\quad x_{15}+x_{25}+x_{35} \ge 1\\&amp;amp;\quad x_{16}+x_{26}+x_{36} \ge 1\\&amp;amp;\quad x_{ij}\,\,\text{is binary}.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3752" LastEditorUserId="123" LastEditDate="2021-02-16T15:53:12.067" LastActivityDate="2021-02-16T15:53:12.067" Title="Formulation of Assignment problem as integer programming" Tags="|integer-programming|combinatorial-optimization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4480" PostTypeId="2" ParentId="4474" CreationDate="2020-07-04T12:03:15.297" Score="3" Body="&lt;p&gt;If you check &lt;a href=&quot;https://github.com/scipy/scipy/blob/master/scipy/optimize/slsqp.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;SLSQP's source code&lt;/a&gt;, there is actually no code (as far as I can tell) that makes use of the Jacobian passed by the user. Instead, the code assumes no Jacobian is ever passed from the outside and keeps approximating it using the constraints.&lt;/p&gt;&#xA;&lt;p&gt;What this means is that even if you do provide a Jacobian, the SLSQP code will ignore it, which is why you do not notice a speed difference.&lt;/p&gt;&#xA;&lt;p&gt;To confirm the suspicion we can check &lt;a href=&quot;https://github.com/scipy/scipy/blob/master/scipy/optimize/slsqp/slsqp_optmz.f&quot; rel=&quot;nofollow noreferrer&quot;&gt;line 525 of the Fortran SLSQP code&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;C   CALL JACOBIAN AT CURRENT X&#xA;&#xA;C   UPDATE CHOLESKY-FACTORS OF HESSIAN MATRIX BY MODIFIED BFGS FORMULA&#xA;&#xA;260 DO 270 i=1,n&#xA;       u(i) = g(i) - ddot_sl(m,a(1,i),1,r,1) - v(i)&#xA;270 CONTINUE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and see that the code to evaluate the Jacobian is not there.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-07-04T12:03:15.297" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4481" PostTypeId="2" ParentId="4467" CreationDate="2020-07-04T12:28:51.370" Score="6" Body="&lt;p&gt;Adhering to the rules of encapsulation, I would simply call it &amp;quot;parameters&amp;quot;. If we're thinking of an optimisation model and, as you said, what changes is the number of things (number of students, number of classrooms, a table with the teachers' schedule, etc.), that's what we call usually parameters in optimisation modelling so I don't see a reason to use a different term.&lt;/p&gt;&#xA;&lt;p&gt;If we wanted to make the name more descriptive, I would attach a problem-specific prefix there, e.g., &amp;quot;planning parameters&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;I like this term because it indicates that the math would be the same (assuming that's the case here) even if those numbers change.&lt;/p&gt;&#xA;&lt;p&gt;I would avoid the word &amp;quot;data&amp;quot; because it's too broad - we also use &amp;quot;data&amp;quot; to formulate the math.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-07-04T12:28:51.370" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4482" PostTypeId="2" ParentId="4474" CreationDate="2020-07-04T12:50:15.273" Score="1" Body="&lt;p&gt;Scipy's minimize allows you to pass the Jacobian of the constraints to the &lt;em&gt;minimize&lt;/em&gt; function (&lt;a href=&quot;https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html#scipy.optimize.minimize&quot; rel=&quot;nofollow noreferrer&quot;&gt;the documentation&lt;/a&gt; says it's used only by SLSQP). Then Scipy won't have to evaluate it by calling the function N times.&lt;/p&gt;&#xA;&lt;p&gt;The Jacobian of the constraints is evaluated &lt;a href=&quot;https://github.com/scipy/scipy/blob/4c0fd79391e3b2ec2738bf85bb5dab366dcd12e4/scipy/optimize/slsqp.py#L279&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; if it's not present.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2020-07-04T12:50:15.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4483" PostTypeId="2" ParentId="4474" CreationDate="2020-07-04T14:01:13.087" Score="2" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: In light of information provided in the comments by @Gabriel Gouvine , I suggest you forego use of scipy,minimize and SLSQP. Instead, try using Pyomo, which cam call a variety of better, more modern solvers, including all solvers which AMPL and  GAMS are capable of calling.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Original answer&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;Spoiler alert:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;scipy.minimize allow specification of linear constraints and bound constraints. So you should be using that capability ... and leave your Jacobian worries behind.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraints are linear. Therefore, the Jacobian of the constraints is the matrix of coefficients in the linear system of constraints.&lt;/p&gt;&#xA;&lt;p&gt;If the modeling package, solver combination allows it (which any decent such should). linear constraints can be treated specially (as opposed to being treated as general nonlinear constrains), and even more special treatment provided for bound constraints (which are a special case of linear constraints).&lt;/p&gt;&#xA;&lt;p&gt;Therefore, any decent solver, provided the linear constraints as such, can trivially compute the Jacobian itself, and there is no value in having Jacobian provided as input to the solver.&lt;/p&gt;&#xA;&lt;p&gt;scipy.minimize allow specification of linear constraints and bound constraints. So you should be using that capability ... and leave your Jacobian worries behind.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-07-04T14:50:52.437" LastActivityDate="2020-07-04T14:50:52.437" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="4484" PostTypeId="2" ParentId="4479" CreationDate="2020-07-04T19:21:49.620" Score="4" Body="&lt;p&gt;Since you mention that you want to operate two out of three machines, it boils down to a problem where you first pick two machines and then perform a standard &lt;span class=&quot;math-container&quot;&gt;$R2||C_{\max}$&lt;/span&gt; parallel machine scheduling problem with the two machines that you selected. Such problems are very suitable for dynamic programming/column generation approaches, but your instance is so small that a IP will work fine. And since you ask for an IP, let us consider a straightforward way to model it.&lt;/p&gt;&#xA;&lt;p&gt;For a formulation, consider the following decision variables:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_j = \left\{ \begin{array}{ll} 1 &amp;amp; \mbox{ if } M_j \mbox{ is being operated } \\ 0 &amp;amp; \mbox{otherwise} \end{array} \right.$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{ij} = \left\{ \begin{array}{ll} 1 &amp;amp; \mbox{ if } P_i \mbox{ is made on } M_j \\ 0 &amp;amp; \mbox{otherwise} \end{array}\right.$$&lt;/span&gt;&#xA;Also, let's assume that &lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt; is the time needed to produce &lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$M_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now the following IP can be formulated:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{llll}&#xA;\min &amp;amp; z \\&#xA;\mbox{s.t.} &amp;amp; \sum_{j} y_j &amp;amp; \leq K \\&#xA;            &amp;amp; \sum_{j} x_{ij} &amp;amp; = 1 &amp;amp; \forall i \\&#xA;            &amp;amp; x_{ij} &amp;amp; \leq y_j &amp;amp; \forall i \forall j \\&#xA;            &amp;amp; \sum_i a_{ij} x_{ij} &amp;amp; \leq z &amp;amp; \forall j \\&#xA;            &amp;amp; x_{ij} \in \{0,1\} &amp;amp; &amp;amp; \forall i \forall j \\&#xA;            &amp;amp; y_j \in \{0,1\} &amp;amp; &amp;amp; \forall j \\&#xA;            &amp;amp; z \in \mathbb{R}&#xA;\end{array}$$&lt;/span&gt;&#xA;Where the objective variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; represents the makespan, the first constraint states that at most &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; machines can be used (in your instance, &lt;span class=&quot;math-container&quot;&gt;$K=2$&lt;/span&gt;, i.e. &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is the number of operators), the second constraint states that each &lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt; must be executed on exactly one &lt;span class=&quot;math-container&quot;&gt;$M_j$&lt;/span&gt;, the third constraint states that a &lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt; can only be produced on a &lt;span class=&quot;math-container&quot;&gt;$M_j$&lt;/span&gt; if that &lt;span class=&quot;math-container&quot;&gt;$M_j$&lt;/span&gt; is being operated and the fourth constraint states that the makespan &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; should be at least the time spent on each individual machine.&lt;/p&gt;&#xA;&lt;p&gt;If you want to allow operators to switch between machines, the problem becomes more complicated, as you need to make sure that both an operator and a machine is available when you produce an item; you probably need to keep track of both the operator and the machine resources in your model and define constraints to avoid conflicts for which you may or may not need to determine an order as well.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastEditorUserId="500" LastEditDate="2020-07-04T20:03:06.180" LastActivityDate="2020-07-04T20:03:06.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4485" PostTypeId="1" CreationDate="2020-07-05T17:32:48.877" Score="7" ViewCount="297" Body="&lt;p&gt;I am working with some computational experiments with an Integer Programming (IP) formulation over a well-known set of instances from the literature of my problem. And I would like to compare my formulation with another author formulation from the literature (making a benchmarking).&lt;/p&gt;&#xA;&lt;p&gt;However, the machine configuration in which the author's formulation was executed is different from mine. So, I thought, if I can find the equivalent time from the author's machine to mine, then I can use this equivalent time on my computational experiments, e.g if one hour of execution on the author's machine is equivalent to two hours of execution on mine machine and the author's experiments were executed with one hour of the time limit, then I can run my experiments with a time limit of two hours and have more precise results to compare.&lt;/p&gt;&#xA;&lt;p&gt;Hence, I would like to know if there is any way to calculate the equivalent time from two different machines (even if this time be approximated).&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="123" LastEditDate="2021-11-20T14:56:21.043" LastActivityDate="2021-11-20T14:56:21.043" Title="How to simulate computational execution time?" Tags="|computational-experiments|runtime|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4486" PostTypeId="2" ParentId="4485" CreationDate="2020-07-06T09:33:04.127" Score="6" Body="&lt;p&gt;Short answer: you can't with any decent level of accuracy. The best you can do is ballpark comparisons.&lt;/p&gt;&#xA;&lt;p&gt;There are so many factors that affect the outcome, that you can maybe get within 20% difference on an identical machine with a decent degree of confidence. I know this for a fact because we benchmark on many identical machines and results always vary.&lt;/p&gt;&#xA;&lt;h2&gt;&lt;strong&gt;Important things under your control&lt;/strong&gt;&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The machine itself&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The operating conditions&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The version of the kernel&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The power supply&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To have identical OS &amp;amp; software on both machines (including running daemons/services)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The network cables (assuming that's important)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The version of the compiler &amp;amp; libraries. This is crucial if using open source software.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;&lt;strong&gt;Important things you can't control&lt;/strong&gt;&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The machine's hardware. This made both lists to point out that unless you have the factory settings of the reference machine, it's hard to reproduce. What's the motherboard? What's the exact CPU? Does it use single or dual socket? What's the RAM frequency? Does is use 2x16 GB RAM or 4x8 GB?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The operating conditions. This also made both lists. Was the reference machine in a cool room, especially if Turbo Boost was activated on multi-hour runs? What's the level of dust inside the box? Was someone else logged in at the same time?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The speed of the network, unless it's private and wired.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The version of the kernel. Yes this also made both lists (I said this is hard right?). Unless you clone the hard drives, even slight differences in installed software can cause the same Linux kernel to work differently on identical machines, or even not at all on one of them. The best way to resolve this is to use Windows.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Different pieces of software. Keep in mind that if you are comparing your method to another author's using your own code, you are comparing algorithms and implementations at the same time, in which case your error bounds can be massive. OR code is extremely implementation sensitive.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-07-06T13:44:42.473" LastActivityDate="2020-07-06T13:44:42.473" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4487" PostTypeId="2" ParentId="4430" CreationDate="2020-07-06T15:56:28.680" Score="3" Body="&lt;p&gt;The latest issue has to do with not having an inventory control constraint. You need to have a constraint like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;port_inventory_vars[(date, grade)] == port_inventory_vars[(date-1, grade)] - pulp.LpSum(vessel_sales_demand_vars[(vessel, grade, date)] for vessel in vessels) + ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The ellipsis indicates where you can put additional terms that describe how inventory increases at the port. As long as the variables used in this constraint are non-negative, this should restrict the loading of goods until there is sufficient inventory at the port.&lt;/p&gt;&#xA;" OwnerUserId="61" LastActivityDate="2020-07-06T15:56:28.680" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4488" PostTypeId="2" ParentId="4485" CreationDate="2020-07-06T16:28:49.157" Score="5" Body="&lt;p&gt;In support of other answers and suggestions that you just run the other algorithm on your hardware, I would argue that failing to match the published results exactly is not necessarily cause for concern. If the authors reran the same examples using their code on their hardware, there is a high likelihood that timings would be at least somewhat different, and a distinct possibility that (if not run to proven optimality) the incumbent objective value and/or best bound might be different at the same time limit originally used. Unless you get a wildly different result from their algorithm (infeasible when they have a feasible solution, a better solution than their proven optimum, ...), I would vote for side-by-side comparison on your hardware.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-07-06T16:28:49.157" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4489" PostTypeId="1" AcceptedAnswerId="4494" CreationDate="2020-07-06T22:40:57.070" Score="4" ViewCount="157" Body="&lt;p&gt;Given two numbers in binary representation &lt;span class=&quot;math-container&quot;&gt;$b_1,b_2$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$k_1, k_2$&lt;/span&gt; be the number of digits.&lt;/p&gt;&#xA;&lt;p&gt;What would be an integer program that models the multiplication of these two numbers?&#xA;The restriction is that the variables as well as the coefficients of the variables are not allowed to take huge values (that it is still solvable in floating point arithmetic for large numbers).&lt;/p&gt;&#xA;&lt;p&gt;The integer program needs at least &lt;span class=&quot;math-container&quot;&gt;$k_1+k_2$&lt;/span&gt; binary variables to model the result of the multiplication.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2020-07-07T08:38:32.047" LastActivityDate="2020-07-08T08:41:04.863" Title="Integer Program for Multiplication of Large Numbers" Tags="|modeling|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4490" PostTypeId="1" CreationDate="2020-07-07T02:01:11.173" Score="5" ViewCount="193" Body="&lt;p&gt;In general, suppose you have a non-convex optimization problem with constraints and you form the dual problem. If you find a local optimum for the dual problem, will the corresponding primal solution always be feasible? If not, when is it not feasible?&lt;/p&gt;&#xA;" OwnerUserId="3826" LastActivityDate="2020-07-09T13:42:15.503" Title="Local optimum of dual of non-linear program" Tags="|duality|nonconvex-programming|optimality-conditions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4491" PostTypeId="1" CreationDate="2020-07-07T04:19:39.403" Score="5" ViewCount="107" Body="&lt;p&gt;What are books on &lt;a href=&quot;https://en.wikipedia.org/wiki/Online_optimization&quot; rel=&quot;noreferrer&quot;&gt;Online Optimization&lt;/a&gt; other than Introduction to Online Convex Optimization?&lt;/p&gt;&#xA;&lt;p&gt;Preferably:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;more on applied side, rather than theoretical&lt;/li&gt;&#xA;&lt;li&gt;not limited to convex only&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2704" LastEditorUserId="2704" LastEditDate="2020-07-07T04:43:58.740" LastActivityDate="2020-07-07T04:43:58.740" Title="Books in applied Online Optimization" Tags="|reference-request|books|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4492" PostTypeId="1" AcceptedAnswerId="4520" CreationDate="2020-07-07T05:28:33.387" Score="7" ViewCount="541" Body="&lt;p&gt;I have been working on a combinatorial optimization problem which can be modeled as an integer linear programming. I implemented it as a c++ project in visual studio 2017 and CPLEX1271. With the hope that my program would run faster, I use MIPStart to provide cplex a feasible solution. But the running time changed from 49s to 140s. All I did is providing a feasible solution to cplex, according to the &lt;a href=&quot;https://or.stackexchange.com/questions/1278/how-does-a-warm-start-work-in-lp-mip/1328?tdsourcetag=s_pctim_aiomsg&quot;&gt;answer&lt;/a&gt;, it cannot hurt the running time. Can anyone explain it?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE1&lt;/strong&gt;: The log shows that cplex accept the solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE2&lt;/strong&gt;: I've tested on hundreds of instances. It turned out that a warm start sometimes slows down cplex and at other times it accelerates cplex.&lt;/p&gt;&#xA;" OwnerUserId="3815" LastEditorUserId="500" LastEditDate="2023-12-13T18:00:53.833" LastActivityDate="2023-12-13T18:00:53.833" Title="CPLEX MIP warm start seems slow down the program?" Tags="|integer-programming|cplex|warm-start|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4493" PostTypeId="1" CreationDate="2020-07-07T17:06:32.427" Score="2" ViewCount="254" Body="&lt;p&gt;I am using MIP (Mixed Integer Programming) module in Python to solve one of my optimization problems. for some of the scenarios, model returns &amp;quot;ERROR&amp;quot; (OptimizationStatus.ERROR) status after optimization ends.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to get more details about why am I getting this status? I tried catching an exceptions putting try/catch but there is no exception.&lt;/p&gt;&#xA;" OwnerUserId="3785" LastEditorUserId="491" LastEditDate="2022-08-09T02:57:09.110" LastActivityDate="2022-08-09T02:57:09.110" Title="How to get detail about 'OptimizationStatus.ERROR' in MIP module in Python?" Tags="|optimization|mixed-integer-programming|python|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4494" PostTypeId="2" ParentId="4489" CreationDate="2020-07-07T20:30:27.510" Score="3" Body="&lt;p&gt;If the numbers are small enough, you can model the multiplication &lt;span class=&quot;math-container&quot;&gt;$z=xy$&lt;/span&gt; in a quadratic program, and add the equality &lt;span class=&quot;math-container&quot;&gt;$x = \sum2^i b_i$&lt;/span&gt; to relate each number &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to its binary representation.&lt;/p&gt;&#xA;&lt;p&gt;If the numbers are too big, you may run into numerical precision issues with the above. A possible method would be to implement the circuit for a multiplier (&lt;a href=&quot;https://en.wikipedia.org/wiki/Wallace_tree&quot; rel=&quot;nofollow noreferrer&quot;&gt;for example&lt;/a&gt;). You just need to model the linearization of the full-adder. Anecdotally, this is how &lt;a href=&quot;http://minisat.se/MiniSat+.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Minisat+&lt;/a&gt; models linear constraints.&lt;/p&gt;&#xA;&lt;p&gt;I am almost certain that this second method would NOT work in practice: showing equivalence of multiplier circuits has a reputation for being hard even for SAT solvers and model checkers. A MIP solver is not designed to handle this.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="123" LastEditDate="2020-07-08T08:41:04.863" LastActivityDate="2020-07-08T08:41:04.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4495" PostTypeId="1" CreationDate="2020-07-07T20:50:29.207" Score="2" ViewCount="105" Body="&lt;p&gt;I read &lt;a href=&quot;https://en.wikipedia.org/wiki/Stochastic_gradient_descent#AdaGrad&quot; rel=&quot;nofollow noreferrer&quot;&gt;on Wikipedia&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;AdaGrad&lt;/strong&gt; (for adaptive gradient algorithm) is a modified stochastic gradient descent algorithm with per-parameter learning rate, first published in 2011. Informally, this increases the learning rate for &lt;strong&gt;sparser&lt;/strong&gt; parameters and decreases the learning rate for ones that are &lt;strong&gt;less sparse&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;What do they mean by &lt;strong&gt;parameter sparsity&lt;/strong&gt;?  I read that AdaGrad averages / accumulates gradients over time. Does parameter sparsity refer to how often (dense?) these gradients are accumulated? or something else?&lt;/p&gt;&#xA;" OwnerUserId="3828" LastEditorUserId="3828" LastEditDate="2020-07-08T00:20:18.003" LastActivityDate="2020-07-08T12:41:17.000" Title="AdaGrad - Sparsity of parameters" Tags="|optimization|nonconvex-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4496" PostTypeId="1" CreationDate="2020-07-08T03:11:51.760" Score="5" ViewCount="63" Body="&lt;p&gt;Does anyone know the complexity of obtaining the optimal solution to the integral multi-commodity network flow problem with unit demands, integral capacities, but the cost of using an arc varies across different commodities?&lt;br /&gt;&#xA;As a follow-up, the same question as above but now we also know that the network is a directed acyclic graph.&lt;/p&gt;&#xA;" OwnerUserId="972" LastActivityDate="2020-07-08T03:11:51.760" Title="Complexity of solving a certain commodity flow problem" Tags="|computational-complexity|network-flow|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4497" PostTypeId="2" ParentId="4490" CreationDate="2020-07-08T03:18:39.740" Score="3" Body="&lt;p&gt;I guess you are assuming that the dual problem was obtained by only dualizing some of the constraints. The answer below makes sense if I am right about my guess.&lt;/p&gt;&#xA;&lt;p&gt;In general, I believe the answer to your problem is no. Take for instance the multi-commodity flow problem. If you dualize the capacity constraints, then the dual problem you will be solving involves computing a min-cost flow problem for each commodity. If you treat the flows that you have obtained as the primal solution to your dual problem, then the primal solution corresponding to your optimal dual multipliers may still violate some capacity constraints when the flows for the different commodities have been aggregated.&lt;/p&gt;&#xA;&lt;p&gt;To answer about the second problem, I do not know how to characterize when the primal solution is not feasible. However, let me tell you of a case when the primal solution will be feasible. Suppose you know that strong duality holds for your problem and the primal solution corresponding to your optimal dual multipliers is unique, then we know that the primal solution will also be feasible. I guess you can convince yourself of this fact from the KKT conditions and strong duality theorem. For an example of such a case, consider the problem of optimizing a strongly convex quadratic function over a set of linear constraints.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2020-07-09T05:32:12.437" LastActivityDate="2020-07-09T05:32:12.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4498" PostTypeId="1" CreationDate="2020-07-08T11:11:30.033" Score="8" ViewCount="148" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$y\in\mathbb{R}^m$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\tau\in\mathbb{R}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X\in\mathbb{R}^{m\times n}$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$\tau&amp;gt;0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would like to efficiently solve the following problem:&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Problem 1&lt;/h3&gt;&#xA;&lt;p&gt;Choose &lt;span class=&quot;math-container&quot;&gt;$\alpha,z\in\mathbb{R}^m,\beta\in\mathbb{R}^n$&lt;/span&gt; to minimize:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(y-\alpha)^\top (y-\alpha) + \tau \beta^\top \beta$$&lt;/span&gt;&#xA;subject to the constraints that:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z=X\beta$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\beta^\top 1_n = 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\beta\ge 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\forall i,j\in\{1,\dots,m\}, z_i\le z_j \rightarrow \alpha_i \le \alpha_j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;(Here &lt;span class=&quot;math-container&quot;&gt;$1_n\in\mathbb{R}^n$&lt;/span&gt; is a vector of ones.)&lt;/p&gt;&#xA;&lt;p&gt;The final constraint is equivalent to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\forall i,j\in\{1,\dots,m\}, (z_j-z_i,\alpha_j-\alpha_i)\in\left\{(c,d)\in\mathbb{R}^2\middle|c\le 0 \vee d\ge 0\right\},$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which is clearly non-convex. While the problem can be given a mixed integer quadratic programming formulation, this is unlikely to be computationally feasible.&lt;/p&gt;&#xA;&lt;p&gt;However, if we knew &lt;span class=&quot;math-container&quot;&gt;$z=\hat z$&lt;/span&gt;, Problem 1 reduces to:&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Problem 2&lt;/h3&gt;&#xA;&lt;p&gt;Choose &lt;span class=&quot;math-container&quot;&gt;$\alpha\in\mathbb{R}^m$&lt;/span&gt; to minimize:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(y-\alpha)^\top (y-\alpha)$$&lt;/span&gt;&#xA;subject to the constraints that:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\forall i,j\in\{1,\dots,m\}, \hat z_i\le \hat z_j \rightarrow \alpha_i \le \alpha_j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;This is the isotonic regression problem, and may be solved very efficiently by the pooled adjacent violators algorithm.&lt;/p&gt;&#xA;&lt;p&gt;Likewise, if we knew &lt;span class=&quot;math-container&quot;&gt;$\alpha=\hat\alpha$&lt;/span&gt;, then Problem 1 reduces to:&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Problem 3&lt;/h3&gt;&#xA;&lt;p&gt;Choose &lt;span class=&quot;math-container&quot;&gt;$z\in\mathbb{R}^m,\beta\in\mathbb{R}^n$&lt;/span&gt; to minimize:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\beta^\top \beta$$&lt;/span&gt;&#xA;subject to the constraints that:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z=X\beta$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\beta^\top 1_n = 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\beta\ge 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\forall i,j\in\{1,\dots,m\}, \hat\alpha_i &amp;gt; \hat\alpha_j \rightarrow z_i &amp;gt; z_j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;This is a simple quadratic programming problem (at least once the strict inequality on &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is replaced by a weak one with a small margin).&lt;/p&gt;&#xA;&lt;h3&gt;Question&lt;/h3&gt;&#xA;&lt;p&gt;My question is whether Problem 2 or Problem 3 can be exploited to give a computationally feasible (iterative?) algorithm for Problem 1. I would of course also be interested in any other approach to efficiently solving Problem 1.&lt;/p&gt;&#xA;&lt;p&gt;Note that the naïve algorithm of alternating between solving Problem 2 and solving Problem 3 cannot possibly converge to a solution of Problem 1, as neither Problem 2 nor 3 depend on &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3830" LastActivityDate="2020-07-15T11:12:08.527" Title="(Iterative?) Solutions to a certain quadratic program with non-convex constraints" Tags="|mixed-integer-programming|quadratic-programming|nonconvex-programming|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4499" PostTypeId="2" ParentId="4495" CreationDate="2020-07-08T12:41:17.000" Score="2" Body="&lt;p&gt;Yes by sparse parameters they mean that they do not receive often/large updates.&#xA;This naming is a little bit confusing, because this often happens when the data is also sparse, so that some features appear only a few times.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2020-07-08T12:41:17.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4501" PostTypeId="2" ParentId="4493" CreationDate="2020-07-08T14:08:56.963" Score="2" Body="&lt;p&gt;I looked at the source code and OptimizationStatus.ERROR is returned if Cbc_isAbandoned evaluates to True. I can't see when this is the case but I would say that only occurs when something goes really wrong on a deeper system level.&#xA;Your best bet would be to ask the developers though as mentioned in a comment above.&lt;/p&gt;&#xA;" OwnerUserId="3192" LastActivityDate="2020-07-08T14:08:56.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4502" PostTypeId="1" CreationDate="2020-07-08T16:56:50.387" Score="4" ViewCount="379" Body="&lt;p&gt;I want to solve the following integer programming problem using &lt;a href=&quot;https://ampl.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AMPL&lt;/a&gt;. The problem is the &lt;a href=&quot;https://math.stackexchange.com/questions/3745954/how-to-construct-a-5-regular-graph-with-diameter-2-on-22-vertices&quot;&gt;following&lt;/a&gt; (It was already asked on &lt;a href=&quot;https://math.stackexchange.com/questions/3745954/how-to-construct-a-5-regular-graph-with-diameter-2-on-22-vertices&quot;&gt;mathstackexchange.com&lt;/a&gt;, but I need to know how to solve it using AMPL):&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$N=\{1,…,22\}$&lt;/span&gt; be the nodes, and let &lt;span class=&quot;math-container&quot;&gt;$P=\{i\in N,j\in N:i&amp;lt;j\}$&lt;/span&gt; be the set of node pairs. For &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in P$&lt;/span&gt;, let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is an edge. For &lt;span class=&quot;math-container&quot;&gt;$(i,j)∈P$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k \in N \setminus \{i,j\}$&lt;/span&gt;, let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j,k}$&lt;/span&gt; indicate whether k is a common neighbor of i and j.&lt;/p&gt;&#xA;&lt;p&gt;Optimization Model:&#xA;&lt;strong&gt;Minimize&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$\sum_{k \in N \setminus \{i,j\}} y_{i,j,k}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \sum_{(i,j)\in P:\ k \in \{i,j\}} x_{i,j} &amp;amp;= 5 &amp;amp;&amp;amp;\text{for $k\in N$} \tag1\\&#xA;    x_{i,j} + \sum_{k \in N \setminus \{i,j\}} y_{i,j,k} &amp;amp;\ge 1 &amp;amp;&amp;amp;\text{for $(i,j)\in P$} \tag2\\&#xA;    y_{i,j,k} &amp;amp;\le [i&amp;lt;k]x_{i,k} + [k&amp;lt;i]x_{k,i} &amp;amp;&amp;amp;\text{for $(i,j)\in P$ and $k \in N \setminus \{i,j\}$} \tag3\\&#xA;    y_{i,j,k} &amp;amp;\le [j&amp;lt;k]x_{j,k} + [k&amp;lt;j]x_{k,j} &amp;amp;&amp;amp;\text{for $(i,j)\in P$ and $k \in N \setminus \{i,j\}$} \tag4&#xA;    \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;so far I have tried the following in AMPL, but the result has error (Please I need help):&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;example1.mod&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set N:={1..22};&#xA;set P:={i in N, j in N: i&amp;lt;j};&#xA;set K:={i in N, j in N, k in N: k!=i,k!=j};&#xA;&#xA;&#xA;var x{i in P, j in P} binary; #for x_{ij}&#xA;var y{i in P, j in P, k in K} binary; #for y_{ijk}  &#xA;&#xA;var x{j in P,k in K: j&amp;lt;k} binary; #for x_{jk}&#xA;var x{i in P,k in K: i&amp;lt;k} binary; #for x_{ik}&#xA;var x{k in K,j in P: k&amp;lt;j} binary; #for x_{kj}&#xA;var x{k in K,i in P: k&amp;lt;i} binary; #for x_{ki}&#xA; &#xA; minimize z: sum{k in K} y[i,j,k];&#xA; &#xA; subject to Constraint1{i in P, j in P}: sum{k in N}x[i,j]=5;&#xA; subject to Constraint2{i in P, j in P}: sum{k in K}y[i,j,k]&amp;gt;=1-x[i,j] ;&#xA; subject to constraint3{i in P, j in P, k in K}: y[i,j,k]&amp;lt;=x[i,k]+x[k,i];&#xA; subject to constraint4{i in P, j in P, k in K}:y[i,j,k]&amp;lt;=x[j,k]+x[k,j];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;example2.run&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;reset;&#xA;model example1.mod;&#xA;option solver cplex;&#xA;solve;&#xA;display x, z;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="3831" LastEditorUserId="3831" LastEditDate="2020-07-08T17:10:28.653" LastActivityDate="2020-07-08T19:33:16.887" Title="Combinatorial Optimization using AMPL" Tags="|integer-programming|combinatorial-optimization|ampl|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4503" PostTypeId="2" ParentId="4502" CreationDate="2020-07-08T17:26:06.413" Score="3" Body="&lt;p&gt;Here is the SAS code that I used to obtain the results in the linked thread.  Maybe it will help you correct your AMPL errors.  In particular, note that you should declare each variable only once.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;proc optmodel;&#xA;   num n = 22;&#xA;   set NODES = 1..n;&#xA;   num degree {NODES} = 5;&#xA;   set NODE_PAIRS = {i in NODES, j in NODES: i &amp;lt; j};&#xA;&#xA;   var X {NODE_PAIRS} binary;&#xA;&#xA;   var Y {&amp;lt;i,j&amp;gt; in NODE_PAIRS, k in NODES diff {i,j}} binary;&#xA;&#xA;   con DegreeCon {k in NODES}:&#xA;      sum {&amp;lt;i,j&amp;gt; in NODE_PAIRS: k in {i,j}} X[i,j] = degree[k];&#xA;&#xA;   con DiameterTwo {&amp;lt;i,j&amp;gt; in NODE_PAIRS}:&#xA;      X[i,j] + sum {k in NODES diff {i,j}} Y[i,j,k] &amp;gt;= 1;&#xA;&#xA;   con CommonNeighbor1 {&amp;lt;i,j&amp;gt; in NODE_PAIRS, k in NODES diff {i,j}}:&#xA;      Y[i,j,k] &amp;lt;= (if &amp;lt;i,k&amp;gt; in NODE_PAIRS then X[i,k] else X[k,i]);&#xA;   &#xA;   con CommonNeighbor2 {&amp;lt;i,j&amp;gt; in NODE_PAIRS, k in NODES diff {i,j}}:&#xA;      Y[i,j,k] &amp;lt;= (if &amp;lt;j,k&amp;gt; in NODE_PAIRS then X[j,k] else X[k,j]);&#xA;&#xA;   solve;&#xA;   set EDGES = {&amp;lt;i,j&amp;gt; in NODE_PAIRS: X[i,j].sol &amp;gt; 0.5};&#xA;   put EDGES=;&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-07-08T17:26:06.413" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4504" PostTypeId="2" ParentId="4502" CreationDate="2020-07-08T19:33:16.887" Score="3" Body="&lt;p&gt;Here is the AMPL interpretation of @RobPratt's answer which works perfectly using the gurobi in my local pc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model;&#xA;param n := 22;&#xA;set NODES = 1..n;&#xA;param degree {NODES} := 5;&#xA;set NODE_PAIRS = {i in NODES, j in NODES: i &amp;lt; j};&#xA;&#xA;var X {NODE_PAIRS} binary;&#xA;var Y {(i,j) in NODE_PAIRS, k in NODES diff {i,j}} binary;&#xA;&#xA;subject to DegreeCon {k in NODES}:&#xA;      sum {(i,j) in NODE_PAIRS: k in {i,j}} X[i,j] = degree[k];&#xA;subject to DiameterTwo {(i,j) in NODE_PAIRS}:&#xA;      X[i,j] + sum {k in NODES diff {i,j}} Y[i,j,k] &amp;gt;= 1;&#xA;subject to CommonNeighbor1 {(i,j) in NODE_PAIRS, k in NODES diff {i,j}}:&#xA;      Y[i,j,k] &amp;lt;= (if (i,k) in NODE_PAIRS then X[i,k] else X[k,i]);&#xA;subject to CommonNeighbor2 {(i,j) in NODE_PAIRS, k in NODES diff {i,j}}:&#xA;      Y[i,j,k] &amp;lt;= (if (j,k) in NODE_PAIRS then X[j,k] else X[k,j]);&#xA;&#xA;option solver gurobi;&#xA;solve;&#xA;display X, Y;&#xA;set EDGES = {(i,j) in NODE_PAIRS: X[i,j].sol &amp;gt; 0.5};&#xA;let EDGES = ;&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The results that I got:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Gurobi 9.0.2: optimal solution; objective 0&#xA;230671 simplex iterations&#xA;166 branch-and-cut nodes&#xA;Objective = find a feasible point.&#xA;X [*,*]&#xA;:    2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22:=&#xA;1    1   1   1   1   1   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0&#xA;2    .   0   0   0   0   1   0   0   1   0   0   0   0   0   0   0   1   1   0   0   0&#xA;3    .   .   0   0   0   0   1   0   0   1   0   0   0   0   1   0   0   0   0   0   1&#xA;4    .   .   .   0   0   0   0   1   0   1   0   0   0   0   1   0   0   0   1   0   0&#xA;5    .   .   .   .   0   0   0   0   0   0   1   1   0   1   0   1   0   0   0   0   0&#xA;6    .   .   .   .   .   0   0   0   0   1   0   0   1   0   0   0   0   0   0   1   1&#xA;7    .   .   .   .   .   .   1   0   0   0   0   0   0   1   0   0   0   0   1   1   0&#xA;8    .   .   .   .   .   .   .   1   0   0   0   1   1   0   0   0   0   0   0   0   0&#xA;9    .   .   .   .   .   .   .   .   1   0   1   0   0   0   0   0   0   0   0   1   0&#xA;10   .   .   .   .   .   .   .   .   .   0   0   0   0   0   0   1   0   1   0   0   1&#xA;11   .   .   .   .   .   .   .   .   .   .   0   0   0   1   0   0   0   1   0   0   0&#xA;12   .   .   .   .   .   .   .   .   .   .   .   0   0   1   0   0   1   0   0   0   1&#xA;13   .   .   .   .   .   .   .   .   .   .   .   .   0   0   0   0   0   1   1   1   0&#xA;14   .   .   .   .   .   .   .   .   .   .   .   .   .   0   0   1   1   0   1   0   0&#xA;15   .   .   .   .   .   .   .   .   .   .   .   .   .   .   0   1   0   0   0   0   0&#xA;16   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   1   1   0   0   1   0&#xA;17   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   0   0   0   0   0&#xA;18   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   1   0   0   0&#xA;19   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   0   0   0&#xA;20   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   0   1&#xA;21   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   0&#xA;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-07-08T19:33:16.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4505" PostTypeId="2" ParentId="4490" CreationDate="2020-07-09T13:42:15.503" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;https://www.stat.cmu.edu/%7Eryantibs/convexopt-F15/scribes/11-dual-gen-scribed.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;duality theory&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;p&gt;At each feasible &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;,&lt;span class=&quot;math-container&quot;&gt;$f(x)=\sup_{u&amp;gt;0,v}L(x,u,v)$&lt;/span&gt;, and the supremum is taken iff &lt;span class=&quot;math-container&quot;&gt;$u\geq 0$&lt;/span&gt; satisfying &lt;span class=&quot;math-container&quot;&gt;$u_ih(x)=0,i=1,...,m$&lt;/span&gt;. The optimal value of the primal problem, named as &lt;span class=&quot;math-container&quot;&gt;$f^*$&lt;/span&gt; satisfies:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;f^*=\inf_x\sup_{u&amp;gt;0,v}L(x,u,v)&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This means that if the dual is feasible, the primal has to be feasible as well. If the problem is convex, then we have strong duality (subject to &lt;a href=&quot;https://en.wikipedia.org/wiki/Slater%27s_condition&quot; rel=&quot;nofollow noreferrer&quot;&gt;Slater's condition&lt;/a&gt;) and the values are also equal.&lt;/p&gt;&#xA;&lt;p&gt;For non-feasible &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, the value of the Lagrangian would be &lt;span class=&quot;math-container&quot;&gt;$\infty$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, for non-convex optimisation, failing to solve the dual problem does not imply that the primal is infeasible, merely that we failed to find a feasible point. If we prove that the dual problem is unbounded (which is a global optimisation problem), then the primal has to be infeasible.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-07-09T13:42:15.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4506" PostTypeId="2" ParentId="3091" CreationDate="2020-07-09T21:14:05.720" Score="1" Body="&lt;p&gt;Related to my previous comment:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;About the issue you reported on the function &lt;code&gt;getNcuts()&lt;/code&gt;, we looked at it and I can confirm that we have a bug in the number of Benders cuts reported by the function &lt;code&gt;getNcuts()&lt;/code&gt; (the issue is there with all CPLEX APIs).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The issue which I described will be fixed in the next CPLEX release.&lt;/p&gt;&#xA;" OwnerUserId="3230" LastActivityDate="2020-07-09T21:14:05.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4507" PostTypeId="1" CreationDate="2020-07-10T18:04:53.243" Score="2" ViewCount="168" Body="&lt;p&gt;I'm trying to implement either one of these objective functions, but I'm having a hard time with the squared terms. I'm attaching both so you can take a look at the structure and see if you can give me any tips. Is there any way to implement either one of them?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1- Matrix notation:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QeZfZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QeZfZ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;: decision variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;: column of ones&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;: squared matrix&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;2- Summation notation:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/i0wwM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/i0wwM.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;: decision variable&#xA;&lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;: degree of the node i&#xA;&lt;span class=&quot;math-container&quot;&gt;$rho$&lt;/span&gt;: parameter that takes into account the influence of the neighbors that surround node i&#xA;&lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;: terms of the adjacency matrix. Shows if nodes i and j are connected&lt;/p&gt;&#xA;&lt;p&gt;Thank you in advance!&lt;/p&gt;&#xA;" OwnerUserId="3836" LastEditorUserId="3836" LastEditDate="2020-07-12T01:02:21.273" LastActivityDate="2020-07-13T04:26:29.117" Title="Problem with implementing squared terms in the objective function" Tags="|optimization|cplex|gurobi|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4508" PostTypeId="1" CreationDate="2020-07-11T10:01:11.887" Score="3" ViewCount="57" Body="&lt;p&gt;If two M/M/1 queues with arrival rate &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and service rate &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; are working independently. Is the system equivalent to a single M/M/1 queue with arrival rate &lt;span class=&quot;math-container&quot;&gt;$2\lambda$&lt;/span&gt; and service rate &lt;span class=&quot;math-container&quot;&gt;$2\mu$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3843" LastActivityDate="2020-07-11T10:01:11.887" Title="Two M/M/1 queues working independently" Tags="|queuing-theory|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4509" PostTypeId="1" CreationDate="2020-07-11T19:35:07.853" Score="2" ViewCount="52" Body="&lt;p&gt;I have a single worker that can work on N different tasks, but his total time T is limited. Let's assume time is in steps of 10 minutes (1 step = 1 mn). The payoff from a single job is 0 for the first step (setup cost) and then &lt;span class=&quot;math-container&quot;&gt;$\log_{10}(t)$&lt;/span&gt;, eg payoff is 0.778 after 60 minutes (6 steps). If a worker goes back to an old job and continues it, there is another setup cost of 1, so working 2 times 60 minutes on the same job, payoff is log(12-1).&lt;/p&gt;&#xA;&lt;p&gt;We can then show that working on each job for 30 minutes (3 steps) and then not going back to it, is better than working on fewer jobs for 60 minutes each. It maximises the total payoff. In fact working on many jobs 11 minutes (1.1 steps) is kind of the optimal thing to do.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;How can I make this more realistic?&lt;/strong&gt; Imagine the worker is a human, and the jobs are meetings. Obviously you would not switch meetings all the time.&lt;/p&gt;&#xA;&lt;p&gt;I appreciate this is not 100% well defined. But grateful for any ideas.&lt;/p&gt;&#xA;" OwnerUserId="3844" LastEditorUserId="123" LastEditDate="2020-07-12T09:16:28.093" LastActivityDate="2020-07-12T09:16:28.093" Title="Scheduling with setup cost" Tags="|scheduling|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4510" PostTypeId="1" CreationDate="2020-07-11T21:59:30.317" Score="2" ViewCount="235" Body="&lt;p&gt;Assume we are given a directed acyclic graph (DAG) &lt;span class=&quot;math-container&quot;&gt;$G(V, A)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$|V| = n, |A| = m$&lt;/span&gt;, and the graph contains a source node &lt;span class=&quot;math-container&quot;&gt;$\mathbf{s}$&lt;/span&gt; (i.e. every node in &lt;span class=&quot;math-container&quot;&gt;$V \backslash \mathbf{s}$&lt;/span&gt; is connected by a directed path from &lt;span class=&quot;math-container&quot;&gt;$\mathbf{s}$&lt;/span&gt;). Let us denote the arc lengths by the &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; dimensional vector &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; which can be chosen from a compact box &lt;span class=&quot;math-container&quot;&gt;$\Xi \subset \mathbb{R}^{m}_{++}$&lt;/span&gt; (positive orthant).&lt;/p&gt;&#xA;&lt;p&gt;The problem of interest to me is from a scheduling problem, so we introduce a start time for each node. For some realization of arc variables &lt;span class=&quot;math-container&quot;&gt;$\xi \in \Xi$&lt;/span&gt;, the start time of node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is set to the cost of the longest path from the source node &lt;span class=&quot;math-container&quot;&gt;$\mathbf{s}$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; denoted by &lt;span class=&quot;math-container&quot;&gt;$L(\mathbf{s}, v, \xi)$&lt;/span&gt; (i.e. earliest start time policy). Note that &lt;span class=&quot;math-container&quot;&gt;$L(\mathbf{s}, v, \xi)$&lt;/span&gt; can be easily computed by any longest path algorithm since &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; is a DAG. For &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\xi \in \Xi$&lt;/span&gt;, the start time of node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is denoted by &lt;span class=&quot;math-container&quot;&gt;$S_v (\xi)$&lt;/span&gt; and obviously &lt;span class=&quot;math-container&quot;&gt;$S_v (\xi) = L(\mathbf{s}, v, \xi)$&lt;/span&gt;. For brevity I will drop the dependence of &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; in the start time variables. The optimization problem I am interested in is of the following form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\underset{\substack{\xi \in \Xi \\ S_v \in \mathbb{R}_{n}^{+}, \, v \in V}}{\max{}} &amp;amp;S_{\mathbf{w}} - S_{\mathbf{u}} - || \xi - \mathbf{\bar{\xi}} ||_1 \\&#xA; \mbox{s.t. } &amp;amp; S_{\mathbf{s}} = 0 \text{  i.e. the start time of source node is always 0} \tag{1}\label{Eq:1}\\&#xA;&amp;amp;S_v = L(\mathbf{s}, v, \xi) , \forall v \in V \backslash \mathbf{s} \tag{2} \label{Eq:2} \\&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w, u}$&lt;/span&gt; are some prespecified nodes both in &lt;span class=&quot;math-container&quot;&gt;$V \backslash \mathbf{s}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\bar{\xi} \in \Xi$&lt;/span&gt; is some constant vector. &lt;strong&gt;Note that in the optimization problem above, both arc lengths and start times of the nodes are variables in the problem&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I am wondering whether the problem shown above can be posed as a convex optimization problem or as a Mixed integer linear program without the use of big-M constants. Any help is appreciated.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My attempt:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, my formulation makes use of disjunctive constraints, which I believe will be hard to pose as a MILP without big-M constants. For &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$Pred(v) \subset V$&lt;/span&gt; denote the set of nodes that are connected to &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; by an arc in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; i.e., if &lt;span class=&quot;math-container&quot;&gt;$x \in Pred(v)$&lt;/span&gt; then the arc &lt;span class=&quot;math-container&quot;&gt;$(x, v) \in A$&lt;/span&gt;. We can write the optimization problem shown previously as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\underset{\substack{\xi \in \Xi \\ S_v \in \mathbb{R}_{n}^{+}, \, v \in V}}{\max{}} &amp;amp;S_{\mathbf{w}} - S_{\mathbf{u}}  - || \xi - \mathbf{\bar{\xi}} ||_1  \\&#xA; \mbox{s.t. } &amp;amp; S_{\mathbf{s}} = 0  \\&#xA;&amp;amp;S_v \geq S_{x} + L(x, v, \xi) , \forall v \in V \backslash \mathbf{s}, \forall x \in Pred(v) \tag{3} \label{Eq:3} \\&#xA;&amp;amp; \underset{x \in Pred(v)}{\lor} \left(S_v \leq S_{x} + L(x, v, \xi)\right) \forall v \in V \backslash \mathbf{s} \tag{4} \label{Eq:4}&#xA;\end{align}&lt;/span&gt;&#xA;In my attempt above, essentially I have just replaced constraint (\ref{Eq:2}) by two constraints (\ref{Eq:3}) and (\ref{Eq:4}). In Eqns (\ref{Eq:3}) and (\ref{Eq:4}), &lt;span class=&quot;math-container&quot;&gt;$ L(x, v, \xi)$&lt;/span&gt; simply denotes the length of the arc &lt;span class=&quot;math-container&quot;&gt;$(x, v)$&lt;/span&gt; in realization &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt;. Eqn (\ref{Eq:3}) enforces that the start time of &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is at least the start time of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; plus the length of the arc &lt;span class=&quot;math-container&quot;&gt;$(x,v)$&lt;/span&gt;. In Eqn (\ref{Eq:4}), &lt;span class=&quot;math-container&quot;&gt;$\lor$&lt;/span&gt; denotes the logical OR constraint. In Eqn (\ref{Eq:4}) we enforce the fact that the start time of each node is equal to the start time of one of its predecessors plus the length of the arc connecting the 2 nodes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT - As Mark points out in his post, disjunctive constraints can be alternatively represented using Indicator functions, which may be beneficial over big-M. I guess I am primarily interested in a strong formulation for my problem, and so would like to know how one may alternatively model the problem or perhaps use a different approach (for e.g. a decomposition method) to approach this problem.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2020-07-13T15:53:16.323" LastActivityDate="2020-07-13T15:53:16.323" Title="Is a convex or MILP (without big-M) formulation possible for this problem" Tags="|mixed-integer-programming|scheduling|convex-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4511" PostTypeId="2" ParentId="4510" CreationDate="2020-07-12T01:16:38.903" Score="3" Body="&lt;p&gt;Disjunctive constraints cam be expressed as a MILP using indicator constraints, which are different than Big M constraints, even if in some sense, they are morally equivalent.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://or.stackexchange.com/questions/231/when-to-use-indicator-constraints-versus-big-m-approaches-in-solving-mixed-int&quot;&gt;When to use indicator constraints versus big-M approaches in solving (mixed-)integer programs&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Does the reason for your &amp;quot;aversion&amp;quot; to Big M constraints extend to indicator constraints?&lt;/p&gt;&#xA;&lt;p&gt;MILPs are, of course, non-convex, but their continuous relaxation is convex (and concave!!).&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-07-12T01:16:38.903" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4512" PostTypeId="2" ParentId="4507" CreationDate="2020-07-13T04:26:29.117" Score="4" Body="&lt;p&gt;It's relatively easy to write &lt;span class=&quot;math-container&quot;&gt;$(1^{T}Kx)^{2}$&lt;/span&gt; in standard quadratic form.&lt;/p&gt;&#xA;&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$1^{T}Kx$&lt;/span&gt; is a scalar,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(1^{T}Kx)^{2}=(1^{T}Kx)(1^{T}Kx)^{T}=1^{T}Kxx^{T}K^{T}1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Using the cyclic property of the trace of a product of matrices,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1^{T}Kxx^{T}K^{T}1=\mbox{tr}(1^{T}Kxx^{T}K^{T}1)=\mbox{tr}(x^{T}K^{T}11^{T}Kx)=x^{T}(K^{T}11^{T}K)x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, &lt;span class=&quot;math-container&quot;&gt;$K^{T}11^{T}K$&lt;/span&gt; will be dense, so if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is large you'll probably run out of storage.&lt;/p&gt;&#xA;" OwnerUserId="103" LastActivityDate="2020-07-13T04:26:29.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4514" PostTypeId="1" CreationDate="2020-07-13T20:32:16.797" Score="2" ViewCount="124" Body="&lt;p&gt;Is the solution to an MINLP problem the global optimum to this problem?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2020-07-14T09:07:33.367" Title="MINLP Solution same as Global Optimum?" Tags="|minlp|global-optimization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4515" PostTypeId="2" ParentId="4514" CreationDate="2020-07-14T05:32:38.813" Score="1" Body="&lt;p&gt;This question is a matter of semantics.&lt;/p&gt;&#xA;&lt;p&gt;If by &amp;quot;solution&amp;quot;, you mean the global optimum, then yes, &amp;quot;the&amp;quot; (a) solution to an MINLP is a global optimum (note that some problems have more than one globally optimum solution).&lt;/p&gt;&#xA;&lt;p&gt;If, however, by &amp;quot;solution&amp;quot;, you mean a local, but not necessarily, global, optimum, then the solution to an MINLP is not necessarily a global optimum.&lt;/p&gt;&#xA;&lt;p&gt;As pointed out in a comment by @Oguz Toragay, branch and bound global optimizers, such as BARON, among others, attempt to find a global optimum. However, under computing time constraint (and to a lesser extent, memory constraint), they do not always succeed in reducing the gap (upper bound minus lower bound) to a satisfactory level. They can also run into numerical trouble and fail or produce an incorrect solution, no matter how much time or memory they are given. The only guaranteed protection against producing incorrect solutions due to bad numerics (scaling) is to use an interval-analysis-based solver with outward rounding. But interval-analysis-based global solvers are even less likely to reach a satisfactory conclusion.&lt;/p&gt;&#xA;&lt;p&gt;Some MINLP solvers, such as KNITRO, employ algorithms which will find the global optimum (if given enough computing time and memory) for problems for which the continuous relaxation is convex; But these algorithms are only heuristic, and not even guaranteed to find a local optimum, for problems for which the continuous relaxation is non-convex - the reported gap can even be negative (better than globally optimal, ha ha) because the algorithm may assume subproblems have been solved to global optimality, when in the absence of convexity, that may not be the case.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-07-14T05:32:38.813" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4516" PostTypeId="2" ParentId="4514" CreationDate="2020-07-14T09:07:33.367" Score="1" Body="&lt;p&gt;Technically, your statement is correct, but nowadays it depends on who you're talking to.&lt;/p&gt;&#xA;&lt;p&gt;Historically, to &lt;span class=&quot;math-container&quot;&gt;$\min f(x) s.t. ...$&lt;/span&gt;  means exactly what we see: to find the minimal value. Not some value that's smaller in some arbitrary neighborhood, &lt;strong&gt;the minimal&lt;/strong&gt; value.&lt;/p&gt;&#xA;&lt;p&gt;Ergo, the semantically correct way is to use &amp;quot;solution&amp;quot; for all global solutions, and &amp;quot;local solution&amp;quot; for, well, all other solutions.&lt;/p&gt;&#xA;&lt;p&gt;However, because of people's inability to find global solutions for decades, abuse of terminology came along, and people started referring to &amp;quot;solution&amp;quot; as any solution, which is technically incorrect.&lt;/p&gt;&#xA;&lt;p&gt;Nowadays, unless you're talking to a global optimisation person, this is the terminology people will understand.&lt;/p&gt;&#xA;&lt;p&gt;If you are talking to a global optimisation person they will still understand what you mean, politely nod, and silently condemn you for all time.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-07-14T09:07:33.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4517" PostTypeId="2" ParentId="4498" CreationDate="2020-07-14T16:11:53.187" Score="2" Body="&lt;p&gt;I'm shooting from the hip here (meaning none of the following ideas are tested), but a few different possibilities for heuristics come to mind.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Fix the order of &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; based on the order of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; rather than &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. Solve the resulting QP and check whether the &lt;span class=&quot;math-container&quot;&gt;$z\rightarrow \alpha$&lt;/span&gt; ordering condition is violated. If so, solve your problem 2 using the &lt;span class=&quot;math-container&quot;&gt;$\hat{z}$&lt;/span&gt; obtained from the first problem, and solve your problem 3 using the &lt;span class=&quot;math-container&quot;&gt;$\hat{\alpha}$&lt;/span&gt; from the first problem. Go with the better of those two solutions.&lt;/li&gt;&#xA;&lt;li&gt;Using binary variables to enforce the order constraints, solve the MILQP on appropriate size subsets of the data (small enough that the MILQP solves &amp;quot;quickly&amp;quot;). Average the resulting &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; vectors, use them to generate &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, the solve problem 2 for &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; based on the &amp;quot;consensus&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;There is a &amp;quot;random key&amp;quot; variant of genetic algorithms suitable for sequencing problems. You could try it. Each member of the population would be a vector of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; random keys, used to dictate the sort order of both &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. The fitness function would be the solution of the QP given a particular sort order. You could cache the fitness values, so that you would not have to repeat QPs, but it would still entail solving a boat-load of QPs.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-07-14T16:11:53.187" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4518" PostTypeId="2" ParentId="4471" CreationDate="2020-07-14T18:43:52.967" Score="5" Body="&lt;p&gt;You are looking for a proof for Total Unimodularity (TU). TU is a property by which a linear program will always have an integral solution. All you need to prove is that in your LP&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; matrix is TU and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; column has only integers.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;What is TU&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is unimodular if &lt;span class=&quot;math-container&quot;&gt;$\det(A) = 1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;A matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is Totally Unimodular (TU) if each square submatrix &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$\det(S) = 0, 1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Sufficient Condition For TU&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is TU if the number of non-zeros in each column is &lt;span class=&quot;math-container&quot;&gt;$\le2$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The sum of the entries of a column is zero&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Why does TU guarantees integral solution for a LP&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Consider the LP problem &lt;span class=&quot;math-container&quot;&gt;$Ax = b$&lt;/span&gt; with basis &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, the value of basic variables &lt;span class=&quot;math-container&quot;&gt;$x_B$&lt;/span&gt; can be obtained as &lt;span class=&quot;math-container&quot;&gt;$$x_B = B^{-1}b = \frac{\operatorname{adj}(B)}{\det(B)}b.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Since &lt;span class=&quot;math-container&quot;&gt;$\det(B) = -1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; (from TU of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; matrix) and the adjoint matrix is also integral it implies that &lt;span class=&quot;math-container&quot;&gt;$B^{-1}$&lt;/span&gt; is integral&lt;/li&gt;&#xA;&lt;li&gt;Since &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is integral, then &lt;span class=&quot;math-container&quot;&gt;$x_B$&lt;/span&gt; is also integral, hence guaranteeing and integral optimum for the LP.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;All network flow problems (shortest path, maximal flow, etc..) exhibit this property.&lt;/p&gt;&#xA;" OwnerUserId="873" LastEditorUserId="123" LastEditDate="2020-07-14T19:53:09.047" LastActivityDate="2020-07-14T19:53:09.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4519" PostTypeId="2" ParentId="4498" CreationDate="2020-07-15T10:44:38.093" Score="2" Body="&lt;p&gt;Although it might be possible to prove that you can obtain a convergent algorithm by alternating between the two problems, intuitively it seems unlikely to achieve constraint satisfaction with certainty. For guaranteed convergence, this is a problem that would typically be solved using continuous branch-and-bound. If you are a student/academic, you can test this with our &lt;a href=&quot;https://octeract.com/academic-licences/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Engine&lt;/a&gt; which is free for non-commercial use.&lt;/p&gt;&#xA;&lt;p&gt;That being said, a way to exploit the formulations algorithmically would be to warm-start the solution of Problem 1 with a feasible solution to either Problem 2 or Problem 3. This would start the algorithm at a point where a subset of the constraints is already satisfied.&lt;/p&gt;&#xA;&lt;p&gt;You can experiment with either, but I suspect that the best way to go about it would be to solve Problem 2 first, which would give you a feasible point to the non-convex sub-problem. It should then be much easier to obtain a solution that satisfies the remaining constraints.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-07-15T11:12:08.527" LastActivityDate="2020-07-15T11:12:08.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4520" PostTypeId="2" ParentId="4492" CreationDate="2020-07-15T11:57:02.787" Score="6" Body="&lt;p&gt;If the solution you provided is not very good (i.e., it's far from the global optimum), it often leads the branch-and-bound algorithm down a different path, which ends up slowing down the overall solution time.&lt;/p&gt;&#xA;&lt;p&gt;MIP solvers are very good in figuring this stuff out by themselves, so the best use of warm-start nowadays is when we solve many similar problems sequentially.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-07-15T11:57:02.787" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4521" PostTypeId="1" AcceptedAnswerId="4537" CreationDate="2020-07-15T13:56:11.970" Score="6" ViewCount="434" Body="&lt;p&gt;I would like to choose a set of &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt;s that maximizes a simple linear objective function of the type&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\underset{\beta_j}{\operatorname{max}}\sum_{j=1}^{J}X_j\beta_j \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to the following constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j=1}^{J}C_j(\beta_j)\beta_j \le M \\&#xA;\beta_j \in \Omega \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;here &lt;span class=&quot;math-container&quot;&gt;$C_j(\beta_j)$&lt;/span&gt; can be thought as a marginal cost function that changes with the chosen &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt; can only be from a set of pre-selected set of integers &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is some budget constraint.&lt;/p&gt;&#xA;&lt;p&gt;I don't know the functional form of &lt;span class=&quot;math-container&quot;&gt;$C_j(\beta_j)$&lt;/span&gt; but can simulate &lt;span class=&quot;math-container&quot;&gt;$C_j$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and each possible &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am having trouble understanding how to optimize this problem efficiently. Can someone give any direction on how this can be solved in R or Python?&lt;/p&gt;&#xA;" OwnerUserId="3852" LastEditorUserId="36" LastEditDate="2020-07-15T14:19:30.590" LastActivityDate="2020-07-17T13:26:03.030" Title="Linear objective function with non-linear constraints" Tags="|optimization|linear-programming|integer-programming|" AnswerCount="2" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="4522" PostTypeId="1" CreationDate="2020-07-15T18:15:26.787" Score="2" ViewCount="82" Body="&lt;p&gt;I have a list of paths e.g. path 1 takes you from point &lt;code&gt;A&lt;/code&gt; to &lt;code&gt;B&lt;/code&gt;. A person needs to complete 5 of such paths.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Route1 = path1 + path2 + path3 + path4 + path5$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objective:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ Min: D(endP1,startP2) + D(endP2,startP3) + D(endP3,startP4) + D(endP4,startP5)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$D(endP1, startP2)$&lt;/span&gt; represents the distance between the start point of path 2 and the end point of path 1.&lt;/p&gt;&#xA;&lt;p&gt;Constraints:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Except for the first path starting point for the next path and the ending&#xA;point of the first path should be within 100 meters distance. E.g. In a&#xA;route, there would be 5 paths. So the starting point of path 2 and the ending point of path 1 should be within 100 meters. Similarly, the starting&#xA;point of path 3 and the ending point of path 2 should be within 100&#xA;meters so on and so forth.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The ending point of the last path and the starting point of the 1st path should be within 100 meters.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each path takes a certain time to complete, so the next path should start at least 5min after the end time of the previous path.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The same path should not exist in more than 1 route.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I need to find possible routes where the objective is minimised.&lt;/p&gt;&#xA;&lt;p&gt;Available Data:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;List of paths&lt;/li&gt;&#xA;&lt;li&gt;Start Time &amp;amp; End time of Path.&lt;/li&gt;&#xA;&lt;li&gt;Start and the end point latitude &amp;amp; longitude.&lt;/li&gt;&#xA;&lt;li&gt;Total distance for the path. (I think that won't be useful to solve the&#xA;problem)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I need to formulate this problem and know possible techniques that can be applied to solve this problem, with working examples &amp;amp; readings.&lt;/p&gt;&#xA;&lt;p&gt;I need to find a list of unique routes that would contain 5 paths such that any of the path is not repeated in more than 1 route.&lt;/p&gt;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ Min: \sum D(S_i,E_{i-1}) \space i \in \{2,3,4,5\}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; is start point of path &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$E_{i-1}$&lt;/span&gt; is end point of path &lt;span class=&quot;math-container&quot;&gt;$i-1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum P_i = 5$$&lt;/span&gt;&#xA;where:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum P_i = \cases{0, if \space path \space not \space selected \cr&#xA;                 1, if \space path \space selected}  \space i \in Z^+$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$D(S_i,E_{i-1}) \le 100 \space i \in \{2,3,4,5\}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$D(E_5,S_1) \le 100$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$S_{t,i} - E_{t,i-1} &amp;gt;= 15 \space \forall \space t \in T, \space i \in \{2,3,4,5\} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I've formulated my first 3 constraints, I can't figure out how would the last constraint would be formulated.&lt;/p&gt;&#xA;&lt;p&gt;Then I need to know how such optimization problem can be solved. I know about simplex method but I don't think it will solve the problem.&lt;/p&gt;&#xA;&lt;p&gt;A working example along with a method to solve such problem would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3853" LastEditorUserId="3853" LastEditDate="2020-07-16T06:20:31.200" LastActivityDate="2020-07-16T06:20:31.200" Title="Finding Optimal Route using different Paths" Tags="|mixed-integer-programming|linear-programming|constraint-programming|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4523" PostTypeId="1" CreationDate="2020-07-15T19:33:19.690" Score="12" ViewCount="218" Body="&lt;p&gt;Some time ago, I wrote this answer: &lt;a href=&quot;https://or.stackexchange.com/a/3323/405&quot;&gt;https://or.stackexchange.com/a/3323/405&lt;/a&gt; to a question here on this stack exchange. I've had similar discussions with colleges, but I never found anything written down on &amp;quot;meta topics&amp;quot;. So I thought, probably someone else knows much more about this then me.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Actual Question:&lt;/strong&gt; I am looking for literature about operations research. In particular sources that look at it from a meta perspective. Examples of what I would consider &amp;quot;meta-questions&amp;quot; would be:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is operations research a form of engineering, an inductive or a deductive science?&lt;/li&gt;&#xA;&lt;li&gt;How is long term progress achieved and measured in operations research?&lt;/li&gt;&#xA;&lt;li&gt;How do the different subfields interact?&lt;/li&gt;&#xA;&lt;li&gt;Is there a theory to practice pipeline?&lt;/li&gt;&#xA;&lt;li&gt;Is there a pipeline in the opposite direction?&lt;/li&gt;&#xA;&lt;li&gt;How long are the pipelines?&lt;/li&gt;&#xA;&lt;li&gt;What differentiates operations research from the neighboring disciplines?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;TL,DR: Are there any meta papers about operations research?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2020-07-16T06:51:20.387" LastActivityDate="2020-07-28T01:23:51.057" Title="Meta papers on operations research" Tags="|reference-request|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4524" PostTypeId="1" CreationDate="2020-07-15T22:31:06.220" Score="1" ViewCount="72" Body="&lt;p&gt;I have a LP problem and derived the corresponding KKT conditions for the same. I simulated the LP and obtained the primal and dual values and manually checked if the KKT conditions hold. Is there any other way to check the correctness of KKT conditions?&lt;/p&gt;&#xA;" OwnerUserId="2546" LastActivityDate="2020-07-15T22:31:06.220" Title="Verifying the correctness of KKT conditions" Tags="|linear-programming|kkt-conditions|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4525" PostTypeId="2" ParentId="4523" CreationDate="2020-07-16T11:04:56.973" Score="6" Body="&lt;p&gt;&lt;a href=&quot;http://nand8a.com/orssa/orion/ORiON_22_155-180.pdf&quot; rel=&quot;noreferrer&quot;&gt;Is operations research really research?&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; discusses how the Design Research paradigm can be used to evaluate OR problems.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Manson, N. J. (2006). Is operations research really research?. &lt;em&gt;Orion.&lt;/em&gt; 22(2):155-180. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2020-07-16T11:42:59.893" LastActivityDate="2020-07-16T11:42:59.893" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4526" PostTypeId="2" ParentId="3828" CreationDate="2020-07-16T11:46:10.920" Score="6" Body="&lt;p&gt;The way I discover literature is to identify the key authors &amp;amp; papers in the field I'm interested in. From there on it's just a matter of following the citation trail. The influential authors/papers tend to be better written as well, which really helps when people are starting up.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-07-16T11:46:10.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4527" PostTypeId="2" ParentId="4521" CreationDate="2020-07-16T11:53:07.650" Score="2" Body="&lt;p&gt;Since you don't know the functional form, you can use &lt;a href=&quot;https://pypi.org/project/pypopt/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pypopt&lt;/a&gt;, the Python wrapper around Ipopt. Ipopt supports callbacks, which means you can provide functions for the solver to evaluate in real-time to get values &amp;amp; derivatives.&lt;/p&gt;&#xA;&lt;p&gt;Another way would be to use any of the genetic/evolutionary algorithms in Scipy.&lt;/p&gt;&#xA;&lt;p&gt;If you have values in a tabular format, i.e., you don't have a black-box function that can produce &lt;span class=&quot;math-container&quot;&gt;$C(\beta)$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;, the workaround for non-linear optimisation would be to simply interpolate between the closest values that you do have. Ipopt defaults to finite differences if you don't provide derivatives, so as a first-order approach you would only need to do this for the evaluation of the function (not the derivatives).&lt;/p&gt;&#xA;&lt;p&gt;It's important to know that it's incorrect to solve this directly as an MILP, as your &lt;span class=&quot;math-container&quot;&gt;$C(\beta)$&lt;/span&gt; would be fixed, rather than updated dynamically as it's supposed to.&lt;/p&gt;&#xA;&lt;p&gt;If you do want to use an MILP formulation to select values from a table you can, but with a few caveats:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you would lose the derivative-based information&lt;/li&gt;&#xA;&lt;li&gt;The number of new binaries won't scale well for dense tables&lt;/li&gt;&#xA;&lt;li&gt;The formulation can be quite challenging&lt;/li&gt;&#xA;&lt;li&gt;There's a decent chance you will need a commercial linear solver&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Thus, the best all-round (and free) option in my opinion would be callbacks through Ipopt.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-07-16T16:00:41.813" LastActivityDate="2020-07-16T16:00:41.813" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4528" PostTypeId="1" CreationDate="2020-07-16T13:02:21.837" Score="0" ViewCount="163" Body="&lt;p&gt;I have been working on an MIP in C#. I want to reduce the gap, so I'm trying warm start. I use this code just before &lt;code&gt;solve()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;try&#xA;    {&#xA;        startvar = new IIntVar[numberOfAllNode * numberOfAllNode];&#xA;        startval = new double[numberOfAllNode * numberOfAllNode];&#xA;&#xA;        for (int j = 1, idx = 0; j &amp;lt;= numberOfAllNode; j++)&#xA;            for (int i = 1; i &amp;lt;= numberOfAllNode; i++)&#xA;            {&#xA;                startvar[idx] = x[j][i];&#xA;                startval[idx] = x_value[j,i];&#xA;                idx++;&#xA;            }&#xA;&#xA;        startvar = null;&#xA;        startval = null;&#xA;        Cplex.AddMIPStart(startvar[], startval[], Cplex.MIPStartEffort.SolveMIP);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I got some syntax errors in the last line. unfortunately, I don't know what variable should I write in &lt;code&gt;startvar[]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3857" LastEditorUserId="500" LastEditDate="2023-12-13T18:00:39.263" LastActivityDate="2023-12-13T18:00:39.263" Title="How can I use warm start in C#" Tags="|cplex|c#|warm-start|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4529" PostTypeId="1" CreationDate="2020-07-16T19:24:56.533" Score="3" ViewCount="50" Body="&lt;p&gt;Does the situation in optimization ever occur in which you have a problem whose feasible set is not described in terms of explicit algebraic equations, but instead you have a large set of points that roughly approximates the feasible set?  If so, is there a term for this?&lt;/p&gt;&#xA;&lt;p&gt;In my particular case I have a large set of samples that I know to be feasible, and the natural thing to do is surround them with balls of some fixed radius, and then use their union as my feasible set.  I'd like to know if this is delving into some well-studied area of optimization.&lt;/p&gt;&#xA;" OwnerUserId="3858" LastActivityDate="2020-07-16T22:50:33.077" Title="Feasible sets represented as point clouds" Tags="|optimization|feasible-points|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4530" PostTypeId="2" ParentId="4529" CreationDate="2020-07-16T22:50:33.077" Score="3" Body="&lt;p&gt;I don't think I've ever seen a name (let alone any research) for the case of having a collection of known feasible points but no explicit mathematical criteria for feasibility.&lt;/p&gt;&#xA;&lt;p&gt;Before gluing together a bunch of balls, I would first ask whether the nature of the problem tells you anything about the shape of the feasible region. I'm assuming that your variables are not discrete, since the union of balls thing would not make sense for integer-valued variables (the union would contain non-integral points). Does the problem lead you to expect a convex feasible region? If so, the convex hull of your known feasible points would be a subset of the true feasible region (with no way of knowing how much of the feasible region you had not captured). If not convex, is there anything else you know about the feasible region based on the problem?&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-07-16T22:50:33.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4531" PostTypeId="1" CreationDate="2020-07-17T00:57:36.147" Score="4" ViewCount="30" Body="&lt;p&gt;DES (Discrete Event Simulation) is a simulation paradigm which can be applied to some OR problems, if combined with SO (Simulation Optimisation).&lt;/p&gt;&#xA;&lt;p&gt;AB-DES (Agent-Based DES) is an adaptation where the simulation model is broken up into many agents with internal state and behavior, and the dynamics of the system as a whole emerge from the individual behaviors and interactions among many agents. Typically there will be many agents of the same &amp;quot;type&amp;quot; e.g. many people interacting, many servers processing jobs, or other arbitrary entities from the ontology, implemented as agents.&lt;/p&gt;&#xA;&lt;p&gt;I am working with a DES architecture which seems similar to AB-DES but has some critical differences. Instead of a large number of autonomous agents with embedded behaviors, there are a large number of dumb entities in the model, and a small number of Actors which &amp;quot;act&amp;quot; on the model state by changing the state of various entities. These Actors do not have internal state, and they are independent of each other, interacting only by publishing messages on common channels and triggering discrete events. This means that the simulation can be modified with different behaviors by adding in different collections of Actors, leading to very flexible and customizable behavior.&lt;/p&gt;&#xA;&lt;p&gt;Has this architecture already been established in literature by some other name (I couldn't find it)? Is the architecture different enough from AB-DES to justify calling it a different paradigm, such as &amp;quot;Actor-Oriented DES&amp;quot; (AO-DES):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Number of agents:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;AB-DES: Many, one per entity in the model&lt;/li&gt;&#xA;&lt;li&gt;AO-DES: Few, one per process/behavior/phenomenon&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;State:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;AB-DES: Stored within each agent, agents modified their own state&lt;/li&gt;&#xA;&lt;li&gt;AO-DES: No state within actors, actors modify entity states&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Coupling/interaction:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;AB-DES: Agents can be tightly coupled and interact directly&lt;/li&gt;&#xA;&lt;li&gt;AO-DES: Actors are decoupled, interacting only indirectly via events and publisher/subscriber message channels&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1071" LastActivityDate="2020-07-17T00:57:36.147" Title="Is this the same as Agent Based DES or something different?" Tags="|simulation|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4532" PostTypeId="1" AcceptedAnswerId="4533" CreationDate="2020-07-17T02:03:41.863" Score="4" ViewCount="207" Body="&lt;p&gt;Is it possible to implement a column generation for a problem that the variables in the &amp;quot;complicating&amp;quot; constraint appear in the objective function?&lt;/p&gt;&#xA;&lt;p&gt;Suppose the MIP is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA; z = \min&amp;amp;\quad\sum_{ij} c_{ij} x_{ij} + \sum_i w_i\\&#xA;\text{s.t.}&amp;amp;\quad  A(x) \leq a, \tag1 \\&#xA;&amp;amp;\quad w_i \geq c_{ij}x_{ij}, \quad \forall i, j\tag2 \\&#xA;&amp;amp;\quad x_{ij} \in \{0,1\},\\&#xA;&amp;amp;\quad w_{i} \geq 0.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where constraint set (2) are the complicating constraints. If we ignore (2), then what happens to the objective function?&lt;/p&gt;&#xA;&lt;p&gt;P.S. I don't have the experience in implementing a column generation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I thank Rob for the great answer. For those unfamiliar with column generation, like me, there is additional information in the comments of his post as well.&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-07-20T02:22:33.607" LastActivityDate="2020-07-20T02:22:33.607" Title="Column generation when intractable variables appear in the objective function" Tags="|mixed-integer-programming|column-generation|implementation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4533" PostTypeId="2" ParentId="4532" CreationDate="2020-07-17T02:36:36.673" Score="8" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is the set of columns, where the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;th column &lt;span class=&quot;math-container&quot;&gt;$x^k \in \{0,1\}^n$&lt;/span&gt; satisfies &lt;span class=&quot;math-container&quot;&gt;$A(x^k) \le a$&lt;/span&gt;.  Now express &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; as a convex combination of the columns &lt;span class=&quot;math-container&quot;&gt;$x^k$&lt;/span&gt;.  Explicitly, substitute &lt;span class=&quot;math-container&quot;&gt;$x_{i,j} = \sum_{k\in K} \lambda_k x_{i,j}^k$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\sum_{k\in K} \lambda_k = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda_k \ge 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt;.  You then obtain the following master problem over &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, with dual variables in parentheses:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;\sum_{k\in K} \left(\sum_{i,j} c_{i,j} x_{i,j}^k\right) \lambda_k + \sum_i w_i \\&#xA;&amp;amp;\text{subject to} &amp;amp;w_i - c_{i,j} \sum_{k\in K} x_{i,j}^k \lambda_k &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $i,j$} &amp;amp;&amp;amp;(\pi_{i,j} \ge 0)\\&#xA;&amp;amp;&amp;amp;\sum_{k\in K} \lambda_k &amp;amp;= 1 &amp;amp;&amp;amp;&amp;amp;&amp;amp;(\text{$\alpha$ free})\\&#xA;&amp;amp;&amp;amp;\lambda_k &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $k$} \\&#xA;&amp;amp;&amp;amp;w_i &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $i$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The column generation subproblem over &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is then to minimize the reduced cost of &lt;span class=&quot;math-container&quot;&gt;$\lambda_k$&lt;/span&gt;.  That is, minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j} c_{i,j} (1+\pi_{i,j}) x_{i,j} - \alpha$$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$A(x) \le a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x \in\{0,1\}^n$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-07-17T04:26:56.963" LastActivityDate="2020-07-17T04:26:56.963" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4534" PostTypeId="1" CreationDate="2020-07-17T07:03:41.243" Score="2" ViewCount="246" Body="&lt;p&gt;For each observations there are 207 variables (binary, either a 'symptom' happened or not), class variable is also binary.&lt;/p&gt;&#xA;&lt;p&gt;For each variable or symptom there is a weight attached (currently set manually to be between -5 and 50) and for each observation there is a critical line (there are 3 different critical lines). Matrix of dummy variables is multiplied by weights and resulting matrix is added up across different columns for each observations resulting in some score. If this score is higher then particular critical line associated with observation then prediction is 1, otherwise is 0.&lt;/p&gt;&#xA;&lt;p&gt;The problem is to set up those weights and critical lines optimally. I obviously have a data set to see which symptoms usually correspond to '1' in prediction.&lt;/p&gt;&#xA;&lt;p&gt;For me it looks like an optimization problem but obviously the prediction itself can be made with machine learning but I am looking for another resource.&lt;/p&gt;&#xA;&lt;p&gt;Question is: do you guys know any areas of OR or can point out me some keywords to look at on how this type of problems are solved? I am good with Python so if you want to recommend me some packages I am more then happy. The only thing I though about is to randomly generate weights in (-5, 50) interval and for loads of trials maybe I will find ones that correspond to best accuracy (point is to minimize false positives).&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;&lt;p&gt;-EDIT 20.07&lt;/p&gt;&#xA;&lt;p&gt;My current formulation is as follows:&lt;/p&gt;&#xA;&lt;p&gt;max( sum over N (t_i * s_i))&#xA;st.&lt;/p&gt;&#xA;&lt;p&gt;(M x')_i &amp;gt;= L_i then s_i = 1&lt;/p&gt;&#xA;&lt;p&gt;(M x')_i &amp;lt; L_i then s_i = 0&lt;/p&gt;&#xA;&lt;p&gt;sum over N(s_i) =&amp;lt; 0.06N&lt;/p&gt;&#xA;&lt;p&gt;where N is the number of observation, M number of variables&#xA;x is a vector of weights, M is a NxM matrix of dummy variables where each row represents one observation therefore Mx' results in a Nx1 vector of cumulative weights for each observation.&lt;/p&gt;&#xA;&lt;p&gt;As I mentioned in the comment, optimal cut-off line L = [L_1, ..., L_n] is also a part of the problem. Vector of true allocations t is known.&#xA;The point is that once I got cut-off lines and weights, the system would process new observations using them.&lt;/p&gt;&#xA;&lt;p&gt;I also don't want to many positive s_i and this is another constrain of the problem.&lt;/p&gt;&#xA;&lt;p&gt;Thank you for all comments, I am new to stack exchange so please bear with me.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Blockquote&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3860" LastEditorUserId="3860" LastEditDate="2020-07-20T07:40:25.107" LastActivityDate="2020-07-24T06:51:44.773" Title="Is there any OR way to solve this problem?" Tags="|optimization|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4535" PostTypeId="2" ParentId="4534" CreationDate="2020-07-17T11:11:19.463" Score="1" Body="&lt;p&gt;There are multiple ways to solve this problem, in my opinion it would be more of a ML problem but you can do with linear programming.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; be the array of features for element &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Assuming you have a sample where given &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; you are told the class it belongs to (&lt;span class=&quot;math-container&quot;&gt;$S_0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt;), let &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; be the matrix of weights and let &lt;span class=&quot;math-container&quot;&gt;$b\in[0,1]$&lt;/span&gt; be an scalar. Establishing that&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;a_i'x \geq b \Longleftrightarrow a_i'\in S_0&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;a_i'x \lt b \Longleftrightarrow a_i'\in S_1&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, we could say the given sample should be classified correctly:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation*}&#xA;a_i'x \ge b, \hspace{10mm} i\in S_0 \\&#xA;a_i'x \lt b, \hspace{10mm} i\in S_1 &#xA;\end{equation*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;There is no need for an objective function, although you may need one in case the problem is infeasible (there is no linear separation). In that case your objective function could be to maximize the accuracy of your predictions, recall, f1-score, depends on the problem.&lt;/p&gt;&#xA;" OwnerUserId="3804" LastActivityDate="2020-07-17T11:11:19.463" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4537" PostTypeId="2" ParentId="4521" CreationDate="2020-07-17T12:53:13.920" Score="5" Body="&lt;p&gt;Given that my comment to the question has been referred  in the other existing answer, I will add it as an answer on its own.&#xA;The premise for the answer is that the &lt;span class=&quot;math-container&quot;&gt;$C_j(y)$&lt;/span&gt; function values can be precomputed for all values of &lt;span class=&quot;math-container&quot;&gt;$y\in\Omega$&lt;/span&gt;. The basic idea is to utilize that &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt; only contains a relatively small number of values in order to convert the problem into a binary linear program solvable by many commercial as well as free solvers.&lt;/p&gt;&#xA;&lt;p&gt;To that end, let &lt;span class=&quot;math-container&quot;&gt;$\omega_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt;, be the different values in &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt;. Then, for each &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j\in J$&lt;/span&gt; compute the values &lt;span class=&quot;math-container&quot;&gt;$C_j(\omega_i):=\gamma_{ij}$&lt;/span&gt;. Next, introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; equaling 1 iff &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt; takes the value &lt;span class=&quot;math-container&quot;&gt;$\omega_i$&lt;/span&gt;. We can then replace the variables &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt; with the sum &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in I}\omega_iz_{ij}$&lt;/span&gt;. The original problem can the be stated as&#xA;\begin{align}&#xA;\max&amp;amp; \sum_{j\in J}X_j \sum_{i \in I}\omega_iz_{ij}\\&#xA;\text{s.t.}:&amp;amp;\sum_{i\in I} z_{ij} = 1,&amp;amp;&amp;amp; \forall j\in J\\&#xA;&amp;amp; \sum_{j\in J} \sum_{i\in I} \gamma_{ij}\omega_iz_{ij}\leq M,\\&#xA;&amp;amp; z_{ij}\in \{0,1\},&amp;amp;&amp;amp;\forall i\in I,j \in J&#xA;\end{align}&#xA;I could imagine, but haven’t tested it, that many solvers can handle this somewhat simple MILP efficiently.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="500" LastEditDate="2020-07-17T13:26:03.030" LastActivityDate="2020-07-17T13:26:03.030" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4538" PostTypeId="2" ParentId="4534" CreationDate="2020-07-17T13:15:20.663" Score="1" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Given weights I can easily calculate how good these weights are for predicting but how can I determine weights?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;From the answer above, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; would represent the weights and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; the cut point to decide whether a sample belongs to &lt;span class=&quot;math-container&quot;&gt;$S_0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt;, those are the two variables in the OR problem. &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; represents the observations from the sample. Solving that problem in linear programming would give you the resulting weights as well as the cut point.&lt;/p&gt;&#xA;" OwnerUserId="3804" LastActivityDate="2020-07-17T13:15:20.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4539" PostTypeId="1" AcceptedAnswerId="4544" CreationDate="2020-07-17T14:16:12.393" Score="3" ViewCount="188" Body="&lt;p&gt;After writing an integer linear program in AMPL, I solved it using CPLEX. Now, I have some variables that must necessarily be 1, others that must necessarily be 0 and finally it is possible that some variables are free and therefore the number of optimal solutions can be greater than one.&lt;/p&gt;&#xA;&lt;p&gt;My question is: is there a way in AMPL to force all free variables to 0?&lt;/p&gt;&#xA;&lt;p&gt;I need this to find the solution that makes the most sense from a practical point of view.&lt;/p&gt;&#xA;" OwnerUserId="3863" LastEditorUserId="491" LastEditDate="2021-01-16T14:29:11.913" LastActivityDate="2021-01-16T14:29:11.913" Title="Find a particular optimal solution" Tags="|optimization|linear-programming|cplex|ampl|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4540" PostTypeId="1" AcceptedAnswerId="4541" CreationDate="2020-07-17T14:20:54.330" Score="12" ViewCount="6378" Body="&lt;p&gt;I have a convex polyhedron given by a set of linear inequalities, for example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_1 \geq 0,~~ x_2 \geq 0, ~~x_3\geq 0&#xA;\\&#xA;x_1+x_2\leq 1,~~ x_2+x_3\leq 1,~~ x_3+x_1\leq 1&#xA;$$&lt;/span&gt;&#xA;I want to list all the extreme points of the polyhedron. In this case, these points would be:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(0,0,0),~~(1,0,0),~~(0,1,0),~~(0,0,1),~~(1/2,1/2,1/2)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In python, there are several linear programming libraries, such as scipy.linprog or cvxpy, that can return one such extreme point using the Simplex method. But I want to list all of them. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2020-10-17T15:39:40.607" Title="How to find all vertices of a polyhedron" Tags="|linear-programming|python|solver|polyhedra|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4541" PostTypeId="2" ParentId="4540" CreationDate="2020-07-17T15:49:13.630" Score="12" Body="&lt;p&gt;The problem of enumerating all vertices of a polytope has been studied, see for example &lt;a href=&quot;https://link.springer.com/article/10.1007/s00454-008-9050-5&quot; rel=&quot;noreferrer&quot;&gt;Generating All Vertices of a Polyhedron Is Hard&lt;/a&gt; by Khachiyan, Boros, Borys, Elbassioni &amp;amp; Gurvich (available free online at Springer's website) and &lt;a href=&quot;https://www.jstor.org/stable/3689148?seq=1&quot; rel=&quot;noreferrer&quot;&gt;A Survey and Comparison of Methods for Finding All Vertices of Convex Polyhedral Sets&lt;/a&gt; by T. H. Matheiss and D. S. Rubin. That's a pretty old survey though (1980), so newer methods may be available.&lt;/p&gt;&#xA;&lt;p&gt;A naive brute force approach can be deduced from the definition of vertex/extreme point. Let's call the polytope &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;. Pseudocode can be as follows:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Select a subset of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; inequalities (in you example &lt;span class=&quot;math-container&quot;&gt;$n = 3$&lt;/span&gt;), getting a smaller linear system of inequalities with submatrix &lt;span class=&quot;math-container&quot;&gt;$A'$&lt;/span&gt; and vector &lt;span class=&quot;math-container&quot;&gt;$b'$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Solve the linear system &lt;span class=&quot;math-container&quot;&gt;$A'x = b'$&lt;/span&gt;. There are three cases here:&lt;/p&gt;&#xA;&lt;p&gt;a. The system has no solution: Then, return to (1) and select another subset (not chosen before).&lt;/p&gt;&#xA;&lt;p&gt;b. The system has no unique solution: Then, &lt;span class=&quot;math-container&quot;&gt;$A'$&lt;/span&gt; is linearly dependent. Return to (1) and select a new subset.&lt;/p&gt;&#xA;&lt;p&gt;c. The system has a unique solution: If that solution is feasible for &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;, then it's a vertex. Go back to (1).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The algorithm ends when no new subsets can be chosen. Note that different subsets of rows could yield the same vertex.&lt;/p&gt;&#xA;&lt;p&gt;A second alternative can be treating the polyhedron's vertices and edges as a graph (might work faster than the brute force solution above):&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start at any vertex &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; of the polytope. For example, the one you found using the Simplex, Interior Point or Ellipsoid method with some cost function.&lt;/li&gt;&#xA;&lt;li&gt;Find all &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;'s edges incident to &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. That is, all 1-dimensional faces of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;. This can be done similar to pivoting on nonbasic variables (with respect to the current vertex). Note that vertices are 0-dimensional faces of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Explore this graph (with the analogy of vertices and edges) using breadth-first search or depth-first search.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;As @batwing mentioned, another alternative is using the Double Description Method by Motzkin et al. to generate all extreme points and extreme rays of a general convex polyhedron represented as a system of linear inequalities &lt;span class=&quot;math-container&quot;&gt;$Ax \leq b$&lt;/span&gt;. An implementation called &lt;code&gt;cdd&lt;/code&gt; can be found at Komei Fukuda's website &lt;a href=&quot;https://people.inf.ethz.ch/fukudak/cdd_home/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, while &lt;a href=&quot;https://github.com/mcmtroffaes/pycddlib&quot; rel=&quot;noreferrer&quot;&gt;this GitHub repo&lt;/a&gt; contains &lt;code&gt;pycddlib&lt;/code&gt;,  a Python wrapper to interact with that library. Finally, &lt;a href=&quot;https://github.com/stephane-caron/pypoman&quot; rel=&quot;noreferrer&quot;&gt;at this repo&lt;/a&gt; the package &lt;code&gt;pypoman&lt;/code&gt; is developed to interact with the Python wrapper to get the extreme points for &lt;span class=&quot;math-container&quot;&gt;$Ax \leq b$&lt;/span&gt; starting from &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="2477" LastEditDate="2020-07-22T13:56:14.513" LastActivityDate="2020-07-22T13:56:14.513" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4542" PostTypeId="1" CreationDate="2020-07-17T16:04:08.163" Score="2" ViewCount="82" Body="&lt;p&gt;If not all constraints satisfy equalities, does Lagrangian dual method make sense to a convex problem?&lt;/p&gt;&#xA;" OwnerUserId="3864" LastActivityDate="2020-07-17T16:04:08.163" Title="Can every convex problem use Lagrangian dual method?" Tags="|convex-optimization|lagrangian-decomposition|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4543" PostTypeId="1" CreationDate="2020-07-17T16:27:38.903" Score="6" ViewCount="132" Body="&lt;p&gt;Suppose I know that for some non-convex program:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_x&amp;amp;\quad f(x)\\\text{s.t.}&amp;amp;\quad g_i(x)\leq 0, i \in C\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;strong duality holds for this problem. Now, suppose I form the dual by only dualizing a subset of the constraints so then the dual problem looks something like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max_\lambda \min_x&amp;amp;\quad f(x) + \sum_{i \in A}\lambda_ig_i(x)\\\text{s.t.}&amp;amp;\quad g_i(x)\leq 0, i \in C\setminus A\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Will the optimal objective value in this problem always equal the optimal objective value in the original primal problem? In other words, does &amp;quot;strong duality&amp;quot; hold between these two problems or does strong duality only hold when the dual problem is formed by dualizing all of the constraints?&lt;/p&gt;&#xA;" OwnerUserId="3826" LastEditorUserId="123" LastEditDate="2020-07-17T18:18:18.700" LastActivityDate="2020-07-18T17:43:57.303" Title="Does strong duality hold when I dualize only a subset of the constraints?" Tags="|nonlinear-programming|nonconvex-programming|duality|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4544" PostTypeId="2" ParentId="4539" CreationDate="2020-07-17T21:42:06.260" Score="6" Body="&lt;p&gt;I don't think there is anything special in AMPL for doing this, but it can be done.&lt;/p&gt;&#xA;&lt;p&gt;Option 1 is to add a term to the objective that penalizes the sum of all variables. (I'm assuming that all variables are nonnegative.) This will encourage the solver to force your &amp;quot;free&amp;quot; variables to zero. The catch is that you have to multiply this term by a coefficient that is small enough to prevent the secondary goal of getting the free variables to be zero from leading the solver to a suboptimal solution with regard to the original objective, while at the same time is not so small that the solver basically considers that term to be rounding error and ignores it.&lt;/p&gt;&#xA;&lt;p&gt;Option 2 is to solve the model twice. First solve the initial model. Next, add a constraint that says the objective value has to be at least as good as the optimal value (with perhaps a small adjustment away from optimality to account for rounding error), change the objective to minimize the sum of the variables, and solve again.&lt;/p&gt;&#xA;&lt;p&gt;Neither of these is foolproof, by the way. Assume there are three &amp;quot;free&amp;quot; variables. It is possible that the solver will have a choice between a solution with two small free variables and one zero versus a solution with one large free variable and two zeros, in which case the first solution might win in terms of the &amp;quot;sum of variables&amp;quot; criterion. Unfortunately, maximizing the actual number of zeros might involve adding binary variables (unless the &amp;quot;free&amp;quot; variables are all binary in the first place).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-07-17T21:42:06.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4545" PostTypeId="2" ParentId="4543" CreationDate="2020-07-18T02:10:45.530" Score="7" Body="&lt;p&gt;If strong duality holds, then it also holds when only a subset of the constraints is dualized.&lt;/p&gt;&#xA;&lt;p&gt;We define the following three problems: the original, the partially dualized, and the dual.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem (P1):&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_x&amp;amp;\quad f(x)\\\text{s.t.}&amp;amp;\quad g_i(x)\leq 0, i \in C\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem (P2):&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max_{\lambda\ge0} \min_x&amp;amp;\quad f(x) + \sum_{i \in A}\lambda_ig_i(x)\\\text{s.t.}&amp;amp;\quad g_i(x)\leq 0, i \in C\setminus A\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem (P3):&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max_{\mu\ge0} \max_{\lambda\ge0} \min_x&amp;amp;\quad f(x) + \sum_{i \in A}\lambda_ig_i(x) + \sum_{i \in C\setminus A}\mu_ig_i(x)\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is given that strong duality holds, which means that (P1) and (P3) have the same objective value. For convenience, denote this by f(P1) = f(P3).&lt;/p&gt;&#xA;&lt;p&gt;Using weak duality, we will show that f(P1) &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; f(P2) &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; f(P3). Because we know that f(P1) = f(P3), it must be that f(P1) = f(P2) = f(P3).&lt;/p&gt;&#xA;&lt;p&gt;From (P1) to (P2): let &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; be an optimal solution to (P1). Because &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; is feasible for (P1), we have &lt;span class=&quot;math-container&quot;&gt;$g_i(\bar{x})\le0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i\in C$&lt;/span&gt;. Next, plug &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; into (P2), which is feasible. Due to the non-negativity of the multipliers, it follows for any &lt;span class=&quot;math-container&quot;&gt;$\lambda \ge 0$&lt;/span&gt; that &lt;span class=&quot;math-container&quot;&gt;$f(\bar{x}) \ge f(\bar{x}) + \sum_{i \in A}\lambda_ig_i(\bar{x})$&lt;/span&gt;. Hence, f(P1) &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; f(P2).&lt;/p&gt;&#xA;&lt;p&gt;From (P2) to (P3): let &lt;span class=&quot;math-container&quot;&gt;$\bar{\lambda} \ge 0$&lt;/span&gt; be optimal multipliers for (P2) and let &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; be corresponding optimal primal variables. Using a similar argument, &lt;span class=&quot;math-container&quot;&gt;$\bar{\lambda}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; can be plugged into (P3). Because &lt;span class=&quot;math-container&quot;&gt;$\mu \ge 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_i(\bar{x})\le0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i\in C\setminus A$&lt;/span&gt;, we have for all &lt;span class=&quot;math-container&quot;&gt;$\mu \ge 0$&lt;/span&gt; that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\quad f(\bar{x}) + \sum_{i \in A}\bar{\lambda}_ig_i(\bar{x}) \ge f(\bar{x}) + \sum_{i \in A}\bar{\lambda}_ig_i(\bar{x}) + \sum_{i \in C\setminus A}\mu_ig_i(\bar{x}).$$&lt;/span&gt;&#xA;It follows that f(P2) &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; f(P3), which completes the proof.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="36" LastEditDate="2020-07-18T17:43:57.303" LastActivityDate="2020-07-18T17:43:57.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4546" PostTypeId="1" AcceptedAnswerId="4561" CreationDate="2020-07-18T22:50:40.327" Score="6" ViewCount="679" Body="&lt;p&gt;According to &lt;a href=&quot;https://en.wikipedia.org/wiki/Strong_duality&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;, strong duality holds when &amp;quot;the primal optimal objective and the dual optimal objective are equal.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;What are the necessary conditions for strong duality to hold in semidefinite programming?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would think this question would be easy to answer with a quick search, but instead I have ended up with many sources saying seemingly slightly different things. Let's go over them:&lt;/p&gt;&#xA;&lt;p&gt;1. &lt;a href=&quot;https://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15859-f11/www/notes/lecture12.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lecture notes from CMU course&lt;/a&gt;. The relevant section is 12.3.1 The Strong Duality Theorem for SDPs.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Theorem 12.9. Assume both primal and dual have feasible solutions. Then &lt;span class=&quot;math-container&quot;&gt;$v_{\text{primal}} ≥ v_{\text{dual}}$&lt;/span&gt;,&#xA;where &lt;span class=&quot;math-container&quot;&gt;$v_{\text{primal}}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v_{\text{dual}}$&lt;/span&gt; are the optimal values to the primal and dual respectively. Moreover,&#xA;if the primal has a strictly feasible solution (a solution &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$x \succ 0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is positive&#xA;definite) then&#xA;1) The dual optimum is attained (which is not always the case for SDPs) and&#xA;2) &lt;span class=&quot;math-container&quot;&gt;$v_{\text{primal}}$&lt;/span&gt; = &lt;span class=&quot;math-container&quot;&gt;$v_{\text{dual}}$&lt;/span&gt;.&#xA;Similarly, if the dual is strictly feasible, then the primal optimal value is achieved, and equals&#xA;the dual optimal value. Hence, if both the primal and dual have strictly feasible solutions,&#xA;then both &lt;span class=&quot;math-container&quot;&gt;$v_{\text{primal}}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v_{\text{dual}}$&lt;/span&gt; are attained.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The first part of this seems to imply that all you need is for the primal &lt;em&gt;or&lt;/em&gt; the dual to have a strictly feasible solution. But then the very last line throws me off as it seems to imply that &lt;em&gt;both&lt;/em&gt; need a strictly feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;2. &lt;a href=&quot;https://people.eecs.berkeley.edu/%7Ewainwrig/ee227a/SDP_Duality.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lecture notes from Berkeley course&lt;/a&gt;. The relevant section is 12.3.2 Strong Duality.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;From Slater’s theorem, strong duality will hold if the primal problem is strictly feasible, that&#xA;is, if there exist &lt;span class=&quot;math-container&quot;&gt;$X \succ 0$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\langle A_i, X \rangle = b_i, i = 1, \ldots , m$&lt;/span&gt;.&#xA;Using the same approach as above, one can show that the dual of problem (13.5) is&#xA;precisely the primal problem (13.2). Hence, if the dual problem is strictly feasible, then&#xA;strong duality also holds. Recall that we say that a problem is attained if its optimal set is&#xA;not empty. It turns out that if both problems are strictly feasible, then both problems are&#xA;attained.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I have the exact same problem with this one. It first seems to say you only need one of the two to be strictly feasible. Then it seems to imply that actually both must be strictly feasible. Or is it possible for strong duality to hold even when one of the two has an empty optimal set? I don't see how this makes sense.&lt;/p&gt;&#xA;&lt;p&gt;3. &lt;a href=&quot;https://www.cse.iitk.ac.in/users/rmittal/prev_course/s18/reports/9dual_sdp.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lecture notes from IIT Kanpur&lt;/a&gt;. The relevant section is 4 Extra reading: Strong duality, Slater’s condition.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Theorem 1. Given a semidefinite program in standard form with parameters &lt;span class=&quot;math-container&quot;&gt;$C, A_i&#xA;, b$&lt;/span&gt;, suppose the feasible&#xA;set of primal is &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and feasible set of dual is &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;. Then strong duality holds if either&#xA;&lt;span class=&quot;math-container&quot;&gt;$D \ne \emptyset$&lt;/span&gt; and there exists a strictly feasible &lt;span class=&quot;math-container&quot;&gt;$X ∈ P$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$X \succ 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Ai • X = b_i &#xA; \forall i$&lt;/span&gt;&#xA;&lt;strong&gt;or&lt;/strong&gt;&#xA;if &lt;span class=&quot;math-container&quot;&gt;$P \ne \emptyset$&lt;/span&gt; and there exists a strictly feasible &lt;span class=&quot;math-container&quot;&gt;$y \in D$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$\sum_i y_i A_i - C \succ 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This throws in an extra condition that neither of the previous two have. You need one of the two to be strictly feasible, and you need the other one to simply have some feasible solution.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I have also taken a look at &lt;a href=&quot;https://en.wikipedia.org/wiki/Slater%27s_condition&quot; rel=&quot;nofollow noreferrer&quot;&gt;Slater's condition&lt;/a&gt; which seems to imply that you just need either the primal &lt;em&gt;or&lt;/em&gt; the dual to be strictly feasible.&lt;/p&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="491" LastEditDate="2023-04-14T11:29:42.527" LastActivityDate="2023-04-14T11:29:42.527" Title="Conditions required for strong duality to hold for SDPs" Tags="|convex-optimization|semidefinite-programming|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="4547" PostTypeId="1" CreationDate="2020-07-18T23:50:21.040" Score="2" ViewCount="528" Body="&lt;p&gt;Consider this to be our SDP problem:&lt;/p&gt;&#xA;&lt;p&gt;Minimize &lt;span class=&quot;math-container&quot;&gt;$\langle C, X \rangle$&lt;/span&gt; such that&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\langle A_i, X  \rangle \ge b_i$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i \in [m]$&lt;/span&gt; and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$X \succcurlyeq 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;For SDPs, is there a relationship between the extreme points of the feasible region and the optimal solutions?&lt;/strong&gt;&lt;/em&gt; In particular, does at least one optimal solution lie at an extreme point? (I know this is true for LPs, but does it extend to SDPs?)&lt;/p&gt;&#xA;&lt;p&gt;For reference, I am asking because I am looking at two proofs (&lt;a href=&quot;https://web.stanford.edu/class/msande314/lecture05.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt; and &lt;a href=&quot;http://www.iasi.cnr.it/%7Eventura/Cargese19/slides/singh.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;) of a theorem by Barvinok and Pataki, and they formulate their statements of the theorem in different ways. In particular, the difference makes me suspect there is some relationship between extreme points and optima.&lt;/p&gt;&#xA;&lt;p&gt;Edit: By extreme point I mean vertex.&lt;/p&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="3866" LastEditDate="2020-07-19T02:28:02.840" LastActivityDate="2020-07-19T02:31:38.170" Title="Relationship between extreme points and optimal solutions of SDPs" Tags="|convex-optimization|sdp|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4548" PostTypeId="2" ParentId="4547" CreationDate="2020-07-19T02:05:08.257" Score="1" Body="&lt;p&gt;I now believe the answer is yes. I.e., at least one optimal solution will lie at an extreme point. See Hermann Schichl's answer &lt;a href=&quot;https://www.researchgate.net/post/Why_are_optimal_solutions_found_at_boundary_points_Can_the_solution_be_within_the_feasible_region&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. For a minimization problem, you need a convex objective function on a convex domain. For a maximization problem, the objective function must instead be concave. Since SDPs have a linear objective function and a convex feasible region, we are good to go in either case.&lt;/p&gt;&#xA;&lt;p&gt;The intuition behind my answer in either case is if the optimum is an interior point, you can write it as a convex combination of extreme points/vertices. Then use the appropriate version of &lt;a href=&quot;https://mathworld.wolfram.com/JensensInequality.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jensen's inequality&lt;/a&gt; based on whether the objective function is convex (minimization) or concave (maximization) to show that at least one of the extreme points also achieves the optimum.&lt;/p&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="3866" LastEditDate="2020-07-19T02:31:38.170" LastActivityDate="2020-07-19T02:31:38.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4549" PostTypeId="1" CreationDate="2020-07-20T06:21:58.800" Score="4" ViewCount="241" Body="&lt;p&gt;I have different metaheuristics (Tabu search, Simulated annealing, Iterated local search) solving an optimization problem (a variant of the resource-constrained project scheduling problem). Each metaheuristic is implemented separately in Python.&lt;/p&gt;&#xA;&lt;p&gt;I want to make an &amp;quot;island model&amp;quot; i.e to run them in parallel with the possibility of handing high-quality solutions to one another i.e keeping track of the best-found solution among all the metaheuristics. If a new higher quality solution using some metaheuristic, every other metaheuristic will then restart from that solution. I am not sure it's the right term&lt;/p&gt;&#xA;&lt;p&gt;I would be grateful if you could guide me on how to do it. I hope I will not need to re-implement everything from scratch.&lt;/p&gt;&#xA;&lt;p&gt;Another question: Is there a risk of implementing a &amp;quot;fancy thing&amp;quot; that could be useless? If so, how to figure out &lt;em&gt;in advance&lt;/em&gt; if the parallelization will be useful.&lt;/p&gt;&#xA;&lt;p&gt;P.S: I don't have any knowledge about parallel methods, except for knowing the term &amp;quot;island model&amp;quot; =).&lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2020-07-20T12:44:27.320" LastActivityDate="2020-07-20T14:08:03.263" Title="How to parallelize metaheuristics algorithms (Island Model)?" Tags="|metaheuristics|parallel-computing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4551" PostTypeId="2" ParentId="4528" CreationDate="2020-07-20T12:48:00.060" Score="2" Body="&lt;p&gt;This looks like a plain C# programming error.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Don't set &lt;code&gt;startvar&lt;/code&gt; and &lt;code&gt;startval&lt;/code&gt; to &lt;code&gt;null&lt;/code&gt; before calling &lt;code&gt;AddMIPStart&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Remove square brackets from &lt;code&gt;startvar&lt;/code&gt; and &lt;code&gt;startval&lt;/code&gt; in the cal to &lt;code&gt;AddMIPStart&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3179" LastActivityDate="2020-07-20T12:48:00.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4552" PostTypeId="2" ParentId="4549" CreationDate="2020-07-20T14:01:03.447" Score="3" Body="&lt;p&gt;The easiest way is to use the &lt;a href=&quot;https://docs.python.org/3/library/multiprocessing.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python multiprocessing module&lt;/a&gt; (or similar). You can create a pool of parallel workers, each of which would run a different heuristic. The multiprocessing toolbox also allows you to pass messages between processes, which you can use to communicate information among them (e.g., solution vectors).&lt;/p&gt;&#xA;&lt;p&gt;In order to do that you would need synchronization points inside your heuristics, i.e., &amp;quot;checkpoints&amp;quot; where each worker requests information from a manager process. If no new information is available in the message it receives, it keeps calculating as normal, and if there's new information it does stuff.&lt;/p&gt;&#xA;&lt;p&gt;The cleanest design is to have a dedicated process as the manager, and that process will be responsible for all communication between workers. Workers should only be able to communicate with the manager, and not with each other. This design pattern is crucial for good scaling and avoiding deadlocks &amp;amp; bottlenecks.&lt;/p&gt;&#xA;&lt;p&gt;Be warned though that parallel computing is hard and full of quirks and subtle edge cases, even in Python. Always implement the bare minimum of the functionality you need. Test, test, test, and if it works for you, you're done. Complexity is your greatest enemy here because debugging becomes rapidly intractable in complicated parallel code.&lt;/p&gt;&#xA;&lt;p&gt;My advice would be to consistently test everything, even syntax that &amp;quot;surely&amp;quot; does what you think it should - in parallel it rarely does, especially in Python.&lt;/p&gt;&#xA;&lt;p&gt;W.r.t. your second question, yes, definitely. Parallel code is very time consuming, so unless there is a clear need for it, you probably shouldn't do it. Some indicators that it might work for you are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There are numerous independent steps in your algorithm that take roughly the same time.&lt;/li&gt;&#xA;&lt;li&gt;If your tasks differ by too much in execution time you need asynchronous parallel code which is much more complicated.&lt;/li&gt;&#xA;&lt;li&gt;If you have one expensive chunk of calculations and everything else is cheap by comparison, you will not see benefits.&lt;/li&gt;&#xA;&lt;li&gt;The application actually &amp;quot;needs&amp;quot; more speed. If it doesn't you need to make a business case to your boss about why this quality of life feature is something they should be spending money on.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Finally, keep in mind that you can simply run the same Python script multiple times with different inputs as background processes, and the OS will run them in parallel if you have enough cores.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-07-20T14:08:03.263" LastActivityDate="2020-07-20T14:08:03.263" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4553" PostTypeId="1" CreationDate="2020-07-20T15:12:38.223" Score="4" ViewCount="183" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_{i=1}^N\frac{A_i}{x_i}\\\text{s.t.}&amp;amp;\quad\sum x_i \le X\\&amp;amp;\quad x_i \ge 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;wherein &lt;span class=&quot;math-container&quot;&gt;$A_i&amp;gt;0, (i\in\{1,\dots,N\})$&lt;/span&gt; is constant, &lt;span class=&quot;math-container&quot;&gt;$x_i, (i\in\{1,\dots,N\})$&lt;/span&gt; is a continuous optimization variable.&lt;/p&gt;&#xA;" OwnerUserId="3864" LastEditorUserId="500" LastEditDate="2020-07-20T19:47:21.080" LastActivityDate="2020-07-20T19:47:21.080" Title="Can we get closed form solution for such a problem?" Tags="|convexity|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4554" PostTypeId="2" ParentId="4553" CreationDate="2020-07-20T15:36:46.083" Score="5" Body="&lt;p&gt;If some &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; is negative the problem is unbounded: we can make the objective arbitrarily small by making &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; arbitrarily close to 0.&lt;/p&gt;&#xA;&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$A_i \geq 0$&lt;/span&gt;, the optimality is obtained when all &lt;span class=&quot;math-container&quot;&gt;$\frac{A_i}{x_i^2}$&lt;/span&gt; are equal (KKT optimality conditions), or equivalently all &lt;span class=&quot;math-container&quot;&gt;$\frac{x_i^2}{A_i}$&lt;/span&gt; are equal, and &lt;span class=&quot;math-container&quot;&gt;$\sum x_i  = X$&lt;/span&gt; (otherwise you can increase some &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and reduce the objective).&lt;/p&gt;&#xA;&lt;p&gt;Stating &lt;span class=&quot;math-container&quot;&gt;$x_i = \sqrt{A_i} y$&lt;/span&gt;, you can deduce &lt;span class=&quot;math-container&quot;&gt;$y = \frac{X}{\sum \sqrt{A_i}}$&lt;/span&gt; from the equality.&lt;/p&gt;&#xA;&lt;p&gt;Therefore &lt;span class=&quot;math-container&quot;&gt;$x_i = \frac{\sqrt{A_i}}{\sum \sqrt{A_j}}X$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2020-07-20T15:45:02.097" LastActivityDate="2020-07-20T15:45:02.097" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="4555" PostTypeId="1" CreationDate="2020-07-21T05:33:57.223" Score="3" ViewCount="903" Body="&lt;p&gt;For an optimization problem, there are multiple-type variables should be optimized. Can we use the convex optimization method to solve a subproblem of partial variables, and then, with the obtained results of the subproblem, solve the remaining subproblem of other variables by reinforcement learning?&lt;/p&gt;&#xA;" OwnerUserId="3864" LastActivityDate="2020-07-22T08:48:47.060" Title="Can we use reinforcement learning and convex optimization to solve an optimization problem?" Tags="|convex-optimization|reinforcement-learning|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4556" PostTypeId="2" ParentId="4555" CreationDate="2020-07-21T10:31:06.677" Score="1" Body="&lt;p&gt;Not &lt;em&gt;really&lt;/em&gt;, but approximately. By OR standards, a problem is &amp;quot;solved&amp;quot; once we manage to satisfy the KKT conditions. There is no machine learning algorithm to date that can &lt;strong&gt;consistently&lt;/strong&gt; satisfy constraints. ML is designed to give pretty good approximations, and that's about it.&lt;/p&gt;&#xA;&lt;p&gt;For instance, image recognition can be posed as a convex optimisation problem, and we all know how well ML works on those problems. That doesn't mean however that it will always work (and it doesn't), unlike an optimisation algorithm.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-07-21T10:31:06.677" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4557" PostTypeId="1" AcceptedAnswerId="4559" CreationDate="2020-07-21T11:26:58.767" Score="3" ViewCount="162" Body="&lt;p&gt;In an applied project we are working on currently, we want to use robust or stochastic programming in order to enhance the performance of the systems (by reference to certain metrics). As you may already know, robust/stochastic optimizations allow to model the randomness impact of certain factors on a system behavior (in my case, its performance).&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, solving robust/stochastic problems is costly in time/resources or both: my question is how frequently the problem needs to be solved in order to provide up-to-date paramaters for the system to operate at maximized/required performance? What would be the best/most efficient interaction scenario for the system to trigger the problem solving process?&lt;/p&gt;&#xA;&lt;p&gt;Any feedback on previous experience or similar work would be very appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2599" LastActivityDate="2020-07-21T12:04:54.160" Title="Robust/Stochastic optimization deployed in real-world systems/applications" Tags="|applications|stochastic-programming|robust-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4558" PostTypeId="1" AcceptedAnswerId="4560" CreationDate="2020-07-21T11:28:32.227" Score="3" ViewCount="485" Body="&lt;p&gt;I am currently attempting to code a model using the Python API.&lt;/p&gt;&#xA;&lt;p&gt;However, the IBM Site seems to not have one that is similar in formating and content depth such as those for C++ or Java (examples and quick starter chapters).&lt;/p&gt;&#xA;&lt;p&gt;I am hazarding a guess that it might have been taken down for various reasons.&lt;/p&gt;&#xA;&lt;p&gt;Thus, may I ask if anyone possesses and is able to share a copy of it which is in PDF format?&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastActivityDate="2020-07-21T12:20:15.877" Title="CPLEX Python API Manual with References" Tags="|python|cplex|cplex-python-api|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4559" PostTypeId="2" ParentId="4557" CreationDate="2020-07-21T12:04:54.160" Score="4" Body="&lt;p&gt;This heavily depends on the application at hand and could vary all the way from milliseconds to months. It all comes down to rigorously defining the specs.&lt;/p&gt;&#xA;&lt;p&gt;Many parameters are in play:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How long does your feedback loop need to be, i.e., how often does your system &lt;em&gt;need&lt;/em&gt; to update?&lt;/li&gt;&#xA;&lt;li&gt;How high is the uncertainty and how does it grow over time?&lt;/li&gt;&#xA;&lt;li&gt;Do you know the statistical distribution of the uncertainty? If not, can you derive it with statistical confidence?&lt;/li&gt;&#xA;&lt;li&gt;How often does new data come in? For a chemical process that could be milliseconds, for price/demand optimisation it could be days/weeks/months.&lt;/li&gt;&#xA;&lt;li&gt;How frequently &lt;em&gt;can&lt;/em&gt; your physical system actually update? For instance, in factories some machines can take two days to shut down/start up.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Unfortunately there's no silver bullet here, your team will have to do bespoke engineering work to figure out the answers to these questions and create a solution that fits the physical system. You need to derive bounds for the uncertainty and then make sure the solution is &lt;em&gt;robust enough&lt;/em&gt; for the specs at hand.&lt;/p&gt;&#xA;&lt;p&gt;Once you figure out the specs, the rest is simply a matter of picking the right algorithm/tools to meet said specs.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-07-21T12:04:54.160" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4560" PostTypeId="2" ParentId="4558" CreationDate="2020-07-21T12:15:52.153" Score="5" Body="&lt;p&gt;Do you want the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/refpythoncplex/html/help.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;matrix oriented python  API&lt;/a&gt; or &lt;a href=&quot;http://ibmdecisionoptimization.github.io/docplex-doc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;docplex API&lt;/a&gt; ?&lt;/p&gt;&#xA;&lt;p&gt;For docplex, some very simple examples at &lt;a href=&quot;https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastEditorUserId="145" LastEditDate="2020-07-21T12:20:15.877" LastActivityDate="2020-07-21T12:20:15.877" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4561" PostTypeId="2" ParentId="4546" CreationDate="2020-07-21T23:40:48.090" Score="5" Body="&lt;p&gt;The following is from Section 2.2 of &lt;a href=&quot;http://opus.kobv.de/zib/volltexte/2000/603/pdf/ZR-00-34.pdf&quot; rel=&quot;noreferrer&quot;&gt;Semidefinite Programming for Combinatorial Optimization&lt;/a&gt; by Christoph Helmberg.&#xA;Let's define&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;p^* &amp;amp;= \inf\{\langle C,X\rangle\,:\,X\text{ primal feasible}\},\\&#xA;d^* &amp;amp;= \sup\{\langle b,y\rangle\,:\,y\text{ dual feasible}\}.&#xA;\end{align*}&lt;/span&gt;&#xA;In particular, &lt;span class=&quot;math-container&quot;&gt;$p^*=\infty$&lt;/span&gt; if the primal is infeasible, &lt;span class=&quot;math-container&quot;&gt;$d^*=-\infty$&lt;/span&gt; if the dual is infeasible, &lt;span class=&quot;math-container&quot;&gt;$p^*=-\infty$&lt;/span&gt; if the primal is unbounded and &lt;span class=&quot;math-container&quot;&gt;$q^*=\infty$&lt;/span&gt; if the dual is unbounded. Then the situation can be summarized as follows (Corollary 2.2.6 in the reference cited above).&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If the primal is strictly feasible and &lt;span class=&quot;math-container&quot;&gt;$p^*$&lt;/span&gt; is finite, then &lt;span class=&quot;math-container&quot;&gt;$p^*=d^*$&lt;/span&gt; and there is a dual solution that achieves this value.&lt;/li&gt;&#xA;&lt;li&gt;If the dual is strictly feasible and &lt;span class=&quot;math-container&quot;&gt;$d^*$&lt;/span&gt; is finite, then &lt;span class=&quot;math-container&quot;&gt;$p^*=d^*$&lt;/span&gt; and there is a primal solution that achieves this value.&lt;/li&gt;&#xA;&lt;li&gt;If both the primal and the dual are strictly feasible, then &lt;span class=&quot;math-container&quot;&gt;$p^*=d^*$&lt;/span&gt; and the value is attained for both problems.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;So in order to guarantee &lt;span class=&quot;math-container&quot;&gt;$p^*=d^*$&lt;/span&gt; it is sufficient that either one of the two problems is strictly feasible, but if we want a primal solution that achieves the value &lt;span class=&quot;math-container&quot;&gt;$p^*$&lt;/span&gt; we should ask for a strictly feasible solution of the dual.&lt;/p&gt;&#xA;" OwnerUserId="741" LastActivityDate="2020-07-21T23:40:48.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4562" PostTypeId="1" AcceptedAnswerId="4566" CreationDate="2020-07-22T00:22:04.987" Score="3" ViewCount="3180" Body="&lt;p&gt;I have just attempted to construct my first Pyomo model.&lt;/p&gt;&#xA;&lt;p&gt;However, I was unable to locate any documentation that shows how to view constraints, decision variables.&lt;/p&gt;&#xA;&lt;p&gt;As my model is big, I need to see that they are created and indexed correctly from time-to-time before proceeding further.&lt;/p&gt;&#xA;&lt;p&gt;May I ask if anyone has chanced upon such documentation or have devised any ingenious method to do so within the confines of Python or Pyomo syntax?&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="123" LastEditDate="2020-07-22T20:15:33.673" LastActivityDate="2020-07-22T20:15:55.243" Title="View of Constraints and Decision Variables in Pyomo" Tags="|python|solver|constraint|pyomo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4563" PostTypeId="2" ParentId="4555" CreationDate="2020-07-22T05:04:41.187" Score="1" Body="&lt;p&gt;You can use RL in any step. But problem is optimality check of solution which is explained above. Also you can solve your problem directly using RL such as    &lt;a href=&quot;https://arxiv.org/abs/1802.04240&quot; rel=&quot;nofollow noreferrer&quot;&gt;RL for VRP&lt;/a&gt;. And you can read this blog &lt;a href=&quot;https://towardsdatascience.com/reinforcement-learning-for-combinatorial-optimization-d1402e396e91&quot; rel=&quot;nofollow noreferrer&quot;&gt;which is about RL usage&lt;/a&gt;. By the way your question is too broad to give detailed answer.&lt;/p&gt;&#xA;" OwnerUserId="432" LastEditorUserId="123" LastEditDate="2020-07-22T08:48:47.060" LastActivityDate="2020-07-22T08:48:47.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4564" PostTypeId="2" ParentId="4540" CreationDate="2020-07-22T11:09:42.143" Score="3" Body="&lt;p&gt;It seems to me that cdd libraries can be useful to solve this problem. Description is available at &lt;a href=&quot;https://people.inf.ethz.ch/fukudak/cdd_home/&quot; rel=&quot;nofollow noreferrer&quot;&gt;cdd&lt;/a&gt;. There is an implementation of this function in R: &lt;a href=&quot;https://cran.r-project.org/web/packages/rcdd/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;rcdd&lt;/a&gt;. You can use the following instruction to solve this problem:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-r prettyprint-override&quot;&gt;&lt;code&gt;install.packages(&amp;quot;rcdd&amp;quot;)&#xA;require(rcdd)&#xA;scdd(makeH(rbind(-diag(3),c(1,1,0),c(0,1,1),c(1,0,1)),c(rep(0,3),rep(1,3))))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3186" LastEditorUserId="123" LastEditDate="2020-07-22T20:16:43.833" LastActivityDate="2020-07-22T20:16:43.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4565" PostTypeId="1" AcceptedAnswerId="4567" CreationDate="2020-07-22T12:36:22.200" Score="3" ViewCount="1844" Body="&lt;p&gt;I am currently attempting to solve a network problem that is not fully connected.Thus, I have attempted to do some preprocessing of data so as to form a set of tuples, e.g. &lt;span class=&quot;math-container&quot;&gt;$\{(a,b), (c,e),\ldots\}$&lt;/span&gt;, i.e. from &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, from &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am able to declare binary decision variables with keys such as &lt;span class=&quot;math-container&quot;&gt;$(a,b)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(c,e)$&lt;/span&gt; via using the set of tuples for indexing.&lt;/p&gt;&#xA;&lt;p&gt;However, when I tried to use rules to declare constraints, with decision variables such as &lt;code&gt;x[i][j]&lt;/code&gt;, errors are thrown stating that &lt;span class=&quot;math-container&quot;&gt;$(a,b)$&lt;/span&gt; is an invalid index.&lt;/p&gt;&#xA;&lt;p&gt;Hence, I would like to ask if tuples can be used as indices for decision variables.&lt;/p&gt;&#xA;&lt;p&gt;If not, is there a way to only declare the only decision variables that are needed, rather than declaring all, and then setting those unneeded to 0.&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="123" LastEditDate="2020-07-22T20:15:11.870" LastActivityDate="2020-07-24T05:38:33.157" Title="Possibility of indexing decision variables with 2 indices using a set of tuples in Pyomo" Tags="|modeling|constraint|pyomo|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4566" PostTypeId="2" ParentId="4562" CreationDate="2020-07-22T19:18:34.080" Score="2" Body="&lt;p&gt;After defining your model by putting the following statement in your code (wherever you want before or after solve command) your model with all the objects has been printed:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.pprint() &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you like to print constraints or variables individually:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.cons1.pprint()  # For entire ConstraintList&#xA;print(model.cons2[i].expr)  # For only one index of ConstraintList&#xA;model.write() # To write the model into a file using .nl format&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Assuming that &lt;code&gt;model&lt;/code&gt; is the model that you defined and &lt;code&gt;cons1&lt;/code&gt; and &lt;code&gt;cons2&lt;/code&gt; are two ConstraintsList in that model.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2020-07-22T20:15:55.243" LastActivityDate="2020-07-22T20:15:55.243" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4567" PostTypeId="2" ParentId="4565" CreationDate="2020-07-22T20:10:55.350" Score="2" Body="&lt;p&gt;It is possible to use tuples as the indices of your variables. If the tuple like &lt;span class=&quot;math-container&quot;&gt;$(a_1, a_2)$&lt;/span&gt; is not defined in the index set, errors will be thrown but you can skip those undefined indices by using:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Constraint.Skip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;checking if the tuple is defined or not. An example of implementation would be as follow:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.cons = ConstraintList()        &#xA;for i in model.nodes:&#xA;    for j in model.nodes:&#xA;        if [i,j] in tuples_list:&#xA;           model.cons.add(&amp;quot;some expressions&amp;quot;)&#xA;        else:&#xA;            Constraint.Skip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastEditorUserId="123" LastEditDate="2020-07-22T20:15:23.813" LastActivityDate="2020-07-22T20:15:23.813" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4568" PostTypeId="1" CreationDate="2020-07-23T02:18:01.033" Score="3" ViewCount="347" Body="&lt;p&gt;I'm trying to find a way of setting the values of a binary MVar object (which is my decision variable) of size n to {-1,1}. Right now I have a vector that can either take values 0 or 1 (due to binary condition), but instead of 0 and 1, I need the variable to take the values -1 and 1. This is what I tried doing, but I don't think it's working:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x = m.addMVar(shape = n, vtype = GRB.BINARY, name = 'X') #My decision variable&#xA;&#xA;y = m.addMVar(shape = n, vtype = GRB.INTEGER, name = 'Y') #Auxiliar decision variable&#xA;&#xA;m.addConstr(y == 2*x - 1) #Transformation from {0,1} to {-1,1}&#xA;&#xA;m.setObjective(#function with y as decision variable)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3836" LastEditorUserId="2477" LastEditDate="2020-07-23T09:35:23.790" LastActivityDate="2020-07-23T09:35:23.790" Title="Decision variable transformation in Gurobi" Tags="|optimization|python|gurobi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4569" PostTypeId="2" ParentId="4568" CreationDate="2020-07-23T02:43:02.353" Score="3" Body="&lt;p&gt;If the shape n is for example a list of indices, then you need to index the variables when you add the constraints and loop through and each index:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.addConstrs(y[i] == 2*x[i] - 1 for i in n)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also note the “s” added to the addConstrs.&lt;/p&gt;&#xA;" OwnerUserId="3255" LastActivityDate="2020-07-23T02:43:02.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4570" PostTypeId="2" ParentId="4568" CreationDate="2020-07-23T07:13:06.510" Score="3" Body="&lt;p&gt;You need to change the lower bound of the auxiliary variables, i.e.,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;y = m.addMVar(shape = n, lb = -1, vtype = GRB.INTEGER, name = 'Y').&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that variables in Gurobi are usually defined between 0 and infinity except binary.&lt;/p&gt;&#xA;" OwnerUserId="2536" LastActivityDate="2020-07-23T07:13:06.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4571" PostTypeId="1" CreationDate="2020-07-23T09:20:39.253" Score="5" ViewCount="1007" Body="&lt;p&gt;Suppose we have a positive continuous variables &lt;span class=&quot;math-container&quot;&gt;$0 \le x \le UB$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$UB$&lt;/span&gt; is a known upper bound.&lt;/p&gt;&#xA;&lt;p&gt;How can we linearize the term &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Detailled problem:&lt;/p&gt;&#xA;&lt;p&gt;Suppose that via a callback we compute a factor namely &lt;span class=&quot;math-container&quot;&gt;$A_i \in ]0,1]$&lt;/span&gt;. After computing this factor: We need to add the following lazy constraint (using add(modeler,...)):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x^2_i \le A_i^2 \sum_k \sigma^2_k y_{ki}$&lt;/span&gt;; (&lt;span class=&quot;math-container&quot;&gt;$x_i \ge 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_{ki} \in \{0,1\}$&lt;/span&gt; are decision variables and &lt;span class=&quot;math-container&quot;&gt;$\sigma_k &amp;gt; 0$&lt;/span&gt; are known parameters).&lt;/p&gt;&#xA;&lt;p&gt;Adding this lazy constraint results in infeasible status given it is quadratic.&lt;/p&gt;&#xA;" OwnerUserId="3877" LastEditorUserId="3877" LastEditDate="2020-07-24T18:58:08.227" LastActivityDate="2020-07-24T18:58:08.227" Title="How to linearize a quadratic constraint to add it then via a callback function" Tags="|optimization|cplex|linearization|combinatorial-optimization|quadratic-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4572" PostTypeId="2" ParentId="4571" CreationDate="2020-07-23T13:10:57.797" Score="1" Body="&lt;p&gt;let me adapt the interpolate example from&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/pulse/tips-tricks-opl-cplex-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.linkedin.com/pulse/tips-tricks-opl-cplex-alex-fleischer/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;to x*x:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;float x[i in 0..sampleSize]=s+(e-s)*i/sampleSize;&#xA;&#xA;int nbSegments=5;&#xA;&#xA;float x2[i in 0..nbSegments]=(s)+(e-s)*i/nbSegments;&#xA;float y2[i in 0..nbSegments]=x2[i]*x2[i];  // y=f(x)&#xA;&#xA;float firstSlope=0;&#xA; float lastSlope=0;&#xA; &#xA; tuple breakpoint // y=f(x)&#xA; {&#xA;  key float x;&#xA;  float y;&#xA; }&#xA; &#xA; sorted { breakpoint } breakpoints={&amp;lt;x2[i],y2[i]&amp;gt; | i in 0..nbSegments};&#xA; &#xA; float slopesBeforeBreakpoint[b in breakpoints]=&#xA; (b.x==first(breakpoints).x)&#xA; ?firstSlope&#xA; :(b.y-prev(breakpoints,b).y)/(b.x-prev(breakpoints,b).x);&#xA; &#xA; pwlFunction f=piecewise(b in breakpoints)&#xA; { slopesBeforeBreakpoint[b]-&amp;gt;b.x; lastSlope } (first(breakpoints).x, first(breakpoints).y);&#xA; &#xA; assert forall(b in breakpoints) abs(f(b.x)-b.y)&amp;lt;=0.001;&#xA; &#xA; float maxError=max (i in 0..sampleSize) abs(x[i]*x[i]-f(x[i]));&#xA; float averageError=1/(sampleSize+1)*sum (i in 0..sampleSize) abs(x[i]*x[i]-f(x[i]));&#xA;&#xA;execute&#xA;    {&#xA;&#xA;    // turn an OPL array into a python list&#xA;    function getPythonListOfArray(_array)&#xA;    {&#xA;&#xA;    var quote=&amp;quot;\&amp;quot;&amp;quot;;&#xA;    var nextline=&amp;quot;\\\n&amp;quot;;&#xA;&#xA;&#xA;    var res=&amp;quot;[&amp;quot;;&#xA;    for(var i in _array)&#xA;    {&#xA;    var value=_array[i];&#xA;&#xA;    if (typeof(value)==&amp;quot;string&amp;quot;) res+=quote;&#xA;    res+=value;&#xA;    if (typeof(value)==&amp;quot;string&amp;quot;) res+=quote;&#xA;    res+=&amp;quot;,&amp;quot;;&#xA;    res+=nextline;&#xA;    }&#xA;    res+=&amp;quot;]&amp;quot;;&#xA;    return res;&#xA;    }&#xA;&#xA;    // Display a function with points with x and y arrays of x and y&#xA;    function displayXY(x,y,pythonpath,pythonfile)&#xA;    {&#xA;    writeln(&amp;quot;displayXY &amp;quot;,x,&amp;quot; &amp;quot;,y,&amp;quot; &amp;quot;,pythonpath,&amp;quot; &amp;quot;,pythonfile);&#xA;&#xA;    var python=new IloOplOutputFile(pythonfile);&#xA;    python.writeln(&amp;quot;import matplotlib.pyplot as plt&amp;quot;);&#xA;    python.writeln(&amp;quot;x = &amp;quot;,getPythonListOfArray(x))&#xA;    python.writeln(&amp;quot;y = &amp;quot;,getPythonListOfArray(y))&#xA;    python.writeln(&amp;quot;plt.plot(x, y)&amp;quot;);&#xA;    python.writeln(&amp;quot;plt.xlabel('x - axis')&amp;quot;);&#xA;    python.writeln(&amp;quot;plt.ylabel('y - axis')&amp;quot;);&#xA;    python.writeln(&amp;quot;plt.title('xy graph')&amp;quot;);&#xA;    python.writeln(&amp;quot;plt.show()&amp;quot;);&#xA;    python.close();&#xA;    IloOplExec(pythonpath+&amp;quot; &amp;quot;+ pythonfile,true);        &#xA;    }&#xA;   &#xA;&#xA;    }&#xA;  &#xA;&#xA;    int nbSegments2=10000;&#xA;&#xA;    float x3[i in 0..nbSegments2]=(s)+(e-s)*i/nbSegments2;&#xA;    float y3[i in 0..nbSegments2]=x3[i]*x3[i];  // y=f(x)&#xA;    float y3pwl[i in 0..nbSegments2]=f(x3[i]);  // y=f(x)&#xA;&#xA;    string pythonpath=&amp;quot;C:\\Python36\\python.exe&amp;quot;;&#xA;    string pythonfile=&amp;quot;C:\\temp\\DisplayXY.py&amp;quot;;&#xA;    execute&#xA;    {&#xA;&#xA;    // display x*x function&#xA;    displayXY(x3,y3,pythonpath,pythonfile);&#xA;    // display pwl approximation&#xA;    displayXY(x3,y3pwl,pythonpath,pythonfile);&#xA;    } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and you will see&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qlcFE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qlcFE.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and later on you may use f as square function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar float xx;&#xA;dvar float yy;&#xA;subject to&#xA;{&#xA;  xx==2;&#xA;  yy==f(xx);&#xA;}    &#xA;&#xA;execute&#xA;{&#xA;  writeln(&amp;quot;yy=&amp;quot;,yy);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;yy=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2020-07-23T14:05:19.893" LastActivityDate="2020-07-23T14:05:19.893" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4573" PostTypeId="2" ParentId="4571" CreationDate="2020-07-23T19:57:15.480" Score="3" Body="&lt;p&gt;You might want to take a look at two blog posts I wrote earlier this year:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://orinanobworld.blogspot.com/2020/03/approximating-nonlinear-functions.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Approximating Nonlinear Functions: Tangents v. Secants&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://orinanobworld.blogspot.com/2020/04/tangents-v-secants-part-ii.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tangents v. Secants Part II&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;If you approximate &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt; via tangents, all feasible points will satisfy your lazy constraint, but there will be some infeasible points that satisfy it. If you approximate &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt; via secants, all points that satisfy the lazy constraint will be feasible, but it will cut off some feasible points. In either case, the more granular the approximation (the more intervals in your piecewise linear function), the closer you get to what you want.&lt;/p&gt;&#xA;&lt;p&gt;The second post includes some Java code (using CPLEX).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-07-23T19:57:15.480" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4574" PostTypeId="1" CreationDate="2020-07-23T21:03:57.247" Score="3" ViewCount="722" Body="&lt;p&gt;I am very new to optimization and OR-Tools. I am trying to solve a very simple question.&lt;/p&gt;&#xA;&lt;p&gt;Let's assume that we have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; students. Each student needs to be assigned to only one teacher as a supervisor. There are several constraints that are not very critical for now. However, there are two types of supervisors.&#xA;But at the same time, I am trying to keep the balance of the workload of the teachers as much as possible.&lt;/p&gt;&#xA;&lt;p&gt;I am trying to write the objective but for some reason, it does not work correctly. I believe that I am missing something important.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = cp_model.CpModel()&#xA;&#xA;# Declare the variables.&#xA;x = []&#xA;for i in range(num_of_students):&#xA;    t = []&#xA;    for j in range(num_of_teacher):&#xA;        t.append(model.NewIntVar(0, 2, &amp;quot;x[%i,%i]&amp;quot; % (i, j))) #0 not supervisor, 1 1st type, 2nd type&#xA;    x.append(t)&#xA;&#xA;workload =[]&#xA;for j in range(num_of_teacher):&#xA;    workload.append(sum([x[i][j] for i in range(num_of_students)]))&#xA;&#xA;# Constraints&#xA;# Each student is assigned to EXACTLY one teacher.&#xA;[model.Add(sum(x[i][j] for j in range(num_of_teacher)) == 1)&#xA;for i in range(num_of_students)]&#xA;&#xA;#objective&#xA;model.Maximize( min(workload))&#xA;&#xA;solver = cp_model.CpSolver()&#xA;status = solver.Solve(model)&#xA;print (solver.ObjectiveValue())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I run the code, each student (I have 11 students and 3 teachers) is assigned to only one teacher. But all of them are the same teacher. When I look at the workloads, it is [0, 0, 11].&lt;/p&gt;&#xA;&lt;p&gt;However, system displays 11 as the ObjectiveValue. But min([0,0,11] is 0, right?.&lt;/p&gt;&#xA;&lt;p&gt;I also tried to write the objective as&#xA;&lt;code&gt;model.Minimize( max(workload))&lt;/code&gt; but all of the students assigned to only one teacher again.&lt;/p&gt;&#xA;" OwnerUserId="3881" LastEditorUserId="981" LastEditDate="2024-04-04T01:20:30.793" LastActivityDate="2024-04-04T01:20:30.793" Title="How to balance the workload of teachers in OR-Tools (maximization of the minimum)" Tags="|optimization|python|or-tools|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4575" PostTypeId="2" ParentId="4574" CreationDate="2020-07-23T22:10:52.177" Score="6" Body="&lt;p&gt;&lt;code&gt;min&lt;/code&gt;, &lt;code&gt;max&lt;/code&gt;, functions do not work in OR-Tools, you should use &lt;a href=&quot;https://google.github.io/or-tools/python/ortools/sat/python/cp_model.html#cp_model.CpModel.AddMinEquality&quot; rel=&quot;noreferrer&quot;&gt;AddMinEquality&lt;/a&gt; instead:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;...&#xA;workload = []&#xA;for j in range(num_of_teacher):&#xA;    tmp = model.NewIntVar(0, num_of_students, &amp;quot;&amp;quot;)&#xA;    model.Add(tmp == sum([x[i][j] for i in range(num_of_students)]))&#xA;    workload.append(tmp)&#xA;&#xA;...&#xA;obj = model.NewIntVar(0, num_of_students, &amp;quot;&amp;quot;)&#xA;model.AddMinEquality(obj, workload)&#xA;model.Maximize(obj)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Related links:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/issues/1581&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/google/or-tools/issues/1581&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/62666474/or-tools-cpsolver-get-minimum-and-maximum-sum-or-absolute/62666907#62666907&quot;&gt;https://stackoverflow.com/questions/62666474/or-tools-cpsolver-get-minimum-and-maximum-sum-or-absolute/62666907#62666907&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2020-07-24T00:16:06.720" LastActivityDate="2020-07-24T00:16:06.720" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4576" PostTypeId="1" AcceptedAnswerId="4577" CreationDate="2020-07-23T23:04:31.533" Score="3" ViewCount="695" Body="&lt;p&gt;I am trying to solve a problem that I believe is a variation of the &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_knapsack_problems&quot; rel=&quot;nofollow noreferrer&quot;&gt;multiple knapsacks&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Like the classical multiple knapsacks problem, I have a set of items, each one with a weight and a value and I am trying to divide them into multiple bins and find the combination with the best value.&lt;/p&gt;&#xA;&lt;p&gt;But unlike the classical, I also need the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Some bins might not accept some items, e.g.: I have item x and bins A, B, and C. Item x can only be added to the bins A and B.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The item can be divided, an item with 100 could be divided into two so that it fits two bins of 50. Note: all numbers are integers.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Even if the item can be divided, I must also make sure that all parts of the item weight are assigned to bins. e.g.:&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This has a valid solution:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;items = [200, 100]&#xA;bins = [150, 150]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This doesn't:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;items = [200]&#xA;bins = [150]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&lt;h1&gt;Is this a known problem?&lt;/h1&gt;&#xA;&lt;p&gt;It looks similar to the knapsack problem to me but does this variation have a name? If I knew the proper name for this problem I could search for solutions for it.&lt;/p&gt;&#xA;&lt;h1&gt;Is possible to solve with the solvers from OR-Tools?&lt;/h1&gt;&#xA;&lt;p&gt;I am using OR-Tools to explore this problem, but so far I haven't had any luck implementing this variation.&lt;/p&gt;&#xA;&lt;p&gt;This is a not homework, my items are actually invoices that I am trying to assign to investment bins.&lt;/p&gt;&#xA;" OwnerUserId="3882" LastEditorUserId="981" LastEditDate="2023-12-22T15:01:24.770" LastActivityDate="2023-12-22T15:01:24.770" Title="Multiple Knapsacks with splitting" Tags="|optimization|or-tools|knapsack|cp-sat|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4577" PostTypeId="2" ParentId="4576" CreationDate="2020-07-24T04:46:51.420" Score="3" Body="&lt;p&gt;This is not too big of a leap from the basic Knapsack problem and can be handled with only 3 constraints for the bin size, all-or-nothing, and the prohibited placements.  Below is an example that I think fits the design pattern.  This is casted in &lt;code&gt;pyomo&lt;/code&gt;.  I think OR-Tools is pretty similar in structure.  It should not be a major leap.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# multi-knapsack, integer divisible&#xA;&#xA;import pyomo.environ as pyo&#xA;&#xA;#           item:   value, weight&#xA;data = {    1:      (20, 10),&#xA;            2:      (30, 20),&#xA;            3:      (40, 5),&#xA;            4:      (5, 10),&#xA;            5:      (100, 10)}&#xA;#           bin:    capacity&#xA;bins = {    1:      8,&#xA;            2:      12,&#xA;            3:      14}&#xA;&#xA;prohibited = {(5, 1), (3, 2)}   # (item:bin) that are prohibited.&#xA;&#xA;mdl = pyo.ConcreteModel()&#xA;&#xA;# sets&#xA;mdl.invs = pyo.Set(initialize=data.keys())&#xA;mdl.bins = pyo.Set(initialize=bins.keys())&#xA;mdl.prohibited = pyo.Set(within=mdl.invs*mdl.bins, initialize=prohibited)&#xA;&#xA;# params&#xA;mdl.value   = pyo.Param(mdl.invs, initialize= {k:data[k][0] for k in data})&#xA;mdl.weight  = pyo.Param(mdl.invs, initialize= {k:data[k][1] for k in data})&#xA;mdl.bin_cap = pyo.Param(mdl.bins, initialize= bins)&#xA;&#xA;# vars&#xA;mdl.X = pyo.Var(mdl.invs, mdl.bins, domain=pyo.NonNegativeIntegers)     # the amount from invoice i in bin j&#xA;mdl.X_used = pyo.Var(mdl.invs, domain=pyo.Binary)&#xA;&#xA;### Objective ###&#xA;&#xA;mdl.OBJ = pyo.Objective(expr=sum(mdl.X[i, b]*mdl.value[i] for &#xA;                        i in mdl.invs for&#xA;                        b in mdl.bins), sense=pyo.maximize)&#xA;&#xA;### constraints ###&#xA;&#xA;# don't overstuff bin&#xA;def bin_limit(self, b):&#xA;    return sum(mdl.X[i, b] for i in mdl.invs) &amp;lt;= mdl.bin_cap[b]&#xA;mdl.c1 = pyo.Constraint(mdl.bins, rule=bin_limit)&#xA;&#xA;# all-or-nothing&#xA;def use_all(self, i):&#xA;    return sum(mdl.X[i, b] for b in mdl.bins) == mdl.X_used[i]*mdl.weight[i]&#xA;mdl.c2 = pyo.Constraint(mdl.invs, rule=use_all)&#xA;&#xA;# don't allow prohibited placements&#xA;def limit_prohib(self, i, b):&#xA;    return mdl.X[i, b] == 0&#xA;mdl.c3 = pyo.Constraint(mdl.prohibited, rule=limit_prohib)&#xA;&#xA;# solve it...&#xA;solver = pyo.SolverFactory('cbc')&#xA;results = solver.solve(mdl)&#xA;mdl.X.display()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Yields:&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;X : Size=15, Index=X_index&#xA;    Key    : Lower : Value : Upper : Fixed : Stale : Domain&#xA;    (1, 1) :     0 :   0.0 :  None : False : False : NonNegativeIntegers&#xA;    (1, 2) :     0 :   0.0 :  None : False : False : NonNegativeIntegers&#xA;    (1, 3) :     0 :   0.0 :  None : False : False : NonNegativeIntegers&#xA;    (2, 1) :     0 :   8.0 :  None : False : False : NonNegativeIntegers&#xA;    (2, 2) :     0 :   8.0 :  None : False : False : NonNegativeIntegers&#xA;    (2, 3) :     0 :   4.0 :  None : False : False : NonNegativeIntegers&#xA;    (3, 1) :     0 :   0.0 :  None : False : False : NonNegativeIntegers&#xA;    (3, 2) :     0 :   0.0 :  None : False : False : NonNegativeIntegers&#xA;    (3, 3) :     0 :   0.0 :  None : False : False : NonNegativeIntegers&#xA;    (4, 1) :     0 :   0.0 :  None : False : False : NonNegativeIntegers&#xA;    (4, 2) :     0 :   0.0 :  None : False : False : NonNegativeIntegers&#xA;    (4, 3) :     0 :   0.0 :  None : False : False : NonNegativeIntegers&#xA;    (5, 1) :     0 :   0.0 :  None : False : False : NonNegativeIntegers&#xA;    (5, 2) :     0 :   0.0 :  None : False : False : NonNegativeIntegers&#xA;    (5, 3) :     0 :  10.0 :  None : False : False : NonNegativeIntegers&#xA;[Finished in 2.9s]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3883" LastActivityDate="2020-07-24T04:46:51.420" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4578" PostTypeId="2" ParentId="4565" CreationDate="2020-07-24T05:02:09.663" Score="1" Body="&lt;p&gt;An example is as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;##First, create the set of tuples needed for filtering&#xA;&#xA;&#xA;#Op_Machine: set of (operation, machine) tuples created to avoid redundancy in decision variable declaration Op_Machine=list() for machine_id, op_proctime in Machine_Op_Time.items():&#xA;    for op in op_proctime.keys():&#xA;        print(Op_Machine)&#xA;        print((op,machine_id))&#xA;        Op_Machine.append((op,machine_id))&#xA;        print(Op_Machine)&#xA;&#xA;##Next, invoke the rule using the if statement to filter across all possible indices accepting those combinations that are aligned with the tuples within the set&#xA;##Use Constraint.Skip to Skip creating constraints that do not belong to the set of tuples&#xA;&#xA;&#xA;def F1_rule(model,i,k):&#xA;    if (i,k) in Op_Machine:&#xA;        ##print(i,k)&#xA;        return model.Cmax&amp;gt;=model.completion_time[i,k]&#xA;    else:&#xA;        return Constraint.Skip            &#xA;            &#xA;#model.makespan= Constraint(model.op_set, model.mach_set, rule=Cmax_rule) model.F1= Constraint(Operation_Set, Machine_Set, rule=F1_rule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that the sets Operation_Set, Machine_Set function as the universal set as it comprises all combinations of operations and machines. Hence the statement model.F1= Constraint(Operation_Set, Machine_Set, rule=F1_rule) can be thought a for loop that iterates over all combinations while the if statement within the def function acts a filter to generate the needed constraints.&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="3682" LastEditDate="2020-07-24T05:07:45.410" LastActivityDate="2020-07-24T05:07:45.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4579" PostTypeId="2" ParentId="4534" CreationDate="2020-07-24T05:03:50.670" Score="1" Body="&lt;p&gt;This sure sounds like you guys are taking the long road to Logistic Regression....&lt;/p&gt;&#xA;&lt;p&gt;You have a bunch of observations, presumably with outcomes to do the training or calculate the model, right?&lt;/p&gt;&#xA;&lt;p&gt;Each observation has 207 data elements that are numerical.  (Some/many of those will likely be dropped in the final model)&lt;/p&gt;&#xA;&lt;p&gt;And you want to make a model from that to use on new data to predict 1/0 outcomes?&lt;/p&gt;&#xA;&lt;p&gt;This is classic logistic regression, which should be your starting point (easiest) and then &lt;em&gt;maybe&lt;/em&gt; some ML model, but this is not optimization unless you consider the calculation of weights for logistical regression an optimization problem.&lt;/p&gt;&#xA;" OwnerUserId="3883" LastEditorUserId="123" LastEditDate="2020-07-24T06:51:44.773" LastActivityDate="2020-07-24T06:51:44.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4580" PostTypeId="2" ParentId="4565" CreationDate="2020-07-24T05:38:33.157" Score="2" Body="&lt;p&gt;Yes.  Totally doable.  Here are 2 examples using either tuples in a pyomo set or just making some up on-the-fly and passing them to a rule-based constraint to make the appropriate number of sparse constraints (seen in the result).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# subsets in tuples&#xA;&#xA;import pyomo.environ as pyo&#xA;&#xA;mdl = pyo.ConcreteModel()&#xA;&#xA;# sets&#xA;mdl.I = pyo.Set(initialize=range(4))&#xA;mdl.J = pyo.Set(initialize=range(3))&#xA;mdl.select_combos = pyo.Set(within = mdl.I * mdl.J, initialize = [(1,2), (3,1)])&#xA;&#xA;# vars&#xA;mdl.X = pyo.Var(mdl.I, mdl.J, domain=pyo.NonNegativeReals)&#xA;&#xA;# constraint with rule and tuples from pyomo Set&#xA;def c1(self, i, j):&#xA;    return mdl.X[i, j] &amp;lt;= 2&#xA;mdl.c1 = pyo.Constraint(mdl.select_combos, rule=c1)&#xA;&#xA;# or make a set of tuples of interest on the fly&#xA;my_combos = {(i, j) for i in mdl.I for j in mdl.J if&#xA;                i &amp;lt;=2 and&#xA;                j &amp;gt;=2 }&#xA;def c2(self, i, j):&#xA;    return mdl.X[i, j] &amp;gt;= 1&#xA;mdl.C2 = pyo.Constraint(my_combos, rule=c2)&#xA;&#xA;mdl.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Output:&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;6 Set Declarations&#xA;    C2_index : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None&#xA;        [(0, 2), (1, 2), (2, 2)]&#xA;    I : Dim=0, Dimen=1, Size=4, Domain=None, Ordered=False, Bounds=(0, 3)&#xA;        [0, 1, 2, 3]&#xA;    J : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=(0, 2)&#xA;        [0, 1, 2]&#xA;    X_index : Dim=0, Dimen=2, Size=12, Domain=None, Ordered=False, Bounds=None&#xA;        Virtual&#xA;    select_combos : Dim=0, Dimen=2, Size=2, Domain=select_combos_domain, Ordered=False, Bounds=None&#xA;        [(1, 2), (3, 1)]&#xA;    select_combos_domain : Dim=0, Dimen=2, Size=12, Domain=None, Ordered=False, Bounds=None&#xA;        Virtual&#xA;&#xA;1 Var Declarations&#xA;    X : Size=12, Index=X_index&#xA;        Key    : Lower : Value : Upper : Fixed : Stale : Domain&#xA;        (0, 0) :     0 :  None :  None : False :  True : NonNegativeReals&#xA;        (0, 1) :     0 :  None :  None : False :  True : NonNegativeReals&#xA;        (0, 2) :     0 :  None :  None : False :  True : NonNegativeReals&#xA;        (1, 0) :     0 :  None :  None : False :  True : NonNegativeReals&#xA;        (1, 1) :     0 :  None :  None : False :  True : NonNegativeReals&#xA;        (1, 2) :     0 :  None :  None : False :  True : NonNegativeReals&#xA;        (2, 0) :     0 :  None :  None : False :  True : NonNegativeReals&#xA;        (2, 1) :     0 :  None :  None : False :  True : NonNegativeReals&#xA;        (2, 2) :     0 :  None :  None : False :  True : NonNegativeReals&#xA;        (3, 0) :     0 :  None :  None : False :  True : NonNegativeReals&#xA;        (3, 1) :     0 :  None :  None : False :  True : NonNegativeReals&#xA;        (3, 2) :     0 :  None :  None : False :  True : NonNegativeReals&#xA;&#xA;2 Constraint Declarations&#xA;    C2 : Size=3, Index=C2_index, Active=True&#xA;        Key    : Lower : Body   : Upper : Active&#xA;        (0, 2) :   1.0 : X[0,2] :  +Inf :   True&#xA;        (1, 2) :   1.0 : X[1,2] :  +Inf :   True&#xA;        (2, 2) :   1.0 : X[2,2] :  +Inf :   True&#xA;    c1 : Size=2, Index=select_combos, Active=True&#xA;        Key    : Lower : Body   : Upper : Active&#xA;        (1, 2) :  -Inf : X[1,2] :   2.0 :   True&#xA;        (3, 1) :  -Inf : X[3,1] :   2.0 :   True&#xA;&#xA;9 Declarations: I J select_combos_domain select_combos X_index X c1 C2_index C2&#xA;[Finished in 2.5s]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3883" LastActivityDate="2020-07-24T05:38:33.157" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4581" PostTypeId="1" AcceptedAnswerId="4586" CreationDate="2020-07-24T15:20:58.263" Score="2" ViewCount="362" Body="&lt;p&gt;A typical gurobi log can have a section where it shows the range of coefficients. Something like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Coefficient statistics:&#xA;  Matrix range     [1e+00, 6e+01]&#xA;  Objective range  [5e+01, 9e+01]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [2e+04, 2e+04]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I've been looking around the docplex package and so far, I've only found the &lt;code&gt;print_information&lt;/code&gt; method of the &lt;code&gt;Model&lt;/code&gt; class which only shows general statistics about the model such as number and type of variables and constraints.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to display the range of coefficients in docplex log?&lt;/p&gt;&#xA;&lt;p&gt;Note:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;CPLEX Interactive Optimizer has &lt;code&gt;display problem stats&lt;/code&gt; but that's not what I'm looking for.&lt;/li&gt;&#xA;&lt;li&gt;I'm interested in knowing how or if this can be done in &lt;a href=&quot;http://ibmdecisionoptimization.github.io/docplex-doc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;docplex API&lt;/a&gt; and not the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/refpythoncplex/html/help.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;cplex python API&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="36" LastActivityDate="2022-06-22T17:58:41.837" Title="How to display the range of coefficients in docplex log?" Tags="|python|docplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4582" PostTypeId="1" AcceptedAnswerId="4583" CreationDate="2020-07-24T17:08:47.217" Score="2" ViewCount="173" Body="&lt;p&gt;For a discrete set of scenarios, minimising value at risk can be formulated as a mixed integer linear programming problem. If each scenario has equal probability then this can be written as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;\gamma\\&#xA;&amp;amp;\text{subject to} &amp;amp;(-r^{s}){'}X &amp;amp;\leq \gamma + M\cdot Y_{s} &amp;amp;&amp;amp;\text{$s = 1,\dots,S$} \tag1\\&#xA;&amp;amp;&amp;amp;\frac{1}{S}\sum_{s=1}^{S} Y_{s} &amp;amp;\leq \alpha \tag2\\&#xA;&amp;amp;&amp;amp;Y_{s} &amp;amp;\in \{0,1\} &amp;amp;&amp;amp;\text{$s = 1,\dots,S$} \\                       &#xA;&amp;amp;&amp;amp;\sum_{i=1}^{n}x_{i} &amp;amp;= 1&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is the confidence level say &lt;span class=&quot;math-container&quot;&gt;$0.05$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a big constant,&#xA;&lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; is the return on assets,&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; is the percentage in asset &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and&#xA;&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is the number of scenarios.&lt;/p&gt;&#xA;&lt;p&gt;If we assume that scenarios do not have same probabilities then constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; can be formulated as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$(-r^{s}\cdot P_{s}){'}X \leq \gamma + M\cdot Y_{s}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$P_{s}$&lt;/span&gt; is the probability of scenario &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;. But I am struggling with redefining constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How can this constraint/problem be formulated if scenarios have different probabilities?&lt;/p&gt;&#xA;" OwnerUserId="3217" LastEditorUserId="500" LastEditDate="2020-07-24T18:54:04.490" LastActivityDate="2020-07-25T08:43:31.200" Title="Scenario based approach to value-at-risk optimization using mixed-integer programming" Tags="|mixed-integer-programming|big-m|stochastic-programming|chance-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4583" PostTypeId="2" ParentId="4582" CreationDate="2020-07-24T20:43:58.993" Score="2" Body="&lt;p&gt;How about &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\gamma\\\text{s.t.}&amp;amp;\quad(-r^s)^\top X\leq \gamma + M Y_s \qquad s=1,\ldots,S\\&amp;amp;\quad\sum_{s=1}^SP_sY_s \leq \alpha\\&amp;amp;\quad \sum_{i=1}^nx_i=1\\&amp;amp;\quad Y_s\in\{0,1\}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="123" LastEditDate="2020-07-25T08:43:31.200" LastActivityDate="2020-07-25T08:43:31.200" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4584" PostTypeId="1" CreationDate="2020-07-24T21:18:08.120" Score="3" ViewCount="681" Body="&lt;p&gt;I have an optimization problem with an uncommon utility: to find a &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; that maximizes&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;r^{T}\cdot H(X\cdot\beta)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$H()$&lt;/span&gt; is a Heaviside step function as in &lt;a href=&quot;https://en.wikipedia.org/wiki/Heaviside_step_function&quot; rel=&quot;nofollow noreferrer&quot;&gt;wiki&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; is a vector of size 1000&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a 1000x50 &amp;quot;tall&amp;quot; matrix&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; is a vector of size 50&lt;/p&gt;&#xA;&lt;p&gt;I am familiar with gradient descent, which is how I usually solve an optimization problem. But Heaviside function does not work with gradient descent. So I am wondering if anyone here could shed some light on how to solve such optimization problem.&lt;/p&gt;&#xA;" OwnerUserId="758" LastEditorUserId="491" LastEditDate="2021-01-11T18:32:17.347" LastActivityDate="2021-01-11T18:32:17.347" Title="How to optimize a utility function that contains step function?" Tags="|optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4585" PostTypeId="2" ParentId="4584" CreationDate="2020-07-24T22:18:19.373" Score="4" Body="&lt;p&gt;You can solve the problem via integer linear programming as follows, assuming &lt;span class=&quot;math-container&quot;&gt;$r_i \ge 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.  Let &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; be a (small) upper bound on &lt;span class=&quot;math-container&quot;&gt;$-(X \cdot \beta)_i$&lt;/span&gt;.&#xA;Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$(X \cdot \beta)_i \ge 0$&lt;/span&gt;.  The problem is to maximize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{1000} r_i y_i$$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-(X \cdot \beta)_i \le M_i(1 - y_i)$$&lt;/span&gt;&#xA;for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&#xA;This &amp;quot;big-M&amp;quot; constraint enforces &lt;span class=&quot;math-container&quot;&gt;$y_i=1 \implies (X \cdot \beta)_i \ge 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-07-24T23:29:31.073" LastActivityDate="2020-07-24T23:29:31.073" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4586" PostTypeId="2" ParentId="4581" CreationDate="2020-07-25T06:14:12.023" Score="3" Body="&lt;p&gt;even from docplex you can get access to the cplex python API.&#xA;See example in SO for sensitivity analysis at &lt;a href=&quot;https://stackoverflow.com/questions/62475139/sensitivity-analysis-in-docplex&quot;&gt;https://stackoverflow.com/questions/62475139/sensitivity-analysis-in-docplex&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Plus before the solve see&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/DataCheck.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/DataCheck.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;« When the value of this parameter is set to level 2, CPX_DATACHECK_ASSIST, CPLEX turns on both data consistency checking and modeling assistance. At this level, CPLEX issues warnings at the start of the optimization about disproportionate values (too large, too small) in coefficients, bounds, and righthand sides (RHS). « &lt;/p&gt;&#xA;&lt;p&gt;that can if data check set to 2 spot numerical problems before solve&lt;/p&gt;&#xA;&lt;p&gt;regards&lt;/p&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2020-07-27T20:00:54.237" LastActivityDate="2020-07-27T20:00:54.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4587" PostTypeId="1" CreationDate="2020-07-25T12:57:50.070" Score="1" ViewCount="263" Body="&lt;p&gt;I have a scheduling problem to solve. It's a resource-constrained project scheduling problem with time-varying resource availabilities. The objective is minimizing tardiness. The full detailed model is given &lt;a href=&quot;https://drive.google.com/file/d/1x7wDYxQZMoKZrHnuMsqNeOuYrlvvhq7Y/view?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I implemented a heuristic based on a priority rule: At each step, the set of tasks can be divided to 3 sets: the set &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; of already-scheduled projects; the set &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; of &amp;quot;schedulable&amp;quot; tasks (tasks whose predecessors are already scheduled) and the set &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; of tasks not &amp;quot;schedulable&amp;quot; yet. At each step, we compute the priority of tasks in &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; and select the one with the highest probability. It's then scheduled at the earliest possible time when there is available resources.&lt;/p&gt;&#xA;&lt;p&gt;However, I want to find a way to somehow deal with this &amp;quot;infeasibility&amp;quot;case.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/1o9Rc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1o9Rc.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Remark: the green lines are the availabilities of the resource, Task A in blue is scheduled and task B in grey is not scheduled because it requires two units wheras only 1 unit is available.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the task A is scheduled first (because it has the highest priority), there will be not enough resource for the task B. Thus, by the end, not all the tasks are scheduled (task B is not scheduled). However if I've scheduled B first, it will be o.k, since task A  requires only one unit, and by the end all the tasks will be scheduled.&lt;/p&gt;&#xA;&lt;p&gt;PS: Finding a feasible solution is NP complete in this case.&lt;/p&gt;&#xA;" OwnerUserId="1188" LastEditorUserId="1188" LastEditDate="2020-07-26T13:06:46.237" LastActivityDate="2020-07-26T19:23:20.587" Title="How to correct this scheduling algorithm?" Tags="|scheduling|algorithms|feasible-points|local-search|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4588" PostTypeId="1" AcceptedAnswerId="4590" CreationDate="2020-07-25T21:24:38.647" Score="8" ViewCount="741" Body="&lt;p&gt;I have a basic knapsack problem where I need to fit the most weight possible in a bin:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;&#xA;&#xA;w = {'hammer': 5, 'wrench': 7, 'screwdriver': 4, 'towel': 3}&#xA;&#xA;limit = 14&#xA;&#xA;M = pyo.ConcreteModel()&#xA;&#xA;M.ITEMS = pyo.Set(initialize=w.keys())&#xA;&#xA;M.x = pyo.Var(M.ITEMS, within=pyo.Binary)&#xA;&#xA;M.value = pyo.Objective(expr=sum(M.x[i] for i in M.ITEMS), sense=pyo.maximize)&#xA;&#xA;M.weight = pyo.Constraint(expr=sum(w[i] * M.x[i] for i in M.ITEMS) &amp;lt;= limit)&#xA;&#xA;solver = pyo.SolverFactory(&amp;quot;cbc&amp;quot;)&#xA;solver.solve(M)&#xA;M.x.display()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Which works fine:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    Key         : Lower : Value : Upper : Fixed : Stale : Domain&#xA;         hammer :     0 :   1.0 :     1 : False : False : Binary&#xA;    screwdriver :     0 :   1.0 :     1 : False : False : Binary&#xA;          towel :     0 :   1.0 :     1 : False : False : Binary&#xA;         wrench :     0 :   0.0 :     1 : False : False : Binary&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My problem is that I need to include a value component and I must ensure that the &lt;strong&gt;average&lt;/strong&gt; value of all selected items is above a certain fixed threshold. I implemented it like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;v = {'hammer': 1, 'wrench': 3, 'screwdriver': 1, 'towel': 2}&#xA;w = {'hammer': 5, 'wrench': 7, 'screwdriver': 4, 'towel': 3}&#xA;&#xA;limit = 14&#xA;&#xA;M = pyo.ConcreteModel()&#xA;&#xA;M.ITEMS = pyo.Set(initialize=w.keys())&#xA;&#xA;M.x = pyo.Var(M.ITEMS, within=pyo.Binary)&#xA;&#xA;M.value = pyo.Objective(expr=sum(M.x[i] for i in M.ITEMS), sense=pyo.maximize)&#xA;&#xA;M.weight = pyo.Constraint(expr=sum(w[i] * M.x[i] for i in M.ITEMS) &amp;lt;= limit)&#xA;&#xA;M.above_average = pyo.Constraint(&#xA;    expr=sum(M.x[i] * v[i] for i in M.ITEMS) / sum(M.x[i] for i in M.ITEMS) &amp;gt;= 2&#xA;)&#xA;&#xA;&#xA;solver = pyo.SolverFactory(&amp;quot;cbc&amp;quot;)&#xA;solver.solve(M)&#xA;M.x.display()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But that caused the following error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ValueError: Cannot write legal LP file.  Constraint 'above_average' has a body with nonlinear terms.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I understand that the constraint that I added is non-linear, therefore the error message is correct. My question is &lt;strong&gt;how I could solve that with pyomo (or equivalent) or workaround this problem.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="3882" LastEditorUserId="500" LastEditDate="2020-07-26T03:26:25.047" LastActivityDate="2020-07-26T03:26:25.047" Title="knapsack problem with non-linear constraint" Tags="|linearization|pyomo|knapsack|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4589" PostTypeId="2" ParentId="4588" CreationDate="2020-07-25T23:16:53.610" Score="4" Body="&lt;p&gt;Here is a workaround for your nonlinear problem:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solver_manager = SolverManagerFactory('neos')&#xA;#solver = pyo.SolverFactory(&amp;quot;BARON&amp;quot;)&#xA;solution = solver_manager.solve(M, solver = 'couenne')&#xA;#solver.solve(M)&#xA;for i in M.ITEMS:&#xA;    print(i,':',pyo.value(M.x[i]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can either use a local nonlinear solver like BARON, or some solvers in NEOS server. I comment out the local solver option in the code, but you can easily use NEOS server to solve it. Please note that you need to add the following line to the beginning of your code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.opt.parallel import SolverManagerFactory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;solution of the model is(using cuenne in NEOS):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;hammer : 3.502043595574344e-08&#xA;wrench : 1.0&#xA;screwdriver : 1.0&#xA;towel : 1.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and with BARON:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;hammer 0.0&#xA;wrench 1.0&#xA;screwdriver 1.0&#xA;towel 1.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-07-25T23:16:53.610" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4590" PostTypeId="2" ParentId="4588" CreationDate="2020-07-26T03:11:14.647" Score="6" Body="&lt;p&gt;Hold the phone...&lt;/p&gt;&#xA;&lt;p&gt;You can keep this linear.  Just sum the selection variables and multiply by the min average requirement.  No division required.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;&#xA;v = {'hammer': 1, 'wrench': 3, 'screwdriver': 1, 'towel': 2}&#xA;w = {'hammer': 5, 'wrench': 7, 'screwdriver': 4, 'towel': 3}&#xA;&#xA;limit = 14&#xA;&#xA;M = pyo.ConcreteModel()&#xA;&#xA;M.ITEMS = pyo.Set(initialize=w.keys())&#xA;&#xA;M.x = pyo.Var(M.ITEMS, within=pyo.Binary)&#xA;&#xA;M.value = pyo.Objective(expr=sum(M.x[i] for i in M.ITEMS), sense=pyo.maximize)&#xA;&#xA;M.weight = pyo.Constraint(expr=sum(w[i] * M.x[i] for i in M.ITEMS) &amp;lt;= limit)&#xA;&#xA;# M.above_average = pyo.Constraint(&#xA;#     expr=sum(M.x[i] * v[i] for i in M.ITEMS) / sum(M.x[i] for i in M.ITEMS) &amp;gt;= 2&#xA;# )&#xA;&#xA;min_avg_val = 2&#xA;&#xA;M.above_average = pyo.Constraint(&#xA;    expr=sum(M.x[i] * v[i] for i in M.ITEMS) &amp;gt;= sum(M.x[i] * min_avg_val for i in M.ITEMS) )&#xA;&#xA;&#xA;solver = pyo.SolverFactory(&amp;quot;cbc&amp;quot;)&#xA;solver.solve(M)&#xA;M.x.display()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Yields:&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;x : Size=4, Index=ITEMS&#xA;    Key         : Lower : Value : Upper : Fixed : Stale : Domain&#xA;         hammer :     0 :   0.0 :     1 : False : False : Binary&#xA;    screwdriver :     0 :   1.0 :     1 : False : False : Binary&#xA;          towel :     0 :   1.0 :     1 : False : False : Binary&#xA;         wrench :     0 :   1.0 :     1 : False : False : Binary&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3883" LastActivityDate="2020-07-26T03:11:14.647" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4591" PostTypeId="2" ParentId="4587" CreationDate="2020-07-26T04:26:21.730" Score="0" Body="&lt;p&gt;Infeasibility, in many cases, back to the structure of the problem under study and as @AirSquid mentioned too, it really has not related to the solving algorithm if, it was implemented correctly. One of the good approach to deal with the infeasible problem is adding the slack variables to the constraints and setting the high-value objective coefficients for them. Would you see this &lt;a href=&quot;https://or.stackexchange.com/questions/1215/infeasibility-in-mathematical-optimization-models&quot;&gt;link&lt;/a&gt;? I hope it will be helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-07-26T04:26:21.730" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4592" PostTypeId="1" AcceptedAnswerId="4596" CreationDate="2020-07-26T07:47:17.097" Score="3" ViewCount="480" Body="&lt;p&gt;I see that certain studies are comparing MIP and constraint programming (CP) performances. And generally, they claim that CP outperforms MIP. But I believe that it is not completely true. Because while comparing,  MIP models don't have LB/UB, symmetry breaking constraints and variable dimensions are accepted from maximum points. In summary, MIP models do not have model performance improvement things. How can MIP models be compared with CP objectively? Are there alternatives to experimental comparison?&lt;/p&gt;&#xA;" OwnerUserId="432" LastActivityDate="2020-07-26T19:53:49.837" Title="Mixed integer programming vs Constraint programming" Tags="|mixed-integer-programming|constraint-programming|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4593" PostTypeId="1" CreationDate="2020-07-26T11:06:08.427" Score="1" ViewCount="91" Body="&lt;p&gt;I tried running my model by adding the following settings to CPLEX.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;##Model Code&#xA;.&#xA;.&#xA;.&#xA;.&#xA;import cplex&#xA;&#xA;opt = SolverFactory('cplex') &#xA;&#xA;opt.options[&amp;quot;threads&amp;quot;] = 8&#xA;opt.options['timelimit'] = 100&#xA;opt.options[&amp;quot;mip cuts disjunctive&amp;quot;]=3&#xA;&#xA;results = opt.solve(model, tee=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After the stipulated time limit of 100s, CPLEX keeps restarting itself to solve the problem. I had to close my IDE to stop the solving process.&lt;/p&gt;&#xA;&lt;p&gt;Before adding in the options, all was normal, as in CPLEX stops after solving without restarting.&lt;/p&gt;&#xA;&lt;p&gt;May I ask if anyone could advise and why this is happening and is there anything I need to do to prevent this?&lt;/p&gt;&#xA;&lt;p&gt;My model is just a typical disjunctive problem with no re-solving processes invoked.&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastActivityDate="2020-07-26T11:06:08.427" Title="CPLEX keeps restarting in Pyomo" Tags="|python|cplex|solver|pyomo|cplex-python-api|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4594" PostTypeId="1" CreationDate="2020-07-26T13:12:18.410" Score="2" ViewCount="467" Body="&lt;p&gt;I have a linear programming problem that I want to write in the canonical form: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad c^\top X\\\text{s.t.}&amp;amp;\quad A\cdot X\le b\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The problem is given by &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad m^\top X\\\text{s.t.}&amp;amp;\quad max\left(\frac{\sum_{i=1}^{\tau}(L_{i}-S_{i})\cdot D_{i}}{D_{\tau} }\right ) \leq \alpha,\quad \forall\tau\in\{1,2,\dots,t\}\tag1\end{align}&lt;/span&gt;&#xA;(A numerical example is given at the bottom)&lt;/p&gt;&#xA;&lt;p&gt;Another range constraint is given by &lt;span class=&quot;math-container&quot;&gt;$${\rm lb} \leq Q^\top X \leq{\rm ub}\tag2$$&lt;/span&gt; where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$n\times1$&lt;/span&gt; matrix&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$n\times t$&lt;/span&gt; matrix&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$t\times1$&lt;/span&gt; matrix&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$n\times1$&lt;/span&gt; matrix&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$t\times1$&lt;/span&gt; matrix&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$n\times1$&lt;/span&gt; matrix of decision variables&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S= P^\top X$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$t\times1$&lt;/span&gt; matrix&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Bounds on the decision variable &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; are given by:&#xA;&lt;span class=&quot;math-container&quot;&gt;$l \leq x \leq u$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The range constraint can be rewritten as one constraint by introducing a variable y:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y+ Q^{T}X = {\rm ub} – {\rm lb}$&lt;/span&gt;&lt;br /&gt;&#xA;where&#xA;&lt;span class=&quot;math-container&quot;&gt;$0 \leq y \leq {\rm ub} - {\rm lb}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here is a numerical example to explain the constraint (1)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X = &#xA;\begin{pmatrix}&#xA;x_{1} \\\&#xA;x_{2}\\\&#xA;x_{3}&#xA;\\ &#xA;\end{pmatrix}$&lt;/span&gt;&#xA;, &lt;span class=&quot;math-container&quot;&gt;$P = &#xA;\begin{pmatrix}&#xA;10 &amp;amp; 10 &amp;amp; 20 &amp;amp; 30 \\&#xA;200 &amp;amp; 30 &amp;amp; 50 &amp;amp; 150\\&#xA;7 &amp;amp; 100 &amp;amp; 99 &amp;amp; 1000 &#xA;\end{pmatrix}$&lt;/span&gt;&#xA;, &lt;span class=&quot;math-container&quot;&gt;$m = &#xA;\begin{pmatrix}&#xA;20 \\&#xA;200\\&#xA;700&#xA;\end{pmatrix}$&lt;/span&gt;&#xA;, &lt;span class=&quot;math-container&quot;&gt;$D = &#xA;\begin{pmatrix}&#xA;1.5 \\&#xA;0.05\\&#xA;0.9\\&#xA;0.15 &#xA;\end{pmatrix}$&lt;/span&gt;&#xA;,&lt;span class=&quot;math-container&quot;&gt;$Q = &#xA;\begin{pmatrix}&#xA;45 \\\&#xA;55\\\&#xA;1000\\&#xA; \end{pmatrix}$&lt;/span&gt;&#xA;,&lt;span class=&quot;math-container&quot;&gt;$L = &#xA;\begin{pmatrix}&#xA;20 \\\&#xA;33\\\&#xA;53\\\&#xA;990&#xA;\end{pmatrix}$&lt;/span&gt;&#xA;,&lt;span class=&quot;math-container&quot;&gt;$S =  P^{T}X$&lt;/span&gt;&#xA;= &lt;span class=&quot;math-container&quot;&gt;$\begin{pmatrix}&#xA;10x_{1}+200x_{2}+7x_{3} \\\&#xA;10x_{1}+30x_{2}+100x_{3}\\\&#xA;20x_{1}+50x_{2}+99x_{3} \\\ &#xA;30x_{1}+150x_{2}+1000x_{3}&#xA;\end{pmatrix}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Linearizing constraint (1) leads to a set of 4 constraints in this example.&#xA;Constraint (1) is given by:&#xA;&lt;span class=&quot;math-container&quot;&gt;$t =1, \frac{(20-\begin{pmatrix}&#xA;10x_{1}+200x_{2}+7x_{3} \\\end{pmatrix})&#xA;*1.5}{1.5} \leq \alpha$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t =2, \frac{(33-\begin{pmatrix}&#xA;10x_{1}+30x_{2}+100x_{3} \\\end{pmatrix})*0.05+(20-\begin{pmatrix}&#xA;10x_{1}+200x_{2}+7x_{3} \\\end{pmatrix})&#xA;*1.5}{0.05} \leq \alpha$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t =3, \frac{(53-\begin{pmatrix}&#xA;20x_{1}+50x_{2}+99x_{3} \\\end{pmatrix})*0.9+(33-\begin{pmatrix}&#xA;10x_{1}+30x_{2}+100x_{3} \\\end{pmatrix})*0.05+(20-\begin{pmatrix}&#xA;10x_{1}+200x_{2}+7x_{3} \\\end{pmatrix})&#xA;*1.5}{0.9} \leq \alpha$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t =4, \frac{(990-\begin{pmatrix}&#xA;30x_{1}+150x_{2}+1000x_{3} \\\end{pmatrix})*0.15+(53-\begin{pmatrix}&#xA;20x_{1}+50x_{2}+99x_{3} \\\end{pmatrix})*0.9+(33-\begin{pmatrix}&#xA;10x_{1}+30x_{2}+100x_{3} \\\end{pmatrix})*0.05+(20-\begin{pmatrix}&#xA;10x_{1}+200x_{2}+7x_{3} \\\end{pmatrix})&#xA;*1.5}{0.15} \leq \alpha$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Constraint\ (2)\ is\ given\ by:y+Q^{T}X = ub – lb$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y+\begin{pmatrix}&#xA;45x_{1}+55x_{2}+1000x_{3} \\\end{pmatrix}&#xA;=ub - lb$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$0 \leq y \leq ub-lb$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraint (1) can be written as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{\tau}(L_{i}\cdot D_{i}-P^{T}\cdot D_{i}\cdot X) \leq \alpha\cdot{D_{\tau}}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{\tau}(-P^{T}\cdot D_{i}) X = \alpha\cdot D_{\tau}-\sum_{i=1}^{\tau}L_{i}\cdot D_{i}\space\  \forall\tau\in\left \{ 1,2,...t \right \}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where LHS will form part of the matrix A and&lt;/p&gt;&#xA;&lt;p&gt;RHS will form part of the matrix b in the canonical form.&lt;/p&gt;&#xA;&lt;p&gt;In the example, the part of the matrix A corresponding to constraint (1) can be determined by calculating cumulative sum of rows of &lt;span class=&quot;math-container&quot;&gt;$P^{T}\cdot D_{i}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A_{con1}=\sum_{i=1}^{\tau}P^{T}\cdot D_{i}\hspace{0.5cm}  \forall\tau\in\{1,2,\dots,4\}&#xA; =\begin{pmatrix}&#xA;15 &amp;amp; 300 &amp;amp; 10.5 \\&#xA;15.5 &amp;amp; 301.5 &amp;amp; 15.5 \\&#xA;33.5 &amp;amp; 346.5 &amp;amp; 104.6 \\ &#xA;38&amp;amp; 369 &amp;amp; 254.6\end{pmatrix}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$\alpha=2$&lt;/span&gt;, the part of the matrix b for constraint (1) can be determined a:&#xA;&lt;span class=&quot;math-container&quot;&gt;$b_{con1}=\begin{pmatrix}&#xA;33.0 \\&#xA;31.75\\&#xA;81.149999\\&#xA;228.15&#xA;\end{pmatrix}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraint (2) can be easily written in the canonical form by splitting it in two constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ Q^\top X \leq{\rm ub}\tag2$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ -Q^\top X \leq{\rm -lb} $$&lt;/span&gt;&#xA;But, if we reformulate it as one equality constraint by introducing a variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; then it remains unclear on how to write it in the canonical form.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;How can this problem be written in the canonical form? Bounds on variables (&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in this case) are often not defined as separate constraints in AMLs. Do I need to define the bounds on variables as constraints in order to convert it in to the canonical form?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="3896" LastEditorUserId="3896" LastEditDate="2020-08-03T10:36:58.490" LastActivityDate="2020-08-03T10:36:58.490" Title="Canonical form of a linear program" Tags="|linear-programming|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4595" PostTypeId="2" ParentId="4587" CreationDate="2020-07-26T19:23:20.587" Score="3" Body="&lt;p&gt;I'm not sure there is a way to tweak your heuristic that will guarantee finding a feasible solution (assuming one exists). What you might try is a restart approach combined with a modification of your priority assignment method. Let's say that the modified heuristic assigns each task a &amp;quot;base&amp;quot; priority and then adjusts it when computing priorities for group B tasks.  If the heuristic finds itself blocked as in your diagram, it increases by some specified amount the base priority of the task that cannot be scheduled (and maybe increases the base priorities of predecessor tasks as well), then scraps the schedule under construction and starts over.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-07-26T19:23:20.587" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4596" PostTypeId="2" ParentId="4592" CreationDate="2020-07-26T19:53:49.837" Score="9" Body="&lt;p&gt;I'm not sure that talking about a comparison of MIP models and CP models makes sense, in part because I think that CP models tend to be solver-specific. MIP models tend to have a standard set of &amp;quot;features&amp;quot;: linear (or maybe convex quadratic) constraints; linear (or maybe quadratic) objective functions; and of course variables (integer or continuous). With CP, your model is likely to be expressed at least in part in terms of &amp;quot;global constraints&amp;quot;, and I suspect those are rather solver-specific (other than the ubiquitous &amp;quot;all different&amp;quot; constraint). So I'm afraid that any comparison of MIP and CP &amp;quot;models&amp;quot; will inevitably drag in the solvers being used.&lt;/p&gt;&#xA;&lt;p&gt;Another issue is the criterion for evaluating the models (and solvers). Beyond correctness (the model is free of errors) and ease of creation (largely a matter of user expertise), there is just solution time. Solution time drags the solver back into the picture, and also raises the question of the criterion for success (provably optimality, solution better than some cutoff value, ...). My impression is that MIP models tend to have tighter bounds than CP models, and from my experience there are problems where a CP solver gets a &amp;quot;good&amp;quot; solution faster than a MIP solver but the MIP solver proves optimality faster (because its better bounds allow it to avoid exploring more of the solution space than the CP solver can avoid).&lt;/p&gt;&#xA;&lt;p&gt;Thus I don't see a way around experimental comparisons, which must look at the solver as well as the model. I agree those comparisons are tricky to do correctly, both due to the effort put into things like mitigating symmetry or avoiding &amp;quot;big M&amp;quot; constraints on the MIP side while properly exploiting global constraints on the CP side and because there are many parameters the user can set with either type of solver. All of which, I think, suggests that we should maybe just not run around making claims about a MIP model being better or worse than a CP model.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-07-26T19:53:49.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4597" PostTypeId="1" CreationDate="2020-07-26T20:42:14.930" Score="5" ViewCount="65" Body="&lt;p&gt;I'm dealing with a problem as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have a finite set of money &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; to spend over &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; different raffles, and I need to spend approximately to my budget, with the goal of maximizing my probability of my total winnings across all raffles being a constant &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;. Each raffle has a different prize amount &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, and there is a certain amount of time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; between now and when the raffle winner is drawn, and at each interval a random number of people &lt;span class=&quot;math-container&quot;&gt;$pe$&lt;/span&gt; enter each raffle(which I have perfect information of), and a random number of people refund their raffle ticket &lt;span class=&quot;math-container&quot;&gt;$pr$&lt;/span&gt;. So, the probability I win each raffle can go up or down each temporal period. I start the scenario with a differing number of raffle tickets in each game, and I have a defined value function for each raffle so I know the increase I get in probability of winning the raffle based on the amount of money I spend buying raffle tickets for it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I've looked into multi-armed bandit problems and knapsack problems but I don't feel the problem perfectly fits into either bucket. Are there multiple problems at hand here, and that's why it doesn't appear to fit into any of those categories?&lt;/p&gt;&#xA;" OwnerUserId="3900" LastActivityDate="2020-07-26T20:42:14.930" Title="What is the generalization of the resource allocation problem I'm dealing with here?" Tags="|combinatorial-optimization|knapsack|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4598" PostTypeId="1" CreationDate="2020-07-27T09:48:47.853" Score="7" ViewCount="1777" Body="&lt;p&gt;In evolutionary algorithms, two main abilities maintained which are Exploration and Exploitation.&lt;/p&gt;&#xA;&lt;p&gt;In Exploration the algorithm searching for new solutions in new regions, while Exploitation means using the already existing solution and make refinements to it so its fitness will improve.&lt;/p&gt;&#xA;&lt;p&gt;In Simulated Annealing, I don't understand when the Exploration and the Exploitation happen.&lt;/p&gt;&#xA;&lt;p&gt;For example in Genetic algorithm: the Exploration is happened in the Crossover and Mutation steps, while the selection in Exploitation step.&lt;/p&gt;&#xA;" OwnerUserId="4389" LastEditorUserId="2477" LastEditDate="2020-07-27T16:55:39.917" LastActivityDate="2020-07-27T16:55:39.917" Title="Difference between exploration and exploitation in Simulated Annealing algorithm" Tags="|optimization|convex-optimization|metaheuristics|simulated-annealing|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4599" PostTypeId="2" ParentId="4598" CreationDate="2020-07-27T10:13:58.150" Score="7" Body="&lt;p&gt;I personally see it as follows. In simulated annealing the likelihood of choosing a solution from the neighborhood is quite high at the beginning. This phase could be regarded as exploration as the algorithm usually takes relatively big steps in the solution space. Later the likelihood decreases and by doing so the algorithm stays within a certain region of the solution space and just moves with small steps towards the end solutions. This can be regarded as exploitation.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="123" LastEditDate="2020-07-27T11:13:49.640" LastActivityDate="2020-07-27T11:13:49.640" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4600" PostTypeId="2" ParentId="4598" CreationDate="2020-07-27T15:42:07.527" Score="6" Body="&lt;p&gt;Those two are also called Diversification (Exploration) and Intensification (Exploitation).&lt;/p&gt;&#xA;&lt;p&gt;In SA, Diversification relates to the larger values of the probability of accepting an inferior neighbor solution, while Intensification relates to the smaller values.&lt;/p&gt;&#xA;&lt;p&gt;Since the probability is dependent to the difference between the objective of the current and neighbor solutions, it means a bad neighbor is less likely to be chosen when the probability is small.&lt;/p&gt;&#xA;&lt;p&gt;Note that you can have an adaptive scheme, that is increasing the temperature when there are a number of consecutive iterations with no improving solution. With that, you diversify the search when the intensified area does not yield to a good solution.&lt;/p&gt;&#xA;&lt;p&gt;BTW, I would suggest you have a look at the threshold accepting (TA) version as well, since there are many researches showing that TA has same or superior solutions than SA, and so there is no need to compute the sophisticated Metropolis probabilities.&lt;/p&gt;&#xA;" OwnerUserId="660" LastActivityDate="2020-07-27T15:42:07.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4601" PostTypeId="1" CreationDate="2020-07-27T16:15:21.287" Score="7" ViewCount="134" Body="&lt;p&gt;I have formulated a problem where I need to minimize the sum of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; functions, with only pairwise dependence between the functions (any single constraint involves only two functions having adjacent indices).&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;[\hat{x}_{1}~\hat{x}_{2}~\cdots~\hat{x}_{N}] &amp;amp;= \text{min}~\sum\limits_{n=1}^{N} f_{n}(x_{n}) \\&#xA;g(f_{1}(x_{1}),f_{2}(x_{2})) &amp;amp;\leq k \\&#xA;g(f_{2}(x_{2}),f_{3}(x_{3})) &amp;amp;\leq k \\&#xA; &amp;amp;\vdots \\&#xA;g(f_{N-1}(x_{N-1}),f_{N}(x_{N})) &amp;amp;\leq k \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The functions &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; are highly non-linear and non-convex, in addition to the decision variables being integer-valued. I am wondering if there is a method for decomposing this problem into smaller sub-problems and iteratively solving them, using a divide-and-conquer approach? Essentially, my question is whether this 'pairwise dependence' can somehow be exploited to make this problem easier to solve? Fortunately, the sample space for the decision variables is small (about 5000 values), and I can actually apply a brute-force search for the minimum, provided the sub-problems are small enough.&lt;/p&gt;&#xA;&lt;p&gt;I am aware of non-convex solvers such as Baron etc. but I'd like to know whether I can instead reduce the overall objective to a sum of 'smaller' objectives that can each be solved by a brute-force approach and where I am certain that the global minimum has been found.&lt;/p&gt;&#xA;" OwnerUserId="2843" LastActivityDate="2020-07-28T21:39:15.880" Title="Minimizing sum of functions with pairwise dependence" Tags="|nonlinear-programming|nonconvex-programming|decomposition|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4602" PostTypeId="2" ParentId="4523" CreationDate="2020-07-28T01:23:51.057" Score="5" Body="&lt;p&gt;One of my favorite OR papers is Ackoff's &lt;a href=&quot;https://link.springer.com/article/10.1057/jors.1979.22&quot; rel=&quot;noreferrer&quot;&gt;The Future of Operational Research is Past (1979)&lt;/a&gt;. It's thought-provoking and quite...colorful.&lt;/p&gt;&#xA;&lt;p&gt;While looking for that paper, I found a few others in related vein:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/inte.8.3.42&quot; rel=&quot;noreferrer&quot;&gt;OR/MS: Dead or Dying? RX for Survival&lt;/a&gt; by Hall and Hess (1978)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/030504838790003X&quot; rel=&quot;noreferrer&quot;&gt;Present Positions and Future Prospects in Management Science&lt;/a&gt; by Jackson (1987)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/opre.41.4.625&quot; rel=&quot;noreferrer&quot;&gt;The Natural Drift: What Happened to Operations Research?&lt;/a&gt; by Corbett and Van Wassenhove (1993)&lt;/p&gt;&#xA;&lt;p&gt;These papers all have 100+ cites (according to Google Scholar). There's a long tradition of discussing OR as a discipline within the OR literature.&lt;/p&gt;&#xA;" OwnerUserId="358" LastActivityDate="2020-07-28T01:23:51.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4603" PostTypeId="1" CreationDate="2020-07-28T04:50:24.117" Score="11" ViewCount="318" Body="&lt;p&gt;I'm reading Boyd's &lt;a href=&quot;https://web.stanford.edu/class/ee392o/decomposition.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;notes&lt;/a&gt; on forming the dual problem in order to decompose the primal problem. On page 4, right before the start of the next section, he talks about how given the optimal dual solution, finding the optimal primal solution is non-trivial. At the end, he says &amp;quot;There are also some standard tricks for regularizing the subproblems that work very well in practice.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Does anyone know what he means and how to go about regularizing the subproblems?&lt;/p&gt;&#xA;" OwnerUserId="3826" LastEditorUserId="491" LastEditDate="2020-10-22T02:25:10.463" LastActivityDate="2023-03-17T15:10:16.627" Title="Finding primal feasible solution from optimal dual" Tags="|duality|optimality-conditions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4604" PostTypeId="2" ParentId="4601" CreationDate="2020-07-28T15:51:17.773" Score="3" Body="&lt;p&gt;I can suggest a shortest path approach, but you'll have to decide if it's computationally feasible (which depends on how hard &lt;span class=&quot;math-container&quot;&gt;$g()$&lt;/span&gt; is to compute and how large &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is, among other things) and better than brute force.&lt;/p&gt;&#xA;&lt;p&gt;First, let &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; be the domain of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$y_n=f(x_n)$&lt;/span&gt;. We can rewrite the problem as minimizing &lt;span class=&quot;math-container&quot;&gt;$\sum_{n=1}^N y_n$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$g(y_n, y_{n+1})\le k$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. Compute &lt;span class=&quot;math-container&quot;&gt;$Y=f(X)$&lt;/span&gt; (which involves something like 5,000 evaluations of &lt;span class=&quot;math-container&quot;&gt;$f()$&lt;/span&gt;). The cardinality of &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is at worst that of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, smaller if you are lucky.&lt;/p&gt;&#xA;&lt;p&gt;Next, compute &lt;span class=&quot;math-container&quot;&gt;$Y_2=\lbrace (y,y')\in Y\times Y : g(y, y') \le k\rbrace$&lt;/span&gt;. This involves potentially 25 million or so evaluations of &lt;span class=&quot;math-container&quot;&gt;$g()$&lt;/span&gt;, so you might want to bring some reading material.&lt;/p&gt;&#xA;&lt;p&gt;Now picture a layered digraph with &lt;span class=&quot;math-container&quot;&gt;$N+2$&lt;/span&gt; layers, indexed &lt;span class=&quot;math-container&quot;&gt;$0,\dots,N+1$&lt;/span&gt;. Layer 0 contains just the root node and layer &lt;span class=&quot;math-container&quot;&gt;$N+1$&lt;/span&gt; contains just the terminus. Layers &lt;span class=&quot;math-container&quot;&gt;$1,\dots,N$&lt;/span&gt; each contain one node for every &lt;span class=&quot;math-container&quot;&gt;$y\in Y$&lt;/span&gt;. Arcs &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; cost &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (except that arcs to the terminus have no cost). There is an arc from the root to every node in layer 1 and from every node in layer &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; to the terminus. Otherwise, arc &lt;span class=&quot;math-container&quot;&gt;$(y_i, y_{i+1})$&lt;/span&gt; exists if and only if &lt;span class=&quot;math-container&quot;&gt;$(y_i, y_{i+1})\in Y_2$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is small, you can solve this directly.&lt;/p&gt;&#xA;&lt;p&gt;If the network is too big, consider breaking it up based on powers of 2. We start with &lt;span class=&quot;math-container&quot;&gt;$N=1$&lt;/span&gt; and find the shortest path from root to each node in layer 1 (trivial). Next, we set &lt;span class=&quot;math-container&quot;&gt;$N=2$&lt;/span&gt; and find the shortest path (if any) from each node of layer 1 to each node of layer 2, which will just be the arc between them (if any). For &lt;span class=&quot;math-container&quot;&gt;$N=4$&lt;/span&gt;, we consider it as two copies of &lt;span class=&quot;math-container&quot;&gt;$N=2$&lt;/span&gt; and find the shortest path from each node of the first layer of the first copy to each node of the second layer of the second copy, using what we know about &lt;span class=&quot;math-container&quot;&gt;$N=2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y_2$&lt;/span&gt; (which is the set of possible connections between the two copies). Now repeat for &lt;span class=&quot;math-container&quot;&gt;$N=8, 16, \dots$&lt;/span&gt;, and eventually for the original value of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; by writing it as a binary expansion and stitching together previous results.&lt;/p&gt;&#xA;&lt;p&gt;(Edit: I corrected something misleading in the preceding paragraph. I originally talked about shortest path source to end layer and start layer to sink, but you really need the shortest path from each node in the front layer of one copy to each node in the back layer of the other copy, which is more work.)&lt;/p&gt;&#xA;&lt;p&gt;There's a lot of comparisons and record keeping in this approach, but the upsides are that it is all just adding and comparing (once the function evaluations are out of the way) and it is amenable to parallel operations.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-07-28T21:39:15.880" LastActivityDate="2020-07-28T21:39:15.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4605" PostTypeId="1" AcceptedAnswerId="4607" CreationDate="2020-07-29T21:36:21.450" Score="5" ViewCount="1847" Body="&lt;p&gt;I am reading through a book which provides an example of a linear program given by &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad-24y_{1}-28y_{2}\\\text{s.t.}&amp;amp;\quad6y_{1}+10y_{2} \leq 2400\\&amp;amp;\quad8y_{1}+5y_{2} \leq 1600\\&amp;amp;\quad0\leq y_{1} \leq 500\\&amp;amp;\quad0\leq y_{2} \leq 100.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The solution is &lt;span class=&quot;math-container&quot;&gt;$-6100{\rm(objective\ value)}, y^{\top} = (137.5,100), \pi^{\top} = (0,-3,0,-13)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; is the simplex multiplier associated with the solution.&lt;/p&gt;&#xA;&lt;p&gt;I can solve the LP to find the feasible values of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; but I do not understand how to find the values of the simplex multiplier. Reading some papers I found out that the simplex multiplier is calculated as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\pi^{\top} = c_{B}^{\top} B^{-1}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have attempted to use this by writing this LP in the standard form but I cannot match the values of the &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad C^\top X\\\text{s.t.}&amp;amp;\quad A\cdot X=b\\&amp;amp;\quad A = \begin{pmatrix}&#xA;6 &amp;amp; 10 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp;0 \\&#xA;8 &amp;amp; 5 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp;0\\&#xA;1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp;0\\&#xA;0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;1 &#xA;\end{pmatrix}\\&amp;amp;\quad b = \begin{pmatrix}&#xA;2400 \\&#xA;1600 \\&#xA;500\\&#xA;100&#xA;\end{pmatrix}\\&amp;amp;\quad c = \begin{pmatrix}&#xA;-24 \\&#xA;-28 \\&#xA;0\\&#xA;0\\&#xA;0\\&#xA;0&#xA;\end{pmatrix}\\&amp;amp;\quad B = \begin{pmatrix}&#xA;1 &amp;amp; 0 &amp;amp; 0 &amp;amp;0 \\&#xA;0 &amp;amp; 1 &amp;amp; 0 &amp;amp;0\\&#xA;0 &amp;amp; 0 &amp;amp; 1 &amp;amp;0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp;1 &#xA;\end{pmatrix}\quad{\rm(Basis\,Matrix)}.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can anyone please explain how to calculate the simplex multiplier in this example?&lt;/p&gt;&#xA;" OwnerUserId="3896" LastEditorUserId="123" LastEditDate="2020-07-30T06:31:38.087" LastActivityDate="2023-05-27T10:41:46.623" Title="Simplex Multiplier" Tags="|linear-programming|simplex|lagrange-multipliers|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4606" PostTypeId="1" AcceptedAnswerId="4611" CreationDate="2020-07-29T23:47:32.443" Score="6" ViewCount="210" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a random variable that is sampled from the &lt;em&gt;mixture of uniform distributions&lt;/em&gt;. In other words:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$X \sim \sum_{i=1}^N w_i \cdot \mathbb{U}(x_i, x_{i+1}),$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbb{U}(x_i, x_{i+1})$&lt;/span&gt; denotes  a random variable that follows a uniform distribution in &lt;span class=&quot;math-container&quot;&gt;$[x_i, x_{i+1}]$&lt;/span&gt;.&#xA;For feasibility, we need &lt;span class=&quot;math-container&quot;&gt;$w \geq 0, \ \sum_{i=1}^N w_i = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In an optimization problem my variables are &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,N$&lt;/span&gt;, and I would like to upper bound the variance of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;. According to &lt;a href=&quot;https://en.wikipedia.org/wiki/Mixture_distribution&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;, the variance of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\mathrm{Var}(X) = \sum_{i=1}^N w_i(\sigma_i^2+ \mu_i^2 - \mu^2) $$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\sigma_i^2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu_i$&lt;/span&gt; are the variance and mean of &lt;span class=&quot;math-container&quot;&gt;$\mathbb{U}(x_i, x_{i+1})$&lt;/span&gt;, respectively (which are parameters), and &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; is the mean of the mixture, which is &lt;span class=&quot;math-container&quot;&gt;$$\mu = \sum_{i=1}^N w_i \frac{x_i &#xA;+ x_{i+1}}{2}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thus, if my derivation is not wrong:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \mathrm{Var}(X) = \sum_{i=1}^N w_i\left(\sigma_i^2+ \mu_i^2 - \left(\sum_{j=1}^N w_j \frac{x_j &#xA;+ x_{j+1}}{2}\right)^2\right)  $$&lt;/span&gt;&#xA;which is very ugly and appears to be non-convex to upper bound this function (edit: I want to constrain &lt;span class=&quot;math-container&quot;&gt;$\mathrm{Var}(X) \leq \mathrm{constant}$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;My question is, is there any trick, or any other convex approximation of such a variance, such that I can include an upper bound on the variance constraint?&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2020-07-31T16:40:02.733" LastActivityDate="2020-07-31T17:08:14.120" Title="Convexity of the variance of a mixture distribution" Tags="|convexity|nonconvex-programming|convex-optimization|probability-distributions|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="4607" PostTypeId="2" ParentId="4605" CreationDate="2020-07-30T00:47:36.740" Score="5" Body="&lt;p&gt;It is explained in this &lt;a href=&quot;http://web.mit.edu/15.053/www/AMP-Appendix-B.pdf&quot; rel=&quot;noreferrer&quot;&gt;link&lt;/a&gt; as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Simplex multipliers are essentially the shadow prices associated with a particular basic solution. Those are the &lt;em&gt;multiples&lt;/em&gt; of their initial system of equations such that, when all of these equations are multiplied by their respective simplex multipliers and subtracted from the initial objective function, the coefficients of the &lt;em&gt;basic variables&lt;/em&gt; are zero.&lt;/li&gt;&#xA;&lt;li&gt;On the other hand, the shadow prices were readily available from the final system of equations. In essence, since varying the righthand side value of a particular constraint is similar to adjusting the slack variable, it was argued that the shadow prices are the negative of the objective-function coefficients of the slack (or artificial) variables in the final system of equations.&lt;/li&gt;&#xA;&lt;li&gt;Similarly, the simplex multipliers at each intermediate iteration are the negative of the objective-function coefficients of these variables.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;An &lt;strong&gt;example&lt;/strong&gt; of how to calculate simplex multipliers in each intermediate iterations is given &lt;a href=&quot;http://user.engineering.uiowa.edu/%7Edbricker/Stacks_pdf8/RSM_Example1.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In your example for the final iteration of the simplex, you need to consider all the matrix operations that affected the &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; matrix. In other words, the &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; matrix should reflect the final basis of the simplex.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2020-07-30T01:00:24.807" LastActivityDate="2020-07-30T01:00:24.807" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4608" PostTypeId="1" CreationDate="2020-07-31T01:21:17.597" Score="4" ViewCount="210" Body="&lt;p&gt;I read some papers on local search. I remark that several authors use different move operators. However, the pseudo-code I found on google only uses one operator.&lt;/p&gt;&#xA;&lt;p&gt;I am wondering how to implement the local search algorithm using different operators. Do I need to run them at the same time or successively? how? Could someone point me to a pseudo-code for the case of several operators?&lt;/p&gt;&#xA;&lt;p&gt;Edit: I heard some bad things about the algorithm suggested in the answer VNS. What do you think of? Is it the only way to manage different operators?&lt;/p&gt;&#xA;" OwnerUserId="3916" LastEditorUserId="-1" LastEditDate="2020-08-02T09:11:55.997" LastActivityDate="2020-08-02T12:33:05.763" Title="How to implement a local search with different operators?" Tags="|reference-request|local-search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4610" PostTypeId="2" ParentId="4608" CreationDate="2020-07-31T04:27:59.623" Score="3" Body="&lt;p&gt;I suggest you take a look at Variable Neighborhood Search (VNS) method. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Variable_neighborhood_search&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia page&lt;/a&gt; has some useful pseudo codes.&lt;/p&gt;&#xA;&lt;p&gt;My answer to OP EDIT:&#xA;First, I think there is no good or bad algorithm, it depends on how you use the different features.&lt;/p&gt;&#xA;&lt;p&gt;Getting back to your question, of course VNS is not the only way to have multiple operators. You can implement multiple operators in many meta-heuristics, e.g., in an Iterated Local Search, Simulated Annealing, Tabu Search, etc. One way to do so is to define a probability for each operator, and each time you pick the operator based on the probability.&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-08-02T12:33:05.763" LastActivityDate="2020-08-02T12:33:05.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4611" PostTypeId="2" ParentId="4606" CreationDate="2020-07-31T05:30:15.760" Score="5" Body="&lt;p&gt;In order to find the best upper bound for variance, for given input values of &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sigma_i^2$&lt;/span&gt;, you should globally maximize variance with respect to the &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt;, subject to the constraints &lt;span class=&quot;math-container&quot;&gt;$w_i \ge 0, \Sigma w_i = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This can be formulated as a convex QP (Quadratic Programming problem), i.e., maximizing a concave quadratic subject to linear constraints. Hence it is easy to solve, unless &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is gigantic, which hardly seems likely for any reasonable mixture distribution. I leave to the OP as an exercise, whether the KKT conditions can yield a closed form solution.&lt;/p&gt;&#xA;&lt;p&gt;The convex QP takes the form:&lt;/p&gt;&#xA;&lt;p&gt;maximize &lt;span class=&quot;math-container&quot;&gt;$(\Sigma_{i=1}^n w_i (\sigma_i^2 +\mu_i^2)) - \mu^2$&lt;/span&gt; with respect to &lt;span class=&quot;math-container&quot;&gt;$\mu, w_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to  &lt;span class=&quot;math-container&quot;&gt;$\Sigma_{i=1}^n w_i \mu_i  = \mu, w_i \ge 0  \forall i, \Sigma_{i=1}^n w_i = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If all &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; are equal to each other, this would be a Linear Programming problem with compact constraints. Therefore the optimum would be at a vertex of the constraints, and in this case, that vertex would be &lt;span class=&quot;math-container&quot;&gt;$w_i = 1$&lt;/span&gt; for the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; corresponding to the largest &lt;span class=&quot;math-container&quot;&gt;$\sigma_i^2$&lt;/span&gt;, and all other &lt;span class=&quot;math-container&quot;&gt;$w_i = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: In response to edit to question: &amp;quot;I want to constrain Var(X) &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; constant)&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;If the naive approach of adding the constraint Var(X) &lt;span class=&quot;math-container&quot;&gt;$\le $&lt;/span&gt; constant to my above convex QP formulation were performed, that would add a non-convex quadratic constraint, making the problem a non-convex Quadratically-Constrained Quadratic Program (QCQP), which requires a global optimizer, such as Gurobi 9.x or BARON to solve to global optimality.&lt;/p&gt;&#xA;&lt;p&gt;However, there is an easier, faster method: Solve the (pre-Edit) convex QP formulation. Then maximum variance, accounting for the constraint Var(X) &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; constant), equals&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;min(optimal objective value of convex QP formulation,constant)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-07-31T17:08:14.120" LastActivityDate="2020-07-31T17:08:14.120" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4612" PostTypeId="1" CreationDate="2020-07-31T11:28:11.297" Score="4" ViewCount="62" Body="&lt;p&gt;It is well-known that the Glauber dynamics will converge in polynomial time to the Gibbs distribution for, say, the Ising model on a d-regular graph at high enough temperatures &lt;span class=&quot;math-container&quot;&gt;$T&amp;gt;T_c$&lt;/span&gt;. There are also some explicit bounds on how high this temperature has to be.&#xA;But how about the slow mixing regime? I only know explicit bounds on the mixing time for the complete graph.&#xA;Is there anything known for d-regular graphs? i.e. a bound of the form if &lt;span class=&quot;math-container&quot;&gt;$T&amp;lt;T_c$&lt;/span&gt;, then the mixing time is at most &lt;span class=&quot;math-container&quot;&gt;$\textrm{exp}(c(T)n)$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$c(T)$&lt;/span&gt; an explicit constant depending on the temperature? Intuitively, I would expect that the exponent of the mixing time should depend on the temperature and hopefully be smaller than 2 for temperatures mildly below the critical one.&lt;/p&gt;&#xA;&lt;p&gt;I would also be happy with the results of this type for other Monte Carlo algorithms such as annealing. That is, a resulting stating that an exponential annealing schedule would give me a sample from the distribution at temperatures above the critical one.&lt;/p&gt;&#xA;" OwnerUserId="3918" LastEditorUserId="491" LastEditDate="2022-01-09T16:52:29.967" LastActivityDate="2022-01-09T16:52:29.967" Title="Mixing time exponent above threshold temperature for Glauber dynamics or annealing" Tags="|optimization|combinatorial-optimization|stochastic-process|approximation-algorithms|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4613" PostTypeId="1" CreationDate="2020-08-01T13:12:42.663" Score="7" ViewCount="171" Body="&lt;p&gt;I am a student self-studying Optimization, and I am reading about the Conjugate Gradient Method in &lt;em&gt;Numerical Optimization&lt;/em&gt; by Nocedal &amp;amp; Wright, and they present two different algorithms for it. First they present Algorithm 5.1 which is the way you might first implement the Conjugate Gradient Method based on the mathematical theory. Then, they do a few mathematical tricks to change the formula for some variables, and claim that the new Algorithm 5.2 is more efficient.&lt;/p&gt;&#xA;&lt;p&gt;I tried comparing the algorithms, and I don't see why the second is significantly more efficient than the first. The only formulas which are different are the ones for &lt;span class=&quot;math-container&quot;&gt;$\alpha_k, r_{k+1},$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta_{k+1}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the formula for &lt;span class=&quot;math-container&quot;&gt;$\alpha_k$&lt;/span&gt;, the only change is that we have replaced the inner product &lt;span class=&quot;math-container&quot;&gt;$-r_k^Tp_k$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$r_k^T r_k$&lt;/span&gt;, and I don't see why this would make a difference.&lt;/p&gt;&#xA;&lt;p&gt;In the formula for &lt;span class=&quot;math-container&quot;&gt;$r_{k+1}$&lt;/span&gt;, I guess I see one efficiency. Instead of computing the matrix product &lt;span class=&quot;math-container&quot;&gt;$Ax_{k+1},$&lt;/span&gt; we can use &lt;span class=&quot;math-container&quot;&gt;$Ap_k$&lt;/span&gt;, a quantity which we already had to calculate in computing &lt;span class=&quot;math-container&quot;&gt;$\alpha_k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the formula for &lt;span class=&quot;math-container&quot;&gt;$\beta_{k+1}$&lt;/span&gt;, we first replaced &lt;span class=&quot;math-container&quot;&gt;$r_{k+1}^TAp_k$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$r_{k+1}^Tr_{k+1}$&lt;/span&gt;. Since, as discussed above, we already know the product &lt;span class=&quot;math-container&quot;&gt;$Ap_k$&lt;/span&gt;, I don't see why this is more efficient. Second, we replaced &lt;span class=&quot;math-container&quot;&gt;$p_k^TAp_k$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$r_k^Tr_k$&lt;/span&gt;, which, for the same reason, doesn't appear to be more efficient.&lt;/p&gt;&#xA;&lt;p&gt;There must be something I'm missing; could you please help me identify it?&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Z5RM1.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Z5RM1.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Wr9jH.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wr9jH.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3527" LastActivityDate="2020-08-10T18:02:19.107" Title="Why is this version of the algorithm more efficient?" Tags="|optimization|algorithms|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="4615" PostTypeId="1" AcceptedAnswerId="4616" CreationDate="2020-08-03T08:03:04.683" Score="5" ViewCount="159" Body="&lt;p&gt;For a given binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x[i,j,k]$&lt;/span&gt; my goal is to get as dense results in terms of k for successive values of j. Distance of k value to be kept as close as possible throughout j values:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d = \sum_{j=2}^n (|k\cdot x[1,j,k] - k\cdot x[1,j-1,k]) + |k\cdot x[1,n,k] - k\cdot x[1,1,k]| $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;e.g &lt;span class=&quot;math-container&quot;&gt;$i = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;j | 1 2 3 4 5&lt;/p&gt;&#xA;&lt;p&gt;k | 3 3 3 3 3 - is the optimal, d = 0&lt;/p&gt;&#xA;&lt;p&gt;k | 5 4 4 5 4 - is good enough  d = 4&lt;/p&gt;&#xA;&lt;p&gt;k | 1 6 9 2 5 - not good d = 22&lt;/p&gt;&#xA;&lt;p&gt;How is that even possible to add this in the objective function since absolute function is introduced and linearity is diminished?&lt;/p&gt;&#xA;" OwnerUserId="3463" LastEditorUserId="500" LastEditDate="2020-08-03T15:31:13.467" LastActivityDate="2020-08-03T15:31:13.467" Title="Minimize binary variable's distance with respect to the index values" Tags="|optimization|constraint|linearization|binary-variable|minimax|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4616" PostTypeId="2" ParentId="4615" CreationDate="2020-08-03T13:38:16.047" Score="3" Body="&lt;p&gt;Introduce a variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$$\left|\sum_k k x_{i,j,k}-\sum_k k x_{i,j-1,k}\right|,$$&lt;/span&gt; together with constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_{i,j} &amp;amp;\ge \sum_k k x_{i,j,k}-\sum_k k x_{i,j-1,k} &amp;amp;&amp;amp;\text{for all $i$ and $j$} \\&#xA;y_{i,j} &amp;amp;\ge -\sum_k k x_{i,j,k}+\sum_k k x_{i,j-1,k} &amp;amp;&amp;amp;\text{for all $i$ and $j$}&#xA;\end{align}&lt;/span&gt;&#xA;The objective is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j} y_{i,j}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Alternatively, you might consider minimizing the range&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i \left(\max_j \sum_k k x_{i,j,k} - \min_j \sum_k k x_{i,j,k}\right),$$&lt;/span&gt; which you can linearize with variables &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; and constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;v_i &amp;amp;\ge \sum_k k x_{i,j,k} &amp;amp;&amp;amp;\text{for all $i$ and $j$} \\&#xA;w_i &amp;amp;\le \sum_k k x_{i,j,k} &amp;amp;&amp;amp;\text{for all $i$ and $j$} \\&#xA;\end{align}&lt;/span&gt;&#xA;The objective is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_i (v_i - w_i)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-08-03T15:30:31.270" LastActivityDate="2020-08-03T15:30:31.270" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4617" PostTypeId="1" AcceptedAnswerId="4620" CreationDate="2020-08-03T15:05:37.667" Score="3" ViewCount="188" Body="&lt;p&gt;When linearizing a separable nonlinear function is there an advantage/disadvantage in using SOS2 sets in comparison to using binary variables?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="500" LastEditDate="2020-08-03T15:30:58.283" LastActivityDate="2020-08-03T19:10:37.600" Title="Linearizing separable functions: SOS2 sets or binary variables" Tags="|linearization|binary-variable|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4618" PostTypeId="1" CreationDate="2020-08-03T16:52:33.290" Score="10" ViewCount="1786" Body="&lt;p&gt;I have the following optimisation problem.&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad\sum_i\sum_j\sum_k x_{ji}y_{kj} \operatorname{cost}(i,k)\\\text{s.t.}&amp;amp;\quad\sum_j x_{ji}=1\quad\forall i\\&amp;amp;\quad\sum_k y_{kj}=1\quad\forall j\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Please suggest any solver for this. The cost function is stored in a matrix.&lt;/p&gt;&#xA;" OwnerUserId="3932" LastEditorUserId="500" LastEditDate="2020-08-04T19:36:11.830" LastActivityDate="2020-08-04T21:07:15.410" Title="Nonlinear integer (0/1) programming solver" Tags="|integer-programming|linearization|nonlinear-programming|quadratic-programming|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4619" PostTypeId="2" ParentId="4618" CreationDate="2020-08-03T18:13:39.987" Score="16" Body="&lt;p&gt;&lt;strong&gt;Option 1&lt;/strong&gt;: Submit as is to a solver which can globally optimize MIQPs having non-convex objective, and which might reformulate to a linearized MILP model under the hood. Such solvers include CPLEX, Gurobi 9.x, and BARON, among others.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Option 2&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt; Linearize the products of binary variables, per &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;How to linearize the product of two binary variables?&lt;/a&gt; . &amp;lt;&lt;strong&gt;Edit&lt;/strong&gt;: This step is written out explicitly in this thread in @Richard 's subsequent answer.&amp;gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: Submit your linearized model to a MILP solver, such as CPLEX, Gurobi, XPress, Mosek, SCIP, or many others.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;:Some solvers, such as CPLEX, give you the option of specifying whether the solver should reformulate the Binary MIQP to a MILP.  There may be a default to let the solver decide which way is better.  See &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.7.1/ilog.odms.cplex.help/CPLEX/Parameters/topics/QPmakePSDInd.html&quot; rel=&quot;noreferrer&quot;&gt;indefinite MIQP switch:Decides whether CPLEX will attempt to reformulate a MIQP or MIQCP model that contains only binary variables.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-08-04T15:45:10.967" LastActivityDate="2020-08-04T15:45:10.967" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4620" PostTypeId="2" ParentId="4617" CreationDate="2020-08-03T19:10:37.600" Score="1" Body="&lt;p&gt;Mathematically they are equivalent, but some solvers will exploit SOS2 structure with customized branching rules. Here is &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/sos/02_SOS_defn.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;IBM's explanation of this for CPLEX&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-08-03T19:10:37.600" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4621" PostTypeId="1" CreationDate="2020-08-03T22:57:21.347" Score="3" ViewCount="522" Body="&lt;p&gt;I am looking for papers or other resources that provide an accessible introduction to L-shaped methods/Benders decomposition for solving stochastic linear programming-ideally something focused more on the practical and implementation side. Birge and Louveaux's book on stochastic programming provides some good examples, but I find their explanations long-winded. What are some of the best resources for learning Benders decomposition?&lt;/p&gt;&#xA;" OwnerUserId="3936" LastEditorUserId="36" LastEditDate="2020-08-03T23:06:37.717" LastActivityDate="2020-08-05T02:35:46.310" Title="Accessible introduction to L-shaped methods/Benders decomposition" Tags="|reference-request|stochastic-programming|benders-decomposition|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4622" PostTypeId="1" CreationDate="2020-08-04T05:31:46.243" Score="1" ViewCount="131" Body="&lt;p&gt;I am working on Diet Allocation problem. Where we need to provide food piece for protein deficiency. The data is as below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Data=&#xA;[{'Individual_ID': 'A', 'State': 'H1', 'Country_Code': 'C1', 'Present_Protein': 750},&#xA;    {'Individual_ID': 'B', 'State': 'H1', 'Country_Code': 'C1', 'Present_Protein': 730},&#xA;    {'Individual_ID': 'C', 'State': 'H2', 'Country_Code': 'C2', 'Present_Protein': 740},&#xA;    {'Individual_ID': 'D', 'State': 'H3', 'Country_Code': 'C2', 'Present_Protein': 850},&#xA;    {'Individual_ID': 'E', 'State': 'H3', 'Country_Code': 'C2', 'Present_Protein': 750}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2BOLu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2BOLu.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;We can allocate at max one type of supplement to one individual.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Objective = min (cost)&#xA;Subjected to individual_protein &amp;gt; Min_requirement&#xA;And we have infinite food packet available.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is plain and simple and I am able to do this easily. Problem start in next part.&lt;/p&gt;&#xA;&lt;p&gt;Now for part 2: I have constraint over food type. (Example only 1 packet of each food is available). And I have predefined priority (i.e. funding company prefer allocation in particular country over another country and/or particular state over other state and/or particular ind over other indv)..&lt;/p&gt;&#xA;&lt;p&gt;Can such constraint be added in LP problem? If yes, how?&lt;/p&gt;&#xA;" OwnerUserId="3927" LastEditorUserId="2477" LastEditDate="2020-08-05T07:39:33.530" LastActivityDate="2020-08-05T07:39:33.530" Title="Resource constrained LP problem" Tags="|linear-programming|modeling|python|pulp|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4623" PostTypeId="2" ParentId="4618" CreationDate="2020-08-04T10:23:46.450" Score="5" Body="&lt;p&gt;You can try our own &lt;a href=&quot;http://octeract.com/octeract-engine/&quot; rel=&quot;noreferrer&quot;&gt;Octeract Engine&lt;/a&gt;, it solves all classes of optimisation problems up to (and including) DMINLP to global optimality. If you are a student/academic, you can also use it for it free! On the free side, there's also SCIP (only free for academics) and Couenne (open source).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-08-04T10:43:25.660" LastActivityDate="2020-08-04T10:43:25.660" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4624" PostTypeId="2" ParentId="4618" CreationDate="2020-08-04T11:41:27.170" Score="6" Body="&lt;p&gt;In my opinion your best bet is to define an auxiliary variable &lt;span class=&quot;math-container&quot;&gt;$z_{ijk}$&lt;/span&gt; such that:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;z_{ijk} \geq x_{ji} + y_{kj} -1 \\&#xA;z_{ijk} \leq x_{ji} \\&#xA;z_{ijk} \leq y_{kj}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now this may become a really huge problem depending on the dimensions of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. However, you gain the linearity of the problem which is worth a lot in my experience.&lt;/p&gt;&#xA;&lt;p&gt;Lastly, you may be able to prune some stuff if you know more about the problem, but nothing comes to my mind right now.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2020-08-04T11:41:27.170" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4625" PostTypeId="2" ParentId="4618" CreationDate="2020-08-04T17:50:39.877" Score="1" Body="&lt;p&gt;Your optimization problem seems like a special variant of the quadratic assignment problem (qap).&#xA;One difference is that you have only products of variables coming from two different sets (x and y). This structure is called separable or disjoint bilinear programming.&lt;/p&gt;&#xA;&lt;p&gt;The standard qap is one of the simplest quadratic problems, there are often examples from the solvers for this problem (some official/some from third-party people).&#xA;They can easily be changed for your problem.&lt;/p&gt;&#xA;&lt;p&gt;Localsolver:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/qap.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.localsolver.com/docs/last/exampletour/qap.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Gurobi:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://rpubs.com/HeatWave2019/560446&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://rpubs.com/HeatWave2019/560446&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://gurobi.github.io/modeling-examples/customer_assignment/customer_assignment.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gurobi.github.io/modeling-examples/customer_assignment/customer_assignment.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="3305" LastEditDate="2020-08-04T20:55:45.100" LastActivityDate="2020-08-04T20:55:45.100" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4626" PostTypeId="2" ParentId="4618" CreationDate="2020-08-04T17:54:24.543" Score="10" Body="&lt;p&gt;Besides the traditional linearization suggested by @MarkL.Stone and @Richard, you might consider using the constraints to obtain a &lt;em&gt;compact linearization&lt;/em&gt;.  Explicitly, multiply both sides of your second constraint by &lt;span class=&quot;math-container&quot;&gt;$x_{j,i}$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_k x_{j,i} y_{k,j} = x_{j,i}$$&lt;/span&gt;&#xA;Now replace &lt;span class=&quot;math-container&quot;&gt;$x_{j,i} y_{kj}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$z_{i,j,k}$&lt;/span&gt; and impose an additional constraint to enforce &lt;span class=&quot;math-container&quot;&gt;$y_{k,j} = 0 \implies z_{i,j,k} = 0$&lt;/span&gt;.  The resulting linear formulation is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{maximize} &amp;amp;\sum_i\sum_j\sum_k \text{cost}(i,k) z_{i,j,k}\\&#xA;&amp;amp;\text{subject to} &amp;amp;\sum_j x_{j,i} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$}\\&#xA;&amp;amp;&amp;amp;\sum_k z_{i,j,k} &amp;amp;= x_{j,i} &amp;amp;&amp;amp;\text{for all $i$ and $j$} \\&#xA;&amp;amp;&amp;amp;0 \le z_{i,j,k} &amp;amp;\le y_{k,j} &amp;amp;&amp;amp;\text{for all $i$, $j$, and $k$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-08-04T17:54:24.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4627" PostTypeId="2" ParentId="4618" CreationDate="2020-08-04T21:07:15.410" Score="14" Body="&lt;p&gt;Maybe I am missing something but it looks like there is no need for a library:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i \sum_j \sum_k x_{ji} y_{kj} cost(i,k)&amp;amp;=\sum_i \sum_j x_{ji} \sum_k y_{kj} cost(i,k)&#xA;\end{align}&lt;/span&gt;&#xA;Now since &lt;span class=&quot;math-container&quot;&gt;$\sum_k y_{kj}=1$&lt;/span&gt;, exactly one row is 1, the others zero. We pick the best one:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;=\sum_i \sum_j x_{ji} \max_k cost(i,k)$$&lt;/span&gt;&#xA;Since &lt;span class=&quot;math-container&quot;&gt;$\sum_j x_{ji}=1$&lt;/span&gt; we get&#xA;&lt;span class=&quot;math-container&quot;&gt;$$=\sum_i \max_k cost(i,k)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So basically go through the cost matrix row by row and pick the largest entry.&#xA;This must have been homework :)&lt;/p&gt;&#xA;" OwnerUserId="3941" LastActivityDate="2020-08-04T21:07:15.410" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4628" PostTypeId="2" ParentId="4621" CreationDate="2020-08-05T02:35:46.310" Score="3" Body="&lt;p&gt;Given your emphasis on practical and implementation aspects, I think the following two lectures will interest you:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.ima.umn.edu/2015-2016/ND8.1-12.16/25379&quot; rel=&quot;nofollow noreferrer&quot;&gt;Stochastic Programming Modeling by Jeff Linderoth (University of Wisconsin, Madison)&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.ima.umn.edu/2015-2016/ND8.1-12.16/25378&quot; rel=&quot;nofollow noreferrer&quot;&gt;Benders Decomposition for Solving Two-stage Stochastic Optimization Models by Jim Luedtke (University of Wisconsin, Madison)&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2020-08-05T02:35:46.310" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4629" PostTypeId="1" CreationDate="2020-08-05T10:27:56.670" Score="3" ViewCount="123" Body="&lt;p&gt;I built a solver for a classic scheduling problem. It has some exact methods and some heuristics methods.&lt;/p&gt;&#xA;&lt;p&gt;I want to judge the quality of the work beyond time efficiency and solution quality.&lt;/p&gt;&#xA;&lt;p&gt;For example, I have found those slides on &lt;a href=&quot;https://school.a4cp.org/summer2017/slidedecks/Consistency-in-Solvers.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;consistency&lt;/a&gt; in solvers. Since they are just slides, it's not elaborate enough.&lt;/p&gt;&#xA;&lt;p&gt;So, what should I consider as quality &amp;quot;measures&amp;quot; and why? Don't hesitate to point me to some articles on the subject.&lt;/p&gt;&#xA;" OwnerUserId="1188" LastActivityDate="2020-08-05T12:39:04.467" Title="How to evalute the quality of a solver (beyond solution quality and time efficiency)?" Tags="|solver|reference-request|applications|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4630" PostTypeId="2" ParentId="4192" CreationDate="2020-08-05T10:42:54.717" Score="6" Body="&lt;p&gt;Many fine answers have already been provided fort this question. Here are some additional frequently solved optimization problems.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Neural network training for image recognition&lt;/strong&gt;, or whatever. Not by number of problems solved, but by total amount of computing (those babies can burn weeks on high end GPUs and TPUs)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Oil Refining&lt;/strong&gt;. In the old days (through the '70s and into at least the early 80s), LPs to optimize oil refining, solved by  some variant of the Simplex Method, were the most frequently solved optimization problems, and were responsible for a large portion of the total worldwide floating point computations.&lt;/p&gt;&#xA;&lt;p&gt;MILPs largely supplanted LPs, to include in oil refining, by the 90s when MILP solvers started greatly maturing and becoming commercially available.&lt;/p&gt;&#xA;&lt;p&gt;Even in the 70s, there was some oil refining optimization done using Nonlinear Programming (or in some case, just Nonlinear Equation Solving). But I think such optimizations were more commonly performed by oil company researchers in Operations Research colloquiums, such as I attended at Stanford in the early 80s, than they were in practice at the oil companies which employed them.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2020-08-05T19:17:15.083" LastActivityDate="2020-08-05T19:17:15.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4632" PostTypeId="2" ParentId="4629" CreationDate="2020-08-05T12:39:04.467" Score="3" Body="&lt;p&gt;In the order of importance (my opinion):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Solution quality/optimality&lt;/li&gt;&#xA;&lt;li&gt;Speed&lt;/li&gt;&#xA;&lt;li&gt;Robustness towards numerically challenging problems&lt;/li&gt;&#xA;&lt;li&gt;API and model creation speed&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The first three you can do through benchmarks (see e.g. the famous &lt;a href=&quot;http://plato.asu.edu/bench.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mittelmann benchmarks&lt;/a&gt;), while the last one is a matter of taste (although you can measure the model creation speed).&lt;/p&gt;&#xA;&lt;p&gt;I think a point that deserves special mention is the numerical robustness: I would get some numerically challenging problems, solve them with your solver and then compare that solution to existing problems. Because any KPI that you can come up with only makes sense if it is compared to an existing product, so that people can judge whether the new product is indeed good.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2020-08-05T12:39:04.467" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4633" PostTypeId="1" CreationDate="2020-08-05T15:45:16.913" Score="4" ViewCount="808" Body="&lt;p&gt;I have implemented a set of &amp;quot;or&amp;quot; constraints in my ILP using binary decision variables (as in &lt;a href=&quot;https://stackoverflow.com/questions/24449959/linear-programming-constraint-x-c-or-x-0&quot;&gt;this method&lt;/a&gt;).  It works fine for smaller problems, but when I try to increase the number of variables it gets very slow very fast, such that it is not feasible for the size of problem I need to solve.  Is there a way to more cleverly implement this method, so that I can get a solution in hours instead of months?&lt;/p&gt;&#xA;&lt;p&gt;Without the “or” constraint, the solution is found in a matter of seconds, even for a problem twice the size that I need, so it’s not just a matter of the number of variables (because the decision variables make the simplex no longer convex).  I have assigned the big constant to be as small as possible while still satisfying the constraints, but I am not sure what else I can do.  All my variables are binary, I am using a GLPK solver from R (Rglpk), running on a professional-grade laptop.  I can successfully solve the problem for &lt;span class=&quot;math-container&quot;&gt;$1,000$&lt;/span&gt; variables in a couple seconds, while &lt;span class=&quot;math-container&quot;&gt;$10,000$&lt;/span&gt; takes a couple hours.  My application calls for a maximum of &lt;span class=&quot;math-container&quot;&gt;$1,000,000$&lt;/span&gt; variables.&lt;/p&gt;&#xA;&lt;p&gt;Thanks for your advice.&lt;/p&gt;&#xA;&lt;p&gt;EDITED to add information about the model:&lt;/p&gt;&#xA;&lt;p&gt;My variables are the entries of a binary matching matrix &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, weighted by a similarity matrix &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, the constraints are just row sums and column sums:&lt;/p&gt;&#xA;&lt;p&gt;Objective:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max_{B} \sum_{i,j} S_{i,j} B_{i,j}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$B_{i,j}$&lt;/span&gt; binary&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall i, \sum_j B_{i,j} = a$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall j, \sum_i B_{i,j} \le b$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall j, \sum_i B_{i,j} \ge c$&lt;/span&gt;  or  &lt;span class=&quot;math-container&quot;&gt;$\sum_i B_{i,j} \le 0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3880" LastEditorUserId="3880" LastEditDate="2020-08-05T20:25:01.937" LastActivityDate="2021-04-25T12:46:25.833" Title="Faster implementation of &quot;or&quot; constraints in ILP" Tags="|linear-programming|integer-programming|constraint|binary-variable|indicator-constraints|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4634" PostTypeId="2" ParentId="4633" CreationDate="2020-08-05T16:14:54.457" Score="7" Body="&lt;p&gt;Answers to the linked question mention both big-M constraints and semicontinuous variables.  To speed up the big-M approach, you might consider introducing the constraints dynamically only as they are violated (&amp;quot;row generation&amp;quot; or &amp;quot;cut generation&amp;quot;).  Explicitly:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Omit all big-M constraints and the associated binary variables.&lt;/li&gt;&#xA;&lt;li&gt;Solve the problem with the current set of big-M constraints and associated binary variables.&lt;/li&gt;&#xA;&lt;li&gt;For any violations (variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt; x_i &amp;lt; c$&lt;/span&gt;), introduce big-M constraints and the associated binary variables.&lt;/li&gt;&#xA;&lt;li&gt;If there are no violations, stop.  Else go to step 2.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Depending on the rest of your model, there might be additional ways to improve the solve time.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-08-05T17:11:37.753" LastActivityDate="2020-08-05T17:11:37.753" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4635" PostTypeId="1" AcceptedAnswerId="5095" CreationDate="2020-08-05T18:39:44.937" Score="6" ViewCount="93" Body="&lt;p&gt;I am trying to solve a linear program that is identical to a min-cost flow problem, except for a difference in the flow-conservation constraint.&lt;/p&gt;&#xA;&lt;p&gt;Instead of the summed outgoing flow equaling the summed incoming flow for each node:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i f_{i,n} = \sum_j f_{n, j}  \ \forall n$$&lt;/span&gt;&#xA;The flow &lt;strong&gt;of each outgoing edge&lt;/strong&gt; should equal the summed incoming flow for each node:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i f_{i,n} = f_{n, m}  \ \forall n, m$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In other words: The incoming flow is replicated along all outgoing edges.&lt;/p&gt;&#xA;&lt;p&gt;I wonder if:&lt;br /&gt;&#xA;1.) This problem has a particular name in the literature&lt;br /&gt;&#xA;2.) It has an optimal integral solution when all edge capacities are integral&lt;/p&gt;&#xA;" OwnerUserId="3948" LastActivityDate="2020-10-24T21:48:56.500" Title="Min-cost flow with per-edge flow conservation" Tags="|linear-programming|integer-programming|network-flow|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4636" PostTypeId="1" CreationDate="2020-08-06T16:29:15.923" Score="3" ViewCount="105" Body="&lt;p&gt;I'm working on implementing &lt;a href=&quot;https://people.csail.mit.edu/rrw/presentations/Lenstra81.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lenstra's algorithm&lt;/a&gt;. At the bottom of p.5 (at &amp;quot;construct &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; linear functions&amp;quot;), he says to constrain each &lt;span class=&quot;math-container&quot;&gt;$g_i:\mathbb{R}^n\to\mathbb{R}$&lt;/span&gt; by its value on each of &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; vectors (namely, &lt;span class=&quot;math-container&quot;&gt;$v_0,\dots,v_n$&lt;/span&gt;). My question pertains to what Lenstra does after optimizing on each &lt;span class=&quot;math-container&quot;&gt;$g_i$&lt;/span&gt; (eq.(16)'s paragraph).&lt;/p&gt;&#xA;&lt;p&gt;Why should replacing &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; satisfying eq.(16) (that is, &lt;span class=&quot;math-container&quot;&gt;$\lvert g_i(x-v_j)\rvert&amp;gt;\frac{3}{2}\lvert g_i(v_i-v_j\rvert$&lt;/span&gt;) cause &lt;span class=&quot;math-container&quot;&gt;$vol(v_0,\dots,v_n)=\det(v_i-v_0)_{i\in[n]}$&lt;/span&gt; to increase by a factor of &lt;span class=&quot;math-container&quot;&gt;$\frac{3}{2}$&lt;/span&gt;? I guess I'm not seeing exactly what about this choice of &lt;span class=&quot;math-container&quot;&gt;$g_i$&lt;/span&gt; makes it so desirable to optimize over.&lt;/p&gt;&#xA;&lt;p&gt;Is there a determinant identity that I'm missing that solves this? It seems that were &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; to be replaced by &lt;span class=&quot;math-container&quot;&gt;$v_i=x$&lt;/span&gt;, the angles between some vectors could become quite slim, causing the determinant to perhaps even decrease.&lt;/p&gt;&#xA;" OwnerUserId="3953" LastEditorUserId="123" LastEditDate="2022-01-09T20:53:42.777" LastActivityDate="2022-01-09T20:53:42.777" Title="Linear functions in Lenstra's algorithm" Tags="|linear-programming|integer-programming|convex-optimization|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4637" PostTypeId="1" CreationDate="2020-08-06T16:43:28.540" Score="5" ViewCount="178" Body="&lt;p&gt;I am trying to model a min-max VRP problem with multiple delivery vehicles and I have come up with a model using branch and cut but I do not think it is strong enough as it takes lot of time to converge.&lt;/p&gt;&#xA;&lt;p&gt;Is there any model which is basic enough to implement (I can implement branch and cut).  What I mean is not something like genetic algorithms or ant-colony kind of things. Just a simple MILP model with cut generation to eliminate sub-tours. I do not have capacity constraints or time windows. I just need to minimize the maximum travel distance.&lt;/p&gt;&#xA;&lt;p&gt;I can provide my model if it is necessary&lt;/p&gt;&#xA;" OwnerUserId="3954" LastEditorUserId="3954" LastEditDate="2020-08-06T16:52:12.900" LastActivityDate="2020-08-06T16:52:12.900" Title="Are there any good models for min-max vehicle routing problem?" Tags="|mixed-integer-programming|integer-programming|vehicle-routing|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4638" PostTypeId="2" ParentId="4192" CreationDate="2020-08-06T16:45:16.657" Score="3" Body="&lt;p&gt;Look at case studies from Gurobi: &lt;a href=&quot;https://www.gurobi.com/customers/case-studies/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/customers/case-studies/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3954" LastActivityDate="2020-08-06T16:45:16.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4639" PostTypeId="1" CreationDate="2020-08-06T16:48:15.787" Score="2" ViewCount="64" Body="&lt;p&gt;I am a student studying optimization, and I am interested in algorithms which finds step sizes satisfying the Wolfe (or strong Wolfe) conditions. I do know of one book which provides such an algorithm: &lt;em&gt;Numerical Optimization&lt;/em&gt; by Nocedal and Wright. However, I find its presentation in this book somewhat difficult to understand. Could you please refer me to any resources which provide algorithm(s) for finding step sizes satisfying the Wolfe conditions? If they contain Python implementations that's a huge plus too.&#xA;Thank you very much.&lt;/p&gt;&#xA;" OwnerUserId="3527" LastEditorUserId="3527" LastEditDate="2020-08-06T17:02:00.890" LastActivityDate="2020-08-06T17:02:00.890" Title="Algorithms for finding step sizes which satisfy the Wolfe conditions?" Tags="|optimization|reference-request|algorithms|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4640" PostTypeId="1" AcceptedAnswerId="4648" CreationDate="2020-08-06T20:14:26.107" Score="2" ViewCount="102" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is quasi-convex,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x^*\in\arg\min_{x\in C}f(x).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How to prove that, for any &lt;span class=&quot;math-container&quot;&gt;$a\in C$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f(x) $&lt;/span&gt; is weakly monotonic in the direction of &lt;span class=&quot;math-container&quot;&gt;$(x^*-a)$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Is this simple result a part of an ancient theorem?&lt;/p&gt;&#xA;" OwnerUserId="3956" LastEditorUserId="3956" LastEditDate="2020-08-06T20:43:09.340" LastActivityDate="2020-08-08T09:45:45.680" Title="Quasi-convex function must be &quot;partially monotonic&quot;?" Tags="|optimization|constraint|convexity|convex-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4641" PostTypeId="1" CreationDate="2020-08-07T08:48:38.647" Score="2" ViewCount="550" Body="&lt;p&gt;I have been asked to calculate cycle and safety stock levels for one of our business units. I have very little/no knowledge on the subject of inventory theory so would like to ask what a reasonable approach to this problem might be:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;5 years daily demand data&lt;/li&gt;&#xA;&lt;li&gt;5 years daily inventory data&lt;/li&gt;&#xA;&lt;li&gt;1.5 days lead time from facility to storage&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Data looks to be gamma distributed, which I can test:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yzyj6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yzyj6.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would be extremely grateful if someone could clarify the steps necessary to calculate the above? my thoughts on an approach:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Aggregate data to monthly. Note: both series appear to be stationary - so whilst we might lose some variance information, this looks to be a reasonable step.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Compute the parameters of a lognormal/gamma dist given the datas &lt;code&gt;loc&lt;/code&gt; and &lt;code&gt;scale&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Calculate cycle and safety stock levels based on &lt;a href=&quot;https://en.wikipedia.org/wiki/Safety_stock#:%7E:text=Safety%20stock%20is%20an%20additional,units%20at%20the%20expected%20time.&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; or similar theory with some reasonable assumptions.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;All help very gratefully received.&lt;/p&gt;&#xA;" OwnerUserId="3395" LastEditorUserId="38" LastEditDate="2020-08-10T12:10:40.840" LastActivityDate="2021-10-27T19:52:30.097" Title="How to calculate Cycle &amp; Safety Stock" Tags="|inventory|probability-distributions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4643" PostTypeId="2" ParentId="4633" CreationDate="2020-08-07T12:13:15.727" Score="2" Body="&lt;p&gt;GLPK is not the best performing MILP solver. Instead, you could give one of the leading commercial MILP solvers a try (e.g. Gurobi). You can also try open-source solvers like SCIP a try. Those solvers should be faster out of the box.&lt;/p&gt;&#xA;&lt;p&gt;You can quickly evaluate different solvers with your model by writing it out as &lt;code&gt;.MPS&lt;/code&gt; file. Every MILP solver I know of can read these files.&lt;/p&gt;&#xA;&lt;p&gt;Some solvers, like Gurobi, have special &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/py_model_agc_xxx.html#pythonmethod:Model.addGenConstrXxx&quot; rel=&quot;nofollow noreferrer&quot;&gt;APIs&lt;/a&gt; to formulate OR constraints and indicator constraints. By using these APIs you can sidestep finding a suitable Big-M yourself and let the solver find appropriate values (which may even tightened during the solving process).&lt;/p&gt;&#xA;&lt;p&gt;Still, a million variables is probably challenging for these solvers as well.&lt;/p&gt;&#xA;" OwnerUserId="69" LastActivityDate="2020-08-07T12:13:15.727" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4644" PostTypeId="1" AcceptedAnswerId="4844" CreationDate="2020-08-07T12:58:52.517" Score="3" ViewCount="421" Body="&lt;p&gt;I am familiar with how to use &lt;code&gt;ompr::MIPModel&lt;/code&gt; but I am trying to learn how to use &lt;code&gt;MILPModel&lt;/code&gt; to take advantage of the model build speed. A simplified version of my model is below. I have two decision variables, &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;, binary and of equal length.  I have constraints on the sum of all the &lt;code&gt;x&lt;/code&gt; decision variables, and the sum of all the &lt;code&gt;y&lt;/code&gt; decision variables.  So far so good with &lt;code&gt;MILPModel&lt;/code&gt;, I can build the model and solve it fast.&lt;/p&gt;&#xA;&lt;p&gt;The problem is when I try to use the next constraint.  The LHS of this constraint multiplies the &lt;code&gt;x&lt;/code&gt; binary decision variables by a numeric column in a dataframe of the same length, then multiplies that by a matrix where the rows are equal to the length of &lt;code&gt;x&lt;/code&gt;.  Similar story in the RHS with the &lt;code&gt;y&lt;/code&gt; variable.  I then iterate this constraint 20 times to represent all the columns of the matrix.&lt;/p&gt;&#xA;&lt;p&gt;I've used constraints similar to this many times using &lt;code&gt;MIPModel&lt;/code&gt;, but now when I try this I get an error message, &lt;code&gt;non-numeric argument to binary operator&lt;/code&gt;.  I assume this has something to do with the &lt;code&gt;colwise&lt;/code&gt; function, but I am completely lost on how to approach this, even after reading up on the ompr github site.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;add_variable(x[i], i=1:10, type='binary') %&amp;gt;%&#xA;add_variable(y[i], i=1:10, type='binary') %&amp;gt;%&#xA;add_constraint(sum_expr(x[i],i=1:10) &amp;lt;= 5) %&amp;gt;%&#xA;add_constraint(sum_expr(y[i],i=1:10) &amp;lt;= 3) %&amp;gt;%&#xA;&#xA;#model builds and solves until this point...&#xA;add_constraint( &#xA;sum_expr( x[i]* df&lt;span class=&quot;math-container&quot;&gt;$numeric_column[i] * matrix_a[i,j],i=1:10) &amp;lt;= &#xA;sum_expr(  2* y[i]* df$&lt;/span&gt;numeric_column[i] * df$other_numeric_column[i] * matrix_a[i,j],i=1:10), &#xA;j=1:20) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3958" LastEditorUserId="491" LastEditDate="2022-01-05T19:48:39.307" LastActivityDate="2022-01-05T19:48:39.307" Title="Non-numeric argument to binary operator in MILPModel of ompr package" Tags="|r|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4645" PostTypeId="1" AcceptedAnswerId="4653" CreationDate="2020-08-07T14:34:57.383" Score="-2" ViewCount="249" Body="&lt;p&gt;I want to create an optimized schedule and production to meet demand of four different buyers. I am starting with Pulp but not able to account for continuous production variable and discrete dispatch together. I have following details, objective is to avoid tank top situation:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Expected production is constant at 6,000m3/h.&lt;/li&gt;&#xA;&lt;li&gt;Storage capacity is 400,000m3,&lt;/li&gt;&#xA;&lt;li&gt;LNG carrier parcel size is 300,000m3 (1 parcel every 50h),&lt;/li&gt;&#xA;&lt;li&gt;Ship loading rate is 20,000m3/h,&lt;/li&gt;&#xA;&lt;li&gt;Start of loading occurs such that stock level at end of loading (operational buffer) is 40,000m3.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Objective (Maximmize) = &lt;span class=&quot;math-container&quot;&gt;$150/m3*(Volume Shipped on time) - $&lt;/span&gt;100/m3*(Volume Produced)-&lt;span class=&quot;math-container&quot;&gt;$200/m3*(Volume wasted due to tank top) + $&lt;/span&gt;100/m3*(delayed volume shipping)&lt;/p&gt;&#xA;&lt;p&gt;Constraints: Tank Capacity (Minimum &amp;amp; Maximum);&#xA;Shipping Capacity (One loading every 50 h)&lt;/p&gt;&#xA;&lt;p&gt;Decision Variable: Production Rate (+/-10%)&#xA;Shipping Schedule (+/-24h)&lt;/p&gt;&#xA;&lt;p&gt;..............Adding details................&#xA;With the details mentioned above, I have a base schedule. Now when my production rate changes, I want to move the schedule accordingly such that I am either moving the ships around (comes with a penalty) or using the extra volume (in case of increased production) to load an additional cargo of same capacity or cancel a cargo (in case of reduced production) to ensure that the rest of the schedule is closely met.&lt;/p&gt;&#xA;&lt;p&gt;so, two decisions to be made:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Move the ships slightly (number of hours)&lt;/li&gt;&#xA;&lt;li&gt;Add or remove a cargo (Where in schedule to put to move the rest the least)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Objective function:&#xA;Cost minimization = Penalty to move ship + (benefit/loss) of change in number of cargoes&lt;/p&gt;&#xA;&lt;p&gt;Looking for help.&#xA;PS: I am looking forward to solve this in continuous time frame.&lt;/p&gt;&#xA;" OwnerUserId="3961" LastEditorUserId="3961" LastEditDate="2020-08-28T17:02:02.107" LastActivityDate="2020-08-28T17:02:02.107" Title="Optimized Production Planning &amp; Scheduling" Tags="|mixed-integer-programming|python|scheduling|pulp|matlab|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4646" PostTypeId="1" AcceptedAnswerId="4647" CreationDate="2020-08-07T18:44:01.227" Score="4" ViewCount="320" Body="&lt;p&gt;How to model the following &amp;quot;If, then&amp;quot; type constraint?&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i \in I}x_i = 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{j \in J}x_{j} = n$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are binary variables, &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is a known parameter and &lt;span class=&quot;math-container&quot;&gt;$I \cap J = \emptyset$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3877" LastEditorUserId="491" LastEditDate="2020-12-08T14:56:55.980" LastActivityDate="2020-12-08T14:56:55.980" Title="Model &quot;If, then&quot; constraint" Tags="|constraint|logical-constraints|indicator-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4647" PostTypeId="2" ParentId="4646" CreationDate="2020-08-07T19:12:38.233" Score="9" Body="&lt;p&gt;You want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left(\bigwedge_{i \in I} \lnot x_i\right) \implies \sum_{j \in J} x_j = n.$$&lt;/span&gt;&#xA;Introduce a new binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left(\bigwedge_{i \in I} \lnot x_i\right) \implies y$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y \implies \sum_{j \in J} x_j = n.$$&lt;/span&gt;&#xA;For the first implication, conjunctive normal form yields&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\left(\bigwedge_{i \in I} \lnot x_i\right) &amp;amp;\implies y \\&#xA;\neg \left(\bigwedge_{i \in I} \lnot x_i\right) &amp;amp;\lor y \\&#xA;\left(\bigvee_{i \in I} x_i\right) &amp;amp;\lor y \\&#xA;\sum_{i \in I} x_i + y &amp;amp;\ge 1 \tag1&#xA;\end{align}&lt;/span&gt;&#xA;For the second implication, use big-M:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(0-n)(1-y) \le \sum_{j \in J} x_j - n \le (|J|-n)(1-y) \tag2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that this formulation works even if &lt;span class=&quot;math-container&quot;&gt;$I \cap J \not= \emptyset$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-08-07T19:18:42.987" LastActivityDate="2020-08-07T19:18:42.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4648" PostTypeId="2" ParentId="4640" CreationDate="2020-08-08T09:45:45.680" Score="2" Body="&lt;p&gt;By the definition of &lt;strong&gt;quasiconvex&lt;/strong&gt;: &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; with compact support &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is quasiconvex if for two points in the domain &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w\in[0,1]$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$f(wx_1+(1-w)x_2)\geq \max\{f(x_1),f(x_2)\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x^* = \arg\min_{x\in C}f(x)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is the compact support of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;. Then consider &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2\in [x^*,\infty)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Choose &lt;span class=&quot;math-container&quot;&gt;$x_2&amp;gt;x_1$&lt;/span&gt;. By the definition of quasiconvexity, the secant segment from &lt;span class=&quot;math-container&quot;&gt;$(x_1,f(x_1))$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$(x_2,f(x_2))$&lt;/span&gt; lies below or at the maximum of the segment endpoints &lt;span class=&quot;math-container&quot;&gt;$\{f(x_1),f(x_2)\}$&lt;/span&gt;. Since &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is a global minimizer, we can choose &lt;span class=&quot;math-container&quot;&gt;$x_1=x^*$&lt;/span&gt; which implies the right limit inequality:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\lim_{x_2\downarrow x_1} f(wx_1+(1-w)x_2)-f(x_1)\geq \max\{0,f(x_2)-f(x_1)\}~\forall w\in[0,1].$$&lt;/span&gt; Thus the right derivative is non-negative. This then holds for all &lt;span class=&quot;math-container&quot;&gt;$x_1\geq x^*$&lt;/span&gt;. Thus &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is weakly monotone increasing on &lt;span class=&quot;math-container&quot;&gt;$[x^*,\infty)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We can do likewise for &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2\in(-\infty,x^*]$&lt;/span&gt; using left limits and show that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is weakly monotone decreasing on &lt;span class=&quot;math-container&quot;&gt;$(-\infty,x^*]$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3901" LastActivityDate="2020-08-08T09:45:45.680" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4649" PostTypeId="1" AcceptedAnswerId="4651" CreationDate="2020-08-08T14:55:34.857" Score="13" ViewCount="989" Body="&lt;p&gt;I know that the Column Generation algorithm delivers an exact solution when you are solving a linear programming optimization problem. I want to know that, does this column generation approach deliver the exact solution when integer variables come into the problem and we have actually  MILP? Does Branch and Price algorithm deliver the exact solution?&#xA;What extra must I do in implementing dual optimization problems (subproblems of the algorithm) when there are integer variables?&lt;/p&gt;&#xA;&lt;p&gt;I appreciate your help, advice, or any clue to find my answer.&lt;/p&gt;&#xA;" OwnerUserId="3964" LastActivityDate="2020-08-09T15:37:47.100" Title="Branch and Price algorithm is exact?" Tags="|optimization|combinatorial-optimization|column-generation|branch-and-bound|branch-and-price|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4650" PostTypeId="1" CreationDate="2020-08-09T15:12:12.130" Score="3" ViewCount="339" Body="&lt;p&gt;I asked this question on datascience.stackexchange but they directed me here.&lt;/p&gt;&#xA;&lt;p&gt;I have a social network represented as a set of people &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; and individual weights for each of person (weight is the cost of person).&#xA;I also have defined relationships between these people (whether people know each other or not).&#xA;I must find such a subset &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;, such that every person in this subset either belongs to the set &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; or knows someone from the set &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; directly.&lt;/p&gt;&#xA;&lt;p&gt;There will be a lot of such subsets.&#xA;I want the subset whose sum of weights of people is the smallest.&lt;/p&gt;&#xA;&lt;p&gt;Let's see example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;D = {(John(7), Adam(15), Viktor(6), Bob(2)} and connections are John - Adam - Viktor - Bob. Solutions are Adam,Bob(17) OR John,Victor(13) OR Adam,Victor(21) OR John,Bob(9). The best is the last one - John,Bob(9).&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I thought to create a directed graph where:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each vertex represents person&lt;/li&gt;&#xA;&lt;li&gt;Each vertex has a weight assigned to it&lt;/li&gt;&#xA;&lt;li&gt;Edges between vertices indicate whether the people know each other or not&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I imagine this as a minimum spanning tree on directed graphs problem. I found Chu-Liu/Edmond's algorithm, I know that this algorithm works for edge-weighted graphs and I have vertices-weighted, so I just set the edge weights to what are the weights of the vertices at the end of the edge. But this is not optimal solution. I don't need direct connections between people in the set &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So after I have result from that algorithm, I can apply on it some greedy algorithm, which will go recursively over each element and check how removing it from the subset &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; will affect the structure - when the sum of the weights will be minimal and will ensure that no element falls out of set &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; (check below).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Refer to an example, my MST result will be John,Adam,Victor,Bob(27). Best solution is John,Bob(9). Interesting bad solution is Viktor,Bob(8) - the sum is minimal, unfortunately John will fall out of the &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; subset.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also I assume that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;cost of a person doesn't correlate with their degree in the network (numbers of&#xA;acquaintances)&lt;/li&gt;&#xA;&lt;li&gt;the maximum number of people and acquaintances (vertices and edges) is about 400&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Is my way to solve this problem is good? Do you suggest any other solutions for that?&lt;/p&gt;&#xA;" OwnerUserId="3967" LastEditorUserId="500" LastEditDate="2020-08-09T16:56:29.320" LastActivityDate="2020-08-09T16:56:29.320" Title="social network analysis - relations between people with weights" Tags="|combinatorial-optimization|algorithms|graphs|set-covering|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4651" PostTypeId="2" ParentId="4649" CreationDate="2020-08-09T15:17:05.910" Score="13" Body="&lt;p&gt;To answer your question, it is good to have in mind the following concepts:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dantzig-Wolfe decomposition&lt;/strong&gt; : in essence, this is a change of variables. The initial variables are expressed as a convex combination of the extreme points of the polygon defined by the constraints of the problem.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Column generation&lt;/strong&gt; : once this change of variables has been done, you are often left with a problem with an exponential number of variables and typically you cannot solve it as is. This is where column generation comes in: variables of this huge problem are dynamically created. Once you have generated all of your &amp;quot;good&amp;quot; columns, you have everything you need to solve your continuous problem. If the problem has integer variables, typically the continuous relaxation of the problem will not yield integer variables.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Branch-and-price&lt;/strong&gt; : after doing your column generation, you typically have a fractional solution, so you have to embed this procedure in a branch-and-bound tree. Branch-and-price refers to this branching tree, where at every node, a column generation algorithm is used to compute the continuous solution.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;So to explicitly answer your questions :&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;does this column generation approach deliver the exact solution when&#xA;integer variables come into the problem and we have actually MILP?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;No : column generation will deliver the exact solution of the continuous relaxation of the MILP. Note however that it can be shown that the integrality gap cannot be larger than the integrality gap obtained without the Dantzig-Wolfe decomposition. Usually this integrality is &amp;quot;quite small&amp;quot; and the solution obtained at the root node is quite good. This however depends on the nature of the problem.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Does Branch and Price algorithm deliver the exact solution?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Yes : since branch-and-bound delivers the exact solution of a MILP, and branch-and-price is a variation of branch-and-bound.&lt;/p&gt;&#xA;&lt;p&gt;Check out this cool &lt;a href=&quot;http://www.science4all.org/article/column-generation/&quot; rel=&quot;noreferrer&quot;&gt;article&lt;/a&gt; for more tricks and tips on the subject !&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="500" LastEditDate="2020-08-09T15:37:47.100" LastActivityDate="2020-08-09T15:37:47.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4652" PostTypeId="2" ParentId="4650" CreationDate="2020-08-09T15:45:16.823" Score="5" Body="&lt;p&gt;This is the &lt;em&gt;minimum weight dominating set problem&lt;/em&gt;.  You can solve it via integer linear programming as follows.  For node &lt;span class=&quot;math-container&quot;&gt;$i \in S$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; be the weight and let &lt;span class=&quot;math-container&quot;&gt;$N_i \subseteq S$&lt;/span&gt; be the set of neighbors.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$i \in D$&lt;/span&gt;.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in S} w_i x_i$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i + \sum_{j \in N_i} x_j \ge 1 \quad \text{for $i \in S$}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-08-09T15:45:16.823" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4653" PostTypeId="2" ParentId="4645" CreationDate="2020-08-10T03:04:07.833" Score="1" Body="&lt;p&gt;I'll address your main issue about discrete dispatch. You should model the problem utilizing inventory levels at discrete time intervals that are short enough to fit just one shipment, which sounds like hourly. Utilize tank volume at the end of time interval &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$v_t$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; between 1 and the end of the planning horizon. This allows you to create a constraint that models the LNG production, inventory and shipped volumes: &lt;span class=&quot;math-container&quot;&gt;$v_t = v_{t-1} + r_t - s_t$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$r_t$&lt;/span&gt; is the rate of production during time interval &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s_t$&lt;/span&gt; is the shipped volume during the same interval. The rest of the model can be built upon this relationship.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://or.stackexchange.com/questions/4365/pulp-python-how-to-formulate-a-time-based-variable-for-shipping-demurrage&quot;&gt;this question&lt;/a&gt; for a shipping model in pulp that could get you started.&lt;/p&gt;&#xA;&lt;p&gt;Once you have a simple model and get stuck while adding to it, post an additional question.&lt;/p&gt;&#xA;" OwnerUserId="61" LastActivityDate="2020-08-10T03:04:07.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4654" PostTypeId="1" CreationDate="2020-08-10T09:43:11.793" Score="2" ViewCount="73" Body="&lt;p&gt;Suppose a minimum weighted independent set in a conflict graph with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; vertices. The basic version is where each vertex &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is associated with a weight &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;. i.e., there is a vector &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; for the weights. The problem is to find a set of vertices (with a fixed cardinality &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;) with the minimum total weight. Now, suppose the generalization of the problem as follows:&lt;/p&gt;&#xA;&lt;p&gt;There are &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; types of weights for each vertex, i.e., there is a matrix &lt;span class=&quot;math-container&quot;&gt;$C_{n\times p}$&lt;/span&gt; for the weights. The problem is to find a set of vertices (with a fixed cardinality &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;) with the minimum total weight, where each type of the weights can only be selected once.&lt;/p&gt;&#xA;&lt;p&gt;The mathematical formulation of the problem is as follows (&lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are the indices for the vertices, and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is the index for types of weights).&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA; z = \min&amp;amp;\quad\sum_{i}\sum_{k} c_{ik} x_{ik} \\&#xA;\text{s.t.}&amp;amp;\quad  \sum_k x_{ik} + \sum_k x_{jk} \leq 1, \quad d(i,j) &amp;lt;u,  \quad \forall i,j, \tag1 \\&#xA;&amp;amp;\quad\sum_{i}\sum_{k} x_{ik} = p, \tag2 \\&#xA;&amp;amp;\quad\sum_{i} x_{ik} = 1, \quad \forall k, \tag3 \\&#xA;&amp;amp;\quad\sum_{k} x_{ik} \leq 1, \quad \forall i, \tag4 \\&#xA;&amp;amp;\quad x_{ik} \in \{0,1\}, \quad \forall i, \forall k.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints (1) sets the edges between any two nodes &lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt; that &lt;span class=&quot;math-container&quot;&gt;$d(i,j) &amp;lt;u$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; is a pre-defined parameter.&lt;/p&gt;&#xA;&lt;p&gt;Is this a known type of generalization in the graph theory problems? I mean is there a similar generalization in &lt;em&gt;maximum&lt;/em&gt; independent set, or related problems?&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2020-08-10T12:15:59.243" LastActivityDate="2020-08-10T12:15:59.243" Title="Is this a common generalization of the independent set problem?" Tags="|reference-request|graphs|set-covering|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4655" PostTypeId="1" AcceptedAnswerId="4661" CreationDate="2020-08-10T11:56:43.337" Score="3" ViewCount="351" Body="&lt;p&gt;I'm working on a location problem and I have an issue with the Benders decomposition. I'm using Cplex with Python. I coded a single cut and a multi-cut to compare.&lt;/p&gt;&#xA;&lt;p&gt;The single-cut implementation takes a very long time to run. It requires huge amounts of time to add several cuts (~5000 sec for 7 cuts on a 50 node network). Meanwhile, the multi-cut takes less time (40 sec) to add 500-7000x the number of cuts.&lt;/p&gt;&#xA;&lt;p&gt;1- Where do you think the problem is coming from?&lt;/p&gt;&#xA;&lt;p&gt;2- Is there a way to know how many subproblems the code is creating and solving? and if there are any Cplex built-in functions to do this?&lt;/p&gt;&#xA;" OwnerUserId="889" LastEditorUserId="889" LastEditDate="2020-08-10T12:46:34.550" LastActivityDate="2020-08-10T19:32:43.153" Title="Benders implementation on Cplex is very slow" Tags="|cplex|benders-decomposition|facility-location|cplex-python-api|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4656" PostTypeId="2" ParentId="4641" CreationDate="2020-08-10T12:10:05.090" Score="3" Body="&lt;p&gt;Cycle stock is used to meet the mean demand. Safety stock is used to protect against randomness in demand.&lt;/p&gt;&#xA;&lt;p&gt;So, I would use your historical data to calculate the mean demand over time and the inventory level over time. The mean demand will equal the cycle stock and any excess is the safety stock.&lt;/p&gt;&#xA;&lt;p&gt;You’ll have to decide how to calculate the averages — moving average maybe? Also note that the timing of the data collection matters. For example if data is only collected once per day, at the end of the day, then it masks the inventory dynamics throughout the day.&lt;/p&gt;&#xA;&lt;p&gt;For example if you start the day with 5 units of inventory, then 10 units come in and 10 go out, so you end with 5 units again, then your cycle stock is really ~10 units and your safety stock is ~5.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-08-10T12:10:05.090" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4657" PostTypeId="1" AcceptedAnswerId="4726" CreationDate="2020-08-10T14:51:02.700" Score="5" ViewCount="462" Body="&lt;p&gt;I have the following problem: I have products with different attributes (price, weight, category) and I have a list of clients. Every client has an &amp;quot;affinity value&amp;quot; with every product, the more affinity a person has, the more likely they will like it. I have a list of constraints to follow like: I have to deliver between 5-7 products to a client, the price of the total products has to be less than some value, etc. And I want to maximize the &amp;quot;total affection value&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;I guess this is a Mixed Integer Problem, I'm using the CBC solver from Google OR-Tools library, I set my variables, my constraints, and my objective function. The problem is, this works with small numbers, but if I have a large number of clients and products, it generates too many variables. If I have 20,000 clients and 1,000 different products, I have 20 million variables to solve. When I try to solve it, it takes too long and my computer kills the program for lack of memory.&lt;/p&gt;&#xA;&lt;p&gt;I never dealt with optimization problems before, someone can give me some advice on how the best way to tackle it? I just need to know the path that I should follow, if it's possible to accomplish what I want as well.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I'll try to be more detailed. I have a binary matrix, X, which each line represents a client and a column represents a product. If I'm going to deliver the product to a person, the entry in the matrix is 1, 0 otherwise. So for example, if I have 5 clients and 4 different products and want to deliver 2 products to each client, I have something like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X =&#xA;\begin{bmatrix}&#xA;0 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0\\&#xA;1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1\\&#xA;0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 1\\&#xA;0 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0\\&#xA;1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1&#xA;\end{bmatrix}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have another matrix that I called N, with the same size of X and each position of this matrix corresponds to the same entry in matrix X. N has the &amp;quot;affinity values&amp;quot; that each client has to each product. So, I could have something like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$N = \begin{bmatrix}&#xA;5 &amp;amp; 4 &amp;amp; 1 &amp;amp; 10\\&#xA;1 &amp;amp; 0 &amp;amp; 4 &amp;amp; 1\\&#xA;9 &amp;amp; 6 &amp;amp; 2 &amp;amp; 9\\&#xA;7 &amp;amp; 1 &amp;amp; 6 &amp;amp; 5\\&#xA;1 &amp;amp; 8 &amp;amp; 0 &amp;amp; 1&#xA;\end{bmatrix}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I want to multiply each entry of X with the correspondent entry in N and sum all this multiplications, for example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://latex.codecogs.com/gif.latex?X_%7B11%7D&amp;space;*&amp;space;N_%7B11%7D&amp;space;&amp;plus;&amp;space;X_%7B12%7D&amp;space;*&amp;space;N_%7B12%7D&amp;space;&amp;plus;&amp;space;...&amp;space;&amp;plus;&amp;space;X_%7Bij%7D&amp;space;*&amp;space;N_%7Bij%7D&quot; title=&quot;X_{11} * N_{11} + X_{12} * N_{12} + ... + X_{ij} * N_{ij}&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;What I want to do is maximize the value of this summation, N has fixed values so I have to find a matrix X that give me the largest value possible of this sum. This is my objective function, so:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://latex.codecogs.com/gif.latex?max(X_%7B11%7D&amp;space;*&amp;space;N_%7B11%7D&amp;space;&amp;plus;&amp;space;X_%7B12%7D&amp;space;*&amp;space;N_%7B12%7D&amp;space;&amp;plus;&amp;space;...&amp;space;&amp;plus;&amp;space;X_%7Bij%7D&amp;space;*&amp;space;N_%7Bij%7D)&quot; title=&quot;max(X_{11} * N_{11} + X_{12} * N_{12} + ... + X_{ij} * N_{ij})&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;But I have to follow some constraints: &lt;br&gt;&#xA;I. Each client has to receive between 5 and 7 products&lt;br&gt;&#xA;II. The products can't cost more than 22.00 &lt;br&gt;&#xA;III. We can't allocate more items of one product than we have in stock &lt;br&gt;&#xA;IV.The weight of the box has to be between 600 and 1000 &lt;br&gt;&#xA;V. Every client has to receive equal or less than two product categories (we have 5)&lt;/p&gt;&#xA;&lt;p&gt;And a lot of other constraints.. Basically what I want to do is allocate our products to our clients in a way that the global &amp;quot;affinity value&amp;quot; is the higher as possible. As I see, every relation between a client and a product is a variable, so I have millions of variables that have to obey a lot of constraints.. The CBC solver works well when I have few variables (like 12,500 variables, for example) but can't handle the millions (maybe almost a billion variables in the future) that I have.&lt;/p&gt;&#xA;" OwnerUserId="3970" LastEditorUserId="491" LastEditDate="2022-04-25T12:55:09.127" LastActivityDate="2022-04-25T12:55:09.127" Title="Best way to solve an allocation problem" Tags="|mixed-integer-programming|or-tools|cbc|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="4658" PostTypeId="2" ParentId="4613" CreationDate="2020-08-10T18:02:19.107" Score="1" Body="&lt;p&gt;Computational complexity depends somewhat on the number of elementary calculations performed. The least troublesome is the addition of two integers. A more complex is the multiplication of two floating point numbers (several times more processor ticks). Then multiplication of a vector by a number, multiplication of two vectors, multiplication of a vector by a matrix, multiplication of two matrices, etc.&lt;/p&gt;&#xA;&lt;p&gt;Both versions of the algorithm differ by two equations 5.14c, 5.24c or 5.14d, 5.24d. While equation 5.24c requires additional multiplication by a number, matrix multiplication operations disappear in the 5.24d.&lt;/p&gt;&#xA;&lt;p&gt;It is essential in the implementation that basic operations are performed through specially optimized linear algebra library routines (e.g. BLAS, ATLAS, etc).&lt;/p&gt;&#xA;" OwnerUserId="3186" LastActivityDate="2020-08-10T18:02:19.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4659" PostTypeId="1" CreationDate="2020-08-10T18:27:11.657" Score="6" ViewCount="203" Body="&lt;p&gt;I am a Ph.D. student in management science and I am interested in Dynamic Pricing. I need to define some problems and work on them as my thesis&lt;/p&gt;&#xA;&lt;p&gt;Most papers in this field are full of complicated proofs covering different topics. If I read each paper in detail to fully understand all proofs, it will take much time. However, if I just read the main ideas and results, I am worried whether I will be able to prove any result in my own research.&lt;/p&gt;&#xA;&lt;p&gt;I would be thankful if someone can explain &lt;strong&gt;what strategy is better to read these papers&lt;/strong&gt;, some of which have as many as 30 pages. In some cases, I do not completely understand proofs and miss the point.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="123" LastEditDate="2021-02-16T15:53:56.910" LastActivityDate="2021-02-16T15:53:56.910" Title="What is the best way to read papers in OR/MS field?" Tags="|revenue|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4660" PostTypeId="1" CreationDate="2020-08-10T18:46:14.143" Score="3" ViewCount="72" Body="&lt;p&gt;If I can show a polyhedron Y is an extended formulation of polyhedron X and every extreme point in Y is integral, does that automatically imply the projection of Y onto the variable space of X gives the convex hull of X? Thank you.&lt;/p&gt;&#xA;" OwnerUserId="3971" LastEditorUserId="500" LastEditDate="2020-08-10T18:52:54.057" LastActivityDate="2020-08-10T18:52:54.057" Title="Theoretical aspect of using extended formulation" Tags="|integer-programming|polyhedra|convex-hull|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4661" PostTypeId="2" ParentId="4655" CreationDate="2020-08-10T19:32:43.153" Score="1" Body="&lt;p&gt;If all the cuts you generate have an impact (i.e., you don't generate cuts that are rendered redundant by other cuts), then at least some of the reason that adding a bunch of cuts at once is faster than adding one at a time is that you update the node LP after each cut is added in the first case, and only after all the cuts are added in the second case. So you might look at the iteration count in the CPLEX log, and see if the first method is racking up a lot more iterations adding 7 cuts than the second method does adding a comparable number of cuts (which might be just one call to the callback).&lt;/p&gt;&#xA;&lt;p&gt;That said, 5000 seconds for 7 cuts on a small network sound pretty high, so I would not rule out a problem with your code.&lt;/p&gt;&#xA;&lt;p&gt;As far as the number of subproblems, you can just put a little code in the callback to increment a counter each time the callback is called.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-08-10T19:32:43.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4662" PostTypeId="2" ParentId="4659" CreationDate="2020-08-10T19:45:11.307" Score="10" Body="&lt;p&gt;I think a two-pass approach might be useful, based on the Pareto principle (20% of the papers in any area give you 80% of the overall benefit). Read each paper closely enough to follow what they are saying (&amp;quot;Lagrangian relaxation solves left-handed, red-haired problems faster than ordinary branch and cut in months with 31 days&amp;quot;) and to get a sense of the reasoning (and limits of generality), but don't sweat the proofs. If this is one of the 80% of papers that go in your reference file (to be used later to pad lit reviews, but not otherwise), you're not going to remember the proofs anyway.&lt;/p&gt;&#xA;&lt;p&gt;If the paper seems useful to you, go through it again more thoroughly, checking the validity of the proofs as much as possible (which may also help you understand why the problem being red-haired made a difference, or what goes horribly wrong in February). You might want to take notes on places where you got stuck, so that if you have to revisit the paper at a later date you don't get stuck in the same place. In addition to helping you understand the content, checking the proofs may occasionally result in you catching the authors dealing off the bottom of the deck, which then spares you relying on results that might not be correct.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-08-10T19:45:11.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4663" PostTypeId="1" CreationDate="2020-08-10T20:06:38.563" Score="4" ViewCount="76" Body="&lt;p&gt;Let's say you have a list of at most N Jobs to be done which are coming in a stream. There are two kinds of systems that can do the job:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;System 1: A very fast system, which however, only does the job correctly some of the time.&lt;/li&gt;&#xA;&lt;li&gt;System 2:  A slower system, which does the job correctly all the time, however has a fixed capacity of only doing C jobs, which is small compared to number of total jobs (C &amp;lt; N).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The time required for doing all the jobs is the same for each system.&lt;/p&gt;&#xA;&lt;p&gt;The Probability of the System 1 doing the job correctly (let's call say P_sys1(Job)) depends upon the job itself (so different jobs have different probabilities, some can be 5% some can be as high as 99%).&lt;/p&gt;&#xA;&lt;p&gt;Let's assume the cost of doing a Job badly is Cost(Job). So expected cost of a bad job is (1 - P_sys1 (Job)) * Cost (Job).&lt;/p&gt;&#xA;&lt;p&gt;We need to decide to send the Job to System 1 or 2 as soon as it arrives. Once a job is sent to the either system, it's done and cannot be reprocessed if done wrongly.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;How would we minimise the overall expected cost of doing all the Jobs.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Or equivalently, how will decide which jobs will we send to System 2 to do?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;(intuitively, you want to send the Jobs with the highest cost &amp;amp; smallest probability to succeed in System 1).&lt;/p&gt;&#xA;&lt;p&gt;Note: since the jobs are coming as a stream you don't know all the jobs before hand. You can assume a prediction of what kind of jobs will come in a stream, however, it will also have its own error.&lt;/p&gt;&#xA;&lt;p&gt;Would even appreciate links to any papers or research done on similar problems.&lt;/p&gt;&#xA;" OwnerUserId="1020" LastEditorUserId="1020" LastEditDate="2020-08-11T04:40:39.630" LastActivityDate="2020-08-23T20:50:55.287" Title="How to decide between a inaccurate system and a accurate system with capacity constraints to do a stream of jobs" Tags="|optimization|combinatorial-optimization|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4664" PostTypeId="1" AcceptedAnswerId="4666" CreationDate="2020-08-11T01:14:03.830" Score="6" ViewCount="518" Body="&lt;p&gt;I want to solve a VRP with a column generation algorithm. The objective of the problem is makespan minimization. In more detail, I want to minimize the arrival time of the last vehicle in the depot. I want to know how I should write the path-based model?&lt;/p&gt;&#xA;&lt;p&gt;In path-based models that I have ever seen for VRP, the objective was total cost minimization and all of the variables in the model were binary that corresponds to each route.&#xA;I think in my problem, I should consider a continuous non-negative variable that represents the latest arrival time of vehicles to depot. I want to know if adding this variable is correct and how will it change the column generation algorithm?&lt;/p&gt;&#xA;" OwnerUserId="3972" LastEditorUserId="3972" LastEditDate="2020-08-23T19:22:37.947" LastActivityDate="2020-08-24T00:17:08.497" Title="Column Generation algorithm for vehicle routing problem" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|vehicle-routing|column-generation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4665" PostTypeId="2" ParentId="4663" CreationDate="2020-08-11T09:15:56.940" Score="1" Body="&lt;p&gt;To use simulation- optimization procedure, One way would be as follows:&lt;/p&gt;&#xA;&lt;p&gt;Suppose, you have some jobs in which need to process in stream or chase customer demand. You will have to calculate the probability distribution function (PDF) of the arrival jobs based on the orders or demands. (e.g. using exponential distribution function with a specific parameter).&lt;/p&gt;&#xA;&lt;p&gt;Then, you would need to estimate the jobs failure probability function by using something like goodness-of-fit method. In the next step, when you could estimate these functions, you can use some criteria, for instance, based on &amp;quot;the highest cost &amp;amp; smallest probability to succeed in System 1&amp;quot; as you mentioned.&lt;/p&gt;&#xA;&lt;p&gt;Once, the jobs are assigned to its specific system you can calculate the detailed schedule based on the MP model or maybe simulation process to achieve the optimum efficiency.&lt;/p&gt;&#xA;&lt;p&gt;The process can be depicted as: The arrival jobs=&amp;gt; assign PDF=&amp;gt; define criteria=&amp;gt; schedule systems.&lt;/p&gt;&#xA;&lt;p&gt;I hope it Would be helpful?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2020-08-11T09:55:50.847" LastActivityDate="2020-08-11T09:55:50.847" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4666" PostTypeId="2" ParentId="4664" CreationDate="2020-08-11T15:37:59.393" Score="7" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; be the demand for customer &lt;span class=&quot;math-container&quot;&gt;$i\in N$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$V=\{1,\dots,K\}$&lt;/span&gt; be the set of vehicles, and let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be the set of columns, where each column corresponds to a feasible subtour starting from the depot, with arc variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; and node variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;.  Let &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; be the makespan.&#xA;The master problem over &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is as follows, with dual variables in parentheses:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;z \\&#xA;&amp;amp;\text{subject to} &amp;amp;z - \sum_{p\in P} \left(\sum_{i,j} c_{i,j} x_{i,j}^p\right) \lambda^p_v &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for $v\in V$} &amp;amp;&amp;amp;(\pi_v \ge 0)\\&#xA;&amp;amp;&amp;amp;\sum_{v \in V} \sum_{p\in P} y_i^p \lambda^p_v &amp;amp;\ge 1 &amp;amp;&amp;amp;\text{for $i\in N$}  &amp;amp;&amp;amp;(\text{$\alpha_i \ge 0$})\\&#xA;&amp;amp;&amp;amp;-\sum_{p\in P} \lambda^p_v &amp;amp;\ge -1 &amp;amp;&amp;amp;\text{for $v\in V$}  &amp;amp;&amp;amp;(\text{$\beta_v \ge 0$})\\&#xA;&amp;amp;&amp;amp;\lambda^p_v &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for $v\in V$ and $p\in P$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The column generation subproblem over &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$v\in V$&lt;/span&gt; is then to minimize the reduced cost of &lt;span class=&quot;math-container&quot;&gt;$\lambda^p_v$&lt;/span&gt;.  That is, minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\pi_v \sum_{i,j} c_{i,j} x_{i,j} - \sum_{i \in N} \alpha_i y_i + \beta_v$$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt; forming a feasible subtour starting from the depot, with &lt;span class=&quot;math-container&quot;&gt;$\sum_i d_i y_i \le L$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is the capacity of each vehicle.&lt;/p&gt;&#xA;&lt;p&gt;Because the vehicles are identical, you can use a common column pool &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; instead of requiring a different &lt;span class=&quot;math-container&quot;&gt;$P_v$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$v\in V$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-08-24T00:17:08.497" LastActivityDate="2020-08-24T00:17:08.497" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4667" PostTypeId="1" AcceptedAnswerId="4668" CreationDate="2020-08-12T09:00:41.507" Score="18" ViewCount="14362" Body="&lt;p&gt;I would like to start using Python for modelling and solving optimization problems. I would like to use both single-objective problems and multi-objective problems with a multidimensional objective space. For the multiobjective problems I'd like to use a metaheuristic, something like multiobjective evolutionary algorithms (like NSGA-2) for solving it.&lt;/p&gt;&#xA;&lt;p&gt;Now my question is, which Python package for OR is suitable for doing this? Can I for example use something like:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pyomo&lt;/li&gt;&#xA;&lt;li&gt;Pulp&lt;/li&gt;&#xA;&lt;li&gt;Pyopt&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I'd appreciate every comment and I'd be quite thankful for your help.&lt;/p&gt;&#xA;&lt;p&gt;Update: Here is a more detailed desciption of what I intend to do. Basically I have a multiobjective optimization problem (mixed-integer linear program) with 2 objectives and I would like to compare three methods in different sceanrios with varying complexity:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Weighted sum approach solved by an exaxt algorithm (e.g. using a commerical solver like CPLEX)&lt;/li&gt;&#xA;&lt;li&gt;Weightes sum approach solved by a single-objetice metaheuristic (like conventional evolutionary algorithms or particle swarm optimization)&lt;/li&gt;&#xA;&lt;li&gt;Real multiobjectice optimization with a metaheuristic (like NSGA-2 or MOPSO)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I'd like to do this all in Python, as I read here in the forum that Python is strongly used in the OR community. Which packages would you advice me to use?&lt;/p&gt;&#xA;&lt;p&gt;Additional note: With real multiobjective optimization I mean, not to use a weighted sum approach (and thus convert the objective space into a one-dimensional space) but to have a multidimensional objective space and try to find the Pareto optimal solutions (e.g. with NSGA-2 which is a 'real' multiobjective optimization metaheuristic)&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2020-08-18T08:12:25.553" LastActivityDate="2022-12-05T08:58:30.803" Title="Which Python package is suitable for multiobjective optimization" Tags="|python|metaheuristics|multi-objective-optimization|" AnswerCount="5" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4668" PostTypeId="2" ParentId="4667" CreationDate="2020-08-12T12:16:12.287" Score="16" Body="&lt;p&gt;If you use packages like PyOMO, PuLP or pyOpt, you'd have to implement all the operations for multiobjective optimization - e.g. to find nondominated solutions or the different mutation operators - that could take some time. An alternative is using &lt;a href=&quot;https://deap.readthedocs.io/en/master/&quot; rel=&quot;noreferrer&quot;&gt;DEAP&lt;/a&gt; for that, it's a Python framework for evolutionary algorithm and they have NSGA-II implemented. It's quite customizable and you can also easily interact with other Python libraries in the routines (e.g. for mutation and crossover operations). A second library is &lt;a href=&quot;https://github.com/jMetal/jMetalPy&quot; rel=&quot;noreferrer&quot;&gt;jMetalPy&lt;/a&gt;, which has a broad scope with more multiobjective optimization algorithms implemented (DEAP is focused on evolutionary algorithms).&lt;/p&gt;&#xA;&lt;p&gt;A second alternative is to model some objectives as a budget constraint and use pyomo, pulp, etc, with a varying parameter for that constraint's bound. In the end you'll have found a set of optimal solutions and will be able approximate the nondominated (Pareto) front. There are also some LP- and MIP-specific multiobjective optimization algorithms in the literature. See for example this &lt;a href=&quot;https://github.com/vOptSolver/vOptSolver&quot; rel=&quot;noreferrer&quot;&gt;this GitHub project which is compatible with Julia&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Other alternatives, like taking a linear combination of objectives, are contained in Mark's answer.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;To answer the updated question: OP wants to compare three methods for multiobjective mixed-integer linear program with 2 objectives, in different scenarios with varying complexity, using Python:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Weighted sum approach solved by an exact algorithm&lt;/li&gt;&#xA;&lt;li&gt;Weighted sum approach solved by a single-objetive metaheuristic&lt;/li&gt;&#xA;&lt;li&gt;Multiobjective optimization with a metaheuristic (like NSGA-2 or MOPSO), having a multidimensional objective space and trying to find the Pareto optimal solutions.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I recommend the following for each scenario:&lt;/p&gt;&#xA;&lt;p&gt;For the weighted sum approach, use PyOMO. This way you'll dominate a Python module that allows you to interact with either Gurobi, CPLEX, GLPK, CBC, Mosek, BARON, among other solvers, allowing to be more tool-agnostic than if you worked with a specific software's API. Moreover, there's &lt;a href=&quot;https://www.gams.com/latest/docs/S_PYOMO.html&quot; rel=&quot;noreferrer&quot;&gt;GAMS/PYOMO&lt;/a&gt; which allows users to solve GAMS models using solvers within the PyOMO modeling system. This can be useful as you stated having used GAMS in the past.&lt;/p&gt;&#xA;&lt;p&gt;For scenarios 2. and 3., you can use jMetalPy which has several kinds of algorithms implemented for single-objective (Evolution Strategy, Genetic Algorithm, Local Search, Simulated annealing) and many more for multi-objective: 8 Evolutionary Algorithms (GDE3, HYPE, IBEA, MOCell, MOEA/D, NSGA-II, NSGA-III, SPEA2) and 2 PSO Algorithms (OMOPSO, SMPSO). This way, you'll learn only one library that can get you a whole variety of algorithms and tests available.&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="2477" LastEditDate="2020-08-19T23:56:03.403" LastActivityDate="2020-08-19T23:56:03.403" CommentCount="25" ContentLicense="CC BY-SA 4.0" />
  <row Id="4669" PostTypeId="1" AcceptedAnswerId="4671" CreationDate="2020-08-12T15:58:41.153" Score="5" ViewCount="279" Body="&lt;p&gt;I am reading &lt;a href=&quot;https://link.springer.com/article/10.1007/s10288-010-0130-z&quot; rel=&quot;nofollow noreferrer&quot;&gt;A tutorial on column generation and branch-and-price for vehicle routing problems by Dominique Feillet&lt;/a&gt; to learn the column generation approach, but I have a problem. in section 3.3 entitled Subproblem I can't understand how Expression (23) is equivalent to Expression (22)?&lt;/p&gt;&#xA;&lt;p&gt;The source considers a fleet of size &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; and a directed graph &lt;span class=&quot;math-container&quot;&gt;$G = (V,A)$&lt;/span&gt; with nodes &lt;span class=&quot;math-container&quot;&gt;$ V = \left \{v_0, \ldots, v_n \right \}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$v_0$&lt;/span&gt; is the depot and the rest the customers. Every arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; has an associated cost and time &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt;, respectively.&lt;/p&gt;&#xA;&lt;p&gt;Then, the following notation is introduced to formulate the column generation model:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt; is the set of feasible routes&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_k$&lt;/span&gt; is the cost of route &lt;span class=&quot;math-container&quot;&gt;$r_k \in \Omega$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;parameter &lt;span class=&quot;math-container&quot;&gt;$a_{ik} = 1$&lt;/span&gt; if route &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; visits customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, 0 else&lt;/li&gt;&#xA;&lt;li&gt;parameter &lt;span class=&quot;math-container&quot;&gt;$b_{ijk} = 1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; uses arc &lt;span class=&quot;math-container&quot;&gt;$(v_i,v_k)$&lt;/span&gt;, 0 else&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;With this, the standard column generation formulation for the VRPTW is stated as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp; \sum_{r_k \in \Omega} c_k \theta_k \\&#xA;&amp;amp;\text{s.t.} &amp;amp;\sum_{r_k \in \Omega} a_{ik} \theta_{k} &amp;amp;\ge 1, &amp;amp;&amp;amp; v_i\in V \setminus \left \{ v_0 \right \}\\&#xA;&amp;amp;&amp;amp;\sum_{r_k \in \Omega} \theta_{k} &amp;amp;\le U \\&#xA;&amp;amp;&amp;amp;\theta_{k} &amp;amp;\in \mathbb{N}, &amp;amp;&amp;amp; r_k \in \Omega&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\lambda_0, \lambda_i$&lt;/span&gt;,  be the dual variable associated to the fleet size constraint and for constraints related to visiting client &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, respective, and &lt;span class=&quot;math-container&quot;&gt;$\lambda^*$&lt;/span&gt; be an optimal solution to the dual of the restricted master program. The mentioned expressions (22) and (23) are the following:&lt;/p&gt;&#xA;&lt;p&gt;Reduced cost subproblem: &lt;span class=&quot;math-container&quot;&gt;$$(22) \; c_k - \sum_{v_i \in V \setminus \left \{v_0 \right \} } a_{ik} \lambda^*_i - \lambda^*_0 &amp;lt; 0.$$&lt;/span&gt; Equivalent problem: &lt;span class=&quot;math-container&quot;&gt;$$(23) \;\sum_{(v_i,v_j) \in A} b_{ijk}(c_{ij} - \lambda^*_i) &amp;lt; 0.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I 'm so appreciated if someone can help me.&lt;/p&gt;&#xA;" OwnerUserId="3972" LastEditorUserId="2477" LastEditDate="2020-08-13T00:33:43.713" LastActivityDate="2020-08-13T00:33:43.713" Title="A Question on A tutorial on column generation and branch-and-price for vehicle routing problems by Dominique Feillet" Tags="|mixed-integer-programming|combinatorial-optimization|vehicle-routing|column-generation|branch-and-price|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4670" PostTypeId="2" ParentId="4667" CreationDate="2020-08-12T16:19:12.970" Score="10" Body="&lt;p&gt;If @dbasson 's excellent answer is not what you're looking for, may I suggest the possibility of using multiobjective optimization capabilities in CPLEX or  Gurobi (under Python)?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;CPLEX&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.9.0/ilog.odms.studio.help/CPLEX/ReleaseNotes/topics/releasenotes1290/newMultiObjOptimization.html&quot; rel=&quot;noreferrer&quot;&gt;New multiobjective optimization features in CPLEX V12.9.0&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Optimization problems with multiple linear objective functions can be&#xA;specified in CPLEX. To solve them, CPLEX offers a mixture of blended&#xA;and lexicographic (or hierarchical) optimization.&lt;/p&gt;&#xA;&lt;p&gt;A blended objective consists of simply the linear combination of&#xA;several objectives with given weights.&lt;/p&gt;&#xA;&lt;p&gt;A lexicographic objective supposes that an order has been given among&#xA;the various objective functions. This order allows you to define a&#xA;lexicographic order among solutions: a solution is lexicographically&#xA;smaller than another one if, in the first objective where they differ&#xA;(following the order), it is smaller. An optimal solution is then one&#xA;that is lexicographically minimal (or maximal depending on the&#xA;optimization sense).&lt;/p&gt;&#xA;&lt;p&gt;CPLEX can combine both blended and lexicographic objectives in the&#xA;same optimization problem.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Gurobi&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/working_with_multiple_obje.html&quot; rel=&quot;noreferrer&quot;&gt;Gurobi: Working With Multiple Objective&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&amp;lt;Edited version follows. Skips examples and some other material.&amp;gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Blended Objectives&lt;/strong&gt;  A blending approach creates a single objective by&#xA;taking a linear combination of your objectives. You provide a weight&#xA;for each objective as an argument to setObjectiveN. Alternatively, you&#xA;can use the ObjNWeight attribute, together with ObjNumber.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Hierarchical Objectives&lt;/strong&gt; A hierarchical or lexicographic approach&#xA;assigns a priority to each objective, and optimizes for the objectives&#xA;in decreasing priority order. At each step, it finds the best solution&#xA;for the current objective, but only from among those that would not&#xA;degrade the solution quality for higher-priority objectives. You&#xA;provide the priority for each objective as an argument to&#xA;setObjectiveN. Alternatively, you can use the ObjNPriority attribute.&#xA;Priorities are integral, not continuous. Larger values indicate higher&#xA;priorities. The default priority for an objective is 0.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Multiple-Objective Degradation&lt;/strong&gt; By default, our hierarchical approach&#xA;won't allow later objectives to degrade earlier objectives, subject to&#xA;the user-given ending gap conditions for the optimization problem.&#xA;This behavior can be relaxed for MIPs through a pair of tolerances: a&#xA;relative and an absolute tolerance. These are provided as arguments to&#xA;setObjectiveN, or they can be set using attributes ObjNRelTol and&#xA;ObjNAbsTol. By setting one of these for a particular objective, you&#xA;can indicate that later objectives are allowed to degrade this&#xA;objective by the specified relative or absolute amount, respectively.&#xA;Objective degradations are handled differently for multi-objective LP&#xA;models. For LP models, solution quality for higher-priority objectives&#xA;is maintained by fixing some variables to their values in previous&#xA;optimal solutions. These fixings are decided using variable reduced&#xA;costs. The value of the ObjNAbsTol parameter indicates the amount by&#xA;which a fixed variable's reduced cost is allowed to violate dual&#xA;feasibility, whereas the ObjNRelTol parameter is simply ignored. If&#xA;you want the MIP behavior, where the degradation is controlled more&#xA;directly, you can add a dummy binary variable to the model, thus&#xA;transforming it into a MIP. Solving the resulting multi-objective MIP&#xA;will be much more time consuming than solving the original&#xA;multi-objective LP.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Combining Blended and Hierarchical Objectives&lt;/strong&gt;&#xA;Actually, both weight and priority are always specified for each&#xA;objective. This allows you to seamlessly combine the blended and&#xA;hierarchical approaches. To understand how this works, we should first&#xA;provide more detail on how hierarchical objectives are handled.  When&#xA;you specify a different priority for each of  objectives, the solver&#xA;performs  separate optimization steps. In each step, in decreasing&#xA;priority order, it optimizes for the current objective multiplied by&#xA;its ObjNWeight attribute, while imposing constraints that ensure that&#xA;the quality of higher-priority objectives isn't degraded by more than&#xA;the specified tolerances&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Multiple objective values can be queried&lt;/strong&gt; programmatically in all our APIs&#xA;The basic&#xA;notion is that you have to specify for which multi objective you want&#xA;to query information (by setting the parameter ObjNumber).&#xA;Furthermore, you can also specify for which solution you want to query&#xA;this information (by setting the parameter SolutionNumber.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-08-12T16:19:12.970" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4671" PostTypeId="2" ParentId="4669" CreationDate="2020-08-13T00:21:26.720" Score="7" Body="&lt;p&gt;Note that (as is asserted in the cited tutorial):&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The cost of a route is the addition of the arcs that compose it: &lt;span class=&quot;math-container&quot;&gt;$c_k = \sum_{(v_i, v_j) \in A} b_{ijk}c_{ij}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Relate &lt;span class=&quot;math-container&quot;&gt;$a_{ik}$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$r_k$&lt;/span&gt; visits customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;) with &lt;span class=&quot;math-container&quot;&gt;$b_{ijk}$&lt;/span&gt; (route &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; uses arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;): &lt;span class=&quot;math-container&quot;&gt;$a_{ik} = \sum_{v_j \in V: (v_i, v_j) \in A} b_{ijk}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;And the conditions (22) and (23) are equivalent because: &lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;c_k - \sum_{v_i \in V \setminus \left \{v_0 \right \} } a_{ik} \lambda^*_i - \lambda^*_0 &#xA;&amp;amp;\stackrel{1.}{=} \sum_{(v_i, v_j) \in A} b_{ijk}c_{ij} - \sum_{v_i \in V \setminus \left \{v_0 \right \} } a_{ik} \lambda^*_i - \lambda^*_0 \\ &#xA;&amp;amp;\stackrel{2.}{=} \sum_{(v_i, v_j) \in A} b_{ijk}c_{ij} - \sum_{v_i \in V \setminus \left \{v_0 \right \} } \sum_{v_j \in V: (v_i, v_j) \in A} b_{ijk} \lambda^*_i - \lambda^*_0 \\ &#xA;&amp;amp;= \sum_{(v_i, v_j) \in A} b_{ijk}c_{ij} - \sum_{(v_i, v_j) \in A: v_i \in V \setminus \left \{v_0 \right \}}  b_{ijk} \lambda^*_i - \lambda^*_0 \\&#xA;&amp;amp;= \sum_{(v_i, v_j) \in A} b_{ijk}c_{ij} - \sum_{(v_i, v_j) \in A: v_i \in V \setminus \left \{v_0 \right \}}  b_{ijk} \lambda^*_i - \sum_{v_j \in V - v_0} b_{0jk} \lambda^*_0 \\&#xA;&amp;amp;= \sum_{(v_i, v_j) \in A} b_{ijk}c_{ij} - \sum_{(v_i, v_j) \in A}  b_{ijk} \lambda^*_i  \\&#xA;&amp;amp;= \sum_{(v_i, v_j) \in A} b_{ijk}( c_{ij} -  \lambda^*_i)&#xA;\end{align*}&lt;/span&gt; where we used the fact that &lt;span class=&quot;math-container&quot;&gt;$\sum_{0jk} = 1$&lt;/span&gt; for every feasible route &lt;span class=&quot;math-container&quot;&gt;$r_k$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="2477" LastEditDate="2020-08-13T00:26:30.840" LastActivityDate="2020-08-13T00:26:30.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4672" PostTypeId="1" CreationDate="2020-08-13T09:37:05.827" Score="9" ViewCount="1029" Body="&lt;p&gt;I am looking for resources to learn constraint programming. I will divide the resources I am looking for in three types:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Modeling&lt;/strong&gt;&lt;br /&gt;&#xA;Is there resources (books, articles, courses, etc.) that are equivalent to Model Building in Mathematics by Paul Williams but in constraint programming modeling?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Knowing how a CP solver work&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am looking for resources to learn just enough information on how the solver work. I guess that knowing some of those information could lead to better modeling/debugging.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What to do when a solver is not efficient ?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there techniques to use when using a CP solver is not sufficient from the performance point of view? For example, in integer programming there is matheuristics or decomposition methods. Is there similar methods to use with constraint programming. Maybe a mix of metaheuristics and constraint programming or some decomposition methods related to constraint programming.&lt;/p&gt;&#xA;" OwnerUserId="1188" LastEditorUserId="199" LastEditDate="2020-08-13T10:09:50.480" LastActivityDate="2020-08-18T07:20:31.847" Title="Constraint programming resources" Tags="|solver|reference-request|constraint-programming|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4673" PostTypeId="2" ParentId="4672" CreationDate="2020-08-13T10:08:11.523" Score="5" Body="&lt;p&gt;Constraint programming in its essence can be used to solve mixed-integer programming problems but, not for all cases is efficient. It is frequently used in the scheduling problems to solve the large scale models in which, using BIP/MIP is a bit complicated and need some special methods like decompositions.&lt;/p&gt;&#xA;&lt;p&gt;For more details, would you see &lt;a href=&quot;https://or.stackexchange.com/questions/732/how-to-select-a-constraint-programming-solver&quot;&gt;this&lt;/a&gt; or &lt;a href=&quot;https://or.stackexchange.com/questions/176/what-is-the-difference-between-integer-programming-and-constraint-programming&quot;&gt;this&lt;/a&gt; useful links? Also, there is a nice introduction to CP optimizer which has been published by&#xA;&lt;a href=&quot;https://www.slideshare.net/PhilippeLaborie/planningscheduling-with-cp-optimizer&quot; rel=&quot;noreferrer&quot;&gt;Philippe Laborie&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-08-13T10:08:11.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4674" PostTypeId="2" ParentId="4659" CreationDate="2020-08-13T11:17:14.390" Score="7" Body="&lt;p&gt;Exploring literature is a numbers game. We have to accept that we'll never know everything, so the priority is to maximise the probability of becoming familiar with the most important stuff, and accept that we'll miss out on some things, and that's ok. As a new researcher, you will forget the proofs in a week, but intuition is what sticks and makes you understand the field, so that's, to me, the goal to maximise.&lt;/p&gt;&#xA;&lt;p&gt;I start by reading the abstract. If that looks relevant, I read the conclusions. If those look legit, I then read the introduction. If that also looks relevant, I will then skip all the filler material and go straight to the &amp;quot;new&amp;quot; contributions, which is typically a couple of pages. I will only revert back to the filler material if I'm missing information to understand the new contribution.&lt;/p&gt;&#xA;&lt;p&gt;Honestly, if a paper is not written in a good, understandable way, and is unnecessarily packed with math, I'll pass. I only have so much time, so I find it optimal to spend time on papers that are relevant &lt;strong&gt;and&lt;/strong&gt; well-written.&lt;/p&gt;&#xA;&lt;p&gt;That's not a golden rule though. Sometimes I do spend time understanding badly written papers (btw to me a paper full of proofs and no intuition building or graphs is a badly written paper), if they're highly cited by other prominent authors. This is an indicator that there's good stuff there.&lt;/p&gt;&#xA;&lt;p&gt;One cheat I use when there's an important but badly written paper, is to track down papers that cite it, and see if one of the newer authors explains the original paper in a better way, which is almost always the case for prominent papers. I've found papers that explain a 30-page paper in half a page. I might spend 3 hours tracking that paper down, but it beats spending a month on the original paper.&lt;/p&gt;&#xA;&lt;p&gt;Remember, as living persons, time is our most valuable resource. Sure, the way I do things I surely miss out on some very good stuff, but at least my time is efficiently spent.&lt;/p&gt;&#xA;&lt;p&gt;Finally, don't be too worried about not understanding proofs. Some proofs take years of building intuition to properly understand.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-08-13T11:23:37.663" LastActivityDate="2020-08-13T11:23:37.663" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4675" PostTypeId="1" CreationDate="2020-08-13T15:11:06.770" Score="3" ViewCount="67" Body="&lt;p&gt;I'm working on my MSc thesis and I need real commuting to work data to apply to the optimization models I developed. I read multiple papers that use commuting data and they all refer to public statistics. I tried to find this data for multiple countries (23 countries so far) but I can't seem to find it at all. Can anyone guide me on how I can proceed, and if there's a way to access data from papers?&lt;/p&gt;&#xA;&lt;p&gt;Thank you,&lt;/p&gt;&#xA;" OwnerUserId="889" LastEditorUserId="123" LastEditDate="2020-08-13T19:17:59.527" LastActivityDate="2020-08-13T19:17:59.527" Title="I need help with finding commuting data for an O.R. MSc thesis" Tags="|online-resources|data|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4676" PostTypeId="2" ParentId="4672" CreationDate="2020-08-14T07:06:40.763" Score="8" Body="&lt;p&gt;For modeling, I would recommend one of the following coursera courses, taught using the MiniZinc modeling language:&#xA;&lt;a href=&quot;https://www.coursera.org/learn/basic-modeling&quot; rel=&quot;noreferrer&quot;&gt;https://www.coursera.org/learn/basic-modeling&lt;/a&gt;&#xA;and&#xA;&lt;a href=&quot;https://www.coursera.org/learn/advanced-modeling&quot; rel=&quot;noreferrer&quot;&gt;https://www.coursera.org/learn/advanced-modeling&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;For knowing how a solver works, I can recommend the slides of the course &amp;quot;Combinatorial Optimisation and Constraint Programming&amp;quot; at Uppsala University, more particularly the second part of the slides (starting at T12) at &lt;a href=&quot;http://user.it.uu.se/%7Epierref/courses/COCP/slides/&quot; rel=&quot;noreferrer&quot;&gt;http://user.it.uu.se/~pierref/courses/COCP/slides/&lt;/a&gt; (The first part covers the modeling bit, so is also of interest.)&lt;/p&gt;&#xA;&lt;p&gt;You can certainly also look at this coursera course: &lt;a href=&quot;https://www.coursera.org/learn/discrete-optimization&quot; rel=&quot;noreferrer&quot;&gt;https://www.coursera.org/learn/discrete-optimization&lt;/a&gt; (which covers much more than just constraint programming).&lt;/p&gt;&#xA;&lt;p&gt;Regarding the last question, I would recommend looking up &amp;quot;Large Neighborhood Search&amp;quot; (LNS), which is some form of meta-heuristics technique on top of a constraint programming solver. I believe that most current solvers support LNS in a way or another. I can't think of a specific resource regarding LNS, apart from the paper that introduced the idea: Paul Shaw. Using constraint programming and local search methods to solve vehicle routing problems. In Proceedings of CP98, 1998.&lt;/p&gt;&#xA;&lt;p&gt;More generally, you can find a bunch of relevant resources on this page, including books, solvers, and more courses:&#xA;&lt;a href=&quot;http://www.it.uu.se/research/group/optimisation/resources/constraint&quot; rel=&quot;noreferrer&quot;&gt;http://www.it.uu.se/research/group/optimisation/resources/constraint&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3980" LastActivityDate="2020-08-14T07:06:40.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4677" PostTypeId="1" AcceptedAnswerId="4678" CreationDate="2020-08-14T18:41:18.123" Score="3" ViewCount="512" Body="&lt;p&gt;I am trying to write an ILP for a problem but I have this logical constraint and I'm stuck.&lt;/p&gt;&#xA;&lt;p&gt;In my model I have:&lt;/p&gt;&#xA;&lt;p&gt;two binary variables: &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;One Integer variable: &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The logical constraint I am trying to write is:&lt;/p&gt;&#xA;&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$x = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y = 1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$z \le Mx$&lt;/span&gt;, else &lt;span class=&quot;math-container&quot;&gt;$z = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;" OwnerUserId="3981" LastEditorUserId="36" LastEditDate="2020-08-14T19:19:10.900" LastActivityDate="2020-08-14T19:19:10.900" Title="How to express this logical constraint for an ILP?" Tags="|mixed-integer-programming|linear-programming|linearization|logical-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4678" PostTypeId="2" ParentId="4677" CreationDate="2020-08-14T18:59:37.200" Score="6" Body="&lt;p&gt;You always want &lt;span class=&quot;math-container&quot;&gt;$$z \ge 0 \tag1$$&lt;/span&gt;&#xA;You want &lt;span class=&quot;math-container&quot;&gt;$x = 0 \implies z \le 0$&lt;/span&gt;:  &lt;span class=&quot;math-container&quot;&gt;$$z \le M x \tag2$$&lt;/span&gt;  Similarly, you want &lt;span class=&quot;math-container&quot;&gt;$y = 0 \implies z \le 0$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$$z \le M y \tag3$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-08-14T19:15:09.090" LastActivityDate="2020-08-14T19:15:09.090" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4679" PostTypeId="1" CreationDate="2020-08-14T19:10:19.470" Score="2" ViewCount="147" Body="&lt;p&gt;I am trying to find an safety stock calculation where the expression incorporates:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Lead time variance&lt;/li&gt;&#xA;&lt;li&gt;Sales demand variance &amp;amp;&lt;/li&gt;&#xA;&lt;li&gt;Production forecast variance&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;My calculation so far is based on the first two:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{Safety stock}=Z\sqrt{\left( \frac{PC}{T} \times \sigma_D^2 \right) + (\sigma_{LT} × \mu_D)}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; = Z score&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$PC$&lt;/span&gt; = Lead time&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sigma_D$&lt;/span&gt; = Std of sales demand&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sigma_{LT}$&lt;/span&gt; = Std of lead time&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mu_D$&lt;/span&gt; = Mean sales demand&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I would be very grateful if anyone could sense check this and let me know how historical production forecast error could be included please?&lt;/p&gt;&#xA;" OwnerUserId="3395" LastEditorUserId="39" LastEditDate="2020-08-15T15:42:38.193" LastActivityDate="2020-08-18T15:26:22.703" Title="Safety stock calculation with production forecast variance" Tags="|optimization|inventory|rq-inventory-model|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4680" PostTypeId="1" CreationDate="2020-08-15T07:55:06.953" Score="6" ViewCount="289" Body="&lt;p&gt;I want to use a column generation based heuristic to solve a capacitated Vehicle Routing Problem. I know the basics of the algorithm but I don't have much experience in coding. is there any code about implementing column generation for CVRP that I can have it and get an idea to code my algorithm?&lt;/p&gt;&#xA;" OwnerUserId="3972" LastEditorUserId="3972" LastEditDate="2020-08-15T12:35:51.053" LastActivityDate="2022-09-20T13:26:16.307" Title="Column generation approach for CVRP" Tags="|combinatorial-optimization|vehicle-routing|algorithms|column-generation|heuristics|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4682" PostTypeId="1" AcceptedAnswerId="4683" CreationDate="2020-08-15T19:08:42.813" Score="4" ViewCount="410" Body="&lt;p&gt;I want to write the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; be an integer variable such that &lt;span class=&quot;math-container&quot;&gt;$0\le z\le M$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; be a binary variable where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; denotes big-M. The logical constraint is as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$z \leq M$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z &amp;gt; 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$t=1$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$z=0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$t=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Is this &lt;span class=&quot;math-container&quot;&gt;$z≤Mt$&lt;/span&gt; sufficient? The &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; variables are not in my objective function but variable &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is connected to another variable in the objective function?&lt;/p&gt;&#xA;&lt;p&gt;Thank you very much, I appreciate your help.&lt;/p&gt;&#xA;" OwnerUserId="3981" LastEditorUserId="123" LastEditDate="2020-08-16T08:24:00.370" LastActivityDate="2020-08-16T08:24:00.370" Title="Logical constraint in ILP" Tags="|mixed-integer-programming|linear-programming|linearization|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4683" PostTypeId="2" ParentId="4682" CreationDate="2020-08-15T19:50:49.820" Score="5" Body="&lt;p&gt;The big-M constraint &lt;span class=&quot;math-container&quot;&gt;$z \le M t$&lt;/span&gt; does enforce &lt;span class=&quot;math-container&quot;&gt;$z &amp;gt; 0 \implies t = 1$&lt;/span&gt;, equivalently its contrapositive &lt;span class=&quot;math-container&quot;&gt;$t = 0 \implies z = 0$&lt;/span&gt;, but not the converse &lt;span class=&quot;math-container&quot;&gt;$$z = 0 \implies t = 0. \tag1$$&lt;/span&gt;  To enforce &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, consider its contrapositive &lt;span class=&quot;math-container&quot;&gt;$$t = 1 \implies z &amp;gt; 0 \tag2,$$&lt;/span&gt; which you can enforce via big-M constraint &lt;span class=&quot;math-container&quot;&gt;$$\epsilon - z \le (\epsilon - 0)(1 - t),$$&lt;/span&gt; equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z \ge \epsilon t,$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; is a tolerance that represents the smallest value of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; that you would consider to be positive.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-08-15T19:50:49.820" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4685" PostTypeId="1" CreationDate="2020-08-17T01:26:36.840" Score="6" ViewCount="944" Body="&lt;p&gt;For this question my short-hand is LP = linear program, BFS = basic feasible solution, SEF = standard equality form.&lt;/p&gt;&#xA;&lt;p&gt;Since the Simplex algorithm iterates from extreme point to extreme point (corresponding to the fact that Simplex iterates from BFS to BFS when the LP is in SEF), how does the Simplex algorithm geometrically work when the feasible region is a polyhedron that cannot be realized in SEF (e.g. a halfspace)? Suppose we have an LP for which the feasible region has no extreme points. Then we can write an 'equivalent' LP which is in SEF and run the Simplex algorithm on it instead. But there are extreme points for this new polyhedron, whereas there are none for the original, by assumption. I originally thought that the extreme points of one LP bijectively corresponded to extreme points of the other, but this is evidently not the case.&lt;/p&gt;&#xA;&lt;p&gt;So when exactly do the extreme points of the SEF version of an LP correspond bijectively to extreme points of the original? And further, when such a bijection does not hold, how are we supposed to geometrically interpret what the Simplex algorithm is doing in terms of the original LP?&lt;/p&gt;&#xA;" OwnerUserId="3988" LastActivityDate="2020-08-18T14:55:37.700" Title="Simplex algorithm and extreme points" Tags="|linear-programming|simplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4686" PostTypeId="2" ParentId="4685" CreationDate="2020-08-17T09:18:51.420" Score="1" Body="&lt;p&gt;Not sure I fully understand your question, but I guess your confusion stems from the assumption that a basic solution is an &amp;quot;extreme point&amp;quot;. A basic (not necessarily primal or dual feasible) solution is just the intersection of number of rows constraints (some of which might be bounds). It is possible that a problem does not have a primal or dual feasible solution in as a result is either infeasible or unbounded. Textbook simplex algorithms sometimes skip over the fact that some form of phase 1 approach is needed to establish a BFS to actually start the algorithm. It is possible that a primal phase 1 finds the problem primal infeasible and its also possible that a dual phase 1 finds the problem unbounded.&lt;/p&gt;&#xA;&lt;p&gt;Update:&#xA;The answer by mtanneau is probably saying all there is to say, for a single constraint with free variables the same applies. I just want to add that simplex implementations work with free variables directly and do not convert them to two variables bounded by 0. But the same holds, the algorithm iterates over basic solutions and the convention is made that non-basic free variables take the value 0. Also note that for bounded polyhedra, basic solutions correspond to extreme points.&lt;/p&gt;&#xA;" OwnerUserId="302" LastEditorUserId="302" LastEditDate="2020-08-18T14:45:46.290" LastActivityDate="2020-08-18T14:45:46.290" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4687" PostTypeId="2" ParentId="4646" CreationDate="2020-08-17T16:42:46.533" Score="5" Body="&lt;p&gt;in OPL CPLEX you could directly use logical constraints and write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int m=7;&#xA;range r=1..m;&#xA;&#xA;int n=2;&#xA;&#xA;{int} I={i | i in r : i mod 2==1};&#xA;{int} J={i | i in r : i mod 2==0};&#xA;&#xA;assert card(I inter J)==0;&#xA;&#xA;dvar boolean x[r];&#xA;&#xA;subject to&#xA;{&#xA;  (sum(i in I) x[i]==0) =&amp;gt; (sum(j in J) x[j]==n);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-08-17T16:42:46.533" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4688" PostTypeId="1" CreationDate="2020-08-17T22:18:13.473" Score="4" ViewCount="584" Body="&lt;p&gt;The standard nurse scheduling problem which is used as an example for OR-Tools (see for example &lt;a href=&quot;https://developers.google.com/optimization/scheduling/employee_scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization/scheduling/employee_scheduling&lt;/a&gt;) attempts to assign boolean values to boolean variables in the following line of code:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;shifts[(n, d, s)] = model.NewBoolVar('shift_n%id%is%i' % (n, d, s))&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;For this toy problem, OR-Tools runs fine, but only 105 boolean variables are created (5 nurses, 7 days, 3 shifts &lt;span class=&quot;math-container&quot;&gt;$\Rightarrow 3\times 5\times7=105$&lt;/span&gt; booleans to assign as to whether a given nurse works a given shift).&lt;/p&gt;&#xA;&lt;p&gt;I'm exploring the use of OR-Tools to solve a more realistic real-world scheduling problem. For the real-world problem I'm dealing with, shifts are assigned in 15-minute increments and there are more workers and more roles involved. In the end, I end up with 11,064 booleans to be assigned.&lt;/p&gt;&#xA;&lt;p&gt;Is this too many to expect OR-Tools to work realistically? I find that it quickly produces a (not very good) schedule but then even if I let it run for an hour it doesn't improve at all upon the initial schedule that it came up with in the first few seconds.&lt;/p&gt;&#xA;&lt;p&gt;Is this typical behavior for OR-Tools? Any thoughts?&lt;/p&gt;&#xA;" OwnerUserId="3992" LastEditorUserId="36" LastEditDate="2020-08-18T01:58:37.007" LastActivityDate="2020-08-18T12:33:11.873" Title="maximum number of BoolVar 's before or-tools is no longer feasible to use" Tags="|optimization|python|or-tools|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4689" PostTypeId="1" AcceptedAnswerId="4690" CreationDate="2020-08-17T22:35:45.823" Score="6" ViewCount="104" Body="&lt;p&gt;In the standard max &lt;strong&gt;cost&lt;/strong&gt; flow problem with arc capacities, the cost of using an arc is proportional to the flow through the arc. For example, if &lt;span class=&quot;math-container&quot;&gt;$f_{uv}$&lt;/span&gt; is the flow through the arc &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt;, then the cost of using this arc is given by &lt;span class=&quot;math-container&quot;&gt;$\mathbf{c}_{uv} f_{uv}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{c}_{uv}$&lt;/span&gt; is some predefined real number. So the objective we are interested in maximizing is &lt;span class=&quot;math-container&quot;&gt;$\underset{(u, v) \in E}{\sum} \mathbf{c}_{uv} f_{uv}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is the edges in the graph. You may assume that graph contains a source and a sink node, and all flows emanate from the source and drain into the sink node.&lt;/p&gt;&#xA;&lt;p&gt;Consider the variant in which the cost associated with using the arc &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt; is instead given by:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{cases}&#xA;\mathbf{c}_{uv} f_{uv} + \mathbf{b}_{uv}, \text{ if } f_{uv} &amp;gt; 0,\\&#xA;0, \text{ otherwise}&#xA;\end{cases}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}_{uv}$&lt;/span&gt; is some predefined positive number.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Does the variant of the max flow problem admit a polynomial-time solution?&lt;/li&gt;&#xA;&lt;li&gt;If not, are there any references that you can point me to?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;P.S. I know that the variant I stated can be posed easily as a MILP, however, I am interested in learning about the structural results and complexity of this problem.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2020-08-18T03:51:44.847" LastActivityDate="2020-08-18T07:07:17.530" Title="Complexity \ Reference request for variant of max flow problem" Tags="|reference-request|computational-complexity|network-flow|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4690" PostTypeId="2" ParentId="4689" CreationDate="2020-08-18T07:07:17.530" Score="4" Body="&lt;p&gt;i would assume, that there doesn't even exist an optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;You want to have &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-flow across every edge to collect all the cost &lt;span class=&quot;math-container&quot;&gt;$b_{uv}$&lt;/span&gt;. On the other hand you want to maximize the flow across the edges with the highest cost &lt;span class=&quot;math-container&quot;&gt;$c_{uv}$&lt;/span&gt;. This leads to pressure to have &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; as small as possible, while still &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt;. Such an &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; cannot exist.&lt;/p&gt;&#xA;" OwnerUserId="405" LastActivityDate="2020-08-18T07:07:17.530" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4691" PostTypeId="2" ParentId="4672" CreationDate="2020-08-18T07:20:31.847" Score="10" Body="&lt;p&gt;Here's a complement to @jnmonette's and @A.Omidi's answers.&lt;/p&gt;&#xA;&lt;p&gt;The best book that covers CP in detail is &amp;quot;Handbook of Constraint Programming&amp;quot; (&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0444527265&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.amazon.com/Constraint-Programming-Foundations-Artificial-Intelligence/dp/0444527265&lt;/a&gt;). However, it's from 2006 so it don't discuss the more recent development in CP, such as lazy clause generation and integration with SAT solving techniques. But all the foundations of CP are there so it's a great read.&lt;/p&gt;&#xA;&lt;p&gt;A slightly more recent - and in part more technical - book is Guido Tack's doctoral thesis &amp;quot;Constraint Propagation - Models, Techniques, Implementation&amp;quot; (2009) (&lt;a href=&quot;https://www.gecode.org/publications/2009-02-24-constraint-propagation---models--techniques--implementation.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.gecode.org/publications/2009-02-24-constraint-propagation---models--techniques--implementation.html&lt;/a&gt; ) . Guido is one of the main developers of Gecode and the thesis explains very well Gecode under the hood.&lt;/p&gt;&#xA;&lt;p&gt;Regarding CP modeling, there are unfortunately very few books on this. One of the best is Gecode's documentation &amp;quot;Modeling and Programming with Gecode&amp;quot; (&lt;a href=&quot;https://www.gecode.org/documentation.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.gecode.org/documentation.html&lt;/a&gt; ). It explains a lot of models and different approaches for solving certain problems, including how to fix slow models.&lt;/p&gt;&#xA;&lt;p&gt;I would also like to mention Helmut Simonis excellent tutorials on Constraint Programming with the ECLiPSe CLP (Prolog) system: &lt;a href=&quot;https://www.eclipseclp.org/ELearning/&quot; rel=&quot;noreferrer&quot;&gt;https://www.eclipseclp.org/ELearning/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="260" LastActivityDate="2020-08-18T07:20:31.847" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4692" PostTypeId="2" ParentId="4688" CreationDate="2020-08-18T12:33:11.873" Score="4" Body="&lt;p&gt;There are no good answers to that question. It depends on the model, on the complexity of the problem. My gut reaction is that OR-Tools routinely solves to optimality bigger problems, but some much smaller problems can be impossible to prove, or even to find a feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;OR-Tools is a good CP solver (it won all 4 gold medals of the last 2 minizinc challenges).&#xA;It is also a decent MIP solver (it closed 5 open MIPLIB 2017 instances and improved bounds on a few more).&lt;/p&gt;&#xA;&lt;p&gt;I would suggest, or repeat the above suggestions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;compare to a commercial MIP solver (Gurobi, Cplex, Xpress) and try your luck.&lt;/li&gt;&#xA;&lt;li&gt;compare to CPLEX CP-Optimizer. I would not expect it to be better following discussions I had with academic researchers who did the comparison, but this might be a problem when CPO performs superbly.&lt;/li&gt;&#xA;&lt;li&gt;send your model to the or-tools users mailing list and ask for help or comments, in particular around the search parameters.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="981" LastActivityDate="2020-08-18T12:33:11.873" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4693" PostTypeId="2" ParentId="4685" CreationDate="2020-08-18T13:06:58.737" Score="10" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;the Simplex algorithm iterates from extreme point to extreme point&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Technically, no. The simplex algorithm iterates from &lt;em&gt;basis&lt;/em&gt; to &lt;em&gt;basis&lt;/em&gt;. It just happens that feasible basic solutions correspond to extreme points.&#xA;(for instance, the dual simplex iterates through dual-feasible basic solutions, which are not extreme points of the primal-feasible region).&lt;/p&gt;&#xA;&lt;p&gt;Consider an LP in standard form, which writes&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min  \ \ \ &amp;amp; c^{T}x\\&#xA;\text{s.t.}  \ \ \ &amp;amp; Ax  = b\\&#xA;       &amp;amp;x \geq 0&#xA;\end{align}&lt;/span&gt;&#xA;That LP's feasible region is always polyhedral.&#xA;If it has no extreme points, then it is either empty (and there are no basic feasible solutions), or an affine sub-space of &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^{n}$&lt;/span&gt;.&#xA;Now, the latter case &lt;em&gt;cannot&lt;/em&gt; happen, because no affine sub-space can be a subset of &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}_{+}^{n}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, coming back to (what I think is) your original question: given an original polyhedron and a SEF representation for it, does that representation has extreme points, and do they correspond to extreme points of the original polyhderon?&#xA;The answer is: yes, the SEF will have extreme points, and no, they may not always correspond to extreme points of your original polyhedron.&lt;/p&gt;&#xA;&lt;p&gt;Here is a simple example: take &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P} = \{x \in \mathbb{R}\}$&lt;/span&gt;, which is a 1-dimensional polyhedron. Its formulation has one free variable and no constraints.&lt;/p&gt;&#xA;&lt;p&gt;To build a SEF representation, replace &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$x^{+} - x^{-}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x^{\pm} \geq 0$&lt;/span&gt;.&#xA;Now, &lt;span class=&quot;math-container&quot;&gt;$(0, 0)$&lt;/span&gt; is an extreme point of that SEF, which corresponds to &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt;, which is not an extreme point of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="123" LastEditDate="2020-08-18T14:55:37.700" LastActivityDate="2020-08-18T14:55:37.700" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4694" PostTypeId="2" ParentId="4679" CreationDate="2020-08-18T15:26:22.703" Score="1" Body="&lt;p&gt;It sounds like you have a problem that involves three types of uncertainty:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Demand uncertainty&lt;/li&gt;&#xA;&lt;li&gt;Lead time uncertainty&lt;/li&gt;&#xA;&lt;li&gt;Yield uncertainty&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Yield uncertainty is a somewhat general term that refers to uncertainty in the amount of supply available. (Related terms include capacity uncertainty and supply disruptions.)&lt;/p&gt;&#xA;&lt;p&gt;With uncertainty sources #1 and 2, you can use the formula you listed. I am not aware of models that combine all 3 sources, but you might search the literature for those three terms simultaneously.&lt;/p&gt;&#xA;&lt;p&gt;It might also be possible to merge #1 and 3: If the demand is &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; and the supply is &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, then the random variable of interest is really &lt;span class=&quot;math-container&quot;&gt;$D-S$&lt;/span&gt;, and you might be able to formulate the problem using that r.v. in place of the demand.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-08-18T15:26:22.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4695" PostTypeId="1" CreationDate="2020-08-18T16:22:31.107" Score="4" ViewCount="185" Body="&lt;p&gt;This question is a variant of a question I posted earlier and also fixes some typos in the earlier post (&lt;a href=&quot;https://or.stackexchange.com/questions/4689/complexity-reference-request-for-variant-of-max-flow-problem&quot;&gt;Complexity \ Reference request for variant of max flow problem&lt;/a&gt;). Some of the changes are highlighted in bold italics and the main difference is in the objective function shown in Eqn (\ref{Eq:1}).&lt;/p&gt;&#xA;&lt;p&gt;In the standard max cost flow problem with arc capacities, the cost of using an arc is proportional to the flow through the arc. For example, if &lt;span class=&quot;math-container&quot;&gt;$f_{uv}$&lt;/span&gt; is the flow through the arc &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt;, then the cost of using this arc is given by &lt;span class=&quot;math-container&quot;&gt;$\mathbf{c}_{uv} f_{uv}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{c}_{uv}$&lt;/span&gt; is some predefined &lt;em&gt;&lt;strong&gt;non-negative&lt;/strong&gt;&lt;/em&gt; number. So the objective we are interested in maximizing is &lt;span class=&quot;math-container&quot;&gt;$\underset{(u, v) \in E}{\sum} \mathbf{c}_{uv} f_{uv}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is the edges in the graph. You may assume that graph contains a source and a sink node, and all flows emanate from the source and drain into the sink node.&lt;/p&gt;&#xA;&lt;p&gt;Consider the variant in which the cost associated with using any arc &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt; is instead given by the pointwise maximum of two linear functions:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max{\left(\mathbf{c}_{uv}^{1} f_{uv} , \mathbf{c}_{uv}^{2} f_{uv} + \mathbf{b}_{uv}^{2}\right)} \tag{1} \label{Eq:1}$$&lt;/span&gt;&#xA;&lt;em&gt;&lt;strong&gt;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}_{uv}^{2} \leq 0$&lt;/span&gt; is some predefined non-positive number, and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{c}_{uv}^{1}, \mathbf{c}_{uv}^{2} \geq 0$&lt;/span&gt; are pre-defined non-negative numbers&lt;/strong&gt;&lt;/em&gt;. As before &lt;span class=&quot;math-container&quot;&gt;$f_{uv}$&lt;/span&gt; is the flow through the arc &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt;. As you can observe from Eqn (\ref{Eq:1}), there may exists some constant &lt;span class=&quot;math-container&quot;&gt;$\lambda \geq 0$&lt;/span&gt; such that&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\tag{2} \label{Eq:2}&#xA;\begin{cases}&#xA;\mathbf{c}_{uv}^{1} f_{uv}  \geq  \mathbf{c}_{uv}^{2} f_{uv} + \mathbf{b}_{uv}^{2}, \text{ if } f_{uv} \leq \lambda \\&#xA;\mathbf{c}_{uv}^{1} f_{uv}  \leq  \mathbf{c}_{uv}^{2} f_{uv} + \mathbf{b}_{uv}^{2}, \text{ otherwise }&#xA;\end{cases}&#xA;\end{equation}&lt;/span&gt;&#xA;From Eqn (\ref{Eq:2}), we can observe that the cost of using an arc (may) switch (to a different function) based on the flow through the arc if it exceeds the threshold &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Does the variant of the max flow problem (whose objective now is &lt;span class=&quot;math-container&quot;&gt;$\underset{(u, v) \in E}{\sum} \max{\left(\mathbf{c}_{uv}^{1} f_{uv}, \mathbf{c}_{uv}^{2} f_{uv} + \mathbf{b}_{uv}^{2}\right)}$&lt;/span&gt; admit a polynomial-time computable optimal solution?&lt;/li&gt;&#xA;&lt;li&gt;If a maximum is not attainable, is there an efficient method to compute the supremum for the problem?&lt;/li&gt;&#xA;&lt;li&gt;Are there any references that you can point me to?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;P.S. I know that the variant I stated can be posed as a MILP, however, I am interested in learning about the structural results and complexity of this problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;My previous question (&lt;a href=&quot;https://or.stackexchange.com/questions/4689/complexity-reference-request-for-variant-of-max-flow-problem&quot;&gt;Complexity \ Reference request for variant of max flow problem&lt;/a&gt;) was an attempt to simplify the problem posted here. I am reposting a new question since the earlier question contained mistakes in the description.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2020-08-18T21:18:07.090" LastActivityDate="2020-08-19T00:56:35.450" Title="Max flow problem with piece-wise costs" Tags="|computational-complexity|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4696" PostTypeId="1" AcceptedAnswerId="4697" CreationDate="2020-08-18T17:29:10.997" Score="3" ViewCount="134" Body="&lt;p&gt;The following problem has only two integer variables; however, they appear in the index of the parameters. Appreciate it if anyone has any efficient idea to transform it into a canonical integer programming model.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{alignat*}{2}&#xA;&amp;amp;&amp;amp;\max  \quad &amp;amp; (d_y - d_x)^2 \\&#xA;&amp;amp;&amp;amp;\text{s.t.} \quad &amp;amp; d_y - d_x \geq \alpha  \\&#xA;&amp;amp;&amp;amp;   &amp;amp; x,y \in \mathbb{Z}_+ \\&#xA;\end{alignat*}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10" LastEditorUserId="500" LastEditDate="2020-08-18T20:10:07.543" LastActivityDate="2020-08-18T20:10:07.543" Title="Integer decision variables as index" Tags="|integer-programming|constraint-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4697" PostTypeId="2" ParentId="4696" CreationDate="2020-08-18T18:30:04.740" Score="3" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$x,y\in\{0,\dots,n\}$&lt;/span&gt;.  I think I would just loop over these &lt;span class=&quot;math-container&quot;&gt;$(n+1)^2$&lt;/span&gt; pairs and keep the best one that satisfies the constraint.&lt;/p&gt;&#xA;&lt;p&gt;But if you insist on integer programming, introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in\{0,\dots,n\}$&lt;/span&gt;, with the interpretation that &lt;span class=&quot;math-container&quot;&gt;$d_x=\sum_i d_i x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_y=\sum_i d_i y_i$&lt;/span&gt;.  The problem is to maximize &lt;span class=&quot;math-container&quot;&gt;$$\left(\sum_i d_i (y_i - x_i)\right)^2$$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i x_i &amp;amp;= 1\\&#xA;\sum_i y_i &amp;amp;= 1\\&#xA;\sum_i d_i (y_i - x_i) &amp;amp;\ge \alpha&#xA;\end{align}&lt;/span&gt;&#xA;If you want, you can linearize the objective.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-08-18T18:30:04.740" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4698" PostTypeId="2" ParentId="4695" CreationDate="2020-08-19T00:56:35.450" Score="3" Body="&lt;p&gt;You can rewrite the maximum cost flow problem with objective&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\underset{(u, v) \in E}{\sum} \max{\left(\mathbf{c}_{uv}^{1} f_{uv}, \mathbf{c}_{uv}^{2} f_{uv} + \mathbf{b}_{uv}^{2}\right)}$$&lt;/span&gt;&#xA;as a minimum cost flow problem with objective&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\underset{(u, v) \in E}{\sum} g_{uv}(f_{uv})$$&lt;/span&gt;&#xA;for the concave function &lt;span class=&quot;math-container&quot;&gt;$g_{uv}(f_{uv}) = -\max{\left(\mathbf{c}_{uv}^{1} f_{uv}, \mathbf{c}_{uv}^{2} f_{uv} + \mathbf{b}_{uv}^{2}\right)}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This problem is known as the &lt;em&gt;minimum concave-cost network flow problem&lt;/em&gt; (MCCNFP), which is &lt;span class=&quot;math-container&quot;&gt;$\mathcal{NP}$&lt;/span&gt;-hard in general, according to &lt;a href=&quot;https://doi.org/10.1007/BF02283688&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;, for example. Of course it is still possible that your specific variant is easier.&lt;/p&gt;&#xA;&lt;p&gt;There is a lot of literature on the MCCNFP, but it seems that modeling the problem as a MILP and testing whether it solves in reasonable time is the most straightforward start.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2020-08-19T00:56:35.450" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4699" PostTypeId="1" CreationDate="2020-08-19T05:16:31.267" Score="4" ViewCount="188" Body="&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{R}^{n \times 1}, X \in \mathbb{R}^{n \times p}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p &amp;gt; n$&lt;/span&gt;, assume a LASSO-type optimization problem in the form of&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \hat\beta=\underset{\beta}{\operatorname{argmin}}\frac{1}{2}\left\|y - X \beta \right\|_{2}^{2} + \sum_{i}p(|\beta_i|; \gamma; \lambda)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$p(|\beta_i|; \gamma; \lambda)$&lt;/span&gt; is a non-convex function in &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; denoting the degree of regularization and non-convexity. Typically known examples are SCAD, MCP penalties, among probably many others.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My question:&lt;/strong&gt; I want to implement solutions for known penalties and test out some custom penalties.  What are currently the faster known solvers that would be able to adequately tackle such problems? Which family of solvers should I be looking at for quick/feasible computations? Are there any general solvers, or do they highly depend on the specific penalty function?&lt;/p&gt;&#xA;&lt;p&gt;My initial approach was to start from Augmented Lagrangian for every &lt;span class=&quot;math-container&quot;&gt;$\lambda, \gamma$&lt;/span&gt; throughout the solution path, which seem to work for small &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; values, given &lt;span class=&quot;math-container&quot;&gt;$p &amp;lt; n$&lt;/span&gt;, but doesn't seem to scale well into bigger problems.&lt;/p&gt;&#xA;" OwnerUserId="3998" LastEditorUserId="3998" LastEditDate="2020-09-07T13:45:34.543" LastActivityDate="2020-09-07T13:45:34.543" Title="Fast solvers for LASSO-type non-convex optimization problems" Tags="|optimization|nonconvex-programming|regression|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4700" PostTypeId="1" AcceptedAnswerId="4702" CreationDate="2020-08-19T13:30:09.623" Score="4" ViewCount="304" Body="&lt;p&gt;I'm working on a paper for the first time and I would like to know which papers are recommended to study and analyze for their excellent writing and structure, and which authors in OR are recognized as strong writers.&lt;/p&gt;&#xA;" OwnerUserId="889" LastEditorUserId="123" LastEditDate="2021-02-09T21:08:57.990" LastActivityDate="2021-02-16T14:52:08.383" Title="What are the best written papers in O.R and best authors in terms of writing?" Tags="|reference-request|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4701" PostTypeId="1" AcceptedAnswerId="4709" CreationDate="2020-08-19T13:42:33.887" Score="5" ViewCount="560" Body="&lt;p&gt;I wonder if there are methods to determine the global optimum of MINLP problems, when the nonlinear functions involved are only of the form &lt;span class=&quot;math-container&quot;&gt;$Z = Y e^{- \alpha X}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$Y \ge 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X \ge 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Are there any papers describing such an approach? Do these functions bear any characteristics that may be exploited?&lt;/p&gt;&#xA;&lt;p&gt;Using logarithms I can rewrite the functions as &lt;span class=&quot;math-container&quot;&gt;$\log(Z) = \log(Y) - \alpha X$&lt;/span&gt;, but I don't think I am winning anything.&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2020-08-19T13:46:48.187" LastActivityDate="2020-08-20T20:32:33.490" Title="Global Optimization when the exponential function is involved" Tags="|reference-request|minlp|global-optimization|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4702" PostTypeId="2" ParentId="4700" CreationDate="2020-08-19T14:09:18.553" Score="7" Body="&lt;p&gt;Many journals offer best paper awards. For example check out the &lt;a href=&quot;https://www.elsevier.com/awards/European-Journal-of-Operational-Research-best-paper-awards&quot; rel=&quot;nofollow noreferrer&quot;&gt;European Journal of Operations Research best paper awards&lt;/a&gt; for some really good papers.&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2020-08-19T14:31:53.543" LastActivityDate="2020-08-19T14:31:53.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4703" PostTypeId="1" CreationDate="2020-08-20T01:48:10.900" Score="6" ViewCount="245" Body="&lt;p&gt;Is there a standard set of asymmetric capacitated vehicle routing problem (ACVRP) benchmark instances similar to CVRP  (&lt;a href=&quot;http://vrp.galgos.inf.puc-rio.br/index.php/en/&quot; rel=&quot;noreferrer&quot;&gt;http://vrp.galgos.inf.puc-rio.br/index.php/en/&lt;/a&gt;)?&lt;/p&gt;&#xA;&lt;p&gt;The only thing I found were a few (easy) instances from Fischetti, et al. (1994) here:&#xA;&lt;a href=&quot;http://or.dei.unibo.it/library/vrplib-vehicle-routing-problem-library&quot; rel=&quot;noreferrer&quot;&gt;http://or.dei.unibo.it/library/vrplib-vehicle-routing-problem-library&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="587" LastActivityDate="2020-08-20T07:00:03.197" Title="Asymmetric vehicle routing benchmark instances" Tags="|vehicle-routing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4704" PostTypeId="2" ParentId="4701" CreationDate="2020-08-20T05:28:12.823" Score="4" Body="&lt;p&gt;Assuming the continuous relaxation is convex you can most likely use conic optimization with the exponential cone. The &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/expo.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek modelling cookbook&lt;/a&gt; has the details.&lt;/p&gt;&#xA;&lt;p&gt;Unsurprisingly &lt;a href=&quot;https://mosek.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek&lt;/a&gt; can solve the mixed integer version of such problems.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2020-08-20T05:28:12.823" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4706" PostTypeId="2" ParentId="4703" CreationDate="2020-08-20T07:00:03.197" Score="6" Body="&lt;p&gt;Take a look at VRP REP's, filtered on ACVRP datasets.&lt;/p&gt;&#xA;&lt;p&gt;That listing includes &lt;a href=&quot;http://www.vrp-rep.org/datasets/item/2017-0001.html&quot; rel=&quot;noreferrer&quot;&gt;my &amp;quot;Belgium&amp;quot; VRP datasets on on VRP REP&lt;/a&gt; (the most popular download on VRP REP) which contain asymmetric CVRP datasets. Look for the &lt;strong&gt;road-km&lt;/strong&gt; and &lt;strong&gt;road-time&lt;/strong&gt; variants in the files of that zip. The &amp;quot;air&amp;quot; variants are symmetric. It has variants with one depot and variants with multiple depots. Each variant has variants with 50 locations up to 2750 locations.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2020-08-20T07:00:03.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4708" PostTypeId="1" AcceptedAnswerId="4710" CreationDate="2020-08-20T08:52:31.810" Score="3" ViewCount="131" Body="&lt;p&gt;I have a MILP model with continuous variables (&lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt;) and binaries (&lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt;).&#xA;I am using Java and cplex 12.8 for implementation.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way by which - using the Java-cplex API - I would be able to write only one model that can be solved first with the binary &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt;'s and then for the continuous variables (&lt;span class=&quot;math-container&quot;&gt;$0 \leq x_{ij} \leq 1$&lt;/span&gt;)? I want to see the gap between LP-R and MIP on the fly - and don't want to build two different LP and MILP models.&lt;/p&gt;&#xA;" OwnerUserId="4005" LastActivityDate="2020-08-20T14:53:49.323" Title="How can I change decision variable type in Concert Technologies (with Java)" Tags="|mixed-integer-programming|cplex|java|concert|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4709" PostTypeId="2" ParentId="4701" CreationDate="2020-08-20T12:43:00.947" Score="4" Body="&lt;p&gt;This is a non-convex global optimisation problem. The state-of-the-art way to solve this is to use a factorable relaxation.&lt;/p&gt;&#xA;&lt;p&gt;A key insight here is that &lt;span class=&quot;math-container&quot;&gt;$e^{-\alpha X}$&lt;/span&gt; is convex (since your &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is positive).&lt;/p&gt;&#xA;&lt;p&gt;The methodology would be as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Introduce a new auxiliary variable &lt;span class=&quot;math-container&quot;&gt;$w=e^{-\alpha X}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;You now have &lt;span class=&quot;math-container&quot;&gt;$Z=Yw$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$w=e^{-\alpha X}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Because both constraints are non-convex, you split each to two inequalities:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Z\leq Yw, -Z\leq -Yw$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ w\leq e^{-\alpha X}, -w\leq -e^{-\alpha X}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first set of inequalities can be convexified using a &lt;a href=&quot;https://optimization.mccormick.northwestern.edu/index.php/McCormick_envelopes&quot; rel=&quot;nofollow noreferrer&quot;&gt;McCormick relaxation&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The second set of inequalities are convex and concave respectively. The convex inequality can be relaxed using an outer approximation, and the concave inequality using a secant.&lt;/p&gt;&#xA;&lt;p&gt;You then plug your relaxed problem into a branch-and-bound algorithm and it will converge quadratically.&lt;/p&gt;&#xA;&lt;p&gt;Note that this methodology is independent of the signs of &lt;span class=&quot;math-container&quot;&gt;$Z,Y,X$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, you can plug this into a global solver which will do all of this for you automatically. &lt;a href=&quot;https://projects.coin-or.org/Couenne&quot; rel=&quot;nofollow noreferrer&quot;&gt;Couenne&lt;/a&gt; is an open-source choice, and if you are an academic/student you can also use SCIP or our own &lt;a href=&quot;https://octeract.com/academic-licences/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Engine&lt;/a&gt; for free.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-08-20T12:49:37.727" LastActivityDate="2020-08-20T12:49:37.727" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4710" PostTypeId="2" ParentId="4708" CreationDate="2020-08-20T14:53:49.323" Score="2" Body="&lt;p&gt;The type of a variable cannot be changed. However, it can be overwritten for a particular model by adding an IloConversion object, which allows you to specify new types for variables within that model. When ILOG CPLEX finds a conversion object in the active model, it uses the variable types specified in the conversion object instead of the original type specified for the optimization. For example in a model containing:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;IloNumVar x = cplex.numVar(0.0, 1.0);   &#xA;cplex.add(cplex.conversion(x, IloNumVarType.Int));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-08-20T14:53:49.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4711" PostTypeId="2" ParentId="4467" CreationDate="2020-08-20T19:51:59.453" Score="3" Body="&lt;p&gt;I think, answers provided so far are great. When talking to professionals in the field, I second Nikos and call them &amp;quot;parameters&amp;quot; and cross my fingers they know the difference between a parameter and a variable (which is a bleeding wound between the OR profession in Industrial Engineering and OR profession in Business Administration). On the other hand, practitioners usually have a hugely different understanding of what &amp;quot;data&amp;quot; mean. They call every number or descriptive text gathered &amp;quot;data,&amp;quot; which is hard to argue as they are right by the definition of &lt;em&gt;data&lt;/em&gt; being like: &amp;quot;Come, come, whoever you are [Mevlana Jelaluddin Rumi].&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;To kindly express the notion in my mind &amp;quot;I cannot do this so-called optimization stuff without you giving me the right data, dude!&amp;quot; I would just tell the practitioner: &amp;quot;I need the &lt;em&gt;problem data&lt;/em&gt;&amp;quot; and define what I mean by it. Have I been successful so far? I don't know, I am only 30... I need to collect more data to answer whether this was a successful approach :)&lt;/p&gt;&#xA;" OwnerUserId="518" LastActivityDate="2020-08-20T19:51:59.453" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4712" PostTypeId="2" ParentId="4701" CreationDate="2020-08-20T20:32:33.490" Score="2" Body="&lt;p&gt;You may find a partial answer to your question in the following article (forthcoming in OR) by JP Vielma and J Huchette &lt;a href=&quot;https://arxiv.org/abs/1708.00050&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/1708.00050&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In that paper, the authors consider the problem of approximating non-linear functions of one or two variables in the objective via the disjunction of multiple hyperplanes. You can then pass the resulting MIP to a general-purpose mixed-integer solver.&lt;/p&gt;&#xA;&lt;p&gt;That article contains citations to other sources that may also be of help.&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2020-08-20T20:32:33.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4713" PostTypeId="1" AcceptedAnswerId="4717" CreationDate="2020-08-20T21:13:03.350" Score="9" ViewCount="630" Body="&lt;p&gt;I am reviewing the facility location problem (FLP) literature. Here, &lt;a href=&quot;http://daskin.engin.umich.edu/wp-content/uploads/sites/133/2014/07/daskinchapterfinaltrackchangesoffwithfullcitation.pdf&quot; rel=&quot;noreferrer&quot;&gt;Daskin and Dean (2004)&lt;/a&gt; provided a short literature on discrete space FLPs, which was useful to distinguish different types of models with varying objectives. Chopra and Meindl (2013) showed a small example of an FLP over continuous space with a single facility selection, which they called &lt;em&gt;gravity location model&lt;/em&gt;, in the book titled: &amp;quot;Supply chain management: strategy, planning, and operation.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;I am in search of a review paper or select papers that formulated FLP over continuous space with &lt;em&gt;multiple&lt;/em&gt; facility selections. Also, the problem was formulated with a nonlinear model in Chopra and Meindl (2013) because they considered Euclidean distance between a demand node and &lt;em&gt;possible&lt;/em&gt; facility coordinates. Have you ever encountered a paper formulating the problem with a linear model? Is this even possible?&lt;/p&gt;&#xA;&lt;p&gt;To better describe the problem, assume there is a polynomially-sized set of demand nodes and we would like to locate facilities to &lt;em&gt;completely&lt;/em&gt; meet the demand while minimizing costs of facilities and services. Each facility has a circular service range, and facility cost is the same across locations. Since facilities are not capacity constrained and there is no incentive of meeting a portion of the demand by another facility, we can assume each demand node will be fully-served by the closest facility, and finding the ramifications is not at interest. We can further assume that the Euclidean distance is the prevailing driver of the service cost calculation.&lt;/p&gt;&#xA;&lt;p&gt;I am also interested in the discretely-spaced facility version of the above described problem. In particular, I am looking for algorithms that can handle covering up to 2 millions of demand nodes in a reasonable amount of computational time, say less than a day. Otherwise, models presented in &lt;a href=&quot;http://daskin.engin.umich.edu/wp-content/uploads/sites/133/2014/07/daskinchapterfinaltrackchangesoffwithfullcitation.pdf&quot; rel=&quot;noreferrer&quot;&gt;Daskin and Dean (2004)&lt;/a&gt; provide a reasonable sketch to build on.&lt;/p&gt;&#xA;" OwnerUserId="518" LastActivityDate="2020-08-21T08:07:39.793" Title="Facility Location Problem over Continuous Space" Tags="|facility-location|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4714" PostTypeId="2" ParentId="4713" CreationDate="2020-08-20T23:36:47.560" Score="7" Body="&lt;p&gt;If I understand correctly, you are given a set of demand nodes, and you want to locate a finite number of facilities, anywhere in the plane, so as to minimize the sum of distances between each demand node and its assigned facility?&lt;/p&gt;&#xA;&lt;p&gt;Beyond the literature on facility location problems, you may find some useful tools in clustering methods (e.g., the K-means algorithm and alikes), as well as Steiner tree problems.&lt;/p&gt;&#xA;&lt;p&gt;The K-means algorithm compute clusters, where each cluster's centroid is located so as to minimize the sum of squared distances to points in the cluster.&#xA;A similar version with non-squared distances is the p-median problem.&#xA;Some column generation-based approaches have been proposed for both, see, e.g., &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-010-0349-7&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The Euclidean Steiner tree problem is not exactly the problem you are mentioning, but there may be some useful modeling tricks from this literature, for instance &lt;a href=&quot;https://link.springer.com/article/10.1007/s00407-013-0127-z&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2020-08-20T23:36:47.560" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4715" PostTypeId="1" AcceptedAnswerId="4716" CreationDate="2020-08-21T01:20:01.107" Score="4" ViewCount="535" Body="&lt;p&gt;I want to develop a model extension of capacitated location problem.&lt;/p&gt;&#xA;&lt;p&gt;The variables are a binary &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and a continuous &lt;span class=&quot;math-container&quot;&gt;$Q_i$&lt;/span&gt;. The following condition must be satisfied:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$x_i = 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Q_i$&lt;/span&gt; must be zero.&lt;/li&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Q_i \geq 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;How do we formulate it in the integer programming formulation?&lt;/p&gt;&#xA;&lt;p&gt;Thank you for your answer.&lt;/p&gt;&#xA;" OwnerUserId="4006" LastEditorUserId="500" LastEditDate="2020-08-21T13:10:56.970" LastActivityDate="2020-08-21T13:10:56.970" Title="Formulating the conditional constraint" Tags="|modeling|integer-programming|logical-constraints|big-m|indicator-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4716" PostTypeId="2" ParentId="4715" CreationDate="2020-08-21T01:23:55.220" Score="6" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; be an upper bound on &lt;span class=&quot;math-container&quot;&gt;$Q_i$&lt;/span&gt;, and impose linear big-M constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$0 \le Q_i \le M_i x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-08-21T01:23:55.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4717" PostTypeId="2" ParentId="4713" CreationDate="2020-08-21T07:58:44.083" Score="4" Body="&lt;p&gt;The type of location problems you are looking for are &lt;em&gt;planar location&lt;/em&gt; problems where the &lt;em&gt;Weber&lt;/em&gt; problem and the &lt;em&gt;multi-Weber&lt;/em&gt; problems are among the most well known (and simplest). &lt;a href=&quot;https://link.springer.com/article/10.1007/BF02060474&quot; rel=&quot;nofollow noreferrer&quot;&gt;Drezner&lt;/a&gt; gives a nice overview of the problem and a solution procedure called &amp;quot;Weizfeld's procedure&amp;quot;. For the multi-Weber problem theres a simple and rather famous heuristic called &amp;quot;&lt;a href=&quot;https://epubs.siam.org/doi/abs/10.1137/1006005?casa_token=LLwNjnTCGEkAAAAA:bc6Fxz_XiN6H26ijTQpM0XFWy0JsJiJn1uUoTQLVp0NChklJy0HioBuzKhEcqDJJ63Q0gRsAPyCG&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cooper's location-allocation heuristic&lt;/a&gt;&amp;quot; (or something along those lines) .&lt;/p&gt;&#xA;&lt;p&gt;I know that you can formulate the multi-Weber problem as both a non-linear mixed integer program and as a difference of convex optimization problem. But you cannot formulate it as a linear program (unless &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P=NP}$&lt;/span&gt;) as it is an &lt;span class=&quot;math-container&quot;&gt;$\mathcal{NP}$&lt;/span&gt;-hard optimization problem.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2020-08-21T08:07:39.793" LastActivityDate="2020-08-21T08:07:39.793" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4718" PostTypeId="2" ParentId="4715" CreationDate="2020-08-21T10:08:10.853" Score="2" Body="&lt;p&gt;I tend to prefer logical constraints to big M unless big M are really needed.&lt;/p&gt;&#xA;&lt;p&gt;In OPL CPLEX we can write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int n=10;&#xA;range r=1..n;&#xA;&#xA;dvar boolean x[r];&#xA;dvar float+ Q[r];&#xA;&#xA;subject to&#xA;{&#xA;  forall(i in r) (x[i]==0) =&amp;gt; (Q[i]==0);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-08-21T10:08:10.853" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4719" PostTypeId="1" CreationDate="2020-08-21T12:06:21.983" Score="2" ViewCount="168" Body="&lt;p&gt;A company should supply 2 products namely A and B. The company can buy A and B in advance or in real-time, however at different prices. The demand is uncertain and prices are considered to be deterministic. Therefore, I developed a stochastic model in which uncertain demand and prices are the input and its revenue for selling the products is the output.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;LA : The price of product A when buying before the delivery time.&#xA;LB : The price of product B when buying before the delivery time.&#xA;&#xA;CA: The price for selling A to the customer&#xA;CB: The price for selling B to the customer&#xA;&#xA;LAA : The price of product A when buying at the delivery time.&#xA;LBB : The price of product B when buying at the delivery time.&#xA;&#xA;R   : Revenue of the company&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now I want to apply a sensitivity analysis based on market prices. My assumption is to gradually increase each price while keeping the others constant and see it's the effect on the revenue. Therefore, I will get 6 tables regarding the relationship between the increase in each price wrt the revenue.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;For example: Let say LA = 30 while R = 50. Thus I change LA to 31 and&#xA;feed it to the model. Let say the R' will be 48. I continue this&#xA;routine until LA = 40. Then I can see the relationship between LA and R&#xA;for a range of prices.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;However, this method only considers the impact of the change in one input variable on the output. Therefore, it doesn't consider the combined variation of inputs (LA, LB). How can I perform a valid sensitivity analysis for this problem where a subset of the inputs are changed while the others are fixed? Moreover, the prices in the model are somehow correlated in reality.&lt;/p&gt;&#xA;" OwnerUserId="3500" LastEditorUserId="123" LastEditDate="2020-09-06T13:13:17.140" LastActivityDate="2020-09-07T07:49:06.003" Title="How to obtain the sensitivity analysis of correlated data?" Tags="|sensitivity-analysis|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4720" PostTypeId="2" ParentId="3282" CreationDate="2020-08-21T20:18:56.210" Score="2" Body="&lt;p&gt;Most Solvers are connected to &lt;code&gt;JuMP.jl&lt;/code&gt; through &lt;code&gt;MathOptInterface.jl&lt;/code&gt; using their respective C APIs. Depending on the solver you trying to connect there is a good chance there is a C API for it. &lt;a href=&quot;https://matbesancon.github.io/post/2019-11-04-binary-julia/&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; article has some great information about connecting a C API to MathOptInterface. I bet if you sent an email to the author, he would respond too.&lt;/p&gt;&#xA;" OwnerUserId="3109" LastEditorUserId="36" LastEditDate="2020-08-22T00:46:02.040" LastActivityDate="2020-08-22T00:46:02.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4721" PostTypeId="2" ParentId="3282" CreationDate="2020-08-22T15:20:31.203" Score="5" Body="&lt;p&gt;The best place to ask (and get answer from the JuMP developers) is &lt;a href=&quot;https://discourse.julialang.org/c/domain/opt/13&quot; rel=&quot;noreferrer&quot;&gt;this Discourse forum&lt;/a&gt;.&#xA;You should provide details such as the class of models that are supported and, ideally, a link to the code itself (or at least its Julia wrapper if applicable).&lt;/p&gt;&#xA;&lt;p&gt;There are also a number of guidelines in the &lt;a href=&quot;https://jump.dev/MathOptInterface.jl/stable/apimanual/#Implementing-a-solver-interface-1&quot; rel=&quot;noreferrer&quot;&gt;MathOptInterface documentation&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;That being said, in a nutshell, the route looks like:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If your solver is not written in Julia, you need to hook it to Julia first.&#xA;The how depends on which language you used.&lt;/li&gt;&#xA;&lt;li&gt;Once you have a Julia interface, you need to implement an interface to &lt;a href=&quot;https://github.com/jump-dev/MathOptInterface.jl&quot; rel=&quot;noreferrer&quot;&gt;MathOptInterface&lt;/a&gt;.&#xA;To do so, you need to identify which functionalities your solver supports (linear? conic? mixed-integer? something else?) and how they are represented in MathOptInterface.&#xA;Looking at other solvers' wrappers (look for a file called &lt;code&gt;MOI_wrapper&lt;/code&gt; in, e.g., &lt;a href=&quot;https://github.com/jump-dev/CPLEX.jl&quot; rel=&quot;noreferrer&quot;&gt;CPLEX.jl&lt;/a&gt;, &lt;a href=&quot;https://github.com/jump-dev/Gurobi.jl&quot; rel=&quot;noreferrer&quot;&gt;Gurobi.jl&lt;/a&gt; or &lt;a href=&quot;https://github.com/jump-dev/Gurobi.jl&quot; rel=&quot;noreferrer&quot;&gt;GLPK.jl&lt;/a&gt;) is  good place to start.&#xA;The MathOptInterface package also provides extensive unit tests to ensure the interface works correctly.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Once your solver is interfaced to MathOptInterface, it can be used in JuMP. There is no additional thing to do.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2020-08-22T15:20:31.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4722" PostTypeId="1" CreationDate="2020-08-23T00:13:49.363" Score="4" ViewCount="267" Body="&lt;p&gt;I want to solve a VRP with a column generation algorithm. The objective of the problem is makespan minimization. but there is a point in calculating the arrival time of the vehicle in each node. the vehicle must be synchronized with another transportation mode like a train whose route is predetermined before solving the abovementioned VRP. the train may pass from some nodes that vehicle will pass and in these nodes, the arrival time is maximum of the arrival time of train and vehicle. I want to know how I should solve the pricing subproblem?&lt;/p&gt;&#xA;" OwnerUserId="3972" LastEditorUserId="3972" LastEditDate="2020-08-23T19:21:35.067" LastActivityDate="2020-08-23T19:21:35.067" Title="Column Generation algorithm" Tags="|mixed-integer-programming|combinatorial-optimization|vehicle-routing|algorithms|column-generation|" AnswerCount="1" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4723" PostTypeId="2" ParentId="4722" CreationDate="2020-08-23T09:12:28.097" Score="6" Body="&lt;p&gt;If I understood your problem correctly, then the only difference with the initial version (without the train) is that the time function is not additive.&lt;/p&gt;&#xA;&lt;p&gt;For example, lets say the train passes through node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at (given) time &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt;, and you are computing a path &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; whose last node is &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. The total accumulated time on this path is denoted by &lt;span class=&quot;math-container&quot;&gt;$\tau_p(i)$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$\Delta t_{ij}$&lt;/span&gt; denotes the time it takes for the vehicle to go from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. If you want to extend the path and add node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, then the total accumulated time for path &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\tau_p$&lt;/span&gt;, is increased as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\tau_p(j) :=  \max\{ t_j, &#xA;\tau_p(i) + \Delta t_{ij}&#xA; \}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the train arrives before the vehicle, then the total accumulated time takes value &lt;span class=&quot;math-container&quot;&gt;$\tau_p(i) + \Delta t_{ij}$&lt;/span&gt;, otherwise, it takes value &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that this is like having time windows on your train nodes, with only a lower bound : you can just add time windows &lt;span class=&quot;math-container&quot;&gt;$[t_j, +\infty[$&lt;/span&gt; on node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and run your shortest path algorithm with time windows (if you have one at hand).&lt;/p&gt;&#xA;&lt;p&gt;In other words the (time) resource extension function is not additive. This is handled for example by &lt;a href=&quot;https://github.com/torressa/cspy&quot; rel=&quot;noreferrer&quot;&gt;cspy&lt;/a&gt;, a great python library which computes shortest paths with resource constraints, where you can enter your own customized resource extension rule (check out the &lt;a href=&quot;https://cspy.readthedocs.io/en/latest/how_to.html#refs&quot; rel=&quot;noreferrer&quot;&gt;docs&lt;/a&gt; where such an example is given). &lt;a href=&quot;https://github.com/Kuifje02/vrpy&quot; rel=&quot;noreferrer&quot;&gt;VRPy&lt;/a&gt;, a VRP python library for the VRP  relies on &lt;em&gt;cspy&lt;/em&gt; to compute its shortest paths for column generation. Since VRPy handles time windows, you have got yourself a good starting point!&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-08-23T13:17:55.143" LastActivityDate="2020-08-23T13:17:55.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4724" PostTypeId="2" ParentId="4663" CreationDate="2020-08-23T20:50:55.287" Score="1" Body="&lt;p&gt;I'll propose an &amp;quot;online&amp;quot; decision process (heuristic), but I don't know if you have the data / forecasting ability to make it work, so I'm not sure it would be helpful.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$C_0$&lt;/span&gt; be the remaining capacity of the slow system when the next job arrives (which you will definitely know), and let &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; be the expected &amp;quot;bad job&amp;quot; cost of the newly arrived job (which I'm assuming you will know once the job arrives). Now, for the tricky part, let &lt;span class=&quot;math-container&quot;&gt;$\Gamma$&lt;/span&gt; be the expected &amp;quot;bad job&amp;quot; cost of the &lt;span class=&quot;math-container&quot;&gt;$C_0 $&lt;/span&gt;th most expensive remaining (yet to arrive) job. If there are not that many jobs left to come, set &lt;span class=&quot;math-container&quot;&gt;$\Gamma = 0$&lt;/span&gt;. For instance, if &lt;span class=&quot;math-container&quot;&gt;$C=6$&lt;/span&gt;, you're being asked to peer into the future and estimate what the fifth worst &amp;quot;bad job&amp;quot; cost out of all remaining jobs might be. (This is known as an order statistic.) You'll need a way to forecast &lt;span class=&quot;math-container&quot;&gt;$\Gamma$&lt;/span&gt;, noting that it depends on both the number of jobs to come and the nature of the jobs.&lt;/p&gt;&#xA;&lt;p&gt;If you can get a figure for &lt;span class=&quot;math-container&quot;&gt;$\Gamma$&lt;/span&gt;, the decision rule is simple. If you route the newly arrived job to the fast process, you incur expected cost &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; (and &lt;span class=&quot;math-container&quot;&gt;$C_0$&lt;/span&gt; remains the capacity left in the slow process). If you route the newly arrived job to the slow process, and charitably assuming you make all remaining decisions optimally, you end up sending the job with expected cost &lt;span class=&quot;math-container&quot;&gt;$\Gamma$&lt;/span&gt; to the fast line (because you don't have capacity for it on the slow line) when, had you sent the current job to the fast line, you would have sent that job to the slow line. So the logic is to use the slow line now if &lt;span class=&quot;math-container&quot;&gt;$\gamma &amp;gt; \Gamma$&lt;/span&gt; and the fast line if &lt;span class=&quot;math-container&quot;&gt;$\gamma &amp;lt; \Gamma$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-08-23T20:50:55.287" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4725" PostTypeId="1" CreationDate="2020-08-24T13:01:51.393" Score="1" ViewCount="74" Body="&lt;p&gt;A customer brought us this problem and we're looking for ideas to help them. It seems to be a flavor of cutting-stock but without the demand profile.&lt;/p&gt;&#xA;&lt;p&gt;They have varied length spools of different types of wire that need to be combined into a cable. For example, 2 spools of red of length 100 and 200, 3 spools of blue of length 80, 100 and 100, and one spool of black of length 250. Cables can be composed of up to 15 wires.&lt;/p&gt;&#xA;&lt;p&gt;They want to make the final cables as long as possible yet minimize the spool ends of the wire. We've been told spool ends are discarded but I expect if the spool end is long enough it's put back into inventory.&lt;/p&gt;&#xA;" OwnerUserId="497" LastActivityDate="2020-08-24T13:01:51.393" Title="How to combine wires into a cable maximizing cable length while minimizing waste?" Tags="|combinatorial-optimization|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4726" PostTypeId="2" ParentId="4657" CreationDate="2020-08-24T19:01:25.730" Score="4" Body="&lt;p&gt;I can think of a couple of ways to reduce the size of the problem, at the risk of producing suboptimal solutions. One, as Daniel Junglas suggested, it to set a nonzero threshold for affinity level, and not include variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; where the affinity of customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; for product &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is below the threshold.&lt;/p&gt;&#xA;&lt;p&gt;Another is to do a cluster analysis of the customers (based on their product affinities), then build product bundles based on the mean / central &amp;quot;customer&amp;quot; of each cluster. That would reduce the 20,000 rows of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; to one row per cluster.&lt;/p&gt;&#xA;&lt;p&gt;You could even combine these, if the number of clusters were too high, by first clustering and then eliminating assignments of product to cluster when the (aggregate) affinity of that cluster for that product was too small.&lt;/p&gt;&#xA;&lt;p&gt;Finally, there was AirSquid's question about handling each customer individually. I did not understand your reply, but I suspect there are some joint constraints (such as supply / inventory of different products) that span customers. If so, you could arbitrarily partition the customers into subsets, arbitrarily partition supplies into the same number of subsets, pair a customer subset with a supply subset and solve those problems separately. In this approach, rather than clustering I would do the opposite: try to partition the customer base into &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; subsets that are each as similar as possible to the overall population of customers. Then divide the resources into &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; more or less identical portions and solve &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; smaller MIPs.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-08-24T19:01:25.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4728" PostTypeId="1" CreationDate="2020-08-24T21:52:25.990" Score="2" ViewCount="80" Body="&lt;p&gt;In my post-graduate research and subsequent career in operational analysis, the difference between following seems to have become clearer with the years: (1) a model of a problem or operations in the real world and (2) implementation of a corresponding analysis tool that applies the model to actual data.&lt;/p&gt;&#xA;&lt;p&gt;Item (1) can take many forms: A collection of inter-related equations, a schematic, and/or a word description.  But one cannot take item (1) and apply it to actual data to get the results.&lt;/p&gt;&#xA;&lt;p&gt;To apply a model to actual data, the model must be realized via item (2), which can take the form of spreadsheets, coding (preferably in a 4th generation language), software whose execution is specified via a graphical schematic language [1], digital circuit/systems modelling environments [2], discrete event simulators, optimization packages, etc.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is there an actual paper, book, or some preferably non-contentious source that describes this distinction?&lt;/strong&gt;  Some of what I've found seem not to distinguish between the two items, preferring instead to distinguish their amalgamation  from &amp;quot;implementation&amp;quot; of recommendations falling out of the analysis. The latter is not what I mean by &amp;quot;implementation&amp;quot; in the context of this question.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;[1]&lt;/strong&gt; Core Sim, G2 ReThink, LabView, etc. &lt;br&gt;&#xA;&lt;strong&gt;[2]&lt;/strong&gt; These may use a combination of schematics and text languages for specifying system behaviour.&lt;/p&gt;&#xA;" OwnerUserId="4015" LastActivityDate="2020-08-24T21:52:25.990" Title="Analysis model vs. executable implementation of model?" Tags="|modeling|terminology|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4729" PostTypeId="1" CreationDate="2020-08-25T13:58:51.423" Score="2" ViewCount="115" Body="&lt;p&gt;I have an Integer Linear Problem which is solved quickly when I change my variable type to double. now I'm developing a fix and relax algorithm and I used conversion to change data type which takes a long time. Does it mean that I made a mistake? how could I reduce the solving time?&lt;/p&gt;&#xA;" OwnerUserId="3857" LastEditorUserId="39" LastEditDate="2020-08-26T17:18:42.740" LastActivityDate="2020-08-26T17:18:42.740" Title="how to convert type of variable in CPLEX" Tags="|cplex|relaxation|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4730" PostTypeId="1" AcceptedAnswerId="4731" CreationDate="2020-08-25T14:33:35.180" Score="3" ViewCount="164" Body="&lt;p&gt;This is related to the foillowing Q on Cross Validated &lt;a href=&quot;https://stats.stackexchange.com/questions/483002/experimental-design-problem-with-goofy-constraints&quot;&gt;https://stats.stackexchange.com/questions/483002/experimental-design-problem-with-goofy-constraints&lt;/a&gt; which I am trying to answer, but the optimization problem needs some other expertize which I hope to find here ... Very brief summary: There is a rectangular matrix &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; with nonnegative numbers (some complications described below) and one want to find some rectangular subarray (not necessarily contiguous) with maximum sum, given an (approximate) size of the subarray. What are some effective algorithms? Please see the linked question for details and background (and, this is my interpretation of that question, I might have misunderstood something.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Complications&lt;/strong&gt;:  Some of the entries of &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; might be undefined, and we know very little about the possible patterns of unefinedness. I have thought that maybe just replace the undefined entries with some large enough negative number, but not sure that is good enough. A solution without considering this complication woud be interesting, but even better some ideas about how handling the complication.&lt;/p&gt;&#xA;" OwnerUserId="166" LastActivityDate="2020-08-25T14:55:42.443" Title="A variant of maximum sum subarray problem?" Tags="|algorithms|knapsack|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4731" PostTypeId="2" ParentId="4730" CreationDate="2020-08-25T14:50:19.457" Score="5" Body="&lt;p&gt;If all &lt;span class=&quot;math-container&quot;&gt;$B_{i,j}$&lt;/span&gt; are known, you can solve the problem via integer linear programming as follows.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; indicate whether entry &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is selected, let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; indicate whether row &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is selected, and let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; indicate whether column &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is selected.  The problem is to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j} B_{i,j} x_{i,j}$&lt;/span&gt; subject to linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{i,j} &amp;amp;\le r_i &amp;amp;&amp;amp;\text{for all $i,j$}\\&#xA;x_{i,j} &amp;amp;\le c_j &amp;amp;&amp;amp;\text{for all $i,j$}\\&#xA;\sum_i r_i &amp;amp;= L \\&#xA;\sum_j c_j &amp;amp;= V&#xA;\end{align}&lt;/span&gt;&#xA;If some &lt;span class=&quot;math-container&quot;&gt;$B_{i,j}$&lt;/span&gt; is unknown, you can fix &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=0$&lt;/span&gt; or omit &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; from the problem.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-08-25T14:55:42.443" LastActivityDate="2020-08-25T14:55:42.443" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="4732" PostTypeId="1" AcceptedAnswerId="4733" CreationDate="2020-08-25T15:38:10.743" Score="3" ViewCount="343" Body="&lt;p&gt;I have a matrix in the size of &lt;span class=&quot;math-container&quot;&gt;$S \in \mathbb{R}^{M\times N}$&lt;/span&gt; with only binary values &lt;span class=&quot;math-container&quot;&gt;$0..1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I want to select &lt;span class=&quot;math-container&quot;&gt;$m&amp;lt;M$&lt;/span&gt; rows from &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; and sum the &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; rows to get a new vector &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I wish &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; to be close to the uniform distribution. Currently, I am thinking of normalizing &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; and maximize the entropy of the &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For example, the matrix &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[[0,1,1,1,0],&#xA;[1,0,0,0,1],&#xA;[1,1,1,1,1],&#xA;[0,1,1,0,0]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I want to select 2 rows from &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. Say I selected first and second rows and the summation of the two rows is:&#xA;&lt;code&gt;[1,1,1,1,1]&lt;/code&gt;. And I normalize &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; into &lt;code&gt;[0.2,0.2,0.2,0.2,0.2]&lt;/code&gt;, which is closest to the uniform distribution compared with other combinations.&lt;/p&gt;&#xA;&lt;p&gt;But I don't know how to formulate this question into the standard mixed-integer linear program form. Thank you if anyone can give some insights.&lt;a href=&quot;https://i.stack.imgur.com/blDhx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/blDhx.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4016" LastActivityDate="2020-08-25T18:57:41.517" Title="How to formulate this problem?" Tags="|mixed-integer-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4733" PostTypeId="2" ParentId="4732" CreationDate="2020-08-25T15:54:07.553" Score="4" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_M$&lt;/span&gt; be binary variables, and let &lt;span class=&quot;math-container&quot;&gt;$y_1,\dots,y_N$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; be general (nonnegative) variables. (They will all turn out to be integers, but you do not need to declare them as integers.) Consider the following constraint set:&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\sum_{i=1}^{M}x_{i} &amp;amp; =m\\&#xA;x^{\prime}S &amp;amp; =y\\&#xA;y_{i} &amp;amp; \ge z\quad\forall i\\&#xA;y_{i} &amp;amp; \le w\quad\forall i.&#xA;\end{align*}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is your row sum, and &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; will be the largest and smallest elements of that sum respectively. One way to achieve what I think you mean by uniformity is to minimize &lt;span class=&quot;math-container&quot;&gt;$w-z$&lt;/span&gt;, packing the row sum elements into the smallest range possible.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-08-25T15:54:07.553" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4734" PostTypeId="2" ParentId="4732" CreationDate="2020-08-25T16:39:20.513" Score="4" Body="&lt;p&gt;Entropy maximization will not result in a MILP. The continuous relaxation is a convex (asymmetric cone) conic optimization problem.&lt;/p&gt;&#xA;&lt;p&gt;Entropy can be maximized, subject to linear and integer constraints (unlike @prubin 's answer, I think you need to declare variables in this problem as binary (integer)) using a convex optimization tool such as CVX, YALMIP, CVXPY, or CVXR. Call and make use of Mosek's mized-integer native exponential cone capability. to solve the problem.&lt;/p&gt;&#xA;&lt;p&gt;You can make use of CVX's &lt;code&gt;entr&lt;/code&gt; function, and similar functions in the other convex optimization tools. If you do not have access to Mosek, but do have access to Gurobi, you can install CVXQUAD under CVX, including its &lt;code&gt;exponential.m&lt;/code&gt; replacement, and call Gurobi to solve an MISOCP produced from CVXQUAD generating 2 by 2 LMIs which CVX converts to SOCP constraints before passing them on to the solver. See &lt;a href=&quot;http://ask.cvxr.com/t/cvxquad-how-to-use-cvxquads-pade-approximant-instead-of-cvxs-unreliable-successive-approximation-for-gp-mode-log-exp-entr-rel-entr-kl-div-log-det-det-rootn-exponential-cone-cvxquads-quantum-matrix-entropy-matrix-log-related-functions/5598&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://ask.cvxr.com/t/cvxquad-how-to-use-cvxquads-pade-approximant-instead-of-cvxs-unreliable-successive-approximation-for-gp-mode-log-exp-entr-rel-entr-kl-div-log-det-det-rootn-exponential-cone-cvxquads-quantum-matrix-entropy-matrix-log-related-functions/5598&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-08-25T18:57:41.517" LastActivityDate="2020-08-25T18:57:41.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4735" PostTypeId="1" CreationDate="2020-08-26T09:20:34.487" Score="5" ViewCount="378" Body="&lt;p&gt;I was hoping to get some help in modelling the following logic as an MIP Constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VnkhE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VnkhE.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;c_{m,l}^{RC} is binary decision variable.&#xA;Simplify it：&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Fv1nQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Fv1nQ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4020" LastEditorUserId="4020" LastEditDate="2020-09-03T01:56:31.263" LastActivityDate="2020-09-03T02:05:40.873" Title="how to apply Big M to model the logic constraint （if-then-else）" Tags="|optimization|logical-constraints|big-m|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4736" PostTypeId="1" CreationDate="2020-08-26T10:15:40.467" Score="5" ViewCount="914" Body="&lt;p&gt;I want to use column generation technique to solve cutting stock problem.&#xA;Is there any other python modeling library that supports column generation?&lt;/p&gt;&#xA;" OwnerUserId="2326" LastActivityDate="2020-08-26T10:43:39.610" Title="Does pyomo support column generation?" Tags="|python|pyomo|column-generation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4737" PostTypeId="2" ParentId="4736" CreationDate="2020-08-26T10:43:39.610" Score="5" Body="&lt;p&gt;You can do this with PuLP. A column wise formulation for the cutting stock problem is given in the &lt;a href=&quot;https://github.com/coin-or/pulp/blob/master/examples/CGcolumnwise.py&quot; rel=&quot;noreferrer&quot;&gt;examples&lt;/a&gt;. So you don't have much to do...&lt;/p&gt;&#xA;&lt;p&gt;However, it would be interesting to see how PuLp compares with Pyomo.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-08-26T10:43:39.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4738" PostTypeId="1" AcceptedAnswerId="4802" CreationDate="2020-08-26T15:31:40.270" Score="4" ViewCount="189" Body="&lt;p&gt;I'm trying to solve the following optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \min_{x, \phi} x \quad \text{s.t.} \quad  \sum_{s,t = 1}^n \left(m_{s,t} x -v_{s,t} \right)\phi_s \phi_t = 0 , \quad \lVert \phi \rVert = 1$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is scalar and &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; is in the unit sphere on &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;After defining some slack variables &lt;span class=&quot;math-container&quot;&gt;$r_{s,t} = m_{s,t} x -v_{s,t}$&lt;/span&gt;, I can rewrite the first constraint as &lt;span class=&quot;math-container&quot;&gt;$\phi'R\phi = 0$&lt;/span&gt;, where we are optimizing over both &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt;. This version of the problem looks potentially standard. If it is, I would appreciate it if anyone could point me to good references.&lt;/p&gt;&#xA;&lt;p&gt;The problem also looks closely related to robust least squares, but I haven't quite managed to make the connection work.&lt;/p&gt;&#xA;&lt;p&gt;Would also appreciate perspectives on whether I should just throw the problem into a nonlinear optimizer and not worry too much.&lt;/p&gt;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="4021" LastEditorUserId="123" LastEditDate="2020-08-26T15:48:30.427" LastActivityDate="2020-09-07T20:12:48.793" Title="Constraint $x'Ax = 0$, where $x$ and $A$ are both optimization variables" Tags="|optimization|nonlinear-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4739" PostTypeId="2" ParentId="4738" CreationDate="2020-08-26T18:52:18.927" Score="3" Body="&lt;p&gt;A first option would be to write the problem as a (non-convex) QCQP and feed that to, e.g., Gurobi.&#xA;To obtain a QCQP formulation, create a variable &lt;span class=&quot;math-container&quot;&gt;$z_{s, t} = \phi_{s} \phi_{t}$&lt;/span&gt; and re-write the constraint with &lt;span class=&quot;math-container&quot;&gt;$z_{s, t}$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; (so all the terms are quadratic).&lt;/p&gt;&#xA;&lt;p&gt;However, since you are minimizing &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, you can try a bisection approach.&#xA;For given &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, you are solving a feasibility problem with quadratic terms which, once again, you can feed to a non-convex solver.&#xA;There may be a more efficient approach using clever linear algebra, since the problem essentially asks whether there exists &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\phi^{T}R(x)\phi = 0$&lt;/span&gt; (and &lt;span class=&quot;math-container&quot;&gt;$R(x)$&lt;/span&gt; is a constant when &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is fixed).&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2020-08-26T18:52:18.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4740" PostTypeId="1" AcceptedAnswerId="4741" CreationDate="2020-08-26T23:21:07.993" Score="14" ViewCount="1014" Body="&lt;p&gt;I have a question on Benders Decomposition (BD). Suppose I have an MILP model which can be decomposed into a master problem (MP) including integer and continuous variables and a subproblem (SP) including only integer variables. In addition, suppose that the SP generated does not hold any nice property like total unimodularity meaning that the relaxation does not do any good for me. In this case, I cannot utilize the duality theorem to generate a Benders cut.&lt;/p&gt;&#xA;&lt;p&gt;I am familiar with Logic-Based BD (LBBD). Yet, in all the studies that I have seen using LBBD, SP becomes a feasibility problem without an objective function, which is solved by constraint programming (CP).&lt;/p&gt;&#xA;&lt;p&gt;Now, let's further assume that the SP has a solid objective function. I was wondering if there are recent studies containing LBBD where SP is an IP with an objective function and is not solved with CP. If not,  what are some viable approaches to tackle such problem settings?&lt;/p&gt;&#xA;" OwnerUserId="4025" LastEditorUserId="869" LastEditDate="2020-09-23T12:53:59.533" LastActivityDate="2022-06-18T09:35:39.017" Title="How to handle an IP sub-problem with an objective function in Benders Decomposition" Tags="|optimization|mixed-integer-programming|reference-request|benders-decomposition|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4741" PostTypeId="2" ParentId="4740" CreationDate="2020-08-27T08:47:13.710" Score="6" Body="&lt;p&gt;I was researching the topic with mixed-integer subproblems in the context of two-stage stochastic programs, but got stuck and haven't revisited. In the mixed-integer case, there has been some progress recently, maybe you can apply some of the findings to your problem.&#xA;Some promising recent studies and some additional pointers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Rahmaniani, R., Ahmed, S., Crainic, T. G., Gendreau, M., &amp;amp; Rei, W. (2020). The benders dual decomposition method. Operations Research.&lt;/li&gt;&#xA;&lt;li&gt;Zou, J., Ahmed, S., &amp;amp; Sun, X. A. (2019). Stochastic dual dynamic integer programming. Mathematical Programming, 175(1-2), 461-502.&lt;/li&gt;&#xA;&lt;li&gt;Li, C., &amp;amp; Grossmann, I. E. (2019). A generalized Benders decomposition-based branch and cut algorithm for two-stage stochastic programs with nonconvex constraints and mixed-binary first and second stage variables. Journal of Global Optimization, 75(2), 247-272.&lt;/li&gt;&#xA;&lt;li&gt;Kim, K., &amp;amp; Zavala, V. M. (2018). Algorithmic innovations and software for the dual decomposition method applied to stochastic mixed-integer programs. Mathematical Programming Computation, 10(2), 225-266.&lt;/li&gt;&#xA;&lt;li&gt;The last paragraph of Section 3.2 offers references for pure integer subproblems (mostly LBBD) and mixed-integer subproblems, and conditions for the validity of cuts.&#xA;Ahmed, S. (2010). Two‐Stage Stochastic Integer Programming: A Brief Introduction. Wiley Encyclopedia of Operations Research and Management Science.&lt;/li&gt;&#xA;&lt;li&gt;Zheng, Q. P., Wang, J., Pardalos, P. M., &amp;amp; Guan, Y. (2013). A decomposition approach to the two-stage stochastic unit commitment problem. Annals of Operations Research, 210(1), 387-410.&lt;/li&gt;&#xA;&lt;li&gt;van der Laan, N., &amp;amp; Romeijnders, W. (2020). A Converging Benders’ Decomposition Algorithm for Two-stage Mixed-integer Recourse Models.&lt;/li&gt;&#xA;&lt;li&gt;van der Laan, N., &amp;amp; Romeijnders, W. (2021). A loose Benders decomposition algorithm for approximating two-stage mixed-integer recourse models. Mathematical Programming, 190(1), 761-794. (approximate method)&lt;/li&gt;&#xA;&lt;li&gt;Chen, R., &amp;amp; Luedtke, J. (2022). On generating Lagrangian cuts for two-stage stochastic integer programs. INFORMS Journal on Computing.&lt;/li&gt;&#xA;&lt;li&gt;Dumouchelle, J., Patel, R., Khalil, E. B., &amp;amp; Bodur, M. (2022). Neur2SP: Neural Two-Stage Stochastic Programming. arXiv preprint arXiv:2205.12006. (heuristic)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Consider that decomposition methods might not be faster than commercial solvers, depending on the sophistication of the decomposition approach. See&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bonami, P., Salvagnin, D., &amp;amp; Tramontani, A. (2020). Implementing Automatic Benders Decomposition in a Modern MIP Solver. In International Conference on Integer Programming and Combinatorial Optimization (pp. 78-90). Springer, Cham.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="869" LastEditorUserId="869" LastEditDate="2022-06-18T09:35:39.017" LastActivityDate="2022-06-18T09:35:39.017" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4742" PostTypeId="2" ParentId="4740" CreationDate="2020-08-27T09:20:13.020" Score="10" Body="&lt;p&gt;It is possible to have an integer subproblem with an objective, but to solve such a problem you need to branch on variables both in the master problem and in the sub-problem. This is not supported by off-the-shelf solvers, so it requires quite some coding to make this work (fast).&lt;/p&gt;&#xA;&lt;p&gt;A recent example of a paper using this method is &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/trsc.2019.0892&quot; rel=&quot;nofollow noreferrer&quot;&gt;Zeighami and Soumis (2019)&lt;/a&gt;, who base their work on &lt;a href=&quot;https://doi.org/10.1287/trsc.35.4.375.10432&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cordeau et al. (2001)&lt;/a&gt;. The authors use Benders to tackle simultaneous crew pairing and crew assignment. In their approach, they put the crew scheduling part, which is an integer programming problem, in the subproblem. They solve the problem using branch-and-price-and-cut, branching both on variables in the master and in the subproblem.&lt;/p&gt;&#xA;" OwnerUserId="764" LastEditorUserId="764" LastEditDate="2020-09-08T08:00:24.253" LastActivityDate="2020-09-08T08:00:24.253" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4743" PostTypeId="2" ParentId="3282" CreationDate="2020-08-27T09:23:44.933" Score="1" Body="&lt;p&gt;JuMP also supports ASL interfaces, you can find detailed instructions on how to connect a solver with an ASL interface &lt;a href=&quot;https://github.com/JuliaOpt/CoinOptServices.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-08-27T09:23:44.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4744" PostTypeId="1" CreationDate="2020-08-27T18:16:23.517" Score="6" ViewCount="138" Body="&lt;p&gt;&lt;strong&gt;(For people who don't know what RLT is)&lt;/strong&gt;: I am maximizing an indefinite quadratic function over a standard simplex, i.e., &lt;em&gt;the standard quadratic optimization problem.&lt;/em&gt; A well-known approach is to relax the problem by convexifying the objective function, i.e., instead of &lt;span class=&quot;math-container&quot;&gt;$\max \sum_{i} \sum_{j} P_{ij} x_i x_j$&lt;/span&gt; for some symmetric &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; we maximize the linear function &lt;span class=&quot;math-container&quot;&gt;$\max \sum_{i} \sum_{j} P_{ij} X_{ij}$&lt;/span&gt; for some symmetric matrix variable &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; (assumption is &lt;span class=&quot;math-container&quot;&gt;$X = xx^\top$&lt;/span&gt;, although we cannot constrain this, so the relaxation follows as we are not imposing such strict equality). We also take each constraint &lt;span class=&quot;math-container&quot;&gt;$a_i^\top x - b_i \leq 0$&lt;/span&gt;, multiply with each other, add the constraint &lt;span class=&quot;math-container&quot;&gt;$(a_i^\top x - b_i) (a_j^\top x - b_j) \geq 0 $&lt;/span&gt; and replace every &lt;span class=&quot;math-container&quot;&gt;$x_i x_j$&lt;/span&gt; term with &lt;span class=&quot;math-container&quot;&gt;$X_{ij}$&lt;/span&gt;. This is the RLT relaxation. If we also add the SDP constraint &lt;span class=&quot;math-container&quot;&gt;$X - xx \succeq 0$&lt;/span&gt;, this tightens the relaxation. Let's call this method the RLT/SDP approximation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;(Question for the people who already know RLT):&lt;/strong&gt; I made numerical experiments, where I generate a symmetric matrix &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; randomly, and then apply RLT/SDP relaxation. The results are crazy-good, almost all of the time I get globally optimum upper bounds (and when I plug the optimized &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, it also gives amazing lower bounds). I am now thinking, every beautiful thing has an ugly truth as well. Can you please let me know an adversarial way to design a &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;, such that the RLT/SDP relaxation is not that good?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;(Matlab Code Below -- uses YALMIP, CPLEX, and MOSEK):&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;P = rand(20); P = P - tril(P,-1) + triu(P,1)'; %generate random symmetric matrix (change 20 to any number)&#xA;n = size(P,1);&#xA;%CPLEX GLOBAL OPTIM BELOW&#xA;x = sdpvar(n,1);&#xA;obj = x'*P*x;&#xA;constraints = [x &amp;gt;= 0, sum(x) == 1];&#xA;sol = optimize(constraints, -obj, sdpsettings('solver', 'cplex', 'cplex.optimalitytarget',3));&#xA;value(obj); %global optimum value&#xA;%RLT RELAXATION BELOW!&#xA;X = sdpvar(n); %matrix variable&#xA;x = sdpvar(n,1); %original variable&#xA;obj2 = P(:)'*X(:); %RLT objective&#xA;constraints2 = [x&amp;gt;=0, sum(x) == 1, sum(X,2) == x, X(:) &amp;gt;= 0, [X, x; x', 1] &amp;gt;= 0]; %RLT/SDP system&#xA;sol2 = optimize(constraints2, -obj2, sdpsettings('solver', 'mosek')); %optimize&#xA;value(obj2) %wow!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="65" LastActivityDate="2020-08-27T18:16:23.517" Title="Cases where RLT/SDP relaxation does not work well with standard quadratic optimization" Tags="|quadratic-programming|nonconvex-programming|mosek|yalmip|reformulation-linearization|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="4745" PostTypeId="1" AcceptedAnswerId="4748" CreationDate="2020-08-27T18:37:48.370" Score="5" ViewCount="393" Body="&lt;p&gt;Is there any way to install and use commercial solvers (for which I have a license) on some virtual machines?&lt;/p&gt;&#xA;&lt;p&gt;For example, if it's possible to install the Octeract engine student version on a google engine virtual machine? Or use Gurobi on a VM?&lt;/p&gt;&#xA;&lt;p&gt;A VM with 624 GB memory and 96 vCPU(which is a possible VM), I think (and I am curious to try) can effectively solve large problems with a great improvement in solving time.&lt;/p&gt;&#xA;&lt;p&gt;If it's not, what is the drawback of having this option?&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-08-28T13:17:39.800" Title="How to use solvers with virtual machines?" Tags="|solver|parallel-computing|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4746" PostTypeId="1" AcceptedAnswerId="4750" CreationDate="2020-08-28T04:57:38.343" Score="7" ViewCount="287" Body="&lt;p&gt;I'm trying to construct a strong MIP formulation for the following integer nonlinear feasibility problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Informally:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We have a &lt;span class=&quot;math-container&quot;&gt;$m \times n$&lt;/span&gt; decision matrix of binary variables&lt;/li&gt;&#xA;&lt;li&gt;Each row of the matrix has to sum to &lt;span class=&quot;math-container&quot;&gt;$2 \leq p \leq n$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Each row is associated with a set of other rows (this association is symmetric) such that for every pair of such rows, exactly &lt;span class=&quot;math-container&quot;&gt;$n-2$&lt;/span&gt; of the variables take the same value&lt;/li&gt;&#xA;&lt;li&gt;Each row is associated with another set of other rows (this association is also symmetric) such that for every pair of such rows, at most &lt;span class=&quot;math-container&quot;&gt;$n-4$&lt;/span&gt; of the variables take the same value.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Formally:&lt;/strong&gt; we are given natural numbers &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$2 \leq p \leq n$&lt;/span&gt; and set-valued mappings &lt;span class=&quot;math-container&quot;&gt;$\mathcal{I}, \mathcal{K}:\{1,2,\dots,m\} \rightrightarrows \{1,2,\dots,m\}$&lt;/span&gt; such that the mappings are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Not reflexive: &lt;span class=&quot;math-container&quot;&gt;$i \not\in \mathcal{I}(i)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i \not\in \mathcal{K}(i)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall i \in \{1,\dots,m\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Symmetric: &lt;span class=&quot;math-container&quot;&gt;$k \in \mathcal{I}(i) \implies i \in \mathcal{I}(k)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k \in \mathcal{K}(i) \implies i \in \mathcal{K}(k)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Of equal cardinality: &lt;span class=&quot;math-container&quot;&gt;$\lvert \mathcal{I}(i) \rvert = \lvert \mathcal{I}(k) \rvert$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lvert \mathcal{K}(i) \rvert = \lvert \mathcal{K}(k) \rvert$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall i, k \in \{1,\cdots,m\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Exclusive: &lt;span class=&quot;math-container&quot;&gt;$k \in \mathcal{I}(i) \implies k \not\in \mathcal{K}(i)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k \in \mathcal{K}(i) \implies k \not\in \mathcal{I}(i)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;We are required to find a decision &lt;span class=&quot;math-container&quot;&gt;$x \in \{0,1\}^{m \times n}$&lt;/span&gt; such that:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\sum_{j=1}^{n} x_{ij} &amp;amp;= p, \quad \forall i \in \{1,\dots,m\}, \\&#xA;\sum_{j=1}^{n} \lvert x_{ij} - x_{kj} \rvert &amp;amp;= 2, \quad \forall i \in \{1,\dots,m\} \: \text{and} \: k \in \mathcal{I}(i), \\&#xA;\sum_{j=1}^{n} \lvert x_{ij} - x_{kj} \rvert &amp;amp;\geq 4, \quad \forall i \in \{1,\dots,m\} \: \text{and} \: k \in \mathcal{K}(i).&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am interested in solving instances with &lt;span class=&quot;math-container&quot;&gt;$m \approx 250$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$n \approx 500$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p \approx 100$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\lvert \mathcal{I}(i) \rvert \approx 10$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\lvert \mathcal{K}(i) \rvert \approx 50$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My current approach is to reformulate each individual absolute value term using MIP. For instance, to model &lt;span class=&quot;math-container&quot;&gt;$\lvert x_{ij} - x_{kj} \rvert$&lt;/span&gt;, I use the auxiliary variables and equations&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;u_{ikj} &amp;amp;= v_{ikj} + w_{ikj}, \\&#xA;x_{ij} - x_{kj} &amp;amp;= v_{ikj} - w_{ikj}, \\&#xA;v_{ikj} &amp;amp;\leq z_{ikj}, \\&#xA;w_{ikj} &amp;amp;\leq 1 - z_{ikj}, \\&#xA;v_{ikj}, &amp;amp;w_{ikj} \geq 0, u_{ikj}, z_{ikj} \in \{0,1\},&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and replace the second and third set of constraints in the original problem with&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\sum_{j=1}^{n} u_{ikj} &amp;amp;= 2, \quad \forall i \in \{1,\dots,m\} \text{ and } k \in \mathcal{I}(i), \\ &#xA;\sum_{j=1}^{n} u_{ikj} &amp;amp;\geq 4, \quad \forall i \in \{1,\dots,m\} \text{ and } k \in \mathcal{K}(i).&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I've also tried to use a cutting-plane approach to solve this problem by iteratively adding violated second and third sets of constraints. These approaches, however, do not scale to the dimensions I want and I'm wondering if there is a stronger MIP formulation for this feasibility problem.&lt;/p&gt;&#xA;" OwnerUserId="468" LastEditorUserId="468" LastEditDate="2020-08-28T16:25:02.627" LastActivityDate="2020-08-28T16:25:02.627" Title="Strong MIP formulations for a large-scale mixed-integer nonlinear feasibility problem" Tags="|mixed-integer-programming|modeling|integer-programming|linearization|combinatorial-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4747" PostTypeId="2" ParentId="4745" CreationDate="2020-08-28T09:45:12.003" Score="3" Body="&lt;p&gt;SAS solvers are part of the SAS Viya cloud platform and thus can be run in containers and virtual machines. The same is probably true for most commercial solvers.&lt;/p&gt;&#xA;&lt;p&gt;But the benefits might be not as great as you think. While a lot of memory certainly does not hurt and might be needed for some problem instances, the gain from hundreds of CPUs is probably minimal.&lt;/p&gt;&#xA;&lt;p&gt;Common wisdom is that improvements in the modeling of an instance and to the core algorithms of a solver typically outweigh more computing power by a significant amount.&lt;/p&gt;&#xA;&lt;p&gt;Virtualization has some drawbacks as well. A solver might not get all resources in a shared environment. Some cloud platforms don't like processes who take up a lot of memory or CPU cycles and might police them (the amount of computation an MILP solver does might look a lot like a process in an endless loop from the outside).&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2020-08-28T09:45:12.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4748" PostTypeId="2" ParentId="4745" CreationDate="2020-08-28T12:43:31.350" Score="5" Body="&lt;p&gt;(Full disclosure: I founded Octeract)&lt;/p&gt;&#xA;&lt;p&gt;So, a few things here:&lt;/p&gt;&#xA;&lt;h2&gt;In practice&lt;/h2&gt;&#xA;&lt;p&gt;Technologically speaking, of course you can (that's the point of a VM), unless a solver is using anti-virtualisation technology, and assuming your hardware supports virtualisation. However, some solver licences tend to be tied to a specific machine/user, so you will need to read the solver's licence carefully to make sure you are not violating the terms of the licence.&lt;/p&gt;&#xA;&lt;h2&gt;Octeract Engine student licence&lt;/h2&gt;&#xA;&lt;p&gt;I can't really comment on other solvers, but for the Octeract Engine student licence you can currently place it and use it on a VM as much as you want, as long as it's you using it on your designated university machine. The only practical restriction of the licence is that you can't use it on a university's cloud. We don't really see this as restrictive, as the student licence supports up to 16 CPUs anyway (see below).&lt;/p&gt;&#xA;&lt;h2&gt;Number of cores supported by the licence&lt;/h2&gt;&#xA;&lt;p&gt;Getting a beefy machine can only help so much, as the student version is up to 16 cores. This is a hard-coded limit that you can't get around, which is true of all multi-core solvers. For high-performance calculations we have &lt;a href=&quot;https://octeract.com/octeract-licences/&quot; rel=&quot;noreferrer&quot;&gt;academic cluster &amp;amp; supercomputing licences&lt;/a&gt; for 96+ CPUs which are commercial. We give pretty lengthy trials though, so simply apply for an &lt;a href=&quot;https://octeract.com/request-trial/&quot; rel=&quot;noreferrer&quot;&gt;Academic Cluster trial licence&lt;/a&gt; and we'll sort you out.&lt;/p&gt;&#xA;&lt;h2&gt;Performance&lt;/h2&gt;&#xA;&lt;p&gt;Again, I can't comment on other solvers, but since people mentioned performance this is an interesting one. Octeract Engine is a native supercomputing solver - it uses MPI even on one machine, and it will usually work out of the box on an HPC/AWS cluster (unless we need to resolve any funky cluster settings with the university's IT), even for 10,000 cores. What I can say, is that it is the only commercial MINLP solver I know of that natively supports supercomputing. It is installed in a bunch of supercomputers across the world, and we've observed that performance scales linearly with the number of cores, which you can't normally get with a traditional solver. If you are curious, you can see some parallel &lt;a href=&quot;https://octeract.com/benchmarks/&quot; rel=&quot;noreferrer&quot;&gt;scaling benchmarks&lt;/a&gt; using 170 cores on our website (benchmarks on more cores coming soon!).&lt;/p&gt;&#xA;&lt;h2&gt;Virtualisation&lt;/h2&gt;&#xA;&lt;p&gt;The vast majority of solvers are either serial or multithreaded, which means their limit is one machine. This might be the reason you are tempted to build a large VM (I assume you want to build a multi-machine VM), as that could bypass the single machine limitations. However, for most solvers you will not get much out of it because their algorithms are not designed for that level of parallelisation. With Octeract Engine that's not an issue, but you also don't need a VM, a simple cluster will work just fine. One reason why you might not want to use a VM though is that virtualisation can come with considerable overhead, depending on the hardware and the virtualisation software used. One exception here is AWS/Docker VMs. We have tested Octeract Engine on both, and we haven't noticed any performance drops.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-08-28T13:17:39.800" LastActivityDate="2020-08-28T13:17:39.800" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4749" PostTypeId="2" ParentId="4745" CreationDate="2020-08-28T13:02:36.270" Score="5" Body="&lt;p&gt;It depends on the solver and on the license type, but generally it is possible and you should reach out to the software provider directly to get more information.&lt;/p&gt;&#xA;&lt;p&gt;Most solvers (I have seen this with Gurobi, Cplex, FICO Xpress) can be bought with different licensing options:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;licenses for dedicated machines&lt;/li&gt;&#xA;&lt;li&gt;single user license (which includes student licenses)&lt;/li&gt;&#xA;&lt;li&gt;floating user licenses (allow the concurrent use of a restricted number of licenses by one or multiple users on one or multiple machines)&lt;/li&gt;&#xA;&lt;li&gt;ISV (integrated software vendor) licences or ESA (Embedded solution agreement)&lt;/li&gt;&#xA;&lt;li&gt;customized license agreements&lt;/li&gt;&#xA;&lt;li&gt;pay-per-use licenses (Gurobi Cloud, Docloud)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;These licenses are for different use cases and are priced very differently.&lt;/p&gt;&#xA;&lt;p&gt;For example a license for a dedicated machine is priced based on the number of cores, memory, and maybe some additional hardware specific details. If you want to transfer this type of license to a different machine, you can normally not just deinstall it on one machine and move it to a second machine.&lt;/p&gt;&#xA;&lt;p&gt;Licenses for dedicated machines and single user licenses are normally not suited to be installed on a VM, but in my experience, there is no problem with floating user licenses and with ISV/ESA licenses, you can run those in VMs or even docker containers.&lt;/p&gt;&#xA;&lt;p&gt;Student licenses are a special case of single user licenses, so they are not made to be installed on VMs. But I think if you have a compelling use case, it should be possible to reach out to the software provider and get a license that you can use on a VM, or maybe you are able to obtain such a license directly through your university.&lt;/p&gt;&#xA;" OwnerUserId="4030" LastActivityDate="2020-08-28T13:02:36.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4750" PostTypeId="2" ParentId="4746" CreationDate="2020-08-28T13:05:59.617" Score="8" Body="&lt;p&gt;You can omit &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and instead directly link &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;-(1 - u_{ikj}) \le x_{ij} + x_{kj} - 1 &amp;amp;\le 1 - u_{ikj} \tag1 \\&#xA;-u_{ikj} \le x_{ij} - x_{kj} &amp;amp;\le u_{ikj} \tag2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$u_{ikj} = 1 \implies x_{ij} + x_{kj} = 1$&lt;/span&gt; (equivalently, &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \ne x_{kj}$&lt;/span&gt;).&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$u_{ikj} = 0 \implies x_{ij} = x_{kj}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-08-28T13:11:04.447" LastActivityDate="2020-08-28T13:11:04.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4751" PostTypeId="1" CreationDate="2020-08-28T14:50:48.413" Score="6" ViewCount="223" Body="&lt;p&gt;I'm using Pyomo to formulate an LP with approx 500,000 constraints and 200,000 decision variables. The LP is solved using CLP. Some instances fail to return even a feasible solution after many iterations (in the range 300,000-700,000).&#xA;It's not hard for me to find a basic feasible solution, which would likely help the solver with solving the instances.&lt;/p&gt;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can I provide an initial solution to CLP to skip Phase 1 of the LP-solve (ideally from Pyomo)? If so, how?&lt;/li&gt;&#xA;&lt;li&gt;Are there other ways for me to explore to improve LP solving performance? The high iteration count is likely either due to degenerate constraints or numerical instability for some specific instances (see Klotz and Newman (2013) &lt;em&gt;Practical Guidelines for Solving Difficult Linear Programs&lt;/em&gt;). I was unable to identify degenerate constraints in my formulation and have tried to limit the span of order of magnitudes in the parameters of the model. Are there any other approaches that have proved fruitful for you in similar situations?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3898" LastActivityDate="2020-08-28T14:50:48.413" Title="Provide basic solution to CLP" Tags="|linear-programming|pyomo|simplex|cbc|numerical-issues|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4752" PostTypeId="1" CreationDate="2020-08-29T00:22:12.917" Score="4" ViewCount="221" Body="&lt;p&gt;I wonder if there is an option in the knapsack problem which has a huge cost for 'out-of-capacity' instead of strictly limiting the constraint.&lt;/p&gt;&#xA;" OwnerUserId="4029" LastActivityDate="2020-08-29T21:05:38.453" Title="Is there a knapsack problem which allows 'out-of-capacity'?" Tags="|knapsack|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4753" PostTypeId="1" CreationDate="2020-08-29T04:57:20.647" Score="5" ViewCount="88" Body="&lt;p&gt;I have a scheduling model formulation ( experimental setup) that takes in product states as input (sample points) and checks the model status (response) and returns feasible or infeasible.&lt;/p&gt;&#xA;&lt;p&gt;My plan is to be able to represent the feasible space of the facility with an algebraic predictor and for this, I need to sample effectively. This is basically how I thought of the problem:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Started with an Initial LHS sample for the whole input space generated 200 samples&lt;/li&gt;&#xA;&lt;li&gt;For each sample check if the model is feasible(-1) or infeasible (1).&lt;/li&gt;&#xA;&lt;li&gt;With that, we have an initial dataset&lt;/li&gt;&#xA;&lt;li&gt;Initiate an adaptive sampling procedure to generate more relevant points.&lt;/li&gt;&#xA;&lt;li&gt;Do this until we have a total of 1000 dataset (inputs and responses)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Here is my main problem: the responses are discrete, because of this I find it hard to perform the usual adaptive sampling procedure because they are all suited for cases where the response is continuous.&lt;/p&gt;&#xA;&lt;p&gt;Are their ways to do adaptive sampling for cases where the response is binary?&#xA;Also, are their ways to better approach the problem, such that the infeasibilities are described by continuous functions?&lt;/p&gt;&#xA;" OwnerUserId="4032" LastActivityDate="2020-08-29T04:57:20.647" Title="Quantifying Feasibility" Tags="|scheduling|machine-learning|gams|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4754" PostTypeId="2" ParentId="4752" CreationDate="2020-08-29T07:51:07.193" Score="6" Body="&lt;p&gt;If &amp;quot;out of capacity&amp;quot; means &amp;quot;if you violate capacity, you get infinite capacity for a large cost&amp;quot; the problem reduces to solving a knapsack problem and checking if the profit of this is higher than all positive profits summed minus the large cost.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2020-08-29T07:51:07.193" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4755" PostTypeId="2" ParentId="4752" CreationDate="2020-08-29T12:25:13.423" Score="4" Body="&lt;p&gt;You can introduce a nonnegative surplus variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; with large cost &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; and maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_j v_j x_j-M y$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\sum_j w_j x_j \le W+y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, if you want to impose a one-time fixed cost &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; if there is any violation, let &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; be binary and change the constraint to &lt;span class=&quot;math-container&quot;&gt;$\sum_j w_j x_j \le W+Uy$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; is some upper bound.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-08-29T14:58:41.180" LastActivityDate="2020-08-29T14:58:41.180" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4756" PostTypeId="2" ParentId="4752" CreationDate="2020-08-29T21:05:38.453" Score="1" Body="&lt;p&gt;If the intent is a per unit penalty, rather than a fixed penalty for violation regardless of the size of the violation, you can switch to a generalized assignment problem with three destinations. The first destination is the original knapsack, with its original capacity. The second destination is an &amp;quot;overflow knapsack&amp;quot; with a sufficiently large capacity. The third destination is &amp;quot;do not take&amp;quot;, again with large capacity. The objective coefficient of an assignment to the original knapsack is unchanged. The objective coefficient of assignment to the overflow knapsack is the original coefficient for that critter minus a penalty. The objective coefficient for assignment to the do not take&amp;quot; destination is zero.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-08-29T21:05:38.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4757" PostTypeId="1" AcceptedAnswerId="4764" CreationDate="2020-08-30T23:43:02.030" Score="5" ViewCount="173" Body="&lt;p&gt;I look for an undergraduate-level textbook on procurement and supply management that is largely organized around (reasonably simple) mathematical models. The texts I have reviewed so far are all description/discussion-based, with minimal to no mathematical content.&lt;/p&gt;&#xA;&lt;p&gt;To illustrate the idea, the type of text I have in mind would be similar to Cachon/Terwiesch, &lt;em&gt;Operations Management&lt;/em&gt; (the undergraduate book), in the level of math, but covers more procurement and supply management topics, e.g., strategic sourcing, supplier selection, and supplier development. That said, any relevant recommendation are appreciated.&lt;/p&gt;&#xA;" OwnerUserId="28" LastEditorUserId="28" LastEditDate="2020-08-31T15:25:01.127" LastActivityDate="2020-09-01T21:06:04.613" Title="Procurement and supply management: model-oriented undergradute textbook" Tags="|reference-request|books|supply-chain|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4758" PostTypeId="1" AcceptedAnswerId="4765" CreationDate="2020-08-31T05:57:22.213" Score="4" ViewCount="106" Body="&lt;p&gt;I would like to compare the performance of various scenario generation algorithms.&lt;/p&gt;&#xA;&lt;p&gt;What are the metrics for comparing the performance of these algorithms?&lt;/p&gt;&#xA;" OwnerUserId="4037" LastEditorUserId="491" LastEditDate="2021-05-11T21:06:22.457" LastActivityDate="2021-05-11T21:06:22.457" Title="How to evaluate the performance of scenario generation algorithms?" Tags="|stochastic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4759" PostTypeId="2" ParentId="4757" CreationDate="2020-08-31T09:33:46.413" Score="2" Body="&lt;p&gt;If you are interested in supply chain management and its related processes, there are lots of textbooks which these concepts have been described in the mathematical form to illustrate and control the behaviour of the supply chain network (e.g. optimization models). Some of them are as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/gp/book/9783540430155&quot; rel=&quot;nofollow noreferrer&quot;&gt;Planning Stability in Material Requirements Planning Systems&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/gp/book/9783642028328&quot; rel=&quot;nofollow noreferrer&quot;&gt;Supply Chain Coordination Mechanisms&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://onlinelibrary.wiley.com/doi/book/10.1002/9781119584445&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fundamentals of Supply Chain Theory&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0133800202&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Supply Chain Management: Strategy, Planning, and Operation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also, there are many useful references which could be found by googling.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-08-31T09:33:46.413" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4760" PostTypeId="1" CreationDate="2020-08-31T14:27:07.187" Score="2" ViewCount="1058" Body="&lt;p&gt;There's something I don't understand about CVXPY's &lt;a href=&quot;https://www.cvxpy.org/examples/basic/mixed_integer_quadratic_program.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt; on its MIQP use. It says that the algorithm returns a solution &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{Z}^n$&lt;/span&gt; but I thought in general the point of MIQP algorithms was to return a solution &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; such as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\forall i, x_{i} \in [m,M] \cup \{0\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;given &lt;span class=&quot;math-container&quot;&gt;$m,M\in \mathbb{R}$&lt;/span&gt;. Am I missing some parameters here?&lt;/p&gt;&#xA;" OwnerUserId="3756" LastEditorUserId="8" LastEditDate="2020-09-01T12:13:37.163" LastActivityDate="2020-09-01T12:13:37.163" Title="Mixed integer quadratic programming (MIQP) in CVXPY" Tags="|mixed-integer-programming|python|cvxpy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4761" PostTypeId="2" ParentId="4760" CreationDate="2020-08-31T14:35:15.093" Score="7" Body="&lt;p&gt;What you described is a problem for which every variable is &lt;em&gt;semicontinuous&lt;/em&gt;.  In mixed integer programming, the variables are &lt;span class=&quot;math-container&quot;&gt;$(x,y)\in\mathbb{Z}^{n_1} \times \mathbb{R}^{n_2}$&lt;/span&gt;.  For (pure) integer programming, take &lt;span class=&quot;math-container&quot;&gt;$n_2=0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-08-31T14:35:15.093" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4762" PostTypeId="5" CreationDate="2020-09-01T16:26:17.417" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2020-09-01T16:26:17.417" LastActivityDate="2020-09-01T16:26:17.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4763" PostTypeId="4" CreationDate="2020-09-01T16:26:17.417" Score="0" Body="CVXPY is a Python-embedded modeling language for convex optimization problems. " OwnerUserId="8" LastEditorUserId="8" LastEditDate="2020-09-01T16:48:37.357" LastActivityDate="2020-09-01T16:48:37.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4764" PostTypeId="2" ParentId="4757" CreationDate="2020-09-01T21:06:04.613" Score="5" Body="&lt;p&gt;I checked with a colleague who taught procurement / sourcing / purchasing / supply management /  for quite a few years. He's skeptical about there being any heavily OR-oriented books in the field. That said, he mentioned &amp;quot;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/B00TSU7YIY&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Better Business Decisions Using Cost Modeling, Second Edition&lt;/a&gt;&amp;quot;, which he used (along with one or more other books) in an undergrad class focuses specifically on cost models, and &amp;quot;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/1461422205&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Purchasing Chessboard: 64 Methods to Reduce Costs and Increase Value with Suppliers&lt;/a&gt;&amp;quot;, which he thought might provide some ideas of how to (in his words) &amp;quot;fit some treatment of quantitative models into a&#xA;'sourcing strategy' framework&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-01T21:06:04.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4765" PostTypeId="2" ParentId="4758" CreationDate="2020-09-01T23:31:10.487" Score="4" Body="&lt;p&gt;I did a little research and found the paper that I have cited below. I think with 517 citations this paper and the reference therein can be a good source for you.&lt;/p&gt;&#xA;&lt;p&gt;Paper:&#xA;Kaut, Michal, and Stein W. Wallace. &amp;quot;Evaluation of scenario-generation methods for stochastic programming.&amp;quot; (2003).&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-09-01T23:31:10.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4766" PostTypeId="1" CreationDate="2020-09-02T01:50:59.463" Score="1" ViewCount="54" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f:\mathbb R^3\to\mathbb R$&lt;/span&gt; is an arbitrary concave function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; is a plane. &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is a given vector on &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x^*=\max_{x\in H} f(x)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Prove that &lt;span class=&quot;math-container&quot;&gt;$\nabla_y\nabla_vf(x^*)\geq 0$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$y=-v$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I draw a plot in 2D and the result is very intuitive. If we move the &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; a little bit along &lt;span class=&quot;math-container&quot;&gt;$-v$&lt;/span&gt;, to &lt;span class=&quot;math-container&quot;&gt;$x^*-v\epsilon$&lt;/span&gt;, then we must have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\nabla_vf(x^*-v\epsilon)\geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;since &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is concave. But idk how to formally prove the whole thing without a graphic illustration. Let me know if uploading a graph will help.&lt;/p&gt;&#xA;" OwnerUserId="3956" LastEditorUserId="3956" LastEditDate="2020-09-02T15:51:53.443" LastActivityDate="2020-09-02T15:51:53.443" Title="$\nabla_y\nabla_vf(x^*)\geq0$ for any concave $f$ if and only if $y=-v$" Tags="|optimization|convexity|convex-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4767" PostTypeId="1" CreationDate="2020-09-02T08:02:48.943" Score="6" ViewCount="1506" Body="&lt;p&gt;A simple algorithm may be traverse all vertices, and perform DFS for every vertex.&lt;/p&gt;&#xA;&lt;p&gt;However, the computational complexity is &lt;span class=&quot;math-container&quot;&gt;$O(n(n+m))$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; are the number of vertices and edges in the DAG, respectively. (Since &lt;span class=&quot;math-container&quot;&gt;$m \in O(n^2)$&lt;/span&gt;, the complexity is actually &lt;span class=&quot;math-container&quot;&gt;$O(n^3)$&lt;/span&gt;. Hope I'm right about the complexity).&lt;/p&gt;&#xA;&lt;p&gt;For very big graphs, the complexity is unacceptable.&lt;/p&gt;&#xA;&lt;p&gt;Is there any algorithm or idea that can solve the problem (reduce the algorithm complexity)?&lt;/p&gt;&#xA;" OwnerUserId="4042" LastEditorUserId="4042" LastEditDate="2020-09-03T07:08:53.933" LastActivityDate="2020-09-15T09:55:27.093" Title="How to find all descendant vertices of all vertices in a big DAG (Directed acyclic graph)?" Tags="|algorithms|computational-complexity|graphs|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4768" PostTypeId="1" CreationDate="2020-09-02T13:51:12.590" Score="3" ViewCount="50" Body="&lt;p&gt;I'm not an expert in OR but I would like to determine what is the maximum manufacturing capacity of a plant (or how much a plant can produce of mix products).&lt;/p&gt;&#xA;&lt;p&gt;Each person in the plant has a known set of competences and is available a certain amount of hours per week.&lt;/p&gt;&#xA;&lt;p&gt;Each product (+1000 SKUs) uses in each section of the plant a set of competences for a determined amount of time (which is also known).&lt;/p&gt;&#xA;&lt;p&gt;When the problem stays like this it's not that hard I'm able to determine the max mix-product by using Google's linear solver (OR-tools).&lt;/p&gt;&#xA;&lt;p&gt;But if I say that I also have to consider the fact that each product needs in each section a defined number of people (while keeping true the competences constraints described earlier) I have a hard time figuring out how my  equations are going to look like.&lt;/p&gt;&#xA;&lt;p&gt;I'm even wondering if this stays a linear problem since I have to ask the question : Are enough people available at a certain time for this section ?  If yes then do this, If no then do that.&lt;/p&gt;&#xA;&lt;p&gt;I'm looking for some inspiration here, so here are my questions :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How would you solve this ?&lt;/li&gt;&#xA;&lt;li&gt;Do you know any literature about capacity determination in a high mix environnement ?&lt;/li&gt;&#xA;&lt;li&gt;What other problem this remind you of ?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Thank you for your help,&lt;/p&gt;&#xA;" OwnerUserId="4043" LastActivityDate="2020-09-02T13:51:12.590" Title="High-mix manufacturing capacity" Tags="|linear-programming|or-tools|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4769" PostTypeId="2" ParentId="4767" CreationDate="2020-09-02T14:21:42.840" Score="1" Body="&lt;p&gt;How about something like this:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Copy the adjacency matrix.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Count the out-valence of each node.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Find all nodes X with 0 out-valence.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Repeat until done:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For each node Y where Y→X is an edge:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Merge row X into row Y.&lt;/li&gt;&#xA;&lt;li&gt;Reduce Y's out-valence by one.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Next X set will be the Y's whose out-valance just became 0.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each row of the resulting matrix will contain all descendant vertices of that node.&lt;/p&gt;&#xA;&lt;p&gt;E.g.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;A: B, C&#xA;B: F&#xA;C: G&#xA;D: C, E&#xA;E: H, I&#xA;F: J&#xA;G:&#xA;H:&#xA;I: J&#xA;J:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Adjacency:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   a b c d e f g h i j   #&#xA;A: - 1 1 - - - - - - -   2&#xA;B: - - - - - 1 - - - -   1&#xA;C: - - - - - - 1 - - -   1&#xA;D: - - 1 - 1 - - - - -   2&#xA;E: - - - - - - - 1 1 -   2&#xA;F: - - - - - - - - - 1   1&#xA;G: - - - - - - - - - -   0&#xA;H: - - - - - - - - - -   0&#xA;I: - - - - - - - - - 1   1&#xA;J: - - - - - - - - - -   0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Resulting descendants:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;A: - 1 1 - - 1 1 - - 1&#xA;B: - - - - - 1 - - - 1&#xA;C: - - - - - - 1 - - -&#xA;D: - - 1 - 1 - 1 1 1 1&#xA;E: - - - - - - - 1 1 1&#xA;F: - - - - - - - - - 1&#xA;G: - - - - - - - - - -&#xA;H: - - - - - - - - - -&#xA;I: - - - - - - - - - 1&#xA;J: - - - - - - - - - -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The use of matrices is an implementation detail.  For sparse matrices, other representations would be better.&lt;/p&gt;&#xA;" OwnerUserId="3482" LastEditorUserId="3482" LastEditDate="2020-09-02T17:58:17.303" LastActivityDate="2020-09-02T17:58:17.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4770" PostTypeId="1" AcceptedAnswerId="4771" CreationDate="2020-09-02T14:52:42.283" Score="3" ViewCount="503" Body="&lt;p&gt;I have a semi-continuous optimization problem reformulated as a MIQP optimization problem.&lt;/p&gt;&#xA;&lt;p&gt;My objective has a quadratic form &lt;span class=&quot;math-container&quot;&gt;$x^{T}Qx$&lt;/span&gt; and my &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; are such as &lt;span class=&quot;math-container&quot;&gt;$x_{i} \in [m,M] \cup \{0\}$&lt;/span&gt;.&#xA;Therefore, I introduce a vector of binary variables &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; such as &lt;span class=&quot;math-container&quot;&gt;$y_{i} \in \{0,1\}$&lt;/span&gt; and consider the following constraint on the &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; : &lt;span class=&quot;math-container&quot;&gt;$m * y_{i} \leq x_{i} \leq M * y_{i}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My optimization problem is hence defined by the objective function, the ranged constraint on the &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; and the binary constraint on &lt;span class=&quot;math-container&quot;&gt;$y_{i}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I'm trying to solve my problem with CPLEX but I'm having trouble specifying the ranged constraint on the &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt;. Here's what I have so far for the constraints :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;myProblem=cplex.Cplex()&#xA;&#xA;#define the variables&#xA;names_amounts=[&amp;quot;amounts &amp;quot; + str(i) for i in range(50))]&#xA;names_binary=[&amp;quot;binary &amp;quot; + str(i) for i in range(50))]&#xA;myProblem.variables.add(ub=[1]*50,&#xA;                        lb=[0]*50,&#xA;                        names=names_amounts)&#xA;myProblem.variables.add(ub=[1]*50,&#xA;                        lb=[0]*50,&#xA;                        names=names_binary)&#xA;for i in range(50):&#xA;    myProblem.variables.set_types(&amp;quot;amounts &amp;quot; + str(i), myProblem.variables.type.continuous)&#xA;    myProblem.variables.set_types(&amp;quot;binary &amp;quot; + str(i), myProblem.variables.type.integer)&#xA;&#xA;#define the constraints&#xA;myProblem.linear_constraints.add(&#xA;        lin_expr=[[names_amounts,[1]*50]],&#xA;        senses=['E'],&#xA;        rhs=[1.0])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I need to add the ranged constraint but can't figure out how. I know my &lt;code&gt;senses&lt;/code&gt; attribute will become &lt;code&gt;['E'] + ['R' for i in range(50)]&lt;/code&gt; but what about the &lt;code&gt;lin_expr&lt;/code&gt; and &lt;code&gt;rhs&lt;/code&gt; attributes ? How to specify the dependance of the &lt;code&gt;rhs&lt;/code&gt; attribute with the binary variables ?&lt;/p&gt;&#xA;" OwnerUserId="3756" LastActivityDate="2020-09-02T15:12:00.417" Title="Semi continuous constraints in CPLEX Python" Tags="|mixed-integer-programming|cplex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4771" PostTypeId="2" ParentId="4770" CreationDate="2020-09-02T15:12:00.417" Score="6" Body="&lt;p&gt;that s quite easy to do with docplex python API:&lt;/p&gt;&#xA;&lt;p&gt;let me change&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/AlexFleischerParis/zoodocplex/blob/master/zoosemiinteger.py&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/AlexFleischerParis/zoodocplex/blob/master/zoosemiinteger.py&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;from&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/&quot; rel=&quot;noreferrer&quot;&gt;https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;into semicontinuous&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;# original model&#xA;&#xA;mdl = Model(name='buses')&#xA;nbbus40 = mdl.semicontinuous_var(4,20,name='nbBus40')&#xA;nbbus30 = mdl.semicontinuous_var(4,20,name='nbBus30')&#xA;mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;mdl.minimize(nbbus40*500 + nbbus30*400)&#xA;&#xA;mdl.solve()&#xA;&#xA;for v in mdl.iter_semicontinuous_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-09-02T15:12:00.417" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4772" PostTypeId="1" CreationDate="2020-09-03T00:32:36.773" Score="6" ViewCount="585" Body="&lt;p&gt;Can branch and price be a good solution approach for a routing problem with min-max objective function? For example, minimizing the max length of any vehicle route in a VRP.&lt;/p&gt;&#xA;&lt;p&gt;In the literature, I haven't ever seen that this solution approach used to solve such a problem. As far as I know, this approach is used to solve VRPs minimizing total cost.&lt;/p&gt;&#xA;" OwnerUserId="3972" LastEditorUserId="3972" LastEditDate="2020-11-17T00:47:56.170" LastActivityDate="2020-11-17T00:47:56.170" Title="Branch and Price Algorithm" Tags="|mixed-integer-programming|combinatorial-optimization|vehicle-routing|column-generation|branch-and-price|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4773" PostTypeId="2" ParentId="4735" CreationDate="2020-09-03T02:05:40.873" Score="2" Body="&lt;p&gt;You want to model &lt;span class=&quot;math-container&quot;&gt;$y=1 \iff x &amp;gt; 0$&lt;/span&gt;.  The following big-M constraints enforce that relationship, where &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt; is a small tolerance:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\epsilon y \le x \le M y$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Because your &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is integer, you can take &lt;span class=&quot;math-container&quot;&gt;$\epsilon = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-09-03T02:05:40.873" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4774" PostTypeId="2" ParentId="4772" CreationDate="2020-09-03T02:08:01.330" Score="9" Body="&lt;p&gt;Being a good or bad approach will depend on several factors, for example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the size of the instances&lt;/li&gt;&#xA;&lt;li&gt;time available to find a solution (this tends to be an important matter in vehicle routing applications)&lt;/li&gt;&#xA;&lt;li&gt;computing power&lt;/li&gt;&#xA;&lt;li&gt;what level of solution quality qualifies as good enough&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;http://viswa.engin.umich.edu/wp-content/uploads/sites/169/2014/08/vrpcc.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this work by Yu, Nagarajan and Shen&lt;/a&gt; on the minimum makespan VRP with compatibility constraints, as it's a similar problem that's been studied before using branch-and-price as an approach to solve a makespan VRP variant. It worked quite well. Note that in their case, they designed an approximation algorithm to accelerate the B&amp;amp;P execution time.&lt;/p&gt;&#xA;&lt;p&gt;I suggest the following experiment:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;First step:&lt;/strong&gt; Following @RobPratt's &lt;a href=&quot;https://or.stackexchange.com/a/4666/2477&quot;&gt;answer to your previous question regarding makespan minimization in VRP&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; be the demand for customer &lt;span class=&quot;math-container&quot;&gt;$i\in N$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$V=\{1,\dots,K\}$&lt;/span&gt;&#xA;be the set of vehicles, and let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be the set of columns, where each&#xA;column corresponds to a feasible subtour starting from the depot, with&#xA;arc variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; and node variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;.  Let &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; be the&#xA;makespan.  The master problem over &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is as follows,&#xA;with dual variables in parentheses:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align} &amp;amp;\text{minimize} &amp;amp;z&#xA;\\ &amp;amp;\text{subject to} &amp;amp;z - \sum_{p\in P} \left(\sum_{i,j} c_{i,j}&#xA;x_{i,j}^p\right) \lambda^p_v &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for $v\in V$} &amp;amp;&amp;amp;(\pi_v \ge&#xA;0)\\ &amp;amp;&amp;amp;\sum_{v \in V} \sum_{p\in P} y_i^p \lambda^p_v &amp;amp;\ge 1&#xA;&amp;amp;&amp;amp;\text{for $i\in N$}  &amp;amp;&amp;amp;(\text{$\alpha_i \ge 0$})\\ &amp;amp;&amp;amp;-\sum_{p\in P}&#xA;\lambda^p_v &amp;amp;\ge -1 &amp;amp;&amp;amp;\text{for $v\in V$}  &amp;amp;&amp;amp;(\text{$\beta_v \ge&#xA;0$})\\ &amp;amp;&amp;amp;\lambda^p_v &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for $v\in V$ and $p\in P$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The column generation subproblem over &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$v\in V$&lt;/span&gt; is&#xA;then to minimize the reduced cost of &lt;span class=&quot;math-container&quot;&gt;$\lambda^p_v$&lt;/span&gt;.  That is, minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\pi_v \sum_{i,j} c_{i,j} x_{i,j} - \sum_{i \in N} \alpha_i y_i +&#xA;\beta_v$$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt; forming a feasible subtour starting from&#xA;the depot, with &lt;span class=&quot;math-container&quot;&gt;$\sum_i d_i y_i \le L$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is the capacity of&#xA;each vehicle.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;As stated there, the subproblem can be reformulated as elementary shortest path: Split the depot into a source and a sink, and move the node weights to the arcs: &lt;span class=&quot;math-container&quot;&gt;$\pi_v c_{i,j}−\alpha_i$&lt;/span&gt; for the weight of arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; in the elementary shortest path subproblem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Second:&lt;/strong&gt; Implement the above method. I recommend trying to use VRPy, as suggested by Kuifje &lt;a href=&quot;https://or.stackexchange.com/a/4723/2477&quot;&gt;here&lt;/a&gt;. That way you won't have to implement all the branch and price operations from scratch. Detailed steps:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Take a look at the project's documentation.&lt;/li&gt;&#xA;&lt;li&gt;Take a look at the code in GitHub.&lt;/li&gt;&#xA;&lt;li&gt;Create a fork or download the project as .zip, such that you can make changes locally.&lt;/li&gt;&#xA;&lt;li&gt;Modify the &lt;a href=&quot;https://github.com/Kuifje02/vrpy/tree/master/vrpy&quot; rel=&quot;nofollow noreferrer&quot;&gt;code regarding the subproblem&lt;/a&gt;, such that the depot is split as was explained above.&lt;/li&gt;&#xA;&lt;li&gt;Run the experiments, you can follow the example instances from the documentation like &lt;a href=&quot;https://vrpy.readthedocs.io/en/dev/examples.html#an-example-borrowed-from-ortools&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://github.com/Kuifje02/vrpy/tree/master/tests/benchmarks&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Let us know how it worked. And remember to acknowledge VRPy and its developers in your work (be it a project report, thesis, publication, etc), as well as respecting the terms on the library's license with respect to modifications.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="500" LastEditDate="2020-11-10T18:49:19.307" LastActivityDate="2020-11-10T18:49:19.307" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4775" PostTypeId="2" ParentId="334" CreationDate="2020-09-03T12:45:04.387" Score="7" Body="&lt;p&gt;For having spent 10 years in &lt;strong&gt;Academia&lt;/strong&gt;/OR and 20 years in the &lt;strong&gt;industry&lt;/strong&gt; side of the force, I noticed that one difference is often the incremental aspect of the problem you have to solve in the industry.&lt;/p&gt;&#xA;&lt;p&gt;Imagine you want to schedule bus drivers for a city bus transit system. Most of the academic work is based on a global optimization question, with an objective function - like minimizing the number of agents - and demand satisfying constraints together with HR constraints or usage/preference constraints.&lt;/p&gt;&#xA;&lt;p&gt;In the industry you never solve from scratch, or very rarely. So you start from a solution (the one of last year or last month) and you want to slightly (&lt;em&gt;to be defined&lt;/em&gt;) tweak it so that it respects new constraints or reach new goals. For instance one stop is added or a concert on Friday has to be covered. And you want it fast without perturbating too much (&lt;em&gt;to be defined&lt;/em&gt;) the initial solution.&lt;/p&gt;&#xA;&lt;p&gt;Mathematically speaking, it's not necessarily more complex, but it forces to approach the metrics differently.&lt;/p&gt;&#xA;" OwnerUserId="4050" LastActivityDate="2020-09-03T12:45:04.387" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4776" PostTypeId="2" ParentId="4767" CreationDate="2020-09-03T19:48:46.797" Score="3" Body="&lt;p&gt;The general strategy is as follows:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;For each node, determine its in-degree.&lt;/li&gt;&#xA;&lt;li&gt;Locate those nodes for which the in-degree is zero have no incoming edges (there will always be some since this is a DAG).&lt;/li&gt;&#xA;&lt;li&gt;Add those nodes to a queue.&lt;/li&gt;&#xA;&lt;li&gt;Pop nodes from the queue and process them.&lt;/li&gt;&#xA;&lt;li&gt;For each node popped from the queue, decrement the in-degree count of its &amp;quot;downstream&amp;quot; neighbours. If a neighbour's count becomes zero, add it to the queue.&lt;/li&gt;&#xA;&lt;li&gt;Repeat.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;This algorithm can be parallelized across the &amp;quot;wavefront&amp;quot; of 0-in-degree cells either directly, or by using a parallelized matrix library.&lt;/p&gt;&#xA;&lt;p&gt;Depending on the type of processing you want to do and whether or not your graph is already partitioned, it may be possible to achieve greater parallelism.&lt;/p&gt;&#xA;&lt;p&gt;For instance, in &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S1364815216304984&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; I wish to calculate the number of &amp;quot;upstream&amp;quot; nodes each node has in a 2 trillion node graph. Since my DAG is conveniently partitioned I can calculate this quantity with fixed per-cell and per-partition communication events achieving considerably more parallelism than the wavefront approach alone would allow.&lt;/p&gt;&#xA;&lt;p&gt;For other resources you could consider the following papers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/1705.04590.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Distributed-Memory Breadth-First Search on Massive Graphs&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/1104.4518.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Parallel Breadth-First Search on&#xA;Distributed Memory Systems&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Both of these papers follow the kind of techniques described in the book &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0898719909&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Graph Algorithms in the Language of Linear Algebra&lt;/a&gt; and proposed in the &lt;a href=&quot;https://arxiv.org/pdf/1504.01039.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;GraphBLAS standard&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="886" LastEditorUserId="886" LastEditDate="2020-09-12T05:11:23.843" LastActivityDate="2020-09-12T05:11:23.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4777" PostTypeId="1" AcceptedAnswerId="4782" CreationDate="2020-09-03T16:09:20.847" Score="4" ViewCount="331" Body="&lt;p&gt;I am trying to solve a problem (in pyspark/ python) where I need to find two distinct values to allocate, and how to allocate them in a network of stores.&lt;/p&gt;&#xA;&lt;p&gt;The two distinct values can only be integer values and constrained within a lower and upper bound. For each such distinct value pair, say 4 and 8, each store can get either 4 or 8 giving a total of 2&lt;sup&gt;&lt;em&gt;n&lt;/em&gt;&lt;/sup&gt; different ways of allocation if there are &lt;em&gt;n&lt;/em&gt; stores (&lt;em&gt;n&lt;/em&gt; is close to 1000).&lt;/p&gt;&#xA;&lt;p&gt;The objective function is a complex one and uses predictive models to give the impact of a particular value pair corresponding to its allocation in the network.&lt;/p&gt;&#xA;&lt;p&gt;I was hoping if I could create a cost function of the form:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Cost  = f( variant1, variant2, store_1_variant, store_2_variant, ..., store_n_variant)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;variant1 = 4&lt;/code&gt; (integer, constrained within a max value)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;variant2 = 8&lt;/code&gt; (integer, constrained within a max value)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;store_1_variant, ..., store_n_variant&lt;/code&gt; are binary [0,1] to suggest whether they receive &lt;code&gt;variant_1&lt;/code&gt; or not (not receiving &lt;code&gt;variant1&lt;/code&gt; would mean receiving &lt;code&gt;variant2&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I could solve for the &lt;em&gt;n + 2&lt;/em&gt; parameters that minimize the cost (there is another constraint that needs to keep in check the impact of a certain allocation)&lt;/p&gt;&#xA;&lt;p&gt;I have looked at various combinatorial optimisation techniques but none that seem to allow me a user defined function as a cost function.&lt;/p&gt;&#xA;&lt;p&gt;I have no prior experience in to this area so any direction/ assistance is appreciated.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;To add some information on the current form of cost function, continuing with the example of two variants being 4 and 8 with say 5 stores, &lt;code&gt;f(4, 8, 0, 1, 1, 0, 0)&lt;/code&gt; will have an associated cost of the form&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;a&lt;/em&gt;*s&lt;sub&gt;11&lt;/sub&gt;*(s&lt;sub&gt;12&lt;/sub&gt;/8)&lt;em&gt;&lt;sup&gt;b&lt;/sup&gt; + a*s&lt;sub&gt;21&lt;/sub&gt;*(s&lt;sub&gt;22&lt;/sub&gt;/4)&lt;/em&gt;&lt;sup&gt;b&lt;/sup&gt; + a*s&lt;sub&gt;31&lt;/sub&gt;*(s&lt;sub&gt;32&lt;/sub&gt;/4)&lt;em&gt;&lt;sup&gt;b&lt;/sup&gt; + a*s&lt;sub&gt;41&lt;/sub&gt;*(s&lt;sub&gt;42&lt;/sub&gt;/8)&lt;/em&gt;&lt;sup&gt;b&lt;/sup&gt; + a*s&lt;sub&gt;51&lt;/sub&gt;*(s&lt;sub&gt;52&lt;/sub&gt;/8)&lt;sup&gt;b&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;p&gt;where s&lt;sub&gt;11&lt;/sub&gt; and s&lt;sub&gt;12&lt;/sub&gt; are store level metrics for store 1 and so on.&lt;/p&gt;&#xA;&lt;p&gt;Parameters &lt;em&gt;a&lt;/em&gt; and &lt;em&gt;b&lt;/em&gt; are regressed coefficients from historic data, but this is just a good starting point and will eventually evolve into a more complex functional form (might be predictions from an ML algorithm)&lt;/p&gt;&#xA;&lt;p&gt;Constraints:&lt;/p&gt;&#xA;&lt;p&gt;variant1 &amp;lt;= k&lt;sub&gt;1&lt;/sub&gt;&lt;br /&gt;&#xA;variant2 &amp;gt;= k&lt;sub&gt;1&lt;/sub&gt; and &amp;lt;= k&lt;sub&gt;2&lt;/sub&gt;&lt;br /&gt;&#xA;(s&lt;sub&gt;13&lt;/sub&gt;/8) + (s&lt;sub&gt;23&lt;/sub&gt;/4) + (s&lt;sub&gt;33&lt;/sub&gt;/4) + (s&lt;sub&gt;43&lt;/sub&gt;/8) + (s&lt;sub&gt;53&lt;/sub&gt;/8) should lie between [ (0.95/k&lt;sub&gt;1&lt;/sub&gt;) * (s&lt;sub&gt;13&lt;/sub&gt; + s&lt;sub&gt;23&lt;/sub&gt; + s&lt;sub&gt;33&lt;/sub&gt;+ s&lt;sub&gt;43&lt;/sub&gt;+ s&lt;sub&gt;53&lt;/sub&gt;),&#xA;(1.05/k&lt;sub&gt;1&lt;/sub&gt;) * (s&lt;sub&gt;13&lt;/sub&gt; + s&lt;sub&gt;23&lt;/sub&gt; + s&lt;sub&gt;33&lt;/sub&gt;+ s&lt;sub&gt;43&lt;/sub&gt;+ s&lt;sub&gt;53&lt;/sub&gt;) ] (5% deviation)&lt;br /&gt;&#xA;where k&lt;sub&gt;1&lt;/sub&gt;, k&lt;sub&gt;2&lt;/sub&gt;, variant1 and variant2 are integers&lt;/p&gt;&#xA;" OwnerUserId="4051" OwnerDisplayName="bb.jose" LastEditorUserId="4051" LastEditDate="2020-09-04T14:56:19.040" LastActivityDate="2020-09-16T20:14:21.563" Title="Combinatorial Optimisation, Allocation problem" Tags="|python|optimization|combinatorics|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4779" PostTypeId="2" ParentId="4112" CreationDate="2020-09-04T01:49:35.797" Score="3" Body="&lt;p&gt;For a Poisson process the rate of events is constant. The distribution of time between events in the Poisson process is exponential with &lt;span class=&quot;math-container&quot;&gt;$F(v)=1-e^{-\lambda v}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$v\ge 0$&lt;/span&gt; which gives the hazard rate &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;. So a non-constant hazard rate can be seen as a way of comparing with a Poisson process, an increasing hazard rate means the events come faster and faster, like delinquences in a financial crisis ... For some more examples see this posts over at Cross Validated: &lt;a href=&quot;https://stats.stackexchange.com/questions/389182/non-monotone-hazard-functions/389206#389206&quot;&gt;Examples of non-monotone hazard functions&lt;/a&gt; and &lt;a href=&quot;https://stats.stackexchange.com/questions/283683/what-are-nbue-new-better-than-used-in-expectation-random-variables/391375#391375&quot;&gt;New Better than Used&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I don't know about revenue management or dynamic pricing, but if you can link to some papers I can have a look ...&lt;/p&gt;&#xA;" OwnerUserId="166" LastEditorUserId="166" LastEditDate="2020-09-04T13:07:47.950" LastActivityDate="2020-09-04T13:07:47.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4780" PostTypeId="1" CreationDate="2020-09-04T17:48:28.620" Score="9" ViewCount="319" Body="&lt;p&gt;What textbook/articles would you use to introduce heuristics and meta-heuristics to OR students? Assume they have already seen some OR (e.g., LP and MILP).&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="224" LastEditDate="2020-09-05T09:04:28.843" LastActivityDate="2020-09-09T02:18:13.663" Title="What is good introductory literature on (meta)heuristics?" Tags="|reference-request|heuristics|metaheuristics|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4781" PostTypeId="2" ParentId="4780" CreationDate="2020-09-04T18:08:08.700" Score="7" Body="&lt;p&gt;This will be opinion based, but I personally like &amp;quot;Handbook of meta heuristics&amp;quot; edited by Michel Gendreau and Jean-Yves Potvin. &lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4419-1665-5&quot; rel=&quot;noreferrer&quot;&gt;https://link.springer.com/book/10.1007/978-1-4419-1665-5&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;There is also &amp;quot;Metaheuristics for Business Analytics&amp;quot; if you are teaching business school students. &lt;a href=&quot;https://www.springer.com/gp/book/9783319681177&quot; rel=&quot;noreferrer&quot;&gt;https://www.springer.com/gp/book/9783319681177&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2020-09-04T19:08:40.673" LastActivityDate="2020-09-04T19:08:40.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4782" PostTypeId="2" ParentId="4777" CreationDate="2020-09-04T20:45:04.460" Score="3" Body="&lt;p&gt;Given what appears to be a nonlinear constraint (the 5% deviation constraint) and a nonlinear (and apparently arbitrarily complex) objective function, I would not be optimistic about finding a provably optimal solution. If you are willing to settle for a &amp;quot;good&amp;quot; solution, there are a variety of metaheuristics that might be applicable. Recommendation of a particular metaheuristic would depend on the specifics of the constraints and the religious tendencies of the person making the recommendation.&lt;/p&gt;&#xA;&lt;p&gt;Addendum: Based on comments below, I tried both a genetic algorithm and a greedy heuristic. The greedy heuristic consistently outperformed the GA (better answer in must less time). Coded in R and run a PC with made up data for 1,000 stores (using &lt;span class=&quot;math-container&quot;&gt;$k_1=6$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k_2=12$&lt;/span&gt;), the greedy heuristic typically took under 0.2 seconds. The greedy heuristic loops through all possible values of variant1 and variant2. For each combination, it initially assigns the cheaper of the two to all stores, then checks whether the balance constraint is met. If not, it loops through the stores in a &amp;quot;biggest bang for the buck&amp;quot; order, switching stores from the cheaper variant to the more expensive one, until balance is (hopefully) met. Of course, larger values of &lt;span class=&quot;math-container&quot;&gt;$k_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k_2$&lt;/span&gt; will lead to more processing time, but I think this is still a very practical route to take.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-09-16T20:14:21.563" LastActivityDate="2020-09-16T20:14:21.563" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4783" PostTypeId="1" AcceptedAnswerId="4785" CreationDate="2020-09-04T22:51:33.783" Score="6" ViewCount="113" Body="&lt;p&gt;I have a MIP that runs for several different data sets. For each data set the MIP runs multiple times, once for each time period in the data set, and each time period is independent. I've experimented with grouping time periods into different sized batches to see how that affects overall run time, and I've found that the optimal batch size varies based on characteristics of the data set being utilized. For example, the more complex the data set being solved, the better it is to run time periods in smaller batches, while for simpler data sets I can run all the time periods at once in a single solve and get the fastest run time.&lt;/p&gt;&#xA;&lt;p&gt;I have data on the total run time for each data set at various batch sizes, and I've put this info together with various statistics that describe the complexity of each data set. In theory, I'm thinking I should be able to predict the optimal batch size for a given data set based on the characteristics of that data set.&lt;/p&gt;&#xA;&lt;p&gt;I'm trying to find a suitable algorithm for performing the above task. I've looked at regression, but the run time is highly nonlinear so using regression for prediction, in this case, does not do well. I've tried to utilize a regression tree in the hopes that it will tell me, based on the complexity of my data set, what batch size I should use. The problem I'm having with this approach is that batch size is not always selected as a splitting feature when the tree is grown. Some branches don't include batch size at all, so for some data sets the tree gives me no useful information.&lt;/p&gt;&#xA;&lt;p&gt;Essentially, I need an algorithm that tells me what batch size to use for a given data set, with the batch size that minimizes run time being optimal. The optimal batch size seems to be a nonlinear function of some characteristics of the data set. I'm wondering about how I can go about solving this general problem, so I have a couple questions in particular:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Are there other machine learning algorithms that would be better suited to this?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If regression trees are one of the better ways to accomplish this, how should I force them to work for this purpose? One method I thought of would be to build a tree that excludes batch size as a variable, and then I could take the data from each leaf of that tree and build an additional regression tree on each, for which batch size is the only feature/independent variable.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Any feedback on this type of problem is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="4056" LastEditorUserId="36" LastEditDate="2020-09-04T23:04:57.563" LastActivityDate="2020-09-05T20:34:04.890" Title="Optimizing MIP Parameters For Various Data Sets" Tags="|optimization|modeling|algorithms|machine-learning|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4784" PostTypeId="1" CreationDate="2020-09-05T01:10:24.913" Score="4" ViewCount="280" Body="&lt;p&gt;Can we get the closed-form solution for this problem?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min&amp;amp;\quad\sum_{i=1}^N\frac{K_i}{x_i\log_2(1+\frac{Q_i}{x_i})}\\&#xA;{\rm{s.t.}}&amp;amp;\quad\sum_{i=1}^N x_i\le X&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;wherein &lt;span class=&quot;math-container&quot;&gt;$K_i&amp;gt;0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Q_i&amp;gt;0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X&amp;gt;0$&lt;/span&gt; are constants, and &lt;span class=&quot;math-container&quot;&gt;$x_i&amp;gt;0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,\ldots,N\}$&lt;/span&gt; is a continuous optimization variable.&lt;/p&gt;&#xA;" OwnerUserId="3864" LastEditorUserId="123" LastEditDate="2020-09-05T20:21:27.417" LastActivityDate="2020-10-06T14:02:55.417" Title="Can we get the closed-form solution for this problem?" Tags="|convex-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4785" PostTypeId="2" ParentId="4783" CreationDate="2020-09-05T07:13:48.940" Score="3" Body="&lt;p&gt;Since you are already familiar with decision trees, you could try random forests.&lt;/p&gt;&#xA;&lt;p&gt;Random forests build an ensemble of decision trees, using, for each tree, a random subset of the data and a random subset of features. Being an ensemble method, the resulting random forest is likely to be more robust and better performing than a single decision tree. In particular, with respect to the issue you mention, some trees will not consider batch size as a feature, but probably several others will, making a better prediction, and more consistently.&lt;/p&gt;&#xA;&lt;p&gt;You can use packages for &lt;a href=&quot;https://cran.r-project.org/package=ranger&quot; rel=&quot;nofollow noreferrer&quot;&gt;R&lt;/a&gt; or &lt;a href=&quot;https://scikit-learn.org/stable/modules/ensemble.html#forest&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python&lt;/a&gt;, they are easy to use and quite efficient.&lt;/p&gt;&#xA;" OwnerUserId="224" LastActivityDate="2020-09-05T07:13:48.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4786" PostTypeId="2" ParentId="4780" CreationDate="2020-09-05T07:24:45.517" Score="1" Body="&lt;p&gt;An introduction to several algorithms can also be found in &amp;quot;Stochastic Local Search - Foundations and Applications&amp;quot; by Holger Hoos and Thomas Stützle. It contains an overview of the main methods, analyses, and some applications.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sciencedirect.com/book/9781558608726/stochastic-local-search&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sciencedirect.com/book/9781558608726/stochastic-local-search&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="224" LastActivityDate="2020-09-05T07:24:45.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4787" PostTypeId="2" ParentId="4784" CreationDate="2020-09-05T20:15:13.510" Score="1" Body="&lt;p&gt;It's easy to prove this is a convex optimization problem, as can be seen in the DCP formulation below. The problem satisfies the linearity constraint qualification. Therefore, the KKT conditions are necessary and sufficient for (global) optimality. Nevertheless, perhaps the KKT conditions can only be solved numerically.&lt;/p&gt;&#xA;&lt;p&gt;It is easy to enter this problem into a convex optimization modeling tool, such as CVX. Here is a CVX program to solve it. I will assume &lt;code&gt;K&lt;/code&gt; and &lt;code&gt;Q&lt;/code&gt; are column vectors, whose ith elements are &lt;span class=&quot;math-container&quot;&gt;$K_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q_i$&lt;/span&gt; respectively.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin&#xA;variable x(N)&#xA;minimize(log(2)*K'*inv_pos(-rel_entr(x,x+Q)))&#xA;sum(x) &amp;lt;= X&#xA;cvx_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;code&gt;rel_entr&lt;/code&gt; function constrains its arguments, hence &lt;code&gt;x&lt;/code&gt;, to be &lt;span class=&quot;math-container&quot;&gt;$\ge 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;CVX will call a solver, and if the solution status is Solved, &lt;code&gt;x&lt;/code&gt; will be populated with its optimal value. Given the use of the exponential cone, Mosek, which natively supports it, is the preferred solver under CVX for this problem.. Otherwise, install CVXQUAD and its &lt;code&gt;exponential.m&lt;/code&gt; replacement - see &lt;a href=&quot;http://ask.cvxr.com/t/cvxquad-how-to-use-cvxquads-pade-approximant-instead-of-cvxs-unreliable-successive-approximation-for-gp-mode-log-exp-entr-rel-entr-kl-div-log-det-det-rootn-exponential-cone-cvxquads-quantum-matrix-entropy-matrix-log-related-functions/5598&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://ask.cvxr.com/t/cvxquad-how-to-use-cvxquads-pade-approximant-instead-of-cvxs-unreliable-successive-approximation-for-gp-mode-log-exp-entr-rel-entr-kl-div-log-det-det-rootn-exponential-cone-cvxquads-quantum-matrix-entropy-matrix-log-related-functions/5598&lt;/a&gt; .&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: In lieu of closed-form solutions, &lt;strong&gt;Differentiable Convex Optimization Layers&lt;/strong&gt;, &lt;a href=&quot;https://github.com/cvxgrp/cvxpylayers&quot; rel=&quot;nofollow noreferrer&quot;&gt;cvxpylayers&lt;/a&gt;, in CVXPY allows insertion of the solution of DCP-compliant convex optimization problems, such as this, as a differentiable layer in lieu of nonlinear activation functions - see the blog &lt;a href=&quot;https://locuslab.github.io/2019-10-28-cvxpylayers&quot; rel=&quot;nofollow noreferrer&quot;&gt;Differentiable Convex Optimization Layers - CVXPY creates powerful new PyTorch and TensorFlow layers&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-09-06T13:52:44.223" LastActivityDate="2020-09-06T13:52:44.223" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4788" PostTypeId="2" ParentId="4783" CreationDate="2020-09-05T20:34:04.890" Score="1" Body="&lt;p&gt;If the relationship is nonlinear and you don't have a feel for the right regression function, you could try support vector machine regression or neural network regression. There are packages for both in R (and I assume also in Python).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-05T20:34:04.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4789" PostTypeId="1" AcceptedAnswerId="4792" CreationDate="2020-09-06T10:20:38.713" Score="4" ViewCount="579" Body="&lt;p&gt;I am trying to solve an optimization problem in which there is an objective function in the following form:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}f(x, y)=x+\left(\frac{1}{y}\right)\end{equation}&lt;/span&gt;&#xA;Where, &lt;span class=&quot;math-container&quot;&gt;$x,y$&lt;/span&gt; are positive variables with &lt;span class=&quot;math-container&quot;&gt;$LB=0$&lt;/span&gt; and a finite &lt;span class=&quot;math-container&quot;&gt;$UB$&lt;/span&gt;.&#xA;When I run the model I have an issue that &lt;code&gt;division by zero&lt;/code&gt;.&#xA;One possible way to do that is set a little number as a &lt;span class=&quot;math-container&quot;&gt;$LB$&lt;/span&gt; but, I am not sure this would be a good idea.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I was wondering if, is there any efficient way to solve this issue?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-09-09T09:27:25.933" Title="Is there efficient way to deal with division by zero?" Tags="|optimization|modeling|solver|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4791" PostTypeId="2" ParentId="4789" CreationDate="2020-09-06T13:43:41.700" Score="1" Body="&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is positive, your fraction is not only convex, but monotonically decreasing. This means that adding a &lt;span class=&quot;math-container&quot;&gt;$y \geq \epsilon$&lt;/span&gt; constraint will not affect the (global) solution, and will also prevent the numerical issues of division by zero.&lt;/p&gt;&#xA;&lt;p&gt;This means that you can add said constraint for each fractional variable in your objective, assuming it's positive, and and any NLP solver will solve it without issues.&lt;/p&gt;&#xA;&lt;p&gt;A word of caution though if you also have constraints with this: since you are minimising, be mindful that this functional form is only convex for &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt; constraints. If it shows up in any other type of constraint, the procedure to handle it is different.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-09-09T09:27:25.933" LastActivityDate="2020-09-09T09:27:25.933" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4792" PostTypeId="2" ParentId="4789" CreationDate="2020-09-06T22:19:41.700" Score="5" Body="&lt;p&gt;Assuming the problem is a minimization problem, you can use a &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/cqo.html#rotated-quadratic-cones&quot; rel=&quot;noreferrer&quot;&gt;rotated second-order cone&lt;/a&gt; (RSOC) formulation.&#xA;Specifically, write the objective as &lt;span class=&quot;math-container&quot;&gt;$x + 2t$&lt;/span&gt;, and add the constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(t, y, 1) \in \mathcal{Q}^{1}_{r},&#xA;$$&lt;/span&gt;&#xA;which is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;t \geq 0, y \geq 0, 2ty \geq 1,&#xA;$$&lt;/span&gt;&#xA;i.e., it yields &lt;span class=&quot;math-container&quot;&gt;$2t \geq \frac{1}{y}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;RSOC constraints are supported by solvers such as CPLEX, Gurobi and Mosek.&#xA;If the rest of you problem is non-linear, I believe KNITRO supports combinations of conic and non-linear constraints.&lt;/p&gt;&#xA;&lt;p&gt;If the objective &lt;span class=&quot;math-container&quot;&gt;$x + \frac{1}{y}$&lt;/span&gt; is to be maximized, then the above formulation does not work.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2020-09-06T22:19:41.700" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4793" PostTypeId="1" CreationDate="2020-09-07T00:42:32.757" Score="1" ViewCount="116" Body="&lt;p&gt;This is a convex problem and although it can be well solved by CVX, I want to know how it can be solved by the Lagrange duality method. The derivations with regard to &lt;span class=&quot;math-container&quot;&gt;$L_k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_k$&lt;/span&gt; are constants, which means the closed-form solution cannot be presented. I'm confused and I need some insights that help me understand the problem deeply.&#xA;I will give my honest appreciation to these who clear up the doubts for me.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Fa64v.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Fa64v.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4062" LastEditorUserId="36" LastEditDate="2020-09-07T00:51:19.197" LastActivityDate="2020-09-07T00:51:19.197" Title="How to solve this problem by Lagrange duality?" Tags="|convex-optimization|lagrange-multipliers|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4795" PostTypeId="2" ParentId="4719" CreationDate="2020-09-07T07:49:06.003" Score="1" Body="&lt;p&gt;Disclaimer: I did my PhD on the topic below and was the author of one of the toolboxes I mention below.&lt;/p&gt;&#xA;&lt;p&gt;This sounds a lot like you are interested in &lt;a href=&quot;https://en.wikipedia.org/wiki/Parametric_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;multi-parametric programming&lt;/a&gt;, i.e. solving your optimization problem as a function of the market prices. Each price is then a parameter and you can then solve the problem as a function thereof.&lt;/p&gt;&#xA;&lt;p&gt;The only tools that allow you to do this (to my knowledge) are the MATLAB toolboxes &lt;a href=&quot;https://www.mpt3.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MPT&lt;/a&gt; and &lt;a href=&quot;http://parametric.tamu.edu/POP/&quot; rel=&quot;nofollow noreferrer&quot;&gt;POP&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The main caveat is that this is fairly restrictive in terms of number of parameters etc., because the number of optimal active sets can explode. But it is impossible to know a priori whether this will be the case. The problem with the most number of parameters I've ever solved was 67 parameters, but I've also had cases where a problem with 5 parameters was really, really difficult.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2020-09-07T07:49:06.003" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4797" PostTypeId="1" AcceptedAnswerId="4803" CreationDate="2020-09-07T09:50:12.680" Score="4" ViewCount="192" Body="&lt;p&gt;Are there any good examples of people successfully switching between industry and academe after their PhD?&lt;/p&gt;&#xA;&lt;p&gt;If so, what were factors contributing to their success?&lt;/p&gt;&#xA;&lt;p&gt;What are things, that close that door for good?&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="405" LastEditDate="2020-09-09T09:42:18.580" LastActivityDate="2020-09-09T11:41:36.417" Title="Is it possible to switch between industry and academe?" Tags="|or-careers|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4798" PostTypeId="1" CreationDate="2020-09-07T12:19:54.333" Score="6" ViewCount="104" Body="&lt;p&gt;In the past 14 years, when dealing with enterprise planning challenges, I've encountered multiple challenges of &amp;quot;repeated planning&amp;quot; and &amp;quot;planning agility&amp;quot; in general. At some point, I started classifying, defining them and &lt;a href=&quot;https://docs.optaplanner.org/latestFinal/optaplanner-docs/html_single/index.html#repeatedPlanning&quot; rel=&quot;nofollow noreferrer&quot;&gt;documenting&lt;/a&gt; them in our manual.&#xA;Some of these terms come from academic paper or conference talks, but some of them I just named myself. Last week I did a &lt;a href=&quot;https://youtu.be/Ew6pq9nJKog?t=2085&quot; rel=&quot;nofollow noreferrer&quot;&gt;video&lt;/a&gt; on these, but I started wondering &lt;strong&gt;which of these are known under other names&lt;/strong&gt;?&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Continuous planning&lt;/strong&gt;: frequent planning of a sliding planning window. For example: in nurse rostering plan a window of 3 weeks every week.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Real-time planning&lt;/strong&gt;: the input problem can change at any time and a new plan taking into account those changes must be delivered within seconds or less (using a warm start). For example: airport gate scheduling or train platform scheduling&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Non-disruptive replanning&lt;/strong&gt;: replan an already published plan with minimal disruption (minimal changes). Also known as &lt;em&gt;non-volatile replanning&lt;/em&gt; or &lt;em&gt;semi-movable planning&lt;/em&gt;. For example: in conference scheduling, a speaker needs a different timeslot to make his/her airplane, after the schedule has been published already.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Overconstrained planning&lt;/strong&gt;: plan with a shortage of resources. For example: in nurse rostering, there are more shifts than available nurses&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Backup planning&lt;/strong&gt;: minimize the impact of a worst case scenario by adding additional constraints. For example: in train scheduling, pad an extra 10 minutes between connections to account for the first train being late&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Which of these are already defined in the academic world by other names? I think &lt;em&gt;backup planning&lt;/em&gt; is a superset of &lt;a href=&quot;https://or.stackexchange.com/questions/4827/what-is-robust-optimization/4833#4833&quot;&gt;&lt;em&gt;robust planning&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2020-09-11T10:46:55.030" LastActivityDate="2020-09-11T10:46:55.030" Title="Terminology for continuous planning, real-time planning, non-disruptive replanning, overconstrained planning, backup planning etc" Tags="|terminology|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4799" PostTypeId="1" AcceptedAnswerId="4800" CreationDate="2020-09-07T13:45:39.657" Score="2" ViewCount="120" Body="&lt;p&gt;I have a demand, &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I also have supply from 1000 sources. The supplies from those &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; (for example, &lt;span class=&quot;math-container&quot;&gt;$N=1000$&lt;/span&gt;) sources are given by&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s_1,s_2,s_3,\cdots,s_N$&lt;/span&gt;. So,the total supply is : &lt;span class=&quot;math-container&quot;&gt;$s_1+s_2+\cdots+s_N$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I meet the demand with least amount of resources wasted?&lt;/p&gt;&#xA;&lt;p&gt;so, the objective is to have minimum &lt;span class=&quot;math-container&quot;&gt;$(d-supply)$&lt;/span&gt;. The supply can come from any number of sources.&lt;/p&gt;&#xA;&lt;p&gt;A heuristic approach is welcome.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="123" LastEditDate="2021-02-17T11:39:22.647" LastActivityDate="2021-02-17T11:39:22.647" Title="How can I have minimum amount of resources wasted in this resource allocation problem?" Tags="|optimization|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4800" PostTypeId="2" ParentId="4799" CreationDate="2020-09-07T13:49:54.780" Score="5" Body="&lt;p&gt;Introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; for each supply and nonnegative waste variable &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\sum_i s_i x_i -w= d$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A heuristic approach is to sort the supplies in decreasing order and greedily take the largest ones until the sum satisfies the demand. Then, if the demand is not met exactly, exchange the last added supply with the smallest remaining supply that satisfies the demand.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-09-07T14:12:58.747" LastActivityDate="2020-09-07T14:12:58.747" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4802" PostTypeId="2" ParentId="4738" CreationDate="2020-09-07T19:02:37.880" Score="3" Body="&lt;p&gt;If you know some additional things on your problem parameters &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; you might find better (or closed-form) solutions. For clarity, we can express the constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{s,t = 1}^n \left(m_{s,t} x -v_{s,t} \right)\phi_s \phi_t = 0$&lt;/span&gt; in matrix form as &lt;span class=&quot;math-container&quot;&gt;$\phi^T (Mx-V)\phi = 0$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; are symmetric matrices of the form &lt;span class=&quot;math-container&quot;&gt;$M(s,t) = \frac{m_{s,t}+m_{t,s}}{2}$&lt;/span&gt; and likewise for &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Once you have that, if either &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; happens to be positive or negative definite, you can get a closed-form solution by doing the following. Assuming it is &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; the one that is positive definite:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Find the Cholesky factors of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$M = R^T R$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Rewrite the constraint as &lt;span class=&quot;math-container&quot;&gt;$\phi^T (Mx-V)\phi = \phi^T R^T\left(Ix - R^{-T}VR^{-1}\right)R\phi$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Compute the eigendecomposition of the symmetric matrix &lt;span class=&quot;math-container&quot;&gt;$R^{-T}VR^{-1} = U^T \Sigma U$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Factor out the eigenvectors: &lt;span class=&quot;math-container&quot;&gt;$\phi^T R^T U^T\left(Ix - \Sigma\right)UR\phi = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Take &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to be the minimum entry in &lt;span class=&quot;math-container&quot;&gt;$\Sigma$&lt;/span&gt;, i.e. &lt;span class=&quot;math-container&quot;&gt;$x = min(\sigma_i)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;And you can follow similar approaches for &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; being the positive definite one, and flipping signs if they are negative definite.&lt;/p&gt;&#xA;&lt;p&gt;A second approach, if the positive definite assumption doesn't apply, but if one of the matrices is positive or negative semi-definite, you can try to take advantage of the fact that, for example, &lt;span class=&quot;math-container&quot;&gt;$\phi^TV\phi$&lt;/span&gt; is always non-negative if &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is positive semidefinite, and thus &lt;span class=&quot;math-container&quot;&gt;$x \phi^TM\phi$&lt;/span&gt; must be non-negative too for the constraint to hold, and study the spectrum of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to derive some bounds. For example, if you know the highest value that &lt;span class=&quot;math-container&quot;&gt;$\phi^T V \phi$&lt;/span&gt; can take (using the highest eigenvalue of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;), and the smallest negative value that &lt;span class=&quot;math-container&quot;&gt;$\phi^T M \phi$&lt;/span&gt; (using some knowledge of the spectrum), you can find the most negative value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; such that these numbers match, and thus derive a lower bound on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A complementary approach to this one would be to find good feasible solutions to your optimization problem. A way to do so is to assume something stronger than what your problem requires, for example, find a value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$(Mx-V)\phi = 0$&lt;/span&gt;. This a sufficient condition for a feasible solution, as any pair of &lt;span class=&quot;math-container&quot;&gt;$x,\phi$&lt;/span&gt; satisfying this will satisfy your original constraint, but is not necessary, as even if &lt;span class=&quot;math-container&quot;&gt;$(Mx-V)\phi \neq 0$&lt;/span&gt;, your constraint can be satisfied if &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; is orthogonal to &lt;span class=&quot;math-container&quot;&gt;$(Mx-V)\phi$&lt;/span&gt;. But the condition &lt;span class=&quot;math-container&quot;&gt;$(Mx-V)\phi = 0$&lt;/span&gt; can be posed as a generalized eigenvalue problem and you can solve it in closed form (see &lt;a href=&quot;https://en.wikipedia.org/wiki/Schur_decomposition#Generalized_Schur_decomposition&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Eigendecomposition_of_a_matrix#Generalized_eigenvalue_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;, but beware that the notation &lt;span class=&quot;math-container&quot;&gt;$(A-\lambda B)x=0$&lt;/span&gt; is used instead of yours) and you can take &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to be the smallest (most negative) eigenvalue of the appropriate generalized eigenvalue problem.&lt;/p&gt;&#xA;&lt;p&gt;So even if you cannot compute closed-form solutions for all cases, you can get good suboptimal solutions and lower bounds, and from there get some suboptimality bounds to know how far you are from being optimal. Hope this helps!&lt;/p&gt;&#xA;" OwnerUserId="4052" LastEditorUserId="4052" LastEditDate="2020-09-07T20:12:48.793" LastActivityDate="2020-09-07T20:12:48.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4803" PostTypeId="2" ParentId="4797" CreationDate="2020-09-07T22:02:21.677" Score="9" Body="&lt;p&gt;If by &amp;quot;research&amp;quot; you mean &amp;quot;academe&amp;quot;, then yes, people have switched in both directions. I can't name anybody you would necessarily know. A bit of advise I got (from an academic) when I was finishing my PhD (and had two industry offers and one academic offer) was that the switch from academe to industry might be easier than the switch from industry to academe. The reason is that schools hiring &lt;em&gt;into a tenure track position&lt;/em&gt; tend to be looking for published papers while industry usually does not value publishing and may in fact discourage or forbid it (less you leak proprietary information).&lt;/p&gt;&#xA;&lt;p&gt;I met a few industry people (in fields outside OR) who migrated to academe, but they tended to be in adjunct (non-tenure stream) positions, where their business experience informed their teaching (and they were given a heavy teaching load with no research expectations). I've met one or two people who went the other direction (started in a tenure track slot, decided academic research was not their jam or failed to produce enough papers, and moved to industry).&lt;/p&gt;&#xA;&lt;p&gt;I don't think anything (other than being close to retirement age or failing to keep up with pertinent trends in your discipline) necessarily close the door to going into industry, nor can I think of anything that closes the door to an adjunct faculty position. Lack of publications, though, may close the door to a tenure stream slot at a research-oriented university.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-07T22:02:21.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4804" PostTypeId="2" ParentId="4798" CreationDate="2020-09-07T22:08:01.223" Score="3" Body="&lt;p&gt;I've seen the first one under the name &amp;quot;moving horizon models&amp;quot;. It seems to me that some people refer to the second with the term &amp;quot;online&amp;quot; (as in &amp;quot;online optimization&amp;quot;), which (confusingly) does not refer to the Internet but to reacting as new data points (orders, gate changes, accident reports) arrive. The fifth one is referred to as &amp;quot;inserted slack&amp;quot; in scheduling, but I don't recall any phrase that applies to the idea of padding in a more general context.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-07T22:08:01.223" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4805" PostTypeId="2" ParentId="3188" CreationDate="2020-09-08T03:32:17.960" Score="4" Body="&lt;p&gt;I make a commercial vehicle routing solver for both dynamic and static problems (see &lt;a href=&quot;https://odllive.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://odllive.com&lt;/a&gt;), and so I can offer a bit of industry insight into this question.&lt;/p&gt;&#xA;&lt;p&gt;Using heuristics, metaheuristics including things like clever splitting of the problem, you can get to much larger problem sizes. This doesn't mean of-course that you're getting optimal solutions for these larger problem sizes, but you are getting 'good enough' solutions to be workable in real-life. For example, we have a 'fuzzy splitting' algorithm within our ODL Live engine that lets us get reasonable solutions in a reasonable timeframe for 5000 delivery problems, as shown in the following screenshot:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/f7tgH.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/f7tgH.jpg&quot; alt=&quot;5000 delivery vehicle routing problem&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Although I've no doubt there's other commercial solvers which can get to this size of problem, 5000 appears to be on the large size for most. For example, as of September 2020 a popular solver called Routific appears to have an upper limit of 2000 deliveries - see &lt;a href=&quot;https://dev.routific.com/pricing&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://dev.routific.com/pricing&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Interestingly enough once you get to these size of problems, creating and holding the distance and travel time matrix in-memory can also become a bottleneck. Academic works using large problems tend to just assume Euclidean (i.e. straight line) distances between points which they can just calculate on-demand, so they don't tend to hit this issue. In-reality you need to be doing calculations based on the road network, with adjustments for rush hours etc. This adds significant overhead in both matrix calculation time and memory storage space.&lt;/p&gt;&#xA;&lt;p&gt;It's also worth mentioning that what you would assume to be the really large problems encountered in industry - i.e. parcel delivery problems - are actually commonly split up into really small problems instead, as for high density parcel delivery operations often each driver has their own fixed territory. So you may have (for example) someone like DHL or UPS delivering tens or hundreds of thousands of items within a large city, but these could all be independent single-vehicle problems with perhaps 100 stops per vehicle. This is common because fixed driver territories makes sortation at the depots more efficient, and allows drivers to build up local knowledge (i.e. best places to park) which helps them complete their route quicker. Presumably this offsets to some extent the loss of efficiency through treating as isolated subproblems.&lt;/p&gt;&#xA;" OwnerUserId="825" LastEditorUserId="825" LastEditDate="2020-09-08T10:53:38.807" LastActivityDate="2020-09-08T10:53:38.807" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4807" PostTypeId="1" AcceptedAnswerId="4808" CreationDate="2020-09-08T22:15:32.673" Score="2" ViewCount="253" Body="&lt;p&gt;For maximizing the objective function &lt;span class=&quot;math-container&quot;&gt;$\sum_i{d_i y_i}+ A x - B \cdot \mathbb{I}_{x&amp;gt;0}$&lt;/span&gt;, how can I linearize &lt;span class=&quot;math-container&quot;&gt;$ A x - B \cdot \mathbb{I}_{x&amp;gt;0}$&lt;/span&gt; term where &lt;span class=&quot;math-container&quot;&gt;$d_i, A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; are positive constants and &lt;span class=&quot;math-container&quot;&gt;$x, y_i$&lt;/span&gt; are continuous non-negative variables? Can you explain the logic of linearization? There are many other constraints involving &lt;span class=&quot;math-container&quot;&gt;$y_i, x$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4069" LastEditorUserId="491" LastEditDate="2020-09-25T20:00:32.410" LastActivityDate="2020-09-25T20:00:32.410" Title="Linearize sum of continuous and boolean variable" Tags="|linear-programming|linearization|indicator-constraints|reformulation-linearization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4808" PostTypeId="2" ParentId="4807" CreationDate="2020-09-08T23:43:21.840" Score="5" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a (small) upper bound on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and big-M constraint &lt;span class=&quot;math-container&quot;&gt;$x \le M z$&lt;/span&gt;. The idea is that &lt;span class=&quot;math-container&quot;&gt;$x&amp;gt;0$&lt;/span&gt; implies &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt;. Now use &lt;span class=&quot;math-container&quot;&gt;$B z$&lt;/span&gt; in the objective.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-09-08T23:43:21.840" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4809" PostTypeId="2" ParentId="4780" CreationDate="2020-09-09T02:18:13.663" Score="3" Body="&lt;p&gt;If you are looking for an introductory textbook, I think &amp;quot;&lt;a href=&quot;https://www.wiley.com/en-us/Metaheuristics%3A+From+Design+to+Implementation+-p-9780470278581&quot; rel=&quot;nofollow noreferrer&quot;&gt;Metaheuristics: From Design to Implementation&lt;/a&gt;&amp;quot; by El-Ghazali Talbi is a very good option as it covers various design ideas and issues as well as different metaheuristics.&lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2020-09-09T02:18:13.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4810" PostTypeId="1" AcceptedAnswerId="4823" CreationDate="2020-09-09T03:00:47.903" Score="2" ViewCount="68" Body="&lt;p&gt;Consider a set of &lt;span class=&quot;math-container&quot;&gt;$A_{vn}$&lt;/span&gt; decision variables such that &lt;span class=&quot;math-container&quot;&gt;$A_{v1},A_{v2},\cdots,A_{vn}&amp;lt;A$&lt;/span&gt;. While this is the standard formulation finding the maximum value of &lt;span class=&quot;math-container&quot;&gt;$A_{vn}$&lt;/span&gt;, I would also like to find the second largest &lt;span class=&quot;math-container&quot;&gt;$A_{vn}$&lt;/span&gt; of this set of decision variables.&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="123" LastEditDate="2020-09-09T07:02:22.440" LastActivityDate="2020-09-10T00:24:10.730" Title="Reformulating to locate the second largest decision variable of a set of decision variables" Tags="|optimization|modeling|indicator-constraints|reformulation-linearization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4811" PostTypeId="2" ParentId="3188" CreationDate="2020-09-09T09:12:51.500" Score="5" Body="&lt;p&gt;In my experience when solving Vehicle Routing with time windows in the industry, with one case handling &lt;strong&gt;50 000+ vehicles and 100 000+ visits per day&lt;/strong&gt; as well as many other cases with lower numbers, all running in production, I notice that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The problem is often (un)naturally &lt;strong&gt;partitioned&lt;/strong&gt;, due to Conway's law. In the 50K+ vehicles case, each vehicle and visit is confined to a region, so each region is a partition. The size of the regions varies (sometimes it's a US state), but if I recall correctly the partitions went up to around 1k vehicles.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;At some point, depending on the solver, partitioning increases solution quality given a fixed time limit. This is a &lt;em&gt;sign of weakness&lt;/em&gt; that every solver will run into when scaling VRP. The question is not if, but when. Note you can first solve partitions and then warm start a global solver on the merging of the resulting partitioned solutions, which sometimes leads to better results.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multi-threaded solving&lt;/strong&gt; (our &lt;code&gt;moveThreadCount&lt;/code&gt;) and &lt;strong&gt;nearby selection&lt;/strong&gt; make a world of difference. Our &lt;a href=&quot;https://www.optaplanner.org/learn/useCases/vehicleRoutingProblem.html&quot; rel=&quot;noreferrer&quot;&gt;OptaPlanner&lt;/a&gt; got scores in minutes what OR-Tools and 2 other competitors took hours to do, in the customer's extensive benchmarks consistently across multiple rounds. Your mileage may vary. Tuning matters.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Management was expecting a 1-2% improvement in driving time reduction. It was 25%, to their surprise. This resulted in huge (CEO level) savings and a reduction of 10 000 000+ kg of CO² fuel emissions per year.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Even &lt;strong&gt;multi-bet solving&lt;/strong&gt; (AKA multi-walks) is worth the extra hardware costs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Night planning (batch planning) != day planning (real-time planning as the problem changes)&lt;/strong&gt;. Both deliver huge benefits. Start with a Minimum Viable Product that only does nightly planning, that's easier to implement.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Do not use air distances. Use actual road times (= distance matrix). In my experiments, optimizations on air distances are easily 4% off compared to real road distances on my test Belgium datasets which have very dense road networks (so others countries will be much worse).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Distances matrix&lt;/strong&gt; are tricky. A distance matrix of 10 000 visits takes 1.6 GB RAM memory in it's most efficient form (it doesn't&#xA;matter if it's Java, C++, Python, etc). That's without traffic data.&#xA;When the number of visits double, the RAM reqs quadruple.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Good demo's matter too. Decision makers rejected our Java Swing demo's, so we recently we build &lt;a href=&quot;https://github.com/kiegroup/optaweb-vehicle-routing&quot; rel=&quot;noreferrer&quot;&gt;a dedicated open source webapp to demo VRP&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oyXnO.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oyXnO.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2020-09-09T09:26:07.210" LastActivityDate="2020-09-09T09:26:07.210" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4812" PostTypeId="1" AcceptedAnswerId="4816" CreationDate="2020-09-09T10:55:14.507" Score="2" ViewCount="108" Body="&lt;p&gt;I am having difficulty formulating the indicator constraints for the following:&lt;/p&gt;&#xA;&lt;p&gt;Consider a set of &lt;span class=&quot;math-container&quot;&gt;$A_{n}$&lt;/span&gt; decision variables such that &lt;span class=&quot;math-container&quot;&gt;$A_{1},A_{2},⋯,A_{n}&amp;lt;A$&lt;/span&gt;. While all of them are integers that are either equal or greater than zero, only either one or two of them are to be non-zero, i.e., the others are to be zero. Additionally, the two non-zero variables might also be equal, though they should be unequal most of the time.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$A_{max}$&lt;/span&gt; be the maximum value, while &lt;span class=&quot;math-container&quot;&gt;$A_{max2nd}$&lt;/span&gt; be the second largest.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A_{max2nd}$&lt;/span&gt;=&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i}A_{i}-A_{max2nd}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$A_{v'}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_{v}$&lt;/span&gt; be two decision variables that whose values are dependant on the value of &lt;span class=&quot;math-container&quot;&gt;$\alpha_{i,j}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\alpha_{i,j}$&lt;/span&gt; be a binary variable linking &lt;span class=&quot;math-container&quot;&gt;$A_{i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_{j}$&lt;/span&gt; such that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{(i,j)}\alpha_{i,j}\le1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\alpha_{i,j}=1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$A_{v'}=A_{max}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_{v}=A_{max2nd}$&lt;/span&gt; for any pairs of &lt;span class=&quot;math-container&quot;&gt;$i, j\in N$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;if no &lt;span class=&quot;math-container&quot;&gt;$\alpha_{i,j}$&lt;/span&gt; is equal to 1, then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{(i,j)}\alpha_{i,j}=0$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$A_{v}=A_{max}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_{v'}=0$&lt;/span&gt; (as &lt;span class=&quot;math-container&quot;&gt;$A_{max2nd}$&lt;/span&gt; and the other &lt;span class=&quot;math-container&quot;&gt;$A_{n}$&lt;/span&gt;s are 0, other than &lt;span class=&quot;math-container&quot;&gt;$A_{max}$&lt;/span&gt; which must always always be present)&lt;/p&gt;&#xA;&lt;p&gt;Appreciate your kind guidance in creating the constraints.&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="3682" LastEditDate="2020-09-09T11:19:58.220" LastActivityDate="2020-09-09T13:01:20.153" Title="Formulating indicator constraint set" Tags="|optimization|modeling|binary-variable|indicator-constraints|reformulation-linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4813" PostTypeId="1" CreationDate="2020-09-09T11:02:00.737" Score="3" ViewCount="116" Body="&lt;p&gt;I have a scheduling problem but rather than having a fixed duration of each task, we have another &amp;quot;concept&amp;quot; that verifies the following property.&#xA;Let's say task A requires a default 200 hours, then :&lt;/p&gt;&#xA;&lt;p&gt;i) It could be done in 400 hours if it's done by an employee whose efficiency is 0.5&lt;/p&gt;&#xA;&lt;p&gt;ii) It could be done in 100 hours if it's done by two employees both with full efficiency (i.e with an efficiency equal to 1)&lt;/p&gt;&#xA;&lt;p&gt;There will be some constraints like: each hour of the processing of the task, the working hours of employees could not exceed a threshold. For example if a task &amp;quot;default duration&amp;quot; is 200 hours, I cannot affect more than 16 working hours each hour which may correspond to 16 regular employees each hour.&lt;/p&gt;&#xA;&lt;p&gt;How do we call this problem? Are there any papers that deal with it?&lt;/p&gt;&#xA;" OwnerUserId="858" LastEditorUserId="858" LastEditDate="2020-09-09T11:18:16.867" LastActivityDate="2020-09-10T05:23:01.723" Title="How is this problem called in literature?" Tags="|scheduling|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4814" PostTypeId="2" ParentId="4797" CreationDate="2020-09-09T11:19:13.697" Score="4" Body="&lt;p&gt;Becoming a career academic (or a career anything for that matter) is a long process that requires focus, persistence, luck, and a plan. I have witnessed many disaster stories, so I will attempt to dispel a few common myths that seem to doom people into suffering consequences they did not expect.&lt;/p&gt;&#xA;&lt;p&gt;I will preface this by saying that if the goal is to just do interesting stuff, then winging it until retirement is a perfectly legitimate strategy. Just be mindful that in this case the higher echelons of a career's progression will most likely be closed off to you. Those are for the people who have worked for 30+ years with the specific goal of getting there.&lt;/p&gt;&#xA;&lt;p&gt;There are always exceptions to everything of course, but I'll stick to what's true in the vast majority of cases.&lt;/p&gt;&#xA;&lt;h2&gt;Myth #1: field/skill diversity is valued&lt;/h2&gt;&#xA;&lt;p&gt;This is only true for professional coders. Otherwise, if the goal is to maximise where people end up at the end of their professional life (and of course money), switching between things can set people back considerably unless done with a very specific plan.&lt;/p&gt;&#xA;&lt;p&gt;Think about it. If I'm willing to pay someone a lot of money to do X, and their value proposition is that &amp;quot;I know a bit of X, but I also know Y and Z (which are not useful to me who's doing the hiring). Because I'm very smart, I'll quickly combine my skills to become stellar in X&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;That doesn't work. I'd rather hire someone who already knows X deeply and can start producing value from day #1. The only reason to hire this other person for a high salary would be if I actually need that intersection of skills. Assuming I'm hiring someone who used to be a professor, it's highly likely that many of the core skills that they have developed over the years are useless in an industrial setting (e.g., supervising, teaching, grant writing).&lt;/p&gt;&#xA;&lt;h2&gt;Myth #2: Age doesn't matter&lt;/h2&gt;&#xA;&lt;p&gt;Switching from industry to academia is very possible in many cases. However, when it comes to building a career, it should be done within a couple of years of completing a PhD, because not publishing resets the academic clock. The truth of the matter is that universities prefer hiring young people for junior positions, so, e.g., a 40-year old who worked for 10 years in the industry and is now doing post-docs and seeking a lecturer position is just very unlikely to get it. This is even truer of more senior positions, because, as far as the committees are concerned, people with industrial experience don't have the skills a career professor needs, such as grant writing, teaching, supervising students, and a good academic network.&lt;/p&gt;&#xA;&lt;p&gt;I personally think this is short-sighted and discriminatory, but it is what it is - I even know career post-docs who were always runner-ups when applying for academic positions, and eventually became too old for committees to even consider, even though they had 50+ papers. They then had to go the industry.&lt;/p&gt;&#xA;&lt;h2&gt;Myth #3: A senior academic switching to the industry will be rich&lt;/h2&gt;&#xA;&lt;p&gt;This way around is much easier, but also not the way people think. An academic of 20 years switching to the industry will only get a fraction of the salary that a person who has been doing this job for 20 years would. There are many reasons why, but the most intuitive one is that the latter has a 20-year track record of delivering things that work. An academic seldom does. In fact, academia has a bad rep of only doing the work required for a publication, and never actually finishing things.&lt;/p&gt;&#xA;&lt;p&gt;There's always this myth of X professor being poached from MIT to work for Y company for a $gazillion, but those are far and few between. For most, switching to something they have never done before reduces their ability to get better/good salaries.&lt;/p&gt;&#xA;&lt;p&gt;The one exception to this myth is if one happens to be one of few academics with a track record of delivering things that are usable (e.g., world-class open source projects). Even in that case, it would typically be the person who actually wrote the code, not the person who supervised.&lt;/p&gt;&#xA;&lt;p&gt;Remember, this is not about who someone is as a person, it is about how they can leverage their track record to get a high salary in a highly competitive market.&lt;/p&gt;&#xA;&lt;h2&gt;Myth #4: Academic training positively affects one's earning potential&lt;/h2&gt;&#xA;&lt;p&gt;Studies have consistently shown that, on average, people with PhDs suffer from slower career progression and lower salaries that other people in their field who never did a PhD and went straight to the industry. According to the data, the less time people spend in academia, the better their earning potential becomes.&lt;/p&gt;&#xA;&lt;h2&gt;The bottomline&lt;/h2&gt;&#xA;&lt;p&gt;This might sound a bit bleak, but I need to stress that all of this only really applies to people whose primary drive is ambition, and risk not becoming what they wanted to be because of bad choices (and thus are not happy). As far as I'm concerned, the main driver behind building a career should be passion. This might ring true if you have ever discussed career prospects with an artist. Many know that the odds of making it big by pursuing their passion are tiny, but they do it anyway because they love it, and that's how it should be. The ones who do make it big are either very lucky, or, most likely, have spent their entire life working tirelessly, following a well laid-out plan of how to get there.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-09-09T11:41:36.417" LastActivityDate="2020-09-09T11:41:36.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4815" PostTypeId="2" ParentId="4813" CreationDate="2020-09-09T12:48:31.300" Score="3" Body="&lt;p&gt;The setting where processing times are variables dependent on the allocated resources, rather than constants, is usually called scheduling with controllable processing times. A very good survey of this problem is:&lt;/p&gt;&#xA;&lt;p&gt;Shabtay, D., &amp;amp; Steiner, G. (2007). A survey of scheduling with controllable processing times. Discrete Applied Mathematics, 155(13), 1643-1666.&lt;/p&gt;&#xA;&lt;p&gt;that is available at:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0166218X0700025X&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sciencedirect.com/science/article/pii/S0166218X0700025X&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="660" LastActivityDate="2020-09-09T12:48:31.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4816" PostTypeId="2" ParentId="4812" CreationDate="2020-09-09T13:01:20.153" Score="2" Body="&lt;p&gt;Do you mean &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v’$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;If so, the constraints you want are &lt;span class=&quot;math-container&quot;&gt;$\alpha_{i,j}\le A_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha_{i,j}\le A_j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-09-09T13:01:20.153" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4817" PostTypeId="1" AcceptedAnswerId="4822" CreationDate="2020-09-09T13:51:39.650" Score="1" ViewCount="1053" Body="&lt;p&gt;My objective function is &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2}w^{T}Vw - P^{T}w$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; a covariance matrix (hence semidefinite positive), &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; a column vector and &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; a vector of semi-continuous variables.&lt;/p&gt;&#xA;&lt;p&gt;Given that the objective function is a quadratic form, the problem is convex.&#xA;However, whenever I try to solve my problem I have the following error :&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Error: Model has non-convex objective&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;DOcplexException: Model&amp;lt;MIQP&amp;gt; did not solve successfully&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The problem is clearly convex though, and I have checked that all the eigenvalues of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; are positive or null. When I replace &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; by a trivial semidefinite positive matrix such as the identity matrix, the algorithm works and returns the solution, so the error must come from the matrix &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is there any way to know why there's a problem with &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; ? It is a bounded matrix with no NaN values.&lt;/p&gt;&#xA;" OwnerUserId="3756" LastEditorUserId="2477" LastEditDate="2020-09-16T01:40:56.913" LastActivityDate="2020-09-16T01:40:56.913" Title="Docplex Error: Model has non-convex objective" Tags="|docplex|numerical-issues|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4818" PostTypeId="2" ParentId="4817" CreationDate="2020-09-09T14:21:17.000" Score="3" Body="&lt;p&gt;Cplex can minimize convex quadratic objectives, or maximize concave ones.&#xA;For example, minimizing &lt;span class=&quot;math-container&quot;&gt;$x^2+y^2$&lt;/span&gt; is OK, but minimizing &lt;span class=&quot;math-container&quot;&gt;$x^2 -y^2$&lt;/span&gt; is not.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/cont_optim/qp/02_convexity_defn.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; page for more details:&lt;/p&gt;&#xA;&lt;p&gt;As mentioned in the page, you can set the parameter &lt;code&gt;optimalitytarget&lt;/code&gt; to 2 to proceed and accept the risk of finding a local optimum. If so, Cplex will not stop and look for an optimum (possibly local).&lt;/p&gt;&#xA;" OwnerUserId="4075" LastEditorUserId="36" LastEditDate="2020-09-09T14:55:23.960" LastActivityDate="2020-09-09T14:55:23.960" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4819" PostTypeId="1" AcceptedAnswerId="4820" CreationDate="2020-09-09T15:35:38.593" Score="4" ViewCount="196" Body="&lt;p&gt;I have these two constraints :&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z \leq My$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t \leq M'y $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; are two integer variables &lt;span class=&quot;math-container&quot;&gt;$ z, t\geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a binary variable,  and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M'$&lt;/span&gt; are two big numbers.&lt;/p&gt;&#xA;&lt;p&gt;So basically these constraints ensure that if &lt;span class=&quot;math-container&quot;&gt;$y = 1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$z, t \leq M , M'$&lt;/span&gt; respectively, otherwise &lt;span class=&quot;math-container&quot;&gt;$z,t = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However these constraints won't give me a positive value for &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$z &amp;gt; 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My question is : how to connect variables &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; to ensure that if &lt;span class=&quot;math-container&quot;&gt;$z &amp;gt; 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$t &amp;gt; 0$&lt;/span&gt; .&lt;/p&gt;&#xA;&lt;p&gt;The logical constraint that I want to write is as following:&lt;/p&gt;&#xA;&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$y= 1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$z &amp;gt;0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t&amp;gt;0$&lt;/span&gt; .&lt;/p&gt;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="3981" LastActivityDate="2020-09-09T16:08:18.617" Title="Formulating these logical constraint in an ILP" Tags="|mixed-integer-programming|linear-programming|linearization|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4820" PostTypeId="2" ParentId="4819" CreationDate="2020-09-09T16:08:18.617" Score="7" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; be a tolerance for what you consider positive.  Now impose linear constraints &lt;span class=&quot;math-container&quot;&gt;$z \ge \epsilon y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t \ge \epsilon y$&lt;/span&gt;.  Because &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; are integer variables, you can take &lt;span class=&quot;math-container&quot;&gt;$\epsilon=1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-09-09T16:08:18.617" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4821" PostTypeId="1" AcceptedAnswerId="4824" CreationDate="2020-09-09T22:30:01.013" Score="2" ViewCount="149" Body="&lt;p&gt;I have system with &lt;span class=&quot;math-container&quot;&gt;$N_U$&lt;/span&gt; users and &lt;span class=&quot;math-container&quot;&gt;$N_T$&lt;/span&gt; transmitters. Multiple transmitters can transmit to a single users and one transmitter can transmit to many users, i.e., two sets of transmitters serving two different users can have one or more common transmitters.&lt;/p&gt;&#xA;&lt;p&gt;When a transmitter does not transmit to a given user, it acts an an interferer to the given user, i.e., its transmission deteriorates the overall signal quality.&lt;/p&gt;&#xA;&lt;p&gt;I want to maximum the minimum of all users' signal qualities. The formulation I created like this&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max \hspace{2mm}\min_{u=1,\cdots,N_{U}}\hspace{2mm}Q_u$$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{subject to}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Q_u=\frac{\sum_{t\in \mathcal{C}_u}P_{t,u}}{\sum_{t\notin \mathcal{C}_u,t\in\mathcal{T}}P_{t,u}+\sigma}$$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$||\mathcal{C}_u||\le 5, \forall u$$&lt;/span&gt;\&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$\mathcal{T}$&lt;/span&gt; is the set of all the transmitters, &lt;span class=&quot;math-container&quot;&gt;$\mathcal{C}_u$&lt;/span&gt; is the set of transmitters serving user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$P_{t,u}$&lt;/span&gt; is the transmission power from transmitter &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; to user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; is a known parameter. &lt;span class=&quot;math-container&quot;&gt;$Q_u$&lt;/span&gt; is the quality of user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;.&lt;span class=&quot;math-container&quot;&gt;$||\mathcal{C}_u||$&lt;/span&gt; is the cardinality of set &lt;span class=&quot;math-container&quot;&gt;$\mathcal{C}_u$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$P_{t,u}$&lt;/span&gt; is a known value. So, the optimization is all about finding the set &lt;span class=&quot;math-container&quot;&gt;$\mathcal{C}_u, u=1,\cdots, N_U$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2020-09-17T09:26:52.043" LastActivityDate="2020-09-17T09:26:52.043" Title="Is my formulation correct and how to formulate this IF-THEN constraint?" Tags="|optimization|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4822" PostTypeId="2" ParentId="4817" CreationDate="2020-09-09T23:24:29.310" Score="3" Body="&lt;p&gt;The comment by @prubin is spot on.&lt;/p&gt;&#xA;&lt;p&gt;The V matrix is probably being numerically evaluated as not positive semidefinite by CPLEX. That can easily happen when one ore more eigenvalues are what you call null, i.e., theoretically equal to zero, i.e., zero in exact arithmetic.&lt;/p&gt;&#xA;&lt;p&gt;But CPLEX is using double precision floating point arithmetic, not exact arithmetic, so eigenvalues can numerically evaluate to negative. Or equivalently, a Cholesky decomposition can fail due to a negative diagonal element occurring in the decomposition which could not occur if the matrix were numerically positive semidefinite.&lt;/p&gt;&#xA;&lt;p&gt;Convex QP solvers, such as CPLEX with optimalitytarget =1, and Mosek, among others, can be quite fussy, and will produce an error message if the smallest eigenvalue numerically evaluates to even the slightest magnitude negative number.  If this is indeed the cause, again per @prubin 's suggestion, adding a small multiple, such as 1e-8, of the Identity matrix to V is a reasonable way of dealing with this. I will defer to you as ro whether your model formulation, containing a rank-deficient covariance matrix, is a good formulation for whatever your intended purpose (unbeknownst to me) of your model is.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-09-09T23:24:29.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4823" PostTypeId="2" ParentId="4810" CreationDate="2020-09-10T00:24:10.730" Score="4" Body="&lt;p&gt;To get the second largest variable when all are nonnegative and at most two can be nonzero, just take the sum of all of them and subtract the largest.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-09-10T00:24:10.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4824" PostTypeId="2" ParentId="4821" CreationDate="2020-09-10T01:21:06.127" Score="4" Body="&lt;p&gt;Introduce a variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$\min_u Q_u$&lt;/span&gt; in the objective, and let binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{t,u}$&lt;/span&gt; indicate whether transmitter &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; serves user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;.  Then replace &lt;span class=&quot;math-container&quot;&gt;$||\mathcal{C}_u||$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\sum_{t\in T} x_{t,u}$&lt;/span&gt; throughout.  Also &lt;span class=&quot;math-container&quot;&gt;$\sum_{t\in C_u} P_{t,u}$&lt;/span&gt; becomes &lt;span class=&quot;math-container&quot;&gt;$\sum_{t\in T} P_{t,u} x_{t,u}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\sum_{t\notin C_u} P_{t,u}$&lt;/span&gt; becomes &lt;span class=&quot;math-container&quot;&gt;$\sum_{t\in T} P_{t,u} (1-x_{t,u})$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To linearize the &lt;span class=&quot;math-container&quot;&gt;$$z \le \frac{\sum_{t\in T} P_{t,u} x_{t,u}}{\sum_{t\in T} P_{t,u} (1-x_{t,u})+\sigma}$$&lt;/span&gt; constraints, multiply both sides by the denominator and perform the usual linearization of the product of a binary variable and a continuous variable.&lt;/p&gt;&#xA;&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is a constant, the if-then logic is just fixing variables.&#xA;If &lt;span class=&quot;math-container&quot;&gt;$P_{t,u} \ge \alpha$&lt;/span&gt;, then fix &lt;span class=&quot;math-container&quot;&gt;$x_{t,u}=1$&lt;/span&gt; and fix &lt;span class=&quot;math-container&quot;&gt;$x_{t',u}=0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$t'\not=t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Here's an indirect approach that avoids products of decision variables.  We want to maximize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\left(\sum_{t\in T} P_{t,u} (1-x_{t,u})+\sigma\right) z &amp;amp;\le \sum_{t\in T} P_{t,u} x_{t,u} &amp;amp;&amp;amp; \text{for all $u$} \\&#xA;1 \le \sum_{t\in T} x_{t,u} &amp;amp;\le 5 &amp;amp;&amp;amp; \text{for all $u$} \\&#xA;x_{t,u} &amp;amp;= 1 &amp;amp;&amp;amp; \text{for all $t,u$ such that $P_{t,u} \ge \alpha$}\\&#xA;x_{t',u} &amp;amp;= 0 &amp;amp;&amp;amp; \text{for all $t,u$ such that $P_{t,u} \ge \alpha$ and $t'\not= t$} \\&#xA;x_{t,u} &amp;amp;\in\{0,1\} &amp;amp;&amp;amp; \text{for all $t,u$}&#xA;\end{align}&lt;/span&gt;&#xA;For fixed &lt;span class=&quot;math-container&quot;&gt;$z=\hat{z}$&lt;/span&gt;, this problem is linear.  Furthermore, if the problem is feasible for &lt;span class=&quot;math-container&quot;&gt;$z=\hat{z}$&lt;/span&gt;, then it is feasible for all &lt;span class=&quot;math-container&quot;&gt;$z \le \hat{z}$&lt;/span&gt;.  Similarly, if the problem is infeasible for &lt;span class=&quot;math-container&quot;&gt;$z=\hat{z}$&lt;/span&gt;, then it is infeasible for all &lt;span class=&quot;math-container&quot;&gt;$z \ge \hat{z}$&lt;/span&gt;.  So apply a bisection search to find the optimal &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;.  For an initial interval &lt;span class=&quot;math-container&quot;&gt;$[L,U]$&lt;/span&gt;, you can take &lt;span class=&quot;math-container&quot;&gt;$L=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U=\min_u\left(\sum_{t\in T} P_{t,u}\right)/\sigma$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-09-12T14:49:50.607" LastActivityDate="2020-09-12T14:49:50.607" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4825" PostTypeId="1" CreationDate="2020-09-10T04:38:38.167" Score="4" ViewCount="159" Body="&lt;p&gt;So, it's been about 15 years since I took my OR class in college. I'm not versed in any programming language besides a little bit of VBA.&lt;/p&gt;&#xA;&lt;p&gt;A client of mine is looking to solve the following problem. I tried to model it in excel and use OpenSolver, but there must be something I'm missing in the configuration of the solver engine, or in the problem setup.&lt;/p&gt;&#xA;&lt;p&gt;The idea is this:&#xA;Yo have a workforce of 50 teachers, and you have 30 classrooms. For each classroom you have the demand (in number of teachers) that must be in that room by 15 minute timeslots.&#xA;You have to minimize the cost of allocating teachers to rooms, while trying to respect the teachers restrictions (for example, if the teacher can't be in earlier than 8 am, or need to leave by 4 pm, or can't work more than 4 hours, or if they only want to be with the students in classrooms 1 or 2, etc.)&lt;/p&gt;&#xA;&lt;p&gt;I tried formulating this problem as a set covering problem and tried to solve it with OpenSolver, but despite my best efforts to linearize or to reconfigure the problem, I'm kind of lost.&#xA;I've uploaded a copy of my file to S3&#xA;&lt;a href=&quot;https://examplesforsolver.s3.amazonaws.com/HowWouldYouLinearizeThis.xlsx&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://examplesforsolver.s3.amazonaws.com/HowWouldYouLinearizeThis.xlsx&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, I decided to make a quick proof of concept using excel's evolutionary solver and OpenSolver's Nomad engine, but still, didn't work.&#xA;I've uploaded this file as well.&#xA;&lt;a href=&quot;https://examplesforsolver.s3.amazonaws.com/Very+Quick+Nomad+Test.xlsx&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://examplesforsolver.s3.amazonaws.com/Very+Quick+Nomad+Test.xlsx&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Please, take a look at the files. Any help will be greatly appreciated. But please bear in mind that neither myself or my client is versed in anything that is not excel, so coming up with a solution using Python, C++ or whatever else will not work.&lt;/p&gt;&#xA;&lt;p&gt;Thanks a lot for your help.&lt;/p&gt;&#xA;" OwnerUserId="4080" LastEditorUserId="123" LastEditDate="2020-09-10T09:43:19.033" LastActivityDate="2020-09-12T20:49:29.280" Title="How would you linearize this scheduling problem? Or how would you solve this? It is variation of a set coverage problem for OpenSolver" Tags="|optimization|linear-programming|excel|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4826" PostTypeId="2" ParentId="4813" CreationDate="2020-09-10T05:23:01.723" Score="2" Body="&lt;p&gt;As you mentioned, the problem is, allocating the adequate resources to each task to complete based on the resources efficiency, it sounds like a resource-constrained project schedule and one of its useful variants called mixed-model assembly line balancing. If you are interested to use an MP, you can find a dozen papers by googling if not, some useful heuristic methods can be applied. Some helpful references are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0278612513001222&quot; rel=&quot;nofollow noreferrer&quot;&gt;Modeling and solving mixed-model assembly line balancing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s11081-019-09462-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Production line balancing by P-graphs&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://ieeexplore.ieee.org/document/6035313&quot; rel=&quot;nofollow noreferrer&quot;&gt;Research on assembly line balancing based on labor proficiency&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://ijesc.org/upload/6dfbd9c7611e0d95bf57dcc6357b7d52.Line%20Balancing%20Technique%20for%20Labour%20Optimisation%20and%20Productivity%20Improvement.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Line Balancing Technique for Labour Optimisation and Productivity Improvement&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.asprova.com/en/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ASPROVA: Production Scheduling System (commercial software)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-09-10T05:23:01.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4827" PostTypeId="1" AcceptedAnswerId="4833" CreationDate="2020-09-10T07:38:20.837" Score="8" ViewCount="1605" Body="&lt;p&gt;What is the academic definition of robust optimization?&#xA;What are examples of robust optimization on:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;shift rostering&lt;/li&gt;&#xA;&lt;li&gt;vehicle routing problem&lt;/li&gt;&#xA;&lt;li&gt;facility location problem&lt;/li&gt;&#xA;&lt;li&gt;bin packing&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="350" LastEditorUserId="278" LastEditDate="2020-09-10T08:36:44.507" LastActivityDate="2020-09-10T20:57:50.957" Title="What is robust optimization?" Tags="|robust-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4828" PostTypeId="1" AcceptedAnswerId="4829" CreationDate="2020-09-10T10:00:35.307" Score="4" ViewCount="268" Body="&lt;p&gt;I would like to seek some advice on modeling the following:&lt;/p&gt;&#xA;&lt;p&gt;I have two integer decisions variables, &lt;span class=&quot;math-container&quot;&gt;$x, x'$&lt;/span&gt;, that are either equal or greater than zero and either of them is to be equated to a third integer decision variable, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, which is also equal or greater than zero in accordance to the value of a binary indicator variable, &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta=1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$x=z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta=0$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$x'=z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Appreciate your kind guidance.&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastActivityDate="2020-09-26T00:10:27.133" Title="Switching of decision variables to be equal to a certain decision variable according to a binary (indicator) variable" Tags="|modeling|integer-programming|logical-constraints|indicator-constraints|reformulation-linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4829" PostTypeId="2" ParentId="4828" CreationDate="2020-09-10T10:08:41.210" Score="4" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x \le z + M(1-\beta) \\&#xA;x \ge z - M(1-\beta) \\&#xA;x' \le z + M\beta \\&#xA;x' \ge z - M\beta \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\beta=1$&lt;/span&gt;, we have&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x \le z  \\&#xA;x \ge z  \\&#xA;x' \le z + M \\&#xA;x' \ge z - M \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which leads to &lt;span class=&quot;math-container&quot;&gt;$x=z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x'$&lt;/span&gt; unconstrained. And likewise if &lt;span class=&quot;math-container&quot;&gt;$\beta=0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-09-10T10:08:41.210" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="4830" PostTypeId="1" AcceptedAnswerId="4832" CreationDate="2020-09-10T12:24:59.533" Score="3" ViewCount="1380" Body="&lt;p&gt;As discussed &lt;a href=&quot;https://or.stackexchange.com/questions/1160/how-to-linearize-min-function-as-a-constraint&quot;&gt;here&lt;/a&gt;, the &lt;code&gt;min&lt;/code&gt; function, &lt;em&gt;i.e&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$X = \min\{x_1,x_2\}$&lt;/span&gt;, can be linearized as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;X &amp;amp; \le x_1 \\&#xA;X &amp;amp; \le x_2 \\&#xA;X &amp;amp; \ge x_1 - M(1-y) \\&#xA;X &amp;amp; \ge x_2 - My.&#xA;\end{align}&lt;/span&gt;&#xA;In this way, when &lt;span class=&quot;math-container&quot;&gt;$x_1&amp;lt;x_2$&lt;/span&gt; then the binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. However, when &lt;span class=&quot;math-container&quot;&gt;$x_1&amp;gt;x_2$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;. Nevertheless, for &lt;span class=&quot;math-container&quot;&gt;$x_1==x_2$&lt;/span&gt;, the binary variable y can either take &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; (free).&#xA;How can I force &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; also to be equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$x_1==x_2$&lt;/span&gt; in the above linearization?&lt;/p&gt;&#xA;" OwnerUserId="3500" LastActivityDate="2020-09-18T12:48:43.087" Title="How to linearize the Min function while letting the binary variable to be fixed for x1==x2 as well?" Tags="|mixed-integer-programming|linearization|logical-constraints|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4831" PostTypeId="2" ParentId="4830" CreationDate="2020-09-10T13:18:50.610" Score="2" Body="&lt;p&gt;side comment : in many tools you can use min directly and then you do not need to linearize.&lt;/p&gt;&#xA;&lt;p&gt;In OPL CPLEX&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar int x in 0..10;&#xA;dvar int y in 0..10;&#xA;dvar int z in 0..10;&#xA;&#xA;maximize (x-y);&#xA;subject to&#xA;{&#xA;  z==minl(x,y);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;works fine&lt;/p&gt;&#xA;&lt;p&gt;And&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar int x in 0..10;&#xA;dvar int y in 0..10;&#xA;dvar int z in 0..10;&#xA;&#xA;dvar boolean xlessthany;&#xA;&#xA;&#xA;subject to&#xA;{&#xA;  x==y;&#xA;  z==minl(x,y);&#xA;  xlessthany==(x&amp;lt;=y);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;if you want a boolean decision variable to know whether x is less than y&lt;/p&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2020-09-10T13:31:27.047" LastActivityDate="2020-09-10T13:31:27.047" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4832" PostTypeId="2" ParentId="4830" CreationDate="2020-09-10T15:02:31.707" Score="6" Body="&lt;p&gt;Consider the contrapositive &lt;span class=&quot;math-container&quot;&gt;$y=0 \implies x_1 \not= x_2$&lt;/span&gt;, equivalently, &lt;span class=&quot;math-container&quot;&gt;$y=0 \implies (x_1 &amp;lt; x_2 \lor x_1 &amp;gt; x_2)$&lt;/span&gt;.  Introduce a small constant tolerance &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt;, two additional binary variables &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_2$&lt;/span&gt;, and the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;1 - y &amp;amp;\le z_1 + z_2 \tag1 \\&#xA;x_1 +\epsilon - x_2 &amp;amp;\le M(1-z_1) \tag2 \\&#xA;x_2 +\epsilon - x_1 &amp;amp;\le M(1-z_2) \tag3&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$\neg y \implies (z_1 \lor z_2)$&lt;/span&gt;. Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$z_1 \implies x_1 + \epsilon \le x_2$&lt;/span&gt;.  Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$z_2 \implies x_2 + \epsilon \le x_1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-09-10T15:02:31.707" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4833" PostTypeId="2" ParentId="4827" CreationDate="2020-09-10T17:13:21.607" Score="16" Body="&lt;p&gt;In colloquial terms, Robust Optimization (RO) is a methodology (including modeling approach and computational methods) for handling optimization problems with uncertain data. Many times data aren't really measured exactly, and even more, in some contexts these measurement errors can trigger infeasibility on the optimization models (a quite undesirable behavior...). A common reference is &lt;em&gt;Robust Optimization&lt;/em&gt; by A. Ben-Tal, L. El Ghaoui, and A. Nemirovski, a free version can be found &lt;a href=&quot;https://www2.isye.gatech.edu/%7Enemirovs/FullBookDec11.pdf&quot; rel=&quot;noreferrer&quot;&gt;online in Nemirovski's website&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In RO, data are known to belong to an &lt;strong&gt;uncertainty set&lt;/strong&gt;. That's a different modelling approach to Stochastic Programming, where data come from a specific probability distribution. Here, the objective and constraint functions are assumed to belong to these uncertainty sets.  The goal is to make a decision that is feasible no matter what the constraints turn out to be, and optimal for the worst-case objective function.&lt;/p&gt;&#xA;&lt;p&gt;Adapting formal definitions and notation from &lt;a href=&quot;https://www2.isye.gatech.edu/%7Enemirovs/MP_RO_2002.pdf&quot; rel=&quot;noreferrer&quot;&gt;a publication by Ben-Tal and Nemirovski&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Ben-Tal, A., &amp;amp; Nemirovski, A. (2002). Robust optimization–methodology&#xA;and applications. &lt;em&gt;Mathematical programming, 92&lt;/em&gt;(3), 453-480.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;A generic mathematical programming problem is of the form:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;  \begin{array}{rrclcl}&#xA;  \displaystyle \min_{x_0 \in \mathbb{R}, x \in \mathbb{R}^n} &amp;amp; {x_0} \\&#xA;  \textrm{s.t.} &amp;amp; f_0(x,\zeta) &amp;amp; \leq &amp;amp; x_0 \\&#xA;  &amp;amp; f_i(x,\zeta) &amp;amp; \leq &amp;amp; 0 &amp;amp; &amp;amp; i = 1, \ldots, m \\&#xA;  \end{array}&#xA;  \end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in the &lt;em&gt;design vector&lt;/em&gt;, the functions &lt;span class=&quot;math-container&quot;&gt;$f_0$&lt;/span&gt; (objective function) and     &lt;span class=&quot;math-container&quot;&gt;$f_1,\ldots,f_m$&lt;/span&gt; are &lt;em&gt;structural elements&lt;/em&gt; of the problem, and &lt;span class=&quot;math-container&quot;&gt;$\zeta$&lt;/span&gt; stands for the   &lt;em&gt;data&lt;/em&gt; specifying a particular problem instance. This notation is quite general, as the functions could be linear or nonlinear.&lt;/p&gt;&#xA;&lt;p&gt;To take uncertainty into account a robust counterpart is associated to the previous problem, introducing an uncertainty set &lt;span class=&quot;math-container&quot;&gt;$\mathcal{U}$&lt;/span&gt; of all possible values for &lt;span class=&quot;math-container&quot;&gt;$\zeta$&lt;/span&gt;. That is, there are several (could be an infinite set) possible scenarios. The robust counterpart is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;  \begin{array}{rrclcll}&#xA;  \displaystyle \min_{x_0 \in \mathbb{R}, x \in \mathbb{R}^n} &amp;amp; {x_0} \\&#xA;  \textrm{s.t.} &amp;amp; f_0(x,\zeta) &amp;amp; \leq &amp;amp; x_0  &amp;amp; \forall \zeta \in \mathcal{U} \\&#xA;  &amp;amp; f_i(x,\zeta) &amp;amp; \leq &amp;amp; 0 &amp;amp; i = 1, \ldots, m, \; \forall \zeta \in \mathcal{U} \\&#xA;  \end{array}&#xA;  \end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Citing from the source:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;For real-world optimization problems, the &amp;quot;decision environment&amp;quot; is often characterized by the following facts:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The data are uncertain/inexact&lt;/li&gt;&#xA;&lt;li&gt;The optimal solution, even if computed very accurately, may be difficult to implement accurately&lt;/li&gt;&#xA;&lt;li&gt;The constraints &lt;em&gt;must&lt;/em&gt; remain feasible for &lt;em&gt;all&lt;/em&gt; the meaningful realizations of the data&lt;/li&gt;&#xA;&lt;li&gt;Problems are &lt;em&gt;large-scale&lt;/em&gt; (&lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; or/and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; are large)&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;Bad&amp;quot; optimal solutions (those which become severely infeasible in the face of even relatively small changes in the nominal data) are &lt;em&gt;not&lt;/em&gt; uncommon.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Facts 1. and 2. motivate the uncertainty set &lt;span class=&quot;math-container&quot;&gt;$\mathcal{U}$&lt;/span&gt; for the data, while 3. relates to including &lt;span class=&quot;math-container&quot;&gt;$\forall \zeta \in \mathcal{U}$&lt;/span&gt; into the constraints.&lt;/p&gt;&#xA;&lt;p&gt;So, the question is in which cases the latter optimization problem can be formulated as (or approximated by) a computationally tractable problem. The reference then goes on to study robust optimization for linear, conic quadratic and semidefinite programs.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;With regards to the second part of the question I remember the following one for routing, where they study a VRPTW with uncertain service times and solve realistic instances via branch and price:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Souyris, S., Cortés, C. E., Ordóñez, F., &amp;amp; Weintraub, A. (2013). A&#xA;robust optimization approach to dispatching technicians under&#xA;stochastic service times. &lt;em&gt;Optimization Letters&lt;/em&gt;, 7(7), 1549-1568.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Other works consider uncertainty in demand and/or travel times. I'm not familiar with approaches for shift rostering, facility location or bin packing so I'd rather not speak of them (even though a Google Scholar search yields some cases), probably other people can lend a helpful hand on that.&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="2477" LastEditDate="2020-09-10T20:57:50.957" LastActivityDate="2020-09-10T20:57:50.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4834" PostTypeId="1" AcceptedAnswerId="4901" CreationDate="2020-09-11T16:37:44.547" Score="5" ViewCount="655" Body="&lt;p&gt;I am trying to solve a vehicle routing problem using Tabu search. I have successfully completed implementing the constraints for CVRP by giving penalties to in the objective function. How do I implement time windows as a constraint?&lt;/p&gt;&#xA;" OwnerUserId="2958" LastEditorUserId="491" LastEditDate="2022-02-16T13:46:25.890" LastActivityDate="2022-02-16T13:46:25.890" Title="How to represent time windows as a constraint in a vehicle routing problem?" Tags="|combinatorial-optimization|vehicle-routing|metaheuristics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4835" PostTypeId="1" CreationDate="2020-09-11T21:10:09.277" Score="11" ViewCount="1684" Body="&lt;p&gt;I want to learn more about solvers by reading the code of some open-source projects such as &lt;a href=&quot;https://github.com/minotaur-solver/minotaur&quot; rel=&quot;nofollow noreferrer&quot;&gt;MINOTAUR&lt;/a&gt;, &lt;a href=&quot;https://github.com/kiegroup/optaplanner&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optaplanner&lt;/a&gt; and &lt;a href=&quot;https://github.com/google/or-tools&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR-Tools&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, I am struggling. I don't know where to start from there are a lot of repositories and files with no high-level overview. I don't know if I need to start with smaller solvers (in this case feel free to suggest one or more) or I need to learn how to approach open-source projects in general (any references for that?).&lt;/p&gt;&#xA;&lt;p&gt;I would be grateful if someone could provide some guidance.&lt;/p&gt;&#xA;" OwnerUserId="3711" LastEditorUserId="981" LastEditDate="2023-12-22T14:43:45.020" LastActivityDate="2023-12-22T14:43:45.020" Title="How to read open-source code of a solver (Or-tools, OptaPlanner, Minotaur, etc.)?" Tags="|solver|or-tools|applications|open-source|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4836" PostTypeId="1" AcceptedAnswerId="4837" CreationDate="2020-09-11T23:38:00.027" Score="4" ViewCount="63" Body="&lt;p&gt;I wonder if there is a special category for this kind of graphs, I am thinking of a bidirectional graph but it would also be interesting in the cases when it is undirected.&lt;/p&gt;&#xA;&lt;p&gt;I am thinking of something like &lt;strong&gt;recursively cyclic&lt;/strong&gt; maby.&lt;/p&gt;&#xA;" OwnerUserId="3762" LastEditorUserId="500" LastEditDate="2020-09-11T23:46:13.417" LastActivityDate="2020-09-11T23:46:13.417" Title="What is the name of the graph where any edge is part of a cycle?" Tags="|graphs|terminology|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4837" PostTypeId="2" ParentId="4836" CreationDate="2020-09-11T23:45:42.813" Score="8" Body="&lt;p&gt;Such a graph is called &lt;em&gt;bridgeless&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-09-11T23:45:42.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4838" PostTypeId="2" ParentId="4835" CreationDate="2020-09-12T02:31:03.190" Score="14" Body="&lt;p&gt;I read through the code of several solvers before developing &lt;a href=&quot;https://github.com/ds4dm/Tulip.jl&quot; rel=&quot;noreferrer&quot;&gt;Tulip.jl&lt;/a&gt;.&#xA;To be honest, unless you are yourself developing a solver/interface, or need to reproduce an author's implementation, there is probably a better use of your time than reading solvers' source code.&#xA;Reading the user guide or, when applicable, the paper(s) that describe the software's algorithmic components should definitely be your starting point.&#xA;In addition, as Kuifje mentions in their comment, begin familiar with a solver's interface makes it easier to understand its inner workings.&lt;/p&gt;&#xA;&lt;p&gt;That being said, I have found that, at least for linear programming, most of the algorithmic components are, overall, fairly similar.&#xA;Differences stem from particular choices of data structures and how modular the code is.&lt;/p&gt;&#xA;&lt;p&gt;To me, &lt;strong&gt;the most important part is knowing what you are looking for in the code.&lt;/strong&gt;&#xA;Is it to understand an algorithm's implementation? Specific data structures? How solvers parameters are handled?&#xA;This will help focus your work and not get lost.&lt;/p&gt;&#xA;&lt;p&gt;Here are another few factors I would take into account (I guess several are not specific to optimization software) when choosing which solvers to look at:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Documentation.&lt;/strong&gt;&#xA;Just don't expect to get much from un-documented source code.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Is the solver maintained?&lt;/strong&gt;&#xA;If a solver is maintained by several people, then those people will have looked at the code. That's a good indication that the source is readable, at least enough so that others have been able to modify it.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Programming language.&lt;/strong&gt;&#xA;It may sound obvious, but reading a language you're familiar with makes the task way easier.&#xA;Most solvers are written in C or C++, some old ones are in Fortran, and I know a few in Julia.&#xA;Similar paradigms may result in completely different implementations in different languages, though the basic ideas will most likely remain the same.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Which problems are supported?&lt;/strong&gt;&#xA;Data structures (and algorithms) vary widely between a linear programming solver and a non-linear programming one.&#xA;The former only needs matrices and vectors, the latter will likely include automatic differentiation tools, appropriate data structures for gradient and hessian computations.&#xA;Mixed-integer solvers add a layer of complexity with branching trees, etc...&#xA;Constraint Programming are another category altogether.&#xA;Thus, know what you're searching for.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;As for whether some solvers are more &amp;quot;readable&amp;quot; than others, my experience here is limited to (mixed-integer) linear programming, and a little of conic optimization.&#xA;I have found GLPK to be well-written and easy to follow. SCIP and Ipopt have good and extensive documentations, which to me is a requirement. I would not go near Clp's or Cbc's codebase unless you know what you are doing.&#xA;For conic optimization, ECOS is a light-weight interior-point solver in C.&#xA;HiGHS is a modern simplex solver for linear programming under active development.&#xA;Solvers written in higher-level languages such as Julia or Matlab may be easier to follow: Tulip's entire codebase is only ~4000 lines of code (Clp is ~180k, Ipopt ~75k, HiGHS ~50k).&lt;/p&gt;&#xA;&lt;p&gt;In most solvers' source code, you will find a &lt;code&gt;src/&lt;/code&gt; directory: this is where the source code will be.&#xA;I generally proceed as follows:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Identify which specific component I want to understand, e.g., how parameters are handled internally&lt;/li&gt;&#xA;&lt;li&gt;Make a quick search through the docs. Many times that is enough&lt;/li&gt;&#xA;&lt;li&gt;If not, peek at the code that's pointed to by the documentation. I generally start by looking at header files, and rarely look at source files directly.&lt;/li&gt;&#xA;&lt;li&gt;If there's anything I don't understand, e.g., some class or I don't know or function whose role is unclear, search where it is defined.&lt;/li&gt;&#xA;&lt;li&gt;Repeat.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2020-09-12T02:31:03.190" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4839" PostTypeId="2" ParentId="4835" CreationDate="2020-09-12T10:00:59.310" Score="5" Body="&lt;p&gt;Funny you should mention MINOTAUR, I actually learned C++ by modifying MINOTAUR's source code for my PhD.&lt;/p&gt;&#xA;&lt;p&gt;In my opinion, virtually no solver has documentation that helps understand how the code itself works and why it's put together the way it is.&lt;/p&gt;&#xA;&lt;p&gt;The reason is that the overall algorithms are straightforward, you can learn those in a couple of days. Solver magic lies in the data structures, and how information is formatted and passed efficiently for iterative calculations.&lt;/p&gt;&#xA;&lt;p&gt;The best way to understand the code is to try and modify it to do something different, but be warned that this can take many months.&lt;/p&gt;&#xA;&lt;p&gt;Here's a few tips I can give you:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Get a good IDE such as CLion. This will help you easily navigate the code, look up method usages, and so on.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't use Eclipse, you'll regret it. If you want a good free option, use VSCode.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't assume that all code is well written. I learned how CGraphs and AD work by modifying MINOTAUR's code. When we implemented that from scratch for Octeract Engine, our code for the CGraph was ~50 times smaller, and faster.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Many design choices are deliberate, even if, for the life of you, you can't fathom the motivation. The why becomes clear years later, when you run into the same bottlenecks the original developers did. Solvers use many tricks such as caching, vectorisation of calculations, and , unfortunately, global variables because it's really not obvious how to put together high performance code and keep it maintainable at the same time.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the solver is not designed using object-oriented programming don't waste your time reading the code. It will take forever and you will learn very little because you shouldn't code a solver that way nowadays.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For C++ try to replace pointer arguments to pass by value instead. This will force you to implement copy and move constructors, which will in turn help you understand the fundamental data structures.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Keep in mind that old-school solvers were written without modern compilers. Back in the day having one massive function instead of 100 small ones actually boosted performance. This is no longer true.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Try to break large functions into smaller ones.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Write tests for the solver so that you know that your modifications produced the same results. Ideally, use a CI platform like Jenkins.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use Git, and use it a lot.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-09-15T09:56:41.697" LastActivityDate="2020-09-15T09:56:41.697" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4840" PostTypeId="1" AcceptedAnswerId="4876" CreationDate="2020-09-12T16:41:57.500" Score="3" ViewCount="172" Body="&lt;p&gt;Suppose there are a few plants (p) and few customers (c). The supply (Sp), distance (Dpc), cost (COSTpc) and demand (DEMANDc) between them is given. I have a constraint that 90% of total demand of all customers should be satisfied by plants which are located within 100 miles of customers location. How should I write this type of constraint?&lt;/p&gt;&#xA;" OwnerUserId="1279" LastEditorUserId="38" LastEditDate="2020-09-14T01:02:00.463" LastActivityDate="2020-09-19T07:16:16.767" Title="How to write distance specific constraint?" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4841" PostTypeId="2" ParentId="4825" CreationDate="2020-09-12T20:18:28.983" Score="1" Body="&lt;p&gt;In general, you could try defining the problem as a linear programming problem and then use the simplex algorithm or Gaussian elimination to find a solution or understand that there is no feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;In theory, you write it as a system of equations and solve for the solution vector.&lt;/p&gt;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&lt;p&gt;We have a budget &lt;span class=&quot;math-container&quot;&gt;$b_{max}$&lt;/span&gt; and the sum of costs should not exceed &lt;span class=&quot;math-container&quot;&gt;$b_{max}$&lt;/span&gt; so that becomes a constraint of the model. &lt;span class=&quot;math-container&quot;&gt;$X_1+X_2+X_3+...+X_N &amp;lt; b_{max}$&lt;/span&gt;. You arrange all constraints to an equation system and solve it to get the solution vector. You can program it in Excel but it should be easier to invoke a stand-alone program if you are comfortable with a few rows of program for using the simplex algorithm or use the built-in Solver in Excel with the LP simplex algorithm.&lt;/p&gt;&#xA;&lt;p&gt;If you want to try Python, there are instructions on how to solve linear programming with python at this link &lt;a href=&quot;https://realpython.com/linear-programming-python/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://realpython.com/linear-programming-python/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2498" LastEditorUserId="36" LastEditDate="2020-09-12T20:49:29.280" LastActivityDate="2020-09-12T20:49:29.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4842" PostTypeId="2" ParentId="4835" CreationDate="2020-09-12T20:47:23.200" Score="5" Body="&lt;p&gt;There are software tools (typically language-specific, I think) that will ingest a software project and excrete a map of dependencies (basically, which methods / classes / files invoke something from which other methods / classes / files). If you pick an open-source project and run it through such a tool, you should be able to sort all the files etc. into a hierarchy. Then you can start with the top-level piece, read the code there and just make a note of what calls to other pieces are doing in general terms (&amp;quot;solves the model&amp;quot;, &amp;quot;exports an MPS file&amp;quot;, &amp;quot;checks data for consistency&amp;quot; ...) without getting into too much detail. Then work your way down the hierarchy as far as you care to go.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-12T20:47:23.200" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4844" PostTypeId="2" ParentId="4644" CreationDate="2020-09-13T18:45:47.467" Score="1" Body="&lt;p&gt;Adding a follow-up on how to style matrix multiplication-type constraints and objective function values.  This has been a major pain point for me, and now that I have a template, this will be a real productivity boost as I switch to being &amp;quot;MILPModel native&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Replace SYMPHONY with the solver of your choice...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;library(tidyverse)&#xA;library(magrittr)&#xA;library(ompr)&#xA;library(ompr.roi)&#xA;library(ROI.plugin.symphony)&#xA;&#xA;&#xA;rm(list=ls())&#xA;&#xA;&#xA;&#xA;set.seed(42)&#xA;&#xA;#in this example, mat1 is a numeric matrix representing coefficients for 40 binary decision variables&#xA;mat1 &amp;lt;- matrix(ncol=10,nrow=4,runif(400))&#xA;&#xA;#define this function, it will be necessary for matrix multiplication inside a MILPModel&#xA;matrix_multiplication_fcn &amp;lt;- function(static_matrix, row_variable, column_variable){&#xA;  vapply(seq_along(row_variable), function(k) static_matrix[row_variable[k], column_variable[k]], numeric(1L))  }&#xA;&#xA;milp_model &amp;lt;- ompr::MILPModel() %&amp;gt;%&#xA;  add_variable(assign_units[rowindex,colindex], rowindex=1:4,colindex=1:10,type='binary') %&amp;gt;%&#xA;  #total binaries ==10&#xA;  add_constraint(sum_expr( assign_units[rowindex,colindex],rowindex=1:4,colindex=1:10 )==10 ) %&amp;gt;%&#xA;  &#xA;  #sum of binaries * mat1 &amp;lt;= 7&#xA;  add_constraint( sum_expr( ompr::colwise(&#xA;    matrix_multiplication_fcn(static_matrix=mat1,row_variable=rowindex,column_variable=colindex)) *&#xA;                              assign_units[rowindex,colindex], &#xA;                            rowindex = 1:4, colindex = 1:10) &amp;lt;= 7) %&amp;gt;%&#xA;&#xA;  #objective: maximize value&#xA;  set_objective(sum_expr(&#xA;    ompr::colwise(matrix_multiplication_fcn(static_matrix=mat1,row_variable=rowindex,column_variable=colindex)) * &#xA;      assign_units[rowindex,colindex],&#xA;    rowindex=1:4,colindex=  1:10),sense='max')&#xA;    &#xA;milp_model_out &amp;lt;-  milp_model %&amp;gt;%   &#xA;  ompr::solve_model(with_ROI(solver = &amp;quot;symphony&amp;quot;,verbosity=-2,gap_limit=0,time_limit=180, node_limit=-1,first_feasible=FALSE))&#xA;&#xA;&#xA;#same with MIPModel&#xA;&#xA;mip_model &amp;lt;- ompr::MIPModel() %&amp;gt;%&#xA;  add_variable(assign_units[rowindex,colindex], rowindex=1:4,colindex=1:10,type='binary') %&amp;gt;%&#xA;  #total binaries ==10&#xA;  add_constraint(sum_expr( assign_units[rowindex,colindex],rowindex=1:4,colindex=1:10 )==10 ) %&amp;gt;%&#xA;  &#xA;  #sum of binaries * mat1 &amp;lt;= 7&#xA;  add_constraint( sum_expr( mat1[rowindex,colindex] * assign_units[rowindex,colindex], &#xA;                            rowindex = 1:4, colindex = 1:10) &amp;lt;= 7) %&amp;gt;%&#xA;  &#xA;  #objective: maximize value&#xA;  set_objective(sum_expr(mat1[rowindex,colindex] * assign_units[rowindex,colindex],&#xA;    rowindex=1:4,colindex=  1:10),sense='max')&#xA;&#xA;mip_model_out &amp;lt;-  mip_model %&amp;gt;%   &#xA;  ompr::solve_model(with_ROI(solver = &amp;quot;symphony&amp;quot;,verbosity=-2,gap_limit=0,time_limit=180, node_limit=-1,first_feasible=FALSE))&#xA;&#xA;#compare results, both should be slightly above 7 (thus slightly violating the constraint), I assume due to floating point issues&#xA;mip_model_out&#xA;milp_model_out&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3958" LastActivityDate="2020-09-13T18:45:47.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4845" PostTypeId="2" ParentId="4840" CreationDate="2020-09-14T01:08:18.267" Score="1" Body="&lt;p&gt;Declare a binary variable (say, &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;), that equals 1 if customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is within 100 miles of an open plant. For example, let &lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt; be a parameter (input) that equals 1 if customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and plant &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are within 100 miles of each other. Then the constraint says&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_i \le \sum_j a_{ij}x_j \quad \forall i,$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; is a decision variable that indicates whether plant &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is open.  (This is similar to a coverage-type model.)&lt;/p&gt;&#xA;&lt;p&gt;Then write a constraint that says at least 90% of total customer demand must be within 100 miles of a plant, i.e., must have &lt;span class=&quot;math-container&quot;&gt;$z_i=1$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i h_iz_i \ge 0.9\sum_i h_i,$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt; is the demand of customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-09-14T01:08:18.267" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4846" PostTypeId="2" ParentId="4840" CreationDate="2020-09-14T04:06:14.737" Score="3" Body="&lt;p&gt;The total demand is &lt;span class=&quot;math-container&quot;&gt;$\sum_c \text{DEMAND}_c$&lt;/span&gt;, and the amount satisfied by close enough plants is &lt;span class=&quot;math-container&quot;&gt;$$\sum_{\substack{p,c:\\D_{p,c}\le 100}} X_{p,c},$$&lt;/span&gt;&#xA;so your desired constraint is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{\substack{p,c:\\D_{p,c}\le 100}} X_{p,c} \ge 0.9 \sum_c \text{DEMAND}_c$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-09-14T04:06:14.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4847" PostTypeId="2" ParentId="4835" CreationDate="2020-09-14T06:45:08.227" Score="4" Body="&lt;p&gt;For &lt;a href=&quot;https://timefold.ai&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner/Timefold&lt;/a&gt;, start by understanding the School timetabling quickstart as explained in &lt;a href=&quot;https://timefold.ai/docs/timefold-solver/latest/quickstart/hello-world/hello-world-quickstart&quot; rel=&quot;nofollow noreferrer&quot;&gt;the docs&lt;/a&gt;. Enable &lt;code&gt;DEBUG&lt;/code&gt; and &lt;code&gt;TRACE&lt;/code&gt; logging to see what happens during a run. Then run that it a java debugger and start adding breakpoints to figure out what's going on.&lt;/p&gt;&#xA;&lt;p&gt;A quick run through of some of the important classes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SolutionDescriptor, EntityDescriptor, GenuineVariableDescriptor: translates annotations on the user's domain classes into a queryable metamodel.&lt;/li&gt;&#xA;&lt;li&gt;ScoreDirector calculates the score for a given solution&lt;/li&gt;&#xA;&lt;li&gt;DefaultSolver: the actual solver implementation&lt;/li&gt;&#xA;&lt;li&gt;DefaultLocalSearchPhase: the actual local search implementation. Start here if you want to see the algorithms at work. This holds the &amp;quot;step iteration&amp;quot; and delegates finding the winning the step to ...&lt;/li&gt;&#xA;&lt;li&gt;LocalSearchDecider, this has the &amp;quot;move evaluation iteration&amp;quot;: it selects a move from the MoveSeletor, does the move, asks ScoreDirector to calculate the score, accepts it with an Acceptor, undoes the move. Until it picks a move as the winning step.&lt;/li&gt;&#xA;&lt;li&gt;TabuSearchAccepter, SimulatedAnnealingAccepter, etc: the local search variant implementations.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2023-12-08T08:00:31.373" LastActivityDate="2023-12-08T08:00:31.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4849" PostTypeId="2" ParentId="4835" CreationDate="2020-09-14T15:38:58.523" Score="5" Body="&lt;p&gt;For the last few releases of the &lt;a href=&quot;https://www.scipopt.org&quot; rel=&quot;noreferrer&quot;&gt;SCIP Optimization Suite&lt;/a&gt; there have been &lt;a href=&quot;https://www.scipopt.org/index.php#cite&quot; rel=&quot;noreferrer&quot;&gt;technical papers covering the new features and improvements&lt;/a&gt; - basically a very detailed CHANGELOG.&lt;/p&gt;&#xA;&lt;p&gt;This might be a possible starting point as the source code is quite complex - which is true for just about any solver.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2020-09-14T15:38:58.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4850" PostTypeId="1" AcceptedAnswerId="4853" CreationDate="2020-09-14T19:06:18.547" Score="3" ViewCount="189" Body="&lt;p&gt;Let's say I have 3 type of sensors: &lt;strong&gt;A&lt;/strong&gt;, &lt;strong&gt;B&lt;/strong&gt;, &lt;strong&gt;C&lt;/strong&gt;. These sensors can be connected to multiple devices at the same time: let's call them &lt;strong&gt;dA&lt;/strong&gt;, &lt;strong&gt;dB&lt;/strong&gt; and &lt;strong&gt;dC&lt;/strong&gt;. Now, device &lt;strong&gt;dA&lt;/strong&gt; can only accept connections of sensor of type &lt;strong&gt;A&lt;/strong&gt;. Device &lt;strong&gt;dB&lt;/strong&gt; can only accept connections of sensor of type &lt;strong&gt;A&lt;/strong&gt; and &lt;strong&gt;B&lt;/strong&gt;. Device &lt;strong&gt;dC&lt;/strong&gt; can only accept connections of sensors of type &lt;strong&gt;C&lt;/strong&gt;. One sensor can be connected to multiple devices. Every device must have one sensor (and no more) connected to it. The number of sensors can be &lt;strong&gt;smaller&lt;/strong&gt; than the number of devices.&lt;/p&gt;&#xA;&lt;p&gt;What's the best way to find a general solution in polynomial time (if possible!) for a problem like this? Please tell me if I have explained the problem in a clear manner.&lt;/p&gt;&#xA;" OwnerUserId="4102" LastEditorUserId="2477" LastEditDate="2020-09-15T20:21:34.040" LastActivityDate="2020-09-15T20:21:34.040" Title="Optimal way of connecting N sensor to M devices in polynomial time?" Tags="|optimization|modeling|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4851" PostTypeId="2" ParentId="4850" CreationDate="2020-09-14T23:15:51.767" Score="2" Body="&lt;p&gt;I'm going to assume that (a) you want to minimize the number of sensors used and (b) there is no limit to the number of devices to which one sensor can be connected. (The second assumption seems shaky to me, but you did not mention a limit.) Under those assumptions, your problem can be reduced to an &lt;a href=&quot;https://en.wikipedia.org/wiki/Facility_location_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;uncapacitated facility location problem&lt;/a&gt; (UFLP), in which each sensor &lt;em&gt;type&lt;/em&gt; is a &amp;quot;facility&amp;quot;, each device is a &amp;quot;customer&amp;quot;, customers (devices) can only be assigned to compatible facilities (sensor types), and the objective is to minimize the number of facilities (sensor types). Given a solution, you just install one sensor of each selected type and hook it to the devices specified by the solution. This can be easily modified to minimize the cost of the selected sensors, if different types have different costs.&lt;/p&gt;&#xA;&lt;p&gt;I'm pretty sure the UFLP is NP-hard, and since your problem is equivalent to it, that should mean no polynomial time &lt;em&gt;exact&lt;/em&gt; solution is possible.&lt;/p&gt;&#xA;&lt;p&gt;If you have a limit on how many devices one sensor can support, you can tweak the model to make it a capacitated FLP by allowing a predefined number of sensors of each type (for instance five type A sensors, assuming that five would be enough to handle every type A-compatible device). You might want to throw in some antisymmetry constraints to improve model solution time.&lt;/p&gt;&#xA;&lt;p&gt;Polynomial time heuristics can of course be cobbled together, with no guarantee of optimality.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-14T23:15:51.767" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4852" PostTypeId="1" CreationDate="2020-09-15T03:42:04.887" Score="1" ViewCount="113" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$r_{m_h,s}(n)=\frac B{m_hb_\ell s}\log_2(1+\gamma_{m_h,s}(n))$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How to deal with multiple subproblems in &lt;strong&gt;Benders decomposition&lt;/strong&gt; when the original objective function is in &lt;strong&gt;product form&lt;/strong&gt; of an integer and multiple continuous variables within a &lt;strong&gt;log&lt;/strong&gt; function term?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max_{a,p,d_n}&amp;amp;\quad R_t-\eta_{EE}P_t^+\\\text{s.t.}&amp;amp;\quad (13)-(36)\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4103" LastEditorUserId="4103" LastEditDate="2020-09-15T07:25:33.813" LastActivityDate="2020-09-15T07:25:33.813" Title="Benders Decomposition Problem" Tags="|mixed-integer-programming|benders-decomposition|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4853" PostTypeId="2" ParentId="4850" CreationDate="2020-09-15T07:11:02.657" Score="3" Body="&lt;p&gt;@prubin assumed that the sensors are not &amp;quot;setup&amp;quot; yet, and that setting them up yields a fixed cost, for each sensor.&lt;/p&gt;&#xA;&lt;p&gt;If the sensors are already in place (this is not clear in the question), then you just want to assign devices to sensors, which you can model as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Minimum-cost_flow_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;min cost flow problem&lt;/a&gt;. Just add a Source node and link it to all the sensors, a Sink node which is linked to all devices. And add an edge with infinite capacity from nodes of type &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$B,C$&lt;/span&gt;) to all devices of type &lt;span class=&quot;math-container&quot;&gt;$dA$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$dB,dC)$&lt;/span&gt;. And then impose that the flow from the devices to the Sink must equal &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; exactly.&lt;/p&gt;&#xA;&lt;p&gt;Since the graph is bipartite, it can be solved in polynomial time.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-09-15T07:11:02.657" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4854" PostTypeId="2" ParentId="4835" CreationDate="2020-09-15T07:53:57.803" Score="4" Body="&lt;p&gt;The most important things have been said already but I want to add that in my opinion the best way to read code is to read it while stepping through a relatively easy test case in the debugger.&#xA;When looking at an LP or MILP solver I would start by stepping through a tiny instance to get an idea of the program flow, do that multiple times, and stepping into major functions as needed and inspecting the data structures. Then I would try larger or different kinds of problems to see more of the code or better understand its intricacies.&#xA;By the way, in my experience the best way to learn a code really well is trying to fix bugs in it...&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2020-09-15T07:53:57.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4855" PostTypeId="2" ParentId="4767" CreationDate="2020-09-15T09:55:27.093" Score="1" Body="&lt;p&gt;This is an interesting one. You could bring your graph into &lt;a href=&quot;https://en.wikipedia.org/wiki/Reverse_Polish_notation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Reverse Polish Notation&lt;/a&gt; form, which allows you to create a stack of nodes and evaluate in one vector pass.&lt;/p&gt;&#xA;&lt;p&gt;For what you want to do, you don't care about evaluation per se, but you can attach a &amp;quot;number of descendants&amp;quot; property to your nodes and propagate that organically as you would normally evaluate a graph - a &amp;quot;descendant arithmetic&amp;quot; if you will. The complexity for this should be roughly the same as evaluating the graph itself.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-09-15T09:55:27.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4856" PostTypeId="2" ParentId="23" CreationDate="2020-09-15T11:35:29.837" Score="5" Body="&lt;p&gt;Here is contrary advice provided by folks running CO@WORK2020 . I referenced this thread.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://app.slack.com/client/T018492NU8P/C018R5MJ8J1/thread/C018R5MJ8J1-1600131609.111100&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://app.slack.com/client/T018492NU8P/C018R5MJ8J1/thread/C018R5MJ8J1-1600131609.111100&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Mark L. Stone&lt;/strong&gt;&#xA;There is a large folklore, see for instance &lt;a href=&quot;https://or.stackexchange.com/questions/23/how-can-i-best-handle-symmetries-in-my-mip/101#101&quot;&gt;How can I best handle symmetries in my MIP?&lt;/a&gt; , that symmetries in MILP models are bad from a solver computation time perspective, Yet the advice in a lecture Monday was pretty much not to make symmetry-breaking changes to a model. Is neither &amp;quot;side&amp;quot; always or usually right?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Victorien Cornet&lt;/strong&gt;&#xA;@Mark L. Stone I understood it as &amp;quot;the program is most likely far better than you at detecting symmetries, and will have a not costly method to detect them and deal with them. As such, you should let him do it, because if by removing 50% of symmetry, you also hide the other 50%, you will make the problem computationally worse.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Paula Fermin&lt;/strong&gt;&#xA;@Mark L. Stone&#xA;There is a very good paper by Fischetti and Liberti (2012), with the title &amp;quot;Orbital Shrinking&amp;quot;, where they claim that symmetry is a beneficial feature that should be exploited. Instead of breaking it with artificial constraints (which they say it should only be done as a last resort) they capture it in the formulation.&#xA;As far as I know CPLEX and Gurobi use algorithms based on these ideas to exploit symmetry rather than breaking it. I'm not sure about other solvers. (edited)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Timo Berthold&lt;/strong&gt;  &amp;lt;organizer/lecturer at CO@WORK2020/developer at FICO XPRESS&amp;gt;&#xA;Xpress and SCIP do as well.&#xA;I am on Matteo's and Leo's page that in most cases, solvers would capture the whole symmetry structure and handle it accordingly, while user constraints easily (not always) fix only a part of the symmetry, but destroy the structure as a whole.That being said, if the modeler has a background in group theory and completely knows the symmetry structure of their problem, they might be able to handle things the solver can't. As one general example, note that solvers consider FORMULATION symmetry, which implies SOLUTION symmetry. Solution symmetry is a stronger concept. If your formulation is solution-symmetric, but not formulation-symmetric, it is up to you to handle this.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edi&lt;/strong&gt;t: Additional Q&amp;amp;A in the above linked thread&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Mark L. Stone&lt;/strong&gt;&#xA;Does it make sense to give the solver a chance to deal with the symmetries. And if it seems to have difficulties, to then consider adding symmetry-breaking constraints?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Timo Berthold&lt;/strong&gt;&#xA;@Mark L. Stone: Trying out different approches is hardly ever a bad idea. I believe that is what everyone can agree on (and what both sources explicitly stated, while coming to a different conclusion what the first choice would be)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Paula Fermin&lt;/strong&gt;&#xA;@Timo Berthold What is the difference between solution symmetry and formulation symmetry?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Timo Berthold&lt;/strong&gt;&#xA;@Paula Fermin Take an IP min Ax = b x \in Z^n. Let F be the set of feasible solutions of this IP. Let p be a permutation of (1...m) and q be a permutation of (1..n). If you apply p to Ax=b and subsequently q to the matrix permuted that way, this will give you a new IP A'x = b' with a new set of feasible solutions (same cardinality of course) F'. We call (p,q) a formulation symmetry if A=A' and b=b'. Of course this implies F=F'. The case that F=F' is called solution symmetry and it does not imply anything on the relation between A,b and A',b'. Of course this can be extended to MIP and the case that we have an objective c, but I wanted to keep notation short.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-09-17T20:13:04.350" LastActivityDate="2020-09-17T20:13:04.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4857" PostTypeId="1" CreationDate="2020-09-16T07:13:31.587" Score="3" ViewCount="114" Body="&lt;p&gt;Can we consider an optimal control problem, a convex optimization problem like static optimization problems? If it is possible, under what conditions, will this problem be a convex problem? For example, in the general problem as follows, how can we check the convexity of the problem (if we arrive to a solution, is it optimal or not)?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max_{u \in \mathcal{U}} Q(u) = \int_{0}^{T} F(x(t),u(t), t) dt + S(x(T),T) \\&#xA;\dot{x}(t)= f(x(t),u(t), t)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Moreover, is it possible to obtain an explicit form for &lt;span class=&quot;math-container&quot;&gt;$Q(u)$&lt;/span&gt;? When is &lt;span class=&quot;math-container&quot;&gt;$Q(u)$&lt;/span&gt; a concave of &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="139" LastEditDate="2020-09-16T22:49:18.177" LastActivityDate="2020-09-18T12:14:17.443" Title="How to evaluate the convexity of an optimal control problem?" Tags="|convexity|convex-optimization|optimal-control|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4858" PostTypeId="1" AcceptedAnswerId="4859" CreationDate="2020-09-16T15:04:00.487" Score="1" ViewCount="452" Body="&lt;p&gt;Let&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$P_{t,u}; t=1,2,\ldots,T, u=1,2,\ldots,U$&lt;/span&gt; be known values&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is also a known parameter&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{t,u}$&lt;/span&gt; an optimization variable&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I have the following constraint: IF &lt;span class=&quot;math-container&quot;&gt;$P_{t,u}\geq\alpha$&lt;/span&gt;, THEN &lt;span class=&quot;math-container&quot;&gt;$X_{t,u}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_{t',u}=0, t'\neq t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I linearize this constraint?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="500" LastEditDate="2020-09-16T17:14:52.033" LastActivityDate="2020-09-17T13:52:55.450" Title="How can I linearize this IF-THEN constraint?" Tags="|modeling|linearization|constraint-programming|logical-constraints|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4859" PostTypeId="2" ParentId="4858" CreationDate="2020-09-16T16:35:01.353" Score="5" Body="&lt;p&gt;Because &lt;span class=&quot;math-container&quot;&gt;$P_{t,u}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; are known constants (not decision variables), no linearization is needed.  In a modeling language, it would look like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;con Mycon1 {t in 1..T, u in 1..U: P[t,u] &amp;gt;= alpha}:&#xA;   X[t,u] = 1;&#xA;con Mycon2 {t in 1..T, u in 1..U, tp in 1..T diff {t}: P[t,u] &amp;gt;= alpha}:&#xA;   X[tp,u] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Some languages support this equivalent form with a single constraint declaration:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;con Mycon {t in 1..T, u in 1..U, tp in 1..T: P[t,u] &amp;gt;= alpha}:&#xA;   X[tp,u] = (if tp = t then 1 else 0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Even more compact:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;con Mycon {t in 1..T, u in 1..U, tp in 1..T: P[t,u] &amp;gt;= alpha}:&#xA;   X[tp,u] = (tp = t);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Some languages also support a FIX statement for equality constraints with one variable:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for {t in 1..T, u in 1..U, tp in 1..T: P[t,u] &amp;gt;= alpha}&#xA;   fix X[tp,u] = (tp = t);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;An alternative to declaring binary variables and then forcing them to 0 is to use a sparse index set, as demonstrated &lt;a href=&quot;https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=casmopt&amp;amp;docsetTarget=casmopt_optmodel_examples07.htm&amp;amp;locale=en&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-09-16T17:14:25.540" LastActivityDate="2020-09-16T17:14:25.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4860" PostTypeId="1" AcceptedAnswerId="4862" CreationDate="2020-09-16T19:09:44.507" Score="0" ViewCount="53" Body="&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; the set of all possible solutions, and &lt;span class=&quot;math-container&quot;&gt;$A \subseteq X$&lt;/span&gt; the set of&#xA;admissible solutions; a cost function is defined like this: &lt;span class=&quot;math-container&quot;&gt;$f:X \rightarrow R$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But it is not clear to me what the function intuitively represents (for example, how is it possible that the solutions are only real numbers? Can't they be, say, strings, pairs of numbers, etc?)&lt;/p&gt;&#xA;" OwnerUserId="4115" LastActivityDate="2020-09-17T03:52:34.603" Title="clarification on the definition of loss function" Tags="|loss-functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4861" PostTypeId="2" ParentId="4858" CreationDate="2020-09-16T19:58:55.130" Score="0" Body="&lt;p&gt;It is possible to translate into a linear programming formulation the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$ P_{t,u} \geq \alpha \rightarrow x_{t,u} =1$&lt;/span&gt;  and &lt;span class=&quot;math-container&quot;&gt;$x_{t’,u}=0 $&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$t’=1,2, …, T$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$t’\neq t$&lt;/span&gt;.&#xA;Let introduce &lt;span class=&quot;math-container&quot;&gt;$ T \cdot U $&lt;/span&gt; Boolean variables: &lt;span class=&quot;math-container&quot;&gt;$ x_{t,u} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Remembering that &lt;span class=&quot;math-container&quot;&gt;$ P_{t,u} \cdot \alpha^{-1}=P_{t,u} \cdot \frac{1}{\alpha} \geq 1 $&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$ P_{t,u} \geq \alpha$&lt;/span&gt;. So, the generic constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x_{t,u} \geq P_{t,u} \alpha^{-1} \rightarrow x_{t,u}=1 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;answers to our problem:&lt;/p&gt;&#xA;&lt;p&gt;Now we want to assign zero value to every remaining variables: it is sufficient to introduce the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{t=1}^T x_{t,u} = 1 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In general we introduce the following contraints as feasible region:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;x_{1,1} \geq P_{1,1} \alpha^{-1} \\&#xA;x_{2,1} \geq P_{2,1} \alpha^{-1}\\&#xA;\vdots \\&#xA;x_{T,1} \geq P_{T,1} \alpha^{-1} \\&#xA;\sum_{t=1}^T x_{t,1} = 1 \\&#xA;\vdots \\&#xA;x_{1,U} \geq P_{1,U} \cdot \alpha^{-1} \\&#xA;x_{2,U} \geq P_{2,U} \alpha^{-1} \\&#xA;\vdots \\&#xA;x_{T,U} \geq P_{T,U} \alpha^{-1} \\&#xA;\sum_{t=1}^T x_{t,U} = 1 \\&#xA;x_{t,u} Boolean \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4114" LastActivityDate="2020-09-16T19:58:55.130" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4862" PostTypeId="2" ParentId="4860" CreationDate="2020-09-17T03:52:34.603" Score="3" Body="&lt;p&gt;We want to measure the quality of a solution, that is given two solutions, &lt;span class=&quot;math-container&quot;&gt;$x, y \in A$&lt;/span&gt;, I want to tell if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a better solution than &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Real numbered as an ordered field enable us to compare two solutions conveniently.&lt;/p&gt;&#xA;&lt;p&gt;For example, for a minimization problem, we can say that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a better solution than &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$f(x) &amp;lt; f(y)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It can carry meaning of operation cost or approximation error, something that you want to minimize.&lt;/p&gt;&#xA;&lt;p&gt;However, in general, of course, it is possible that you might want to measure something based on different quantity and obtained a tuple instead. You can define own notion of comparison, &lt;span class=&quot;math-container&quot;&gt;$&amp;lt;$&lt;/span&gt;. For example, we might want to define things to be compared lexicographically. It is possible but for the scope of the text/paper that you read, they might want to study a particular class of problem.&lt;/p&gt;&#xA;" OwnerUserId="85" LastActivityDate="2020-09-17T03:52:34.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4863" PostTypeId="1" AcceptedAnswerId="4865" CreationDate="2020-09-17T11:34:48.943" Score="2" ViewCount="117" Body="&lt;p&gt;The variation of the average price of a product over a longer period is generally lower than a shorter period. I am interested to capture both uncertainties as to the input of the stochastic programming problem. Let's say the average price of oil in a week has a mean of &lt;span class=&quot;math-container&quot;&gt;$\overline{\lambda}_{w}$&lt;/span&gt; and std of &lt;span class=&quot;math-container&quot;&gt;$\sigma_{w}$&lt;/span&gt;. Thus, the N samples representing the weakly average price of oil can be shown by &lt;span class=&quot;math-container&quot;&gt;$\lambda_{wi}, \ wi=1...N$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, let's represent the daily variations of oil price regarding each above mentioned generated sample with M other samples, e.g. &lt;span class=&quot;math-container&quot;&gt;$\lambda_{wi}^{dj},\ j=1:M$&lt;/span&gt;. Specifically, for each &lt;span class=&quot;math-container&quot;&gt;$wi$&lt;/span&gt;, the uncertainty around the daily price, despite having the same mean as the weekly sample, i.e.  &lt;span class=&quot;math-container&quot;&gt;$\overline{\lambda_{wi}}^{dj=1:M} = \lambda_{wi}$&lt;/span&gt;, has a larger standard deviation, &lt;span class=&quot;math-container&quot;&gt;$\text{i.e } \sigma_{d}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To better illustrate, lets say we have &lt;code&gt;N=2&lt;/code&gt; samples regarding the average oil price during one week with the mean of &lt;span class=&quot;math-container&quot;&gt;$\overline{\lambda}_{w} = 100 \\\$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sigma_{w} = 20 \\\$$&lt;/span&gt;. Also, for each weakly sample, we have &lt;code&gt;M=3&lt;/code&gt; samples discirbing the daily variation of the price with &lt;span class=&quot;math-container&quot;&gt;$\overline{\lambda_{wi}}^{dj=1:M} = \lambda_{wi}$&lt;/span&gt; and  &lt;span class=&quot;math-container&quot;&gt;$ \sigma_{d} = 30$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{for } \lambda_{w1} = 80, \ \lambda_{d1}^{w1} = 50,\lambda_{d1}^{w1} =80,\lambda_{d1}^{w1}=110 \\&#xA;\text{for }  \lambda_{w2} = 120, \ \lambda_{d1}^{w2} = 90,\lambda_{d1}^{w2} = 120,\lambda_{d1}^{w2}=150$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assume that the uncertainty in both time periods can be modeled as a Gaussian distribution function.&lt;/p&gt;&#xA;&lt;p&gt;Q1) How can I generate &lt;code&gt;N&lt;/code&gt; samples with a mean of &lt;span class=&quot;math-container&quot;&gt;$\overline{\lambda}_{w}$&lt;/span&gt; and std of &lt;span class=&quot;math-container&quot;&gt;$\sigma_{w}$&lt;/span&gt; as well as &lt;code&gt;M&lt;/code&gt; other samples with mean of &lt;span class=&quot;math-container&quot;&gt;$\overline{\lambda_{wi}}^{dj=1:M} = \lambda_{wi}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sigma_{d} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Q2) How can I generate the above samples while considering the std of the daily price variations as a function of weekly average sample: e.g. &lt;span class=&quot;math-container&quot;&gt;$\sigma_{di} =  \lambda_{wi}/10$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If possible please give some hints for Matlab or Python implementation of such a sampling method.&lt;/p&gt;&#xA;" OwnerUserId="3500" LastActivityDate="2020-09-19T14:05:19.137" Title="How to generate correlated samples?" Tags="|stochastic-programming|uncertainty|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4864" PostTypeId="2" ParentId="4858" CreationDate="2020-09-17T13:52:55.450" Score="2" Body="&lt;p&gt;If I got the question correct you don't even need a constraint. You can simply define the lower and upper bounds on your variables &lt;span class=&quot;math-container&quot;&gt;$X_{t,u}$&lt;/span&gt; based on the parameters. For instance:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x[t,u] = model.addVar(lb = 1 if P[t,u] &amp;gt;= alpha else 0, ub = 1 if P[t,u] &amp;gt;= alpha else 0, vtype=&amp;quot;B&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If there isn't a &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; that fulfills &lt;span class=&quot;math-container&quot;&gt;$P_{t,u} \geq \alpha$&lt;/span&gt; you can define a new set &lt;span class=&quot;math-container&quot;&gt;$K:=\{(t,u)| P_{t,u} \geq \alpha \quad \forall t\in T, u \in U\}$&lt;/span&gt; and set the bounds accordingly to the set.&lt;/p&gt;&#xA;" OwnerUserId="2536" LastActivityDate="2020-09-17T13:52:55.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4865" PostTypeId="2" ParentId="4863" CreationDate="2020-09-17T19:28:45.587" Score="2" Body="&lt;p&gt;The issue you are describing has to do with the necessity of accounting for both short- and long-term dynamics in a decision problem under uncertainty, or in general uncertainty at different levels of resolution.&#xA;There are two issues here.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The practical implementation of a stochastic program lives on a scenario tree. So the first issue is how to arrange random data in a scenario tree accounting for different time resolutions. The authors of &lt;a href=&quot;https://link.springer.com/content/pdf/10.1007/s10287-013-0182-6.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this work&lt;/a&gt; suggest a so called &amp;quot;multi-horizon&amp;quot; scenario tree, which allows you to model exactly the issue you are describing, that is, uncertainty at different levels of resolution. In practice, when you populate your scenario tree, you would sample daily prices conditioning on the realization of the weekly prices.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How to concretely sample from a multivariate Gaussian in order to populate you scenario tree (and your stochastic program) with data. In Python you can use numpy to sample from a multivariate Gaussian. It is explained &lt;a href=&quot;https://numpy.org/doc/stable/reference/random/generated/numpy.random.multivariate_normal.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&#xA;For example:&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Import the necessary stuff&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from scipy.stats import multivariate_normal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Example data which you would have to populate based on your case&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;n_random_vars = 5&#xA;means = [10 for i in range(n_random_vars)] &#xA;covs = [[0 for x in range(n_random_vars))] for y in range(n_random_vars)] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Create a &lt;code&gt;multivariate_normal&lt;/code&gt; object&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mn = multivariate_normal(mean = means, cov = covs)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Draw random samples&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mn.rvs()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="766" LastEditorUserId="766" LastEditDate="2020-09-19T14:05:19.137" LastActivityDate="2020-09-19T14:05:19.137" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4866" PostTypeId="2" ParentId="4863" CreationDate="2020-09-18T01:06:09.493" Score="3" Body="&lt;p&gt;How to generate a multivariate Gaussian? It must be answered somewhere on Cross Validated, but I cannot find it now, some comments at &lt;a href=&quot;https://stats.stackexchange.com/questions/341805/are-mvrnorm-in-mass-r-package-and-rmvn-in-mgcv-r-package-equivalent/341808#341808&quot;&gt;https://stats.stackexchange.com/questions/341805/are-mvrnorm-in-mass-r-package-and-rmvn-in-mgcv-r-package-equivalent/341808#341808&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$X \sim \mathcal{N}(\mu, \Sigma)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\epsilon \sim \mathcal{N}(0,I)$&lt;/span&gt;. Then we can decompose the covariance matrix in different ways, say the Cholesky decomposition &lt;span class=&quot;math-container&quot;&gt;$\Sigma= C C^T$&lt;/span&gt; or by the spectral theorem &lt;span class=&quot;math-container&quot;&gt;$\Sigma=U \Lambda U^T = (U\Lambda^{1/2}) (U\Lambda^{1/2})^T$&lt;/span&gt; and then either&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \mu + C\epsilon$$&lt;/span&gt; or&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \mu + U \Lambda^{1/2} \epsilon$$&lt;/span&gt; does the trick.&lt;/p&gt;&#xA;" OwnerUserId="166" LastActivityDate="2020-09-18T01:06:09.493" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4867" PostTypeId="2" ParentId="4667" CreationDate="2020-09-18T06:45:49.030" Score="6" Body="&lt;p&gt;The vOptGeneric (&lt;a href=&quot;https://github.com/vOptSolver/vOptGeneric.jl&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/vOptSolver/vOptGeneric.jl&lt;/a&gt;) package of the vOptSolver includes the primitives for solving 2-objectives IP with weighted sum method, epsilon-constraint method and also Chalmet method. You can select GLPK, CPLEX or GUROBI as MIP solver (only one line to set up). vOptGeneric is implemented in Julia (&lt;a href=&quot;https://julialang.org/&quot; rel=&quot;noreferrer&quot;&gt;https://julialang.org/&lt;/a&gt;) and comes with JuMP (algebraic modeling language). The code is compliant with the last version of Julia and JuMP. I am currently updating the documentation.&lt;/p&gt;&#xA;&lt;p&gt;About MOMH, jMetal (java or C++ or now python) fits with your needs.&lt;/p&gt;&#xA;" OwnerUserId="4119" LastActivityDate="2020-09-18T06:45:49.030" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4868" PostTypeId="1" AcceptedAnswerId="4950" CreationDate="2020-09-18T09:55:19.393" Score="7" ViewCount="495" Body="&lt;p&gt;In my experience many OR Industry projects contains at least one person with background in OR (who is not familiar with the technical background) and at least one person from industry with the technical background, let's call them person1 and person2.&lt;/p&gt;&#xA;&lt;p&gt;In meetings between these persons the initial vague problem definition becomes clearer and clearer.&#xA;However there are many anecdotes that there are projects where person2 is missing to tell person1 some critical constraints, which have a huge impact on the model/ design of solving algorithms/results etc.&lt;/p&gt;&#xA;&lt;p&gt;What are strategies/tools/things to do in order to minimize the risk of missing &amp;quot;important&amp;quot; characteristics about the optimization problem?&lt;/p&gt;&#xA;&lt;p&gt;I thought as person1 about listing in a table all the assumptions that the models relies on and then explicitly discussing every assumption with person2 and also listing all effects which are left out because they &amp;quot;seem&amp;quot; not so important.&lt;/p&gt;&#xA;&lt;p&gt;I think this is very similar to requirement engineering in software development, but I wonder if there are additional details if there is a mathematical model involved.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="2477" LastEditDate="2020-09-19T00:12:38.353" LastActivityDate="2020-09-30T11:33:13.697" Title="How to reduce the risk of wrong modelling in OR industry projects?" Tags="|modeling|software|industry|practical-or|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4869" PostTypeId="2" ParentId="4857" CreationDate="2020-09-18T10:21:38.510" Score="1" Body="&lt;p&gt;I suggest to take a look at &amp;quot;&lt;em&gt;Foundations of Optimization&lt;/em&gt;&amp;quot; written by Osman Guler and edited by Springer in 2010. The 3rd chapter is wholly dedicated to Variational Principles and in 4.5 &amp;quot;&lt;em&gt;Optimization on Convex Sets&lt;/em&gt;&amp;quot; is stated that:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;One of the most important and basic proprieties of convex functions is the fact that any local minimizer on a convex set is a global one.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4114" LastEditorUserId="123" LastEditDate="2020-09-18T12:14:17.443" LastActivityDate="2020-09-18T12:14:17.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4870" PostTypeId="2" ParentId="4868" CreationDate="2020-09-18T12:23:21.907" Score="5" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;One way is to always start by modeling a &lt;strong&gt;baseline&lt;/strong&gt; (a model which pictures the current situation). Basically, if you are working with linear programming (for example), you write your model and add constraints that model the existing situation. Then you check your results and analyse some KPIs and make sure they match the company's current KPIs. This will give you (and your interlocutors) some confidence in your model. As @Mark L Stone says in the comment section, this is an iterative process.&lt;/p&gt;&#xA;&lt;p&gt;For example, if you are working with flows, constrain your model such that your model outputs the exact flows of the current situation. Then make sure you have the same sites, the same volumes, the same costs, etc. Once you have a valid baseline, it becomes your reference model that you need to optimize. This way you compare comparable objects.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Also, a rule of thumb that is (almost) always true : if your model's results do not match roughly a result that you obtain with very basic reasoning and calculations (which the decision maker will do on a corner of a sheet of paper when you show him your results), then it is very likely that there is something wrong with your model.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2020-09-18T12:46:50.030" LastActivityDate="2020-09-18T12:46:50.030" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4871" PostTypeId="2" ParentId="4830" CreationDate="2020-09-18T12:24:23.953" Score="1" Body="&lt;p&gt;Once we have remembered that &lt;span class=&quot;math-container&quot;&gt;$\min f(x)=-\max (-f(x))$&lt;/span&gt;, we wish Boolean variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is forced to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; whenever &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is free to be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, so we can add &lt;span class=&quot;math-container&quot;&gt;$-y$&lt;/span&gt; to the objective function &lt;span class=&quot;math-container&quot;&gt;$Z=-q_1p_1$&lt;/span&gt;, so that &lt;span class=&quot;math-container&quot;&gt;$Z’=-q_1p_1-y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In this way, &lt;span class=&quot;math-container&quot;&gt;$\min Z’$&lt;/span&gt; forces &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; to be equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$x_1=x_2$&lt;/span&gt; because of &lt;span class=&quot;math-container&quot;&gt;$$\min Z’=\min(-q_1p_1) + \min(-y)= \min Z - \max y.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In fact, &lt;span class=&quot;math-container&quot;&gt;$\max(y) \implies y=1$&lt;/span&gt; whenever &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is free to be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4114" LastEditorUserId="123" LastEditDate="2020-09-18T12:48:43.087" LastActivityDate="2020-09-18T12:48:43.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4872" PostTypeId="2" ParentId="1105" CreationDate="2020-09-18T15:44:57.053" Score="-1" Body="&lt;p&gt;With regards to the topic of Optimal Transportation Problem I strongly recommend&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;L.V. Kantorovich, On the Translocation of Masses (1942), in Management Science, vol. 5, n. 1, october 1958, pp. 1-4&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4114" LastActivityDate="2020-09-18T15:44:57.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4873" PostTypeId="2" ParentId="1340" CreationDate="2020-09-18T18:24:08.140" Score="1" Body="&lt;p&gt;A Boolean linear programming formulation is given for the problem.&lt;/p&gt;&#xA;&lt;p&gt;Let suppose to have &lt;span class=&quot;math-container&quot;&gt;$S=[ 1,2, \cdots, n ] $&lt;/span&gt; students and &lt;span class=&quot;math-container&quot;&gt;$T=[ 1,2, \cdots, m ]$&lt;/span&gt; training classes. Let introduce &lt;span class=&quot;math-container&quot;&gt;$m \cdot n $&lt;/span&gt; variables designated as &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$i=1,2, \cdots, n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j=1, 2, \cdots, m$&lt;/span&gt;.&#xA;For every student is know in advance his ready time that is the day in which student is available for training&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$r_1, r_2, \cdots, r_n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;UNKNOWNS&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x_{i,j} $&lt;/span&gt; is a Boolean variable whose value is 1 if i-th student is assigned to j-th training class,  0 otherwise.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;LESSONS/CLASSES CALENDAR AND DURATION&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$[t_{j,s} , t_{j,e} ]$&lt;/span&gt; is the Time Window of j-th class where &lt;span class=&quot;math-container&quot;&gt;$ t_{j,s} $&lt;/span&gt; is the start day of j-th class and &lt;span class=&quot;math-container&quot;&gt;$ t_{j,e} $&lt;/span&gt; is the end day of j-th class. It is clear that every class lasts &lt;span class=&quot;math-container&quot;&gt;$ d_j= t_{j,e} - t_{j,s}$&lt;/span&gt; days.&lt;/p&gt;&#xA;&lt;p&gt;We can introduce &lt;span class=&quot;math-container&quot;&gt;$n \cdot m$&lt;/span&gt; futher variables in order to take into account the waste time spent by i-th student in waiting for j-th class starts:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ w_{i,j} := t_{j,s} – r_i $&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i=1,2, \cdots, n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j=1, 2, \cdots, m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;OBJECTIVE FUNCTION&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;We desire to minimize the time spent by every student both in waiting for the course and in attending the course. If i-th student attends to the class l-th and p-th, we have &lt;span class=&quot;math-container&quot;&gt;$ x_{i,l}=1 $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ x_{i,p}=1 $&lt;/span&gt;, As a consequence, the waiting time for the two courses results as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ w_{i,l} \cdot x_{i,l} + w_{i,p} \cdot x_{i,p} = (t_{l,s} – r_i) + (t_{p,s}  – r_i) $&lt;/span&gt; days.&lt;/p&gt;&#xA;&lt;p&gt;The whole time spent in attending the two selected class is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ d_l \cdot x_{i,l} + d_p \cdot x_{i,p}   = (t_{l,e} - t_{l,s}) + (t_{p,e} - t_{p,s}) $&lt;/span&gt; days.&lt;/p&gt;&#xA;&lt;p&gt;In general, the student &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; will wait for&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{j=1}^m w_{i,j} \cdot x_{i,j} $&lt;/span&gt; days.&lt;/p&gt;&#xA;&lt;p&gt;The student &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; will spend for attending the selected classes&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{j=1}^m d_{j} \cdot x_{i,j} $&lt;/span&gt; days.&lt;/p&gt;&#xA;&lt;p&gt;Extending the sum to all students we get the following objective function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ z = \sum_{i=1}^n \sum_{j=1}^m (w_{i,j} + d_j ) \cdot x_{i,j}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We will seek &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}^*$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$ z^*= \min z $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, it remains to write the constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;NO OVERLAPED CLASSES&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \vdots $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;REQUIREMENTS FOR EVERY CLASS&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \vdots $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4114" LastActivityDate="2020-09-18T18:24:08.140" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4874" PostTypeId="2" ParentId="4868" CreationDate="2020-09-18T21:42:59.707" Score="5" Body="&lt;p&gt;Simulation experts have dealt with this question for years. If you do a search for &amp;quot;simulation validation&amp;quot; and/or &amp;quot;simulation face validation&amp;quot;, you will find lots of hits. As I recall it, most of the suggestions for how to validate simulation models also apply (or generalize) to other types of OR models.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-18T21:42:59.707" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4875" PostTypeId="2" ParentId="4868" CreationDate="2020-09-19T04:04:12.573" Score="5" Body="&lt;p&gt;In my experience the best way to manage risk in these kinds of situations is to correctly manage client expectation and avoid 'big design up front'. You should expect the unexpected - i.e. new constraints to appear that were not discussed up-front. You should arrange the project in an iterative manner, so come up with a model, test in a real-world setting (ensuring all stakeholders understand this is a testing or tuning phase for the model, not the final result, and issues are expected), find out what's wrong with it, correct this, and then repeat this cycle as many times as needed. So basically follow something closer to an agile methodology and not a waterfall pattern. Big design up front doesn't work well for OR models, so avoid it.&lt;/p&gt;&#xA;" OwnerUserId="825" LastActivityDate="2020-09-19T04:04:12.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4876" PostTypeId="2" ParentId="4840" CreationDate="2020-09-19T07:16:16.767" Score="0" Body="&lt;p&gt;The formulation of Leonid Kantorovich &lt;strong&gt;On the translocation of masses&lt;/strong&gt; has a simple expression in case of discrete optimal transportation problem. This formulation will be the starting point to answer to the question.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$ c_{i,j} $&lt;/span&gt; be the unitary cost of transportation for &lt;strong&gt;one unit&lt;/strong&gt; of good from plant &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to customer &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x_{i,j} $&lt;/span&gt; designates the quantity of goods which will be shipped from i-th plant to j-th customer. We do assume divisibility of goods so that &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j} $&lt;/span&gt; is a non-negative real number.&lt;/p&gt;&#xA;&lt;p&gt;The optimization of the following objective function gives the best “routes” which minimize the total cost of transportation while the demand is met at every customers location.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \min Z = \min \sum_{i=1}^p \sum_{j=1}^c c_{i,j}  \cdot x_{i,j}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;\sum_{j=1}^c x_{1,j} \leq Sp_1 \\&#xA;\vdots \\&#xA;\sum_{j=1}^c x_{p,j} \leq Sp_p \\&#xA;\sum_{i=1}^p x_{i,1} \geq DEMAND_1 \\&#xA;\vdots \\&#xA;\sum_{i=1}^p x_{i,c} \geq DEMAND_c \\&#xA;x_{ij} \geq 0 i=1,2, … ,p ; j=1,2,…, c \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;We wish to meet the 90% of total demand of all customers by means of plants which are located within 100 miles far from customers location. So, we can write:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;0,90 \cdot \sum_{j=1}^c DEMAND_j \leq \sum_{i=1}^p \sum_{j=1}^c x_{i,1} \\&#xA;z_{1,1} \cdot D_{1,1} \leq 100 \\&#xA;\vdots \\&#xA;z_{1,c} \cdot D_{1,c} \leq 100 \\&#xA;\vdots \\&#xA;z_{p,1} \cdot D_{p,1} \leq 100 \\&#xA;\vdots \\&#xA;z_{p,c} \cdot D_{p,c} \leq 100 \\&#xA;z_{i,j} \leq x_{i,j} \\&#xA;z_ij binary \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We have introduced &lt;span class=&quot;math-container&quot;&gt;$pc$&lt;/span&gt; auxiliary Boolean variables which will permit us to formulate the two following implications:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j}=0 \implies z_{i,j}=0  $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j}&amp;gt;0 \implies z_{i,j}=1 $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The feasible region designating the above logic implications is defined as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \min Z’ = \min (Z + \sum_{i=1}^p \sum_{j=1}^c z_{i,j}) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;x_{i,j} \leq M \cdot z_{i,j} \\&#xA;z_{ij} binary \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that if &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j}=0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_{i,j} \leq M \cdot z_{i,j}$&lt;/span&gt; is verified for &lt;span class=&quot;math-container&quot;&gt;$ z_{i,j} =0 $&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$ z_{i,j} =1 $&lt;/span&gt;. But, inserting &lt;span class=&quot;math-container&quot;&gt;$ z_{i,j} $&lt;/span&gt; in the objective function &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; permits us to force &lt;span class=&quot;math-container&quot;&gt;$ z_{i,j} $&lt;/span&gt; to assume the zero value by optimality.&lt;/p&gt;&#xA;&lt;p&gt;Because of &lt;span class=&quot;math-container&quot;&gt;$ z_{i,j} $&lt;/span&gt; is a Boolean variable whose value is 1 if  &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j} &amp;gt; 0 $&lt;/span&gt; and is 0 if if  &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j} = 0 $&lt;/span&gt;, we are able to select the i-th plant which is located within 100 miles far from j-th customer by means of constraint such as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ z_{i,j} \cdot D_{i,j} \leq 100 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Whenever &lt;span class=&quot;math-container&quot;&gt;$ z_{i,j} \cdot D_{i,j} \leq 100 $&lt;/span&gt; is violated, this means that &lt;span class=&quot;math-container&quot;&gt;$ z_{i,j}=0$&lt;/span&gt;. But, &lt;span class=&quot;math-container&quot;&gt;$z_{i,j}=0 \implies x_{i,j}=0$&lt;/span&gt;, therefore &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j} $&lt;/span&gt; is not selected as optimal route.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The proposed model selects as optimal solution the &lt;em&gt;routes&lt;/em&gt; minimizing the total cost of transportation while the 90% of total demand is served by plants located within 100 miles far from customers location. This means that model is unfeasible if there are not sufficiently plants “near” the customer meeting the 90% of total demand.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \min Z’ = \min (Z + \sum_{i=1}^p \sum_{j=1}^c z_{i,j}) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;\sum_{j=1}^c x_{i,j} \leq Sp_i \forall i\\&#xA;\sum_{i=1}^p x_{i,j} \geq DEMAND_j \forall j\\&#xA;z_{i,j} \cdot D_{i,j} \leq 100 \forall i,j\\&#xA;x_{i,j} \leq M \cdot z_{i,j} \forall i,j\\&#xA;x_{ij} \in R_0^+ \forall i,j\\&#xA;z_{ij} binary \forall i,j\\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4114" LastActivityDate="2020-09-19T07:16:16.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4877" PostTypeId="1" AcceptedAnswerId="4878" CreationDate="2020-09-19T08:41:24.560" Score="1" ViewCount="448" Body="&lt;p&gt;I would like to seek some advice on modeling the following:&lt;/p&gt;&#xA;&lt;p&gt;I have two integer decisions variables, &lt;span class=&quot;math-container&quot;&gt;$x, x'$&lt;/span&gt;, that are either equal or greater than zero and either of them is greater than or equal to a third integer decision variable, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, which is also equal or greater than zero in accordance to the value of a binary indicator variable, &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta=1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$x\ge z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta=0$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$x'\ge z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, I would also like to about the case for the opposite too:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta=1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$x\le z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta=0$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$x'\le z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Appreciate your kind guidance.&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="500" LastEditDate="2020-09-19T13:57:28.650" LastActivityDate="2020-09-19T16:27:27.373" Title="Switching of decision variables to be larger than or equal to a decision variable according to an indicator variable value" Tags="|modeling|integer-programming|linearization|logical-constraints|indicator-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4878" PostTypeId="2" ParentId="4877" CreationDate="2020-09-19T10:20:22.287" Score="2" Body="&lt;p&gt;A &lt;strong&gt;non-linear formulation&lt;/strong&gt; is given for &lt;span class=&quot;math-container&quot;&gt;$ x \geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ x’ \geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z \geq 0$&lt;/span&gt;  and &lt;span class=&quot;math-container&quot;&gt;$ \beta $&lt;/span&gt; binary.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;x \geq \beta \cdot z \\&#xA;x’ \geq (1- \beta) \cdot z \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$ \beta = 1 $&lt;/span&gt; we get&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;x \geq  z \\&#xA;x’ \geq 0 \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$ \beta = 0 $&lt;/span&gt; we get&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;x \geq  0 \\&#xA;x’ \geq z \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Oppositive case&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;z \geq \beta \cdot x \\&#xA;z \geq (1- \beta) \cdot x’ \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The following formulation is &lt;strong&gt;linear&lt;/strong&gt;, but it is valid only for &lt;span class=&quot;math-container&quot;&gt;$z &amp;lt; 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;x \geq (\beta -1) + z \\&#xA;x’ \geq - \beta + z \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As known, &lt;span class=&quot;math-container&quot;&gt;$ (0;1) \cong R$&lt;/span&gt;  meaning that a bijective function exists between the open interval and the set of real numbers. Also the generic interval &lt;span class=&quot;math-container&quot;&gt;$ (a;b) $&lt;/span&gt;  is isomorph to &lt;span class=&quot;math-container&quot;&gt;$ (0;1) $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ (a;b) \cong (0;1) $&lt;/span&gt;  by means of the following bijection:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ f(x):= (x-a)/(b-a) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thanks to this observation, the &lt;strong&gt;linear formulation&lt;/strong&gt; of the logical constraints can be given changing the interval where variables are defined. From &lt;span class=&quot;math-container&quot;&gt;$ x \geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ x’ \geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z \geq 0$&lt;/span&gt;  and &lt;span class=&quot;math-container&quot;&gt;$ \beta $&lt;/span&gt; binary, let introduce &lt;span class=&quot;math-container&quot;&gt;$ y := (x-a)/(b-a) $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ y’ := (x’-a)/(b-a) $&lt;/span&gt;’ &lt;span class=&quot;math-container&quot;&gt;$ w := (z-a)/(b-a) $&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; are suggested from the context of the examinated problem.&lt;/p&gt;&#xA;&lt;p&gt;‘&amp;gt; &lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;y \geq ( \beta - 1) + w \\&#xA;y’ \geq - \beta + w \\&#xA;y \in (0;1) \\&#xA;y’ \in (0;1) \\&#xA;w \in (0;1) \\&#xA;\beta binary \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4114" LastEditorUserId="4114" LastEditDate="2020-09-19T16:27:27.373" LastActivityDate="2020-09-19T16:27:27.373" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4879" PostTypeId="1" CreationDate="2020-09-19T12:11:19.303" Score="5" ViewCount="148" Body="&lt;p&gt;This problem comes from a problem of economics. Let &lt;span class=&quot;math-container&quot;&gt;$x\in [0,1]^n$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$\{x_1,x_2,\ldots,x_n\}$&lt;/span&gt; is partitioned into &lt;span class=&quot;math-container&quot;&gt;${S_1, S_2,\ldots,S_k}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\sum_{x_i\in S_j}x_i\leq 1$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$1\leq j\leq k$&lt;/span&gt;. This constraint can be restated as &lt;span class=&quot;math-container&quot;&gt;$Bx\leq 1$&lt;/span&gt; componentwise, where matrix &lt;span class=&quot;math-container&quot;&gt;$B \in \mathbb \{0,1\}^{k \times n}$&lt;/span&gt; and its component &lt;span class=&quot;math-container&quot;&gt;$b_{ij}=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_j\in S_i$&lt;/span&gt;. For instance, suppose &lt;span class=&quot;math-container&quot;&gt;$x=(x_1,x_2,x_3)$&lt;/span&gt; and the partition is &lt;span class=&quot;math-container&quot;&gt;$\{x_1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\{x_2,x_3\}$&lt;/span&gt;, this constraint can be written as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{gather*}&#xA;\begin{bmatrix} 1 &amp;amp; 0 &amp;amp; 0\\ 0 &amp;amp; 1 &amp;amp; 1 \end{bmatrix}\quad&#xA;\begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix}\quad \leq&#xA;\begin{bmatrix} 1 \\ 1 \end{bmatrix}&#xA;\end{gather*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let matrix &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb \{0,\pm 1\}^{m \times n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P = \{x\in[0,1]^n: Bx\leq 1 \text{componentwise}, Ax=c\}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c\in \mathbb{Z}^m$&lt;/span&gt; with each &lt;span class=&quot;math-container&quot;&gt;$c_i\leq 1$&lt;/span&gt; (possibly negative). &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is known to be nonempty. What condition on &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; would guarantee the existence of an integral vertex on &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;? From some examples I studied, my conjecture is that when &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is unimodular (not necessarily totally unimodular), &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; has at least an integral vertex.&lt;/p&gt;&#xA;" OwnerUserId="4123" LastEditorUserId="4123" LastEditDate="2020-09-22T18:24:58.320" LastActivityDate="2020-09-22T18:24:58.320" Title="When is there at least an integral point in a polyhedron?" Tags="|integer-programming|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4880" PostTypeId="2" ParentId="4877" CreationDate="2020-09-19T13:52:46.570" Score="3" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; be a binary variable and let &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; be a linear function bounded above by some constant &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. The standard approach to enforce &lt;span class=&quot;math-container&quot;&gt;$y=1 \implies f\le 0$&lt;/span&gt; is to impose linear big-M constraint &lt;span class=&quot;math-container&quot;&gt;$$f\le M(1-y)\tag1.$$&lt;/span&gt;  All four of your implications are of this form.  For the first one, take &lt;span class=&quot;math-container&quot;&gt;$y=\beta$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f=z-x$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, yielding &lt;span class=&quot;math-container&quot;&gt;$z-x\le M(1-\beta)$&lt;/span&gt;. For the second one, take &lt;span class=&quot;math-container&quot;&gt;$y=1-\beta$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f=z-x’$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, yielding &lt;span class=&quot;math-container&quot;&gt;$z-x’\le M\beta$&lt;/span&gt;. The other two are similar.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-09-19T13:52:46.570" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4881" PostTypeId="1" CreationDate="2020-09-19T21:49:26.273" Score="1" ViewCount="107" Body="&lt;p&gt;I need to optimize the end-to-end latency of a multi-component application.&lt;/p&gt;&#xA;&lt;p&gt;Assuming that the application has 10 components, component 1-5 is hosted by device 1, and device 2 is hosting the other 5 components. Note device 1 has cpu limitation and device 2 has unlimited cpu.&lt;/p&gt;&#xA;&lt;p&gt;The end-to-end latency is calculated by the execution time of 1-5 component + the output data transfer time of component 5 ( to be fed as input to the component 6 (on device 2)) + the execution time of component 6-10.&lt;/p&gt;&#xA;&lt;p&gt;Due to some system load on device 1, the allocation needs to be changed for instance component 1-3 on device 1 and component 4-10 on device 2 but this allocation must consider the bandwidth constraint and cpu limitation of device1.&lt;/p&gt;&#xA;&lt;p&gt;I would like to ask can this problem be considered multiobjective or not?.I need to use a multiobjective algorithm to solve the below problem such as pareto optimality or genetic algorithm. The end to end latency is affected by the bandwidth (bandwidth constraint) and device 1 cpu limitation (device1 constraint).&lt;/p&gt;&#xA;&lt;p&gt;Help is highly appreciated. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="3811" LastEditorUserId="67" LastEditDate="2020-09-21T21:02:37.253" LastActivityDate="2020-09-21T21:05:30.800" Title="How this problem can be defined as MultiObjective optimisation" Tags="|mixed-integer-programming|linear-programming|integer-programming|scheduling|multi-objective-optimization|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4882" PostTypeId="1" CreationDate="2020-09-20T06:49:45.707" Score="2" ViewCount="5624" Body="&lt;p&gt;How do I derive the steady state probabilities for the &lt;span class=&quot;math-container&quot;&gt;$M/M/1/k$&lt;/span&gt; queueing systems with finite system capacity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="4124" LastEditorUserId="491" LastEditDate="2020-11-03T03:41:26.577" LastActivityDate="2023-01-17T12:46:58.157" Title="How do derive the steady state probabilities M/M/1/k queueing system?" Tags="|queuing-theory|steady-state|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4883" PostTypeId="2" ParentId="1105" CreationDate="2020-09-20T10:49:33.707" Score="2" Body="&lt;p&gt;On the applied side, an interesting one is tensor calculus which is used a lot in aerodynamical optimisation. Tensors are used to employ curvilinear coordinate systems which follow the flow lines of the particles. Although this might sound specific to fluid mechanics, certain specialised methods in aerodynamics, such as calculating the adjoint derivatives of the flow equations, include a lot of interplay between the optimisation methods and the fluid mechanics math.&lt;/p&gt;&#xA;&lt;p&gt;Another area that I looked into during my PhD was manifold evolution using the &lt;a href=&quot;https://en.wikipedia.org/wiki/Ricci_flow&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ricci flow&lt;/a&gt; in order to evolve the metric tensor of the vector space so that the problem can become easier to solve.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-09-20T10:49:33.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4884" PostTypeId="2" ParentId="4881" CreationDate="2020-09-20T12:17:25.583" Score="2" Body="&lt;p&gt;&lt;strong&gt;Model without bandwidth limitation&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;We wish to select the most performing components to be hosted by two devices in order to have an end-to-end latency as minimum as possible.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j} $&lt;/span&gt; be a Boolean variable whose value is 1 if i-th component is assigned to j-th device,  0 otherwise where &lt;span class=&quot;math-container&quot;&gt;$i=1,2, \cdots, 10 $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i=1,2$&lt;/span&gt;. The &lt;strong&gt;cpu limitation&lt;/strong&gt; (equals to &lt;span class=&quot;math-container&quot;&gt;$c_1$&lt;/span&gt;) constraint could be written as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{i=1}^{10} x_{i,1} \leq c_1 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In order to allocate every component only in 1 and only 1 device and not have a trivial solution (i.e. all variables equal to zero), we can impose that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{j=1}^2 x_{i,j} = 1 $&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$i=1,\cdots , 10$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The following constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{i=1}^{10} x_{i,1} \geq 1 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;requires that at least one component is hosted by device 1 and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{i=1}^{10} x_{i,2} \geq 1 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;the same for device 2.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt; be the execution time of components and &lt;span class=&quot;math-container&quot;&gt;$T_i$&lt;/span&gt; the output data transfer time of component i from 1st device to 2nd device. The &lt;strong&gt;obijective function&lt;/strong&gt; Z to be minimized could be&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ Z = ( \sum_{j=1}^2 \sum_{i=1}^{10} t_i  \cdot x_{i,j} ) + T $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; should designate the &lt;em&gt;output data transfer time&lt;/em&gt; of i-th component in last position on board of device 1. Because we do not consider bandwidth limitation, &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; will be equal to 0.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Model with bandwidth limitation&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; be the bandwidth of every components, we have to consider the &lt;strong&gt;bandwidth contraint&lt;/strong&gt; applied only on the “last” component on board of 1st device. This point requires to consider auxiliary variables indicating the ranking of the components on board of device 1 and furnishing the output data transfer time &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;.&#xA;Because the output data transfer time &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is inversely proportional to &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;, as last component on device 1 we wish to select the largest available bandwidth.&#xA;Let introduce ten Boolean auxiliary variables, &lt;span class=&quot;math-container&quot;&gt;$ z_1, \cdots, z_{10} $&lt;/span&gt;, assuming value is 1 if i-th component transmits bytes from device 1 to device 2.&#xA;Because only one component is designate to transmit from device 1 to device 2, we introduce the constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{10} z_i = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \min T $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;T \geq \sum_{i=1}^{10} b^{-1}_i \cdot z_i \\&#xA;x_{1,2} + z_1 \leq 1 \\&#xA;x_{2,2} + z_2 \leq 1  \\&#xA;\vdots \\&#xA;x_{10,2} + z_{10} \leq 1 \\&#xA;\sum_{i=1}^{10} z_i = 1 \\&#xA;T \geq 0 \\&#xA;z_1, \cdots, z_{10} binary \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The logic constraint &lt;span class=&quot;math-container&quot;&gt;$x_{i,2} + z_i \leq 1$&lt;/span&gt; guarantees to avoid to select components that are allocated on device 2: &lt;span class=&quot;math-container&quot;&gt;$x_{i,2}=1 \implies z_i=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Finally, the model is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ Z = ( \sum_{j=1}^2 \sum_{i=1}^{10} t_i  \cdot x_{i,j} ) + T $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;s.t.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;T \geq \sum_{i=1}^{10} b^{-1}_i \cdot z_i \\&#xA;\sum_{i=1}^{10} x_{i,1} \leq c_1 \\&#xA;\sum_{j=1}^2 x_{1,j} = 1 \\&#xA;\vdots \\&#xA;\sum_{j=1}^2 x_{10,j} = 1 \\&#xA;\sum_{i=1}^{10} x_{i,1} \geq 1 \\&#xA;\sum_{i=1}^{10} x_{i,2} \geq 1 \\&#xA;x_{1,2} + z_1 \leq 1 \\&#xA;x_{2,2} + z_2 \leq 1  \\&#xA;\vdots \\&#xA;x_{10,2} + z_{10} \leq 1 \\&#xA;\sum_{i=1}^{10} z_i = 1 \\&#xA;T \geq 0 \\&#xA;z_1, \cdots, z_{10},x_{1,1}, \cdots, x_{2,10}  binary \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4114" LastEditorUserId="4114" LastEditDate="2020-09-20T19:59:41.957" LastActivityDate="2020-09-20T19:59:41.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4885" PostTypeId="1" AcceptedAnswerId="4914" CreationDate="2020-09-20T21:38:43.143" Score="3" ViewCount="713" Body="&lt;p&gt;In a stochastic programming problem, I have binary variables in the second stage. As an example, consider that the optimization problem is given by:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;\gamma\\&#xA;&amp;amp;\text{subject to} &amp;amp;M\cdot Y_{s} &amp;amp;\geq  (b-\omega^{s}){'}X -\gamma &amp;amp;&amp;amp;\text{$s = 1,\dots,S$} \tag1\\&#xA;&amp;amp;&amp;amp;\sum_{s=1}^{S} Y_{s}P_{s} &amp;amp;\leq \alpha \tag2\\&#xA;&amp;amp;&amp;amp;Y_{s} &amp;amp;\in \{0,1\} &amp;amp;&amp;amp;\text{$s = 1,\dots,S$} \\                       &#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; is free,&#xA;&lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is the vector of optimization variables &lt;span class=&quot;math-container&quot;&gt;$0\leq x_{i} \leq 1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$i = 1,...,n$&lt;/span&gt;,&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is the confidence level,&#xA;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a big constant,&#xA;&lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a vector of constant values of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$\omega^{s}$&lt;/span&gt; is a vector of uncertain values of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$P_{s}$&lt;/span&gt; is the probability of a scenario, and&#xA;&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is the number of scenarios.&lt;/p&gt;&#xA;&lt;p&gt;My understanding is that benders decomposition cannot be used due to presence of binary variables in the second stage. The extensive form may be difficult to solve if the number of scenarios are large.&lt;/p&gt;&#xA;&lt;p&gt;What decomposition methods can be used for this problem? How it can be formulated as a two stage stochastic programming problem using the suggested method?&lt;/p&gt;&#xA;" OwnerUserId="3217" LastEditorUserId="3217" LastEditDate="2020-09-21T21:58:37.230" LastActivityDate="2020-09-24T17:56:49.503" Title="Decomposition methods for two-stage stochastic program with integer variables" Tags="|stochastic-programming|benders-decomposition|chance-constraints|lagrangian-decomposition|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="4886" PostTypeId="2" ParentId="4885" CreationDate="2020-09-21T05:19:24.523" Score="4" Body="&lt;p&gt;To solve stochastic programming models with integer recourse, there are some methods. Most stochastic programming textbooks cover these methods. For example, chapter 7 of &lt;a href=&quot;https://www.springer.com/gp/book/9781461402367&quot; rel=&quot;nofollow noreferrer&quot;&gt;Introduction to Stochastic Programming&lt;/a&gt; by Birge and Louveux covers these techniques. In particular, I suggest either using the integer L-shaped method or the progressive hedging algorithm (PHA). The basic idea of the integer L-shaped is to employ the combinatorial benders-type cuts to handle the integer recourse problem (see &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/016763779390002X&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for the original reference and &lt;a href=&quot;https://pubsonline.informs.org/doi/pdf/10.1287/ijoc.2016.0695&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for an improved version of the algorithm). The basic idea of PHA is to enforce nonanticipativity constraints (i.e., having the same first-stage variables for all the scenarios) using penalty terms similar to the idea of Lagrangian relaxation (see &lt;a href=&quot;https://www.jstor.org/stable/3689852&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for the original reference and &lt;a href=&quot;https://link.springer.com/article/10.1007/s10287-010-0125-4&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for improved versions of the algorithm).&lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2020-09-21T05:19:24.523" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4887" PostTypeId="2" ParentId="1105" CreationDate="2020-09-21T05:59:18.200" Score="3" Body="&lt;p&gt;Jordan algebra is used to analyze interior-point methods for optimization over symmetric cones. &lt;a href=&quot;https://link.springer.com/article/10.1023/A:1009701824047&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is a random reference.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2020-09-21T05:59:18.200" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4888" PostTypeId="2" ParentId="361" CreationDate="2020-09-21T09:58:48.043" Score="1" Body="&lt;p&gt;Suppose there are three scenarios &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in the second stage and two time steps &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. With&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_1 = \begin{pmatrix}&#xA;    x_{11} \\&#xA;    x_{12} \\&#xA;    \end{pmatrix},\quad&#xA;x_2 = \begin{pmatrix}&#xA;    x_{21} \\&#xA;    x_{22} \\&#xA;    \end{pmatrix},\quad&#xA;x_3 = \begin{pmatrix}&#xA;    x_{31} \\&#xA;    x_{32} \\&#xA;    \end{pmatrix},&#xA;$$&lt;/span&gt;&#xA;one obvious choice would be&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;H_1 = \begin{pmatrix}&#xA;    1 &amp;amp; 0 \\&#xA;    0 &amp;amp; 0 \\&#xA;    0 &amp;amp; 1 \\&#xA;    0 &amp;amp; 0 \\&#xA;    \end{pmatrix},\quad&#xA;H_2 = \begin{pmatrix}&#xA;    -1 &amp;amp; 0 \\&#xA;    1 &amp;amp; 0 \\&#xA;    0 &amp;amp; -1 \\&#xA;    0 &amp;amp; 1 \\&#xA;    \end{pmatrix},\quad&#xA;H_3 = \begin{pmatrix}&#xA;    0 &amp;amp; 0 \\&#xA;    -1 &amp;amp; 0 \\&#xA;    0 &amp;amp; 0 \\&#xA;    0 &amp;amp; -1 \\&#xA;    \end{pmatrix}.&#xA;$$&lt;/span&gt;&#xA;Another possibility:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;H_1 = \begin{pmatrix}&#xA;    1 &amp;amp; 0 \\&#xA;    1 &amp;amp; 0 \\&#xA;    0 &amp;amp; 1 \\&#xA;    0 &amp;amp; 1 \\&#xA;    \end{pmatrix},\quad&#xA;H_2 = \begin{pmatrix}&#xA;    -1 &amp;amp; 0 \\&#xA;    0 &amp;amp; 0 \\&#xA;    0 &amp;amp; -1 \\&#xA;    0 &amp;amp; 0 \\&#xA;    \end{pmatrix},\quad&#xA;H_3 = \begin{pmatrix}&#xA;    0 &amp;amp; 0 \\&#xA;    -1 &amp;amp; 0 \\&#xA;    0 &amp;amp; 0 \\&#xA;    0 &amp;amp; -1 \\&#xA;    \end{pmatrix}.&#xA;$$&lt;/span&gt;&#xA;Both with &lt;span class=&quot;math-container&quot;&gt;$h = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Visually, the block structure is more obvious in the latter formulation. I don't see any major advantages or disadvantages by using one or the other.&lt;/p&gt;&#xA;" OwnerUserId="869" LastEditorUserId="869" LastEditDate="2020-09-21T12:40:46.220" LastActivityDate="2020-09-21T12:40:46.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4889" PostTypeId="1" CreationDate="2020-09-21T14:23:14.827" Score="1" ViewCount="152" Body="&lt;p&gt;Gurobi 9.0.0 // C++ // LP&lt;/p&gt;&#xA;&lt;p&gt;Let us assume the following problem with three nodes: &lt;code&gt;(1)-----(2)-----(3)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;node (1)&lt;/code&gt; is producing something and it gets transported to the demand at &lt;code&gt;node (2)&lt;/code&gt; and &lt;code&gt;node (3)&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now I do have the option to build either new factories or roads.&lt;/p&gt;&#xA;&lt;p&gt;I created the variables &lt;code&gt;0 &amp;lt;= build_factory &amp;lt;= 1&lt;/code&gt; and &lt;code&gt;0 &amp;lt;= build_road &amp;lt;= 1&lt;/code&gt;. All relevant constraints of the new objects are multiplied with &lt;code&gt;build_factory&lt;/code&gt; and &lt;code&gt;build_road&lt;/code&gt; respectively. The investment cost in the objective function are also multiplied with these variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Mathematical formulation of the problem as an example. The problem shows the decision of increasing the production facility at node (1)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;All variables &amp;gt;= 0&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Initial Problem (LP): x1 factory, x2 and x3 demand&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;max - 0.5x1 + 1.5x2 + 1.5x3 &#xA;s.t. x1 - x2 -x3  = 0 (Supply=Demand)&#xA;     x1          &amp;lt;= 3 (Capacity Road 1, (1)-(2), (redundant))&#xA;     x1 - x2     &amp;lt;= 1 (Capacity Road 2, (2)-(3))&#xA;     x1          &amp;lt;= 2 (Production Capacity node 1)&#xA;     x2          &amp;lt;= 2 (Demand Capacity node 2)&#xA;     x3          &amp;lt;= 1 (Demand Capacity node 3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Optimal solution = 2&lt;/strong&gt; with &lt;code&gt;x1 = 2&lt;/code&gt; and either &lt;code&gt;x2 = 2&lt;/code&gt; or &lt;code&gt;x2 = x3 = 1&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The demand is not exhausted and there is room for improvement.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Build option added (LP -&amp;gt; MILP) through binary variable y4 representing building an additional factory with capacity x4 at node (1)&lt;/em&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;max - 0.5x1 + 1.5x2 + 1.5x3 - 0.5x4 - 0.25y4&#xA;s.t. x1 - x2 -x3 + x4        = 0 (Supply=Demand)&#xA;     x1          + x4       &amp;lt;= 3 (Capacity Road 1, (1)-(2))&#xA;     x1 - x2     + x4       &amp;lt;= 1 (Capacity Road 2, (2)-(3))&#xA;     x1                     &amp;lt;= 2 (Production Capacity node 1)&#xA;     x2                     &amp;lt;= 2 (Demand Capacity node 2)&#xA;     x3                     &amp;lt;= 1 (Demand Capacity node 3)&#xA;                   x4       &amp;lt;= 2 (Production Capacity also node 1)&#xA;                   x4 -2*y4 &amp;lt;= 0 (Restriction to only use when built)&#xA;                         y4  e [0,1] (Build variable)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For a MILP the &lt;strong&gt;optimal solution = 2.75&lt;/strong&gt; with &lt;code&gt;x4 = y4 = 1&lt;/code&gt;. If I relax the MILP the &lt;strong&gt;optimal solution = 2.875&lt;/strong&gt; with  &lt;code&gt;x4 = 1 and y4 = 0.5&lt;/code&gt;. So building the production facility makes sense but it would be better to build a smaller one.&lt;/p&gt;&#xA;&lt;p&gt;Now imagine there was another factory or road that could be built alternatively and has build variable &lt;code&gt;y5&lt;/code&gt;. In the optimal solution of the MILP I might get &lt;code&gt;y4 = 1 and y5 = 1&lt;/code&gt; and even if one of them is smaller than 1 in the relaxed problem, I still can't determine which is the better option or am I mistaken? I calculate the dual price in case of &lt;code&gt;y4 = 1 and y5 = 1&lt;/code&gt; but can I be sure that the one with the heigher dual price is the better option considering building the whole object?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The main question is:&lt;/strong&gt; &lt;strong&gt;How can I determine which is the better project?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I identified three problems regarding that question:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem 1&lt;/strong&gt;: Is it possible to compare expansion possibilities by comparing the corresponding build variables in the relaxed model (and maybe use the dual price as an additional criterium)?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem 2&lt;/strong&gt;: Now this still leads to the problem of interdependencies of the &amp;quot;build&amp;quot;-objects.&lt;/p&gt;&#xA;&lt;p&gt;In the example above it could be the case that a new factory at &lt;code&gt;node (1)&lt;/code&gt; is only useful in combination with an increase in road capacity from &lt;code&gt;node (1)&lt;/code&gt; to &lt;code&gt;node (2)&lt;/code&gt;. However, I might not be able to build all suggested objects. How can I avoid these interdependencies?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem 3&lt;/strong&gt;: Additionally, I do not know what the optimal factory or road capacity is in case of &lt;code&gt;build_x = 1&lt;/code&gt; in the the relaxed model. I only know that the suggested object should be built completely. Due to the size of the original problem, the creation of variables and constraints for multiple different sized factories or roads is not feasible. How can I find the optimal size for new objects?&lt;/p&gt;&#xA;&lt;p&gt;If you have any suggestions on how I can mitigate/solve these problems, it would help me a lot.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Running the whole thing as an MILP once is not feasible due to size of the problem (execution time) and the iterative process I currently use to avoid too strong interdependencies. Therefore I only solve the relaxed model in every iteration.&lt;/p&gt;&#xA;&lt;p&gt;(Gurobi reduced cost = shadow price = dual price)&lt;/p&gt;&#xA;" OwnerUserId="4128" LastEditorUserId="4128" LastEditDate="2020-09-22T13:49:44.557" LastActivityDate="2020-09-22T13:49:44.557" Title="Expansion heuristic using gurobi reduced cost / shadow price (LP)" Tags="|linear-programming|gurobi|heuristics|reduced-costs|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4890" PostTypeId="2" ParentId="4881" CreationDate="2020-09-21T21:05:30.800" Score="2" Body="&lt;p&gt;You can treat it as multiobjective if you treat end-to-end latency as one objective (to be minimized) and load on device 1 (which has limited capacity) as another objective (also to be minimized).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-21T21:05:30.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4891" PostTypeId="1" CreationDate="2020-09-21T22:52:06.380" Score="0" ViewCount="311" Body="&lt;p&gt;I went through the answers to this question: &lt;a href=&quot;https://or.stackexchange.com/questions/443/modeling-floor-function-exactly/513#513&quot;&gt;Modeling floor function exactly&lt;/a&gt;, but I still do not get how to model &lt;code&gt;y = floor(x)&lt;/code&gt;. Is that question answered and I just do not see it?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="727" LastEditDate="2021-03-04T22:34:33.950" LastActivityDate="2021-04-04T00:07:40.753" Title="How to model y = floor(x)?" Tags="|mixed-integer-programming|" AnswerCount="2" CommentCount="4" ClosedDate="2021-10-27T19:55:46.060" ContentLicense="CC BY-SA 4.0" />
  <row Id="4892" PostTypeId="1" CreationDate="2020-09-22T02:06:55.157" Score="6" ViewCount="325" Body="&lt;p&gt;I'm a graduate student studying Robust Optimization (RO).&lt;/p&gt;&#xA;&lt;p&gt;So far, I've been studied the theoretic point of RO, and now I am looking for an actual tool for solving RO problems, both for practice and real application.&lt;/p&gt;&#xA;&lt;p&gt;I'm familiar with Python, but I couldn't find any Python packages for RO unfortunately.&lt;/p&gt;&#xA;&lt;p&gt;The alternative found was Julia, especially package &amp;quot;JuMPeR&amp;quot;, which handles RO problem with user-friendly syntax. Also the general optimization tool, &amp;quot;JuMP&amp;quot; seems great.&lt;/p&gt;&#xA;&lt;p&gt;But it seems that this library has not been updated for several years, and the reason may be that this is developed and maintained by an individual.&lt;/p&gt;&#xA;&lt;p&gt;Especially, constructing the uncertainty set and reformulation of robust counterpart to tractable convex programming is important but also tricky in RO. But I think the uncertainty sets provided by &amp;quot;JuMPeR&amp;quot; are quite simple and small in quantity. So I have a few questions.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is JuMPeR quite good enough for RO problem, both for experiments in paper and real applications? The default uncertainty sets are box set, ellipsoidal, and cardinally-constrained set. Are they the only options? Or is there any chance for customization, or available sets in Julia-github?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If not, can you recommend another software/language for RO?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="4130" LastEditorUserId="36" LastEditDate="2020-09-22T12:53:46.047" LastActivityDate="2021-08-26T14:07:42.413" Title="Is JuMPeR good enough for Robust Optimization problem?" Tags="|robust-optimization|modeling-languages|julia|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4893" PostTypeId="1" CreationDate="2020-09-22T08:24:15.673" Score="3" ViewCount="102" Body="&lt;p&gt;Consider a constraint of type&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c_1x_1+c_2x_2+\cdots+c_nx_n\leq C$$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; binary.&lt;/p&gt;&#xA;&lt;p&gt;We call a &lt;em&gt;cover&lt;/em&gt; a subset of the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; indices such that the sum of the corresponding coefficients is higher than the right-hand-side &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;.&#xA;A cover is &lt;em&gt;minimal&lt;/em&gt; if, by removing an index of the cover, it is not a cover anymore.&lt;/p&gt;&#xA;&lt;p&gt;Question: what is a general procedure for finding all covers and all minimal covers?&lt;/p&gt;&#xA;" OwnerUserId="766" LastActivityDate="2020-09-22T08:24:15.673" Title="How to find all covers and minimal covers?" Tags="|integer-programming|" AnswerCount="0" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4894" PostTypeId="2" ParentId="4891" CreationDate="2020-09-22T09:00:21.353" Score="1" Body="&lt;p&gt;in &lt;a href=&quot;https://github.com/AlexFleischerParis/howtowithopl/blob/master/ceil.mod&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/AlexFleischerParis/howtowithopl/blob/master/ceil.mod&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    range r=1..4;&#xA;&#xA;    float x[r]=[1.5,4.0,2.0001,5.9999];&#xA;&#xA;    dvar int y[r];&#xA;    dvar float f[r] in 0..0.9999999;&#xA;&#xA;    subject to&#xA;    {&#xA;    forall(i in r) y[i]==x[i]+f[i];&#xA;&#xA;&#xA;    }&#xA;&#xA;    execute&#xA;    {&#xA;    writeln(x,&amp;quot; ==&amp;gt; &amp;quot;,y);&#xA;    }&#xA;&#xA;    assert forall(i in r) y[i]==ceil(x[i]);&#xA;&#xA;//which gives&#xA;&#xA;//    [1.5 4 2.0001 5.9999] ==&amp;gt;  [2 4 3 6]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I gave an OPL CPLEX example about how to model ceil. Floor is not very different.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;range r=1..4;&#xA;&#xA;float x[r]=[1.5,4.0,2.0001,5.9999];&#xA;&#xA;dvar int y[r];&#xA;dvar float f[r] in 0..0.9999;&#xA;&#xA;subject to&#xA;{&#xA;forall(i in r) y[i]==x[i]-f[i];&#xA;&#xA;&#xA;}&#xA;&#xA;execute&#xA;{&#xA;writeln(x,&amp;quot; ==&amp;gt; &amp;quot;,y);&#xA;}&#xA;&#xA;assert forall(i in r) y[i]==floor(x[i]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-09-22T09:00:21.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4895" PostTypeId="2" ParentId="4891" CreationDate="2020-09-22T12:45:51.040" Score="1" Body="&lt;p&gt;I tried finding floor value together with ceil value.&#xA;c = ceil(x) and f=floor(x)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x \leq c \leq x+1 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x \geq f \geq x-1 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ c-f \leq 1 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x \leq f + M(c-x) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x \geq c - M(x-f) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x\in R^+, c,f \in Z^+ $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Possible cases:&#xA;Case 1: x=3.9&#xA;&lt;span class=&quot;math-container&quot;&gt;$$3.9 \leq c \leq 4.9 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$3.9 \geq f \geq 2.9 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ c-f \leq 1 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ 3.9 \leq f + M(c-3.9) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ 3.9 \geq c - M(3.9-f) $$&lt;/span&gt;&#xA;Result c=4, f=3&lt;/p&gt;&#xA;&lt;p&gt;Case 2: x=3.1&#xA;&lt;span class=&quot;math-container&quot;&gt;$$3.1 \leq c \leq 4.1 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$3.1 \geq f \geq 2.1 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ c-f \leq 1 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ 3.1 \leq f + M(c-3.1) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ 3.1 \geq c - M(3.1-f) $$&lt;/span&gt;&#xA;Result c=4, f=3&lt;/p&gt;&#xA;&lt;p&gt;Case 3: x=3&#xA;&lt;span class=&quot;math-container&quot;&gt;$$3 \leq c \leq 4 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$3 \geq f \geq 2 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ c-f \leq 1 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ 3 \leq f + M(c-3) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ 3 \geq c - M(3-f) $$&lt;/span&gt;&#xA;3.a. c=4, f=2 is possible from const 1 and 2 but const 3 inf.&lt;/p&gt;&#xA;&lt;p&gt;3.b. c=4, f=3 is possible from const 1 and 2 but const 5 inf.&lt;/p&gt;&#xA;&lt;p&gt;3.c. c=3, f=2 is possible from const 1 and 2 but const 4 inf.&#xA;Therefore c=3, f=3.&lt;/p&gt;&#xA;&lt;p&gt;M is big number and determines the sensivity of x. For example, x=3.9 , M must be equal or greater than 10. Likewise, if x=3.99, &lt;span class=&quot;math-container&quot;&gt;$M \geq 100$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="432" LastEditorUserId="432" LastEditDate="2020-09-23T06:24:31.783" LastActivityDate="2020-09-23T06:24:31.783" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4896" PostTypeId="1" AcceptedAnswerId="4899" CreationDate="2020-09-23T00:21:02.860" Score="2" ViewCount="87" Body="&lt;p&gt;I have some points with determined coordinates &lt;span class=&quot;math-container&quot;&gt;$(a_i,b_i)$&lt;/span&gt;. A vehicle can move between these points based on rectangular distance. In more detail, we consider that the path between points is an orthogonal path.&lt;/p&gt;&#xA;&lt;p&gt;In a mathematical model of my problem, I need to determine the coordinates of specific points that can exist in the path between each pair of points, according to the orthogonal path between them. For example, if the vehicle traverses between two specific points &lt;span class=&quot;math-container&quot;&gt;$(a_1,b_1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(a_2,b_2)$&lt;/span&gt;, the coordinates of the desired point &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt; can be &lt;span class=&quot;math-container&quot;&gt;$x=a_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_1&amp;lt;y&amp;lt;b_2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$a_1&amp;lt;x&amp;lt;a_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y=b_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How should I write such constraint in my MIP (mixed integer programming) model, which can explain the above mentioned feature?&lt;/p&gt;&#xA;" OwnerUserId="3972" LastEditorUserId="2477" LastEditDate="2020-09-23T01:22:55.163" LastActivityDate="2020-09-23T14:59:12.697" Title="distance specific constraint" Tags="|mixed-integer-programming|modeling|constraint|combinatorial-optimization|logical-constraints|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4897" PostTypeId="1" CreationDate="2020-09-23T03:11:46.867" Score="2" ViewCount="162" Body="&lt;p&gt;CPLEX &lt;code&gt;writeSolution&lt;/code&gt; method outputs both primal and dual variable values of a LP. I know how to parse through the solution file to extract specific primal variable values.&lt;/p&gt;&#xA;&lt;p&gt;However, is there a build-in way (parameters or options) in CPLEX to just output primal variable values of a LP?&lt;/p&gt;&#xA;" OwnerUserId="162" LastActivityDate="2020-09-26T14:45:57.737" Title="Can CPLEX output LP solution with primal variables only?" Tags="|linear-programming|cplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4898" PostTypeId="2" ParentId="4897" CreationDate="2020-09-23T07:49:22.410" Score="2" Body="&lt;p&gt;The method &lt;code&gt;writeSolution&lt;/code&gt; will always output both primal and dual values.&lt;/p&gt;&#xA;&lt;p&gt;A MIP Start will not have the dual values. C.f. &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/FileFormats/topics/MST.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/FileFormats/topics/MST.html&lt;/a&gt;.  But MIP Start don’t apply to continuous problems, so that’s not suited to your case.&lt;/p&gt;&#xA;" OwnerUserId="295" LastEditorUserId="295" LastEditDate="2020-09-26T14:45:57.737" LastActivityDate="2020-09-26T14:45:57.737" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4899" PostTypeId="2" ParentId="4896" CreationDate="2020-09-23T13:17:59.323" Score="3" Body="&lt;p&gt;To enforce this disjunction, introduce a small constant &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt;, binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, and linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;a_1 +\epsilon(1- z)\le x &amp;amp;\le a_1 z+(a_2-\epsilon)(1-z)\\&#xA;b_2(1-z)+(b_1+\epsilon)z \le y &amp;amp;\le b_2 -\epsilon z&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;To instead allow &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt; to appear along the orthogonal paths through &lt;span class=&quot;math-container&quot;&gt;$(a_1,b_2)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$(a_2,b_1)$&lt;/span&gt; (four line segments), introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,2,3,4\}$&lt;/span&gt; and linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;a_1 z_1 +(a_1+\epsilon) z_2 + (a_1+\epsilon) z_3 + a_2 z_2 \le x \le a_1 z_1+(a_2-\epsilon) z_2 +(a_2-\epsilon) z_3 + a_2 z_2 \\&#xA;(b_1+\epsilon)z_1 + b_2 z_2 + b_1 z_3 + (b_1+\epsilon)z_4 \le y \le (b_2-\epsilon) z_1 + b_2 z_2 + b_1 z_3 + (b_2-\epsilon) z_4 \\&#xA;z_1 + z_2 + z_3 + z_4 = 1&#xA;$$&lt;/span&gt;&#xA;The earlier formulation corresponds to &lt;span class=&quot;math-container&quot;&gt;$(z_1,z_2,z_3,z_4)=(z,1-z,0,0)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-09-23T14:59:12.697" LastActivityDate="2020-09-23T14:59:12.697" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4900" PostTypeId="1" AcceptedAnswerId="4902" CreationDate="2020-09-23T18:06:55.860" Score="0" ViewCount="115" Body="&lt;p&gt;I am wondering if the objective function in the following problem makes sense. The question is posted in &lt;a href=&quot;https://stats.stackexchange.com/questions/488836/estimation-of-the-coefficient-matrix-in-a-matrix-equation&quot;&gt;CrossValidated, stack exchange&lt;/a&gt; as well.&lt;/p&gt;&#xA;&lt;p&gt;I know there is a physical system having an underlying deterministic relationship:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathbf{y}_t = \mathbf{A} \mathbf{x}_t&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{y}_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_t$&lt;/span&gt; are column vectors with same numbers of rows. They represent some measured values of a fixed number of entities. We know the number of rows, and want to estimate &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}$&lt;/span&gt; based on observations. All entries in &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}$&lt;/span&gt; are positive.&lt;/p&gt;&#xA;&lt;p&gt;The major obstacle is that I only have &lt;strong&gt;partial&lt;/strong&gt; observations for &lt;span class=&quot;math-container&quot;&gt;$\mathbf{y}_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_t$&lt;/span&gt; at entries &lt;span class=&quot;math-container&quot;&gt;$i \in I_{\text{obs}}$&lt;/span&gt;. That is, observations for some entries, &lt;span class=&quot;math-container&quot;&gt;$i \in I_{\text{hidden}}$&lt;/span&gt;, are missing &lt;strong&gt;all the time&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For example, if there are 3 entities. Let's say observations at the third entity are missing. I only have observations of &lt;span class=&quot;math-container&quot;&gt;$(x_{t, 1}, y_{t, 1})$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(x_{t, 2}, y_{t, 2})$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I can obtain some candidates &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat{A}}$&lt;/span&gt; (through heuristic algorithms). The task is to evaluate if these candidates are good representations of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For every candidate &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat{A}}$&lt;/span&gt;, I find a column vector &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}$&lt;/span&gt; to max the following problem (call it vector-b problem):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned}&#xA;    \max_{\mathbf{b}} \quad &amp;amp; \mathbf{b}^{\top} \mathbf{\hat{A}} \mathbf{x}_{\text{binary}} \\&#xA;    \text{s.t.} \quad &amp;amp; b_i = 0 \quad \forall i \in I_{\text{missing}}&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_{\text{binary}}$&lt;/span&gt; is a column vector with binary values, -1 and 1. The value is -1 if the observation is missing. Corresponding to the previous example, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_{\text{binary}} = \left[1 \quad 1 \quad -1 \right]^{\top}$&lt;/span&gt;, because we don't have observations for &lt;span class=&quot;math-container&quot;&gt;$x_{t, 3}$&lt;/span&gt;. The reason for this step is to minimise the impact of missing observations. The fact that entries in &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}$&lt;/span&gt; are positive is essential in this problem.&lt;/p&gt;&#xA;&lt;p&gt;With the optimal value, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat{b}} = \arg \max \mathbf{b}^{\top}  \mathbf{\hat{A}} \mathbf{x}_{\text{binary}}$&lt;/span&gt;, the performance of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat{A}}$&lt;/span&gt; is evaluated by a scalar:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;    \sum_{t \in T} \left[\mathbf{\hat{b}}^{\top} \mathbf{y}_{t, \text{obs}} - \mathbf{\hat{b}}^{\top}  \mathbf{\hat{A}} \mathbf{x}_{t, \text{obs}} \right]^2&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;where entries &lt;span class=&quot;math-container&quot;&gt;$i \in I_{\text{missing}}$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_{t, \text{obs}}$&lt;/span&gt; are 0. Entries &lt;span class=&quot;math-container&quot;&gt;$i \in I_{\text{missing}}$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{y}_{t, \text{obs}}$&lt;/span&gt; don't matter because &lt;span class=&quot;math-container&quot;&gt;$b_i = 0, \forall i \in I_{\text{missing}}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;That is, I am trying to minimise the deviation between observed aggregated&#xA;&lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; values and calculated aggregated &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; values, which I am not sure if it makes sense.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The task can be done by multiple regression. However, for entries in the same rows of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}$&lt;/span&gt;, I know most of them are similar. Because all variables in &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}$&lt;/span&gt; are correlated with each other and some variables are hidden, some statistical issues like multicollinearity will distort the estimation results. For example, some coefficients will become negative. Besides, there is no way to have results for those coefficients not obtained from the multiple regression.&lt;/p&gt;&#xA;&lt;p&gt;But I am not interested in predictions. This is a physical system, and I want to explain it by &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}$&lt;/span&gt;. The advantage of using heuristics is that meaningful &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}$&lt;/span&gt; comes first and then we talk about their performance. Right now, I have a way to get meaningful candidates, but not sure about the way to evaluate them.&lt;/p&gt;&#xA;" OwnerUserId="3163" LastEditorUserId="3163" LastEditDate="2020-09-24T07:50:55.083" LastActivityDate="2020-09-24T07:50:55.083" Title="Does this objective function makes sense?" Tags="|optimization|heuristics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4901" PostTypeId="2" ParentId="4834" CreationDate="2020-09-23T18:13:37.003" Score="2" Body="&lt;p&gt;&lt;strong&gt;Vehicle Routing Problem with Time Window constraints&lt;/strong&gt;&#xA;Let imagine a logistics network consisting of a warehouse and numerous retailers. All stocks enter into the logistics network through the depot and from this one the goods are distributed to the retails via a fleet of vehicles. Each retailer (customer) specifies to the load to be delivered. In addition, if retailer specifies a period of time (&lt;em&gt;time window&lt;/em&gt;) in which the delivery should occur then the model is called &lt;em&gt;Vehicle Routing Problem with Time Window constraints&lt;/em&gt;(VRPTW). The objective is to find a set of routes which minimizes the total length of the routes or the number of used vehicles without violating the vehicle capacity and time window constraints. Let the index set of the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; retailers be denoted &lt;span class=&quot;math-container&quot;&gt;$N=1,2, \cdots, n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let the &lt;em&gt;load&lt;/em&gt; which has to be delivered be &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let the &lt;em&gt;earliest starting time&lt;/em&gt; for the service of unload be &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt;.  The value of &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; can be thought as a release time of the i-th job in machine scheduling environment so that it designates the time job (retailer) is available for processing.&lt;/p&gt;&#xA;&lt;p&gt;Let the &lt;em&gt;duration&lt;/em&gt; of unloading activity be &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; that is the time required to complete the service. The value of &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; can be thought as the processing time of the i-th job in the machine scheduling environment&lt;/p&gt;&#xA;&lt;p&gt;Let the &lt;em&gt;latest termination time&lt;/em&gt; for the service be &lt;span class=&quot;math-container&quot;&gt;$l_i$&lt;/span&gt; that is the time the service can end. The value of &lt;span class=&quot;math-container&quot;&gt;$l_i$&lt;/span&gt; can be thought as the due date for the i-th job.&lt;/p&gt;&#xA;&lt;p&gt;For the depot (the depot is located at the origin, &lt;span class=&quot;math-container&quot;&gt;$i=0$&lt;/span&gt; ) and for each retailer there is a &lt;strong&gt;time window&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ [r_i, l_i]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;during which it must be served where &lt;span class=&quot;math-container&quot;&gt;$i=0,1, 2, \cdots, n$&lt;/span&gt;. The &lt;strong&gt;service start time&lt;/strong&gt; at each node must be &lt;span class=&quot;math-container&quot;&gt;$\geq r_i$&lt;/span&gt; and the &lt;strong&gt;arrival time&lt;/strong&gt; at each node must be &lt;span class=&quot;math-container&quot;&gt;$\leq l_i$&lt;/span&gt;. If a vehicle arrives at time &lt;span class=&quot;math-container&quot;&gt;$&amp;lt;r_i$&lt;/span&gt; then the vehicle must wait before starting to serve the retailer.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$r_i &amp;lt; l_i - d_i $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;or &lt;span class=&quot;math-container&quot;&gt;$r_i = l_i - d_i $&lt;/span&gt; if there is not a slack between release time and due date.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$r_i, l_i, d_i$&lt;/span&gt; are parameters and are known without uncertainty.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;TW Constraint&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{i,k,m}$&lt;/span&gt; be a Boolean variable: &lt;span class=&quot;math-container&quot;&gt;$x_{i,k,m} = 1$&lt;/span&gt;  if m-th vehicle travels from i-th node to k-th node, zero otherwise. For simplicity, we will suppose m=1. Let &lt;span class=&quot;math-container&quot;&gt;$t_k$&lt;/span&gt; be a continuous decision variable representing the arrival time at node &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; that is instant the service can start. We assign a &lt;strong&gt;travel time&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt; to every edge i-j. The &lt;strong&gt;time window constraint&lt;/strong&gt; can be formulated as:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_i \geq r_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_i \leq l_i$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i=1,2, \cdots, n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Let assume the travel times &lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt; satisfy the &lt;strong&gt;triangle inequality&lt;/strong&gt;, i.e.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ t_{ik} +  t_{kj} \geq t_{ij} $&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i=1,2, \cdots, n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The generic temporal constraints can be formulated as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;t_j \geq t_i + (r_j – l_i + d_i + t_{ij} ) \cdot x_{i,j} – M \cdot (l_i – r_j) \cdot (1- x_{i,j}) \\&#xA;t_i \geq r_i \\&#xA;t_i \leq l_i \\&#xA;t_i , t_j \ge 0&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4114" LastActivityDate="2020-09-23T18:13:37.003" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4902" PostTypeId="2" ParentId="4900" CreationDate="2020-09-23T21:17:22.083" Score="1" Body="&lt;p&gt;I do not think it is possible to get a useful evaluation of candidates for &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;. I'm going to tweak your notation slightly, making the time index a superscript, and I'm going to assume that we have permuted indices so that the observed values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; come first, followed by the hidden values. We can partition things and write the matrix equation as &lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left[\begin{array}{c}&#xA;y_{O}^{(t)}\\&#xA;y_{H}^{(t)}&#xA;\end{array}\right]=\left[\begin{array}{cc}&#xA;A_{1} &amp;amp; A_{2}\\&#xA;A_{3} &amp;amp; A_{4}&#xA;\end{array}\right]\left[\begin{array}{c}&#xA;x_{O}^{(t)}\\&#xA;x_{H}^{(t)}&#xA;\end{array}\right],&#xA;$$&lt;/span&gt;&#xA;where the subscripts &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; mean observed and hidden respectively. Submatrices &lt;span class=&quot;math-container&quot;&gt;$A_3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_4$&lt;/span&gt; only affect &lt;span class=&quot;math-container&quot;&gt;$y^{(t)}_H$&lt;/span&gt;, not &lt;span class=&quot;math-container&quot;&gt;$y_{O}^{(t)}$&lt;/span&gt;, so you could plug anything (positive) you like in there and have no idea, based on the data, if it was remotely close to being correct.&lt;/p&gt;&#xA;&lt;p&gt;You could evaluate candidates by solving &lt;span class=&quot;math-container&quot;&gt;$y_{O}^{(t)} - A_1 x_{O}^{(t)} = A_2 x_{H}^{(t)}$&lt;/span&gt;, separately for each &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, for the value of &lt;span class=&quot;math-container&quot;&gt;$x_{H}^{(t)}$&lt;/span&gt; that minimizes the squared error in the equation. Then pool those squared errors to get an evaluation of the quality of the estimates of &lt;span class=&quot;math-container&quot;&gt;$A_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_2$&lt;/span&gt;. As I said, though, you're still in the dark on &lt;span class=&quot;math-container&quot;&gt;$A_3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_4$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-23T21:17:22.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4903" PostTypeId="1" AcceptedAnswerId="5101" CreationDate="2020-09-24T00:57:33.843" Score="2" ViewCount="479" Body="&lt;p&gt;can anyone suggest some good books with the implementation of heuristics and matheuristics using C++ to solve operations research problems especially routing problems such as TSP and VRP. also, I need to know how I can link c++ and cplex?&lt;/p&gt;&#xA;" OwnerUserId="3972" LastActivityDate="2020-11-10T01:35:16.217" Title="implementation of heuristics using C++ to solve operations research problems" Tags="|cplex|combinatorial-optimization|algorithms|heuristics|implementation|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4904" PostTypeId="1" CreationDate="2020-09-24T03:59:54.873" Score="3" ViewCount="73" Body="&lt;p&gt;I have a system in which I want to maximize the value of some function &lt;span class=&quot;math-container&quot;&gt;$f(x_T, y_T)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The time evolution of the system is described by some functions:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\frac{dx}{dt}&amp;amp;=\alpha \frac{x}{x+y}+\ldots \\&#xA;\frac{dy}{dt}&amp;amp;=\beta \frac{y}{x+y}+\ldots \\&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;If I discretize the system it linearizes nicely as a multi-period problem, except for the ratios &lt;span class=&quot;math-container&quot;&gt;$x/(x+y)$&lt;/span&gt;. (Examples of such a system might occur in fisheries models or SIR models.)&lt;/p&gt;&#xA;&lt;p&gt;The ratios are nice because increasing &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; at a given time leads to greater values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; at future times, regardless of the value of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; (assuming &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is otherwise fixed); the same holds true for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. That is, although the function ratio saturates to 1, it doesn't impose any upper limits on what values &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; should take.&lt;/p&gt;&#xA;&lt;p&gt;Is there some clever way to linearize this function or approximate it via convex constraints? Alternately, is there some formulation which would give a similar behaviour to that described in the previous paragraph?&lt;/p&gt;&#xA;" OwnerUserId="886" LastActivityDate="2020-09-24T03:59:54.873" Title="Optimizing with a logistic function" Tags="|nonlinear-programming|convex-optimization|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4905" PostTypeId="1" AcceptedAnswerId="4909" CreationDate="2020-09-24T13:40:34.287" Score="6" ViewCount="788" Body="&lt;p&gt;I have two binary variables &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and a non-negative continuous variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. In addition, I have the following two parameters &lt;span class=&quot;math-container&quot;&gt;$u&amp;gt;q&amp;gt;0$&lt;/span&gt;. I would like to formulate the following implications&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1=0 \implies y=0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2)=(1,0) \implies y\leq u-q$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2)=(1,1) \implies y\leq u$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I have managed to formulate these relations using the following two inequalities&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA; &amp;amp;y\leq ux_1\\&#xA; &amp;amp;y\leq (u-q)x_1 + qx_2&#xA;\end{align}&lt;/span&gt;&#xA;However, I am wondering whether it can be achieved using only one inequality?&lt;/p&gt;&#xA;" OwnerUserId="609" LastEditorUserId="500" LastEditDate="2020-09-24T15:13:52.147" LastActivityDate="2020-09-24T16:45:29.277" Title="Can this be formulated as one inequality" Tags="|mixed-integer-programming|modeling|logical-constraints|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4906" PostTypeId="1" AcceptedAnswerId="4916" CreationDate="2020-09-24T14:24:32.427" Score="2" ViewCount="99" Body="&lt;p&gt;I want to know if there is any already defined problem that could give me a hint on how should I approach the following task.&lt;/p&gt;&#xA;&lt;p&gt;There are N tasks that should be accomplished, each task requires different amount of time to complete. On the other hand we have X persons to take care of the tasks but their speed of execution may vary per task. One restriction here is that each person should be designated to a single task. The goal here is to meet the demand of the tasks but also total duration should be kept as low as possible.&lt;/p&gt;&#xA;&lt;p&gt;An easy way to proceed is to set a weight on meet the demand and also reduce the time of execution.(e.g 0.7 for demand and 0.3 for duration). I need to get the optimal weights.&lt;/p&gt;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&lt;p&gt;Demand: total number of tasks: 1000&lt;/p&gt;&#xA;&lt;p&gt;3 different tasks with the following distribution of demand T1: 20%, T2: 40%, T3: 40%&lt;/p&gt;&#xA;&lt;p&gt;How should I formulate the problem so as weights can get into the game?&lt;/p&gt;&#xA;" OwnerUserId="3463" LastEditorUserId="123" LastEditDate="2020-09-24T14:39:23.543" LastActivityDate="2020-09-24T18:23:22.320" Title="Looking for a similar optimization problem" Tags="|optimization|constraint-programming|knapsack|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4907" PostTypeId="2" ParentId="4905" CreationDate="2020-09-24T14:25:43.737" Score="3" Body="&lt;p&gt;I don't think there is a linear inequality covering all the cases or at least I couldn't find any linear inequality for that but the following can be considered:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y\le ux_1-x_1(1-x_2)q$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-09-24T14:25:43.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4908" PostTypeId="2" ParentId="4905" CreationDate="2020-09-24T14:53:55.307" Score="6" Body="&lt;p&gt;As @OguzToragay mentioned, you can do it with one quadratic inequality:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y \le (u-q)x_1 + q x_1 x_2,$$&lt;/span&gt;&#xA;which you can linearize as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y &amp;amp;\le (u-q)x_1 + q z \tag1 \\&#xA;z &amp;amp;\le x_1 \tag2 \\&#xA;z &amp;amp;\le x_2 \tag3 &#xA;\end{align}&lt;/span&gt;&#xA;This linearization is at least as tight as your original formulation because &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; imply your first constraint and &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; imply your second constraint.  In fact, this linearization has the same strength, as you can see by considering the two mutually exclusive cases &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;lt; x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_1 \ge x_2$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-09-24T15:17:22.320" LastActivityDate="2020-09-24T15:17:22.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4909" PostTypeId="2" ParentId="4905" CreationDate="2020-09-24T14:59:40.973" Score="8" Body="&lt;p&gt;It is not possible as a &lt;em&gt;linear&lt;/em&gt; inequality in the variables that you provide.&lt;/p&gt;&#xA;&lt;p&gt;Without loss of generality, this linear inequality would be of the form &lt;span class=&quot;math-container&quot;&gt;$$y \le \alpha x_1 + \beta x_2 + \gamma.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Condition 1 says that for &lt;span class=&quot;math-container&quot;&gt;$x_1=0$&lt;/span&gt;, the right-hand side must be zero for both &lt;span class=&quot;math-container&quot;&gt;$x_2=0$&lt;/span&gt;, which implies &lt;span class=&quot;math-container&quot;&gt;$\gamma=0$&lt;/span&gt;, and for &lt;span class=&quot;math-container&quot;&gt;$x_2=1$&lt;/span&gt;, which then implies &lt;span class=&quot;math-container&quot;&gt;$\beta = 0$&lt;/span&gt; as well.&lt;/p&gt;&#xA;&lt;p&gt;Condition 3 says that for &lt;span class=&quot;math-container&quot;&gt;$x_1=x_2=1$&lt;/span&gt;, the right-hand side must be &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, which implies &lt;span class=&quot;math-container&quot;&gt;$\alpha = u$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You end up with the constraint &lt;span class=&quot;math-container&quot;&gt;$y\le ux_1$&lt;/span&gt;, which clearly does not satisfy condition 2. So you cannot formulate your implications as a single linear constraint.&lt;/p&gt;&#xA;&lt;p&gt;If you are not concerned about linearity, you can formulate quadratically as proposed by Oguz. Even simpler you could just say &lt;span class=&quot;math-container&quot;&gt;$$y \le \min\{ux_1, (u-q)x_1 + qx_2\},$$&lt;/span&gt; which is a single constraint.&#xA;From a computational standpoint, this is unlikely to bring you anything, and linear inequalities would typically be strongly preferred. Having more of them is not necessarily worse, and is often better.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2020-09-24T14:59:40.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4911" PostTypeId="1" CreationDate="2020-09-24T16:08:54.323" Score="0" ViewCount="78" Body="&lt;p&gt;I want to linearize a max constraint as below:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/V0rhS.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/V0rhS.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In which x_(i,t),are binary decision variables and T is a constant.&lt;/p&gt;&#xA;&lt;p&gt;How can I linearize this constraint?&lt;/p&gt;&#xA;" OwnerUserId="4137" LastEditorUserId="2477" LastEditDate="2020-09-24T16:27:25.530" LastActivityDate="2020-09-24T16:27:25.530" Title="Linearizing max constraint Problem" Tags="|modeling|integer-programming|constraint|binary-variable|logical-constraints|" AnswerCount="0" CommentCount="2" ClosedDate="2020-09-24T16:35:46.717" ContentLicense="CC BY-SA 4.0" />
  <row Id="4912" PostTypeId="2" ParentId="4905" CreationDate="2020-09-24T16:38:15.073" Score="5" Body="&lt;p&gt;If you are willing to introduce an additional binary variable and your goal is to have only a single constraint on &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, you could do the following:&lt;/p&gt;&#xA;&lt;p&gt;Introduce three binary variables &lt;span class=&quot;math-container&quot;&gt;$\zeta_{10}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\zeta_{01}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\zeta_{11}$&lt;/span&gt;. Now you need the constraint &lt;span class=&quot;math-container&quot;&gt;$\zeta_{10} + \zeta_{01} + \zeta_{11} \leq 1$&lt;/span&gt; (note that this constraint does not involve &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;). In your model, you then have to substitute all occurences of &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\zeta_{10} + \zeta_{11}$&lt;/span&gt; and all occurences of &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\zeta_{01} + \zeta_{11}$&lt;/span&gt;, effectively getting rid of &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; from your model (thus the number of binary variables in the model only increases by one). Note that this substitution should not introduce non-linearities (although you may have to be careful if you have some big-M type of constraints or some other rewriting tricks to deal with non-linear constraints).&lt;/p&gt;&#xA;&lt;p&gt;Now you can easily define a single linear constraint on &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; as follows: &lt;span class=&quot;math-container&quot;&gt;$y \leq \zeta_{10} (u-q) + \zeta_{11} q$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am not sure if this makes any sense in practice, and I don't think it is more efficient than having multiple constraints on &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in most cases.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastActivityDate="2020-09-24T16:38:15.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4913" PostTypeId="1" CreationDate="2020-09-24T17:39:14.197" Score="8" ViewCount="264" Body="&lt;p&gt;One of the most commonly known combinatorial problems is the set cover problem, which states that given a collection of sets &lt;span class=&quot;math-container&quot;&gt;$S = \{s_1, \dots, s_m\}$&lt;/span&gt; and a universe of elements &lt;span class=&quot;math-container&quot;&gt;$U = \bigcup_{i=1}^m s_i$&lt;/span&gt; we should select the minimum number of sets from &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; such that the union of those sets is equal to &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The LP-relaxation of this problem often pops up in OR techniques and it can obviously be solved in polynomial time with an LP-solver using the following formulation:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{llll}&#xA;\min &amp;amp; \sum_{i \in \{1, \dots, m\}} x_i \\&#xA;\mbox{s.t.} &amp;amp; \sum_{i \in \{1, \dots, m\} \land j \in s_i} x_i &amp;amp; \geq 1 &amp;amp; \forall j \in U \\&#xA; &amp;amp; x_i &amp;amp; \geq 0 &amp;amp; \forall i \in \{1, \dots, m\}\\&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, contrary to some other &amp;quot;classical&amp;quot; combinatorial problems that can be solved in polynomial time, I do not know any other algorithm than using an LP-solver. For the knapsack problem, for example, you can sort the items and use a greedy algorithm to obtain the LP-relaxation. For shortest path and network flow there also many well known algorithms that can be implemented in a reasonable about of time. The only result I know for set cover, is that we can use a greedy algorithm to obtain a &lt;span class=&quot;math-container&quot;&gt;$\ln |U| + 1$&lt;/span&gt; approximation, but this algorithm does not consider the option to select sets fractionally (which is allowed in the LP-relaxation).&lt;/p&gt;&#xA;&lt;p&gt;My question is whether there are more specific algorithms than general LP-solvers that give you the optimal solution to the LP-relaxation of the set cover problem. As a bonus, it would be nice if it is easy to implement.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastActivityDate="2020-09-29T17:31:45.187" Title="Specific algorithms to compute the LP-relaxation of the Set-Cover problem" Tags="|algorithms|lp-relaxation|combinatorics|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4914" PostTypeId="2" ParentId="4885" CreationDate="2020-09-24T17:56:49.503" Score="2" Body="&lt;p&gt;You can try a master problem of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat*}{1}&#xA;\min &amp;amp; \quad \gamma\\&#xA;\textrm{s.t.} &amp;amp; \quad \sum_{s=1}^{S}P_{s}Y_{s}\le\alpha\\&#xA; &amp;amp; \quad \gamma\ge\gamma_{T}\left[\sum_{s\in T}(1-Y_{s})-|T|+1\right]\quad\forall T\in\mathcal{T}\\&#xA; &amp;amp; \quad Y_{s}\in\left\{ 0,1\right\} \quad\forall s\in\left\{ 1,\dots,S\right\} &#xA;\end{alignat*}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{T}$&lt;/span&gt; is a set of subsets of &lt;span class=&quot;math-container&quot;&gt;$\lbrace 1,\dots, S\rbrace$&lt;/span&gt; defined below. Initially &lt;span class=&quot;math-container&quot;&gt;$\mathcal{T}=\emptyset$&lt;/span&gt;. Each time you find a candidate solution &lt;span class=&quot;math-container&quot;&gt;$\hat{Y}$&lt;/span&gt; to the master problem, set &lt;span class=&quot;math-container&quot;&gt;$T=\lbrace s : \hat{Y}_s = 0\rbrace$&lt;/span&gt; and solve the LP&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat*}{1}&#xA;\min &amp;amp; \quad \gamma\\&#xA;\textrm{s.t.} &amp;amp; \quad \gamma\ge(b-\omega^{s})^{\prime}X\quad\forall s\in T.&#xA;\end{alignat*}&lt;/span&gt;&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$\gamma_T$&lt;/span&gt; be the optimal objective value of the LP. If &lt;span class=&quot;math-container&quot;&gt;$\gamma_T$&lt;/span&gt; is greater than the value of &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; in the candidate master solution, add &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\mathcal{T}$&lt;/span&gt; and add the corresponding constraint to the master. Otherwise, do not add a cut. Either way, continue solving the master problem until the MIP solver declares victory.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-24T17:56:49.503" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4915" PostTypeId="2" ParentId="4913" CreationDate="2020-09-24T18:04:52.103" Score="9" Body="&lt;p&gt;Not sure about solving the LP relaxation, but you can get a closed-form lower bound from LP duality, without calling any solver.  Let &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; be the dual variable for constraint &lt;span class=&quot;math-container&quot;&gt;$j\in U$&lt;/span&gt;.  The dual LP is to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_j y_j$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{j \in s_i} y_j &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for $i\in \{1,\dots,m\}$} \\&#xA;y_j &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for $j\in U$}&#xA;\end{align}&lt;/span&gt;&#xA;Now &lt;span class=&quot;math-container&quot;&gt;$$y_j=\min_{\substack{i\in\{1,\dots,m\}:\\ j \in s_i}} \frac{1}{|s_i|}$$&lt;/span&gt; is dual feasible and hence the dual objective value&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j\in U} \min_{\substack{i\in\{1,\dots,m\}:\\ j \in s_i}} \frac{1}{|s_i|}$$&lt;/span&gt; is a valid lower bound.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-09-25T02:11:06.017" LastActivityDate="2020-09-25T02:11:06.017" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4916" PostTypeId="2" ParentId="4906" CreationDate="2020-09-24T18:14:50.667" Score="6" Body="&lt;p&gt;If &amp;quot;total duration&amp;quot; means sum of durations,&#xA;this is called the &lt;a href=&quot;https://en.wikipedia.org/wiki/Generalized_assignment_problem&quot; rel=&quot;noreferrer&quot;&gt;generalized assignment problem&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &amp;quot;total duration&amp;quot; means maximum of durations,&#xA;this is called the &lt;em&gt;bottleneck generalized assignment problem&lt;/em&gt;.  You might also find something useful by searching for &lt;em&gt;makespan minimization&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-09-24T18:23:22.320" LastActivityDate="2020-09-24T18:23:22.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4917" PostTypeId="1" CreationDate="2020-09-24T22:27:45.107" Score="1" ViewCount="606" Body="&lt;p&gt;It has been quite a journey for me to go from 0 to understanding the &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/dotnet/JobshopFt06Sat.cs&quot; rel=&quot;nofollow noreferrer&quot;&gt;job shop&lt;/a&gt; (js) and the &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/python/flexible_job_shop_sat.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;flexible job shop&lt;/a&gt; (fjs) examples given by Google's ORTOOLS team.&lt;/p&gt;&#xA;&lt;p&gt;Now the time has come for me to start modeling my reality which I believe is a variant of the FJS example above.&lt;/p&gt;&#xA;&lt;p&gt;In my case :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Instead of having 1 resource per alternatives I need to have several resources per alternatives. For example, to perform task A I need to have Machine 1 &lt;strong&gt;and&lt;/strong&gt; employee number 412 (alternative 1) or Machine 1 &lt;strong&gt;and&lt;/strong&gt; employee number 516 (alternative 2) or machine 2 &lt;strong&gt;and&lt;/strong&gt; machine 3 (alternative 3).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So, my take on this for now is :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Instead of having an alternative task described as [(3, 0), (1, 1), (5, 2)] I'm thinking of having something like [(3, List1), (1, List2), (5, List3)] where List1, List2 and List3 are sets of resources with different combinations.&lt;/li&gt;&#xA;&lt;li&gt;Then having a &lt;em&gt;NewBoolVar&lt;/em&gt; for each set of resources I have and implement it just as I saw in the example above.&lt;/li&gt;&#xA;&lt;li&gt;But the enigma for me is how to force resources to be available at the same Interval ?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Before spending too much coding time in the wrong direction I wanted to ask some questions to the public :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is it in your opinion the right approach to the problem (having a set of resources, a bool to toggle between the sets, and a way to have resources available in the same interval)?&lt;/li&gt;&#xA;&lt;li&gt;Do you see another way of solving this?&lt;/li&gt;&#xA;&lt;li&gt;Is there references/examples on this subject that I have missed (I didn't find any example with an alternative more than 1 machine/resource)?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As I said I'm in a learning process so don't hesitate to suggest learning paths.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2020-09-24T22:51:18.023" LastActivityDate="2020-09-25T08:48:18.613" Title="Flexible Job Shop Problem with several resources per alternative - Ortools" Tags="|python|or-tools|c#|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4919" PostTypeId="1" CreationDate="2020-09-25T08:12:16.463" Score="2" ViewCount="497" Body="&lt;p&gt;I'm solving a MILP model whose native lower bound (via linear relaxation) is very poor. We could provide a lower bound by providing a given value (derived based on the problem itself). I know that directly adding a numerical lower bound on the objective may do no good (sometimes it leads to a worse case by misleading the search procedure). I tried both cases: with and without the numeric lower bound.  However, in neither case, CPLEX finds the optimal solution in more than ten hours with out of memory.&lt;/p&gt;&#xA;&lt;p&gt;My problem is what makes my specific model so hard to solve?&lt;/p&gt;&#xA;" OwnerUserId="4149" LastEditorUserId="279" LastEditDate="2020-09-25T20:27:45.227" LastActivityDate="2020-09-25T21:04:53.650" Title="How can I identify the reason that makes a MILP model hard for solvers such as CPLEX?" Tags="|mixed-integer-programming|cplex|gurobi|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4920" PostTypeId="2" ParentId="4917" CreationDate="2020-09-25T08:48:18.613" Score="1" Body="&lt;p&gt;The sum(bool_vars) tells you each job has only one way to be executed.&#xA;It does not tell you what is 'a' way.&lt;/p&gt;&#xA;&lt;p&gt;You can reuse the bool_var from each alternative in multiple resources.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2020-09-25T08:48:18.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4921" PostTypeId="1" CreationDate="2020-09-25T13:21:45.677" Score="4" ViewCount="136" Body="&lt;p&gt;Suppose I want to find the minimum of a differentiable, strongly convex function &lt;span class=&quot;math-container&quot;&gt;$f:\mathbb{R}^n\to\mathbb{R}$&lt;/span&gt; with constant &lt;span class=&quot;math-container&quot;&gt;$\mu&amp;gt;0$&lt;/span&gt;. That is, for all &lt;span class=&quot;math-container&quot;&gt;$x,y\in\mathbb{R}^n$&lt;/span&gt;, I have that:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(y) \geq f(x)+\nabla f(x)^{T}(y-x)+\frac{\mu}{2}\|y-x\|^{2}.$$&lt;/span&gt;&#xA;If I can efficiently evaluate &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and its gradient, then it is clear how to find the minimum of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; with first-order methods.&#xA;But now assume that I only have access to approximate entries of &lt;span class=&quot;math-container&quot;&gt;$\nabla f(x)$&lt;/span&gt;, say up to an additive error &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;. What is the state of the art result on how small &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; has to be compared to &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; so that I can still ensure convergence of some optimization method to an approximate minimum?&lt;/p&gt;&#xA;" OwnerUserId="3918" LastEditorUserId="491" LastEditDate="2021-04-07T13:43:22.123" LastActivityDate="2021-04-13T08:27:27.473" Title="Optimization of strongly convex functions with approximate evaluations of gradient and Hessian" Tags="|optimization|convexity|convex-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4922" PostTypeId="2" ParentId="4919" CreationDate="2020-09-25T16:29:21.133" Score="10" Body="&lt;p&gt;MILPs are NP-hard. People make a big deal about NP-hardness for a reason - in the worst case they are very, very hard to solve.&lt;/p&gt;&#xA;&lt;p&gt;There is a short, easy to understand exposition of this by @Johan Löfberg : &lt;a href=&quot;https://yalmip.github.io/slowmilp&quot; rel=&quot;noreferrer&quot;&gt;Why is my MILP not finishing&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Johan provides an example: For a MILP with 72 binary variables, in the worst case, a MILP solver will have to solve &lt;span class=&quot;math-container&quot;&gt;$2^{72}$&lt;/span&gt; continuous LPs (MILP relaxations). That is &lt;span class=&quot;math-container&quot;&gt;$4.2  *10^{21}$&lt;/span&gt; LPs to solve in the worst case. If 10,000 LPs are solved per second, that would require the age of the universe (since the big bang).&lt;/p&gt;&#xA;&lt;p&gt;So consider yourself fortunate when a MILP solver does better than this worst case, which is not that infrequently, otherwise MILP solver vendors wouldn't get many paying customers.&lt;/p&gt;&#xA;&lt;p&gt;Put another way. MILPs are hard to solve in general. Some MILPs wind up not being so hard to solve, but it is often not easy to predict which will be which.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-09-25T16:29:21.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4923" PostTypeId="2" ParentId="4919" CreationDate="2020-09-25T21:04:53.650" Score="5" Body="&lt;p&gt;Solver-related comments below are specific to CPLEX but may apply to some other solvers.&lt;/p&gt;&#xA;&lt;p&gt;First comment: Out of memory errors can be postponed (by tweaking the parameter settings for swapping stuff out to disk) or possibly eliminated (by switching to depth-first search). Neither guarantees the optimum will be found within your lifetime.&lt;/p&gt;&#xA;&lt;p&gt;Second comment: If you have not already done so, you might try switching the MIP emphasis from its default setting to the setting that stressed tightening the best bound. In addition, there are a variety of settings that can be tweaked to increase the use of various cuts (which may or may not help), or to use strong branching (which may or may not help). Switching emphasis changes some of those for you (I think), but I couldn't say which ones.&lt;/p&gt;&#xA;&lt;p&gt;Third comment: You might want to look at an excellent paper by Klotz and Newman titled &amp;quot;Practical Guidelines for Solving Difficult Mixed Integer Linear Programs&amp;quot; (Surveys in Operations Research and Management Science, 2013, &lt;strong&gt;18&lt;/strong&gt;, 18-32). There's a &lt;a href=&quot;http://inside.mines.edu/%7Eanewman/MIP_practice120212.pdf&quot; rel=&quot;noreferrer&quot;&gt;proof (PDF)&lt;/a&gt; on Alexandra Newman's web site.&lt;/p&gt;&#xA;&lt;p&gt;Fourth comment: Some formulations are known to be weak. A classic example is a &amp;quot;big M&amp;quot; model with a, well, big &amp;quot;M&amp;quot;. If you can tighten your formulation, that should be your first choice. Unfortunately, tighter formulations are not always easy to find.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-25T21:04:53.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4925" PostTypeId="1" CreationDate="2020-09-26T11:36:55.927" Score="3" ViewCount="207" Body="&lt;p&gt;Is there a website that compiles the best known results on the &lt;strong&gt;flexible jobshop&lt;/strong&gt; problem ?&lt;/p&gt;&#xA;&lt;p&gt;I know there was a blog post/article by &lt;em&gt;Quintiq&lt;/em&gt;, a (deleted) blog post on &lt;em&gt;CP Optimizer&lt;/em&gt;, some more recent articles, but nothing easy to read.&lt;/p&gt;&#xA;&lt;p&gt;I have some good results with &lt;em&gt;OR-Tools CP-SAT&lt;/em&gt;, but it is hard to judge exactly their quality.&lt;/p&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2023-12-22T15:10:41.277" LastActivityDate="2024-02-15T10:12:30.653" Title="Best known results on the flexible jobshop benchmarks" Tags="|combinatorial-optimization|scheduling|or-tools|cp-sat|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4926" PostTypeId="1" AcceptedAnswerId="4929" CreationDate="2020-09-26T20:43:57.523" Score="3" ViewCount="126" Body="&lt;p&gt;I am new to linear programming, and I recently came across the following exercise, which I do not know how to solve:&lt;/p&gt;&#xA;&lt;p&gt;When publishing data, it is sometimes important to &amp;quot;suppress&amp;quot; sensitive information. Consider the following table:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{|c|c|c|c|}&#xA;\hline&#xA;&amp;amp;  &amp;amp;  &amp;amp; X &amp;amp;  \\ \hline&#xA;X &amp;amp; &amp;amp; &amp;amp; &amp;amp; \\ \hline&#xA; &amp;amp; X &amp;amp; &amp;amp; \\ \hline&#xA; &amp;amp; X &amp;amp; X &amp;amp; \\ \hline &#xA;&amp;amp; &amp;amp; &amp;amp;  &amp;amp; X\\ \hline&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Values marked with an &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; indicate cells whose data need to be suppressed (note that the values of these cells might not be the same even though I'm indicating them with the same variable &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;). However, there is one problem: we want to also report the sum of the rows and columns. This means that one could easily derive the value of each of the &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;'d cells by just setting up a system of equations and solving. For example, you could easily derive the leftmost &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; cell by just computing the sum of the values in the first column and subtracting the first column's sum by the computed sum.&lt;/p&gt;&#xA;&lt;p&gt;This means that it might be necessary to suppress cells that are not marked by &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; in order to protect the contents of the &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;-marked cells. I want to formulate an integer linear programming problem that will choose the smallest number of suppressions needed in order to protect all of the &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;-marked cells. So it will be necessary to have at least two suppressed values in each row and column.&lt;/p&gt;&#xA;&lt;p&gt;I thought about having &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; equal &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if the cell &lt;span class=&quot;math-container&quot;&gt;$(i, j)$&lt;/span&gt; is suppressed and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise so we want to minimize the sum over all &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt;'s, but then coming up with the actual constraints is really hard (at least for me). I've thought about this problem for a few hours now, and I think the hardest part about it is coming up with a set of constraints. I've looked at lots of examples of formulations, but I haven't come across anything similar yet. I would appreciate any help with this problem.&lt;/p&gt;&#xA;" OwnerDisplayName="user4156" LastEditorDisplayName="user4156" LastEditDate="2020-09-26T22:35:40.523" LastActivityDate="2020-09-28T14:46:51.103" Title="Modelling a data-sensitivity scenario as an ILP problem" Tags="|linear-programming|integer-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4927" PostTypeId="2" ParentId="4926" CreationDate="2020-09-26T22:04:44.127" Score="3" Body="&lt;p&gt;For the suppression to be successful, what you need is that there some nonzero amount of &amp;quot;noise&amp;quot; you can add to each suppressed cell such that the row and column sums are unaffected (meaning the sum of the noise in each row is zero, and similarly for the noise in each column). The noise in each suppressed cell may be different from the noise in any other cell, and clearly noise will need to be negative in some cells and positive in others to get row/column sums to zero out. You also need the noise in any cell that is not suppressed to be zero. So you might consider two sets of binary variables, say &lt;span class=&quot;math-container&quot;&gt;$x_{rc}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{rc}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x_{rc}=1$&lt;/span&gt; means cell &lt;span class=&quot;math-container&quot;&gt;$(r,c)$&lt;/span&gt; has positive noise and &lt;span class=&quot;math-container&quot;&gt;$y_{rc}=1$&lt;/span&gt; means cell &lt;span class=&quot;math-container&quot;&gt;$(r,c)$&lt;/span&gt; has negative noise (and &lt;span class=&quot;math-container&quot;&gt;$x_{rc}=0=y_{rc}$&lt;/span&gt; means cell &lt;span class=&quot;math-container&quot;&gt;$(r,c)$&lt;/span&gt; has zero noise and is not suppressed). The full formulation is left as an exercise. :-)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-26T22:04:44.127" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4928" PostTypeId="1" CreationDate="2020-09-27T13:53:37.500" Score="1" ViewCount="114" Body="&lt;p&gt;I have a Markov chain problem below, where :&lt;/p&gt;&#xA;&lt;h3&gt;The problem&lt;/h3&gt;&#xA;&lt;p&gt;An urn initially contains 3 black balls and 1 red ball. The balls are indistinguishable to the touch. One ball is randomly drawn.&lt;/p&gt;&#xA;&lt;p&gt;If this ball is black, it is removed.&#xA;If this ball is red, we put it back in the urn.&#xA;The operation is repeated until the urn contains only the red ball.&lt;/p&gt;&#xA;&lt;p&gt;1- Let Xn be the number of black balls contained in the urn after n prints.&#xA;Show that (Xn)n∈N is a Markov chain.&lt;/p&gt;&#xA;&lt;p&gt;2- Give its associated and reduced graph and its transition matrix. Is the chain homogeneous?&lt;/p&gt;&#xA;&lt;p&gt;3- Classify the states.&lt;/p&gt;&#xA;&lt;p&gt;4- What type of chain (absorbent, irreducible, ergodic) is it?&lt;/p&gt;&#xA;&lt;p&gt;5- Give a possible trajectory of size 10.&lt;/p&gt;&#xA;&lt;p&gt;6- Determine the expectation of the number of prints until the urn contains only the red ball.&lt;/p&gt;&#xA;&lt;p&gt;7- Does the chain admit a stationary distribution? a borderline distribution? Calculate limP^(n), where 'n' tends towards infinity.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Solution&lt;/h3&gt;&#xA;&lt;p&gt;1- We denote that E=(1,2,3) and the process is discrete to a discrete state space the state of Xn+1 depends only on the previous state Xn,&lt;/p&gt;&#xA;&lt;p&gt;Therefore Xn is a Markov chain.&lt;/p&gt;&#xA;&lt;p&gt;2-&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Transition Matrix :&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YKU0F.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YKU0F.png&quot; alt=&quot;Transition matrix&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Associated graph :&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kok5j.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kok5j.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The chain is not homogeneous because p(2/3) is different from p(2/1).&lt;/p&gt;&#xA;&lt;p&gt;3- Classify the states: state classification: we have three transitory states (class):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;State 1 does not communicate with any state other than itself.&lt;/li&gt;&#xA;&lt;li&gt;State 2 communicates with state 1 but state 1 does not communicate (same for state 3 ).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Hence: E={1}U{2}U{3}.&lt;/p&gt;&#xA;&lt;p&gt;4-&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The chain is not ergodic because it does not admit a recurrent state.&lt;/li&gt;&#xA;&lt;li&gt;The chain is not irreducible because it admits 3 classes.&lt;/li&gt;&#xA;&lt;li&gt;The chain is absorbent because state 1 is an absorbent state and all non-absorbent states (2/3) reach state 1.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;5- Trajectory of size 10 :&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iR6N8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iR6N8.png&quot; alt=&quot;Trajectory of size 10&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Help&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can you please tell me if I'm correct and I'm doing good, if not please correct me.&lt;/li&gt;&#xA;&lt;li&gt;Can anyone please guide me solve questions 5 and 6.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3806" LastEditorUserId="3806" LastEditDate="2020-09-27T14:08:26.340" LastActivityDate="2020-09-27T14:08:26.340" Title="Markov Chain - Stationary or Borderline distribution" Tags="|probability-distributions|markov-decision-process|probability-theory|" AnswerCount="0" CommentCount="1" ClosedDate="2020-11-03T08:34:36.113" ContentLicense="CC BY-SA 4.0" />
  <row Id="4929" PostTypeId="2" ParentId="4926" CreationDate="2020-09-27T14:31:46.960" Score="1" Body="&lt;p&gt;With your decision variables, some necessary constraints are&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j x_{i,j} &amp;amp;\ge 2 &amp;amp;&amp;amp;\text{for all rows $i$ that contain an $X$}\\&#xA;\sum_i x_{i,j} &amp;amp;\ge 2 &amp;amp;&amp;amp;\text{for all columns $j$ that contain an $X$}\\&#xA;x_{i,j} &amp;amp;=1 &amp;amp;&amp;amp;\text{for all $X$-marked cells}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-09-28T14:46:51.103" LastActivityDate="2020-09-28T14:46:51.103" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4930" PostTypeId="1" AcceptedAnswerId="4931" CreationDate="2020-09-27T19:31:34.877" Score="5" ViewCount="159" Body="&lt;p&gt;Consider the network flow polyhedron for a directed graph &lt;span class=&quot;math-container&quot;&gt;$G = (N, A)$&lt;/span&gt;. Along with the standard flow-balance and single-arc capacity constraints, we are faced with additional constraints which enforce capacities on the total flow through subsets of arcs. Formally, for (not necessarily disjoint) subsets &lt;span class=&quot;math-container&quot;&gt;$S_1, S_2, \dots, S_k \subseteq A$&lt;/span&gt; we have constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{a \in S_i} x_a \leq u_{S_i} \quad \forall i \in [k].$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Do such constraints have a specific name in the network flow literature, or have they been specifically studied? I'm mostly interested in the polyhedral aspects of these constraints, but applications would be interesting as well.&lt;/p&gt;&#xA;" OwnerUserId="196" LastEditorUserId="500" LastEditDate="2020-09-27T20:35:09.803" LastActivityDate="2020-09-27T20:35:09.803" Title="Combined arc capacity constraints in network flows" Tags="|reference-request|constraint|network-flow|terminology|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4931" PostTypeId="2" ParentId="4930" CreationDate="2020-09-27T20:17:06.680" Score="5" Body="&lt;p&gt;These are called &lt;em&gt;Generalized Upper Bound&lt;/em&gt; (GUB) constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-09-27T20:17:06.680" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4932" PostTypeId="1" AcceptedAnswerId="4935" CreationDate="2020-09-28T02:35:59.200" Score="3" ViewCount="345" Body="&lt;p&gt;I've been recently reading some papers where the authors use &lt;em&gt;local branching&lt;/em&gt; specifically in Benders Decomposition (&lt;a href=&quot;http://www.or.deis.unibo.it/research_pages/ORinstances/mic2003-lb.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;see&lt;/a&gt; for reference). Although I understand up to some extend how the algorithm works, I am having hard time to understand how it is implemented in practice.&lt;/p&gt;&#xA;&lt;p&gt;For instance, it is stated that we can divide the feasible region into two parts by using &lt;span class=&quot;math-container&quot;&gt;$\Delta(x_o,x) \leq \kappa$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\Delta(x_o,x) \geq \kappa+1$&lt;/span&gt; which are identified as the left and right branches, respectively.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering if someone can briefly explain how this operation can be performed from the coding perspective when using in Java API using &lt;code&gt;CPLEX&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Some academic references are:&lt;/p&gt;&#xA;&lt;p&gt;Rei, W., Cordeau, J. F., Gendreau, M., &amp;amp; Soriano, P. (2009). &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.1080.0296&quot; rel=&quot;nofollow noreferrer&quot;&gt;Accelerating Benders decomposition by local branching&lt;/a&gt;. INFORMS Journal on Computing, 21(2), 333-345.&lt;/p&gt;&#xA;&lt;p&gt;Baena, D., Castro, J., &amp;amp; Frangioni, A. (2020). &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/mnsc.2019.3341&quot; rel=&quot;nofollow noreferrer&quot;&gt;Stabilized benders methods for large-scale combinatorial optimization, with application to data privacy&lt;/a&gt;. Management Science.&lt;/p&gt;&#xA;" OwnerUserId="4025" LastActivityDate="2020-09-28T18:30:08.720" Title="Implementation of Local Branching" Tags="|cplex|benders-decomposition|java|branch-and-cut|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4935" PostTypeId="2" ParentId="4932" CreationDate="2020-09-28T18:30:08.720" Score="4" Body="&lt;p&gt;You need to use a callback, and CPLEX introduced a new callback system (&amp;quot;generic callbacks&amp;quot;) in version 12.8 (I think) while maintaining support, at least for now, for the original callback system (&amp;quot;legacy callbacks&amp;quot;). The details of doing the branching depend in part on which system you use.&lt;/p&gt;&#xA;&lt;p&gt;With legacy callbacks, you create a class that extends IloCplex.BranchCallback and attach it to your model using IloCplex.use(). Inside the main() method, you use one of the overloads of makeBranch() to make each branch. To create two child nodes, you call makeBranch() twice.&lt;/p&gt;&#xA;&lt;p&gt;With generic callbacks, you create a class that implements the IloCplex.Callback.Function interface and attach it to your model using a different overload of IloCplex.use(). In this overload of use(), you have to specify a mask for the contexts in which the callback is invoked, and in particular you will need to include the &amp;quot;branching&amp;quot; context in the mask. The class implementing IloCplex.Callback.Function will have a method invoke(), which CPLEX will call, passing in an argument of type IloCplex.Callback.Context. Within your implementation of invoke(), after checking if necessary to be sure you are in the branching context, you invoke the context object's makeBranch() method once for each child node.&lt;/p&gt;&#xA;&lt;p&gt;In both approaches, attempting to create more than two children at a node will cause the space-time continuum to collapse in on itself.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-28T18:30:08.720" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4936" PostTypeId="1" CreationDate="2020-09-28T21:32:35.467" Score="3" ViewCount="790" Body="&lt;p&gt;What are the solvers that take the maximal computation time as a parameter and gives the best found feasible solution within this time.&lt;/p&gt;&#xA;" OwnerUserId="3711" LastEditorUserId="3711" LastEditDate="2020-09-29T07:13:38.620" LastActivityDate="2020-09-29T15:04:35.983" Title="What are the solvers that give a feasible solution within a given time?" Tags="|integer-programming|solver|constraint-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4937" PostTypeId="1" CreationDate="2020-09-28T22:01:16.180" Score="2" ViewCount="593" Body="&lt;p&gt;I know that MILP solvers are bad with scheduling problems.&#xA;However, if we are allowed to keep unscheduled some tasks (i.e a solution with 0 scheduled tasks is a feasible solution but we add the objective (makespan) the maximiation of scheduled tasks), does things become easier?&lt;/p&gt;&#xA;" OwnerUserId="3711" LastActivityDate="2020-09-29T18:22:31.530" Title="Does it make sense to use a MILP solver for a scheduling problem but without the obligation to schedule all the tasks?" Tags="|mixed-integer-programming|solver|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4938" PostTypeId="2" ParentId="4937" CreationDate="2020-09-29T00:08:27.030" Score="5" Body="&lt;p&gt;That's a misconception - MILP solvers can be brilliant with scheduling tasks as long as the modeler knows their stuff, but that's true of all NP-Hard optimisation problems. The snag is that a certain level of custom modelling work is typically needed for real problems, but this is not a solver limitation per se.&lt;/p&gt;&#xA;&lt;p&gt;If what you have in mind is to make the scheduling of some tasks optional in order to aid the solver, then many solvers support lazy constraints.&lt;/p&gt;&#xA;&lt;p&gt;This is not trivial to model properly because you still need to ensure that the tasks are scheduled some of the time, but to answer your question directly no, it's not necessarily easier. The only way to check is to try out both formulations and see what works best for a particular problem.&lt;/p&gt;&#xA;&lt;p&gt;In global optimisation (including MILP), constraints are our friends because they help us reduce the solution space. However, the problem is NP-Hard &lt;strong&gt;because&lt;/strong&gt; (or the other way around depending on your preference) there is no one-size-fits-all way to change the problem to make it easier. For some problems constraining the system more tightly helps a lot, for others it makes things much worse.&lt;/p&gt;&#xA;&lt;p&gt;From experience, what does work much better than MILP if you &lt;strong&gt;need&lt;/strong&gt; to have fuzzy scheduling is to formulate an MINLP.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-09-29T00:08:27.030" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="4939" PostTypeId="2" ParentId="4936" CreationDate="2020-09-29T00:14:31.577" Score="8" Body="&lt;p&gt;Pretty much all of them. Any solver worth using will support timeouts and what you describe is basically running a solver with a timeout.&lt;/p&gt;&#xA;&lt;p&gt;Solvers that are supposed to compute more than one solution (e.g. MILP, convex &amp;amp; global MINLP, global NLP, stochastic MILP &amp;amp; MINLP) will return the best one by timeout - the rest will typically return garbage if a solution is not computed by timeout.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-09-29T00:14:31.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4940" PostTypeId="1" AcceptedAnswerId="4941" CreationDate="2020-09-29T00:23:50.113" Score="1" ViewCount="224" Body="&lt;p&gt;I need to formulate the following problem as a Mixed Integer Linear Programming problem&lt;/p&gt;&#xA;&lt;p&gt;A farmer needs to establish a 17-year business plan where he will decide when to sell or buy a new truck. The farmer cannot sell the truck before it is two years old but he must sell it by the time it is 5 years old. The price of a new truck is 43,000 USD but loses 10% of its value when bought plus an extra 7% each year. Aditionally, we know that truck prices go up 5% every year with respect to last year.&lt;/p&gt;&#xA;&lt;p&gt;The annual operating expense of the truck is 1300 USD and each year it goes up by 15%.&lt;/p&gt;&#xA;&lt;p&gt;So far, the only thing that I have is that I need to minimize the &lt;em&gt;cost - profit&lt;/em&gt; function but have no idea how to make it linear or how to even begin to formulate the restrictions. Every similar problem that I have found uses a dynamic programming approach.&lt;/p&gt;&#xA;" OwnerUserId="4163" LastEditorUserId="500" LastEditDate="2020-09-29T12:36:29.260" LastActivityDate="2020-09-30T00:21:19.663" Title="Formulate a problem as Mixed Linear Programming problem" Tags="|mixed-integer-programming|dynamic-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4941" PostTypeId="2" ParentId="4940" CreationDate="2020-09-29T01:51:53.130" Score="1" Body="&lt;p&gt;From context, I'm assuming that the farmer always needs to have a truck, and the question is when he should replace it.&lt;/p&gt;&#xA;&lt;p&gt;For the constraints, you can formulate in terms of 17 binary decision variables: &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; = &amp;quot;replace in year 1?&amp;quot;, &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; = &amp;quot;replace in year 2?&amp;quot;, ...etc.&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Cannot sell before it is two years old&amp;quot;: i.e. cannot replace in two consecutive years, i.e. no two consecutive &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; can both be 1. So &lt;span class=&quot;math-container&quot;&gt;$x_1+x_2 \le 1, x_2+x_3 \le 1, ...$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Must sell by the time it is five years old&amp;quot;: i.e. if we replace it in year &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, must replace again somewhere between years &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n+5$&lt;/span&gt;. That is, if &lt;span class=&quot;math-container&quot;&gt;$x_n=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{n+1}, x_{n+2},...,x_{n+5}$&lt;/span&gt; can't all be zero. Since they're all binary variables, this can be expressed as: &lt;span class=&quot;math-container&quot;&gt;$x_n \le x_{n+1}+x_{n+2}+...+x_{n+5}$&lt;/span&gt;. (I'll leave it to you to figure out how to handle the ends of the time period.)&lt;/p&gt;&#xA;&lt;p&gt;The replacement costs are then a simple linear function of your &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, since they only depend on what year you're buying new trucks - the fact that it's an exponential function of the year doesn't matter, it's still linear in your x-variables.&lt;/p&gt;&#xA;&lt;p&gt;The tricky part of the problem is in how to handle the costs that depend on how long you've had the truck, i.e. operating expenses and -1*resale value.&lt;/p&gt;&#xA;&lt;p&gt;One way to handle this in a linear framework would be to introduce a set of auxiliary binary variables &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}=1$&lt;/span&gt; if and only if there is a truck which is bought in year &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and sold in year &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can then express the total operating costs and resale minus-costs as a linear function of these &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; (again, be sure to consider end cases!). Now you just need to set some constraints that relate the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; to the &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; in a way that enforces the definition of &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt;. That is: &lt;span class=&quot;math-container&quot;&gt;$y_{i,j} = 1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$x_i=x_j=1$&lt;/span&gt; and none of the values between them are 1. This can be done by two linear inequality constraints which shouldn't be too hard to figure out - if you have difficulty here please comment and I'll expand on it.&lt;/p&gt;&#xA;&lt;p&gt;This expands the problem size a bit, because you're creating 17^2 = 289 extra auxiliary variables, but if efficiency is a concern you can cut that down quite a bit by noticing that &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; can only be 1 if &lt;span class=&quot;math-container&quot;&gt;$2 \le j-i \le 5$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;edit: as Rob Pratt suggested in comments, you can eliminate the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; from the problem altogether by applying flow balance constraints: if &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}=1$&lt;/span&gt; there must be exactly one &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$y_{j,k}=1$&lt;/span&gt; and so forth. (Again, glossing over end conditions.)&lt;/p&gt;&#xA;&lt;p&gt;Keeping the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;s in the problem may make it easier to understand what's going on, but being able to transform the problem is a very useful skill and worth developing.&lt;/p&gt;&#xA;" OwnerUserId="546" LastEditorUserId="546" LastEditDate="2020-09-30T00:21:19.663" LastActivityDate="2020-09-30T00:21:19.663" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4943" PostTypeId="1" CreationDate="2020-09-29T08:14:39.187" Score="2" ViewCount="1142" Body="&lt;p&gt;Did anyone have experiences with Pyomo and GAMS as solver? I had looked into the pyomo documentation (&lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/library_reference/solvers/gams.html#pyomo.solvers.plugins.solvers.GAMS.GAMSShell.solve&quot; rel=&quot;nofollow noreferrer&quot;&gt;GAMSShell Solver&lt;/a&gt;) and in the CPLEX Manuals, but doesnt find the correct syntax.&lt;/p&gt;&#xA;&lt;p&gt;My Code looks like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;slv = SolverFactory('gams')&#xA;results = slv.solve(model, tee=True,timelimit=100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have also tried it with the io_options=dict(timelimit=100):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;results = slv.solve(model,tee=True,io_options=io_options)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I get all time the error: &amp;quot;ValueError - GAMS writer passed unrecognized io_options&amp;quot;. I think the problem I have is that I havent the correct parameter to set the time limit over the Python GAMS API.&lt;/p&gt;&#xA;&lt;p&gt;Did anyone know how I can set the time limit with the GAMS Python API ?&lt;/p&gt;&#xA;" OwnerUserId="4164" LastActivityDate="2021-09-01T04:07:17.260" Title="How to set solver options in Pyomo with GAMS Python API?" Tags="|optimization|python|solver|gams|api|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4944" PostTypeId="2" ParentId="4936" CreationDate="2020-09-29T09:26:50.287" Score="3" Body="&lt;p&gt;In &lt;a href=&quot;https://www.optaplanner.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner&lt;/a&gt; (open source, java), we not just support the traditional approaches such as &lt;strong&gt;the solving wall clock time&lt;/strong&gt; in &lt;code&gt;application.properties&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Terminate solving after 30 seconds.&#xA;# To run for 5 minutes use &amp;quot;5m&amp;quot; and for 2 hours use &amp;quot;2h&amp;quot;.&#xA;optaplanner.solver.termination.spent-limit=30s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or the &lt;strong&gt;unimproved wall clock time&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Terminate if the best score hasn't improved for 30 consecutive seconds.&#xA;optaplanner.solver.termination.unimproved-spent-limit=30s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or &lt;strong&gt;a certain score has been attained&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Terminate when the first feasible solution has been found&#xA;optaplanner.solver.termination.best-score-limit=0hard/*soft&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or an AND/OR combination of those and/or several other pre-configured terminations (&lt;a href=&quot;https://docs.optaplanner.org/latestFinal/optaplanner-docs/html_single/index.html#termination&quot; rel=&quot;nofollow noreferrer&quot;&gt;full list here&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;We also support &lt;strong&gt;asynchronous termination&lt;/strong&gt;, which is very powerful in combination with best solution changed events, to &lt;em&gt;give the end-users control over their own time&lt;/em&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;SolverJob solverJob = solverManager.solveAndListen(...,&#xA;    // Each time we have a new best solution, show the latest one to the user&#xA;    newBestSolution -&amp;gt; showOnScreen(newBestSolution));&#xA;...&#xA;// When the user is satified with the shown solution and tired of waiting&#xA;terminateButton.onClick(solverJob.terminateEarly());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;That feedback loop can be important.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2020-09-29T15:04:35.983" LastActivityDate="2020-09-29T15:04:35.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4945" PostTypeId="1" CreationDate="2020-09-29T14:20:50.480" Score="4" ViewCount="246" Body="&lt;p&gt;It's been a few years since I graduated from university with an engineering MSc degree, during which I focussed a lot on OR and quantitative techniques for mobility and logistics problems. Right after graduating and during the last couple of years, I have had several opportunities to start a PhD in my field. However, I have always turned down the options mostly because I wanted to have direct impact and work with clients. After three years in consultancy, and now in my second job, I start noticing that I often desire to delve deeper into problems and still enjoy the puzzle-solving. We are picking up on that field in my current work place, but the applications and projects remain limited / hard to get.&lt;/p&gt;&#xA;&lt;p&gt;What would you advice to advance my career in OR?&lt;/p&gt;&#xA;&lt;p&gt;edit: advice could include things like changing to academia, finding senior 'mentors', advice on types of positions and self-development etcetra?&lt;/p&gt;&#xA;" OwnerUserId="954" LastEditorUserId="123" LastEditDate="2021-02-17T11:39:28.327" LastActivityDate="2021-02-17T12:23:03.390" Title="How to find advice for OR career?" Tags="|job-market|or-careers|phd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4946" PostTypeId="1" AcceptedAnswerId="4951" CreationDate="2020-09-29T14:56:10.777" Score="3" ViewCount="777" Body="&lt;p&gt;I have a LP with equality and inequality constraints.&lt;/p&gt;&#xA;&lt;p&gt;When solving the LP with the &lt;strong&gt;excel-solver&lt;/strong&gt; (&lt;strong&gt;GRG Nonlinear&lt;/strong&gt;) the sensitivity report returns the lagrange multiplier for all constraints.&lt;/p&gt;&#xA;&lt;p&gt;When solving the problem with the &lt;strong&gt;excel-solver&lt;/strong&gt; (&lt;strong&gt;Simplex LP&lt;/strong&gt;) however, the sensitivity report returns the shadow price for all constraints.&lt;/p&gt;&#xA;&lt;p&gt;From my understanding those two should be the same but they are not. Why is this the case?&#xA;For some constraints they are the same while for others they differ substantially (0 vs. 6.653 for instance).&lt;/p&gt;&#xA;&lt;p&gt;When I use Matlab &lt;strong&gt;linprog&lt;/strong&gt; I get the same results as the &lt;strong&gt;excel-solver&lt;/strong&gt; (&lt;strong&gt;GRG Nonlinear&lt;/strong&gt;) which confuses me since it uses the &lt;strong&gt;dual-simplex&lt;/strong&gt;. My &lt;strong&gt;Gurobi model&lt;/strong&gt; using the &lt;strong&gt;attribute reduced cost&lt;/strong&gt; on the other hand returns the same as the &lt;strong&gt;excel-solver&lt;/strong&gt; (&lt;strong&gt;Simplex LP&lt;/strong&gt;).&lt;/p&gt;&#xA;&lt;p&gt;It seems I have a misunderstanding about the equality of the lagrange multiplier and the reduced cost. Can anyone explain where this error comes from?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Model&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tFmJP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tFmJP.png&quot; alt=&quot;Model&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Sensitivity Report comparison&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/zlSO0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zlSO0.png&quot; alt=&quot;Sensitivity Report comparison&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4128" LastActivityDate="2020-09-29T21:10:18.157" Title="Why is the Lagrange Multiplier not equal the Shadow Price (Excel solver, Matlab linprog, Gurobi)?" Tags="|linear-programming|gurobi|matlab|excel|lagrange-multipliers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4947" PostTypeId="1" CreationDate="2020-09-29T15:44:17.457" Score="1" ViewCount="169" Body="&lt;p&gt;I want to solve the following portfolio optimization problem by means of the Python API of Gurobi: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max_w&amp;amp;\quad w^\top\Pi\\\text{s.t.}&amp;amp;\quad w^\top\Sigma w=\sigma^{\rm target}\\&amp;amp;\quad\sum_{i=1}^nw_i=1-{\rm cash}\\&amp;amp;\quad l_i\le w_i\le u_i\quad\forall i\in\{1,\ldots,n\}\quad\small\text{(absolute constraints})\\&amp;amp;\quad w_j=0\quad\forall j\in{\cal J}\quad\small\text{(certain assets are excluded from the portfolio)}\\&amp;amp;\quad L_j\le\sum_{s\in G_j}w_s\le U_j\quad\forall j\in\{1,\ldots,t\}\quad\small\text{(group constraints)}\\&amp;amp;\quad|w_i-w_i^{\rm start}|\Bbb I_{\{|w_i-w_i^{\rm start}|&amp;gt;0\}}\ge\textsf{rebalancing_threshold}\quad{\small\text{(rebalancing must be}\\\small\text{above a threshold)}}\\&amp;amp;\quad\|w-w^{\rm start}\|_1\le\textsf{max_rebalancing}\quad\small\text{(total portfolio rebalancing is bounded)}\\&amp;amp;\quad\sum_{i=1}^n\Bbb I_{\{|w_i-w_i^{\rm start}|&amp;gt;0\}}\le\textsf{max_number_rebalancing}\quad{\small\text{(maximum number of}\\\small\text{rebalances is bounded)}}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have implemented the problem in the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;subassets = ptf_optimization.ptf.index&#xA;max_rebalancing = 0.50&#xA;max_number_rebalancing = 10&#xA;rebalancing_threshold = 0.02&#xA;J = np.array(Chosen_new.tolist())&#xA;&#xA;# Define model and set parameters&#xA;m2 = gp.Model('eff_ret_portfolio')&#xA;m2.setParam(&amp;quot;NonConvex&amp;quot;, 2)&#xA;m2.setParam(&amp;quot;MIPGapAbs&amp;quot;, 5e-3)&#xA;m2.setParam(&amp;quot;TimeLimit&amp;quot;, 100.0)&#xA;&#xA;# Define variables&#xA;vars = pd.Series(m2.addVars(subassets), index=subassets)&#xA;vars_diff = pd.Series(m2.addVars(subassets, lb=(-1)*np.ones(len(subassets)), ub=2*np.ones(len(subassets))), index=subassets)&#xA;vars_abs = pd.Series(m2.addVars(subassets, lb=np.zeros(len(subassets)), ub=2*np.ones(len(subassets))), index=subassets)&#xA;vars_ind = pd.Series(m2.addVars(subassets, vtype=GRB.BINARY), index=subassets)&#xA;m2.update()&#xA;&#xA;# Set objective&#xA;m2.setObjective(vars.T.dot(BL_returns), GRB.MAXIMIZE)&#xA;&#xA;## Set constraints&#xA;portfolio_variance = vars.T.dot(ptf_optimization.cov.dot(vars))&#xA;m2.addConstr(portfolio_variance == target_std**2)&#xA;m2.addConstr(vars.sum() == 1-cash, 'budget')&#xA;m2.addConstrs((vars[j] == 0 for j in range(len(J)) if J[j] == True), name='c1')     #J defined in min vol optimization&#xA;m2.addConstrs((vars_diff[item] == vars[item]-w_start[item] for item in subassets), name='diff')&#xA;m2.addConstrs((vars_abs[item] == gp.abs_(vars_diff[item]) for item in subassets), name='abs')&#xA;for item in subassets:&#xA;    m2.addConstr((vars_ind[item]==1) &amp;gt;&amp;gt; (vars_abs[item] &amp;gt;= 1e-5))&#xA;    m2.addConstr((vars_ind[item]==0) &amp;gt;&amp;gt; (vars_abs[item] &amp;lt;= 1e-5))&#xA;m2.addConstr(quicksum(vars_ind) &amp;lt;= max_number_rebalancing, 'max_number_rebalancing')&#xA;m2.addConstrs((vars_abs[item]*vars_ind[item] &amp;gt;= rebalancing_threshold for item in subassets), name='rebalancing_threshold')&#xA;m2.addConstr(quicksum(vars_abs) &amp;lt;= max_rebalancing, 'max_rebalancing')&#xA;&#xA;# Add absolute constraints&#xA;for item in subassets:&#xA;    l = ptf_optimization.absolute_constraints[item]['Min']&#xA;    u = ptf_optimization.absolute_constraints[item]['Max']&#xA;    m2.addConstr(l &amp;lt;= vars[item], f'constraint_abs_{item}_lower')&#xA;    m2.addConstr(vars[item] &amp;lt;= u, f'constraint_abs_{item}_upper')&#xA;# Add group constraints&#xA;for j, item in enumerate(ptf_optimization.group_constraints):&#xA;    constraint = ptf_optimization.group_constraints[item]&#xA;    l = constraint['Min']&#xA;    u = constraint['Max']&#xA;    vars_list = (vars[item] for item in constraint['Group'])&#xA;    m2.addConstr(l &amp;lt;= quicksum(vars_list), f'constraint_group_{j}_lower')&#xA;    m2.addConstr(quicksum(vars_list) &amp;lt;= u, f'constraint_group_{j}_upper')&#xA;m2.setParam('OutputFlag', 1)    &#xA;m2.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, by inserting the constraint that rebalancing must be above a certain threshold, I obtained that the problem becomes infeasible. I computed an IIS and obtain the following .ilp file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\ Model eff_ret_portfolio_copy&#xA;\ LP format - for model browsing. Use MPS format to capture full model detail.&#xA;Maximize&#xA;&#xA;Subject To&#xA;max_number_rebalancing: C96 + C97 + C98 + C99 + C100 + C101 + C102 + C103&#xA;+ C104 + C105 + C106 + C107 + C108 + C109 + C110 + C111 + C112 + C113&#xA;+ C114 + C115 + C116 + C117 + C118 + C119 + C120 + C121 + C122 + C123&#xA;+ C124 + C125 + C126 + C127 &amp;lt;= 10&#xA;rebalancing_threshold[Obbligazionari_Governativi_Dollari]: [ C64 * C96 ]&#xA;&amp;gt;= 0.02&#xA;rebalancing_threshold[Obbligazionari_High_Yield_Euro]: [ C70 * C102 ]&#xA;&amp;gt;= 0.02&#xA;rebalancing_threshold[Obbligazionari_Emergenti_Hard_Currency]: [&#xA;C71 * C103 ] &amp;gt;= 0.02&#xA;rebalancing_threshold[Azionari_Euro]: [ C73 * C105 ] &amp;gt;= 0.02&#xA;rebalancing_threshold[Obbligazionari_Governativi_Breve_Termine_Europe_ex_Euro]:&#xA;[ C84 * C116 ] &amp;gt;= 0.02&#xA;rebalancing_threshold[Obbligazionari_Governativi_Breve_Termine_Yen]: [&#xA;C85 * C117 ] &amp;gt;= 0.02&#xA;rebalancing_threshold[Obbligazionari_Inflation_Linked_Dollari]: [&#xA;C87 * C119 ] &amp;gt;= 0.02&#xA;rebalancing_threshold[Obbligazionari_Corporate_Finanziari]: [ C89 * C121 ]&#xA;&amp;gt;= 0.02&#xA;rebalancing_threshold[Obbligazionari_Corporate_Dollari_Breve_Termine]: [&#xA;C91 * C123 ] &amp;gt;= 0.02&#xA;rebalancing_threshold[Obbligazionari_ABS]: [ C92 * C124 ] &amp;gt;= 0.02&#xA;rebalancing_threshold[Obbligazionari_Convertible_Euro]: [ C94 * C126 ]&#xA;&amp;gt;= 0.02&#xA;Bounds&#xA;C64 free&#xA;C70 free&#xA;C71 free&#xA;C73 free&#xA;C84 free&#xA;C85 free&#xA;C87 free&#xA;C89 free&#xA;C91 free&#xA;C92 free&#xA;C94 free&#xA;Binaries&#xA;C96 C97 C98 C99 C100 C101 C102 C103 C104 C105 C106 C107 C108 C109 C110&#xA;C111 C112 C113 C114 C115 C116 C117 C118 C119 C120 C121 C122 C123 C124 C125&#xA;C126 C127&#xA;End&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Can you please tell me if I coded the model correctly and where the source of infeasibility is?&lt;/p&gt;&#xA;" OwnerUserId="4167" LastEditorUserId="123" LastEditDate="2021-05-21T06:56:49.547" LastActivityDate="2021-05-21T06:56:49.547" Title="Issues modeling portfolio optimization with rebalancing in gurobipy" Tags="|mixed-integer-programming|python|gurobi|finance|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4948" PostTypeId="2" ParentId="4937" CreationDate="2020-09-29T18:22:31.530" Score="4" Body="&lt;p&gt;What follows is conjecture.&lt;/p&gt;&#xA;&lt;p&gt;If you have a tightly constrained model, for which the solver struggles to find a feasible (or good feasible) schedule, then I suspect that allowing tasks to be skipped (at a penalty) may facilitate getting a feasible solution. Whether it will get you to an optimal solution sooner is anybody's guess.&lt;/p&gt;&#xA;&lt;p&gt;If the MIP solver finds feasible schedules in reasonable time but struggles either finding an optimal schedule or proving optimality, I suspect that allowing tasks to be skipped will make things worse. It will expand the feasible region (so the search tree probably gets bigger), and I think it likely will loosen the LP relaxation bounds.&lt;/p&gt;&#xA;&lt;p&gt;Overall, I doubt I would try it. If the issue is difficulty getting good schedules early (or any feasible schedule), I would try either scheduling heuristics or a constraint solver (specifically one that has global constraints tailored to scheduling problems). With heuristics, I would try to get a good schedule and then use it as a hot start for the MIP solver. With a constraint solver, I would first try to let the solver progress to optimality, and only use its solution to hot start the MIP solver if the constraint solver looked like it was going to struggle to reach optimality itself.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-29T18:22:31.530" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4949" PostTypeId="2" ParentId="4940" CreationDate="2020-09-29T19:57:53.320" Score="2" Body="&lt;p&gt;The following model gives the purchasing temporal sequence for truck so that the cash flow is optimal within the planning horizon of 17 years. The model requires &lt;span class=&quot;math-container&quot;&gt;$68$&lt;/span&gt; Boolean variables (&lt;span class=&quot;math-container&quot;&gt;$68=17 \cdot 4$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$17$&lt;/span&gt; integers variables (1 integer variable for each year). Every year will be designate by means of a pedice &lt;span class=&quot;math-container&quot;&gt;$k=1, 2, \cdots, m=17$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For each year the possible choices are basically two:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;“sell” or “buy” the truck in the k-th year&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;By the contest, there are four kind of available plans:&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;1-st plan&lt;/em&gt;: keep the truck &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; years, &lt;span class=&quot;math-container&quot;&gt;$t_1=2$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;2-nd plan&lt;/em&gt;: keep the truck &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; years, &lt;span class=&quot;math-container&quot;&gt;$t_2=3$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;3-rd plan&lt;/em&gt;: keep the truck &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; years, &lt;span class=&quot;math-container&quot;&gt;$t_3=4$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;4-rd plan&lt;/em&gt;: keep the truck &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; years, &lt;span class=&quot;math-container&quot;&gt;$t_4=5$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We designate by means of a pedice &lt;span class=&quot;math-container&quot;&gt;$j=1, 2, \cdots , 4$&lt;/span&gt; the kind of adopted plan for each year. As a consequence, we need &lt;span class=&quot;math-container&quot;&gt;$17 \cdot 4 = 68 $&lt;/span&gt; variables in order to define all possible decisions. Let introduce the Boolean variable &lt;span class=&quot;math-container&quot;&gt;$x_{k,j}$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{k,j}=1$&lt;/span&gt; if in k-th year I decide to keep the truck as many years as specified by the j-th plan&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{k,j}=0$&lt;/span&gt; if in k-th year I decide to not keep the truck as many years as specified by the j-th plan.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For example, the sequence &lt;span class=&quot;math-container&quot;&gt;$ x_{1,3}= x_{2,3}= \cdots = x_{k-1,3}= x_{k+1,3}= \cdots = 0 $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ x_{k,3}=1$&lt;/span&gt; is suitable to describe the choice of buying the truck in year k and keeping it 3 years.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Unitary Time Period&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The planning horizon &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is divided into a finite set of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; instants: &lt;span class=&quot;math-container&quot;&gt;$t_{k+1}= t_k + \Delta h_k$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$ K=0,1, \cdots, m-1$&lt;/span&gt;. The discretization step will be chosen constant and with an extent of 1 year: &lt;span class=&quot;math-container&quot;&gt;$ \Delta h_k = \Delta h = 1$&lt;/span&gt; year. In this way, &lt;span class=&quot;math-container&quot;&gt;$T= \Delta t_1 + \cdots + \Delta t_m = m \cdot \Delta h $&lt;/span&gt; and in our case study we have &lt;span class=&quot;math-container&quot;&gt;$m=17$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$t_0=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Temporal Constraints&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;We introduce &lt;span class=&quot;math-container&quot;&gt;$m=17$&lt;/span&gt; equations and variables &lt;span class=&quot;math-container&quot;&gt;$A_k$&lt;/span&gt; that track in each year how long the truck will be kept for the future years.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ A_1 = \sum_{j=1}^{4} x_{1,j}  \cdot t_j $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ A_2 = A_1  - 1 + \sum_{j=1}^{4} x_{2,j}  \cdot t_j $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \vdots $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ A_m = A_{m-1}  - 1 + \sum_{j=1}^{4} x_{m,j}  \cdot t_j $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For example, in the first year if we decide to buy the truck and to keep it for three years (2nd plan), it results: &lt;span class=&quot;math-container&quot;&gt;$ A_1 = \sum_{j=1}^{4} x_{1,j}  \cdot t_j = t_2 = 3$&lt;/span&gt; because &lt;span class=&quot;math-container&quot;&gt;$ x_{1,2}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ x_{1,1}=x_{1,3}= x_{1,4}= 0 $&lt;/span&gt;.&#xA;In order to impose that in every year there is a truck in service, we add further &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$ A_k \geq 1 \quad \forall k=1,\ldots,m $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Finally, the constraint &lt;span class=&quot;math-container&quot;&gt;$ \sum_{k=1}^{17} \sum_{j=1}^{4} x_{k,j}  \cdot t_j \leq 17 $&lt;/span&gt;  makes sure that all investment choices are made within the fixed planning horizon &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; and generate cash flows with maturity no later than horizon planning &lt;span class=&quot;math-container&quot;&gt;$T=17$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In order to avoid the unacceptable situation of buying a truck when the plan of the previous truck has not yet come to an end, we introduce &lt;span class=&quot;math-container&quot;&gt;$m-1$&lt;/span&gt; additional constraints as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;\sum_{j=1}^{4} x_{1,j} \cdot t_j \leq (1 - \sum_{j=1}^{4} x_{2,j} ) \cdot M +1 \\&#xA;A_{1} -1 + \sum_{j=1}^{4} x_{2,j} \cdot t_j  \leq (1 - \sum_{j=1}^{4} x_{3,j} ) \cdot M +1 \\&#xA;\vdots \\&#xA;A_{m-2} -1 + \sum_{j=1}^{4} x_{m-1,j} \cdot t_j  \leq (1 - \sum_{j=1}^{4} x_{m,j} ) \cdot M +1  \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$M &amp;gt; \max_j t_j $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Whenever &lt;span class=&quot;math-container&quot;&gt;$ A_{k-1} = A_{k-2} -1 + \sum_{j=1}^{4} x_{k-1,j}  \cdot t_j \geq 2 $&lt;/span&gt; we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$(1 - \sum_{j=1}^{4} x_{k,j} ) \cdot M +1 = M+1 $&lt;/span&gt;, so it implicitly requires that in the following period &lt;span class=&quot;math-container&quot;&gt;$ \sum_{j=1}^{4} x_{k,j} = 0 $&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. On the other hand, suppose at time &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; we buy a truck with regards to  &lt;span class=&quot;math-container&quot;&gt;$\tilde j$&lt;/span&gt; plan earlier than expected, that is when being &lt;span class=&quot;math-container&quot;&gt;$ A_{k-2} \geq 2$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$ A_{k-2} -1 + t_{\tilde j} \leq 1 $&lt;/span&gt; holds. This last inequality is not possible if &lt;span class=&quot;math-container&quot;&gt;$ A_{k-2} \geq 2$&lt;/span&gt;. As a result, it is not possible to buy a truck before sell the previous one. Of course, it is possible buy a truck in &lt;span class=&quot;math-container&quot;&gt;$k-1$&lt;/span&gt; period if &lt;span class=&quot;math-container&quot;&gt;$ A_{k-2} =1 $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective Function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \max (revenue - cost) = \max (revenue) + \max (-cost) = \max (revenue) - \min (cost) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;revenue &lt;span class=&quot;math-container&quot;&gt;$=\sum_{k=1}^{17} r_k ( \sum_{j=1}^{4} x_{k,j})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;cost &lt;span class=&quot;math-container&quot;&gt;$=\sum_{k=1}^{17} c_k ( \sum_{j=1}^{4} x_{k,j})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$ r_k $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ c_k $&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$k=1, \cdots, 17$&lt;/span&gt; play the role of coefficients. These coefficients can be easily calculated as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$r_k= 45000 \cdot (1-0.10) \cdot (1-0.07)^{k-1}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_k= 45000 \cdot (1+0.05)^{k-1}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4114" LastEditorUserId="4114" LastEditDate="2020-09-29T20:55:32.667" LastActivityDate="2020-09-29T20:55:32.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4950" PostTypeId="2" ParentId="4868" CreationDate="2020-09-29T20:22:07.863" Score="5" Body="&lt;p&gt;One of my favorite things about working in operations research is diving into a new problem to understand all the complexities. Getting a non-OR person to list all the requirements for an optimization problem is almost like asking someone to explain all the steps to ride a bike. They know how to do it, but won't be able to explain all the steps.&lt;/p&gt;&#xA;&lt;p&gt;Here are some useful strategies to go about it:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Get out in the real world&lt;/strong&gt; You need to understand the fundamentals of the system you are modeling. If you are working with a factory, you should visit the factory, watch how it works and how the planners do their job and ask all the silly questions. Where does the planning process start? Why did you decide to do A instead of B? Would C be a possibility?&#xA;This will help you not just understand what the requirements are, but also why certain things are important and maybe even some things that aren't as important as someone told you.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Have a structured approach to uncover the full problem&lt;/strong&gt;&#xA;Identify ways you can split the problem and dive deep into the different components separately. For example, when formulating the objective function, you can identify all the stakeholders involved in the system and determine what their objectives are. They shouldn't all be included in the model, but it can help you ensure that you didn't miss anything important.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Gather real-world solutions&lt;/strong&gt;&#xA;Create some smaller datasets and discuss with the expert what the solution should be. They could also be real-life datasets you have collected. You can use them ongoingly to pressure test your solutions and see what the differences are between what business did and what your model proposes. Businesses often have an idea of how the ideal world should look like, but when reality hits, rules can be broken, and priorities can often shift.&#xA;This can also help you discover if you are getting contradictory requirements.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Be agile&lt;/strong&gt;&#xA;A model should always be judged by the solution it produces and the value it creates. It is easy to get caught up in writing an elaborate document to describe all the aspects. You will never find the right model in your first attempt, so it is important to get ongoing feedback on the latest version of the model. Build a prototype that includes a way to visualize solutions produced by your model, so it is easy for users to engage and validate your results. A way to do this is to have some fixed interval where you demo the newest version and discuss priorities, e.g., every 2-4 weeks.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I always see it as a goal to get as deep into the problem as possible. The deeper you are, the more you will be able to ask the right questions, challenge their assumptions, and build credibility with the business to ultimately create some real-life impact with your model.&lt;/p&gt;&#xA;" OwnerUserId="140" LastEditorUserId="140" LastEditDate="2020-09-30T11:33:13.697" LastActivityDate="2020-09-30T11:33:13.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4951" PostTypeId="2" ParentId="4946" CreationDate="2020-09-29T21:10:18.157" Score="3" Body="&lt;p&gt;If you look at the &amp;quot;allowable decrease&amp;quot; in the RHS of the highlighted constraint, it's zero. A number of the binding constraints have either allowable increase or allowable decrease zero. That means that your primal solution is degenerate, and your dual problem has &lt;em&gt;multiple optima&lt;/em&gt;. The highlighted difference probably means that the simplex solver and the GRG solver found different dual solutions.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-09-29T21:10:18.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4953" PostTypeId="2" ParentId="4947" CreationDate="2020-09-30T07:25:07.320" Score="2" Body="&lt;p&gt;There are 11 constraints of the form&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x * y &amp;gt;= 0.02&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;with &lt;code&gt;y&lt;/code&gt; being a binary variable, effectively forcing all these binaries to 1 to satisfy the constraints.&#xA;Then there is the first constraint:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;y_1 + ... + y_11 &amp;lt;= 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This can never be satisfied if all 11 &lt;code&gt;y&lt;/code&gt; variables have to be 1.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360073480112-Issues-modeling-portfolio-optimization-with-rebalancing-in-gurobipy&quot; rel=&quot;nofollow noreferrer&quot;&gt;crosspost in Gurobi community forum&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2020-09-30T07:25:07.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4954" PostTypeId="1" CreationDate="2020-09-30T08:12:53.447" Score="2" ViewCount="122" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; be a &lt;span class=&quot;math-container&quot;&gt;$(0,1)$&lt;/span&gt;-matrix where no row or column is a zero vector, and consider the following optimization programs &lt;span class=&quot;math-container&quot;&gt;\begin{align}(1):\min&amp;amp;\quad y\cdot1\\\text{s.t.}&amp;amp;\quad yA\ge w\\&amp;amp;\quad y\ge0\\(2):\max&amp;amp;\quad w\cdot x\\\text{s.t.}&amp;amp;\quad Ax\le 1\\&amp;amp;\quad x\ge0\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; denotes the vector &lt;span class=&quot;math-container&quot;&gt;$\begin{pmatrix}1&amp;amp;\cdots&amp;amp;1\end{pmatrix}^\top$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It is well-known that if &lt;span class=&quot;math-container&quot;&gt;$x,y$&lt;/span&gt; run through non-negative real vectors, the min-max has a common optimum (strong duality of linear programming). However, this might not be true for other types of problems like integer programming.&lt;/p&gt;&#xA;&lt;p&gt;I was able to find some sufficient conditions for the question to be true. For example:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is totally unimodular; that is, if and only if &lt;span class=&quot;math-container&quot;&gt;$\det S\in\{−1, 0, 1\}$&lt;/span&gt; for all square submatrices &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; (not necessarily formed from contiguous rows or columns).&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is balanced; that is, if &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; contains no square submatrix of odd order whose row and column sums are all two.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is totally balanced; that is, if &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; contains no square submatrix having no repeated columns and its row and column sums are all two.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Is there a necessary condition for which min-max holds for all (or some) integer programs?&lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="4169" LastEditDate="2020-09-30T08:35:07.497" LastActivityDate="2020-09-30T08:35:07.497" Title="Condition for an integer program and its linear relaxation to have the same value" Tags="|mixed-integer-programming|linear-programming|integer-programming|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4955" PostTypeId="1" CreationDate="2020-09-30T12:42:19.643" Score="1" ViewCount="57" Body="&lt;p&gt;How can I apply different modifications separately on a model? &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/GettingStarted/topics/tutorials/Cplusplus/modifyingNetworkFlowEG_overview.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;The example in CPLEX documentation&lt;/a&gt; shows how to make modifications on a single solved model. However, unlike this example, I want to make two different sets of modifications separately on the original model.&lt;/p&gt;&#xA;" OwnerUserId="2917" LastEditorUserId="36" LastEditDate="2020-09-30T20:01:14.577" LastActivityDate="2020-09-30T20:01:14.577" Title="Making distinct modifications on a model" Tags="|cplex|solver|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4956" PostTypeId="1" AcceptedAnswerId="4958" CreationDate="2020-09-30T14:27:47.160" Score="1" ViewCount="434" Body="&lt;p&gt;I'm solving a bunch of similar problems and I want to compare them. To do so, I need everything to run on one thread. Even by setting the number of threads to 1, the model still runs on 8 threads. Has anyone ever encountered this problem? and is there a way to fix it? (I'm using Cplex with python)&lt;/p&gt;&#xA;&lt;p&gt;Thank you,&lt;/p&gt;&#xA;" OwnerUserId="889" LastActivityDate="2020-10-01T06:49:20.743" Title="Issue with number of threads on Cplex" Tags="|python|cplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4958" PostTypeId="2" ParentId="4956" CreationDate="2020-10-01T05:09:20.003" Score="1" Body="&lt;p&gt;Try using context as explained &lt;a href=&quot;http://ibmdecisionoptimization.github.io/docplex-doc/mp/docplex.mp.model.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. An example of modeling with docplex (shown below) indicates that you can change the default setting for solver options in cplex using the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;context = Context.make_default_context()&#xA;context.cplex_parameters.threads = 1&#xA;model = Model(context=context&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Alternatively the code can be as follow:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = Model()&#xA;model.context.cplex_parameters.threads = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or if you are using Pyomo the following solver option will be used:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mysolver = SolverFactory('CPLEX')&#xA;mysolver.options['threads'] = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-10-01T05:09:20.003" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4959" PostTypeId="2" ParentId="4956" CreationDate="2020-10-01T06:49:20.743" Score="2" Body="&lt;p&gt;let me change the &lt;a href=&quot;https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;zoo example&lt;/a&gt; for your need. (Number of threads)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;mdl = Model(name='buses')&#xA;&#xA;mdl.parameters.threads=1&#xA;&#xA;&#xA;nbbus40 = mdl.integer_var(name='nbBus40')&#xA;nbbus30 = mdl.integer_var(name='nbBus30')&#xA;mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;mdl.minimize(nbbus40*500 + nbbus30*400)&#xA;&#xA;mdl.solve()&#xA;&#xA;&#xA;&#xA;print(&amp;quot;threads = &amp;quot;,mdl.parameters.threads.get())&#xA;&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;threads =  1&#xA;nbBus40  =  6.0&#xA;nbBus30  =  2.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-10-01T06:49:20.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4960" PostTypeId="1" AcceptedAnswerId="4961" CreationDate="2020-10-01T12:05:38.953" Score="6" ViewCount="360" Body="&lt;p&gt;I need to solve instances of the Directed Hamiltonian Cycle Problem (DHCP). I know that I can reduce the problem to TSP and then use a TSP solver like concorde.&lt;/p&gt;&#xA;&lt;p&gt;I am unable to figure out though how to make concorde abort when a Hamiltonian cycle was found, i.e. when it found a solution with a given (by the reduction) upper bound.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone know of a solver for DHCP itself, or a TSP solver that features early abort when a specified upper bound was reached?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I wrote to the maintainer of concorde, and apparently the &lt;code&gt;-u&lt;/code&gt; flag allows to specify a numeric upper bound on which the solver terminates as soon as it is reached.&lt;/p&gt;&#xA;" OwnerUserId="4175" LastEditorUserId="4175" LastEditDate="2020-10-02T04:17:44.557" LastActivityDate="2020-10-07T08:57:16.930" Title="Solving the (Directed) Hamiltonian Cycle problem" Tags="|solver|traveling-salesman|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4961" PostTypeId="2" ParentId="4960" CreationDate="2020-10-01T14:00:19.503" Score="4" Body="&lt;p&gt;As far as I know, Concorde solves only symmetric TSPs, but you can do a transformation like &lt;a href=&quot;http://home.engineering.iastate.edu/%7Erkumar/PUBS/atsp.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you are trying to find any Hamiltonian cycle, you can use any arc costs, but constant costs (say, &lt;span class=&quot;math-container&quot;&gt;$c_{i,j}=1$&lt;/span&gt; for all arcs) should yield an optimal solution faster than random costs.  With constant costs, the solver will automatically stop at the first feasible solution; with random costs, the solver will have to keep searching to prove optimality.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-10-01T14:00:19.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4962" PostTypeId="1" CreationDate="2020-10-01T21:07:21.570" Score="5" ViewCount="116" Body="&lt;p&gt;Optimization problems over linear constraints (defining a convex polyhedron) can be written as optimization over a simplex in a higher dimension. Let &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}$&lt;/span&gt; be a bounded polyhedron, and the vertices of this polyhedron are saved as columns of the matrix &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;. Then, any feasible solution &lt;span class=&quot;math-container&quot;&gt;$x \in \mathcal{P}$&lt;/span&gt; can be found by some convex combination of columns of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^n$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$V \in \mathbb{R}^{n \times m}$&lt;/span&gt;, then we can always find some &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{R}^m$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x = Vy$&lt;/span&gt;. Since &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; defines the weights of a convex combination, it lies in a standard simplex.&lt;/p&gt;&#xA;&lt;p&gt;In other words, &lt;span class=&quot;math-container&quot;&gt;$\min \{ f(x) \ : \ x \in \mathcal{P} \} \equiv \min\{f(Vy) \ : \ y \geq 0, \ \sum_{i=1}^m y_i = 1 \}$&lt;/span&gt;. Sometimes, solving the lifted problem makes our life easier (I will soon cite some examples here). However, as you can notice, &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is typically large. There are some examples of polyhedra that have linearly or polynomially many vertices. Some examples:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1-norm constraint (&lt;span class=&quot;math-container&quot;&gt;$c \geq 0$&lt;/span&gt;): &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P} = \{x \in \mathbb{R}^n \ : \ ||x||_1 \leq c \}$&lt;/span&gt;  with &lt;span class=&quot;math-container&quot;&gt;$V = \begin{bmatrix} c\cdot \mathbb{I}_{n\times n}  &amp;amp; -c\cdot\mathbb{I}_{n\times n} \end{bmatrix}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt;-simplex: &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P} = \{x \in \mathbb{R}^n \ : \ x \geq 0, \ \sum_{i=1}^m x_i\leq 1\}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$V = \begin{bmatrix} \mathbb{I}_{n\times n} &amp;amp; \mathbf{0}_{n \times 1}\end{bmatrix}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I just wanted to ask if there are some other explicit examples, where, we would be able to detect (linearly many, or polynomially) vertices of a polyhedron in closed form. I know there are algorithmic ways to enumerate vertices of any polyhedron, but I am looking for some closed form polyhedron-vertex pairs that usually appear in convex optimization.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="67" LastEditDate="2020-10-02T21:10:54.550" LastActivityDate="2020-10-02T21:10:54.550" Title="Polyhedra to Simplex by using convex combination of vertices" Tags="|convex-optimization|polyhedra|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4963" PostTypeId="1" CreationDate="2020-10-01T23:22:22.800" Score="6" ViewCount="2247" Body="&lt;p&gt;I heard once that the branch and price (B&amp;amp;P) algorithm is among the hardest ones in OR, but if it's implemented well, it could be very efficient. Aare there other algorithms that are also that tricky?&lt;/p&gt;&#xA;&lt;p&gt;I want to implement B&amp;amp;P on a problem. So how do I choose a problem that is not too complex? Feel free to suggest more than one problem if you think that it has an impact on the way the algorithm is implemented, i.e. if I will learn different principles from different problems.&lt;/p&gt;&#xA;&lt;p&gt;I also need some guidance. How to start? What are the pitfalls to avoid? Any resource that has an open-source code that is well documented would be appreciated as well. I want to choose python or C++.&lt;/p&gt;&#xA;" OwnerUserId="3711" LastEditorUserId="491" LastEditDate="2020-10-13T16:47:42.310" LastActivityDate="2021-02-21T23:19:37.437" Title="How to implement branch and price?" Tags="|branch-and-price|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4964" PostTypeId="2" ParentId="4963" CreationDate="2020-10-01T23:47:48.987" Score="5" Body="&lt;p&gt;Using a framework like &lt;a href=&quot;https://www.scipopt.org&quot; rel=&quot;noreferrer&quot;&gt;SCIP&lt;/a&gt; may be a good&#xA;idea for starting. By doing so, you can quickly implement your formulation. It has interfaces on both C++ and Python. The documentation contains examples of branch-and-price, I suggest you to take a look at them. For any problem at hand, you can use Dantzig-Wolfe decomposition method to generate branch-and-price scheme.&lt;/p&gt;&#xA;" OwnerUserId="2917" LastActivityDate="2020-10-01T23:47:48.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4965" PostTypeId="2" ParentId="4963" CreationDate="2020-10-02T07:51:09.480" Score="11" Body="&lt;p&gt;Before starting implementation, I would make sure I am comfortable with all the theoretical aspects, which are somewhat tricky as well. This is quite an advanced topic in OR and requires some experience. Are you comfortable with branch-and-bound, with the simplex algorithm, with Dantzig-Wolfe decomposition, column generation, etc ?&lt;/p&gt;&#xA;&lt;p&gt;You are hesitating between Python and C++. Is there a reason for that ? Python is much much simpler, but C++ will be faster. So is this for academia or for industry ?&lt;/p&gt;&#xA;&lt;p&gt;You can also checkout &lt;a href=&quot;https://projects.coin-or.org/Dip/wiki/DipPy&quot; rel=&quot;noreferrer&quot;&gt;DipPy&lt;/a&gt;,  which is an extension of ​&lt;a href=&quot;https://coin-or.github.io/pulp/&quot; rel=&quot;noreferrer&quot;&gt;PuLP&lt;/a&gt; (so its Python) that allows users to specify decompositions and customize the branching, cut generation, and column generation of &lt;a href=&quot;https://projects.coin-or.org/Dip&quot; rel=&quot;noreferrer&quot;&gt;DIP&lt;/a&gt;, from within a PuLP model. Everything is open source.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-10-02T07:51:09.480" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4966" PostTypeId="1" CreationDate="2020-10-02T15:15:09.053" Score="3" ViewCount="496" Body="&lt;p&gt;I have the following portfolio optimization problem that I want to solve using CVXPY: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_w&amp;amp;\quad w^\top\Pi\\\text{s.t.}&amp;amp;\quad\sum_{i=1}^nw_i=1\\&amp;amp;\quad w^\top\Sigma w\le\sigma^{\rm target}\\&amp;amp;\quad|w_i-w_i^{\rm start}|\Bbb I_{\{|w_i-w_i^{\rm start}|&amp;gt;0\}}\ge0.02\Bbb I_{\{|w_i-w_i^{\rm start}|&amp;gt;0\}}\quad\forall i.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However I am having trouble implementing the last constraint involving an indicator function. Any ideas on how to code that constraint? Also, if the constraint is not implementable in CVXPY, is there any open-source solver that can deal with that kind of constraint?&lt;/p&gt;&#xA;" OwnerUserId="4167" LastEditorUserId="123" LastEditDate="2021-05-21T06:47:49.590" LastActivityDate="2021-05-21T06:47:49.590" Title="Portfolio optimization with indicator function constraint in CVXPY" Tags="|mixed-integer-programming|indicator-constraints|cvxpy|finance|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4967" PostTypeId="1" AcceptedAnswerId="4969" CreationDate="2020-10-02T15:36:23.867" Score="4" ViewCount="216" Body="&lt;p&gt;I am reading &lt;em&gt;Nonlinear Programming&lt;/em&gt; by Bertsekas, and the chapter on duality starts like this: we define the primal problem as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align*}&#xA;&amp;amp;\min f(x)\\&#xA;&amp;amp;x \in X\\&#xA;&amp;amp;g(x) \le 0&#xA;\end{align*}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$X \subseteq \mathbb{R}^n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g: \mathbb{R}^n \to \mathbb{R}^m$&lt;/span&gt;. Then the author uses &lt;span class=&quot;math-container&quot;&gt;$f^*$&lt;/span&gt; to denote the solution of this problem, using &lt;span class=&quot;math-container&quot;&gt;$\inf$&lt;/span&gt; now:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align*}&#xA;&amp;amp;\inf f(x)\\&#xA;&amp;amp;x \in X\\&#xA;&amp;amp;g(x) \le 0&#xA;\end{align*}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then the author goes on to say:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Note that the definition of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_i$&lt;/span&gt; [the components of &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;] is immaterial outside &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, so if in a given problem the cost function and/or some of the constraints are defined over a domain &lt;span class=&quot;math-container&quot;&gt;$D \subset \mathbb{R^n}$&lt;/span&gt;, we can introduce &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; as part of the set &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, and redefine these functions arbitrarily outside &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;. Unless the opposite is clearly stated, we will assume throughout this chapter the following:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Assumption 6.1.1: (Feasibility and Boundedness)&lt;/strong&gt; There exists at least one feasible solution for the primal problem and the cost is bounded below, i.e. &lt;span class=&quot;math-container&quot;&gt;$- \infty &amp;lt; f^* &amp;lt; \infty.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There are several things I don't understand here:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1)$&lt;/span&gt; Why switch from the minimum to the infimum?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$2)$&lt;/span&gt; Why would we ever consider the feasible region as defined by an abstract set &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, AND by inequalities? If we allow ourselves to use abstract sets, why don't we just cobine all the constrains into one set?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$3)$&lt;/span&gt; What does it mean to &amp;quot;introduce &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; as part of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;&amp;quot;? I assume &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; must already be contained in &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;, so what does it mean to make &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; &amp;quot;a part&amp;quot; of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;? My best guess is that we redefine &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;. But why would we modify our domain of feasibility? We are making up a new problem, whose solution may not be the same as the original problem, in whose solution we are interested.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$4)$&lt;/span&gt; Is Assumption 6.1.1 in any way connected to the discussion about &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; above it? I don't see how it would be, but it's &lt;em&gt;right&lt;/em&gt; below the discussion about &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Thank you very much.&lt;/p&gt;&#xA;" OwnerUserId="910" LastActivityDate="2020-10-02T20:54:12.910" Title="Trouble understanding a passage in Nonlinear Programming by Bertsekas" Tags="|optimization|nonlinear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4968" PostTypeId="2" ParentId="4966" CreationDate="2020-10-02T20:46:19.280" Score="5" Body="&lt;p&gt;I assume that &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; is a continuous variable with &lt;span class=&quot;math-container&quot;&gt;$0 \le w_i \le 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_i^\text{start}$&lt;/span&gt; is a constant with &lt;span class=&quot;math-container&quot;&gt;$0 \le w_i^\text{start} \le 1$&lt;/span&gt;.&#xA;You want to enforce &lt;span class=&quot;math-container&quot;&gt;$$|w_i-w_i^\text{start}| &amp;gt; 0 \implies |w_i-w_i^\text{start}| \ge 0.02.$$&lt;/span&gt;&#xA;You can introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$y_i^+$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_i^-$&lt;/span&gt; and linear big-M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0.02 y_i^+ \le w_i - w_i^\text{start} &amp;amp;\le (1 - w_i^\text{start}) y_i^+ &amp;amp;&amp;amp;\text{for all $i$} \tag1 \\&#xA;0.02 y_i^- \le w_i^\text{start} - w_i &amp;amp;\le (w_i^\text{start} - 0) y_i^- &amp;amp;&amp;amp;\text{for all $i$} \tag2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w_i - w_i^\text{start} &amp;gt; 0 \implies w_i - w_i^\text{start} \ge 0.02.$$&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w_i^\text{start} - w_i &amp;gt; 0 \implies w_i^\text{start} - w_i \ge 0.02.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-10-02T21:01:16.840" LastActivityDate="2020-10-02T21:01:16.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4969" PostTypeId="2" ParentId="4967" CreationDate="2020-10-02T20:54:12.910" Score="9" Body="&lt;ol&gt;&#xA;&lt;li&gt;Switching from minimum to infimum allows you to discuss problems where the objective value is bounded below but a minimum is never attained (such as &amp;quot;minimizing&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$f(x)=1/x$&lt;/span&gt; over the domain &lt;span class=&quot;math-container&quot;&gt;$x&amp;gt;0$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;li&gt;It is common to state domain limits (&lt;span class=&quot;math-container&quot;&gt;$x\ge 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x \le 5$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; integer) separately from &amp;quot;functional constraints&amp;quot; (&lt;span class=&quot;math-container&quot;&gt;$x_1^2 + x_2^2 - 1 \le 0$&lt;/span&gt; etc.). You may want to assign Lagrange multipliers to the latter, take derivatives, or do other stuff than would not necessarily make sense for the domain limits.&lt;/li&gt;&#xA;&lt;li&gt;This is a bit opaque, but my best guess is that the author intends &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; to intersect without either necessarily being contained in the other. Off hand, I can't think of a suitable example. If &lt;span class=&quot;math-container&quot;&gt;$D \subset X$&lt;/span&gt;, it certainly does make sense to just change &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; in the problem statement.&lt;/li&gt;&#xA;&lt;li&gt;I don't think the Assumption is explicitly tied to the confusing passage, although it is connected in the sense that the assumption implies &lt;span class=&quot;math-container&quot;&gt;$D\cap X \neq \emptyset$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-10-02T20:54:12.910" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4970" PostTypeId="2" ParentId="4963" CreationDate="2020-10-02T21:07:32.060" Score="4" Body="&lt;p&gt;If you want to look at C++ source code, there are some COIN-OR projects that provide frameworks for &amp;quot;branch price and cut&amp;quot; or &amp;quot;branch cut and price&amp;quot; as it's sometimes known. Two that come to mind are &lt;a href=&quot;https://github.com/coin-or/Bcp&quot; rel=&quot;nofollow noreferrer&quot;&gt;BCP&lt;/a&gt; and &lt;a href=&quot;https://github.com/coin-or/SYMPHONY&quot; rel=&quot;nofollow noreferrer&quot;&gt;Symphony&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-10-02T21:07:32.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4971" PostTypeId="2" ParentId="4963" CreationDate="2020-10-03T10:02:57.787" Score="5" Body="&lt;p&gt;Nah. Building an ASL interface is &lt;strong&gt;hard&lt;/strong&gt;, BnP is OK. Assuming you are familiar with its building blocks (just like with any other algorithm), the challenge lies in the implementation details.&lt;/p&gt;&#xA;&lt;p&gt;There are a few things to be aware of for BnB in general, and for BnP specifically:&lt;/p&gt;&#xA;&lt;h2&gt;BnB&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Acceleration heuristics: BnB algorithms only work well if combined with certain acceleration heuristics such as domain reduction (e.g. constraint propagation), or good branching strategies (e.g. pseudocosts).&lt;/li&gt;&#xA;&lt;li&gt;For large problems you need good &amp;amp; scalable data structures to avoid the algorithm slowing down to a crawl, especially if your problems are large enough to require column generation.&lt;/li&gt;&#xA;&lt;li&gt;Pure Python will be 1,000-10,000 times slower than C++ for any problem of decent size. The proper way of doing this is to code C++ libraries for the high performance calculations and import them as Python objects using Python-&amp;gt;C++ APIs such as boost Python. This can get you to 100x slower than C++.&lt;/li&gt;&#xA;&lt;li&gt;For the two reasons above, Python has its limits due to the limited bandwidth in transferring data between different parts of your code. In particular, many Python-&amp;gt;C++ APIs unavoidably trigger C++ copy constructors which can be a big problem if your data structures are large. Memory can also become an issue.&lt;/li&gt;&#xA;&lt;li&gt;Since we're on the subject, even if you &lt;strong&gt;really&lt;/strong&gt; know what you're doing in C++, the best you can do with hybrid code is 100x slower than C++. However, if you're in that level of knowing what you're doing, you might as well do the entire thing in C++.&lt;/li&gt;&#xA;&lt;li&gt;MINOTAUR is the most well written C++ open-source BnB code I've seen so far (although not very well documented as of a few years ago).&lt;/li&gt;&#xA;&lt;li&gt;One thing that most people neglect in the beginning is that you need a way to get the math in your code. Think about how you will do this early on as it will affect many of your architecture decisions.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;BnP&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An important implementation consideration here is that you are required to add columns to the relaxation as the solution procedure progresses. This can be a very costly operation, especially with large matrices, so you will need to research the fastest way that your linear solver supports to add new columns. Rebuilding the matrix is the simplest way of course and is actually ok-ish for many algorithms, but it's a no-no for column generation.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;From your description it sounds like your goal is to learn new stuff, so either Python or C++ are fine for that purpose. If you want to use your code for something &amp;quot;real&amp;quot;, using C++ to some extent will be unavoidable, so it's up to you to decide what you want to learn programming-wise. Be mindful though that migrating hybrid code to C++ can be quite painful, so if you see that you have to go with C++ better to do it early on in development.&lt;/p&gt;&#xA;&lt;p&gt;Either way, mentally prepare yourself for a big time investment, and have fun!&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-10-03T10:02:57.787" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4973" PostTypeId="1" AcceptedAnswerId="4982" CreationDate="2020-10-03T19:21:46.990" Score="5" ViewCount="180" Body="&lt;p&gt;Given a set of integer points &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, one is often interested in finding &lt;span class=&quot;math-container&quot;&gt;$\operatorname{conv}(S)$&lt;/span&gt; or characterizing certain cases, where &lt;span class=&quot;math-container&quot;&gt;$\operatorname{conv}(S)$&lt;/span&gt; is described by few inequalities.&#xA;Examples would be stable set polytope on perfect graphs or the min-cost flow polytope.&lt;/p&gt;&#xA;&lt;p&gt;There are certain techniques to prove this; for example, total unimodularity, and total dual integrality (TDI). I am looking for examples, where given a point in the relaxation, there is an algorithm which retrieves the convex combinators to write this point as a convex combination of integral points.&lt;/p&gt;&#xA;&lt;p&gt;Can you point to some examples? It would be great if you can also link to a paper or something where the algorithm is described.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="3305" LastEditDate="2020-10-03T19:40:00.330" LastActivityDate="2020-10-06T08:09:06.793" Title="What are examples of integral polytopes, where there exists an algorithm to write a given point as a convex combination of integral points?" Tags="|reference-request|polyhedra|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4974" PostTypeId="1" CreationDate="2020-10-05T01:18:26.997" Score="4" ViewCount="454" Body="&lt;p&gt;I am solving a large scale MIQP optimisation problem at each step of a model predictive control problem. The problem description is as below.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}  \min_{u} \quad (x_{k}&amp;amp;-x_\text{ref})^{T}Q(x_{k}-x_\text{ref}) + (P_{k}-P_{\text{ref},k})^{T}R(P_{k}-P_{\text{ref},k}) \\  \text{s.t. } x_{k+1}&amp;amp;=Ax_{k}+Bu_{k} \\  P_{k} &amp;amp;= \mathbb{I}^{T}u_{k}\\ u_{k} &amp;amp;\in \{0.25,0.50,0.75,1.0\}\\ \underline{x}&amp;amp;\leq x_{k}\leq \overline{x} \end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; are positive definite, &lt;span class=&quot;math-container&quot;&gt;$\underline{x}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\overline{x}$&lt;/span&gt; represent the lower and upper bounds of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{ref}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_{ref}$&lt;/span&gt; are the reference values at each step &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. In addition to that, &lt;span class=&quot;math-container&quot;&gt;$P_{k} = \sum_{i} u_{k}^{i}$&lt;/span&gt; which is the sum of all decision variables at time step &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The issue that I have is, the decision variable &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; is in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^{1000}$&lt;/span&gt;, i.e. the problem involves a large number of integer variables which are not even binary.&lt;/p&gt;&#xA;&lt;p&gt;I tried solving this optimisation problem at each iteration with &lt;strong&gt;Gurobi&lt;/strong&gt; but was unable to solve at all. Thereafter, I contacted the Gurobi support centre and based on their suggestions, tried tweaking parameters (&lt;em&gt;MIPGap&lt;/em&gt;, &lt;em&gt;MIPHeuristics&lt;/em&gt;) to find at least a feasible solution. But it also did not improve the performance of the task. On the other hand, I am in need of finding a feasible solution within 60 seconds to match the real-world application.&lt;/p&gt;&#xA;&lt;p&gt;I would really appreciate if someone could help me in the following problems.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is this problem NP-hard? if so is there any way to solve this kind of a large problem based on the formulation shown above.&lt;/li&gt;&#xA;&lt;li&gt;I am familiar with McCormick envelopes and big-M relaxations, but since the decision variables are not binary, is there any way I can apply those techniques here, I mean constraint relaxations?&lt;/li&gt;&#xA;&lt;li&gt;Is there any powerful solver which I can try other than Gurobi?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="4182" LastEditorUserId="500" LastEditDate="2020-10-05T03:14:26.380" LastActivityDate="2021-10-11T10:49:09.860" Title="Issue in solving a large scale MIQP problem" Tags="|optimization|mixed-integer-programming|integer-programming|gurobi|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4975" PostTypeId="2" ParentId="4974" CreationDate="2020-10-05T07:08:47.620" Score="8" Body="&lt;p&gt;TL;DR: Some optimization problems are tough, and it requires a lot of work to get them solved.&lt;/p&gt;&#xA;&lt;p&gt;First, let me answer your questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Yes, this is NP-hard, but that does not say anything about whether or not it is easy to solve. Most MIPs are NP-hard, yet they are solved extremely frequently. My favorite treatment of this comes courtesy of Paul Rubin (see &lt;a href=&quot;https://orinanobworld.blogspot.com/2018/07/np-confusion.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can always convert your integers into binaries. So if you have &lt;span class=&quot;math-container&quot;&gt;$u \in \{0,1,2,3\}$&lt;/span&gt;, you can convert this into &lt;span class=&quot;math-container&quot;&gt;$y_k\in \{0,1\}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$u = \sum \limits_k ky_k$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\sum \limits_k y_k = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k\in\{0,1,2,3\}$&lt;/span&gt;. Then you can apply the traditional McCormick relaxations and big-M formulations from the textbooks. Note that you can do McCormick relaxations also for a bound integer variable.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I work for Gurobi, so my obvious answer is &amp;quot;No&amp;quot; :) However, this being an MPC problem gives you actually quite a bit of structure. First off, I would try to work with shorter horizon lengths and see how that degrades performance. Next, I would look into relaxing &lt;span class=&quot;math-container&quot;&gt;$u_k$&lt;/span&gt; and seeing what type of results you get. This is going to be the LP relaxation of the problem, and from the &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360043524431-Gurobi-very-slow-at-solving-MIQP&quot; rel=&quot;nofollow noreferrer&quot;&gt;log file you posted on Gurobi's community forum&lt;/a&gt; it seems that the lower bound does not move much. So this may be a good place to start.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In general, you may have to create some specialized approaches. Note though that what you are really doing here is performance tuning, and following the comments of &lt;a href=&quot;https://undocumentedmatlab.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Yair Altman&lt;/a&gt;, you should always have a quantitative goal when performance tuning. So e.g. Gurobi does provide you a heuristic solution extremely quickly, however the MIP gap is fairly high. So you have to see which MIP gap would be acceptable for you and then add layers of algorithms on top to achieve this performance.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: thanks to Paul Rubin and Rob Pratt for spotting mistakes in my equations.&lt;/p&gt;&#xA;" OwnerUserId="133" LastEditorUserId="133" LastEditDate="2020-10-08T11:08:44.927" LastActivityDate="2020-10-08T11:08:44.927" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4978" PostTypeId="2" ParentId="4973" CreationDate="2020-10-05T20:37:44.313" Score="1" Body="&lt;p&gt;Here is a rough attempt at solving your problem. Let us denote the polytope &lt;span class=&quot;math-container&quot;&gt;$P = \operatorname{conv}(S)$&lt;/span&gt; (if I am to understand your OP correctly, we know that &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is an integral polytope), and let &lt;span class=&quot;math-container&quot;&gt;$x \in P$&lt;/span&gt; be the point you want to find the convex combinators for. Further you mentioned in the comments that &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is specified in H representation, so let us assume that &lt;span class=&quot;math-container&quot;&gt;$P = \lbrace{x \in \mathbb{R}^n \mid Ax \leq b \rbrace}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Find a direction &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; such that both points &lt;span class=&quot;math-container&quot;&gt;$x + d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x - d$&lt;/span&gt; lie in &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;. You can compute such a &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; by solving an optimization problem.&lt;/li&gt;&#xA;&lt;li&gt;Using ray tracing, find out which inequality in &lt;span class=&quot;math-container&quot;&gt;$Ax \leq b$&lt;/span&gt; the ray &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; starting at &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; intersects first. Let that inequality be &lt;span class=&quot;math-container&quot;&gt;$\alpha_1 x \leq b_1$&lt;/span&gt;. Denote the point of intersection of the ray and &lt;span class=&quot;math-container&quot;&gt;$\alpha_1 x \leq b_1$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;. Similarly using ray tracing figure out which inequality in &lt;span class=&quot;math-container&quot;&gt;$Ax \leq b$&lt;/span&gt; the ray &lt;span class=&quot;math-container&quot;&gt;$-d$&lt;/span&gt; intersects first starting at &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Let that inequality be &lt;span class=&quot;math-container&quot;&gt;$\alpha_2 x \leq b_2$&lt;/span&gt;. Let that point of intersection of the ray and &lt;span class=&quot;math-container&quot;&gt;$\alpha_2 x \leq b_2$&lt;/span&gt; be &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;. So &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a convex combination of &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Now my suppose we knew how &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; can be represented as a convex combination of the vertices of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;, then we can represent &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; as a convex combination using the vertices of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; used to represent &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;. My goal below is to figure out how to represent &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; as a convex combination of the vertices of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;. We can analogously do similar steps for &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Since we know that &lt;span class=&quot;math-container&quot;&gt;$x_1 \in P$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha_1 x_1 = b_1$&lt;/span&gt;, we know that &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; can be represented as a convex combination of the vertices of &lt;span class=&quot;math-container&quot;&gt;$P_1 = P \cap (\alpha_1 x_1 = b_1)$&lt;/span&gt;. Note that &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt; is just a face of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;, so the vertices of &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt; are also integral. However crucially, &lt;span class=&quot;math-container&quot;&gt;$\dim(P_1) \leq \dim(P)$&lt;/span&gt;. So now, if we had a method to compute &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; as a convex combination of the vertices of &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt; (which by the way equivalent to your original question), then we are done. Note that suppose &lt;span class=&quot;math-container&quot;&gt;$\dim(P_1) = 1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt; is just a line segment, so &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; is just a convex combination of the end points of the line segment. The end points of the line segment can be found using some linear programming solver.&lt;/li&gt;&#xA;&lt;li&gt;The observation in 4 suggests for finding &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; as a convex combination of the vertices of &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt;, we can simply replace &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt; in steps 1 and 2. So this leads to a recursive procedure over all.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Hopefully the explanation above gives you one way of computing the convex combinators. There a few minor details you would have deal with if you were to implement this method, but hopefully you should be able to figure them out.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="123" LastEditDate="2020-10-06T08:09:06.793" LastActivityDate="2020-10-06T08:09:06.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4979" PostTypeId="1" CreationDate="2020-10-05T21:29:44.577" Score="2" ViewCount="51" Body="&lt;p&gt;This is a follow up to a problem I posted here: &lt;a href=&quot;https://or.stackexchange.com/questions/4926/modelling-a-data-sensitivity-scenario-as-an-ilp-problem&quot;&gt;Modelling a data-sensitivity scenario as an ILP problem&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As a recap, I was interested in finding the minimum number of cells that need to be suppressed to hide the values of certain cells. Now I'm also interested in finding upper and lower bounds for each cell. Take the following array:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{|c|c|c|c|c|c|}&#xA;\hline&#xA;&amp;amp; &amp;amp; &amp;amp; &amp;amp; &amp;amp; \text{Total}\\ \hline&#xA;&amp;amp; X &amp;amp; X &amp;amp; 56 &amp;amp; 12 &amp;amp; 155\\ \hline&#xA;&amp;amp; 32 &amp;amp; 93 &amp;amp; X &amp;amp; 37 &amp;amp; X\\ \hline&#xA;&amp;amp; 54 &amp;amp; 75 &amp;amp; 12 &amp;amp; 13 &amp;amp; 154\\ \hline&#xA;&amp;amp; 75 &amp;amp; X &amp;amp; 21 &amp;amp; 88 &amp;amp; X\\ \hline &#xA;&amp;amp; 37&amp;amp; 26&amp;amp;X  &amp;amp; 51  &amp;amp; X\\ \hline&#xA;\text{Total} &amp;amp; X &amp;amp; X &amp;amp; 210 &amp;amp; 201 &amp;amp; 952 \\ \hline&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;At this point, I'm no longer interested in suppressing cells but rather recovering cells. I want to set up an ILP to determine upper and lower bounds for each of the unknown cells, marked as &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone have any ideas as to how I can go about this? I've been using the ILP in the previous post as something to work off of.&lt;/p&gt;&#xA;" OwnerDisplayName="user4156" LastActivityDate="2020-10-05T22:04:32.800" Title="Finding bounds on a data sensitivity scenario ILP problem" Tags="|linear-programming|integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4980" PostTypeId="2" ParentId="4979" CreationDate="2020-10-05T22:04:32.800" Score="2" Body="&lt;p&gt;I assume the values are nonnegative; without some finite bounds like that, there is no minimum or maximum.  For each cell &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, let decision variable &lt;span class=&quot;math-container&quot;&gt;$z_{i,j} \ge 0$&lt;/span&gt; be the value in that cell, with &lt;span class=&quot;math-container&quot;&gt;$z_{i,j}$&lt;/span&gt; fixed for the known values.  For each &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;-marked cell, you want to minimize or maximize the corresponding variable subject to linear constraints that enforce the row and column sums.  Note that this is &lt;span class=&quot;math-container&quot;&gt;$2\cdot10=20$&lt;/span&gt; separate problems.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-10-05T22:04:32.800" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4981" PostTypeId="1" CreationDate="2020-10-05T23:02:16.800" Score="5" ViewCount="130" Body="&lt;p&gt;I'm using CBC with PuLP to solve a small unit commitment problem.  I'm finding that with certain combinations of input parameters, CBC simply stalls.  With other input parameters, it solves, usually in 10 seconds or so.&lt;/p&gt;&#xA;&lt;p&gt;I've applied a 20 second time limit, but when it stalls, this is not triggered.&lt;/p&gt;&#xA;&lt;p&gt;Typically, the last few lines of output are below.&lt;/p&gt;&#xA;&lt;p&gt;Any ideas what could be causing this?&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Cbc0013I At root node, 182 cuts changed objective from 2190655.4 to 2191172.3 in 20 passes&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Cbc0014I Cut generator 0 (Probing) - 0 row cuts average 0.0 elements, 1 column cuts (8 active)  in 2.461 seconds - new frequency is 5&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Cbc0014I Cut generator 1 (Gomory) - 2461 row cuts average 103.2 elements, 0 column cuts (0 active)  in 0.301 seconds - new frequency is 1&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Cbc0014I Cut generator 2 (Knapsack) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.329 seconds - new frequency is 1000&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Cbc0014I Cut generator 3 (Clique) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.016 seconds - new frequency is -100&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Cbc0014I Cut generator 4 (MixedIntegerRounding2) - 553 row cuts average 105.5 elements, 0 column cuts (0 active)  in 0.376 seconds - new frequency is 1&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Cbc0014I Cut generator 5 (FlowCover) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.909 seconds - new frequency is -100&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Cbc0014I Cut generator 6 (TwoMirCuts) - 360 row cuts average 89.7 elements, 0 column cuts (0 active)  in 0.516 seconds - new frequency is -100&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Cbc0010I After 0 nodes, 1 on tree, 10044587 best solution, best possible 2191172.3 (11.70 seconds)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4186" LastActivityDate="2020-10-07T13:20:39.597" Title="CBC stalling after approximately 10 seconds" Tags="|pulp|cbc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4982" PostTypeId="2" ParentId="4973" CreationDate="2020-10-06T05:59:21.220" Score="2" Body="&lt;p&gt;The argument from the paper &lt;a href=&quot;https://doi.org/10.1016/j.orl.2016.07.006&quot; rel=&quot;nofollow noreferrer&quot;&gt;Geometric proofs for convex hull defining formulations&lt;/a&gt;, Operations Research Letters &lt;strong&gt;44&lt;/strong&gt; (2016), 625-629, can be turned into a simple algorithm for writing a point in the stable set polytope for a chordal graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; as a convex combination of incidence vectors of stable sets.&#xA;Let the vertex set of &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; be &lt;span class=&quot;math-container&quot;&gt;$\{1,\dots,n\}$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$x=(x_1,\dots,x_n)$&lt;/span&gt; be a point in the stable set polytope. Proceeding along a perfect elimination order, we find sets &lt;span class=&quot;math-container&quot;&gt;$X_i\subseteq[0,1)$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt; has measure &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_i\cap X_j=\emptyset$&lt;/span&gt; for every edge &lt;span class=&quot;math-container&quot;&gt;$ij$&lt;/span&gt;. Thus, for every &lt;span class=&quot;math-container&quot;&gt;$t\in[0,1)$&lt;/span&gt;, the set &lt;span class=&quot;math-container&quot;&gt;$I(t)=\{i\,:\,t\in X_i\}$&lt;/span&gt; is a stable set, and if we define &lt;span class=&quot;math-container&quot;&gt;$\lambda(\xi)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\xi\in\{0,1\}^n$&lt;/span&gt; to be the measure of the set&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\{t\,:\,\xi\text{ is the characteristic vector of }I(t)\}$$&lt;/span&gt;&#xA;then &lt;span class=&quot;math-container&quot;&gt;$x=\sum_{\xi}\lambda(\xi)\xi$&lt;/span&gt; is the required convex representation of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, where the sum is over the characteristic vectors of stable sets.&lt;/p&gt;&#xA;" OwnerUserId="741" LastActivityDate="2020-10-06T05:59:21.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4984" PostTypeId="1" CreationDate="2020-10-06T09:55:11.033" Score="3" ViewCount="59" Body="&lt;p&gt;The first reference to the modelling cycle (reality, model, solution, implementation) for operations research I found, is the paper &amp;quot;Operations research from the viewpoint of general systems theory&amp;quot; by Sagasti and Mitroff from 1973. However, they don't cite anyone else for it, but they also act as if it is common knowledge. Is there some source the modelling cycle is usually attributed to?&lt;/p&gt;&#xA;" OwnerUserId="405" LastActivityDate="2020-10-06T09:55:11.033" Title="What is the first mention of the modelling cycle in OR?" Tags="|reference-request|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4985" PostTypeId="1" CreationDate="2020-10-06T16:22:46.160" Score="2" ViewCount="122" Body="&lt;p&gt;I have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; integer variables &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt; with the following integer programming problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;COST = \sum^{n-1}_{i = 0} a_i x_i + \sum^{n-1}_{j=0} b_j I(x_j &amp;gt; 0)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$a_i, b_j \in \mathbb{R}_+$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is the indicator function. I would like to minimize COST. How can I implement &lt;span class=&quot;math-container&quot;&gt;$\sum^{n-1}_{j=0} b_j I(x_j &amp;gt; 0)$&lt;/span&gt; so that it is a quadratic unconstrained binary/integer optimization problem?&lt;/p&gt;&#xA;" OwnerUserId="3730" LastActivityDate="2020-10-06T16:22:46.160" Title="Indicator function for integer variable with inequality constraint" Tags="|mixed-integer-programming|integer-programming|binary-variable|quadratic-programming|indicator-constraints|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4986" PostTypeId="1" CreationDate="2020-10-07T03:35:04.347" Score="9" ViewCount="622" Body="&lt;p&gt;Is it true that the more we add constraint to a constraint programming solver the more efficient it will be? How does this compare to adding constraints in integer programming solvers.&lt;/p&gt;&#xA;" OwnerUserId="3711" LastEditorUserId="8" LastEditDate="2020-10-08T11:53:08.713" LastActivityDate="2022-02-16T13:49:17.567" Title="Adding a constraint in constraint programming" Tags="|solver|constraint|constraint-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4987" PostTypeId="2" ParentId="4986" CreationDate="2020-10-07T07:29:32.377" Score="13" Body="&lt;p&gt;This is not true in practice. Moreover, this is something almost impossible to guess without experimenting. Indeed, adding constraints (proven to be mathematical valid, or just guessed by your flair and feeling of the business) to a mathematical optimization model that is solved by constraint programming techniques or integer programming techniques should be good to cut some branches of the enumeration tree (that is, the enumeration of partial solutions), by improving the propagation of constraints and/or the continuous relaxation. On the other hand, constraint programming solvers and integer programming solvers now rely on many heuristic ingredients; adding constraints may be bad for these heuristics. In conclusion, sometimes this is good, sometimes not. Take the time to experiment on the instances you have to solve.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="491" LastEditDate="2022-02-16T13:49:17.567" LastActivityDate="2022-02-16T13:49:17.567" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4988" PostTypeId="2" ParentId="4960" CreationDate="2020-10-07T08:57:16.930" Score="5" Body="&lt;p&gt;If you just want to find Hamiltonian cycles in a directed graph, maybe have a look at LKH-3 the TSP solver developed by Keld Helsgaun: &lt;a href=&quot;http://webhotel4.ruc.dk/%7Ekeld/research/LKH-3/&quot; rel=&quot;noreferrer&quot;&gt;http://webhotel4.ruc.dk/~keld/research/LKH-3/&lt;/a&gt;. The solver is based on high-performance local-search heuristics. It was used by the Concorde team to find feasible solutions (then proved to be optimal by branch-and-cut approaches) to &amp;quot;world-record&amp;quot; TSP instances (for example, see &lt;a href=&quot;http://www.math.uwaterloo.ca/%7Ebico/papers/proof.pdf&quot; rel=&quot;noreferrer&quot;&gt;http://www.math.uwaterloo.ca/~bico/papers/proof.pdf&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-10-07T08:57:16.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4989" PostTypeId="2" ParentId="4981" CreationDate="2020-10-07T13:20:39.597" Score="4" Body="&lt;p&gt;CBC does have its fair share of bugs, especially when it comes to proper termination.&lt;/p&gt;&#xA;&lt;p&gt;If you are running in multithreaded mode try running in serial (or vice-versa), and see if that helps.&lt;/p&gt;&#xA;&lt;p&gt;If you are feeling particularly adventurous, you can comment out all the code related to the &amp;quot;SIGNAL_TRAP&amp;quot; and recompile CBC. This helps with proper termination (especially when running with timeouts), although it seems to crash more often as a result.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-10-07T13:20:39.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4991" PostTypeId="1" CreationDate="2020-10-08T07:29:25.303" Score="24" ViewCount="3358" Body="&lt;p&gt;In Denmark, a rather substantial amount of work and effort has gone into reducing bullying in the Danish public schools. Many initiatives, which purposes are to strengthen the unity and solidarity in the individual classes, have been introduced (and this with quite remarkable results actually).&lt;/p&gt;&#xA;&lt;p&gt;One of these initiatives is the so-called “Dinner with friends” initiative. The idea is that the kids in a class should go home to each other for dinner in small groups of four to five kids. These visits to each other’s homes should happen approximately 6 times a year (three times in the fall and three times in the spring) and each time the groups are different such that the kids get to visit and dine with as many of their class mates as possible. The reasoning behind the initiative is that you do not bully those with whom you have dined.&lt;/p&gt;&#xA;&lt;p&gt;Making such a “Dinner with friends”-plan is obviously a combinatorial optimization problem (at least it is to me)!&lt;/p&gt;&#xA;&lt;p&gt;The plan for the 6 events during the year should be such that&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;at most 5 kids go to the same dinner arrangement&lt;/li&gt;&#xA;&lt;li&gt;at least two girls and two boys go to each dinner arrangement,&lt;/li&gt;&#xA;&lt;li&gt;all kids should try to be the host of a dinner at least once a year,&lt;/li&gt;&#xA;&lt;li&gt;if kid &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is host at a dinner, then this kid cannot be a host for the next event (for the sake of the parents)&lt;/li&gt;&#xA;&lt;li&gt;Each kid should go to exactly one dinner on each of the event days (possibly as a host)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The objective is to maximize the number of different pairings of kids during the events. That is, if &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; is a binary variable equaling one if kids &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; go to the same dinner at least once during the 6 events, then the objective is to maximize the sum over these &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt;-variables.&lt;/p&gt;&#xA;&lt;p&gt;I have a working ILP formulation using the following variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;binary &lt;span class=&quot;math-container&quot;&gt;$y_j^e$&lt;/span&gt;-variables that equal one if kid &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is host at event &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;binary &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^e$&lt;/span&gt;-variables equaling one if kid &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; goes to kid &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;’s house during event &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;binary &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt;-variables equaling one if kids &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; go to the same dinner at least once during the six events.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;However, my model is not very elegant! Therefore, I have two questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is this a known problem in the literature? To me, it is somewhat similar to graph partitioning but not all the way there. There is also an element of scheduling in the problem, but I am embarrassingly unfamiliar with the scheduling literature.&lt;/li&gt;&#xA;&lt;li&gt;I have a feeling that this problem could be formulated much more elegantly with different variables. Could you suggest a way to formulate the problem elegantly?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="278" LastEditorUserId="279" LastEditDate="2020-10-09T03:01:13.980" LastActivityDate="2020-10-09T03:01:13.980" Title="Combinatorial problem in my daughter’s class" Tags="|modeling|combinatorial-optimization|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4992" PostTypeId="2" ParentId="4991" CreationDate="2020-10-08T11:33:37.733" Score="12" Body="&lt;p&gt;This is a variant of the University Course Scheduling problem (e.g. &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0957417419301393#:%7E:text=The%20University%20Course%20Scheduling%20Problem,into%20account%20the%20given%20constraints.&quot; rel=&quot;noreferrer&quot;&gt;this one&lt;/a&gt;). Interestingly, writing software to solve this was Bill Gates' first gig &lt;a href=&quot;https://www.coursedog.com/post/class-scheduling-playbook-vol-i&quot; rel=&quot;noreferrer&quot;&gt;when he was still a student&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There is a lot of software around for this type of problem (just google course scheduling software).&lt;/p&gt;&#xA;&lt;p&gt;It's also very similar to sports scheduling (e.g. how the NFL schedule is calculated, including pairing teams), so you could check that out too.&lt;/p&gt;&#xA;&lt;p&gt;There are many ways to model this and it can get very complicated - one of the hardest bits is if you want to pair children, i.e., if I have dinner at Mark's I &lt;em&gt;have&lt;/em&gt; to have Mark over for dinner. The simplest way is saying that each child must have dinner at least 6 times, and that no one child can host more than some number of dinners.&lt;/p&gt;&#xA;&lt;p&gt;Paired scheduling (like they do with sports teams), is actually a supercomputing problem, so be mindful that this is an inherently very hard problem. If your formulation is not working out try dropping some of those constraints, especially on when people are available, and it should be manageable.&lt;/p&gt;&#xA;&lt;p&gt;This is also infinitely easier if you pre-select the hosts and times, and then try to assign guests.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-10-08T11:33:37.733" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4993" PostTypeId="2" ParentId="4991" CreationDate="2020-10-08T13:54:49.327" Score="8" Body="&lt;p&gt;As &lt;a href=&quot;https://or.stackexchange.com/users/4030/wsg&quot;&gt;wsg&lt;/a&gt; mentioned in a comment, your problem is related to the Social Golfer problem. You can find references on the web and in the OR literature under this naming. For example, have a look at this &lt;a href=&quot;http://www.mathpuzzle.com/MAA/54-Golf%20Tournaments/mathgames_08_14_07.html&quot; rel=&quot;noreferrer&quot;&gt;webpage&lt;/a&gt; or this &lt;a href=&quot;http://www.csplib.org/Problems/prob010/&quot; rel=&quot;noreferrer&quot;&gt;one&lt;/a&gt;. This problem has tight connections to &lt;a href=&quot;https://en.wikipedia.org/wiki/Latin_square&quot; rel=&quot;noreferrer&quot;&gt;Latin square&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Kirkman%27s_schoolgirl_problem&quot; rel=&quot;noreferrer&quot;&gt;Kirkman's schoolgirl problem&lt;/a&gt;, and more generally &lt;a href=&quot;https://en.wikipedia.org/wiki/Combinatorial_design&quot; rel=&quot;noreferrer&quot;&gt;combinatorial design&lt;/a&gt; problems. This is a &lt;a href=&quot;http://www.csplib.org/Problems/prob010/&quot; rel=&quot;noreferrer&quot;&gt;historical benchmark&lt;/a&gt; for Constraint Programming (CP) solvers.&lt;/p&gt;&#xA;&lt;p&gt;Your ILP formulation is good. You should be able to solve it by using free MILP solvers like COIN-CBC or even GLPK if the number of kids is very small. But for classes with 20-30 kids, given our experience with this problem, it may be quite difficult to get solutions. Indeed, as pointed out &lt;a href=&quot;https://or.stackexchange.com/users/1228/nikos-kazazakis&quot;&gt;Nikos&lt;/a&gt; above, the modeling of the pairing (your variables z[i][j]) leads to quadratic binary expressions. These expressions can be linearized as described &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;here&lt;/a&gt; on the forum. Once linearized, these ones make the linear relaxation of the ILP very bad while increasing the size of the ILP (because the number of z[i][j] variables grows quadratically).&lt;/p&gt;&#xA;&lt;p&gt;Thanks to its local-search heuristics, this is the kind of highly combinatorial problems for which LocalSolver is able to deliver good solutions quickly, despite the bad, useless linear relaxation. The LocalSolver model for the Social Golfer problem is given &lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/socialgolfer.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; in the Example Tour, for languages like Python, Java, C#, or C++. LocalSolver is a commercial product but if you're interested to use it for free to solve this problem, you will be welcome.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-10-08T13:54:49.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4994" PostTypeId="1" AcceptedAnswerId="4995" CreationDate="2020-10-08T14:15:01.107" Score="6" ViewCount="734" Body="&lt;p&gt;&lt;strong&gt;I will use an example to detail my question but I would like you to keep in mind that I wanted to define:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Robustness,&lt;/li&gt;&#xA;&lt;li&gt;Resillience,&lt;/li&gt;&#xA;&lt;li&gt;Reliability&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;in the most general case within Operations Research.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let us suppose you want to find the classical shortest path in a graph between two different nodes.&#xA;However, you know in advance that at most one edge could be unavailable or present a failure. e.g. for rehabilitation works.&lt;/p&gt;&#xA;&lt;p&gt;You use a model, it's not important which it is, to minimize the cost of your shortest path and for each edge of this shortest path, your objective function will take into account the detour caused by the failure of possibly each edge.&lt;/p&gt;&#xA;&lt;p&gt;Would you say that your model is resilient, robust, reliable, or a combination of those three adjectives?&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;From what I've search, I have read this question about &lt;a href=&quot;https://or.stackexchange.com/questions/4827/what-is-robust-optimization&quot;&gt;Robustness Optimization&lt;/a&gt; and thus, we will say that the model will have robustness because a part of the data is uncertain: which edge that will fail.&lt;/li&gt;&#xA;&lt;li&gt;For resilience, &lt;a href=&quot;https://en.wikipedia.org/wiki/Resilience_(network)&quot; rel=&quot;noreferrer&quot;&gt;wikipedia writes:&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Resilience is the ability to &amp;quot;provide and maintain an acceptable level&#xA;of service in the face of faults and challenges to normal operation.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;which is quite also appropriate to our model.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For reliability, it is sometimes defined as the quality of being trustworthy or of performing consistently well.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;With these very similar definitions, I wander which adjectives are appropriate, for my small example first, but in general in Operations Research. Maybe some papers have dealt with such definitions, maybe introducing theirs?&lt;/p&gt;&#xA;" OwnerUserId="35" LastActivityDate="2020-10-08T15:17:44.540" Title="What is intended when we use &quot;robustness&quot;, &quot;resilience&quot; and &quot;reliability&quot; in Operations Research?" Tags="|graphs|robust-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4995" PostTypeId="2" ParentId="4994" CreationDate="2020-10-08T15:17:44.540" Score="8" Body="&lt;p&gt;I think these terms are all rather vague and imprecise, and different people use them slightly differently. Some papers try to draw clear lines between them—for example, in my dissertation in 2003, I draw a distinction between&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;robust (i.e., perform well with respect to uncertainties in the data, such as&#xA;demand) and reliable (i.e., perform well when parts of the system fail).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;—but such clear lines should be interpreted as being respected within the scope of the document, and not necessarily interpreted the same way more broadly in other works. And even within a definition (like mine above), there is ambiguity—one could interpret failures in parts of the system as arising from uncertainties in the data.&lt;/p&gt;&#xA;&lt;p&gt;Having said that, my own opinion is that &lt;em&gt;robust&lt;/em&gt; refers to data uncertainty, and &lt;em&gt;resilient&lt;/em&gt; and &lt;em&gt;reliable&lt;/em&gt; refer to disruptions of some sort (and are nearly synonymous with each other).&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-10-08T15:17:44.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4996" PostTypeId="2" ParentId="4991" CreationDate="2020-10-08T16:31:54.130" Score="9" Body="&lt;p&gt;This reminds me of the Progressive Party Problem, for which an elegant MIP formulation is given here:&lt;/p&gt;&#xA;&lt;p&gt;Erwin Kalvelagen, &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0305054802001016&quot; rel=&quot;noreferrer&quot;&gt;On solving the progressive party problem as a MIP&lt;/a&gt;. &lt;em&gt;Computers &amp;amp; Operations Research&lt;/em&gt; &lt;strong&gt;30&lt;/strong&gt; (2003) 1713–1726&lt;/p&gt;&#xA;&lt;p&gt;An AMPL implementation of this formulation, and an alternative approach for getting a good solution faster, are described in my tutorial, &lt;a href=&quot;https://ampl.com/MEETINGS/TALKS/2018_03_Denver_SA13.pdf&quot; rel=&quot;noreferrer&quot;&gt;Identifying Good Near-Optimal Formulations for Hard Mixed-Integer Programs&lt;/a&gt;. See the example headed &amp;quot;Breaking Up 3&amp;quot; beginning on slide 36.&lt;/p&gt;&#xA;" OwnerUserId="52" LastActivityDate="2020-10-08T16:31:54.130" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4997" PostTypeId="1" CreationDate="2020-10-08T22:01:01.097" Score="-2" ViewCount="124" Body="&lt;p&gt;The problem description of the challenge is given &lt;a href=&quot;https://github.com/rte-france/challenge-roadef-2020/raw/master/Challenge_Subject.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone has some references to similar problem. I would like to participate but I don't know where to start.&lt;/p&gt;&#xA;" OwnerUserId="3711" LastActivityDate="2020-10-10T14:01:59.577" Title="Any references to the ROADEF 2020 Challenge?" Tags="|integer-programming|constraint-programming|metaheuristics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4998" PostTypeId="1" AcceptedAnswerId="4999" CreationDate="2020-10-08T22:29:18.827" Score="1" ViewCount="93" Body="&lt;p&gt;I have a discrete optimization problem in which there are some predetermined nodes in the set A. a vehicle must visit them as the traveling salesman problem. there are some other nodes in the set B that they must be covered by a  node in set A or a new node that is chosen from a set of candidate nodes. we define a node in B is covered if there is a node at a distance of R from it. I want to choose the minimum nodes from candidate nodes that must be added to set A to cover all nodes in B. the objective function is minimizing the tour length visiting nodes in A and the new nodes added.&#xA;I want to model and solve this problem. Could anyone introduce articles in the literature that are somewhat related to this issue?&lt;/p&gt;&#xA;" OwnerUserId="3972" LastActivityDate="2020-10-09T00:29:29.467" Title="A discrete location problem" Tags="|mixed-integer-programming|modeling|combinatorial-optimization|facility-location|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4999" PostTypeId="2" ParentId="4998" CreationDate="2020-10-09T00:29:29.467" Score="5" Body="&lt;p&gt;This sounds like the &lt;a href=&quot;https://www.jstor.org/stable/25768381&quot; rel=&quot;noreferrer&quot;&gt;Covering Salesman Problem&lt;/a&gt;, introduced in 1989.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-10-09T00:29:29.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5000" PostTypeId="1" AcceptedAnswerId="5001" CreationDate="2020-10-09T12:08:45.597" Score="6" ViewCount="1134" Body="&lt;p&gt;I use the weighted sum approach for a multiobjective optimization problem that is formulated as a MILP. This means that the objective function is linear. I read quite often that the weighted sum approach can't find certain pareto-optimal solutions in case of non-convex objective spaces (see for example slide 12 in this presentation &lt;a href=&quot;https://engineering.purdue.edu/%7Esudhoff/ee630/Lecture09.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://engineering.purdue.edu/~sudhoff/ee630/Lecture09.pdf&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Now, having a MILP problem, can I deduce that basically the weighted sum approach can find all pareto optimal solutions if I just vary the weights? Of course the number of pareto-optimal solutions might be infinite, but I'd like to know whether there is the risk of missing some areas of the pareto-front. My gut feeling is that in a MILP the weighted sum approach can in fact find all pareto-optimal solutions.&lt;/p&gt;&#xA;&lt;p&gt;Can anyone tell me more about this issue? I'd really appreciate every comment.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastActivityDate="2020-10-09T13:18:01.520" Title="Does the weighted sum approach find all pareto-optimal solutions in MILP" Tags="|mixed-integer-programming|multi-objective-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5001" PostTypeId="2" ParentId="5000" CreationDate="2020-10-09T12:21:52.187" Score="4" Body="&lt;p&gt;No. You cannot be sure to find all Pareto optimal solutions to a MILP using the weighted sum approach. You are not even guaranteed to find all non-dominated outcomes.&#xA;You are only guaranteed to be able to generate the supported non-dominated solutions. All the unsupported non-dominated solutions cannot be found using the weighted sum approach (without adding additional constraints). This is all due to the fact that it is not enough that the objective functions are convex, also the decision space needs to be convex for the weighted sum approach to guarantee all non-dominated outcomes.&lt;/p&gt;&#xA;&lt;p&gt;Consider the following small bi-objective MILP example:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  \min\ &amp;amp; 4 + 2x_1+x_2+\frac{1}{2}y\\&#xA;  \min\ &amp;amp; 2+x_1+2x_2+3y\\&#xA;  \mbox{s.t.:}\ &amp;amp; x_1+x_2+y\geq 2\\&#xA;  \ &amp;amp; x_1,x_2\geq 0\\&#xA;  \ &amp;amp; y\in\{0,1\}&#xA;\end{align}&lt;/span&gt;&#xA;The non-dominate solutions can be illustrated as follows:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Uof6M.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Uof6M.png&quot; alt=&quot;Non-dominated frontier&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The red line (solid and dotted) is the efficient front for &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt; and the blue solid line is the efficient front for &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;. Hence, the set of non-dominated outcomes is given by the union of the two solid lines. However, it is only the top left red dot and everything one the blue line you can find using the weighted sum scalarization. You can find the top red point using weights &lt;span class=&quot;math-container&quot;&gt;$(0.9,0.1)$&lt;/span&gt;, the middel blue point using weights &lt;span class=&quot;math-container&quot;&gt;$(0.6,0.4)$&lt;/span&gt;, and the lower right blue point using weights &lt;span class=&quot;math-container&quot;&gt;$(0.1,0.9)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Thus, you cannot generate the entire set of non-dominated outcomes for MILP problems in general using the weighted sum scalarization.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2020-10-09T13:18:01.520" LastActivityDate="2020-10-09T13:18:01.520" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="5002" PostTypeId="1" AcceptedAnswerId="5005" CreationDate="2020-10-09T13:47:06.733" Score="3" ViewCount="220" Body="&lt;p&gt;I have the following multiobjective problem.&lt;/p&gt;&#xA;&lt;p&gt;I need to minimize the user-perceived latency while doing so aggressively minimizing user-perceived latency generates large switching cost (Reconfiguration overhead) which effects the user-perceived latency and downtime in the application. My question is how to balance this user-perceived delay- switching cost trade-off in a cost-efficient manner.&lt;/p&gt;&#xA;&lt;p&gt;To optimize the conflicting objectives (i.e., perceived latency and switching cost) in a balanced manner, different weights are assigned to the defined objectives and then minimize the weighted sum of them. Given a finite time horizon T, then the problem is formulated as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fT7m1.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fT7m1.gif&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;where ωt are the dynamic weights of user-perceived latency and switching cost respectively,&#xA;which can be set through the running application demands.&lt;/p&gt;&#xA;&lt;p&gt;How the values for the dynamic weights can be assigned will this be learned during the application deployment of the application lifecycle. Would anyone clear my concept on this issue? I am completely stuck on how to solve this problem.&lt;/p&gt;&#xA;&lt;p&gt;I also need to ask which algorithm/approach can be used to solve these conflicting objectives. Any suggestion for solving this problem through some fast and lightweight approach.&#xA;Help is highly appreciated.&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="3811" LastEditorUserId="3811" LastEditDate="2020-10-09T13:52:33.127" LastActivityDate="2020-10-09T19:15:46.813" Title="Which method to use to solve this multi-objective conflicting objectives" Tags="|optimization|linear-programming|modeling|multi-objective-optimization|machine-learning|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5003" PostTypeId="1" CreationDate="2020-10-09T17:58:37.123" Score="1" ViewCount="205" Body="&lt;p&gt;I am dealing with a discrete math optimization problem on a complete graph. My variables are the arcs but I want to delete the arcs that &amp;quot;cost too much&amp;quot;. I have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; nodes which means I have &lt;span class=&quot;math-container&quot;&gt;$n(n-1)$&lt;/span&gt; arcs before deletion.&#xA;I define the following set in AMPL&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ARCS:={i in 1..n, j in 1..n : i!=j &amp;amp;&amp;amp; d[i,j]&amp;lt;= R}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where &lt;code&gt;d[i,j]&lt;/code&gt; is the cost on the arc &lt;code&gt;(i,j)&lt;/code&gt; and &lt;code&gt;R&lt;/code&gt; the limit I am putting.&lt;/p&gt;&#xA;&lt;p&gt;My problem is that I don't know how to index the variables now. I know I can write&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt; sum{ i in 1..n, j in 1..n : (i,j) in ARCS} blablabla[i,j]&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;But I think this is quite a tedious way to do.&#xA;I thought I could write something like this&#xA;&lt;code&gt; sum{e in ARCS} blablabla[e[0],e[1]]&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4248" LastEditorUserId="123" LastEditDate="2021-02-17T11:39:34.730" LastActivityDate="2021-02-17T11:39:34.730" Title="Handy way to index set of tuples in AMPL" Tags="|optimization|graphs|ampl|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5004" PostTypeId="2" ParentId="5003" CreationDate="2020-10-09T18:09:34.457" Score="5" Body="&lt;p&gt;Try&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sum{(i,j) in ARCS} blablabla[i,j]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-10-09T18:09:34.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5005" PostTypeId="2" ParentId="5002" CreationDate="2020-10-09T19:15:46.813" Score="6" Body="&lt;p&gt;There is a rich literature on reconciling multiple objectives (which I will not attempt to repeat in its entirety here, although what follows is long-winded enough to appear to do so). The ones I know (possibly not all of them) fall into the following categories.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Optimize a weighted combination of the objectives (as you have written). The big problem here is finding appropriate weights (which is particularly challenging when the objectives are not directly comparable, as in your case).&lt;/li&gt;&#xA;&lt;li&gt;Optimize one objective while constraining how bad the others can get. For instance, minimize switching cost subject to user latency never going above some limit. Among the problems with this approach is finding an appropriate limit for each objective not being optimized.&lt;/li&gt;&#xA;&lt;li&gt;Goal programming, a variant of the previous approach, sets &amp;quot;aspiration levels&amp;quot; (targets) for each objective and minimizes the amount by which a solution fails to attain those levels. You can set multiple goals for the same objective with different weights in the objective (e.g., &amp;quot;don't let latency exceed  and &lt;em&gt;really&lt;/em&gt; don't let latency exceed ). Problems with this approach including picking the aspiration levels, scaling them (so that being x short on a latency goal is comparable to being x short on a cost goal) and weight the shortfalls.&lt;/li&gt;&#xA;&lt;li&gt;Computing some or all of the &lt;strong&gt;Pareto frontier&lt;/strong&gt; (the set of all solutions that are not dominated by any other solution, where dominance means being better on at least on objective and no worse on the other objectives). Problems here include the computation time involved in finding the Pareto frontier and how to choose one solution from among those on the frontier.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Crucial in any of these, I think, will be for you to figure out whom you need to satisfy and get their input. Who will sit in judgment of your solution? If it's the boss, switching costs (directly measurable) may be more important than perceived latency. If it's customers, vice versa. Whoever has the &amp;quot;final say&amp;quot; on the solution will need to provide input on what trade-offs between your two objectives are/are not appropriate. There is no mathematical silver bullet for this.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-10-09T19:15:46.813" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5006" PostTypeId="1" AcceptedAnswerId="5017" CreationDate="2020-10-10T03:53:51.287" Score="6" ViewCount="167" Body="&lt;p&gt;As it will become apparent, my field is not operation-research and so this question will sound very naive. I am sorry for that.&lt;/p&gt;&#xA;&lt;p&gt;I have a set of &amp;quot;buildings&amp;quot; that I want to place on a small 2d grid; one per cell only. There is a non-linear objective function that accounts for adjacency effects as well as a score for each building.&lt;/p&gt;&#xA;&lt;p&gt;Problem right now is small enough that I can brute force it, but I would like to read more about this general class of combinatorial problems.&lt;/p&gt;&#xA;&lt;p&gt;I've tried reading about 0-1 Knapsack problems and bin-packing but none of them seem to deal or care about adjacency effects. Is there a better term/class for this kind of problems?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;To try and narrow down the problem, let's just say the objective function is just the &amp;quot;value&amp;quot; associated with each building + some bonus/malus if two buildings are next to each other (i.e. the police station is worth 1 point, the prison is worth 2 points and you get a bonus of one point if they are next to each other)&lt;/p&gt;&#xA;" OwnerUserId="4079" LastEditorUserId="4079" LastEditDate="2020-10-11T08:01:58.343" LastActivityDate="2020-10-11T11:42:17.643" Title="Literature on &quot;simcity-like&quot; problems" Tags="|integer-programming|combinatorial-optimization|literature-research|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5007" PostTypeId="1" AcceptedAnswerId="5014" CreationDate="2020-10-10T05:31:40.110" Score="4" ViewCount="336" Body="&lt;p&gt;I am trying to solve the following problem. The decisions in the problem are &lt;span class=&quot;math-container&quot;&gt;$x, y, v, $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x, y$&lt;/span&gt; are binary and &lt;span class=&quot;math-container&quot;&gt;$v, W$&lt;/span&gt; are continuous variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{eq:3}&#xA;\begin{aligned}&#xA;&amp;amp; \underset{x, y, v, W}{\text{minimize}}&#xA;&amp;amp; &amp;amp; c^{T}v + W^{T}\mathbf{1}\\&#xA;&amp;amp; \text{subject to}&#xA;&amp;amp; &amp;amp; Ax \le b\\&#xA;&amp;amp; &amp;amp; &amp;amp; \sum_{f = 1}^{q} y_{lf} = x_l, \forall l = 1, ..., p\\&#xA;&amp;amp; &amp;amp; &amp;amp; Hv = d\\&#xA;&amp;amp; &amp;amp; &amp;amp; v_a \le \left(\sum_{f = 1}^{q} f y_{l(a)f}\right) W_i, \forall a = 1, ..., m, \forall i = 1, .., n \\&#xA;&amp;amp; &amp;amp; &amp;amp;x \in \{0, 1\}^p, y \in \{0, 1\}^{p\times q}, v \in \mathbb{R}^{m}_{+}, W \in \mathbb{R}^{n}_{+}&#xA;\end{aligned}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As we can see that there is a product of continuous and binary variable in the fourth set constraints, so I linearize that using McCormick Relaxation. Assuming &lt;span class=&quot;math-container&quot;&gt;$0 \le W_i \le \bar{W}_{i}$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$t_{fai} = y_{l(a)f} \times W_i$&lt;/span&gt;, we can state the problem as an exact MIP as below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{aligned}&#xA;&amp;amp; \underset{x, y, v, W, t}{\text{minimize}}&#xA;&amp;amp; &amp;amp; c^{T}v + W^{T}\mathbf{1}\\&#xA;&amp;amp; \text{subject to}&#xA;&amp;amp; &amp;amp; Ax \le b\\&#xA;&amp;amp; &amp;amp; &amp;amp; \sum_{f = 1}^{q} y_{lf} = x_l, \forall l = 1, ..., p\\&#xA;&amp;amp; &amp;amp; &amp;amp; Hv = d\\&#xA;&amp;amp; &amp;amp; &amp;amp; v_a \le \left(\sum_{f = 1}^{q} f t_{fai} \right), \forall a = 1, ..., m, \forall i = 1, .., n \\&#xA;&amp;amp; &amp;amp; &amp;amp; W_i - t_{fai} \le \bar{W}_{i} (1 - y_{l(a)f}), \forall f = 1, ..., q, \forall a = 1, ..., m, \forall i = 1, .., n\\&#xA;&amp;amp; &amp;amp; &amp;amp; t_{fai} \le \bar{W}_{i} y_{l(a)f}, \forall f = 1, ..., q, \forall a = 1, ..., m, \forall i = 1, .., n\\&#xA;&amp;amp; &amp;amp; &amp;amp; W_i - t_{fai} \ge 0,  \forall f = 1, ..., q, \forall a = 1, ..., m, \forall i = 1, .., n\\&#xA;&amp;amp; &amp;amp; &amp;amp; t_{fai} \ge 0,  \forall f = 1, ..., q, \forall a = 1, ..., m, \forall i = 1, .., n\\&#xA;&amp;amp; &amp;amp; &amp;amp;x \in \{0, 1\}^p, y \in \{0, 1\}^{p\times q}, v \in \mathbb{R}^{m}_{+}, W \in \mathbb{R}^{n}_{+}&#xA;\end{aligned}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am applying Benders Decomposition to solve the problem. The complicating variables are &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. Due to a large value of &lt;span class=&quot;math-container&quot;&gt;$\bar{W}_{i}$&lt;/span&gt;, the lower bound to the problem is really bad. The iterations look as below. The algorithm does not converge and becomes slow after adding lots of optimality cuts. I tried different values of &lt;span class=&quot;math-container&quot;&gt;$\bar{W}_i$&lt;/span&gt;. Letting &lt;span class=&quot;math-container&quot;&gt;$\bar{W}_i$&lt;/span&gt; too low makes the subproblem infeasible (but my subproblem has been proved to have feasible solution for any value of &lt;span class=&quot;math-container&quot;&gt;$x, y$&lt;/span&gt; so it should not gernerate any feasibility cuts). Are there any possible solutions to avoid this problem? I appreciate any help.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(it = 1, LB = -1249013856, UB = 780802)&#xA;(it = 2, LB =  -260761666, UB = 647047)&#xA;(it = 3, LB = -260385041, UB = 780652)&#xA;(it = 4, LB = -255998781, UB = 729034)&#xA;(it = 5, LB = -255661092, UB = 765904)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2424" LastActivityDate="2020-10-10T20:12:15.317" Title="Benders subproblem with product of continuous and discrete variables" Tags="|mixed-integer-programming|big-m|benders-decomposition|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5008" PostTypeId="2" ParentId="4997" CreationDate="2020-10-10T14:01:59.577" Score="2" Body="&lt;p&gt;This is a maintenance planning problem, here related to the French high-voltage transmission system. By searching for &amp;quot;maintenance planning problem&amp;quot; on the web, you will find a lot of OR literature on the topic.&lt;/p&gt;&#xA;&lt;p&gt;Now, to start, may we advise you to:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;entirely read the subject of the challenge;&lt;/li&gt;&#xA;&lt;li&gt;read the input data using your favorite programming language;&lt;/li&gt;&#xA;&lt;li&gt;implement a first, basic solution approach, based on a greedy algorithm or relying on a mathematical optimization solver.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Then, you will be able to iterate, sophisticating your solution approach (or implementing a new, different one).&lt;/p&gt;&#xA;&lt;p&gt;Note that all the instances given for now (namely, A instances) can be solved to near optimality by LocalSolver through a direct modeling approach. In particular, LocalSolver allows modeling easily and exactly the risk as an external (black-box) function, which is not possible when using traditional MILP solvers. LocalSolver is a commercial product but if you are interested to use it freely for the challenge, you will be welcome.&lt;/p&gt;&#xA;&lt;p&gt;In a way or another, we encourage you to participate in such a challenge. This is a very formative exercise for real-life OR.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-10-10T14:01:59.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5009" PostTypeId="2" ParentId="5007" CreationDate="2020-10-10T14:16:43.880" Score="4" Body="&lt;p&gt;It would be better to use big-M values that depend on &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, like &lt;span class=&quot;math-container&quot;&gt;$\bar{W}_{f,a,i}$&lt;/span&gt;, instead of just on &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; only. Also, how are you computing big-M?&lt;/p&gt;&#xA;&lt;p&gt;For fixed &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; that satisfy the first two constraints, your original problem is linear and feasible.  An alternative approach to linearization is to use combinatorial Benders decomposition, where the Benders optimality cuts are big-M constraints. Because the subproblem is feasible for all &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, you do not need Benders feasibility cuts.&lt;/p&gt;&#xA;&lt;p&gt;An idea that might help both approaches is to strengthen the master problem by including, a priori, additional valid inequalities that involve only &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and/or &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.  For example, if you can determine, perhaps by solving some auxiliary problem, that &lt;span class=&quot;math-container&quot;&gt;$x_\ell=1$&lt;/span&gt; implies that the contribution to the objective for (location?) &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; is at least &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt;, you can impose master constraint &lt;span class=&quot;math-container&quot;&gt;$\eta \ge \sum_{\ell=1}^p g_\ell x_\ell$&lt;/span&gt;.  Otherwise, you are completely relying on weak optimality cuts to guide the algorithm.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-10-10T14:50:30.550" LastActivityDate="2020-10-10T14:50:30.550" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5010" PostTypeId="1" CreationDate="2020-10-10T16:53:26.630" Score="2" ViewCount="599" Body="&lt;p&gt;Assume we have two variables &lt;span class=&quot;math-container&quot;&gt;$x,y \in S$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$S=\{1,2, \dots, 1000\}$&lt;/span&gt;.&#xA;Also, we are given a partition of set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_1 = \{1,2, \dots, 249\}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$,S_2 = \{250, \dots, 499\}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$,S_3 = \{500, \dots, 749\}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$,S_4 = \{750, \dots, 1000\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How to model a constraint that &lt;strong&gt;prevents&lt;/strong&gt; variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; both belonging to the same partition.&#xA;That said, &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y = 2$&lt;/span&gt; is an invalid assignment but &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y = 250$&lt;/span&gt; is allowed.&lt;/p&gt;&#xA;&lt;p&gt;I am using Google OR-Tools Constraint Programming.&lt;/p&gt;&#xA;&lt;p&gt;(Please note the intersection of any two of the subsets is empty, and their union is the whole set. Each partition is &lt;strong&gt;not&lt;/strong&gt; necessarily a full range of integers, unlike the example. For instance, &lt;span class=&quot;math-container&quot;&gt;$S_1=\{1,\dots,249,750,\dots,1000\}, \quad S_2=\{250,\dots,749\}$&lt;/span&gt; is too a valid partition.)&lt;/p&gt;&#xA;" OwnerUserId="765" LastEditorUserId="765" LastEditDate="2020-10-11T01:45:03.303" LastActivityDate="2020-10-11T04:33:29.793" Title="How to model two variables to NOT to belong to the same set partition using Constraint Programming" Tags="|modeling|constraint-programming|or-tools|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5011" PostTypeId="1" CreationDate="2020-10-10T17:38:39.747" Score="2" ViewCount="125" Body="&lt;p&gt;Assume we have variables &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2, x_3, x_4$&lt;/span&gt; that each can belong to &lt;span class=&quot;math-container&quot;&gt;$\{1,2,...,10\}$&lt;/span&gt;. How can we model a constraint that variables &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2$&lt;/span&gt; get assigned &lt;strong&gt;different&lt;/strong&gt; values than &lt;span class=&quot;math-container&quot;&gt;$x_3, x_4$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Because of scaling issue, it is not efficient to enumerate all assignment combinations as &lt;span class=&quot;math-container&quot;&gt;$\\x_1 \neq x_3, \quad x_1 \neq x_4, \quad x_2 \neq x_3, \quad x_2 \neq x_4$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am using OR-Tools CP-SAT.&lt;/p&gt;&#xA;" OwnerUserId="765" LastEditorUserId="981" LastEditDate="2023-12-22T15:14:41.583" LastActivityDate="2023-12-22T15:14:41.583" Title="How to model a set of integer variables getting assigned different values than another set of integer variables" Tags="|modeling|constraint-programming|or-tools|cp-sat|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5012" PostTypeId="2" ParentId="5010" CreationDate="2020-10-10T17:48:16.923" Score="4" Body="&lt;p&gt;Here's one way:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x\not=i \lor y\not=j \text{ for } k\in\{1,2,3,4\}, i\in S_k, j\in S_k$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Here's another way, using ELEMENT constraints, as suggested by @prubin.  The following is SAS code, but maybe OR-Tools has something similar.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;proc optmodel;&#xA;   set S {k in 1..4} = &#xA;      if      k = 1 then 1..249&#xA;      else if k = 2 then 250..499&#xA;      else if k = 3 then 500..749&#xA;      else               750..1000;&#xA;   num p {1..1000};&#xA;   for {k in 1..4, i in S[k]} p[i] = k;&#xA;&#xA;   var X &amp;gt;= 1 &amp;lt;= 1000 integer;&#xA;   var Y &amp;gt;= 1 &amp;lt;= 1000 integer;&#xA;&#xA;   var PX &amp;gt;= 1 &amp;lt;= 4 integer;&#xA;   var PY &amp;gt;= 1 &amp;lt;= 4 integer;&#xA;&#xA;   /* PX = p[X] */&#xA;   con ElementConX:&#xA;      element(X, p, PX);&#xA;   /* PY = p[Y] */&#xA;   con ElementConY:&#xA;      element(Y, p, PY);&#xA;&#xA;   con NotEqual:&#xA;      PX ne PY;&#xA;&#xA;   solve;&#xA;   print X Y PX PY;&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The first solution found was&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(X, Y, PX, PY) = (1, 250, 1, 2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and specifying the FINDALLSOLNS option yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$1000^2-249^2-250^2-250^2-251^2=749998$$&lt;/span&gt;&#xA;solutions, as expected.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-10-11T04:33:29.793" LastActivityDate="2020-10-11T04:33:29.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5013" PostTypeId="2" ParentId="5011" CreationDate="2020-10-10T17:51:07.413" Score="3" Body="&lt;p&gt;If you mean &lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2)\not=(x_3,x_4)$&lt;/span&gt;, you can enforce this with:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$10(x_1-1) + (x_2-1) \not= 10(x_3-1)+(x_4-1)$$&lt;/span&gt;&#xA;Equivalently:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$10x_1 + x_2 \not= 10x_3+x_4 \tag1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If instead you meant the four disequalities you listed,&#xA;you can impose &lt;span class=&quot;math-container&quot;&gt;$$(x_1 - x_3)(x_1 - x_4)(x_2 - x_3)(x_2 - x_4)\not=0$$&lt;/span&gt;&#xA;Alternatively,&#xA;you might consider generating your four disequalities dynamically only if they are violated.  In this case, &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; is still valid but is only a relaxation.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Here's a MILP formulation.  Let binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$x_i=j$&lt;/span&gt;, and let binary variable &lt;span class=&quot;math-container&quot;&gt;$z_{g,j}$&lt;/span&gt; indicate whether any variable in group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is assigned value &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.  Then your constraints are&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j y_{i,j} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for $i\in\{1,\dots,1000\}$} \\&#xA;\sum_j j y_{i,j} &amp;amp;= x_i &amp;amp;&amp;amp;\text{for $i\in\{1,\dots,1000\}$} \\&#xA;y_{i,j} &amp;amp;\le z_{g,j} &amp;amp;&amp;amp;\text{for $g\in\{1,2\}$, $i$ in group $g$, and $j\in\{1,\dots,10\}$} \\&#xA;\sum_g z_{g,j} &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for $j\in\{1,\dots,10\}$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-10-11T15:39:10.457" LastActivityDate="2020-10-11T15:39:10.457" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="5014" PostTypeId="2" ParentId="5007" CreationDate="2020-10-10T20:05:02.570" Score="4" Body="&lt;p&gt;If I'm correct in my understanding of the decomposition, the master problem contains the binary variables (and a surrogate variable for the subproblem objective value) and the subproblem contains all the other variables and all the terms of the original objective function. That being the case, you might look at a paper by Codato and Fischetti [1], specifically the case where (in their notation) &lt;span class=&quot;math-container&quot;&gt;$c=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d \neq 0$&lt;/span&gt;. In essence, they eliminate the big &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; coefficients (your &lt;span class=&quot;math-container&quot;&gt;$\overline{W}$&lt;/span&gt;) by dropping, at each iteration, any subproblem constraint whose RHS is effectively &lt;span class=&quot;math-container&quot;&gt;$\infty$&lt;/span&gt;. They also add a constraint to the subproblem saying that it has to produce a solution with better objective value than the current incumbent, so that a feasible subproblem incapable of improving the incumbent becomes infeasible (and generates a feasibility cut). There is no guarantee it produces better bounds than you are getting, but it might be worth trying.&lt;/p&gt;&#xA;&lt;p&gt;[1] Codato, G. &amp;amp; Fischetti, M. Combinatorial Benders' Cuts for Mixed-Integer Linear Programming. &lt;em&gt;Operations Research&lt;/em&gt;, &lt;strong&gt;2006&lt;/strong&gt;, 54, 756-766.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="500" LastEditDate="2020-10-10T20:12:15.317" LastActivityDate="2020-10-10T20:12:15.317" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5015" PostTypeId="2" ParentId="5010" CreationDate="2020-10-10T20:18:28.820" Score="2" Body="&lt;p&gt;I don't use OR-Tools, so I cannot be specific about syntax, but I'm pretty sure it has a table lookup constraint. So you can create a table that associates each value from 1 to 1,000 with its partition index (1 to 4), and then just add a constraint that says the partition value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; cannot equal the partition value of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-10-10T20:18:28.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5016" PostTypeId="2" ParentId="5010" CreationDate="2020-10-11T00:53:10.383" Score="2" Body="&lt;p&gt;Using intermediate booleans and &lt;code&gt;AddLinearExpressionInDomain&lt;/code&gt; you get:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from ortools.sat.python import cp_model&#xA;&#xA;model = cp_model.CpModel()&#xA;solver = cp_model.CpSolver()&#xA;&#xA;x = model.NewIntVar(1, 1000, &amp;quot;x&amp;quot;)&#xA;y = model.NewIntVar(1, 1000, &amp;quot;y&amp;quot;)&#xA;&#xA;sx = {i: model.NewBoolVar(f&amp;quot;x in S{i}&amp;quot;) for i in range(1, 5)}&#xA;sy = {i: model.NewBoolVar(f&amp;quot;y in S{i}&amp;quot;) for i in range(1, 5)}&#xA;for i in range(4):&#xA;    si = cp_model.Domain.FromFlatIntervals([250 * i, 250 * (i + 1) - 1])&#xA;    model.AddLinearExpressionInDomain(x, si).OnlyEnforceIf(sx[i + 1])&#xA;    model.AddLinearExpressionInDomain(y, si).OnlyEnforceIf(sy[i + 1])&#xA;    model.AddBoolOr([sx[i + 1].Not(), sy[i + 1].Not()])&#xA;&#xA;model.Add(sum(sx.values()) == 1)&#xA;model.Add(sum(sy.values()) == 1)&#xA;&#xA;solver.Solve(model)&#xA;print(solver.Value(x))&#xA;print(solver.Value(y))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="991" LastActivityDate="2020-10-11T00:53:10.383" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5017" PostTypeId="2" ParentId="5006" CreationDate="2020-10-11T11:42:17.643" Score="4" Body="&lt;p&gt;Your problem looks like a &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;quadratic assignment problem&lt;/a&gt;. The problem has been researched since at least the 1950s. As long as P&lt;span class=&quot;math-container&quot;&gt;$\neq$&lt;/span&gt;NP, there cannot be any constant factor approximation algorithm.  I think there are some O(log(n))-approximation algorithms. There are also a number of well tested exact algorithms, that are better than brute force, and some heuristic algorithms that perform relatively well.&lt;/p&gt;&#xA;&lt;p&gt;My go to reference for this comes from the world of VLSI design: Check out Chapter 2 (Lower bounds for placement) of Korte, B., &amp;amp; Vygen, J. (2008). Combinatorial problems in chip design. In Building Bridges (pp. 333-368). Springer, Berlin, Heidelberg.&lt;/p&gt;&#xA;" OwnerUserId="405" LastActivityDate="2020-10-11T11:42:17.643" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5018" PostTypeId="1" AcceptedAnswerId="5019" CreationDate="2020-10-12T05:53:59.733" Score="6" ViewCount="564" Body="&lt;h3&gt;My Problem&lt;/h3&gt;&#xA;&lt;p&gt;I am quite new to optimisation, so any advice is appreciated. I am currently trying to solve a problem as follows:&lt;br /&gt;&#xA;&lt;em&gt;Given a pool of people, we want to create n teams such to find the optimal solution based on all players' preferences&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;As a test, I have been assuming there are 6 players, each of which selects a 1st and a 2nd preference for who they would like in their team. For now, I am looking to create 2 teams of 3 players.&lt;/p&gt;&#xA;&lt;h3&gt;How I have attempted it&lt;/h3&gt;&#xA;&lt;p&gt;I want to solve this using an open-source solver in Python, so I am currently trying the 'glpk' solver via Pyomo, however I am stuck. I created a matrix of preferences, whereby each row represents a given player's top 2 preferences (here, 2 means 1st pick) as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;preferenceMatrix =  [0 1 0 0 2 0]  # Player 1 would like players 5 (1st pick) and 2 (2nd pick)&#xA;                    [2 0 1 0 0 0]  # Player 2 would like players 1 (1st pick) and 3 (2nd pick)&#xA;                    [0 0 0 0 2 1]  # Player 3 would like players 5 (1st pick) and 6 (2nd pick)&#xA;                    [0 1 2 0 0 0]  # Player 4 would like players 3 (1st pick) and 2 (2nd pick)&#xA;                    [0 0 0 1 2 0]  # Player 5 would like players 5 (1st pick) and 4 (2nd pick)&#xA;                    [2 0 0 1 0 0]  # Player 6 would like players 1 (1st pick) and 4 (2nd pick)&#xA;                    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Next, I multiply the preference matrix by a binary matrix (subject to a constraint of 2 players per row and column), and then maximise the sum over the entire matrix. An example of what the binary matrix could look like is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;binaryMatrix =   [0 1 1 0 0 0]&#xA;                 [1 0 1 0 0 0]&#xA;                 [1 1 0 0 0 0]&#xA;                 [0 0 0 0 1 1]&#xA;                 [0 0 0 1 0 1]&#xA;                 [0 0 0 1 1 0]&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This would form 2 teams: &lt;strong&gt;Team 1)&lt;/strong&gt; players 1,2,3, and &lt;strong&gt;Team 2)&lt;/strong&gt; players 4,5,6 and the &lt;strong&gt;objective function&lt;/strong&gt; (summing over rows) would be 1+3+0+0+1+1 = 6.&lt;/p&gt;&#xA;&lt;h3&gt;My questions&lt;/h3&gt;&#xA;&lt;p&gt;&lt;strong&gt;1)&lt;/strong&gt; If I continue with this approach, then how could I constrain it to create exactly 2 teams? I originally posted this exact issue &lt;a href=&quot;https://stackoverflow.com/questions/64224832/create-pyomo-constraint-for-maximum-number-of-connected-sets&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;2)&lt;/strong&gt; As I am finding it hard to approach the problem using glpk, is there a more appropriate open-source solver I could use instead?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;3)&lt;/strong&gt; Or, could I approach this entirely differently (e.g. using networkx where I specify that the problem should create 2 equal-sized connected groups)?&lt;/p&gt;&#xA;" OwnerUserId="4256" LastActivityDate="2020-10-12T14:40:02.590" Title="Can GLPK be used to solve an optimal team selection problem?" Tags="|mixed-integer-programming|linear-programming|python|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5019" PostTypeId="2" ParentId="5018" CreationDate="2020-10-12T07:50:31.990" Score="4" Body="&lt;blockquote&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If I continue with this approach, then how could I constrain it to&#xA;create exactly 2 teams?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If you need two teams exactly, you could define a &amp;quot;preference cost&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt; betweeen each pair of players &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;. For example, you could define&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p_{ij} = \left\{&#xA;    \begin{array}{ll}&#xA;        4 &amp;amp; \mbox{if $i$ and $j$ are each others first pick}\\&#xA;        3 &amp;amp; \mbox{if $i$ or $j$ is a first pick} \\&#xA;        2 &amp;amp; \mbox{if $i$ and $j$ are each others second pick} \\&#xA;        1 &amp;amp; \mbox{if $i$ or $j$ is a second pick} \\&#xA;        0 &amp;amp; \mbox{otherwise} \\&#xA;    \end{array}&#xA;\right.&#xA;$$&lt;/span&gt;&#xA;Then use the following binary variables :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}^1 = 1$&lt;/span&gt; if and only if players &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; end up in team &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}^2 = 1$&lt;/span&gt; if and only if players &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; end up in team &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$w_{ij}=1$&lt;/span&gt; if and only if players &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; end up together (whatever the team),&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_i=1$&lt;/span&gt; if and only if player &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is selected for team &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; (and so &lt;span class=&quot;math-container&quot;&gt;$y_i=0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is selected for team &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So you want to maximize the global preference :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \; \sum_{i,j} p_{ij}w_{ij}&#xA;$$&lt;/span&gt;&#xA;subject to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each team must have &lt;span class=&quot;math-container&quot;&gt;$n/2$&lt;/span&gt; players (&lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; denotes the total number of players):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i}y_i = n/2&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; is only active if &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are selected simultaneously:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{ij}^1 \le y_{i} \\&#xA;x_{ij}^1 \le y_{j} \\&#xA;x_{ij}^2 \le 1-y_{i} \\&#xA;x_{ij}^2 \le 1-y_{j} \\&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are together if they are simultaneously in team &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;w_{ij} = x_{ij}^1 + x_{ij}^2&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;variables are binary&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{ij}^1,x_{ij}^2,w_{ij},y_i \in \{0,1\}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/em&gt; there is probably a way to simplify the above equations. You basically need to model&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\boxed{&#xA;w_{ij}=1 \quad \Rightarrow y_i=y_j&#xA;}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;As I am finding it hard to approach the problem using glpk, is&#xA;there a more appropriate open-source solver I could use instead?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I would suggest using &lt;a href=&quot;https://github.com/coin-or/pulp&quot; rel=&quot;nofollow noreferrer&quot;&gt;pulp&lt;/a&gt; instead. Pulp is a modeler, not a solver, but it can call any solver out there (including GLPK). With pulp, you can focus on the modeling part, and not worry about the solver, it will call the default one if you do not have any at hand (CBC). Check out the &lt;a href=&quot;https://coin-or.github.io/pulp/CaseStudies/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;examples&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Or, could I approach this entirely differently (e.g. using networkx&#xA;where I specify that the problem should create 2 equal-sized connected&#xA;groups)?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You could create a complete graph with one vertex per player, and one edge between each pair of vertices with the above defined preference cost. You want to partition your vertices into two equal sized sets, so you want to color the vertices of the graph with two colors exactly, such that 1) both colors have the same amount of vertices 2) the preference cost is maximized, and it is only active when both vertices have the same color. There is no algorithm in the networkx package for this, to my knowledge.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT :&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is basically a &lt;a href=&quot;https://coin-or.github.io/pulp/CaseStudies/a_set_partitioning_problem.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;wedding planning problem&lt;/a&gt;. There is an example given in &lt;a href=&quot;https://coin-or.github.io/pulp/CaseStudies/a_set_partitioning_problem.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;pulp's documentation&lt;/a&gt;, where the problem is modeled differently than above: it is modeled as a set partitioning problem, where all possible combinations are generated a priori. You can use it and consider that you are planning a wedding with 2 tables. Note that they also define a &amp;quot;preference cost&amp;quot;, which they call &amp;quot;happiness.&amp;quot;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-10-12T14:40:02.590" LastActivityDate="2020-10-12T14:40:02.590" CommentCount="24" ContentLicense="CC BY-SA 4.0" />
  <row Id="5020" PostTypeId="1" AcceptedAnswerId="5021" CreationDate="2020-10-12T11:44:16.357" Score="5" ViewCount="598" Body="&lt;p&gt;I have a result I want to save in a .txt file. So I use this line to save a result &lt;code&gt;k&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;param OutputFile symbolic := &amp;quot;output.txt&amp;quot;;&#xA;print k &amp;gt;&amp;gt; (OutputFile);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, I may run the script several times which means I will open an existing file and add lines to it. What I want to do is &lt;strong&gt;overwrite&lt;/strong&gt; on the file output.txt so I will not have the previous runs results.&lt;/p&gt;&#xA;&lt;p&gt;How do I do this?&lt;/p&gt;&#xA;" OwnerUserId="4248" LastEditorUserId="491" LastEditDate="2020-10-13T16:40:20.407" LastActivityDate="2020-10-13T16:40:20.407" Title="Overwrite on a txt file from AMPL" Tags="|ampl|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5021" PostTypeId="2" ParentId="5020" CreationDate="2020-10-12T12:06:54.897" Score="5" Body="&lt;p&gt;This should overwrite :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; k &amp;gt; (OutputFile);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;While this appends :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; k &amp;gt;&amp;gt; (OutputFile);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-10-12T12:06:54.897" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5022" PostTypeId="2" ParentId="5020" CreationDate="2020-10-12T12:57:30.033" Score="6" Body="&lt;p&gt;To overwrite a file that you have previously been writing in an AMPL session, first close the file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;close (OutputFile);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then use &amp;gt; to overwrite the file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;print k &amp;gt; (OutputFile);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This deletes the file and then opens a new, empty file with the same name. Note that once the file is open, &amp;gt; and &amp;gt;&amp;gt; both append to it. A complete description of AMPL file redirection is given in section &lt;a href=&quot;https://ampl.com/BOOK/CHAPTERS/15-display.pdf#page=33&quot; rel=&quot;noreferrer&quot;&gt;12.7 General facilities for manipulating output&lt;/a&gt; of the AMPL book.&lt;/p&gt;&#xA;" OwnerUserId="52" LastActivityDate="2020-10-12T12:57:30.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5023" PostTypeId="1" CreationDate="2020-10-12T17:38:08.930" Score="5" ViewCount="136" Body="&lt;p&gt;I want to add robustness to my AMPL code, here is what I am actually doing:&#xA;In my script I use a .txt file that contains all my parameters, let's call it &amp;quot;instance.txt&amp;quot;. I want to print my result in another txt file and call it &amp;quot;output_instance.txt&amp;quot;. This is not an issue for me.&lt;/p&gt;&#xA;&lt;p&gt;However, I may try the code with several instances and thus use many files &amp;quot;instance0.txt&amp;quot;, &amp;quot;instance1.txt&amp;quot;, &amp;quot;instance2.txt&amp;quot; etc.&lt;/p&gt;&#xA;&lt;p&gt;I would like to generalize the above by writing :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;param filename := &amp;quot;instance.txt&amp;quot;&#xA;print blablabla &amp;gt; out (&amp;quot;output&amp;quot; &amp;amp; filename)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The purpose of doing this is to have a specific file name for each output.&lt;/p&gt;&#xA;&lt;p&gt;The first line generates this error (I don't know if the second is correct)  :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;error processing param filename:&#xA;    can't convert 'instance.txt' to a number.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I read the chapter about strings in the ampl book but I didn't find what I was looking for.&lt;/p&gt;&#xA;&lt;p&gt;Please tell me if you have a way of doing this with .txt files or with .dat files&lt;/p&gt;&#xA;" OwnerUserId="4248" LastEditorUserId="123" LastEditDate="2021-02-23T09:32:07.880" LastActivityDate="2021-02-23T09:32:07.880" Title="Add robustness of AMPL code through file name" Tags="|cplex|ampl|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5024" PostTypeId="2" ParentId="5023" CreationDate="2020-10-12T19:46:25.107" Score="7" Body="&lt;p&gt;AMPL assumes that a parameter takes only numerical values, unless you add the keyword &lt;code&gt;symbolic&lt;/code&gt; to say that string values are also permitted. So your first statement should be&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;param filename symbolic := &amp;quot;instance.txt&amp;quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then you can use the string expression &lt;code&gt;(&amp;quot;output&amp;quot; &amp;amp; filename)&lt;/code&gt; to specify a file that receives the output from a command. For example, if you execute&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;print {i in 1..5} i^2 &amp;gt; (&amp;quot;output&amp;quot; &amp;amp; filename);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then you will write this line to the file outputinstance.txt:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1 4 9 16 25&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="52" LastActivityDate="2020-10-12T19:46:25.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5025" PostTypeId="1" AcceptedAnswerId="5027" CreationDate="2020-10-13T07:55:42.073" Score="5" ViewCount="444" Body="&lt;p&gt;I have a NLP problem at hand, which I am trying to solve via &lt;code&gt;Pyomo + ipopt&lt;/code&gt;. I try to run several different instances of the optimizer with different conditions, out of which I notice that I am able to optimize for ~90% of times. In the other 10% cases, I hit infeasibility.&lt;/p&gt;&#xA;&lt;p&gt;Upon looking into the reason for infeasibility via Pyomo's &lt;code&gt;log_infeasible_constraints&lt;/code&gt;, I found that there is one common constraint in all of those cases that is unmet and that too by just a little margin. I provide an example below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;INFO: CONSTR Cnstr_ethylene_turb2_exhaust_temp: 860.0000011442067 &amp;gt; 860.0&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;In here, the soft-constraint named &lt;em&gt;Cnstr_ethylene_turb2_exhaust_temp&lt;/em&gt; is not satisfied, but only by a slight amount (upper limit is set to be 860). My initial thought was to nudge the upper limit by some amount, however upon doing it I notice that even then the optimizer is not able to optimize for it and leaves me with an infeasible solution by again not meeting the constraint by a little amount. I provide an example below, where I increase the upper limit to 862.5.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;INFO: CONSTR Cnstr_ethylene_turb2_exhaust_temp: 862.5000010274459 &amp;gt; 862.5&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am curious to know (i) why is this happening and what is going on here in terms of mathematics, and (ii) if its possible to be handled, then how to handle such cases.&lt;/p&gt;&#xA;&lt;p&gt;Looking forward to inputs from the community.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Important Note:&lt;/strong&gt;&#xA;This happens because of very low tolerance. Pyomo also recognizes that this is mainly from tolerance issue because the solver status is still rendered as optimal and not infeasible. The confusion was caused because it still in the &lt;code&gt;log_infeasible_constraints&lt;/code&gt; , prints the constraint.&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="113" LastEditDate="2020-10-13T13:08:07.193" LastActivityDate="2020-10-13T13:10:09.127" Title="Failing to meet a constraint in a NLP problem" Tags="|constraint|nonlinear-programming|pyomo|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5026" PostTypeId="2" ParentId="5025" CreationDate="2020-10-13T10:06:30.310" Score="4" Body="&lt;p&gt;In cases like that, I usually add a variable to the constraint (slack or surplus, depending on the direction off the inequality) measuring the infeasibility. The variable should then have a large unfavorable coefficient in the objective (positive for minimization and negative for maximization) so it takes the smallest possible value.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="123" LastEditDate="2020-10-13T10:38:34.760" LastActivityDate="2020-10-13T10:38:34.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5027" PostTypeId="2" ParentId="5025" CreationDate="2020-10-13T13:10:09.127" Score="3" Body="&lt;p&gt;This happens because of very low tolerance. Setting the &lt;a href=&quot;https://coin-or.github.io/Ipopt/OPTIONS.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;tol parameter&lt;/a&gt; in ipopt solved this issue. Pyomo also recognizes that this is mainly from tolerance because the solver status is still rendered as optimal and not infeasible. The confusion was caused because it still in the &lt;code&gt;log_infeasible_constraints&lt;/code&gt; , prints the constraint. Something to take note of.&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2020-10-13T13:10:09.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5028" PostTypeId="1" CreationDate="2020-10-14T07:43:04.583" Score="4" ViewCount="269" Body="&lt;p&gt;I want to know about the number of variables and constraints of this formulation (exp: &lt;span class=&quot;math-container&quot;&gt;$o(n)$&lt;/span&gt; variables and constraints or &lt;span class=&quot;math-container&quot;&gt;$o(n^2)$&lt;/span&gt; ....).&lt;/p&gt;&#xA;&lt;p&gt;Is the number of variables &lt;span class=&quot;math-container&quot;&gt;$\mathcal O(n^3)$&lt;/span&gt; because we have three index variables with &lt;span class=&quot;math-container&quot;&gt;$N\times N\times N$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;How can I compute the complexity of the constraints step by step? I would be grateful if you have any other examples or references explaining this question.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/JHaNw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JHaNw.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4273" LastEditorUserId="123" LastEditDate="2020-10-14T07:49:42.093" LastActivityDate="2020-10-16T13:48:56.357" Title="How to determine the size of a model?" Tags="|optimization|modeling|integer-programming|computational-complexity|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5029" PostTypeId="2" ParentId="5028" CreationDate="2020-10-14T08:05:36.037" Score="5" Body="&lt;p&gt;You are correct, you have to look at the variables' ranges.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt; is defined &lt;span class=&quot;math-container&quot;&gt;$\forall t \in T$&lt;/span&gt;, so you have &lt;span class=&quot;math-container&quot;&gt;$|T| \in O(|T|)$&lt;/span&gt; such variables;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_i^k$&lt;/span&gt; is defined &lt;span class=&quot;math-container&quot;&gt;$\forall i \in [1,n], \; \forall k \in [1,n]$&lt;/span&gt;, so you have &lt;span class=&quot;math-container&quot;&gt;$n^2 \in O(n^2)$&lt;/span&gt; such variables;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}^k$&lt;/span&gt; is defined &lt;span class=&quot;math-container&quot;&gt;$\forall (i,j) \in [1,n]\times [1,n], i &amp;lt; j, \; \forall k \in [1,n]$&lt;/span&gt;, so you have &lt;span class=&quot;math-container&quot;&gt;$\frac{n(n-1)}{2}n \in O(n^3)$&lt;/span&gt; such variables;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So you end up with a total of &lt;span class=&quot;math-container&quot;&gt;$O(|T|)+ O(n^2) + O(n^3) = O(|T|)+ O(n^3)$&lt;/span&gt; variables.&lt;/p&gt;&#xA;&lt;p&gt;Likewise for constraints: you can see that you have &lt;span class=&quot;math-container&quot;&gt;$O(n^3)$&lt;/span&gt; of them.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-10-14T15:10:55.177" LastActivityDate="2020-10-14T15:10:55.177" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="5030" PostTypeId="1" AcceptedAnswerId="5032" CreationDate="2020-10-14T13:24:44.733" Score="4" ViewCount="415" Body="&lt;p&gt;In linear programming for an optimal primal degenerate solution the values of the dual variables are in general not identical with the corresponding shadow prices. Several proposals on how to find the &amp;quot;true&amp;quot; shadow prices have been made and terms like &amp;quot;two-sided-shadow prices&amp;quot; (one for decrease of the capacity of the relevant constraint and one for increase) have been coined (Gal 1986).&lt;/p&gt;&#xA;&lt;p&gt;The case of an optimal basic solution which is primal degenerated occurs frequently in practice (Pan 1998).&lt;/p&gt;&#xA;&lt;p&gt;Not the question is how can I get the &amp;quot;true&amp;quot; shadow prices?&lt;/p&gt;&#xA;&lt;p&gt;All approaches that I have found so far require modification of the LP and therefore some kind of resolving. To me this does not seem feasible for large real world problems.&lt;/p&gt;&#xA;&lt;p&gt;This leads to three questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Why is this not a larger problem in the industry or why do commercial solver not address this by providing the functionality to determine the &amp;quot;true&amp;quot; shadow prices in case of degeneracy (even if it is a performance trade off)?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What steps can I take to still use shadow prices? One Option is the reduction/exclusion of redundant constraints but I am not sure if this is always possible in larger problems.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Degeneracy does not falsify all shadow prices (at least that is my experience so far). Is there a way to determine which shadow prices are falsified due to degeneracy and which aren't? Maybe by identifying the responsible basic variables (the ones that take 0 value)?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4128" LastEditorUserId="491" LastEditDate="2020-10-15T15:38:11.120" LastActivityDate="2020-10-15T15:38:11.120" Title="Derive &quot;true&quot; shadow price for degenerated LPs using commercial solvers (e.g. Gurobi)" Tags="|linear-programming|gurobi|duality|dual|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5031" PostTypeId="1" AcceptedAnswerId="5033" CreationDate="2020-10-14T19:35:11.460" Score="2" ViewCount="218" Body="&lt;p&gt;I have a modified assignment problem for which I'm having difficulty formulating the constraints mathematically.&lt;/p&gt;&#xA;&lt;p&gt;I have a set of workers and a set of tasks which should be completed in the &lt;strong&gt;minimum time possible&lt;/strong&gt;. Each worker is unique and will take a different amount of time to do each task than the other workers. Some workers cannot do certain tasks, but each task can be completed by at least one worker. Additionally, there is the constraint that some tasks have &amp;quot;prerequisite&amp;quot; tasks which must be completed before that task can start.&lt;/p&gt;&#xA;&lt;p&gt;How could I formulate this problem and its constraints efficiently/mathematically? It seems reasonable to make the decision variable a binary vector of length &lt;span class=&quot;math-container&quot;&gt;$WT$&lt;/span&gt; if there are &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; workers and &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; tasks. Then in the first &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; variables, only one of them can be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and the rest &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, meaning that the first task is assigned to a particular worker. But mainly I'm having trouble incorporating the &amp;quot;prerequisite&amp;quot; constraints on tasks, because they are affected by which prerequisite is assigned to which worker, and how long it will take the worker to complete the prerequisite.&lt;/p&gt;&#xA;" OwnerUserId="4274" LastActivityDate="2020-10-14T20:13:35.667" Title="MIP for assigning tasks with prerequisite tasks" Tags="|optimization|mixed-integer-programming|scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5032" PostTypeId="2" ParentId="5030" CreationDate="2020-10-14T20:09:27.097" Score="5" Body="&lt;p&gt;I find the phrase &amp;quot;true shadow prices&amp;quot; misleading, and the use of &amp;quot;falsified&amp;quot; even more so, since the shadow prices any reputable solver returns are valid shadow prices ... possibly only in one direction, or even for a zero step size in either direction, when degeneracy occurs, but still correct.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I can't say why it's &amp;quot;not a larger problem in the industry&amp;quot;, but as to why solvers do not provide mechanisms to reveal all shadow prices, I suspect it is because the results would be hard to present in an interpretable manner. If degeneracy only affects one shadow price, that's easy, but when a basic feasible solution involves multiple sources of degeneracy, you get into a combinatorial mess (&amp;quot;if you increase this RHS and that RHS but decrease this other RHS, then these are the relevant shadow prices&amp;quot;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can answer specific questions along the lines of &amp;quot;what is the marginal impact of increasing this RHS?&amp;quot; by combining shadow prices with sensitivity results, which every solver I've used provide. The sensitivity output tells you how much you can increase (or decrease) any RHS in isolation without making the current basic solution infeasible or suboptimal (forcing a pivot). If you are changing one RHS, as long as you stay in this range, the shadow price is valid. If you need to know what the shadow price is outside the range, you have to perturb the constraint and update the solution. (Fortunately, with dual simplex this is usually not horribly expensive.) If you are changing multiple constraints, there is a slightly conservative result you can use: express each change as a fraction of the allowable change in that direction according to the sensitivity info, and if the fractions sum to at most 1, all the shadow prices will be valid over that change.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the sensitivity information for a constraint has nonzero change limits in both directions, the shadow price is valid for small perturbations in either direction. If it allows a nonzero change in one direction but a zero change in the other, the shadow price is valid in the first direction but may be invalid in the second one. If both change limits are zero, don't trust the shadow price for anything.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-10-14T20:09:27.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5033" PostTypeId="2" ParentId="5031" CreationDate="2020-10-14T20:13:35.667" Score="3" Body="&lt;p&gt;Without going into a ton of detail, the usual approach is to include a variable for the start time of each task, and a variable for the end time of each task. (Your binary assignment variables are also included.) Your objective (known as the &lt;em&gt;makespan&lt;/em&gt;) is the maximum of the task end times. The end time for a task is the start time plus the processing time (which in your case is contingent on the assigned worker). Precedence constraints are simply (end time of predecessor) &amp;lt;= (start time of successor).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-10-14T20:13:35.667" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5034" PostTypeId="2" ParentId="709" CreationDate="2020-10-14T20:22:30.587" Score="-4" Body="&lt;p&gt;&lt;strong&gt;Yes, it is !! Especially that there is no other choice for solving such problems.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I suggest looking at the following new paper:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Nidhal Kamel Taha El-Omari, “Sea Lion Optimization Algorithm for Solving the Maximum Flow Problem”, International Journal of Computer Science and Network Security (IJCSNS), e-ISSN: 1738-7906, DOI: 10.22937/IJCSNS.2020.20.08.5, 20(8):30-68, 2020.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can also find this paper in the following address:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.researchgate.net/publication/344324283_Sea_Lion_Optimization_Algorithm_for_Solving_the_Maximum_Flow_Problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.researchgate.net/publication/344324283_Sea_Lion_Optimization_Algorithm_for_Solving_the_Maximum_Flow_Problem&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4275" LastActivityDate="2020-10-14T20:22:30.587" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5035" PostTypeId="2" ParentId="4170" CreationDate="2020-10-14T20:48:16.913" Score="9" Body="&lt;p&gt;MATLAB is a language built on top of a library.&#xA;Python (with NumPy &amp;amp; numba) is a language with a library built under it.&lt;/p&gt;&#xA;&lt;p&gt;Neither is ideal. Like all languages, both have a few quirks, due to their history.&lt;/p&gt;&#xA;&lt;p&gt;My suggestion: &lt;strong&gt;Door Number 3, &lt;em&gt;Julia&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In either case (MATLAB, Python, Julia), you should ask yourself:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is your immediate goal to master the &lt;em&gt;math&lt;/em&gt;, or to master &lt;em&gt;how to program&lt;/em&gt; it?&lt;/li&gt;&#xA;&lt;li&gt;Is your long-term career goal academia, or industry?&lt;/li&gt;&#xA;&lt;li&gt;Is it important to you that other people can run your code (e.g. github repo)?&lt;/li&gt;&#xA;&lt;li&gt;Is your code all short, or might it grow into a large (many 1000-line, 100's of functions) code?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;If your answers are: 1: &lt;em&gt;math&lt;/em&gt;, 2: &lt;em&gt;academia&lt;/em&gt;, 3: &lt;em&gt;no&lt;/em&gt;, 4: &lt;em&gt;all short&lt;/em&gt;, then MATLAB is fine. It is an excellent tool. I love it for doing something fast and not fussing with things; it's an industry standard in DSP and radar and other problems that rely very heavily on linear algebra. There is a lot of code written in it; it will be around for a long time to come.&lt;/p&gt;&#xA;&lt;p&gt;Nevertheless, if those are not your answers, then between the two, I definitely suggest Python over MATLAB. You will become a much better programmer, and your job prospects will be much better, too. If your code gets long, beware that managing a large (many 1000-lines) MATLAB code is a nightmare IMO (namespaces, anyone?). If you find you have to use MATLAB at some later date, it will be easy. Conversely, if you learn MATLAB and later on find you need to learn Python + NumPy + numba, then you will probably find this very difficult.&lt;/p&gt;&#xA;&lt;p&gt;This is all the more true if we are talking about optimization, which is at least tangential to machine learning (ML). MATLAB is trying to compete in this space, but if you look online for job ads, they are almost all asking for Python, not MATLAB. In fact, in ML, you will find (in my experience) more job ads asking for &lt;em&gt;Julia&lt;/em&gt; than for MATLAB.&lt;/p&gt;&#xA;&lt;p&gt;But again (and yes it is just my personal opinion), I would suggest you take a look at Julia. I have not been as excited about a language after trying Julia since.... well, since I started learning Python 18 years ago. I use all three at work, and Julia is my first choice most of the time; I think the language is truly going places. But, I'm a risk-taker. It's not the safe move. &lt;strong&gt;If you want safe, the safe move is Python.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt;Disclosure: I have no interests, financial or otherwise, in MATLAB, Python, or Julia, other than my own experience using them for work/research.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="4276" LastEditorUserId="491" LastEditDate="2021-01-26T22:56:41.703" LastActivityDate="2021-01-26T22:56:41.703" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5036" PostTypeId="2" ParentId="709" CreationDate="2020-10-15T07:07:55.117" Score="6" Body="&lt;p&gt;Heuristics are useful to solve continuous optimization problems, in particular:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Large-scale problems, whatever their nature. Because even if the problem has nice properties (&lt;a href=&quot;https://en.wikipedia.org/wiki/Convex_function&quot; rel=&quot;nofollow noreferrer&quot;&gt;convexity&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Smoothness&quot; rel=&quot;nofollow noreferrer&quot;&gt;smoothness&lt;/a&gt;), its large scale may prevent the nice algorithms (for example, &lt;a href=&quot;https://en.wikipedia.org/wiki/Augmented_Lagrangian_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Augmented Lagrangian&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/Interior-point_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Interior Point&lt;/a&gt; methods) to converge to quality solutions in reasonable running times.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Nonconvex problems. Because the nice algorithms evoked above generally fail to converge to global optima.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Nonsmooth problems. When computing &lt;a href=&quot;https://en.wikipedia.org/wiki/Derivative&quot; rel=&quot;nofollow noreferrer&quot;&gt;derivatives&lt;/a&gt; is hard or time-consuming. For example, in the presence of black-box functions related to numerical simulations.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;We use the term &amp;quot;heuristics&amp;quot; and not &amp;quot;metaheuristics&amp;quot; on purpose. At Hexaly, we don't like the prefix &amp;quot;meta&amp;quot; because it only refers in the mind of many to the zoo of search strategies employed to escape local optima and then to the major scientific abuse that resulted (see &lt;a href=&quot;https://www.cs.ubc.ca/%7Ehutter/EARG.shtml/stack/2013_Sorensen_MetaheuristicsTheMetaphorExposed.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kenneth Sörensen's saving paper&lt;/a&gt; about this). The &amp;quot;meta&amp;quot; ingredients - whose goal is to escape local optima when searching for solutions to discrete or nonconvex continuous problems - are not the hard part of the job when implementing heuristics to solve practical problems. In many cases, they are even not critical to getting high-quality solutions quickly. For example, have a look at &lt;a href=&quot;https://www.localsolver.com/fgardi/downloads/Estellon-Gardi-Nouioua_EJOR_06.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;, &lt;a href=&quot;https://www.localsolver.com/fgardi/downloads/Estellon-Gardi-Nouioua_SLS_09_Paper.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;, &lt;a href=&quot;https://www.localsolver.com/fgardi/downloads/Gardi-Nouioua_EDF_EVOCOP_2011.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;, or &lt;a href=&quot;https://www.localsolver.com/fgardi/downloads/Benoist-Estellon-Gardi-Jeanjean_TRSC_09.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;that&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Local_search_%28optimization%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;Local/neighborhood search&lt;/a&gt; methods for combinatorial optimization have their counterpart in continuous optimization. They are called &lt;a href=&quot;https://en.wikipedia.org/wiki/Pattern_search_(optimization)&quot; rel=&quot;nofollow noreferrer&quot;&gt;direct or random search&lt;/a&gt; methods. For example, the &lt;a href=&quot;https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nelder-Mead&lt;/a&gt; method is one of them. Like local search methods in combinatorial optimization, they are very useful in practice but suffer from a lack of understanding in theory. Mostly because understanding requires complex maths like &lt;a href=&quot;https://en.wikipedia.org/wiki/Smoothed_analysis&quot; rel=&quot;nofollow noreferrer&quot;&gt;smooth complexity analysis&lt;/a&gt; but also because they were discredited for years in academia, being considered as &amp;quot;cooking&amp;quot; (see &lt;a href=&quot;http://emis.maths.adelaide.edu.au/journals/DMJDMV/vol-ismp/42_wright-margaret.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Margaret H. Wright's nice paper&lt;/a&gt; on this).&lt;/p&gt;&#xA;&lt;p&gt;At Hexaly, we work at integrating the &amp;quot;dirty&amp;quot; (heuristic) ones together with the &amp;quot;nice&amp;quot; (exact) ones for combinatorial and continuous optimization. We work to offer our users the best of both worlds because we know this is critical to getting the best answers in practice.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2023-12-05T00:00:31.280" LastActivityDate="2023-12-05T00:00:31.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5039" PostTypeId="1" AcceptedAnswerId="5041" CreationDate="2020-10-15T13:30:53.927" Score="7" ViewCount="347" Body="&lt;p&gt;I'm using &lt;code&gt;cvxpy&lt;/code&gt; to model a problem. Inside a very large and complex LP, I create two continuous, affine (unconstrained) expressions: &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. Due to how they are created, I know that &lt;span class=&quot;math-container&quot;&gt;$0\lt x \lt y \leq U$&lt;/span&gt;. Obviously: &lt;span class=&quot;math-container&quot;&gt;$x/y \lt 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In my LP &lt;em&gt;objective&lt;/em&gt;, how do I &lt;em&gt;&lt;strong&gt;maximize&lt;/strong&gt;&lt;/em&gt; the ratio &lt;span class=&quot;math-container&quot;&gt;$x/y$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Things I tried:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Maximizing &lt;code&gt;x*cp.inv_pos(y)&lt;/code&gt; states my problem is non DCP (also if I try to minimize the inverse)&lt;/li&gt;&#xA;&lt;li&gt;I found various LP formulations for maximizing ratios (e.g. &lt;a href=&quot;http://lpsolve.sourceforge.net/5.5/ratio.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; or &lt;a href=&quot;https://download.aimms.com/aimms/download/manuals/AIMMS3OM_LinearProgrammingTricks.pdf#page=8&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;) but these requires rewriting the &lt;em&gt;constraints&lt;/em&gt; on all the terms in the expressions for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; - I have no idea how to do that with &lt;code&gt;cvxpy&lt;/code&gt;.&lt;br /&gt;&#xA;If this is the way to go then an example would be very helpful!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3903" LastEditorUserId="3903" LastEditDate="2021-02-09T07:44:23.360" LastActivityDate="2021-02-09T07:44:23.360" Title="Maximizing a Ratio/Percent" Tags="|linear-programming|linearization|reformulation-linearization|cvxpy|disciplined-quasiconvex-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5040" PostTypeId="1" AcceptedAnswerId="5042" CreationDate="2020-10-15T16:52:46.177" Score="7" ViewCount="275" Body="&lt;p&gt;I have a nonlinear problem as follows: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_{k=1}^{K}\left|y_k - \sum_{i=1}^{N} \frac{e^{x_{k}^{i}}}{\sum_{j=1}^{K} e^{x^{i}_{j}}}\right|\\\text{s.t.}&amp;amp;\quad x^i_{j} \ge 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Essentially, there are &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; buckets with a desired value of &lt;span class=&quot;math-container&quot;&gt;$y_k$&lt;/span&gt; for each. There are &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; agents, each of which makes a choice based on a multinomial logit function.&lt;/p&gt;&#xA;&lt;p&gt;I think I can get rid of the absolute value using the common trick: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad \sum_{k=1}^{K}t_k\\\text{s.t.}&amp;amp;\quad t_k \ge y_k - \sum_{i=1}^{N} \frac{e^{x_{k}^{i}}}{\sum_{j=1}^{K} e^{x^{i}_{j}}}\\&amp;amp;\quad t_k\ge-\left(y_k - \sum_{i=1}^{N} \frac{e^{x_{k}^{i}}}{\sum_{j=1}^{K} e^{x^{i}_{j}}}\right)\end{align}&lt;/span&gt; but I don't know how to proceed from here. I have 2 questions.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is it possible to linearize the fractional exp and reduce the problem to a linear program?&lt;/li&gt;&#xA;&lt;li&gt;If not, how should I try to solve this problem? Is there a class of models that encompass this?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4251" LastEditorUserId="500" LastEditDate="2020-10-16T13:53:49.123" LastActivityDate="2020-10-16T13:53:49.123" Title="Linearizing a program with multinomial logit in the objective" Tags="|linearization|nonlinear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5041" PostTypeId="2" ParentId="5039" CreationDate="2020-10-15T18:52:14.113" Score="4" Body="&lt;p&gt;CVXPY makes this easy to do, using its disciplined quasiconvex programming (DQCP) capability.&lt;/p&gt;&#xA;&lt;p&gt;An example is provided at &lt;a href=&quot;https://www.cvxpy.org/examples/dqcp/concave_fractional_function.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.cvxpy.org/examples/dqcp/concave_fractional_function.html&lt;/a&gt; .  Fractional Linear programming, as you have, is a simple special case of this.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-10-15T18:52:14.113" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5042" PostTypeId="2" ParentId="5040" CreationDate="2020-10-15T19:10:21.813" Score="7" Body="&lt;p&gt;This is going to be a bit involved, so you might want to load up on caffeine now.&#xA;The first step is a change of variables. Let &lt;span class=&quot;math-container&quot;&gt;$$z_{k}^{i}=\frac{e^{x_{k}^{i}}}{\sum_{j=1}^{K}e^{x_{j}^{i}}}\ge0.$$&lt;/span&gt;The objective function reduces to &lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{k=1}^{K}|y_{k}-\sum_{i=1}^{N}z_{k}^{i}|$$&lt;/span&gt;(which you can linearize) subject to the constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{k=1}^{K}z_{k}^{i}=1\quad\forall i=1,\dots,N$$&lt;/span&gt;plus nonnegativity of the &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; variables. This should be easy to solve for &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Before attempting to recover &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, we need to note a bit of invariance that works in our favor. Let &lt;span class=&quot;math-container&quot;&gt;$\lambda_i, i=1,\dots,N$&lt;/span&gt; be arbitrary constants. Suppose that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a particular solution, and define &lt;span class=&quot;math-container&quot;&gt;$$\hat{x}_{k}^{i}=x_{k}^{i}+\lambda^{i}\quad\forall i,k.$$&lt;/span&gt; Then &lt;span class=&quot;math-container&quot;&gt;$$\hat{z}_{k}^{i}=\frac{e^{\lambda^{i}}e^{x_{k}^{i}}}{\sum_{j=1}^{K}e^{\lambda^{i}}e^{x_{j}^{i}}}=z_{k}^{i}\quad\forall i,k.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now let &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; be an optimal solution to the transformed problem. For fixed &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$$\frac{z_{k}^{i}}{z_{j}^{i}}=\frac{e^{x_{k}^{i}}}{e^{x_{j}^{i}}}=e^{x_{k}^{i}-x_{j}^{i}}$$&lt;/span&gt;and so &lt;span class=&quot;math-container&quot;&gt;$$\log\left(\frac{z_{k}^{i}}{z_{j}^{i}}\right)=x_{k}^{i}-x_{j}^{i}.$$&lt;/span&gt;This will let us recover appropriate &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; values. For each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$j_0=\textrm{argmin}_j \lbrace z^i_j \rbrace$&lt;/span&gt;. Arbitrarily set &lt;span class=&quot;math-container&quot;&gt;$x^i_{j_0}=0$&lt;/span&gt;, resulting in &lt;span class=&quot;math-container&quot;&gt;$$x^i_k=\log\left(\frac{z_{k}^{i}}{z_{j_0}^{i}}\right)\ge 0\quad \forall k\neq j_0.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: There is one serious flaw in this solution. If we constrain &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to be nonnegative, the LP solution may set &lt;span class=&quot;math-container&quot;&gt;$z^i_k=0$&lt;/span&gt; for some index combinations, in which case the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; values cannot be recovered. (My recovery method would lead to division by 0, and if we go back to the definition of &lt;span class=&quot;math-container&quot;&gt;$z^i_k$&lt;/span&gt; in terms of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, we see that no &lt;span class=&quot;math-container&quot;&gt;$z^i_k$&lt;/span&gt; can actually be 0 (other than approximately, if some &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; values are very large). So we need to set a nonzero lower bound for &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-10-16T03:21:06.167" LastActivityDate="2020-10-16T03:21:06.167" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="5043" PostTypeId="2" ParentId="3652" CreationDate="2020-10-15T19:18:49.903" Score="1" Body="&lt;p&gt;&lt;code&gt;1.#J&lt;/code&gt; in C++ is the output obtained when printing a formatted double equal to infinity (&lt;code&gt;1.#INF&lt;/code&gt;). See &lt;a href=&quot;https://stackoverflow.com/questions/840081/what-does-floating-point-error-1-j-mean&quot;&gt;this related stackoverflow question&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The CBC gap is computed this way in &lt;a href=&quot;https://github.com/coin-or/Cbc/blob/master/src/CbcSolver.cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;CbcSolver.cpp&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if (babModel_-&amp;gt;bestSolution()) {&#xA;  sprintf(generalPrint + strlen(generalPrint),&#xA;    &amp;quot;Gap:                            %.2f\n&amp;quot;,&#xA;    (babModel_-&amp;gt;getObjValue() - babModel_-&amp;gt;getBestPossibleObjValue()) / fabs(babModel_-&amp;gt;getBestPossibleObjValue()));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If &lt;code&gt;babModel_-&amp;gt;getBestPossibleObjValue()&lt;/code&gt; is equal to &lt;code&gt;0.0&lt;/code&gt;, you will obtain a gap of &lt;code&gt;1.#INF&lt;/code&gt; which will then be formatted to &lt;code&gt;1.#J&lt;/code&gt;. This is also what other solvers do, see for example &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/mipgap.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi MIPGap documentation&lt;/a&gt; which returns infinity in such case. Note that this matches your outputted lower bound of &lt;code&gt;0.000&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As for pyomo, returning a gap of 0 could be wrong in most cases, that is, unless the best solution is also 0. Returning some form of infinity, such as &lt;code&gt;numpy.inf&lt;/code&gt;, could be the correct solution. Although I didn't check if pyomo would handle that gracefully. Looking quickly trough the other pyomo solver plugins, I don't see any handling of a MIP gap being anything other than a float, which seems problematic.&lt;/p&gt;&#xA;" OwnerUserId="210" LastEditorUserId="210" LastEditDate="2020-10-15T19:28:25.310" LastActivityDate="2020-10-15T19:28:25.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5044" PostTypeId="2" ParentId="3762" CreationDate="2020-10-16T08:37:36.310" Score="5" Body="&lt;p&gt;A good starting point is to look at the following Wikipedia resources:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Protein_design&quot; rel=&quot;noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Protein_design&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikibooks.org/wiki/Structural_Biochemistry/Proteins/Protein_Folding_Problem&quot; rel=&quot;noreferrer&quot;&gt;https://en.wikibooks.org/wiki/Structural_Biochemistry/Proteins/Protein_Folding_Problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The biochemistry problematic is described and the related mathematical optimization problems are discussed. Now, the state of the art on this topic can be found in &lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4939-6637-0&quot; rel=&quot;noreferrer&quot;&gt;this book&lt;/a&gt;. Note that an &lt;a href=&quot;https://or.stackexchange.com/questions/3644/are-there-any-covid-19-coronavirus-related-optimization-problems-with-input-da?noredirect=1&amp;amp;lq=1&quot;&gt;interesting discussion&lt;/a&gt; related to the topic can also be found on this forum.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-10-16T08:37:36.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5045" PostTypeId="2" ParentId="3762" CreationDate="2020-10-16T12:24:24.273" Score="3" Body="&lt;p&gt;Optimisation technology is practically irrelevant for protein folding because of the garbage-in garbage-out rule.&lt;/p&gt;&#xA;&lt;p&gt;Our models for molecular interactions are simply so bad that solving Gibbs free energy models is pointless in practice (from an optimisation point of view).&lt;/p&gt;&#xA;&lt;p&gt;Just to give you a bit more context about the state of the art, people are still struggling to model water properly (let alone very complex structures like proteins).&lt;/p&gt;&#xA;&lt;p&gt;The underlying reason is that these models are only approximations to the interactions encoded into the Schroedinger equation, but the resulting modelling error makes de Novo based molecular design kind of pointless.&lt;/p&gt;&#xA;&lt;p&gt;Until we can actually solve the Schroedinger equation at large scale (or somehow devise simple models that approximate it extremely well), discovery of new molecular compounds will be driven by experiments and empirical knowledge.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-10-16T15:47:45.680" LastActivityDate="2020-10-16T15:47:45.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5047" PostTypeId="2" ParentId="3762" CreationDate="2020-10-16T21:39:01.987" Score="2" Body="&lt;p&gt;Protein folding calculations have been turned into &lt;a href=&quot;https://or.stackexchange.com/q/828/727&quot;&gt;QUBO&lt;/a&gt; (quadratic unconstrained binary optimization) in &lt;a href=&quot;https://www.nature.com/articles/srep00571&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; where the goal was to run the calculations on a quantum annealer (in OR we are familiar with &amp;quot;simulated annealing&amp;quot;, so think of quantum annealing as &amp;quot;real annealing&amp;quot; or &amp;quot;not just simulated&amp;quot; annealing).&lt;/p&gt;&#xA;&lt;p&gt;The &amp;quot;objective function&amp;quot; for the optimization is in the first equation of the above paper: &lt;span class=&quot;math-container&quot;&gt;$$E({\bf s})=\sum h_is_i+\sum J_{ij}s_is_j\tag1$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$s_i\in\{0,1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J_{ij}$&lt;/span&gt; are just real numbers: Basically you are just trying to minimize a quadratic function of binary variables, to get the lowest energy configuration of the protein.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately there's better ways of solving the protein folding problem using &lt;a href=&quot;https://mattermodeling.stackexchange.com/questions/tagged/molecular-dynamics&quot;&gt;molecular dynamics&lt;/a&gt; and other types of physics/chemistry simulations, than to convert the problem into QUBO and then solve the QUBO. This seems to be the case with all QUBO problems, as &lt;a href=&quot;https://or.stackexchange.com/q/1380/727&quot;&gt;I have not yet found a case&lt;/a&gt; where converting problem &amp;quot;A&amp;quot; to QUBO form, then solving the QUBO, is better than just solving &amp;quot;A&amp;quot; in its original form without &amp;quot;forcing&amp;quot; yourself to use OR techniques via QUBO.&lt;/p&gt;&#xA;" OwnerUserId="727" LastEditorUserId="123" LastEditDate="2020-10-17T09:19:08.740" LastActivityDate="2020-10-17T09:19:08.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5048" PostTypeId="2" ParentId="1380" CreationDate="2020-10-17T09:05:49.683" Score="7" Body="&lt;p&gt;A recent paper by Quantum Computing Inc people is showing experiments on graph partitioning where QUBO approaches lead to better results than the state of the art.&lt;/p&gt;&#xA;&lt;p&gt;Here is the paper: &lt;a href=&quot;https://arxiv.org/pdf/2006.15067.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://arxiv.org/pdf/2006.15067.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Nevertheless, one can argue that this graph partitioning problem is not in essence what we can call a real-world OR problem. But it seems difficult to find publications where real-world optimization problems (that is, with rich, dirty features modeled) are tackled through several optimization techniques fairly compared.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-10-17T09:05:49.683" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5049" PostTypeId="2" ParentId="4540" CreationDate="2020-10-17T15:31:22.550" Score="6" Body="&lt;p&gt;You obtain all vertices of a polytope using &lt;a href=&quot;https://polymake.org/doku.php/user_guide/tutorials/latest/apps_polytope#v-description&quot; rel=&quot;noreferrer&quot;&gt;polymake&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can directly try the &lt;a href=&quot;https://polymake.org/doku.php/boxdoc&quot; rel=&quot;noreferrer&quot;&gt;online version&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4300" LastEditorUserId="4300" LastEditDate="2020-10-17T15:39:40.607" LastActivityDate="2020-10-17T15:39:40.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5050" PostTypeId="1" CreationDate="2020-10-17T17:04:32.840" Score="2" ViewCount="91" Body="&lt;p&gt;i have two models that address the same problem.&lt;br/&gt;&lt;br/&gt;&#xA;the first one is :&lt;br/&gt;&lt;br/&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/CVFYI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CVFYI.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;the second one is:&lt;br/&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/WfHSh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WfHSh.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;for different instances for the same size (n=30) i found the following results ( the first column on the left is for the first model , the second column is for the second model).&lt;br/&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/UTJGg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UTJGg.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It seems illogical that a model with o(n3) variables and constraints consumes less time than a model with o(n2) variables and constraints. Could these results be explained ? or the use of multiple binary variables instead of of low variables could reduce time?&lt;/p&gt;&#xA;" OwnerUserId="4273" LastActivityDate="2020-10-17T20:36:16.177" Title="confusing results of two models with different complexity" Tags="|optimization|mixed-integer-programming|integer-programming|computational-complexity|computational-experiments|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5051" PostTypeId="2" ParentId="5050" CreationDate="2020-10-17T20:36:16.177" Score="3" Body="&lt;p&gt;There are a number of possible explanations (not mutually exclusive). The larger model might have a tighter continuous relaxation. (You can test that by relaxing the integrality restrictions and solving both LPs.) Assuming you are using a solver that has a presolve stage, there may be something in the first model that allows the presolver to tighten things in a way it cannot do in the second model. The solver may generate cuts that are more productive in the first model than in the second (or not available / not relevant in the second). Also, there may be an element of luck involved (particularly if your time comparison is based on a single problem instance).&lt;/p&gt;&#xA;&lt;p&gt;Integer programs are perverse beasts.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-10-17T20:36:16.177" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5052" PostTypeId="1" CreationDate="2020-10-17T21:31:37.820" Score="3" ViewCount="95" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$ x \in \mathbb{R}^n_+$&lt;/span&gt; be a variable such that &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n x_i = 1$&lt;/span&gt;. In other words, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is in a probability simplex.  I am working on barrier-like functions in nonconvex optimization over such &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$f(x) = ||(DR) \cdot(x - \frac{1}{n} \mathbf{1})||_2^2$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is a diagonal matrix (off-diagonals are zero), and &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; is a rotation matrix (non-zero). If we maximize &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, then the maximum value is at an extreme point (convex maximization over a bounded space). So we will have &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt; for one &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_j = 0$&lt;/span&gt; for all other &lt;span class=&quot;math-container&quot;&gt;$j \neq i$&lt;/span&gt;. But, if we minimize &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;, then we get &lt;span class=&quot;math-container&quot;&gt;$x = \frac{1}{n}\mathbf{1}$&lt;/span&gt;, as a norm-squared is non-negative, and this achieves &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, let &lt;span class=&quot;math-container&quot;&gt;$g(x) = \sum_{i=1}^n \ln(x_i)$&lt;/span&gt;. Notice that if we maximize &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, then the solution is &lt;span class=&quot;math-container&quot;&gt;$x = \frac{1}{n}\mathbf{1}$&lt;/span&gt;, and if we minimize it, the solution is at an extreme point as &lt;span class=&quot;math-container&quot;&gt;$\ln(0) = -\infty$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So, instead of maximizing &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;, if we maximize &lt;span class=&quot;math-container&quot;&gt;$f(x) + g(x)$&lt;/span&gt;, then thanks to &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, we will not have an extreme point solution, and the solution will be slightly going towards the middle of the simplex.&lt;/p&gt;&#xA;&lt;p&gt;Now my question follows: If I don't select &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; appropriately, then the solution tends to be either &lt;strong&gt;very&lt;/strong&gt; close to the extreme point of the simplex, or directly has &lt;span class=&quot;math-container&quot;&gt;$x= \frac{1}{n}\mathbf{1}$&lt;/span&gt; (i.e., same solution if we didn't have &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;). So I am looking for a way to select &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; in a clever way such that the solution is not straightforward. In other words, I don't want the sum-log term to dominate the solution, but also don't want to have a solution that is very close to the extreme points.&lt;/p&gt;&#xA;&lt;p&gt;Is there any research about selecting such &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; in a good way? I believe rotation matrix is very important here.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2020-10-18T17:00:12.860" LastActivityDate="2020-10-18T17:00:12.860" Title="Appropriate Rotation Matrix in Nonconvex Optimization with Barrier" Tags="|nonconvex-programming|multi-objective-optimization|polyhedra|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5053" PostTypeId="1" AcceptedAnswerId="5054" CreationDate="2020-10-17T23:17:59.587" Score="2" ViewCount="1875" Body="&lt;p&gt;Is there any systematic way to retrieve some information on the constraint that caused infeasibility in Or.Tools CP-SAT?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using System;&#xA;using Google.OrTools.Sat;&#xA;&#xA;public class InfeasibleCpModel&#xA;{&#xA;  static void Main()&#xA;  {&#xA;    CpModel _cpModel = new CpModel();&#xA;&#xA;    IntVar x = _cpModel.NewIntVar(0, 10, &amp;quot;x&amp;quot;);&#xA;    IntVar y = _cpModel.NewIntVar(0, 10, &amp;quot;y&amp;quot;);&#xA;    &#xA;    _cpModel.AddAllDifferent(new IntVar[]{x, y})&#xA;    _cpModel.Add(x == y);&#xA;    &#xA;    CpSolver solver = new CpSolver();&#xA;    CpSolverStatus status = solver.Solve(_cpModel);&#xA;    &#xA;    if (status == CpSolverStatus.Infeasible)&#xA;    {&#xA;        // Catch the constraint that did not meet the feasibility gap&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="765" LastEditorUserId="981" LastEditDate="2023-12-22T15:10:21.640" LastActivityDate="2023-12-22T15:10:21.640" Title="How to know which constraint in CP-SAT did not meet the feasibility gap" Tags="|constraint-programming|or-tools|cp-sat|irreducible-infeasible-subset|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5054" PostTypeId="2" ParentId="5053" CreationDate="2020-10-18T02:12:44.507" Score="4" Body="&lt;p&gt;Not yet, see &lt;a href=&quot;https://github.com/google/or-tools/issues/973&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/issues/973&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;For debugging I would recommend you to divide your constraints into groups so you can activate/deactivate some of them to pin down the infeasibility&lt;/p&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2020-10-19T08:30:32.657" LastActivityDate="2020-10-19T08:30:32.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5055" PostTypeId="1" CreationDate="2020-10-18T18:23:54.353" Score="0" ViewCount="147" Body="&lt;p&gt;Need help with the following exercise. I am unable to work out the objective function.&lt;/p&gt;&#xA;&lt;p&gt;After months of closure due to &lt;strong&gt;Covid-19&lt;/strong&gt;, a food court is preparing to&#xA;re-open for business. However, safe management measures need to be&#xA;implemented and one of these requires that there must be a distance&#xA;of at least &lt;strong&gt;Dmin = &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;&lt;/strong&gt; between any two tables occupied by customers.&#xA;The food court has a total of &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; tables and they may not meet this&#xA;requirement if all tables are occupied simultaneously. Furthermore,&#xA;the tables are fixed and cannot be moved, and so there is a need to&#xA;determine which of the &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; tables can be selected for use so that the&#xA;maximum number of tables are made available to customers at any&#xA;time without violating the requirement, while the rest of the tables&#xA;not selected will be marked with &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;s to indicate that they cannot be&#xA;used. The location of each of the &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; tables is known and specified by&#xA;its respective &lt;span class=&quot;math-container&quot;&gt;$(X_i, Y_i)$&lt;/span&gt; positional coordinates measured with respect to&#xA;some reference point, for &lt;span class=&quot;math-container&quot;&gt;$i = 1, 2,\ldots,12$&lt;/span&gt;, as tabulated below. Which&#xA;are the tables that should be selected for use? (It can be assumed that&#xA;all distances and coordinates are expressed in consistent units.)&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Table 1: &lt;span class=&quot;math-container&quot;&gt;$(X=3, Y=17)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Table 2: &lt;span class=&quot;math-container&quot;&gt;$(X=4, Y=8)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Table 3: &lt;span class=&quot;math-container&quot;&gt;$(X=5, Y=4)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Table 4: &lt;span class=&quot;math-container&quot;&gt;$(X=5, Y=14)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Table 5: &lt;span class=&quot;math-container&quot;&gt;$(X=7, Y=6)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Table 6: &lt;span class=&quot;math-container&quot;&gt;$(X=8, Y=12)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Table 7: &lt;span class=&quot;math-container&quot;&gt;$(X=13, Y=7)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Table 8: &lt;span class=&quot;math-container&quot;&gt;$(X=14, Y=5)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Table 9: &lt;span class=&quot;math-container&quot;&gt;$(X=16, Y=13)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Table 10: &lt;span class=&quot;math-container&quot;&gt;$(X=17, Y=4)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Table 11: &lt;span class=&quot;math-container&quot;&gt;$(X=17, Y=10)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Table 12: &lt;span class=&quot;math-container&quot;&gt;$(X=18, Y=15)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4303" LastEditorUserId="199" LastEditDate="2020-10-19T06:07:11.270" LastActivityDate="2020-10-19T06:07:11.270" Title="Help with excel solver" Tags="|modeling|solver|excel|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5056" PostTypeId="2" ParentId="5055" CreationDate="2020-10-18T20:37:44.767" Score="1" Body="&lt;p&gt;This is a &lt;em&gt;maximum independent set problem&lt;/em&gt; on a graph with 12 nodes, which you can solve with one binary variable &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; per node and one &amp;quot;conflict&amp;quot; constraint &lt;span class=&quot;math-container&quot;&gt;$z_i+z_j \le 1$&lt;/span&gt; per edge.  The objective is to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_i z_i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-10-19T00:29:01.383" LastActivityDate="2020-10-19T00:29:01.383" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5057" PostTypeId="1" AcceptedAnswerId="5058" CreationDate="2020-10-19T01:47:11.343" Score="2" ViewCount="632" Body="&lt;p&gt;I have a simple question regarding the divisibility in integer programming&lt;/p&gt;&#xA;&lt;p&gt;suppose the objective function is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{max}\quad x_1 + x_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the constraint is that the sum of &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; are divisible by either 5, 7 or 9&lt;/p&gt;&#xA;&lt;p&gt;I'm wondering how can I model the constraint of divisibility?&lt;/p&gt;&#xA;&lt;p&gt;The only solution I can think of is like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;max &#xA;x1+x2+ 0*x3&#xA;&#xA;&#xA;subject to &#xA;&#xA;y1+y2+y3 &amp;gt;= 0&#xA;&#xA;y1*(x1+x2) = 5*x3*y1&#xA;y2*(x1+x2) = 7*x3*y2&#xA;y3(x1+x2) = 9*x3*y3&#xA;&#xA;x1&amp;gt;=0,x2&amp;gt;=0,x3&amp;gt;=0&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is it correct to solve divisibility constraints like this?&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="4286" LastEditorUserId="500" LastEditDate="2020-10-19T03:13:32.590" LastActivityDate="2020-10-19T03:13:32.590" Title="Divisibility constraint in Integer programming" Tags="|optimization|modeling|integer-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5058" PostTypeId="2" ParentId="5057" CreationDate="2020-10-19T03:13:19.363" Score="5" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$x_1+x_2$&lt;/span&gt; is bounded above by some &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;; otherwise the problem is unbounded.  Let &lt;span class=&quot;math-container&quot;&gt;$D=\{5,7,9\}$&lt;/span&gt;, and for &lt;span class=&quot;math-container&quot;&gt;$d\in D$&lt;/span&gt;, introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$z_d$&lt;/span&gt; and nonnegative integer variable &lt;span class=&quot;math-container&quot;&gt;$w_d$&lt;/span&gt;.  You can enforce the desired behavior by imposing the following linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_1 + x_2 &amp;amp;= \sum_{d\in D} d\cdot w_d \\&#xA;d\cdot w_d &amp;amp;\le M\cdot z_d &amp;amp;&amp;amp;\text{for $d\in D$}\\&#xA;\sum_{d\in D} z_d &amp;amp;= 1&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-10-19T03:13:19.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5059" PostTypeId="1" CreationDate="2020-10-20T14:31:08.940" Score="2" ViewCount="110" Body="&lt;p&gt;Hell everyone I have been trying to read through this forum for the methodology to approach a graph/network problem. The idea is I have an undirected graph, and every node is capable of talking to any node it wants through any path. Give a set of source nodes and set of sink nodes, I need to find the minimum number of nodes to remove that will sever all source nodes from all sink nodes.&lt;/p&gt;&#xA;&lt;p&gt;I have been trying to read a lot on the Min Cut (s-t) max flow problem, but I can't seem to figure out how to apply it to a scenario with multiple sources / sinks.&lt;/p&gt;&#xA;&lt;p&gt;I have a set of MATLAB code below that creates a pseudo-random graph as an example. So I need to figure out which nodes to remove so green can not reach red.&lt;/p&gt;&#xA;&lt;p&gt;*Note that both red and green nodes are allowed to be transition nodes for other pathways as well.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MkaQM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MkaQM.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;close all;clearvars;clc&#xA;% Create an Example undirected/unweighted graph&#xA;nNodes = 15;   % number of nodes&#xA;pLink  = 0.08; % probabilitiy off link between to verticies&#xA;&#xA;adjMat = rand(nNodes) &amp;lt;= pLink;    % Create adjaceny matrix&#xA;adjMat(eye(nNodes)==1) = false;    % Remove any self loops or connetions&#xA;&#xA;adjMat = (adjMat + adjMat')/2;     % Make adjaceny matrix symetric&#xA;&#xA;&#xA;good_graph = all(sum(adjMat)&amp;gt;=1);  % Also to check all nodes are connected&#xA;&#xA;while ~good_graph %Loop until good graph&#xA;    adjMat = rand(nNodes) &amp;lt;= pLink;    % Create adjaceny matrix&#xA;    adjMat(eye(nNodes)==1) = false;    % Remove any self loops or connetions&#xA;    &#xA;    adjMat = (adjMat + adjMat')/2;     % Make adjaceny matrix symetric&#xA;    good_graph = all(sum(adjMat)&amp;gt;=1);  % Also to check all nodes are connected&#xA;end&#xA;&#xA;G = graph(adjMat); %Create Graph&#xA;&#xA;% Number of random source and sink nodes&#xA;nSource = 4;&#xA;nSink   = 2;&#xA;&#xA;nodeList   = 1:nNodes;&#xA;&#xA;SourceList = randperm(length(nodeList));&#xA;SourceList = SourceList(1:nSource);&#xA;&#xA;nodeList(any(nodeList == SourceList')) = []; %Remove source nodes&#xA;&#xA;SinkList   = randperm(length(nodeList));&#xA;SinkList   = nodeList(SinkList(1:nSink));&#xA;&#xA;%% Plot Graph&#xA;gg = plot(G,'Layout','layered'  ); % plot graph - Also to check all nodes are connected&#xA;&#xA;highlight(gg,SourceList,'NodeColor','g','MarkerSize',7);&#xA;highlight(gg,SinkList,'NodeColor','r','MarkerSize',7)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3486" LastActivityDate="2020-10-20T15:32:34.767" Title="Algorithm / Method for determining N nodes to disconnect group of nodes" Tags="|graphs|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5060" PostTypeId="2" ParentId="5059" CreationDate="2020-10-20T15:24:05.050" Score="5" Body="&lt;p&gt;Introduce a supersource node &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; that is adjacent to all sources and a supersink node &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; that is adjacent to all sinks, and then solve the minimum &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;-&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; node cut problem on the resulting graph.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-10-20T15:32:34.767" LastActivityDate="2020-10-20T15:32:34.767" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5061" PostTypeId="1" AcceptedAnswerId="5062" CreationDate="2020-10-20T15:26:13.197" Score="4" ViewCount="88" Body="&lt;p&gt;I am reading from &lt;em&gt;Nonlinear Programming&lt;/em&gt; by Bertsekas, and in the section on ADMM, he says:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Consider the problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{min} \sum _{i=1} ^ m f_i(x)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{s.t. }x \in \cap _{i = 1}^m X_i,$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f_i : \mathbb{R}^n \to \mathbb{R}$&lt;/span&gt; are convex functions and &lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt; are closed, convex sets with nonempty intersection. We can reformulate this as an equality constrained problem, by introducing additional artificial variables &lt;span class=&quot;math-container&quot;&gt;$z_i, i = 1,..., m$&lt;/span&gt; and the equality constraints &lt;span class=&quot;math-container&quot;&gt;$x = z_i$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{min} \sum _{i=1} ^ m f_i(z_i)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{s.t.} \hspace{0.3 cm} x = z_i, \hspace{0.6cm} z_i \in X_i,\hspace{0.6cm}  i = 1, ..., m$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I don't quite understand this transformation. I see that we have &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; different functions, and for each function &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; its input must come from a (possibly) different set &lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt;. That makes sense. But what does &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; mean in this second problem? My only idea is that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; doesn't really stand for anything; it is just there as a short way of saying &lt;span class=&quot;math-container&quot;&gt;$z_1 = z_2 = ... = z_m$&lt;/span&gt;. Is this correct?&lt;/p&gt;&#xA;&lt;p&gt;Thank you very much!&lt;/p&gt;&#xA;" OwnerUserId="3527" LastActivityDate="2020-10-20T15:38:33.343" Title="How do you turn an abstract set constraint into equality constraints?" Tags="|optimization|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5062" PostTypeId="2" ParentId="5061" CreationDate="2020-10-20T15:38:33.343" Score="4" Body="&lt;p&gt;Yes, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the common value of the &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;s.  This idea of introducing multiple copies of a variable is known as &lt;a href=&quot;https://or.stackexchange.com/questions/279/whats-the-difference-between-lagrangian-relaxation-and-lagrangian-decomposition&quot;&gt;Lagrangian Decomposition&lt;/a&gt;.  The &lt;span class=&quot;math-container&quot;&gt;$x=z_i$&lt;/span&gt; equalities are linking constraints for what otherwise would decompose into &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; disjoint subproblems.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-10-20T15:38:33.343" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5063" PostTypeId="1" AcceptedAnswerId="5064" CreationDate="2020-10-20T18:32:37.733" Score="1" ViewCount="394" Body="&lt;p&gt;I want to use linear programming to assign weights to a number of groups of variables.&lt;/p&gt;&#xA;&lt;p&gt;Let's assume we have group &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x,y,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and group &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$m,n,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to define constraints so that at least one of the variables from each group gets a weight larger than zero?&lt;/p&gt;&#xA;&lt;p&gt;A feasible solution wout be &lt;span class=&quot;math-container&quot;&gt;$x=2,y=0,z=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m=3, n=0, p=0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4310" LastEditorUserId="2556" LastEditDate="2020-10-20T18:54:25.307" LastActivityDate="2020-10-20T18:54:25.307" Title="Minimum value for a group of variables in linear programming" Tags="|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5064" PostTypeId="2" ParentId="5063" CreationDate="2020-10-20T18:46:12.993" Score="4" Body="&lt;p&gt;I am assuming the weights are integers.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_i^A$&lt;/span&gt; denote the weight assigned to item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; from group &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i^B$&lt;/span&gt; denote the weight assigned to item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; from group &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You need the following constraints :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i} x_i^A \ge 1 \\&#xA;\sum_{i} x_i^B \ge 1 \\&#xA;x_i^A, x_i^B \in \mathbb{N}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-10-20T18:46:12.993" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5065" PostTypeId="2" ParentId="828" CreationDate="2020-10-20T23:19:13.593" Score="5" Body="&lt;p&gt;Many state-of-art real-world large-scale combinatorial optimization problems are based on heuristics that use some sort of local search in them. Although not stated directly as a QUBO, many of these local search moves are based on solving a QUBO (with no &amp;quot;tricks&amp;quot; of penalizing the constraints). For example in the Travelling Salesman Problem, the popularly used 2-Opt and 3-Opt moves are in fact QUBOs with no penalized constraints. However, they form a very simple QUBO of just 2 and 3 variables respectively, thus brute force is sufficient to solve these QUBOs. So if you view this as a method that uses QUBOs in a state-of-art method, then there are many other applications, just not directly stated as a QUBO. Take a look at the paper on &lt;a href=&quot;https://arxiv.org/abs/1911.09810&quot; rel=&quot;noreferrer&quot;&gt;https://arxiv.org/abs/1911.09810&lt;/a&gt; for more such examples where the QUBO's generate are no longer trivial to solver, for example in local search moves for the Quadratic Assignment Problem.&lt;/p&gt;&#xA;" OwnerUserId="4305" LastActivityDate="2020-10-20T23:19:13.593" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5066" PostTypeId="1" AcceptedAnswerId="5067" CreationDate="2020-10-21T05:24:46.517" Score="6" ViewCount="372" Body="&lt;p&gt;I’m not sure if I’m wording this right but in a nutshell, my problem is:&lt;/p&gt;&#xA;&lt;p&gt;I’m modelling potential actions a boat owner can do to their boat. Let’s say he wants to know over the 50 year lifespan of the boat, what’s the cheapest way to maintain the exterior paint.&lt;/p&gt;&#xA;&lt;p&gt;He has three options:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Option 1:&lt;/strong&gt; first paint at a cost of $1M/boat. Under this option, it is suggested (not a must) to redo the paint at within next 5 years of the previous paint job for the remainder life of the boat.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Option 2:&lt;/strong&gt; If the boat has not been painted in the last 7 years, then it deteriorates to a point where it needs more significant repair at $1.4M. This will include repairs and paint at no extra cost.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Option 3:&lt;/strong&gt; if the boat hasn’t been painted for more than 10 years straight, then some items would have to be replaced at a total cost of \$1.6M/boat. Under this option, he also must paint &lt;em&gt;one year&lt;/em&gt; after the Option 3 repair at the same additional cost of $1M/boat.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;For the sake of argument and more constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The surface area of the boat is 400 m2. (Costs should be divided by that number to get the per m2 cost)&lt;/li&gt;&#xA;&lt;li&gt;The boat was fully painted 2 years ago, so no paint is required on the boat until period &amp;gt;= 3.&lt;/li&gt;&#xA;&lt;li&gt;Minimum repair area = 25m2&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;At a max budget of \$200K/year for the first 6 years and a max budget of \$300K/yr after, how much should he do from Option 1, 2, and 3 to maximize the condition (painted area)?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note, I’d like to run this as both a minimization of cost and maximization of condition separate models.&lt;/p&gt;&#xA;&lt;p&gt;I’m struggling to build the constraints for this model especially the interaction variable on how to build the multiple constraints / variables and summarize them back into results.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;Solution must be able to somewhat scale to &lt;code&gt;n&lt;/code&gt; boats and &lt;code&gt;i&lt;/code&gt; options, and &lt;code&gt;m&lt;/code&gt; owners.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;Initially I didn't include the deterioration Curve but there is one. I think for simplicity's sake, we can assume that deterioration occurs at a constant 3% a year and one of the constraints is to ensure that  no more than 10% is in deteriorating condition.&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, at Option 1, returns the repaired section to 90% condition rate, option 2 to 95% and option 3 to 100%.&lt;/p&gt;&#xA;" OwnerUserId="2955" LastEditorUserId="2955" LastEditDate="2020-10-23T14:10:33.600" LastActivityDate="2020-10-23T15:05:22.277" Title="Multi-period linear dynamic programming with differing in-period dependencies and changes" Tags="|mixed-integer-programming|linear-programming|scheduling|dynamic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5067" PostTypeId="2" ParentId="5066" CreationDate="2020-10-21T12:25:40.557" Score="4" Body="&lt;p&gt;&lt;strong&gt;Disclaimer : this is more of a hint than a complete answer.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can use the following model as a starting point to make your own model. I am ignoring two items :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Constraint from option 3:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Under this option, he also must paint one year after the Option 3&#xA;repair at the same additional cost of $1M/boat.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Surface area constraints&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You will have to tweak what follows to take the above constraints into account.&lt;/p&gt;&#xA;&lt;p&gt;This relaxation of your problem can be solved as a shortest path problem in the following directed acyclic graph:&lt;/p&gt;&#xA;&lt;p&gt;Define one node per year, from &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt;. Then, define an edge from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i&amp;lt;j$&lt;/span&gt;, if it is feasible for the owner to do some maintenance on years &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and nothing years &lt;span class=&quot;math-container&quot;&gt;$i+1, i+2, ..., j-1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The cost function on these edges is defined according to the &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; options. So for example, between nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i+1,i+2,i+3,i+4,i+5$&lt;/span&gt;, the cost is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; M dollars (option 1). Between nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i+7,i+8, i+9$&lt;/span&gt;, it is &lt;span class=&quot;math-container&quot;&gt;$1.4$&lt;/span&gt; M dollars (option 2). And between nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i+10$&lt;/span&gt;, it is &lt;span class=&quot;math-container&quot;&gt;$1.6$&lt;/span&gt; M dollars (option 3).&lt;/p&gt;&#xA;&lt;p&gt;If the max budget is not satisfied, do not create the corresponding edges.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The shortest path from node &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt; determines the cheapest maintenance strategy for the owner of the boat.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT #1&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The fact that the above is shortest path problem hints that the problem could probably be solved with dynamic programming. Anyway, one way to address the problem is to consider &amp;quot;states.&amp;quot; A state &lt;span class=&quot;math-container&quot;&gt;$(t,s)$&lt;/span&gt; is defined by two parameters : &lt;span class=&quot;math-container&quot;&gt;$t\in \{1,...,50\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s\in \{0,1,2,...,400\}$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; denotes the year, and &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; denotes the surface area that is left unpainted year &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. In the above answer, partial surface areas were ignored, so all vertices correspond to &lt;span class=&quot;math-container&quot;&gt;$(t,0)$&lt;/span&gt; states.&lt;/p&gt;&#xA;&lt;p&gt;Once you have defined such states, create a grid where nodes represent all possible states. And create an (oriented) edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; between two vertices &lt;span class=&quot;math-container&quot;&gt;$i=(t_i,s_i)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j=(t_j,s_j)$&lt;/span&gt; if the following holds:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t_j &amp;gt; t_i$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is a feasible transition in terms of budget,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is a feasible transition in terms of painting strategy&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also, create a source node and link it to all vertices (if feasible), and a sink node, to which all vertices are linked (if feasible). Once you have all the edges, add the corresponding cost. For example, on edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, if &lt;span class=&quot;math-container&quot;&gt;$s_j &amp;gt; s_i$&lt;/span&gt;, it means you do nothing, and so the cost is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$s_j \le s_i $&lt;/span&gt;, it means you are painting &lt;span class=&quot;math-container&quot;&gt;$s_i - s_j - A_{ij}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$m^2$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$A_{ij}$&lt;/span&gt; denotes the surface deteriorated between &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt;, at a cost which depends on which option (&lt;span class=&quot;math-container&quot;&gt;$1,2,3$&lt;/span&gt;) you are using (and so on the length of edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Once you have defined such an oriented graph. A path from the source node to the sink node defines a maintenance strategy, and the shortest path defines the best (cheapest) strategy.&lt;/p&gt;&#xA;&lt;p&gt;The constraint in option 3 :&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Under this option, he also must paint one year after the Option 3&#xA;repair at the same additional cost of $1M/boat.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;needs to be addressed (I think) with integer programming. You will have to formulate the shortest path problem as a MIP (easy), and add extra constraints and variables to take into account the fact that if you use an edge corresponding to a &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; year transition, then you must use an edge corresponding to a &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; year transition the year after.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-10-23T15:05:22.277" LastActivityDate="2020-10-23T15:05:22.277" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="5068" PostTypeId="1" CreationDate="2020-10-21T13:05:19.950" Score="9" ViewCount="5095" Body="&lt;p&gt;I have an MINLP problem to solve where I was initially using 'ipopt' solver but the solution was not sticking to 'binary/boolean/integer' domain type for a variable. I am not sure which free solver would be good to go?&#xA;Also, I understand 'SCIP' is not straight forward to use.&lt;/p&gt;&#xA;" OwnerUserId="3961" LastEditorUserId="491" LastEditDate="2021-01-26T15:30:21.373" LastActivityDate="2023-01-27T22:22:05.980" Title="Can I use 'SCIP' solver for PYOMO?" Tags="|optimization|python|combinatorial-optimization|pyomo|scip|" AnswerCount="3" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5069" PostTypeId="2" ParentId="5068" CreationDate="2020-10-21T13:38:23.463" Score="5" Body="&lt;p&gt;SCIP used to be a bit challenging to set up with PYOMO as we needed to build the ASL interface. It's been a few years so I don't know if that's changed, but you can find a relevant discussion &lt;a href=&quot;https://groups.google.com/g/pyomo-forum/c/peBjIvkVwtQ&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What might be easier would be to use &lt;a href=&quot;https://github.com/coin-or/Couenne&quot; rel=&quot;noreferrer&quot;&gt;Couenne&lt;/a&gt;, which is a deterministic global optimisation solver for MINLP and works out of the box with PYOMO.&lt;/p&gt;&#xA;&lt;p&gt;If you are a student/academic, you can also use our own global MINLP solver (Octeract Engine) &lt;a href=&quot;https://octeract.com/academic-licences/&quot; rel=&quot;noreferrer&quot;&gt;for free&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you do, you can find a detailed tutorial on how to use it with PYOMO on Windows &amp;amp; Linux &lt;a href=&quot;https://octeract.com/pyomo-with-the-engine/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-10-21T13:38:23.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5070" PostTypeId="1" CreationDate="2020-10-21T14:33:03.733" Score="1" ViewCount="150" Body="&lt;p&gt;I have a constraint problem that I need to resolve, but I did not how know to model the problem:&lt;/p&gt;&#xA;&lt;p&gt;I have 11 employees, I will name them from &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\{a,b,c,d,e,f,g,h,i,j,k\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have a small company that can only receive a maximum of 8 employees.&lt;/p&gt;&#xA;&lt;p&gt;how can I divide these employees in group in order to go to the company knowing that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; must go together at least 1 time in 10 days.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; must go together at least 1 time in 10 days.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; must go together at least 1 time in 10 days.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; must go together at least 1 time in 10 days.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Furthermore every employee must see every one of his colleagues in 10 days period.&lt;/p&gt;&#xA;&lt;p&gt;The objective is how to divide these employees on 10 days.&lt;/p&gt;&#xA;&lt;p&gt;I didn't know how to model these constraints in order to solve the problem.&lt;/p&gt;&#xA;" OwnerUserId="4314" LastEditorUserId="123" LastEditDate="2021-02-23T09:33:34.457" LastActivityDate="2021-02-23T09:33:34.457" Title="Constraint programming and scheduling issues" Tags="|modeling|integer-programming|scheduling|constraint-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5071" PostTypeId="1" CreationDate="2020-10-21T14:55:20.563" Score="0" ViewCount="903" Body="&lt;p&gt;I am working on a pyomo model, and need to create a few different sets of variables that are dependent on a solution from a master model.  I need the variables to be indexed variables however the conventional method of using &amp;quot;Var(indexSet1, indexSet2, indexSet3, etc.)&amp;quot; is not applicable because &amp;quot;indexSet2, indexSet3, etc.&amp;quot; are dependent upon the current index of &amp;quot;indexSet1&amp;quot;.  So as an example if I have an index set called crews = [0,1,2], then I will have a two dimensional array of jobs where the first index of the array is the crew and the second index of the set is job one of the jobs assigned to that crew. So jobs would look like [[0,3,7], [1,2,6],[4,5]].  Then I would like to create a variable &amp;quot;&lt;code&gt;x_ij&lt;/code&gt;&amp;quot; using the first index set and the second two dimensional array.  I tried &lt;code&gt;x_ij= Var(crews, jobs[crews])&lt;/code&gt; but this obviously didn't work.  I also tried the &lt;code&gt;add_component&lt;/code&gt; method which does add the correct variables to the model, but I tried to store them in a python dict with the keys being their index tuple &lt;code&gt;(i,j)&lt;/code&gt;, however, &lt;code&gt;add_component&lt;/code&gt; does not have a return value so my dict has the form &lt;code&gt;dict = {(i,j): none}&lt;/code&gt;.  Any help on how to do this would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="4315" LastEditorUserId="36" LastEditDate="2020-10-21T18:04:01.307" LastActivityDate="2020-10-21T20:00:47.180" Title="Pyomo variable creation dilemma" Tags="|pyomo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5072" PostTypeId="2" ParentId="5070" CreationDate="2020-10-21T16:53:22.023" Score="5" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; be the set of employees, and let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be the set of periods.  For &lt;span class=&quot;math-container&quot;&gt;$e\in E$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p\in P$&lt;/span&gt;, let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{e,p}$&lt;/span&gt; indicate whether employee &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; goes to the company in period &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;.  Let &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; be the set of groups that must go together at least once, and for &lt;span class=&quot;math-container&quot;&gt;$g\in G$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$E_g \subseteq E$&lt;/span&gt; be the set of employees in group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;.  For &lt;span class=&quot;math-container&quot;&gt;$g\in G$&lt;/span&gt;, let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{g,p}$&lt;/span&gt; indicate whether group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is scheduled in period &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;.  The constraints are&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{e\in E} x_{e,p} &amp;amp;\le 8 &amp;amp;&amp;amp;\text{for all $p\in P$} \tag1\\&#xA;\sum_{p\in P} y_{g,p} &amp;amp;\ge 1 &amp;amp;&amp;amp;\text{for all $g\in G$} \tag2\\&#xA;y_{g,p} &amp;amp;\le x_{e,p} &amp;amp;&amp;amp;\text{for all $g\in G$, $p\in P$, $e\in E_g$} \tag3\\&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces the capacity of 8 employees at a time.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; forces each group to appear at least once.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y_{g,p}=1 \implies x_{e,p}=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In your example, you identified four employee groups explicitly, but you can also model each pair of employees as a group of size 2.&lt;/p&gt;&#xA;&lt;p&gt;You did not specify an objective, but a natural choice might be to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{e\in E} \sum_{p\in P} x_{e,p}$&lt;/span&gt;.  The minimum turns out to be 22, and you can achieve that with only three periods.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-10-21T16:53:22.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5073" PostTypeId="2" ParentId="5068" CreationDate="2020-10-21T19:39:52.157" Score="5" Body="&lt;p&gt;You can use SCIP with PYOMO easily. My way is: At first, use an executable SCIP version, it is available for the 7.0 version. After then giving the path of the executable to PYOMO, such as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    solver = SolverFactory('scip', executable=&amp;quot;./scip&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It works. But I use BONMIN in same way.&lt;/p&gt;&#xA;" OwnerUserId="432" LastEditorUserId="432" LastEditDate="2020-10-21T20:49:21.947" LastActivityDate="2020-10-21T20:49:21.947" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5074" PostTypeId="2" ParentId="5071" CreationDate="2020-10-21T19:53:39.523" Score="1" Body="&lt;p&gt;I am preparing a list of tuple of index based on the conditions, after then giving to index parameter to &amp;quot;Var&amp;quot;.  For your problem, if I understand it correctly, this will be enough:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;index_list = [(0,1),(0,3), (0,7), (1,1), (1,2), (1,6), (2,4), (2,5)]&#xA;x_ij = Var(index_list) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can prepare this list any way, such as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;index_list = [] &#xA;for crew in crews:&#xA;   for job in jobs[crew]:&#xA;       index_list.append((crew,job))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="432" LastEditorUserId="432" LastEditDate="2020-10-21T20:00:47.180" LastActivityDate="2020-10-21T20:00:47.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5075" PostTypeId="1" CreationDate="2020-10-22T03:22:12.900" Score="4" ViewCount="2708" Body="&lt;p&gt;Some say adding constraints cuts the feasible region smaller hence the same solver terminates faster due to the less search effort. Others say it adds more complexity to the problem and it may take longer to solve.&lt;/p&gt;&#xA;&lt;p&gt;Personally, I think it depends on the model and the algorithm that is solving it. For instance, adding constraints to a linear program may add more vertices to the polyhedron that represents the feasible region. Consequently, the Simplex algorithm may take longer as it pivots over more extreme points.&lt;/p&gt;&#xA;&lt;p&gt;To what extent do we know the effect of adding constraint to any given mathematical model and solution algorithm?&lt;/p&gt;&#xA;" OwnerUserId="765" LastActivityDate="2020-10-22T14:17:19.050" Title="Does adding constraint to an optimization model make it solve faster?" Tags="|optimization|modeling|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5076" PostTypeId="2" ParentId="5075" CreationDate="2020-10-22T03:51:11.140" Score="1" Body="&lt;p&gt;Depends on the model itself as you mentioned. Adding constraints would help the model to define its search space but there is also a possibility where you may not find a solution in your search space at all.&lt;/p&gt;&#xA;" OwnerUserId="3961" LastEditorUserId="972" LastEditDate="2020-10-22T04:59:53.520" LastActivityDate="2020-10-22T04:59:53.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5077" PostTypeId="1" CreationDate="2020-10-22T09:54:02.283" Score="5" ViewCount="275" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}=\left(a_{ij}\right)$&lt;/span&gt; be a &lt;span class=&quot;math-container&quot;&gt;$n\times J$&lt;/span&gt; matrix with &lt;span class=&quot;math-container&quot;&gt;$a_{ij}\geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$n&amp;gt;J$&lt;/span&gt; and such that no row or column has all its entries equal to zero. Let also &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}=\left(k_j\right)$&lt;/span&gt; be a &lt;span class=&quot;math-container&quot;&gt;$J\times 1$&lt;/span&gt; vector of non negative coeficients and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}=\left(q_i\right)$&lt;/span&gt; a &lt;span class=&quot;math-container&quot;&gt;$n\times 1$&lt;/span&gt; vector of variables. Abusing notation, I'll write &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^{\beta}=\left(q_i^{\beta}\right)$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$\beta&amp;gt;1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, the following problem can be solved&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;    \min\limits_{\{q_i\}}&amp;amp; \quad \sum_{i=1}^n q_i^{\beta}a_{ij}\\&#xA;    \text{s.t.}&amp;amp;\quad \quad &#xA;     \begin{cases} &#xA;         \sum_{i=1}^n q_i=1\\&#xA;         \mathbf{q}\geq 0.&#xA;    \end{cases} &#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^j$&lt;/span&gt; denote the minimand,  &lt;span class=&quot;math-container&quot;&gt;$\mathbf{z}^j=\mathbf{A}^{\top}\left(\mathbf{q}^j\right)^{\beta}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{Z}=\left(z^j_j\right)$&lt;/span&gt; the matrix resulting from adjoining all the &lt;span class=&quot;math-container&quot;&gt;$\mathbf{z}^j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\langle \mathbf{Z}\rangle$&lt;/span&gt; the convex cone spanned by &lt;span class=&quot;math-container&quot;&gt;$\mathbf{Z}$&lt;/span&gt;. It can be shown that &lt;span class=&quot;math-container&quot;&gt;$\langle \mathbf{Z}\rangle\subseteq \langle \mathbf{A}\rangle$&lt;/span&gt;. I'd like to prove that for &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\in\langle \mathbf{Z}\rangle$&lt;/span&gt;, problems&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;    \max\limits_{\{q_i\}}&amp;amp; \quad \sum_{i=1}^n q_i&amp;amp;\quad &amp;amp;\quad &amp;amp;\quad &amp;amp;\max\limits_{\{q_i\}}&amp;amp;\sum_{i=1}^n q_i\\&#xA;    \text{s.t.}&amp;amp;&#xA;     \begin{cases} &#xA;         \mathbf{A}^{\top}\mathbf{q}^\beta\leq\mathbf{k}\\&#xA;         \mathbf{q}\geq 0&#xA;    \end{cases}&amp;amp;\quad&amp;amp;\quad &amp;amp;\quad  &amp;amp;\text{s.t.}&amp;amp;&#xA;     \begin{cases} &#xA;         \mathbf{A}^{\top}\mathbf{q}^\beta=\mathbf{k}\\&#xA;         \mathbf{q}\geq 0&#xA;    \end{cases} &#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;yield the same result, i.e., all the inequality constraints other than the non negativity constraints are binding. I believe this result to be true also for &lt;span class=&quot;math-container&quot;&gt;$\beta=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm trying to prove this by contradiction. Assume that the minimands are different and denote &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat q}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\tilde q}$&lt;/span&gt; the solution to the problem with inequality and with equality constraints respectively. If &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat q}\neq\mathbf{\tilde q}$&lt;/span&gt;, then it must happen that&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\hat q=\sum_{i=1}^n \hat q_i&amp;gt;\sum_{i=1}^n \tilde q_i=\tilde q$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^{\prime}=\mathbf{A}^{\top}\mathbf{\hat q}^{\beta}\leq\mathbf{k}$&lt;/span&gt;, with strict inequality for some &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I think that it suffices to show that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^{\prime}\in\langle \mathbf{Z}\rangle$&lt;/span&gt;. Note that for &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^{\prime}$&lt;/span&gt;, both problems need to yield &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat q}$&lt;/span&gt; as the solution and, therefore, the assumption that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\in\langle \mathbf{Z}\rangle\implies \mathbf{\hat q}\neq\mathbf{\tilde q}$&lt;/span&gt; cannot be true.&lt;/p&gt;&#xA;&lt;p&gt;I know that &lt;span class=&quot;math-container&quot;&gt;$k_j\geq k^{\prime}_j\geq \hat q^{\beta} z_j^j\;\forall j$&lt;/span&gt;, but an example has convinced me that this is not enough to warrant &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^{\prime}\in\langle \mathbf{Z}\rangle$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$J&amp;gt;2$&lt;/span&gt; (it is enough for &lt;span class=&quot;math-container&quot;&gt;$J=2$&lt;/span&gt;, though).&lt;/p&gt;&#xA;&lt;p&gt;I believe that some &amp;quot;continuity&amp;quot; argument must imply that, given &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\in\langle \mathbf{Z}\rangle$&lt;/span&gt;, there must exist some &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^{\prime\prime}\in\langle \mathbf{Z}\rangle$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^{\prime\prime}\leq\mathbf{k}$&lt;/span&gt; and that the solution to the problem with inequality constraints is unchanged. On the other hand, the solution to the problem with equality constraints would be &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\tilde q}^{\prime\prime}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{n}=\tilde q^{\prime\prime}_i&amp;gt;\tilde q$&lt;/span&gt;. Could iterating this procedure yield &lt;span class=&quot;math-container&quot;&gt;$\tilde q \rightarrow \hat q$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt;&#xA;Two other approaches, both of them incomplete:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;An alternative is trying to prove the contrapositive, i.e.,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation*}&#xA;     \hat{\mathbf{q}}\neq\tilde{\mathbf{q}}\implies\mathbf{k}\not\in\langle \mathbf{Z}\rangle.&#xA; \end{equation*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are two cases:&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\nexists \tilde{\mathbf{q}}$&lt;/span&gt;. This can only happen if the feasible set is empty (if it is not empty, it is compact and convex, and since the objective function is continuous, it will reach a maximum). Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}=\left(w_{i}\right)_{1\leq i\leq n}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$w_{i}=q_{i}^{\beta}\geq 0$&lt;/span&gt;. The feasible set being empty implies that &lt;span class=&quot;math-container&quot;&gt;$\nexists \mathbf{q}\geq 0$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}^{\top}\mathbf{q}^{\beta}=\mathbf{k}$&lt;/span&gt; and, therefore, &lt;span class=&quot;math-container&quot;&gt;$\nexists \mathbf{w}\geq 0$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}^{\top}\mathbf{w}=\mathbf{k}$&lt;/span&gt;. This means &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\not\in\langle \mathbf{A}\rangle$&lt;/span&gt; and, hence, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\not\in\langle \mathbf{Z}\rangle$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\exists \tilde{\mathbf{q}}$&lt;/span&gt; but &lt;span class=&quot;math-container&quot;&gt;$\tilde{\mathbf{q}}\neq\hat{\mathbf{q}}$&lt;/span&gt;. The fact that they are different implies (a) &lt;span class=&quot;math-container&quot;&gt;$\sum \hat q_i&amp;gt;\sum\tilde q_i$&lt;/span&gt; and (b) &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^{\prime}\leq\mathbf{k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\exists j^*$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$k^{\prime}_{j^{*}}&amp;lt;k_{j^*}$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}=\left(w_{j}\right)_{1\leq j\leq J}$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$\mathbf{Z}$&lt;/span&gt; is full rank, the system &lt;span class=&quot;math-container&quot;&gt;$\mathbf{Z}\mathbf{w}=\mathbf{k}^{\prime}$&lt;/span&gt; has a solution. If the solution was such that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}\geq 0$&lt;/span&gt; we'd have that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^{\prime}\in\langle \mathbf{Z}\rangle$&lt;/span&gt;. However, I don't know how to prove that indeed &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}\geq 0$&lt;/span&gt;. In addition, this leaves out the case of a singular &lt;span class=&quot;math-container&quot;&gt;$\mathbf{Z}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}=\left(w_{j}\right)_{1\leq j\leq J}$&lt;/span&gt; be a vector that (a) is a linear combination of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{Z}$&lt;/span&gt; and (b) is orthogonal to those &lt;span class=&quot;math-container&quot;&gt;$\mathbf{z}^j$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$k_{j}=k_{j}^{\prime}$&lt;/span&gt;. It should be the case that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}^{\top}\mathbf{k}&amp;gt;\mathbf{w}^{\top}\mathbf{k}^{\prime}$&lt;/span&gt;. In fact, what needs to happen is that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}$&lt;/span&gt; separates &lt;span class=&quot;math-container&quot;&gt;$\langle \mathbf{Z}\rangle$&lt;/span&gt; from the part of &lt;span class=&quot;math-container&quot;&gt;$\langle \mathbf{A}\rangle$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}$&lt;/span&gt; lies. The underlying rationale is that if the solutions to (I) and (II) are different, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\not\in\langle \mathbf{Z}\rangle$&lt;/span&gt;, while &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^{\prime}\in\langle \mathbf{Z}\rangle$&lt;/span&gt;. As &lt;span class=&quot;math-container&quot;&gt;$\langle\mathbf{Z}\rangle$&lt;/span&gt; is convex, we use a separating hyperplane, which is just the specific &lt;em&gt;side&lt;/em&gt; of the cone on which &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^{\prime}$&lt;/span&gt; sits. The problem is that I don't know how to implement this approach.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit 3:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;All three approaches boil down to proving that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}^{\prime}=\mathbf{A}^{\top}\mathbf{\hat q}^{\beta}\in\langle \mathbf{Z}\rangle$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit 4:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;It can be shown that the two problems having different solutions implies that some of the Lagrange multipliers in the problem with equality constraints need to be negative. If it's possible to show that those multipliers are non-negative &lt;span class=&quot;math-container&quot;&gt;$\forall\mathbf{k}\in\langle\mathbf{Z}\rangle$&lt;/span&gt; then we'll have completed the proof. I think the following proves that the Lagrange multipliers are indeed non-negative for each of the &lt;span class=&quot;math-container&quot;&gt;$\mathbf{z}^{j}$&lt;/span&gt;. However, I still need to extend the proof to the rest of  &lt;span class=&quot;math-container&quot;&gt;$\langle\mathbf{Z}\rangle$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Choose an input, say &lt;span class=&quot;math-container&quot;&gt;$j^{*}$&lt;/span&gt;. Solving the problem with inequality constraints with &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}=\mathbf{z}^{j^{*}}$&lt;/span&gt; results in &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^{j^{*}}$&lt;/span&gt; and, therefore, a maximum production of 1, because &lt;span class=&quot;math-container&quot;&gt;$z_{j^{*}}^{j^{*}}$&lt;/span&gt; is the minimum quantity of &lt;span class=&quot;math-container&quot;&gt;$j^{*}$&lt;/span&gt; needed to produce one unit of output and, on the other hand, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^{j^{*}}$&lt;/span&gt; is feasible and results in precisely in &lt;span class=&quot;math-container&quot;&gt;$\sum q_{i}^{j^{*}}=1$&lt;/span&gt;. Note that increasing marginally the available amount of any input except the &lt;span class=&quot;math-container&quot;&gt;$j^{*th}$&lt;/span&gt; has no effect on the maximum production (because, again, it is limited by the fact that &lt;span class=&quot;math-container&quot;&gt;$z_{j^{*}}^{j^{*}}$&lt;/span&gt; is the minimum needed for a production of one unit), and, therefore the corresponding KKT multipliers (denoted &lt;span class=&quot;math-container&quot;&gt;$\lambda_j$&lt;/span&gt;) need to be zero. On the other hand, we can obtain from the FOCs wrt &lt;span class=&quot;math-container&quot;&gt;$q_i\,\forall i$&lt;/span&gt; of either problem&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation*}&#xA;    \sum_{i=1}^n q_i=\beta\sum_{j=1}^{J} \lambda_{j} \sum_{i=1}^{n} q_{i}^{\beta}x_{ij}.&#xA;\end{equation*}&lt;/span&gt;&#xA;As &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^{j^{*}}$&lt;/span&gt; satisfies the FOCs of both problems and &lt;span class=&quot;math-container&quot;&gt;$\lambda_{j}=0\;\forall j\neq j^{*}$&lt;/span&gt;, we have that &lt;span class=&quot;math-container&quot;&gt;$\lambda_{j^{*}}=\frac{1}{\beta z_{j^{*}}^{j^{*}}}&amp;gt;0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2391" LastEditorUserId="2391" LastEditDate="2020-11-30T13:56:19.063" LastActivityDate="2020-11-30T13:56:19.063" Title="Substituting inequality by equality constraints" Tags="|optimization|constraint|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5078" PostTypeId="1" AcceptedAnswerId="5082" CreationDate="2020-10-22T10:26:49.793" Score="0" ViewCount="424" Body="&lt;p&gt;I have a production planning / scheduling problem, which I believe is a kind of job shop scheduling problem.&#xA;But I would like to get some input on what kind of job shop scheduling problem it is and how it can be solved.&lt;/p&gt;&#xA;&lt;p&gt;I have materials which needs to be produced in a given week, each with a given quantity. These would be the jobs.&#xA;So I want to create a production plan for the entire week.&lt;/p&gt;&#xA;&lt;p&gt;To produce each material, I need a specific tool. All materials needs a specific tool. For some of the tools I have multiple of the same kind and for others I only have one. So I might have 100 different materials, but only have 20 tools. So a lot of materials needs the same tool and for some there a multiple and for others there are only one.&lt;/p&gt;&#xA;&lt;p&gt;In order to produce a material I need the tool associated with the material to be placed into a machine. Each tools can only be placed into a subset of the machines.&#xA;So e.g. tool A can be placed into machine 1, 2 and 3, while tool B can only be placed into machine 3, 4 and 5.&#xA;I have more tools than machines.&lt;/p&gt;&#xA;&lt;p&gt;So #materials &amp;gt; #tools &amp;gt; #machines.&lt;/p&gt;&#xA;&lt;p&gt;Each material and its given quantity have a production time associated with it.&lt;/p&gt;&#xA;&lt;p&gt;If I want to change the tools which are placed in a machine, there is a changeover time. However, if I after producing a material on a machine continue to produce another material which requi&#xA;res the same tool then there is no changeover time.&#xA;The changeover is dependent on what tool you are changing from and which tool you are changing to. Further, the changeover time from A -&amp;gt; B is not the same as the changeover time from B -&amp;gt; A.&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, after producing a given quantity on a machine, it needs to be cleaned which requires some cleaning time.&lt;/p&gt;&#xA;&lt;p&gt;In this problem I want to minimize the make-span and of course come up with a feasible plan.&lt;/p&gt;&#xA;&lt;p&gt;Want kind of job shop scheduling problem is this, and what would be the best way to solve it?&lt;/p&gt;&#xA;" OwnerUserId="3019" LastEditorUserId="123" LastEditDate="2020-10-22T10:29:55.193" LastActivityDate="2020-10-22T13:12:36.660" Title="What kind of job shop scheduling problem is this and how do I solve it?" Tags="|optimization|modeling|combinatorial-optimization|scheduling|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="5079" PostTypeId="1" CreationDate="2020-10-22T10:36:36.060" Score="3" ViewCount="142" Body="&lt;p&gt;I have two different MILP formulations for the same scheduling problem with the same complexity but with different running times. Why it is recommended to compare the relaxed versions of each formulation to deduce the running time (and more precisely about the B&amp;amp;B tree size)?&lt;/p&gt;&#xA;&lt;p&gt;What is the advantage of considering the relaxed models instead of the original models?&lt;/p&gt;&#xA;&lt;p&gt;Also I have other questions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Are all the scheduling problems NP-hard? Otherwise how to determine if a problem is NP-hard or not?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A formulation with integer and binary variables is called integer program or mixed integer linear program?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4273" LastEditorUserId="123" LastEditDate="2020-10-22T10:40:39.780" LastActivityDate="2020-10-22T17:24:32.907" Title="Relaxation and complexity of two formulations" Tags="|mixed-integer-programming|modeling|combinatorial-optimization|scheduling|relaxation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5080" PostTypeId="2" ParentId="5075" CreationDate="2020-10-22T11:02:45.137" Score="4" Body="&lt;p&gt;We don't, that's why many optimisation problems are NP-Hard (or vice-versa). Some tricks are known to work most of the time, such as RLT or Gomory cuts, but even then we need to pick the &amp;quot;right&amp;quot; constraints out of all the possible options, and to add the &amp;quot;right&amp;quot; number of constraints, otherwise:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Number of iterations is improved, but each iteration is too slow, or&lt;/li&gt;&#xA;&lt;li&gt;Number of iterations is pretty much the same, but each iteration is, again, too slow, or&lt;/li&gt;&#xA;&lt;li&gt;The model becomes numerically unstable/infeasible, or&lt;/li&gt;&#xA;&lt;li&gt;Number of iterations is actually larger and slower, due to some chaotic change in how the change in the problem interacted with the solver's algorithms.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;What we do know for sure is that removing certain types of constraints the &amp;quot;right way&amp;quot; is always good, e.g., symbolically eliminating singleton constraints.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-10-22T11:02:45.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5081" PostTypeId="1" AcceptedAnswerId="5085" CreationDate="2020-10-22T11:07:35.963" Score="3" ViewCount="557" Body="&lt;p&gt;I'm having difficulties understanding my FlowControl output compared to what the Engine Log shows me.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hYAve.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hYAve.png&quot; alt=&quot;Scripting Log (left) and Engine Log (right)&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;My output from the FlowControl into the Scripting Log (yellow marks) is &lt;code&gt;cplex.getObjValue()&lt;/code&gt;, then &lt;code&gt;cplex.getBestObjValue()&lt;/code&gt;, and &lt;code&gt;cplex.getMIPRelativeGap()&lt;/code&gt;. The Engine log shows the last entry before the optimization is terminated. I have a &lt;code&gt;dettillim = 15000&lt;/code&gt;, which doesn't seem to be reached, but also a few fixed binary variables (LB==UB), so I'm expecting a gap.&lt;/p&gt;&#xA;&lt;p&gt;Now my question is why (and/or how) does the MIP gap extracted from the FlowControl differ from the last entry in the Engine Log? I can't find any reasonable explanation in the documentation.&lt;/p&gt;&#xA;" OwnerUserId="2725" LastActivityDate="2020-10-22T16:48:15.323" Title="How do I interpret the CPLEX Optimization Studio MIP gap output?" Tags="|optimization|mixed-integer-programming|cplex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5082" PostTypeId="2" ParentId="5078" CreationDate="2020-10-22T12:59:04.990" Score="2" Body="&lt;p&gt;It is an unrelated parallel machine scheduling problem with sequence-dependent family setup times. The tools define the families; the materials are family members. The tool that is on a machine completely defines the state of the machine. In the machine scheduling literature the problem might be denoted as Q|sij|Cmax&lt;/p&gt;&#xA;&lt;p&gt;It's unrelated parallel machines because not all families can be installed on all machines. A special case though, where processing time of task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on machine &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is either &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt; or infinite-ish.&lt;/p&gt;&#xA;&lt;p&gt;Not really sure what the state of the art is for Q|sij|Cmax but the simpler uniform parallel machine problem P|sij|Cmax isn't super rare in the literature.&lt;/p&gt;&#xA;&lt;p&gt;A quirk you have to deal with (i.e. side constraint) is that your tool count is limited so a family can only be on a limited number of machines at a time. The underlying problem remains Q|sij|Cmax but your problem has this additional difficulty.&lt;/p&gt;&#xA;&lt;p&gt;I suggest that you'd use a list scheduling heuristic here as your starting point...&lt;/p&gt;&#xA;" OwnerUserId="4321" LastEditorUserId="36" LastEditDate="2020-10-22T13:12:36.660" LastActivityDate="2020-10-22T13:12:36.660" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5083" PostTypeId="2" ParentId="5075" CreationDate="2020-10-22T14:17:19.050" Score="9" Body="&lt;p&gt;There's no single answer to the question of whether adding constraints will help or hurt.&lt;/p&gt;&#xA;&lt;p&gt;If we have a MIP formulation of the TSP and we remove the subtour-elimination constraints, the resulting MIP is easy; now add the subtour-elimination constraints back in, and the problem gets much &lt;strong&gt;harder&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, if we have a MIP formulation and we add constraints forcing all the decision variables to equal some known feasible solution, then the resulting problem is trivial; it got much &lt;strong&gt;easier&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(I know your post asked the much more interesting and nuanced question of &lt;em&gt;what is known about the effect of adding constraints&lt;/em&gt; ... I'm purposely avoiding that part. :) )&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2020-10-22T14:17:19.050" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5084" PostTypeId="2" ParentId="5079" CreationDate="2020-10-22T16:30:18.580" Score="4" Body="&lt;p&gt;Why it is recommended to compare the relaxed versions of each formulation to deduce the running time (and more precisely about the B&amp;amp;B tree size)?&lt;/p&gt;&#xA;&lt;p&gt;Generally, better (= tighter) is the relaxation of an integer optimization model, better should work a brand-and-bound tree solution approach to this model. Nevertheless, there exist some NP-hard problems for which the cost of the linear relaxation is equal to the cost of an optimal integer solution. Indeed, despite having a cost equal to the optimum integer solution, the relaxed solution may be highly fractional, then bringing no insightful information for the search of an integer one. In conclusion, just looking at the value of the linear relaxation will not inform you so much about the running time of the resolution of the original integer model (by B&amp;amp;B or any other approaches).&lt;/p&gt;&#xA;&lt;p&gt;Are all the scheduling problems NP-hard? Otherwise how to determine if a problem is NP-hard or not?&lt;/p&gt;&#xA;&lt;p&gt;Some scheduling problems are easy to solve, by polynomial-time (or even linear-time) combinatorial algorithms. But these problems are generally very basic, not realistic OR problems as you can find in the industry. For example, &lt;a href=&quot;https://hal-lirmm.ccsd.cnrs.fr/lirmm-00522986/document&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; is a paper on such an easy problem. To learn about NP-hardness, have a look at the &lt;a href=&quot;https://en.wikipedia.org/wiki/NP-hardness&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia page on the topic&lt;/a&gt;; this is a good starting point. You will also find a lot of resources on the web.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2020-10-22T17:17:23.923" LastActivityDate="2020-10-22T17:17:23.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5085" PostTypeId="2" ParentId="5081" CreationDate="2020-10-22T16:48:15.323" Score="5" Body="&lt;p&gt;The engine log does not print the gap for every node cplex investigates. That would leave you with more than 2000 lines in the log for your instance. So cplex has done some work between the last line in the engine log and the time it terminates.&lt;/p&gt;&#xA;&lt;p&gt;I must admit I do not know anything about the frequency with which cplex outputs a line in the engine log. It might be node or time specific?&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2020-10-22T16:48:15.323" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5086" PostTypeId="2" ParentId="5079" CreationDate="2020-10-22T17:24:32.907" Score="3" Body="&lt;p&gt;The initial gap can be an indicator but not a very good one. I have seen many problems start with a tight bound and then never improve, and I have also seen many problems start with a horrendous gap that improves very quickly.&lt;/p&gt;&#xA;&lt;p&gt;Honestly, there is no way to know in advance, we just have to try solving all formulations we can come up with, until we find one that works.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-10-22T17:24:32.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5088" PostTypeId="1" CreationDate="2020-10-23T08:31:08.740" Score="6" ViewCount="436" Body="&lt;p&gt;I have a MILP model that solves a master production schedule including capacity decisions. In the model I have a production quantity that should either be 0 or at least the amount that can be produced in one shift (or half shift), i.e., a minimium production quantity. Right now this is modeled using two variables, one binary and one continuous.&lt;/p&gt;&#xA;&lt;p&gt;The actual implementation right now is done with Google's or-tools which doesn't support semi-continuous variables, so I can't easily test this out. I would need to rewrite the whole model using a solver specific API and that would take quite some time.&lt;/p&gt;&#xA;&lt;p&gt;The model is solved in about 24h (with a reasonable gap remaining), it has more than 100,000 rows, 150,000 columns, and 600,000 non-zeros. Due to this &amp;quot;minimum quantity&amp;quot; I have about 28,000 binary variables in the model and without it there would be only a handful (basically choosing between different capacity levels). I tried removing the minimum quantity restriction (and thus those binary variables) and the model is solved in 2-3h to optimality.&lt;/p&gt;&#xA;&lt;p&gt;Would the use of semi-continuous variables instead of the binary-continuous pair allow the model to be solved faster than using two variables?&#xA;Are there any examples that show this difference in similar sized dimensions?&lt;/p&gt;&#xA;" OwnerUserId="242" LastActivityDate="2020-10-23T14:01:02.053" Title="What is the performance improvement when using semi-continuous variables instead of binary + continuous variable pair?" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5089" PostTypeId="2" ParentId="5088" CreationDate="2020-10-23T14:01:02.053" Score="8" Body="&lt;p&gt;A solver may branch directly on the semi-continuous variables, or may transform each one to an equivalent formulation using a continuous variable and a binary variable (like you have now). Either way, the solver must deal with the same number of discrete variables that require branching.&lt;/p&gt;&#xA;&lt;p&gt;One solver might do better with your continuous+binary formulation (perhaps because you know better bounds on the variables than the solver can deduce). Another solver might do better with the semi-continuous formulation, by taking advantage of its special structure.&lt;/p&gt;&#xA;&lt;p&gt;Additionally, any results with mixed-integer programming tend to be highly problem-specific. Although a given formulation and/or solver may be superior for your problem, it may well be inferior for someone else's problem that has a different structure.&lt;/p&gt;&#xA;&lt;p&gt;The upshot of all this is that the only way to be sure what works best is to run some tests. If you are writing directly to solver APIs, then that will mean programming more than one version of your model.&lt;/p&gt;&#xA;" OwnerUserId="52" LastActivityDate="2020-10-23T14:01:02.053" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5090" PostTypeId="2" ParentId="3347" CreationDate="2020-10-23T16:35:52.383" Score="9" Body="&lt;p&gt;As Marco briefly explained in his comment, TSP is not the ideal problem to teach the column generation approach. TSP is suited for the row generation approach, also known as &lt;a href=&quot;https://en.wikipedia.org/wiki/Branch_and_cut&quot; rel=&quot;noreferrer&quot;&gt;branch-and-cut&lt;/a&gt;, by following the Dantzig–Fulkerson–Johnson formulation that you can easily find on the web (for example, on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Travelling_salesman_problem&quot; rel=&quot;noreferrer&quot;&gt;Wikipedia page related to TSP&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;On the other, VRP is a good candidate to teach the column generation approach. You can start from the basics and &lt;a href=&quot;https://www.math.u-bordeaux.fr/%7Ersadykov/slides/Sadykov_INOC19slides.pdf&quot; rel=&quot;noreferrer&quot;&gt;go further and further in sophistication&lt;/a&gt;. Nevertheless, &lt;a href=&quot;https://en.wikipedia.org/wiki/Cutting_stock_problem&quot; rel=&quot;noreferrer&quot;&gt;cutting stock problems&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Bin_packing_problem&quot; rel=&quot;noreferrer&quot;&gt;bin packing problems&lt;/a&gt; are maybe better candidates to start your lesson. Indeed, in the case of cutting stock, the subproblem (also called pricing problem) is simply a &lt;a href=&quot;https://en.wikipedia.org/wiki/Knapsack_problem&quot; rel=&quot;noreferrer&quot;&gt;knapsack problem&lt;/a&gt;. In addition, studying the cutting stock problem allows an interesting historical note about the pioneering work by &lt;a href=&quot;https://pdfs.semanticscholar.org/1417/64b5e86dc6c2647dfce48098794c79d5a38b.pdf&quot; rel=&quot;noreferrer&quot;&gt;Gilmore and Gomory about column generation&lt;/a&gt; in the sixties (additional references are given in the Wikipedia page previously mentioned).&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-10-23T16:35:52.383" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5091" PostTypeId="1" CreationDate="2020-10-23T17:09:06.957" Score="3" ViewCount="88" Body="&lt;p&gt;Let's make a space for ALL of OR to be discussed. I'm particularly interested in the link between OR and design, I also co-chair the PSM SIG for the OR Society.  Hopefully by putting in some tags we can ensure these aspects of OR are included in this space.  But I don't have credits and this is a hard OR dominated space???&lt;/p&gt;&#xA;&lt;p&gt;As a starter - what is soft OR?  I know what I think, what do you think?&lt;/p&gt;&#xA;" OwnerUserId="4326" LastEditorUserId="68" LastEditDate="2020-10-24T01:51:33.280" LastActivityDate="2020-10-24T11:07:16.630" Title="Soft OR &amp; Problem Structuring Methods - often the first steps on an OR journey should not be missed out on this site. So what are they?" Tags="|modeling|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5092" PostTypeId="1" CreationDate="2020-10-23T21:24:48.697" Score="4" ViewCount="233" Body="&lt;p&gt;Nowadays, mathematical programming solvers have been frequently used to solve lots of practical/academic problems. Many of these might be interpreted as a &lt;em&gt;&lt;strong&gt;MIP&lt;/strong&gt;&lt;/em&gt; or &lt;em&gt;&lt;strong&gt;MINLP&lt;/strong&gt;&lt;/em&gt; to represent a specific problem (e.g. VRP variants). Some of the nonlinear terms in these models contain:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Product of two or more different variables&lt;/li&gt;&#xA;&lt;li&gt;Using either &lt;em&gt;&lt;strong&gt;min&lt;/strong&gt;&lt;/em&gt;, &lt;em&gt;&lt;strong&gt;max&lt;/strong&gt;&lt;/em&gt; or &lt;em&gt;&lt;strong&gt;abs&lt;/strong&gt;&lt;/em&gt; functions in the objective, constraints or both.&lt;/li&gt;&#xA;&lt;li&gt;Applying some mathematical functions, etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also, there are some linearizing tricks to change these nonlinear terms into whose linear forms. For example, the multiplier of two or more binary variables.&lt;/p&gt;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there any reasonable way to use &lt;em&gt;&lt;strong&gt;MINLP&lt;/strong&gt;&lt;/em&gt; engine instead of &lt;em&gt;&lt;strong&gt;MIP&lt;/strong&gt;&lt;/em&gt; to solve such problems?&lt;/li&gt;&#xA;&lt;li&gt;May these linearizations cause to increase the solving time?&lt;/li&gt;&#xA;&lt;li&gt;Is there any way to speed up the solving time by using both engines?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-10-23T23:27:49.217" Title="How/when can we use MINLP engines instead of linearizing MP models?" Tags="|optimization|solver|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5093" PostTypeId="2" ParentId="5092" CreationDate="2020-10-23T23:27:49.217" Score="5" Body="&lt;p&gt;I think by MIP you mean MILP which stands for mixed integer &lt;strong&gt;linear&lt;/strong&gt; program(ming).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Q1. Is there any reasonable way to use MINLP engine instead of MIP to solve such problems?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Of course you can use a MINLP solver, but such solvers may eventually use some form of linearization. I would first try to linearize a non-linear formulation (if possible) and then use a linear solver to solve the linear formulation. The reason is that modern linear solvers are quite enhanced and optimized for solving linear programs compared to non-linear solvers and you know what linear formulation is actually being solved. If a linear solver/reformulation is not an option for any reason, using the MINLP solvers is the only option. Note that some MILP problems (e.g., the Minimum Sum-of-Squared Clustering) can be represented as pure continuous but non-linear formulations. For such problems, using a non-linear solver may prove better (in finding feasible or optimal solutions) than a modern linear solver.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Q2. May these linearizations cause to increase the solving time?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;It depends on 1) the problem itself, 2) the linearization technique (there are sometimes a number of different ways) and 3) the solver used to solve the linearized problem. So anything is possible.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Q3. Is there any way to speed up the solving time by using both engines?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Depending on the problem, it is possible. For example, you may be able to reformulate the problem and decompose it into the so-called master problem and subproblem(s). In a scenario, the master problem is linear while the subproblem(s) are non-linear problems that can be solved by specialized algorithms (or MINLP solvers) more efficiently. In addition, modern MILP solvers are based on LP-based branch and bound (B&amp;amp;B) in which an LP is solved at each node of the B&amp;amp;B tree. You may be able to employ the same strategy, but solve a non-linear problem at each node (instead of an LP) to obtain stronger bounds. For example, semidefinite programs usually provide bounds that are stronger than their LP-relaxation counterparts (again, check the Minimum Sum-of-Squared Clustering as an example).&lt;/p&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2020-10-23T23:27:49.217" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5094" PostTypeId="2" ParentId="5091" CreationDate="2020-10-24T10:48:34.393" Score="3" Body="&lt;p&gt;As Mark commented above, Soft Operations Research is fully part of Operations Research. Soft OR focuses on approaches and methodologies to state and model the complex problems encountered in the real life of organizations. In contrast, &amp;quot;Hard OR&amp;quot; refers more to the mathematical and algorithmic foundations of the discipline, that is, how to solve the problem once it has been stated and modeled.&lt;/p&gt;&#xA;&lt;p&gt;A classical sentence about modeling is that this is more of an art than a science. Nevertheless, having a scientific and systematic approach to the definition, structuring, and modeling of real-life problems is critical for the advance of OR and for its success to improve society. Like any other field which is at the same time a practice, a technology, and a scientific discipline.&lt;/p&gt;&#xA;&lt;p&gt;In particular, Soft OR raises one interesting point: this is critical to well understand &lt;em&gt;the people&lt;/em&gt; for which we build an optimization model or an optimization software solution, to solve a problem. Not only to define the problem but also to understand why they wish to solve this problem (that is, the context around the problem), and in the end, to ensure that our work and our solution will fully satisfy their needs, beyond the problem. Indeed, answering the needs of our clients and users is the only way to create value for people and society. Now, answering the needs is not &lt;em&gt;only&lt;/em&gt; a matter of maths and algorithms. All of us - OR scientists, teachers, and practitioners - we must always remember this point if we wish our discipline to be successful &lt;em&gt;in practice&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For an introduction to Soft OR, we encourage you to read &lt;a href=&quot;http://analytics-magazine.org/operations-research-taming-hard-problems-with-soft-or/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article published in the INFORMS Analytics magazine&lt;/a&gt; or &lt;a href=&quot;https://link.springer.com/article/10.1057%2Fpalgrave.jors.2602193&quot; rel=&quot;nofollow noreferrer&quot;&gt;this JORS paper&lt;/a&gt;. The &lt;a href=&quot;http://people.brunel.ac.uk/%7Emastjjb/jeb/or/softor.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;J.E. Beasley notes&lt;/a&gt; or &lt;a href=&quot;http://www.opanalytics.ca/MORS/softor.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this webpage of the Military Operations Research Society (MORS)&lt;/a&gt; are also of interest.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2020-10-24T11:07:16.630" LastActivityDate="2020-10-24T11:07:16.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5095" PostTypeId="2" ParentId="4635" CreationDate="2020-10-24T21:48:56.500" Score="4" Body="&lt;p&gt;There is a well-studied problem close to your one: &lt;a href=&quot;https://math.stackexchange.com/questions/2293355/flow-problem-with-multiplicative-nodes&quot;&gt;Integral Flow With Multipliers&lt;/a&gt;. It was proved to be NP-hard in &lt;a href=&quot;https://www.cise.ufl.edu/%7Esahni/papers/computationallyRelatedProblems.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;the seminal Sartaj Sahni's paper&lt;/a&gt; in computational complexity theory (see section 2.2 of the paper). Another interesting, more recent paper can be found &lt;a href=&quot;http://e-archive.informatik.uni-koeln.de/589/2/zaik2009-589.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-10-24T21:48:56.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5096" PostTypeId="2" ParentId="4237" CreationDate="2020-10-24T22:33:48.257" Score="5" Body="&lt;p&gt;At Hexaly, we have several clients in advertising in media like TV, radio, and (D)OOH. We love this field of application of OR where problems consist of maximizing media's revenues while satisfying advertisers' constraints. We know that some people consider these applications &amp;quot;morally discussable&amp;quot; because they consider advertising bad for society.&lt;/p&gt;&#xA;&lt;p&gt;Another field of application that may be controversial is workforce planning. When we discuss this topic, particularly with students in OR courses, we see some worried about &amp;quot;minimizing the number of workers&amp;quot; and leading to firing people. By explaining more precisely the context and goals of workforce planning in companies, we observe people getting relaxed with the topic.&lt;/p&gt;&#xA;&lt;p&gt;More generally, since the outcomes of OR in the economy are optimization and automation, some people see OR as bad for society because efficiency gains mean job destruction in their minds.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T02:35:45.587" LastActivityDate="2024-04-04T02:35:45.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5097" PostTypeId="2" ParentId="4903" CreationDate="2020-10-24T23:21:23.147" Score="6" Body="&lt;p&gt;The best paper we ever read about the implementation of heuristics for the TSP is &lt;a href=&quot;http://webhotel4.ruc.dk/%7Ekeld/research/LKH/LKH-2.0/DOC/LKH_REPORT.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;An Effective Implementation of the Lin-Kernighan Traveling Salesman Heuristic&amp;quot; by Keld Helsgaun&lt;/a&gt;. This 70-page report is really a masterpiece in the field. You can find more details &lt;a href=&quot;http://webhotel4.ruc.dk/%7Ekeld/research/LKH/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; about Helgaun's research on TSP, and &lt;a href=&quot;http://webhotel4.ruc.dk/%7Ekeld/research/LKH-3/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for extensions to VRP.&lt;/p&gt;&#xA;&lt;p&gt;You can also have a look at &lt;a href=&quot;https://www.localsolver.com/fgardi/downloads/Benoist-Estellon-Gardi-Jeanjean_TRSC_09_extended.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;our paper&lt;/a&gt; on the Inventory Routing Problem, which describes a &amp;quot;mixed-variable&amp;quot; local search approach to deal with extensions of VRP involving additional quantitative decisions, constraints, and objectives.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Disclosure:&lt;/strong&gt; LocalSolver is our commercial software product.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="491" LastEditDate="2020-11-10T01:35:16.217" LastActivityDate="2020-11-10T01:35:16.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5098" PostTypeId="1" AcceptedAnswerId="5099" CreationDate="2020-10-25T07:14:09.780" Score="3" ViewCount="182" Body="&lt;p&gt;I am doing a project where I am using Particle Swarm Optimization (PSO) for a design optimization problem. Naturally, in there I had to conduct hyperparameter optimization to find the most optimal values of the hyperparameters. I was asked a question by someone that whether the same set of optimal hyperparameters can still work if I increase the system size (i.e. increase search dimensionality) or do I need to do a fresh optimal hyperparameter search.&lt;/p&gt;&#xA;&lt;p&gt;My response was, ideally yes, we would want to do a separate hyperparameter optimization since the problem changes the objective function landscape. I am looking forwards to your answers. Am I correct in saying this? If not, then what could be a more better response ?&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2020-10-25T08:04:29.083" Title="PSO. Hyperparameter Optimization for Similar Problems" Tags="|metaheuristics|local-search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5099" PostTypeId="2" ParentId="5098" CreationDate="2020-10-25T08:04:29.083" Score="4" Body="&lt;p&gt;In general you are correct, but the extent to which you are depends heavily on your objective function (and set of constraints, if you have any).&lt;/p&gt;&#xA;&lt;p&gt;As you say, when the problem changes, the landscape changes, and you will need a different set of hyperparameters. However, small changes, or changes limited to certain features, may alter the landscape in a way that does not require a different algorithm configuration. Starting the new tuning from the original good configuration may help.&lt;/p&gt;&#xA;&lt;p&gt;What you can do is to find the best configuration for some cases, and observe which hyperparameters change (and how) in relation to the features of the problem you are changing, and which don't. This may at least give you a better understanding of the landscapes generated your problem. For example, you may end up redefining certain hyperparameters as a function of the dimensionality, or of some landscape statistics.&lt;/p&gt;&#xA;&lt;p&gt;Whether this is worth the effort, it depends on how many times you will have to run your design under different conditions.&lt;/p&gt;&#xA;" OwnerUserId="224" LastActivityDate="2020-10-25T08:04:29.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5101" PostTypeId="2" ParentId="4903" CreationDate="2020-10-25T17:54:21.987" Score="4" Body="&lt;p&gt;Regarding the last question (how to link C++ and CPLEX), CPLEX has a C++ API that is thoroughly documented in the user manual. They also provide quite a few C++ examples (source code).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-10-25T17:54:21.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5102" PostTypeId="1" CreationDate="2020-10-26T00:47:47.870" Score="7" ViewCount="148" Body="&lt;p&gt;Let&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A \cdot X + B \preceq 0$$&lt;/span&gt; be a system of linear inequalities with &lt;span class=&quot;math-container&quot;&gt;$X \in \mathbb{R}^n$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$A\in \mathbb{R}^{m\times n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B \in \mathbb{R}^m$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$m \geq n$&lt;/span&gt;. According to Farkas lemma, exactly one of the following two is true:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\exists X \in \mathbb{R}^n$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$A\cdot X + B \preceq 0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\exists y \in \mathbb{R}^m_+$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$y^T \cdot A = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^T \cdot B &amp;gt; 0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Then lets define the convex optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ d^{\star} = \min q^T \cdot A \cdot A^T \cdot q \\ &#xA;s.t \begin{cases} q \succeq 0\\ B^T \cdot q \geq 0 \\ \textbf{1}^T \cdot q \geq 1\\ \textbf{1}^T \cdot q \leq 2 \end{cases}$$&lt;/span&gt;  Let &lt;span class=&quot;math-container&quot;&gt;$q^{\star}$&lt;/span&gt; be the solution to the above problem.&lt;/p&gt;&#xA;&lt;p&gt;The constraints are explained as follows: &lt;span class=&quot;math-container&quot;&gt;$q \succeq 0, B^T \cdot q \geq 0$&lt;/span&gt; are due to Farkas lemma, &lt;span class=&quot;math-container&quot;&gt;$1^T \cdot q \geq 1$&lt;/span&gt; makes sure that &lt;span class=&quot;math-container&quot;&gt;$q = 0$&lt;/span&gt; is not the solution and &lt;span class=&quot;math-container&quot;&gt;$1^T \cdot q \leq 2$&lt;/span&gt; makes sure that the search space is bounded. We have two possible outcomes:&lt;/p&gt;&#xA;&lt;p&gt;a) &lt;span class=&quot;math-container&quot;&gt;$d^{\star} = 0$&lt;/span&gt; hence &lt;span class=&quot;math-container&quot;&gt;$q^{\star} \cdot A = 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B^T \cdot q^{\star} \geq 0$&lt;/span&gt; therefore the system is NOT (strictly) feasible&lt;/p&gt;&#xA;&lt;p&gt;b) &lt;span class=&quot;math-container&quot;&gt;$d^{\star} &amp;gt; 0$&lt;/span&gt; hence &lt;span class=&quot;math-container&quot;&gt;$\not \exists q \succeq 0$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$q^T \cdot B &amp;gt; 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q^T \cdot A = 0$&lt;/span&gt; otherwise  &lt;span class=&quot;math-container&quot;&gt;$\frac{q}{1^T \cdot q }$&lt;/span&gt; would vanish the above function, therefore yielding a smaller value than &lt;span class=&quot;math-container&quot;&gt;$d^{\star}$&lt;/span&gt;. It follows that the linear system HAS a solution&lt;/p&gt;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&lt;p&gt;The above optimization problem can be solved with ellipsoid algorithm without dependency on the problem data, right? Indeed, I think, initialize the ellipsoid with the ball &lt;span class=&quot;math-container&quot;&gt;$\mathcal{B}(0, 2\cdot \sqrt{m})$&lt;/span&gt;, hence in a number of steps which does not depend on &lt;span class=&quot;math-container&quot;&gt;$A,B$&lt;/span&gt; its volume will decrease below some &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt;. Of course, this does not yield the solution (to LP) but can decide if the LP is feasible or not, in polynomial complexity for real coefficients LP ?! What am I missing ?&lt;/p&gt;&#xA;&lt;p&gt;This question is also &lt;a href=&quot;https://cs.stackexchange.com/questions/131486/strong-polynomial-time-algorithm-for-deciding-lp-feasibility&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3200" LastEditorUserId="3200" LastEditDate="2020-10-26T18:11:08.283" LastActivityDate="2020-10-26T18:11:08.283" Title="Is this a valid strong polynomial algorithm for deciding LP feasibility?" Tags="|linear-programming|convex-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5103" PostTypeId="1" AcceptedAnswerId="5117" CreationDate="2020-10-26T03:25:13.473" Score="2" ViewCount="769" Body="&lt;p&gt;I am using &lt;code&gt;Pyomo&lt;/code&gt; + &lt;code&gt;Ipopt&lt;/code&gt; as solver to solve a NLP problem. The problem is not extremely complex in terms of dimensionality and number of constraints. However, I am required to solve several thousands of instance of this model with different input parameters. Currently I am using a &lt;code&gt;for loop&lt;/code&gt; to loop over. Solving a single instance takes me ~ 1 second on &lt;code&gt;32 GB RAM Windows&lt;/code&gt; PC, &lt;code&gt;Python 3.7.3&lt;/code&gt;. That means I have to wait for hours before I am able to retrieve full optimization results.&lt;/p&gt;&#xA;&lt;p&gt;I profiled into where the time is getting consumed. The model building itself does not takes any time as such but its the model solving via &lt;code&gt;Ipopt&lt;/code&gt; that is performance determining here.&lt;/p&gt;&#xA;&lt;p&gt;I would like to know if someone has previously run into a similar problem and what are the common ways one can try to achieve some sort of performance gains.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;. From a &lt;a href=&quot;https://stackoverflow.com/questions/45873846/pyomo-takes-time-after-ipopt-solver-call&quot;&gt;question&lt;/a&gt; asked elsewhere I found out that:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Pyomo default behavior is to write an &lt;code&gt;*.nl&lt;/code&gt; file, then to call&#xA;IPOPT to process that file and produce a &lt;code&gt;*.sol&lt;/code&gt; file. Pyomo then&#xA;parses back in the &lt;code&gt;*.sol&lt;/code&gt; file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;From this, it seems that achieving speed gains might not be that easy with Pyomo. Still looking forward for the community response.&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="113" LastEditDate="2020-10-26T03:38:11.090" LastActivityDate="2020-10-28T07:20:26.867" Title="Pyomo + Ipopt. Speed Issue" Tags="|optimization|python|nonlinear-programming|pyomo|nonconvex-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5104" PostTypeId="1" CreationDate="2020-10-26T03:58:30.783" Score="2" ViewCount="225" Body="&lt;p&gt;As the title says, what are the tests for optimality or non-optimality I can build into my procedure and code to alert me that the model is going to be infeasible so I need to revise my constraints?&lt;/p&gt;&#xA;&lt;p&gt;Large models can take a quite a long time to build, run, and solve. Trying to avoid the hassle of running a model if from the getgo it was going to be non-optimal&lt;/p&gt;&#xA;" OwnerUserId="2955" LastActivityDate="2020-10-27T00:09:43.327" Title="Are there any standard &quot;tests&quot; that determine if a model will not optimize / no solution?" Tags="|optimization|algorithms|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5105" PostTypeId="2" ParentId="5104" CreationDate="2020-10-26T07:51:15.367" Score="3" Body="&lt;p&gt;TL;DR: You can do a lot with data QA, but it may not cover everything.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Let's assume that you have written your model &amp;quot;correctly&amp;quot;, i.e. there are no typos etc. Then, any infeasibility will come from your data. Therefore it is (very) good practice to perform rigorous data QA checks to make sure what comes in is sensible. For example, say you are looking to staff nurses in a hospital. Then you could check that the number of available shifts each day is greater than the shifts required. This was covered quite nicely in a &lt;a href=&quot;https://www.youtube.com/watch?v=2jkps9FYeKA&quot; rel=&quot;nofollow noreferrer&quot;&gt;webinar by Princeton Consultants&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This will catch some of the things. If you want to do more than that, then I suggest that you code up your constraints explicitly. So you use the lower and upper bounds of your variables to check whether it is at all possible to satisfy the constraints. This will catch more, but requires you to keep this list up to date with the model. It is though a good idea if your model building takes a long time.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2020-10-26T07:51:15.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5106" PostTypeId="1" CreationDate="2020-10-26T08:37:48.253" Score="5" ViewCount="748" Body="&lt;p&gt;Suppose that I have a pool with N nodes and I have to move the nodes one by one to another pool. For each move, consider a value on the edge linking the two pools. The goal is to find a order of nodes (for the N nodes) that minimizes the overall cut weights between the two pools.&lt;/p&gt;&#xA;&lt;p&gt;Is this considered a scheduling problem? If so what kind of scheduling problem?&lt;/p&gt;&#xA;&lt;p&gt;Is it NP-complete or NP-hard?&lt;/p&gt;&#xA;&lt;p&gt;Here is a pictorial explanation of the problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EGtit.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EGtit.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4273" LastEditorUserId="-1" LastEditDate="2020-10-27T01:59:03.347" LastActivityDate="2020-11-24T10:56:26.220" Title="How to determine if this problem is NP-HARD or NP-COMPLETE?" Tags="|optimization|modeling|scheduling|computational-complexity|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5107" PostTypeId="2" ParentId="5106" CreationDate="2020-10-26T09:23:31.530" Score="3" Body="&lt;p&gt;As nicely mentioned above by @Kuifje, the problem can be reduced to a minimum-cost maximum flow problem if &lt;em&gt;all the nodes&lt;/em&gt; have to be transferred.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;em&gt;only a subset of the nodes&lt;/em&gt; has to be transferred then this is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Graph_partition&quot; rel=&quot;nofollow noreferrer&quot;&gt;graph partitioning problem&lt;/a&gt; known: partitioning the vertices of a graph into two subsets such that the weight of the cut between the two subsets is minimum. It was proved NP-hard; the proof is given in the famous Garey &amp;amp; Johnson's book on computational complexity theory.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2020-10-26T19:00:51.383" LastActivityDate="2020-10-26T19:00:51.383" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5108" PostTypeId="2" ParentId="5106" CreationDate="2020-10-26T09:25:24.350" Score="5" Body="&lt;p&gt;If only a subset of nodes is to be transfered, and that the cardinality of this subset is undefined, then I agree with @LocalSolver. Otherwise (if all nodes have to be transfered &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;), I believe the problem is &lt;strong&gt;not NP-hard&lt;/strong&gt; (nor NP-complete):&lt;/p&gt;&#xA;&lt;p&gt;Consider the following graph :&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create a first layer with the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; nodes.&lt;/li&gt;&#xA;&lt;li&gt;Create a second layer with &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt; nodes : &lt;span class=&quot;math-container&quot;&gt;$1.1, 1.2, ...,1.n,...,n.1,n.2, n.n$&lt;/span&gt;. Link node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$i.1,...,i.n$&lt;/span&gt; forall &lt;span class=&quot;math-container&quot;&gt;$i=1,...,n$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Create a third layer with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; nodes. Link nodes &lt;span class=&quot;math-container&quot;&gt;$i.j$&lt;/span&gt; from layer &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; from layer &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;, forall &lt;span class=&quot;math-container&quot;&gt;$i=1,...,n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j=1,...,n$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Create a source node linked to layer &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and a sink node linked to layer &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;. Each of these edges have a flow that must equal exactly &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The graph is illustrated bellow:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WjTrM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WjTrM.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, a flow in this graph is a feasible solution of your problem (if my understanding is correct). Layer &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; will give you the order of the transfers. For example, if edge &lt;span class=&quot;math-container&quot;&gt;$(1,1.3)$&lt;/span&gt; is used, node &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; will be transfered in 3rd position. The third layer ensures there is exactly &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; node that is transfered per iteration.&lt;/p&gt;&#xA;&lt;p&gt;To have the cheapest solution, add the cost of the cut on the edges linking layers &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Therefore your problem is not NP-complete, nor NP-hard, as flow problems can be solved in polynomial time.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-10-26T10:46:29.090" LastActivityDate="2020-10-26T10:46:29.090" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5109" PostTypeId="1" AcceptedAnswerId="5127" CreationDate="2020-10-26T13:48:35.623" Score="2" ViewCount="677" Body="&lt;p&gt;I have heard it said that QP problems&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min f(x) = \frac 12 x^TAx + b^T x$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x \in P$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a symmetric matrix and &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is a polyhedron can all be solved exactly and in finite time (or it can be shown that there is no minimum in finite time). I can solve a few of the cases, but not all of them.&lt;/p&gt;&#xA;&lt;p&gt;I have done a couple of cases below, but they all involve &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; being bounded. I'm not sure how to deal with &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; being unbounded. I think there are two cases to do when &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is unbounded: &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is bounded below on &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is unbounded below on &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Case 1:&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is bounded, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is P.S.D.&lt;/p&gt;&#xA;&lt;p&gt;By boundedness a minimum exists. The minimum can be found by analyzing the KKT points. Indeed, we have &lt;span class=&quot;math-container&quot;&gt;$\nabla^2_{xx} L = Q$&lt;/span&gt; is P.S.D., so every KKT point satisfies the SOSC, so is a local minimum . But &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is convex, so any local minimum is global.&lt;/p&gt;&#xA;&lt;p&gt;Finding the KKT points for quadratic problems reduces to solving a bunch of systems of linear equations, which can be done exactly in finite time.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Case 2:&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is bounded, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is N.S.D.&lt;/p&gt;&#xA;&lt;p&gt;In this case &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is concave, and it is well-known that the minimum of a concave function over a polytope occurs at a vertex. Therefore we could find the minimum by examining the vertices, which can be done exactly in finite time to find.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Case 3:&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is bounded, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is indefinite.&lt;/p&gt;&#xA;&lt;p&gt;I know that the minimum will occur at a boundary point of the domain, but I don't know how to go further.&lt;/p&gt;&#xA;" OwnerUserId="3527" LastActivityDate="2020-10-30T16:23:01.787" Title="Why can quadratic functions over polyhedrons be minimized exactly in finite time?" Tags="|optimization|quadratic-programming|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5110" PostTypeId="2" ParentId="5109" CreationDate="2020-10-26T17:01:55.550" Score="5" Body="&lt;p&gt;[EDIT]: this answer is only valid for the &lt;strong&gt;convex&lt;/strong&gt; quadratic programming case.&lt;/p&gt;&#xA;&lt;p&gt;This comes from the solution set of the KKT conditions having a particular structure, that can be exploited in a simplex-like fashion (see the &lt;a href=&quot;http://pages.cs.wisc.edu/%7Ebrecht/cs838docs/wolfe-qp.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;seminal paper of Wolfe&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Consider a quadratic programming problem in standard form&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(QP) \ \ \ \min_{x} \ \ \ &amp;amp; \frac{1}{2}x^{T} Q x + c^{T} x\\&#xA;s.t. \ \ \ &amp;amp; A x = b,\\&#xA;x \geq 0.&#xA;\end{align}&lt;/span&gt;&#xA;and its dual&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(QD) \ \ \ \max_{x, y, s} \ \ \ &amp;amp; b^{T}y - \frac{1}{2}x^{T} Q x\\&#xA;s.t. \ \ \ &amp;amp; -Q x + A^{T}y + s = c,\\&#xA;s \geq 0.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, the first-order KKT conditions write&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;A x &amp;amp;= b,\\&#xA;-Qx + A^{T}y + s &amp;amp;= c\\&#xA;x_{j} s_{j} &amp;amp;= 0, \ \ j = 1, ..., n\\&#xA;x, s &amp;amp; \geq 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The mathematical details are given in Wolfe's paper but, essentially, one can use the simplex algorithm to find a solution to this system.&#xA;There are only a finite number of steps the simplex algorithm can take before converging, hence finite-time termination.&#xA;The &lt;strong&gt;exact&lt;/strong&gt; part relies on the fact that all linear systems are solved exactly, which is possible in practice if the problem's data is rational.&lt;/p&gt;&#xA;&lt;p&gt;Some final remarks:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Simplex-QP algorithm is finite-time, but is not polynomial&lt;/li&gt;&#xA;&lt;li&gt;Interior-point methods run in polynomial time, but do not produce exact solutions&lt;/li&gt;&#xA;&lt;li&gt;If one allows for quadratic constraints, then &amp;quot;exactness&amp;quot; is generally not possible in practice, since the solution may be irrational (e.g., &lt;span class=&quot;math-container&quot;&gt;$\sqrt{2}$&lt;/span&gt; cannot be represented using finite-precision arithmetic).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="3598" LastEditDate="2020-10-26T19:51:37.403" LastActivityDate="2020-10-26T19:51:37.403" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5111" PostTypeId="2" ParentId="5104" CreationDate="2020-10-26T19:09:41.280" Score="3" Body="&lt;p&gt;I don't see any way to avoid spending the time building the model, since you will presumably need something equivalent to a built model to test whether you have a problem with your constraints. Also, if you problem is a feasibility problem (find a feasible solution) rather than an optimality problem (find an optimal solution), I doubt there will be any free lunch to be had.&lt;/p&gt;&#xA;&lt;p&gt;For a real-world optimization problem (making optimal decisions for an extant system), you might ask the end-user to specify a solution that they know is (or expect should be) feasible. It does not have to be a &amp;quot;good&amp;quot; solution, just a workable one. If you are working with parameter values that have not occurred in the past (for instance, dealing with inventory problems where supply parameters are speculative due to an unprecedented pandemic's disruption of the supply chain), you can at least ask the user for a solution they believe should work given those parameters. Given such a solution, you then plug it into all the constraints and look for violations. If a constraint is violated, either it is wrong, too tight (RHS value needs tweaking), or the user's solution is not in fact feasible. (You might go back to the user, show the infeasibility, and ask for either a different solution or a looser value for any violated constraint.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-10-26T19:09:41.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5112" PostTypeId="1" AcceptedAnswerId="5113" CreationDate="2020-10-26T21:16:04.047" Score="0" ViewCount="446" Body="&lt;p&gt;This is the shortest path problem. I've used a model where we can find the shortest path between the source and a specified destination.&lt;/p&gt;&#xA;&lt;p&gt;The idea behind this model is that we assign a flow of 1 for the source and -1 for the destination and every other node has a flow of 0 because they're acting as transfer only.&lt;/p&gt;&#xA;&lt;p&gt;However, I want to find the shortest path for every node in the graph from the source. It's similar to what the Dijkstra algorithm does however I want to use linear programming.&lt;/p&gt;&#xA;&lt;p&gt;How can I adapt the model to give me the shortest path for every node in the graph from the source?&#xA;Here's how the original model I used looks like.&lt;/p&gt;&#xA;&lt;p&gt;[![graph][1]][1]&lt;/p&gt;&#xA;&lt;p&gt;Where x12 is the arc from edge 1 to edge 2.&lt;/p&gt;&#xA;&lt;p&gt;The basic idea would be to have all edges with a flow of -1 however when I try this it doesn't work.&#xA;Any help would be appreciated.&#xA;the graph used :&#xA;[1]: &lt;a href=&quot;https://i.stack.imgur.com/x8yuT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/x8yuT.png&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4077" LastEditorUserId="500" LastEditDate="2020-10-27T03:10:01.080" LastActivityDate="2023-07-28T07:45:30.270" Title="How can I find the shortest path for all nodes in a graph from a source $s$?" Tags="|optimization|linear-programming|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5113" PostTypeId="2" ParentId="5112" CreationDate="2020-10-26T21:28:18.627" Score="5" Body="&lt;p&gt;Dijkstra's algorithm finds a shortest path from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to all other nodes in &lt;span class=&quot;math-container&quot;&gt;$N \setminus\{s\}$&lt;/span&gt;.  The corresponding linear programming problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{(i,j)\in A} c_{i,j} x_{i,j}$$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{(i,j)\in A} x_{i,j} - \sum_{(j,i)\in A} x_{j,i} = &#xA;\begin{cases}&#xA;n-1 &amp;amp;\text{for $i=s$}\\&#xA;-1 &amp;amp;\text{for $i\in N \setminus \{s\}$}&#xA;\end{cases}$$&lt;/span&gt;&#xA;and &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}\ge 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in A$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;That is, node &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; has a supply of &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt;, and every other node has a demand of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-10-27T12:39:05.370" LastActivityDate="2020-10-27T12:39:05.370" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5114" PostTypeId="2" ParentId="5104" CreationDate="2020-10-27T00:09:43.327" Score="2" Body="&lt;p&gt;Infeasibility may come from:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Data that feed your optimization model.&lt;/li&gt;&#xA;&lt;li&gt;The constraints defined in your model.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;To prevent the troubles implied by 1), you have to check drastically the input data that feeds your optimization model. The goal is to ensure that the input data respect the conditions for which the model is supposed to work properly. This is a common software engineering practice; for details, have a look at the &lt;a href=&quot;https://en.wikipedia.org/wiki/Design_by_contract&quot; rel=&quot;nofollow noreferrer&quot;&gt;design by contract&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In addition, if you have basic constraints in your model that may lead to basic infeasibilities, then check them before the launch of the resolution. You can catch and then explain these infeasibilities to the users very early and quickly in the optimization process.&lt;/p&gt;&#xA;&lt;p&gt;To prevent troubles implied by 2), you have to follow a &lt;a href=&quot;https://en.wikipedia.org/wiki/Goal_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;goal programming&lt;/a&gt; modeling approach. Many constraints defined by clients are not really constraints but objectives in effect: if the constraint can be satisfied, this is good, otherwise try to make it violated as little as possible. Remind that for operations the &amp;quot;no solution found&amp;quot; answer is useless.&lt;/p&gt;&#xA;&lt;p&gt;Finally, testing the possible suboptimality of the resolution before the resolution is of course impossible. The only way to make your users happy is to ensure, by extensive testing on realistic input data, that your optimization software output quality solutions in short running times, if possible in minutes. This can be done by carefully choosing the solution technique to tackle your problem efficiently, even if approximately.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-10-27T00:09:43.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5115" PostTypeId="1" CreationDate="2020-10-27T04:08:50.133" Score="4" ViewCount="323" Body="&lt;p&gt;Consider a linear programming (LP) problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;M(b) \in \arg\min_x \{ c^\top x : Ax=b, x \ge 0   \}.&#xA;\end{align}&lt;/span&gt;&#xA;Suppose the LP is feasible and bounded for all values of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. We know that &lt;span class=&quot;math-container&quot;&gt;$M(b)$&lt;/span&gt; may not be a function, as &lt;span class=&quot;math-container&quot;&gt;$M(b)$&lt;/span&gt; may not be unique. If at a given &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, the LP has a unique solution, then &amp;quot;locally&amp;quot; M(b) is a linear function of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. This is because the basic feasible solution is &lt;span class=&quot;math-container&quot;&gt;$x_{B}=B^{-1}b$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is the optimal basis. So, for sufficiently small changes in &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, the optimal basis &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; does not change, so the optimal solution will be  &lt;span class=&quot;math-container&quot;&gt;$M(b+\hat{b})=B^{-1}b + B^{-1}\hat{b}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\hat{b}$&lt;/span&gt; is a small perturbation in &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My question is what can be said for more global changes where the optimal basis changes? Does &lt;span class=&quot;math-container&quot;&gt;$M(b)$&lt;/span&gt; have  a piecewise linear behaviour?&lt;/p&gt;&#xA;" OwnerUserId="2982" LastActivityDate="2020-10-27T18:52:14.867" Title="the set of optimal solutions of a linear programming (LP) problem as a mapping of right-hand side" Tags="|optimization|linear-programming|global-optimality|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5116" PostTypeId="2" ParentId="5103" CreationDate="2020-10-27T06:20:56.133" Score="2" Body="&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; This is not exactly an answer to this question but its a piece of information I found quite useful.&lt;/p&gt;&#xA;&lt;p&gt;I ran the same piece of code on both Windows PC (32 GB RAM, Windows 10) and Macbook Pro (4GB RAM, Catalina) and found the code to be roughly 5 times faster on Mac. I have little idea why this is happening but it could be due to the pyomo file processing.&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="113" LastEditDate="2020-10-28T07:20:26.867" LastActivityDate="2020-10-28T07:20:26.867" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5117" PostTypeId="2" ParentId="5103" CreationDate="2020-10-27T12:21:58.373" Score="3" Body="&lt;p&gt;Mac probably has a solid state drive, so if your Windows machine doesn't have one (or has a worse one), I/O speed could be your bottleneck.&lt;/p&gt;&#xA;&lt;p&gt;For small runtimes like these, your version of Python &amp;amp; Pyomo can also be the culprit.&lt;/p&gt;&#xA;&lt;p&gt;Νow when it comes to making the process faster, there's no general solution I'm afraid other than profiling the Python code and see if you can optimise the code on your end. What you want to see is how many &lt;strong&gt;seconds&lt;/strong&gt; are spent in each Python routine (as opposed to percentages), so that you can derive where the bulk of your overall runtime is spent.&lt;/p&gt;&#xA;&lt;p&gt;One thing you could try to speed things up would be to run multiple instances of these problems in parallel using the Python multiprocessing toolbox. Since the problems are similar you don't have to worry about writing asynchronous code to get good scaling, which makes things much easier.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-10-27T12:21:58.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5118" PostTypeId="2" ParentId="5115" CreationDate="2020-10-27T18:52:14.867" Score="3" Body="&lt;p&gt;In general, if the LP is bounded, the optimal set &lt;span class=&quot;math-container&quot;&gt;$M(b)$&lt;/span&gt; is a face of the feasible set &lt;span class=&quot;math-container&quot;&gt;$P = \{ x | Ax = b, x \geq 0\}$&lt;/span&gt; (which is a polyhedral set).&#xA;In fact, &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a function, but one that maps a vector &lt;span class=&quot;math-container&quot;&gt;$b \in \mathbb{R}^{m}$&lt;/span&gt; to a &lt;strong&gt;set&lt;/strong&gt; of points &lt;span class=&quot;math-container&quot;&gt;$M(b) \subseteq \mathbb{R}^{n}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Thus, in order to talk about piece-wise linearity of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, you must define what you mean by piece-wise linearity of such a function.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;em&gt;objective function&lt;/em&gt; of an LP is a piece-wise linear function of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, though.&lt;/p&gt;&#xA;&lt;p&gt;That being said, take the example&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_{x, y} \ \ \ &amp;amp; -x - y\\&#xA;\text{s.t.} \ \ \ &amp;amp; x + y = b\\&#xA;&amp;amp; x, y \geq 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here,&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$b &amp;lt; 0$&lt;/span&gt;, the LP is infeasible.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$M(0) = \{(0, 0)\}$&lt;/span&gt; (a singleton)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$M(b &amp;gt; 0) = \{(x, y) \geq 0 \ | \ x + y = b\}$&lt;/span&gt; (a one-dimensional segment)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;so the dimension of &lt;span class=&quot;math-container&quot;&gt;$M(b)$&lt;/span&gt; may change for small variations in &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Two side remarks:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;depending on the data &lt;span class=&quot;math-container&quot;&gt;$A, c$&lt;/span&gt;, there may exist values of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; for which the LP is unbounded or infeasible, so the assumption that &lt;span class=&quot;math-container&quot;&gt;$LP$&lt;/span&gt; is bounded and feasible for all values of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; may not hold in practice.&lt;/li&gt;&#xA;&lt;li&gt;Changing the primal right-hand side corresponds to changing the dual objective. This perspective may simplify the analysis.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2020-10-27T18:52:14.867" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5119" PostTypeId="1" AcceptedAnswerId="5121" CreationDate="2020-10-27T22:25:52.937" Score="7" ViewCount="669" Body="&lt;p&gt;I'm just reading [1]. The authors use a neural network to solve capacitated vehicle routing problems through iterative generation of tours by solving a price-collecting traveling salesman problem in the action selection step of the neural network.&lt;/p&gt;&#xA;&lt;p&gt;In the conclusion they state that other promising approaches to use machine learning to help solve discrete optimization problems would be to learn the selection of local search operators.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The success of local search methods in tackling these problems suggests an orthogonal reinforcement learning approach, in which the action space is a set of cost-improving local moves, could be successful.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I was very surprised that this has not been studied before, since it seems kind of an obvious avenue to take (no need to encode constraints directly in the NN as it can be handled by the search operators). A quick search only turned up [2], which seems to generate initial solutions via reinforcement learning and then improves these solutions with local search.&lt;/p&gt;&#xA;&lt;p&gt;Topics like learning to branch in/decompose mixed-integer programs have been studied since at least 2014 [3-5]. I would argue that those topics have much higher barriers of entry than learning search operator selection for VRPs.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone know of and can point me to research that studies learning the selection of local search operators (think relocate vs. swap)? Does not need to be vehicle routing.&lt;/p&gt;&#xA;&lt;sup&gt;&#xA;[1] Delarue A., Anderson R., Tjandraatmadja C. (2020). Reinforcement Learning with Combinatorial Actions: An Application to Vehicle Routing. https://arxiv.org/abs/2010.12001.&#xA;&lt;p&gt;[2] Zhao, J., Mao, M., Zhao, X., &amp;amp; Zou, J. (2020). A hybrid of deep reinforcement learning and local search for the vehicle routing problems. IEEE Transactions on Intelligent Transportation Systems.&lt;/p&gt;&#xA;&lt;p&gt;[3] He, H., Daume III, H., &amp;amp; Eisner, J. M. (2014). Learning to search in branch and bound algorithms. In Advances in neural information processing systems (pp. 3293-3301).&lt;/p&gt;&#xA;&lt;p&gt;[4] Khalil, E. B., Le Bodic, P., Song, L., Nemhauser, G., &amp;amp; Dilkina, B. (2016). Learning to branch in mixed integer programming. In Thirtieth AAAI Conference on Artificial Intelligence.&lt;/p&gt;&#xA;&lt;p&gt;[5] Kruber, M., Lübbecke, M. E., &amp;amp; Parmentier, A. (2017). Learning when to use a decomposition. In International Conference on AI and OR Techniques in Constraint Programming for Combinatorial Optimization Problems (pp. 202-210). Springer, Cham.&#xA;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="869" LastEditorUserId="869" LastEditDate="2020-10-28T10:11:44.687" LastActivityDate="2022-03-18T07:43:59.547" Title="Learning local search operator selection" Tags="|reference-request|combinatorial-optimization|machine-learning|local-search|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5120" PostTypeId="2" ParentId="5119" CreationDate="2020-10-27T23:02:26.823" Score="5" Body="&lt;p&gt;I think you may be interested in the topic of hyper-heuristics. Very loosely, given a bunch of local search operators for a problem, the idea is to combine those local search operators to form a short chains. Each chain is a sequence of the local search operators, and so each chain itself acts like a heuristic for the original problem. Typically, the work in this field tries to come up with a method to learn those chains, and also tries to come up with an execution schedule for applying the heuristics (which is what you are interested in). Personally, I am not very familiar with this line of work, but you  may find the thesis of Chung-Yao Chuang as a starting point. You can find a copy of his thesis online by searching for: Combining Multiple Heuristics: Studies on Neighborhood-base Heuristics and Sampling-based Heuristics.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2020-10-27T23:22:20.740" LastActivityDate="2020-10-27T23:22:20.740" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5121" PostTypeId="2" ParentId="5119" CreationDate="2020-10-28T09:34:33.237" Score="6" Body="&lt;p&gt;In addition to the hyperheuristics mentioned by batwing, you can look for the broader topic of (automatic) algorithm selection and configuration.&lt;/p&gt;&#xA;&lt;p&gt;Generally speaking, algorithm selection is the task of choosing one algorithm among a set of possible ones, based on some information (features) about the problem and instance you want to solve. Configuration is the task of finding the best combination of parameter values of a given algorithm, for a problem/instance. The line between these two task is blurred, and you can combine selection and configuration, perform configuration based on features, etc.&lt;/p&gt;&#xA;&lt;p&gt;If you consider a parameter as a choice you don't make in the algorithm design phase, but leave it to the moment you effectively run the algorithm, then you can naturally extend the idea to the choice at runtime of an operator, among a set of possible ones, as a categorical parameter. Likewise, if you think you have a set of algorithms that only differ for the selection operator, then by choosing one operator you are effectively selecting one algorithm. Which task is more appropriate for your case, will depend on what you have (observable features, experience with a certain tool, implementation of your method).&lt;/p&gt;&#xA;&lt;p&gt;These are, however, learning tasks, where you want to find a mapping between the instance space and the algorithm/parameter space, such that some performance metric is optimized (maximization or minimization of solution quality, minimization or running time, etc). Relevant discussion on this site include &lt;a href=&quot;https://or.stackexchange.com/questions/304/use-of-machine-learning-techniques-to-determine-parameter-values&quot;&gt;this question&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/a/891/224&quot;&gt;this answer&lt;/a&gt;. An introduction to algorithm selection can be found e.g. in these &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0004370216300388#se0080&quot; rel=&quot;nofollow noreferrer&quot;&gt;two&lt;/a&gt; &lt;a href=&quot;https://www.mitpressjournals.org/doi/full/10.1162/evco_a_00242&quot; rel=&quot;nofollow noreferrer&quot;&gt;papers&lt;/a&gt; or on &lt;a href=&quot;https://www.coseal.net/algorithm-selection/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this webpage&lt;/a&gt;. For configuration, &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-642-21434-9_3&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; or &lt;a href=&quot;http://www.aclib.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this website&lt;/a&gt; and references therein. For how to apply configuration to generate algorithms, you can take a look at &lt;a href=&quot;https://dl.acm.org/doi/pdf/10.1145/2076450.2076469?casa_token=I1gNkN4gkYgAAAAA:4OezyJZ66qr-XePD4d3BoRV2OEVvd-oMXvHFE31EJCVMt6DPoAUW3NRHOoKLoL0P2EnfEctrczFZ-A&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;.&#xA;You can also look for &amp;quot;automatic algorithm design&amp;quot; and &amp;quot;hyperparameter optimization&amp;quot; (how configuration is usually called in ML).&lt;/p&gt;&#xA;&lt;p&gt;Hyperheuristics are a related approach, that combines low-level, generic heuristics to produce an algorithm. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Hyper-heuristic&quot; rel=&quot;nofollow noreferrer&quot;&gt;wikipedia page&lt;/a&gt; has several links to explore, including &lt;a href=&quot;https://mustafamisir.github.io/hh.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this bibliography&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A line of work you might find of interest uses &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0305054818300315&quot; rel=&quot;nofollow noreferrer&quot;&gt;knowledge about what a good VRP solution look like&lt;/a&gt; to &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0305054819300024&quot; rel=&quot;nofollow noreferrer&quot;&gt;design a good algorithm for VRP&lt;/a&gt; and some variants, and &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0305054819300668&quot; rel=&quot;nofollow noreferrer&quot;&gt;very large instances&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Edited again to add: &lt;a href=&quot;https://arxiv.org/pdf/2006.08246.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this preprint&lt;/a&gt; uses Reinforcement Learning to dynamically learn heuristic selection policies, it's probably the closest to what you're looking for.&lt;/p&gt;&#xA;&lt;p&gt;As a sidenote, I think that titles containing &amp;quot;Learning to...&amp;quot; mostly come from researchers in ML, by using different keywords you can find more works coming from areas such as search heuristics/optimization.&lt;/p&gt;&#xA;" OwnerUserId="224" LastEditorUserId="224" LastEditDate="2020-10-30T15:21:42.610" LastActivityDate="2020-10-30T15:21:42.610" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5124" PostTypeId="1" CreationDate="2020-10-28T18:15:42.737" Score="5" ViewCount="131" Body="&lt;p&gt;I am solving a non-linear mixed-integer programme with BARON. The objective function looks like &lt;span class=&quot;math-container&quot;&gt;$\big( \sum_i x_i \big) \cdot \big(\prod_i e^{-y_i}\big)$&lt;/span&gt; (binary &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and real-valued &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;) and it has some quadratic constraints.&lt;/p&gt;&#xA;&lt;p&gt;My problem is that I have an exponential number of linear constraints. I would like to add them in a way analogous to the Lazy Constraint callbacks of CPLEX and Gurobi. Does Baron support anything like this? Are there other solvers which allow lazy constraints and also have out-of-the-box support for weird non-linearities such as the above ones?&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2020-10-29T07:40:11.287" LastActivityDate="2020-10-29T07:40:11.287" Title="Is there a way to use lazy constraints with Baron?" Tags="|nonlinear-programming|nonconvex-programming|baron|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5125" PostTypeId="1" AcceptedAnswerId="5126" CreationDate="2020-10-29T23:26:43.903" Score="6" ViewCount="423" Body="&lt;p&gt;I have a problem which is mainly linear but it has a non-linear component. The objective function is&lt;/p&gt;&#xA;&lt;p&gt;obj = Linear_term + &lt;span class=&quot;math-container&quot;&gt;$c*f(x,y)$&lt;/span&gt; where,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f(x,y) = (G_1 x_1 + G_2 x_2)/(x_1 + x_2)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The decision variables and parameters are as follows.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt; b_1 &amp;lt;1$&lt;/span&gt; :: decision variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt;b_2 &amp;lt;1$&lt;/span&gt; :: decision variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c&amp;gt;1$&lt;/span&gt; :: integer decision variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Q_1$&lt;/span&gt; :: constant&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Q_2$&lt;/span&gt; :: constant&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$G_1$&lt;/span&gt; :: constant&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$G_2$&lt;/span&gt; :: constant&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1 = Q_1 * b_1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_2 = Q_2 * b_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&lt;p&gt;How I can model &lt;span class=&quot;math-container&quot;&gt;$cf(x,y)$&lt;/span&gt; in MIP?&#xA;Please note it is also probable that more than two decision variables of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; appear in the last equation.&lt;/p&gt;&#xA;&lt;p&gt;How do I break this fraction and model it in linear form?&lt;/p&gt;&#xA;" OwnerUserId="4345" LastEditorUserId="491" LastEditDate="2020-10-30T03:07:09.273" LastActivityDate="2020-10-30T12:53:05.790" Title="How to linearize $f(x,y) = (ax+by)/(x+y)$?" Tags="|linear-programming|modeling|linearization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5126" PostTypeId="2" ParentId="5125" CreationDate="2020-10-29T23:34:50.257" Score="8" Body="&lt;p&gt;Without the &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; variable, you could do a Charnes-Cooper transformation, followed by a linearization of a product of a continuous and binary variable, as shown in my answer &lt;a href=&quot;https://math.stackexchange.com/questions/3500493/doing-a-charnes-cooper-transformation-with-matrices-and-an-zero-one-constraint/3500608#3500608&quot;&gt;https://math.stackexchange.com/questions/3500493/doing-a-charnes-cooper-transformation-with-matrices-and-an-zero-one-constraint/3500608#3500608&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; has a small enough upper bound, you can solve a separate problem for each value of &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and take the best.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, you can introduce a variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to replace &lt;span class=&quot;math-container&quot;&gt;$c\cdot f(x,y)$&lt;/span&gt; in the objective function and impose constraint &lt;span class=&quot;math-container&quot;&gt;$(x_1+x_2)z=c(G_1 x_1+G_2 x_2)$&lt;/span&gt;, which you can linearize by linearizing the resulting products of continuous and binary variables.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-10-30T12:53:05.790" LastActivityDate="2020-10-30T12:53:05.790" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5127" PostTypeId="2" ParentId="5109" CreationDate="2020-10-30T03:18:07.137" Score="5" Body="&lt;p&gt;I would point to a paper by Vavasis &amp;quot;Quadratic Programming is in NP&amp;quot;&#xA;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/002001909090100C&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sciencedirect.com/science/article/abs/pii/002001909090100C&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;His proof shows that the optimal solution to minimizing a QP over a polyhedron is in fact the solution to a certain set of linear equations, and hence the optimal solution has a polynomial encoding size in the bit model. So, as a brute force, you could enumerate rational points in a given region to find such a point in finite time.&lt;/p&gt;&#xA;&lt;p&gt;But the proof does one bit better. It essentially outlines an exponential-time algorithm to solve the problem. Let me explain.&lt;/p&gt;&#xA;&lt;p&gt;The proof shows that the optimal solution lies in the relative interior of a face of the polyhedron (that defines the feasible region). If the objective is convex, then it may lie on the actual interior of the feasible region. Otherwise, if the objective is nonconvex, then the objective function pushes towards boundaries.  Hence, let's look at a facet of the polyhedron. If we restrict to a facet, then we can project into a lower dimension, and rethink the problem. Is the objective convex after the projection? If so, then solve like a normal convex QP.  Otherwise, push to other faces.&lt;/p&gt;&#xA;&lt;p&gt;Hence, the brute-force algorithm is:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be the polyhedron defining the feasible region.&lt;/li&gt;&#xA;&lt;li&gt;Compute all faces of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;. This means faces of any dimension.&lt;/li&gt;&#xA;&lt;li&gt;For each face, check if the objective, when projected into that face, is convex.&lt;/li&gt;&#xA;&lt;li&gt;If so, compute the optimal solution in that face and store it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Lastly, compare all the solutions that you found and return the optimal one.&lt;/p&gt;&#xA;" OwnerUserId="3043" LastEditorUserId="3391" LastEditDate="2020-10-30T16:23:01.787" LastActivityDate="2020-10-30T16:23:01.787" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5128" PostTypeId="2" ParentId="5109" CreationDate="2020-10-30T11:53:28.177" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Deterministic_global_optimization#:%7E:text=Deterministic%20global%20optimization%20is%20a,one%2C%20within%20some%20predefined%20tolerance.&quot; rel=&quot;nofollow noreferrer&quot;&gt;Deterministic global optimisation&lt;/a&gt; algorithms can solve all problems up to and including algebraic MINLPs (which of course includes QPs) to global optimality in finite time, up to an arbitrary tolerance (which, for all intents and purposes is equivalent to &amp;quot;exactly&amp;quot; when it comes to floating point numbers). That time might be exponentially long, but is still finite. &lt;a href=&quot;https://books.google.co.uk/books?hl=en&amp;amp;lr=&amp;amp;id=vmKJ2htoWnkC&amp;amp;oi=fnd&amp;amp;pg=PA271&amp;amp;dq=neumaier%20acta%20numerica&amp;amp;ots=__k0gOSRVW&amp;amp;sig=rD5l-9aqguL3fXMeKTXWym-cVdI&amp;amp;redir_esc=y#v=onepage&amp;amp;q=neumaier%20acta%20numerica&amp;amp;f=false&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neumaier&lt;/a&gt; provided an extensive review of the methods in 2004 if you're curious about the fundamentals.&lt;/p&gt;&#xA;&lt;p&gt;This is the class of algorithms used in global optimisation solvers such as Couenne, BARON, ANTIGONE, and our own Octeract Engine.&lt;/p&gt;&#xA;&lt;p&gt;The underlying reason is that certain classes of convex/linear relaxations such as generalised McCormick relaxations or &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;BB relaxations have been proven to improve their bound (quadraticaly but that's of secondary import here) as the domain is reduced (typically through branching). &lt;a href=&quot;https://link.springer.com/article/10.1007/s10898-011-9685-2&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mitsos&lt;/a&gt; has a nice proof of the convergence rate for both classes of relaxations.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-10-30T11:53:28.177" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5129" PostTypeId="1" AcceptedAnswerId="5130" CreationDate="2020-10-30T12:56:29.310" Score="7" ViewCount="392" Body="&lt;p&gt;I’m sorry to bother you with this simple question. I would like to model a simple model of the minimum cover vertex set problem. I believe that the original problem is such as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \quad \sum_{v\in V} x_v&#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_u + x_v \ge 1 \quad \forall (u,v) \in E &#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_v$&lt;/span&gt; is a binary variable, which takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if  vertex &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is included in the minimum set and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&#xA;I have added another binary variable &lt;span class=&quot;math-container&quot;&gt;$z_{uv}$&lt;/span&gt; with the following constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{(u,v)\in E} z_{uv} \ge k    &#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is a parameter and &lt;span class=&quot;math-container&quot;&gt;$z_{uv}$&lt;/span&gt; equals &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if vertex &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is in the set  while vertex &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; is not a member of the minimum set.&lt;/p&gt;&#xA;&lt;p&gt;So, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is variable controling the vertices while &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; controls the edges.&lt;/p&gt;&#xA;&lt;p&gt;I hope you can help me with modeling the second constraint.&lt;/p&gt;&#xA;&lt;p&gt;I’m confused about the interaction between if nodes are decided to be in the set (i.e., &lt;span class=&quot;math-container&quot;&gt;$x_v = 1$&lt;/span&gt;) and the edge connected to it.&#xA;P.S the edges are defined as &lt;span class=&quot;math-container&quot;&gt;$e=(u,v)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$u,v$&lt;/span&gt; are the vertices incident to that edge.&lt;/p&gt;&#xA;&lt;p&gt;Thank you so much in advance.&lt;/p&gt;&#xA;" OwnerUserId="4347" LastEditorUserId="2556" LastEditDate="2020-10-30T13:13:03.377" LastActivityDate="2020-10-30T13:13:03.377" Title="MILP formulation for minimum set Vertex cover problem" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5130" PostTypeId="2" ParentId="5129" CreationDate="2020-10-30T13:04:05.467" Score="9" Body="&lt;p&gt;You can use the following model on the graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \quad \sum_{v\in V} x_v&#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_u + x_v &amp;amp;\ge 1 \quad &amp;amp;\forall (u,v) \in E \\&#xA;\sum_{(u,v)\in E} z_{uv} &amp;amp;\ge k \\&#xA;z_{uv} &amp;amp;\le x_v \quad &amp;amp;\forall (u,v) \in E\\&#xA;z_{uv} &amp;amp;\le 1-x_u \quad &amp;amp;\forall (u,v) \in E\\&#xA;x_v&amp;amp;\in \{0,1\} \quad &amp;amp;\forall v \in V\\&#xA;z_{uv} &amp;amp;\in \{0,1\}\quad &amp;amp;\forall (u,v) \in E&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I believe your question specifically refers to the following constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{uv} \le x_v \quad \forall (u,v) \in E$&lt;/span&gt; : ensures that when &lt;span class=&quot;math-container&quot;&gt;$z_{uv}$&lt;/span&gt; takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, vertex &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is selected and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{uv} \le 1-x_u \quad \forall (u,v) \in E$&lt;/span&gt; : ensures that when &lt;span class=&quot;math-container&quot;&gt;$z_{uv}$&lt;/span&gt; takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, vertex &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; is left out&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-10-30T13:09:27.123" LastActivityDate="2020-10-30T13:09:27.123" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5131" PostTypeId="2" ParentId="5119" CreationDate="2020-10-30T16:08:49.990" Score="2" Body="&lt;p&gt;Elementary learning approaches to select local search operators dynamically - that is, during the search - work well in practice. Here is what we call &amp;quot;elementary learning approaches&amp;quot;. Given a pool of local search moves, you can score each move during the search. For example, if one move succeeds at an iteration, increase its score, otherwise decrease it. Then, when choosing the next move to apply, consider the score of the moves in such a way that moves with higher scores has a higher probability to be chosen.&lt;/p&gt;&#xA;&lt;p&gt;Such approaches can be infinitely refined. For instance, if your search strategy is not a pure descent (for example, a simulated annealing heuristic), then you can give a bonus to moves than improve strictly the objective value, in comparison with the moves which are accepted because diversifying the search (ex: neutral moves). Then, you can decide to stop attempting some moves when their score is below a given threshold because you consider their probability of success too low. On the contrary, you can decide to shuffle the scores in order to initialize the probability to be chosen, after a number of iterations. This is the famous dilemma between exploration and exploitation in &lt;a href=&quot;https://en.wikipedia.org/wiki/Reinforcement_learning&quot; rel=&quot;nofollow noreferrer&quot;&gt;reinforcement learning&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Such an approach being &amp;quot;elementary&amp;quot;, there are not so many papers published about it. The idea is quite simple and very practical, with a lot of experiments to perform to tune up all the machinery. This approach is implemented inside LocalSolver, when it comes to the local search techniques, for both discrete and continuous models. It allows us to automatically adapt, for cheap in terms of running time, the selection of the next move to apply among hundreds of possible moves, to the instance which is tackled.&lt;/p&gt;&#xA;&lt;p&gt;More tuning can be done by offline learning large datasets, as explained above by Alberto. But to start with, on a practical optimization project, we advise avoiding such kinds of tuning (online or offline). Having just a few local search moves following a random choice with equal probabilities at each iteration is generally enough to make a business client happy with your optimization solution.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-10-30T16:08:49.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5132" PostTypeId="1" CreationDate="2020-10-31T01:52:30.883" Score="3" ViewCount="91" Body="&lt;p&gt;I'm trying to solve a flexible job shop problem variant that has precedence constraints on jobs along with a few other issues. We have a MIP formulation and also a simulated annealing algorithm to solve at the moment.  But now we would like to allow preemption of jobs (leaving a job and coming back to finish it later, possibly times).&lt;br /&gt;&#xA;Do you have any thoughts on how to model the problem to allow for preemption?&lt;/p&gt;&#xA;" OwnerUserId="3043" LastEditorUserId="123" LastEditDate="2020-10-31T10:42:45.407" LastActivityDate="2020-10-31T10:42:45.407" Title="Flexible Job Shop with Preemption" Tags="|optimization|integer-programming|solver|scheduling|simulated-annealing|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5133" PostTypeId="1" AcceptedAnswerId="5134" CreationDate="2020-10-31T19:49:16.537" Score="4" ViewCount="968" Body="&lt;p&gt;As a following up for my question for modeling a simple moded of the minimum set vertex cover problem, which is shown next. I would like to have your help in modeling this problem using Python or MATLAB. I believe that each edge with its origin vertex and destination vertex as a binary variable will solve the problem. I'm a little confused about how this variable will represent both vertices.&lt;br /&gt;&#xA;The problem can be shown as graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; where we want to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \quad \sum_{v\in V} x_v&#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_u + x_v &amp;amp;\ge 1 \quad &amp;amp;\forall (u,v) \in E \\&#xA;\sum_{(u,v)\in E} z_{uv} &amp;amp;\ge k \\&#xA;z_{uv} &amp;amp;\le x_v \quad &amp;amp;\forall (u,v) \in E\\&#xA;z_{uv} &amp;amp;\le 1-x_u \quad &amp;amp;\forall (u,v) \in E\\&#xA;x_v&amp;amp;\in \{0,1\} \quad &amp;amp;\forall v \in V\\&#xA;z_{uv} &amp;amp;\in \{0,1\}\quad &amp;amp;\forall (u,v) \in E&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4347" LastEditorUserId="491" LastEditDate="2020-11-02T02:57:57.283" LastActivityDate="2020-11-02T02:57:57.283" Title="MILP Minimum set Vertex cover coding by Python or MATLAB?" Tags="|python|cplex|matlab|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5134" PostTypeId="2" ParentId="5133" CreationDate="2020-10-31T20:14:07.550" Score="6" Body="&lt;p&gt;In Python, with &lt;a href=&quot;https://github.com/coin-or/pulp&quot; rel=&quot;noreferrer&quot;&gt;pulp&lt;/a&gt; and &lt;a href=&quot;https://github.com/networkx/networkx&quot; rel=&quot;noreferrer&quot;&gt;networkx&lt;/a&gt; :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pulp &#xA;import networkx as nx&#xA;&#xA;G = nx.Graph()&#xA;# define your graph here&#xA;#...&#xA;&#xA;&#xA;# define the problem&#xA;prob = pulp.LpProblem(&amp;quot;MinimumSetVertexCover&amp;quot;, pulp.LpMinimize)&#xA;&#xA;# define the variables&#xA;x = pulp.LpVariable.dicts(&amp;quot;x&amp;quot;, G.nodes(), cat=pulp.LpBinary)&#xA;z = pulp.LpVariable.dicts(&amp;quot;z&amp;quot;, G.edges(), cat=pulp.LpBinary)&#xA;&#xA;# define the objective function&#xA;prob += pulp.lpSum(x)&#xA;&#xA;# define the constraints&#xA;for (u,v) in G.edges():&#xA;    prob += x[u] + x[v] &amp;gt;= 1&#xA;    prob += z[(u,v)] &amp;lt;= x[v]&#xA;    prob += z[(u,v)] &amp;lt;= 1-x[u]&#xA;prob += pulp.lpSum(z) &amp;gt;= k&#xA;&#xA;# solve&#xA;prob.solve()&#xA;&#xA;# display objective function value&#xA;print(&amp;quot;number of vertices in solution : %s&amp;quot;%pulp.prob.objective.value())&#xA;&#xA;# display solution&#xA;for v in G.nodes():&#xA;    if pulp.value(x[v]) &amp;gt; 0.9:&#xA;         print(&amp;quot;node %s selected&amp;quot;%v)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I suggest you&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Check out pulp's &lt;a href=&quot;https://coin-or.github.io/pulp/CaseStudies/index.html&quot; rel=&quot;noreferrer&quot;&gt;examples&lt;/a&gt; to understand the syntax&lt;/li&gt;&#xA;&lt;li&gt;Do not just copy paste the above answer if you want to learn something&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-10-31T21:33:31.650" LastActivityDate="2020-10-31T21:33:31.650" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5135" PostTypeId="1" CreationDate="2020-11-02T03:50:40.393" Score="1" ViewCount="147" Body="&lt;p&gt;I would like to know how vehicle routing software optimizes routes? In demos of this software, they provide the optimal (or a good) route in just a few seconds or minutes with several nodes (maybe 50 or 100). What are the main algorithms used to solve this type of problem?&#xA;Moreover, in software, it is possible to define the location of nodes by clicking on the map and it adds another step to determine the distance of nodes. However, the software can easily solve the problem.&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2020-11-02T03:50:40.393" Title="How to develop a vehicle routing optimization package?" Tags="|optimization|combinatorial-optimization|vehicle-routing|software|" AnswerCount="0" CommentCount="4" ClosedDate="2020-11-03T08:34:21.167" ContentLicense="CC BY-SA 4.0" />
  <row Id="5136" PostTypeId="1" CreationDate="2020-11-02T04:05:42.560" Score="2" ViewCount="1225" Body="&lt;p&gt;I am trying to solve a production problem and right now I need to assign an initial value to the inventory, and that value is given.&#xA;This is my definition of the inventory variable:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;H = pl.LpVariable.dicts(&amp;quot;H[i,t]&amp;quot;, [(i,t) for i in productos for t in periodos],cat='Integer')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;productos=[&amp;quot;golilla&amp;quot;,&amp;quot;tornillo&amp;quot;,&amp;quot;tuerca&amp;quot;]&#xA;periodos= [1,2,3,4,5,6,7,8,9,10,11,12]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and &lt;code&gt;H[&amp;quot;golilla&amp;quot;,0]&lt;/code&gt; need to be 2400, &lt;code&gt;H[&amp;quot;tuerca&amp;quot;,0]&lt;/code&gt; need to be 140 and &lt;code&gt;H[&amp;quot;tornillo&amp;quot;,0]&lt;/code&gt; need to be 320&lt;/p&gt;&#xA;" OwnerUserId="4354" LastEditorUserId="491" LastEditDate="2020-11-03T01:42:36.093" LastActivityDate="2020-11-03T01:42:36.093" Title="How can I assign an initial value to a variable in PuLP?" Tags="|pulp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5137" PostTypeId="1" AcceptedAnswerId="5144" CreationDate="2020-11-02T15:22:23.353" Score="2" ViewCount="172" Body="&lt;p&gt;I'm developing a heuristic based on U-NSGA-III and GA for continuous variables with a crossover operator from this article: &lt;a href=&quot;https://www.researchgate.net/publication/331451524_CAM-ADX_A_New_Genetic_Algorithm_with_Increased_Intensification_and_Diversification_for_Design_Optimization_Problems_with_Real_Variables&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.researchgate.net/publication/331451524_CAM-ADX_A_New_Genetic_Algorithm_with_Increased_Intensification_and_Diversification_for_Design_Optimization_Problems_with_Real_Variables&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My model has binary and continuous variables, being the continuous variables dependent on the binary ones, so I divided my problem into two: 1 solves the problem with the binary type, and for each solution of the problem 1, there's another problem that defines the continuous variables.&lt;/p&gt;&#xA;&lt;p&gt;Using this technique, my algorithm is slower than a B&amp;amp;B Algorithm, so I want to know, this kind of division is always a bad option or I could be doing something wrong other than that?&lt;/p&gt;&#xA;" OwnerUserId="2900" LastEditorUserId="500" LastEditDate="2020-11-02T16:07:50.773" LastActivityDate="2020-11-03T09:36:49.353" Title="Two Genetic Algorithms to solve two subproblems is a bad decision or I'm doing something wrong?" Tags="|metaheuristics|benders-decomposition|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5139" PostTypeId="2" ParentId="5137" CreationDate="2020-11-02T19:45:39.107" Score="5" Body="&lt;p&gt;There is a type of GA called a &amp;quot;random key&amp;quot; GA [1] that was originally designed for scheduling problems, with an eye toward dealing with constraints inherent in those problems. I've had some luck using it on other types of problems. The gist of the approach is that you establish a chromosome (in your case, a vector with some positions designated binary and the rest continuous between specified bounds) and then provide a function that &amp;quot;decodes&amp;quot; chromosomes into solutions. The critical part is that every chromosome must decode to a feasible solution. (It's okay if multiple chromosomes decode to the same solution.) Also important: every feasible solution, or at least every good feasible solution, is represented by some chromosome. Everything else about GAs (fitness, crossover, mutation, elitism, ...) is unchanged. If you can make your problem fit that paradigm, you can solve it with a single GA rather than having to &amp;quot;nest&amp;quot; two different GA models.&lt;/p&gt;&#xA;&lt;p&gt;[1] Bean, J. C. Genetic Algorithms and Random Keys for Sequencing and Optimization &lt;em&gt;ORSA Journal on Computing&lt;/em&gt;, &lt;strong&gt;1994&lt;/strong&gt;, &lt;em&gt;6&lt;/em&gt;, 154-160&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-11-02T19:45:39.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5140" PostTypeId="2" ParentId="5136" CreationDate="2020-11-02T20:00:47.913" Score="2" Body="&lt;p&gt;In Pyomo you can use the &lt;code&gt;.fix()&lt;/code&gt; method to do that. In the following example based on a condition you can fix some variables to different values:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if pyo.value(instance.x[2]) == 0:&#xA;   instance.x[2].fix(1)&#xA;else:&#xA;   instance.x[2].fix(0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In PuLP:&lt;/p&gt;&#xA;&lt;p&gt;Assigning values to variables also permit fixing those variables to that value. In order to do that, you can use the &lt;code&gt;fixValue&lt;/code&gt; method of the variable.(Please look at &lt;a href=&quot;https://coin-or.github.io/pulp/guides/how_to_mip_start.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; link)&lt;/p&gt;&#xA;&lt;p&gt;If you have not yet solved the model, you can use the &lt;code&gt;setInitialValue&lt;/code&gt; method to assign a value to the variable.&lt;/p&gt;&#xA;&lt;p&gt;For our example, if we know some variable needs to be 1, we can do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;_variable = x[('O', 'P', 'Q', 'R')]&#xA;_variable.setInitialValue(1)&#xA;_variable.fixValue()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-11-02T20:00:47.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5141" PostTypeId="2" ParentId="4882" CreationDate="2020-11-03T03:38:55.193" Score="2" Body="&lt;p&gt;There are a couple of ways to derive the steady state probabilities for a &lt;span class=&quot;math-container&quot;&gt;$M/M/1/k$&lt;/span&gt; queuing system with Markovian* arrivals (the first &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;), exponential service time distribution (the second &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;), a single server (the 1), and a finite total system capacity of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. Note this implies the queue can be at most &lt;span class=&quot;math-container&quot;&gt;$k-1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;*&lt;sub&gt;Recall a system with &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; arrivals has exponential interarrivals with rate &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and mean interarrival time of &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{\lambda}$&lt;/span&gt;. Equivalently, arrivals occur according to a homogeneous Poisson process with rate &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;. &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;One approach&lt;/strong&gt;&lt;br /&gt;&#xA;The &lt;span class=&quot;math-container&quot;&gt;$M/M/1/k$&lt;/span&gt; queuing system can be thought of as a Continuous Time Markov Chain (CTMC), &lt;span class=&quot;math-container&quot;&gt;$\{X(t), t&amp;gt;=0\}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$X(t)$&lt;/span&gt; represents the total number of customers in the system. We can take advantage of the system capacity (constraint) being finite.&lt;/p&gt;&#xA;&lt;p&gt;If the arrivals happen at rate &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and the service rate is &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;, then the transition rate diagram is given below. Note the finite number of states, with the statespace &lt;span class=&quot;math-container&quot;&gt;$\mathcal S = \{0,1,2,3,\ldots,k\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MnlXk.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MnlXk.jpg&quot; alt=&quot;Transition rate diagram&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The steady state probabilities, &lt;span class=&quot;math-container&quot;&gt;$\mathbf \pi = [\pi_0\; \pi_1\; \pi_2\; \ldots\; \pi_k]$&lt;/span&gt;, are obtained by the solution to the steady-state equations (flow out = flow in),&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\lambda \pi_0 = \mu \pi_1 \\&#xA;(\lambda+\mu) \pi_1 = \lambda \pi_0 + \mu \pi_2 \\&#xA;(\lambda+\mu) \pi_2 = \lambda \pi_1 + \mu \pi_3 \\&#xA;\vdots \\&#xA;\lambda \pi_{k-1} = \mu \pi_k&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and the normalization equation &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=0}^k \pi_k = 1$&lt;/span&gt;. The steady-state equations contain the dependency pattern of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Birth%E2%80%93death_process&quot; rel=&quot;nofollow noreferrer&quot;&gt;Birth-Death Process&lt;/a&gt;, with the final equation being modified due to the finite state space (though this will not hamper the solution).&lt;/p&gt;&#xA;&lt;p&gt;Ignoring the requirement for the &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt;'s to sum to 1 for now, set &lt;span class=&quot;math-container&quot;&gt;$\pi_0 = 1$&lt;/span&gt;.&#xA;Then &lt;span class=&quot;math-container&quot;&gt;$\hat \pi_j = \left(\frac{\lambda}{\mu}\right)^j$&lt;/span&gt;, or letting &lt;span class=&quot;math-container&quot;&gt;$\rho=\frac{\lambda}{\mu}$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\hat \pi_j = \rho^j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To normalize the solution, we need to divide the &lt;span class=&quot;math-container&quot;&gt;$\hat \pi$&lt;/span&gt;'s by the normalization constant &lt;span class=&quot;math-container&quot;&gt;$G = \hat \pi_0 + \hat \pi_1 + \hat \pi_2 +\hat \pi_3 + \cdots + \hat \pi_k$&lt;/span&gt;, which is a finite sum because we have a finite state space.&lt;/p&gt;&#xA;&lt;p&gt;Rearranging,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;G &amp;amp;= \hat \pi_0 + \hat \pi_1 + \hat \pi_2 +\hat \pi_3 + \cdots \hat \pi_k \\&#xA;  &amp;amp;= 1 + \rho + \rho^2 + \rho^3 + \cdots + \rho^k \\&#xA;  &amp;amp;= \left(\frac{1-\rho^{k+1}}{1-\rho} \right)&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;which gives&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{1}{G} = \frac{1-\rho}{1-\rho^{k+1}}$$&lt;/span&gt;&#xA;which is valid for any value of &lt;span class=&quot;math-container&quot;&gt;$\rho \in [0,1)$&lt;/span&gt; with the special case of &lt;span class=&quot;math-container&quot;&gt;$\rho=1$&lt;/span&gt; requiring the trivial &lt;span class=&quot;math-container&quot;&gt;$G = k+1$&lt;/span&gt; yielding&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{1}{G}=\frac{1}{k+1}$$&lt;/span&gt;&#xA;for this exception case.&lt;/p&gt;&#xA;&lt;p&gt;This implies that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;\pi_j = \rho^j\left(\frac{1-\rho}{1-\rho^{k+1}}\right) &amp;amp; \text{for } \rho\ne 1 \tag{Key Result} \\&#xA;\pi_j = \frac{1}{k+1} &amp;amp; \text{for } \rho = 1  \\&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2023-01-17T12:46:58.157" LastActivityDate="2023-01-17T12:46:58.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5142" PostTypeId="5" CreationDate="2020-11-03T03:45:52.757" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2020-11-03T03:45:52.757" LastActivityDate="2020-11-03T03:45:52.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5143" PostTypeId="4" CreationDate="2020-11-03T03:45:52.757" Score="0" Body="Use this tag for questions regarding a system whose behavior over a sufficiently long period is not governed by the initial conditions and instead will converge to the steady-state.   " OwnerUserId="491" LastEditorUserId="491" LastEditDate="2020-11-03T08:33:31.087" LastActivityDate="2020-11-03T08:33:31.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5144" PostTypeId="2" ParentId="5137" CreationDate="2020-11-03T09:36:49.353" Score="3" Body="&lt;p&gt;Your problem is what we call at LocalSolver a &lt;em&gt;mixed-variable&lt;/em&gt; problem. It involves discrete decisions and continuous decisions that cannot be expressed from the discrete ones. Once the discrete decisions are fixed, you have to decide the continuous ones, that may have to satisfy some (linear or nonlinear) constraints and that may appear in the objectives of your model as well. This is the typical structure of problems like the &lt;a href=&quot;https://en.wikipedia.org/wiki/Unit_commitment_problem_in_electrical_power_production&quot; rel=&quot;nofollow noreferrer&quot;&gt;unit commitment problem&lt;/a&gt; or the &lt;a href=&quot;https://myweb.uiowa.edu/acampbll/inventoryrouting.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;inventory routing problem&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;When the discrete part of the model is not heavily combinatorial and the continuous part can be linearly approximate, the model may be frontally solved by MILP solvers. When you don't get quality solutions in short running times like this, then you have several ways to proceed.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use MILP solvers through decomposition approaches like &lt;a href=&quot;https://en.wikipedia.org/wiki/Benders_decomposition&quot; rel=&quot;nofollow noreferrer&quot;&gt;Benders decomposition&lt;/a&gt;, as Rob mentioned in his comment above. Benders decomposition is quite sophisticated. There are many ways to heuristically decompose the problem, then solving each part with MILP solvers. For example, solve first the discrete part of the model by approximating roughly the continuous part; then, having values for the discrete variables, solve the continuous part (exactly or heuristically).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use &amp;quot;mixed-variable&amp;quot; local search approaches like the ones described in &lt;a href=&quot;https://www.localsolver.com/fgardi/downloads/Gardi-Nouioua_EDF_EVOCOP_2011.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; for a real-life, large-scale unit commitment problem or &lt;a href=&quot;https://www.localsolver.com/fgardi/downloads/Benoist-Estellon-Gardi-Jeanjean_TRSC_09.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; for a real-life, large-scale inventory routing problem. The main idea of the approach is simple but the practical implementation can be hard. Starting from a solution (feasible or infeasible), you perform a &amp;quot;mixed-variable&amp;quot; local search at each iteration. It consists of moving discrete decisions (as classically done in &lt;a href=&quot;https://en.wikipedia.org/wiki/Local_search_%28optimization%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;local/neighborhood search&lt;/a&gt; methods or &lt;a href=&quot;https://en.wikipedia.org/wiki/Evolutionary_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;evolutionary methods&lt;/a&gt;) and then of repairing the continuous part by exact or heuristic continuous methods (for example, by using incremental greedy algorithms which is complex to implement but makes the overall approach converging very fast in practice, or by using basically LP/NLP algorithms which is easier but slower). Here you can also use evolutionary methods as the one described &lt;a href=&quot;https://www.researchgate.net/publication/331451524_CAM-ADX_A_New_Genetic_Algorithm_with_Increased_Intensification_and_Diversification_for_Design_Optimization_Problems_with_Real_Variables&quot; rel=&quot;nofollow noreferrer&quot;&gt;in the paper you mentioned in the question&lt;/a&gt; to repair the continuous part of the solution.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;LocalSolver has under its hood some of the approaches described above.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-11-03T09:36:49.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5145" PostTypeId="1" CreationDate="2020-11-03T09:43:06.233" Score="2" ViewCount="90" Body="&lt;p&gt;I am currently working on &lt;strong&gt;SALBP-2&lt;/strong&gt; described as:&#xA;Given the number &lt;em&gt;m&lt;/em&gt; of assembly stations, minimize the cicle time &lt;em&gt;c&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have done a bit of research and found the following approach to solve it:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n8jvrl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n8jvrl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The lower bound is clear to me but I am struggling to find a simple heuristic that computes the upper bound. What are approaches to do this?&lt;/p&gt;&#xA;" OwnerUserId="4313" LastActivityDate="2020-11-03T09:43:06.233" Title="Heuristic to compute upper bound for the simple assembly line balancing problem type 2?" Tags="|scheduling|heuristics|bounds|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5147" PostTypeId="1" CreationDate="2020-11-04T08:07:41.227" Score="0" ViewCount="2117" Body="&lt;p&gt;If optimal solution to the primal is degenerate, does it necessarily follow that optimal solution to dual not unique? That is, is uniqueness an unnecessary assumption?&lt;/p&gt;&#xA;&lt;p&gt;Spin-off from &lt;a href=&quot;https://math.stackexchange.com/questions/1049796/prove-optimal-solution-to-dual-is-not-unique-if-optimal-solution-to-the-primal-i&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In my Operations Research problem set, our professor required us to prove&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;If an optimal solution to the primal is degenerate, then there is at least one alternative optimal solution to the dual.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I found, however, that if we do not assume uniqueness, the statement is &lt;a href=&quot;https://math.stackexchange.com/questions/8393/primal-degenerate-optimal-dual-unique-optimal/8399#8399&quot;&gt;false&lt;/a&gt;?&lt;/p&gt;&#xA;&lt;p&gt;I asked by e-mail:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;In the problem set, does the optimal solution to the primal really need not be unique?&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The reply I got:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;Yes. Some LP problems have alternative optimal solutions.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I asked if uniqueness was not needed to conclude an alternative optimal solution to dual and showed the counterexample I linked above (&lt;a href=&quot;https://math.stackexchange.com/questions/8393/primal-degenerate-optimal-dual-unique-optimal/8399#8399&quot;&gt;again here&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Reply I got:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;I only said thet in LP, alternative optimal solutions may exist. I am not referring to the problem in the exercise specifically. Please read the statement of the problem again.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I then asked if the OP was equivalent to&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If there are several optimal solutions to the primal with at least one of them being degenerate or there is a unique degenerate optimal solution to the primal, then the optimal solution to the dual is not unique?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;i.e. (well so I think) uniqueness of degenerate optimal solution to primal is irrelevant.&lt;/p&gt;&#xA;&lt;p&gt;The reply I got:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;There is an additional assumption in your statement which is not in the problem.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h2&gt;&lt;strong&gt;Question: What is the additional assumption?&lt;/strong&gt;&lt;/h2&gt;&#xA;&lt;p&gt;In the end, we just copied the &amp;quot;proof&amp;quot; of one of our other classmates. Apparently, e was able to prove the statement even though it looks to be false. I don't have the proof with me though.&lt;/p&gt;&#xA;&lt;p&gt;One of my classmates asked our professor on the day of submission that someone (me) pointed out that if we don't assume uniqueness, the statement doesn't hold. I was kind of sleepy, but iirc, our prof said something that began with&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;But that's not what you're trying to show&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;or something like that. My classmate didn't respond, and we just moved on. Well, they did.&lt;/p&gt;&#xA;" OwnerUserId="3791" LastEditorUserId="3791" LastEditDate="2020-12-05T07:34:22.007" LastActivityDate="2020-12-05T07:34:22.007" Title="Is optimal solution to dual not unique if optimal solution to the primal is degenerate?" Tags="|linear-programming|duality|dual|optimality-conditions|primal|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="5148" PostTypeId="1" CreationDate="2020-11-04T10:36:53.653" Score="6" ViewCount="99" Body="&lt;p&gt;In many OR problems, it is sometimes a good idea (or necessary) to relax routing constraints.&lt;/p&gt;&#xA;&lt;p&gt;An example of this occurs in the classical facility location problem, where a warehouse can send out a truck that makes several stops at different stores on the same route. In this case, transportation costs are no longer a simple point-to-point rate, they depend on which stores are on which route, and it is difficult to allocate  the costs of the routes to each individual stop. Of course one could model the routing part of the problem, but besides the size issue, there many be differing levels of detail in the routing versus network design problems, and it may be counter productive to combine the two in a unique model.&lt;/p&gt;&#xA;&lt;p&gt;A good compromise is to relax the routing constraints, but to estimate the multistop routing costs. In this &lt;a href=&quot;https://books.google.fr/books/about/Supply_Chain_Network_Design.html?id=WT5iAwAAQBAJ&amp;amp;redir_esc=y&quot; rel=&quot;nofollow noreferrer&quot;&gt;book&lt;/a&gt;, the authors propose the following methodology. Suppose you are dealing with one warehouse and &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; stores.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Compute the costs out and back from the warehouse to each the stores, assuming a full truckload.&lt;/li&gt;&#xA;&lt;li&gt;Add the &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; costs together. Let &lt;span class=&quot;math-container&quot;&gt;$c_1$&lt;/span&gt; denote this cost.&lt;/li&gt;&#xA;&lt;li&gt;Since multistop routes are typically ran for more frequent deliveries, it is reasonnable to assume that each route delivers only a fraction of the store's demand, e.g. one third. So a fair comparison between the direct full truckload route and the multistop route, is to run the multistop route &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; times, which yields a second cost &lt;span class=&quot;math-container&quot;&gt;$c_2$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Between the warehouse and each store, multiply each point-to-point cost by &lt;span class=&quot;math-container&quot;&gt;$\frac{c_2}{c_1}$&lt;/span&gt;. Note that if the stores are all very far away from the warehouse, and close to one another, this factor will be very close to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;This methodology has some strengths, but one major downside is that you have to compute &lt;span class=&quot;math-container&quot;&gt;$c_2$&lt;/span&gt; in the first place, that is, you have to compute a potentially hard route before hand. A way around this is to simply multiply each cost by &lt;span class=&quot;math-container&quot;&gt;$1+\varepsilon$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt; is estimated somehow, but this obviously lacks accuracy.&lt;/p&gt;&#xA;&lt;p&gt;Another example is described in this &lt;a href=&quot;https://pdfs.semanticscholar.org/013e/21950d1d347de0a4c641b5caecf54dbb2c2f.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt;, in which the authors formulate their &lt;em&gt;inventory routing problem&lt;/em&gt; as a MILP, and then introduce a relaxation without routing model which eliminates the routing part of the problem. They basically introduce fractional vehicles and underestimate the costs by considering the distance to and from the depot only.&lt;/p&gt;&#xA;&lt;p&gt;Last but not least, I have seen the following method in the past. The cost is estimated as follows: two terms are considered, the direct point-to-point distance, and an estimation of the average distance between stops, multiplied by an estimation of the average number of stops per route. This average distance &lt;span class=&quot;math-container&quot;&gt;$\bar{d}$&lt;/span&gt; is computed with the following formula :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\bar{d} \approx \frac{2}{\sqrt{\mbox{node density} \times \pi}}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Are there other ways to model/estimate routing costs in such problems, without explicitely computing the routes ?&lt;/li&gt;&#xA;&lt;li&gt;Does anyone have a reference detailing the last methodology that is described above (with &lt;span class=&quot;math-container&quot;&gt;$\bar{d}$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-11-04T13:44:01.770" LastActivityDate="2020-11-04T13:44:01.770" Title="Estimating multistop routing costs" Tags="|linear-programming|modeling|vehicle-routing|facility-location|cost-matrix|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5150" PostTypeId="1" AcceptedAnswerId="5153" CreationDate="2020-11-04T21:12:10.497" Score="29" ViewCount="14329" Body="&lt;p&gt;I come from an ML background, and occasionally have to dive into the OR world. I am trying to figure out whether I need to purchase a commercial solver license for a certain problem set.&lt;/p&gt;&#xA;&lt;p&gt;In the ML world, open source libraries like Tensorflow, Scikit-Learn, PyTorch, etc...are as good as it gets in terms of performance and features. Whether to go with open source or commercial product is more a Human Resources consideration: Do you have an ML engineering team capable of building and deploying models with open source libraries? If so, going with a commercial product makes no sense whatsoever.&lt;/p&gt;&#xA;&lt;p&gt;Is the situation similar with OR solvers? Or are there more in-depth reasons that justify paying the license for a commercial solver, e.g.: performance, size of search space, SLAs, quality of results, etc...?&lt;/p&gt;&#xA;" OwnerUserId="1315" LastEditorUserId="1315" LastEditDate="2020-11-04T21:41:08.587" LastActivityDate="2022-03-18T03:53:14.647" Title="What are the advantages of commercial solvers like Gurobi or Xpress over open source solvers like COIN-OR or CVXPY?" Tags="|cplex|solver|gurobi|coin-or|constrained-optimization|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5151" PostTypeId="2" ParentId="5150" CreationDate="2020-11-04T21:49:46.483" Score="22" Body="&lt;p&gt;I think the short answer is: speed.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Most optimization problems solved in the OR world are computationally intractable&lt;/strong&gt;, they cannot be solved in reasonable time as the size of the data increases. A commercial solver will allow you to push back the limit of the size of the problem you are tackling, and to solve the small ones very fast.&lt;/p&gt;&#xA;&lt;p&gt;If you checkout for example Gurobi's benchmarks, you can see the big difference between open source and commercial solvers:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sruia.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sruia.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have seen problems in the past where CBC (best open source solver) cannot find a feasible solution after more than 30 hours, and commercial solvers solve optimally within 15 minutes.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-11-04T21:49:46.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5152" PostTypeId="2" ParentId="5150" CreationDate="2020-11-04T22:06:53.697" Score="23" Body="&lt;p&gt;No, the situation isn´t the same for OR libraries. There are several reasons for this, among them being&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance:&lt;/strong&gt; The difference is relevant, with an emphasis on Mixed Integer Programming (linear and nonlinear). For Linear Programming it's less abrupt but it still exists. You can see empirical results in e.g. the &lt;a href=&quot;http://plato.asu.edu/bench.html&quot; rel=&quot;noreferrer&quot;&gt;Mittelmann benchmarks for Optimization Software&lt;/a&gt;. As mentioned in the website, the current version doesn't contain some commercial solvers, but previous ones did and the results are still available online.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Size of search space:&lt;/strong&gt; Yeah, first, in general commercial solvers have state of the art implementations with dedicated developer teams focused in scalability, high performance, robustness, multithreading, heuristics (e.g. feasibility pump) and other features which tend to make their software more capable of handling large search spaces, when compared to open source solvers. I'm not saying that open source solvers (e.g. CLP, CBC, DIP) are bad: they too have many of the same great tricks and advances in capabilities implemented. It just isn't the same you can achieve with a large funding agenda and teams dedicated full time to research and development. Second, for some specific problems where the search space is too large, it can be worth it(*) to design heuristics, apply metaheuristics, or other similar approaches which don't guarantee an optimal solution but can be validated on realistic instances to compare the solution with the optimum. Otherwise you could need sophisticated methods like decomposition methods which have their own numerical issues and some organizations tend to prefer simpler models for different reasons (**).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;SLA&lt;/strong&gt; is definitely an important factor. Sometimes open source code will have bugs - because of library-solver integration or even a numerical issue in the solver's code - and it's not the same to have immediate or fast support vs a project maintained by a couple of people who may not be able to dedicate full time. You could try to solve the bugs yourself and contribute but it'll be difficult if your project (which uses the solver) needs to be shipped soon.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Quality of solution&lt;/strong&gt; this can be related to the discussions above on performance, SLA and reliability.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Integration with other services and frameworks:&lt;/strong&gt; Commercial solvers tend to have APIs available for a couple of programming languages, which can make it easier to integrate them into larger projects for organizations. Even more, some of them (e.g. Gurobi and CPLEX) have kept the rhythm of the market and started adding cloud computing capabilities.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;User experience, user base and adoption:&lt;/strong&gt; Many times there's a significant gap in quality of documentation, completeness of documentation,, ease of installation (can be excruciatingly painful for many open source solvers, almost impossible in a Windows OS), availability of online resources/size of community (large open-source communities in ML, not the case for OR). Hopefully the adoption of OR methods will change in the future as part of the analytics community starts adopting optimization knowledge for prescriptive modeling. In many practical situations, making decisions is the end goal of predictive modeling, and optimization can help to make efficient decisions. And this can be combined with organizational constraints like budget, workforce hours, or infrastructure capacity. Some examples:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;demand prediction is an intermediate step for capacity allocation or production planning&lt;/li&gt;&#xA;&lt;li&gt;fraud and churn prediction must be followed by actual decisions (which campaign or action, how many resources to assign to each customer, and when)&lt;/li&gt;&#xA;&lt;li&gt;stockout predictions are not the end goal, planning when to replenish which SKU, and how much, should be&lt;/li&gt;&#xA;&lt;li&gt;Estimates of &lt;em&gt;willingness to pay&lt;/em&gt; can be a first step towards revenue optimization.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note that for continuous optimization, there are great solvers available in open source software. SciPy contains many of them (L-BFGS-B etc), CVX is centered on convex optimization, and OSQP for Quadratic Programming. But even in these cases, using commercial solvers (e.g. MOSEK and BARON) tends to be faster or achieve better solutions in a fixed same timeframe.&lt;/p&gt;&#xA;&lt;p&gt;Also what makes choosing OR software more complex is that there's no free lunch, no universal ranking (in part because only internal teams know what their program does and how it works). There are cases where Gurobi is better than CPLEX for some model instance A while the reverse situation happens for a different instance B. A specific nonlinear solver could perform significantly better than Gurobi/CPLEX for a model you have in mind. And if this is important or not will depend on your available computing infrastructure. To add more complexity into this, it can happen that a Constraint Programming model for a specific problem is solved in seconds while a Mathematical Programming solver takes several minutes or hours to obtain a solution of similar quality, or vice versa.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;(*) To delve into the reasons why I said &lt;em&gt;&lt;strong&gt;for some&lt;/strong&gt; specific problems where the search space is too large, it can be worth it&lt;/em&gt;, please refer to Tobias Achterberg's answer that covers the reason into more detail. With &lt;em&gt;worth it&lt;/em&gt; I mean in terms of available budget for the solution vs the incremental savings/benefits it will bring. This isn't a hard constraint, as the OR practitioner's knowledge can help tweaking a software and changing the modelling approach to one that performs well.&lt;/p&gt;&#xA;&lt;p&gt;(**) Might be practical reasons, as the model will likely need maintenance, tuning and/or updates in the future. If the solution was developed by consultants, it could be nontrivial to do these tasks by an internal team.&lt;/p&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="51" LastEditDate="2022-03-18T03:53:14.647" LastActivityDate="2022-03-18T03:53:14.647" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5153" PostTypeId="2" ParentId="5150" CreationDate="2020-11-05T12:01:04.497" Score="62" Body="&lt;p&gt;Disclaimer: I am currently working for a commercial solver company (Gurobi) and have worked before on another commercial solver (IBM CPLEX). Hence, my opinion may be biased, but still I am trying to not turn my answer into a marketing and sales pitch. For my PhD thesis I developed the academic solver SCIP, which is still actively maintained and developed by a large group of researchers, so I also know the academic side of the solver world. In any case, what I am going to say is my personal opinion and not necessarily aligned with my current or former employers or my former research group.&lt;/p&gt;&#xA;&lt;p&gt;I agree with dhasson's points, but I would like to emphasize a certain aspect of performance (also addressed in Kuifje's answer) that I think is hard to understand in its full consequences for people that are not experts in operations research.&lt;/p&gt;&#xA;&lt;p&gt;First, let me state that I am only discussing mixed integer programming (MIP) here, which is just a small sub-area in the field of operations research, but I think is the main topic that Skander H.'s question is about.&lt;/p&gt;&#xA;&lt;p&gt;The main issue of performance for mixed integer programming solvers is that all known algorithms for MIP have exponential worst-case running time. While this may also be true for other areas like ML or data base operations, I think that in practice the algorithms that are applied there scale reasonably well with the size of the input data.&lt;/p&gt;&#xA;&lt;p&gt;For MIP, the running time heavily depends on the structure of the model to be solved and on the capabilities of the solver to exploit this structure. If there is no useful structure in the model or if the solver is not able to identify and exploit the structure, then you will often see that the theoretical exponential growth in running time manifests itself in practice.&lt;/p&gt;&#xA;&lt;p&gt;For example, there are models with just 50 binary variables and a handful of constraints that are pretty much unsolvable with today's state-of-the-art algorithms. And for such models each additional binary variable pretty much doubles the resulting runtime. You really can see the exponential complexity. On the other hand, there are models with millions of variables and constraints that can be routinely solved to optimality. This is true for both free/academic solvers as well as commercial solvers.&lt;/p&gt;&#xA;&lt;p&gt;Fortunately, models of practical problems that are of interest in industrial applications are most often of the latter type. Nevertheless, as said before, being able to solve a model or not within reasonable time heavily depends on whether the solver at hand is able to identify and exploit the structure of the model. And this is where the main difference is between free/academic solvers and commercial solvers when it comes to performance. Commercial vendors with their teams of full-time developers and their large customer base who provide models from a diverse set of applications are just in a much better position to develop, implement, and tune algorithms to cover all these different aspects and structures that appear in real-world models. Hence, the likelihood that the solver deals nicely with your application type is larger if you select a commercial solver.&lt;/p&gt;&#xA;&lt;p&gt;And this aspect does not show very well in the performance comparisons that you see in publicly available benchmarks. From the pictures like the one that Kuifje refered to, you may get the conclusion that free solvers are something like 5 or 10 or 20 times slower than the best commercial solvers. And then, you may think &amp;quot;speed is not that relevant for me, I don't mind having to wait 10 minutes instead of just 1 minute&amp;quot;. But this is just not the right way of looking at this. Check also the number of models that could be solved to optimality: in the (relatively old) picture you can see that CBC (which is a good free solver) is able to solve only 48 out of the 87 problem instances, while the commercial ones solve 86 of them.&lt;/p&gt;&#xA;&lt;p&gt;For your particular problem class, it could be that a free solver just behaves nicely and has the same or at least comparable performance than a commercial solver. It could even be that there is some research advancement implemented in the free/academic solver that has not yet found its way into the commercial product and thus the free solver is actually faster than the commercial product. But there are also a number of cases where the models for your problem class are intractable for one solver while they can be solved in a fraction of a second by a different solver, often a commercial one.&lt;/p&gt;&#xA;&lt;p&gt;This is what I think is often hard to grasp. From, say, ML algorithms or data bases or operating systems or whatever type of software where you have both commercial and free (open source) alternatives, one is used to commercial products being maybe a little faster or a little better or just a little different in certain aspects. But there usually is not the difference between &amp;quot;it is impossible to solve my problem&amp;quot; versus &amp;quot;my problem solves very easily&amp;quot;. But this is sometimes the case for MIP solvers.&lt;/p&gt;&#xA;&lt;p&gt;Thus, I would recommend the following approach:&lt;/p&gt;&#xA;&lt;p&gt;First, you consider all the various other aspects that have been mentioned above by dhasson. Is a reliable support, SLA, cloud computing, a certain API or platform support essential to you? What about the other non-standard features that some commercial solvers offer? Is there a free solver that provides what you need? If not, you are already bound to looking at commercial alternatives.&lt;/p&gt;&#xA;&lt;p&gt;If a free solver is a valid option, then pick one based on publicly available benchmarks and try to solve your models with it. Just check if it works. Verify carefully whether the results are correct, because apart from performance there is also the aspect of numerical robustness that is often better in commercial products. Try multiple problem instances of your problem class. And if everything works well with the free solver, just stick to it for this project.&lt;/p&gt;&#xA;&lt;p&gt;But if at some point you run into a wall, for example because the free solver is just unable to solve your problems, then please do not make the mistake of dismissing the whole technology of mixed integer programming. It could be that with the solver you tried it appears completely hopeless to solve your problem and you have the impression that you need to look at a completely different approach like implementing a heuristic. But at this point it is definitely time to check out commercial alternatives. The commercial vendors provide evaluation licenses such that you don't need to pay anything for a first try. And it can very well be that you are going to be positively surprised. It happens frequently that a commercial solver can solve certain types of models easily that appear completely hopeless with a free solver. And this is not only due to the differences in free and commercial products, it can also happen when switching from one free solver to another, or when comparing different commercial solvers. For example, it could very well be that Gurobi struggles for some problem class but CPLEX and XPRESS have no issue at all with it. So, please try different alternatives before you give up! MIP is really a cool and useful technology that is worth learning and embracing.&lt;/p&gt;&#xA;" OwnerUserId="4365" LastEditorUserId="126" LastEditDate="2020-11-08T14:38:16.963" LastActivityDate="2020-11-08T14:38:16.963" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5155" PostTypeId="2" ParentId="5150" CreationDate="2020-11-05T12:25:27.883" Score="10" Body="&lt;p&gt;(Full disclosure: I run a solver company)&lt;/p&gt;&#xA;&lt;h2&gt;The state of the art&lt;/h2&gt;&#xA;&lt;p&gt;Unlike ML, in the optimisation space commercial software is unfortunately &lt;strong&gt;on average&lt;/strong&gt; superior to open-source alternatives. This does not mean that open source can't be a perfectly viable choice. Open source solvers can and do solve very difficult problems. It just means that commercial solvers can solve many problems that are well beyond the scope of what we can expect open-source solvers to be able to solve.&lt;/p&gt;&#xA;&lt;p&gt;The are many reasons why, but at the end of the day it comes down to the fact that optimisation solvers are solving a &amp;quot;more difficult&amp;quot; problem that ML frameworks do, and there are far fewer people who know how to write solvers well. Therefore, the necessary volume of developers to support viable open-source alternatives doesn't really exist yet.&lt;/p&gt;&#xA;&lt;p&gt;ML is much closer to the curriculum of your average computer scientist, which is partially why we have so many good frameworks. In order to write a good optimisation solver the developer needs to also understand the math, and most CS curricula don't include higher math, so good hobbyists are much harder to come by.&lt;/p&gt;&#xA;&lt;p&gt;Also don't forget that the &lt;strong&gt;main&lt;/strong&gt; reason we have such good ML frameworks today is because big corporate money funded its development (e.g. Google). This hasn't happened in the optimisation space yet, nor does it seem likely to happen anytime soon.&lt;/p&gt;&#xA;&lt;h2&gt;The commercial perspective&lt;/h2&gt;&#xA;&lt;p&gt;When it comes to open source vs commercial there are numerous straightforward answers as to what differentiates commercial software: speed, robustness, plurality of interfaces, better user experience, and of course support. The more subtle answers (and in many ways the most crucial ones) are data bandwith and tuning.&lt;/p&gt;&#xA;&lt;p&gt;At the end of the day though, it comes down to this: the better our solvers are, the more money we make. Therefore, we have incentive and resources to pour money and time towards constantly improving the solvers and the user experience. Open source relies on expert volunteers, and unfortunately, as I mentioned in the beginning of this, there are very few professional solver developers in the world to begin with.&lt;/p&gt;&#xA;&lt;h2&gt;Speed&lt;/h2&gt;&#xA;&lt;p&gt;The speed is quite intuitive and has been answered by other people, so I won't cover that. We're all pretty fast. Often &amp;gt;1000x faster than open source.&lt;/p&gt;&#xA;&lt;h2&gt;Robustness&lt;/h2&gt;&#xA;&lt;p&gt;Robustness is less obvious. If you run open source software enough, you will see quite a few bugs. Enough bugs in fact, that e.g. most COIN-OR software is hard to use in production. Commercial solvers have Q&amp;amp;A teams, plus thousands of customers' feedback and bug reports, so it makes sense that our software breaks less frequently.&lt;/p&gt;&#xA;&lt;h2&gt;Interfaces&lt;/h2&gt;&#xA;&lt;p&gt;This is also a trivial argument, solver companies will spend money to build and test good interfaces for numerous programming languages, GUIs, and modelling frameworks. In open source there's little incentive to do that.&lt;/p&gt;&#xA;&lt;h2&gt;Better user experience&lt;/h2&gt;&#xA;&lt;p&gt;Another intuitive one: the easier it is to use our software, the more customers we can get. With open-source solvers, devs seem to care more about the core functionality, not how easy it is for others to use. This makes sense - working on algorithms is fun and stimulating, debugging Python interfaces isn't.&lt;/p&gt;&#xA;&lt;h2&gt;Support&lt;/h2&gt;&#xA;&lt;p&gt;Often the main incentive to buy a solver, you know that if something goes wrong you're not on your own.&lt;/p&gt;&#xA;&lt;h2&gt;Tuning&lt;/h2&gt;&#xA;&lt;p&gt;Having teams of people working full-time to make the software faster, and also having seen thousands of real problems from customers, gives us resources not available to the open-source community to tune our solvers to run better on the most commonly encountered problems.&lt;/p&gt;&#xA;&lt;h2&gt;Data bandwidth&lt;/h2&gt;&#xA;&lt;p&gt;The elephant in the room. The other main reason to buy a commercial solver is that it's typically designed to process large amounts of data efficiently. Most solvers will instantly hit a ceiling when large problems are loaded because, even if their algorithms are great, their implementation doesn't scale beyond a certain data bandwidth. This is absolutely a ceiling for the vast majority of open-source solvers, and for many commercial solvers as well btw. Once you've worked with enough solvers you just know that if a problem is large-ish, there's no point even trying to load it on certain solvers. In &lt;a href=&quot;https://octeract.com/octeract-engine/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Engine&lt;/a&gt; for instance, we have 4 classes of implementations for data structures and most expensive algorithms, and the solver switches between them dynamically depending on problem size: small, mid-size, large, and humongous. The only reason we got to do that though is because we had users who couldn't solve certain problems, which made us aware of the bottlenecks.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-11-09T16:19:43.793" LastActivityDate="2020-11-09T16:19:43.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5156" PostTypeId="2" ParentId="5147" CreationDate="2020-11-05T16:16:40.560" Score="4" Body="&lt;p&gt;If I understand your question correctly, I think you can find your answer by considering the following two primal problems. The first is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat*}{2}&#xA; &amp;amp; \max &amp;amp; x_{1}\\&#xA; &amp;amp; \textrm{s.t.} &amp;amp; x_{1}+x_{2} &amp;amp; \le1\\&#xA; &amp;amp;  &amp;amp; x_{1} &amp;amp; \le1\\&#xA; &amp;amp;  &amp;amp; x &amp;amp; \ge0&#xA;\end{alignat*}&lt;/span&gt;&#xA;and the second is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat*}{2}&#xA; &amp;amp; \max &amp;amp; 0\\&#xA; &amp;amp; \textrm{s.t.} &amp;amp; x_{1}+x_{2} &amp;amp; \le1\\&#xA; &amp;amp;  &amp;amp; x_{1} &amp;amp; \le1\\&#xA; &amp;amp;  &amp;amp; x &amp;amp; \ge0.&#xA;\end{alignat*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x=(1,0)$&lt;/span&gt; is a degenerate optimal solution for both problems. Inspecting their duals should prove informative.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-11-05T16:16:40.560" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="5157" PostTypeId="1" AcceptedAnswerId="5193" CreationDate="2020-11-05T16:38:58.637" Score="24" ViewCount="1241" Body="&lt;p&gt;Mixed-integer programming is a super powerful tool for operations researchers to solve many difficult problems.&lt;/p&gt;&#xA;&lt;p&gt;As described by Bixby[1] there has been an overall improvement in the performance of a factor of over 1.1M X since the early 1990s. Giving a ~1.8x speed-up per year.&lt;/p&gt;&#xA;&lt;p&gt;We have Moores law, predicting the exponential increase in computer power, and Kryder's Law predicting the exponential increase in storage capacity. I have though never seen a similar prediction for mixed-integer programming performance despite fairly consistent algorithmic improvements.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What speed-up is it &lt;strong&gt;most likely&lt;/strong&gt; we will see in the next 10 years?&lt;/li&gt;&#xA;&lt;li&gt;What are the reasons for a &lt;strong&gt;lower&lt;/strong&gt; rate in the future than what we have seen in the last 30 years?&lt;/li&gt;&#xA;&lt;li&gt;What are the reasons for a &lt;strong&gt;higher&lt;/strong&gt; rate in the future than what we have seen in the last 30 years?&lt;/li&gt;&#xA;&lt;li&gt;Which trends and technologies will have an impact on this?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;sub&gt;[1]&lt;a href=&quot;https://people.bath.ac.uk/masjhd/Others/Bixby2015a.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://people.bath.ac.uk/masjhd/Others/Bixby2015a.pdf&lt;/a&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="140" LastEditorUserId="140" LastEditDate="2020-11-05T16:50:30.427" LastActivityDate="2020-11-11T10:17:59.797" Title="How much can we expect to increase the speed of mixed integer programming in the next 10 years?" Tags="|mixed-integer-programming|benchmark|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="5160" PostTypeId="1" CreationDate="2020-11-06T18:36:57.343" Score="3" ViewCount="2252" Body="&lt;p&gt;I looked at the GAMS python API but the documentation only describing already predefined models (run .gms with some tweaking options).&#xA;My question is now: Can I somehow build a gams model from scratch with data I have imported in python.&#xA;When I worked with gurobi everything seemed easy, but my professor forces me to use Gams...&#xA;It seems to me GAMS is only good for hardcoding and doesn't give me a lot of flexibility.&lt;/p&gt;&#xA;&lt;p&gt;Advice?&lt;/p&gt;&#xA;&lt;p&gt;I found this, but it just looks like it inserts the whole model in a string with the GAMS syntax...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from gams import *&#xA; import os&#xA; import sys&#xA;  &#xA; def get_data_text():&#xA;     return '''&#xA;   Sets&#xA;        i   canning plants   / seattle, san-diego /&#xA;        j   markets          / new-york, chicago, topeka / ;&#xA;  &#xA;   Parameters&#xA;  &#xA;        a(i)  capacity of plant i in cases&#xA;          /    seattle     350&#xA;               san-diego   600  /&#xA;  &#xA;        b(j)  demand at market j in cases&#xA;          /    new-york    325&#xA;               chicago     300&#xA;               topeka      275  / ;&#xA;  &#xA;   Table d(i,j)  distance in thousands of miles&#xA;                     new-york       chicago      topeka&#xA;       seattle          2.5           1.7          1.8&#xA;       san-diego        2.5           1.8          1.4  ;&#xA;  &#xA;   Scalar f  freight in dollars per case per thousand miles  /90/ ; '''&#xA;  &#xA; def get_model_text():&#xA;     return '''&#xA;   Sets&#xA;        i   canning plants&#xA;        j   markets&#xA;  &#xA;   Parameters&#xA;        a(i)   capacity of plant i in cases&#xA;        b(j)   demand at market j in cases&#xA;        d(i,j) distance in thousands of miles&#xA;   Scalar f  freight in dollars per case per thousand miles;&#xA;  &#xA; &lt;span class=&quot;math-container&quot;&gt;$if not set gdxincname $&lt;/span&gt;abort 'no include file name for data file provided'&#xA; &lt;span class=&quot;math-container&quot;&gt;$gdxin %gdxincname%&#xA; $&lt;/span&gt;load i j a b d f&#xA; $gdxin&#xA;  &#xA;   Parameter c(i,j)  transport cost in thousands of dollars per case ;&#xA;  &#xA;             c(i,j) = f * d(i,j) / 1000 ;&#xA;  &#xA;   Variables&#xA;        x(i,j)  shipment quantities in cases&#xA;        z       total transportation costs in thousands of dollars ;&#xA;  &#xA;   Positive Variable x ;&#xA;  &#xA;   Equations&#xA;        cost        define objective function&#xA;        supply(i)   observe supply limit at plant i&#xA;        demand(j)   satisfy demand at market j ;&#xA;  &#xA;   cost ..        z  =e=  sum((i,j), c(i,j)*x(i,j)) ;&#xA;  &#xA;   supply(i) ..   sum(j, x(i,j))  =l=  a(i) ;&#xA;  &#xA;   demand(j) ..   sum(i, x(i,j))  =g=  b(j) ;&#xA;  &#xA;   Model transport /all/ ;&#xA;  &#xA;   Solve transport using lp minimizing z ;&#xA;  &#xA;   Display x.l, x.m ; '''&#xA;  &#xA;  &#xA; if __name__ == &amp;quot;__main__&amp;quot;:&#xA;     if len(sys.argv) &amp;gt; 1:&#xA;         ws = GamsWorkspace(system_directory = sys.argv[1])&#xA;     else:&#xA;         ws = GamsWorkspace()&#xA;  &#xA;     t3 = ws.add_job_from_string(get_data_text())&#xA;     t3.run()&#xA;     t3.out_db.export(os.path.join(ws.working_directory, &amp;quot;tdata.gdx&amp;quot;))&#xA;     t3 = ws.add_job_from_string(get_model_text())&#xA;  &#xA;     opt = ws.add_options()&#xA;     opt.defines[&amp;quot;gdxincname&amp;quot;] = &amp;quot;tdata&amp;quot;&#xA;     opt.all_model_types = &amp;quot;xpress&amp;quot;&#xA;     t3.run(opt)&#xA;     for rec in t3.out_db[&amp;quot;x&amp;quot;]:&#xA;         print(&amp;quot;x(&amp;quot; + rec.key(0) + &amp;quot;,&amp;quot; + rec.key(1) + &amp;quot;): level=&amp;quot; + str(rec.level) + &amp;quot; marginal=&amp;quot; + str(rec.marginal))&#xA;  &#xA;     t3a = ws.add_job_from_string(get_data_text())&#xA;     t3b = ws.add_job_from_string(get_model_text())&#xA;     t3a.run()&#xA;     opt.defines[&amp;quot;gdxincname&amp;quot;] = t3a.out_db.name&#xA;     t3b.run(opt, databases=t3a.out_db)&#xA;     for rec in t3b.out_db[&amp;quot;x&amp;quot;]:&#xA;         print(&amp;quot;x(&amp;quot; + rec.key(0) + &amp;quot;,&amp;quot; + rec.key(1) + &amp;quot;): level=&amp;quot; + str(rec.level) + &amp;quot; marginal=&amp;quot; + str(rec.marginal))&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4380" LastEditorUserId="36" LastEditDate="2020-11-06T18:53:59.513" LastActivityDate="2020-11-06T21:25:13.120" Title="How to build a GAMS model in python" Tags="|optimization|modeling|gams|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5161" PostTypeId="1" CreationDate="2020-11-06T20:13:24.853" Score="3" ViewCount="148" Body="&lt;p&gt;I'm tasked with solving a minimal cost flow problem. I'm asked to first use the Ford-Fulkerson algorithm on my graph to find a basic solution that will then be used to do the simplex method on that graph.&lt;/p&gt;&#xA;&lt;p&gt;Once I found the maximum possible flow I can have for my graph with the Ford-Fulkerson algorithm, do I use this information to get a basic solution for the simplex method? A basic solution is a partial tree that is linked to all the nodes in the graph, right?&lt;/p&gt;&#xA;&lt;p&gt;Because I have multiple sources and multiple destinations in my graph. I made a super source and a super destination and then applied the Ford-Fulkerson algorithm. When trying to find the basic solution what do I do with these nodes? Do I simply revert back to the original graph?&lt;/p&gt;&#xA;" OwnerUserId="4077" LastEditorUserId="500" LastEditDate="2020-11-06T20:46:06.330" LastActivityDate="2022-12-04T14:27:43.690" Title="Simplex method on graphs: How do I find a basic solution using the Ford-Fulkerson algorithm?" Tags="|linear-programming|graphs|network-flow|reduced-costs|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5162" PostTypeId="2" ParentId="5160" CreationDate="2020-11-06T21:25:13.120" Score="4" Body="&lt;p&gt;Unfortunately, GAMS does not have an independent low-level API language (such as CPLEX or Gurobi) and you will need to use its high-level language into your favourite API. In the simplest form, you can write your optimization problem in the gams file (.gms) and invoke it in python as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# transport1 example in the gams directory&#xA;from __future__ import print_function&#xA;from gams import *&#xA;import os&#xA;import sys&#xA;&#xA;&#xA;if __name__ == &amp;quot;__main__&amp;quot;:&#xA;    if len(sys.argv) &amp;gt; 1:&#xA;        ws = GamsWorkspace(system_directory = sys.argv[1])&#xA;    else:&#xA;        ws = GamsWorkspace()&#xA;&#xA;    ws.gamslib(&amp;quot;trnsport&amp;quot;)&#xA;    &#xA;    t1 = ws.add_job_from_file(&amp;quot;trnsport.gms&amp;quot;)&#xA;    t1.run()&#xA;    print(&amp;quot;Ran with Default:&amp;quot;)&#xA;&#xA;    for rec in t1.out_db[&amp;quot;x&amp;quot;]:&#xA;        print(&amp;quot;x(&amp;quot; + rec.key(0) + &amp;quot;,&amp;quot; + rec.key(1) + &amp;quot;): level=&amp;quot; + str(rec.level) + &amp;quot; marginal=&amp;quot; + str(rec.marginal))&#xA;    &#xA;    opt = ws.add_options()&#xA;    opt.all_model_types = &amp;quot;xpress&amp;quot;&#xA;    t1.run(opt)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you would like to write and modify your code simultaneously, you will have to follow up the mentioned template. (e.g. see transport6 example in the gams directory).&lt;/p&gt;&#xA;&lt;p&gt;Please noted that, GAMS (from ver. 25) has a studio platform with lots of features that would be interested if you do not have any force to use a low-level API.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-11-06T21:25:13.120" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5163" PostTypeId="1" AcceptedAnswerId="5166" CreationDate="2020-11-06T23:22:12.043" Score="8" ViewCount="824" Body="&lt;p&gt;When I mark a variable in a Gurobi MIP model as binary, sometimes Gurobi gives me a solution where that variable has a fractional value other than 0 or 1.  How do I constraint a variable to be honest-to-goodness truly binary?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/variables.html&quot; rel=&quot;noreferrer&quot;&gt;The Gurobi documentation says&lt;/a&gt; &amp;quot;integer variables will often take values that aren't exactly integral&amp;quot;. Gurobi allows setting &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/intfeastol.html&quot; rel=&quot;noreferrer&quot;&gt;IntFeasTol&lt;/a&gt; to a lower value, but this doesn't always solve the issue.  A staff member writes &amp;quot;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360012237872-Why-does-Gurobi-sometimes-return-non-integral-values-for-integer-variables-&quot; rel=&quot;noreferrer&quot;&gt;in many models, rounding to an exact integer value can create problems, such as making the solution infeasible&lt;/a&gt;&amp;quot; but if the result is that the model is infeasible, I would rather know that, instead of being returned a value that isn't actually integer. Is there a way to do this in Gurobi?&lt;/p&gt;&#xA;" OwnerUserId="2415" LastEditorUserId="3391" LastEditDate="2020-11-06T23:29:42.597" LastActivityDate="2020-11-07T16:02:24.017" Title="No, Gurobi, I really do want this variable to be binary" Tags="|mixed-integer-programming|gurobi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5165" PostTypeId="1" CreationDate="2020-11-07T15:23:19.993" Score="1" ViewCount="54" Body="&lt;p&gt;Gams problem instances can be saved in a .inc file what is basically just a .txt file and u can make gams read from that, but how can i automatize the generation process for those problem instances? I also want to generate random values in the process. I want to have the flexibility to create every possible instance size. What the best non-tedious way?&lt;/p&gt;&#xA;&lt;p&gt;example of the beginning of an .inc file&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Sets&#xA;         j               / P1*P3 /&#xA;         t               / T1*T10 /;&#xA;  &#xA;Scalar&#xA;         C               / 11 /;&#xA;&#xA;Table D(j,t) Demand&#xA;            T1        T2        T3        T4        T5        T6        T7        T8        T9        T10       T11       T12&#xA;P1          6         7         8         7         8         5         9         3         6         1         7         1         &#xA;P2          6         7         8         7         8         5         9         3         6         1         7         1         &#xA;P3          3         3         1         1         2         2         1         1         1         3         3         2  &#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4380" LastActivityDate="2020-11-07T15:23:19.993" Title="How to automatize instance generation for GAMS?" Tags="|solver|gams|test-instances|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5166" PostTypeId="2" ParentId="5163" CreationDate="2020-11-07T15:53:37.157" Score="10" Body="&lt;p&gt;Gurobi has apparently been listening to you and others with similar concerns. Gurobi 9.1 was just released and introduces a new parameter &lt;code&gt;IntegralityFocus&lt;/code&gt; to somewhat ameliorate those concerns (although I haven't tried it yet, so don't know how well).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/integralityfocus.html&quot; rel=&quot;noreferrer&quot;&gt;Gurobi 9.1 Reference Manual page for InetgralityFocus&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Integrality focus&lt;/strong&gt;&lt;br /&gt;&#xA;&lt;strong&gt;Type:&lt;/strong&gt;     int&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Default value:&lt;/strong&gt;    0&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Minimum value:&lt;/strong&gt;    0&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Maximum value:&lt;/strong&gt;    1&lt;/p&gt;&#xA;&lt;p&gt;One unfortunate reality in MIP is that integer variables don't always&#xA;take exact integral values. While this typically doesn't create&#xA;significant problems, in some situations the side-effects can be quite&#xA;undesirable. The best-known example is probably a trickle flow, where&#xA;a continuous variable that is meant to be zero when an associated&#xA;binary variable is zero instead takes a non-trivial value. More&#xA;precisely, given a constraint &lt;span class=&quot;math-container&quot;&gt;$y \le M b$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a non-negative continuous&#xA;variable, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a binary variable, and&#xA;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a constant that captures the largest&#xA;possible value of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, the constraint is&#xA;intended to enforce the relationship that&#xA;&lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; must be zero if&#xA;&lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is zero. With the default &lt;code&gt;integer feasibility tolerance&lt;/code&gt;, the binary variable is allowed to take a value&#xA;as large as &lt;span class=&quot;math-container&quot;&gt;$1e-5$&lt;/span&gt; while still being&#xA;considered as taking value zero. If the &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; value is large, then the &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; upper bound&#xA;on the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variable can be substantial.&lt;/p&gt;&#xA;&lt;p&gt;Reducing the value of the &lt;code&gt;IntFeasTol&lt;/code&gt; parameter can mitigate the&#xA;effects of such trickle flows, but often at a significant cost, and&#xA;often with limited success. The IntegralityFocus parameter provides a&#xA;better alternative. &lt;strong&gt;Setting this parameter to 1 requests that the&#xA;solver work harder to try to avoid solutions that exploit integrality&#xA;tolerances. More precisely, the solver tries to find solutions that&#xA;are still (nearly) feasible if all integer variables are rounded to&#xA;exact integral values. We should say that the solver won't always&#xA;succeed in finding such solutions, and that this setting introduces a&#xA;modest performance penalty, but the setting will significantly reduce&#xA;the frequency and magnitude of such violations&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-11-07T16:02:24.017" LastActivityDate="2020-11-07T16:02:24.017" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5167" PostTypeId="1" CreationDate="2020-11-07T23:18:31.037" Score="20" ViewCount="3190" Body="&lt;p&gt;If one recalls how the Simplex method is taught by hand in most LP classes it takes place entirely in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{Q}$&lt;/span&gt;. All operations yield exact fractions.&lt;/p&gt;&#xA;&lt;p&gt;For this reason I'm looking for linear programming library that doesn't use floats/doubles and other imprecise arithmetic but exclusively uses exact fractions; as I had done some work assuming exact fraction representation of my vertices.&lt;/p&gt;&#xA;&lt;p&gt;While anyone could build such a simplex solver by hand, I still want to avail the benefits of a commercial solver/well maintained open source tool in terms of speed (although I expect to lose some performance if not using state of the art algorithms/floating point arithmetic). What options are out there?&lt;/p&gt;&#xA;" OwnerUserId="1239" LastEditorUserId="8" LastEditDate="2020-12-12T20:02:48.410" LastActivityDate="2021-06-06T18:47:50.003" Title="Is there a Linear Programming Library that natively supports fractions instead of floating point arithmetic?" Tags="|linear-programming|solver|reference-request|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5169" PostTypeId="2" ParentId="5167" CreationDate="2020-11-08T00:04:06.317" Score="17" Body="&lt;p&gt;&lt;a href=&quot;http://www.math.uwaterloo.ca/%7Ebico//qsopt/ex/&quot; rel=&quot;noreferrer&quot;&gt;QSopt-Exact&lt;/a&gt; by Applegate, Cook, Dash, and Espinoza&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-11-08T00:52:07.710" LastActivityDate="2020-11-08T00:52:07.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5171" PostTypeId="2" ParentId="5167" CreationDate="2020-11-08T00:40:32.577" Score="6" Body="&lt;p&gt;I agree with Rob Pratt about QSopt-Exact.  That's probably the right thing to do if you're doing larger scale solves.&lt;/p&gt;&#xA;&lt;p&gt;I think that you can also do exact LP in Sage (using fractions).  Sage is based on Python, so this would be easy to code in, but you do have to download the whole Sage installation at this point.  But I don't think this would be quite as robust as QSopt-Exact.&lt;/p&gt;&#xA;" OwnerUserId="3043" LastActivityDate="2020-11-08T00:40:32.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5172" PostTypeId="1" CreationDate="2020-11-08T00:50:23.000" Score="6" ViewCount="222" Body="&lt;p&gt;Given a linear system of inequalities &lt;span class=&quot;math-container&quot;&gt;$Ax \geq b$&lt;/span&gt;, I would &lt;em&gt;ideally&lt;/em&gt; like to compute the irredundant set for those set of inequalities. I know how to do so mathematically, but I was wondering if there is a function implemented in CPLEX which the user can access and obtain the required irredundant set. When solving a LP using CPLEX, the solver seems to eliminate redundant inequalities as the first step, so I am wondering if it is possible for the user to access the pruned set (even if it is not the irredundant set). If it is possible, can someone please tell me how.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="869" LastEditDate="2020-11-11T11:13:58.003" LastActivityDate="2021-05-30T22:42:56.080" Title="Obtaining the system of irredundant inequalities from a set of inequalities using CPLEX" Tags="|linear-programming|cplex|presolve-preprocessing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5173" PostTypeId="2" ParentId="5167" CreationDate="2020-11-08T09:06:36.607" Score="10" Body="&lt;p&gt;&lt;a href=&quot;https://www.bugseng.com/parma-polyhedra-library&quot; rel=&quot;noreferrer&quot;&gt;Parma Polyhedra Library&lt;/a&gt; supports MIP on fractions. It's based on gmp and is used by &lt;a href=&quot;https://gcc.gnu.org/wiki/Graphite&quot; rel=&quot;noreferrer&quot;&gt;gcc&lt;/a&gt; and &lt;a href=&quot;https://julialang.org/&quot; rel=&quot;noreferrer&quot;&gt;Julia&lt;/a&gt; &lt;a href=&quot;https://www.bugseng.com/ppl-applications&quot; rel=&quot;noreferrer&quot;&gt;among other projects&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4388" LastActivityDate="2020-11-08T09:06:36.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5174" PostTypeId="2" ParentId="5167" CreationDate="2020-11-08T11:15:19.393" Score="7" Body="&lt;p&gt;You could also use &lt;a href=&quot;https://polymake.org/&quot; rel=&quot;noreferrer&quot;&gt;polymake&lt;/a&gt; which includes a few exact linear programming libraries (including my own one). It should also be possible to compile &lt;a href=&quot;https://soplex.zib.de/doc/html/EXACT.php&quot; rel=&quot;noreferrer&quot;&gt;SoPlex with GMP support&lt;/a&gt;, but I actually never tried it.&lt;/p&gt;&#xA;" OwnerUserId="3501" LastActivityDate="2020-11-08T11:15:19.393" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5175" PostTypeId="1" AcceptedAnswerId="5178" CreationDate="2020-11-08T12:59:39.850" Score="2" ViewCount="469" Body="&lt;p&gt;Metaheuristic algorithms are generally used to find the optimal solution to unconstrained optimization problems. I would like to maximize &lt;span class=&quot;math-container&quot;&gt;$x_1+3x_2-x_3\ge0$&lt;/span&gt; while respecting the equality constraint &lt;span class=&quot;math-container&quot;&gt;$x_1+x_2=5$&lt;/span&gt;. How can I do by using a metaheuristic method?&lt;/p&gt;&#xA;" OwnerUserId="4389" LastEditorUserId="3391" LastEditDate="2020-11-09T22:21:49.743" LastActivityDate="2020-11-12T08:00:37.697" Title="How to handle an equality constraint in metaheuristic algorithms (like GA, PSO)?" Tags="|optimization|constraint|metaheuristics|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5177" PostTypeId="2" ParentId="5167" CreationDate="2020-11-08T15:13:00.823" Score="11" Body="&lt;p&gt;I suggest &lt;a href=&quot;https://en.wikipedia.org/wiki/GNU_Linear_Programming_Kit&quot; rel=&quot;noreferrer&quot;&gt;GLPK&lt;/a&gt;, which has the advantage of being fully open source and easily available everywhere (as a package on most Linux distribution).&lt;/p&gt;&#xA;&lt;p&gt;Run it &lt;a href=&quot;https://en.wikibooks.org/wiki/GLPK/Using_GLPSOL&quot; rel=&quot;noreferrer&quot;&gt;from the command line&lt;/a&gt; with the --exact option. It is limited to LPs though (no MIPs), and not so easy to use directly from a programming language. From the &lt;a href=&quot;https://en.wikibooks.org/wiki/GLPK/GLPK_release_information#GLPK_4.13_(release_date:_Nov_13,_2006)&quot; rel=&quot;noreferrer&quot;&gt;release notes&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;h3&gt;GLPK 4.13 (release date: Nov 13, 2006)&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;    A tentative implementation of the &amp;quot;exact&amp;quot; simplex method based&#xA;    on bignum (rational) arithmetic was included in the package.&#xA;&#xA;    On API level this new feature is available through the routine&#xA;    lpx_exact, which is similar to the routine lpx_simplex.&#xA;&#xA;    In the solver glpsol this feature is available through two new&#xA;    command-line options: --exact and --xcheck. If the '--exact'&#xA;    option is specified, glpsol solves LP instance using the exact&#xA;    simplex method; in case of MIP it is used to obtain optimal&#xA;    solution of LP relaxation. If the --xcheck option is specified,&#xA;    LP instance (or LP relaxation) is solved using the standard&#xA;    (floating-point) simplex method, however, then glpsol calls the&#xA;    exact simplex routine to make sure that the final LP basis is&#xA;    exactly optimal, and if it is not, to perform some additional&#xA;    simplex iterations in exact arithmetic.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="1198" LastEditDate="2020-12-11T14:23:57.813" LastActivityDate="2020-12-11T14:23:57.813" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5178" PostTypeId="2" ParentId="5175" CreationDate="2020-11-08T19:13:20.600" Score="3" Body="&lt;p&gt;The random key variant [1] of genetic algorithms was developed, I believe, to solve sequencing (permutation) problems, but it can be adapted to at least some other types of constrained problems. Let &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; be the set of possible chromosomes and &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; the set of feasible solutions to the original problem. You provide a surjection &lt;span class=&quot;math-container&quot;&gt;$d:C\rightarrow X$&lt;/span&gt; that decodes chromosomes to feasible solutions. So if &lt;span class=&quot;math-container&quot;&gt;$f()$&lt;/span&gt; is the original objective function (expressed in terms of the original variables in the model) and &lt;span class=&quot;math-container&quot;&gt;$c\in C$&lt;/span&gt; is some chromosome, the fitness of &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is given by &lt;span class=&quot;math-container&quot;&gt;$f(d(c))$&lt;/span&gt;. Function &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; does not need to be injective -- it's OK if multiple chromosomes map to the same feasible solution -- but must be surjective (every feasible solution is represented by at least one chromosome). Importantly, every possible chromosome must map to a feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;So, for instance, you could define a chromosome to be a vector of two reals, decoded by &lt;span class=&quot;math-container&quot;&gt;$d(c) = (c_1, 5-c_1, c_2)$&lt;/span&gt; with fitness &lt;span class=&quot;math-container&quot;&gt;$f(d(c))=c_1 + 3(5-c_1) - c_2=15 -2c_1 - c_2$&lt;/span&gt;. Since you indicated the original objective function is nonnegative, I presume you have some bounds on the components of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. You would need to find the equivalent bounds for the genes &lt;span class=&quot;math-container&quot;&gt;$c_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_2$&lt;/span&gt; and then impose them as the domains of the genes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt;[1] Bean, J. C. Genetic Algorithms and Random Keys for Sequencing and Optimization. &lt;em&gt;ORSA Journal on Computing&lt;/em&gt;, &lt;strong&gt;1994&lt;/strong&gt;, &lt;em&gt;6&lt;/em&gt;, 154–160&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="491" LastEditDate="2020-11-11T13:36:04.577" LastActivityDate="2020-11-11T13:36:04.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5179" PostTypeId="1" CreationDate="2020-11-09T06:17:22.130" Score="2" ViewCount="31" Body="&lt;p&gt;Let's assume that we have a system where there are two exogenous factors, name &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, that can affect the system state. At each decision epoch either &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; occurs and it is not possible that they occur both at the same time. If &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; occurs (with probability &lt;span class=&quot;math-container&quot;&gt;$p(a)$&lt;/span&gt;) the only action for the agent is to wait and reward is zero. If &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; occurs (with probability &lt;span class=&quot;math-container&quot;&gt;$p(b)$&lt;/span&gt;) the agent has two options: action 1 and action 2 that happens immediately upon the occurrence of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. Actions 1 and 2 result in rewards &lt;span class=&quot;math-container&quot;&gt;$r_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r_2$&lt;/span&gt; respectively. Since actions are done immediately upon the occurrence of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, I was wondering how I can define transition probabilities for this system.&lt;/p&gt;&#xA;" OwnerUserId="4396" LastEditorUserId="123" LastEditDate="2020-11-09T08:37:57.330" LastActivityDate="2020-11-09T08:37:57.330" Title="MDP model for a unique system" Tags="|optimization|markov-decision-process|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5180" PostTypeId="2" ParentId="5175" CreationDate="2020-11-09T06:31:34.000" Score="3" Body="&lt;p&gt;One way in which you can handle constraints in evolutionary optimization is by adding &lt;a href=&quot;http://140.138.143.31/Teachers/Ycliang/Heuristic%20Optimization%20922/class%20note/penalty%20function.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;penalty functions&lt;/a&gt; to you original objective function (assuming a minimization problem at hand). This penalty function can be defined in several ways and its goal is to quantify the amount of constraint violation.&lt;/p&gt;&#xA;&lt;p&gt;However, implementing it sometimes is not as easy as it seems. The key problem comes with deciding the weight of penalty function you want to augment your original objective function with. This is in some sense a hyperparameter that you have to tune. An untuned amount of penalty can result in skewed objective function landscape with sharp constraint boundaries. Essentially you have to take care that original objective function and the penalty functions for the constrains are along approximately similar scales.&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2020-11-09T06:31:34.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5181" PostTypeId="1" CreationDate="2020-11-09T07:29:16.967" Score="4" ViewCount="263" Body="&lt;p&gt;I have to minimize a quantity &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; subject to the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ w_1 + w_2 + w_3  = 1 \tag{1}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \frac{f_1(w_1 Z) + f_2(w_2 Z) + f_3(w_3 Z)}{Z} \ge k \tag{2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is a known constant. &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f_3$&lt;/span&gt; are nonlinear functions that we have empirical curves for. These curves are approximately logarithmic (maybe this can help for the resolution). &lt;span class=&quot;math-container&quot;&gt;$w_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w_2$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$w_3$&lt;/span&gt; are weights whose optimal values are to be arrived at. &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; does not depend on the values of &lt;span class=&quot;math-container&quot;&gt;$w_1, w_2, w_3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am aware of basic linear programming techniques. However, I was unable to reduce constraint (2) into a linear constraint.&lt;/p&gt;&#xA;&lt;p&gt;Please note that I have posted a duplicate of &lt;a href=&quot;https://scicomp.stackexchange.com/questions/36256/how-can-i-deal-with-optimization-problems-that-have-a-sum-of-functions-of-z-as-a&quot;&gt;this question on SciComp SE&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;PS: Solutions that use Python would be ideal. However, I am more interested in the approach rather than the language/package used.&lt;/p&gt;&#xA;" OwnerUserId="4398" LastEditorUserId="491" LastEditDate="2020-11-09T19:35:41.573" LastActivityDate="2020-11-10T09:42:51.883" Title="How to deal with an optimization problem that have a sum of nonlinear functions of Z as a constraint when Z is the quantity to be minimized?" Tags="|optimization|nonlinear-programming|reformulation-linearization|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5182" PostTypeId="2" ParentId="5181" CreationDate="2020-11-09T08:53:02.017" Score="3" Body="&lt;p&gt;If well understood, w1, w2, w3, and Z are some continuous variables in your mathematical model, while k is a constant. If the functions f1, f2, f3 involved in constraint #2 are continuous and nonlinear, then the only way to proceed to solve the problem by using MILP techniques and solvers is to use piecewise linear approximations of these functions. There is a lot of literature on this. For example, you can have a look at this &lt;a href=&quot;https://optimization.mccormick.northwestern.edu/index.php/Piecewise_linear_approximation&quot; rel=&quot;nofollow noreferrer&quot;&gt;webpage&lt;/a&gt; for a short introduction.&lt;/p&gt;&#xA;&lt;p&gt;The main drawbacks in such an approach is that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Your model is only an approximation of your original problem.&lt;/li&gt;&#xA;&lt;li&gt;In many cases, piecewise linear approximations force you to introduce binary variables that make the resulting mixed-integer linear model much harder to solve than (purely continuous) linear models.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Roughly speaking, the stronger the nonlinearities, the more linear pieces you need for the approximation, the more you have additional binary variables to deal with the pieces, the harder is the resulting MILP model to solve.&lt;/p&gt;&#xA;&lt;p&gt;There exist some techniques and solvers, like LocalSolver, that allow tackling directly the original nonlinear formulation. LocalSolver uses piecewise linear approximations under the hood, but also some nonlinear optimization methods. With LocalSolver, you can give your three nonlinear functions f1, f2, f3 directly as arrays in your optimization model, or even as external functions (for example, if they can be simulated by some codes).&lt;/p&gt;&#xA;&lt;p&gt;Note: If your problem has only the 4 variables w1, w2, w3, Z to decide, then you can easily solve your problem by using a dedicated derivative-free heuristic as pointed out by prubin. For an example, check &lt;a href=&quot;https://or.stackexchange.com/questions/4248/linear-optimization-problem-with-user-defined-cost-function/4271#4271&quot;&gt;our answer&lt;/a&gt; to a similar post previously discussed on this forum.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Disclosure:&lt;/strong&gt; LocalSolver is our commercial software product.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2020-11-10T09:42:51.883" LastActivityDate="2020-11-10T09:42:51.883" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5183" PostTypeId="1" AcceptedAnswerId="5283" CreationDate="2020-11-09T14:02:49.763" Score="5" ViewCount="213" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$l,u\in\mathbb{R}^n$&lt;/span&gt;, and consider the QP:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{l\le x\le u} {(\Delta x)^\top (\Delta x)}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\Delta x=[x_2-x_1,\,x_3-x_2,\,\dots,\,x_n-x_{n-1}]^\top$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I.e. we want to minimize the squared change in the elements of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; being above the lower bound &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; and below the upper bound &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My hunch is that this is simple enough that it ought to have an exact &amp;quot;pooled adjacent violators algorithm (PAVA)&amp;quot; style solution. Is this correct? Has this problem been studied in the prior literature?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Aside: Of course as stated here the problem may have multiple solutions. I do not care which is returned.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Further aside: Here's MATLAB type code for an inefficient solution procedure. I expect there's a much more efficient algorithm!&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-matlab prettyprint-override&quot;&gt;&lt;code&gt;while true&#xA;&#xA;    xo = x;&#xA;&#xA;    x( 1 ) = max( l( 1 ), min( u( 1 ), x( 2 ) ) );&#xA;    for i = 2 : ( n - 1 )&#xA;        x( i ) = max( l( i ), min( u( i ), 0.5 * ( x( i - 1 ) + x( i + 1 ) ) ) );&#xA;    end&#xA;    x( n ) = max( l( n ), min( u( n ), x( n - 1 ) ) );&#xA;&#xA;    if all( abs( x - xo ) &amp;lt; 1e-12 )&#xA;        break&#xA;    end&#xA;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3830" LastEditorUserId="3830" LastEditDate="2020-11-10T08:08:53.500" LastActivityDate="2020-11-26T13:56:08.953" Title="PAVA-like solution to simple QP" Tags="|quadratic-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5184" PostTypeId="2" ParentId="5181" CreationDate="2020-11-09T19:07:22.217" Score="1" Body="&lt;p&gt;If you are willing to take an approximate solution (no guarantee of optimality), it should be fairly easy to apply any of a number of metaheuristics to your problem. It would be helpful if, for fixed &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f_i(w_i Z)/Z$&lt;/span&gt; were monotone in &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; (with all such ratios monotone in the same direction, increasing or decreasing). If they are not all monotonic, you could probably still get at least some metaheuristics to work.&lt;/p&gt;&#xA;&lt;p&gt;I'm fairly certain that you can find Python packages for most of the commonly used metaheuristics. Selecting a metaheuristic is somewhat a function of taste (or should I say religious preference, given the fervor of some of their adherents?). Under the monotonicity assumption I mentioned (and assuming all variables are nonnegative), I suspect I could get a genetic algorithm (my go-to choice) to handle the constraints properly.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-11-09T19:07:22.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5186" PostTypeId="1" CreationDate="2020-11-09T22:38:54.660" Score="1" ViewCount="137" Body="&lt;p&gt;I am new to GAMS and the documentation is not helping me to make fast progress.&#xA;I am looking for an example implementation similar to Relax and Fix heuristic&#xA;where in several iterations subsets of binary variables are relaxed/fixed.&lt;/p&gt;&#xA;" OwnerUserId="4380" LastEditorUserId="491" LastEditDate="2020-11-11T02:19:31.800" LastActivityDate="2020-11-11T02:19:31.800" Title="Looking for an example of a heuristic implementation in GAMS" Tags="|mixed-integer-programming|solver|metaheuristics|heuristics|gams|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5187" PostTypeId="2" ParentId="5157" CreationDate="2020-11-10T00:09:20.573" Score="4" Body="&lt;p&gt;More than speedup improvement factors on a bunch of abstract LP/MPS files, we at LocalSolver think that this is more interesting to look at &lt;em&gt;problems&lt;/em&gt;. We look at academic problems, used as benchmarks by the research, and at the core of many industrial problems. Here are some examples: traveling salesman, vehicle routing, job scheduling, multidimensional knapsack, bin packing, facility location, quadratic assignment, clustering like k-means, unit commitment, network design, optimal power flow, pooling, portfolio optimization, pricing optimization, etc. We look at problems posed in the context of OR competitions like the &lt;a href=&quot;https://www.roadef.org/challenge/2020/en/index.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;ROADEF challenges&lt;/a&gt;. But mostly, we look at the problems of our clients.&lt;/p&gt;&#xA;&lt;p&gt;For each problem, we benchmark LocalSolver against the latest research. We mostly look at the size of the instances which are solvable to near optimality in minutes. Because according to us, this is what users want in the industry. For each problem, the goal is to reach the scale of the instances encountered in practice. We first concentrate on delivering near-optimal solutions in minutes, even with bad lower bounds. Then, we work to reach near-optimal lower bounds, that is, the holy grail of near-optimal gaps.&lt;/p&gt;&#xA;&lt;p&gt;Over the next 10 years, what will be really interesting will be to have more problems &amp;quot;solved&amp;quot; according to the definition above. For example, we started working on the Capacitated Vehicle Routing Problem (CVRP) almost 10 years ago. In the prototype version developed in 2010, modeling the CVRP was tedious and we got almost no feasible solution to instances with just 10 clients to serve. With the last 9.5 version released in 2020, LocalSolver finds near-optimal solutions in minutes to CVRP instances with hundreds of clients to serve. Moreover, this is possible by using using a 10-line mathematical model. In the next version 10, LocalSolver will provide quality lower bounds for instances with 100 clients.&lt;/p&gt;&#xA;&lt;p&gt;Our goal is not to make publicity here but to share views and practices that may help to improve optimization solvers, which are important tools for the practice of OR.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-11-10T00:09:20.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5188" PostTypeId="2" ParentId="5186" CreationDate="2020-11-10T10:17:53.043" Score="5" Body="&lt;p&gt;To fix a variable use &lt;code&gt;x.fx(i) = 1&lt;/code&gt;. To unfix: &lt;code&gt;x.lo(i) = 0; x.up(i) = 1;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To relax an integer/binary variable you can use: &lt;code&gt;x.prior(i)=INF&lt;/code&gt;;&lt;/p&gt;&#xA;&lt;p&gt;Documentation of this can be found at the obvious place: &lt;a href=&quot;https://www.gams.com/latest/docs/UG_Variables.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gams.com/latest/docs/UG_Variables.html&lt;/a&gt;. &lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2008/06/rolling-horizon-implementation-in-gams.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is an example of how to use this.&lt;/p&gt;&#xA;" OwnerUserId="907" LastActivityDate="2020-11-10T10:17:53.043" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="5189" PostTypeId="2" ParentId="5175" CreationDate="2020-11-10T12:19:13.917" Score="4" Body="&lt;p&gt;You can create moves (neighborhoods) that don't impact the equality constraint.&lt;/p&gt;&#xA;&lt;p&gt;For example in &lt;a href=&quot;https://www.youtube.com/watch?v=NdyIf0JG94Y&quot; rel=&quot;nofollow noreferrer&quot;&gt;investment portfolio&lt;/a&gt; I added &lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/src/main/java/org/optaplanner/examples/investment/solver/move&quot; rel=&quot;nofollow noreferrer&quot;&gt;this custom move&lt;/a&gt; in OptaPlanner (java, open source) that uses Local Search configuration (Late Acceptance probably).&lt;/p&gt;&#xA;&lt;p&gt;Elaboration:&lt;/p&gt;&#xA;&lt;p&gt;In that example we need to decide how which percentage of our budget to invest in which assets (such as stocks). In the end, we need to invest 100% of our budget (total=100%). Now presume that in Local Search at some point we have 0% in asset A, 50% in asset B, 30% in asset C and 20% in asset D. A typical change move will add/remove a percentage for an asset, without balancing it out somewhere, so it break the &amp;quot;total=100%&amp;quot; hard constraint. Instead, we replaced all the out-of-the-box move selectors (=neighborhoods) with a set that never breaks the  &amp;quot;total=100%&amp;quot; constraint. That InvestmentQuantityTransferMove takes a a part of percentage assigned to one asset and assigns it to another. For example, take 5% from B and assign it to A, so it results in 5% in asset A, 45% in asset B, 30% in asset C and 20% in asset D.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2020-11-12T08:00:37.697" LastActivityDate="2020-11-12T08:00:37.697" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5191" PostTypeId="2" ParentId="4772" CreationDate="2020-11-10T18:09:09.860" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/Kuifje02/vrpy&quot; rel=&quot;nofollow noreferrer&quot;&gt;VRPy&lt;/a&gt; (v0.3.0) now supports this option : all you have to do is set the &lt;code&gt;minimize_global_span&lt;/code&gt; option to &lt;code&gt;True&lt;/code&gt; when instantiating the &lt;code&gt;VehicleRoutingProblem&lt;/code&gt; object:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;prob = VehicleRoutingProblem(G, num_vehicles=2, minimize_global_span=True)&#xA;prob.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Of course, your graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; has to be well defined in the first place.&lt;/p&gt;&#xA;&lt;p&gt;The formulation proposed by @RobPratt is implemented. If you play around with some toy problems, you will see that the formulation is weak compared to the classical one (without the makespan). It is easy to see that the constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z - \sum_{p\in P} \left(\sum_{i,j} c_{i,j}x_{i,j}^p\right) \lambda^p_v \ge 0 \quad \text{    for $v\in V$} &#xA;$$&lt;/span&gt;&#xA;is responsible for this.&lt;/p&gt;&#xA;&lt;p&gt;You can also try the following alternative approach :&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Solve the problem without the min_max option&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Query the largest span&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Solve again without min_max, but constrain the problem such that each route has a smaller span than the largest one queried in 2.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If infeasible, stop, otherwise, go to step 2.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;All of this is straightforward with VRPy's ecosystem. Have fun.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-11-10T18:55:30.600" LastActivityDate="2020-11-10T18:55:30.600" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5193" PostTypeId="2" ParentId="5157" CreationDate="2020-11-11T10:17:59.797" Score="21" Body="&lt;p&gt;I work at a solver company (SAS Institute Inc.) and can probably weigh in on this a little bit.&lt;/p&gt;&#xA;&lt;p&gt;The problem with saying anything about performance is that there is a lot of variability between instances in mixed integer programming. Naturally that evens out a bit if looking at a longer time frame and more instances. In the past solver developers typically lacked the resources to get data from running a lot of instances (and almost never added randomization). This has been changing in the last few years so benchmarking got better but that meant that the resulting perceived gains got smaller.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What speed-up is it most likely we will see in the next 10 years?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;From my experience, and also from talking to other people in my field, I would guess that an average improvement on a big set of instances (thousands) of about factor 1.3 year-to-year is a good year in solver development. This might vary a lot, but that is the number that is in my head.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What are the reasons for a lower rate in the future than what we have seen in the last 30 years?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There was a time in the late 90s and early 2000s in which the solver companies mined the research community for useful results and achieved a lot of speedup. Recently, in my perception, less research is focused on mixed integer linear programming, so there is probably less to mine there.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What are the reasons for a higher rate in the future than what we have seen in the last 30 years?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;More computing resources allow for more benchmarking and more experimentation. Also storing more test data is less of a problem than it used to be. There is always a chance that revolutionary new algorithm idea emerges, but I would not hold my breath for that. Solvers are very sophisticated, any significant improvement kind of has to build on what we already have or it will be very time consuming to re-do all the previous work in a different framework.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Which trends and technologies will have an impact on this?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Some people claim that tuning and making decisions in the solver with machine learning will make a huge impact, but I personally am skeptical and am not aware of a real breakthrough result there. More cores and more parallelization are also not going to help, except maybe from improvements in compilers and programming languages, such as micro-threading and the like. From all information I have, quantum computing is many, many years away from being reliable and accurate enough to matter for linear algebra heavy applications, if it ever gets there, so I don't think it will matter in your 10 year timeframe. The best bet is improvements from theoretical results that are successfully transferred into working code. In the past that was  what made solvers faster, the last big innovation there, symmetry handling through orbital branching, was such a deeply mathematical result applied in a clever way to solve certain instances.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2020-11-11T10:17:59.797" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5195" PostTypeId="1" CreationDate="2020-11-11T14:41:37.903" Score="0" ViewCount="317" Body="&lt;p&gt;I am looking for a way to write data from several iterations during a loop process into my excel.&#xA;How can i change the location it is written to during every loop iteration?&lt;/p&gt;&#xA;&lt;p&gt;those 2 lines would keep writing everything in the same place if i start repeating the command.&#xA;Can i somehow make it change the sheet every iteration?&lt;/p&gt;&#xA;&lt;p&gt;´´´&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;loop(t,&#xA;    execute_unload &amp;quot;Results_Country1.gdx&amp;quot; y.l&#xA;    execute 'gdxxrw.exe Results_Country1.gdx var=y.L'&#xA;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;´´´´&lt;/p&gt;&#xA;" OwnerUserId="4380" LastEditorUserId="39" LastEditDate="2020-11-11T21:49:50.550" LastActivityDate="2020-11-12T14:20:47.967" Title="GAMS export to excel in a loop" Tags="|gams|excel|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5196" PostTypeId="1" AcceptedAnswerId="5197" CreationDate="2020-11-11T17:49:15.267" Score="3" ViewCount="502" Body="&lt;p&gt;I'm writing a code for solving the &lt;strong&gt;MDS&lt;/strong&gt; problem, the problem is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_{v\in V}y_v\\\text{s.t.}&amp;amp;\quad y_v+\sum_{(u,v)\in E}y_u\ge1\quad\forall v\in V\\&amp;amp;\quad y_v\in\{0,1\}\quad\forall v\in V.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have used &lt;strong&gt;Pulp&lt;/strong&gt; and &lt;strong&gt;nx.network&lt;/strong&gt; in python to model the problem as following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The problem &lt;code&gt;prob = pulp.LpProblem(&amp;quot;MinimumDominatingSet&amp;quot;, pulp.LpMinimize)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Variables &lt;code&gt;y = pulp.LpVariable.dicts(&amp;quot;y&amp;quot;, g.nodes(), cat=pulp.LpBinary)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The objective &lt;code&gt;for (v,u) in g.edges(): prob += pulp.lpSum(y)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Constraint &lt;code&gt;for (v,u) in g.edges():   prob += y.get(v) + sum(y.get(u) for (v,u) in g.edges) &amp;gt;= 1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I have tried to test the output with a simple star figure. Unfortunately, the output is not correct.&#xA;I'm suspecting there may be an issue with modeling the constraint.&lt;/p&gt;&#xA;&lt;p&gt;Could anyone guide me through this?&lt;/p&gt;&#xA;" OwnerUserId="4347" LastEditorUserId="123" LastEditDate="2020-11-12T11:49:00.447" LastActivityDate="2020-11-12T11:49:00.447" Title="Python modeling for ILP Minimum Dominating Set (MDS)" Tags="|mixed-integer-programming|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5197" PostTypeId="2" ParentId="5196" CreationDate="2020-11-11T17:55:16.000" Score="3" Body="&lt;p&gt;Your objective should be &lt;code&gt;prob+= pulp.lpSum(y)&lt;/code&gt;, and the constraints should be :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for v in g.nodes():&#xA;       prob += y[v] + pulp.lpSum([y[u] for u in g.neighbors(v)]) &amp;gt;= 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-11-12T08:24:46.277" LastActivityDate="2020-11-12T08:24:46.277" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5198" PostTypeId="1" AcceptedAnswerId="5199" CreationDate="2020-11-11T18:05:51.577" Score="2" ViewCount="868" Body="&lt;p&gt;I have trouble finding a solution to the following problem. I have a decision variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. If the value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is between 0 and a constant &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, then the binary variable &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; must be equal to 1. If &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is greater than &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; but lower than another constant &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, then the binary variable &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; must be equal to 1 while the &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; must be equal to 0. If &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; goes above &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, the binary variable &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt; must be equal to 1 while &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; must be equal to 0.&lt;/p&gt;&#xA;&lt;p&gt;I tried using the Big &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; method as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x \le Ay_1 \tag{1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The problem here is that if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; goes above &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is infeasible. Then I created three new decision variables &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; that could &amp;quot;follow&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; for a certain amount:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x = (x_1 y_1)+(x_2 y_2)+(x_3 y_3) \tag{2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_1 \le A y_1 \tag{1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_2 \ge A y_2 \tag{3}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_2 \le B y_2 \tag{4}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_3 \ge B y_3 \tag{5} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This does not work: the solver tells me it is infeasible. I'm using OpenSolver in Excel. How can I resolve this?&lt;/p&gt;&#xA;" OwnerUserId="4410" LastEditorUserId="3391" LastEditDate="2020-11-16T10:00:35.070" LastActivityDate="2020-11-16T10:00:35.070" Title="If-Then-Else modeling in MILP using the Big M method" Tags="|mixed-integer-programming|big-m|excel|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5199" PostTypeId="2" ParentId="5198" CreationDate="2020-11-11T18:13:50.780" Score="10" Body="&lt;p&gt;There is some ambiguity about the strictness of above/beneath, but does the following do what you want?&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;0y_1 + Ay_2 + By_3 \le x \le Ay_1 + By_2 + Cy_3 \\&#xA;y_1 + y_2 + y_3 = 1&#xA;$$&lt;/span&gt;&#xA;Checking, we have:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_1 = 1 &amp;amp;\implies x \in [0,A] \\&#xA;y_2 = 1 &amp;amp;\implies x \in [A,B] \\&#xA;y_3 = 1 &amp;amp;\implies x \in [B,C] \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-11-11T19:19:48.687" LastActivityDate="2020-11-11T19:19:48.687" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5200" PostTypeId="2" ParentId="5195" CreationDate="2020-11-11T23:20:12.810" Score="4" Body="&lt;p&gt;It is much better to collect all &lt;code&gt;y.l(i)&lt;/code&gt; in a parameter with an extra index &lt;code&gt;t&lt;/code&gt;, and export that in one swoop. I.e.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;parameter results(t,i); &#xA;loop(t,&#xA;*  calculate y.l(i)&#xA;    solve ...;&#xA;    results(t,i) = y.l(i);  &#xA;); &#xA;execute_unload &amp;quot;AllResults.gdx&amp;quot;, results;&#xA;execute 'gdxxrw.exe AllResults.gdx par=results';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Calls to Excel are expensive so they should preferably not be done inside a loop. It also helps structuring the model a bit better: separate model logic from reporting. Mixing them often leads to messy models. In addition, combining things in a larger multidimensional &amp;quot;cube&amp;quot; has some advantages for Excel: we can do filtering, pivot tables, pivot charts, store in data model etc.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2020-11-12T14:20:47.967" LastActivityDate="2020-11-12T14:20:47.967" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5201" PostTypeId="1" AcceptedAnswerId="5203" CreationDate="2020-11-12T03:14:14.083" Score="3" ViewCount="147" Body="&lt;p&gt;I'm trying to model a constraint in Python using Pulp and networkX that is getting the sum of the edges that contain this node over all the nodes. The constraint can be like that:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{m\in\cal N}z_{(m,n)}\succeq k(1-y_m),\quad\forall m\in\cal N.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have used this code to model the constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;for m in g.nodes(): prob +=  pulp.lpSum(z[(m,n)] for m in g.nodes()) &amp;gt;= k*(1-y[m])&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;This piece of code rises an error about the key of the dictionary since the variable dictionary &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; doesn't contains all the neighbors values. If I used this instead&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;for m in g.nodes(): prob +=  pulp.lpSum(z[(m,n)] for (u,v) in g.edges()) &amp;gt;= k*(1-y[m])&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;It sums all the links, not the ones associated with link &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would like your help with this!.&lt;/p&gt;&#xA;&lt;p&gt;Please be noted that &lt;span class=&quot;math-container&quot;&gt;$z_{(m,n)}$&lt;/span&gt; is a dict of the graph edges&lt;/p&gt;&#xA;" OwnerUserId="4347" LastEditorUserId="123" LastEditDate="2020-11-12T11:47:02.743" LastActivityDate="2020-11-12T11:47:02.743" Title="Summation of all links that contains nieghbors to certain node in Graph" Tags="|optimization|python|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5202" PostTypeId="2" ParentId="5201" CreationDate="2020-11-12T07:17:09.510" Score="2" Body="&lt;p&gt;You can use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;all_neighbors(graph, node): Returns all of the neighbors of a node in the graph.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;function in networkX to find all the nodes which are connected to node m and then use the first constraint that you mentioned. I think there is a typo in the constraint as well instead of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; you should have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; (it's confusing). The output of that function is &lt;code&gt;iterator&lt;/code&gt; you need to save it as a list (I am not sure about the format that PuLP accept).&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-11-12T07:17:09.510" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5203" PostTypeId="2" ParentId="5201" CreationDate="2020-11-12T08:22:18.563" Score="4" Body="&lt;p&gt;Alternatively, just like in your &lt;a href=&quot;https://or.stackexchange.com/questions/5196/python-modeling-for-ilp-minimum-dominating-set-mds&quot;&gt;previous question&lt;/a&gt; :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for m in g.nodes():&#xA;    prob += pulp.lpSum(z[(m,n)] for n in g.neighbors(m)) &amp;gt;= k*(1-y[m])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-11-12T08:22:18.563" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5204" PostTypeId="1" CreationDate="2020-11-12T09:57:59.340" Score="1" ViewCount="170" Body="&lt;p&gt;I will use a meta-heuristic algorithm, to maximize the following objective functions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Objective function 1 &lt;span class=&quot;math-container&quot;&gt;$=\sum\limits_{r=1}^{M} \sum\limits_{s=r+1}^{M} \sum\limits_{j=r+1}^{N}  (r_{rj}w_j - r_{sj}w_j)  $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Objective function 2 &lt;span class=&quot;math-container&quot;&gt;$= \sum\limits_{j=r+1}^{N} [(2w_1r_{1j} ) + (0.5w_2r_{2j})+(1w_3r_{3j}) ] $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;subject to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$  0 \le w_1, w_2, w_3 \le 10$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$ w_1+ w_2+ w_3 = 10$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Can I combine two objective functions if they have a relation between them? Or consider the problem as a multi-objective optimization problem?&lt;/p&gt;&#xA;" OwnerUserId="4389" LastEditorUserId="123" LastEditDate="2020-11-12T11:51:04.033" LastActivityDate="2020-11-12T11:51:04.033" Title="Can I combine two objective functions if they have a relation between them?" Tags="|combinatorial-optimization|multi-objective-optimization|penalty-based-optimization|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5206" PostTypeId="1" AcceptedAnswerId="5207" CreationDate="2020-11-12T13:37:23.407" Score="3" ViewCount="171" Body="&lt;p&gt;I'm trying to model this constraint in an optimization problem using Pulp and NetworkX. Here is a piece of code I'm using.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pulp &#xA;import networkx as nx&#xA;&#xA;g = nx.Graph() &#xA;&#xA;links = [(1,2),(1,4),(1,5),(2,5),(2,3),(3,5),(3,4),(4,5)] &#xA;&#xA;g.add_edges_from(links)&#xA;&#xA;#The problem&#xA;prob = pulp.LpProblem(&amp;quot;MinimumSetVertexCover&amp;quot;, pulp.LpMinimize)&#xA;&#xA;# The variables&#xA;y = pulp.LpVariable.dicts(&amp;quot;y&amp;quot;, g.nodes(), cat=pulp.LpBinary)&#xA;z = pulp.LpVariable.dicts(&amp;quot;z&amp;quot;, g.edges(), cat=pulp.LpBinary)&#xA;&#xA;#The objective function&#xA;&#xA;for (u,v) in g.edges():&#xA;    prob += pulp.lpSum(y) + pulp.lpSum(z)&#xA;&#xA;#The constraints&#xA;for (u,v) in g.edges():&#xA;    prob += z[(u,v)] &amp;lt;= y[v]&#xA;    prob += z[(u,v)] &amp;lt;= 1-y[u]&#xA;for v in g.nodes():&#xA;    prob +=  pulp.lpSum([z[(u,v)] for v in g.neighbors(u)]) &amp;gt;= 2*(1-y[v])    &#xA;&#xA;prob.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The optimizer throws this error &lt;code&gt;         ---&amp;gt; 55     prob +=  pulp.lpSum([z[(u,v)] for v in g.neighbors(u)]) &amp;gt;= 2*(1-y[v]) KeyError: (5, 1)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4347" LastEditorUserId="491" LastEditDate="2022-04-05T15:43:07.803" LastActivityDate="2022-04-05T15:43:07.803" Title="Sum of links neighbors in a graph" Tags="|optimization|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5207" PostTypeId="2" ParentId="5206" CreationDate="2020-11-12T13:45:42.357" Score="4" Body="&lt;p&gt;This is because you are trying to call &lt;code&gt;z[(5,1)]&lt;/code&gt;, while your variable is &lt;code&gt;z[(1,5)]&lt;/code&gt;. Also &lt;code&gt;u&lt;/code&gt; and &lt;code&gt;v&lt;/code&gt; are mixed up in the last constraint.&lt;/p&gt;&#xA;&lt;p&gt;You can try:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for v in g.nodes():&#xA;    prob +=  pulp.lpSum([z[(u,v)] for u in g.neighbors(v) if (u,v) in z]) + pulp.lpSum([z[(v,u)] for u in g.neighbors(v) if (v,u) in z]) &amp;gt;= 2*(1-y[v]) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-11-12T14:25:27.670" LastActivityDate="2020-11-12T14:25:27.670" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5208" PostTypeId="1" CreationDate="2020-11-12T16:55:09.567" Score="1" ViewCount="459" Body="&lt;p&gt;I wrote my model down in GAMS:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;all sets&lt;/li&gt;&#xA;&lt;li&gt;parameter&lt;/li&gt;&#xA;&lt;li&gt;obj. function&lt;/li&gt;&#xA;&lt;li&gt;constraints&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;and used $include in order to feed the model differently sized data...&#xA;I am currently using&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$include &amp;quot;C:\Users\...\GAMS modelling\P3T5.inc&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;in order to import my data file.&lt;/p&gt;&#xA;&lt;p&gt;My file name is always &amp;quot;P{number of products}T{Number of time periods}.inc&amp;quot;&#xA;What would be the best way to access all the files in a loop? How can I change the file name during the loop statement? I am thinking of making a set of all product numbers and period numbers, but I don't know how to use the index in the loop to alter the command of the include.&lt;/p&gt;&#xA;" OwnerUserId="4380" LastEditorUserId="279" LastEditDate="2021-08-08T22:28:56.367" LastActivityDate="2021-08-08T22:28:56.367" Title="How can one iterate over all instances and solve them in GAMS?" Tags="|solver|gams|test-instances|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5210" PostTypeId="1" AcceptedAnswerId="5222" CreationDate="2020-11-13T03:32:09.777" Score="3" ViewCount="352" Body="&lt;p&gt;Does anybody have an example of the vehicle routing problem with time windows (VRPTW), implemented on Python with CPLEX library, AMPL, or MiniZinc? So far I've looked into &lt;code&gt;https://github.com/industrial-ucn/jupyter-examples/blob/master/optimization/cvrp-cplex.ipynb&lt;/code&gt; which I found really helpful for the VRP problem, but I'm looking for VRPTW implementation.&#xA;I haven't found any example for MiniZinc yet. So if anybody has one at hand so I could try to understand.&lt;/p&gt;&#xA;" OwnerUserId="4416" LastActivityDate="2020-11-15T20:38:01.537" Title="VRPTW implementation" Tags="|vehicle-routing|ampl|minizinc|cplex-python-api|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5211" PostTypeId="1" CreationDate="2020-11-13T12:04:49.410" Score="8" ViewCount="2395" Body="&lt;p&gt;I found in the literature different gaps:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a gap between a random solution and an exact solution&lt;/li&gt;&#xA;&lt;li&gt;a gap between the exact solution and a lower bound&lt;/li&gt;&#xA;&lt;li&gt;a gap between the exact solution and a lower bound&lt;/li&gt;&#xA;&lt;li&gt;a gap between lower bound and upper bound&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I am confused when writing the corresponding formula of each gap: what is the rule ( ?- ?)/(?)  ?&lt;/p&gt;&#xA;&lt;p&gt;Shall I use the gap between lower bound and upper bound only if I don't have an exact solution?&lt;/p&gt;&#xA;&lt;p&gt;And what is the significance between these gaps and the gap returned by Cplex in terms of %?&lt;/p&gt;&#xA;" OwnerUserId="4273" LastEditorUserId="123" LastEditDate="2021-06-11T21:00:39.330" LastActivityDate="2021-12-24T16:14:49.637" Title="How to determine different gap rates?" Tags="|optimization|cplex|global-optimality|optimality-conditions|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5213" PostTypeId="2" ParentId="244" CreationDate="2020-11-13T13:32:40.660" Score="1" Body="&lt;p&gt;There is also:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://gaslib.zib.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GasLib&lt;/a&gt;, with gas network instances based on perturbed real-world data.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="126" LastActivityDate="2020-11-13T13:32:40.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5215" PostTypeId="2" ParentId="5208" CreationDate="2020-11-13T16:50:37.787" Score="3" Body="&lt;p&gt;You cannot loop over include files ($include is compile-time, while loop is execution- time, this is similar to say C where you cannot loop over #include). One could loop over complete GAMS models (call gams inside a loop), or over reading data from GDX (GAMS data) files. But often a better approach is the following.&lt;/p&gt;&#xA;&lt;p&gt;I would just read in all problem data in one big swoop (possibly with an extra index indicating the scenario). Once you have all the data (checked and possibly transformed) do a solve loop. This was discussed already before in a previous question. So, to summarize, I usually do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; 1. load all data, do data checks and data transformations&#xA; 2. loop over scenarios, execute solve statements, and collect results&#xA; 3. reporting&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This approach has many advantages, not in the least better structuring of the model. Cleanly organized models are much to be preferred over messy models. In addition, checking all data before starting solving is often more convenient than intersperse these operations (I want to stop and complain before running expensive solves). This approach makes it also easier to use more advanced techniques such as parallel processing and using the scenario solver.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2020-11-13T17:19:48.900" LastActivityDate="2020-11-13T17:19:48.900" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5216" PostTypeId="1" CreationDate="2020-11-13T18:16:22.997" Score="1" ViewCount="127" Body="&lt;p&gt;I am working on the following problem:&lt;/p&gt;&#xA;&lt;p&gt;I have a scheduling problem with time-varying capacities and other characteristics that are not treated in classic Job Shop or Flow Shop.&lt;/p&gt;&#xA;&lt;p&gt;How to &lt;em&gt;generate&lt;/em&gt; such data in order to test algorithms ?  I am not looking to solve the problem.&lt;/p&gt;&#xA;&lt;p&gt;P.S: I took a look in literature for data sets from job shop, rcpsp and flow shop problems. I couldn't find all the aspects I wanted.&lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="4358" LastEditDate="2020-11-17T22:16:51.550" LastActivityDate="2020-11-17T22:16:51.550" Title="How to generate data for test?" Tags="|simulation|data|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="5217" PostTypeId="2" ParentId="5211" CreationDate="2020-11-13T21:32:21.750" Score="10" Body="&lt;p&gt;MIP solvers such as CPLEX &amp;amp; Gurobi indicate a gap (in %) between the current best solution and the current best dual bound (which is a lower bound for a minimization problem).&#xA;In general, the optimum value is not known until, well, the problem is solved.&lt;/p&gt;&#xA;&lt;p&gt;Different solvers may use slightly different definitions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/en/SS9UKU_12.10.0/com.ibm.cplex.zos.help/CPLEX/Parameters/topics/EpGap.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPLEX&lt;/a&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ g = \frac{|Z_{\rm dual} - Z_{\rm primal}|}{10^{-10} + |Z_{\rm primal}|}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/mipgap.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi&lt;/a&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ g = \frac{|Z_{\rm dual} - Z_{\rm primal}|}{|Z_{\rm primal}|}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.scipopt.org/doc/html/PARAMETERS.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;SCIP&lt;/a&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ g = \frac{|Z_{\rm dual} - Z_{\rm primal}|}{\min (|Z_{\rm dual}|, |Z_{\rm primal}|)} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In the case of CPLEX and Gurobi, you may interpret this as &amp;quot;the current solution cannot be improved by more than &lt;span class=&quot;math-container&quot;&gt;$g\%$&lt;/span&gt;&amp;quot;.&#xA;For a minimization problem, if the current best solution has objective value &lt;span class=&quot;math-container&quot;&gt;$150$&lt;/span&gt; and the current gap is &lt;span class=&quot;math-container&quot;&gt;$2.3\%$&lt;/span&gt;, then there does not exist a feasible solution with objective value less than &lt;span class=&quot;math-container&quot;&gt;$150 - \frac{2.3}{100} \times 150 = 146.55$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There are obviously some limitations to this formula:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the primal and lower bound have different signs&lt;/li&gt;&#xA;&lt;li&gt;If the primal value is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If no primal or dual bound is known (some solvers will report a gap of &lt;span class=&quot;math-container&quot;&gt;$+\infty$&lt;/span&gt;, some will report a gap of &lt;span class=&quot;math-container&quot;&gt;$100 \%$&lt;/span&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="123" LastEditDate="2021-06-11T21:01:07.787" LastActivityDate="2021-06-11T21:01:07.787" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5218" PostTypeId="2" ParentId="5211" CreationDate="2020-11-13T21:34:54.960" Score="7" Body="&lt;p&gt;Gaps are typically tied to specific models and solution methods. The gap reflects the difference between the best known bound and the objective value of the best solution produced by a particular algorithm. How that is computed depends in part on whether you are minimizing and maximizing, in part on whether you want the gap as a fraction of the best solution or best bound, and in part on how you avoid dividing by zero. I believe expressing the gap as a fraction of the best bound is the more common approach, but I hesitate to say that it is universally adopted.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\hat{f}$&lt;/span&gt; is the objective value of the incumbent (best known feasible solution) and &lt;span class=&quot;math-container&quot;&gt;$\bar{f}$&lt;/span&gt; is the best known bound for the objective function, CPLEX computes the gap as &lt;span class=&quot;math-container&quot;&gt;$$\frac{|\hat{f}-\bar{f}|}{|\bar{f}| + 10^{-10}}$$&lt;/span&gt; (and converts it to a percentage in the node log).&lt;/p&gt;&#xA;&lt;p&gt;Regarding the difference between lower and upper bound, in a minimization problem the best known solution (whether known to be optimal or just the current incumbent) gives you the upper bound, and for a maximization the best known solution gives you the lower bound. So this is no different from the previous case.&lt;/p&gt;&#xA;&lt;p&gt;If you have an exact solution, the value of that solution is also the best known bound, and so the difference between a &amp;quot;random solution&amp;quot; (incumbent) and the exact solution (best bound) is again covered by the above.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-11-13T21:34:54.960" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5220" PostTypeId="1" AcceptedAnswerId="5227" CreationDate="2020-11-14T14:47:21.483" Score="4" ViewCount="224" Body="&lt;p&gt;I have the following problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{X_{i,j},i\in N_{U},j\in N_{B}}\sum_{i=1}^{N_U}\sum_{j=1}^{N_B}R_{i,j}X_{i,j}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{subject to}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{\min}\le\sum_{j=1}^{N_B}X_{i,j}\le a_{\max}, \forall i$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{N_U}X_{i,j}\le b_{\max}, \forall j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is a convex problem,b ut I need a heuristic approach to solve this.&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; is a knowm matrix. &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a binary matrix. &lt;span class=&quot;math-container&quot;&gt;$a_{\min}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a_{\max}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_{\max}$&lt;/span&gt; are also know. and positive&lt;/p&gt;&#xA;&lt;p&gt;Any suggestions&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="500" LastEditDate="2020-11-18T22:43:33.200" LastActivityDate="2020-11-18T22:43:33.200" Title="How to solve this convex problem heuristically?" Tags="|integer-programming|convex-optimization|heuristics|network-flow|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5221" PostTypeId="2" ParentId="5220" CreationDate="2020-11-14T15:11:47.517" Score="9" Body="&lt;p&gt;This is a &lt;em&gt;minimum cost flow problem&lt;/em&gt; in the bipartite graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,A)$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$V=N_U \cup N_B$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Add a source node and link it to each vertex &lt;span class=&quot;math-container&quot;&gt;$v\in N_U$&lt;/span&gt;. On each of these arcs, constrain the flow to be in the range &lt;span class=&quot;math-container&quot;&gt;$[a_{min},a_{max}]$&lt;/span&gt;. Note that if &lt;span class=&quot;math-container&quot;&gt;$a_{min} &amp;gt; |N_B|$&lt;/span&gt; the problem is infeasible.&lt;/p&gt;&#xA;&lt;p&gt;Likewise with a sink node, that you link to each vertex &lt;span class=&quot;math-container&quot;&gt;$v \in N_B$&lt;/span&gt;, and constrain the flow such that it does not exceed &lt;span class=&quot;math-container&quot;&gt;$b_{max}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then,  on edges &lt;span class=&quot;math-container&quot;&gt;$(i,j) \in A$&lt;/span&gt;, add a cost &lt;span class=&quot;math-container&quot;&gt;$-R_{ij}$&lt;/span&gt;, a capacity &lt;span class=&quot;math-container&quot;&gt;$Q_{ij}=1$&lt;/span&gt;, and find a minimum cost flow in this graph.&lt;/p&gt;&#xA;&lt;p&gt;Not only is this problem convex : it can be solved in polynomial time with the above approach. Are you sure you want a heuristic when you have a free optimal solution ? I guess if you really want a heuristic for such problems you can checkout for example &lt;a href=&quot;https://arxiv.org/abs/1207.6381&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-11-14T15:30:01.503" LastActivityDate="2020-11-14T15:30:01.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5222" PostTypeId="2" ParentId="5210" CreationDate="2020-11-14T16:30:32.463" Score="6" Body="&lt;p&gt;Before implementing anything, you need to understand the equations. A good approach is to think in terms of resources. When handling capacity constraints, you are dealing with a &lt;em&gt;load&lt;/em&gt; resource which is limited to the vehicle's capacity. When dealing with constraints linked to time, you need an extra resource for this. Each of these resources can be delt with in a similar fashion. In essence, you use equations that keep track of how these resources are incremented when using an arc.&lt;/p&gt;&#xA;&lt;p&gt;You need to write an equivalent equation as the one which keeps track of the total load :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{ij} = 1 \quad\Rightarrow \quad  u_j =u_i +q_j \quad \forall (i,j)\in A&#xA;$$&lt;/span&gt;&#xA;This means that if you use arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, then the total load that has been delivered up to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$u_j$&lt;/span&gt;, is the total load up to node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt;, plus the amount that is delivered at node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$q_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So if &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt; is a variable that denotes the time at which you reach node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and if &lt;span class=&quot;math-container&quot;&gt;$\Delta_{ij}$&lt;/span&gt; denotes the time it takes to go from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, you can write the following equation:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{ij} = 1 \quad \Rightarrow \quad  t_j = t_i + \Delta_{ij} \quad \forall (i,j)\in A&#xA;$$&lt;/span&gt;&#xA;Once you have this, writing the time window constraint should be straightforward.&lt;/p&gt;&#xA;&lt;p&gt;Note however that this formulation assumes that the lower bounds on the time windows &lt;span class=&quot;math-container&quot;&gt;$[a_i,b_i]$&lt;/span&gt; are hard. Typically, this is not the case, as waiting is usually allowed upon arrival. In this case, the above constraint has to be tweaked as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{ij} = 1 \quad \Rightarrow \quad  t_j = \max\{a_j,t_i + \Delta_{ij}\} \quad \forall (i,j)\in A&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, there may be a service time at each node. If you understand the above equations, you should be able to take this service time into account.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-11-15T20:38:01.537" LastActivityDate="2020-11-15T20:38:01.537" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5223" PostTypeId="2" ParentId="5216" CreationDate="2020-11-14T21:43:39.137" Score="3" Body="&lt;p&gt;The first step is to ascertain &amp;quot;reasonable&amp;quot; configurations of the facility being modeled. Configuration includes physical characteristics (types of machines, number of machines of each type, typical availability v. down time, etc.) as well as information about the demand patterns (types of jobs, arrival rates of jobs, typical due dates, etc.). For random quantities, such as job arrivals or machine failures, you would look for an appropriate distribution (e.g., exponential interarrival times for jobs) and &amp;quot;average&amp;quot; or &amp;quot;typical&amp;quot; parameters (mean arrival rate, mean time between arrivals, ...). If you were modeling an existing (real-world) facility, you would just use the configuration data from that facility and best estimates of the demand data.&lt;/p&gt;&#xA;&lt;p&gt;Since you are not modeling an actual facility, you could try looking for literature in which similar facilities are modeled, finding ones that are comparable, and parameterizing yours similarly to what has been published. Note that the published problems do not need to be identical. So, for instance, if your problem includes machine breakdowns and repairs and you find a published instance A with most of your features but not breakdowns, and another instance B that is somewhat similar to your problem and includes breakdowns but not some other thing you have, you could try mixing the breakdown rates from B with the other characteristics of A.&lt;/p&gt;&#xA;&lt;p&gt;An alternative approach is to build a discrete simulation model for a facility of the type you are modeling. You would pick &amp;quot;dimensions&amp;quot; (number of machine types, number of machines etc.) that you think are reasonable, assign plausible distributions to random quantities (time between job arrivals, time between machine breakdowns, ...), then tune parameters such as mean interarrival time or mean time between breakdowns by running the simulation with different parameter combinations until you get a few combinations that result in reasonable system behavior (the facility is not starved for work, the queue does not explode, ...). That will give you some specific facility profiles you can use for testing your scheduling model/algorithm.&lt;/p&gt;&#xA;&lt;p&gt;If your goal is to publish results, you need to be careful that your test problems look &amp;quot;reasonable&amp;quot; to a reviewer and do not look as if they were cherry-picked to produce good results with your model/algorithm. That's why basing your problems on a real-world facility is most desirable, and basing them on published instances for comparable models is second most desirable.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-11-14T21:43:39.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5224" PostTypeId="1" AcceptedAnswerId="5225" CreationDate="2020-11-16T03:25:18.247" Score="0" ViewCount="279" Body="&lt;p&gt;IF &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_d X_{i,d}\ge6$&lt;/span&gt; THEN &lt;span class=&quot;math-container&quot;&gt;$Y_i = 1$&lt;/span&gt; (strictly)&lt;/p&gt;&#xA;&lt;p&gt;AND&lt;/p&gt;&#xA;&lt;p&gt;IF &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_d X_{i,d}&amp;lt;6$&lt;/span&gt; THEN &lt;span class=&quot;math-container&quot;&gt;$Y_i = 0$&lt;/span&gt; (strictly)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; are binary variables.&lt;/p&gt;&#xA;&lt;p&gt;What I'm actually trying to do is to charge the objective function some value whenever &lt;span class=&quot;math-container&quot;&gt;$Y_i = 1$&lt;/span&gt;. That is, for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, if &lt;span class=&quot;math-container&quot;&gt;$Y_i=1$&lt;/span&gt;, the term &lt;span class=&quot;math-container&quot;&gt;$C\cdot Y_i$&lt;/span&gt; is charged in the objective function only and only if &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_d X_{i,d}\ge6$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here are some more details about the problem if needed.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$I =$&lt;/span&gt; set of workers (a total of 5 workers);&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D =$&lt;/span&gt; set of days (a total of 6 days);&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C=$&lt;/span&gt; cost for each worked day is fixed.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;If a worker worked for 6 days, then the cost of the sixth day is double the normal cost i.e. &lt;span class=&quot;math-container&quot;&gt;$= 2C$&lt;/span&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Define &lt;span class=&quot;math-container&quot;&gt;$X_{i,d} = 1$&lt;/span&gt; if worker &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; works on day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; and 0 otherwise, so I want to charge the objective function a cost if the sum of &lt;span class=&quot;math-container&quot;&gt;$X_{i,d}$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; equals &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How can introduce such a variable that would charge the objective function?&lt;/p&gt;&#xA;" OwnerUserId="4430" LastEditorUserId="500" LastEditDate="2020-11-17T15:47:54.183" LastActivityDate="2020-11-17T23:28:20.483" Title="How can I formulate this specific if-then constraint?" Tags="|optimization|mixed-integer-programming|linear-programming|integer-programming|constraint-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5225" PostTypeId="2" ParentId="5224" CreationDate="2020-11-16T04:23:58.403" Score="5" Body="&lt;p&gt;For simplicity, I will drop the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; subscripts everywhere and instead write &lt;span class=&quot;math-container&quot;&gt;$x_d$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$x_{i,d}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The linear constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{d=1}^6 x_d \le 5 + y$$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$$\sum_{d=1}^6 x_d &amp;gt; 5 \implies y=1.$$&lt;/span&gt;&#xA;You can derive this constraint via conjunctive normal form as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left(\land_{d=1}^6 x_d\right) \implies y \\&#xA;\lnot\left(\land_{d=1}^6 x_d\right) \lor y \\&#xA;\left(\lor_{d=1}^6 \lnot x_d\right) \lor y \\&#xA;\sum_{d=1}^6 (1-x_d) + y \ge 1 \\&#xA;\sum_{d=1}^6 x_d - y \le 5 \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The objective will drive &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt; otherwise, but if you want to explicitly enforce it, you can again use conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\neg\left(\land_{d=1}^6 x_d\right) \implies \lnot y \\&#xA;\left(\land_{d=1}^6 x_d\right) \lor \lnot y \\&#xA;\land_{d=1}^6 (x_d \lor \lnot y) \\&#xA;x_d + (1 - y) \ge 1 \quad \text{for $d\in\{1,\dots,6\}$} \\&#xA;x_d \ge y \quad \text{for $d\in\{1,\dots,6\}$}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-11-17T02:02:20.180" LastActivityDate="2020-11-17T02:02:20.180" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5226" PostTypeId="1" AcceptedAnswerId="5230" CreationDate="2020-11-16T13:29:41.747" Score="1" ViewCount="147" Body="&lt;p&gt;I would like to seek some advice on modeling the following (chain of) logical implication:&lt;/p&gt;&#xA;&lt;p&gt;For instance &lt;span class=&quot;math-container&quot;&gt;$\omega_{xy}$&lt;/span&gt; might indicate precedence, i.e., &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; being the nodes &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, respectively. Thus if &lt;span class=&quot;math-container&quot;&gt;$\omega_{xy}$$=1$&lt;/span&gt;, it implies that the departure time of the vehicle from node &lt;span class=&quot;math-container&quot;&gt;$x $&lt;/span&gt; is to be less than or equal to the arrival time at node &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Say for instance, there is an additional node &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, which also to be visited as is always behind temporally, and for other nodes that are also temporally behind &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, such as &lt;span class=&quot;math-container&quot;&gt;$z_1...z_n$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Hence, I would like to force the logical implication such that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\omega_{xy}$$=1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{xz}$$=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\omega_{xy}$$=1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{xz_1}$$=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\omega_{xy}$$=1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{xz_n}$$=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Appreciate your kind guidance.&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="3682" LastEditDate="2020-11-17T02:28:46.877" LastActivityDate="2020-11-17T03:04:27.293" Title="How to model this chain of logical implication" Tags="|mixed-integer-programming|modeling|binary-variable|logical-constraints|indicator-constraints|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5227" PostTypeId="2" ParentId="5220" CreationDate="2020-11-16T16:46:05.543" Score="2" Body="&lt;p&gt;Now that you have removed the range constraints, the problem decomposes by &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and can be solved optimally for each &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; by a greedy algorithm: set &lt;span class=&quot;math-container&quot;&gt;$X_{i,j}=1$&lt;/span&gt; for the &lt;span class=&quot;math-container&quot;&gt;$b_\max$&lt;/span&gt; largest (positive) values of &lt;span class=&quot;math-container&quot;&gt;$R_{i,j}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-11-16T16:46:05.543" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5228" PostTypeId="1" AcceptedAnswerId="5234" CreationDate="2020-11-16T17:07:28.307" Score="3" ViewCount="1035" Body="&lt;p&gt;I am working on a problem of form&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \begin{array}{l @{\quad} l}&#xA;    \mathrm{max}_{x, u} &amp;amp;  p^{\top} u&#xA;    \\&#xA;    \text{st.} &amp;amp; A u  + a x \leq 0&#xA;    \\&#xA;    &amp;amp; x \in \{0, 1\}^n&#xA;    \\&#xA;    &amp;amp; u \in \mathbb{R}^k&#xA;    \end{array}&#xA;\end{equation}&lt;/span&gt;&#xA;Sometimes, this problem is unbounded from the above. I would like to obtain the extreme ray of  both &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; in a C++ environment. I have tried different suggestions from the internet, however, it always fails. &lt;strong&gt;So I am wondering what exactly a sample code looks like to achieve my purpose?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The code that I have arrived currently is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// set up Gurobi model&#xA;GRBModel model = GRBModel (*prob-&amp;gt;env);&#xA;model.set (GRB_IntParam_Threads, 4);&#xA;&#xA;GRBVar *x = model.addVars (n, GRB_BINARY);&#xA;GRBVar *u = model.addVars (size_of_u, GRB_CONTINUOUS);&#xA;&#xA;GRBVar tau = model.addVar (-GRB_INFINITY , GRB_INFINITY, 1.0, GRB_CONTINUOUS); &#xA;&#xA;// set up objective function&#xA;model.set (GRB_IntAttr_ModelSense, GRB_MAXIMIZE);&#xA;&#xA;GRBLinExpr expr;&#xA;&#xA;// epigraphical constraints: tau &amp;lt;= p'u&#xA;for (int k = 0; k &amp;lt; size_of_u; ++k)&#xA;    expr += p[k] * u[k];&#xA;model.addConstr (tau &amp;lt;= expr);&#xA;&#xA;// Constraints A' u - a' x &amp;lt;= 0&#xA;for (int k = 0; k &amp;lt; constraint_vectors.size(); ++k){&#xA;    for(auto &amp;amp; a : constraint_vectors[k]){&#xA;        expr = 0;&#xA;        for (int l = 0; l &amp;lt;size_of_u; ++l)&#xA;            expr += A_T[k][l]*u[l];&#xA;        for (int i = 1; i &amp;lt; n; ++i) //&#xA;            expr -= a[i]*x[i] + a[n + i]*(1-x[i]); &#xA;        model.addConstr (expr -  a[-1] &amp;lt;= 0 );&#xA;    }&#xA;}&#xA;&#xA;model.set(GRB_IntParam_InfUnbdInfo, 1);&#xA;model.optimize();&#xA;for (int i=0; i&amp;lt;iterations;i++){&#xA;    cout &amp;lt;&amp;lt; &amp;quot;This is the solution status in the master problem &amp;quot;&#xA;     &amp;lt;&amp;lt; model.get(GRB_IntAttr_Status) &amp;lt;&amp;lt; endl;&#xA;    if (model.get(GRB_IntAttr_Status) == 5){&#xA;        for (int l = 0; l&amp;lt; size_of_u; ++l) {&#xA;            current_u[l] = u[l].get(GRB_DoubleAttr_UnbdRay);&#xA;            cout &amp;lt;&amp;lt; &amp;quot;current_u[&amp;quot; &amp;lt;&amp;lt; l &amp;lt;&amp;lt; &amp;quot;] = &amp;quot; &amp;lt;&amp;lt; current_u[l] &amp;lt;&amp;lt; endl;&#xA;            }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When run this code, there is an error message saying:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;libc++abi.dylib: terminating with uncaught exception of type GRBException &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;pointing to the first line inside the second for loop. &lt;strong&gt;I am also wondering why this error occurs?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="491" LastEditDate="2020-11-17T01:20:00.377" LastActivityDate="2020-11-18T00:04:29.530" Title="How to get an extreme ray of an LP from Gurobi" Tags="|integer-programming|gurobi|binary-variable|c++|extreme-rays|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5229" PostTypeId="1" AcceptedAnswerId="5232" CreationDate="2020-11-16T22:13:55.160" Score="5" ViewCount="185" Body="&lt;p&gt;I am solving an optimization problem using Pulp and NetworkX. The problem is similar to the Minimum Vertex Set (MVS) problem. I have noticed that the optimizer is Scanning the edges according to their order in the entry of set edges and deciding about the minimum set according to that. In other words, the results are changing according to the order of the edges, for example, if I define the set of edges as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   edges = [(5,4),(5,3),(3,1),(3,2),(2,1),(4,1),(5,1),(4,2),(5,2),(4,3)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The order of nodes in this case is &lt;code&gt;[5,4,3,1,2]&lt;/code&gt;&#xA;and the minimum set is &lt;code&gt;{5,4}&lt;/code&gt;&#xA;while enring the set of edges as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   edges = [(2,1),(2,3),(3,1),(4,1),(5,1),(4,2),(5,2),(4,3),(5,3),(5,4)] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The order of the nodes is &lt;code&gt;[2,1,3,4,5]&lt;/code&gt; and the minimum set is &lt;code&gt;{2,1}&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to scan all the posibilites instead of going with the nodes one by one and ignoring the other nodes if the solution is satisfied.Here is the code I am using:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pulp &#xA;import networkx as nx&#xA;import numpy as np&#xA;&#xA;&#xA;g = nx.Graph() &#xA;&#xA;&#xA;edges = [(1,2),(3,1),(4,1),(5,1),(4,2),(5,2),(3,2)]&#xA;&#xA;#edges = [(3,1),(4,1),(5,1),(4,2),(5,2),(1,2),(3,2)]&#xA;&#xA; &#xA;  g.add_edges_from(edges)&#xA;&#xA;#The problem&#xA;prob = pulp.LpProblem(&amp;quot;MinimumSetVertexCover&amp;quot;, pulp.LpMinimize)&#xA;&#xA;# The variables&#xA;y = pulp.LpVariable.dicts(&amp;quot;y&amp;quot;, g.nodes(), cat=pulp.LpBinary)&#xA;x = pulp.LpVariable.dicts(&amp;quot;x&amp;quot;, g.edges(), cat=pulp.LpBinary)&#xA;&#xA;#The objective function&#xA; for (u,v) in g.edges():&#xA;     prob += pulp.lpSum(y) - pulp.lpSum(x)&#xA;#The constraints&#xA; for (u,v) in g.edges():&#xA;     prob += x[(u,v)] &amp;lt;= y[u]&#xA;     prob += x[(u,v)] &amp;lt;= 1-y[v]&#xA;&#xA; for v in g.nodes():&#xA;     prob +=  pulp.lpSum([x[(u,v)] for u in g.neighbors(v) if (u,v) in x])+pulp.lpSum([x[(v,u)] for u in g.neighbors(v) if (v,u) in x]) &amp;gt;= 2*(1-y[v])   &#xA;&#xA;prob.solve()&#xA;&#xA;for v in g.nodes():&#xA;    if pulp.value(y[v]) ==1:&#xA;       print(&amp;quot;node %s selected&amp;quot;%v)&#xA;for (u,v) in g.edges():&#xA;    if pulp.value(x[(u,v)]) ==1:&#xA;       print(&amp;quot;edge %s was included&amp;quot;%{(u,v)})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Thank you for helping me figuring this out&lt;/p&gt;&#xA;" OwnerUserId="4347" LastEditorUserId="4347" LastEditDate="2020-11-17T15:54:53.920" LastActivityDate="2020-11-17T16:42:51.257" Title="Is the order of edges in graph is changing the optimization result?" Tags="|optimization|python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5230" PostTypeId="2" ParentId="5226" CreationDate="2020-11-17T03:04:27.293" Score="3" Body="&lt;p&gt;To enforce &lt;span class=&quot;math-container&quot;&gt;$x = 1 \implies y = 1$&lt;/span&gt; for binary variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, impose linear constraint &lt;span class=&quot;math-container&quot;&gt;$x \le y$&lt;/span&gt;.  You can derive this constraint via conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x \implies y \\&#xA;\lnot x \lor y \\&#xA;(1 - x) + y \ge 1 \\&#xA;x \le y&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-11-17T03:04:27.293" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5231" PostTypeId="2" ParentId="4170" CreationDate="2020-11-17T04:59:45.503" Score="7" Body="&lt;p&gt;I am geophysics professor and have been solving scientific computing problems in Matlab since 2000. In the last ~8 years graduate students have been preferring to work in Python. I have the following observations:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;On a practical level Python is MUCH slower than Matlab.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Code that my graduate students write is literally orders of magnitude slower than my Matlab for solution for matrices that arise from discretizing PDE's.&lt;/p&gt;&#xA;&lt;p&gt;How can this be, aren't both using the same libraries under the hood?&#xA;Yes, but clearly Matlab is much better at recognizing special forms of matrices and choosing optimized solvers for them. Once my graduate students have have put several weeks into optimizing their code, it is still much slower (seconds vs. tens of minutes). You may think my graduate students suck - but some of them are in a leading computational math graduate program.&lt;/p&gt;&#xA;&lt;p&gt;One reason I am more likely to switch to Julia than Python is that many of the advertised advantages of Python, such as great string manipulation simply don't matter for scientific programming. Also the syntax is clumsy and verbose. Most people that know what they are doing are picking up Julia. For example the new Climate model (&lt;a href=&quot;https://clima.caltech.edu/&quot; rel=&quot;noreferrer&quot;&gt;https://clima.caltech.edu/&lt;/a&gt;) is being developed in Julia, not Python. The same is true for various Astrophysical codes (&lt;a href=&quot;https://juliacomputing.com/case-studies/celeste/&quot; rel=&quot;noreferrer&quot;&gt;https://juliacomputing.com/case-studies/celeste/&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="4436" LastActivityDate="2020-11-17T04:59:45.503" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5232" PostTypeId="2" ParentId="5229" CreationDate="2020-11-17T14:11:14.597" Score="4" Body="&lt;p&gt;&lt;strong&gt;EDIT 1&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I was able to replicate the issue and it turns out:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There is a problem in the objective function. You can only have &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, while you have a loop. Replace your objective function by &lt;code&gt;prob += lpSum(y)-lpSum(x)&lt;/code&gt;. Maybe the confusion came from the fact that with &lt;code&gt;lpSum&lt;/code&gt;, if your coefficients are &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, you don't have to write the variables as a dictionnary with the indexes. But even after fixing this, the issue is still there.&lt;/li&gt;&#xA;&lt;li&gt;If you take a look at the .lp files (&lt;code&gt;print(prob)&lt;/code&gt;), you will see that both models are not the same. For example in one case, you have a variable &lt;code&gt;x[(1,3)]&lt;/code&gt;, and in the other case you have &lt;code&gt;x[(3,1)]&lt;/code&gt;. And so this messes up the constraints &lt;span class=&quot;math-container&quot;&gt;$x_{uv}\le y_u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{uv}\le 1-y_v$&lt;/span&gt;. This is because &lt;code&gt;networkx&lt;/code&gt; created the edges differently in the first place.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;So this issue is &lt;strong&gt;not related to optimization&lt;/strong&gt;, or to a solver, it is due to the way the edges are defined. It seems you are working with an undirected graph, but have constraints where order matters. I am not sure there is enough information in the question to validate that. You may need to rethink your model.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;INITIAL ANSWER&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If I understood correctly, you want all possible optimal solutions.&lt;/p&gt;&#xA;&lt;p&gt;You can achieve this by iteratively solving the problem, adding a constraint at each iteration so that the next solution is different. If &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; denotes the set of binaries that take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in the solution, you can add the following constraint :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i\in B}x_i \le |B| -1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This way, among all binaries that took value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, you impose that at least one has to take value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; this time.&lt;/p&gt;&#xA;&lt;p&gt;Here is a possible python code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;while True:&#xA;    prob.solve()&#xA;    if LpStatus[prob.status] == &amp;quot;Optimal&amp;quot;:&#xA;    &#xA;        # display solution&#xA;        S = 0&#xA;        for v in g.nodes():&#xA;           if pulp.value(y[v]) ==1:&#xA;               print(&amp;quot;node %s selected&amp;quot;%v)&#xA;               S += 1&#xA;        for (u,v) in g.edges():&#xA;            if pulp.value(x[(u,v)]) ==1:&#xA;               print(&amp;quot;edge %s was included&amp;quot;%{(u,v)})&#xA;&#xA;&#xA;        # Add the following constraint to preclude the solver from finding the same set of nodes in next iteration&#xA;        prob += lpSum([y[v] for v in y if value(y[v])&amp;gt;0.9]) &amp;lt;= S -1&#xA;&#xA;    # If a new optimal solution cannot be found, we end the program    &#xA;    else:&#xA;        break&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-11-17T16:42:51.257" LastActivityDate="2020-11-17T16:42:51.257" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5233" PostTypeId="1" CreationDate="2020-11-17T15:07:32.930" Score="6" ViewCount="824" Body="&lt;p&gt;I am working on a vehicle routing problem with &lt;a href=&quot;https://developers.google.com/optimization/routing&quot; rel=&quot;noreferrer&quot;&gt;or-tools&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to partially fulfill a demand? I know it is possible to &lt;a href=&quot;https://developers.google.com/optimization/routing/penalties&quot; rel=&quot;noreferrer&quot;&gt;drop nodes&lt;/a&gt; with the disjunction constraints. But in this case, a node is either visited, or not. I would like to allow a node to be visited, with the possibility to deliver only a fraction of its demand, if it is profitable. For example, for a given customer with demand &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;, there might not be enough resources (vehicles/capacity) to complete its delivery, but there may be enough to deliver &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; unit, and in this case the customer would be more happy than without any visit at all.&lt;/p&gt;&#xA;&lt;p&gt;Another way of saying this is that I would like to maximize the quantity that is delivered, while minimizing transportation costs.&lt;/p&gt;&#xA;&lt;p&gt;One option would be to duplicate nodes, each node having a given fraction of the demand. But this will quickly lead to very big networks and I don't think it is a good idea. Also, determining the values of the fractions may not be simple. The ideal fraction would be &amp;quot;whatever spare space there is in the truck,&amp;quot; but this is not straighforward to compute before hand.&lt;/p&gt;&#xA;&lt;p&gt;Is this possible with or-tools ?&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2020-11-20T15:32:09.710" Title="OR-TOOLS : is it possible to partially fulfill a demand?" Tags="|modeling|vehicle-routing|or-tools|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5234" PostTypeId="2" ParentId="5228" CreationDate="2020-11-17T15:25:21.470" Score="3" Body="&lt;p&gt;In order to query the &lt;code&gt;GRB_DoubleAttr_UnbdRay&lt;/code&gt; attribute, you need to optimize the problem with the &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/infunbdinfo.html#parameter:InfUnbdInfo&quot; rel=&quot;nofollow noreferrer&quot;&gt;InfUnbdInfo&lt;/a&gt; parameter set to 1.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2020-11-17T15:25:21.470" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5235" PostTypeId="2" ParentId="5224" CreationDate="2020-11-17T15:29:11.373" Score="2" Body="&lt;p&gt;I thought about the following:&lt;/p&gt;&#xA;&lt;p&gt;then all you need is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Y \ge (\sum X_d) - 5 \ \ \&amp;amp; \ \ Y \le (\sum X_d)/5.&#xA;$$&lt;/span&gt;&#xA;This can be written in a solver:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall$&lt;/span&gt; worker &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, you can just add &lt;span class=&quot;math-container&quot;&gt;$Cy_i$&lt;/span&gt; to the cost function and add the constraint &lt;span class=&quot;math-container&quot;&gt;$$ \sum_{d=1}^6 x_{id} \leq 5 + y_i$$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(Note that &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; can be declared as either continuous or binary.)&lt;/p&gt;&#xA;" OwnerUserId="4438" LastEditorUserId="39" LastEditDate="2020-11-17T23:28:20.483" LastActivityDate="2020-11-17T23:28:20.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5236" PostTypeId="2" ParentId="5233" CreationDate="2020-11-17T17:20:38.800" Score="5" Body="&lt;p&gt;You can split the demand in two visits.&#xA;You will need to duplicate the node in two, and add a disjunction on each visit.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2020-11-17T17:20:38.800" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5237" PostTypeId="2" ParentId="5228" CreationDate="2020-11-18T00:04:29.530" Score="2" Body="&lt;p&gt;I don't know whether this is the reason, but the documentation says that InfUnbdInfo is for LP only. So we might have to work with the LP. Two thoughts:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;x = 0, u = 0 is a feasible solution for the MIP.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As x is bounded, x will not be part of the ray.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Thus, any ray for the LP should also be a ray for the MIP.&lt;/p&gt;&#xA;&lt;p&gt;So if Gurobi decides your problem is unbounded, you might just switch to the LP and solve it through primal simplex to obtain your ray.&lt;/p&gt;&#xA;" OwnerUserId="3501" LastActivityDate="2020-11-18T00:04:29.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5238" PostTypeId="1" CreationDate="2020-11-18T06:16:26.147" Score="2" ViewCount="84" Body="&lt;p&gt;I am looking for an analogy to the problem I am facing or better yet a paper or even code.&lt;/p&gt;&#xA;&lt;p&gt;I have:&lt;/p&gt;&#xA;&lt;p&gt;Nodes from set A and B.&lt;/p&gt;&#xA;&lt;p&gt;Edges are from a single A to many B.&lt;/p&gt;&#xA;&lt;p&gt;I am framing a max bipartite matching problem where the edge weights change at thresholds. If I have 9 edges between a single node in A and 9 nodes of B, and then a new edge is incorporated into that node A, all of its edge weights should be discounted by a factor.&lt;/p&gt;&#xA;&lt;p&gt;I am having some trouble with finding relevant literature about this problem.&lt;/p&gt;&#xA;&lt;p&gt;My objective function is a shopper wanting to purchase as many things that they can to make them &lt;code&gt;happy&lt;/code&gt; while minimizing the &lt;code&gt;cost&lt;/code&gt; of the order. Happiness can be a function of the full set of items. Some customers might be happier with a diverse set of products, some just want one thing.&lt;/p&gt;&#xA;&lt;p&gt;They make a purchase where prices change depending on the composition of the items ordered. In my case there is a &lt;code&gt;discount&lt;/code&gt; given for buying more than a number of items in a certain &lt;code&gt;category&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A shopper has a utility for any given item and the store is offering discounts for certain families of items. e.g. buy 5 chocolate bars and get a dollar off.&lt;/p&gt;&#xA;&lt;p&gt;So I  can buy 4 Hershey's bars and it's $5.&lt;/p&gt;&#xA;&lt;p&gt;But if I buy 4 Hershey's bars and a snickers (extra 80 cents),&#xA;I can get the whole set of candy bars for $1 off and be better off in terms of me being more happy and paying less.&lt;/p&gt;&#xA;&lt;h2&gt;Limits:&lt;/h2&gt;&#xA;&lt;p&gt;There are &amp;lt;100 A nodes. (Shopper)&lt;/p&gt;&#xA;&lt;p&gt;There are &amp;lt; 10,000 B nodes (Items)&lt;/p&gt;&#xA;&lt;p&gt;There should be a max of 3 discount factors for 3 categories of items (total of 9). e.g.&#xA;-&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;More than 5 candy bars --&amp;gt; Get 1 free&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;More than 50 candy bars --&amp;gt; Get 5 free&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;More than 100 candy bars --&amp;gt; Get some other item for free&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;More than 2 cases of soda --&amp;gt; get one free&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;More than 10 cases of soda --&amp;gt; get 4 free&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;More than 20 cases of soda --&amp;gt; get 6 free&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Any node will have a maximum degree of ~1000.&lt;/p&gt;&#xA;" OwnerUserId="4442" LastEditorUserId="4442" LastEditDate="2020-11-18T23:58:10.840" LastActivityDate="2020-11-19T14:21:15.353" Title="Maximum bipartite matching with breakpoints in edge weight function" Tags="|linear-programming|modeling|python|combinatorial-optimization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5239" PostTypeId="1" AcceptedAnswerId="5240" CreationDate="2020-11-18T11:15:02.477" Score="1" ViewCount="122" Body="&lt;p&gt;I would like to seek some advice on modeling the following (chain of) logical implication:&lt;/p&gt;&#xA;&lt;p&gt;For instance &lt;span class=&quot;math-container&quot;&gt;$\omega_{xz}$&lt;/span&gt; might indicate precedence, i.e., &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; being the nodes &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, respectively. Thus if &lt;span class=&quot;math-container&quot;&gt;$\omega_{xz}$$=1$&lt;/span&gt;, it implies that the departure time of a vehicle from node &lt;span class=&quot;math-container&quot;&gt;$x $&lt;/span&gt; is to be less than or equal to the arrival time at node &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Say for instance, there is an additional node &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;, which must visited after &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; temporally, and for other nodes that are also temporally behind &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;, such as &lt;span class=&quot;math-container&quot;&gt;$y_1...y_n$&lt;/span&gt;, i.e &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the first node to be visited followed by &lt;span class=&quot;math-container&quot;&gt;$y_1...y_n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is before &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; must definitely be visited before &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;, followed by &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; and so on&lt;/p&gt;&#xA;&lt;p&gt;Hence, I would like to force the logical implication such that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\omega_{zx}$$\ge$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{zy_1}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{zx}$$\ge$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{zy_2}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\omega_{zx}$$\ge$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{zy_1}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{zx}$$\ge$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{zy_3}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\omega_{zx}$$\ge$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{zy_1}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{zx}$$\ge$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{zy_n}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;on the other hand the converse might also be true such If &lt;span class=&quot;math-container&quot;&gt;$y_n$&lt;/span&gt; is before &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; be visited before &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. As the chain of nodes could either be on the extreme left or extreme right of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\omega_{y_nz}$$\le$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{y_{n-1}z}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{y_nz}$$\le$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{y_{n-2}z}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\omega_{y_nz}$$\le$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{y_{n-1}z}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{y_nz}$$\le$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{y_{n-3}z}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\omega_{y_nz}$$\le$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{y_{n-1}z}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{y_nz}$$\le$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_{xz}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="491" LastEditDate="2022-07-21T18:18:49.130" LastActivityDate="2022-07-21T18:18:49.130" Title="How to model this chain of logical implication II" Tags="|mixed-integer-programming|modeling|binary-variable|logical-constraints|indicator-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5240" PostTypeId="2" ParentId="5239" CreationDate="2020-11-18T14:07:44.623" Score="5" Body="&lt;p&gt;You can use conjunctive normal form to derive the desired constraints.  The first one is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a \ge b \implies a\ge c\\&#xA;(b \implies a) \implies (c \implies a)\\&#xA;\lnot(\lnot b \lor a) \lor (\lnot c \lor a)\\&#xA;(b \land \lnot a) \lor (\lnot c \lor a)\\&#xA;(b \lor \lnot c \lor a)&#xA;\land (\lnot a \lor \lnot c \lor a)\\&#xA;(b \lor \lnot c \lor a)\\&#xA;b+ 1- c +a \ge 1\\&#xA;a+b \ge c&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The second one is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a \le b \implies a\le c\\&#xA;(a \implies b) \implies (a \implies c)\\&#xA;\lnot(\lnot a \lor b) \lor (\lnot a \lor c)\\&#xA;(a \land \lnot b) \lor (\lnot a \lor c)\\&#xA;(a \lor \lnot a \lor c)&#xA;\land (\lnot b \lor \lnot a \lor c)\\&#xA;\lnot b \lor \lnot a \lor c\\&#xA;1-b + 1-a + c \ge 1\\&#xA;a+b \le c+1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-11-18T14:52:29.500" LastActivityDate="2020-11-18T14:52:29.500" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5241" PostTypeId="2" ParentId="3012" CreationDate="2020-11-18T15:16:21.480" Score="3" Body="&lt;p&gt;Even if brainteasers are not sufficient to test the ability of candidates to be good OR engineers and scientists, they can be useful to test some specific hard or soft skills. For example, at LocalSolver, we use brainteasers to check if candidates love computer programming (assuming that loving means practicing) or if candidates are able to react positively faced with &amp;quot;hard&amp;quot; clients (assuming that a good reaction to a tedious question is not just to dismiss the question).&lt;/p&gt;&#xA;&lt;p&gt;Here are examples of the brainteasers we use at LocalSolver:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Give two ordered sequences of numbers, could you describe an algorithm that merges the two sequences in one ordered sequence? Then we can discuss the computational complexity of the algorithm.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Given a graph with vertices and edges that connect these ones, we want to compute the largest subset of vertices such that these ones are all pairwise connected (this is what we call a clique). How do you proceed? Again, this is the opportunity to launch a discussion about computational complexity and algorithm efficiency.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If the candidate has difficulty to go ahead, we help her/him. The goal is to create a conversation to evaluate the skills mentioned above. We always take a step back from the answers given by candidates, taking into account, in particular, their professional experience and their education. This is just a part of the exchanges we have with the candidates. Nevertheless, this part is important for us at LocalSolver since we always find it useful to get an accurate evaluation of the candidates.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-11-18T15:16:21.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5243" PostTypeId="2" ParentId="2927" CreationDate="2020-11-18T17:30:40.027" Score="1" Body="&lt;p&gt;set k=1 in a=be=1+be^5.&#xA;therefore a=k+be^5.&#xA;solve for k=a-be^5.&lt;/p&gt;&#xA;" OwnerUserId="4444" LastActivityDate="2020-11-18T17:30:40.027" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5244" PostTypeId="1" CreationDate="2020-11-18T18:40:53.203" Score="3" ViewCount="110" Body="&lt;p&gt;I'm a software developer who likes to play a video game that has a complex economy. I realized that the type of problem I'm trying to solve mimics real life operations research problems, and I am seeking your assistance in designing an OR-Tools model that would solve a scheduling problem given several constraints. I'm new to OR-Tools and finding some difficulties with describing my problem in the form of constraint programming. I already have python code that can unravel the requirements into phases of production naively based off of the total raw materials required for each component.&lt;/p&gt;&#xA;&lt;p&gt;I've answered the following questions:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What is the known information in this problem?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are five planets with mining and production machines.&lt;/p&gt;&#xA;&lt;p&gt;It takes roughly 3 minutes to travel from planet to planet.&lt;/p&gt;&#xA;&lt;p&gt;Each mining machine can do 2 jobs, each production machine can do 5 jobs.&lt;/p&gt;&#xA;&lt;p&gt;The maximum amount each job can do is 100 units.&lt;/p&gt;&#xA;&lt;p&gt;Mining machines are used to extract raw resources. Production machines are used to make 1. components to producible items 2. producible items themselves. Sometimes producible items also require a combination of raw materials and producible items.&lt;/p&gt;&#xA;&lt;p&gt;It takes about 1 minute to travel between mining and production terminals on the same planet.&lt;/p&gt;&#xA;&lt;p&gt;These five planets have overlapping but different sets of resources on each.&lt;/p&gt;&#xA;&lt;p&gt;For example, Planet A has &amp;quot;chemicals&amp;quot;, &amp;quot;biomass&amp;quot;, &amp;quot;copper&amp;quot; and Planet B has &amp;quot;carbon&amp;quot;, &amp;quot;chemicals&amp;quot;, &amp;quot;biomass&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;There are many, many items. Here is an example: A first aid kit requires 1 bioplasma and 1 textiles. A unit of bioplasma takes 3 biomass. A textile requires 2 biomass (not bioplasma) and 1 refined chemical. 1 refined chemical takes 3 chemicals. We will want to combine different orders that will share raw materials and intermediate items.&lt;/p&gt;&#xA;&lt;p&gt;In order to mine 100 raw materials, it generally takes about 23 minutes. It takes about 14 seconds to mine one raw material. In order to produce items, it varies depending on the number of raw materials that go into each item. This isn't public information but can be reverse engineered. I can determine this formula later as needed.&lt;/p&gt;&#xA;&lt;p&gt;We do know what each producible item requires and all the raw materials and their locations. This has been entered into a large spreadsheet built as an adjacency matrix.&lt;/p&gt;&#xA;&lt;p&gt;Technically, each planet has a player's storage with a capacity that can be expanded for money, transferring items between planets costs money, and traveling between planets also costs money. Profitability isn't really a concern however, because it's a given that fulfilling the order will be profitable. Our real goal is to have a fast turnaround time.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What are the decision variables or unknowns in this problem?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;We don't know how much of each producible item an order will request until the request is made. We don't know what combination of producible items will be requested until the request is made.&#xA;Which jobs should occupy each slot? How much of each item in the job should we do? What order should we do these operations?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What are the constraints on these variables?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Each planet has a set of mining machines and production machines. Each mining machine can only do 2 jobs. Each production machine (including intermediate items) can do 5 jobs at once. It takes 3 minutes to transition between planets. It takes about 1 minute to travel between mining and production terminals on the same planet. You can't collect output of the jobs early. They must complete and can't be interrupted once started.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What is the objective?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective is to produce a schedule of mining/production operations that minimizes our time spent in the game. Essentially, a production plan and schedule.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What am I asking you for?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'd like your sagely advice on how to describe this problem in the form of constraint programming/scheduling/production planning. The output would be a list of operations needed to fulfill an order of products.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Some Examples&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let's say we wanted to fulfill an order of 100 first aid kits.&lt;/p&gt;&#xA;&lt;p&gt;This would require 100 bioplasma and 100 textiles.&lt;/p&gt;&#xA;&lt;p&gt;100 bioplasma would require 300 biomass.&lt;/p&gt;&#xA;&lt;p&gt;100 textiles would require 200 biomass and 100 refined chemicals.&lt;/p&gt;&#xA;&lt;p&gt;100 refined chemicals would require 300 chemicals.&lt;/p&gt;&#xA;&lt;p&gt;In total, 500 biomass and 300 chemicals are required in raw materials.&lt;/p&gt;&#xA;&lt;p&gt;A naive answer might look like:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to Planet A and start 2 jobs of mining biomass, for a total of 200.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then go to Planet B and start 2 jobs of mining 100 chemicals. 23 minutes elapse, and the player would mine 100 more chemicals and 100 more biomass on Planet B.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Go back to Planet A and start another 2 jobs of mining 100 biomass each.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After transferring all the raw materials back to one of the Planets, let's say Planet A, the player could then start 3 jobs of refining ~33 bioplasma (consuming 300 biomass) and then start 2 jobs of refining 50 refined chemicals (consuming 300 chemicals).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After about 34 minutes elapse, they start 5 jobs of refining 20 textiles, taking about 23 minutes.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finally, they start 5 jobs of producing 20 first aid kits each, for a total of 100 first aid kits. As you can see, the jobs can be split up across the &amp;quot;slots&amp;quot; to speed up the process.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4445" LastEditorUserId="123" LastEditDate="2021-02-19T11:17:50.070" LastActivityDate="2021-02-19T11:17:50.070" Title="Production planning for a video game economy" Tags="|modeling|scheduling|or-tools|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5245" PostTypeId="1" CreationDate="2020-11-18T22:00:41.967" Score="2" ViewCount="329" Body="&lt;p&gt;Are you aware of any tutorial that can help me learn on how to reconstruct the objective function and constraints from a MPS file once it's loaded in MATLAB. I can load the mps file given to me and solve using lpsolve. But I would like to run a sensitivity test by modifying the RHS of a certain constraint. Therefore, it would be helpful if I could reconstruct the constraints from the MPS file.&lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="67" LastEditDate="2020-11-18T23:47:09.547" LastActivityDate="2020-11-18T23:47:09.547" Title="Reading MPS file for linear programming and reconstructing the Optimization model" Tags="|optimization|linear-programming|matlab|sensitivity-analysis|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5246" PostTypeId="2" ParentId="3069" CreationDate="2020-11-19T00:42:30.773" Score="5" Body="&lt;p&gt;I know some related sites which provide what you want.&lt;/p&gt;&#xA;&lt;p&gt;The first is &lt;a href=&quot;http://www.csc.kth.se/%7Eviggo/problemlist/compendium.html&quot; rel=&quot;noreferrer&quot;&gt;A compendium of NP optimization problems&lt;/a&gt;, the most related to your question. It has formal definitions of the problems and papers containing algorithms for solving them.&lt;/p&gt;&#xA;&lt;p&gt;The second is mostly related to mathematical programming and constraint programming, &lt;a href=&quot;https://sofdem.github.io/gccat/gccat/index.html&quot; rel=&quot;noreferrer&quot;&gt;Global Constraint Catalog&lt;/a&gt;. It has many constraints and their properties. For example, a constraint family to remove symmetries in TSP.&lt;/p&gt;&#xA;&lt;p&gt;The third site is a well-known &lt;a href=&quot;https://www.graphclasses.org/&quot; rel=&quot;noreferrer&quot;&gt;GraphClasses&lt;/a&gt;. It is only for problems related to graphs, but it is the most comprehensive that I know.&lt;/p&gt;&#xA;" OwnerUserId="1252" LastActivityDate="2020-11-19T00:42:30.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5247" PostTypeId="2" ParentId="5238" CreationDate="2020-11-19T00:42:39.687" Score="2" Body="&lt;p&gt;Since the discount function is arbitrary, it is difficult to reduce it to a maximum matching problem in a bipartite graph. On the other hand, your problem can be viewed as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Set_cover_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;set cover problem&lt;/a&gt;, having enumerated all the subsets of items the shopper can buy. For each feasible subset, you can compute the utility and the discounted price. Then the shopper wants to pick subsets of items in such a way to reach a certain level of overall utility while minimizing the overall price.&lt;/p&gt;&#xA;&lt;p&gt;A client of ours was interested in the same problem as you. He modeled the problem as described above. Then the main difficulty in solving the problem efficiently in practice comes from the huge number of feasible subsets to enumerate and then the size of the resulting set cover problem to solve.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2020-11-19T14:21:15.353" LastActivityDate="2020-11-19T14:21:15.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5248" PostTypeId="1" CreationDate="2020-11-19T01:49:04.057" Score="1" ViewCount="37" Body="&lt;p&gt;I'm working on an optimization problem which is kind of finding the minimum dominating set (MDS) or the minimum vertex set (MVS) in an undirected graph. given the MILP formulation for both problems, &lt;strong&gt;I was wondering is there a way to state a constraint to find the (minimum) of (the minimum set)&lt;/strong&gt;. In other words, given the set &lt;strong&gt;C&lt;/strong&gt; is the solution of MDS with some edges, I am looking for a constraint that relates this set &lt;strong&gt;C&lt;/strong&gt; using a new decision variable/s to find a new set &lt;strong&gt;P&lt;/strong&gt; which is the MDS of the set &lt;strong&gt;C&lt;/strong&gt;. &lt;strong&gt;The problem is like finding the root (or multiple roots) of an undirected graph in two linked stages&lt;/strong&gt;. I can imagine that the problem will go like this, given:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   x_v is the decision variable for the node to be selected in C (first level or child)&#xA;   y_v is the decision variable for the node to be selected in P (second level or parent (root))&#xA;   z(u,v) is the decision variable about the edges of the graph resulting from solving the first level&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;hence, the constraint that relates those variables are:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;     y_v &amp;lt;- x_v # to ensure that the parent node will be selected from the set of child nodes&#xA;     y_v &amp;lt;- z(u,v) # to ensure that the parent node will be selected from the resulting edges&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I can not figure out another constraint that forces the solver to select the set from the resulting set. As an example, consider the set &lt;strong&gt;C&lt;/strong&gt; is &lt;strong&gt;{1,2,5,7}&lt;/strong&gt;, Is there a way to promote node &lt;strong&gt;7&lt;/strong&gt; as a root if I have the edges &lt;strong&gt;[(7,5),(7,2),(7,1)]&lt;/strong&gt;.&#xA;Please be noted that I meant by the root here is the node that at least connected to each child with one link.&lt;/p&gt;&#xA;&lt;p&gt;Any guidance will be very appreciated?&lt;/p&gt;&#xA;" OwnerUserId="4347" LastActivityDate="2020-11-19T01:49:04.057" Title="MILP formualtion for Two-level minimum dominating set (MDS) problem?" Tags="|optimization|python|combinatorial-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5249" PostTypeId="1" CreationDate="2020-11-19T10:01:58.313" Score="3" ViewCount="214" Body="&lt;p&gt;I have a min-cut formulation and a bi-partitioning problem.&#xA;The two problems focus on finding the minimal cut value separating the two partitions?&#xA;So what are really the differences between the problems? what are mainly the considered objectives and constraints?&lt;/p&gt;&#xA;" OwnerUserId="4273" LastActivityDate="2020-11-19T14:57:43.957" Title="What is the difference between min- cut formulation and (bi) partitioning formulation?" Tags="|optimization|modeling|network-flow|clustering|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5251" PostTypeId="2" ParentId="5249" CreationDate="2020-11-19T14:57:43.957" Score="2" Body="&lt;p&gt;Roughly speaking, in &lt;a href=&quot;https://en.wikipedia.org/wiki/Minimum_cut&quot; rel=&quot;nofollow noreferrer&quot;&gt;minimum cut problems&lt;/a&gt;, the goal is generally to find a minimum &lt;a href=&quot;https://en.wikipedia.org/wiki/Cut_%28graph_theory%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;cut&lt;/a&gt; (possibly weighted) between two &lt;em&gt;fixed&lt;/em&gt; sets of vertices, called the sources and the sinks. Given one source and one sink in input, the problem can be solved in polynomial time, a famous theorem in combinatorial optimization.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, in &lt;a href=&quot;https://en.wikipedia.org/wiki/Graph_partition&quot; rel=&quot;nofollow noreferrer&quot;&gt;graph partitioning problems&lt;/a&gt;, the goal is generally to find a partition of the vertices into subsets with a maximum size while minimizing the cut (possibly weighted) between these subsets. For example, the bisection problem consists of finding a partition of the vertices into two subsets of equal size, while the minimum cut between the two subsets is minimum. This problem is known to be NP-hard.&lt;/p&gt;&#xA;&lt;p&gt;But in the end, this is a matter of precise definition of the problem to be solved. Some cut problems are polynomial; some others are NP-hard (for example, the so-called &lt;a href=&quot;https://en.wikipedia.org/wiki/Maximum_cut&quot; rel=&quot;nofollow noreferrer&quot;&gt;maximum cut problem&lt;/a&gt;). The same holds for graph partitioning problems.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2020-11-19T14:57:43.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5252" PostTypeId="1" AcceptedAnswerId="5258" CreationDate="2020-11-19T22:20:24.833" Score="1" ViewCount="296" Body="&lt;p&gt;So I want to define multiple sequences (an array of them).&#xA;I have this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar interval casy[d in 1..Domy][ukol in Ukoly] size Trvani[ukol];&#xA;&#xA;dvar sequence S[d in 1..Domy] in i in casy[d];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I get an error: &lt;code&gt;Cannot use domain type dvar interval[][Ukoly] for dvar sequence&lt;/code&gt;.&#xA;But when I use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar interval casy[ukol in Ukoly] size Trvani[ukol];&#xA;&#xA;dvar sequence S in i in casy;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;everything just runs fine.&#xA;Also, when I use&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar interval casy[d in 1..Domy][ukol in Ukoly] size Trvani[ukol];&#xA;&#xA;dvar sequence S[d in 1..Domy] in i in casy;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;it works, but the sequences are for all the intervals, which I dont want. I want to have different sequences separately for each array of intervals, indexed by &lt;code&gt;d&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I just can't understand why would it use the array of intervals when I declare it normally, but would complain when I pull the same exact interval from an array by its index.&lt;/p&gt;&#xA;&lt;p&gt;Is there something I am missing?&lt;/p&gt;&#xA;" OwnerUserId="4459" LastEditorUserId="38" LastEditDate="2020-11-20T12:49:05.157" LastActivityDate="2020-11-21T10:04:10.880" Title="Get array of sequences for array of interval arrays in OPL" Tags="|cplex|opl|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5253" PostTypeId="1" CreationDate="2020-11-20T14:09:19.867" Score="3" ViewCount="141" Body="&lt;p&gt;In R, I regularly ompr::MILPModel for optimization.  I  adapt the below snippet to enable multiplication of a decision variable with two dimensions (e.g., &lt;code&gt;x[i,j]&lt;/code&gt; ) by a numeric matrix of the same dimensions, in constraints and the objective function. I chanced upon this code elsewhere, so I am not going to claim I much know what is going on &lt;code&gt;matrix_multiplication_fcn&lt;/code&gt;, just that it works.&lt;/p&gt;&#xA;&lt;p&gt;I would like to be able to use MILPModel with decision variables of 3+ dimensions, e.g., &lt;code&gt;x[i,j,k]&lt;/code&gt; or &lt;code&gt;x[i,j,k,m]&lt;/code&gt; , and be able to multiply these decision variables against numeric arrays of the same dimension.  I am having a really hard time figuring out how to make an &lt;code&gt;array_multiplication_fcn&lt;/code&gt; of 3+ dimensions that has the same effect.&lt;/p&gt;&#xA;&lt;p&gt;I've made a couple attempts but when I look at the model's objective function, it's just the first two or three values from the numeric array, repeated over and over.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mat1 &amp;lt;- matrix(ncol=10,nrow=4,runif(400))&#xA;&#xA;#define this function, it will be necessary for matrix multiplication inside a MILPModel&#xA;matrix_multiplication_fcn &amp;lt;- function(static_matrix, row_variable, column_variable){&#xA;  vapply(seq_along(row_variable), function(k) static_matrix[row_variable[k], column_variable[k]], numeric(1L))  }&#xA;&#xA;milp_model &amp;lt;- ompr::MILPModel() %&amp;gt;%&#xA;  add_variable(assign_units[rowindex,colindex], rowindex=1:4,colindex=1:10,type='binary') %&amp;gt;%&#xA;  #total binaries ==10&#xA;  add_constraint(sum_expr( assign_units[rowindex,colindex],rowindex=1:4,colindex=1:10 )==10 ) %&amp;gt;%&#xA;  &#xA;  #sum of binaries * mat1 &amp;lt;= 7&#xA;  add_constraint( sum_expr( ompr::colwise(&#xA;    matrix_multiplication_fcn(static_matrix=mat1,row_variable=rowindex,column_variable=colindex)) *&#xA;                              assign_units[rowindex,colindex], &#xA;                            rowindex = 1:4, colindex = 1:10) &amp;lt;= 7) %&amp;gt;%&#xA;&#xA;  #objective: maximize value&#xA;  set_objective(sum_expr(&#xA;    ompr::colwise(matrix_multiplication_fcn(static_matrix=mat1,row_variable=rowindex,column_variable=colindex)) * &#xA;      assign_units[rowindex,colindex],&#xA;    rowindex=1:4,colindex=  1:10),sense='max')&#xA;    &#xA;milp_model_out &amp;lt;-  milp_model %&amp;gt;%   &#xA;  ompr::solve_model(with_ROI(solver = &amp;quot;glpk&amp;quot;,verbosity=-2,gap_limit=0,time_limit=180, node_limit=-1,first_feasible=FALSE))&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3958" LastActivityDate="2020-11-20T14:09:19.867" Title="R ompr MILPModel array multiplication?" Tags="|optimization|r|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5254" PostTypeId="1" AcceptedAnswerId="5255" CreationDate="2020-11-20T14:15:31.343" Score="5" ViewCount="376" Body="&lt;p&gt;I am trying to count the number of matchings in a complete bipartite graph (perfect as well as imperfect). It's relatively easy for me to convince myself that there is &lt;span class=&quot;math-container&quot;&gt;$n!$&lt;/span&gt; &lt;em&gt;perfect&lt;/em&gt; matchings in the graph &lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}_{n,n}$&lt;/span&gt;. However, I cannot seem to figure out how many matchings this graph contains. I have experimented a bit, and the number seems to be very large.&#xA;I have repeatedly solved the IP&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  \min &amp;amp;\ \sum_{i=1}^n\sum_{j=1}^n x_{ij }\\&#xA;  \mbox{s.t.:}\ &amp;amp; \sum_{i =1}^n x_{ij}=1,&amp;amp;&amp;amp;\forall j=1,\dots,n\\&#xA;              \ &amp;amp; x_{ij}\in\{0,1\},&amp;amp;&amp;amp;\forall i,j=1,\dots,n&#xA;\end{align}&lt;/span&gt;&#xA;and then added ``no-good'' inequalities to remove the current solution until the solver (CPLEX) declared the problem infeasible. For &lt;span class=&quot;math-container&quot;&gt;$n=1,2,3,4$&lt;/span&gt; I have gotten the numbers &lt;span class=&quot;math-container&quot;&gt;$1,4,27,256$&lt;/span&gt; which suggests that the number of matchings should be &lt;span class=&quot;math-container&quot;&gt;$n^n$&lt;/span&gt;. But &lt;span class=&quot;math-container&quot;&gt;$n=5$&lt;/span&gt; gave me &lt;span class=&quot;math-container&quot;&gt;$3174$&lt;/span&gt; matchings (not the expected &lt;span class=&quot;math-container&quot;&gt;$5^5=3125$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Can anyone guide me to the number of mathings in &lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}_{n,n}$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Edit: The no-good inequalities I use are the following&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{(i,j):\bar{x}_{ij}=1}x_{ij}\leq n-1&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; is the solution I want to cut out.&lt;/p&gt;&#xA;&lt;p&gt;It turns out that @Kuifje was right and that I had a bug in my code. After fixing that, I get that there is &lt;span class=&quot;math-container&quot;&gt;$n^n$&lt;/span&gt; solutions to my IP.&lt;/p&gt;&#xA;" OwnerUserId="609" LastEditorUserId="609" LastEditDate="2020-11-21T16:44:07.343" LastActivityDate="2020-11-21T16:44:07.343" Title="Counting the number of matchings in a complete bipartite graph" Tags="|assignment-problem|matching|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5255" PostTypeId="2" ParentId="5254" CreationDate="2020-11-20T14:45:39.893" Score="3" Body="&lt;p&gt;If the bipartite graph is &lt;span class=&quot;math-container&quot;&gt;$K_{n,n}$&lt;/span&gt;, then all &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; vertices of the left hand size have exactly &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; possible matches (each node of the right layer is a candidate). So the total number of matchings is &lt;span class=&quot;math-container&quot;&gt;$n^n$&lt;/span&gt; indeed.&lt;/p&gt;&#xA;&lt;p&gt;Maybe you can try and detect if there are identical matchings among the &lt;span class=&quot;math-container&quot;&gt;$3174$&lt;/span&gt; found by CPLEX ?&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="3391" LastEditDate="2020-11-21T09:45:01.057" LastActivityDate="2020-11-21T09:45:01.057" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5256" PostTypeId="1" CreationDate="2020-11-20T14:51:46.723" Score="8" ViewCount="1306" Body="&lt;p&gt;I am using ortools to model a VRP with pickup and delivery constraints, where pickups can be done at different nodes. For example, if node A has a demand, it must be picked at node B or C.&lt;/p&gt;&#xA;&lt;p&gt;Here is how I do this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# data[&amp;quot;pickups_deliveries&amp;quot;] is a dict with keys delivery_nodes and values a list of possible pickup nodes&#xA;# example : data[&amp;quot;pickups_deliveries&amp;quot;][a] = [b,c]&#xA;&#xA;for delivery_node in self.data[&amp;quot;pickups_deliveries&amp;quot;]:&#xA;            # choose one node among all pickup options&#xA;            all_pickups = [&#xA;                self.manager.NodeToIndex(p)&#xA;                for p in self.data[&amp;quot;pickups_deliveries&amp;quot;][delivery_node]&#xA;            ]&#xA;            self.routing.AddDisjunction(all_pickups, 0)&#xA;          &#xA;            # same vehicle for pickup and delivery&#xA;            delivery_index = self.manager.NodeToIndex(delivery_node)&#xA;            self.routing.solver().Add(&#xA;                sum(&#xA;                    self.routing.ActiveVar(p) * self.routing.VehicleVar(p)&#xA;                    for p in all_pickups&#xA;                )&#xA;                == self.routing.VehicleVar(delivery_index)&#xA;            )&#xA;       &#xA;            # precedence constraint&#xA;            time_dimension = self.routing.GetDimensionOrDie(&amp;quot;Time&amp;quot;)&#xA;            self.routing.solver().Add(&#xA;                sum(&#xA;                    self.routing.ActiveVar(p)&#xA;                    * time_dimension.CumulVar(p)&#xA;                    for p in all_pickups&#xA;                )&#xA;                &amp;lt;= time_dimension.CumulVar(delivery_index)&#xA;            )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This works if everything fits into 1 vehicle.  But if capacity constraints require more than 1 vehicle, the solver does not find a solution after a few minutes (solver status 3).&lt;/p&gt;&#xA;&lt;p&gt;I suspect something is wrong with the constraints imposing that the same vehicle is used for the pickup and delivery, but I am not sure.  I have also tried using the following code (from&lt;a href=&quot;https://github.com/google/or-tools/issues/968&quot; rel=&quot;noreferrer&quot;&gt; here&lt;/a&gt;), but it does not help:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;pickup_vehicles = [self.routing.VehicleVar(i) for i in all_pickups]&#xA;deliver_vehicle = [self.routing.VehicleVar(delivery_index)]&#xA;self.routing.solver().AddConstraint(&#xA;self.routing.solver().Max(pickup_vehicles)== self.routing.solver().Max(deliver_vehicle))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Can someone help ? Thanks!&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Note : I have cross posted on ortools &lt;a href=&quot;https://groups.google.com/g/or-tools-discuss&quot; rel=&quot;noreferrer&quot;&gt;mailing list&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-11-20T15:04:43.123" LastActivityDate="2022-03-20T08:59:15.247" Title="OR-TOOLS : delivery node with multiple possible pickup nodes" Tags="|modeling|vehicle-routing|or-tools|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5257" PostTypeId="2" ParentId="5254" CreationDate="2020-11-20T23:34:10.273" Score="8" Body="&lt;p&gt;A matching of size &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$\mathrm{K}_{n,n}$&lt;/span&gt; is uniquely identified by (i) the set of covered vertices in the left partition, for which there are &lt;span class=&quot;math-container&quot;&gt;$\binom{n}{m}$&lt;/span&gt; choices, (ii) the set of covered vertices in the right position, ditto &lt;span class=&quot;math-container&quot;&gt;$\binom{n}{m}$&lt;/span&gt; choices, and (iii) a bijection from the covered vertices on the left onto the covered vertices on the right, for which there are &lt;span class=&quot;math-container&quot;&gt;$m!$&lt;/span&gt; choices. This means there are &lt;span class=&quot;math-container&quot;&gt;$\binom{n}{m}^2 m!$&lt;/span&gt; matchings of size &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, and thus&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;  \sum_{m=0}^n \binom{n}{m}^2 m!&#xA;$$&lt;/span&gt;&#xA;matchings altogether. For example, for &lt;span class=&quot;math-container&quot;&gt;$n=2$&lt;/span&gt; there are &lt;span class=&quot;math-container&quot;&gt;$7$&lt;/span&gt; matchings: &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; perfect matchings, &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; matchings of size &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; (choose one out of two vertices to match on each side), and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; empty matching. Small table:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;  \begin{array}{rr}&#xA;    n &amp;amp; \sum_{m=0}^n \binom{n}{m}^2 m! \\&#xA;    1 &amp;amp; 2 \\&#xA;    2 &amp;amp; 7 \\&#xA;    3 &amp;amp; 34 \\&#xA;    4 &amp;amp; 209 \\&#xA;    5 &amp;amp; 1546 \\&#xA;    6 &amp;amp; 13327 \\&#xA;    7 &amp;amp; 130922&#xA;  \end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4461" LastEditorUserId="4461" LastEditDate="2020-11-21T11:17:44.997" LastActivityDate="2020-11-21T11:17:44.997" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5258" PostTypeId="2" ParentId="5252" CreationDate="2020-11-21T10:04:10.880" Score="2" Body="&lt;p&gt;in the sched_sequence example in OPL CPLEX you have an example of array of sequences:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar sequence workers[w in WorkerNames] in&#xA;    all(h in Houses, t in TaskNames: Worker[t]==w) itvs[h][t] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;that should help you&lt;/p&gt;&#xA;&lt;p&gt;regards&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2020-11-21T10:04:10.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5259" PostTypeId="1" AcceptedAnswerId="5260" CreationDate="2020-11-21T03:27:57.093" Score="5" ViewCount="446" Body="&lt;p&gt;One of the problems I have recently considered is the problem of rebalancing bicycle stations for bike-sharing schemes all over the world. It is not a secret that the demand for bikes across the city varies (some people, including myself, prefer to go downhill rather than uphill, other ride a bike only during sunny weather etc.). Thus, resulting in a serious disproportion of available bikes among different stations at different times of the day. As a result, bike-sharing companies hire men with a van to pick up bikes from less used locations to locations with high demand.&lt;/p&gt;&#xA;&lt;p&gt;How would one go about trying to model that? I am fairly familiar with the concept of networks in operations research. However, this seems to be far more complex. Would it be possible to create a list of stations (nodes) from which the driver would have to pick a certain amount of bikes and transport them elsewhere (to other station/ node)?&lt;/p&gt;&#xA;&lt;p&gt;Suppose that I have data on &lt;code&gt;starting station&lt;/code&gt;, &lt;code&gt;ending station&lt;/code&gt;, &lt;code&gt;duration of the ride&lt;/code&gt;, &lt;code&gt;coordinates of each station&lt;/code&gt;. From a more practical point of view - what might be the right place to get data on the distance between nodes? Assuming the straight lines between nodes seems like a quite of simplification, however, this is what I am trying to do, simplify and then solve the easier problem. If, however, this is an oversimplification, where to get real data on the distances? I tried google's static API but it does not work for me even after I signed up and everything.&lt;/p&gt;&#xA;" OwnerUserId="4465" OwnerDisplayName="bajun65537" LastEditorUserId="38" LastEditDate="2020-11-22T18:46:59.143" LastActivityDate="2020-11-22T18:46:59.143" Title="How to model bicycle sharing scheme?" Tags="|optimization|modeling|applications|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5260" PostTypeId="2" ParentId="5259" CreationDate="2020-11-21T15:03:35.357" Score="11" Body="&lt;p&gt;Daniel Freund, Shane G. Henderson, Eoin O'Mahony, and David B. Shmoys won the 2018 Wagner Prize for their work on this problem.  This link gives lots of info, including a video presentation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.informs.org/Impact/O.R.-Analytics-Success-Stories/Analytics-and-Bikes-Riding-Tandem-with-Motivate-to-Improve-Mobility&quot; rel=&quot;noreferrer&quot;&gt;https://www.informs.org/Impact/O.R.-Analytics-Success-Stories/Analytics-and-Bikes-Riding-Tandem-with-Motivate-to-Improve-Mobility&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The paper is:&lt;/p&gt;&#xA;&lt;p&gt;Freund, Daniel, et al. &amp;quot;Analytics and bikes: Riding tandem with motivate to improve mobility.&amp;quot; &lt;em&gt;INFORMS Journal on Applied Analytics&lt;/em&gt; &lt;strong&gt;49.5&lt;/strong&gt; (2019): 310-323.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-11-21T15:03:35.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5261" PostTypeId="1" CreationDate="2020-11-21T18:19:01.283" Score="4" ViewCount="214" Body="&lt;p&gt;What are the flow-based formulations? For what optimization problems are they applied, and in which form? Which are the specificities of such a formulation?&lt;/p&gt;&#xA;&lt;p&gt;Also, the same question for the time staged formulation.&lt;/p&gt;&#xA;" OwnerUserId="4273" LastEditorUserId="2477" LastEditDate="2020-11-21T18:55:42.127" LastActivityDate="2020-11-22T16:50:06.063" Title="What are the flow based formulations?" Tags="|optimization|mixed-integer-programming|modeling|combinatorial-optimization|scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5262" PostTypeId="1" AcceptedAnswerId="5268" CreationDate="2020-11-21T19:29:16.040" Score="5" ViewCount="344" Body="&lt;p&gt;I recently got interested in the following variation of the shortest path problem. I've looked in the literature for days but I couldn't find any paper studying this problem. I'd like to ask if you have seen this problem (or any similar problem) before, and if you could point me to some relevant literature.&lt;/p&gt;&#xA;&lt;p&gt;In a few words, the problem is as follows. We have a directed graph &lt;span class=&quot;math-container&quot;&gt;$G = (V, E)$&lt;/span&gt;. For each vertex &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt; we have a set &lt;span class=&quot;math-container&quot;&gt;$S_v \in \mathbb R^m$&lt;/span&gt; (say convex) and a point in it &lt;span class=&quot;math-container&quot;&gt;$x_v \in S_v$&lt;/span&gt;. The length of the edge &lt;span class=&quot;math-container&quot;&gt;$(u,v) \in E$&lt;/span&gt; is, e.g., the Euclidean distance between &lt;span class=&quot;math-container&quot;&gt;$x_u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_v$&lt;/span&gt;. A path &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; from source &lt;span class=&quot;math-container&quot;&gt;$s \in V$&lt;/span&gt; to destination &lt;span class=&quot;math-container&quot;&gt;$d \in V$&lt;/span&gt; is defined the usual way. The length of the path &lt;span class=&quot;math-container&quot;&gt;$P = (v_1=s, v_2, \ldots, v_{n-1}, v_n=d)$&lt;/span&gt;, on the other hand, is defined as the minimum w.r.t. the point locations &lt;span class=&quot;math-container&quot;&gt;$x_{v_1} \in S_{v_1}, \ldots, x_{v_n} \in S_{v_n}$&lt;/span&gt; of the sum of the lengths of the edges &lt;span class=&quot;math-container&quot;&gt;$(v_1, v_2), \ldots, (v_{n-1}, v_n)$&lt;/span&gt;. Among all paths from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;, we seek one of minimum length.&lt;/p&gt;&#xA;&lt;p&gt;This problem has the flavor of the &amp;quot;Euclidean shortest path&amp;quot; (see e.g. Sharir and Schorr, &amp;quot;On Shortest Paths in Polyhedral Spaces&amp;quot;) which is common in robot navigation, but it has important differences. I've also seen shortest path problems with generalized arc lengths (see e.g. Frieze, &amp;quot;Minimum Paths in Directed Graphs&amp;quot;), but this problem formulation doesn't quite match the one above either.&lt;/p&gt;&#xA;&lt;p&gt;Any thoughts/ideas?&lt;/p&gt;&#xA;" OwnerUserId="994" LastEditorUserId="491" LastEditDate="2020-11-24T00:06:15.743" LastActivityDate="2020-11-26T20:12:09.057" Title="Shortest path problem with underlying continuous variables" Tags="|mixed-integer-programming|graphs|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5263" PostTypeId="2" ParentId="5259" CreationDate="2020-11-21T22:47:17.040" Score="6" Body="&lt;p&gt;Coordinates of the stations (I assume you mean latitude and longitude) aren't necessary if you have the driving times between stations. You should be able to get estimated driving times via an API to Google Maps or some other mapping source, with a couple of caveats. The first is that driving time may be dependent on time of day and day of week, so you might want to sample all the distances at intervals throughout a week. The other caveat is that driving times from Google Maps, Waze etc. are affected by traffic conditions (generally a good thing), which might include temporary phenomena such as road closures for construction, accident remediation, a parade, etc. It could be tricky to rule those things out, which suggests to me sampling driving times for each segment not just multiple times during the week but over a few different weeks.&lt;/p&gt;&#xA;&lt;p&gt;Another possibility, if you are working with an actual ride share company, is to get them to log van trips (starting and ending station, day and time, travel time). That won't necessarily give you every possible link in the network, but it would provide realistic estimates for at least some (leaving you to use Google Maps, Waze or whatever for the remaining links).&lt;/p&gt;&#xA;&lt;p&gt;You also need demand data (how many bikes are wanted on average at each station at each time of day, how many on average are dropped off at each station at each time of day). There will tend to be temporal patterns, such as commuters wanting to pick up bikes in residential areas or near train and bus stations in the morning, dropping them near urban destinations, and reversing that pattern in the evening.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-11-21T22:47:17.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5264" PostTypeId="2" ParentId="5262" CreationDate="2020-11-22T13:13:39.157" Score="5" Body="&lt;p&gt;One way of addressing this problem would be to discretize the sets &lt;span class=&quot;math-container&quot;&gt;$S_v$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt;. That is, define a finite number of points within &lt;span class=&quot;math-container&quot;&gt;$S_v$&lt;/span&gt;, and for each of these points, define a node. Link these nodes to all of the neighbors of node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, but adapt the distance with the actual Euclidian distance.&lt;/p&gt;&#xA;&lt;p&gt;Once you have this new graph, run the classical shortest path algorithm.&lt;/p&gt;&#xA;&lt;p&gt;For example, suppose you have only one edge in your graph: &lt;span class=&quot;math-container&quot;&gt;$G=(\{u,v\},(u,v))$&lt;/span&gt;. You want the shortest path from &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;. Define nodes &lt;span class=&quot;math-container&quot;&gt;$u_1,...,u_n$&lt;/span&gt; to cover set &lt;span class=&quot;math-container&quot;&gt;$S_u$&lt;/span&gt;, and nodes &lt;span class=&quot;math-container&quot;&gt;$v_1,...,v_n$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$S_v$&lt;/span&gt;, and add an edge from each vertex &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; to each vertex &lt;span class=&quot;math-container&quot;&gt;$v_j$&lt;/span&gt;, with cost &lt;span class=&quot;math-container&quot;&gt;$d_{u_i,v_j}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; denotes the distance that you are using. You can define a source and link it to each node &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt;, and a sink that is linked to each &lt;span class=&quot;math-container&quot;&gt;$v_j$&lt;/span&gt;. Now, the shortest path from &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is the shortest path from the source to the sink.&lt;/p&gt;&#xA;&lt;p&gt;If the triangle inequality holds for the distance function, I cannot think of a good reason why it would not be sufficient to only discretize the borders of sets &lt;span class=&quot;math-container&quot;&gt;$S_v$&lt;/span&gt;. In this case you would save some space and reduce the complexity. However, proving that it is sufficient is yet to be done.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-11-26T20:12:09.057" LastActivityDate="2020-11-26T20:12:09.057" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5265" PostTypeId="2" ParentId="5261" CreationDate="2020-11-22T13:52:29.330" Score="4" Body="&lt;p&gt;&lt;strong&gt;What are flow based formulations ?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Flow based formulations can be used when working with networks. The classical approach is to define a variable for each edge of the network. In a flow based formulation, you basically perform a change of variables, and define a variable for each possible path/flow of the network.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;For what optimization problems are they applied ?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For example, if you are solving a &lt;a href=&quot;https://en.wikipedia.org/wiki/Multi-commodity_flow_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;multi-commodity flow problem&lt;/a&gt;, you would normally have a variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^p$&lt;/span&gt; for each edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; of the network, for each commodity &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;. In a flow based formulation, you will define variables for each possible path, for example, for a path from the source to the sink, for a given commodity, you can define variable &lt;span class=&quot;math-container&quot;&gt;$\lambda_q, q \in \Omega$&lt;/span&gt; . If you have a capacity constraint on an edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, in the first model you would write &lt;span class=&quot;math-container&quot;&gt;$\sum_{p\in P}x_{ij}^p\le Q$&lt;/span&gt;. With a flow based formulation, you would write &lt;span class=&quot;math-container&quot;&gt;$\sum_{q\in \Omega, (i,j) \in q}\lambda_q \le Q$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Which are the specificities of such formulations ?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;They have a tighter linear relaxations than edge based models&lt;/li&gt;&#xA;&lt;li&gt;They are designed to be used with decomposition approaches (column generation/Lagrangian relaxation)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-11-22T16:50:06.063" LastActivityDate="2020-11-22T16:50:06.063" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5267" PostTypeId="1" CreationDate="2020-11-22T19:21:25.377" Score="7" ViewCount="178" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}=\left(a_{ij}\right)$&lt;/span&gt; be a &lt;span class=&quot;math-container&quot;&gt;$n\times J$&lt;/span&gt; matrix with &lt;span class=&quot;math-container&quot;&gt;$a_{ij}\geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$n&amp;gt;J$&lt;/span&gt; and such that no row has all its entries equal to zero, and each column has at most one zero. Let also  &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}=\left(q_i\right)$&lt;/span&gt; a &lt;span class=&quot;math-container&quot;&gt;$n\times 1$&lt;/span&gt; vector of variables. Abusing notation, I'll write &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^{\beta}=\left(q_i^{\beta}\right)$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$\beta&amp;gt;1$&lt;/span&gt;. Finally, let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}=\left(w_j\right)_{1\leq j\leq J}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$w_{j}\geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^{J}w_{j}=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Consider the problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;    \min\limits_{\{q_i\}}&amp;amp; \quad \left(\mathbf{A}\mathbf{w}\right)^{\top}\mathbf{q}^{\beta}\\&#xA;    \text{s.t.}&amp;amp;\quad \quad &#xA;     \begin{cases} &#xA;         \sum_{i=1}^n q_i=1\\&#xA;         \mathbf{q}\geq 0.&#xA;    \end{cases} &#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and, in particular, the specific problems that result from choosing &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}=\mathbf{e}_k=\left(e_j\right)_{1\leq j\leq J}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$e_{k}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e_{j}=0\;\forall j\neq k$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$k=\{1,\dots,J\}$&lt;/span&gt;. Observe that the objetive function in the general problem above is a convex combination of the objective in the &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; specific problems. Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^k$&lt;/span&gt; denote the minimand for each &lt;span class=&quot;math-container&quot;&gt;$\mathbf{e}_k$&lt;/span&gt; and call &lt;span class=&quot;math-container&quot;&gt;$\mathbf{z}^k=\mathbf{A}^{\top}\left(\mathbf{q}^k\right)^{\beta}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If we call &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat q}$&lt;/span&gt; the solution to the general problem for &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}\neq\mathbf{e}_k\;\forall k$&lt;/span&gt;, I believe that there exists &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}^{\prime}$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$w_j^\prime\geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum w_j^\prime&amp;gt;0$&lt;/span&gt;) such that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}^{\top}\mathbf{\hat q}^{\beta}=\sum_{k=1}^J\mathbf{z}^kw_k^\prime$&lt;/span&gt;. In other words, the solution to the general problem is a convex combination of the solutions to the specific problems. Is this correct? If it is, can you provide a reference for the proof?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Following @mtanneau's suggestion, I've obtained the closed form solution for the optimal &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}\left(\mathbf{w}\right)=\left(q_i\left(\mathbf{w}\right)\right)$&lt;/span&gt; given &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}$&lt;/span&gt;. To simplify notation, write &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\bar a}\left(\mathbf{w}\right)=\left(\bar a_i\left(\mathbf{w}\right)\right)=\mathbf{Aw}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\bar a_i\left(\mathbf{w}\right)$&lt;/span&gt; is just the weighted average of the values on row &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (with weights given by &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}$&lt;/span&gt;). Two cases:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\exists i^{*}\,|\,a_{i^{*}j}=0$&lt;/span&gt;. The assumptions on &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}$&lt;/span&gt; warrant that &lt;span class=&quot;math-container&quot;&gt;$i^*$&lt;/span&gt; is unique, and that if &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}$&lt;/span&gt; is such that &lt;span class=&quot;math-container&quot;&gt;$\bar a_{i^*}\left(\mathbf{w}\right)=0$&lt;/span&gt;, it must be the case that &lt;span class=&quot;math-container&quot;&gt;$\bar a_{i}\left(\mathbf{w}\right)&amp;gt;0\;\forall i\neq i^*$&lt;/span&gt;. The solution to the specific problem is &lt;span class=&quot;math-container&quot;&gt;$q_{i^*}\left(\mathbf{e}_j\right)=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q_{i}\left(\mathbf{e}_j\right)=0\,\forall i\neq i^*$&lt;/span&gt;, and, simmilarly, for those &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\bar a_{i^*}\left(\mathbf{w}\right)=0$&lt;/span&gt;, that of the general problem is &lt;span class=&quot;math-container&quot;&gt;$q_{i^*}\left(\mathbf{w}\right)=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q_{i}\left(\mathbf{w}\right)=0\,\forall i\neq i^*$&lt;/span&gt; (if &lt;span class=&quot;math-container&quot;&gt;$\bar a_{i}\left(\mathbf{w}\right)&amp;gt;0\,\forall i$&lt;/span&gt;, the solution follows the structure in (2) below).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a_{ij}&amp;gt;0\;\forall i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ q_i\left(\mathbf{w}\right)=\frac{1}{\bar a_i\left(\mathbf{w}\right)^\frac{1}{\beta-1}\sum_{i^{*}=1}^n\left(\frac{1}{\bar a_{i^{*}}\left(\mathbf{w}\right)}\right)^\frac{1}{\beta-1}}$$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;When &lt;span class=&quot;math-container&quot;&gt;$\mathbf{w}=\mathbf{e}_k$&lt;/span&gt;, this simplifies to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ q_i\left(\mathbf{e}_k\right)=\frac{1}{a_{ik}^\frac{1}{\beta-1}\sum_{i^{*}=1}^n\left(\frac{1}{a_{i^{*}k}}\right)^\frac{1}{\beta-1}}$$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I don't see how to proceed from here.&lt;/p&gt;&#xA;" OwnerUserId="2391" LastEditorUserId="2616" LastEditDate="2020-12-12T05:39:17.433" LastActivityDate="2020-12-12T05:39:17.433" Title="Is the solution of a convex combination of the objective in simple problems a convex combination of the solutions of the same problems?" Tags="|optimization|nonlinear-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5268" PostTypeId="2" ParentId="5262" CreationDate="2020-11-22T21:43:34.097" Score="4" Body="&lt;p&gt;To answer the original question, this is not a problem I have seen before. I upvoted Kuifje's answer, because while approximate it should be fairly computationally efficient if the discretization does not create too many points.&lt;/p&gt;&#xA;&lt;p&gt;Another approach that I think would work would be a riff on Benders decomposition. It requires that the convex sets be polyhedral and given algebraically (either as sets of extreme points and extreme rays or as solutions to sets of linear inequalities). The master problem would be a mixed integer linear program that selects the &amp;quot;virtual path&amp;quot; (the path in the graph). The convex sets and the points in them would not appear in the master problem. The subproblem would be a second order cone program that, for a candidate &amp;quot;virtual path&amp;quot;, would compute the shortest corresponding &amp;quot;physical path&amp;quot; (picking the points in the convex sets). If the master problem underestimated the length of the physical path, an &amp;quot;optimality cut&amp;quot; would be added to the master problem and the fun would resume. I have a tentative formulation, but I'm not sure it is useful.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: By &amp;quot;popular request&amp;quot;, here's my idea. Someone should check my math. First, some terminology. The &lt;em&gt;virtual&lt;/em&gt; path is the path in the graph. The &lt;em&gt;physical&lt;/em&gt; path is the corresponding sequence of line segments connecting points in the associated convex sets. I'll use &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; to denote the origin and destination of the virtual path, respectively.&lt;/p&gt;&#xA;&lt;p&gt;Before formulating the master problem, we compute the shortest physical distance corresponding to each edge in &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$$d_{i,j}=\min\left\{ \left\Vert x_{i}-x_{j}\right\Vert :x_{i}\in S_{i},x_{j}\in S_{j}\right\} \ \forall(i,j)\in E.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The master problem involves only the virtual portion (i.e., the graph), not the physical portion. For each edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in E$&lt;/span&gt; we have a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; that is 1 if and only if that edge is part of the chosen path. We also have a nonnegative variable &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; that is a surrogate for the length of the physical path. The master problem is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat*}{1}&#xA;\min &amp;amp; \ \ w\\&#xA;\textrm{s.t.} &amp;amp; \sum_{(i,j)\in E}y_{i,j}-\sum_{(j,i)\in E}y_{j,i}=\begin{cases}&#xA;1 &amp;amp; i=s\\&#xA;-1 &amp;amp; i=t\\&#xA;0 &amp;amp; s\neq i\neq t&#xA;\end{cases}\forall i\in V\\&#xA; &amp;amp; w\ge\sum_{(i,j)\in E}d_{i,j}y_{i,j}\\&#xA; &amp;amp; \dots&#xA;\end{alignat*}&lt;/span&gt;&#xA;where the ellipsis represents Benders cuts (to come). The first set of constraints is the usual path flow stuff; the last constraint is a valid lower bound for any possible path.&lt;/p&gt;&#xA;&lt;p&gt;The subproblem is a second order cone problem (I think -- someone &lt;em&gt;really&lt;/em&gt; should check this as I don't normally mess with SOCPs). The subproblem is constructed around a proposed virtual path &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;. I use &lt;span class=&quot;math-container&quot;&gt;$P_V$&lt;/span&gt; to denote the vertices on the path and &lt;span class=&quot;math-container&quot;&gt;$P_E$&lt;/span&gt; to denote the edges on the path, both viewed as sets. It uses nonnegative variables &lt;span class=&quot;math-container&quot;&gt;$z_{i,j}$&lt;/span&gt; to represent the Euclidean length of the physical segment corresponding to an edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in P_E$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat*}{1}&#xA;\min &amp;amp; \sum_{(i,j)\in P_{E}}z_{i,j}\\&#xA;\mathrm{s.t.} &amp;amp; \ \ x_{i}\in S_{i}\ \ \forall i\in P_{V}\\&#xA; &amp;amp; z_{i,j}\ge\left\Vert x_{i}-x_{j}\right\Vert \ \ \forall(i,j)\in P_{E}.&#xA;\end{alignat*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first constraint (&lt;span class=&quot;math-container&quot;&gt;$x_i \in S_i$&lt;/span&gt;) has to be translated into linear equality or inequality constraints. (Recall that I assume &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; is polyhedral.) If &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; is given as a set of extreme points (and maybe a set of extreme rays), this entails adding a gaggle of weight variables used to take convex combinations of extreme points and nonnegative combinations of extreme rays. Note that if the virtual path is just a single edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, this problem can be used to calculate &lt;span class=&quot;math-container&quot;&gt;$d_{i,j}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The idea is to solve the master problem and get a candidate virtual path &lt;span class=&quot;math-container&quot;&gt;$\hat{P}$&lt;/span&gt;. You can solve the master to optimality, or if using a solver that supports callbacks you can just go as far as the first (or next) candidate solution. That path is used to construct the subproblem, which is solved to get the actual shortest physical representation of the virtual path. If the surrogate variable matches the physical length, accept the solution (and, if using callbacks, continue). If not, we add the following Benders cut:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w\ge\hat{f}\left(\sum_{(i,j)\in\hat{P}_{E}}y_{i,j}-\left|\hat{P}_{E}\right|+1\right),$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\hat{f}$&lt;/span&gt; is the optimal objective value of the subproblem (the shortest possible length of the physical path) and &lt;span class=&quot;math-container&quot;&gt;$\left|\hat{P}_{E}\right|$&lt;/span&gt; is the number of edges in the virtual path. The Benders cut is guaranteed nonbinding except when a virtual path contains all the edges that the current one does, so it's not a strong cut by any means, but it is valid.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-11-23T19:10:05.877" LastActivityDate="2020-11-23T19:10:05.877" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="5269" PostTypeId="1" AcceptedAnswerId="5270" CreationDate="2020-11-22T23:39:17.597" Score="0" ViewCount="766" Body="&lt;p&gt;I'm trying to describe the travelling salesman problem as an integer programming model. I'm interested in the asymmetric version of the problem. The problem can be summarized as finding the optimal Hamilton circuit. We also always start at node 1. ex: 1 -&amp;gt; 2 -&amp;gt; 4 -&amp;gt; 3 -&amp;gt; 1 is a solution for a graph containing 4 nodes.&lt;/p&gt;&#xA;&lt;p&gt;I have the following constraints :&lt;/p&gt;&#xA;&lt;p&gt;(1) &lt;span class=&quot;math-container&quot;&gt;$\sum_{(i,j) \in A^+} y_{ij} = 1$&lt;/span&gt; Here &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; is a binary variable. if it's equal to 1 it means that the edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is in the optimal path. &lt;span class=&quot;math-container&quot;&gt;$(i,j) \in A^+$&lt;/span&gt; means all edges that enters in a node &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(2) &lt;span class=&quot;math-container&quot;&gt;$\sum_{(j,i) \in A^-} y_{ji} = 1$&lt;/span&gt; Same thing but with every edge that exits a node &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the following constraints we use &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \geq 0$&lt;/span&gt; which represents the flow on an edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(3) &lt;span class=&quot;math-container&quot;&gt;$\sum_{(i,j) \in A^+(i)} x_{ij} = |V|$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$i \in V \text{ , } i = 1$&lt;/span&gt; This means that the total flow that exit through the various edges going out of node 1 is equal to the number of nodes in the graph.&lt;/p&gt;&#xA;&lt;p&gt;(4) &lt;span class=&quot;math-container&quot;&gt;$\sum_{(i,j) \in A^+(i)} x_{ij} - \sum_{(j,i) \in A^-(i)} x_{ji} = -1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$i \in V \text{ , } i \neq 1$&lt;/span&gt; This means that a node i consume one unit of flow. The exception is node 1.&lt;/p&gt;&#xA;&lt;p&gt;(5) &lt;span class=&quot;math-container&quot;&gt;$\sum_{(j,i) \in A^-(i)} x_{ji} = 1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$i \in V \text{ , } i = 1$&lt;/span&gt; This means that the flow that is sent to node 1 is equal to 1. This correspond to when we arrive to our destination ex: 1 -&amp;gt; 2 -&amp;gt; 3 -&amp;gt; 4 -&amp;gt; 1.&lt;/p&gt;&#xA;&lt;p&gt;This programming model is not complete as long as I do not link the binary variables with the flow variables. However I don't understand how to do it properly. Should a new constraint be added?&lt;/p&gt;&#xA;" OwnerUserId="4077" LastEditorUserId="4077" LastEditDate="2020-11-28T20:34:35.313" LastActivityDate="2020-11-28T20:34:35.313" Title="How to describe the traveling salesman problem with an integer programming model?" Tags="|optimization|mixed-integer-programming|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5270" PostTypeId="2" ParentId="5269" CreationDate="2020-11-22T23:42:37.673" Score="10" Body="&lt;p&gt;To enforce &lt;span class=&quot;math-container&quot;&gt;$x_{i,j} &amp;gt; 0 \implies y_{i,j} = 1$&lt;/span&gt;, you can impose a linear big-M constraint &lt;span class=&quot;math-container&quot;&gt;$$x_{i,j} \le (|V|-1) y_{i,j}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This TSP formulation is described in Application 16.2 of Ahuja, Magnanti, and Orlin, &lt;em&gt;Network Flows&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-11-23T13:50:41.003" LastActivityDate="2020-11-23T13:50:41.003" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="5271" PostTypeId="1" AcceptedAnswerId="5272" CreationDate="2020-11-23T12:31:13.880" Score="3" ViewCount="342" Body="&lt;p&gt;I have a known matrix, &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; of size &lt;span class=&quot;math-container&quot;&gt;$U\times B$&lt;/span&gt;.&#xA;The optimization variable is &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; of same size, which is binary&lt;/p&gt;&#xA;&lt;p&gt;Now I have &lt;span class=&quot;math-container&quot;&gt;$$S_u=\frac{\sum\limits_{b=1}^{B} D_{u,b}H_{u,b}}{\sum\limits_{b=1}^{B}H_{u,b}-\sum\limits_{b=1}^{B} D_{u,b}H_{u,b}},\quad \forall u\in\{1,\cdots, U\}$$&lt;/span&gt; and I want to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{u=1}^US_u$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$b_\min\le \sum_{b=1}^B D_{u,b}\le b_\max, \forall u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_{u=1}^{U}D_{u,b}\le u_\max, \forall b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can I perform some alternative formulation so that the function becomes convex, or any convex approximation?&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&lt;p&gt;The denominator is strictly non-negative. The first or positive part of the denominator denotes the case where &lt;span class=&quot;math-container&quot;&gt;$D_{u,b}=1, \forall b, b=1,\cdots, B$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, the elements in &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; are non-negative.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="123" LastEditDate="2021-03-31T07:06:08.143" LastActivityDate="2021-03-31T07:06:08.143" Title="How can I convexify (allowed some approximation) the objective function?" Tags="|mixed-integer-programming|linearization|disciplined-convex-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5272" PostTypeId="2" ParentId="5271" CreationDate="2020-11-23T13:48:01.640" Score="6" Body="&lt;p&gt;You can reformulate exactly as a MILP problem by performing a Charnes-Cooper transformation and then a linearization of the resulting products of binary and continuous variables, as described in my answer &lt;a href=&quot;https://math.stackexchange.com/questions/3500493/doing-a-charnes-cooper-transformation-with-matrices-and-an-zero-one-constraint/3500608?r=SearchResults#3500608&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Because you have a sum of ratios here, introduce a new variable &lt;span class=&quot;math-container&quot;&gt;$T_u$&lt;/span&gt; for each summand &lt;span class=&quot;math-container&quot;&gt;$S_u$&lt;/span&gt;.  The idea is to multiply numerator and denominator by &lt;span class=&quot;math-container&quot;&gt;$T_u$&lt;/span&gt; so that the denominator becomes 1.  You want to maximize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{u,b} D_{u,b} H_{u,b} T_u$$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$$\sum_b H_{u,b} T_u - \sum_b D_{u,b} H_{u,b} T_u = 1$$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;.  Now introduce &lt;span class=&quot;math-container&quot;&gt;$Y_{u,b} = T_u\cdot D_{u,b}$&lt;/span&gt; to linearize both objective and constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{maximize $\sum_{u,b} H_{u,b} Y_{u,b}$ subject to $\sum_b H_{u,b} T_u - \sum_b H_{u,b} Y_{u,b}=1$}$$&lt;/span&gt;&#xA;Finally, linearize the relationship between &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For your new question in EDIT 2, first linearize &lt;span class=&quot;math-container&quot;&gt;$P_{u,b}D_{u,b}$&lt;/span&gt; and then apply Charnes-Cooper.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-11-24T00:05:26.800" LastActivityDate="2020-11-24T00:05:26.800" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="5274" PostTypeId="1" AcceptedAnswerId="5281" CreationDate="2020-11-24T10:30:48.613" Score="0" ViewCount="123" Body="&lt;p&gt;I am struggling with the following optimization problems.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem 1&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max_{\alpha, s_1, s_2}&amp;amp;\quad s_1 + s_2 - \gamma (s_1 (K_1 +c_1 + s_1) + s_2 (K_2+ c_2 + s_2) + 2\alpha K) +C\\\text{s.t.}&amp;amp;\quad s_1 \geq 0, s_2 \geq 0, \alpha \geq 0, \alpha \geq A-s_1 - \beta s_2\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem 2&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max_{\alpha, s_1, s_2}&amp;amp;\quad s_1 + s_2 - \gamma (s_1 (K_1 + s_1) + s_2 (K_2 + s_2) + \alpha K)\\\text{s.t.}&amp;amp;\quad s_1 \geq 0, s_2 \geq 0, \alpha \geq 0, B-s_1 - \beta s_2  \leq  \alpha \leq A-s_1 - \beta s_2\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$K_1 &amp;gt;0, K_2 &amp;gt;0, C&amp;gt;0, 0&amp;lt;\beta&amp;lt;1, 0&amp;lt;B&amp;lt;A, \gamma &amp;gt;0, c_1, c_2 &amp;gt;0 $&lt;/span&gt; are constants.&lt;/p&gt;&#xA;&lt;p&gt;If for a given &lt;span class=&quot;math-container&quot;&gt;$\gamma = \gamma'$&lt;/span&gt;, the optimal objective value of &lt;strong&gt;Problem 1&lt;/strong&gt; is greater than that of &lt;strong&gt;Problem 2&lt;/strong&gt;, is the optimal objective value of &lt;strong&gt;Problem 1&lt;/strong&gt; greater than that of &lt;strong&gt;Problem 2&lt;/strong&gt; for all &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt; \gamma &amp;lt; \gamma'$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;I can prove this when the constraints &lt;span class=&quot;math-container&quot;&gt;$s_1, s_2, \alpha \geq 0$&lt;/span&gt; do not exist. I proved it by determining a closed form solution for each problem and just compared the two (derivative with respect to &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; yields lower value for &lt;strong&gt;Problem 1&lt;/strong&gt; for all &lt;span class=&quot;math-container&quot;&gt;$\gamma &amp;gt;0$&lt;/span&gt;). How can this be solved when the non-negativity constraints are introduced?&lt;/p&gt;&#xA;" OwnerUserId="3983" LastEditorUserId="123" LastEditDate="2020-11-24T10:49:06.027" LastActivityDate="2020-11-25T15:24:44.870" Title="How to prove this convex-optimization problem?" Tags="|optimization|convex-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5275" PostTypeId="2" ParentId="5106" CreationDate="2020-11-24T10:56:26.220" Score="1" Body="&lt;p&gt;As I did not see how one would have to choose the weights in @Kuifje answer I started thinking about the problem as well and I came to the conclusion that it is NP hard.&lt;/p&gt;&#xA;&lt;p&gt;The proof uses reduction of graph partitioning and goes as follows.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$G = (V,E)$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$n:=|V|$&lt;/span&gt; even be the graph that we want to find the minimal graph partitioning of. Create an instance of the above problem by adding an extra node &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; and edges &lt;span class=&quot;math-container&quot;&gt;$\{r,v\}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$v\in V$&lt;/span&gt;. Let the weights of the edges be &lt;span class=&quot;math-container&quot;&gt;$c(e) = \begin{cases} 1 &amp;amp; \text{if } e\in E \\ n &amp;amp; \text{if } r\in e\end{cases}$&lt;/span&gt;. Thus all the original edges have weight &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and the newly added edges have weight &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As we are minimising the maximum cut it is easy to see that &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; has to be moved after exactly half of the nodes in &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; were moved (if this is not clear I can elaborate on it). Let &lt;span class=&quot;math-container&quot;&gt;$V', V''$&lt;/span&gt; be the partition of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; we get from this. The weight of the cut we have at this point is then &lt;span class=&quot;math-container&quot;&gt;$n^2/2 + C(V', V'')$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$C(V', V'')$&lt;/span&gt; is the number of edges between &lt;span class=&quot;math-container&quot;&gt;$V'$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V''$&lt;/span&gt;. As the solving the above problem would minimise this cost it would also minimise the graph partitioning problem.&lt;/p&gt;&#xA;&lt;p&gt;Let me know if any of the steps were unclear or whether I did any mistakes.&lt;/p&gt;&#xA;" OwnerUserId="4477" LastActivityDate="2020-11-24T10:56:26.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5276" PostTypeId="2" ParentId="3989" CreationDate="2020-11-24T15:20:29.327" Score="5" Body="&lt;p&gt;I am pretty sure the answer is &lt;strong&gt;NO&lt;/strong&gt;!&lt;/p&gt;&#xA;&lt;p&gt;Consider the graph consisting of a &lt;span class=&quot;math-container&quot;&gt;$K_5$&lt;/span&gt; (the fully connected graph with 5 nodes) and two additional nodes &lt;span class=&quot;math-container&quot;&gt;$r_1, r_2$&lt;/span&gt; that have an edge to each of the nodes in the &lt;span class=&quot;math-container&quot;&gt;$K_5$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tUJk4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tUJk4.png&quot; alt=&quot;counter example&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The optimal LP relaxation &lt;span class=&quot;math-container&quot;&gt;$S_{hi}$&lt;/span&gt; is taking all nodes with value &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Adding the extra odd circle constraints one can get an optimal solution &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; by setting all nodes to &lt;span class=&quot;math-container&quot;&gt;$\frac{2}{3}$&lt;/span&gt;. Optimality can be seen by the following argument. For each of the seven nodes &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; add two circle constraints that cover the remaining six nodes together, which gives a new constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\neq i}x_j\geq 4$&lt;/span&gt;. Adding all of these scaled by &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{6}$&lt;/span&gt; gives the new inequality &lt;span class=&quot;math-container&quot;&gt;$\sum_{i}x_i\geq 4\cdot \frac{7}{6}$&lt;/span&gt;, which proofs optimality of the solution where all nodes get value &lt;span class=&quot;math-container&quot;&gt;$\frac{2}{3}$&lt;/span&gt;. Thus each of the nodes would fulfil your condition.&lt;/p&gt;&#xA;&lt;p&gt;But the only optimal vertex cover consists of all the nodes in the &lt;span class=&quot;math-container&quot;&gt;$K_5$&lt;/span&gt; leaving the two nodes &lt;span class=&quot;math-container&quot;&gt;$r_1, r_2$&lt;/span&gt; out.&lt;/p&gt;&#xA;" OwnerUserId="4477" LastEditorUserId="4477" LastEditDate="2020-12-19T14:25:54.187" LastActivityDate="2020-12-19T14:25:54.187" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5277" PostTypeId="1" CreationDate="2020-11-24T15:37:40.877" Score="3" ViewCount="130" Body="&lt;p&gt;I am a third year bioinformatics student and would like to apply my knowledge from an introductory course in Optimization Methods to some problems in the field of genomics or bioinformatics.&lt;/p&gt;&#xA;&lt;p&gt;Do you know any optimization problems in this context that a beginner in OR could solve?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="491" LastEditDate="2020-11-24T20:28:11.387" LastActivityDate="2020-11-25T11:27:23.117" Title="Bioinformatics / Genomics Optimization Problems?" Tags="|optimization|cplex|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5278" PostTypeId="1" CreationDate="2020-11-25T10:53:31.353" Score="1" ViewCount="27" Body="&lt;p&gt;currently I'm working on a wind farm layout optimization problem. I found an appropriate model in literature (Fischetti et al.) and now I'm trying to reproduce it using the Python API of cplex with DOCPlex.&#xA;The model looks like the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{align}&#xA;\text{max} \  z = \sum_{i \in V} (P_i x_i - w_i)&#xA;\end{align}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{align}&#xA;N_ {min} \le \sum_{i \in V} x_i \le N_{max} \\\\&#xA;x_i + x_j \le 1 \qquad (i,j) \in E_I \tag{eqn of interest}\\\\&#xA;\sum_{j \in V} I_{i,j} x_j \le w_i + M_i (1-x_i) \quad i \in V \\\\&#xA;w_i \in \{0,1\} \quad i \in V \\\\&#xA;w_i \ge 0 \quad i \in V&#xA;\end{align}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with the corresponding set &lt;span class=&quot;math-container&quot;&gt;$E_I$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\begin{equation}&#xA;\{(i,j): i,j \in V, dist(i,j) &amp;lt; D_{min}, i \neq j\}&#xA;\end{equation}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;From my understanding, this constraint ensures the mininum distance &lt;span class=&quot;math-container&quot;&gt;$D_{min}$&lt;/span&gt; is achieved by comparing the current iterator &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; with all already set locations &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; in the distance of &lt;span class=&quot;math-container&quot;&gt;$D_{min}$&lt;/span&gt;. If there would be a match, the eqn &lt;span class=&quot;math-container&quot;&gt;$x_i + x_j$&lt;/span&gt; would be at least 2 (if the binary at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; would be set), violating the constraint.&#xA;I am currently failing to add this constraint to my model in DOCcplex. If anyone could help my, by giving me a hint I would be glad.&lt;/p&gt;&#xA;&lt;p&gt;Thank you in advance&lt;/p&gt;&#xA;" OwnerUserId="4484" LastActivityDate="2020-11-25T10:53:31.353" Title="Implement geometric constraint using DOCplex" Tags="|mixed-integer-programming|python|docplex|geometric-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5279" PostTypeId="2" ParentId="5277" CreationDate="2020-11-25T11:27:23.117" Score="3" Body="&lt;p&gt;The simplest problem  I can come up with. You have three operations: insertion, deletion and replacement and they are assigned weights: i,d,r. How to transform one string (say AGCT) into another (say TGCAT) with minimum total weight. One way to do this: AGCT-&amp;gt;TGCT-&amp;gt;TGCAT. One replacement and one insertion; total weight: r+i. It can be easily solved by dynamic programming. The strings are genomes or chromosomes, and the operations are gene mutations.&lt;/p&gt;&#xA;" OwnerUserId="4485" LastActivityDate="2020-11-25T11:27:23.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5280" PostTypeId="1" AcceptedAnswerId="5286" CreationDate="2020-11-25T12:14:07.487" Score="3" ViewCount="90" Body="&lt;p&gt;I was trying to find a name for the following model; is it mathematical programming, constraint programming, convex optimization, but as I can see, none of them has a continuous parameter &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; like in the following example.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_i\ge 0$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$i=1,...,n$&lt;/span&gt;) be real variables that we need to determine, &lt;span class=&quot;math-container&quot;&gt;$a_{ij},b_{ij},c_{ij}, d_i$&lt;/span&gt; be given real constants. What is the type of the following model:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$min\sum_{i=1}^{n} x_i$$&lt;/span&gt;&#xA;s.t.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{ij}+b_{ij}(t+x_i)^2+c_{ij}(t+x_j)^2\ge \epsilon, \forall t\in[min\{x_i,x_j\},max\{x_i+d_i,x_j+d_j\}], \forall i,j: i\ne j ?$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To me, it looks like constraint programming, but there is this continuous parameter &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Also, the variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are in the segments for &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4486" LastEditorUserId="4486" LastEditDate="2020-11-30T08:33:24.853" LastActivityDate="2020-11-30T08:33:24.853" Title="What type of model is this" Tags="|modeling|nonlinear-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5281" PostTypeId="2" ParentId="5274" CreationDate="2020-11-25T12:26:32.087" Score="4" Body="&lt;p&gt;If I understood everything correctly this should be false. The following is a counter example.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt;0$&lt;/span&gt; be small. Choose &lt;span class=&quot;math-container&quot;&gt;$K_1=K_2=2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_1 = c_2 = 3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$K=\epsilon$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B=\epsilon, A=2\epsilon$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\beta = \epsilon$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C = 4\epsilon^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;First consider &lt;span class=&quot;math-container&quot;&gt;$\gamma=\gamma'=1$&lt;/span&gt;:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then the first objective becomes:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;-(s_1^2+4s_1+s_2^2+4s_2+2\epsilon\alpha) + 4\epsilon^2&#xA;$$&lt;/span&gt;&#xA;This is optimized by &lt;span class=&quot;math-container&quot;&gt;$s_1=s_2=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha=A=2\epsilon$&lt;/span&gt; giving an objective of &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then the second objective we find:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;-(s_1^2+s_1+s_2^2+s_2+\epsilon\alpha)&#xA;$$&lt;/span&gt;&#xA;This is optimized by &lt;span class=&quot;math-container&quot;&gt;$s_1=s_2=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha=B=\epsilon$&lt;/span&gt; giving an objective of &lt;span class=&quot;math-container&quot;&gt;$-\epsilon^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Thus the optimal solution for the first problem is bigger than the one for the second.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Now consider &lt;span class=&quot;math-container&quot;&gt;$\gamma=\frac{1}{4}&amp;lt;\gamma'$&lt;/span&gt;:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now the first objective becomes:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;-\frac{1}{4}(s_1^2+s_1+s_2^2+s_2+2\epsilon\alpha) + 4\epsilon^2&#xA;$$&lt;/span&gt;&#xA;This is again optimized by &lt;span class=&quot;math-container&quot;&gt;$s_1=s_2=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha=A=2\epsilon$&lt;/span&gt; giving an objective of &lt;span class=&quot;math-container&quot;&gt;$3\epsilon^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And for the second objective we find:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\frac{1}{2}(s_1+s_2)-\frac{1}{4}(s_1^2+s_2^2+\epsilon\alpha))&#xA;$$&lt;/span&gt;&#xA;Here we consider the (not necessarily optimal) solution &lt;span class=&quot;math-container&quot;&gt;$s_1=0, s_2=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha=0$&lt;/span&gt; giving an objective of &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{4}&amp;gt;3\epsilon^2$&lt;/span&gt; for sufficient &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Thus we have a contradiction to your conjecture.&lt;/p&gt;&#xA;" OwnerUserId="4477" LastEditorUserId="4477" LastEditDate="2020-11-25T15:24:44.870" LastActivityDate="2020-11-25T15:24:44.870" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5283" PostTypeId="2" ParentId="5183" CreationDate="2020-11-25T18:34:14.143" Score="5" Body="&lt;p&gt;I found the problem interesting, so I designed an algorithm to solve it (not PAVA-style). You can find a Python implementation &lt;a href=&quot;https://github.com/Coloquinte/stackexchange-fun/blob/master/solver.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;A geometric formulation&lt;/h2&gt;&#xA;&lt;p&gt;The optimality conditions are, for &lt;span class=&quot;math-container&quot;&gt;$1 \lt i \lt n$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i - x_{i-1} = x_{i+1} - x_i~$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$l_i \lt x_i \lt u_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i - x_{i-1} \leq x_{i+1} - x_i~$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_i = u_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i - x_{i-1} \geq x_{i+1} - x_i~$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_i = l_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Using those, we can replace it by a geometric problem with the same optimal solutions. For each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, there is a vertical line with &lt;span class=&quot;math-container&quot;&gt;$x=i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$l_i \leq y \leq u_i$&lt;/span&gt;. The goal is to find the shortest path going through all these segments from left to right. Any bend in this path will correspond to &lt;span class=&quot;math-container&quot;&gt;$x_i = l_i$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x_i = u_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lB7yCm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lB7yCm.png&quot; alt=&quot;Geometric version of the problem&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And its solution:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pbg7Mm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pbg7Mm.png&quot; alt=&quot;Optimal solution&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2&gt;The algorithm&lt;/h2&gt;&#xA;&lt;p&gt;The idea of the algorithm is to find where the next bend is going to be, and restart from there. Knowing the previous bend, we maintain the minimum and maximum slope for the next line, and which &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is at the limit, until we are forced to introduce a new bend.&lt;/p&gt;&#xA;&lt;p&gt;So the core loop is:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;def find_next_bend(n, l, u, x, previous_bend):&#xA;    min_slope = -float(&amp;quot;inf&amp;quot;)&#xA;    max_slope = float(&amp;quot;inf&amp;quot;)&#xA;    min_slope_ind = -1&#xA;    max_slope_ind = -1&#xA;    for i in range(last_bend+1, n):&#xA;        new_min_slope = (l[i] - x[previous_bend]) / (i-previous_bend)&#xA;        new_max_slope = (u[i] - x[previous_bend]) / (i-previous_bend)&#xA;        if new_min_slope &amp;gt; max_slope:&#xA;            # Bend upwards&#xA;            x[max_slope_ind] = u[max_slope_ind]&#xA;            return max_slope_ind&#xA;        if new_max_slope &amp;lt; min_slope:&#xA;            # Bend downwards&#xA;            x[min_slope_ind] = l[min_slope_ind]&#xA;            return min_slope_ind&#xA;        if new_max_slope &amp;lt; max_slope:&#xA;            # Restrict max possible slope&#xA;            max_slope_ind = i&#xA;            max_slope = new_max_slope&#xA;        if new_min_slope &amp;gt; min_slope:&#xA;            # Restrict min possible slope&#xA;            min_slope_ind = i&#xA;            min_slope = new_min_slope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There are cornercases for the first and last bend, that I won't describe here: they are commented in the &lt;a href=&quot;https://github.com/Coloquinte/stackexchange-fun/blob/master/solver.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;full code&lt;/a&gt;. The proof of the algorithm is left as an exercise for the reader :)&lt;/p&gt;&#xA;&lt;h2&gt;Computational results&lt;/h2&gt;&#xA;&lt;p&gt;The algorithm scales perfectly on random data, and finds the optimal solution for &lt;span class=&quot;math-container&quot;&gt;$n &amp;gt; 10^6$&lt;/span&gt; in seconds. Theoretically, it is only &lt;span class=&quot;math-container&quot;&gt;$O(n^2)$&lt;/span&gt; as far as I can tell, but has linear complexity in practice. I am convinced that it's possible to find something that is &lt;span class=&quot;math-container&quot;&gt;$O(n \log n)$&lt;/span&gt;, as it bears some similarity to 2D convex hull algorithms, but that's fun for another day ;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GPwIOm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GPwIOm.png&quot; alt=&quot;First example&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://i.stack.imgur.com/Tjc12m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tjc12m.png&quot; alt=&quot;Second example&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/e2YpOm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/e2YpOm.png&quot; alt=&quot;Third example&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://i.stack.imgur.com/xiLN2m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xiLN2m.png&quot; alt=&quot;Fourth example&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2020-11-26T13:56:08.953" LastActivityDate="2020-11-26T13:56:08.953" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="5284" PostTypeId="1" CreationDate="2020-11-25T18:40:25.473" Score="1" ViewCount="267" Body="&lt;p&gt;Suppose we have two continuous nonnegative variables  &lt;span class=&quot;math-container&quot;&gt;$X_{1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_{2}$&lt;/span&gt; both bounded by the number &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; from above.&lt;/p&gt;&#xA;&lt;p&gt;I would like to model the following:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$X_{1} &amp;gt; 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$X_{2} = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$X_{2} &amp;gt; 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$X_{1} = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I can do this by imposing &lt;span class=&quot;math-container&quot;&gt;$X_{1} X_{2} = 0$&lt;/span&gt; but this is a nonconvex nonlinear term.&lt;/p&gt;&#xA;&lt;p&gt;I can instead model as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{1} \le M \\&#xA;X_{2} \le M  \\ &#xA;X_{1} \le B_{1} M \\&#xA;X_{2} \le B_{2} M \\&#xA;B_{1} + B_{2} \le 1 &#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$B_{1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_{2}$&lt;/span&gt; are binary variables. The result is a MILP.&lt;/p&gt;&#xA;&lt;p&gt;Can you see an alternative way for modeling this relation?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="500" LastEditDate="2020-11-25T18:44:04.323" LastActivityDate="2020-11-26T08:39:45.617" Title="Modeling the product of two variables" Tags="|mixed-integer-programming|modeling|big-m|indicator-constraints|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5285" PostTypeId="2" ParentId="5284" CreationDate="2020-11-25T19:22:37.593" Score="3" Body="&lt;p&gt;This type of constraint is called a &lt;em&gt;complementarity constraint&lt;/em&gt;, and there are several ways of modeling it, two of them you already mentioned.&#xA;There is no silver-bullet formulation: some will work better than others depending on your instance, your solver, etc.&lt;/p&gt;&#xA;&lt;p&gt;Some solvers support complementarity constraints directly, for instance &lt;a href=&quot;https://www.artelys.com/docs/knitro/2_userGuide/complementarity.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Knitro&lt;/a&gt; or &lt;a href=&quot;http://pages.cs.wisc.edu/%7Eferris/path.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;PATH&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you choose the MIP-base route, then an alternative to big-M formulations (the one you proposed above) is to use &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/constraints.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;indicator constraints&lt;/a&gt;. The majority of commercial MIP solvers support it, and it can be more efficient than using a big-M.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2020-11-25T19:22:37.593" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5286" PostTypeId="2" ParentId="5280" CreationDate="2020-11-25T21:45:51.750" Score="2" Body="&lt;p&gt;I would say that &amp;quot;mathematical program&amp;quot; and &amp;quot;optimization&amp;quot; would apply. Constraint programming (CP) is designed primarily for use with discrete variables. It can cope to some extent with continuous variables, but I doubt this problem would fit the CP paradigm very well. Whether the qualifier &amp;quot;convex&amp;quot; applies is hard to say, particularly without knowing the signs of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-11-25T21:45:51.750" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5287" PostTypeId="2" ParentId="5284" CreationDate="2020-11-25T21:52:14.337" Score="2" Body="&lt;p&gt;You can declare &lt;span class=&quot;math-container&quot;&gt;$\lbrace X_1, X_2 \rbrace$&lt;/span&gt; to be a &lt;a href=&quot;https://en.wikipedia.org/wiki/Special_ordered_set&quot; rel=&quot;nofollow noreferrer&quot;&gt;type 1 special ordered set&lt;/a&gt; (SOS1). Assuming that your solver understands SOS1 constraints, it will enforce what you want internally, possibly by a &amp;quot;big M&amp;quot; approach and possibly through branching. This again results in a MILP.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="52" LastEditDate="2020-11-26T08:39:45.617" LastActivityDate="2020-11-26T08:39:45.617" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5288" PostTypeId="1" CreationDate="2020-11-25T23:29:34.807" Score="1" ViewCount="78" Body="&lt;p&gt;In an undirected graph, I'm trying to model a constraint that forcing the optimizer to set an edge &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt; between two nodes to only exist (= &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;) if the two nodes have been selected to be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. The three decision variables can be something like that:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z(u,v) \geq y_u x_v$&lt;/span&gt; , &lt;span class=&quot;math-container&quot;&gt;$\quad x,y,z \in \{0,1\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and to linearize the multiplication here, I'm introducing a new decision variable &lt;span class=&quot;math-container&quot;&gt;$r=xy$&lt;/span&gt; and these constraints has been added:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z(u,v) \geq r(u,v)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$r(u,v) \leq y_u$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$r(u,v) \leq x_v$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$r(u,v) \geq y_u + x_v -1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Keeping in mind that this is for undirected graph where &lt;span class=&quot;math-container&quot;&gt;$r(u,v)$&lt;/span&gt; is different from &lt;span class=&quot;math-container&quot;&gt;$r(v,u)$&lt;/span&gt;. How can I model this in Python using &lt;strong&gt;Pulp&lt;/strong&gt; and &lt;strong&gt;NetworkX&lt;/strong&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="4347" LastActivityDate="2020-11-25T23:29:34.807" Title="Modeling the multiplication of two binary decision variables in undirected graph in python" Tags="|mixed-integer-programming|modeling|python|" AnswerCount="0" CommentCount="12" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5290" PostTypeId="1" AcceptedAnswerId="5291" CreationDate="2020-11-27T03:29:37.213" Score="3" ViewCount="1682" Body="&lt;p&gt;I am trying to solve a basic puzzle by using Google OR-Tools, this is my first try with OR-Tools and I am trying to learn. I completed almost everything and was ready to conclude the program until I came across this problem.&lt;/p&gt;&#xA;&lt;p&gt;For information my &lt;code&gt;game_board&lt;/code&gt; is a dictionary including entire board, with already given values and not given values that are set to &lt;code&gt;IntVar&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have several values in each cell as following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Variable&lt;/strong&gt;, cell is set as &lt;code&gt;IntVar&lt;/code&gt; which were initially 0 in board, so it will be determined to be filled or not, values are 0 for empty, 1 for filled)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;8&lt;/strong&gt;, the cell is free connection, indicating this is just a virtual cell added to represent the game in a matrix so cell above this, is connected to cell below it directly&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;9&lt;/strong&gt;, the cell is a solid block, so it separates its above and below cells.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;What I do is, I iterate over the board and I am try to fill water according to gravity (and some other rules), so I assigned &lt;strong&gt;A cell should be equal to the cell below it if there is no block between them&lt;/strong&gt;. However I forgot that, cell below can be full and the cell above can be empty, however with the constraint set above they can only be equal.&lt;/p&gt;&#xA;&lt;p&gt;I used the part below the set the constraint mentioned above and I have 2 problems at this point.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if (row+1 &amp;lt;= max(row_variable_indices)) and (game_board[(row+1,column)] == 8):&#xA;  if (game_board[(row+1,column)] == -1):&#xA;    model.Add(game_board[(row,column)] == game_board[(row+1,column)])&#xA;  else:&#xA;    model.Add(game_board[(row,column)] == game_board[(row+2,column)])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I overcame this by other methods, but still wanted to ask how can I differentiate &lt;code&gt;IntVar&lt;/code&gt; from something else. I can not differentiate &lt;code&gt;IntVar&lt;/code&gt; as checking &lt;code&gt;IntVar == Int&lt;/code&gt; or &lt;code&gt;IntVar != Int&lt;/code&gt; since thety both return &lt;code&gt;True&lt;/code&gt; for any given &lt;code&gt;Int&lt;/code&gt;. So I checked if cell is equal to &lt;strong&gt;8&lt;/strong&gt; first, if cell is &lt;strong&gt;8&lt;/strong&gt; then cell is either a free connection or a variable, and then I checked if cell is &lt;strong&gt;-1&lt;/strong&gt; as &lt;strong&gt;-1&lt;/strong&gt; is not used in the board anywhere, it would only choose the variables.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;My main problem is I need to change this constraint to &lt;strong&gt;A cell should be equal to the cell below it if there is no block between them and the cell below is assigned to 0&lt;/strong&gt;. I tried doing it &lt;code&gt;.OnlyEnforceIf()&lt;/code&gt; by something like following, but it didn't work and gave following error. How can I solve this. I understand I need to use &lt;code&gt;BoolVar&lt;/code&gt; however I am not sure how to set a &lt;code&gt;BoolVar&lt;/code&gt; for this  condition (and for every other cell I have) because if I can not say if a variable A is set to value x, I can not set the bool based on if A is set to x either&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.Add(game_board[(row,column)] == game_board[(row+1,column)]).OnlyEnforceIf(game_board[(row+1,column)] == 1)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note I actually tried it on some dummy matrix as following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.Add(x[(0,0)]==5).OnlyEnforceIf(x[(0,1)]==6)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;/usr/local/lib/python3.6/dist-packages/ortools/sat/python/cp_model.py in OnlyEnforceIf(self, boolvar)&#xA;    607                     self.__constraint.enforcement_literal.append(b.Index())&#xA;    608         else:&#xA;--&amp;gt; 609             self.__constraint.enforcement_literal.append(boolvar.Index())&#xA;    610         return self&#xA;    611 &#xA;&#xA;AttributeError: 'BoundedLinearExpression' object has no attribute 'Index'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Edited to add that, I can not change (or I don't know if I can) my &lt;code&gt;IntVar&lt;/code&gt; variables to &lt;code&gt;BoolVar&lt;/code&gt; variables and check this filling problem, because I also use &lt;code&gt;sum()&lt;/code&gt; somewhere else counting the filled cells of that row/column by adding up the all &lt;code&gt;IntVar&lt;/code&gt; variables of that row/column. I don't think it works in &lt;code&gt;BoolVar&lt;/code&gt; as they don't have a value to be summed up unlike integer value of &lt;code&gt;IntVar&lt;/code&gt; which is summable.&lt;/p&gt;&#xA;" OwnerUserId="4497" LastEditorUserId="981" LastEditDate="2023-03-04T00:26:15.597" LastActivityDate="2023-03-04T00:26:15.597" Title="Python, Google OR-Tools, OnlyEnforceIf() method" Tags="|python|constraint|constraint-programming|or-tools|puzzles-games|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5291" PostTypeId="2" ParentId="5290" CreationDate="2020-11-27T11:26:23.833" Score="3" Body="&lt;p&gt;Okay I solved the main problem (2) after researching and playing around a bit with &lt;code&gt;BoolVar&lt;/code&gt;. So unlike I thought, I don't have to assign &lt;code&gt;BoolVar&lt;/code&gt; myself based on other things. Instead I could use its two cases &lt;code&gt;True&lt;/code&gt; and &lt;code&gt;False&lt;/code&gt; to check and bind the two cases I have. I made the modification below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if (row+1 &amp;lt;= max(row_variable_indices)) and (game_board[(row+1,column)] == 8):&#xA;  a = model.NewBoolVar('a')&#xA;  if (game_board[(row+1,column)] == -1):&#xA;    model.Add(game_board[(row+1,column)] == 0).OnlyEnforceIf(a)&#xA;    model.Add(game_board[(row,column)] == game_board[(row+1,column)]).OnlyEnforceIf(a)&#xA;&#xA;    model.Add(game_board[(row+1,column)] == 1).OnlyEnforceIf(a.Not())&#xA;&#xA;  else:&#xA;    model.Add(game_board[(row+2,column)] == 0).OnlyEnforceIf(a)&#xA;    model.Add(game_board[(row,column)] == game_board[(row+2,column)]).OnlyEnforceIf(a)&#xA;&#xA;    model.Add(game_board[(row+2,column)] == 1).OnlyEnforceIf(a.Not())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It assigns the cell below as &lt;strong&gt;1&lt;/strong&gt; if and only if &lt;code&gt;BoolVar == False&lt;/code&gt;. Assigns the cell below &lt;strong&gt;0&lt;/strong&gt; if and only if &lt;code&gt;BoolVar == True&lt;/code&gt;, and in this case assigns the top to bottom.&lt;/p&gt;&#xA;&lt;p&gt;Don't forget to add &lt;code&gt;BoolVar == False&lt;/code&gt; case, even if this case doesn't specify any relation between the top and bottom; If this is not set the bottom can be &lt;strong&gt;0&lt;/strong&gt; with &lt;code&gt;BoolVar == False&lt;/code&gt; and in this case top wouldn't be assigned to bottom and the violation of the required constraint (the top is equal to bottom if bottom is 0) may occur.&lt;/p&gt;&#xA;" OwnerUserId="4497" LastActivityDate="2020-11-27T11:26:23.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5292" PostTypeId="1" CreationDate="2020-11-27T16:06:35.130" Score="2" ViewCount="280" Body="&lt;p&gt;This question relates directly to a dataset I've generated for Fantasy Premier League, but I'm also curious how I can apply this to a more general case.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Data&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have a list of premier league players, and for each player &lt;strong&gt;&lt;em&gt;p&lt;/em&gt;&lt;/strong&gt; I have calculated a predicted score &lt;strong&gt;&lt;em&gt;s&lt;/em&gt;&lt;/strong&gt; for that player over a period of time.&lt;/p&gt;&#xA;&lt;p&gt;Each player inherently has a type &lt;strong&gt;&lt;em&gt;t&lt;/em&gt;&lt;/strong&gt;, ranging from 1-4, and a team &lt;strong&gt;&lt;em&gt;m&lt;/em&gt;&lt;/strong&gt; ranging from 1-20. Each player also has an inherent cost &lt;strong&gt;&lt;em&gt;c&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I can construct a team of consisting of 15 of these players. I am constrained by the number of players I can choose from each type &lt;strong&gt;&lt;em&gt;t&lt;/em&gt;&lt;/strong&gt; and team &lt;strong&gt;&lt;em&gt;m&lt;/em&gt;&lt;/strong&gt; such that, the team must have:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;2 players of type &lt;strong&gt;&lt;em&gt;t&lt;/em&gt;&lt;/strong&gt;=&lt;strong&gt;1&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;5 players of type &lt;strong&gt;&lt;em&gt;t&lt;/em&gt;&lt;/strong&gt;=&lt;strong&gt;2&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;5 players of type &lt;strong&gt;&lt;em&gt;t&lt;/em&gt;&lt;/strong&gt;=&lt;strong&gt;3&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;3 players of type &lt;strong&gt;&lt;em&gt;t&lt;/em&gt;&lt;/strong&gt;=&lt;strong&gt;4&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;no more than 3 players from any one team &lt;strong&gt;&lt;em&gt;m&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;a total cost &lt;strong&gt;&lt;em&gt;sum(m)&lt;/em&gt; &amp;lt;=&lt;/strong&gt; some budget value &lt;strong&gt;&lt;em&gt;B&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I create a team which maximises the sum of predicted scores &lt;strong&gt;&lt;em&gt;sum(s)&lt;/em&gt;&lt;/strong&gt; such that all constraints have been met. The brute force approach of generating every allowed team is not viable.&lt;/p&gt;&#xA;" OwnerUserId="4500" OwnerDisplayName="Chris" LastEditorUserId="2477" LastEditDate="2020-11-28T00:10:53.410" LastActivityDate="2020-11-28T00:10:53.410" Title="How can I perform discrete optimisation of a variable over a data set" Tags="|optimization|modeling|constraint|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5293" PostTypeId="2" ParentId="5292" CreationDate="2020-11-27T17:57:14.777" Score="5" Body="&lt;p&gt;What about the following model:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be the set of players. Each player &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; has a type &lt;span class=&quot;math-container&quot;&gt;$t_p$&lt;/span&gt;, expected score &lt;span class=&quot;math-container&quot;&gt;$s_p$&lt;/span&gt;, team &lt;span class=&quot;math-container&quot;&gt;$m_p$&lt;/span&gt; and cost &lt;span class=&quot;math-container&quot;&gt;$c_p$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_p$&lt;/span&gt; be a binary decision variable equal to 1 if &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is chosen for the team, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;/p&gt;&#xA;&lt;p&gt;The constraints are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Must choose 15 players - &lt;em&gt;note that in this case this constraint is redundant and can be omitted, as it's implied by the 4 constraints after it&lt;/em&gt;: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{p \in P} x_p = 15$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;2 players of type &lt;span class=&quot;math-container&quot;&gt;$t = 1$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{p \in P: t_p = 1} x_p = 2$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;5 players of type &lt;span class=&quot;math-container&quot;&gt;$t = 2$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{p \in P: t_p = 2} x_p = 5$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;5 players of type &lt;span class=&quot;math-container&quot;&gt;$t = 3$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{p \in P: t_p = 3} x_p = 5$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;3 players of type &lt;span class=&quot;math-container&quot;&gt;$t = 4$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{p \in P: t_p = 4} x_p = 3$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;no more than 3 players from any one team &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$$ \sum_{p \in P: m_p = i} x_p \leq 3 ; \forall i = 1, \ldots, 20  $$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Total cost below budget value &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{p \in P} c_p x_p \leq B$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Finally, the objective function of maximixing sum of predicted scores will be &lt;span class=&quot;math-container&quot;&gt;$$\sum_{p \in P} s_p x_p. $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are several alternatives to implement and solve this model, such as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An AML such as AMPL or GAMS connected to a mathematical programming solver&lt;/li&gt;&#xA;&lt;li&gt;Via integer programming or constraint programming modules through programming languages like Python.&lt;/li&gt;&#xA;&lt;li&gt;Reading the sets and parameters in a spreadsheet and solve using the tools like Excel's Solver (if model size and complexity allow for it).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2477" LastEditorUserId="2477" LastEditDate="2020-11-27T23:43:37.520" LastActivityDate="2020-11-27T23:43:37.520" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5294" PostTypeId="1" AcceptedAnswerId="5304" CreationDate="2020-11-28T15:53:10.197" Score="8" ViewCount="461" Body="&lt;p&gt;I would like to verify if I understand the nature or workings of integer programming solvers.&lt;/p&gt;&#xA;&lt;p&gt;My understanding is that for integer programming problems like the knapsack problem or the traveling salesman problem several algorithms can be used to solve these problems. Integer programming solvers under the hood formulate a strategy using these algorithms to solve a formalized integer programming problem.&lt;/p&gt;&#xA;&lt;p&gt;Am I correct?&lt;/p&gt;&#xA;" OwnerUserId="4502" LastEditorUserId="491" LastEditDate="2020-12-05T18:33:18.430" LastActivityDate="2020-12-05T18:33:18.430" Title="Understanding integer programming solvers" Tags="|integer-programming|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5295" PostTypeId="2" ParentId="5294" CreationDate="2020-11-28T23:14:45.253" Score="11" Body="&lt;p&gt;The backbone of modern MIP solvers is the so-called &lt;a href=&quot;https://www.jstor.org/stable/1910129&quot; rel=&quot;noreferrer&quot;&gt;branch-and-bound algorithm&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Nowadays, MIP solvers employ a variety of algorithmic tools, such as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;presolve&lt;/li&gt;&#xA;&lt;li&gt;cutting planes&lt;/li&gt;&#xA;&lt;li&gt;heuristics&lt;/li&gt;&#xA;&lt;li&gt;branching strategies&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You can have a look at &lt;a href=&quot;https://www.math.uni-bielefeld.de/documenta/vol-ismp/25_bixby-robert.pdf&quot; rel=&quot;noreferrer&quot;&gt;this paper by R. Bixby&lt;/a&gt; for an overview of such techniques, and their historical context. It is a few years old, but not a difficult read.&lt;/p&gt;&#xA;&lt;p&gt;It's the (non-trivial) combination &amp;amp; interplay of &lt;strong&gt;all&lt;/strong&gt; these tools that make MIP solvers so efficient.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2020-11-28T23:14:45.253" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5296" PostTypeId="2" ParentId="5294" CreationDate="2020-11-30T07:51:19.687" Score="1" Body="&lt;p&gt;Modeling this problems and other types of problems like network flow problems as MIP and solving them with MIP solvers is just one of the available solutions. There are other kinds of algorithms like dynamic programming that may work better than MIP to solve this problems.&#xA;As I know MIP solvers don't support this kind of algorithms.&#xA;You can use solvers API and Implement the algorithm in a programming language. This allows you to combine different algorithms.&lt;/p&gt;&#xA;" OwnerUserId="2326" LastActivityDate="2020-11-30T07:51:19.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5297" PostTypeId="2" ParentId="5294" CreationDate="2020-11-30T08:43:22.093" Score="7" Body="&lt;p&gt;As mtanneau said the core algorithm in MIP solvers is branch-and-bound (actually branch-and-cut) and a lot of machinery around it. But to a certain degree, solvers try to identify problem structures and might employ more problem specific algorithms if they detect a certain structure or adjust their overall solving strategy.&#xA;Single constraint knapsack problems are a good example for that. Depending on the coefficients involved it is way more efficient to use a problem specific dynamic programming algorithm to solve them than using branch-and-cut. Since some of the machinery (cutting place separators for cover and flow cover cuts) require a knapsack solver anyways and it is only natural that some MIP solvers will simply call that code if they realize they got a single constraint knapsack problem as input.&#xA;For other problems it might not be that straight forward, but I can say for certain that some solvers use problem structure specific heuristics to ensure they find good solutions early for problems that, for example, have some form of a traveling salesman structure (and SAS Optimization that I work on actually includes a separate TSP solver if that is what is needed).&#xA;With all these things it is important to remember that MIP solver developers try to implement techniques that are as general as possible and apply to more than a narrow class of problems. But some classes of problems just can't be solved without very specific techniques (at the moment) and then that rule can be muddled up to the point of implementing very specific algorithms for very specific problems...&lt;/p&gt;&#xA;" OwnerUserId="302" LastEditorUserId="302" LastEditDate="2020-12-01T08:32:41.810" LastActivityDate="2020-12-01T08:32:41.810" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5298" PostTypeId="1" CreationDate="2020-11-30T11:00:57.393" Score="7" ViewCount="298" Body="&lt;p&gt;I am given two formulations, that is, two integer programs&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ (IP1)\quad \min \{c^tx \mid Ax\geq a, x\in Z^n\} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ (IP2)\quad \min \{d^ty \mid By\geq b, y\in Z^m\} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and I wish to check whether they describe the same problem. That is, I wish to know, whether the set of integer feasible points for both models is the same. This is, however, complicated by the fact that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables may live in totally different spaces (think of the one-constraint binary program for 0-1 knapsack, and the equivalent longest-path flow formulation that mimics the dynamic program --- toootally different models, same problem).&lt;/p&gt;&#xA;&lt;p&gt;I know that I need a transformation/projection between &lt;span class=&quot;math-container&quot;&gt;$(P1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(P2)$&lt;/span&gt;, and for the above knapsack example (and many others), I know how to do this. But I am interested in a generic answer.&lt;/p&gt;&#xA;&lt;p&gt;I expect that, even when this can be settled in theory (which I assume to be very hard already), computationally doing the &amp;quot;proof&amp;quot; is totally intractable -- and I am ultimately interested in doing a computational check of the equivalence of the two models. Therefore, I can do with a &amp;quot;high probability&amp;quot; argument. What we currently do it to (a) have a reference formulation, (b) explicitly prescribe the transformation (a set of variables that has to be used by every formulation, maybe by explicitly modeling the projection), then (c) use specific instances, (d) put &amp;quot;random&amp;quot; objective functions, (e) solve to optimality, and (f) check whether the same (?) solution occurs -- well, there can be many optimal solutions... so, all this is not so trivial.&lt;/p&gt;&#xA;&lt;p&gt;I cannot help it but I think of Benders here as well.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="491" LastEditDate="2020-11-30T13:48:51.980" LastActivityDate="2020-11-30T13:48:51.980" Title="How to check whether two formulations are equivalent?" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5299" PostTypeId="2" ParentId="5298" CreationDate="2020-11-30T13:02:48.563" Score="1" Body="&lt;p&gt;&lt;strong&gt;A further algorithmic way:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is given you could try to solve for &lt;span class=&quot;math-container&quot;&gt;$i=1, \ldots, \text{number of constraints in }  A$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$r_i = \min \{(A_{i:}x): f(x) = y, By \geq b, y \in \mathbb{Z}^m \}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$r_i &amp;lt; a_i$&lt;/span&gt; then you have found a counterexample, otherwise you can conclude at least for this instance, that they are equal. Might only be practical if the instance is small and &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is simple.&lt;/p&gt;&#xA;&lt;p&gt;It is also possible to multiply &lt;span class=&quot;math-container&quot;&gt;$A_{i:} x \geq a_i$&lt;/span&gt; such they only contain integral values, then one can write a pure feasibility problem &lt;span class=&quot;math-container&quot;&gt;$A_{i:} x \leq a_i -1$&lt;/span&gt;, which might produce stronger cuts.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="3305" LastEditDate="2020-11-30T13:29:34.923" LastActivityDate="2020-11-30T13:29:34.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5300" PostTypeId="1" CreationDate="2020-11-30T13:45:42.373" Score="0" ViewCount="493" Body="&lt;p&gt;Is it possible to solve a 2d bin packing problem or nesting problem with Cplex?&#xA;The solution should present the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; coordinates of each item.&lt;/p&gt;&#xA;" OwnerUserId="4509" LastEditorUserId="36" LastEditDate="2021-02-03T16:48:51.113" LastActivityDate="2021-02-03T16:48:51.113" Title="Solving 2d bin packing, nesting problem with Cplex" Tags="|cplex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5301" PostTypeId="2" ParentId="5300" CreationDate="2020-11-30T16:11:56.743" Score="3" Body="&lt;p&gt;you could start with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;//using CP;&#xA;&#xA;int n=25; // nb of rectangles&#xA; &#xA;&#xA; &#xA; int sizeBigSquare=10000;&#xA; &#xA; int l[i in 1..n]=rand(100);&#xA; int w[i in 1..n]=rand(100);&#xA; &#xA; dvar int x[i in 1..n]in 0..sizeBigSquare;&#xA; dvar int y[i in 1..n] in 0..sizeBigSquare;&#xA; dvar boolean rota[i in 1..n]; // do we rotate?&#xA; &#xA; dexpr int x2[i in 1..n]=x[i]+(rota[i]==1)*w[i]+(rota[i]==0)*l[i];&#xA; dexpr int y2[i in 1..n]=y[i]+(rota[i]==1)*l[i]+(rota[i]==0)*w[i];&#xA; &#xA; dexpr int Mx=max(i in 1..n) x2[i];&#xA; dexpr int My=max(i in 1..n) y2[i];&#xA; &#xA; minimize My;&#xA; &#xA; subject to&#xA; {&#xA;   &#xA;   Mx&amp;lt;=1000;&#xA;   forall(ordered i,j in 1..n)&#xA;     (x2[i]&amp;lt;=x[j]) || (x2[j]&amp;lt;=x[i]) || (y2[i]&amp;lt;=y[j]) || (y2[j]&amp;lt;=y[i]);&#xA; }  &#xA; &#xA; float rate=sum(i in 1..n) w[i]*l[i]/My/Mx; &#xA; &#xA; execute&#xA; {&#xA;  writeln(&amp;quot;Rate=&amp;quot;,rate); &#xA; }   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;that is relying on MIP within CPLEX&lt;/p&gt;&#xA;&lt;p&gt;And if you comment // in //using CP; then this model will use constraint programming&lt;/p&gt;&#xA;" OwnerUserId="627" LastEditorUserId="123" LastEditDate="2020-11-30T17:01:06.493" LastActivityDate="2020-11-30T17:01:06.493" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5302" PostTypeId="1" CreationDate="2020-11-30T16:37:41.450" Score="2" ViewCount="66" Body="&lt;p&gt;I am seeking for a way how to determine set of &amp;quot;arbitrage-free&amp;quot; regional prices for a single commodity market.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There are &lt;span class=&quot;math-container&quot;&gt;$N&amp;gt;1$&lt;/span&gt; production units with costs &lt;span class=&quot;math-container&quot;&gt;$C^{prod}_i, i=1,\dots,N$&lt;/span&gt; and limited production capacities &lt;span class=&quot;math-container&quot;&gt;$P_i^{max}$&lt;/span&gt;. There are no fixed costs.&lt;/li&gt;&#xA;&lt;li&gt;There are &lt;span class=&quot;math-container&quot;&gt;$M&amp;gt;1$&lt;/span&gt; consumers sitting in different regions with fix demands of &lt;span class=&quot;math-container&quot;&gt;$D_j, j=1,\dots,M$&lt;/span&gt;. Total demand is smaller than total supply so that some producers are not producing.&lt;/li&gt;&#xA;&lt;li&gt;There is a transportation cost matrix &lt;span class=&quot;math-container&quot;&gt;$C^{tr}_{ij}$&lt;/span&gt; for shipping from producers to consumers&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;How do I find a set of equilibrium regional prices that:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Maximize profits of producers&lt;/li&gt;&#xA;&lt;li&gt;Match &amp;quot;rational&amp;quot; behavior (most expensive producer sells to marginal costs)&lt;/li&gt;&#xA;&lt;li&gt;Individual producers cannot increase their profits by increasing sale prices because they would loose market share due to activation of concurrents&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I found some literature &lt;a href=&quot;https://doi.org/10.1007/978-0-387-74759-0_628&quot; rel=&quot;nofollow noreferrer&quot;&gt;describing &amp;quot;spatial equilibrium&amp;quot;&lt;/a&gt; which sounds similar to what I am looking for. Somehow I cannot formulate my problem's objective (market welfare). Can you help me or direct in a right direction?&lt;/p&gt;&#xA;&lt;p&gt;What i tried so far:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;introduced common sales price for each producer &lt;span class=&quot;math-container&quot;&gt;$p_i^{prod}$&lt;/span&gt; which is used for all &amp;quot;shipments&amp;quot;. In case if producer is activated it is set to at least &lt;span class=&quot;math-container&quot;&gt;$C^{prod}_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p_i^{prod}\geq used_i\cdot C^{prod}_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;introduced regional sales prices &lt;span class=&quot;math-container&quot;&gt;$p_i^{cons}$&lt;/span&gt; which are limited from below by the cost of shipments used to serve demand. This introduces binary &amp;quot;is shipping&amp;quot; variables &lt;span class=&quot;math-container&quot;&gt;$s_{ij}$&lt;/span&gt; for each producer-consumer link. &lt;span class=&quot;math-container&quot;&gt;$p_i^{cons} \geq p_j^{prod} + C^{tr}_{ij}\cdot s_{ij} - (1-s_{ij})\cdot BigM, \forall j$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;defined welfare function as &lt;span class=&quot;math-container&quot;&gt;$\sum_{ij} (p_i^{prod} - C^{tr}_{ij} - C^{prod}_i)\cdot q_{ij} - \sum_j D_j \cdot p_j^{cons}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Tried to maximize it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There are several issues with my approach:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Problem is MIP&lt;/li&gt;&#xA;&lt;li&gt;Problem is QP&lt;/li&gt;&#xA;&lt;li&gt;Objective seems to be non-convex as reported by CPLEX&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There must be something that i am missing..&lt;/p&gt;&#xA;" OwnerUserId="4512" LastEditorUserId="4512" LastEditDate="2020-12-02T18:17:19.277" LastActivityDate="2020-12-02T18:17:19.277" Title="Determine set of &quot;arbitrage-free&quot; regional prices" Tags="|linear-programming|quadratic-programming|pricing|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5303" PostTypeId="1" CreationDate="2020-11-30T16:38:01.463" Score="1" ViewCount="129" Body="&lt;p&gt;I am trying to solve an optimization programming model involving a non-linear constraint with a square root. It follows (in a simplified form): &lt;span class=&quot;math-container&quot;&gt;$X_i\ge\sqrt{A_i/B_i}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$X_i,A_i,B_i$&lt;/span&gt; are positive variables.&lt;/p&gt;&#xA;&lt;p&gt;Can you please give me some indications to solve?&lt;/p&gt;&#xA;" OwnerUserId="4511" LastEditorUserId="39" LastEditDate="2020-11-30T19:51:51.007" LastActivityDate="2020-11-30T19:51:51.007" Title="Linearization of constraints with square root" Tags="|optimization|mixed-integer-programming|linearization|" AnswerCount="0" CommentCount="4" FavoriteCount="0" ClosedDate="2021-03-04T22:35:12.343" ContentLicense="CC BY-SA 4.0" />
  <row Id="5304" PostTypeId="2" ParentId="5294" CreationDate="2020-11-30T18:12:52.823" Score="9" Body="&lt;p&gt;I'd like to share a MIP solver developer's perspective on how our process works and what that means for the user.&lt;/p&gt;&#xA;&lt;p&gt;A MIP solver is a massive toolbox of algorithmic tools and tricks. Because MIP is generally NP-Hard, when we design a solver we set up a basic framework (for MIP typically branch-and-bound, some parallel functionality, and a bunch of acceleration &amp;amp; primal heuristics), and then enter a painstaking cycle of testing combintions of algorithms on real problems and understanding implementation &amp;amp; algorithmic bottlenecks.&lt;/p&gt;&#xA;&lt;p&gt;MIP solver developers combine fundamental algorithmic tools with this empirical experience to (i) elucidate and exploit special structure, and (ii) tweak algorithms &amp;amp; parameters to skip all calculations that can be skipped.&lt;/p&gt;&#xA;&lt;p&gt;From the user's perspective, this all just works automatically: we identify special structure, reformulate the problem for you, resolve numerical issues in the formulation, quickly test algorithms to see what may or may not perform well in a particular situation, swap algorithms on-the-fly, and so on.&lt;/p&gt;&#xA;&lt;p&gt;This is a process that never ends - people always come up with something we've never seen before (especially in MINLP which is my area of expertise), and the way we make it work in practice is that we start tweaking algorithms and observing changes in behaviour. It is often the case that minor tweaks can make all the difference, but a lot of the time this process leads to the development of brand-new algorithms altogether.&lt;/p&gt;&#xA;&lt;p&gt;We try our best to make sure that the solvers will work well out of the box 100% of the time, but of course this is theoretically impossible - there's always edge cases where the default tuning just doesn't work, which is why solvers also come with options to change some of the algorithms and parameters that the solver will use.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-12-01T21:32:39.040" LastActivityDate="2020-12-01T21:32:39.040" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5305" PostTypeId="1" CreationDate="2020-11-30T23:00:58.790" Score="3" ViewCount="812" Body="&lt;p&gt;I wonder which command should I use to see how the steps the pulp solver is doing when solving a linear program.&lt;/p&gt;&#xA;" OwnerUserId="4514" LastEditorUserId="123" LastEditDate="2021-02-19T11:17:43.540" LastActivityDate="2021-02-19T11:17:43.540" Title="How can I see the engine log when solving a LP using pulp (python)?" Tags="|linear-programming|python|pulp|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5307" PostTypeId="1" AcceptedAnswerId="5347" CreationDate="2020-12-01T02:49:02.900" Score="4" ViewCount="234" Body="&lt;p&gt;I am working on a splittable multicommodity flow problem, where each commodity can be split into &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; orders. However, I don't know the value of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; in advance. Here is my code.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA; {string} nodes=...;&#xA; &#xA; tuple Arc { &#xA;  string fromnode; &#xA;  string tonode; }&#xA;{Arc} arcs=...;&#xA;&#xA;&#xA; tuple Commodity{   &#xA;     key int no;&#xA;     string origin;&#xA;     string dest;&#xA;     int due_time;&#xA;     int departure_time;&#xA; }&#xA;&#xA;{Commodity} commodities =...;&#xA;{Commodity} orders =...; // there is something wrong&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Actually, the tuple&amp;quot;orders&amp;quot; should be a subset of &amp;quot;commodities&amp;quot;. I mean &amp;quot;orders&amp;quot; share the same characteristics with &amp;quot;commodities&amp;quot;, while I don't know the volume of each commodity and how many orders consist of one commodity. All of them should be calculated by MCF.&lt;/p&gt;&#xA;&lt;p&gt;So how should I express &amp;quot;orders&amp;quot;? I also want to find a suitable index of orders, like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar demand[c in commodities][k in orders]&#xA;dvar arrival_time[c in commodities][k in orders];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4515" LastEditorUserId="491" LastEditDate="2022-04-25T12:56:15.610" LastActivityDate="2022-04-25T12:56:15.610" Title="splittable multicommodity problem with CPLEX" Tags="|cplex|network-flow|split-delivery-routing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5308" PostTypeId="1" CreationDate="2020-12-01T03:58:43.957" Score="1" ViewCount="512" Body="&lt;p&gt;Suppose I have the following set of binary variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; ranges from {1,..,4} Highest priority among the three variables &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; , &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Y_j$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; ranges from {1,..,3}&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Z_k$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; ranges from {1,2} lowest priority among the three variables &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; , &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I formulate the following :&lt;/p&gt;&#xA;&lt;p&gt;(1)&#xA;If any variable &lt;span class=&quot;math-container&quot;&gt;$Z_k = 1$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt;, Then each and every &lt;span class=&quot;math-container&quot;&gt;$Y_j$&lt;/span&gt; variables &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt; must first  &lt;span class=&quot;math-container&quot;&gt;$=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;i.e. &lt;span class=&quot;math-container&quot;&gt;$y_1 = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_2 = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_3 = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In other words, before any &lt;span class=&quot;math-container&quot;&gt;$Z_k$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; 1, all &lt;span class=&quot;math-container&quot;&gt;$Y_j$&lt;/span&gt; variables must FIRST = 1&lt;/p&gt;&#xA;&lt;p&gt;(2) SAME APPLIES FOR THE RELATIONSHIP BETWEEN &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; AND &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; variables&lt;/p&gt;&#xA;&lt;p&gt;If any variable &lt;span class=&quot;math-container&quot;&gt;$Yj = 1$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$j\in J$&lt;/span&gt; Then each and every Xi variable &lt;span class=&quot;math-container&quot;&gt;$X1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$X2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$X3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$X4$&lt;/span&gt; must first &lt;span class=&quot;math-container&quot;&gt;$=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x1 = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x2 = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x3 = 1$&lt;/span&gt; , &lt;span class=&quot;math-container&quot;&gt;$x4 = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In other words, before any &lt;span class=&quot;math-container&quot;&gt;$Y_j$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$j\in J$&lt;/span&gt; variables = 1, all &lt;span class=&quot;math-container&quot;&gt;$Yj$&lt;/span&gt; variables must first be = 1&lt;/p&gt;&#xA;&lt;p&gt;I'll write an example just to make sure I was clear:&lt;/p&gt;&#xA;&lt;p&gt;Before &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; is picked and is = 1, All &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; must equal to 1. Meaning that X variables are at a higher priority than y variables and should be picked first.&lt;/p&gt;&#xA;" OwnerUserId="4430" LastEditorUserId="4430" LastEditDate="2020-12-01T04:04:52.383" LastActivityDate="2020-12-01T08:29:04.010" Title="Priority Constraint" Tags="|modeling|integer-programming|constraint|logical-constraints|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5309" PostTypeId="2" ParentId="5308" CreationDate="2020-12-01T08:29:04.010" Score="4" Body="&lt;p&gt;When I get your problem correctly you want to enforce every &lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt; to be activated when any &lt;span class=&quot;math-container&quot;&gt;$Y_j$&lt;/span&gt; is activated and every &lt;span class=&quot;math-container&quot;&gt;$Y_j$&lt;/span&gt; to be activated when any &lt;span class=&quot;math-container&quot;&gt;$Z_k$&lt;/span&gt; is activated.&lt;/p&gt;&#xA;&lt;p&gt;This can be achieved by adding constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;X_i &amp;amp;\geq Y_j &amp;amp;\forall i\in I, j\in J\\ &#xA;Y_j &amp;amp;\geq Z_k &amp;amp;\forall j\in J, k\in K\\&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Here the first set enforces all &lt;span class=&quot;math-container&quot;&gt;$X_i=1$&lt;/span&gt; when any &lt;span class=&quot;math-container&quot;&gt;$Y_j=1$&lt;/span&gt; and the second all &lt;span class=&quot;math-container&quot;&gt;$Y_j=1$&lt;/span&gt; when any &lt;span class=&quot;math-container&quot;&gt;$Z_k=1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4477" LastActivityDate="2020-12-01T08:29:04.010" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5310" PostTypeId="1" CreationDate="2020-12-01T10:21:32.563" Score="3" ViewCount="999" Body="&lt;p&gt;I am solving a MILP model in C++ using Gurobi 7.5.2. More specifically, I am determining the CPU time of my C++ program via the following commands:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;clock_t start_time;&lt;/li&gt;&#xA;&lt;li&gt;double elapsed_time;&lt;/li&gt;&#xA;&lt;li&gt;start_time= clock();&lt;/li&gt;&#xA;&lt;li&gt;model.optimize();&lt;/li&gt;&#xA;&lt;li&gt;elapsed_time = (double) (clock() - start_time)/CLOCKS_PER_SEC;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When I compare the elapsed_time with the Gurobi runtime, the Gurobi runtime does show the actual duration (measured by a chronometer) but the calculated elapsed_time of C++ is way higher. Why is the elapsed_time not the same as the Gurobi runtime and the actual duration (measured by the chronometer)?&lt;/p&gt;&#xA;" OwnerUserId="4520" LastEditorUserId="4520" LastEditDate="2020-12-01T10:37:43.190" LastActivityDate="2020-12-01T18:50:10.453" Title="Calculated CPU time of C++ is different from actual time to solve MILP model via Gurobi" Tags="|mixed-integer-programming|gurobi|c++|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5311" PostTypeId="2" ParentId="5310" CreationDate="2020-12-01T11:15:15.780" Score="1" Body="&lt;p&gt;This is more of a C++ question, so you should rather look for similar questions on stackoverflow.&lt;/p&gt;&#xA;&lt;p&gt;A common issue is that clock() is not accurate for short durations, so you may want one of the high resolution C++ timers instead, as shown in an answer &lt;a href=&quot;https://stackoverflow.com/questions/3220477/how-to-use-clock-in-c&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: as commented by user3680510 and Stradivari, this is due to the use of multithreading, as clock() &lt;a href=&quot;https://stackoverflow.com/questions/2962785/c-using-clock-to-measure-time-in-multi-threaded-programs&quot;&gt;measures the CPU time&lt;/a&gt;. The C++ timer above (or C's time()) will behave correctly.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2020-12-01T13:16:47.660" LastActivityDate="2020-12-01T13:16:47.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5312" PostTypeId="1" AcceptedAnswerId="5314" CreationDate="2020-12-01T12:57:32.000" Score="2" ViewCount="128" Body="&lt;p&gt;I am working with a kind of a reconfigurable process planning, meaning that the same machine can have different configurations and perform multiple operations. Each machine has an initial configuration that can be changed according to the needs. The process plan has a given sequence, each machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; can assume one position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on the process plan.&lt;/p&gt;&#xA;&lt;p&gt;My question is, how to create a constraint to ensure that if in the first occurrence of a given machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; its configuration &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is different from its initial configuration &lt;span class=&quot;math-container&quot;&gt;$c_o$&lt;/span&gt; there will be a cost of changing configuration?&lt;/p&gt;&#xA;&lt;p&gt;I just need to ensure the cost of changing configuration between the first occurrence of a given machine in the process plan, because the change of configuration within the same machine between two consecutive process plan positions is stated by the binary variable presented below:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Y_w{_c}_{c'j-1j}=1$&lt;/span&gt; if a machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; changes its configuration from &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$c'$&lt;/span&gt; between positions &lt;span class=&quot;math-container&quot;&gt;$j-1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, 0 otherwise&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I am also using the following binary variable:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$X_p{_w}_{cj}=1$&lt;/span&gt; if an operation &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is done by a machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; with a configuration &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; at process plan position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, 0 otherwise&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;and the parameter:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$IC_w{_c}_{O}=1$&lt;/span&gt; if configuration &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is the initial configuration of machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, 0 otherwise&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;: process plan positions&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;:machines&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_w$&lt;/span&gt;: configuration &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; of machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;: operations&lt;/p&gt;&#xA;&lt;p&gt;Could someone help me?&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="491" LastEditDate="2022-04-04T21:18:09.790" LastActivityDate="2022-04-04T21:18:09.790" Title="Constraint to handle the machine-configuration's change between initial position and its first occurrence in the process" Tags="|mixed-integer-programming|integer-programming|cplex|constraint|docplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5313" PostTypeId="2" ParentId="5310" CreationDate="2020-12-01T13:54:13.470" Score="1" Body="&lt;p&gt;&lt;code&gt;clock()&lt;/code&gt; measures CPU time instead of real time. In order to measure real time in C++ use:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;auto start = std::chrono::steady_clock::now();&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;//do stuff&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;auto end = std::chrono::steady_clock::now();&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;auto milliseconds = std::chrono::duration_cast&amp;lt;std::chrono::milliseconds&amp;gt;(end - start).count();&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-12-01T18:50:10.453" LastActivityDate="2020-12-01T18:50:10.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5314" PostTypeId="2" ParentId="5312" CreationDate="2020-12-01T14:20:00.160" Score="4" Body="&lt;p&gt;I think you do need some variable that keeps track of the configuration a machine is in at a given process plan position. This could be a variable &lt;span class=&quot;math-container&quot;&gt;$C_{wcj}$&lt;/span&gt; that is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is in configuration &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; at process plan position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then the following three constraints give you that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each machine is in exactly one configuration at each process plan position&lt;/li&gt;&#xA;&lt;li&gt;The configuration of a machine stays the same unless we change the configuration&lt;/li&gt;&#xA;&lt;li&gt;A process can only be run on a machine that has the correct configuration&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\sum_c C_{wcj} &amp;amp;= 1 &amp;amp; \forall w,j\\&#xA;C_{wcj} &amp;amp;= C_{wc(j-1)} + \sum_{c'}Y_{wc'c(j−1)j} - \sum_{c'}Y_{wcc'(j−1)j} &amp;amp;\forall w,c,j\\&#xA;X_{pwcj} &amp;amp;\leq C_{wcj} &amp;amp;\forall p,w,c,j&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this setting you can naturally set the initial configuration of the machine by setting &lt;span class=&quot;math-container&quot;&gt;$C_{wc_w0} = IC_{wcO}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I hope I understood your problem correctly and this helps.&lt;/p&gt;&#xA;" OwnerUserId="4477" LastActivityDate="2020-12-01T14:20:00.160" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5315" PostTypeId="2" ParentId="5312" CreationDate="2020-12-01T14:24:44.880" Score="1" Body="&lt;p&gt;Let binary variable &lt;span class=&quot;math-container&quot;&gt;$Z_w$&lt;/span&gt; indicate whether the first occurrence of machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is different than its initial configuration.  Here's a derivation of linear constraints via conjunctive normal form, without introducing any additional variables:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\bigvee_{c \not= c_0} \bigvee_j \left(\bigvee_p X_{p,w,c,j} \land \bigwedge_{k&amp;lt;j} \bigwedge_q \bigwedge_d \lnot X_{q,w,d,k}\right) \implies Z_w \\&#xA;\lnot \left[\bigvee_{c \not= c_0} \bigvee_j \left(\bigvee_p X_{p,w,c,j} \land \bigwedge_{k&amp;lt;j} \bigwedge_q \bigwedge_d \lnot X_{q,w,d,k}\right)\right] \lor Z_w \\&#xA;\left[\bigwedge_{c \not= c_0} \bigwedge_j \left(\bigwedge_p \lnot X_{p,w,c,j} \lor \bigvee_{k&amp;lt;j} \bigvee_q \bigvee_d X_{q,w,d,k}\right)\right] \lor Z_w \\&#xA;\left[\bigwedge_{c \not= c_0} \bigwedge_j \bigwedge_p \left(\lnot X_{p,w,c,j} \lor \bigvee_{k&amp;lt;j} \bigvee_q \bigvee_d X_{q,w,d,k}\right)\right] \lor Z_w \\&#xA;\bigwedge_{c \not= c_0} \bigwedge_j \bigwedge_p \left(\lnot X_{p,w,c,j} \lor \bigvee_{k&amp;lt;j} \bigvee_q \bigvee_d X_{q,w,d,k} \lor Z_w\right) \\&#xA;1 -  X_{p,w,c,j} + \sum_{k&amp;lt;j} \sum_q \sum_d X_{q,w,d,k} + Z_w \ge 1 \quad \text{for $c \not= c_0, j, p$} \\&#xA;X_{p,w,c,j} \le \sum_{k&amp;lt;j} \sum_q \sum_d X_{q,w,d,k} + Z_w \quad \text{for $c \not= c_0, j, p$} \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If each machine can have at most one configuration at a time, you can strengthen as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{c \not= c_0} X_{p,w,c,j} \le \sum_{k&amp;lt;j} \sum_q \sum_d X_{q,w,d,k} + Z_w \quad \text{for all $j, p$} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If each machine can also perform at most one operation at a time, you can further strengthen as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_p \sum_{c \not= c_0} X_{p,w,c,j} \le \sum_{k&amp;lt;j} \sum_q \sum_d X_{q,w,d,k} + Z_w \quad \text{for all $j$}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;An interpretation of the linear constraints is:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;If machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is in configuration &lt;span class=&quot;math-container&quot;&gt;$c\not= c_0$&lt;/span&gt; at position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; then either it is in some configuration at an earlier position or the first occurrence is different than its initial configuration.&amp;quot;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-12-01T18:18:00.130" LastActivityDate="2020-12-01T18:18:00.130" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5316" PostTypeId="1" AcceptedAnswerId="5317" CreationDate="2020-12-01T14:58:09.560" Score="2" ViewCount="440" Body="&lt;p&gt;I'm trying to understand a proof in Puterman'05 (Markov Decision Processes: Discrete Stochastic Systems). My question is within Theorem 6.9.1 pertaining to the equivalence of solutions to the primal (MDP) LP and the dual LP. The Dual Linear Program has the constraint (Equation 6.9.2):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{a\in A_j} x(j,a) - \sum_{s\in S}\sum_{a\in A_s} \lambda p(j\mid s,a)x(s,a)=\alpha(j),$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; set of all states.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$A_s$&lt;/span&gt; set of actions available in state &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_d(s,a)$&lt;/span&gt; is an occupancy measure for a policy reaching state s and taking action a following the stationary decision-rules/policy &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; discount factor.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p(s'\mid s, a)$&lt;/span&gt; is the MDP's transition dynamics.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is the initial state distribution, and &lt;span class=&quot;math-container&quot;&gt;$\alpha(s)$&lt;/span&gt; is the probability of starting in state &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;My question has to do with the proof that establishes this constraint (Equation 6.9.5). The proof is as follows:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Clearly &lt;span class=&quot;math-container&quot;&gt;$x_d \geq 0$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$\delta(j|k)$&lt;/span&gt; denote the &lt;span class=&quot;math-container&quot;&gt;$(k,j)$&lt;/span&gt;th element of &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;. Then&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align} \sum_s\sum_a \lambda p(j\mid s,a)x_d(s, a) \\ &amp;amp;=\sum_s \sum_a\lambda p(j\mid s, a)\sum_{k\in S}\alpha(k)\sum_{n=1}^{\infty}\lambda^{n-1} P^{d^\infty}(X_n=s,Y_n=a\mid X_1=k) \\ &amp;amp;=\sum_k\alpha(k)\left[ \sum_{n=1}^{\infty} \lambda^n P^{d^\infty} (X_{n+1}=j\mid X_1 = k)\right]\\ &amp;amp;=\sum_k\alpha(k)\left[ \sum_{n=1}^{\infty} \lambda^{n-1} P^{d^\infty} (X_n=j\mid X_1 = k) - \delta(j\mid k)\right] \\ &amp;amp;=\sum_{a}x(j,a) - \alpha(j)\end{align}$$&lt;/span&gt;&#xA;establishing (6.9.2).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Could someone explain the intuition behind the transition between lines 3 and 4? In particular, how &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; is constructed and why that reduces the exponent of &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My current institutions say it has something to do with the fact that line 3 does not account for starting in state &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (and thus if you are in state &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; you need not discount the occupancy probability); however, I cannot follow the decomposition of the terms with this train of thought.&lt;/p&gt;&#xA;" OwnerUserId="4523" LastActivityDate="2020-12-01T15:42:46.823" Title="Understanding MDP's Dual Linear Program" Tags="|linear-programming|markov-decision-process|reinforcement-learning|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5317" PostTypeId="2" ParentId="5316" CreationDate="2020-12-01T15:42:46.823" Score="1" Body="&lt;p&gt;It is just &lt;span class=&quot;math-container&quot;&gt;$$\sum_{n=1}^\infty a_n = \sum_{n=0}^\infty a_n - a_0 = \sum_{n=1}^\infty a_{n-1} - a_0,$$&lt;/span&gt;&#xA;where&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_n=\lambda^n P^{d^\infty}(X_{n+1}=j\mid X_1=k).$$&lt;/span&gt;&#xA;In particular&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_0=\lambda^0 P^{d^\infty}(X_1=j\mid X_1=k) = [j=k] = \begin{cases}1 &amp;amp;\text{if $j=k$}\\0 &amp;amp;\text{otherwise} \end{cases}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-12-01T15:42:46.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5318" PostTypeId="1" AcceptedAnswerId="5319" CreationDate="2020-12-01T18:25:38.260" Score="2" ViewCount="208" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Consider the  minimization problem &lt;span class=&quot;math-container&quot;&gt;$$\min_{x \in \Delta_n} f(x)$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$C^1$&lt;/span&gt; function over the unit simplex &lt;span class=&quot;math-container&quot;&gt;$\Delta_n$&lt;/span&gt;. Prove that &lt;span class=&quot;math-container&quot;&gt;$x^*\in\Delta_n$&lt;/span&gt; is a stationary point of the problem iff there exists &lt;span class=&quot;math-container&quot;&gt;$\mu\in\mathbb{R}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$$\frac{\partial f}{\partial x_i}(x^*)=\left\{\begin{array}{rcl} = \mu&amp;amp;x_i^*&amp;gt;0  \\ \geq\mu&amp;amp;x_i^*=0 \end{array}\right.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I know the solution for the stationary points of &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}_{+}^{n}$&lt;/span&gt; and for&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$C = \{ x : \sum_{i=1}^{n}x_i = 1 \}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and I need to solve this without KKT.&lt;br /&gt;&#xA;I've tried taking &lt;span class=&quot;math-container&quot;&gt;$y\in\Delta_n$&lt;/span&gt; which defined by &lt;span class=&quot;math-container&quot;&gt;$y_k=\left\{\begin{array}{rcl}&#xA;x_k^*&amp;amp;k\notin\{i,j\}\\&#xA;x_j^*&amp;amp;k=i\\&#xA;x_i^*&amp;amp;k=j\\&#xA;\end{array}\right.$&lt;/span&gt;&lt;br /&gt;&#xA;And then looking at the definition of stationary point for &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; and y :&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\nabla f(x^*)(y-x^*)=\sum_{k=1}^{n}\frac{\partial f}{\partial x_k}(x^*)(y_k-x_k^*)=\frac{\partial f}{\partial x_i}(x_j-x_i)+\frac{\partial f}{\partial x_j}(x_i-x_j)=(x_j-x_i)(\frac{\partial f}{\partial x_i}-\frac{\partial f}{\partial x_j})\geq0$&lt;/span&gt; and I tried from this condition to get the desired result but got stuck here.&lt;/p&gt;&#xA;&lt;p&gt;Definition of Stationarity&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; be &lt;span class=&quot;math-container&quot;&gt;$C^1$&lt;/span&gt; function over a closed and convex set &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; . then &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is called a stationary point of (P) if &lt;span class=&quot;math-container&quot;&gt;$\nabla f(x^*)(x-x^*)\geq0$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$x\in C$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4526" LastActivityDate="2020-12-01T22:27:06.693" Title="Stationary condition for unit simplex" Tags="|nonconvex-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5319" PostTypeId="2" ParentId="5318" CreationDate="2020-12-01T22:27:06.693" Score="3" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$e^{(k)}$&lt;/span&gt; denote the vector with &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-th component 1 and all other components 0. Assume first that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is a stationary point. Pick two indices &lt;span class=&quot;math-container&quot;&gt;$i\neq j$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$x_i^*$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_j^*$&lt;/span&gt; are both positive. Then for small positive &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x=x^* + \delta e^{(i)} - \delta e^{(j)}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x^-=x^* - \delta e^{(i)} + \delta e^{(j)}$&lt;/span&gt; are in the simplex. Use the definition of stationarity to show that &lt;span class=&quot;math-container&quot;&gt;$\frac{\partial f}{\partial x_{i}}\left(x^{*}\right)=\frac{\partial f}{\partial x_{j}}\left(x^{*}\right)$&lt;/span&gt;. Next, assume that &lt;span class=&quot;math-container&quot;&gt;$x^*_i \gt 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x^*_j = 0$&lt;/span&gt;, in which case only &lt;span class=&quot;math-container&quot;&gt;$x^-$&lt;/span&gt; is in the simplex. Use the definition of stationarity to show that &lt;span class=&quot;math-container&quot;&gt;$\frac{\partial f}{\partial x_{i}}\left(x^{*}\right) \le \frac{\partial f}{\partial x_{j}}\left(x^{*}\right)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now assume that the gradient condition is satisfied, and use similar logic to show that the stationarity condition is met.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-12-01T22:27:06.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5320" PostTypeId="1" AcceptedAnswerId="5323" CreationDate="2020-12-02T08:49:43.103" Score="2" ViewCount="349" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathcal{U} = \{ [x_1, ..., x_n] \in \mathbb{R}^n : 0 \leq x_i \leq 1\}$&lt;/span&gt; be the unit hypercube and &lt;span class=&quot;math-container&quot;&gt;$C \in \mathbb{R}^n\setminus\mathcal{U}$&lt;/span&gt; fixed. Let us consider the following problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \max_{X \in \mathcal{U}} \hspace{0.5cm}\|X - C\|^2.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there a known polynomial algorithm to solve the above? We can assume that &lt;span class=&quot;math-container&quot;&gt;$\|C\|$&lt;/span&gt; is large enough.&lt;/p&gt;&#xA;" OwnerUserId="3200" LastEditorUserId="3200" LastEditDate="2020-12-02T09:24:03.510" LastActivityDate="2020-12-02T17:47:25.583" Title="Find the farthest point in hypercube to an exterior point" Tags="|optimization|convex-optimization|nonconvex-programming|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5321" PostTypeId="1" CreationDate="2020-12-02T09:21:24.887" Score="3" ViewCount="42" Body="&lt;p&gt;I wondered about this question for sometime.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Definition of Stationarity&lt;br /&gt;&#xA;(P)&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\mbox{min}  f(x)$&lt;/span&gt;&lt;br /&gt;&#xA;s.t&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x\in C$&lt;/span&gt;&lt;br /&gt;&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; be &lt;span class=&quot;math-container&quot;&gt;$C^1$&lt;/span&gt; function over a closed and convex set &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; . then &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is called a stationary point of (P) if &lt;span class=&quot;math-container&quot;&gt;$\nabla f(x^*)(x-x^*)\geq0$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$x\in C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Assume that we know the stationary condition for some two sets &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; ,&lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; can we say something about the stationary condition for &lt;span class=&quot;math-container&quot;&gt;$C=A\cap B$&lt;/span&gt;?&lt;br /&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Cmb8S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cmb8S.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;i.e if we look at &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}_n^+\cap B[0,r]$&lt;/span&gt; can we get the conditions in easier way than checking again by definition?&lt;/p&gt;&#xA;" OwnerUserId="4526" LastActivityDate="2020-12-02T09:21:24.887" Title="Stationary conditions for intersection" Tags="|convex-optimization|nonconvex-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5322" PostTypeId="2" ParentId="5320" CreationDate="2020-12-02T09:29:11.953" Score="3" Body="&lt;p&gt;The solution is given by &lt;span class=&quot;math-container&quot;&gt;$x_i= 0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$abs(c_i) &amp;gt; abs(c_i -1)$&lt;/span&gt; else &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2020-12-02T09:29:11.953" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5323" PostTypeId="2" ParentId="5320" CreationDate="2020-12-02T09:43:54.060" Score="4" Body="&lt;p&gt;As &lt;span class=&quot;math-container&quot;&gt;$x_i\in[0,1]$&lt;/span&gt; we just need to compare the values of the endpoints since &lt;span class=&quot;math-container&quot;&gt;$(x_i-c_i)^2$&lt;/span&gt; is minimised at &lt;span class=&quot;math-container&quot;&gt;$x_i=c_i$&lt;/span&gt;. It is easy to see that &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt; gives the maximum whenever &lt;span class=&quot;math-container&quot;&gt;$c_i\ge1/2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i=1$&lt;/span&gt; otherwise.&lt;/p&gt;&#xA;&lt;p&gt;Thus we can treat &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; as binary variables for the purpose of maximisation (see &lt;a href=&quot;https://or.stackexchange.com/q/33/123&quot;&gt;In an integer program, how I can force a binary variable to equal 1 if some condition holds?&lt;/a&gt; for integer programming formulations).&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2020-12-02T09:51:46.197" LastActivityDate="2020-12-02T09:51:46.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5325" PostTypeId="1" CreationDate="2020-12-02T10:26:25.407" Score="9" ViewCount="285" Body="&lt;p&gt;For a given set of valid inequalities &lt;span class=&quot;math-container&quot;&gt;$\cal V$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left\{\sum_{i}^n w_k x_i + c_k \le 0\right\}_k&#xA;$$&lt;/span&gt;&#xA;we can obtain a polyhedron &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-dimensional space. It's known that the polyhedron &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; can be either represented by its vertices, which is named as the V-representation, or represented by its facet inequalities and equalities, which is called the H-representation. To switch from those two representations, we can utilize different algorithms and packages like &lt;code&gt;lrs&lt;/code&gt;, &lt;code&gt;cdd&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Definitely we can calculate the V-representation from the set of valid inequalities &lt;span class=&quot;math-container&quot;&gt;$\cal V$&lt;/span&gt;, and then switch to the H-representation to obtain all the facet inequalities. Well, this indirect approach is extremely time-consuming sometimes.&lt;/p&gt;&#xA;&lt;p&gt;So the question is, is there a better way to get all the facet inequalities from a set of valid inequalities?&lt;/p&gt;&#xA;" OwnerUserId="4529" LastEditorUserId="500" LastEditDate="2020-12-04T14:00:10.147" LastActivityDate="2020-12-04T18:33:12.400" Title="How to get all the facet inequalities from a set of valid inequalities?" Tags="|linear-programming|polyhedra|valid-inequalities|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5326" PostTypeId="2" ParentId="5320" CreationDate="2020-12-02T13:27:57.540" Score="6" Body="&lt;p&gt;This answers a comment by the OP, to explain why the other answers are correct. It is due to the following standard result.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;A concave objective subject to compact convex constraints has a global minimum at an extreme of the constraints.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;You're maximizing a convex objective, which is equivalent to minimizing the negative of the objective, which is concave. The constraints are compact (bounded feasible set) and convex, so the result applies. Extreme of the constraints has &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; at 0 or 1. Hence the answers from the other posters follow.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2020-12-02T17:47:25.583" LastActivityDate="2020-12-02T17:47:25.583" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5329" PostTypeId="1" CreationDate="2020-12-02T23:16:25.953" Score="2" ViewCount="41" Body="&lt;p&gt;In Optimization, we have problems of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;&amp;amp;\min f(x)\\&#xA;&amp;amp;\text{s.t. }\hspace{0.2cm} x \in S &#xA;\end{align*}&lt;/span&gt;&#xA;and many theorems are of the form &amp;quot;If the problem satisfies certain conditions and &lt;span class=&quot;math-container&quot;&gt;$x^k$&lt;/span&gt; is a certain sequence, then every limit point of &lt;span class=&quot;math-container&quot;&gt;$x^k$&lt;/span&gt;  is a minimum of the problem.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;My question is: Let's say you run the algorithm and produce &lt;span class=&quot;math-container&quot;&gt;$x^1, x^2, ..., x^{1000}$&lt;/span&gt;. Do you write a little problem to pick arbitrary subsequences and see if they look like they might converge?&lt;/p&gt;&#xA;&lt;p&gt;Also, how do you tell if a sequence looks like it might converge? Do you literarily look at it and see if it seems to stabilize around a point?&lt;/p&gt;&#xA;" OwnerUserId="910" LastActivityDate="2020-12-03T22:15:57.443" Title="Question about theorems of the form &quot;Any limit point of the sequence is a minimum of the problem&quot;" Tags="|optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5330" PostTypeId="1" AcceptedAnswerId="5337" CreationDate="2020-12-02T23:44:02.677" Score="2" ViewCount="207" Body="&lt;p&gt;I have &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; jobs and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; machines and want to minimize the makespan, i.e. the total time to finish all jobs. Some jobs have precedence constraints and can only be started once other jobs are finished. Not all machines can do all of the jobs. So far I have a working solution implemented in &lt;code&gt;ortools&lt;/code&gt; based on a problem formulation from &lt;a href=&quot;https://stackoverflow.com/a/62617843/4540852&quot;&gt;this StackOverflow&lt;/a&gt; answer.&lt;/p&gt;&#xA;&lt;p&gt;However I would like to modify the problem, and this is where it gets more tricky. Before, it was assumed that the time it takes a machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; to do job &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is a fixed function &lt;span class=&quot;math-container&quot;&gt;$t(m,n)$&lt;/span&gt;. However, I would like to modify the problem such that the time it takes machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; to do job &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is &lt;strong&gt;also&lt;/strong&gt; a function of the previous job completed by machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; (or a &amp;quot;dummy job&amp;quot; if the machine hasn't done any jobs yet). Something like: &lt;span class=&quot;math-container&quot;&gt;$t'(m, n, n_{prev})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am struggling to add this to the problem formulation. Any suggestions, or links to relevant papers, would be appreciated. I am envisioning a &lt;span class=&quot;math-container&quot;&gt;$t_{m}$&lt;/span&gt; matrix for each machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$t_{m,i,j}$&lt;/span&gt; is the time for machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; to complete job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; if the previous job it did was &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4274" LastEditorUserId="981" LastEditDate="2023-03-04T00:22:57.573" LastActivityDate="2023-03-04T00:22:57.573" Title="Parallel scheduling with precedence constraints and variable job length" Tags="|optimization|combinatorial-optimization|scheduling|or-tools|cp-sat|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5331" PostTypeId="1" CreationDate="2020-12-03T02:02:34.833" Score="9" ViewCount="311" Body="&lt;p&gt;Consider a mixed integer linear program with an objective function that includes only integer variables. &lt;em&gt;Objective integrality cuts&lt;/em&gt; are known as a class of valid inequalities that can be added to strengthen such a formulation: If the objective coefficients are all integers, then the objective value must be an integer because the variables are required to be integer.&lt;/p&gt;&#xA;&lt;p&gt;I am wondering whether objective integrality cuts have been implemented in modern solvers? If not, what could be challenging when implementing objective integrality cuts? I am surprised that a commercial solver such as CPLEX does not seem to consider objective integrality cuts (I'm not sure about Gurobi). It is not uncommon for an optimization problem to have integer objective values (e.g., scheduling problems, assembly line balancing problems, etc). In such cases, the integrality cuts could play a significant role in solving the problem faster. Just to give an example, here is the log file for an instance of a real-world course scheduling problem solved by CPLEX 12.10 (the objective is to maximize the number of student-lesson allocations):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;            Nodes                                         Cuts/&#xA;       Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap&#xA;    &#xA;    *     0+    0                           57.0000       80.0000            40.35%&#xA;          0     0       64.4321  3783       57.0000       64.4321       18   13.04%&#xA;          0     0       63.3571  3783       57.0000     Cuts: 297    16536   11.15%&#xA;          0     0       62.5714  3783       57.0000     Cuts: 744    37274    9.77%&#xA;          0     0       62.5714  3783       57.0000     Cuts: 472    58784    9.77%&#xA;          0     0       62.5714  3783       57.0000     Cuts: 400    80695    9.77%&#xA;          0     0       62.5714  3783       57.0000      Cuts: 50   100726    9.77%&#xA;          0     0       62.5536  3783       57.0000     Cuts: 405   122147    9.74%&#xA;    *     0+    0                           60.0000       62.5536             4.26%&#xA;          0     0        cutoff             60.0000       62.5536   122147    4.26%&#xA;          0     0       62.5536  3783       60.0000     Cuts: 487   163607    4.26%&#xA;    Heuristic still looking.&#xA;          0     2       62.5536  2211       60.0000       62.5536   217531    4.26%&#xA;    Elapsed time = 237.27 sec. (226054.16 ticks, tree = 0.02 MB, solutions = 2)&#xA;          1     3       62.5536  2220       60.0000       62.5536   287580    4.26%&#xA;          2     3       62.5536  2086       60.0000       62.5536   251100    4.26%&#xA;          3     4       62.5536  2162       60.0000       62.5536   309506    4.26%&#xA;.&#xA;.&#xA;.&#xA;&#xA;       2469  1948       62.0000  1506       60.0000       62.5536  4209632    4.26%&#xA;    Elapsed time = 1212.46 sec. (840425.96 ticks, tree = 35.92 MB, solutions = 2)&#xA;       2501  1968       62.0000  1126       60.0000       62.5536  4229228    4.26%&#xA;       2544  1990       62.0000  1025       60.0000       62.5536  4254943    4.26%&#xA;       2555  2005       61.0000  1483       60.0000       62.5536  4266956    4.26%&#xA;    &#xA;    Performing restart 1&#xA;    &#xA;    Repeating presolve.&#xA;    Tried aggregator 2 times.&#xA;    MIP Presolve eliminated 463 rows and 676 columns.&#xA;    MIP Presolve modified 7567 coefficients.&#xA;    Aggregator did 43 substitutions.&#xA;    Reduced MIP has 8121 rows, 14050 columns, and 135496 nonzeros.&#xA;    Reduced MIP has 13853 binaries, 197 generals, 0 SOSs, and 0 indicators.&#xA;    Presolve time = 0.28 sec. (310.77 ticks)&#xA;    Tried aggregator 1 time.&#xA;    Reduced MIP has 8121 rows, 14050 columns, and 135496 nonzeros.&#xA;    Reduced MIP has 13853 binaries, 197 generals, 0 SOSs, and 0 indicators.&#xA;    Presolve time = 0.08 sec. (90.85 ticks)&#xA;    Represolve time = 0.62 sec. (575.33 ticks)&#xA;       2574     0       62.5000  2516       60.0000     Cuts: 122  4514780    4.17%&#xA;       2574     0       62.5000  2516       60.0000     Cuts: 528  4534076    4.17%&#xA;       2574     0       62.2000  2516       60.0000     Cuts: 220  4550193    3.67%&#xA;       2574     0       62.0000  2516       60.0000     Cuts: 200  4565065    3.33%&#xA;       2574     0       62.0000  2516       60.0000     Cuts: 240  4582021    3.33%&#xA;       2574     0       62.0000  2516       60.0000     Cuts: 203  4595338    3.33%&#xA;       2574     0       62.0000  2516       60.0000      Cuts: 94  4615273    3.33%&#xA;       2574     0       62.0000  2516       60.0000     Cuts: 212  4629574    3.33%&#xA;       2574     0       62.0000  2516       60.0000      Cuts: 31  4644396    3.33%&#xA;       2574     0       62.0000  2516       60.0000     Cuts: 228  4660555    3.33%&#xA;       2574     0       62.0000  2516       60.0000     Cuts: 103  4674035    3.33%&#xA;       2574     2       62.0000  1389       60.0000       62.0000  4674035    3.33%&#xA;       2575     3       62.0000  1826       60.0000       62.0000  4709875    3.33%&#xA;       2576     4       62.0000  1816       60.0000       62.0000  4747076    3.33%&#xA;       2577     5       62.0000  1818       60.0000       62.0000  4763581    3.33%&#xA;       2579     7       62.0000  1977       60.0000       62.0000  4816350    3.33%&#xA;       2580     4       62.0000  1936       60.0000       62.0000  4728882    3.33%&#xA;       2582    10       62.0000  2032       60.0000       62.0000  4891825    3.33%&#xA;    Elapsed time = 1711.68 sec. (1187756.21 ticks, tree = 0.05 MB, solutions = 2)&#xA;       2583     5       62.0000  1773       60.0000       62.0000  4764410    3.33%&#xA;       2586    11       62.0000  1604       60.0000       62.0000  4908032    3.33%&#xA;&#xA;.&#xA;.&#xA;.&#xA;&#xA;       6137  1599       61.3333  1125       60.0000       62.0000 12157124    3.33%&#xA;       6146  1598       61.9079  1424       60.0000       62.0000 12173722    3.33%&#xA;       6181  1609       61.3647  1111       60.0000       61.9995 12233657    3.33%&#xA;       6226  1625       61.0000  1003       60.0000       61.9995 12250334    3.33%&#xA;       6249  1636    infeasible             60.0000       61.9995 12278475    3.33%&#xA;       6283  1641    infeasible             60.0000       61.9951 12317307    3.33%&#xA;    Elapsed time = 3963.23 sec. (2538648.23 ticks, tree = 41.58 MB, solutions = 2)&#xA;       6301  1647       61.5000  1577       60.0000       61.9951 12418694    3.33%&#xA;       6364  1666    infeasible             60.0000       61.9934 12316289    3.32%&#xA;       6412  1733       61.7162  1227       60.0000       61.9904 12709071    3.32%&#xA;       6444  1736       61.0000  1106       60.0000       61.9904 12716961    3.32%&#xA;       6476  1656       61.7184  1323       60.0000       61.9904 12350981    3.32%&#xA;       6484  1769       61.7025  1211       60.0000       61.9903 12794727    3.32%&#xA;       6496  1735        cutoff             60.0000       61.9903 12743643    3.32%&#xA;       6511  1775       61.3971   941       60.0000       61.9903 12813587    3.32%&#xA;       6535  1743       61.0000   977       60.0000       61.9903 12757733    3.32%&#xA;       6569  1779       61.0000  1082       60.0000       61.9903 12830429    3.32%&#xA;    Elapsed time = 4023.28 sec. (2579373.65 ticks, tree = 43.78 MB, solutions = 2)&#xA;       6588  1791       61.4419  1166       60.0000       61.9903 12850058    3.32%&#xA;       6603  1791       61.8181  1268       60.0000       61.9903 12872281    3.32%&#xA;       6628  1793       61.5922  1131       60.0000       61.9903 12892286    3.32%&#xA;       6647  1795       61.5000  1150       60.0000       61.9903 12910529    3.32%&#xA;       6672  1795       61.3736  1376       60.0000       61.9903 12927013    3.32%&#xA;       6689  1840       61.0000  1093       60.0000       61.9832 13086892    3.31%&#xA;       6702  1814       61.8944  1642       60.0000       61.9803 12977507    3.30%&#xA;       6747  1842        cutoff             60.0000       61.9803 13106508    3.30%&#xA;       6767  1830       61.8605  1587       60.0000       61.9803 13007243    3.30%&#xA;       6792  1832       61.1159  1134       60.0000       61.9803 13051760    3.30%&#xA;    Elapsed time = 4078.46 sec. (2620380.80 ticks, tree = 45.21 MB, solutions = 2)&#xA;       6822  1832        cutoff             60.0000       61.9803 13070729    3.30%&#xA;       6842  1838       61.0000  1324       60.0000       61.9803 13062044    3.30%&#xA;       6866  1910       61.8334  1441       60.0000       61.9767 13384490    3.29%&#xA;       6874  1909       61.5960  1261       60.0000       61.9767 13405032    3.29%&#xA;       6878  1864       61.2500  1442       60.0000       61.9767 13189519    3.29%&#xA;       6884  1909       61.5172  1466       60.0000       61.9767 13425013    3.29%&#xA;       6907  1920       61.8302  1533       60.0000       61.9687 13538726    3.28%&#xA;       6939  1910       61.0000   944       60.0000       61.9687 13446020    3.28%&#xA;       6966  1909       61.4766   879       60.0000       61.9687 13459069    3.28%&#xA;       7001  1915       61.0000  1167       60.0000       61.9687 13472454    3.28%&#xA;    Elapsed time = 4145.74 sec. (2661009.25 ticks, tree = 47.80 MB, solutions = 2)&#xA;       7021  1967        cutoff             60.0000       61.9687 13747529    3.28%&#xA;       7040  1923       61.3571  1135       60.0000       61.9687 13504972    3.28%&#xA;       7070  1918        cutoff             60.0000       61.9681 13572484    3.28%&#xA;       7114  1984       61.0000  1237       60.0000       61.9681 13811339    3.28%&#xA;       7161  1985       61.3571   936       60.0000       61.9681 13791200    3.28%&#xA;       7195  1990       61.0000  1051       60.0000       61.9655 13802870    3.28%&#xA;       7241  2037       61.4184  1335       60.0000       61.9655 13856241    3.28%&#xA;       7273  2041       61.0000   718       60.0000       61.9605 13870340    3.27%&#xA;       7330  2027    infeasible             60.0000       61.9605 14163653    3.27%&#xA;       7381  2049       61.4755  1224       60.0000       61.9605 14182949    3.27%&#xA;    Elapsed time = 4206.36 sec. (2700755.48 ticks, tree = 51.38 MB, solutions = 2)&#xA;       7398  2062       61.7146  1275       60.0000       61.9605 14200049    3.27%&#xA;       7429  2012       61.2611  1148       60.0000       61.9605 14005744    3.27%&#xA;       7436  2052       61.3431  1829       60.0000       61.9605 13906393    3.27%&#xA;       7449  2070       61.0000   764       60.0000       61.9603 14231211    3.27%&#xA;       7490  2022       61.2747  1098       60.0000       61.9603 14022232    3.27%&#xA;       7530  2074        cutoff             60.0000       61.9521 14272106    3.25%&#xA;       7549  2039       61.7106  1072       60.0000       61.9521 14038477    3.25%&#xA;       7586  2048       61.8510  1416       60.0000       61.9521 14059524    3.25%&#xA;       7606  2230       61.0000  1314       60.0000       61.9502 14554729    3.25%&#xA;       7628  2179        cutoff             60.0000       61.9502 14392664    3.25%&#xA;    Elapsed time = 4270.14 sec. (2743050.11 ticks, tree = 53.81 MB, solutions = 2)&#xA;       7648  2120       61.0000   894       60.0000       61.9502 14322353    3.25%&#xA;       7672  2133       61.8597  1531       60.0000       61.9502 14308142    3.25%&#xA;       7686  2231       61.9079  1684       60.0000       61.9502 14601680    3.25%&#xA;       7699  2119       61.8254  1403       60.0000       61.9502 14351175    3.25%&#xA;       7714  2234       61.0000   998       60.0000       61.9470 14664571    3.25%&#xA;       7723  2236       61.0000  1212       60.0000       61.9470 14644039    3.25%&#xA;       7731  2134       61.8674  1343       60.0000       61.9470 14318333    3.25%&#xA;       7756  2238       61.0000   733       60.0000       61.9463 14674875    3.24%&#xA;       7776  2255       61.2500  1536       60.0000       61.9463 14725473    3.24%&#xA;       7786  2256       61.8481  1247       60.0000       61.9463 14735565    3.24%&#xA;    Elapsed time = 4332.20 sec. (2783199.85 ticks, tree = 56.46 MB, solutions = 2)&#xA;       7791  2257        cutoff             60.0000       61.9463 14745895    3.24%&#xA;       7808  2264       61.0000  1198       60.0000       61.9430 14946733    3.24%&#xA;       7821  2270       61.0000   984       60.0000       61.9430 14950291    3.24%&#xA;       7860  2290       61.0000  1212       60.0000       61.9430 14776599    3.24%&#xA;       7875  2295       61.0000   932       60.0000       61.9430 14786495    3.24%&#xA;       7895  2263       61.0000  1251       60.0000       61.9430 14884742    3.24%&#xA;       7934  2271    infeasible             60.0000       61.9430 14890638    3.24%&#xA;       7955  2303       61.7400  1119       60.0000       61.9430 14828629    3.24%&#xA;       7971  2317       61.0000   905       60.0000       61.9383 15097930    3.23%&#xA;       7990  2272       61.3033  1703       60.0000       61.9383 15027318    3.23%&#xA;    Elapsed time = 4388.94 sec. (2822866.25 ticks, tree = 57.50 MB, solutions = 2)&#xA;       8007  2333       61.0000   867       60.0000       61.9354 15151925    3.23%&#xA;       8029  2333       61.8355  1319       60.0000       61.9354 15165228    3.23%&#xA;       8046  2334       61.0000  1299       60.0000       61.9354 15178204    3.23%&#xA;       8060  2343       61.2530  1273       60.0000       61.9354 15191329    3.23%&#xA;       8078  2326       61.0000  1075       60.0000       61.9354 15125606    3.23%&#xA;       8098  2354       61.0000  1058       60.0000       61.9324 15218130    3.22%&#xA;       8156  2361       61.4800   969       60.0000       61.9324 15232884    3.22%&#xA;       8188  2266       61.0000  1072       60.0000       61.9324 15065570    3.22%&#xA;       8217  2352    infeasible             60.0000       61.9304 15355287    3.22%&#xA;       8241  2354       61.3676  1088       60.0000       61.9303 15369248    3.22%&#xA;    Elapsed time = 4446.48 sec. (2862230.01 ticks, tree = 60.96 MB, solutions = 2)&#xA;       8277  2365       61.0924  1171       60.0000       61.9303 15247471    3.22%&#xA;       8316  2426       61.0000   942       60.0000       61.9261 15559093    3.21%&#xA;       8336  2400       61.1240  1216       60.0000       61.9261 15508046    3.21%&#xA;       8367  2401       61.3986  1564       60.0000       61.9261 15517862    3.21%&#xA;       8416  2357       61.0000  1159       60.0000       61.9261 15407396    3.21%&#xA;       8469  2372    infeasible             60.0000       61.9261 15396690    3.21%&#xA;       8506  2369       61.0000   779       60.0000       61.9261 15418228    3.21%&#xA;       8547  2449       61.8355  1424       60.0000       61.9235 15744339    3.21%&#xA;       8574  2373        cutoff             60.0000       61.9235 15484108    3.21%&#xA;       8584  2373       61.3522  1138       60.0000       61.9235 15508231    3.21%&#xA;    Elapsed time = 4506.51 sec. (2901953.67 ticks, tree = 61.37 MB, solutions = 2)&#xA;       8620  2487    infeasible             60.0000       61.9189 15913518    3.20%&#xA;       8642  2512       61.0000   815       60.0000       61.9173 16054147    3.20%&#xA;       8682  2491       61.0000   693       60.0000       61.9173 15951697    3.20%&#xA;       8718  2489    infeasible             60.0000       61.9142 15960741    3.19%&#xA;       8783  2547       61.5657  1450       60.0000       61.9142 16227651    3.19%&#xA;       8824  2523    infeasible             60.0000       61.9142 16130680    3.19%&#xA;       8887  2489       61.0000   714       60.0000       61.9142 15813419    3.19%&#xA;       8920  2494    infeasible             60.0000       61.9142 15834833    3.19%&#xA;       8980  2492       61.0000   738       60.0000       61.9142 15857991    3.19%&#xA;       9006  2548    infeasible             60.0000       61.9142 16322787    3.19%&#xA;    Elapsed time = 4562.09 sec. (2940776.73 ticks, tree = 65.84 MB, solutions = 2)&#xA;       9025  2547       61.6203  1203       60.0000       61.9142 16235296    3.19%&#xA;       9050  2500       61.2500   975       60.0000       61.9142 16018633    3.19%&#xA;       9088  2552       61.8385  1463       60.0000       61.9036 16341978    3.17%&#xA;       9123  2553        cutoff             60.0000       61.8966 16365088    3.16%&#xA;       9164  2593       61.6620  1309       60.0000       61.8966 16502662    3.16%&#xA;       9196  2641       61.0000  1047       60.0000       61.8966 16746483    3.16%&#xA;       9243  2647       61.5000   913       60.0000       61.8966 16767595    3.16%&#xA;       9280  2599       61.0000  1102       60.0000       61.8966 16561253    3.16%&#xA;       9332  2627       61.7113  1186       60.0000       61.8966 16590406    3.16%&#xA;       9356  2628       61.0930  1225       60.0000       61.8966 16611364    3.16%&#xA;    Elapsed time = 4625.76 sec. (2981229.66 ticks, tree = 66.86 MB, solutions = 2)&#xA;       9380  2650       61.2630  1095       60.0000       61.8919 16836200    3.15%&#xA;       9399  2653       61.0000  1807       60.0000       61.8919 16868094    3.15%&#xA;       9434  2652       61.0000  1115       60.0000       61.8919 16872831    3.15%&#xA;       9452  2663       61.7739   989       60.0000       61.8919 16908281    3.15%&#xA;       9489  2689       61.0000   916       60.0000       61.8919 16922193    3.15%&#xA;       9515  2676        cutoff             60.0000       61.8825 17184971    3.14%&#xA;       9536  2676        cutoff             60.0000       61.8825 17197590    3.14%&#xA;       9559  2653       61.0000  1108       60.0000       61.8674 16989017    3.11%&#xA;       9596  2655        cutoff             60.0000       61.8674 16997530    3.11%&#xA;       9631  2692       61.0000  1068       60.0000       61.8674 17219131    3.11%&#xA;    Elapsed time = 4683.73 sec. (3020301.29 ticks, tree = 67.36 MB, solutions = 2)&#xA;       9677  2705    infeasible             60.0000       61.8674 17243510    3.11%&#xA;       9710  2692       61.2222   543       60.0000       61.8674 17047013    3.11%&#xA;       9730  2711        cutoff             60.0000       61.8674 17281318    3.11%&#xA;       9736  2713       61.5693  1157       60.0000       61.8674 17293726    3.11%&#xA;       9741  2718       61.0305  1214       60.0000       61.8674 17301128    3.11%&#xA;       9760  2762       61.0314  1247       60.0000       61.8451 17579803    3.08%&#xA;       9787  2817       61.0000  1424       60.0000       61.8451 17774155    3.08%&#xA;       9820  2797    infeasible             60.0000       61.8451 17700085    3.08%&#xA;       9837  2766       61.0000  1023       60.0000       61.8363 17608387    3.06%&#xA;       9847  2833       61.0000  1176       60.0000       61.8363 17815781    3.06%&#xA;    Elapsed time = 4754.33 sec. (3067906.75 ticks, tree = 70.23 MB, solutions = 2)&#xA;       9867  2812       61.1667  2051       60.0000       61.8363 17870760    3.06%&#xA;       9889  2837        cutoff             60.0000       61.8363 17858429    3.06%&#xA;       9931  2838       61.5000  1075       60.0000       61.8291 17872321    3.05%&#xA;       9978  2825       61.0000  1209       60.0000       61.8291 17970922    3.05%&#xA;      10067  2863       61.0000  1335       60.0000       61.8291 17909832    3.05%&#xA;      10155  2829    infeasible             60.0000       61.8291 17748554    3.05%&#xA;      10222  2813        cutoff             60.0000       61.8291 17982223    3.05%&#xA;      10288  2847    infeasible             60.0000       61.8165 18056261    3.03%&#xA;      10336  2857       61.1795  1001       60.0000       61.8165 18077392    3.03%&#xA;      10376  2947    infeasible             60.0000       61.8041 18445395    3.01%&#xA;    Elapsed time = 4810.86 sec. (3107326.40 ticks, tree = 74.47 MB, solutions = 2)&#xA;      10435  2859    infeasible             60.0000       61.8041 18125171    3.01%&#xA;      10489  2868        cutoff             60.0000       61.8041 18130255    3.01%&#xA;      10503  2951       61.4333  1405       60.0000       61.8041 18508519    3.01%&#xA;      10537  2874       61.0000   648       60.0000       61.8041 18151270    3.01%&#xA;      10559  2950        cutoff             60.0000       61.8041 18542058    3.01%&#xA;      10597  3003        cutoff             60.0000       61.7965 18672270    2.99%&#xA;      10637  2957       61.0000  1077       60.0000       61.7965 18584630    2.99%&#xA;      10671  2887       61.0000   967       60.0000       61.7965 18183141    2.99%&#xA;      10691  2883       61.0000   880       60.0000       61.7965 18207587    2.99%&#xA;      10727  2892       61.2927  1416       60.0000       61.7965 18231150    2.99%&#xA;    Elapsed time = 4873.31 sec. (3146013.14 ticks, tree = 73.37 MB, solutions = 2)&#xA;      10774  3047        cutoff             60.0000       61.7760 19014444    2.96%&#xA;      10826  2963        cutoff             60.0000       61.7760 18665600    2.96%&#xA;      10845  3013       61.5000  1202       60.0000       61.7701 18746676    2.95%&#xA;      10862  3054       61.0000  1081       60.0000       61.7701 18883472    2.95%&#xA;      10904  3069       61.0000   861       60.0000       61.7701 19268861    2.95%&#xA;      10949  3052       61.0000  1054       60.0000       61.7701 18921892    2.95%&#xA;      10980  3059       61.3111  1383       60.0000       61.7701 18940213    2.95%&#xA;      11001  3063       61.0000   848       60.0000       61.7701 19043353    2.95%&#xA;      11038  3073       61.0000   944       60.0000       61.7654 19067069    2.94%&#xA;      11059  3058       61.0000  1304       60.0000       61.7654 18971160    2.94%&#xA;    Elapsed time = 4933.79 sec. (3184940.39 ticks, tree = 76.15 MB, solutions = 2)&#xA;      11099  3079       61.0000  1048       60.0000       61.7654 18979024    2.94%&#xA;      11141  3078        cutoff             60.0000       61.7654 19001584    2.94%&#xA;      11181  3116       61.1591  1047       60.0000       61.7552 19553552    2.93%&#xA;      11211  3116       61.0000  1263       60.0000       61.7514 19559733    2.92%&#xA;      11246  3089       61.0000   779       60.0000       61.7514 19458460    2.92%&#xA;      11291  3132       61.4763  1437       60.0000       61.7514 19575665    2.92%&#xA;      11318  3130        cutoff             60.0000       61.7514 19597777    2.92%&#xA;      11357  3138    infeasible             60.0000       61.7514 19771799    2.92%&#xA;      11398  3141        cutoff             60.0000       61.7453 19780179    2.91%&#xA;      11451  3100    infeasible             60.0000       61.7453 19503913    2.91%&#xA;    Elapsed time = 4986.36 sec. (3224179.72 ticks, tree = 76.34 MB, solutions = 2)&#xA;      11509  3131        cutoff             60.0000       61.7453 19827301    2.91%&#xA;      11549  3162       61.1432  1142       60.0000       61.7360 19946929    2.89%&#xA;      11570  3129       61.0000   877       60.0000       61.7360 19663162    2.89%&#xA;      11634  3165       61.4550   983       60.0000       61.7360 19880048    2.89%&#xA;      11698  3166        cutoff             60.0000       61.7360 19902554    2.89%&#xA;      11734  3150       61.0000  1006       60.0000       61.7147 20159523    2.86%&#xA;      11790  3145    infeasible             60.0000       61.7147 20061632    2.86%&#xA;      11854  3165    infeasible             60.0000       61.7147 19948884    2.86%&#xA;      11893  3187    infeasible             60.0000       61.7147 20215485    2.86%&#xA;      11944  3183       61.4327  1461       60.0000       61.7147 20236691    2.86%&#xA;    Elapsed time = 5042.58 sec. (3262981.88 ticks, tree = 78.15 MB, solutions = 2)&#xA;      11977  3147       61.5000  1015       60.0000       61.7147 20121081    2.86%&#xA;      12027  3184        cutoff             60.0000       61.7066 20277701    2.84%&#xA;      12083  3176        cutoff             60.0000       61.7066 20300601    2.84%&#xA;      12124  3161       61.5000  1002       60.0000       61.6967 20771814    2.83%&#xA;      12154  3148       61.3691  1151       60.0000       61.6967 20381973    2.83%&#xA;      12194  3158    infeasible             60.0000       61.6967 20580807    2.83%&#xA;      12250  3150       61.0000  1240       60.0000       61.6919 20842945    2.82%&#xA;      12303  3141        cutoff             60.0000       61.6919 20449019    2.82%&#xA;      12364  3197        cutoff             60.0000       61.6835 21017417    2.81%&#xA;      12387  3206       61.0000  1339       60.0000       61.6835 21154927    2.81%&#xA;    Elapsed time = 5103.26 sec. (3302444.71 ticks, tree = 78.19 MB, solutions = 2)&#xA;      12437  3221    infeasible             60.0000       61.6835 21175005    2.81%&#xA;      12476  3221       61.0000   988       60.0000       61.6835 21199639    2.81%&#xA;      12508  3166    infeasible             60.0000       61.6835 20892100    2.81%&#xA;      12516  3162       61.0000  1108       60.0000       61.6835 20909465    2.81%&#xA;      12549  3186       61.0000  1307       60.0000       61.6667 21301906    2.78%&#xA;      12608  3158    infeasible             60.0000       61.6590 21568178    2.76%&#xA;      12698  3247       61.0000  1065       60.0000       61.6590 21277625    2.76%&#xA;      12755  3186    infeasible             60.0000       61.6590 21513465    2.76%&#xA;      12781  3181        cutoff             60.0000       61.6494 21535145    2.75%&#xA;      12844  3188       61.0000  1098       60.0000       61.6494 21381785    2.75%&#xA;    Elapsed time = 5168.29 sec. (3341418.56 ticks, tree = 76.25 MB, solutions = 2)&#xA;      12899  3201        cutoff             60.0000       61.6494 21784101    2.75%&#xA;      12936  3196        cutoff             60.0000       61.6321 21608725    2.72%&#xA;      12955  3197    infeasible             60.0000       61.6224 21811000    2.70%&#xA;      12980  3191       61.0000   677       60.0000       61.6224 21833958    2.70%&#xA;      13003  3165       61.0000   924       60.0000       61.6224 21638900    2.70%&#xA;      13026  3234       61.0000  1059       60.0000       61.6224 22075653    2.70%&#xA;      13065  3239        cutoff             60.0000       61.6224 22090956    2.70%&#xA;      13074  3210        cutoff             60.0000       61.6224 21909136    2.70%&#xA;      13115  3154    infeasible             60.0000       61.6224 21712230    2.70%&#xA;      13157  3232        cutoff             60.0000       61.6000 22137303    2.67%&#xA;    Elapsed time = 5227.01 sec. (3380933.18 ticks, tree = 75.92 MB, solutions = 2)&#xA;      13170  3225        cutoff             60.0000       61.6000 22153208    2.67%&#xA;      13183  3222       61.0000  1456       60.0000       61.6000 22164650    2.67%&#xA;      13206  3215       61.0000  1186       60.0000       61.6000 22296707    2.67%&#xA;      13237  3165       61.0000   987       60.0000       61.6000 22394542    2.67%&#xA;      13270  3127        cutoff             60.0000       61.5568 22670998    2.59%&#xA;      13302  3213        cutoff             60.0000       61.5568 22348758    2.59%&#xA;      13319  3116       61.0000  1003       60.0000       61.5568 22700891    2.59%&#xA;      13350  3104    infeasible             60.0000       61.5568 22721876    2.59%&#xA;      13371  3082        cutoff             60.0000       61.5568 22789932    2.59%&#xA;      13400  3079        cutoff             60.0000       61.5191 22900534    2.53%&#xA;    Elapsed time = 5287.62 sec. (3422572.94 ticks, tree = 73.30 MB, solutions = 2)&#xA;      13416  3064        cutoff             60.0000       61.5000 22968687    2.50%&#xA;      13448  3079       61.0000  1175       60.0000       61.5000 22927242    2.50%&#xA;      13460  3074        cutoff             60.0000       61.5000 22940326    2.50%&#xA;      13471  3058        cutoff             60.0000       61.5000 22994565    2.50%&#xA;      13495  3041        cutoff             60.0000       61.5000 23026843    2.50%&#xA;      13524  3047        cutoff             60.0000       61.5000 23023921    2.50%&#xA;      13561  2997        cutoff             60.0000       61.5000 23146081    2.50%&#xA;      13595  2979       61.0000   961       60.0000       61.5000 23194905    2.50%&#xA;      13635  2952    infeasible             60.0000       61.5000 23243440    2.50%&#xA;      13671  3026       61.0000  1011       60.0000       61.5000 23126969    2.50%&#xA;    Elapsed time = 5341.50 sec. (3461642.86 ticks, tree = 73.45 MB, solutions = 2)&#xA;      13685  2949       61.0000  1025       60.0000       61.5000 23284084    2.50%&#xA;      13702  2943        cutoff             60.0000       61.5000 23295585    2.50%&#xA;      13735  2951       61.0000   984       60.0000       61.5000 23274270    2.50%&#xA;      13745  3105       61.0000  1410       60.0000       61.5000 22804004    2.50%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In this case, the optimality gap is set to 2% and the optimization would have terminated earlier if the integrality of the objective function had been considered. I have seen this issue numerous times with more severe delays in the termination due to the solver not considering the integrality cuts. I could resolve this issue manually by introducing an auxiliary integer variable that captures the value of the original objective function in a constraint. However, I am wondering why this has not already been considered in modern solvers (perhaps it has, but it requires a certain configuration/implementation)?&lt;/p&gt;&#xA;" OwnerUserId="1202" LastEditorUserId="3391" LastEditDate="2020-12-03T04:46:42.990" LastActivityDate="2023-10-25T14:17:56.143" Title="Objective Integrality Cuts" Tags="|cplex|solver|gurobi|cutting-planes|presolve-preprocessing|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5332" PostTypeId="1" AcceptedAnswerId="5340" CreationDate="2020-12-03T07:15:25.447" Score="5" ViewCount="679" Body="&lt;p&gt;There's efficient algorithms for solving the 0-1 knapsack problems when the objective function is just a sum of profits. I am dealing with the following problem with non-linear objective function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{S \subseteq N}  \frac{\left( \sum_{k\in S} a_k \right) \cdot \left(\sum_{k\in S} b_k \right)}{1 + \sum_{k\in S} b_k}\;\;\; \text{subject to}\;\;\; \sum_{k\in S} w_k \leq C,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$a_i, b_i, w_i \geq 0 \;\; \forall \;\; i \in N. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I can transform this problem into the equivalent MILP formulation using CC transformation, but it cannot be solved in polynomial time if &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is large. Is there any technique or developed algorithm to solve this in polynomial time?&lt;/p&gt;&#xA;" OwnerUserId="3983" LastEditorUserId="500" LastEditDate="2020-12-04T13:57:34.903" LastActivityDate="2020-12-04T13:57:34.903" Title="0-1 knapsack with non-linear objective function" Tags="|optimization|combinatorial-optimization|knapsack|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5333" PostTypeId="2" ParentId="5330" CreationDate="2020-12-03T08:58:02.220" Score="1" Body="&lt;p&gt;First of all, if in the problem there is a specific precedence constraint for each job, let's say each job has its specific &lt;code&gt;route&lt;/code&gt;, your problem sounds like (flexible) job shop scheduling which is different from parallel scheduling problem. There are some ways to tackle this problem, e.g. using MIP, CP or (meta) heuristics methods. In the first case (MIP), as this problem is well known as a hard problem class, for the real world-class problems it takes a too long time to solve efficiently. CP or heuristic is an excellent way to do that. There are many resources that you can read by googling. Is it what you are looking for?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-12-03T08:58:02.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5334" PostTypeId="1" AcceptedAnswerId="5338" CreationDate="2020-12-03T16:53:09.227" Score="3" ViewCount="449" Body="&lt;p&gt;Consider an M/M/1 queue with arrival rate &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and service rate &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;, where participants renege after a random amount of time which follows an exponential distribution with mean &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt;. We neglect balking. Is there an expression for the steady-state probability that a participant receives service?&lt;/p&gt;&#xA;" OwnerUserId="358" LastEditorUserId="358" LastEditDate="2020-12-04T01:24:07.053" LastActivityDate="2020-12-04T15:10:23.483" Title="Service probability for M/M/1 queue with reneging" Tags="|queuing-theory|probability-theory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5336" PostTypeId="2" ParentId="5329" CreationDate="2020-12-03T22:15:57.443" Score="2" Body="&lt;p&gt;I can't say that I've ever done this -- my experience with iterative methods has largely been confined to cases where the master sequence converges to a single limit point -- but one possibility would be to run the algorithm long enough to generate a decent size sequence, sort the sequence (using lexicographic order if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; has dimension greater than 1), and then scan the sorted sequence for clusters of observations that are close together (perhaps by looking at L1 difference in consecutive observations). If you find such a cluster, one of those limit points would be nearby.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-12-03T22:15:57.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5337" PostTypeId="2" ParentId="5330" CreationDate="2020-12-03T22:30:48.423" Score="2" Body="&lt;p&gt;If you search for literature on job shop scheduling with &lt;em&gt;sequence-dependent setups&lt;/em&gt;, I think you will find what you want. As the phrase suggests, sequence-dependent setups refer to lost time and/or additional cost incurred during a transition of a machine from one job to another. Although setup times are typically viewed as separate from processing times, you could treat a processing time &lt;span class=&quot;math-container&quot;&gt;$t_{m,i,j}$&lt;/span&gt; as the sum of a base processing time &lt;span class=&quot;math-container&quot;&gt;$\tau_{m,j} = \min_i t_{m,i,j}$&lt;/span&gt; and a &amp;quot;setup&amp;quot; time &lt;span class=&quot;math-container&quot;&gt;$s_{m,i,j}=t_{m,i,j}-\tau_{m,j}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-12-03T22:30:48.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5338" PostTypeId="2" ParentId="5334" CreationDate="2020-12-04T01:22:51.657" Score="2" Body="&lt;p&gt;The steady-state probability of being served for an M/M/1 queue with exponential reneging times and no balking is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p_s=\frac{1+z}{1+r(1+z)}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$r=\lambda/\mu$&lt;/span&gt; is the service intensity, and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z=\exp(r\mu\tau)\cdot(r\mu\tau)^{-\mu\tau}\cdot\gamma(\mu\tau+1,r\mu\tau).&#xA;$$&lt;/span&gt;&#xA;Here, &lt;span class=&quot;math-container&quot;&gt;$\gamma(x,a)$&lt;/span&gt; is the &lt;em&gt;unscaled&lt;/em&gt; lower incomplete gamma function:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\gamma(s,x)=\int_0^x t^{s-1}\exp(-t)\;\mathrm{d}t.&#xA;$$&lt;/span&gt;&#xA;This result was originally given by &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1002/nav.3800100112&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ancker and Cafarian in 1963&lt;/a&gt; (paywall)&lt;sup&gt;[1]&lt;/sup&gt;. The equivalent formula for multiple heterogeneous servers can be found in &lt;a href=&quot;https://apps.dtic.mil/dtic/tr/fulltext/u2/a444342.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Section 3 here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt;[1] Ancker, C.J., &amp;amp; Cafarian, A.V. 1963. Queuing with reneging and multiple heterogeneous servers, &lt;em&gt;Naval Research Logistics Quarterly&lt;/em&gt;, Vol 10, No 1, 125–149. DOI: 10.1002/nav.3800100112 &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="358" LastEditorUserId="491" LastEditDate="2020-12-04T15:10:23.483" LastActivityDate="2020-12-04T15:10:23.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5339" PostTypeId="1" AcceptedAnswerId="5341" CreationDate="2020-12-04T03:33:34.200" Score="6" ViewCount="444" Body="&lt;p&gt;&amp;quot;It is a well-known result in network flow theory that an extreme point and an extreme ray of the polyhedron defined by the convex hull of feasible region corresponds to a path and cycle (resp.) in the network.&amp;quot; I see this statement everywhere but could not find the proof. Is there any reference proving the result? I want to use the proof to understand the polyhedral structure of the stochastic shortest path problem. In case of the stochastic shortest path problem, does an extreme point represent subgraph instead of just a path?&lt;/p&gt;&#xA;" OwnerUserId="2424" LastEditorUserId="354" LastEditDate="2020-12-04T10:17:27.857" LastActivityDate="2020-12-04T10:17:27.857" Title="Extreme point and extreme ray of a network flow problem" Tags="|optimization|network-flow|polyhedra|extreme-rays|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5340" PostTypeId="2" ParentId="5332" CreationDate="2020-12-04T05:06:57.953" Score="7" Body="&lt;p&gt;Even though knapsack problems are relatively easy to solve in practice, there does not exist a polynomial-time algorithm to solve even the standard knapsack problem, unless &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}=\mathcal{NP}$&lt;/span&gt;. The knapsack problem can be solved in &lt;em&gt;pseudo-polynomial&lt;/em&gt; time &lt;span class=&quot;math-container&quot;&gt;$\mathcal{O}(nC)$&lt;/span&gt;. Even when the input length (=number of digits describing the problem) is small, the actual number &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; may be large (e.g., I only need six digits to write the number 999,999), which is why the complexity is not polynomial.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; be the number of items, and let &lt;span class=&quot;math-container&quot;&gt;$B = \sum_{k\in N} b_k$&lt;/span&gt;. Then I think you can solve your problem in pseudo-polynomial time &lt;span class=&quot;math-container&quot;&gt;$\mathcal{O}(nCB^2)$&lt;/span&gt; as follows:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Add the constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{k \in S} b_k = D$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$D \in \{0,\dots,B\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The factor &lt;span class=&quot;math-container&quot;&gt;$\frac{\sum_{k\in S} b_k }{1 + \sum_{k\in S} b_k}$&lt;/span&gt; is now a constant and can be removed from the objective. What remains is a multidimensional knapsack problem in dimension two, with one inequality and one equality constraint.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Solve the problem with dynamic programming. Let &lt;span class=&quot;math-container&quot;&gt;$f_D(k,c,d)$&lt;/span&gt; be the best objective value obtainable after processing the first &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; items, with a total weight less than or equal to &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and for which the current sum of the &lt;span class=&quot;math-container&quot;&gt;$b_k$&lt;/span&gt; weights is exactly &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;. To calculate the value of &lt;span class=&quot;math-container&quot;&gt;$f_D(k,c,d)$&lt;/span&gt; you pick the best of two options&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Not selecting item &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, which gives you objective &lt;span class=&quot;math-container&quot;&gt;$f_D(k-1,c,d)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Or selecting item &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, which gives you objective &lt;span class=&quot;math-container&quot;&gt;$f_D(k-1,c-w_k,d-b_k)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Record the optimal solution for &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;, given by &lt;span class=&quot;math-container&quot;&gt;$f_D(n, C, D)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Repeat 1-4 for all possible values of &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; and compare the solutions to select the best one.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;For a given &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;, the dynamic program calculates &lt;span class=&quot;math-container&quot;&gt;$\mathcal{O}(nCB)$&lt;/span&gt; values, each in constant time. Repeating this for all &lt;span class=&quot;math-container&quot;&gt;$D\in \{0,\dots,B\}$&lt;/span&gt; and comparing the outcomes puts the complexity in &lt;span class=&quot;math-container&quot;&gt;$\mathcal{O}(nCB^2)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It should be noted that the multi-dimensional knapsack problem is significantly more difficult than the standard knapsack problem. For example, knapsack allows for a FPTAS, while the multi-dimensional knapsack does not, even in dimension two. Dynamic programming is not necessarily the best approach in practice. &lt;a href=&quot;http://doi.org/10.1007/978-3-540-24777-7&quot; rel=&quot;noreferrer&quot;&gt;This Knapsack Problems book&lt;/a&gt; discusses both dynamic programming and other approaches in detail. Finally, a direct method for non-linear knapsack may be better than fixing &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; and solving the remainder, as I showed here.&lt;/p&gt;&#xA;" OwnerUserId="145" LastActivityDate="2020-12-04T05:06:57.953" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5341" PostTypeId="2" ParentId="5339" CreationDate="2020-12-04T07:14:47.040" Score="6" Body="&lt;p&gt;I believe this result (with proof) is contained in the text book &amp;quot;Network Flows&amp;quot; by Ahuja, Magnati and Orlin.&lt;/p&gt;&#xA;&lt;p&gt;In particular, chapter 11 is on the Network Simplex algorithm and Theorems 11.2 and 11.3 are about optimal solutions in the form of spanning trees. The proofs use the structure of the dual solutions, and also use previous results, so it's not easy to reproduce here.&lt;/p&gt;&#xA;&lt;p&gt;Knowing that solutions with MST structure exist, it should be possible to show that other solutions can be built as combinations of these (and cycles).&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2020-12-04T07:14:47.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5342" PostTypeId="2" ParentId="5325" CreationDate="2020-12-04T10:23:52.123" Score="3" Body="&lt;p&gt;I believe the answer to your question is principally &amp;quot;no.&amp;quot; You mention these implementations, and there are some more, like porta or polymake, but in principle, this is an enormously resource-consuming enumeration, and the list of facets will be very long, maybe too long.&lt;/p&gt;&#xA;&lt;p&gt;Yet, it may depend on your use case. In optimization practice, you almost never need access to all the facets explicitly, but an implicit access suffices. When you can separate a violated inequality, you may still get all the info you &amp;quot;need.&amp;quot; from a computational standpoint.&lt;/p&gt;&#xA;&lt;p&gt;When you are more into theory and really want to &lt;strong&gt;see&lt;/strong&gt; all the facets, then you will consider small instances/polyhedra anyway (mainly to get an intution to prove something), and then the packages you list are (I think) the way to go.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2020-12-04T10:23:52.123" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5343" PostTypeId="2" ParentId="5331" CreationDate="2020-12-04T10:45:39.090" Score="4" Body="&lt;p&gt;AFAIK Lindo &lt;a href=&quot;http://cepac.cheme.cmu.edu/pasi2011/library/maravelias/Atamturk.2005.AOR.IPSoftwareSystems.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;have implemented&lt;/a&gt; objective integrality cuts, but I don't know the details of the implementation. It's always a trade-off that depends on what type of problems a solver's users solve more frequently.&lt;/p&gt;&#xA;&lt;p&gt;We don't use them in &lt;a href=&quot;https://octeract.com/octeract-engine/&quot; rel=&quot;nofollow noreferrer&quot;&gt;our solver&lt;/a&gt; because the slowdown we experience from the sheer number of constraints that must be added to impose integrality slows down the solving process overall, especially for pure integer (i.e. not binary) variables.&lt;/p&gt;&#xA;&lt;p&gt;The other reason we avoid them is that they can be numerically unstable: say the relaxation has a value of 62.0001, should the cuts enforce rounding up to 63, or is this a numerical artifact? It is very hard to control this, especially for large problems where accumulation of error is significant. I have seen problems where the correct answer could go either way. All we need is to get unlucky on a single node of the branch and bound tree, and then we've missed the global solution.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-12-04T11:47:23.953" LastActivityDate="2020-12-04T11:47:23.953" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5344" PostTypeId="2" ParentId="5331" CreationDate="2020-12-04T12:41:22.997" Score="7" Body="&lt;p&gt;I am not familiar with objective integrality cuts, but I know that CPLEX has the option to set the parameter &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/ObjDif.html&quot; rel=&quot;noreferrer&quot;&gt;absolute objective difference cutoff&lt;/a&gt;. If you set this parameter to 1, CPLEX will terminate the search if the difference between the best integer solution and the best bound is strictly less than 1.&lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2020-12-04T12:41:22.997" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5345" PostTypeId="1" CreationDate="2020-12-04T17:35:55.393" Score="2" ViewCount="93" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is a vector of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; complex elements.&#xA;&lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is a binary variable&lt;/p&gt;&#xA;&lt;p&gt;The requirements are:&#xA;when &lt;span class=&quot;math-container&quot;&gt;$D==1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$L_{\min}\le ||W||_2^2\le L_{\max}$&lt;/span&gt;&#xA;and when &lt;span class=&quot;math-container&quot;&gt;$D==0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$||W||_2^2=0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have formulated the following constraints to fulfill the requirements&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$||W||_2^2\ge 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$||W||_2^2\le L_{\max}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$||W||_2^2\le DL_{\max}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$||W||_2^2\ge DL_{\min}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Using programming language&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; norm(W)&amp;gt;= 0&#xA; norm(W)&amp;lt;=sqrt(Lmax)&#xA; norm(W)&amp;lt;=D*sqrt(Lmax)&#xA; norm(W)&amp;gt;=D*sqrt(Lmin)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;norm is a convex function. Is convex&amp;gt;=0 a valid model?&lt;/p&gt;&#xA;&lt;p&gt;Have I modeled them correctly?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="2477" LastEditDate="2020-12-04T21:23:47.037" LastActivityDate="2020-12-04T21:23:47.037" Title="How to model these constraints correctly" Tags="|modeling|constraint|linearization|convex-optimization|disciplined-convex-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5346" PostTypeId="2" ParentId="5345" CreationDate="2020-12-04T18:46:37.390" Score="4" Body="&lt;p&gt;The first and second constraints can be omitted.  The third and fourth constraints are sufficient, as you can see by considering both cases for &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2020-12-04T18:57:13.723" LastActivityDate="2020-12-04T18:57:13.723" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5347" PostTypeId="2" ParentId="5307" CreationDate="2020-12-05T13:40:24.897" Score="4" Body="&lt;p&gt;I think that there might be a straightforward approach here that requires only solving a linear program.&lt;/p&gt;&#xA;&lt;p&gt;Consider the LP arc-flow formulation of multi-commodity network flow; I won't repeat it here since it is very well known. The solution is expressed by flow variables &lt;span class=&quot;math-container&quot;&gt;$x^b_{ij}$&lt;/span&gt;, the flow of commodity &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; on network directed arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;. Based on your description, each commodity &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; has a single origin and destination. Thus, for each &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, the arcs &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x^b_{ij}&amp;gt;0$&lt;/span&gt; are such that one or more paths from &lt;span class=&quot;math-container&quot;&gt;$orig(b)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$dest(b)$&lt;/span&gt; exist using only those arcs. Call this set of arcs &lt;span class=&quot;math-container&quot;&gt;$A(b)$&lt;/span&gt;. Now consider the idea of &lt;em&gt;flow decomposition into paths&lt;/em&gt; for each commodity &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; given a feasible multi-commodity flow solution; this is a well-known concept in network flows. The idea essentially is that you can sequentially find unique paths &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$orig(b)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$dest(b)$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$A(b)$&lt;/span&gt; and assign a &lt;em&gt;path flow&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$x^b_p$&lt;/span&gt; equal to the minimum (remaining) flow &lt;span class=&quot;math-container&quot;&gt;$x^b_{ij}$&lt;/span&gt; for all arcs &lt;span class=&quot;math-container&quot;&gt;$(i,j) \in p$&lt;/span&gt;. You then remove this flow from all arcs and repeat until you have assigned all commodity &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; flow to paths.&lt;/p&gt;&#xA;&lt;p&gt;In my view, you have now solved your problem! For each commodity &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, each path flow &lt;span class=&quot;math-container&quot;&gt;$x^b_p$&lt;/span&gt; represents a single order (in your terminology). The value of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; then is simply the maximum number of path flows you find for any commodity. Note that you could modify this approach even if you had a maximum size per order.&lt;/p&gt;&#xA;" OwnerUserId="105" LastActivityDate="2020-12-05T13:40:24.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5348" PostTypeId="1" CreationDate="2020-12-05T15:32:31.483" Score="2" ViewCount="236" Body="&lt;p&gt;I'm solving a network optimization problem which is modeled as a graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt;. Solving this problem using &lt;strong&gt;Pulp&lt;/strong&gt; and &lt;strong&gt;NetworkX&lt;/strong&gt; in Python and ordering the graph's nodes in a certain order (i.e. &lt;strong&gt;(1,2,3,4,5)&lt;/strong&gt;) gives a certain optimal solution. However, changing the order of the nodes (i.e.,&lt;strong&gt;(3,4,1,2,5)&lt;/strong&gt;) may lead to another optimal solution.&#xA;&lt;strong&gt;Is there a metric for nodes that can order the nodes to provide the best optimal solution/s instead of going through the whole possible orders?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4347" LastActivityDate="2020-12-05T15:32:31.483" Title="Node ordering in Graph optimization" Tags="|optimization|graphs|cplex-python-api|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5349" PostTypeId="1" CreationDate="2020-12-05T15:37:34.180" Score="-2" ViewCount="187" Body="&lt;p&gt;In this problem, &lt;span class=&quot;math-container&quot;&gt;$\beta_u$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w_{u,c}$&lt;/span&gt; (a vector of complex elements), &lt;span class=&quot;math-container&quot;&gt;$x_u$&lt;/span&gt; are optimization variables.&lt;/p&gt;&#xA;&lt;p&gt;Now,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$||2\sqrt{\frac{\pi_u}{2}}\beta_u; h_{u,c}^{\rm H}w_{u,c}-\frac{1}{2\pi_u}x_u-1||_2\le h_{u,c}^{\rm H}w_{u,c}-\frac{1}{2\pi_u}x_u-1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is a valid convex constraint, hyperbolic constraint. Here &lt;span class=&quot;math-container&quot;&gt;$h_{u,c}^{\rm H}w_{u,c}$&lt;/span&gt; came for the original expression, &lt;span class=&quot;math-container&quot;&gt;$\sqrt{|h_{u,c}^{\rm H}w_{u,c}|^2}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, in my problem, instead of &lt;span class=&quot;math-container&quot;&gt;$\sqrt{|h_{u,c}^{\rm H}w_{u,c}|^2}$&lt;/span&gt;, I have&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sqrt{\sum_{c=1}^{C}|h_{u,c}^{\rm H}w_{u,c}|^2}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textbf{How can I put in the form of hyperbolic constraint as above?}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$||2\sqrt{\frac{\pi_u}{2}}\beta_u; \sqrt{\sum_{c=1}^{C}|h_{u,c}^{\rm H}w_{u,c}|^2}-\frac{1}{2\pi_u}x_u-1||_2\le \sqrt{\sum_{c=1}^{C}|h_{u,c}^{\rm H}w_{u,c}|^2}-\frac{1}{2\pi_u}x_u-1$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2020-12-05T16:31:48.903" LastActivityDate="2020-12-10T08:39:58.330" Title="How can I model this Hyperbolic constraint?" Tags="|linear-programming|convex-optimization|disciplined-convex-programming|conic-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5350" PostTypeId="1" AcceptedAnswerId="5351" CreationDate="2020-12-05T20:14:04.523" Score="3" ViewCount="986" Body="&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assign 11 projects to 11 students, based on their preference.&lt;/p&gt;&#xA;&lt;p&gt;For this example, each students chooses only one project, for simplicity shake (as shown below). Student 1 one chooses project 1, students 2 chooses project 2 etc. Obviously there is a feasible solution!&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;students/projects       1 2 3 4 5 6 7 8 9 10 11&#xA;                    1   9 0 0 0 0 0 0 0 0 0 0&#xA;                    2   0 9 0 0 0 0 0 0 0 0 0&#xA;                    3   0 0 9 0 0 0 0 0 0 0 0&#xA;                    4   0 0 0 9 0 0 0 0 0 0 0&#xA;                    5   0 0 0 0 9 0 0 0 0 0 0&#xA;                    6   0 0 0 0 0 9 0 0 0 0 0&#xA;                    7   0 0 0 0 0 0 9 0 0 0 0&#xA;                    8   0 0 0 0 0 0 0 9 0 0 0&#xA;                    9   0 0 0 0 0 0 0 0 9 0 0&#xA;                    10  0 0 0 0 0 0 0 0 0 9 0&#xA;                    11  0 0 0 0 0 0 0 0 0 0 9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The problem is that glpk does not find it! I'll demonstrate the modeling of the problem and the code below.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;&lt;strong&gt;Modeling&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is a maxmin problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Decision Variables&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA;  x_{ij} =\left\{&#xA;  \begin{array}{@{}ll@{}}&#xA;0, &amp;amp; \text{project j not assigned to student i}\\\&#xA;1, &amp;amp; \text{otherwise}&#xA;  \end{array}\right.&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{ij}:$&lt;/span&gt; The &amp;quot;profit&amp;quot; of assigning project &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to student &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;: The minimum profit on bilateral matching&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Constraints&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Every project is assigned to only one student: &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{11} x_{ij} = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Each student gets only one problem: &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^{11} x_{ij} = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assign a project to a student, only if her chose it (upper bound): &lt;span class=&quot;math-container&quot;&gt;$P \leq x_{ij} \cdot p_{ij} + A \cdot (1-x_{ij})$&lt;/span&gt; (Where A is a big constant)&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Objective Function&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Maximize P&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;GLPK code&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/* number of students */&#xA;param m, integer, &amp;gt; 0;&#xA;&#xA;/* number of projects */&#xA;param n, integer, &amp;gt; 0;&#xA;&#xA;/* set of students */&#xA;set I := 1..m;&#xA;&#xA;/* set of projects */&#xA;set J := 1..n;&#xA;&#xA;/* profit of allocating project j to student i */&#xA;param p{i in I, j in J}, &amp;gt;= 0;&#xA;&#xA;/* Binary assignment variable */&#xA;var x{i in I, j in J}, = 0;&#xA;&#xA;/* Minimum profit of allocating project j to student i */&#xA;var P, &amp;gt;= 0; &#xA;&#xA;/* each student must perform exactly one project */&#xA;s.t. con1{i in I}: sum{j in J} x[i,j] = 1;&#xA;&#xA;/* each project must be assigned exactly to one student */&#xA;s.t. con2{j in J}: sum{i in I} x[i,j] = 1;&#xA;&#xA;/* Upper bound */&#xA;s.t. con3{j in J, i in I}: P &amp;lt;=  x[i,j] * p[i,j]  + 9999999 * (1 - x[i,j]);  &#xA;&#xA;maximize obj: P;&#xA;&#xA;solve;&#xA;&#xA;printf &amp;quot;\n&amp;quot;;&#xA;printf &amp;quot;student  project       profit\n&amp;quot;;&#xA;printf{i in I} &amp;quot;%5d %5d %10g\n&amp;quot;, i, sum{j in J} j * x[i,j],&#xA;   sum{j in J} p[i,j] * x[i,j];&#xA;printf &amp;quot;----------------------\n&amp;quot;;&#xA;printf &amp;quot;     Total: %10g\n&amp;quot;, sum{i in I, j in J} p[i,j] * x[i,j];&#xA;printf &amp;quot;\n&amp;quot;;&#xA;&#xA;data;&#xA;&#xA;param m := 11;&#xA;&#xA;param n := 11;&#xA;&#xA;param p : 1 2 3 4 5 6 7 8 9 10 11:=&#xA;      1   9 0 0 0 0 0 0 0 0 0 0&#xA;      2   0 9 0 0 0 0 0 0 0 0 0&#xA;      3   0 0 9 0 0 0 0 0 0 0 0&#xA;      4   0 0 0 9 0 0 0 0 0 0 0&#xA;      5   0 0 0 0 9 0 0 0 0 0 0&#xA;      6   0 0 0 0 0 9 0 0 0 0 0&#xA;      7   0 0 0 0 0 0 9 0 0 0 0&#xA;      8   0 0 0 0 0 0 0 9 0 0 0&#xA;      9   0 0 0 0 0 0 0 0 9 0 0&#xA;      10  0 0 0 0 0 0 0 0 0 9 0&#xA;      11  0 0 0 0 0 0 0 0 0 0 9 ;&#xA;end;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;The question&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;GLPK doesn't seem to find a solution. But there is obviously one. What went wrong?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;user@ubuntu:~$ glpsol -m assign.mod &#xA;GLPSOL: GLPK LP/MIP Solver, v4.65&#xA;Parameter(s) specified in the command line:&#xA; -m assign.mod&#xA;Reading model section from assign.mod...&#xA;Reading data section from assign.mod...&#xA;61 lines were read&#xA;Generating con1...&#xA;Generating con2...&#xA;Generating con3...&#xA;Generating obj...&#xA;Model has been successfully generated&#xA;GLPK Simplex Optimizer, v4.65&#xA;144 rows, 122 columns, 485 non-zeros&#xA;Preprocessing...&#xA;PROBLEM HAS NO PRIMAL FEASIBLE SOLUTION&#xA;Time used:   0.0 secs&#xA;Memory used: 0.3 Mb (295915 bytes)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;P.S: I know this can be easily solved with Hungarian algorithm. But using hungarian I cannot add the P constraint, where I ask the program to assign a project to a student only if he chose it.&lt;/p&gt;&#xA;" OwnerUserId="4552" LastActivityDate="2020-12-05T20:24:39.770" Title="Simplex (GLPK) doesn't find a feasible solution on this simple assignment problem, but there is an obvious one" Tags="|optimization|mixed-integer-programming|simplex|assignment-problem|feasible-points|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5351" PostTypeId="2" ParentId="5350" CreationDate="2020-12-05T20:24:39.770" Score="8" Body="&lt;p&gt;Maybe the unnecessarily large value for &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is causing numerical trouble.  Try instead &lt;span class=&quot;math-container&quot;&gt;$A = \max_{i,j} p_{i,j} = 9$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Probably your &lt;span class=&quot;math-container&quot;&gt;$=0$&lt;/span&gt; in the declaration of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; should be &lt;span class=&quot;math-container&quot;&gt;$\ge 0$&lt;/span&gt;.  In fact, you generally need to declare &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to be binary when you include side constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-12-05T20:24:39.770" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5353" PostTypeId="1" CreationDate="2020-12-06T00:06:42.217" Score="3" ViewCount="192" Body="&lt;p&gt;Lately, I have been working on a CP-SAT model for solving multi-resource flexible job shop problems.&lt;/p&gt;&#xA;&lt;p&gt;I used the code (1) as an inspiration for building code (2) in Python which works well. Then I had to recode (2) in C# which gave me code (3).&lt;/p&gt;&#xA;&lt;p&gt;When I feed same data set in 2 and 3 I get different results and I have very hard time explaining it to me. It could definitely be my code but I spend the whole afternoon without finding the mistake.&lt;/p&gt;&#xA;&lt;p&gt;(1) &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/python/flexible_job_shop_sat.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/examples/python/flexible_job_shop_sat.py&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;(2) &lt;a href=&quot;https://github.com/ozizi1/MultiResourceFJSP/blob/master/Python_MR-FJSP&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ozizi1/MultiResourceFJSP/blob/master/Python_MR-FJSP&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;(3) &lt;a href=&quot;https://github.com/ozizi1/MultiResourceFJSP/blob/master/Cs_MR-FJSP&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ozizi1/MultiResourceFJSP/blob/master/Cs_MR-FJSP&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Case :&#xA;&lt;a href=&quot;https://i.stack.imgur.com/aEMzu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aEMzu.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/5fXEi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5fXEi.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Following Laurent Perron's recommandation bellow I kept on looking and to me both models seem correct. They both try to minimize makespan and they both respect no overlap and precedence constraints in the results displayed.&lt;/p&gt;&#xA;&lt;p&gt;Once again this could be my model but I really don't see the issue.&lt;/p&gt;&#xA;&lt;p&gt;Another weird phenomena is that code 2 and 3 can choose same alternatives but give different objective values :&#xA;&lt;a href=&quot;https://i.stack.imgur.com/MX0zv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MX0zv.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you want to replicate this behaviour just change second's alternative lead time on github's code by 9 so that jobs start like : [[[[3, (0,1)],[9, (1,2)]...&lt;/p&gt;&#xA;&lt;p&gt;Also please notice the difference in wall times. If I didn't had to use WPF - MVVM design pattern I would have stuck to Python.&lt;/p&gt;&#xA;&lt;p&gt;If you have any idea where this is coming from please let me know.&lt;/p&gt;&#xA;" OwnerUserId="4145" LastEditorUserId="981" LastEditDate="2023-12-22T15:13:12.773" LastActivityDate="2023-12-22T15:13:12.773" Title="Google OR returning different values depending on language" Tags="|python|or-tools|cp-sat|c#|" AnswerCount="2" CommentCount="11" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5354" PostTypeId="2" ParentId="5353" CreationDate="2020-12-06T10:14:51.750" Score="2" Body="&lt;p&gt;Running the C# version with or-tools master&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;/usr/local/share/dotnet/dotnet&amp;quot; run --no-build  --project examples/tests/wrong_solution_flex_sat.csproj&#xA;[[[[3, (0, 1)],[1, (1, 2)],[5, (2, 3)]],[[2, (3, 4)], [4, (1, 2)], [6, (2, 3)]], [[2, (0, 1)], [3, (1, 2)], [1, (2, 3)]]],[[[2, (0, 1)], [3, (1, 2)], [4, (2, 3)]], [[1, (0, 1)], [5, (1, 2)], [4, (2, 3)]], [[2, (0, 1)], [1, (1, 2)], [4, (2, 3)]]],[[[2, (0, 1)], [1, (1, 2)], [4, (2, 3)]], [[2, (0, 1)], [3, (1, 2)], [4, (2)]], [[3, (0, 1)]]]]&#xA;38&#xA;Objective value: { &amp;quot;status&amp;quot;: &amp;quot;OPTIMAL&amp;quot;, &amp;quot;solution&amp;quot;: [ &amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;5&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;6&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;9&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;5&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;9&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;5&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;9&amp;quot; ], &amp;quot;objectiveValue&amp;quot;: 9, &amp;quot;bestObjectiveBound&amp;quot;: 9, &amp;quot;numBooleans&amp;quot;: &amp;quot;64&amp;quot;, &amp;quot;numConflicts&amp;quot;: &amp;quot;25&amp;quot;, &amp;quot;numBranches&amp;quot;: &amp;quot;176&amp;quot;, &amp;quot;numBinaryPropagations&amp;quot;: &amp;quot;1045&amp;quot;, &amp;quot;numIntegerPropagations&amp;quot;: &amp;quot;2769&amp;quot;, &amp;quot;wallTime&amp;quot;: 0.007670000000000001, &amp;quot;userTime&amp;quot;: 0.007671000000000001, &amp;quot;deterministicTime&amp;quot;: 0.00020175300000000072, &amp;quot;numRestarts&amp;quot;: &amp;quot;103&amp;quot; }&#xA;Solution: Optimal&#xA;Objective value: 9&#xA;Job1-task1-Alt2&#xA;Job1-task2-Alt1&#xA;Job1-task3-Alt3&#xA;Job2-task1-Alt3&#xA;Job2-task2-Alt1&#xA;Job2-task3-Alt2&#xA;Job3-task1-Alt2&#xA;Job3-task2-Alt1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Running the python version&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Horizon = 42&#xA;Solution 0, time = 0.004693 s, objective = 22&#xA;Solution 1, time = 0.005145 s, objective = 19&#xA;Solution 2, time = 0.005526 s, objective = 12&#xA;Solution 3, time = 0.006028 s, objective = 11&#xA;Solution 4, time = 0.006320 s, objective = 10&#xA;Solution 5, time = 0.006531 s, objective = 9&#xA;Job 1:&#xA;  task_1_1 starts at 1 - ends at 6 (alt 3, resources : 2,3, duration 5)&#xA;  task_1_2 starts at 6 - ends at 8 (alt 1, resources : 3,4, duration 2)&#xA;  task_1_3 starts at 8 - ends at 9 (alt 3, resources : 2,3, duration 1)&#xA;Job 2:&#xA;  task_2_1 starts at 1 - ends at 3 (alt 1, resources : 0,1, duration 2)&#xA;  task_2_2 starts at 3 - ends at 4 (alt 1, resources : 0,1, duration 1)&#xA;  task_2_3 starts at 6 - ends at 7 (alt 2, resources : 1,2, duration 1)&#xA;Job 3:&#xA;  task_3_1 starts at 0 - ends at 1 (alt 2, resources : 1,2, duration 1)&#xA;  task_3_2 starts at 4 - ends at 6 (alt 1, resources : 0,1, duration 2)&#xA;  task_3_3 starts at 6 - ends at 9 (alt 1, resources : 0,1, duration 3)&#xA;Solve status: OPTIMAL&#xA;Objective value: 9&#xA;Statistics&#xA;  - conflicts : 8&#xA;  - branches  : 214&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I get the same objective value.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2020-12-06T10:14:51.750" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5355" PostTypeId="1" CreationDate="2020-12-06T14:53:27.307" Score="-1" ViewCount="126" Body="&lt;p&gt;I am having trouble with my Problem Instances, which seem to be not &amp;quot;complicated&amp;quot; enough..&#xA;Is there a way to find out what the problem is? It is being solved in a matter of seconds even if the problem instance contains over 100 of periods...Although The solution seems reasonable&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WaEOw.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WaEOw.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I attach the .gms and the instance .inc files and the model description:&#xA;&lt;a href=&quot;https://seafile.rlp.net/d/a8d1fa91f43d429fa7f0/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://seafile.rlp.net/d/a8d1fa91f43d429fa7f0/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4380" LastActivityDate="2020-12-06T21:01:32.140" Title="GAMS CPLEX solver solves big problem instances suspiciously fast" Tags="|cplex|gams|test-instances|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5356" PostTypeId="2" ParentId="5353" CreationDate="2020-12-06T18:32:23.283" Score="1" Body="&lt;p&gt;1 constraint on 1 job wasn't applied on code 2 because sketchy implementation of a if statement.&lt;/p&gt;&#xA;&lt;p&gt;Fixed it and updated the code on GitHub for people who need smtg similar.&lt;/p&gt;&#xA;" OwnerUserId="4145" LastActivityDate="2020-12-06T18:32:23.283" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5357" PostTypeId="2" ParentId="5355" CreationDate="2020-12-06T21:01:32.140" Score="7" Body="&lt;p&gt;For a test problem, check manually (outside GAMS) that the solution satisfies all constraints. If not, your GAMS model may be wrong. If all constraints are satisfied, try using a different solver and see if the same objective value is achieved. If the other solver gets a better result, your current runs may be stopping short of optimality. If the objective values match, your problem is apparently easy (which is a good thing in the real world, perhaps not such a good thing in portions of academe).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-12-06T21:01:32.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5359" PostTypeId="1" AcceptedAnswerId="5362" CreationDate="2020-12-07T19:16:16.953" Score="8" ViewCount="661" Body="&lt;p&gt;I am looking for an algorithm that, given a set of linear inequalities in &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; variables, returns a simplified set. &amp;quot;Simplified&amp;quot; may mean an equivalent set with a smallest number of inequalities. If finding an optimal solution is computationally-hard, then a heuristic solution, that applies some reasonable simplification rules, would also be fine. As an example, given the inequalities:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x + y \geq 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x + y \leq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;the algorithm should return the empty set. Given the inequalities:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x + y \geq 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ 2 x + 2 y \geq 3$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;the algorithm should return e.g.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ 2 x + 2 y \geq 3$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A Google search for &amp;quot;simplifying linear inequalities&amp;quot; yielded graphical solutions for two variables, e.g. &lt;a href=&quot;https://www.universalclass.com/articles/math/algebra/solving-systems-of-linear-inequalities.htm&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://www.alamo.edu/contentassets/ab5b70d70f264cec9097745e8f30ca0a/systems/math0303-system-of-linear-inequalities.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. I am not looking for a graphical solution but for a logical solution in the form of a small set of equivalent inequalities.&lt;/p&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="2576" LastEditDate="2020-12-08T09:37:37.503" LastActivityDate="2021-01-08T14:41:16.880" Title="Algorithm for simplifying a set of linear inequalities" Tags="|linear-programming|reference-request|valid-inequalities|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5360" PostTypeId="2" ParentId="5359" CreationDate="2020-12-07T19:24:33.950" Score="6" Body="&lt;p&gt;It sounds like you want something along the lines of a (partial) presolve, which most commercial solvers implement.&lt;/p&gt;&#xA;&lt;p&gt;For example, Gurobi has a presolve accessible from the Python interface which should do what you want, and maybe more.&#xA;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360024738352-How-does-presolve-work-&quot; rel=&quot;noreferrer&quot;&gt;https://support.gurobi.com/hc/en-us/articles/360024738352-How-does-presolve-work-&lt;/a&gt;&#xA;I suppose you can provide a model just containing the desired variable declarations and inequalities.&lt;/p&gt;&#xA;&lt;p&gt;If you provide a model having redundant ineqqalities to a solver having presolve, it should by default execute its presolve as the first step of its solution process, without first requiring a separate call by the user to the presolve.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-12-07T19:24:33.950" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5361" PostTypeId="1" AcceptedAnswerId="5363" CreationDate="2020-12-07T21:37:34.657" Score="17" ViewCount="2515" Body="&lt;p&gt;As part of a final project for my linear programming course, I have been asked to discuss implementations of pivot algorithms, including which combinations of the ideas we have talked about in class this fall are actually used by available solvers today. Would someone be able to answer or point me to resources on the following questions?&lt;/p&gt;&#xA;&lt;p&gt;From my work so far with optimization solvers, I see primal and dual simplex seem to be the two pivot algorithms implemented. Do any commonly used solvers implement any others?&lt;/p&gt;&#xA;&lt;p&gt;I've learned in a previous LP course that revised simplex can greatly improve the efficiency of pivot calculations for LP's. Is revised simplex commonly used within today's solvers? If so, is there any specific variants of it that are most popular? If it isn't used, are there any other methods of calculating pivots employed?&lt;/p&gt;&#xA;&lt;p&gt;When it comes to deciding how to pivot, we have learned about least ratios and lexicographic minimums for picking new bases as well as Bland's rule for avoiding cycles. Are these concepts still relevant for today's solvers, and if so are there any specific variants that are most popular? If not, what other kinds of pivoting rules and cycle avoidance techniques are common?&lt;/p&gt;&#xA;&lt;p&gt;I know from my time working with OR scientists before grad school that my colleagues would talk about preprocessing as being a significant source of the improvements in which optimization models could be solved by solvers. What kinds of things are done for preprocessing and can any of them be done in general for all LP's? Is there anything in addition to preprocessing that solvers do outside of selecting and calculating pivots that help solve performance?&lt;/p&gt;&#xA;" OwnerUserId="342" LastEditorUserId="134" LastEditDate="2022-11-10T07:27:33.487" LastActivityDate="2022-11-10T07:27:33.487" Title="How Close Is Linear Programming Class to What Solvers Actually Implement for Pivot Algorithms" Tags="|linear-programming|solver|simplex|dual-simplex|primal-simplex|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5362" PostTypeId="2" ParentId="5359" CreationDate="2020-12-07T23:34:03.350" Score="10" Body="&lt;p&gt;What I'm about to suggest is less sophisticated than (and presumably less efficient than) the presolvers Mark L. Stone mentions, but would be relatively easy to implement (assuming you have an LP solver). It assumes that the variables are continuous, not discrete. For simplicity, I'll assume that all inequalities are of the form &lt;span class=&quot;math-container&quot;&gt;$a_i'x \ge b_i$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$i=1,\dots,N$&lt;/span&gt;). For each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in turn, minimize &lt;span class=&quot;math-container&quot;&gt;$a_i' x$&lt;/span&gt; subject to the other surviving inequalities. If the minimum is greater than or equal to &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;, inequality &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is redundant and is dropped. Otherwise, it is kept.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-12-07T23:34:03.350" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5363" PostTypeId="2" ParentId="5361" CreationDate="2020-12-08T03:10:33.540" Score="24" Body="&lt;p&gt;There was an excellent lecture by Bob Bixby in 2015 at the Zuse Institute Berlin (ZIB) as part of Combinatorial Optimization at Work 2015. Bixby founded CPLEX and Gurobi, 2 of the 3 leading commercial MILP+ solvers.&lt;/p&gt;&#xA;&lt;p&gt;The lecture is divided into 3 videos, and gives the actual nitty gritty about what makes LP  Simplex family solvers work effectively on large-scale problems. The lecture covers pricing, why dual Simplex is usually better than primal Simplex, and the advances made in efficiently doing sparse linear algebra in these algorithms. I think this will answer your questions.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=z1xvqwQR6xU&quot; rel=&quot;noreferrer&quot;&gt;Robert Bixby: Solving Linear Programs: The Dual Simplex Algorithm (1/3): Some Basic Theory&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=ZNf84y4M-Dw&quot; rel=&quot;noreferrer&quot;&gt;Robert Bixby: Solving Linear Programs: The Dual Simplex Algorithm (2/3): The Dual Simplex Algorithm&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=uccbVoamiUM&quot; rel=&quot;noreferrer&quot;&gt;Robert Bixby: Solving Linear Programs: The Dual Simplex Algorithm (3/3): Implementing the Algorith&lt;/a&gt;m&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-12-08T03:10:33.540" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5364" PostTypeId="2" ParentId="5361" CreationDate="2020-12-08T03:16:21.167" Score="13" Body="&lt;p&gt;One of the best resource I know is the series of lectures on linear programming that was part of the &lt;a href=&quot;https://co-at-work.zib.de/#about&quot; rel=&quot;noreferrer&quot;&gt;CO@work workshop 2020&lt;/a&gt;.&#xA;I especially recommend the lectures by Bob Bixby (he is the &amp;quot;bi&amp;quot; in &amp;quot;Gurobi&amp;quot;).&#xA;They are freely available &lt;a href=&quot;https://www.youtube.com/playlist?list=PLYWmzh0Y6EOYbrsKy1lyf9CSswLKkywY2&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, and you'll find some theoretical and practical viewpoints.&lt;/p&gt;&#xA;&lt;p&gt;As for presolving: it is fundamental for MIP, and very important even for LP.&#xA;In a nutshell, presolve removes elementary redundancies (like a constraint &lt;span class=&quot;math-container&quot;&gt;$x = 1$&lt;/span&gt; or duplicate variables), reduces problem size and improves numerics.&#xA;In this direction, you can have a look at the &amp;quot;Presolving&amp;quot; and &amp;quot;Learning to scale&amp;quot; lectures from CO@work.&#xA;If you are into academic papers, these two references pretty much cover LP presolve:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/BF01586000&quot; rel=&quot;noreferrer&quot;&gt;Andersen &amp;amp; Andersen, Presolving in linear programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.9.1.73&quot; rel=&quot;noreferrer&quot;&gt;Gondzio, Presolve analysis prior to applying an interior-point method&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2020-12-08T03:16:21.167" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5365" PostTypeId="1" CreationDate="2020-12-08T13:49:47.017" Score="0" ViewCount="140" Body="&lt;p&gt;I defined a complex variable in cvx, but I want to restrict the first element of the variable to be larger than the max of the variable, but it doesn't work. Someone told me to transform it using a binary variable, but I don't know how to do that?&#xA;The code is in matlab:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin quiet&#xA;variable wt(Mt-2) complex %variable&#xA;minimize(norm(cur_Qt*wt,1));&#xA;subject to&#xA;At_tar’*wt == 1;&#xA;abs(wt(1)) &amp;gt;= max(abs(wt))*0.0001; %%canstrain the first element of the variable&#xA;abs(wt(end)) &amp;gt;= max(abs(wt))*0.0001; %%canstrain the first element of the variable&#xA;for sl=1:length(sl_ind)&#xA;abs(Ats(:,sl)’*wt) &amp;lt;= 10^(desired_psll/20);&#xA;end&#xA;cvx_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The error is:&#xA;Disciplined convex programming error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   Invalid constraint: {convex} &amp;gt;= {convex}&#xA;&#xA;error  &amp;gt;=  (line 21)&#xA;b = newcnstr( evalin( 'caller', 'cvx_problem', '[]' ), x, y, '&amp;gt;=' );&#xA;&#xA;error hybrid_weight_location_minpsll (line 54)&#xA;            abs(wt(1)) &amp;gt;= max(abs(wt))*0.0001;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4564" LastEditorUserId="36" LastEditDate="2020-12-08T14:19:01.040" LastActivityDate="2020-12-10T08:55:12.263" Title="How to convert an element of a variable to a convex constraint using binary variables?" Tags="|convex-optimization|matlab|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5366" PostTypeId="1" AcceptedAnswerId="5371" CreationDate="2020-12-08T15:36:47.227" Score="2" ViewCount="149" Body="&lt;p&gt;I have the following statements for an MILP:&lt;/p&gt;&#xA;&lt;p&gt;Variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; (can be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;);&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\alpha_j$&lt;/span&gt; (real numbers with &lt;span class=&quot;math-container&quot;&gt;$0\le\alpha_j\le1$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I have a linear inequality system for &lt;span class=&quot;math-container&quot;&gt;$\alpha_j$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_jv_j\cdot\alpha_j = 0$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$v_j$&lt;/span&gt; constants)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\alpha_j = c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;and I have the following logic:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If there exists a solution for &lt;span class=&quot;math-container&quot;&gt;$c=1$&lt;/span&gt;, the formulation should be infeasible;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If there exists the &lt;strong&gt;only one&lt;/strong&gt; solution &lt;span class=&quot;math-container&quot;&gt;$c = 0$&lt;/span&gt; (each &lt;span class=&quot;math-container&quot;&gt;$\alpha_j$&lt;/span&gt; must be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;) the formulation should be feasible.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I need some more equations or changes so that the logic above holds. The background is the following. I want to test if a point (here &lt;span class=&quot;math-container&quot;&gt;$(0.0, 0.0, 0.0)$&lt;/span&gt;) is inside a polygon. The constants &lt;span class=&quot;math-container&quot;&gt;$v_j$&lt;/span&gt; are the vertices of the polygon. The above equations have to be set up for each spatial direction, here we only focus on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. If no solution can be found for &lt;span class=&quot;math-container&quot;&gt;$c = 1$&lt;/span&gt;, the point is outside. For my calculations I have to make sure that the point is outside.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;First idea:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;When I use an additional constraint &lt;span class=&quot;math-container&quot;&gt;$c = 1$&lt;/span&gt; the MILP finds a solution for &lt;span class=&quot;math-container&quot;&gt;$c = 1$&lt;/span&gt; und no solution for &lt;span class=&quot;math-container&quot;&gt;$c = 0$&lt;/span&gt;. This helps to identify if &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;  can be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; but this flips the feasible solution space since the solver breaks when &lt;span class=&quot;math-container&quot;&gt;$c = 0$&lt;/span&gt; which should be the feasible one. Adding the constraint &lt;span class=&quot;math-container&quot;&gt;$c = 0$&lt;/span&gt; will not help, since it is not enough that &lt;span class=&quot;math-container&quot;&gt;$c = 0$&lt;/span&gt; is one potential solution, it must be the only one valid solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Second idea:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;When I use the objective function &lt;code&gt;max(c)&lt;/code&gt; I can conclude that &lt;code&gt;IF max(c) = 1 THEN not feasible&lt;/code&gt; (or &lt;code&gt;IF max(c) = 0 THEN feasible&lt;/code&gt;). However I don't want to use &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; in the objective function.&lt;/p&gt;&#xA;&lt;p&gt;Is there any other possibility to change the formulation so that the logic above holds?&lt;/p&gt;&#xA;" OwnerUserId="4567" LastEditorUserId="123" LastEditDate="2020-12-08T19:41:28.543" LastActivityDate="2020-12-12T17:44:06.000" Title="Defining Solution Space in MILP / LP using If Then Statements" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5367" PostTypeId="2" ParentId="5361" CreationDate="2020-12-08T16:00:35.177" Score="12" Body="&lt;p&gt;The videos linked in the other answers contain some of what I will write here but both my writing and the videos are still only scratching on the surface of actual simplex implementations. I'll try to directly answer the questions here:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Dual simplex is the most important simplex algorithm right now (because of its performance when solving LPs and because of its warm starting capabilities in the context of mixed integer programming solvers and branch-and-cut). Network simplex can be a superior choice for instances where it applies. Crossover simplex is needed to get a basic solution from an IPM solver or any other method that returns a not necessarily basic solution to LPs. To the best of my knowledge no commercial solver uses a true criss-cross method (except maybe in the context of a phase 1).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The revised simplex is what is used but the important part are the details. A (hyper-) sparse LU Update method to solve the linear systems is very important for good performance, see the &lt;a href=&quot;https://digital.ub.uni-paderborn.de/hsmig/content/titleinfo/3885&quot; rel=&quot;noreferrer&quot;&gt;thesis by Achim Koberstein&lt;/a&gt; for some details on that. The thesis also contains information about the bound flipping ratio test (long step method) that was skipped in the Bixby-Videos and has some importance for dual simplex. The Harris ratio test is also very important for a fast and stable simplex implementation.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The pivoting rules typically discussed in class are not efficient in practice. As far as I can say all solvers use some form of (projected) steepest-edge pricing or approximations thereof (like DEVEX). Especially for dual simplex, steepest edge pricing, if implemented efficiently, is hard to beat.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As far as I can say all solvers use some form of perturbation to avoid cycling. There are many details to think about, but in the end its pretty much what Bixby says in his videos. Its not very fancy but works great.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Presolve (or preprocessing) is much more important for mixed integer programming solvers than for LP solvers. The basic techniques pointed out in references here are typically applied, but don't change the performance all that dramatically. That said, there are some techniques that can dramatically change how fast an instance is solved. Three things come directly to mind:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Removing dependent rows: mostly for IPMs and is done using a simplex type algorithm itself&lt;/li&gt;&#xA;&lt;li&gt;Dualizing the problem: if a problem has many more rows than columns, solve the dual.&lt;/li&gt;&#xA;&lt;li&gt;LP folding: removing a form of symmetry from LPs at the cost of potentially having to do a crossover at the end (Grohe et al., 2014:&#xA;&lt;a href=&quot;https://arxiv.org/abs/1307.5697&quot; rel=&quot;noreferrer&quot;&gt;Dimension Reduction via Colour Refinement&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="302" LastActivityDate="2020-12-08T16:00:35.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5369" PostTypeId="1" AcceptedAnswerId="5370" CreationDate="2020-12-08T17:30:06.823" Score="11" ViewCount="519" Body="&lt;p&gt;In this post &lt;a href=&quot;https://or.stackexchange.com/questions/4827/what-is-robust-optimization&quot;&gt;What is robust optimization?&lt;/a&gt; there is a nice introduction to robust optimization.&lt;/p&gt;&#xA;&lt;p&gt;There are many concept for uncertainty in optimization problems like&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;robust optimization&lt;/li&gt;&#xA;&lt;li&gt;stochastic optimization&lt;/li&gt;&#xA;&lt;li&gt;distributionally robust optimization&lt;/li&gt;&#xA;&lt;li&gt;adjustable robustness&lt;/li&gt;&#xA;&lt;li&gt;... and many more.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;How common are these concepts applied in real-life applications for optimization, and how are the uncertainty sets derived in a practical scenario?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="2477" LastEditDate="2020-12-08T18:00:28.907" LastActivityDate="2020-12-08T22:04:44.333" Title="How is optimization under uncertainty done in real world applications?" Tags="|stochastic-programming|robust-optimization|uncertainty|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5370" PostTypeId="2" ParentId="5369" CreationDate="2020-12-08T22:04:44.333" Score="10" Body="&lt;p&gt;The following is purely personal opinion. I would say a (substantial) majority of non-academic optimization problems do not involve any of the methods you listed, for a number of reasons.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;quot;Better is the enemy of good enough.&amp;quot; Using fixed, plausible values for parameters and ignoring uncertainty often produce answers that are good enough for management, so why get any more complicated?&lt;/li&gt;&#xA;&lt;li&gt;For large scale problems, any additional complexity could be a back-breaker, so why risk it?&lt;/li&gt;&#xA;&lt;li&gt;Stochastic optimization requires distributional assumptions/estimates that may not be easy to come by.&lt;/li&gt;&#xA;&lt;li&gt;Many OR/MS/IE students get a basic education in LP, graph models, dynamic programming and hopefully MIP, and maybe something a little funkier (optimal control theory?), but do not get much if any classroom exposure to stochastic optimization and especially to robust optimization (which is relatively new). Now shift from &amp;quot;exposure&amp;quot; to &amp;quot;mastery&amp;quot; (a nonincreasing transformation), get them jobs, and you end up with people solving problems who may or may not be aware of those things but in any case are definitely not comfortable with them.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Since a lynch mob is forming outside my study, let me add that there is merit to each of the concepts you listed, and I'm not arguing against their use (except where it would turn a difficult to solve approximate model into an impossible to solve but more exact model). Somewhere down the road, as they become more mainstream academic topics, their use will likely increase.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-12-08T22:04:44.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5371" PostTypeId="2" ParentId="5366" CreationDate="2020-12-08T22:55:27.567" Score="1" Body="&lt;p&gt;I'm not sure I understand the question correctly, but I'm going to assume that you are given a polytope &lt;span class=&quot;math-container&quot;&gt;$P\subset \mathbb{R}^d$&lt;/span&gt; specified by its vertex set &lt;span class=&quot;math-container&quot;&gt;$v_1,\dots,v_n \in \mathbb{R}^d$&lt;/span&gt; and a point &lt;span class=&quot;math-container&quot;&gt;$x\in \mathbb{R}^d$&lt;/span&gt;, and you want an optimization model that will be infeasible if &lt;span class=&quot;math-container&quot;&gt;$x\in P$&lt;/span&gt; and feasible if &lt;span class=&quot;math-container&quot;&gt;$x\notin P$&lt;/span&gt;. (The opposite approach -- feasible if &lt;span class=&quot;math-container&quot;&gt;$x\in P$&lt;/span&gt; and infeasible if &lt;span class=&quot;math-container&quot;&gt;$x\notin P$&lt;/span&gt; -- is easy to formulate.) Let &lt;span class=&quot;math-container&quot;&gt;$\alpha \in \mathbb{R}^d$&lt;/span&gt; be a vector of sign-unrestricted (free) variables, and consider the system of inequalities &lt;span class=&quot;math-container&quot;&gt;$$\alpha^\prime x \ge \alpha^\prime v_i + 1 \quad\forall i=1,\dots,n.$$&lt;/span&gt;You can turn it into a linear program by maximizing or minimizing 0 subject to those constraints.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x\in P$&lt;/span&gt;, there cannot be a feasible solution, since &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; would be a convex combination of the &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; and thus &lt;span class=&quot;math-container&quot;&gt;$\alpha^\prime x$&lt;/span&gt; would be a convex combination of the &lt;span class=&quot;math-container&quot;&gt;$\alpha^\prime v_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x\notin P$&lt;/span&gt;, you can get a feasible solution as follows. Let &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; be any face of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; lies on the opposite side of &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; (meaning that &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is the intersection of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; with a hyperplane &lt;span class=&quot;math-container&quot;&gt;$H = \lbrace y\in \mathbb{R}^d : \alpha^\prime y = \alpha_0\rbrace$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$y\in P \implies \alpha^\prime y \le \alpha_0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha^\prime x \gt \alpha_0$&lt;/span&gt;). Just scale up &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; as needed to get the minimum difference between &lt;span class=&quot;math-container&quot;&gt;$\alpha^\prime x$&lt;/span&gt; and any &lt;span class=&quot;math-container&quot;&gt;$\alpha^\prime v_i$&lt;/span&gt; to be at least 1.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: It appears I misunderstood the question. Given two convex polytopes &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_2$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^d$&lt;/span&gt;, to create constraints that are feasible only if &lt;span class=&quot;math-container&quot;&gt;$P_1 \cap P_2 = \emptyset$&lt;/span&gt;, you can add free variables &lt;span class=&quot;math-container&quot;&gt;$w_1, \dots, w_d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; along with the constraints &lt;span class=&quot;math-container&quot;&gt;$$w^\prime x \ge u + \epsilon\quad \forall x\in P_1$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$w^\prime x \le u - \epsilon\quad \forall x\in P_2,$$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is a small positive constant and &lt;span class=&quot;math-container&quot;&gt;$-1\le w_i \le 1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. (Bounding &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is necessary to avoid huge values that let the constraints be &amp;quot;satisfied&amp;quot; courtesy of rounding error.) If a solution exists, it represents a hyperplane separating the polygons. It will be infeasible if the polygons intersect or come too close (with &amp;quot;too close&amp;quot; related to the choice of &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-12-12T17:44:06.000" LastActivityDate="2020-12-12T17:44:06.000" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5372" PostTypeId="1" CreationDate="2020-12-09T08:02:38.647" Score="-4" ViewCount="215" Body="&lt;p&gt;I have not a good knowledge in math field, I am working on multi objective functions, and I have two maximization functions, and one minimize function, where:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Max (X,Y) = X+Y&lt;/li&gt;&#xA;&lt;li&gt;Max (L,M) = Sum (LC + MD), where C and D are constants.&lt;/li&gt;&#xA;&lt;li&gt;Min (T)= T*C.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I want to turn the two Max functions to Minimize function, how the function will be ?&lt;/p&gt;&#xA;" OwnerUserId="4389" LastEditorUserId="1228" LastEditDate="2020-12-09T15:26:28.420" LastActivityDate="2020-12-09T15:26:28.420" Title="How to change a function from Min(F(x)) to -Max(-F(x))?" Tags="|optimization|combinatorial-optimization|minimax|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5374" PostTypeId="1" AcceptedAnswerId="5379" CreationDate="2020-12-09T09:09:02.827" Score="3" ViewCount="168" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$A\in\mathbb{R}^{m\times n},c\in\mathbb{R}^n$&lt;/span&gt;. Show that exactly one of the following two systems is feasible:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Ax\geq0,x\geq0,c^Tx&amp;gt;0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$A^Ty\geq c,y\leq0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Assume that A is feasible meaning &lt;span class=&quot;math-container&quot;&gt;$Ax\geq0,x\geq0,c^tx&amp;lt;0$&lt;/span&gt; we'll show that B is not feasible.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$A^Ty\geq c\iff x^TA^Ty\geq x^Tc\iff(Ax)^Ty\geq c^Tx&amp;gt;0$$&lt;/span&gt;&#xA;because &lt;span class=&quot;math-container&quot;&gt;$Ax\geq0$&lt;/span&gt; we get that &lt;span class=&quot;math-container&quot;&gt;$y&amp;gt;0$&lt;/span&gt; and therefore B is not feasible.(not sure if this true or not)&lt;/p&gt;&#xA;&lt;p&gt;for the second side I got stuck.&lt;/p&gt;&#xA;" OwnerUserId="4526" LastEditorUserId="4526" LastEditDate="2020-12-09T10:16:09.443" LastActivityDate="2020-12-10T21:11:54.860" Title="Let $A\in\mathbb{R}^{m\times n},c\in\mathbb{R}^n$. Show that exactly one of the following two systems is feasible:" Tags="|optimization|convex-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5375" PostTypeId="2" ParentId="5372" CreationDate="2020-12-09T13:03:40.473" Score="5" Body="&lt;p&gt;In order to maximize X+Y, you can minimize -(X+Y), and then negate the optimal objective value. The optimal X and Y will also be optimal for maximize X+Y.&lt;/p&gt;&#xA;&lt;p&gt;Similarly, to maximize  Sum (LC + MD), you can minimize -Sum (LC + MD), and then negate the optimal objective value.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-12-09T13:03:40.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5376" PostTypeId="1" AcceptedAnswerId="5377" CreationDate="2020-12-10T02:40:01.023" Score="3" ViewCount="399" Body="&lt;p&gt;I'm trying to use Gurobi to model an optimization max function whose objective function is &lt;span class=&quot;math-container&quot;&gt;$$f(x)=\frac{r^Tx}{x^TQx}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thus maximizing this function &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is the same as maximizing &lt;span class=&quot;math-container&quot;&gt;$\log f(x)$&lt;/span&gt; and I want to implement it in Gurobi. My understanding is Gurobi doesn't handle log objective functions so I've made a linear maximization function &lt;span class=&quot;math-container&quot;&gt;$z(x) = t$&lt;/span&gt; as follows: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad z(x)=t\\\text{s.t.}&amp;amp;\quad\log(r^Tx) - \log(x^TQx) - t = 0\tag{C1}\\&amp;amp;\quad\vdots\quad\text{(other equality constraints)}.\end{align}&lt;/span&gt; Does anyone know how to implement constraint C1 in Gurobi?&lt;/p&gt;&#xA;" OwnerUserId="4581" LastEditorUserId="123" LastEditDate="2020-12-10T08:55:44.857" LastActivityDate="2020-12-10T08:55:44.857" Title="Using log optimization function in Gurobi" Tags="|nonlinear-programming|gurobi|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5377" PostTypeId="2" ParentId="5376" CreationDate="2020-12-10T03:11:06.207" Score="6" Body="&lt;p&gt;I will make the following assumptions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is symmetric positive semidefinite&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$r^Tx \ge 0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Note that maximizing &lt;span class=&quot;math-container&quot;&gt;$\frac{r^Tx}{X^TQx}$&lt;/span&gt; is equivalent to minimizing  &lt;span class=&quot;math-container&quot;&gt;$\frac{X^TQx}{r^Tx}$&lt;/span&gt; .&lt;/p&gt;&#xA;&lt;p&gt;Under the stated assumptions, this is a convex optimization problem, which can be submitted to and solved by Gurobi.&lt;/p&gt;&#xA;&lt;p&gt;The easiest way of doing so is using a convex optimization tool such as CVX or CVXPY. The CVX code would be&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin&#xA;cvx_solver gurobi&#xA;variable x(n)&#xA;minimize(quad_over_lin(chol(A)*x,r'*x))&#xA;cvx_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which uses the CVX function &lt;code&gt;quad_over_lin&lt;/code&gt;.  &lt;code&gt;chol(A)&lt;/code&gt; is the upper triangular Cholesky factor of A.&lt;/p&gt;&#xA;&lt;p&gt;CVXPY also has the same &lt;code&gt;quad_ovdr_lin&lt;/code&gt; function as CVX, but depending on which function is called to compute the Cholesky factor, you would need to apply a transpose to the Cholesky factor if a lower triangular Cholesky factor is generated&lt;/p&gt;&#xA;&lt;p&gt;This could instead be done using a &amp;quot;native&amp;quot; Gurobi interface. In that case, you would need to minimize a new variable, t,  subject to the rotated second order constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;norm(chol(A)*x) &amp;lt;= sqrt(t*r'*x), t &amp;gt;= 0, r'*x &amp;gt;= 0&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;using the appropriate syntax to specify this constraint for whatever interface you are using. As before, if chol(A) is lower triangular, you need to use its transpose.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2020-12-10T03:11:06.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5378" PostTypeId="2" ParentId="5374" CreationDate="2020-12-10T07:27:12.503" Score="1" Body="&lt;p&gt;Assume that A is feasible we'll show that B is not feasible.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A^Ty\geq c\iff x^TA^Ty\geq x^Tc\iff(Ax)^Ty\geq c^Tx&amp;gt;0\to (Ax)^Ty&amp;gt;0$&lt;/span&gt; but &lt;span class=&quot;math-container&quot;&gt;$Ax\geq0$&lt;/span&gt; therefore &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; must satisfy that &lt;span class=&quot;math-container&quot;&gt;$y&amp;gt;0$&lt;/span&gt; and B is not feasible.&lt;br /&gt;&#xA;Assume that B is feasible and we will show that A is not feasible&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$Ax\geq0\iff y^TAx\leq 0\iff(A^Ty)^Tx\leq0\iff c^Tx\leq(A^Ty)^Tx\leq 0\to c^Tx\leq 0$&lt;/span&gt; and A is not feasible. as desired.&lt;br /&gt;&#xA;Correct if I am wrong&lt;/p&gt;&#xA;" OwnerUserId="4526" LastActivityDate="2020-12-10T07:27:12.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5379" PostTypeId="2" ParentId="5374" CreationDate="2020-12-10T08:18:53.683" Score="2" Body="&lt;p&gt;Here is a solution using LP duality. Consider the following primal dual problems:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\textbf{PRIMAL} \\&#xA;\underset{x\in \mathbb{R}^{n}}{\max{}} &amp;amp; c^\top x \\&#xA; \mbox{s.t.} &amp;amp; Ax \geq 0 \\&#xA;&amp;amp;x \geq 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\textbf{DUAL} \\&#xA;\underset{y\in \mathbb{R}^{n}}{\min{}} &amp;amp; 0 \\&#xA; \mbox{s.t.} &amp;amp; A^\top y \geq c \\&#xA;&amp;amp;y \leq 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can verify that the 2 LPs shown above indeed form a primal-dual pair. Now suppose the PRIMAL problem has a feasible solution, say &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt;, and suppose &lt;span class=&quot;math-container&quot;&gt;$c^\top \bar{x} &amp;gt; 0$&lt;/span&gt;, then DUAL must be infeasible. This is because, the optimal value of the dual problem is 0 assuming that the dual is feasible. So if both the PRIMAL and DUAL were feasible and &lt;span class=&quot;math-container&quot;&gt;$c^\top \bar{x} &amp;gt; 0$&lt;/span&gt;, then we will violate the Weak LP duality rule that the optimal value of the PRIMAL can be no greater than the optimal value of the DUAL. So this proves the first part of the question.&lt;/p&gt;&#xA;&lt;p&gt;Now assume that the DUAL is feasible, so the optimal value of the DUAL is 0. Once again by weak duality recall that the optimal value of the PRIMAL cannot exceed 0. That means there is no &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; feasible to the PRIMAL (i.e. the constraints &lt;span class=&quot;math-container&quot;&gt;$Ax \geq 0, x \geq 0$&lt;/span&gt;) such that &lt;span class=&quot;math-container&quot;&gt;$c^\top x &amp;gt; 0$&lt;/span&gt; (since &lt;span class=&quot;math-container&quot;&gt;$c^\top x$&lt;/span&gt; is the objective of the PRIMAL). This completes the proof of the second part.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2020-12-10T21:11:54.860" LastActivityDate="2020-12-10T21:11:54.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5380" PostTypeId="2" ParentId="5349" CreationDate="2020-12-10T08:39:58.330" Score="2" Body="&lt;p&gt;You are asking about representations of &lt;span class=&quot;math-container&quot;&gt;$\sqrt{a^2 + b^2} \leq b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It is trivially only feasible for &lt;span class=&quot;math-container&quot;&gt;$a = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b\geq 0$&lt;/span&gt;. The  constraint &lt;span class=&quot;math-container&quot;&gt;$b\geq 0$&lt;/span&gt; term will be problematic in your new model as it represents a nonconvex quadratic set.&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2020-12-10T08:39:58.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5381" PostTypeId="2" ParentId="5365" CreationDate="2020-12-10T08:55:12.263" Score="1" Body="&lt;p&gt;Impossible in cvx since absolute value of a complex expression effectively is something represented using second-order cones/quadratics, and you thus have a nonconvex quadratic constraints since you are bounding that term from below, and that is not supported in cvx.&lt;/p&gt;&#xA;&lt;p&gt;Not possible to represent using reformulations with binary variables either. That would be the case if the variable was real and it was absolute values instead of 2-norms.&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2020-12-10T08:55:12.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5382" PostTypeId="1" CreationDate="2020-12-10T12:49:46.097" Score="2" ViewCount="152" Body="&lt;p&gt;I have a constraint in the form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sqrt{|\sum_{c\in C}{h_cw_c}|^2}\ge\sqrt{x}\zeta$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$h_c$&lt;/span&gt; is s row vector (know), &lt;span class=&quot;math-container&quot;&gt;$w_c$&lt;/span&gt; is a column vector (variable).&#xA;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\zeta$&lt;/span&gt; are also optimization variables.&lt;/p&gt;&#xA;&lt;p&gt;How can I transform this into linear/convex constraint?&lt;/p&gt;&#xA;&lt;p&gt;Also, I have &lt;span class=&quot;math-container&quot;&gt;$\text{imag}(h_cw_c)==0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Of course, I can write the LHS part as &lt;span class=&quot;math-container&quot;&gt;$||\sum_{c\in C}\rm{h_cw_c}||_2\ge\sqrt{x}\zeta$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, how to deal the RHS part?&lt;/p&gt;&#xA;&lt;p&gt;Is there any way to linearize this?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="38" LastEditDate="2020-12-10T16:02:40.417" LastActivityDate="2020-12-10T16:02:40.417" Title="How to linearize this multiplicative constraint?" Tags="|linear-programming|constraint|convex-optimization|quadratic-programming|disciplined-quasiconvex-programming|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5384" PostTypeId="1" AcceptedAnswerId="5385" CreationDate="2020-12-10T14:58:00.167" Score="4" ViewCount="288" Body="&lt;p&gt;I have a variable that can be defined as a sum of other variables. Should I create this variable and add a constraint that they are sum of the other variables or should use the minimum number of variables and use the sum each time?&lt;/p&gt;&#xA;&lt;p&gt;Anybody having some intuition and experience regarding these choices.&lt;/p&gt;&#xA;" OwnerUserId="4591" LastActivityDate="2020-12-11T09:01:56.737" Title="Best practices regarding using &quot;aggregated variables&quot; in MIP" Tags="|mixed-integer-programming|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5385" PostTypeId="2" ParentId="5384" CreationDate="2020-12-10T16:16:57.287" Score="5" Body="&lt;p&gt;We use this method in &lt;a href=&quot;https://octeract.com/octeract-engine/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Engine&lt;/a&gt;, and on a test set of ~3,000 problems it's better ~50% of the time, and worse for the remaining 50%.&lt;/p&gt;&#xA;&lt;p&gt;I wish a had an explanation for you - we have yet to discover a reason or pattern as to why it's worse (one would expect it to be better most of the time).&lt;/p&gt;&#xA;&lt;p&gt;Since you ask about best practices, we resorted to using machine learning to make the decision every time, which worked out pretty well.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-12-10T18:31:21.313" LastActivityDate="2020-12-10T18:31:21.313" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5386" PostTypeId="1" CreationDate="2020-12-10T19:36:45.787" Score="2" ViewCount="445" Body="&lt;p&gt;Whats the difference between MIP solution and Final Solve? I am trying to benchmark some solution approaches and I am not sure which of those is the more significant... sometimes they have the same value.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yBs57.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yBs57.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4380" LastActivityDate="2022-05-29T19:38:43.543" Title="CPLEX output log" Tags="|cplex|gams|benchmark|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5387" PostTypeId="2" ParentId="5386" CreationDate="2020-12-10T20:25:16.110" Score="5" Body="&lt;p&gt;By default, Gams/Cplex will try to calculate duals by fixing the integer variables and then resolving as an LP. This is the &amp;quot;final solve&amp;quot;. Usually the objectives are the same. In rare cases the final lp can be infeasible or the objective can be different because of an artifact in Cplex (mind-numbing detail: it can return mip solutions obeying the gap tolerance that are not lp optimal but found heuristically; in that case the final lp can improve the mip solution).&lt;/p&gt;&#xA;" OwnerUserId="907" LastActivityDate="2020-12-10T20:25:16.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5388" PostTypeId="2" ParentId="5386" CreationDate="2020-12-10T20:38:09.240" Score="1" Body="&lt;p&gt;While ago, I asked such a question and GAMS answer was:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I try solving a VRP problem with the below results without the gap option:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;Iteration log . . .&#xA;Iteration:     1   Dual objective     =           124.000000&#xA;Root relaxation solution time = 0.00 sec. (0.10 ticks)&#xA;&#xA;        Nodes                                         Cuts/&#xA;   Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap&#xA;   36       11       integral     0      497.0000        390.9714       269       21.33%&#xA;Found incumbent of value 497.000000 after 0.05 sec. (4.06 ticks)&#xA;&#xA;Solution satisfies tolerances.&#xA;MIP Solution:          497.000000    (444 iterations, 74 nodes)&#xA;Final Solve:           497.000000    (0 iterations)&#xA;&#xA;Best possible:         448.352400&#xA;Absolute gap:           48.647600&#xA;Relative gap:            0.097882&#xA;*-----------------------------------------------------------------------------------------------------&#xA;When I use the gap option:&#xA;Iteration log . . .&#xA;Iteration:     1   Dual objective     =           124.000000&#xA;Root relaxation solution time = 0.00 sec. (0.10 ticks)&#xA;&#xA;        Nodes                                         Cuts/&#xA;   Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap&#xA;   36       11       integral     0      497.0000        390.9714       269       21.33%&#xA;Found incumbent of value 497.000000 after 0.05 sec. (4.06 ticks)&#xA;&#xA;Proven optimal solution.&#xA;&#xA;MIP Solution:          497.000000    (470 iterations, 80 nodes)&#xA;Final Solve:           497.000000    (0 iterations)&#xA;&#xA;Best possible:         497.000000&#xA;Absolute gap:            0.000000&#xA;Relative gap:            0.000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The answer:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;The gap that you highlighted is not the final one from when the solver&#xA;terminated.&#xA;&#xA;With the default settings (which is optcr=0.1), you got&#xA;&#xA;Solution satisfies tolerances.&#xA;MIP Solution:          497.000000    (444 iterations, 74 nodes)&#xA;Final Solve:           497.000000    (0 iterations)&#xA;&#xA;Best possible:         448.352400&#xA;Absolute gap:           48.647600&#xA;Relative gap:            0.097882&#xA;&#xA;That is, the remaining relative gap is 10%, which is just below optcr=0.1.&#xA;CPLEX enumerated 74 nodes in the B&amp;amp;B tree to get to this gap.&#xA;&#xA;When you set optcr=0, you got&#xA;&#xA;Proven optimal solution.&#xA;&#xA;MIP Solution:          497.000000    (470 iterations, 80 nodes)&#xA;Final Solve:           497.000000    (0 iterations)&#xA;&#xA;Best possible:         497.000000&#xA;Absolute gap:            0.000000&#xA;Relative gap:            0.000000&#xA;&#xA;That is, CPLEX did not stop when the gap falls below 10% but continued&#xA;until it could bring down the gap to 0.&#xA;It had to enumerate 80 nodes in the B&amp;amp;B tree for this.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For more details please, see this &lt;a href=&quot;https://www.gams.com/latest/docs/UG_OptionStatement.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;. I hope it would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2020-12-10T20:38:09.240" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5389" PostTypeId="1" AcceptedAnswerId="5390" CreationDate="2020-12-11T07:43:20.070" Score="3" ViewCount="184" Body="&lt;p&gt;I am trying to prove that &lt;span class=&quot;math-container&quot;&gt;$P_{FL} \subset P_{AFL}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;\begin{align}P_{FL}&amp;amp;=\left\{({\bf x},{\bf y})\,\,\middle\vert\,\,\forall i,j:\sum_{j=1}^nx_{ij}=1,x_{ij}\le y_j,0\le x_{ij},y_j\le1\right\}\\P_{AFL}&amp;amp;=\left\{({\bf x},{\bf y})\,\,\middle\vert\,\,\forall i,j:\sum_{j=1}^nx_{ij}=1,\sum_{i=1}^mx_{ij}\le my_j,0\le x_{ij},y_j\le1\right\}.\end{align}&lt;/span&gt; I could get to a point that given &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \leq y_j$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$P_{FL}$&lt;/span&gt; summing over &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; to get &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i=1}^m x_{ij} \leq my_j$&lt;/span&gt;. Hence, &lt;span class=&quot;math-container&quot;&gt;$P_{FL}$&lt;/span&gt; is at least as strong as &lt;span class=&quot;math-container&quot;&gt;$P_{AFL}$&lt;/span&gt;. However, I couldn't provide a point where &lt;span class=&quot;math-container&quot;&gt;$P_{FL} \setminus P_{AFL}$&lt;/span&gt; to prove the inclusion is strict. How can I prove it?&lt;/p&gt;&#xA;" OwnerUserId="4594" LastEditorUserId="123" LastEditDate="2020-12-11T08:53:10.617" LastActivityDate="2020-12-11T08:55:38.990" Title="Strict inclusion for facility location formula and aggregate facility location formula" Tags="|mixed-integer-programming|linear-programming|integer-programming|facility-location|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5390" PostTypeId="2" ParentId="5389" CreationDate="2020-12-11T08:38:27.573" Score="4" Body="&lt;p&gt;Without loss of generality take &lt;span class=&quot;math-container&quot;&gt;$m=2$&lt;/span&gt;. Then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_i \leq y\implies\sum_{i=1}^m x_i \leq my$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is proven by direct summation as in the OP.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^m x_i \leq my\quad\not\!\!\!\!\implies x_i \leq y $$&lt;/span&gt;&#xA;is proven by carefully choosing a counterexample. I shall take &lt;span class=&quot;math-container&quot;&gt;$x_1 = y+\frac{\epsilon}{2}&amp;gt; y , x_2  = y-\epsilon$&lt;/span&gt;. The FL constraint is clearly violated for &lt;span class=&quot;math-container&quot;&gt;$i=1$&lt;/span&gt;, and yet the AFL constraint is satisfied:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_i x_i = 2y - \frac{\epsilon}{2} &amp;lt; 2y.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2616" LastEditorUserId="123" LastEditDate="2020-12-11T08:55:38.990" LastActivityDate="2020-12-11T08:55:38.990" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5391" PostTypeId="2" ParentId="5384" CreationDate="2020-12-11T09:01:56.737" Score="6" Body="&lt;p&gt;In my experience, it does not matter much for in terms of speed. The reason is that the size of an optimization really does not correlate with the time it takes to solve the model. There are even examples, where an equivalent formulation with significantly less variables and constraints is significantly harder to solve (see e.g. &lt;a href=&quot;https://github.com/RichardOberdieck/optimization-blog/blob/master/Is%20a%20better%20model%20really%20always%20better.ipynb&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, I always add those aggregate variables since they make the modeling cleaner. Then I give it to the solver and see whether it solves according to the performance that I need. If yes, great. If not, they you may want to have another look at the model formulation (and other details like computer hardware, solver parameters etc.) to see whether there are any improvements to be had.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2020-12-11T09:01:56.737" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5392" PostTypeId="1" CreationDate="2020-12-11T10:35:43.363" Score="2" ViewCount="997" Body="&lt;p&gt;I am asked to solve the following problem:&lt;/p&gt;&#xA;&lt;h1&gt;The problem:&lt;/h1&gt;&#xA;&lt;p&gt;You were asked to repair a farm house with sheets of plywood.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You were given &lt;strong&gt;thirty sheets of plywood&lt;/strong&gt;. (each size = 10ft x 10ft)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The house requires &lt;strong&gt;20 circles&lt;/strong&gt; (radius = 2.5ft ) and &lt;strong&gt;15 rectangles&lt;/strong&gt; (size = 6ft x 4ft)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It costs &lt;strong&gt;20 dollars to cut a circle&lt;/strong&gt; and &lt;strong&gt;15 dollars to cut a rectange&lt;/strong&gt;. And there are &lt;strong&gt;three ways&lt;/strong&gt; to cut the sheets as shown below:&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mOomz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mOomz.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&#xA;(I set these into x,y,z: numbers of sheets cut in the way)&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You can also buy &lt;strong&gt;1 single circle with 45 dollars&lt;/strong&gt; and &lt;strong&gt;1 rectangle with 30 dollars&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You &lt;strong&gt;CANNOT waste more than 30%&lt;/strong&gt; of the material. (Assuming total unused area &amp;lt;= 30%)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;Here is how I solve the problem:&lt;/h1&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x,y,z$&lt;/span&gt; - numbers of sheets cut in the ways shown above&lt;/p&gt;&#xA;&lt;p&gt;Objective function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M = 80x + 60y + 55z \tag{1}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$4x + 2z \le 20 \tag{2}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$4y + z \le 15 \tag{3}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x + y + z \le 30 \tag{4}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0.215x + 0.04y + 0.367z \le 0.3(x+y+z) \tag{5}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It seems that I am getting all zero but I cannot figure out how to set the constraints.&lt;/p&gt;&#xA;&lt;p&gt;I am asked to solve this with &lt;code&gt;ortools&lt;/code&gt; in Python.&lt;/p&gt;&#xA;&lt;p&gt;But it doesn't make any sense to do it with the incorrect equations.&lt;/p&gt;&#xA;" OwnerUserId="4596" LastEditorUserId="51" LastEditDate="2024-02-21T11:22:16.213" LastActivityDate="2024-02-21T11:22:16.213" Title="Cutting Stock Problem : Mixed Integer Programming" Tags="|mixed-integer-programming|python|or-tools|cutting-stock|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="5393" PostTypeId="2" ParentId="5392" CreationDate="2020-12-11T13:16:22.700" Score="4" Body="&lt;p&gt;Economically speaking, if there is no cost of reprogramming your cutter (be it a CNC machine or a bearded handyman), there is no reason to go on and cut out all four rectangles from the next plywood sheet, if you only need one more.&lt;/p&gt;&#xA;&lt;p&gt;In this realistic scenario, you need a bit more control variables, than specified in the first attempt: 12 vs 3.&lt;/p&gt;&#xA;&lt;p&gt;If we allow for more variety in possible cuts we have the following control variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; - number of plywood sheets out of which we only cut out &lt;span class=&quot;math-container&quot;&gt;$i=1,..4$&lt;/span&gt; circles.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the cost is &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{4} 20i x_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;wasted surface is &lt;span class=&quot;math-container&quot;&gt;$100 - 25\frac{\pi}{4}i $&lt;/span&gt; per sheet&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; - number of plywood sheets out of which we only cut out &lt;span class=&quot;math-container&quot;&gt;$i=1,..4$&lt;/span&gt; rectangles&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the cost is &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{4} 15i y_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;wasted surface is &lt;span class=&quot;math-container&quot;&gt;$100 - 24i$&lt;/span&gt; per sheet&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; - number of plywood sheets out of which we cut out a single rectangle and &lt;span class=&quot;math-container&quot;&gt;$i=1,2$&lt;/span&gt; circles.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the cost is &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{2} (15+20i)z_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;wasted surface is &lt;span class=&quot;math-container&quot;&gt;$76 - 25\frac{\pi}{4}i $&lt;/span&gt; per sheet&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; - number of circular shapes we purchase additionally&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the cost is &lt;span class=&quot;math-container&quot;&gt;$45 q$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; - number of rectangular shapes we purchase additionally&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the cost is &lt;span class=&quot;math-container&quot;&gt;$30 r$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The total cost is given by&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ M = \sum_{i=1}^{4} 20i x_i + \sum_{i=1}^{4} 15i y_i + \sum_{i=1}^{2} (15+20i)z_i + 45 q + 30 r,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;the total number of plywood sheets used is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^{4} (x_i+ y_i) + \sum_{i=1}^{2} z_i \leq 30,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and total unused area is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^{4} (100 - 25\frac{\pi}{4}i) x_i + \sum_{i=1}^{4} (100 - 24i) y_i + \sum_{i=1}^{2} (76 - 25\frac{\pi}{4}i)z_i \leq 30 \left( \sum_{i=1}^{4} (x_i+ y_i) + \sum_{i=1}^{2} z_i\right).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraints regarding the required number of shapes are:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^{4} i x_i + \sum_{i=1}^{2} i z_i + q\geq 20$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^{4} i y_i + \sum_{i=1}^{2} z_i + r\geq 15 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Allowing for more flexible cuts, you can reduce the cost from &lt;strong&gt;640&lt;/strong&gt; (&lt;span class=&quot;math-container&quot;&gt;$x=5, y=4$&lt;/span&gt;) to &lt;strong&gt;625&lt;/strong&gt; (&lt;span class=&quot;math-container&quot;&gt;$x_4=5, y_4=3, y_3=1$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="2616" LastEditorUserId="2616" LastEditDate="2020-12-11T13:40:09.603" LastActivityDate="2020-12-11T13:40:09.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5394" PostTypeId="2" ParentId="5167" CreationDate="2020-12-11T14:03:58.510" Score="4" Body="&lt;p&gt;While working with polyhedra representations myself, I've come across the package &lt;a href=&quot;http://cgm.cs.mcgill.ca/%7Eavis/C/lrs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;lrslib&lt;/strong&gt;&lt;/a&gt; by David Avis from McGill University.&lt;/p&gt;&#xA;&lt;p&gt;The key functionality of the package is the conversion between V- and H-representations for polytopes, but it has an efficient built-in LP solver.&lt;/p&gt;&#xA;&lt;p&gt;All computations are done exactly in either multiple precision or fixed integer arithmetic (under your control).&lt;/p&gt;&#xA;" OwnerUserId="2616" LastActivityDate="2020-12-11T14:03:58.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5395" PostTypeId="1" CreationDate="2020-12-11T15:52:44.807" Score="1" ViewCount="83" Body="&lt;p&gt;I'm using Active Set Method to solve a nonlinear optimization function minimizing a convex function over a polyhedron of 2 linear inequalities starting at an interior point &lt;span class=&quot;math-container&quot;&gt;$x_o$&lt;/span&gt;  At this point is it correct that the direction of travel can be anywhere insofar as it's a descent direction, ie the &lt;span class=&quot;math-container&quot;&gt;$Z_+$&lt;/span&gt; basis of the null space is &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; because there are 0 active constraints?&lt;/p&gt;&#xA;&lt;p&gt;Whenever I perform the algorithm by hand, the Reduced Newton Direction with maximum step &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; brings me to a feasible solution that meets local optimum conditions and is on the boundary of constraint C1, but it is not the global solution as the better minimum actually exists on the boundary of the 2nd constraint C2 which I am unable to reach once I'm on the boundary of C1.&lt;/p&gt;&#xA;&lt;p&gt;Thus my question is, based on where you start the algorithm &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; is global convergence guaranteed using active set method with Reduced Newton Direction or does it heavily depend on the starting point to find a local min that satisfies the algorithm's stopping conditions?&lt;/p&gt;&#xA;" OwnerUserId="4581" LastActivityDate="2020-12-11T15:52:44.807" Title="active set method guaranteed convergence" Tags="|nonlinear-programming|convex-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5396" PostTypeId="2" ParentId="5267" CreationDate="2020-12-11T17:47:44.860" Score="4" Body="&lt;h1&gt;It is not. Not with the same weights.&lt;/h1&gt;&#xA;&lt;p&gt;Regarding general positive coefficients (not necessarily weights) this is a question of existence of a positive solution to the system &lt;span class=&quot;math-container&quot;&gt;$Q_{n\times J} w' = q^w_{n\times 1}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$Q = [q^1 ... q^J]$&lt;/span&gt; collects the horizontally stacked column solution vectors to pure objectives, and &lt;span class=&quot;math-container&quot;&gt;$q^w$&lt;/span&gt; is the column solution vector of the averaged objective. A natural first step towards resolving this problem is &lt;a href=&quot;https://en.wikipedia.org/wiki/Farkas%27_lemma&quot; rel=&quot;nofollow noreferrer&quot;&gt;Farkas' lemma&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Proof by counterexample:&lt;/h3&gt;&#xA;&lt;p&gt;Just to have the peace of mind, we shall use the minimal example: &lt;span class=&quot;math-container&quot;&gt;$n=J=2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\beta = 2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w=(\frac{1}{2},\frac{1}{2})$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$A = \begin{bmatrix} a_1 &amp;amp; b_1 \\ a_2 &amp;amp; b_2\end{bmatrix}$&lt;/span&gt; be the matrix with positive entries.&lt;/p&gt;&#xA;&lt;p&gt;So we have 3 maximization programs with solutions :&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_1 &amp;amp; = \arg \min_{x\in[0,1]} a_1 x^2 + b_1(1-x)^2 = \frac{b_1}{a_1+b_1}\\&#xA;x_2 &amp;amp; = \arg \min_{x\in[0,1]} a_2 x^2 + b_2(1-x)^2 = \frac{b_2}{a_2+b_2}\\&#xA;x_w &amp;amp; = \arg \min_{x\in[0,1]} \bar a x^2 + \bar b (1-x)^2 = \frac{\bar b}{\bar a+\bar b},&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\bar a = \frac{a_1+a_2}{2}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar b = \frac{b_1+b_2}{2}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It is immediate to see that the minimum of the averaged objective is not the average of the minima of the pure objectives:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{x_1+x_2}{2} = \frac{1}{2}\left(\frac{b_1}{a_1+b_1}+ \frac{b_2}{a_2+b_2}\right) \neq \frac{1}{2} \frac{b_1 + b_2}{\bar a + \bar b} = x_w$$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2616" LastEditorUserId="2616" LastEditDate="2020-12-11T18:22:09.860" LastActivityDate="2020-12-11T18:22:09.860" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5397" PostTypeId="1" AcceptedAnswerId="5403" CreationDate="2020-12-11T21:24:15.610" Score="10" ViewCount="684" Body="&lt;p&gt;I was doing an assignment regarding turbine placements, where one has to write and solve a maximisation problem. As I was reading into the topic, I came across the fact that I could transform the constraints into an equivalent &lt;span class=&quot;math-container&quot;&gt;$\sqrt{...^{2}+...^{2}} \leq ...$&lt;/span&gt; form, which I believe is called a SOCP.&lt;/p&gt;&#xA;&lt;p&gt;Although, we will not touch upon this topic, it did spark my curiosity. Therefore, I have some basic questions that I am unable to find by myself and thus hereby I would like to ask them to you all.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the intuition behind it that a SOCP formulation can be solved more efficiently?&lt;/li&gt;&#xA;&lt;li&gt;Why does SOCP give relatively stable solutions (i.e. if I change parameters the maximum of the objective function does not vary significantly, but remain rather stable).&lt;/li&gt;&#xA;&lt;li&gt;Why doesn't the solver transform the problem automatically into a SOCP one, if SOCP is so much better?&lt;/li&gt;&#xA;&lt;li&gt;Is a SOCP formulation &lt;strong&gt;always&lt;/strong&gt; better (i.e. meaning are there instances where one is better off not transforming the constraints into a SOCP)?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Thanks all!&lt;/p&gt;&#xA;" OwnerUserId="563" LastActivityDate="2020-12-14T02:34:31.553" Title="Intuition behind SOCP and why it sometimes can be solved more efficiently than without transforming it into a SOCP?" Tags="|cone|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5398" PostTypeId="2" ParentId="5392" CreationDate="2020-12-11T22:03:46.570" Score="1" Body="&lt;p&gt;Your objective function doesn't include the cost of buying singles, so you are only minimizing the cost of doing cuts, not the total cost to acquire 20 circles and 15 rectangles (so of course, making no cuts at all gives you the minimal solution). For any potential x,y,z solution point, you will actually need to buy 20-(4x+2z) single circles at 45 each and 15-(4y+z) single rectangles at 30 each. If I've done my arithmetic correctly, the objective function should be 1350-100x-60y-65z.&lt;/p&gt;&#xA;" OwnerUserId="4598" LastActivityDate="2020-12-11T22:03:46.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5400" PostTypeId="1" AcceptedAnswerId="5401" CreationDate="2020-12-12T23:37:25.320" Score="2" ViewCount="2797" Body="&lt;p&gt;In an undirected graph, I would like to order its nodes according to their degree. However, to do this I have to enter the edges of the graph first. When I do this, &lt;strong&gt;NetworkX&lt;/strong&gt; in Python reads the nodes from the entries of the edges and doesn't consider the contribution of the &lt;code&gt;add_nodes_from&lt;/code&gt; command. Is there any way to overcome this problem? Here is a sample of code I'm using:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;g = nx.Graph()&#xA;weighted_edges =    [(4,3,150),(1,2,15),(1,4,100),(1,3,100),(1,5,130)&#xA;                    ,(2,3,205),(2,4,211),(2,5,200),(3,5,100),(4,5,10)]&#xA;#Sorting edges according to node degree &#xA;sorted_edges = sorted(g.degree(weight='weight'), key=lambda x: x[1], reverse=True)&#xA;# extract the sorted nodes &#xA;nodes = []&#xA;for e in range(len(sorted_edges)):&#xA;   temp = sorted_edges[e][0]&#xA;   nodes.append(temp)&#xA;&#xA;g.add_nodes_from(nodes)&#xA;g.add_weighted_edges_from(weighted_edges)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;according to the above sample of code, &lt;code&gt;print(nodes)&lt;/code&gt; output is an &lt;strong&gt;empty set&lt;/strong&gt;, since &lt;code&gt;add_weighted_edges_from&lt;/code&gt; is coming after. When we add the edges first, &lt;code&gt;g.nodes&lt;/code&gt; outputs following the order edge entries. &lt;strong&gt;nodes&lt;/strong&gt; are meant to be the sorted nodes according to their degree, and &lt;strong&gt;g.nodes&lt;/strong&gt; are the nodes according to the graph edges entries.&#xA;I appreciate your help!&lt;/p&gt;&#xA;" OwnerUserId="4347" LastEditorUserId="2477" LastEditDate="2020-12-13T00:23:52.377" LastActivityDate="2020-12-13T19:06:11.660" Title="Ordering Nodes of a graph according to their degree" Tags="|python|graphs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5401" PostTypeId="2" ParentId="5400" CreationDate="2020-12-13T15:46:07.323" Score="2" Body="&lt;p&gt;I know this is not a typical answer, but I decided to post this tweak to help others when they are facing the same problem.&#xA;I have added another initiation for the graph method using the same name of the graph &lt;code&gt;g=nx.graph()&lt;/code&gt; just before the definition of the sorted nodes, such that the graph will consider the sorted nodes as &lt;code&gt;g.nodes&lt;/code&gt;, the code will be such that&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;g = nx.Graph()&#xA;weighted_edges =    [(4,3,150),(1,2,15),(1,4,100),(1,3,100),(1,5,130)&#xA;                     ,(2,3,205),(2,4,211),(2,5,200),(3,5,100),(4,5,10)]&#xA;#Sorting edges according to node degree &#xA;sorted_edges = sorted(g.degree(weight='weight'), key=lambda x: x[1], reverse=True)&#xA;# extract the sorted nodes &#xA;nodes = []&#xA;for e in range(len(sorted_edges)):&#xA;    temp = sorted_edges[e][0]&#xA;    nodes.append(temp)&#xA;g=nx.graph() # this line was added to restart the graph definition&#xA;g.add_nodes_from(nodes)&#xA;g.add_weighted_edges_from(weighted_edges)&#xA;print (g.nodes)&#xA;output: NodeView((2, 3, 4, 5, 1)) # g.nodes are sorted according to the node degree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4347" LastEditorUserId="4347" LastEditDate="2020-12-13T19:06:11.660" LastActivityDate="2020-12-13T19:06:11.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5402" PostTypeId="1" AcceptedAnswerId="5404" CreationDate="2020-12-13T18:02:43.723" Score="3" ViewCount="399" Body="&lt;p&gt;I noticed that when I run the solver via the GAMS IDE or Python API I don't use more than ~33% of my RAM. Is there an artificial barrier which I can put up or disable?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/foXua.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/foXua.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4380" LastEditorUserId="279" LastEditDate="2021-08-08T22:28:44.273" LastActivityDate="2021-08-08T22:28:44.273" Title="GAMS default Solver doesn't use much of my RAM and CPU" Tags="|cplex|gams|cplex-python-api|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5403" PostTypeId="2" ParentId="5397" CreationDate="2020-12-14T02:34:31.553" Score="13" Body="&lt;p&gt;Whether a given formulation is faster / more stable than another depends on the software you use to solve either.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;What is the intuition behind it that a SOCP formulation can be solved more efficiently?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Here are a few reasons. For more details, you can have a look at the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;noreferrer&quot;&gt;Mosek modeling cookbook&lt;/a&gt; or the seminal book of &lt;a href=&quot;https://www2.isye.gatech.edu/%7Enemirovs/lmco_run.pdf&quot; rel=&quot;noreferrer&quot;&gt;Ben Tal &amp;amp; Nemirovskii, Lectures on Modern Convex Optimization&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cones do not require derivatives.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you write a constraint &lt;span class=&quot;math-container&quot;&gt;$\sqrt{x^{2} + y^{2}} \leq z$&lt;/span&gt; an give it to, say, Ipopt (which is uses derivatives), it may fail when &lt;span class=&quot;math-container&quot;&gt;$x, y, z$&lt;/span&gt; are zero (because the square root is non-differentiable at zero). On the other hand, conic solvers do not work with derivatives, and will not fail.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Second-Order Cones are convex.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Consider the constraint &lt;span class=&quot;math-container&quot;&gt;$x^{2} + y^{2} \leq z^{2}, z \geq 0$&lt;/span&gt;. The quadratic part &lt;span class=&quot;math-container&quot;&gt;$x^{2} + y^{2} - z^{2} \leq 0$&lt;/span&gt; is not convex, and some solvers may fail to detect that (in general, it's NP-hard to determine whether a given function is convex over its domain). If you write that same constraint as an SOC, you know intrinsically that it is convex.&#xA;In fact, if your problem is convex, there's a 99.99% chance you can write it as a conic optimization problem. You can look at the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;noreferrer&quot;&gt;Mosek modeling cookbook&lt;/a&gt; and its &lt;a href=&quot;https://docs.mosek.com/cheatsheets/conic.pdf&quot; rel=&quot;noreferrer&quot;&gt;conic modeling cheatsheet&lt;/a&gt; for such examples.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Conic duality&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The dual of a (convex) conic optimization problem is also a convex conic optimization problem and, in most cases of interest, we know how to write it. That is not true in general for convex optimization problems (for instance, the Lagrangian dual, in general, is non-convex).&lt;/p&gt;&#xA;&lt;p&gt;Thus, efficient algorithms exist for the resolution of conic optimization problems. They include, among others, interior-point methods and the Alternating Direction Method of Multipliers (ADMM). The former are implemented in,  e.g., &lt;a href=&quot;https://www.mosek.com/&quot; rel=&quot;noreferrer&quot;&gt;Mosek&lt;/a&gt;, Sedumi, &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/papers/ecos.html&quot; rel=&quot;noreferrer&quot;&gt;ECOS&lt;/a&gt;; the latter in OSQP or &lt;a href=&quot;https://github.com/cvxgrp/scs&quot; rel=&quot;noreferrer&quot;&gt;SCS&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Why does SOCP give relatively stable solutions (i.e. if I change parameters the maximum of the objective function does not vary significantly, but remain rather stable).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This behavior depends on which algorithm you use to solve your problem.&#xA;Interior-point methods are likely to give you a similar solution if you do not change the parameters much. Others may behave differently, especially if your problem has multiple optimal solutions.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Why doesn't the solver transform the problem automatically into a SOCP one, if SOCP is so much better?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Several people advocate for doing so.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MOSEK will always reformulate everything using conic formulations.&lt;/li&gt;&#xA;&lt;li&gt;Disciplined Convex Programming tools such as &lt;a href=&quot;https://cvxr.com/cvx/&quot; rel=&quot;noreferrer&quot;&gt;CVX&lt;/a&gt;, &lt;a href=&quot;https://cvxpy.org&quot; rel=&quot;noreferrer&quot;&gt;cvxpy&lt;/a&gt;, etc. allow to formulate a problem using convex optimization paradigms, and will reformulate it as a conic optimization problem under the hood.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;However, it only makes sense to use a conic formulation if you have a conic solver at hand. For instance, Ipopt does not support conic constraints.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Is a SOCP formulation always better (i.e. meaning are there instances where one is better off not transforming the constraints into a SOCP)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;My general experience is that conic formulations tend to be faster and numerically more robust. Thus, I would recommend using conic formulations when possible. Sometimes doing so helps realizing that a problem is actually convex (which is a good thing).&lt;/p&gt;&#xA;&lt;p&gt;For completeness, here are a couple of counter-examples to this rule:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If your problem has linear constraints and a convex quadratic objective, you can solve it using the &lt;a href=&quot;https://www.rand.org/pubs/papers/P1205.html&quot; rel=&quot;noreferrer&quot;&gt;simplex algorithm&lt;/a&gt;. Doing so can be advantageous if, e.g., you need to warm-start. This is particularly true when solving Mixed-Integer Quadratic Programs, or when solving multiple instances that do not vary too much.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Formulating a quadratic constraint (or objective) as a SOC requires computing a matrix factorization. Sometimes, this may result in much denser problems, which are then harder to solve.&lt;/p&gt;&#xA;&lt;p&gt;The converse can also happen: if you have a quadratic objective &lt;span class=&quot;math-container&quot;&gt;$x^{T}Qx$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$Q = M^{T}M$&lt;/span&gt; for some low-rank matrix &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, then an SOC formulation may be much faster (though you could also introduce &lt;span class=&quot;math-container&quot;&gt;$y = Mx$&lt;/span&gt; and minimize &lt;span class=&quot;math-container&quot;&gt;$y^{T}y$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2020-12-14T02:34:31.553" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5404" PostTypeId="2" ParentId="5402" CreationDate="2020-12-14T19:28:42.423" Score="4" Body="&lt;p&gt;As @ErwinKalvelagen pointed out: by default gams cplex uses only 1 thread which results in a low usage of the pc ressources.&lt;/p&gt;&#xA;&lt;p&gt;In order to change this one has to increase the thread  number so that multiple cores can be used at the same time:&#xA;&lt;a href=&quot;https://support.gams.com/solver:multiple_cplex_threads&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://support.gams.com/solver:multiple_cplex_threads&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4380" LastActivityDate="2020-12-14T19:28:42.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5405" PostTypeId="1" CreationDate="2020-12-14T21:10:19.593" Score="4" ViewCount="210" Body="&lt;p&gt;Good evening,&#xA;I am looking for a way to retrieve information from the final solve statement. Lower bound and Gap would be nice. I am working with the python api but i can only get the final obj. value and all parameters etc..&#xA;Is there a way to store the information I need in a parameter and what would be the command?&lt;/p&gt;&#xA;&lt;p&gt;I want to access and store the underlined values in the picture..&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ntGlc.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ntGlc.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4380" LastEditorUserId="4380" LastEditDate="2020-12-14T21:19:17.707" LastActivityDate="2020-12-15T19:48:50.130" Title="GAMS: Is there a way to retrieve the gap from the final solve statement" Tags="|cplex|gams|test-instances|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5406" PostTypeId="1" CreationDate="2020-12-15T02:16:20.890" Score="2" ViewCount="84" Body="&lt;p&gt;I have a problem that I must formulate as a DP problem and solve.&lt;/p&gt;&#xA;&lt;p&gt;A hospital is split up into 4 sections, each section has 1 or 2 or 3 backup generators. We have to maximize the likelihood that no section of the hospital fails but we cannot buy as many generators as we want since we have a 10,000 € maximum budget.&lt;/p&gt;&#xA;&lt;p&gt;The number of generators and the likelihood of NOT losing power:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Generator&lt;/th&gt;&#xA;&lt;th&gt;Section 1&lt;/th&gt;&#xA;&lt;th&gt;Section 2&lt;/th&gt;&#xA;&lt;th&gt;Section 3&lt;/th&gt;&#xA;&lt;th&gt;Section 4&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0.5&lt;/td&gt;&#xA;&lt;td&gt;0.6&lt;/td&gt;&#xA;&lt;td&gt;0.7&lt;/td&gt;&#xA;&lt;td&gt;0.5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;0.6&lt;/td&gt;&#xA;&lt;td&gt;0.7&lt;/td&gt;&#xA;&lt;td&gt;0.8&lt;/td&gt;&#xA;&lt;td&gt;0.7&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;td&gt;0.8&lt;/td&gt;&#xA;&lt;td&gt;0.8&lt;/td&gt;&#xA;&lt;td&gt;0.9&lt;/td&gt;&#xA;&lt;td&gt;0.9&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;And the cost of having the generators&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Generator&lt;/th&gt;&#xA;&lt;th&gt;Section 1&lt;/th&gt;&#xA;&lt;th&gt;Section 2&lt;/th&gt;&#xA;&lt;th&gt;Section 3&lt;/th&gt;&#xA;&lt;th&gt;Section 4&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1,000€&lt;/td&gt;&#xA;&lt;td&gt;2,000€&lt;/td&gt;&#xA;&lt;td&gt;1,000€&lt;/td&gt;&#xA;&lt;td&gt;2,000€&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;2,000€&lt;/td&gt;&#xA;&lt;td&gt;4,000€&lt;/td&gt;&#xA;&lt;td&gt;3,000€&lt;/td&gt;&#xA;&lt;td&gt;3,000€&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;td&gt;3,000€&lt;/td&gt;&#xA;&lt;td&gt;5,000€&lt;/td&gt;&#xA;&lt;td&gt;4,000€&lt;/td&gt;&#xA;&lt;td&gt;4,000€&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;So far I have identified:&lt;/p&gt;&#xA;&lt;p&gt;n: is the section of the hospital&lt;/p&gt;&#xA;&lt;p&gt;Xn: Generators for a section n&lt;/p&gt;&#xA;&lt;p&gt;Pn(Xn): Likelihood of not losing power to section n if we have Xn generators&lt;/p&gt;&#xA;&lt;p&gt;I cannot identify my Sn and any other important variables. I also do not know how to proceed with the calculations, if someone can explain how one calculation affects the next one it could be great for an in-depth explanation&lt;/p&gt;&#xA;" OwnerUserId="4608" LastActivityDate="2020-12-15T02:16:20.890" Title="Dynamic Programming problem of affecting equipment with budget constraint" Tags="|optimization|modeling|dynamic-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5407" PostTypeId="1" CreationDate="2020-12-15T11:46:43.843" Score="1" ViewCount="159" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$A\in\mathbb{R}^{m \times n}, c\in\mathbb{R}^{n}, b\in\mathbb{R}^{m}, d\in\mathbb{R}$&lt;/span&gt;. Suppose that there exists &lt;span class=&quot;math-container&quot;&gt;$y\geq0$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$A^Ty=c$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; prove that exactly one of the following is feasible:&lt;/p&gt;&#xA;&lt;p&gt;either&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{cases}A x&amp;amp;\leq b\\  c^T x &amp;amp;&amp;gt;d \end{cases} \tag{A}$$&lt;/span&gt;&#xA;or&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{cases} A^T y &amp;amp; = c \\ b^T y &amp;amp;&amp;lt; d. \end{cases} \tag{B}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;&lt;strong&gt;My attempt&lt;/strong&gt; is the following.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;I'm not sure about the way I solve the second part where B doesn't hold.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Assume that B holds and we'll show that A doesn't.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Ax\leq b\iff y^T Ax\leq y^T b\iff (A^Ty)^Tx\leq d\iff c^Tx\leq d$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and therefore A doesn't hold.&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Now, assume the contrary, that B doesn't hold and we'll show that A is feasible.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;If B doesn't holds then &lt;span class=&quot;math-container&quot;&gt;$A^Ty=c,b^Ty=d$&lt;/span&gt; doesn't hold either. Introduce&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tilde{A}:=\begin{pmatrix}&#xA;A^T\\b^T&#xA;\end{pmatrix},\quad \tilde{c}:=\begin{pmatrix}&#xA;c\\d&#xA;\end{pmatrix}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now from the homogenous Farkas' lemma we know that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tilde{A}\tilde{x}\leq 0,\tilde{c}^T \tilde x&amp;gt;0\iff Ax+x_{n+1}b\leq0,c^Tx+dx_{n+1}&amp;gt;0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and setting &lt;span class=&quot;math-container&quot;&gt;$x_{n+1}=-1$&lt;/span&gt; we get &lt;span class=&quot;math-container&quot;&gt;$Ax\leq b,c^Tx &amp;gt;d$&lt;/span&gt; as desired.&lt;/p&gt;&#xA;" OwnerUserId="4526" LastEditorUserId="2616" LastEditDate="2020-12-21T19:22:05.717" LastActivityDate="2020-12-21T19:22:05.717" Title="Prove Non-Homogeneous Farkas' Lemma" Tags="|optimization|convex-optimization|kkt-conditions|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5408" PostTypeId="1" CreationDate="2020-12-15T14:01:32.743" Score="1" ViewCount="233" Body="&lt;p&gt;I am currently trying to solve a problem where I need to minimise transport cost through the choice of vehicle (and how many of each choice) subject to a given demand.&lt;/p&gt;&#xA;&lt;p&gt;The problem:&lt;/p&gt;&#xA;&lt;p&gt;There are currently 3 vehicle sizes corresponding to their haulage capacity, an associated daily cost, and a daily demand.&lt;/p&gt;&#xA;&lt;p&gt;I need an objective function that minimises the cost through the choice of vehicle whilst satisfying the sales demand, however, I do not know how to define an expression that is based on the number of vehicles used * the cost per day, as it depends on the weight.&lt;/p&gt;&#xA;&lt;p&gt;Data:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Vehicle capacity&#xA;truck_capacity_dict = {&#xA;    '7.5T': {'capacity': 7500},&#xA;    '12T': {'capacity': 12000},&#xA;    '44T': {'capacity': 44000}&#xA;}&#xA;&#xA;# Vehicle daily costs&#xA;truck_capacity_dict = {&#xA;    '7.5T': {'rate': 350},&#xA;    '12T': {'rate': 660},&#xA;    '44T': {'rate': 2000}&#xA;}&#xA;&#xA;# Daily demand &#xA;sales_demand_tonnes = {&#xA;'2020-01-01': 300,&#xA;'2020-01-02': 293,&#xA;'2020-01-03': 176&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Mathematically, this is similar to the below expression where the OF is to minimise the costs based on the choice of vehicle:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum V_{t, v} \cdot C_{t, v} \forall t \subset T, v \subset V$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, I do not know how to formulate an expression in python that determines &lt;strong&gt;how many&lt;/strong&gt; vehicles are chosen, as this depends on the weight.&lt;/p&gt;&#xA;" OwnerUserId="3395" LastEditorUserId="123" LastEditDate="2021-11-03T14:42:30.710" LastActivityDate="2021-11-03T14:42:30.710" Title="How can I formulate an objective function that minimises the number of items required to solve a problem" Tags="|optimization|linear-programming|python|pulp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5409" PostTypeId="2" ParentId="5405" CreationDate="2020-12-15T19:48:50.130" Score="5" Body="&lt;p&gt;Collecting things in a parameter is actually very simple.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set run /.../;&#xA;&#xA;parameter objresult(run,*);&#xA;&#xA;loop(run,  &#xA;    solve m ....&#xA;    objresult(run,&amp;quot;obj&amp;quot;) = m.objval;&#xA;    objresult(run,&amp;quot;bestbound&amp;quot;) = m.objest;&#xA;    objresult(run,&amp;quot;absgap&amp;quot;) = abs(m.objval-m.objest);&#xA;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="907" LastActivityDate="2020-12-15T19:48:50.130" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5410" PostTypeId="2" ParentId="5408" CreationDate="2020-12-16T08:59:14.463" Score="1" Body="&lt;p&gt;I suggest introducing &lt;span class=&quot;math-container&quot;&gt;$3n$&lt;/span&gt; variables. Let &lt;span class=&quot;math-container&quot;&gt;$ c_{i} $&lt;/span&gt; be the daily rate of each vehicle &lt;span class=&quot;math-container&quot;&gt;$i=1,2,3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x_{i,j} $&lt;/span&gt; designates the quantity of vehicles which will be used every day: the subscript &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; indicates the day in interest. Supposing to consider &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; days, we have &lt;span class=&quot;math-container&quot;&gt;$j=1, 2, \ldots, n$&lt;/span&gt; days.&#xA;Clearly, &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j} $&lt;/span&gt; is a non-negative integer numbe and &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j}=0$&lt;/span&gt; means that no vehicle of kind &lt;span class=&quot;math-container&quot;&gt;$i-th$&lt;/span&gt; is used in &lt;span class=&quot;math-container&quot;&gt;$j-th$&lt;/span&gt; day.&lt;/p&gt;&#xA;&lt;p&gt;The total cost based on the number of vehicles used is&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \min \sum_{j=1}^n \sum_{j=1}^3 c_i  \cdot x_{ij}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4114" LastActivityDate="2020-12-16T08:59:14.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5411" PostTypeId="1" AcceptedAnswerId="6185" CreationDate="2020-12-16T11:06:38.917" Score="3" ViewCount="213" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$X\in\mathbb{R}^{m\times n}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$v\in\mathbb{R}^m$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w\in\mathbb{R}^n$&lt;/span&gt; are variables from an optimization problem, which also includes the constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0\le v\le a$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0\le w\le 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w_1+\dots+w_n=b$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$X=vw^\top$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; are known constants with &lt;span class=&quot;math-container&quot;&gt;$0\le a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0\le b\le n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The final constraint is non-linear, and non-convex.&lt;/p&gt;&#xA;&lt;p&gt;Does it have a MILP (or similar) representation?&lt;/p&gt;&#xA;&lt;p&gt;If not, what is the tightest relaxation of this constraint that is globally solvable by standard methods (SDP, SOCP, MIQP, etc.)?&lt;/p&gt;&#xA;&lt;p&gt;Note 1: The &lt;a href=&quot;http://users.cecs.anu.edu.au/%7Erobert/lmirank/&quot; rel=&quot;nofollow noreferrer&quot;&gt;LMIRANK solver&lt;/a&gt; can find solutions to rank constrained feasibility problems, but it requires the matrix with the rank constraint to be symmetric and positive definite. My matrix &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is not even square.&lt;/p&gt;&#xA;&lt;p&gt;Note 2: If &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is integer and we add the additional constraint that &lt;span class=&quot;math-container&quot;&gt;$w_1,\dots,w_n\in\{0,1\}$&lt;/span&gt;, then the problem has a MILP representation (given by replacing the final constraint with the constraints: &lt;span class=&quot;math-container&quot;&gt;$0\le X_{i,j}\le v_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0\le X_{i,j}\le a w_j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$X_{i,1}+\dots+X_{i,n}=v_i b$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,\dots,m\},j\in\{1,\dots,n\}$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;It seems strange that adding binary constraints could actually make this problem easier, which is what leads me to suspect there must be a tractable approach to the original problem.&lt;/p&gt;&#xA;" OwnerUserId="3830" LastActivityDate="2021-04-28T00:52:14.157" Title="&quot;Rank 1&quot; type constraint $X=vw^\top$: MILP representation? Convex relaxation? Other tractable approach?" Tags="|optimization|mixed-integer-programming|nonlinear-programming|nonconvex-programming|relaxation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5413" PostTypeId="1" AcceptedAnswerId="5414" CreationDate="2020-12-16T18:16:43.233" Score="8" ViewCount="625" Body="&lt;p&gt;We are using Gurobi 9.0.2 to solve complex mixed integer linear programs for which we are attempting to maintain total unimodularity (TUM). In our log file we see things like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Concurrent spin time: 13403.45s (can be avoided by choosing Method=3)&#xA;Concurrent spin time: 921.14s (can be avoided by choosing Method=3)&#xA;Concurrent spin time: 244.37s (can be avoided by choosing Method=3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What does &lt;em&gt;Concurrent spin time&lt;/em&gt; mean and what does Method=3 do?&lt;/p&gt;&#xA;" OwnerUserId="3966" LastActivityDate="2020-12-18T11:36:44.263" Title="What does &quot;Concurrent spin time&quot; mean in the Gurobi log and what does choosing Method=3 do?" Tags="|gurobi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5414" PostTypeId="2" ParentId="5413" CreationDate="2020-12-16T18:50:05.537" Score="14" Body="&lt;p&gt;Performing parallel operations deterministically often leads to some overhead and threads waiting or idling - this is the spin time. A non-deterministic or opportunistic parallel mode does not have this overhead but also does not guarantee reproducibility - this is enabled via &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/method.html#parameter:Method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Method=3&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: When solving very similar models you should also just check what is the winning method and then enable this explicitly. This can free up one or two additional threads for the barrier algo (Method=2) or make the simplex slightly more performant, due to less strain on memory and CPU bandwidth (Method=0 or Method=1).&lt;/p&gt;&#xA;" OwnerUserId="141" LastEditorUserId="141" LastEditDate="2020-12-18T11:36:44.263" LastActivityDate="2020-12-18T11:36:44.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5416" PostTypeId="1" CreationDate="2020-12-18T09:05:37.993" Score="5" ViewCount="1879" Body="&lt;p&gt;I have some attempts to solve a scheduling problem using the Gurobi and doCPLEX API in python and .NET on Ubuntu-server installed on a hyper-computing cluster with 64 physical cores. Unfortunately, both solvers cannot exploit more than 32 cores and it seems a bit weird to me! Even I attempted to force using 64 cores with the &lt;code&gt;Threads&lt;/code&gt; parameter; however, it deteriorated the convergences speed. Appreciate someone has any interpretations of this case and of course a solution to this issue.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DFkpX.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DFkpX.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE #1:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The machine is deployed with 64 physical cpus. Here is the detail of cpu #26:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;*-cpu:25&#xA;        description: CPU&#xA;        product: Intel(R) Xeon(R) CPU E5-2698 v4 @ 2.20GHz&#xA;        vendor: Intel Corp.&#xA;        physical id: 419&#xA;        bus info: cpu@25&#xA;        version: RHEL 7.6.0 PC (i440FX + PIIX, 1996)&#xA;        slot: CPU19&#xA;        size: 2GHz&#xA;        capacity: 2GHz&#xA;        width: 64 bits&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and cpu #64:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; *-cpu:63&#xA;        description: CPU&#xA;        product: Intel(R) Xeon(R) CPU E5-2698 v4 @ 2.20GHz&#xA;        vendor: Intel Corp.&#xA;        physical id: 43f&#xA;        bus info: cpu@63&#xA;        version: RHEL 7.6.0 PC (i440FX + PIIX, 1996)&#xA;        slot: CPU3f&#xA;        size: 2GHz&#xA;        capacity: 2GHz&#xA;        width: 64 bits&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE #2:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The architecture of CPUs:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XKYqK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XKYqK.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE #3:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;From the Gurobi community support center (&lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360033280511-How-does-Gurobi-count-cores-&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Gurobi always aims to count &lt;code&gt;physical cores&lt;/code&gt;. To do this, the&#xA;operating system is queried for the number of physical and logical&#xA;cores. Gurobi license files always contain the (maximal) number of&#xA;(physical) cores for which they are valid. (For reasons of&#xA;backward-compatibility, they also contain the number of sockets if it&#xA;is greater than 1.) &lt;code&gt;On virtual machines, the number of physical cores is more difficult to obtain&lt;/code&gt;, since VMs typically hide the difference&#xA;between physical and logical cores. In a properly configured VM with&#xA;hyper-threading, a total number of 16 logical cores would be counted&#xA;as 8 physical cores. To check how many physical cores are measured by&#xA;Gurobi, you can download and install Gurobi and use the &lt;code&gt;grbprobe&lt;/code&gt;&#xA;utility.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So, I tried the &lt;code&gt;grbprobe&lt;/code&gt; and here is the result:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;info  : grbprobe version , build v9.1.1rc0&#xA;HOSTNAME=packer-Ubuntu-18&#xA;HOSTID=a6400be&#xA;PLATFORM=linux64&#xA;USERNAME=ubuntu&#xA;SOCKETS=64&#xA;CORES=64&#xA;CPU=Intel(R) Xeon(R) CPU E5-2698 v4 @ 2.20GHz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10" LastEditorUserId="10" LastEditDate="2020-12-28T12:27:07.937" LastActivityDate="2020-12-28T12:27:07.937" Title="Gurobi and CPLEX cannot exploit more than 32 cores of machine" Tags="|optimization|cplex|scheduling|gurobi|parallel-computing|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5417" PostTypeId="2" ParentId="5416" CreationDate="2020-12-18T09:30:44.997" Score="7" Body="&lt;p&gt;You need to distinguish between threads and (physical) cores. Is it possible that the cores you see in your machine are actually just hyperthreads, i.e. 2 cores resemble one physical core?&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, using many cores is not always very helpful to solve a MIP. You may want to try something like &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/concurrent_optimizer.html#sec:Concurrent&quot; rel=&quot;noreferrer&quot;&gt;Concurrent Optimization in Gurobi&lt;/a&gt; to exploit performance variability and run several settings at once.&lt;/p&gt;&#xA;&lt;p&gt;Did you already &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/parameter_tuning_tool.html&quot; rel=&quot;noreferrer&quot;&gt;tune the solver parameters&lt;/a&gt;? In most cases, this is way more effective in reducing the solving time than just throwing more cores into the mix.&lt;/p&gt;&#xA;" OwnerUserId="141" LastEditorUserId="141" LastEditDate="2020-12-18T09:38:20.890" LastActivityDate="2020-12-18T09:38:20.890" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5418" PostTypeId="2" ParentId="5402" CreationDate="2020-12-18T10:32:32.057" Score="3" Body="&lt;p&gt;This analogy might help: CPU usage is like the power output of an engine - more is better in terms of performance. Memory usage is more like the heat produced by the engine - too much heat, aka memory capacity exceeded, and the engine breaks down.&lt;/p&gt;&#xA;&lt;p&gt;There is simply no reason in trying to increase or even max out memory usage.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2020-12-18T10:32:32.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5419" PostTypeId="1" CreationDate="2020-12-17T02:08:35.190" Score="2" ViewCount="457" Body="&lt;p&gt;I am using Google OR Tools for solving the capacitated vehicle routing problem.I want to implement optimization solution for delivery problem.For example there is one storage location which load all packages to multiple trucks which have multiple capacities. These trucks should deliver packages (no pickup) minimizing the total distance.&#xA;In &lt;a href=&quot;https://developers.google.com/optimization/routing/cvrp&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR-tools documentation there is a example for pickup and delivery problem&lt;/a&gt;,I am not able to modify this example for only delivery problem.&lt;/p&gt;&#xA;" OwnerUserId="4630" OwnerDisplayName="Rajith Thennakoon" LastEditorUserId="500" LastEditDate="2020-12-18T15:38:56.003" LastActivityDate="2020-12-18T15:38:56.003" Title="modify pickup and delivery problem to only delivery scenario in google OR-tools" Tags="|optimization|or-tools|vehicle-routing|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5421" PostTypeId="1" CreationDate="2020-12-20T16:21:03.507" Score="3" ViewCount="277" Body="&lt;p&gt;I've noticed that for integer programming models with binary variables some use upper bound constraints and others use big M constraints in order to have two mutually exclusive choices.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I have trouble understanding the difference and when to use one instead of the other?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Example of a lower upper bound constraint assuming &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; to be a binary variable : &lt;span class=&quot;math-container&quot;&gt;$x \leq 3y$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;From this constraint I understand that x can be at most &lt;span class=&quot;math-container&quot;&gt;$= 3$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$y = 1$&lt;/span&gt; otherwise &lt;span class=&quot;math-container&quot;&gt;$x \leq 0$&lt;/span&gt;. However usually we have non-negativity constraints so &lt;span class=&quot;math-container&quot;&gt;$x = 0$&lt;/span&gt; in this case.&lt;/p&gt;&#xA;&lt;p&gt;Example of a big M constraint assuming &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; to be a binary variable : &lt;span class=&quot;math-container&quot;&gt;$x_1 + x_2 + x_3 \leq 15 + M(1-y)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I understand that the expression at the left of the inequation can either be &lt;span class=&quot;math-container&quot;&gt;$\leq 15$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$y = 1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\leq \infty$&lt;/span&gt;. The latter suggest that we can have any values we want for left side.&lt;/p&gt;&#xA;" OwnerUserId="4077" LastEditorUserId="4077" LastEditDate="2020-12-20T18:41:17.267" LastActivityDate="2020-12-20T19:13:23.683" Title="In integer programming what's the difference between using lower upper bound constraints and using a big M constraints?" Tags="|mixed-integer-programming|linear-programming|integer-programming|big-m|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5422" PostTypeId="2" ParentId="5421" CreationDate="2020-12-20T19:13:23.683" Score="6" Body="&lt;p&gt;As Sune said in a comment, they really are both &amp;quot;big-M&amp;quot; constraints, differing (perhaps) in how &amp;quot;big&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is. If you choose &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; sufficiently large, then yes, your second constraint will not meaningfully limit the values of the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables ... which likely is by design. Other constraints in the model will probably restrict the values of those variables. For instance, your constraint might mean that shipments to three customers (left side) are limited to 15 units if being sent by air freight (&lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;). If being sent via ground transportation (&lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;), &lt;em&gt;this constraint&lt;/em&gt; does limit shipments to those customers ... but something else (supply, demand) will.&lt;/p&gt;&#xA;&lt;p&gt;Also, the &lt;span class=&quot;math-container&quot;&gt;$\le \infty$&lt;/span&gt; part is not entirely correct. There is a misconception, fostered in part by textbook authors who do not want to spend time or energy explaining how to choose values of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, that in a &amp;quot;big-M&amp;quot; constraint &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a stand-in for infinity. In practice, it should be as small as possible subject to the requirement that when &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt; the constraint becomes nonbinding. So, continuing my example, I would choose &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to be the smaller of supply for whatever is in the constraint or combined demand of the three customers. That implies that the left side when &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt; would not be unconstrained; it just would not be constrained enough to rule out valid choices. Choosing a stupid-large value for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; can result in numerical stability problems leading to incorrect answers from solvers.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-12-20T19:13:23.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5423" PostTypeId="1" AcceptedAnswerId="5425" CreationDate="2020-12-21T04:29:55.263" Score="10" ViewCount="574" Body="&lt;p&gt;I have an undirected graph such as the one shown below. I can make up to 3 choices about the color of each node. The edge weights are equal to the difference between the nodes, given by the &amp;quot;distance&amp;quot; between the colors chosen for each node. What is an algorithm I can use to choose the colors for the nodes such that the total edge weight is maximized?&lt;/p&gt;&#xA;&lt;p&gt;For example, say node 0 can be red, blue, or gray, and node 5 can be either blue or gold. If node 0 and node 5 were both blue, the edge between them would have low weight, which is not good. &lt;a href=&quot;https://i.stack.imgur.com/xHl6k.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xHl6k.png&quot; alt=&quot;Example graph&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have considered a few possibilities:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Brute-force search. While feasible for this example, where there are only &lt;code&gt;3*2*2*1*1*2 = 24&lt;/code&gt; total possible color combinations, my actual problem has well over 300 nodes, so this is not feasible.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Nonlinear optimization problem. I have written a formulation such that this small example can be solved in AMPL and Python's &lt;code&gt;scipy&lt;/code&gt;, but this also suffers from large complexity.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Maximum-cost network flow. I have tried to formulate this as a network flow problem, where each node represents a &amp;quot;choice&amp;quot; to be made about each actual node. However, I am unsure how to introduce appropriate constraints and/or dummy nodes such that I guarantee that the cost of the flow actually equals my objective function, and that the only feasible solutions in the flow problem &amp;quot;make sense&amp;quot; for my original problem.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There is also a chance that this problem is not really tractable, but I would not know how to show that.&lt;/p&gt;&#xA;&lt;p&gt;The actual use case of this problem is that I have a Voronoi diagram where each region corresponds to a different team. I can select one of up to 3 colors for each team to use for that team's region on the map, and I want to choose the colors such that the contrast between bordering regions is maximized.&lt;/p&gt;&#xA;&lt;p&gt;I originally posted this on StackOverflow but I was redirected here. Any idea on how to formulate this problem?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: After solving the problem, here was the resulting image, note that I removed pure black and white (to avoid obtaining a checkerboard). Lots of gold and navy blue!&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XzIqS.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XzIqS.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9724" LastEditorUserId="9724" LastEditDate="2021-01-23T05:12:59.613" LastActivityDate="2021-01-23T15:59:33.523" Title="How to maximize &quot;contrast&quot; between nodes on a graph?" Tags="|optimization|integer-programming|algorithms|graphs|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5424" PostTypeId="2" ParentId="5423" CreationDate="2020-12-21T09:01:13.633" Score="6" Body="&lt;p&gt;If you are dealing with Voronoi diagrams then perhaps your graph is planar, and in this case there is probably a good heuristic for the problem, but more details should be given I think before going down that road. In the mean time you can try working with a MIP as suggested by @SimonT. For example:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{vc}$&lt;/span&gt; be a binary variable that takes values &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if node &lt;span class=&quot;math-container&quot;&gt;$v\in V$&lt;/span&gt; is assigned color &lt;span class=&quot;math-container&quot;&gt;$c \in C(v)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$C(v)$&lt;/span&gt; denotes the set of choices for node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;. Also, let &lt;span class=&quot;math-container&quot;&gt;$\omega_c \in \mathbb{R}^+$&lt;/span&gt; denote the weight of color &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; (used to measure the distance between two nodes).&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$y_{uv}^{jk}$&lt;/span&gt; be another binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if colors &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; are assigned to nodes &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, respectively, with &lt;span class=&quot;math-container&quot;&gt;$(u,v) \in A, j \in C(u),  k \in C(v).$&lt;/span&gt; And let &lt;span class=&quot;math-container&quot;&gt;$z_{uv}$&lt;/span&gt; be a non negative variable that equals the distance between nodes &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You want to maximize the total edge weight:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \quad \sum_{(u,v)\in A} z_{uv}&#xA;$$&lt;/span&gt;&#xA;subject to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each node must be assigned exactly one color:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{c \in C(v)} x_{vc} = 1 \quad \forall v \in V&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; must be consistent:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;x_{uj}+x_{vk} &amp;amp;\le y_{uv}^{jk} +1 \quad &amp;amp;\forall (u,v) \in A, \forall j \in C(u), \forall k \in C(v) \\&#xA;y_{uv}^{jk} &amp;amp;\le  x_{uj} \quad &amp;amp;\forall (u,v) \in A, \forall j \in C(u), \forall k \in C(v) \\&#xA;y_{uv}^{jk} &amp;amp;\le  x_{vk} \quad &amp;amp;\forall (u,v) \in A, \forall j \in C(u), \forall k \in C(v)&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The distance between two vertices is the difference between the&#xA;weights of their colors:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z_{uv} = \sum_{j\in C(u)}\sum_{k\in C(v)}|\omega_j- \omega_k| y_{uv}^{jk} \quad \forall (u,v) \in A&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are binary:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x,y \in \{0,1\}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Variables &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; are non negative:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z\in \mathbb{R^+}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2020-12-21T09:06:56.327" LastActivityDate="2020-12-21T09:06:56.327" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5425" PostTypeId="2" ParentId="5423" CreationDate="2020-12-21T15:19:57.000" Score="6" Body="&lt;p&gt;You can solve this as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;quadratic assignment problem&lt;/em&gt;&lt;/a&gt;.  With the same &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables as in @Kuifje's answer, you want to maximize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{(u,v)\in A}\sum_{j\in C(u)}\sum_{k\in C(v)}|\omega_j- \omega_k| x_{u,j}x_{v,k} \tag1$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j \in C(v)} x_{u,j} = 1 \quad \text{for $v \in V$} \tag2$$&lt;/span&gt;&#xA;One approach is to call a mixed integer quadratic programming solver.&#xA;Alternatively, you can linearize the quadratic objective &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; by introducing binary (or just nonnegative) variables &lt;span class=&quot;math-container&quot;&gt;$y_{u,v}^{j,k}$&lt;/span&gt; and linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_{u,v}^{j,k} &amp;amp;\le x_{u,j} &amp;amp;&amp;amp;\text{for $(u,v) \in A, j \in C(u), k \in C(v)$} \tag3 \\&#xA;y_{u,v}^{j,k} &amp;amp;\le x_{v,k} &amp;amp;&amp;amp;\text{for $(u,v) \in A, j \in C(u), k \in C(v)$} \tag4 \\&#xA;\end{align}&lt;/span&gt;&#xA;and then maximize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{(u,v)\in A}\sum_{j\in C(u)}\sum_{k\in C(v)}|\omega_j- \omega_k| y_{u,v}^{j,k} \tag5$$&lt;/span&gt;&#xA;Notice that &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;-&lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; is very similar to @Kuifje's formulation but eliminates &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and also omits one set of &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; constraints.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;You can instead use &lt;em&gt;compact linearization&lt;/em&gt; as follows.  Maximize &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;, and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j \in C(u)} y_{u,v}^{j,k} = x_{v,k} \quad \text{for $(u,v) \in A$ and $k \in C(v)$} \tag6$$&lt;/span&gt;&#xA;You can derive &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; by multiplying both sides by &lt;span class=&quot;math-container&quot;&gt;$x_{j,v}$&lt;/span&gt; and replacing the resulting product with &lt;span class=&quot;math-container&quot;&gt;$y_{u,v}^{j,k}$&lt;/span&gt;, as in the &lt;em&gt;Reformulation-Linearization Technique (RLT)&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: After seeing the resulting map, which has several bordering regions with similar colors like gold and yellow, I think you want a slightly different objective.  Instead of maximizing the &lt;em&gt;sum&lt;/em&gt; of the edge weights, I recommend maximizing the &lt;em&gt;minimum&lt;/em&gt; of the edge weights, which you can do as follows.  Introduce a new variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and maximize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt;, and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z \le \sum_{j\in C(u)}\sum_{k\in C(v)}|\omega_j- \omega_k| y_{u,v}^{j,k} \quad \text{for $(u,v)\in A$} \tag7$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, both objectives treat all borders the same, so a short border accrues the same reward as a long border.  If you have access to the length &lt;span class=&quot;math-container&quot;&gt;$\ell_{u,v}$&lt;/span&gt; of the border between &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, you might get better results by replacing &lt;span class=&quot;math-container&quot;&gt;$|\omega_j- \omega_k|$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\ell_{u,v} |\omega_j- \omega_k|$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-01-23T15:59:33.523" LastActivityDate="2021-01-23T15:59:33.523" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5426" PostTypeId="1" CreationDate="2020-12-21T17:45:20.313" Score="4" ViewCount="282" Body="&lt;p&gt;When we use Lagrangian relaxation-based methods to solve mixed integer programming, does the convergence of multipliers to the optimum as well as convergence of primal variables to the optimum happen at the same time?&lt;/p&gt;&#xA;" OwnerUserId="4637" LastEditorUserId="67" LastEditDate="2020-12-21T21:56:59.703" LastActivityDate="2020-12-21T23:50:43.143" Title="Using LR-based method to solve mixed integer programming" Tags="|mixed-integer-programming|lagrangian-relaxation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5427" PostTypeId="2" ParentId="5426" CreationDate="2020-12-21T23:50:43.143" Score="5" Body="&lt;p&gt;As its name indicates, a Lagrangian relaxation is a relaxation and therefore only provides a dual bound. If you are interested in getting a primal solution, you have several ways to exploit a Lagrangian relaxation:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Designing a procedure to &amp;quot;repair&amp;quot; the infeasible solutions generated at each iteration of the resolution method of the Lagrangian relaxation (bundle method, subgradient method...). Thus, at each iteration of the Lagrangian relaxation resolution, you should get better solutions since the dual information that you get becomes more and more accurate. However, there is no guarantee to get the optimal solution at the end or even just to get a feasible solution. This can be a good choice if solving the Lagrangian relaxation is so costly that it does not terminate within your time limit. An example for the Set Covering Problem: &amp;quot;A lagrangian heuristic for set‐covering problems&amp;quot; (Beasley, 1990)&lt;/li&gt;&#xA;&lt;li&gt;Embedding the Lagrangian relaxation inside a branch-and-bound algorithm. It is similar to a LP-based branch-and-bound, but at each node, you solve a (whole) Lagrangian relaxation instead of a linear relaxation. Therefore, you get optimal multipliers at each node for the corresponding node subproblem. The branch-and-bound provides an improving global dual bound as the search goes and if it terminates, it guarantees to return the optimal solution if there is one. An example for the Generalized Assignment Problem: &amp;quot;An exact method with variable fixing for solving the generalized assignment problem&amp;quot; (Posta et al., 2012)&lt;/li&gt;&#xA;&lt;li&gt;Computing the relaxation and then using the Lagrangian information inside another algorithm, for example inside a local search algorithm. Usually, there is no guarantee to find the optimal solution. An example for the Generalized Assignment Problem: &amp;quot;A path relinking approach with ejection chains for the generalized assignment problem&amp;quot; (Yagiura et al., 2006). Another example for the Set Covering Problem: &amp;quot;A Heuristic Method for the Set Covering Problem&amp;quot; (Caprara et al., 1999)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2020-12-21T23:50:43.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5428" PostTypeId="1" AcceptedAnswerId="5433" CreationDate="2020-12-22T08:25:48.280" Score="5" ViewCount="248" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; be a feasible solution of the following convex optimization problem &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad f_0(x)\\\text{s.t.}&amp;amp;\quad f_i(x)\leq0,i=1,\ldots,m\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$f_0$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$C^1$&lt;/span&gt; and convex and &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$C^1$&lt;/span&gt; and strictly convex functions. Suppose the following condition is satisfied:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;there exist &lt;span class=&quot;math-container&quot;&gt;$y_i\geq0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in\{0\}\cup I(x^*)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$I(x^*)=\{i:f_i(x^*)=0\}$&lt;/span&gt; which are not all zeroes such that &lt;span class=&quot;math-container&quot;&gt;$y_0\nabla f_0(x^*)+\sum\limits_{i\in I(x^*)}y_i\nabla f_i(x^*)=0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Prove that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is an optimal solution.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I've tried to set &lt;span class=&quot;math-container&quot;&gt;$S(x)=y_0f_0(x^*)+\sum\limits_{i\in I(x^*)}y_if_i(x^*)$&lt;/span&gt;. Then &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is a convex function as it is a sum of convex functions and &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is minimizer of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; because &lt;span class=&quot;math-container&quot;&gt;$\nabla S(x^*)=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$f(x^*)=y_0f_0(x^*)+\sum_{i\in I(x^*)}y_if_i(x^*)=S(x^*).$$&lt;/span&gt; Using the gradient inequality we get &lt;span class=&quot;math-container&quot;&gt;$0=y_0\nabla f_0(x^*)+\sum_{i\in I(x^*)}y_i\nabla f_i(x^*)$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$$0=\left(y_0\nabla f_0(x^*)+\sum_{i\in I(x^*)}y_i\nabla f_i(x^*)\right)^\top(y-x)&amp;lt;S(y)-S(x^*)$$&lt;/span&gt; which implies that &lt;span class=&quot;math-container&quot;&gt;$S(y)&amp;gt;S(x^*)$&lt;/span&gt;. This is the same as &lt;span class=&quot;math-container&quot;&gt;$$y_0f_0(y)+\sum_{i\in I(x^*)}y_if_i(y)&amp;gt;y_0f_0(x^*)+\sum_{i\in I(x^*)}y_if_i(x^*)=y_0f_0(x^*)$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_0f_0(y)+\sum_\limits{i\in I(x^*)}y_if_i(y)\leq y_0f_0(y)$&lt;/span&gt; because &lt;span class=&quot;math-container&quot;&gt;$y_i\geq0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_i(y)\leq0$&lt;/span&gt;. Thus &lt;span class=&quot;math-container&quot;&gt;$$y_0f_0(y)&amp;gt;y_0f_0(x^*)\iff f_0(y)&amp;gt;f_0(x^*)$$&lt;/span&gt; which is the desired result. The strong inequality is because &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; are strictly convex.&#xA;Where &lt;span class=&quot;math-container&quot;&gt;$y_0\neq0$&lt;/span&gt;&lt;br /&gt;&#xA;Now I need to solve the case when &lt;span class=&quot;math-container&quot;&gt;$y_0=0$&lt;/span&gt; any hint?&lt;/p&gt;&#xA;" OwnerUserId="4526" LastEditorUserId="4526" LastEditDate="2020-12-23T09:56:31.533" LastActivityDate="2020-12-23T12:52:11.817" Title="Prove that $x^*$ is an optimal solution where $f_0$ is $C^1$ and convex and $f_i$ are $C^1$ and strictly convex functions" Tags="|optimization|convex-optimization|kkt-conditions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5429" PostTypeId="1" AcceptedAnswerId="5430" CreationDate="2020-12-22T10:42:25.293" Score="4" ViewCount="686" Body="&lt;p&gt;I investigating various aspects of MIP and I can see that my current modelling langaunge support Special Ordered Sets(&lt;a href=&quot;https://python-mip.readthedocs.io/en/latest/sos.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://python-mip.readthedocs.io/en/latest/sos.html&lt;/a&gt;) but looking at the papers they are from 1978 and 1984, and there seems very little online material about them and which leaves me the question should I use these and does any body having good experiences of using them in recent time?&lt;/p&gt;&#xA;" OwnerUserId="4591" LastActivityDate="2020-12-23T14:08:42.997" Title="Should I use Special Ordered Sets in MIP model" Tags="|mixed-integer-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5430" PostTypeId="2" ParentId="5429" CreationDate="2020-12-22T14:33:18.880" Score="4" Body="&lt;p&gt;As long as the solver you pass that information to also supports SOS, and as long as the modelling environment has an SOS interface for that solver, you can notice massive differences in performance for some problems. As usual, this is not always the case, but it works great a lot of the time.&lt;/p&gt;&#xA;&lt;p&gt;You can see why (from a more intuitive point of view than the papers) in Jeff Linderoth's &lt;a href=&quot;https://homepages.cae.wisc.edu/%7Elinderot/classes/ie418/lecture2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;lecture notes&lt;/a&gt; on SOS.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2020-12-22T14:33:18.880" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5431" PostTypeId="2" ParentId="5359" CreationDate="2020-12-22T15:28:14.857" Score="2" Body="&lt;p&gt;I have some experience with theoretical work around large systems of inequalities, and I found these packages very useful:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://cgm.cs.mcgill.ca/%7Eavis/C/lrs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;lrslib&lt;/strong&gt;&lt;/a&gt; - computational geometry package, in exact arithmetics, created by David Avis from McGill University. One of its key functionalities is &lt;a href=&quot;http://cgm.cs.mcgill.ca/%7Eavis/C/lrslib/USERGUIDE.html#redund&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;redund&lt;/strong&gt;&lt;/a&gt; - quick and efficient removal of redundant inequalities from an H-representaion of a convex polytope. There is also an option to do this in parallel.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.normaliz.uni-osnabrueck.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;normaliz&lt;/strong&gt;&lt;/a&gt; - another amazing project that I found very useful in working with large systems of inequalities in exact arithmetics.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The functionalities of the two packages have a partial overlap, but the implementations differ. I found that they complemented each other nicely as the shapes and sizes of the inputs varied.&lt;/p&gt;&#xA;" OwnerUserId="2616" LastEditorUserId="2616" LastEditDate="2020-12-22T19:27:13.603" LastActivityDate="2020-12-22T19:27:13.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5433" PostTypeId="2" ParentId="5428" CreationDate="2020-12-23T10:48:39.170" Score="3" Body="&lt;p&gt;Note that by assumption, there must be some &lt;span class=&quot;math-container&quot;&gt;$i \in I(x^*) \cup \{0\}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$y_i \ne 0$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$\mathcal I = \{i \in I(x^*) \cup \{0\} \mid y_i \ne 0\}$&lt;/span&gt; be the set of such indices.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; be any unit vector of the same dimension as &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;. We wish to show that &lt;span class=&quot;math-container&quot;&gt;$x^* + tu$&lt;/span&gt; is either not feasible or has weakly worse objective for any positive scalar &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. To show this, choose an index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; from the set &lt;span class=&quot;math-container&quot;&gt;$\mathcal I$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\nabla f_i(x^*) \cdot u \geq 0$&lt;/span&gt;, which is possible because the following sum cannot have all negative terms.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in \mathcal I} y_i(\nabla f_i(x^*) \cdot u)&#xA;= \left(\sum_{i \in \mathcal I} y_i\nabla f_i(x^*)\right) \cdot u&#xA;= 0.&#xA;$$&lt;/span&gt;&#xA;Note that the sum above is just the original expression with all terms where &lt;span class=&quot;math-container&quot;&gt;$y_i = 0$&lt;/span&gt; removed and the &lt;span class=&quot;math-container&quot;&gt;$i = 0$&lt;/span&gt; term included into the sum if &lt;span class=&quot;math-container&quot;&gt;$y_0$&lt;/span&gt; is nonzero.&lt;/p&gt;&#xA;&lt;p&gt;However it now follows from &lt;span class=&quot;math-container&quot;&gt;$\nabla f_i(x^*) \cdot u \geq 0$&lt;/span&gt; that &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; is non-decreasing in the direction &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$i = 0$&lt;/span&gt;, it follows by weak convexity that &lt;span class=&quot;math-container&quot;&gt;$f_0(x^* + ut) \geq f_0(x^*)$&lt;/span&gt; for every positive &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Thus &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is optimal in this direction.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$i \ne 0$&lt;/span&gt;, it follows from strong convexity that &lt;span class=&quot;math-container&quot;&gt;$f_i(x^* + ut) &amp;gt; f_i(x^*) = 0$&lt;/span&gt; for every positive &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Thus &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is the only feasible solution in this direction.&lt;/p&gt;&#xA;&lt;p&gt;It now follows that all other solutions are either infeasible or have &lt;span class=&quot;math-container&quot;&gt;$f_0(y) \geq f_0(x^*)$&lt;/span&gt;. Thus &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is optimal.&lt;/p&gt;&#xA;&lt;p&gt;Note that if you assume that &lt;span class=&quot;math-container&quot;&gt;$y_0 = 0$&lt;/span&gt; as in your question, the above argument concludes that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is the only feasible solution.&lt;/p&gt;&#xA;" OwnerUserId="4641" LastEditorUserId="4641" LastEditDate="2020-12-23T12:52:11.817" LastActivityDate="2020-12-23T12:52:11.817" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5434" PostTypeId="2" ParentId="5429" CreationDate="2020-12-23T14:08:42.997" Score="3" Body="&lt;p&gt;There are two aspects to Special Ordered Sets.  The first is that they can make the model definition simpler and thereby make the intent clearer.&lt;/p&gt;&#xA;&lt;p&gt;The second is that a particular solver &lt;strong&gt;may&lt;/strong&gt; use dedicated algorithms to assist solution times.&lt;/p&gt;&#xA;&lt;p&gt;As originally developed, there are two types of Special Ordered Sets.  The first, SOS1, is used when it is required to select exactly one option from a choice of several.  The second type, SOS2 are used to select one or two (adjacent) variables and are typically used to approximate a non-linear function (objective or constraint) by a set of piece-wise linear elements.&lt;/p&gt;&#xA;&lt;p&gt;The only real potential downside is that if it is required to port the model to some other environment the Special Ordered Sets may not be available or defined in a different way.  However, this can be overcome if it arises and I wouldn't consider it as a major drawback.&lt;/p&gt;&#xA;" OwnerUserId="4643" LastActivityDate="2020-12-23T14:08:42.997" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5435" PostTypeId="1" CreationDate="2020-12-23T17:22:47.010" Score="4" ViewCount="479" Body="&lt;p&gt;What is the appropriate measure to indicate the efficiency of an algorithm\model that solves a MILP through B&amp;amp;B?&lt;/p&gt;&#xA;&lt;p&gt;Is it&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the number of nodes examined to reach the optimum?&lt;/li&gt;&#xA;&lt;li&gt;the number of iterations to reach the optimum?&lt;/li&gt;&#xA;&lt;li&gt;the computing time required to reach the optimum?&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I would favour the computing time but is there anything that speaks against that?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2020-12-24T11:57:24.707" Title="What expresses the efficiency of an algorithm when solving MILPs" Tags="|mixed-integer-programming|branch-and-bound|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5436" PostTypeId="2" ParentId="5435" CreationDate="2020-12-23T17:33:10.497" Score="5" Body="&lt;p&gt;For algorithms, hands down number of nodes, assuming you are not solving numerous (MI)LPs/node (e.g. you are not doing strong branching). This is how we evaluate potential when we prototype new algorithms at Octeract.&lt;/p&gt;&#xA;&lt;p&gt;The reason is that the steps performed per node can be optimised in many ways, while the number of nodes we need to explore is purely a result of the algorithm(s) used.&lt;/p&gt;&#xA;&lt;p&gt;Computing time is not a very good one, because it's very sensitive to implementation rather than a result of the algorithm itself. I've achieved improvements of 20,000x just by optimising code for existing algorithms. If we were evaluating using time, those algorithms would never have passed the test, but after optimisations they were really good.&lt;/p&gt;&#xA;&lt;p&gt;Computing time becomes a more relevant metric when tuning a solver with highly optimised code. Even then, a trained eye can identify steps to skip altogether without changing the overarching algorithm.&lt;/p&gt;&#xA;&lt;p&gt;As people have pointed out there is merit to computing time, but I'll just give an example as to how misleading this can be when developing an algorithm. Say I have two algorithms, A and B. A converges in 100 iterations and 100 seconds, B converges in 10 iterations and 500 seconds. Closer analysis reveals that B is slower because the linear solver solving the relaxation gets stuck on one node and spends 480 seconds on that 1 node. &lt;strong&gt;Even though it's slower, algorithm B is clearly superior to algorithm A.&lt;/strong&gt; B is simply slower because of implementation issues which can be addressed (e.g. by switching to a different LP solver).&lt;/p&gt;&#xA;&lt;p&gt;This is not an academic example btw, we deal with issues like this every day.&lt;/p&gt;&#xA;&lt;p&gt;Since you mentioned number of iterations, for a branch-and-bound algorithm that's pretty much interchangeable with the number of nodes, so either goes. Number of iterations is also the equivalent of what I describe for non-BnB algorithms, e.g., interior point. There we would care much less about cost per iteration (when it comes to evaluating the algorithm itself) than we would about the number of iterations.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2020-12-23T19:56:38.367" LastActivityDate="2020-12-23T19:56:38.367" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5437" PostTypeId="2" ParentId="5435" CreationDate="2020-12-23T18:58:53.463" Score="9" Body="&lt;p&gt;I agree with Erwin's comment about heuristics and strong branching. When comparing algorithms or models, I would lean toward compute time, with a few caveats:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;they would have to be tested on the same hardware, using the same number of cores/threads;&lt;/li&gt;&#xA;&lt;li&gt;they would have to be tested on multiple problem instances;&lt;/li&gt;&#xA;&lt;li&gt;they would have to use the same solver (if comparing models) or be coded equally well (if comparing algorithms);&lt;/li&gt;&#xA;&lt;li&gt;they should be compared on both time to find the optimal solution (or progress on the primal bound) and time to prove optimality (or progress on the dual bound).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The first two points should be fairly obvious. The third point reflects the fact that a lot of person-hours of professional coders goes into creating CPLEX or Gurobi, while a limited number of person-hours of hack coding goes into anything I create. If testing, say, my cut generation subroutine versus someone else's, I would want to code theirs rather than rely on their published code (which might be better or worse than mine for reasons unrelated to the efficiency of the respective cuts).&lt;/p&gt;&#xA;&lt;p&gt;As to the fourth point, some people (particularly academics) feel the need to reach proven optimality, and other people just need a good (or really good) solution in a &amp;quot;reasonable&amp;quot; amount of time. For the former, time to proven optimality is the obvious measure, regardless of whether the optimal solution pops up in the first few seconds or the last few seconds. For the latter, a performance profile (comparing solution quality over time) makes more sense, since it is unclear how patient they will be (and how that patience will translate into time, since 30 minutes on their 64 core computing beast is not 30 minutes on my 4 core desktop PC).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-12-23T18:58:53.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5438" PostTypeId="2" ParentId="5435" CreationDate="2020-12-23T22:06:23.503" Score="7" Body="&lt;p&gt;Obviously, the only universally valid (but little useful) answer is: it depends.&#xA;One reason is that, as mentioned in other answers, implementation has a huge impact on practical performance.&lt;/p&gt;&#xA;&lt;p&gt;That being said:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;No matter which metric you choose, I would look at each approach's scalability w.r.t problem size.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There exist various statistical tests &amp;amp; comparison tools (from geometric mean of computing time to performance profiles) for assessing performance. Each has its pros and cons. You can read more in &lt;a href=&quot;https://youtu.be/9H823EloFIA&quot; rel=&quot;noreferrer&quot;&gt;this lecture&lt;/a&gt; at the &lt;a href=&quot;https://co-at-work.zib.de/&quot; rel=&quot;noreferrer&quot;&gt;CO@Work workshop &lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In addition to @prubin's answer: unless that's the component you're comparing, I would recommend to extract the presolved models (you can do so with Gurobi), and then run each approach on them. Presolve is so important that, otherwise, you may be comparing apples and oranges.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you are deciding &amp;quot;should I use algorithm A or B to solve problem X in real life?&amp;quot;, then computing time would likely be the most relevant, &lt;strong&gt;BUT&lt;/strong&gt; bear in mind that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It is not deterministic&lt;/li&gt;&#xA;&lt;li&gt;It is impacted by many things, including: the machine you're using, how many cores you are using, whether other processes are running at the same time, etc.&#xA;I've seen problems take 3x longer to solve just because I was running other tasks on my machine at the same time, and I typically see at least 20-30% variability (same code, same problem, same machine specs) on a shared computing cluster.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Number of nodes/simplex iterations is a &amp;quot;cleaner&amp;quot; metric, but again, it does not necessarily tell the whole story: are you &amp;quot;better&amp;quot; if you're exploring 10x less nodes, but each node is 100x slower?&#xA;You may look at &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-319-93031-2_43&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt; and &lt;a href=&quot;https://arxiv.org/pdf/2002.05120.pdf&quot; rel=&quot;noreferrer&quot;&gt;this one&lt;/a&gt;, which introduce &amp;amp; discuss some performance metrics (e.g. the &amp;quot;fair&amp;quot; number of nodes).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Other metrics include primal, dual, primal-dual integral (see e.g. &lt;a href=&quot;https://doi.org/10.1016/j.orl.2013.08.007&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, particularly useful to assess the ability to find good solutions/ good dual bounds fast.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;All in all: you probably want a combination of several metrics :)&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2020-12-23T22:06:23.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5439" PostTypeId="2" ParentId="5435" CreationDate="2020-12-24T11:57:24.707" Score="1" Body="&lt;p&gt;To be clear, we should distinguish between the following two comparisons:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;measuring the quality of a model solved by a B&amp;amp;B algorithm&lt;/li&gt;&#xA;&lt;li&gt;measuring the efficiency of a B&amp;amp;B algorithm that solves a given model&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The first comparrison has been extensively studied for MILP problems solved by LP-based B&amp;amp;B algorithms. Regarding the second comparison, I add the &lt;code&gt;time per node&lt;/code&gt; measure since it indicates how difficult it is to explore a node. This measure is quite useful since it explains why a model may be solved faster by an algorithm that uses a relatively larger number of nodes. The &lt;code&gt;time per iteration&lt;/code&gt; can also be used if an LP-based B&amp;amp;B algorithm is used. It indicates how fast the LP-relaxations are solved. This measure proves useful in cases where the quality of the LP-relaxation bounds are good, but each LP is solved relatively slowly which results in a larger overall time. A time-independent measure would be the number of &lt;code&gt;iterations per node&lt;/code&gt; which removes the drawbacks of the computational time. This measure somewhat shows how difficult the LP-relaxations of the model are. Note that the solution time of each LP is dependent on the number of variables and constraints as well as the number of non-zero elements in the coefficient matrix.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2020-12-24T11:57:24.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5440" PostTypeId="2" ParentId="5416" CreationDate="2020-12-25T20:26:52.140" Score="7" Body="&lt;p&gt;Modern CPUs are very complex and have at least two features that limit their scaling capability. The first one is a turbo feature that increases the clock speed when not all cores are utilized. The second one is that all cores share the same memory bus and the same L2 and L3 cache. If you solve the same problem in parallel (so start Python twice and let each solve the same problem), you will notice that it takes longer than solving just one problem, even though in both cases a single problem is solved by 32 dedicated cores.&lt;/p&gt;&#xA;&lt;p&gt;The second issue is algorithmic. Since you mention a scheduling problem, I assume there are binary variables, so there are many continuous subproblems. Solving one subproblem can be paralellized. For the simplex method, &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/ijoc.12.1.45.11902&quot; rel=&quot;noreferrer&quot;&gt;this article&lt;/a&gt; by Bixby and Martin (Bixby co-founded CPLEX and Gurobi, he is the 'bi' in 'Gurobi') shows good scaling up to 4 cores. The barrier method uses a sparse Cholesky factorization, which can also be parallelized (I cannot find a reference for how CPLEX/Gurobi do this, although with certain structure you &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-003-0379-5&quot; rel=&quot;noreferrer&quot;&gt;can do better than CPLEX/Gurobi&lt;/a&gt;). &lt;a href=&quot;https://link.springer.com/article/10.1007/s00186-012-0390-9&quot; rel=&quot;noreferrer&quot;&gt;This article&lt;/a&gt; from 2012 (&lt;a href=&quot;https://coral.ise.lehigh.edu/%7Eted/files/papers/Million11.pdf&quot; rel=&quot;noreferrer&quot;&gt;free preprint here&lt;/a&gt;) shows in Section 7.1 how well the barrier algorithms of CPLEX and Gurobi scale. Figure 5 shows that there is hardly any gain going from 16 to 32 cores (the efficiency drops by almost 50%), which  is also commented on in the text (search for &amp;quot;16 threads&amp;quot;). In CPLEX, &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.1/ilog.odms.cplex.help/CPLEX/UsrMan/topics/parallel_optim/multi_threaded_parallel/08_Interactive.html&quot; rel=&quot;noreferrer&quot;&gt;only the barrier method supports parallelization&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Linear programming models (LPs) are solved by default with the dual simplex algorithm. The dual simplex algorithm does not use multiple threads. In order to benefit from parallel execution for LP, you need to invoke the barrier or concurrent optimizers explicitly.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;For branch&amp;amp;bound, the simplex method is typically preferrable because it is much better at warm starting.&lt;/p&gt;&#xA;&lt;p&gt;So, the real question is how CPLEX and Gurobi perform branch&amp;amp;bound on a multicore machine. Do they solve nodes in parallel, or they solve one node at a time. For the latter, there is hardly any gain going above 16 cores, whereas for the former there is a trade-off between solving a few nodes quickly and pruning the branch&amp;amp;bound tree, and solving many nodes with the single threaded simplex or barrier method. Prior to CPLEX 11 you could actually control this behavior with the MipThreads and BarThreads parameters, but now there is no such option anymore. I suspect that it defaults to solving &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/Threads.html&quot; rel=&quot;noreferrer&quot;&gt;CPX_PARAM_THREADS&lt;/a&gt; nodes, each with a single threaded instance of dual simplex. Cplex then waits until all nodes are finished to continue. In the node log you can how much time is spent waiting. You can change this behavior by changing &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/ParallelMode.html&quot; rel=&quot;noreferrer&quot;&gt;CPX_PARAM_PARALLELMODE&lt;/a&gt; to -1 (CPX_PARALLEL_OPPORTUNISTIC).&lt;/p&gt;&#xA;&lt;p&gt;My suspicicion is that 64 instances of dual simplex do not run as fast as 32 instances, even though you have 64 cores, due to what I described in the first paragraph. You could test that experimentally. On top of that, it is possible that most of the work done by the extra cores is wasted because those nodes would be pruned otherwise. By inspecting the node log you could verify how many extra nodes were solved.&lt;/p&gt;&#xA;" OwnerUserId="538" LastActivityDate="2020-12-25T20:26:52.140" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5442" PostTypeId="1" AcceptedAnswerId="5443" CreationDate="2020-12-26T05:56:54.100" Score="4" ViewCount="205" Body="&lt;p&gt;Background: I have a set of ZIP codes (e.g., all of the state of Wisconsin), and am trying to figure out an optimization-based approach to identify a subset of these ZIP codes for a logistics service area.  Whether or not to include each ZIP code is a binary decision variable, &lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i=1 \ldots N$&lt;/span&gt;.  Each ZIP code has a cost and benefit to its inclusion in the service area; these will be used in the objective function and some constraints (objective function will be linear, and the costs &amp;amp; benefits constraints will be linear)&lt;/p&gt;&#xA;&lt;p&gt;What I'm having trouble with is the requirement that the selected ZIPs need to be contiguous, i.e., you need to be able to travel from any selected ZIP, to any other selected ZIP, by traveling through selected ZIPs.  I have a rough idea how to formulate this using nonlinear constraints and concepts from graph theory, but I would like to understand if there are any papers or references that might already suggest how to approach it.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastEditorUserId="491" LastEditDate="2022-01-07T16:09:47.617" LastActivityDate="2022-01-07T16:09:47.617" Title="Contiguous service area constraint" Tags="|integer-programming|nonlinear-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5443" PostTypeId="2" ParentId="5442" CreationDate="2020-12-26T11:31:26.133" Score="8" Body="&lt;p&gt;These are called &lt;em&gt;contiguity constraints&lt;/em&gt;.  See &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2020/01/7582.pdf&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt; for models and references.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-12-26T11:31:26.133" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5445" PostTypeId="2" ParentId="5416" CreationDate="2020-12-27T05:19:05.747" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BvT4v.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Your screenshot here&lt;/a&gt; indicates to me that you have 32 physical cores, 64 threads, and 64 vCPUs. You observed that Gurobi and CPLEX are not making use of more than 32 cores, but you have not shown us anything indicating that your machine has ever successfully used more than 32 cores &lt;em&gt;for any calculation&lt;/em&gt; that doesn't use hyperthreading. If you try other software (such as MATLAB, or even just a few lines of code written by yourself only for the purpose of testing), you may find that there's nothing special here about Gurobi or CPLEX, as no other program is able to use more than 32 cores either, as long as hyperthreading is turned off.&lt;/p&gt;&#xA;&lt;p&gt;You can also check this by checking the name of your CPU. If it says &amp;quot;Intel&amp;quot; anywhere then it does not have more than 32 physical cores unless it's a Xeon Phi in the x200 series, for which &lt;a href=&quot;https://web.archive.org/web/20171111044329/https://research.spec.org/icpe_proceedings/2014/p137.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;it is very well-known that the speed-up is not linear with the number of cores&lt;/a&gt; and does not resemble the physical cores of standard CPUs. If the name of your CPU does not contain &amp;quot;AMD RYZEN&amp;quot; or &amp;quot;AMD EPYC&amp;quot; anywhere, then your CPU is very unlikely to have more than 32 physical cores. I highly recommend you tell us the name of your CPU next time, as the &lt;a href=&quot;https://or.stackexchange.com/a/5417/727&quot;&gt;highest-voted answer&lt;/a&gt; also suspected the same thing as me (and they turned out to be right). As the &lt;a href=&quot;https://or.stackexchange.com/a/5440/727&quot;&gt;other answer&lt;/a&gt; says: &amp;quot;Modern CPUs are very complex&amp;quot; so when asking a question about high-performance computing, it's always very important to tell us not only the name and version of your operating system, but also the name and version of your hardware (i.e. CPU, GPU, etc.).&lt;/p&gt;&#xA;" OwnerUserId="727" LastActivityDate="2020-12-27T05:19:05.747" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="5449" PostTypeId="1" CreationDate="2020-12-29T22:50:02.947" Score="4" ViewCount="391" Body="&lt;p&gt;I am studying the book by Martin Osborne &amp;quot;An Introduction to Game Theory&amp;quot;. My background is IE and I am more familiar with OR. Is there any book that teaches Game theory in Operations Research framework? If its concentration is on revenue management, it will be better.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="2477" LastEditDate="2020-12-30T21:33:04.057" LastActivityDate="2021-01-12T19:31:22.300" Title="References for Game theory with Operations Research Orientation" Tags="|reference-request|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5450" PostTypeId="2" ParentId="5449" CreationDate="2020-12-30T02:27:26.500" Score="4" Body="&lt;p&gt;I'm not sure exactly what you mean by Operations Research framework, but I'll interpret a mathematical treatment, heavy on O.R. and optimization material, as fitting the bill.&lt;/p&gt;&#xA;&lt;p&gt;The book &lt;a href=&quot;https://www.elsevier.com/books/mathematical-methods-and-theory-in-games-programming-and-economics/karlin/978-1-4831-9795-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mathematical Methods and Theory in Games, Programming, and Economics, 1st Edition: Matrix Games, Programming, and Mathematical Economics, by Samuel Karlin&lt;/a&gt;&#xA;was published in 1959. An oldie but goodie. This is not a book on &amp;quot;Game Theory applied to Revenue Management&amp;quot;, however. But it should provide a solid foundation which you can supplement with more recent material.&lt;/p&gt;&#xA;&lt;p&gt;When I was taking a course in Total Positivity from Karlin in Fall 1980, somehow the topic of Game Theory came up.&lt;br /&gt;&#xA;&lt;strong&gt;Karlin&lt;/strong&gt;: &amp;quot;Game Theory. You have two nonnegative sigma-finite measures ...&amp;quot;&#xA;Then he mentioned this book, which was 21 years old at the time. &amp;quot;It should be out of date, but it isn't.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Matrix Games, Programming, and Mathematical Economics deals with game theory, programming theory, and techniques of mathematical economics in a single systematic theory. The principles of game theory and programming are applied to simplified problems related to economic models, business decisions, and military tactics. The book explains the theory of matrix games and some of the tools used in the analysis of matrix games. The text describes optimal strategies for matrix games which have two basic properties, as well as the construction of optimal strategies. The book investigates the structure of sets of solutions of discrete matrix games, with emphasis on the class of games whose solutions are unique. The examples show the use of dominance concepts, symmetries, and probabilistic arguments that emphasize the principles of game theory. One example involves two opposing political parties in an election campaign, particularly, how they should distribute their advertising efforts for wider exposure. The text also investigates how to determine an optimal program from several choices that results with the maximum or minimum objective. The book also explores the analogs of the duality theorem, the equivalence of game problems to linear programming problems, and also the inter-industry nonlinear activity analysis model requiring special mathematical methods. The text will prove helpful for students in advanced mathematics and calculus. It can be appreciated by mathematicians, engineers, economists, military strategists, or statisticians who formulate decisions using mathematical analysis and linear programming.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Introduction. the Nature of the Mathematical Theory of Decision Processes&lt;br /&gt;&#xA;1 The Background&lt;br /&gt;&#xA;2 The Classification of the Mathematics of Decision Problems&lt;br /&gt;&#xA;3 The Main Disciplines&lt;/p&gt;&#xA;&lt;p&gt;Part I. The Theory of Matrix Games&lt;/p&gt;&#xA;&lt;p&gt;Chapter 1. The Definition of a Game and the Min-Max Theorem&#xA;1.1 Introduction. Games in Normal Form&lt;br /&gt;&#xA;1.2 Examples&lt;br /&gt;&#xA;1.3 Choice of Strategies&lt;br /&gt;&#xA;1.4 The Min-Max Theorem for Matrix Games&lt;br /&gt;&#xA;1.5 General Min-Max Theorem&lt;/p&gt;&#xA;&lt;p&gt;Chapter 2. The Nature of Optimal Strategies for Matrix Games&#xA;2.1 Properties of Optimal Strategies&lt;br /&gt;&#xA;2.2 Types of Strict Dominance&lt;br /&gt;&#xA;2.3 Construction of Optimal Strategies&lt;br /&gt;&#xA;2.4 Characterization of Extreme-Point Optimal Strategies&lt;br /&gt;&#xA;2.5 Completely Mixed Matrix Games&lt;br /&gt;&#xA;2.6 Symmetric Games&lt;/p&gt;&#xA;&lt;p&gt;Chapter 3. Dimension Relations for Sets of Optimal Strategies&lt;br /&gt;&#xA;3.1 The Principal Theorems&lt;br /&gt;&#xA;3.2 Proof of Theorem 3.1.1&lt;br /&gt;&#xA;3.3 Proof of Theorem 3.1.2&lt;br /&gt;&#xA;3.4 The Converse of Theorem 3.1.2&lt;br /&gt;&#xA;3.5 Uniqueness of Optimal Strategies&lt;/p&gt;&#xA;&lt;p&gt;Chapter 4. Solutions of Some Discrete Games&lt;br /&gt;&#xA;4.1 Colonel Blotto Game&lt;br /&gt;&#xA;4.2 Identification of Friend and Foe (I.F.F. Game)&lt;br /&gt;&#xA;4.3 Poker Game&lt;br /&gt;&#xA;4.4 An Advertising Example&lt;br /&gt;&#xA;4.5 a Bargaining Example&lt;/p&gt;&#xA;&lt;p&gt;Part II. Linear and Nonlinear Programming and Mathematical Economics&lt;/p&gt;&#xA;&lt;p&gt;Chapter 5. Linear Programming&lt;br /&gt;&#xA;5.1 Formulation of the Linear Programming Problem&lt;br /&gt;&#xA;5.2 The Linear Programming Problem and its Dual&lt;br /&gt;&#xA;5.3 The Principal Theorems of Linear Programming (Preliminary Results)&lt;br /&gt;&#xA;5.4 The Principal Theorems of Linear Programming (Continued)&lt;br /&gt;&#xA;5.5 Connections Between Linear Programming Problems and Game Theory&lt;br /&gt;&#xA;5.6 Extensions of the Duality Theorem&lt;br /&gt;&#xA;5.7 Warehouse Problem&lt;br /&gt;&#xA;5.8 Optimal Assignment Problem&lt;br /&gt;&#xA;5.9 Transportation and Flow Problem&lt;br /&gt;&#xA;5.10 Maximal-Flow, Minimal-Cut Theorem&lt;br /&gt;&#xA;5.11 The Caterer's Problem&lt;br /&gt;&#xA;5.12 Price Speculation Model&lt;/p&gt;&#xA;&lt;p&gt;Chapter 6. Computational Methods for Linear Programming and Game Theory&lt;br /&gt;&#xA;6.1 The Simplex Method&lt;br /&gt;&#xA;6.2 Auxiliary Simplex Methods&lt;br /&gt;&#xA;6.3 An Illustration of the Use of the Simplex Method&lt;br /&gt;&#xA;6.4 Computation of Network Flow&lt;br /&gt;&#xA;6.5 A Method of Approximating the Value of a Game&lt;br /&gt;&#xA;6.6 Proof of the Convergence&lt;br /&gt;&#xA;6.7 A Differential-Equations Method for Determining the Value of a Game&lt;/p&gt;&#xA;&lt;p&gt;Chapter 7. Nonlinear Programming&lt;br /&gt;&#xA;7.1 Concave Programming&lt;br /&gt;&#xA;7.2 Examples of Concave Programming&lt;br /&gt;&#xA;7.3 The Arrow-Hurwicz Gradient Method&lt;br /&gt;&#xA;7.4 The Vector Maximum Problem&lt;br /&gt;&#xA;7.5 Conjugate Functions&lt;br /&gt;&#xA;7.6 Composition of Conjugate Functions&lt;br /&gt;&#xA;7.7 Conjugate Concave Functions&lt;br /&gt;&#xA;7.8 A Duality Theorem of Nonlinear Programming&lt;br /&gt;&#xA;7.9 Applications of the Theory of Conjugate Functions to Convex Sets&lt;/p&gt;&#xA;&lt;p&gt;Chapter 8. Mathematical Methods in the Study of Economic Models&lt;br /&gt;&#xA;8.1 Open and Closed Linear Leontief Models&lt;br /&gt;&#xA;8.2 The Theory of Positive Matrices&lt;br /&gt;&#xA;8.3 Applications of the Theory of Positive Matrices to the Study of Linear Models of Equilibrium and Exchange&lt;br /&gt;&#xA;8.4 The Theory of Production&lt;br /&gt;&#xA;8.5 Efficient Points of a Leontief-Type Model&lt;br /&gt;&#xA;8.6 The Theory of Consumer Choice&lt;br /&gt;&#xA;8.7 Nonlinear Models of Equilibrium&lt;br /&gt;&#xA;8.8 The Arrow-Debreu Equilibrium Model of a Competitive Economy&lt;/p&gt;&#xA;&lt;p&gt;Chapter 9. Mathematical Methods in the Study of Economic Models (Continued)&lt;br /&gt;&#xA;9.1 Welfare Economics&lt;br /&gt;&#xA;9.2 The Stability of a Competitive Equilibrium&lt;br /&gt;&#xA;9.3 Local Stability&lt;br /&gt;&#xA;9.4 Global Stability of Price Adjustment Processes&lt;br /&gt;&#xA;9.5 Global Stability (Continued)&lt;br /&gt;&#xA;9.6 A Difference-Equations Formulation of Global Stability&lt;br /&gt;&#xA;9.7 Stability and Expectations (Model I)&lt;br /&gt;&#xA;9.8 Stability and Expectations (Model II)&lt;br /&gt;&#xA;9.9 The Von Neumann Model of an Expanding Economy&lt;br /&gt;&#xA;9.10 A General Model of Balanced Growth&lt;/p&gt;&#xA;&lt;p&gt;Appendix A. Vector Spaces and Matrices&lt;br /&gt;&#xA;A.1 Euclidean and Unitary Spaces&lt;br /&gt;&#xA;A.2 Subspaces, Linear Independent, Basis, Direct Sums, Orthogonal Complements&lt;br /&gt;&#xA;A.3 Linear Transformations, Matrices, and Linear Equations&lt;br /&gt;&#xA;A.4 Eigenvalues, Eigenvectors, and the Jordan Canonical Form&lt;br /&gt;&#xA;A.5 Transposed, Normal, and Hermitian Matrices; Orthogonal Complement&lt;br /&gt;&#xA;A.6 Quadratic Form&lt;br /&gt;&#xA;A.7 Matrix-Valued Functions&lt;br /&gt;&#xA;A.8 Determinants; Minors, Cofactors&lt;br /&gt;&#xA;A.9 Some Identities&lt;br /&gt;&#xA;A.10 Compound Matrices&lt;/p&gt;&#xA;&lt;p&gt;Appendix B. Convex Sets and Convex Functions&#xA;B.1 Convex Sets in En&lt;br /&gt;&#xA;B.2 Convex Hulls of Sets and Extreme Points of Convex Sets&lt;br /&gt;&#xA;B.3 Convex Cones&lt;br /&gt;&#xA;B.4 Convex and Concave Functions&lt;/p&gt;&#xA;&lt;p&gt;Appendix C. Miscellaneous Topics&lt;br /&gt;&#xA;C.1 Semicontinuous and Equicontinuous Functions&lt;br /&gt;&#xA;C.2 Fixed-Point Theorems&lt;br /&gt;&#xA;C.3 Set Functions and Probability Distributions&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="491" LastEditDate="2021-01-12T19:31:22.300" LastActivityDate="2021-01-12T19:31:22.300" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5451" PostTypeId="1" CreationDate="2020-12-30T06:43:51.317" Score="2" ViewCount="63" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Consider the primal problem &lt;span class=&quot;math-container&quot;&gt;\begin{align}f^*=\min&amp;amp;\quad f(x)\\\text{s.t.}&amp;amp;\quad g_i(x)\le0\tag P\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$f,g_i$&lt;/span&gt; are convex functions. Suppose there exists &lt;span class=&quot;math-container&quot;&gt;$\hat{x}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$g_i(\hat{x})&amp;lt;0$&lt;/span&gt; and (P) is bounded from below (&lt;span class=&quot;math-container&quot;&gt;$f^*&amp;gt;-\infty$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Consider the dual problem (D) given by &lt;span class=&quot;math-container&quot;&gt;$\max\{q(\lambda):\lambda\in\operatorname{dom}(q)\}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$$q(\lambda)=\min_xL(x,\lambda),\quad\operatorname{dom}(q)=\{\lambda\in\mathbb{R}^m_+:q(\lambda)&amp;gt;-\infty\}.$$&lt;/span&gt; Let &lt;span class=&quot;math-container&quot;&gt;$\lambda^*$&lt;/span&gt; be an optimal solution of the dual problem. Prove&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{m}\lambda_i^*\leq\frac{f(\hat{x})-f^*}{\underset{i=1,\ldots,m}{\min}(-g_i(\hat{x}))}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;My attempt&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;From the the information that &lt;span class=&quot;math-container&quot;&gt;$\lambda^*$&lt;/span&gt; is optimal solution of (D) we can deduce that &lt;span class=&quot;math-container&quot;&gt;$$f^*\leq q(\lambda^*)=\underset{x}{\min}\{f(x)+\sum_i\lambda_i^*g_i(x)\}$$&lt;/span&gt; using the non-linear extension of Farkas' lemma. Because we take the minimal &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$q(x^*)$&lt;/span&gt;, if we take &lt;span class=&quot;math-container&quot;&gt;$\hat{x}$&lt;/span&gt; we only increase the value. Therefore&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\underset{x}{\min}\{f(x)+\sum_i\lambda_i^*g_i(x)\}\leq f(\hat{x})+\sum_i\lambda_i^*g_i(\hat{x})\implies f^*\leq f(\hat{x})+\sum_i\lambda_i^*g_i(\hat{x})$$&lt;/span&gt; iff &lt;span class=&quot;math-container&quot;&gt;$$f(\hat{x})-f^*\geq \sum_i\lambda_i^*g_i(\hat{x})\geq \underset{i=1,\ldots,m}{\min}(-g_i(\hat{x}))\sum_i\lambda_i^*.$$&lt;/span&gt; Therefore we get &lt;span class=&quot;math-container&quot;&gt;$$f(\hat{x})-f^*\geq\underset{i=1,\ldots,m}{\min}(-g_i(\hat{x}))\sum_i\lambda_i^*$$&lt;/span&gt; as desired.&lt;/p&gt;&#xA;" OwnerUserId="4526" LastEditorUserId="123" LastEditDate="2020-12-30T11:18:58.297" LastActivityDate="2020-12-30T11:18:58.297" Title="Prove $\sum_{i=1}^{m}\lambda_i^*\leq\frac{f(\hat{x})-f^*}{\underset{i=1,\ldots,m}{\min}(-g_i(\hat{x}))}$" Tags="|convex-optimization|duality|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5452" PostTypeId="2" ParentId="5449" CreationDate="2020-12-30T18:12:04.993" Score="8" Body="&lt;p&gt;Don't know whether this is stating the obvious, but &lt;em&gt;Algorithmic Game Theory&lt;/em&gt; by Nisan, Roughgarden, Tardos, and Vazirani has to be in the mix here.&lt;/p&gt;&#xA;&lt;p&gt;Major content would be: (Complexity of) Finding (pure) Nash equilibria, Algorithmic Mechanism Design, the Price of Anarchy (ratio of efficiency between equilibria and optima), Cooperative Games.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2020-12-30T18:12:04.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5453" PostTypeId="1" CreationDate="2020-12-30T23:15:27.013" Score="3" ViewCount="341" Body="&lt;p&gt;I have some experience with linear and integer programming modeling (I read Model Building In Mathematical Programming by Williams).&lt;/p&gt;&#xA;&lt;p&gt;Now I am trying to learn how to model with constraint programming. Is there some rule of thumbs on how to pass from an IP way of modeling to a CP way of modeling?&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, I didn't found a similar book on CP modeling. I am aware of an online course in coursera but I do prefer books.&#xA;Moreover, I am interested in comparing LP/IP models to CP models and not only to learn CP modeling.&lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="491" LastEditDate="2020-12-31T23:53:10.713" LastActivityDate="2020-12-31T23:53:10.713" Title="Modeling in integer programming vs modeling in constraint programming" Tags="|mixed-integer-programming|linear-programming|modeling|integer-programming|constraint-programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5454" PostTypeId="2" ParentId="5453" CreationDate="2020-12-31T00:43:42.637" Score="8" Body="&lt;p&gt;There are many resources available to learn constraint modelling. When learning about constraint modelling I can recommend the following books:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1017/CBO9780511615320&quot; rel=&quot;noreferrer&quot;&gt;Principles of Constraint Programming&lt;/a&gt; by Krzysztof Apt is probably the most used constraint programming book that will teach you all the aspects of constraint programming.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The book that would most fit your description might however be &lt;a href=&quot;https://doi.org/10.1007/978-3-030-41732-1&quot; rel=&quot;noreferrer&quot;&gt;Building Decision Support Systems&lt;/a&gt; by Mark Wallace. This book focuses on the modelling of combinatorial problems using the MiniZinc constraint modelling language. Although MiniZinc can be used with both integer programming and constraint programming solvers (and even more kinds of solvers), its original design is as a standard input language for constraint programming solvers and the techniques learned can be transferred to other constraint programming solvers.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another book that is often used is &lt;a href=&quot;https://www.elsevier.com/books/handbook-of-constraint-programming/rossi/978-0-444-52726-4&quot; rel=&quot;noreferrer&quot;&gt;Handbook of Constraint Programming&lt;/a&gt; by Rossi, van Beek, and Walsh. This book is written from the perspective of artificial intelligence and will focuses on the search techniques employed by constraint programming.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Apart from books there are many (written) tutorials dedicated to constraint programming:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.gecode.org&quot; rel=&quot;noreferrer&quot;&gt;Gecode&lt;/a&gt;, one of the most used constraint programming solver, provides the &lt;a href=&quot;https://www.gecode.org/doc-latest/MPG.pdf&quot; rel=&quot;noreferrer&quot;&gt;Modelling and Programming with Gecode (MPG)&lt;/a&gt; handbook. This handbook is probably the best and most complete resource that is dedicated to the implementation (i.e., building the model) of constraint models and how a solver will handle these models. It even covers extensions possible to the solver, one of the big strengths of constraint programming that is often overlooked. As the name suggest, some parts are very specific to the Gecode solver and might not be applicable to other solvers. (That is not necessarily a problem since Gecode is one of the fastest constraint programming solvers).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;More focussed on modelling, &lt;a href=&quot;https://www.minizinc.org&quot; rel=&quot;noreferrer&quot;&gt;MiniZinc&lt;/a&gt; provides an &lt;a href=&quot;https://www.minizinc.org/doc-2.5.3/en/part_2_tutorial.html&quot; rel=&quot;noreferrer&quot;&gt;online tutorial&lt;/a&gt; to get started with the language. This tutorial introduces all concepts of constraint modelling at a fast pace.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Finally, depending on your interest there are also a few books on Constraint Logic Programming that I can recommend: &lt;a href=&quot;https://mitpress.mit.edu/books/programming-constraints&quot; rel=&quot;noreferrer&quot;&gt;Programming with Constraints&lt;/a&gt; by Mariott and Stuckey and &lt;a href=&quot;https://link.springer.com/chapter/10.1007/3-540-45628-7_19&quot; rel=&quot;noreferrer&quot;&gt;Constraint Logic Programming&lt;/a&gt; by Mark Wallace.&lt;/p&gt;&#xA;&lt;p&gt;P.S. Although I know you were specifically looking for a book, I would really recommend the Coursera courses &lt;a href=&quot;https://www.coursera.org/learn/basic-modeling&quot; rel=&quot;noreferrer&quot;&gt;Basic Modelling for Discrete Optimisation&lt;/a&gt; and &lt;a href=&quot;https://www.coursera.org/learn/discrete-optimization&quot; rel=&quot;noreferrer&quot;&gt;Discrete Optimistion&lt;/a&gt; for anyone who wants to learn constraint modelling and wants to get some hand on experience. Since it actually allows you to be automatically graded on going from a problem description to a constraint model, there is no better tool to really get a feel for how to model well.&lt;/p&gt;&#xA;" OwnerUserId="97" LastActivityDate="2020-12-31T00:43:42.637" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5455" PostTypeId="1" CreationDate="2020-12-31T02:03:40.790" Score="2" ViewCount="294" Body="&lt;p&gt;I am trying to define both upper and lower bounds for a vector of variables in AMPL (solver Gurobi). However, after solving to optimal solution, the variables violate the bounds. The only way these bounds work is defined as explicit constraint in AMPL through the 'subject to' clause. Any idea why AMPL doesn't accept the bounds defined in the first way?&lt;/p&gt;&#xA;&lt;p&gt;The first way:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var pi{t in 1..T} &amp;gt;= lb_pi[t] &amp;lt;= ub_pi[t];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The explicit way:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;subject to C_pi_low{t in 1..T}:&#xA;    pi[t] &amp;gt;= lb_pi[t];&#xA;&#xA;subject to C_pi_up{t in 1..T}:&#xA;    pi[t] &amp;lt;= ub_pi[t];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="98" LastEditorUserId="491" LastEditDate="2022-08-09T02:57:00.733" LastActivityDate="2022-08-09T02:57:00.733" Title="AMPL Gurobi Define Variables Bounds" Tags="|gurobi|ampl|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5456" PostTypeId="1" AcceptedAnswerId="5457" CreationDate="2020-12-31T03:25:16.350" Score="0" ViewCount="177" Body="&lt;p&gt;Thinking if it is a Knapsack  problem.&lt;/p&gt;&#xA;&lt;p&gt;Here is the scenario:&lt;/p&gt;&#xA;&lt;p&gt;Michael and his daughter (7 year old kid) enjoy going to cinema for movies.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Weekdays fare for kids is 5 dollars, adult 8.&#xA;Weekend fare $12.00, regardless kid or adult.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With $100 budget, how can Michael and his daughter enjoy more movies, considering most of those falls in weekdays?&lt;/p&gt;&#xA;" OwnerUserId="2440" LastEditorUserId="123" LastEditDate="2021-02-25T07:57:18.697" LastActivityDate="2021-02-25T07:57:18.697" Title="Solving weekday and weekend fare movies" Tags="|knapsack|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5457" PostTypeId="2" ParentId="5456" CreationDate="2020-12-31T05:48:08.333" Score="7" Body="&lt;p&gt;So it costs \$13 for the two of them on a weekday and \$24 for the two of them on a weekend.  If you want to maximize the number of movies, skip the expensive ones and the \$100 budget yields &lt;span class=&quot;math-container&quot;&gt;$\lfloor 100/13 \rfloor = 7$&lt;/span&gt; movies.&lt;/p&gt;&#xA;&lt;p&gt;If you prefer writing it explicitly as an optimization (yes, knapsack) problem, let integer decision variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; be the numbers of weekday and weekend movies attended, respectively.  The problem is to maximize &lt;span class=&quot;math-container&quot;&gt;$x+y$&lt;/span&gt; subject to linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;13x+24y &amp;amp;\le 100 \\&#xA;x &amp;amp;\ge 0 \\&#xA;y &amp;amp;\ge 0 &#xA;\end{align}&lt;/span&gt;&#xA;The unique optimal solution is &lt;span class=&quot;math-container&quot;&gt;$(x,y)=(7,0)$&lt;/span&gt;, with objective value &lt;span class=&quot;math-container&quot;&gt;$7+0=7$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2020-12-31T05:48:08.333" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5458" PostTypeId="2" ParentId="5455" CreationDate="2020-12-31T08:37:41.673" Score="0" Body="&lt;p&gt;According to section 14-1 of AMPL book:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;For continuous variables, normally AMPL passes to solvers the first set of bounds, but you can instruct it to pass the second set by changing option var_bounds to 2 from its default value of 1. When active-set methods (like the simplex method) are applied, the second set tends to give rise to more degenerate variables, and hence more degenerate iterations that may impede progress toward a solution.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Reference: &lt;a href=&quot;https://ampl.com/BOOK/CHAPTERS/17-solvers.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ampl.com/BOOK/CHAPTERS/17-solvers.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2020-12-31T08:37:41.673" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5459" PostTypeId="2" ParentId="5453" CreationDate="2020-12-31T21:17:19.977" Score="8" Body="&lt;p&gt;When I started learning CP (coming from IP), one of the first things I discovered is that model elements are less standardized in CP than in IP. An IP model typically contains a polynomial objective function and equality/inequality constraints involving polynomial functions (where you are hoping the polynomials are linear or at worst quadratic). Beyond that (and declaring types and bounds for variables), about the only model constructs I can think of are SOS1/SOS2 constraints and indicator constraints. Most high quality MIP solvers understand all the above, and if the solver does not do SOS1/SOS2 or indicator constraints, they can be replaced with more equations and inequalities (involving binary variables). Differences among solver tend to be more on the solution technique side than in which model elements they know.&lt;/p&gt;&#xA;&lt;p&gt;With CP, there are a lot more types of constraints. I would guess that any CP solver worth a look would implement the &amp;quot;all different&amp;quot; constraint, but beyond some basic core set of constraints it gets interesting. IBM's CP Optimizer, for instance, implements constraints specifically intended for scheduling problems, such as &amp;quot;end before begin&amp;quot; (task A must end before task B begins), which I don't think you will find in every (or even most) CP solvers. So building an IP model for a job shop is largely independent of the solver you choose, whereas building a CP model for a job shop very much depends on the solver.&lt;/p&gt;&#xA;&lt;p&gt;Another major difference is tied to that profusion of constraints. There are things you can express directly in a CP model that would be either impossible or extremely painful to express in an IP model. I would characterize the &amp;quot;all different&amp;quot; constraint as moderately painful in IP. (There's a straightforward way to model it, using a separate binary variable for each possible value of the original variable, but you might not like having that many binary variables in your model.) My experience with CP is limited, but the CP solvers I've seen have all been able to index a variable with a variable (i.e.,deal with the expression x[y] where x is a vector variable and y is a scalar variable that chooses one component of x). You can usually (always?) do the equivalent in an IP model, but it again involves copious binary variables and copious additional constraints, makes the model difficult to read, and has been known to cause severe brain cramps. In CP, the equivalent is as simple as writing &amp;quot;x[y]&amp;quot; or using a build in constraint function along the lines of &amp;quot;select(x, y)&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Other differences include the following. LP/IP tends to &amp;quot;like&amp;quot; continuous variables and &amp;quot;tolerate&amp;quot; integer variables, in the sense that integer variables make solving harder. CP tends to &amp;quot;like&amp;quot; integer variables (with finite, preferably small, domains) and &amp;quot;tolerate&amp;quot; continuous variables. How, or even whether, a CP solver handles continuous variables will differ among solvers. IP models tend, at least in my experience, to have tighter bounds than CP models do (although I'm sure someone can find exceptions), which means it may be a bit easier to tell how good your intermediate IP solution is compared to how good your intermediate CP solution is.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2020-12-31T21:17:19.977" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5460" PostTypeId="2" ParentId="5455" CreationDate="2020-12-31T21:50:35.893" Score="1" Body="&lt;p&gt;I am going to answer my own question. After I made the post, I realized the variable pi actually don't show up in the model though declared. It looks like this is the reason why the first way doesn't take effective in the 'solve' process while the second explicit way works.&lt;/p&gt;&#xA;" OwnerUserId="98" LastActivityDate="2020-12-31T21:50:35.893" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5461" PostTypeId="1" CreationDate="2021-01-01T17:20:26.003" Score="2" ViewCount="94" Body="&lt;p&gt;I am talking about optimization problems related to spraying disinfectants in public spaces which prevents COVID-19 transmission.&lt;/p&gt;&#xA;" OwnerUserId="4688" LastEditorUserId="727" LastEditDate="2021-03-04T20:19:38.983" LastActivityDate="2021-03-04T20:19:38.983" Title="Are there any optimization problems related to preventing COVID-19 transmission?" Tags="|reference-request|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5462" PostTypeId="1" CreationDate="2021-01-01T19:03:49.103" Score="4" ViewCount="156" Body="&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$i\in [0,n)$&lt;/span&gt;, denoted as a vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, given a linear objective function that we want to &lt;strong&gt;minimize&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$c^\top x$&lt;/span&gt; with 2 constraints:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum x_{i}^{2} &amp;lt; n+1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\log(x_{i}) &amp;gt; 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;How can I solve this optimization problem?&lt;/p&gt;&#xA;&lt;p&gt;The only thing I can think of is to convert the 2nd constraint to be the product of all &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; bigger than &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. I cannot think of a way to turn the 2nd constraint into a 'common' quadratic one.&lt;/p&gt;&#xA;&lt;p&gt;Can anyone share some ideas?&lt;/p&gt;&#xA;" OwnerUserId="758" LastEditorUserId="123" LastEditDate="2021-01-01T20:28:45.143" LastActivityDate="2021-01-26T22:33:34.163" Title="Linear objective function with power term in constraint" Tags="|optimization|quadratic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5463" PostTypeId="2" ParentId="5462" CreationDate="2021-01-01T20:11:21.340" Score="4" Body="&lt;p&gt;This is a convex optimization problem which can be modeled as a combination of Second Order (SOCP) and Exponential cones.&lt;/p&gt;&#xA;&lt;p&gt;It is easy to enter into a conic convex optimization tool, such as CVX (MATLAB), CVXPY (Python), CVXR (&amp;quot;R&amp;quot;), or YALMIP (MATLAB), which can call Mosek 9.x, ECOS, or SCS to solve it.&lt;/p&gt;&#xA;&lt;p&gt;Here is CVX code (note: indices for &lt;code&gt;x&lt;/code&gt; run from 1 to n, because MATLAB vector indexing starts at 1 rather than 0)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin&#xA;variable x(n)&#xA;minimize(c'*x)&#xA;subject to&#xA;x'*x &amp;lt;= n+1-small_positive_number&#xA;sum(log(x)) &amp;gt;= 0&#xA;cvx_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where &lt;code&gt;small_positive_number&lt;/code&gt;is a small positive number such as 1e-6.&#xA;If you want &lt;code&gt;sum(log(x))&lt;/code&gt; to be strictly positive, you can use a small positive number, such as 1e-6, instead of 0, on the right-hand side of that constraint.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="491" LastEditDate="2021-01-26T22:33:34.163" LastActivityDate="2021-01-26T22:33:34.163" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5464" PostTypeId="1" AcceptedAnswerId="5480" CreationDate="2021-01-01T21:55:20.597" Score="6" ViewCount="390" Body="&lt;h1&gt;Background&lt;/h1&gt;&#xA;&lt;p&gt;I am trying to implement the reranking algorithm proposed in the &lt;a href=&quot;https://arxiv.org/pdf/1805.01788.pdf&quot; rel=&quot;noreferrer&quot;&gt;paper&lt;/a&gt; (Eqn 3). The algorithm is cast into an integer linear program which is trying to find &lt;em&gt;permutation matrix&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X} \in \mathbb{R}^{n\times n}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}_{ij} =1$&lt;/span&gt; means ranking item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yYNli.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yYNli.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&lt;p&gt;Initially, I implemented this algorithm using &lt;code&gt;cvxpy&lt;/code&gt; and setting the solver to be Gurobi. The runtime is not satisfying. So I decided to directly call Gurobi Python API (i.e. &lt;code&gt;gurobipy&lt;/code&gt;) rather than using the modeling interface (i.e. &lt;code&gt;cvxpy&lt;/code&gt;). I expected the runtime to be improved as I skip the abstraction from &lt;code&gt;cvxpy&lt;/code&gt;. However, the runtime is surprisingly much worse (see below).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# gurobipy runtime in seconds&#xA;174.727278&#xA;# cvxpy runtime in seconds&#xA;54.925721&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The only two explanations I could think are&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;My implementation based on &lt;code&gt;gurobipy&lt;/code&gt; is not efficient.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;cvxpy&lt;/code&gt; somehow optimizes the formulation by using some transformation. This transformation makes it easier for Gurobi to discover the structure in the problem. However, when directly code the formulation using &lt;code&gt;gurobipy&lt;/code&gt;, this structure is not well exploited by Gurobi.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;My questions are&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Does any of my explanations make sense? Why this odd behavior might happen.&lt;/li&gt;&#xA;&lt;li&gt;What could I do to optimize my &lt;code&gt;cvxpy&lt;/code&gt; code or &lt;code&gt;gurobipy&lt;/code&gt; code to improve the runtime?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;Code to reproduce my result&lt;/h1&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import numpy as np&#xA;import cvxpy as cp&#xA;import gurobipy as gp&#xA;&#xA;from datetime import datetime&#xA;from gurobipy import GRB&#xA;&#xA;def runGUROBIImpl(n, theta=0.5, nIter=10):&#xA;    for i in range(nIter):&#xA;        with gp.Env(empty=True) as env:&#xA;            env.setParam(&amp;quot;OutputFlag&amp;quot;, 0)&#xA;            env.start()&#xA;            with gp.Model(env=env) as model:&#xA;                C = np.random.rand(n, n)&#xA;                DCG = np.random.rand(n, n)&#xA;                IDCG = np.random.rand()&#xA;&#xA;                P = model.addVars(n, n, vtype=GRB.BINARY)&#xA;                obj = sum([C[i, j] * P[i, j] for i in range(n) for j in range(n)])&#xA;                constrLHS = sum([DCG[i, j] * P[i, j] for i in range(n) for j in range(n)])&#xA;&#xA;                model.setObjective(obj, GRB.MINIMIZE)&#xA;                model.addConstr(constrLHS &amp;gt;= theta * IDCG)&#xA;                model.addConstrs((P.sum(&amp;quot;*&amp;quot;, i) == 1 for i in range(n)))&#xA;                model.addConstrs((P.sum(i, &amp;quot;*&amp;quot;) == 1 for i in range(n)))&#xA;&#xA;                model.optimize()&#xA;&#xA;                if not (model.status == GRB.OPTIMAL): print(&amp;quot;unsuccessful...&amp;quot;)&#xA;&#xA;def runCVXPYImpl(n, theta=0.5, nIter=10):&#xA;    C, DCG, IDCG = cp.Parameter((n, n)), cp.Parameter((n, n)), cp.Parameter()&#xA;    P = cp.Variable((n, n), boolean=True)&#xA;&#xA;    objective = cp.Minimize(cp.sum(cp.multiply(C, P)))&#xA;    constraints = [cp.sum(cp.multiply(DCG, P)) &amp;gt;= theta * IDCG,&#xA;                   cp.matmul(np.ones((1, n)), P) == np.ones((1, n)),&#xA;                   cp.matmul(P, np.ones((n, 1))) == np.ones((n, 1))]&#xA;    problem = cp.Problem(objective, constraints)&#xA;&#xA;    for i in range(nIter):&#xA;        C.value = np.random.rand(n, n)&#xA;        DCG.value = np.random.rand(n, n)&#xA;        IDCG.value = np.random.rand()&#xA;        # solve problem&#xA;        problem.solve(solver=cp.GUROBI, verbose=False)&#xA;&#xA;        if not (problem.status == cp.OPTIMAL): print(&amp;quot;unsuccessful...&amp;quot;)&#xA;&#xA;np.random.seed(0)&#xA;start = datetime.now()&#xA;runGUROBIImpl(n=100, theta=0.5, nIter=300)&#xA;end = datetime.now()&#xA;print((end - start).total_seconds())&#xA;&#xA;np.random.seed(0)&#xA;start = datetime.now()&#xA;runCVXPYImpl(n=100, theta=0.5, nIter=300)&#xA;end = datetime.now()&#xA;print((end - start).total_seconds())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Logs&lt;/h1&gt;&#xA;&lt;p&gt;The algorithm proposed in the paper requires the linear program to be solved several hundreds times with updated parameter matrix each time to get the final result &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As it would be much too verbose to provide logs for several hundreds solving attempts, the following are the logs when I set &lt;code&gt;nIter=1&lt;/code&gt; for both &lt;code&gt;runGUROBIImpl()&lt;/code&gt; and &lt;code&gt;runCVXPYImpl()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note when &lt;code&gt;nIter=1&lt;/code&gt; the situation for runtime is different from when &lt;code&gt;nIter=300&lt;/code&gt; as the &lt;code&gt;cvxpy&lt;/code&gt; requires a lot of time to construct problem.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# gurobipy runtime in seconds&#xA;0.61062&#xA;# cvxpy runtime in seconds&#xA;15.098772&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;&lt;code&gt;runGUROBIImpl()&lt;/code&gt; Logs&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;Gurobi Optimizer version 9.1.1 build v9.1.1rc0 (linux64)&#xA;Thread count: 2 physical cores, 4 logical processors, using up to 4 threads&#xA;Optimize a model with 201 rows, 10000 columns and 30000 nonzeros&#xA;Model fingerprint: 0x4962970c&#xA;Variable types: 0 continuous, 10000 integer (10000 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [2e-04, 1e+00]&#xA;  Objective range  [7e-05, 1e+00]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [2e-01, 1e+00]&#xA;Found heuristic solution: objective 48.7825807&#xA;Presolve removed 1 rows and 0 columns&#xA;Presolve time: 0.03s&#xA;Presolved: 200 rows, 10000 columns, 20000 nonzeros&#xA;Variable types: 0 continuous, 10000 integer (10000 binary)&#xA;&#xA;Root relaxation: objective 1.415358e+00, 210 iterations, 0.00 seconds&#xA;&#xA;    Nodes    |    Current Node    |     Objective Bounds      |     Work&#xA; Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time&#xA;&#xA;*    0     0               0       1.4153579    1.41536  0.00%     -    0s&#xA;&#xA;Explored 0 nodes (210 simplex iterations) in 0.03 seconds&#xA;Thread count was 4 (of 4 available processors)&#xA;&#xA;Solution count 2: 1.41536 48.7826 &#xA;&#xA;Optimal solution found (tolerance 1.00e-04)&#xA;Best objective 1.415357907906e+00, best bound 1.415357907906e+00, gap 0.0000%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;&lt;code&gt;runCVXPYImpl()&lt;/code&gt; Logs&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;Parameter OutputFlag unchanged&#xA;   Value: 1  Min: 0  Max: 1  Default: 1&#xA;Changed value of parameter QCPDual to 1&#xA;   Prev: 0  Min: 0  Max: 1  Default: 0&#xA;Gurobi Optimizer version 9.1.1 build v9.1.1rc0 (linux64)&#xA;Thread count: 2 physical cores, 4 logical processors, using up to 4 threads&#xA;Optimize a model with 201 rows, 10000 columns and 30000 nonzeros&#xA;Model fingerprint: 0x8b5dd50a&#xA;Variable types: 0 continuous, 10000 integer (10000 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [2e-04, 1e+00]&#xA;  Objective range  [7e-05, 1e+00]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [2e-01, 1e+00]&#xA;Found heuristic solution: objective 47.5478288&#xA;Presolve removed 1 rows and 0 columns&#xA;Presolve time: 0.03s&#xA;Presolved: 200 rows, 10000 columns, 20000 nonzeros&#xA;Variable types: 0 continuous, 10000 integer (10000 binary)&#xA;&#xA;Root relaxation: objective 1.415358e+00, 210 iterations, 0.00 seconds&#xA;&#xA;    Nodes    |    Current Node    |     Objective Bounds      |     Work&#xA; Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time&#xA;&#xA;*    0     0               0       1.4153579    1.41536  0.00%     -    0s&#xA;&#xA;Explored 0 nodes (210 simplex iterations) in 0.03 seconds&#xA;Thread count was 4 (of 4 available processors)&#xA;&#xA;Solution count 2: 1.41536 47.5478 &#xA;&#xA;Optimal solution found (tolerance 1.00e-04)&#xA;Best objective 1.415357907906e+00, best bound 1.415357907906e+00, gap 0.0000%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4684" LastEditorUserId="4684" LastEditDate="2021-01-01T23:46:59.150" LastActivityDate="2021-01-05T15:51:10.583" Title="Directly calling gurobipy API causes substantially longer runtime than calling cvxpy" Tags="|gurobi|cvxpy|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5465" PostTypeId="2" ParentId="5464" CreationDate="2021-01-02T00:13:56.417" Score="4" Body="&lt;p&gt;Note that the &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360036959831-What-is-the-model-fingerprint-the-log-files-&quot; rel=&quot;nofollow noreferrer&quot;&gt;model fingerprint&lt;/a&gt; differs.  I suspect that the variable or constraint orders are different.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-01-02T00:13:56.417" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5466" PostTypeId="1" CreationDate="2021-01-02T06:12:39.703" Score="4" ViewCount="80" Body="&lt;p&gt;I have an facility layout problem where the flow between any two departments is either zero or one. Also the distance between each location pair has the same nature (zero or one). I am curious whether the problem with that specific nature has another name so that specific solving methods can be found rather than the original facility layout problem ones.&lt;/p&gt;&#xA;" OwnerUserId="3480" LastEditorUserId="500" LastEditDate="2021-01-02T15:01:25.697" LastActivityDate="2021-01-03T07:13:39.143" Title="Does the facility layout problem with zero and one matrices have a specific name?" Tags="|combinatorial-optimization|facility-location|terminology|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5467" PostTypeId="1" AcceptedAnswerId="5469" CreationDate="2021-01-02T08:49:00.543" Score="4" ViewCount="102" Body="&lt;p&gt;A vacuum robot runs on randomized direction when it is operating in a room.&lt;/p&gt;&#xA;&lt;p&gt;I want to know how long it takes to fully cover the whole area (or at least most part of the area) with given information:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the area in the room is 10 square meters.&lt;/li&gt;&#xA;&lt;li&gt;the dimension of the round shape robot is 40 centimeter.&lt;/li&gt;&#xA;&lt;li&gt;the robot travels at a speed of 20 meters per minute.&lt;/li&gt;&#xA;&lt;li&gt;the robot only travels straightly.&lt;/li&gt;&#xA;&lt;li&gt;the robot forwards to a random direction when hit the wall.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Below the left is a vacuum robot. The right is the imagination of a working robot.&lt;/p&gt;&#xA;&lt;p&gt;I'm not sure if it relates to routing problem or other Operations Research method. (neither sure if it is a problem that can be optimized by Operation Research but just allow me to put it here.)&lt;/p&gt;&#xA;&lt;p&gt;Can you please advise how to solve this problem? Thank you&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sRYh6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sRYh6.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2440" LastEditorUserId="123" LastEditDate="2021-02-09T21:08:45.497" LastActivityDate="2021-02-09T21:08:45.497" Title="To calculate the time needed for a vacuum robot to cover whole area" Tags="|vehicle-routing|simulation|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5468" PostTypeId="1" CreationDate="2021-01-02T09:02:23.780" Score="3" ViewCount="346" Body="&lt;p&gt;I am currently to invoke solvers, CPLEX, in particular.&lt;/p&gt;&#xA;&lt;p&gt;As I am solving my problem sequentially, i.e., the top-level subproblem results are being used to generate the model of the next subproblem.&lt;/p&gt;&#xA;&lt;p&gt;To prevent cycling and suboptimality, I would like to be able to retrieve all the solutions of the top-level subproblem so as to generate and solve all possible realizations of the next subproblem.&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="491" LastEditDate="2022-07-21T18:18:32.303" LastActivityDate="2022-07-21T18:18:32.303" Title="How to collect solutions within CPLEX and retrieve them from PYOMO?" Tags="|cplex|solver|pyomo|cplex-python-api|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5469" PostTypeId="2" ParentId="5467" CreationDate="2021-01-02T22:43:48.897" Score="8" Body="&lt;p&gt;I don't know if a closed form solution is achievable. Assuming you can quantify how the robot selects its next direction when it hits a boundary (uniform over the entire circle, uniform over directions not within some angle of its last direction, some nonuniform distribution, ...), you could fairly easily build a simulation model (starting with an empty room -- furniture could be included but would make the model much more complex). Run the simulation a zillion times and you have an estimated distribution for the time to achieve a specified level of coverage. There are other complicating factors you could build in if you chose (such as battery life -- the vac might run out of juice before it achieved the target coverage level).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-01-02T22:43:48.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5470" PostTypeId="2" ParentId="5466" CreationDate="2021-01-03T07:13:39.143" Score="1" Body="&lt;p&gt;In the real situation, usually, this is not important how you could define the input matrices either by float numbers or binary numbers. The most important thing is that these matrices most show the applicable factors of the facility such as, material flow, the distance between the departments or whose related cost/time.&lt;/p&gt;&#xA;&lt;p&gt;If you have a binary matrix for input data, it might be interesting to change those results in an objective function sense (e.g. cost or time). After that, you can use some useful traditional algorithms like CRAFT, CORELAP, etc. or solving your problem by developing a mathematical programme.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-01-03T07:13:39.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5471" PostTypeId="2" ParentId="5468" CreationDate="2021-01-03T08:28:57.487" Score="5" Body="&lt;p&gt;It seems you should take a look at the &lt;em&gt;solution pool&lt;/em&gt; feature in CPLEX. This allows you to collect multiple solutions during the branch and bound search and to examine these solutions afterwards. I don't know how to do this in pyomo but you can find more information here &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.5.1/ilog.odms.ide.help/OPL_Studio/usroplide/topics/opl_ide_solpool_ide.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.5.1/ilog.odms.ide.help/OPL_Studio/usroplide/topics/opl_ide_solpool_ide.html&lt;/a&gt;&#xA;In my version of CPLEX there is an example file called Populate/IloPopulate (depending on language) which was quite useful when I needed to know this feature. Maybe it could be of help to you too.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-01-03T08:28:57.487" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5472" PostTypeId="1" AcceptedAnswerId="5473" CreationDate="2021-01-03T17:22:43.670" Score="3" ViewCount="552" Body="&lt;p&gt;I have following problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_i = 1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$X + \sum_j^N G_j = T$&lt;/span&gt; else &lt;span class=&quot;math-container&quot;&gt;$c_i = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also there is another constraint which upper bounds equation&#xA;&lt;span class=&quot;math-container&quot;&gt;$X + \sum_j^N G_j \le T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; is binary&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X, T$&lt;/span&gt; are constant&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$G_j$&lt;/span&gt; is continuous.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;My attempt:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}c_i &amp;amp;\ge 1 - M\left(X + \sum_j^N G_j -T\right)\\c_i &amp;amp;\le 1 + M \left(X + \sum_j^N G_j -T\right)\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This enforces the binary variable to get value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. For &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, I reduced &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$T-\delta$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; is a very small value&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$c_i \le X + \sum_j^N G_j - (T - \delta)  \text{  (This is where I need help for $c_i = 0$)}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since my objective function is &lt;span class=&quot;math-container&quot;&gt;$\max\sum_i c_i$&lt;/span&gt;, it is necessary for zero condition of &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; to be tight.&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="2477" LastEditDate="2021-01-03T22:21:48.473" LastActivityDate="2021-01-03T22:21:48.473" Title="If else condition to MILP" Tags="|mixed-integer-programming|linearization|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5473" PostTypeId="2" ParentId="5472" CreationDate="2021-01-03T18:45:48.830" Score="8" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; be a constant lower bound on &lt;span class=&quot;math-container&quot;&gt;$X + \sum_j^N G_j$&lt;/span&gt;.&#xA;You want &lt;span class=&quot;math-container&quot;&gt;$$X + \sum_j^N G_j \in [L,T-\delta] \cup [T,T]$$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$c_i=0$&lt;/span&gt; for the first interval and &lt;span class=&quot;math-container&quot;&gt;$c_i=1$&lt;/span&gt; for the second (single-point) interval.&#xA;You can enforce that with the following linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L(1-c_i)+T c_i \le X + \sum_j^N G_j \le (T-\delta)(1-c_i)+T c_i$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-01-03T18:45:48.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5474" PostTypeId="1" CreationDate="2021-01-04T10:26:11.860" Score="3" ViewCount="115" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Find the dual problem of&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_x\{||x-a_1||+||x-a_2||+||x-a_3||,a_i\in\mathbb{R}^n\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I've tried the following but got stuck&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_x\{||x-a_1||+||x-a_2||+||x-a_3||,a_i\in\mathbb{R}^n\}=\min_{x,z_i}\{||z_1||+||z_2||+||z_3||,a_i\in\mathbb{R}^n\,z_i=x-a_i\}$$&lt;/span&gt;&lt;br /&gt;&#xA;and the Lagrangian is:\&#xA;&lt;span class=&quot;math-container&quot;&gt;$L(x,z,\lambda)=  ||z_1||+||z_2||+||z_3||+\sum_{i=1}^3\lambda_i(z_i-x+a_i)=\sum_{i=1}^{3}z_i\lambda_i+||z_i||-x\sum\lambda_i+\sum\lambda_ia_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;from &lt;span class=&quot;math-container&quot;&gt;$-x\sum\lambda_i$&lt;/span&gt; we can deduce that &lt;span class=&quot;math-container&quot;&gt;$\sum \lambda_i=0$&lt;/span&gt; else we get &lt;span class=&quot;math-container&quot;&gt;$-\infty$&lt;/span&gt;.&#xA;Now when I try to solve for each &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; I get &lt;span class=&quot;math-container&quot;&gt;$\frac{\partial L}{\partial z_i}=\lambda_i+\frac{z_i}{||z_i||}=0$&lt;/span&gt;&#xA;and I'm not sure how to continue from here.&lt;br /&gt;&#xA;Any hint?&lt;/p&gt;&#xA;" OwnerUserId="4526" LastActivityDate="2021-01-06T08:49:01.850" Title="Find the dual problem of $\min_x\{||x-a_1||+||x-a_2||+||x-a_3||,a_i\in\mathbb{R}^n\}$" Tags="|convex-optimization|duality|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5475" PostTypeId="2" ParentId="3703" CreationDate="2021-01-04T15:44:45.440" Score="2" Body="&lt;p&gt;I want to expand on @Sunes answer, as I too wanted to solve the LP relaxation of my MIP and thought, there must be another solution than to convert each variable manually (at least this is how I interpreted @Sunes answer and it sounded needlessly complex). Therefore, I unnecessarily used up a lot more time searching through the internet for alternatives (without success).&lt;/p&gt;&#xA;&lt;p&gt;It happens that you can convert a whole &lt;code&gt;IloNum/Int/BoolVarArray&lt;/code&gt; at once and using IloConversion is way simpler than it sounds. Assuming you have your MIP model in an IloModel &lt;code&gt;model&lt;/code&gt; and that you have all your integer variables in an array &lt;code&gt;y&lt;/code&gt;. Then creating the LP relaxation of your MIP is as easy as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;IloConversion relax_y = IloConversion( env, y, ILOFLOAT );&#xA;model.add( relax_y );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To regain the original MIP model just execute&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;relax_y.end();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4692" LastActivityDate="2021-01-04T15:44:45.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5476" PostTypeId="1" CreationDate="2021-01-04T17:53:25.420" Score="2" ViewCount="228" Body="&lt;p&gt;I am working with a variant of TSP, number of nodes that I need to test are in between 2500 to 3000 nodes, I am using docplex for modelling, I have a 8 gb Ram but it gets filled with only 400 nodes.&lt;/p&gt;&#xA;&lt;p&gt;for 100 nodes, there are 2280 constraints and 408100 indicator and if_then constraints.&lt;/p&gt;&#xA;&lt;p&gt;for 200 nodes, there are 4480 constraints and 1616200 indicator and if_then constraints. (Maybe my model is not optimal.)&lt;/p&gt;&#xA;&lt;p&gt;How to handle large models? I am looking for techniques available to solve or optimize large models.&lt;/p&gt;&#xA;&lt;p&gt;My Model:&lt;/p&gt;&#xA;&lt;p&gt;problem:  there are &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; cars they need to  deliver goods at &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; nodes, each car has goods and they give some % of there goods to these delivery points multiple cars can deliver at same point.&lt;/p&gt;&#xA;&lt;p&gt;example 2 cars 3 delivery points&lt;/p&gt;&#xA;&lt;p&gt;car 1 can deliver 0.4 goods at p1, 0.6 at p2&lt;/p&gt;&#xA;&lt;p&gt;car 2 can deliver 0.6 goods at p1, 0.4 at p2&lt;/p&gt;&#xA;&lt;p&gt;so p1 and p2 has 1 (represent it as T) they are full filled but p3 has none. If car has no goods left it comes back at start point.&lt;/p&gt;&#xA;&lt;p&gt;variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j,k}$&lt;/span&gt; - car k take edge i,j. (binary)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_{i}$&lt;/span&gt; - delivery point i requirement full filled. (binary)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$G_{i,k}$&lt;/span&gt; - goods car k has left at node i. (continuous &lt;span class=&quot;math-container&quot;&gt;$\in [0,1]$&lt;/span&gt; )&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$DG_{i,k}$&lt;/span&gt; - amount of goods gained by node i from car k. (continuous &lt;span class=&quot;math-container&quot;&gt;$\in [0,1] $&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A_{i,k}$&lt;/span&gt; - arrival time of car k at node i.&lt;/p&gt;&#xA;&lt;p&gt;objective:&lt;/p&gt;&#xA;&lt;p&gt;start node is excluded.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$max. \sum_{i}^{n} d_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j}^{n} x_{j,i,k} - \sum_{j}^{n} x_{i,j,k}=0 \text{, incoming node - outgoing node = 0}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j}^{n} x_{j,0,k} = 1 \text{, for start point 1 incoming}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j}^{n} x_{0,j,k} = 1 \text{, for start point 1 outgoing}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$A_{0,k} = 0 \text{, initialise arrival time at start to 0 }$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$G_{0,k} = 1 \text{, initialise total goods at start to 100%}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{i,j,k} -&amp;gt; A_{j,k} = A_{i,k}+X $$&lt;/span&gt;&#xA;if i,j edge is taken (&lt;span class=&quot;math-container&quot;&gt;$x_{i,j,k} = 1$&lt;/span&gt;) so arrival time at j is arrival time at i + X, X is constant (also removes sub tours).&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{i,j,k} -&amp;gt; G_{j,k} = G_{i,k} - DG_{j,k} - Y $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;if i,j edge is taken (&lt;span class=&quot;math-container&quot;&gt;$x_{i,j,k} = 1$&lt;/span&gt;) so goods at j is reduced by goods at i - goods gain by node at j, Y is constant.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j}^{n} x_{j,i,k} = 0  -&amp;gt; DG_{i,k} = 0 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;if there is no visit to node i then charge gain at node i is 0.&lt;/p&gt;&#xA;&lt;p&gt;Referring to @robpratt answer here &lt;a href=&quot;https://or.stackexchange.com/questions/5472/if-else-condition-to-milp&quot;&gt;If else condition to MILP&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$T*d_{j} \leq Z+\sum_{k}^{m}DG_{j,k} \leq (T-0.0001) * (1-d_{j}) + T*d_{j}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;above equation means if charge gain at node j from all cars to equal to threshold (T) then &lt;span class=&quot;math-container&quot;&gt;$d_{j}$&lt;/span&gt;  is 1&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$d_{i} = 0 -&amp;gt; \sum_{j}^{n} x_{j,i,k} = 0  $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;means if we can not deliver goods to i don't visit i.&lt;/p&gt;&#xA;&lt;p&gt;docplex has methods such as add_indicator and add_if_then so I have not linearized there constraints.&lt;/p&gt;&#xA;&lt;p&gt;Above formulation works for small nodes 10-20 how do I improve this model so that it can be tested with large number of nodes.&lt;/p&gt;&#xA;" OwnerUserId="700" LastEditorUserId="500" LastEditDate="2021-01-05T15:28:14.243" LastActivityDate="2021-01-05T15:28:14.243" Title="Working with large models" Tags="|mixed-integer-programming|modeling|vehicle-routing|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="5477" PostTypeId="1" CreationDate="2021-01-04T19:34:16.767" Score="1" ViewCount="119" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Given the set &lt;span class=&quot;math-container&quot;&gt;$T_{\alpha}=\{x\in\mathbb{R}^n:\sum x_i=1,0\leq x_i\leq \alpha\}$&lt;/span&gt;&lt;br /&gt;&#xA;For which &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; the set is non-empty?&lt;br /&gt;&#xA;Find a dual problem with one dual decision variable to the problem of finding&#xA;the orthogonal projection of a given vector &lt;span class=&quot;math-container&quot;&gt;$y ∈\mathbb{R}^n$&lt;/span&gt; onto &lt;span class=&quot;math-container&quot;&gt;$T_α$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I found that &lt;span class=&quot;math-container&quot;&gt;$\alpha\geq1/n$&lt;/span&gt; and when i tried to calculate the dual function  I did the following.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\min$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$||x-y||^2$&lt;/span&gt;&lt;br /&gt;&#xA;s.t&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum x_i=1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$0\leq x_i\leq\alpha\to X=\{x:0\leq x_i\leq\alpha\}$&lt;/span&gt;&lt;br /&gt;&#xA;Setting the lagrangian to be &lt;span class=&quot;math-container&quot;&gt;$L(x,\lambda)=||x-y||^2+2\lambda(\sum x_i-1)$&lt;/span&gt;,we would like to minimize the lagrangian w.r.t x then :&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\underset{x\in X}{\min}L(x,\lambda)=\sum x_i^2+2(\lambda-y_i)x_i+||y||^2-2\lambda$$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{\partial L}{\partial x_i}=2x_i+2(\lambda-y_i)=0\to x_i^*=\left\{\begin{array}{rcl} y_i-\lambda&amp;amp;0\leq y_i-\leq\alpha\\&#xA;\alpha&amp;amp;y_i-\lambda&amp;gt;\alpha\\&#xA;0&amp;amp;y_i-\lambda&amp;lt;0\end{array}\right.$$&lt;/span&gt;&lt;br /&gt;&#xA;and the dual function is &lt;span class=&quot;math-container&quot;&gt;$q(\lambda)=-2\lambda+||y||^2+\left\{\begin{array}{rcl}n\alpha^2+2n\alpha\lambda-2\alpha\sum y_i&amp;amp;y_i-\lambda&amp;gt;\alpha\\&#xA;-\sum [y_i-\lambda]_+^2&amp;amp;\mbox{else}\end{array}\right.$&lt;/span&gt;&#xA;and the derivative of &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; is:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$q'(\lambda)=-2+\left\{\begin{array}{rcl}2n\alpha &amp;amp;y_i-\lambda&amp;gt;\alpha\\&#xA;-2\sum[y_i-\lambda]_+^2&amp;amp;\mbox{else}\end{array}\right.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm not sure if I've found the right dual function and if I've found the right derivative, and I need to write a Matlab code that solves the dual problem and afterwards returns x&lt;/p&gt;&#xA;" OwnerUserId="4526" LastEditorUserId="4526" LastEditDate="2021-01-04T19:41:18.750" LastActivityDate="2021-01-06T12:48:53.903" Title="Find a dual problem with one dual decision variable to the problem of finding the orthogonal projection of a given vector" Tags="|convex-optimization|convexity|duality|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5478" PostTypeId="2" ParentId="5476" CreationDate="2021-01-05T08:59:08.637" Score="3" Body="&lt;p&gt;Please have a look at our answer to a previous post about modeling and solving TSP by using LocalSolver: &lt;a href=&quot;https://or.stackexchange.com/questions/3933/how-to-model-a-tsp-where-the-salesman-can-choose-between-flight-train-and-bus-f/3944#3944&quot;&gt;How to model a TSP where the salesman can choose between flight, train and bus for every single connection?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Your problem can be modeled differently from the one you proposed above by following a list-based modeling approach instead of the classical Boolean modeling approach. This is a modeling approach offered by LocalSolver, which is different from traditional MILP solvers. &lt;strong&gt;Note that LocalSolver is commercial software&lt;/strong&gt;. Nevertheless, it is free for faculty and students.&lt;/p&gt;&#xA;&lt;p&gt;Below is the code snippet to model the classical TSP problem in Python:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;    # Open the optimization model&#xA;    model = ls.model&#xA;&#xA;    # List variable: cities[i] is the index of the ith city in the tour&#xA;    cities = model.list(nb_cities) &#xA;&#xA;    # Constraint: all cities must be visited&#xA;    model.constraint(model.count(cities) == nb_cities)&#xA;&#xA;    # Array to store the distance matrix&#xA;    distance_array = model.array(distance_weight)&#xA;&#xA;    # Objective: minimize the total traveled distance&#xA;    dist_selector = model.lambda_function(&#xA;        lambda i: model.at(distance_array, cities[i-1], cities[i]))&#xA;    obj = (model.sum(model.range(1, nb_cities), dist_selector)&#xA;        + model.at(distance_array, cities[nb_cities - 1], cities[0]))&#xA;    model.minimize(obj)&#xA;&#xA;    # Close the optimization model&#xA;    model.close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The complete code and the corresponding codes for Java, C#, and C++ are given here:  &lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/tsp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.localsolver.com/docs/last/exampletour/tsp.html&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Having followed this modeling approach, LocalSolver finds quality solutions (optimality gap less than 1%) in a few minutes on a standard computer for TSP or VRP instances and problem variants like CVRP, CVRTW, SDVRP, PDPTW, with thousands of customers to visit. LocalSolver embeds and combines neighborhood search, constraint programming, and mixed-integer linear programming techniques under the hood to get such results.&lt;/p&gt;&#xA;&lt;p&gt;For an introduction to the list-based modeling approach for combinatorial optimization, have a look at &lt;a href=&quot;https://www.localsolver.com/docs/last/advancedfeatures/collectionvariables.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.localsolver.com/docs/last/advancedfeatures/collectionvariables.html&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-01-05T08:59:08.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5479" PostTypeId="2" ParentId="225" CreationDate="2021-01-05T10:39:59.763" Score="2" Body="&lt;p&gt;The question is still open and interesting.&lt;/p&gt;&#xA;&lt;p&gt;In my contribution to IPCO-2, Pittsburgh,  1992, I provided a family of examples of a Euclidean instance with a worst case ratio approaching &lt;span class=&quot;math-container&quot;&gt;$2.43$&lt;/span&gt; and a non-Euclidean one with ratio approaching &lt;span class=&quot;math-container&quot;&gt;$6.5$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An easy example of a Euclidean instance with a bad Farthest Insertion result is constructed by considering an &lt;strong&gt;infinite&lt;/strong&gt; number of cities along the edges of two squares &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S_2$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;\begin{align}S_1&amp;amp;=\{(x,y)\mid|x|+|y|\le2\land(|x|=1\vee|y|=1)\}\\S_2&amp;amp;=(1+\epsilon)\cdot S_1.\end{align}&lt;/span&gt; Choosing &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; sufficiently small gives a ratio of approximately &lt;span class=&quot;math-container&quot;&gt;$1.73$&lt;/span&gt;. The Farthest Insertion tour will cross from &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$S_2$&lt;/span&gt; and back multiple times.&lt;/p&gt;&#xA;" OwnerUserId="4728" LastEditorUserId="123" LastEditDate="2021-01-05T11:25:32.983" LastActivityDate="2021-01-05T11:25:32.983" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5480" PostTypeId="2" ParentId="5464" CreationDate="2021-01-05T15:51:10.583" Score="4" Body="&lt;p&gt;As others have pointed out already, you are not solving the same instances. When writing out the MPS files using a &lt;code&gt;gurobi.env&lt;/code&gt; file containing &lt;code&gt;GURO_PAR_DUMP=1&lt;/code&gt;, we can see that the instances differ (here &lt;code&gt;n=2&lt;/code&gt;, &lt;code&gt;nIters=1&lt;/code&gt;; left is cvxpy, right is Gurobi):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Lm8SH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Lm8SH.png&quot; alt=&quot;first diff&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;To get the signs in order, you could change this line in the Gurobi method&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.addConstr(constrLHS &amp;gt;= theta * IDCG)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.addConstr(-constrLHS &amp;lt;= -theta * IDCG)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Apparently, cvxpy changes this internally.&#xA;This still leaves the variable order different in both models. I didn't manage to get this identical for both codes. I did verify that the only difference is in the ordering - the objective values coincide.&lt;/p&gt;&#xA;&lt;p&gt;That Gurobi takes more time in some configurations (especially when the instance size is larger) is probably due to the fact that you are constructing a new model every time (you should reuse the environment, by the way). In cvxpy on the other hand, the model structure is only constructed once and then reused for all instances. This also doesn't require creating a new set of variables every time. I am not sure how this is handled internally, though, since at some point the model data needs to be handed over to Gurobi.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2021-01-05T15:51:10.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5481" PostTypeId="1" CreationDate="2021-01-05T19:55:54.640" Score="3" ViewCount="190" Body="&lt;p&gt;I am applying Lagrangian Relaxation with Subgradient Optimization Method and trying to solve a MIP model. Before testing the large-scale instances, I wanted to see how it performs on small-size ones. I have a great problem which makes me desperate for days  and I need the ideas of experienced people in OR Community of SE. I know that in SO method, choosing the good values for the parameters is highly important. Even if I apply many trial and fail tests , I get the same result: The lower bound converges well until a certain point and when the best lower bound is found as 0, (the optimum value is 1) it is getting stuck there. After that moment in the following iterations, the newly found lower bounds change slightly such as from  -3,9677 to -3,8599 , so best lower bound is kept as 0. It never goes beyond 0 towards to optimum value which is 1.&#xA;I got stuck at this point and I do not know which path should I follow now. I checked the evolution of multipliers etc, they all correct.&lt;/p&gt;&#xA;&lt;p&gt;If anyone who experienced the same issue or has knowledge about this case, shares ideas with me, I will be very happy , what should I do know?&lt;/p&gt;&#xA;&lt;p&gt;Thank you so much&lt;/p&gt;&#xA;" OwnerUserId="4730" LastActivityDate="2021-01-06T13:57:13.533" Title="Lagrangian Relaxation The Weak Lower Bound" Tags="|mixed-integer-programming|lagrangian-relaxation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5482" PostTypeId="2" ParentId="5477" CreationDate="2021-01-06T05:50:28.777" Score="2" Body="&lt;p&gt;I've checked my answer and it works.&#xA;&lt;strong&gt;&lt;a href=&quot;https://github.com/ronkurman/matlab&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt;&lt;/strong&gt; is a Matlab code that I've written.&lt;/p&gt;&#xA;" OwnerUserId="4526" LastEditorUserId="329" LastEditDate="2021-01-06T12:48:53.903" LastActivityDate="2021-01-06T12:48:53.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5483" PostTypeId="1" CreationDate="2021-01-06T08:26:35.697" Score="1" ViewCount="123" Body="&lt;p&gt;Is there any way I can obtain all the vertices of a polytope using Gurobi?&lt;/p&gt;&#xA;&lt;p&gt;If this isn't possible, can I log all the intermediate vertices that Simplex finds before it hits the optimal one?&lt;/p&gt;&#xA;" OwnerUserId="4734" LastActivityDate="2021-01-06T08:26:35.697" Title="Vertices of Polytope using Gurobi" Tags="|linear-programming|polyhedra|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5484" PostTypeId="2" ParentId="5474" CreationDate="2021-01-06T08:49:01.850" Score="1" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_x\{||x-a_1||+||x-a_2||+||x-a_3||,a_i\in\mathbb{R}^n\}=\min_{x,z_i}\{||z_1||+||z_2||+||z_3||,a_i\in\mathbb{R}^n\,z_i=x-a_i\}$$&lt;/span&gt;&lt;br /&gt;&#xA;and the Lagrangian is:\&#xA;&lt;span class=&quot;math-container&quot;&gt;$L(x,z,\lambda)=  ||z_1||+||z_2||+||z_3||+\sum_{i=1}^3\lambda_i^T(z_i-x+a_i)=\sum_{i=1}^{3}\lambda_i^Tz_i+||z_i||-x\sum\lambda_i+\sum\lambda_i^Ta_i$&lt;/span&gt;\&lt;/p&gt;&#xA;&lt;p&gt;From &lt;span class=&quot;math-container&quot;&gt;$-x\sum\lambda_i$&lt;/span&gt; we can deduce that &lt;span class=&quot;math-container&quot;&gt;$\sum \lambda_i=0$&lt;/span&gt; else we get &lt;span class=&quot;math-container&quot;&gt;$-\infty$&lt;/span&gt;.&#xA;Now when we try to solve for each &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; we can see it is sperable for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and minimizing &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; we get the following minimizing problem &lt;span class=&quot;math-container&quot;&gt;$\min_{z_i}\lambda_i^Tz_i+||z_i||$&lt;/span&gt;  which have finite solution iff &lt;span class=&quot;math-container&quot;&gt;$||\lambda_i||\leq1$&lt;/span&gt;(seen in class for 1-D case).\&#xA;So the dual problem is:\&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\underset{\lambda_i\in B}{q(\lambda_1,\lambda_2,\lambda_3)}=\sum\lambda_i^Ta_i$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$B=\{\lambda_i\in\mathbb{R}^n:\sum_{i=1}^{3}\lambda_i=0,||\lambda_i||\leq1\}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4526" LastActivityDate="2021-01-06T08:49:01.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5485" PostTypeId="1" CreationDate="2021-01-06T10:02:07.980" Score="5" ViewCount="514" Body="&lt;p&gt;If you're programming OR challenges in Python, besides using mathematical optimization software (= constraint solvers), which other libraries do you often use? Maybe for mundane tasks such as data parsing, etc. Why? How do they make your life easier?&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-01-06T11:12:52.693" Title="Python for OR: Which non-solver libraries do you use?" Tags="|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5486" PostTypeId="1" CreationDate="2021-01-06T10:04:41.467" Score="5" ViewCount="83" Body="&lt;p&gt;If you're programming OR challenges in Java, besides using constraint solvers, which other libraries do you typically use? Maybe for common tasks such as data reading, etc. Why? How do they make your life easier?&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-01-06T22:15:56.350" Title="Java in OR: Which non-constraint solving libraries do you use?" Tags="|java|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5487" PostTypeId="2" ParentId="5481" CreationDate="2021-01-06T10:31:54.707" Score="4" Body="&lt;p&gt;A problem with subgradient optimization is the phenomenon of “zigzagging” in the vicinity of the optimal solution. That is, it is often seen that the direction of search in one step is almost opposite to the search direction in the previous step. This often yields very slow convergence. Many different schemes to prevent this behavior have been proposed in the literature. I will focus on two schemes proposed in  (&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0377221798001945?casa_token=EBsfwOkwcpAAAAAA:yS2YwjYiO8xwQ7YKdF2BVNoPGviEWTJPQ-YFk5LL5AcNRzLIqGUa4c9M6cPoQp8qd0TkIJe_Y1U&quot; rel=&quot;nofollow noreferrer&quot;&gt;Baker and Sheasby, 1999&lt;/a&gt;) and (&lt;a href=&quot;https://link.springer.com/chapter/10.1007/BFb0120697&quot; rel=&quot;nofollow noreferrer&quot;&gt;Camerini, Fratta and Maffioli, 1975&lt;/a&gt;).&#xA;The method proposed by Baker and Sheasby is known as &lt;em&gt;exponential smoothing&lt;/em&gt; and works as follows: In iteration &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; of the subgradient procedure, a subgradient is found given &lt;span class=&quot;math-container&quot;&gt;$g^k$&lt;/span&gt;. In stead of moving in the direction of &lt;span class=&quot;math-container&quot;&gt;$g^k$&lt;/span&gt;, an alternative direction given by&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;h^k=(1-\alpha)h^{k-1} +\alpha g^k&#xA;\end{equation}&lt;/span&gt;&#xA;is used. Here &lt;span class=&quot;math-container&quot;&gt;$\alpha\in(0,1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h^0:= g^1$&lt;/span&gt;, meaning that we are search in the direction of the subgradient only in the first iteration.&lt;/p&gt;&#xA;&lt;p&gt;Antoher method, with some more theoretical justification, is propsoed in Camerini et al.. Here the subgradient at iteration &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$g^k$&lt;/span&gt;, is &lt;em&gt;deflected&lt;/em&gt; as follows&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;h^k = g^k-\delta_kh^{k-1}&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\delta\geq 0$&lt;/span&gt; is given by the expression&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA; \delta_k=\begin{cases}&#xA;  \gamma_k\frac{h^{k-1}\cdot g^k}{\Vert h^{k-1}\Vert^2}, &amp;amp;\text{if}\ h^{k-1}\cdot g^k&amp;lt;0\\&#xA;0,&amp;amp;\text{otherwise}&#xA;\end{cases}&#xA;\end{equation}&lt;/span&gt;&#xA;The parameter &lt;span class=&quot;math-container&quot;&gt;$\gamma_k$&lt;/span&gt; should be taken from the interval &lt;span class=&quot;math-container&quot;&gt;$[0,2]$&lt;/span&gt; for convergence to be guaranteed. Camerini et al. show that this scheme is not worse than &lt;em&gt;plain&lt;/em&gt; subgradient optimization.&lt;/p&gt;&#xA;&lt;p&gt;The good thing with these strategies is that they are extremely easy to implement when you have your subgradient procedure up and running. So it will only take you a couple of hours to see if it works for you.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="123" LastEditDate="2021-01-06T13:57:13.533" LastActivityDate="2021-01-06T13:57:13.533" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5488" PostTypeId="2" ParentId="5485" CreationDate="2021-01-06T11:07:42.880" Score="6" Body="&lt;p&gt;I can do 90% of my work with the following :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pandas.pydata.org/&quot; rel=&quot;noreferrer&quot;&gt;pandas&lt;/a&gt; for data&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://networkx.org/&quot; rel=&quot;noreferrer&quot;&gt;networkx&lt;/a&gt; for graphs&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://coin-or.github.io/pulp/&quot; rel=&quot;noreferrer&quot;&gt;pulp&lt;/a&gt; for linear programming modeling&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://ipyleaflet.readthedocs.io/en/latest/index.html&quot; rel=&quot;noreferrer&quot;&gt;ipyleaflet&lt;/a&gt; for interactive maps&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/pyutils/line_profiler&quot; rel=&quot;noreferrer&quot;&gt;line profiler&lt;/a&gt; for code profiling&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I use them extensively because they are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;used by many others&lt;/li&gt;&#xA;&lt;li&gt;well documented&lt;/li&gt;&#xA;&lt;li&gt;maintained&lt;/li&gt;&#xA;&lt;li&gt;user friendly&lt;/li&gt;&#xA;&lt;li&gt;free&lt;/li&gt;&#xA;&lt;li&gt;open source&lt;/li&gt;&#xA;&lt;li&gt;robust&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-01-06T11:12:52.693" LastActivityDate="2021-01-06T11:12:52.693" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5489" PostTypeId="1" AcceptedAnswerId="5490" CreationDate="2021-01-06T11:12:16.150" Score="4" ViewCount="451" Body="&lt;p&gt;I have a mixed-integer nonlinear programming (MINP) problem.&#xA;Is there a free solver for such a problem?&lt;/p&gt;&#xA;" OwnerUserId="4735" LastActivityDate="2023-05-22T13:29:51.407" Title="Free solver for MINP problems" Tags="|mixed-integer-programming|solver|nonlinear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5490" PostTypeId="2" ParentId="5489" CreationDate="2021-01-06T13:17:12.197" Score="6" Body="&lt;h2&gt;&lt;a href=&quot;https://github.com/coin-or/Couenne&quot; rel=&quot;nofollow noreferrer&quot;&gt;COUENNE&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;An open-source deterministic global MINLP solver.&lt;/p&gt;&#xA;&lt;h2&gt;&lt;a href=&quot;https://github.com/coin-or/Bonmin&quot; rel=&quot;nofollow noreferrer&quot;&gt;BONMIN&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;An open-source local MINLP solver.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Octeract Engine is no longer free as of summer 2022. The free version has since been replaced by Octeract Neural.&lt;/p&gt;&#xA;&lt;h2&gt;&lt;a href=&quot;https://octeract.com/octeract-engine/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Engine&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;(our own solver) is a commercial massively parallel deterministic global MINLP solver that is &lt;a href=&quot;https://octeract.com/get-a-licence/&quot; rel=&quot;nofollow noreferrer&quot;&gt;free for academics&lt;/a&gt;. What's more interesting is that &lt;strong&gt;starting next month the 1-core version of Octeract Engine will also be free for commercial purposes (therefore for everyone)&lt;/strong&gt;. We're still setting up the web framework for people to get that version automatically, but in the meantime you can just request a &lt;a href=&quot;https://octeract.com/get-a-licence/&quot; rel=&quot;nofollow noreferrer&quot;&gt;commercial trial&lt;/a&gt; on our website and we'll send you the free 1-core licence automatically when the trial runs out.&lt;/p&gt;&#xA;&lt;p&gt;Since I have written a lot of the code I cannot overstate how biased I am, but this is the solver I would recommend - as of the current version (1.9) the 1-core version &lt;strong&gt;finds feasible solutions for 94.5% of 3,016 test problems&lt;/strong&gt; (pretty much every test problem ever published) within 30 minutes, which is vastly superior to open-source alternatives.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2023-05-22T13:29:51.407" LastActivityDate="2023-05-22T13:29:51.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5491" PostTypeId="2" ParentId="5486" CreationDate="2021-01-06T22:15:56.350" Score="4" Body="&lt;p&gt;A few key ones that I use are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://algs4.cs.princeton.edu/code/&quot; rel=&quot;nofollow noreferrer&quot;&gt;algs4&lt;/a&gt; -- a variety of programs/utilities from an online course at Princeton (Go Tiger!), including some graph/network libraries&lt;/li&gt;&#xA;&lt;li&gt;Various &lt;a href=&quot;https://commons.apache.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Apache Commons&lt;/a&gt; libraries -- for reading/writing CSV files, doing operations on collections that Java currently does not directly support, and so on&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.renjin.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Renjin&lt;/a&gt; -- let's me execute R code inside a Java program (not something I do often, but it has come up once or twice)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/xerial/sqlite-jdbc&quot; rel=&quot;nofollow noreferrer&quot;&gt;SQLite JDBC&lt;/a&gt; -- for pulling data from/pushing data to SQL databases (handy when you're running a bunch of experiments with different combinations of problem/algorithm/parameters and you want to store results in a coherent manner)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://watchmaker.uncommons.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Watchmaker Framework&lt;/a&gt; -- Java framework for genetic algorithms (not under active development, and there are several other Java packages for GAs, some newer, but I like Watchmaker)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://x-stream.github.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;XStream&lt;/a&gt; -- converts Java objects to XML and back&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I've also had reason to use a Java matrix library, but I've yet to find one that I like and, importantly, trust, so I'm not naming any here. (I've tried a few that exhibited a &amp;quot;good enough for government work&amp;quot; attitude about computing matrix ranks and doing rank-revealing QR decompositions.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-01-06T22:15:56.350" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5493" PostTypeId="1" CreationDate="2021-01-07T11:30:49.137" Score="6" ViewCount="1566" Body="&lt;p&gt;How do you write order in a linear program?&lt;/p&gt;&#xA;&lt;p&gt;For instance, you want to arrange red and blue marbles labelled 1 – 30 each, and you would want to arrange it in ascending order,  you cannot have red marble #28 before #7 - how do you communicate that through LP?&lt;/p&gt;&#xA;" OwnerUserId="4739" LastEditorUserId="491" LastEditDate="2021-01-11T18:30:09.307" LastActivityDate="2021-01-11T18:30:09.307" Title="How do you take into account order in linear programming?" Tags="|linear-programming|binary-variable|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5494" PostTypeId="2" ParentId="5493" CreationDate="2021-01-07T15:34:42.113" Score="11" Body="&lt;p&gt;Presumably you have binary decision variables like &lt;span class=&quot;math-container&quot;&gt;$x_{ik} = 1$&lt;/span&gt; if marble #&lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is in slot #&lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. Then you can write a constraint like&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{ik} \le 1 - x_{jl} \qquad \forall \text{$i &amp;lt; j$ and $k &amp;gt; l$}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In other words, if &lt;span class=&quot;math-container&quot;&gt;$i &amp;lt; j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is in slot &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; cannot be in any slot &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; that comes after &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2021-01-07T15:34:42.113" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5495" PostTypeId="1" AcceptedAnswerId="5499" CreationDate="2021-01-08T02:54:29.623" Score="3" ViewCount="145" Body="&lt;p&gt;I'm trying to understand what my options are for optimizing a black-box simulation (output from a commercial, closed source finite element solver).&lt;/p&gt;&#xA;&lt;p&gt;An example problem is the following.  We have a building composed of a large number of beams.  The size of each beam comes from a discrete set of choices (depending on what is available from the manufacturer).  We would like to minimize the weight under some constraints, for example the internal force in each beam needs to be lower than its maximum force capacity.&lt;/p&gt;&#xA;&lt;p&gt;At the moment we simply start with the lowest-weight solution, and iteratively increase the sizes until the constraints are satisfied, but this can result in cycles (increasing the size of one beam and increase the load in an another).  We are looking for something that is a bit more robust.&lt;/p&gt;&#xA;&lt;p&gt;I think what I'm looking for is surrogate optimization.  But ideally I would like to work with hundreds if not thousands of variables and I think methods like Bayesian optimization are limited to low dimensional problems.  I'm happy with just finding  'good-enough' solutions instead of a global optimal.&lt;/p&gt;&#xA;" OwnerUserId="4740" LastActivityDate="2021-01-08T12:22:42.443" Title="Optimizing black-box finite element model" Tags="|nonlinear-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5496" PostTypeId="2" ParentId="5493" CreationDate="2021-01-08T09:46:55.470" Score="6" Body="&lt;p&gt;As per the answer by @LarrySnyder610, we can use position-based variable &lt;span class=&quot;math-container&quot;&gt;$x_{ik}$&lt;/span&gt; to model such scenarios. Note that we also need the following constraints to ensure that each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to exactly one position &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{k}x_{ik}=1 ~~~~~~~~ \forall i&#xA;$$&lt;/span&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the total number of possible &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, then this method requires &lt;span class=&quot;math-container&quot;&gt;$\mathcal{O}(n^4)$&lt;/span&gt; constraints. Another way to model this is to introduce &lt;em&gt;auxiliary variables&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; to capture the position number of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. In this case, we can use the following constraints to achieve the same result:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{k}x_{ik}=1 ~~~~~~~~ \forall i\\&#xA;\sum_{k}kx_{ik}=p_i ~~~~~~~~ \forall i\\&#xA;p_i \le p_{i+1} ~~~~~~~~ \forall i&amp;lt;n.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this case, the order of the constraints is reduced to &lt;span class=&quot;math-container&quot;&gt;$\mathcal{O}(n)$&lt;/span&gt;. In addition, the number of non-zero elements of the coefficient matrix is reduced which could result in faster LP-relaxation solutions. Such application of the auxiliary variables has been shown to be effective in some cases (see e.g., &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0305054815001446&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221715010851&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2021-01-08T09:46:55.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5497" PostTypeId="1" CreationDate="2021-01-08T12:10:07.523" Score="1" ViewCount="699" Body="&lt;p&gt;I am doing inventory optimization for my firm and need to compute the safety stock for a couple of products. I have learned that the correct quantity to consider in calculating the safety stock is the standard deviation of the forecast error.&lt;/p&gt;&#xA;&lt;p&gt;Currently I have have observed one year's monthly demand data &lt;span class=&quot;math-container&quot;&gt;$d_1, d_2,\ldots,d_{12}$&lt;/span&gt;, and correspondingly I have the monthly demand forecast &lt;span class=&quot;math-container&quot;&gt;$\hat{d}_1,\hat{d}_2,\ldots,\hat{d}_{12}$&lt;/span&gt;. I have found the forecast error &lt;span class=&quot;math-container&quot;&gt;$e_i = d_i-\hat{d}_i$&lt;/span&gt;, and the (squared) standard deviation for the forecast error &lt;span class=&quot;math-container&quot;&gt;$\sigma^2 = &#xA;\frac{1}{11}\sum (e_i - \bar{e})^2$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\bar{e}=\frac{1}{12}\sum e_i$&lt;/span&gt; is the mean of forecast error.&lt;/p&gt;&#xA;&lt;p&gt;But somehow, in planning the inventory policy it is more convenient to have the daily demand data, the way we do this is to use the monthly demand data and divide each of them by &lt;span class=&quot;math-container&quot;&gt;$30$&lt;/span&gt; to have a daily demand. So my question is how should we scale the corresponding standard deviation for the forecast error from month to day. Is dividing &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$\sqrt{30}$&lt;/span&gt; reasonable?&lt;/p&gt;&#xA;" OwnerUserId="4743" LastEditorUserId="123" LastEditDate="2021-01-08T13:55:46.807" LastActivityDate="2022-03-12T00:54:47.427" Title="Scaling of standard deviation for forecast error" Tags="|inventory|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5498" PostTypeId="2" ParentId="5493" CreationDate="2021-01-08T12:18:29.173" Score="2" Body="&lt;p&gt;Considering you have a set of n variables (elements) &lt;span class=&quot;math-container&quot;&gt;$p_1, p_2, …, p_n$&lt;/span&gt; to be sorted in ascending order so that&#xA;&lt;span class=&quot;math-container&quot;&gt;$p_{[1]}, p_{[2]}, …, p_{[n]}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$p_{[1]} \leq p_{[2]} \leq …\leq p_{[n]}$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;you can introduce &lt;span class=&quot;math-container&quot;&gt;$n^2$&lt;/span&gt; binary decision variable &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;  variables &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x_{i,j}=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$i-th$&lt;/span&gt; element is assigned to &lt;span class=&quot;math-container&quot;&gt;$j-th$&lt;/span&gt; position.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ min \left \{ \sum_{i = 1}^n A_i \right \} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subject to&lt;/p&gt;&#xA;&lt;p&gt;:&lt;span class=&quot;math-container&quot;&gt;$ \left\{ \begin{array}{l} &#xA;A_1 =  \sum_{i=1}^n x_{i,1} \cdot \ p_{i}  \\ &#xA;A_2 = A_1 +  \sum_{i=1}^n x_{i,2} \cdot \ p_{i} \\ &#xA;\vdots \\&#xA;A_n = A_{n-1} +  \sum_{i=1}^n x_{i,n} \cdot \ p_{i}  \\&#xA;\sum_{i=1}^n x_{i,k} = 1   \forall \ k \\&#xA;\sum_{k=1}^n x_{i,k} = 1   \forall \ i  \\&#xA;A_i \ge 0   \forall \ i  \\&#xA;x_{i,k} \in \left \{ 0 ; 1 \right \} \forall \ i, k&#xA;\end{array} \right.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What it has been written works for example in &lt;em&gt;one machine scheduling problem&lt;/em&gt; where &lt;span class=&quot;math-container&quot;&gt;$p_1, p_2, …, p_n$&lt;/span&gt; represent &lt;strong&gt;processing times&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For example: the set &lt;span class=&quot;math-container&quot;&gt;$p_1=16.2, p_2=16, p3=16.1 , p_4=15.9, p_5=15.7, p_6=15.8 $&lt;/span&gt; is easily ordered by the model as &lt;span class=&quot;math-container&quot;&gt;$p_{[1]}=15.7, p_{[2]}=15.8, …, p_{[6]}=16.2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The element in first position is equal to &lt;span class=&quot;math-container&quot;&gt;$p_{[1]} = \sum_{i=1}^n x_{i,1} \cdot \ p_{i}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The element in second position is equal to &lt;span class=&quot;math-container&quot;&gt;$p_{[2]} = \sum_{i=1}^n x_{i,2} \cdot \ p_{i}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The element in third position is equal to &lt;span class=&quot;math-container&quot;&gt;$p_{[3]} = \sum_{i=1}^n x_{i,3} \cdot \ p_{i}$&lt;/span&gt;&#xA;...&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Remark&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you wish to sort in &lt;strong&gt;descending order&lt;/strong&gt; the set, it is sufficient to consider &lt;span class=&quot;math-container&quot;&gt;$ max \left \{ \sum_{i = 1}^n A_i \right \} $&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4114" LastActivityDate="2021-01-08T12:18:29.173" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5499" PostTypeId="2" ParentId="5495" CreationDate="2021-01-08T12:22:42.443" Score="6" Body="&lt;p&gt;Surrogate modeling is one of many options. Indeed, it usually does not scale to thousands of variables, unless you can incorporate some domain knowledge in a custom surrogate model. However, you have other options:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Surrogate modeling with fewer variables. For example, create a few size groups instead of independent beam sizes&lt;/li&gt;&#xA;&lt;li&gt;A local search or evolutionary method without surrogate modeling. It can perform quite well, in particular if your finite-element model is fast enough (say less than a second)&lt;/li&gt;&#xA;&lt;li&gt;Using gradient information if the finite-element solver can provide it. With it, a simple nonlinear optimization can yield good solutions with fewer calls to the solver&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I used to work on the blackbox optimization algorithm in &lt;a href=&quot;https://www.localsolver.com&quot; rel=&quot;noreferrer&quot;&gt;LocalSolver&lt;/a&gt;. It's powerful and user friendly, so I suggest trying it and the local search solver. For other options and ideas, you can have a look at the &lt;a href=&quot;https://www.ini.rub.de/PEOPLE/glasmtbl/projects/bbcomp/&quot; rel=&quot;noreferrer&quot;&gt;blackbox optimization competition&lt;/a&gt;. You can find many packages for surrogate modeling and evolutionary algorithms if you look around, particularly in the machine learning community.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2021-01-08T12:22:42.443" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5500" PostTypeId="2" ParentId="5497" CreationDate="2021-01-08T13:15:53.667" Score="2" Body="&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;I believe the question can be rephrased as: what is the method of converting &lt;span class=&quot;math-container&quot;&gt;$\sigma_1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\sigma_2$&lt;/span&gt;, where one is in a different time dimension than the other. Now, for most inventory systems, the following model satisfactorily captures the required relationship (Silver, 1998):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sigma_m = m^c\sigma_1$$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is the multiplier that connects both time dimension: so if &lt;span class=&quot;math-container&quot;&gt;$\sigma_1$&lt;/span&gt; is days, and &lt;span class=&quot;math-container&quot;&gt;$\sigma_m$&lt;/span&gt; is in months, &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$30$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is a coefficient that needs to be estimated. Then to find this coefficient , what you can do is, is to first calculate a forecast and find the associated forecast error by using:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$e_i(m) = \sum_{r=1}^m \hat{d}_{t, t+r} - \sum_{r=1}^m \hat{d}_{t+r} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So the forecast is compared to the actual demand that resulted over the immediate period of duration &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;. We ofcourse do this for several values of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&#xA;Then for each value of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; the sample standard deviation of forecast errors is computed used as an estimate of &lt;span class=&quot;math-container&quot;&gt;$\sigma_m$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sigma_m = \{\frac{1}{n-1}\sum_{t} [e_t(m)-\bar{e}(m)]^2]\}^\frac{1}{2}$$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\bar{e}(m) = \frac{\sum_{t} e_t(m)}{n}$&lt;/span&gt; is the average error for the &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; under consideration.&lt;/p&gt;&#xA;&lt;p&gt;We can then estimate &lt;span class=&quot;math-container&quot;&gt;$m^c$&lt;/span&gt; by looking at the ratio &lt;span class=&quot;math-container&quot;&gt;$$\frac{\sigma_m}{\sigma_1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;or we can find the slope of a regression line by taking the logarithm of this ratio:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$c \times log\space m $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;From empirical analysis, we know that &lt;span class=&quot;math-container&quot;&gt;$0.5$&lt;/span&gt; is a reasonable approximation that serves as a good fit. This gives us:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sigma_m = \sqrt{m}\sigma_1$$&lt;/span&gt;&#xA;Ofcourse, you could nowadays, calculate this relationship exactly per SKU.&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2021-01-08T19:17:22.520" LastActivityDate="2021-01-08T19:17:22.520" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5501" PostTypeId="2" ParentId="5497" CreationDate="2021-01-08T13:36:00.050" Score="2" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$(x_i)_{i\le n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(\hat x_i)_{i\le n}$&lt;/span&gt; be sequences of observed data and forecast values respectively. Suppose we wish to split each &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; equally over &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; elements so that &lt;span class=&quot;math-container&quot;&gt;$(x_i)_{i\le n}$&lt;/span&gt; becomes &lt;span class=&quot;math-container&quot;&gt;$(y_j)_{j\le mn}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$y_j=x_{\lceil j/m\rceil}/m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Denote the forecast error by &lt;span class=&quot;math-container&quot;&gt;$\varepsilon_i$&lt;/span&gt; and its variance by &lt;span class=&quot;math-container&quot;&gt;$\sigma_\varepsilon^2$&lt;/span&gt;. &lt;strong&gt;Assuming that&lt;/strong&gt;* &lt;span class=&quot;math-container&quot;&gt;$(\hat x_i)_{i\le n}$&lt;/span&gt; becomes &lt;span class=&quot;math-container&quot;&gt;$(\hat y_j)_{j\le mn}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\hat y_j=\hat x_{\lceil j/m\rceil}/m$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$E_j=y_j-\hat y_j$&lt;/span&gt;. Then &lt;span class=&quot;math-container&quot;&gt;$$\overline E=\frac1{mn}\sum_j(y_j-\hat y_j)=\frac 1m\bar\varepsilon$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;\begin{align}(mn-1)\sigma_E^2&amp;amp;=\sum_j\left(y_j-\hat y_j-\frac1m \bar\varepsilon\right)^2\\&amp;amp;=\sum_j(y_j-\hat y_j)^2-\frac nm\bar\varepsilon^2\\&amp;amp;=\frac1m\left(\sum_i\varepsilon_i^2-n\bar\varepsilon^2\right)=\frac{n-1}m\sigma_\varepsilon^2.\end{align}&lt;/span&gt; Hence &lt;span class=&quot;math-container&quot;&gt;$$\sigma_E=\sigma_\varepsilon\sqrt{\frac{n-1}{m(mn-1)}}.$$&lt;/span&gt; So in your case with &lt;span class=&quot;math-container&quot;&gt;$m=30$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n=12$&lt;/span&gt;, the SD of the daily forecast error is around &lt;span class=&quot;math-container&quot;&gt;$3.2\%$&lt;/span&gt; of that of the monthly forecast error. It should be noted that when &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is large we have the reasonably good approximation &lt;span class=&quot;math-container&quot;&gt;$\sigma_E\approx\sigma_\varepsilon/m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;* This does not necessarily hold. Given the split in observed data you may need to re-run your model to obtain a new set of forecast values, whose sum may differ from that originally.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2021-01-08T15:16:34.037" LastActivityDate="2021-01-08T15:16:34.037" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5502" PostTypeId="2" ParentId="5359" CreationDate="2021-01-08T14:41:16.880" Score="2" Body="&lt;p&gt;Sometimes it already helps to know the name of a problem.&#xA;From a more theoretical point of view, i believe that there is a community working on your problem. I know the problem you describe under the term: constraint propagation.&lt;/p&gt;&#xA;&lt;p&gt;For an introduction check for instance: &lt;a href=&quot;http://www.cs.unibo.it/%7Egabbri/MaterialeCorsi/CP@CS.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.cs.unibo.it/~gabbri/MaterialeCorsi/CP@CS.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3224" LastActivityDate="2021-01-08T14:41:16.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5503" PostTypeId="1" AcceptedAnswerId="5504" CreationDate="2021-01-09T09:18:30.013" Score="19" ViewCount="904" Body="&lt;p&gt;Recently, I attended a very nice talk given by someone at the place I work about applying Deep Reinforcement Learning (DRL) for a design optimization problem. It was particularly interesting to me because I was not aware about this domain in optimization that is emerging.&lt;/p&gt;&#xA;&lt;p&gt;However, one thing which I could not understand is that what is the motivation behind using DRL approach for such problems? If the problem is extremely complex, then one way to solve them can be by building black box data-driven models and then using heuristics. What advantages does DRL offers over gradient-based or gradient-free optimization?&lt;/p&gt;&#xA;&lt;p&gt;Would anyone, who has experience in working on such topic like to share their opinion? Also, is there some standard text or paper that you can point me to?&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="2424" LastEditDate="2021-01-09T23:41:24.327" LastActivityDate="2021-01-09T23:41:24.327" Title="Deep Reinforcement Learning for General Purpose Optimization" Tags="|optimization|reference-request|nonlinear-programming|machine-learning|reinforcement-learning|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5504" PostTypeId="2" ParentId="5503" CreationDate="2021-01-09T17:31:09.420" Score="24" Body="&lt;p&gt;&amp;quot;General purpose optimization&amp;quot; is quite broad, so I'll take a step back first, to better identifying the motivation of using ML in optimization settings.&lt;/p&gt;&#xA;&lt;p&gt;To keep things simple, I'll consider a single-objective minimization problem with decision vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, objective function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and some constraints &lt;span class=&quot;math-container&quot;&gt;$x \in X$&lt;/span&gt;, i.e.,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(P) \ \ \ \min_{x} \ \ \ &amp;amp; f(x)\\&#xA;\text{s.t.} \ \ \ &amp;amp; x \in X.&#xA;\end{align}&lt;/span&gt;&#xA;&amp;quot;Solving&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$(P)$&lt;/span&gt; means&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;finding &lt;span class=&quot;math-container&quot;&gt;$x^{*} \in X$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$f(x^{*})$&lt;/span&gt; is as small as possible, and&lt;/li&gt;&#xA;&lt;li&gt;proving that there does not exist an &lt;span class=&quot;math-container&quot;&gt;$\bar{x} \in X$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$f(\bar{x}) &amp;lt; f(x^{*})$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Heuristic methods will only handle 1., approximation algorithms handle 1. with some guarantee w.r.t 2., and exact methods ensure both 1. and 2.&lt;/p&gt;&#xA;&lt;p&gt;Now, where can ML come into play?&#xA;I will outline two of the most common avenues in combinatorial optimization.&lt;/p&gt;&#xA;&lt;p&gt;For background:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;quot;Machine Learning for Combinatorial Optimization: a Methodological Tour d'Horizon&amp;quot; (&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221720306895&quot; rel=&quot;noreferrer&quot;&gt;journal version&lt;/a&gt; and &lt;a href=&quot;https://arxiv.org/abs/1811.06128&quot; rel=&quot;noreferrer&quot;&gt;preprint&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://sites.google.com/view/ml4co-ijcai20/home&quot; rel=&quot;noreferrer&quot;&gt;ML4CO Tutorial @ IJCAI 2021&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;ML-based heuristic solutions&lt;/h2&gt;&#xA;&lt;p&gt;A first and perhaps most intuitive approach is to use a model to predict &lt;span class=&quot;math-container&quot;&gt;$x^{*}$&lt;/span&gt; based on the problem's data: give me &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and I will tell you &lt;span class=&quot;math-container&quot;&gt;$x^{*}$&lt;/span&gt; (see also &lt;a href=&quot;https://sites.google.com/view/ml4co-ijcai20/home#h.kocdbqe3xqh7&quot; rel=&quot;noreferrer&quot;&gt;Part 2 of the IJCAI tutorial&lt;/a&gt;).&#xA;For problems where feasibility is not hard (e.g. unconstrained problems or problems with a simple constraint structure), this can give decent results.&#xA;In the general case, however, one must ensure that the predicted solution is feasible, or tolerate some amount of infeasibility.&lt;/p&gt;&#xA;&lt;p&gt;A more refined approach consists in using ML techniques to &lt;em&gt;learn&lt;/em&gt; heuristics.&#xA;A typical example is a greedy algorithm wherein ones uses a learning scheme (typically trained offline) to select the next move.&#xA;Some examples: &lt;a href=&quot;https://arxiv.org/abs/1611.09940&quot; rel=&quot;noreferrer&quot;&gt;Neural Combinatorial Optimization with Reinforcement Learning&lt;/a&gt;, &lt;a href=&quot;https://arxiv.org/abs/1704.01665&quot; rel=&quot;noreferrer&quot;&gt;Learning Combinatorial Optimization Algorithms over Graphs&lt;/a&gt; or &lt;a href=&quot;https://arxiv.org/abs/1910.07600&quot; rel=&quot;noreferrer&quot;&gt;Learning chordal extensions&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Tailored algorithmic strategies&lt;/h2&gt;&#xA;&lt;p&gt;A lot of optimization algorithms, from simple gradient descent to sophisticated branch-and-bound methods, rely on a number of heuristic decisions.&#xA;Some are static: should the problem be linearized or not? which algorithm should I use?; some are dynamic: which variable should I branch on? which cuts should be added? should I perform a restart now?&lt;/p&gt;&#xA;&lt;p&gt;In any case, ML techniques offer the possibilities of tuning those heuristic decisions to a particular distribution of instances (see &lt;a href=&quot;https://sites.google.com/view/ml4co-ijcai20/home#h.ytuh5eg814l&quot; rel=&quot;noreferrer&quot;&gt;Part 3 of the ML4CO Tutorial @ IJCAI&lt;/a&gt;).&#xA;Again, some examples:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Deciding whether to linearize a problem or not: &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-319-93031-2_43&quot; rel=&quot;noreferrer&quot;&gt;initial paper&lt;/a&gt;, which was later implemented in CPLEX.&lt;/li&gt;&#xA;&lt;li&gt;Learning-based branching strategies: &lt;a href=&quot;https://papers.nips.cc/paper/2019/file/d14c2267d848abeb81fd590f371d39bd-Paper.pdf&quot; rel=&quot;noreferrer&quot;&gt;Exact Combinatorial Optimizationwith Graph Convolutional Neural Networks&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Learning-based approaches to cut selection: &lt;a href=&quot;https://arxiv.org/pdf/1906.04859.pdf&quot; rel=&quot;noreferrer&quot;&gt;Reinforcement Learning for Integer Programming: Learning to Cut&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Some intrinsic limitations&lt;/h2&gt;&#xA;&lt;p&gt;There are two theoretical elements that, I think, underlie some intrinsic limitations to the above approaches: &lt;a href=&quot;https://en.wikipedia.org/wiki/Computational_complexity_theory&quot; rel=&quot;noreferrer&quot;&gt;computational complexity&lt;/a&gt; and the &lt;a href=&quot;https://en.wikipedia.org/wiki/No_free_lunch_theorem&quot; rel=&quot;noreferrer&quot;&gt;no free lunch theorem&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;First, unless P=NP, problems that are NP-hard cannot be solved in polynomial time. This means that any algorithm (whether based on ML or not) that only performs polynomially many operations cannot return an optimal solution all the time. However, this does not prevent highly-tuned heuristics from obtaining excellent-quality solutions in practice.&#xA;Likewise, sometimes even finding a feasible solution &lt;span class=&quot;math-container&quot;&gt;$x \in X$&lt;/span&gt; can be NP-hard in itself, and it becomes impossible to guarantee that a polynomial-time oracle (whether based on ML or not) can always return a feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;Second, the no free lunch theorem essentially states that, if an algorithm performs well on a set of problems, then there exists a set of problems on which it will perform badly.&#xA;In practice, this means one likely must re-train their ML models when dealing with a new problem distribution; this comes at a computational and financial cost.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2021-01-09T17:31:09.420" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5506" PostTypeId="1" CreationDate="2021-01-11T01:49:54.963" Score="4" ViewCount="221" Body="&lt;p&gt;Where can I find the formulation of the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-MST (&lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-minimum spanning tree) problem as (mixed) integer linear program&#xA;based on Miller-Tucker-Zemlin subtour elimination constraints (MTZ)?&lt;/p&gt;&#xA;" OwnerUserId="4735" LastEditorUserId="278" LastEditDate="2021-01-11T11:39:55.067" LastActivityDate="2021-01-12T11:34:08.490" Title="k -MST problem based on Miller-Tucker-Zemlin subtour elimination constraints" Tags="|mixed-integer-programming|reference-request|combinatorial-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5508" PostTypeId="1" CreationDate="2021-01-11T21:52:14.613" Score="2" ViewCount="128" Body="&lt;p&gt;If a matrix is totally unimodular (TU), then we know that &lt;span class=&quot;math-container&quot;&gt;$\text{\{}x| Ax\leq b \text{\}}$&lt;/span&gt; is integral for all integral &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;'s. This is often used for convex hull proofs, but does the concept of TU has further applications?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="199" LastEditDate="2021-01-12T06:43:42.067" LastActivityDate="2021-01-12T07:09:53.890" Title="Has the concept of TU other application than proving convex hull characterizations?" Tags="|integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5509" PostTypeId="2" ParentId="5508" CreationDate="2021-01-12T07:09:53.890" Score="1" Body="&lt;p&gt;&lt;strong&gt;The reference: Model building in mathematical programming&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Total unimodularity is a strong property that guarantees integer optimal solutions to an LP problem for all &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and integer &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. Many IP models for which the matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is not totally unimodular frequently (although not always) produce integer solutions to the optimal solution of the corresponding LP problem.&lt;/p&gt;&#xA;&lt;p&gt;In particular, this often happens with the set packing, partitioning and covering problems. There is, therefore, great virtue in such a reformulation as the high computational costs associated with an IP problem over an LP problem is avoided. For example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KWbNb.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KWbNb.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-01-12T07:09:53.890" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5510" PostTypeId="2" ParentId="5506" CreationDate="2021-01-12T11:34:08.490" Score="1" Body="&lt;p&gt;Is this the formulation that you are looking for:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Min-degree constrained minimum spanning tree problem: New formulation&#xA;via Miller–Tucker–Zemlin constraints&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://yoksis.bilkent.edu.tr/pdf/files/10.1016-j.cor.2009.03.006.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://yoksis.bilkent.edu.tr/pdf/files/10.1016-j.cor.2009.03.006.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-01-12T11:34:08.490" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5511" PostTypeId="2" ParentId="5449" CreationDate="2021-01-12T14:26:35.083" Score="4" Body="&lt;p&gt;There is a new book &lt;a href=&quot;https://www.springer.com/gp/book/9783030521189&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bilevel Optimization Advances and Next Challenges&lt;/a&gt; which has a great deal of material on game theory, and how it can be handled with Bilevel Optimization.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Chapters&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;•   Interactions Between Bilevel Optimization and Nash Games&#xA;•   On Stackelberg–Nash Equilibria in Bilevel Optimization Games&#xA;•   A Short State of the Art on Multi-Leader-Follower Games&#xA;•   Regularization and Approximation Methods in Stackelberg Games and Bilevel Optimization&#xA;•   Applications of Bilevel Optimization in Energy and Electricity Markets&#xA;•   Bilevel Optimization of Regularization Hyperparameters in Machine Learning&#xA;•   Bilevel Optimization and Variational Analysis&#xA;•   Constraint Qualifications and Optimality Conditions in Bilevel Optimization&#xA;•   Algorithms for Simple Bilevel Programming&#xA;•   Algorithms for Linear Bilevel Optimization&#xA;•   Global Search for Bilevel Optimization with Quadratic Data&#xA;•   MPEC Methods for Bilevel Optimization Problems&#xA;•   Approximate Bilevel Optimization with Population-Based Evolutionary Algorithms&#xA;•   Methods for Pessimistic Bilevel Optimization&#xA;•   Methods for Multiobjective Bilevel Optimization&#xA;•   Bilevel Optimal Control: Existence Results and Stationarity Conditions&#xA;•   Bilevel Linear Optimization Under Uncertainty&#xA;•   A Unified Framework for Multistage Mixed Integer Linear Optimization&#xA;•   BOLIB: Bilevel Optimization LIBrary of Test Problems&#xA;•   Bilevel Optimization: Theory, Algorithms, Applications and a Bibliography&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="68" LastActivityDate="2021-01-12T14:26:35.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5512" PostTypeId="1" AcceptedAnswerId="5515" CreationDate="2021-01-12T14:42:18.770" Score="2" ViewCount="98" Body="&lt;p&gt;I have few tasks &lt;code&gt;t1, t2, t3, t4, t5&lt;/code&gt; which need to be assigned to resources &lt;code&gt;r1, r2&lt;/code&gt;, the tasks are located across multiple districts &lt;code&gt;d1, d2&lt;/code&gt;, for example &lt;code&gt;t1, t2, t3&lt;/code&gt; are located in district &lt;code&gt;d1&lt;/code&gt; and &lt;code&gt;t4, t5&lt;/code&gt; are located in district &lt;code&gt;d2&lt;/code&gt;. Each task have some duration like &lt;code&gt;t1 : 3 hours, t2 : 3 hours, t3 : 4 hours, t4 : 4 hours, t5 : 5 hours&lt;/code&gt; also each resource have &lt;code&gt;8 hours&lt;/code&gt; of daily capacity.&lt;/p&gt;&#xA;&lt;p&gt;Here my question is how shall I create decision variables and constraints considering following requirements&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How do I enforce  that in a day resource can only be in one district ?&#xA;In other words, if resource is in &lt;code&gt;district d1&lt;/code&gt; then he can only attend &lt;code&gt;t1, t2, t3&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;task &lt;code&gt;t3&lt;/code&gt; can only be assigned to &lt;code&gt;resource r1&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1279" LastActivityDate="2021-01-12T16:37:20.537" Title="MIP for resources to task assignments" Tags="|mixed-integer-programming|scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5513" PostTypeId="1" AcceptedAnswerId="5514" CreationDate="2021-01-12T15:14:28.213" Score="1" ViewCount="737" Body="&lt;p&gt;I am trying to setup Gurobi with Google OR-Tools with the function &lt;code&gt;pywraplp.Solver.CreateSolver(&amp;quot;GUROBI&amp;quot;)&lt;/code&gt;. The function returns None, which could occur if Gurobi was not linked in, or if the Gurobi license is not supplied.&lt;/p&gt;&#xA;&lt;p&gt;Currently, &lt;code&gt;CreateSolver&lt;/code&gt; works with SCIP, and I could run Gurobi through the &lt;code&gt;gurobipy&lt;/code&gt; interface (I have the licenses set up correctly).&lt;/p&gt;&#xA;&lt;p&gt;I am using or-tools installed from pip (&lt;code&gt;pip install ortools&lt;/code&gt;).  Based on online documentation, the binary version of or-tools has support for Gurobi. I would like to know if there are any additional steps I need to take to set up or-tools, or if I must follow a set of instructions to compile or-tools from source to support Gurobi.&lt;/p&gt;&#xA;" OwnerUserId="4751" LastEditorUserId="36" LastEditDate="2021-01-12T15:57:53.940" LastActivityDate="2021-01-12T15:57:53.940" Title="Problem with setting up gurobi with OR-tools" Tags="|gurobi|or-tools|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5514" PostTypeId="2" ParentId="5513" CreationDate="2021-01-12T15:43:32.833" Score="4" Body="&lt;p&gt;You need to install the binary package locally, with a correct license.&lt;/p&gt;&#xA;&lt;p&gt;It should pick it up at this point.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2021-01-12T15:43:32.833" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5515" PostTypeId="2" ParentId="5512" CreationDate="2021-01-12T16:00:49.347" Score="4" Body="&lt;p&gt;Start by defining the appropriate binary variable: &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1$&lt;/span&gt; if and only if task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to resource &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A given task can only be assigned to one resource:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_j x_{ij}=1 \quad \forall i&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Daily capacity for each resource:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_i \Delta_i x_{ij}\le 8 \quad \forall j&#xA;$$&lt;/span&gt;&#xA;(&lt;span class=&quot;math-container&quot;&gt;$\Delta_i$&lt;/span&gt; denotes the duration of task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;)&lt;/li&gt;&#xA;&lt;li&gt;task &lt;span class=&quot;math-container&quot;&gt;$t_3$&lt;/span&gt; must be assigned to resource &lt;span class=&quot;math-container&quot;&gt;$r_1$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{t_3,r_1}=1&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Can you take it from here ? I will leave you with question 1., which you should be able to do if you understand the above.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-01-12T16:37:20.537" LastActivityDate="2021-01-12T16:37:20.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5516" PostTypeId="1" AcceptedAnswerId="5517" CreationDate="2021-01-12T18:16:43.333" Score="3" ViewCount="1290" Body="&lt;p&gt;I have been working lately on scheduling optimization using CP-SAT in OR-TOOLS and now I'm at the point where I need to start considering due dates in my model.&lt;/p&gt;&#xA;&lt;p&gt;I didn't want to put them as constraints since I was afraid falling in this problem : &lt;a href=&quot;https://github.com/google/or-tools/issues/973&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/issues/973&lt;/a&gt; which would be very bugging for the end users.&lt;/p&gt;&#xA;&lt;p&gt;So instead I decided to do a multi-objective optimization like : &lt;a href=&quot;https://github.com/google/or-tools/issues/1344&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/issues/1344&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I will start by minimizing makespan after which I will try to minimize the sum(end date - due date) for jobs where end dates &amp;gt; due date, and that's where I have a problem.&lt;/p&gt;&#xA;&lt;p&gt;My question is how do I do a conditionnel sum in OR-Tools ?&lt;/p&gt;&#xA;&lt;p&gt;Currently my .net code looks like the following for that section :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    var DiffList = new List&amp;lt;LinearExpr&amp;gt;();&#xA;&#xA;    for (int i = 0; i &amp;lt; job_ends.Count(); i++)&#xA;    {&#xA;        if (DueDateList[i] &amp;lt; horizon)&#xA;        {&#xA;            var diff = job_ends[i] - DueDateList[i] ;&#xA;         &#xA;            DiffList.Add(diff);&#xA;        }&#xA;    }&#xA;    var DiffListSum = LinearExpr.Sum(DiffList);&#xA;&#xA;&#xA;    model.Minimize(DiffListSum);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have tried several technics already without much success :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OnlyEnforceIf(job_ends[i] &amp;gt; DueDateList[i]) =&amp;gt; Didn't work.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;model.Add(diff == (DueDateList[i] - job_ends[i])).OnlyEnforceIf(job_ends[i] &amp;gt; DueDateList[i]);&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if (job_ends[i] &amp;gt; DueDateList[i]) then add to the list =&amp;gt; Didn't work.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Please let me know if you have seen an exemple of this or if you have a solution for me.&lt;/p&gt;&#xA;" OwnerUserId="4145" LastEditorUserId="981" LastEditDate="2023-03-04T00:21:49.270" LastActivityDate="2023-04-05T19:31:20.187" Title="CP-SAT _ Summing variables under conditions" Tags="|or-tools|c#|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5517" PostTypeId="2" ParentId="5516" CreationDate="2021-01-12T21:29:44.870" Score="4" Body="&lt;p&gt;A few hours after posting my question here I found a concept I was not familiar with called channelling : &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/sat/docs/channeling.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/ortools/sat/docs/channeling.md&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I used it for my needs and it seems to works. I find a bit odd the way I set my variable b, but anyway...&lt;/p&gt;&#xA;&lt;p&gt;For those it can help, my code now looks like :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    var DiffList = new List&amp;lt;LinearExpr&amp;gt;();&#xA;&#xA;    for (int i = 0; i &amp;lt; job_ends.Count(); i++)&#xA;    {&#xA;        if (DueDateList[i] &amp;lt; horizon)&#xA;        {&#xA;&#xA;            var diff2 = model.NewIntVar(0, horizon, &amp;quot;DueDateList&amp;quot; + i);&#xA;&#xA;            var b = model.NewBoolVar(&amp;quot;b&amp;quot;); &#xA;&#xA;            model.Add(job_ends[i] &amp;gt; DueDateList[i]).OnlyEnforceIf(b);  &#xA;            model.Add(job_ends[i] &amp;lt; DueDateList[i]).OnlyEnforceIf(b.Not());&#xA;             &#xA;            model.Add(diff2 == job_ends[i] - DueDateList[i] ).OnlyEnforceIf(b);&#xA;            model.Add(diff2 == 0).OnlyEnforceIf(b.Not());&#xA;&#xA;            DiffList.Add(diff2);&#xA;        }&#xA;    }&#xA;     &#xA;    var DiffListSum = LinearExpr.Sum(DiffList);  &#xA;&#xA;    model.Minimize(DiffListSum);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4145" LastEditorUserId="981" LastEditDate="2023-04-05T19:31:20.187" LastActivityDate="2023-04-05T19:31:20.187" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5518" PostTypeId="1" AcceptedAnswerId="5522" CreationDate="2021-01-12T23:33:04.983" Score="3" ViewCount="1992" Body="&lt;p&gt;I recently posted a question &lt;a href=&quot;https://stackoverflow.com/questions/65677194/how-to-solve-for-multiple-solutions-to-linear-program-in-python?noredirect=1#comment116121079_65677194&quot;&gt;here&lt;/a&gt; where I had written some Pyomo code to solve a simple linear program, however I feel the Operations Research platform is perhaps a better fit for this question. My problem  is that every time I run this, I get just one optimal solution. I am wondering whether there is a way to produce a different solution every time I run the code (it doesn't have to always be a unique solution)?&lt;/p&gt;&#xA;&lt;p&gt;The problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ 3a+2b+2c=15$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-20\leqslant a \leqslant 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ 0 \leqslant b \leqslant 20$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ 20 \leqslant c \leqslant 50$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am also open to solutions in Pulp as well of Pyomo.&lt;/p&gt;&#xA;" OwnerUserId="4256" LastEditorUserId="4256" LastEditDate="2021-01-14T04:57:49.210" LastActivityDate="2021-01-15T15:50:05.390" Title="How to generate multiple solutions to linear program in Python?" Tags="|python|pyomo|pulp|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5519" PostTypeId="1" AcceptedAnswerId="5520" CreationDate="2021-01-13T18:44:35.880" Score="0" ViewCount="493" Body="&lt;p&gt;As far as I know, if there is a directed arc with a negative cost, we change its direction to its opposite and get a positive cost. But in the following question, if we change the direction of the arc with the negative cost, we can't get to node 4 or node 1. How do you think I should approach this?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HLt4m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HLt4m.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4647" LastEditorUserId="36" LastEditDate="2021-01-13T19:01:43.753" LastActivityDate="2021-01-13T19:30:25.803" Title="Minimum cost flow problem with negative cost arcs" Tags="|linear-programming|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5520" PostTypeId="2" ParentId="5519" CreationDate="2021-01-13T19:30:25.803" Score="1" Body="&lt;p&gt;No, making the change you describe could make the problem infeasible, as you observed for this instance.  Instead, just think of the negative cost as a reward.  If using the arc will reduce the overall cost, then the solver will exploit that.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-01-13T19:30:25.803" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5521" PostTypeId="2" ParentId="5518" CreationDate="2021-01-14T09:51:48.157" Score="3" Body="&lt;p&gt;Your problem does not have any objective function, so you do not have to use software to solve linear programs here. It is just a system of linear inequalities. (Of course, you still can use LP tools by just minimizing a constant objective function.)&lt;/p&gt;&#xA;&lt;p&gt;May I suggest a solution that neither requires &lt;code&gt;Pyomo&lt;/code&gt; nor &lt;code&gt;Pulp&lt;/code&gt;? You can solve those systems by using the &lt;a href=&quot;https://en.wikipedia.org/wiki/Fourier%E2%80%93Motzkin_elimination&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fourier-Motzkin Method&lt;/a&gt;. This would give you either no solution (if solution space is empty), one solution (if unique), or infinitely many (if solid). In the latter case, you should be able to get parametrized bounds for each variable depending on which order you eliminate the variables.&lt;/p&gt;&#xA;" OwnerUserId="130" LastEditorUserId="130" LastEditDate="2021-01-14T13:45:46.997" LastActivityDate="2021-01-14T13:45:46.997" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5522" PostTypeId="2" ParentId="5518" CreationDate="2021-01-14T10:37:31.747" Score="4" Body="&lt;p&gt;When I understand your question correctly you are not interested in the full solution space. In that case you can generate alternative optimal solutions by first solving your problem to optimality. Then you can add the objective function with the optimal value as a constraint and resolve with a random objective vector. For example for the problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA;\begin{align}&#xA;\min &amp;amp;&amp;amp; c^Tx\\&#xA;\text{s.t.}&amp;amp;&amp;amp; Ax\leq b\\&#xA;&amp;amp;&amp;amp; x\geq 0&#xA;\end{align}&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$C^*$&lt;/span&gt; be the optimal objective value you get from solving the initial problem and let &lt;span class=&quot;math-container&quot;&gt;$c'$&lt;/span&gt; be an other random objective vector. Then solving&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA;\begin{align}&#xA;\min &amp;amp;&amp;amp; c'^Tx\\&#xA;\text{s.t.}&amp;amp;&amp;amp; Ax&amp;amp;\leq b\\&#xA;&amp;amp;&amp;amp; c^Tx &amp;amp;= C^*\\&#xA;&amp;amp;&amp;amp; x&amp;amp;\geq 0&#xA;\end{align}&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;will give you a solution that is optimal with respect to the original objective &lt;span class=&quot;math-container&quot;&gt;$\min c^Tx$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you are interested in getting all optimal solutions you will need to find all optimal basis solutions as pointed you by @Erwin Kalvelagen &lt;a href=&quot;https://stackoverflow.com/questions/65677194/how-to-solve-for-multiple-solutions-to-linear-program-in-python?noredirect=1#comment116121079_65677194&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There are multiple ways to do so. Either you solve multiple MIPs where in each iteration you add cuts that prevent you from finding previously found basis solutions again. It is described in &lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2016/01/finding-all-optimal-lp-solutions.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; blog post. As pointed out by Erwin Kalvelagen some solvers like &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/finding_multiple_solutions.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;gurobi&lt;/a&gt; provide features that allow to extract multiple optimal solutions. If these are not available multiple MIPs might to be solved, which could result in quite big runtimes.&lt;/p&gt;&#xA;&lt;p&gt;The more direct way would be to modify the &lt;a href=&quot;https://en.wikipedia.org/wiki/Simplex_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Simplex Algorithm&lt;/a&gt; to not exchange for better basis solutions, but for equal ones. Starting with an optimal solution (which you can get from any LP solver you want) you choose entering variables with entry in the objective row &lt;span class=&quot;math-container&quot;&gt;$=0$&lt;/span&gt;. For leaving variables you proceed as usual. To ensure you find all solutions you can use classic &lt;a href=&quot;https://en.wikipedia.org/wiki/Graph_traversal&quot; rel=&quot;nofollow noreferrer&quot;&gt;graph traversal&lt;/a&gt; techniques.&lt;/p&gt;&#xA;&lt;p&gt;Note that any optimal solution can then be expressed as linear combinations of the optimal basis solutions.&lt;/p&gt;&#xA;" OwnerUserId="4477" LastEditorUserId="4477" LastEditDate="2021-01-15T15:50:05.390" LastActivityDate="2021-01-15T15:50:05.390" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5523" PostTypeId="1" CreationDate="2021-01-14T12:53:46.483" Score="6" ViewCount="53" Body="&lt;p&gt;Consider an optimization problem with &lt;span class=&quot;math-container&quot;&gt;$n&amp;gt;3$&lt;/span&gt; objectives.&#xA;For handling this there exists often two approaches:&lt;/p&gt;&#xA;&lt;p&gt;a) some weighting of the objectives,&lt;/p&gt;&#xA;&lt;p&gt;b) fix an order of objectives and then optimize each one after another, allowing the objective of the previous optimization to only degrade by a small factor.&lt;/p&gt;&#xA;&lt;p&gt;The weighting or the small factor is often difficult to estimate &lt;em&gt;a priori&lt;/em&gt;.&#xA;Assume now someone who wants to find a solution with a good balance between the objective, by manually tweaking these parameters and wants to identify cases by say 1% degrading in this objective I can gain 80% gain in a different objective.&lt;/p&gt;&#xA;&lt;p&gt;What are useful plots/statistics/metrics for this, that help guide finding good parameters?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2021-01-15T10:39:23.700" LastActivityDate="2021-01-15T10:39:23.700" Title="What are useful plots/statistics/metrics when analyzing the solution sensitivity in multi-objective optimization?" Tags="|mixed-integer-programming|multi-objective-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5524" PostTypeId="1" CreationDate="2021-01-14T20:16:17.657" Score="2" ViewCount="92" Body="&lt;p&gt;I am solving a MILP model in C++ using Gurobi 10.1.&#xA;I retrieve the CPU time of my C++ program under Linux via the following commands:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;clock_t start_time;&#xA;double elapsed_time;&#xA;start_time= clock();&#xA;model.optimize();&#xA;elapsed_time = (double) (clock() - start_time)/CLOCKS_PER_SEC;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Each time I solve the same problem instance with the same gurobi options and using only ONE thread, I get different CPU times; sometimes drastically different; for example 6500 sec vs. 3800 sec.&lt;/p&gt;&#xA;&lt;p&gt;I do not understand why, in particular, since I use only one thread.&#xA;CPU time is also significantly larger than the wall-clock time.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, the wall-clock time remains stable.&lt;/p&gt;&#xA;&lt;p&gt;Can somebody help me understand this and fix this issue?&lt;/p&gt;&#xA;" OwnerUserId="4768" LastEditorUserId="36" LastEditDate="2021-01-14T20:23:47.710" LastActivityDate="2021-01-14T20:23:47.710" Title="CPU time on Linux with Gurobi" Tags="|optimization|gurobi|c++|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5525" PostTypeId="1" AcceptedAnswerId="5527" CreationDate="2021-01-14T11:17:28.397" Score="4" ViewCount="187" Body="&lt;p&gt;I'm considering the following basic assignment problem: a group of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; people is to be assigned, in one-to-one fashion, a set of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; jobs. Write &lt;span class=&quot;math-container&quot;&gt;$C_{ij}$&lt;/span&gt; for the cost incurred when person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; gets assigned to job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. I shall assume that the &lt;span class=&quot;math-container&quot;&gt;$C_{ij}$&lt;/span&gt; are iid exponentially distributed.&lt;/p&gt;&#xA;&lt;p&gt;I consider two greedy algorithms.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Algorithm A&lt;/strong&gt; assigns to person 1 the job that results in the least cost, then chooses for person 2 the cheapest job out of the remaining &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; options, and so on.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Algorithm B&lt;/strong&gt; considers all &lt;span class=&quot;math-container&quot;&gt;$n^2$&lt;/span&gt; cost values, finds the minimal pair &lt;span class=&quot;math-container&quot;&gt;$(i_1,j_1)$&lt;/span&gt;, and assigns person &lt;span class=&quot;math-container&quot;&gt;$i_1$&lt;/span&gt; to job &lt;span class=&quot;math-container&quot;&gt;$j_1$&lt;/span&gt;, so that &lt;span class=&quot;math-container&quot;&gt;$(n-1)^2$&lt;/span&gt; values remain, finds the minimal pair &lt;span class=&quot;math-container&quot;&gt;$(i_2,j_2)$&lt;/span&gt; out of those, and so on.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I claim that both algorithms have the same expected cost. By noting that the minimum of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; exponentially distributed variables of rate &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; is itself exponentially distributed of rate &lt;span class=&quot;math-container&quot;&gt;$k\mu$&lt;/span&gt;, one shows that algorithm A has expected cost&#xA;&lt;span class=&quot;math-container&quot;&gt;$$E(A) = 1 + \frac{1}{2} + \cdots + \frac{1}{n}.$$&lt;/span&gt;&#xA;Now for algorithm B. The minimal cost &lt;span class=&quot;math-container&quot;&gt;$C_{(i_1,j_1)}$&lt;/span&gt; is exponentially distributed of rate &lt;span class=&quot;math-container&quot;&gt;$n^2$&lt;/span&gt;. By memorylessness, &lt;span class=&quot;math-container&quot;&gt;$C_{(i_2,j_2)}$&lt;/span&gt; is equal to &lt;span class=&quot;math-container&quot;&gt;$C_{(i_1,j_1)}$&lt;/span&gt; plus an exponential of rate &lt;span class=&quot;math-container&quot;&gt;$(n-1)^2$&lt;/span&gt;, and so on, so that&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{split}&#xA;E(B) &amp;amp;= E(C_{(i_1,j_1)}) + \cdots + E(C_{(i_n,j_n)}) \\&#xA;&amp;amp;= n \cdot \frac{1}{n^2} + (n-1)\cdot \frac{1}{(n-1)^2} + \cdots + 1 \cdot \frac{1}{1^2}\\&#xA;&amp;amp;= \frac{1}{n} + \frac{1}{n-1} + \cdots + 1.&#xA;\end{split}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My intuition expecting the global approach to typically be more efficient, I was surprised by this outcome, and attempted to simulate the situation. Let's implement the greedy algorithms in Python.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def GreedyA(arr):&#xA;    total_cost = 0&#xA;    for _ in range(n - 1):&#xA;        job_choices = arr[0]&#xA;        cheapest = job_choices.argmin()&#xA;        total_cost += job_choices[cheapest]&#xA;        arr = np.delete(arr, 0, axis = 0)&#xA;        arr = np.delete(arr, cheapest, axis = 1)&#xA;    return total_cost&#xA;&#xA;def GreedyB(arr):&#xA;    total_cost = 0&#xA;    for _ in range(n - 1):&#xA;        x, y = np.unravel_index(arr.argmin(), arr.shape)&#xA;        total_cost += arr[x][y]&#xA;        arr = np.delete(arr, x, axis = 0)&#xA;        arr = np.delete(arr, y, axis = 1)&#xA;    return total_cost&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I now run the simulation, arbitrarily picking &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; to be &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt;, making the math predict that &lt;span class=&quot;math-container&quot;&gt;$E(A) = E(B) \approx 2.9$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;values_A = []&#xA;values_B = []&#xA;&#xA;n = 10&#xA;iterations = 10000&#xA;&#xA;for _ in range(iterations):&#xA;    costs = np.random.exponential(size = (n, n), scale = 1)&#xA;    outcomeA = GreedyA(costs)&#xA;    outcomeB = GreedyB(costs)&#xA;    values_A.append(outcomeA)&#xA;    values_B.append(outcomeB)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'll plot the results.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nSvU5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nSvU5.png&quot; alt=&quot;Simulating algorithms A and B.&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Both algorithms seem to come out more efficiently than expected, as nearly all simulation resulted in a cost significantly below &lt;span class=&quot;math-container&quot;&gt;$2.9$&lt;/span&gt;. In addition, in line with my doubts, algorithm B seems to perform much better than algorithm A.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question.&lt;/strong&gt; What is going wrong in my analysis?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4779" OwnerDisplayName="Jim" LastEditorUserId="123" LastEditDate="2021-01-15T14:25:57.483" LastActivityDate="2021-01-15T16:21:10.710" Title="Greedy algorithms for assignment problems --- prediction doesn't match simulation" Tags="|optimization|python|algorithms|assignment-problem|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5527" PostTypeId="2" ParentId="5525" CreationDate="2021-01-15T16:21:10.710" Score="2" Body="&lt;p&gt;In your greedy algorithms you are assigning &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; people to jobs by &lt;code&gt;for _ in range(n - 1)&lt;/code&gt;. Thus you are assigning one job too little - even though this choice is trivial it is missing in your objective. When fixing it to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; this should solve your problem.&lt;/p&gt;&#xA;&lt;p&gt;Just because I couldn't resist not mentioning it. There are extremely good polynomial time exact algorithms for the bipartite matching problem you are describing. ;)&lt;/p&gt;&#xA;" OwnerUserId="4477" LastActivityDate="2021-01-15T16:21:10.710" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5528" PostTypeId="1" CreationDate="2021-01-15T19:51:00.347" Score="0" ViewCount="1134" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ewqgw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ewqgw.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;I need Miller-Tucker-Zemlin  subtour elimination formulation for  symmetric traveling salesman problem (STSP) to use to construct a minimum spanning tree. Ie,&#xA;I need Miller-Tucker-Zemlin formulation for an undirected graph.&lt;/p&gt;&#xA;" OwnerUserId="4735" LastEditorUserId="4735" LastEditDate="2021-01-16T03:26:10.550" LastActivityDate="2021-01-16T05:32:35.920" Title="Miller-Tucker-Zemlin subtour elimination constraints to obtain a minimum spanning tree" Tags="|integer-programming|graphs|traveling-salesman|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5529" PostTypeId="2" ParentId="5528" CreationDate="2021-01-15T20:47:44.703" Score="3" Body="&lt;p&gt;Replace each undirected edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in E$&lt;/span&gt; with two directed arcs &lt;span class=&quot;math-container&quot;&gt;$(i,j),(j,i)\in A$&lt;/span&gt; with the same cost &lt;span class=&quot;math-container&quot;&gt;$c_{i,j} = c_{j,i}$&lt;/span&gt;.  For each &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in A$&lt;/span&gt;, let binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; indicate whether that arc appears in the tree.  Let node &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; (arbitrarily) be the root, and omit all arcs into the root. For each node &lt;span class=&quot;math-container&quot;&gt;$i\in N$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$u_i\in [0,n-1]$&lt;/span&gt; be the MTZ variable.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{(i,j) \in A} c_{i,j} x_{i,j}$$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j x_{1,j} &amp;amp;\ge 1 \tag1\\&#xA;\sum_i x_{i,j} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for $j\in N \setminus \{1\}$} \tag2\\&#xA;u_i + 1 - u_j &amp;amp;\le n(1-x_{i,j}) &amp;amp;&amp;amp;\text{for $(i,j)\in A$ with $j \not= 1$} \tag3&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; forces at least one arc to leave the root node.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; forces exactly one arc to enter each non-root node.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; eliminates subtours by enforcing the logical implication &lt;span class=&quot;math-container&quot;&gt;$x_{i,j} = 1 \implies u_i + 1 \le u_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For your sample data, an optimal solution is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{1,6}=x_{3,2}=x_{5,3}=x_{5,4}=x_{6,5}=x_{6,7}=x_{7,10}=x_{8,9}=x_{10,8}=1,$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$u_{1}=0, u_{2}=9, u_{3}=8, u_{4}=9, u_{5}=7, u_{6}=1, u_{7}=6, u_{8}=8, u_{9}=9, u_{10}=7,$$&lt;/span&gt; with all other &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=0$&lt;/span&gt;, yielding objective value &lt;span class=&quot;math-container&quot;&gt;$38$&lt;/span&gt;.&#xA;(The optimal &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; solution turns out to be unique, but there are multiple possibilities for optimal &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-01-16T05:32:35.920" LastActivityDate="2021-01-16T05:32:35.920" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5530" PostTypeId="1" AcceptedAnswerId="5531" CreationDate="2021-01-15T22:28:06.273" Score="1" ViewCount="79" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; be two binary variables.&lt;/p&gt;&#xA;&lt;p&gt;How can I express  &lt;span class=&quot;math-container&quot;&gt;$i \neq  j$&lt;/span&gt; as a linear constraint?&lt;/p&gt;&#xA;" OwnerUserId="4735" LastActivityDate="2021-01-16T00:07:51.907" Title="$i \neq j$ as a linear constraint where variables are binary" Tags="|linear-programming|binary-variable|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5531" PostTypeId="2" ParentId="5530" CreationDate="2021-01-15T22:38:30.947" Score="7" Body="&lt;p&gt;@user3680510 gave the correct answer in a comment.  Here's a way to derive it via conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;i \not= j \\&#xA;(i \implies \lnot j) \land (\lnot i \implies j) \\&#xA;(\lnot i \lor \lnot j) \land (i \lor j) \\&#xA;(1 - i + 1 - j \ge 1) \land (i + j \ge 1) \\&#xA;(i + j \le 1) \land (i + j \ge 1) \\&#xA;i + j = 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;To prevent both to be 1 at the same time:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\lnot(i \land j) \\&#xA;\lnot i \lor \lnot j \\&#xA;1 - i + 1 - j \ge 1 \\&#xA;i + j \le 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-01-15T22:38:30.947" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5537" PostTypeId="1" CreationDate="2021-01-16T22:37:25.023" Score="6" ViewCount="130" Body="&lt;p&gt;For a given optimization problem there are often many known math programming formulations.&#xA;For example for the TSP here is a survey &lt;a href=&quot;https://link.springer.com/chapter/10.1007/3-540-36626-1_5&quot; rel=&quot;noreferrer&quot;&gt;https://link.springer.com/chapter/10.1007/3-540-36626-1_5&lt;/a&gt;&#xA;of many different formulations, that all describe the same problem, sometimes in lifted spaces.&lt;/p&gt;&#xA;&lt;p&gt;Often there is an &amp;quot;intuitive way&amp;quot; of modeling a problem. For example for the knapsack problem the single constraint formulation is the first things that comes to my mind. But there are alternative formulations in extended spaces, which do not come to my mind straightforward.&lt;/p&gt;&#xA;&lt;p&gt;Are there strategies/rules/systematic approaches to derive &amp;quot;alternative formulation&amp;quot;?&#xA;Is there literature on this?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2024-04-04T05:24:08.110" Title="Are there strategies/rules/systematic approaches to derive alternative formulations for an optimization problem?" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5538" PostTypeId="1" AcceptedAnswerId="5544" CreationDate="2021-01-17T00:26:56.050" Score="4" ViewCount="680" Body="&lt;p&gt;I have an LP that has exponentially many constraints, and just linearly many variables. The dual of the problem, therefore, has exponentially many variables, while just linearly many constraints. My question is, in general, is it a more usual approach to solve the dual problem with column-generation? If yes, can you please help me with a good reference of column-generation for LP (not integer or nonconvex optimization, please).&lt;/p&gt;&#xA;&lt;p&gt;Moreover, I implemented a cutting-plane approach to the primal problem. Namely, in order to avoid exponentially many constraints, I found a way of solving the problem with one constraint, then 'finding' the most violated constraint in linear time, adding this constraint, re-optimizing the problem, and iterating the whole procedure until the most violated constraint is still feasible. Of course there is no guarantee of termination quickly, but my initial experiments show this is working well! Hence, I don't know whether or not the dual column-generation approach will be better than this approach. However, my second question is, is there any known primal-dual method, where I can use my primal cutting-plane approach and also use the dual column-generation approach simultaneously to beat both methods?&lt;/p&gt;&#xA;&lt;p&gt;So the questions can be summarized as:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is column-generation on the dual LP problem a usual way to solve LP problems with exponentially many constraints?&lt;/li&gt;&#xA;&lt;li&gt;Is there a good source on column-generation for LP?&lt;/li&gt;&#xA;&lt;li&gt;If we can find the most-violated primal constraint for any primal solution, does this somehow improve the performance of dual column-generation?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="65" LastActivityDate="2021-01-17T20:16:30.120" Title="Column generation for a linear optimization problem" Tags="|linear-programming|column-generation|duality|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5539" PostTypeId="1" CreationDate="2021-01-17T03:08:18.897" Score="2" ViewCount="44" Body="&lt;p&gt;I have 3 teams within a group with each team working on different tasks assigned. I was given data of how each team performed in terms of the number of task completed each month and the average days taken to complete these task (cells O3,O5,O6). From this data, an overall group performance was generated, again based on the total tasks completed by the group and the total days used to arrive at an average days per task to complete (Cells N10).&lt;/p&gt;&#xA;&lt;p&gt;We were given an improvement target to reduce the overall group average days per task by 30% in H1 of 2021 and then a further 30% by H2 based on the performance from last year. So a 30% reduction will result in a new target in cell &amp;quot;N11&amp;quot;. My challenge is each team within the group works on different type of task with different degree of difficulty so i need to translate this new target (Cell N11) into 3 different new average days to complete for each different team.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to use excel solver to help to calculate what will be the new targets of average days to complete task for each team in order to achieve an overall goal for the group?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/dJ2Lc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dJ2Lc.jpg&quot; alt=&quot;Average days to complete task&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4778" LastActivityDate="2021-01-17T03:08:18.897" Title="Finding average days target for teams to achieve an overall group target using excel solver?" Tags="|solver|excel|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5540" PostTypeId="2" ParentId="1304" CreationDate="2021-01-17T06:46:56.350" Score="4" Body="&lt;p&gt;&lt;strong&gt;Mathematical Contest in Modeling (MCM)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Mathematical Contest in Modeling (MCM), an international contest for high school students and college undergraduates. It challenges teams of students to clarify, analyze, and propose solutions to open-ended problems. The contest attracts diverse students and faculty advisors from over 900 institutions around the world.&lt;/p&gt;&#xA;&lt;p&gt;LINK - &lt;a href=&quot;https://www.comap.com/undergraduate/contests/matrix/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;MCM&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="208" LastActivityDate="2021-01-17T06:46:56.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5541" PostTypeId="2" ParentId="1304" CreationDate="2021-01-17T10:58:40.393" Score="4" Body="&lt;p&gt;&lt;strong&gt;Global Trajectory Optimization&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Mission level Trajectory Optimization is also subfield of OR, although it is often only worked on by the aerospace industry. The Global Trajectory Optimization Competition is a competition between aerospace engineers and mathematicians world wide which work to the best solution to &amp;quot;nearly-impossible&amp;quot; problems of interplanetary trajectory design.&lt;/p&gt;&#xA;&lt;p&gt;Since the next years workshop is hosted by the winners of the last years one, the solutions and problems are hosted at different websites. However &lt;a href=&quot;https://sophia.estec.esa.int/gtoc_portal/&quot; rel=&quot;nofollow noreferrer&quot;&gt;the GTOC portal by&#xA;ESA has links to all of those&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-01-17T10:58:40.393" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5542" PostTypeId="1" AcceptedAnswerId="5543" CreationDate="2021-01-17T14:32:12.230" Score="1" ViewCount="146" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/b3l0s.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/b3l0s.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Two questions:&lt;/p&gt;&#xA;&lt;p&gt;Q1- Why do we need to add  &amp;quot;bidirectional&amp;quot; arcs (instead of single directional arcs)&#xA;between the new node n + 1 and with every node in the original network?&lt;/p&gt;&#xA;&lt;p&gt;Q2- Why is the shortest H-path problem on an n-node&#xA;network G is equivalent to an (n + 1)-node TSP on network G'?&lt;/p&gt;&#xA;" OwnerUserId="4735" LastEditorUserId="4735" LastEditDate="2021-01-17T14:39:49.603" LastActivityDate="2021-01-17T15:19:38.970" Title="Equivalence of Shortest Hamiltonian Paths to Traveling Salesman Problem" Tags="|traveling-salesman|hamiltonian-path|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5543" PostTypeId="2" ParentId="5542" CreationDate="2021-01-17T15:19:38.970" Score="2" Body="&lt;p&gt;Q1. You need bidirectional arcs to and from the dummy node &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; because you don't know ahead of time which directions are needed to complete the tour.  Exactly one arc will enter the dummy, and exactly one arc will leave the dummy.&lt;/p&gt;&#xA;&lt;p&gt;Q2. The two problems are equivalent because the H-paths in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; and TSP tours in &lt;span class=&quot;math-container&quot;&gt;$G'$&lt;/span&gt; are in one-to-one-correspondence, with the same objective values.  To go from H-path (with start &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and end &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;) to tour, insert arcs &lt;span class=&quot;math-container&quot;&gt;$(t,n+1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(n+1,s)$&lt;/span&gt;.  To go from tour to H-path, remove the two arcs incident to &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-01-17T15:19:38.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5544" PostTypeId="2" ParentId="5538" CreationDate="2021-01-17T17:50:11.880" Score="14" Body="&lt;p&gt;TL;DR: column generation on the dual problem is 100% equivalent to cutting plane on the primal problem.&lt;/p&gt;&#xA;&lt;h2&gt;Equivalence between primal and dual form&lt;/h2&gt;&#xA;&lt;p&gt;Consider the (primal) LP problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    (P) \ \ \ \min_{x \in \mathbb{R}^{n}} \ \ \ &amp;amp; c^{T}x\\&#xA;    \text{s.t.} \ \ \ &#xA;    &amp;amp; \sum_{j=1}^{n} a_{i, j} x_{j} \geq b_{i}, &amp;amp; i = 1, ..., M,&#xA;\end{align}&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; very large (thereby motivating a cutting-plane approach).&#xA;The corresponding dual problem is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    (D) \ \ \ \max_{y \in \mathbb{R}^{M}} \ \ \ &amp;amp; b^{T}y\\&#xA;    \text{s.t.} \ \ \ &#xA;    &amp;amp; \sum_{i=1}^{M} a_{i, j} y_{i} = c_{j}, &amp;amp; j = 1, ..., n,\\&#xA;    &amp;amp; y \geq 0.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is straightforward to see that adding the constraint &lt;span class=&quot;math-container&quot;&gt;$a_{i, .}^{T} x \geq b_{i}$&lt;/span&gt; in the primal is equivalent to adding the corresponding variable &lt;span class=&quot;math-container&quot;&gt;$y_{i}$&lt;/span&gt; (and associated column) in the dual.&#xA;Thus, any cutting plane oracle for the primal is a pricing oracle for the dual, i.e., whether you look for violated cuts in the primal, or positive reduced cost variables in dual, the procedure is the same.&lt;/p&gt;&#xA;&lt;p&gt;(to view this, start from the complementarity slackness condition and show that the reduced cost of variable &lt;span class=&quot;math-container&quot;&gt;$y_{i}$&lt;/span&gt; is the slack of constraint &lt;span class=&quot;math-container&quot;&gt;$a_{i}^{T}x \geq b_{i}$&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Consequently, there is no theoretical argument for using one form over the other: the differences are purely computational.&lt;/p&gt;&#xA;&lt;h2&gt;Computational &amp;amp; implementation differences&lt;/h2&gt;&#xA;&lt;p&gt;Should one use the primal or dual form? The only universally valid answer can be: &amp;quot;it depends&amp;quot;.&lt;/p&gt;&#xA;&lt;h3&gt;Primal vs dual simplex&lt;/h3&gt;&#xA;&lt;p&gt;In a cutting plane-based approach, you iteratively add constraint to your LP formulation.&#xA;This is best done with a dual simplex algorithm (just like in branch-and-cut).&lt;/p&gt;&#xA;&lt;p&gt;It happens that (i) dual simplex &lt;em&gt;tends&lt;/em&gt; to be more efficient than primal simplex, and that (ii) most LP solvers provide a nice API for doing this constraint generation (via so-called &amp;quot;lazy constraints&amp;quot;).&lt;/p&gt;&#xA;&lt;p&gt;In a column-generation approach, you iteratively add variables to your LP formulation; this is best done using the primal simplex.&#xA;Furthermore, column generation requires dual information (recall that we're solving &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;, so we're talking about dual solutions for &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;): if you're using simplex that's OK, but if you have something more exotic this information may not always be available.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, most LP solvers do not have any column-generation API. This means you must manually solve the current LP, get the current solution, call your pricing oracle, add new variables if any, and re-solve. This means more work (and more opportunities for bugs).&lt;/p&gt;&#xA;&lt;p&gt;Overall: if you can try both, great. If not, I'd recommend sticking with a primal cutting plane-based approach.&lt;/p&gt;&#xA;&lt;h3&gt;Primal-dual column generation&lt;/h3&gt;&#xA;&lt;p&gt;One way to implicitly use both primal and dual forms is the so-called &lt;a href=&quot;https://link.springer.com/article/10.1007/s12532-015-0090-6&quot; rel=&quot;noreferrer&quot;&gt;primal-dual column generation method&lt;/a&gt; (this paper also provides some background on column-generation in the LP case).&#xA;It has been found to outperform simplex-based implementations on some large-scale problems.&#xA;However, software tools for doing so are very scarce: &lt;a href=&quot;https://www.maths.ed.ac.uk/%7Egondzio/software/pdcgm.html&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; is the only one I know of.&#xA;It's not too hard to implement yourself, but it requires some familiarity with interior-point algorithms.&lt;/p&gt;&#xA;&lt;p&gt;For completeness, a closely related method is the &lt;a href=&quot;https://link.springer.com/article/10.1007/BF00939559&quot; rel=&quot;noreferrer&quot;&gt;Analytic Center Cutting-Plane Method&lt;/a&gt; (ACCPM), which is one of the most effective approach for, e.g., multi-commodity network flow problems.&lt;/p&gt;&#xA;&lt;p&gt;One reason why the primal-dual column generation is so effective is because it implicitly provides a &lt;em&gt;stabilization effect&lt;/em&gt;, which I discuss next.&lt;/p&gt;&#xA;&lt;h3&gt;Acceleration &amp;amp; stabilization techniques&lt;/h3&gt;&#xA;&lt;p&gt;So-called &lt;em&gt;stabilization techniques&lt;/em&gt; help speedup column-generation (or, equivalently, cutting-plane) algorithms.&#xA;From a primal (cutting-plane) perspective, the idea is that the point to separate should not move &amp;quot;too much&amp;quot; between successive iterations.&#xA;Most of the time, there is little theoretical justification (like a proof of faster convergence) for them, but they generally work well.&lt;/p&gt;&#xA;&lt;p&gt;For background:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First and last chapters of the &lt;a href=&quot;https://link.springer.com/book/10.1007/b135457&quot; rel=&quot;noreferrer&quot;&gt;Column Generation book&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0166218X08002916?via%3Dihub&quot; rel=&quot;noreferrer&quot;&gt;On the choice of explicit stabilizing terms in column generation&lt;/a&gt; (&lt;a href=&quot;https://pages.di.unipi.it/frangio/papers/G-2007-109.pdf&quot; rel=&quot;noreferrer&quot;&gt;preprint here&lt;/a&gt;) gives a nice overview of various techniques, together with some computational experiments.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="3598" LastEditDate="2021-01-17T20:16:30.120" LastActivityDate="2021-01-17T20:16:30.120" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5545" PostTypeId="1" CreationDate="2021-01-15T23:16:19.567" Score="5" ViewCount="222" Body="&lt;p&gt;In an exam, I studied Theoretical approaches to converting constrained minimum problems into unconstrained minimum problems. Specifically:&lt;/p&gt;&#xA;&lt;p&gt;KKT conditions&lt;/p&gt;&#xA;&lt;p&gt;Projection Gradient Descent&lt;/p&gt;&#xA;&lt;p&gt;Penalty and Barrier Methods&lt;/p&gt;&#xA;&lt;p&gt;But how are nonlinear constrained problems solved numerically with KKT conditions? I can't find any library in Python that uses them.&lt;/p&gt;&#xA;&lt;p&gt;Same for Projection Gradient Descent and Penalization and Barrier methods, I can't find any library in Python.&lt;/p&gt;&#xA;&lt;p&gt;Are these just theoretical methods, or are they also used in practice? What are the algorithms and library in Python to solve nonlinear programming problems in practice and also in business?&lt;/p&gt;&#xA;" OwnerDisplayName="Francesco Ladogana" LastEditorUserId="500" LastEditDate="2021-01-18T15:34:06.977" LastActivityDate="2021-01-18T15:34:06.977" Title="Solve nonlinear programming problems practically" Tags="|optimization|python|nonlinear-programming|constrained-optimization|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5546" PostTypeId="2" ParentId="5545" CreationDate="2021-01-17T22:38:02.723" Score="4" Body="&lt;p&gt;A common and free NLP solver is IPOPT. IPOPT implements an interior-point line-search filter method, a variation of the interior-point method, these interior point method uses the barrier functions you are aware of. Interior point methods are also useful for large linear systems, as the number of interior steps doesn't depend on the number of constraints. IPOPT is callable from Python.&lt;/p&gt;&#xA;&lt;p&gt;As for penalty methods there is a solver called WORHP which includes one. It also has a quiet ugly Python API and could use a wrapper in a modeling language. I have started to make it accessible from JuMP but I haven't completed that.&lt;/p&gt;&#xA;&lt;p&gt;KKT conditions are often employed to verify the goodness of a solution. There are also solvers that work using this augmented Lagrangian algorithm such as Lancelot. I've never used Lancelot so I can't comment on it's use but it is an old solver.&lt;/p&gt;&#xA;&lt;p&gt;I am not aware what Projection Gradient Descent is so I can't comment on that.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="166" LastEditDate="2021-01-18T15:27:01.090" LastActivityDate="2021-01-18T15:27:01.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5547" PostTypeId="2" ParentId="5545" CreationDate="2021-01-17T22:52:24.673" Score="3" Body="&lt;p&gt;A commonly used alternative to Interior Point methods is Sequential Quadratic Programming (SQP) &lt;a href=&quot;https://www.math.uh.edu/%7Erohop/fall_06/Chapter4.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.math.uh.edu/~rohop/fall_06/Chapter4.pdf&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;SQP essentially amounts to iteratively numerically solving the KKT conditions, while &amp;quot;rolling downhill&amp;quot; (for minimization).&lt;/p&gt;&#xA;&lt;p&gt;There are several commercial, as well as free, nonlinear programming solvers of varying quality available under Python which either are exclusively based on SQP, or have SQP as an algorithm option.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2021-01-17T22:52:24.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5548" PostTypeId="1" AcceptedAnswerId="5551" CreationDate="2021-01-18T01:03:00.920" Score="8" ViewCount="318" Body="&lt;p&gt;There are two non-negative integer variables &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, where only one of them can take a positive value. To impose this relation, I write:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;q &amp;amp;\leq M(1 - y) \tag1 \\&#xA;p &amp;amp;\leq M(y) \tag2&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is binary and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a large number.&lt;/p&gt;&#xA;&lt;p&gt;Is there a better way to model this relation, possibly without binary and/or big-M?&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="500" LastEditDate="2021-01-18T01:55:04.287" LastActivityDate="2021-01-18T02:37:39.490" Title="Formulating two non-negative variables without binary and/or big-M" Tags="|mixed-integer-programming|modeling|binary-variable|big-m|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5549" PostTypeId="1" AcceptedAnswerId="5550" CreationDate="2021-01-18T01:05:55.020" Score="1" ViewCount="119" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7a67a.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7a67a.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Q- Can someone explain  the equivalence in detail please?&lt;/p&gt;&#xA;" OwnerUserId="4735" LastActivityDate="2021-01-18T01:49:10.483" Title="Equivalence of Shortest Hamiltonian Paths with a Starting Node to Traveling Salesman Problem" Tags="|traveling-salesman|hamiltonian-path|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5550" PostTypeId="2" ParentId="5549" CreationDate="2021-01-18T01:49:10.483" Score="2" Body="&lt;p&gt;The correspondence is almost the same as your &lt;a href=&quot;https://or.stackexchange.com/questions/5542/equivalence-of-shortest-hamiltonian-paths-to-traveling-salesman-problem&quot;&gt;other question&lt;/a&gt;.  Here, the starting node is specified, so you don't need a dummy node or dummy arcs out of the starting node.  To go from H-path (with start &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and end &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;) to tour, insert arc &lt;span class=&quot;math-container&quot;&gt;$(t,1)$&lt;/span&gt;. To go from tour to H-path, remove the arc that enters &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-01-18T01:49:10.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5551" PostTypeId="2" ParentId="5548" CreationDate="2021-01-18T01:54:03.890" Score="11" Body="&lt;p&gt;The big-M values need not be the same.  You should choose &lt;span class=&quot;math-container&quot;&gt;$M_1$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; to be a small upper bound on &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_2$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; to be a small upper bound on &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An alternative formulation is &lt;span class=&quot;math-container&quot;&gt;$p q = 0$&lt;/span&gt;, but that is nonlinear.&lt;/p&gt;&#xA;&lt;p&gt;If your solver supports indicator constraints, you can write the desired implications directly, without specifying big-M:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y = 1 &amp;amp;\implies q = 0 \\&#xA;y = 0 &amp;amp;\implies p = 0&#xA;\end{align}&lt;/span&gt;&#xA;But the solver might just introduce the big-M constraints on your behalf.&lt;/p&gt;&#xA;&lt;p&gt;If your solver supports &lt;a href=&quot;https://en.wikipedia.org/wiki/Special_ordered_set#Types_of_SOS&quot; rel=&quot;noreferrer&quot;&gt;SOS1 constraints&lt;/a&gt;, you can use those, but again these might be automatically converted to big-M constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="491" LastEditDate="2021-01-18T02:37:39.490" LastActivityDate="2021-01-18T02:37:39.490" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5552" PostTypeId="1" CreationDate="2021-01-18T07:58:46.630" Score="3" ViewCount="1016" Body="&lt;p&gt;I am trying to solve a nonlinear problem with only a set of continuous variables (where the nonlinearity stems from negative inconsistent - across differently indexed variables - large powers), e.g., one variable has a power -0.2 and another -3.5. I used Ipopt through Pyomo and received the below output. The problem was solved by Knitro through AMPL years ago, and the objective function values (from Ipopt and Knitro) are not any close.&lt;/p&gt;&#xA;&lt;p&gt;1.What do you think is happening here? Why does it converge to an infeasible point and report it as a result?&lt;/p&gt;&#xA;&lt;p&gt;2.Is there any alternative solver I could try within Pyomo?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Ipopt 3.11.1: &#xA;&#xA;****************************************************************************** This program contains Ipopt, a library for large-scale nonlinear optimization.  Ipopt is released as open source code under the Eclipse Public License (EPL).&#xA;         For more information visit http://projects.coin-or.org/Ipopt&#xA;******************************************************************************&#xA;&#xA;NOTE: You are using Ipopt by default with the MUMPS linear solver.&#xA;      Other linear solvers might be more efficient (see Ipopt documentation).&#xA;&#xA;&#xA;This is Ipopt version 3.11.1, running with linear solver mumps.&#xA;&#xA;Number of nonzeros in equality constraint Jacobian...:        0 Number of nonzeros in inequality constraint Jacobian.:  2858853 Number of nonzeros in Lagrangian Hessian.............:    31110&#xA;&#xA;Total number of variables............................:     9677&#xA;                     variables with only lower bounds:     9677&#xA;                variables with lower and upper bounds:        0&#xA;                     variables with only upper bounds:        0 Total number of equality constraints.................:        0 Total number of inequality constraints...............:  1559235&#xA;        inequality constraints with only lower bounds:   523080    inequality constraints with lower and upper bounds:        0&#xA;        inequality constraints with only upper bounds:  1036155&#xA;&#xA;iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls    0 -1.7292478e+006 1.51e+005 9.89e+000  -1.0 0.00e+000 &#xA;-  0.00e+000 0.00e+000   0    1 -1.7295299e+006 1.50e+005 1.12e+001  -1.0 6.06e+002   0.0 9.47e-004 3.57e-003f  1    2 -1.7314126e+006 1.49e+005 1.14e+001  -1.0 4.52e+004    -  1.33e-003 9.59e-003f  1    3 -1.7314994e+006 1.49e+005 1.17e+001  -1.0 5.97e+002  -0.5 6.36e-003 1.37e-003f  1    4 -1.7323450e+006 1.47e+005 1.68e+001  -1.0 9.65e+002  -1.0 4.05e-003 9.91e-003f  1    5 -1.7324589e+006 1.47e+005 1.66e+001  -1.0 2.38e+003  -1.4 6.32e-003 1.51e-003f  1    6 -1.7352921e+006 1.45e+005 1.63e+001  -1.0 4.27e+004    -  5.78e-003 1.45e-002f  1    7 -1.7358416e+006 1.44e+005 1.63e+001  -1.0 1.19e+004    -  6.52e-003 5.48e-003f  1    8 -1.7372923e+006 1.42e+005 1.60e+001  -1.0 6.27e+003    -  6.59e-003 1.45e-002f  1    9 -1.7378360e+006 1.41e+005 1.59e+001  -1.0 1.85e+003    -  3.87e-003 8.04e-003f  1 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls   10&#xA;-1.7382291e+006 1.40e+005 1.58e+001  -1.0 4.44e+003    -  2.21e-003 6.91e-003f  1   11 -1.7387577e+006 1.38e+005 1.56e+001  -1.0 5.04e+003    -  1.02e-002 1.01e-002f  1   12 -1.7389229e+006 1.38e+005 1.55e+001  -1.0 1.65e+003    -  5.40e-003 5.82e-003f  1   13 -1.7393875e+006 1.35e+005 1.53e+001  -1.0 1.51e+003    -  6.59e-003 1.50e-002f  1   14 -1.7393109e+006 1.34e+005 1.64e+001  -1.0 1.26e+003    -  1.41e-002 8.77e-003f  1   15 -1.7391161e+006 1.33e+005 1.68e+001  -1.0 8.47e+002    -  9.61e-003 6.09e-003f  1   16 -1.7387181e+006 1.32e+005 1.67e+001  -1.0 6.72e+002    -  9.61e-003 9.63e-003f  1   17 -1.7382631e+006 1.31e+005 1.67e+001  -1.0 4.98e+002    -  9.57e-003 6.71e-003f  1   18 -1.7381868e+006 1.31e+005 3.53e+001  -1.0 4.09e+002    -  3.06e-003 8.33e-004f  1   19 -1.7371899e+006 1.30e+005 1.90e+001  -1.0 3.96e+002    -  1.72e-004 1.27e-002f  1 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls   20 -1.7362542e+006 1.29e+005&#xA;1.63e+001  -1.0 3.20e+002    -  8.66e-003 7.16e-003h  1   21 -1.7348790e+006 1.27e+005 3.86e+001  -1.0 2.86e+002    -  7.04e-004 8.64e-003h  1   22 -1.7336666e+006 1.27e+005 1.87e+001  -1.0 2.91e+002    -  1.38e-002 5.78e-003h  1   23 -1.7317366e+006 1.26e+005 2.15e+001  -1.0 3.49e+002    -  8.14e-003 8.01e-003h  1   24 -1.7295260e+006 1.25e+005 2.49e+001  -1.0 3.51e+002    -  7.46e-003 7.30e-003h  1   25 -1.7276058e+006 1.24e+005 2.73e+001  -1.0 3.98e+002    -  7.61e-003 5.05e-003h  1   26 -1.7249847e+006 1.23e+005 3.19e+001  -1.0 4.44e+002    -  7.48e-003 5.94e-003h  1   27 -1.7222735e+006 1.23e+005 5.99e+001  -1.0 4.43e+002    -  7.50e-003 4.96e-003h  1   28 -1.7190370e+006 1.22e+005 6.60e+001  -1.0 4.97e+002    -  5.17e-003 4.82e-003h  1   29 -1.7166933e+006 1.22e+005 1.31e+002  -1.0 5.99e+002    -  4.85e-003 2.68e-003h  1 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls   30 -1.7156839e+006 1.22e+005 2.21e+002 &#xA;-1.0 6.57e+002    -  2.96e-003 9.50e-004h  1   31 -1.7136458e+006 1.22e+005 1.39e+002  -1.0 7.14e+002    -  2.78e-004 1.79e-003h  1   32 -1.7111915e+006 1.21e+005 1.68e+002  -1.0 8.48e+002    -  2.23e-003 1.85e-003h  1   33 -1.7094299e+006 1.21e+005 8.00e+001  -1.0 1.07e+003    -  3.63e-004 1.07e-003h  1   34 -1.7081456e+006 1.21e+005 5.96e+002  -1.0 1.28e+003    -  3.52e-003 6.71e-004h  1   35 -1.7045886e+006 1.21e+005 5.30e+002  -1.0 1.49e+003    -  1.41e-003 1.66e-003h  1   36 -1.7029935e+006 1.21e+005 1.14e+003  -1.0 2.20e+003    -  1.42e-003 5.05e-004h  1   37 -1.7015932e+006 1.21e+005 1.64e+003  -1.0 2.62e+003    -  7.80e-004 3.59e-004h  1   38 -1.6998463e+006 1.21e+005 2.10e+003  -1.0 3.33e+003    -  5.86e-004 3.67e-004h  1   39 -1.6985938e+006 1.21e+005 4.33e+003  -1.0 5.07e+003    -  6.34e-004 1.96e-004h  1 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls   40 -1.6970693e+006 1.21e+005 4.61e+003  -1.0 6.92e+003    - &#xA;2.03e-004 1.80e-004h  1   41 -1.6967167e+006 1.21e+005 3.38e+003  -1.0 1.08e+004    -  1.86e-006 2.98e-005h  1   42 -1.6964594e+006 1.21e+005 3.43e+003  -1.0 1.24e+004    -  2.16e-005 2.09e-005h  1   43 -1.6960265e+006 1.21e+005 1.19e+004  -1.0 1.42e+004    -  1.22e-004 3.32e-005h  1   44 -1.6953687e+006 1.21e+005 1.79e+004  -1.0 2.12e+004    -  6.15e-005 3.78e-005h  1   45 -1.6951933e+006 1.21e+005 6.56e+004  -1.0 3.49e+004    -  5.04e-005 1.18e-005h  1   46r-1.6951933e+006 1.21e+005 1.00e+003   5.1 0.00e+000    -  0.00e+000 3.94e-007R  5   47r-1.7007303e+006 1.21e+005 1.04e+003   5.1 6.46e+007    -  3.82e-006&#xA;4.08e-005f  1   48r-1.7031261e+006 1.20e+005 1.03e+003   3.0 1.79e+006    -  2.63e-004 4.95e-004f  1   49r-1.7041104e+006 1.19e+005 1.04e+003   3.0 4.53e+006    -  9.16e-004 2.06e-004f  1 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls   50r-1.7095152e+006 1.17e+005 1.04e+003   3.0 3.87e+006    -  2.00e-003&#xA;8.75e-004f  1   51r-1.8866957e+006 3.02e+005 1.04e+003   3.0 1.17e+007    -  4.26e-004 4.82e-003f  1   52 -1.8867312e+006 3.02e+005 2.03e+002  -1.0 3.59e+003   0.8 3.47e-005 3.57e-005f  1   53 -1.8867829e+006 3.02e+005 2.03e+002  -1.0 3.18e+003   0.3 3.54e-005 5.02e-005f  1   54 -1.8870483e+006 3.02e+005 2.03e+002  -1.0 2.36e+003  -0.2 6.12e-005 2.51e-004f  1   55 -1.8871681e+006 3.02e+005 2.03e+002  -1.0 2.18e+003   0.3 7.68e-005 1.13e-004f  1   56 -1.8876126e+006 3.02e+005 2.02e+002  -1.0 1.78e+003  -0.2 9.65e-005 4.12e-004f  1   57 -1.8880735e+006 3.02e+005 2.02e+002  -1.0 1.70e+003  -0.7 2.72e-004 4.09e-004f  1   58 -1.8898043e+006 3.02e+005 2.02e+002  -1.0 1.55e+003  -1.2 3.55e-004 1.36e-003f  1   59 -1.8908320e+006 3.02e+005 2.02e+002  -1.0 2.25e+004    -  5.52e-005 9.04e-004h  1 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls   60 -1.8926835e+006 3.02e+005&#xA;2.45e+002  -1.0 1.42e+004    -  5.79e-004 1.16e-003f  1   61 -1.8937447e+006 3.01e+005 2.42e+002  -1.0 1.56e+003  -0.7 4.39e-004 6.61e-004f  1   62 -1.8950149e+006 3.01e+005 2.35e+002  -1.0 2.08e+003  -1.2 3.12e-004 7.35e-004f  1   63 -1.8965425e+006 3.01e+005 2.37e+002  -1.0 2.10e+003    -  4.57e-004 8.70e-004f  1   64 -1.8969693e+006 3.01e+005 2.37e+002  -1.0 2.11e+003    -  4.30e-004 2.38e-004f  1   65 -1.8984479e+006 3.01e+005 2.36e+002  -1.0 2.20e+003    -  5.09e-004 8.38e-004f  1   66 -1.8995440e+006 3.01e+005 2.36e+002  -1.0 2.45e+003    -  5.10e-004 6.42e-004f  1   67 -1.9001378e+006 3.01e+005 2.36e+002  -1.0 2.17e+003    -  5.15e-004 3.66e-004f  1   68 -1.9009338e+006 3.00e+005 2.36e+002  -1.0 2.08e+003    -  4.37e-004 5.19e-004f  1   69 -1.9021128e+006 3.00e+005 2.35e+002  -1.0 1.99e+003    -  5.58e-004 7.98e-004f  1 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls   70 -1.9026180e+006 3.00e+005 2.35e+002 &#xA;-1.0 2.06e+003    -  1.47e-004 3.51e-004f  1   71 -1.9027830e+006 3.00e+005 2.35e+002  -1.0 2.11e+003    -  1.26e-005 1.14e-004f  1   72 -1.9034292e+006 3.00e+005 2.35e+002  -1.0 2.13e+003    -  7.58e-004 4.36e-004f  1   73 -1.9042225e+006 3.00e+005 2.35e+002  -1.0 2.34e+003    -  5.04e-004 5.31e-004f  1   74 -1.9046505e+006 3.00e+005 2.35e+002  -1.0 2.66e+003    -  3.77e-004 2.73e-004f  1   75 -1.9050938e+006 3.00e+005 2.35e+002  -1.0 2.91e+003    -  2.50e-005 2.72e-004f  1   76 -1.9056574e+006 3.00e+005 2.35e+002  -1.0 3.13e+003    -  5.85e-004 3.24e-004f  1   77 -1.9061540e+006 3.00e+005 2.35e+002  -1.0 4.01e+003    -  3.37e-004 2.66e-004f  1   78 -1.9067267e+006 3.00e+005 2.35e+002  -1.0 4.58e+003    -  2.77e-004 2.76e-004f  1   79 -1.9070506e+006 3.00e+005 2.35e+002  -1.0 5.35e+003    -  1.82e-004 1.33e-004f  1 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls   80 -1.9073483e+006 3.00e+005 2.35e+002  -1.0 6.37e+003    - &#xA;2.16e-004 1.08e-004f  1   81 -1.9077093e+006 3.00e+005 2.35e+002  -1.0 7.23e+003    -  1.26e-004 1.14e-004f  1   82 -1.9080169e+006 3.00e+005 2.35e+002  -1.0 9.03e+003    -  1.05e-004 7.96e-005f  1   83 -1.9082633e+006 3.00e+005 2.35e+002  -1.0 1.14e+004    -  2.35e-005 5.10e-005f  1   84 -1.9083384e+006 3.00e+005 2.35e+002  -1.0 1.46e+004    -  2.26e-006 1.24e-005f  1   85 -1.9084228e+006 3.00e+005 8.72e+002  -1.0 1.60e+004    -  7.15e-005 1.27e-005f  1   86 -1.9088284e+006 3.00e+005 2.36e+002  -1.0 1.77e+004    -  2.43e-005 5.40e-005f  1   87 -1.9088744e+006 3.00e+005 2.43e+003  -1.0 4.03e+004    -  1.46e-005 2.72e-006f  1   88 -1.9090741e+006 3.00e+005 1.66e+003  -1.0 4.76e+004    -  7.37e-006 9.93e-006f  1   89r-1.9090741e+006 3.00e+005 1.00e+003   5.0 0.00e+000    -  0.00e+000 1.98e-007R  2 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls   90r-1.9117648e+006 3.04e+005 1.00e+003   5.0 7.29e+007    -  6.41e-006&#xA;1.12e-005f  1   91r-2.1032212e+006 6.41e+005 1.02e+003   2.9 1.98e+007    -  6.21e-004 4.00e-003f  1   92r-2.3809515e+006 1.38e+006 1.03e+003   2.9 4.19e+007    -  1.14e-003 3.51e-003f  1   93r-2.4939888e+006 1.67e+006 1.04e+003   2.9 1.61e+007    -  2.46e-003 4.69e-003f  1   94r-2.7761309e+006 2.57e+006 8.41e+003   2.9 8.00e+006    -  3.18e-003&#xA;2.35e-002f  1   95r-2.6728405e+006 2.19e+006 5.71e+004   2.9 2.42e+006    -  2.52e-002 5.77e-002f  1   96r-2.8038551e+006 2.68e+006 2.84e+007   2.9 7.94e+005    -  9.44e-002 1.82e-001f  1   97r-2.7662202e+006 2.53e+006 2.31e+007   2.9 2.08e+004    -  2.05e-001 2.06e-001f  1   98r-2.7497552e+006 2.46e+006 1.57e+007   2.9 1.29e+005    -  1.63e-001&#xA;4.69e-001f  1   99r-2.7405025e+006 2.42e+006 9.02e+006   2.9 8.10e+004    -  2.03e-001 7.07e-001f  1 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls  100r-2.7220229e+006 2.35e+006&#xA;5.05e+006   2.9 9.17e+002    -  2.28e-001 6.97e-001f  1  101r-2.7000216e+006 2.28e+006 2.93e+006   2.9 2.73e+004    - &#xA;4.42e-001 6.34e-001f  1  102r-2.6688323e+006 2.17e+006 1.41e+006   2.9 3.23e+004    -  1.00e+000 9.04e-001f  1  103r-2.6489554e+006 2.11e+006 6.37e+005   2.9 1.90e+004    -  1.00e+000 1.00e+000f  1  104r-2.6473015e+006 2.10e+006 2.75e+005   2.9 1.33e+003    - &#xA;1.00e+000 1.00e+000h  1  105r-2.6472264e+006 2.10e+006 1.14e+005   2.9 1.34e+002    -  1.00e+000 1.00e+000f  1  106r-2.6471852e+006 2.10e+006 4.25e+004   2.9 6.86e+001    -  1.00e+000 1.00e+000f  1  107r-2.6471586e+006 2.10e+006 1.29e+004   2.9 3.93e+001    - &#xA;1.00e+000 1.00e+000f  1  108r-2.7052367e+006 2.30e+006 3.99e+003   2.2 7.66e+004    -  8.48e-001 7.25e-001f  1  109r-2.7499870e+006 2.45e+006 6.27e+002   2.2 4.91e+004    -  9.74e-001 1.00e+000f  1 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls  110r-2.7507558e+006 2.45e+006 8.13e+000   2.2 3.06e+003    - &#xA;1.00e+000 1.00e+000h  1  111r-2.7763702e+006 2.55e+006 2.63e+002   0.1 3.63e+004    -  8.21e-001 7.50e-001f  1  112r-2.7835442e+006 2.57e+006 1.22e+002   0.1 1.22e+004    -  9.07e-001 6.88e-001f  1  113r-2.7860550e+006 2.58e+006 5.69e+001   0.1 3.94e+003    - &#xA;9.06e-001 7.59e-001f  1  114r-2.7868349e+006 2.59e+006 1.55e+000   0.1 9.51e+002    -  1.00e+000 1.00e+000f  1  115r-2.7870579e+006 2.59e+006 3.90e+001  -1.3 3.30e+002    -  9.51e-001 7.76e-001f  1  116r-2.7871275e+006 2.59e+006 3.70e+000  -1.3 8.42e+001    - &#xA;9.76e-001 1.00e+000f  1  117r-2.7871272e+006 2.59e+006 1.46e-002  -1.3 9.47e-002    -  1.00e+000 1.00e+000h  1  118r-2.7871386e+006 2.59e+006 1.32e+000  -3.1 1.35e+001    -  1.00e+000 9.67e-001f  1  119r-2.7871409e+006 2.59e+006 2.33e-003  -3.1 2.75e+000    - &#xA;1.00e+000 1.00e+000f  1 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls  120r-2.7871411e+006 2.59e+006&#xA;1.96e-002  -4.6 2.55e-001    -  1.00e+000 1.00e+000f  1  121r-2.7871413e+006 2.59e+006 6.10e-005  -4.6 3.04e-001    - &#xA;1.00e+000 1.00e+000h  1  122r-2.7871413e+006 2.59e+006 3.80e-003  -6.9 7.53e-003    -  1.00e+000 1.00e+000f  1  123r-2.7871414e+006 2.59e+006 2.36e-008  -6.9 5.92e-002    -  1.00e+000 1.00e+000h  1 In iteration 123, 1 Slack too small, adjusting variable bound  124r-2.7871414e+006&#xA;2.59e+006 2.70e-004  -9.0 4.02e-005    -  1.00e+000 1.00e+000f  1 In iteration 124, 1 Slack too small, adjusting variable bound&#xA;&#xA;Number of Iterations....: 124&#xA;&#xA;                                   (scaled)                 (unscaled) Objective...............: -2.3436762840071004e+006 &#xA;-2.7871413928982806e+006 Dual infeasibility......:  9.2870257854463659e+002   1.1044295733229690e+003 Constraint violation....:  7.7957580080225132e+005   2.5871668139707851e+006 Complementarity.........:  2.2997082264203370e-004  &#xA;2.7348537992141043e-004 Overall NLP error.......:  7.7957580080225132e+005   2.5871668139707851e+006&#xA;&#xA;&#xA;Number of objective function evaluations             = 133 Number of objective gradient evaluations             = 87 Number of equality constraint evaluations            = 0 Number of inequality constraint evaluations          = 133 Number of equality constraint Jacobian evaluations   = 0 Number of inequality constraint Jacobian evaluations&#xA;= 128 Number of Lagrangian Hessian evaluations             = 125 Total CPU secs in IPOPT (w/o function evaluations)   =   1068.222 Total CPU secs in NLP function evaluations           =   1365.220&#xA;&#xA;EXIT: Converged to a point of local infeasibility. Problem may be infeasible. WARNING: Loading a SolverResults object with a warning status into model=CTA;&#xA;        message from solver=Ipopt 3.11.1\x3a Converged to a locally infeasible&#xA;        point. Problem may be infeasible.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="518" LastEditorUserId="518" LastEditDate="2021-01-18T08:12:37.957" LastActivityDate="2021-01-18T20:12:30.603" Title="Ipopt (probably) fails to solve a nonlinear problem, what is next?" Tags="|nonlinear-programming|pyomo|open-source|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5553" PostTypeId="2" ParentId="5552" CreationDate="2021-01-18T10:11:28.773" Score="2" Body="&lt;p&gt;IPOPT most likely selects a different starting point than KNITRO did, and converges to a locally infeasible point. Not much you can do I'm afraid other than trying different starting points.&lt;/p&gt;&#xA;&lt;p&gt;It should be noted that, depending on the domains and expressions, certain fractional powers can give results in the complex domain (among many nasty mathematical artefacts). This means that, without proper symbolic reformulation of the problem, a local NLP solver can only solve such problems by luck, because it needs to somehow avoid the complex domain points &amp;amp; singularities while trying to locate a solution in the real domain (otherwise you'll see a nice &lt;code&gt;cmath&lt;/code&gt; exception or similar).&lt;/p&gt;&#xA;&lt;p&gt;On the free side, you could alternatively try &lt;a href=&quot;https://github.com/coin-or/filterSD&quot; rel=&quot;nofollow noreferrer&quot;&gt;FilterSD&lt;/a&gt;, or our own &lt;a href=&quot;https://octeract.com/octeract-engine/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Engine&lt;/a&gt; which will symbolically reformulate your problem to eliminate singularities and complex solutions. Because Octeract Engine is a deterministic global optimisation solver it will keep searching for a solution automatically without need for user-provided starting points.&lt;/p&gt;&#xA;&lt;p&gt;Octeract Engine is &lt;a href=&quot;https://octeract.com/get-a-licence/&quot; rel=&quot;nofollow noreferrer&quot;&gt;free for academics&lt;/a&gt;, and in February 2021 it will also be free for commercial use! We are currently setting up the user account system etc. for the free users, so if you are not an academic simply &lt;a href=&quot;https://octeract.com/get-a-licence/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ask for a trial&lt;/a&gt; and we'll send you the free licence automatically when the trial runs out.&lt;/p&gt;&#xA;&lt;p&gt;Since you are using Pyomo, &lt;a href=&quot;https://octeract.com/pyomo-with-the-engine/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; is a step-by-step tutorial on how to use Octeract Engine with Pyomo.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-01-18T20:12:30.603" LastActivityDate="2021-01-18T20:12:30.603" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5554" PostTypeId="2" ParentId="5537" CreationDate="2021-01-18T10:29:19.250" Score="5" Body="&lt;p&gt;About extended reformulation for integer linear programming, you can be interested in &lt;a href=&quot;https://www.lamsade.dauphine.fr/%7Ejfro/JourneesPrecedentes/anciennesJournees/docs/jfro21/jfro6mars09_VanderBeck.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this lecture by Vanderbeck and Wolsey&lt;/a&gt; and &lt;a href=&quot;https://www.math.u-bordeaux.fr/%7Efvanderb/papers/refDecompIPworkingPaper.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;the corresponding research report&lt;/a&gt;. They formalize reformulations, especially what are good reformulations, and describe techniques to build them systematically. They give many examples of reformulations for some well-known discrete optimization problems.&lt;/p&gt;&#xA;&lt;p&gt;There is also some research on reformulations of quadratic binary programs. For example, look at &lt;a href=&quot;https://cedric.cnam.fr/fichiers/art_1579.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;the work of Billionnet, Elloumi, and Lambert&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As well said in the comment, formulating problems mathematically is more than science. Now, formulating and reformulating problems to be solved at best by solvers is an experimental work. Solver designers generally give some modeling guidelines and illustrate them with examples of problems. But sometimes, even the solvers' designers cannot say what formulations will be better solved by an optimization engine. Just because optimization engines are complex systems and, like any complex system, their outputs are not fully predictable.&lt;/p&gt;&#xA;&lt;p&gt;Modeling techniques are generally less emphasized in research and teaching than solving techniques. At Hexaly, we love implementing and improving solving techniques in a very agnostic fashion. But we are also convinced that &amp;quot;modeling is the master and computation the servant&amp;quot; as &lt;a href=&quot;http://www.constraint-programming.com/letters/Papers/v1/hooker.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;John Hooker nicely wrote&lt;/a&gt;. In particular, we are convinced that the classical Boolean modeling approach, traditionally used in integer linear programming, is not the best one to capture the structure of combinatorial problems, which is critical to solving them efficiently in practice. We have introduced innovative modeling features to model discrete problems like routing, scheduling, packing, or clustering problems. For example, for the TSP you cited in your question, ideas are given in previous posts like &lt;a href=&quot;https://or.stackexchange.com/questions/5476/working-with-large-models/5478#5478&quot;&gt;this one&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T05:24:08.110" LastActivityDate="2024-04-04T05:24:08.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5555" PostTypeId="1" AcceptedAnswerId="5556" CreationDate="2021-01-18T10:54:01.720" Score="5" ViewCount="1646" Body="&lt;p&gt;Suppose that we have a standard TSP, except that it is required to visit each city at least&#xA;once instead of exactly once. The challenge is: how to transform this problem to a&#xA;standard TSP?  To that end, one construct a new network with arcs representing the shortest paths&#xA;between each pair of nodes.&lt;/p&gt;&#xA;&lt;p&gt;Now the TSP with multiple city visits is equivalent to a standard TSP defined on the new network.&lt;/p&gt;&#xA;&lt;p&gt;Q: Can somebody explain why TSP with multiple city visits on the original network is equivalent to a standard TSP defined on the new network?&lt;/p&gt;&#xA;" OwnerUserId="4735" LastActivityDate="2022-08-12T21:54:14.447" Title="TSP with Repeated City Visits" Tags="|traveling-salesman|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5556" PostTypeId="2" ParentId="5555" CreationDate="2021-01-18T11:43:31.677" Score="9" Body="&lt;p&gt;If the distance between your nodes follows the triangle inequality (you can never travel faster between two points by adding an intermediary step), then the shortest path visits each node only once.&lt;/p&gt;&#xA;&lt;p&gt;However, if your network has nodes &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$$d(a,b) \geq d(a,c) + d(c,b)$$&lt;/span&gt; any path that goes from &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; will always go through. So you can mark all the edges where this is the case and just use the length of the path of the shortest path between &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. For example,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$d(a,b) := d(a,c) + d(c,b)$$&lt;/span&gt;&#xA;Solve the TSP using these updated weights (which no longer violate the triangle inequality) and in your solution, when you travel over the marked edge &lt;span class=&quot;math-container&quot;&gt;$\vec{ab}$&lt;/span&gt;, add the intermediary nodes along which the path is shortest.&lt;/p&gt;&#xA;&lt;p&gt;In summary, TSP with Repeated City Visits without additional constraints (such as carrying packages) is equivalent TSP and only the slightest bit interesting when you violate the triangle inequality.&lt;/p&gt;&#xA;&lt;p&gt;Here is the algorithm applied to the graph @byteherder suggested. After the preprocessing has run a vanilla DSP solution is as good as the suggested best solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4JViG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4JViG.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2022-08-12T21:54:14.447" LastActivityDate="2022-08-12T21:54:14.447" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5557" PostTypeId="1" CreationDate="2021-01-18T14:18:57.420" Score="12" ViewCount="228" Body="&lt;p&gt;There are many (numeric) optimizers which solve some subset of the set of &lt;em&gt;multi-objective, black-or-grey-or-white box, robust, stochastic, mixed-integer, non-linear, non-smooth, manifold-constrained programming&lt;/em&gt; problems.&lt;/p&gt;&#xA;&lt;p&gt;Some of them are well known. Such as all the solvers that appear in the Mittelmann benchmarks. I don't want to hear about those, I want to hear about obscure, old, bleeding edge, unknown solvers or algorithms that you chose over the more popular well known ones:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What made you choose it over more well known solvers?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Where can I learn more about it?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What is the underlying principle?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What kind of problems can it solve?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Under what license/pricing is it (or an implementation of it) available for hobbyist, academics or professionals?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;From what programming languages can it (or an implementation of it) be called?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;When describing an algorithm please be specific (not just &amp;quot;evolutionary algorithm&amp;quot;) about it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Background&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;If I find any solver/algorithms intriguing I might decide to wrap/implement them for a modeling language. Others might find a solver that fits their use case in the replies or learn something new and interesting.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="123" LastEditDate="2021-01-18T16:45:08.003" LastActivityDate="2021-01-18T16:45:08.003" Title="Unpopular/Obscure solvers/algorithms that you used" Tags="|solver|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5558" PostTypeId="1" CreationDate="2021-01-18T21:05:08.970" Score="2" ViewCount="74" Body="&lt;p&gt;Consider a general nonconvex QP &lt;span class=&quot;math-container&quot;&gt;$x^\top Qx$&lt;/span&gt;. This can be linearized in an extended space by using the variable &lt;span class=&quot;math-container&quot;&gt;$Y=xx^\top$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now a valid inequality &lt;span class=&quot;math-container&quot;&gt;$a^\top x \le b$&lt;/span&gt; can be strengthend by the RLT procedure by multiplying with some &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; to obtain &lt;span class=&quot;math-container&quot;&gt;$a^\top y \le bx_j$&lt;/span&gt;. See for example &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/mip/cuts/38_RLTcuts.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Are there other approaches than RLT in the context of nonconvex qps to strengthen a given inequality?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2021-01-18T22:43:16.493" LastActivityDate="2021-01-18T22:43:16.493" Title="Non RLT-Cutting planes for nonconvex QPs?" Tags="|quadratic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5559" PostTypeId="2" ParentId="5558" CreationDate="2021-01-18T22:29:56.997" Score="2" Body="&lt;p&gt;One such paradigm is &lt;em&gt;intersection cuts&lt;/em&gt;.&#xA;It's a widely used framework in mixed-integer programming, and it naturally extends to non-convex nonlinear settings as well.&lt;/p&gt;&#xA;&lt;p&gt;A (very) recent work on this topic: &lt;a href=&quot;https://opus4.kobv.de/opus4-zib/frontdoor/index/index/docId/7999&quot; rel=&quot;nofollow noreferrer&quot;&gt;On the implementation and strengthening of intersection cuts for QCQPs&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2021-01-18T22:29:56.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5560" PostTypeId="1" CreationDate="2021-01-19T01:45:58.097" Score="1" ViewCount="198" Body="&lt;p&gt;I am looking for a good textbook explaining:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Transformation of Multiple Traveling Salesmen Problem to the Standard Traveling Salesman Problem.&amp;quot;&lt;/p&gt;&#xA;" OwnerUserId="4735" LastEditorUserId="123" LastEditDate="2021-01-19T10:07:22.703" LastActivityDate="2021-01-19T10:07:22.703" Title="Textbook recommendation for multiple traveling salesman problem transformation to standard TSP" Tags="|reference-request|traveling-salesman|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5561" PostTypeId="2" ParentId="5560" CreationDate="2021-01-19T02:04:45.003" Score="5" Body="&lt;p&gt;The transformation is mentioned in Ahuja, Magnanti, and Orlin, &lt;em&gt;Network Flows&lt;/em&gt;, Exercise 16.25(b).&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-01-19T02:17:26.650" LastActivityDate="2021-01-19T02:17:26.650" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5562" PostTypeId="1" CreationDate="2021-01-19T09:37:03.597" Score="2" ViewCount="348" Body="&lt;p&gt;I am fairly new to Pyomo and Gurobi. I'd like to find 20 sets of different solutions that meet the following constraints.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;constraints：&#xA;10&amp;lt;=x1&amp;lt;=20 &#xA;12&amp;lt;=x2&amp;lt;=32 &#xA;5&amp;lt;=x3&amp;lt;=15 &#xA;5&amp;lt;=x4&amp;lt;=52 &#xA;x1+x2+x3+x4=100.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;From &lt;a href=&quot;https://or.stackexchange.com/questions/5518/how-to-generate-multiple-solutions-to-linear-program-in-python&quot;&gt;here&lt;/a&gt;  I learned Gurobi has PoolSolutions, so I decided to have a try.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from gurobipy import GRB&#xA;import numpy as np&#xA;from pyomo.environ import *&#xA;import matplotlib.pyplot as plt&#xA;&#xA;generator={  &#xA;1 :{'down':10,  'up':20,},&#xA;2 :{'down':12,  'up':32,},&#xA;3 :{'down':5,   'up':15,},&#xA;4 :{'down':5,   'up':52,},&#xA;    }&#xA;G = generator.keys()&#xA;&#xA;# create a new model&#xA;m = ConcreteModel()&#xA;&#xA;# create variables&#xA;m.P = Var(G, domain=NonNegativeReals)&#xA;&#xA;# set objective &#xA;m.OBJ = Objective(expr = 0)&#xA;&#xA;# add constraints&#xA;m.c = ConstraintList()&#xA;m.c.add(sum(m.P[g] for g in G)== 100)&#xA;for g in G:   &#xA;     m.c.add(m.P[g] &amp;lt;= generator[g]['up'])&#xA;     m.c.add(m.P[g] &amp;gt;= generator[g]['down'])&#xA;&#xA;# try to get 20 sets of different solutions&#xA;n_of_s = 20&#xA;opt = SolverFactory('gurobi_persistent')&#xA;opt.set_instance(m)&#xA;opt.set_gurobi_param('PoolSolutions', n_of_s)&#xA;opt.set_gurobi_param('PoolSearchMode', 2)&#xA;opt.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But it doesn't work properly. Hope somebody could teach me how to modify this and how to show the results of 20 solutions. Any suggestions are welcomed. THX&lt;/p&gt;&#xA;" OwnerUserId="4788" LastActivityDate="2021-01-19T09:37:03.597" Title="Find multiple solutions in Pyomo with Gurobi" Tags="|gurobi|pyomo|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5563" PostTypeId="1" AcceptedAnswerId="5564" CreationDate="2021-01-19T13:02:47.047" Score="6" ViewCount="909" Body="&lt;p&gt;How do I validate my Gurobi academic license remotely, that is, from a computer that is not on my university network?&lt;/p&gt;&#xA;&lt;p&gt;Official instructions for Gurobi 9.1 are here:  &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/quickstart_mac/academic_validation.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.1/quickstart_mac/academic_validation.html&lt;/a&gt;, but these require a VPN.&lt;/p&gt;&#xA;&lt;p&gt;There are old instructions for using an ssh tunnel on the (retired) google group &lt;a href=&quot;https://groups.google.com/g/gurobi/c/MaEP4cun8o8?pli=1&quot; rel=&quot;noreferrer&quot;&gt;https://groups.google.com/g/gurobi/c/MaEP4cun8o8?pli=1&lt;/a&gt;, but these no longer work.&lt;/p&gt;&#xA;" OwnerUserId="4789" LastActivityDate="2023-10-04T11:04:17.037" Title="How to validate a Gurobi academic license remotely via ssh SOCKS proxy?" Tags="|gurobi|software|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5564" PostTypeId="2" ParentId="5563" CreationDate="2021-01-19T13:02:47.047" Score="6" Body="&lt;p&gt;EDIT: Instead of a VPN, one can apparently use an &lt;a href=&quot;https://superuser.com/questions/1308495/how-to-create-a-socks-proxy-with-ssh&quot;&gt;ssh SOCKS proxy&lt;/a&gt;.  This worked for me as of January 2021.  Specifically, commands for enabling a SOCKS proxy on my mac are:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sudo networksetup -setsocksfirewallproxy 'Ethernet' 127.0.0.1 4088&#xA;sudo networksetup -setsocksfirewallproxy 'Wi-Fi' 127.0.0.1 4088&#xA;&#xA;ssh -N -D 4088 &amp;lt;remote host&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then, in a separate terminal window, run grbgetkey as usual.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;grbgetkey &amp;lt;LICENSE KEY&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360076437251-grbgetkey-via-ssh-socks-proxy&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://support.gurobi.com/hc/en-us/community/posts/360076437251-grbgetkey-via-ssh-socks-proxy&lt;/a&gt; .&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;EDIT Sept. 2021&lt;/em&gt;: the following comment for Mac OS Catalina was given at the above link, &lt;a href=&quot;https://superuser.com/questions/1308495/how-to-create-a-socks-proxy-with-ssh&quot;&gt;1&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I couldn't get these instructions to work. (on Catalina, it seems&#xA;opening a new terminal window doesn't give the terminal the proxy&#xA;information... and I was still getting the 'not an academic domain'&#xA;error) But this led me to an easier fix...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ ssh -N -D 4088 user@host.edu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Then in another terminal&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;math-container&quot;&gt;$ export HTTP_PROXY=socks5://127.0.0.1:4088&#xA;$&lt;/span&gt; grbgetkey --http --verbose &amp;lt;LICENSE KEY&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can probably get this to use https too if you setup the&#xA;https_proxy variable, but I didn't try that.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;EDIT Oct. 2022 (and still working Oct 2023)&lt;/em&gt;:&lt;/p&gt;&#xA;&lt;p&gt;It seems grbgetkey version 9.5.2 doesn't have the --http flag, but using HTTPS_PROXY did work for me:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ ssh -N -D 4088 user@host.edu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Then in another terminal&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;math-container&quot;&gt;$ export HTTPS_PROXY=socks5://127.0.0.1:4088&#xA;$&lt;/span&gt; grbgetkey --verbose &amp;lt;LICENSE KEY&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4789" LastEditorUserId="-1" LastEditDate="2023-10-04T11:04:17.037" LastActivityDate="2023-10-04T11:04:17.037" CommentCount="2" CommunityOwnedDate="2021-01-19T13:02:47.047" ContentLicense="CC BY-SA 4.0" />
  <row Id="5565" PostTypeId="1" CreationDate="2021-01-19T17:40:38.200" Score="1" ViewCount="593" Body="&lt;p&gt;I am trying to solve a large-scale nonlinear problem. Below is the objective function coded for pyscipopt. I have some loops over a list of tuples (r,p,s) in the list RouteTimeStop, and the only variable is headway[pat]. When I looped over RouteTimeStop, the solver stuck at the objective function creation and did not produce any progress for quite a long time. Then, I tried to see what is going on and considered first 200 tuples of the list.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;### BEGIN DECLARING THE MODEL ###&#xA;m = Model('CTA')&#xA;### END DECLARING THE MODEL ###&#xA;&#xA;### BEGIN ADDING VARIABLES INTO THE MODEL m ###&#xA;headway = {}&#xA;for pat in Pattern:&#xA;    headway[pat] = m.addVar(vtype = &amp;quot;C&amp;quot;, lb = 1, ub = 30, name = &amp;quot;headway (%s)&amp;quot;%(pat))&#xA;print(&amp;quot;Added the variables.&amp;quot;)&#xA;### END ADDING VARIABLES INTO THE MODEL m ###&#xA;&#xA;### BEGIN INTRODUCING THE OBJECTIVE FUNCTION INTO m ###&#xA;m.setObjective(quicksum(b/2/(1-el[r,p,s])*con2[r,p,s]*(30**(1-el[r,p,s])&#xA;             -(quicksum(pattern_ratio[r,p,s,pat]*30*headway[pat] for pat in RTSPdict[r,p,s])/30)&#xA;             **(el[r,p,s]-1)) for (r,p,s) in RouteTimeStop[:200])&#xA;             + quicksum(con[r,p,s]*quicksum(pattern_ratio[r,p,s,pat]*30*headway[pat]&#xA;             for pat in RTSPdict[r,p,s])**el[r,p,s] for (r,p,s) in RouteTimeStop[:200]),&#xA;             'maximize')&#xA;print(&amp;quot;Added the objective function.&amp;quot;)&#xA;### END INTRODUCING THE OBJECTIVE FUNCTION ###&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The solver produced the following error.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Added the variables.&#xA;---------------------------------------------------------------------------&#xA;AssertionError                            Traceback (most recent call last)&#xA;&amp;lt;ipython-input-40-164bed181b42&amp;gt; in &amp;lt;module&amp;gt;&#xA;     11 &#xA;     12 ### BEGIN INTRODUCING THE OBJECTIVE FUNCTION INTO m ###&#xA;---&amp;gt; 13 m.setObjective(quicksum(b/2/(1-el[r,p,s])*con2[r,p,s]*(30**(1-el[r,p,s])&#xA;     14        -(quicksum(pattern_ratio[r,p,s,pat]*30*headway[pat] for pat in RTSPdict[r,p,s])/30)&#xA;     15                 **(el[r,p,s]-1)) for (r,p,s) in RouteTimeStop[:200])&#xA;&#xA;src/pyscipopt/scip.pyx in pyscipopt.scip.Model.setObjective()&#xA;&#xA;AssertionError: given coefficients are neither Expr or number but SumExpr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After playing a bit with the objective function, I realized number &lt;strong&gt;/&lt;/strong&gt; variable and variable &lt;strong&gt;^&lt;/strong&gt; number are not accepted in the objective function. How can I deal with this issue?&lt;/p&gt;&#xA;&lt;p&gt;Below is a math formulation of the objective function (some notation names do differ between the code and the math formulation):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$max \sum_{(r,p,s)\in RTS}e_{r,p,s}(h_{pat})+b w_{r,p,s}(h_{pat})\tag{1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{2}e_{r,p,s}(h_{pat})=C_{r,p,s}\left(\sum_{pat\in \pi_{r,p,s}}l_{pat}^{r,p,s}\frac{30}{h_{pat}}\right)^{\beta_{r,p,s}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{3}w_{r,p,s}(h_{pat})=\frac{C_{r,p,s}^\prime}{2\left(1-\beta_{r,p,s}\right)}\left[30^{\left(1-\beta_{r,p,s}\right)}-\left(\frac{\sum_{pat\in \pi_{r,p,s}}l_{pat}^{r,p,s}\frac{30}{h_{pat}}}{30}\right)^{\beta_{r,p,s}-1}\right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$h_{pat}\in\mathbb{R}^+$&lt;/span&gt; and is the only variable. The parameter &lt;span class=&quot;math-container&quot;&gt;$\beta_{r,p,s}\in[0.01,0.95]$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="727" LastEditDate="2021-03-04T20:15:46.077" LastActivityDate="2021-03-04T20:15:46.077" Title="Doesn't Pyscipopt handle nonlinear objective functions?" Tags="|python|nonlinear-programming|open-source|scip|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5566" PostTypeId="1" CreationDate="2021-01-19T19:46:05.250" Score="3" ViewCount="425" Body="&lt;p&gt;I am using CPLEX with Julia using the package JuMP to solve a MIP problem.&#xA;In a small instance, I have tested my problem but, after 10 minutes, nothing happens. I have defined the following parameters in CPLEX:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;set_optimizer_attribute(modelo,&amp;quot;CPX_PARAM_ZEROHALFCUTS&amp;quot;,2)&lt;/code&gt; --&amp;gt;&amp;gt; Generate zero-half cuts aggressively&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;set_optimizer_attribute(modelo,&amp;quot;CPXPARAM_MIP_Cuts_Covers&amp;quot;,2)&lt;/code&gt;  --&amp;gt;&amp;gt; Generate cover cuts aggressively&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;set_optimizer_attribute(modelo,&amp;quot;CPXPARAM_MIP_Strategy_SubAlgorithm&amp;quot;,1)&lt;/code&gt; --&amp;gt;&amp;gt; Emphasize feasibility over optimality&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The branch-and-bound does not even begin. Look the CPLEX report:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;CPXPARAM_TimeLimit                               600&#xA;CPXPARAM_MIP_Cuts_Covers                         2&#xA;CPXPARAM_MIP_Tolerances_MIPGap                   0.01&#xA;CPXPARAM_MIP_Strategy_SubAlgorithm               1&#xA;CPXPARAM_MIP_Cuts_ZeroHalfCut                    2&#xA;Warning:  Non-integral bounds for integer variables rounded.&#xA;Warning:  No solution found from 1 MIP starts.&#xA;Retaining values of one MIP start for possible repair.&#xA;&#xA;Root node processing (before b&amp;amp;c):&#xA;  Real time             =  600.11 sec. (206099.96 ticks)&#xA;Parallel b&amp;amp;c, 12 threads:&#xA;  Real time             =    0.00 sec. (0.00 ticks)&#xA;  Sync time (average)   =    0.00 sec.&#xA;  Wait time (average)   =    0.00 sec.&#xA;                          ------------&#xA;Total (root+branch&amp;amp;cut) =  600.11 sec. (206099.96 ticks)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In another test, I used all of the default parameters but the result was the same.&lt;/p&gt;&#xA;&lt;p&gt;My problem does not have any big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; usage in the formulation.&lt;/p&gt;&#xA;&lt;p&gt;Is there a combination of CPLEX parameters that accelerate obtaining an integer feasible solution?&lt;/p&gt;&#xA;" OwnerUserId="4760" LastEditorUserId="491" LastEditDate="2021-01-20T17:08:39.220" LastActivityDate="2021-01-20T17:08:39.220" Title="Problems finding a feasible solution in a MIP" Tags="|mixed-integer-programming|integer-programming|cplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5567" PostTypeId="2" ParentId="5566" CreationDate="2021-01-19T22:36:17.737" Score="9" Body="&lt;ol&gt;&#xA;&lt;li&gt;Aggressive cut generation will slow the processing of the root node (and other nodes, if cuts are generated beyond the root), so it's more likely to slow finding a feasible solution than to speed it up.&lt;/li&gt;&#xA;&lt;li&gt;Setting MIP_Strategy_Subalgorithm to 1 tells CPLEX to use primal simplex on node subproblems. To emphasize finding feasible solutions, you want to set CPXPARAM_Emphasis_MIP to 1.&lt;/li&gt;&#xA;&lt;li&gt;You might try setting CPXPARAM_Emphasis_MIP to 4 (&amp;quot;hidden feasibility&amp;quot;) if setting 1 does not yield a good incumbent.&lt;/li&gt;&#xA;&lt;li&gt;If you are using CPLEX 20.1, there is a new value (5) for CPXPARAM_Emphasis_MIP. The documentation describes this as &amp;quot;Emphasize finding high quality feasible solutions earlier&amp;quot;.&lt;/li&gt;&#xA;&lt;li&gt;The log indicates that you gave CPLEX an incomplete or infeasible solution as a warm-start, but that it failed to turn that into a feasible starting solution. If this came from some heuristic, you might look at whether you can improve the heuristic. Also, if you think the starting &amp;quot;solution&amp;quot; can be turned into a feasible solution, you can try increasing the value of CPXPARAM_MIP_Limits_RepairTries. (The default is to let CPLEX decide how much it tries to repair your starting solution.)&lt;/li&gt;&#xA;&lt;li&gt;Assuming that you have no quadratic constraints, you can try using the feasibility pump heuristic, by setting CPXPARAM_MIP_Strategy_FPHeur to 1 or 2.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I would not try all of these at once, but rather experiment with one or two at a time.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-01-19T22:36:17.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5568" PostTypeId="1" CreationDate="2021-01-20T14:29:28.017" Score="1" ViewCount="56" Body="&lt;p&gt;I'm modeling a fairly basic order and inventory management system but with a use case that doesn't seem very common (or at least hard to look up online and in books about operations): &lt;strong&gt;the order fulfillment date is specific and sometimes far in the future&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A simplified description: a hotel wants to sell items during or after the reservation process. A room can be reserved for the next day or the next year. The order fulfillment (= item delivery) is at check-in time. There is no shipping delay, as the stock is maintain at the hotel and delivered into the room in person.&lt;/p&gt;&#xA;&lt;p&gt;I've been able to define some basic concepts to help figure out the scope of the system, specifically: orders with a scheduled fulfillment date (i.e. not &amp;quot;ASAP&amp;quot;), on-hand inventory, stock reservations, and a simple, low-scale replenishment process.&lt;/p&gt;&#xA;&lt;p&gt;However, I'd like to better define an important operational aspect: &lt;strong&gt;reservations for 1 year in the future should not result in a stock reservation against on-hand inventory&lt;/strong&gt;. This is for a few reasons:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The hotel will definitely replenish the inventory before then&lt;/li&gt;&#xA;&lt;li&gt;If the on-hand inventory is reserved for 1 year in the future, it's inventory the hotel cannot sell and use to fulfill more recent orders with a near-future fulfillment date&lt;/li&gt;&#xA;&lt;li&gt;The inventory might be perishable&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Are there any resources, best practices, case studies around these needs?&lt;/p&gt;&#xA;&lt;p&gt;What concepts could help me define how far in the future an order results in a stock reservation against on-hand inventory vs. a reservation to be matched with inventory when the time comes?&lt;/p&gt;&#xA;" OwnerUserId="4798" LastActivityDate="2021-01-20T14:29:28.017" Title="Concepts for managing inventory and orders with specific fulfillment date" Tags="|inventory|base-stock|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5570" PostTypeId="1" CreationDate="2021-01-20T18:47:08.527" Score="4" ViewCount="555" Body="&lt;p&gt;Supose that I have an integer feasible solution for a MIP and I provide this one for CPLEX. I have tested this situation in a problem and CPLEX have reported the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;CPXPARAM_TimeLimit                               600&#xA;CPXPARAM_MIP_Tolerances_MIPGap                   0.01       &#xA;Warning:  Non-integral bounds for integer variables rounded.&#xA;5 of 6 MIP starts provided solutions.&#xA;MIP start 'm1' defined initial solution with objective 8711.0000.&#xA;Warning:  Non-integral bounds for integer variables rounded.     &#xA;Tried aggregator 3 times.&#xA;MIP Presolve eliminated 41041 rows and 5542 columns.&#xA;MIP Presolve modified 12819 coefficients.&#xA;Aggregator did 102 substitutions.&#xA;Reduced MIP has 15022 rows, 13813 columns, and 81253 nonzeros.&#xA;Reduced MIP has 12735 binaries, 0 generals, 0 SOSs, and 0 indicators.&#xA;Presolve time = 0.19 sec. (256.82 ticks)&#xA;Probing fixed 900 vars, tightened 0 bounds.&#xA;Probing time = 0.08 sec. (66.81 ticks)&#xA;Tried aggregator 2 times.&#xA;MIP Presolve eliminated 93 rows and 902 columns.&#xA;MIP Presolve modified 1396 coefficients.&#xA;Aggregator did 3 substitutions.&#xA;Reduced MIP has 14926 rows, 12908 columns, and 76009 nonzeros.        &#xA;Reduced MIP has 12858 binaries, 15 generals, 0 SOSs, and 0 indicators.&#xA;Presolve time = 0.08 sec. (105.79 ticks)&#xA;Probing time = 0.00 sec. (6.36 ticks)&#xA;Clique table members: 11526.&#xA;MIP emphasis: balance optimality and feasibility.    &#xA;MIP search method: dynamic search.&#xA;Parallel mode: deterministic, using up to 12 threads.&#xA;Root relaxation solution time = 0.98 sec. (883.29 ticks)&#xA;&#xA;        Nodes                                         Cuts/&#xA;   Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap &#xA;&#xA;*     0+    0                         8711.0000  -458520.0000              --- &#xA;      0     0   -17149.9829  2477     8711.0000   -17149.9829        0  296.88%&#xA;*     0+    0                         7205.0000   -17149.9829           338.03%&#xA;      0     0   -15317.4801  2303     7205.0000     Cuts: 572    16267  312.60%&#xA;      0     0   -14779.1052  2136     7205.0000     Cuts: 440    21296  305.12%&#xA;      0     0   -14380.2661  2301     7205.0000     Cuts: 320    31470  299.59%&#xA;      0     0   -14103.7735  2526     7205.0000     Cuts: 448    37793  295.75%&#xA;      0     0   -13732.7994  2426     7205.0000     Cuts: 400    43124  290.60%&#xA;      0     0   -13445.8090  2638     7205.0000     Cuts: 392    50169  286.62%&#xA;      0     0   -13155.3050  2773     7205.0000     Cuts: 372    59588  282.59%&#xA;      0     0   -12823.9768  2893     7205.0000     Cuts: 364    67111  277.99%&#xA;      0     0   -12599.0288  2404     7205.0000     Cuts: 337    75557  274.87%&#xA;      0     0   -12430.1956  2773     7205.0000     Cuts: 382    85578  272.52%&#xA;      0     0   -12150.1949  2883     7205.0000     Cuts: 408    96883  268.64%&#xA;      0     0   -11987.4450  3172     7205.0000     Cuts: 388   117106  266.38%&#xA;      0     0   -11798.6406  2739     7205.0000     Cuts: 380   128615  263.76%&#xA;      0     0   -11592.1280  2515     7205.0000     Cuts: 367   141135  260.89%&#xA;      0     0   -11195.5796  2557     7205.0000     Cuts: 558   163911  255.39%&#xA;      0     0   -10867.8034  2569     7205.0000     Cuts: 485   182024  250.84%&#xA;      0     0   -10563.4191  2822     7205.0000     Cuts: 425   204140  246.61%&#xA;      0     0   -10321.3655  3025     7205.0000     Cuts: 417   215627  243.25%&#xA;      0     0   -10150.4502  2638     7205.0000     Cuts: 421   233232  240.88%&#xA;      0     0   -10048.7581  2715     7205.0000     Cuts: 378   245798  239.47%&#xA;      0     0    -9945.2271  2933     7205.0000     Cuts: 360   257496  238.03%&#xA;      0     0    -9832.7526  3319     7205.0000     Cuts: 363   271374  236.47%&#xA;      0     0    -9736.9997  3211     7205.0000     Cuts: 396   285686  235.14%&#xA;      0     0    -9652.8245  2848     7205.0000     Cuts: 340   298003  233.97%&#xA;      0     0    -9550.7594  3086     7205.0000     Cuts: 366   311895  232.56%&#xA;      0     0    -9448.1725  3051     7205.0000     Cuts: 416   331676  231.13%&#xA;      0     0    -9353.9779  3025     7205.0000     Cuts: 380   342695  229.83%&#xA;      0     0    -9281.6027  3068     7205.0000     Cuts: 390   354086  228.82%&#xA;      0     0    -9193.7089  3084     7205.0000     Cuts: 370   368795  227.60%&#xA;*     0+    0                         6997.0000    -9193.7089           231.40%&#xA;      0     0    -9099.7451  3741     6997.0000     Cuts: 387   381566  230.05%&#xA;*     0+    0                         6835.5000    -9099.7451           233.12%&#xA;*     0+    0                         6510.5000    -9099.7451           239.77%&#xA;      0     0    -9044.4629  3377     6510.5000     Cuts: 363   389565  238.92%&#xA;      0     0    -8964.7389  2960     6510.5000     Cuts: 349   407833  237.70%&#xA;      0     0    -8911.6534  2837     6510.5000     Cuts: 372   422932  236.88%&#xA;*     0+    0                         6167.0000    -8911.6534           244.51%&#xA;*     0+    0                         6096.0000    -8911.6534           246.19%&#xA;*     0+    0                         5401.0000    -8911.6534           265.00%&#xA;      0     0    -8835.6035  3156     5401.0000     Cuts: 345   438079  263.59%&#xA;*     0+    0                         5384.0000    -8835.6035           264.11%&#xA;      0     0    -8759.5640  3011     5384.0000     Cuts: 372   448024  262.70%&#xA;&#xA;GUB cover cuts applied:  213&#xA;Clique cuts applied:  14&#xA;Cover cuts applied:  59&#xA;Implied bound cuts applied:  96&#xA;Flow cuts applied:  33&#xA;Mixed integer rounding cuts applied:  176&#xA;Zero-half cuts applied:  1721&#xA;Gomory fractional cuts applied:  12&#xA;&#xA;Root node processing (before b&amp;amp;c):&#xA;  Real time             =  600.09 sec. (300168.69 ticks)&#xA;Parallel b&amp;amp;c, 12 threads:&#xA;  Real time             =    0.00 sec. (0.00 ticks)&#xA;  Sync time (average)   =    0.00 sec.&#xA;  Wait time (average)   =    0.00 sec.&#xA;                          ------------&#xA;Total (root+branch&amp;amp;cut) =  600.09 sec. (300168.69 ticks)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Are there any suggestion in the CPLEX paraameters to accelerate/improve the lower bound of my problem and, consequenty, improve the relative GAP when CPLEX runs? I will apreciate any suggestion. Thank you so much.&lt;/p&gt;&#xA;" OwnerUserId="4760" LastActivityDate="2021-01-21T08:30:59.900" Title="How to improve relative mip GAP using CPLEX in a MIP" Tags="|mixed-integer-programming|integer-programming|cplex|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5571" PostTypeId="1" AcceptedAnswerId="5574" CreationDate="2021-01-20T19:29:15.713" Score="1" ViewCount="84" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$f: \mathbb{R}^n \rightarrow \mathbb{R}.$&lt;/span&gt; Consider second order approximation &lt;span class=&quot;math-container&quot;&gt;$f(x) \approx f_0(x)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$$f_0(x) = f(x_0) + \nabla f(x_0)^T (x-x_0) + (\mathrm{H}f(x_0)(x - x_0))^T(x - x_0)$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\mathrm{H}$&lt;/span&gt; is a hessian matrix. Write KKT conditions for problem of minimizing &lt;span class=&quot;math-container&quot;&gt;$f_0$&lt;/span&gt; with constraint &lt;span class=&quot;math-container&quot;&gt;$Ax + b$&lt;/span&gt; = 0.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It seems like there are only equality constraints, I have to create a Lagrangian and for that I need a gradient of &lt;span class=&quot;math-container&quot;&gt;$f_0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I treat &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; as a column vector.&lt;/p&gt;&#xA;&lt;p&gt;My attempt:&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$f(x_0) = c_0, \nabla f(x_0) = c, \mathrm{H}f(x_0) = D$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;then &lt;span class=&quot;math-container&quot;&gt;$\nabla f_0(x) = c + (D + D^T)x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Basically I treat  value, gradient and hessian at &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; as constants.&lt;/p&gt;&#xA;&lt;p&gt;Is this correct way of calculating the gradient of &lt;span class=&quot;math-container&quot;&gt;$f_0(x)$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;That means the lagrangian is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c + (D + D^T)x + \lambda^T(Ax - b)$$&lt;/span&gt;&#xA;with constraint that &lt;span class=&quot;math-container&quot;&gt;$Ax - b = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So the KKT conditions are in this case&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c + (D + D^T)x + \lambda^T(Ax - b) = 0 \\ Ax-b = 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can someone agree or say what is wrong?&lt;/p&gt;&#xA;" OwnerUserId="4797" LastEditorUserId="4797" LastEditDate="2021-01-21T09:03:52.610" LastActivityDate="2021-01-21T09:03:52.610" Title="KKT for second order approximation of $f(x)$" Tags="|optimization|kkt-conditions|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5572" PostTypeId="2" ParentId="5570" CreationDate="2021-01-20T22:07:41.693" Score="3" Body="&lt;p&gt;You can use the automatic parameter tuning in cplex, or try parameters yourself and see which ones work best. There is a guide by IBM on what they suggest: &lt;a href=&quot;https://www.ibm.com/support/pages/cplex-performance-tuning-mixed-integer-programs&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/support/pages/cplex-performance-tuning-mixed-integer-programs&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can give the problem more runtime and it will most likely improve the gap.&lt;/p&gt;&#xA;&lt;p&gt;You can try to find a better inital feasible solution and hope that it prunes the tree faster. Based on the size of your gap, this will likely not help very much.&lt;/p&gt;&#xA;&lt;p&gt;But to get any real improvement, you will likely need to improve the formulation of your problem.&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2021-01-21T08:30:59.900" LastActivityDate="2021-01-21T08:30:59.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5573" PostTypeId="2" ParentId="5570" CreationDate="2021-01-20T22:12:13.243" Score="3" Body="&lt;p&gt;You can try setting the MIP Emphasis parameter (Java name loCplex.Param.Emphasis.MIP) to 3, which emphasizes tightening the best bound. This may result in slower progress on the primal bound (best known solution), and it is not guaranteed to help. There are also a variety of parameters related to adding cuts (how frequently cuts are added, how much emphasis is put on adding cuts). It is possible that playing with those would make the bound increase faster, but again there is no guarantee. Tweaking the repeat presolve parameter (Java name IloCplex.Param.Preprocessing.RepeatPresolve) also might (or might not) help. The same is true for node presolve (Java name IloCplex.Param.MIP.Strategy.PresolveNode).&lt;/p&gt;&#xA;&lt;p&gt;The fact that your lower bounds are negative has me wondering whether negative objective values are actually feasible in practice, or whether the optimum must have a positive objective value. If the latter is true, you might look for ways to tighten your formulation (beyond the trivial one of just constraining the objective to be nonnegative).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-01-20T22:12:13.243" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5574" PostTypeId="2" ParentId="5571" CreationDate="2021-01-20T22:19:03.827" Score="3" Body="&lt;p&gt;The gradient and Hessian of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$x=x_0$&lt;/span&gt; are constants (vector and matrix respectively), so &lt;span class=&quot;math-container&quot;&gt;$f_0(x)$&lt;/span&gt; is a quadratic function of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. If it helps, write it as &lt;span class=&quot;math-container&quot;&gt;$f_0(x) = c_0 + c^Tx + x^T D x$&lt;/span&gt;. Hopefully you know the gradient of that. Then figure out what &lt;span class=&quot;math-container&quot;&gt;$c_0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; are in terms of &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f(x_0)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\nabla f(x_0)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Hf(x_0)$&lt;/span&gt;, substitute and maybe simplify a little.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-01-20T22:19:03.827" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5575" PostTypeId="1" AcceptedAnswerId="5576" CreationDate="2021-01-21T15:07:06.923" Score="6" ViewCount="1137" Body="&lt;p&gt;Given a set of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; points &lt;span class=&quot;math-container&quot;&gt;$\{x\mid x \in \mathbb{R}^D\}$&lt;/span&gt; for some dimensionality &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; I want a fast algorithm which will give me all unique subsets which satisfy:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\|x_{i} - x_{j}\|_{D} \leq M$&lt;/span&gt; (all pairs of points in the subset are close to one another)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$|\{x\}| \ge n$&lt;/span&gt; (there is some minimum number of points in the subset)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In normal-speak: I want to find all sets of closely bunched points on a map and be able to point to them and say &amp;quot;that's a set of closely clustered points, we should look into it!&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;The naive approach would be to check every point, and see if it has &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; or more points within &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; distance of it. But I feel like there should be a more efficient way.&lt;/p&gt;&#xA;&lt;p&gt;Then, in the context of my map application, the follow up would be to do some sort of non-maximum suppression on overlapping subsets.&lt;/p&gt;&#xA;" OwnerUserId="2828" LastEditorUserId="123" LastEditDate="2021-01-21T15:16:57.603" LastActivityDate="2021-01-23T00:13:53.753" Title="What are some &quot;clustering&quot; algorithms? (but not the type of clustering you're thinking about)" Tags="|clustering|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5576" PostTypeId="2" ParentId="5575" CreationDate="2021-01-21T16:47:27.207" Score="14" Body="&lt;p&gt;You are trying to list all cliques of a graph. You said that &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^2$&lt;/span&gt;, which greatly simplifies the problem: the graph is a &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Unit_disk_graph&quot; rel=&quot;noreferrer&quot;&gt;unit disk graph&lt;/a&gt;, for which the maximum clique problem is polynomial. However, the number of cliques may be exponential.&lt;/p&gt;&#xA;&lt;p&gt;In practice, it is likely easier to apply a heuristic or a generic maximum clique algorithm rather than rolling your own. The exponential worst case can be avoided by listing a limited number of clusters for each point.&lt;/p&gt;&#xA;&lt;p&gt;Links:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.google.com/url?q=https://citeseerx.ist.psu.edu/viewdoc/download%3Fdoi%3D10.1.1.70.1687%26rep%3Drep1%26type%3Dpdf&amp;amp;sa=U&amp;amp;ved=2ahUKEwi69omKvq3uAhWu4IUKHfs6A8gQFjAMegQIABAB&amp;amp;usg=AOvVaw3HB19BwLnUCLePnCSaZEPH&quot; rel=&quot;noreferrer&quot;&gt;a heuristic to list all cliques on unit disk graphs&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://cs.stackexchange.com/questions/84856/what-is-the-exact-algorithm-to-find-maximum-clique-of-a-given-unit-disk-graph&quot;&gt;a polynomial algorithm for the maximum clique problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2021-01-21T16:55:25.077" LastActivityDate="2021-01-21T16:55:25.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5577" PostTypeId="1" CreationDate="2021-01-22T09:16:54.280" Score="3" ViewCount="569" Body="&lt;p&gt;What are all necessary changes to the below model so that constraint set &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; becomes soft?&lt;/p&gt;&#xA;&lt;p&gt;Give the new full model. &lt;span class=&quot;math-container&quot;&gt;$\alpha_{ij}$&lt;/span&gt; are parameters. Eqn. &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; refers to an already existing function of the decision variables that is being maximized.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max\limits_{x\in \mathbb{R^{m\times n}}}&amp;amp;\quad f(x) \tag{1} \\&#xA;\text{s.t.}&amp;amp;\quad\sum_{i=1}^m a_{ij}x_{ij}=10  &amp;amp;\forall j=1,\ldots,m \tag{2} \\&amp;amp;\quad x_{ij}\ge 0 &amp;amp; \forall i=1,\ldots,m,\; \forall j=1,\ldots,n \tag{3}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What will change if the problem becomes a minimization problem?&lt;/p&gt;&#xA;" OwnerUserId="4807" LastEditorUserId="123" LastEditDate="2021-01-22T09:52:03.813" LastActivityDate="2021-01-25T12:42:13.160" Title="Hard to soft constraint" Tags="|optimization|constraint|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5578" PostTypeId="2" ParentId="5577" CreationDate="2021-01-22T14:01:37.193" Score="7" Body="&lt;p&gt;To make constraint (2) soft, you can proceed as follows. Transform the constraint into two inequalities (2a) and (2b), add non negative variables &lt;span class=&quot;math-container&quot;&gt;$\varepsilon_{kj}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$k\in \{1,2\}$&lt;/span&gt; to allow violation, and minimize the violation in the cost function :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max\limits_{x\in \mathbb{R^{m\times n}}}\quad f(x)  - \sum_{k,j}\varepsilon_{kj}&#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\sum_{i=1}^m a_{ij}x_{ij}\le10 + \varepsilon_{1j}  &amp;amp;\forall j=1,\ldots,m \tag{2a} \\&#xA;&amp;amp;\sum_{i=1}^m a_{ij}x_{ij}\ge10 - \varepsilon_{2j}  &amp;amp;\forall j=1,\ldots,m \tag{2b} &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Depending on how much violation is allowed, you might want to add weights to variables &lt;span class=&quot;math-container&quot;&gt;$\varepsilon_{kj}$&lt;/span&gt;. You might also want to consider minimizing &lt;span class=&quot;math-container&quot;&gt;$\max\{\varepsilon_{kj}\}$&lt;/span&gt; instead.&lt;/p&gt;&#xA;&lt;p&gt;Now if this is homework, I will leave you with question 2, which you should be able to easily answer if you understand the spirit of the above strategy.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="39" LastEditDate="2021-01-22T15:28:35.053" LastActivityDate="2021-01-22T15:28:35.053" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5579" PostTypeId="1" CreationDate="2021-01-22T16:28:07.750" Score="2" ViewCount="173" Body="&lt;p&gt;I am using CPLEX 12.8 to minimize a quadratic binary nonconvex function, according to &lt;a href=&quot;https://or.stackexchange.com/questions/503/cplex-non-convex-quadratic-programming-algorithms&quot;&gt;quadratic function by CPLEX&lt;/a&gt;.&#xA;In particular, my function is the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^{m-1} \sum_{f=1}^{F} \sum_{\underset{\bar{f} \neq f}{\bar{f}=1}}^F \sum_{h \in H}  \left( D_{f \bar{f}} \cdot \gamma_{i\bar{f}h} \cdot \gamma_{i+1,f,h} \right) $$&lt;/span&gt;&#xA;over a set &lt;span class=&quot;math-container&quot;&gt;$X \neq \varnothing$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\gamma_{ifh} \in \{0,1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D_{f\bar{f}} &amp;gt; 0$&lt;/span&gt; (distance symetric matrix).&lt;/p&gt;&#xA;&lt;p&gt;However, when I apply CPLEX in this function (even not knowing if it is convex), the error appears:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Matrix Q must be either symmetric or triangular&#xA;error(::String) at error.jl:33&#xA;add_qpterms!(::CPLEX.Model, ::Array{Int32,1}, ::Array{Int32,1}, ::Array{Float64,1}) at cpx_quad.jl:17&#xA;set(::CPLEX.Optimizer, ::MathOptInterface.ObjectiveFunction{MathOptInterface.ScalarQuadraticFunction{Float64}}, ::MathOptInterface.ScalarQuadraticFunction{Float64}) at MOI_wrapper.jl:727&#xA;set(::MathOptInterface.Bridges.LazyBridgeOptimizer{CPLEX.Optimizer}, ::MathOptInterface.ObjectiveFunction{MathOptInterface.ScalarQuadraticFunction{Float64}}, ::MathOptInterface.ScalarQuadraticFunction{Float64}) at bridge_optimizer.jl:718&#xA;_pass_attributes(::MathOptInterface.Bridges.LazyBridgeOptimizer{CPLEX.Optimizer}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Array{MathOptInterface.AbstractModelAttribute,1}, ::Tuple{}, ::Tuple{}, ::Tuple{}, ::typeof(MathOptInterface.set)) at copy.jl:148&#xA;pass_attributes at copy.jl:112 [inlined]&#xA;pass_attributes at copy.jl:111 [inlined]&#xA;default_copy_to(::MathOptInterface.Bridges.LazyBridgeOptimizer{CPLEX.Optimizer}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::Bool) at copy.jl:337&#xA;#automatic_copy_to#109 at copy.jl:15 [inlined]&#xA;automatic_copy_to at copy.jl:14 [inlined]&#xA;#copy_to#3 at bridge_optimizer.jl:268 [inlined]&#xA;(::MathOptInterface.var&amp;quot;#copy_to##kw&amp;quot;)(::NamedTuple{(:copy_names,),Tuple{Bool}}, ::typeof(MathOptInterface.copy_to), ::MathOptInterface.Bridges.LazyBridgeOptimizer{CPLEX.Optimizer}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}) at bridge_optimizer.jl:268&#xA;attach_optimizer(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at cachingoptimizer.jl:149&#xA;optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at cachingoptimizer.jl:185&#xA;optimize!(::Model, ::Nothing; bridge_constraints::Bool, ignore_optimize_hook::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at optimizer_interface.jl:131&#xA;optimize! at optimizer_interface.jl:107 [inlined]&#xA;optimize!(::Model) at optimizer_interface.jl:107&#xA;top-level scope at Modelo_avancado_graus_dias.jl.jl:139&#xA;include_string(::Function, ::Module, ::String, ::String) at loading.jl:1088&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have linerized this function by adding the constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\gamma_{i\bar{f}h} + \gamma_{i+1,f,h} - u_{if\bar{fh}} \leq 1, \quad \quad i=1,...,m,\, \quad f=1,...,F, \quad \bar{f} \in \{1,...,F\} \setminus f, \quad h \in H&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;u_{if\bar{fh}}  \leq  \gamma_{i\bar{f}h}, \quad \quad i=1,...,m,\, \quad f=1,...,F, \quad \bar{f} \in \{1,...,F\} \setminus f, \quad h \in H&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;u_{if\bar{fh}}  \leq  \gamma_{i+1,f,h}, \quad \quad i=1,...,m,\, \quad f=1,...,F, \quad \bar{f} \in \{1,...,F\} \setminus f, \quad h \in H&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$0 \leq u_{if\bar{fh}} = \gamma_{i\bar{f}h} \cdot \gamma_{i+1,f,h}$&lt;/span&gt;. But it was terrible to optimize the linear version: &lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^{m-1} \sum_{f=1}^{F} \sum_{\underset{\bar{f} \neq f}{\bar{f}=1}}^F \sum_{h \in H}  D_{f \bar{f}} \cdot u_{if\bar{f}h}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How can I fix this?&lt;/li&gt;&#xA;&lt;li&gt;How can I acess the matrix &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;?&lt;/li&gt;&#xA;&lt;li&gt;There is another way to minimize this function by using CPLEX, even I am not knowing if is convex?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4760" LastEditorUserId="491" LastEditDate="2021-01-22T16:42:30.427" LastActivityDate="2021-01-22T21:02:53.883" Title="Minimizing a quadratic binary nonconvex function by CPLEX" Tags="|mixed-integer-programming|integer-programming|cplex|solver|quadratic-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5580" PostTypeId="1" AcceptedAnswerId="5582" CreationDate="2021-01-22T20:54:38.127" Score="2" ViewCount="190" Body="&lt;p&gt;For the following problem I am trying to find maximum flow and minimum cut:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5tnqy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5tnqy.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I found the maximum flow as 6 like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1-3-7-8:2 flows$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1-2-5-8: 2 flows$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1-3-4-5-8:1 flow$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1-3-4-6-5-8:1 flow$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But I am having trouble to match the min cut, I thought it would be 8(by cutting the following arcs &lt;span class=&quot;math-container&quot;&gt;$(7,8)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(5,8))$&lt;/span&gt;. How do I match the min cut? Or do you think I made a mistake finding max flow?&lt;/p&gt;&#xA;" OwnerUserId="4647" LastActivityDate="2021-01-22T21:13:43.007" Title="Maximum flow minimum cut" Tags="|linear-programming|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5581" PostTypeId="2" ParentId="5579" CreationDate="2021-01-22T21:02:53.883" Score="3" Body="&lt;p&gt;The error is coming from an old version of CPLEX.jl.&lt;/p&gt;&#xA;&lt;p&gt;You should install CPLEX 20.1 and the latest version of CPLEX.jl, which doesn't have this issue.&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2021-01-22T21:02:53.883" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5582" PostTypeId="2" ParentId="5580" CreationDate="2021-01-22T21:13:43.007" Score="3" Body="&lt;p&gt;The maximum flow is &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt;.  To find a corresponding minimum cut, note that &lt;span class=&quot;math-container&quot;&gt;$S=\{1,3,4,7\}$&lt;/span&gt; is the set of nodes reachable from the source node &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in the residual network.  Now consider the arcs from &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$N\setminus S$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-01-22T21:13:43.007" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5584" PostTypeId="1" CreationDate="2021-01-22T22:15:48.380" Score="-2" ViewCount="130" Body="&lt;p&gt;I tried to solve this problem but I failed, please how to linearized full model.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/z7sur.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/z7sur.jpg&quot; alt=&quot;TSP&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4807" LastEditorUserId="123" LastEditDate="2021-01-23T10:44:50.157" LastActivityDate="2021-01-23T10:44:50.157" Title="how to linearize the full model for TSP quadratic formulation?" Tags="|linearization|traveling-salesman|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5585" PostTypeId="2" ParentId="5584" CreationDate="2021-01-22T22:24:11.427" Score="1" Body="&lt;p&gt;You can linearize a product of binary variables by introducing a new nonnegative variable and linear constraints, as shown &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;here&lt;/a&gt;.  In the present case, you can exploit the fact that the product appears only in the objective with a nonnegative objective coefficient.  So only one additional linear constraint (instead of three) is needed per product:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_{k,i,j} \ge y_{k,i} + y_{k+1,j} - 1$$&lt;/span&gt;&#xA;The linearized objective function is then&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j} d_{i,j} \sum_k z_{k,i,j}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Because of the original equality constraints, you can reduce the linearized problem size by using a single additional variable per edge:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_{i,j} \ge y_{k,i} + y_{k+1,j} - 1$$&lt;/span&gt;&#xA;with linearized objective function&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j} d_{i,j} z_{i,j}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-01-22T22:30:34.127" LastActivityDate="2021-01-22T22:30:34.127" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5586" PostTypeId="2" ParentId="5575" CreationDate="2021-01-23T00:13:53.753" Score="2" Body="&lt;p&gt;The naïve method you describe (loop over all points, select those that have more than &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; other points within distance &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; of them) is actually not a bad choice, as long as you store your points in a suitable spatial data structure (such as something based on a &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;quadtree&lt;/a&gt;) that makes finding and/or counting nearby points a cheap operation.  One advantage of this approach is that it will let you vary your definition of a cluster (e.g. to something like &amp;quot;the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-th nearest point is less than &lt;span class=&quot;math-container&quot;&gt;$f(n)$&lt;/span&gt; distance away&amp;quot;) fairly easily without having to switch to a different algorithm or a different data structure.&lt;/p&gt;&#xA;&lt;p&gt;That said, for the specific definition you give, you don't really need a quadtree.  The simplest spatial data structure sufficient for finding clusters according to your definition is just a regular grid.&lt;/p&gt;&#xA;&lt;p&gt;As you note in the comments, simply dividing the map into a grid of squares (or triangles or hexagons) and binning each point into the square it's located in could fail to correctly detect clusters located near a grid boundary.  However, the solution is simple: just count points located near a boundary in both of the squares on each side of the boundary.&lt;/p&gt;&#xA;&lt;p&gt;In fact, if you make your grid consist of squares with a side length of (at least) &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; units, you can use the following simple binning algorithm:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For each point, find the location of the closest grid &lt;em&gt;intersection&lt;/em&gt; (i.e. the closest corner point between four grid squares).  You can do this with simple division and rounding of the point coordinates.  Then add the point to &lt;em&gt;each of the four grid squares touching the intersection&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Once all points have been binned, look for squares with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; or more points.  Not all such squares will necessarily contain a cluster according to your definition (and they might also contain several disjoint clusters), they are at least &amp;quot;weakly clustered&amp;quot; in the sense of having &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; or more points at most &lt;span class=&quot;math-container&quot;&gt;$2\sqrt2 M'$&lt;/span&gt; units apart (where &lt;span class=&quot;math-container&quot;&gt;$M' \ge M$&lt;/span&gt; is the side length of your grid squares).  What is guaranteed, however, is that all the points in any cluster with diameter at most &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; are assigned to at least one common grid square.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In fact, for data visualization, you might not even need to find the actual clusters — it might be sufficient to plot the number of points assigned to each grid square by the algorithm above.&lt;/p&gt;&#xA;&lt;p&gt;Note that, if your map is very large compared to your cluster diameter &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, and your points are sparsely scattered on it, it may be inefficient to store the entire grid as a dense matrix or array.  Instead, use a sparse array data type so that you only need to store data for squares that actually have points assigned to them.  (This will also save time in the second step, since you can only iterate over the squares that actually have something in them.)  You can also save a bit of storage space if you, instead of assigning each point to four adjacent squares, actually assign it to only one of them, but then, in the second step, look for &lt;em&gt;groups of four adjacent squares&lt;/em&gt; with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; or more points.&lt;/p&gt;&#xA;" OwnerUserId="2510" LastActivityDate="2021-01-23T00:13:53.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5587" PostTypeId="2" ParentId="5577" CreationDate="2021-01-23T10:13:16.403" Score="12" Body="&lt;p&gt;My approach would be:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA; \min\&amp;gt;&amp;amp;- f(\color{darkred}x)+\sum_j \color{darkblue}p^-_j \color{darkred}s^-_j +\sum_j \color{darkblue}p^+_j \color{darkred}s^+_j\\&#xA;       &amp;amp;\sum_i \color{darkblue}a_{i,j}\color{darkred}x_{i,j} = 10 -\color{darkred}s^-_j + \color{darkred}s^+_j&amp;amp;&amp;amp;\forall j\\&#xA;       &amp;amp;\color{darkred}s^-_j,\color{darkred}s^+_j \ge 0&#xA;\end{align}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\color{darkblue}p$&lt;/span&gt; are penalties and &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}s$&lt;/span&gt; are slack variables. This prevents duplicating the terms &lt;span class=&quot;math-container&quot;&gt;$\sum_i \color{darkblue}a_{i,j}\color{darkred}x_{i,j}$&lt;/span&gt; (incurring possibly a large number of nonzero elements) and may also convey more clearly that we are making just one equality constraint elastic.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="126" LastEditDate="2021-01-25T12:42:13.160" LastActivityDate="2021-01-25T12:42:13.160" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5588" PostTypeId="1" CreationDate="2021-01-23T14:01:42.933" Score="5" ViewCount="117" Body="&lt;p&gt;As far as I know, one of the interesting resources to learn the basic concept of the decomposition methods is &lt;em&gt;&lt;strong&gt;column generation book (GERAD 25th Anniversary Series)&lt;/strong&gt;&lt;/em&gt;, which has been mentioned in some useful community Q&amp;amp;A like &lt;a href=&quot;https://or.stackexchange.com/questions/291/reference-for-column-generation-applications&quot;&gt;this&lt;/a&gt;, but unlikely there are no more materials/sample codes to reproduce whose examples (maybe, I cannot find that).&lt;/p&gt;&#xA;&lt;p&gt;I would like to know, are there any sample codes, specifically, based on the Java or Python API of CPLEX/Gurobi/SCIP, to benchmark them?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-12-11T08:59:43.597" LastActivityDate="2023-12-11T08:59:43.597" Title="Materials or sample code for column generation book (GERAD 25th Anniversary Series)" Tags="|solver|combinatorial-optimization|column-generation|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5589" PostTypeId="1" AcceptedAnswerId="5590" CreationDate="2021-01-24T04:33:13.723" Score="5" ViewCount="604" Body="&lt;p&gt;When applying the &lt;a href=&quot;https://en.wikipedia.org/wiki/Base_stock_model&quot; rel=&quot;nofollow noreferrer&quot;&gt;base stock inventory policy&lt;/a&gt;, assuming the daily demands are normally distributed with parameter &lt;span class=&quot;math-container&quot;&gt;$(\mu, \sigma)$&lt;/span&gt;, we can find the optimal parameter &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; (the base stock level) in several different ways: (say we have 0 lead time and review period is 1 unit period, and assume infinite horizon)&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;From the holding cost/stockout cost criterion: if holding cost per item is &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; and stockout cost per item is &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$S = \mu + \sigma\Phi^{-1}(\frac{p}{p+h})$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\Phi$&lt;/span&gt; is the cdf of the standard normal distribution.&lt;/li&gt;&#xA;&lt;li&gt;If the stockout cost &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is difficult to estimate for the firm, then a service-level-based approach is used, in particular, the two most basic types of service levels are Cycle Service Level (type 1 service rate) and Fill Rate (type 2 service rate): To achieve a type 1 service level of &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;, we simply have&#xA;&lt;span class=&quot;math-container&quot;&gt;$\alpha = \Phi((S-\mu)/\sigma)$&lt;/span&gt;, so the base stock level &lt;span class=&quot;math-container&quot;&gt;$S = \mu + \sigma\Phi^{-1}(\alpha)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For a type 2 service level, the calculation is more complicated. The usual formula for approximating the fill rate is &lt;span class=&quot;math-container&quot;&gt;$\beta = 1-\frac{n(S)}{\mu}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$n(S) = \sigma \mathcal{L}(z), z=(S-\mu)/\sigma$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{L}(z)$&lt;/span&gt; is the standard normal loss function (&lt;a href=&quot;https://books.google.com/books/about/Fundamentals_of_Supply_Chain_Theory.html?id=U7GTrLyVnPMC&quot; rel=&quot;nofollow noreferrer&quot;&gt;see e.g. in the appendix of this book&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The first two approaches give the base stock level a nice structure: &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; is the cycle stock to cover the average demand in lead time and review period, while &lt;span class=&quot;math-container&quot;&gt;$\sigma \Phi^{-1}(\alpha)$&lt;/span&gt; is the safety stock to buffer the fluctuations in lead time demand, and we have a rather simple description of the relation between the safety stock and the service level &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;. However, when using the fill rate approach, the base stock level &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is found by solving the nonlinear equation &lt;span class=&quot;math-container&quot;&gt;$\beta = 1-n(S)/\mu$&lt;/span&gt;, we can still compute the associated base safety stock level &lt;span class=&quot;math-container&quot;&gt;$ss = S-\mu$&lt;/span&gt;, but we no longer have a simple description on the relationship bewteen the safety stock level, the fill rate &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; and the demand standard deviation &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So my question is: is there any approximate formula/asymptotic expression (as &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; approaches &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;) that gives the rough relation between the safety stock level &lt;span class=&quot;math-container&quot;&gt;$ss = S-\mu$&lt;/span&gt; and the fill rate &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is found by solving the fill rate constraint?&lt;/p&gt;&#xA;" OwnerUserId="4743" LastEditorUserId="123" LastEditDate="2021-01-24T10:15:31.580" LastActivityDate="2021-11-22T10:39:55.467" Title="Safety Stock with Fill Rate Criterion" Tags="|inventory|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5590" PostTypeId="2" ParentId="5589" CreationDate="2021-01-24T11:13:40.517" Score="2" Body="&lt;p&gt;We can work from scratch. Rearrange &lt;span class=&quot;math-container&quot;&gt;$\beta=1-n(S)/\mu$&lt;/span&gt; to get &lt;span class=&quot;math-container&quot;&gt;$$-\frac{\mu\sqrt{2\pi}}\sigma(\beta-1)=e^{-z^2/2}-z\sqrt{2\pi}+z\int_{-\infty}^ze^{-t^2/2}\,dt$$&lt;/span&gt; on using &lt;span class=&quot;math-container&quot;&gt;${\cal L}(z)=\phi(z)-z(1-\Phi(z))$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\Phi'(z)=\phi(z)=e^{-z^2/2}/\sqrt{2\pi}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To determine the inverse asymptotic behaviour as &lt;span class=&quot;math-container&quot;&gt;$\beta\to1^-$&lt;/span&gt;, we now expand the integral term about infinity to obtain the Laurent series of &lt;span class=&quot;math-container&quot;&gt;$\Phi$&lt;/span&gt;, which is possible by &lt;a href=&quot;https://math.stackexchange.com/a/2862937/471884&quot;&gt;expanding the reciprocal about zero&lt;/a&gt;. This gives &lt;span class=&quot;math-container&quot;&gt;\begin{align}y:=\frac{\mu\sqrt{2\pi}}\sigma(1-\beta)&amp;amp;=-e^{-z^2/2}\sum_{n=1}^\infty\frac{(-1)^n(2n-1)!!}{z^{2n}},\end{align}&lt;/span&gt; where for simplicity, we can cut the sum at the first term as &lt;span class=&quot;math-container&quot;&gt;$\mathcal O(1/z^4)$&lt;/span&gt; decays much faster than &lt;span class=&quot;math-container&quot;&gt;$1/z^2$&lt;/span&gt;. Thus the RHS can be approximated as &lt;span class=&quot;math-container&quot;&gt;$f(z)=e^{-z^2/2}/z^2$&lt;/span&gt; with inverse &lt;span class=&quot;math-container&quot;&gt;$$f^{-1}(z)=\sqrt{2W\left(\frac1{2z}\right)}$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is the Lambert &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; function. This can be reduced to elementary functions through the asymptotic &lt;span class=&quot;math-container&quot;&gt;$W(z)\sim\log z-\log\log z+o(1)$&lt;/span&gt;, so the safety stock is asymptotically equal to &lt;span class=&quot;math-container&quot;&gt;$$\textsf{SS}=z\sigma\sim\sigma\sqrt{2\log\left(\frac\sigma{2\mu\sqrt{2\pi}(1-\beta)}\right)-2\log\log\left(\frac\sigma{2\mu\sqrt{2\pi}(1-\beta)}\right)}$$&lt;/span&gt; which indeed tends to infinity as &lt;span class=&quot;math-container&quot;&gt;$\beta\to1^-$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2021-11-22T10:39:55.467" LastActivityDate="2021-11-22T10:39:55.467" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5591" PostTypeId="2" ParentId="5589" CreationDate="2021-01-24T18:35:48.227" Score="1" Body="&lt;p&gt;You can solve:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta = 1-\frac{n(S)}{\mu}$&lt;/span&gt; wrt &lt;span class=&quot;math-container&quot;&gt;$\mathcal{L}(z) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which gives you:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\mathcal{L}(z) = \frac{\mu\times(1-\beta)}{\sigma}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then there is a a good approximation function (don't have the specific reference to it) that can convert &lt;span class=&quot;math-container&quot;&gt;$\mathcal{L}(z)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$z = 4.85-\mathcal{L}(z)^{1.3}\times0.3924-\mathcal{L}(z)^{0.135}\times 5.359 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then the safety stock can be found as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ss = \sigma \times z $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; or fill rate &lt;span class=&quot;math-container&quot;&gt;$= 0.98$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sigma = 5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu=30$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\mathcal{L}(z) = \frac{30\times(1-0.98)}{5}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\mathcal{L}(z) \approx 0.12$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$z = 4.85-0.12^{1.3}\times0.3924-0.12^{0.135}\times 5.359$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ z \approx  0.8 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$safety\space stock = 5\times 0.8 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\approx4$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2021-01-24T18:56:08.250" LastActivityDate="2021-01-24T18:56:08.250" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5592" PostTypeId="1" AcceptedAnswerId="5601" CreationDate="2021-01-24T20:17:12.837" Score="11" ViewCount="1117" Body="&lt;p&gt;In the machine learning community there is the big topic of explainability, where you want to make the solution of ML models explainable or derive explainable models.&lt;/p&gt;&#xA;&lt;p&gt;This is also interesting for optimization, because the stakeholders sometimes want to know why the solution is optimal and this is not easy to explain.&lt;/p&gt;&#xA;&lt;p&gt;What are approaches to this? Are there papers on this in the context of optimization?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="279" LastEditDate="2021-01-25T14:05:54.770" LastActivityDate="2021-02-12T04:45:26.367" Title="Are there explainability approaches in optimization?" Tags="|integer-programming|reference-request|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5593" PostTypeId="1" AcceptedAnswerId="5594" CreationDate="2021-01-24T20:18:03.480" Score="3" ViewCount="262" Body="&lt;p&gt;Is there a difference between logical and combinatorial Benders Decomposition and the cutting plane method?&lt;/p&gt;&#xA;&lt;p&gt;My understanding is that for all of these techniques, there is a MIP and based on solutions to the problem new constraints are generated and added to the problem until the solution is optimal. Are these just different names for the same technique or is there real difference?&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="2477" LastEditDate="2021-01-24T22:20:51.220" LastActivityDate="2021-01-24T22:46:56.807" Title="Logical / combinatorial Benders Decomposition vs Cutting plane method" Tags="|benders-decomposition|terminology|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5594" PostTypeId="2" ParentId="5593" CreationDate="2021-01-24T22:46:56.807" Score="6" Body="&lt;p&gt;I'm going to assume that &amp;quot;the cutting plane method&amp;quot; refers to branch and cut (branch and bound with cuts added at the root and possibly other nodes), as opposed to older cutting plane algorithms that relied exclusively on adding cuts to the LP relaxation (no branching).&lt;/p&gt;&#xA;&lt;p&gt;I would consider branch and cut different from logical or combinatorial Benders (or original Benders, for that matter), because in branch and cut the cuts are derived from the structure/properties of the master problem, while Benders cuts are derived from a different problem. (Note that solvers used on the Benders master problem will also generate non-Benders cuts.)&lt;/p&gt;&#xA;&lt;p&gt;Now it's fair to ask whether Benders cuts are different from the cuts you would get if you did not use Benders decomposition and solved a single (larger) MIP model. For &amp;quot;traditional&amp;quot; Benders, I don't think a solver attacking the combined problem would generate those particular cuts, but I'm not positive. For logical/combinatorial Benders, I would say no, for either of two reasons. In some cases, the Benders decomposition is letting you avoid big-M constraints, so the original MIP is not just the merger of the master and subproblems in combinatorial Benders, but is structurally somewhat different.&lt;/p&gt;&#xA;&lt;p&gt;Also, depending on how you interpret &amp;quot;combinatorial Benders&amp;quot; and &amp;quot;logical Benders&amp;quot;, there are versions of them in which the subproblem is not an LP and possibly not even a MIP. It's some external problem that somehow coughs up a linear constraint when the master problem solution is not to its liking. Those constraints would not occur as one of the standard types of cuts supported by the MIP solver, and in any case the non-LP/non-MIP nature of the subproblem might prevent having a single MIP model at all.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-01-24T22:46:56.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5595" PostTypeId="1" CreationDate="2021-01-25T01:37:46.583" Score="3" ViewCount="131" Body="&lt;p&gt;I am working on a nonlinear scheduling problem that minimizes the electricity cost of a facility. This system includes a number of identical machines that consume power and produce a product. When the product demanded by these machines is low (i.e. near the low bound for one machine) this causes an infeasibility. I think this is occurring because in reality only one machine should be on, but the way I have the problem written, mathematically this decision is impossible to reach. In general what is the best way to model identical equipment?&lt;/p&gt;&#xA;&lt;p&gt;I could make one machine just slightly more efficient than the other...but that's not ideal. Is there a more elegant way to handle this?&lt;/p&gt;&#xA;" OwnerUserId="4806" LastEditorUserId="491" LastEditDate="2021-01-25T16:05:40.360" LastActivityDate="2021-01-25T22:23:43.507" Title="Scheduling Problem With Identical Machines" Tags="|nonlinear-programming|scheduling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5596" PostTypeId="1" CreationDate="2021-01-25T04:05:43.920" Score="9" ViewCount="1009" Body="&lt;p&gt;Is there any book about the history of linear programming? I would like to know more about the persons involved in the beginning of the field. I know about Kantorovich, Dantzig and Von Neumann, but I'm searching for a book that organizes the history in a chronological narrative and reports about the people involved but not as famous as the previous three.&lt;/p&gt;&#xA;" OwnerUserId="4817" LastActivityDate="2021-01-25T04:55:38.773" Title="Is there a book about the history of linear programming?" Tags="|books|history|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5598" PostTypeId="2" ParentId="5596" CreationDate="2021-01-25T04:55:38.773" Score="9" Body="&lt;p&gt;I suggest having a look at the following book:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.zib.de/groetschel/publications/OptimizationStories.pdf&quot; rel=&quot;noreferrer&quot;&gt;Grötschel, M. (Ed.). (2012). Optimization stories. Dt. Mathematiker-Vereinigung.&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The book has a number of chapters and in particular a chapter titled &amp;quot;Linear Programming Stories&amp;quot; which can interest you.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2021-01-25T04:55:38.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5599" PostTypeId="2" ParentId="5595" CreationDate="2021-01-25T05:40:19.443" Score="2" Body="&lt;p&gt;As per you mentioned, your problem divided into two parts. The first is, related to the power system optimization and the second is about machinery scheduling system. I don't know, how do you formulate the first one, (linear or non-linear) but, the second one can be represented as the mixed-integer programming as well. Also, other techniques such as CP would be useful. For scheduling your plant, some things would be considered:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If your plant optimization problem is medium/large scale, it is convenient to use LP/MILP instead of NLP/MINLP. (defiantly, if it is possible).&lt;/li&gt;&#xA;&lt;li&gt;It is important to identify, which kind of machinery system you have faced? (e.g. single/parallel machine, shopping family, etc). Based on the problem in hand, you can develop an appropriate solution to that.&lt;/li&gt;&#xA;&lt;li&gt;If you are interested to optimize more than one objective function, for example, minimizing power-consuming versus minimizing the number of tardy jobs simultaneously, you would like to use multi-objective optimization.&lt;/li&gt;&#xA;&lt;li&gt;If you have encountered to probability/noisy data, the stochastic/robust optimization can be applied.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Finally, there are many related resources, software, etc which you could use them to solve your problem but, what the most important is, how do you define your problem and its specifications?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-01-25T05:40:19.443" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5600" PostTypeId="2" ParentId="5592" CreationDate="2021-01-25T08:24:15.080" Score="7" Body="&lt;p&gt;In my view, mathematical optimization is inherently explainable for various reasons:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The model is &amp;quot;white-box&amp;quot;, i.e. it is developed by a person defining all the variables and constraints. This means that if a certain constraint is active or inactive, there is a logical conclusion that can be drawn from this.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The result is, as you say, provably optimal. One can explain how to get there; I like to use the example of Google Maps, where the lower bound is the speed &amp;quot;as the crow flies&amp;quot;, and then the actual solution is taking the highway, which is a little bit slower. By getting these things close to each other you can prove that something cannot be done better. In my book, this means I can explain it.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Using the values of the dual variables at the optimal solution you can explain how the objective function would change if one was to move in one direction or another away from the optimal solution; the dual variables are sometimes interpreted as the derivatives of the objective function along that particular constraint. In fact, even for a mixed-integer program, you could fix the discrete components and visualize this effect for the continuous variables. This &amp;quot;post-optimal&amp;quot; analysis, as it is sometimes called, is readily available and comes naturally out of the theory of mathematical optimization.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="133" LastActivityDate="2021-01-25T08:24:15.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5601" PostTypeId="2" ParentId="5592" CreationDate="2021-01-25T09:07:09.487" Score="8" Body="&lt;h2&gt;Solving: why is this solution optimal?&lt;/h2&gt;&#xA;&lt;p&gt;As Richard explained, the objective in OR is not &amp;quot;fuzzy&amp;quot; like in ML: we assume an objective that can be evaluated by the computer. Once the problem is specified, there is not much to explain: you can prove optimality or infeasibility directly.&lt;/p&gt;&#xA;&lt;p&gt;Many solution methods attempt to prove optimality, and it is possible to get an optimality (or infeasibility) certificate from the solution process. This is trivial for LPs, and well known for SAT and MILP problem (see &lt;a href=&quot;https://arxiv.org/pdf/1611.08832.pdf&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt; for more information). When using heuristics you are out of luck, but can still compare the results to bounds obtained with other methods.&lt;/p&gt;&#xA;&lt;h2&gt;Modeling: what is a good solution?&lt;/h2&gt;&#xA;&lt;p&gt;But you asked &lt;em&gt;how to explain the solutions to stakeholders&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Before you solve the problem, you have to model it in a way that matches the stakeholders' expectation of a good solution. The difficulty here is to specify what a good solution is. The stakeholders have domain knowledge that you don't, and many conflicting objectives.&#xA;The goal is to &lt;em&gt;specify&lt;/em&gt; the model with them so that they can understand the solutions: this is a matter of engineering and communication.&lt;/p&gt;&#xA;&lt;p&gt;I suggest the answer to &lt;a href=&quot;https://or.stackexchange.com/questions/2953/what-are-the-reasons-or-industry-projects-fail&quot;&gt;this question about OR industry projects&lt;/a&gt; for a better view of the issues at hand.&lt;/p&gt;&#xA;&lt;h3&gt;An example&lt;/h3&gt;&#xA;&lt;p&gt;The stakeholders may ask the OR team:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;We want to minimize costs and downtime at our factory&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is not explainable: how do you compare a solution with 1 hour downtime and 100k cost, and one with 10 hours downtime and 20k cost? So the OR team will lead them to more explainable specifications.&lt;/p&gt;&#xA;&lt;p&gt;For example, by ordering the objectives:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;We want less than one hour of downtime if possible, and otherwise want to minimize the cost&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Or by providing a conversion factor:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;We can allow some downtime, if it saves at least 20k per hour&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In both cases, it is easy to see which solution is better.&lt;/p&gt;&#xA;&lt;h3&gt;In practice&lt;/h3&gt;&#xA;&lt;p&gt;In practice, the stakeholders will have an idea of what a good solution looks like, but it will not always be easy to explain: they know it when they see it!&lt;/p&gt;&#xA;&lt;p&gt;The task of the OR practitioners is to turn this domain knowledge into a model. A good way is to look at solutions with them, and understanding how they rank them. From there, it is generally possible to come up with an ordering of the objectives, or conversion factors, that they can agree with.&lt;/p&gt;&#xA;&lt;p&gt;Just like in ML, it builds trust in the model when you can explain it, and is crucial for tool adoption. Compared to ML, the explanation stems from the specification, and is generally easy to understand for everyone involved.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2021-01-25T09:07:09.487" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5602" PostTypeId="1" CreationDate="2021-01-25T12:11:32.510" Score="2" ViewCount="278" Body="&lt;p&gt;I am trying to solve the following problem using Network Simplex method. But I have questions.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BxO1Z.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BxO1Z.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My attempt:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Basis Matrix&lt;span class=&quot;math-container&quot;&gt;$(B)$&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Rows: 1, 2, 3, 4, 5&lt;/p&gt;&#xA;&lt;p&gt;Column: (1,3) (1,4) (1,5) (2,3) (2,4) (2,5)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;    \begin{bmatrix}&#xA;     1&amp;amp;1&amp;amp;1&amp;amp;0&amp;amp;0&amp;amp;0  \\&#xA;     0&amp;amp;0&amp;amp;0&amp;amp;1&amp;amp;1&amp;amp;1\\&#xA;     -1&amp;amp;0&amp;amp;0&amp;amp;-1&amp;amp;0&amp;amp;0\\&#xA;     0&amp;amp;-1&amp;amp;0&amp;amp;0&amp;amp;-1&amp;amp;0\\&#xA;     0&amp;amp;0&amp;amp;-1&amp;amp;0&amp;amp;0&amp;amp;-1&#xA;\\&#xA;    \end{bmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Vector of basic variables&lt;span class=&quot;math-container&quot;&gt;$(x_B)$&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;    \begin{bmatrix}&#xA;     x_{13}  \\&#xA;     x_{14}\\&#xA;     x_{15}\\&#xA;     x_{23}\\&#xA;     x_{24}\\&#xA;     x_{25}&#xA;\\&#xA;    \end{bmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I couldn't be sure where to add the root arc both on the matrix and the graph. I guess I need to add 2 root arcs, but where do I add them?&lt;/p&gt;&#xA;&lt;p&gt;To solve the problem I need to solve the &lt;span class=&quot;math-container&quot;&gt;$B*x_B=b$&lt;/span&gt; equality where &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is basis, &lt;span class=&quot;math-container&quot;&gt;$x_B$&lt;/span&gt; is the vector of basis variables(consists of the arcs) and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is the capacities. I also couldn't find a way to represent the basis variables.&lt;/p&gt;&#xA;" OwnerUserId="4647" LastEditorUserId="123" LastEditDate="2021-02-25T07:57:24.137" LastActivityDate="2021-02-25T07:57:24.137" Title="Solving transportation problem by the Network Simplex" Tags="|optimization|linear-programming|network-flow|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5603" PostTypeId="1" CreationDate="2021-01-25T17:39:12.333" Score="7" ViewCount="120" Body="&lt;p&gt;Assume we have a simple resource allocation problem, where all players have the same cost, but a different utility &lt;span class=&quot;math-container&quot;&gt;$a_s$&lt;/span&gt;. The resources assigned to a certain player must be between &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. Moreover, we add a proportion constraint. That is, each player &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is assumed to contribute a percentage of &lt;span class=&quot;math-container&quot;&gt;$p_s$&lt;/span&gt; of his utility to a goal that we require to be at least &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; % of the total utility. We assume that these quantities are inversely related, that is: players with a large utility, have a small &lt;span class=&quot;math-container&quot;&gt;$p_s$&lt;/span&gt;. The problem is formulated as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;     z_{BP}=\max \quad &amp;amp; \sum_{s \in \mathcal{S}} a_{s} \cdot y_{s} &amp;amp; \\&#xA;    \text{s.t.} \quad     &amp;amp; \sum_{s \in \mathcal{S}}y_s = R &amp;amp; \\&#xA;   &amp;amp;   \sum_{s \in \mathcal{S}} a_{s} \cdot y_{s}\cdot p_s \geq \sum_{s \in \mathcal{S}} a_{s} \cdot y_{s}\cdot P  \\&#xA;    &amp;amp; L \leq y_s \leq M &amp;amp; \forall s \in \mathcal{S}&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$y_s$&lt;/span&gt; is the decision variable deciding the amount of resources assigned to player &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We use Lagrangian relaxation to relax the difficult constraints, i.e. the constraint prescribing the minimum proportion of utilities. We are left with a simple knapsack problem, where we can just select the players with the highest score (utility corrected for constraint violation).&lt;/p&gt;&#xA;&lt;p&gt;I was wondering whether there would be a way to estimate the Lagrange multiplier given the instance, without solving the problem and without using subgradient optimization. As the optimal solution without the proportion constraint is trivial, I suspect that there should be a way to estimate the 'price' of the constraint. For example by comparing the number of players with &lt;span class=&quot;math-container&quot;&gt;$p_s \geq P$&lt;/span&gt; and the number of players with  &lt;span class=&quot;math-container&quot;&gt;$p_s &amp;lt; P$&lt;/span&gt;, or the sum &lt;span class=&quot;math-container&quot;&gt;$\sum_{s \in \mathcal{S}:p_s &amp;lt; P} a_s$&lt;/span&gt; and the sum &lt;span class=&quot;math-container&quot;&gt;$\sum_{s \in \mathcal{S}:p_s \geq P} a_s$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4820" LastEditorUserId="4820" LastEditDate="2021-01-26T08:10:15.003" LastActivityDate="2021-01-26T08:10:15.003" Title="Estimate lagrangian multiplier based on instance characteristics" Tags="|duality|knapsack|lagrangian-relaxation|lagrange-multipliers|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5604" PostTypeId="2" ParentId="5595" CreationDate="2021-01-25T22:23:43.507" Score="2" Body="&lt;p&gt;It's hard to answer this without knowing more about your model. Let's say that you have variables for the quantity produced on each machine (say, &lt;span class=&quot;math-container&quot;&gt;$x_m$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$m\in\lbrace 1,\dots, M\rbrace$&lt;/span&gt; indexes the machine). It sounds as if there is a nonzero lower bound &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; for the output of a machine &lt;em&gt;when it is running&lt;/em&gt;. Rather than say &lt;span class=&quot;math-container&quot;&gt;$x_m \ge L\,\, \forall m$&lt;/span&gt;, what you need is binary variables &lt;span class=&quot;math-container&quot;&gt;$y_m$&lt;/span&gt; (1 if machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is used, 0 if not) with the constraint &lt;span class=&quot;math-container&quot;&gt;$x_m \ge L y_m \,\, \forall m$&lt;/span&gt;. Introducing binary variables makes the model harder to solve, but if you have a nonzero lower limit on output for running machines and at the same time do not require every machine to be used, I think that is unavoidable.&lt;/p&gt;&#xA;&lt;p&gt;Also, since the machines are identical, you could arbitrarily impose the constraints &lt;span class=&quot;math-container&quot;&gt;$x_1\ge x_2 \ge \dots \ge x_M$&lt;/span&gt;. This would eliminate some symmetry in your model.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-01-25T22:23:43.507" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5605" PostTypeId="1" CreationDate="2021-01-26T11:19:45.863" Score="3" ViewCount="286" Body="&lt;p&gt;I am trying to solve the multi-objective function of my linear program. Are there another approaches other than the weighted sum approximation?&lt;/p&gt;&#xA;" OwnerUserId="4850" LastEditorUserId="123" LastEditDate="2021-01-27T08:14:44.703" LastActivityDate="2021-02-05T19:03:08.603" Title="Multi-objective function normalization" Tags="|linear-programming|multi-objective-optimization|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5606" PostTypeId="5" CreationDate="2021-01-26T14:09:37.650" Score="0" Body="&lt;p&gt;Solver related questions are answered also by the SCIP development team. You can obtain the code and documentation at scipopt.org.&lt;/p&gt;&#xA;" OwnerUserId="354" LastEditorUserId="354" LastEditDate="2021-01-26T14:09:37.650" LastActivityDate="2021-01-26T14:09:37.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5607" PostTypeId="4" CreationDate="2021-01-26T14:09:37.650" Score="0" Body="SCIP is a source-open solver for (among others) MILPs, MINLPs, ... ask questions about usage, bugs, interfaces, behavior." OwnerUserId="354" LastEditorUserId="354" LastEditDate="2021-01-26T14:09:37.650" LastActivityDate="2021-01-26T14:09:37.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5608" PostTypeId="2" ParentId="4015" CreationDate="2021-01-26T15:29:45.460" Score="4" Body="&lt;p&gt;Accepted answer from the cross-post: &lt;a href=&quot;https://stackoverflow.com/q/61522580/8239061&quot;&gt;Stop Branch-and-Price tree and return gap&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;You can easily compute this yourself: &lt;code&gt;SCIPgetDualbound&lt;/code&gt; will return you&#xA;the best (global) dual bound, and &lt;code&gt;SCPgetPrimalbound&lt;/code&gt; will give you the&#xA;best primal bound.    -&lt;a href=&quot;https://stackoverflow.com/users/11158393/leon&quot;&gt;Leon&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;sub&gt;Will delete this CW if &lt;a href=&quot;https://stackoverflow.com/users/11158393/leon&quot;&gt;Leon&lt;/a&gt; posts answer here.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="491" LastActivityDate="2021-01-26T15:29:45.460" CommentCount="0" CommunityOwnedDate="2021-01-26T15:29:45.460" ContentLicense="CC BY-SA 4.0" />
  <row Id="5609" PostTypeId="1" AcceptedAnswerId="5610" CreationDate="2021-01-26T15:47:31.380" Score="0" ViewCount="281" Body="&lt;p&gt;I have the following question. I want to clarify couple of points.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n9HmO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n9HmO.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you can see, total demand and total supply does not match, we do not have enough demand. What I want to ask is:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Do we need to add a slack node to provide that gap? If yes, would adding one slack node be enough? I mean, if we had a gap in supply I believe we had to, but for this case, I could not be sure.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If we add a slack node, what cost value we assign for the arc that carries the &amp;quot;needed&amp;quot; supply/demand?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Does adding a slack node change anything about the other arcs, do we need to remake our calculations?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I am asking for both insufficient demand and supply cases.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;My attempt:&lt;/em&gt;&#xA;I am not very sure about my model as I couldn't figure out how the slack node should be but, I thought &lt;span class=&quot;math-container&quot;&gt;$x_{12}=3$&lt;/span&gt; , &lt;span class=&quot;math-container&quot;&gt;$x_{24}=4$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{32}=2$&lt;/span&gt;. (&lt;span class=&quot;math-container&quot;&gt;$x_{ij}=$&lt;/span&gt;flow from node i to node j). &lt;span class=&quot;math-container&quot;&gt;$z=15$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Linear program I created is as follows:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Min$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$x_{12}+3x_{13}+4x_{24}-2x_{32}+3x_{34}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s.t$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$x_{12}+x_{34}=4$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$-x_{12}+x_{24}=-1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{13}-x_{32}-x_{34}=2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{24}+x_{34}=-4$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4647" LastEditorUserId="4647" LastEditDate="2021-01-26T21:09:15.393" LastActivityDate="2021-01-26T21:11:55.177" Title="Adding slack nodes to min cost network flows" Tags="|optimization|linear-programming|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5610" PostTypeId="2" ParentId="5609" CreationDate="2021-01-26T21:11:55.177" Score="5" Body="&lt;p&gt;Whether you need a dummy node to absorb excess flow depends on the method you are using for solving the problem. (For instance, if you are using an LP model then you do not need the dummy node.) If you do need it, one dummy node will suffice. You assign it demand = excess supply and run a zero-cost arc from each supply node to the dummy node. No other changes to the network are required.&lt;/p&gt;&#xA;&lt;p&gt;For the excess demand case, you can do the same with a single dummy supply node (supply = excess demand) and zero cost arcs to the various demand nodes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;: The above works if there is no cost for excess supply / unmet demand or the cost of excess supply / unmet demand is constant regardless of where it occurs. That's not awesomely realistic. If excess supply is stored or disposed of, and that cost varies by supply node, then you still only need one dummy demand node, but the cost of the arc from each supply node to the dummy should equal the unit storage/disposal cost at that supply node. The case of customer-specific shortfall costs when demand exceeds supply is analogous: one dummy supply node but with the cost of the arc to each demand node equal to the unit shortfall cost.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-01-26T21:11:55.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5611" PostTypeId="2" ParentId="3883" CreationDate="2021-01-27T02:28:03.320" Score="2" Body="&lt;p&gt;Don't get hung up on having to use Excel - many off-the-shelf software packages don't even begin to address the issues job shops have. Excel is a great way to experiment and develop a system that works without spending a small fortune in the process.&lt;/p&gt;&#xA;&lt;p&gt;Speaking of the process, it is often useful to apply the Theory of Constraints to your business, and use it as the framework for planning.  Here are some other ideas that might help:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.jobshopleanmanufacturing.com/heijunka.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Heijunka&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.jobshopleanmanufacturing.com/product-mix-control-chart.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Product Mix Control Chart&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.jobshopleanmanufacturing.com/production-tracker-gantt-chart.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Production Tracker Gantt Chart&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4856" LastEditorUserId="123" LastEditDate="2021-01-27T08:28:35.620" LastActivityDate="2021-01-27T08:28:35.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5612" PostTypeId="1" AcceptedAnswerId="5613" CreationDate="2021-01-27T02:37:22.370" Score="7" ViewCount="738" Body="&lt;p&gt;Given the following problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;P: \min_{x,y}&amp;amp;\quad c^\top x+f^\top y\\&#xA;\text{s.t.}&amp;amp;\quad Ax+By=b\\&#xA;&amp;amp;\quad y\in Y\\&#xA;&amp;amp;\quad x\geq 0&#xA;\end{align}&lt;/span&gt;&#xA;Problem &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is equivalent to:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;P': \min_{y}&amp;amp;\quad f^\top y+S(y)\\&#xA;\text{s.t.}&amp;amp;\quad y\in Y\\&#xA;\end{align}&lt;/span&gt;&#xA;with&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;S(y):\min_{x}&amp;amp;\quad c^\top x\\&#xA;\text{s.t.}&amp;amp;\quad Ax=b-By\\&#xA;&amp;amp;\quad x\geq 0&#xA;\end{align}&lt;/span&gt;&#xA;The dual &lt;span class=&quot;math-container&quot;&gt;$\operatorname{SD}(y)$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$S(y)$&lt;/span&gt; is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\operatorname{SD}(y): \max_{u}&amp;amp;\quad(b-By)^\top u\\&#xA;\text{s.t.}&amp;amp;\quad A^\top u\leq c\\&#xA;&amp;amp;\quad u\mbox{ unrestricted}&#xA;\end{align}&lt;/span&gt;&#xA;Through classical Benders decomposition, problem &lt;span class=&quot;math-container&quot;&gt;$P'$&lt;/span&gt; can be reformulated as:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;Q:\min_{y}&amp;amp;\quad f^\top y+z&amp;amp;\\&#xA;\text{s.t.}&amp;amp;\quad(\alpha^r_j)^\top(b-By)\leq 0&amp;amp;\forall j\in 1,\dots,J\\&#xA;&amp;amp;\quad(\alpha^p_i)^\top(b-By)\leq z&amp;amp;\forall i\in 1,\dots,I\\&#xA;&amp;amp;\quad y\in Y\\&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; are respectively the set of extreme points and the set of extreme rays defining the feasible space of &lt;span class=&quot;math-container&quot;&gt;$\operatorname{SD}(y)$&lt;/span&gt;. Since &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; can be extremely large, the Benders decomposition algorithm iteratively solves a problem &lt;span class=&quot;math-container&quot;&gt;$Q'$&lt;/span&gt; which is identical to &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; but where the sets &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; are replaced by &lt;span class=&quot;math-container&quot;&gt;$I'\subseteq I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J'\subseteq J$&lt;/span&gt;. During every iteration of the algorithm, additional optimality and feasibility cuts are separated and added to &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; respectively.&lt;/p&gt;&#xA;&lt;p&gt;The Classical Benders decomposition algorithm iteratively solves problem &lt;span class=&quot;math-container&quot;&gt;$Q'$&lt;/span&gt;, thereby obtaining a solution &lt;span class=&quot;math-container&quot;&gt;$\bar{y}$&lt;/span&gt;, and problem &lt;span class=&quot;math-container&quot;&gt;$\operatorname{SD}(\bar{y})$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Case 1: If &lt;span class=&quot;math-container&quot;&gt;$Q'$&lt;/span&gt; is infeasible, then &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; must be infeasible. If &lt;span class=&quot;math-container&quot;&gt;$Q'$&lt;/span&gt; is unbounded (objective is &lt;span class=&quot;math-container&quot;&gt;$-\infty$&lt;/span&gt;) then &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is unbounded.&lt;/li&gt;&#xA;&lt;li&gt;Case 2: If &lt;span class=&quot;math-container&quot;&gt;$\operatorname{SD}(y)$&lt;/span&gt; is infeasible, then &lt;span class=&quot;math-container&quot;&gt;$S(y)$&lt;/span&gt; must be unbounded for some &lt;span class=&quot;math-container&quot;&gt;$\hat{y}\in Y$&lt;/span&gt; or infeasible for all &lt;span class=&quot;math-container&quot;&gt;$y\in Y$&lt;/span&gt;. By extension, &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; must be unbounded or infeasible.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;how to efficiently determine which of the two possible cases we ran into: unbounded or infeasible?&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Case 3: If &lt;span class=&quot;math-container&quot;&gt;$\operatorname{SD}(\bar{y})$&lt;/span&gt; is feasible and bounded for some &lt;span class=&quot;math-container&quot;&gt;$\bar{y}\in Y$&lt;/span&gt;, optimality cut &lt;span class=&quot;math-container&quot;&gt;$\bar{u}^\top(b-By)\leq z$&lt;/span&gt; is added to &lt;span class=&quot;math-container&quot;&gt;$I'$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\bar{u}$&lt;/span&gt; is the optimal solution to &lt;span class=&quot;math-container&quot;&gt;$\operatorname{SD}(\bar{y})$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Case 4: If &lt;span class=&quot;math-container&quot;&gt;$\operatorname{SD}(\bar{y})$&lt;/span&gt; is feasible and unbounded for some &lt;span class=&quot;math-container&quot;&gt;$\bar{y}\in Y$&lt;/span&gt;, there exists an extreme ray &lt;span class=&quot;math-container&quot;&gt;$\alpha^r$&lt;/span&gt; s.t. &lt;span class=&quot;math-container&quot;&gt;$\alpha^r(b-B\bar{y})&amp;gt;0$&lt;/span&gt;. Feasibility cut &lt;span class=&quot;math-container&quot;&gt;$(\alpha^r)^\top(b-By)\leq 0$&lt;/span&gt; is added to &lt;span class=&quot;math-container&quot;&gt;$J'$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For Case 4, we need to determine an extreme ray &lt;span class=&quot;math-container&quot;&gt;$\alpha^r$&lt;/span&gt;. Since the recession cone &lt;span class=&quot;math-container&quot;&gt;$\operatorname{rec}(\operatorname{SD}(y))$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$\operatorname{SD}(y)$&lt;/span&gt; is given by &lt;span class=&quot;math-container&quot;&gt;$\operatorname{rec}(\operatorname{SD}(y))=\{u\in R^{n} \mid A^\top u\leq 0\}$&lt;/span&gt;, we can solve the optimization problem &lt;span class=&quot;math-container&quot;&gt;$\operatorname{ray}(y)$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\operatorname{ray}(y): \max_{u}&amp;amp;\quad(b-By)^\top u\\&#xA;\text{s.t.}&amp;amp;\quad(b-By)^\top u = 1\\&#xA;&amp;amp;\quad A^\top u\leq 0\\&#xA;&amp;amp;\quad u\mbox{ unrestricted}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;To find the extreme ray, I presume that an actual implementation does not solve an LP like &lt;span class=&quot;math-container&quot;&gt;$\operatorname{ray}(y)$&lt;/span&gt;, but derives the ray directly from the information in the simplex tableau when solving &lt;span class=&quot;math-container&quot;&gt;$S(y)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\operatorname{SD}(y)$&lt;/span&gt;?&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;From a computational perspective, when solving the subproblem, is there an advantage to solving &lt;span class=&quot;math-container&quot;&gt;$S(y)$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$\operatorname{SD}(y)$&lt;/span&gt;? Is there a preferred algorithm (e.g. primal simplex/dual simplex/..)?&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;When embedding the Benders decomposition in a branch-and-bound search, when do you typically solve the subproblem (best practice)? (1) only at the integer nodes, (2) at all nodes (both fractional and integer), or (3) typically at the root node and at every integer node.&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Each time subproblem &lt;span class=&quot;math-container&quot;&gt;$\operatorname{SD}(\bar{y})$&lt;/span&gt; is solved, do you generate a single cut, or multiple? E.g. there can exist multiple extreme points or rays.&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="49" LastEditorUserId="123" LastEditDate="2021-01-27T08:25:41.773" LastActivityDate="2021-01-27T08:25:41.773" Title="Classical Benders decomposition algorithm implementation details" Tags="|benders-decomposition|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5613" PostTypeId="2" ParentId="5612" CreationDate="2021-01-27T04:51:49.440" Score="7" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Yes, there is no need to solve () to obtain an extreme ray as you mentioned. In CPLEX, for example, you can use a method called getRay &lt;a href=&quot;https://www.ibm.com/support/pages/how-obtain-extreme-ray-when-lp-unbounded&quot; rel=&quot;noreferrer&quot;&gt;(see here)&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can solve the primal problem using a suitable algorithm (primal simplex, dual simplex, etc, whichever is faster for your problem) and then get the dual values (&lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_20.1.0/ilog.odms.cplex.help/refcppcplex/html/classes/IloCplex.html#method_getDual&quot; rel=&quot;noreferrer&quot;&gt;using getDual or getDuals&lt;/a&gt;), or you can solve the dual problem directly. It is important to note that the dual values you get from the two approaches can be different. In a numerical study, I observed that hundreds of instances of a problem are solved at least twice faster if the dual values are obtained from solving the dual problem directly. But the reverse can also happen depending on the problem. So this should be checked. The reason is that different dual values can result in different cuts, and in the afformentioned case, the quality of the cuts obtained where quite different.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In the cases I have seen, the first approach (solving only at the integer nodes) has been a better option. Having said that, you can take a two-phase approach to accelerate the Benders decomposition approach: In the first phase, you solve the LP-relaxation of the problem by a cutting plane approach (i.e., the clasical implementation of Benders decomposition where at each iteration cuts are added to remove the optimal solution of the LP in the previous iteration). Once the LP-relaxation is solved, you keep the generated Benders cuts in the master problem and proceed with the modern implementation of Benders decomposition (I borrowed the word 'modern' from the keynote presentation of Matteo Fischetti in ISMP2018).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you can generate multiple (different) cuts then you can examine whether it is good to add them all or only a subset of them. The multi-cut version of Benders decomposition is usually considered as an improvement technique. Note that the single-cut version of the algorithm can actually outperform the multi-cut version (see e.g., &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/mnsc.2016.2455&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2021-01-27T04:51:49.440" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5614" PostTypeId="1" AcceptedAnswerId="5615" CreationDate="2021-01-27T05:03:37.617" Score="2" ViewCount="394" Body="&lt;p&gt;I am currently learning how to use Gurobi for Python using their official tutorial found &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/quickstart_windows/cs_netflow_py_example.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. In this example, they appear to formulate the objective by simply specifying a cost dictionary to the &lt;code&gt;obj&lt;/code&gt; argument in &lt;code&gt;addVars&lt;/code&gt;. However, I am not sure how to formulate more complicated objectives such as the example below:&lt;/p&gt;&#xA;&lt;p&gt;I have formulated the cost to be &lt;span class=&quot;math-container&quot;&gt;$$\min\sum_{i=1}^{v}\sum_{j=1}^{w}\left[c_{ij}\sum_{k=1}^{p} x_{ijk}\right]$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; represents the fixed cost of shipping 1 unit of product from vineyard &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to winery &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}$&lt;/span&gt; represents the amount of product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; shipped from vineyard &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to winery &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The goal of this toy model is to minimize the cost of shipping while using up all the supply at the vineyards. However, I am having a hard time formulating the objective. I cannot simply use &lt;code&gt;obj=&lt;/code&gt; because the cost of shipping isn't multiplied by each individual decision variable. The tutorial does not showcase more complicated examples of constructing objectives using &lt;code&gt;obj&lt;/code&gt; argument.&lt;/p&gt;&#xA;&lt;p&gt;How can I formulate my objective properly using Gurobi in Python?&lt;/p&gt;&#xA;" OwnerUserId="3231" LastEditorUserId="3231" LastEditDate="2021-01-28T02:45:49.457" LastActivityDate="2021-01-28T02:45:49.457" Title="Formulating &quot;more complicated&quot; objectives in Python Gurobi" Tags="|optimization|python|gurobi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5615" PostTypeId="2" ParentId="5614" CreationDate="2021-01-27T06:26:43.073" Score="4" Body="&lt;pre&gt;&lt;code&gt;obj = (gb.quicksum(gb.quicksum(c[i,j]*gb.quicksum(x[i,j,k] for k in P)) for j in W) for i in V)&#xA;m.setObjective(obj, GRB.MINIMIZE)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-01-27T06:26:43.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5616" PostTypeId="1" CreationDate="2021-01-27T15:04:15.757" Score="1" ViewCount="106" Body="&lt;p&gt;I have the following problem: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad3x_1+5x_2+3x_3-2x_4+3x_5\\\text{s.t.}&amp;amp;\quad x_1+x_2+x_3+x_4\geq3\\&amp;amp;\quad3x_1+x_2+5x_3+x_4-2x_5\geq6\\&amp;amp;\quad x_1+2x_3-x_4\geq2\\&amp;amp;\quad x_1,x_2,x_3,x_4,x_5\geq0.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;My attempt:&lt;/em&gt; A hint is given that the first constraint can be taken as complicating constraint and the rest as easy constraints. Then, I thought maybe I could proceed taking the dual of last two constraints as I think it is impossible to proceed in primal. I named the dual variables as &lt;span class=&quot;math-container&quot;&gt;$w_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_2 $&lt;/span&gt;, got the following program. &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad6w_1+2w_2\\\text{s.t.}&amp;amp;\quad3w_1+w_2\leq3\\&amp;amp;\quad w_1\leq5\\&amp;amp;\quad5w_1+2w_2\leq3\\&amp;amp;\quad w_1-w_2\leq-2\\&amp;amp;\quad-2w_1\leq3\\&amp;amp;\quad w_1,w_2\geq0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I found their values as &lt;span class=&quot;math-container&quot;&gt;$w_1=3/2$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$w_2=0$&lt;/span&gt; graphically. Then I thought getting into the subproblem &lt;span class=&quot;math-container&quot;&gt;$\max\{(wA-c)x+\alpha\}$&lt;/span&gt; to use the dual values I obtained, but I don't have the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; value which corresponds to the row zero of lambda one.&lt;/p&gt;&#xA;&lt;p&gt;How do you think I should proceed?&lt;/p&gt;&#xA;" OwnerUserId="4647" LastEditorUserId="123" LastEditDate="2021-01-27T15:49:55.603" LastActivityDate="2021-01-27T15:49:55.603" Title="How to start the Dantzig-Wolfe decomposition?" Tags="|optimization|linear-programming|duality|dantzig-wolfe-decomposition|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5617" PostTypeId="1" AcceptedAnswerId="5618" CreationDate="2021-01-27T16:05:07.510" Score="4" ViewCount="230" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Given the following problem &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad x_1+2x_2+3x_3+4x_4+\sum_{i=1}^4x_i\ln(x_i)\\\text{s.t.}&amp;amp;\quad e^\top x=1\\&amp;amp;\quad x\geq0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I was asked to solved the dual problem and I think I've managed to do so, I've got &lt;span class=&quot;math-container&quot;&gt;$$q(\lambda)=-e^{-\lambda}(e^{-2}+e^{-3}+e^{-4}+e^{-5})-\lambda.$$&lt;/span&gt; I wanted to check if I'm right so I wanted to check with CVX via matlab but the following code doesn't work.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin  &#xA;variable x(4)&#xA;minimize (x(1)+2*x(2)+3*x(3)+4*x(4)+x(1)*log(x(1))+x(2)*log(x(2))+x(3)*log(x(3))+x(4)*log(x(4)))&#xA;sum(x)==1&#xA;x&amp;gt;=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How can I fix the objective function? (I know the problem is at &lt;span class=&quot;math-container&quot;&gt;$x_i\ln(x_i)$&lt;/span&gt;)&lt;/p&gt;&#xA;" OwnerUserId="4526" LastEditorUserId="123" LastEditDate="2021-01-28T07:46:47.907" LastActivityDate="2021-01-28T07:46:47.907" Title="Following code doesn't work in matlab with CVX" Tags="|convex-optimization|duality|kkt-conditions|matlab|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5618" PostTypeId="2" ParentId="5617" CreationDate="2021-01-27T16:19:01.157" Score="5" Body="&lt;p&gt;Use CVX's &lt;code&gt;entr&lt;/code&gt; function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^ 4x_i\ln(x_i)$&lt;/span&gt; can be entered as &lt;code&gt;-sum(entr(x))&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;entr   Scalar entropy.&#xA;    entr(X) returns an array of the same size as X with the unnormalized&#xA;    entropy function applied to each element:&#xA;                 { -X.*LOG(X) if X &amp;gt; 0,&#xA;       entr(X) = { 0          if X == 0,&#xA;                 { -Inf       otherwise.&#xA;    If X is a vector representing a discrete probability distribution, then&#xA;    SUM(entr(X)) returns its entropy.&#xA; &#xA;    Disciplined convex programming information:&#xA;        entr(X) is concave and nonmonotonic in X. Thus when used in CVX&#xA;        expressions, X must be real and affine. Its use will effectively &#xA;        constrain X to be nonnegative: there is no need to add an&#xA;        additional X &amp;gt;= 0 to your model in order to enforce this.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="68" LastActivityDate="2021-01-27T16:19:01.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5621" PostTypeId="1" CreationDate="2021-01-27T19:07:16.127" Score="4" ViewCount="77" Body="&lt;p&gt;Assuming that we have a linear math model with &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; bounded &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt; uncertain parameters &lt;span class=&quot;math-container&quot;&gt;$p_n$&lt;/span&gt; within a typical polyhedral budget uncertainty set that says &lt;span class=&quot;math-container&quot;&gt;$\sum_{n}{p_n} \le \Gamma$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I want to find which uncertain parameters are activated in the robustly optimal solution.&#xA;If &lt;span class=&quot;math-container&quot;&gt;$\Gamma = 0$&lt;/span&gt;, I know that none of the parameters were activated, so I recover the nominal solution. For &lt;span class=&quot;math-container&quot;&gt;$\Gamma &amp;gt; 0$&lt;/span&gt;, a robustly optimal solution will guarantee the feasibility of the solution if up to &lt;span class=&quot;math-container&quot;&gt;$\Gamma$&lt;/span&gt; uncertain parameters go to their worst case.&lt;/p&gt;&#xA;&lt;p&gt;The question is which of the parameters were activated?&lt;/p&gt;&#xA;" OwnerUserId="590" LastEditorUserId="123" LastEditDate="2021-01-28T07:44:40.330" LastActivityDate="2021-02-18T07:58:07.933" Title="Identify the specific parameters that reached their worst case in a robustly optimal solution" Tags="|robust-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5622" PostTypeId="1" AcceptedAnswerId="5637" CreationDate="2021-01-28T00:35:43.703" Score="2" ViewCount="270" Body="&lt;p&gt;I am working on a MINLP problem and am searching for a solver that works. I have tried ANTIGONE and receive the following &amp;quot;Termination Status: Infeasible Problem.&amp;quot; I also tried DICOPT which also says the problem is infeasible. I also tried BARON and though the solver never terminates on its own, the solution obtained in the local search is often never updated even after 2000+ iterations. When I inspect this solution, it appears the way I would expect an optimal solution to appear. So if I set the solver limit to run for 180 s and use the best solution up until that point, what does this solution represent? What are the risks associated with using this output?&lt;/p&gt;&#xA;&lt;p&gt;Assuming I am able to use the solution discussed above, I have another question. The purpose of this program is to inform decisions and to update based on current conditions. So even if I have a solution for a particular set of conditions, how can I feel confident it will work well under any number of conditions?&lt;/p&gt;&#xA;&lt;p&gt;And last, I am not convinced that my formulation can not be improved. I would very much appreciate any tips on improving the formulation to reduce complexity or infeasibility.&lt;/p&gt;&#xA;" OwnerUserId="4806" LastActivityDate="2021-01-30T12:48:16.217" Title="Large MINLP problem, searching for solver, tried BARON, ANTIGONE, DICOPT" Tags="|minlp|baron|local-minimum|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5623" PostTypeId="1" CreationDate="2021-01-28T15:03:32.960" Score="3" ViewCount="83" Body="&lt;p&gt;I am seeking the help  to know where I can study the job shop scheduling Heuristics or using solver&#xA;by some course/video as I see some of books and papers hard to understand .&lt;/p&gt;&#xA;&lt;p&gt;It is hoped that the course will include the update scheduling theory, algorithms, system introduction.&lt;/p&gt;&#xA;" OwnerUserId="4867" LastEditorUserId="491" LastEditDate="2022-03-03T23:14:01.397" LastActivityDate="2022-03-03T23:14:01.397" Title="Where I can study some job shop scheduling by course (video )?" Tags="|optimization|linear-programming|modeling|scheduling|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5624" PostTypeId="2" ParentId="4170" CreationDate="2021-01-28T15:55:14.407" Score="2" Body="&lt;p&gt;I'd go with Python because&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Python is a general purpose programming language and is much more widely used in industry than MATLAB. In the industry you rarely find yourself just code optimization algorithms or models in your daily work. It is more like you write an entire pipeline from data acquisition, data cleaning, model development (both statistical predictive models and/or optimization models) to visualization. Python provides more flexibility in that sense and have more APIs developed to communicate with other tools or applications (e.g databases) used in the pipelines.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The trend in industry is that many companies are moving to Python or using Python as the primary languages for analytics work, which means you can get more support from your IT department in terms infrastructure and computational capacity. For example, would your future employer's MATLAB capacity allow you to process tens of millions or billions of records? It is more likely that its Python infrastructure allows so because there are many other teams needing that capacity.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In your industry career, you would sooner or later collaborate with (e.g. code sharing) people from non-engineering background. Python is more widely used among them such as statisticians.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Have a look at the job description of your future ideal job and you will get a sense about what is needed.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="98" LastEditorUserId="98" LastEditDate="2021-01-29T01:55:22.203" LastActivityDate="2021-01-29T01:55:22.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5625" PostTypeId="1" AcceptedAnswerId="5641" CreationDate="2021-01-28T17:38:46.560" Score="2" ViewCount="780" Body="&lt;p&gt;I am trying to figure out how can I assign tasks to workers in a way that maximum time required to complete all tasks is minimum.&lt;/p&gt;&#xA;&lt;p&gt;Suppose I have following matrix&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;+----------+-------+-------+-------+&#xA;|          | Job 1 | Job 2 | Job 3 |&#xA;+----------+-------+-------+-------+&#xA;| Worker 1 |     5 |     4 |     5 |&#xA;| Worker 2 |     3 |     2 |     5 |&#xA;| Worker 3 |     1 |     5 |     2 |&#xA;+----------+-------+-------+-------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If I want to assign 1 task to each worker one way is to assign &lt;code&gt;worker 1&lt;/code&gt; &lt;code&gt;Job 3&lt;/code&gt; &lt;code&gt;worker 2&lt;/code&gt; &lt;code&gt;Job 2&lt;/code&gt; and &lt;code&gt;Worker 3&lt;/code&gt; &lt;code&gt;Job 1&lt;/code&gt;. Using this approach we are minimizing overall cost for all workers. (i.e. 5 + 2 + 1 =8). What algorithm can be applied to get overall minimization using this approach?&lt;/p&gt;&#xA;&lt;p&gt;Next approach is to find an assignment such that maximum time of assignment is minimized. Using this approach we assign &lt;code&gt;worker 1&lt;/code&gt; &lt;code&gt;Job 2&lt;/code&gt; &lt;code&gt;worker 2&lt;/code&gt; &lt;code&gt;Job 1&lt;/code&gt; and &lt;code&gt;Worker 3&lt;/code&gt; &lt;code&gt;Job 3&lt;/code&gt;. (i.e. 4 + 3 + 2)&#xA;Using this assignment approach maximum is 4 instead of 5. What algorithm can be used to make assignment in such manner?&lt;/p&gt;&#xA;&lt;p&gt;Note: Each  worker gets only 1 task.&lt;/p&gt;&#xA;" OwnerUserId="3853" LastActivityDate="2021-01-31T18:08:52.537" Title="How to determine least time required to complete all tasks?" Tags="|assignment-problem|minimax|cost-matrix|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5626" PostTypeId="1" CreationDate="2021-01-28T18:45:31.737" Score="3" ViewCount="80" Body="&lt;p&gt;I would like to solve the following problem: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max_{x_1, \ldots, x_n}&amp;amp;\quad\frac{1}{x_1} + \frac{1}{x_2} + \cdots + \frac{1}{x_n}\\\text{s.t.}&amp;amp;\quad\sum_{i=1}^n x_i A_i \succeq A_0\\&amp;amp;\quad x_1, \ldots, x_n \geq 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$A_0, A_1, \ldots, A_n$&lt;/span&gt; is a collection of symmetric matrices.&lt;/p&gt;&#xA;&lt;p&gt;I'm not sure what is a good way to solve this, since the objective is the maximization (rather than minimization) of a convex function. Can this be done in polynomial time, and, if not, what are some good heuristics for this?&lt;/p&gt;&#xA;" OwnerUserId="4869" LastEditorUserId="123" LastEditDate="2021-01-28T19:26:50.600" LastActivityDate="2021-01-28T19:35:23.447" Title="Maximize $\sum_{i=1}^n 1/x_i$ subject to an SDP constraint" Tags="|nonlinear-programming|nonconvex-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5627" PostTypeId="2" ParentId="5626" CreationDate="2021-01-28T19:21:03.107" Score="3" Body="&lt;p&gt;This is a concave programming problem, i.e., concave objective with convex constraints. It is a nonlinear, non-convex SDP. However, the constraints are not compact, so the theorem which says that there is a global optimum of a concave programming problem at an extreme of the constraints, does not apply. You can forget about polynomial time.&lt;/p&gt;&#xA;&lt;p&gt;If you want to try to solve this to global optimality, my suggestion is to specify BMIBNB as solver using YALMIP under MATLAB. Since the latter part of last year, BMIBNB has the capability of solving non-convex SDPs to global optimality, and is the only publicly available solver which can do so as far as I know. Whether it succeeds may depend on the uppersolver and lowersolver you specify for BMIBNB to call, as well as the difficulty of the problem. If you need help, you can post at &lt;a href=&quot;https://groups.google.com/g/yalmip&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://groups.google.com/g/yalmip&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2021-01-28T19:35:23.447" LastActivityDate="2021-01-28T19:35:23.447" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5628" PostTypeId="1" AcceptedAnswerId="5633" CreationDate="2021-01-28T20:35:03.720" Score="5" ViewCount="323" Body="&lt;p&gt;I am new to OR, and apologies if my mathematical notation is not clear. I have tried my best to keep it concise and given an explanation with numerical data.&#xA;I would like to understand:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can this model be formulated as convex, such as piecewise linear or quadratic, or SOCP? I will be interested to know both for the case when the variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are binary and also if they are non-binary.&lt;/li&gt;&#xA;&lt;li&gt;Can we use a global solver, such as Octeract or Baron to solve this problem of large size (n=10,000 and T=1200)? I have seen a number of posts on this website that some global solvers can reformulate the model that can be solved efficiently, but it would be good to know whether it will work for this case.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max\ q_1+q_2 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{Subject to}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\qquad \sum_{i=1}^{n} p_{i} x_{i} = \sum_{t=0}^{T} \frac{F_{t}}{(1+q_{1})^{t}} \qquad \qquad \qquad(1)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\qquad \sum_{i=1}^{n} p_{i} x_{i} = \sum_{t=0}^{T}\sum_{i=1}^{n} \frac{b_{i}^{t} x_{i}}{\left ( 1+q_{2} \right )^{t}} \qquad \qquad(2)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\qquad \sum_{i=1}^{n} p_{i} x_{i} = \beta \sum_{t=0}^{T} \frac{F_{t}}{(1+q_{1}+q_{2})^{t}} \qquad \qquad(3)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i\in \{0,1\} \qquad \text{are optimization variables}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$q_1 \geq\ 0, \qquad q_2 \geq\ 0 \qquad \text{are variables}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i\ =\ {1,2,3,...n}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t\ =\ {0,1,2,...T}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta \quad \text{is a constant}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$F\ =\ {c_1,c_2,c_3,...c_T} \quad \text{(coefficients)}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_i\ =\ {p_1,p_2,p_3,...p_n} \quad \text{(coefficients)}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b_i\ =\ {b_i^0,b_i^1,b_i^2,...b_i^T}  \quad \text{(coefficients)}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have illustrated this using numerical data in the attached image (in case if the maths above is written incorrectly)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/uIRmI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uIRmI.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4870" LastEditorUserId="4870" LastEditDate="2021-01-29T05:23:32.667" LastActivityDate="2021-01-30T00:23:04.620" Title="Piecewise linear and global optimization" Tags="|convex-optimization|quadratic-programming|reformulation-linearization|global-optimization|disciplined-quasiconvex-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5629" PostTypeId="1" CreationDate="2021-01-28T23:56:05.347" Score="4" ViewCount="75" Body="&lt;p&gt;Suppose we are given a (simple) graph with non-negative edge weights, along with a matching &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, which may or may not be max weight. I know that &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; will be max weight if and only if the graph does not contain an &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;-augmenting path or cycle. But is there an efficient way to compute such an object? In the unweighted case, there is an efficient method for finding an augmenting path by doing a modified breadth-first-search (where for every other 'layer' of the search you take the unique matched edge available, assuming it exists), but I don't really see how this would generalize to the weighted case.&lt;/p&gt;&#xA;&lt;p&gt;Would someone be able to verify whether or not an efficient algorithm for finding such an augmenting path/cycle exists, and possibly explain a sketch of how this works (assuming it is pretty technical) or give a reference of where to find an explanation? Any assistance would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3988" LastActivityDate="2021-02-01T22:57:09.523" Title="Finding an augmenting path or cycle in weighted graph" Tags="|combinatorial-optimization|matching|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5630" PostTypeId="1" CreationDate="2021-01-29T03:10:35.757" Score="1" ViewCount="78" Body="&lt;p&gt;Cloud computing has transformed the landscape of compute operations. Of course, there are still many labs/businesses with local, large-scale compute clusters. For those businesses who keep the hardware, it would be beneficial to the users to have a tool for deciding whether or not a job should be ran locally versus on the cloud. Two important factors would be how much time the user can afford to wait and the funds available to the user.&lt;/p&gt;&#xA;&lt;p&gt;If we were only optimizing for cost, of course, we'd send every job to the local resources. It gets interesting when you optimize for both cost and time, considering there's a finite amount of machines locally (other users' jobs creates a queue) and the cloud can provide better/faster hardware.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Ultimately, say you have some amount of money and a time frame. After providing this information and a list of jobs (each with varying CPU nodes requested, memory required, estimated job time, etc.), this tool should be able to make a near-optimal decision about which jobs to run locally and which to run on the cloud.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Considering the optimization nature of this problem, Google's &lt;a href=&quot;https://developers.google.com/optimization/introduction/overview&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR-Tools&lt;/a&gt; library looks great to start with. They provide guides (check left side bar there) to several &amp;quot;problem types&amp;quot;. I'm having trouble deciding which category this problem falls into.&lt;/p&gt;&#xA;&lt;p&gt;For those unable to visit the OR-Tools link, the problem types are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Linear Optimization&lt;/li&gt;&#xA;&lt;li&gt;Integer Optimization&lt;/li&gt;&#xA;&lt;li&gt;Constraint Optimization&lt;/li&gt;&#xA;&lt;li&gt;Assignment&lt;/li&gt;&#xA;&lt;li&gt;Routing&lt;/li&gt;&#xA;&lt;li&gt;Bin Packing&lt;/li&gt;&#xA;&lt;li&gt;Network Flows&lt;/li&gt;&#xA;&lt;li&gt;Scheduling&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;What problem type category does this best fall into, and what are some ideas on how to formulate said problem?&lt;/p&gt;&#xA;" OwnerUserId="4874" LastEditorUserId="981" LastEditDate="2023-12-31T11:13:54.487" LastActivityDate="2023-12-31T11:13:54.487" Title="What is a good approach to deciding which jobs (from a list of HPC jobs) should be ran locally vs. on the cloud given time &amp; cost constraints?" Tags="|optimization|scheduling|or-tools|constraint-programming|multi-objective-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5631" PostTypeId="1" AcceptedAnswerId="5632" CreationDate="2021-01-29T09:56:34.020" Score="2" ViewCount="1061" Body="&lt;p&gt;I just started to learn about Pyomo. In several tutorials it is stated that the command for creating a variable is just &lt;code&gt;model.Variable = VAR(...)&lt;/code&gt;. However, I get the error message when using the Var function:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;NameError: name 'Var' is not defined&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Why do I get this error? Here you see my full code (the problematic statement is the last line):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;&#xA;model = pyo.ConcreteModel()&#xA;&#xA;#Sets&#xA;&#xA;&#xA;#empty set&#xA;model.A = pyo.Set()&#xA;&#xA;#initialized set with values&#xA;model.D = pyo.Set(initialize=['red', 'green', 'blue'])&#xA;&#xA;&#xA;#Define a function to create ta sequence of numbers&#xA;def createSequenceOfNumbers(startNumber, endNumber):&#xA;    return (i for i in range (startNumber, endNumber + 1))&#xA;&#xA;model.C = pyo.Set(initialize=createSequenceOfNumbers(4, 9))&#xA;model.E = pyo.RangeSet(5,9)&#xA;&#xA;&#xA;#printing a set&#xA;model.C.pprint()&#xA;model.D.pprint()&#xA;model.E.pprint()&#xA;&#xA;&#xA;#Parameter&#xA;&#xA;#define sets&#xA;model.A_P = pyo.RangeSet(1,3)&#xA;model.B_P = pyo.RangeSet(1,3)&#xA;&#xA;#Values for the sets by using a dict-datatype.&#xA;valuesForParam = {}&#xA;valuesForParam [1,1] = 1&#xA;valuesForParam [1,3] = 2&#xA;valuesForParam [2,3] = 10&#xA;&#xA;#define Parameters (2 dimensional)&#xA;model.P = pyo.Param(model.A_P, model.B_P, initialize=valuesForParam, default=0)&#xA;&#xA;model.P.pprint()&#xA;&#xA;&#xA;&#xA;#Variables&#xA;&#xA;&#xA;model.variable1 = Var(within=NonNegativeReals, bounds =(0,6), initialize=1.5)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="491" LastEditDate="2021-01-29T15:05:33.333" LastActivityDate="2021-02-01T09:43:51.413" Title="Error when defining variables in Pyomo" Tags="|python|pyomo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5632" PostTypeId="2" ParentId="5631" CreationDate="2021-01-29T13:28:25.653" Score="5" Body="&lt;p&gt;You are just importing the &lt;code&gt;pyomo.environ&lt;/code&gt; module while the tutorials probably use the &lt;code&gt;from&lt;/code&gt; syntax.&lt;/p&gt;&#xA;&lt;p&gt;These variables are inside &lt;code&gt;pyomo.environ&lt;/code&gt; so you have 3 alternatives:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Import them explicitly &lt;code&gt;from pyomo.environ import Var, NonNegativeReals&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Import them using a wildcard &lt;code&gt;from pyomo.environ import *&lt;/code&gt; (this is considered an antipattern)&lt;/li&gt;&#xA;&lt;li&gt;Import the module (with an alias in this case) &lt;code&gt;import pyomo.environ as pyo&lt;/code&gt; and access them like &lt;code&gt;pyo.VariableName&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;PS: this isn't really related to pyomo. For more information about the python import system please read: &lt;a href=&quot;https://docs.python.org/3/reference/simple_stmts.html#import&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.python.org/3/reference/simple_stmts.html#import&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="991" LastEditorUserId="991" LastEditDate="2021-02-01T09:43:51.413" LastActivityDate="2021-02-01T09:43:51.413" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5633" PostTypeId="2" ParentId="5628" CreationDate="2021-01-29T15:47:45.013" Score="3" Body="&lt;p&gt;As far as I can see there is no exact convex reformulation for this, unless someone else can think of a nice trick. Constraint 1 can actually be convexified for certain ranges of &lt;span class=&quot;math-container&quot;&gt;$q_i$&lt;/span&gt; as these functions are partially convex, e.g. &lt;span class=&quot;math-container&quot;&gt;$1/(1+x)^3$&lt;/span&gt; is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/afbiN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/afbiN.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The fractions in constraint 3 are also convex past certain hyperplanes. However, you would have to restrict your feasible region quite significantly to impose that, which means missing out on solutions.&lt;/p&gt;&#xA;&lt;p&gt;Constraint 2 unfortunately can not be convexified because of the multiplication by &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As you mentioned, a deterministic global optimisation solver such as Octeract Engine, Baron, ANTIGONE, or Couenne, will solve this problem automatically. The solver will not make the problem convex, but will instead generate a &lt;a href=&quot;https://cpb-us-w2.wpmucdn.com/sites.gatech.edu/dist/2/436/files/2016/11/17-convex-relaxation.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;convex relaxation&lt;/a&gt; that can be solved rigorously (because it's convex). This value provides a rigorous lower bound on your problem (assuming minimisation), and the solver will the iteratively generate and solves such relaxations using branch-and-bound until it proves global optimality.&lt;/p&gt;&#xA;&lt;p&gt;If you want to try this out, &lt;a href=&quot;https://github.com/coin-or/Couenne&quot; rel=&quot;nofollow noreferrer&quot;&gt;Couenne&lt;/a&gt; and our own &lt;a href=&quot;https://octeract.com/octeract-engine/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Engine&lt;/a&gt; are free to use for any purpose.&lt;/p&gt;&#xA;&lt;p&gt;As a final note, keep in mind that equality constraints with convex functional forms do not generally make the problem convex. Intuitively, assuming we're minimising subject to e.g., &lt;span class=&quot;math-container&quot;&gt;$x^2=1$&lt;/span&gt;, this constraint is equivalent to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x^2 \le 1$&lt;/span&gt;, and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x^2\ge1 \implies-x^2 \le-1 $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The first constraint defines a convex feasible region, but the second constraint defines a concave one. The intersection of the two gives us the equality feasible region.&lt;/p&gt;&#xA;&lt;p&gt;Some solvers can handle this out-of-the-box (e.g., Octeract Engine), but certain solvers (especially if they are convex-only) only support convex inequality constraints, so make sure to check what your solver is designed to handle.&lt;/p&gt;&#xA;&lt;p&gt;As a final-final note on semantics, since you are maximising, a convex optimisation problem is either (i) the maximisation of a concave objective, or (ii) the minimisation of a convex objective, over a convex set. Convex problems are can be &lt;em&gt;minimized&lt;/em&gt; to global optimality in a single local solve, and concave problems can be &lt;em&gt;maximized&lt;/em&gt; to global optimality in a single local solve. Since your objective is linear this doesn't affect your problem, but keep it in mind as you experiment with reformulations.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-01-30T00:23:04.620" LastActivityDate="2021-01-30T00:23:04.620" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5634" PostTypeId="2" ParentId="5628" CreationDate="2021-01-29T18:53:40.397" Score="3" Body="&lt;p&gt;I might be missing something here (and by &amp;quot;might be&amp;quot; I mean &amp;quot;probably am&amp;quot;), but at least for the case of &lt;span class=&quot;math-container&quot;&gt;$x_i \in [0,1]$&lt;/span&gt; you might be able to get solutions via &amp;quot;brute force&amp;quot;. I'm assuming that all the parameters (&lt;span class=&quot;math-container&quot;&gt;$F,p,b,\beta$&lt;/span&gt;) are positive.&lt;/p&gt;&#xA;&lt;p&gt;Suppose we slap a somewhat arbitrary upper bound &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$q_1$&lt;/span&gt;, and then do a bisection search (or any other one-dimensional line search) on &lt;span class=&quot;math-container&quot;&gt;$q_1$&lt;/span&gt;. Since (1)-(3) all have the same LHS, the RHS of (1) equals the RHS of (3), and for fixed &lt;span class=&quot;math-container&quot;&gt;$q_1$&lt;/span&gt; the RHS of (3) looks like a strictly decreasing function of &lt;span class=&quot;math-container&quot;&gt;$q_2$&lt;/span&gt;. So given a value of &lt;span class=&quot;math-container&quot;&gt;$q_1$&lt;/span&gt;, either we can use the fact that the RHS of (3) equals the known RHS of (1) to solve for &lt;span class=&quot;math-container&quot;&gt;$q_2$&lt;/span&gt;, or else we find there is no solution (so the value of &lt;span class=&quot;math-container&quot;&gt;$q_1$&lt;/span&gt; is infeasible).&lt;/p&gt;&#xA;&lt;p&gt;Assuming we find a value for &lt;span class=&quot;math-container&quot;&gt;$q_2$&lt;/span&gt;, we solve for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; satisfying (1) and (2). Given &lt;span class=&quot;math-container&quot;&gt;$q_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q_2$&lt;/span&gt;, these are now linear equations in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, and if the system is underdetermined (likely) that's fine. We don't care which feasible solution we find; we just need to confirm that there is a solution that respects the bounds on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. One way to do this would be solve a linear program. If the LP is infeasible, again that means our choice of &lt;span class=&quot;math-container&quot;&gt;$q_1$&lt;/span&gt; is infeasible. If it's feasible, we have a new feasible solution with a known objective value, and now we go back to the line search of &lt;span class=&quot;math-container&quot;&gt;$q_1$&lt;/span&gt; and use the new objective value to decide where to look next.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-01-29T18:53:40.397" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5635" PostTypeId="2" ParentId="5630" CreationDate="2021-01-29T21:06:28.917" Score="2" Body="&lt;p&gt;In order to pin down a problem type, you will have to answer a number of questions about the application.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How are you going to deal with the cost-time conflict? There are quite a few methods for dealing with multiple criteria, including taking a weighted sum, constraining one while optimizing the other (fastest turn-around within a budget, cheapest solution meeting a time limit), goal programming, ... Also, if you are simultaneously scheduling jobs for multiple customers, do they independently set time/cost tradeoffs (some impatient free-spenders, some patient tight-wads) or is there one tradeoff that applies to all of them.&lt;/li&gt;&#xA;&lt;li&gt;Is this an &amp;quot;online&amp;quot; application (schedule gets updated each time a new job comes in) or a &amp;quot;batch&amp;quot; application (accumulate a gaggle of jobs, schedule them all, accumulate more jobs, schedule those, ...). In the latter case, are previously schedules but as yet unrun jobs subject to being delayed in favor of new jobs? (I'm assuming, somewhat charitably, that there will be no preemptions of running jobs.)&lt;/li&gt;&#xA;&lt;li&gt;If in batch mode, are batches sufficiently far apart in time not to affect each other? If not (decisions on the last batch affect the next batch), you have to deal with &amp;quot;horizon effects&amp;quot;. Decisions that look good in the short term can adversely affect long term results. As an example, you do daily batches, and on Monday you schedule enough cheap jobs locally to tie up the local resources through Wednesday. On Tuesday, an urgent job comes in with a truly ghastly cloud cost. Oops.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;There are probably more questions, but I would start with those.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-01-29T21:06:28.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5636" PostTypeId="1" CreationDate="2021-01-30T10:23:37.793" Score="4" ViewCount="582" Body="&lt;p&gt;I'm new to Cplex and I'm working with the python API. I have a variable &lt;span class=&quot;math-container&quot;&gt;$w^t_{iksm}$&lt;/span&gt; and I could just find the binary_var_cube function which only accepts 3 indices. I'm then using this &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; to define &lt;span class=&quot;math-container&quot;&gt;$X^z_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y_{im}$&lt;/span&gt; which are my decision variables. My question is, how should I code this variable with more than 3 indices?&lt;/p&gt;&#xA;&lt;p&gt;I'm sorry if this is a basic one, but if you had any useful resources for beginners, please don't hesitate to share them with me.&lt;/p&gt;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="4879" LastActivityDate="2021-02-02T01:17:20.430" Title="Binary variables with multiple indices" Tags="|python|cplex|cplex-python-api|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5637" PostTypeId="2" ParentId="5622" CreationDate="2021-01-30T12:48:16.217" Score="1" Body="&lt;p&gt;If a deterministic global optimisation solver (such as Baron) reports a local solution, that solution is reliable. If the solver is terminated prematurely, the global solver will return the best solution it has found so far.&lt;/p&gt;&#xA;&lt;p&gt;For NLP, it is quite common that global solvers find the global solution very early on, and then spend the majority of time proving it is global.&lt;/p&gt;&#xA;&lt;p&gt;For MINLP, I often see new solutions discovered after quite a long time into the solving process, so it really depends.&lt;/p&gt;&#xA;&lt;p&gt;Whether a non-global solution is usable for your problem or not is impossible to tell without the actual problem, but non-linear models tend to be more precise than linear ones (assuming the underlying phenomenon is non-linear), hence non-global solutions can be perfectly viable. You will have to confirm that yourself though.&lt;/p&gt;&#xA;&lt;p&gt;Regarding change in conditions, you can't. It is likely that small changes in the model will not affect the solver's ability to solve it, but it's NP-Hard so you never know. All you can do is simulate scenarios and test the solver's robustness.&lt;/p&gt;&#xA;&lt;p&gt;Finally, since you've tried Baron and ANTIGONE already, you could also try &lt;a href=&quot;https://github.com/coin-or/Couenne&quot; rel=&quot;nofollow noreferrer&quot;&gt;Couenne&lt;/a&gt; or our own &lt;a href=&quot;https://octeract.com/octeract-engine/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Engine&lt;/a&gt;. The latter is the only deterministic global optimisation solver that has parallel branch and bound, so it's possible to globally converge within the time you need by investing more computing power.&lt;/p&gt;&#xA;&lt;p&gt;In general though, global optimisation is the most computationally expensive type of optimisation. For hard MINLPs 180s can be nowhere near the necessary solving time, try a few hours instead. If time is critical for you, I would suggest either (i) improving the formulation, or (ii) using Octeract Engine with as many cores as you can access.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-01-30T12:48:16.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5638" PostTypeId="1" AcceptedAnswerId="5639" CreationDate="2021-01-30T20:56:28.943" Score="3" ViewCount="75" Body="&lt;p&gt;I am formulating a model that seeks to minimize the cost of shipping goods from factories to warehouses, where the cost of shipping is independent of the type or amount of goods being shipped (except when no goods are shipped, then the cost should be identically zero). To model this, I thought about creating an indicator variable that would apply the fixed cost of shipping from factory &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to warehouse &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; if a given route was taken (i.e. the amount of goods sent via this route is not zero). Here is my current formulation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textbf{Parameters}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The cost of shipping goods from factory &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to warehouse &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$c_{ij}\in \mathbb{R}_{+}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textbf{Decision Variables}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Amount of good &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; (in tons) shipped from factory &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to warehouse &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$x_{ijk} \in \mathbb{Q}_{+}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Indicator variable to apply cost &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$y_{ij} = \mathbb{1}\{\sum_{k=1}^{p}x_{ijk} &amp;gt; 0\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textbf{Objective}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We want to minimize the cost of shipping. To represent cost, we sum up all applied fixed costs, that is, sum up the cost of each route currently being taken:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i=1}^{n}\sum_{j=1}^{m}c_{ij}y_{ij}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the total number of factories and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is the total number of warehouses.&lt;/p&gt;&#xA;&lt;p&gt;Here is the heart of my question: Would it be logically equivalent to forget the indicator variable altogether and simply model the objective as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i=1}^{n}\sum_{j=1}^{m}c_{ij}\sum_{k=1}^{p}x_{ijk}$$&lt;/span&gt;&#xA;In this case, routes that are quite expensive to take would have &lt;span class=&quot;math-container&quot;&gt;$\sum_{k=1}^{p}x_{ijk}=0$&lt;/span&gt; (is this a correct assumption?), effectively eliminating that route from consideration. However, the costs would differ in magnitude and would not capture the true cost that is desired (as well as other potential other issues my untrained eye is missing). Still, if all that matters is the routes taken, would these objectives be equivalent in both desire and outcome?&lt;/p&gt;&#xA;" OwnerUserId="3231" LastEditorUserId="67" LastEditDate="2021-01-30T21:48:46.253" LastActivityDate="2021-01-30T21:53:44.000" Title="Logical equivalencies to modeling an indicator decision variable in transportation problem" Tags="|optimization|modeling|binary-variable|indicator-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5639" PostTypeId="2" ParentId="5638" CreationDate="2021-01-30T21:53:44.000" Score="5" Body="&lt;p&gt;Consider the following tiny example. You have two factories, one warehouse and two product. Factory 1 can produce both goods in sufficient quantity to meet demand but has a very large cost coefficient. Factory 2 only produces the second product, with adequate capacity and a small cost coefficient. The optimal solution to the original problem is to ship everything from factory 1: you have to pay &lt;span class=&quot;math-container&quot;&gt;$c_{1,1}$&lt;/span&gt; anyway, since you need to ship product 1 from factory 1, so product 2 gets a free ride. The optimal solution to your modified model ships product 2 from factory 2 because it's cheaper than shipping from factory 1.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-01-30T21:53:44.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5640" PostTypeId="2" ParentId="3660" CreationDate="2021-01-31T00:58:31.130" Score="2" Body="&lt;p&gt;Most solvers will accept additional information about variables like &lt;span class=&quot;math-container&quot;&gt;$B(i)$&lt;/span&gt;. Some may be useful. Here are some examples for Gurobi, which let you influence the search:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can use the parameter &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/branchdir.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;BranchDir&lt;/a&gt; to tell Gurobi to always first explore the &amp;quot;up&amp;quot; branch. This means that non-zero values will be tried first. Unfortunately, this is a global setting - so Gurobi will always try non-zero values first for &lt;em&gt;all&lt;/em&gt; variables.&lt;/li&gt;&#xA;&lt;li&gt;The variable attribute &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/varhintval.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;VarHintVal&lt;/a&gt; let's you provide hints of &amp;quot;expected optimal values&amp;quot; for variables. If you're certain that &lt;span class=&quot;math-container&quot;&gt;$B(i) = 7$&lt;/span&gt;, you can set &lt;code&gt;b[i].VarHintVal = 7&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Setting the a high &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/branchpriority.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;BranchPriority&lt;/a&gt; instructs the solver to first branch on a specific variable. The solver will try non-zero values sooner for variables with a high branch priority.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Other solvers offer similar settings with similar effects.&lt;/p&gt;&#xA;" OwnerUserId="69" LastActivityDate="2021-01-31T00:58:31.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5641" PostTypeId="2" ParentId="5625" CreationDate="2021-01-31T14:52:58.400" Score="3" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Minimizing the sum of all assignments: this is the classical version of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;assignment problem&lt;/a&gt;. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Hungarian_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hungarian algorithm&lt;/a&gt; solves it in polynomial time.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Minimizing the maximum of all assignments: this one is known as the &lt;a href=&quot;https://en.wikipedia.org/wiki/Linear_bottleneck_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;linear bottleneck assignment problem&lt;/a&gt;. The most obvious way to solve it is to solve a succession a decision problems: is it possible to find an assignment such that every worker is assigned exactly one job using only assignments with costs smaller than &lt;code&gt;c&lt;/code&gt;? And to do a binary search on the value of &lt;code&gt;c&lt;/code&gt;. This decision problem is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Maximum_cardinality_matching&quot; rel=&quot;nofollow noreferrer&quot;&gt;maximum cardinality matching problem&lt;/a&gt; in a bipartite graph which can be solved in polynomial time with &lt;a href=&quot;https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ford-Fulkerson algorithm&lt;/a&gt; or with &lt;a href=&quot;https://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hopcroft–Karp algorithm&lt;/a&gt;. Additionally, a dual method and a dedicated augmenting path method can be found in the book &amp;quot;Assignment problems&amp;quot; (Burkard et al., 2009), section 6.2.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;All these algorithms have a polynomial complexity. However, if you don't have them on hand, it might be faster to simply write an integer linear programming model or a constraint programming model and to solve it with a corresponding solver.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2021-01-31T18:08:52.537" LastActivityDate="2021-01-31T18:08:52.537" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5642" PostTypeId="1" AcceptedAnswerId="5646" CreationDate="2021-01-31T16:06:24.980" Score="4" ViewCount="1285" Body="&lt;p&gt;I have the following code in Python and PuLP which uses static variables. I want to know how to solve the problem by converting all of the LpVariable parts into an array, as well as the constraints. The idea is to be able to add new elements to the LpVariable and constraints array and having the solver run through the arrays rather than having to manually code new lines if another type of bicycle needs to be produced or additional parts are added as constraints.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    #Bicycle Manufacturing Schedule&#xA;from pulp import *&#xA;&#xA;# The challenge is to maximise the profit by producing an optimum number of each type of bicycle&#xA;# A - &amp;quot;Mountain Bike&amp;quot;, profit margin of &lt;span class=&quot;math-container&quot;&gt;$45 per unit&#xA;# B - &quot;Street Bike&quot;, profit margin of $&lt;/span&gt;60 per unit&#xA;# C - &amp;quot;Racing Bike&amp;quot;, profit margin of &lt;span class=&quot;math-container&quot;&gt;$55 per unit&#xA;# D - &quot;Commuter bike&quot;, profit margin of $&lt;/span&gt;50 per unit &#xA;#&#xA;model = LpProblem(&amp;quot;Profit Maximising&amp;quot;, LpMaximize)&#xA;&#xA;#We can't sell half a bike, so the category for each bicycle type is an integer.&#xA;#A &amp;gt;= 0, B &amp;gt;= 0, C &amp;gt;= 0, D &amp;gt;= 0 : Input (Changing) cells&#xA;A = LpVariable('A', lowBound=0, cat='Integer')&#xA;B = LpVariable('B', lowBound=0, cat='Integer')&#xA;C = LpVariable('C', lowBound=0, cat='Integer')&#xA;D = LpVariable('D', lowBound=0, cat='Integer')&#xA;&#xA;#Our objective is to maximise the profit&#xA;model += 45 * A + 60 * B + 55 * C + 50 * D, &amp;quot;Total Profit&amp;quot;&#xA;&#xA;#Setup the constraints (parts available in stock)&#xA;wheels = 2 * A + 2 * B + 2 * C + 2 * D&#xA;alloy_chassis = 1 * A + 1 * C&#xA;steel_chassis = 1 * B + 1 * D&#xA;hub_gears = 1 * A + 1 * D&#xA;derailleur_gears = 1 * B + 1 * C&#xA;&#xA;#Add constraints to the model&#xA;model += wheels &amp;lt;=180&#xA;model += alloy_chassis &amp;lt;= 40&#xA;model += steel_chassis &amp;lt;= 60&#xA;model += hub_gears &amp;lt;= 50&#xA;model += derailleur_gears &amp;lt;= 40&#xA;&#xA;#Print the problem&#xA;print (model)&#xA;&#xA;#Solve the problem&#xA;model.solve()&#xA;print (&amp;quot;Status : &amp;quot;, LpStatus[model.status])&#xA;&#xA;#Print our changing cells&#xA;print (&amp;quot;Units of Mountain Bike   = &amp;quot;, A.varValue)&#xA;print (&amp;quot;Units of Street Bike     = &amp;quot;, B.varValue)&#xA;print (&amp;quot;Units of Racing Bike     = &amp;quot;, C.varValue)&#xA;print (&amp;quot;Units of Commuter Bike   = &amp;quot;, D.varValue)&#xA;&#xA;#Print our objective function value - Result (Target) cell&#xA;print (&amp;quot;Total Profit             = &amp;quot;, value(model.objective))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;EDIT 01-FEB-2021&lt;/p&gt;&#xA;&lt;p&gt;I have converted the code to use arrays instead of fixed variables.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    #Bicycle Manufacturing Schedule&#xA;from pulp import *&#xA;&#xA;# The challenge is to maximise the profit by producing an optimum number of each type of bicycle&#xA;# A, profit margin of &lt;span class=&quot;math-container&quot;&gt;$45 per unit&#xA;# B, profit margin of $&lt;/span&gt;60 per unit&#xA;# C, profit margin of &lt;span class=&quot;math-container&quot;&gt;$55 per unit&#xA;# D, profit margin of $&lt;/span&gt;50 per unit &#xA;&#xA;bike_types = [&amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;D&amp;quot;]&#xA;bike_profit = [45, 60, 55, 50]&#xA;&#xA;parts_name = [&amp;quot;wheels&amp;quot;, &amp;quot;alloy_chassis&amp;quot;, &amp;quot;steel_chassis&amp;quot;, &amp;quot;hub_gears&amp;quot;, &amp;quot;derailleur_gears&amp;quot;]&#xA;parts_stock = [180, 40, 60, 50, 40] &#xA;bike_parts = [  #part_names&#xA;                #&amp;quot;wheels&amp;quot;, &amp;quot;alloy_chassis&amp;quot;, &amp;quot;steel_chassis&amp;quot;, &amp;quot;hub_gears&amp;quot;, &amp;quot;derailleur_gears&amp;quot;&#xA;                [2,1,0,1,0],#Bike type A&#xA;                [2,0,1,0,1],#Bike type B&#xA;                [2,1,0,0,1],#Bike type C&#xA;                [2,0,1,1,0] #Bike type D&#xA;            ]&#xA;&#xA;prob = LpProblem(&amp;quot;Profit Maximising&amp;quot;, LpMaximize)&#xA;&#xA;n = len(bike_profit)&#xA;N = range(n)&#xA;&#xA;#We can't sell half a bike, so the category for each bicycle type is an integer.&#xA;x = LpVariable.dicts(&amp;quot;x&amp;quot;, N, lowBound=0, cat='Integer')&#xA;&#xA;#Our objective is to maximise the profit&#xA;prob += lpSum([bike_profit[i]*x[i] for i in N]), &amp;quot;Total Profit&amp;quot;&#xA;&#xA;#Constraints on available bike parts&#xA;for p in range(len(parts_name)):&#xA;    prob += lpSum(bike_parts[i][p]*x[i] for i in N) &amp;lt;= parts_stock[p], parts_name[p]&#xA;    &#xA;#Print the problem&#xA;print (prob)&#xA;&#xA;#Solve the problem&#xA;prob.solve()&#xA;print (&amp;quot;Status : &amp;quot;, LpStatus[prob.status])&#xA;&#xA;#Print our changing cells&#xA;for i in range(len(bike_types)):&#xA;    print (&amp;quot;Units of &amp;quot;, x[i],&amp;quot;= &amp;quot;, x[i].varValue)&#xA;&#xA;#Print our objective function value - Result (Target) cell&#xA;print (&amp;quot;Total Profit             = &amp;quot;, value(prob.objective))&#xA;&#xA;     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4883" LastEditorUserId="4883" LastEditDate="2021-02-01T11:53:34.007" LastActivityDate="2021-02-01T14:47:48.767" Title="How to convert static variables into arrays for use with PuLP" Tags="|optimization|linear-programming|python|pulp|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5643" PostTypeId="1" CreationDate="2021-01-31T21:49:03.557" Score="1" ViewCount="75" Body="&lt;p&gt;I want to create randomly an undirected connected graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; nodes and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; edges using Matlab. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="4735" LastEditorUserId="123" LastEditDate="2021-02-01T09:14:07.547" LastActivityDate="2021-02-01T09:14:07.547" Title="Create randomly an undirected connected graph using Matlab" Tags="|graphs|matlab|" AnswerCount="0" CommentCount="1" ClosedDate="2021-02-01T20:11:14.257" ContentLicense="CC BY-SA 4.0" />
  <row Id="5645" PostTypeId="1" CreationDate="2021-02-01T08:51:03.663" Score="3" ViewCount="73" Body="&lt;p&gt;I just wonder, whether there is a good reference for the symbols used in a flow chart to describe a DES process. I am looking for something like &lt;a href=&quot;https://en.wikipedia.org/wiki/Kendall%27s_notation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kendall notation&lt;/a&gt; but with a reference to the symbols.&#xA;I searched the web, but could not find a good reference (e.g., a well-known journal).&lt;/p&gt;&#xA;" OwnerUserId="4612" LastEditorUserId="36" LastEditDate="2024-02-14T13:25:05.240" LastActivityDate="2024-03-15T14:06:20.723" Title="Are there standard symbols to describe discrete event simulations (DES)" Tags="|modeling|reference-request|simulation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5646" PostTypeId="2" ParentId="5642" CreationDate="2021-02-01T13:24:46.583" Score="5" Body="&lt;p&gt;Your code is correct, you have used &lt;code&gt;pulp.LpVariable.dicts&lt;/code&gt; correctly.&lt;/p&gt;&#xA;&lt;p&gt;For better readability, it is often better to use dictionaries. So the idea is to convert your data from lists to dicts as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# convert data into dicts&#xA;dict_bike_profit = dict(zip(bike_types, bike_profit)) # simple dict&#xA;dict_bike_stock = dict(zip(part_names, parts_stock)) # simple dict&#xA;dict_bike_parts = makeDict([part_names, bike_types], bike_parts) # nested dict&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I suggest you print the above dicts to see what they are equal to, with your own eyes. Once you have such objects, writing the constraints is easier. The code below yields a total profit of 4750.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Bicycle Manufacturing Schedule&#xA;from pulp import *&#xA;&#xA;# The challenge is to maximise the profit by producing an optimum number of each type of bicycle&#xA;# A, profit margin of &lt;span class=&quot;math-container&quot;&gt;$45 per unit&#xA;# B, profit margin of $&lt;/span&gt;60 per unit&#xA;# C, profit margin of &lt;span class=&quot;math-container&quot;&gt;$55 per unit&#xA;# D, profit margin of $&lt;/span&gt;50 per unit&#xA;&#xA;bike_types = [&amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;D&amp;quot;]&#xA;bike_profit = [45, 60, 55, 50]&#xA;parts_stock = [180, 40, 60, 50, 40]&#xA;part_names = [&#xA;    &amp;quot;wheels&amp;quot;,&#xA;    &amp;quot;alloy_chassis&amp;quot;,&#xA;    &amp;quot;steel_chassis&amp;quot;,&#xA;    &amp;quot;hub_gears&amp;quot;,&#xA;    &amp;quot;derailleur_gears&amp;quot;,&#xA;]&#xA;bike_parts = [  # part_names&#xA;    # &amp;quot;wheels&amp;quot;, &amp;quot;alloy_chassis&amp;quot;, &amp;quot;steel_chassis&amp;quot;, &amp;quot;hub_gears&amp;quot;, &amp;quot;derailleur_gears&amp;quot;&#xA;    [2, 1, 0, 1, 0],  # Bike type A&#xA;    [2, 0, 1, 0, 1],  # Bike type B&#xA;    [2, 1, 0, 0, 1],  # Bike type C&#xA;    [2, 0, 1, 1, 0],  # Bike type D&#xA;]&#xA;# transpose the above array (you need to do this to write your constraint correctly)&#xA;bike_parts = list(map(list, zip(*bike_parts)))&#xA;&#xA;# convert data into dicts&#xA;dict_bike_profit = dict(zip(bike_types, bike_profit))&#xA;dict_bike_stock = dict(zip(part_names, parts_stock))&#xA;dict_bike_parts = makeDict([part_names, bike_types], bike_parts)&#xA;&#xA;&#xA;prob = LpProblem(&amp;quot;Profit Maximising&amp;quot;, LpMaximize)&#xA;&#xA;&#xA;# We can't sell half a bike, so the category for each bicycle type is an integer.&#xA;x = LpVariable.dicts(&amp;quot;x&amp;quot;, bike_types, lowBound=0, cat=&amp;quot;Integer&amp;quot;)&#xA;&#xA;# Our objective is to maximise the profit&#xA;prob += lpSum([dict_bike_profit[i] * x[i] for i in dict_bike_profit]), &amp;quot;Total Profit&amp;quot;&#xA;&#xA;# Constraints on available bike parts&#xA;for i in dict_bike_parts:&#xA;    prob += (&#xA;        lpSum(dict_bike_parts[i][p] * x[p] for p in dict_bike_parts[i])&#xA;        &amp;lt;= dict_bike_stock[i],&#xA;        &amp;quot;availability_%s&amp;quot; % (i),&#xA;    )&#xA;&#xA;# Print the problem&#xA;print(prob)&#xA;&#xA;# Solve the problem&#xA;prob.solve()&#xA;print(&amp;quot;Status : &amp;quot;, LpStatus[prob.status])&#xA;&#xA;# Print our changing cells&#xA;for i in x:&#xA;    print(&amp;quot;Units of &amp;quot;, x[i], &amp;quot;= &amp;quot;, x[i].varValue)&#xA;&#xA;# Print our objective function value - Result (Target) cell&#xA;print(&amp;quot;Total Profit             = &amp;quot;, value(prob.objective))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-02-01T14:47:48.767" LastActivityDate="2021-02-01T14:47:48.767" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5647" PostTypeId="1" AcceptedAnswerId="5648" CreationDate="2021-02-01T15:34:43.287" Score="2" ViewCount="528" Body="&lt;p&gt;I've set up and successfully executed an evolutionary optimization in Excel, and now have a need to convert the problem to Python. &lt;code&gt;differential_evolution()&lt;/code&gt; in the optimize package would seem to get me there, but doesn't appear to allow for the setting of a constraint such as &lt;code&gt;x1 &amp;lt; x2&lt;/code&gt; (where &lt;code&gt;x1&lt;/code&gt; and &lt;code&gt;x2&lt;/code&gt; are elements of the decision variable vector).&lt;/p&gt;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="4888" LastEditorUserId="36" LastEditDate="2021-02-01T18:23:17.320" LastActivityDate="2021-02-01T18:23:17.320" Title="Converting evolutionary optimization problem from Excel to Python" Tags="|optimization|python|solver|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5648" PostTypeId="2" ParentId="5647" CreationDate="2021-02-01T17:04:15.140" Score="6" Body="&lt;p&gt;You could apply the following trick inside your objective function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x1 = min(x[1],x[2])&#xA;x2 = max(x[1],x[2])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now &lt;code&gt;x1 &amp;lt;= x2&lt;/code&gt; automatically holds and you don't need the constraint. (Assuming you can live with &lt;code&gt;&amp;lt;=&lt;/code&gt; instead of &lt;code&gt;&amp;lt;&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2021-02-01T17:16:56.280" LastActivityDate="2021-02-01T17:16:56.280" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5649" PostTypeId="1" CreationDate="2021-02-01T18:55:52.473" Score="7" ViewCount="163" Body="&lt;p&gt;I'm looking for information concerning Genetic Algorithm (GA) outputs reliability.&#xA;I've found some papers applying metaheuristics that have run their algorithms 30 times and got the best solution among them. However, I did not find a consistent reference (i.e., book or scientific papers) affirming that 30 times is an appropriate quantity to run the algorithm. Does anyone know if there is a reference addressing that in more detail?&lt;/p&gt;&#xA;&lt;p&gt;Regarding the solution gaps of GA or other metaheuristics: Is there a consensus about it? For example, could I say that an algorithm is reliable if its solutions gap is lower than 10%?&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="491" LastEditDate="2021-02-03T17:57:07.047" LastActivityDate="2021-02-03T17:57:07.047" Title="Measuring performance of Genetic Algorithms" Tags="|reference-request|heuristics|metaheuristics|genetic-algorithm|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5650" PostTypeId="1" AcceptedAnswerId="5651" CreationDate="2021-02-01T19:35:04.580" Score="3" ViewCount="1306" Body="&lt;p&gt;I am a 2nd year PhD student in a (mostly) pure Mathematics department. I do not have any prior experience in applied mathematics, but I've recently had a change of heart and decided to study Optimization, with the purpose of going into industry after I graduate. I have started reading a couple optimization books (&lt;em&gt;Nonlinear Programming&lt;/em&gt; by Bersekas and &lt;em&gt;Numerical Optimization&lt;/em&gt; by Nocedal and Wright).&lt;/p&gt;&#xA;&lt;p&gt;I have a few basic questions about the field:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Are there dedicated &amp;quot;optimizers&amp;quot; who do nothing but Optimization? What is the job market like?&lt;/li&gt;&#xA;&lt;li&gt;Do most optimizers work for a company, or do they work as freelancers?&lt;/li&gt;&#xA;&lt;li&gt;From what I understand, an optimizer must have 3 skills&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Be familiar with many (most?) of the optimization algorithms currently known&lt;/li&gt;&#xA;&lt;li&gt;Have a deep, intuitive understanding of the algorithms so that you can guess which algorithm is best for which problem&lt;/li&gt;&#xA;&lt;li&gt;Know how to model a real world problem into an optimization one.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;How do I go about acquiring these skills? The first one I can get from textbooks, and I would guess for the second two I just have to develop experience by studying lots of real world problems. But where can I see examples of real world problems and solutions that I can learn from? Are there textbooks, papers, or websites about this?&lt;/p&gt;&#xA;" OwnerUserId="4563" LastEditorUserId="123" LastEditDate="2021-02-25T07:57:28.833" LastActivityDate="2021-02-25T07:57:28.833" Title="How to learn Optimization?" Tags="|optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5651" PostTypeId="2" ParentId="5650" CreationDate="2021-02-01T20:31:22.243" Score="9" Body="&lt;p&gt;The answer to this question is mostly opinion based and hence not so practical for stackexchange.&lt;/p&gt;&#xA;&lt;p&gt;Nevertheless, here is my take on this, having both experience in academia and industry. I would first distinguish between knowledge and skills:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;understanding of different optimization models and techniques (knowledge)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you must develop a toolbox of optimization methods, such that given a problem, you can apply the 'right' tool to solve the problem. This requires in-depth knowledge of various approaches to be able to assess what will and what won't work.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;understanding of a problem domain (knowledge)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it helps if you have at least 1 problem domain in which you are specialized, understand the different models commonly used to solve problems in that domain, know who else works in this domain, and know the state-of-the-art. Think about domains such as healthcare (e.g. nurse rostering), transportation (e.g. routing), or scheduling. You might argue that a person with optimization skills can tackle any problem domain, but in practice it helps a lot if you have prior knowledge in a particular domain.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;ability to implement models, programming (skills)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;particularly in industry, you must be able to implement, test and evaluate your models. Most companies require familiarity with a programming language (Java/C++/C#/Python), a solver (xpress/gurobi/cplex) and sometimes matlab.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;ability to process and analyse data, as well as to make results interpretable (skills)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;in the era of big-data, data processing and analysis skills are indispensable. Python and matlab are currently the most common. Knowledge of statistics is also a must.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;ability to distill the right optimization problem (skills)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;this is perhaps more of a soft-skill. Very often, when working in industry, the problems given to you will be highly ambiguous. Your task is to ask the right questions, and to distill the right problem to solve. More often than not, the people owning the problems are non-technical, have no optimization background and it will take a considerable amount of effort to understand the actual problem that requires solving (which might be very different from what is being asked by the problem owners).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When interviewing with a company, you will be tested on all of the above. If you have the knowledge but not the skills, or vice versa, you have a clear direction on what to improve. Obviously, the above knowledge and skills list is substantial and you won't master them all at once. The most natural approach is to get hands-on experience by working on practical problems. Read papers in a domain you are interested in, look for papers that are motivated by real-world problems (as opposed to a stylized academic problem), and pay attention to what data sources these papers use to perform their experimental evaluation. Just to give an example, both prof Bertsimas as well as prof van Hentenryck have some very interesting papers on online, large scale vehicle routing and ride-sharing/transit problems.&lt;/p&gt;&#xA;&lt;p&gt;Finally, there is often a difference between models you will find in academic papers and models that are used to solve industry problems. Models in industry are often required to be scalable, implementable, maintainable, interpretable, extendable, must often be developed within a very limited amount of time, must be able to handle all sorts of real-world side-constraints as well as uncertainty and inaccuracies in data input. In practice you will often have to make a compromise between performance and complexity.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2021-02-01T22:09:47.517" LastActivityDate="2021-02-01T22:09:47.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5652" PostTypeId="2" ParentId="5629" CreationDate="2021-02-01T22:57:09.523" Score="1" Body="&lt;p&gt;You might be interested in the paper published by Vladimir Kolmogorov in Mathematical Programming Computation (MPC), July 2009, 1(1), pp. 43-67: &amp;quot;Blossom V: A new implementation of a minimum cost perfect matching algorithm&amp;quot;. You can find the paper &lt;a href=&quot;http://pub.ist.ac.at/%7Evnk/papers/blossom5.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; together with a C++ implementation by the author &lt;a href=&quot;http://pub.ist.ac.at/%7Evnk/software.html#BLOSSOM5&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-02-01T22:57:09.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5653" PostTypeId="2" ParentId="5636" CreationDate="2021-02-02T01:17:20.430" Score="2" Body="&lt;p&gt;You can create a binary decision variable as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;m = Model(...)&#xA;my_var = m.binary_var(&amp;quot;name_of_this_var&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The variable is just an object and does not know how many indices it has. You can then maintain your own variable dictionary. So if you have a variable defined for the indices i,k,s,m,t, you could create a dictionary that maps keys defined as tuples to their corresponding variables:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var_dict[(i,k,s,m,t)]=m.binary_var(&amp;quot;name_of_this_var&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To create a large number of variables simultaneously, and to produce a dict or a list, consider using the factory methods &lt;code&gt;binary_var_dict&lt;/code&gt; or &lt;code&gt;binary_var_list&lt;/code&gt;. I recommend that you study the examples provided with docplex.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-02-02T01:17:20.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5656" PostTypeId="2" ParentId="5649" CreationDate="2021-02-02T13:41:51.897" Score="4" Body="&lt;p&gt;There is no magic. Considering that the algorithm is carefully designed, it is a matter of solution quality versus running time. If each run needs a lot of time to converge, running it 30 times could be too long for practical use. If the algorithm converges very fast, in milliseconds, why not running it hundreds of times.&lt;/p&gt;&#xA;&lt;p&gt;Now, if an iterative algorithm has been launched a large number of times to converge toward quality solutions, it means that the algorithm in question is more like a basic random search and then that this one is not so innovative from a scientific point of view. Nevertheless, in some cases (for example, when tackling highly non-convex problems), random search-like approaches with many restarts may be the best practical way to get quality solutions in short running times.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-02-02T13:41:51.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5657" PostTypeId="1" CreationDate="2021-02-02T16:41:19.613" Score="1" ViewCount="156" Body="&lt;p&gt;I have used deterministic optimization approaches before but never ventured into stochastic optimization.&lt;/p&gt;&#xA;&lt;p&gt;In my problem there are a number of decision variables that the optimizer must choose from in order to maximize the objective function. Each decision variable represents a gamble that it will either pay off or return 0.&lt;/p&gt;&#xA;&lt;p&gt;i.e. choosing between a selection of scratch cards each with a different prize and a different likelihood of winning.&lt;/p&gt;&#xA;&lt;p&gt;my gut feeling is that I can just put my objective function as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Maximize sum( choose[i] * prize[i] * likelihood[i] for i in scratchcards) within some constraints&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where &lt;em&gt;choose&lt;/em&gt; is the binary decision variable that is solved for&lt;/p&gt;&#xA;&lt;p&gt;In my simple (lazy) understanding the above is valid because it represents maximizing the &lt;em&gt;expected winnings&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So my question is; do I need to bother with some sort of stochastic optimization approach? or can I get away with the above?&lt;/p&gt;&#xA;" OwnerUserId="4903" LastEditorUserId="491" LastEditDate="2022-11-18T17:41:44.647" LastActivityDate="2022-11-18T17:41:44.647" Title="Do I need to use a stochastic optimization approach" Tags="|optimization|stochastic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5659" PostTypeId="2" ParentId="5649" CreationDate="2021-02-02T18:47:38.043" Score="3" Body="&lt;p&gt;Assuming the random seed is different every time, genetic algorithms (and by extension stochastic algorithms) are non-deterministic by nature, which is why they need to be run many times until we get &amp;quot;lucky&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;There is no meaningful &amp;quot;gap&amp;quot; per se in this context, as genetic algorithms can't rigorously bound the problem to generate an optimality gap. There can be an integrality gap, but this is not really meaningful for GA as they are not guaranteed to iteratively improve that gap.&lt;/p&gt;&#xA;&lt;p&gt;The probability of finding solutions is complicated to calculate, especially for MINLP problems, and I am not aware of any general proofs on convergence for general MINLPs. This means that the number of times the algorithm must be run varies on a case-by-case basis, and as far as I am aware the theoretical bound for that number for general problems is infinity.&lt;/p&gt;&#xA;&lt;p&gt;In practice, the main use case for these algorithms is for problems that are so large/computationally expensive that normal solvers can't handle them (e.g. industrial CFD or structural analysis). In these cases, we typically run the GA many times, and in many different configurations, until we get a solution that is &amp;quot;good enough&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;The secondary use case is for optimisation beginners, as GA are a great way of getting a workable solution without knowing much about the theory &amp;amp; algorithms.&lt;/p&gt;&#xA;&lt;p&gt;Running the problem 30 times is an empirical rule of thumb for expensive-ish problems, which usually translates to roughly a week or two of calculations (so about 6-12 hours/run). If we don't have a workable solution by then, we simply change how the algorithm mutates and hope for the best on the next batch.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-02-02T19:02:58.577" LastActivityDate="2021-02-02T19:02:58.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5660" PostTypeId="2" ParentId="5657" CreationDate="2021-02-02T19:00:46.230" Score="3" Body="&lt;p&gt;Whether maximizing expected winnings is an appropriate solution depends on the underlying problem and, crucially, the consumer of the solution (the problem &amp;quot;owner&amp;quot;). Two major considerations jump out at me. One is whether the owner requires a certain minimum payout with a certain probability, in which case you may need to use chance constrained programming (with the minimum payout captured in a chance constraint). For instance, the owner might say &amp;quot;I need to be at least 95% sure of winning at least this amount, or else I don't eat for a week&amp;quot;. The other is the utility of winnings, which depends on risk attitude. The value of winnings to the owner may not be a linear function of the dollar amount.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-02-02T19:00:46.230" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5661" PostTypeId="1" CreationDate="2021-02-03T08:00:14.060" Score="0" ViewCount="538" Body="&lt;p&gt;I have a pretty large data set with several independent variables and one variable that I would like to explain the behavior (dependent variable).&lt;/p&gt;&#xA;&lt;p&gt;What I want to do is find the linear coefficient and the independent variables that would minimize the error factor.&lt;/p&gt;&#xA;&lt;p&gt;In your opinion can I use an OR algorithm to setup the search of variables and coefficient until error is minimal? Have you ever tried this ?&lt;/p&gt;&#xA;" OwnerUserId="4145" LastEditorUserId="123" LastEditDate="2021-02-25T07:57:40.067" LastActivityDate="2021-02-25T07:57:40.067" Title="Operational research and Linear regression" Tags="|regression|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5662" PostTypeId="2" ParentId="5661" CreationDate="2021-02-03T10:23:52.923" Score="3" Body="&lt;p&gt;OR can help you in what you are doing. The &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/opre.2015.1436&quot; rel=&quot;nofollow noreferrer&quot;&gt;article&lt;/a&gt; you mentioned can help you to set the coefficient and also to select the variables (best subset selection) -- among other things (e.g., sparsity, robustness). &lt;a href=&quot;https://projecteuclid.org/euclid.aos/1458245736&quot; rel=&quot;nofollow noreferrer&quot;&gt;This other article&lt;/a&gt; is probably also worth looking at, since it focuses solely on features selection. It is a rather comprehensive approach. However, you should know that it results in a mixed-integer quadratic programming problem. With a too large dataset the resulting problem might become too difficult to solve.&lt;/p&gt;&#xA;&lt;p&gt;The alternative is, probably, trial and error: you define different models with different subsets of variables and compare them. Libraries for this are widely available in, e.g., Python (&lt;a href=&quot;https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;scikit-learn&lt;/a&gt;), R, or even MS Excel.&#xA;Compared with the above mentioned method, this is a heuristic approach: you may not find the best model. Nevertheless, it should be easier from a computational perspective, or at least scale better with the size of the dataset.&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="766" LastEditDate="2021-02-03T15:55:07.677" LastActivityDate="2021-02-03T15:55:07.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5663" PostTypeId="2" ParentId="5661" CreationDate="2021-02-03T22:18:12.057" Score="4" Body="&lt;p&gt;As mentioned in other responses, mixed-integer optimization can be used to simultaneously fit a model and select variables. Other possibilities include best-subset regression, which many (most?) statistics packages include, and &lt;a href=&quot;https://en.wikipedia.org/wiki/Lasso_(statistics)&quot; rel=&quot;nofollow noreferrer&quot;&gt;lasso regression&lt;/a&gt;, which uses optimization but does not involve integer programming.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-02-03T22:18:12.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5664" PostTypeId="1" CreationDate="2021-02-04T05:28:39.307" Score="1" ViewCount="78" Body="&lt;p&gt;There is no doubt that clear examples consolidate the understanding of concepts being learnt. I am new to finding the structure and decomposition of a polyhedra. Suppose that we have the system&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{bmatrix} 1 &amp;amp; 1 &amp;amp; 1 \\ -1 &amp;amp; 0&amp;amp; 0\\ 0 &amp;amp; -1 &amp;amp; 0 \\ 0 &amp;amp; 0 &amp;amp; -1  \end{bmatrix}  \begin{bmatrix} x_1 \\ x_2 \\ x_3  \end{bmatrix} \le \begin{bmatrix} 3 \\ 0 \\ 0  \end{bmatrix}$$&lt;/span&gt;&#xA;and we would like to find the decomposition as the direct sum of a&lt;/p&gt;&#xA;&lt;p&gt;(i) linearity space,&lt;/p&gt;&#xA;&lt;p&gt;(ii) cone,&lt;/p&gt;&#xA;&lt;p&gt;(ii) polytope.&lt;/p&gt;&#xA;&lt;p&gt;(iv) List the generators of each component and list the facets and minimal faces of each polyhedron.&lt;/p&gt;&#xA;&lt;p&gt;By definition the linearity space is synonymous to the null space of the coefficient matrix which is easy.&lt;/p&gt;&#xA;&lt;p&gt;The cone by definition is given as &lt;span class=&quot;math-container&quot;&gt;$\{x: x + y \in P, \ \forall y \in P\}\ldots (\alpha_1)\ \ $&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\ \ \{x: Ax \le 0\} \ldots (\alpha_2)$&lt;/span&gt;  where &lt;span class=&quot;math-container&quot;&gt;$A, P$&lt;/span&gt; are some matrix and polydrea respectively. Applying &lt;span class=&quot;math-container&quot;&gt;$(\alpha_1)$&lt;/span&gt;, I realized that &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^3$&lt;/span&gt; and so each &lt;span class=&quot;math-container&quot;&gt;$y's \in P$&lt;/span&gt; (column vectors) is in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R^4}$&lt;/span&gt; so since the dimensions of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are not compatible, how can &lt;span class=&quot;math-container&quot;&gt;$(\alpha_1)$&lt;/span&gt; be use in our problem above?&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$(\alpha_2)$&lt;/span&gt; how do find &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$Ax \le 0$&lt;/span&gt; holds? It looks like a null space but so far as I can remember, we don't have any inequality null space. A help here will be appreciated.&lt;/p&gt;&#xA;&lt;p&gt;For the polytope, it is stated as &lt;span class=&quot;math-container&quot;&gt;$P = cov.hull\{ x' \ldots \ x^m \}$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$A^{m \times n}.$&lt;/span&gt; Is the convex hull of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; the same as finding all submatrices of dimension &lt;span class=&quot;math-container&quot;&gt;$3\times 3$&lt;/span&gt; from our given matrix and find the unknown variables so that the constraints are satisfy? When I did that I got  a set of four linearly independent vectors in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^3.$&lt;/span&gt; Is this also correct? Could there be any better way of finding the convex hull?&lt;/p&gt;&#xA;&lt;p&gt;For generators, I have not come across a clear cut definition of it and it kind of confuses me with the vectors in the convex hull. Are they the same?&lt;/p&gt;&#xA;&lt;p&gt;The definition of a facet is such that it is the maximal face of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; not equal to &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;. That means we cannot find the facet without knowing all the possible faces of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;. Thus, is there any formula or tool available in finding the face and facets of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;? If so what are the faces and facets of our coefficient matrix above?&lt;/p&gt;&#xA;" OwnerUserId="4914" LastEditorUserId="4914" LastEditDate="2021-02-04T13:29:19.393" LastActivityDate="2021-02-04T13:29:19.393" Title="Decomposition of Polyhedra" Tags="|optimization|linear-programming|convex-optimization|convexity|polyhedra|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5666" PostTypeId="2" ParentId="5605" CreationDate="2021-02-05T08:24:42.937" Score="5" Body="&lt;p&gt;Yes. There are plenty of other approaches to handle multiple objectives. First of all, you need to figure out, what you consider an optimal solution (set) to your multi objective optimization problem. To name a few notions of optimality you might consider&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pareto optimality&lt;/li&gt;&#xA;&lt;li&gt;Lexicographic optimality (as @Kuifje suggests in a comment to the question)&lt;/li&gt;&#xA;&lt;li&gt;Max-ordering optimality&lt;/li&gt;&#xA;&lt;li&gt;Combinations of some of the above&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Next, you need to figure out a way to actually achieve an optimal solution (set). Here you also have quite a toolbox to choose from. I am most familiar with the methodology developed for finding the set of non-dominated outcome vectors (the image of the set of Pareto optimal solutions). I your problem is in fact a multi-objective linear program (MOLP) (no integer constrained variables) the following methods can be used to generate all non-dominated outcome vectors to your MOLP&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The perpendicular search method (a simple search strategy based on weighted sum scalarizations). This method is very easy to implement for two objectives, and not so easy to implement for more than two. A method for using this dichotomic search when having more than two objectives is described in this &lt;a href=&quot;https://doi.org/10.1287/ijoc.1090.0342&quot; rel=&quot;noreferrer&quot;&gt;paper&lt;/a&gt; by A. Przybylski, X. Gandibleux, and M. Ehrgott.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-constraint method&lt;/li&gt;&#xA;&lt;li&gt;The weighted &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-method&lt;/li&gt;&#xA;&lt;li&gt;Benson's method. Details of a primal-dual version is described in this &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2016.02.039&quot; rel=&quot;noreferrer&quot;&gt;paper&lt;/a&gt; by A. Löhne and B. Weißing. The algorithm is implemented in &lt;a href=&quot;https://www.bensolve.org&quot; rel=&quot;noreferrer&quot;&gt;BENSOLVE&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Generally, I would advice you to study chapter 2, 3, 4, and 5 in &lt;em&gt;Multicriteria Optimization&lt;/em&gt; by Matthias Ehrgott, 2nd edition. It gives a thorough and easy to follow indtroduction to the different optimality concepts and to some of the methods listed above.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-02-05T08:24:42.937" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5667" PostTypeId="2" ParentId="5661" CreationDate="2021-02-05T14:11:50.657" Score="2" Body="&lt;p&gt;By searching for &amp;quot;sparse linear regression&amp;quot; on the web, you will find a lot of interesting material on this topic. For example, have a look at &lt;a href=&quot;https://www.cs.cmu.edu/%7Eggordon/10725-F12/scribes/10725_Lecture2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this nice, comprehensive lecture&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As mentioned above, sparse linear regression can be modeled as a &lt;a href=&quot;https://link.springer.com/article/10.1007/s10898-018-0713-3&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mixed-Integer Quadratic Program&lt;/a&gt; and solved by using mathematical optimization solvers like LocalSolver. Nevertheless, it is generally tackled by &lt;a href=&quot;https://github.com/topics/sparse-regression&quot; rel=&quot;nofollow noreferrer&quot;&gt;heuristics&lt;/a&gt; in practice.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-02-05T14:11:50.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5668" PostTypeId="1" AcceptedAnswerId="5669" CreationDate="2021-02-05T16:57:59.050" Score="6" ViewCount="579" Body="&lt;p&gt;Consider several Integer (0/1) ILP variables, i.e., Boolean variables, &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;'s. Consider an ILP constraint &lt;span class=&quot;math-container&quot;&gt;$x_1 + x_2 + x_3 \geq 1$&lt;/span&gt; and another constraint &lt;span class=&quot;math-container&quot;&gt;$x_4 + x_5 + x_6 \geq 1$&lt;/span&gt;. I would like to represent that exactly one such constraint is satisfied, ie. if &lt;span class=&quot;math-container&quot;&gt;$x_1 + x_2 + x_3 \geq 1$&lt;/span&gt; is satisfied, the constraint &lt;span class=&quot;math-container&quot;&gt;$x_4 + x_5 + x_6 \geq 1$&lt;/span&gt; should not be satisfied and vice versa. How can such a constraint be represented? In the example, there are two constraints, how can it be generalized to any number of similar constraints? Variables are unique across constraints, i.e., variables which occur in the first constraint do not occur in the other constraints.&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="584" LastEditDate="2021-02-05T17:31:51.907" LastActivityDate="2021-02-05T19:15:05.833" Title="ILP Constraint to ensure exactly one constraint from a set of constraints is satisfied" Tags="|optimization|modeling|integer-programming|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5669" PostTypeId="2" ParentId="5668" CreationDate="2021-02-05T17:56:35.093" Score="10" Body="&lt;p&gt;You can add an extra binary that equals &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if the first constraint is satisfied:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_1+x_2+x_3 &amp;amp;\ge \delta\\&#xA;x_1+x_2+x_3 &amp;amp;\le 3\delta\\&#xA;x_4+x_5+x_6 &amp;amp;\ge 1 - \delta\\&#xA;x_4+x_5+x_6 &amp;amp;\le 3(1 - \delta)\\&#xA;\delta &amp;amp;\in \{0,1\}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\delta=1$&lt;/span&gt;, the first two constraints become:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;1 \le x_1+x_2+x_3 \le 3&#xA;$$&lt;/span&gt;&#xA;And the last two:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;0 \le x_4+x_5+x_6 \le 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And likewise the other way around if &lt;span class=&quot;math-container&quot;&gt;$\delta=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can easily generalize this approach by adding as many binaries as necessary (one for each pair of constraints), and by adapting the &amp;quot;big-M&amp;quot; values (&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; in the above example).&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-02-05T19:15:05.833" LastActivityDate="2021-02-05T19:15:05.833" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5670" PostTypeId="2" ParentId="5605" CreationDate="2021-02-05T19:03:08.603" Score="3" Body="&lt;p&gt;To Sune's list, I'll add goal programming, in which you set targets for your objectives (possibly more than one target for a single objective), prioritize them, then minimize unfavorable deviations from the target in priority order.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-02-05T19:03:08.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5672" PostTypeId="1" CreationDate="2021-02-06T11:15:31.020" Score="2" ViewCount="166" Body="&lt;p&gt;I have solved a very simple mathematical model ( 2 variables) using Gurobi in Python and now I want to fix the amount of the variable in another model and solve it, for example, consider the variable &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; is solved and it is equal to &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;, and now I want to add it to another mathematical programming as an input (parameter) the problem is, Gurobi expects the &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; to be a variable, not a parameter wich finally gives the error &amp;quot;Variable not in model&amp;quot;, I would appreciate it if anyone can help me with this issue.&lt;/p&gt;&#xA;" OwnerUserId="4924" LastEditorUserId="2556" LastEditDate="2021-02-06T11:24:18.083" LastActivityDate="2021-02-06T11:24:18.083" Title="Fixing the amount of variable in Gurobi - Python as a parameter for another model" Tags="|python|gurobi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5673" PostTypeId="2" ParentId="5672" CreationDate="2021-02-06T11:23:51.920" Score="2" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_2^1$&lt;/span&gt; be the variable in the first model, and &lt;span class=&quot;math-container&quot;&gt;$x_2^2$&lt;/span&gt; be the corresponding variable in the second model. Also, let &lt;span class=&quot;math-container&quot;&gt;$\hat{x}_2^1$&lt;/span&gt; be the optimal value of &lt;span class=&quot;math-container&quot;&gt;$x_2^1$&lt;/span&gt;, after solving the first model.&lt;/p&gt;&#xA;&lt;p&gt;So if you want to add the optimal value of &lt;span class=&quot;math-container&quot;&gt;$x_2^1$&lt;/span&gt; in the second model, use the constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_2^2 = \hat{x}_2^1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2021-02-06T11:23:51.920" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5674" PostTypeId="1" AcceptedAnswerId="5675" CreationDate="2021-02-06T11:36:40.527" Score="5" ViewCount="244" Body="&lt;p&gt;Let us consider the following problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max &amp;amp;\quad\sum_{i=1}^n\sum_{j=1}^m v_{i,j}\cdot x_{i,j} \\&#xA;\text{s.t.}&amp;amp;\quad \sum_{i=1}^n x_{i,j} =1 &amp;amp;\forall j =1,\dots,m \\&#xA;&amp;amp;\quad \sum_{i=1}^n\sum_{j=1}^m w_i\cdot x_{i,j} = W &amp;amp; \\&#xA;&amp;amp;\quad x_{i,j} \in \mathbb{B} &amp;amp;\forall i =1,\dots,n,\quad \forall j =1,\dots,m&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would like to prove that this problem is NP-hard. I know that the multiple choice knapsack problem is NP-hard. However, there are two substantial differences with our problem:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The weights of all item within a class are equal (i.e. we have &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$w_{i,j}$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;li&gt;The capacity constraint must be satisfied by equality.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Therefore, my problem is a special case of the multiple choice knapsack problem, or: multiple choice knapsack problem is a generalisation of my problem. Therefore, I suspect that I can not reduce my problem from the multiple choice knapsack problem.&lt;/p&gt;&#xA;&lt;p&gt;Still, I strongly suspect that the problem above is NP-hard. Am I missing something?&lt;/p&gt;&#xA;" OwnerUserId="4820" LastEditorUserId="123" LastEditDate="2021-02-07T10:35:19.783" LastActivityDate="2021-02-07T10:35:19.783" Title="NP-hardness of a special case of multiple choice knapsack problem" Tags="|computational-complexity|knapsack|assignment-problem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5675" PostTypeId="2" ParentId="5674" CreationDate="2021-02-06T13:53:48.527" Score="3" Body="&lt;p&gt;I think the problem is NP-hard since:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;it will reduce to the 0-1 Knapsack problem with an equality constraint; and,&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;changing &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; in the 0-1 Knapsack constraint does not change its complexity (see explanation below).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;So, your problem is NP-hard as 0-1 Knapsack is.&lt;/p&gt;&#xA;&lt;p&gt;P.S.&#xA;To see why (2) is correct, suppose all weights and values are equal. Then the problem reduces to the subset sum problem, that is also NP-hard.&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2021-02-06T14:51:47.163" LastActivityDate="2021-02-06T14:51:47.163" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5676" PostTypeId="1" AcceptedAnswerId="5677" CreationDate="2021-02-06T18:28:53.600" Score="4" ViewCount="355" Body="&lt;p&gt;I am looking for a book recommendation on the VRP and variants.  I am encountering VRP-like problems more and more in my work and would appreciate a reference.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastEditorUserId="196" LastEditDate="2021-02-07T02:10:10.123" LastActivityDate="2021-02-07T02:10:10.123" Title="VRP book recommendations" Tags="|reference-request|vehicle-routing|logistics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5677" PostTypeId="2" ParentId="5676" CreationDate="2021-02-06T23:31:30.823" Score="8" Body="&lt;p&gt;If there is one book to know about VRPs, it is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1137/1.9781611973594&quot; rel=&quot;noreferrer&quot;&gt;&amp;quot;Vehicle Routing: Problems, Methods, and Applications, Second Edition&amp;quot; (Paolo Toth and Daniele Vigo, 2014)&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2021-02-06T23:31:30.823" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5678" PostTypeId="1" CreationDate="2021-02-07T15:22:51.390" Score="2" ViewCount="124" Body="&lt;p&gt;Let's say we have a kiosk inside gas station selling cigarettes and snacks outside a supermarket. There are limited space for each product. The kiosk only allows to get restocked from the supermarket, so there's &lt;strong&gt;no&lt;/strong&gt; lead time to restock. The objective is to figure out what is the ideal BOH(balance on hand )value or (s,S), (r,Q) for each product to minimize the lost sales. There's &lt;strong&gt;no&lt;/strong&gt; labor or any type of cost. We have the ability to monitor the BOH every day.  Another question is that some people buy a carton of cigarette rather than an individual pack, and I think we need to treat them as different product.  We can only restock once per day.&lt;/p&gt;&#xA;&lt;p&gt;My thinking: since each product has fixed self space(could be changed based in the future), this space number becomes the &lt;strong&gt;S&lt;/strong&gt;.  The problems becomes to find the right safe stock &lt;strong&gt;s&lt;/strong&gt; considering the demand(could be bootstrapped from history or forecast).&lt;/p&gt;&#xA;&lt;p&gt;Is there any inventory model for this kind of problem? Is it too over-simplified?&lt;/p&gt;&#xA;" OwnerUserId="1219" LastEditorUserId="1219" LastEditDate="2021-02-08T13:04:54.317" LastActivityDate="2021-02-09T10:52:04.080" Title="inventory control for vending machine like mini store" Tags="|inventory|rq-inventory-model|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5679" PostTypeId="1" CreationDate="2021-02-07T18:28:42.577" Score="5" ViewCount="88" Body="&lt;p&gt;Given an primal optimization with bounded feasible set: &lt;span class=&quot;math-container&quot;&gt;$\max \{cx: Ax \leq b\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The feasible region of the dual is &lt;span class=&quot;math-container&quot;&gt;$D = \{y:y^\top A = c^\top, y \geq 0\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If the primal feasbile region is a polytope, then the dual might still by an polyhedron (not bounded in all directions).&lt;/p&gt;&#xA;&lt;p&gt;Each polyhedron can be written as a convex part plus a cone (&lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;-representation of polytopes).&lt;/p&gt;&#xA;&lt;p&gt;How can I get an upper bound &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; on the values of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in the convex part?&#xA;(the bound should say that all verticies of &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; have entries smaller than &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;?)&lt;/p&gt;&#xA;&lt;p&gt;The bound obviously needs to depend on &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2021-02-07T21:05:40.890" LastActivityDate="2021-02-07T21:05:40.890" Title="Bounding the size of the dual solution" Tags="|integer-programming|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5680" PostTypeId="1" CreationDate="2021-02-09T04:32:53.433" Score="2" ViewCount="325" Body="&lt;p&gt;I am interested in solving a set of maximization problems where those problems only just differ in their objective. The objective functions are all linear and the constraints are all just affine. I was wondering what is the most efficient way to implement it using CPLEX since I would like the solver to reuse as much information across the different solves. The problems are solved sequentially one after the other (as shown in the for loop below). I tried to get this information from the CPLEX manual, but I was unsuccessful. Any help would be appreciated. Below I have provided a snippet from my code (in C++), any advice on improving its speed will be great.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;IloEnv env;&#xA;IloModel model(env);        &#xA;IloNumVarArray vec_x_vars(env);&#xA;&#xA;// I call a function here to populate constraints into the model&#xA;&#xA;std::vector&amp;lt;IloNumArray&amp;gt; vec_obj_coeffs; //Assume this vector contains all the different linear objectives&#xA;&#xA;IloExpr obj_expr(env);&#xA;for(size_t uiIndex = 0; uiIndex &amp;lt; vec_objectives.size(); uiIndex++)&#xA;{&#xA;   obj_expr.setLinearCoefs(vec_x_vars, vec_objectives[uiIndex]);&#xA;   IloObjective obj = IloMaximize(env, obj_expr);&#xA;   model.add(obj);&#xA;   IloCplex cplex(model);&#xA;   cplex.solve();&#xA;   model.remove(obj);&#xA;}&#xA;obj_expr.end();&#xA;vec_x_vars.end();&#xA;env.end();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is the implementation above the best possible in terms of efficiency that we can get?&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2021-02-09T05:50:47.930" LastActivityDate="2021-02-09T06:36:27.347" Title="Solving multiple problems with identical constraints but different objective function using CPLEX" Tags="|cplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5681" PostTypeId="2" ParentId="5680" CreationDate="2021-02-09T06:36:27.347" Score="3" Body="&lt;p&gt;The only thing I would change is to add the IloObjective object outside the loop and then set the coefficients directly in this object. That way you avoid adding and removing the objective function to/from the model. Whether it is significantly faster, I have no idea, unfortunately.&lt;/p&gt;&#xA;" OwnerUserId="609" LastActivityDate="2021-02-09T06:36:27.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5682" PostTypeId="2" ParentId="5678" CreationDate="2021-02-09T10:52:04.080" Score="1" Body="&lt;p&gt;I think you could use a simple continuous-review base-stock policy, as @LarrySnyder610 mentioned too. About the inventorying each product to minimize the lost sales, first of all, you will need to forecast demand for each product in a specific time bucket, (e.g. weekly sales). Based on, further, you would be able to calculate the inventory level and replenishment periods for each item. Also, are being able to capture customers favours based on their frequent orders to stock items.&lt;/p&gt;&#xA;&lt;p&gt;As you said, you do not have any specific cost, such as labour or logistics costs, it would be easy to replenishment the kiosk storage area by your own at the end of the day. Indeed, you might be interesting to use shared storage policy in contrast fixed storage policy to increase sales flexibility.&lt;/p&gt;&#xA;&lt;p&gt;Finally, to control the inventory level of each item, you would not need to use any specific software and all of the things might be applied in the separate sheet, like excel.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-02-09T10:52:04.080" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5683" PostTypeId="1" AcceptedAnswerId="5684" CreationDate="2021-02-09T13:37:32.897" Score="2" ViewCount="755" Body="&lt;p&gt;I am in the process of solving the VRP and I have a set of Solomon test instances to test my program.&lt;/p&gt;&#xA;&lt;p&gt;I actually found a test set with &lt;code&gt;C101, C102, ...&lt;/code&gt;, &lt;code&gt;R101, R102, ...&lt;/code&gt; and &lt;code&gt;RC201, RC202, ...&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My question is what is the difference or the characteristics of each set (&lt;code&gt;C&lt;/code&gt;, &lt;code&gt;R&lt;/code&gt;, and &lt;code&gt;RC&lt;/code&gt;) ?&lt;/p&gt;&#xA;" OwnerUserId="4940" LastEditorUserId="123" LastEditDate="2021-02-09T14:44:23.940" LastActivityDate="2021-02-09T14:44:23.940" Title="Difference between Solomon's problem instances" Tags="|vehicle-routing|test-instances|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5684" PostTypeId="2" ParentId="5683" CreationDate="2021-02-09T13:53:56.097" Score="3" Body="&lt;p&gt;There is a good description of different problem instances &lt;a href=&quot;http://www.bernabe.dorronsoro.es/vrp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. From the link:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;...benchmark problems (Solomon, 1987) composed of six different problem types (C1,C2,R1,R2,RC1,RC2). Each data set contains between eight to twelve 100-node problems. The names of the six problem types have the following meaning. Sets C have clustered customers whose time windows were generated based on a known solution. Problem sets R have customers location generated uniformly randomly over a square. Sets RC have a combination of randomly placed and clustered customers. Sets of type 1 have narrow time windows and small vehicle capacity. Sets of type 2 have large time windows and large vehicle capacity. Therefore, the solutions of type 2 problems have very few routes and significantly more customers per route.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="36" LastActivityDate="2021-02-09T13:53:56.097" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5685" PostTypeId="1" CreationDate="2021-02-09T18:41:44.667" Score="4" ViewCount="203" Body="&lt;p&gt;I am trying to solve the capacitated vehicle routing problem (CVRP) with the ALNS metaheuristic.&lt;/p&gt;&#xA;&lt;p&gt;To test the performance of my algorithm I run it 10 times and I want to calculate the average of the results obtained in each run.&lt;/p&gt;&#xA;&lt;p&gt;My question is: is the calculation of the average in this case done quite simply by the formula &lt;code&gt;avg = Sum of all values ​​÷ number of values&lt;/code&gt;, or is there another way to calculate the average to evaluate the results of metaheuristics?&lt;/p&gt;&#xA;" OwnerUserId="4940" LastEditorUserId="123" LastEditDate="2021-02-09T21:19:36.570" LastActivityDate="2021-02-09T21:19:36.570" Title="Calculate the average of the objective function values ​resulting from metaheuristics after a defined number of executions" Tags="|vehicle-routing|metaheuristics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5686" PostTypeId="2" ParentId="5685" CreationDate="2021-02-09T18:51:40.817" Score="7" Body="&lt;p&gt;There are multiple ways you can analyze and compare the results of heuristics/randomized search procedures.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Report the average, best and worst&lt;/li&gt;&#xA;&lt;li&gt;Report the average, and standard deviation&lt;/li&gt;&#xA;&lt;li&gt;Graphically represent the results as a boxplot.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;When computing the average, you need to be careful when there are instances that could not be solved by the heuristic. This holds in particular for problems where finding a feasible solution is challenging. In such a case, one should also report the number of instances for which a feasible solution was found.&lt;/p&gt;&#xA;&lt;p&gt;Finally note that just reporting an objective value is not necessary very informative. In many cases, reporting the (average) optimality gap is much more insightful.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-02-09T18:51:40.817" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5687" PostTypeId="1" CreationDate="2021-02-10T16:01:19.890" Score="2" ViewCount="498" Body="&lt;p&gt;I need to implement a load scheduling algorithm that involves solving an online optimisation problem from a research paper for my Real time systems course.&#xA;This convex optimisation problem is setup through Model predictive control or receding horizon control. This problem involves under 100 decision variables. I am just googling about solvers and it would be great if you can give me more accurate suggestions about specific numerical solvers available in python for solving these kinds of cost functions (quadratic + one norm + infinity norm) and constraints (both equality and inequality). I think its convex (single minimum) because the author says so.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;If you are an expert you dont have to read the contents below just click and look at the Optimzation problem formulation below and suggest to me a solver or links to a solver in python, Thanks :)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Aniyc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimzation problem formulation&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9EuoB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;constraints description&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Full paper at this link: &lt;a href=&quot;https://github.com/JosePeeterson/pdf_hosting/blob/master/paper_2_RTS.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Full paper&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Please see the cost function and constraints in the link above.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Brief description of the problem:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;We want to schedule tasks (i.e. power allocation) that maximises power allocation from renewable sources, W to Electric vehicle (EV) loads, E that have some timing deadlines, di (due to running out of charge). We should minimize the use of grid energy sources, G and only use it in the worst case when EV load demand cannot be satisfied using renewable sources.&lt;/p&gt;&#xA;&lt;p&gt;In the objective function the matrix W represents renewable energy/power allocation for task i at time step k. we look into N time steps into the future from the current time step, t.&#xA;Say we have a renewable energy forecast chart that predicts the maximum output power at future times like in &lt;a href=&quot;https://i.stack.imgur.com/hcX18.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;renewable generation forecast graph&lt;/a&gt;. Matrix G is grid generated power/energy also indexed similarly to W and is available at all times. Total power/energy supplied to load E is W + G. phi (flexibility factor) is the term that implicitly brings W into the cost fucntion. we try to keep phi large so that we can always defer load scheduling to future times if renewable power/energy is not sufficiently available for the time being and maybe available in the future.  Note: the size/dimension (MXN) of matrix W and G is decreasing as we approach end of active tasks list in the time horizon N. As tasks in active tasks get completed and as we approach the last deadline in active task list M and N are decreasing.&lt;/p&gt;&#xA;&lt;p&gt;In constraint 7, we put a cap on the maximum renewable energy available for all the M tasks up to N time steps using the renewable energy forcast data given below.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/hcX18.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;renewable generation forecast graph&lt;/a&gt;&#xA;constraint 8 is a conservation equation W and G power/energy supplied equals load energy required, E for the M tasks.&#xA;In constriant 9 mi is maximum power that can be supplied to the load due to loads physical limitation.&#xA;In contraint 10 and 11, di is the deadline of task i, delta t is time step for within which the optimisation must be solved. ei(k) is the remanining energy required for the task to complete.&lt;/p&gt;&#xA;&lt;p&gt;From this description please suggest solvers or links to solvers that can be used in python.&lt;/p&gt;&#xA;&lt;p&gt;Thank you!!&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VZTm3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper abstract&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4945" LastActivityDate="2021-02-11T19:52:47.080" Title="Recommended python solver for an online optimization problem" Tags="|python|solver|convex-optimization|implementation|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5688" PostTypeId="1" AcceptedAnswerId="5689" CreationDate="2021-02-10T18:07:41.243" Score="4" ViewCount="1434" Body="&lt;p&gt;Until now, I used CPLEX to solve single-objective optimization problems only,&#xA;but now I need to solve a two-objective mixed-integer linear optimization problem and I noticed that CPLEX 12.6.9 (unlike its previous versions) is able to accomplish this.&lt;/p&gt;&#xA;&lt;p&gt;So, I'm wondering about two questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Which algorithm does CPLEX use to solve two-objective problems?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Maybe this piece of text (copied from &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/multiobj/multiobj_solving.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPLEX Official Page&lt;/a&gt;) could answer my question..&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The CPLEX multiobjective optimization algorithm sorts the objectives&#xA;by decreasing priority value. If several objectives have the same&#xA;priority, they are blended in a single objective using the weight&#xA;attributes provided. As a result, CPLEX constructs a sorted list of&#xA;objectives (or blended objectives), each with a unique priority. CPLEX&#xA;can then proceed to find the lexicographically minimal (or maximal)&#xA;solution for this order. To obtain this solution, each objective is&#xA;optimized in turn by decreasing order of the priority value in a&#xA;hierarchical manner. Whenever the optimal solution for an objective&#xA;(or blended objective) is found, CPLEX imposes that, for the remaining&#xA;(lower priority) objectives, the only solutions considered are those&#xA;that are also optimal for the previously (higher priority) optimized&#xA;objectives.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;What are the main advantages/disadvantages between, solving a two-objective optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;a) by &lt;strong&gt;passing it directly as a two-objective problem to CPLEX&lt;/strong&gt;, or&lt;/p&gt;&#xA;&lt;p&gt;b) by &lt;strong&gt;solving it&lt;/strong&gt;, in CPLEX, &lt;strong&gt;by&lt;/strong&gt; adopting the &amp;quot;&lt;strong&gt;Augmented Epsilon-Constraint&lt;/strong&gt; Method&amp;quot;?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I guess that &lt;strong&gt;a)&lt;/strong&gt; could allow writing less code, but I don't know anything about differences in terms of efficiency, computational time, etc.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, I'm wondering if these two methods may generate different solutions.&lt;/p&gt;&#xA;" OwnerUserId="4944" LastEditorUserId="36" LastEditDate="2021-02-10T20:49:12.057" LastActivityDate="2021-02-10T22:14:10.753" Title="Two-Objective Optimization in CPLEX" Tags="|optimization|mixed-integer-programming|linear-programming|cplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5689" PostTypeId="2" ParentId="5688" CreationDate="2021-02-10T19:53:46.533" Score="5" Body="&lt;p&gt;The augmented &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-constraint method is designed to generate &lt;em&gt;all&lt;/em&gt; non-dominated outcome vectors to a bi-objective (or multi objective) optimization problem, whereas a lexicographic optimization approach is designed to generate one particular non-dominated outcome vector to bi-objective (or multiobjective) problem. So it all depends on what you want to achieve.&#xA;Given that a lexicographic optimal solution is one among many efficient solutions one should expect that using an &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-constraint method to generate all efficient solutions is computationally much harder than just finding a lexicographic optimum.&#xA;To explicitly address your last question : a) gives you one solution and b) gives you a &lt;em&gt;set&lt;/em&gt; of solutions.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-02-10T19:53:46.533" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5690" PostTypeId="2" ParentId="5688" CreationDate="2021-02-10T22:14:10.753" Score="4" Body="&lt;p&gt;As Sune noted, the &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-constraint method is not comparable to what CPLEX does, since it finds all Pareto efficient solutions. In case you were thinking of option 2 as finding a lexicographic optimum by optimizing the highest priority objective, constraining it to be optimal, optimizing the next highest priority objective etc. (similar to but not the same as the &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-constraint method), I would expect CPLEX's version to be more efficient.&lt;/p&gt;&#xA;&lt;p&gt;Disclaimer: What follows is conjecture, since I'm not privy to the internal workings of CPLEX. CPLEX maintains a solution pool (feasible but not necessarily optimal solutions encountered along the way). By dropping solutions from the pool only when they are lexically dominated by a new solution, it can in effect get a head start on each subsequent objective (using the pool solution with the best value of that objective as an incumbent). Also, it can modify the rules for pruning nodes so that a node is pruned only if the bound is &lt;em&gt;strictly inferior&lt;/em&gt; to the best known value of the highest priority goal. Not pruning nodes where the bound ties the best known value (or removing them from the current search tree and adding them to a &amp;quot;shadow&amp;quot; tree for later searching) allows it to come back later, when it has finished optimizing the first objective, and search for nodes that match the optimal value of the first objective and improve on the second (or subsequent) objective without wandering through parts of the original search tree that were ruled out.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-02-10T22:14:10.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5691" PostTypeId="1" AcceptedAnswerId="5692" CreationDate="2021-02-11T09:52:58.900" Score="3" ViewCount="1340" Body="&lt;p&gt;I have a question regarding pyomo. I have seen quite often, that for the definition of parameters, objectives and constraints, explicit functions are defined. These functions expect some arguments and in Pyomo most often they are not passed when calling. I do not understand how this is possible. Here is an example (taken from &lt;a href=&quot;https://pyomo.readthedocs.io/en/doc-testbuild/pyomo_modeling_components/Parameters.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pyomo.readthedocs.io/en/doc-testbuild/pyomo_modeling_components/Parameters.html&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def s_init(model, i, j):&#xA;    if i == j:&#xA;        return i*i&#xA;    else:&#xA;        return 0.0&#xA;model.S2 = pyo.Param(model.A, model.A, initialize=s_init)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The function &lt;code&gt;s_init&lt;/code&gt; requires 3 parameters: &lt;code&gt;model&lt;/code&gt;, &lt;code&gt;i&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;. However when calling the function no parameter is being passed &lt;code&gt;initialize=s_init&lt;/code&gt;. So I am wondering how this is possible? While the parameter model has been defined (maybe it can be regarded as a static variable like in Java), I have no clue where the function takes the parameters &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;j&lt;/code&gt; from.&lt;/p&gt;&#xA;&lt;p&gt;Can anybody tell me more about this? I'd appreciate every comment and will be quite thankful for your help.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="123" LastEditDate="2021-02-11T10:25:15.580" LastActivityDate="2021-02-11T19:37:02.723" Title="Why functions with arguments can be called without arguments in Pyomo" Tags="|python|pyomo|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5692" PostTypeId="2" ParentId="5691" CreationDate="2021-02-11T15:50:57.147" Score="4" Body="&lt;p&gt;From the syntax used in your specific example, &lt;code&gt;s_init&lt;/code&gt; is most likely used as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Callback_(computer_programming)&quot; rel=&quot;nofollow noreferrer&quot;&gt;callback&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here's a simple Python example of how this works:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def get_square(val):&#xA;...     &amp;quot;&amp;quot;&amp;quot;The callback.&amp;quot;&amp;quot;&amp;quot;&#xA;...     return val ** 2&#xA;...&#xA;&amp;gt;&amp;gt;&amp;gt; def caller(func, val):&#xA;...     return func(val)&#xA;...&#xA;&amp;gt;&amp;gt;&amp;gt; caller(get_square, 5)&#xA;25&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;More broadly speaking, many languages, including Python and C++, also provide syntax for optional arguments to methods. Depending on the language/syntax used, they don't even need to be in a specific order. If you don't provide everything, default values will be used instead for that method, assuming the developer has coded that logic into that specific method. &lt;code&gt;Param()&lt;/code&gt; has optional arguments, so you need to tell Python that the third argument (&lt;code&gt;s_init&lt;/code&gt;) should be used to populate a variable called &lt;code&gt;initialize&lt;/code&gt; with data.&lt;/p&gt;&#xA;&lt;p&gt;In this particular case, this data is a reference to the function (&lt;code&gt;s_init&lt;/code&gt;). You can tell by the lack of parentheses. &lt;code&gt;s_init()&lt;/code&gt; would call the function, while &lt;code&gt;s_init&lt;/code&gt; is a reference to the function. What happens next really depends on how that information is used by Param, but syntactically this is simply passing a reference as an optional argument.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-02-11T19:37:02.723" LastActivityDate="2021-02-11T19:37:02.723" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="5693" PostTypeId="2" ParentId="5687" CreationDate="2021-02-11T19:52:47.080" Score="2" Body="&lt;p&gt;Assuming you are writing the norms as explicit mathematical expressions (e.g. &lt;span class=&quot;math-container&quot;&gt;$|x_1|+|x_2|...$&lt;/span&gt;) you can just use our own &lt;a href=&quot;https://octeract.com/octeract-engine/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Engine&lt;/a&gt;. As of next Monday (15 Feb 2021) it's free for everyone, and it will most likely destroy any problem that size, especially compared to any open source solver I could recommend as an alternative. It has a &lt;a href=&quot;https://octeract.com/how-to-use-python-with-the-engine/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python API&lt;/a&gt;, and also &lt;a href=&quot;https://octeract.com/pyomo-with-the-engine/&quot; rel=&quot;nofollow noreferrer&quot;&gt;works with Pyomo&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you do want to try open-source, the only alternative that I know of (although I'm sure there are others) that could handle the norm expressions out-of-the-box is &lt;a href=&quot;https://github.com/coin-or/Couenne&quot; rel=&quot;nofollow noreferrer&quot;&gt;Couenne&lt;/a&gt;, so you can also try that out. Couenne also works with Pyomo but AFAIK doesn't have a Python API.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-02-11T19:52:47.080" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5694" PostTypeId="2" ParentId="4250" CreationDate="2021-02-11T19:59:25.000" Score="3" Body="&lt;p&gt;The most hands-on way I can recommend is to try and write a prototype solver in your area of interest. It doesn't need to be anything fancy, you can just focus on solving, say, 5-variable problems. You don't even need to succeed.&lt;/p&gt;&#xA;&lt;p&gt;In the process of trying to do this you will be forced to understand the theory correctly (otherwise you'll keep getting wrong numbers), and you will gain insights most people don't have about why models are best written in certain ways.&lt;/p&gt;&#xA;&lt;p&gt;Once you understand the fundamental solving algorithms, going deeper into the theory becomes much easier.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-02-11T19:59:25.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5695" PostTypeId="2" ParentId="4250" CreationDate="2021-02-12T04:30:22.207" Score="3" Body="&lt;p&gt;I get a sense that you have correct background to get started in OR. The thing with OR however is that its a diverse field with multitude of different problem types and the typical challenges that arise in solving them. In my opinion, it becomes difficult then to compile them into one textbook that covers it all. You may find textbooks on specific sub topics though. That being said, there is one book that still qualifies as beginner friendly OR textbook. Its called Model Building in Mathematical Programming. &lt;a href=&quot;http://pourghaderi.com/wp-content/uploads/2018/12/Wiliams-Model-Building-in-Mathematical-Programming-5th-2013.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Its openly available&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Next thing you might need is to practice the concepts. For this, if you have a Python background, my recommendation would be to look at Pyomo. Its a well maintained and widely used library for solving numerical optimization problems with integration support for open source and commercial solvers. There are examples online. Getting started, this will give you some push in the right direction.&lt;/p&gt;&#xA;&lt;p&gt;Good Luck!&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2021-02-12T04:30:22.207" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5696" PostTypeId="2" ParentId="3357" CreationDate="2021-02-12T04:34:45.730" Score="2" Body="&lt;p&gt;I think the best one is &lt;a href=&quot;http://pourghaderi.com/wp-content/uploads/2018/12/Wiliams-Model-Building-in-Mathematical-Programming-5th-2013.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;:&#xA;Model Building in Mathematical Programming.&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2021-02-12T04:34:45.730" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5697" PostTypeId="2" ParentId="5592" CreationDate="2021-02-12T04:45:26.367" Score="2" Body="&lt;p&gt;I assume one way to gain good level of interpretation of solver's result in optimization (especially in a high dimensional setting) is by doing something called &lt;strong&gt;Scenario Discovery&lt;/strong&gt;. You can read more about this from linked papers &lt;a href=&quot;https://www.rand.org/pardee/pubs/futures_method/scenario_discovery.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2021-02-12T04:45:26.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5698" PostTypeId="1" CreationDate="2021-02-12T23:41:27.777" Score="4" ViewCount="218" Body="&lt;p&gt;I have an assignment problem as follows&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{equation}&#xA; \begin{array}{*{35}{l}}&#xA;\underset{d_{u,c}}{\max}\hspace{1mm}\hspace{1mm}\sum_{u=1}^{U}\sum_{c=1}^{C}d_{u,c}\omega_{u,c}\\&#xA;\text{}\text{subject to }\text{ C1:} \hspace{2mm}1\le \sum_{c=1}^Cd_{u,c}\le 10,\forall u, u=1,\cdots, U, \\&#xA;\text{}\hspace{16.5mm}\text{ C2:} \hspace{2mm}\sum_{u=1}^U d_{u,c}\le 50,\forall c, c=1,\cdots, C, \\&#xA;\end{array}&#xA;\end{equation}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective is to maximise the quality/quality.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way I can solve this problem heuristically but optimally?&#xA;For example, some iterative approach?&lt;/p&gt;&#xA;&lt;p&gt;What I tried:&lt;/p&gt;&#xA;&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, I find the &lt;span class=&quot;math-container&quot;&gt;$C_{\max}$&lt;/span&gt; largest values for &lt;span class=&quot;math-container&quot;&gt;$\omega_{u,c}$&lt;/span&gt; and assign them to corresponding &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;'s.&lt;/p&gt;&#xA;&lt;p&gt;Then Find the number of assignment we get for each &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If for some &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, we have higher than &lt;span class=&quot;math-container&quot;&gt;$U_{\max}$&lt;/span&gt; assignments, find the &lt;span class=&quot;math-container&quot;&gt;$X_c$&lt;/span&gt; number of lowest  (&lt;span class=&quot;math-container&quot;&gt;$X_c$&lt;/span&gt; is the number of extra assignments for &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;) values of assigned &lt;span class=&quot;math-container&quot;&gt;$\omega_{u,c}$&lt;/span&gt; and unassociated them.&lt;/p&gt;&#xA;&lt;p&gt;However, I find that this is not giving me optimal assignments.&lt;/p&gt;&#xA;&lt;p&gt;Any Help?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2021-02-14T23:21:19.070" LastActivityDate="2021-02-15T00:15:19.937" Title="How can I find the optimal assignments for this MILP problem heuristically?" Tags="|mixed-integer-programming|integer-programming|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5699" PostTypeId="2" ParentId="5698" CreationDate="2021-02-13T12:51:31.277" Score="4" Body="&lt;p&gt;It seems to me that this problem can be reduced to a variant of the generalized assignment problem (GAP). If you set &lt;span class=&quot;math-container&quot;&gt;$U_{\max} = 1, \forall u$&lt;/span&gt;, then your problem is indeed GAP with equal weights for items. I know GAP is NP-hard, but not sure about this variant of GAP. I guess you can find some good stuff if you look for variants of GAP.&lt;/p&gt;&#xA;" OwnerUserId="660" LastActivityDate="2021-02-13T12:51:31.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5700" PostTypeId="2" ParentId="5698" CreationDate="2021-02-13T14:44:07.460" Score="5" Body="&lt;p&gt;This is the &lt;em&gt;transportation problem&lt;/em&gt;, a network flow problem (in a directed bipartite network) and hence solvable exactly as an LP. If you prefer a combinatorial algorithm, this might be a good exercise to learn the primal-dual method, and your heuristic approach can provide the initial solution.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-02-13T14:44:07.460" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5701" PostTypeId="1" AcceptedAnswerId="5702" CreationDate="2021-02-14T00:57:46.257" Score="7" ViewCount="221" Body="&lt;p&gt;I saw the following problem and was looking for references about the problem. The problem is stated as&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;“The green field is the empty area, the dark green 2x2 blocks are&#xA;trees and the grey area is the off area. I’m wondering how to place&#xA;the blocks in the field, while cutting the least amount of trees.”&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;with a picture (I've reduced the size)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TfnGE.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TfnGE.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As far as I can tell this is related to square packing (&lt;a href=&quot;https://en.wikipedia.org/wiki/Packing_problems#Packing_squares&quot; rel=&quot;noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Packing_problems#Packing_squares&lt;/a&gt;) but there is the related problem of minimizing the number of trees cut. I also found this Stack Exchange answer which suggested some approaches (&lt;a href=&quot;https://stackoverflow.com/questions/1213394/what-algorithm-can-be-used-for-packing-rectangles-of-different-sizes-into-the-sm&quot;&gt;https://stackoverflow.com/questions/1213394/what-algorithm-can-be-used-for-packing-rectangles-of-different-sizes-into-the-sm&lt;/a&gt;) but it doesn't fit exactly.&lt;/p&gt;&#xA;&lt;p&gt;Any insights would be useful.&lt;/p&gt;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="4955" LastActivityDate="2021-02-15T14:11:58.337" Title="Square packing variant" Tags="|combinatorial-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5702" PostTypeId="2" ParentId="5701" CreationDate="2021-02-14T03:25:01.257" Score="9" Body="&lt;p&gt;You can solve the problem via integer linear programming as follows.  For each size &lt;span class=&quot;math-container&quot;&gt;$s\in\{3,4,5\}$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$n_s$&lt;/span&gt; be the number of blocks of size &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to place. For each cell &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; and each size &lt;span class=&quot;math-container&quot;&gt;$s \in \{3,4,5\}$&lt;/span&gt;, let binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,s}$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is the top left corner of a block of size &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.  For each cell &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$B_{i,j}$&lt;/span&gt; be the set of blocks that cover that cell, and let binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; indicate whether that cell is covered by some block.  For each tree &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$C_t$&lt;/span&gt; be the cells that are covered by that tree, and let binary variable &lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt; indicate whether that tree is cut.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_t z_t$&lt;/span&gt; subject to linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i,j} x_{i,j,s} &amp;amp;=n_s &amp;amp;&amp;amp;\text{for all $s$} \tag1 \\&#xA;\sum_{(i',j',s)\in B_{i,j}} x_{i',j',s} &amp;amp;=y_{i,j} &amp;amp;&amp;amp;\text{for all $(i,j)$} \tag2 \\&#xA;y_{i,j} &amp;amp;\le z_t &amp;amp;&amp;amp;\text{for all $t$ and $(i,j)\in C_t$} \tag3\\&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; places all &lt;span class=&quot;math-container&quot;&gt;$n_s$&lt;/span&gt; blocks of size &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; prevents overlapping blocks.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; enforces cutting a tree if some block covers a tree cell.&lt;/p&gt;&#xA;&lt;p&gt;If I have entered the data correctly, the minimum turns out to be &lt;span class=&quot;math-container&quot;&gt;$13$&lt;/span&gt;, as shown here, where T indicates a surviving tree, C indicates a cut tree, &lt;span class=&quot;math-container&quot;&gt;$3\times 3$&lt;/span&gt; blocks are red, &lt;span class=&quot;math-container&quot;&gt;$4\times 4$&lt;/span&gt; blocks are orange, &lt;span class=&quot;math-container&quot;&gt;$5\times 5$&lt;/span&gt; blocks are blue, and uncovered cells are green:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/PjnbM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PjnbM.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-02-15T14:11:58.337" LastActivityDate="2021-02-15T14:11:58.337" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5703" PostTypeId="1" CreationDate="2021-02-14T20:27:11.900" Score="1" ViewCount="49" Body="&lt;p&gt;I have tried to solve an optimization problem (an MINLP) to minimize the number of items which need to be stored. The objective function is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \quad z = \sum_{i=1}^{n} \, \color{blue} {R_{i}}/x_{i}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where, &lt;span class=&quot;math-container&quot;&gt;$\color{blue} {R_{i}}, i \in \left\{1,\cdots,n\right\}$&lt;/span&gt;, given constant and &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; are integer variables. I have used three different formulations to compare which one may solve the problem faster. First, the above formulation was solved by an MINLP solver. Second, defining the new auxiliary variables and substituting diviation. Third, reformulating the objective function into the rotated second-order cone constraints. &lt;em&gt;What I am interested in is&lt;/em&gt;:&lt;/p&gt;&#xA;&lt;p&gt;In the first case, some of the solvers like Baron or Lindo could solve the problem faster than the second on. In the second case, a solver like SCIP could deal with the problem faster than the first one!. (substituting diviation with product). In the third case, the RSOC model was solved by CPLEX or Xpress efficiently.&lt;/p&gt;&#xA;&lt;p&gt;It should be noted that In all of the cases the model solved optimality and the results are the same. When I tried to solve the RSOC model by Mosek, as it has some features to encounter with that efficiently, it returned: &lt;code&gt;The quadratic constraint matrix is not NSD&lt;/code&gt; that I think it is related to the RSOC constraints.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering if, is it possible I am doing something wrong as per, other solvers returned the optimal solution?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2021-02-14T20:27:50.373" LastActivityDate="2021-02-14T20:27:50.373" Title="The different behavior of the solvers to dial with MINLP problem" Tags="|modeling|solver|global-optimality|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="5704" PostTypeId="1" CreationDate="2021-02-14T21:55:54.720" Score="7" ViewCount="118" Body="&lt;p&gt;I have found the following slides of talks:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://school.a4cp.org/summer2017/slidedecks/Consistency-in-Solvers.pdf&quot; rel=&quot;noreferrer&quot;&gt;Consistency in solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://coral.ise.lehigh.edu/mip-2008/talks/danna.pdf&quot; rel=&quot;noreferrer&quot;&gt;Performance variability in mixed integer programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I am looking for similar resource (slides, videos, articles, etc.) that treats issues and subjects (numerical issues, performance, architecture etc.) related to building a solver (no matter the techniques MIP, CP, Local-search based etc.)&lt;/p&gt;&#xA;" OwnerUserId="4961" LastEditorUserId="4961" LastEditDate="2021-02-14T22:08:15.510" LastActivityDate="2021-02-16T13:00:50.267" Title="How to learn about some general Issues related to solvers?" Tags="|solver|reference-request|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5705" PostTypeId="2" ParentId="5698" CreationDate="2021-02-15T00:15:19.937" Score="3" Body="&lt;p&gt;I did a few computational trials on a small example, and it appears that you can solve the Lagrangean relaxation via a gradient based method. If we reverse the constraint requiring all users to be assigned at least one provider, to &lt;span class=&quot;math-container&quot;&gt;$$-\sum_{c=1}^C d_{u,c}\ge -1\,\forall u$$&lt;/span&gt;(so that all multipliers are nonnegative), the Lagrangean problem is&lt;span class=&quot;math-container&quot;&gt;$$\min_{\lambda,\mu,\nu\ge0}LR(\lambda,\mu,\nu)=\\\max_{d\in\left\{ 0,1\right\} ^{U\times C}}\left(\sum_{u}\sum_{c}\omega_{u,c}d_{u,c}-\sum_{u}\lambda_{u}\left[\sum_{c}d_{u,c}-C_{\max}\right]\\+\sum_{u}\mu_{u}\left[\sum_{c}d_{u,c}-1\right]-\sum_{c}\nu_{c}\left[\sum_{u}d_{u,c}-U_{\max}\right]\right)$$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is the multiplier vector for the upper limit on providers assigned to a user, &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; is the multiplier vector for the lower limit, and &lt;span class=&quot;math-container&quot;&gt;$\nu$&lt;/span&gt; is the multiplier vector for the upper limit on users assigned to a provider. We can reduce that to&lt;span class=&quot;math-container&quot;&gt;$$LR(\lambda,\mu,\nu)=\sum_{u}\sum_{c}\left(\omega_{u,c}-\lambda_{u}+\mu_{u}-\nu_{c}\right)^{+}\\+C_{\max}\sum\lambda_{u}-\sum_{u}\mu_{u}+U_{\max}\sum_{c}\nu_{c}$$&lt;/span&gt;, using the fact that in the inner maximization &lt;span class=&quot;math-container&quot;&gt;$d_{u,c}$&lt;/span&gt; will be 1 if it has a positive coefficient and 0 if it has a negative coefficient. &lt;span class=&quot;math-container&quot;&gt;$LR$&lt;/span&gt; is piecewise linear, with a gradient defined piecewise, so with a little care a gradient based descent procedure should work (and does in my limited tests).&lt;/p&gt;&#xA;&lt;p&gt;That said, I personally would use an LP solver, per Rob's answer.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-02-15T00:15:19.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5706" PostTypeId="1" CreationDate="2021-02-15T10:12:05.330" Score="2" ViewCount="605" Body="&lt;p&gt;I'm currently solving the &lt;strong&gt;capacitated vehicle routing problem (cvrp)&lt;/strong&gt; with the&#xA;approached methods (metaheuristics).&lt;/p&gt;&#xA;&lt;p&gt;In order to do this I have to build a &lt;strong&gt;random initial solution&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My question is when we say a random solution it means that we have to solve it without respecting the &lt;strong&gt;capacity constraint&lt;/strong&gt; or what?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm using the following code :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;public void RandomInitializer() {&#xA;    VrpProblem problem = this.getProblem();&#xA;    List&amp;lt;List&amp;lt;Integer&amp;gt;&amp;gt; routes = new ArrayList&amp;lt;List&amp;lt;Integer&amp;gt;&amp;gt;();&#xA;    routes = this.getRoutes();&#xA;    HashSet&amp;lt;Integer&amp;gt; remainingNodes = new HashSet&amp;lt;Integer&amp;gt;();&#xA;    for (int i = 0; i &amp;lt; problem.getNumRames(); i++) {&#xA;        remainingNodes.add(i);&#xA;    }&#xA;    for (List&amp;lt;Integer&amp;gt; route : routes) {&#xA;        for (Integer node : route) {&#xA;            remainingNodes.remove(node);&#xA;        }&#xA;    }&#xA;    List&amp;lt;Integer&amp;gt; curRoute = new ArrayList&amp;lt;Integer&amp;gt;();&#xA;    routes.add(curRoute);&#xA;    &#xA;    int curNodeId = -1;&#xA;&#xA;    int remCapacity = problem.getVehicleCapacity();&#xA;    while (remainingNodes.size() &amp;gt; 0) {&#xA;        Number[] ret = findNode(curNodeId, remCapacity, remainingNodes, problem);&#xA;&#xA;        int nextNodeId = (Integer) ret[0];&#xA;        if (nextNodeId != -1) {&#xA;            remainingNodes.remove(nextNodeId);&#xA;            curRoute.add(nextNodeId);&#xA;            curNodeId = nextNodeId;&#xA;            remCapacity -= problem.getDemands()[nextNodeId];&#xA;        } else {&#xA;            curRoute = new ArrayList&amp;lt;Integer&amp;gt;();&#xA;            routes.add(curRoute);&#xA;            curNodeId = -1;&#xA;            remCapacity = problem.getVehicleCapacity();&#xA;        }&#xA;    }&#xA;&#xA;    this.setRoutes(routes);&#xA;    this.setNumLocomotives(routes.size());&#xA;}&#xA;&#xA;private Number[] findNode(int curLastId, int remCapacity, HashSet&amp;lt;Integer&amp;gt; remainingNodes, VrpProblem problem) {&#xA;    int[] demands = problem.getDemands();&#xA;&#xA;    double[][] times = problem.getRameTimes();&#xA;    double[] timesFromDepot = problem.getTimesFromMultimodal();&#xA;&#xA;    int bestNodeId = -1;&#xA;    Iterator&amp;lt;Integer&amp;gt; iter = remainingNodes.iterator();&#xA;&#xA;         while (iter.hasNext()) {&#xA;          int nodeId = iter.next();&#xA;          &#xA;          if (demands[nodeId] &amp;gt; remCapacity) {&#xA;                continue;&#xA;            }&#xA;        &#xA;            bestNodeId = nodeId;&#xA;           &#xA;        }&#xA;&#xA;    return new Number[] { new Integer(bestNodeId) };&#xA;}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But when I run my program &lt;code&gt;several times&lt;/code&gt; I get the &lt;strong&gt;&lt;code&gt;same solution&lt;/code&gt;&lt;/strong&gt; is this normal since I proceed randomly?&lt;/p&gt;&#xA;" OwnerUserId="4940" LastEditorUserId="4940" LastEditDate="2021-02-15T11:03:51.103" LastActivityDate="2021-02-15T13:52:31.177" Title="Random solution for capacitated vehcle routing problem (cvrp)" Tags="|vehicle-routing|metaheuristics|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5707" PostTypeId="2" ParentId="5706" CreationDate="2021-02-15T10:35:46.120" Score="7" Body="&lt;p&gt;&amp;quot;Random solution&amp;quot; means the decision variables are chosen randomly. It does not usually mean ignoring feasibility constraints. So, in the case of CVRP, it would mean choosing the cities for a given route, as well as their sequence on the route, randomly. There are various ways to deal with the capacity constraint -- for example, if the next randomly chosen city would violate the capacity of the current route, start a new route. Or, if the next randomly chosen city would violate the capacity, then keep checking all the cities (in random order) until you find one that is capacity-feasible, or until you've checked all remaining cities.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2021-02-15T10:35:46.120" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5708" PostTypeId="1" AcceptedAnswerId="5711" CreationDate="2021-02-15T10:36:17.893" Score="2" ViewCount="3693" Body="&lt;p&gt;I am trying to model the transportation problem of Dantzig in Pyomo (see the GAMS code here &lt;a href=&quot;https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_trnsport.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_trnsport.html&lt;/a&gt; or the description here &lt;a href=&quot;https://www.math.uh.edu/%7Erohop/fall_06/Chapter1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.math.uh.edu/~rohop/fall_06/Chapter1.pdf&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;I have problem defining the constraints for the supply using sets and variables. So basically what I want to do is to add the constraints:&#xA;For all set_plants&#xA;Sum over all set_markets x(set_plants, set_markets) &amp;lt;= param_capacityOfPlant (set_plants)&lt;/p&gt;&#xA;&lt;p&gt;in GAMS it is this line&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;supply(i).. sum(j, x(i,j)) =l= a(i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and in the description (&lt;a href=&quot;https://www.math.uh.edu/%7Erohop/fall_06/Chapter1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.math.uh.edu/~rohop/fall_06/Chapter1.pdf&lt;/a&gt;) it is equation 1.2&lt;/p&gt;&#xA;&lt;p&gt;I am struggeling to implement this in Pyomo. I tried different things and I always get the error &amp;quot;TypeError: Cannot apply a Set operator to an indexed Var component (variable_x)&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Here you can see my code in which the lines at the very bottom are problematic (after #Constraints):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# -*- coding: utf-8 -*-&#xA;&amp;quot;&amp;quot;&amp;quot;&#xA;Transport problem in Pyomo&#xA;&#xA;Created on Mon Feb 15 09:55:06 2021&#xA;&#xA;&#xA;&amp;quot;&amp;quot;&amp;quot;&#xA;&#xA;import pyomo.environ as pyo&#xA;&#xA;#Define the model&#xA;&#xA;model = pyo.ConcreteModel()&#xA;&#xA;&#xA;#Define the sets&#xA;model.set_plants = pyo.Set(initialize=['Seattle', 'San_Diego'])&#xA;model.set_markets = pyo.Set(initialize=['New_York', 'Chicago', 'Topeka'])&#xA;&#xA;&#xA;# Parameters&#xA;&#xA;valuesForCapacity = {'Seattle':350, 'San_Diego':600}&#xA;valuesForDemand = {'New_York': 325, 'Chicago': 300, 'Topeka': 275}&#xA;&#xA;model.param_capacityOfPlants = pyo.Param(model.set_plants, initialize=valuesForCapacity)&#xA;model.param_demandAtMarkets = pyo.Param(model.set_markets, initialize=valuesForDemand)&#xA;&#xA;model.param_capacityOfPlants.pprint()&#xA;model.param_demandAtMarkets.pprint()&#xA;&#xA;&#xA;#Parameter entry as table&#xA;&#xA;valuesForDistance =  {('Seattle', 'New_York'): 2.5, ('Seattle', 'Chicago'): 1.7, ('Seattle', 'Topeka'): 1.8,&#xA;('San_Diego', 'New_York'): 2.5, ('San_Diego', 'Chicago'): 1.8, ('San_Diego', 'Topeka'): 1.4}&#xA;                      &#xA;model.param_distances = pyo.Param(model.set_plants, model.set_markets, initialize=valuesForDistance)&#xA;&#xA;model.param_distances.pprint()&#xA;&#xA;&#xA;#Scalar&#xA;freightCostsPerUnitPerThousandMiles = 90&#xA;&#xA;&#xA;#Variables&#xA;&#xA;model.variable_x = pyo.Var(model.set_plants,model.set_markets, within=pyo.NonNegativeReals)&#xA;model.variable_totalCosts = pyo.Var()&#xA;&#xA;model.variable_x.pprint()&#xA;&#xA;&#xA;#Constraints&#xA;&#xA;def supplyConstraintRule(model):&#xA;    #First try&#xA;    # return pyo.summation(variable_x)&amp;lt;=model.param_capacityOfPlants&#xA;    #Second try&#xA;    #return sum(variable_x for j in model.set_markets)&amp;lt;=model.param_capacityOfPlants&#xA;    # Third try&#xA;    return sum(variable_x(i,j) for j in model.set_markets)&amp;lt;=model.param_capacityOfPlants(i)&#xA;&#xA;&#xA;model.constraint_supply = pyo.Constraint (model.variable_x, rule=supplyConstraintRule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Do you know how I have to implement this? I'd appreciate every comment from you.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastActivityDate="2021-02-15T18:09:27.487" Title="How to define constraints in Pyomo using sets and variables" Tags="|python|constraint|pyomo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5709" PostTypeId="2" ParentId="5706" CreationDate="2021-02-15T10:51:04.597" Score="7" Body="&lt;p&gt;Usually such statements mean that you should device a construction heuristic, which relies on some level of randomness. That is, if you run your construction procedure twice you should not (necessarily) get the same solution. I would in most cases, if not stated explicitly, expect the solution to be feasible to the problem (in your case it should probably respect the capacity constraints).&lt;/p&gt;&#xA;&lt;p&gt;A simple, and probably not very good, randomized construction heuristic for cvrps could be something along the lines of&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start a new route by placing a vehicle at the depot. Let the depot be the &lt;em&gt;current node&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;Make a list of &lt;span class=&quot;math-container&quot;&gt;$k\geq 1$&lt;/span&gt; promising nodes that does not belong to any other routes (nodes with demand less than the residual capacity of the vehicle).&lt;/li&gt;&#xA;&lt;li&gt;Generate a random number, &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;, between 1 and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and extend the route with the &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;'th node from the list. Let the &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;' th node become the current node.&lt;/li&gt;&#xA;&lt;li&gt;If all nodes belong to a route, return the solution.&lt;/li&gt;&#xA;&lt;li&gt;If the route cannot be extended further, return to the depot and go to 1. Else go to 2.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-02-15T10:51:04.597" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5710" PostTypeId="2" ParentId="5706" CreationDate="2021-02-15T13:52:31.177" Score="5" Body="&lt;p&gt;Altough I agree with the other answers, I think its worth mentioning that &lt;strong&gt;a random initial solution does not have to be feasible&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;When using (meta)heuristics, it is often the case that infeasible solutions are used in the search space, while the number of conflicts (the number of times a constraint is violated) is minimized in the cost function.&lt;/p&gt;&#xA;&lt;p&gt;For example, this is the case in &lt;a href=&quot;https://app.cs.amherst.edu/%7Eccmcgeoch/cs34/papers/tabuveh2661622.pdf&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt;, where the authors develop a tabu search heuristic for the CVRP called TABUROUTE, where infeasible routes (with respect to length or capacity) are used throughout the procedure.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2021-02-15T13:52:31.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5711" PostTypeId="2" ParentId="5708" CreationDate="2021-02-15T15:15:10.643" Score="2" Body="&lt;p&gt;Replace the Def and last line of your code with the following lines:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.constraint_supply = pyo.ConstraintList()&#xA;    for i in model.set_plants:&#xA;        model.constraint_supply.add(sum(model.variable_x[i, j] for j in model.set_markets) &amp;lt;= model.param_capacityOfPlants[i])&#xA;model.constraint_supply.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The output will be as follow:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;constraint_supply : Size=2, Index=constraint_supply_index, Active=True&#xA;    Key : Lower : Body                                                                                          : Upper : Active&#xA;      1 :  -Inf :       variable_x[Seattle,New_York] + variable_x[Seattle,Chicago] + variable_x[Seattle,Topeka] : 350.0 :   True&#xA;      2 :  -Inf : variable_x[San_Diego,New_York] + variable_x[San_Diego,Chicago] + variable_x[San_Diego,Topeka] : 600.0 :   True&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Instead of using &lt;strong&gt;Def&lt;/strong&gt; I used &lt;strong&gt;for loop&lt;/strong&gt; for constraint definitions. If the constraints are not correct you can play with the for loop mentioned here. Generally there is no difference in the output of these two approaches in defining the constraints.&lt;/p&gt;&#xA;&lt;p&gt;Edit: the following changes in your code solve the problem of using &lt;strong&gt;Def&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def supplyConstraintRule(model,i):&#xA;    # First try&#xA;    # return pyo.summation(variable_x)&amp;lt;=model.param_capacityOfPlants&#xA;    # Second try&#xA;    # return sum(variable_x for j in model.set_markets)&amp;lt;=model.param_capacityOfPlants&#xA;    # Third try&#xA;    return sum(model.variable_x[i, j] for j in model.set_markets) &amp;lt;= model.param_capacityOfPlants[i]&#xA;&#xA;model.constraint_supply = pyo.Constraint(model.set_plants, rule=supplyConstraintRule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2021-02-15T18:09:27.487" LastActivityDate="2021-02-15T18:09:27.487" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="5712" PostTypeId="2" ParentId="5704" CreationDate="2021-02-15T16:06:20.770" Score="8" Body="&lt;p&gt;Unfortunately this is a very sparsely documented subject in optimisation literature. The only technical resource I am aware of in my field is &lt;a href=&quot;https://www.researchgate.net/publication/227138669_Writing_Global_Optimization_Software&quot; rel=&quot;noreferrer&quot;&gt;this one&lt;/a&gt;. &lt;a href=&quot;https://depositonce.tu-berlin.de/handle/11303/1931&quot; rel=&quot;noreferrer&quot;&gt;Tobias Achterberg's thesis&lt;/a&gt; is also a good resource for MILP solver development.&lt;/p&gt;&#xA;&lt;p&gt;The problem is that the number of people who are proficient in solver development is so small that the probability of one of us taking the time to also write a book about it is, unfortunately, practically zero.&lt;/p&gt;&#xA;&lt;p&gt;The one thing I will warn you about is to only read resources written by people who have actually implemented solvers that are good enough for people to use. I've found that most other resources are just full of misconceptions/mistakes.&lt;/p&gt;&#xA;&lt;p&gt;In my opinion, the best resource by far is to try and understand the source code of a good open-source solver in your area of interest. Examples of good code include MINOTAUR (local MINLP), Couenne (Global MINLP), SCIP (for MILP &amp;amp; MINLP), and SoPlex (LP). There's also a bunch of other code bases like SHOT or Maingo, but those are implementations of more niche methods that are not very relevant to beginners. Do not attempt to read any CoinOR code (other than Couenne) as it's very hard to read even for professional solver developers like myself.&lt;/p&gt;&#xA;&lt;p&gt;When it comes to understanding solver design, it is important to ask yourself (while reading source code), &amp;quot;why is this implemented the way it is&amp;quot;. Many design choices in solver code appear odd at first glance, but there is always a reason (typically performance) if you dig deeper.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-02-15T16:06:20.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5713" PostTypeId="1" AcceptedAnswerId="5716" CreationDate="2021-02-15T17:41:14.590" Score="1" ViewCount="183" Body="&lt;p&gt;I am new to using OPL. I wrote a CPLEX code for the vaccine distribution from a paper, it doesn't get an error, but it hasn't given the answer. I don't know its problem; please help me; I attached the code in the following. I'm so confused and don't know what can be done?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/*********************************************&#xA; * OPL 12.8.0.0 Model&#xA; * Author: Ramin&#xA; * Creation Date: Feb 12, 2021 at 4:32:21 PM&#xA; *********************************************/&#xA;//sets--------------------------------------------------------------------------------------------------------------------------------------------------------------------&#xA;range D=1..3;   {int} DD=asSet(D);    //Distribution centers.&#xA;int c=0;        {int} cc={0};         //center.&#xA;range I=4..6;   {int} II={4,5,6};     //Local clinics.&#xA;range DI=1..6; //D+I&#xA;range cD=0..3; //c+D&#xA;range J=0..6;   {int} JJ= cc union DD union II;       //Vertices.&#xA;{int} L={0,1,2} ;                      //Levels which central 0, DC 1, local clinic 2.&#xA;range T=0..2;   {int} TT=asSet(T);     //Transportation vehicles which cold truck ( = 0), 4 × 4 truck ( = 1), motorbike ( = 2).&#xA;range R=0..3;   {int} RR= {0,1,2,3};   //Storage devices which cold room ( = 0), regional device ( = 1), district device ( = 2), local clinic device ( = 3).&#xA;range F=0..1;   {int} FF={0,1};        //Replenishment frequency: {quarterly ( = 0), monthly ( = 1)}.&#xA;//Define Arcs---------------------------------------------------------------------------------------------------------------------------------------------------------------&#xA;tuple Arc{&#xA;key int origin;&#xA;key int destination;&#xA;} &#xA;{Arc} A1={&amp;lt;0,1&amp;gt;,&amp;lt;0,2&amp;gt;,&amp;lt;0,3&amp;gt;};          //Arcs between center and Distribution centers. &#xA;{Arc} A2={&amp;lt;1,4&amp;gt;,&amp;lt;1,5&amp;gt;,&amp;lt;1,6&amp;gt;,&amp;lt;2,4&amp;gt;,&amp;lt;2,5&amp;gt;,&amp;lt;2,6&amp;gt;,&amp;lt;3,4&amp;gt;,&amp;lt;3,5&amp;gt;,&amp;lt;3,6&amp;gt;,&amp;lt;1,2&amp;gt;,&amp;lt;2,3&amp;gt;};   //Arcs between Distribution centers and locla clinics.&#xA;{Arc} A3={&amp;lt;1,2&amp;gt;,&amp;lt;2,3&amp;gt;};               //Arcs between Distribution centers.&#xA;{Arc} A={&amp;lt;0,1&amp;gt;,&amp;lt;0,2&amp;gt;,&amp;lt;0,3&amp;gt;,&amp;lt;1,4&amp;gt;,&amp;lt;1,5&amp;gt;,&amp;lt;1,6&amp;gt;,&amp;lt;2,4&amp;gt;,&amp;lt;2,5&amp;gt;,&amp;lt;2,6&amp;gt;,&amp;lt;3,4&amp;gt;,&amp;lt;3,5&amp;gt;,&amp;lt;3,6&amp;gt;,&amp;lt;1,2&amp;gt;,&amp;lt;2,3&amp;gt;};  //total Arcs.&#xA;//EXTEND//-----------------------------------------------------------------------------------------------------------------------------------------------------------------&#xA;///suppose1:motorbike ( = 2) works by electricity///&#xA;{int} chargestation={1,2,3};          //chargestation in route.&#xA;range chargestationcopy=1..6;   {int} chargestationcopyy={1,2,3,4,5,6}; //we have three shargestation but it may each chargestation visited more than one.&#xA;&#xA;//parameters-----------------------------------------------------------------------------------------------------------------------------------------------------&#xA;float C[A][t in T]=rand(10);          //Transportation cost per kilometer of vehicle type t from location i to location j.&#xA;float CS[R]=[8116,1582,600,596];      //Annual storage cost per storage device r.&#xA;float C0=40000;                       //Annual level 0 facility (central store) operating cost.&#xA;float C1[j in D]=4500;                //Annual level 1 facility (DC) operating cost at location j.&#xA;float C2[j in I]=800;                 //Annual level 2 facility (clinic) operating cost at location j.&#xA;float P[T]= [9293, 172,5];            //Transportation capacity per trip of vehicle t.&#xA;float PS[R]=[18000,1843,76,35];       //Storage capacity of device r.&#xA;float G[f in F]=(f==0)?4:12;          //Annual number of replenishments f  ( = 4 if f = 0 and = 12 if f = 1).&#xA;float S=0.25;                         //Buffer stock factor for vaccines stored at a location (typically = 0.25).&#xA;float H[A]= [2,3,2,2,5,6,7,5,8,9,12,13,12,6]; //Distance (kilometer) between location i and location j.&#xA;float M=100000000;                    //Big M.&#xA;//EXTEND//--------------------------------------------------------------------------------------------------------------------------------------------------------&#xA;///suppose1:motorbike ( = 2) works by electricity///-------------------------------------------------&#xA;int Beta=1;                           //(1+ beta) shows the number of copy of shargstations.&#xA;int Q =200;                           //motorbike battery capacity.&#xA;float e[i in cD][j in DI]=rand(10);   //charge consumption of motorbike from i to j.&#xA;int Tmax=200;                         //maximum time that motorbike should drive in two nodes.&#xA;///suppose2:cold truck ( = 0), 4 × 4 truck ( = 1) work by diesel, for decrease green gas///----------&#xA;int GHL[f in F]=100;&#xA;///suppose3:define cost of green house gas in objective function/////--------------------------------&#xA;float costco2=20;                     //average cost of co2 on the ration of weight.&#xA;float wco2=10;                        //weight of generate co2 by burning fuel per liter.&#xA;float fuel[T]=[10,5,0];               //volume of burning fuel per weight of vehicle and distance.&#xA;float w[T]=[100,200,0];               //weight of vehicle.&#xA;float wload[T]=[50,40,0];             //weight of load.&#xA;float wcurb[T]=[150,240,0];           //weights of vehicle and its load.&#xA;int RVC[T]=[3,2,1];                   //ratio of volume of vehicle on weight (without load).&#xA;&#xA;//variables--------------------------------------------------------------------------------------------------------------------------------&#xA;dvar float x[A];                      //Annual flow (volume) of vaccines from location i to location j&#xA;dvar float Y[J][R][F];                //Number of storage devices of type r at location j with replenishment frequency f &#xA;dvar float Z[A][T][F];                //Number of vehicle trips per replenishment from location i to location j using vehicle type t with replenishment&#xA;dvar boolean W[J];                    //1 if a location j is open, 0 otherwise&#xA;dvar boolean U[A];                    //1 if vaccines flow from location i to location j, 0 otherwise&#xA;dvar boolean V[J];                    //1 if a location j has monthly replenishment frequency, 0 otherwise&#xA;//EXTEND//-----------------------------------------------------------------------------------------------------------------------------------------&#xA;///suppose1:motorbike ( = 2) works by electricity///&#xA;dvar float y[J][T];                   //charge level of motorbike in each node.&#xA;dvar float q[chargestationcopy][T];   //charge level of motorbike in each chargestation.&#xA;dvar float O[chargestationcopy][T];   //charge of motorbike when depart from chargestation.&#xA;dvar float delta[chargestationcopy][T];//period of time being in chargestation.&#xA;dvar float timeexitchargestationcopy[chargestationcopy][T];//exit time from chargestation.&#xA;dvar float timeenterchargestationcopy[chargestationcopy][T];//enter time to chargstation.&#xA;dvar float recievetime[J][T];         //recieve time to a nod&#xA;dvar float servicetime[J][T];         //service time for costomer or clinic&#xA;dvar float time[cD][DI];              //time period of motorbike when drive from obe node to other.&#xA;dvar boolean K[cD][DI];               //if motorebike visit i an j be one and else zero.&#xA;///suppose2;cold truck ( = 0), 4 × 4 truck ( = 1) work by diesel, for decrease green gas///&#xA;dvar float GHG[F];                    //amount of green gas which generate by vehicle.&#xA;&#xA;//formulation------------------------------------------------------------------------------------------------------------------------------------------&#xA;dexpr float objective= sum(i in A,t in T,f in F)2* C[i][t]*G[f]*H[i]*Z[i][t][f]+&#xA;sum(j in J,f in F,r in R)CS[r]*Y[j][r][f]+ C0*W[0]+ sum(j in D)C1[j]*W[j]+sum(j in I)C2[j]*W[j]+&#xA;sum(i in A,t in T:t!=2)H[i]*costco2*wco2*fuel[t]*w[t]*wload[t]+sum(i in A,t in T:t!=2)x[i]*H[i]*wco2*fuel[t]*wcurb[t]/RVC[t]&#xA; ;&#xA;&#xA;minimize objective;&#xA;subject to{&#xA;cos1:sum(i in A)x[i]-sum(j in A)x[j]==0;&#xA;forall(i,j in A)cos2:sum(t in T,f in F)P[t]*G[f]*Z[i][t][f]&amp;gt;=x[i];&#xA;cos3:sum(t in T,r in R, f in F,j in J)P[t]*G[f]*Y[j][r][f]&amp;gt;=(1+S)*sum(i in A)x[i];&#xA;forall(j in DD)cos4:M*W[j]&amp;gt;=sum(i in A)x[i]+sum(j in A)x[j];&#xA;forall(i in A)cos5:x[i]&amp;lt;=M*U[i];&#xA;cos6:sum(i in A)U[i]&amp;lt;=1;&#xA;forall(j in D)cos7:sum(r in R,f in F)Y[j][r][f]&amp;lt;=M*W[j];&#xA;forall(j in J)cos8:sum(r in R)Y[j][r][1]&amp;lt;=M*V[j];&#xA;forall(j in J)cos9:sum(r in R)Y[j][r][0]&amp;lt;=M*(1-V[j]);&#xA;forall (i in A3,j in J)cos10:x[i]&amp;lt;=M*V[j];&#xA;forall (i in A1,k in D)cos11:V[k]&amp;lt;=2-U[i]-(sum(j in A3)U[j]/abs(3));&#xA;forall (i in cc union II)cos12:W[i]==1;&#xA;forall (i in I)cos13:V[i]==1;&#xA;cos14:Y[0][0][0]==1;&#xA;forall (i in A)cos15:x[i]&amp;gt;=0;&#xA;///////////EXTEND////////////////-----------------------------------------------------------------------------------------------------------------------------------&#xA;///suppose1:motorbike ( = 2) works by electricity///&#xA;forall(i in cD, t in T:t==2)sum(j in DI)K[i][j]&amp;lt;=1;&#xA;forall(i in cD,j in DI,t in T:t==2)e[i][j]*K[i][j]-(1-K[i][j])*Q &amp;lt;=y[i][t]-y[j][t];&#xA;forall(i in cD,j in DI,t in T:t==2)y[i][t]-y[j][t]&amp;lt;=e[i][j]*K[i][j]+(1-K[i][j])*Q;&#xA;forall(i in cD,j in chargestationcopy,t in T:t==2)e[i][j]*K[i][j]-(1-K[i][j])*Q&amp;lt;= y[i][t]-q[j][t];&#xA;forall(i in cD,j in chargestationcopy,t in T:t==2)y[i][t]-q[j][t]&amp;lt;=e[i][j]*K[i][j]-(1-K[i][j])*Q;&#xA;forall(i in cc,t in T:t==2)y[i][t]==Q;&#xA;forall(i in chargestationcopy,t in T:t==2)y[i][t]==O[i][t];&#xA;forall(i in chargestationcopy,t in T:t==2)q[i][t]&amp;lt;=O[i][t];&#xA;forall(i in chargestationcopy,t in T:t==2)delta[i][t]==timeexitchargestationcopy[i][t]-timeenterchargestationcopy[i][t];&#xA;forall(i in cD,j in DI,t in T:t==2)recievetime[i][t]+(time[i][j]+servicetime[j][t])*K[i][j]-Tmax*(1-K[i][j])&amp;lt;=recievetime[j][t];&#xA;forall(i in cD:i!=0,j in chargestationcopy,t in T:t==2)recievetime[i][t]+delta[i][t]+time[i][j]*K[i][j]-Tmax*(1-K[i][j])&amp;lt;=recievetime[j][t];&#xA;forall(i in cD,j in DI,t in T:t==2)recievetime[j][t]+time[i][j]&amp;lt;=Tmax;&#xA;forall(t in T:t==2)recievetime[0][t]&amp;lt;=Tmax;&#xA;///suppose2:cold truck ( = 0), 4 × 4 truck ( = 1) work by diesel, for decreasing green gas///&#xA;forall(f in F,t in T:t!=2)sum(i in A)GHG[f]*H[i]*U[i]&amp;lt;=GHL[f];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is the engine log output!!!!!&#xA;&lt;a href=&quot;https://i.stack.imgur.com/qFfBd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qFfBd.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4306" LastEditorUserId="36" LastEditDate="2021-02-15T19:27:48.180" LastActivityDate="2021-02-16T08:18:08.967" Title="Coding the OR problem with cplex" Tags="|mixed-integer-programming|cplex|opl|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5714" PostTypeId="2" ParentId="4700" CreationDate="2021-02-16T03:50:33.743" Score="1" Body="&lt;p&gt;The Franz Edelman award  run by informs generates a lot of interesting papers. They award a prize and also declare finalists based on impactful OR projects. Participants submit a paper as part of the process.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.informs.org/Recognizing-Excellence/INFORMS-Prizes/Franz-Edelman-Award&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.informs.org/Recognizing-Excellence/INFORMS-Prizes/Franz-Edelman-Award&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="32" LastActivityDate="2021-02-16T03:50:33.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5716" PostTypeId="2" ParentId="5713" CreationDate="2021-02-16T08:18:08.967" Score="2" Body="&lt;p&gt;if you name other constraints as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;forall(i in cD, t in T:t==2)  cb1:sum(j in DI)K[i][j]&amp;lt;=1;&#xA;forall(i in cD,j in DI,t in T:t==2)  cb2:e[i][j]*K[i][j]-(1-K[i][j])*Q &amp;lt;=y[i][t]-y[j][t];&#xA;forall(i in cD,j in DI,t in T:t==2) cb3:y[i][t]-y[j][t]&amp;lt;=e[i][j]*K[i][j]+(1-K[i][j])*Q;&#xA;forall(i in cD,j in chargestationcopy,t in T:t==2) cb4:e[i][j]*K[i][j]-(1-K[i][j])*Q&amp;lt;= y[i][t]-q[j][t];&#xA;forall(i in cD,j in chargestationcopy,t in T:t==2) cb5:y[i][t]-q[j][t]&amp;lt;=e[i][j]*K[i][j]-(1-K[i][j])*Q;&#xA;forall(i in cc,t in T:t==2)y[i][t]==Q;&#xA;forall(i in chargestationcopy,t in T:t==2)y[i][t]==O[i][t];&#xA;forall(i in chargestationcopy,t in T:t==2) cb6:q[i][t]&amp;lt;=O[i][t];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then you ll get some conflicts to look at:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UpGCZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UpGCZ.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-02-16T08:18:08.967" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5717" PostTypeId="1" AcceptedAnswerId="5718" CreationDate="2021-02-16T09:02:45.497" Score="1" ViewCount="6672" Body="&lt;p&gt;I am new to Pyomo and I have the following optimization problem (original transport problem by Dantzig):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# -*- coding: utf-8 -*-&#xA;&amp;quot;&amp;quot;&amp;quot;&#xA;Transport problem in Pyomo&#xA;&#xA;Created on Mon Feb 15 09:55:06 2021&#xA;&#xA;&#xA;&amp;quot;&amp;quot;&amp;quot;&#xA;&#xA;import pyomo.environ as pyo&#xA;&#xA;&#xA;#Define the model&#xA;&#xA;model = pyo.ConcreteModel()&#xA;&#xA;&#xA;#Define the sets&#xA;model.set_plants = pyo.Set(initialize=['Seattle', 'San_Diego'])&#xA;model.set_markets = pyo.Set(initialize=['New_York', 'Chicago', 'Topeka'])&#xA;&#xA;&#xA;# Parameters&#xA;&#xA;valuesForCapacity = {'Seattle':350, 'San_Diego':600}&#xA;valuesForDemand = {'New_York': 325, 'Chicago': 300, 'Topeka': 275}&#xA;&#xA;model.param_capacityOfPlants = pyo.Param(model.set_plants, initialize=valuesForCapacity)&#xA;model.param_demandAtMarkets = pyo.Param(model.set_markets, initialize=valuesForDemand)&#xA;&#xA;model.param_capacityOfPlants.pprint()&#xA;model.param_demandAtMarkets.pprint()&#xA;&#xA;&#xA;#Parameter entry as table&#xA;&#xA;valuesForDistance =  {('Seattle', 'New_York'): 2.5, ('Seattle', 'Chicago'): 1.7, ('Seattle', 'Topeka'): 1.8,&#xA;('San_Diego', 'New_York'): 2.5, ('San_Diego', 'Chicago'): 1.8, ('San_Diego', 'Topeka'): 1.4}&#xA;                      &#xA;model.param_distances = pyo.Param(model.set_plants, model.set_markets, initialize=valuesForDistance)&#xA;&#xA;model.param_distances.pprint()&#xA;&#xA;&#xA;#Scalar&#xA;freightCostsPerUnitPerThousandMiles = 90&#xA;&#xA;&#xA;#Variables&#xA;&#xA;model.variable_x = pyo.Var(model.set_plants,model.set_markets, within=pyo.NonNegativeReals)&#xA;model.variable_totalCosts = pyo.Var()&#xA;&#xA;model.variable_x.pprint()&#xA;&#xA;&#xA;#Constraints&#xA;&#xA;def supplyConstraintRule(model,i):&#xA;    return sum(model.variable_x[i,j] for j in model.set_markets)&amp;lt;=model.param_capacityOfPlants[i]&#xA;&#xA;&#xA;model.constraint_supply = pyo.Constraint (model.set_plants, rule=supplyConstraintRule)&#xA;&#xA;def demandConstraintRule (model, j):&#xA;    return sum(model.variable_x [i,j] for i in model.set_plants)&amp;gt;=model.param_demandAtMarkets[j]&#xA;&#xA;model.constraint_demand = pyo.Constraint (model.set_markets, rule=demandConstraintRule)&#xA;model.constraint_demand.pprint()&#xA;&#xA;&#xA;#Objective&#xA;&#xA;def ObjectiveRule (model):&#xA;    return sum( sum(model.variable_x[i,j]* model.param_distances[i,j]*freightCostsPerUnitPerThousandMiles  for i in model.set_plants) for j in model.set_markets)&#xA;&#xA;&#xA;model.objective = pyo.Objective(rule=ObjectiveRule, sense =pyo.minimize)&#xA;&#xA;model.objective.pprint()&#xA;&#xA;opt = pyo.SolverFactory('glpk')&#xA;#opt = SolverFactory(&amp;quot;gurobi&amp;quot;, solver_io=&amp;quot;python&amp;quot;)&#xA;opt.solve(model) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried to solve it with the statement &lt;code&gt;opt = pyo.SolverFactory('glpk')&lt;/code&gt; as recommended here &lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/solving_pyomo_models.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pyomo.readthedocs.io/en/stable/solving_pyomo_models.html&lt;/a&gt; but I get the error message &amp;quot;ApplicationError: No executable found for solver 'glpk'&amp;quot;. I also tried to use the statement &lt;code&gt;opt = SolverFactory(&amp;quot;gurobi&amp;quot;, solver_io=&amp;quot;python&amp;quot;)&lt;/code&gt;but here I get the error &amp;quot;NameError: name 'SolverFactory' is not defined&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Do you know what I have to do in order to solve the model? I'd appreciate every comment.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastActivityDate="2021-02-16T11:42:12.800" Title="Pyomo can't find solver" Tags="|python|solver|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5718" PostTypeId="2" ParentId="5717" CreationDate="2021-02-16T09:32:22.653" Score="2" Body="&lt;p&gt;If you add &lt;code&gt;pyo.&lt;/code&gt; to the beginning of your solver definition line, it works and gives the solution as follow:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;param_capacityOfPlants : Size=2, Index=set_plants, Domain=Any, Default=None, Mutable=False&#xA;    Key       : Value&#xA;    San_Diego :   600&#xA;      Seattle :   350&#xA;param_demandAtMarkets : Size=3, Index=set_markets, Domain=Any, Default=None, Mutable=False&#xA;    Key      : Value&#xA;     Chicago :   300&#xA;    New_York :   325&#xA;      Topeka :   275&#xA;param_distances : Size=6, Index=param_distances_index, Domain=Any, Default=None, Mutable=False&#xA;    Key                       : Value&#xA;     ('San_Diego', 'Chicago') :   1.8&#xA;    ('San_Diego', 'New_York') :   2.5&#xA;      ('San_Diego', 'Topeka') :   1.4&#xA;       ('Seattle', 'Chicago') :   1.7&#xA;      ('Seattle', 'New_York') :   2.5&#xA;        ('Seattle', 'Topeka') :   1.8&#xA;variable_x : Size=6, Index=variable_x_index&#xA;    Key                       : Lower : Value : Upper : Fixed : Stale : Domain&#xA;     ('San_Diego', 'Chicago') :     0 :  None :  None : False :  True : NonNegativeReals&#xA;    ('San_Diego', 'New_York') :     0 :  None :  None : False :  True : NonNegativeReals&#xA;      ('San_Diego', 'Topeka') :     0 :  None :  None : False :  True : NonNegativeReals&#xA;       ('Seattle', 'Chicago') :     0 :  None :  None : False :  True : NonNegativeReals&#xA;      ('Seattle', 'New_York') :     0 :  None :  None : False :  True : NonNegativeReals&#xA;        ('Seattle', 'Topeka') :     0 :  None :  None : False :  True : NonNegativeReals&#xA;constraint_demand : Size=3, Index=set_markets, Active=True&#xA;    Key      : Lower : Body                                                          : Upper : Active&#xA;     Chicago : 300.0 :   variable_x[Seattle,Chicago] + variable_x[San_Diego,Chicago] :  +Inf :   True&#xA;    New_York : 325.0 : variable_x[Seattle,New_York] + variable_x[San_Diego,New_York] :  +Inf :   True&#xA;      Topeka : 275.0 :     variable_x[Seattle,Topeka] + variable_x[San_Diego,Topeka] :  +Inf :   True&#xA;objective : Size=1, Index=None, Active=True&#xA;    Key  : Active : Sense    : Expression&#xA;    None :   True : minimize : 225.0*variable_x[Seattle,New_York] + 225.0*variable_x[San_Diego,New_York] + 153.0*variable_x[Seattle,Chicago] + 162.0*variable_x[San_Diego,Chicago] + 162.0*variable_x[Seattle,Topeka] + 125.99999999999999*variable_x[San_Diego,Topeka]&#xA;153675.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;for that you need to add the following lines to your code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;opt = pyo.SolverFactory('gurobi', solver_io=&amp;quot;python&amp;quot;)&#xA;results = opt.solve(model)&#xA;print(pyo.value(model.objective))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As you &lt;code&gt;import Pyomo.environ as pyo&lt;/code&gt;, for all the defined words in pyomo you need to add &lt;code&gt;pyo.&lt;/code&gt; to the beginning. For instance, to get the value of the objective function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;my_obj = pyo.value(model.objective)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To be able to use glpk you need to install it by using:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;conda install glpk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://stackoverflow.com/q/32316069&quot;&gt;this&lt;/a&gt; if you cannot find the exe path. The following lines worked for me:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;opt = pyo.SolverFactory('glpk')&#xA;results = opt.solve(model)&#xA;print(pyo.value(model.objective))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And I got the same solution: &lt;code&gt;153675.0&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Edit2:&#xA;To see all the variables' value:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for v in model.component_objects(pyo.Var,active=True):&#xA;    for index in v:&#xA;        print(index, ': ', pyo.value(v[index]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2021-02-16T11:42:12.800" LastActivityDate="2021-02-16T11:42:12.800" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="5719" PostTypeId="2" ParentId="5704" CreationDate="2021-02-16T12:04:02.793" Score="4" Body="&lt;p&gt;The most important thing when writing a floating point solver is to learn the fundamentals of numerical analysis, to include understanding the effects of roundoff error in finite precision numerical calculations. This is the building block on which all else rests.&lt;/p&gt;&#xA;&lt;p&gt;For this purpose, I can suggest a book such as&#xA;&lt;a href=&quot;http://www.ma.man.ac.uk/%7Ehigham/asna/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Accuracy and Stability of Numerical Algorithms, Second Edition&#xA;by Nicholas J. Higham, SIAM, 2002&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This book also provides introductory material on numerical linear algebra, to include matrix factorizations.  The book notably omits coverage of eigenvalues, eigenvectors, singular values, and singular vectors; so be aware. You may wish to proceed to more advanced numerical linear algebra and matrix factorization material at some point.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2021-02-16T13:00:50.267" LastActivityDate="2021-02-16T13:00:50.267" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5721" PostTypeId="1" AcceptedAnswerId="5723" CreationDate="2021-02-16T13:30:20.923" Score="1" ViewCount="1567" Body="&lt;p&gt;I am looking to set variables in my Pyomo model by using a loop, so that they can be created automatically. However, each variable also contains bounds.&lt;/p&gt;&#xA;&lt;p&gt;I was hoping that it can loop through a dictionary to assign the bounds to each variable.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Current code&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;coeffs = [120, 600, 800, 200]&#xA;y_target = 165120&#xA;&#xA;rangeStore = []&#xA;&#xA;for index in range(4):&#xA;    # Define model and variables&#xA;    model = ConcreteModel()&#xA;    model.b = Var(bounds=(0,15))&#xA;    model.c = Var(bounds=(15,60))&#xA;    model.d = Var(bounds=(60,150))&#xA;    model.e = Var(bounds=(150,300))&#xA;    model_x = [model.b,model.c, model.d, model.e]&#xA;&#xA;    # Model Constraint&#xA;    def weight_rule(model):&#xA;        return sum(coeffs[i] * model_x[i] for i in range(len(coeffs))) == y_target &#xA;    model.weight = Constraint( rule=weight_rule )&#xA;&#xA;    # Model Objective&#xA;    obj = model_x[index]&#xA;    model.objective = Objective(expr=obj, sense=minimize)&#xA;&#xA;    # Solve the model&#xA;    solver = SolverFactory('glpk')&#xA;    solver.solve(model)&#xA;    &#xA;    # Store value&#xA;    rangeStore.append([value(model_x[i]) for i in range(len(coeffs))])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Part I want to be created in loop&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    model.b = Var(bounds=(0,15))&#xA;    model.c = Var(bounds=(15,60))&#xA;    model.d = Var(bounds=(60,150))&#xA;    model.e = Var(bounds=(150,300))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4256" LastEditorUserId="278" LastEditDate="2022-11-11T15:29:08.630" LastActivityDate="2022-11-11T15:29:08.630" Title="How to dynamically create variables in Pyomo?" Tags="|linear-programming|pyomo|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5722" PostTypeId="2" ParentId="4700" CreationDate="2021-02-16T14:52:08.383" Score="1" Body="&lt;p&gt;You might consider &lt;a href=&quot;https://faculty.nps.edu/gbrown/docs/Brown-%20howtowriteaboutor3.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to Write about OR&lt;/a&gt; by Gerald Brown (a &lt;a href=&quot;https://www.nae.edu/&quot; rel=&quot;nofollow noreferrer&quot;&gt;NAE&lt;/a&gt; member).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Full citation with free PDF:&lt;/strong&gt;&lt;br /&gt;&#xA;Brown, Gerald G. 2004. How To Write About Operations Research, &lt;em&gt;PHALANX&lt;/em&gt;, Vol. 37, No. 3, p. 7. &lt;a href=&quot;https://faculty.nps.edu/gbrown/docs/Brown-%20howtowriteaboutor3.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;PDF&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="491" LastActivityDate="2021-02-16T14:52:08.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5723" PostTypeId="2" ParentId="5721" CreationDate="2021-02-16T15:24:54.453" Score="2" Body="&lt;pre&gt;&lt;code&gt;coeffs = [120, 600, 800, 200]&#xA;y_target = 165120&#xA;&#xA;rangeStore = []&#xA;&#xA;bound_dic = {0:[0,15],1:[15,60],2:[60,150],3:[150,300]}&#xA;model = ConcreteModel()&#xA;model.ind = set(bound_dic.keys())&#xA;&#xA;def b_rule(model, i):&#xA;    return (bound_dic[i][0], bound_dic[i][1])&#xA;&#xA;model.x = Var(model.ind, bounds = b_rule)&#xA;&#xA;model.weight = Constraint(expr = sum(coeffs[i] * model.x[i] for i in range(len(coeffs))) == y_target)&#xA;&#xA;# Model Objective&#xA;obj = model.x[index]&#xA;model.objective = Objective(expr=obj, sense=minimize)&#xA;&#xA;# Solve the model&#xA;solver = SolverFactory('glpk')&#xA;solver.solve(model)&#xA;&#xA;# Store value&#xA;rangeStore.append([value(model.x[i]) for i in range(len(coeffs))])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-02-16T15:24:54.453" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5724" PostTypeId="2" ParentId="4945" CreationDate="2021-02-17T12:17:58.953" Score="6" Body="&lt;p&gt;I have a bit of perspective on this since I make decisions to hire people to do this kind of work, so I'll share how I think about this.&lt;/p&gt;&#xA;&lt;p&gt;In general, being an OR professional typically requires a PhD, ideally in something industrially relevant. This is by no means always the case, but the field is not yet at a level of user-friendliness that allows people who don't deeply understand the fundamentals to these jobs well, unless the job is just very easy anyway. This has nothing to do with how bright someone is. Optimisation professionals simply need to know too much before they can be useful, and accumulating that kind of experience takes time.&lt;/p&gt;&#xA;&lt;p&gt;Our world is a big place and there are very diverse opportunities. Mine is merely one opinion, but I would personally not consider an entry-level professional without a PhD for an optimisation position, simply because training them to do the things I'm not smart enough to do myself would take years. For perspective, we spend 6-9 months training people &lt;em&gt;with&lt;/em&gt; a PhD at my company (although admittedly we do high-tech stuff).&lt;/p&gt;&#xA;&lt;p&gt;Don't get me wrong, it's not that a PhD gets people automatically hired, but it will get them an intro phone call if their field of study is relevant to what we need at our company at the time.&lt;/p&gt;&#xA;&lt;p&gt;Note that all this applies to young professionals. When it comes to someone with work experience in the field I don't care what their academic credentials are, as long as they can do the job.&lt;/p&gt;&#xA;&lt;p&gt;The more subtle factor here is actually something common throughout hiring decision-making in technology: &amp;quot;why are we hiring someone?&amp;quot;. There are exactly three reasons:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We need more manpower on this.&lt;/li&gt;&#xA;&lt;li&gt;We have no idea how to do this so we need someone who does.&lt;/li&gt;&#xA;&lt;li&gt;We know what we're doing but we lack specialist know-how in this specific thing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;With all this in mind, your first decision should be what aspect of the work appeals the most to you. Do you enjoy solver technology, metaheuristics, or modelling? If you pick one of those, which sub-topic within them do you find most interesting?&lt;/p&gt;&#xA;&lt;p&gt;The second train of thought is practicality. Among the things that you do find interesting, which of them are used the most in practice, or will be in 5 years' time?&lt;/p&gt;&#xA;&lt;p&gt;Your third decision is what kind of professional you want to be. Do you want to be a generalist and work at a small consultancy, or do you want to be the absolute best at one thing and get hired to do the really high-tech stuff? The former ensures there will always be some job you can take, while the latter means that maybe 100 people might ever be interested in hiring you and would pay big money for your skills, but it might be years before you find such a position.&lt;/p&gt;&#xA;&lt;p&gt;Once you decide what's an acceptable trade-off between these factors, you have your goal. Once you do, figuring out how to go about it in practice is the simpler part. Look for a PhD under a supervisor who knows what they're doing, apply for relevant jobs/internships to get hands-on experience, or start coding/contributing to an open-source optimisation codebase.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-02-17T12:23:03.390" LastActivityDate="2021-02-17T12:23:03.390" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5725" PostTypeId="1" CreationDate="2021-02-17T13:07:24.017" Score="2" ViewCount="138" Body="&lt;p&gt;I am attempting to solve five variables from a system of equations. Let the variables be &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2,x_3,x_4,x_5$&lt;/span&gt;. Let the problem have the form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\exp(x_1)+x_1^6=x_3+x_4+x_5 \tag{1}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\exp(x_2)+x_2^6=x_3+x_4+x_5 \tag{2}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$f_1(x_1,x_2,x_3,x_4,x_5)=0 \tag{3}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$f_2(x_1,x_2,x_3,x_4,x_5)=0 \tag{4}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$f_3(x_1,x_2,x_3,x_4,x_5)=0 \tag{5}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$f_1,f_2,f_3$&lt;/span&gt; are some generally complicated functions. I am looking for the most efficient way to solve this problem.&lt;/p&gt;&#xA;&lt;p&gt;One can see that I can solve for the first two variables simply from the first two equations and represent them as &lt;span class=&quot;math-container&quot;&gt;$x_1=g_1(x_3,x_4,x_5)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2=g_2(x_3,x_4,x_5)$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$g_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_2$&lt;/span&gt; were analytic, I could simply plug the first two variables to the last three equations and solve for a much simpler three equation problem, which would typically improve both speed and accuracy. However, the issue is that here &lt;span class=&quot;math-container&quot;&gt;$g_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_2$&lt;/span&gt; cannot be derived analytically and hence the relationship is implicit.&lt;/p&gt;&#xA;&lt;p&gt;I have tried a nested solution approach, where for each guess value for the last three variables I numerically solve for the first two from the first two equations. However, this does not appear to improve speed much over simply giving a standard solver a full problem with 5 equations and unknowns.&lt;/p&gt;&#xA;&lt;p&gt;Could someone suggest an alternative solution approach?&lt;/p&gt;&#xA;" OwnerUserId="4968" LastEditorUserId="491" LastEditDate="2021-02-17T17:49:41.313" LastActivityDate="2021-02-17T17:49:41.313" Title="Solving systems of equations with simple implicit functional relations" Tags="|optimization|solver|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5726" PostTypeId="1" AcceptedAnswerId="5727" CreationDate="2021-02-17T15:04:22.980" Score="7" ViewCount="1037" Body="&lt;p&gt;Solvers for non-convex QPs generally do the McCormick relaxation of the term &lt;span class=&quot;math-container&quot;&gt;$xy=z$&lt;/span&gt; and then do spatial branch and bound.&lt;/p&gt;&#xA;&lt;p&gt;This requires that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; have given bounds, how do they handle the case when the variables are unbounded?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="279" LastEditDate="2021-02-18T15:40:10.370" LastActivityDate="2021-02-22T23:48:28.840" Title="How do Quadratic Programming solvers handle variables without bounds?" Tags="|quadratic-programming|branch-and-bound|bounds|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5727" PostTypeId="2" ParentId="5726" CreationDate="2021-02-17T16:23:54.040" Score="9" Body="&lt;p&gt;Unless we can derive bounds during presolving, the standard way is to set a default variable range instead (e.g. &lt;span class=&quot;math-container&quot;&gt;$\pm1.e16$&lt;/span&gt;) so that we can generate the McCormick constraints.&lt;/p&gt;&#xA;&lt;p&gt;There are numerical &amp;amp; convergence issues to consider depending on the number that is chosen, so setting smaller bounds might be preferable if we are certain that it's safe from a modelling point of view.&lt;/p&gt;&#xA;&lt;p&gt;In general-purpose solvers we don't have that luxury because this is a modelling issue, so we pick large bounds by default and compensate for potentially bad numerics using a large bag of tricks, e.g., domain reduction techniques, re-scaling the problem, or higher precision arithmetic.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-02-18T17:52:01.530" LastActivityDate="2021-02-18T17:52:01.530" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5729" PostTypeId="2" ParentId="4222" CreationDate="2021-02-17T16:39:35.117" Score="1" Body="&lt;p&gt;Many people seem to think that, but we do nothing of the sort in OR - our process is much simpler than people think.&lt;/p&gt;&#xA;&lt;p&gt;We build and solve a model, and if the results make sense, we are pretty much done. If the results don't make sense we typically know why. Crucially, we can know whether the issue is in the data or not.&lt;/p&gt;&#xA;&lt;p&gt;The reason OR has a reputation for being difficult and time consuming is because problems that describe the real world well take skill to create and even more skill to solve if a solver can't handle them out-of-the-box.&lt;/p&gt;&#xA;&lt;p&gt;ML &lt;em&gt;is&lt;/em&gt; optimisation. The difference is in how the models are created, and the skill level required to produce something that is usable.&lt;/p&gt;&#xA;&lt;p&gt;Keep in mind that &amp;quot;classical&amp;quot; mathematical optimisation is simply engineering, and has been used in the industry with great success for many decades.&lt;/p&gt;&#xA;&lt;p&gt;It is useful to remember that ML &amp;amp; optimisation are not mutually exclusive. Either can solve problems the other one can't solve at all. The advent of ML has actually triggered massive growth in OR because the two technology stacks are incredibly powerful when used in conjunction.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-02-17T16:39:35.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5730" PostTypeId="1" CreationDate="2021-02-17T18:55:48.390" Score="4" ViewCount="246" Body="&lt;p&gt;I have the following problem:&lt;/p&gt;&#xA;&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; workers and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; tasks I have to assign a worker to each task where each worker has a time to get to the task, and each task has a preparation time.&#xA;for example, task 1 preparation time is 10 minutes, it will take worker A 2 minutes to get there, 5 minutes for worker B, and 7 minutes for worker C.&lt;/p&gt;&#xA;&lt;p&gt;My objective is to assign workers such that the waiting time is minimised.&lt;/p&gt;&#xA;&lt;p&gt;I modelled it to a Weighted Bipartite Graph&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8xEap.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8xEap.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where each edge has a weight and each blue node (task) has a negative weight and we need to assign a worker such that the total cost will be as close to zero&lt;/p&gt;&#xA;&lt;p&gt;Which algorithms should I look into to solve this?&lt;/p&gt;&#xA;" OwnerUserId="4971" LastEditorUserId="36" LastEditDate="2021-02-17T19:11:23.743" LastActivityDate="2021-02-18T12:49:06.523" Title="Assignment Problem With Weighted Bipartite Graph" Tags="|optimization|assignment-problem|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5731" PostTypeId="2" ParentId="5726" CreationDate="2021-02-17T19:22:37.713" Score="6" Body="&lt;p&gt;Besides simply adding a large bound (which can cause numerical issues and lead to poor branching) or presolve from constraints involving the unbounded variable, the solver might be able to derive bounds by bound-propagation once a feasible solution is available.&lt;/p&gt;&#xA;&lt;p&gt;As an example (assuming you have some bound, otherwise an indefinite problem will be unbounded), if you want to minimize &lt;span class=&quot;math-container&quot;&gt;$-xy + y^2$&lt;/span&gt; and only have the bound &lt;span class=&quot;math-container&quot;&gt;$0\leq x \leq 1$&lt;/span&gt; and you find the solution &lt;span class=&quot;math-container&quot;&gt;$x = y = 0$&lt;/span&gt;, you immediately have that the optimal solution satisfies &lt;span class=&quot;math-container&quot;&gt;$-xy+y^2\leq 0$&lt;/span&gt; or equivalently &lt;span class=&quot;math-container&quot;&gt;$y^2\leq xy$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; it must hold that &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is non-negative, and by maximizing over &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to upper bound the right-hand side it holds that &lt;span class=&quot;math-container&quot;&gt;$y^2 \leq y$&lt;/span&gt; which means &lt;span class=&quot;math-container&quot;&gt;$y\leq 1$&lt;/span&gt;, so in summary &lt;span class=&quot;math-container&quot;&gt;$0 \leq y \leq 1$&lt;/span&gt; in any optimal solution.&lt;/p&gt;&#xA;" OwnerUserId="487" LastEditorUserId="487" LastEditDate="2021-02-17T19:29:35.657" LastActivityDate="2021-02-17T19:29:35.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5732" PostTypeId="1" AcceptedAnswerId="5735" CreationDate="2021-02-18T03:34:16.903" Score="2" ViewCount="436" Body="&lt;p&gt;I recently chanced upon the idea of solution diversity through the setting of random seeds within CPLEX.&lt;/p&gt;&#xA;&lt;p&gt;However, the documentation page on the settings does not shed any light with regard to the implementation and default value of the seed value.&lt;/p&gt;&#xA;&lt;p&gt;Hence, I would like to seek your kind assistance in resolving this as I would like to sample different solutions so as to assess their bounds and suitability as inputs for the next stage of my problem.&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastActivityDate="2021-02-18T19:36:40.713" Title="Generating a different optimal solution from CPLEX for each run" Tags="|mixed-integer-programming|python|cplex|solver|implementation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5733" PostTypeId="2" ParentId="5621" CreationDate="2021-02-18T07:58:07.933" Score="3" Body="&lt;p&gt;A robust optimal solution has to satisfy all constraints for each choice of the uncertainty parameters. Thus you might not be able to point out one particular set that is active for an optimal solution. Consider the following small problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min x_1+x_2+x_3\\&#xA;x_1+x_2&amp;amp;\geq b_3 \\&#xA;x_1+x_3&amp;amp;\geq b_2 \\&#xA;x_2+x_3&amp;amp;\geq b_1 \\&#xA;x_1, x_2, x_3&amp;amp;\geq0 \\&#xA;\forall b_1, b_2, b_3 \geq0 &amp;amp;\text{ s.t. } b_1+b_2+b_3 \leq 1.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$b_1, b_2, b_3$&lt;/span&gt; are the uncertainty parameters and &lt;span class=&quot;math-container&quot;&gt;$\Gamma=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The optimal solution is &lt;span class=&quot;math-container&quot;&gt;$x_1=x_2=x_3=\frac{1}{2}$&lt;/span&gt;, as the solution has to hold for each choice of &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;. Also one can see that one can not name exactly one (&lt;span class=&quot;math-container&quot;&gt;$\Gamma$&lt;/span&gt;) of the variables that are responsible for this solution, as each of the three constraints is tight for a different choice of &lt;span class=&quot;math-container&quot;&gt;$b_i=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I hope this helps with the intuition.&lt;/p&gt;&#xA;" OwnerUserId="4477" LastActivityDate="2021-02-18T07:58:07.933" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5734" PostTypeId="2" ParentId="5730" CreationDate="2021-02-18T12:49:06.523" Score="4" Body="&lt;p&gt;From the comments I found that your problem can be described by&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a setup time &lt;span class=&quot;math-container&quot;&gt;$s_j$&lt;/span&gt; for process &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;a travel time &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; for worker &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to process &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Then the waiting time that we get when assigning worker &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to process &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is given by &lt;span class=&quot;math-container&quot;&gt;$w_{ij}:=|s_j-c_{ij}|$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Using &lt;span class=&quot;math-container&quot;&gt;$w_{ij}$&lt;/span&gt; as your new weights of the assignments you can use any classic assignement algorithm you want to solve this. For example you could use the following LP, which happens to always have an integral optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min \sum_{i,j} w_{ij}x_{ij}\\&#xA;\sum_i x_{ij} &amp;amp;= 1 &amp;amp;\forall j\\&#xA;\sum_j x_{ij} &amp;amp;=1 &amp;amp;\forall i \\&#xA;0\leq x_{ij} &amp;amp;\leq 1&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If this turns out to be too slow you could look into min cost flows on bipartite graphs.&lt;/p&gt;&#xA;" OwnerUserId="4477" LastActivityDate="2021-02-18T12:49:06.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5735" PostTypeId="2" ParentId="5732" CreationDate="2021-02-18T19:36:40.713" Score="3" Body="&lt;p&gt;CPLEX treats the seed as a parameter. The parameter name varies by API; for Python it seems to be &amp;quot;parameters.randomseed&amp;quot;. The docs somewhat unhelpfully state that &amp;quot;[t]he default value of this parameter changes with each release&amp;quot; (but do not specify what it is in the current release).&lt;/p&gt;&#xA;&lt;p&gt;Note that a change to the seed is not guaranteed to produce a change in the optimal solution (even if there the optimal solution is not unique). To find multiple optimal (or near optimal) solutions, you might be better served by using the solution pool.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-02-18T19:36:40.713" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5736" PostTypeId="1" AcceptedAnswerId="5740" CreationDate="2021-02-18T21:30:06.593" Score="1" ViewCount="1658" Body="&lt;p&gt;I want to code a problem by CPLEX, in this problem I have variables and decision variables, how define them?&lt;/p&gt;&#xA;&lt;p&gt;In this picture you can see the variables:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/j2FED.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/j2FED.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;which we have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xLe9n.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xLe9n.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I use these codes for variables:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;//Variables&#xA;&#xA;float Q[periods]; //Inventory of the blood product at the blood center in time period t after receiving the quantity produced in time period t 1, allocating the delivered quantity to hospitals and disposing of the expired quantity&#xA;&#xA;float W[periods]; //Quantity of expired blood product at the blood center in time period t&#xA;&#xA;float I[hospitals][periods]; //Inventory level of the blood product at hospital i in time period t after receiving the delivered quantity and usage and i &amp;gt; 0&#xA;&#xA;float G[hospitals][periods]; //Shortage quantity at hospital i in time period t&#xA;   &#xA;&#xA;//Decision Variable   &#xA;                     &#xA;dvar float+ p[periods]; //Quantity of the blood product produced at the blood center in time period t&#xA;&#xA;dvar boolean y[nodes][vehicles][periods]; //A binary variable, if hospital i is served by vehicle k in time period t, y = 1 ; otherwise, y = 0&#xA;&#xA;dvar float+ dq[hospitals][vehicles][periods]; //Quantity of the blood product delivered to hospital i by vehicle k in time period t&#xA;&#xA;dvar float+ pq[hospitals][vehicles][periods]; //Quantity of the blood product picked up from hospital i by vehicle k in time period t&#xA;&#xA;dvar boolean x[nodes][nodes][vehicles][periods]; //A binary variable, if the delivery vehicle k travels from node i to node j in time period t, x = 1 ; otherwise, x = 0&#xA;&#xA;dvar float+ tq[nodes][nodes][vehicles][periods]; //Quantity of the blood product transported by vehicle k trough arc (i, j) in time period t&#xA;&#xA;dvar float+ xq[nodes][nodes][vehicles][periods]; //An auxiliary variable for linearization&#xA;&#xA;dvar boolean b[periods]; //An auxiliary binary variable for linearization&#xA;&#xA;dvar float+ Z; //An auxiliary variable for linearization&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is it correct or not? what is the difference between decision variables and variables in coding in CPLEX?&lt;/p&gt;&#xA;" OwnerUserId="4306" LastEditorUserId="123" LastEditDate="2021-02-19T11:17:12.460" LastActivityDate="2021-02-19T11:17:12.460" Title="How define variable in CPLEX and What is diffrence between decision variables and variable in CPLEX" Tags="|mixed-integer-programming|cplex|multi-objective-optimization|opl|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5739" PostTypeId="1" CreationDate="2021-02-18T23:11:49.450" Score="5" ViewCount="61" Body="&lt;p&gt;I'm looking for references to do a review of research on managing fisheries in industry. I've seen adaptions of&#xA;population growth models which include some harvesting constant or function and was wondering what has been done in the area, particularly with respect to variable prices and how temperature or nutrients could affect the yield of the fish.&lt;/p&gt;&#xA;" OwnerUserId="4955" LastEditorUserId="123" LastEditDate="2021-02-19T16:04:34.067" LastActivityDate="2021-02-19T16:04:34.067" Title="Reference request — fishery yield optimization" Tags="|optimization|mixed-integer-programming|reference-request|industry|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5740" PostTypeId="2" ParentId="5736" CreationDate="2021-02-19T08:06:23.057" Score="4" Body="&lt;p&gt;as can be read in OPL CPLEX documentation, &lt;strong&gt;A decision variable is an unknown in an optimization problem.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For instance&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar int x in 0..10;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;is a decision variable&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int a=3;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;is some data definition whereas in&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;execute&#xA;{&#xA; var b=2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;b is a scripting variable.&lt;/p&gt;&#xA;&lt;p&gt;In your model, I see&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;float Q[periods]; //Inventory of the blood product at the blood center in time period t after receiving the quantity produced in time period t 1, allocating the delivered quantity to hospitals and disposing of the expired quantity&#xA;&#xA;float W[periods]; //Quantity of expired blood product at the blood center in time period t&#xA;&#xA;float I[hospitals][periods]; //Inventory level of the blood product at hospital i in time period t after receiving the delivered quantity and usage and i &amp;gt; 0&#xA;&#xA;float G[hospitals][periods]; //Shortage quantity at hospital i in time period t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which are data.&lt;/p&gt;&#xA;&lt;p&gt;But if you keep the model like this all the Q,W,I,G will be 0 so those should either be defined through a formula or in extension.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int Q[1..2]=[4,5];     // in extension&#xA;int Q2[i in 1..2]=i+3; // formula&#xA;&#xA;assert forall(i in 1..2) Q[i]==Q2[i];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-02-19T08:06:23.057" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5741" PostTypeId="1" AcceptedAnswerId="5747" CreationDate="2021-02-19T10:37:08.163" Score="5" ViewCount="273" Body="&lt;p&gt;I am solving &lt;strong&gt;Capacitated Vehicle Routing Problem (CVRP)&lt;/strong&gt; with &lt;strong&gt;Adaptive Large Neighborhood Search (ALNS) metaheuristic&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I start my algorithm with a &lt;strong&gt;random initial solution&lt;/strong&gt;, but the solution I get is &lt;strong&gt;incomplete&lt;/strong&gt;. There is a node that has not been visited.&lt;/p&gt;&#xA;&lt;p&gt;Does it cause a problem, in this case, to start with an incomplete initial solution? Is there a way to fix this problem?&lt;/p&gt;&#xA;&lt;p&gt;My program is in Java. The initial solution is generated randomly.&lt;/p&gt;&#xA;" OwnerUserId="4942" LastEditorUserId="3391" LastEditDate="2021-03-16T17:36:04.057" LastActivityDate="2021-03-16T17:36:04.057" Title="Incomplete initial solution for capacitated vehicle routing problem" Tags="|vehicle-routing|metaheuristics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5742" PostTypeId="1" CreationDate="2021-02-19T14:53:35.000" Score="3" ViewCount="87" Body="&lt;p&gt;I am working on a Copper payables problem where the objective function is to maximise the sum of copper payable over a time period, T.&lt;/p&gt;&#xA;&lt;p&gt;The total amount of payable tonnes i.e. what the customer will pay for is dependent on the copper content of the sales material.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Each customer has a number of payable terms expressed as copper specification operable bounds, as per the below example data:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2&gt;Customer data&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;import io&#xA;import pandas as pd&#xA;&#xA;customer_payables = &amp;quot;&amp;quot;&amp;quot;customer, tier, specvalue_1, specoperator_1, specvalue_2, \&#xA;specoperator_2, coeff&#xA;    'abc', 1, 0, '&amp;gt;=', 20, '&amp;lt;=', 96.0&#xA;    'abc', 2, 20, '&amp;gt;', 24, '&amp;lt;=', 96.5 &#xA;    'abc', 3, 24, '&amp;gt;', 100, '&amp;lt;=', 96.65&#xA;    'def', 1, 0, '&amp;gt;=', 20, '&amp;lt;=', 96.0&#xA;    'def', 2, 20, '&amp;gt;=', 22, '&amp;lt;=', 96.66&#xA;    'def', 3, 22, '&amp;gt;=', 100', '&amp;lt;=', 97.0&#xA;    &amp;quot;&amp;quot;&amp;quot;&#xA;&#xA;_cust_data = io.StringIO(customer_payables)&#xA;cust_df = pd.read_csv(_cust_data, sep=&amp;quot;,&amp;quot;)&#xA;cust_df = cust_df.set_index('customer')&#xA;cust_df&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;I have a dataframe of available material, in tonnes, with specific copper content in two warehouse with two stockpiles. Note that the quality of this material changes over time:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2&gt;Stockpile Data&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;stockpile_data_dict = {&#xA;    'Warehouse 1': {&#xA;        'Stockpile 1': {'cu': 27},&#xA;        'Stockpile 2': {'cu': 18}&#xA;    },&#xA;    'Warehouse 2': {&#xA;        'Stockpile 1': {'cu': 22},&#xA;        'Stockpile 2': {'cu': 16}        &#xA;    }&#xA;}&#xA;&#xA;stockpile_df = pd.concat(&#xA;    {k: pd.DataFrame(v).T for k, v in stockpile_data_dict.items()}, axis=0)&#xA;stockpile_df&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&#xA;I have created a variable to represent the copper concentration for each warehouse, stockpile (and time period, but this is not reflected here for simplicities sake).&lt;/p&gt;&#xA;&lt;p&gt;How can I create a linear constraint that returns the correct payable coefficient with respect to the copper concentration VALUE of this variable?&lt;/p&gt;&#xA;&lt;p&gt;I do not use Pulp very often, so please bear with me.&lt;/p&gt;&#xA;&lt;p&gt;All help gratefully received, thank you.&lt;/p&gt;&#xA;" OwnerUserId="3395" LastActivityDate="2021-02-19T14:53:35.000" Title="PuLP Python: How to linearize an inequality involving an integer variable" Tags="|optimization|mixed-integer-programming|linear-programming|python|pulp|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5743" PostTypeId="1" CreationDate="2021-02-16T21:38:01.597" Score="5" ViewCount="165" Body="&lt;p&gt;I am struggling with transport optimization problem, that simplified might stated as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Minimize the number of bananas transports to the shop in the following 5 days (&lt;code&gt;transported_bananas = [n1_bananas, n2_bananas, n3_bananas, n4_bananas, n5_bananas]&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;The number of bananas in the shop, at any moment, cannot exceed 1000 (max constrain)&lt;/li&gt;&#xA;&lt;li&gt;The number of bananas in the shop, at any moment, cannot be lower than 100 (min constrain)&lt;/li&gt;&#xA;&lt;li&gt;Predicted bananas bought in the shop in the 5 following days are: (&lt;code&gt;predictions = [100, 500, 800, 10, 30]&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I use &lt;code&gt;scipy.optimize.minimize&lt;/code&gt; with &lt;code&gt;SLSQP&lt;/code&gt;. I have &lt;code&gt;ineq&lt;/code&gt; min and max constraints for each day, something like: &lt;code&gt;min_bananas &amp;gt; transported_bananas[0, current_day] - predictions[0, current_day]&lt;/code&gt;and similar to max constraint.&lt;/p&gt;&#xA;&lt;p&gt;The function which I am trying to optimize is: &lt;code&gt;transport_number = sum(transported_bananas &amp;gt; 0)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;SLSQP cannot find minimum of this function. I believe that is because only if transported bananas in given day are 0 there is no transport. It also does not matter if 1 banana is transported or 100000 bananas is transported - it is still one transport in given day. Should I look for different solver then (not based on gradient) or should I think about scaling transport number or think about making the objective function continues somehow?&lt;/p&gt;&#xA;" OwnerDisplayName="jacekblaz" LastActivityDate="2021-02-20T18:29:04.283" Title="Discontinued function optimization" Tags="|optimization|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5744" PostTypeId="1" AcceptedAnswerId="5745" CreationDate="2021-02-19T20:44:19.883" Score="1" ViewCount="1614" Body="&lt;p&gt;I am attempting to capture the nature of a &amp;quot;source&amp;quot; node as well as a &amp;quot;sink&amp;quot; node where the net flow for each node aside from the source and sink is zero. Here is my code so far:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;import pandas&#xA;import os&#xA;&#xA;&#xA;# writes constraints and objective to model file for easier inspection&#xA;def write_to_file(model, filestring):&#xA;    directory = os.getcwd()&#xA;    filename = directory+filestring&#xA;    if model.write(filename):&#xA;        return 0&#xA;    else:&#xA;        print(&amp;quot;failed to write to file&amp;quot;)&#xA;        return -1&#xA;&#xA;# nodes&#xA;# for my example, SOURCE s = 2 and SINK t = 7&#xA;vertices = [1,2,3,4,5,6,7]&#xA;&#xA;# arcs = edges, each arc has a fixed capacity&#xA;arcs, capacity = gp.multidict({&#xA;    (2,1) : 100,&#xA;    (2,3) : 50,&#xA;    (3,4) : 25,&#xA;    (4,7) : 25,&#xA;    (3,6) : 200,&#xA;    (1,6) : 500,&#xA;    (3,7) : 25,&#xA;    (6,5) : 500,&#xA;    (6,7) : 50,&#xA;    (5,7) : 200&#xA;})&#xA;&#xA;# create model&#xA;m = gp.Model(&amp;quot;Maximum Flow Problem&amp;quot;)&#xA;&#xA;# define variables&#xA;flow = m.addVars(arcs, name = &amp;quot;flow&amp;quot;)&#xA;&#xA;# flow capacity&#xA;m.addConstrs(&#xA;    (flow.sum(i,j) &amp;lt;= capacity[i,j] for i,j in arcs), &amp;quot;cap&amp;quot;)&#xA;&#xA;# flow conservation ISSUE HERE!&#xA;m.addConstrs(&#xA;    (flow.sum('*',j) - flow.sum(j,'*') == 0 for j in vertices), &amp;quot;node&amp;quot;)&#xA;&#xA;obj = (flow.sum('*', 7) - flow.sum(7,'*'))&#xA;m.setObjective(obj, GRB.MAXIMIZE)&#xA;&#xA;#write_to_file(m, &amp;quot;\\rec2_model_simple.lp&amp;quot;)&#xA;&#xA;m.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The issue has to do with the flow conservation constraint. I want to ensure all flow going in and out of all nodes that aren't &lt;code&gt;s=2&lt;/code&gt; and &lt;code&gt;t=7&lt;/code&gt; to equal zero; however, I do not know how to capture this in my constraint.&lt;/p&gt;&#xA;&lt;p&gt;I would like to have something like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.addConstrs(&#xA;    (flow.sum('*',j) - flow.sum(j,'*') == 0 for j != 2 or j != 7 in vertices), &amp;quot;node&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This throws an error, but I am curious if there is something similar in nature to capture this notion of a &amp;quot;source&amp;quot; and a &amp;quot;sink&amp;quot; in my flow conservation constraint. This may be a question more geared towards the python language instead of gurobipy, but since it is a question specific to modeling, I felt as though it is appropriate here.&lt;/p&gt;&#xA;" OwnerUserId="3231" LastActivityDate="2021-02-19T20:57:22.103" Title="Python Gurobipy Maximum Flow: How to model &quot;source&quot; and &quot;sink&quot; in constraints" Tags="|python|gurobi|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5745" PostTypeId="2" ParentId="5744" CreationDate="2021-02-19T20:48:32.890" Score="2" Body="&lt;p&gt;One way to model this is to add a dummy arc from the sink to the source and impose flow balance of 0 at every node, including the source and sink.&lt;/p&gt;&#xA;&lt;p&gt;But if you prefer the conditional constraint, I think the proper syntax is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.addConstrs(&#xA;    (flow.sum('*',j) - flow.sum(j,'*') == 0 for j in vertices if j != 2 and j != 7), &amp;quot;node&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-02-19T20:57:22.103" LastActivityDate="2021-02-19T20:57:22.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5746" PostTypeId="2" ParentId="5743" CreationDate="2021-02-19T22:15:06.047" Score="3" Body="&lt;p&gt;Your problem has continuous variables (the number of bananas delivered each day) but a discrete objective function (the number of deliveries over the period).&lt;/p&gt;&#xA;&lt;p&gt;As you noticed, counting the number of deliveries by using the expression &amp;quot;sum(transported_bananas &amp;gt; 0)&amp;quot; makes the objective function discontinuous. SLSQP (Least Square Sequential Quadratic Programming) belongs to &lt;a href=&quot;https://en.wikipedia.org/wiki/Sequential_quadratic_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;SQP methods&lt;/a&gt; which require the objective and the constraints to be twice continuously differentiable.&lt;/p&gt;&#xA;&lt;p&gt;Your problem can be expressed as a Mixed-Integer Linear Problem (MILP) and then solves using MILP solvers. To do so, you have to introduce binary variables to count the number of deliveries and link these variables to the number of bananas using the so-called &lt;a href=&quot;https://en.wikipedia.org/wiki/Big_M_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;big M&amp;quot; modeling technique&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To solve it directly, without any reformulation, you can also use LocalSolver, which is a global optimization solver (contrary to what the name suggests :-). Indeed, LocalSolver is able to handle discontinuous expressions like &amp;quot;sum(transported_bananas &amp;gt; 0)&amp;quot;. Please note that LocalSolver is a commercial solver. Nevertheless, academic and trial licenses are available for free.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2021-02-20T18:29:04.283" LastActivityDate="2021-02-20T18:29:04.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5747" PostTypeId="2" ParentId="5741" CreationDate="2021-02-19T22:35:20.157" Score="6" Body="&lt;p&gt;There is no problem in starting your &lt;a href=&quot;https://homes.di.unimi.it/righini/Didattica/AlgoritmiEuristici/MaterialeAE/15%20-%20ALNS.pdf&quot; rel=&quot;noreferrer&quot;&gt;ALNS&lt;/a&gt; with an infeasible (what you call &amp;quot;incomplete&amp;quot;) solution. ALNS consists of destroying a part of the solution and then repairing it, at each iteration. Generally, destroying is done by removing a number of tours in the incumbent solution. But you can adapt the method by selecting a number of tours plus some clients which are not delivered.&lt;/p&gt;&#xA;&lt;p&gt;Nevertheless, building an initial solution to the CVRP that is feasible (&amp;quot;complete&amp;quot;) is not difficult. For example, you can use the &lt;a href=&quot;http://web.mit.edu/urban_or_book/www/book/chapter6/6.4.12.html&quot; rel=&quot;noreferrer&quot;&gt;Clarke &amp;amp; Wright heuristic&lt;/a&gt;. Many Java implementations are given on the web; you can find one &lt;a href=&quot;https://github.com/dooglz/Java-Clarke-Wright&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. It will considerably speed up the convergence of your ALNS.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-02-19T22:35:20.157" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5748" PostTypeId="1" AcceptedAnswerId="5757" CreationDate="2021-02-20T04:36:22.160" Score="-3" ViewCount="109" Body="&lt;p&gt;Please consider&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://stoprog.org/what-stochastic-programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://stoprog.org/what-stochastic-programming&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and look at  &amp;quot;A SIMPLE INTEGER RECOURSE MODEL&amp;quot; at&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Stochastic Integer Programming&amp;quot; section.&lt;/p&gt;&#xA;&lt;p&gt;Should not &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; be &lt;span class=&quot;math-container&quot;&gt;$y_ib_i$&lt;/span&gt; in the cost function and &lt;span class=&quot;math-container&quot;&gt;$q_i$&lt;/span&gt; in the second-stage function as in the attached picture?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7kTPo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7kTPo.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4735" LastEditorUserId="4735" LastEditDate="2021-02-22T04:56:46.107" LastActivityDate="2021-02-22T04:56:46.107" Title="is this a mistake or not in this tutorial?" Tags="|mixed-integer-programming|stochastic-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5749" PostTypeId="1" AcceptedAnswerId="5750" CreationDate="2021-02-20T09:33:06.100" Score="4" ViewCount="1055" Body="&lt;p&gt;Suppose there is a optimization problem that aims at minimizing an objective function &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; but we can't develop a mathematical model for minimizing &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;. However, there are two objective functions &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; are a lower bound and an upper bound of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; respectively. We can develop a mathematical model for minimizing either &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;. Then &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is calculated for the output solution hoping that the solution with &lt;span class=&quot;math-container&quot;&gt;$Y_\min$&lt;/span&gt; (or &lt;span class=&quot;math-container&quot;&gt;$Z_\min$&lt;/span&gt;) will have an &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; value with a good deviation from &lt;span class=&quot;math-container&quot;&gt;$X_\min$&lt;/span&gt; (which is unknown).&lt;/p&gt;&#xA;&lt;p&gt;Is there any theoretical theory that states which is better: to minimize w.r.t &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; (the lower bound) or w.r.t &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; (the upper bound) if we can't minimize w.r.t to &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3480" LastEditorUserId="123" LastEditDate="2021-02-20T10:36:41.707" LastActivityDate="2021-02-20T12:01:59.913" Title="Which is better to minimize w.r.t a lower bound or an upper bound of an objective function?" Tags="|optimization|modeling|bounds|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5750" PostTypeId="2" ParentId="5749" CreationDate="2021-02-20T11:36:49.883" Score="5" Body="&lt;p&gt;Both might provide useful approximations, but minimizing the &lt;em&gt;underestimator&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is a &lt;em&gt;relaxation&lt;/em&gt; in the sense that an optimal solution yields a lower bound on the minimum &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;.  Bill Cook and his team exploit this idea to solve large TSPs when the edge costs are road distances.  The number of pairs is too large to query Google for all of them, so geodetic distance is used as a lower bound, and only the edges that appear in a solution are actually queried.  This approach (which you can think of as Benders decomposition with optimality cuts only) can take several rounds but reduces the overall number queries substantially while still yielding an optimal tour with respect to road distances. See &lt;a href=&quot;http://www.math.uwaterloo.ca/tsp/uk/index.html&quot; rel=&quot;noreferrer&quot;&gt;http://www.math.uwaterloo.ca/tsp/uk/index.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you were maximizing &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; instead, the &lt;em&gt;overestimator&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; would provide a relaxation.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-02-20T12:01:59.913" LastActivityDate="2021-02-20T12:01:59.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5751" PostTypeId="1" CreationDate="2021-02-20T13:05:18.107" Score="2" ViewCount="48" Body="&lt;p&gt;A fruit supplier sells 3 types of fruits. The company has 3 salespersons.&lt;/p&gt;&#xA;&lt;p&gt;Here are the sales quantity of each person for each fruit. The total sales figure is available. (this is all the available data)&lt;/p&gt;&#xA;&lt;p&gt;Because of different reasons, e.g. season, event, bulk purchase, etc. The unit sales prices were all different (and has no record in place).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hIr2e.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hIr2e.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the new year, management wants to estimate how many new (in addition to the old) business these 3 salespersons can bring in.&lt;/p&gt;&#xA;&lt;p&gt;Assuming each new customer is $100, How many new customers that David, Mike, and Lilly can generate in the new year?&lt;/p&gt;&#xA;&lt;p&gt;An idea:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;I. to calculate the weight of the sales of each fruit type in 2020&#xA;II. multiple the fruit quantity each by the calculated weight (I)&#xA;III. Sum all the II of each person&#xA;IV. to calculate each person's III's weight in all IIIs.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The IV of each person is the expectations of new customers, i.e. David is expected to bring in 3 customers, Mike will bring 5 etc.&lt;/p&gt;&#xA;&lt;p&gt;Does this idea make sense? What would be a better choice and why?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6c7lv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6c7lv.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2440" LastEditorUserId="491" LastEditDate="2021-02-20T15:46:38.350" LastActivityDate="2021-02-20T15:46:38.350" Title="To estimate new sales from history" Tags="|linear-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5752" PostTypeId="1" CreationDate="2021-02-20T16:05:13.323" Score="4" ViewCount="243" Body="&lt;p&gt;I've long wondered this, but what is the algorithm(s) implemented in modern linear equation solvers for sparse systems?&lt;/p&gt;&#xA;&lt;p&gt;The obvious answer I can think of is Gauss-Jordan with a bunch of tricks to make it computationally efficient and exploit sparsity, or LU decompositions (e.g. &lt;a href=&quot;https://eigen.tuxfamily.org/dox/group__TutorialLinearAlgebra.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;the ones in Eigen&lt;/a&gt;), but are there any different algorithms that are commonly used?&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-02-21T11:07:22.617" LastActivityDate="2021-02-21T11:07:22.617" Title="Algorithms for sparse linear systems" Tags="|linear-programming|algorithms|linear-algebra|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5753" PostTypeId="2" ParentId="5752" CreationDate="2021-02-20T16:25:44.367" Score="7" Body="&lt;p&gt;The following isn't meant to be exhaustive. It usually depends on the structure of the matrix because that impacts the way you choose it. In general there are sparse variants for many of the general matrix decompositions you see LU, QR, SVD and what not. There are also sparse Kyrlov methods such as the shifted Block Lanczos method. If it isn't symmetric then there is the Arnoldi algorithm which they use in GMRES (there is a sparse variant). There are a bunch of tricks they do use like&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Preconditioning&lt;/li&gt;&#xA;&lt;li&gt;Restarting&lt;/li&gt;&#xA;&lt;li&gt;Shifting (in terms of eigenvalue methods).&lt;/li&gt;&#xA;&lt;li&gt;The Hessenberg reduction which cuts the computations in half for Krylov methods.&lt;/li&gt;&#xA;&lt;li&gt;Randomization has become very popular in the last 20 years.&lt;/li&gt;&#xA;&lt;li&gt;Convergence speed up methods like Nesterov's method.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Usually the reasoning for choosing one over the other is a combination of the size of the matrix, the conditioning and any relevant structure. MATLAB has a detailed explanation of how the backslash operator works which you can see below. If you look on a website like the NETLIB it has the actual code for most of LAPACK (&lt;a href=&quot;https://www.netlib.org/&quot; rel=&quot;noreferrer&quot;&gt;https://www.netlib.org/&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TtnDy.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TtnDy.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4955" LastEditorUserId="4955" LastEditDate="2021-02-20T17:09:36.170" LastActivityDate="2021-02-20T17:09:36.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5754" PostTypeId="1" AcceptedAnswerId="5755" CreationDate="2021-02-20T20:17:26.077" Score="4" ViewCount="153" Body="&lt;p&gt;In the GAMS documentation concerning non-smooth optimization I found the following statement:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A smooth approximation for &lt;span class=&quot;math-container&quot;&gt;$\max(f(x),g(y))$&lt;/span&gt; is as in the following example code:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;[f(x) + g(y) + sqrt(sqr(f(x)-g(y)) + sqr(delta))] /2&lt;/code&gt; where &lt;code&gt;delta&lt;/code&gt; a small number.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Does something similar exist for &lt;span class=&quot;math-container&quot;&gt;$\max(f_1(x),f_2(x),\cdots,f_n(x))$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2021-02-21T10:23:38.947" LastActivityDate="2021-02-21T10:23:38.947" Title="Smooth approximation of $\max(f_1(x),f_2(x),\cdots,f_n(x))$" Tags="|nonlinear-programming|approximation|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5755" PostTypeId="2" ParentId="5754" CreationDate="2021-02-20T20:42:15.443" Score="7" Body="&lt;p&gt;Indeed, there exists numerous smooth approximations for the max function.&#xA;One of the most well known approximation is the Kreisselmeier-Steinhauser (KS) functional, that approximates the non-smooth functional&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max(f_1(x), \cdots, f_n(x))&#xA;$$&lt;/span&gt;&#xA;with the smooth functional&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;KS(f_1, \cdots, f_n; \rho) = \frac{1}{\rho} \log{\sum_{i=1}^n w_i e^{\rho f_i} } &#xA;= \max_i f_i \; + \; \frac{1}{\rho} \log{\sum_{i=1}^n w_i e^{\rho (f_i - \max_i(f_i))} } &#xA;$$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$\rho&amp;gt;0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_1, \cdots, w_n$&lt;/span&gt; given (positive) weights.&lt;/p&gt;&#xA;&lt;p&gt;This functional satisfies:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$KS(f_1, \cdots, f_n; \rho) &amp;gt; \max_i(f_i)$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$\rho &amp;gt;0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\lim_{\rho \to +\infty} KS(f_1, \cdots, f_n; \rho) \to \max_i(f_i)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\max_i(f_i) &amp;lt; KS(f_1, \cdots, f_n; \rho) \leq \max_i(f_i) + \frac{\log(n)}{\rho} $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You could find more details about the KS functional in&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Polyak, R. A. &amp;quot;Smooth optimization methods for minimax problems.&amp;quot; SIAM Journal on Control and Optimization 26.6 (1988): 1274-1286.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2452" LastEditorUserId="123" LastEditDate="2021-02-21T10:20:46.807" LastActivityDate="2021-02-21T10:20:46.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5756" PostTypeId="1" CreationDate="2021-02-20T22:08:13.227" Score="2" ViewCount="106" Body="&lt;p&gt;I have an MILP as below&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{equation}&#xA; \begin{array}{*{35}{l}}&#xA;\underset{d_{u,c}}{\max}\hspace{1mm}\hspace{1mm}\sum_{u=1}^{U}\sum_{c=1}^{C}d_{u,c}\omega_{u,c}\\&#xA;\text{}\text{subject to }\text{ C1:} \hspace{2mm}1\le \sum_{c=1}^Cd_{u,c}\le 10,\forall u, u=1,\cdots, U, \\&#xA;\text{}\hspace{16.5mm}\text{ C2:} \hspace{2mm}\sum_{u=1}^U d_{u,c}\le 50,\forall c, c=1,\cdots, C, \\&#xA;\end{array}&#xA;\end{equation}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In addition, I want to enforce that for &lt;span class=&quot;math-container&quot;&gt;$\omega_{u,c}&amp;lt;t_{\min}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_{u,c}=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Should I replace the entries of &lt;span class=&quot;math-container&quot;&gt;$\omega_{u,c}$&lt;/span&gt; that are less than &lt;span class=&quot;math-container&quot;&gt;$&amp;lt;t_{\min}$&lt;/span&gt; to 0 or negative value, or add a new constraint?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="123" LastEditDate="2021-02-21T10:20:20.517" LastActivityDate="2021-02-21T10:20:20.517" Title="Should I process the data or add a new constraint to achieve the target?" Tags="|optimization|combinatorial-optimization|constraint|convex-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5757" PostTypeId="2" ParentId="5748" CreationDate="2021-02-20T22:55:32.253" Score="3" Body="&lt;p&gt;Yes. Assuming that &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; in the text are the same as &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; in the model, then &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; should be &lt;span class=&quot;math-container&quot;&gt;$b_i y_i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-02-20T22:55:32.253" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5758" PostTypeId="2" ParentId="5756" CreationDate="2021-02-20T23:07:23.320" Score="6" Body="&lt;p&gt;Neither. You should delete &lt;span class=&quot;math-container&quot;&gt;$d_{u,c}$&lt;/span&gt; from the model whenever &lt;span class=&quot;math-container&quot;&gt;$\omega_{u,c} &amp;lt; t_\min$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-02-20T23:07:23.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5759" PostTypeId="1" CreationDate="2021-02-21T06:49:53.777" Score="2" ViewCount="42" Body="&lt;p&gt;Suppose there are &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; servers, and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; users. The &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; users are to be assigned to the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; servers similar to classic scheduling problems. The cost of using servers is given by &lt;span class=&quot;math-container&quot;&gt;$c(|x|)$&lt;/span&gt; which is an increasing function of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, the number of servers. The more the number of servers used, the higher the cost function. There is another load function &lt;span class=&quot;math-container&quot;&gt;$L(x_i)$&lt;/span&gt; which indicates the load, i.e. number of users assigned to each server &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. The optimization objective is to Minimize the cost function of the servers, i.e. Minimize &lt;span class=&quot;math-container&quot;&gt;$c(|x|)$&lt;/span&gt; such that the load at each server is within a pre-specified limit, i.e, &lt;span class=&quot;math-container&quot;&gt;$L(x_i) \leq k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If we look at the solution space of the problem, it comprises an exponential number of choices representing each user-server combination as per my understanding goes. What would be a reduction to prove the Hardness of this problem if my intuition about the solution space is indeed correct?&lt;/p&gt;&#xA;" OwnerUserId="584" LastActivityDate="2021-02-21T06:49:53.777" Title="Hardness Reduction for assigning Users to Servers" Tags="|optimization|modeling|computational-complexity|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5760" PostTypeId="2" ParentId="5756" CreationDate="2021-02-21T09:30:05.243" Score="1" Body="&lt;p&gt;To add to @prubin's answer (which is the correct answer) if you somehow need to choose between the two obtions, my advice would be to add the constraints (or better, change the bounds on the variables). Obviously, a good solver will immediately identify the variables with a negativ profit and set their value to zero, but a bad/homebrew solver might not. Thus, you help the solver more by giving the values of the fixed variables explicitly, compared to &lt;em&gt;indicating&lt;/em&gt; the values.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-02-21T09:30:05.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5761" PostTypeId="1" CreationDate="2021-02-21T11:51:22.967" Score="4" ViewCount="102" Body="&lt;p&gt;I would be interested in knowing if finding a maximum clique in &lt;a href=&quot;https://en.wikipedia.org/wiki/Circulant_graph&quot; rel=&quot;nofollow noreferrer&quot;&gt;circulant graphs&lt;/a&gt; is NP-hard? Does anybody have any pointers or papers to suggest?&lt;/p&gt;&#xA;" OwnerUserId="4987" LastEditorUserId="123" LastEditDate="2021-02-21T14:25:54.690" LastActivityDate="2021-02-22T02:50:40.427" Title="Does anybody know the complexity of finding a maximum clique in circulant graphs?" Tags="|reference-request|combinatorial-optimization|graphs|computational-complexity|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5762" PostTypeId="1" CreationDate="2021-02-21T12:17:22.510" Score="2" ViewCount="436" Body="&lt;p&gt;Currently I am coding the &lt;strong&gt;ALNS algorithm for the vehicle routing problem&lt;/strong&gt; .&lt;/p&gt;&#xA;&lt;p&gt;I am stuck in the &lt;strong&gt;operator selection phase&lt;/strong&gt;, I did not understand how I can apply this formula: &lt;span class=&quot;math-container&quot;&gt;$$p_i=\frac{f_i}{\sum_{j=1}^Nf_j}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Please can someone post some little ALNS java code with the roulette-wheel-selection?&lt;/p&gt;&#xA;" OwnerUserId="4942" LastEditorUserId="491" LastEditDate="2021-03-15T12:45:01.720" LastActivityDate="2021-03-15T12:45:01.720" Title="ALNS java code with the roulette-wheel-selection?" Tags="|metaheuristics|java|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5763" PostTypeId="2" ParentId="5762" CreationDate="2021-02-21T17:09:33.720" Score="2" Body="&lt;p&gt;The idea behind roulette wheel selection is to use a random number generator to pick an index, so that the probability of index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; being selected is your &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt;. One way to do this is to compute partial sums &lt;span class=&quot;math-container&quot;&gt;$s_i = \sum_{j=1}^i p_j$&lt;/span&gt;, then generate a random value &lt;span class=&quot;math-container&quot;&gt;$u~U(0,1)$&lt;/span&gt; and pick the largest index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$u\le s_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Below is a Java function that does it slightly differently. Rather than computing the partial sums, it subtracts each &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; until &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; goes negative, at which point you have the &amp;quot;winning&amp;quot; index. The input vector to the function is your &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;. Since Java uses 0-based indexing, it return an index in &lt;span class=&quot;math-container&quot;&gt;$\lbrace 0,\dots,N-1\rbrace$&lt;/span&gt; rather than &lt;span class=&quot;math-container&quot;&gt;$\lbrace 1,\dots,N\rbrace$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  /**&#xA;   * Selects an input entry using roulette wheel selection,&#xA;   * where the probability of an entry being chosen is proportional to its&#xA;   * input value.&#xA;   * @param input the vector of input values&#xA;   * @param rng the random number generator to use for selection&#xA;   * @return the 0-based index of the selected entry&#xA;   */&#xA;  private int roulette(final double[] input, final Random rng) {&#xA;    // Sum the input vector.&#xA;    double sum = Arrays.stream(input).sum();&#xA;    // Calculate probabilities by dividing inputs by the sum.&#xA;    double[] prob = Arrays.stream(input).map((x) -&amp;gt; x / sum).toArray();&#xA;    // Generate an observation from the U[0,1] distribution.&#xA;    double u = rng.nextDouble();&#xA;    // Find the first index for which the cumulative sum of the probabilities&#xA;    // is greater than the observation. Rather than summing the probabilities,&#xA;    // we subtract each probability from the observation until the difference&#xA;    // becomes negative.&#xA;    for (int i = 0; i &amp;lt; input.length; i++) {&#xA;      u -= prob[i];&#xA;      if (u &amp;lt; 0) {&#xA;        return i;&#xA;      }&#xA;    }&#xA;    // We should never reach this point, but to appease the compiler we need&#xA;    // a return value here. It would have to be the highest index.&#xA;    return input.length - 1;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-02-21T17:09:33.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5764" PostTypeId="1" CreationDate="2021-02-21T17:35:26.450" Score="1" ViewCount="127" Body="&lt;p&gt;All the examples I saw so far were for the case when lead time is smaller than the cycle period. What should the reorder point be if lead time is higher than the cycle time? Should I just simply order 2 cycles in advance or something?&lt;/p&gt;&#xA;" OwnerUserId="4988" LastEditorUserId="36" LastEditDate="2021-02-21T18:07:44.843" LastActivityDate="2022-10-22T14:35:00.933" Title="Lead time higher than cycle time in static EOQ model" Tags="|inventory|economic-order-quantity|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5765" PostTypeId="1" AcceptedAnswerId="5766" CreationDate="2021-02-21T19:27:51.253" Score="3" ViewCount="642" Body="&lt;p&gt;I was usually using if-then constraints with integer variables but ended up using continuous variables and got confused. I have variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}\in\mathbb{R}_{\geq 0}$&lt;/span&gt;, and would like to force the program: if &lt;span class=&quot;math-container&quot;&gt;$x_{ij}&amp;gt;0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_{ji}=0$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$i,j\in\mathcal{I}$&lt;/span&gt;. When I use the following (in which &lt;span class=&quot;math-container&quot;&gt;$\mathbb{M}$&lt;/span&gt; is a big number), it looks like the constraint serves to the purpose.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{ij}\geq \mathbb{M}x_{ji} \qquad \forall i,j\in\mathcal{I}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, it does a bit further than what is expected and undesired, which is &lt;span class=&quot;math-container&quot;&gt;$x_{ji}=0$&lt;/span&gt;, when &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=0$&lt;/span&gt;. The symmetry of this will be conflicting. My variable essentially denotes a flow amount from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and I would like to ensure: if flow occurs from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, it should not occur from &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="491" LastEditDate="2021-04-14T15:11:22.717" LastActivityDate="2021-04-19T07:30:32.843" Title="If-then constraint with continuous variables" Tags="|linear-programming|constraint|indicator-constraints|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5766" PostTypeId="2" ParentId="5765" CreationDate="2021-02-21T20:08:25.123" Score="7" Body="&lt;p&gt;Introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; and linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{i,j} &amp;amp;\le M y_{i,j} \tag1 \\&#xA;y_{i,j} + y_{j,i} &amp;amp;\le 1 \tag2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$x_{i,j} &amp;gt; 0 \implies y_{i,j} = 1$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y_{i,j} = 1 \implies y_{j,i} = 0$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; (with the roles of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; interchanged) enforces &lt;span class=&quot;math-container&quot;&gt;$y_{j,i} = 0 \implies x_{j,i} = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-02-21T20:08:25.123" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5767" PostTypeId="1" CreationDate="2021-02-21T21:10:28.460" Score="3" ViewCount="219" Body="&lt;p&gt;I have a nonlinearly-constrained model and wonder if a nonlinear solver like Ipopt or Knitro can solve the problem.&lt;/p&gt;&#xA;&lt;p&gt;Briefly, my objective function is linear. I have the following variables with their associated domains: &lt;span class=&quot;math-container&quot;&gt;$d^\tau_i, d^\rho_o, y_{ij}, \eta_{ij}\in \mathbb{R}_{\geq 0}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i, z_{oo^\prime}\in \{0,1\}$&lt;/span&gt;. The used sets are &lt;span class=&quot;math-container&quot;&gt;$\mathcal{I}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mathcal{O}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{V}=\mathcal{I}\cup\mathcal{O}$&lt;/span&gt;. You may assume all variables are created based on &lt;span class=&quot;math-container&quot;&gt;$\mathcal{V}$&lt;/span&gt; to sort of ease the interpretability. All symbols other than the aforementioned are parameters in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}_{\geq 0}$&lt;/span&gt;. I have a bunch of linear constraints listed below (big M has a tight bound):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \sum_{o\in\mathcal{O}}y_{io} \leq K_i \qquad \forall i\in\mathcal{I}.&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    K_i x_i \geq y_{io} \qquad \forall i\in\mathcal{I}, o\in\mathcal{O}.&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    L_i^\tau \leq d^\tau_i \leq U_i^\tau \qquad \forall i\in\mathcal{I}.&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    L_o^\rho \leq d^\rho_o \leq U_o^\rho \qquad \forall o\in\mathcal{O}.&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    y_{o o^\prime} \leq \mathbb{M} z_{oo^\prime}, z_{oo^\prime}+z_{o^\prime o} \leq 1 \qquad \forall o,o^\prime \in \mathcal{O}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and the following nonlinear constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \sum_{o^\prime\in\mathcal{O}\land o^\prime\neq o}y_{oo^\prime} \leq \sum_{j\in\mathcal{V}\land j\neq o}\eta_{jo}y_{jo} \qquad \forall o\in\mathcal{O}.&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \sum_{j\in\mathcal{V}\land j\neq o}\eta_{jo}y_{jo} \geq E_o \qquad \forall o\in\mathcal{O}.&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and the following additional nonlinear constraints including the exponential function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \eta_{io} = 1-e^{\displaystyle d^\tau_i d^\rho_o} \qquad \forall i\in\mathcal{I}, o\in\mathcal{O}.&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \eta_{oo^\prime} = 1-e^{\displaystyle d^\rho_o d^\rho_{o^\prime}} \qquad \forall o,o^\prime\in\mathcal{O}, o\neq o^\prime.&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you may notice, the above are the sources of the nonlinearity. As a person living in the linear world, I am not sure (aware) if Knitro or Ipopt can handle such a model as there exists a chain of continuous variable multiplications. If they can do so, what do you think the magnitude of &lt;span class=&quot;math-container&quot;&gt;$|\mathcal{V}|$&lt;/span&gt; it can tackle?&lt;/p&gt;&#xA;&lt;p&gt;I guess, I should also clarify that I am not chasing the global optimality when I ask if the above nonlinear solvers can handle the problem. A locally optimal solution (if one exists) could be satisfactory.&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="518" LastEditDate="2021-02-21T21:31:21.897" LastActivityDate="2021-02-21T21:31:21.897" Title="Solving a nonlinear model with constraints of exponential functions and continuous variable multiplications" Tags="|mixed-integer-programming|nonlinear-programming|minlp|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5768" PostTypeId="2" ParentId="4963" CreationDate="2021-02-21T23:19:37.437" Score="2" Body="&lt;p&gt;One of the main ideas behind our decomposition solver GCG (gcg.or.rwth-aachen.de/dev) is to save you the time experimenting with your own B&amp;amp;P code only to find out that B&amp;amp;P is not the right approach to your problem. One other main idea of our solver is that once you found out &lt;em&gt;that&lt;/em&gt; B&amp;amp;P is a good approach then you can just use GCG to do the job for you. Give it a try, it hopefully saves you some hours. Download with SCIP at scipopt.org.&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2021-02-21T23:19:37.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5769" PostTypeId="2" ParentId="5761" CreationDate="2021-02-22T02:40:53.133" Score="5" Body="&lt;p&gt;It is NP-hard:&lt;/p&gt;&#xA;&lt;p&gt;Bruno Codenotti, Ivan Gerace, Sebastiano Vigna.&#xA;Hardness results and spectral techniques for combinatorial problems on circulant graphs,&#xA;&lt;em&gt;Linear Algebra and its Applications&lt;/em&gt; &lt;strong&gt;285&lt;/strong&gt; (1-3), pages 123-142, 1998, &lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.78.6028&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;noreferrer&quot;&gt;pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Other Cayley graphs have been studied by Chris Godsil and Brendan Rooney in the paper &lt;a href=&quot;https://arxiv.org/abs/1502.00965&quot; rel=&quot;noreferrer&quot;&gt;Hardness of Computing Clique Number and Chromatic Number For Cayley Graphs&lt;/a&gt;, &lt;em&gt;European Journal of Combinatorics&lt;/em&gt; &lt;strong&gt;62&lt;/strong&gt;, pages 147-166, 2017&lt;/p&gt;&#xA;" OwnerUserId="741" LastEditorUserId="741" LastEditDate="2021-02-22T02:50:40.427" LastActivityDate="2021-02-22T02:50:40.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5770" PostTypeId="1" CreationDate="2021-02-22T04:50:42.243" Score="7" ViewCount="1032" Body="&lt;p&gt;I am looking for a textbook on linear programming  decomposition fundamentals.&#xA;The book should be clear and easy-to-follow for self study and should include examples to illustrate the concepts.&lt;/p&gt;&#xA;" OwnerUserId="4735" LastEditorUserId="491" LastEditDate="2021-02-22T14:40:48.540" LastActivityDate="2021-02-23T01:28:37.483" Title="Textbook recommendation for linear programming decomposition fundamentals" Tags="|reference-request|benders-decomposition|books|lagrangian-decomposition|lp-decomposition|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5771" PostTypeId="2" ParentId="5770" CreationDate="2021-02-22T09:44:33.520" Score="8" Body="&lt;p&gt;I propose reading the following textbook:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.wiley.com/en-au/Linear+Programming+and+Network+Flows%2C+4th+Edition-p-9780470462720&quot; rel=&quot;noreferrer&quot;&gt;Linear Programming and Network Flows by by Hanif D. Sherali, John J.&#xA;Jarvis, and M. S. Bazaraa&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I read the first 7 chapters of the book a long time ago (during my Bachelor studies), and I really enjoyed it. Chapter 7 of the book titled &lt;code&gt;THE DECOMPOSITION PRINCIPLE&lt;/code&gt; introduces Dantzig-Wolfe decomposition and its relationships with Benders decomposition and Lagrangian relaxation (for linear programming). As in other chapters of the book, Chapter 7 includes quite a few numerical examples which are very insightful.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2021-02-22T09:44:33.520" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5772" PostTypeId="2" ParentId="5770" CreationDate="2021-02-22T12:26:54.737" Score="7" Body="&lt;p&gt;I took the &lt;a href=&quot;https://kurser.dtu.dk/course/42136&quot; rel=&quot;noreferrer&quot;&gt;course 42136&lt;/a&gt; for Benders decomposition and Dantzig-Wolfe (DW) decomposition at Technical University of Denmark. Besides the textbook [conejo2006decomposition] (mentioned by @A.Omidi as well), following materials are recommended:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;[carøe1998l], chapter 5.1 in [birge2011introduction] for L-shaped Benders Decomposition, in terms of two-stage (stochastic) MILP with first-stage integer variables&lt;/li&gt;&#xA;&lt;li&gt;[desrosiers2005primer] for basics of DW&lt;/li&gt;&#xA;&lt;li&gt;[feillet2010tutorial] for vehicle routing with DW&lt;/li&gt;&#xA;&lt;li&gt;[merle1999stabilized] and [rousseau2007interior] for stabilization in column generation in DW&lt;/li&gt;&#xA;&lt;li&gt;[lübbecke2005selected] for DW in depth&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;By the way, Benders' decomposition is integrated in CPLEX Versions 12.7 and later. We got a guest lecture from IBM that time. See &lt;a href=&quot;https://www.ibm.com/support/pages/how-implement-benders-decomposition-using-cplex&quot; rel=&quot;noreferrer&quot;&gt;How to implement Benders' decomposition using CPLEX, IBM support&lt;/a&gt;. In particular:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The Benders' strategy parameter controls how CPLEX does the decomposition.  The easiest way to use it consists of setting this parameter to 3 to instruct CPLEX to do the decomposition automatically, putting the constraints that intersect only integer variables into the master problem.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;[conejo2006decomposition] Conejo, A. J., Castillo, E., Minguez, R., &amp;amp; Garcia-Bertrand, R. (2006). Decomposition techniques in mathematical programming: engineering and science applications. Springer Science &amp;amp; Business Media.&lt;/li&gt;&#xA;&lt;li&gt;[carøe1998l] Carøe, C. C., &amp;amp; Tind, J. (1998). L-shaped decomposition of two-stage stochastic programs with integer recourse. Mathematical Programming, 83(1), 451-464.&lt;/li&gt;&#xA;&lt;li&gt;[birge2011introduction] Birge, J. R., &amp;amp; Louveaux, F. (2011). Introduction to stochastic programming. Springer Science &amp;amp; Business Media.&lt;/li&gt;&#xA;&lt;li&gt;[desrosiers2005primer] Desrosiers, J., &amp;amp; Lübbecke, M. E. (2005). A primer in column generation. In Column generation (pp. 1-32). Springer, Boston, MA.&lt;/li&gt;&#xA;&lt;li&gt;[lübbecke2005selected] Lübbecke, M. E., &amp;amp; Desrosiers, J. (2005). Selected topics in column generation. Operations research, 53(6), 1007-1023.&lt;/li&gt;&#xA;&lt;li&gt;[rousseau2007interior] Rousseau, L. M., Gendreau, M., &amp;amp; Feillet, D. (2007). Interior point stabilization for column generation. Operations Research Letters, 35(5), 660-668.&lt;/li&gt;&#xA;&lt;li&gt;[merle1999stabilized] Du Merle, O., Villeneuve, D., Desrosiers, J., &amp;amp; Hansen, P. (1999). Stabilized column generation. Discrete Mathematics, 194(1-3), 229-237.&lt;/li&gt;&#xA;&lt;li&gt;[feillet2010tutorial] Feillet, D. (2010). A tutorial on column generation and branch-and-price for vehicle routing problems. 4or, 8(4), 407-424.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3163" LastActivityDate="2021-02-22T12:26:54.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5773" PostTypeId="1" AcceptedAnswerId="5781" CreationDate="2021-02-22T14:45:07.460" Score="4" ViewCount="706" Body="&lt;p&gt;Although I asked this question on stackoverflow to possibly reach a broader audience, I wonder your inputs about this problem. Without giving much research into this, I thought p-center problem (&lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1$&lt;/span&gt; if point is clustered around point &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;; 0, otherwise) can be useful to construct a simple model to partition the points into equally-sized clusters. With a proper constraint, I could also let &lt;span class=&quot;math-container&quot;&gt;$x_{ij}\in\mathbb{R}_{\geq 0}$&lt;/span&gt;, I guess. I am just afraid that the problem size might be too large for the exact solution, hence I tried to find the cure in heuristic/algorithmic solutions world. How would you approach this problem?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/66295810/clustering-with-distance-matrix-in-sklearn-agglomerative&quot;&gt;Cross-posted&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;p&gt;I am trying to cluster a dataset with 3,663 points. I have (x,y) coordinates and point-to-point weights available. Since I would like to use the weights instead of Euclidean distances, I implemented the AgglomerativeClustering with Python's sklearn thanks to Vivek Kumar's answer &lt;a href=&quot;https://stackoverflow.com/questions/53849107/sklearn-agglomerative-clustering-custom-affinity&quot;&gt;here&lt;/a&gt;. I created 20 clusters and had the following number of points in each cluster:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Num_points_in_cluster = [673,54,111,88,312,464,332,366,141,128,33,86,426,39,45,1,63,105,2,194]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As seen, some clusters have only 1 or 2 point(s). I would instead like to have number of points in clusters almost uniformly distributed. Is there a way to play around this within AgglomarativeClustering or is there any other method (preferably in sklearn world) that meets the criterion? I think, an alternative solution could be solving a p-center-like problem, but the time performance of off-the-shelf linear solvers can be a bottleneck as I also would like a quick solution.&lt;/p&gt;&#xA;&lt;p&gt;For code-checking purposes, here is my code, where TT_np_matrix is my weight matrix in numpy matrix type, e.g., &lt;code&gt;TT_np_matrix  = array([[2,3,4],[5,2,3],[4,5,8]])&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;agg = AgglomerativeClustering(n_clusters=20, affinity='precomputed',&#xA;                                  linkage='average')&#xA;agg_results = agg.fit_predict(TT_np_matrix) # The solution is an array&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Below is my (though I say &amp;quot;my,&amp;quot; it most likely exists somewhere readily) formulation to solve the problem with binary/linear programming.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min&amp;amp;\quad \sum_{i,j\in I}c_{ij}x_{ij}&amp;amp;\\&#xA;\text{s.t.}&amp;amp;\quad \sum_{j\in I} y_{j} =k &amp;amp; \\&#xA;&amp;amp;\quad \sum_{i\in I}x_{ij}\geq \lfloor |I|/k\rfloor y_j &amp;amp;\forall j\in I\\&#xA;&amp;amp;\quad \sum_{j\in I}x_{ij}=1 &amp;amp;\forall i\in I\\&#xA;&amp;amp;\quad x_{ij}\leq y_j &amp;amp;\forall i,j\in I\\&#xA;&amp;amp;\quad x,y\in\{0,1\},&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1$&lt;/span&gt; if point &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; is centered around point &lt;span class=&quot;math-container&quot;&gt;$j\in I$&lt;/span&gt;; &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, otherwise, and &lt;span class=&quot;math-container&quot;&gt;$y_j=1$&lt;/span&gt; if point &lt;span class=&quot;math-container&quot;&gt;$j\in I$&lt;/span&gt; is selected as a center; &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, otherwise. Here, &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; defines the number of clusters, and &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; denotes the set of points to be clustered/partitioned.&lt;/p&gt;&#xA;&lt;p&gt;Although I write this, I do not want to implement it as I believe it will be computationally more expensive (regardless of exactness) than an off-the-shelf so-called machine learning clustering algorithm. I am instead seeking an open-source implementable function or its example coded in Python (too much constraint, sorry).&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="518" LastEditDate="2021-02-27T12:02:18.113" LastActivityDate="2024-04-04T04:53:34.393" Title="Clustering points based on a distance matrix" Tags="|linear-programming|clustering|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5774" PostTypeId="1" AcceptedAnswerId="5775" CreationDate="2021-02-22T15:34:12.663" Score="3" ViewCount="239" Body="&lt;p&gt;I would like to define a difference equation in pyomo for a temperature variable. The equation (simplified) looks like:&#xA;&lt;span class=&quot;math-container&quot;&gt;$Temperature(t) = Temperature (t-1) + x(t)$&lt;/span&gt; , for t&amp;gt;0&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Temperature (0) = 20 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So this is what I tried in Pyomo&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.set_timeslots = pyo.RangeSet(0,95)  &#xA;&#xA;model.variable_x = pyo.Var(model.set_timeslots, within=pyo.Binary)  &#xA;model.variable_temperature[0].fix(20)&#xA;&#xA;def temperatureConstraintRule(model):&#xA;    model.variable_temperature(t) = model.variable_temperature(t-1) + model.variable_x(t) &#xA;model.constraint_temperature = pyo.Constraint (model.set_timeslots, rule=temperatureConstraintRule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, I get the error message &amp;quot;SyntaxError: can't assign to function call&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Can anybody tell me how I can implement this difference equation in Pyomo?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="491" LastEditDate="2021-02-22T18:57:54.657" LastActivityDate="2021-02-22T18:57:54.657" Title="How to implement a difference equation in Pyomo" Tags="|python|pyomo|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5775" PostTypeId="2" ParentId="5774" CreationDate="2021-02-22T16:25:23.010" Score="3" Body="&lt;p&gt;try:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.set_timeslots = pyo.RangeSet(0,95)  &#xA;&#xA;model.variable_x = pyo.Var(model.set_timeslots, within=pyo.Binary)  &#xA;i0 = 20&#xA;&#xA;def temperatureConstraintRule(model, t):&#xA;    if t == model.set_timeslots.first():&#xA;         return model.variable_x[t] == i0 + model.variable_x[t]&#xA;    return model.variable_x[t] == model.variable_x[t-1] + model.variable_x[t]&#xA;model.constraint_temperature = Constraint(model.set_timeslots, rule=temperatureConstraintRule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="329" LastActivityDate="2021-02-22T16:25:23.010" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5776" PostTypeId="1" AcceptedAnswerId="5777" CreationDate="2021-02-22T17:29:28.773" Score="1" ViewCount="221" Body="&lt;p&gt;This is a practice in using reduction. Suppose I have a solver that only allows input to a MCF that specifies only one demand and one supply node. How could I use this solver to solve general MCF problems? I have been attempting to solve this with the following toy model:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;&#xA;vertices = [1,2,3,4,5,6]&#xA;&#xA;arcs, capacity = gp.multidict({&#xA;    (1,2) : 2,&#xA;    (1,6) : 2,&#xA;    (2,1) : 2,&#xA;    (2,5) : 2,&#xA;    (3,2) : 2,&#xA;    (4,3) : 2,&#xA;    (4,2) : 2,&#xA;    (5,4) : 2,&#xA;    (5,6) : 2,&#xA;    (6,5) : 2&#xA;})&#xA;&#xA;cost = {&#xA;    (1,2) : 1,&#xA;    (1,6) : 1,&#xA;    (2,1) : 1,&#xA;    (2,5) : 1,&#xA;    (3,2) : 1,&#xA;    (4,3) : 1,&#xA;    (4,2) : 1,&#xA;    (5,4) : 1,&#xA;    (5,6) : 1,&#xA;    (6,5) : 1&#xA;}&#xA;&#xA;supply = {&#xA;    1 : -1,&#xA;    2 : 2,&#xA;    3 : -2,&#xA;    4 : 3,&#xA;    5 : 0,&#xA;    6 : -2&#xA;}&#xA;&#xA;m = gp.Model(&amp;quot;test&amp;quot;)&#xA;&#xA;flow = m.addVars(arcs, obj = cost, name = &amp;quot;flow&amp;quot;)&#xA;&#xA;m.addConstrs(&#xA;    (flow.sum(i,j) &amp;lt;= capacity[i,j] for i,j in arcs), &amp;quot;cap&amp;quot;)&#xA;&#xA;m.addConstrs(&#xA;    (flow.sum(i,'*') - flow.sum('*',i) == supply[i] for i in vertices), &amp;quot;conservation&amp;quot;)&#xA;&#xA;m.optimize()&#xA;&#xA;if m.status == GRB.OPTIMAL:&#xA;        solution = m.getAttr('x', flow)&#xA;        for i, j in arcs:&#xA;            if solution[i, j] &amp;gt; 0:&#xA;                print('%s -&amp;gt; %s: %g' % (i, j, solution[i, j]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now suppose I wish to solve this type of problem with the solver mentioned above. I could make a few changes to the code and get another feasible model:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;&#xA;vertices = [1,2,3,4,5,6]&#xA;&#xA;# we need to change the capacities here to get a feasible model&#xA;arcs, capacity = gp.multidict({&#xA;    (1,2) : 3,&#xA;    (1,6) : 2,&#xA;    (2,1) : 2,&#xA;    (2,5) : 3,&#xA;    (3,2) : 2,&#xA;    (4,3) : 2,&#xA;    (4,2) : 2,&#xA;    (5,4) : 2,&#xA;    (5,6) : 5,&#xA;    (6,5) : 2&#xA;})&#xA;&#xA;cost = {&#xA;    (1,2) : 1,&#xA;    (1,6) : 1,&#xA;    (2,1) : 1,&#xA;    (2,5) : 1,&#xA;    (3,2) : 1,&#xA;    (4,3) : 1,&#xA;    (4,2) : 1,&#xA;    (5,4) : 1,&#xA;    (5,6) : 1,&#xA;    (6,5) : 1&#xA;}&#xA;&#xA;# Now b1 carries all supply and b6 carries all demand&#xA;supply = {&#xA;    1 : 5,&#xA;    2 : 0,&#xA;    3 : 0,&#xA;    4 : 0,&#xA;    5 : 0,&#xA;    6 : -5&#xA;}&#xA;&#xA;m = gp.Model(&amp;quot;test&amp;quot;)&#xA;&#xA;flow = m.addVars(arcs, obj = cost, name = &amp;quot;flow&amp;quot;)&#xA;&#xA;m.addConstrs(&#xA;    (flow.sum(i,j) &amp;lt;= capacity[i,j] for i,j in arcs), &amp;quot;cap&amp;quot;)&#xA;&#xA;m.addConstrs(&#xA;    (flow.sum(i,'*') - flow.sum('*',i) == supply[i] for i in vertices), &amp;quot;conservation&amp;quot;)&#xA;&#xA;m.optimize()&#xA;&#xA;if m.status == GRB.OPTIMAL:&#xA;        solution = m.getAttr('x', flow)&#xA;        for i, j in arcs:&#xA;            if solution[i, j] &amp;gt; 0:&#xA;                print('%s -&amp;gt; %s: %g' % (i, j, solution[i, j]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It does not seem obvious at all to me how to convert this new solution to the original problem. It seems analogous to trying to &amp;quot;unmix&amp;quot; paint here, and I don't think a Fourier transform is applicable in this scenario. In order to get the feasible model, I also had to make changes to the capacities to ensure feasibility, so one idea may be to try to somehow &amp;quot;unwind&amp;quot; these changes in capacity to trace back the steps this flow would take in the general context, but I have no idea how to formalize this. It seems intuitively that better solutions in the one supply/demand node problem would correspond to better solutions in the general case since the costs are equivalent, but again, I am not sure how to formalize this.&lt;/p&gt;&#xA;" OwnerUserId="3231" LastEditorUserId="491" LastEditDate="2021-02-22T18:57:34.890" LastActivityDate="2021-02-22T18:57:34.890" Title="Solving general minimum cost flow problems using only one demand and one supply node" Tags="|optimization|modeling|python|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5777" PostTypeId="2" ParentId="5776" CreationDate="2021-02-22T18:22:21.243" Score="6" Body="&lt;p&gt;Introduce a supersource node &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, a supersink node &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, arcs from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to each source, and arcs from each sink to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.  Arc &lt;span class=&quot;math-container&quot;&gt;$(s,i)$&lt;/span&gt; has zero cost and capacity equal to supply[i].  Arc &lt;span class=&quot;math-container&quot;&gt;$(i,t)$&lt;/span&gt; has zero cost and capacity equal to -supply[i].  All original nodes have supply zero, &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; has supply equal to the sum of positive supplies, and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; has supply equal to the sum of negative supplies (equivalently, demand equal to the sum of demands).&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-02-22T18:40:02.207" LastActivityDate="2021-02-22T18:40:02.207" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5778" PostTypeId="2" ParentId="5773" CreationDate="2021-02-22T21:53:22.047" Score="3" Body="&lt;p&gt;I'm not familiar with agglomarative clustering, but in general terms you are dealing with a bicriterion optimization problem. One criterion has to do with the &amp;quot;affinities&amp;quot; of points in a cluster. You may want to maximize (?) something to do with the pairwise weights. That might be the sum of the weights of all pairs sharing a cluster, or the minimum weight of any pair sharing a cluster, or something else. The second criterion has to do with cluster size. You may want to minimize the range of cluster sizes, or maximize the size of the smallest cluster, or minimize the standard deviation of the cluster sizes, or something else.&lt;/p&gt;&#xA;&lt;p&gt;So your first step is to figure out exactly what your two criteria are. You second step is then to figure out how to manage the competition between them. You can optimize a weighted sum, or optimize one subject to a limit on how bad the other can get, or use some other multiobjective scheme (for instance, goal programming), or just settle for any Pareto efficient solution. Depending on your objectives, you may also need to constrain the number of clusters, to avoid getting each point as its own cluster or one cluster containing all the points. (It's not guaranteed you need to constrain the number of clusters or the size of a cluster.)&lt;/p&gt;&#xA;&lt;p&gt;Once you have nailed down the two objectives and how to merge them, you can probably define a mixed integer programming model, or look for a heuristic or metaheuristic to get a &amp;quot;good&amp;quot; solution. The heuristic might be a clustering method or might just be a general purpose (meta)heuristic.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-02-22T21:53:22.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5779" PostTypeId="2" ParentId="5726" CreationDate="2021-02-22T23:48:28.840" Score="1" Body="&lt;p&gt;I asked this question to the Gurobi support and this is their response:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Gurobi tries to deduce valid bounds for variables in presolve.&#xA;Depending on the bounds of the participating variables, it might be&#xA;possible to construct a partial McCormick relaxation.&lt;/p&gt;&#xA;&lt;p&gt;If Gurobi can't find any bounds for one of the variables, the&#xA;unboundedness is handled via branching. For example, Gurobi could&#xA;branch on the unbounded variable at a large value like 1e6. The &amp;gt;=1e6&#xA;node is deferred for later - this is a case where you would see a&#xA;&amp;quot;postponed&amp;quot; message in the log file. If Gurobi finds a feasible point,&#xA;it can try to derive bounds for the deferred node through constraint&#xA;propagation. It may also be able to compute a certificate of&#xA;infeasibility for the node. Otherwise, the solver doesn't have much&#xA;choice but to keep branching.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2021-02-22T23:48:28.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5780" PostTypeId="2" ParentId="5770" CreationDate="2021-02-23T01:28:37.483" Score="4" Body="&lt;p&gt;Some more references, different than those in the other answers. I added some application papers too. I often find a practical example rather helpful to understand a specific technique.&lt;/p&gt;&#xA;&lt;h2&gt;Classical Benders decompositon:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Martin R.K. (1999) Projection: Benders’ Decomposition. In: Large Scale Linear and Integer Optimization: A Unified Approach. Springer, Boston, MA. &lt;a href=&quot;https://doi.org/10.1007/978-1-4615-4975-8_10&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1007/978-1-4615-4975-8_10&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Bonami P., Salvagnin D., Tramontani A. (2020) Implementing Automatic Benders Decomposition in a Modern MIP Solver. In: Bienstock D., Zambelli G. (eds) Integer Programming and Combinatorial Optimization. IPCO 2020. Lecture Notes in Computer Science, vol 12125. Springer, Cham. &lt;a href=&quot;https://doi.org/10.1007/978-3-030-45771-6_7&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1007/978-3-030-45771-6_7&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Lecture notes Benders Decomposition and Delayed Constraint Generation&#xA;&lt;a href=&quot;https://personal.eur.nl/birbil/ie606/05_Benders_Dec/05_Benders_Dec_Octave.html&quot; rel=&quot;noreferrer&quot;&gt;https://personal.eur.nl/birbil/ie606/05_Benders_Dec/05_Benders_Dec_Octave.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Combinatorial Benders decomposition:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Codato, Gianni, and Matteo Fischetti. &amp;quot;Combinatorial Benders' cuts for mixed-integer linear programming.&amp;quot; Operations Research 54.4 (2006): 756-766.&lt;/li&gt;&#xA;&lt;li&gt;Trick, M. (2010) Combinatorial Benders Approaches to Hard Problems. &lt;a href=&quot;https://mat.tepper.cmu.edu/trick/Talks/alio.pptx&quot; rel=&quot;noreferrer&quot;&gt;https://mat.tepper.cmu.edu/trick/Talks/alio.pptx&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;application: Bai, Lihui, and Paul A. Rubin. &amp;quot;Combinatorial benders cuts for the minimum tollbooth problem.&amp;quot; Operations research 57.6 (2009): 1510-1522.&lt;/li&gt;&#xA;&lt;li&gt;application: Peterson, Benjamin, and Michael A. Trick. &amp;quot;A Benders’ approach to a transportation network design problem.&amp;quot; International Conference on AI and OR Techniques in Constriant Programming for Combinatorial Optimization Problems. Springer, Berlin, Heidelberg, 2009.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Logic-based Benders decomposition:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Hooker, John N., and Greger Ottosson. &amp;quot;Logic-based Benders decomposition.&amp;quot; Mathematical Programming 96.1 (2003): 33-60.&lt;/li&gt;&#xA;&lt;li&gt;Thorsteinsson, Erlendur S. &amp;quot;Branch-and-check: A hybrid framework integrating mixed integer programming and constraint logic programming.&amp;quot; International Conference on Principles and Practice of Constraint Programming. Springer, Berlin, Heidelberg, 2001.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Lagrangean Decomposition:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Colin R. Reeves (Ed.). 1993. Lagrangean Relaxation (chapter 6). In: Modern heuristic techniques for combinatorial problems. John Wiley &amp;amp; Sons, Inc., USA.&lt;/li&gt;&#xA;&lt;li&gt;application: Göthe-Lundgren, Maud, Francesco Maffioli, and Peter Värbrand. A Lagrangean decomposition approach for a prize collecting traveling salesman type problem. Universitetet i Linköping/Tekniska Högskolan i Linköping. Department of Mathematics, 1994.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-02-23T01:28:37.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5781" PostTypeId="2" ParentId="5773" CreationDate="2021-02-23T06:01:09.840" Score="3" Body="&lt;p&gt;To solve this using a p-center formulation, you could use this base model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;P: \min&amp;amp;\quad \sum_{i,j\in I}c_{ij}x_{ij}&amp;amp;\\&#xA;\text{s.t.}&amp;amp;\quad \sum_{j\in I} x_{ij} =1 &amp;amp; \forall i\in I\\&#xA;&amp;amp;\quad \sum_{i\in I}x_{ii}\leq maxClusters &amp;amp;\\&#xA;&amp;amp;\quad x_{ij}\leq x_{jj} &amp;amp;\forall i,j\in I\\&#xA;&amp;amp;\quad u\geq \sum_{i\in I}x_{ij} &amp;amp;\forall j\in I\\&#xA;&amp;amp;\quad l\leq \sum_{i\in I}x_{ij}+M(1-x_{jj}) &amp;amp;\forall j\in I\\&#xA;&amp;amp;\quad x,u,l\geq 0 &amp;amp;\\&#xA;&amp;amp;\quad x_{ii} \;binary &amp;amp; \forall i\in I&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is the set of items, &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; are the assignment variables and variables &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; record the cardinality of respectively the largest and smallest cluster.&#xA;You can then either add an additional constraint like:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\quad u-l \leq maxClusterSizeDifference &amp;amp;&#xA;\end{align}&lt;/span&gt;&#xA;to limit the maximum tolerated difference in cluster size, or, you could add an additional weighted objective term to the objective:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\quad w(u-l) &amp;amp;&#xA;\end{align}&lt;/span&gt;&#xA;,where &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is some weight constant.&#xA;Given that the above model is simple and quick to implement, you might give its implementation a try and see whether a MIP model finds a good enough solution within a very small amount of time. (try setting the MIP emphasis parameter of the solver to focus on finding good feasible solutions fast).&lt;/p&gt;&#xA;&lt;p&gt;The above model would serve as a good benchmark. If speed is really of the essence, I would implement some heuristic. E.g. first partition all your nodes &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; into two clusters (say &lt;span class=&quot;math-container&quot;&gt;$I_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$I_2$&lt;/span&gt;) using the above model. Then recursively, reapply this splitting procedure for each of the new clusters. Continue until the desired number of clusters is reached.&lt;/p&gt;&#xA;&lt;p&gt;Finally, you can use some &lt;a href=&quot;https://stackoverflow.com/questions/5452576/k-means-algorithm-variation-with-equal-cluster-size&quot;&gt;balanced k-means clustering algorithm&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2021-02-23T18:36:56.277" LastActivityDate="2021-02-23T18:36:56.277" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5782" PostTypeId="2" ParentId="5773" CreationDate="2021-02-23T09:11:51.220" Score="3" Body="&lt;p&gt;If you are interested in a model-and-run approach, maybe you can have a look at Hexaly. An example model for basic k-means is given &lt;a href=&quot;https://www.hexaly.com/docs/last/exampletour/kmeans.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. Hexaly finds near-optimal solutions in seconds, with up to 100,000 points to be clustered.&lt;/p&gt;&#xA;&lt;p&gt;Instead of the classical Boolean modeling approach, using so-called set variables makes the model natural to read and compact in memory. Then, the relaxation-free heuristics embedded inside Hexaly allow delivering quality solutions quickly while scaling to large-scale instances.&lt;/p&gt;&#xA;&lt;p&gt;The model is written below using the Hexaly Modeler. You can also find it written for Python, Java, C#, or C++ at the above link.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function model() {&#xA;  // Set decisions: clusters[c] represents the points in cluster c&#xA;  clusters[1..k] &amp;lt;- set(nbObservations);&#xA;&#xA;  // Each point must be in one cluster and one cluster only&#xA;  constraint partition[c in 1..k](clusters[c]);&#xA;&#xA;  // Compute variances&#xA;  for [c in 1..k] {&#xA;    local cluster &amp;lt;- clusters[c];&#xA;    local size &amp;lt;- count(cluster);&#xA;&#xA;    // Compute the centroid of the cluster&#xA;    centroid[d in 0..nbDimensions-1] &amp;lt;- size == 0 ? 0 :&#xA;            sum(cluster, o =&amp;gt; coordinates[o][d]) / size;&#xA;&#xA;    // Compute the variance of the cluster&#xA;    squares[d in 0..nbDimensions-1] &amp;lt;- sum(cluster,&#xA;        o =&amp;gt; pow(coordinates[o][d] - centroid[d], 2));&#xA;    variances[c] &amp;lt;- sum[d in 0..nbDimensions-1](squares[d]);&#xA;  }&#xA;&#xA;  // Minimize the total variance&#xA;  obj &amp;lt;- sum[c in 1..k](variances[c]);&#xA;  minimize obj;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; Please note that Hexaly is a commercial solver. Nevertheless, academic and trial licenses are available for free.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T04:53:34.393" LastActivityDate="2024-04-04T04:53:34.393" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5783" PostTypeId="1" AcceptedAnswerId="5784" CreationDate="2021-02-23T11:10:15.083" Score="6" ViewCount="874" Body="&lt;p&gt;Consider the binary variables &lt;span class=&quot;math-container&quot;&gt;$x, y, z \in \{0,1\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I'd like to formulate the two if-then constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x + y \geq 2 \implies z = 0, \tag{1} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x + y \leq 1 \implies z = 1. \tag{2} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraint (1) can be formulated as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x + y \leq 2 - z.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How to proceed for (2) ?&lt;/p&gt;&#xA;" OwnerUserId="5007" LastEditorUserId="491" LastEditDate="2021-02-23T14:45:34.907" LastActivityDate="2021-02-23T14:45:34.907" Title="How to transform this logical if-then constraint?" Tags="|mixed-integer-programming|modeling|linearization|logical-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5784" PostTypeId="2" ParentId="5783" CreationDate="2021-02-23T11:28:44.747" Score="9" Body="&lt;p&gt;Indeed, for the first constraint you can use:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x+y+z \le 2&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the second one, it might be easier to model the contraposition:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z=0 \quad \Rightarrow \quad x+y \ge 2 \quad \Rightarrow \quad x=y=1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This yields:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;1-z  \le x \\&#xA;1-z  \le y&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-02-23T11:35:31.043" LastActivityDate="2021-02-23T11:35:31.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5786" PostTypeId="2" ParentId="5783" CreationDate="2021-02-23T13:42:34.883" Score="5" Body="&lt;p&gt;You want to linearize &lt;span class=&quot;math-container&quot;&gt;$xy=1-z$&lt;/span&gt;. See &lt;a href=&quot;https://or.stackexchange.com/a/473/500&quot;&gt;https://or.stackexchange.com/a/473/500&lt;/a&gt; for a somewhat automatic derivation of a linearization for &lt;span class=&quot;math-container&quot;&gt;$xy=z$&lt;/span&gt; via conjunctive normal form. You can then replace &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$1-z$&lt;/span&gt; in the resulting constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-02-23T13:42:34.883" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5787" PostTypeId="1" AcceptedAnswerId="5789" CreationDate="2021-02-23T13:57:53.093" Score="1" ViewCount="4296" Body="&lt;p&gt;I would like to see the current results (e.g. MIP gaps) of a solver in pyomo (as in GAMS) while solving the problem. I read that I should use the option &amp;quot;stream-solver&amp;quot; (see for instance here &lt;a href=&quot;https://static1.squarespace.com/static/5492d7f4e4b00040889988bd/t/57bd0f93d482e927298cc9da/1472008085561/3_PyomoFundamentals.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://static1.squarespace.com/static/5492d7f4e4b00040889988bd/t/57bd0f93d482e927298cc9da/1472008085561/3_PyomoFundamentals.pdf&lt;/a&gt;). But I do not know how to apply it. When I put it as a parameter I get an error message. So here you can see what I tried:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;opt = pyo.SolverFactory('glpk')&#xA;results = opt.solve(model, stream-solver=true)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Do you know how I can do that?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="491" LastEditDate="2021-05-07T14:25:14.347" LastActivityDate="2021-05-07T14:25:14.347" Title="How to display results from a solver during solving in Pyomo" Tags="|python|solver|pyomo|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5788" PostTypeId="1" AcceptedAnswerId="5838" CreationDate="2021-02-23T14:06:40.377" Score="4" ViewCount="695" Body="&lt;p&gt;I have a question about referecing set in Pyomo objectives. Basically I have 2 options and I do not understand why one of it works whereas the other yields an error. Here you see them:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.set_timeslots = pyo.RangeSet(0,95)&#xA;&#xA;#Option1&#xA;def ObjectiveRule (model):&#xA;    return sum(model.variable_heatGeneration[t]  for t in model.set_timeslots)&#xA;&#xA;model.objective_costs = pyo.Objective( rule=ObjectiveRule, sense =pyo.minimize)&#xA;&#xA;#Option 2&#xA;def ObjectiveRule_2 (model, t):&#xA;    return sum(model.variable_heatGeneration[t])&#xA;&#xA;model.objective_costs = pyo.Objective(model.set_timeslots, rule=ObjectiveRule_2, sense =pyo.minimize)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The second options leads to the error&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;TypeError: '_GeneralVarData' object is not iterable&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Can you tell me what the difference is and why the second option does not work?&lt;/p&gt;&#xA;&lt;p&gt;Reminder: Can nobody tell me what the difference is?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2021-03-01T09:29:12.960" LastActivityDate="2021-03-02T12:56:16.587" Title="Referencing of sets in Pyomo objectives" Tags="|python|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5789" PostTypeId="2" ParentId="5787" CreationDate="2021-02-23T17:26:57.013" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;tee = True&lt;/code&gt; as a parameter for .solve in Pyomo. Moreover, to access the optimality gap you can use the following code in Pyomo:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;msolver = SolverFactory('glpk')&#xA;solution = msolver.solve(m, tee=True)&#xA;data = solution.Problem._list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then you have a list of detailed information about the problem's solution. For instance&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;LB = data[0].lower_bound&#xA;UB = data[0].upper_bound&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;will give you the LB and UB from which you can calculate the gap.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;Try &lt;code&gt;model.solve(GLPK(options=['--mipgap', '0.02']))&lt;/code&gt; to change the gap value for the solver. Or try &lt;code&gt;msolver.options['mipgap'] = 0.02&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2021-02-23T18:25:45.770" LastActivityDate="2021-02-23T18:25:45.770" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5790" PostTypeId="1" CreationDate="2021-02-23T21:55:10.370" Score="2" ViewCount="137" Body="&lt;p&gt;I am trying to build an optimization model using PYOMO for the daily production of a product demand, minimizing the production cost.&lt;/p&gt;&#xA;&lt;p&gt;I have demand, production capacity (by machine by day), production cost (by machine by day) and delivery cost to produce the products. Some machines have different costs and production capacities to produce the same product.&lt;/p&gt;&#xA;&lt;p&gt;My problem is that I am getting very low production numbers (like 3.981296e-08 ) and  I'm not be able to know where this numbers are getting from.&lt;/p&gt;&#xA;&lt;p&gt;I suppose they are about OF, but I can't see a way to implement them differently.&#xA;Below the code - Any suggestions are welcome.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;### SOURCES:&#xA;import pandas as pd&#xA;from pyomo.environ import *&#xA;&#xA;capacidade = {&#xA;    'MC05': {'PRODUCT_A': 371, 'PRODUCT_B': 371, 'PRODUCT_C': 427},&#xA;    'MC06': {'PRODUCT_A': 396, 'PRODUCT_B': 396, 'PRODUCT_C': 435},&#xA;    'MC07': {'PRODUCT_A': 547, 'PRODUCT_B': 571, 'PRODUCT_C': 1},&#xA;    'MC08': {'PRODUCT_A': 476, 'PRODUCT_B': 497, 'PRODUCT_C': 1},&#xA;    'MC09': {'PRODUCT_A': 657, 'PRODUCT_B': 692, 'PRODUCT_C': 790}&#xA;    }&#xA;df_capacidade = pd.DataFrame(capacidade)&#xA;&#xA;custo = {&#xA;     'MC05': {'PRODUCT_A': 1368, 'PRODUCT_B': 1368, 'PRODUCT_C': 1368},&#xA;     'MC06': {'PRODUCT_A': 1435, 'PRODUCT_B': 1435, 'PRODUCT_C': 1427},&#xA;     'MC07': {'PRODUCT_A': 1189, 'PRODUCT_B': 1207, 'PRODUCT_C': 100000},&#xA;     'MC08': {'PRODUCT_A': 1221, 'PRODUCT_B': 1209, 'PRODUCT_C': 100000},&#xA;     'MC09': {'PRODUCT_A': 1905, 'PRODUCT_B': 1907, 'PRODUCT_C': 1965}&#xA;     } &#xA;df_custo = pd.DataFrame(custo)&#xA;dmd =  {&#xA; 'Argentina'        : {'PRODUCT_A':       899.58 ,   'PRODUCT_B':        0 ,     'PRODUCT_C':       0 },&#xA; 'Paraguay'         : {'PRODUCT_A':      253.067 ,   'PRODUCT_B':        0 ,     'PRODUCT_C':       0 },&#xA; 'Uruguay'          : {'PRODUCT_A':       94.472 ,   'PRODUCT_B':        0 ,     'PRODUCT_C':   1.123 },&#xA; 'Peru'             : {'PRODUCT_A':      1370.06 ,   'PRODUCT_B':   614.97 ,     'PRODUCT_C':       0 },&#xA; 'Caribe'           : {'PRODUCT_A':        50.64 ,   'PRODUCT_B':   73.078 ,     'PRODUCT_C':       0 },&#xA; 'AmericaCentral'   : {'PRODUCT_A':     1936.941 ,   'PRODUCT_B':  108.893 ,     'PRODUCT_C':       0 },&#xA; 'Colombia'         : {'PRODUCT_A':       72.814 ,   'PRODUCT_B':        0 ,     'PRODUCT_C':       0 },&#xA; 'Chile'            : {'PRODUCT_A':     3013.913 ,   'PRODUCT_B':        0 ,     'PRODUCT_C':       0 },&#xA; 'Bolivia'          : {'PRODUCT_A':        1.266 ,   'PRODUCT_B':        0 ,     'PRODUCT_C':       0 },&#xA; 'Equador'          : {'PRODUCT_A':        471.6 ,   'PRODUCT_B':        0 ,     'PRODUCT_C':       0 },&#xA; 'Mexico-Intc'      : {'PRODUCT_A':      394.758 ,   'PRODUCT_B':        0 ,     'PRODUCT_C':       0 },&#xA; 'Europa'           : {'PRODUCT_A':     2774.484 ,   'PRODUCT_B': 1843.355 ,     'PRODUCT_C':       0 },&#xA; 'Brasil'           : {'PRODUCT_A':    14868.788 ,   'PRODUCT_B':        0 ,     'PRODUCT_C': 118.354 },&#xA; 'Mea'              : {'PRODUCT_A':     1020.808 ,   'PRODUCT_B':  1989.25 ,     'PRODUCT_C':       0 },&#xA; 'Others'           : {'PRODUCT_A':           0  ,   'PRODUCT_B':   21.457 ,     'PRODUCT_C':       0 },&#xA;                                                       &#xA;}&#xA;df_demanda = pd.DataFrame(dmd)&#xA;&#xA;frete =  {&#xA; 'Argentina' : {'MC05': 12214.3739456068, 'MC06': 12214.3739456068, 'MC07': 12987.9489324915, 'MC08': 12987.9489324915, 'MC09': 14063.2725317568},&#xA; 'Paraguay' : {'MC05': 8415.8538992,  'MC06': 8415.8538992,  'MC07': 8750.83648755556, 'MC08': 8750.83648755556, 'MC09': 9465.15779},&#xA; 'Uruguay'  : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025},&#xA; 'Peru'     : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025},&#xA; 'Caribe'    : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025},&#xA; 'AmericaCentral'   : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025},&#xA; 'Colombia' : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025},&#xA; 'Chile'    : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025},&#xA; 'Bolivia'  : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025},&#xA; 'Equador' : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025},&#xA; 'Mexico-Intc' : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025},&#xA; 'Europa' : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025},&#xA; 'Brasil' : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025},&#xA; 'Mea'  : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025},&#xA; 'Others' : {'MC05': 2851.8259,    'MC06': 2851.8259,  'MC07': 4067.61025,  'MC08': 4067.61025,  'MC09': 7449.23025}&#xA;    &#xA;}&#xA;df_frete = pd.DataFrame(frete)&#xA;&#xA;&#xA;model = ConcreteModel()&#xA;model.i = df_custo.keys()    ## i=Machines&#xA;model.j = df_demanda.index   ## j=Products&#xA;model.h = df_demanda.keys()  ## h=Customers&#xA;&#xA;container = 25&#xA;&#xA;&#xA;model.x = Var(model.i, model.j,model.h, within=NonNegativeReals)                  ### Quantity &#xA;model.y = Var(model.i, model.j,model.h, bounds=(1,31), within=NonNegativeReals)   ### Days&#xA;&#xA;model.OF = Var(within=Reals)                  ### Total production Cost&#xA;model.P = Var(model.i,within=Reals)           ### Production by Machine&#xA;&#xA;def rule_C1(model, i):&#xA;    return sum(model.x[i,j,h] for j in model.j for h in model.h) == model.P[i]&#xA;model.C1 = Constraint(model.i, rule=rule_C1)&#xA;&#xA;&#xA;model.cons = ConstraintList()&#xA;for j in model.j:&#xA;    for h in model.h:&#xA;        model.cons.add(sum(model.x[i,j,h] for i in model.i) == (df_demanda.loc[j,h] ) )&#xA;&#xA;model.cons2 = ConstraintList()&#xA;for i in model.i:&#xA;    for j in model.j:&#xA;        for h in model.h:&#xA;            model.cons2.add( model.x[i,j,h] &amp;lt;= capacidade[i][j] * model.y[i,j,h])&#xA;&#xA;def rule_OF(model): ##&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;       #Cost by Unit                 #Production        #Days                 #delivery by container &#xA;    return model.OF == sum( ( custo[i][j]/capacidade[i][j] ) * (model.x[i,j,h]  * model.y[i,j,h])  + (model.x[i,j,h] / container) * df_frete.loc[i,h]  for i in model.i for j in model.j for h in model.h) &#xA;model.C3 = Constraint(rule=rule_OF)&#xA;model.obj1 = Objective(expr=model.OF, sense=minimize)&#xA;&#xA;&#xA;solver = SolverFactory('ipopt')&#xA;results = solver.solve(model, tee=True)&#xA;&#xA;results.solver.termination_condition&#xA;&#xA;print(&amp;quot;OF= &amp;quot;, value(model.OF))&#xA;&#xA;&#xA;df = pd.DataFrame(columns=('Machines','Products', 'Clients', 'Production', 'Days',&amp;quot;MachineCost&amp;quot;, &amp;quot;MachineCapacity&amp;quot;) )&#xA;for i in model.i:&#xA;  for j in model.j:&#xA;    for h in model.h:&#xA;      v1 = value(model.x[i,j,h])&#xA;      v2 = value(model.y[i,j,h])&#xA;      v3 = custo[i][j]&#xA;      v4 = capacidade[i][j]&#xA;      #print (i, j, h, v1, v2, v3,v4)&#xA;      df = df.append(pd.DataFrame({&amp;quot;Machines&amp;quot;:[i], &amp;quot;Products&amp;quot;:[j], &amp;quot;Clients&amp;quot;:[h], &amp;quot;Production&amp;quot;:[v1], &amp;quot;Days&amp;quot;:[v2], &amp;quot;MachineCost&amp;quot;: v3, &amp;quot;MachineCapacity&amp;quot;: v4})) &#xA;&#xA;df&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4975" LastEditorUserId="4975" LastEditDate="2021-02-26T16:53:07.100" LastActivityDate="2021-02-26T16:53:07.100" Title="PYOMO - Optimization for the daily production of a products demand minimizing the production cost" Tags="|optimization|pyomo|demand-distribution|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5791" PostTypeId="1" AcceptedAnswerId="5793" CreationDate="2021-02-23T23:54:26.037" Score="3" ViewCount="527" Body="&lt;p&gt;I am new to CPLEX. I am using CPLEX with Xcode in macOS.&lt;/p&gt;&#xA;&lt;p&gt;I have three arrays (known parameters used in optimisation) which I define as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  IloNumArray capacity(env), fixedCost(env);&#xA;  FloatMatrix cost(env);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I then assign values to this arrays as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   fixedCost=[480, 200, 320, 340, 300];&#xA;   cost=[[ 24, 74, 31, 51, 84],&#xA;    [ 57, 54, 86, 61, 68],&#xA;    [ 57, 67, 29, 91, 71],&#xA;    [ 54, 54, 65, 82, 94],&#xA;    [ 98, 81, 16, 61, 27],&#xA;    [ 13, 92, 34, 94, 87],&#xA;    [ 54, 72, 41, 12, 78],&#xA;    [ 54, 64, 65, 89, 89]];&#xA;   capacity=[ 3, 1, 2, 4, 1];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But, I am getting the following error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    Expected variable name or 'this' in lambda capture list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How can I get rid of this?&lt;/p&gt;&#xA;" OwnerUserId="836" LastActivityDate="2021-02-24T09:31:42.367" Title="How to assign values to array in CPLEX with C++?" Tags="|optimization|cplex|modeling-languages|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5792" PostTypeId="1" AcceptedAnswerId="5794" CreationDate="2021-02-24T08:37:15.633" Score="1" ViewCount="698" Body="&lt;p&gt;I use this code in the cplex and don't know why some decision variables don't get value, I attach my code below. I don't know my model is wrong or my code? I haven't error in the code but have some conflicts.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; //sets--------------------------------------------------------------------------------------------------------------------------------------------------------------------&#xA;range D=1..3;   {int} DD=asSet(D);    //Distribution centers.&#xA;int c=0;        {int} cc={0};         //center.&#xA;range I=4..10;  {int} II={4,5,6};     //Local clinics.&#xA;range DI=1..10; //D+I&#xA;range cD=0..3; //c+D&#xA;//range cDI=0..10; //c+D+I&#xA;range J=0..10;  {int} JJ= cc union DD union II;       //Vertices.&#xA;{int} L={0,1,2} ;                      //Levels which central 0, DC 1, local clinic 2.&#xA;range T=0..2;   {int} TT=asSet(T);     //Transportation vehicles which cold truck ( = 0), 4 × 4 truck ( = 1), motorbike ( = 2).&#xA;range R=0..3;   {int} RR= {0,1,2,3};   //Storage devices which cold room ( = 0), regional device ( = 1), district device ( = 2), local clinic device ( = 3).&#xA;range F=0..1;   {int} FF={0,1};        //Replenishment frequency: {quarterly ( = 0), monthly ( = 1)}.&#xA;//Define Arcs---------------------------------------------------------------------------------------------------------------------------------------------------------------&#xA;tuple Arc{&#xA;key int origin;&#xA;key int destination;&#xA;} &#xA;{Arc} A1={&amp;lt;0,1&amp;gt;,&amp;lt;0,2&amp;gt;,&amp;lt;0,3&amp;gt;};          //Arcs between center and Distribution centers. &#xA;{Arc} A2={&amp;lt;1,4&amp;gt;,&amp;lt;1,5&amp;gt;,&amp;lt;1,6&amp;gt;,&amp;lt;2,4&amp;gt;,&amp;lt;2,5&amp;gt;,&amp;lt;2,6&amp;gt;,&amp;lt;3,4&amp;gt;,&amp;lt;3,5&amp;gt;,&amp;lt;3,6&amp;gt;,&amp;lt;1,2&amp;gt;,&amp;lt;2,3&amp;gt;,&amp;lt;3,7&amp;gt;,&amp;lt;2,8&amp;gt;,&amp;lt;1,9&amp;gt;,&amp;lt;2,10&amp;gt;};  //Arcs between Distribution centers and locla clinics.&#xA;{Arc} A3={&amp;lt;1,2&amp;gt;,&amp;lt;2,3&amp;gt;};               //Arcs between Distribution centers.&#xA;{Arc} A={&amp;lt;0,1&amp;gt;,&amp;lt;0,2&amp;gt;,&amp;lt;0,3&amp;gt;,&amp;lt;1,4&amp;gt;,&amp;lt;1,5&amp;gt;,&amp;lt;1,6&amp;gt;,&amp;lt;2,4&amp;gt;,&amp;lt;2,5&amp;gt;,&amp;lt;2,6&amp;gt;,&amp;lt;3,4&amp;gt;,&amp;lt;3,5&amp;gt;,&amp;lt;3,6&amp;gt;,&amp;lt;1,2&amp;gt;,&amp;lt;2,3&amp;gt;,&amp;lt;3,7&amp;gt;,&amp;lt;2,8&amp;gt;,&amp;lt;1,9&amp;gt;,&amp;lt;2,10&amp;gt;}; //total Arcs.&#xA;//EXTEND//-----------------------------------------------------------------------------------------------------------------------------------------------------------------&#xA;///suppose1:motorbike ( = 2) works by electricity///&#xA;{int} chargestation={1,2,3};          //chargestation in route.&#xA;range chargestationcopy=1..6;   {int} chargestationcopyy={1,2,3,4,5,6}; //we have three shargestation but it may each chargestation visited more than one.&#xA;&#xA;//parameters-----------------------------------------------------------------------------------------------------------------------------------------------------&#xA;float C[A][t in T]=rand(10);          //Transportation cost per kilometer of vehicle type t from location i to location j.&#xA;float CS[R]=[8116,1582,600,596];      //Annual storage cost per storage device r.&#xA;float C0=40000;                       //Annual level 0 facility (central store) operating cost.&#xA;float C1[j in D]=4500;                //Annual level 1 facility (DC) operating cost at location j.&#xA;float C2[j in I]=800;                 //Annual level 2 facility (clinic) operating cost at location j.&#xA;float P[T]= [9293, 172,5];            //Transportation capacity per trip of vehicle t.&#xA;float PS[R]=[18000,1843,76,35];       //Storage capacity of device r.&#xA;float G[f in F]=(f==0)?4:12;          //Annual number of replenishments f  ( = 4 if f = 0 and = 12 if f = 1).&#xA;float S=0.25;                         //Buffer stock factor for vaccines stored at a location (typically = 0.25).&#xA;float H[A]= [2,3,2,2,5,6,7,5,8,9,12,13,12,6,5,7,5,6]; //Distance (kilometer) between location i and location j.&#xA;float M=100000000;                    //Big M.&#xA;//EXTEND//--------------------------------------------------------------------------------------------------------------------------------------------------------&#xA;///suppose1:motorbike ( = 2) works by electricity///-------------------------------------------------&#xA;int Beta=1;                           //(1+ beta) shows the number of copy of shargstations.&#xA;int Q =200;                           //motorbike battery capacity.&#xA;float e[i in cD][j in DI]=rand(10);   //charge consumption of motorbike from i to j.&#xA;int Tmax=200;                         //maximum time that motorbike should drive in two nodes.&#xA;float time[i in cD][j in DI]=rand(10);&#xA;///suppose2:define cost of green house gas in objective function/////--------------------------------&#xA;float costco2=20;                     //average cost of co2 on the ration of weight.&#xA;float wco2=10;                        //weight of generate co2 by burning fuel per liter.&#xA;float fuel[T]=[10,5,0];               //volume of burning fuel per weight of vehicle and distance.&#xA;float w[T]=[100,200,0];               //weight of vehicle.&#xA;float wload[T]=[50,40,0];             //weight of load.&#xA;float wcurb[T]=[150,240,0];           //weights of vehicle and its load.&#xA;int RVC[T]=[3,2,1];                   //ratio of volume of vehicle on weight (without load).&#xA;///suppose3:consume fuel for refrigerator///----------&#xA;float Emisionfueltoco2[t in T]=0.4;&#xA;float Emisionco2torefrigerator[t in T]=0.2;&#xA;&#xA;//variables--------------------------------------------------------------------------------------------------------------------------------&#xA;dvar float+ x[A];                     //Annual flow (volume) of vaccines from location i to location j&#xA;dvar float+ Y[J][R][F];               //Number of storage devices of type r at location j with replenishment frequency f &#xA;dvar float+ Z[A][T][F];                   //Number of vehicle trips per replenishment from location i to location j using vehicle type t with replenishment&#xA;dvar boolean W[J];                    //1 if a location j is open, 0 otherwise&#xA;dvar boolean U[A];                    //1 if vaccines flow from location i to location j, 0 otherwise&#xA;dvar boolean V[J];                    //1 if a location j has monthly replenishment frequency, 0 otherwise&#xA;//EXTEND//-----------------------------------------------------------------------------------------------------------------------------------------&#xA;///suppose1:motorbike ( = 2) works by electricity///&#xA;dvar float+ y[J][T];                      //charge level of motorbike in each node.&#xA;dvar float+ q[chargestationcopy][T];   //charge level of motorbike in each chargestation.&#xA;dvar float+ O[chargestationcopy][T];   //charge of motorbike when depart from chargestation.&#xA;dvar float+ delta[chargestationcopy][T];//period of time being in chargestation.&#xA;dvar float+ timeexitchargestationcopy[chargestationcopy][T];//exit time from chargestation.&#xA;dvar float+ timeenterchargestationcopy[chargestationcopy][T];//enter time to chargstation.&#xA;dvar float+ recievetime[J][T];        //recieve time to a nod&#xA;dvar float+ servicetime[J][T];        //service time for costomer or clinic&#xA;//dvar float time[cD][DI];            //time period of motorbike when drive from obe node to other.&#xA;dvar boolean K[cD][DI][F];                //if motorebike visit i an j be one and else zero.&#xA;&#xA;//formulation------------------------------------------------------------------------------------------------------------------------------------------&#xA;dexpr float objective= sum(i in A,t in T,f in F)2* C[i][t]*G[f]*H[i]*Z[i][t][f]+&#xA;sum(j in J,f in F,r in R)CS[r]*Y[j][r][f]+ C0*W[0]+ sum(j in D)C1[j]*W[j]+sum(j in I)C2[j]*W[j]+sum(i in chargestationcopy, t in T:t==2)delta[i][t]+&#xA;sum(i in cD,j in DI,t in T: t==2, f in F)time[i][j]*K[i][j][f]+sum(i in A,t in T:t!=2)H[i]*costco2*wco2*fuel[t]*w[t]*wload[t]+sum(i in A,t in T:t!=2)x[i]*H[i]*wco2*fuel[t]*wcurb[t]/RVC[t]+&#xA;sum(t in T:t!=2)fuel[t]*Emisionfueltoco2[t]*Emisionco2torefrigerator[t] ;&#xA;&#xA;minimize objective;&#xA;subject to{&#xA;cos1:sum(i in A)x[i]-sum(j in A)x[j]==0;&#xA;forall(i,j in A)cos2:sum(t in T,f in F)P[t]*G[f]*Z[i][t][f]&amp;gt;=x[i];&#xA;cos3:sum(t in T,r in R, f in F,j in J)P[t]*G[f]*Y[j][r][f]&amp;gt;=(1+S)*sum(i in A)x[i];&#xA;forall(j in DD)cos4:M*W[j]&amp;gt;=sum(i in A)x[i]+sum(j in A)x[j];&#xA;forall(i in A)cos5:x[i]&amp;lt;=M*U[i];&#xA;cos6:sum(i in A)U[i]&amp;lt;=1;&#xA;forall(j in D)cos7:sum(r in R,f in F)Y[j][r][f]&amp;lt;=M*W[j];&#xA;forall(j in J)cos8:sum(r in R)Y[j][r][1]&amp;lt;=M*V[j];&#xA;forall(j in J)cos9:sum(r in R)Y[j][r][0]&amp;lt;=M*(1-V[j]);&#xA;forall (i in A3,j in J)cos10:x[i]&amp;lt;=M*V[j];&#xA;forall (i in A1,k in D)cos11:V[k]&amp;lt;=2-U[i]-(sum(j in A3)U[j]/abs(3));&#xA;forall (i in cc union II)cos12:W[i]==1;&#xA;forall (i in I)cos13:V[i]==1;&#xA;cos14:Y[0][0][0]==1;&#xA;forall (i in A)cos15:x[i]&amp;gt;=0;&#xA;///////////EXTEND////////////////-----------------------------------------------------------------------------------------------------------------------------------&#xA;///suppose1:motorbike ( = 2) works by electricity///&#xA;forall(i in cD, t in T:t==2, f in F)cb1:sum(j in DI)K[i][j][f]&amp;lt;=1;&#xA;forall(i in cD,j in DI,t in T:t==2,f in F)cb2:e[i][j]*K[i][j][f]-(1-K[i][j][f])*Q &amp;lt;=y[i][t]-y[j][t];&#xA;forall(i in cD,j in DI,t in T:t==2,f in F)cb3:y[i][t]-y[j][t]&amp;lt;=e[i][j]*K[i][j][f]+(1-K[i][j][f])*Q;&#xA;forall(i in cD,j in chargestationcopy,t in T:t==2, f in F)cb4:e[i][j]*K[i][j][f]-(1-K[i][j][f])*Q&amp;lt;= y[i][t]-q[j][t];&#xA;forall(i in cD,j in chargestationcopy,t in T:t==2, f in F)cb5:y[i][t]-q[j][t]&amp;lt;=e[i][j]*K[i][j][f]-(1-K[i][j][f])*Q;&#xA;forall(i in cc,t in T:t==2)cb6:y[i][t]==Q;&#xA;forall(i in chargestationcopy,t in T:t==2)cb7:y[i][t]==O[i][t];&#xA;forall(i in chargestationcopy,t in T:t==2)cb8:q[i][t]&amp;lt;=O[i][t];&#xA;forall(i in chargestationcopy,t in T:t==2)cb9:delta[i][t]==timeexitchargestationcopy[i][t]-timeenterchargestationcopy[i][t];&#xA;forall(i in cD,j in DI,t in T:t==2, f in F)cb10:recievetime[i][t]+(time[i][j]+servicetime[j][t])*K[i][j][f]-Tmax*(1-K[i][j][f])&amp;lt;=recievetime[j][t];&#xA;forall(i in cD:i!=0,j in chargestationcopy,t in T:t==2, f in F)cb11:recievetime[i][t]+delta[i][t]+time[i][j]*K[i][j][f]-Tmax*(1-K[i][j][f])&amp;lt;=recievetime[j][t];&#xA;forall(i in cD,j in DI,t in T:t==2)cb12:recievetime[j][t]+time[i][j]&amp;lt;=Tmax;&#xA;forall(t in T:t==2)cb13:recievetime[0][t]&amp;lt;=Tmax;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/z9fkz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/z9fkz.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/c1MIl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/c1MIl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CVJge.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CVJge.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4306" LastEditorUserId="4306" LastEditDate="2021-02-24T10:14:37.567" LastActivityDate="2021-02-24T11:05:29.220" Title="Why some decision variables don't get values in Cplex?" Tags="|mixed-integer-programming|modeling|cplex|vehicle-routing|opl|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5793" PostTypeId="2" ParentId="5791" CreationDate="2021-02-24T09:31:42.367" Score="5" Body="&lt;p&gt;According to the docs, &lt;code&gt;IloNumArray&lt;/code&gt;s constructor signature is&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;public IloNumArray(const IloEnv env, IloInt n, IloNum f0, IloNum f1, ...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which creates an array of n floating point objects for use in a model. Note&#xA;that the constructor is a C-Style variadic function due to the &lt;code&gt;...&lt;/code&gt; parameter.&#xA;Thus, you can assign your values while calling the constructor, i.e.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;IloNumArray capacity(env, 5, 3, 1, 2, 4, 1);&#xA;IloNumArray fixedCost(env, 5, 480, 200, 320, 340, 300);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For the second one it's not clear what &lt;code&gt;FloatMatrix&lt;/code&gt; should be.&#xA;I assume you use the (C++11) alias&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;using FloatMatrix = IloArray&amp;lt;IloNumArray&amp;gt;; &#xA;// C++98: typedef IloArray&amp;lt;IloNumArray&amp;gt; FloatMatrix; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then you could do it like this&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;FloatMatrix cost(env);&#xA;&#xA;cost.add(IloNumArray(env, 5, 24, 74, 31, 51, 84));&#xA;cost.add(IloNumArray(env, 5, 57, 54, 86, 61, 68));&#xA;cost.add(IloNumArray(env, 5, 54, 54, 65, 82, 94));&#xA;cost.add(IloNumArray(env, 5, 98, 81, 16, 61, 27));&#xA;cost.add(IloNumArray(env, 5, 13, 92, 34, 94, 87));&#xA;cost.add(IloNumArray(env, 5, 54, 72, 41, 12, 78));&#xA;cost.add(IloNumArray(env, 5, 54, 64, 65, 89, 89));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To access the arrays, you simply call &lt;code&gt;capacity[i]&lt;/code&gt; and &lt;code&gt;cost[i][j]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2021-02-24T09:31:42.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5794" PostTypeId="2" ParentId="5792" CreationDate="2021-02-24T11:05:29.220" Score="4" Body="&lt;p&gt;your model is not feasible and that is why you get no solution.&lt;/p&gt;&#xA;&lt;p&gt;if you comment&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;//forall(i in cD,j in DI,t in T:t==2, f in F)cb10:recievetime[i][t]+(time[i][j]+servicetime[j][t])*K[i][j][f]-Tmax*(1-K[i][j][f])&amp;lt;=recievetime[j][t];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then you ll get some conflicts and relaxations like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;72  [0,Infinity]    [-6,Infinity]   delta[1][2]&#xA;72  [0,Infinity]    [-10,Infinity]  delta[2][2]&#xA;72  [0,Infinity]    [-5,Infinity]   delta[3][2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and a relaxed solution in the problem browser&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NjpFZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NjpFZ.png&quot; alt=&quot;relaxed solution in the problem browser&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-02-24T11:05:29.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5795" PostTypeId="1" AcceptedAnswerId="5796" CreationDate="2021-02-24T11:24:45.410" Score="2" ViewCount="2137" Body="&lt;p&gt;I have a pyomo model that I can solve using the GLPK solver by just using the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solver = pyo.SolverFactory('glpk')&#xA;solver.options['mipgap'] = 0.02&#xA;solution = solver.solve(model, tee=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now I have installed the academic version of Gurobi on my computer. However I can't use Gurobi when having the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solver = pyo.SolverFactory('gurobi', solver_io=&amp;quot;python&amp;quot;)&#xA;solver.options['mipgap'] = 0.02&#xA;solution = solver.solve(model, tee=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I get the error message:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;ApplicationError: No Python bindings available for &amp;lt;class 'pyomo.solvers.plugins.solvers.gurobi_direct.GurobiDirect'&amp;gt; solver plugin&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now I found this discussion on Stackoverflow &lt;a href=&quot;https://stackoverflow.com/questions/54268665/pyomo-cant-use-gurobi-solver&quot;&gt;Pyomo can't use Gurobi solver&lt;/a&gt;&#xA;I did what the accepted answer advices. I used the windows cmd and navigated to my installation path of Gurobi. I tried two different folders&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;C:\Gurobi\win64\&lt;/li&gt;&#xA;&lt;li&gt;C:\Gurobi\&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;and I use the suggested command&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;python setup.py install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, I get an error message in the cmd of Windows telling that the command 'python' can't be found or is wrong. Do you know what I have to do in order to use Gurobi with Pyomo in Python?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="491" LastEditDate="2021-05-07T14:26:02.740" LastActivityDate="2021-05-07T14:26:02.740" Title="Pyomo can't find Gurobi solver" Tags="|python|gurobi|pyomo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5796" PostTypeId="2" ParentId="5795" CreationDate="2021-02-24T11:47:50.747" Score="3" Body="&lt;p&gt;The mentioned link is about using gurobipy (gurobi's interface for python) to model your problem and solve it using gurobi. If you want to model the problem using Pyomo and use gurobi as a solver, you need to add the gurobi solver to the system's path. For that do the followings:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;In Windows search for &lt;strong&gt;Edit the system environment variables&lt;/strong&gt; (I am not familiar with Mac OS).&lt;/li&gt;&#xA;&lt;li&gt;Open &lt;em&gt;Environment Variables&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;In the &lt;em&gt;System variables&lt;/em&gt; window click on &lt;em&gt;Path&lt;/em&gt; and add the folder that includes your gurobi.exe&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;then use the following in your code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solver = pyo.SolverFactory('gurobi')&#xA;solver.options['MIPGap'] = 0.02&#xA;solution = solver.solve(model, tee=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-02-24T11:47:50.747" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5797" PostTypeId="1" CreationDate="2021-02-24T15:23:42.973" Score="3" ViewCount="265" Body="&lt;p&gt;I'm having some troubles to continue solving my system, I'm used to solve such systems but with &amp;quot;one&amp;quot; binding constraint, if someone could give me some helpful hints so I can solve it I will be grateful.&lt;/p&gt;&#xA;&lt;p&gt;Here is the problem:&lt;/p&gt;&#xA;&lt;p&gt;Solve the following LP using the Dantzig-Wolfe method:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Tw0X7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tw0X7.png&quot; alt=&quot;LP&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is what I have done so far:&lt;/p&gt;&#xA;&lt;p&gt;We may notice that there are 6 constraints, and the 2 first constraints will be binding constraints.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The matrix form of the problem (P) is:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8PECd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8PECd.png&quot; alt=&quot;Matrix form of (P)&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Hence:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/enKac.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/enKac.png&quot; alt=&quot;Matrix A&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2FXlQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2FXlQ.png&quot; alt=&quot;Matrix B&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7ykVf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7ykVf.png&quot; alt=&quot;Matrix C&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is a two-block structure.&lt;/p&gt;&#xA;&lt;p&gt;i = 1 Constraints block (3) and (4)&lt;/p&gt;&#xA;&lt;p&gt;i = 2 Constraints block (5) and (6)&lt;/p&gt;&#xA;&lt;p&gt;Constraints 1 and 2 are binding constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mTYGu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mTYGu.png&quot; alt=&quot;D1&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TyFVc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TyFVc.png&quot; alt=&quot;D2&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/w0Fkj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/w0Fkj.png&quot; alt=&quot;b1&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0q9xN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0q9xN.png&quot; alt=&quot;b2&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yqRBE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yqRBE.png&quot; alt=&quot;c1&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3Gd02.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3Gd02.png&quot; alt=&quot;c2&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;My question is: What can I do so I could solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="3806" LastEditorUserId="500" LastEditDate="2021-04-07T14:20:14.747" LastActivityDate="2021-04-07T14:20:14.747" Title="Two binding constraints - Linear Programming" Tags="|optimization|linear-programming|constraint|dantzig-wolfe-decomposition|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5800" PostTypeId="1" AcceptedAnswerId="5801" CreationDate="2021-02-25T11:06:39.430" Score="11" ViewCount="1966" Body="&lt;p&gt;Is it possible for an NLP solver to claim that a knowingly feasible problem is infeasible?&lt;/p&gt;&#xA;&lt;p&gt;Shouldn't the solver be able to provide a solution (of course not necessarily the global optimum but a feasible one)?&lt;/p&gt;&#xA;&lt;p&gt;Is a wrongly claimed infeasibility a matter of tolerances or are there algorithmic issues?&lt;/p&gt;&#xA;&lt;p&gt;Edit: Here is the EXIT state of IPOPT&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;EXIT: Converged to a point of local infeasibility. Problem may be infeasible.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;That indicates that the problem is an algorithmic issue.&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="3391" LastEditDate="2021-02-28T16:58:39.783" LastActivityDate="2021-03-02T08:04:14.893" Title="Trustful Nonlinear Programming" Tags="|nonlinear-programming|nonconvex-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5801" PostTypeId="2" ParentId="5800" CreationDate="2021-02-25T11:55:33.743" Score="19" Body="&lt;p&gt;Local nonlinear optimization solvers, such as IPOPT, are not guaranteed to find a feasible point for problems that are feasible. That is certainly the case for problems with non-convex constraints, and I believe may even occur sometimes for problems having convex nonlinear constraints.&lt;/p&gt;&#xA;&lt;p&gt;The starting (initial) point is often important in determining whether or not a feasible point is found.&lt;/p&gt;&#xA;&lt;p&gt;Things are even worse than you might think. I have experienced a number of occasions on which I provided a starting point in the interior of the feasible region, and the solver diverged to an infeasible point.&lt;/p&gt;&#xA;&lt;p&gt;If you want an (almost) guaranteed determination of feasibility for a non-convex problem, use an (almost) rigorous (branch and bound) global optimization solver, such as BARON, COUENNE, ANTIGONE, BMIBNB (under YALMIP), Octeract or SCIP. Even those solvers can occasionally declare feasible problems as infeasible, generally when the numerics of the problem are bad, such as very bad input data scaling.&lt;/p&gt;&#xA;&lt;p&gt;The only guaranteed way to make a reliable determination of feasibility is to use a &amp;quot;verified&amp;quot; global solver, such as based on interval (or affine) arithmetic with outward rounding, based on, perhaps, branch and bound interval Newton's method. Unfortunately, there are no hardware implementations I know of to implement interval arithmetic with outward rounding; so that needs to be done in software. Therefore, such solvers tend to take orders of magnitude longer to run than the much more popular almost rigorous (branch and bound) global optimization solvers, which already can have very long run times. Note that for purposes of determining feasibility, it is sufficient to use a nonlinear equation and inequality solver rather than an optimizer.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="126" LastEditDate="2021-03-02T08:04:14.893" LastActivityDate="2021-03-02T08:04:14.893" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5802" PostTypeId="1" AcceptedAnswerId="5825" CreationDate="2021-02-25T14:54:26.997" Score="4" ViewCount="187" Body="&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; this question has been previously posted on &lt;a href=&quot;https://math.stackexchange.com/questions/4036496/continuous-water-filling-x-posting-disclaimer&quot;&gt;Math StackExchange&lt;/a&gt;. I reposted it here since I did not receive any satisfactory answer there and a user suggested to re-post it here.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x\in\mathbb{R}^n$&lt;/span&gt; be an optimization variable and &lt;span class=&quot;math-container&quot;&gt;$\alpha\in\mathbb{R}^n$&lt;/span&gt; be a given &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-dimensional vector. The standard water-filling problem is formulated as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{array}{ll}&#xA;\underset{x}{\operatorname{minimize}} &amp;amp; -\displaystyle\sum_{i=1}^{n} \log \left(\alpha_{i}+x_{i}\right) \\&#xA;\text { subject to } &amp;amp; x \succeq 0, \quad \mathbf{1}^{T} x=1,&#xA;\end{array}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and it has a well-known solution (see &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Boyd &amp;amp; Vandenberghe&lt;/a&gt; page 245).&lt;/p&gt;&#xA;&lt;p&gt;I was thinking about the case in which we have continuous communication channel slots. Intuitively this may be thought of as the case when the sizes of the communication channels approach zero. How is it possible to generalize this optimization problem to this case?&lt;/p&gt;&#xA;&lt;p&gt;I believe that &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, which from now on we will denote by &lt;span class=&quot;math-container&quot;&gt;$\alpha(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; respectively, would in this case be continuous real function and the problem would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{array}{ll}&#xA;\underset{f \in \mathcal{F}}{\operatorname{minimize}} &amp;amp; -\displaystyle\int_{x} \log \left(\alpha(x)+f(x)\right)dx \\&#xA;\text { subject to } &amp;amp; f(x) \geq 0\; \forall x, \quad \int_x f(x)dx=1&#xA;\end{array}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{F}$&lt;/span&gt; is a given class of functions (e.g. Hölder continuous, Lipschitz, etc). We can also assume that the domain of the functions &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha(x)$&lt;/span&gt; is compact, i.e. &lt;span class=&quot;math-container&quot;&gt;$x\in\mathcal{X}\subseteq \mathbb{R}$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$\mathcal{X}$&lt;/span&gt; a compact subspace of &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Am I following the right path?&lt;/p&gt;&#xA;&lt;p&gt;Do you have any idea on how to solve these types of problems? It looks it is related to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Calculus_of_variations&quot; rel=&quot;nofollow noreferrer&quot;&gt;calculus of variations&lt;/a&gt;, but I have never seen these types of problems and I have no idea how to solve them.&lt;/p&gt;&#xA;" OwnerUserId="5005" LastEditorUserId="491" LastEditDate="2021-02-25T19:56:14.553" LastActivityDate="2021-02-28T23:18:16.277" Title="Continuous water-filling optimization problem" Tags="|optimization|nonlinear-programming|continuous-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5803" PostTypeId="2" ParentId="5800" CreationDate="2021-02-25T16:10:28.747" Score="13" Body="&lt;p&gt;Oh boy. Adding to Mark's great answer, I'll add some fun facts on what can go wrong with IPOPT and feasibility, and provide us with endless nights of entertainment:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The linear system solver gets stuck. A timeless classic, especially for MUMPS. It will suddenly slow down to a crawl for no apparent reason. It can also fail outright, which can cascade to reporting infeasibility.&lt;/li&gt;&#xA;&lt;li&gt;Iteration limit/timeout can be reached before a feasible point can be found. The exit flag is often, but not necessarily, indicative of this having happened.&lt;/li&gt;&#xA;&lt;li&gt;The cryptic &amp;quot;restoration failed&amp;quot; message. Another timeless classic, this can be caused by a number of things, but utterly it means that IPOPT could not bring the solution inside the feasible region within tolerances. The &amp;quot;within tolerances&amp;quot; part we have to guess, as IPOPT has the same umbrella message for any number of different issues that lead to failed restoration.&lt;/li&gt;&#xA;&lt;li&gt;The Newton iteration can diverge.&lt;/li&gt;&#xA;&lt;li&gt;The Newton iteration can diverge because we didn't provide exact/good/correct derivatives.&lt;/li&gt;&#xA;&lt;li&gt;The Newton iteration can diverge because the barrier parameters need tweaking.&lt;/li&gt;&#xA;&lt;li&gt;The Newton iteration can diverge/be so slow that iteration limit is reached before feasibility because the line search failed/needs tweaking.&lt;/li&gt;&#xA;&lt;li&gt;The starting point is bad.&lt;/li&gt;&#xA;&lt;li&gt;The starting point is technically ok, but a tiny numerical flux in the first few iterations derails the iterative process.&lt;/li&gt;&#xA;&lt;li&gt;Another great one: the starting point is feasible but far from the optimal solution. IPOPT &amp;quot;tends&amp;quot; to work best with points close to the local solution, even if they are infeasible. &amp;quot;Tends&amp;quot; is the normative word here, as this is often, but not always, true.&lt;/li&gt;&#xA;&lt;li&gt;The problem formulation is not numerically stable.&lt;/li&gt;&#xA;&lt;li&gt;There is a bug in the automatic differentiation the user provided to IPOPT.&lt;/li&gt;&#xA;&lt;li&gt;The user did not define variable bounds properly.&lt;/li&gt;&#xA;&lt;li&gt;There is a bug in the interface or .nl file that is passed to IPOPT.&lt;/li&gt;&#xA;&lt;li&gt;IPOPT's default tolerances are just marginally too strict for this problem.&lt;/li&gt;&#xA;&lt;li&gt;IPOPT was compiled for Windows instead of Linux. Although rare, results can actually be different (including feasibility/infeasibility) depending on OS/architecture.&lt;/li&gt;&#xA;&lt;li&gt;Just for fun, we have also seen a single case where the reason was a compiler bug. Compiling with a different version made the problem go away.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;IPOPT can be quite cryptic about why things go wrong, so if you know that your model is feasible the reason can be any one of these things. However, &lt;strong&gt;IPOPT is damn good&lt;/strong&gt; and most people will probably never encounter most of these. &lt;strong&gt;The most common reasons by far (as in, 99.99% of cases)&lt;/strong&gt; are that (i) the feasible solution you have has different tolerances than IPOPT's defaults, and (ii) the starting point is bad.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-02-25T16:29:45.727" LastActivityDate="2021-02-25T16:29:45.727" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5805" PostTypeId="1" CreationDate="2021-02-26T08:52:47.040" Score="1" ViewCount="92" Body="&lt;p&gt;I have the following simplified problem, which I think it is a maximization problem with multiple options, constraints, and a time factor:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Factory A, initial number known (e.g. 8), cost 11000, unitary daily&lt;br /&gt;&#xA;output 5&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Factory B, initial number known (e.g. 3), cost 7000&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Catalyzer, cost 3000. It reduces cost of building A or B by 10% for&lt;br /&gt;&#xA;each unit of catalyzer. The catalyzer bonus is permanent and additive&#xA;with more catalyzer.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Factory A can produce Factory A, Factory B, or catalyzer.&lt;/p&gt;&#xA;&lt;p&gt;Besides, the following conversions are possible (conversion cost in brackets):&#xA;Factory A -&amp;gt; Factory B (4000)&#xA;Factory B -&amp;gt; Factory A (9000)&lt;/p&gt;&#xA;&lt;p&gt;Only up to 15 A factories can work simultaneously in producing A, B, or catalyzer.&lt;/p&gt;&#xA;&lt;p&gt;Example: 8 factories A, with an output of 5, can produce another factory A, in 11000 /  (8 * 5) = 275 days.&lt;/p&gt;&#xA;&lt;p&gt;The objective is to maximize the number of B factories at different time horizons: 2, 3, 4, 5, and 6 years from the present.&lt;/p&gt;&#xA;&lt;p&gt;I would appreciate any comments on how to approach this problem, what are the techniques I should apply, and the best software that I can use to solve this. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="5027" LastEditorUserId="5027" LastEditDate="2021-02-26T12:49:47.337" LastActivityDate="2021-02-26T12:49:47.337" Title="Production maximization problem" Tags="|production-planning|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5806" PostTypeId="1" CreationDate="2021-02-26T11:44:26.207" Score="3" ViewCount="533" Body="&lt;p&gt;I have a beginners level knowledge in Java , I am trying to learn optaplanner , can anyone help me finding the right resources to learn optaplanner and spring/springboot integration ,since my background is operations research I am new to spring environment.&lt;/p&gt;&#xA;" OwnerUserId="2958" LastActivityDate="2021-10-06T11:53:58.083" Title="How do I learn and use optaplanner ? any detailed tutorials/videos available online apart from the ones in optaplanner website?" Tags="|java|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5807" PostTypeId="1" AcceptedAnswerId="5828" CreationDate="2021-02-26T13:58:50.710" Score="0" ViewCount="164" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; be a fixed matrix. Define &lt;span class=&quot;math-container&quot;&gt;$$\operatorname{pos}W \triangleq \{t \mid Wy =t , y≥ 0\}.$$&lt;/span&gt; It is called the positive hull of &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt;. It represents&#xA;the set of right-hand sides that can be obtained by a non-negative combination&#xA;of the columns of &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt;. The positive hull is easily seen to be a convex cone.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; be a point not in the set &lt;span class=&quot;math-container&quot;&gt;$\operatorname{pos}W$&lt;/span&gt;. Then, there exists a hyperplane&#xA;&lt;span class=&quot;math-container&quot;&gt;$H \triangleq \{x\mid\sigma^Tx =0\}$&lt;/span&gt; that separates &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\operatorname{pos}W$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How can we prove that the number of possible separating hyperplanes (separating &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\operatorname{pos}W$&lt;/span&gt;) is finite based on the fact that &lt;span class=&quot;math-container&quot;&gt;$\operatorname{pos}W$&lt;/span&gt; is finitely generated?&lt;/p&gt;&#xA;" OwnerUserId="4735" LastEditorUserId="123" LastEditDate="2021-03-02T09:34:39.367" LastActivityDate="2021-03-02T09:34:39.367" Title="Separating hyperplanes for a convex cone" Tags="|convex-optimization|cone|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5808" PostTypeId="2" ParentId="5807" CreationDate="2021-02-26T14:40:14.180" Score="4" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;How can we prove that the number of possible separating hyperplanes (separating &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\operatorname{pos}W$&lt;/span&gt;) is finite based on the fact that &lt;span class=&quot;math-container&quot;&gt;$\operatorname{pos}W$&lt;/span&gt; is finitely generated?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In general, it is not. There may be infinitely many separating hyperplanes.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\sigma_{1}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\sigma_{2}$&lt;/span&gt; define two distinct separating hyperplanes.&#xA;Then it's straightforward to see that, for &lt;span class=&quot;math-container&quot;&gt;$0 \leq \lambda \leq 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\lambda \sigma_{1} + (1 - \lambda) \sigma_{2}$&lt;/span&gt; also defines a separating hyperplane.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="123" LastEditDate="2021-03-02T09:33:05.820" LastActivityDate="2021-03-02T09:33:05.820" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5809" PostTypeId="1" CreationDate="2021-02-26T16:20:31.383" Score="4" ViewCount="140" Body="&lt;p&gt;I'm trying to linearize this optimization problem (&lt;span class=&quot;math-container&quot;&gt;$S_j$&lt;/span&gt; is a subset of variables): &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_{x_i \in X} x_i\\\text{s.t.}&amp;amp;\quad\max_{i \in S_j}x_i\geq 1\quad\forall S_j\\&amp;amp;\quad0 \le x_i \le 1\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, I have no idea to linearize my maximum constraint. The following naïve constraint is not good enough: &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in S} x_i \geq 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Do you have any better ideas than mine?&lt;/p&gt;&#xA;" OwnerUserId="5028" LastEditorUserId="500" LastEditDate="2021-02-26T17:07:43.797" LastActivityDate="2021-02-26T17:07:43.797" Title="Linearize $\max x_i\ge1$" Tags="|constraint|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5810" PostTypeId="2" ParentId="5809" CreationDate="2021-02-26T16:31:17.097" Score="10" Body="&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, you want to enforce &lt;span class=&quot;math-container&quot;&gt;$x_i \ge 1$&lt;/span&gt; for at least one &lt;span class=&quot;math-container&quot;&gt;$i\in S_j$&lt;/span&gt;.  Introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; to indicate whether &lt;span class=&quot;math-container&quot;&gt;$x_i=1$&lt;/span&gt;, and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i \in S_j} y_i &amp;amp;\ge 1 &amp;amp;&amp;amp;\text{for all $j$} \\&#xA;y_i &amp;amp;\le x_i &amp;amp;&amp;amp;\text{for all $i$} \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-02-26T16:31:17.097" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5813" PostTypeId="1" CreationDate="2021-02-27T16:41:27.240" Score="1" ViewCount="48" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\DeclareMathOperator\Set{Set}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let&#xA;&lt;span class=&quot;math-container&quot;&gt;$Set=\{x\in\mathbb Z^{n}:\exists y\in\mathbb Z^m\text{ satisfying } A[x,y]'\leq b\}$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$r=km$&lt;/span&gt; rows and &lt;span class=&quot;math-container&quot;&gt;$k=O(1)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am trying to write&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Set=\{x\in\mathbb Z^n:C[x]'\leq d\}\quad\text{where $C$ has $r'$ rows.}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Is the number of rows &lt;span class=&quot;math-container&quot;&gt;$r'\leq r^{m}$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In my situation in addition to &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; having &lt;span class=&quot;math-container&quot;&gt;$r=O(m)$&lt;/span&gt; rows and every row has &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; entries. We further divide &lt;span class=&quot;math-container&quot;&gt;$n+m$&lt;/span&gt; columns to first &lt;span class=&quot;math-container&quot;&gt;$m_0=n$&lt;/span&gt; columns, next &lt;span class=&quot;math-container&quot;&gt;$m_1$&lt;/span&gt; columns until final &lt;span class=&quot;math-container&quot;&gt;$m_d$&lt;/span&gt; columns (&lt;span class=&quot;math-container&quot;&gt;$m=\sum_{i=1}^d m_i$&lt;/span&gt;) and so &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is block matrix of &lt;span class=&quot;math-container&quot;&gt;$d(d+1)$&lt;/span&gt; blocks (rows are &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; times number of columns). A block is non-zero iff it is &lt;span class=&quot;math-container&quot;&gt;$(i,i)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(i,i+1)$&lt;/span&gt; block (diagonal and one above).&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$A=\begin{bmatrix}&#xA;A_{0,0}&amp;amp;A_{0,1}&amp;amp;0&amp;amp;\dots&amp;amp;0&amp;amp;0\\&#xA;0&amp;amp;A_{1,1}&amp;amp;A_{1,2}&amp;amp;\dots&amp;amp;0&amp;amp;0\\&#xA;\vdots\\&#xA;0&amp;amp;0&amp;amp;0&amp;amp;\dots&amp;amp;A_{d-1,d-1}&amp;amp;A_{d-1,d}&#xA;\end{bmatrix}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A_{j-1,j}=\mathbb I_{m_j,m_j}\otimes\mathbb 1_{k}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\mathbb I_{m_j,m_j}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$m_j\times m_j$&lt;/span&gt; identity and &lt;span class=&quot;math-container&quot;&gt;$\mathbb 1_k$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$k\times 1$&lt;/span&gt; vectors of every entry being &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_{j,j}$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$km_{j+1}$&lt;/span&gt; rows and &lt;span class=&quot;math-container&quot;&gt;$m_j$&lt;/span&gt; columns. In addition at every block matrix &lt;span class=&quot;math-container&quot;&gt;$A_{j,j+1}$&lt;/span&gt; every column is non-zero and every row has &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; non-zero entry. Every row of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; non-zero entries.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In the situation involved is it possible that &lt;span class=&quot;math-container&quot;&gt;$r'=\operatorname{poly}(2^d{m}r)=\operatorname{poly}(m2^d)$&lt;/span&gt; holds?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5033" LastEditorUserId="5033" LastEditDate="2021-02-28T00:25:23.907" LastActivityDate="2021-02-28T00:25:23.907" Title="Unifying constraint matrices in sparse situations" Tags="|linear-programming|integer-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5814" PostTypeId="1" CreationDate="2021-02-27T23:29:05.143" Score="7" ViewCount="1553" Body="&lt;p&gt;I have a fixed number of bins which are themselves weightless. Each bin can hold only a fixed amount of weight. Not all bins have the same capacity.&lt;/p&gt;&#xA;&lt;p&gt;I also have a fixed number of objects each of which has a weight. Not all objects have the same weight.&lt;/p&gt;&#xA;&lt;p&gt;I would like to place objects in the bins in a way which respects their capacity while minimizing the weight of the heaviest bin.&lt;/p&gt;&#xA;&lt;p&gt;What is the name of this problem?&lt;/p&gt;&#xA;&lt;p&gt;(If the capacities were infinite, this would reduce to multi-way number partitioning.&lt;/p&gt;&#xA;&lt;p&gt;With one bin and a low number of unique weights this looks like a cutting stock problem.)&lt;/p&gt;&#xA;" OwnerUserId="886" LastEditorUserId="2707" LastEditDate="2021-03-01T14:21:53.640" LastActivityDate="2024-04-04T05:14:05.617" Title="What's the name of a finite-capacity bin packing problem trying to minimize the weight of the heaviest bin?" Tags="|integer-programming|combinatorial-optimization|terminology|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5815" PostTypeId="2" ParentId="5814" CreationDate="2021-02-28T02:54:11.707" Score="10" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$w_o$&lt;/span&gt; denote the weight of object &lt;span class=&quot;math-container&quot;&gt;$o$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$c_b$&lt;/span&gt; denote the capacity of bin &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can interpret this as a &lt;em&gt;job shop scheduling problem&lt;/em&gt;.  The correspondence is that each object is a job, with duration &lt;span class=&quot;math-container&quot;&gt;$w_o$&lt;/span&gt;, each bin is a machine that is available for only &lt;span class=&quot;math-container&quot;&gt;$c_b$&lt;/span&gt; time units, and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is the makespan.&lt;/p&gt;&#xA;&lt;p&gt;It is also a special case of the &lt;em&gt;bottleneck generalized assignment problem&lt;/em&gt; where the costs depend only on the tasks (objects) and not the agents (bins).&lt;/p&gt;&#xA;&lt;p&gt;You can solve the problem via mixed integer linear programming as follows.  Let binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{o,b}$&lt;/span&gt; indicate whether object &lt;span class=&quot;math-container&quot;&gt;$o$&lt;/span&gt; is assigned to bin &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_b x_{o,b} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $o$} \tag1\\&#xA;\sum_o w_o x_{o,b} &amp;amp;\le c_b &amp;amp;&amp;amp;\text{for all $b$} \tag2\\&#xA;\sum_o w_o x_{o,b} &amp;amp;\le z  &amp;amp;&amp;amp;\text{for all $b$} \tag3\\&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; assigns each object to exactly one bin.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces the bin capacity.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; enforces the minimax objective.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Sparse formulation: introduce bin variable &lt;span class=&quot;math-container&quot;&gt;$y_b$&lt;/span&gt; to represent the common LHS of &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, and minimize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_b x_{o,b} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $o$} \\&#xA;\sum_o w_o x_{o,b} &amp;amp;= y_b &amp;amp;&amp;amp;\text{for all $b$} \\&#xA;y_b &amp;amp;\le c_b &amp;amp;&amp;amp;\text{for all $b$} \\&#xA;y_b &amp;amp;\le z  &amp;amp;&amp;amp;\text{for all $b$} \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If many items have the same weight, you can exploit symmetry and reduce the problem size by letting &lt;span class=&quot;math-container&quot;&gt;$n_t$&lt;/span&gt; be the number of objects of type &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; (with weight &lt;span class=&quot;math-container&quot;&gt;$w_t$&lt;/span&gt;) and treating &lt;span class=&quot;math-container&quot;&gt;$x_{t,b}$&lt;/span&gt; as an integer variable that represents the number of objects of type &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; that are assigned to bin &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_b x_{t,b} &amp;amp;= n_t &amp;amp;&amp;amp;\text{for all $t$} \\&#xA;\sum_t w_t x_{t,b} &amp;amp;= y_b &amp;amp;&amp;amp;\text{for all $b$} \\&#xA;y_b &amp;amp;\le c_b &amp;amp;&amp;amp;\text{for all $b$} \\&#xA;y_b &amp;amp;\le z  &amp;amp;&amp;amp;\text{for all $b$} \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-02-28T17:24:15.750" LastActivityDate="2021-02-28T17:24:15.750" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="5816" PostTypeId="2" ParentId="5814" CreationDate="2021-02-28T08:36:41.847" Score="3" Body="&lt;p&gt;within CPLEX CPOptimizer you could rely on the &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_20.1.0/ilog.odms.ide.help/OPL_Studio/opllang_quickref/topics/tlr_oplf_pack.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;pack&lt;/a&gt; constraint.&lt;/p&gt;&#xA;&lt;p&gt;A slight change of the model in the documentation:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using CP;&#xA;int m = 2;&#xA;int n = 3;&#xA;&#xA;dvar int l[j in 1..m] in 0..10000;&#xA;dvar int p[i in 1..n] in 1..m;&#xA;dvar int nb;&#xA;&#xA;int w[1..n] = [i : 1 | i in 1..n];  &#xA;&#xA;// minimizing the weight of the heaviest bin.&#xA;minimize max(i in 1..m) l[i];&#xA;subject to {&#xA;   &#xA;  pack(l, p, w, nb); &#xA;  &#xA;}&#xA;&#xA;assert nb==m-count(l,0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;l = [1 2];&#xA;p = [1 2 2];&#xA;nb = 2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-02-28T08:36:41.847" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5818" PostTypeId="2" ParentId="5802" CreationDate="2021-02-28T13:50:56.743" Score="3" Body="&lt;p&gt;I can't tell if your path is right (because it depends on that you want to do), but it is sensible.&lt;/p&gt;&#xA;&lt;p&gt;Your problem structure is quite similar to one occurring in the field of optimal control. I'm not aware of any closed form solution of your approach, so you will have to pick a numerical approach to get started.&lt;/p&gt;&#xA;&lt;p&gt;As you are probably aware, you can't express arbitrary functions over the real numbers in a computer with finite memory, so you will have to approximate your function using finite amount of information. I see two approaches being applicable here: collocation and function vector space composition. I will detail the second approach as results in simpler constraints.&lt;/p&gt;&#xA;&lt;p&gt;We choose some basis of (preferably orthogonal) functions &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; of length &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; with sufficient properties and choose a set of real weights &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$f(x) = \sum_{i=1}^m h_iG_i(x)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall x: f(x) \geq 0$&lt;/span&gt; can be expressed as&#xA;&lt;span class=&quot;math-container&quot;&gt;$\forall i\in \{1, ..., m\}: h_i \geq 0 $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\forall i\in \{1, ..., m\}, \forall x:G_i(x) \geq 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\quad \int_x f(x)dx=1$&lt;/span&gt; can be expressed as a linear constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^m h_i\int_x G_i(x)dx = 1$&lt;/span&gt; where the integral can be evaluated ahead of time.&lt;/p&gt;&#xA;&lt;p&gt;Now we are left with this constrained optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{array}{ll}&#xA;\underset{h}{\operatorname{minimize}} &amp;amp; -\displaystyle\int_{x} \log \left(\alpha(x)+\sum_{i=1}^m h_iG_i(x)\right)dx \\&#xA;\text { subject to } &amp;amp; \forall i\in \{1, ..., m\}: h_i \geq 0; \\ &amp;amp; \forall i\in \{1, ..., m\}, \forall x:G_i(x) \geq 0; \\ &amp;amp; \sum_{i=1}^m h_i\int_x G_i(x)dx = 1&#xA;\end{array}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This type of problem for a given basis can be solved using optimal control methods. For smooth problems i in general would recommend giving the optimizer of your choosing access to the derivatives of your objective in regards to &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt;. One way to accomplish that is using sensitives of the ODE solutions using this observation that &lt;span class=&quot;math-container&quot;&gt;$$\frac{dS_j}{dt}=\frac{d}{dt}\frac{\partial u}{\partial p_{j}}=\frac{\partial f}{\partial y}\frac{\partial y}{\partial p_{j}}+\frac{\partial f}{\partial p_{j}}=J\cdot S_{j}+F_{j}$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$S_j(t)$&lt;/span&gt; is the &lt;a href=&quot;https://diffeq.sciml.ai/v6.17/analysis/sensitivity/&quot; rel=&quot;nofollow noreferrer&quot;&gt;local sensitivity&lt;/a&gt; at point &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. &lt;a href=&quot;https://computing.llnl.gov/casc/nsde/pubs/toms_cvodes_with_covers.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;For more details also see this software manual.&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;By calculating the sensitivities you turned you Quadrature problem into an ODE problem but since the sensitivities are the gradients of your objective you can use a wider variety of constrained optimization algorithms.&lt;/p&gt;&#xA;&lt;p&gt;Sadly implementing a practical and robust solution to this requires some engineering but i'm positive that within 5 years a plug-and-play solution will exist for this kind of problem.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="123" LastEditDate="2021-02-28T15:28:40.593" LastActivityDate="2021-02-28T15:28:40.593" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5819" PostTypeId="1" AcceptedAnswerId="5820" CreationDate="2021-02-28T15:44:07.117" Score="3" ViewCount="480" Body="&lt;p&gt;I am working on a formulation for a problem that seems similar to the bin packing problem. My problem variables include items that are to be placed in bins, special events that are conditionally required, and the bins themselves. The constraints include&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Capacity constraints for the bins&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Certain items cannot be in the same bin as other items&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Certain items must be have a special event between them. For example, to get from item i to item j, a special event must occur. Based on certain properties of the item.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A sequence dependent constraint such that items must follow a particular order in the bins. For         example, item i must come before items j,k (if they are in the same bin together) and therefore cannot be placed in the bin after them. This is determined by a property of the item.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The objective for this problem is to identify the least number of bins needed to store all of the items, with an upper bound on the number of special events allowed on a bin.&lt;/p&gt;&#xA;&lt;p&gt;The most obvious formulation I can think of is to have binary variables x_ijk and y_ijk. Where index i is the item (or special event taking place), j is the bin, and k is the position on the bin. Using a triple index like this makes formulating the problem quite simple, but I believe for even a modest size (100 items), the problem size is massive. I expect encoding the variables this way will make the problem size large because I am after a feasible solution and therefore expect the number of items = number of bins = number of sequence position. This guarantees the edge cases of all items being placed on a single bin, and all items being associated to their own individual bins.&lt;/p&gt;&#xA;&lt;p&gt;Is there another formulation that is more efficient that can be used to model this problem?&lt;/p&gt;&#xA;" OwnerUserId="5035" LastEditorUserId="5035" LastEditDate="2021-02-28T17:30:45.557" LastActivityDate="2024-04-04T05:12:34.373" Title="A relaxed version of job shop scheduling" Tags="|mixed-integer-programming|modeling|combinatorial-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5820" PostTypeId="2" ParentId="5819" CreationDate="2021-02-28T16:05:23.303" Score="2" Body="&lt;p&gt;I recommend using binary item-to-bin assignment variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,b}$&lt;/span&gt; and continuous nonnegative start time variables &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt;. You can think of each item as having duration &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; so that precedence constraints look like &lt;span class=&quot;math-container&quot;&gt;$s_i+1\le s_j$&lt;/span&gt; if item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; must precede item &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and items &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are assigned to the same bin.  You can enforce this as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{i,b} + x_{j,b} - 1 &amp;amp;\le y_{i,j} \tag1 \\&#xA;s_i + 1 - s_j &amp;amp;\le M_{i,j}(1-y_{i,j}) \tag2 \\&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$x_{i,b} \land x_{j,b} \implies y_{i,j}$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y_{i,j} \implies s_i+1\le s_j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-02-28T17:33:39.263" LastActivityDate="2021-02-28T17:33:39.263" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5821" PostTypeId="2" ParentId="5814" CreationDate="2021-02-28T16:25:13.020" Score="4" Body="&lt;p&gt;Your problem can be modeled differently using a set-based approach instead of the classical Boolean approach proposed above. This modeling approach offered by Hexaly is different from traditional MILP solvers. Note that Hexaly is commercial software. Nevertheless, it is free for faculty and students.&lt;/p&gt;&#xA;&lt;p&gt;Below is the code snippet to model your bin packing problem by using Hexaly Modeler:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/* Your model written in LSP. */&#xA;function model() {&#xA;  // Set decisions: bins[k] represents the items in bin k&#xA;  bins[k in 0..nbMaxBins-1] &amp;lt;- set(nbItems);&#xA;&#xA;  // Each item must be in one bin and one bin only&#xA;  constraint partition[k in 0..nbMaxBins-1](bins[k]);&#xA;&#xA;  for [k in 0..nbMaxBins-1] {&#xA;    // Weight constraint for each bin&#xA;    binWeights[k] &amp;lt;- sum(bins[k], i =&amp;gt; itemWeights[i]);&#xA;    constraint binWeights[k] &amp;lt;= binCapacities[k];&#xA;  }&#xA;&#xA;  // Compute the weight of the heaviest bin&#xA;  heaviestBin &amp;lt;- max[k in 0..nbMaxBins-1](binWeights[k]);&#xA;&#xA;  // Minimize the weight of the heaviest bin&#xA;  minimize heaviestBin;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can write the same model in Python, Java, C#, or C++. For that, you can inspire from the original bin packing example described &lt;a href=&quot;https://www.hexaly.com/docs/last/exampletour/binpacking.html#&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Having followed this modeling approach, Hexaly finds quality solutions (optimality gap less than 1%) in a few minutes on a standard computer for instances with thousands of items to pack. For example, look at &lt;a href=&quot;https://www.hexaly.com/benchmarkbpp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this benchmark&lt;/a&gt;. Hexaly embeds and combines innovative exact and heuristic methods under the hood to get such results.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T05:14:05.617" LastActivityDate="2024-04-04T05:14:05.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5822" PostTypeId="2" ParentId="5819" CreationDate="2021-02-28T16:49:14.287" Score="3" Body="&lt;p&gt;Such a problem is difficult to model and solve following a MILP approach, as suggested above. Indeed, the resulting MILP instances will grow quadratically regarding the number of items and bins, while the linear relaxation will be weak.&lt;/p&gt;&#xA;&lt;p&gt;Your problem is closer to a job shop scheduling problem than a basic bin packing problem because of your temporal constraints between items. It can be modeled compactly using a list-based approach instead of the classical Boolean approach proposed above. This is a modeling approach offered by Hexaly that is different from traditional MILP solvers. Note that Hexaly is commercial software. Nevertheless, it is free for faculty and students.&lt;/p&gt;&#xA;&lt;p&gt;Below is the code snippet to model the job shop scheduling problem by using Hexaly Modeler:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function model() {&#xA;  // Integer decisions: start time of each activity&#xA;  // start[j][m] is the start time of the activity of job j which is processed on machine m&#xA;  start[j in 0..nbJobs-1][m in 0..nbMachines-1] &amp;lt;- int(0, maxStart);&#xA;  end[j in 0..nbJobs-1][m in 0..nbMachines-1] &amp;lt;- start[j][m] + processingTime[j][m];&#xA;&#xA;  // Precedence constraints between the activities of a job&#xA;  for [j in 0..nbJobs-1][k in 1..nbMachines-1]&#xA;    constraint start[j][machineOrder[j][k]] &amp;gt;= end[j][machineOrder[j][k-1]];&#xA;&#xA;  // Sequence of activities on each machine&#xA;  jobsOrder[m in 0..nbMachines-1] &amp;lt;- list(nbJobs);&#xA;&#xA;  for [m in 0..nbMachines-1] {&#xA;    // Each job has an activity scheduled on each machine&#xA;    constraint count(jobsOrder[m]) == nbJobs;&#xA;&#xA;    // Disjunctive resource constraints between the activities on a machine&#xA;    constraint and(0..nbJobs-2, i =&amp;gt; start[jobsOrder[m][i+1]][m] &amp;gt;= end[jobsOrder[m][i]][m]);&#xA;  }&#xA;&#xA;  // Minimize the makespan: end of the last activity of the last job&#xA;  makespan &amp;lt;- max[j in 0..nbJobs-1] (end[j][machineOrder[j][nbMachines-1]]);&#xA;  minimize makespan;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can write the same model in Python, Java, C#, or C++. Look at the job shop scheduling example &lt;a href=&quot;https://www.hexaly.com/docs/last/exampletour/jobshop.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Following this modeling approach, Hexaly finds quality solutions in minutes on a standard computer for instances with thousands of jobs to schedule. Hexaly embeds and combines unique exact and heuristic methods under the hood to get such results.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T05:12:34.373" LastActivityDate="2024-04-04T05:12:34.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5823" PostTypeId="2" ParentId="5814" CreationDate="2021-02-28T19:46:36.963" Score="6" Body="&lt;p&gt;With a low to moderate number of distinct weights, this is a variant of a transportation problem. An appropriate model would be &lt;span class=&quot;math-container&quot;&gt;$$\begin{alignat*}{1}&#xA;\min\ \ &amp;amp; w_{\max}\\&#xA;\text{s.t.}\ \ \  &amp;amp; \sum_{j=1}^{J}x_{ij}=n_{i}\ \ \ i=1,\dots,I\\&#xA; &amp;amp; \sum_{i=1}^{I}a_{i}x_{ij}=w_{j}\ \ \ j=1,\dots,J\\&#xA; &amp;amp; w_{j}\le w_{\max}\ \ \ j=1,\dots,J\\&#xA; &amp;amp; 0\le w_{j}\le c_{j}\ \ \ j=1,\dots,J\\&#xA; &amp;amp; x_{ij}\in\mathbb{Z}_{\ge0}\ \ \ \forall i,j&#xA;\end{alignat*}$$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; are the number of distinct weight classes and number of bins respectively, &lt;span class=&quot;math-container&quot;&gt;$n_i$&lt;/span&gt; is the number of items with weight &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; is the capacity of bin &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Using counts within a weight class assigned to each bin rather than indicators for individual items will shrink the model size and get rid of one source of symmetry (invariance of the solution with respect to permuting indices of items with identical weights). The other potential source of symmetry is invariance of the solution with respect to permuting indices of bins with identical capacity. If that happens, you can add constraints to eliminate the bin symmetry. Assume that bins are already sorted in ascending capacity order (&lt;span class=&quot;math-container&quot;&gt;$c_1 \le \dots \le c_J$&lt;/span&gt;). For each group of bins &lt;span class=&quot;math-container&quot;&gt;$j_0, \dots, j_1$&lt;/span&gt; with identical capacity, add constraints requiring &lt;span class=&quot;math-container&quot;&gt;$w_{j_0} \le w_{j_{0}+1} \le \dots \le w_{j_1}$&lt;/span&gt;. The idea is to fill identical bins in nondecreasing order of the weight dumped into each bin.&lt;/p&gt;&#xA;&lt;p&gt;I ran the example you posted as a comment to Rob's solution (64 bins, no weight limits on a bin). The optimal solution had a maximum weight of 1280 for any bin (occurring in 41 of the 64 bins). CPLEX 20 solved it to optimality in something like 0.04 seconds.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-02-28T20:16:51.253" LastActivityDate="2021-02-28T20:16:51.253" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5824" PostTypeId="1" CreationDate="2021-02-28T22:09:12.413" Score="2" ViewCount="111" Body="&lt;p&gt;On &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratically_constrained_quadratic_program#Relaxation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;, I encountered a statement that the semidefinite relaxation of a quadratically constrained quadratic program can be solved more efficiently (using only LP) in the case that no variable is ever multipled by itself; a nonlinear term may only multiply a variable by a different variable. Since a problem I'm interested in fits that requirement—in fact, it's bilinear in the sense that there is an explicit bipartition of the set of variables and a variable from one part may only be multiplied by a variable from the other part—I went to check out the source for this claim: &lt;a href=&quot;https://doi.org/10.1007%2Fs10898-019-00795-w&quot; rel=&quot;nofollow noreferrer&quot;&gt;Solving pooling problems with time discretization by LP and SOCP relaxations and rescheduling methods&lt;/a&gt; by Kimizuka &lt;em&gt;et al.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;That paper is primarily about a particular application (the &lt;em&gt;pooling problem&lt;/em&gt;), but its middle part considers quadratic programming in general, and indeed provides a proof of the stated claim: if there are no square terms in the QP (&amp;quot;Assumption 4.1&amp;quot; in the paper) then a linear relaxation of it attains the same optimal value of the objective function as the semidefinite relaxation of it. Both Wikipedia and the introduction of the paper present the result in that manner. However, after looking at the proof it seems to me that they in fact prove something that goes even farther (though perhaps is not as publishable): &lt;em&gt;in these cases, the semidefiniteness contraint is trivially satisfiable&lt;/em&gt; and thus pointless. It's not so much that a clever linear relaxation provides as good an approximation as the semidefinite one, but rather that the semidefinite relaxation provides an approximation every bit as poor as a rather coarse linear relaxation, which suggests it probably isn't doing a very good job of addressing the nonlinearity of the original QP. :-(&lt;/p&gt;&#xA;&lt;p&gt;But I'm new to QP, so it's quite possible there is something I've overlooked. Thus my question becomes: &lt;strong&gt;Is this analysis correct—is the semidefiniteness constraint in fact pointless?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;h1&gt;The relaxations in question&lt;/h1&gt;&#xA;&lt;p&gt;A general QCQP may be stated as:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;over all &lt;span class=&quot;math-container&quot;&gt;$w \in \mathbb{R}^n$&lt;/span&gt; minimise &lt;span class=&quot;math-container&quot;&gt;$w^\mathrm{T} Q_0 w + \beta_0^\mathrm{T} w + \gamma_0$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$w^\mathrm{T} Q_k w + \beta_k^\mathrm{T} w + \gamma_k \leqslant 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$1 \leqslant k \leqslant m$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$Q_0,\dotsc,Q_m$&lt;/span&gt; are symmetric &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt; matrices, &lt;span class=&quot;math-container&quot;&gt;$\beta_0,\dotsc,\beta_m \in \mathbb{R}^n$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\gamma_0,\dotsc,\gamma_m \in \mathbb{R}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The relaxations are carried out for a reformulation of this, which instead takes as variable a &lt;span class=&quot;math-container&quot;&gt;$(1+n) \times (1+n)$&lt;/span&gt; matrix &lt;span class=&quot;math-container&quot;&gt;$\bar{W} = \begin{pmatrix} w_{00} &amp;amp; w^{\mathrm{T}} \\ w &amp;amp; W \end{pmatrix}$&lt;/span&gt; (for ease of reference, the matrices are named as in Kimizuka &lt;em&gt;et al.&lt;/em&gt;, even if simplifications could be in order). Also define the helper matrices &lt;span class=&quot;math-container&quot;&gt;$\bar{H}_0 = \begin{pmatrix} 1 &amp;amp; \mathbf{0}^\mathrm{T} \\ \mathbf{0} &amp;amp; \mathsf{0} \end{pmatrix}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\hat{Q}_k = \begin{pmatrix} \gamma_k &amp;amp; \tfrac{1}{2}\beta_k^\mathrm{T} \\ \tfrac{1}{2}\beta_k^\mathrm{T} &amp;amp; Q_k \end{pmatrix}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$k=0,\dotsc,m$&lt;/span&gt;. Finally write &lt;span class=&quot;math-container&quot;&gt;$\langle A, B\rangle$&lt;/span&gt; for the Frobenius inner product &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j} A_{i,j} B_{i,j} = \operatorname{Tr}(A B^\mathrm{T})$&lt;/span&gt; of two matrices &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;. Now the QCQP can be restated as:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;minimise &lt;span class=&quot;math-container&quot;&gt;$\langle \hat{Q}_0, \bar{W} \rangle$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\langle \hat{Q}_k, \bar{W} \rangle \leqslant 0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$1 \leqslant k \leqslant m$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\langle \bar{H}_0, \bar{W} \rangle = 1$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$W = w w^\mathrm{T}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The final &lt;span class=&quot;math-container&quot;&gt;$W = w w^\mathrm{T}$&lt;/span&gt; here is the constraint that will be the subject of the relaxation steps. &lt;span class=&quot;math-container&quot;&gt;$\langle \bar{H}_0, \bar{W} \rangle = 1$&lt;/span&gt; is just saying &lt;span class=&quot;math-container&quot;&gt;$w_{00}=1$&lt;/span&gt;. With that in mind, the various &lt;span class=&quot;math-container&quot;&gt;$\langle \hat{Q}_k, \bar{W} \rangle$&lt;/span&gt; are direct transcriptions of the original quadratic constraints and objective function.&lt;/p&gt;&#xA;&lt;h2&gt;Semidefinite (SDP) relaxation&lt;/h2&gt;&#xA;&lt;p&gt;By replacing &lt;span class=&quot;math-container&quot;&gt;$W = w w^\mathrm{T}$&lt;/span&gt; with the constraint that&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bar{W}$&lt;/span&gt; is symmetric and positive semidefinite,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;we arrive at the SDP relaxation, for which efficient methods are available (even if one could wish for them to be faster).&lt;/p&gt;&#xA;&lt;h2&gt;Second-order cone programming (SOCP) relaxation&lt;/h2&gt;&#xA;&lt;p&gt;A necessary (but far from sufficient) condition for &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; to be positive semidefinite is that &lt;span class=&quot;math-container&quot;&gt;$x^\mathrm{T} W x \geqslant 0$&lt;/span&gt; for any test vector &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^n$&lt;/span&gt; with at most two nonzero elements; if these are at positions &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, this condition is moreover equivalent to the claim that the &lt;span class=&quot;math-container&quot;&gt;$2 \times 2$&lt;/span&gt; matrix &lt;span class=&quot;math-container&quot;&gt;$\begin{pmatrix} W_{ii} &amp;amp; W_{ij} \\ W_{ji} &amp;amp; W_{jj} \end{pmatrix}$&lt;/span&gt; is positive semidefinite, which in turn is equivalent to the claim that the determinant &lt;span class=&quot;math-container&quot;&gt;$W_{ii} W_{jj} - W_{ij} W_{ji}$&lt;/span&gt; and its diagonal elements all are nonnegative. Hence a further relaxation of the positive semidefiniteness is that&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$W_{ii} \geqslant 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$1 \leqslant i \leqslant n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$W_{ij}^2 \leqslant W_{ii} W_{jj}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$1 \leqslant i &amp;lt; j \leqslant n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This can apparently be restated as SOCP constraints, which though still nonlinear are easier to handle than SDP constraints. The exact details are not so important, because we shall continue with the linear relaxation.&lt;/p&gt;&#xA;&lt;h2&gt;Linear (LP) relaxation&lt;/h2&gt;&#xA;&lt;p&gt;Another way of looking at &lt;span class=&quot;math-container&quot;&gt;$W_{ij}^2 \leqslant W_{ii} W_{jj}$&lt;/span&gt; is that &lt;span class=&quot;math-container&quot;&gt;$\vert W_{ij}\vert \leqslant \sqrt{W_{ii} W_{jj}}$&lt;/span&gt;, i.e., an off-diagonal element of &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is (in absolute value) bounded from above by the &lt;a href=&quot;https://en.wikipedia.org/wiki/Geometric_mean&quot; rel=&quot;nofollow noreferrer&quot;&gt;geometric mean&lt;/a&gt; of its same row/column diagonal elements. Since the geometric mean in turn is bounded from above by the arithmetic mean, we have that &lt;span class=&quot;math-container&quot;&gt;$-(W_{ii}+W_{jj}) \leqslant 2W_{ij} \leqslant W_{ii}+W_{jj}$&lt;/span&gt; is a relaxation of &lt;span class=&quot;math-container&quot;&gt;$W_{ij}^2 \leqslant W_{ii} W_{jj}$&lt;/span&gt;. In other words we have now arrived at a fully linear relaxation of the original QCQP:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;minimise &lt;span class=&quot;math-container&quot;&gt;$\langle \hat{Q}_0, \bar{W} \rangle$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\langle \hat{Q}_k, \bar{W} \rangle \leqslant 0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$1 \leqslant k \leqslant m$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\langle \bar{H}_0, \bar{W} \rangle = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is symmetric, &lt;span class=&quot;math-container&quot;&gt;$W_{ii} \geqslant 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$1 \leqslant i \leqslant n$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$-(W_{ii}+W_{jj}) \leqslant 2W_{ij} \leqslant W_{ii}+W_{jj}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$1 \leqslant i &amp;lt; j \leqslant n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h2&gt;No squares assumption&lt;/h2&gt;&#xA;&lt;p&gt;It appears all of the above was well known. The new observation Kimizuka &lt;em&gt;et al.&lt;/em&gt; make is that if all the diagonal elements in all of the &lt;span class=&quot;math-container&quot;&gt;$Q_k$&lt;/span&gt; are zero, then the inner products &lt;span class=&quot;math-container&quot;&gt;$\langle \hat{Q}_k, \bar{W} \rangle$&lt;/span&gt; have no contribution from the diagonal elements &lt;span class=&quot;math-container&quot;&gt;$W_{11}$&lt;/span&gt; through &lt;span class=&quot;math-container&quot;&gt;$W_{nn}$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt;, so changing these do not affect the original quadratic constraints or the objective function. In particular, one may take any feasible solution &lt;span class=&quot;math-container&quot;&gt;$\bar{W}$&lt;/span&gt; to the linear relaxation of the problem and add to the &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; part a suitable multiple &lt;span class=&quot;math-container&quot;&gt;$\alpha I$&lt;/span&gt; of the identity matrix (the authors suggest any &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; larger than the largest eigenvalue of &lt;span class=&quot;math-container&quot;&gt;$w w^\mathrm{T} - W$&lt;/span&gt;) to obtain a new &lt;span class=&quot;math-container&quot;&gt;$\bar{W}$&lt;/span&gt; with the same values for all &lt;span class=&quot;math-container&quot;&gt;$\langle \hat{Q}_k, \bar{W} \rangle$&lt;/span&gt; that is furthermore positive (semi)definite—thus a feasible point for the semidefinite relaxation, with the same value for the objective function. Hence all three relaxations have the same optimal value for all instances of QP where the &lt;span class=&quot;math-container&quot;&gt;$Q_k$&lt;/span&gt; diagonals are all zeroes.&lt;/p&gt;&#xA;&lt;p&gt;The catch is that all three relaxations in these cases lack any inequality that puts an upper bound on the &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; diagonal elements, so one may always look at these last. Instead of starting from a feasible point for the above linear relaxation, one can start with a feasible point for the even further relaxed&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;minimise &lt;span class=&quot;math-container&quot;&gt;$\langle \hat{Q}_0, \bar{W} \rangle$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\langle \hat{Q}_k, \bar{W} \rangle \leqslant 0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$1 \leqslant k \leqslant m$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\langle \bar{H}_0, \bar{W} \rangle = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is symmetric,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;then proceed with increasing the diagonal elements as above to achieve semidefiniteness. But this last relaxation is exactly the same as the SDP relaxation minus the semidefiniteness constraint, so that constraint appears to be completely pointless: it does nothing to constrain the set of vectors &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; that the solver might return as solutions to the relaxed problem!&lt;/p&gt;&#xA;" OwnerUserId="4461" LastEditorUserId="38" LastEditDate="2022-01-24T12:42:59.683" LastActivityDate="2022-01-24T12:42:59.683" Title="Is this semidefinite constraint in fact pointless?" Tags="|quadratic-programming|semidefinite-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5825" PostTypeId="2" ParentId="5802" CreationDate="2021-02-28T23:18:16.277" Score="3" Body="&lt;p&gt;Using Calculus of Variations as an inspiration we have the lagrangian&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathcal{L}(f,\lambda) = \int_0^{x_{max}}\left(-\ln\left(\alpha(x)+f(x)\right)+\lambda\left(f(x)-\frac{1}{x_{max}}\right)\right)dx\ \ \  \text{s. t.}\ \ \ f(x)\ge 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The variation regarding &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; gives&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;-\frac{1}{\alpha(x)+f(x)}+\lambda = 0\Rightarrow f(x) = \frac{1}{\lambda}-\alpha(x)\ge 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Proposing then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f_{\lambda}(x) = \max\left(0,\frac{1}{\lambda}-\alpha(x)\right)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;now choosing &lt;span class=&quot;math-container&quot;&gt;$\lambda^*$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\int_0^{x_{max}}f_{\lambda^*}(x)dx = 1$&lt;/span&gt; we follow with the solution&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f_{\lambda^*}(x) = \max\left(0,\frac{1}{\lambda^*}-\alpha(x)\right)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Attached a MATHEMATICA script to handle the necessary computations.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Clear[g, f, binsearch]&#xA;alpha[t_] := (Sin[2 t] + Cos[3 t - 1/2] + 3)/5&#xA;xmax = 3 Pi;&#xA;f[x_, lambda_] := Max[0, 1/lambda - alpha[x]]&#xA;g[lambda_] := NIntegrate[f[x, lambda], {x, 0, xmax}] - 1&#xA;binsearch[xi0_, xs0_] := Module[{error = 0.0001, xi = xi0, xs = xs0, gi, gs, xm, gm},&#xA;  gi = g[xi];&#xA;  gs = g[xs];&#xA;  If[Abs[gi - gs] &amp;gt; error,&#xA;    xm = 0.5 (xi + xs);&#xA;    gm = g[xm];&#xA;    If[gm &amp;gt; 0, xi = xm, xs = xm];&#xA;    binsearch[xi, xs], Return[0.5 (xi + xs)]&#xA;  ]&#xA;]&#xA;&#xA;lambda0 = binsearch[1, 3]&#xA;Plot[{alpha[x], f[x, lambda0]}, {x, 0, xmax}]&#xA;Plot[{alpha[x], alpha[x] + f[x, lambda0]}, {x, 0, xmax}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rUB4T.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rUB4T.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/c2Icg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/c2Icg.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2683" LastActivityDate="2021-02-28T23:18:16.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5826" PostTypeId="1" CreationDate="2021-03-01T11:32:52.463" Score="4" ViewCount="220" Body="&lt;p&gt;I am solving the &lt;strong&gt;CVRP&lt;/strong&gt; with &lt;strong&gt;Adaptive Large Neighborhood Search (ALNS)&lt;/strong&gt; .&lt;/p&gt;&#xA;&lt;p&gt;I used the following construction operators: &lt;code&gt;GreedyInsertion&lt;/code&gt; and &lt;code&gt;regretHeuristique&lt;/code&gt;, and the following destruction operators: &lt;code&gt;relaxShawDeletion&lt;/code&gt; , &lt;code&gt;RoutePortionOperator&lt;/code&gt;, and &lt;code&gt;LongestDetourOperator&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But the solutions I get are very far from the solutions that are in the literature.&lt;/p&gt;&#xA;&lt;p&gt;Do you have an idea on how I can improve the solution? Are there any other operators that give better solutions?&lt;/p&gt;&#xA;" OwnerUserId="4942" LastEditorUserId="491" LastEditDate="2021-03-15T12:44:30.973" LastActivityDate="2021-03-15T12:44:30.973" Title="How to improve the solution in ALNS metaheuristic" Tags="|combinatorial-optimization|vehicle-routing|metaheuristics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5827" PostTypeId="2" ParentId="4456" CreationDate="2021-03-01T16:42:15.120" Score="2" Body="&lt;p&gt;Your problem description is quiet vague. So i picked the simplest solution to his problem i can think off in modeling language &lt;code&gt;JuMP&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you are more detailed about the reality you are working with a better model can be chosen.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;clients = 24&#xA;servers = 3&#xA;&#xA;using JuMP&#xA;using GLPK&#xA;&#xA;&#xA;class = Model(with_optimizer(GLPK.Optimizer))&#xA;&#xA;cost = rand(clients, servers) # cost to connect client i, to server j as cost[i,j]&#xA;# write an array &#xA;@variable(class, connection[1:clients,1:servers], Bin) # a connection exist or it doesn't&#xA;&#xA;for i in 1:clients&#xA;    @constraint(class, sum(connection[i,:]) &amp;gt;= 1 )&#xA;    # every client is connected to at least one server directly &#xA;    # and can only connect to servers&#xA;    # a server can receive an unlimited amount of connections.&#xA;end&#xA;&#xA;@objective(class, Min, sum(cost.*connection)) # minimize cost of connections&#xA;&#xA;@time optimize!(class)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-03-01T16:42:15.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5828" PostTypeId="2" ParentId="5807" CreationDate="2021-03-01T21:28:38.243" Score="1" Body="&lt;p&gt;Perhaps the argument is the following. Observe that &lt;span class=&quot;math-container&quot;&gt;$\operatorname{pos}W$&lt;/span&gt; is a polyhedral cone (every finitely generated cone is polyhedral). That it is finitely generated can be seen from the fact that it is positively spanned by the finite number of columns of &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Thus we can write&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\operatorname{pos}W=\{t\mid Wy=t,y\geq 0\}=\{t\mid Dt\leq 0\}$$&lt;/span&gt;&#xA;for some matrix &lt;span class=&quot;math-container&quot;&gt;$D\in \mathbb{R}^{m\times n}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; being the dimension of &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&#xA;The last expression illustrates that the number of hyperplanes separating &lt;span class=&quot;math-container&quot;&gt;$\operatorname{pos}W$&lt;/span&gt; is finite (&lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="123" LastEditDate="2021-03-02T09:33:28.023" LastActivityDate="2021-03-02T09:33:28.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5829" PostTypeId="1" CreationDate="2021-03-01T21:43:21.333" Score="-1" ViewCount="366" Body="&lt;p&gt;I am wondering to know how it is possible to prove that the second-stage value function in a two-stage stochastic program is convex on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt;? A two-stage stochastic program can be defined as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad c^\top x+\mathcal{Q}(x)\\\text{s.t.}&amp;amp;\quad Ax=b\\&amp;amp;\quad x \ge 0\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;\begin{align}\mathcal{Q}(x)&amp;amp;= E_{\xi}[Q(x,\xi)]&#xA;\\Q(x,\xi)&amp;amp;= \min d(\xi)^\top y\\Wy&amp;amp;=h(\xi)-T(\xi)x\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How is it possible to prove that &lt;span class=&quot;math-container&quot;&gt;$Q(x,\xi)$&lt;/span&gt; is convex on both &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt;? For example, when &lt;span class=&quot;math-container&quot;&gt;$Q(x,\xi)$&lt;/span&gt; is defined as follows, how to prove the convexity?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\xi_1 y_1+y_2&#xA;\\\text{s.t.}&amp;amp;\quad2y_1+3y_2 \ge 1- 2x_1&#xA;\\&amp;amp;\quad y_2 \ge \xi_2-x_1-2x_2&#xA;\\&amp;amp;\quad y_1,y_2 \ge 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="766" LastEditDate="2021-03-07T17:24:40.127" LastActivityDate="2021-03-07T17:24:40.127" Title="How to prove that the second-stage value function of a Stochastic Program is convex?" Tags="|convex-optimization|stochastic-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5830" PostTypeId="1" CreationDate="2021-03-01T21:51:14.757" Score="2" ViewCount="72" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$V\sim F$&lt;/span&gt; be some positive valued random variable such that &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; has a monotone hazard rate (alternatively &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is log-concave). Let &lt;span class=&quot;math-container&quot;&gt;$p = \operatorname{argmax}q(1-F(q))$&lt;/span&gt;. We call &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; the monopoly reserve price, when &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is MHR it's well known that &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is unique.&lt;/p&gt;&#xA;&lt;p&gt;I'm interested the relationship between the monopoly price and the mean, specifically I want to know if &lt;span class=&quot;math-container&quot;&gt;$p \le \Bbb E[V]$&lt;/span&gt;, or else be given an MHR distribution such that &lt;span class=&quot;math-container&quot;&gt;$p &amp;gt; \Bbb E[V]$&lt;/span&gt;. The best bounds I've seen in the literature come from Lemma 3.4 of &lt;a href=&quot;https://dl.acm.org/doi/10.1145/3434423&quot; rel=&quot;nofollow noreferrer&quot;&gt;Giannakopoulos &lt;em&gt;et al.&lt;/em&gt; (2021)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; which shows that &lt;span class=&quot;math-container&quot;&gt;$$\frac{p}{\mu} \le \frac{e}{e-1} = 1.58$$&lt;/span&gt; by loosely using a result of &lt;a href=&quot;https://projecteuclid.org/journals/annals-of-mathematical-statistics/volume-35/issue-3/Bounds-for-Distributions-with-Monotone-Hazard-Rate-I/10.1214/aoms/1177703281.full&quot; rel=&quot;nofollow noreferrer&quot;&gt;Barlow &lt;em&gt;et al.&lt;/em&gt; (1964)&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For the canonical MHR distributions like exponential, uniform, etc. &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is either equal to or less than &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; so I believe if the result fails is should take some sort of construction.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Giannakopoulos, Y., Poças, D., Zhu, K. (2021). Optimal Pricing For MHR and &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;-Regular Distributions. &lt;em&gt;ACM Transactions on Economics and Computation.&lt;/em&gt; 9(1). &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [2] Barlow, R. E., Marshall, A. W. (1964). Bounds for distributions with monotone hazard rate, i. &lt;em&gt;Ann. Math. Stat.&lt;/em&gt; 35(3):1234-1257. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="4800" LastEditorUserId="123" LastEditDate="2021-03-02T09:48:22.067" LastActivityDate="2021-03-02T09:48:22.067" Title="If $F$ is MHR (log-concave), can the monopoly reserve price exceed the mean?" Tags="|inventory|revenue|pricing|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5832" PostTypeId="1" CreationDate="2021-03-02T03:16:20.970" Score="6" ViewCount="3092" Body="&lt;p&gt;I have a &amp;quot;mathematical programming&amp;quot; (MP) problem that does not have an objective function. Namely, I want to find a vector that satisfies all constraints (no optimization involved, right?). Now, a couple of (maybe) silly questions come to my head:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;A &amp;quot;mathematical programming&amp;quot; problem with no objective function is a valid mathematical programming problem?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Whatever the nature of this problem, it can be implemented in optimization software by adding a dummy objective function that is just ignored. So, is this an optimization problem or not? Is it an existence problem that may be solved by construction (finding the solution if it exists)?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Does this kind of problem have a particular name?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5075" LastEditorUserId="491" LastEditDate="2021-03-03T17:21:18.137" LastActivityDate="2021-03-03T17:21:18.137" Title="Is a mathematical programming problem with no objective function an optimization problem?" Tags="|nonlinear-programming|terminology|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5833" PostTypeId="2" ParentId="5832" CreationDate="2021-03-02T03:34:23.787" Score="11" Body="&lt;ol&gt;&#xA;&lt;li&gt;Yes. But some software may require explicit specification of an objective, which can be a constant.&lt;/li&gt;&#xA;&lt;li&gt;Yes. An optimization solver will attempt to find a feasible solution. Any feasible solution is optimal.&lt;/li&gt;&#xA;&lt;li&gt;Feasibility problem.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Some optimization modeling systems or optimization software require an objective to be provided. In such case, you can specify the objective as a constant of your choice; zero is a popular choice.&lt;/p&gt;&#xA;&lt;p&gt;If there are no inequalities, a feasibility problem is often called &amp;quot;root finding&amp;quot;, or &amp;quot;solving a system of equations&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2021-03-02T09:37:24.230" LastActivityDate="2021-03-02T09:37:24.230" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5834" PostTypeId="2" ParentId="5832" CreationDate="2021-03-02T05:07:27.223" Score="9" Body="&lt;p&gt;These problems are known as &lt;a href=&quot;https://en.wikipedia.org/wiki/Constraint_satisfaction_problem&quot; rel=&quot;noreferrer&quot;&gt;Constraint Satisfaction Problems&lt;/a&gt;. In contrast, problems with an objective function are known as Constraint Optimization Problems. Many examples exist. E.g. given some graph with an incomplete edge set, does there exist a closed tour in the graph such that every city is visited exactly once? Or find a schedule that satisfies all scheduling constraints, e.g. every shift needs to be assigned to someone, there must be 1 day off between two different shifts assigned to the same person, no-one can work more than 5 consecutive days.&lt;/p&gt;&#xA;&lt;p&gt;Not all optimization solvers require you to specify an objective function. Even if they do, if the objective is irrelevant you can always specify some dummy objective. In some cases, if you are simply interested in finding any feasible solution, you can actually specify a suitable objective function, and terminate the search when the first feasible solution is found.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-03-02T05:07:27.223" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5835" PostTypeId="1" CreationDate="2021-03-02T07:23:58.690" Score="0" ViewCount="65" Body="&lt;p&gt;I'm looking for a solution approach for my MIP model, but I couldn't find any specific books about this issue whose solution approach is suitable for my model. There are a lot of exact, heuristic or hybrid approaches. Besides, there are a lot of acceleration techniques that can reduce the solution time and I don't know which of them is appropriate for mine. Could anyone help me on what should I do?&lt;/p&gt;&#xA;" OwnerDisplayName="user5077" LastEditorUserId="123" LastEditDate="2021-03-02T09:36:11.017" LastActivityDate="2021-03-02T09:36:11.017" Title="How can we understand which solution approach is suitable for our mathematical problem?" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5836" PostTypeId="2" ParentId="5835" CreationDate="2021-03-02T07:55:02.813" Score="2" Body="&lt;p&gt;I guess that depends on the application and the constraints and expectations that the end users have.&lt;/p&gt;&#xA;&lt;p&gt;For example, do users work with the model interactively, trying different parameter choices and then look at the results immediately? This would mean that the solution time should be in seconds or few minutes. But if it's a planning problem that can be run over night, you can invest hours into the solving time.&lt;/p&gt;&#xA;&lt;p&gt;Is an optimal solution (or bounds) required? Then a model-based approach would be required, otherwise a heuristic might be better.&lt;/p&gt;&#xA;&lt;p&gt;Did you try solving the model with a MIP solver? If it's fast enough, then I'd recommend sticking with that, because it's often easier to modify a model with new requirements, compared to changing a handcrafted heuristic algorithm.&lt;/p&gt;&#xA;" OwnerUserId="126" LastEditorUserId="123" LastEditDate="2021-03-02T09:35:04.797" LastActivityDate="2021-03-02T09:35:04.797" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5837" PostTypeId="2" ParentId="5829" CreationDate="2021-03-02T08:02:13.123" Score="2" Body="&lt;p&gt;Standard assumption: we write a general second-stage problem as &lt;span class=&quot;math-container&quot;&gt;$Q(x,\xi)=\min_y\{q^\top y\mid Wy=h-Tx\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\xi=(q,W,T,h)$&lt;/span&gt;. In your example &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; are fixed (not stochastic) while &lt;span class=&quot;math-container&quot;&gt;$q=(\xi_1,1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h=(1,\xi_2)$&lt;/span&gt; are stochastic.&lt;/p&gt;&#xA;&lt;p&gt;Now, &lt;span class=&quot;math-container&quot;&gt;$Q(x,\xi)$&lt;/span&gt; is convex in &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; but is concave in &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt;. So, saying that &lt;span class=&quot;math-container&quot;&gt;$Q(x,\xi)$&lt;/span&gt; is, in general, convex in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; is wrong, except if &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; is fixed. &lt;span class=&quot;math-container&quot;&gt;$Q(x)$&lt;/span&gt; is the expectation of a convex function and, as such, is convex. In your specific case, the second-stage problem is convex in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\xi_2$&lt;/span&gt;, and is concave in &lt;span class=&quot;math-container&quot;&gt;$\xi_1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To see that &lt;span class=&quot;math-container&quot;&gt;$Q(x,\xi)$&lt;/span&gt; is convex in &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, simply observe that they appear in the right-hand-side of the problem. Now, a minimization linear program is always convex in its right-hand-side. To prove that an LP is convex in its RHS let &lt;span class=&quot;math-container&quot;&gt;$t=h-Tx$&lt;/span&gt;. Consider &lt;span class=&quot;math-container&quot;&gt;$t_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t^{\alpha}=\alpha t_1+(1-\alpha)t_2$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\alpha\in[0,1]$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; be the optimal solution to &lt;span class=&quot;math-container&quot;&gt;$f(t)=\min_y\{q^\top y\mid Wy=t\}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$t=t_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t=t_2$&lt;/span&gt;, respectively. It is easy to see that &lt;span class=&quot;math-container&quot;&gt;$y^{\alpha}= \alpha y_1+(1-\alpha)y_2$&lt;/span&gt; is feasible for &lt;span class=&quot;math-container&quot;&gt;$f(t^{\alpha})=\min_y\{q^\top y\mid Wy=t^{\alpha}\}$&lt;/span&gt; (it satisfies the constraints). However, it is not necessarily optimal. Let &lt;span class=&quot;math-container&quot;&gt;$y^{\alpha*}$&lt;/span&gt; be the optimal solution to &lt;span class=&quot;math-container&quot;&gt;$f(t^{\alpha})$&lt;/span&gt;. We can write&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}f(t^{\alpha})&amp;amp;=q^\top y^{\alpha*}\leq q^\top y^{\alpha}\\&#xA;&amp;amp;=q^\top(\alpha y_1+(1-\alpha)y_2)=\alpha (q^\top y_1)+(1-\alpha)(q^\top y_2)\\&#xA;&amp;amp;=\alpha f(t_1)+(1-\alpha)f(t_2)\end{align*}&lt;/span&gt;&#xA;Which proves convexity. To make the proof more rigorous one must specify how the RHS vectors are chosen. &lt;a href=&quot;https://epubs.siam.org/doi/abs/10.1137/0114008&quot; rel=&quot;nofollow noreferrer&quot;&gt;This article&lt;/a&gt; clarifies that the set of RHSs which make the problem feasible is a polyhedral cone. However, this should suffice for now.&lt;/p&gt;&#xA;&lt;p&gt;To see that is its concave in &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; observe that &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; shows up in the right-hand-side of the dual of &lt;span class=&quot;math-container&quot;&gt;$Q(x,\xi)$&lt;/span&gt;, which is a maximization linear program. A maximization LP is always concave in its right-hand-side.&#xA;The proof proceeds with the same steps used to prove convexity above.&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="766" LastEditDate="2021-03-04T08:55:34.907" LastActivityDate="2021-03-04T08:55:34.907" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5838" PostTypeId="2" ParentId="5788" CreationDate="2021-03-02T10:44:30.070" Score="3" Body="&lt;p&gt;The first option makes sense to me : you are returning &lt;strong&gt;a sum&lt;/strong&gt; such as :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{t \in T} h_t&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$h_t$&lt;/span&gt; represents your &lt;code&gt;variable_heatGeneration&lt;/code&gt; and &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; your &lt;code&gt;set_timeslots&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The second option I do not understand and am not surprised an error is raised. You are returning the sum of &lt;strong&gt;a constant&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$h_t$&lt;/span&gt;. I believe the error&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;TypeError: '_GeneralVarData' object is not iterable&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;is raised because the object &lt;code&gt;model.variable_heatGeneration[t]&lt;/code&gt; is constant and not an iterable object such as list. It is trying to sum over a constant which makes no sense.&lt;/p&gt;&#xA;&lt;p&gt;In a sum, you need an iterable object, for example :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sum(x for x in range(10)) # sum over an iterable&#xA;sum(x for x in L) # if L is a list &#xA;sum([x for x in range(10)]) # sum over a list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In option 2 you are doing something like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sum(x) # where x is a constant&#xA;# or &#xA;sum(3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To get rid of this specific error, try removing the sum :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Option 2&#xA;def ObjectiveRule_2 (model, t):&#xA;    return model.variable_heatGeneration[t]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that this will probably create another error somewhere else, and it will not model the wanted cost function. Sticking with option &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; is a better idea.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-03-02T12:56:16.587" LastActivityDate="2021-03-02T12:56:16.587" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="5839" PostTypeId="1" CreationDate="2021-03-02T13:24:23.703" Score="3" ViewCount="44" Body="&lt;p&gt;I have a strong feeling that this problem I'm trying to solve has already been done by someone much smarter than me at one point and I'm more looking at where I can research a topic further rather than asking for an outright solution.&lt;/p&gt;&#xA;&lt;p&gt;Essentially, I'm looking for a method on how to evenly distribute resources between providers and recipients, not entirely unlike a power grid in real life.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dU6rf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;A example provider/recipient graph&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this example, all the recipients require 100 units of a resource and each provider has 350 units to be handed out. The ideal outcome would be for all recipients except D to receive 100 units from providers 1 and 2, with D receiving an equal 50 units from both provider 1 and 2.&lt;/p&gt;&#xA;" OwnerUserId="5079" LastEditorUserId="491" LastEditDate="2021-03-03T17:24:11.957" LastActivityDate="2021-03-03T17:24:11.957" Title="Power grid distribution and recipient bias" Tags="|graphs|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5840" PostTypeId="1" AcceptedAnswerId="5841" CreationDate="2021-03-02T13:37:29.053" Score="4" ViewCount="480" Body="&lt;p&gt;I would like to seek some advice on modeling the following logical condition:&lt;/p&gt;&#xA;&lt;p&gt;I would like to ensure that a group of binary variables do not equate to 1 simultaneously, i.e., &lt;span class=&quot;math-container&quot;&gt;$\omega_{1}=1, \omega_{2}=1,\cdots,\omega_{n}=1$&lt;/span&gt; is unaccepted.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, the values for &lt;span class=&quot;math-container&quot;&gt;$\omega_{1},\omega_{2},\cdots,\omega_{n}$&lt;/span&gt; can take any permutation of 0s and 1s, e.g. &lt;span class=&quot;math-container&quot;&gt;$\omega_{1}=1,\omega_{2}=1,\cdots,\omega_{n}=0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="2556" LastEditDate="2021-03-02T14:59:12.780" LastActivityDate="2021-03-02T16:55:15.123" Title="Modeling a constraint such that a set of binary decision variables do not equate to 1 simultaneously" Tags="|modeling|integer-programming|constraint|binary-variable|logical-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5841" PostTypeId="2" ParentId="5840" CreationDate="2021-03-02T13:41:54.013" Score="8" Body="&lt;p&gt;How about&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\omega_1 + \cdots + \omega_n \le n-1 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This way, at most all variables but one of them can take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; simultaneously.&lt;/p&gt;&#xA;&lt;p&gt;In the context of knapsack problems, if each variable models the selection of a given item and that the sum of the weights of the items exceed the knapsack capacity, these inequalities are called &lt;em&gt;cover inequalities&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-03-02T14:18:13.037" LastActivityDate="2021-03-02T14:18:13.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5842" PostTypeId="2" ParentId="5840" CreationDate="2021-03-02T16:55:15.123" Score="8" Body="&lt;p&gt;@Kuifje's formulation is correct.  Here's a somewhat automatic derivation via conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\lnot \bigwedge_{i=1}^n \omega_i \\&#xA;\bigvee_{i=1}^n \lnot \omega_i \\&#xA;\sum_{i=1}^n (1 - \omega_i) \ge 1 \\&#xA;\sum_{i=1}^n \omega_i \le n-1 \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-03-02T16:55:15.123" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5843" PostTypeId="2" ParentId="5826" CreationDate="2021-03-02T18:04:21.303" Score="3" Body="&lt;p&gt;We encourage you to look at the code of &lt;a href=&quot;https://github.com/graphhopper/jsprit&quot; rel=&quot;nofollow noreferrer&quot;&gt;jsprit&lt;/a&gt;, the open-source Java vehicle routing library. The jsprit approach is based on a &amp;quot;ruin &amp;amp; recreate&amp;quot; heuristic, also known as Adaptive Large Neighborhood Search (ALNS). The operators can be found &lt;a href=&quot;https://github.com/graphhopper/jsprit/tree/master/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; in the folders &amp;quot;ruin&amp;quot; and &amp;quot;recreate&amp;quot; respectively.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-03-02T18:04:21.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5844" PostTypeId="1" AcceptedAnswerId="5845" CreationDate="2021-03-03T12:18:26.707" Score="6" ViewCount="554" Body="&lt;p&gt;When a paper says they used the intlinprog in MATLAB to solve an integer program, what system actually does the solving?  I have seen documentation about Gurobi and MATLAB: does Gurobi always provide the solving for MATLAB or is that just one option?  What is the &amp;quot;default&amp;quot; solver?  Is it a high quality solver?&lt;/p&gt;&#xA;" OwnerUserId="214" LastActivityDate="2021-03-03T16:31:06.187" Title="What underlies intlinprog in MATLAB?" Tags="|integer-programming|gurobi|matlab|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5845" PostTypeId="2" ParentId="5844" CreationDate="2021-03-03T12:32:46.377" Score="7" Body="&lt;p&gt;Mention of &lt;strong&gt;intlinprog&lt;/strong&gt;, without further specification, generally means the &lt;a href=&quot;https://www.mathworks.com/help/optim/ug/intlinprog.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;intlinprog&lt;/code&gt;&lt;/a&gt; of the MATLAB Optimization Toolbox.&lt;/p&gt;&#xA;&lt;p&gt;However, Gurobi also has a function called &lt;code&gt;intlinprog&lt;/code&gt;, which mimics the interface of the  MATLAB Optimization Toolbox &lt;code&gt;intlinprog&lt;/code&gt;, but which calls the Gurobi solver.  Similarly with Mosek.  CPLEX  has &lt;code&gt;cplexintlinprog&lt;/code&gt;, which mimics the interface of the  MATLAB Optimization Toolbox &lt;code&gt;intlinprog&lt;/code&gt;.  Gurobi, Mosek, and CPLEX also offer other interfaces in MATLAB offering additional functionality not available through the (cplex)intlinprog functions.&lt;/p&gt;&#xA;&lt;p&gt;As to which winds up being the default, that depends on the order of entries in the MATLAB path. Many people don't even realize which solver they are using, and it wouldn't surprise me if there are published papers in which the author(s) used a different solver than what they thought.&lt;/p&gt;&#xA;&lt;p&gt;Further compounding the potential confusion is that &lt;code&gt;intlinprog&lt;/code&gt; might be called through an optimization modeling tool (language), in which case the user is further removed from the actual solver selection. Editorial note: yes of course you should look at the solver  output, at least during debugging and check out, but many people do not.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="8" LastEditDate="2021-03-03T16:31:06.187" LastActivityDate="2021-03-03T16:31:06.187" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5846" PostTypeId="2" ParentId="5832" CreationDate="2021-03-03T16:52:30.420" Score="3" Body="&lt;p&gt;Others have answered most of your questions so I'll just add a bit of info on 2.&lt;/p&gt;&#xA;&lt;p&gt;Any optimisation solver would support this formulation unless it's a very crappy one. Our solver even has a special exit flag for this, &lt;code&gt;Found_Solution_For_CS_Problem&lt;/code&gt;. What might not support the notation explicitly is the modelling environment.&lt;/p&gt;&#xA;&lt;p&gt;For instance, AFAIK GAMS requires users to specify an objective no matter what. The most common way to do this is to simply minimize 0.&lt;/p&gt;&#xA;&lt;p&gt;AMPL on the other hand doesn't need an objective defined, and under the hood it passes &lt;span class=&quot;math-container&quot;&gt;$obj=0$&lt;/span&gt; to the solver.&lt;/p&gt;&#xA;&lt;p&gt;When we receive such a problem in our solver we simply solve &lt;span class=&quot;math-container&quot;&gt;$\min_{x\in X} 0$&lt;/span&gt;, s.t. the constraints.&lt;/p&gt;&#xA;&lt;p&gt;It's important to note that it's bad practice to introduce a dummy variable, because unless you remember to fix its bounds the problem will be unbounded, e.g. &lt;span class=&quot;math-container&quot;&gt;$\min x, x\in[-\infty,\infty]$&lt;/span&gt; is an unbounded problem if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; doesn't appear in your constraints, regardless of your other constraints. Most solvers reeeeeally don't like unbounded problems.&lt;/p&gt;&#xA;&lt;p&gt;The algorithms used to solve constraint satisfaction problems reuse all the basic building blocks but are slightly different because we don't have an objective value to guide us.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-03-03T16:58:22.767" LastActivityDate="2021-03-03T16:58:22.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5847" PostTypeId="1" CreationDate="2021-03-03T23:19:31.410" Score="2" ViewCount="229" Body="&lt;p&gt;I have to define this binary parameter in AMPL:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;param h{k in K, j in Jk, t in T, r in R}; binary&lt;/code&gt;&#xA;which equals 1 if a bus of type &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and age &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; can be assigned to run &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; during period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And I want to:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for {k in K,j in Jk}{&#xA;param h:=&#xA;   [k,j,*,*]:  1   2   3:=&#xA;       2020    0   1   0&#xA;       2025    1   0   1&#xA;       2030    0   0   1&#xA;       2035    0   1   0;   &#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But the output of the console gives me the following error when I print it:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Base_casenew.dat, line 40 (offset 1478):&#xA;    h is already defined&#xA;context:  param  &amp;gt;&amp;gt;&amp;gt; h: &amp;lt;&amp;lt;&amp;lt; =&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5086" LastEditorUserId="36" LastEditDate="2021-03-03T23:34:34.260" LastActivityDate="2021-03-04T00:02:51.357" Title="Error defining a binary parameter in AMPL" Tags="|ampl|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5848" PostTypeId="2" ParentId="5847" CreationDate="2021-03-04T00:02:51.357" Score="3" Body="&lt;p&gt;Using the assignment operator := inside the loop is redefining h for each combination of k and j, which is an error.&lt;/p&gt;&#xA;&lt;p&gt;I assume that your actual data set will not have the same 2D data matrix for all (k, j) combinations (which is what your example here would do if it worked). You might want to look at &lt;a href=&quot;https://ampl.com/BOOK/CHAPTERS/12-data.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chapter 12&lt;/a&gt; of the AMPL book, which discusses various ways for setting up multidimensional parameter data tables.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-03-04T00:02:51.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5849" PostTypeId="1" AcceptedAnswerId="5851" CreationDate="2021-03-04T14:01:34.470" Score="11" ViewCount="890" Body="&lt;p&gt;To solve a linear program (LP) using the simplex method one first needs to bring the LP to standard form. This requires replacing every equality constraint with two inequalities and replacing every free variable with two non-negative variables. I have always felt like this approach can obscure the true structure of the problem and is not the most efficient as it increases the dimensions of the problem. Hence the question: do state-of-the-art solvers convert LPs to standard form before solving, or do they apply more clever strategies to deal with equality constraints and free variables?&lt;/p&gt;&#xA;" OwnerUserId="764" LastEditorUserId="764" LastEditDate="2021-03-04T15:07:06.907" LastActivityDate="2021-03-04T15:10:28.913" Title="Do LP solvers convert LPs to standard form?" Tags="|linear-programming|cplex|solver|gurobi|presolve-preprocessing|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5850" PostTypeId="2" ParentId="5849" CreationDate="2021-03-04T14:27:01.420" Score="3" Body="&lt;p&gt;Based on their manual, as I understood, &lt;em&gt;Gurobi&lt;/em&gt; does not reformat the &lt;strong&gt;equality&lt;/strong&gt; constraint because the equality expression can immediately be added to the list of constraints. They use more clever ways to handle these situations but as a black-box commercial solver, they don't share these approaches with the public and you would never know those techniques.&lt;/p&gt;&#xA;&lt;p&gt;Please check the Gurobi &lt;a href=&quot;https://www.gurobi.com/wp-content/plugins/hd_documentations/documentation/9.0/refman.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;reference manual&lt;/a&gt; page 234 where the equality and inequality operators are being explained.&lt;/p&gt;&#xA;&lt;p&gt;Although increasing the number of constraints and variables may affect the complexity of the model but I don't agree with your statement when you said:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I have always felt like this approach can obscure the true structure of the problem&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-03-04T14:27:01.420" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5851" PostTypeId="2" ParentId="5849" CreationDate="2021-03-04T15:10:28.913" Score="12" Body="&lt;p&gt;No, state of the art LP solvers do not do that. They do bring the problem into a computational form that suits the algorithm used. Note that in the case of simplex algorithms, modern solvers use the revised simplex method with lower and upper bounds that does not require standard form. You can get an idea of the computation forms used from &amp;quot;Computational Techniques of the Simplex Method&amp;quot; by István Maros.&lt;/p&gt;&#xA;&lt;p&gt;The exact form depends on implementational details and might be different from one major solver to the other while not leading to significant performance differences. But specifically the splitting up of equalities and free variables is inefficient and most likely not done by anyone.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2021-03-04T15:10:28.913" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5852" PostTypeId="1" CreationDate="2021-03-04T16:44:59.597" Score="2" ViewCount="158" Body="&lt;p&gt;Assume I have given a convex feasible set &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and I have an oracle that can optimize some linear objective function &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;. Assume that I have given a point &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I want to solve the separation problem to decide if either &lt;span class=&quot;math-container&quot;&gt;$r \in X$&lt;/span&gt; or I want a hyperplane that separates &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;. Is there some practical algorithm for this given the optimization oracle?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="500" LastEditDate="2021-03-04T23:10:59.087" LastActivityDate="2021-03-05T18:01:56.077" Title="Can I solve the separation problem efficiently, when I have access to an optimization oracle?" Tags="|linear-programming|integer-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5853" PostTypeId="1" AcceptedAnswerId="5855" CreationDate="2021-03-04T22:42:04.680" Score="6" ViewCount="2639" Body="&lt;p&gt;I was wondering how does the solver for a MILP determine whether a solution is optimal. I am having a hard time to believe that the solver actually tries all solutions, since in some cases I have over 100 variables and a significant amount of constraints and the solver can solve it in matter of minutes.&lt;/p&gt;&#xA;&lt;p&gt;So suppose, the search space using a &amp;quot;dumb&amp;quot; brute force method is &lt;span class=&quot;math-container&quot;&gt;$2^{100}$&lt;/span&gt;, does branch and bound together with the cutting plane method really decrease the space needed to search to such a small amount that it can conclude within minutes whether the solution is optimal?&lt;/p&gt;&#xA;&lt;p&gt;If not, (which I think is the case), how do solvers generally determine whether a solution is optimal?&lt;/p&gt;&#xA;" OwnerUserId="563" LastActivityDate="2021-03-05T16:12:32.900" Title="How does a solver generally know whether a solution is optimal?" Tags="|optimization|mixed-integer-programming|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5854" PostTypeId="2" ParentId="5852" CreationDate="2021-03-04T22:55:34.430" Score="3" Body="&lt;p&gt;You can minimize any convex function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; using the &lt;a href=&quot;https://en.wikipedia.org/wiki/Frank%E2%80%93Wolfe_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Frank-Wolfe algorithm&lt;/a&gt;.&#xA;In particular, this will give you valid dual bounds at every iteration.&lt;/p&gt;&#xA;&lt;p&gt;[Note: the FW algorithm assumes that you can minimize &lt;em&gt;any&lt;/em&gt; linear function over &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;]&lt;/p&gt;&#xA;&lt;p&gt;Consider the problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;Z^{*} = &amp;amp;\min_{x}\quad\|x - r\|^{2}\\&#xA;&amp;amp;\text{s.t.} \quad x \in X&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assume that &lt;span class=&quot;math-container&quot;&gt;$r \notin X$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$Z^{*} &amp;gt; 0$&lt;/span&gt;, and apply Frank-Wolfe to the above problem.&#xA;After some iteration, you will get a positive dual bound, i.e., you know that &lt;span class=&quot;math-container&quot;&gt;$Z^{*} \geq Z_{\text{dual}} &amp;gt; 0$&lt;/span&gt;, which will prove that &lt;span class=&quot;math-container&quot;&gt;$r \notin X$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can then deduce a separation hyperplane from the ball centered at &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; of radius &lt;span class=&quot;math-container&quot;&gt;$Z^{*}$&lt;/span&gt; by taking a tangent at &lt;span class=&quot;math-container&quot;&gt;$x^{*}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x^{*}$&lt;/span&gt; is an optimal solution of the above problem.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="3598" LastEditDate="2021-03-05T18:01:56.077" LastActivityDate="2021-03-05T18:01:56.077" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5855" PostTypeId="2" ParentId="5853" CreationDate="2021-03-04T23:23:38.070" Score="12" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;I am having a hard time to believe that the solver actually tries all solutions&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Indeed, they typically do not explore the whole search space (though it's possible to build problematic instances where they would).&lt;/p&gt;&#xA;&lt;p&gt;MILP solvers will use a combination of tools to do so, under the umbrella of the branch-and-cut paradigm (B&amp;amp;C is basically branch-and-bound with cutting planes).&#xA;In the rest of my answer I assume basic familiarity with branch-and-bound schemes.&lt;/p&gt;&#xA;&lt;p&gt;First, presolve will typically reduce the size of the problem, by eliminating variables, fixing some, aggregating some constraints, finding symmetries, etc.&#xA;For instance, if your problem has a constraint of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x + 3y \leq 2&#xA;$$&lt;/span&gt;&#xA;for &lt;span class=&quot;math-container&quot;&gt;$x, y$&lt;/span&gt; binary, then you can already set &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; to zero (otherwise the constraint is automatically violated).&#xA;Doing this kind of reductions can significantly reduce the search space.&lt;/p&gt;&#xA;&lt;p&gt;The rest of the proof lies in the branch-and-bound tree.&#xA;Imagine a problem with &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt; binary variables, which would give an exploration tree of &lt;span class=&quot;math-container&quot;&gt;$2^{100}$&lt;/span&gt; leaves.&#xA;A branch=and-bound algorithm will cut portions of that tree using various rules, thereby avoiding the need to explore it all.&lt;/p&gt;&#xA;&lt;p&gt;There are mainly 2 ways of doing so:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;showing that a node in the tree (and thus all of its children) does not contain any feasible integer solution&lt;/li&gt;&#xA;&lt;li&gt;showing that a node in the tree (and thus all of its children) does not contain any optimal integer solution&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Cutting planes&lt;/h2&gt;&#xA;&lt;p&gt;Cutting planes naturally restrict the search space.&#xA;Assume that, at the current node, a binary variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; takes value &lt;span class=&quot;math-container&quot;&gt;$0.5$&lt;/span&gt;, and that you find a valid cut &lt;span class=&quot;math-container&quot;&gt;$x \leq 0.6$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then, you know that the branching decision &lt;span class=&quot;math-container&quot;&gt;$x =1$&lt;/span&gt; will result in an infeasible problem: you can prune the corresponding node, and all of its children.&#xA;The earlier you can do so, the bigger the savings. This is why most of the cuts are typically generated at the root node of the tree.&lt;/p&gt;&#xA;&lt;h2&gt;Pruning by bound&lt;/h2&gt;&#xA;&lt;p&gt;Assume you have a feasible solution to your problem, and its objective value is &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt;.&#xA;Now, assume that, at the current node, the linear relaxation has an objective value of &lt;span class=&quot;math-container&quot;&gt;$110$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then, any integer point (if any) that would be obtained from any of the current's node children, would have an objective value of at least &lt;span class=&quot;math-container&quot;&gt;$110$&lt;/span&gt;: none of them can be optimal, and you can discard the node.&#xA;Again, the earlier you can do that, the better.&lt;/p&gt;&#xA;&lt;p&gt;Note that better linear relaxation provide better bounds, and there allow to discard nodes earlier, which speeds up performance.&#xA;Cutting planes also improve the linear relaxation, thereby providing tighter bounds, which also helps to prune nodes faster.&lt;/p&gt;&#xA;&lt;h2&gt;Other tricks&lt;/h2&gt;&#xA;&lt;p&gt;The two techniques outlines above are, as far as I know, the most generic &amp;amp; common ones to prove optimality in an MILP; though not the only ones.&lt;/p&gt;&#xA;&lt;p&gt;Other techniques include:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;reduced-cost fixing, which allows one to prove that a variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; must take a certain value in any integer-optimal solution&lt;/li&gt;&#xA;&lt;li&gt;symmetry detection, which allow to discard portions of the search tree by showing only a small part needs to be explored for correctness&lt;/li&gt;&#xA;&lt;li&gt;integrality of the objective: if all variables are integer, and all objective coefficients are integer, then the optimal value must be integer. So, if you have a solution with objective value &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt;, and a lower bound of &lt;span class=&quot;math-container&quot;&gt;$9.5$&lt;/span&gt;, you know you have the optimal. Obviously this does not hold for the mixed-integer case.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2021-03-04T23:23:38.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5856" PostTypeId="1" AcceptedAnswerId="5857" CreationDate="2021-03-05T01:02:25.757" Score="3" ViewCount="231" Body="&lt;p&gt;My optimisation problem has a constraint in the form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA; \begin{array}{*{35}{l}}&#xA;\text{}\hspace{16.5mm}\text{ C4:} \hspace{2mm}\sum_{u=1}^U d_{u,1}L_{u}:\sum_{u=1}^U d_{u,2}L_{u}:\cdots:\sum_{u=1}^U d_{u,C}L_{u}=\psi_1:\psi_2:\cdots:\psi_C&#xA;\end{array}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This nonlinear and makes the problem even more complex.&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$L_{u}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\psi_{c}$&lt;/span&gt; are known parameters.&lt;/p&gt;&#xA;&lt;p&gt;I will be satisfied with approximate proportional relation, e..g,&#xA;C4 can be&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{ C4:} \hspace{2mm}\sum_{u=1}^U d_{u,1}L_{u}:\sum_{u=1}^U d_{u,2}L_{u}:\cdots:\sum_{u=1}^U d_{u,C}L_{u}\approx\psi_1:\psi_2:\cdots:\psi_C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I deal with this nonlinear constraint?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2021-03-06T00:57:54.133" LastActivityDate="2021-03-06T00:57:54.133" Title="How can I linearise this nonlinear proportional relation constraint?" Tags="|mixed-integer-programming|integer-programming|nonlinear-programming|linearization|convex-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5857" PostTypeId="2" ParentId="5856" CreationDate="2021-03-05T02:17:14.850" Score="7" Body="&lt;p&gt;Based on the comments (thanks @RobPratt), C4 looks like&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{\sum_{u=1}^U d_{u,1}L_{u}}{\sum_{u=1}^U d_{u,2}L_{u}} = \frac{\psi_1}{\psi_2}$$&lt;/span&gt;&#xA;with similar constraints for other ratios.&lt;/p&gt;&#xA;&lt;p&gt;Just multiply both sides by the denominator, which males it a linear constraint.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{u=1}^U d_{u,1}L_{u} = \frac{\psi_1}{\psi_2}\sum_{u=1}^U d_{u,2}L_{u}$$&lt;/span&gt;&#xA;Similarly with the other constraints in C4.&lt;/p&gt;&#xA;&lt;p&gt;This is then a MILP.&lt;/p&gt;&#xA;&lt;p&gt;If you only require the proportions to be approximately satisfied, one way of doing that is to add a term &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; (declared as an optimization variable) on the right-hand side of the ith of these constraints, and add the inequality constraints &lt;span class=&quot;math-container&quot;&gt;$-f \le a_i \le f$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is the allowed fudge (tolerance) factor for constraint satisfaction. This is still a MILP.&lt;/p&gt;&#xA;&lt;p&gt;You could instead make the tolerance a multiplicative factor of the ratios of the &lt;span class=&quot;math-container&quot;&gt;$\psi 's$&lt;/span&gt;. This introduces binary, continuous product terms, which can be linearized using standard techniques well-covered in this forum.&lt;/p&gt;&#xA;&lt;p&gt;Or change the equality constraints to double-sided inequality constraints building in the allowable tolerance, rather than introducing new variables. This can be done with either the additive or multiplicative tolerance.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2021-03-05T02:39:34.180" LastActivityDate="2021-03-05T02:39:34.180" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5859" PostTypeId="2" ParentId="5853" CreationDate="2021-03-05T11:38:48.063" Score="3" Body="&lt;p&gt;This depends on your definition of &amp;quot;optimal&amp;quot;. Generally speaking, a solution is optimal iff it satisfies the KKT conditions for optimality. In that sense, finding a KKT point is relatively simple, and proving that a given point satisfies (or not) KKT is as trivial as evaluating a system of equations.&lt;/p&gt;&#xA;&lt;p&gt;If the problem is mixed-integer, the concept of optimality vanishes because, in the general case, integer feasible points will not necessarily satisfy KKT. In that case, we refer to a solution as optimal simply if it's integer feasible, even though the proper term is &amp;quot;feasible&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Going by the body of your question, I suspect you refer to &amp;quot;globally optimal&amp;quot; solutions, as in proving that an optimal/feasible (for MI) point is the best. This is the domain of deterministic global optimisation solvers and the main algorithm is branch-and-bound, although different algorithms exist for special cases (e.g., QP Diving for convex MINLP).&lt;/p&gt;&#xA;&lt;p&gt;In order for a deterministic global optimisation solver to work well we need to implement literally thousands of algorithms, including:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Primal heuristics to find locally optimal points&lt;/li&gt;&#xA;&lt;li&gt;Domain reduction techniques&lt;/li&gt;&#xA;&lt;li&gt;Problem reduction techniques&lt;/li&gt;&#xA;&lt;li&gt;Branching heuristics&lt;/li&gt;&#xA;&lt;li&gt;Techniques to generate multiple types of convex relaxations&lt;/li&gt;&#xA;&lt;li&gt;Continuous and integer cuts&lt;/li&gt;&#xA;&lt;li&gt;Symbolic reformulation techniques, usually to symbolically transform the problem to an easier problem class&lt;/li&gt;&#xA;&lt;li&gt;Techniques to eliminate singularities from the problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The reason we can &lt;em&gt;prove&lt;/em&gt; that a solution is globally optimal, even for non-convex problems, is that the techniques we use to generate the convex relaxations provide theoretical guarantees that the lower bounds (if we are minimising) we obtain will improve if the domain is reduced, which is why we use branch and bound. After creating enough nodes, we are left with a lowest lower bound (across the entire branch and bound tree) that is within an arbitrarily small tolerance of the best local solution/feasible point we have found so far. This means that this is literally the best possible value that can be achieved, ergo it is globally optimal.&lt;/p&gt;&#xA;&lt;p&gt;For MILPs it's a very similar concept, MILP solvers relax integrality and solve that as their relaxation. When the worst value of the relaxed problem is within a tolerance of the best integer solution found so far, global optimality is proven.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-03-05T11:38:48.063" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5860" PostTypeId="1" AcceptedAnswerId="5861" CreationDate="2021-03-05T12:13:53.793" Score="2" ViewCount="168" Body="&lt;p&gt;I have the following problem:&lt;/p&gt;&#xA;&lt;p&gt;Depending on my continuous optimization variable &lt;span class=&quot;math-container&quot;&gt;$S_m$&lt;/span&gt;, I would like to introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_m$&lt;/span&gt;, which, depending on the value of &lt;span class=&quot;math-container&quot;&gt;$S_m$&lt;/span&gt; (greater or less than 0) receives the value 0 or 1. The whole thing is to be repeated for 12 months. I have already created both variables, I just don't know how to link them, so that &lt;span class=&quot;math-container&quot;&gt;$x_m$&lt;/span&gt; has no influence on &lt;span class=&quot;math-container&quot;&gt;$S_m$&lt;/span&gt;, and the value for &lt;span class=&quot;math-container&quot;&gt;$x_m$&lt;/span&gt; depends purely on the value of &lt;span class=&quot;math-container&quot;&gt;$S_m$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5092" LastEditorUserId="39" LastEditDate="2021-03-05T12:40:56.820" LastActivityDate="2021-03-07T10:14:28.133" Title="Link a binary variable to continuous variable in Java Gurobi" Tags="|optimization|gurobi|java|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5861" PostTypeId="2" ParentId="5860" CreationDate="2021-03-05T12:43:37.677" Score="1" Body="&lt;p&gt;The easiest would probably be to model it as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;S_m \leq a + bx_m \\&#xA;S_m \geq ax_m&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is the switch and &lt;span class=&quot;math-container&quot;&gt;$a+b$&lt;/span&gt; is the upper bound for variable &lt;span class=&quot;math-container&quot;&gt;$S_m$&lt;/span&gt;. In this case, if &lt;span class=&quot;math-container&quot;&gt;$S_m&amp;lt; a$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_m$&lt;/span&gt; has to be 0 (otherwise this is infeasible). Similarly, if &lt;span class=&quot;math-container&quot;&gt;$S_m &amp;gt; a$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_m$&lt;/span&gt; has to be 1. The key question here is what you want to happen if &lt;span class=&quot;math-container&quot;&gt;$S_m = a$&lt;/span&gt;, but that is something that depends on your business requirements.&lt;/p&gt;&#xA;&lt;p&gt;To answer your questions, you can model these things using a simple linear constraint, see the Gurobi Java documentation &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/java_model_addconstr.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2021-03-05T12:43:37.677" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5862" PostTypeId="2" ParentId="5860" CreationDate="2021-03-05T12:54:50.503" Score="1" Body="&lt;p&gt;In addition to what @Richard mentioned:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You can consider &lt;span class=&quot;math-container&quot;&gt;$a=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b=\epsilon$&lt;/span&gt; in @Richard's answer.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gurobi.com/pdfs/user-events/2017-frankfurt/Modeling-2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; you can find how special functions in the constraint can be modeled using Gurobi. Yours is defining an indicator variable for &lt;span class=&quot;math-container&quot;&gt;$S_m$&lt;/span&gt; to find out whether the value of your variable is positive or negative.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;you can model it as follow:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$S_m \leq 150x_m-\epsilon(1-x_m)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-100(1-x_m)+\epsilon x_m\leq S_m$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A positive &lt;span class=&quot;math-container&quot;&gt;$S_m$&lt;/span&gt; will force &lt;span class=&quot;math-container&quot;&gt;$x_m=1$&lt;/span&gt; via the first constraint. A negative &lt;span class=&quot;math-container&quot;&gt;$S_m$&lt;/span&gt; will make &lt;span class=&quot;math-container&quot;&gt;$x_m=0$&lt;/span&gt; while the second constraint is active.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2021-03-05T14:44:03.390" LastActivityDate="2021-03-05T14:44:03.390" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5863" PostTypeId="2" ParentId="5853" CreationDate="2021-03-05T15:58:20.363" Score="6" Body="&lt;p&gt;Optimality implies that a proof was constructed that proves there does not exist a better solution than the best feasible solution found. A brute force search does indeed give you a (rather long) proof. However, in many settings you can find shorter proofs than enumerating all possible cases. For example, when finding a shortest-path in a fully connected graph, we have better approaches than to enumerate all &lt;span class=&quot;math-container&quot;&gt;$2^{|V|}$&lt;/span&gt; simple paths.&lt;/p&gt;&#xA;&lt;p&gt;Typically, proving optimality can be done as follows: when you have a proof for a lower bound on the solution value and a proof for an upper bound on the solution value with equal bounds, you know the optimal solution value. If you have found an actual solution that has this solution value, you have an optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;If we assume a minimization problem such as the MILP, the upper bound typically corresponds to finding actual solutions: any feasible solution is by itself a proof of an upper-bound on the solution value (it is typically easy to verify the feasibility and objective value of a given solution). Often, the hard part is actually finding a concise proof for the lower-bound. The &lt;em&gt;P&lt;/em&gt; vs &lt;em&gt;NP&lt;/em&gt; problem actually is closely related to when we can and can not prove efficiently both a lower and upper-bound. For a minimization problem in &lt;em&gt;P&lt;/em&gt; &lt;sup&gt;[1]&lt;/sup&gt;, we know that there always exists a proof of the optimal lower-bound which has a polynomial length in the description of the problem. For &lt;em&gt;NP-hard&lt;/em&gt; problems, we generally have no idea how to construct polynomial sized proofs in general for this optimal lower-bound, although for specific problem instances we may end up being lucky that we can find a short proof.&lt;/p&gt;&#xA;&lt;p&gt;So ultimately the whole thing boils down to how smart you are in finding short and concise proofs in an automated way. For MILP, the LP-relaxation will give you a proof of a lower-bound in polynomial time. If you somehow are able to find a solution/upper-bound with the same solution value, you are happy that your instance admits a short proof - you do not need full enumeration to build a proof, but can use the much shorter LP-relaxation. If there is a gap between your solution/upper-bound and the lower-bound given by the LP-relaxation, you can use case analysis (a common proving technique in mathematics) by partitioning the problem into sub-problems, hoping that these sub-problems can provide you with better gaps. This is ultimately what branch-and-bound does when you interpret it's workings as a proving-technique. In that context, the techniques mentioned by &lt;a href=&quot;https://or.stackexchange.com/a/5855/1047&quot;&gt;mtanneau's answer&lt;/a&gt; are basically smarter ways to perform (or even avoid) this case-analysis.&lt;/p&gt;&#xA;&lt;p&gt;Often, a MILP solver just spends a lot of time trying to bring the proof for the lower-bound and the upper-bound close enough together to argue that the solution that was found is optimal. It can perfectly happen that the solver finds the optimal solution in a second, but needs hours to prove that it is actually optimal since the gap is not closed.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sup&gt;[1]&lt;/sup&gt; I might be a bit sloppy here since the P vs NP theory is mostly concered with decision problems rather than optimization problems, but for problems in &lt;em&gt;P&lt;/em&gt; it should not really matter which type of problem you have.&lt;/p&gt;&#xA;" OwnerUserId="1047" LastEditorUserId="1047" LastEditDate="2021-03-05T16:12:32.900" LastActivityDate="2021-03-05T16:12:32.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5865" PostTypeId="2" ParentId="5860" CreationDate="2021-03-06T10:57:41.690" Score="1" Body="&lt;pre&gt;&lt;code&gt;for (int m = 0; m &amp;lt; (int)this.Anzahl_Monate; m++)&#xA;    {&#xA;        constra = new GRBLinExpr();&#xA;        constra.addTerm(150, x_m[m]);&#xA;        constra.addTerm(0.000001, x_m[m]);&#xA;        constra.addConstant(-0.000001);&#xA;        &#xA;        model.addConstr(constra, GRB.GREATER_EQUAL, S_m[m], &amp;quot;a&amp;quot;);&#xA;        &#xA;        constrb = new GRBLinExpr();&#xA;        constrb.addTerm(100, x_m[m]);&#xA;        constrb.addConstant(-100);&#xA;        constrb.addTerm(0.000001, x_m[m]);&#xA;    &#xA;        model.addConstr(constrb, GRB.LESS_EQUAL, S_m[m], &amp;quot;b&amp;quot; + m);&#xA;         &#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5092" LastEditorUserId="5092" LastEditDate="2021-03-07T10:14:28.133" LastActivityDate="2021-03-07T10:14:28.133" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5866" PostTypeId="1" CreationDate="2021-03-06T14:58:25.443" Score="0" ViewCount="250" Body="&lt;p&gt;I am trying to sum over a subset between &lt;span class=&quot;math-container&quot;&gt;$t+1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t+U-1$&lt;/span&gt; as follows &lt;span class=&quot;math-container&quot;&gt;$$y_i^t+\sum_{k=t+1}^{t+Ut_i-1}z_i^k\le1$$&lt;/span&gt; but I could not define the condition within &lt;code&gt;sum&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here is what I have tried:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;y(i,t) + sum(t $(ord(t)=t+1 and ord(t)&amp;lt;= t+gendata(i,&amp;quot;U&amp;quot;)-1)  ,z(i,j)) =l= 1;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5099" LastEditorUserId="123" LastEditDate="2021-03-06T15:06:32.630" LastActivityDate="2021-05-05T08:44:41.403" Title="GAMS summing over subset" Tags="|gams|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5867" PostTypeId="1" AcceptedAnswerId="5868" CreationDate="2021-03-06T16:06:46.510" Score="4" ViewCount="734" Body="&lt;p&gt;We define the Min Cost Flow Problem with Lower Bounds (MCFPLB) as a generalization of the usual Min Cost Flow. The input consists of:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;a directed graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;capacities &lt;span class=&quot;math-container&quot;&gt;$u_{ij} \geq 0$&lt;/span&gt; for each edge &lt;span class=&quot;math-container&quot;&gt;$(i,j) \in E$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;costs &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; for each edge &lt;span class=&quot;math-container&quot;&gt;$(i,j) \in E$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;a supply value &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; for each node &lt;span class=&quot;math-container&quot;&gt;$i\in V$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It is balanced &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in V} b_i = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The output are values &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in E$&lt;/span&gt;, so that&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij} \geq 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in E$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij} \leq u_{ij}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in E$&lt;/span&gt; (capacity constraints)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{ij} x_{ij} - \sum_{ji} x_{ji} = b_i$&lt;/span&gt;  &lt;span class=&quot;math-container&quot;&gt;$\forall i\in V$&lt;/span&gt; (flow&#xA;conservation constraints)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij} \geq \ell_{ij}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in E$&lt;/span&gt; (lower bound&#xA;constraints)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Our objective is the same:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\min \sum_{(i,j)\in E} c_{ij} x_{ij}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Using the MCF algorithm, solve the MCFPLB.&lt;/p&gt;&#xA;&lt;p&gt;So the issue here is handling the lower bound constraints. The MCF problem does not inherently capture this when solving, so we must be a little creative. My current idea to motivate the MCF algorithm is to take the lower bound and add it to a node &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; as demand so that the MCF will satisfy the lower bound constraints, i.e. we define &lt;span class=&quot;math-container&quot;&gt;$b_i' = b_i \pm \ell_{ij}$&lt;/span&gt; (add for supply, subtract for demand, we add to supply nodes and subtract from demand nodes). However I am having a hard time justifying and formalizing this idea. Furthermore, I am not sure if this is the best way to do this, so I am open to any advice or help.&lt;/p&gt;&#xA;" OwnerUserId="3231" LastEditorUserId="500" LastEditDate="2021-03-06T16:23:00.940" LastActivityDate="2021-03-06T16:23:00.940" Title="Min Cost Flow with lower bound reduction to MCF algorithm" Tags="|optimization|linear-programming|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5868" PostTypeId="2" ParentId="5867" CreationDate="2021-03-06T16:22:21.037" Score="7" Body="&lt;p&gt;Your intuition that you need to adjust &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; is correct, but you also need to adjust &lt;span class=&quot;math-container&quot;&gt;$u_{i,j}$&lt;/span&gt;.  To derive the desired MCF, perform a change of variables &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}=x_{i,j}-\ell_{i,j}$&lt;/span&gt; (so that the lower bound constraints become &lt;span class=&quot;math-container&quot;&gt;$y_{i,j} \ge 0$&lt;/span&gt;).  That is, replace &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}+\ell_{i,j}$&lt;/span&gt; throughout your constraints, and rewrite into the form of MCF.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-03-06T16:22:21.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5869" PostTypeId="1" AcceptedAnswerId="5870" CreationDate="2021-03-06T20:06:01.080" Score="2" ViewCount="154" Body="&lt;p&gt;Let's say I have a graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; where each vertex has an edge going both into and out of it (i.e. cyclic, akin to the kidney donor pair problem). Now suppose we have a capacity &lt;span class=&quot;math-container&quot;&gt;$u_{ij} = 1 \forall(i,j) \in E$&lt;/span&gt; and supplies &lt;span class=&quot;math-container&quot;&gt;$b_i=0 \forall i\in V$&lt;/span&gt;. We also have some cost &lt;span class=&quot;math-container&quot;&gt;$c_{ij} \forall(i,j) \in E$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The typical constraints for a MCF problem are not exceeding capacity and flow conservation:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{ij} \leq u_{ij} \forall (i,j) \in E$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{ji}x_{ji}-\sum\limits_{ij}x_{ij}=b_i=0 \forall i \in V$$&lt;/span&gt;&#xA;Now suppose I want to model the following constraint using only input to the MCF algorithm. Let's say I only want exactly one unit or less of flow into and out of a given node, instead of merely satisfying flow conservation. I.e, I want to capture something stronger &lt;span class=&quot;math-container&quot;&gt;$(\dagger)$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{ji}x_{ji} \leq 1 \hspace{5mm} \text{Flow into node i}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{ij}x_{ij}\leq 1 \hspace{5mm} \text{Flow out of node i}$$&lt;/span&gt;&#xA;using only capacity and flow conservations constraints.&lt;/p&gt;&#xA;&lt;p&gt;Subtracting the two constraints merely brings us back to flow conservation, so I believe additional structure is needed for the graph. So for a given node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, if we have more than one edge directed towards and out of the node, it becomes an issue as we could possibly send and receive two or more units. So we need to somehow &amp;quot;turn off&amp;quot; these additional edges once one edge is used. My intuition tells me we need to construct some dummy nodes that somehow remove all flow going out of node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; so that when we look at flow conservation, we only have flow into node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; which we can then be used to restrict only one flow of unit into the node. However, this would require also changing the supply to &lt;span class=&quot;math-container&quot;&gt;$b_i' = 1$&lt;/span&gt; which does not seem right. I want to keep the original supplies intact. I am currently stuck on how dummy nodes could be used to capture &lt;span class=&quot;math-container&quot;&gt;$(\dagger)$&lt;/span&gt; or if dummy nodes are even the correct approach here.&lt;/p&gt;&#xA;" OwnerUserId="3231" LastEditorUserId="500" LastEditDate="2021-03-06T20:16:01.100" LastActivityDate="2021-03-07T12:09:54.620" Title="Constraining flow into a node and out of a node using Min Cost Flow input" Tags="|optimization|linear-programming|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5870" PostTypeId="2" ParentId="5869" CreationDate="2021-03-06T20:13:38.543" Score="4" Body="&lt;p&gt;The transformation you want is called &lt;em&gt;node splitting&lt;/em&gt;.  Replace node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; with two nodes &lt;span class=&quot;math-container&quot;&gt;$i'$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i''$&lt;/span&gt;, where all incoming arcs to node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; instead arrive at node &lt;span class=&quot;math-container&quot;&gt;$i'$&lt;/span&gt; and all outgoing arcs from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; instead leave node &lt;span class=&quot;math-container&quot;&gt;$i''$&lt;/span&gt;.  Also introduce a directed arc from &lt;span class=&quot;math-container&quot;&gt;$i'$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$i''$&lt;/span&gt; with capacity &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-03-06T20:13:38.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5871" PostTypeId="1" AcceptedAnswerId="5876" CreationDate="2021-03-07T11:00:23.433" Score="5" ViewCount="127" Body="&lt;p&gt;This is an intrinsically &amp;quot;practical&amp;quot; question, but it leads to a well-defined mathematical problem. Let me start with the practical part:&lt;/p&gt;&#xA;&lt;p&gt;I regularly back up my data. My backup strategy are &lt;em&gt;differential backups&lt;/em&gt;, where the first backup is a &lt;em&gt;full&lt;/em&gt; backup containing all files and subsequent backups are either full backups or differential backups, containing only data that has been added/changed since the last full backup.&lt;sup&gt;1&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;p&gt;My backup storage is limited to &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;. I use the term &amp;quot;snapshot&amp;quot; to refer to the data from either a full backup or a differential backup.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: After how many differential backups should I make a new full backup to maximize the number of snapshots I can squeeze in the storage capacity &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Intuition: A full backup takes up more space than a differential backup, but the more data has been added since the last full backup, the larger becomes &lt;em&gt;each&lt;/em&gt; additional differential backup. Therefore, there is a trade-off between an additional large full backup vs. many larger differential backups.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I tried to formalize my problem as follows:&lt;/p&gt;&#xA;&lt;p&gt;Denote data that is newly added between &lt;span class=&quot;math-container&quot;&gt;$t-1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$s(t)$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$s(0) = d_0$&lt;/span&gt; (some constant, size of initial data). Ignore deletes, i.e. total data at time &lt;span class=&quot;math-container&quot;&gt;$\tilde{t}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$f(\tilde{t})=\sum_{t=0}^{\tilde{t}} s(t)$&lt;/span&gt;, which equals the size of a full backup at this time. The size of a differential backup (&lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;) at time &lt;span class=&quot;math-container&quot;&gt;$\tilde{t}$&lt;/span&gt; depends on the time of the last full backup &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$d(\tilde{t},b) = \sum_{t=b+1}^{\tilde{t}} s(t)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;With 1 full backup and only differential backups afterwards, I am not running out of storage capacity &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; as long as &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is small enough&lt;sup&gt;2&lt;/sup&gt; such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(0) + \sum_{\tilde{t}=1}^T d(\tilde{t}, 0) \leq C.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With 2 full backups, each followed by differential backups, &lt;span class=&quot;math-container&quot;&gt;$T_1$&lt;/span&gt; must be small enough such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(0) + \sum_{\tilde{t}=1}^{T_0} \Big[ d(\tilde{t}, 0) \Big] + f(T_0+1) + \sum_{\tilde{t}=T_0+2}^{T_1} d(\tilde{t}, T_0+1) \leq C.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I think the pattern becomes clear now:&lt;sup&gt;3&lt;/sup&gt; with &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; full backups, &lt;span class=&quot;math-container&quot;&gt;$T_{N-1}$&lt;/span&gt; must be small enough such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(0) + \sum_{\tilde{t}=1}^{T_0} \Big[ d(\tilde{t}, 0) \Big] + \sum_{n=1}^{N-1} \Big[ f(T_{n-1}+1) + \sum_{\tilde{t}=T_{n-1}+2}^{T_n} d(\tilde{t}, T_{n-1}+1) \Big] \leq C. \tag{1} \label{eq:cond}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This leads to the ultimate &lt;strong&gt;question&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Which &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; maximizes the largest &lt;span class=&quot;math-container&quot;&gt;$T_{N-1}$&lt;/span&gt; for which equation &lt;span class=&quot;math-container&quot;&gt;$(\ref{eq:cond})$&lt;/span&gt; holds?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I am not sure how to approach a solution to this problem, nor am I sure if further assumptions are needed to make progress. Maybe it is helpful to assume that the amount of new data in each period &lt;span class=&quot;math-container&quot;&gt;$s(t)$&lt;/span&gt; is constant (&lt;span class=&quot;math-container&quot;&gt;$s(t) = \bar{s} ~ \forall ~ t$&lt;/span&gt;)?&lt;/p&gt;&#xA;&lt;p&gt;Plugging my definitions of &lt;span class=&quot;math-container&quot;&gt;$f(\tilde{t})$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d(\tilde{t}, b)$&lt;/span&gt; into equation &lt;span class=&quot;math-container&quot;&gt;$(\ref{eq:cond})$&lt;/span&gt; yields:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$d_0 + \Big[ \sum_{\tilde{t}=1}^{T_0} \sum_{t=1}^{\tilde{t}} s(t) \Big] + \sum_{n=1}^{N-1} \Bigg[ \Big[ \sum_{t=0}^{T_{n-1}+1} s(t) \Big] + \Big[ \sum_{\tilde{t}=T_{n-1}+2}^{T_n} \sum_{t=T_{n-1}+2}^{\tilde{t}} s(t) \Big] \Bigg] \leq C, \tag{1'} \label{eq:cond-plugged-in}$$&lt;/span&gt;&#xA;but I do not know how to proceed from here.&lt;/p&gt;&#xA;&lt;p&gt;Any help, either on tackling equation &lt;span class=&quot;math-container&quot;&gt;$(\ref{eq:cond-plugged-in})$&lt;/span&gt; or completely different strategies to solve the problem are highly appreciated!&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; Note that I am &lt;em&gt;not&lt;/em&gt; referring to &lt;em&gt;incremental&lt;/em&gt; backups, where each backup contains only the data since the previous incremental backup. Differential backups always contain all data since the last &lt;em&gt;full&lt;/em&gt; backup.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sup&gt;2&lt;/sup&gt; I assume that &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is large enough for at least 1 full and 1 differential backup.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sup&gt;3&lt;/sup&gt; To be more explicit, the conditions for 3 and 4 full backups are&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(0) + \sum_{\tilde{t}=1}^{T_0} d(\tilde{t}, 0) + f(T_0+1) + \sum_{\tilde{t}=T_0+2}^{T_1} d(\tilde{t}, T_0+1) + f(T_1+1) + \sum_{\tilde{t}=T_1+2}^{T_2} d(\tilde{t}, T_1+1) \leq C,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f(0) + \sum_{\tilde{t}=1}^{T_0} d(\tilde{t}, 0) + f(T_0+1) + \sum_{\tilde{t}=T_0+2}^{T_1} d(\tilde{t}, T_0+1) + f(T_1+1) + \sum_{\tilde{t}=T_1+2}^{T_2} d(\tilde{t}, T_1+1) + f(T_2+1) + \sum_{\tilde{t}=T_2+2}^{T_3} d(\tilde{t}, T_2+1) \leq C.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5102" LastActivityDate="2021-03-14T21:58:34.827" Title="Maximize number of backups that fit on backup drive" Tags="|optimization|solver|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="5873" PostTypeId="1" CreationDate="2021-03-07T21:46:01.800" Score="10" ViewCount="794" Body="&lt;p&gt;I am looking for papers (or any resources) that go deep into the details of implementing local search algorithms.&lt;/p&gt;&#xA;&lt;p&gt;I don't want an introductory paper on the subject. Rather, I would prefer a survey dedicated to the implementation issues or papers that go into the details of implementation on a given optimization problem.&lt;/p&gt;&#xA;&lt;p&gt;N.B : I would appreciate papers with code but detailed papers with no code will be also good&lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="123" LastEditDate="2021-03-08T08:33:37.517" LastActivityDate="2024-04-04T05:25:36.077" Title="Paper suggestions on local search algorithms" Tags="|optimization|reference-request|implementation|local-search|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5874" PostTypeId="2" ParentId="5873" CreationDate="2021-03-08T09:02:41.273" Score="4" Body="&lt;p&gt;I'm not an expert in the field, but the paper &lt;a href=&quot;http://webhotel4.ruc.dk/%7Ekeld/research/LKH/&quot; rel=&quot;nofollow noreferrer&quot;&gt;An effective implementation of the Lin-Kernighan traveling salesman heuristic&lt;/a&gt; by Keld Helsgaun was mentioned in another question before.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2021-03-08T09:02:41.273" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5875" PostTypeId="2" ParentId="5873" CreationDate="2021-03-08T09:07:57.833" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s10732-018-9381-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Blot &lt;em&gt;et al.&lt;/em&gt; (2018)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; did an extensive literature review on multi-objective LS algorithms. You may wish to take a look at &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-540-24854-5_120&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ishibuchi and Murata (2004)&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt; which focuses on issues in evolutionary algorithms.&lt;/p&gt;&#xA;&lt;p&gt;These were found through a very quick search using &lt;a href=&quot;https://scholar.google.com/scholar?hl=en&amp;amp;as_sdt=0%2C5&amp;amp;q=allintitle%3A+survey+OR+review+OR+issue+%22local+search%22&amp;amp;btnG=&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;allintitle: survey OR review OR issue &amp;quot;local search&amp;quot;&lt;/code&gt;&lt;/a&gt; but the query can be broadened as needed.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Blot, A., Kessaci, M-É., Jourdan, L. (2018). Survey and unification of local search techniques in metaheuristics for multi-objective combinatorial optimisation. &lt;em&gt;Journal of Heuristics.&lt;/em&gt; 24(6):853-877. &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [2] Ishibuchi, H., Narukawa, K. (2004). Some Issues on the Implementation of Local Search in Evolutionary Multiobjective Optimization. In &lt;em&gt;Genetic and Evolutionary Computation Conference&lt;/em&gt; (pp. 1246-1258). Springer, Berlin, Heidelberg. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2021-03-08T14:16:38.077" LastActivityDate="2021-03-08T14:16:38.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5876" PostTypeId="2" ParentId="5871" CreationDate="2021-03-08T10:00:44.597" Score="4" Body="&lt;p&gt;Here is an easy dynamic programming solution which runs in &lt;span class=&quot;math-container&quot;&gt;$O(n^2)$&lt;/span&gt; time, where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the number of updates to the data.&lt;/p&gt;&#xA;&lt;p&gt;Create an array of partial sums &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; of size &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$p[j]=\sum_{i=0}^{j}s(i)$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$0\leq j \leq n-1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$0\leq k \leq t \leq n$&lt;/span&gt; let &lt;span class=&quot;math-container&quot;&gt;$m[k][t]$&lt;/span&gt; denote the minimum amount of storage required to store the first &lt;span class=&quot;math-container&quot;&gt;$k+1$&lt;/span&gt; snapshots, knowing that the last full backup happened at snapshot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We have:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$m[0][0] = s(0)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$m[i][i] = \min_{0\leq t \leq i-1}\{m[i-1][t]\}+p[i]$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;i\leq n-1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$m[i][t] = m[i-1][t] + (p[i]-p[t])$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$0\leq t&amp;lt;i \leq n-1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;These relations let you compute the whole matrix &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$O(n^2)$&lt;/span&gt; time. If you then let &lt;span class=&quot;math-container&quot;&gt;$m'[i] = \min_{0\leq t \leq i}\{m[i][t]\}$&lt;/span&gt; denote the minimum amount of storage required to store the first &lt;span class=&quot;math-container&quot;&gt;$i+1$&lt;/span&gt; snapshots for all &lt;span class=&quot;math-container&quot;&gt;$0\leq i \leq n-1$&lt;/span&gt;, the maximum number of snapshots you can store is one more than the maximum &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$m'[i]\leq C$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that you can also compute &lt;span class=&quot;math-container&quot;&gt;$m'$&lt;/span&gt; as you are computing &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; and stop whenever you find that &lt;span class=&quot;math-container&quot;&gt;$m'[i] &amp;gt; C$&lt;/span&gt;. You can also easily adapt this approach to handle deletes.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Now to actually find out when you should do a full backup and when you should do a differential backup, there are two main approaches (essentially doing the same thing). One involves storing some additional information while computing &lt;span class=&quot;math-container&quot;&gt;$m'$&lt;/span&gt;, the other a sort of backtracking to figure out which choices led to the values of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m'$&lt;/span&gt; we end up with.&lt;/p&gt;&#xA;&lt;p&gt;I prefer the former, and it goes like this:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$q[i]$&lt;/span&gt; denote the last time before &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; we have to do a full backup in order to do store the first &lt;span class=&quot;math-container&quot;&gt;$i+1$&lt;/span&gt; backups using &lt;span class=&quot;math-container&quot;&gt;$m'[i]$&lt;/span&gt; storage. In other words, &lt;span class=&quot;math-container&quot;&gt;$q[i]=t$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$0\leq t \leq i$&lt;/span&gt; is the value which minimizes &lt;span class=&quot;math-container&quot;&gt;$m[i][t]$&lt;/span&gt;. You can compute &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; while computing &lt;span class=&quot;math-container&quot;&gt;$m'$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;To store the &lt;span class=&quot;math-container&quot;&gt;$i+1$&lt;/span&gt; first snapshots with the least amount of storage, you need to do your last full backup at time &lt;span class=&quot;math-container&quot;&gt;$t=q[i]$&lt;/span&gt; and minimize the storage required for the first &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; snapshots. To minimize the storage of the first &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; snapshots you need to do your last full backup at time &lt;span class=&quot;math-container&quot;&gt;$t'=q[t-1]$&lt;/span&gt; and minimize the storage required for the first &lt;span class=&quot;math-container&quot;&gt;$t'$&lt;/span&gt; snapshots. To minimize the storage of the first &lt;span class=&quot;math-container&quot;&gt;$t'$&lt;/span&gt; snapshots you need to do your last full backup at time &lt;span class=&quot;math-container&quot;&gt;$t''=q[t'-1]$&lt;/span&gt;... And so on until you reach &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, where you have no choice but to do a full backup.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The values &lt;span class=&quot;math-container&quot;&gt;$t,t',t'',t'''\ldots$&lt;/span&gt; you will reach in this process tell you exactly when you have to do a full backup in order to store the first &lt;span class=&quot;math-container&quot;&gt;$i+1$&lt;/span&gt; snapshots using &lt;span class=&quot;math-container&quot;&gt;$m'[i]$&lt;/span&gt; storage (which is the minimum possible).&lt;/p&gt;&#xA;" OwnerUserId="5104" LastEditorUserId="5104" LastEditDate="2021-03-14T21:58:34.827" LastActivityDate="2021-03-14T21:58:34.827" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5877" PostTypeId="2" ParentId="5873" CreationDate="2021-03-08T10:29:55.877" Score="4" Body="&lt;p&gt;This answer focuses on the &amp;quot;papers that go into the details of implementation on a given optimization problem&amp;quot; part of the question.&lt;/p&gt;&#xA;&lt;p&gt;In &amp;quot;&lt;a href=&quot;https://doi.org/10.1016/S0966-8349(98)00030-8&quot; rel=&quot;nofollow noreferrer&quot;&gt;Variable neighborhood search for the &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median&lt;/a&gt;&amp;quot; by P. Hansen and N. Mladenovic, they go into quite some detail about how to efficiently implement an interchange heuristic originally proposed in &lt;a href=&quot;https://doi.org/10.1080/03155986.1983.11731889&quot; rel=&quot;nofollow noreferrer&quot;&gt;Whitaker (1983)&lt;/a&gt; for the &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-median problem. You have to go to the appendix of the paper by Hansen and Mladenocic to get the details of the implementation (no code, just pseudo-code).&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2021-03-09T10:15:56.567" LastActivityDate="2021-03-09T10:15:56.567" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5878" PostTypeId="1" AcceptedAnswerId="5883" CreationDate="2021-03-08T15:17:03.503" Score="0" ViewCount="496" Body="&lt;p&gt;I am looking for the most elegant solution to the following problem:&lt;/p&gt;&#xA;&lt;p&gt;I have an if-else query that depends on my optimization variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$a \leq b_i + x_i$&lt;/span&gt;, the parameter &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; should take the value of an parameter &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, otherwise it should be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I'm sure I need to solve this via constraints, but I don't know how to do it most cleverly.&lt;/p&gt;&#xA;" OwnerUserId="5092" LastEditorUserId="5092" LastEditDate="2021-03-10T07:28:27.117" LastActivityDate="2021-03-10T07:28:27.117" Title="if-else query depending on optimization variable in Gurobi (Java)" Tags="|optimization|gurobi|indicator-constraints|java|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="5880" PostTypeId="2" ParentId="5873" CreationDate="2021-03-08T22:44:47.707" Score="9" Body="&lt;p&gt;Below are some papers from Hexaly team members that detail local search approaches for diverse combinatorial optimization problems, with some focus on low-level implementation details:&lt;/p&gt;&#xA;&lt;p&gt;T. Benoist, B. Estellon, F. Gardi, A. Jeanjean (2011). Randomized local search for real-life inventory routing. Transportation Science 45(3), pp. 381-398. &lt;a href=&quot;https://www.fredericgardi.com/downloads/Benoist-Estellon-Gardi-Jeanjean_TRSC_09.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt; (extended version &lt;a href=&quot;https://www.fredericgardi.com/downloads/Benoist-Estellon-Gardi-Jeanjean_TRSC_09_extended.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;F. Gardi, K. Nouioua (2011). Local search for mixed-integer nonlinear optimization: a methodology and an application. In Proceedings of EvoCOP 2011, the 11th European Conference on Evolutionary Computation in Combinatorial Optimisation (P. Merz, J.-K. Hao, eds.), Lecture Notes in Computer Science 6622, pp. 167-178. Springer, Berlin, Germany. &lt;a href=&quot;https://www.fredericgardi.com/downloads/Gardi-Nouioua_EDF_EVOCOP_2011.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;B. Estellon, F. Gardi, K. Nouioua (2009). High-performance local search for task scheduling with human resource allocation. In Proceedings of SLS 2009, the 2nd International Workshop on Engineering Stochastic Local Search Algorithms (T. Stützle, M. Birattari, H.H. Hoos, eds.), Lecture Notes in Computer Science 5752, pp. 1-15. Springer, Berlin, Germany. &lt;a href=&quot;https://www.fredericgardi.com/downloads/Estellon-Gardi-Nouioua_SLS_09_Paper.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt; &lt;a href=&quot;https://www.fredericgardi.com/downloads/Estellon-Gardi-Nouioua_SLS_09_Presentation.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;B. Estellon, F. Gardi, K. Nouioua (2008). Two local search approaches for solving real-life car sequencing problems. In Special Issue: The Car Sequencing Problem (C. Solnon, V.D. Cung, A. Nguyen, C. Artigues, eds.), European Journal of Operational Research 191(3), pp. 928-944. &lt;a href=&quot;https://www.fredericgardi.com/downloads/Estellon-Gardi-Nouioua_EJOR_06.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;B. Estellon, F. Gardi, K. Nouioua (2006). Large neighborhood improvements for solving car sequencing problems. In Special Issue: Journées Francophones de Programmation par Contraintes 2005 (F. Fages, N. Jussien, C. Solnon, eds.), RAIRO Operations Research 40(4), pp. 355-379. &lt;a href=&quot;https://www.fredericgardi.com/downloads/Estellon-Gardi-Nouioua_RAIRO_06.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;These research works have inspired the development of Hexaly.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T05:25:36.077" LastActivityDate="2024-04-04T05:25:36.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5882" PostTypeId="1" AcceptedAnswerId="5895" CreationDate="2021-03-09T20:16:17.800" Score="1" ViewCount="256" Body="&lt;p&gt;This is a modified version of the algorithm that I have proposed &lt;a href=&quot;https://or.stackexchange.com/questions/3989/minimum-vertex-cover-and-linear-programming&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Suppose we have a graph &lt;strong&gt;G&lt;/strong&gt;. Consider the minimum vertex cover problem of &lt;strong&gt;G&lt;/strong&gt; formulated as a linear programming problem, that is for each vertex &lt;span class=&quot;math-container&quot;&gt;$v_{i}$&lt;/span&gt; we have the variable &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt;, for each edge &lt;span class=&quot;math-container&quot;&gt;$v_{i}v_{j}$&lt;/span&gt; we have the constraint &lt;span class=&quot;math-container&quot;&gt;$x_{i}+x_{j}\geq 1$&lt;/span&gt;, for each variable we have &lt;span class=&quot;math-container&quot;&gt;$0\leq x_{i}\leq 1$&lt;/span&gt; and we have the objective function &lt;span class=&quot;math-container&quot;&gt;$\min \sum\limits_{1}^{n}{x_{i}}$&lt;/span&gt;. We call such a linear programming problem &lt;em&gt;LP&lt;/em&gt;. Note that it is NOT an integer linear programming problem.&lt;/p&gt;&#xA;&lt;p&gt;Consider the following algorithm:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Find an optimal solution &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of &lt;em&gt;LP&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For each variable &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt;, one by one, add the constraint &lt;span class=&quot;math-container&quot;&gt;$x_{i}=0$&lt;/span&gt; to &lt;em&gt;LP&lt;/em&gt; and find a new optimal solution &lt;span class=&quot;math-container&quot;&gt;$S’$&lt;/span&gt;. If in &lt;span class=&quot;math-container&quot;&gt;$S’$&lt;/span&gt; the objective function is greater than in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, remove the constraint &lt;span class=&quot;math-container&quot;&gt;$x_{i}=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Find an optimal solution &lt;span class=&quot;math-container&quot;&gt;$S’’$&lt;/span&gt; of &lt;em&gt;LP&lt;/em&gt;. Remove all the vertices from &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; that take value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$S’’$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For each odd cycle &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;, add the constraint &lt;span class=&quot;math-container&quot;&gt;$x_{a}+x_{b}+x_{c}+...+x_{i}\geq \left\lfloor h+1 \right\rfloor$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_{a},x_{b},x_{c},...,x_{i}$&lt;/span&gt; are the vertices of the cycle and &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; is the sum of the values of the variables of &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$S’’$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If any constraints are added in the step 4., repeat from 2..&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The vertices whose variables take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$S’’$&lt;/span&gt; are a minimum vertex cover of the given &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The algorithm finds a vertex cover of the given graph, this is clear. The question is: does the algorithm find a minimum vertex cover of the given graph?&lt;/p&gt;&#xA;&lt;p&gt;The idea behind the algorithm is: in a graph without odd cycles, the optimal value of the objective function of &lt;em&gt;LP&lt;/em&gt; is the cardinality of the minimum vertex cover of the given graph (1). If there are any odd cycles, the optimal value of the objective can be less than the cardinality of the minimum vertex cover. For this reason, the algorithm increases the lower limit of the sum of the variables of each odd cycle of &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;, until all the variables take value in &lt;span class=&quot;math-container&quot;&gt;$\left\{0, 1\right\} $&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$S’’$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(1) G. L. Nemhauser and L. E. Trotter Jr. Properties of vertex packing and independence system polyhedra. Mathematical Programming, 6:48–61, 1974.&lt;/p&gt;&#xA;" OwnerUserId="3221" LastActivityDate="2021-03-11T07:42:48.447" Title="Minimum vertex cover and linear programming 2" Tags="|combinatorial-optimization|graphs|combinatorics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5883" PostTypeId="2" ParentId="5878" CreationDate="2021-03-09T20:49:32.340" Score="2" Body="&lt;p&gt;&amp;quot;&lt;em&gt;variable c (no optimization variable)&lt;/em&gt;&amp;quot; is not something that one can say in linear and (mixed) integer programming. There are decision variables and there are parameters (coefficients). That's it. There are no local variables as in computer programming. It is best to look at things as solving large sparse systems of linear equations.&lt;/p&gt;&#xA;&lt;p&gt;Now, Gurobi has one very useful feature: &lt;strong&gt;indicator constraints&lt;/strong&gt;. They take the form of implications with a binary variable on the left and a linear constraint on the right. We can use this to formulate: &amp;quot;&lt;em&gt;If &lt;span class=&quot;math-container&quot;&gt;$a\le b_i+x_i$&lt;/span&gt;, the variable c should take the value of a parameter z, otherwise it should be 0.&lt;/em&gt;&amp;quot; Well, more or less. As stated it looks wrong. What if for one &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; the constraint holds and for another it does not? So I will assume the problem is more like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned} &amp;amp; a\le b_i+x_i \Rightarrow c_i = z \\ &#xA;                &amp;amp; a\gt b_i+x_i \Rightarrow c_i = 0 \end{aligned}   &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As we cannot have strict inequalities, here is my suggestion to implement this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned} &#xA;&amp;amp; \delta_i = 1 \Rightarrow a\le b_i+x_i \\&#xA;&amp;amp; \delta_i = 0 \Rightarrow a\ge b_i+x_i+0.0001 \\&#xA;&amp;amp; c_i = z \cdot \delta_i\\&#xA;&amp;amp; \delta_i \in \{0,1\}&#xA; \end{aligned}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Again, the implications can be implemented in Gurobi in a straightforward manner using indicator constraints. &lt;span class=&quot;math-container&quot;&gt;$\delta_i$&lt;/span&gt; is an additional binary variable.&lt;/p&gt;&#xA;&lt;p&gt;In practice, I would drop the 0.0001 and keep the model a bit ambiguous in case of equality (the model can then pick the most profitable branch). If all quantities involved are integers, we can replace 0.0001 by 1.&lt;/p&gt;&#xA;&lt;p&gt;Instead of indicator constraints, it is also possible to use big-M constraints. They require a bit more care, as we need to worry about good bounds.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2021-03-09T22:56:48.950" LastActivityDate="2021-03-09T22:56:48.950" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5884" PostTypeId="1" CreationDate="2021-03-09T23:51:12.090" Score="3" ViewCount="335" Body="&lt;p&gt;I am using the Python &lt;code&gt;ortools&lt;/code&gt; to solve large LPs where the number of variables and constraints are in the hundred thousands (&lt;span class=&quot;math-container&quot;&gt;$10^5$&lt;/span&gt;). Surprisingly, it takes longer to initialize variables and declare constraints than to solve the actual LP:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&quot;text-align: left;&quot;&gt;Phase&lt;/th&gt;&#xA;&lt;th&gt;Average Time (secs)&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;Variable Initialization&lt;/td&gt;&#xA;&lt;td&gt;56.28&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;Constraint Initialization&lt;/td&gt;&#xA;&lt;td&gt;203.73&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;LP Solve&lt;/td&gt;&#xA;&lt;td&gt;116.34&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Is there a way to lower the time to initialize variables and constraints by batching them?&#xA;For my experiments, I solve many of these LPs, so any reduction in runtime would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5113" LastEditorUserId="123" LastEditDate="2021-11-20T14:56:05.943" LastActivityDate="2021-11-20T14:56:05.943" Title="Add Variables in Bulk for ortools" Tags="|python|or-tools|runtime|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5885" PostTypeId="1" CreationDate="2021-03-10T06:35:35.613" Score="12" ViewCount="863" Body="&lt;p&gt;Could someone suggest good blogs to follow for researchers in Operations Management/ Supply Chain Management /Operations Research?&lt;/p&gt;&#xA;" OwnerUserId="3499" LastActivityDate="2022-12-28T05:47:15.080" Title="Recommendations for OM blogs" Tags="|optimization|inventory|supply-chain|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5886" PostTypeId="2" ParentId="5885" CreationDate="2021-03-10T09:02:05.310" Score="15" Body="&lt;p&gt;Here is the list of blogs and social media that I regularly check [in no particular order]:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.zverovich.net/&quot; rel=&quot;noreferrer&quot;&gt;https://www.zverovich.net/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/&quot; rel=&quot;noreferrer&quot;&gt;https://yetanothermathprogrammingconsultant.blogspot.com/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://orinanobworld.blogspot.com/&quot; rel=&quot;noreferrer&quot;&gt;https://orinanobworld.blogspot.com/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://erlingdandersen.blogspot.com/&quot; rel=&quot;noreferrer&quot;&gt;http://erlingdandersen.blogspot.com/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://punkrockor.com/&quot; rel=&quot;noreferrer&quot;&gt;https://punkrockor.com/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://lemire.me/blog/&quot; rel=&quot;noreferrer&quot;&gt;https://lemire.me/blog/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://nathanbrixius.wordpress.com/&quot; rel=&quot;noreferrer&quot;&gt;https://nathanbrixius.wordpress.com/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://themosekblog.blogspot.com/&quot; rel=&quot;noreferrer&quot;&gt;https://themosekblog.blogspot.com/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://annanagurney.blogspot.com/&quot; rel=&quot;noreferrer&quot;&gt;https://annanagurney.blogspot.com/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.optimisationintherealworld.co.uk/blog/&quot; rel=&quot;noreferrer&quot;&gt;http://www.optimisationintherealworld.co.uk/blog/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://fa.bianp.net/&quot; rel=&quot;noreferrer&quot;&gt;http://fa.bianp.net/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://thiagoserra.com/blog/&quot; rel=&quot;noreferrer&quot;&gt;https://thiagoserra.com/blog/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://blogs.princeton.edu/imabandit/&quot; rel=&quot;noreferrer&quot;&gt;https://blogs.princeton.edu/imabandit/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://towardsdatascience.com/&quot; rel=&quot;noreferrer&quot;&gt;https://towardsdatascience.com/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://medium.com/opex-analytics&quot; rel=&quot;noreferrer&quot;&gt;https://medium.com/opex-analytics&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://stegua.github.io/&quot; rel=&quot;noreferrer&quot;&gt;http://stegua.github.io/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://matthewcrews.com/&quot; rel=&quot;noreferrer&quot;&gt;http://matthewcrews.com/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://optano.com/en/blog/&quot; rel=&quot;noreferrer&quot;&gt;https://optano.com/en/blog/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://francisbach.com/&quot; rel=&quot;noreferrer&quot;&gt;https://francisbach.com/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://mluebbecke.wordpress.com/&quot; rel=&quot;noreferrer&quot;&gt;https://mluebbecke.wordpress.com/&lt;/a&gt; [in German]&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gurobi.com/resources/?category-filter=blog&quot; rel=&quot;noreferrer&quot;&gt;https://www.gurobi.com/resources/?category-filter=blog&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="133" LastEditorUserId="133" LastEditDate="2021-03-10T09:15:15.517" LastActivityDate="2021-03-10T09:15:15.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5887" PostTypeId="1" CreationDate="2021-03-10T17:19:02.843" Score="0" ViewCount="64" Body="&lt;p&gt;How can I create a linear equation in Gurobi (Java) from values (x-y value pairs) that also has the following properties:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall x \leq 0 \Longrightarrow y = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The linear line/equation should have its starting point at the x/y value, from which &lt;span class=&quot;math-container&quot;&gt;$y \geq 0$&lt;/span&gt; and is monotonously increasing and should go maximally up to a point, at which y takes the value &lt;span class=&quot;math-container&quot;&gt;$\geq 1$&lt;/span&gt; for the first time.  All values below this point shall be &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, and all values above this point shall be &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As a small example I have attached a table: The linear equation should have its starting point at &lt;span class=&quot;math-container&quot;&gt;$x = 10$&lt;/span&gt; and its end point at &lt;span class=&quot;math-container&quot;&gt;$x = 40$&lt;/span&gt;. For &lt;span class=&quot;math-container&quot;&gt;$x = 0, -10 \Longrightarrow y = 0$&lt;/span&gt; and for &lt;span class=&quot;math-container&quot;&gt;$x = 40, 50 \Longrightarrow y=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Since the values change, again and again, the whole should, of course, be generally formulated.&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;x&lt;/th&gt;&#xA;&lt;th&gt;y&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;-10&lt;/td&gt;&#xA;&lt;td&gt;0.1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0.1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;10&lt;/td&gt;&#xA;&lt;td&gt;0.2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;20&lt;/td&gt;&#xA;&lt;td&gt;0.3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;30&lt;/td&gt;&#xA;&lt;td&gt;0.5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;40&lt;/td&gt;&#xA;&lt;td&gt;1.1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;50&lt;/td&gt;&#xA;&lt;td&gt;1.3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;" OwnerUserId="5092" LastEditorUserId="5092" LastEditDate="2021-03-11T12:09:30.353" LastActivityDate="2021-03-11T12:09:30.353" Title="Linear equation from pairs of values with conditions in Gurobi (Java)" Tags="|optimization|linear-programming|gurobi|java|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5889" PostTypeId="1" AcceptedAnswerId="5911" CreationDate="2021-03-10T21:56:12.277" Score="1" ViewCount="664" Body="&lt;p&gt;I have an objective function as follows&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\underset{x_{m,n}}{\max}\hspace{1mm}\hspace{1mm}\sum_{m=1}^{M}\log_2\left(\frac{\sum_{n=1}^{N}(1-x_{m,n})\omega_{m,n}+z}{\sum_{n=1}^{N}x_{m,n}\omega_{m,n}}\right)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$x_{m,n}$&lt;/span&gt; are optimization variables which are binary.&lt;/p&gt;&#xA;&lt;p&gt;How can I transform this objective into a linear/convex function?&lt;/p&gt;&#xA;&lt;p&gt;Thoughts:&lt;/p&gt;&#xA;&lt;p&gt;Due to monotonicity of the logarithmic function, as well making use of logarithm rule for multiplicative terms, we can transform the problem as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\underset{x_{m,n}, t_m,\beta_m }{\max}\hspace{1mm}\hspace{1mm}\prod_{m=1}^{M}t_m$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Consequently, the following constraints will be added to the system.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{n=1}^{N}(1-x_{m,n})\omega_{m,n}+z\ge t_m\beta_m$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta_m\ge \sum_{n=1}^{N}x_{m,n}\omega_{m,n}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Am I doing it right?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \text{What are the steps forward?}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bf \text{EDIT:}$&lt;/span&gt; (According to Johan Löfberg's answer )&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\underset{x_{m,n}, y_{m,n},z_{m,n}}{\max}\hspace{1mm}\hspace{1mm}\sum_{m=1}^{M}\log_2\left(y_{m}\right)$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2021-03-12T13:05:57.157" LastActivityDate="2021-03-12T14:20:38.797" Title="How to transform this problem with logarithmic objective function into an approximated convex optimization problem?" Tags="|mixed-integer-programming|linear-programming|linearization|convex-optimization|disciplined-convex-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5890" PostTypeId="2" ParentId="5885" CreationDate="2021-03-10T22:10:21.180" Score="7" Body="&lt;p&gt;For OM, you might like &lt;a href=&quot;https://heizerrenderom.wordpress.com/&quot; rel=&quot;noreferrer&quot;&gt;Jay, Barry and Chuck's OM Blog&lt;/a&gt;.&#xA;For OR, I like &lt;a href=&quot;https://orindevon.blogspot.com/&quot; rel=&quot;noreferrer&quot;&gt;OR in Devon, UK&lt;/a&gt; as well as many of the entries in Richard's excellent answer. I had a few other OR blogs that I liked, but sadly their owners appear to have stopped posting.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-03-10T22:10:21.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5892" PostTypeId="1" CreationDate="2021-03-10T23:42:58.153" Score="0" ViewCount="171" Body="&lt;p&gt;I have a constraint in the form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{n=1}^{N}x_{m,n}\omega_{m,n}\ge (t_u-1)\beta_u, \forall u, u=1,2,\cdots, U$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x_{m,n}$&lt;/span&gt; is binary variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta_u$&lt;/span&gt; are continuous optimization variables.&lt;/p&gt;&#xA;&lt;p&gt;How can I linearise this constraint?&lt;/p&gt;&#xA;" OwnerUserId="836" LastActivityDate="2021-03-11T20:32:05.570" Title="How to linearise this nonlinear constraint?" Tags="|mixed-integer-programming|linear-programming|nonlinear-programming|linearization|convex-optimization|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5894" PostTypeId="1" CreationDate="2021-03-11T07:39:10.833" Score="4" ViewCount="410" Body="&lt;p&gt;&lt;sub&gt;&lt;strong&gt;Note:&lt;/strong&gt; Initially &lt;a href=&quot;https://mathoverflow.net/q/385971&quot;&gt;posted&lt;/a&gt; on MathOverflow.&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I am working on an optimization problem where some of the terms of the objective function to maximize are expressed as a piecewise linear function of variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ z =  \begin{cases} &#xA;      c^- x, &amp;amp; x \leq 0 \\&#xA;      c^+ x, &amp;amp; x    &amp;gt; 0 \\&#xA;   \end{cases} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;as depicted below&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://wbo.ophir.dev/boards/Nd39jocBDSAJ54Vd1HqGxiaeoHt2S4segM12tQqzFx0&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BO5J9.png&quot; alt=&quot;objective function plot&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;When I have &lt;span class=&quot;math-container&quot;&gt;$c^- \geq c^+$&lt;/span&gt;, I can solve the problem by adding a new variable &lt;span class=&quot;math-container&quot;&gt;$x'$&lt;/span&gt;, and two constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x' \leq c^- x $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x' \leq c^+ x $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;But what do I do when &lt;span class=&quot;math-container&quot;&gt;$c^- &amp;lt; c^+$&lt;/span&gt; ? I don't think there is a way to express the problem as a linear  programming problem in that case, is there ?&lt;/p&gt;&#xA;&lt;p&gt;I have heard about &lt;a href=&quot;https://en.wikipedia.org/wiki/Special_ordered_set&quot; rel=&quot;nofollow noreferrer&quot;&gt;SOS constraints&lt;/a&gt;. Are they the canonical way to solve this kind of problem ? If my problem contains many such piecewise linear functions, is it reasonable to expect a solver from being able to solve such a problem with thousands of SOS1 constraints ?&lt;/p&gt;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{ll} \text{maximize} &amp;amp; a \max(x,0) + b \min(x,0) + c \max(y,0) + d \min(y,0)\\ \text{subject to} &amp;amp; x,y \in [−1,1]\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5117" LastEditorUserId="8" LastEditDate="2021-03-11T07:50:44.340" LastActivityDate="2021-03-11T09:05:28.540" Title="Maximizing a piecewise-linear convex function" Tags="|solver|constraint|linearization|nonconvex-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5895" PostTypeId="2" ParentId="5882" CreationDate="2021-03-11T07:42:48.447" Score="2" Body="&lt;p&gt;I am pretty sure the answer is again &lt;strong&gt;NO&lt;/strong&gt;. And it can be seen with the same graph as in the previous question &lt;a href=&quot;https://or.stackexchange.com/a/5276/4477&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Consider the graph consisting of a &lt;span class=&quot;math-container&quot;&gt;$K_5$&lt;/span&gt; (the fully connected graph with 5 nodes) and two additional nodes &lt;span class=&quot;math-container&quot;&gt;$r_1, r_2$&lt;/span&gt; that have an edge to each of the nodes in the &lt;span class=&quot;math-container&quot;&gt;$K_5$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/049jn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/049jn.png&quot; alt=&quot;counter example graph&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;First note that if we force any of the nodes &lt;span class=&quot;math-container&quot;&gt;$r_1, r_2$&lt;/span&gt; to take value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; in any of the LP formulations all the nodes in &lt;span class=&quot;math-container&quot;&gt;$K_5$&lt;/span&gt; have to take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in order to cover all the edges from &lt;span class=&quot;math-container&quot;&gt;$K_5$&lt;/span&gt; to the respective &lt;span class=&quot;math-container&quot;&gt;$r_1, r_2$&lt;/span&gt;. Thus an optimal LP solution would at least take value &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;. Furthermore if we force any of the nodes in &lt;span class=&quot;math-container&quot;&gt;$K_5$&lt;/span&gt; to take value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; then all the other nodes have to take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, as each node in &lt;span class=&quot;math-container&quot;&gt;$K_5$&lt;/span&gt; is connected to all other nodes and these edges have to be covered. Thus an optimal LP solution would at least take value &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As was shown in the original &lt;a href=&quot;https://or.stackexchange.com/a/5276/4477&quot;&gt;answer&lt;/a&gt; the first optimal LP solution we find gives all nodes value &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2}$&lt;/span&gt;. As seen above step 2 will not add any additional constraints and step 3 will not remove anything. Then the constraints added in step 4 are exactly the ones from the &lt;a href=&quot;https://or.stackexchange.com/q/3989/4477&quot;&gt;previous question&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So as shown in the original answer the next optimal solution found will assign all nodes value &lt;span class=&quot;math-container&quot;&gt;$\frac{2}{3}$&lt;/span&gt;. Again with the argument from above step 2 and 3 will not do anything. Now step 4 will add constraints that will force all cycles of length &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; to take at least value &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As each node is contained in a cycle of length &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; this implies that the next solution found has to take all vertices with value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. Now forcing any of the nodes to value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; will make the solution illegal, as the respective new cycle constraints are violated. Thus the algorithm terminates with a solution that has value &lt;span class=&quot;math-container&quot;&gt;$7$&lt;/span&gt;, where the optimal solution would be &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4477" LastActivityDate="2021-03-11T07:42:48.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5896" PostTypeId="1" AcceptedAnswerId="5901" CreationDate="2021-03-11T08:16:02.980" Score="2" ViewCount="139" Body="&lt;p&gt;I have a scheduling problem in which machines consume their battery when executing tasks and charge their battery when not executing tasks. A single task has to be executed in one go (no recharging pauses). Battery consumption/charging happens at a fixed rate. Tasks have a fixed interval and the goal is to maximize the number of executed tasks.&lt;/p&gt;&#xA;&lt;p&gt;I'm want to model this problem with constraint programming, in which I have basic knowledge. The problem is that no scheduling examples that I have encountered have tasks that alter the state of the executing machine (which determines when that machine can accept a subsequent task).&lt;/p&gt;&#xA;&lt;p&gt;How would one model such a problem (specifically the consumption/charging part)? Is it suitable for constraint programming at all?&lt;/p&gt;&#xA;" OwnerUserId="5119" LastActivityDate="2021-03-12T12:40:42.150" Title="Scheduling: Tasks changing the state of the executing machine" Tags="|scheduling|constraint-programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5897" PostTypeId="2" ParentId="5894" CreationDate="2021-03-11T09:05:28.540" Score="3" Body="&lt;p&gt;within CPLEX you can use piecewise linear function in the objective with all APIs.&lt;/p&gt;&#xA;&lt;p&gt;Let me show how to do that in OPL. Let me use the example from &lt;a href=&quot;https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Making Optimization Simple&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/AlexFleischerParis/zooopl/blob/master/zoopiecewise.mod&quot; rel=&quot;nofollow noreferrer&quot;&gt;Piecewise linear function&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;let s now deal with a new information : for a given bus size if we take more than 4 then we get a 20% discount.&#xA;This moves our function cost from linear to piecewise linear. Let's have a look at how to deal with this in OPL.&#xA; &#xA;We would then write:&#xA;*/&#xA;&#xA;&#xA;&#xA;int nbKids=300;&#xA;float costBus40=500;&#xA;float costBus30=400;&#xA;&#xA;// If we take more than 4 buses for a given size, 20% cheaper for additional buses&#xA; &#xA;dvar int+ nbBus40;&#xA;dvar int+ nbBus30;&#xA;&#xA;pwlFunction pricePerQuantity=piecewise{1-&amp;gt;4;0.8};&#xA;&#xA;assert forall(k in 1..4 ) pricePerQuantity(k)==k;&#xA;assert forall(k in 5..10) as:abs(pricePerQuantity(k)-4-(k-4)*0.8)&amp;lt;=0.00001;&#xA; &#xA;minimize&#xA; costBus40*pricePerQuantity(nbBus40)  +pricePerQuantity(nbBus30)*costBus30;&#xA; &#xA;subject to&#xA;{&#xA; 40*nbBus40+nbBus30*30&amp;gt;=nbKids;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;NB: I am an IBMer&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-03-11T09:05:28.540" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5898" PostTypeId="1" AcceptedAnswerId="5900" CreationDate="2021-03-11T12:04:20.057" Score="4" ViewCount="607" Body="&lt;p&gt;OR-Software is mostly available for LINUX.&lt;/p&gt;&#xA;&lt;p&gt;Linux comes in different distributions, which are managed differently, so the question is:&lt;/p&gt;&#xA;&lt;p&gt;Is there a LINUX distribution that should be preferred, when using/developing OR Software?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2021-03-11T12:46:05.213" Title="OR Software on Linux" Tags="|solver|software|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5899" PostTypeId="2" ParentId="5898" CreationDate="2021-03-11T12:33:56.147" Score="3" Body="&lt;p&gt;When you develop software, based on &lt;a href=&quot;https://superuser.com/a/117945&quot;&gt;this&lt;/a&gt; answer, as long as you provide the libraries (lib files) and set the LD_LIBRARY_PATH accordingly, there are no differences between the different distributions.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-03-11T12:33:56.147" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5900" PostTypeId="2" ParentId="5898" CreationDate="2021-03-11T12:34:34.217" Score="4" Body="&lt;p&gt;I don't think it matters much if you pick one the big ones (Fedora, RHEL, Ubuntu, Debian, Suse, etc), so its app repository has all the important apps (openjdk, maven, gcc, python, docker, ruby, ...). So &lt;code&gt;sudo dnf install &amp;lt;app&amp;gt;&lt;/code&gt; or &lt;code&gt;sudo apt-get install &amp;lt;app&amp;gt;&lt;/code&gt; should just work.&lt;/p&gt;&#xA;&lt;p&gt;For &lt;a href=&quot;https://www.optaplanner.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner&lt;/a&gt; development, my entire team is on Fedora Linux, which shouldn't be a big surprise as we all work for Red Hat. Our open source contributors do use all kind of OS's and I can't recall any issues with those that use Ubuntu, Debian, etc. Less issues than those using Mac (.DS_Store) and far, far less than those using Windows (line endings (&lt;code&gt;.gitattributes&lt;/code&gt; is a life saver), path separators, and of course the &lt;a href=&quot;https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation&quot; rel=&quot;nofollow noreferrer&quot;&gt;260 path limit which can burn in hell&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Benchmarks do show that OptaPlanner (100% pure java) is significantly faster on Linux than on Windows, but that too is no big surprise, as I've seen that on many other Java applications too - I can't speak for non-java apps.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2021-03-11T12:46:05.213" LastActivityDate="2021-03-11T12:46:05.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5901" PostTypeId="2" ParentId="5896" CreationDate="2021-03-11T12:54:02.907" Score="3" Body="&lt;p&gt;In OptaPlanner, I'd start from the &lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/master/optaplanner-examples/src/main/java/org/optaplanner/examples/taskassigning&quot; rel=&quot;nofollow noreferrer&quot;&gt;task assigning example&lt;/a&gt; and use &lt;a href=&quot;https://youtu.be/ENKHGBMDaCM&quot; rel=&quot;nofollow noreferrer&quot;&gt;a shadow variable&lt;/a&gt; to track the remaining battery level of every task. Then a simple constraint can check if it's ok to schedule that task on that machine:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from(Task.class)&#xA;.filter(task -&amp;gt; task.getRemainingBatteryLevel() &amp;lt; task.getRequiredBatteryLevel())&#xA;.penalize(&amp;quot;Battery&amp;quot;, ofHard(1));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-03-11T12:54:02.907" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5902" PostTypeId="2" ParentId="5885" CreationDate="2021-03-11T12:57:31.370" Score="6" Body="&lt;p&gt;Our blog might be useful too:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.optaplanner.org/blog/&quot; rel=&quot;noreferrer&quot;&gt;https://www.optaplanner.org/blog/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;We cover OR use cases (just did an article on &lt;a href=&quot;https://www.optaplanner.org/blog/2021/03/04/OptimizingCovid19VaccinationScheduling.html&quot; rel=&quot;noreferrer&quot;&gt;Covid Appointment Scheduling&lt;/a&gt;), our technology and general insights.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-03-11T12:57:31.370" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5903" PostTypeId="1" CreationDate="2021-03-11T13:28:09.887" Score="0" ViewCount="67" Body="&lt;p&gt;I have a model which delivers the following results (other combinations are also possible, all Xs have 50 as an upper bound):&lt;/p&gt;&#xA;&lt;p&gt;Case I&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X1 = 50.0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X2 = 13.750$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X3 = 50.0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X4 = 50.0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Case II (obtained adding valid constraints to the model)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X1 = 50.0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X2 = 47.50$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X3 = 50.0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X4 = 16.25$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Both results lead to the same value of the objective function. Both solutions are optimal.&lt;/p&gt;&#xA;&lt;p&gt;The variables express how a certain resource j is loaded in time.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to model that the resource is loaded with maximum possible amount in earlier times, whenever possible?&lt;/p&gt;&#xA;&lt;p&gt;So here, I would like that Case II is prefered over Case I. Case I should be declared infeasible.&lt;/p&gt;&#xA;&lt;p&gt;EDIT&lt;/p&gt;&#xA;&lt;p&gt;I think we could reach the goal by introducing penalties in the objective function as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max  f(X_1,X_2,X_3,X_4) - \delta_1 (50-X_1) - \delta_2 (50-X_2) - \delta_3 (50-X_3) - \delta_4 (50-X_4)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now the question is, what is a good choice for the &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt;s so that the optimal value for &lt;span class=&quot;math-container&quot;&gt;$f(X_1,X_2,X_3,X_4)$&lt;/span&gt; is the same when optimising with and without the penalties.&lt;/p&gt;&#xA;&lt;p&gt;We know that we should not use the same value for the penalties, but when are they too high, meaning, that they alter the value of &lt;span class=&quot;math-container&quot;&gt;$f(X_1,X_2,X_3,X_4)$&lt;/span&gt; of the optimum when optimising without the penalties?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="1269" LastEditDate="2021-03-11T19:00:25.477" LastActivityDate="2021-03-11T19:00:25.477" Title="Excluding non-preferable solutions from a MILP" Tags="|modeling|symmetry|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5904" PostTypeId="2" ParentId="5873" CreationDate="2021-03-11T14:09:51.997" Score="2" Body="&lt;p&gt;For what it's worth, here you can download our paper on &lt;a href=&quot;https://www.researchgate.net/publication/344299245_Multithreaded_incremental_solving_for_local_search_based_metaheuristics_with_step_chasing&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multithreaded Incremental Solving for Local Search&lt;/a&gt; (not to be confused with multi-walk solving (AKA multi-bet solving), multi-tentant solving or multithreaded partitioned solving), which made our Local Search algorithms up to 3 times faster on 4 cores.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-03-11T14:09:51.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5905" PostTypeId="1" CreationDate="2021-03-11T16:17:29.753" Score="0" ViewCount="204" Body="&lt;p&gt;I'm dealing with a kind of assignment problem, in which I have a set of tasks &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; to be executed by machines &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, but these tasks depend on the variatns &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; of components &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; being selected, which is stated by decision variable &lt;span class=&quot;math-container&quot;&gt;$Y_{mv}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would like to ensure that all selected components will satisfy a set of requirements when creating a given product composed of many components. Besides that, I would like to ensure that all the selected components' tasks will be fulfilled somewhere in a process plan.&lt;/p&gt;&#xA;&lt;p&gt;Considering the following parameters:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$F = 1, 3, 4,...$&lt;/span&gt; be the set of requirements to be satisfied.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$M = 1, 2, 3,...$&lt;/span&gt; be the set of components that can appear in a product.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$V_{M} = 1, 2, 3, ...$&lt;/span&gt; be the set of variants &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; of a given component &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$T = 1, 2, 3, ...$&lt;/span&gt; be the set of available tasks&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$R_{mvt}=1$&lt;/span&gt; a parameter that states if variant &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; of component &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; requires task &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$S_{mvf}=1$&lt;/span&gt; a parameter that states if variant &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; of component &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; satisfies the requirement &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise&lt;/p&gt;&#xA;&lt;p&gt;Considering the following decision variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{twj}=1$&lt;/span&gt; if task &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is performed by machine &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; in process plan position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Y_{mv}=1$&lt;/span&gt; if variant &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; of component &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is selected in the product, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise&lt;/p&gt;&#xA;&lt;p&gt;My objectives are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ensuring that, besides all available tasks, only the tasks required by the selected variants &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; of components &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; will be performed (first equation)&lt;/li&gt;&#xA;&lt;li&gt;Ensuring that all requirements will be satisfied by the selected variants &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; of components &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; (second equation)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\sum_{m} \sum_{v} Y_{mv}*S_{mvf} &amp;amp;= 1 &amp;amp; \forall f in F\\&#xA;\sum_{m} \sum_{v} Y_{mv}*R_{mvt} &amp;amp;= \sum_{t} \sum_{w}  \sum_{j}X_{twj} \\&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How to state a constraint to ensure that only the required tasks will be executed?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: I am using cplex, and when I run the code using the constraints above, it does not return any result (model is infeasible as suggested by @Alex Fleischer).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;AttributeError: 'NoneType' object has no attribute 'get_objective_value'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I suppose that the constraints are not well established, but I still have not identified where the problem is. Could someone help with this trouble?&lt;/p&gt;&#xA;" OwnerUserId="2453" LastEditorUserId="123" LastEditDate="2021-03-12T15:40:41.487" LastActivityDate="2021-03-12T15:40:41.487" Title="Assignment problem with variable tasks to be done" Tags="|mixed-integer-programming|modeling|integer-programming|cplex|docplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5906" PostTypeId="1" AcceptedAnswerId="5908" CreationDate="2021-03-11T16:47:07.827" Score="5" ViewCount="571" Body="&lt;p&gt;I have the following problem:&lt;/p&gt;&#xA;&lt;p&gt;I have an objective function with the optimization variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, which looks simplified like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ZF = (a+b)*(x+1)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is simply a constant value.&#xA;However, behind &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a 4th degree polynomial which is dependent on my optimization variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now my idea was to create a constraint with &lt;code&gt;GRBModel.addGenConstrPoly()&lt;/code&gt;, where &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is then also an optimization variable.&lt;/p&gt;&#xA;&lt;p&gt;When I do that, I get the following error code back:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;Error code: 10020. Objective Q not PSD (diagonal adjustment of 6.5e+06 would be required). Set NonConvex parameter to 2 to solve model.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Maybe I am thinking completely wrong and someone can help me how I can enter my polynomial differently.&lt;/p&gt;&#xA;" OwnerUserId="5092" LastEditorUserId="491" LastEditDate="2021-03-11T20:30:21.733" LastActivityDate="2021-03-11T20:30:21.733" Title="how to implement an optimization function with polynomial in Gurobi (Java)" Tags="|optimization|nonlinear-programming|gurobi|nonconvex-programming|java|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5908" PostTypeId="2" ParentId="5906" CreationDate="2021-03-11T19:13:01.747" Score="8" Body="&lt;p&gt;This can be handled by &lt;strong&gt;transforming this to a bilinear problem&lt;/strong&gt;, i.e., a problem only involving products of no more than 2 variables at a time.&lt;/p&gt;&#xA;&lt;p&gt;This is accomplished by &lt;strong&gt;lifting the problem into a higher dimension&lt;/strong&gt;, i.e., by introducing new variables and corresponding constraints.&lt;/p&gt;&#xA;&lt;p&gt;For instance, the term &lt;span class=&quot;math-container&quot;&gt;$x^3$&lt;/span&gt; can be made bilinear (quadratic), by introducing a new variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, adding the constraint &lt;span class=&quot;math-container&quot;&gt;$y=x^2$&lt;/span&gt;, and rewriting &lt;span class=&quot;math-container&quot;&gt;$x^3$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$xy$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let's say you have a term &lt;span class=&quot;math-container&quot;&gt;$x^2w$&lt;/span&gt;. Introduce a new variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, add the constraint &lt;span class=&quot;math-container&quot;&gt;$z=xw$&lt;/span&gt;, and rewrite &lt;span class=&quot;math-container&quot;&gt;$x^2w$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$xz$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This can be extended to an arbitrary polynomial in any degree and number of variables, resulting in a bilinear formulation, which can be solved to global optimality (run time and memory permitting) by Gurobi 9.x. You will need to set the  NonConvex parameter appropriately to handle a non-convex bilinear model.&lt;/p&gt;&#xA;&lt;p&gt;Gurtobi 9.1 does not automate this for polynomials &amp;quot;above&amp;quot; bilinear (quadratic). Perhaps some future version might. Some optimization modeling systems actually do automate this; for instance, YALMIP automatically reformulates polynomial matrix inequalities as Bilinear Matrix Inequalities (BMI) by lifting (adding new variables and constraints).&lt;/p&gt;&#xA;&lt;p&gt;This lifting approach is discussed at greater length in the context of linear matrix inequalities in &lt;a href=&quot;https://arxiv.org/pdf/1309.3112.pdf&quot; rel=&quot;noreferrer&quot;&gt;Optimization on linear matrix inequalities for polynomial systems control&lt;/a&gt;. The general idea is the same for polynomial optimization.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2021-03-11T20:08:20.700" LastActivityDate="2021-03-11T20:08:20.700" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="5909" PostTypeId="2" ParentId="5892" CreationDate="2021-03-11T20:32:05.570" Score="2" Body="&lt;p&gt;To bound the variables (preparatory to McCormick relaxation), you can maximize (and then minimize) each &lt;span class=&quot;math-container&quot;&gt;$t_u$&lt;/span&gt; and each &lt;span class=&quot;math-container&quot;&gt;$\beta_u$&lt;/span&gt; individually, subject to all the linear constraints of the original model (ignoring the nonlinear constraint). Hopefully those problems are all bounded.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-03-11T20:32:05.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5910" PostTypeId="1" CreationDate="2021-03-11T21:58:19.950" Score="1" ViewCount="205" Body="&lt;p&gt;Since the introduction of the Clubhouse app, there are several groups on different topics and people can talk about specific topics in different fields. Is there any group related to &amp;quot;Operations Research&amp;quot; in Clubhouse?&#xA;I would be thankful if well-known researchers and scholars in the forum can make a group In CH.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="68" LastEditDate="2021-03-12T12:57:10.490" LastActivityDate="2021-06-01T12:08:31.310" Title="Is there any Operations Research group in Clubhouse?" Tags="|optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5911" PostTypeId="2" ParentId="5889" CreationDate="2021-03-12T06:08:34.393" Score="3" Body="&lt;p&gt;Introduce a term &lt;span class=&quot;math-container&quot;&gt;$y_m$&lt;/span&gt; to replace and lower bound the terms inside the logarithm.&lt;/p&gt;&#xA;&lt;p&gt;Those lower bound constraints simplify to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{n=1}^{N}(1-x_{m,n})\omega_{m,n}+z\ge y_m(\sum_{n=1}^{N}x_{m,n}\omega_{m,n})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The only problem here are the bilinear terms &lt;span class=&quot;math-container&quot;&gt;$y_m x_{m,n}$&lt;/span&gt;. Since &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is binary this is linearly representable by introducing a new variable &lt;span class=&quot;math-container&quot;&gt;$z_{m,n}$&lt;/span&gt; to replace the product and model the product via standard big-M &lt;span class=&quot;math-container&quot;&gt;$0 \leq z_{m,n} \leq M x_{m,n},0 \leq z_{m,n}-y_{m} \leq M (1-x_{m,n})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;At this point your constraints are linear and the objective is concave hence a mixed-integer convex program. Any mixed-integer nonlinear solver should work, but it is not only convex but exponential cone representable so the specialized solver Mosek will be applicable.&lt;/p&gt;&#xA;" OwnerUserId="487" LastEditorUserId="487" LastEditDate="2021-03-12T14:20:38.797" LastActivityDate="2021-03-12T14:20:38.797" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5912" PostTypeId="2" ParentId="5896" CreationDate="2021-03-12T07:56:59.343" Score="2" Body="&lt;p&gt;In CP Optimizer, I would use &amp;quot;typeOfPrev/Next&amp;quot; expressions to track the level of the battery at the endpoints (start and end) of the activities on the resource.&lt;/p&gt;&#xA;&lt;p&gt;Here is a simple example on just one machine (in OPL but you can write the same model in Java, Python or C++). I assumed the battery consumption/production rate is 1. Activities are optional, have specific time-windows and the objective is to maximize the number of executed activities:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int N = 1000; // Number of activities&#xA;int C = 100;  // Battery capacity&#xA;int H = 30*N;&#xA;&#xA;// Random data&#xA;execute {&#xA;  Opl.srand(1);&#xA;}&#xA;int D[i in 1..N] = 1+rand(50);&#xA;int S[i in 1..N] = rand(H - (H div 10));&#xA;int E[i in 1..N] = S[i]+D[i]+rand(H div 10);&#xA;&#xA;dvar interval x[i in 1..N] optional in S[i]..E[i] size D[i]; // Optional activities x[i]&#xA;dvar int le[i in 0..N] in 0..C; // Battery level at the end of x[i]&#xA;&#xA;dvar sequence seq in all(i in 1..N) x[i] types all(i in 1..N) i; // sequence of activities on the machine&#xA;&#xA;execute {&#xA;  var f = cp.factory;&#xA;  cp.setSearchPhases(f.searchPhase(seq)); &#xA;}&#xA;&#xA;maximize sum(i in 1..N) presenceOf(x[i]);&#xA;subject to {&#xA;  noOverlap(seq);&#xA;  le[0]==0;&#xA;  forall (i in 1..N) {&#xA;    le[i] == minl(C, le[typeOfPrev(seq,x[i],0)] + (startOf(x[i],D[i])-endOfPrev(seq,x[i],0)))-D[i];&#xA;    // When x[i] is absent, by the above constraint: le[i]=0&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that on this type of problem, it can be useful to use search phases on the sequence variables so that the default search will work on sequencing the interval variables of the sequences before fixing their actual start/end values.&lt;/p&gt;&#xA;&lt;p&gt;Of course, I suppose that your problem is more complex and these batteries must be integrated in a more complex scheduling problem. So in order to be more realistic, I tried for fun to add these battery constraints on all the machines of a &amp;quot;classical&amp;quot; job-shop scheduling problem. The only change is to add the 'le' variables on each operation on the machines. On this tiny instance, CP Optimizer proves optimality of the solution (with makespan 79).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int nbJobs = 6;&#xA;int nbMchs = 6;&#xA;&#xA;range Jobs = 1..nbJobs;&#xA;range Mchs = 1..nbMchs; &#xA;// Mchs is used both to index machines and operation position in job&#xA;&#xA;tuple Operation {&#xA;  int mch; // Machine&#xA;  int pt;  // Processing time&#xA;};&#xA;&#xA;Operation Ops[Jobs][Mchs] = [&#xA; [ &amp;lt;6,4&amp;gt;, &amp;lt;2,3&amp;gt;, &amp;lt;5,3&amp;gt;, &amp;lt;4,2&amp;gt;, &amp;lt;1,1&amp;gt;, &amp;lt;3,2&amp;gt; ],&#xA; [ &amp;lt;2,3&amp;gt;, &amp;lt;1,8&amp;gt;, &amp;lt;6,7&amp;gt;, &amp;lt;3,2&amp;gt;, &amp;lt;5,9&amp;gt;, &amp;lt;4,3&amp;gt; ],&#xA; [ &amp;lt;4,1&amp;gt;, &amp;lt;5,9&amp;gt;, &amp;lt;2,9&amp;gt;, &amp;lt;1,7&amp;gt;, &amp;lt;6,5&amp;gt;, &amp;lt;3,5&amp;gt; ],&#xA; [ &amp;lt;4,8&amp;gt;, &amp;lt;5,2&amp;gt;, &amp;lt;2,1&amp;gt;, &amp;lt;6,7&amp;gt;, &amp;lt;3,8&amp;gt;, &amp;lt;1,9&amp;gt; ],&#xA; [ &amp;lt;2,6&amp;gt;, &amp;lt;4,2&amp;gt;, &amp;lt;5,5&amp;gt;, &amp;lt;6,5&amp;gt;, &amp;lt;1,3&amp;gt;, &amp;lt;3,1&amp;gt; ],&#xA; [ &amp;lt;5,10&amp;gt;, &amp;lt;3,4&amp;gt;, &amp;lt;1,4&amp;gt;, &amp;lt;4,3&amp;gt;, &amp;lt;2,2&amp;gt;, &amp;lt;6,3&amp;gt; ]&#xA;];&#xA;&#xA;int C = 10; // Battery capacity&#xA;&#xA;int O[j in Jobs][m in Mchs] = first({o | o in Mchs : Ops[j][o].mch == m}); // Operation of job j on machine m&#xA;&#xA;dvar interval op[j in Jobs][o in Mchs] size Ops[j][o].pt;&#xA;dvar sequence mchs[m in Mchs] &#xA;  in    all(j in Jobs, o in Mchs : Ops[j][o].mch == m) op[j][o]&#xA;  types all(j in Jobs, o in Mchs : Ops[j][o].mch == m) j;&#xA;          &#xA;dvar int le[m in Mchs][j in 0..nbJobs] in 0..C; // Battery level at the end of operation of job j on machine m&#xA;&#xA;minimize max(j in Jobs) endOf(op[j][nbMchs]);&#xA;subject to {&#xA;  forall (m in Mchs) {&#xA;    le[m][0] == 0;&#xA;    noOverlap(mchs[m]);&#xA;    forall (j in Jobs) {&#xA;      le[m][j] == minl(C, le[m][typeOfPrev(mchs[m],op[j][O[j][m]],0)] + (startOf(op[j][O[j][m]])-endOfPrev(mchs[m],op[j][O[j][m]],0)))-Ops[j][O[j][m]].pt;&#xA;    }      &#xA;  }    &#xA;  forall (j in Jobs, o in 1..nbMchs-1)&#xA;    endBeforeStart(op[j][o], op[j][o+1]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/43f3V.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/43f3V.png&quot; alt=&quot;Optimal solution with makespan 79&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="312" LastEditorUserId="312" LastEditDate="2021-03-12T12:40:42.150" LastActivityDate="2021-03-12T12:40:42.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5913" PostTypeId="2" ParentId="5905" CreationDate="2021-03-12T09:45:45.967" Score="2" Body="&lt;p&gt;I guess your model is not feasible.&lt;/p&gt;&#xA;&lt;p&gt;Let me use the tiny &lt;a href=&quot;https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;zoo example&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;mdl = Model(name='buses')&#xA;nbbus40 = mdl.integer_var(name='nbBus40')&#xA;nbbus30 = mdl.integer_var(name='nbBus30')&#xA;mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;&#xA;mdl.minimize(nbbus40*500 + nbbus30*400)&#xA;&#xA;mdl.solve(log_output=True,)&#xA;&#xA;print(&amp;quot;solution is empty : &amp;quot;,mdl.solution.is_empty())&#xA;&#xA;print(&amp;quot;obj : &amp;quot;,mdl.solution.get_objective_value())&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solution is empty :  False&#xA;obj :  3800.0&#xA;nbBus40  =  6.0&#xA;nbBus30  =  2.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But if add a constraint that I should not use more than 4 buses in total&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mdl.add_constraint(nbbus40 + nbbus30 &amp;lt;= 4, 'nbbus')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then I get your error&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    print(&amp;quot;solution is empty : &amp;quot;,mdl.solution.is_empty())&#xA;AttributeError: 'NoneType' object has no attribute 'is_empty'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You should check why your model is not fasible&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-03-12T09:45:45.967" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5914" PostTypeId="1" AcceptedAnswerId="5916" CreationDate="2021-03-12T12:47:23.277" Score="11" ViewCount="1870" Body="&lt;p&gt;The other day someone asked about &lt;a href=&quot;https://or.stackexchange.com/questions/5885/recommendations-for-om-blogs&quot;&gt;recommended blogs to follow&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The older generation tends to prefer blog posts, but the newer generations tend to watch videos instead.&#xA;And we want to help the newer generations find their way to Operations Research, no?&lt;/p&gt;&#xA;&lt;p&gt;So which YouTube channels and other video channels would you recommend for following OR?&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="279" LastEditDate="2021-10-31T17:17:45.040" LastActivityDate="2023-03-09T04:53:03.683" Title="Recommendations for OR video channels (YouTube etc.)" Tags="|online-resources|" AnswerCount="8" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5915" PostTypeId="2" ParentId="5914" CreationDate="2021-03-12T12:48:47.323" Score="2" Body="&lt;p&gt;Let me start by adding these as a community wiki (the first one is our channel):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCcpkOKpujFlM67D2h0RdaeQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner YouTube channel&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCCwr0VjkxPvbt9xNmKOHHFA&quot; rel=&quot;nofollow noreferrer&quot;&gt;INFORMS YouTube channel&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PL0B05D53A5E101AA6&quot; rel=&quot;nofollow noreferrer&quot;&gt;SAS Statistics and Operations Research YouTube channel&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="350" LastEditorUserId="500" LastEditDate="2021-03-12T20:06:21.227" LastActivityDate="2021-03-12T20:06:21.227" CommentCount="0" CommunityOwnedDate="2021-03-12T12:48:47.323" ContentLicense="CC BY-SA 4.0" />
  <row Id="5916" PostTypeId="2" ParentId="5914" CreationDate="2021-03-12T18:55:57.050" Score="9" Body="&lt;p&gt;Some of the playlists I enjoyed:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=a2QgdDk4Xjw&amp;amp;list=PL05350A31E6C09B7A&quot; rel=&quot;noreferrer&quot;&gt;https://www.youtube.com/watch?v=a2QgdDk4Xjw&amp;amp;list=PL05350A31E6C09B7A&lt;/a&gt; &lt;em&gt;fundamentals of operations research&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=4U3B5lr-MqM&amp;amp;list=PL004010FEA702502F&quot; rel=&quot;noreferrer&quot;&gt;https://www.youtube.com/watch?v=4U3B5lr-MqM&amp;amp;list=PL004010FEA702502F&lt;/a&gt; &lt;em&gt;advanced topics in operations research&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLOEpD2bjMC9JsTBCafj8Fs5ChDdRqjw5j&quot; rel=&quot;noreferrer&quot;&gt;https://www.youtube.com/playlist?list=PLOEpD2bjMC9JsTBCafj8Fs5ChDdRqjw5j&lt;/a&gt; &lt;em&gt;Operations &amp;amp; Supply chain mangagement&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="329" LastEditorUserId="-1" LastEditDate="2021-03-12T22:10:16.380" LastActivityDate="2021-03-12T22:10:16.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5917" PostTypeId="2" ParentId="5914" CreationDate="2021-03-12T19:19:08.007" Score="3" Body="&lt;p&gt;There's the &lt;a href=&quot;https://www.youtube.com/channel/UCwycy9aiePMk-rmj-5-i-mg?sub_confirmation=1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract YouTube channel&lt;/a&gt; where we host a web series called &lt;a href=&quot;https://www.youtube.com/watch?v=6RIR6Y5N63U&amp;amp;ab_channel=Octeract&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimisation for Noobz&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-03-12T19:19:08.007" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5918" PostTypeId="2" ParentId="5914" CreationDate="2021-03-12T20:07:50.090" Score="9" Body="&lt;p&gt;Here are some YouTube channels having research level talks, all of which were livestreamed with live Q&amp;amp;A prior to being archived. These are all ongoing series with new talks (videos) added regularly.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCbUviq3XZCrpjn5qlsTP5Zw&quot; rel=&quot;nofollow noreferrer&quot;&gt;Discrete Optimization Talks&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCMXtHAfnKRntVKzPCUIiJnw&quot; rel=&quot;nofollow noreferrer&quot;&gt;One World Optimization Seminar&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCSlAhBOIY68IWLxpPUFHuSQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Communications in NLA&lt;/a&gt; (Numerical Linear Algebra), which has many talks pertinent to optimization, as well as some in optimization per se.&lt;/p&gt;&#xA;&lt;p&gt;Given the research level of these talks, they are more generally better suited for people who have already found their way to Operations Research, or at least a closely neighboring field, than for neophytes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://u.pcloud.link/publink/show?code=kbTctalK&quot; rel=&quot;nofollow noreferrer&quot;&gt;Euro Working Group on OR Practice&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Additional seminar series:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCB_MDxNsfAX9nGIy82EGS0A&quot; rel=&quot;nofollow noreferrer&quot;&gt;Machine Learning NeEDS (Network of European Data Scientists) Mathematical Optimization&lt;/a&gt; This series includes a number of presentations from leading academics in the field of Data Science and Analytics that will cover important topics such as explainability, fairness, fraud, privacy, etc. Mathematical Modeling and Mathematical Optimization will be at the core of their presentations. We also have the YOUNG Online Seminar Series “Machine Learning NeEDS Mathematical Optimization”.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit2&lt;/strong&gt; There is a new &lt;a href=&quot;https://www.youtube.com/@robustoptimizationwebinar/about&quot; rel=&quot;nofollow noreferrer&quot;&gt;Robust Optimization YouTube channel&lt;/a&gt;. It has a collection of Robust Optimization webinar talks, which can be attended live by signing up at the &lt;a href=&quot;https://sites.google.com/view/row-series/home?pli=1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Robust Optimization Webinar (ROW) web page&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-03-09T04:53:03.683" LastActivityDate="2023-03-09T04:53:03.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5919" PostTypeId="2" ParentId="5914" CreationDate="2021-03-13T00:08:28.413" Score="6" Body="&lt;p&gt;The &lt;a href=&quot;https://www.youtube.com/user/GurobiVideos/videos&quot; rel=&quot;noreferrer&quot;&gt;Gurobi YouTube channel&lt;/a&gt; has great collection of videos covering industry webinars, technical tutorials and primers on LP &amp;amp; MIP.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.youtube.com/channel/UCphLz_BXrOAInHozAlTsigA/videos&quot; rel=&quot;noreferrer&quot;&gt;Mixed Integer Programming channel&lt;/a&gt; hosts all recorded lectures of the &lt;a href=&quot;http://co-at-work.zib.de/&quot; rel=&quot;noreferrer&quot;&gt;CO@Work 2020&lt;/a&gt; summer school as well as the invited talks from &lt;a href=&quot;https://www.euro-online.org/websites/or-in-practice/ewg-por-2020-challenges-in-the-deployment-of-or-projects/&quot; rel=&quot;noreferrer&quot;&gt;EURO working group on Practice of OR 2020 meeting&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="562" LastEditorUserId="562" LastEditDate="2021-03-13T00:15:05.540" LastActivityDate="2021-03-13T00:15:05.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5920" PostTypeId="2" ParentId="5914" CreationDate="2021-03-13T04:15:29.433" Score="3" Body="&lt;p&gt;This &lt;a href=&quot;https://www.youtube.com/channel/UCKMY2i-ROJjOXCxePFewnkg&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Subject to&quot;&gt;YouTube channel&lt;/a&gt; posts interviews with researchers in OR.&lt;/p&gt;&#xA;&lt;p&gt;Also, this &lt;a href=&quot;https://www.youtube.com/c/SebastienBubeck/playlists&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Sebastien Bubeck&quot;&gt;YouTube channel by Sebustien Bubeck&lt;/a&gt; covers optimization and ML topics.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="-1" LastEditDate="2021-03-13T17:50:35.210" LastActivityDate="2021-03-13T17:50:35.210" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5922" PostTypeId="1" CreationDate="2021-03-13T12:26:51.487" Score="1" ViewCount="2646" Body="&lt;p&gt;I was wondering why the complexity order of the interior point method is O()^3 or O()^3.5?&lt;/p&gt;&#xA;&lt;p&gt;Much appreciate your time and consideration.&lt;/p&gt;&#xA;" OwnerUserId="5131" LastActivityDate="2021-03-15T00:32:39.577" Title="complexity order of the interior point method" Tags="|optimization|linear-programming|convex-optimization|computational-complexity|linear-algebra|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5923" PostTypeId="1" CreationDate="2021-03-14T12:23:22.703" Score="0" ViewCount="53" Body="&lt;p&gt;I have the following problem:&#xA;I want to determine a linear equation for a data table with &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; value. Point 1 should be the point where the first time &lt;span class=&quot;math-container&quot;&gt;$y &amp;gt; 0$&lt;/span&gt; and point 2 should be the point where the last time &lt;span class=&quot;math-container&quot;&gt;$y &amp;lt; 1$&lt;/span&gt;. The linear equation is then to be generated between points 1 and 2. For example in the table between point &lt;span class=&quot;math-container&quot;&gt;$x = 2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x = 4$&lt;/span&gt;. In addition the x-values are written in an array, the y-values are imported from an excel-file.&#xA;At the end I want so save the parameters of the linear equation.&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;x&lt;/th&gt;&#xA;&lt;th&gt;y&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0.0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;0.1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;td&gt;0.4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;td&gt;0.95&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5&lt;/td&gt;&#xA;&lt;td&gt;1.1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6&lt;/td&gt;&#xA;&lt;td&gt;0.9&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;" OwnerUserId="5092" LastActivityDate="2021-03-14T12:23:22.703" Title="linear equation with conditions in Java" Tags="|linear-programming|java|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5924" PostTypeId="2" ParentId="5922" CreationDate="2021-03-15T00:32:39.577" Score="5" Body="&lt;p&gt;For a linear program in standard form&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_{x} \ \ \ &amp;amp; c^{T}x\\&#xA;\text{s.t.} \ \ \ &amp;amp; Ax = b,\\&#xA;&amp;amp; x \geq 0,&#xA;\end{align}&lt;/span&gt;&#xA;where the constraint matrix &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{m \times n}$&lt;/span&gt; (i.e., &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; constraints and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables) has full row rank (which implies &lt;span class=&quot;math-container&quot;&gt;$n \geq m$&lt;/span&gt;), the best-known interior-point algorithms require &lt;span class=&quot;math-container&quot;&gt;$O(\sqrt{n} \log(1/\epsilon))$&lt;/span&gt; iterations to achieve a precision of &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;. See for instance the &lt;a href=&quot;https://doi.org/10.1137/1.9781611971453&quot; rel=&quot;noreferrer&quot;&gt;textbook of S. Wright on interior-point methods&lt;/a&gt; for a detailed description.&lt;/p&gt;&#xA;&lt;p&gt;This means that after &lt;span class=&quot;math-container&quot;&gt;$O(\sqrt{n} \log(1/\epsilon))$&lt;/span&gt; iterations, you get a primal-dual solution which is feasible and optimal up to some tolerance measured by &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;.&#xA;Now, each iteration requires the solution of a linear system of size &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, whose complexity is roughly &lt;span class=&quot;math-container&quot;&gt;$O(n^{3})$&lt;/span&gt; (recall that &lt;span class=&quot;math-container&quot;&gt;$n \geq m$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;This gives an overall complexity of &lt;span class=&quot;math-container&quot;&gt;$O(n^{3.5} \log(1 / \epsilon))$&lt;/span&gt; to solve the problem &lt;em&gt;to &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; accuracy&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;PS:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I am voluntarily vague w.r.t &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; since the OP was about complexity w.r.t &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. There are plenty of details in Wright's book.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;span class=&quot;math-container&quot;&gt;$O(n^{3})$&lt;/span&gt; is a slight upper estimate: AFAIK, the theoretical complexity for matrix inversion is around &lt;span class=&quot;math-container&quot;&gt;$O(n^{2.37})$&lt;/span&gt;. In practice, all this is not as relevant since we deal with sparse matrices.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2021-03-15T00:32:39.577" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5925" PostTypeId="1" AcceptedAnswerId="5927" CreationDate="2021-03-15T09:52:08.070" Score="1" ViewCount="258" Body="&lt;p&gt;I found in the literature that &lt;strong&gt;Adaptive Large Neighborhood Search (ALNS)&lt;/strong&gt;, which uses a &lt;strong&gt;roulette mechanism&lt;/strong&gt; to select the best-performing operators, is the most &lt;strong&gt;efficient method&lt;/strong&gt;. However, other approaches use other selection mechanisms such as &lt;strong&gt;choice function&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What are the most known &lt;strong&gt;disadvantages of the roulette selection mechanism&lt;/strong&gt; compared to the &lt;strong&gt;choice function mechanism?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4942" LastEditorUserId="3391" LastEditDate="2021-03-15T14:13:49.097" LastActivityDate="2021-03-15T14:13:49.097" Title="Roulette mechanism with ALNS" Tags="|vehicle-routing|metaheuristics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5927" PostTypeId="2" ParentId="5925" CreationDate="2021-03-15T13:45:55.747" Score="4" Body="&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Fitness_proportionate_selection&quot; rel=&quot;nofollow noreferrer&quot;&gt;roulette selection mechanism&lt;/a&gt; is a kind of choice function. Thus, the question is not well stated. What is the other choice function you consider against roulette selection?&lt;/p&gt;&#xA;&lt;p&gt;The roulette selection is a randomized, possibly biased, choice function. Randomization is an important ingredient of the efficiency of neighborhood search approaches in combinatorial optimization. At each new iteration of the search, the idea is to select the best-performing operators with a higher probability and the worst-performing ones with a lower probability. The choice is randomized to ensure diversification and avoid bias for a given instance to solve. It also favors the robustness of the search when solving instances that possibly have a different combinatorial structure.&lt;/p&gt;&#xA;&lt;p&gt;There is no particular drawback to use the roulette selection. It can be implemented quite easily in its simplest form while almost nothing in terms of running time. Indeed, you have to add some counters in your algorithm that count successes or failures for each operator and then implement your roulette choice function.&lt;/p&gt;&#xA;&lt;p&gt;We prefer to use a quick and dirty pseudo-random number generator, like &lt;a href=&quot;https://en.wikipedia.org/wiki/Pseudorandom_number_generator&quot; rel=&quot;nofollow noreferrer&quot;&gt;linear congruential generators&lt;/a&gt;, in roulette selection. By experience, the random sequence's quality is not critical in such a context, even if you perform millions of moves over the search.&lt;/p&gt;&#xA;&lt;p&gt;Some examples of roulette selection approach for variable neighborhood search can be found in the papers below:&lt;/p&gt;&#xA;&lt;p&gt;B. Estellon, F. Gardi, K. Nouioua (2008). Two local search approaches for solving real-life car sequencing problems. In Special Issue: The Car Sequencing Problem (C. Solnon, V.D. Cung, A. Nguyen, C. Artigues, eds.), European Journal of Operational Research 191(3), pp. 928-944. &lt;a href=&quot;https://www.localsolver.com/fgardi/downloads/Estellon-Gardi-Nouioua_EJOR_06.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;T. Benoist, B. Estellon, F. Gardi, A. Jeanjean (2011). Randomized local search for real-life inventory routing. Transportation Science 45(3), pp. 381-398. &lt;a href=&quot;https://www.localsolver.com/fgardi/downloads/Benoist-Estellon-Gardi-Jeanjean_TRSC_09.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt; (extended version &lt;a href=&quot;https://www.localsolver.com/fgardi/downloads/Benoist-Estellon-Gardi-Jeanjean_TRSC_09_extended.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdf&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-03-15T13:45:55.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5928" PostTypeId="1" CreationDate="2021-03-16T10:15:04.223" Score="3" ViewCount="911" Body="&lt;p&gt;I am trying to implement benders decomposition for a simple fixed charge transportation problem for the purpose of learning. I implemented the classic Benders decomposition successfully by adding benders cuts as cutting planes to the master problem (generate cut and add to master - solve again ) and it works well ! But, when I wanted to treat benders cuts as lazy and user cut constraints, and embed them within the branch and bound, it doesn't work. Infact, when I only used benders cuts as a lazyconstraint, the algorithm worked out very well, but when I used them as both usercut and lazyconstraint, the programm couldn't stop, it kept calling usercutCallback at at the root node (please see the image below) and wouldn't make branch. I really don't know what the problem is.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QtllD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QtllD.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Please below find the some part of the codes:&lt;/p&gt;&#xA;&lt;p&gt;The codes related to adding benders cuts iteratively to the master problem:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void Benders::Benders_body()&#xA;{&#xA;&#xA;    &#xA;        #pragma region create relaxed master ILP&#xA;    model_master = new IloModel(env_master);&#xA;    createMasterILP();//set up master problem&#xA;    #pragma endregion create relaxed master ILP&#xA;&#xA;    // Create subproblem IloCplex algorithm and subproblem LP for Benders' cuts separation&#xA;    cplex_sub = IloCplex(env_sub);&#xA;    createSubproblemLP();&#xA;    // Create subproblem IloCplex algorithm and subproblem LP for Benders' cuts separation&#xA;&#xA;    // Set up the cut callback to be used for separating Benders' cuts&#xA;    cplex_master = IloCplex(env_master);&#xA;    cplex_master.extract(*model_master);&#xA;    cplex_master.setParam(IloCplex::Param::Preprocessing::Presolve, IloFalse);&#xA;    cplex_master.setParam(IloCplex::Param::Threads, 1);&#xA;    // ***********Turn on traditional search for use with control callbacks***********&#xA;    cplex_master.setParam(IloCplex::Param::MIP::Strategy::Search,IloCplex::Traditional);&#xA;    //cplex_master.setOut(env_master.getNullStream());&#xA;        &#xA;    //add lazy constraints (to handle integer nodes) and user call back (to handle fractional ones) to the model&#xA;    cplex_master.use(BendersLazyCallback(env_master, data, *this));&#xA;    cplex_master.use(BendersUserCallback(env_master, data, *this));&#xA;&#xA;    &#xA;    //cplex_master.exportModel(&amp;quot;Mater-mathmodel.lp&amp;quot;);&#xA;        &#xA;        if (cplex_master.solve())&#xA;        {&#xA;            IloAlgorithm::Status solStatus = cplex_master.getStatus();&#xA;            cout &amp;lt;&amp;lt; &amp;quot;Solution status: &amp;quot; &amp;lt;&amp;lt; solStatus &amp;lt;&amp;lt; endl;&#xA;&#xA;            &#xA;&#xA;            if (solStatus == IloAlgorithm::Optimal) {&#xA;                cout &amp;lt;&amp;lt; &amp;quot;master Objective&amp;quot; &amp;lt;&amp;lt; &amp;quot;\t&amp;quot; &amp;lt;&amp;lt; cplex_master.getObjValue() &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&#xA;            }&#xA;        }&#xA;&#xA;    &#xA;    model_master-&amp;gt;end();&#xA;    model_sub-&amp;gt;end();&#xA;    cplex_master.end();&#xA;    cplex_sub.end();&#xA;}&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The code of the Lazy constraints callback macro:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ILOLAZYCONSTRAINTCALLBACK2(BendersLazyCallback, InputData , data, Benders &amp;amp;, B)&#xA;{&#xA;        &#xA;    //initilize Y_bar which is fixed now to be used in the subproblem&#xA;    IloArray&amp;lt;IloNumArray&amp;gt; Y_bar(B.Get_env_master(),data.Get_nWarehouse());&#xA;    for (int i = 0; i &amp;lt; data.Get_nWarehouse(); ++i) {&#xA;        Y_bar[i] = IloNumArray(B.Get_env_master());&#xA;        getValues(Y_bar[i], B.Get_Y()[i]);&#xA;    }&#xA;&#xA;    &#xA;    IloExpr BenCut(B.Get_env_master());&#xA;&#xA;    //cout &amp;lt;&amp;lt; &amp;quot;ADD Lazy constraint&amp;quot; &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&#xA;    IloBool sepStat =B.separate(Y_bar, BenCut);&#xA;    &#xA;&#xA;    if (sepStat) {&#xA;        if (B.Get_CutType() == 1)//benders feasibility cut&#xA;            add(BenCut &amp;lt;= 0).end();&#xA;        else if (B.Get_CutType() == 2)//benders optimality cut&#xA;            add(B.Get_MaxFlow() &amp;gt;= BenCut).end();&#xA;    }&#xA;&#xA;    &#xA;    BenCut.end();&#xA;    &#xA;    return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The code of the User cut callback macro:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ILOUSERCUTCALLBACK2(BendersUserCallback, InputData, data, Benders &amp;amp;, B)&#xA;{&#xA;    &#xA;    //This method indicates whether or not the callback was invoked after CPLEX stopped generating cuts and called the callback a final time.&#xA;    if (!isAfterCutLoop())&#xA;        return; &#xA;&#xA;&#xA;    //initilize Y_bar which is fixed now to be used in the subproblem&#xA;    IloArray&amp;lt;IloNumArray&amp;gt; Y_bar(B.Get_env_master(),data.Get_nWarehouse());&#xA;    for (int i = 0; i &amp;lt; data.Get_nWarehouse(); ++i) {&#xA;        Y_bar[i] = IloNumArray(B.Get_env_master());&#xA;        getValues(Y_bar[i], B.Get_Y()[i]);&#xA;    }&#xA;&#xA;    &#xA;&#xA;    IloExpr BenCut(B.Get_env_master());&#xA;&#xA;    IloBool sepStat =B.separate(Y_bar, BenCut);&#xA;    &#xA;&#xA;    if (sepStat) {&#xA;        if (B.Get_CutType() == 1)//benders feasibility cut&#xA;            add(BenCut &amp;lt;= 0).end();&#xA;        else if (B.Get_CutType() == 2)//benders optimality cut&#xA;            add(B.Get_MaxFlow() &amp;gt;= BenCut).end();&#xA;    }&#xA;&#xA;    &#xA;    BenCut.end();&#xA;    &#xA;    return;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The code of the separate function&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;IloBool Benders::separate(const IloArray&amp;lt;IloNumArray&amp;gt; Y_bar, IloExpr &amp;amp; BenCut)&#xA;{&#xA;    IloBool violatedCutFound = IloFalse;&#xA;&#xA;    //update the rhs of the BigM constraints given the new Y_fixed&#xA;    float minM2;&#xA;    int counter = 0;&#xA;    rhs_bigM = IloNumArray(env_sub, data.Get_nWarehouse()*data.Get_nCustomers());&#xA;    for (int i = 0; i &amp;lt; data.Get_nWarehouse(); i++)&#xA;        for (int j = 0; j &amp;lt; data.Get_nCustomers(); j++)&#xA;        {&#xA;            minM2 = std::min(data.Get_Capacity(i), data.Get_Demand(j));&#xA;            rhs_bigM[counter] = minM2*Y_bar[i][j];&#xA;            counter += 1;&#xA;&#xA;        }&#xA;&#xA;    BigM_constraints.setUbs(rhs_bigM);&#xA;    &#xA;    cplex_sub.extract(*model_sub);&#xA;    cplex_sub.solve();&#xA;    &#xA;&#xA;    //to save extreme points or dual values&#xA;    Warehouse_Ray= IloNumVarArray(env_sub);&#xA;    Customer_Ray= IloNumVarArray(env_sub);&#xA;    BigM_Ray= IloNumVarArray(env_sub);&#xA;    warehouse_ray= IloNumArray(env_sub);&#xA;    customer_ray= IloNumArray(env_sub);&#xA;    bigM_ray= IloNumArray(env_sub);&#xA;&#xA;    if (cplex_sub.getStatus() == IloAlgorithm::Infeasible) //primal subproblem is infeasible&#xA;    {&#xA;        cut_type = 1;&#xA;        violatedCutFound = IloTrue;&#xA;        cplex_sub.getDuals(warehouse_ray, Capacities_constraints);&#xA;        cplex_sub.getDuals(customer_ray, Demands_constraints);&#xA;        cplex_sub.getDuals(bigM_ray, BigM_constraints);&#xA;    }&#xA;    else if (cplex_sub.getStatus() == IloAlgorithm::Optimal)//subproblem is optimal&#xA;    {&#xA;&#xA;        cut_type = 2;&#xA;        violatedCutFound = IloTrue;&#xA;        cplex_sub.getDuals(warehouse_ray, Capacities_constraints);&#xA;        cplex_sub.getDuals(customer_ray, Demands_constraints);&#xA;        cplex_sub.getDuals(bigM_ray, BigM_constraints);&#xA;    }&#xA;    &#xA;    BenCut = Get_BenCut(env_master);&#xA;&#xA;    &#xA;&#xA;    Warehouse_Ray.end();&#xA;    Customer_Ray.end();&#xA;    BigM_Ray.end();&#xA;    warehouse_ray.end();&#xA;    customer_ray.end();&#xA;    bigM_ray.end();&#xA;&#xA;&#xA;    return violatedCutFound;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I should note that I am using Cplex 12.9 and C++ technology concert;&lt;/p&gt;&#xA;&lt;p&gt;I would be grateful if you could help me out !&lt;/p&gt;&#xA;&lt;p&gt;Best regards,&lt;/p&gt;&#xA;" OwnerUserId="5008" LastEditorUserId="5008" LastEditDate="2021-04-13T12:59:03.983" LastActivityDate="2021-04-13T12:59:03.983" Title="Implementing benders decomposition using Lazy and User cuts callback of Cplex" Tags="|cplex|combinatorial-optimization|benders-decomposition|c++|callback|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5930" PostTypeId="2" ParentId="5928" CreationDate="2021-03-16T19:51:44.320" Score="2" Body="&lt;p&gt;First, I don't understand why you extract the master model, set parameters and add the callback repeatedly inside a loop. When using a callback, the plan is to solve the master problem &lt;em&gt;once&lt;/em&gt;, adding cuts via the callback along the way, so extracting the model etc. would be done &lt;em&gt;once&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strike&gt;Second, and more directly related to your issue, while I'm not a C/C++ user I believe that applying &lt;code&gt;end()&lt;/code&gt; to the cut you just added has the effect of removing it from the model. Try removing the calls to &lt;code&gt;end()&lt;/code&gt; after &lt;code&gt;add()&lt;/code&gt;. I think ending &lt;code&gt;BenCut&lt;/code&gt; is harmless (but probably unnecessary, since it has local scope), but I might be wrong about that.&lt;/strike&gt;&#xA;(This is incorrect. As noted in a comment, the Benders ATSP example supplied by IBM invokes .end() on added cuts within the callback.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-03-18T15:11:35.893" LastActivityDate="2021-03-18T15:11:35.893" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="5931" PostTypeId="1" CreationDate="2021-03-17T10:46:23.657" Score="2" ViewCount="684" Body="&lt;p&gt;I would like to assign a single value to a paramter that depends on a created set in Pyomo. I have the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import SetUpScenarios &#xA;import pyomo.environ as pyo&#xA;import pandas as pd&#xA;&#xA;&#xA;&#xA;#Define the model&#xA;&#xA;model = pyo.ConcreteModel()&#xA;&#xA;&#xA;#Define the sets&#xA;&#xA;model.set_timeslots = pyo.RangeSet(1, SetUpScenarios.numberOfTimeSlotsPerDay)&#xA;&#xA;&#xA;#Reading of the data&#xA;df_buildingData = pd.read_csv(&amp;quot;C:/Users/Data/H9_HH1 - Day_4.csv&amp;quot;, sep =&amp;quot;;&amp;quot;)&#xA;&#xA;&#xA;&#xA;#Create the dictionaries for the set&#xA;&#xA;#dictionaryHeatDemand= df_buildingData.set_index('Timeslot')['Q_htg'].to_dict()&#xA;&#xA;&#xA;&#xA;model.param_heatDemand = pyo.Param(model.set_timeslots, initialize=df_buildingData['Q_htg'])&#xA;&#xA;model.param_heatDemand.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Normally I did that with a dictionary but here the dataframe does not include the set 'timeslot' and with my currently used assignment &amp;quot;model.param_heatDemand = pyo.Param(model.set_timeslots, initialize=df_buildingData['Q_htg'])&amp;quot; the whole dataframe column is assigned to each value of the set. But I just want the first entry of the dataframe column 'Q_htg' to be assigned to the first value of the set timeslots. Any idea how I can do that? I'd appreciate every comment.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: A little more information to the code and the data&#xA;The 'SetUpScenario' class just sets up static values that I can use in other classes. So for this example it is just important to know that the variable 'SetUpScenarios.numberOfTimeSlotsPerDay' has the value 288 (one day with a time resolution of 5 minutes). The dataframe df_buildingData contains 5 columns with 288 values each (one for each timeslot with a resolution of 5 minutes). One of them is the heat demand 'Q_htg'. The values of the Pyomo parameter 'model.param_heatDemand' should just contain one heat demand value of the row 'Q_htg' for each of the 288 elements of the Set 'model.set_timeslots'. So the first value in the set 'model.set_timeslots' should be assigned the first value of the dataframe column 'Q_htg'. The second value in the set 'model.set_timeslots' should be assigned the second value of the dataframe column 'Q_htg' and so on. Both of them have 288 entries.&lt;/p&gt;&#xA;&lt;p&gt;Does anybody have an idea how I can do that?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2021-03-19T08:09:10.067" LastActivityDate="2021-03-19T08:09:10.067" Title="How to assign a single value to Pyomo parameter without a dictionary" Tags="|python|pyomo|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5932" PostTypeId="1" AcceptedAnswerId="5933" CreationDate="2021-03-17T12:05:50.237" Score="2" ViewCount="175" Body="&lt;p&gt;I have &lt;code&gt;N&lt;/code&gt; bounding boxes that I want to fuse/merge given some constraints. Each bounding box has a label.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt;&#xA;The main goal is to minimize &lt;code&gt;N&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Bounding boxes with the same label can be grouped together&#xA;&lt;br/&gt;&lt;img src=&quot;https://i.stack.imgur.com/drGQE.png&quot; width=&quot;400&quot; /&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A new bounding box resulting from a fusion can't overlap a bounding box with a different label:&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/3O2BB.png&quot; width=&quot;400&quot; /&gt;&lt;br/&gt;&lt;br/&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/xwxsC.png&quot; width=&quot;400&quot; /&gt;&lt;br/&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can this be solved ? Is it related to a classic OR problem ?&lt;/p&gt;&#xA;" OwnerUserId="5148" LastEditorUserId="500" LastEditDate="2021-03-17T13:05:50.443" LastActivityDate="2021-03-17T13:05:50.443" Title="Bounding box fusion with constraints" Tags="|modeling|algorithms|heuristics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5933" PostTypeId="2" ParentId="5932" CreationDate="2021-03-17T13:03:51.000" Score="3" Body="&lt;p&gt;You can solve this as a graph coloring problem in a graph with one node per original box and an edge between each pair of nodes for which the corresponding boxes cannot be merged (either because they have different labels or because merging would conflict with a box of a different label). Each color corresponds to a new bounding box, adjacent nodes cannot be the same color, and you want to minimize the number of colors.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-03-17T13:03:51.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5934" PostTypeId="1" CreationDate="2021-03-17T17:12:36.300" Score="6" ViewCount="1565" Body="&lt;p&gt;I have a linear programming problem &lt;span class=&quot;math-container&quot;&gt;$LP$&lt;/span&gt; where all the variables &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; take value in &lt;span class=&quot;math-container&quot;&gt;$\left[0, 1\right]$&lt;/span&gt; (that is &lt;span class=&quot;math-container&quot;&gt;$0\leq x_{i} \leq 1$&lt;/span&gt;). All the constraints are as follow: &lt;span class=&quot;math-container&quot;&gt;$a_{1}+a_{2}+a_{3}=1$&lt;/span&gt; that is each constraint is the sum of three distinct elements, for each elememt &lt;span class=&quot;math-container&quot;&gt;$a_{j}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$j\in \left\{1; 2; 3\right\}$&lt;/span&gt; we have &lt;span class=&quot;math-container&quot;&gt;$a_{j}=x_{i}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$a_{j}=1-x_{i}$&lt;/span&gt; and each sum is equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. It is &lt;strong&gt;not&lt;/strong&gt; possible that the same variable &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; appears two times in the same sum.&lt;/p&gt;&#xA;&lt;p&gt;If for each variable &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; we have that &lt;span class=&quot;math-container&quot;&gt;$LP$&lt;/span&gt; is feasible whether we set &lt;span class=&quot;math-container&quot;&gt;$x_{i}=0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x_{i}=1$&lt;/span&gt;, can we say that exists an integer solution of &lt;span class=&quot;math-container&quot;&gt;$LP$&lt;/span&gt;, that is a solution where each variable takes value in &lt;span class=&quot;math-container&quot;&gt;$\left\{0; 1\right\}$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;I give an example to make clearer my question.&lt;br /&gt;&#xA;Given:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{1}+x_{2}+x_{3}=1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{4}+(1-x_{5})+x_{6}=1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$(1-x_{7})+x_{8}+x_{9}=1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$(1-x_{1})+(1-x_{5})+(1-x_{7})=1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$0\leq x_{i} \leq 1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Foreach variable &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; of the problem, one by one, we have that the problem is feasible whether we set &lt;span class=&quot;math-container&quot;&gt;$x_{i}=0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x_{i}=1$&lt;/span&gt;.&lt;br /&gt;&#xA;The problem has at least an integer solution: &lt;span class=&quot;math-container&quot;&gt;$x_{1}=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{2}=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{3}=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{4}=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{5}=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{6}=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{7}=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{8}=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{9}=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The question is: in general, for a problem where the constraints are the sums of three variables or their complement to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, the sums are equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0\leq x_{i} \leq 1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i$&lt;/span&gt; (like in the given example), is it true that if the given problem is feasible whether we set, one by one, &lt;span class=&quot;math-container&quot;&gt;$x_{i}=0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x_{i}=1$&lt;/span&gt; foreach variable &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; of the problem, then there is at least an integer solution of the given problem?&lt;/p&gt;&#xA;" OwnerUserId="3221" LastEditorUserId="3221" LastEditDate="2021-03-18T02:57:10.213" LastActivityDate="2021-09-02T22:57:01.500" Title="0 1 solution of linear programming problem with only equality constraints" Tags="|linear-programming|integer-programming|combinatorial-optimization|binary-variable|" AnswerCount="2" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5936" PostTypeId="1" CreationDate="2021-03-17T22:47:17.063" Score="4" ViewCount="73" Body="&lt;p&gt;To derive problem-specific cutting planes for some given problem (think something like TSP problem), one common way is to study small examples. To this end, one can create small instances for the polytope and feed them to tools like &lt;a href=&quot;https://polymake.org/doku.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://polymake.org/doku.php&lt;/a&gt; or &lt;a href=&quot;https://porta.zib.de&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://porta.zib.de&lt;/a&gt;, and they return the &amp;quot;perfect&amp;quot; linear description. Then one can try to generalize the found inequalities to yield general cutting planes for our problem.&lt;/p&gt;&#xA;&lt;p&gt;How do you investigate if the structures become non-polyhedral? How to derive linear cutting planes for the convex hull of the feasible set?&lt;/p&gt;&#xA;&lt;p&gt;Consider for example something like &lt;span class=&quot;math-container&quot;&gt;$S = \{x,y,z : xy + yz = 5, x \le 3, y \ge5\}$&lt;/span&gt; and one wants to find linear cutting planes to come as close as possible to &lt;span class=&quot;math-container&quot;&gt;$\operatorname{conv}(S)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="3391" LastEditDate="2021-03-18T15:40:53.007" LastActivityDate="2021-03-18T15:40:53.007" Title="How can non-polyhedral sets be investigated?" Tags="|nonlinear-programming|nonconvex-programming|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5937" PostTypeId="1" CreationDate="2021-03-18T15:02:48.857" Score="3" ViewCount="91" Body="&lt;p&gt;In a scheduling problem I want to assign the resources to tasks, each task has earliest start date, latest start date and duration. Also each resource has fixed number of available hours in a day. The problem is resource and task are located at different locations and each task have their own time window. A resource can make a trip to a location and complete certain number of tasks and come back. Later on it can make second trip and complete certain number tasks. For each hour (worktime, wait time) spent at destination location there is a cost. What tasks shall I assign in a trip so that there is minimum cost of assignment and when shall a resource start a trip ?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cG9lg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cG9lg.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2780" LastEditorUserId="500" LastEditDate="2021-03-18T18:29:46.077" LastActivityDate="2024-04-04T05:17:04.710" Title="How to assign task, resources to trips" Tags="|mixed-integer-programming|scheduling|vehicle-routing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5938" PostTypeId="1" CreationDate="2021-03-18T13:43:36.840" Score="3" ViewCount="160" Body="&lt;p&gt;My question is about how to construct a mixed integer programming to model that there is no feasible solution to a given linear system. Specifically, given &lt;span class=&quot;math-container&quot;&gt;$x\in \mathbb{R}^{n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z\in \{0,1\}^{d}$&lt;/span&gt;, we have a linear system &lt;span class=&quot;math-container&quot;&gt;$f_i(x,z)\le s_i, i = 1,2,\cdots,m$&lt;/span&gt;. The linear system can be written in matrix form: &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{A}x + \boldsymbol{B}z\le s$&lt;/span&gt;. I have another linear inequality &lt;span class=&quot;math-container&quot;&gt;$g(x,z)\le c$&lt;/span&gt;. The statement I want to model is:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;there is no feasible solution such that &lt;span class=&quot;math-container&quot;&gt;$f_i(x,z)\le s_i, i = 1,2,\cdots,m$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g(x,z)\le c$&lt;/span&gt; hold simultaneously.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Is there any way to model this statement in mixed integer programming?&lt;/p&gt;&#xA;&lt;p&gt;P.S.: Since the question above is only part of my overall problem, I will briefly explain the big picture behind the problem. I want to model a defender-attacker problem. The defender tries to find the best defending choice &lt;span class=&quot;math-container&quot;&gt;$\beta\in \{0,1\}^{a}$&lt;/span&gt; with an objective to minimize &lt;span class=&quot;math-container&quot;&gt;$\Arrowvert \beta \Arrowvert_0$&lt;/span&gt;. The defender requires that once the constraints on the attacker (&lt;span class=&quot;math-container&quot;&gt;$f_i(x,z)\le s_i(\beta), i = 1,2,\cdots,m$&lt;/span&gt;) hold, the event (&lt;span class=&quot;math-container&quot;&gt;$g(x,z)\le c$&lt;/span&gt;) will not happen.&lt;/p&gt;&#xA;&lt;p&gt;Methods I tried:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Farkas-type theorem of alternative. This approach does not work since it requires first to relax the above mixed integer inequalities into linear programming (LP). However, directly relaxing &lt;span class=&quot;math-container&quot;&gt;$z\in \{0,1\}^{d}$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$z\in[0,1]$&lt;/span&gt; is too coarse.&lt;/li&gt;&#xA;&lt;li&gt;Integer-version theorem of alternative. Currently, I have only found one paper &amp;quot;Cutting planes from a mixed integer Farkas lemma&amp;quot;, which requires [A,B] to have full row rank.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5160" OwnerDisplayName="Yu-di Huang" LastEditorUserId="491" LastEditDate="2021-05-10T12:20:30.273" LastActivityDate="2021-05-10T12:20:30.273" Title="Modeling that there is no feasible solution to a linear system in mixed integer programming" Tags="|integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5939" PostTypeId="1" CreationDate="2021-03-18T19:06:29.967" Score="2" ViewCount="738" Body="&lt;p&gt;In Multi-stage stochastic programming, we write the constraints that for scenarios &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s^{\prime}$&lt;/span&gt;  which have the same trajectory up to time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, should take the same value. That is,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{t,s} = x_{t,s^{\prime}}  \quad \quad \forall t, s,s^{\prime} \in S: \: \: (\xi_{1}^s,\dots,\xi_{t-1}^s)=(\xi_{1}^{s^{\prime}},\dots,\xi_{t-1}^{s^{\prime}})&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I thought that for all decision variables except the first stage. For example, if &lt;span class=&quot;math-container&quot;&gt;$y_{ts},z_{ts}$&lt;/span&gt; are used in different stages, I should write nonanticipativity constraints for all of them. However, in some papers, nonanticipativity constraints are used for just a subset of variables, like &lt;span class=&quot;math-container&quot;&gt;$x_{ts}$&lt;/span&gt;. Could you please let me know how we should decide to include a variable in nonanticipativity constraints or not.&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2021-03-18T19:06:29.967" Title="How to write nonanticipativity constraints?" Tags="|stochastic-programming|multi-stage|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5940" PostTypeId="2" ParentId="5938" CreationDate="2021-03-18T20:56:00.647" Score="3" Body="&lt;p&gt;The following assumes that &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is a function of &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; (per your more detailed explanation of the problem).&lt;/p&gt;&#xA;&lt;p&gt;You can approach this via a row-generation method (similar to logical Benders decomposition). Start with the master problem &lt;span class=&quot;math-container&quot;&gt;$$\min\ \left\Vert \beta\right\Vert _{0}$$&lt;/span&gt;subject to only the constraint that &lt;span class=&quot;math-container&quot;&gt;$\beta\in \lbrace 0,1 \rbrace^a$&lt;/span&gt;. Each time the solver finds a candidate solution &lt;span class=&quot;math-container&quot;&gt;$\hat\beta$&lt;/span&gt; to the master, calculate &lt;span class=&quot;math-container&quot;&gt;$s(\hat\beta)$&lt;/span&gt; and try to solve the linear system&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;f(x,z) &amp;amp; \le s(\hat{\beta})\\&#xA;g(x,z) &amp;amp; \le c.&#xA;\end{align*}&lt;/span&gt;&#xA;If the linear system is inconsistent, accept &lt;span class=&quot;math-container&quot;&gt;$\hat\beta$&lt;/span&gt;. If the linear system has a solution, add a &amp;quot;no good&amp;quot; constraint of the form &lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i:\hat{\beta}_{i}=0}\beta_{i}+\sum_{i:\hat{\beta}=1}\left(1-\beta_{i}\right)\ge1&#xA;$$&lt;/span&gt; to the master problem. Depending on the IP solver you are using for the master problem, this could either mean solving the master from root node to &amp;quot;optimality&amp;quot; each iteration, or it could mean using a callback to add &amp;quot;no good&amp;quot; constraints to the master on the fly (interrupting the solver when a candidate solution is found, then resuming where the solver left off after adding the constraint).&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-03-23T15:22:42.227" LastActivityDate="2021-03-23T15:22:42.227" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5941" PostTypeId="2" ParentId="5885" CreationDate="2021-03-18T21:59:20.660" Score="5" Body="&lt;p&gt;SAS (my employer) has several blogs.  Here are two relevant tags:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://blogs.sas.com/content/tag/optimization/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://blogs.sas.com/content/tag/optimization/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://blogs.sas.com/content/tag/operations-research/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://blogs.sas.com/content/tag/operations-research/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-11-11T19:25:57.843" LastActivityDate="2022-11-11T19:25:57.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5942" PostTypeId="1" CreationDate="2021-03-18T22:14:46.323" Score="3" ViewCount="540" Body="&lt;p&gt;I have installed Gurobi 9.1.1 on a supercomputer node with 64 Xeon processors. For the installation I used conda.&lt;/p&gt;&#xA;&lt;p&gt;I access this node via ssh. When running &amp;quot;htop&amp;quot; I see that the process uses 1 core at 100% and very rare times (lets say 1% of the total time) it uses 1 or 2 extra cores for only a few seconds.&lt;/p&gt;&#xA;&lt;p&gt;In fact, my laptop with Intel i5 runs the same process using all the cores and is 10 times faster than the &amp;quot;supercomputer&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;I have asked the admin of the server if this situation may be the result of a configuration in the server. I am waiting for her answer.&lt;/p&gt;&#xA;&lt;p&gt;I have already added m.setParams(&amp;quot;Threads&amp;quot;, 64). But, there is no change.&lt;/p&gt;&#xA;&lt;p&gt;What could be the reason for this situation?&lt;/p&gt;&#xA;" OwnerUserId="5075" LastEditorUserId="5075" LastEditDate="2021-03-19T15:13:43.537" LastActivityDate="2021-03-19T15:13:43.537" Title="Gurobi uses 1 core on supercomputer node with 64 cores" Tags="|gurobi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5943" PostTypeId="2" ParentId="5942" CreationDate="2021-03-18T23:45:35.100" Score="2" Body="&lt;p&gt;Add the following line to your Python script:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.setParam('Threads', 64)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In which m is your gurobipy model defined as follow:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gb&#xA;m = gb.Model('NewModel')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-03-18T23:45:35.100" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5944" PostTypeId="1" AcceptedAnswerId="5985" CreationDate="2021-03-19T03:24:36.807" Score="1" ViewCount="163" Body="&lt;p&gt;Suppose a perishable item that is associated with a shelf life &lt;span class=&quot;math-container&quot;&gt;$m\in \mathcal{M} = \{1,\dots,M\}$&lt;/span&gt;. We have a periodic review system with stock level &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, i.e., based on the inventory level of the item, denoted by &lt;span class=&quot;math-container&quot;&gt;$\nu_{t}^{m}$&lt;/span&gt;, we decide over the size of the new order. In other words, at each review period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, we order &lt;span class=&quot;math-container&quot;&gt;$o_{t} = S - \sum_{m\in \mathcal{M}}\nu_{t-1}^{m}$&lt;/span&gt; items (stock level minus the remaining inventory of the previous period, that can be of any shelf life), so that the inventory level reaches &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The incoming order is not necessarily fresh, and we don't decide over the shelf life when ordering. What we know is that the shelf life of the incoming order follows a known distribution.&lt;/p&gt;&#xA;&lt;p&gt;My question is: how can I update the inventory level of the items with respect to their shelf life? If &lt;span class=&quot;math-container&quot;&gt;$\epsilon_{t}^{m}$&lt;/span&gt; is the amount of items in the shipment that are of age &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, we should have &lt;span class=&quot;math-container&quot;&gt;$\sum_{m \in \mathcal{M}} \epsilon_{t}^{m} = o_{t}$&lt;/span&gt;, and the values of &lt;span class=&quot;math-container&quot;&gt;$\epsilon_{t}^{m}$&lt;/span&gt; should follow the known distribution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\nu_{t}^{m} = \nu_{t-1}^{m-1} + \epsilon_{t}^{m}, \quad \forall m \in \mathcal{M}\setminus\{M\}, \forall t \in T\setminus\{1\}.&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So, the question is how to generate the &lt;span class=&quot;math-container&quot;&gt;$\epsilon_{t}^{m}$&lt;/span&gt; values so that they add up to a known value &lt;span class=&quot;math-container&quot;&gt;$o_{t}$&lt;/span&gt; (that changes in different time periods) where they are the realizations of a known distribution (I prefer doing it in python-Gurobi)?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;AN IDEA:&lt;/p&gt;&#xA;&lt;p&gt;I have come up with an idea: suppose &lt;span class=&quot;math-container&quot;&gt;$o_{t}$&lt;/span&gt; can be between 0 to 100. Before starting to solve the model, for each value &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; between 0 to 100, I will generate &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; random numbers based on the known distribution (e.g., a uniform distribution between 20 and 30), and then I count the number of individual values and store them. Then, I will use those counts for the relative &lt;span class=&quot;math-container&quot;&gt;$o_{t}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As an example, suppose &lt;span class=&quot;math-container&quot;&gt;$i=6$&lt;/span&gt;, I will generate a random number based on the distribution for six times. It will give six numbers (shelf lifes), say, 28, 22, 24, 22, 27, 24. Then, I will count those realizations: count(22)=2, count(24)=2, count(27)=1, count(28)=1, and count(20) = count(21) = count(23) = count(25) = count(26) = count(29) = count(30) = 0. Then, if I get &lt;span class=&quot;math-container&quot;&gt;$o_t=6$&lt;/span&gt;, I will refer to these counts and set: &lt;span class=&quot;math-container&quot;&gt;$\epsilon^{22}_t=2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\epsilon^{24}_t=2$&lt;/span&gt;, and so on (note that I do the process of generating numbers and counting the values for any &lt;span class=&quot;math-container&quot;&gt;$i\in\{0,\dots,100\}$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;However, the issue with this approach is that for the same value of o in different periods, the individuals are always the same, though it was supposed to be stochastic values.&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2021-03-21T03:36:13.827" LastActivityDate="2021-03-24T22:08:19.807" Title="Generating numbers that should add up to a fixed value while they follow a known distribution" Tags="|integer-programming|inventory|stochastic-programming|probability-distributions|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="5945" PostTypeId="1" CreationDate="2021-03-19T07:26:52.013" Score="3" ViewCount="233" Body="&lt;p&gt;I found following way to model a minimum constraint but in my case I need a non-zero minimum value. So in this figure, if any value of x_i is 0 then answer is 0 (assume x_i &amp;gt;=0) but I need non-zero value. Could you please help me to model this?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cfx1S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cfx1S.png&quot; alt=&quot;Trick to model minimum constraint.&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4812" LastActivityDate="2021-03-19T07:26:52.013" Title="How to model non-zero minimum constraint?" Tags="|optimization|modeling|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5946" PostTypeId="1" CreationDate="2021-03-19T07:31:58.777" Score="3" ViewCount="53" Body="&lt;p&gt;Let’s say I have a drink for several customers, and I know their demand. Besides, I also have a storage tank for the drink during times when demand exceeds supply. The storage tank's size is not yet known, but we need to determine what the minimum size of the storage tank needs to be. Unfortunately, the storage tank also comes with a cost per time unit. We want to maximize the profits.&#xA;I am currently a bit stuck at the storage component without the model blowing up.&#xA;We define &lt;span class=&quot;math-container&quot;&gt;$c_{i,t}$&lt;/span&gt; as a decision variable, whether we are going to serve customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Also, we define &lt;span class=&quot;math-container&quot;&gt;$D_{i,t}$&lt;/span&gt; as a parameter, which are the demands for customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Also, the storage cost of the tank is &lt;span class=&quot;math-container&quot;&gt;$S_{t}$&lt;/span&gt;. Basically, our objective function would be&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max \sum_{t} c_{i,t} \cdot D_{i,t} - q_{t} \cdot S_{t}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$q_{t}$&lt;/span&gt; is the current content of the storage tank. However, if we would like to define &lt;span class=&quot;math-container&quot;&gt;$q_{t}$&lt;/span&gt;, we need to sum up all the previous inflows and outflows to the storage tank, which is cumulative over the previous periods. This blows up the model, I think. What would be a better way to model this?&lt;/p&gt;&#xA;&lt;p&gt;A big assumption in this is that the more liquid you store, the higher the cost. However, for simplicity's sake, let's assume &lt;span class=&quot;math-container&quot;&gt;$S_{t}$&lt;/span&gt; is the price per unit storage.&lt;/p&gt;&#xA;&lt;p&gt;PS: Other additions to speed up to solve this model or anything else would be highly appreciated. Suggestions and improvements are highly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="563" LastEditorUserId="3391" LastEditDate="2021-03-19T09:50:47.417" LastActivityDate="2021-03-19T09:50:47.417" Title="How to formulate a storage component?" Tags="|mixed-integer-programming|modeling|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5948" PostTypeId="1" AcceptedAnswerId="5950" CreationDate="2021-03-19T19:49:47.763" Score="1" ViewCount="523" Body="&lt;p&gt;I'm wondering how I can translate this math constraint to gurobi python.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\forall a \in A, b \in B, x_{ab} \in \{0, 1\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So far I have written:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xab = m.addVar(lb=0, ub=1, vtype=GRB.BINARY, name=&amp;quot;xab&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I'm not sure what to add for the constraints section...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.addConstr(?? for a in A for b in B, &amp;quot;c0&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is it really as simple as replacing ?? with &lt;code&gt;xab&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5157" LastEditorUserId="491" LastEditDate="2022-03-09T04:49:41.683" LastActivityDate="2022-03-09T05:05:07.923" Title="How to write this constraint in Gurobi python?" Tags="|gurobi|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5949" PostTypeId="1" CreationDate="2021-03-19T21:18:46.290" Score="1" ViewCount="64" Body="&lt;p&gt;I gonna use the approach used in &lt;a href=&quot;https://www.gams.com/docs/contributed/financial/wr_WorkGAMS.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this document&lt;/a&gt;. Suppose there are &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; stages and uncertain parameter is &lt;span class=&quot;math-container&quot;&gt;$\xi_{t}, \quad t \in \{1,2,\dots,T\}$&lt;/span&gt;.&#xA;In this algorithm, it is required to calculate the distance between two scenarios &lt;span class=&quot;math-container&quot;&gt;$\xi^s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\xi^{s^{\prime}}$&lt;/span&gt; which is &lt;span class=&quot;math-container&quot;&gt;$C_t = \sum_{\tau=1}^{t}|\xi_{\tau}^s-\xi_{\tau}^{s^{\prime}}|$&lt;/span&gt; and two scenarios are joined if this distance is small. In this model, I think it is assumed that &lt;span class=&quot;math-container&quot;&gt;$\xi_t \in R$&lt;/span&gt;. I am wondering what I should do if &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; is multi-dimensional? For example, &lt;span class=&quot;math-container&quot;&gt;$\xi_{ijt}$&lt;/span&gt; represents the demand of customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; for product &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. In this case, the distance between two scenarios will be&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;C_t = \sum_{\tau=1}^{t} \sum_{i=1}^{I} \sum_{j=1}^{J} |\xi_{ij\tau}^s-\xi_{ij\tau}^{s^{\prime}}|&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is obvious that if the dimension of uncertain parameter increases, &lt;span class=&quot;math-container&quot;&gt;$C_t$&lt;/span&gt; increases and it is less likely to be able to merge two scenarios. It issue will be more problematic if the dimension of uncertain parameter increases. I would be thankful if you can let me know, how I should handle it.&lt;/p&gt;&#xA;&lt;p&gt;There is a package for this purpose in &lt;a href=&quot;https://www.gams.com/latest/docs/T_SCENRED2.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;GAMS&lt;/a&gt;. Can I know if there is any code in other software or programming languages?&lt;/p&gt;&#xA;&lt;p&gt;In general, is there any package for scenario tree construction?&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2021-03-19T21:18:46.290" Title="Scenario Tree Construction in Multi-Stage Stochastic Programming" Tags="|stochastic-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5950" PostTypeId="2" ParentId="5948" CreationDate="2021-03-20T17:35:52.477" Score="3" Body="&lt;pre&gt;&lt;code&gt;from gurobipy import *&#xA;A = []; B = [] # You need to enter the data in these lists &#xA;&#xA;m = Model()&#xA;x = {} # Dictionary of variables&#xA;for a in A:&#xA;    for b in B:&#xA;        x[a, b] = m.addVar(lb=0, ub=1, vtype=GRB.BINARY, name=&amp;quot;x_&amp;quot; +str(a) + str(b))&#xA;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note: Adding binary variables would constrain them to take values either 0 or 1. To add constraints involving these variables, you can use the following example syntax:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.addConstr(x[a1, b1] + x[a2, b2] &amp;lt;= 10, name = 'c0')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2424" LastEditorUserId="2424" LastEditDate="2021-03-20T20:23:06.647" LastActivityDate="2021-03-20T20:23:06.647" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5951" PostTypeId="2" ParentId="5937" CreationDate="2021-03-20T18:17:32.050" Score="2" Body="&lt;p&gt;As pointed out by A.Omidi in the comment above, your problem is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Vehicle_routing_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Capacitated Vehicle Routing Problem with Time Windows (CVRPTW)&lt;/a&gt;. It can be naturally modeled by following a list-based modeling approach. This is a modeling approach offered by Hexaly, which is different from traditional solvers. &lt;strong&gt;Note that Hexaly is commercial software.&lt;/strong&gt; Nevertheless, it is free for faculty and students.&lt;/p&gt;&#xA;&lt;p&gt;Below is the code snippet to model the classical CVRPTW problem in Hexaly Modeler:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function model() {&#xA;  customersSequences[k in 1..nbTrucks] &amp;lt;- list(nbCustomers);&#xA;&#xA;  // All customers must be visited by the trucks&#xA;  constraint partition[k in 1..nbTrucks](customersSequences[k]);&#xA;&#xA;  for[k in 1..nbTrucks] {&#xA;    local sequence &amp;lt;- customersSequences[k];&#xA;    local c &amp;lt;- count(sequence);&#xA;&#xA;    // A truck is used if it visits at least one customer&#xA;    truckUsed[k] &amp;lt;- c &amp;gt; 0;&#xA;&#xA;    // The quantity needed in each route must not exceed the truck capacity&#xA;    routeQuantity[k] &amp;lt;- sum(0..c-1, i =&amp;gt; demands[sequence[i]]);&#xA;    constraint routeQuantity[k] &amp;lt;= truckCapacity;&#xA;&#xA;    endTime[k] &amp;lt;- array(0..c-1, (i, prev) =&amp;gt; max(earliestStart[sequence[i]],&#xA;      i == 0 ?&#xA;      distanceWarehouse[sequence[0]] :&#xA;      prev + distanceMatrix[sequence[i-1]][sequence[i]]) + serviceTime[sequence[i]]);&#xA;&#xA;    homeLateness[k] &amp;lt;- truckUsed[k] ?&#xA;      max(0, endTime[k][c - 1] + distanceWarehouse[sequence[c - 1]] - maxHorizon) :&#xA;      0;&#xA;&#xA;    // Distance traveled by truck k&#xA;    routeDistances[k] &amp;lt;- sum(1..c-1,&#xA;      i =&amp;gt; distanceMatrix[sequence[i-1]][sequence[i]]) + (truckUsed[k] ?&#xA;      distanceWarehouse[sequence[0]] + distanceWarehouse[sequence[c-1]] :&#xA;      0);&#xA;&#xA;    lateness[k] &amp;lt;- homeLateness[k] + sum(0..c-1,&#xA;      i =&amp;gt; max(0, endTime[k][i] - latestEnd[sequence[i]]));&#xA;  }&#xA;&#xA;  // Total lateness, must be 0 for a solution to be valid&#xA;  totalLateness &amp;lt;- sum[k in 1..nbTrucks](lateness[k]);&#xA;&#xA;  nbTrucksUsed &amp;lt;- sum[k in 1..nbTrucks](truckUsed[k]);&#xA;&#xA;  // Total distance traveled&#xA;  totalDistance &amp;lt;- sum[k in 1..nbTrucks](routeDistances[k]);&#xA;&#xA;  minimize totalLateness;&#xA;  minimize nbTrucksUsed;&#xA;  minimize totalDistance;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The complete Hexaly Modeler code and the corresponding Python, Java, C#, and C++ codes are here: &lt;a href=&quot;https://www.hexaly.com/docs/last/exampletour/vrptw.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.hexaly.com/docs/last/exampletour/vrptw.html&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Following this modeling approach, Hexaly finds quality solutions (optimality gap less than 1%) for CVRPTW instances with thousands of customers to visit in a few minutes.&lt;/p&gt;&#xA;&lt;p&gt;For an introduction to the list-based modeling approach for combinatorial optimization, look at &lt;a href=&quot;https://www.hexaly.com/docs/last/advancedfeatures/collectionvariables.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.hexaly.com/docs/last/advancedfeatures/collectionvariables.html&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T05:17:04.710" LastActivityDate="2024-04-04T05:17:04.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5952" PostTypeId="1" CreationDate="2021-03-20T21:23:10.247" Score="4" ViewCount="240" Body="&lt;p&gt;I am formulating and solving a scheduling problem. The problem consists of scheduling items on a single machine, where the only time element is the transition from item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to item &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. For example, it takes 3 units of time to go from item 1 to item 2, and 2 units of time to go from item 2 to item 1. The formulation I follow is using a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; to represent item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; immediately preceding item &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The constraints and variables are as follows:&lt;/p&gt;&#xA;&lt;p&gt;Variables:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_{ij}, \forall i \in \text{Items},j\in\text{Items},i \neq j\\&#xA;s_i, \forall i \in \text{Items}&#xA;$$&lt;/span&gt;&#xA;Constraints: &lt;br /&gt;&#xA;An item will only be behind one other item&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j\neq i}y_{ij} \le 1, \forall i \in \text{Items}&#xA;$$&lt;/span&gt;&#xA;An item will only be in front of one other item&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i\neq j}y_{ij} \le 1, \forall j \in \text{Items}&#xA;$$&lt;/span&gt;&#xA;An item cannot be both behind and in front of another item&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_{ij} + y_{ji} \le 1, \forall i,j \in \text{Items}&#xA;$$&lt;/span&gt;&#xA;Only one item will not be before another item&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i,j,i \neq j} y_{ij} \ge |\text{Items}| - 1&#xA;$$&lt;/span&gt;&#xA;Tracking start times&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;s_i - s_j + t_{ij} \le M  ( 1 - y_{ij} )&#xA;$$&lt;/span&gt;&#xA;Objective:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \sum_{i} s_i&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Using Pulp with the default solver, I can solve an instances of up to 7 items. I have tried 10 but killed it after waiting &amp;gt;2 minutes. Any feedback on improving the formulation would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5161" LastEditorUserId="500" LastEditDate="2021-03-20T22:38:04.467" LastActivityDate="2024-04-04T05:19:20.453" Title="Optimization formulation has slow performance" Tags="|mixed-integer-programming|scheduling|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5953" PostTypeId="2" ParentId="5952" CreationDate="2021-03-20T21:48:52.437" Score="1" Body="&lt;p&gt;You did not define all your symbols, so I am going to infer from the model that &lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt; is the transition time from item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to item &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (a parameter) and &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; is the time that item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is processed (a variable). Assuming that is correct, your objective function looks unlikely to be correct. The sum of the start/end times has no intrinsic meaning. It is more likely that you want to minimize the &lt;em&gt;makespan&lt;/em&gt; (the time it takes to process all items). Normally that is accomplished by adding a continuous variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; for the makespan, minimizing &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, and defining &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; via the constraints &lt;span class=&quot;math-container&quot;&gt;$$z \ge s_i\quad\forall i.$$&lt;/span&gt;&#xA;In your case, however, since there is no processing time (only setup time), we can make things even simpler. The makespan will be the sum of the setup times, so you can eliminate the &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; variables and the big-M constraints and just minimize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j} t_{ij} y_{ij}$$&lt;/span&gt; subject to your first four constraints. Eliminating the big-M constraints should speed things up a fair bit.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-03-20T21:48:52.437" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5954" PostTypeId="1" CreationDate="2021-03-21T06:13:19.503" Score="2" ViewCount="85" Body="&lt;p&gt;As we all know, &lt;a href=&quot;https://en.wikipedia.org/wiki/Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions&quot; rel=&quot;nofollow noreferrer&quot;&gt;KKT point&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Stationary_point&quot; rel=&quot;nofollow noreferrer&quot;&gt;stationary point&lt;/a&gt; are well defined when the optimization variables are continuous in the problem.&lt;/p&gt;&#xA;&lt;p&gt;Now, I want to know whether there exist some special points except for the globally optimal solution in discrete optimization problems. For example, suppose &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;'s are differentiable with respect to &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; for any given &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned}\min_{x,y}\quad&amp;amp; f_0(x,y), \\&#xA;\mathrm{s.t.}\quad&amp;amp;f_k(x,y)\leq 0,\forall k\\&#xA;&amp;amp;x\in\mathcal X,\\&#xA;&amp;amp; y\in\mathbb Z.\end{aligned}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathcal X$&lt;/span&gt; is a compact and convex set. Except for the globally optimal solution, what else do some special points (e.g. stationary point) exist? And how to define these points?&lt;/p&gt;&#xA;&lt;p&gt;Thanks a lot for any help.&lt;/p&gt;&#xA;" OwnerUserId="5163" LastEditorUserId="123" LastEditDate="2021-03-21T09:12:33.717" LastActivityDate="2021-03-22T11:22:13.383" Title="How to define a stationary point of the MINLP problem?" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|convex-optimization|minlp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5955" PostTypeId="2" ParentId="5952" CreationDate="2021-03-21T08:40:15.757" Score="3" Body="&lt;p&gt;since you deal with scheduling on top of MIP you could try CPOptimizer scheduling.&lt;/p&gt;&#xA;&lt;p&gt;For instance you could start with &lt;a href=&quot;https://github.com/AlexFleischerParis/howtowithopl/blob/master/tspcpo.mod&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/AlexFleischerParis/howtowithopl/blob/master/tspcpo.mod&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using CP; &#xA;int     n       = ...;&#xA;range   Cities  = 1..n;&#xA;&#xA;int realCity[i in 1..n+1]=(i&amp;lt;=n)?i:1;&#xA;&#xA;&#xA;&#xA;// Edges -- sparse set&#xA;tuple       edge        {int i; int j;}&#xA;setof(edge) Edges       = {&amp;lt;i,j&amp;gt; | ordered i,j in 1..n};&#xA;setof(edge) Edges2       = {&amp;lt;i,j&amp;gt; | i,j in 1..n+1};  // node n+1 is node 1&#xA;&#xA;int         dist[Edges] = ...;&#xA;int         dist2[&amp;lt;i,j&amp;gt; in Edges2]=(realCity[i]==realCity[j])?0:&#xA;((realCity[i]&amp;lt;realCity[j])?dist[&amp;lt;realCity[i],realCity[j]&amp;gt;]:dist[&amp;lt;realCity[j],realCity[i]&amp;gt;]);&#xA;&#xA;&#xA;dvar interval itvs[1..n+1] size 1;&#xA;&#xA;&#xA;dvar sequence seq in all(i in 1..n+1) itvs[i]; &#xA;&#xA;execute&#xA;{&#xA;&#xA;cp.param.TimeLimit=60;&#xA;var f = cp.factory;&#xA;  cp.setSearchPhases(f.searchPhase(seq));&#xA;}&#xA;&#xA;tuple triplet { int c1; int c2; int d; };&#xA;{triplet} Dist = { &#xA;    &amp;lt;i-1,j-1,dist2[&amp;lt;i ,j &amp;gt;]&amp;gt;&#xA;           |  i,j in 1..n+1};&#xA;           &#xA;           &#xA;minimize endOf(itvs[n+1]) - (n+1);           &#xA;subject to&#xA;{&#xA;    startOf(itvs[1])==0; // break sym&#xA;    noOverlap(seq,Dist,true);   // nooverlap with a distance matrix&#xA;    last(seq, itvs[n+1]); // last node&#xA;}&#xA;          &#xA;          &#xA; int  x[&amp;lt;i,j&amp;gt; in Edges]=prev(seq,itvs[i],itvs[j])+prev(seq,itvs[j],itvs[i]); &#xA; int  isPrevFromNPlus1[i in 1..n]=prev(seq,itvs[i],itvs[n+1]);&#xA; int l=first({i | i in 1..n : isPrevFromNPlus1[i]==1});&#xA; edge el=&amp;lt;1,l&amp;gt;;&#xA; &#xA; execute&#xA; {&#xA; isPrevFromNPlus1;&#xA; x; &#xA; x[el]=1;&#xA; }&#xA; &#xA; // Let us check here that the constraints of the IP model are ok&#xA; assert forall (j in Cities)&#xA;        as:sum (&amp;lt;i,j&amp;gt; in Edges) x[&amp;lt;i,j&amp;gt;] + sum (&amp;lt;j,k&amp;gt; in Edges) x[&amp;lt;j,k&amp;gt;] == 2;&#xA;        &#xA;// Let us compute here the objective the IP way&#xA;int cost=sum (&amp;lt;i,j&amp;gt; in Edges) dist[&amp;lt;i,j&amp;gt;]*x[&amp;lt;i,j&amp;gt;];&#xA;&#xA;execute&#xA;{&#xA;writeln(cost);&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which gives&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4Ke8r.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4Ke8r.jpg&quot; alt=&quot;Berlin52 result&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;noOverlap(seq,Dist,true);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Dist is the transition time matrix&lt;/p&gt;&#xA;&lt;p&gt;NB: CPOptimizer also available in python through &lt;a href=&quot;https://pypi.org/project/docplex/&quot; rel=&quot;nofollow noreferrer&quot;&gt;docplex&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-03-21T08:40:15.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5956" PostTypeId="1" CreationDate="2021-03-21T09:26:56.960" Score="2" ViewCount="140" Body="&lt;p&gt;I am new to modelling language and specifically NEOS server. I aim to solve MINLP using Baron, through the NEOS server. So, far I have been able to write model file, data file and command file as required by the NEOS server and get my results. However, I was wondering if there was a way to automate the process and call NEOS using Python without making the use of Pyomo since that would require change of modelling and I am certain that I don't have enough time to learn that and implement it correctly. I would be incredibly grateful if I could be guided to get around this.&lt;/p&gt;&#xA;&lt;p&gt;Thank you for your time!&lt;/p&gt;&#xA;" OwnerDisplayName="user4387" LastActivityDate="2021-03-21T16:08:18.600" Title="How to use NEOS without using Pyomo" Tags="|optimization|modeling|modeling-languages|neos|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5957" PostTypeId="1" AcceptedAnswerId="5968" CreationDate="2021-03-21T12:49:26.630" Score="4" ViewCount="152" Body="&lt;p&gt;I want to implement a (simple) branching heuristic through a CPLEX generic callback. There are multiple overloads of the makeBranch method in CPLEX's C++ API, see &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_20.1.0/ilog.odms.cplex.help/refcppcplex/html/classes/Callback_Context.html#method_makeBranch&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;CPXLONG makeBranch(IloNumVar const &amp;amp; branchVar, IloNum bound, IloCplex::BranchDirection dir, IloNum estimate) const&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The function argument of interest is &lt;code&gt;estimate&lt;/code&gt;, which is an estimate for the objective value of the new child's relaxation. According to the docs, it is often a reasonable choice to use the objective value of the current node's relaxation. Unfortunately, I could not find any information on how CPLEX handles this estimate.&lt;/p&gt;&#xA;&lt;p&gt;Assuming I can cheaply calculate an accurate objective estimate for the newly created node's relaxation. Is it guaranteed that CPLEX processes the node with the best estimate first? In other words, is it possible to control the B&amp;amp;B search strategy via &lt;code&gt;estimate&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="3696" LastEditDate="2021-03-21T22:14:12.367" LastActivityDate="2021-03-22T12:54:54.860" Title="How does CPLEX handle objective estimates passed to the makeBranch method?" Tags="|cplex|c++|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5959" PostTypeId="1" CreationDate="2021-03-21T19:17:30.843" Score="11" ViewCount="4065" Body="&lt;p&gt;While looking through the job offerings, I noticed that everybody seems to be looking for experienced professionals, senior engineers, or at least three years of industry experience.&lt;/p&gt;&#xA;&lt;p&gt;Was this just a bad sample, or is there a trick to getting your first &amp;quot;real&amp;quot; job?&lt;/p&gt;&#xA;&lt;p&gt;How do you get started in industry after your master's, PhD or even postdoc degree?&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="1160" LastEditDate="2021-03-23T09:35:10.227" LastActivityDate="2021-03-23T17:02:24.250" Title="How can I do the jump from academia to industry?" Tags="|industry|or-careers|" AnswerCount="6" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5960" PostTypeId="2" ParentId="5959" CreationDate="2021-03-21T20:06:45.713" Score="7" Body="&lt;p&gt;I was on the job market a &lt;em&gt;very&lt;/em&gt; long time ago, so this information may be past its use-by date. When I interviewed at an industrial lab, I was told that they treated a successfully completed PhD as the equivalent of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; years of experience. I've forgotten the value they gave me for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, but I think &lt;span class=&quot;math-container&quot;&gt;$x\approx 3$&lt;/span&gt; for them (and would likely vary somewhat for other companies). This will depend on the specific employer, the specific position and how closely your graduate training aligns with what they need. Bottom line, if you are interested in a position and think you would be a good fit, it can't hurt to ask whether they treated a Ph.D. or post-doc as fulfilling the stated experience requirement.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-03-21T20:06:45.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5961" PostTypeId="2" ParentId="5959" CreationDate="2021-03-22T08:49:37.623" Score="4" Body="&lt;p&gt;It depends of course on what kind of job you are looking for, but the reason for companies looking for experience is just because then want to see a kind of track record. When we look for new people in our team (machine learning developers or (research) data scientists) we are mostly interested in project samples. Besides the appropriate knowledge you've gained in academia, we are interested in examples where you can show how well you can engineer things and on what level. The first thing I do is check people's Github page.&#xA;So a good advice is to get your hands dirty and start exploring the ways you can built up a track record that's in line with the job you want to have.&lt;/p&gt;&#xA;" OwnerUserId="329" LastActivityDate="2021-03-22T08:49:37.623" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5962" PostTypeId="1" AcceptedAnswerId="5969" CreationDate="2021-03-22T09:05:23.793" Score="2" ViewCount="236" Body="&lt;p&gt;I have an MILP where we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;t_k = \sum_i P_i\cdot C_{ik} : P_i\ \in \{0,1\}, C_{ik} \in I^+&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and our model is constrained by the number of times &lt;span class=&quot;math-container&quot;&gt;$t_k$&lt;/span&gt; is bigger than a certain value &lt;span class=&quot;math-container&quot;&gt;$T_k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left[\sum_k\left(t_k \ge T_k\right)\right] \ge N&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is the minimum number of constraints to be satisfied.&lt;/p&gt;&#xA;&lt;p&gt;Can this problem be solved in MILP and how? I am new to this domain and any leads would be very helpful.&lt;/p&gt;&#xA;" OwnerUserId="5162" LastEditorUserId="500" LastEditDate="2021-03-23T12:48:48.660" LastActivityDate="2021-03-23T12:49:13.870" Title="MILP constrained by the minimum number of satisfied constraints" Tags="|mixed-integer-programming|modeling|constraint|linearization|indicator-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5963" PostTypeId="2" ParentId="5959" CreationDate="2021-03-22T09:13:40.263" Score="3" Body="&lt;p&gt;For new comers from IT / Computer and Engineering fields, their first job / internship depends upon their final year project / research thesis. So write the details of your final project on the first page of your CV especially the tools and technologies used in it. Submit it to different technology companies. You'll surely be called for few interviews even if you are a fresh graduate but have done a good final year project. Rest depends upon your hard work and luck.&lt;/p&gt;&#xA;" OwnerUserId="5166" LastActivityDate="2021-03-22T09:13:40.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5964" PostTypeId="2" ParentId="5952" CreationDate="2021-03-22T10:53:22.933" Score="3" Body="&lt;p&gt;As you observed, such a problem is challenging to model and solve following a MILP approach. Boolean modeling approaches are tedious to write and don't scale well for this problem.&lt;/p&gt;&#xA;&lt;p&gt;Your problem can be modeled compactly by following a list-based approach instead of the classical Boolean approach, as you described in your question. This modeling approach offered by Hexaly is different from traditional MILP solvers. &lt;strong&gt;Note that Hexaly is commercial software.&lt;/strong&gt; Nevertheless, it is free for faculty and students.&lt;/p&gt;&#xA;&lt;p&gt;Since you're interested in scheduling the jobs on several machines, and not only one as described in your question, you may be more interested in the job shop scheduling problem than the traveling salesman problem. Below is the code snippet to model the job shop scheduling problem by using Hexaly Modeler:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function model() {&#xA;  // Integer decisions: start time of each activity&#xA;  // start[j][m] is the start time of the activity of job j which is processed on machine m&#xA;  start[j in 0..nbJobs-1][m in 0..nbMachines-1] &amp;lt;- int(0, maxStart);&#xA;  end[j in 0..nbJobs-1][m in 0..nbMachines-1] &amp;lt;- start[j][m] + processingTime[j][m];&#xA;&#xA;  // Precedence constraints between the activities of a job&#xA;  for [j in 0..nbJobs-1][k in 1..nbMachines-1]&#xA;    constraint start[j][machineOrder[j][k]] &amp;gt;= end[j][machineOrder[j][k-1]];&#xA;&#xA;  // Sequence of activities on each machine&#xA;  jobsOrder[m in 0..nbMachines-1] &amp;lt;- list(nbJobs);&#xA;&#xA;  for [m in 0..nbMachines-1] {&#xA;    // Each job has an activity scheduled on each machine&#xA;    constraint count(jobsOrder[m]) == nbJobs;&#xA;&#xA;    // Disjunctive resource constraints between the activities on a machine&#xA;    constraint and(0..nbJobs-2, i =&amp;gt; start[jobsOrder[m][i+1]][m] &amp;gt;= end[jobsOrder[m][i]][m]);&#xA;  }&#xA;&#xA;  // Minimize the makespan: end of the last activity of the last job&#xA;  makespan &amp;lt;- max[j in 0..nbJobs-1] (end[j][machineOrder[j][nbMachines-1]]);&#xA;  minimize makespan;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can write the same model in Python, Java, C#, or C++. Look at the job shop scheduling example &lt;a href=&quot;https://www.hexaly.com/docs/last/exampletour/jobshop.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Following this modeling approach, Hexaly finds near-optimal solutions in minutes on a standard computer for instances with thousands of jobs to schedule. Look at &lt;a href=&quot;https://www.hexaly.com/benchmarks&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hexaly benchmarks&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T05:19:20.453" LastActivityDate="2024-04-04T05:19:20.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5965" PostTypeId="2" ParentId="5954" CreationDate="2021-03-22T11:22:13.383" Score="2" Body="&lt;p&gt;Welcome to OR Stack Exchange.&lt;/p&gt;&#xA;&lt;p&gt;Your question is not clear. You are interested in special points in discrete optimization spaces. But you describe a mixed-variable problem involving both continuous variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and integer variables &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For a given &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, the theory of calculus of variations applies to the continuous subproblem on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. But I don't think you are interested in such a trivial answer.&lt;/p&gt;&#xA;&lt;p&gt;If you're interested in the discrete part of the problem, the notion &amp;quot;local optimum&amp;quot; can be defined too, in an analog way defined for continuous spaces. Please have a look at &lt;a href=&quot;https://en.wikipedia.org/wiki/PLS_(complexity)&quot; rel=&quot;nofollow noreferrer&quot;&gt;Polynomial Local Search complexity class&lt;/a&gt; definition and, even better, at &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/0022000088900463&quot; rel=&quot;nofollow noreferrer&quot;&gt;the seminal paper by David S. Johnson, Christos H. Papadimitriou, and Mihalis Yannakakis on this topic, namely &amp;quot;How easy is local search?&amp;quot;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-03-22T11:22:13.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5966" PostTypeId="2" ParentId="5959" CreationDate="2021-03-22T11:32:57.437" Score="4" Body="&lt;p&gt;I recently got a job as a junior software developer, coming from a biology post-doc. I think what got me the job were my personal programming projects, that clearly showed I was interested, and had some level of aptitude and ability - at least enough to be trainable in a reasonable time frame.&lt;/p&gt;&#xA;&lt;p&gt;Regardless of the exact switch, try looking at yourself as a candidate from their point of view. In all my applications, I acknowledged the experience I didn't have, but then always countered with what I did have, and why that is good.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2021-03-22T11:32:57.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5967" PostTypeId="1" AcceptedAnswerId="6037" CreationDate="2021-03-22T11:35:46.190" Score="1" ViewCount="788" Body="&lt;p&gt;I want to solve a job shop scheduling problem. I got &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; Jobs that have to be scheduled on &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; Machines. A Job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; has 2 or 3 Tasks &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and there is a known sequence of the Tasks of a Job. One Machine can only handle one Task at a time. A Job can only start at or after its Release date. Every Job has a Duedate. The goal is to minimize the tardiness of all Jobs.&lt;/p&gt;&#xA;&lt;p&gt;I got a working model for my problem. Only the last two constraints (constraints 5 and 6) are not working properly (or maybe more constraints). They should ensure that only one task is scheduled on a machine at a time. But in reality, several Tasks are scheduled on the same machine at the same time.&lt;/p&gt;&#xA;&lt;p&gt;I got 15 Jobs, but I show the data for 2 Jobs, so the code example is not too long. In my real code, I got the correct indents. I use Python with the solver Gurobi. I have the following code:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;#Create model.&#xA;Model = gp.Model(&amp;quot;Job_Shop_Scheduling&amp;quot;)&#xA;&#xA;#Number of Jobs i.&#xA;Jobs = range(1, 16)&#xA;#Number of Operations j.&#xA;NumofOperations = 3&#xA;Operations = range(1, NumofOperations+1)&#xA;#Number of Machines k.&#xA;NumofMachines = 5&#xA;Machines = range(1, NumofMachines+1)&#xA;&#xA;#Processing Times pij.&#xA;P = { #(Job_ID, Task_ID): Processing time&#xA;(1, 1): 2, (1, 2): 2, (1, 3): 1,&#xA;(2, 1): 3, (2, 2): 2, (2, 3): 2,&#xA;}&#xA;Release = { # Job_ID : Release&#xA;1:2,&#xA;2:1,&#xA;}&#xA;Duedate = { # Job_ID : Duedate&#xA;1:3,&#xA;2:8,&#xA;}&#xA;&#xA;#Predecessor is 1, if Task J form Job i follows Task j from the same job; 0 otherwise.&#xA;Predecessor = { #(Job_ID, Task_ID, TaskFollower_ID: 1 or 0&#xA;(1, 1, 1): 0, (1, 1, 2): 1, (1, 1, 3): 0,&#xA;(1, 2, 1): 0, (1, 2, 2): 0, (1, 2, 3): 1,&#xA;(1, 3, 1): 0, (1, 3, 2): 0, (1, 3, 3): 0,&#xA;(2, 1, 1): 0, (2, 1, 2): 1, (2, 1, 3): 0, &#xA;(2, 2, 1): 0, (2, 2, 2): 0, (2, 2, 3): 1, &#xA;(2, 3, 1): 0, (2, 3, 2): 0, (2, 3, 3): 0,&#xA;}&#xA;&#xA;#L is a big number.&#xA;L = 100&#xA;&#xA;#Completion of Job i.&#xA;Completion = {}&#xA;for i in Jobs:&#xA;  Completion[i] = Model.addVar(vtype=GRB.CONTINUOUS, lb = 0, name=&amp;quot;Completion(%s)&amp;quot; % (i))&#xA;#Tardiness of Job i.&#xA;Tardy = {}&#xA;for i in Jobs:&#xA;  Tardy[i] = Model.addVar(vtype=GRB.CONTINUOUS, lb = 0, name=&amp;quot;Tardy(%s)&amp;quot; % (i))&#xA;&#xA;#X is 1 if Task J of Job I follows Task j of Job i on Machine k; 0 otherwise.&#xA;X = {}&#xA;for i in Jobs:&#xA;  for j in Operations:&#xA;    for I in Jobs:&#xA;      for J in Operations:&#xA;        for k in Machines:&#xA;          X[i,j,I,J,k] = Model.addVar(vtype=GRB.BINARY, name=&amp;quot;X(%s,%s,%s,%s,%s)&amp;quot; % (i,j,I,J,k))&#xA;#Starting time of Job i.&#xA;S = {}&#xA;for i in Jobs:&#xA;  for j in Operations:&#xA;    S[i,j] = Model.addVar(vtype=GRB.CONTINUOUS, lb = 0, name=&amp;quot;S(%s,%s)&amp;quot; % (i,j))&#xA;&#xA;Model.setObjective(quicksum((Tardy[i]) for i in Jobs), sense=GRB.MINIMIZE)&#xA;#Constraints.&#xA;#1)&#xA;Model.addConstrs((Tardy[i] &amp;gt;= (Completion[i] - Duedate[i]) for i in Jobs), name=&amp;quot;1&amp;quot;)&#xA;&#xA;#2)&#xA;Model.addConstrs((Completion[i] &amp;gt;= S[i,j] + P[i,j] for i in Jobs for j in Operations), name=&amp;quot;2&amp;quot;)&#xA;&#xA;#3)&#xA;Model.addConstrs(((S[i, 1] &amp;gt;= Release[i])for i in Jobs), name=&amp;quot;3&amp;quot;)&#xA;&#xA;#4)&#xA;Model.addConstrs(((S[i,j] + P[i, j]) * Predecessor[i, j, J] &amp;lt;= S[i, J]\&#xA;for i in Jobs for j in Operations for J in Operations), name=&amp;quot;4&amp;quot;)&#xA;&#xA;#5)&#xA;Model.addConstrs(((S[i, j] + P[i, j] - (1 - X[i, j, I, J, k]) * L) &amp;lt;= S[I, J]\&#xA; for I in Jobs for i in Jobs if i != I for J in Operations for j in Operations if j != J for k in Machines), name=&amp;quot;5&amp;quot;)&#xA;&#xA;#6)&#xA;Model.addConstrs(((S[I, J] + P[I, J] - X[i, j, I, J, k] * L) &amp;lt;= S[i, j]\&#xA; for I in Jobs for i in Jobs if i != I for J in Operations for j in Operations if j != J for k in Machines), name=&amp;quot;6&amp;quot;)&#xA;&#xA;Model.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This model works, but some tasks are scheduled at the same time at one machine.&#xA;How can I solve this problem?&lt;/p&gt;&#xA;" OwnerDisplayName="user5167" LastEditorUserId="67" LastEditDate="2021-03-22T20:31:10.280" LastActivityDate="2021-03-31T20:52:59.510" Title="Job Shop Scheduling Problem: jobs are scheduled on the same machine at the same time" Tags="|linear-programming|python|scheduling|gurobi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5968" PostTypeId="2" ParentId="5957" CreationDate="2021-03-22T12:54:54.860" Score="3" Body="&lt;p&gt;The answer is basically no. You will find interesting information &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.1/ilog.odms.cplex.help/refdotnetcplex/html/T_ILOG_CPLEX_Cplex_NodeEvaluator.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; related to node evaluation and &lt;a href=&quot;https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.1/ilog.odms.cplex.help/refdotnetcplex/html/Fields_T_ILOG_CPLEX_Cplex_NodeSelect.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; related to node selection in the CPLEX B&amp;amp;B. In particular, by setting the parameter Cplex.NodeSelect to the value BestEst, you will activate the so-called Best-Estimate Search.&lt;/p&gt;&#xA;&lt;p&gt;As a competitor of CPLEX, we know CPLEX quite well :-) Now, the best would be to have an answer from CPLEX people themselves, of course. In the meantime, I hope that these pointers will help you.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-03-22T12:54:54.860" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5969" PostTypeId="2" ParentId="5962" CreationDate="2021-03-22T14:13:44.267" Score="4" Body="&lt;p&gt;You can introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_k$&lt;/span&gt; and linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_k x_k &amp;amp;\ge N\tag1\\&#xA;-t_k+T_k&amp;amp;\le M_k(1-x_k) &amp;amp;&amp;amp;\text{for $k\in K$}\tag2&#xA;\end{align}&lt;/span&gt;&#xA;Here, the “big-M” constant &lt;span class=&quot;math-container&quot;&gt;$M_k$&lt;/span&gt; is a small upper bound on &lt;span class=&quot;math-container&quot;&gt;$-t_k+T_k$&lt;/span&gt;. Because &lt;span class=&quot;math-container&quot;&gt;$t_k\ge 0$&lt;/span&gt;, you can take &lt;span class=&quot;math-container&quot;&gt;$M_k=T_k$&lt;/span&gt;, and the constraint simplifies to &lt;span class=&quot;math-container&quot;&gt;$t_k\ge T_k x_k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; forces at least &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; of the &lt;span class=&quot;math-container&quot;&gt;$x_k$&lt;/span&gt; variables to be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces the logical implication &lt;span class=&quot;math-container&quot;&gt;$x_k=1\implies t_k\ge T_k$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-03-23T12:49:13.870" LastActivityDate="2021-03-23T12:49:13.870" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5970" PostTypeId="1" AcceptedAnswerId="5974" CreationDate="2021-03-22T19:32:47.097" Score="5" ViewCount="771" Body="&lt;p&gt;Most MIP solver's API have special methods to add SOS1-constraints of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i \in I} c_i x_i \leq 1, \tag{1}$$&lt;/span&gt;&#xA;i.e. at most one of the binary variables &lt;span class=&quot;math-container&quot;&gt;$x_i, i \in I$&lt;/span&gt; is allowed to take a non-zero value. As far as I know, writing &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; as SOS1-constraint enables most solvers to use SOS1-branching, i.e. in Gurobi's Python API this means to&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;# Use this&#xA;model.addSOS(GRB.SOS_TYPE1, x, c)&#xA;# instead of&#xA;model.addConstr(sum(c[i]*x[i] for i in I) &amp;lt;= 1) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is there also a special method for a SOS1-constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i \in I} c_i x_i = 1,  \tag{2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;i.e. exactly one of the binary variables takes a non-zero value?&lt;/p&gt;&#xA;" OwnerUserId="5007" LastActivityDate="2021-03-23T20:17:52.637" Title="How to add a SOS1 equality constraint?" Tags="|gurobi|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5971" PostTypeId="1" CreationDate="2021-03-22T19:55:37.390" Score="8" ViewCount="110" Body="&lt;p&gt;I am looking for papers/resources that deal with timetabling problems in education. I want the resources to cover as much information as possible:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I don't have enough contact with people who are managing high schools. I cannot imagine all of their needs (constraints, objectives, on-line optimization, etc.).&lt;/li&gt;&#xA;&lt;li&gt;I am interested to know what the majority is actually doing to solve the problem.&lt;/li&gt;&#xA;&lt;li&gt;Is there similar applications (scheduling from an OR point of view, let's say to minimize the gaps in timetables, for example)?&lt;/li&gt;&#xA;&lt;li&gt;The state of the art to solving this problem.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3711" LastEditorUserId="3391" LastEditDate="2021-03-23T09:04:07.293" LastActivityDate="2021-03-23T09:04:07.293" Title="Real-life timetabling problems in education" Tags="|reference-request|scheduling|applications|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5972" PostTypeId="1" CreationDate="2021-03-22T20:07:51.930" Score="3" ViewCount="142" Body="&lt;p&gt;I would like to show that the function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is convex in &lt;span class=&quot;math-container&quot;&gt;$\rho\in [0,1)$&lt;/span&gt; under &lt;span class=&quot;math-container&quot;&gt;$s\in \mathbb{Z}^+$&lt;/span&gt;. When I use Sympy packages of Python to find &lt;span class=&quot;math-container&quot;&gt;$\displaystyle\frac{\partial^2 f(\rho)}{d\rho^2}$&lt;/span&gt;. I get an extremely long equation which is not really visually workable to prove convexity &lt;span class=&quot;math-container&quot;&gt;$\left(\text{i.e.,}~\displaystyle\frac{\partial^2 f(\rho)}{d\rho^2}&amp;gt;0\right)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f = \frac{\left(\rho s\right)^{s}}{2s! \rho s^{2} \left(1 - \rho\right)^{2} \left(\frac{\left(\rho s\right)^{s}}{\left(1 - \rho\right) s!} + \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right)}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there an alternative approach for this proof, e.g., partitioning the function?&lt;/p&gt;&#xA;&lt;p&gt;For completeness purposes, I am leaving the second order derivative obtained by Sympy and its associated Python code below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\displaystyle\frac{\partial^2 f(\rho)}{d\rho^2}=- \frac{\left(\rho s\right)^{s} \left(- \frac{2 \left(\rho s\right)^{s}}{\left(\rho - 1\right)^{3} s!} + \sum_{n=0}^{s - 1} \left(\frac{n^{2} \left(\rho s\right)^{n}}{\rho^{2} n!} - \frac{n \left(\rho s\right)^{n}}{\rho^{2} n!}\right) + \frac{2 s \left(\rho s\right)^{s}}{\rho \left(\rho - 1\right)^{2} s!} - \frac{s^{2} \left(\rho s\right)^{s}}{\rho^{2} \left(\rho - 1\right) s!} + \frac{s \left(\rho s\right)^{s}}{\rho^{2} \left(\rho - 1\right) s!}\right)}{2 \rho s^{2} \left(\rho - 1\right)^{2} \left(\left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right)^{2}\right) s!} - \frac{\left(\rho s\right)^{s} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right)^{2} s!} + \sum_{n=0}^{s - 1} \frac{n \left(\rho s\right)^{n}}{\rho n!} - \frac{s \left(\rho s\right)^{s}}{\rho \left(\rho - 1\right) s!}\right) \left(\frac{2 \left(\rho s\right)^{s}}{\left(\rho - 1\right)^{2} s!} + 2 \sum_{n=0}^{s - 1} \frac{n \left(\rho s\right)^{n}}{\rho n!} - \frac{2 s \left(\rho s\right)^{s}}{\rho \left(\rho - 1\right) s!}\right)}{2 \rho s^{2} \left(\rho - 1\right)^{2} \left(\left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right)^{3}\right) s!} + \frac{2 \left(\rho s\right)^{s} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right)^{2} s!} + \sum_{n=0}^{s - 1} \frac{n \left(\rho s\right)^{n}}{\rho n!} - \frac{s \left(\rho s\right)^{s}}{\rho \left(\rho - 1\right) s!}\right)}{\rho s^{2} \left(\rho - 1\right)^{3} \left(\left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right)^{2}\right) s!} - \frac{3 \left(\rho s\right)^{s}}{\rho s^{2} \left(\rho - 1\right)^{4} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right) s!} - \frac{\left(\rho s\right)^{s} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right)^{2} s!} + \sum_{n=0}^{s - 1} \frac{n \left(\rho s\right)^{n}}{\rho n!} - \frac{s \left(\rho s\right)^{s}}{\rho \left(\rho - 1\right) s!}\right)}{\rho^{2} s \left(\rho - 1\right)^{2} \left(\left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right)^{2}\right) s!} + \frac{2 \left(\rho s\right)^{s}}{\rho^{2} s \left(\rho - 1\right)^{3} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right) s!} + \frac{\left(\rho s\right)^{s} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right)^{2} s!} + \sum_{n=0}^{s - 1} \frac{n \left(\rho s\right)^{n}}{\rho n!} - \frac{s \left(\rho s\right)^{s}}{\rho \left(\rho - 1\right) s!}\right)}{\rho^{2} s^{2} \left(\rho - 1\right)^{2} \left(\left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right)^{2}\right) s!} - \frac{2 \left(\rho s\right)^{s}}{\rho^{2} s^{2} \left(\rho - 1\right)^{3} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right) s!} - \frac{\left(\rho s\right)^{s}}{2 \rho^{3} \left(\rho - 1\right)^{2} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right) s!} + \frac{3 \left(\rho s\right)^{s}}{2 \rho^{3} s \left(\rho - 1\right)^{2} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right) s!} - \frac{\left(\rho s\right)^{s}}{\rho^{3} s^{2} \left(\rho - 1\right)^{2} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right) s!}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import sympy as sy&#xA;sy.init_printing()&#xA;&#xA;rho = sy.symbols('rho', real=True)&#xA;n, s = sy.symbols('n s', integer= True)&#xA;&#xA;f = ((rho*s)**s / (2*sy.factorial(s)*s**2*rho*(1-rho)**2&#xA;            *(sy.Sum((s*rho)**n/sy.factorial(n), (n,0,s-1)) &#xA;              + (s*rho)**s/(sy.factorial(s)*(1-rho)))))&#xA;sy.simplify(sy.diff(sy.diff(f, rho), rho))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="518" LastActivityDate="2021-03-22T20:07:51.930" Title="Proving convexity for a function with summation and integer variable" Tags="|python|convexity|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5973" PostTypeId="2" ParentId="5959" CreationDate="2021-03-22T20:49:55.860" Score="18" Body="&lt;p&gt;Just apply for any job you find interesting and you think you can do well. The trick lies in convincing the people hiring that you are great value for money.&lt;/p&gt;&#xA;&lt;p&gt;Although this might seem obvious, my advice would be to also consider adjusting your salary expectations according to your industrial experience.&lt;/p&gt;&#xA;&lt;p&gt;Because asking for too much money is the greatest mistake I have seen academics make during interviews, I'll try to explain how this works from an employer's point of view. I know this quite well because I have been on both sides of the table, and I made that mistake myself in the early stages of my career.&lt;/p&gt;&#xA;&lt;p&gt;An academic who expects the same compensation as someone who has been working in the industry for an equivalent amount of time is unfortunately a hard ask, as the two skillsets are worth different amounts of money for very good reasons. If you believe that this is not true in your case, this nevertheless is what most interviewers think, so keep in mind that you'll need to convince them otherwise.&lt;/p&gt;&#xA;&lt;p&gt;In the private sector if you are good your salary goes up very quickly. However, asking for a lot of money without a track record is an easy way to get rejected, because for the same money we can find someone who has been doing xyz in practice for a long time. The reason is simply that an employer's risk in paying someone too much without hard proof that they can do the job is a hard ask.&lt;/p&gt;&#xA;&lt;p&gt;Note that this is neither about skill nor personal brilliance. It's about skills that are only really acquired by working industrially. Publishing papers is a very different skill than getting a product/feature/service to a state where someone will pay for it. The main differentiator is people's ability to work well with teams and deadlines. I have found that many academics tend to not be very well trained to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Produce results that can be readily used by other people&lt;/li&gt;&#xA;&lt;li&gt;Produce results in a handful of days and move on to the next thing&lt;/li&gt;&#xA;&lt;li&gt;Properly document details so that other teammates can reproduce their work&lt;/li&gt;&#xA;&lt;li&gt;Be happy with something that works even if they don't know why&lt;/li&gt;&#xA;&lt;li&gt;Work efficiently in teams&lt;/li&gt;&#xA;&lt;li&gt;Use modern productivity software&lt;/li&gt;&#xA;&lt;li&gt;Only do what they have been asked to do and ask management what to do next (rather than pursuing some cool random thing we don't care about)&lt;/li&gt;&#xA;&lt;li&gt;Communicate delays/issues to management as early as possible&lt;/li&gt;&#xA;&lt;li&gt;Properly estimate how long something will take&lt;/li&gt;&#xA;&lt;li&gt;Decide when to cut something off because we're out of time&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When an employer asks for X years of experience, what you see above is the real reason why. It's not about how good people are at math or algorithms. It's about lowering the employer's risk of a new employee being unable to produce results for a very long time, and we are willing to pay for that.&lt;/p&gt;&#xA;&lt;p&gt;As an entry-level professional who's making the switch, there are only really two options:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Acknowledge that you lack key experience and ask for a salary that reflects this, OR&lt;/li&gt;&#xA;&lt;li&gt;Walk into the interview like a boss and convince the interviewers that despite your lack of experience you can do all of these things well, and why.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Option 1. is safe, because people will give you time to accumulate experience and raise your salary on par with the results you produce.&lt;/p&gt;&#xA;&lt;p&gt;Option 2. is high-risk high-reward, because people will expect results from day 1. If you can deliver that's awesome and everyone is happy. If you can't, you're probably in trouble.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-03-22T21:42:48.803" LastActivityDate="2021-03-22T21:42:48.803" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5974" PostTypeId="2" ParentId="5970" CreationDate="2021-03-23T03:45:02.287" Score="7" Body="&lt;p&gt;I don't think&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; model.addSOS(GRB.SOS_TYPE1, x, c)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;is precisely the same as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; model.addConstr(sum(c[i]*x[i] for i in I) &amp;lt;= 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;unless you add bounds like &lt;span class=&quot;math-container&quot;&gt;$x_i \in [0,1/c_i]$&lt;/span&gt; to the SOS variables (and add another constraint to select one &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;For an &amp;quot;exactly one non-zero&amp;quot; you need the equality constraint.&lt;/p&gt;&#xA;&lt;p&gt;Also, note that in many cases binary variables are better than SOS1 constructs (unless you need big-M constraints). This has to do with better bounding and cuts. Even for SOS2, binary variables can work better. In practice, I use SOS1 variables very rarely: binary variables and indicator constraints can handle most cases. Some solvers will even try to replace SOS1 variables by binary variables in the presolve phase.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2021-03-23T20:17:52.637" LastActivityDate="2021-03-23T20:17:52.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5975" PostTypeId="1" CreationDate="2021-03-23T08:13:02.600" Score="3" ViewCount="183" Body="&lt;p&gt;Let us suppose that I have a &lt;span class=&quot;math-container&quot;&gt;$\max \min$&lt;/span&gt; objective function that only depends on one set of variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\underset{x}\max \underset{y}\min dy$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Associated with the linear set of constraints and right size real matrices and vectors &lt;span class=&quot;math-container&quot;&gt;$A, B, b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Ax + By\le b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(n,m)\in \mathbb N^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x\in \{0,1\}^n$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y\in \{0,1\}^m$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Meaning that the model tries to chose the values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; so that &lt;span class=&quot;math-container&quot;&gt;$\underset{y}\min dy$&lt;/span&gt; is maximized.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to linearize this objective function to get an ILP or a MILP at the end?&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="500" LastEditDate="2021-03-23T12:52:17.343" LastActivityDate="2021-03-23T12:52:17.343" Title="How to linearize a max min objective function?" Tags="|linear-programming|modeling|integer-programming|linearization|bilevel-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5976" PostTypeId="2" ParentId="5971" CreationDate="2021-03-23T09:01:46.983" Score="5" Body="&lt;p&gt;A. Schaerf wrote an academic 40-page survey on the topic in 1999: A Survey of Automated Timetabling. Artificial Intelligence Review 13, 87–127 (1999). &lt;a href=&quot;https://doi.org/10.1023/A:1006576209967&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1023/A:1006576209967&lt;/a&gt;. You can find the PDF file &lt;a href=&quot;https://cm.ihu.gr/arximidis/pdf/kazarlis/PE1/1d.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. In this survey, Schaerf discusses school timetabling, course timetabling, examination timetabling, and related scheduling problems. He presents common solution approaches, mainly heuristic ones since timetabling problems are generally highly combinatorial and hard to solve optimally in practical running times.&lt;/p&gt;&#xA;&lt;p&gt;A more recent 70-page report is available &lt;a href=&quot;https://backend.orbit.dtu.dk/ws/files/60366101/A_Comprehensive_Study.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; by S. Kristiansen and T.R. Stidsen. In addition to the topics addressed in Schaerf's survey, the authors list all the benchmark data available publicly, in particular through the famous International Timetabling Competition (look at the &lt;a href=&quot;https://www.sportscheduling.ugent.be/ITC2021/index.php&quot; rel=&quot;noreferrer&quot;&gt;2021 edition dedicated to sport timetabling&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Several educational groups, schools, and universities worldwide use LocalSolver to solve large-scale timetabling problems effectively. These problems are richer than the ones described in Schaerf's survey. To get an idea of the constraints and objectives in real-life timetabling, look at the questionnaire and answers on Table IV in &lt;a href=&quot;https://publications.waset.org/10004352/a-survey-on-the-requirements-of-university-course-timetabling&quot; rel=&quot;noreferrer&quot;&gt;this study&lt;/a&gt; done in a public Malaysian university.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-03-23T09:01:46.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5977" PostTypeId="2" ParentId="5959" CreationDate="2021-03-23T09:08:47.980" Score="8" Body="&lt;p&gt;&lt;em&gt;This answers is based on experience from computer science in Germany. Different fields and cultures might differ. However, I think that the core message of my answer is still somewhat applicable in any field, hence I've decided to post it.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;They may be asking for &amp;quot;industry experience&amp;quot;, but as virtually always with job postings, feel free to convince the interviewers with equivalent experience.&lt;/p&gt;&#xA;&lt;p&gt;When I did my doctorate, plenty (think, roughly half) of the doctoral candidates around me would switch to industry after completing their doctorate. The typical entry point for them would be as some senior developer or head of a small team position - and when I was at the point of leaving academia, I went the same path.&lt;/p&gt;&#xA;&lt;p&gt;Rather than as a blocker, I saw the requirement of previous &amp;quot;industry experience&amp;quot; as an opportunity to have something to talk about during the interview. The point is that interviewers from industry are often woefully unaware of how work at a university actually takes place. Thus, I used the interview for some explanations:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I could point out plenty of hands-on programming experience.&lt;/li&gt;&#xA;&lt;li&gt;I pointed out that I had to make technical decisions also on a higher level - although just in experimental/prototype projects, I nonetheless had to build software that was somewhat stable and would at least survive e.g. user studies without crashing.&lt;/li&gt;&#xA;&lt;li&gt;With some research assistants working for me, I could point out that I had some experience leading a small team of developers of different capabilities.&lt;/li&gt;&#xA;&lt;li&gt;I could highlight that, with research endeavours often being collaborative in nature, I was experienced with collaboration tools and the human interaction that goes along with it.&lt;/li&gt;&#xA;&lt;li&gt;Likewise, I could point out that I was well capable of communicating not only in domestic, but also in international contexts (thereby also underlining a sufficient level of English proficiency to discuss professional matters).&lt;/li&gt;&#xA;&lt;li&gt;All of the above are connected to good self-organization skills and the ability and willingness to stick to deadlines and manage time between multiple different tasks.&lt;/li&gt;&#xA;&lt;li&gt;They may not care about your scientific publication history, although being able and diligent enough to clearly document technical knowledge is, once again, a valuable skill also for industry software development.&lt;/li&gt;&#xA;&lt;li&gt;Related to that, an experience in preparing and giving presentations on topics of one's work, also in English, can also be advertised as valuable, e.g. for the internal training of colleagues.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Therefore: &lt;strong&gt;I think there are plenty of points to make that are relevant for industry work.&lt;/strong&gt; This is especially true if you are &lt;em&gt;not&lt;/em&gt; entering on a very junior level (where you are exactly told what you have to do), but at a somewhat higher level where you have some autonomy or responsibility for making certain decisions.&lt;/p&gt;&#xA;" OwnerUserId="5171" LastEditorUserId="5171" LastEditDate="2021-03-23T17:02:24.250" LastActivityDate="2021-03-23T17:02:24.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5979" PostTypeId="1" CreationDate="2021-03-23T12:23:43.010" Score="2" ViewCount="143" Body="&lt;p&gt;I am trying to model the attached online optmization problem in pyomo. Eventually, I am going to use the octeract solver to find the matrix soluions of W and G.&lt;/p&gt;&#xA;&lt;p&gt;I would like to ask advice about whether my code implementation of this problem is correct? Is the objective and constraints defined correctly to be passed to a solver?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/w8MTL.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/w8MTL.jpg&quot; alt=&quot;Optimization problem&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.environ import *&#xA;import numpy as np&#xA;import time&#xA;import itertools&#xA;&#xA;m = ConcreteModel()&#xA;&#xA;# constants&#xA;a1 = 1&#xA;a2 = 1&#xA;del_t = 5&#xA;M = 2 # set of active tasks&#xA;N = 4 # 4 time steps&#xA;# note; w_hat is energy over del_t (5 seconds) NOT power&#xA;w_hat = np.array([[5,5,5,5]]).T&#xA;E = np.array([[1.6,1.6]]).T&#xA;ones_G = np.ones((1,M))&#xA;ones_W = np.ones((M,1))&#xA;ones_WG = np.ones((N,1))&#xA;maxP = 0.14&#xA;d = np.array([20,40]) # deadline in seconds&#xA;start_time = time.time()&#xA;curr_time = 0 #start_time - time.time()&#xA;&#xA;&#xA;# dimensions of matrix, m x n&#xA;m.m = Param(within=NonNegativeIntegers)&#xA;m.n = Param(within=NonNegativeIntegers)&#xA;m.N = Param(within=NonNegativeIntegers)&#xA;&#xA;&#xA;# index set, indexing the matrix or vector&#xA;m.I = RangeSet(1,M)&#xA;m.K = RangeSet(1,N)&#xA;m.phi = Param(m.I, m.K,within=Reals)&#xA;m.energy = Param(m.I, m.K,within=Reals)&#xA;        &#xA;m.W = Var(m.I,m.K,domain=NonNegativeReals)&#xA;m.G = Var(m.I,m.K,domain=NonNegativeReals)&#xA;&#xA;iter_At = range(M)&#xA;iter_N = range(N)&#xA;&#xA;m.obj = Objective(expr= np.linalg.norm(np.matmul(ones_G,m.G),ord=1) + np.linalg.norm(np.matmul(ones_G,m.G),ord=np.inf) + sum( (N - m.phi[i,k] )**2 for i,k in itertools.product(iter_At,iter_N) ) )&#xA;&#xA;m.c1 = Constraint(expr = np.matmul((m.W).T,ones_W) &amp;lt;= w_hat)&#xA;m.c2 = Constraint(expr = np.matmul((m.W + m.G),ones_WG) == E )&#xA;&#xA;&#xA;def WG_constraint_rule(m, i,maxP,del_t,curr_time):&#xA;    for k in m.K:&#xA;        if curr_time + k*del_t &amp;lt;= d[i] + curr_time:&#xA;            return (m.W[i,k] + m.G[i,k] &amp;lt;= maxP*del_t)&#xA;        else:&#xA;            return (m.W[i,k] + m.G[i,k] == 0)&#xA;&#xA;m.c3 = Constraint(m.I, rule=WG_constraint_rule)&#xA;&#xA;&#xA;def energy_constraint_rule(m, i,maxP, del_t,curr_time,E):&#xA;    for k in m.K:&#xA;         return (m.energy[i,k] == E[i] - sum( m.W[i,j] + m.G[i,j] for j in k)  ) &#xA;&#xA;m.c4 = Constraint(m.I, rule=energy_constraint_rule)&#xA;&#xA;def phi_constraint_rule(m, i,maxP, del_t,curr_time):&#xA;    for k in m.K:&#xA;        return (m.phi[i,k] == d[i] - curr_time + (k*del_t) - m.energy[i,k]/maxP )&#xA;&#xA;m.c5 = Constraint(m.I, rule=phi_constraint_rule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;At the moment, I have the following error but I am not too concerned about this. I just want to know if my definitions are correct.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iEcSX.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iEcSX.jpg&quot; alt=&quot;Error&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thank you. :)&lt;/p&gt;&#xA;" OwnerUserId="4945" LastActivityDate="2021-06-03T07:33:57.890" Title="Model definition in pyomo to solve online optimization problem" Tags="|modeling|convex-optimization|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5980" PostTypeId="1" CreationDate="2021-03-23T17:23:08.187" Score="0" ViewCount="135" Body="&lt;p&gt;There are a number of orders, which needs to be shipped. For each order, there may be 1 to 3 route options. The problem here is to find out the best allocation (combination) of orders among these routes.&lt;/p&gt;&#xA;&lt;p&gt;Assumptions:&lt;/p&gt;&#xA;&lt;p&gt;Suppose the full capacity and per km transport cost for each type of truck are:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;7.6(size) -&amp;gt; 5300(weight), 4.4(cost per km);&#xA;9.6(size) -&amp;gt; 7100(weight), 4.81(cost per km);&#xA;15(size) -&amp;gt; 12000(weight), 6.34(cost per km);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Suppose all routes has 3 number of transit times to reach the destination, then:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;transit cost of each route = transit times*order quantity allocated to this route*4.5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Suppose transport cost of route is based on number of trucks used and the travling distance, then:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;transport cost of each route = number of trucks allocated to this route*route distance&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;// Variables&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x[j] -&amp;gt; 0-1 variables, if route x1,x2,x3....xj is used.&#xA;a[i][j] -&amp;gt; is the weight proportion of order i allocated to route j&#xA;t[j][s] -&amp;gt; truck number of certain size needed for each routes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Objective Function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Min (total tranpsort cost + total transit cost) -&amp;gt; MinΣ(x[j]*t[j][s]*Distance[j]*Cost[j] + x[j]*a[i][j]*OrderQuantity[i]*TransitTimes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Subject to:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1. if a[i][j] is the proportion of weight allocation among the feasible routes of an order, then:&#xA;a1+a2+a3 = 1&#xA;2. orders combined together must choose the same route&#xA;3. orders combined together must be the same route type&#xA;4. all orders must be allocated to one or more trucks and shipped&#xA;5. the chosen of the truck size must be within the truck options for each route&#xA;6. total weight loaded on the truck must not exceed the total capacity of the truck&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is how the input date may look like:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/w0wZW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/w0wZW.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is the CSV formate of the input data:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;OrderID,Order_Category,Quantity,Weight,Route1,Route1_Distance,Route1_Type,Route1_TruckOption,Route2,Route2_Distance,Route2_Type,Route2_TruckOption,Route3,Route3_Distance,Route3_Type,Route3_TruckOption&#xA;1,B,2000,4000,010W,2000,1,13.5-15,010WE,1750,1,13.5-15,022X,2200,1,13.5-15&#xA;2,B,4000,8000,010W,2000,1,13.5-15,010WE,1750,1,13.5-15,022X,2200,1,13.5-15&#xA;3,B,1000,2000,010W,2000,1,13.5-15,010WE,1750,1,13.5-15,022X,2200,1,13.5-15&#xA;4,B,3500,7000,010WE,1750,1,13.5-15,022X,2200,1,13.5-15,,,,&#xA;5,B,2500,5000,020WB,2100,1,13.5-15,022X,2200,1,13.5-15,,,,&#xA;6,B,2500,5000,311W,1500,1,13.5-15,022X,2200,1,13.5-15,,,,&#xA;7,B,1000,2000,755WF,3500,2,7.6-9.6,755WE,3300,2,7.6-9.6,,,,&#xA;8,C,1000,2000,471W,3200,1,13.5-15,010WE,1750,1,13.5-15,022X,2200,1,13.5-15&#xA;9,C,1500,3000,471W,3200,1,13.5-15,010WE,1750,1,13.5-15,022X,2200,1,13.5-15&#xA;10,C,2000,4000,769WX,2750,2,7.6-9.6,663WA,2600,2,7.6-9.6,,,,&#xA;11,C,1000,2000,769WX,2750,2,7.6-9.6,754W,2900,2,7.6-9.6,663WA,2600,2,7.6-9.6&#xA;12,C,2000,4000,769WX,2750,2,7.6-9.6,755WE,3100,2,7.6-9.6,,,,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The optimization result might look like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YgpvQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YgpvQ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;My questions:&#xA;I am not sure how to write the constraints 2,3,5,6.&#xA;In particular, I have no idea to:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1). model the connection between the weight allocated to a route and the associated truck size and quantity needed for the same route (i.e. how to write the objective function properly to represent the total transport cost); &#xA;2). make sure orders combined using the same route and same route type&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;An MIP code example using Google OR tools or Gurobi python would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="5174" LastActivityDate="2021-03-23T17:23:08.187" Title="Mixed Integer Programming - Model Formulation for A Resource Allocation Problem" Tags="|optimization|mixed-integer-programming|gurobi|or-tools|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5981" PostTypeId="1" CreationDate="2021-03-24T03:37:24.600" Score="2" ViewCount="545" Body="&lt;p&gt;I have two variables &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, in which &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is the amount of goods and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is the amount of boxes of the given sizes. So &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; (box size + number) is dependent on a (goods quantity). If &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is allocated to a given path, then &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; will increase based on &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, based on a rule to increase the number of boxes and select the best size.&lt;/p&gt;&#xA;&lt;p&gt;The objective is to minimize the total cost of using boxes for all paths (i.e. tells the proportion of &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; that is allocated to &lt;code&gt;path_1&lt;/code&gt;, &lt;code&gt;path_2&lt;/code&gt;, &lt;code&gt;path_n&lt;/code&gt;, where the combined cost (spending on boxes) is minimal.)&lt;/p&gt;&#xA;&lt;p&gt;Problem: How to express the relationship between &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; in the model? Should I model their dependency in the objective function or in the constraint? If constraint, how to describe such a relationship?&lt;/p&gt;&#xA;" OwnerUserId="5174" LastEditorUserId="123" LastEditDate="2021-03-24T07:39:00.987" LastActivityDate="2021-12-22T21:44:02.740" Title="Mixed Integer Programming - How to model the dependency of two variables in an objective function" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5982" PostTypeId="2" ParentId="5981" CreationDate="2021-03-24T07:23:54.453" Score="1" Body="&lt;p&gt;You should model this using a set of constraints. Off the cuff you could try this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{array}{ll}&#xA;\text{minimize} &amp;amp; \sum_{i} c_ib_i \\&#xA;\text{subject to} &amp;amp; a \leq A_i \rightarrow b_i = n_i&#xA;\end{array}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; is meant to be the path allocation and &lt;span class=&quot;math-container&quot;&gt;$n_i$&lt;/span&gt; the number of boxes assigned. The &lt;span class=&quot;math-container&quot;&gt;$\rightarrow$&lt;/span&gt; constraint is called an indicator constraint, and most modern MIP solvers support it. I would start with this.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2021-03-24T07:23:54.453" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5983" PostTypeId="1" CreationDate="2021-03-24T08:48:22.787" Score="3" ViewCount="208" Body="&lt;p&gt;I have the following mixed-integer optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\max_{x,y} \quad &amp;amp; \sum_i x_i - \|wx\|_2 \\&#xA;\text{s.t.} \quad &amp;amp; \sum_i x_i  \leq A \\ &#xA;\quad &amp;amp; x \leq x_{\max} y \\&#xA;\quad &amp;amp; x \geq x_{\min} y  \\&#xA;\quad &amp;amp; y \in \{0,1\} &#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; is a positive constant, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a positive constant, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$n \times 1$&lt;/span&gt; vector of positive real values, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$n \times 1$&lt;/span&gt; binary vector, &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt; diagonal matrix, and &lt;span class=&quot;math-container&quot;&gt;$x_{\min}, x_{\max}$&lt;/span&gt; are each &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt; diagonal matrices with positive constants. This optimization problem is solved online &lt;strong&gt;(where the diagonal values of &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; are changing in each iteration). For fixed values in &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, the oscillations can still occur.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;When I tried to solve this problem numerically, the optimal values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are oscillating in each iteration. This is expected because of the hard constraints imposed. Is there a way to prevent these oscillations with relaxation or hysteresis on the &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;? Or possibly adding another constraint/variable to prevent the oscillations?&lt;/p&gt;&#xA;&lt;p&gt;Your help will be much appreciated.&lt;/p&gt;&#xA;&lt;p&gt;Here is an example of the kind of oscillations I get. For this plot, &lt;span class=&quot;math-container&quot;&gt;$x_{\min} = 6$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{\max} = 32$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$A = 50$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$5 \times 1$&lt;/span&gt; vector. So from this plot, its clear that the values jump from 0 to 6 (since this is imposed by the hard constraints in the problem). But I want to prevent this kind of behavior (i.e., keep constant and only change based on some kind of epsilon relaxation).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HEdon.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HEdon.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5179" LastEditorUserId="500" LastEditDate="2021-04-02T15:51:18.560" LastActivityDate="2021-04-02T15:51:18.560" Title="Oscillations with (online) mixed-integer optimization problem" Tags="|optimization|mixed-integer-programming|convex-optimization|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5984" PostTypeId="2" ParentId="5983" CreationDate="2021-03-24T13:21:57.477" Score="3" Body="&lt;p&gt;If I understand the problem correctly, the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables decide which components of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are non-zero, and the rest is essentially some variant of a least-square problem.&lt;/p&gt;&#xA;&lt;p&gt;There are several ways you can prevent a solution &lt;span class=&quot;math-container&quot;&gt;$x^{*}, y^{*}$&lt;/span&gt; from deviating too much from a previous solution &lt;span class=&quot;math-container&quot;&gt;$\bar{x}, \bar{y}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Adding extra constraints&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Restrict the number of components of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; that can be changed. For instance, you may add a constraint specifying that only &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; elements of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; may be changed.&#xA;This can be done with a single &lt;em&gt;linear&lt;/em&gt; constraints on &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; using a &lt;a href=&quot;https://en.wikipedia.org/wiki/Hamming_distance&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hamming distance&lt;/a&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j | \bar{y}_{j} = 0} y_{j} + \sum_{j | \bar{y}_{j} = 1} (1 - y_{j}) \leq K,&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$K \geq 0$&lt;/span&gt; is the number of coordinates you allow to be modified.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Explicitly restrict the distance between &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\| x - \bar{x}\| \leq D,&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$D \geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\|.\|$&lt;/span&gt; is any norm you want. A sub-case is to set a box around &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; and constraint &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to lie in that box:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\bar{x} - \epsilon \leq x \leq \bar{x} + \epsilon.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Changing the objective&lt;/h2&gt;&#xA;&lt;p&gt;A simple way would be to add a so-called &amp;quot;proximal term&amp;quot; to the objective, which would penalize large deviations from a reference point &lt;span class=&quot;math-container&quot;&gt;$\bar{x}, \bar{y}$&lt;/span&gt;.&#xA;The objective would become, e.g.,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\| w x \|_{2} + \rho \|x - \bar{x}\|,&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\rho \geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\|.\|$&lt;/span&gt; is any norm you want; common choices include &lt;span class=&quot;math-container&quot;&gt;$\ell_{1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\ell_{2}$&lt;/span&gt; norms.&#xA;You can also square the norm, i.e., add a term &lt;span class=&quot;math-container&quot;&gt;$\rho \|x - \bar{x}\|^{2}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that setting &lt;span class=&quot;math-container&quot;&gt;$\bar{x} = 0$&lt;/span&gt; yields the so-called regularization terms in machine-learning literature.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="123" LastEditDate="2021-04-02T13:42:58.443" LastActivityDate="2021-04-02T13:42:58.443" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="5985" PostTypeId="2" ParentId="5944" CreationDate="2021-03-24T21:39:32.670" Score="2" Body="&lt;p&gt;I'm still not sure I understand the question, but I'll suggest an answer to what I think is being asked. I'm going to assume that an &lt;em&gt;a priori&lt;/em&gt; upper bound &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; exists for &lt;span class=&quot;math-container&quot;&gt;$o_t$&lt;/span&gt;. To keep what follows somewhat compact, I'm going to assume that &lt;span class=&quot;math-container&quot;&gt;$\mathcal{M} = \lbrace 20, 21, 22, 23\rbrace$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$O=6$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To start, for each &lt;span class=&quot;math-container&quot;&gt;$t\in T$&lt;/span&gt; generate a random sample of &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; item ages, arranged as a vector &lt;span class=&quot;math-container&quot;&gt;$v^t$&lt;/span&gt;. Using my example with &lt;span class=&quot;math-container&quot;&gt;$O=6$&lt;/span&gt;, you might get &lt;span class=&quot;math-container&quot;&gt;$v^t=(22, 23, 23, 20, 22, 23)$&lt;/span&gt; for some particular &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Next, compute for each &lt;span class=&quot;math-container&quot;&gt;$n \in \lbrace 1, \dots, O\rbrace$&lt;/span&gt; a vector &lt;span class=&quot;math-container&quot;&gt;$a_{t,n} = (a_{t,n}^{m_1},\dots,a_{t,n}^{m_N})$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{M}=\lbrace m_1,\dots,m_N\rbrace$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_{t,n}^m$&lt;/span&gt; is the number of items among the first &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; entries of &lt;span class=&quot;math-container&quot;&gt;$v^t$&lt;/span&gt; having age &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;. Continuing the example, we would have &lt;span class=&quot;math-container&quot;&gt;$a_{t,1} = (0, 0, 1, 0)$&lt;/span&gt; (one item of age 22), &lt;span class=&quot;math-container&quot;&gt;$a_{t,2} = (0, 0, 1, 1)$&lt;/span&gt; (one item each ages 22 and 23), ..., &lt;span class=&quot;math-container&quot;&gt;$a_{t,6} = (1, 0, 2, 3)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now in the MIP model we add binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{t,n}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$t\in T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n\in \lbrace 1,\dots,O\rbrace$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$z_{t,n}=1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$o_t = n$&lt;/span&gt;. We add the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{n=1}^O z_{t,n} \le 1 \quad \forall t\in T\quad  (1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$o_t = \sum_{n=1}^O n z_{t,n} \quad \forall t\in T \quad (2)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\epsilon_t^m = \sum_{n=1}^O a_{t,n}^m z_{t,n} \quad \forall m\in \mathcal{M},\ \forall t\in T. \quad (3)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that (1) allows all the &lt;span class=&quot;math-container&quot;&gt;$z_{t,n}$&lt;/span&gt; to be 0 at a particular time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, in which case &lt;span class=&quot;math-container&quot;&gt;$o_t = 0$&lt;/span&gt; in (2). (1) ensures that at each time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; a single order size is selected, (2) makes &lt;span class=&quot;math-container&quot;&gt;$o_t$&lt;/span&gt; the selected size and (3) ensures that the random age counts for that period and order size are used.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-03-24T22:08:19.807" LastActivityDate="2021-03-24T22:08:19.807" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5986" PostTypeId="1" AcceptedAnswerId="5987" CreationDate="2021-03-25T00:10:45.223" Score="3" ViewCount="292" Body="&lt;p&gt;I am surprised I couldn't find an already written answer for my question in the internet.&lt;/p&gt;&#xA;&lt;p&gt;I want to linearize &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; different of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; for two nonegative integer decision variables. I am not considering using Constraint Programming which I know that it is better for such constraints, only ILP.&lt;/p&gt;&#xA;&lt;p&gt;My idea was that I use two sets of constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x \ge y + 0.5 \text{ OR } x \le y - 0.5$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, with binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; rightly chosen constant depending on the domains of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x \ge (y + 0.5)z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x \le (y - 0.5) + Mz$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then linearize the first constraint.&lt;/p&gt;&#xA;&lt;p&gt;However, one of my friend suggested me: &amp;quot;compute &lt;span class=&quot;math-container&quot;&gt;$x-y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y-x$&lt;/span&gt;, take maximum value of these two variables, for instance using this next picture:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HYhqp.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HYhqp.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And then you have the distance between &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; which you impose to be positive.&lt;/p&gt;&#xA;&lt;p&gt;What is the best way?&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="35" LastEditDate="2021-03-25T00:17:43.637" LastActivityDate="2021-03-25T00:53:53.613" Title="Linearize x different of y in ILP" Tags="|mixed-integer-programming|linearization|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5987" PostTypeId="2" ParentId="5986" CreationDate="2021-03-25T00:32:33.273" Score="12" Body="&lt;p&gt;I recommend a third approach, similar to yours but linear:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x + 1 - y &amp;amp;\le M_1 z \tag1 \\&#xA;y + 1 - x &amp;amp;\le M_2 (1-z) \tag2 \\&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$z=0 \implies x + 1 \le y$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$z=1 \implies y + 1 \le x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This idea goes back at least to &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/opre.8.2.219&quot; rel=&quot;noreferrer&quot;&gt;Manne, &lt;em&gt;On the Job-Shop Scheduling Problem&lt;/em&gt; (1960)&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In some modeling languages, you can also enforce these implications by using indicator constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-03-25T00:53:53.613" LastActivityDate="2021-03-25T00:53:53.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5989" PostTypeId="1" CreationDate="2021-03-25T15:13:07.803" Score="3" ViewCount="1640" Body="&lt;p&gt;Initially, I had the below objective function&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max \sum_{u=1}^{U}\sum_{c=1}^{C}x_{u,c}d_{u,c}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x_{u,c}$&lt;/span&gt; are optimization variables&lt;/p&gt;&#xA;&lt;p&gt;I modelled this in CPLEX as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   IloExpr  objFun (env); &#xA;    for(int u = 0; u &amp;lt; U; u++){&#xA;          for(int c = 0; c &amp;lt; C; c++){&#xA;         objFun += x[u][c]* d[u][c];&#xA;        }&#xA;    }&#xA;    model.add(IloMaximize(env, objFun));  &#xA;    objFun.end();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now, I have a slightly different objective&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{maximize} \min_{u} \sum_{c=1}^{C}x_{u,c}d_{u,c}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now how can I model this?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2021-03-26T07:13:54.250" LastActivityDate="2021-03-26T07:13:54.250" Title="How can I express this max-min in CPLEX?" Tags="|modeling|cplex|convex-optimization|minimax|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5990" PostTypeId="2" ParentId="5914" CreationDate="2021-03-25T15:42:58.590" Score="3" Body="&lt;p&gt;Here are few more YouTube channels related to OR&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/channel/UC2FECDvMphKdqi8RnFGD3Bg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimus Prime&lt;/a&gt; -  Lecture series on Introduction of LP and MILP by Professor: Alberto Del Pia, University of Wisconsin-Madison&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/user/TheORSocietyUK&quot; rel=&quot;nofollow noreferrer&quot;&gt;The OR Society&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/user/GAMSLessons&quot; rel=&quot;nofollow noreferrer&quot;&gt;GAMS Lessons&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/user/AIMMSChannel&quot; rel=&quot;nofollow noreferrer&quot;&gt;AIMMS Channel&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/channel/UC6Yt3duW9a2IFj3nO2ZL6Ew/featured&quot; rel=&quot;nofollow noreferrer&quot;&gt;AMPL Optimization&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCZ1IbFCz_jiB7-RwOoTLCkg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Supply Chain Academy&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCB_MDxNsfAX9nGIy82EGS0A&quot; rel=&quot;nofollow noreferrer&quot;&gt;NeEDS - Network of European Data Scientists&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCsZ5SOyr3XLIa3zXJsxkeXQ/featured&quot; rel=&quot;nofollow noreferrer&quot;&gt;James Davis&lt;/a&gt; -  Videos on LP and MILP methods and algorithms&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/c/YongWang/about&quot; rel=&quot;nofollow noreferrer&quot;&gt;Yong Wang&lt;/a&gt; - This Youtube channel hosts some of the courses taught by Dr. Yong Wang&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/c/DecisionMaking101/featured&quot; rel=&quot;nofollow noreferrer&quot;&gt;Decision Making 101&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCP9j0k-u0Stlm3x-aV-NdVQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Operations Management 101&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="208" LastActivityDate="2021-03-25T15:42:58.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5991" PostTypeId="2" ParentId="5989" CreationDate="2021-03-25T18:19:32.927" Score="9" Body="&lt;p&gt;You can model this as a maxmin problem by introducing an auxiliary variable &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max&amp;amp;\quad\theta &amp;amp;\\&#xA;\text{s.t.}&amp;amp;\quad\theta \leq \sum_{c=1}^C x_{uc}d_{uc} &amp;amp; \forall u=1,\dots,U&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For future reference, if in contrast you had a &lt;strong&gt;minmax&lt;/strong&gt; objective instead of a &lt;strong&gt;maxmin&lt;/strong&gt; objective, you could apply the same trick:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min&amp;amp;\quad\theta &amp;amp;\\&#xA;\text{s.t.}&amp;amp;\quad\theta \geq \sum_{c=1}^C x_{uc}d_{uc} &amp;amp; \forall u=1,\dots,U&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="123" LastEditDate="2021-03-25T20:20:34.573" LastActivityDate="2021-03-25T20:20:34.573" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5992" PostTypeId="2" ParentId="5989" CreationDate="2021-03-25T18:20:00.417" Score="6" Body="&lt;p&gt;Maximize an auxiliary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to the constraints &lt;span class=&quot;math-container&quot;&gt;$z\le \sum_{c=1}^C d_{u,c}x_{u,c}\ \forall u$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-03-25T18:20:00.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5993" PostTypeId="1" CreationDate="2021-03-26T10:31:14.863" Score="2" ViewCount="246" Body="&lt;p&gt;I'm using CVXPY. Given a &lt;span class=&quot;math-container&quot;&gt;$2\times2$&lt;/span&gt; matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, is it possible to add a singularity constraint?&lt;/p&gt;&#xA;&lt;p&gt;Anything equivalent to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$|A| = 0$&lt;/span&gt;: The determinant is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\operatorname{rank}(A) \leq 1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Smallest eigenvalue is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;etc...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3903" LastEditorUserId="123" LastEditDate="2021-03-26T11:21:15.990" LastActivityDate="2021-03-26T11:21:15.990" Title="Matrix Singularity Constraint" Tags="|constraint|cvxpy|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="5994" PostTypeId="2" ParentId="5993" CreationDate="2021-03-26T10:41:49.973" Score="6" Body="&lt;p&gt;No, it is an intrinsically non-convex constraint. Just take a diagonal matrix, and the feasible set would be the coordinate axes, i.e. nonconvex and highly ill-conditioned as the feasible set has measure 0.&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2021-03-26T10:41:49.973" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5995" PostTypeId="1" CreationDate="2021-03-26T14:51:34.840" Score="1" ViewCount="230" Body="&lt;p&gt;Has been crossposted in &lt;a href=&quot;https://stackoverflow.com/questions/66818222/modified-bus-scheduling-problem-question-in-ortools&quot;&gt;stackoverflow&lt;/a&gt;. I want to solve the bus scheduling problem using ortools with some minor modifications. In my case, the max number of drivers &lt;strong&gt;is&lt;/strong&gt; known. The modifications I would like to have in the code are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Shifts can overlap, i.e. drivers can work in parallel&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Shifts must be consecutive&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Breaks of drivers cannot overlap&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Max, min driving and max working time are the same as in predefined fixed duty&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;TL;DR: The range of working hours is from 07:00 am to 24:00 (midnight). If we have 2 bus drivers for this schedule, I would accept an allocation to cover the daily duty based on 12-h driver shift as following:&#xA;Driver 1: 07:00 - 19:00 with a break at 13:00&#xA;Driver 2: 12:00 - 24:00 with a break at 14:00 (basically no overlap with Driver 1 break)&lt;/p&gt;&#xA;&lt;p&gt;We can see that shifts can be covered by both drivers and what I mean by consecutive hours is that solutions that satisfy a 12-h driver shift solution in the form of 07:00-11:00 + 14:00-15:00 + 17:00-24:00 should not be acceptable.&lt;/p&gt;&#xA;&lt;p&gt;Here's the code I am using:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Copyright 2010-2018 Google LLC&#xA;# Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;);&#xA;# you may not use this file except in compliance with the License.&#xA;# You may obtain a copy of the License at&#xA;#&#xA;#     http://www.apache.org/licenses/LICENSE-2.0&#xA;#&#xA;# Unless required by applicable law or agreed to in writing, software&#xA;# distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&#xA;# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#xA;# See the License for the specific language governing permissions and&#xA;# limitations under the License.&#xA;&amp;quot;&amp;quot;&amp;quot;This model implements a bus driver scheduling problem.&#xA;&#xA;Constraints:&#xA;- max driving time per driver &amp;lt;= 12h&#xA;- max working time per driver &amp;lt;= 12h&#xA;- min working time per driver &amp;gt;= 12h (soft)&#xA;- 30 min break after each 4h of driving time per driver&#xA;- 10 min preparation time before the first shift&#xA;- 15 min cleaning time after the last shift&#xA;- 2 min waiting time after each shift for passenger boarding and alighting&#xA;&amp;quot;&amp;quot;&amp;quot;&#xA;&#xA;import collections&#xA;import math&#xA;&#xA;from google.protobuf import text_format&#xA;from absl import app&#xA;from absl import flags&#xA;from ortools.sat.python import cp_model&#xA;&#xA;FLAGS = flags.FLAGS&#xA;&#xA;flags.DEFINE_string('output_proto', '',&#xA;                    'Output file to write the cp_model proto to.')&#xA;flags.DEFINE_string('params', 'num_search_workers:8,log_search_progress:true',&#xA;                    'Sat solver parameters.')&#xA;flags.DEFINE_integer('instance', 1, 'Instance to select (1, 2, 3).', 1, 3)&#xA;&#xA;SAMPLE_SHIFTS_SMALL = [&#xA;    #&#xA;    # column description:&#xA;    # - shift id&#xA;    # - shift start time as hh:mm string (for logging and readability purposes)&#xA;    # - shift end time as hh:mm string (for logging and readability purposes)&#xA;    # - shift start minute&#xA;    # - shift end minute&#xA;    # - shift duration in minutes&#xA;    #&#xA;    [0, '07:00', '07:30', 420, 450, 30],&#xA;    [1, '07:30', '08:00', 450, 480, 30],&#xA;    [2, '08:00', '08:30', 480, 510, 30],&#xA;    [3, '08:30', '09:00', 510, 540, 30],&#xA;    [4, '09:00', '09:30', 540, 570, 30],&#xA;    [5, '09:30', '10:00', 570, 600, 30],&#xA;    [6, '10:00', '10:30', 600, 630, 30],&#xA;    [7, '10:30', '11:00', 630, 660, 30],&#xA;    [8, '11:00', '11:30', 660, 690, 30],&#xA;    [9, '11:30', '12:00', 690, 720, 30],&#xA;    [10, '12:00', '12:30', 720, 750, 30],&#xA;    [11, '12:30', '13:00', 750, 780, 30],&#xA;    [12, '13:00', '13:30', 780, 810, 30],&#xA;    [13, '13:30', '14:00', 810, 840, 30],&#xA;    [14, '14:00', '14:30', 840, 870, 30],&#xA;    [15, '14:30', '15:00', 870, 900, 30],&#xA;    [16, '15:00', '15:30', 900, 930, 30],&#xA;    [17, '15:30', '16:00', 930, 960, 30],&#xA;    [18, '16:00', '16:30', 960, 990, 30],&#xA;    [19, '16:30', '17:00', 990, 1020, 30],&#xA;    [20, '17:00', '17:30', 1020, 1050, 30],&#xA;    [21, '17:30', '18:00', 1050, 1080, 30],&#xA;    [22, '18:00', '19:30', 1080, 1110, 30],&#xA;    [23, '18:30', '19:00', 1110, 1140, 30],&#xA;    [24, '19:00', '19:30', 1140, 1170, 30],&#xA;    [25, '19:30', '20:00', 1170, 1200, 30],&#xA;    [26, '20:00', '20:30', 1200, 1230, 30],&#xA;    [27, '20:30', '21:00', 1230, 1260, 30],&#xA;    [28, '21:00', '21:30', 1260, 1290, 30],&#xA;    [29, '21:30', '22:00', 1320, 1350, 30],&#xA;    [30, '22:00', '22:30', 1350, 1380, 30],&#xA;    [31, '22:30', '23:00', 1410, 1440, 30],&#xA;    [32, '23:00', '23:30', 1440, 1470, 30],&#xA;    [33, '23:30', '24:00', 1470, 1500, 30]&#xA;]  # yapf:disable&#xA;&#xA;# pytype: disable=wrong-arg-types&#xA;&#xA;&#xA;def bus_driver_scheduling(minimize_drivers, max_num_drivers):&#xA;    &amp;quot;&amp;quot;&amp;quot;Optimize the bus driver scheduling problem.&#xA;&#xA;  This model has two modes.&#xA;&#xA;  If minimize_drivers == True, the objective will be to find the minimal&#xA;  number of drivers, independently of the working times of each drivers.&#xA;&#xA;  Otherwise, will will create max_num_drivers non optional drivers, and&#xA;  minimize the sum of working times of these drivers.&#xA;&#xA;  Args:&#xA;    minimize_drivers: A Boolean parameter specifying the objective of the&#xA;      problem. If True, it tries to minimize the number of used drivers. If&#xA;      false, it minimizes the sum of working times per workers.&#xA;    max_num_drivers: This number specifies the exact number of non optional&#xA;      drivers to use. This is only used if 'minimize_drivers' is False.&#xA;&#xA;  Returns:&#xA;      The objective value of the model.&#xA;  &amp;quot;&amp;quot;&amp;quot;&#xA;    shifts = None&#xA;    if FLAGS.instance == 1:&#xA;        shifts = SAMPLE_SHIFTS_SMALL&#xA;&#xA;    num_shifts = len(shifts)&#xA;&#xA;    # All durations are in minutes.&#xA;    max_driving_time = 720  # 12 hours.&#xA;    max_driving_time_without_pauses = 720&#xA;    min_pause_after_4h = 30&#xA;    max_pause_after_4h = 30&#xA;    min_delay_between_shifts = 0&#xA;    max_working_time = 720&#xA;    min_working_time = 720  # 12 hours&#xA;    setup_time = 0&#xA;    cleanup_time = 0&#xA;&#xA;    # Computed data.&#xA;    total_driving_time = sum(shift[5] for shift in shifts)&#xA;    min_num_drivers = int(math.ceil(total_driving_time * 1.0 /&#xA;                                    max_driving_time))&#xA;    num_drivers = 2 * min_num_drivers if minimize_drivers else max_num_drivers&#xA;    min_start_time = min(shift[3] for shift in shifts)&#xA;    max_end_time = max(shift[4] for shift in shifts)&#xA;&#xA;    print('Bus driver scheduling')&#xA;    print('  num shifts =', num_shifts)&#xA;    print('  total driving time =', total_driving_time, 'minutes')&#xA;    print('  min num drivers =', min_num_drivers)&#xA;    print('  num drivers =', num_drivers)&#xA;    print('  min start time =', min_start_time)&#xA;    print('  max end time =', max_end_time)&#xA;&#xA;    model = cp_model.CpModel()&#xA;&#xA;    # For each driver and each shift, we store:&#xA;    #   - the total driving time including this shift&#xA;    #   - the acrued driving time since the last 30 minute break&#xA;    # Special arcs have the following effect:&#xA;    #   - 'from source to shift' sets the starting time and accumulate the first&#xA;    #      shift&#xA;    #   - 'from shift to end' sets the ending time, and fill the driving_times&#xA;    #      variable&#xA;    # Arcs between two shifts have the following impact&#xA;    #   - add the duration of the shift to the total driving time&#xA;    #   - reset the accumulated driving time if the distance between the two&#xA;    #     shifts is more than 30 minutes, add the duration of the shift to the&#xA;    #     accumulated driving time since the last break otherwise&#xA;&#xA;    # Per (driver, node) info (driving time, performed,&#xA;    # driving time since break)&#xA;    total_driving = {}&#xA;    no_break_driving = {}&#xA;    performed = {}&#xA;    starting_shifts = {}&#xA;&#xA;    # Per driver info (start, end, driving times, is working)&#xA;    start_times = []&#xA;    end_times = []&#xA;    driving_times = []&#xA;    working_drivers = []&#xA;    working_times = []&#xA;&#xA;    # Weighted objective&#xA;    delay_literals = []&#xA;    delay_weights = []&#xA;&#xA;    # Used to propagate more between drivers&#xA;    shared_incoming_literals = collections.defaultdict(list)&#xA;    shared_outgoing_literals = collections.defaultdict(list)&#xA;&#xA;    for d in range(num_drivers):&#xA;        start_times.append(&#xA;            model.NewIntVar(min_start_time - setup_time, max_end_time,&#xA;                            'start_%i' % d))&#xA;        end_times.append(&#xA;            model.NewIntVar(min_start_time, max_end_time + cleanup_time,&#xA;                            'end_%i' % d))&#xA;        driving_times.append(&#xA;            model.NewIntVar(0, max_driving_time, 'driving_%i' % d))&#xA;        working_times.append(&#xA;            model.NewIntVar(0, max_working_time, 'working_times_%i' % d))&#xA;&#xA;        incoming_literals = collections.defaultdict(list)&#xA;        outgoing_literals = collections.defaultdict(list)&#xA;        outgoing_source_literals = []&#xA;        incoming_sink_literals = []&#xA;&#xA;        # Create all the shift variables before iterating on the transitions&#xA;        # between these shifts.&#xA;        for s in range(num_shifts):&#xA;            total_driving[d, s] = model.NewIntVar(0, max_driving_time,&#xA;                                                  'dr_%i_%i' % (d, s))&#xA;            no_break_driving[d, s] = model.NewIntVar(&#xA;                0, max_driving_time_without_pauses, 'mdr_%i_%i' % (d, s))&#xA;            performed[d, s] = model.NewBoolVar('performed_%i_%i' % (d, s))&#xA;&#xA;        for s in range(num_shifts):&#xA;            shift = shifts[s]&#xA;            duration = shift[5]&#xA;&#xA;            # Arc from source to shift.&#xA;            #    - set the start time of the driver&#xA;            #    - increase driving time and driving time since break&#xA;            source_lit = model.NewBoolVar('%i from source to %i' % (d, s))&#xA;            outgoing_source_literals.append(source_lit)&#xA;            incoming_literals[s].append(source_lit)&#xA;            shared_incoming_literals[s].append(source_lit)&#xA;            model.Add(start_times[d] == shift[3] -&#xA;                      setup_time).OnlyEnforceIf(source_lit)&#xA;            model.Add(total_driving[d, s] == duration).OnlyEnforceIf(source_lit)&#xA;            model.Add(no_break_driving[d,&#xA;                                       s] == duration).OnlyEnforceIf(source_lit)&#xA;            starting_shifts[d, s] = source_lit&#xA;&#xA;            # Arc from shift to sink&#xA;            #    - set the end time of the driver&#xA;            #    - set the driving times of the driver&#xA;            sink_lit = model.NewBoolVar('%i from %i to sink' % (d, s))&#xA;            outgoing_literals[s].append(sink_lit)&#xA;            shared_outgoing_literals[s].append(sink_lit)&#xA;            incoming_sink_literals.append(sink_lit)&#xA;            model.Add(end_times[d] == shift[4] +&#xA;                      cleanup_time).OnlyEnforceIf(sink_lit)&#xA;            model.Add(&#xA;                driving_times[d] == total_driving[d, s]).OnlyEnforceIf(sink_lit)&#xA;&#xA;            # Node not performed&#xA;            #    - set both driving times to 0&#xA;            #    - add a looping arc on the node&#xA;            model.Add(total_driving[d,&#xA;                                    s] == 0).OnlyEnforceIf(performed[d,&#xA;                                                                     s].Not())&#xA;            model.Add(no_break_driving[d, s] == 0).OnlyEnforceIf(&#xA;                performed[d, s].Not())&#xA;            incoming_literals[s].append(performed[d, s].Not())&#xA;            outgoing_literals[s].append(performed[d, s].Not())&#xA;            # Not adding to the shared lists, because, globally, each node will have&#xA;            # one incoming literal, and one outgoing literal.&#xA;&#xA;            # Node performed:&#xA;            #    - add upper bound on start_time&#xA;            #    - add lower bound on end_times&#xA;            model.Add(start_times[d] &amp;lt;= shift[3] - setup_time).OnlyEnforceIf(&#xA;                performed[d, s])&#xA;            model.Add(end_times[d] &amp;gt;= shift[4] + cleanup_time).OnlyEnforceIf(&#xA;                performed[d, s])&#xA;&#xA;            for o in range(num_shifts):&#xA;                other = shifts[o]&#xA;                delay = other[3] - shift[4]&#xA;                if delay &amp;lt; min_delay_between_shifts:&#xA;                    continue&#xA;                lit = model.NewBoolVar('%i from %i to %i' % (d, s, o))&#xA;&#xA;                # Increase driving time&#xA;                model.Add(total_driving[d, o] == total_driving[d, s] +&#xA;                          other[5]).OnlyEnforceIf(lit)&#xA;&#xA;                # Increase no_break_driving or reset it to 0 depending on the delay&#xA;                if max_pause_after_4h &amp;gt;= delay &amp;gt;= min_pause_after_4h:&#xA;                    model.Add(&#xA;                        no_break_driving[d, o] == other[5]).OnlyEnforceIf(lit)&#xA;                else:&#xA;                    model.Add(no_break_driving[d, o] == no_break_driving[d, s] +&#xA;                              other[5]).OnlyEnforceIf(lit)&#xA;&#xA;                # Add arc&#xA;                outgoing_literals[s].append(lit)&#xA;                shared_outgoing_literals[s].append(lit)&#xA;                incoming_literals[o].append(lit)&#xA;                shared_incoming_literals[o].append(lit)&#xA;&#xA;                # Cost part&#xA;                delay_literals.append(lit)&#xA;                delay_weights.append(delay)&#xA;&#xA;        model.Add(working_times[d] == end_times[d] - start_times[d])&#xA;&#xA;        if minimize_drivers:&#xA;            # Driver is not working.&#xA;            working = model.NewBoolVar('working_%i' % d)&#xA;            model.Add(start_times[d] == min_start_time).OnlyEnforceIf(&#xA;                working.Not())&#xA;            model.Add(end_times[d] == min_start_time).OnlyEnforceIf(&#xA;                working.Not())&#xA;            model.Add(driving_times[d] == 0).OnlyEnforceIf(working.Not())&#xA;            working_drivers.append(working)&#xA;            outgoing_source_literals.append(working.Not())&#xA;            incoming_sink_literals.append(working.Not())&#xA;            # Conditional working time constraints&#xA;            model.Add(&#xA;                working_times[d] &amp;gt;= min_working_time).OnlyEnforceIf(working)&#xA;            model.Add(working_times[d] == 0).OnlyEnforceIf(working.Not())&#xA;        else:&#xA;            # Working time constraints&#xA;            model.Add(working_times[d] &amp;gt;= min_working_time)&#xA;&#xA;        # Create circuit constraint.&#xA;        model.Add(sum(outgoing_source_literals) == 1)&#xA;        for s in range(num_shifts):&#xA;            model.Add(sum(outgoing_literals[s]) == 1)&#xA;            model.Add(sum(incoming_literals[s]) == 1)&#xA;        model.Add(sum(incoming_sink_literals) == 1)&#xA;&#xA;    # Each shift is covered.&#xA;    for s in range(num_shifts):&#xA;        model.Add(sum(performed[d, s] for d in range(num_drivers)) == 1)&#xA;        # Globally, each node has one incoming and one outgoing literal&#xA;        model.Add(sum(shared_incoming_literals[s]) == 1)&#xA;        model.Add(sum(shared_outgoing_literals[s]) == 1)&#xA;&#xA;    # Symmetry breaking&#xA;&#xA;    # The first 1 shift must be performed by 1 different drivers.&#xA;    # Let's assign them to the first driver in sequence&#xA;    model.Add(starting_shifts[0, 0] == 1)&#xA;&#xA;    if minimize_drivers:&#xA;        # Push non working drivers to the end&#xA;        for d in range(num_drivers - 1):&#xA;            model.AddImplication(working_drivers[d].Not(),&#xA;                                 working_drivers[d + 1].Not())&#xA;&#xA;    # Redundant constraints: sum of driving times = sum of shift driving times&#xA;    model.Add(cp_model.LinearExpr.Sum(driving_times) == total_driving_time)&#xA;    if not minimize_drivers:&#xA;        model.Add(&#xA;            cp_model.LinearExpr.Sum(working_times) == total_driving_time +&#xA;            num_drivers * (setup_time + cleanup_time) +&#xA;            cp_model.LinearExpr.ScalProd(delay_literals, delay_weights))&#xA;&#xA;    if minimize_drivers:&#xA;        # Minimize the number of working drivers&#xA;        model.Minimize(cp_model.LinearExpr.Sum(working_drivers))&#xA;    else:&#xA;        # Minimize the sum of delays between tasks, which in turns minimize the&#xA;        # sum of working times as the total driving time is fixed&#xA;        model.Minimize(&#xA;            cp_model.LinearExpr.ScalProd(delay_literals, delay_weights))&#xA;&#xA;    if not minimize_drivers and FLAGS.output_proto:&#xA;        print('Writing proto to %s' % FLAGS.output_proto)&#xA;        with open(FLAGS.output_proto, 'w') as text_file:&#xA;            text_file.write(str(model))&#xA;&#xA;    # Solve model.&#xA;    solver = cp_model.CpSolver()&#xA;    if FLAGS.params:&#xA;        text_format.Parse(FLAGS.params, solver.parameters)&#xA;&#xA;    status = solver.Solve(model)&#xA;&#xA;    if status != cp_model.OPTIMAL and status != cp_model.FEASIBLE:&#xA;        return -1&#xA;&#xA;    # Display solution&#xA;    if minimize_drivers:&#xA;        max_num_drivers = int(solver.ObjectiveValue())&#xA;        print('minimal number of drivers =', max_num_drivers)&#xA;        return max_num_drivers&#xA;&#xA;    for d in range(num_drivers):&#xA;        print('Driver %i: ' % (d + 1))&#xA;        print('  total driving time =', solver.Value(driving_times[d]))&#xA;        print('  working time =',&#xA;              solver.Value(working_times[d]) + setup_time + cleanup_time)&#xA;&#xA;        first = True&#xA;        for s in range(num_shifts):&#xA;            shift = shifts[s]&#xA;&#xA;            if not solver.BooleanValue(performed[d, s]):&#xA;                continue&#xA;&#xA;            # Hack to detect if the waiting time between the last shift and&#xA;            # this one exceeds 30 minutes. For this, we look at the&#xA;            # no_break_driving which was reinitialized in that case.&#xA;            if solver.Value(no_break_driving[d, s]) == shift[5] and not first:&#xA;                print('    **break**')&#xA;            print('    shift ', shift[0], ':', shift[1], '-', shift[2])&#xA;            first = False&#xA;&#xA;    return int(solver.ObjectiveValue())&#xA;&#xA;&#xA;def main(_):&#xA;    &amp;quot;&amp;quot;&amp;quot;Optimize the bus driver allocation in two passes.&amp;quot;&amp;quot;&amp;quot;&#xA;    print('----------- first pass: minimize the number of drivers')&#xA;    num_drivers = bus_driver_scheduling(False, 2)&#xA;    if num_drivers == -1:&#xA;        print('no solution found, skipping the final step')&#xA;    else:&#xA;        print('----------- second pass: minimize the sum of working times')&#xA;        bus_driver_scheduling(False, num_drivers)&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    app.run(main)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5220" LastEditorUserId="981" LastEditDate="2023-12-29T10:51:00.930" LastActivityDate="2023-12-29T10:51:00.930" Title="Modified bus scheduling problem question in ortools" Tags="|scheduling|or-tools|cp-sat|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5996" PostTypeId="1" AcceptedAnswerId="6000" CreationDate="2021-03-27T05:32:39.230" Score="2" ViewCount="449" Body="&lt;p&gt;I have a problem which simplifies to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\max w &amp;amp;\\&#xA;w&amp;amp;\le xy  \\&#xA;x,y&amp;amp;\le10  \\&#xA;x,y&amp;amp;\ge0&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Recognizing that &lt;span class=&quot;math-container&quot;&gt;$xy$&lt;/span&gt; form a hyperbolic constraint, I can solve by introducing a second-order cone:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\max w &amp;amp; \\&#xA;\left\lVert\begin{bmatrix} 2w \\ x - y \end{bmatrix}\right\rVert &amp;amp;\le x+y  \\&#xA;x,y&amp;amp;\le10  \\&#xA;x,y&amp;amp;\ge0&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;And all is well with the world, except that &lt;span class=&quot;math-container&quot;&gt;$w=\sqrt{xy}$&lt;/span&gt;. What I would like in reality is &lt;span class=&quot;math-container&quot;&gt;$w=xy$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is there an SOCP way of achieving this?&lt;/p&gt;&#xA;" OwnerUserId="886" LastActivityDate="2021-03-27T13:54:18.023" Title="Hyperbolic constraint as second-order cone" Tags="|convex-optimization|socp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5997" PostTypeId="5" CreationDate="2021-03-27T05:33:49.187" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2021-03-27T05:33:49.187" LastActivityDate="2021-03-27T05:33:49.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5998" PostTypeId="4" CreationDate="2021-03-27T05:33:49.187" Score="0" Body="For questions related to second-order cone programming, a type of convex optimization problem." OwnerUserId="886" LastEditorUserId="123" LastEditDate="2021-03-27T09:47:25.613" LastActivityDate="2021-03-27T09:47:25.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5999" PostTypeId="1" AcceptedAnswerId="6005" CreationDate="2021-03-27T07:30:13.940" Score="3" ViewCount="130" Body="&lt;p&gt;I am looking for an IP model for finding a &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-rooted minimum spanning forest on an undirected graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Given a set of roots &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; and a set of nodes &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$(R\cap N=\emptyset)$&lt;/span&gt;, I would find a forest of &lt;span class=&quot;math-container&quot;&gt;$k=|R|$&lt;/span&gt; disjointed trees that span all nodes in &lt;span class=&quot;math-container&quot;&gt;$R \cup N$&lt;/span&gt; where each &lt;span class=&quot;math-container&quot;&gt;$r \in R$&lt;/span&gt; belongs to exactly one tree, and the sum of the edges in the trees is the minimum.&lt;/p&gt;&#xA;&lt;p&gt;AFAIK, this is a well-known problem. However, I only found IP models for the (single) minimum spanning tree.&lt;/p&gt;&#xA;&lt;p&gt;I tried to extrapolate a model from &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0360835220300991&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, but to no avail (there are a few things I don't understand, and eventually my attempt does not avoid cycles).&lt;/p&gt;&#xA;&lt;p&gt;I &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/0377221794003351&quot; rel=&quot;nofollow noreferrer&quot;&gt;know that this is &lt;span class=&quot;math-container&quot;&gt;$\sf NP$&lt;/span&gt;-hard&lt;/a&gt;, but I would like to implement and test it on small instances.&lt;/p&gt;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="459" LastEditorUserId="123" LastEditDate="2021-03-27T09:49:03.143" LastActivityDate="2021-03-28T01:40:52.053" Title="IP model for k-rooted spanning forest" Tags="|modeling|integer-programming|reference-request|graphs|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6000" PostTypeId="2" ParentId="5996" CreationDate="2021-03-27T08:48:10.517" Score="3" Body="&lt;p&gt;No, the product is indefinite so it can neither be bounded from above using an tight convex epigraph representation, nor from below using a convex hypograph representation.&lt;/p&gt;&#xA;&lt;p&gt;If you cannot accept a general nonlinear form (and thus a general nonlinear solver), you might use a geometric programming form (and thus solve as a convex problem) if all your other constraints satisfy the requirements for a posynomial representation. In GP language, you are minimizing the posynomial &lt;span class=&quot;math-container&quot;&gt;$w^{-1}$&lt;/span&gt; under the posynomial constraint &lt;span class=&quot;math-container&quot;&gt;$wx^{-1}y^{-1}\leq 1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="487" LastEditorUserId="487" LastEditDate="2021-03-27T13:54:18.023" LastActivityDate="2021-03-27T13:54:18.023" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6001" PostTypeId="1" CreationDate="2021-03-27T09:14:59.680" Score="7" ViewCount="288" Body="&lt;p&gt;Consider a decision variable in a MILP constrained:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i p_i = 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$p_i\ \in \{0, 1\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Obviously one element in &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is 1 and all others are 0. How can I set a decision variable to the index i of the element &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; = 1?&lt;/p&gt;&#xA;&lt;p&gt;I think I can do this by multiple if-then-else constraints but that's a bit clunky.&lt;/p&gt;&#xA;" OwnerUserId="5221" LastActivityDate="2021-03-27T10:28:36.290" Title="Index of element in MILP vector decision variable that equals 1" Tags="|optimization|mixed-integer-programming|constraint|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6003" PostTypeId="2" ParentId="6001" CreationDate="2021-03-27T10:17:34.127" Score="6" Body="&lt;p&gt;My interpretation is that you want &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; to be &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$p_i=1$&lt;/span&gt;. You can do that with a simple multiplication &lt;span class=&quot;math-container&quot;&gt;$y=c^Tp$&lt;/span&gt; where the constant vector &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is given by &lt;span class=&quot;math-container&quot;&gt;$c_i=i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2021-03-27T10:17:34.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6004" PostTypeId="2" ParentId="6001" CreationDate="2021-03-27T10:28:36.290" Score="6" Body="&lt;p&gt;Assuming your index goes from 0 to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; you can do &lt;span class=&quot;math-container&quot;&gt;$k = \sum_{i = 0}^{n}i \cdot p_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is the desired index.&lt;/p&gt;&#xA;" OwnerUserId="459" LastActivityDate="2021-03-27T10:28:36.290" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6005" PostTypeId="2" ParentId="5999" CreationDate="2021-03-27T22:23:38.673" Score="3" Body="&lt;p&gt;There are flow models for the MST problem that can easily be adapted to the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-rooted MST. For each edge &lt;span class=&quot;math-container&quot;&gt;$e=(i,j)$&lt;/span&gt; in the graph, create a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_e$&lt;/span&gt; (1 if the edge is used in a tree, 0 if not) and two nonnegative variables &lt;span class=&quot;math-container&quot;&gt;$y_{ij}, y_{ji}$&lt;/span&gt; representing flows along the edge in either direction. Connect them via the constraints &lt;span class=&quot;math-container&quot;&gt;$y_{ij} \le n x_e$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{ji} \le n x_e$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$n = \vert N \vert$&lt;/span&gt;. The objective is to minimize the weighted sum of the &lt;span class=&quot;math-container&quot;&gt;$x_e$&lt;/span&gt; variables.&lt;/p&gt;&#xA;&lt;p&gt;Add a dummy source node to &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; with supply &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and an arc with cost 0 and capacity &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; to each node in &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt;. Give each node in &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; a demand of 1 and set up the usual flow conservation constraints. Note that there are no costs for flows, only the fixed costs for including the edges carrying the flows.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-03-27T22:23:38.673" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6006" PostTypeId="2" ParentId="5999" CreationDate="2021-03-28T01:40:52.053" Score="4" Body="&lt;p&gt;I recommend extending Paul's single-commodity formulation to a multicommodity formulation with &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; commodities.  Let binary variable &lt;span class=&quot;math-container&quot;&gt;$z_{i,r}$&lt;/span&gt; indicate whether node &lt;span class=&quot;math-container&quot;&gt;$i\in R \cup N$&lt;/span&gt; is assigned to tree &lt;span class=&quot;math-container&quot;&gt;$r\in R$&lt;/span&gt;.  The idea is to send one unit of commodity &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; from the dummy source node &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; iff &lt;span class=&quot;math-container&quot;&gt;$z_{i,r}=1$&lt;/span&gt;.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_e c_e x_e$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_r z_{i,r} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for $i\in R \cup N$} \\&#xA;z_{r,r} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for $r\in R$} \\&#xA;y_{i,j,r} + y_{j,i,r} &amp;amp;\le (n+1) x_e &amp;amp;&amp;amp;\text{for $e=(i,j) \in E$ and $r\in R$} \\&#xA;\sum_j (y_{j,i,r} - y_{i,j,r}) &amp;amp;= z_{i,r} &amp;amp;&amp;amp;\text{for $i \in R \cup N$ and $r \in R$} \\&#xA;\sum_j y_{0,j,r} &amp;amp;= \sum_i z_{i,r} &amp;amp;&amp;amp;\text{for $r \in R$} \\&#xA;\end{align}&lt;/span&gt;&#xA;You can optionally include a cut &lt;span class=&quot;math-container&quot;&gt;$\sum_e x_e = n$&lt;/span&gt; because a spanning forest on &lt;span class=&quot;math-container&quot;&gt;$n+k$&lt;/span&gt; nodes with &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; trees has &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; edges.&lt;/p&gt;&#xA;&lt;p&gt;Like the usual formulation for the minimum-cost multicommodity network flow problem, this formulation lends itself to Dantzig-Wolfe decomposition with one block per commodity.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-03-28T01:40:52.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6007" PostTypeId="1" AcceptedAnswerId="6010" CreationDate="2021-03-28T11:41:01.440" Score="2" ViewCount="2930" Body="&lt;p&gt;I would like to define the following constraint in Pyomo &lt;span class=&quot;math-container&quot;&gt;$$W^\top{\bf 1}\le\hat w=\begin{bmatrix}\hat{w}_1&amp;amp;\hat{w}_2&amp;amp;\ldots&amp;amp;\hat{w}_N\end{bmatrix}^\top$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$2\times4$&lt;/span&gt; matrix. Can I define the scalar constraints using the entries of &lt;span class=&quot;math-container&quot;&gt;$\hat w$&lt;/span&gt; and put these constraints as a list in Pyomo?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;## First constraint START ##&#xA;m.c1 = []&#xA;for k in range(N):&#xA;    c1_exp = np.matmul((W_var).T,ones_W)[k][0] &amp;lt;= w_hat[k][0]&#xA;    m.c1.append(Constraint(expr= c1_exp))&#xA;    print(m.c1[k])&#xA;## First constraint END ##&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The output is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hfVLJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hfVLJ.png&quot; alt=&quot;console output&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Does this mean the constraints are created correctly?&lt;/p&gt;&#xA;" OwnerUserId="4945" LastEditorUserId="52" LastEditDate="2021-03-28T19:24:09.190" LastActivityDate="2021-03-28T19:24:09.190" Title="Can I define constraints in Pyomo as a list?" Tags="|modeling|constraint|convex-optimization|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6008" PostTypeId="1" CreationDate="2021-03-28T13:59:25.300" Score="1" ViewCount="286" Body="&lt;p&gt;Can I know if the constraint below can be defined as follows in Pyomo for convex optimization &lt;span class=&quot;math-container&quot;&gt;\begin{align}\forall k,\quad W_{ik}+G_{ik}\begin{cases}\in[0,m_i\Delta t],&amp;amp;\quad\forall i:t+k\Delta t\le d_i\\=0,&amp;amp;\quad\forall i:t+k\Delta t&amp;gt;d_i\end{cases}\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; are arrays of dimension &lt;span class=&quot;math-container&quot;&gt;$M\times N$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;del_t = 5&#xA;M = 2 # set of active tasks&#xA;N = 4 # 4 time steps&#xA;maxP = 0.14&#xA;d = np.array([20,20]) # deadline in seconds&#xA;curr_time = 0 &#xA;&#xA;&#xA;## Third constraint START ##&#xA;m.c3 = []&#xA;for i in range(M):&#xA;    for k in range(N):&#xA;        if curr_time + k*del_t &amp;lt;= d[i] + curr_time:&#xA;            c3_exp = m.W[i+1,k+1] + m.G[i+1,k+1] &amp;lt;= maxP*del_t&#xA;            m.c3.append(Constraint(expr= c3_exp))&#xA;            print(m.c3[i])&#xA;        else:&#xA;            c3_exp = m.W[i+1,k+1] + m.G[i+1,k+1] == 0&#xA;            m.c3.append(Constraint(expr= c3_exp))&#xA;            print(m.c3[i])&#xA;## Third constraint END ##&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Can I also know if the output I get below when I run this code is correct?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1s8Lb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1s8Lb.png&quot; alt=&quot;output&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4945" LastEditorUserId="123" LastEditDate="2022-02-10T17:23:23.847" LastActivityDate="2022-02-10T17:23:23.847" Title="Correct way to define constraints in Pyomo" Tags="|modeling|constraint|convex-optimization|pyomo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6010" PostTypeId="2" ParentId="6007" CreationDate="2021-03-28T19:20:02.487" Score="2" Body="&lt;p&gt;Although the code that you shared shows that simple constraints have been generated, it does not show the constraints. A better way to generate these constraints in Pyomo is to use constraint lists as follow:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.cons1 = ConstraintList()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and then in a for loop you will generate the expression for each constraint and add them to the list:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.cons1.add(expr = expression)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;you can also in each iteration &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; of for loop observe the generated constraint by:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.cons1[i].pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-03-28T19:20:02.487" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6011" PostTypeId="1" AcceptedAnswerId="6027" CreationDate="2021-03-28T19:40:48.070" Score="1" ViewCount="309" Body="&lt;p&gt;Annual demand: &lt;span class=&quot;math-container&quot;&gt;$1000$&lt;/span&gt; units&lt;/p&gt;&#xA;&lt;p&gt;Unit cost: &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; dollars&lt;/p&gt;&#xA;&lt;p&gt;Company replenishes the inventory two times per year.&lt;/p&gt;&#xA;&lt;p&gt;Average Cycle Stock: &lt;span class=&quot;math-container&quot;&gt;$300$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am asked to compare average cycle stock with number of replenishments per year.&lt;/p&gt;&#xA;&lt;p&gt;My approach:&lt;/p&gt;&#xA;&lt;p&gt;The formula of average cycle stock is: &lt;span class=&quot;math-container&quot;&gt;$$\frac{cQ}{2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So when I applied the given information:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{(5)(Q)}{2}=300$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I found &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; to be &lt;span class=&quot;math-container&quot;&gt;$120$&lt;/span&gt;. If that is correct, how can it be possible that annual demand is &lt;span class=&quot;math-container&quot;&gt;$1000$&lt;/span&gt;, and company replenishes the inventory two times a year and order quantity to be &lt;span class=&quot;math-container&quot;&gt;$120$&lt;/span&gt;? I mean if we order twice a year, wouldn't our total order quantity be &lt;span class=&quot;math-container&quot;&gt;$240$&lt;/span&gt;? What point do you think I am missing?&lt;/p&gt;&#xA;" OwnerDisplayName="user5245" LastActivityDate="2021-03-31T08:52:25.527" Title="Relation between order quantity and average cycle stock" Tags="|optimization|inventory|economic-order-quantity|production-planning|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6012" PostTypeId="2" ParentId="3317" CreationDate="2021-03-28T21:26:32.737" Score="3" Body="&lt;p&gt;We (Thibaut Vidal, Daniele Vigo, Michael Schneider, and I) just released a &lt;a href=&quot;https://santini.in/files/papers/santini-schneider-vidal-vigo-2021.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;preprint&lt;/a&gt; on decomposition methods for Vehicle Routing heuristics.&lt;/p&gt;&#xA;&lt;p&gt;Clustering is one such family of methods and we try different types of clustering in our computational experiments.&#xA;Indeed, it works very well, as long as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The clusters are based on some existing high-quality solution. In other words, clustering based on routes works much better than clustering based on geographical distance.&lt;/li&gt;&#xA;&lt;li&gt;The cluster size is not too large (or the sub-problem optimising the routes visiting the cluster's customers is almost as hard as the original problem) nor too small (or the sub-problem is too trivial).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="136" LastActivityDate="2021-03-28T21:26:32.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6014" PostTypeId="2" ParentId="3952" CreationDate="2021-03-29T00:04:46.350" Score="5" Body="&lt;p&gt;The main reason why Pyomo is being used in industry and JuMP is not is that JuMP is a version 0.21.6 package whereas Pyomo is v5.7.3. Naturally, most businesses are not going to use a package with version less than 1.&lt;/p&gt;&#xA;&lt;p&gt;Also, according to the following discussion, first-class nonlinear optimization support is something for v2.0 (two or three years away):&#xA;&lt;a href=&quot;https://github.com/jump-dev/JuMP.jl/issues/2355&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/jump-dev/JuMP.jl/issues/2355&lt;/a&gt;&#xA;This (and other related links) provide excellent and open discussion that in and of itself is a testament to JuMP's potential.&lt;/p&gt;&#xA;&lt;p&gt;V1.0 and solid support for Conic and Linear-Quadratic problems should be on the cards for the near future. It seems like they are preparing the documentation for its release.&#xA;&lt;a href=&quot;https://arxiv.org/pdf/2002.03447.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://arxiv.org/pdf/2002.03447.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But the OP is concerned with teaching students who will go into industry. In the future when JuMP reaches v1.0, it will be competitive with Pyomo because: Julia is beautiful.&lt;/p&gt;&#xA;&lt;p&gt;The students will probably enjoy Julia more than Python (at least I did when I started).&lt;/p&gt;&#xA;" OwnerUserId="5235" LastEditorUserId="5235" LastEditDate="2021-03-29T00:48:32.910" LastActivityDate="2021-03-29T00:48:32.910" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6015" PostTypeId="1" AcceptedAnswerId="6016" CreationDate="2021-03-29T15:32:44.407" Score="2" ViewCount="1846" Body="&lt;p&gt;So I have the following matrix:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;P_{i,j}=&#xA;  \begin{bmatrix}&#xA;  x_0 &amp;amp; x_1 &amp;amp; x_2 \\&#xA;  y_0 &amp;amp; y_1 &amp;amp; y_2 \\&#xA;  z_0 &amp;amp; z_1 &amp;amp; z_2 &#xA;  \end{bmatrix}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where each of the elements in the matrix are binary variables (can be either 0 or 1). I am solving an optimization problem where I want to impose a constraint where each of the rows of the matrix have to have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; number of zeros. So for example, for the first row of matrix &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; (containing the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; elements), I want to enfore that for this row, I want &lt;strong&gt;one&lt;/strong&gt; of these &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;'s to be zero (but not explicitly stating which one should be zero). As a second example, for the second row of matrix &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; (containing the &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; elements), I want to enfore that for this row, I want &lt;strong&gt;two&lt;/strong&gt; of these &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;'s to be zero (but not explicitly stating which ones should be zero). And so fourth...&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to make this kind of formulation?&#xA;I was thinking of imposing the constraints as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_j P_{1,j} = 2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_j P_{2,j} = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Would this be the correct approach?&lt;/p&gt;&#xA;&lt;p&gt;Your help would be much appreciated!&lt;/p&gt;&#xA;" OwnerUserId="5179" LastEditorUserId="5179" LastEditDate="2021-03-31T12:11:50.653" LastActivityDate="2021-03-31T12:11:50.653" Title="Impose binary constraint on integer matrix with CVXPY" Tags="|optimization|mixed-integer-programming|python|cvxpy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6016" PostTypeId="2" ParentId="6015" CreationDate="2021-03-29T15:50:40.590" Score="3" Body="&lt;p&gt;Set &lt;code&gt;boolean=True&lt;/code&gt; for the matrix variable &lt;code&gt;P&lt;/code&gt;, and use the constraints you have proposed.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2021-03-29T15:50:40.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6017" PostTypeId="1" CreationDate="2021-03-29T19:31:39.123" Score="4" ViewCount="79" Body="&lt;p&gt;I'm trying to solve a clustering problem that's similiar to a VRP Pickup and Delivery problem with multiple depots and customers.&lt;/p&gt;&#xA;&lt;p&gt;Each customer demands a commodity that is exclusively found on one depot. I want to generate routes (not even trying to find the optimal order) that fulfill customers' requirements but also minimizing the total cost (distance) of those routes, having a set of Q-capacitated vehicles.&lt;/p&gt;&#xA;&lt;p&gt;I draw my problem here:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zBZwj.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zBZwj.jpg&quot; alt=&quot;My Problem&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Any help will be deeply appreciated. I'm trying to study how to make these &amp;quot;clusters&amp;quot; happen. Tried VRP Pickup and Delivery problems, Dial-a-Ride problems and so. But I can't find a way to solve this by some heuristic (seems extremely NP-hard for an exact method).&lt;/p&gt;&#xA;" OwnerUserId="5248" LastActivityDate="2021-03-31T07:47:42.180" Title="Clustering problem involving multidepots and customers requiring commodities located exclusively in an specific depot" Tags="|optimization|mixed-integer-programming|python|vehicle-routing|clustering|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6018" PostTypeId="1" CreationDate="2021-03-30T06:26:12.373" Score="2" ViewCount="250" Body="&lt;p&gt;I am reading some papers about PHA to solve multi-stage stochastic programming, but I think it is not still clear to me. This is my understanding and I would be thankful to know if it is correct or not. When have non-anticipativity constraints, all scenarios are linked and we cannot decompose the problem. So, we decompose all non-anticipativity constraints and solve the problem for each scenario. In this situation, the value of decision variables used in non-anticipativity and &lt;strong&gt;first-stage decision variables&lt;/strong&gt; might be different. So, we penalize the deviation from the average.&#xA;I have a non-anticipativity constraints as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p_{jts} = p_{jts^{\prime}} \quad \forall j,t,s,s^{\prime} \in S: (\xi_1^s,\dots,\xi_{t-1}^s)=(\xi_1^{s^\prime},\dots,\xi_{t-1}^{s^\prime})&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;One thing that is not clear to me is how to penalize the deviation for this constraint? I have defined a variable &lt;span class=&quot;math-container&quot;&gt;$\Xi_{t,s,s^{\prime}}$&lt;/span&gt; which takes 1 if  &lt;span class=&quot;math-container&quot;&gt;$(\xi_1^s,\dots,\xi_{t-1}^s)=(\xi_1^{s^\prime},\dots,\xi_{t-1}^{s^\prime})$&lt;/span&gt;. Can I use the following constraint as the penalty?&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j}\sum_{t}\sum_{s}|p_{jts}-\bar{p}_{jts}|&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\bar{p}_{jts} = \frac{\sum_{s^{\prime}}\Xi_{tss^{\prime}}.p_{jts^{\prime}}.pr_{s^{\prime}}}{\sum_{s^{\prime}}\Xi_{tss^{\prime}}.pr_{s^{\prime}}}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bar{p}_{jts}$&lt;/span&gt; will be equal to &lt;span class=&quot;math-container&quot;&gt;$\bar{p}_{jts^{\prime}}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$\Xi_{tss^{\prime}}.p_{jts^{\prime}}=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, if &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; is the first-stage decision variable, I should add the following term into the objective function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j}|y_j-\bar{y}_j| \quad \text{where} \quad \bar{y}_j= \sum_{s}pr_s.y_{js}&#xA;$$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I think most papers use fan of scenarios and node-by-node to develop PHA. However, I am willing to use &lt;span class=&quot;math-container&quot;&gt;$\Xi_{tss^{\prime}}$&lt;/span&gt; to define the algorithm which is based on the scenario tree. If someone has a clear pseudo-code of PHA for multi-stage algorithm, I will be thankful if you can share it.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="139" LastEditDate="2021-03-30T06:48:01.883" LastActivityDate="2021-03-30T06:48:01.883" Title="What is the intuition behind Progressive hedging algorithm?" Tags="|stochastic-programming|multi-stage|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6019" PostTypeId="1" AcceptedAnswerId="6020" CreationDate="2021-03-30T08:05:33.390" Score="5" ViewCount="2594" Body="&lt;p&gt;I am using or-tools linear solver. and my problem ends up having no optimal solution. how can I tell the solver to find a suboptimal solution?&lt;/p&gt;&#xA;" OwnerUserId="5162" LastEditorUserId="5162" LastEditDate="2021-03-30T08:06:35.087" LastActivityDate="2021-04-08T20:22:35.220" Title="find suboptimal solution, if no optimal solution exists?" Tags="|or-tools|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6020" PostTypeId="2" ParentId="6019" CreationDate="2021-03-30T10:05:44.140" Score="2" Body="&lt;p&gt;&amp;quot;Sub-optimal&amp;quot; is a global optimisation term. In global optimisation, we refer to a &amp;quot;sub-optimal&amp;quot; solution as a solution that is optimal, i.e., it satisfies KKT, but is not the global solution (its value is not the best it can be, hence the term sub-optimal).&lt;/p&gt;&#xA;&lt;p&gt;It is important to note that the counterpoint to &amp;quot;sub-optimal&amp;quot; is not &amp;quot;optimal&amp;quot;, it is &amp;quot;globally optimal&amp;quot;. Thus, sub-optimal solutions can be locally optimal if the problem is continuous nonlinear (they satisfy the KKT conditions).&lt;/p&gt;&#xA;&lt;p&gt;If the solver reports that the solution is not optimal, then you have the following options:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Relax the constraint violation tolerance&lt;/li&gt;&#xA;&lt;li&gt;Relax the integrality tolerance (if MIP)&lt;/li&gt;&#xA;&lt;li&gt;Try different starting points (if nonlinear)&lt;/li&gt;&#xA;&lt;li&gt;Check your model for inconsistencies&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The last two are by far the most likely causes for not finding optimal solutions. Since you are solving linear problems, my money would be on the last one.&lt;/p&gt;&#xA;&lt;p&gt;On a side note, MIP problems don't generally satisfy the KKT conditions (since derivatives are not defined) so calling their solutions &amp;quot;optimal&amp;quot; is an abuse of terminology, the right term is &amp;quot;feasible&amp;quot;, and &amp;quot;best feasible&amp;quot; for the global solution. Nevertheless, the convention is to call those solutions optimal as well.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: There seems to be quite a bit of contention w.r.t. what the right terminology is, so even if this is out of scope of what the OP needed to know, I will elaborate on terminology and its origins below, just for the sake of correctness:&lt;/p&gt;&#xA;&lt;p&gt;The most general definition of an optimisation problem, is to solve the problem of finding &lt;strong&gt;the best feasible solution&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;From &lt;a href=&quot;https://en.wikipedia.org/wiki/Optimization_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In mathematics, computer science and economics, an optimization&#xA;problem is the problem of finding the best solution from all feasible&#xA;solutions.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is a very broad definition that covers pretty much everything. Also notice that the word &amp;quot;optimal&amp;quot; does not appear here. This is not a coincidence.&lt;/p&gt;&#xA;&lt;h1&gt;Types of solutions&lt;/h1&gt;&#xA;&lt;p&gt;In optimisation, we can have two types of solutions based on constraint satisfaction:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Feasible solutions, and&lt;/li&gt;&#xA;&lt;li&gt;Optimal solutions.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Based on objective value, we further have:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Best feasible solutions, and&lt;/li&gt;&#xA;&lt;li&gt;Globally optimal solutions&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;A feasible solution is just that - a solution that satisfies all the constraints.&lt;/p&gt;&#xA;&lt;p&gt;An &lt;em&gt;optimal&lt;/em&gt; solution is something stronger. Both for linear and nonlinear programming, a point is optimal &lt;strong&gt;if and only if&lt;/strong&gt; it satisfies the &lt;a href=&quot;https://en.wikipedia.org/wiki/Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions&quot; rel=&quot;nofollow noreferrer&quot;&gt;KKT conditions for optimality&lt;/a&gt;. You can find many references to this, e.g. &lt;a href=&quot;https://bookdown.org/edxu96/matrixoptim/kkt-conditions.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. For linear programming the conditions degenerate to simpler expressions, but it's KKT nonetheless.&lt;/p&gt;&#xA;&lt;p&gt;Note that by &amp;quot;KKT conditions&amp;quot; I refer to &lt;em&gt;all KKT conditions&lt;/em&gt;, i.e., the necessary and sufficient conditions, including the second-order conditions, along with the regularity conditions.&lt;/p&gt;&#xA;&lt;p&gt;For nonlinear programming that's intuitive, as we have the concept of local optimality, however this is also necessary in linear programming, because it's very possible to have a feasible solution that is not on the globally optimal vertex (e.g., a &lt;a href=&quot;https://en.wikipedia.org/wiki/Basic_feasible_solution#:%7E:text=In%20the%20theory%20of%20linear,there%20exists%20an%20optimal%20BFS.&quot; rel=&quot;nofollow noreferrer&quot;&gt;Basic Feasible Solution&lt;/a&gt;), or not at a vertex at all (e.g. if we're using interior-point to solve the LP and terminate early). In continuous optimisation, the way we distinguish between merely feasible and &amp;quot;optimal&amp;quot; points, is through the KKT test.&lt;/p&gt;&#xA;&lt;h1&gt;Where we have what type of solution&lt;/h1&gt;&#xA;&lt;p&gt;The most important distinction here is that mixed-integer problems can not satisfy the KKT conditions because derivatives are not defined. Ergo, generally speaking, since &amp;quot;a solution is optimal &lt;strong&gt;iff&lt;/strong&gt; it satisfies the KKT conditions&amp;quot;, if the solution can not pass the KKT test (because we can't define derivatives), &lt;strong&gt;that solution can not be optimal&lt;/strong&gt;. Therefore, it can only be some flavour of &amp;quot;feasible&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;A second, more subtle point, is that we can (and do) get merely feasible solutions for continuous problems, e.g. when we use derivative-free methods such as evolutionary algorithms, or when we terminate a continuous solver after it has found a feasible point but before proving KKT satisfaction.&lt;/p&gt;&#xA;&lt;p&gt;With the above in mind, this is the breakdown of what we &lt;em&gt;can&lt;/em&gt; get for different types of optimisation problems:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;LP &amp;amp; NLP: Feasible, optimal, globally optimal&lt;/li&gt;&#xA;&lt;li&gt;MILP &amp;amp; MINLP: Feasible, best feasible&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;Sub-optimal&lt;/h1&gt;&#xA;&lt;p&gt;Now, circling back to what &amp;quot;sub-optimal&amp;quot; means, it depends on the problem being solved. For continuous problems, it technically refers to a solution that satisfies KKT but is not globally optimal. Some people abuse this terminology to also refer to feasible solutions that are not globally optimal.&lt;/p&gt;&#xA;&lt;p&gt;In MI optimisation, &lt;em&gt;this literally means nothing&lt;/em&gt; because the concept of optimality is not defined. The term &amp;quot;optimal&amp;quot; is still used here because it's too tedious to use different terminology, but it's an abuse of terminology nonetheless.&lt;/p&gt;&#xA;&lt;p&gt;If the problem is MI, the &amp;quot;sub-optimal&amp;quot; can only refer to:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;a feasible solution that is not the best feasible solution.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h1&gt;Intuition&lt;/h1&gt;&#xA;&lt;p&gt;If anyone is still in doubt about the correctness of this, just think about how we prove &amp;quot;optimality&amp;quot; for a mixed integer problem. We fix the integer variables (or relax them to continuous) and then solve those sub-(N)LPs to optimality many times in branch-and-bound. These sub-(N)LPs do satisfy KKT, but the original MI(N)LP problem does not. In fact, the very reason we fix/relax the integer variables is so that we can satisfy KKT.&lt;/p&gt;&#xA;&lt;p&gt;Because branch-and-bound is a process of intelligent elimination, at some point we can prove that there is no better feasible solution that the one we currently have. However, even though this solution is referred to as &amp;quot;optimal&amp;quot;, it will not necessarily satisfy the KKT conditions. In some cases &lt;em&gt;it can&lt;/em&gt;, if the solution of the continuous relaxation happens to be integral, but in the general case it will not.&lt;/p&gt;&#xA;&lt;p&gt;If you are still not convinced, you can always test this yourself. Simply get a solution to a mixed-integer problem and try to prove whether it passes the KKT test.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-04-08T13:18:33.443" LastActivityDate="2021-04-08T13:18:33.443" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="6021" PostTypeId="2" ParentId="6017" CreationDate="2021-03-30T12:14:52.587" Score="5" Body="&lt;p&gt;This is a tough problem indeed, but I am not sure about the &amp;quot;extremely NP-hard&amp;quot; part :). All problems which are NP-hard are...very hard.&lt;/p&gt;&#xA;&lt;p&gt;This looks like a &lt;a href=&quot;https://en.wikipedia.org/wiki/Multi-commodity_flow_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;multi-commodity flow problem&lt;/a&gt;, one commodity per depot.&lt;/p&gt;&#xA;&lt;p&gt;It is natural to decompose such a problem as follows. For each customer &lt;span class=&quot;math-container&quot;&gt;$v\in V$&lt;/span&gt;, for each commodity &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt; we assume that the demand &lt;span class=&quot;math-container&quot;&gt;$D_{vk}\in \mathbb{R}^+$&lt;/span&gt; is known. Let &lt;span class=&quot;math-container&quot;&gt;$\Omega_k^v$&lt;/span&gt; denote all possible paths from depot/commodity &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt; to customer &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$\Omega_k =\bigcup_{v \in V}\Omega_k^v$&lt;/span&gt; denote the set of all paths from depot &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$y_{p}$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if path &lt;span class=&quot;math-container&quot;&gt;$p\in \Omega_k^v$&lt;/span&gt; is used to satisfy the demand of customer &lt;span class=&quot;math-container&quot;&gt;$v\in V$&lt;/span&gt; for commodity &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$n_{ij} \in \mathbb{N}$&lt;/span&gt; be a variable for the number of vehicles of capacity &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; required on edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in A$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; denote the cost of using one vehicle on edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You want to minimize the overall cost :&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{(i,j)\in A}c_{ij} n_{ij}&#xA;$$&lt;/span&gt;&#xA;subject to:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Each customer &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; must be serviced by exactly one path for each commodity:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{p\in \Omega_k^v } y_{p} = 1\quad \forall v \in V, \; \forall k\in K&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Capacity constraints must hold:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{k \in K}\sum_{v \in V}\sum_{p\in \Omega_k^v|(i,j) \in p} D_{vk}y_{p} \le Q n_{ij}\quad \forall (i,j) \in A&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Note that there is an exponential number of paths in a network, so you will not be able to define the entire set &lt;span class=&quot;math-container&quot;&gt;$\Omega_k$&lt;/span&gt;. You have two options:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Define a subset of such paths, e.g., the &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; best ones (shortest ones) for each &lt;span class=&quot;math-container&quot;&gt;$(k,v)$&lt;/span&gt;. See how the model grows when &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; varies, and how the quality of the solution evolves.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;a href=&quot;https://en.wikipedia.org/wiki/Column_generation&quot; rel=&quot;nofollow noreferrer&quot;&gt;column generation&lt;/a&gt; to define paths dynamically. But since you have &lt;span class=&quot;math-container&quot;&gt;$n_{ij}$&lt;/span&gt; variables that are integer, you will need to embed this in a branch-and-bound tree. If you are not familiar with branch-and-price, I would go with option &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. In my experience option &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; already gives good results.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Also, note that once you solve this problem, you do not have individual routes per vehicle. You &amp;quot;only&amp;quot; have the routing of each commodity, for each customer, and the number of vehicles that are required on each edge. For individual routes per vehicle, you need to solve another problem after this one : you need to &amp;quot;cover&amp;quot; your network with routes, such that on each edge you have the required number of vehicles. And last but not least, all of this assumes that you may use multiple vehicles to send commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; to customer &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, as you may need to transfer the commodity to another vehicle at one point (in order to minimize &lt;span class=&quot;math-container&quot;&gt;$n_{ij}$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;ADDENDUM&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If it is assumed that commodities cannot be mixed in a same vehicle, and that each depot has its own set of vehicles, then you could simply run a classical CVRP for each depot, independently. Of course in this case you would be missing out on a lot of potential optimization, as mixing different commodities in a same vehicle could turn out to be very cost efficient.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-03-31T07:47:42.180" LastActivityDate="2021-03-31T07:47:42.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6023" PostTypeId="1" AcceptedAnswerId="6031" CreationDate="2021-03-30T20:49:46.160" Score="0" ViewCount="389" Body="&lt;p&gt;I have a system with &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; service points.&#xA;There are also &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; users in the system.&lt;/p&gt;&#xA;&lt;p&gt;We  have &lt;span class=&quot;math-container&quot;&gt;$$U&amp;gt;S&amp;gt;G$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;One group can have maximum &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; service points, but there is no restrictions on the number of users per group.&lt;/p&gt;&#xA;&lt;p&gt;A user is served by all the service points belonging to the user's group/cluster. Therefore, if one user happens to be in a group of multiple service points, then it will be served by all the service points in that group. Also, the service points in one group negatively impact the service offered to a user in a different group.&lt;/p&gt;&#xA;&lt;p&gt;There is a gain between a service point and a user, denoted by &lt;span class=&quot;math-container&quot;&gt;$h_{u,s}, u=1,2,\cdots,U, s=1,2,\cdots,S$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The objective is to maximise the sum-quality of all the users in the system&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max\sum_{u=1}^Uq_u$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I mathematically formulate this optimization problem? How to express the constraints mathematically?&lt;/p&gt;&#xA;&lt;h3&gt;Thoughts&lt;/h3&gt;&#xA;&lt;p&gt;A similar equation is given here. &lt;a href=&quot;https://or.stackexchange.com/questions/5889/how-to-transform-this-problem-with-logarithmic-objective-function-into-an-approx?noredirect=1#comment10272_5889&quot;&gt;How to transform this problem with logarithmic objective function into an approximated convex optimization problem?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The solution suggested there does not help. It is helpful to convexity my objective may be. But my question is different here. I want to have a mathematical formulation. In the previous problem, we had only user and service points lets ay. But in this problem, we have grouping of service points and users, which make the formation difficult.&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&lt;p&gt;For linearising constraint (5) in the above formulation, let, &lt;span class=&quot;math-container&quot;&gt;$\nu_{u,s,g}=y_{u,g}z_{s,g}$&lt;/span&gt;. Then I follow what @RobPratt suggests.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2021-04-29T09:48:52.110" LastActivityDate="2021-04-29T09:48:52.110" Title="How to mathematically formulate the optimization problem?" Tags="|mixed-integer-programming|linear-programming|modeling|convex-optimization|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6024" PostTypeId="1" AcceptedAnswerId="6082" CreationDate="2021-03-30T22:01:33.447" Score="1" ViewCount="95" Body="&lt;p&gt;I am trying to compile very old source code which uses cplex functions from the callable C library (cplex 4.0).&lt;/p&gt;&#xA;&lt;p&gt;Some of the functions seem to have been renamed/replaced...&lt;/p&gt;&#xA;&lt;p&gt;Can anyone tell me the functions that have replaced&lt;/p&gt;&#xA;&lt;p&gt;CPXloadlp&lt;/p&gt;&#xA;&lt;p&gt;CPXloadbase&lt;/p&gt;&#xA;&lt;p&gt;CPXgetcolspace&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2021-04-12T13:03:40.403" Title="Cplex callable library" Tags="|cplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6025" PostTypeId="1" CreationDate="2021-03-31T04:41:36.087" Score="2" ViewCount="394" Body="&lt;p&gt;I would like to write a piecewise constraint for an Abstract Model in Pyomo.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\operatorname{pu}_i(t_i^{'v})=\begin{align}\begin{cases}\rho_1(e_i'-t_i^{'v})+\rho_2(e_i-e_i'),\quad&amp;amp; t_i^{'v}\le e_i',\\\rho_2(e_i-t_i^{'v}),&amp;amp;e_i'&amp;lt;t_i^{'v}\le e_i,\\0,&amp;amp;e_i&amp;lt;t_i^{'v}\le l_i,\\\rho_3(t_i^{'v}-l_i),&amp;amp;l_i&amp;lt;t_i^{'v}\le l_i',\\\rho_3(l_i'-l_i)+\rho_4(t_i^{'v}-l_i'),&amp;amp;l_i'&amp;lt;t_i^{'v}.\end{cases}\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The only variable here is &lt;span class=&quot;math-container&quot;&gt;$t'^{v}_i$&lt;/span&gt;, the &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; values are defined in a separate &lt;code&gt;.dat&lt;/code&gt; file.&lt;/p&gt;&#xA;&lt;p&gt;Here is what I tried to do, but I am struggling with the breakpoints:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def PenaltyCost_rule(model, v, i):&#xA;        if value(model.t[v,i]) &amp;lt;= model.ep[i]: &#xA;            return model.pn[v,i] == model.rho[1]*(model.ep[i]-model.t[v,i]) + model.rho[2]*(model.e[i]-model.ep[i])&#xA;        if value(model.t[v,i]) &amp;gt;= model.ep[i] &amp;amp; value(model.t[v,i])&amp;lt;= model.e[i]:&#xA;            return model.pn[v,i] == model.rho[2]*(model.e[i]-model.t[v,i])&#xA;        if value(model.t[v,i]) &amp;gt;= model.e[i] &amp;amp; value(model.t[v,i]) &amp;lt;= model.l[i]:&#xA;            return model.pn[v,i] == 0&#xA;        if value(model.t[v,i]) &amp;gt;= model.l[i] &amp;amp; value(model.t[v,i])&amp;lt;= model.lp[i]:&#xA;            return model.pn[v,i] == model.rho[3]*(model.t[v,i]-model.l[i])&#xA;        if value(model.t[v,i]) &amp;gt;= model.lp[i]:&#xA;            return model.pn[v,i] == model.rho[1]*(model.ep[i]-model.tp[i,v]) + model.rho[3]*(model.t[i]-model.l[i])&#xA;model.PenaltyConstConstraint = Constraint(model.v, model.n, rule=PenaltyCost_rule)&#xA;&#xA;bpts = [model.ep[i],model.e[i], model.l[i],model.lp[i]]&#xA;&#xA;&#xA;model.Penalty_constraint = Piecewise(&#xA;                model.v, model.n,&#xA;                model.t, model.pn,&#xA;                pw_pts=bpts,&#xA;                pw_repn='INC',&#xA;                pw_constr_type = 'EQ',&#xA;                f_rule = PenaltyCost_rule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5254" LastEditorUserId="123" LastEditDate="2021-03-31T07:10:37.833" LastActivityDate="2021-03-31T07:10:37.833" Title="Piecewise Constraint in Abstract Model" Tags="|constraint|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6026" PostTypeId="2" ParentId="6025" CreationDate="2021-03-31T06:45:08.193" Score="1" Body="&lt;p&gt;If I understand the question correctly, you can just separate the breakpoint and dedicate an if-then condition for each of them inside your constraint generator function. BTW, take a look at the last line of your constraint (the figure that uploaded), the last &lt;span class=&quot;math-container&quot;&gt;$l_i$&lt;/span&gt; should be &lt;span class=&quot;math-container&quot;&gt;$l'_i$&lt;/span&gt; (??).&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-03-31T06:45:08.193" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6027" PostTypeId="2" ParentId="6011" CreationDate="2021-03-31T08:52:25.527" Score="1" Body="&lt;p&gt;So as a formal answer: your &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$600$&lt;/span&gt; as the average cycle stock is in pieces. So&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$average\space cycle\space stock = 300 = \frac{Q}{2} \implies Q = 300 \times 2 = 600 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The total average cycle stock value in the exchange curve is the sum of all average cycle stocks of all items in your group you are evaluating, expressed in value. So for one item, your average cycle stock value is &lt;span class=&quot;math-container&quot;&gt;$\frac{cQ}{2}$&lt;/span&gt;, which in this example is &lt;span class=&quot;math-container&quot;&gt;$\frac{5\times 600}{2} = 1500$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;With &lt;span class=&quot;math-container&quot;&gt;$Q = 600$&lt;/span&gt;, the company orders twice a year which is the x-axis in the exchange curve. You can then do this for several items and plot the current situation, together with the exchange curve to see&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;what your order strategy should be based on managerial implications&lt;/li&gt;&#xA;&lt;li&gt;how far off you are with the current situation.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This is also handled in the book of Silver, Pyke &amp;amp; Peterson :&lt;strong&gt;Inventory Management and Production Planning and Scheduling (1998)&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="329" LastActivityDate="2021-03-31T08:52:25.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6028" PostTypeId="1" AcceptedAnswerId="6029" CreationDate="2021-03-31T09:34:44.590" Score="7" ViewCount="2102" Body="&lt;p&gt;So I have an optimization problem of the following form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\max_{x,y} \quad &amp;amp; \sum_i x_i \\&#xA;\text{s.t.} \quad &amp;amp; \sum_i x_iy_i \leq a \\&#xA;\quad &amp;amp;  x_{\min} \leq x \leq x_{\max} \\&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a vector of real (positive) variables, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a vector of binary variables (&lt;span class=&quot;math-container&quot;&gt;$y_i \in \{0, 1\}$&lt;/span&gt;), and &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is a positive constant. The objective function is linear, but the constraint is bilinear.&lt;/p&gt;&#xA;&lt;p&gt;One way to solve this problem is the so-called &amp;quot;mountain-climbing&amp;quot; method where I first fix &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and solve for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, and then use the solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; to to solve for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, and continue the process until some convergence condition is achieved on the objective.&lt;/p&gt;&#xA;&lt;p&gt;My first question is, is there an easier way to solve such a problem? (i.e., convexifying the constraint somehow).&lt;/p&gt;&#xA;&lt;p&gt;My second question is, if I'm using this &amp;quot;mountain-climbing&amp;quot; method, when I obtain a solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; and then solve the next problem for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, do I just set &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; for the constraint and keep the objective as optimization function, or do I simply solve for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; using the constraint with no objective?&lt;/p&gt;&#xA;&lt;p&gt;Your help is much appreciated!&lt;/p&gt;&#xA;" OwnerUserId="5179" LastEditorUserId="500" LastEditDate="2021-03-31T13:03:11.990" LastActivityDate="2021-04-01T13:41:50.907" Title="Mixed-integer optimization with bilinear constraint" Tags="|optimization|mixed-integer-programming|linearization|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6029" PostTypeId="2" ParentId="6028" CreationDate="2021-03-31T12:51:46.007" Score="10" Body="&lt;p&gt;You can linearize the constraint by introducing a nonnegative variable &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;, replacing &lt;span class=&quot;math-container&quot;&gt;$x_i y_i$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;, and imposing linear big-M constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}x_\min y_i &amp;amp;\le z_i \le x_\max y_i\tag1\\&#xA;(0-x_\max)(1-y_i) &amp;amp;\le z_i - x_i \le (0-x_\min)(1-y_i)\tag2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y_i=0\implies z_i=0$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y_i=1\implies z_i=x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Because @Nikos mentioned automated reformulation, I should mention that the &lt;a href=&quot;https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=v_007&amp;amp;docsetId=casmopt&amp;amp;docsetTarget=casmopt_optmodel_details56.htm&amp;amp;locale=en&quot; rel=&quot;noreferrer&quot;&gt;LINEARIZE option&lt;/a&gt; in SAS will do this for you:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;con C1: sum {i in ISET} x[i] * y[i] &amp;lt;= a;&#xA;solve linearize;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Alternatively, you can use &lt;a href=&quot;https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=v_010&amp;amp;docsetId=casmopt&amp;amp;docsetTarget=casmopt_optmodel_details48.htm&amp;amp;locale=en&quot; rel=&quot;noreferrer&quot;&gt;indicator constraints&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;con C1: sum {i in ISET} z[i] &amp;lt;= a;&#xA;con C2 {i in ISET}: y[i] = 0 implies z[i] = 0;&#xA;con C3 {i in ISET}: y[i] = 1 implies z[i] = x[i];&#xA;solve;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If you have &lt;span class=&quot;math-container&quot;&gt;$$x_\min q_i \le x_i \le x_\max q_i,$$&lt;/span&gt; the new constraints are instead&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}0 &amp;amp;\le z_i \le x_\max y_i\tag{$1'$}\\&#xA;(0-x_\max)(1-y_i) &amp;amp;\le z_i - x_i \le 0\tag{$2'$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-04-01T13:41:50.907" LastActivityDate="2021-04-01T13:41:50.907" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6030" PostTypeId="2" ParentId="6028" CreationDate="2021-03-31T13:29:39.087" Score="7" Body="&lt;p&gt;The best way to solve this in general is to reformulate this to an MILP. Although the reformulation itself is easy, it's also incredibly easy to make a mistake/forget to take something into account.&lt;/p&gt;&#xA;&lt;p&gt;Since this is a toy problem, I will provide a solution that will work for any problem that has the structure &lt;span class=&quot;math-container&quot;&gt;$xy, y\in\{0,1\}$&lt;/span&gt;, including your actual problem.&lt;/p&gt;&#xA;&lt;h1&gt;The reformulation&lt;/h1&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$xy$&lt;/span&gt; can be linearized by replacing &lt;span class=&quot;math-container&quot;&gt;$xy$&lt;/span&gt; with an auxiliary variable and adding the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;x_ly-w\le0\\&#xA;w-x_uy\le0\\&#xA;w-x+x_l(1-y)\le0\\&#xA;-w+x-x_u(1-y)\le0\\&#xA;xy_l\le w\le xy_u&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x_l,x_u$&lt;/span&gt; are parameters specifying the lower and upper bounds of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h1&gt;Reformulating automatically&lt;/h1&gt;&#xA;&lt;p&gt;The easiest way (and the only one that is free) to do this automatically for any problem where this structure is present, is to use our own Octeract Reformulator, which is free to use. It will perform the linearisation for every bilinear term even if your problem only partially has this structure and the rest is e.g. logarithms or cosines or other complicated functions.&lt;/p&gt;&#xA;&lt;p&gt;You just need to install &lt;a href=&quot;https://octeract.com/&quot; rel=&quot;noreferrer&quot;&gt;Octeract Engine&lt;/a&gt; (which is also free), grab the &lt;a href=&quot;https://github.com/Octeract/reformulator/blob/main/linearizations/LinearizeBilinearContBinary.py&quot; rel=&quot;noreferrer&quot;&gt;reformulation file&lt;/a&gt; from our GitHub repo, and copy-paste the following in a Python file:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from octeract import *&#xA;from LinearizeBilinearContBinary import LinearizeBilinearContBinaryMod&#xA;&#xA;m = Model()&#xA;m.import_model_file('model.nl')&#xA;&#xA;m.apply_mod(LinearizeBilinearContBinaryMod)&#xA;&#xA;print(m)&#xA;&#xA;m.write_problem_to_NL_file('/my/file/name.nl')&#xA;#m.write_problem_to_LP_file('/my/file/name.lp')&#xA;#m.write_problem_to_MPS_file('/my/file/name.mps')&#xA;#m.write_problem_to_GAMS_file('/my/file/name.gms')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will produce a new file in your desired format which will contain the reformulated problem. You can then solve this with any solver/modelling language you want.&lt;/p&gt;&#xA;&lt;p&gt;For example, the following Octeract Shell script creates a dummy model to try out the reformulation:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from octeract import *&#xA;&#xA;# ==== Create a toy model ====&#xA;m = Model()&#xA;&#xA;for i in range(1,4):&#xA;    m.add_variable(&amp;quot;y&amp;quot;+str(i),0,1,BIN)&#xA;&#xA;m.minimize(&amp;quot;x1&amp;quot;)&#xA;&#xA;m.set(&amp;quot;x1*y1+x2*y2+x3*y3&amp;quot;).to(4)&#xA;&#xA;for i in range(1,4):&#xA;    m.set_variable_bounds('x'+str(i),-1000,1000)&#xA;print(m)&#xA;m.write_problem_to_NL_file('model.nl')&#xA;# ============================&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;code&gt;print&lt;/code&gt; command will give us:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;Structure : MBQCQP&#xA;Convexity : nonconvex&#xA;------------------------------------------&#xA;var y1 binary  &amp;gt;= 0, &amp;lt;= 1;&#xA;var y2 binary  &amp;gt;= 0, &amp;lt;= 1;&#xA;var y3 binary  &amp;gt;= 0, &amp;lt;= 1;&#xA;var x1 &amp;gt;= -1000, &amp;lt;= 1000;&#xA;var x3 &amp;gt;= -1000, &amp;lt;= 1000;&#xA;var x2 &amp;gt;= -1000, &amp;lt;= 1000;&#xA;&#xA;minimize obj : +1*x1+0;&#xA;&#xA;subject to&#xA;&#xA;constraint : (x3*y3)+(x1*y1)+(x2*y2)+0.0 = 4;&#xA;------------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and if we then run the very first script on the &lt;code&gt;model.nl&lt;/code&gt; file we just created, we get:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;Structure : MILP&#xA;Convexity : convex&#xA;------------------------------------------&#xA;var x1 &amp;gt;= -1000, &amp;lt;= 1000;&#xA;var x2 &amp;gt;= -1000, &amp;lt;= 1000;&#xA;var x3 &amp;gt;= -1000, &amp;lt;= 1000;&#xA;var x4 binary  &amp;gt;= 0, &amp;lt;= 1;&#xA;var x5 binary  &amp;gt;= 0, &amp;lt;= 1;&#xA;var x6 binary  &amp;gt;= 0, &amp;lt;= 1;&#xA;var w_xy_0 &amp;gt;= -1000, &amp;lt;= 1000;&#xA;var w_xy_1 &amp;gt;= -1000, &amp;lt;= 1000;&#xA;var w_xy_2 &amp;gt;= -1000, &amp;lt;= 1000;&#xA;&#xA;minimize obj : +1*x1+0;&#xA;&#xA;subject to&#xA;&#xA;con1 : 1.0*w_xy_2+1.0*w_xy_1+1.0*w_xy_0+0.0 = 4;&#xA;constraint_0 : -1.0*w_xy_0+-1000.0*x6+0.0 &amp;lt;= 0;&#xA;constraint_1 : 1.0*w_xy_0+-1000.0*x6+0.0 &amp;lt;= 0;&#xA;constraint_2 : -1.0*x3+1000.0*x6+1.0*w_xy_0+0.0 &amp;lt;= 0;&#xA;constraint_3 : -1.0*w_xy_0+1000.0*x6+1.0*x3+0.0 &amp;lt;= 0;&#xA;constraint_4 : -1.0*w_xy_1+-1000.0*x4+0.0 &amp;lt;= 0;&#xA;constraint_5 : 1.0*w_xy_1+-1000.0*x4+0.0 &amp;lt;= 0;&#xA;constraint_6 : -1.0*x2+1000.0*x4+1.0*w_xy_1+0.0 &amp;lt;= 0;&#xA;constraint_7 : -1.0*w_xy_1+1.0*x2+1000.0*x4+0.0 &amp;lt;= 0;&#xA;constraint_8 : -1.0*w_xy_2+-1000.0*x5+0.0 &amp;lt;= 0;&#xA;constraint_9 : 1.0*w_xy_2+-1000.0*x5+0.0 &amp;lt;= 0;&#xA;constraint_10 : -1.0*x1+1.0*w_xy_2+1000.0*x5+0.0 &amp;lt;= 0;&#xA;constraint_11 : -1.0*w_xy_2+1000.0*x5+1.0*x1+0.0 &amp;lt;= 0;&#xA;------------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;What the reformulation file does&lt;/h1&gt;&#xA;&lt;p&gt;The file uses the Reformulator Python API to encapsulate the mathematical logic, so that the same logic can be applied to any problem. I have added comments in the mod to describe the steps:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from octeract import *&#xA;&#xA;# Linearize bilinear term x*y where y is binary&#xA;# =============================================&#xA;# x_l*y-w&amp;lt;=0&#xA;# w-x_u*y&amp;lt;=0&#xA;# w-x+x_l*(1-y)&amp;lt;=0&#xA;# -w+x-x_u*(1-y)&amp;lt;=0&#xA;# xy_l&amp;lt;=w&amp;lt;=xy_u&#xA;# =============================================&#xA;&#xA;# Define symbolic trigger&#xA;my_trigger = Match('V(x)*V(y)') &#xA;&#xA;# Filter binaries and account for permutations - we bind binary to b and non-binary to nb&#xA;xbin_filter = (IsBinary('x') &amp;amp; ~ IsBinary('y') &amp;amp; Bind('x', 'b') &amp;amp; Bind('y', 'nb'))&#xA;ybin_filter = (IsBinary('y') &amp;amp; ~ IsBinary('x') &amp;amp; Bind('y', 'b') &amp;amp; Bind('x', 'nb'))&#xA;&#xA;# Combine the filters&#xA;my_filter = (xbin_filter | ybin_filter)&#xA;&#xA;# Specify how to change the model&#xA;# Add auxiliary variable with the same bounds as x*y&#xA;add_auxiliary_var = AddVariableSpan('w_xy','b*nb')&#xA;# Add parameters for the bounds of the continuous variable&#xA;add_parameters = AddParameter('nb_LB','nb','lb') + AddParameter('nb_UB','nb','ub')&#xA;substitute_term = SubWith('w_xy')&#xA;add_constraint0 = AddConstraint('nb_LB*b-w_xy &amp;lt;= 0')&#xA;add_constraint1 = AddConstraint('w_xy-nb_UB*b &amp;lt;= 0')&#xA;add_constraint2 = AddConstraint('w_xy-nb-nb_LB*(1-b) &amp;lt;= 0')&#xA;add_constraint3 = AddConstraint('-w_xy+nb-nb_UB*(1-b) &amp;lt;= 0')&#xA;&#xA;add_constraints = add_constraint0 + add_constraint1 + add_constraint2 + add_constraint3&#xA;&#xA;# Add all modifications &#xA;my_actions = add_auxiliary_var + add_parameters + substitute_term + add_constraints&#xA;&#xA;# Create mod&#xA;LinearizeBilinearContBinaryMod = (my_trigger &amp;amp; my_filter).then(my_actions)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The best part about this approach is that you only need to figure out the reformulation logic once. You can then keep using the same mods on your problems or mixing and matching rules until the end of time.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-03-31T18:47:51.367" LastActivityDate="2021-03-31T18:47:51.367" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6031" PostTypeId="2" ParentId="6023" CreationDate="2021-03-31T14:56:15.307" Score="5" Body="&lt;p&gt;With the natural binary decision variables &lt;span class=&quot;math-container&quot;&gt;$x_{s,u}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_{u,g}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z_{s,g}$&lt;/span&gt; you had defined earlier, the problem is to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_u q_u$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;q_u &amp;amp;= \frac{\sum_s h_{s,u} x_{s,u}}{\sum_s h_{s,u} (1-x_{s,u})} &amp;amp;&amp;amp;\text{for all $u$} \tag1 \\&#xA;\sum_g y_{u,g} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $u$} \tag2 \\&#xA;\sum_g z_{s,g} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $s$} \tag3 \\&#xA;\sum_s z_{s,g} &amp;amp;\le M &amp;amp;&amp;amp;\text{for all $g$} \tag4 \\&#xA;x_{s,u} &amp;amp;= \sum_g y_{u,g} z_{s,g} &amp;amp;&amp;amp;\text{for all $s,u$} \tag5 &#xA;\end{align}&lt;/span&gt;&#xA;You can linearize &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; by using a Charnes-Cooper transformation, as described &lt;a href=&quot;https://or.stackexchange.com/questions/5271/how-can-i-convexify-allowed-some-approximation-the-objective-function&quot;&gt;here&lt;/a&gt;.  You can linearize the product in &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; in the usual way, as described &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-04-21T16:13:22.477" LastActivityDate="2021-04-21T16:13:22.477" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6032" PostTypeId="1" AcceptedAnswerId="6033" CreationDate="2021-03-31T15:38:24.663" Score="8" ViewCount="342" Body="&lt;p&gt;The problem &lt;span class=&quot;math-container&quot;&gt;$$\min \ x^3 \ \mathrm{s.t.} \ x \geq 0$$&lt;/span&gt;&#xA;is sometimes said to be a convex optimization problem. &lt;span class=&quot;math-container&quot;&gt;$f(x) = x^3$&lt;/span&gt; is &lt;strong&gt;not&lt;/strong&gt; a convex function. However, in the domain of &lt;span class=&quot;math-container&quot;&gt;$x\geq 0$&lt;/span&gt; it is convex. So for some definitions this is a convex optimization problem, for others it is not. Could you please help me figure out in which &lt;strong&gt;main&lt;/strong&gt; (books like convex analysis, convex optimization, etc.) source this problem is said to be convex?&lt;/p&gt;&#xA;&lt;p&gt;I am looking to Rockafellar's convex analysis book, it says the objective function &lt;strong&gt;needs to be a proper convex function with domain &lt;span class=&quot;math-container&quot;&gt;$\{x \ : x \geq 0\}.$&lt;/span&gt;&lt;/strong&gt; Well, &lt;span class=&quot;math-container&quot;&gt;$x^3 $&lt;/span&gt; is not a proper convex function, and has domain &lt;span class=&quot;math-container&quot;&gt;$\{x\  : \ x\geq 0 \}$&lt;/span&gt;, however &lt;span class=&quot;math-container&quot;&gt;$x^3$&lt;/span&gt; restricted to this domain is a convex function. Which interpretation is correct?&lt;/p&gt;&#xA;&lt;p&gt;Note: the given example is just a simplified version of a higher-level question, so I don't actually care about minimizing &lt;span class=&quot;math-container&quot;&gt;$x^3$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2021-04-01T03:11:09.703" LastActivityDate="2021-04-01T03:11:09.703" Title="Is $\min \ x^3 \ \mathrm{s.t.}\ x \geq 0$ a convex problem?" Tags="|optimization|convex-optimization|convexity|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6033" PostTypeId="2" ParentId="6032" CreationDate="2021-03-31T15:54:35.673" Score="7" Body="&lt;p&gt;An objective function which is convex on only part of its unconstrained domain, but which is convex on the constraint set (i.e.., for any feasible point), can be 'convexified&amp;quot; by modifying the objective function to have value &lt;span class=&quot;math-container&quot;&gt;$\infty$&lt;/span&gt; for infeasible points.&lt;/p&gt;&#xA;&lt;p&gt;This is essentially what is done by Disciplined Convex Programming (DCP) systems such as CVX, which has the function &lt;code&gt;pow_p&lt;/code&gt;, which can be used as &lt;code&gt;pow_p(x,3)&lt;/code&gt;  which equals &lt;span class=&quot;math-container&quot;&gt;$x^3$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$ x\ \ge 0$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\infty$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$x &amp;lt; 0$&lt;/span&gt;.  That is indeed a convex function, and the problem is completely equivalent to the original problem as you stated. It is a convex optimization problem by anyone's definition.&lt;/p&gt;&#xA;&lt;p&gt;So I would say the answer is yes, your stated problem is convex. Definitely, as a practical matter. And to the extent that anyone disagrees, that is essentially a matter of semantics as to whether my minimal transformation is considered to still be the original problem.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2021-03-31T15:54:35.673" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6034" PostTypeId="2" ParentId="6032" CreationDate="2021-03-31T15:55:49.737" Score="3" Body="&lt;p&gt;This is a convex problem under any definition.&lt;/p&gt;&#xA;&lt;p&gt;From Wikipedia:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a convex function or if a minimum point of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is being sought, then &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is called proper if there exists some point &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; in its domain such that:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;f(x_0)&amp;lt;\infty\\&#xA;f(x) &amp;gt; -\infty&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x^3$&lt;/span&gt; is convex for &lt;span class=&quot;math-container&quot;&gt;$x\geq 0$&lt;/span&gt; and it also satisfies the above condition, making it a proper convex function for non-negative &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The same is mathematically true of any function that is only convex in a particular subdomain, when defined in only that subdomain.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-03-31T15:55:49.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6035" PostTypeId="1" AcceptedAnswerId="6036" CreationDate="2021-03-31T17:23:43.537" Score="2" ViewCount="1651" Body="&lt;p&gt;I have a minimization function which is in its simplest form looks like below. I am including the index of the variables.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;min cost * Z&#xA;&#xA;S.t.&#xA;&#xA;Z &amp;gt;= max(a1, a2, a3,....aN)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where Z and a's are variables. Since this is a minimization, I wrote a constraint in AMPL, that goes through the index of these variables and enforces the following.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Z &amp;gt;= a1&#xA;&#xA;Z &amp;gt;= a2&#xA;&#xA;......&#xA;&#xA;Z &amp;gt;= aN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, Z is set to a value that is greater than the maximum of a1, a2,....., aN. Please let me know how can I optimize this formulation so that Z is set to exactly the value of the max (a1, a2,....,aN). Do I need to use big-M formulation to do that? If yes, how do I do that?&lt;/p&gt;&#xA;" OwnerUserId="2546" LastEditorUserId="500" LastEditDate="2021-03-31T22:04:21.970" LastActivityDate="2021-04-01T13:11:59.050" Title="Linearizing a Max Function in the constraint - not working" Tags="|optimization|mixed-integer-programming|linear-programming|linearization|big-m|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="6036" PostTypeId="2" ParentId="6035" CreationDate="2021-03-31T19:47:50.370" Score="6" Body="&lt;p&gt;If you want &lt;span class=&quot;math-container&quot;&gt;$z=\max(a_1,\dots,a_n)$&lt;/span&gt;, you can first enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$z\ge\max(a_1,\dots,a_n)$&lt;/span&gt; via linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z &amp;amp;\ge a_i &amp;amp;&amp;amp;\text{for all $i$} \tag1&#xA;\end{align}&lt;/span&gt;&#xA;If you cannot rely on the objective to also enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$z\le\max(a_1,\dots,a_n)$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; be a small constant upper bound on &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$\ell_i$&lt;/span&gt; be a constant lower bound on &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;, introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, and impose linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i x_i &amp;amp;\ge 1 \tag2 \\&#xA;z - a_i &amp;amp;\le (M - \ell_i)(1-x_i) &amp;amp;&amp;amp;\text{for all $i$} \tag3&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$x_i = 1 \implies z \le a_i$&lt;/span&gt;.  Alternatively, replace &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; with an indicator constraint.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-03-31T22:04:03.863" LastActivityDate="2021-03-31T22:04:03.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6037" PostTypeId="2" ParentId="5967" CreationDate="2021-03-31T20:52:59.510" Score="1" Body="&lt;p&gt;Based on what you mentioned, you have two jobs with three operations for each. As you do not determine which processing time goes on the specific machine, I assume that each job is processed sequentially on the machines. For minimizing the tardiness of all jobs, one possible schedule is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/695rR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/695rR.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;(Solution with &lt;span class=&quot;math-container&quot;&gt;$C_{max} = 11$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$T_{max} = 4$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum{T_{i}} = 7$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Please noted that, in the shopping schedule models like this, if all of the jobs do have a specific route, the problem can be reduced to the flow shop scheduling and it might be solved in less time than the job shop problem. I recommend you took a look at the following reference, &lt;span class=&quot;math-container&quot;&gt;$P89$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.msi-jp.com/xpress/learning/square/application.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Applications of optimization with Xpress-MP&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-03-31T20:52:59.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6038" PostTypeId="2" ParentId="6035" CreationDate="2021-03-31T21:56:07.140" Score="3" Body="&lt;p&gt;You could try fudging the objective function by replacing any zero cost with a cost of &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is chosen small enough not to cause the selection of a suboptimal solution but large enough that &lt;span class=&quot;math-container&quot;&gt;$\epsilon * (z-\max_i a_i)$&lt;/span&gt; does not look like rounding error to the solver. Selecting &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is a bit of an art form, but if this works it avoids the &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; constant and extra binary variables in Rob's approach.&lt;/p&gt;&#xA;&lt;p&gt;Another possibility: Can you just solve your model as it currently is and then post-process the solution, adjusting &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; downward as needed?&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-03-31T21:56:07.140" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6039" PostTypeId="1" AcceptedAnswerId="6052" CreationDate="2021-03-31T22:37:06.803" Score="0" ViewCount="203" Body="&lt;p&gt;I am currently trying to implement a piecewise McCormick envelope in &lt;a href=&quot;https://drake.mit.edu/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Drake&lt;/a&gt; (c++). The current issue I am having is that the solution produced by the optimization does not produce a valid &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; values (outside my specified bounds or infeasible) and &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;&amp;quot; is not close to &lt;span class=&quot;math-container&quot;&gt;$x*y$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have used several references such as &lt;a href=&quot;http://www.roboticsproceedings.org/rss16/p047.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;A Global Quasi-Dynamic Model for Contact-Trajectory Optimization&lt;/a&gt;, &lt;a href=&quot;https://optimization.mccormick.northwestern.edu/index.php/McCormick_envelopes&quot; rel=&quot;nofollow noreferrer&quot;&gt;McCormick envelopes Northwestern Wiki&lt;/a&gt;, and more, but I have based off the code below from &lt;a href=&quot;https://groups.csail.mit.edu/robotics-center/public_papers/Valenzuela16.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mixed-Integer Convex Optimization for Planning Aggressive Motions of Legged Robots Over Rough Terrain&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A few things that I felt were missing from this particular paper was the sum of the binary decision variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; equal to 1. If I'm not mistaken, one piece of the piecewise McCormick envelope gets chosen by the optimization, thus, the sum of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; should be equal to 1.&lt;/p&gt;&#xA;&lt;p&gt;Gurobi was used to solve this problem.&lt;/p&gt;&#xA;&lt;p&gt;I would like to know if I am missing any major components to the piecewise McCormick envelope.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    solvers::MathematicalProgram prog = solvers::MathematicalProgram();&#xA;&#xA;    // For this problem, M &amp;lt; 4 gives a solution. However, it may be incorrect. &#xA;    // M &amp;gt;= 4 makes the problem infeasible &#xA;    const int M = 6; //number of partitions&#xA;&#xA;    solvers::VectorDecisionVariable&amp;lt;1&amp;gt; x = prog.NewContinuousVariables&amp;lt;1&amp;gt;(&amp;quot;x&amp;quot;); &#xA;    solvers::VectorDecisionVariable&amp;lt;1&amp;gt; y = prog.NewContinuousVariables&amp;lt;1&amp;gt;(&amp;quot;y&amp;quot;); &#xA;    solvers::VectorXDecisionVariable x_hat = prog.NewContinuousVariables(M, &amp;quot;x_hat&amp;quot;);&#xA;    solvers::VectorXDecisionVariable y_hat = prog.NewContinuousVariables(M, &amp;quot;y_hat&amp;quot;);&#xA;    solvers::VectorDecisionVariable&amp;lt;1&amp;gt; w = prog.NewContinuousVariables&amp;lt;1&amp;gt;(&amp;quot;w&amp;quot;); &#xA;    solvers::VectorXDecisionVariable z = prog.NewBinaryVariables(M, &amp;quot;z&amp;quot;); &#xA;    //solvers::VectorDecisionVariable&amp;lt;1&amp;gt; lorentz = prog.NewContinuousVariables&amp;lt;1&amp;gt;(&amp;quot;lorentz&amp;quot;);&#xA;&#xA;    const double x_upper = 1;&#xA;    const double x_lower = 0; &#xA; &#xA;    // Replacing quadratic cost with rotated lorentz cone in the future. (developer's suggesting for better results)&#xA;    // prog.AddLinearCost(lorentz[0]);&#xA;    // prog.AddRotatedLorentzConeConstraint(&#xA;    //   symbolic::Expression(lorentz[0]), symbolic::Expression(1), (0.4-w[0])*2*(0.4-w[0]) + (0.5-x[0])*10*(0.5-x[0])&#xA;    // );&#xA;&#xA;    //Min 2*(0.4-w)^2 + 10*(0.5-x)^2   --&amp;gt; solution should be x:0.5, y:0.8, w:0.4&#xA;    prog.AddCost((0.4-w[0])*2*(0.4-w[0]) + (0.5-x[0])*10*(0.5-x[0]));  &#xA;&#xA;    VectorXd x_bounds(M+1);&#xA;    x_bounds = VectorXd::Zero(M+1);&#xA;&#xA;    // Generate evenly distributed upper and lower bounds&#xA;    for(int i = 0; i &amp;lt;= M; i++){&#xA;      x_bounds(i) = i*(x_upper-x_lower)/M + x_lower;&#xA;    }&#xA;&#xA;    Expression e_x; //Sum of x_hat&#xA;    Expression e_y; //Sum of y_hat&#xA;    Expression e_z; //Sum of z&#xA;&#xA;    Expression e_1;&#xA;    Expression e_2;&#xA;    Expression e_3;&#xA;    Expression e_4;&#xA;&#xA;    for(int k = 0; k &amp;lt; M; k++){&#xA;&#xA;      // Bound constraints for all x_hat and y_hat values&#xA;      prog.AddLinearConstraint(&#xA;        x_bounds(k)*z[k] &amp;lt;= x_hat[k] &amp;amp;&amp;amp; x_hat[k] &amp;lt;= x_bounds(k+1)*z[k] &amp;amp;&amp;amp; &#xA;        0 &amp;lt;= y_hat[k] &amp;amp;&amp;amp; y_hat[k] &amp;lt;= z[k]&#xA;      );&#xA;      // The constraint below has been removed.&#xA;      // y_bounds(k)*z[k] &amp;lt;= y_hat[k] &amp;amp;&amp;amp; y_hat[k] &amp;lt;= y_bounds(k+1)*z[k]&#xA;&#xA;      // Add sum of lower and upper bounds&#xA;      e_1 += x_bounds(k)*y_hat[k]; &#xA;      e_2 += x_bounds(k+1)*y_hat[k] + x_hat[k] - x_bounds(k+1);&#xA;      e_3 += x_bounds(k)*y_hat[k] + x_hat[k] - x_bounds(k);&#xA;      e_4 += x_bounds(k+1)*y_hat[k];&#xA;&#xA;      e_x += x_hat[k];  // e_x += x_hat[M-1]; The paper has capital M but I assumed that this is a mistake. &#xA;      e_y += y_hat[k];  // e_y += y_hat[M-1]; &#xA;      e_z += z[k];      //Sum of binary decision variable z &#xA;    }&#xA;&#xA;    prog.AddLinearConstraint(&#xA;      w[0] &amp;gt;= e_1 &amp;amp;&amp;amp;&#xA;      w[0] &amp;gt;= e_2 &amp;amp;&amp;amp;&#xA;      w[0] &amp;lt;= e_3 &amp;amp;&amp;amp;&#xA;      w[0] &amp;lt;= e_4 &amp;amp;&amp;amp;&#xA;&#xA;      x[0] == e_x &amp;amp;&amp;amp;&#xA;      y[0] == e_y &amp;amp;&amp;amp;&#xA;      e_z == 1 &#xA;    );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5258" LastEditorUserId="5258" LastEditDate="2021-04-05T23:07:55.990" LastActivityDate="2021-04-05T23:07:55.990" Title="Invalid solutions to Piecewise Mccormick Envelope Implementation" Tags="|optimization|c++|mccormick|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6040" PostTypeId="1" CreationDate="2021-04-01T04:41:47.357" Score="3" ViewCount="322" Body="&lt;p&gt;Suppose I want to set the price &lt;span class=&quot;math-container&quot;&gt;$0 \le p_t \le p_{max} $&lt;/span&gt; and based on the price, demand is determined &lt;span class=&quot;math-container&quot;&gt;$D_t(p_t)=a-bp_t$&lt;/span&gt;. Inventory level at each time is denoted by &lt;span class=&quot;math-container&quot;&gt;$I_t$&lt;/span&gt; and it is determined by &lt;span class=&quot;math-container&quot;&gt;$I_t= I_{t-1}+x_t-D_t$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; is the quantity that is refilled. Now, the quantity that we can send to customers is determined based on the inventory level and demand, &lt;span class=&quot;math-container&quot;&gt;$z_t \le I_{t-1}+x_{t}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$z_t \le D_t(p_t)$&lt;/span&gt;. Now, consider a part of objective function &lt;span class=&quot;math-container&quot;&gt;$\sum_{t\in T}p_t.z_t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Gurobi can solve it regardless if it is convex or concave. Now, suppose we discretize the price with &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; levels and price is re-written as &lt;span class=&quot;math-container&quot;&gt;$p_t=\sum_{l \in L}p_ly_{lt}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\sum_{l \in L}y_{lt}=1 \quad \forall t \in T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Regardsless the gap between these two formulation, I am wondering which formulation is well-suited for solvers like Gurobi, because in the second formulation, the number of decision variables increases and there will be some binary variables. This will be more severe if it depends on scenarios, i.e., &lt;span class=&quot;math-container&quot;&gt;$p_{ts}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;One more question, if I use the second formulation, should I linearized the objective function or Gurobi can do it by it-self? That is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max  \sum_{t \in T}\sum_{l \in L}p_l W_{lt}&#xA;\\&#xA; W_{lt} \le M.y_{lt} &#xA;\\&#xA;W_{lt} \le z_t&#xA;\\&#xA;\sum_{l \in L}y_{lt}=1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="500" LastEditDate="2021-04-01T04:53:06.567" LastActivityDate="2021-04-01T06:47:45.233" Title="Linearizing a quadratic function with more variables or not in Gurobi?" Tags="|mixed-integer-programming|linearization|gurobi|quadratic-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6041" PostTypeId="2" ParentId="6040" CreationDate="2021-04-01T06:47:45.233" Score="6" Body="&lt;p&gt;You can ask Gurobi to do this for you&#xA;&lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/preqlinearize.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.1/refman/preqlinearize.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Whether a linearization leads to better or worse performance is almost impossible to know beforehand. You will simply have to test.&lt;/p&gt;&#xA;&lt;p&gt;Cplex for instance uses an ML-trained classifier to make this decision, indicating that it is hard to come up with any simple rule manually&#xA;&lt;a href=&quot;http://www.optimization-online.org/DB_HTML/2020/03/7662.html&quot; rel=&quot;noreferrer&quot;&gt;http://www.optimization-online.org/DB_HTML/2020/03/7662.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2021-04-01T06:47:45.233" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6042" PostTypeId="2" ParentId="6035" CreationDate="2021-04-01T13:11:59.050" Score="1" Body="&lt;p&gt;Some modeling languages allow max and then you do not need to use big M.&lt;/p&gt;&#xA;&lt;p&gt;With CPLEX in OPL you can write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int nbKids=300;&#xA;&#xA;{int} buses={30,40,50};&#xA;&#xA;&#xA;dvar int+ nbBus[buses];&#xA;dvar int maxNbOfBusesGivenSize;&#xA;&#xA;    &#xA;minimize maxNbOfBusesGivenSize;&#xA;     &#xA;subject to&#xA;{&#xA; maxNbOfBusesGivenSize==max(i in buses) nbBus[i];&#xA; sum(i in buses) i*nbBus[i]&amp;gt;=nbKids;&#xA;}&#xA;&#xA;execute DISPLAY_After_SOLVE&#xA;{&#xA;  writeln(&amp;quot;The max number of buses is &amp;quot;,maxNbOfBusesGivenSize);&#xA;  writeln(&amp;quot;nbBus = &amp;quot;,nbBus);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and in python docplex&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;mdl = Model(name='buses')&#xA;&#xA;nbKids=300;&#xA;buses=[30,40,50]&#xA;&#xA;#decision variables&#xA;mdl.nbBus = {b: mdl.integer_var(name=&amp;quot;nbBus&amp;quot;+str(b)) for b in buses}&#xA;&#xA;# Constraint&#xA;mdl.add_constraint(sum(mdl.nbBus[b]*b for b in buses) &amp;gt;= nbKids, 'kids')&#xA;&#xA;# Objective&#xA;mdl.minimize(mdl.max(mdl.nbBus[b] for b in buses)) &#xA;&#xA;mdl.solve(log_output=True,)&#xA;&#xA;mdl.export(&amp;quot;c:\\temp\\buses.lp&amp;quot;)&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-04-01T13:11:59.050" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6043" PostTypeId="1" AcceptedAnswerId="6047" CreationDate="2021-04-01T14:44:57.273" Score="1" ViewCount="206" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;We wish to apply dynamic programming techniques to find the optimal betting strategy for a pool to wager on the outcome of the NCAA men's basketball tournament&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;64 teams compete in a single elimination bracket that lasts for 6 rounds. For each game, the winner will advance and the loser is to be eliminated. The victor is whoever wins 6 games in a row.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Each bracket is split into four regions with 16 teams each. Each team is assigned a seed from 1 to 16 (best to worst).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Before the tournament begins, each player (i.e. the better) who enters the pool is allowed to purchase up to one dollar's worth of teams. We know the outcome of the tournament. This is not a stochastic process. We wish to determine what WOULD have been the optimal betting strategy.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$c_k$&lt;/span&gt; denote the cost of seed &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; denote the number of wins team &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; received. Let &lt;span class=&quot;math-container&quot;&gt;$q_i$&lt;/span&gt; denote the seed of team &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Here is my work so far:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The stages will be the number of teams we have selected thus far, denote this by &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0 \leq j \leq 64$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The state will be &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; amount of money used in the budget as well as a vector &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; where each entry is a binary indicating whether we have selected team &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; or not (&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; = selected)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$f_j(s,v)$&lt;/span&gt; denote the maximum amount of wins to gain, given we have chosen &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; teams and have used up &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; dollars and have selected &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; teams, where &lt;span class=&quot;math-container&quot;&gt;$v[i]=1$&lt;/span&gt; if team &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; was chosen.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I now need to construct a recurrence relation for the dynamic program. This is why my trouble lies. So far I have:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f_j(s,v) = \max_{i, s + \text{extra cost} \leq 1}\{\sum_{i = 0}^{63} p_iv_i + f_{j+1}(s+\text{additional cost}, \text{appropriately update v vector})\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The recurrence function is intended to maximize the amount of wins at a given stage (choosing a team) while not going over budget as well as not betting on team already selected. I am struggling to capture the additional cost at each stage of selecting a cohort of teams given the parameters I have to work with. Furthermore, I am not sure how to update my vector &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; using mathematical notation. In practice, I would set a &lt;span class=&quot;math-container&quot;&gt;$64\times 1$&lt;/span&gt; array and initialize all entries to be zero. Then, I'd check which entries would provide the greatest net gain by flipping the value to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; as well as being within budget. However, again, I am struggling to properly model this action.&lt;/p&gt;&#xA;" OwnerUserId="3231" LastEditorUserId="3231" LastEditDate="2021-04-04T15:54:11.650" LastActivityDate="2021-04-04T15:54:11.650" Title="Dynamic Programming - Formulating recurrence relation" Tags="|python|knapsack|dynamic-programming|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="6044" PostTypeId="1" AcceptedAnswerId="6051" CreationDate="2021-04-01T22:19:01.160" Score="4" ViewCount="624" Body="&lt;p&gt;This is not a very technical question, but I'm having trouble finding any information about it. I often use CPLEX to solve my &lt;a href=&quot;http://switch-model.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;power system planning problems&lt;/a&gt;. I just noticed  that CPLEX suddenly jumped from version 12.10.0 (December 2019) to 20.1.0 (December 2020) (see &lt;a href=&quot;https://en.wikipedia.org/wiki/CPLEX#Release_History&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt; and  &lt;a href=&quot;https://www.ibm.com/docs/en/icos&quot; rel=&quot;nofollow noreferrer&quot;&gt;IBM's documentation website&lt;/a&gt;). Does anyone know why IBM skipped over versions 13-19?  Is there something radically different about version 20?&lt;/p&gt;&#xA;" OwnerUserId="5262" LastActivityDate="2021-04-13T07:51:59.063" Title="Why did CPLEX jump from version 12 to version 20?" Tags="|cplex|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6046" PostTypeId="1" AcceptedAnswerId="6049" CreationDate="2021-04-02T01:23:58.503" Score="1" ViewCount="224" Body="&lt;p&gt;In an NLP, I have a constraint that I would like to formulate in a convex manner preferably without introducing binary variables and/or big M formulations if possible. The actual problem is non-convex and I am happy with a local solution but I want to avoid any integer variables as there is not a good choice of open-source solvers for nonlinear problems. But of course, if it is not possible to avoid binary variables then it should be fine. The issue is to reformulate IF-THEN-ELSE condition of the type below to determine the appropriate parameter to use:&#xA;&lt;span class=&quot;math-container&quot;&gt;$ IF \hspace{0.5mm}\ \sum_{i=1}^{n}\left(x_i{\ c}_i^t\ \ -{\ L}_t\right)\ &amp;lt;0$&lt;/span&gt;&#xA;Then &lt;span class=&quot;math-container&quot;&gt;$\hspace{0.5mm}\ r_t\ =\ s_t  \hspace{0.5mm}\ Else \hspace{0.5mm}\ r_t\ =\ g_t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;r, s , g and L are constant parameters (time dependent)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is a vector of optimisation variables (continuous)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;${\ c}_i^t$&lt;/span&gt; are coefficients of &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The actual constraint is given by:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{t=1}^{T}{EP}_t=0\ $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&#xA;&lt;span class=&quot;math-container&quot;&gt;${EP}_0\ =\ 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${EP}_1\ =\ \sum_{i=1}^{n}{x_ic_i^1} - L_1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${EP}_2\ =\ \sum_{i=1}^{n}{x_ic_i^2} - L_2\ +\ {EP}_1\ r_1\ $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${EP}_3\ =\ \sum_{i=1}^{n}{x_ic_i^3} - L_3\ +\ {EP}_2\ r_2\  $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${EP}_t\ =\ \sum_{i=1}^{n}{x_ic_i^t} - L_t\ +\ {EP}_{t-1}\ r_t\ $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$If\ {EP}_{t-1}\ &amp;lt;0\  then \hspace{0.5mm}\ r_t\ =\ s_t \hspace{0.5mm}\&#xA;Else \hspace{0.5mm}\ r_t\ =\ g_t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$r_t, \hspace{0.5mm}\ s_t , \hspace{0.5mm}\ g_t and \hspace{0.5mm}\ L_t$&lt;/span&gt; are constants&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$0\leq x_i \leq 1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\hspace{5mm}\ i  \in {1,2...n}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;${\ c}_i^t$&lt;/span&gt; are coefficients of &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Only &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;  are the optimisation variables&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;How can this constraint be reformulated either using Big M /binary variables or using some other formulation? I don't want to use IF in the constraint as it will make the problem hard to solve. Please note that there are a number of other nonlinear constraints in the model.&lt;/strong&gt; I was thinking that we may be able to write it using min and max, e.g.,&#xA;&lt;span class=&quot;math-container&quot;&gt;${EP}_t\ =\ \sum_{i=1}^{n}{x_ic_i^t}\ +\ min\left\{0,{EP}_{t-1}\ \right\}\ s_t\ \ +\ max\left\{0,{EP}_{t-1}\ \right\}\ g_t$&lt;/span&gt;&#xA;and then introduce some auxiliary variables but I am not sure where to go next.&lt;/p&gt;&#xA;&lt;p&gt;I have given a numerical example in the attached image which explains how this constraint is constructed and where we have determined value of x.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c = \begin{pmatrix} 1 &amp;amp; 20 &amp;amp; 30 &amp;amp; 40\\ &#xA;1 &amp;amp; 2 &amp;amp; 60 &amp;amp; 2\\ &#xA;5 &amp;amp; 3 &amp;amp; 2 &amp;amp; 1\\ &#xA;10 &amp;amp; 8 &amp;amp; 5 &amp;amp; 40\\ &#xA;3 &amp;amp; 6 &amp;amp; 2 &amp;amp; 3&#xA;\end{pmatrix}&#xA;, \hspace{0.5mm}\ L = \begin{pmatrix}&#xA;30\\ &#xA;60\\ &#xA;30\\ &#xA;20\\ &#xA;1&#xA;\end{pmatrix} , \hspace{0.5mm}\ x = \begin{pmatrix}&#xA;x_1\\ &#xA;x_2\\ &#xA;x_3\\ &#xA;x_4&#xA;\end{pmatrix}, s = \begin{pmatrix}&#xA;0.001\\ &#xA;0.002\\ &#xA;0.003\\ &#xA;0.004\\ &#xA;0.005&#xA;\end{pmatrix}&#xA;, g = \begin{pmatrix}&#xA;0.006\\ &#xA;0.050\\ &#xA;0.009\\ &#xA;0.010\\ &#xA;0.020&#xA;\end{pmatrix}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The above constraint will be satisfied for the following values of&#xA;&lt;span class=&quot;math-container&quot;&gt;$x = \begin{pmatrix}&#xA;0.363034965\\&#xA;0.514820246\\&#xA;0.539183467\\&#xA;0.856864726\\&#xA;\end{pmatrix}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9JXB4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9JXB4.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4870" LastEditorUserId="500" LastEditDate="2021-04-02T14:19:32.373" LastActivityDate="2021-04-05T12:00:25.387" Title="Non-linear optimization local or global solution" Tags="|mixed-integer-programming|linearization|nonlinear-programming|nonconvex-programming|big-m|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6047" PostTypeId="2" ParentId="6043" CreationDate="2021-04-02T01:32:16.427" Score="5" Body="&lt;p&gt;You have an instance of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Knapsack_problem#0-1_knapsack_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;0-1 knapsack problem&lt;/a&gt; where you want to determine which teams to select to maximize the number of wins, subject to a budget.  The linked page provides a DP recurrence, which is obtained by conditioning on whether or not you select the next team.&lt;/p&gt;&#xA;&lt;p&gt;The optimal objective value for your instance is 28:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{matrix}&#xA;\text{team}  &amp;amp;  \text{wins}  &amp;amp;  \text{seed}  &amp;amp;  \text{cost}  \\&#xA;\hline&#xA;1  &amp;amp;  6  &amp;amp;  1  &amp;amp;  25 \\&#xA;2  &amp;amp;  5  &amp;amp;  3  &amp;amp;  18 \\&#xA;4  &amp;amp;  4  &amp;amp;  5  &amp;amp;  12 \\&#xA;15 &amp;amp;  2  &amp;amp;  12 &amp;amp;  2  \\&#xA;17 &amp;amp;  1  &amp;amp;  9  &amp;amp;  5  \\&#xA;18 &amp;amp;  1  &amp;amp;  12 &amp;amp;  2  \\&#xA;20 &amp;amp;  1  &amp;amp;  10 &amp;amp;  4  \\&#xA;21 &amp;amp;  1  &amp;amp;  9  &amp;amp;  5  \\&#xA;22 &amp;amp;  1  &amp;amp;  12 &amp;amp;  2  \\&#xA;24 &amp;amp;  1  &amp;amp;  10 &amp;amp;  4  \\&#xA;25 &amp;amp;  1  &amp;amp;  9  &amp;amp;  5  \\&#xA;27 &amp;amp;  1  &amp;amp;  11 &amp;amp;  3  \\&#xA;29 &amp;amp;  1  &amp;amp;  9  &amp;amp;  5  \\&#xA;30 &amp;amp;  1  &amp;amp;  13 &amp;amp;  1  \\&#xA;32 &amp;amp;  1  &amp;amp;  10 &amp;amp;  4  \\&#xA;\hline&#xA;   &amp;amp;  28 &amp;amp;     &amp;amp;  97 \\&#xA;\end{matrix}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Your code incorrectly yields 29 because your budget check should instead be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if s + seed_costs[teams[j][0]] &amp;lt;= budget:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-04-02T03:54:17.183" LastActivityDate="2021-04-02T03:54:17.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6048" PostTypeId="1" CreationDate="2021-04-02T02:19:09.273" Score="1" ViewCount="936" Body="&lt;p&gt;I would like to find dual values and reduced costs after solving a MIP problem using CPLEX. IBM's &lt;a href=&quot;https://www.ibm.com/support/pages/trying-obtain-dual-variables-and-reduced-costs-after-solving-mip&quot; rel=&quot;nofollow noreferrer&quot;&gt;solution in this case&lt;/a&gt; is to fix the integer variables to create a “&lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=solution-working-fixed-mip-problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;fixed MIP problem&lt;/a&gt;”, then solve this continuous problem and obtain the duals and reduced costs from that.&lt;/p&gt;&#xA;&lt;p&gt;I do this by using the following commands in the CPLEX Interactive Optimizer:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set timelimit 1200&#xA;set threads 1&#xA;read /tmp/tmpu8f4obrb.pyomo.lp&#xA;optimize&#xA;change problem fix&#xA;optimize&#xA;write /tmp/tmp55qy8xe5.cplex.sol&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This works well for my problems most of the time, but sometimes the first optimization stage will reach the time limit and return an integer feasible solution, but then the second stage will report infeasibility, e.g., &lt;code&gt;Infeasibility row 'c_u_x495386_':  0 &amp;lt;= -0.00011798.&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm assuming this occurs because the initial solution isn’t quite integral, and then in the second stage CPLEX finds a constraint where one now-fixed variable is supposed to match up with another now-fixed variable or expression, and it doesn't quite work. (This is my assumption, but I could be wrong...)&lt;/p&gt;&#xA;&lt;p&gt;So my question is, are there settings I can adjust for the first optimization to get a “more integral” solution or for the second optimization to tolerate the non-integrality of the first solution?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Looking a little deeper, I find that the infeasible constraint has the form &lt;code&gt;commit_amount &amp;lt;= 1505.86 * is_committed&lt;/code&gt;. In this problem, &lt;code&gt;commit_amount&lt;/code&gt; is a continuous variable that is separately constrained to equal &lt;code&gt;150.586 * unit_size&lt;/code&gt;, where &lt;code&gt;unit_size&lt;/code&gt; is a general integer variable. &lt;code&gt;is_committed&lt;/code&gt; is a binary variable. In the incumbent solution (before changing to a fixed mip), &lt;code&gt;commit_amount = 0&lt;/code&gt; and &lt;code&gt;is_committed = -7.8347247411958421e-08&lt;/code&gt;. So when the integer variables are fixed, this constraint becomes &lt;code&gt;0 &amp;lt;= 1505.86 * -7.8347247411958421e-08&lt;/code&gt; or &lt;code&gt;0 &amp;lt;= -0.00011798&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So my original intuition seems to be right: in the initial optimization, CPLEX has set the binary variable &lt;code&gt;is_committed&lt;/code&gt; to a small negative value. Then, when the integer variables are fixed at the incumbent values, the problem becomes infeasible. But I don't know how to get the second stage to solve under these conditions.&lt;/p&gt;&#xA;" OwnerUserId="5262" LastEditorUserId="5262" LastEditDate="2021-04-02T19:54:49.273" LastActivityDate="2021-04-05T19:10:27.933" Title="Avoid infeasibility in &quot;fixed MIP problem&quot; in CPLEX" Tags="|cplex|parameters-tuning|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6049" PostTypeId="2" ParentId="6046" CreationDate="2021-04-02T11:08:01.470" Score="5" Body="&lt;p&gt;Introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta_t$&lt;/span&gt; to represent which case it is and &lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt; to represent the modelled product, and your MILP model of the piecewise-affine dynamics would be&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${EP}_t\ =\ \sum_{i=1}^{n}{x_ic_i^t}\ -L_t + z_t\\ &#xA;{EP}_{t-1}\leq (1-\delta_t)M, -(1-\delta_t)M \leq z_t - s_t{EP}_{t-1}\leq (1-\delta_t)M\\&#xA;~{EP}_{t-1}\geq -\delta_t M, -\delta_tM \leq z_t - g_t{EP}_{t-1}\leq \delta_t M$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="487" LastEditorUserId="487" LastEditDate="2021-04-05T12:00:25.387" LastActivityDate="2021-04-05T12:00:25.387" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6051" PostTypeId="2" ParentId="6044" CreationDate="2021-04-02T15:54:28.060" Score="5" Body="&lt;p&gt;I don't know why the version number jumped. I will say that I found the creeping pace documented in Mark's comment odd from a marketing perspective -- it might lead a consumer to think IBM was just patching the occasional bug while competitors (with faster moving version numbers) were making technological &amp;quot;leaps&amp;quot;. Maybe someone at IBM had the same thought?&lt;/p&gt;&#xA;&lt;p&gt;As for the last question, no, I would not say there is anything radically different about 20.1. There are one or two new features (which I cannot recall offhand), but my use of it has not changed in any fundamental way from what I was doing with 12.10.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-04-02T15:54:28.060" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6052" PostTypeId="2" ParentId="6039" CreationDate="2021-04-02T19:12:36.333" Score="3" Body="&lt;p&gt;I agree that the &lt;code&gt;e_z == 1&lt;/code&gt; constraint belongs in the model. Your constraints &lt;code&gt;y_bounds(k)*z[k] &amp;lt;= y_hat[k] &amp;amp;&amp;amp; y_hat[k] &amp;lt;= y_bounds(k+1)*z[k]&lt;/code&gt; do not appear in the Valenzuela dissertation, though, and I suspect they are the source of your troubles. Note, for example, that if &lt;span class=&quot;math-container&quot;&gt;$M=10$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z[3] = 1$&lt;/span&gt;, you are forcing &lt;span class=&quot;math-container&quot;&gt;$x\in [0.3, 0.4]$&lt;/span&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$y\in [0.3,0.4]$&lt;/span&gt;, the latter restriction for no apparent reason.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="123" LastEditDate="2021-04-02T19:40:45.847" LastActivityDate="2021-04-02T19:40:45.847" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6053" PostTypeId="1" AcceptedAnswerId="6055" CreationDate="2021-04-03T22:08:26.607" Score="2" ViewCount="145" Body="&lt;p&gt;In [1] the authors define the RCPSP (resource-constrained project scheduling problem) as follows:&lt;/p&gt;&#xA;&lt;p&gt;minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{t} t x_{n t}&#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{c}&#xA;\sum_{t} x_{j t}=1, \quad j \in J, \\&#xA;\sum_{s=t}^{T} x_{i s}+\sum_{s=0}^{t+d_{i j}-1} x_{j s} \leq 1, \quad(i, j) \in L, t=0, \ldots, T, \\&#xA;x_{j t} \geq 0, \quad j \in J, t=0, \ldots, T, \\&#xA;x_{j t} \text { integer, } \quad j \in J, t=0, \ldots, T \\&#xA;\sum_{j} r_{j k}\left(\sum_{s=t-p_{j}+1}^{t} x_{j s}\right) \leq R_{k}, k \in R, t=0, \ldots, T .&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What I do not understand here is the second constraint, which is the precedence constraint. Why do we need the sum &lt;span class=&quot;math-container&quot;&gt;$\sum_{s=t}^{T} x_{i s} $&lt;/span&gt; and cannot just use  &lt;span class=&quot;math-container&quot;&gt;$x_{i t} $&lt;/span&gt; instead? Would'nt&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{i t}+\sum_{s=0}^{t+d_{i j}-1} x_{j s} \leq 1, \quad(i, j) \in L, t=0, \ldots, T \\&#xA;$$&lt;/span&gt;&#xA;be enough to be sure that if the predecessor starts at time t the successor j cannot start at any time before &lt;span class=&quot;math-container&quot;&gt;$t+d_{i j}$&lt;/span&gt;, when &lt;span class=&quot;math-container&quot;&gt;$d_{i j}$&lt;/span&gt; is the enforced time lag between the predecessor i and succesor j (which equals the duration of the predecessor if we have strict finish-start precedence constraints)?&lt;/p&gt;&#xA;&lt;p&gt;[1] Möhring, Rolf H.; Schulz, Andreas S.; Stork, Frederik; Uetz, Marc (2003): Solving Project Scheduling Problems by Minimum Cut Computations. In: Management Science 49 (3), S. 330–350. DOI: 10.1287/mnsc.49.3.330.12737.&lt;/p&gt;&#xA;" OwnerUserId="5273" LastActivityDate="2021-04-04T02:30:31.890" Title="How does the RCPSP's precedence constraint work?" Tags="|mixed-integer-programming|modeling|integer-programming|scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6055" PostTypeId="2" ParentId="6053" CreationDate="2021-04-04T02:30:31.890" Score="3" Body="&lt;p&gt;Yes, your proposal suffices. But the published second constraint is stronger, yielding a tighter formulation.  You can think of it as a lifting obtained by using the first constraint.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-04-04T02:30:31.890" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6056" PostTypeId="2" ParentId="6048" CreationDate="2021-04-04T15:53:56.280" Score="5" Body="&lt;p&gt;The second-stage infeasibility arises because the original MIP solution from CPLEX is technically infeasible.&lt;/p&gt;&#xA;&lt;p&gt;My best guess is that there are 3 things at play here: CPLEX' primal tolerance, integrality tolerance, and internal presolve/rescaling. The last one matters because, as I explain below, tolerances are typically applied on the presolved, rescaled problem (not necessarily the one you gave to CPLEX).&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The integrality tolerance &lt;span class=&quot;math-container&quot;&gt;$\epsilon_{i}$&lt;/span&gt; (default value &lt;span class=&quot;math-container&quot;&gt;$10^{-5}$&lt;/span&gt;) means that a binary variable that takes value, e.g., &lt;span class=&quot;math-container&quot;&gt;$0 \pm \epsilon$&lt;/span&gt;, is treated as binary-feasible by CPLEX.&#xA;You can change the value of &lt;span class=&quot;math-container&quot;&gt;$\epsilon_{i}$&lt;/span&gt; via the &lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=parameters-integrality-tolerance&quot; rel=&quot;noreferrer&quot;&gt;&amp;quot;Integrality tolerance&amp;quot; parameter&lt;/a&gt; in CPLEX.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;CPLEX also has some tolerance &lt;span class=&quot;math-container&quot;&gt;$\epsilon_{p}$&lt;/span&gt; (default value &lt;span class=&quot;math-container&quot;&gt;$10^{-6}$&lt;/span&gt;) on primal constraint violation. This means that a constraint &lt;span class=&quot;math-container&quot;&gt;$a^{T}x = b +\pm \epsilon_{p}$&lt;/span&gt; will be treated as non-violated. You can also tighten that, via CPLEX' &lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=parameters-feasibility-tolerance&quot; rel=&quot;noreferrer&quot;&gt;&amp;quot;feasibility tolerance&amp;quot; parameter&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Before solving the problem, CPLEX applies presolve, and will re-scale the problem to make more numerically stable. This is an internal procedure. Typically, the above tolerances apply to the &lt;em&gt;scaled&lt;/em&gt; model, not the original one.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In the example you gave, and for the MIP solution you report, the constraint &lt;code&gt;commit_amount &amp;lt;= 1505.86 * is_committed&lt;/code&gt; is violated by roughly &lt;span class=&quot;math-container&quot;&gt;$10^{-4}$&lt;/span&gt;, which is above the default feasibility tolerance of &lt;span class=&quot;math-container&quot;&gt;$10^{-6}$&lt;/span&gt;.&#xA;What likely happened is that, in the initial MIP solve, this constraint was rescaled to, e.g., &lt;code&gt;0.001 * commit_amount &amp;lt;= 1.50586 * is_committed&lt;/code&gt;, in which case the violation becomes &lt;span class=&quot;math-container&quot;&gt;$\simeq 10^{-7}$&lt;/span&gt;, which CPLEX would consider feasible.&lt;/p&gt;&#xA;&lt;p&gt;To get rid of the infeasibility issue in your second stage, you could try:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;tighten CPLEX' tolerances in the initial MIP solve, e.g., &lt;span class=&quot;math-container&quot;&gt;$10^{-8}$&lt;/span&gt; feasibility and &lt;span class=&quot;math-container&quot;&gt;$10^{-8}$&lt;/span&gt; integrality tolerances. This will reduce the likelyhodd of CPLEX returning a solution that's technically infeasible, but it will likely increase solution time (impossible to know by much unless you try it out).&lt;/li&gt;&#xA;&lt;li&gt;slightly relax the constraints in the second stage solve, to further reduce the risk of infeasibility. For instance, relax each inequality constraint by something like &lt;span class=&quot;math-container&quot;&gt;$10^{-6}$&lt;/span&gt; before solving for the second time.&lt;/li&gt;&#xA;&lt;li&gt;play with CPLEX's &lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=parameters-scale-parameter&quot; rel=&quot;noreferrer&quot;&gt;scale parameter&lt;/a&gt; as well, though it's usually better to keep this to default.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2021-04-04T15:53:56.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6057" PostTypeId="1" CreationDate="2021-04-05T12:31:00.763" Score="4" ViewCount="271" Body="&lt;p&gt;I am studying an assignment problem with batching costs, and I would like to know if there is a standard name or algorithm for this problem. I know this problem can be formulated as mixed-integer programming and be solved using the solvers, but I am looking for algorithms that are faster than the standard MILP methods. Both exact and approximated algorithms are appreciated, and polynomial-time methods are expected if exist.&lt;/p&gt;&#xA;&lt;p&gt;The problem is: We have &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; jobs that can be assigned to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; workers, &lt;span class=&quot;math-container&quot;&gt;$j&amp;gt;i$&lt;/span&gt;. Each job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; has a cost when assigned to worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, namely, &lt;span class=&quot;math-container&quot;&gt;$w_{ij}$&lt;/span&gt;. Each worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; can work with one or two job(s). When worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; only works with one job, there is no additional cost. However, if worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; works with two jobs, there is an additional cost. This additional cost can be regarded as a batching cost as it only exists when two jobs are assigned to the same worker. The additional cost for worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; with job &lt;span class=&quot;math-container&quot;&gt;$i_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i_2$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$c_{i_1i_2j}$&lt;/span&gt;, and it can be arbitrarily positive or negative. In this case, the total cost for worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; with job &lt;span class=&quot;math-container&quot;&gt;$i_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i_2$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$w_{i_1j}+w_{i_2j}+c_{i_1i_2j}$&lt;/span&gt;. Our objective is to assign all the jobs with a minimum total cost.&lt;/p&gt;&#xA;" OwnerUserId="5274" LastEditorUserId="491" LastEditDate="2021-04-07T13:42:52.837" LastActivityDate="2021-04-08T15:30:44.027" Title="Assignment problem with batching costs" Tags="|mixed-integer-programming|combinatorial-optimization|assignment-problem|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="6058" PostTypeId="2" ParentId="6057" CreationDate="2021-04-05T13:45:26.590" Score="5" Body="&lt;p&gt;You can formulate this as an instance of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;quadratic assignment problem&lt;/a&gt; by duplicating the workers and incurring the batching cost only for pairs of duplicate workers.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Here's an alternative MIQP formulation that does not double the number of workers.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; indicate whether job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to worker &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.  The problem is to minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j} w_{i,j} x_{i,j} + \sum_{i_1&amp;lt;i_2} \sum_j c_{i_1,i_2,j} x_{i_1,j} x_{i_2,j} \tag1$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j x_{i,j} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \tag2\\&#xA;\sum_i x_{i,j} &amp;amp;\le 2 &amp;amp;&amp;amp;\text{for all $j$} \tag3\\&#xA;\end{align}&lt;/span&gt;&#xA;You can use an MIQP solver directly or linearize.&lt;/p&gt;&#xA;&lt;p&gt;The most straightforward linearization is to introduce a new binary (optionally nonnegative) decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{i_1,i_2,j}$&lt;/span&gt; to represent the product &lt;span class=&quot;math-container&quot;&gt;$x_{i_1,j} x_{i_2,j}$&lt;/span&gt; and then minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j} w_{i,j} x_{i,j} + \sum_{i_1&amp;lt;i_2} \sum_j c_{i_1,i_2,j} y_{i_1,i_2,j} \tag4$$&lt;/span&gt;&#xA;subject to &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;, and&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_{i_1,i_2,j} &amp;amp;\le x_{i_1,j} &amp;amp;&amp;amp;\text{for all $i_1&amp;lt;i_2$ and $j$} \tag5\\&#xA;y_{i_1,i_2,j} &amp;amp;\le x_{i_2,j} &amp;amp;&amp;amp;\text{for all $i_1&amp;lt;i_2$ and $j$} \tag6\\&#xA;y_{i_1,i_2,j} &amp;amp;\ge x_{i_1,j} + x_{i_2,j} - 1 &amp;amp;&amp;amp;\text{for all $i_1&amp;lt;i_2$ and $j$} \tag7\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can strengthen this formulation by replacing &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt; with the valid inequality&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i &amp;lt; i_2} y_{i,i_2,j} + \sum_{i &amp;gt; i_2} y_{i_2,i,j} &amp;amp;\le x_{i_2,j} &amp;amp;&amp;amp;\text{for all $i_2$ and $j$} \tag8\\&#xA;\end{align}&lt;/span&gt;&#xA;Note that &lt;span class=&quot;math-container&quot;&gt;$(8)$&lt;/span&gt; is obtained via RLT by multiplying both sides of &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$x_{i_2,j}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would be interested to hear how your MILP compares with:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MIQP: minimize &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;MILP: minimize &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$(8)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-04-08T15:30:44.027" LastActivityDate="2021-04-08T15:30:44.027" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6060" PostTypeId="2" ParentId="6048" CreationDate="2021-04-05T19:10:27.933" Score="1" Body="&lt;p&gt;Based on your update, you might try the following in lieu of &amp;quot;change problem fix&amp;quot;: change the bounds of the integer variables to equal the feasible solution, then solve the resulting LP problem. For instance, you would set the lower and upper bounds of &lt;code&gt;is_committed&lt;/code&gt; to 0, and do the same for &lt;code&gt;commit_amount&lt;/code&gt;. It's more tedious than tightening the tolerance parameters but perhaps a bit more reliable.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-04-05T19:10:27.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6061" PostTypeId="1" AcceptedAnswerId="6063" CreationDate="2021-04-06T07:11:24.580" Score="1" ViewCount="657" Body="&lt;p&gt;I would like to specify a certain range for a variable for a certain timeslot in Pyomo. I have a temperature variable &lt;span class=&quot;math-container&quot;&gt;$T(t)$&lt;/span&gt; that is defined by using the difference equation &lt;span class=&quot;math-container&quot;&gt;$$T(t) = T(t-1) + \cdots,\quad\forall t&amp;gt;1.$$&lt;/span&gt; But for the last value of the timeslot &lt;code&gt;t_end&lt;/code&gt; the temperature should be between two limits &lt;code&gt;T_init + 0.1 &amp;gt;= T(t_end) &amp;gt;= T_init - 0.1&lt;/code&gt;, where &lt;code&gt;T_init&lt;/code&gt; is a constant temperature value at the beginning of the optimization. How can I realize that in Pyomo? I have only set one boundary so far (either the greater than or equal or the less than or equal constraint). Here is the code that I have:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def temperatureBufferStorageConstraintRule(model, t):&#xA;    if t == model.set_timeslots.first():&#xA;        return model.variable_temperatureBufferStorage[t] == SetUpScenarios.initialBufferStorageTemperature&#xA;    if t == model.set_timeslots.last():&#xA;         return  SetUpScenarios.initialBufferStorageTemperature + 0.1 &amp;gt;=  model.variable_temperatureBufferStorage[t] &amp;gt;= SetUpScenarios.initialBufferStorageTemperature - 0.1&#xA;    return model.variable_temperatureBufferStorage[t] == model.variable_temperatureBufferStorage[t-1] + ((model.variable_heatGenerationCoefficient_SpaceHeating[t] * model.param_COPHeatPump_SpaceHeating[t] *  SetUpScenarios.electricalPower_HP * SetUpScenarios.timeResolution - model.param_heatDemand_In_W [t]  * SetUpScenarios.timeResolution - SetUpScenarios.standingLossesBufferStorage * SetUpScenarios.timeResolution) / (SetUpScenarios.capacityOfBufferStorage * SetUpScenarios.densityOfCement * SetUpScenarios.specificHeatCapacityOfCement))&#xA;&#xA;&#xA;&#xA;model.constraint_temperatureBufferStorage = pyo.Constraint (model.set_timeslots, rule=temperatureBufferStorageConstraintRule)&#xA;&#xA;model.constraint_temperatureBufferStorage.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You do not have to care about the exact definition of &lt;code&gt;model.variable_temperatureBufferStorage[t]&lt;/code&gt; which is the &lt;span class=&quot;math-container&quot;&gt;$T(t)$&lt;/span&gt;. Basically only the line with &lt;code&gt;if t == model.set_timeslots.last():&lt;/code&gt; is important. Just for clarification I want to mention that I load all the constant values from a class called &lt;code&gt;SetUpScenarios&lt;/code&gt; but this is not so important I guess for my question.&#xA;When using my code I only realize the less than or equal constraint and get the following output when printing the constraint:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;variable_temperatureBufferStorage[288] :  21.1 :   True&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Do you know how I can combine those two constraints and also realize the less than or equal constraint? I'd appreciate every comment and would be quite thankful for your help.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="123" LastEditDate="2021-04-06T08:48:55.567" LastActivityDate="2021-04-06T08:48:55.567" Title="How to assure a range for a specific variable in Pyomo" Tags="|python|constraint|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6062" PostTypeId="1" CreationDate="2021-04-06T08:14:42.107" Score="3" ViewCount="433" Body="&lt;p&gt;I am currently working on a VRP problem where the vehicles are electric. This means that I have range restrictions, and charging stations as nodes which are optional to visit.&lt;/p&gt;&#xA;&lt;p&gt;In my model I have the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;O = [0] # depot&#xA;N = [1,2,3,4,5,6,7] # deliveries&#xA;V = [0,1,2,3,4,5,6,7] # all nodes which must be visited&#xA;F = [8,9] # charging stations.&#xA;G = [0,1,2,3,4,5,6,7,8,9] # all the nodes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In addition I have a distance matrix with distances between all nodes. I also have demand in weight at every delivery point.&lt;/p&gt;&#xA;&lt;p&gt;My current model looks like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m = Model('E-VRP')&#xA;x = m.addVars(G, G, vtype=GRB.BINARY)&#xA;lw = m.addVars(G, vtype=GRB.CONTINUOUS) # for calculating load weight&#xA;d = m.addVars(G, vtype=GRB.CONTINUOUS) # for calculating distance driven&#xA;&#xA;m.setObjective(quicksum(distance[i,j]*x[i,j] for i in G for j in G if i!=j), GRB.MINIMIZE)&#xA;&#xA;# Restrictions&#xA;&#xA;m.addConstrs(quicksum(x[i,j] for j in V if j!=i)== 1 for i in N)  #1&#xA;m.addConstrs(quicksum(x[i,j] for i in V if i!=j)== 1 for j in N)  #2&#xA;&#xA;m.addConstrs ((x[i,j]==1) &amp;gt;&amp;gt; (lw[i] + Dw[i] == lw[j])  #3&#xA;              for i in G for j in G if i!=0 if j!=0)&#xA;m.addConstrs (lw[i] &amp;gt;= Dw[i] for i in G);  #4 (Dw being demand in weight at delivery)&#xA;m.addConstrs (lw[i] &amp;lt;= Qw for i in G);     #5 (Qw being weight capacity of vehicle)&#xA;&#xA;m.addConstrs ((x[i,j]==1) &amp;gt;&amp;gt; (d[i] + distance[i,j] == d[j])&#xA;              for i in G for j in G if j&amp;gt;0);   #6&#xA;m.addConstrs (d[i] &amp;lt;= Qr for i in G);          #7 (Qr being range restriction of vehicle)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A combination of the first three restrictions make the model a working capacitated vehicle routing problem. It starts and ends at the depot (0), and if &lt;code&gt;Qw&lt;/code&gt; is less than &lt;code&gt;lw&lt;/code&gt;, the model will make multiple routes.&lt;/p&gt;&#xA;&lt;p&gt;The problem comes when I impose range restrictions, where I have two problems:&lt;/p&gt;&#xA;&lt;p&gt;First, the model will not make charging stations part of the route. I understand that restrictions #1 and #2 state that there must be a connection from list &lt;code&gt;V&lt;/code&gt; to &lt;code&gt;N&lt;/code&gt;, and vice versa, meaning that for node &lt;code&gt;j&lt;/code&gt;, there must at be an &lt;code&gt;i&lt;/code&gt; in list &lt;code&gt;V&lt;/code&gt; (which does not include charging stations). However, whenever I try to &amp;quot;loose up&amp;quot; the two first restrictions, the model will suggest subtours that do not start nor end at the depot. Does anyone have any suggestions as to how I can solve this?&lt;/p&gt;&#xA;&lt;p&gt;Second, my variable &lt;code&gt;d&lt;/code&gt;, which keeps track of the distance travelled, will only add up the distance to the last node prior to returning to the depot. I realize that my code &lt;code&gt;j&amp;gt;0&lt;/code&gt; states that the depot cannot be a destination in my travel variable, however, this is the only way I have had it to work for all the other nodes.&lt;/p&gt;&#xA;" OwnerUserId="5278" LastEditorUserId="123" LastEditDate="2021-04-06T08:51:57.473" LastActivityDate="2024-04-04T04:32:19.513" Title="Trouble with optional nodes in a VRP model using Gurobi for python" Tags="|modeling|python|gurobi|vehicle-routing|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6063" PostTypeId="2" ParentId="6061" CreationDate="2021-04-06T08:28:51.303" Score="2" Body="&lt;p&gt;My way, I only change second if clause in def:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if t == model.set_timeslots.last():&#xA;        return  SetUpScenarios.initialBufferStorageTemperature + 0.1 &amp;gt;=  model.variable_temperatureBufferStorage[t] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And second part of combined constraint is added separetly:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.constraint_temperatureBufferStorage_last = Constraint(expr = model.variable_temperatureBufferStorage[model.set_timeslots.last()*] &amp;gt;= SetUpScenarios.initialBufferStorageTemperature - 0.1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;: I don't know data type of model.set_timeslots.last(), therefore I used as.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="432" LastActivityDate="2021-04-06T08:28:51.303" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6066" PostTypeId="2" ParentId="6019" CreationDate="2021-04-07T12:21:00.810" Score="7" Body="&lt;p&gt;If your linear program does not have an optimal solution one of three things might be the case:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The solver didn't find the optimal solution, even though it exists. This might be due to runtime or storage space limitations. However this should rarely be the problem, unless you have huge LPs.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There is no optimal solution, because the problem is unbounded and therefore there are arbitrarily good solutions. Think: &lt;span class=&quot;math-container&quot;&gt;$\max x$&lt;/span&gt; s.t. &lt;span class=&quot;math-container&quot;&gt;$x \geq 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There exists no solution at all. Think: &lt;span class=&quot;math-container&quot;&gt;$1 \leq x \leq 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In cases 2 and 3 check you model: Is this a reasonable result? Is there maybe an error in the model or in the implementation or in the data?&lt;/p&gt;&#xA;&lt;p&gt;Case 2 is the only case where you can reasonable want a &amp;quot;sub-optimal&amp;quot; solution, which I take to mean a feasible, but not optimal solution. To obtain it, get any feasible solution.&lt;/p&gt;&#xA;" OwnerUserId="405" LastEditorUserId="123" LastEditDate="2021-04-08T20:22:35.220" LastActivityDate="2021-04-08T20:22:35.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6067" PostTypeId="1" CreationDate="2021-04-07T18:21:17.330" Score="1" ViewCount="135" Body="&lt;p&gt;Does anybody know how we could optimie fpl problems with additional constraints?&lt;/p&gt;&#xA;" OwnerUserId="5298" LastEditorUserId="491" LastEditDate="2023-02-18T23:16:20.920" LastActivityDate="2023-02-18T23:16:20.920" Title="fpl and constraints about centers" Tags="|optimization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6068" PostTypeId="2" ParentId="6067" CreationDate="2021-04-07T18:34:07.540" Score="2" Body="&lt;p&gt;Your problem is a so-called &lt;em&gt;single source capacitated facility location problem&lt;/em&gt;. Your second constraint is not meaningful and should be removed, otherwise the formulation seems to be correct. Often you see your third and fourth set of constraints combined in&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} &#xA;\sum_{i \in I} d_ia_{ij} \leq c_jy_j, \quad \forall j\in J&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;There is a ton of literature on this problem.&lt;/p&gt;&#xA;&lt;p&gt;Edit: apparently I missed the wrong objective function for some reason. You need to measure the total travel cost and add the total fixed costs to that:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\min\text{total travel costs} + \text{total fixed costs}&#xA;\end{equation}&lt;/span&gt;&#xA;Can you take it from there?&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2021-04-07T20:05:20.107" LastActivityDate="2021-04-07T20:05:20.107" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6069" PostTypeId="1" CreationDate="2021-04-09T06:54:52.977" Score="0" ViewCount="4050" Body="&lt;p&gt;I would like to define the value of a variable &lt;code&gt;model.variable_costsPerTimeSlot [t]&lt;/code&gt; in pyomo and I would like to use if-statements. Depending on the value of the if-statements, another expression should be used for assigning the value. However, I get an error message when doing this&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Evaluating Pyomo variables in a Boolean context, e.g.&#xA;            if expression &amp;lt;= 5:&#xA;        is generally invalid.  If you want to obtain the Boolean value of the&#xA;        expression based on the current variable values, explicitly evaluate the&#xA;        expression using the value() function:&#xA;            if value(expression) &amp;lt;= 5:&#xA;        or&#xA;            if value(expression &amp;lt;= 5):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My question is how can I avoid this error? I do not really understand what the problem is. I also tried to use the value() function but I got an error telling me `NameError: name 'value' is not defined&lt;/p&gt;&#xA;&lt;p&gt;So here you can see this constraint:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def costsPerTimeSlotRule (model, t):&#xA;    if (model.variable_pvGeneration [t] &amp;lt;= model.variable_electricalPowerTotal [t]):&#xA;        return model.variable_costsPerTimeSlot [t] == (model.variable_electricalPowerTotal [t] - model.variable_pvGeneration [t]) * SetUpScenarios.timeResolution * 60 * (model.param_electricityPrice_In_Cents[t]/3600000)&#xA;    if (model.variable_pvGeneration [t] &amp;gt; model.variable_electricalPowerTotal [t]):&#xA;        return model.variable_costsPerTimeSlot [t] == (model.variable_pvGeneration [t] - model.variable_electricalPowerTotal [t]) * SetUpScenarios.timeResolution * 60 * (SetUpScenarios.revenueForFeedingBackElecticityIntoTheGrid_CentsPerKWH/3600000)&#xA;model.constraint_costsPerTimeSlots = pyo.Constraint(model.set_timeslots, rule =costsPerTimeSlotRule )`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'd appreciate every comment and would be thankful for your help.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastActivityDate="2022-02-10T16:09:10.360" Title="Use if-statements when defining a constraint in Pyomo" Tags="|python|constraint|pyomo|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="6070" PostTypeId="1" CreationDate="2021-04-09T10:02:21.607" Score="4" ViewCount="1459" Body="&lt;p&gt;I am trying to write a program to schedule a team of 8 individuals into shifts.&lt;/p&gt;&#xA;&lt;p&gt;I want to know how to model that every individual must get &lt;strong&gt;at least one night shift break&lt;/strong&gt;, and &lt;strong&gt;must not work two consecutive shifts&lt;/strong&gt;. Finally, we want to ensure as &lt;strong&gt;close to equal numbers of night shifts and total shifts for each individual&lt;/strong&gt; as possible.&lt;/p&gt;&#xA;&lt;p&gt;More specifically I have the following problem:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;8 Individuals&lt;/li&gt;&#xA;&lt;li&gt;3 Shifts per day (morning, afternoon, night)&lt;/li&gt;&#xA;&lt;li&gt;18 Days&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I want to distribute individuals to shifts to meet the following criteria:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There must be 3 people on each shift&lt;/li&gt;&#xA;&lt;li&gt;Every individual must work 1 shift per day&lt;/li&gt;&#xA;&lt;li&gt;Every individual must not work more than 2 shifts per day&lt;/li&gt;&#xA;&lt;li&gt;Every individual must get at least one night shift break, preferably two. This means that individual A can work night shift 1, but then cannot work night shift 2 (and preferably not 3), returning to night shift 4. I.e. each individual must do a maximum of 1 night shift in every 2 nights, preferably 1 night shift in every 3 night shifts.&lt;/li&gt;&#xA;&lt;li&gt;We should distribute these shifts as evenly as possible, especially night shifts but also the total number of shifts.&lt;/li&gt;&#xA;&lt;li&gt;Each individual must not work consecutive shifts (e.g. the night shift on Day 1 and the morning shift on Day 2)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I need to know how to either write these as constraints or otherwise, to include them in an objective function.&lt;/p&gt;&#xA;&lt;p&gt;As an objective function: I have considered minimising the maximum difference in the number of night shifts, or else, minimising the maximum difference in the total number of shifts.&lt;/p&gt;&#xA;&lt;p&gt;I need some help writing this as a mathematical model. I don't know where to start with this!&lt;/p&gt;&#xA;" OwnerUserId="5306" LastEditorUserId="491" LastEditDate="2021-05-10T12:20:43.690" LastActivityDate="2021-05-18T13:36:49.537" Title="Scheduling optimisation constraint on consecutive shifts &amp; consecutive night shifts (`python`)" Tags="|linear-programming|integer-programming|scheduling|constraint-programming|pulp|" AnswerCount="2" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6071" PostTypeId="1" CreationDate="2021-04-11T07:21:52.007" Score="2" ViewCount="1601" Body="&lt;p&gt;Suppose we have a binary variable &lt;span class=&quot;math-container&quot;&gt;$b \in \{0, 1\}$&lt;/span&gt; and a continuous (possibly negative) variable &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{R}$&lt;/span&gt;. How can we linearize the product &lt;span class=&quot;math-container&quot;&gt;$b \cdot y$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2021-04-13T08:22:43.390" Title="How to linearize the product of a binary and a continuous variable?" Tags="|linear-programming|linearization|binary-variable|" AnswerCount="1" CommentCount="1" ClosedDate="2021-04-13T08:22:24.987" ContentLicense="CC BY-SA 4.0" />
  <row Id="6072" PostTypeId="2" ParentId="6071" CreationDate="2021-04-11T07:21:52.007" Score="5" Body="&lt;p&gt;Suppose we know an upper bound &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$|y| \leq M$&lt;/span&gt;, we can linearize this constraint as follows. First, we introduce a new variable &lt;span class=&quot;math-container&quot;&gt;$h \in \mathbb{R}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$h = b y$&lt;/span&gt;. Then we need to model that &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; equals &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$b = 1$&lt;/span&gt; and equals &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$b = 0$&lt;/span&gt;. For this purpose we add the following linear constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;h &amp;amp;\leq b M \tag{1} \\&#xA;h &amp;amp;\geq -b M \tag{2} \\&#xA;h &amp;amp;\leq y + (1-b)M \tag{3} \\&#xA;h &amp;amp;\geq y - (1-b)M \tag{4}&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$b=1$&lt;/span&gt; the constraints (1) and (2) are fulfilled while (3) and (4) enforce &lt;span class=&quot;math-container&quot;&gt;$h = y$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$b=0$&lt;/span&gt; the constraints (3) and (4) are fulfilled while (1) and (2) enforce &lt;span class=&quot;math-container&quot;&gt;$h=0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2021-04-11T07:21:52.007" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6073" PostTypeId="2" ParentId="6070" CreationDate="2021-04-11T14:57:25.660" Score="4" Body="&lt;p&gt;There are certainly different ways of achieving what you want. Here is how I would proceed:&lt;/p&gt;&#xA;&lt;p&gt;Start by predefining the set of all possible schedules which satisfy your constraints &lt;span class=&quot;math-container&quot;&gt;$2,3,4,6$&lt;/span&gt;. Although there are many, I believe that with your constraints, it may be not too difficult to derive them somewhat automatically. Here is a subset of them in the table below, &lt;em&gt;if there were only &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; days&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{l|l|l|l|l|l|l}&#xA;                       &amp;amp;           &amp;amp; Schedule 1 &amp;amp; Schedule 2 &amp;amp; Schedule 3 &amp;amp;  … &amp;amp; Required \\&#xA;{Day 1} &amp;amp; Morning   &amp;amp; 1          &amp;amp; 0          &amp;amp;                  1      &amp;amp;   &amp;amp; 3        \\&#xA;                       &amp;amp; Afternoon &amp;amp; 1          &amp;amp; 1          &amp;amp;   1&#xA;                     &amp;amp;   &amp;amp; 3        \\&#xA;                       &amp;amp; Night     &amp;amp; 0          &amp;amp; 1          &amp;amp;    0                   &amp;amp;   &amp;amp; 3        \\&#xA;{Day 2} &amp;amp; Morning   &amp;amp; 1          &amp;amp; 0          &amp;amp;                    1    &amp;amp;   &amp;amp; 3        \\&#xA;                       &amp;amp; Afternoon &amp;amp; 1          &amp;amp; 1          &amp;amp;      1                  &amp;amp;   &amp;amp; 3        \\&#xA;                       &amp;amp; Night     &amp;amp; 0          &amp;amp; 0          &amp;amp;       0                 &amp;amp;   &amp;amp; 3        \\&#xA;{Day 3} &amp;amp; Morning   &amp;amp; 1          &amp;amp; 1          &amp;amp;                     0   &amp;amp;   &amp;amp; 3        \\&#xA;                       &amp;amp; Afternoon &amp;amp; 1          &amp;amp; 1          &amp;amp;      0                  &amp;amp;   &amp;amp; 3        \\&#xA;                       &amp;amp; Night     &amp;amp; 0          &amp;amp; 0          &amp;amp;       1                 &amp;amp;   &amp;amp; 3       &#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can see the the above schedules do satisfy constraints &lt;span class=&quot;math-container&quot;&gt;$2,3,4,6$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Once you have your schedules, you can solve your problem as follows. Define a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; for each schedule &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt;, and a binary &lt;strong&gt;parameter&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if schedule &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt; is &amp;quot;active&amp;quot; during shift &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt;. So for example, for the first schedule, &lt;span class=&quot;math-container&quot;&gt;$a_{11}=1$&lt;/span&gt;, but &lt;span class=&quot;math-container&quot;&gt;$a_{13}=0$&lt;/span&gt;. You need to solve the problem with the following constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You need &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; individual schedules over the total time span:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in I} x_i = 8&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;You need &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; people on each shift:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in I} a_{ij} x_i = 3 \quad \forall j\in J&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;At this point, you have taken account each of your constraints except for constraint &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt;. You could define a pairwise coefficient &lt;span class=&quot;math-container&quot;&gt;$b_{ik}$&lt;/span&gt; for each pair of shifts &lt;span class=&quot;math-container&quot;&gt;$i,k \in I\times I$&lt;/span&gt;. This coefficient would be a measure of how &amp;quot;uneven&amp;quot; the schedules are. And so you would solve the above constraint problem while minimizing the sum of such coefficients. Since they are pairwise, this means you also need pairwise binary variables &lt;span class=&quot;math-container&quot;&gt;$y_{ik}$&lt;/span&gt;. This way you minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i,k}b_{ik}y_{ik}&#xA;$$&lt;/span&gt;&#xA;with the additional constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_i+x_k \le y_{ik}+1 \quad \forall i,k&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2021-04-11T14:57:25.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6074" PostTypeId="1" CreationDate="2021-04-11T16:14:26.963" Score="1" ViewCount="166" Body="&lt;p&gt;My objective function is &lt;span class=&quot;math-container&quot;&gt;$\log_2(1+{x^2y^2})$&lt;/span&gt; and I found two upper bounds for &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For example, assumed that we have the following upper bounds:&#xA;&lt;span class=&quot;math-container&quot;&gt;$x^2\leq\text{constant}_1^2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^2\leq\text{constant}_2^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So, my question is: could we say that &lt;span class=&quot;math-container&quot;&gt;$\log_2(1+{x^2y^2})\leq \log_2(1+{\text{constant}_1^2\cdot\text{constant}_2^2})$&lt;/span&gt;? If so, how tight is this bound?&lt;/p&gt;&#xA;" OwnerUserId="5131" LastEditorUserId="123" LastEditDate="2021-04-12T07:14:29.300" LastActivityDate="2021-04-12T07:14:29.300" Title="Find an upper bound for an objective function" Tags="|optimization|convex-optimization|nonconvex-programming|bounds|approximation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6075" PostTypeId="2" ParentId="6074" CreationDate="2021-04-11T16:36:04.243" Score="5" Body="&lt;p&gt;Yes, because &lt;span class=&quot;math-container&quot;&gt;$\log$&lt;/span&gt; is monotonic, it preserves inequalities. The tightness depends on your other constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-04-11T16:36:04.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6076" PostTypeId="1" CreationDate="2021-04-11T17:36:48.207" Score="1" ViewCount="185" Body="&lt;p&gt;Take a single source capacitated FLP (facility location problem). As we know the linear formulation to this problem is:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    &amp;amp;      &amp;amp;&amp;amp; \text{min} \; \sum_{j \in J} a_{ij} \; t_{ij} &amp;amp;&amp;amp; \\&#xA;    &amp;amp; s.t. &amp;amp;&amp;amp; \sum_{j \in J} \; a_{ij} = 1     &amp;amp;&amp;amp;  \forall i\in I \\&#xA;    &amp;amp;      &amp;amp;&amp;amp; a_{ij} \in \{0,1\} &amp;amp;&amp;amp;  \\&#xA;\end{align}&lt;/span&gt;&#xA;Where &lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt; is equal to 1 if client &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is served by center &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and 0 otherwise. &lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt; is the travel cost from center &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to client &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;br /&gt;&#xA;Is the first constraint correct?&#xA;P.S. I am new to this subject and hence my struggle to solve this problem.&lt;/p&gt;&#xA;" OwnerUserId="5298" LastEditorUserId="5298" LastEditDate="2021-04-14T22:32:41.410" LastActivityDate="2021-04-14T22:32:41.410" Title="add constraints to the problem" Tags="|modeling|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6077" PostTypeId="2" ParentId="6076" CreationDate="2021-04-11T20:28:46.113" Score="3" Body="&lt;p&gt;Here's a way to formulate a more generic constraint that you can then apply to your situation.  Suppose you have constant &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and binary variables &lt;span class=&quot;math-container&quot;&gt;$y_r$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{r\in R} y_r \ge b \implies z=1$$&lt;/span&gt;&#xA;The contrapositive is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z = 0 \implies \sum_{r\in R} y_r \le b - 1$$&lt;/span&gt;&#xA;You can enforce this via an indicator constraint or by using the following big-M constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{r\in R} y_r -(b - 1) \le M z$$&lt;/span&gt;&#xA;Here, &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; should be a small constant upper bound on the LHS when &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt;, and a good choice is &lt;span class=&quot;math-container&quot;&gt;$M=|R|-b+1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-04-12T12:07:15.547" LastActivityDate="2021-04-12T12:07:15.547" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6078" PostTypeId="1" AcceptedAnswerId="6079" CreationDate="2021-04-11T23:36:33.000" Score="7" ViewCount="325" Body="&lt;p&gt;I have two tasks &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; with durations &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_k$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_k$&lt;/span&gt; are nonnegative variables.&lt;/p&gt;&#xA;&lt;p&gt;I would like to model that &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; may precede &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; may precede &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and that they may not overlap.&lt;/p&gt;&#xA;&lt;p&gt;So, with &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_k$&lt;/span&gt; denoting the start times of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, I have to model:&lt;/p&gt;&#xA;&lt;p&gt;either &lt;span class=&quot;math-container&quot;&gt;$t_i + d_i \le t_k$&lt;/span&gt;   OR  &lt;span class=&quot;math-container&quot;&gt;$t_k + d_k \le t_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Introducing a binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, I can achieve the result with the following two big M constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_i + d_i - t_k \le M y $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_k + d_k - t_i \le M (1-y)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If it is required that &lt;span class=&quot;math-container&quot;&gt;$t_i + d_i \le H $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_k + d_k \le H $&lt;/span&gt; then I can set &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to be &lt;span class=&quot;math-container&quot;&gt;$M=H$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My question is, is what I have done so far correct (what worries me is the variable duration) and can anyone think about a better formulation?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="500" LastEditDate="2021-04-12T00:18:20.050" LastActivityDate="2021-07-07T07:41:23.897" Title="Modelling precedence relations" Tags="|mixed-integer-programming|scheduling|big-m|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6079" PostTypeId="2" ParentId="6078" CreationDate="2021-04-12T00:20:07.280" Score="4" Body="&lt;p&gt;Yes, this is correct and is the classical approach from &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/opre.8.2.219&quot; rel=&quot;nofollow noreferrer&quot;&gt;Manne, &lt;em&gt;On the Job-Shop Scheduling Problem&lt;/em&gt; (1960)&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In some modeling languages, you can also enforce these implications by using indicator constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y = 0 &amp;amp;\implies t_i + d_i \le t_k \\&#xA;y = 1 &amp;amp;\implies t_k + d_k \le t_i \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-04-12T00:20:07.280" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6080" PostTypeId="2" ParentId="6062" CreationDate="2021-04-12T06:54:31.153" Score="5" Body="&lt;p&gt;Welcome to OR.SE.&lt;/p&gt;&#xA;&lt;p&gt;It is not easy to enter into your problem and your model. You have modeled your problem in MILP, with each edge represented as a 0-1 variable. There are different possible formulations. It will all be tedious to implement, even more so if you have many constraints to implement. To make it easier and more scalable, we suggest you follow a heuristic column generation approach: generate some feasible &amp;quot;good&amp;quot; routes and then set a MILP to select the best subset of routes.&lt;/p&gt;&#xA;&lt;p&gt;As explained above, Boolean modeling approaches are tedious to write and don't scale well for this problem. Your problem can be modeled compactly by following a list-based approach instead of the classical Boolean approach, as you described in your question. This modeling approach offered by Hexaly is different from traditional MILP solvers. &lt;strong&gt;Note that Hexaly is commercial software.&lt;/strong&gt; Nevertheless, it is free for faculty and students.&lt;/p&gt;&#xA;&lt;p&gt;Below is the code snippet to model the Capacitated Vehicle Routing Problem (CVRP) by using Hexaly Modeler:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function model() {&#xA;  // Sequence of customers visited by each truck&#xA;  customersSequences[k in 1..nbTrucks] &amp;lt;- list(nbCustomers);&#xA;&#xA;  // All customers must be visited by the trucks&#xA;  constraint partition[k in 1..nbTrucks](customersSequences[k]);&#xA;&#xA;  for [k in 1..nbTrucks] {&#xA;      local sequence &amp;lt;- customersSequences[k];&#xA;      local c &amp;lt;- count(sequence);&#xA;&#xA;      // A truck is used if it visits at least one customer&#xA;      trucksUsed[k] &amp;lt;- c &amp;gt; 0;&#xA;&#xA;      // The quantity needed in each route must not exceed the truck capacity&#xA;      routeQuantity &amp;lt;- sum(0..c-1, i =&amp;gt; demands[sequence[i]]);&#xA;      constraint routeQuantity &amp;lt;= truckCapacity;&#xA;&#xA;      // Distance traveled by truck k&#xA;      routeDistances[k] &amp;lt;- sum(1..c-1, i =&amp;gt; distanceMatrix[sequence[i - 1]][sequence[i]])&#xA;         + (c &amp;gt; 0 ? (distanceWarehouse[sequence[0]] + distanceWarehouse[sequence[c - 1]]) : 0);&#xA;  }&#xA;&#xA;  nbTrucksUsed &amp;lt;- sum[k in 1..nbTrucks](trucksUsed[k]);&#xA;&#xA;  // Total distance traveled&#xA;  totalDistance &amp;lt;- sum[k in 1..nbTrucks](routeDistances[k]);&#xA;&#xA;  // Objective: minimize the number of trucks used, then minimize the distance traveled&#xA;  minimize nbTrucksUsed;&#xA;  minimize totalDistance;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can write the same model in Python, Java, C#, or C++. Just have a look at the example &lt;a href=&quot;https://www.hexaly.com/docs/last/exampletour/vrp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Following this modeling approach, Hexaly finds quality solutions in minutes on a standard computer for instances with &lt;a href=&quot;https://www.hexaly.com/benchmark/huge-instances-capacitated-vehicle-routing-problem-cvrp&quot; rel=&quot;nofollow noreferrer&quot;&gt;thousands of clients to serve&lt;/a&gt;. Hexaly embeds and combines neighborhood search, constraint programming, and mixed-integer linear programming techniques under the hood to get such results.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T04:32:19.513" LastActivityDate="2024-04-04T04:32:19.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6081" PostTypeId="2" ParentId="6076" CreationDate="2021-04-12T07:14:36.103" Score="1" Body="&lt;p&gt;@RobPratt's answer is obviously the correct answer to this question and is also more general than this one, however, I think this answer can supplement it as it is specific to the OP's case and it also gives a simple thought process to arrive at the result.&lt;/p&gt;&#xA;&lt;p&gt;The way I think about it is, that you would like to have &lt;em&gt;less&lt;/em&gt; than two facilities open from each set &lt;span class=&quot;math-container&quot;&gt;$S_k$&lt;/span&gt;. Less than two, when counting, means less than or equal to 1. Thus what we ideally would like, in order to avoid the penalties, is that the following set of constraints are satisfied&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;  \sum_{j\in S_k}x_j\leq 1,\quad \forall k=1,\dots,K&#xA;\end{equation}&lt;/span&gt;&#xA;However, we cannot be sure, that it isn't better to pay some penalties in order to get a better facility constellation, so we introduce a new binary variable for each set &lt;span class=&quot;math-container&quot;&gt;$S_k$&lt;/span&gt;, here called &lt;span class=&quot;math-container&quot;&gt;$z_k$&lt;/span&gt;. This binary variable &lt;span class=&quot;math-container&quot;&gt;$z_k$&lt;/span&gt; equals 1 if we choose two or more facilities from set &lt;span class=&quot;math-container&quot;&gt;$S_k$&lt;/span&gt;. The implication&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;  \sum_{j\in S_k}x_j\geq 2 \Rightarrow z_k=1, \quad\forall k=1,\dots,K&#xA;\end{equation}&lt;/span&gt;&#xA;can be modelled using a &amp;quot;big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;&amp;quot; constraint as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;  \sum_{j\in S_k}x_j\leq 1+ M_kz_k,\quad \forall k=1,\dots,K&#xA;\end{equation}&lt;/span&gt;&#xA;Here you allow the left hand side to become strictly larger than 1 at the price of setting &lt;span class=&quot;math-container&quot;&gt;$z_k=1$&lt;/span&gt;. The value of &lt;span class=&quot;math-container&quot;&gt;$M_k$&lt;/span&gt; should be set large enough not to interfere with the logic of the problem, but as small as possible: The maximal value of &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in S_k}x_j$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$\vert S_k\vert$&lt;/span&gt; implying that &lt;span class=&quot;math-container&quot;&gt;$M_k$&lt;/span&gt; should be the solution to &lt;span class=&quot;math-container&quot;&gt;$\vert S_k\vert = 1 + M_k$&lt;/span&gt;, which obviously is (as @RobPratt's answer states) &lt;span class=&quot;math-container&quot;&gt;$M_k= \vert S_k\vert-1$&lt;/span&gt;. The last thing to do is to add the term&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{k=1}^Kp_kz_k&#xA;\end{equation}&lt;/span&gt;&#xA;to the objective function.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-04-12T07:14:36.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6082" PostTypeId="2" ParentId="6024" CreationDate="2021-04-12T13:03:40.403" Score="4" Body="&lt;p&gt;&lt;strong&gt;CPXXreadcopyprob and CPXreadcopyprob&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The routine CPXXreadcopyprob/CPXreadcopyprob reads an MPS, LP, or SAV file into an existing CPLEX problem object.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;CPXXreadcopybase and CPXreadcopybase&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The routine CPXXreadcopybase/CPXreadcopybase reads a basis from a BAS file, and copies that basis into a CPLEX problem object.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;CPXXsolution and CPXsolution&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The routine CPXXsolution/CPXsolution accesses the solution values&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-04-12T13:03:40.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6083" PostTypeId="2" ParentId="6078" CreationDate="2021-04-12T14:16:58.200" Score="5" Body="&lt;p&gt;You may also use &lt;a href=&quot;https://www.slideshare.net/PhilippeLaborie/an-introduction-to-cp-optimizer&quot; rel=&quot;noreferrer&quot;&gt;CPOptimizer within CPLEX&lt;/a&gt; that contains scheduling high level concepts. And then you can directly use noOverlap constraints.&lt;/p&gt;&#xA;&lt;p&gt;In&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using  CP;&#xA;&#xA;dvar interval i size 5;&#xA;dvar interval k size 4;&#xA;&#xA;dvar sequence seq in append(i,k);&#xA;&#xA;minimize maxl(endOf(i),endOf(k));&#xA;subject to&#xA;{&#xA;  noOverlap(seq);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;the constraint&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;noOverlap(seq);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;makes sure that i and k do not overlap&lt;/p&gt;&#xA;&lt;p&gt;and in the CPLEX IDE you will see&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/70Cwl.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/70Cwl.png&quot; alt=&quot;view of seq in CPLEX IDE&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-04-12T14:16:58.200" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6084" PostTypeId="1" CreationDate="2021-04-12T15:20:44.817" Score="2" ViewCount="176" Body="&lt;p&gt;I'm trying to get the constraint matrix from a Gurobi model in C++.&#xA;In Python, one can get this by simply calling a method that will populate a scipy object (see &lt;a href=&quot;https://stackoverflow.com/questions/38647230/get-constraints-in-matrix-format-from-gurobipy/40231779#40231779&quot;&gt;this post&lt;/a&gt;). However, in a C++ fashion, one may expect three vectors (column, row, value) for the non-zero elements in the matrix.&lt;/p&gt;&#xA;&lt;p&gt;One could technically iterate through the result of&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;GRBConstr* getConstrs() const;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;however, I am not sure how efficient this method would be. Has anyone tried and found an efficient way of doing so?&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&lt;p&gt;One can also get the non-zero coefficients for a given variable  with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;GRBColumn getCol(GRBVar v)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;EDIT 2:&#xA;The first (possibly inefficient) idea is the following. Assume the object &lt;code&gt;presolved&lt;/code&gt; stores the presolved model.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; auto         vars = presolved.getVars();&#xA; //Getting the vars and iterating through them&#xA; for (int v = 0; v &amp;lt; nVariables; ++v) {&#xA; //Get the column of the v-th var&#xA; auto varCol = presolved.getCol(vars[v]);&#xA; &#xA;&#xA; if (varCol.size() &amp;gt; 0) { &#xA; //For any constraint in the number of constraints of the presolved model&#xA;    for (int c = 0; c &amp;lt; nconstr; ++c) {&#xA;      auto val = varCol.getCoeff(c);&#xA;      if (val &amp;gt; 1e-6 || val &amp;lt; -1e-6)&#xA;         // Fill the matrix A with the value&#xA;         A.at(c, v) = val;&#xA;    }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;" OwnerUserId="535" LastEditorUserId="535" LastEditDate="2021-04-12T19:36:04.973" LastActivityDate="2021-04-12T19:36:04.973" Title="Gurobi c++: Getting constraint matrix" Tags="|solver|gurobi|c++|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6085" PostTypeId="2" ParentId="6062" CreationDate="2021-04-12T16:22:32.987" Score="3" Body="&lt;p&gt;In addition to @LocalSolver's answer, I believe you can solve your problem &lt;em&gt;relatively&lt;/em&gt; easily with the &lt;a href=&quot;https://developers.google.com/optimization/routing&quot; rel=&quot;nofollow noreferrer&quot;&gt;or-tools routing library&lt;/a&gt; (free and open source). At its core, this library solves a TSP, over which you can add constraints with a &lt;em&gt;resource based logic&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For example, the load on a vehicle is a resource, this resource is incremented when visiting a node, and the accumulated value of this resource cannot exceed a given value (the vehicle's capacity).&lt;/p&gt;&#xA;&lt;p&gt;In your case, you could use a resource to keep track of the consumption of the electric charge of the battery, which would be incremented when using an edge with endpoint any node different from a charging station. Conversely, when passing through a charging station, the accumulated electric charge would go back to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Also, since visiting a charging station is optional, you could use the &lt;a href=&quot;https://developers.google.com/optimization/routing/penalties&quot; rel=&quot;nofollow noreferrer&quot;&gt;drop node option&lt;/a&gt; to allow skipping any charging station.&lt;/p&gt;&#xA;&lt;p&gt;Or-tools is based on constraint programming, heuristics, and local search, so as stated by @LocalSolver, you can expect much better results than with a MILP when the problem size grows.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-04-12T16:35:41.737" LastActivityDate="2021-04-12T16:35:41.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6086" PostTypeId="1" CreationDate="2021-04-12T21:27:10.670" Score="4" ViewCount="54" Body="&lt;p&gt;Suppose we have a two-stage stochastic program as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{split}&#xA;\min \ &amp;amp; c^Tx + \mathbb{E}_\xi[Q(x,\xi)] \\&#xA;&amp;amp;  \text{where}\\&#xA; &amp;amp;Q(x,\xi)=\min q(\xi)^Ty\\&#xA;&amp;amp;Tx+W(\xi)y=h(\xi)\\&#xA;&amp;amp;y \ge 0&#xA;\end{split}&#xA;\end{equation}&lt;/span&gt;&#xA;I am wondering how it is possible to find a set of values for the first-stage decisions such that in the L-Shape method, the same (optimality) cuts are generated. For example, suppose we have a problem like the follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{split}&#xA; \min \ &amp;amp; 5x_1+10x_2 + \mathbb{E}_\xi[q_1y_1+q_2y_2] \\&#xA;&amp;amp; y_1 + 2y_2 \ge d_1 -x_1 \\&#xA;&amp;amp; y_1 \ge d_2 -2x_2\\&#xA;&amp;amp; 0 \le x_1 \le 10 \\&#xA;&amp;amp; 0 \le x_2\le 10 \\&#xA;&amp;amp; y_1,y_2 \ge 0&#xA;\end{split}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$(q_1,q_2,d_1,d_2)$&lt;/span&gt; takes two values &lt;span class=&quot;math-container&quot;&gt;$(20,10,5,10)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(15,25,12,5)$&lt;/span&gt; with equal probabilities.&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2021-04-12T21:27:10.670" Title="How to find range of values for the first-stage decisions resulting in the same cuts in two-stage stochastic programming?" Tags="|stochastic-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6087" PostTypeId="2" ParentId="6044" CreationDate="2021-04-13T07:33:27.433" Score="3" Body="&lt;p&gt;This can be one of two things: (i) they changed their versioning system from Semantic Versioning to Calendar Versioning (e.g. they are now following the calendar so CPLEX 20 stands for &amp;quot;2020&amp;quot;), or (ii) the new release is a major release.&lt;/p&gt;&#xA;&lt;p&gt;Since calendar versioning is self-explanatory, I'll explain what major releases are, since we use the same system at Octeract.&lt;/p&gt;&#xA;&lt;p&gt;Contrary to intuition, a &amp;quot;major&amp;quot; release does not imply that some new major feature has been introduced.&lt;/p&gt;&#xA;&lt;p&gt;What it does imply is that there has been a breaking change in the API of the software that is not backwards compatible.&lt;/p&gt;&#xA;&lt;p&gt;For instance, the bump from Python 2.7 to Python 3 was a major release, which broke existing Python 2.7 code. This was marked by the bump from 2 to 3. This is a convention that nearly all professional developers are familiar with.&lt;/p&gt;&#xA;&lt;p&gt;Note that introducing a &amp;quot;breaking&amp;quot; change doesn't mean that everything is broken (although in some cases it does, like Python broke &lt;code&gt;print&lt;/code&gt;), it's just the developer's way of saying that this will no longer interact with other software in quite the same way it used to.&lt;/p&gt;&#xA;&lt;p&gt;Now, applying Occam's razor here to see what happened with CPLEX, (i) it's highly unlikely that they broke backwards compatibility for an enterprise product, and (ii) it's too much of a coincidence that out of all numbers they chose &amp;quot;20&amp;quot; for the December 2020 release, therefore my money would be on them having changed their versioning to track the calendar year.&lt;/p&gt;&#xA;&lt;p&gt;Now why did they do that out of the blue? Well, if you have been following some of their staff on Twitter you might connect the dots. From a developer's point of view, my guess is something that I am always a bit sad to see happen in mature software: such a switch often indicates that management has decided that the API is what it is, and they've switched to maintenance mode with no foreseeable plans to improve it.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-04-13T07:51:59.063" LastActivityDate="2021-04-13T07:51:59.063" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6088" PostTypeId="2" ParentId="4921" CreationDate="2021-04-13T08:18:17.093" Score="1" Body="&lt;p&gt;For the problem you describe, since the function is strongly convex and &lt;span class=&quot;math-container&quot;&gt;$x,y \in \mathbb{R}$&lt;/span&gt; (so you don't have bound constraints), your solution is obtained by solving the system &lt;span class=&quot;math-container&quot;&gt;$\nabla f = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, if you only have approximations to the gradient, the resulting error largely depends on the algorithm you chose to use to solve this. For instance, since your function remains strongly convex, &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; would not affect each other at all if you simply solve the nonlinear system &lt;span class=&quot;math-container&quot;&gt;$\nabla f = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Solving this system of equations is a perfectly legitimate optimisation method, as this is what a solver would actually do in this case. In fact, the only reasons for a solver &lt;em&gt;not&lt;/em&gt; to solve this system directly would be if the problem had bound constraints, or if there are memory limitations. Even in the case of bound constraints though, a good solver would first try solving the system and see if it has a solution within bounds before resorting to more expensive methods.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-04-13T08:27:27.473" LastActivityDate="2021-04-13T08:27:27.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6089" PostTypeId="1" AcceptedAnswerId="6106" CreationDate="2021-04-14T06:23:25.753" Score="4" ViewCount="88" Body="&lt;p&gt;Given a general function &lt;span class=&quot;math-container&quot;&gt;$f:\Bbb Z\to\Bbb R$&lt;/span&gt; is there a simple way to verify whether &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is pseudo-convex or not?&lt;/p&gt;&#xA;" OwnerUserId="5346" LastEditorUserId="5346" LastEditDate="2021-04-14T15:54:48.077" LastActivityDate="2021-04-15T17:00:35.550" Title="How to prove pseudo-convexity of a discrete function?" Tags="|combinatorial-optimization|convex-optimization|optimality-conditions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6090" PostTypeId="1" CreationDate="2021-04-14T06:54:56.700" Score="3" ViewCount="1375" Body="&lt;p&gt;I need to build a if-else constraint for this statement, where &lt;span class=&quot;math-container&quot;&gt;$x_P$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_I$&lt;/span&gt; are decision variables, and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is a constant:&lt;/p&gt;&#xA;&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$x_P \ge C$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_I = x_P - C$&lt;/span&gt; else &lt;span class=&quot;math-container&quot;&gt;$x_I = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Any help is greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5348" LastEditorUserId="2556" LastEditDate="2021-04-14T07:11:23.747" LastActivityDate="2021-04-14T15:27:36.610" Title="Model if-else statement" Tags="|optimization|modeling|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6091" PostTypeId="2" ParentId="6090" CreationDate="2021-04-14T07:47:12.317" Score="3" Body="&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$x_p$&lt;/span&gt; is a continuous variable, you could use the following big-M inequalities:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;C - M_2(1- y) &amp;amp;\le x_p \le C-1 + M_1 y \\&#xA;x_p - C - M_4(1-y) &amp;amp;\le x_I \le x_p - C + M_3(1-y) \\&#xA;0 &amp;amp; \le x_I \le M_5y \\&#xA; y &amp;amp;\in \{0,1\}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So if &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_P \le C-1$&lt;/span&gt;, or by contrapositive, if &lt;span class=&quot;math-container&quot;&gt;$x_P \ge C$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And if &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_P -C \le x_I\le x_P -C$&lt;/span&gt;, and if &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$0 \le x_I\le &#xA;0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-04-14T08:08:28.727" LastActivityDate="2021-04-14T08:08:28.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6092" PostTypeId="2" ParentId="6090" CreationDate="2021-04-14T07:52:33.277" Score="4" Body="&lt;p&gt;You can model it by adding a binary variable &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and the following four constraints.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;x_I &amp;amp;\geq x_P - C &amp;amp; x_I &amp;amp;\geq 0\\&#xA;x_I &amp;amp;\leq x_P - C + Mb &amp;amp; x_I &amp;amp;\leq M(1-b)&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a big constant.&lt;/p&gt;&#xA;&lt;p&gt;Note that if &lt;span class=&quot;math-container&quot;&gt;$x_P &amp;gt; C$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; can't be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; as otherwise &lt;span class=&quot;math-container&quot;&gt;$0\geq x_I &amp;gt; 0$&lt;/span&gt;, which would lead to infeasibility. Thus &lt;span class=&quot;math-container&quot;&gt;$b=0$&lt;/span&gt; and the left two inequalities force &lt;span class=&quot;math-container&quot;&gt;$x_I = x_P-C$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand if &lt;span class=&quot;math-container&quot;&gt;$x_P &amp;lt; C$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; can't be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; as otherwise &lt;span class=&quot;math-container&quot;&gt;$0&amp;gt;x_I&amp;gt;0$&lt;/span&gt; by the left side. Thus &lt;span class=&quot;math-container&quot;&gt;$b=1$&lt;/span&gt; and the right to constraints give &lt;span class=&quot;math-container&quot;&gt;$x_I=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$x_P=C$&lt;/span&gt; it doesn't matter.&lt;/p&gt;&#xA;&lt;p&gt;I hope this helps. ;)&lt;/p&gt;&#xA;" OwnerUserId="4477" LastActivityDate="2021-04-14T07:52:33.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6093" PostTypeId="1" AcceptedAnswerId="6099" CreationDate="2021-04-14T09:22:22.497" Score="2" ViewCount="168" Body="&lt;p&gt;I am trying to implement benders decomposition for a simple two stage unit commitment problem. I implemented the classic Benders decomposition to add feasible cut and optimal cut to relax master problem by solving the dual of sub-problem.  When I use a 6bus system it works fine, however when I change to a larger system (ex: 118bus) the coefficient of the cut started to become ill-conditioned and the result cannot be found. For example：&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; ...13.6 onOff(gen30)(time22)#2291- 12 onOff(gen30)(time23)#2292+ 1.4210854715202e-14 onOff(gen30)(time24)#2293...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;the coefficient of variable &lt;code&gt;onOff(gen30)(time24)&lt;/code&gt; should to zero and the variable should not be included into the constraints and the warning below is also given.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Detected nonzero &amp;lt;= CPX_MINBOUND at constraint 7878, variable&#xA;'onOff[gen30][time24]'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;My questions are listed as follow:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;As far as I know cplex will treat the value below 1e-9 as zero. I wonder if the above problem will be the reason that my program fail or I need to look at different direction?&lt;/li&gt;&#xA;&lt;li&gt;The following warning also repeatedly appear but the coefficient  seem to be normal&#xA;&lt;code&gt;16.4799999999999 onOff(gen22)(time13)#2090&lt;/code&gt;. I would be grateful if you could give some explanation regarding to the meaning of this warning!&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Detected nonzero &amp;lt;= the maximum value of either CPX_PARAM_EPRHS or&#xA;CPX_PARAM_EPOPT at constraint 7824, variable 'onOff[gen22][time13]'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;A large scale problem such as this one, is there any method to improve the numerical stability of the cut? I think the above coefficient should be &lt;code&gt;16.48&lt;/code&gt; rather than &lt;code&gt;16.4799999999999&lt;/code&gt; and the coefficient such as &lt;code&gt;1.4210854715202e-14&lt;/code&gt; should not have happened in the first place. I should mention that I also use &lt;code&gt;IloRound&lt;/code&gt; to any master binary variable, but it does not seem to change anything.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I should note that I am using Cplex 12.9 and C++ technology concert.&lt;/p&gt;&#xA;&lt;p&gt;I would be grateful if you could help me out !&lt;/p&gt;&#xA;&lt;p&gt;Best regards,&lt;/p&gt;&#xA;" OwnerUserId="5343" LastEditorUserId="5343" LastEditDate="2021-04-14T12:45:03.043" LastActivityDate="2021-04-14T18:22:04.747" Title="Numerical problem regarding to classical benders cut of large scale problem" Tags="|cplex|stochastic-programming|benders-decomposition|robust-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6094" PostTypeId="1" AcceptedAnswerId="6095" CreationDate="2021-04-14T09:39:37.953" Score="1" ViewCount="367" Body="&lt;p&gt;I have the following optimization problem: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max_x&amp;amp;\quad\log_2(1+|a+bx|^2+cx^2)\\\text{s.t.}&amp;amp;\quad0\le x\le1\\&amp;amp;\quad(1-x^2)\ge\text{constant}\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; are two complex numbers, and &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is a real positive number.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone have any idea regarding how this objective function can be converted into a convex one?&lt;/p&gt;&#xA;&lt;p&gt;Is it true to say that the optimal value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is equal to &lt;span class=&quot;math-container&quot;&gt;$\sqrt{1-\text{constant}}$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5131" LastEditorUserId="123" LastEditDate="2021-04-14T13:15:31.980" LastActivityDate="2021-04-14T13:15:49.317" Title="How to convexify log(convex) function?" Tags="|optimization|convex-optimization|convexity|nonconvex-programming|bounds|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6095" PostTypeId="2" ParentId="6094" CreationDate="2021-04-14T10:04:17.487" Score="6" Body="&lt;p&gt;You are maximizing a convex quadratic (the monotonic log is irrelevant) so the maximum is attained at the border, i.e. either &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\min(1,\sqrt{1-\text{constant}})$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="487" LastEditorUserId="123" LastEditDate="2021-04-14T13:15:49.317" LastActivityDate="2021-04-14T13:15:49.317" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6096" PostTypeId="2" ParentId="6090" CreationDate="2021-04-14T12:24:16.250" Score="5" Body="&lt;p&gt;You want to enforce &lt;span class=&quot;math-container&quot;&gt;$$x_I=\max(x_P-C,0).$$&lt;/span&gt; See &lt;a href=&quot;https://math.stackexchange.com/a/4086955/683666&quot;&gt;https://math.stackexchange.com/a/4086955/683666&lt;/a&gt;, where the various big-M values are specified explicitly.&lt;/p&gt;&#xA;&lt;p&gt;More generally, see &lt;a href=&quot;https://or.stackexchange.com/questions/6035/linearizing-a-max-function-in-the-constraint-not-working/6036#6036&quot;&gt;Linearizing a Max Function in the constraint - not working&lt;/a&gt; to linearize the max of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; linear functions.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-04-14T15:27:36.610" LastActivityDate="2021-04-14T15:27:36.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6097" PostTypeId="1" AcceptedAnswerId="6098" CreationDate="2021-04-14T12:47:54.100" Score="3" ViewCount="3814" Body="&lt;p&gt;I have a Pyomo model with many constraints and variables. When solving it with Gurobi, I get the message &amp;quot;Model is infeasible or unbounded&amp;quot;. Now I would like to find out which constraints cause the problem. Here in this question &lt;a href=&quot;https://stackoverflow.com/questions/51044262/finding-out-reason-of-pyomo-model-infeasibility&quot;&gt;Finding out reason of Pyomo model infeasibility&lt;/a&gt; there is an advice to use the following command&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;log_infeasible_constraints(model)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The problem with this approach is that it just prints out every single value of a variable that causes problems. As I have quite many variables the printed out information is too large for the console of Spyder. So basically I have 2 questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can I print out the information from the log into a txt file? I tried the following but I get an error message:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;file = open(&amp;quot;Log.txt&amp;quot;, &amp;quot;w&amp;quot;) &#xA;file.write(log_infeasible_constraints(model)) &#xA;file.close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;--&amp;gt; &lt;code&gt;TypeError: write() argument must be str, not None&lt;/code&gt;&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Is there another approach for finding out what is causing the problem in Pyomo? Can I somehow see the values of all variables at the time the infeasibility or unboundedness is found out?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Reminder&lt;/strong&gt;: Does anyone have an idea how I can get more precise information about the error? Especially seeing the values of the variables would be quite helpful. Any idea?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2021-04-23T08:24:09.270" LastActivityDate="2023-11-28T03:08:19.833" Title="How to find out which constraint causes problems in Pyomo" Tags="|constraint|gurobi|pyomo|unboundedness|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6098" PostTypeId="2" ParentId="6097" CreationDate="2021-04-14T13:36:17.007" Score="4" Body="&lt;p&gt;You can find out which constraints cause the infeasibility by the following code. For details look at &lt;a href=&quot;https://github.com/Pyomo/pyomo/blob/main/pyomo/util/infeasible.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;log_infeasible_constraints(m)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is your model's name. In the provided link, you can find details of how the infeasible constraints log in Pyomo. The output of the provided code is a dictionary with constraint name, constraint's body value, constraint's lower bound, etc. These values can be obtained individually as well. Instead of write, I suggest using &lt;code&gt;print&lt;/code&gt; to see what the output is.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&#xA;The following is an MWE for your question:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.environ import Param, ConcreteModel, Var, Objective, ConstraintList, value, minimize&#xA;from pyomo.opt import SolverFactory&#xA;from pyomo.util.infeasible import log_infeasible_constraints&#xA;import logging&#xA;&#xA;m = ConcreteModel()&#xA;m.LE = set([1, 2, 3])&#xA;m.x = Var(m.LE, initialize=0)&#xA;m.M = Param(initialize=1000000)&#xA;&#xA;def obj_rule(m):&#xA;        return sum(m.x[i] * 1 for i in m.LE)&#xA;&#xA;m.z = Objective(rule=obj_rule, sense=minimize)&#xA;m.cons1 = ConstraintList()&#xA;&#xA;for i in m.LE:&#xA;    m.cons1.add(10**2 * m.x[i] &amp;gt;= m.M)&#xA;    m.cons1.add(10**2 * m.x[i] &amp;lt;= -3)&#xA;&#xA;solver = SolverFactory('glpk')&#xA;solution = solver.solve(m, tee=False)&#xA;log_infeasible_constraints(m, log_expression=True, log_variables=True)&#xA;logging.basicConfig(filename='example.log', encoding='utf-8', level=logging.INFO)&#xA;print(value(m.z))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And the &lt;code&gt;example.log&lt;/code&gt; is the generated .txt file which includes the following data:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;INFO:pyomo.util.infeasible:CONSTR cons1[1]: 1000000.0 &amp;lt;/= 0&#xA;  - EXPR: 1000000.0 &amp;lt;/= 100*x[1]&#xA;  - VAR x[1]: 0&#xA;INFO:pyomo.util.infeasible:CONSTR cons1[2]: 0 &amp;lt;/= -3.0&#xA;  - EXPR: 100*x[1] &amp;lt;/= -3.0&#xA;  - VAR x[1]: 0&#xA;INFO:pyomo.util.infeasible:CONSTR cons1[3]: 1000000.0 &amp;lt;/= 0&#xA;  - EXPR: 1000000.0 &amp;lt;/= 100*x[2]&#xA;  - VAR x[2]: 0&#xA;INFO:pyomo.util.infeasible:CONSTR cons1[4]: 0 &amp;lt;/= -3.0&#xA;  - EXPR: 100*x[2] &amp;lt;/= -3.0&#xA;  - VAR x[2]: 0&#xA;INFO:pyomo.util.infeasible:CONSTR cons1[5]: 1000000.0 &amp;lt;/= 0&#xA;  - EXPR: 1000000.0 &amp;lt;/= 100*x[3]&#xA;  - VAR x[3]: 0&#xA;INFO:pyomo.util.infeasible:CONSTR cons1[6]: 0 &amp;lt;/= -3.0&#xA;  - EXPR: 100*x[3] &amp;lt;/= -3.0&#xA;  - VAR x[3]: 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;example.log&lt;/code&gt; is generated in the same location that you run your code (same folder).&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2021-04-27T18:14:41.967" LastActivityDate="2021-04-27T18:14:41.967" CommentCount="20" ContentLicense="CC BY-SA 4.0" />
  <row Id="6099" PostTypeId="2" ParentId="6093" CreationDate="2021-04-14T18:22:04.747" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;CPLEX treats certain small values as negligible &lt;em&gt;for purposes of constraint satisfaction&lt;/em&gt; (including satisfying integrality constraints). That does not mean it automatically rounds small values to zero. If the coefficient 1.4210854715202e-14 in your cut is the value of a dual variable from a subproblem, it is up to you to decide whether to round it to zero when constructing the cut or leave it as it is.&lt;/li&gt;&#xA;&lt;li&gt;Are you sure that the warning applies to the coefficient 16.47999...? Might you be looking at the wrong constraint? The value 16.48(ish) should not be less than either of the mentioned bounds, unless you changed one of those parameters to an unusually large value.&lt;/li&gt;&#xA;&lt;li&gt;For certain sources of instability (such as the notorious &amp;quot;big M&amp;quot; constraint), you may be able to mitigate stability issues by either changing the model in a fundamental way, scaling things better, or just finding a tighter value of M. Otherwise, it's a hit-and-miss thing. You can try rounding/truncating dual values a bit before creating Benders cuts (in particular, rounding anything times 10^-14 to 0) and see what happens. Also, keep in mind that the CPLEX messages are just warnings of a &lt;em&gt;possible issue&lt;/em&gt;, not guarantees that your results are buggered. If your model is producing plausible answers, it may not need any fixing.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-04-14T18:22:04.747" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6100" PostTypeId="1" CreationDate="2021-04-14T20:07:18.090" Score="3" ViewCount="46" Body="&lt;p&gt;I would like to know if my methodology was 'correct':&lt;/p&gt;&#xA;&lt;p&gt;I am trying to conduct an experiment on my stores. I would like to find out the effect of a marketing campaign on the number of transactions.&lt;/p&gt;&#xA;&lt;p&gt;Only about 20% of the stores are participating in the marketing campaign.&lt;/p&gt;&#xA;&lt;p&gt;The original methodology was to use the entire 20% as the experimental group and the remaining 80% as the control group. Unfortunately, these two groups are incomparable in terms of number of transactions. when plotted as box and whisker plots next to each other, their distributions are incomparable (mean, median, quartlies, min, max, etc).&lt;/p&gt;&#xA;&lt;p&gt;So what I did was filter out the 'outlier stores' at each end until the box and whisker plots for each group were practically identical. I then ran a t-test on the filtered groups, we failed to rej the null (meaning that these groups are statistically the same prior to the promotion).&lt;/p&gt;&#xA;&lt;p&gt;Now that we have 2 comparable groups for time -1, we run the promotion for a month. after promotion month is over, we take the number of transactions from each group and run another t-test. We Rejected the null in favor of the alternate Hypo, which is that these 2 groups are now statistically different with an alpha of 0.05.&lt;/p&gt;&#xA;&lt;p&gt;My first question is: is this methodology okay ?&lt;/p&gt;&#xA;&lt;p&gt;My second question is: alternatively from using box and whiskers and removing outliers until both groups' descriptive stats are similar, can i use a normal distribution and STDEV to remove outliers and create comparable groups within my population ? The box and whisker method worked to get a comparable groups as confirmed by the t-test, but is very manual. So i would like to create an automated method and was wondering if using a normal distribution and removing outliers by STDEV would be plausible ?&lt;/p&gt;&#xA;" OwnerUserId="5351" LastEditorUserId="491" LastEditDate="2021-04-18T16:45:01.467" LastActivityDate="2021-04-18T16:45:01.467" Title="Control &amp; Experimental Group Selection Methodology using STDEV and T-Test?" Tags="|optimization|modeling|python|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6101" PostTypeId="1" AcceptedAnswerId="6104" CreationDate="2021-04-14T20:54:26.003" Score="13" ViewCount="1061" Body="&lt;p&gt;I am sort of new to mathematical optimization and have to build some fairly complicated models for my thesis. I was wondering where I could find literature to help me develop more efficient versions of them. I'm thinking of general good practices in the field, common solutions to constraints that are usually a bottleneck in the computations. For example, avoiding non-linear constraints in our formulations, by linearizing the product of a binary and a continuous, as it is generally a good practice, as far as I know.&lt;/p&gt;&#xA;&lt;p&gt;To summarize, I'm confident that my methods yield the correct results, but would like equivalent (or weaker but sufficiently strong) formulations that are more efficient.&lt;/p&gt;&#xA;&lt;p&gt;If it helps, the problem I'm dealing with is to find the best time to schedule maintenance in order to minimize costs, subject to a bunch of constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/834/best-practices-for-formulating-mips&quot;&gt;Here&lt;/a&gt;, Gualandi mentions &lt;em&gt;Model Building in Mathematical Programming&lt;/em&gt; which I will definitely take a look. Are there any more books or websites/forums on the topic?&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&lt;p&gt;I also found &lt;em&gt;Speeding up Energy System Models -&#xA;a Best Practice Guide&lt;/em&gt;, which seems to answer my question as well, but I haven't looked into it yet.&lt;/p&gt;&#xA;" OwnerUserId="5352" LastEditorUserId="5352" LastEditDate="2021-04-14T22:46:41.773" LastActivityDate="2021-04-18T22:33:29.790" Title="Where can I find documentation on good practices for efficient formulations of a problem?" Tags="|mixed-integer-programming|modeling|reference-request|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6102" PostTypeId="2" ParentId="6101" CreationDate="2021-04-15T07:25:53.857" Score="7" Body="&lt;p&gt;Honestly, there is not that much in general that I am aware of. The best resource (other than the ones you mentioned) that comes to mind is Fischetti's modeling book &amp;quot;&lt;a href=&quot;https://www.amazon.de/Introduction-Mathematical-Optimization-English-Fischetti-ebook/dp/B0869NFNZX/ref=sr_1_1?__mk_de_DE=%C3%85M%C3%85%C5%BD%C3%95%C3%91&amp;amp;dchild=1&amp;amp;keywords=fischetti+optimization&amp;amp;qid=1618471253&amp;amp;sr=8-1&quot; rel=&quot;noreferrer&quot;&gt;Introduction to Mathematical Optimization&lt;/a&gt;&amp;quot;, which gives a good overview over many standard problems and various formulations.&lt;/p&gt;&#xA;&lt;p&gt;Otherwise I can recommend some specific ones:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://opensolver.org/opensolverwordpress2/wp-content/uploads/2016/11/AIMMS3OM_LinearProgrammingTricks.pdf&quot; rel=&quot;noreferrer&quot;&gt;LP tricks&lt;/a&gt; by AIMMS&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://download.aimms.com/aimms/download/manuals/AIMMS3OM_IntegerProgrammingTricks.pdf&quot; rel=&quot;noreferrer&quot;&gt;MIP tricks&lt;/a&gt; by AIMMS&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;noreferrer&quot;&gt;Modeling cookbook&lt;/a&gt; by MOSEK&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="133" LastActivityDate="2021-04-15T07:25:53.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6103" PostTypeId="2" ParentId="6101" CreationDate="2021-04-15T07:29:54.203" Score="5" Body="&lt;p&gt;You might find &lt;a href=&quot;https://docs.optaplanner.org/latestFinal/optaplanner-docs/html_single/index.html#domainModelingGuide&quot; rel=&quot;noreferrer&quot;&gt;OptaPlanner's domain modeling guide&lt;/a&gt; (Docs section 20.2) useful.&lt;/p&gt;&#xA;&lt;p&gt;It's a step by step guide on how to design a good model - and explains why some models are better or worse than others. Here's a few examples of good vs bad models:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pdYW5.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pdYW5.png&quot; alt=&quot;Modeling guide&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QWnEW.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QWnEW.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-04-15T07:29:54.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6104" PostTypeId="2" ParentId="6101" CreationDate="2021-04-15T07:54:21.523" Score="14" Body="&lt;p&gt;In my opinion, @Erwin Kalvelagen's &lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2020/&quot; rel=&quot;noreferrer&quot;&gt;blog&lt;/a&gt; is a great resource for learning mathematical modeling.&lt;/p&gt;&#xA;&lt;p&gt;He posts a variety of tricks and tips, compares different models with one another, different solvers, etc.&lt;/p&gt;&#xA;&lt;p&gt;What is great about the blog is that its not just textbook theory, its operational research exploration which challenges and/or verifies textbook theory.&lt;/p&gt;&#xA;&lt;p&gt;Otherwise I recommend the famous &lt;a href=&quot;https://mitmgmtfaculty.mit.edu/jorlin/network-flows/&quot; rel=&quot;noreferrer&quot;&gt;Network Flows&lt;/a&gt; book by Ahuja et al.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-04-15T08:52:05.513" LastActivityDate="2021-04-15T08:52:05.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6106" PostTypeId="2" ParentId="6089" CreationDate="2021-04-15T11:41:56.940" Score="2" Body="&lt;p&gt;For a continuous function, all you need to do is prove that it's (i) non-convex, and (ii) monotonic. (i) can be shown using the eigenvalues of the hessian matrix, and (ii) using the gradient.&lt;/p&gt;&#xA;&lt;p&gt;However, in your case your domain is &lt;span class=&quot;math-container&quot;&gt;$\mathbb{Z}$&lt;/span&gt;, therefore derivatives are generally not defined, and neither is the concept of (pseudo)convexity.&lt;/p&gt;&#xA;&lt;p&gt;You can show whether the relaxed &lt;span class=&quot;math-container&quot;&gt;$f:\mathbb{R}\rightarrow \mathbb{R}$&lt;/span&gt; is pseudo-convex, but the concept is not defined in the integral domain. In a way, this directly answers your question: &lt;span class=&quot;math-container&quot;&gt;$f:\mathbb{Z}\rightarrow \mathbb{R}$&lt;/span&gt; can not be pseudo-convex.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-04-15T17:00:35.550" LastActivityDate="2021-04-15T17:00:35.550" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6107" PostTypeId="2" ParentId="6100" CreationDate="2021-04-15T17:44:12.470" Score="1" Body="&lt;p&gt;I don't think weeding &amp;quot;outliers&amp;quot; will get you to a fair comparison, given that some stores have larger sales than others. A somewhat crude alternative is to compute two average sales per period figures for every store, one for a time period before the marketing campaign and the other for the time period containing the marketing campaign. Then compare the ratios of after-average divided by before-average. Hopefully the ratio is ~1 for the control group and &amp;gt; 1 for the experimental group.&lt;/p&gt;&#xA;&lt;p&gt;A potentially more accurate but much more complicated approach uses what is known as &amp;quot;time series intervention analysis&amp;quot;. The intervention here is the marketing campaign. You fit a time series model to the experimental stores (individually or in aggregate) using pre-campaign data, then use the post-campaign data to estimate the change due to the intervention. You don't really need the control group for this, although you might want to fit a time series model to the control group just to verify that it remains stable after the marketing campaign starts (ruling out the possibility that some other factor that coincides with the marketing campaign is causing the change -- a pandemic, arrival of a cicada brood, the Dodgers winning the World Series, ...). This approach requires facility with &lt;a href=&quot;https://en.wikipedia.org/wiki/Autoregressive_integrated_moving_average&quot; rel=&quot;nofollow noreferrer&quot;&gt;ARIMA models&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-04-15T17:44:12.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6108" PostTypeId="1" AcceptedAnswerId="6109" CreationDate="2021-04-15T21:31:37.783" Score="3" ViewCount="534" Body="&lt;p&gt;I am trying to write a mathematical problem that involves some conditions based on binary variables. More specifically, I have a set of three binary variables &lt;span class=&quot;math-container&quot;&gt;$d_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_3$&lt;/span&gt; and depending on their values, I want to have some other binary variables &lt;span class=&quot;math-container&quot;&gt;$y_1,\ldots,y_5$&lt;/span&gt; activated according to the following table:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;&lt;/th&gt;&#xA;&lt;th&gt;&lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th&gt;&lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th&gt;&lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th&gt;&lt;span class=&quot;math-container&quot;&gt;$y_4$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th&gt;&lt;span class=&quot;math-container&quot;&gt;$y_5$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$d_1$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$d_2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$d_3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;For instance, &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; is equal to 1 if and only if &lt;span class=&quot;math-container&quot;&gt;$d_1$&lt;/span&gt; is equal to 1. Same goes for the pairs &lt;span class=&quot;math-container&quot;&gt;$(y_2,d_2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(y_3,d_3)$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$y_4$&lt;/span&gt; becomes equal to 1 if both &lt;span class=&quot;math-container&quot;&gt;$d_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_2$&lt;/span&gt; are 1. Finally, &lt;span class=&quot;math-container&quot;&gt;$y_5$&lt;/span&gt; becomes 1 if all of &lt;span class=&quot;math-container&quot;&gt;$d_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_3$&lt;/span&gt; are equal to 1.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, at the same time, only one of &lt;span class=&quot;math-container&quot;&gt;$y_1,\ldots,y_5$&lt;/span&gt; can be activated, which is to formulate as &lt;span class=&quot;math-container&quot;&gt;$\sum y_i = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am having problems though formulating the other constraints regarding the &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; variables.&lt;/p&gt;&#xA;&lt;p&gt;I have tried formulating the following set of constraints for &lt;span class=&quot;math-container&quot;&gt;$y_5$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y_{\rm intermediate} \geq d_1 + d_2 - 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This will allow &lt;span class=&quot;math-container&quot;&gt;$y_{\rm intermediate}$&lt;/span&gt; to become 1 if both &lt;span class=&quot;math-container&quot;&gt;$d_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_2$&lt;/span&gt; are activated.&lt;/p&gt;&#xA;&lt;p&gt;Then, I could have: &lt;span class=&quot;math-container&quot;&gt;\begin{align}y_5 &amp;amp;\geq y_{\rm intermediate} + d_3 - 1\\y_4&amp;amp;\geq y_{\rm intermediate} + (1 - d_3) - 1\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then depending on the value of &lt;span class=&quot;math-container&quot;&gt;$d_3$&lt;/span&gt; either &lt;span class=&quot;math-container&quot;&gt;$y_5$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$y_4$&lt;/span&gt; will become equal to 1.&lt;/p&gt;&#xA;&lt;p&gt;However, I am having trouble formulating the rest of the constraints for &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt; and I am also not sure if what I already have is good enough.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone have any pointers or ideas? Any help would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3441" LastEditorUserId="123" LastEditDate="2021-04-16T10:13:15.693" LastActivityDate="2021-04-16T10:13:15.693" Title="Constraints that set values to binary variables depending on other binaries" Tags="|mixed-integer-programming|integer-programming|constraint|linearization|binary-variable|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6109" PostTypeId="2" ParentId="6108" CreationDate="2021-04-15T22:07:22.423" Score="7" Body="&lt;p&gt;If I understand correctly, the following enforces your desired behavior:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_1 &amp;amp;= d_1 \\&#xA;y_2 &amp;amp;= d_2 \\&#xA;y_3 &amp;amp;= d_3 \\&#xA;y_4 &amp;amp;\ge d_1 + d_2 - 1\\&#xA;y_5 &amp;amp;\ge d_1 + d_2 + d_3 - 2\\&#xA;\end{align}&lt;/span&gt;&#xA;If you also want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_4 \implies (d_1 \land d_2)$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_5 \implies (d_1 \land d_2 \land d_3)$&lt;/span&gt;,&#xA;then include these additional constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_4 &amp;amp;\le d_1 \\ &#xA;y_4 &amp;amp;\le d_2 \\ &#xA;y_5 &amp;amp;\le d_1 \\ &#xA;y_5 &amp;amp;\le d_2 \\ &#xA;y_5 &amp;amp;\le d_3 &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;On second thought, your comment about only one &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; being activated makes me think that, instead of &lt;span class=&quot;math-container&quot;&gt;$y_1 = 1 \iff d_1 = 1$&lt;/span&gt;, you meant &lt;span class=&quot;math-container&quot;&gt;$y_1 = 1 \iff (d_1,d_2,d_3) = (1,0,0)$&lt;/span&gt;.  Equivalently, &lt;span class=&quot;math-container&quot;&gt;$y_1 = d_1(1-d_2)(1-d_3)$&lt;/span&gt;, which you can linearize as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_1 &amp;amp;\le d_1 \\&#xA;y_1 &amp;amp;\le 1 - d_2 \\&#xA;y_1 &amp;amp;\le 1 - d_3 \\&#xA;y_1 &amp;amp;\ge d_1 + (1 - d_2) + (1 - d_3) - 2&#xA;\end{align}&lt;/span&gt;&#xA;You could similarly set up four linear inequality constraints for each of the other &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; and then impose &lt;span class=&quot;math-container&quot;&gt;$y_1+y_2+y_3+y_4+y_5=1$&lt;/span&gt;.  But a simpler formulation is just to treat the table entries as the constraint coefficients:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_1 + y_4 + y_5 &amp;amp;= d_1 \\&#xA;y_2 + y_4 + y_5 &amp;amp;= d_2 \\&#xA;y_3 + y_5 &amp;amp;= d_3 \\&#xA;y_1 + y_2 + y_3 + y_4 + y_5 &amp;amp;= 1&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-04-15T23:34:54.453" LastActivityDate="2021-04-15T23:34:54.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6110" PostTypeId="1" AcceptedAnswerId="6114" CreationDate="2021-04-16T08:21:42.407" Score="0" ViewCount="892" Body="&lt;p&gt;I am defining a Pyomo model that should have some mutable Big-M parameters whose values should be dynamically assigned (once). However, I am having a problem with a difference equation as described in this post &lt;a href=&quot;https://or.stackexchange.com/questions/6105/error-message-in-difference-equation-in-pyomo&quot;&gt;Error message in difference equation in Pyomo&lt;/a&gt;. Here you can see my extremel simplified model in pyomo (that does not make much sense from a logical point of view, but I just want to adress the error):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;import pandas as pd&#xA;from pyomo.util.infeasible import log_infeasible_constraints&#xA;&#xA;&#xA;#Define the model&#xA;model = pyo.ConcreteModel()&#xA;&#xA;&#xA;#Define the sets&#xA;model.set_timeslots = pyo.RangeSet(1, 288)&#xA;&#xA;&#xA;#Define the bigM parameter&#xA;model.param_BigM_Surplus_Positive = pyo.Param(model.set_timeslots, mutable=True, default =0)&#xA;&#xA;&#xA;#Define the variables&#xA;model.variable_temperatureBufferStorage = pyo.Var(model.set_timeslots, bounds=(20, 22))&#xA;model.variable_surplusPowerTotal = pyo.Var(model.set_timeslots)&#xA;&#xA;&#xA;&#xA;#Equations for the Big-M parameters&#xA;'''When commenting this Big-M parameter equation out, the model can be solved. Otherwise I get an error for each value of the variable model.variable_temperatureBufferStorage&#xA;   variable ERROR: evaluating object as numeric value:&#xA;    variable_temperatureBufferStorage[274]&#xA;    (object: &amp;lt;class 'pyomo.core.base.var._GeneralVarData'&amp;gt;)&#xA;    No value for uninitialized NumericValue object&#xA;    variable_temperatureBufferStorage[274]&#xA;'''    &#xA;def BigM_Surplus_PositiveRule (model, t):&#xA;    return model.param_BigM_Surplus_Positive [t] == 10&#xA;&#xA;model.constraint_BigM_Surplus_Positive = pyo.Constraint(model.set_timeslots, rule = BigM_Surplus_PositiveRule)&#xA;&#xA;&#xA;&#xA;# Defining the constraints &#xA;&#xA;&#xA;#Temperature constraint for the buffer storage (space heating) with energetic difference equation&#xA;def temperatureBufferStorageConstraintRule(model, t):&#xA;    if t == model.set_timeslots.first():&#xA;        return model.variable_temperatureBufferStorage[t] == 21&#xA;    return model.variable_temperatureBufferStorage[t] == model.variable_temperatureBufferStorage[t-1] &#xA;&#xA;model.constraint_temperatureBufferStorage = pyo.Constraint (model.set_timeslots, rule=temperatureBufferStorageConstraintRule)&#xA;&#xA;&#xA;#Equations for the surplus power&#xA;def surplusPowerTotalRule (model, t):&#xA;    return model.variable_surplusPowerTotal [t] == 1&#xA;&#xA;model.constraint_surplusPowerTotal = pyo.Constraint(model.set_timeslots, rule = surplusPowerTotalRule)&#xA;&#xA;&#xA;&#xA;#Objectives&#xA;&#xA;def objectiveRule_combined_general (model):&#xA;    return  sum(model.variable_surplusPowerTotal[t] for t in model.set_timeslots)&#xA;    &#xA;model.objective_combined_general = pyo.Objective( rule=objectiveRule_combined_general, sense =pyo.minimize)&#xA;&#xA;&#xA;&#xA;print(&amp;quot;Start of solving&amp;quot;)&#xA;solver = pyo.SolverFactory('gurobi')&#xA;solver.options['MIPGap'] = 1&#xA;solver.options['TimeLimit'] = 20&#xA;solution = solver.solve(model, tee=True)&#xA;&#xA;log_infeasible_constraints(model)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The problematic part is when I define the constraints for the mutable Big-M parameter &lt;code&gt;model.param_BigM_Surplus_Positive = pyo.Param(model.set_timeslots, mutable=True, default =0)&lt;/code&gt;. When they are active and not commented out I get an error from Gurobi telling that the problem is infeasible or unbounded:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Infeasible or unbounded model&#xA;WARNING: Loading a SolverResults object with a warning status into&#xA;    model.name=&amp;quot;unknown&amp;quot;;&#xA;      - termination condition: infeasibleOrUnbounded&#xA;      - message from solver: Problem proven to be infeasible or unbounded.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When looking what is causing this problem with &lt;code&gt;from pyomo.util.infeasible import log_infeasible_constraints&lt;/code&gt; I can see an error for each value of the variable &lt;code&gt;model.variable_temperatureBufferStorage&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ERROR: evaluating object as numeric value:&#xA;    variable_temperatureBufferStorage[2]&#xA;        (object: &amp;lt;class 'pyomo.core.base.var._GeneralVarData'&amp;gt;)&#xA;    No value for uninitialized NumericValue object&#xA;    variable_temperatureBufferStorage[2]&#xA;ERROR: evaluating object as numeric value:&#xA;    variable_temperatureBufferStorage[3]&#xA;        (object: &amp;lt;class 'pyomo.core.base.var._GeneralVarData'&amp;gt;)&#xA;    No value for uninitialized NumericValue object&#xA;    variable_temperatureBufferStorage[3]&#xA;ERROR: evaluating object as numeric value:&#xA;    variable_temperatureBufferStorage[4]&#xA;        (object: &amp;lt;class 'pyomo.core.base.var._GeneralVarData'&amp;gt;)&#xA;    No value for uninitialized NumericValue object&#xA;    variable_temperatureBufferStorage[4]`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Without the Big-M parameter constraints the model is solvable. So my question is why does this error occur when having a mutable parameter and how can I tackle this problem?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="491" LastEditDate="2021-04-18T16:45:52.113" LastActivityDate="2021-04-18T16:45:52.113" Title="Mutable parameter in Pyomo causes a problem" Tags="|python|pyomo|big-m|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6111" PostTypeId="2" ParentId="6101" CreationDate="2021-04-16T10:42:55.760" Score="3" Body="&lt;p&gt;I would also add &lt;a href=&quot;https://www.springer.com/gp/book/9783319567679&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Optimization in Engineering&amp;quot;&lt;/a&gt; as a reference. It offers a good overview on LPs, MILPs and convex programming, focusing on applications. It is also a good resource in best practises, see for example Chapter 3.3 &amp;quot;Linearizing Nonlinearities Using Binary Variables&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="4150" LastActivityDate="2021-04-16T10:42:55.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6112" PostTypeId="2" ParentId="6101" CreationDate="2021-04-16T14:57:34.047" Score="3" Body="&lt;p&gt;There's also the &lt;a href=&quot;https://github.com/Octeract/reformulator&quot; rel=&quot;nofollow noreferrer&quot;&gt;Octeract Reformulator repository&lt;/a&gt;, where we host a growing collection of scripts to automatically apply reformulations to non-linear problems, e.g.:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;&#xA;from octeract import *&#xA;&#xA;# Linearize bilinear term x*y where x,y binary&#xA;# =============================================&#xA;# x*y = w&#xA;# w &amp;lt;= x&#xA;# w &amp;lt;= y&#xA;# x + y - 1 &amp;lt;= w&#xA;# 0 &amp;lt;= w &amp;lt;= 1&#xA;# =============================================&#xA;&#xA;# Define symbolic trigger&#xA;my_trigger = Match('C(n)*V(x)*V(y)') &#xA;&#xA;# Filter binaries &#xA;my_filter = (IsBinary('x') &amp;amp; IsBinary('y'))&#xA;&#xA;# Specify how to change the model&#xA;# Add auxiliary variable with the same bounds as x*y&#xA;add_auxiliary_var = AddBinaryVariable('w_xy')&#xA;substitute_term = SubWith('n*w_xy')&#xA;add_constraint0 = AddConstraint('w_xy &amp;lt;= x')&#xA;add_constraint1 = AddConstraint('w_xy &amp;lt;= y')&#xA;add_constraint2 = AddConstraint('x + y - 1 &amp;lt;= w_xy')&#xA;&#xA;add_constraints = add_constraint0 + add_constraint1 + add_constraint2&#xA;&#xA;# Add all modifications &#xA;my_actions = add_auxiliary_var + substitute_term + add_constraints&#xA;&#xA;# Create mod&#xA;LinearizeBilinearBinaryBinaryMod = (my_trigger &amp;amp; my_filter).then(my_actions)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The language is human readable so it's easy to understand/modify what's happening, and the reformulations can be automatically applied to any problem. For instance, this script will automatically linearise any Binary Quadratic problem:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;&#xA;&#xA;from octeract import *&#xA;from LinearizeBilinearBinaryBinary import LinearizeBilinearBinaryBinaryMod&#xA;from LinearizeBilinearContBinary import LinearizeBilinearContBinaryMod&#xA;from LinearizeSquaredBinary import LinearizeSquaredBinaryMod&#xA;&#xA;m = Model()&#xA;&#xA;m.add_variable(&amp;quot;y1&amp;quot;, 0, 1, BIN)&#xA;m.add_variable(&amp;quot;y2&amp;quot;, 0, 1, BIN)&#xA;m.add_variable(&amp;quot;y3&amp;quot;, 0, 1, BIN)&#xA;m.add_variable(&amp;quot;x&amp;quot;, -10, 10)&#xA;m.minimize(&amp;quot;2*y1*y2 + 3*x*y1 + y1^2&amp;quot;)&#xA;&#xA;m.set(&amp;quot;y2*y3 + y2*x + 5*y2*y1 - 5*y2^2&amp;quot;).to(0)&#xA;&#xA;print(m)&#xA;&#xA;m.apply_mod(LinearizeBilinearBinaryBinaryMod)&#xA;m.apply_mod(LinearizeBilinearContBinaryMod)&#xA;m.apply_mod(LinearizeSquaredBinaryMod)&#xA;&#xA;print(m)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-04-16T14:57:34.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6113" PostTypeId="1" AcceptedAnswerId="6115" CreationDate="2021-04-17T23:03:02.980" Score="3" ViewCount="1057" Body="&lt;p&gt;I am interested in the following problem.&#xA;The input is a set of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; integers, and a fixed integer &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&#xA;The required output is a partitioning of the integers into &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; subsets, such that the &lt;em&gt;smallest&lt;/em&gt; sum of a subset is as &lt;em&gt;large&lt;/em&gt; as possible.&#xA;This is a variant of the NP-hard &lt;a href=&quot;https://en.wikipedia.org/wiki/Multiway_number_partitioning&quot; rel=&quot;nofollow noreferrer&quot;&gt;multiway number partitioning&lt;/a&gt; problem.&lt;/p&gt;&#xA;&lt;p&gt;I found several references for Python solutions of a related problem - &lt;a href=&quot;https://en.wikipedia.org/wiki/Bin_packing_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;bin packing&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pypi.org/project/binpacking/&quot; rel=&quot;nofollow noreferrer&quot;&gt;A stand-alone Python package&lt;/a&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://developers.google.com/optimization/bin/bin_packing&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bin packing in OR tools&lt;/a&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/binpacking.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bin packing in LocalSolver&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;But it is a different problem. Also, I am not sure what is the most efficient way to approach this problem - should I search for solutions for this specific problem? Or should I just present it as a general integer programming or use a generic solver?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: Following the answer by Rob Pratt, I installed &lt;a href=&quot;https://pypi.org/project/PuLP/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PuLP&lt;/a&gt; and solved the problem using an integer linear program. In case anyone is interested, here is the code.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def mms_partition(values:list, k:int)-&amp;gt;int:&#xA;    parts = range(k)&#xA;    items = range(len(values))&#xA;    min_value = pulp.LpVariable(&amp;quot;min_value&amp;quot;, cat=pulp.LpContinuous)&#xA;    vars = [&#xA;        [pulp.LpVariable(f&amp;quot;x_{item}_{part}&amp;quot;, lowBound=0, upBound=1, cat=pulp.LpInteger)&#xA;        for part in parts]&#xA;        for item in items&#xA;    ]         # vars[i][j] is 1 iff item i is in part j.&#xA;    mms_problem = pulp.LpProblem(&amp;quot;MMS_problem&amp;quot;, pulp.LpMaximize)&#xA;    mms_problem += min_value    # Objective function: maximize min_value&#xA;    for item in items:  # Constraints: each item must be in exactly one part.&#xA;        mms_problem += (pulp.lpSum([vars[item][part] for part in parts]) == 1)&#xA;    for part in parts:  # Constraint: the sum of each part must be at least min_value (by definition of min_value).&#xA;        mms_problem += (min_value &amp;lt;= pulp.lpSum([vars[item][part]*values[item] for item in items]))&#xA;    pulp.PULP_CBC_CMD(msg=False).solve(mms_problem)&#xA;    return min_value.value()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Usually it works quite fast, but in some cases it is very slow. Here are some run-times on random instances, all with &lt;span class=&quot;math-container&quot;&gt;$k=3$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;3 items, 1-of-3 MMS: 0.013010892027523369 seconds.&#xA;    [1, 8, 14]&#xA;4 items, 1-of-3 MMS: 0.07400063099339604 seconds.&#xA;    [47, 49, 54, 64]&#xA;5 items, 1-of-3 MMS: 0.07231759402202442 seconds.&#xA;    [20, 64, 71, 72, 94]&#xA;6 items, 1-of-3 MMS: 0.08935485797701403 seconds.&#xA;    [45, 55, 61, 70, 86, 93]&#xA;7 items, 1-of-3 MMS: 0.11710083403158933 seconds.&#xA;    [13, 41, 42, 55, 56, 88, 90]&#xA;8 items, 1-of-3 MMS: 0.1803806659881957 seconds.&#xA;    [9, 31, 45, 49, 54, 55, 62, 62]&#xA;9 items, 1-of-3 MMS: 0.1663428150350228 seconds.&#xA;    [3, 6, 23, 35, 38, 38, 46, 77, 84]&#xA;10 items, 1-of-3 MMS: 0.28711252100765705 seconds.&#xA;    [29, 34, 43, 46, 54, 56, 70, 81, 92, 95]&#xA;11 items, 1-of-3 MMS: 0.03978497500065714 seconds.&#xA;    [3, 9, 11, 26, 37, 41, 49, 76, 82, 83, 96]&#xA;12 items, 1-of-3 MMS: 0.6636879530269653 seconds.&#xA;    [3, 8, 9, 12, 38, 47, 53, 65, 71, 73, 85, 94]&#xA;13 items, 1-of-3 MMS: 0.08022642397554591 seconds.&#xA;    [31, 31, 32, 39, 40, 46, 49, 50, 55, 59, 61, 62, 90]&#xA;14 items, 1-of-3 MMS: 0.13822774798609316 seconds.&#xA;    [22, 29, 35, 50, 51, 62, 66, 74, 78, 80, 82, 87, 93, 97]&#xA;15 items, 1-of-3 MMS: 0.06699130398919806 seconds.&#xA;    [5, 6, 8, 9, 12, 15, 15, 18, 19, 54, 56, 59, 73, 73, 88]&#xA;16 items, 1-of-3 MMS: 7.507785552996211 seconds.&#xA;    [18, 29, 30, 30, 44, 47, 57, 60, 66, 77, 77, 78, 79, 82, 83, 93]&#xA;17 items, 1-of-3 MMS: 0.09432925801957026 seconds.&#xA;    [2, 3, 9, 14, 15, 25, 29, 32, 36, 39, 42, 62, 65, 68, 79, 81, 92]&#xA;18 items, 1-of-3 MMS: 0.14621741196606308 seconds.&#xA;    [6, 6, 8, 10, 16, 26, 26, 38, 42, 48, 51, 60, 72, 79, 89, 94, 95, 98]&#xA;19 items, 1-of-3 MMS: 7.723582196980715 seconds.&#xA;    [23, 36, 41, 44, 54, 56, 66, 67, 72, 75, 79, 86, 87, 88, 92, 93, 95, 96, 98]&#xA;20 items, 1-of-3 MMS: 132.41131251398474 seconds.&#xA;    [10, 10, 11, 13, 24, 26, 26, 28, 29, 35, 51, 62, 66, 69, 79, 80, 82, 87, 88, 94]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;EDIT: Here is the log of CBC solving the 20-item problem:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Welcome to the CBC MILP Solver &#xA;Version: 2.9.0 &#xA;Build Date: Feb 12 2015 &#xA;&#xA;command line - /usr/local/lib/python3.8/dist-packages/pulp/apis/../solverdir/cbc/linux/64/cbc /tmp/3de7ce0a9b7f41edbfad00526ae9bffd-pulp.mps max branch printingOptions all solution /tmp/3de7ce0a9b7f41edbfad00526ae9bffd-pulp.sol (default strategy 1)&#xA;At line 2 NAME          MODEL&#xA;At line 3 ROWS&#xA;At line 28 COLUMNS&#xA;At line 273 RHS&#xA;At line 297 BOUNDS&#xA;At line 359 ENDATA&#xA;Problem MODEL has 23 rows, 61 columns and 123 elements&#xA;Coin0008I MODEL read with 0 errors&#xA;Continuous objective value is 323.333 - 0.00 seconds&#xA;Cgl0004I processed model has 23 rows, 61 columns (60 integer (60 of which binary)) and 123 elements&#xA;Cbc0038I Initial state - 4 integers unsatisfied sum - 0.632799&#xA;Cbc0038I Pass   1: suminf.    0.00000 (0) obj. -309 iterations 3&#xA;Cbc0038I Solution found of -309&#xA;Cbc0038I Relaxing continuous gives -309&#xA;Cbc0038I Before mini branch and bound, 56 integers at bound fixed and 0 continuous&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 2 rows 2 columns&#xA;Cbc0038I Mini branch and bound did not improve solution (0.00 seconds)&#xA;Cbc0038I Round again with cutoff of -310.433&#xA;Cbc0038I Pass   2: suminf.    0.03050 (2) obj. -310.433 iterations 1&#xA;Cbc0038I Pass   3: suminf.    0.62908 (2) obj. -310.433 iterations 1&#xA;Cbc0038I Pass   4: suminf.    0.82473 (2) obj. -310.433 iterations 8&#xA;Cbc0038I Solution found of -310.433&#xA;Cbc0038I Relaxing continuous gives -312&#xA;Cbc0038I Before mini branch and bound, 40 integers at bound fixed and 0 continuous&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 3 rows 11 columns&#xA;Cbc0038I Mini branch and bound improved solution from -312 to -322 (0.00 seconds)&#xA;Cbc0038I Round again with cutoff of -322.267&#xA;Cbc0038I Pass   5: suminf.    0.30922 (3) obj. -322.267 iterations 1&#xA;Cbc0038I Pass   6: suminf.    0.37730 (3) obj. -322.267 iterations 1&#xA;Cbc0038I Pass   7: suminf.    0.63034 (4) obj. -322.267 iterations 10&#xA;Cbc0038I Pass   8: suminf.    0.09867 (4) obj. -322.267 iterations 4&#xA;Cbc0038I Pass   9: suminf.    0.68337 (4) obj. -322.267 iterations 7&#xA;Cbc0038I Pass  10: suminf.    0.30922 (3) obj. -322.267 iterations 4&#xA;Cbc0038I Pass  11: suminf.    0.37730 (3) obj. -322.267 iterations 5&#xA;Cbc0038I Pass  12: suminf.    1.21920 (4) obj. -322.267 iterations 7&#xA;Cbc0038I Pass  13: suminf.    0.25604 (4) obj. -322.267 iterations 6&#xA;Cbc0038I Pass  14: suminf.    0.77137 (4) obj. -322.267 iterations 7&#xA;Cbc0038I Pass  15: suminf.    0.35177 (3) obj. -322.267 iterations 6&#xA;Cbc0038I Pass  16: suminf.    0.41986 (3) obj. -322.267 iterations 5&#xA;Cbc0038I Pass  17: suminf.    0.83404 (4) obj. -322.267 iterations 16&#xA;Cbc0038I Pass  18: suminf.    0.54975 (4) obj. -322.267 iterations 6&#xA;Cbc0038I Pass  19: suminf.    1.27959 (4) obj. -322.267 iterations 9&#xA;Cbc0038I Pass  20: suminf.    0.56454 (3) obj. -322.267 iterations 5&#xA;Cbc0038I Pass  21: suminf.    0.63262 (3) obj. -322.267 iterations 8&#xA;Cbc0038I Pass  22: suminf.    1.31931 (4) obj. -322.267 iterations 15&#xA;Cbc0038I Pass  23: suminf.    1.00000 (3) obj. -322.267 iterations 8&#xA;Cbc0038I Pass  24: suminf.    1.00000 (3) obj. -322.267 iterations 9&#xA;Cbc0038I Pass  25: suminf.    1.00000 (3) obj. -322.267 iterations 6&#xA;Cbc0038I Pass  26: suminf.    1.37854 (4) obj. -322.267 iterations 12&#xA;Cbc0038I Pass  27: suminf.    0.56454 (3) obj. -322.267 iterations 8&#xA;Cbc0038I Pass  28: suminf.    0.63262 (3) obj. -322.267 iterations 10&#xA;Cbc0038I Pass  29: suminf.    1.02096 (4) obj. -322.267 iterations 12&#xA;Cbc0038I Pass  30: suminf.    0.98971 (4) obj. -322.267 iterations 6&#xA;Cbc0038I Pass  31: suminf.    1.42328 (4) obj. -322.267 iterations 13&#xA;Cbc0038I Pass  32: suminf.    1.42328 (4) obj. -322.267 iterations 5&#xA;Cbc0038I Pass  33: suminf.    1.01418 (4) obj. -322.267 iterations 11&#xA;Cbc0038I Pass  34: suminf.    1.01418 (4) obj. -322.267 iterations 3&#xA;Cbc0038I No solution found this major pass&#xA;Cbc0038I Before mini branch and bound, 15 integers at bound fixed and 0 continuous&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 14 rows 40 columns&#xA;Cbc0038I Mini branch and bound did not improve solution (0.03 seconds)&#xA;Cbc0038I After 0.03 seconds - Feasibility pump exiting with objective of -322 - took 0.03 seconds&#xA;Cbc0012I Integer solution of -322 found by feasibility pump after 0 iterations and 0 nodes (0.03 seconds)&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 3 rows 10 columns&#xA;Cbc0031I 3 added rows had average density of 61&#xA;Cbc0013I At root node, 3 cuts changed objective from -323.33333 to -323.33333 in 100 passes&#xA;Cbc0014I Cut generator 0 (Probing) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.007 seconds - new frequency is -100&#xA;Cbc0014I Cut generator 1 (Gomory) - 352 row cuts average 60.9 elements, 0 column cuts (0 active)  in 0.008 seconds - new frequency is -100&#xA;Cbc0014I Cut generator 2 (Knapsack) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.003 seconds - new frequency is -100&#xA;Cbc0014I Cut generator 3 (Clique) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.001 seconds - new frequency is -100&#xA;Cbc0014I Cut generator 4 (MixedIntegerRounding2) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.005 seconds - new frequency is -100&#xA;Cbc0014I Cut generator 5 (FlowCover) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.001 seconds - new frequency is -100&#xA;Cbc0014I Cut generator 6 (TwoMirCuts) - 28 row cuts average 47.3 elements, 0 column cuts (0 active)  in 0.003 seconds - new frequency is -100&#xA;Cbc0010I After 0 nodes, 1 on tree, -322 best solution, best possible -323.33333 (0.09 seconds)&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 3 rows 15 columns&#xA;Cbc0004I Integer solution of -323 found after 961 iterations and 81 nodes (0.13 seconds)&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 4 rows 13 columns&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 4 rows 13 columns&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 5 rows 16 columns&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 3 rows 14 columns&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 4 rows 18 columns&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 5 rows 21 columns&#xA;Cbc0010I After 1000 nodes, 8 on tree, -323 best solution, best possible -323.33333 (2.30 seconds)&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 4 rows 19 columns&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 3 rows 16 columns&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 3 rows 17 columns&#xA;Cbc0010I After 2000 nodes, 5 on tree, -323 best solution, best possible -323.33333 (4.62 seconds)&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 3 rows 13 columns&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 5 rows 22 columns&#xA;Cbc0010I After 3000 nodes, 5 on tree, -323 best solution, best possible -323.33333 (7.92 seconds)&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 3 rows 19 columns&#xA;Cbc0010I After 4000 nodes, 5 on tree, -323 best solution, best possible -323.33333 (9.92 seconds)&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 4 rows 17 columns&#xA;Cbc0010I After 5000 nodes, 6 on tree, -323 best solution, best possible -323.33333 (12.14 seconds)&#xA;Cbc0038I Full problem 23 rows 61 columns, reduced to 4 rows 17 columns&#xA;Cbc0001I Search completed - best objective -323, took 2028836 iterations and 1170256 nodes (13.24 seconds)&#xA;Cbc0032I Strong branching done 10846 times (21617 iterations), fathomed 206 nodes and fixed 620 variables&#xA;Cbc0041I Maximum depth 20, 257 variables fixed on reduced cost (complete fathoming 2647 times, 1164430 nodes taking 2019718 iterations)&#xA;Cuts at root node changed objective from -323.333 to -323.333&#xA;Probing was tried 100 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.007 seconds)&#xA;Gomory was tried 100 times and created 352 cuts of which 0 were active after adding rounds of cuts (0.008 seconds)&#xA;Knapsack was tried 100 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.003 seconds)&#xA;Clique was tried 100 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.001 seconds)&#xA;MixedIntegerRounding2 was tried 100 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.005 seconds)&#xA;FlowCover was tried 100 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.001 seconds)&#xA;TwoMirCuts was tried 100 times and created 28 cuts of which 0 were active after adding rounds of cuts (0.003 seconds)&#xA;&#xA;Result - Optimal solution found&#xA;&#xA;Objective value:                323.00000000&#xA;Enumerated nodes:               1170256&#xA;Total iterations:               2028836&#xA;Time (CPU seconds):             13.24&#xA;Time (Wallclock seconds):       13.54&#xA;&#xA;Option for printingOptions changed from normal to all&#xA;Total time (CPU seconds):       13.24   (Wallclock seconds):       13.54&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;EDIT: I re-implemented with XPRESS solver. Now I can solve instances with over 100 items in less than a second. I do not know what was the problem with CBC.&lt;/p&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="2576" LastEditDate="2021-04-21T17:19:46.837" LastActivityDate="2021-04-21T17:19:46.837" Title="Efficient solver for multiway number partitioning" Tags="|python|integer-programming|combinatorial-optimization|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6114" PostTypeId="2" ParentId="6110" CreationDate="2021-04-17T23:12:21.167" Score="2" Body="&lt;p&gt;Based on given model section, model.param_BigM_Surplus_Positive  parameter is used in only constraint which is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.constraint_BigM_Surplus_Positive = pyo.Constraint(model.set_timeslots, rule = BigM_Surplus_PositiveRule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You are using BigM_Surplus_PositiveRule for generating constraint which is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.param_BigM_Surplus_Positive[t] == 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But this parameter is defined as 0, therefore model is infeasible. If you want to assign 10 to this parameter, you should use &lt;a href=&quot;https://github.com/Pyomo/pyomo/blob/main/examples/pyomo/tutorials/param.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;initialize function&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note: On your model there isn't any big-m constraint. &lt;a href=&quot;https://or.stackexchange.com/questions/3299/problem-with-big-m-in-cplex-opl?rq=1&quot;&gt;In this question&lt;/a&gt; you can find an example.&lt;/p&gt;&#xA;" OwnerUserId="432" LastActivityDate="2021-04-17T23:12:21.167" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6115" PostTypeId="2" ParentId="6113" CreationDate="2021-04-17T23:15:50.157" Score="4" Body="&lt;p&gt;Here's one possible formulation, where &lt;span class=&quot;math-container&quot;&gt;$a_1,\dots, a_n$&lt;/span&gt; are the values of the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; integers.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; indicate whether integer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to subset &lt;span class=&quot;math-container&quot;&gt;$j\in\{1,\dots,k\}$&lt;/span&gt;.  The problem is to maximize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j x_{i,j} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \tag1\\&#xA;\sum_i a_i x_{i,j} &amp;amp;\ge z &amp;amp;&amp;amp;\text{for all $j$} \tag2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; assigns each integer to exactly one subset.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces the maximin objective.&lt;/p&gt;&#xA;&lt;p&gt;If you use a solver that does not exploit symmetry, you will want to include explicit symmetry-breaking constraints.  For example, impose descending order with respect to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i a_i x_{i,j} \ge \sum_i a_i x_{i,j+1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you have multiple duplicate values of &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;, an integer (rather than binary) formulation is likely to perform better.  In that case, the interpretation of &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; is the number of copies of integer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; assigned to subset &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and the RHS of &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; should instead be the total number of copies of integer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In either case, a simple greedy heuristic can provide a good initial feasible solution: sort the values in descending order and assign each item to the subset whose current sum is the smallest.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Another approach for this maximin problem is to apply bisection search for the optimal objective value &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt;.  The greedy heuristic (or any integer feasible solution) provides a lower bound &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$U=(\sum_i a_i)/k$&lt;/span&gt; is an upper bound.  Now perform a bisection search on the interval &lt;span class=&quot;math-container&quot;&gt;$[L,U]$&lt;/span&gt;, in each step fixing &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to a trial value &lt;span class=&quot;math-container&quot;&gt;$\hat{z}=(L+U)/2$&lt;/span&gt; and solving the resulting feasibility problem.  If the problem is feasible for a given &lt;span class=&quot;math-container&quot;&gt;$\hat{z}$&lt;/span&gt;, it is feasible for all smaller &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; values, and you can update &lt;span class=&quot;math-container&quot;&gt;$L=\hat{z}$&lt;/span&gt;.  Conversely, if the problem is infeasible for a given &lt;span class=&quot;math-container&quot;&gt;$\hat{z}$&lt;/span&gt;, it is infeasible for all larger &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; values, and you can update &lt;span class=&quot;math-container&quot;&gt;$U=\hat{z}$&lt;/span&gt;.  Repeat as needed until the gap &lt;span class=&quot;math-container&quot;&gt;$U-L$&lt;/span&gt; is sufficiently small.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-04-20T19:22:37.930" LastActivityDate="2021-04-20T19:22:37.930" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="6116" PostTypeId="1" AcceptedAnswerId="6130" CreationDate="2021-04-18T18:10:48.730" Score="3" ViewCount="236" Body="&lt;p&gt;Mostly when I search dynamic programming in google I get : dynamic programming (DP) in python, in C++, in java from web pages like geekforgeeks, litecode, codechef, and so on.&lt;/p&gt;&#xA;&lt;p&gt;But in the operation research books (taha,lieberman)  they use just analitical tools.&lt;/p&gt;&#xA;&lt;p&gt;I really want to study this subject, Can I study DP by both OR books and by software industry like python ?&lt;/p&gt;&#xA;&lt;p&gt;Are they the same with differents approach?&lt;/p&gt;&#xA;&lt;p&gt;Is the DP in OR books the same when you make a interview in software industry (i.e for software developer) ?&lt;/p&gt;&#xA;" OwnerUserId="5365" LastEditorUserId="39" LastEditDate="2021-04-18T21:01:30.203" LastActivityDate="2021-04-21T09:53:23.663" Title="Is the Dynamic programming in Operations Research book the same dynamic programming in software industry?" Tags="|python|dynamic-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6117" PostTypeId="1" CreationDate="2021-04-18T19:27:34.127" Score="4" ViewCount="186" Body="&lt;p&gt;I'm working on an implementation of the simplex algorithm.&#xA;I want to solve problems in real time every 30 minutes. They could be interpreted as a classic transportation problem.&#xA;I couldn't really say how much the next problem will be different from the one before.&lt;/p&gt;&#xA;&lt;p&gt;This should be an illustrating example:&lt;/p&gt;&#xA;&lt;p&gt;Problem 1:&lt;br /&gt;&#xA;3 supply points&lt;br /&gt;&#xA;4 demand points&lt;/p&gt;&#xA;&lt;p&gt;total supply = 9&lt;br /&gt;&#xA;total demand = 9&lt;/p&gt;&#xA;&lt;p&gt;Problem 2:&lt;br /&gt;&#xA;2 supply points&lt;br /&gt;&#xA;5 demand points&lt;/p&gt;&#xA;&lt;p&gt;total supply = 10&lt;br /&gt;&#xA;total demand = 10&lt;/p&gt;&#xA;&lt;p&gt;Problem 2 is the problem which follows on problem 1.&#xA;The costs in between all points are known and linear to the transported good.&lt;/p&gt;&#xA;&lt;p&gt;In Problem 2 one supply point became a demand point. Thus regarding the simplex there will be a change of my objective function and my restrictions.&lt;/p&gt;&#xA;&lt;p&gt;Now my question:&#xA;Could I warmstart problem 2 by using my optimal solution of problem 1?&#xA;If so, how much could my problem 2 differ from problem 1 so warmstarting would still be possible?&#xA;For some reason I can't really find literature on this.&lt;/p&gt;&#xA;" OwnerUserId="5366" LastEditorUserId="500" LastEditDate="2023-12-13T18:06:19.860" LastActivityDate="2023-12-13T18:06:19.860" Title="warmstarting simplex algorithm- how much can problems differ from each other?" Tags="|optimization|linear-programming|simplex|dual-simplex|warm-start|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6118" PostTypeId="2" ParentId="6117" CreationDate="2021-04-18T21:15:10.957" Score="6" Body="&lt;p&gt;Your constraint matrix is changing with each new problem, so it might not be easy to warm-start ... and it might not be worthwhile, even if you could. One nice thing (among several) about transportation problems is that the origin is feasible, meaning the simplex method has an obvious starting basis. Warm-starting would require you to massage the previous solution into a feasible solution for the modified problem (which might not be easy, especially if a source becomes a sink or or if the network structure changes substantially), and would then require the solver to take your proposed solution and reverse-engineer a basis for it (unless you are going to use an interior point method). It's not clear if all that work would pay for itself.&lt;/p&gt;&#xA;&lt;p&gt;If your problem is sufficiently different from a transportation problem that a starting basis is not obvious, and if you could extract from the previous optimal solution a pretty good (really good?) starting solution for the next problem, then it &lt;em&gt;might&lt;/em&gt; be worthwhile.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-04-18T21:15:10.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6119" PostTypeId="2" ParentId="6101" CreationDate="2021-04-18T22:33:29.790" Score="2" Body="&lt;p&gt;For the case of mixed integer programs, I would recommend the following paper:&lt;/p&gt;&#xA;&lt;p&gt;Klotz, E., &amp;amp; Newman, A. M. (2013). Practical guidelines for solving difficult mixed integer linear programs. Surveys in Operations Research and Management Science, 18(1-2), 18-32.&lt;/p&gt;&#xA;&lt;p&gt;As the abstract says:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Even with state-of-the-art hardware and software, mixed integer programs can require hours, or even days, of run time and are not guaranteed to yield an optimal (or near-optimal, or any!) solution. In this paper, we present suggestions for appropriate use of state-of-the-art optimizers and guidelines for careful&#xA;formulation, both of which can vastly improve performance.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;I hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="806" LastActivityDate="2021-04-18T22:33:29.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6120" PostTypeId="1" CreationDate="2021-04-19T06:45:19.480" Score="1" ViewCount="116" Body="&lt;p&gt;I have a question of understanding in Gurobi:&#xA;I have an objective function in which my optimization variable x is squared. I have solved this bsiher by a quadratic objective function with &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Now, however, I need another optimization variable in this equation, so according to other posts here, I have set up a constraint that returns me the optimization variable &lt;span class=&quot;math-container&quot;&gt;$z = x^2$&lt;/span&gt; and use this instead of &lt;span class=&quot;math-container&quot;&gt;$x, x$&lt;/span&gt; in my objective function. Correspondingly, I also set the parameter for NonConvex to 2. What irritates me now is that I get different values for my objective function when using &lt;span class=&quot;math-container&quot;&gt;$x, x$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. Maybe someone can explain to me why this is the case or maybe I am doing something wrong.&lt;/p&gt;&#xA;" OwnerUserId="5092" LastActivityDate="2021-04-19T06:45:19.480" Title="Quadratic optimization in Gurobi with constraint" Tags="|optimization|gurobi|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6121" PostTypeId="2" ParentId="5765" CreationDate="2021-04-19T07:30:32.843" Score="3" Body="&lt;p&gt;For sake of completeness: An alternative to using an additional binary variable and a big M would be to use an SOS constraint. An SOS constraint specifies a set of variables, at most one of which may be non-zero.&lt;/p&gt;&#xA;" OwnerUserId="3179" LastActivityDate="2021-04-19T07:30:32.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6122" PostTypeId="1" AcceptedAnswerId="6129" CreationDate="2021-04-20T07:23:33.267" Score="1" ViewCount="3602" Body="&lt;p&gt;I would like to display all the results of Pyomo variables in a pandas dataframe. I had a look at this question &lt;a href=&quot;https://or.stackexchange.com/questions/2708/pyomo-looping-over-a-variable-method/2720#2720&quot;&gt;Pyomo: Looping Over A Variable Method&lt;/a&gt; and tried to adjust it to my case without success. I always get error messages. Here is a part of my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.set_timeslots = pyo.RangeSet(1, 288)&#xA;iterables = list (range (1, 288))&#xA;...&#xA;...&#xA;...&#xA;for v in model.component_objects(pyo.Var, active=True):&#xA;    for index in v:&#xA;        print(index, ': ', pyo.value(v[index]))&#xA;&#xA;DF = pd.DataFrame(index=iterables)&#xA;for v in model.component_objects(pyo.Var, active=True):&#xA;    for index in v:&#xA;        DF.at[index, 'val'] = pyo.value(v[index]) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So I would like to print each value of the variables for all 288 set values for the set model.set_timeslots. Further, I also have some variables that do not depend on a set (for example objective variables). I would also like them to be displayed in a pandas dataframe. Do you know how I can do that? I'd appreciate every comment and would be quite thankful for your help.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Reminder&lt;/strong&gt;: Does nobody have an idea how I can do that?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2021-04-21T05:58:10.040" LastActivityDate="2021-04-21T18:42:25.047" Title="How to display results of Pyomo variables in a pandas dataframe" Tags="|python|pyomo|pandas|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6123" PostTypeId="2" ParentId="6117" CreationDate="2021-04-20T09:43:31.447" Score="2" Body="&lt;p&gt;Warm starting is used predominantly when solving problems that are only slightly different, and typically when only some coefficients have changed. The idea is that many of the feasible polyhedrons' vertices are shared between the two problems, therefore starting at a vertex that was good at a previous problem will save us pivot operations.&lt;/p&gt;&#xA;&lt;p&gt;If the problems are more than &amp;quot;slightly different&amp;quot;, the chances of putting previous information to good use vanish for this very reason, there is little chance that the warm-starting vertex will be anywhere near the optimum, nor even feasible for that matter.&lt;/p&gt;&#xA;&lt;p&gt;What's even harder though is that if the two problems have different dimensionality you would need to somehow manually convert the solution of the first problem to the dimensions of the second one.&lt;/p&gt;&#xA;&lt;p&gt;In some cases this makes sense. For instance, if there is a block of logic that is common between the two problems, say some connectivity constraints, then that information could conceivably carry over well, assuming that you make sure that the variables of the first problem are properly mapped to reflect what's happening in the second one.&lt;/p&gt;&#xA;&lt;p&gt;To make a long story short, you might be able to derive a meaningful connection if you work on this hard enough, but at potentially minimal tradeoff.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-04-20T09:43:31.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6124" PostTypeId="1" CreationDate="2021-04-20T11:05:13.360" Score="4" ViewCount="271" Body="&lt;p&gt;As an R user, I'm trying to read a CPLEX LP model from file by using the &lt;em&gt;read.lp&lt;/em&gt; function from package &lt;em&gt;lpSolveAPI&lt;/em&gt;.&#xA;Here's the command line (from within RStudio):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;lprec &amp;lt;- read.lp(filename=&amp;quot;P01_a.lp&amp;quot;,type = &amp;quot;lp&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I get this message:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Error in read.lp(filename = &amp;quot;P01_a.lp&amp;quot;, type = &amp;quot;lp&amp;quot;) :&#xA;could not interpret P01_a.lp as an lp file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Could you please help me? There seems to be no examples out there.&#xA;I attach the LP file &amp;quot;P01_a.lp&amp;quot; in CPLEX format:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Minimize&#xA;  cost: 12q1 + 14q2 + 16q3 + 18q4 + 10r1 + 12r2 + 14r3 + 16r4 + 3s1 + 3s2 + 3s3 + 3s4&#xA;Subject To&#xA;  d1: q1 +r1 - s1 = 100&#xA;  d2: s1 + q2 + r2 - s2 = 200&#xA;  d3: s2 + q3 + r3 - s3 = 150&#xA;  d4: s3 + q4 + r4 - s4 = 400&#xA;  l1: q1 - 200b1 &amp;gt;= 0&#xA;  l2: q2 - 200b2 &amp;gt;= 0&#xA;  l3: q3 - 200b3 &amp;gt;= 0&#xA;  l4: q4 - 200b4 &amp;gt;= 0&#xA;  m1: r1 - 10000b1 &amp;lt;= 0&#xA;  m2: r2 - 10000b2 &amp;lt;= 0&#xA;  m3: r3 - 10000b3 &amp;lt;= 0&#xA;  m4: r4 - 10000b4 &amp;lt;= 0&#xA;Bounds&#xA;  0 &amp;lt;= q1 &amp;lt;= 200&#xA;  0 &amp;lt;= q2 &amp;lt;= 200&#xA;  0 &amp;lt;= q3 &amp;lt;= 200&#xA;  0 &amp;lt;= q4 &amp;lt;= 200&#xA;Binary&#xA;  b1&#xA;  b2&#xA;  b3&#xA;  b4&#xA;End&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here's my environment:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sessionInfo()&#xA;R version 4.0.2 (2020-06-22)&#xA;Platform: x86_64-w64-mingw32/x64 (64-bit)&#xA;Running under: Windows 10 x64 (build 19041)&#xA;&#xA;Matrix products: default&#xA;&#xA;locale:&#xA;[1] LC_COLLATE=Italian_Italy.1252  LC_CTYPE=Italian_Italy.1252    LC_MONETARY=Italian_Italy.1252&#xA;[4] LC_NUMERIC=C                   LC_TIME=Italian_Italy.1252    &#xA;&#xA;attached base packages:&#xA;[1] stats     graphics  grDevices utils     datasets  methods   base     &#xA;&#xA;other attached packages:&#xA;[1] lpSolveAPI_5.5.2.0-17.7&#xA;&#xA;loaded via a namespace (and not attached):&#xA;[1] compiler_4.0.2  htmltools_0.5.0 tools_4.0.2     yaml_2.2.1      rmarkdown_2.3   knitr_1.29      &#xA;xfun_0.16      &#xA; [8] digest_0.6.27   rlang_0.4.7     evaluate_0.14  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5369" LastEditorUserId="36" LastEditDate="2021-04-21T12:50:28.183" LastActivityDate="2021-04-21T12:50:28.183" Title="Problems with reading CPLEX LP models from file in R by package 'lpSolveAPI'" Tags="|cplex|r|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6125" PostTypeId="2" ParentId="6117" CreationDate="2021-04-20T11:53:00.147" Score="6" Body="&lt;p&gt;I actually have quite a few points. As usual, things are not as clear cut.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I use advanced bases for LPs very often and they are surprisingly effective and tolerant of quite a few changes in the model.&lt;/li&gt;&#xA;&lt;li&gt;For large problems, often a good strategy is to use the barrier method for the first problem (solved from scratch) and the simplex for subsequent related solves (solved with an advanced basis). For NLPs this is similar: interior point for the first problem and active-set algorithms for subsequent solves.&lt;/li&gt;&#xA;&lt;li&gt;Your problem seems small so likely not much of an issue. Maybe your real problems are larger.&lt;/li&gt;&#xA;&lt;li&gt;Note that an advanced basis usually means: no presolve. That may be a downside. Solvers typically don't use a basis-preserving presolve algorithm. So you have to choose: using an advanced basis or doing a presolve. Sometimes there are ways to use an advanced basis on the presolved problem (too esoteric for me, so I have no experience with that).&lt;/li&gt;&#xA;&lt;li&gt;I always try these things out. Much better than guessing. My guesses are about 50% wrong, so I don't really trust them.&lt;/li&gt;&#xA;&lt;li&gt;For performance you may want to look into more specialized algorithms for transportation problems. Maybe a network algorithm, or something like an auction algorithm.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2021-04-20T12:16:11.803" LastActivityDate="2021-04-20T12:16:11.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6126" PostTypeId="2" ParentId="6124" CreationDate="2021-04-20T15:59:55.140" Score="3" Body="&lt;p&gt;The first issue is that &amp;quot;LP&amp;quot; format means different things to lpsolve and CPLEX. See the warning about that near the top of the &lt;a href=&quot;http://lpsolve.sourceforge.net/5.1/lp-format.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;lpsolve page&lt;/a&gt; describing their format. There are &lt;a href=&quot;http://lpsolve.sourceforge.net/5.1/XLI.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;converters available&lt;/a&gt;, but I don't know if there are any packaged for R. So you may need to install one and then convert the CPLEX .lp file to lpsolve format outside of R (or by making a system call from R).&lt;/p&gt;&#xA;&lt;p&gt;A second issue is that lpsolve (or the lpsolveAPI package) is rather sensitive to white space. I tried copying a couple of examples from the lpsolve web pages, pasting them into text files, and then reading those text files into R. Something as trivial as an end-of-line character at the end of the last line of text (creating an empty final line) would trigger an error message. So good luck with that.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-04-20T15:59:55.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6127" PostTypeId="1" AcceptedAnswerId="6128" CreationDate="2021-04-21T07:01:38.923" Score="5" ViewCount="250" Body="&lt;p&gt;I would like to know how to define a constraint to set a limit for switching to 0 for a decision variable? So I have a linear variable &lt;span class=&quot;math-container&quot;&gt;$x(t)$&lt;/span&gt; which quantifies the modulation degree of a heating device. It can be between &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; (meaning that the device is switched off) and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; (meaning that the device is heating with full power). My &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is between &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$288$&lt;/span&gt; (timeslots for every &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; minutes of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; day). As you can imagine it is not really good to change frequently between &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and a non-zero value because this would mean, that the heating device starts and stopps frequently during one day (sometime I have &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; starts and stopps during &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; hour) which should be avoided as it increases the wear of the device.&lt;/p&gt;&#xA;&lt;p&gt;So I would like to set a limit to switching to 0 during one day. Is there a way how I could define a constraint for that? The rule in pseudocode is basically&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if x(t-1)&amp;gt;0 and x(t)=0 then increase count by 1&#xA;Constraint: count &amp;lt;= limit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Do you have an idea how I could model that (if it is possible)? I'd appreciate every comment and would be thankful for your help.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="2556" LastEditDate="2021-04-21T07:39:01.483" LastActivityDate="2021-04-21T10:34:45.737" Title="How to set a limit for a switch to 0 of a variable" Tags="|modeling|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6128" PostTypeId="2" ParentId="6127" CreationDate="2021-04-21T07:37:43.293" Score="5" Body="&lt;p&gt;You can model this as follows. Let &lt;span class=&quot;math-container&quot;&gt;$y(t)\in \{0,1\}$&lt;/span&gt; be a binary variable that is activated if the heating device is switched off at time &lt;span class=&quot;math-container&quot;&gt;$t\in \{1,...,288\}$&lt;/span&gt; (and was active at time &lt;span class=&quot;math-container&quot;&gt;$t-1$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;This variable is activated every time &lt;span class=&quot;math-container&quot;&gt;$x(t-1)=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x(t)=0$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x(t-1) \le x(t) + y(t)\quad \forall t=1,...,288&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So if &lt;span class=&quot;math-container&quot;&gt;$x(t-1)=1$&lt;/span&gt;, either &lt;span class=&quot;math-container&quot;&gt;$x(t)$&lt;/span&gt; also takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; (and the device remains active), either &lt;span class=&quot;math-container&quot;&gt;$y(t)$&lt;/span&gt; is activated.&lt;/p&gt;&#xA;&lt;p&gt;You might want to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{t=1}^{288}y(t)$&lt;/span&gt; so that &lt;span class=&quot;math-container&quot;&gt;$y(t)$&lt;/span&gt; is never activated &amp;quot;for free&amp;quot;. Or you could also enforce this with additional constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y(t)\le x(t-1) \quad \forall t=1,...,288\\&#xA;x(t)+y(t) \le 1 \quad \forall t=1,...,288&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And you can limit the number of activated variables to an upper bound &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; (or equivalently, the number of times the device is switched off):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{t=1}^{288}y(t) \le \ell&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is continuous, you need to create a binary variable &lt;span class=&quot;math-container&quot;&gt;$b(t)$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$x(t)&amp;gt;0$&lt;/span&gt;. You can do this with the following constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x(t)\le b(t)\quad \forall t&#xA;$$&lt;/span&gt;&#xA;And in the above approach, replace &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-04-21T10:34:45.737" LastActivityDate="2021-04-21T10:34:45.737" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="6129" PostTypeId="2" ParentId="6122" CreationDate="2021-04-21T09:07:33.490" Score="2" Body="&lt;p&gt;I don't know your entire code or the errors you get, but&#xA;the general way is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;optimal_values = [value(model.x[key]) for key in model.x]&#xA;df = pd.DataFrame(optimal_values)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;is your target variable that is optimized.&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2021-04-21T18:42:25.047" LastActivityDate="2021-04-21T18:42:25.047" CommentCount="17" ContentLicense="CC BY-SA 4.0" />
  <row Id="6130" PostTypeId="2" ParentId="6116" CreationDate="2021-04-21T09:26:08.833" Score="2" Body="&lt;p&gt;It's definitely the same idea. You can look at dynamic programming as developing a program to deal with large combinatorial problems, where brute force just isn't efficient. It comes down to finding a program that runs in polynomial time. And just like we like efficient solutions in OR, it's crucial to write efficient code when you are developing mathematical programs. Nowadays, all these solvers do everything so quickly, that you probably end up working with these packages, rather than developing them yourselves.&lt;/p&gt;&#xA;&lt;p&gt;You said you wanted to learn the subject and despite the above statement, I do reckon it is really useful to learn it, as it as a very useful way of thinking about problems, especially in OR. But then I would definitely start with learning it via OR-books.&lt;/p&gt;&#xA;&lt;p&gt;A good example from the OR-side, is the n-period economic lot sizing problem. Wagner and Whitin proposed a dynamic program that runs in &lt;span class=&quot;math-container&quot;&gt;$O(n^2)$&lt;/span&gt; time, where Wagelmans, Hoesel and Kolen proposed an algorithm that runs in &lt;span class=&quot;math-container&quot;&gt;$O(n \log n)$&lt;/span&gt; time and even in &lt;span class=&quot;math-container&quot;&gt;$O(n)$&lt;/span&gt; time for the special case where holding costs are equal and nonnegative for every period.&lt;/p&gt;&#xA;&lt;p&gt;This is a real nice start if you want to learn to think in terms of dynamic programming (you need to learn how to break up complex problems into small subsets of simpler problems and then combining them). For me personally, it really comes down to learn to think in a different way. When you can do that, you can tackle many other problems that suffer from exploding solution spaces (and there are a lot of them in OR!).&lt;/p&gt;&#xA;&lt;p&gt;ps: the link to the Wagelmans paper (very interesting!)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.researchgate.net/publication/46431739_Economic_Lot_Sizing_An_On_log_n_Algorithm_That_Runs_in_Linear_Time_in_the_Wagner-Whitin_Case&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.researchgate.net/publication/46431739_Economic_Lot_Sizing_An_On_log_n_Algorithm_That_Runs_in_Linear_Time_in_the_Wagner-Whitin_Case&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="123" LastEditDate="2021-04-21T09:53:23.663" LastActivityDate="2021-04-21T09:53:23.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6131" PostTypeId="1" CreationDate="2021-04-21T09:55:28.320" Score="1" ViewCount="264" Body="&lt;p&gt;In the example files of GLPK, the assignment problem is written as a linear program. I don't understand why this isn't an integer programming problem. The problem formulation:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;minimize obj: sum{i in I, j in J} c[i,j] * x[i,j];&#xA;/* the objective is to find a cheapest assignment */&#xA;&#xA;s.t. phi{i in I}: sum{j in J} x[i,j] &amp;lt;= 1;&#xA;/* each agent can perform at most one task */&#xA;&#xA;s.t. psi{j in J}: sum{i in I} x[i,j] = 1;&#xA;/* each task must be assigned exactly to one agent */&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The relevant line is here:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var x{i in I, j in J}, &amp;gt;= 0;&#xA;/* x[i,j] = 1 means task j is assigned to agent i&#xA;   note that variables x[i,j] are binary, however, there is no need to&#xA;   declare them so due to the totally unimodular constraint matrix */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I invoke the solver it says that the LP solver was used.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;glpsol --math assign.mod &#xA;...&#xA;OPTIMAL LP SOLUTION FOUND&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The way I understand the comment is that the author of this problem says that the constraint matrix is unimodular, and hence the variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; will be automatically binary. Therefore we can use an LP solver instead of an IP solver. The cost matrix are positive integers, in case this is relevant:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;param c : 1  2  3  4  5  6  7  8 :=&#xA;      1  13 21 20 12  8 26 22 11&#xA;      2  12 36 25 41 40 11  4  8&#xA;      3  35 32 13 36 26 21 13 37&#xA;      4  34 54  7  8 12 22 11 40&#xA;      5  21  6 45 18 24 34 12 48&#xA;      6  42 19 39 15 14 16 28 46&#xA;      7  16 34 38  3 34 40 22 24&#xA;      8  26 20  5 17 45 31 37 43 ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What does it mean that the constraint matrix is unimodular, and why does this imply that the solution is binary? I understand the reasoning that &lt;span class=&quot;math-container&quot;&gt;$0 \leq x_{ij} \leq 1$&lt;/span&gt;, but why isn't &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; real?&lt;/p&gt;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;&lt;p&gt;the full file can be found here: &lt;a href=&quot;https://ftp.gnu.org/gnu/glpk/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ftp.gnu.org/gnu/glpk/&lt;/a&gt; by downloading glpk-5.0 and looking into &lt;code&gt;examples/assign.mod&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3575" LastActivityDate="2021-04-21T09:55:28.320" Title="LP instead of IP formulation of assignment problem" Tags="|linear-programming|assignment-problem|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6132" PostTypeId="1" AcceptedAnswerId="6133" CreationDate="2021-04-21T19:04:11.523" Score="6" ViewCount="215" Body="&lt;p&gt;A model contains constraints of the following form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$R(k) \leq X(k) G(k)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$X(k)$&lt;/span&gt; binary and &lt;span class=&quot;math-container&quot;&gt;$G(k)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$R(k)$&lt;/span&gt; non-negative variables.&lt;/p&gt;&#xA;&lt;p&gt;The index &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; runs from &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I linearise the equations as they are products of binary and  continuous variables.&lt;/p&gt;&#xA;&lt;p&gt;The question is, is there anything I can exploit to tighten the region these constraints define?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="500" LastEditDate="2021-04-21T21:25:18.523" LastActivityDate="2021-04-21T21:25:18.523" Title="How to treat a system of bilinear constraints" Tags="|mixed-integer-programming|linearization|reformulation-linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6133" PostTypeId="2" ParentId="6132" CreationDate="2021-04-21T21:19:48.620" Score="7" Body="&lt;p&gt;You want to enforce &lt;span class=&quot;math-container&quot;&gt;$X(k) = 0 \implies R(k) = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X(k) = 1 \implies R(k) \le G(k)$&lt;/span&gt;.  You can use indicator constraints for that.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, a straightforward big-M formulation yields&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;R(k) &amp;amp;\le M_1(k) X(k) \tag1 \\&#xA;R(k) - G(k) &amp;amp;\le M_2(k) (1 - X(k)) \tag2 \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A natural choice for &lt;span class=&quot;math-container&quot;&gt;$M_1(k)$&lt;/span&gt; is a small constant upper bound &lt;span class=&quot;math-container&quot;&gt;$\bar{G}(k)$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$G(k)$&lt;/span&gt;, and a natural choice for &lt;span class=&quot;math-container&quot;&gt;$M_2(k)$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$\bar{G}(k) - 0$&lt;/span&gt;.  But notice that you can do better because &lt;span class=&quot;math-container&quot;&gt;$M_2(k)$&lt;/span&gt; needs to be an upper bound on &lt;span class=&quot;math-container&quot;&gt;$R(k)-G(k)$&lt;/span&gt; only when &lt;span class=&quot;math-container&quot;&gt;$X(k)=0$&lt;/span&gt;; in that case, &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; forces &lt;span class=&quot;math-container&quot;&gt;$R(k)=0$&lt;/span&gt;, so you can take &lt;span class=&quot;math-container&quot;&gt;$M_2(k)=0$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;R(k) &amp;amp;\le \bar{G}(k) X(k) \tag1 \\&#xA;R(k) &amp;amp;\le G(k) \tag2 \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Depending on other constraints in your model, you might be able to tighten further.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-04-21T21:19:48.620" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6135" PostTypeId="1" AcceptedAnswerId="6137" CreationDate="2021-04-22T15:48:18.177" Score="7" ViewCount="619" Body="&lt;p&gt;Finding a maximum matching, or a maximum-weight matching, is a well-known problem, which has polynomial-time combinatorial algorithms.&#xA;It can also be formulated as an integer linear program.&#xA;In general, an integer linear program might require exponential time. However, the particular ILP corresponding to a maximum matching problem can be solved in polynomial time.&lt;/p&gt;&#xA;&lt;p&gt;My question is: are there generic ILP solvers that can identify this special structure, and solve matching-related ILPs as fast as solvers that are specially written for matching (e.g. the ones in the Python &lt;code&gt;networkx&lt;/code&gt; library)?&lt;/p&gt;&#xA;&lt;p&gt;The motivation for this question is that having a general ILP formulation allows us to easily add problem-specific constraints and modifications. For example, it is easy to solve one-to-many matching, or add other kinds of constraints, that are less easy to do with a specialized graph-matching solver. So the question is: how much do we &amp;quot;pay&amp;quot; for the added generality, in terms of run-time?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2021-04-22T17:29:07.327" Title="Can a generic ILP solver find graph matchings as fast as a specialized algorithm?" Tags="|integer-programming|solver|graphs|computational-complexity|matching|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6136" PostTypeId="2" ParentId="6135" CreationDate="2021-04-22T16:23:53.470" Score="8" Body="&lt;p&gt;In general ILP solvers are not as efficient in solving the Maximum Matching problem. A comparison of efficient matching algorithm implementations, as well as an ILP formulation for the Maximum Cardinality Matching Problem and the Minimum Weight perfect matching problem can be found in Figures 5 and 6 of this paper:&lt;/p&gt;&#xA;&lt;p&gt;Dimitrios Michail, Joris Kinable, Barak Naveh, and John V. Sichi. 2020. JGraphT—A Java Library for Graph Data Structures and Algorithms. ACM Trans. Math. Softw. 46, 2, Article 16 (June 2020). DOI:&lt;a href=&quot;https://doi.org/10.1145/3381449&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1145/3381449&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The ILP model is one or two orders of magnitude slower than the dedicated algorithmic implementations.&lt;/p&gt;&#xA;&lt;p&gt;Implementing Matching algorithms for general graphs is actually hard and very labor intensive (that's why only a few graph libraries have implementations for these problems). Modifying an existing implementation to include a side constraint could be even harder. My recommendation is to use a dedicated implementation when possible, and to try an ILP formulation if you need side constraints. Implementing the ILP formulation is typically very easy for matchings and the ILP's performance is often adequate for most applications.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2021-04-22T16:51:37.117" LastActivityDate="2021-04-22T16:51:37.117" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6137" PostTypeId="2" ParentId="6135" CreationDate="2021-04-22T17:29:07.327" Score="10" Body="&lt;p&gt;This is where decomposition algorithms (specifically Dantzig-Wolfe can be quite useful).&lt;/p&gt;&#xA;&lt;p&gt;My thesis work and subsequent OSS in COIN provides APIs to do this kind of thing:&#xA;&lt;a href=&quot;https://projects.coin-or.org/Dip&quot; rel=&quot;noreferrer&quot;&gt;https://projects.coin-or.org/Dip&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The basic idea is that the oracle is the graph implementation while the side constraints are modeled as the master constraints in the decomposition reformulation.&lt;/p&gt;&#xA;" OwnerUserId="587" LastActivityDate="2021-04-22T17:29:07.327" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6138" PostTypeId="1" AcceptedAnswerId="6146" CreationDate="2021-04-22T20:38:10.573" Score="3" ViewCount="161" Body="&lt;p&gt;I wanna learn how to solve non-linear programs using the docplex library. according to this &lt;a href=&quot;https://ibmdecisionoptimization.github.io/tutorials/html/Beyond_Linear_Programming.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;&#xA;I should be able to run the model as a QP. But when running the model I got the error: &lt;code&gt;DOcplexException: Model&amp;lt;portfolio_miqp&amp;gt; has not been solved yet&lt;/code&gt;. So I'm wondering if it is because of some theory that I'm not aware of (I'm just starting to study optimization) or if it is because I'm making a syntax error. Below the problem I'm trying to solve:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A retailer buys an item from a supplier for &lt;span class=&quot;math-container&quot;&gt;$c=\\\$500$&lt;/span&gt; and sells it to its customers for &lt;span class=&quot;math-container&quot;&gt;$p=\\\$700$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The retailer experiences a constant daily demand of &lt;span class=&quot;math-container&quot;&gt;$d=20$&lt;/span&gt; units per day for the item.&lt;/li&gt;&#xA;&lt;li&gt;If the retailers spend &lt;span class=&quot;math-container&quot;&gt;$\\\$x$&lt;/span&gt; dollars on advertisement daily, it will increase daily demand by &lt;span class=&quot;math-container&quot;&gt;$\sqrt{x}/10$&lt;/span&gt; units.&lt;/li&gt;&#xA;&lt;li&gt;Lead time for procuring the item from the supplier is two days.&lt;/li&gt;&#xA;&lt;li&gt;There is a fixed cost of &lt;span class=&quot;math-container&quot;&gt;$f=\\\$2,000$&lt;/span&gt; for placing an order. This cost does not depend on the number of units ordered.&lt;/li&gt;&#xA;&lt;li&gt;There is a variable cost of &lt;span class=&quot;math-container&quot;&gt;$h=\\\$5$&lt;/span&gt; per day associated with holding an item in the retailer’s inventory.&lt;/li&gt;&#xA;&lt;li&gt;Customers' demands must be met without backorders.&lt;/li&gt;&#xA;&lt;li&gt;The retailer wishes to maximize profit.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;Assumptions&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Lead time can be assumed to be zero.&lt;/li&gt;&#xA;&lt;li&gt;Retailer orders only when inventory drops to zero.&lt;/li&gt;&#xA;&lt;li&gt;The optimal order quantity does not change with time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;Variables&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Optimum quantity of items to order &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Period between order (days) &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Advertisement investment &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;Constraints&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Demand must be equal to the order &lt;span class=&quot;math-container&quot;&gt;$(d+\alpha{(x)})T=Q$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;Objective&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Maximize profits: &lt;span class=&quot;math-container&quot;&gt;$(p-c)(d+\alpha{(x)})-\frac{hQ}{2}-\frac{f}{T}-x$&lt;/span&gt;&#xA;Then the algebraic model can be written as follows:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;The Algebraic Model&#xA;&lt;p&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\text{Maximize:} \quad &amp;amp;  \; (p-c)(d+\alpha{(x)})-\frac{hQ}{2}-\frac{f}{T}-x \\&#xA;\text{Subject to:} \quad &amp;amp;  (d+\alpha{(x)})T=Q\\&#xA;\quad &amp;amp; Q &amp;gt;0\\&#xA;\quad &amp;amp; x\geq 0&#xA;\end{aligned}&lt;/span&gt;&#xA;Note that the objective function was derivate from the problem. I didn't include how the objective function was developed. Because I'm extracting the problem from an example solved in class which was solved using the GRG Nonlinear method that comes with the solver extension in excel.&lt;/p&gt;&#xA;&lt;p&gt;The code I'm running is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;import math&#xA;&#xA;&#xA;mdl = Model(name='portfolio_miqp')&#xA;&#xA;Q = mdl.continuous_var(name='Quantity of Items')&#xA;T = mdl.continuous_var(name='Period in days')&#xA;x = mdl.continuous_var(name='Advertisement per day')&#xA;&#xA;alpha = 0.1&#xA;c = 500&#xA;p = 700 &#xA;d = 20 &#xA;f = 2000&#xA;h = 5&#xA;&#xA;mdl.add_constraint((d + alpha*math.sqrt(x))*T == Q)&#xA;&#xA;profit =  (p-c)*(d + alpha*math.sqrt(x)) - (h*Q)/2 - f/T-x&#xA;&#xA;mdl.maximize(profit)&#xA;mdl.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4416" LastEditorUserId="4416" LastEditDate="2021-04-23T15:10:30.527" LastActivityDate="2021-04-23T15:10:30.527" Title="Implementing NLP as QP on docplex" Tags="|quadratic-programming|cplex-python-api|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6139" PostTypeId="2" ParentId="6138" CreationDate="2021-04-22T21:06:27.003" Score="3" Body="&lt;p&gt;The error message suggests that you tried to access the solution before solving the model. At the point that mdl.maximize(profit) is executed, you have constructed your model, but you have not solved it. Trying invoking mdl.solve() next.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-04-22T21:06:27.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6140" PostTypeId="1" CreationDate="2021-04-23T01:07:06.567" Score="3" ViewCount="106" Body="&lt;p&gt;I have a task scheduling/assignment on machines problem (like a classic bin packing problem) with a twist in which the placement/assignment of one task affects the placement/assignment of other tasks (their placement needs to be jointly considered). I am trying to concurrently schedule the tasks and jointly consider their dependencies which can be expressed as a DAG. I have expressed the assignment problem as a MILP which is actually realized as a MIQCP in an effort to express the relations between the placements of different tasks through the constraints and minimize the number of decision variables.&lt;/p&gt;&#xA;&lt;p&gt;However, the execution time of the optimization (CPLEX implementation) is significant, even for a really small unrealistic problem size, spanning from tens of seconds to a minute when I would ideally like to be subsecond. Two option that I am aware of is to perform the linearization of the problem, by moving from the discrete to the continuous representation, or increase the number of variables and eliminate the quadratic terms. Since this is an already proven hard problem, solving the entire MILP in practice is usually not scalable. Approaches in the past have mapped the scheduling problem into a network flow problem where a &lt;em&gt;MinCost-MaxFlow&lt;/em&gt; heuristic algorithm is used to find the assignments (references: &lt;a href=&quot;https://www.microsoft.com/en-us/research/wp-content/uploads/2009/10/isard-sosp09.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;[1]&lt;/a&gt;, &lt;a href=&quot;https://www.cl.cam.ac.uk/research/srg/netos/camsas/pubs/osdi16-firmament.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;[2]&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Instead of solving the entire MILP, the problem mapping to a network flow representation provides a heuristic &lt;em&gt;greedy&lt;/em&gt; way to approach the assignment problem with the optimization objectives which performs much better in practice since it exploits graph properties and greedily solves the problem.  However, trying to express the correlation between different tasks through the network flow representation for their concurrent scheduling and consideration, makes the option seem unfeasible. So my question is either if there is a way to track dependencies between tasks through a flow network joint scheduling approach or if any other approach exists that might map to the problem case and can meet the performance requirements of a heuristic approach.&lt;/p&gt;&#xA;" OwnerUserId="5383" LastEditorUserId="491" LastEditDate="2021-04-23T15:47:24.243" LastActivityDate="2021-04-23T18:43:28.840" Title="Relationship aware task scheduling heuristics" Tags="|optimization|scheduling|heuristics|assignment-problem|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6141" PostTypeId="2" ParentId="6140" CreationDate="2021-04-23T06:28:51.517" Score="1" Body="&lt;p&gt;since you deal with a scheduling problem I encourage you to have a look at &lt;a href=&quot;https://cp2019.a4cp.org/PDFs/P-Laborie.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPOptimizer&lt;/a&gt; scheduling within CPLEX.&lt;/p&gt;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://stackoverflow.com/questions/49405659/mip-vs-cp-for-scheduling-problems&quot;&gt;https://stackoverflow.com/questions/49405659/mip-vs-cp-for-scheduling-problems&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-04-23T06:28:51.517" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6142" PostTypeId="1" AcceptedAnswerId="6144" CreationDate="2021-04-23T11:34:37.673" Score="2" ViewCount="47" Body="&lt;p&gt;I would like to write the following constraint, where &lt;span class=&quot;math-container&quot;&gt;$varBuyWater$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$varSellWater$&lt;/span&gt; are decision variables on how much water to buy and to sell. However, I do not want the solver to buy and sell water at the same time, because that makes no sense.&lt;/p&gt;&#xA;&lt;p&gt;How do I force to solver to have &lt;strong&gt;either&lt;/strong&gt; one of them, i.e. if &lt;span class=&quot;math-container&quot;&gt;$varBuyWater &amp;gt; 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$varSellWater = 0$&lt;/span&gt; and the other way around. Is there a way to do this&amp;gt;&lt;/p&gt;&#xA;" OwnerUserId="563" LastActivityDate="2021-04-23T12:15:05.447" Title="How to write the following constraint?" Tags="|constraint|logical-constraints|" AnswerCount="1" CommentCount="1" ClosedDate="2021-04-23T15:58:34.037" ContentLicense="CC BY-SA 4.0" />
  <row Id="6143" PostTypeId="1" CreationDate="2021-04-23T11:51:06.850" Score="3" ViewCount="451" Body="&lt;p&gt;I would like to seek some advice on modeling the following:&lt;/p&gt;&#xA;&lt;p&gt;I am currently using Pyomo to generate my MILP model in Pyomo. It seems that it is not possible to cast the integer and binary variables to continuous variables for solving the model as a linear program for obtaining its linear relaxation.&lt;/p&gt;&#xA;&lt;p&gt;Short of creating a similar model for linear relaxation due to model loading and solution time constraints, I would like to ask if there is any way to invoke the solver from Pyomo to solve the said model as a Linear Program?&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="491" LastEditDate="2021-05-20T14:57:02.907" LastActivityDate="2021-05-20T14:57:02.907" Title="Obtaining linear relaxation objective value from MILP model coded in Pyomo" Tags="|mixed-integer-programming|modeling|cplex|pyomo|lp-relaxation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6144" PostTypeId="2" ParentId="6142" CreationDate="2021-04-23T12:15:05.447" Score="6" Body="&lt;p&gt;You need to introduce a binary variable for buying, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, and one for selling, &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Make sure &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; are active when &lt;span class=&quot;math-container&quot;&gt;$varBuyWater$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$varSellWater$&lt;/span&gt; are positive, respectively:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;varBuyWater \le M_1 b \\&#xA;varSellWater \le M_2 s \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_2$&lt;/span&gt; are upper bounds on variables  &lt;span class=&quot;math-container&quot;&gt;$varBuyWater$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$varSellWater$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And impose that both binaries cannot take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; simultaneously:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;b+s \le 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2021-04-23T12:15:05.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6145" PostTypeId="2" ParentId="6143" CreationDate="2021-04-23T12:22:22.153" Score="2" Body="&lt;p&gt;Can't you add a parameter to your model which defines the nature of your variables ?&lt;/p&gt;&#xA;&lt;p&gt;Something like :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def my_model(model, continuous):&#xA;&#xA;   ...&#xA;&#xA;   if continuous:&#xA;      model.my_variable = Var(within=NonNegativeReals)&#xA;   else:&#xA;      model.my_variable = Var(within=PositiveIntegers)&#xA;&#xA;   ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and then &lt;code&gt;model.solve()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I am not so familiar with Pyomo but with &lt;a href=&quot;https://coin-or.github.io/pulp/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;PuLP&lt;/a&gt;, depending on the solver that you are using, &lt;a href=&quot;https://coin-or.github.io/pulp/technical/solvers.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;you can add a parameter &lt;code&gt;mip=True/False&lt;/code&gt;&lt;/a&gt; which should do the trick. Perhaps it is possible to do the same with Pyomo ? In this case you wouldn't have to rebuild the model.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-04-23T12:43:12.017" LastActivityDate="2021-04-23T12:43:12.017" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="6146" PostTypeId="2" ParentId="6138" CreationDate="2021-04-23T12:52:20.560" Score="4" Body="&lt;p&gt;Within docplex I would use cpoptimizer and write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mdl = CpoModel(name='portfolio_miqp')&#xA;&#xA;scale=10000&#xA;&#xA;scaleQ = mdl.integer_var(0,200*scale,name='scaleQuantity of Items')&#xA;scaleT = mdl.integer_var(0,100*scale,name='scalePeriod in days')&#xA;scalex = mdl.integer_var(0,100*scale,name='scaleAdvertisement per day')&#xA;&#xA;Q=scaleQ/scale&#xA;T=scaleT/scale&#xA;x=scalex/scale&#xA;&#xA;alpha = 0.1&#xA;c = 500&#xA;p = 700 &#xA;d = 20 &#xA;f = 2000&#xA;h = 5&#xA;&#xA;mdl.add_constraint((d + alpha*mdl.power(x,0.5))*T == Q)&#xA;&#xA;profit =  (p-c)*(d + alpha*mdl.power(x,0.5)) - (h*Q)/2 - f/T-x&#xA;&#xA;mdl.maximize(profit)&#xA;&#xA;msol=mdl.solve()&#xA;&#xA;print(&amp;quot;Q=&amp;quot;,msol[scaleQ]/scale)&#xA;print(&amp;quot;T=&amp;quot;,msol[scaleT]/scale)&#xA;print(&amp;quot;x=&amp;quot;,msol[scalex]/scale)&#xA;print(&amp;quot;profit :&amp;quot;,msol.get_objective_values()[0])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Q= 127.1403&#xA;T= 6.076&#xA;x= 85.5625&#xA;profit : (3452.42, 3452.42)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-04-23T12:52:20.560" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6147" PostTypeId="1" AcceptedAnswerId="6148" CreationDate="2021-04-23T13:32:31.957" Score="2" ViewCount="177" Body="&lt;p&gt;Suppose, we want to locate some given facilities &lt;span class=&quot;math-container&quot;&gt;$\left \{ (i,j) \ |\  (i,j) \in \text[{1,\cdots, N}]\right \}$&lt;/span&gt; in a specific area. Each facility has a predefined dimension with a length &lt;span class=&quot;math-container&quot;&gt;$l_{i}$&lt;/span&gt; and width &lt;span class=&quot;math-container&quot;&gt;$w_{i}$&lt;/span&gt;, (they are not necessarily square). The overall dimensions of the area are &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt;. The objective is to find the best fit shape of the facilities in the area. As far as I know, this problem can be formulated as mixed-integer programming by defining the non-overlap constraints as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} &amp;amp;x_i+w_i \le x_j  &amp;amp; \text{or} \\ &amp;amp;x_j+w_j \le x_i  &amp;amp; \text{or} \\ &amp;amp;y_i+h_i \le y_j  &amp;amp; \text{or} \\ &amp;amp;y_j+h_j \le y_i  \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;or other formulations like &lt;span class=&quot;math-container&quot;&gt;$\text{ABS}$&lt;/span&gt; models in the facility location literature.&lt;/p&gt;&#xA;&lt;p&gt;The important thing is that to achieve a good feasible solution by the above-mentioned formulations, we should define the facility shape in the fixed orientation as prior, for example horizontal. What I am interested to know is about the orientation of the facility shape and rotation of them by formulation. I was wondering if, how we can change the above formulation to capture the rotation of the facility shape automatically by using mixed-integer programming?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-04-23T14:13:19.770" Title="How to interpret no-overlap constraints with rotation as a mixed integer programming" Tags="|optimization|mixed-integer-programming|facility-location|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6148" PostTypeId="2" ParentId="6147" CreationDate="2021-04-23T14:13:19.770" Score="3" Body="&lt;p&gt;It sounds like you want to pack &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; rectangles with given dimensions &lt;span class=&quot;math-container&quot;&gt;$w_i \times h_i$&lt;/span&gt; in a &lt;span class=&quot;math-container&quot;&gt;$W \times H$&lt;/span&gt; rectangle, as discussed &lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2017/07/rectangles-no-overlap-constraints.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.  To allow each rectangle to be rotated 90 degrees (with dimensions &lt;span class=&quot;math-container&quot;&gt;$h_i \times w_i$&lt;/span&gt;), you can introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; to indicate whether to rotate rectangle &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; or not.  Then modify the constraints like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} &amp;amp;x_i+w_i(1-r_i)+h_i r_i \le x_j  &amp;amp; \text{or} \\ &amp;amp;x_j+w_j(1-r_j)+h_j r_j \le x_i  &amp;amp; \text{or} \\ &amp;amp;y_i+h_i(1-r_i)+w_i r_i \le y_j  &amp;amp; \text{or} \\ &amp;amp;y_j+h_j(1-r_j)+w_j r_j \le y_i  \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-04-23T14:13:19.770" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6149" PostTypeId="1" AcceptedAnswerId="6151" CreationDate="2021-04-23T17:41:33.187" Score="3" ViewCount="322" Body="&lt;p&gt;I am trying to develop a model, solving an optimization problem which has the following objective function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;variable p(i);&#xA;minimize sum(cost)&#xA;subject to&#xA;p&amp;gt;=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where cost is defined as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cost(i) = 0, if p(i) = 0,&#xA;cost(i) = 10*p + 23.6, if 0&amp;lt;p(i)&amp;lt;= 5, &#xA;cost(i) = 15*p + 45.4, if 5&amp;lt;p(i)&amp;lt;=10, &#xA;cost(i) = 20*p*p - 10*p + 375, if p(i) &amp;gt; 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that the problem is discontinuous, which means the functions do not match at the breakpoints. As if statement is not allowed to be used in cvx, I think that declaring binary variables as indicators might work, like using the constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$p(i) - 5 + My &amp;gt;0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;so that &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; will be forced to be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$p(i) \le 5$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&#xA;Yet, I still have no idea how to deal with the segment like &lt;span class=&quot;math-container&quot;&gt;$5&amp;lt;p(i)\le10$&lt;/span&gt; by indicator variables.&lt;/p&gt;&#xA;&lt;p&gt;Could anyone help me on this formulation?&lt;/p&gt;&#xA;" OwnerUserId="5388" LastEditorUserId="5388" LastEditDate="2021-04-23T18:25:38.793" LastActivityDate="2021-04-23T18:51:52.860" Title="How to reformulate a discontinuous piecewise-quadratic functions" Tags="|optimization|mixed-integer-programming|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6150" PostTypeId="2" ParentId="6149" CreationDate="2021-04-23T18:22:30.533" Score="2" Body="&lt;p&gt;If the constants are such that the cost function is convex (e.g., &lt;span class=&quot;math-container&quot;&gt;$b=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c=-25$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d=-1775$&lt;/span&gt;), you could minimize a variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z &amp;amp;\ge 10p + b \\&#xA;z &amp;amp;\ge 15p+c \\&#xA;z &amp;amp;\ge 20p^2 -10p +d \\&#xA;z &amp;amp;\ge 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With the above values, the cost function is the maximum of the curves in the figure below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gLIJx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gLIJx.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;EDIT:&#xA;With the constants given by OP after editing his post, the cost function turns out to not be convex, so this does not apply.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-04-23T18:35:36.353" LastActivityDate="2021-04-23T18:35:36.353" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6151" PostTypeId="2" ParentId="6149" CreationDate="2021-04-23T18:24:31.963" Score="5" Body="&lt;p&gt;Although focused on implementing the model in YALMIP instead of CVX (converting the code should be trivial), precisely this case is described in the following tutorial &lt;a href=&quot;https://yalmip.github.io/modellingif&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://yalmip.github.io/modellingif&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You basically introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta_i$&lt;/span&gt; for each region, and then add the implications that &lt;span class=&quot;math-container&quot;&gt;$\delta_i \rightarrow \{\text{cost} = f_i(x), x \in \text{region}_i\}$&lt;/span&gt; and model these using standard big-M.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$-M(1-\delta_i)\leq  \text{cost}-f_i(x) \leq M(1-\delta_i),\\~-M(1-\delta_i)+ x_i^L\leq x\leq x_{i}^U + M(1-\delta_i)\\\sum_i \delta_i=1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(The term with the quadratic cost is actually treated slightly differently to avoid adding nonconvex quadratics, discussed in tutorial)&lt;/p&gt;&#xA;&lt;p&gt;If the cost is convex, it can be done more efficiently without any binary variables.&lt;/p&gt;&#xA;&lt;p&gt;The discontinuity at zero is essentially impossible to capture with a numerical solver. You can of course add a region for it to allow the cost to become &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, but you must understand that a solver can have for instance &lt;span class=&quot;math-container&quot;&gt;$x = 10^{-8}$&lt;/span&gt; but still declare that you are in the zero cost region.&lt;/p&gt;&#xA;" OwnerUserId="487" LastEditorUserId="487" LastEditDate="2021-04-23T18:51:52.860" LastActivityDate="2021-04-23T18:51:52.860" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6152" PostTypeId="2" ParentId="6140" CreationDate="2021-04-23T18:43:28.840" Score="1" Body="&lt;p&gt;Since you are open to a heuristic, I wonder if a restricted decision diagram (DD) might work for you. Decision diagrams are similar to dynamic programs in the sense that each node represents a state of the system and each arc represents a decision that results in a new state that is dependent only on the decision and the state at which it is made. The least cost solution is found by getting the shortest path from start node to end node. The &amp;quot;restricted&amp;quot; part is that, to avoid the size of the diagram blowing up, you glue certain nodes together (I'm pretty sure that's not the technical term for it) and/or omit certain nodes or arcs, effectively excluding some possible solutions (hopefully not the best ones). Finding the shortest path through the restricted decision diagram is a primal heuristic.&lt;/p&gt;&#xA;&lt;p&gt;A good starting point is Willem-Jan Van Hoeve's &lt;a href=&quot;https://www.andrew.cmu.edu/user/vanhoeve/mdd/&quot; rel=&quot;nofollow noreferrer&quot;&gt;web page&lt;/a&gt; on decision diagrams, which gives an overview of decision diagrams in optimization and lists various resources, including an excellent book of which he is co-author.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-04-23T18:43:28.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6153" PostTypeId="1" AcceptedAnswerId="6154" CreationDate="2021-04-24T09:22:16.347" Score="6" ViewCount="4067" Body="&lt;p&gt;I am trying to understand travelling salesman problem, the Dantzig, Fulkerson, Johnson(1954) formulation. In the general formulation given below I am having trouble to implement subtour elimination in a practical problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Min $$\sum\sum c_{ij}x_{ij}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s.t.\sum x_{ij}=1, j=1,...,n$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum x_{ij}=1, i=1,...,n$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\sum x_{ij}\leq|S|-1, \forall i,j,i\neq j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So I have a simple symmetric problem as the following:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{bmatrix}&#xA;0 &amp;amp; 3 &amp;amp; 1 &amp;amp; 2 &amp;amp; 4\\&#xA;3 &amp;amp; 0 &amp;amp; 3 &amp;amp; 6 &amp;amp; 7\\&#xA;1 &amp;amp; 3 &amp;amp; 0 &amp;amp; 7 &amp;amp; 4\\&#xA;2 &amp;amp; 6 &amp;amp; 7 &amp;amp; 0 &amp;amp; 1\\&#xA;4 &amp;amp; 7 &amp;amp; 4 &amp;amp; 1 &amp;amp; 0&#xA;\end{bmatrix}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have formulated as the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Min 3x_{12}+x_{13}+2x_{14}+4x_{15}+....+4x_{35}+x_{45}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s.t. x_{11}+x_{21}+...+x_{51}=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{15}+x_{25}+...+x_{55}=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{11}+x_{12}+...+x_{15}=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{51}+x_{52}+...+x_{55}=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have written until here without any problem. But for the last constraint, I couldn't understand how to write it down. How do I add the subtour elimination constraint in the formulation? The following one, to be specific:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum\sum x_{ij}\leq|S|-1, \forall i,j,i\neq j$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user5245" LastActivityDate="2022-08-04T14:27:31.627" Title="Subtour elimination constraint in Travelling Salesman Problem" Tags="|optimization|traveling-salesman|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6154" PostTypeId="2" ParentId="6153" CreationDate="2021-04-24T09:37:07.280" Score="8" Body="&lt;p&gt;I think one of the reasons you have difficulties implementing the constraint is because it is not written correctly. You need to be more precise with your indexes. If &lt;span class=&quot;math-container&quot;&gt;$N:=\{1,...,n \}$&lt;/span&gt;, you can write the constraint as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in S}\sum_{j \in S, j\neq i} x_{ij} \le |S| -1 \quad \forall S \subset N, 2 \le |S| \le n-1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This means that you have to consider all possible subsets &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;, and unfortunately there is an exponential number of them. So writing all of them is not really an option.&lt;/p&gt;&#xA;&lt;p&gt;What you can do is run the program without the constraint, check if you have a subtour, and if you do, dynamically add the cut that forbids this subtour in the following iteration. This is called a &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360025804471-What-is-the-difference-between-user-cuts-and-lazy-constraints-&quot; rel=&quot;noreferrer&quot;&gt;lazy constraint&lt;/a&gt;, check out &lt;a href=&quot;https://orinanobworld.blogspot.com/2012/08/user-cuts-versus-lazy-constraints.html&quot; rel=&quot;noreferrer&quot;&gt;Paul Rubin's article&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So for example, if you have the subtour &lt;span class=&quot;math-container&quot;&gt;$1-2-1$&lt;/span&gt; (that is, &lt;span class=&quot;math-container&quot;&gt;$S=\{1,2\}$&lt;/span&gt;), you can add the constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in \{1,2\}}\sum_{j \in  \{1,2\}, j\neq i} x_{ij} \le |S| -1&#xA;$$&lt;/span&gt;&#xA;which simplifies to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{12}+x_{21} \le 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also note that there are different versions of the subtour elimination constraint, such as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in S}\sum_{j \not \in  S} x_{ij} \ge 1 \quad \forall S \subset N, S \neq \emptyset&#xA;$$&lt;/span&gt;&#xA;In this version, the constraint imposes that you need at least one edge between two subtours. So with the same above example, you would have:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{13}+ x_{14}+ x_{15}+ x_{23}+ x_{24} + x_{25} \ge 1&#xA;$$&lt;/span&gt;&#xA;It would be interesting to see which one performs best, I have been told that the second option is better in practice, but I cannot prove it nor have the evidence to confirm it. If anyone has this information, I would love to know about it!&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-04-24T10:44:15.067" LastActivityDate="2021-04-24T10:44:15.067" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6155" PostTypeId="1" AcceptedAnswerId="6156" CreationDate="2021-04-24T13:00:00.650" Score="3" ViewCount="164" Body="&lt;p&gt;I am adding some constraints to my model described in my &lt;a href=&quot;https://or.stackexchange.com/questions/6149/how-to-reformulate-a-discontinuous-piecewise-quadratic-functions/6151#6151&quot;&gt;previous post&lt;/a&gt;, where a discontinuous piecewise-quadratic functions is the objective to be minimized in cvx.&lt;/p&gt;&#xA;&lt;p&gt;Here I have an additional terms, &lt;em&gt;sum(cost2)&lt;/em&gt;, that is included in the objective as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;variable p(N);&#xA;variable cost1(N);&#xA;variable cost2(N);&#xA;variable delta(N, 4);&#xA;variable gamma(N, 3);&#xA;expression cost1_exp(4);&#xA;expression cost2_exp(3);&#xA;minimize sum(cost1)+sum(cost2)&#xA;subject to&#xA;    p&amp;gt;=0&#xA;    for i = 1:N&#xA;        -M*(1-delta(i, 1))&amp;lt;=cost1(i)-cost1_exp(1)&amp;lt;=M*(1-delta(i, 1))&#xA;        -M*(1-delta(i, 2))&amp;lt;=cost1(i)-cost1_exp(2)&amp;lt;=M*(1-delta(i, 2))&#xA;        -M*(1-delta(i, 3))&amp;lt;=cost1(i)-cost1_exp(3)&amp;lt;=M*(1-delta(i, 3))&#xA;        -M*(1-delta(i, 4))&amp;lt;=cost1(i)-cost1_exp(4)&amp;lt;=M*(1-delta(i, 4))&#xA;        -M*(1-delta(i, 1))&amp;lt;=p(i)&amp;lt;=M*(1-delta(i, 1))&#xA;        -M*(1-delta(i, 2))&amp;lt;=p(i)&amp;lt;=5+M*(1-delta(i, 1))&#xA;        -M*(1-delta(i, 3))+5&amp;lt;=p(i)&amp;lt;=10+M*(1-delta(i, 1))&#xA;        -M*(1-delta(i, 4))+10&amp;lt;=p(i)&amp;lt;=100+M*(1-delta(i, 1))&#xA;        sum(delta(i))==1&#xA;    end&#xA;    for i = 1:N&#xA;        -M*(1-gamma(i, 1))&amp;lt;=cost2(i)-cost2_exp(1)&amp;lt;=M*(1-gamma(i, 1))&#xA;        -M*(1-gamma(i, 2))&amp;lt;=cost2(i)-abs(cost2_exp(2))&amp;lt;=M*(1-gamma(i, 2))&#xA;        -M*(1-gamma(i, 3))&amp;lt;=cost2(i)-abs(cost2_exp(3))&amp;lt;=M*(1-gamma(i, 3))&#xA;        -M*(1-gamma(i, 1))&amp;lt;=p(i)&amp;lt;=M*(1-gamma(i, 1))&#xA;        -M*(1-gamma(i, 2))&amp;lt;=p(i)&amp;lt;=0.01+M*(1-gamma(i, 1))&#xA;        -M*(1-gamma(i, 3))+0.01&amp;lt;=p(i) - 10^-6&amp;lt;=100+M*(1-gamma(i, 1))&#xA;        sum(gamma(i))==1&#xA;    end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where I add the constraints provided by @Johan to linearize my problem (I have not modified the constraints for quadratic terms) and the cost1_exp is identical as &lt;a href=&quot;https://or.stackexchange.com/questions/6149/how-to-reformulate-a-discontinuous-piecewise-quadratic-functions/6151#6151&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cost1(i) = 0, if p(i) = 0,&#xA;cost1(i) = 10*p + 23.6, if 0&amp;lt;p(i)&amp;lt;= 5, &#xA;cost1(i) = 15*p + 45.4, if 5&amp;lt;p(i)&amp;lt;=10, &#xA;cost1(i) = 20*p*p - 10*p + 375, if p(i) &amp;gt; 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, the cost function cost2_exp makes the trouble:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cost2_exp(1) = 0, if p = 0,&#xA;cost2_exp(2) = 6*(10*log10(p))^2 -10*10*log10(p), if 0&amp;lt;p&amp;lt;= 0.01, &#xA;cost2_exp(3) = 17*10*log10(p) + 42.8, if 0.01&amp;lt;p&amp;lt;=100, &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I try to add constraints as for cost1, and make similar works for cost2.&lt;/p&gt;&#xA;&lt;p&gt;However, there are still some problems: When &lt;code&gt;p(i) = 0, gamma(i, 1) = 1, gamma(i, 2) = gamma(i, 3) = 0&lt;/code&gt;, the &lt;code&gt;cost2_exp(2)&lt;/code&gt; and &lt;code&gt;cost2_exp(3)&lt;/code&gt; will force the cost to be &lt;em&gt;Inf&lt;/em&gt; and &lt;em&gt;-Inf&lt;/em&gt; respectively to satisfy the constraints, while &lt;code&gt;cost2_exp(1)&lt;/code&gt; force the cost to be 0. In addition, cost2_exp(2) is greater than cost2_exp(3) at p = 0.01, which will force the solver to select cost2_exp(3) when p = 0.01.&lt;/p&gt;&#xA;&lt;p&gt;To address these problems, I add abs() to force the cost2_exps produce only positive value, which makes the solver to choose cost2 = 0 at p = 0, since the problem is minimization problem. However, this approach can not be adopted to &lt;code&gt;cost2_exp(2)&lt;/code&gt; since it is a quadratic function, and should be divided into quadratic and linear term to handle. Also, to force the solver to choose cost2_exp(2) at p = 0.01, I add a small number 10^-6 to prevent the solver from choosing cost2_exp(3) when p = 0.01.&lt;/p&gt;&#xA;&lt;p&gt;Thus, my question is: How can I deal with this particular case when &lt;code&gt;p = 0&lt;/code&gt; for &lt;code&gt;cost2_exp(2)&lt;/code&gt;, or I can just not make it an absolute value since it will produce &lt;em&gt;Inf&lt;/em&gt; when p = 0?&lt;/p&gt;&#xA;" OwnerUserId="5388" LastEditorUserId="5388" LastEditDate="2021-04-24T14:42:06.770" LastActivityDate="2021-04-24T16:35:51.590" Title="How to deal with log0 in optimization problem" Tags="|optimization|mixed-integer-programming|linearization|binary-variable|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6156" PostTypeId="2" ParentId="6155" CreationDate="2021-04-24T16:35:51.590" Score="3" Body="&lt;p&gt;You are not going to be able to add these logs and quadratic terms to the model via simple double-sided big-M constraints, as they generate non-convex use of convex quadratics and logs, and CVX does not support that. The use of the squared log is not possible either. I don't think it supports automatic modelling of nonconvex use of abs operator either.&lt;/p&gt;&#xA;&lt;p&gt;Most problematic though is the concave term &lt;em&gt;cost2_exp3&lt;/em&gt;. This will not be exponential-cone representable, so CVX cannot be used.&lt;/p&gt;&#xA;&lt;p&gt;If you plug it into YALMIP instead, it will compile and run, but a general global optimization solver will be invoked (the internal one if you haven't installed any), i.e. the complexity of the problem is most likely harder than you think. Nevertheless, it looks like a simple structure so it could possibly be solved by a global solver.&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2021-04-24T16:35:51.590" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6157" PostTypeId="1" AcceptedAnswerId="6160" CreationDate="2021-04-24T19:53:13.390" Score="9" ViewCount="1127" Body="&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&#xA;Suppose we have an integer program &lt;span class=&quot;math-container&quot;&gt;$\min\{c^\top{x}\mid{Ax\leq{b}},x\in\mathbb{Z}_+^n\}$&lt;/span&gt;, and suppose that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is a feasible solution for this IP (or even that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is an extreme point of the convex hull of the feasible region). Is there a method to eliminate &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; (and only &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;) from the feasible region, so that if we re-solve the IP, we do not obtain the solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt;&#xA;If the integer program contains only binary variables, then we can use a no-good inequality of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i:x^*_i=0}x_i+\sum_{i:x^*_i=1}(1-x_i)\geq1&#xA;$$&lt;/span&gt;&#xA;to eliminate &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; and only &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; from the feasible region. Is there an analogue of this (possibly using multiple inequalities) for general integer variables? I imagine that if &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is an arbitrary feasible point, the answer is no (unless we use an extended formulation of some kind, or nonlinear inequalities)--one can imagine if &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is a single point in the middle of the integer lattice, there would be no way to simply punch only that point out of the middle. But if &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is an extreme point of the convex hull, it seems that it should be possible.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;One possible solution:&lt;/strong&gt;&#xA;One clear solution is to use a binary expansion of the integer variables, and replace all the general integer variables with binary variables. I am wondering if there is a way to do this without a binary expansion (i.e. hopefully in the original space of variables).&lt;/p&gt;&#xA;" OwnerUserId="358" LastActivityDate="2021-05-02T01:33:08.630" Title="No-good cuts for general integer variables" Tags="|integer-programming|valid-inequalities|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6158" PostTypeId="2" ParentId="6157" CreationDate="2021-04-24T21:58:56.347" Score="8" Body="&lt;p&gt;Here's one way, assuming &lt;span class=&quot;math-container&quot;&gt;$L_i \le x_i \le U_i$&lt;/span&gt;.  Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;, with linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i (y_i+z_i) &amp;amp;\ge 1 \tag1\\&#xA;y_i + z_i &amp;amp;\le 1 &amp;amp;\text{for all $i$} \tag2\\&#xA;L_i(1-z_i) + (x_i^*+1)z_i \le x_i &amp;amp;\le (x_i^*-1)y_i + U_i(1-y_i) &amp;amp;\text{for all $i$} \tag3\\&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; forces &lt;span class=&quot;math-container&quot;&gt;$y_i \lor z_i$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; forces &lt;span class=&quot;math-container&quot;&gt;$\lnot(y_i \land z_i)$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y_i = 1 \implies x_i &amp;lt; x_i^*$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_i = 1 \implies x_i &amp;gt; x_i^*$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-04-24T21:58:56.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6159" PostTypeId="2" ParentId="6157" CreationDate="2021-04-24T22:18:22.547" Score="6" Body="&lt;p&gt;If you are willing to entertain an element of risk, and assuming that the feasible region is bounded, you might get away with a single new binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. Assume that the feasible region &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is bounded, which implies that the number of feasible &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is finite. Generate a vector &lt;span class=&quot;math-container&quot;&gt;$r\in \mathbb{R}^n$&lt;/span&gt; uniformly over the unit rectangle. Since the feasible region is finite, &lt;span class=&quot;math-container&quot;&gt;$\mathrm{Pr}(r^\prime x = r^\prime x^*)=0$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$x^*\neq x\in X$&lt;/span&gt;. So adding the constraint &lt;span class=&quot;math-container&quot;&gt;$r^\prime x \neq r^\prime x^*$&lt;/span&gt; gets rid of &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; while (with probability 1) not eliminating any other feasible solution. This is true even if &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is in the interior of the convex hull of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The catch is that &lt;span class=&quot;math-container&quot;&gt;$\neq$&lt;/span&gt; constraints are not allowed. So we introduce a single binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, a tolerance parameter &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; and an upper bound &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$\left( \vert r^\prime x - r^\prime x^*\vert + \epsilon \right)$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$x\in X$&lt;/span&gt; and add the constraints &lt;span class=&quot;math-container&quot;&gt;$$r^\prime x^* + \epsilon -M(1-z) \le r^\prime x \le r^\prime x^* -\epsilon + Mz.$$&lt;/span&gt;The probability of excluding a feasible point is no longer zero, but it should be small (assuming &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is small). So I would call this approach &amp;quot;low risk&amp;quot; as opposed to &amp;quot;risk free&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-04-24T22:18:22.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6160" PostTypeId="2" ParentId="6157" CreationDate="2021-04-24T22:54:28.837" Score="7" Body="&lt;p&gt;This is what I have been using. Assume &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}x_i \in \{\color{darkblue}L_i,\dots,\color{darkblue}U_i\}$&lt;/span&gt; and we want:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_i |\color{darkred}x_i-\color{darkblue}x_i^*| \ge 1$$&lt;/span&gt;&#xA;or&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}  &amp;amp; \color{darkred}z_i \le |\color{darkred}x_i-\color{darkblue}x_i^*| \\ &amp;amp; \sum_i \color{darkred}z_i \ge 1 \end{align}$$&lt;/span&gt;&#xA;This can be modeled with a binary variable &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}\delta_i$&lt;/span&gt; : &lt;span class=&quot;math-container&quot;&gt;$$\begin{align} &amp;amp; \color{darkred}z_i\le \color{darkred}x_i-\color{darkblue}x_i^*+\color{darkblue}M_i\cdot\color{darkred}\delta_i \\ &amp;amp; \color{darkred}z_i\le -(\color{darkred}x_i-\color{darkblue}x_i^*)+\color{darkblue}M_i\cdot(1-\color{darkred}\delta_i)\\ &amp;amp; \sum_i \color{darkred}z_i \ge 1\\ &amp;amp;\color{darkred}\delta_i \in \{0,1\} \\ &amp;amp; \color{darkblue}M_i=\color{darkblue}U_i-\color{darkblue}L_i\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A refinement is to consider the two special cases:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\color{darkblue}x_i^*=\color{darkblue}L_i$&lt;/span&gt;. No need for &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}\delta_i$&lt;/span&gt;: use &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}z_i=\color{darkred}x_i-\color{darkblue}x_i^*$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\color{darkblue}x_i^*=\color{darkblue}U_i$&lt;/span&gt;. Again no need for &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}\delta_i$&lt;/span&gt;: use &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}z_i= -(\color{darkred}x_i-\color{darkblue}x_i^*)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2021-05-02T01:33:08.630" LastActivityDate="2021-05-02T01:33:08.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6161" PostTypeId="1" CreationDate="2021-04-25T01:48:38.023" Score="4" ViewCount="660" Body="&lt;p&gt;&lt;strong&gt;I missed the opportunity to ask this on OR.SE by 24 days! I asked it &lt;a href=&quot;https://cs.stackexchange.com/q/109039/61663&quot;&gt;at CS.SE on 6 May 2019&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/q/1/727&quot;&gt;OR.SE entered Private Beta on 30 May 2019&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It's a problem about minimizing a sum of terms that are quadratic in its integer variables.&lt;/li&gt;&#xA;&lt;li&gt;It's a QUBO (quadratic unconstrainted binary optimization) problem, and QUBO questions have been fairly well received here at OR.SE (e.g. &lt;a href=&quot;https://or.stackexchange.com/q/828/727&quot;&gt;this&lt;/a&gt;, &lt;a href=&quot;https://or.stackexchange.com/q/1380/727&quot;&gt;this&lt;/a&gt;, and &lt;a href=&quot;https://or.stackexchange.com/q/2869/727&quot;&gt;this&lt;/a&gt;) whereas at CS.SE there was interest from only one user that wrote comments.&lt;/li&gt;&#xA;&lt;li&gt;While We're beyond the 60-day limit to &amp;quot;migrate&amp;quot; a question, I'll follow &lt;a href=&quot;https://meta.stackexchange.com/a/4713/391772&quot;&gt;Robert Cartaino's advice&lt;/a&gt; and re-ask it here.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr&gt;&#xA;&lt;h3&gt;The Question:&lt;/h3&gt;&#xA;&lt;p&gt;A &lt;a href=&quot;https://advances.sciencemag.org/content/5/4/eaav2372/tab-pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper was published recently in Science&lt;/a&gt; where the authors minimized the following function:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$E_{\text{Ising}}(s) = -\dfrac{1}{2} \Sigma_{i=1}^{N} \Sigma_{j=1}^{N} J_{i,j} s_i s_j,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; denotes the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;th Ising spin, which takes a value of 1 or -1, &lt;span class=&quot;math-container&quot;&gt;$s = (s_1 s_2 \cdots s_N)$&lt;/span&gt; is the vector representation of a spin configuration, and &lt;span class=&quot;math-container&quot;&gt;$J_{i,j}(=J_{j,i})$&lt;/span&gt; is the coupling coefficient between the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;th and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; spins (&lt;span class=&quot;math-container&quot;&gt;$J_{i,i}=0$&lt;/span&gt;). The problem is to find a spin configuration minimizing the Ising energy. This problem is mathematically equivalent to a famous combinatorial optimization problem named MAX-CUT (5, 17, 18, 39): divide the nodes of a weighted graph into two groups maximizing the total weight (called &amp;quot;cut value&amp;quot;) of the edges cut by the division. By setting the coupling coefficient as &lt;span class=&quot;math-container&quot;&gt;$J_{i,j} = - w_{i,j}$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$w_{i,j} = w_{j,i}$&lt;/span&gt; is the weight between &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;th and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;th nodes), we can solve MAX-CUT using Ising machines.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In particular, it appears that they are solving instances of weighted MAX-CUT where the input graph is the complete graph on 2000 vertices with edge weights assigned from &lt;span class=&quot;math-container&quot;&gt;$\{-1,1\}$&lt;/span&gt; independently and uniformly at random.&lt;/p&gt;&#xA;&lt;p&gt;They say they found solutions in 0.5 ms and the other specifics such as the criteria for calling something a &amp;quot;solution&amp;quot; are also given.&lt;/p&gt;&#xA;&lt;p&gt;They say in the abstract that 0.5ms is 10 times faster than the Coherent Ising Machine (a type of &lt;em&gt;&lt;strong&gt;quantum calculator&lt;/strong&gt;&lt;/em&gt;), but I would like it to instead be compared to state-of-the-art for conventional algorithms on &lt;em&gt;&lt;strong&gt;classical computers&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It should be possible to generate the same type of random instances of MAX-CUT as the authors, and solve the problem with a conventional algorithm for classical computing (e.g. CPUs, GPUs, FPGAs), and compare the performance to what is claimed in the paper, when using the &lt;em&gt;same&lt;/em&gt; criteria for what is considered a good enough solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Are there any algorithms or codes apart from just general SAT/CSP solvers, that could be applied to this specific problem?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="727" LastActivityDate="2021-04-26T06:56:05.703" Title="MAX-CUT: are there any algorithms or codes for classical computers, that cater to this specific case?" Tags="|optimization|integer-programming|combinatorial-optimization|graphs|quadratic-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6162" PostTypeId="2" ParentId="6161" CreationDate="2021-04-25T08:50:45.730" Score="4" Body="&lt;p&gt;Have a look at &lt;a href=&quot;https://github.com/MQLib/MQLib&quot; rel=&quot;nofollow noreferrer&quot;&gt;MQLib&lt;/a&gt;, which contains efficient implementations of many published algorithms. &lt;a href=&quot;https://github.com/MQLib/MQLib/blob/master/paper/SECM_final.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Their paper&lt;/a&gt; is awesome too.&lt;/p&gt;&#xA;&lt;p&gt;You can find a lot of code for QUBO online, one of the most publicized being &lt;a href=&quot;https://github.com/dwavesystems/qbsolv&quot; rel=&quot;nofollow noreferrer&quot;&gt;qbsolv&lt;/a&gt; from Dwave. It is meant as a demonstrator of how much better quantum algorithms are, and the method is very basic.&#xA;In general, I would take any hype on quantum or classical annealers with a hefty grain of salt.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2021-04-25T08:50:45.730" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6163" PostTypeId="2" ParentId="4633" CreationDate="2021-04-25T12:46:25.833" Score="2" Body="&lt;p&gt;{0,1}-ILP can be rewritten as Pseudo-Boolean programming or MAX-Sat. It might be worth to explore alternative solving technologies for your problem.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-04-25T12:46:25.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6164" PostTypeId="1" AcceptedAnswerId="6168" CreationDate="2021-04-25T12:48:16.497" Score="4" ViewCount="101" Body="&lt;p&gt;In &lt;a href=&quot;https://glossary.informs.org/myths/CurrentVersion/myths.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Myths and Counterexamples of Mathematical Programming&amp;quot;&lt;/a&gt; myth &amp;quot;IP Myth 21&amp;quot; says:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The problem of finding &lt;span class=&quot;math-container&quot;&gt;$x\in \mathbb{Z}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$A\in\mathbb{Z}^{m\times n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b\in \mathbb{Z}^m$&lt;/span&gt;, is NP-complete.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Which is incorrect (as all myths in this excellent resource are).&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The key to this myth is that there are no bounds on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. (If we add&#xA;&lt;span class=&quot;math-container&quot;&gt;$x≥0$&lt;/span&gt;, we have the standard form of a linear integer program, which is&#xA;NP-complete.) This is the problem of solving linear diophantine&#xA;equations for which Brown provides simple, polynomial-time algorithms&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a name for this problem class in OR/Optimization?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a name for this problem class some linear equality constraints over &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}$&lt;/span&gt; are added?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Are you aware of any MILP solvers which find such subproblems and solve them using specialized routines?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Are problems of the same form but with &lt;span class=&quot;math-container&quot;&gt;$\min ||x||$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\min c^Tx$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\min \sum_i (c_i x_i)^2 $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\min x^T D x$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\min x^T D x + c^Tx$&lt;/span&gt; where D positive definite as objective still solvable in polynomial time?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="123" LastEditDate="2021-04-25T13:50:01.357" LastActivityDate="2021-04-25T19:01:30.063" Title="Name for subclass of ILP without any inequality constraints (including constraints on x)" Tags="|mixed-integer-programming|linear-programming|integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6165" PostTypeId="1" CreationDate="2021-04-25T18:01:42.317" Score="4" ViewCount="579" Body="&lt;p&gt;Let's have the following trivial linear program: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad z=20A+30B\\\text{s.t.}&amp;amp;\quad A\le60\\&amp;amp;\quad B\le50\\&amp;amp;\quad A+2B\ge220\\&amp;amp;\quad A,B\ge0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It's easy to spot that the first three constraints are contradictory. So, there are no solutions.&lt;/p&gt;&#xA;&lt;p&gt;Let's assume we have dozens, hundreds, or even thousands of variables and constraints.&#xA;Is there any automatic way to spot the contradictory constraints? Maybe by some nuance of AI?&lt;/p&gt;&#xA;" OwnerUserId="5369" LastEditorUserId="123" LastEditDate="2021-04-26T08:07:48.780" LastActivityDate="2021-04-26T08:07:48.780" Title="Is there any automatic way to spot contradictory constraints in linear programming?" Tags="|optimization|linear-programming|constraint|constraint-programming|irreducible-infeasible-subset|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6166" PostTypeId="1" CreationDate="2021-04-25T18:31:37.170" Score="2" ViewCount="109" Body="&lt;p&gt;I'm an operations data analyst. I was wondering if I can get recommendations on books/videos on statistical models specific to optimizing business operations through analytics and statistical modeling.&lt;/p&gt;&#xA;&lt;p&gt;An example of a problem I am trying to solve is trying to understand if the variance in case volume divided by customer population and intersected over time are statistically significant. E.g. if I were to compare the previous week's performance with this week's performance. The objective here is to understand if the delta between the two weeks is significant. I am not necessarily trying to take into account all of the previous weeks and using linear regression to find future values.&lt;/p&gt;&#xA;" OwnerUserId="5397" LastEditorUserId="2579" LastEditDate="2021-09-30T12:39:49.943" LastActivityDate="2021-09-30T12:39:49.943" Title="Recommendations on Operations Statistics/Analytics Approaches/Materials" Tags="|modeling|reference-request|statistics|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6167" PostTypeId="2" ParentId="6165" CreationDate="2021-04-25T18:40:25.977" Score="5" Body="&lt;p&gt;Shameless plug: I recently gave a &lt;a href=&quot;https://www.sas.com/en_us/webinars/diagnose-infeasibility.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;webinar on diagnosing infeasibility&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here's what your example looks like in SAS:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;proc optmodel;&#xA;   var A &amp;gt;= 0;&#xA;   var B &amp;gt;= 0;&#xA;   max z = 20*A + 30*B;&#xA;   con c1: A &amp;lt;= 60;&#xA;   con c2: B &amp;lt;= 50;&#xA;   con c3: A+2*B &amp;gt;= 220;&#xA;   solve with lp / iis=true;&#xA;   expand / iis;&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The resulting IIS contains all three constraints but not the lower bounds on A and B:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Constraint c1: A &amp;lt;= 60                                                                         &#xA;Constraint c2: B &amp;lt;= 50                                                                         &#xA;Constraint c3: A + 2*B &amp;gt;= 220   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-04-25T20:36:49.427" LastActivityDate="2021-04-25T20:36:49.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6168" PostTypeId="2" ParentId="6164" CreationDate="2021-04-25T19:01:30.063" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.m.wikipedia.org/wiki/Diophantine_equation&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.m.wikipedia.org/wiki/Diophantine_equation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;any milp solver can handle it, but maybe something like mathematica/mable has special algortihms or one can use the algorithm described by the wiki entry&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;4a) &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Lattice_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.m.wikipedia.org/wiki/Lattice_problem&lt;/a&gt;&#xA;4b) is i think polytime, either the problem is unbounded, infeasible or all solutions are optimal.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2021-04-25T19:01:30.063" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6169" PostTypeId="1" CreationDate="2021-04-26T03:45:23.437" Score="7" ViewCount="358" Body="&lt;p&gt;I am looking for a paper/study in which a Logic-based Benders decomposition (LLBD) framework is used when the master problem is associated with integer variables (not specifically binary).&lt;/p&gt;&#xA;&lt;p&gt;In general LBBD, we often send fixed binary solutions to the subproblem and the Benders cuts aim to alternate the previous solutions as &amp;quot;&lt;em&gt;combinatorial cuts&lt;/em&gt;&amp;quot;. I am just curious if LLBD could be utilized in the case of having integer master variables. I have gone through a lot of recent LBBD papers, but it seems like the master problem is always associated with binary variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/6157/no-good-cuts-for-general-integer-variables&quot;&gt;In a previous post&lt;/a&gt;, it is discussed that there exist no-good cut strategies, but in general, no-good cuts are not really effective to converge the optimal solution. That is why I am curious if there exists a study where authors design effective LBBD cuts when the master variables are integer.&lt;/p&gt;&#xA;" OwnerUserId="4025" LastEditorUserId="4025" LastEditDate="2021-04-26T04:01:43.083" LastActivityDate="2023-06-07T16:50:33.943" Title="Logic-based Benders decomposition with integer master variables" Tags="|reference-request|benders-decomposition|literature-research|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6170" PostTypeId="2" ParentId="6161" CreationDate="2021-04-26T06:56:05.703" Score="4" Body="&lt;p&gt;Maxcut with CPLEX CPOptimizer in &lt;a href=&quot;https://github.com/AlexFleischerParis/howtowithopl/blob/master/maxcutcpo.mod&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/AlexFleischerParis/howtowithopl/blob/master/maxcutcpo.mod&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using CP;&#xA;&#xA;execute&#xA;{&#xA;  // time limit 10 s&#xA;  cp.param.timelimit=10;&#xA;}&#xA;&#xA;int n=400;&#xA;range r=1..n;&#xA;&#xA;// Random graph  &#xA;float edge_prob=0.5;&#xA;int  weight_range=10;&#xA;int big=100000;&#xA; &#xA;tuple t&#xA;{&#xA;  int i;&#xA;  int j;&#xA;}&#xA;&#xA;{t} s={&amp;lt;i,j&amp;gt; | ordered i,j in r};&#xA;&#xA;int w[i in r][j in r]=(i&amp;lt;=j)?((rand(big)&amp;lt;=big*edge_prob)?rand(weight_range):0):0;&#xA;&#xA;// end of random graph&#xA;&#xA;//int n=4;&#xA;//range r=1..n;&#xA;//float w[r][r]=&#xA;//&#xA;//[[ 0. , 8. ,-9. , 0.],&#xA;// [ 8. , 0. , 7. , 9.],&#xA;// [-9. , 7.  ,0., -8.],&#xA;// [ 0. , 9., -8. , 0.]];&#xA;&#xA;assert card(s)==n*(n-1) div 2;&#xA;&#xA; // x is the unknown and 0 or 1 means in one or the other side of the fence&#xA; dvar boolean x[r];&#xA; &#xA; dexpr float obj=2*sum(&amp;lt;i,j&amp;gt; in s) w[i][j]*(x[i]!=x[j]);&#xA; &#xA; maximize obj;&#xA; &#xA; subject to&#xA; {&#xA;   // break symmetry&#xA;   x[1]==1;&#xA; }&#xA; &#xA; {int} x1={i| i in r:x[i]==1};&#xA; &#xA; execute&#xA; {&#xA;   writeln(&amp;quot;objective = &amp;quot;,obj);&#xA;   writeln(&amp;quot;x set to 1 : &amp;quot;,x1);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With CPLEX MP at &lt;a href=&quot;https://github.com/AlexFleischerParis/howtowithopl/blob/master/maxcut.mod&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/AlexFleischerParis/howtowithopl/blob/master/maxcut.mod&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int n=400;&#xA;range r=1..n;&#xA;&#xA;// Random graph  &#xA;float edge_prob=0.5;&#xA;int  weight_range=10;&#xA;int big=100000;&#xA; &#xA;tuple t&#xA;{&#xA;  int i;&#xA;  int j;&#xA;}&#xA;&#xA;{t} s={&amp;lt;i,j&amp;gt; | ordered i,j in r};&#xA;&#xA;int w[i in r][j in r]=(i&amp;lt;=j)?((rand(big)&amp;lt;=big*edge_prob)?rand(weight_range):0):0;&#xA;&#xA;// end of random graph&#xA;&#xA;//int n=4;&#xA;//range r=1..n;&#xA;//float w[r][r]=&#xA;//&#xA;//[[ 0. , 8. ,-9. , 0.],&#xA;// [ 8. , 0. , 7. , 9.],&#xA;// [-9. , 7.  ,0., -8.],&#xA;// [ 0. , 9., -8. , 0.]];&#xA;&#xA;assert card(s)==n*(n-1) div 2;&#xA;&#xA; // x is the unknown and 0 or 1 means in one or the other side of the fence&#xA; dvar boolean x[r];&#xA; &#xA; dexpr float obj=2*sum(&amp;lt;i,j&amp;gt; in s) w[i][j]*x[i]*(1-x[j]);&#xA; &#xA; maximize obj;&#xA; &#xA; subject to&#xA; {&#xA;   &#xA; }&#xA; &#xA; {int} x1={i| i in r:x[i]==1};&#xA; &#xA; execute&#xA; {&#xA;   writeln(&amp;quot;objective = &amp;quot;,obj);&#xA;   writeln(&amp;quot;x set to 1 : &amp;quot;,x1);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and IBM Quantum Qiskit at &lt;a href=&quot;https://qiskit.org/documentation/tutorials/optimization/6_examples_max_cut_and_tsp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://qiskit.org/documentation/tutorials/optimization/6_examples_max_cut_and_tsp.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-04-26T06:56:05.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6171" PostTypeId="2" ParentId="6169" CreationDate="2021-04-26T07:33:00.520" Score="3" Body="&lt;p&gt;The state-of-the-art method for solving the vehicle routing problem with split deliveries is in fact LBBD as can be seen in the following papers:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S037722171400352X&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sciencedirect.com/science/article/abs/pii/S037722171400352X&lt;/a&gt;&#xA;&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.2018.0825&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pubsonline.informs.org/doi/abs/10.1287/trsc.2018.0825&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Although the authors do not refer to their algorithms as LBBD, their methods can be seen as LBBD. The master problem employs general integer variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; which counts the number of times edge/arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is visited by any vehicles. The cut they employ has the form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{(i,j) \in S} x_{ij} \ge 1,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;in which &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; corresponds to the set of edges that setting their corresponding &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables to zero (all at the same time) will certainly result in an infeasible solution. See the papers for more details.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2021-04-26T07:33:00.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6172" PostTypeId="1" AcceptedAnswerId="6173" CreationDate="2021-04-26T08:10:13.850" Score="5" ViewCount="231" Body="&lt;p&gt;I have a follow up question to another question of mine &lt;a href=&quot;https://or.stackexchange.com/questions/6127/how-to-set-a-limit-for-a-switch-to-0-of-a-variable&quot;&gt;How to set a limit for a switch to 0 of a variable&lt;/a&gt; about counting the number of switches to 0 of one decision variable. Now I would like to ask the same question for two combined decision variables. So basically I have the decision variable x(t) and another decision variable y(t). The both quantify the heating output of a heating device for two different thermal storage systems for every timeslot t in [1,...,288]. It should be avoided that the heating device is switched on and off frequently thus I want to set a limit for the switching.&lt;/p&gt;&#xA;&lt;p&gt;The rule in pseudocode looks like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if (x(t-1)&amp;gt;0 AND x(t)=0 AND y(t)=0) OR if (y(t-1)&amp;gt;0 AND y(t)=0 AND x(t)=0) &#xA;then increase count by 1&#xA;Constraint: count &amp;lt;= limit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Both variables x(t) and y(t) are continious variables with the boundaries [0,1]. It should also be noted that x(t) and y(t) can't be greater 0 simultaneously (this would mean that the heating device would have heated up 2 storages at the same time which is not possible). For this I just use 2 constraints with binary auxilliary variable h(t)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x(t)&amp;lt;= h(t)&#xA;y(t)&amp;lt;= (1- h(t))&#xA;with h(t) in {0,1}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Any idea how I can derive constraints for something like this? Next to the pure answer I would also appreciate some general advices as how to approach questions like this (if there is a more or less general way of doing this).&lt;/p&gt;&#xA;" OwnerUserId="3396" LastActivityDate="2021-04-28T16:11:09.760" Title="How to set a limit for a switch to 0 of a variable for 2 variables combined" Tags="|modeling|constraint|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6173" PostTypeId="2" ParentId="6172" CreationDate="2021-04-26T09:38:51.927" Score="10" Body="&lt;p&gt;Again, you need to introduce binaries:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\delta_t$&lt;/span&gt; takes values &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if the device is switched off at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\alpha_t$&lt;/span&gt; is the binary associated with variable &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta_t$&lt;/span&gt; is the binary associated with variable &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The condition can be written in conjunctive normal form as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ &#xA;(\alpha_{t-1}\wedge \lnot \alpha_{t} \wedge \lnot \beta_{t}) \vee (\beta_{t-1}\wedge \lnot \beta_{t} \wedge \lnot \alpha_{t}) \implies \delta_t\\&#xA;\lnot \left( (\alpha_{t-1}\wedge \lnot \alpha_{t} \wedge \lnot \beta_{t}) \vee (\beta_{t-1}\wedge \lnot \beta_{t} \wedge \lnot \alpha_{t})\right) \vee \delta_t\\&#xA; (\lnot \alpha_{t-1}\vee  \alpha_{t} \vee \beta_{t}) \wedge (\lnot \beta_{t-1}\vee  \beta_{t} \vee  \alpha_{t}) \vee \delta_t\\&#xA;(\lnot \alpha_{t-1}\vee  \alpha_{t} \vee \beta_{t} \vee \delta_t)\wedge (\lnot \beta_{t-1}\vee  \beta_{t} \vee  \alpha_{t} \vee \delta_t)\\&#xA;(1-\alpha_{t-1}+\alpha_t + \beta_t+ \delta_t \ge 1) \wedge (1-\beta_{t-1}+\beta_t + \alpha_t+ \delta_t \ge 1) &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And since &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; cannot simultaneously be positive, the constraints are&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA; \alpha_{t-1} &amp;amp;\le  \alpha_t + \beta_t+ \delta_t \quad &amp;amp;\forall t   \tag{1}\\ &#xA;  \beta_{t-1} &amp;amp;\le \beta_t + \alpha_t+ \delta_t \quad &amp;amp;\forall t \tag{2}\\&#xA;\sum_t \delta_t &amp;amp;\le \ell \tag{3} \\&#xA;\alpha_t + \beta_t &amp;amp;\le 1 \quad &amp;amp;\forall t \tag{4} \\&#xA;x_t &amp;amp;\le M \alpha_t  \quad &amp;amp;\forall t \tag{5} \\&#xA;y_t &amp;amp;\le M \beta_t  \quad &amp;amp;\forall t \tag{6} \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-04-28T16:11:09.760" LastActivityDate="2021-04-28T16:11:09.760" CommentCount="34" ContentLicense="CC BY-SA 4.0" />
  <row Id="6174" PostTypeId="1" CreationDate="2021-04-26T12:09:08.117" Score="3" ViewCount="3270" Body="&lt;p&gt;I tried the code provided on the link :&#xA;&lt;a href=&quot;https://developers.google.com/optimization/routing/tsp&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization/routing/tsp&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The actual requirement is to traverse all paths without returning to the start point with minimum distance to travel.&lt;/p&gt;&#xA;&lt;p&gt;Then I found this link on stackoverflow  &lt;a href=&quot;https://stackoverflow.com/a/7158721/3016453&quot;&gt;https://stackoverflow.com/a/7158721/3016453&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I added a dummy point and run the first algorithm but not get the expected output. But this is upvoted more than 35 times. I don't know where I am wrong.&lt;/p&gt;&#xA;&lt;p&gt;I ran the below code with both above-mentioned method:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import json&#xA;&#xA;import flask&#xA;import numpy as np&#xA;from flask import request, jsonify&#xA;from ortools.constraint_solver import routing_enums_pb2&#xA;from ortools.constraint_solver import pywrapcp&#xA;&#xA;app = flask.Flask(__name__)&#xA;app.config[&amp;quot;DEBUG&amp;quot;] = True&#xA;&#xA;&#xA;def create_data_model(distance_input_matrix):&#xA;    &amp;quot;&amp;quot;&amp;quot;Stores the data for the problem.&amp;quot;&amp;quot;&amp;quot;&#xA;    data = {'distance_matrix': distance_input_matrix, 'num_vehicles': 1, 'depot': 0}&#xA;    # data['distance_matrix'] = [&#xA;    #     [0, 2451, 713, 1018, 1631, 1374, 2408, 213, 2571, 875, 1420, 2145, 1972],&#xA;    #     [2451, 0, 1745, 1524, 831, 1240, 959, 2596, 403, 1589, 1374, 357, 579],&#xA;    #     [713, 1745, 0, 355, 920, 803, 1737, 851, 1858, 262, 940, 1453, 1260],&#xA;    #     [1018, 1524, 355, 0, 700, 862, 1395, 1123, 1584, 466, 1056, 1280, 987],&#xA;    #     [1631, 831, 920, 700, 0, 663, 1021, 1769, 949, 796, 879, 586, 371],&#xA;    #     [1374, 1240, 803, 862, 663, 0, 1681, 1551, 1765, 547, 225, 887, 999],&#xA;    #     [2408, 959, 1737, 1395, 1021, 1681, 0, 2493, 678, 1724, 1891, 1114, 701],&#xA;    #     [213, 2596, 851, 1123, 1769, 1551, 2493, 0, 2699, 1038, 1605, 2300, 2099],&#xA;    #     [2571, 403, 1858, 1584, 949, 1765, 678, 2699, 0, 1744, 1645, 653, 600],&#xA;    #     [875, 1589, 262, 466, 796, 547, 1724, 1038, 1744, 0, 679, 1272, 1162],&#xA;    #     [1420, 1374, 940, 1056, 879, 225, 1891, 1605, 1645, 679, 0, 1017, 1200],&#xA;    #     [2145, 357, 1453, 1280, 586, 887, 1114, 2300, 653, 1272, 1017, 0, 504],&#xA;    #     [1972, 579, 1260, 987, 371, 999, 701, 2099, 600, 1162, 1200, 504, 0],&#xA;    # ]  # yapf: disable&#xA;    return data&#xA;&#xA;&#xA;def print_solution(manager, routing, solution):&#xA;    &amp;quot;&amp;quot;&amp;quot;Prints solution on console.&amp;quot;&amp;quot;&amp;quot;&#xA;    # print('Objective: {} miles'.format(solution.ObjectiveValue()))&#xA;    index = routing.Start(0)&#xA;    # plan_output = 'Route for vehicle 0:\n'&#xA;    plan_output = ''&#xA;    route_distance = 0&#xA;    while not routing.IsEnd(index):&#xA;        plan_output += '{}-&amp;gt;'.format(manager.IndexToNode(index))&#xA;        previous_index = index&#xA;        index = solution.Value(routing.NextVar(index))&#xA;        route_distance += routing.GetArcCostForVehicle(previous_index, index, 0)&#xA;    plan_output += '{}'.format(manager.IndexToNode(index))&#xA;    return plan_output&#xA;    # print(plan_output)&#xA;    # plan_output += 'Route distance: {}miles\n'.format(route_distance)&#xA;&#xA;&#xA;def main(distance_input_matrix=None):&#xA;    &amp;quot;&amp;quot;&amp;quot;Entry point of the program.&amp;quot;&amp;quot;&amp;quot;&#xA;    # Instantiate the data problem.&#xA;    data = create_data_model(distance_input_matrix)&#xA;&#xA;    # Create the routing index manager.&#xA;    manager = pywrapcp.RoutingIndexManager(len(data['distance_matrix']),&#xA;                                           data['num_vehicles'], data['depot'])&#xA;&#xA;    # Create Routing Model.&#xA;    routing = pywrapcp.RoutingModel(manager)&#xA;&#xA;    def distance_callback(from_index, to_index):&#xA;        &amp;quot;&amp;quot;&amp;quot;Returns the distance between the two nodes.&amp;quot;&amp;quot;&amp;quot;&#xA;        # Convert from routing variable Index to distance matrix NodeIndex.&#xA;        from_node = manager.IndexToNode(from_index)&#xA;        to_node = manager.IndexToNode(to_index)&#xA;        return data['distance_matrix'][from_node][to_node]&#xA;&#xA;    transit_callback_index = routing.RegisterTransitCallback(distance_callback)&#xA;&#xA;    # Define cost of each arc.&#xA;    routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)&#xA;&#xA;    # Setting first solution heuristic.&#xA;    search_parameters = pywrapcp.DefaultRoutingSearchParameters()&#xA;    search_parameters.first_solution_strategy = (&#xA;        routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)&#xA;&#xA;    # Solve the problem.&#xA;    solution = routing.SolveWithParameters(search_parameters)&#xA;&#xA;    # Print solution on console.&#xA;    if solution:&#xA;        return print_solution(manager, routing, solution)&#xA;&#xA;&#xA;@app.route('/', methods=['GET'])&#xA;def home():&#xA;    return main()&#xA;&#xA;&#xA;@app.route('/optimize', methods=['POST'])&#xA;def optimize():&#xA;    if request.json:&#xA;        data_matrix = request.json['data']&#xA;        narrows = len(data_matrix)  # 3 rows in your example&#xA;        narcs = len(data_matrix[0])&#xA;        a = np.zeros((narrows + 1, narcs + 1), dtype='int32').tolist()&#xA;        for i in range(len(data_matrix)):&#xA;            for j in range(len(data_matrix[i])):&#xA;                a[i][j] = data_matrix[i][j]&#xA;        #result = main(a)&#xA;        result = main(data_matrix)&#xA;        r_l = result.split('-&amp;gt;')&#xA;        #r_l.remove(str(narrows))&#xA;        return jsonify({'data': r_l})&#xA;&#xA;&#xA;app.run()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5400" LastEditorUserId="36" LastEditDate="2021-04-26T12:22:48.420" LastActivityDate="2023-01-26T18:37:20.480" Title="Travelling salesman problem variant without returning to the starting point" Tags="|python|or-tools|traveling-salesman|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6175" PostTypeId="1" CreationDate="2021-04-26T19:04:48.643" Score="2" ViewCount="693" Body="&lt;p&gt;I'm modeling an optimization problem in which a decision variable &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; in the objective function depends on if-else conditions involving decision variables &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;, as the following equation, where &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; are constants. I know a possibility would be using binary variables, but I'm not sure how to do it. Could someone help me?&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;x_1 =&#xA;    \begin{cases}&#xA;    a, &amp;amp; \text{if } x_2 \geq c \ \text{and} \ x_3 \geq d\\&#xA;    b \cdot x_3, &amp;amp; \text{if } x_2 \geq c \ \text{and} \ 0 \leq x_3 \leq d\\&#xA;    0, &amp;amp; \text{otherwise}&#xA;\end{cases}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5407" LastEditorUserId="500" LastEditDate="2021-04-26T19:25:23.077" LastActivityDate="2021-10-19T14:02:40.577" Title="How to deal with a decision variable in the objective function that depends on if-else conditions involving other decision variables?" Tags="|linear-programming|modeling|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6177" PostTypeId="2" ParentId="6174" CreationDate="2021-04-27T09:16:42.707" Score="8" Body="&lt;p&gt;A TSP with a fixed starting point and no return to start, can be solved as an ordinary TSP with all the in-going arcs to the starting point having a cost of zero. That way the return to the starting point is &amp;quot;for free&amp;quot; and the TSP solver only focuses on the remaining part of the tour, giving you an optimal &amp;quot;open TSP&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-04-27T09:16:42.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6178" PostTypeId="2" ParentId="6175" CreationDate="2021-04-27T11:15:29.893" Score="8" Body="&lt;p&gt;Introduce four binary variables indicating which region you are in and the function value.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\delta_1 &amp;amp;\rightarrow x_2\geq c, ~x_3\geq d, ~x_1 = a\\ &#xA;\delta_2 &amp;amp;\rightarrow x_2\geq c, ~0\leq x_3 \leq d, ~x_1 = bx_3\\&#xA;\delta_3 &amp;amp;\rightarrow x_2\leq c, ~x_1 = 0\\&#xA;\delta_4 &amp;amp;\rightarrow x_3\leq 0, ~x_1 = 0&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You are in one of the regions so &lt;span class=&quot;math-container&quot;&gt;$\delta_1+\delta_2 +\delta_3+\delta_4=1$&lt;/span&gt;, and all the implications are standard big-M representable such as &lt;span class=&quot;math-container&quot;&gt;$x_2-c\geq -M(1-\delta_1), -M(1-\delta_1) \leq x_1-a\leq M(1-\delta_1)$&lt;/span&gt; etc. By exloiting structure and linearity in some terms this can be reduced and simplified, but this is the basic model.&lt;/p&gt;&#xA;" OwnerUserId="487" LastEditorUserId="487" LastEditDate="2021-04-27T12:02:47.360" LastActivityDate="2021-04-27T12:02:47.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6179" PostTypeId="1" AcceptedAnswerId="6180" CreationDate="2021-04-27T11:44:19.423" Score="2" ViewCount="121" Body="&lt;p&gt;I am looking for some resources to learn the modelling tricks of GAMS in power system optimisation problems.&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="491" LastEditDate="2021-04-27T12:33:44.133" LastActivityDate="2021-04-27T12:33:44.133" Title="Any good resource for solving power system optimization in GAMS?" Tags="|reference-request|gams|energy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6180" PostTypeId="2" ParentId="6179" CreationDate="2021-04-27T12:15:51.077" Score="5" Body="&lt;p&gt;There is a good reference that has been published by Alireza Soroudi.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/gp/book/9783319623498&quot; rel=&quot;noreferrer&quot;&gt;Power System Optimization Modeling in GAMS&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-04-27T12:15:51.077" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6181" PostTypeId="1" AcceptedAnswerId="6189" CreationDate="2021-04-27T21:20:40.500" Score="1" ViewCount="722" Body="&lt;p&gt;I understand that we use SCUC (Security Constrained Unit Commitment) and SCED (Security Constrained Economic Dispatch) in day ahead electricity market – According to the literature, SCUC is used to take commitment decisions and SCED is used for dispatching (calculating MWs) energy.&lt;/p&gt;&#xA;&lt;p&gt;I want to understand why do we need SCED when SCUC already provide commitment decisions and dispatch schedules? Why do we ignore dispatch schedules already calculated by SCUC and reculate them using SCED?&lt;/p&gt;&#xA;&lt;p&gt;Edit 1: In PJM market, the day-ahead wholesale process consist of SCUC and SCED. Same offers/bids and fixed demand requirements are used in both SCUC and SCED (first execution of SCED, upcoming SCED may have different demand). As the demand remain the same, the dispatch from SCUC and first SCED should also be the same.&lt;/p&gt;&#xA;" OwnerUserId="4263" LastEditorUserId="5413" LastEditDate="2021-04-28T09:15:51.253" LastActivityDate="2021-04-29T06:26:00.927" Title="Why do we need SCED in addition to SCUC in RTO/ISO electricity markets?" Tags="|optimization|energy|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6182" PostTypeId="2" ParentId="6175" CreationDate="2021-04-27T21:47:01.070" Score="1" Body="&lt;p&gt;Is the following model correct?&lt;/p&gt;&#xA;&lt;p&gt;Consider &lt;span class=&quot;math-container&quot;&gt;$\delta_i$&lt;/span&gt; as binary variables, whereas &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; are continuous.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;x_1 = a \delta_1 + y_1&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the first if statement:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{matrix}&#xA;c - M(1 - \delta_2) \leq x_2 \leq c + M\delta_2\\&#xA;d - M(1 - \delta_3) \leq x_3 \leq d + M\delta_3\\&#xA;\delta_2 + \delta_3 \geq2\delta_1&#xA;\end{matrix}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the second if statement:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{matrix}&#xA;- M(1 - \delta_4) \leq x_3 \leq   M\delta_4\\&#xA;d - M\delta_5 \leq x_3 \leq d + M(1 - \delta_5)\\&#xA;\delta_2 + \delta_4 + \delta_5 \geq 3\delta_6\\&#xA;bx_3 - M(1 - \delta_6) \leq y_1 \leq bx_3 + M(1 - \delta_6)\\&#xA;-M\delta_6 \leq y_1 \leq M\delta_6\\&#xA;\end{matrix}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5407" LastEditorUserId="5407" LastEditDate="2021-04-27T22:20:54.010" LastActivityDate="2021-04-27T22:20:54.010" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6183" PostTypeId="2" ParentId="6181" CreationDate="2021-04-27T22:00:36.790" Score="2" Body="&lt;p&gt;This is because SCUC provided on/off + dispatch&#xA;Sometimes when you are at time t the demand is not the same as the predicted value and you need to adjust the P values (not on/off since they can't be changed) then you will run a SCED to make sure everything is fine&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2021-04-27T22:00:36.790" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6184" PostTypeId="1" CreationDate="2021-04-27T22:59:06.453" Score="1" ViewCount="132" Body="&lt;p&gt;Is it possible to import data into SCIP from Excel (and then export results to Excel)? If yes, how can I do it?&lt;/p&gt;&#xA;" OwnerUserId="5146" LastActivityDate="2021-04-28T04:13:19.353" Title="Importing data into SCIP solver" Tags="|excel|scip|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6185" PostTypeId="2" ParentId="5411" CreationDate="2021-04-28T00:52:14.157" Score="4" Body="&lt;p&gt;Rank-one constraints are unfortunately not mixed-integer convex representable, as shown in this paper: &lt;a href=&quot;https://arxiv.org/abs/1706.05135&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/1706.05135&lt;/a&gt;, although they are quadratically-constrained quadratic representable.&lt;/p&gt;&#xA;&lt;p&gt;If the problem size is not too large, you can try solving it using Gurobi, either directly (for n&amp;lt;=10) or via branch-and-cut (for say n&amp;lt;=50; see &lt;a href=&quot;https://arxiv.org/abs/2009.10395&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/2009.10395&lt;/a&gt;). At a larger size, your best bet would be to either solve the semidefinite (actually, completely positive which relaxes to doubly non-negative in this case) relaxation and round, or use a heuristic such as alternating minimization.&lt;/p&gt;&#xA;&lt;p&gt;I agree that at first glance introducing binaries should make the problem harder rather than easier, but we have actually recently shown that low-rank problems belong to a different (and probably harder) complexity class than MIO (see section 2 of &lt;a href=&quot;https://arxiv.org/abs/2009.10395&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/2009.10395&lt;/a&gt;), so it maybe shouldn't be too surprising that introducing binaries makes the problem easier.&lt;/p&gt;&#xA;" OwnerUserId="43" LastActivityDate="2021-04-28T00:52:14.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6186" PostTypeId="2" ParentId="6184" CreationDate="2021-04-28T04:13:19.353" Score="1" Body="&lt;p&gt;As far as I know, &lt;a href=&quot;https://www.scipopt.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SCIP&lt;/a&gt; has presented some useful solutions to deal with it.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First, by using an interactive shell, which I don't know has the capability to connect with the separate sheet software like excel.&lt;/li&gt;&#xA;&lt;li&gt;The second, by using a low-level API like C/C++, &lt;a href=&quot;https://github.com/scipopt/PySCIPOpt&quot; rel=&quot;nofollow noreferrer&quot;&gt;python&lt;/a&gt;, etc. I think you could write your own model in your favorite language through the many capabilities of IDEs/code writers such as sheet read methods.&lt;/li&gt;&#xA;&lt;li&gt;The third, by connecting SCIP with some of the algebraic modeling languages like &lt;a href=&quot;http://www.gams.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;GAMS&lt;/a&gt; or &lt;a href=&quot;https://ampl.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AMPL&lt;/a&gt;. I knew that GAMS has the last version of SCIP by default and you can easily read your separate sheet data in GAMS and solving the problem by SCIP solver.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I hope it would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-04-28T04:13:19.353" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6187" PostTypeId="1" AcceptedAnswerId="6188" CreationDate="2021-04-28T17:35:41.720" Score="7" ViewCount="440" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are binary variables, &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; are arbitrary variables, &lt;span class=&quot;math-container&quot;&gt;$a_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; are constants, and I have the following linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_i + \sum_j a_j y_j &amp;amp;\le b &amp;amp;&amp;amp;\text{for all $i$} \tag1\\&#xA;\sum_i x_i &amp;amp;\le 1 \tag2&#xA;\end{align}&lt;/span&gt;&#xA;How can I replace &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;?&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i x_i + \sum_j a_j y_j &amp;amp;\le b \tag{3}\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-06-19T23:32:11.933" LastActivityDate="2021-06-19T23:32:11.933" Title="How can I strengthen a family of constraints in the presence of a clique constraint?" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6188" PostTypeId="2" ParentId="6187" CreationDate="2021-04-28T17:35:41.720" Score="11" Body="&lt;p&gt;Consider the only two possible cases:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; both reduce to &lt;span class=&quot;math-container&quot;&gt;$\sum_j a_j y_j \le b$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_i=1$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; implies that &lt;span class=&quot;math-container&quot;&gt;$x_k=0$&lt;/span&gt; for all other &lt;span class=&quot;math-container&quot;&gt;$k \not= i$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; both reduce to &lt;span class=&quot;math-container&quot;&gt;$1+\sum_j a_j y_j \le b$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Alternatively, you can think of lifting &lt;span class=&quot;math-container&quot;&gt;$x_i+\sum_j a_j y_j \le b$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\alpha_k x_k + x_i+\sum_j a_j y_j \le b$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$k \not= i$&lt;/span&gt;.  If &lt;span class=&quot;math-container&quot;&gt;$x_k=0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\alpha_k$&lt;/span&gt; can be anything.  If &lt;span class=&quot;math-container&quot;&gt;$x_k=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; and you want to find the largest &lt;span class=&quot;math-container&quot;&gt;$\alpha_k$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\alpha_k+\sum_j a_j y_j \le b$&lt;/span&gt; is valid.  Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; implies that you should take &lt;span class=&quot;math-container&quot;&gt;$\alpha_k=1$&lt;/span&gt;, yielding &lt;span class=&quot;math-container&quot;&gt;$x_k + x_i+\sum_j a_j y_j \le b$&lt;/span&gt;.  Now repeat this argument to obtain &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-04-28T17:47:45.353" LastActivityDate="2021-04-28T17:47:45.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6189" PostTypeId="2" ParentId="6181" CreationDate="2021-04-28T18:52:13.837" Score="3" Body="&lt;p&gt;With my best understanding (mostly from the practice of MISO), the goal of Day-ahead SCUC is to provide commitment decisions for the next day while the commitment decisions will also guarantee there are enough &amp;quot;average&amp;quot; power/energy with sufficient ramping for each of the considered discretized time-window. (See [1] for the manual reference)&lt;/p&gt;&#xA;&lt;p&gt;In other words, we can also say SCUC is not perfect or ideal because:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;it's considering a moving &amp;quot;average&amp;quot; in general &amp;quot;sum&amp;quot; but not every couple of minutes at each generator &amp;amp; bus level -&amp;gt; you may miss the &amp;quot;peaks&amp;quot; (aka worse case situations like temporarily loss of winds for parts of your grid in 10 minutes, then back in another 10 minutes),&lt;/li&gt;&#xA;&lt;li&gt;checking all possible contingencies are difficult due to computational complexity -&amp;gt; in practice not all transmission constraints/limits &amp;amp; contingency limits are implemented -&amp;gt; in practice you can still miss some violations/contingencies,&lt;/li&gt;&#xA;&lt;li&gt;Same with 2), the transmission network may be omitted/aggregated/reduced to trade fidelity &amp;amp; accuracy for speed,&lt;/li&gt;&#xA;&lt;li&gt;there are usually no explicit models on reactive power there -&amp;gt; it's at most a DC solution but not an AC solution -&amp;gt; there is no guarantee on whether there will be voltage collapse plus unsure what are the reactive reserves needed (i.e. you may actually need to correct your decisions to start up more generators due to just the need to provide reactive reserves but not active reserves.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;To tackle at least some of the issues above, individual Day-Ahead SCED will be run separately, where these SCEDs will also use system state-estimation data to try to model extra detail with the transmission network(s). The idea is that hopefully these Day-Ahead SCEDs will capture some of these violations early on in the Day-Ahead market. In practice, we still have to run Future/Intra-Day/Look-Ahead Reliability Assessment Commitment Process (FRAC/Intra-Day RAC/LAC) to adjust many of the issues (e.g. a wrong prediction), plus the real-time market to correct the final bits.&lt;/p&gt;&#xA;&lt;p&gt;Theoretically speaking I do agree we can always defined one super large Day-Ahead model merging the existing SCUC and all subsequent SCEDs together mathematically in full details (AC, all network constraints, all contingency constraints, etc), and there are research work putting AC equations on SCUC too. Computationally speaking, due to its mixed-integer complexities (and AC non linearity), decomposition methods are still widely used and the current industry seems fond of the current SCUC and SCED(s) decomposed architecture. Of course, it is forever evolving (see [2])&lt;/p&gt;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&lt;p&gt;[1] BPM 002. &lt;a href=&quot;https://www.misoenergy.org/legal/business-practice-manuals/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.misoenergy.org/legal/business-practice-manuals/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[2] &lt;a href=&quot;https://www.ferc.gov/sites/default/files/2020-06/T3-1_Pan_et_al_0.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ferc.gov/sites/default/files/2020-06/T3-1_Pan_et_al_0.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5416" LastEditorUserId="123" LastEditDate="2021-04-29T06:26:00.927" LastActivityDate="2021-04-29T06:26:00.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6191" PostTypeId="1" AcceptedAnswerId="6239" CreationDate="2021-04-28T22:34:48.783" Score="3" ViewCount="234" Body="&lt;p&gt;Dual information of electricity markets clearing problem is required to calculate the marginal clearing price. As most electricity market problems are based on MIP (and dual information of MIP is not well-defined), &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=solution-working-fixed-mip-problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;fixed-MIP&lt;/a&gt; can be a potential strategy to obtain the dual prices.&lt;/p&gt;&#xA;&lt;p&gt;I would like to ask if the fixed-MIP approach is used by electricity markets in practice? What could be its potential limitations except the one defined in an &lt;a href=&quot;https://or.stackexchange.com/questions/6048/avoid-infeasibility-in-fixed-mip-problem-in-cplex&quot;&gt;earlier post&lt;/a&gt;?&lt;/p&gt;&#xA;&lt;p&gt;If it is not used, why?&lt;/p&gt;&#xA;" OwnerUserId="4263" LastEditorUserId="123" LastEditDate="2021-04-29T06:25:00.493" LastActivityDate="2021-05-09T18:26:04.943" Title="Electricity market clearing price using fixed-MIP formulation?" Tags="|mixed-integer-programming|dual|energy|pricing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6192" PostTypeId="1" CreationDate="2021-04-29T00:10:06.510" Score="3" ViewCount="99" Body="&lt;p&gt;I try to model the following problem: given &lt;span class=&quot;math-container&quot;&gt;$z\in\{0,1\}^m$&lt;/span&gt; and a linear system &lt;span class=&quot;math-container&quot;&gt;$Ax\le b(z), x\in\Bbb R^n, A\in\Bbb R^{d\times n}, b(z)\in\Bbb R^{d}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$b(z)$&lt;/span&gt; means that some entries of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; are functions of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. Specifically, the entries in &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; that depend on &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; are in the form of &lt;span class=&quot;math-container&quot;&gt;$c + 1-z$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; indicates some constant.&lt;/p&gt;&#xA;&lt;p&gt;The statement I want to model is: minimize &lt;span class=&quot;math-container&quot;&gt;$\|z\|_0$&lt;/span&gt; such that the linear system &lt;span class=&quot;math-container&quot;&gt;$Ax\le b(z)$&lt;/span&gt; is infeasible. It is already known that this linear system is feasible when &lt;span class=&quot;math-container&quot;&gt;$z = 0$&lt;/span&gt; and there exists a &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; making the system infeasible. Is there any way to model it into MILP?&lt;/p&gt;&#xA;" OwnerUserId="5160" LastEditorUserId="123" LastEditDate="2021-04-29T06:23:34.123" LastActivityDate="2021-04-29T17:36:43.610" Title="MILP modelling on minimal disturbance of right-hand-side to make a linear system infeasible" Tags="|mixed-integer-programming|logical-constraints|feasible-points|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6193" PostTypeId="1" AcceptedAnswerId="6194" CreationDate="2021-04-29T04:35:10.763" Score="5" ViewCount="988" Body="&lt;p&gt;I have a connected network where I want to visit a set of destinations which may require visiting intermediate nodes as well because there may be no direct edge between source and destination nodes. I want to visit all destinations including intermediate nodes (not all nodes, only those nodes which help in completing the tour in minimum time). As soon as the last destination is visited, it should give the minimum time to visit the destination, i.e., the source node will not be visited at the end. Each edge in the network is bidirectionally visitable. For example, a network in the following diagram, the source could be &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; and destinations could be &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7yUNs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7yUNs.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have the following mathematical formulation for this purpose.&lt;/p&gt;&#xA;&lt;p&gt;The objective function is to minimize the total travelling distance from source to all destination nodes which is defined as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{(i, j)\in N} T_{ij} x_{ij}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraints include:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i,j\in\rm Edges} x_{ij} = 1$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is a source node;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i,j\in\rm Edges} x_{ij} = 0$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is a source node;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{j\in\rm Destinations}\sum\limits_{i,j \in\rm Edges} = \sum\limits_{j\in\rm Destinations}\sum\limits_{j, i\rm \in Edges} - 1$$&lt;/span&gt; for all edges going into the destination nodes, it should be one greater than the last destination;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i,j\in\rm Edges} x_{ij} = \sum\limits_{j,l\in\rm Edges} x_{jl}$&lt;/span&gt; for each intermediate nodes &lt;strong&gt;excluding&lt;/strong&gt; source and destination nodes. It ensures path starts at origin and that each subsequent edge in the path is a continuation from the previous edge.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When I run these constraints in Docplex, it shows an infeasible solution. If I exclude the second &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i,j\in\rm Edges} x_{ij} = 0$&lt;/span&gt; constraint, it provides the solution as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   O-A&#xA;   A-O&#xA;   C-O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The actual solution should be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   O-A&#xA;   A-B&#xA;   B-C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5419" LastEditorUserId="491" LastEditDate="2021-04-30T13:59:08.960" LastActivityDate="2021-05-05T07:45:04.667" Title="How to visit a subset of network nodes in a single trip?" Tags="|mixed-integer-programming|linear-programming|cplex|constraint-programming|network-flow|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6194" PostTypeId="2" ParentId="6193" CreationDate="2021-04-29T06:26:23.820" Score="6" Body="&lt;p&gt;To be clear, you have a set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of nodes of a graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,A)$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$S\subseteq V$&lt;/span&gt;, which must be visited. There is a special node &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt;, which must be the starting point of a tour. A tour visiting the nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; starting from &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; (but not returning to &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt;) at minimum length must be found? If that is the case, I think the easiest way is to compute an all-pairs shortest path matrix on the set &lt;span class=&quot;math-container&quot;&gt;$O\cup S$&lt;/span&gt; and then solve a TSP with the modification described in &lt;a href=&quot;https://or.stackexchange.com/a/6177/278&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Edit: As I can see from the comments that the answer was not entirely clear, I will try to elaborate a bit on the idea.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We can observe, that we will never take a route between two of the destination nodes, which is longer than the shortest path between the two destinations. This is because we can visit the nodes of the graph several times without problems per the OPs description.&lt;/li&gt;&#xA;&lt;li&gt;If we knew the shortest paths between each pair of destinations nodes, say &lt;span class=&quot;math-container&quot;&gt;$i,j\in S$&lt;/span&gt;, and we knew the order in which the destination nodes should be visited, we can piece a correct solution together by traversing the shortest paths between the destination nodes in the order specified by the order of the destination nodes.&lt;/li&gt;&#xA;&lt;li&gt;An optimal ordering of the destination nodes can be found by solving a TSP over the set &lt;span class=&quot;math-container&quot;&gt;$V= O\cup S$&lt;/span&gt; with a distance matrix given by the shortest path distances between the nodes in &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If we do not want to return to &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; we can set the distances leading from destination nodes back to the origin to zero, and then solve a TSP over &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; with the new distance matrix as per &lt;a href=&quot;https://or.stackexchange.com/a/6177/278&quot;&gt;this answer&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;From these observations you can solve you problem using the following approach&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Compute an all pairs shortest path matrix on the set &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; in the graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;. You can e.g. use the &lt;a href=&quot;https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Floyd-Warshall algorithm&lt;/a&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$(p_{ij})_{i,j\in V}$&lt;/span&gt; be the matrix of shortest paths and let &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; be the corresponding distances..&lt;/li&gt;&#xA;&lt;li&gt;For each &lt;span class=&quot;math-container&quot;&gt;$i,j\in V$&lt;/span&gt; define a new matrix &lt;span class=&quot;math-container&quot;&gt;$\tilde{d}_{ij}$&lt;/span&gt; as follows: if &lt;span class=&quot;math-container&quot;&gt;$i\in V$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j\in S$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\tilde{d}_{ij}=d_{ij}$&lt;/span&gt; and otherwise &lt;span class=&quot;math-container&quot;&gt;$\tilde{d}_{ij}=0$&lt;/span&gt; (that is, &lt;span class=&quot;math-container&quot;&gt;$\tilde{d}_{iO}=0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i\in V$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Solve a TSP over the set &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; with the matrix &lt;span class=&quot;math-container&quot;&gt;$\tilde{d}_{ij}$&lt;/span&gt; as the distance matrix. From this you get an optimal &amp;quot;open TSP&amp;quot; of the set &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;. Let an optimal ordering of the destination nodes be given by &lt;span class=&quot;math-container&quot;&gt;$\{O,s_1,s_2,\dots,s_{\vert S\vert}\}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Find an optimal solution to your problem using the &amp;quot;tour&amp;quot; given by &lt;span class=&quot;math-container&quot;&gt;$p_{0s_1}\rightarrow p_{s_1 s_2}\rightarrow\dots\rightarrow p_{s_{\vert S\vert-1}s_{\vert S\vert}}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2021-05-05T07:45:04.667" LastActivityDate="2021-05-05T07:45:04.667" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6195" PostTypeId="2" ParentId="6192" CreationDate="2021-04-29T07:31:50.203" Score="5" Body="&lt;p&gt;By Farkas lemma, infeasibility of &lt;span class=&quot;math-container&quot;&gt;$Ax\leq b$&lt;/span&gt; is equivalent to feasibility of &lt;span class=&quot;math-container&quot;&gt;$A^Ty = 0, y^Tb &amp;lt; 0, y\geq 0$&lt;/span&gt;, or more practically useful &lt;span class=&quot;math-container&quot;&gt;$A^Ty=0, y^Tb \leq -1, y\geq 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, this will lead to a bilinear model when you parameterize &lt;span class=&quot;math-container&quot;&gt;$b(z)$&lt;/span&gt;. It is fairly similar to an application I worked on a decade ago &lt;a href=&quot;https://users.isy.liu.se/johanl/2011_AUT_OOPS.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Oops! I cannot do it again:&#xA;Testing for recursive feasibility in MPC&lt;/a&gt; where we started with bilinear stuff coming from Farkas lemma, and it was possible to trade that bilinearity with a complementarity condition (Sec 4.2) which (at the time) was more efficiently solved.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: Missed the fact that &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is binary. In that case, you can linearize &lt;span class=&quot;math-container&quot;&gt;$y^Tb(z)$&lt;/span&gt; using standard big-M methods, and you end up with a MILP.&lt;/p&gt;&#xA;&lt;p&gt;Here is a small proof-of-concept implementation in the MATLAB Toolbox YALMIP (disclaimer, developed by me). I was too lazy to manually linearize so I used a built-in command to derive the big-M model&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;% Feasible model&#xA;m = 50;n = 5;&#xA;A = randn(m,n);&#xA;b0 = A*randn(n,1) + 0.99&#xA;&#xA;% Perturb&#xA;z = binvar(m,1);&#xA;b = b0 - z;&#xA;&#xA;% Solve&#xA;y = sdpvar(m,1);&#xA;[linear_b_y,cut]=binmodel(b'*y,[-100 &amp;lt;= y &amp;lt;= 100]);&#xA;Model = [A'*y == 0, y &amp;gt;= 0, linear_b_y == -1, cut];&#xA;optimize(Model,sum(z))&#xA;nnz(z)&#xA;&#xA;% Check that it is infeasible&#xA;x = sdpvar(n,1);&#xA;optimize(A*x&amp;lt;=value(b))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="487" LastEditorUserId="487" LastEditDate="2021-04-29T17:36:43.610" LastActivityDate="2021-04-29T17:36:43.610" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6196" PostTypeId="2" ParentId="6193" CreationDate="2021-04-29T07:49:31.800" Score="5" Body="&lt;p&gt;If the set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of nodes to be visited is not too large, you can solve &lt;span class=&quot;math-container&quot;&gt;$|S|$&lt;/span&gt; shortest path problems with additional constraints imposing a visit to some nodes.&lt;/p&gt;&#xA;&lt;p&gt;With your example, &lt;span class=&quot;math-container&quot;&gt;$|S|=|\{A,C \}|=2$&lt;/span&gt; so it is not too bad.  1/ Find the shortest path from &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, while imposing a visit to node &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;. 2/ Then find the shortest path from &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, while imposing a visit to node &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;. 3/ Compare the two solutions and keep the best one.&lt;/p&gt;&#xA;&lt;p&gt;The first case can be modeled as follows :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min \; \sum_{(i,j) \in E} T_{ij}x_{ij}$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{(i,j)\in E} x_{ij} &amp;amp;= \sum_{(j,i)\in E} x_{ji} \quad &amp;amp;\forall j \not \in \{O,A\} \tag{1}\\&#xA;\sum_{(O,j)\in E} x_{Oj} &amp;amp;= 1 \tag{2} \\&#xA;\sum_{(i,A)\in E} x_{iA} &amp;amp;= 1 \tag{3} \\&#xA;x_{ij} &amp;amp;\le y_j  &amp;amp; \forall (i,j) \in E \tag{4}\\&#xA;y_j &amp;amp;\le \sum_{(i,j)\in E} x_{ij} \quad &amp;amp;\forall j \in V \tag{5}\\&#xA;y_{C} &amp;amp;= 1 \tag{6} \\&#xA;y_i &amp;amp; \in \{0,1\} \quad &amp;amp;\forall j \in V \\&#xA;0 \le x_{ij} &amp;amp;\le 1 &amp;amp; \forall (i,j) \in E&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; are flow conservation constraints. Constraints &lt;span class=&quot;math-container&quot;&gt;$(2)-(3)$&lt;/span&gt; impose that the path starts at &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; and ends at &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;. Constraints &lt;span class=&quot;math-container&quot;&gt;$(4)-(5)$&lt;/span&gt; activates a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; when the associated node is visited, and constraints &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt; imposes a visit to node &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-04-29T12:52:07.143" LastActivityDate="2021-04-29T12:52:07.143" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6197" PostTypeId="1" AcceptedAnswerId="6216" CreationDate="2021-04-29T09:46:23.010" Score="0" ViewCount="95" Body="&lt;p&gt;I want to simulate the demand of a factory. This is not a real problem, the demand follows this relation &lt;span class=&quot;math-container&quot;&gt;$D= AB^2C^3$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; have &lt;strong&gt;normal distributions&lt;/strong&gt;: &lt;span class=&quot;math-container&quot;&gt;$$A\sim N(10,2.5),\quad B\sim(6,0.4),\quad C\sim(5,0.9).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have the covariance matrix of this problem which is &lt;span class=&quot;math-container&quot;&gt;$$\text{cov}_x=\begin{bmatrix}2.5&amp;amp;0.1&amp;amp;0.2\\0.1&amp;amp;0.4&amp;amp;0.3\\0.2&amp;amp;0.3&amp;amp;0.9\end{bmatrix}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The problems asks to&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Generate demand data in a non-correlated context and use &lt;strong&gt;eigenvalue&lt;/strong&gt; and &lt;strong&gt;eigenvector&lt;/strong&gt; for this.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fit these demands using the &lt;a href=&quot;https://en.wikipedia.org/wiki/Kumaraswamy_distribution&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kumaraswamy distribution&lt;/a&gt; function, which is &lt;span class=&quot;math-container&quot;&gt;$$Z= Z_\min + (Z_\max-Z_\min)(1-(1-F(Z))^{1/b})^{1/a}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I attach my code below. I don't know why this code has an error.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;clc&#xA;clear&#xA;cov_x=[2.5 0.1 0.2;0.1 0.4 0.3;0.2 0.3 0.9];&#xA;E_x=[10 6 5];&#xA;[V, landa]=eig(cov_x);&#xA;E_w=V'*E_x';&#xA;var_w= landa;&#xA;W=repmat(E_w,1,1000)+sqrt(var_w)*(randn(3,1000));&#xA;X=V*W;&#xA;A= X(1,:);  B= X(2,:);  C=X(3,:);&#xA;%D= A'*B.^2*C.^3';&#xA;for k=1:1000&#xA;   D(:,k)=A(:,k)'*B(:,k).^2*C(:,k).^3;&#xA;end&#xA;&#xA;%now we use kumara&#xA;Z=sort(D);&#xA;FZ= @(i)i/1001;&#xA;f=@(y,FDS) y(1)+((y(2)-y(1)).*((1-((1-FDS).^(1/y(3)))).^(1/ y(4))));&#xA;y0=[0.1 0.1 0.1 0.1];&#xA;y =lsqcurvefit(f,y0,FZ,Z)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is my error:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/6EPtH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6EPtH.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4306" LastEditorUserId="123" LastEditDate="2021-04-29T10:53:37.067" LastActivityDate="2021-05-02T19:36:18.167" Title="lsqcurvefit error in simulation of demands in MATLAB" Tags="|matlab|simulation|probability-distributions|demand-distribution|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6198" PostTypeId="2" ParentId="6192" CreationDate="2021-04-29T16:32:15.693" Score="3" Body="&lt;p&gt;I think this can be approached using a constraint generation technique (variant of Benders decomposition), although I have no idea if it would efficient. By reordering the rows of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, we can assume that &lt;span class=&quot;math-container&quot;&gt;$$b(z)=\left[\begin{array}{c}&#xA;\hat{b}\\ c+e-z \end{array}\right]$$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$\hat{b}\in\mathbb{R}^{d-m}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c\in \mathbb{R}^m$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$e=(1,\dots,1)^\prime \in \mathbb{R}^m$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z\in \lbrace 0,1 \rbrace^m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You start out minimizing &lt;span class=&quot;math-container&quot;&gt;$\parallel z\parallel_{0}$&lt;/span&gt; subject only to &lt;span class=&quot;math-container&quot;&gt;$z\in \lbrace 0,1 \rbrace^m$&lt;/span&gt;. Each time the solver finds what it thinks is a new incumbent &lt;span class=&quot;math-container&quot;&gt;$\tilde{z}$&lt;/span&gt; (satisfying all constraints added to that point), you solve the inequality &lt;span class=&quot;math-container&quot;&gt;$Ax\le b(\tilde{z})$&lt;/span&gt;. If the inequality is infeasible, accept the new incumbent and keep chugging along. If a feasible solution &lt;span class=&quot;math-container&quot;&gt;$\tilde{x}$&lt;/span&gt; is found, let &lt;span class=&quot;math-container&quot;&gt;$$A\tilde{x}=\left[\begin{array}{c} \tilde{u}\\ \tilde{v} \end{array}\right],$$&lt;/span&gt;noting that &lt;span class=&quot;math-container&quot;&gt;$\tilde{u}\le \hat{b}$&lt;/span&gt; (about which you can do nothing) and &lt;span class=&quot;math-container&quot;&gt;$\tilde{v}\le c + e - \tilde{z}$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$J=\lbrace j : \tilde{z}_j = 0  \land \tilde{v}_j &amp;gt; c_j\rbrace$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$J=\emptyset$&lt;/span&gt; you are screwed: there is no way to make &lt;span class=&quot;math-container&quot;&gt;$\tilde{x}$&lt;/span&gt; infeasible. Otherwise, you can add the constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j\in J} z_j \ge 1$$&lt;/span&gt;to the IP model, making &lt;span class=&quot;math-container&quot;&gt;$\tilde{z}$&lt;/span&gt; infeasible, and resume solving.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-04-29T16:32:15.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6199" PostTypeId="2" ParentId="6193" CreationDate="2021-04-29T18:03:02.567" Score="4" Body="&lt;p&gt;I think your third constraint should be + 1, not - 1, on the right hand side. As stated, it says you enter destination nodes one time &lt;em&gt;fewer&lt;/em&gt; than you exit them. You want to enter one time &lt;em&gt;more&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Fixing that will make the optimal solution feasible, but it will not make the model correct. There still remains the possibility of a solution that is not a contiguous trip. For instance, in your sample network, suppose that A, B, D and E are destinations. O-A-B D-E-D satisfies your constraints: O is exited once and never entered; the number of entries to destinations (4) exits the number of exits (3) by 1; and entries and exits at non-destination nodes are equal (both 0). With the right set of arc transit times, that &amp;quot;solution&amp;quot; could be optimal.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-04-29T18:03:02.567" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6200" PostTypeId="1" AcceptedAnswerId="6236" CreationDate="2021-04-29T18:47:29.063" Score="4" ViewCount="558" Body="&lt;p&gt;I have 10 tasks with 6 workers. Each worker can only serve one task at a time and must complete the task before moving on to the next task. Each worker has a maximum work output value and each task has an amount of work required. A worker can output work at any continuous value up to its maximum work output for any given minute. Each task (in units) need not begin at it's start time (in mins), but must be completed by its max_completion_time (in mins). We are trying to minimize overall workload across all workers at any given time.&lt;/p&gt;&#xA;&lt;p&gt;Maximum work output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Worker 1: {'max_work_output': 10 units per min, 'ramp_up': 5}&#xA;Worker 2: {'max_work_output': 10 units per min, 'ramp_up': 5}&#xA;Worker 3: {'max_work_output': 10 units per min, 'ramp_up': 5}&#xA;Worker 4: {'max_work_output': 10 units per min, 'ramp_up': 5}&#xA;Worker 5: {'max_work_output': 10 units per min, 'ramp_up': 5}&#xA;Worker 6: {'max_work_output': 50 units per min, 'ramp_up': 5}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Task work units needed, minimum start time, and maximum completion time:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Task 1:  {'work_needed': 3000 units, 'min_start_time': 0, 'max_completion_time': 600}&#xA;Task 2:  {'work_needed': 3600 units, 'min_start_time': 0, 'max_completion_time': 600}&#xA;Task 3:  {'work_needed': 1800 units, 'min_start_time': 5, 'max_completion_time': 600}&#xA;Task 4:  {'work_needed': 1200 units, 'min_start_time': 10, 'max_completion_time': 600}&#xA;Task 5:  {'work_needed': 3300 units, 'min_start_time': 15, 'max_completion_time': 600}&#xA;Task 6:  {'work_needed': 3000 units, 'min_start_time': 20, 'max_completion_time': 600}&#xA;Task 7:  {'work_needed': 3600 units, 'min_start_time': 30, 'max_completion_time': 600}&#xA;Task 8:  {'work_needed': 1800 units, 'min_start_time': 100, 'max_completion_time': 600}&#xA;Task 9:  {'work_needed': 1200 units, 'min_start_time': 100, 'max_completion_time': 600}&#xA;Task 10: {'work_needed': 3300 units, 'min_start_time': 120, 'max_completion_time': 600}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;when a worker changes it's output this can only be done at a maximum value of &lt;code&gt;ramp_up&lt;/code&gt;.&#xA;Objective:&#xA;What is the optimal schedule (which includes the work output at each minute from each worker) that minimizes the maximum sum of work across each worker?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The solution should be a 10 x 6 x 600 tensor that describes each worker's output at each minute for each task - where we minimize the sum of any matrix along the &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; dimension&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Wondering if there are any other examples of similar work or how this solution would be formalized/implemented.&lt;/p&gt;&#xA;" OwnerUserId="5422" LastEditorUserId="5422" LastEditDate="2021-05-24T05:16:25.927" LastActivityDate="2021-05-24T05:16:25.927" Title="Assignment and scheduling problem with resource constraints" Tags="|scheduling|assignment-problem|multicriteria-decision-analysis|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="6201" PostTypeId="1" AcceptedAnswerId="6202" CreationDate="2021-04-30T05:51:54.217" Score="5" ViewCount="521" Body="&lt;p&gt;I have the following sports scheduling problem.&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; teams and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; rounds, I define the binary decision variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{i,j,s} = \text{1 if team $i$ plays at home against team $j$ at round $s$, 0 otherwise}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and the constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;x_{i,i,s} &amp;amp;= 0\quad \forall i = 1,\ldots, n, s = 1,\ldots, m \tag{1} \\&#xA;\sum_{j=1}^{n} x_{i,j,s} + x_{j,i,s} &amp;amp;= 1 \quad \forall i=1,\ldots,n, s = 1,\ldots,m \tag{2} \\&#xA;\sum_{s=1}^{m} x_{i,j,s} + x_{j,i,s} &amp;amp;= 1 \quad \forall i,j=1,\ldots,n, i \neq j \tag{3} \\&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(1) ensures that no team plays againts itself, (2) that the match is either at team &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;'s home or at team's &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and (3) enforces that each team&#xA;plays against the other teams exactly once.&lt;/p&gt;&#xA;&lt;p&gt;I'd like to minimize the number of breaks. That is, if team &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&#xA;plays at home for two consecutive rounds, it has a break. The same holds true&#xA;for two consecutive away games. How can I minimize the number of breaks?&lt;/p&gt;&#xA;" OwnerUserId="5007" LastEditorUserId="123" LastEditDate="2021-04-30T06:55:56.193" LastActivityDate="2021-04-30T08:53:45.530" Title="How to minimize the number of breaks in sports scheduling?" Tags="|modeling|scheduling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6202" PostTypeId="2" ParentId="6201" CreationDate="2021-04-30T06:29:53.627" Score="8" Body="&lt;p&gt;If I understood you correctly, you could do it like this (assuming that &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is even and &lt;span class=&quot;math-container&quot;&gt;$m = n-1$&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;First, add the binary variables&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;h_{is} &amp;amp;= \begin{cases} 1, &amp;amp;\text{if team $i$ plays at home in round $s$ and $s-1$}, \\ 0, &amp;amp;\text{otherwise}, \end{cases} \\\\&#xA;%&#xA;a_{is} &amp;amp;= \begin{cases} 1, &amp;amp;\text{if team $i$ plays away in round $s$ and $s-1$}, \\ 0, &amp;amp;\text{otherwise} \end{cases}&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for all teams &lt;span class=&quot;math-container&quot;&gt;$i = 1, \ldots, n$&lt;/span&gt; and rounds &lt;span class=&quot;math-container&quot;&gt;$s = 2, \ldots, m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In order to count the number of breaks, we need to formulate the following&#xA;if-then constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\sum_{j=1}^{n} x_{i,j,s-1} + x_{i, j, s} &amp;amp;= 2 \implies h_{i,s} = 1, \quad\forall i=1,\ldots,n, s=2,\ldots,m,\\&#xA;\sum_{j=1}^{n} x_{j,i,s-1} + x_{j, i, s} &amp;amp;= 2 \implies a_{i,s} = 1, \quad\forall i=1,\ldots,n, s=2,\ldots,m.\\&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This can be done as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\sum_{j=1}^{n} x_{i,j,s-1} + x_{i,j,s} &amp;amp;\leq 1 + h_{i,s} \quad\forall i=1,..,n, s=2,...,m, \\&#xA;\sum_{j=1}^{n} x_{j,i,s-1} + x_{j,i,s} &amp;amp;\leq 1 + a_{i,s}, \quad\forall i=1,...n, s=2,...,m.&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Consequently, we can minimize the number of breaks by setting the objective function&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \quad \sum_{i=1}^{n} \sum_{s = 2}^{m} h_{i,s} + a_{i,s} .&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="3696" LastEditDate="2021-04-30T08:44:13.887" LastActivityDate="2021-04-30T08:44:13.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6203" PostTypeId="2" ParentId="6201" CreationDate="2021-04-30T08:53:45.530" Score="7" Body="&lt;p&gt;joni's answer is correct. However, this formulation will not allow you to find an optimal solution for anything more than 10-12 teams, even without any additional typical sports scheduling constraints. If you aren't using a commercial solver, the limit is even lower.&lt;/p&gt;&#xA;&lt;p&gt;There is an excellent book about round robin scheduling by Dirk Briskorn. It is a must-read if you are interested in sports scheduling: &lt;a href=&quot;https://www.springer.com/gp/book/9783540755173&quot; rel=&quot;noreferrer&quot;&gt;https://www.springer.com/gp/book/9783540755173&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are chapters about theoretical limits of number of breaks and also suggests alternative methods that are worth looking into. If your main goal is to minimize the number of breaks and you don't have too many side constraints, I suggest you take a look at the &amp;quot;first-break-then-schedule&amp;quot; method.&lt;/p&gt;&#xA;&lt;p&gt;Btw. in reality, none of the methods that you will find in literature are powerful/ sophisticated enough to solve larger (&amp;gt;20 teams) league scheduling problems. The methods that are used in reality are mostly trade secrets of the companies that do this type of work. Nevertheless, Briskorn's book is a good starting point and contains many valuable references to other papers and publications.&lt;/p&gt;&#xA;" OwnerUserId="4030" LastActivityDate="2021-04-30T08:53:45.530" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6204" PostTypeId="1" AcceptedAnswerId="6206" CreationDate="2021-04-30T11:27:47.493" Score="2" ViewCount="323" Body="&lt;p&gt;How to convert the following primal problem into its dual problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_{x,z}&amp;amp;\quad a^\top x + b^\top z\\\text{s.t.}&amp;amp;\quad Ax-d \le Cz \\&amp;amp;\quad x\ge 0, z \le 0.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I first attempted to convert it to canonical where the decision variables are all positive and the constraint is a less than constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_{x,z}&amp;amp;\quad a^\top x - b^\top z\\\text{s.t.}&amp;amp;\quad -Ax-Cz\ge-d \\&amp;amp;\quad x,z\ge0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for which the dual problem should be&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max&amp;amp;\quad-d^\top y\\\text{s.t.}&amp;amp;\quad(-A)^\top y\le a\\&amp;amp;\quad(-C)^\top y\le b\\&amp;amp;\quad y\ge0.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The correct answer is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max&amp;amp;\quad d^\top y\\\text{s.t.}&amp;amp;\quad A^\top y\le a\\&amp;amp;\quad-C^\top y\ge b\\&amp;amp;\quad y\le0.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I guess my problem is when trying to write the original problem in canonical form?&lt;/p&gt;&#xA;" OwnerUserId="5423" LastEditorUserId="123" LastEditDate="2021-05-01T09:34:45.897" LastActivityDate="2021-05-01T09:34:45.897" Title="Finding the dual problem of a minimum problem" Tags="|duality|dual|primal|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6205" PostTypeId="2" ParentId="6193" CreationDate="2021-04-30T15:22:10.320" Score="3" Body="&lt;p&gt;you could try &lt;a href=&quot;https://www.slideshare.net/PhilippeLaborie/planningscheduling-with-cp-optimizer&quot; rel=&quot;nofollow noreferrer&quot;&gt;constraint programming / scheduling&lt;/a&gt; within CPLEX and use noOverlap to model the time matrix.&lt;/p&gt;&#xA;&lt;p&gt;In OPL that gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using CP;&#xA;&#xA;execute&#xA;{&#xA;  cp.param.timelimit=10;&#xA;}&#xA;&#xA;{string} nodes={&amp;quot;O&amp;quot;,&amp;quot;A&amp;quot;,&amp;quot;B&amp;quot;,&amp;quot;C&amp;quot;,&amp;quot;D&amp;quot;,&amp;quot;E&amp;quot;,&amp;quot;T&amp;quot;};&#xA;&#xA;tuple edge&#xA;{&#xA;  key string o;&#xA;  key string d;&#xA;  int time;&#xA;}&#xA;&#xA;{edge} edges with o,d in nodes=&#xA;{&#xA;  &amp;lt;&amp;quot;O&amp;quot;,&amp;quot;A&amp;quot;,40&amp;gt;,&#xA;  &amp;lt;&amp;quot;O&amp;quot;,&amp;quot;B&amp;quot;,60&amp;gt;,&#xA;  &amp;lt;&amp;quot;O&amp;quot;,&amp;quot;C&amp;quot;,50&amp;gt;,&#xA;  &amp;lt;&amp;quot;A&amp;quot;,&amp;quot;B&amp;quot;,10&amp;gt;,&#xA;  &amp;lt;&amp;quot;C&amp;quot;,&amp;quot;B&amp;quot;,20&amp;gt;,&#xA;  &amp;lt;&amp;quot;A&amp;quot;,&amp;quot;D&amp;quot;,70&amp;gt;,&#xA;  &amp;lt;&amp;quot;B&amp;quot;,&amp;quot;D&amp;quot;,55&amp;gt;,&#xA;  &amp;lt;&amp;quot;B&amp;quot;,&amp;quot;E&amp;quot;,40&amp;gt;,&#xA;  &amp;lt;&amp;quot;D&amp;quot;,&amp;quot;E&amp;quot;,10&amp;gt;,&#xA;  &amp;lt;&amp;quot;D&amp;quot;,&amp;quot;T&amp;quot;,60&amp;gt;,&#xA;  &amp;lt;&amp;quot;E&amp;quot;,&amp;quot;T&amp;quot;,80&amp;gt;&#xA;};&#xA;&#xA;string origin=&amp;quot;O&amp;quot;;&#xA;{string} targets={&amp;quot;A&amp;quot;,&amp;quot;C&amp;quot;};&#xA;int bigvalue=1000;&#xA;int repeat=3;&#xA;range ranks=1..repeat;&#xA;&#xA;{edge} edgeswithsym=edges union {&amp;lt;d,o,t&amp;gt; | &amp;lt;o,d,t&amp;gt; in edges};&#xA;&#xA;{edge} transitions=edgeswithsym union {&amp;lt;o,d,bigvalue&amp;gt; | o,d in nodes: &amp;lt;o,d&amp;gt; not in edgeswithsym};&#xA;&#xA;tuple triplet {int id1; int id2; int value;};&#xA;{triplet} M = {&amp;lt;ord(nodes,tr.o)+1,ord(nodes,tr.d)+1,tr.time&amp;gt; | tr in transitions};&#xA;&#xA;assert card(transitions)==card(nodes)*(card(nodes));&#xA;&#xA;// Interval for visiting a node&#xA;dvar interval itvs[nodes][ranks] optional;&#xA;&#xA;// Sequence means visits&#xA;dvar sequence seq in all(n in nodes,r in ranks)itvs[n][r] types &#xA;all(n in nodes,r in ranks)(ord(nodes,n)+1); &#xA;&#xA;// First we want to minimize the time for latest visit&#xA;// Second we want to minimize present intervals&#xA;minimize &#xA;staticLex(max(t in targets) min(r in ranks) startOf(itvs[t,r],bigvalue),&#xA;sum(n in nodes,r in ranks) presenceOf(itvs[n][r]));&#xA;subject to&#xA;{&#xA;  // We visit origin at time 0&#xA;  startOf(itvs[origin,1])==0;&#xA;  &#xA;  // origin and destinations should be present&#xA;  presenceOf(itvs[origin,1])==1;&#xA;  forall(t in targets) presenceOf(itvs[t,1])==1;&#xA;  &#xA;  // noOverlap constraint will enforce time matrix&#xA;  noOverlap(seq,M,true);&#xA;  &#xA;  // break sym&#xA;  forall(n in nodes) forall(r in ranks:r!=1) &#xA;    presenceOf(itvs[n,r-1])&amp;gt;=presenceOf(itvs[n,r]);&#xA;  &#xA;}&#xA;&#xA;int nbActiveIntervals=sum(n in nodes,r in ranks) presenceOf(itvs[n][r]);&#xA;range R=1..nbActiveIntervals;&#xA;&#xA;// Display solution&#xA;execute {&#xA;  &#xA;&#xA;  writeln(origin);&#xA;  var s=seq.first(); &#xA;  for(var i in R) &#xA;  {&#xA;   if (i!=nbActiveIntervals)&#xA;      writeln(Opl.item(nodes,-1+Opl.typeOfNext(seq,s,bigvalue,0)));&#xA;   s=seq.next(s); &#xA;   &#xA;  } &#xA;   &#xA;}&#xA;&#xA;/*&#xA;&#xA;gives&#xA;&#xA;O&#xA;A&#xA;B&#xA;C&#xA;&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-04-30T15:22:10.320" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6206" PostTypeId="2" ParentId="6204" CreationDate="2021-04-30T20:56:46.323" Score="2" Body="&lt;h3&gt;Primal Problem&lt;/h3&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\text{minimize} \quad &amp;amp; \sum_{i=1}^n a_i x_i  + \sum_{i=1}^n b_i z_i  \\\&#xA;\text{subject to} \quad &amp;amp; A\mathbf x-\mathbf d \le C\mathbf z \\&#xA;&amp;amp; x_i \ge 0 \quad \forall i=1,\ldots,n \\&#xA;&amp;amp; z_i \le 0 \quad \forall i=1,\ldots,n&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;strong&gt;dual formulation&lt;/strong&gt; of the primal problem can be obtained by writing the &lt;em&gt;Lagrangian function&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; of the primal problem and connecting heuristically such a function to the &lt;em&gt;minimax theorem&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$$\max_\mathbf y \min_{\mathbf x,\mathbf z} L(\mathbf x,\mathbf z,\mathbf y) = \min_{\mathbf x,\mathbf z} \max_\mathbf y  L(\mathbf x,\mathbf z,\mathbf y)$$&lt;/span&gt; proven by John von Neumann.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;em&gt;Lagrangian function&lt;/em&gt; to be considered is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$L(\mathbf x,\mathbf z,\mathbf y) = \langle\mathbf a, \mathbf x\rangle  + \langle \mathbf b, \mathbf z\rangle &#xA;+ \langle\mathbf y, A\mathbf x-\mathbf d - C\mathbf z\rangle$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the notation &lt;span class=&quot;math-container&quot;&gt;$\langle\cdot,\cdot\rangle$&lt;/span&gt; indicates the scalar product between two vectors and &lt;span class=&quot;math-container&quot;&gt;$ \mathbf y = (y_1, y_2, \ldots, y_m)$&lt;/span&gt; are &lt;em&gt;Lagrange multipliers&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Recall the identity &lt;span class=&quot;math-container&quot;&gt;$\langle \mathbf v, A\mathbf w\rangle = \langle A^\top\mathbf v, \mathbf w\rangle$&lt;/span&gt;. Taking advantage of the linearity of the dot product, and putting in the evidence variable &lt;span class=&quot;math-container&quot;&gt;$\mathbf x$&lt;/span&gt; and the variable &lt;span class=&quot;math-container&quot;&gt;$\mathbf z$&lt;/span&gt;, we get&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}L(\mathbf x,\mathbf z,\mathbf y) &amp;amp;= \langle\mathbf a,\mathbf x \rangle + \langle\mathbf b,\mathbf z\rangle +\langle\mathbf y,A\mathbf x\rangle - \langle\mathbf y, \mathbf d\rangle - \langle\mathbf y, C\mathbf z\rangle\\&amp;amp;=\langle\mathbf a,\mathbf x \rangle + \langle\mathbf b,\mathbf z\rangle - \langle\mathbf y, \mathbf d\rangle + \langle A^\top\mathbf y,\mathbf x\rangle - \langle C^\top\mathbf y,\mathbf z\rangle\\&amp;amp;=-\langle\mathbf y, \mathbf d\rangle + \langle A^\top\mathbf y + \mathbf a,\mathbf x\rangle + \langle-C^\top\mathbf y + \mathbf b,\mathbf z\rangle.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Minimizing &lt;span class=&quot;math-container&quot;&gt;$L(\mathbf x,\mathbf z,\mathbf y)$&lt;/span&gt; with respect to variables &lt;span class=&quot;math-container&quot;&gt;$\mathbf x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf z$&lt;/span&gt; is equivalent considering simultaneously the minimum of &lt;span class=&quot;math-container&quot;&gt;$\langle A^\top\mathbf y + \mathbf a,\mathbf x\rangle$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\langle-C^\top\mathbf y + \mathbf b,\mathbf z\rangle$&lt;/span&gt;. This minimum is finite and equal to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$A^\top\mathbf y + \mathbf a \ge 0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\mathbf x\ge 0 $&lt;/span&gt; and&#xA;&lt;span class=&quot;math-container&quot;&gt;$\mathbf b - C^\top\mathbf y \le 0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\mathbf z\le 0 $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The dual problem associated with the Lagrangian is by definition&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \max_\mathbf y \min_{\mathbf x,\mathbf z} L(\mathbf x,\mathbf z,\mathbf y).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In order to obtain an explicit description of the dual problem we minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \min\limits_{\mathbf x,\mathbf z} L(\mathbf x,\mathbf z,\mathbf y)$&lt;/span&gt;&#xA;with respect to  &lt;span class=&quot;math-container&quot;&gt;$\mathbf x $&lt;/span&gt; and  &lt;span class=&quot;math-container&quot;&gt;$\mathbf z $&lt;/span&gt;. Fixing &lt;span class=&quot;math-container&quot;&gt;$\mathbf y $&lt;/span&gt;, we get&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{\mathbf x,\mathbf z} L(\mathbf x,\mathbf z,\mathbf y)=-\langle\mathbf y, \mathbf d\rangle + \min_{\mathbf x,\mathbf z} [\langle A^\top\mathbf y + \mathbf a,\mathbf x\rangle + \langle-C^\top\mathbf y + \mathbf b,\mathbf z\rangle]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and therefore&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{\mathbf x \ge 0,\mathbf z \le 0} L(\mathbf x,\mathbf z,\mathbf y) = &#xA;\left\{\begin{align}&#xA;\begin{matrix} &#xA;-\langle\mathbf y, \mathbf d\rangle&amp;amp;\mbox{ if } A^\top\mathbf y + \mathbf a \ge 0 \mbox{ and } \mathbf b - C^\top\mathbf y \le 0 \\&#xA;-\infty&amp;amp;\mbox{otherwise} &#xA;\end{matrix}\end{align}&#xA;\right.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The dual objective function is therefore expressed as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{\mathbf y \ge 0} L(\mathbf x,\mathbf z,\mathbf y) = \max [-\langle\mathbf y, \mathbf d\rangle].$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Dual Problem&lt;/h3&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\text{maximize} \quad &amp;amp; \sum_{j=1}^m -d_j y_j \\\&#xA;\text{subject to} \quad &amp;amp; A^\top\mathbf y + \mathbf a \ge 0 \\&#xA;\quad &amp;amp; \mathbf b - C^\top\mathbf y \le 0 \\&#xA;&amp;amp; y_j \ge 0 \quad \forall j=1,\ldots,m \\&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf y'= - \mathbf y$&lt;/span&gt;, then we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\text{maximize} \quad &amp;amp; \sum_{j=1}^m d_j y'_j \\\&#xA;\text{subject to} \quad &amp;amp; A^\top\mathbf y' \le \mathbf a \\&#xA;\quad &amp;amp; -C^\top\mathbf y' \ge \mathbf b \\&#xA;&amp;amp; y'_j \le 0 \quad \forall j=1,\ldots,m \\&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4114" LastEditorUserId="123" LastEditDate="2021-05-01T09:29:55.197" LastActivityDate="2021-05-01T09:29:55.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6207" PostTypeId="1" CreationDate="2021-04-30T21:30:06.100" Score="2" ViewCount="203" Body="&lt;p&gt;I'm modeling an LP problem in which I have to maximize an objective function. Two of the constraints are the following, where &lt;span class=&quot;math-container&quot;&gt;$k_i$&lt;/span&gt; are constants and &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; decision variables (continuous). Could anyone help me on how to linearize these constraints?&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{max}{[(x_1 + k_1), (x_2 + x_3 + x_4)]} &amp;amp;\leq k_2\\&#xA;\text{min}{[(x_1 + k_1), (x_2 + x_3 + x_4)]} &amp;amp;\geq -k_2&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5407" LastEditorUserId="123" LastEditDate="2021-05-01T09:36:00.877" LastActivityDate="2021-05-01T09:36:00.877" Title="How to linearize inequalities having max or min?" Tags="|linear-programming|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6208" PostTypeId="2" ParentId="6207" CreationDate="2021-04-30T22:03:41.687" Score="8" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max(y,z)\le b$&lt;/span&gt; is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y&amp;amp;\le b\\&#xA;z&amp;amp;\le b&#xA;\end{align}&lt;/span&gt;&#xA;The &lt;span class=&quot;math-container&quot;&gt;$\min$&lt;/span&gt; constraint is similar.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-04-30T22:03:41.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6209" PostTypeId="1" CreationDate="2021-05-01T12:17:40.630" Score="1" ViewCount="346" Body="&lt;p&gt;How can I find out which method or algorithm was used to solve my model? When I use &lt;code&gt;GRB.IntParam.Method-&lt;/code&gt; to output the method, I get &lt;code&gt;-1&lt;/code&gt; for the automatic method.&lt;/p&gt;&#xA;&lt;p&gt;I have a quadratic objective function with quadratic constraints and PWL constructs, so I had to set the model to &amp;quot;Non-Convex&amp;quot;. So I would also like to know if I consequently have a QP, QCP, MIQP, or MIQCP.&lt;/p&gt;&#xA;" OwnerUserId="5092" LastEditorUserId="123" LastEditDate="2021-05-01T15:34:46.610" LastActivityDate="2021-05-01T19:16:53.813" Title="Method (Algorithm) and Objective used in Gurobi Model" Tags="|gurobi|algorithms|quadratic-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6210" PostTypeId="1" CreationDate="2021-05-01T13:52:44.547" Score="6" ViewCount="129" Body="&lt;p&gt;A problem I study reduces to whether the polyhedron &lt;span class=&quot;math-container&quot;&gt;$P=\{\mathbf{x}\mid A\mathbf{x}=\mathbf{1}, \mathbf{x}\geq0\}$&lt;/span&gt; is integral (&lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a matrix with coefficients in &lt;span class=&quot;math-container&quot;&gt;$\{0,1\}$&lt;/span&gt;). I know that the unimodularity of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a sufficient condition, which has been useful for me. I want to know whether there is any weaker condition.&lt;/p&gt;&#xA;&lt;p&gt;I read from a textbook that &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is integral if the system &lt;span class=&quot;math-container&quot;&gt;$A\mathbf{x}=\mathbf{1}, \mathbf{x}\geq0$&lt;/span&gt; is totally dual integral (TDI), i.e., the minimum in&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max\{\mathbf{c}^T\mathbf{x}\mid A\mathbf{x}=\mathbf{1}, \mathbf{x}\geq0\}=\min\{\mathbf{y}^T\cdot\mathbf{1}\mid \mathbf{y}^TA\geq \mathbf{c}^T\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;has an integral optimum solution &lt;span class=&quot;math-container&quot;&gt;$\mathbf{y}$&lt;/span&gt; for each integral &lt;span class=&quot;math-container&quot;&gt;$\mathbf{c}$&lt;/span&gt; for which the minimum is finite.&lt;/p&gt;&#xA;&lt;p&gt;This definition is too abstract for me. I wonder whether there is any characterization for this condition that I can use directly.&lt;/p&gt;&#xA;" OwnerUserId="4123" LastEditorUserId="4123" LastEditDate="2021-05-02T10:44:48.610" LastActivityDate="2021-05-02T10:44:48.610" Title="Characterization for total dual integrality" Tags="|integer-programming|combinatorial-optimization|polyhedra|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6211" PostTypeId="1" CreationDate="2021-05-01T16:02:12.163" Score="2" ViewCount="370" Body="&lt;p&gt;I want to get the lagrange multipliers for an LP problem solution calculated using CPLEX. I am using it via Python.&lt;/p&gt;&#xA;&lt;p&gt;The problem is an LP problem with continuous variables with a linear objective function and elements of solution vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are linearly constrained to be in the interval &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt;. Here are the main cplex calls.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;my_prob = cplex.Cplex()&#xA;my_prob.objective.set_sense(my_prob.objective.sense.minimize)&#xA;my_prob.variables.add(obj=my_obj,&#xA;                      lb=my_lb,&#xA;                      ub=my_ub,&#xA;                      names=my_colNames)&#xA;&#xA;my_prob.linear_constraints.add(lin_expr=my_rows,&#xA;                               senses=my_sense,&#xA;                               rhs=my_rhs)&#xA;&#xA;my_prob.solve()&#xA;x = my_prob.solution.get_values()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; contains the solution. I want to know what function returns the Lagrange multipliers of the solution. I now think the answer is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;l = my_prob.solution.get_dual_values()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Can someone please confirm.&lt;/p&gt;&#xA;" OwnerUserId="5156" LastEditorUserId="5156" LastEditDate="2022-12-04T20:19:26.867" LastActivityDate="2022-12-05T09:18:30.600" Title="Accessing Lagrange Multipliers in CPLEX" Tags="|optimization|cplex|cplex-python-api|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6212" PostTypeId="2" ParentId="6211" CreationDate="2021-05-01T17:24:47.790" Score="3" Body="&lt;p&gt;First of all, you should determine the sign of the multipliers based on the objective function direction and how the complicating constraints are violated. Then you have to use a standard method like subgradient optimization to solve the lagrangian dualized problem to determine the optimal value of the multipliers. For more details:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;Marshall L. Fisher, An applications-oriented guide to lagrangian relaxation, Interfaces 15(1985), no. 2, 10-21.&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Richard Kipp Martin, Large scale linear and integer optimization; a unified approach, Kluwer,1999.&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Fundamentals of Supply Chain Theory by Lawrence V. Snyder.&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-05-01T17:24:47.790" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6213" PostTypeId="2" ParentId="6209" CreationDate="2021-05-01T19:16:53.813" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;IsQP&lt;/code&gt;, &lt;code&gt;IsQCP&lt;/code&gt; to see the type of your model as follow:&lt;/p&gt;&#xA;&lt;p&gt;Let's sat your model called &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.update()&#xA;qp = m.IsQP&#xA;qcp = m.IsQCP&#xA;print(qp)&#xA;print(qcp)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The output will be a binary value which indicates that your model is QP if &lt;span class=&quot;math-container&quot;&gt;$qp =1$&lt;/span&gt; or your model is a QCP if &lt;span class=&quot;math-container&quot;&gt;$qcp = 1$&lt;/span&gt;. You should also use the following code to set the model as non-convex:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.setParam('NonConvex', 2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that all these codes are good for Python API of Gurobi. Based on Gurobi website: &amp;quot;With setting 2, non-convex quadratic problems are solved by means of translating them into bilinear form and applying spatial branching.&amp;quot;&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-05-01T19:16:53.813" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6214" PostTypeId="1" AcceptedAnswerId="6376" CreationDate="2021-05-02T10:28:27.680" Score="1" ViewCount="79" Body="&lt;p&gt;While doing some reading on the power system resource adequacy studies I have noticed that the standard (baseline?) model for generation availability is the two state model - assumes two possible capacities, zero and maximum. It also requires that the capacities from different units are independent. While I think I get the independence reasoning for conventional and wind/hydro generation and why sometimes it cannot be achieved (e.g. wind capacities at different locations might be driven by the same weather systems - it can be windy or calm in the whole power system at some time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;). I have a problem understanding the logic behind using two state model.&lt;/p&gt;&#xA;&lt;p&gt;The papers are quite advanced and they talk about more complicated scenarios and thus, authors do not explain the two state model assumptions in detail. From what I have seen there's usually just something along the lines: &amp;quot;generating units are usually represented by a two state model&amp;quot; or &amp;quot;two-state model is well suited for modeling conventional generators&amp;quot;. But I haven't been able to find a proper answer to WHY the two state model is justified here.&lt;/p&gt;&#xA;&lt;p&gt;My question is whether the assumption of operating under two states, zero and maximum, is justified for conventional and unconventional generation. It might be super obvious but I just can't see why this is true.&lt;/p&gt;&#xA;" OwnerUserId="4465" LastActivityDate="2021-06-01T20:00:40.930" Title="Generation capacity adequacy assessment - intuition behind two state model" Tags="|energy|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6216" PostTypeId="2" ParentId="6197" CreationDate="2021-05-02T19:36:18.167" Score="1" Body="&lt;p&gt;My professor helped me for solving this error like below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;clc&#xA;clear&#xA;cov_x=[2.5 0.1 0.2;0.1 0.4 0.3;0.2 0.3 0.9];&#xA;E_x=[10 6 5];&#xA;[V, landa]=eig(cov_x);&#xA;E_w=V'*E_x';&#xA;var_w= landa;&#xA;W=repmat(E_w,1,1000)+sqrt(var_w)*(randn(3,1000));&#xA;X=V*W;&#xA;A= X(1,:);  B= X(2,:);  C=X(3,:);&#xA;%D= A'*B.^2*C.^3';&#xA;for k=1:1000&#xA;   D(:,k)=A(:,k)'*B(:,k).^2*C(:,k).^3;&#xA;end&#xA; &#xA;%now we use komara&#xA;Z=sort(D);&#xA;i=1:1000;&#xA;FZ=@(i)i/1001;&#xA; &#xA;f=@(y,Ramin)y(1)+((y(2)-y(1)).*((1-((1-Ramin).^(1/y(3)))).^(1/ y(4))));&#xA;y0=[0.1 0.1 0.1 0.1];&#xA;&#xA;y =lsqcurvefit(f,y0,FZ(i),Z)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;this code has not a error.&lt;/p&gt;&#xA;" OwnerUserId="4306" LastActivityDate="2021-05-02T19:36:18.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6218" PostTypeId="2" ParentId="3991" CreationDate="2021-05-03T14:54:50.337" Score="1" Body="&lt;p&gt;&lt;code&gt;Eq(h) .. e(h) =e= E0 - sum(t$(ord(t) &amp;lt;=Ord(h) ), pd(t)+n*sum(t, pc(t));&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;It's better to define &lt;code&gt;E0&lt;/code&gt; as a scalar in GAMS.&#xA;you should also define alias(h,t);&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2021-05-14T21:09:33.143" LastActivityDate="2021-05-14T21:09:33.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6219" PostTypeId="2" ParentId="5866" CreationDate="2021-05-03T14:57:41.563" Score="-2" Body="&lt;pre&gt;&lt;code&gt;eq(t) .. y(i,t) + sum(t $(ord(k)&amp;lt;=t+1 and ord(k)&amp;lt;= ord(t)+gendata(i,&amp;quot;U&amp;quot;)-1)  ,z(i,k)) =l= 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Just make sure that k is a subset of t&#xA;This way&#xA;alias(k,t);&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2021-05-05T08:44:41.403" LastActivityDate="2021-05-05T08:44:41.403" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6220" PostTypeId="1" AcceptedAnswerId="6221" CreationDate="2021-05-04T08:22:41.483" Score="3" ViewCount="255" Body="&lt;p&gt;I have the following question:&lt;/p&gt;&#xA;&lt;p&gt;I have a non-convex QCP model. In the parameter description for method it says that &amp;quot;Only barrier is available for continuous QCP models&amp;quot;. However, the dual simplex algorithm (i.e. method 1) is used automatically. Does my model become MIQCP by setting NonConvex = 2 or how can I understand this?&lt;/p&gt;&#xA;" OwnerUserId="5092" LastActivityDate="2021-05-04T16:28:19.157" Title="Non-Convex QCP model - Used Method in Gurobi" Tags="|optimization|gurobi|nonconvex-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6221" PostTypeId="2" ParentId="6220" CreationDate="2021-05-04T10:23:46.637" Score="2" Body="&lt;p&gt;I'm not familiar with what GUROBI does exactly, but continuous non-convex QCPs are solved using continuous branch-and-bound. This involves generating a linear relaxation of the problem which is solved at every node of the BnB tree, along with local optimisation of QCPs to get primal solutions (until we hit the global optimum).&lt;/p&gt;&#xA;&lt;p&gt;The linear relaxations would typically be solved using Dual Simplex.&lt;/p&gt;&#xA;&lt;p&gt;An interesting special case is if your QCP has complementarity constraints, which solvers typically (but not always) transform to MI linear constraints. Depending on the outcome, the problem can be fully linearised, in which case it's solved as an MILP, or partially linearised, in which case it's solved as an MIQCP.&lt;/p&gt;&#xA;&lt;p&gt;From GUROBI's manual however, it's quite clear:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In the current release, the default Automatic (-1) setting will&#xA;typically choose non-deterministic concurrent (Method=3) for an LP,&#xA;&lt;strong&gt;barrier (Method=2) for a QP or QCP&lt;/strong&gt;, and dual (Method=1) for the MIP&#xA;root node. Only the simplex and barrier algorithms are available for&#xA;continuous QP models. Only primal and dual simplex are available for&#xA;solving the root of an MIQP model. &lt;strong&gt;Only barrier is available for&#xA;continuous QCP models&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;They specifically say that only barrier is available for continuous QCP, and that Automatic mode will select barrier (Method=2) for those problems.&lt;/p&gt;&#xA;&lt;p&gt;Even though it doesn't say so, I would expect it to use Dual Simplex if the QCP problem has e.g. complementarity constraints and is transformed to an MILP.&lt;/p&gt;&#xA;&lt;p&gt;Generally speaking, if you see that Dual Simplex was used in the output, it most likely means that it reformulated your problem to an MILP by exploiting special structure.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-05-04T16:28:19.157" LastActivityDate="2021-05-04T16:28:19.157" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6222" PostTypeId="1" AcceptedAnswerId="6223" CreationDate="2021-05-04T13:59:49.973" Score="2" ViewCount="193" Body="&lt;p&gt;I have the objective function (Maximally Diverse Grouping Problem) as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max\sum_{g=1}^G\sum_{i=1}^{N-1}\sum_{j=i+1}^{N}d_{ij}x_{ig}x_{jg}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; are known parameters, and &lt;span class=&quot;math-container&quot;&gt;$x_{ig}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{jg}$&lt;/span&gt; are binary variables.&lt;/p&gt;&#xA;&lt;p&gt;It is nonlinear as we have the bilinear term, &lt;span class=&quot;math-container&quot;&gt;$x_{ig}x_{jg}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Linearization Technique 1&lt;/h3&gt;&#xA;&lt;p&gt;We can linearise it by introducing an binary variable &lt;span class=&quot;math-container&quot;&gt;$z_{ijg}=x_{ig}x_{jg}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}z_{ijg} &amp;amp;\le x_{ig}\\z_{ijg} &amp;amp;\le x_{jg}\\z_{ijg}&amp;amp;\ge x_{ig}+x_{jg}-1\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, the new objection function becomes&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max\sum_{g=1}^G\sum_{i=1}^{N-1}\sum_{j=i+1}^{N}d_{ij}z_{ijg}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Linearization Technique 2&lt;/h3&gt;&#xA;&lt;p&gt;I do not introduce any extra variables. Instead I rewrite the objective function as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max\sum_{g=1}^G\sum_{i=1}^{N-1}\sum_{j=i+1}^{N}d_{ij}(x_{ig}+x_{jg}-1)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2021-05-05T08:56:45.193" LastActivityDate="2021-05-05T08:56:45.193" Title="Which linearisation technique is correct?" Tags="|linearization|nonlinear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6223" PostTypeId="2" ParentId="6222" CreationDate="2021-05-04T15:18:04.193" Score="10" Body="&lt;p&gt;They are equivalent except when &lt;span class=&quot;math-container&quot;&gt;$x_{i,g}=x_{j,g}=0$&lt;/span&gt;, in which case the second linearization incorrectly contributes &lt;span class=&quot;math-container&quot;&gt;$-d_{ij}$&lt;/span&gt; to the objective.&lt;/p&gt;&#xA;&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$d_{ij} \ge 0$&lt;/span&gt;, I recommend a third linearization (relaxing &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and omitting two constraints from linearization 1):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z_{ijg}&amp;amp;\ge x_{ig}+x_{jg}-1 \\&#xA;z_{ijg}&amp;amp;\ge 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-05-04T15:18:04.193" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6224" PostTypeId="2" ParentId="5172" CreationDate="2021-05-04T21:42:45.863" Score="4" Body="&lt;p&gt;I recommend you to try very powerful utility LRS, &lt;a href=&quot;http://cgm.cs.mcgill.ca/%7Eavis/C/lrs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://cgm.cs.mcgill.ca/~avis/C/lrs.html&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It is an open source application (a set of applications) to handle polyhedrals. B.t.w. one of LRS applications, called &lt;strong&gt;redund&lt;/strong&gt; &amp;quot;removes redundant inequalities from an H-representation&amp;quot; (from description) - seems that what you need. There are parallel (MPI-based) versions for clusters and multiprocessor computers, as well.&lt;/p&gt;&#xA;&lt;p&gt;If you are Linux user you can find LRS in standard repositories. Anyway, open sources (in C) are available for &amp;quot;manual&amp;quot; built.&lt;/p&gt;&#xA;" OwnerUserId="5445" LastEditorUserId="5445" LastEditDate="2021-05-30T22:42:56.080" LastActivityDate="2021-05-30T22:42:56.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6226" PostTypeId="1" AcceptedAnswerId="6229" CreationDate="2021-05-05T07:17:05.443" Score="1" ViewCount="92" Body="&lt;p&gt;In my optimization model, I use piecewise-linear constraints with the output of &lt;span class=&quot;math-container&quot;&gt;$y[m]$&lt;/span&gt;. The question or problem I have now is whether there is a way in Gurobi (Java) to form the integral for this PWL in my objective function, from &lt;span class=&quot;math-container&quot;&gt;$-20$&lt;/span&gt; to my &lt;span class=&quot;math-container&quot;&gt;$x[m]$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x[m]$&lt;/span&gt; is my optimization variable. I need the area between the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;-axis and the PWL constraint, where &lt;span class=&quot;math-container&quot;&gt;$y[m]$&lt;/span&gt; is always &lt;span class=&quot;math-container&quot;&gt;$\ge0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5092" LastEditorUserId="123" LastEditDate="2021-05-05T08:39:18.963" LastActivityDate="2021-05-05T12:07:53.457" Title="Integral of PWL-Constraint in Gurobi (Java)" Tags="|optimization|gurobi|quadratic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6227" PostTypeId="1" CreationDate="2021-05-05T08:32:21.840" Score="4" ViewCount="431" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/i6nzq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/i6nzq.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;I am looking for an efficient approach to &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-means clustering with minimum cluster size constraints. The clusters are non overlapping, so, one point can belong to only one cluster.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; be the number of points&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; be the number of clusters&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_{\min}$&lt;/span&gt; be the minimum cluster size&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_{\max}$&lt;/span&gt; be the maximum cluster size&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{nc}$&lt;/span&gt; be an indicator variable. If &lt;span class=&quot;math-container&quot;&gt;$x_{nc}=1$&lt;/span&gt;, then point &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; belongs to cluster &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, otherwise not.&lt;/p&gt;&#xA;&lt;p&gt;So, the constraints we can express as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$S_{\min}\le\sum_{n=1}^Nx_{nc}\le S_{\max},\forall c, c=1,2,\cdots,C$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{c=1}^Cx_{nc}=1,\forall n, n=1,2,\cdots,N$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{c=1}^C\sum_{n=1}^Nx_{nc}=N$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What should be the objective here.&lt;/p&gt;&#xA;&lt;p&gt;Or any other efficient mathematical formulations for this clustering problem?&lt;/p&gt;&#xA;&lt;p&gt;We have the objective function for Kmean as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{c=1}^C\sum_{n\in \mathcal{S}_c}||d_n-\mu_c||^2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where, &lt;span class=&quot;math-container&quot;&gt;$\mu_c$&lt;/span&gt; (a two-dimensional vector) is the mean of points in cluster &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}_c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$d_n$&lt;/span&gt; is a two-dimensional vector containing the coordinates of point &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2021-05-05T09:54:37.997" LastActivityDate="2021-05-06T03:24:20.817" Title="Any Solution for $k$-means with minimum and maximum cluster size constraint?" Tags="|linear-programming|convex-optimization|graphs|clustering|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6228" PostTypeId="2" ParentId="6227" CreationDate="2021-05-05T09:16:47.067" Score="4" Body="&lt;p&gt;It depends on what you want to achieve exactly. You could, for example, want to minimize the average distance between a point and the &amp;quot;center&amp;quot; of the cluster. This requires that you first define this center. Assuming it is one of the points, then intoduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if point &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is the center of one of the clusters. And slightly modifiy your &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; variables, so that they now take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if point &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is in the cluster with center point &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. For consistency you need to add the following constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You need &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; centers, one for each cluster: &lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j} y_j = C$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If point &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is in cluster &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, then variable &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; needs to be activated:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{ij} \le y_j \quad \forall i,j&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;A point belongs to exactly one cluster:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j}x_{ij} = 1 \quad \forall i&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The size of each cluster is bounded:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;L_j \le \sum_{i}x_{ij} \le U_j\quad \forall j&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You can now minimize the average distance from a point to the center of its cluster:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min\;\sum_{i}\sum_{j}d_{ij}x_{ij}&#xA;$$&lt;/span&gt;&#xA;Or perhaps the maximum distance from a point to its center:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min\;\max_{i,j}\;\{d_{ij}x_{ij}\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; denotes the distance between points &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If you really don't want the centers to be one the points, then things get a little messier (linearity is sacrificed). You could start by plotting the points (and add the plot to your question), so that we can eyeball if it makes sense to restrict the centers to one of the points.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: since the distribution of points seems to be sparse, it definitely makes sense to consider centers which are not initial points. In this case, you can solve the following (non linear) problem.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \; \sum_{i}\sum_{j} d_{ij}^2x_{ij} &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to your constraints, plus the following ones:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Define &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; as the Euclidean distance between point &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and center &lt;span class=&quot;math-container&quot;&gt;$\mu_j$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;d_{ij}^2=(X_i - X_{\mu_j})^2+(Y_i - Y_{\mu_j})^2&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Define the coordinates of the centers &lt;span class=&quot;math-container&quot;&gt;$\mu_{j}$&lt;/span&gt; as the weighted sum of all the points in cluster &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;X_{\mu_j} = \frac{\sum_i X_i x_{ij}}{\sum_i  x_{ij}} \\&#xA;Y_{\mu_j} = \frac{\sum_i Y_i x_{ij}}{\sum_i  x_{ij}}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Again, this is not linear...&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-05-05T12:48:53.583" LastActivityDate="2021-05-05T12:48:53.583" CommentCount="18" ContentLicense="CC BY-SA 4.0" />
  <row Id="6229" PostTypeId="2" ParentId="6226" CreationDate="2021-05-05T12:07:53.457" Score="2" Body="&lt;p&gt;Integrating a piecewise linear function means you end up with a piecewise quadratic function.&lt;/p&gt;&#xA;&lt;p&gt;Unless there is come convex structure in the resulting piecewise quadratic function (i.e. the PWL is non-decreasing) you will end up with a model involving nonconvexities.&lt;/p&gt;&#xA;&lt;p&gt;It was an interesting question so I had to play around a bit with it, and wrote a small post here &lt;a href=&quot;https://yalmip.github.io/example/integratedpwa/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://yalmip.github.io/example/integratedpwa/&lt;/a&gt;. It is not Java, but the basic idea in the 'hard way' should be easily transferable to any modelling language.&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2021-05-05T12:07:53.457" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6230" PostTypeId="2" ParentId="6227" CreationDate="2021-05-05T20:28:41.040" Score="4" Body="&lt;p&gt;I had the following model lying around:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned} &#xA;\min&amp;amp;\sum_{i,k}\color{darkred}d_{i,k}\\&#xA;    &amp;amp; \color{darkred}d_{i,k} \ge \sum_c \left(\color{darkblue}p_{i,c}-\color{darkred}\mu_{k,c}\right)^2-\color{darkblue}M(1-\color{darkred}x_{i,k}) \\&#xA;    &amp;amp; \sum_k\color{darkred}x_{i,k} = 1 &amp;amp;&amp;amp; \forall i\\&#xA;    &amp;amp; \color{darkred}n_k = \sum_i \color{darkred}x_{i,k} \\&#xA;    &amp;amp; \color{darkred}n_k \in [\color{darkblue}\ell,\color{darkblue}u] \\&#xA;    &amp;amp; \color{darkred}x_{i,k} \in \{0,1\}\\&#xA;    &amp;amp; \color{darkred}\mu_{k,c} \in [\min_i\color{darkblue}p_{i,c},\max_i\color{darkblue}p_{i,c}] \\&#xA;    &amp;amp; \color{darkred}d_{i,k} \ge 0 \\&#xA;    &amp;amp; \color{darkblue}M=\max_{i,i'} \sum_c \left(\color{darkblue}p_{i,c}-\color{darkblue}p_{i',c}\right)^2\\&#xA;    &amp;amp; c \in \{x,y\}&#xA;\end{aligned}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\color{darkred}d_{i,k}$&lt;/span&gt;: squared distance between point &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and cluster centroid &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; or zero if point &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is not part of cluster &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\color{darkblue}p_{i,c}$&lt;/span&gt;: coordinates of point &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\color{darkred}\mu_{k,c}$&lt;/span&gt;: cluster centroid coordinates&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\color{darkred}x_{i,k}$&lt;/span&gt;: assignment of points &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to clusters &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\color{darkred}n_k$&lt;/span&gt;: number of points in cluster &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\color{darkblue}\ell,\color{darkblue}u$&lt;/span&gt; are your constraints on the cluster size&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is a convex MIQCP.&lt;/li&gt;&#xA;&lt;li&gt;The objective is the &amp;quot;within-cluster sum-of-squares&amp;quot;.&lt;/li&gt;&#xA;&lt;li&gt;As with many quadratic models, performance is not that good. 50 points is no problem, but after that things may slow down.&lt;/li&gt;&#xA;&lt;li&gt;I am not at all sure if this the best formulation.&lt;/li&gt;&#xA;&lt;li&gt;The big-M constraint can be replaced by indicator constraints. But unfortunately, most solvers don't support quadratic indicator constraints. I don't know why this is the case.&lt;/li&gt;&#xA;&lt;li&gt;The coordinates of the cluster centroids are not explicitly calculated as the mean of the coordinates of the points inside the cluster. The minimization will automatically take care of that. The centroid is the best location for &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}\mu_{k,c}$&lt;/span&gt;. This can be proven by looking at the first-order conditions (after fixing the assignments). It is quite nice that we can drop completely from our model the nonlinear constraints that make up the centroid calculation. We are super lucky here.&lt;/li&gt;&#xA;&lt;li&gt;The model assumes the number of clusters is given. A standard way to find the &amp;quot;optimal&amp;quot; number of clusters is to solve with &lt;span class=&quot;math-container&quot;&gt;$K=1,2,3,..$&lt;/span&gt; clusters and see when adding more clusters does not really improve the objective anymore. When plotting this we often see some kink in the graph that makes visually selecting this point not too difficult.&lt;/li&gt;&#xA;&lt;li&gt;In a sense, this is a multi-objective problem: minimize within-cluster SS and minimize the number of clusters.&lt;/li&gt;&#xA;&lt;li&gt;This model should always be feasible.&lt;/li&gt;&#xA;&lt;li&gt;The objective can be interpreted as &lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i,k,c}\left(\color{darkblue}p_{i,c}-\color{darkred}\mu_{k,c}\right)^2\cdot \color{darkred}x_{i,k} $$&lt;/span&gt; Unfortunately, this makes the model a non-convex MINLP.&lt;/li&gt;&#xA;&lt;li&gt;This model is essentially k-means clustering. Of course, there are many alternative clustering approaches. Some obvious variants of this model are: &lt;br&gt; 1. using L1 distances. That makes the model a linear MIP so easier to solve. &lt;br&gt; 2. using distances instead of squared distances. That makes the model an MISOCP (after some reformulations) and even slower.&lt;/li&gt;&#xA;&lt;li&gt;There is symmetry with respect to how the clusters are numbered. Adding an ordering constraint, say &lt;span class=&quot;math-container&quot;&gt;$$\color{darkred}\mu_{k,x}\le \color{darkred}\mu_{k+1,x}$$&lt;/span&gt; may help. It can reduce the solution time (sometimes substantially).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2021-05-06T03:24:20.817" LastActivityDate="2021-05-06T03:24:20.817" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6231" PostTypeId="1" CreationDate="2021-05-05T21:50:45.690" Score="1" ViewCount="174" Body="&lt;p&gt;It is known that any boolean function may be represented, in some sense, as a system of linear inequalities. But my rather intensive literature search brought a little references. I will appreciate any relevant references! I'm looking for references to sci. books, papers etc. on the subject!&lt;/p&gt;&#xA;&lt;p&gt;The thing is that recently, I understood how to represent any boolean function &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf{x})$&lt;/span&gt; as an irreducible system of linear inequalities in the following sense.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$B^n\doteq\left\{(x_1,x_2,\ldots, x_n): x_k\in\{0,1\}\right\}\subset R^n$&lt;/span&gt; be a set of all vertices of an &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-dimensional unit cube, i.e. the set of all 0-1 arguments of some boolean function &lt;span class=&quot;math-container&quot;&gt;$f: B^n\to\{0,1\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then there exists a system of linear inequalities of &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; variables &lt;span class=&quot;math-container&quot;&gt;$(\mathbf{x},y)$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$$S(\mathbf{x},y)=\{a_i+l_i(\mathbf{x}) + b_iy \geqslant 0: i=1,\ldots,m\}$$&lt;/span&gt;&#xA;(where &lt;span class=&quot;math-container&quot;&gt;$a_i, b_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_i\neq0$&lt;/span&gt; are scalars, and &lt;span class=&quot;math-container&quot;&gt;$l_i(\mathbf{x})$&lt;/span&gt; are linear functions of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables) such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\forall\mathbf{x}\in B^n:\left\{f(\mathbf{x})=y\right\}\iff\left\{a_i+ l_i(\mathbf{x})+b_iy \geqslant 0:i=1,\ldots,m\right\}$$&lt;/span&gt;&#xA;i.e. for any &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}\in B^n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf{x})=y$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$S(\mathbf{x},y)$&lt;/span&gt; holds.&lt;/p&gt;&#xA;&lt;p&gt;It is important that we do not need to assume that &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a discrete, 0-1, variable! For any 0-1 vector &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}$&lt;/span&gt;, the system &lt;span class=&quot;math-container&quot;&gt;$S(\mathbf{x},y)$&lt;/span&gt; has the only solution &lt;span class=&quot;math-container&quot;&gt;$(\mathbf{x}, y=f(\mathbf{x}))$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And I can explicitly produce the system &lt;span class=&quot;math-container&quot;&gt;$S(\mathbf{x},y)$&lt;/span&gt; (in vector-matrix form) for any function &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf{x})$&lt;/span&gt; defined either by a formula or in tabular form.&lt;/p&gt;&#xA;&lt;p&gt;The main drawback of the approach is that I need to calculate values of boolean function for all (!) 0-1 arguments (&lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; for n-variant function).&#xA;Of course, there are another computing limitations for a large number of variables, but we can always express &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf{x})$&lt;/span&gt; as a composition of functions of a fewer number of variables.&lt;/p&gt;&#xA;&lt;p&gt;Can you give me any references on this subject? Can you recommend something else, beyond the &amp;quot;realm of SAT&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1109/CompComm.2018.8780844&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wenxia Guo, etc. An Efficient Method to Transform a SAT problem to a Mixed Integer Linear Programming Problem, 2018&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1109/ASPDAC.2004.1337719&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ruirning Li, etc. Satisfiability and integer programming as complementary tools, 2004&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5445" LastEditorUserId="5445" LastEditDate="2021-06-04T20:27:17.530" LastActivityDate="2021-06-04T20:27:17.530" Title="References to publications on representation of any boolean function as a system of linear inequalities" Tags="|mixed-integer-programming|reference-request|binary-variable|polyhedra|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6232" PostTypeId="2" ParentId="6231" CreationDate="2021-05-05T22:38:17.850" Score="8" Body="&lt;p&gt;If I understand correctly, you can obtain the desired linear constraints via conjunctive normal form.  Explicitly, suppose &lt;span class=&quot;math-container&quot;&gt;$f(\bar{x}_1,\dots,\bar{x}_n)=1$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$S_0 = \{j\in\{1,\dots,n\}:\bar{x}_j = 0\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S_1 = \{j\in\{1,\dots,n\}:\bar{x}_j = 1\}$&lt;/span&gt;.  You want to enforce &lt;span class=&quot;math-container&quot;&gt;$$\left[\left(\bigwedge_{j\in S_0} \lnot x_j\right) \bigwedge \left(\bigwedge_{j\in S_1} x_j\right)\right] \implies y.$$&lt;/span&gt;&#xA;Equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lnot\left[\left(\bigwedge_{j\in S_0} \lnot x_j\right) \bigwedge \left(\bigwedge_{j\in S_1} x_j\right)\right] \lor y \\&#xA;\left[\lnot\left(\bigwedge_{j\in S_0} \lnot x_j\right) \bigvee \lnot\left(\bigwedge_{j\in S_1} x_j\right)\right] \lor y \\&#xA;\left[\left(\bigvee_{j\in S_0} x_j\right) \bigvee \left(\bigvee_{j\in S_1} \lnot x_j\right)\right] \lor y \\&#xA;\sum_{j\in S_0} x_j + \sum_{j\in S_1} (1-x_j) + y \ge 1 \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Similarly, if &lt;span class=&quot;math-container&quot;&gt;$f(\bar{x}_1,\dots,\bar{x}_n)=0$&lt;/span&gt;, you want to enforce &lt;span class=&quot;math-container&quot;&gt;$$\left[\left(\bigwedge_{j\in S_0} \lnot x_j\right) \bigwedge \left(\bigwedge_{j\in S_1} x_j\right)\right] \implies \lnot y,$$&lt;/span&gt;&#xA;yielding linear constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j\in S_0} x_j + \sum_{j\in S_1} (1-x_j) - y \ge 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This approach yields &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-05-06T17:11:11.797" LastActivityDate="2021-05-06T17:11:11.797" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6233" PostTypeId="1" CreationDate="2021-05-07T12:17:57.027" Score="0" ViewCount="108" Body="&lt;p&gt;I have clustering problem with servers and users. This is different to the one posted in &lt;a href=&quot;https://math.stackexchange.com/questions/4088441/what-will-be-an-efficient-joint-clustering-solution-to-this-problem/4090360?noredirect=1#comment8537059_4090360&quot;&gt;https://math.stackexchange.com/questions/4088441/what-will-be-an-efficient-joint-clustering-solution-to-this-problem/4090360?noredirect=1#comment8537059_4090360&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There is a link gain between a server and a user. The farther away the user is, the lower the gain. Sometimes, there is zero gain is the distance between a user and server is too high. We do not want to put one user in a cluster where the user has zero gain for one of the servers belonging to user cluster.&lt;/p&gt;&#xA;&lt;p&gt;I want to form the cluster such that the users have better overall gain.&#xA;Also, we prefer that the servers are closer to each other to reduce the overall communication delay as the servers may need to communicate to each other.&lt;/p&gt;&#xA;&lt;p&gt;The clustering constraints I have are as follows:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There is a maximum cluster size limit.&lt;/li&gt;&#xA;&lt;li&gt;Minimum cluster size is one.&lt;/li&gt;&#xA;&lt;li&gt;The number of clusters is variable.&lt;/li&gt;&#xA;&lt;li&gt;Since there is individual cluster size limit, there exists a number that dictates the minimum number of clusters the system can have, which is number of servers/maximum cluster size.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The objective is to maximum the overall gain of the whole system, which is the sum of individual user gains.&lt;/p&gt;&#xA;&lt;p&gt;User gain is decided by sum-gain from its own cluster servers divided by sum of the gains from the remaining servers in the system.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2021-05-08T11:28:39.090" LastActivityDate="2021-05-08T11:28:39.090" Title="How to solve this clustering problem with heuristic or meta-heuristic approach?" Tags="|optimization|mixed-integer-programming|nonlinear-programming|clustering|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="6234" PostTypeId="2" ParentId="6233" CreationDate="2021-05-07T19:57:30.273" Score="4" Body="&lt;p&gt;[I'm leaving out constraint 0]&lt;/p&gt;&#xA;&lt;p&gt;I see two levels of decisions in your problem:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Group servers into clusters&lt;/li&gt;&#xA;&lt;li&gt;Assign each user to one of these clusters&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;(BTW, this way of seeing the problem is heavily inspired by Facility location problems).&lt;/p&gt;&#xA;&lt;p&gt;The second step is actually the easiest: once the clusters are known, you can just compute each user's gain w.r.t to each cluster, and assign it to the best cluster.&#xA;Note that if you introduce some capacity constraints, e.g., server &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; can serve at most &lt;span class=&quot;math-container&quot;&gt;$N_{k}$&lt;/span&gt; users, then you complicate the user &lt;span class=&quot;math-container&quot;&gt;$\rightarrow$&lt;/span&gt; server assignment, but it's still very tractable.&lt;/p&gt;&#xA;&lt;p&gt;So the &amp;quot;hard&amp;quot; part is how to cluster the servers together. There are many approaches for doing so, such as greedy heuristics, K-means variants, etc...&#xA;For instance, you could generate &lt;span class=&quot;math-container&quot;&gt;$1{,}000$&lt;/span&gt; different clusterings of the servers, then compute an optimal assignment of the users for each, and pick the best solution.&lt;/p&gt;&#xA;&lt;p&gt;You could also plug this into an exploration mechanism, where you perturb the clusters (e.g. move one server from a cluster to another).&lt;/p&gt;&#xA;&lt;p&gt;All these methods are purely heuristic, are relatively easy to implement and should scale quite well.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2021-05-07T19:57:30.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6235" PostTypeId="1" AcceptedAnswerId="6237" CreationDate="2021-05-08T10:06:08.317" Score="5" ViewCount="249" Body="&lt;p&gt;Consider the polyhedron given by the set of inequalities&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\mathbf{b}^T\mathbf{x} ~&amp;amp;\leq~ c \\&#xA;\mathbf{e}^T\mathbf{x} - 1 ~&amp;amp;\leq~0 \\&#xA;\mathbf{x}~&amp;amp;\geq~0&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}\in\mathbb{R}^d$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}$&lt;/span&gt; is a given element-wise positive vector, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is a given positive constant and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{e}$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$d-$&lt;/span&gt;dimensional all-ones vector.&lt;/p&gt;&#xA;&lt;p&gt;I am interested in the extreme points of this polyhedron. If the constraint &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}^T\mathbf{x} \leq c$&lt;/span&gt; was not there, it is easy to see that the polyhedron is simply the probability simplex or the standard &lt;a href=&quot;https://en.wikipedia.org/wiki/Simplex&quot; rel=&quot;nofollow noreferrer&quot;&gt;simplex&lt;/a&gt; (basically the convex hull of columns of a &lt;span class=&quot;math-container&quot;&gt;$d\times d$&lt;/span&gt; identity matrix &lt;span class=&quot;math-container&quot;&gt;$I_d$&lt;/span&gt; and the origin). In that case, the extreme points would indeed be the columns of &lt;span class=&quot;math-container&quot;&gt;$I_d$&lt;/span&gt; and the origin, thus &lt;span class=&quot;math-container&quot;&gt;$d+1$&lt;/span&gt; extreme points.&lt;/p&gt;&#xA;&lt;p&gt;When this constraint &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}^T\mathbf{x} \leq c$&lt;/span&gt; is added, I am curious to know whether it is easy to calculate the new set of extreme points. For instance, some of the extreme points will get retained. It is easy to find these by identifying the columns of &lt;span class=&quot;math-container&quot;&gt;$I_d$&lt;/span&gt; that satisfy &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}^T\mathbf{x} \leq c$&lt;/span&gt; and those that don't. Is there a simple algorithm to find the newly added extreme points using the ones that were retained and the ones that were removed?&lt;/p&gt;&#xA;" OwnerUserId="3024" LastEditorUserId="123" LastEditDate="2021-05-08T14:08:38.987" LastActivityDate="2021-05-08T14:56:46.607" Title="Extreme points of a simple polyhedron" Tags="|linear-programming|polyhedra|convex-hull|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6236" PostTypeId="2" ParentId="6200" CreationDate="2021-05-08T11:13:37.727" Score="4" Body="&lt;p&gt;I didn't find a way to express the transition constraints so i give a description what this does and mention what it lacks.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using JuMP&#xA;using Gurobi #needs Gurobi license but any other MILP solver callable from JuMP should work too## Heading ##&#xA;using UnicodePlots&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;are dependencies. I used UnicodePlots for debugging. It is neat. In Julia dependencies can be installed via &lt;code&gt;]add JuMP&lt;/code&gt; in the Julia shell. Gurobi also needs to be installed and have a license. Another solver like should also do the trick. Learn more &lt;a href=&quot;https://jump.dev/JuMP.jl/stable/installation/#Installing-a-solver&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; .&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;workers = [&#xA;  10 5;&#xA;  10 5;&#xA;  10 5;&#xA;  10 5;&#xA;  10 5;&#xA;  50 5;&#xA;]&#xA;&#xA;tasks = [&#xA;  3000 1 600; #out of bounds if 0&#xA;  3600 1 600;&#xA;  1800 1 600;&#xA;  1200 10 600;&#xA;  3300 15 600;&#xA;  3000 20 600;&#xA;  3600 30 600;&#xA;  1800 100 600;&#xA;  1200 100 600;&#xA;  3300 120 600;&#xA;]&#xA;&#xA;sim_time = 600; #needs to be bigger or equal than the last time stamp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is the problem information you provided. It could have also been stored in structures, dictionaries but i went with arrays for simplicity&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = Model(Gurobi.Optimizer)&#xA;&#xA;@variable(model, workspeed[1:(size(workers)[1]), 1:(size(tasks)[1]), 1:sim_time], lower_bound = 0)&#xA;&#xA;for i=1:(size(workers)[1])&#xA;  @constraint(model, workspeed[i,:,:] .&amp;lt;= workers[i,1])&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Since worker top speed differs there is no good way to define all upper bound at once. Here i broadcast the lesser or equal constraint over all &lt;code&gt;workspeed&lt;/code&gt; of an particular worker.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@variable(model,p)&#xA;@constraint(model,sum(workspeed,dims=(1,2)).&amp;lt;=p)  #the sum over all dimensions expect time, the total work at each time point&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This define the objective which is the lowest maximum over all work happening at any time point.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;@variable(model, work_done[1:(size(tasks)[1]), 1:sim_time], lower_bound = 0)&#xA;&#xA;for i=1:(size(tasks)[1])&#xA;  for j=1:tasks[i,2]&#xA;    @constraint(model, work_done[i,j] == 0)&#xA;  end&#xA;  for j=(tasks[i,3]):sim_time&#xA;    @constraint(model, work_done[i,j] &amp;gt;= tasks[i,1])&#xA;  end&#xA;end&#xA;&#xA;for t=1:(sim_time-1)&#xA;  @constraint(model, work_done[:,t+1] .==  work_done[:,t] .+ sum(workspeed,dims=1)[1,:,t])&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This block could be almost removed and i think Gurobi does that during presolve sometimes. &lt;code&gt;sum([ workspeed[:,i,t] for t=(tasks[i,2]):(tasks[i,3])]) &amp;gt;= tasks[i,1]&lt;/code&gt; or something similar could do the trick and eliminate the necessity for &lt;code&gt;work_done&lt;/code&gt; completely. This block makes sure that work on tasks is not started early or finishes late.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for t=1:(sim_time-1)&#xA;  for w=1:(size(workers)[1])&#xA;    @constraint(model, -workers[w,2] .&amp;lt;= workspeed[w,:,t+1] .- workspeed[w,:,t] .&amp;lt;= workers[w,2] ) # different ramp down?&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;constrains the growth/decline of the all individual workspeeds. In the previous version i had constrained the sum instead which allowed the solver to keep production speed when switching tasks. Now that this constraint is enforced properly, switching can still happen for free and instantly when production speed is &amp;lt;= the wind_up without down time.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@variable(model, workson[1:(size(workers)[1]), 1:(size(tasks)[1]), 1:sim_time], Bin)&#xA;@variable(model, worksonatall[1:(size(workers)[1]), 1:(size(tasks)[1])], Bin)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;These binary variables are responsible for enforcing the scheduling logic. If a worker &lt;code&gt;n&lt;/code&gt; ever works task &lt;code&gt;t&lt;/code&gt; &lt;code&gt;value(worksonatall[n,t])&lt;/code&gt; will be true. While forcing certain values to false can be used to forbid people from working on something, it would be more smart to not generate the backbone in &lt;code&gt;workspeed&lt;/code&gt; and other places. While presolve might remove it would be better not to generate it at all.&lt;/p&gt;&#xA;&lt;p&gt;Note that without this logic a linear program would result which could be solved a lot faster.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i=1:(size(workers)[1])&#xA;  @constraint(model, workspeed[i,:,:] .&amp;lt;= workers[i,1] * workson[i,:,:] )&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This ensures that if a worker works on some task at some time that this information is available as a boolean.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@constraint(model, sim_time*worksonatall[:,:] .&amp;gt;= sum(workson,dims=3)[:,:,1]) # any&#xA;@constraint(model, sum(workson,dims=3)[:,:,1] .&amp;gt;= worksonatall[:,:]) # any&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This code established the relationship between &lt;code&gt;workson&lt;/code&gt; and &lt;code&gt;worksonatall&lt;/code&gt; the latter is the logical or over all time of &lt;code&gt;workson&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@constraint(model, sum(worksonatall, dims=1)[1,:] .== 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Every task can only ever be worked on by one worker.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for t=1:sim_time&#xA;      for w=1:(size(workers)[1])&#xA;      @constraint(model,sum(workson[w,:,t]) &amp;lt;= 1)&#xA;    end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A worker can work at most at one task at a time.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@objective(model, Min, p)&#xA;&#xA;optimize!(model)&#xA;&#xA;println(value.(worksonatall))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Defines objective and hands problem to the solver.&#xA;Show which worker work on what which is useful for debugging.&lt;/p&gt;&#xA;&lt;p&gt;I let the program run over night on my quadcore. Gurobi found an global optimum. The resulting array of workspeed is pasted &lt;a href=&quot;https://pastebin.com/A6PGtFSL&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&#xA;Here is an excerpt of the log for every time a new incumbent integer solution was found:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    Nodes    |    Current Node    |     Objective Bounds      |     Work&#xA; Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time&#xA;&#xA;&#xA;* 2465  1985             731      43.7307033   43.07179  1.51%   421 1356s&#xA;H 2649   930                      43.4719711   43.07179  0.92%   402 1884s&#xA;H 2877   601                      43.2761578   43.07179  0.47%   422 1983s&#xA;H 2879   571                      43.2646048   43.07179  0.45%   422 2321s&#xA;H 2879   543                      43.2423208   43.07179  0.39%   422 2321s&#xA;H 2880   516                      43.2367973   43.07179  0.38%   422 2762s&#xA;H 2888   495                      43.2312925   43.07179  0.37%   421 6594s&#xA;H 2956   566                      43.2282794   43.07179  0.36%  1065 13263s&#xA;H 2978   535                      43.2033898   43.07179  0.30%  1141 13263s&#xA;H 3006   683                      43.1895093   43.07179  0.27%  1165 15293s&#xA;H 3340  1119                      43.1725888   43.07179  0.23%  1567 16752s&#xA;H 3489  1048                      43.1587838   43.07179  0.20%  1591 16752s&#xA;H 4936  1195                      43.1418919   43.07179  0.16%  1459 18634s&#xA;H 4963  1148                      43.1165541   43.07179  0.10%  1461 19244s&#xA;H 9711   972                      43.1008403   43.07179  0.07%  1470 27005s&#xA;H11482   430                      43.0904523   43.07179  0.04%  1498 29415s&#xA;H12431   220                      43.0717863   43.07179  0.00%  1513 31324s&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The resulting objective is 43.071786310517524.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;workspeed by workers over time&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/M9O9O.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/M9O9O.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;workspeed on tasks over time&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/3bdnl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3bdnl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;We see that the tasks in the current formulation can get resumed later. The easiest way to achieve no resumes would be to constrain the sum of xors between successive workson to be 2 and to set initial workspeed to 0 for all workers, alternatively or with some amount related to the sum of workson could work to. At the moment worker 6 starts with the maximal work speed. This would almost double the amount of binary values though and make the search space less relaxed. &lt;a href=&quot;http://yetanothermathprogrammingconsultant.blogspot.com/2016/02/xor-as-linear-inequalities.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;See here how to do or and xor&lt;/a&gt;. However i think there should be a better solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;work_done on tasks over time&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Wl9go.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wl9go.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;sum of workspeed over time&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/YmfjU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YmfjU.png&quot; alt=&quot;sum of workspeed&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-05-09T21:04:47.337" LastActivityDate="2021-05-09T21:04:47.337" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6237" PostTypeId="2" ParentId="6235" CreationDate="2021-05-08T14:56:46.607" Score="4" Body="&lt;p&gt;Let's assume that (a) the full polyhedron is not empty (a solution to the inequalities exists) and (b) you have identified the extreme points of the unit simplex that remain extreme points after the new constraint has been added. Any other extreme points will necessarily satisfy the new constraint as an equality (&lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}^T\mathbf{x}=c$&lt;/span&gt;). Since they are extreme points, at least &lt;span class=&quot;math-container&quot;&gt;$d-1$&lt;/span&gt; of the original constraints must also be binding there. So you can look for all feasible solutions of &lt;span class=&quot;math-container&quot;&gt;$$\mathbf{b}^T\mathbf{x}=c$$&lt;/span&gt; where all but one component of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}$&lt;/span&gt; is zero (by enumeration), and then take the system &lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\mathbf{b}^{T}\mathbf{x} &amp;amp; =c\\ \mathbf{e}^{T}\mathbf{x} &amp;amp; =1 \end{align*}&lt;/span&gt; and look for all solutions where &lt;span class=&quot;math-container&quot;&gt;$d-2$&lt;/span&gt; components of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}$&lt;/span&gt; are zero (again, by enumerating the &lt;span class=&quot;math-container&quot;&gt;$d \choose 2$&lt;/span&gt; combinations of components that might not be zero).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-05-08T14:56:46.607" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6238" PostTypeId="1" AcceptedAnswerId="6243" CreationDate="2021-05-09T09:38:36.553" Score="5" ViewCount="125" Body="&lt;p&gt;I am self-learning optimization algorithms. A certain assignment problem is as follows:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Show that the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-dimensional function&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f(\mathbf{x})=\|(1-x_1,x_1-x_2,x_2-x_3,\ldots,x_{n-1}-x_n,x_n-2)\|_2^2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;has exactly one stationary point which is a global minimum. Compute this minimum.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I would like someone to verify my optimal solution; does the math checkout?&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Solution.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;We have,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;f(\mathbf{x})= (1-x_1)^2+(x_1-x_2)^2+\ldots+(x_{n-1}-x_{n})^2 + (x_n-2)^2&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The partial derivatives of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; are as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;f_{x_1}(\mathbf{x}) &amp;amp;= 2(1-x_1)(-1)+2(x_1-x_2) = -2 + 4x_1 - 2x_2\\&#xA;f_{x_2}(\mathbf{x}) &amp;amp;= 2(x_1-x_2)(-1)+2(x_2-x_3) = -2x_1 + 4x_2 -2x_3 \\&#xA;f_{x_3}(\mathbf{x}) &amp;amp;= 2(x_2-x_3)(-1)+2(x_3-x_4) = -2x_2 + 4x_3 -2x_4 \\&#xA;\vdots\\&#xA;f_{x_{n-1}}(\mathbf{x}) &amp;amp;= 2(x_{n-2}-x_{n-1})(-1)+2(x_{n-1}-x_n) = -2x_{n-2} + 4x_{n-1} -2x_n \\&#xA;f_{x_n}(\mathbf{x}) &amp;amp;= 2(x_{n-1}-x_n)(-1)+2(x_n-2) = -2x_{n-1} + 4x_n -4&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The critical points of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; are given by,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\nabla f(\mathbf{x}) = 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Therefore, we have the system of equations:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\begin{bmatrix}&#xA;4 &amp;amp;-2 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0\\ &#xA;-2&amp;amp; 4 &amp;amp;-2 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0\\&#xA;0 &amp;amp;-2 &amp;amp; 4 &amp;amp;-2 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp;-2 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;-2 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0\\&#xA;\vdots\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp;-2 &amp;amp; 4 &amp;amp;-2\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp;-2 &amp;amp; 4&#xA;\end{bmatrix}\begin{bmatrix}&#xA;x_1\\&#xA;x_2\\&#xA;x_3\\&#xA;x_4\\&#xA;x_5\\&#xA;x_6\\&#xA;\vdots\\&#xA;x_{n-1}\\&#xA;x_n&#xA;\end{bmatrix}=\begin{bmatrix}&#xA;2\\&#xA;0\\&#xA;0\\&#xA;0\\&#xA;0\\&#xA;0\\&#xA;\vdots\\&#xA;0\\&#xA;4&#xA;\end{bmatrix}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;These are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; equations in &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; unknowns. This tridiagonal system has a unique solution vector &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}$&lt;/span&gt;. Applying Gaussian elimination to the augmented matrix &lt;span class=&quot;math-container&quot;&gt;$[A \quad b]$&lt;/span&gt;, by hand, we have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\begin{bmatrix}&#xA;4 &amp;amp;-2 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\ &#xA;-2&amp;amp; 4 &amp;amp;-2 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 0\\&#xA;0 &amp;amp;-2 &amp;amp; 4 &amp;amp;-2 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm|  &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp;-2 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm|  &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm|  &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;-2 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm|  &amp;amp; 0\\&#xA;\vdots &amp;amp;  &amp;amp;  &amp;amp;  &amp;amp; &amp;amp;  &amp;amp;  &amp;amp;  &amp;amp; &amp;amp;\bigm|  &amp;amp; \vdots\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp;-2 &amp;amp; 4 &amp;amp;-2 &amp;amp;\bigm|  &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp;\bigm|  &amp;amp; 4\\&#xA;\end{bmatrix}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Applying&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\{R_2 \rightarrow 2R_2 + R_1\}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\begin{bmatrix}&#xA;4 &amp;amp;-2 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\ &#xA;0 &amp;amp; 6 &amp;amp;-4 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\&#xA;0 &amp;amp;-2 &amp;amp; 4 &amp;amp;-2 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm|  &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp;-2 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm|  &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm|  &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;-2 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm|  &amp;amp; 0\\&#xA;\vdots &amp;amp;  &amp;amp;  &amp;amp;  &amp;amp; &amp;amp;  &amp;amp;  &amp;amp;  &amp;amp; &amp;amp;\bigm|  &amp;amp; \vdots\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp;-2 &amp;amp; 4 &amp;amp;-2 &amp;amp;\bigm|  &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp;\bigm|  &amp;amp; 4\\&#xA;\end{bmatrix}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Applying&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\{R_3 \rightarrow 3R_3 + R_2\}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\begin{bmatrix}&#xA;4 &amp;amp;-2 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\ &#xA;0 &amp;amp; 6 &amp;amp;-4 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\&#xA;0 &amp;amp; 0 &amp;amp; 8 &amp;amp;-6 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\&#xA;0 &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp;-2 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;-2 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 0\\&#xA;\vdots &amp;amp;  &amp;amp;  &amp;amp;  &amp;amp; &amp;amp;  &amp;amp;  &amp;amp;  &amp;amp; &amp;amp;\bigm|  &amp;amp; \vdots\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp;-2 &amp;amp; 4 &amp;amp;-2 &amp;amp;\bigm| &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp;\bigm| &amp;amp; 4\\&#xA;\end{bmatrix}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Applying&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\{R_4 \rightarrow 4R_4 + R_3\}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\begin{bmatrix}&#xA;4 &amp;amp;-2 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\ &#xA;0 &amp;amp; 6 &amp;amp;-4 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\&#xA;0 &amp;amp; 0 &amp;amp; 8 &amp;amp;-6 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp;10 &amp;amp;-8 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;-2 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 0\\&#xA;\vdots &amp;amp;  &amp;amp;  &amp;amp;  &amp;amp; &amp;amp;  &amp;amp;  &amp;amp;  &amp;amp; &amp;amp;\bigm|  &amp;amp; \vdots\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp;-2 &amp;amp; 4 &amp;amp;-2 &amp;amp;\bigm| &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp;-2 &amp;amp; 4 &amp;amp;\bigm| &amp;amp; 4\\&#xA;\end{bmatrix}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Continuing in this fashion, we obtain after &lt;span class=&quot;math-container&quot;&gt;$\{R_n\rightarrow n R_n + R_{n-1}\}$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\begin{bmatrix}&#xA;4 &amp;amp;-2 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\ &#xA;0 &amp;amp; 6 &amp;amp;-4 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\&#xA;0 &amp;amp; 0 &amp;amp; 8 &amp;amp;-6 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp;10 &amp;amp;-8 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp;0 &amp;amp; 12 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp;\bigm| &amp;amp; 2\\&#xA;\vdots &amp;amp;  &amp;amp;  &amp;amp;  &amp;amp; &amp;amp;  &amp;amp;  &amp;amp;  &amp;amp; &amp;amp;\bigm|  &amp;amp; \vdots\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp; 2n &amp;amp;-2(n-1) &amp;amp;\bigm| &amp;amp; 2\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 &amp;amp;0 &amp;amp; 2n+2 &amp;amp;\bigm| &amp;amp; 4n+2&#xA;\end{bmatrix}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;By back-substitution,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(2n+2)x_n &amp;amp;= 4n+2\\&#xA;x_n &amp;amp;= \frac{2n+1}{n+1} \tag{1}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Substituting the value of &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$2n x_{n-1} -2(n-1)x_n = 2$&lt;/span&gt;, we have:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;2n x_{n-1} &amp;amp;= 2 + 2(n-1)x_n\\&#xA;x_{n-1} &amp;amp;= \frac{1}{n}\left[1 + (n-1)x_n\right]\\&#xA;&amp;amp;= \frac{1}{n}\left[1 + (n-1)\frac{2n+1}{n+1}\right]\\&#xA;&amp;amp;= \frac{1}{n}\left[\frac{(n+1)+(n-1)(2n+1)}{n+1}\right]\\&#xA;&amp;amp;= \frac{1}{n}\left[\frac{(n+1)+n(2n+1)-(2n+1)}{n+1}\right]\\&#xA;&amp;amp;= \frac{1}{n}\left[\frac{n + 1 + 2n^2 + n - 2n - 1}{n+1}\right]\\&#xA;&amp;amp;= \frac{1}{n}\left[\frac{2n^2}{n+1}\right]\\&#xA;&amp;amp;= \frac{2n}{n+1} \tag{2}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As the recurrence relationship stays the same for &lt;span class=&quot;math-container&quot;&gt;$n \in \{1,2,3,4,\ldots,n-1\}$&lt;/span&gt;, we have:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;x_{n-1} &amp;amp;= \frac{2n}{n+1}\\&#xA;x_{n-2} &amp;amp;= \frac{2n-1}{n+1}\\&#xA;x_{n-3} &amp;amp;= \frac{2n-2}{n+1}\\&#xA;\vdots\\&#xA;x_3 &amp;amp;= \frac{n+4}{n+1}\\&#xA;x_2 &amp;amp;= \frac{n+3}{n+1}\\&#xA;x_1 &amp;amp;= \frac{n+2}{n+1}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, the Hessian of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Hf(\mathbf{x})$&lt;/span&gt; is the same tridiagonal matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; as above. If we find the sequence of determinants &lt;span class=&quot;math-container&quot;&gt;$\det(B_k)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$B_k$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$k \times k$&lt;/span&gt; sub-matrix of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; in the upper-left corner, we see that &lt;span class=&quot;math-container&quot;&gt;$\det(B_1) = 4, \det(B_2) = 8, \det(B_3) = 16, \ldots, \det(B_n)=2^{n+1}$&lt;/span&gt;. Consequently, the critical point &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}$&lt;/span&gt; is a global minima.&lt;/p&gt;&#xA;&lt;p&gt;The minimum value of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is given by,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min \{f(\mathbf{x}):\mathbf{x}\in \mathbf{R}^n \} &amp;amp;=\left(1-\frac{n+2}{n+1}\right)^2 + \left(\frac{1}{n+1}\right)^2 + \ldots +  \left(\frac{2n+1}{n+1}-2\right)^2\\&#xA;&amp;amp;= \frac{(n+1)}{(n+1)^2}\\&#xA;&amp;amp;= \frac{1}{n+1}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5460" LastEditorUserId="123" LastEditDate="2021-05-09T14:18:47.740" LastActivityDate="2021-05-10T19:13:25.113" Title="Finding the global minimum of $f(\mathbf{x})=\|(1-x_1,x_1-x_2,x_2-x_3,\ldots,x_{n-1}-x_n,x_n-2)\|_2^2$" Tags="|optimization|global-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6239" PostTypeId="2" ParentId="6191" CreationDate="2021-05-09T16:32:23.883" Score="3" Body="&lt;p&gt;I've gained sufficient information in last couple of weeks to write an answer myself.&lt;/p&gt;&#xA;&lt;p&gt;As a prerequisite to the discussion, please note the difference between &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221703009196&quot; rel=&quot;nofollow noreferrer&quot;&gt;uniform vs non-uniform&lt;/a&gt; market clearing price. Non-convexities present in electricity market clearing models would lead to non-uniform prices, which would result in participants loosing money if no uplifts/side-payments are employed.&lt;/p&gt;&#xA;&lt;h3&gt;Economic interpretation of dual prices obtained from fixed-MIP&lt;/h3&gt;&#xA;&lt;p&gt;The classical economic interpretation of dual price of power balance constraint in electricity market is &amp;quot;&lt;em&gt;the total attained increase in objective cost if the electricity demand is increased by 1 MW&lt;/em&gt;&amp;quot;; Thus, the economic interpretation of dual price obtained from fixed-MIP concern the objective cost of fixed-MIP instead of the objective cost of original MIP problem.&lt;br /&gt;&#xA;&lt;strong&gt;Hence, if the desired market clearing price is supposed to be the one corresponding to the original MIP problem [in terms of economical interpretation], then, fixed-MIP approach to obtain dual price is not suitable.&lt;/strong&gt; In other words, the dual price obtained from fixed-MIP does not represent the cost impact of 1 MW increase of demand in original MIP problem due to the fact that the original MIP could potentially find a completely different solution to binary/integer variable in response to 1 MW increase in demand.&lt;/p&gt;&#xA;&lt;h3&gt;Additional non-convexities usually present in fixed-MIP model and their impact on dual prices&lt;/h3&gt;&#xA;&lt;p&gt;If the objective is to find a uniform market clearing price using fixed-MIP approach, one must make sure that fixed-MIP is free of all non-convexities. Most electricity market problems consist of various non-convexities in addition to already fixed binary/integer decision variables (startup/shutdown, mustrun etc.) making it impossible to find a uniform market clearing price using fixed-MIP. Such non-convexities include (non-exhaustive list):&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Transmission congestion and losses&lt;/li&gt;&#xA;&lt;li&gt;Minimum generation level&lt;/li&gt;&#xA;&lt;li&gt;Ramping constraints&lt;/li&gt;&#xA;&lt;li&gt;Co-optimization of energy and capacity etc.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h3&gt;Fixed-MIP approach in practice&lt;/h3&gt;&#xA;&lt;p&gt;In practice, various market designs employ fixed-MIP to a certain degree but a special care is always required to clarify the impact of non-convexities. Below are some examples:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;RTO/ISO type power pool markets&lt;/strong&gt;: In this type of market, SCUC can be considered as original MIP problem and SCED can be considered equivalent to fixed-MIP. Some non-convexities such as transmission congestions and losses are handled using locational marginal pricing. Other non-convexities such as ramping, startup/shutdown etc. is handled using dedicated products which are settled via side-payments. However, even if the overall pricing mechanism is non-uniform, fixed-MIP (SCED) is used for driving the uniform part of price for energy and ancillary services products.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Pay-as-bid to manage non-convexities&lt;/strong&gt;: Some markets settle the energy product at a uniform price [obtained from fixed-MIP] if the offer/bid is in-the-money and use pay-as-bid if the offer/bid is out of money (mostly due to non-convexities).&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;No fixed-MIP&lt;/strong&gt;: Some other markets do not use fixed-MIP as they use alternate settlement mechanisms such as:&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pay-as-bid for all cleared offers/bids (+ side-payments for startup/shutdown).&lt;/li&gt;&#xA;&lt;li&gt;Price of most expensive offer can be used if non-convexities are eliminated in the optimization algorithm by allowing sub-optimal solution.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4263" LastEditorUserId="4263" LastEditDate="2021-05-09T18:26:04.943" LastActivityDate="2021-05-09T18:26:04.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6240" PostTypeId="1" AcceptedAnswerId="6242" CreationDate="2021-05-10T14:55:36.567" Score="4" ViewCount="567" Body="&lt;p&gt;With &lt;code&gt;SetHint()&lt;/code&gt; from the OR-tools linear solver I am trying to pass a feasible solution to my problem. But I receive the following warning:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;WARNING: ignore partial solution (0) because unknown rate is too large (0.862233 &amp;gt; 0.85)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;What is the unknown rate and how can I reduce it?&lt;/p&gt;&#xA;&lt;p&gt;I firstly thought, &amp;quot;unknown rate&amp;quot; refers to the proportion of variables that I provide a value for. But even when providing a value for all variables, I receive the warning above.&lt;/p&gt;&#xA;&lt;p&gt;Background: I am dealing with a VRP and its split delivery generalization. First, I calculate a solution without splits passing it with &lt;code&gt;SetHint(variables, values)&lt;/code&gt; to the generalized model. I have done this before with Gurobi (warm start), but wanted to try the same with the OR-Tools SCIP solver. I am working with Python.&lt;/p&gt;&#xA;" OwnerUserId="3418" LastEditorUserId="500" LastEditDate="2023-12-13T18:10:33.327" LastActivityDate="2023-12-13T18:10:33.327" Title="OR-Tools: Partial Solution ignored due to &quot;unknown rate is too large&quot;" Tags="|python|vehicle-routing|or-tools|warm-start|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6241" PostTypeId="2" ParentId="6240" CreationDate="2021-05-10T16:33:27.027" Score="2" Body="&lt;p&gt;I believe the warning comes from SCIP. So check the documentation there.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2021-05-10T16:33:27.027" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6242" PostTypeId="2" ParentId="6240" CreationDate="2021-05-10T18:05:25.150" Score="7" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;SetSolverSpecificParametersAsString(&amp;quot;heuristics/completesol/maxunknownrate = 0.9&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.scipopt.org/doc/html/PARAMETERS.php&quot; rel=&quot;noreferrer&quot;&gt;SCIP params&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/linear_solver/scip_interface.cc#L1028&quot; rel=&quot;noreferrer&quot;&gt;SetSolverSpecificParametersAsString usage&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="991" LastActivityDate="2021-05-10T18:05:25.150" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6243" PostTypeId="2" ParentId="6238" CreationDate="2021-05-10T19:13:25.113" Score="6" Body="&lt;p&gt;&lt;a href=&quot;https://math.stackexchange.com/a/4134332/31498&quot;&gt;Cross-posting&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The math looks good but why starting with &lt;span class=&quot;math-container&quot;&gt;$\nabla f(x) = 0$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2}\nabla f(x) = 0$&lt;/span&gt;? You should have noticed that the factor &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; was everywhere and could be simplified.&lt;/p&gt;&#xA;&lt;p&gt;For the curious readers who wonder whether there exists a simpler solution to this simple problem: the answer is yes. It suffices to notice that the sum of the elements of &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is a constant (&lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt;) and apply the following inequality:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;m(a_1^2 +a_2^2+\dots+a_m^2) \ge (a_1+a_2+\dots+a_m)^2,&#xA;\end{equation}&lt;/span&gt;&#xA;with equality occurs if and only if &lt;span class=&quot;math-container&quot;&gt;$a_1=a_2=\dots=a_m$&lt;/span&gt;. More concretely one should use the form &lt;span class=&quot;math-container&quot;&gt;$(a_0^2 +a_1^2+\dots+a_n^2) \ge \frac{1}{n+1} (a_0+a_1+\dots+a_n)^2,$&lt;/span&gt; where the &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; are the &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; elements of &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;. The minimum is attained at &lt;span class=&quot;math-container&quot;&gt;$a_0=a_2=\dots=a_n=\frac{S}{n+1}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$S=-1$&lt;/span&gt; is the sum of all elements, which yields immediately &lt;span class=&quot;math-container&quot;&gt;$x_1=\frac{n+2}{n+1}$&lt;/span&gt; and consequently all the other &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;P/s: The following solution is only for your reference, I do not recommend it.&lt;/p&gt;&#xA;&lt;p&gt;Applying the inequality &lt;span class=&quot;math-container&quot;&gt;$z^2\ge - \frac{2z}{n+1} - \frac{1}{(n+1)^2}$&lt;/span&gt; (which is true because it is equivalent to &lt;span class=&quot;math-container&quot;&gt;$\left(z + \frac{1}{n+1}\right)^2\ge 0$&lt;/span&gt;) to each of the elements of &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; (i.e., replacing &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; by those elements), and summing up the obtained &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; inequalities, we obtain immediately the results.&lt;/p&gt;&#xA;" OwnerUserId="5481" LastActivityDate="2021-05-10T19:13:25.113" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6244" PostTypeId="2" ParentId="3952" CreationDate="2021-05-11T04:50:03.530" Score="4" Body="&lt;p&gt;The latest &lt;a href=&quot;https://jump.dev/&quot; rel=&quot;nofollow noreferrer&quot;&gt;JuMP&lt;/a&gt;.jl website gives a few examples of its use in industry:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.the74million.org/article/building-a-smarter-and-cheaper-school-bus-system-how-a-boston-mit-partnership-led-to-new-routes-that-are-20-more-efficient-use-400-fewer-buses-save-5-million/&quot; rel=&quot;nofollow noreferrer&quot;&gt;route school buses&lt;/a&gt; by the Boston school district&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://juliacomputing.com/case-studies/psr/&quot; rel=&quot;nofollow noreferrer&quot;&gt;plan powergrid expansion&lt;/a&gt; by PSR&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://juliacomputing.com/case-studies/moo/&quot; rel=&quot;nofollow noreferrer&quot;&gt;optimize milk output&lt;/a&gt; by dairy farmers in New Zealand&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I personally find JuMP.jl, by far, the most user-friendly and flexible optimization interface I ever used. By far.&lt;/p&gt;&#xA;" OwnerUserId="5482" LastEditorUserId="8" LastEditDate="2021-05-11T06:58:04.923" LastActivityDate="2021-05-11T06:58:04.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6245" PostTypeId="1" AcceptedAnswerId="6247" CreationDate="2021-05-11T11:42:16.463" Score="2" ViewCount="70" Body="&lt;p&gt;I would like to seek some modeling advice on the following:&lt;/p&gt;&#xA;&lt;p&gt;Say for instance I have 5 nodes representing workstations of the operation of 5 jobs, and that I have less than 5 vehicles. Say I have two vehicles.&lt;/p&gt;&#xA;&lt;p&gt;It is obvious that only 2 workstations will be serviced at the beginning while the rest will have to wait till either of the 2 have finished processing.&lt;/p&gt;&#xA;&lt;p&gt;Hence, say for instance, vehicles have been assigned to visit stations 1 and 2, with the start time of each station being the distance traveled, and that both vehicles depart from the depot at time 0.&lt;/p&gt;&#xA;&lt;p&gt;The difficulty resides in finding the minimum of the 2 completion times, so that the earliest of the remaining 3 stations to be served is approximated by setting it to be greater than or equal to that of the minimal completion times of both said stations.&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="3682" LastEditDate="2021-05-11T12:24:23.063" LastActivityDate="2021-05-11T15:49:44.817" Title="Finding the minimum of a group of timings" Tags="|mixed-integer-programming|modeling|integer-programming|combinatorial-optimization|binary-variable|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6246" PostTypeId="1" AcceptedAnswerId="6251" CreationDate="2021-05-11T12:56:50.497" Score="5" ViewCount="285" Body="&lt;p&gt;I am trying to add some more constraints to the flow-based ADVRP model in &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0377221712008922?casa_token=cIPGSnOBUbQAAAAA:bIB8mN8a9IXM2z6LgZBLk1t-l35nbWac3HpXgIjtJDwg_wgapURWY_c-wW0S1fsKC2J8QAM_Fg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Almoustafa &lt;em&gt;et al.&lt;/em&gt; (2013)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; (pp.4).&lt;/p&gt;&#xA;&lt;p&gt;The mentioned model caps the travel distance, while I cap the travel time. Let &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; represent the maximum travel time each vehicle can make. Additionally, there is a node-dependent time spent at each delivery node. For example, if 5 packages are delivered to location &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, the truck will spend 25 minutes (assuming 5 min per package). I think, I can address this by embedding, &lt;span class=&quot;math-container&quot;&gt;$s_j:=\text{time spent at delivery node } j$&lt;/span&gt;, into (6) and (9). I don't add this into the objective because I only want to minimize the travel time without including the package drop time. Firstly, is the following formulation correct based on the assumptions? Consider the following set definitions: &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; set of nodes, where &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; represents the depot, and the parameter: &lt;span class=&quot;math-container&quot;&gt;$T_{ij}$&lt;/span&gt; is the asymmetric travel time from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$T_{ii}=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min&amp;amp;\quad\sum_{i,j\in I, i\neq j}T_{ij} x_{ij}\tag1&#xA;\\\text{s.t.}&amp;amp;\quad\sum_{i\in I, i\neq j}x_{ij} = 1 \quad \forall j\in I\setminus\{0\}\tag2&#xA;\\&amp;amp;\quad\sum_{j\in I, i\neq j}x_{ij} = 1 \quad \forall i\in I\setminus\{0\}\tag3&#xA;\\&amp;amp;\quad\sum_{i\in I\setminus\{0\}}x_{0i} = m\tag4&#xA;\\&amp;amp;\quad\sum_{i\in I\setminus\{0\}}x_{i0} = m\tag5&#xA;\\&amp;amp;\quad\sum_{j\in I,i\neq j}z_{ij}-\sum_{j\in I,i\neq j}z_{ji}-\sum_{j\in I,i\neq j}\left(T_{ij}-s_j\right)x_{ij} = 0 \quad \forall i \in I\setminus\{0\}\tag6&#xA;\\&amp;amp;\quad z_{ij} \leq (U-T_{j0})x_{ij} \quad \forall i\in I,j\in I\setminus{\{0\}}, i\neq j\tag7&#xA;\\&amp;amp;\quad z_{i0} \leq U x_{i0} \quad \forall i\in I \setminus{\{0\}}\tag8&#xA;\\&amp;amp;\quad z_{ij} \geq (T_{ij}+T_{0i}+s_j)x_{ij} \quad \forall i\in I\setminus{\{0\}},j\in I, i\neq j\tag9&#xA;\\&amp;amp;\quad z_{0i} = T_{0i}x_{0i} \quad \forall i\in I\setminus{\{0\}}\tag{10}&#xA;\\&amp;amp;\quad x_{ij} \in \{0,1\}, z_{ij} \in \mathbb{R}_{\geq 0}, m\in \mathbb{Z}_{\geq 0}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Next, I want to constrain the number of packages each truck can deliver. Say, we have a capacity of &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; packages for each truck, and &lt;span class=&quot;math-container&quot;&gt;$P_j$&lt;/span&gt; is the number of packages to deliver at each node. How can I incorporate these constraints?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Almoustafa, S., Hanafi, S., Mladenović, N. (2013). New exact method for large asymmetric distance-constrained vehicle routing problem. &lt;em&gt;European Journal of Operational Research.&lt;/em&gt; 226(3):386-394. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="123" LastEditDate="2021-05-11T13:20:48.780" LastActivityDate="2021-05-12T16:26:19.073" Title="Asymmetric time-constrained capacitated vehicle routing problem" Tags="|linear-programming|vehicle-routing|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6247" PostTypeId="2" ParentId="6245" CreationDate="2021-05-11T15:49:44.817" Score="2" Body="&lt;p&gt;Assuming that the routing of the vehicles is part of the solution, you will likely need a ton of binary variables. The binary variables will determine both which vehicles serve which stations and also the sequencing. There are multiple ways to approach this. For instance, you might have &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1$&lt;/span&gt; if vehicle &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; serves station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{jk}=1$&lt;/span&gt; if station &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is served immediately after station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; by the same vehicle that served &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, or you might have &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1$&lt;/span&gt; if vehicle &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; serves station &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; immediately after serving station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Once you have the binary variables pinned down, you can use continuous variables to capture the start times and end times for operations. This typically involves &amp;quot;big M&amp;quot; constraints. For example, using the triple-subscripted &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; above, suppose &lt;span class=&quot;math-container&quot;&gt;$s_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e_j$&lt;/span&gt; are continuous variables capturing the start and end of operations at station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt; is a parameter representing the processing time at station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; if served by vehicle &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. (You can drop the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; subscript if processing time is independent of the vehicle doing the processing.) Getting the end time from the start time is easy:&lt;span class=&quot;math-container&quot;&gt;$$e_k = s_k + \sum_i p_{ik} \sum_j x_{ijk}.$$&lt;/span&gt;(I'm assuming here that each vehicle visits each station at most once.) Getting the start time from the end time of the previous station is a bit trickier. Assume that &lt;span class=&quot;math-container&quot;&gt;$t_{ijk}$&lt;/span&gt; is a parameter representing the transit time for vehicle &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; from station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to station &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. (Again, drop the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; if all vehicles operate at the same speed.) The start time constraints look like&lt;span class=&quot;math-container&quot;&gt;$$s_k \ge e_j + t_{ijk} -M(1-x_{ijk})\quad \forall i,j.$$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=0$&lt;/span&gt;, the constraint is vacuous. if &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1$&lt;/span&gt; (vehicle &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; goes to station &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; immediately after station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;), station &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; starts no earlier than the ending time at station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; plus the transit time between stations.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-05-11T15:49:44.817" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="6248" PostTypeId="2" ParentId="6246" CreationDate="2021-05-11T21:01:44.857" Score="4" Body="&lt;p&gt;Define a directed graph &lt;span class=&quot;math-container&quot;&gt;$G(V,A)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$V=\{0,1,2,\dots,n,n+1\}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; are the starting and ending depot of the vehicles (these depots are typically the same physical depots, but duplicating the depot makes modelling easier). Let &lt;span class=&quot;math-container&quot;&gt;$V'=\{1,2,\dots,n\}$&lt;/span&gt; be the set of customers. Then arc set &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is defined as &lt;span class=&quot;math-container&quot;&gt;$A\subseteq \{0\}\times V'\ \cup V'\times V' \cup V'\times \{n+1\}$&lt;/span&gt;. Note that the starting depot &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; has only &lt;em&gt;outgoing&lt;/em&gt; arcs, and the ending depot &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; has only &lt;em&gt;incoming&lt;/em&gt; arcs.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Parameters:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt;: parameter defining the travel time from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s_j$&lt;/span&gt;: service time of node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$s_0=s_{n+1}=0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;: number of allowed vehicles&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\overline{Q}$&lt;/span&gt;: truck capacity&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$q_i$&lt;/span&gt;: demand of node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$q_0=q_{n+1}=0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\overline{T}$&lt;/span&gt;: maximum travel time&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Decision variables:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt;: Binary variable determining whether arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is used by some vehicle&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Q_i$&lt;/span&gt;: Residual capacity of the vehicle serving node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T_i$&lt;/span&gt;: Departure time of the vehicle servicing node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Model:&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\mbox{minimize}~&amp;amp; \;\sum_{(i,j)\in A}t_{ij}x_{ij}&amp;amp; \\&#xA;\mbox{s.t. } &amp;amp;\sum_{(0,j)\in A}x_{0j}=m  &amp;amp; \\ % use m vehicles&#xA;&amp;amp;\sum_{(j,i)\in A}x_{ji}=1 &amp;amp; \forall i\in V'\\ %every customer must be visited by exactly 1 vehicle&#xA;&amp;amp;\sum_{(i,j)\in A}x_{ij}=1 &amp;amp; \forall i\in V'\\ % leave every visited node&#xA;&amp;amp;T_j\geq(T_i+t_{ij}+s_j)-\overline{T}(1-x_{ij}) &amp;amp; \forall (i,j)\in A\\&#xA;&amp;amp;Q_j\geq(Q_i+q_j)-\overline{Q}(1-x_{ij})  &amp;amp; \forall (i,j)\in A\\&#xA;&amp;amp; x_{ij} \in \{0,1\} &amp;amp; \forall (i,j)\in A\\&#xA;&amp;amp; T_0=0 &amp;amp; \\&#xA;&amp;amp; 0\leq T_i\leq \overline{T} &amp;amp; \forall i\in V\\&#xA;&amp;amp; Q_0=0 &amp;amp; \\&#xA;&amp;amp; 0\leq Q_i\leq \overline{Q} &amp;amp; \forall i\in V&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first 3 constraints resp. ensure that (1) &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; vehicles leave the starting depot, (2) every customer is visited by exactly 1 vehicle, (3) exactly one vehicle leaves the customer.&#xA;The 4th and 5th constraint take care of the vehicle departure times and vehicle capacities. As per example, for the vehicle capacity constraints: If a vehicle travels arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, then its capacity at node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; equals its capacity at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, plus the quantity it picked up at &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. Similarly, for the departure times: if a vehicle traverses arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, then its departure time at &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; equals its departure time at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; plus the travel time from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, plus the service time at &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2021-05-11T21:37:00.593" LastActivityDate="2021-05-11T21:37:00.593" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6249" PostTypeId="1" CreationDate="2021-05-12T07:25:22.253" Score="1" ViewCount="992" Body="&lt;p&gt;I get an error in Pyomo that I do not understand. I habe 288 timeslots t and a binary variable y (which I call here &lt;code&gt;model.variable_HPswitchedOff_Individual_SpaceHeating &lt;/code&gt;) and another binary variable x (which I call &lt;code&gt;model.variable_HPswitchedOff_HelpAssociatedBinary_SpaceHeating&lt;/code&gt;). Now I want to have an equation that sets:&lt;/p&gt;&#xA;&lt;p&gt;y(t) &amp;lt;= x(t-1)    for all t &amp;gt;=2&lt;/p&gt;&#xA;&lt;p&gt;y(t) =0    for t = 1&lt;/p&gt;&#xA;&lt;p&gt;I only do this if the boolean from another file &lt;code&gt;Run_Simulations.considerMaxiumNumberOfStartsHP_Individual ==True:&lt;/code&gt; Basically I am trying to implement the first suggested equations from here&lt;a href=&quot;https://or.stackexchange.com/questions/6127/how-to-set-a-limit-for-a-switch-to-0-of-a-variable&quot;&gt;How to set a limit for a switch to 0 of a variable&lt;/a&gt; (but in the equations in the link there is a small error because there the t begins by 1 but it should begin by 2 for the difference equation). Here is a part of my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.set_timeslots = pyo.RangeSet(1, 288)&#xA;model.variable_HPswitchedOff_Individual_SpaceHeating = pyo.Var(model.set_timeslots, within =pyo.Binary)&#xA;model.variable_HPswitchedOff_HelpAssociatedBinary_SpaceHeating = pyo.Var(model.set_timeslots, within =pyo.Binary)&#xA;    &#xA;    def maximumNumberOfStarts_Individual_SpaceHeating_EQ1_Rule (model, t):&#xA;        if Run_Simulations.considerMaxiumNumberOfStartsHP_Individual ==True:&#xA;            if t == model.set_timeslots.first():&#xA;                return model.variable_HPswitchedOff_Individual_SpaceHeating [t] == 0&#xA;            return model.variable_HPswitchedOff_Individual_SpaceHeating [t] &amp;lt;= model.variable_HPswitchedOff_HelpAssociatedBinary_SpaceHeating [t-1] &#xA;            &#xA;    model.constraint_maximumNumberOfStarts_Individual_SpaceHeating_EQ1 = pyo.Constraint(model.set_timeslots, rule =maximumNumberOfStarts_Individual_SpaceHeating_EQ1_Rule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, when I execute it, I get an error message that I do not understand&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ValueError: Constraint 'constraint_maximumNumberOfStarts_Individual_SpaceHeating_EQ1[1]': rule returned None.&#xA;&#xA;Constraint rules must return either a valid expression, a 2- or 3-member&#xA;tuple, or one of Constraint.Skip, Constraint.Feasible, or&#xA;Constraint.Infeasible.  The most common cause of this error is&#xA;forgetting to include the &amp;quot;return&amp;quot; statement at the end of your rule.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Do you have an idea what the problem might be and how I can get rid of it? As indicated the problem is caused by the first timeslot for the equation but I do not know how to solve it because in another equation in my model I have exactly the same structure and it works. I'd appreciate every comment.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I think the problem is that the boolean variable &lt;code&gt;Run_Simulations.considerMaxiumNumberOfStartsHP_Individual ==True&lt;/code&gt; was False such that there was no instruction for the constraint. But this brings me to another follow-up question. How can I exclude constraints from the model based on the boolean value of a external if-statement (external means that is does not come from the model itself)?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2021-05-12T08:40:52.580" LastActivityDate="2023-01-07T11:09:40.837" Title="Value Error in Pyomo: Constraint rule returned None" Tags="|python|pyomo|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="6250" PostTypeId="2" ParentId="239" CreationDate="2021-05-12T11:13:39.360" Score="1" Body="&lt;p&gt;The answer provided by Joris Kinable is correct for CP Optimizer versions up to 12.7.1&#xA;Starting from 12.8.0 they made changes in the API (more info &lt;a href=&quot;https://www.ibm.com/docs/fi/icos/12.8.0.0?topic=v1271-new-feature-api-changes-extension-engine-classes&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;What this basically means is that you should change IloCP to IloCPEngine (in .hpp and .cpp files), and you are more or less set to go!&lt;/p&gt;&#xA;" OwnerUserId="5494" LastEditorUserId="123" LastEditDate="2021-05-12T11:35:42.707" LastActivityDate="2021-05-12T11:35:42.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6251" PostTypeId="2" ParentId="6246" CreationDate="2021-05-12T11:59:37.703" Score="3" Body="&lt;p&gt;@JorisKinable uses the MTZ-like constraints to ensure the capacities on the vehicles are respected. Unfortunately, this formulation is known to be (very) weak, and you will probably not be able to solve any large instances.&lt;/p&gt;&#xA;&lt;p&gt;I would suggest to use a network flow based formulation, akin to the formulation you already have to keep track of the time consumption. To that end, introduce a new variable, &lt;span class=&quot;math-container&quot;&gt;$f_{ij}$&lt;/span&gt; for each arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; in the graph. This variable is defined as follows: if &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$f_{ij}$&lt;/span&gt; denotes the amount of goods (number of packages) delivered on the route to customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; when the vehicle leaves customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Otherwise, &lt;span class=&quot;math-container&quot;&gt;$f_{ij}=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To ensure that the &lt;span class=&quot;math-container&quot;&gt;$f_{ij}$&lt;/span&gt; variables follow this definition, you should introduce the following sets of constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  &amp;amp;f_{ij} \leq Kx_{ij}&amp;amp;&amp;amp;\forall i,j\in I:i\neq j\\&#xA;  &amp;amp;f_{ij}\geq 0,&amp;amp;&amp;amp; \forall i,j\in I:i\neq j\\&#xA;  &amp;amp;\sum_{j \in I}f_{ij}=\sum_{j\in I}f_{ji}+P_i,&amp;amp;&amp;amp;\forall i\in I\setminus\{0\}&#xA;\end{align}&lt;/span&gt;&#xA;The first set of constraints ensure that &lt;span class=&quot;math-container&quot;&gt;$f_{ij}=0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=0$&lt;/span&gt; and that the number of packages delivered on a tour does not exceed the capacity of the vehicle when &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$f_{ij}\leq K$&lt;/span&gt;). The second set enforces the non-negativity and finally the last set of constraints say that the number of packages delivered when leaving node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; must equal the number of packages delivered when entering node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; plus those packages delivered at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. This must hold for all customer nodes.&lt;/p&gt;&#xA;&lt;p&gt;It is fairly easy to show, that this formulations is stronger than the MTZ formulation. The formulation can be strengthened by tightening the first and second set of constraints as follows&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  &amp;amp;f_{ij} \leq (K-P_j)x_{ij}&amp;amp;&amp;amp;\forall i,j\in I:i\neq j\\&#xA;  &amp;amp;f_{ij}\geq P_ix_{ij},&amp;amp;&amp;amp; \forall i,j\in I:i\neq j\\&#xA;\end{align}&lt;/span&gt;&#xA;With this strengtening, the formulation produces the same bound as when you exactly separate all &lt;em&gt;Generalize Large Multi-star&lt;/em&gt; inequalities, meaning this formulation, although not the strongest, actually performs OK bound-wise.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2021-05-12T16:26:19.073" LastActivityDate="2021-05-12T16:26:19.073" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6254" PostTypeId="1" CreationDate="2021-05-13T05:14:36.873" Score="1" ViewCount="211" Body="&lt;p&gt;I have the following problem which seems to be a mixture of a resource constrained scheduling and packing problem.&lt;/p&gt;&#xA;&lt;p&gt;There is a set of activities &lt;span class=&quot;math-container&quot;&gt;$A_1,\ldots,A_n$&lt;/span&gt; and given precedences &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$(A_i,A_j)\in P$&lt;/span&gt; means &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; needs to run before &lt;span class=&quot;math-container&quot;&gt;$A_j$&lt;/span&gt;. There is a set of machines &lt;span class=&quot;math-container&quot;&gt;$M_1,\ldots,M_k$&lt;/span&gt;. Any activity can be run on any machine. Each &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; has a certain resource consumption on a machine.&lt;/p&gt;&#xA;&lt;p&gt;Here the packing aspect comes into play. Any machine can be viewed as a rectangle where the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;-coordinate is time and the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;-coordinate is the amount of a resource. Any activity &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; has a resource consumption characterized by an area &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;. Say, if &lt;span class=&quot;math-container&quot;&gt;$A_1,\ldots,A_3$&lt;/span&gt; are scheduled on &lt;span class=&quot;math-container&quot;&gt;$M_1$&lt;/span&gt; then we have to place rectangles &lt;span class=&quot;math-container&quot;&gt;$r_1,\ldots,r_3$&lt;/span&gt; of areas &lt;span class=&quot;math-container&quot;&gt;$c_1,\ldots,c_3$&lt;/span&gt; into the rectangle of &lt;span class=&quot;math-container&quot;&gt;$M_1$&lt;/span&gt; without overlap. The goal is to schedule each task on a machine such that the least amount of time has elapsed. This is equal to minimizing the maximum &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;-coordinate of the machines where there is no activity to the right.&lt;/p&gt;&#xA;&lt;p&gt;In a further variant it is also possible that for a activity &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; we can place multiple rectangles &lt;span class=&quot;math-container&quot;&gt;$r_{i1},\ldots,r_{ij}$&lt;/span&gt; into the big rectangle of a machine, such that the areas of those rectangles sum up to &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;. But there is also the restriction that &lt;span class=&quot;math-container&quot;&gt;$r_{i1},\ldots,r_{ij}$&lt;/span&gt; do not have gaps with respect to the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;-coordinates and must be scheduled to the same machine.&lt;/p&gt;&#xA;" OwnerUserId="5501" LastEditorUserId="123" LastEditDate="2021-05-13T06:19:23.357" LastActivityDate="2021-05-16T05:11:29.970" Title="What kind of scheduling/packing problem is this?" Tags="|optimization|scheduling|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6255" PostTypeId="1" AcceptedAnswerId="6256" CreationDate="2021-05-13T17:00:22.753" Score="4" ViewCount="877" Body="&lt;p&gt;This question is a follow-up to &lt;a href=&quot;https://or.stackexchange.com/questions/6246/asymmetric-time-constrained-capacitated-vehicle-routing-problem?noredirect=1#comment11021_6246&quot;&gt;this one&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Since I understand the complexity of the problem I have been underestimating, I turned my attention to off-the-shelf solvers, like &lt;a href=&quot;https://vrpy.readthedocs.io/en/dev/solving_options.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;VRPy&lt;/a&gt; and &lt;a href=&quot;https://developers.google.com/optimization/routing/vrp&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR-tools&lt;/a&gt;. I would like to use these tools either to completely solve the problem or to obtain a heuristic solution to feed into the formulation provided in &lt;a href=&quot;https://or.stackexchange.com/questions/6246/asymmetric-time-constrained-capacitated-vehicle-routing-problem?noredirect=1#comment11021_6246&quot;&gt;here&lt;/a&gt;. The size of the problem I am trying to deal with is around 1,000-1,500 nodes, single depot, single vehicle type, node varying demand and service time, and fixed load capacity and tour durations.&lt;/p&gt;&#xA;&lt;p&gt;To solve the problem with VRPy in Python, I coded is as follows, and I want to make sure it is coded correctly. Another concern is that does VRPy minimize only the travel time or does it include the service time?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from networkx import DiGraph&#xA;from vrpy import VehicleRoutingProblem&#xA;G = DiGraph()&#xA;for i, j in TT.keys():&#xA;    if i != j:&#xA;        if i == Depot_loc:&#xA;            k = &amp;quot;Source&amp;quot;&#xA;        else:&#xA;            k = i&#xA;        if j == Depot_loc:&#xA;            l = &amp;quot;Sink&amp;quot;&#xA;        else:&#xA;            l = j&#xA;        G.add_edge(k, l, cost = TT[i,j], time = TT[i,j])&#xA;for j in [i for i in I if i != Depot_loc]:&#xA;    G.nodes[j][&amp;quot;demand&amp;quot;] = 3&#xA;    G.nodes[j][&amp;quot;service_time&amp;quot;] = 100&#xA;prob = VehicleRoutingProblem(G, load_capacity=120, duration = 36000)&#xA;prob.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here, &lt;code&gt;TT&lt;/code&gt; is a dictionary keyed by a tuple of node indices and valued as the travel time between all nodes (including the depot, represented by &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;), and the &lt;code&gt;Depot_loc&lt;/code&gt; is the index for depot. In &lt;code&gt;TT&lt;/code&gt;, &lt;code&gt;TT[i,j] = 0&lt;/code&gt;, when &lt;span class=&quot;math-container&quot;&gt;$i=j$&lt;/span&gt;. For simplicity, I assume all nodes demand &lt;code&gt;3&lt;/code&gt; units to be delivered, and the service time at all nodes are &lt;code&gt;100&lt;/code&gt; seconds (so, a vehicle arriving at a node will spend &lt;code&gt;100&lt;/code&gt; seconds additional to driving times). I further assume, each vehicle can carry &lt;code&gt;120&lt;/code&gt; units, and the total tour time for each should not exceed &lt;code&gt;36,000&lt;/code&gt; seconds.&lt;/p&gt;&#xA;&lt;p&gt;I thought over the OR-tools application in Python but found it a bit complicated to implement. Your help for comparison is appreciated!&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="518" LastEditDate="2021-05-13T17:11:09.393" LastActivityDate="2021-05-13T19:26:51.333" Title="Using VRPy and OR-tools in Python to solve the DCVRP" Tags="|or-tools|vrpy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6256" PostTypeId="2" ParentId="6255" CreationDate="2021-05-13T19:11:41.847" Score="5" Body="&lt;p&gt;1 500 nodes is a lot... don't expect any MILP solver to find decent solutions quickly (or at all). See for example @LocalSolver's &lt;a href=&quot;https://www.localsolver.com/benchmarktsp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;benchmarks&lt;/a&gt;. Which brings me to my next point: for big graphs, maybe LocalSolver is the way to go.&lt;/p&gt;&#xA;&lt;p&gt;I also think its worth giving &lt;em&gt;or tools&lt;/em&gt; a try. The API is not that user friendly (in my opinion), but the optimization engine is powerful, and its all free. Also, the &lt;a href=&quot;https://developers.google.com/optimization/routing&quot; rel=&quot;nofollow noreferrer&quot;&gt;examples&lt;/a&gt; are very useful and well documented. Your example would be quite straightforward to implement.&lt;/p&gt;&#xA;&lt;p&gt;Now if you insist on wanting to use VRPy, I am not going to argue, but don't expect good performances with such graphs.&lt;/p&gt;&#xA;&lt;p&gt;The Python code looks good,  except for &lt;code&gt;TT[i,j]&lt;/code&gt;, I am pretty sure you will get an error. Instead use &lt;code&gt;TT[(i,j)]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that if you constrain the routes to have maximum duration, the route duration does include the travel time, and the service time, which is logical.&lt;/p&gt;&#xA;&lt;p&gt;You can also minimize the global time span with &lt;code&gt;VehicleRoutingProblem(minimize_global_span=True)&lt;/code&gt;. This may however have an impact on computation times, because the linear relaxation of the formulation becomes weak. This was discussed in &lt;a href=&quot;https://or.stackexchange.com/questions/4772/branch-and-price-algorithm/5191#5191&quot;&gt;this post&lt;/a&gt; some time ago.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-05-13T19:26:51.333" LastActivityDate="2021-05-13T19:26:51.333" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6257" PostTypeId="1" CreationDate="2021-05-13T23:10:56.350" Score="2" ViewCount="235" Body="&lt;p&gt;I have an MILP program written in Pyomo and I am using CBC as a solver. Below is a description of my problem:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The model works fine when it is run on my local computer&lt;/li&gt;&#xA;&lt;li&gt;The output is the following in local machine: Number of objectives: 1, Number of constraints: 5184, Number of variables: 3507. Status: ok, Message: CBC 2.10.3 optimal, objective 1538.88: 28 nodes, 4878 iterations, 4.5 seconds...etc&lt;/li&gt;&#xA;&lt;li&gt;When I move it over to a new server accessed by remote desktop the program fails&lt;/li&gt;&#xA;&lt;li&gt;The output is the following on RDP: Number of objectives: 1, Number of constraints: 0, Number of variables: 0, Status: ok, Message: CBC 2.10.3.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;It seems that the model is not being properly accessed by the solver when I run it on remote desktop, but I don't know how to fix it. If I remove the solver and just run it to see what happens, the problem is 'Infeasible' but I get the correct number of constraints and variables. Help would be appreciated!&lt;/p&gt;&#xA;&lt;p&gt;This is what the first few lines of the .sol file looks like if the program was successful: &lt;a href=&quot;https://i.stack.imgur.com/uxFKy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uxFKy.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And this is what it looks like if it fails:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/A7HPU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/A7HPU.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I figured out that the issue for the hours the program fails is that the problem is infeasible. So now my question is, why am I not getting an 'infeasible' status output from the solver?&lt;/p&gt;&#xA;" OwnerUserId="4806" LastEditorUserId="4806" LastEditDate="2021-05-14T18:21:08.110" LastActivityDate="2023-10-19T11:12:07.380" Title="Pyomo Trouble - Number of Constraints in Output is 0 When It Should Be &gt; 5000" Tags="|mixed-integer-programming|pyomo|cbc|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6258" PostTypeId="2" ParentId="6254" CreationDate="2021-05-14T17:34:49.943" Score="3" Body="&lt;p&gt;I'm not sure there is name for your specific problem, but I think it is safe to say that it falls into the umbrella category of &lt;em&gt;job shop scheduling&lt;/em&gt;, with the objective of minimizing &lt;em&gt;makespan&lt;/em&gt;. If you do a web search for &amp;quot;taxonomy of job shop models&amp;quot; you will find a barely finite number of diagrams and articles on the subject. &lt;a href=&quot;https://www.researchgate.net/publication/339128833_Job_shop_scheduling_Classification_constraints_and_objective_functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;This paper&lt;/a&gt;, for instance, gives some structure the general subject.&lt;/p&gt;&#xA;&lt;p&gt;Both integer programming models and constraint programming models are commonly used for problems such as yours. I will note, among the various options, that IBM's CP Optimizer constraint solver has global constraints specifically designed for scheduling problems, including one or more that let you model resources that can be shared by simultaneous tasks as long as their collective demand for the resource does not exceed supply. (Supply can vary with time.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-05-14T17:34:49.943" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6259" PostTypeId="1" CreationDate="2021-05-15T05:57:00.240" Score="1" ViewCount="57" Body="&lt;p&gt;This arises from an engineering problem I am working on. Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{c}_i,\mathbf{a}_i\in \mathbb{R}^{d}$&lt;/span&gt; be a given set (collection) of vectors where &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,\dots,n\}$&lt;/span&gt;. Define the bounded polyhedrons (indexed over &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;)&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathcal{Q}_i\,=\,\{\mathbf{x}_i\in\mathbb{R}^d ~\lvert~ \mathbf{A}_i\mathbf{x}_i\leq \mathbf{b}_i,~\mathbf{x}_i\geq 0 \}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}_i$&lt;/span&gt; is a matrix and vector defining the bounded polyhedron &lt;span class=&quot;math-container&quot;&gt;$\mathcal{Q}_i$&lt;/span&gt; (over all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;) with appropriate dimensions and assume their interiors are non-empty. Now, consider the optimization problem (&lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is a positive constant)&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_{\mathbf{x}_i} ~&amp;amp;\sum_{i=1}^{n}\mathbf{c}_i^T\mathbf{x}_i ~\\&#xA;~~&amp;amp;\sum_{i=1}^{n}\mathbf{a}_i^T\mathbf{x}_i~\leq~\alpha \\&#xA;~~&amp;amp;\mathbf{x}_i\in\mathcal{Q}_i~,~~\forall i \in \{1,\dots,n\}&#xA;\end{align}&lt;/span&gt;&#xA;You can see that this can be converted to the standard input form for the Dantzig-Wolfe Decomposition (DWD). Due to the properties of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{Q}_i$&lt;/span&gt;, it turns out that I can assume access to an oracle that can solve the collection of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; subproblems extremely fast compared to a standard LP solver&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_{\mathbf{x}_i} ~&amp;amp;\mathbf{c}_i^T\mathbf{x}_i ~\\&#xA;~~&amp;amp;\mathbf{x}_i\in\mathcal{Q}_i~&#xA;\end{align}&lt;/span&gt;&#xA;Given the Oracle, how should I modify the steps of DWD? can you please provide the details?&lt;/p&gt;&#xA;&lt;p&gt;I can also assume that the oracle is extremely fast at giving the extreme points of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{Q}_i$&lt;/span&gt;. Given these two facts, can I further specialize the iterations of DWD. Do you mind providing the steps of the DWD then?&lt;/p&gt;&#xA;" OwnerUserId="3024" LastActivityDate="2021-05-15T05:57:00.240" Title="Specializing Iterations of Dantzig-Wolfe Decomposition with an Oracle" Tags="|linear-programming|dantzig-wolfe-decomposition|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6260" PostTypeId="2" ParentId="6254" CreationDate="2021-05-15T20:00:59.613" Score="2" Body="&lt;p&gt;Besides the useful answers mentioned by community folks, some notations would be considered:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;As there are many scheduling environments in the real situation or academic literature you should first determine which kind of scheduling model you have faced. For this, it would be helpful to see the &lt;a href=&quot;https://en.wikipedia.org/wiki/Notation_for_theoretic_scheduling_problems#:%7E:text=A%20convenient%20notation%20for%20theoretic,%3A%20%CE%B1%2C%20%CE%B2%20and%20%CE%B3.&amp;amp;text=The%20%CE%B1%20field%20describes%20the,and%20%CE%B3%20the%20objective%20function.&quot; rel=&quot;nofollow noreferrer&quot;&gt;Graham notation&lt;/a&gt; to determine (or at least for the benchmark) the scheduling model.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Please, keep in mind that in the (hybrid) flow shop or (flexible) job shop models, there is a pre-determined route for each job/task. It means that each job/task must be processed based on and there is no way to perform that on any machine or in the favorite dispatching.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As you mentioned, &lt;code&gt;Any activity can be run on any machine&lt;/code&gt; and there is a precedence constraint for performing the jobs/tasks, it sounds like a &lt;a href=&quot;https://www.google.com/books/edition/Resource_Constrained_Project_Scheduling/ySbNA2sQcRYC?hl=en&amp;amp;gbpv=1&amp;amp;printsec=frontcover&quot; rel=&quot;nofollow noreferrer&quot;&gt;resource-constrained project scheduling model&lt;/a&gt; (RCPSP). Also, to visualize the final results, there are two kinds of diagrams. First, the resource Gantt chart and the second the task Gantt chart.&lt;/p&gt;&#xA;&lt;p&gt;I recommended you start with the RCPSP and expand it further in the next level. In the following, a variant of the mixed-integer program (time index formulation) is presented. Indeed, in contrast to the solving time, despite MIP formulation, CP is another good alternative.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{split}\textrm{Minimize} &amp;amp; \\&#xA;&amp;amp;  \sum_{t\in \mathcal{T}} t\cdot x_{(n+1,t)}\\&#xA;\textrm{Subject to:} &amp;amp; \\&#xA; \sum_{t\in \mathcal{T}} x_{(j,t)} &amp;amp; = 1  \,\,\, \forall j\in J\\&#xA; \sum_{j\in J} \sum_{t_2=t-p_{j}+1}^{t} u_{(j,r)}x_{(j,t_2)} &amp;amp; \leq c_{r}  \,\,\, \forall t\in \mathcal{T}, r \in R\\&#xA; \sum_{t\in \mathcal{T}} t\cdot x_{(s,t)} - \sum_{t \in \mathcal{T}} t\cdot x_{(j,t)} &amp;amp; \geq p_{j}  \,\,\, \forall (j,s) \in S\\&#xA;x_{(j,t)} &amp;amp; \in \{0,1\} \,\,\, \forall j\in J, t \in \mathcal{T}\end{split}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; is the set of the jobs&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; is the set of the resources&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is the precedence sets&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is the planning duration&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$P_{j}$&lt;/span&gt; is the processing time of job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$U_{(r,j)}$&lt;/span&gt; is the amount of resource &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; required for processing job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$C_{r}$&lt;/span&gt; is the capacity of renewable resource &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The resource Gantt chart of the above formulation (for &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; tasks) is shown in the following.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/CUfnE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CUfnE.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2021-05-16T05:11:29.970" LastActivityDate="2021-05-16T05:11:29.970" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6261" PostTypeId="1" AcceptedAnswerId="6286" CreationDate="2021-05-15T21:56:45.310" Score="3" ViewCount="66" Body="&lt;p&gt;I am self-learning basic optimization techniques and trying to implement the 1-dimensional line search algorithms from the book - &lt;a href=&quot;https://mitpress.mit.edu/books/algorithms-optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Algorithms for Optimization&lt;/a&gt; by Kochenderfer and Wheerler, MIT Press. I had a couple of rather straight-forward questions about the Fibonacci method.&lt;/p&gt;&#xA;&lt;p&gt;On page 37, the authors write:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Suppose we can query &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; twice. If we query &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; on the one-third and two-third points of the interval, then we are guaranteed to remove one-third of our interval.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/D6w73.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/D6w73.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;We can guarantee a tighter bracket by moving our guesses towards the center. In the limit &lt;span class=&quot;math-container&quot;&gt;$\epsilon \to 0$&lt;/span&gt;, we are guaranteed to shrink our guess by a factor of &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; as shown below.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ionqx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ionqx.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In any iteration &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, the search interval is shrunk to &lt;span class=&quot;math-container&quot;&gt;$1-\rho_k$&lt;/span&gt; times the original length.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question.&lt;/strong&gt; Does the second picture above tell that, as the process converges, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; are quite close to each other, and the reduction factor approaches &lt;span class=&quot;math-container&quot;&gt;$1/2$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0GWmd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0GWmd.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;With three queries, we can shrink the interval by a factor of three. We first query &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; on the one-third and two-third points on the interval, discard one-third of the interval, and then sample just next to the better sample as shown in the figure.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sGIwL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sGIwL.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; queries, the length of the intervals are related to the Fibonacci sequence: &lt;span class=&quot;math-container&quot;&gt;$1,1,2,3,5,8,13,\ldots$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kRwSr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kRwSr.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question.&lt;/strong&gt; I deduced this mathematically. For instance, if &lt;span class=&quot;math-container&quot;&gt;$N=5$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;I_2 &amp;amp;= (1- \rho_1) I_1 = \frac{F_5}{F_6}I_1 = \frac{8}{13} I_1\\&#xA;I_3 &amp;amp;= (1- \rho_2) I_2 = \frac{F_4}{F_5}I_2 = \frac{5}{8} \cdot \frac{8}{13} I_1\\&#xA;I_4 &amp;amp;= (1- \rho_3) I_3 = \frac{F_3}{F_4}I_3 = \frac{3}{5}\cdot \frac{5}{8} \cdot \frac{8}{13} I_1\\&#xA;I_5 &amp;amp;= (1- \rho_4) I_4 = \frac{F_2}{F_3}I_4 = \frac{2}{3} \cdot \frac{3}{5}\cdot \frac{5}{8} \cdot \frac{8}{13} I_1\\&#xA;I_6 &amp;amp;= (1- \rho_5) I_4 = \frac{F_1}{F_2}I_5 = \frac{1}{2} \cdot \frac{2}{3} \cdot \frac{3}{5}\cdot \frac{5}{8} \cdot \frac{8}{13} I_1 = \frac{1}{13}I_1&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The visual description was not super-intuitive to me. It's apparent that &lt;span class=&quot;math-container&quot;&gt;$I_1=I_2 + I_3$&lt;/span&gt; and so forth. Any insights into the visual description?&lt;/p&gt;&#xA;" OwnerUserId="5460" LastActivityDate="2021-05-20T19:21:53.463" Title="Length of intervals in Fibonacci Line Search" Tags="|optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6263" PostTypeId="1" AcceptedAnswerId="6268" CreationDate="2021-05-16T10:04:24.977" Score="4" ViewCount="369" Body="&lt;p&gt;I am currently experimenting with GUROBI and would appreciate some kind advice on the following:&lt;/p&gt;&#xA;&lt;p&gt;In &lt;a href=&quot;https://stackoverflow.com/questions/47887602/pyomo-setting-variable-branching-priorities&quot;&gt;Pyomo: Setting variable branching priorities&lt;/a&gt;, there was a response to doing so for CPLEX, hence I would like to ask if anyone has managed to do so for GUROBI too.&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="491" LastEditDate="2021-05-20T14:56:45.090" LastActivityDate="2021-05-20T14:56:45.090" Title="Setting up Branching Priority for GUROBI in Pyomo" Tags="|mixed-integer-programming|modeling|pyomo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6264" PostTypeId="1" AcceptedAnswerId="6266" CreationDate="2021-05-16T20:55:20.670" Score="2" ViewCount="322" Body="&lt;p&gt;I have a function to minimize which has the following term &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in I}\sum_{j\in J}\sum_{k\in K}x_{ijk}N_{ij}a_{ijk},$$&lt;/span&gt; where the variables are &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}\in\{0,1\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a_{ijk}$&lt;/span&gt; are given as input and &lt;span class=&quot;math-container&quot;&gt;$$N_{ij}=\sum_{k\in K}x_{ijk}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can we linearize this objective function assuming that we have the following constraints: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in I}x_{ijk}=1,\forall j,k.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3075" LastActivityDate="2021-05-16T23:32:50.380" Title="Linearize a product of binary variables" Tags="|linearization|reformulation-linearization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6265" PostTypeId="2" ParentId="6264" CreationDate="2021-05-16T22:25:06.340" Score="2" Body="&lt;p&gt;If you do it, you will force a constraint that maybe is not true. Are you sure that constraint (&lt;span class=&quot;math-container&quot;&gt;$\displaystyle \sum_{i \in I} x_{ijk}=1, \forall j,k$&lt;/span&gt;) is always true? If you are, so it's a correct approach. If you aren't, the best way to linearize this constraint is to use a big-M approach. This approach can create problems of approximation and probably you should choose a better big-M.&lt;/p&gt;&#xA;&lt;p&gt;So, let &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; a large  enough  number, note that depends of your problem, but you can use &lt;span class=&quot;math-container&quot;&gt;$M=\displaystyle \sum_{i \in i} \sum_{j \in J} \sum_{k \in K}a_{ijk})$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; a variable that models the linearization. Your objective function will be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\displaystyle \min \sum_{i \in i} \sum_{j \in J} \sum_{k \in K} y_{ij}a_{ijk}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And you will keep with the constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \displaystyle N_{ij} = \sum_{k \in K} x_{ijk} (\mbox{put the domain})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can add these constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ y_{ij} \geq - M(1-x_{ijk})  + N_{ij}, \forall i \in I, j \in J, k \in K$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ y_{ij} \leq  M(1-x_{ijk})  + N_{ij}, \forall i \in I, j \in J, k \in K$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that if &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1 \rightarrow ( y_{ij} \geq N_{ij} \wedge  y_{ij} \leq N_{ij}) \leftrightarrow y_{ij} = N_{ij}$&lt;/span&gt; and otherwise these constraints will be redundant.&lt;/p&gt;&#xA;&lt;p&gt;Maybe, depending on your problem, the value of &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; will be 0 if these constraint don't activate. But, you can force &lt;span class=&quot;math-container&quot;&gt;$y_{ij} =0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=0$&lt;/span&gt; with these constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ y_{ij} \leq Mx_{ijk}, \forall i \in I, j \in J$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5355" LastEditorUserId="36" LastEditDate="2021-05-16T23:32:50.380" LastActivityDate="2021-05-16T23:32:50.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6266" PostTypeId="2" ParentId="6264" CreationDate="2021-05-16T22:25:27.943" Score="5" Body="&lt;p&gt;Introduce bounded variable &lt;span class=&quot;math-container&quot;&gt;$y_{jk}$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in I} x_{ijk} N_{ij} a_{ijk}$&lt;/span&gt;, and minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in J}\sum_{k\in K} y_{jk}$&lt;/span&gt;.  Now enforce &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1 \implies y_{jk} = N_{ij} a_{ijk}$&lt;/span&gt;, by using either indicator constraints or big-M constraints.  If &lt;span class=&quot;math-container&quot;&gt;$a_{ijk} \ge 0$&lt;/span&gt;, you need only enforce &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1 \implies y_{jk} \ge N_{ij} a_{ijk}$&lt;/span&gt; because the minimization objective will then naturally enforce equality.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-05-16T22:25:27.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6267" PostTypeId="2" ParentId="6263" CreationDate="2021-05-17T08:47:24.467" Score="3" Body="&lt;p&gt;You can control the branching priorities in Gurobi using the &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/branchpriority.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;BranchPriority&lt;/a&gt; attribute, which you can then store in an &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/ord_format.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;.ord&lt;/a&gt; file.&lt;/p&gt;&#xA;&lt;p&gt;This file can then be provided as an input using the &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/inputfile.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;InputFile&lt;/a&gt; parameter.&lt;/p&gt;&#xA;&lt;p&gt;If you cannot add a parameter through the pyomo API, you can always create a &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/quickstart_linux/using_a_grb_env_file.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;gurobi.env&lt;/a&gt; file in the directory where your script is located and store all your parameter modifications there.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;InputFile&lt;/code&gt; parameter cannot be added as a parameter in the &lt;code&gt;gurobi.env&lt;/code&gt;. Instead, you should follow @Oguz's approach:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;msolver.options['InputFile'] = '&amp;lt;path-to-ord-file&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="133" LastEditorUserId="133" LastEditDate="2021-05-20T12:58:59.443" LastActivityDate="2021-05-20T12:58:59.443" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="6268" PostTypeId="2" ParentId="6263" CreationDate="2021-05-17T13:08:14.980" Score="3" Body="&lt;p&gt;In addition to @Richard's answer, you can simply change any of Gurobi's attributes from your Pyomo code as follow:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;msolver = SolverFactory('gurobi')&#xA;msolver.options['TimeLimit'] = 100&#xA;msolver.options['BranchPriority'] = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can set the &lt;code&gt;BranchPriority&lt;/code&gt; to whatever value you decided.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-05-17T13:08:14.980" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6269" PostTypeId="2" ParentId="6070" CreationDate="2021-05-17T14:21:13.533" Score="2" Body="&lt;h2&gt;Math Formulation + Pyomo model&lt;/h2&gt;&#xA;&lt;p&gt;We need to define 3 sets&#xA;i: 1 to 8  staffs&#xA;j: 1 to 3  shifts&#xA;t: 1 to 18 days&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{i,j,t} \in {0/1} $&lt;/span&gt; Binary&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There must be 3 people on each shift&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall t,j $&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\sum_i X_{i,j,t} =3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Every individual (i) must work 1 shift per day\&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall t,i $&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\sum_j X_{i,j,t} \geq 1 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Every individual must not work more than 2 shifts per day\&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall t,i $&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\sum_j X_{i,j,t} \leq 2 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Every individual must get at least one night shift break, preferably two.\&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall t,i $&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$X_{i,3,t}+ X_{i,3,t+1} \leq 1 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each individual must not work consecutive shifts (e.g. the night shift on Day 1 and the morning shift on Day 2) \&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall t,i $&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$X_{i,3,t}+ X_{i,1,t+1} \leq 1 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall i \sum_t X_{i,3,t} \leq Z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min Z $&lt;/span&gt;, Z represent the maximum number of nightshift for all staffs&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/O0CNE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/O0CNE.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/alirezasoroudi/Optimization/blob/main/ShiftScheduling.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;Github Link&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = AbstractModel()&#xA;model.i = RangeSet(1,8)&#xA;model.j = RangeSet(1,3)&#xA;model.t = RangeSet(1,18)&#xA;&#xA;model.X = Var(model.i,model.j,model.t, within=Binary)&#xA;model.Nshift= Var( within=NonNegativeReals)&#xA;&#xA;def Rule_C1(model,t,j):&#xA;    return sum(model.X[i,j,t] for i in model.i)==3&#xA;model.C1=Constraint(model.t,model.j,  rule=Rule_C1)&#xA;&#xA;def Rule_CA(model,t,i):&#xA;    return sum(model.X[i,j,t] for j in model.j)&amp;lt;=2&#xA;model.CA=Constraint(model.t,model.i,  rule=Rule_CA)&#xA;&#xA;def Rule_CB(model,t,i):&#xA;    return sum(model.X[i,j,t] for j in model.j)&amp;gt;=1&#xA;model.CB=Constraint(model.t,model.i,  rule=Rule_CB)&#xA;&#xA;def Rule_C2(model,t,i):&#xA;    if t&amp;lt;18:&#xA;        return model.X[i,3,t]+ model.X[i,3,t+1] &amp;lt;=1&#xA;    else:&#xA;        return Constraint.Skip&#xA;model.C2=Constraint(model.t,model.i,  rule=Rule_C2)&#xA;&#xA;def Rule_C3(model,t,i):&#xA;    if t&amp;lt;18:&#xA;        return model.X[i,3,t]+ model.X[i,1,t+1] &amp;lt;=1&#xA;    else:&#xA;        return Constraint.Skip&#xA;model.C3=Constraint(model.t,model.i,  rule=Rule_C3)&#xA;&#xA;def Rule_C4(model,i):&#xA;    return sum(model.X[i,3,t] for t in model.t)  &amp;lt;=model.Nshift&#xA;model.C4=Constraint(model.i,  rule=Rule_C4)&#xA;&#xA;def rule_OF(model):&#xA;    #return quicksum(model.X[i,j,t] for i in model.i for j in model.j for t in model.t )&#xA;    return model.Nshift+quicksum(model.X[i,j,t] for i in model.i for j in model.j for t in model.t ) &#xA;model.obj1 = Objective(rule=rule_OF, sense=minimize)&#xA;&#xA;opt = SolverFactory('gurobi')&#xA;instance = model.create_instance()&#xA;results = opt.solve(instance) # solves and updates instance&#xA;print('OF= ',value(instance.obj1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2021-05-18T13:36:49.537" LastActivityDate="2021-05-18T13:36:49.537" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6270" PostTypeId="1" AcceptedAnswerId="6284" CreationDate="2021-05-17T16:37:42.973" Score="4" ViewCount="997" Body="&lt;p&gt;I have a continuous variable &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt;. A binary variable &lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt; should be coupled to &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt; has the value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; has a value greater than &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt; has the value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; has the value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. Any idea how I can do that without including the term &lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt; in the objective function?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="4777" LastEditDate="2021-05-20T10:27:48.030" LastActivityDate="2021-05-20T10:28:14.063" Title="How to couple a binary variable to a continuous variable to indicate values greater 0" Tags="|constraint|binary-variable|indicator-constraints|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6272" PostTypeId="2" ParentId="6270" CreationDate="2021-05-17T18:25:56.273" Score="0" Body="&lt;p&gt;Many solvers and APIs allow logical constraints.&lt;/p&gt;&#xA;&lt;p&gt;For instance with OPL CPLEX you may write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar float+ x;&#xA;dvar boolean b;&#xA;&#xA;subject to&#xA;{&#xA;  &#xA;  b==!(x==0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-05-17T18:25:56.273" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6273" PostTypeId="1" CreationDate="2021-05-17T07:49:29.047" Score="1" ViewCount="353" Body="&lt;p&gt;I'm trying to replicate some of the suggestions of &lt;a href=&quot;https://arxiv.org/abs/1705.00109&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;. On page 40-41, it's made the following suggestion when it comes to enforcing a minimum trade size:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fWwFk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fWwFk.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ufgAx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ufgAx.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this context, &lt;code&gt;z&lt;/code&gt; is the trade vector. When it's time for the second pass, how do you constrain on &lt;code&gt;z&lt;/code&gt; being larger than a certain value? A minimal example below (I'm using &lt;code&gt;u&lt;/code&gt; instead of &lt;code&gt;z&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import cvxpy as cp&#xA;import numpy as np&#xA;&#xA;x = np.random.normal(0., 1., size=(100, 1))&#xA;u = cp.Variable((100, 1))&#xA;S = np.random.rand(100, 100)&#xA;S = np.dot(S, S.T)&#xA;&#xA;prob = cp.Problem(cp.Maximize(x.T @ u - 0.1 * cp.quad_form(u, S)),&#xA;    [cp.sum(u) == 1.,&#xA;     cp.abs(u) &amp;lt;= 0.1])&#xA;&#xA;prob.solve()&#xA;&#xA;# try again with non-zero&#xA;u_bar = u.value.copy()&#xA;&#xA;min_trade = 0.05&#xA;prob = cp.Problem(cp.Maximize(x.T @ u - 0.1 * cp.quad_form(u, S)),&#xA;    [cp.sum(u) == 1.,&#xA;     cp.abs(u) &amp;lt;= 0.1,&#xA;     u[u_bar &amp;gt; 0] &amp;gt;= 0.,&#xA;     u[u_bar == 0] == 0.,&#xA;     u[u_bar &amp;lt; 0] &amp;lt;= 0,&#xA;     % how do you constrain u to be abs(u) &amp;gt;= min_trade?)&#xA;prob.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;[Edit] The reason why I'm asking is that let's say the smallest positive trade in the first pass is 0.01. If the minimum trade is 0.05, this value will most likely drop to 0 (and the average value of all the other positive entries slightly higher). So I can't use &lt;code&gt;u[u_bar &amp;gt; 0] &amp;gt;= min_trade&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5527" OwnerDisplayName="stevew" LastEditorUserId="36" LastEditDate="2021-05-18T17:17:42.270" LastActivityDate="2021-05-18T17:17:42.270" Title="Minimum trade size in CVXPY" Tags="|convex-optimization|cvxpy|finance|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6274" PostTypeId="1" AcceptedAnswerId="6276" CreationDate="2021-05-18T14:04:55.387" Score="2" ViewCount="253" Body="&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; There is an order to fabricate some products of total number, let's say 200 (all products are the same). We have some number of factories, let's say 5. Every factory has different number of production lines (every line performs differently (speed of production). One of main constraints is that all factories must finish together at the same time (there is an epsilon for some small deviation).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;### [Factory ID, Number Of Lines, Performance(Products per line per month)]&#xA;factories = {&#xA;['f1', 10, 2],&#xA;['f2',  3, 5],&#xA;['f3',  4, 10],&#xA;['f4',  8, 11],&#xA;['f5', 11, 17]}&#xA;&#xA;order_to_fabricate = 200 # (products)&#xA;&#xA;&#xA;for factory in factories:&#xA;    is_factory_enabled = model.NewBoolVar(f'{factory[0]}')&#xA;    lines_per_factory_enabled = model.NewIntVar(0, factory[1], f&amp;quot;line per factory: {factory[0]}&amp;quot;)&#xA;    products_per_factory = model.NewIntVar(0, order_to_fabricate, f&amp;quot;products per factory: {factory[0]}&amp;quot;)&#xA;    &#xA;    model.Add(products_per_factory &amp;gt;= lines_per_factory_enabled)&#xA;    &#xA;    total_fab_rate = model.NewIntVar(0, factory[1]*factory[2], f&amp;quot;Production rate per factory: {factory[0]}&amp;quot;) #upper bound than can be produced by factory&#xA;    model.AddMultiplicationEquality(total_fab_rate, [lines_per_factory_enabled, factory[2]])&#xA;&#xA;    fabrication_duration = model.NewIntVar(0, int(round(order_to_fabricate / factory[2])), f&amp;quot;Production duration&amp;quot;) #upper bound set like single line will serve total number of products&#xA;    model.AddDivisionEquality(fabrication_duration, products_per_factory, total_fab_rate) # total_fab_rate can be zero :(&#xA;    &#xA;    factory_enabled.append(is_factory_enabled)&#xA;    number_of_lines.append(lines_per_factory_enabled)&#xA;    number_of_products.append(products_per_factory)&#xA;    factory_er_for_all_lines.append(total_fab_rate)&#xA;    factory_er_duration.append(fabrication_duration)&#xA;    &#xA;# some constraints here...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The thing is that when the factory is not enabled number of lines is zero and fabricated number of products is also zero. &lt;code&gt;AddDivisionEquality&lt;/code&gt; gets &lt;code&gt;ZERO&lt;/code&gt; in the denominator and this constraint doesn't have the &lt;code&gt;OnlyEnforceIf&lt;/code&gt; option.&lt;/p&gt;&#xA;&lt;p&gt;I'm really stuck on how to avoid this issue. I want the model to select specific factories (also with some other constraints), but not all of them which is why I have &lt;code&gt;is_factory_enabled&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is there any approach to overcome such an issue?&lt;/p&gt;&#xA;" OwnerUserId="5399" LastEditorUserId="123" LastEditDate="2021-05-18T14:21:57.487" LastActivityDate="2021-05-18T15:34:10.607" Title="OR-Tools, How to avoid dividing by zero" Tags="|constraint-programming|or-tools|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6275" PostTypeId="1" CreationDate="2021-05-18T15:31:36.780" Score="2" ViewCount="568" Body="&lt;p&gt;Consider the problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;&amp;amp;\min f(x)\\&#xA;&amp;amp; \ \text{s.t.} \ \ \ Ax = b&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/papers/pdf/admm_distr_stats.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;expository paper&lt;/a&gt;, Boyd claims (top of page &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt;) that if:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\lambda^*$&lt;/span&gt; is a dual optimal solution&lt;/li&gt;&#xA;&lt;li&gt;There is no duality gap&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$L(x, \lambda^*)$&lt;/span&gt; has a unique minimizer &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; (which can happen, for example, if &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is strongly convex)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;then &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is primal optimial.&lt;/p&gt;&#xA;&lt;p&gt;I've played around with the Lagrangian for some time, but I have not been able to show that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is primal feasible, nor that &lt;span class=&quot;math-container&quot;&gt;$f(x^*)$&lt;/span&gt; is the primal optimal value.&lt;/p&gt;&#xA;&lt;p&gt;I am also wondering: if &lt;span class=&quot;math-container&quot;&gt;$L(x, \lambda^*)$&lt;/span&gt; does not have a unique minimizer, must a primal optimal solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; be among them?&lt;/p&gt;&#xA;&lt;p&gt;Thank you in advance for any help.&lt;/p&gt;&#xA;" OwnerUserId="4563" LastEditorUserId="4563" LastEditDate="2021-05-18T17:10:45.787" LastActivityDate="2021-05-21T16:27:10.900" Title="Recovering Primal Solution from Dual solution" Tags="|optimization|convex-optimization|duality|lagrange-multipliers|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="6276" PostTypeId="2" ParentId="6274" CreationDate="2021-05-18T15:34:10.607" Score="5" Body="&lt;p&gt;I assume fab_rate is variable, otherwise you can just test it.&lt;/p&gt;&#xA;&lt;p&gt;You can use temporary variables:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;non_zero_fab_rate = model.NewIntVar(1, ..)&#xA;fab_rate_is_zero = model.NewBoolVar(..)&#xA;model.Add(non_zero_fab_rate == 1).OnlyEnforceIf(fab_rate_is_zero)&#xA;model.Add(non_zero_fab_rate == fab_rate).OnlyEnforceIf(fab_rate_is_zero.Not())&#xA;model.Add(fab_rate == 0).OnlyEnforceIf(fab_rate_is_zero)&#xA;model.Add(fab_rate &amp;gt; 0).OnlyEnforceIf(fab_rate_is_zero.Not())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then use the division with the &lt;code&gt;non_zero_fab_rate&lt;/code&gt; variable, and only use the target variable if &lt;code&gt;fab_rate_is_zero&lt;/code&gt; is false.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2021-05-18T15:34:10.607" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6277" PostTypeId="1" AcceptedAnswerId="6281" CreationDate="2021-05-18T16:36:24.073" Score="2" ViewCount="111" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$G = (V,E)$&lt;/span&gt; be an undirected graph, with &lt;span class=&quot;math-container&quot;&gt;$e \in E$&lt;/span&gt; has positive weight &lt;span class=&quot;math-container&quot;&gt;$w_e$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Given a set of integers &lt;span class=&quot;math-container&quot;&gt;$I = \{i_1,\dots,i_n\}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\sum_{k=1}^n i_k = |V|$&lt;/span&gt;. I want to find a partition &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; of cardinality &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; such that each element of the partition has cardinality corresponding exactly to one of the elements of &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The maximization function sums all the edges weights &lt;span class=&quot;math-container&quot;&gt;$w_{(v_1,v_2)}$&lt;/span&gt; if both &lt;span class=&quot;math-container&quot;&gt;$v_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v_2$&lt;/span&gt; belong the same subset within the solution - i.e. &lt;span class=&quot;math-container&quot;&gt;$v_1, v_2 \in P_j$&lt;/span&gt;, for any &lt;span class=&quot;math-container&quot;&gt;$P_j \in P$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Similarly, the objective function might be minimizing all the weights &lt;span class=&quot;math-container&quot;&gt;$w_{(v_1,v_2)}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$v_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v_2$&lt;/span&gt; belong different element of the partition.&lt;/p&gt;&#xA;&lt;p&gt;My question is whether such a problem has already an official formulation in literature. Or if there is an interesting equivalent problem.&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="67" LastEditDate="2021-05-18T20:10:10.580" LastActivityDate="2021-05-18T21:22:20.667" Title="Graph partitioning/cutting problem" Tags="|mixed-integer-programming|graphs|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6279" PostTypeId="1" AcceptedAnswerId="6283" CreationDate="2021-05-18T17:37:10.920" Score="3" ViewCount="139" Body="&lt;p&gt;I am reading this &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/papers/pdf/admm_distr_stats.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;expository paper on ADMM by&lt;/a&gt; Boyd, et. al.&lt;/p&gt;&#xA;&lt;p&gt;Consider the problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;&amp;amp;\min f(x)\\&#xA;&amp;amp; \ \text{s.t.} \ \ \ Ax = b&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with Lagrangian &lt;span class=&quot;math-container&quot;&gt;$L(x, \lambda) = f(x) + \lambda^T (Ax - b)$&lt;/span&gt;. The Dual Ascent algorithm is&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Choose &lt;span class=&quot;math-container&quot;&gt;$\lambda_0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$k = 0, 1, 2, ...$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\ \ \ \ \ \ \ x^k = \arg \min_x L(x, \lambda^k)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \ \ \ \ \ \ \ \lambda^{k+1} = \lambda^k + \alpha_k (Ax^k - b)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;With some assumptions and correct choice of the step size &lt;span class=&quot;math-container&quot;&gt;$\alpha_k$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x^k$&lt;/span&gt; converges to primal optimal solution and &lt;span class=&quot;math-container&quot;&gt;$\lambda^k$&lt;/span&gt; converges to dual optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;In the Method of Multipliers, all we do is apply the Dual Ascent algorithm to the equivalent problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;&amp;amp;\min f(x) + \frac p2 ||Ax - b||^2\\&#xA;&amp;amp; \ \text{s.t.} \ \ \ Ax = b&#xA;\end{align*}&lt;/span&gt;&#xA;and choose the stepsize as the constant &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;. Thus, the Method of Multipliers is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Choose &lt;span class=&quot;math-container&quot;&gt;$\lambda_0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$k = 0, 1, 2, ...$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\ \ \ \ \ \ \ x^k = \arg \min_x L_p(x, \lambda^k)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \ \ \ \ \ \ \ \lambda^{k+1} = \lambda^k + p (Ax^k - b)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$L_p(x, \lambda) = f(x) + \lambda^T(Ax - b) +  \frac p2 ||Ax - b||^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, in the case where &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is differentiable, the authors give the following as a justification of why the step size should be &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; (pages 11-12): since &lt;span class=&quot;math-container&quot;&gt;$x^k$&lt;/span&gt; minimizes &lt;span class=&quot;math-container&quot;&gt;$L_p(x, \lambda^k)$&lt;/span&gt;, we must have&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;0 &amp;amp;= \nabla_x L_p(x^k, \lambda^k)\\&#xA;&amp;amp;= \nabla f(x^k) + A^T \lambda ^k + pA^T(Ax^k - b)\\&#xA;&amp;amp;= \nabla f(x^k) + A^T(\lambda ^k + p(Ax - b))\\&#xA;&amp;amp;= \nabla f(x^k) + A^T \lambda^{k+1} \tag{1}\label{Eq:1}&#xA;\end{align*}&lt;/span&gt;&lt;br /&gt;&#xA;The authors claim if we chose &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; for the stepsize, the above calculation implies &lt;span class=&quot;math-container&quot;&gt;$\lambda^{k+1}$&lt;/span&gt; is dual feasible. However, I don't see why. Using what was just proved, we have&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;d(\lambda^{k+1}) &amp;amp;= \inf_x [f(x) + \lambda^{k+1} \cdot(Ax-b) + \frac p2 ||Ax - b||^2]\\&#xA;&amp;amp;= \inf_x [f(x) - \nabla f(x^k)^Tx + \frac p2 ||Ax - b||^2] - \lambda^{k+1} \cdot b \tag{2} \label{Eq:2}&#xA;\end{align*}&lt;/span&gt;&#xA;But it's not clear at all to me why this &lt;span class=&quot;math-container&quot;&gt;$\inf$&lt;/span&gt; cannot be &lt;span class=&quot;math-container&quot;&gt;$-\infty$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4563" LastEditorUserId="972" LastEditDate="2021-05-19T16:04:06.213" LastActivityDate="2021-05-19T16:19:56.227" Title="Method of Multipliers: Why is the next iterate always dual feasible?" Tags="|optimization|duality|lagrange-multipliers|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6281" PostTypeId="2" ParentId="6277" CreationDate="2021-05-18T20:16:54.357" Score="2" Body="&lt;p&gt;When the objective function relies on the weights of edges within the subgraphs (as opposed to edges connecting subgraphs), I believe your problem is equivalent to a quadratic multiple knapsack problem. There seems to be a fair bit of literature on that problem (of all of which I am blissfully ignorant).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-05-18T20:16:54.357" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6282" PostTypeId="2" ParentId="6277" CreationDate="2021-05-18T21:16:21.510" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-007-0139-z&quot; rel=&quot;nofollow noreferrer&quot;&gt;capacitated max-k-cut&lt;/a&gt; formulation models the problem I describe.&lt;/p&gt;&#xA;&lt;p&gt;Besides, it is less constraining, since the equality &lt;span class=&quot;math-container&quot;&gt;$\sum_{k=1}^n i_k = |V|$&lt;/span&gt; becomes &lt;span class=&quot;math-container&quot;&gt;$\sum_{k=1}^n i_k \geq |V|$&lt;/span&gt;, where elements &lt;span class=&quot;math-container&quot;&gt;$i_k$&lt;/span&gt; are referred as capacity.&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="5523" LastEditDate="2021-05-18T21:22:20.667" LastActivityDate="2021-05-18T21:22:20.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6283" PostTypeId="2" ParentId="6279" CreationDate="2021-05-19T16:19:56.227" Score="3" Body="&lt;p&gt;By dual feasibility, all that the authors mean is that &lt;span class=&quot;math-container&quot;&gt;$(x^{k+1}, \lambda^{k+1})$&lt;/span&gt; in Equation (1) satisfies the stationarity equation in the KKT optimality conditions for the problem shown at the top of your question. Recall that the stationarity equation for the problem is to find &lt;span class=&quot;math-container&quot;&gt;$x, \lambda$&lt;/span&gt; such that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \nabla f(x) + A^{\top} \lambda = 0 $$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="972" LastActivityDate="2021-05-19T16:19:56.227" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6284" PostTypeId="2" ParentId="6270" CreationDate="2021-05-20T08:51:23.920" Score="4" Body="&lt;p&gt;I'm only aware of a mechanism that works if there is an upper bound for the continuous variable.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}x_{t, \max}\cdot b_t &amp;amp;\geq x_t\\ m\cdot x_t &amp;amp;\geq b_t\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I used this in answering &lt;a href=&quot;https://or.stackexchange.com/questions/6200/assignment-and-scheduling-problem-with-resource-constraints/6236?noredirect=1#comment11082_6236&quot;&gt;this question&lt;/a&gt;. I'm not aware of a way to solve it for unbounded &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt;, unless the solver handles floating points infinities correctly. This would need to be tested by solvers.&#xA;The second equation implements the &lt;span class=&quot;math-container&quot;&gt;$x_t &amp;lt; \frac{1}{m}\implies b_t=0 $&lt;/span&gt;. If the trueness of &lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt; is penalized in the objective the second term is unnecessary.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="123" LastEditDate="2021-05-20T10:27:36.430" LastActivityDate="2021-05-20T10:27:36.430" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6285" PostTypeId="2" ParentId="6270" CreationDate="2021-05-20T09:33:19.313" Score="4" Body="&lt;p&gt;Enforcing &lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt; to take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; is positive is done with &lt;span class=&quot;math-container&quot;&gt;$x_t \le b_t$&lt;/span&gt;, assuming &lt;span class=&quot;math-container&quot;&gt;$x_t \le 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For the second part, quoting @MarkL.Stone:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;You will have to choose a tolerance as to how close to zero should be&#xA;considered zero&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; be this tolerance. So you want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_t &amp;lt; \epsilon\implies b_t = 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now referring to &lt;a href=&quot;https://or.stackexchange.com/questions/33/in-an-integer-program-how-i-can-force-a-binary-variable-to-equal-1-if-some-cond?rq=1&quot;&gt;this link&lt;/a&gt; (careful as &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; in the link is a constant &lt;span class=&quot;math-container&quot;&gt;$\neq$&lt;/span&gt; your &lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt;):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;To enforce &amp;quot;if &lt;span class=&quot;math-container&quot;&gt;$x &amp;lt; b$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;&amp;quot;&lt;/em&gt;:  &lt;span class=&quot;math-container&quot;&gt;$$b - x \le My,$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a large constant. The logic is that if &lt;span class=&quot;math-container&quot;&gt;$b - x &amp;gt; 0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; must&#xA;equal 1, and otherwise it may equal 0.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Given that &lt;span class=&quot;math-container&quot;&gt;$x_t \le 1$&lt;/span&gt;, and that you want the binary variable to take value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; (and not &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;), the constraint becomes:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\epsilon-x_t \le 1-b_t&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is easy to see that if &lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt; takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, then it implies &lt;span class=&quot;math-container&quot;&gt;$x_t \ge \epsilon$&lt;/span&gt;, which is the contrapositive of what you want.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2021-05-20T10:28:14.063" LastActivityDate="2021-05-20T10:28:14.063" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6286" PostTypeId="2" ParentId="6261" CreationDate="2021-05-20T19:21:53.463" Score="3" Body="&lt;p&gt;First question: Theoretically, yes (assuming you are talking about the reduction factor per &lt;em&gt;pair&lt;/em&gt; of observations). Practically speaking, there is a minimum gap you can have between &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;, below which rounding error makes the comparison of &lt;span class=&quot;math-container&quot;&gt;$f(c)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f(d)$&lt;/span&gt; too dicey to trust. So the reduction factor per pair of iterations approaches something slightly less than 1/2 (but close enough to 1/2 for government work, as the saying goes). This is similar to bisection search using gradients (where you evaluate &lt;span class=&quot;math-container&quot;&gt;$f'(x)$&lt;/span&gt; at the midpoint, rather than &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; at and near the midpoint).&lt;/p&gt;&#xA;&lt;p&gt;Second question: The picture does not specifically convey the use of the Fibonacci sequence. It just shows how points are added and interval of uncertainty shrinks. I you drew a free-hand diagram for golden section search, I suspect it would be indistinguishable from the given diagram.&lt;/p&gt;&#xA;&lt;p&gt;As an aside, my understanding is that with &lt;span class=&quot;math-container&quot;&gt;$N=5$&lt;/span&gt; measurement points, the first fraction should be &lt;span class=&quot;math-container&quot;&gt;$F_4/F_5 = 5/8$&lt;/span&gt; rather than &lt;span class=&quot;math-container&quot;&gt;$F_5/F_6$&lt;/span&gt;, and so on.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-05-20T19:21:53.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6287" PostTypeId="1" CreationDate="2021-05-20T21:19:57.053" Score="0" ViewCount="215" Body="&lt;p&gt;When running the cplex model, I noticed that the CPLEX repeats the same gap value several times. I ask if there is a parameter in docplex that limits the number of iterations without improvements or just stop it after obtaining n times the same value on the gap.&lt;/p&gt;&#xA;" OwnerUserId="5537" LastActivityDate="2021-05-23T21:55:12.573" Title="For docplex, it's possible to set the number of iterations without improvement?" Tags="|mixed-integer-programming|docplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6288" PostTypeId="1" CreationDate="2021-05-20T23:48:08.033" Score="2" ViewCount="131" Body="&lt;p&gt;A portfolio of solvers is a collection of solvers with different configurations that share CPU time, CPU cores, and memory resources and try to get an answer as soon as possible. Solvers might also communicate with each other. &lt;a href=&quot;https://baldur.iti.kit.edu/hordesat/files/horde.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;&#xA;The task of solver portfolio design involves computing metrics about the problem (which also takes compute time) and choosing which solvers to run for how long with how many cores based on any information you can collect about the problem (including information from solvers which already ran).&lt;/p&gt;&#xA;&lt;p&gt;Portfolios are often more successful in SAT competitions than any single solvers &lt;a href=&quot;https://arxiv.org/pdf/1111.2249.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;. I am interested in literature on designing portfolios for optimization algorithms. I have been unable to find any as many searches are overshadowed by &amp;quot;portfolio optimization problems&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;In particular, I am looking for:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Introductory Literature on Portfolios for Satisfiability and Optimization&lt;/li&gt;&#xA;&lt;li&gt;Automation of portfolio creation based on (automated) experiments for Optimization&lt;/li&gt;&#xA;&lt;li&gt;Improving any-time performance with solver portfolios&lt;/li&gt;&#xA;&lt;li&gt;The trade-off between good anytime performance and good performance stopping at a certain time point&lt;/li&gt;&#xA;&lt;li&gt;Automatic solver configuration exploration as the configuration space can be huge&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://baldur.iti.kit.edu/hordesat/files/horde.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt; See &lt;a href=&quot;https://baldur.iti.kit.edu/hordesat/files/horde.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;HordeSat&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/pdf/1111.2249.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt; See Table 5 of &lt;a href=&quot;https://arxiv.org/pdf/1111.2249.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;SatZilla&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="36" LastEditDate="2021-06-18T14:39:18.180" LastActivityDate="2021-06-18T14:39:18.180" Title="Literature for building solver portfolios" Tags="|optimization|solver|reference-request|parallel-computing|computational-experiments|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6289" PostTypeId="2" ParentId="6287" CreationDate="2021-05-21T00:26:06.633" Score="1" Body="&lt;p&gt;Please read the relevant manuals. I am not aware of any such functionality and a search of named parameters in the documentation yields no results either.&lt;/p&gt;&#xA;&lt;p&gt;However this &lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.7.1.0?topic=cpxxgetcallbackinfo-cpxgetcallbackinfo&quot; rel=&quot;nofollow noreferrer&quot;&gt;page&lt;/a&gt; goes into details how to get the information you want and also documents in an example how to stop it from this callback based on this information using the C Interface.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-05-23T21:55:12.573" LastActivityDate="2021-05-23T21:55:12.573" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6290" PostTypeId="1" CreationDate="2021-05-21T12:26:48.230" Score="5" ViewCount="273" Body="&lt;h3&gt;Problem description&lt;/h3&gt;&#xA;&lt;p&gt;I am working on a variation of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Multi-commodity_flow_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;multicommodity flow problem&lt;/a&gt; on a graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt;. I have requests &lt;span class=&quot;math-container&quot;&gt;$r_{uv}$&lt;/span&gt; for pairs of nodes &lt;span class=&quot;math-container&quot;&gt;$(u,v), u\in V, v\in V$&lt;/span&gt;, which means that &lt;span class=&quot;math-container&quot;&gt;$r_{uv}$&lt;/span&gt; units of flow must be shipped from node &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The variation of the problem is twofold:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There are capacity constraints on the edges of the graph: when the total flow on an edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in E$&lt;/span&gt; exceeds a given threshold &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;, an integer variable &lt;span class=&quot;math-container&quot;&gt;$N_{ij}$&lt;/span&gt; is incremented, so that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;N_{ij} = \Bigg\lceil\frac{{\rm flow}_{ij}}{Q} \Bigg\rceil&#xA;$$&lt;/span&gt;&#xA;A weighted sum of the &lt;span class=&quot;math-container&quot;&gt;$N_{ij}$&lt;/span&gt; is minimized in the objective function. You can interpret &lt;span class=&quot;math-container&quot;&gt;$N_{ij}$&lt;/span&gt; as vehicles with capacity &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;, transporting units of flow.&lt;/li&gt;&#xA;&lt;li&gt;Transshipment cannot be performed in some vertices of the graph. This means that in these specific vertices, a unit of flow cannot be transferred from a given vehicle to another. As an example, consider the graph below, with two requests: &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; unit from &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; unit from &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;. Also, let &lt;span class=&quot;math-container&quot;&gt;$Q=2$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;                                              &#xA;&lt;a href=&quot;https://i.stack.imgur.com/v9sMsm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/v9sMsm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If transshipment is allowed in node &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, then the following flow is feasible, yealding &lt;span class=&quot;math-container&quot;&gt;$N_{ab}=1$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$N_{ij}$&lt;/span&gt; is represented by the purple squares, flows are represents by the filled triangles):&lt;/p&gt;&#xA;&lt;p&gt;                                              &#xA;&lt;a href=&quot;https://i.stack.imgur.com/l8eUwm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/l8eUwm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since transshipment is allowed, all the units of flow can be packed in one vehicle on edge &lt;span class=&quot;math-container&quot;&gt;$(a,b)$&lt;/span&gt;; and then one of the two demands, &lt;span class=&quot;math-container&quot;&gt;$r_{ac}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$r_{ad}$&lt;/span&gt; can be transferred to another vehicle when arriving in node &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, if transshipment is not allowed, this is not a valid configuration, and both requests must be in individual vehicles on edge &lt;span class=&quot;math-container&quot;&gt;$(a,b)$&lt;/span&gt;, as follows:&lt;/p&gt;&#xA;&lt;p&gt;                                              &#xA;&lt;a href=&quot;https://i.stack.imgur.com/tUSr2m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tUSr2m.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Problem formulation&lt;/h3&gt;&#xA;&lt;p&gt;Assuming transshipment can take place at all vertices, I am currently using a columnwise formulation with a predefined set of paths &lt;span class=&quot;math-container&quot;&gt;$P_{uv}$&lt;/span&gt; for each request &lt;span class=&quot;math-container&quot;&gt;$r_{uv} \in R$&lt;/span&gt;. So I use binary variables &lt;span class=&quot;math-container&quot;&gt;$y_p$&lt;/span&gt; that take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if path &lt;span class=&quot;math-container&quot;&gt;$p \in \bigcup_{(u,v)\in R} P_{uv}$&lt;/span&gt; is used, and variables &lt;span class=&quot;math-container&quot;&gt;$N_{ij}$&lt;/span&gt; for the vehicles with capacity &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;. As mentioned above, a weighted sum the &lt;span class=&quot;math-container&quot;&gt;$N_{ij}$&lt;/span&gt; variables is minimized, subject to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\sum_{p\in P_{uv}}y_p &amp;amp;= 1 \;\;\;\;\;\; &amp;amp;\forall (u,v) \in R  \\&#xA;\sum_{(u,v)\in R}\sum_{p\in P_{uv}|(i,j)\in p}r_{uv}y_p &amp;amp;\le Q N_{ij} \;\;\;\;\;\; &amp;amp;\forall (i,j)\in E&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first constraint enforces the selection of one path per request, while the second one handles capacity constraints. The way transshipment constraints are handled is explained hereafter.&lt;/p&gt;&#xA;&lt;h3&gt;A possible way of dealing with transshipment constraints&lt;/h3&gt;&#xA;&lt;p&gt;The way I currently cope with transshipment constraints is by duplicating vertices when I need to. For example, for the above example, I use the following graph:&lt;/p&gt;&#xA;&lt;p&gt;                                              &#xA;&lt;a href=&quot;https://i.stack.imgur.com/PVkvfm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PVkvfm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This way, it is guaranteed that both requests are not in the same vehicle on edge &lt;span class=&quot;math-container&quot;&gt;$(a,b)$&lt;/span&gt;, and so the transshipment constraint is satisfied structurally.&lt;/p&gt;&#xA;&lt;h3&gt;My question&lt;/h3&gt;&#xA;&lt;p&gt;Is there another way to handle the transshipment constraints? I would be interested in a formulation which can handle them, so that I do not have to transform the graph. Transforming the graph does work, but sometimes it becomes very big. Also, there are many pitfalls with this approach that I can detail if necessary.&lt;/p&gt;&#xA;&lt;p&gt;One of its weaknesses is that if there is for example a request &lt;span class=&quot;math-container&quot;&gt;$r_{ab}$&lt;/span&gt; with path &lt;span class=&quot;math-container&quot;&gt;$a-b$&lt;/span&gt;, then this path must also be duplicated. This makes the whole process quite heavy.&lt;/p&gt;&#xA;&lt;p&gt;I am interested in any other approach, which could simplify things.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;More examples to illustrate the problem, and help validate answers&lt;/h3&gt;&#xA;&lt;p&gt;First example: we have two requests &lt;span class=&quot;math-container&quot;&gt;$r_{ad}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r_{cd}$&lt;/span&gt;. The nodes in green are transshipment nodes, and the node in red is not.  Since &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a transshipment node, all requests can be packed together on edge &lt;span class=&quot;math-container&quot;&gt;$(b,d)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NrYtXm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NrYtXm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Another one: we have two requests &lt;span class=&quot;math-container&quot;&gt;$r_{ad}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r_{ae}$&lt;/span&gt;. Although &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is a transshipment node, the requests cannot be merged on &lt;span class=&quot;math-container&quot;&gt;$(a,b)$&lt;/span&gt;, as it would imply splitting them downstream, where it is not possible.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/122ETm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/122ETm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And to make things harder, if we had a third request &lt;span class=&quot;math-container&quot;&gt;$r_{ab}$&lt;/span&gt;, it &lt;em&gt;could&lt;/em&gt; be merged with either of the other two.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tkZvxm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tkZvxm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Another example with requests &lt;span class=&quot;math-container&quot;&gt;$r_{gd}, r_{ge},r_{ab}$&lt;/span&gt;. Although &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is not a transshipment node, merging the requests is possible. Requests &lt;span class=&quot;math-container&quot;&gt;$r_{gd}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r_{ge}$&lt;/span&gt; must be split in node &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, which is a transshipment node.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/195OI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/195OI.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The above examples illustrate that it is not trivial to determine if requests can be merged on a given edge. In particular, this does not only depend on the nature of the endpoints of the edge. And the condition may vary from one pair of requests to another. So the formulation should probably take into account some binary parameter &lt;span class=&quot;math-container&quot;&gt;$\delta_{p(r_1),p(r_2)}^{i,j}$&lt;/span&gt; which takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if requests &lt;span class=&quot;math-container&quot;&gt;$r_1,r_2$&lt;/span&gt; can be merged on edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; if paths &lt;span class=&quot;math-container&quot;&gt;$p(r_1),p(r_2)$&lt;/span&gt; are used (&lt;span class=&quot;math-container&quot;&gt;$p(r_i)$&lt;/span&gt; denotes the considered path for request &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;I believe this parameter could be computed as follows: for each pair of paths &lt;span class=&quot;math-container&quot;&gt;$p(r_1),p(r_2)$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; be the intersection of &lt;span class=&quot;math-container&quot;&gt;$p(r_1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p(r_2)$&lt;/span&gt;. The parameter &lt;span class=&quot;math-container&quot;&gt;$\delta_{p(r_1),p(r_2)}^{i,j}$&lt;/span&gt; is only defined over the edges of &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt;, and takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if one of the following conditions holds:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$q = p(r_1) \subseteq p(r_2)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$q = p(r_2) \subseteq p(r_1)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p(r_1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p(r_2)$&lt;/span&gt; have the same destination node, and there is a transshipment node somewhere before &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p(r_1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p(r_2)$&lt;/span&gt; have the same origin, and there is a transshipment node somewhere downstream after &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This list may not be complete.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-05-25T10:53:33.620" LastActivityDate="2021-05-25T10:53:33.620" Title="How to model this multi-commodity flow problem with a twist?" Tags="|mixed-integer-programming|modeling|network-flow|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6291" PostTypeId="2" ParentId="6290" CreationDate="2021-05-21T12:51:48.527" Score="2" Body="&lt;p&gt;One approach is to introduce disaggregated variables &lt;span class=&quot;math-container&quot;&gt;$N_{ij}^{uv}$&lt;/span&gt; where needed, in addition to the original &lt;span class=&quot;math-container&quot;&gt;$N_{ij}$&lt;/span&gt; variables. For edges &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; where merging requests is allowed, use your original capacity constraint. For edges &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; where merging requests is not allowed, replace your original capacity constraint with &lt;span class=&quot;math-container&quot;&gt;$$\sum_{p\in P_{uv}\mid (i,j)\in p} r_{uv} y_p \le Q N_{ij}^{uv}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-05-21T13:47:28.497" LastActivityDate="2021-05-21T13:47:28.497" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6292" PostTypeId="1" CreationDate="2021-05-21T14:23:41.877" Score="5" ViewCount="54" Body="&lt;p&gt;I am pondering if a machine learning problem might be better formulated as a reinforcement or control problem. I have no experience with the latter, so bear with me.&lt;/p&gt;&#xA;&lt;p&gt;Let's say I am organising a tour and each time the tour has a different number of participants. My responsibility is to make sure that there is enough water for everybody during the tour. I know historically how much water is used per person per tour. So that is a good rule of the thumb.&lt;/p&gt;&#xA;&lt;p&gt;But it is also known that the morning tours needs more water than the evening tours. And that there are seasonal differences.&lt;/p&gt;&#xA;&lt;p&gt;What I would like to build is a mechanism that takes the average water usage per person per tour as a starting point. And then per morning and evening tour starts adjusting the average amount of water to be taken on the tour. The goal is to have enough water on 95% of the tours.&lt;/p&gt;&#xA;&lt;p&gt;What kind of algorithm is this? I would be interested in the name of the class of the problem (stochastic discrete time continuous state control?) or the name of an applicable algorithm.&lt;/p&gt;&#xA;" OwnerUserId="4502" LastEditorUserId="4502" LastEditDate="2021-05-21T14:35:33.470" LastActivityDate="2021-05-21T14:35:33.470" Title="What kind of algorithm is this: water foraging" Tags="|stochastic-process|optimal-control|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6293" PostTypeId="1" CreationDate="2021-05-21T14:43:33.623" Score="2" ViewCount="109" Body="&lt;p&gt;I am trying to use CPXaddusercuts to add cutting planes, which have not been violated yet but are likely to be violated as we go down the branch &amp;amp; bound tree, to the list (pool) of constraints. As per IBM documentation, CPLEX can add those cuts to the LP subproblem during MIP optimization which are violated by the LP relaxation solution. The problem is that even after successfully adding the cuts using CPXaddusercuts and knowing for sure that these cuts are going to be violated, I see no change in the CPLEX log file for branch and bound. Now, I am not sure about the following:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;How to know whether CPLEX at all uses some of these user cuts from the provided pool?&#xA;Am I missing something here? What is the correct approach to make use of my pool of user cuts?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3640" LastActivityDate="2021-05-21T14:43:33.623" Title="How to implement CPLEX user cuts using CPXaddusercuts in C API?" Tags="|cplex|solver|branch-and-bound|cutting-planes|api|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6295" PostTypeId="2" ParentId="6275" CreationDate="2021-05-21T16:08:18.420" Score="2" Body="&lt;p&gt;A proof that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is optimal can be achieved by a Taylor expansion around &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; at optimality. Observe that &lt;span class=&quot;math-container&quot;&gt;$$f(x^*+p) = f(x^*) + p^\top f'(x^*) + \frac12p^\top f''(x^*)p$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that at a local optimum &lt;span class=&quot;math-container&quot;&gt;$\nabla f=0$&lt;/span&gt; and given that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is strictly convex it is a PD matrix with positive eigenvalues. Thus the third argument involving the Hessian &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;0$&lt;/span&gt; thereby implies that &lt;span class=&quot;math-container&quot;&gt;$f(x^*+p) &amp;gt; f(x^*)$&lt;/span&gt; and thus proves that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is a global minimum on &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As to your question on how to prove &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is feasible I think you can prove that by contradiction assuming &lt;span class=&quot;math-container&quot;&gt;$A(x^*) \ne b$&lt;/span&gt; and then the KKT conditions under that assumption will not be satisfied.&lt;/p&gt;&#xA;" OwnerUserId="4581" LastEditorUserId="123" LastEditDate="2021-05-21T16:27:10.900" LastActivityDate="2021-05-21T16:27:10.900" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6296" PostTypeId="2" ParentId="6288" CreationDate="2021-05-21T20:13:11.770" Score="3" Body="&lt;p&gt;For the automatic solver configuration, I know of this reference (there may be a journal version): &lt;a href=&quot;http://pages.di.unipi.it/frangio/papers/LOD20.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;A learning-based mathematical programming formulation for the automatic configuration of optimization solvers&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;They also cite further references on the topic.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2021-05-21T20:13:11.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6297" PostTypeId="1" AcceptedAnswerId="6300" CreationDate="2021-05-21T22:02:29.273" Score="-4" ViewCount="324" Body="&lt;p&gt;How to formulate the following as constraints in MILP?&lt;/p&gt;&#xA;&lt;p&gt;a[0][0] = y, if x[0]= 0,&lt;/p&gt;&#xA;&lt;p&gt;a[0][0] = 0, if x[0] != 0,&#xA;.&#xA;.&lt;/p&gt;&#xA;&lt;p&gt;.&#xA;.&lt;/p&gt;&#xA;&lt;p&gt;a[i][j] = b[i][j-1] + y, if x[j]=i,&lt;/p&gt;&#xA;&lt;p&gt;a[i][j] = a[i][j-1],  if x[j] != i,&#xA;...&#xA;.&#xA;.&#xA;.&lt;/p&gt;&#xA;&lt;p&gt;b[0][0] = z[0], if x[0] =0,&lt;/p&gt;&#xA;&lt;p&gt;b[0][0] = 0, if x[0] != 0,&#xA;.&#xA;.&#xA;.&#xA;.&#xA;.&lt;/p&gt;&#xA;&lt;p&gt;b[i][j] = b[i][j-1] + z[i], if x[j] = i,&lt;/p&gt;&#xA;&lt;p&gt;b[i][j] = b[i][j-1], if x[j] != i,&#xA;.....&lt;/p&gt;&#xA;&lt;p&gt;Suggest answers based on optimization or coding , both will help.&#xA;How to use Piece-wise constraint or logical based constraint for this MILP?&lt;/p&gt;&#xA;" OwnerUserId="530" LastEditorUserId="530" LastEditDate="2021-05-21T22:23:30.767" LastActivityDate="2021-05-22T22:02:00.487" Title="Multiple If else constraints in Mixed integer programming" Tags="|optimization|mixed-integer-programming|linear-programming|python|constraint-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6298" PostTypeId="1" AcceptedAnswerId="6310" CreationDate="2021-05-22T07:40:13.797" Score="0" ViewCount="77" Body="&lt;p&gt;I am trying to implement a simple line-search algorithm in Julia. I am new to Julia programming, so I am learning it on the go. I'd like to ask for some help, if possible, to correct an error while running the code.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Source code&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using LinearAlgebra&#xA;&#xA;function bracket_minimum(f, x = 0, s = 1e-2, k = 2.0)&#xA;    a, fa = x, f(x)&#xA;    b, fb = x + s, f(x + s)&#xA;&#xA;    if(fb &amp;gt; fa)&#xA;        a, b = b, a&#xA;        fa, fb = fb, fa&#xA;        s = -s&#xA;    end&#xA;&#xA;    while(true)&#xA;        c, fc = b + s, f(b + s)&#xA;        if(fb &amp;lt; fc)&#xA;            return a &amp;lt; c ? (a, c) : (c, a)&#xA;        else&#xA;            a, fa, b, fb = b, fb, c, fc&#xA;            s *= k&#xA;        end&#xA;    end&#xA;end&#xA;&#xA;function bisection(f, a₀, b₀, ϵ)&#xA;&#xA;    function D(f,a)&#xA;        # Approximate the first derivative using central differences&#xA;        h = 0.001&#xA;        return (f(a + h) - f(a - h))/(2 * h)&#xA;    end&#xA;&#xA;    a = a₀&#xA;    b = b₀&#xA;&#xA;    while((b - a) &amp;gt; ϵ)&#xA;        c = (a + b)/2.0&#xA;&#xA;        if D(f,c) &amp;gt; 0&#xA;            b = c&#xA;        else&#xA;            a = c&#xA;        end&#xA;    end&#xA;&#xA;    return (a,b)&#xA;end&#xA;&#xA;function line_search(f::Function, x::Vector{Float64}, d::Vector{Float64})&#xA;    println(&amp;quot;Hello&amp;quot;)&#xA;    objective = α -&amp;gt; f(x + α*d)&#xA;    a, b = bracket_minimum(objective)&#xA;    α = bisection(objective, a, b, 1e-5)&#xA;    return α, x + α*d&#xA;end&#xA;&#xA;f(x) = sin(x[1] * x[2]) + exp(x[2] + x[3]) - x[3]&#xA;&#xA;x = [1,2,3]&#xA;d = [0, -1, -1]&#xA;α, x_min = line_search(f, x, d)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am getting a Linear algebraic error, so I think I must not be passing vectors correctly or perhaps I am not doing scalar-vector multiplication correctly. But, I was having a hard-time figuring out. If I step through the code, it fails on the function call &lt;code&gt;line_search(f,x,d)&lt;/code&gt; and does even enter inside the function body.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Error description&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ERROR: MethodError: no method matching *(::Tuple{Float64,Float64}, ::Array{Int64,1})&#xA;Closest candidates are:&#xA;  *(::Any, ::Any, ::Any, ::Any...) at operators.jl:538&#xA;  *(::Adjoint{var&amp;quot;#s828&amp;quot;,var&amp;quot;#s8281&amp;quot;} where var&amp;quot;#s8281&amp;quot;&amp;lt;:(AbstractArray{T,1} where T) where var&amp;quot;#s828&amp;quot;&amp;lt;:Number, ::AbstractArray{var&amp;quot;#s827&amp;quot;,1} where var&amp;quot;#s827&amp;quot;&amp;lt;:Number) at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\LinearAlgebra\src\adjtrans.jl:283&#xA;  *(::Transpose{T,var&amp;quot;#s828&amp;quot;} where var&amp;quot;#s828&amp;quot;&amp;lt;:(AbstractArray{T,1} where T), ::AbstractArray{T,1}) where T&amp;lt;:Real at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\LinearAlgebra\src\adjtrans.jl:284&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5460" LastEditorUserId="3598" LastEditDate="2021-05-25T12:27:05.333" LastActivityDate="2021-05-25T12:27:05.333" Title="Trouble implementing a line-search algorithm" Tags="|optimization|algorithms|implementation|unconstrained-optimization|julia|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6299" PostTypeId="1" AcceptedAnswerId="6309" CreationDate="2021-05-22T08:49:21.623" Score="2" ViewCount="594" Body="&lt;p&gt;I'm using Pyomo to solve an optimization problem and I'm using as a solver IPOPT.&#xA;Now I'm getting an error from IPOPT.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;EXIT: Search Direction is becoming Too Small.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;according to the docs, this means:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Search Direction is becoming Too Small.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This indicates that IPOPT is calculating very small step sizes and making very little progress. This could happen if the problem has been solved to the best numerical accuracy possible given the current scaling.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: I interpret this as that IPOPT has a value calculated, but is returning an error because it isn't 'satisfied'? I find it weird that they don't return a 'best possible value'. Why is this and can we make IPOPT return that best possible value (so that when the search direction is becoming too small, return the best found value at that point)?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt; I came across this document which seems useful for solving my case.&#xA;&lt;a href=&quot;https://coin-or.github.io/Ipopt/OPTIONS.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://coin-or.github.io/Ipopt/OPTIONS.html&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2021-05-23T19:43:30.533" LastActivityDate="2021-05-24T01:47:32.650" Title="Returning the best possible value found when the search direction is becoming too small (IPOPT via Pyomo)" Tags="|optimization|python|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6300" PostTypeId="2" ParentId="6297" CreationDate="2021-05-22T13:04:30.323" Score="5" Body="&lt;p&gt;You just seem to have hidden a long list of constraints of the form &lt;span class=&quot;math-container&quot;&gt;$(x_i=j)  \Rightarrow \text{equalities}_{ij}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Introduce a binary matrix &lt;span class=&quot;math-container&quot;&gt;$C_{ij}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\sum_j C_{ij}= 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_{ij} \Rightarrow \{x_{i} = j, \text{equalities}_{ij}\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To model the binary implication you can use big-M modelling, e.g. &lt;span class=&quot;math-container&quot;&gt;$-M(1- C_{ij})\leq x_{i} - j\leq M (1-C_{ij})$&lt;/span&gt; and similar for all the other equalities.&lt;/p&gt;&#xA;&lt;p&gt;The big-M model for &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; can be replaced with &lt;span class=&quot;math-container&quot;&gt;$x_i=\sum_j C_{ij} j$&lt;/span&gt; to reduce the model slightly.&lt;/p&gt;&#xA;" OwnerUserId="487" LastEditorUserId="487" LastEditDate="2021-05-22T22:02:00.487" LastActivityDate="2021-05-22T22:02:00.487" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6301" PostTypeId="1" AcceptedAnswerId="6305" CreationDate="2021-05-22T16:05:25.307" Score="11" ViewCount="1444" Body="&lt;p&gt;Does anyone know any linear optimization libraries for C++ supporting GPUs for parallelization? If multiple, which do you recommend?&lt;/p&gt;&#xA;&lt;p&gt;The GPU support is important to me since I am dealing with large matrices in my problem constraints where the solving section is pretty much time-consuming without parallelization.&lt;/p&gt;&#xA;&lt;p&gt;I myself found 1-2 PhD theses but they hadn't published their implementation as a library publicly.&lt;/p&gt;&#xA;" OwnerUserId="5549" LastEditorUserId="5549" LastEditDate="2021-05-22T21:30:16.243" LastActivityDate="2024-01-05T13:47:35.100" Title="Linear Optimization Library for C++ with GPU Support" Tags="|optimization|linear-programming|c++|parallel-computing|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="6302" PostTypeId="2" ParentId="6288" CreationDate="2021-05-22T18:58:54.093" Score="1" Body="&lt;p&gt;I'm not sure if this is exactly on point, but there is a &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2013/05/3900.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt; by Carvajal et al. on the use of parallel trees (with communication between them) for solving integer programs. You might also be interested in reference [10] in their paper (Koch et al.), which discusses &amp;quot;racing ramp-up&amp;quot;, a technique adopted by CPLEX a while back, in which you initially turn different solver configurations loose and, after some amount of time or iterations, pick the one that seems to be making the best progress.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-05-22T18:58:54.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6304" PostTypeId="1" AcceptedAnswerId="6307" CreationDate="2021-05-23T07:09:34.867" Score="4" ViewCount="265" Body="&lt;p&gt;I am somewhat new to OR. I have taken up courses on Linear Programming, Game Theory and Queueing Theory and I know a bit of Dynamic Programming. Soon I shall be doing a project on OR or Optimization and haven't yet decided on the topic. So before selecting the topic, I wish to get an overview (i.e., what kinds of problems are studied) of the different areas of OR and Optimization. Could you provide some good reference(s) for the above. I repeat, I am &lt;strong&gt;not&lt;/strong&gt; asking for resources to study the various areas in depth.&lt;br /&gt;&#xA;Note: I am interested more in the math of the subject than the applications.&lt;/p&gt;&#xA;" OwnerUserId="5551" LastActivityDate="2021-06-01T21:24:02.897" Title="Overview of the different areas of OR and optimization" Tags="|reference-request|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6305" PostTypeId="2" ParentId="6301" CreationDate="2021-05-23T15:40:32.240" Score="20" Body="&lt;p&gt;For context: most (if not all) major LP solvers are built on 2 algorithms: the simplex method, and the interior-point method.&lt;/p&gt;&#xA;&lt;p&gt;The simplex method is intrinsically sequential: you're doing a lot of (cheap) operations called pivots, and the matrices involved are usually sparse. At each pivot, you essentially perform a rank-one update of a sparse LU factorization, plus a few matrix-vector products. Unless your problem exhibits some particular structure (as in &lt;a href=&quot;https://mlubin.github.io/pdf/pipss.pdf&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt;), the potential for parallelism is relatively low (even on CPU), especially when dealing with problems that exhibit &lt;a href=&quot;https://link.springer.com/article/10.1007/s10589-005-4802-0&quot; rel=&quot;noreferrer&quot;&gt;hyper sparsity&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the interior-point method, the main cost at each iteration is computing the Cholesky factorization of a matrix of the form &lt;span class=&quot;math-container&quot;&gt;$A D A^{T}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is the constraint matrix of your problem (in standard form) and &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is diagonal.&#xA;Again, the matrices involved are sparse, but Cholesky factorization is more amenable to parallelism. Here, modern LP solvers will use multiple (CPU) threads when available.&lt;/p&gt;&#xA;&lt;p&gt;From there, here are the 3 main reasons that LP solvers typically don't run on a GPU:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Because the matrices are sparse, the potential GPU speed-up is less dramatic than, e.g., in machine learning (where everything mostly boils down to dense matrix-matrix multiplication). Even just handling memory requirements on a GPU can quickly become a nightmare.&lt;/li&gt;&#xA;&lt;li&gt;The available GPU libraries for &lt;strong&gt;sparse&lt;/strong&gt; linear algebra are not yet as numerically robust and broad as existing CPU ones. For instance, as far as I know, there is no sparse Cholesky factorization on &lt;a href=&quot;https://docs.nvidia.com/cuda/cusparse/index.html&quot; rel=&quot;noreferrer&quot;&gt;CuSparse&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Solver development teams are usually small, and building/maintaining GPU support is a lot of work, which may simply not be worth it at the moment.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;One further reason: LP solvers perform computations in double-precision floating-point arithmetic. However, recent trends in GPU development are moving towards lower-precision arithmetic, such as single-precision or even lower (see NVIDA's recent &amp;quot;Tensor32&amp;quot; arithmetic). When looking at GPUs' flop-count for double-precision, the potential speedups are less dramatic.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="3598" LastEditDate="2021-05-24T12:23:05.527" LastActivityDate="2021-05-24T12:23:05.527" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6306" PostTypeId="1" AcceptedAnswerId="6308" CreationDate="2021-05-23T15:50:48.637" Score="3" ViewCount="64" Body="&lt;p&gt;I'm unfamiliar with OR, and would like to get some advice on how to &amp;quot;think&amp;quot; about this scenario:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I work for an organization that primarily has store fronts. Customer's arrive throughout the day and are serviced per their needs. Some needs require less than 10 minutes to service. Some require half an hour. There's probably 10 types of services a customer can come in for.&lt;/li&gt;&#xA;&lt;li&gt;The most frequently used services can be completed in less than 10 minutes. The complex ones - around half an hour.&lt;/li&gt;&#xA;&lt;li&gt;Now, should a customer call the help-line and be scheduled for an appointment (instead of randomly walking in), the time taken to help the customer schedule an in-person appointment for the right reasons, is approx 10 minutes.&lt;/li&gt;&#xA;&lt;li&gt;Most times, the customer just walks-in.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The scenario:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The organization is recovering from the Pandemic and would like to switch to an appointments only model.&lt;/li&gt;&#xA;&lt;li&gt;The organization will have self scheduling options in the future, but not on day one of opening up.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The question:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How would one go about modeling/comparing the FCFS (original) situation, with an appointment only model?&lt;/li&gt;&#xA;&lt;li&gt;How would I arrive at a reasonable scheduled appointment duration for a given type of service. Meaning: if a frequently used service takes 10 minutes to complete (on average), how much time should I block off for that service, in an appointments only model?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Data:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I don't have much data in hand. I have the average time (minutes) to complete a service, by service type. I have the total number of service requests by service type (by month). I don't have customer wait times.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5552" LastEditorUserId="123" LastEditDate="2021-05-23T19:28:33.337" LastActivityDate="2021-05-23T19:28:33.337" Title="How would I model the following problem concerning customer service via FCFS vs Appointment Scheduling" Tags="|scheduling|queuing-theory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6307" PostTypeId="2" ParentId="6304" CreationDate="2021-05-23T18:59:01.817" Score="8" Body="&lt;p&gt;Optimization is a very large area in terms of the types of problems and models. You have taken a course on linear programming, in which (a) the problem is deterministic (you assume that you know at the outset everything required to find an optimal solution), (b) the variables are real-valued and &amp;quot;continuous&amp;quot; (perhaps more correctly, &amp;quot;divisible&amp;quot;), meaning fractional values are allowed, (c) there is a single criterion (objective) function, (d) all constraints (and the objective function) are linear, and (e) there are no not-equal-to constraints (no &lt;span class=&quot;math-container&quot;&gt;$a^T x \neq b$&lt;/span&gt;). Pretty much every combination of those assumptions can be dropped, leading to another branch of the optimization family tree.&lt;/p&gt;&#xA;&lt;p&gt;If you make all (some) variables integer-valued but leave all the other assumptions alone, you get integer (mixed-integer) linear programming. Let the object function be quadratic (all other assumptions holding) and you have quadratic programming. Let some variables be integer, the objective quadratic and some constraints quadratic (of the right form) and you have MIQCQP (mixed-integer quadratically constrained quadratic programming).&lt;/p&gt;&#xA;&lt;p&gt;The assumption of a deterministic problem can also be dropped, leading to stochastic optimization, including among its forms chance constrained programming and stochastic programming with recourse (which differ in how the lack of determinism is handled). Drop the assumption of a single criterion and you have multicriterion optimization, which includes special cases such as goal programming, fuzzy goal programming, Pareto optimization, archimean weighted objective functions and other approaches.&lt;/p&gt;&#xA;&lt;p&gt;That's not an exhaustive list by any means. I've intentionally not even touched optimal control theory. Importantly, that's just optimization. Stochastic processes, simulation and other OR areas are also out there (and also prone to forking into progressively more specific subareas with progressively longer acronyms).&lt;/p&gt;&#xA;&lt;p&gt;You said you were not primarily interested in the applications, and this is already a very long answer, so I won't go into those. I will say that for just about every type of OR problem or model, there are real-world applications to be found.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-05-23T18:59:01.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6308" PostTypeId="2" ParentId="6306" CreationDate="2021-05-23T19:09:03.800" Score="4" Body="&lt;p&gt;Since you are unfamiliar with OR, I would recommend using &lt;a href=&quot;https://en.wikipedia.org/wiki/Discrete-event_simulation&quot; rel=&quot;nofollow noreferrer&quot;&gt;discrete event simulation&lt;/a&gt;, which I think is the easiest approach for a newcomer (although it may require some programming chops, depending on what software you use). You will need a bit more than just average service completion times -- you will want a distribution of service times. (In the absence of a robust data sample, you will probably have to just assume a commonly used distribution, such as exponential.) Similarly, for the walk-in case you will need a distribution of what are called interarrival times (time between consecutive customer arrivals), which again might be assumed exponential. For the appointment case, you may need a distribution for time between arriving calls for appointments (maybe exponential).&lt;/p&gt;&#xA;&lt;p&gt;That may be enough to get you started. For a more realistic model, you may need some additional information, including when (and for how long) servers take breaks (you do give them breaks, don't you?), how likely a walk-in customer is likely to wait before bailing out (&amp;quot;reneging&amp;quot;), how likely an arriving walk-in customer is to look at line length and think &amp;quot;no way&amp;quot; (&amp;quot;balking&amp;quot;), how likely a customer with an appointment is to be a no-show or to be late (in which case, how late?), and possibly some other criteria. You can build a fairly simple model for the FCFS case, play with it, and see if people in the know think the results match their experience (&amp;quot;face validation&amp;quot;). Then you can start tweaking the model to reflect policy choices. The reservation-only model can be approached similarly.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-05-23T19:09:03.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6309" PostTypeId="2" ParentId="6299" CreationDate="2021-05-24T01:47:32.650" Score="1" Body="&lt;p&gt;Ipopt and similar solvers rely on criteria such as &lt;a href=&quot;https://en.wikipedia.org/wiki/Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions&quot; rel=&quot;nofollow noreferrer&quot;&gt;KKT&lt;/a&gt; to find out whether they converged against a point which satisfies 2nd order optimality conditions. However for the sake of not running forever and in the face of finite precision of Floating point numbers it does not make sense to continue running. So it stopped early and reported a failure.&lt;/p&gt;&#xA;&lt;p&gt;Imagine a function &lt;span class=&quot;math-container&quot;&gt;$f(x) = 0.5 (\varepsilon*x)^2$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt; is the floating point epsilon. The gradient as you approach 0 becomes vanishingly small so you Ipopt with the current settings might not feel confident that can do another step but knows from the KKT conditions that it has reached a point which satisfies 2nd order optimality conditions.&lt;/p&gt;&#xA;&lt;p&gt;Here are some things you could check&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;On page 8 of the &lt;a href=&quot;https://projects.coin-or.org/CoinBinary/export/837/CoinAll/trunk/Installer/files/doc/Short%20tutorial%20Ipopt.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Short Ipopt tutorial&lt;/a&gt; it says the Ipopt might&#xA;also get stuck in saddle points. Are you getting stuck in one? If so starting a different initial value probably help.&lt;/li&gt;&#xA;&lt;li&gt;If you pass hessians/gradients into Ipopt are they correct?&lt;/li&gt;&#xA;&lt;li&gt;Try rescaling the objective multiplying it by some largeish number&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I'm not familiar with Pyomo but JuMP from the Julia ecosystem &lt;a href=&quot;https://github.com/jump-dev/Ipopt.jl/issues/95#issue-277608124&quot; rel=&quot;nofollow noreferrer&quot;&gt;is able to extract the current iteration&lt;/a&gt;, the objective and so on, even on solver failure. These information are also available from the C Interface.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-05-24T01:47:32.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6310" PostTypeId="2" ParentId="6298" CreationDate="2021-05-24T09:31:27.253" Score="4" Body="&lt;p&gt;Your bisection code is returning a tuple of &lt;code&gt;[a,b]&lt;/code&gt; but in your main function you are only retrieving &lt;code&gt;a&lt;/code&gt;, which should be causing the type error.&lt;/p&gt;&#xA;&lt;p&gt;There's also another bug in your &lt;code&gt;bracket_minimum&lt;/code&gt; function - it can potentially get stuck in an infinite loop if your return condition is never satisfied. Ideally you want to have max iterations and return &lt;code&gt;no solution found&lt;/code&gt; if you hit that max.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-05-24T09:31:27.253" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6311" PostTypeId="2" ParentId="3045" CreationDate="2021-05-24T09:47:35.557" Score="2" Body="&lt;p&gt;There are two main reasons to add cuts. First, to tighten the relaxation, i.e., make the domain smaller whilst preserving the global solution. Second, to kick a known (or predicted) solution out of the problem. This is common in e.g. feasibility pumps, where we want to avoid cycling of solutions, or when we want to break symmetry. We can also generate cuts for conflict analysis but that's a bit more convoluted.&lt;/p&gt;&#xA;&lt;p&gt;To answer your question directly, it depends on context. In general, the new variable fixing would result in the problem being infeasible in that node, which is usually what we want (e.g., this node can't produce a better value than our current one). However, this is only true if the cut is supposed to be globally valid. If the cut is only supposed to be valid in a specific neighbourhood, it should be removed instead, unless your node is in the same branch as the node used to generate the local cut.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-05-24T09:47:35.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6312" PostTypeId="1" CreationDate="2021-05-24T10:01:32.330" Score="0" ViewCount="430" Body="&lt;p&gt;I have a linear programming problem, with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$a\leq x_{i} \leq b$&lt;/span&gt; for each variable &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt;, where the objective function is &lt;span class=&quot;math-container&quot;&gt;$\min \sum\limits_{i=1}^{n}{2^{i} x_{i}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is it true that, given the problem is feasible, there is only one optimal solution of the problem?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: all the variables have coefficient &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt; in the constraints.&lt;/p&gt;&#xA;" OwnerUserId="3221" LastEditorUserId="3221" LastEditDate="2021-05-24T12:53:08.907" LastActivityDate="2021-05-26T12:42:52.867" Title="Objective function with exponential coefficients" Tags="|linear-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6313" PostTypeId="1" AcceptedAnswerId="6315" CreationDate="2021-05-24T16:38:21.973" Score="2" ViewCount="247" Body="&lt;p&gt;I'd like to find the minimum of a smooth, continuous function inside the unit hypercube (the dimensionality of which could go into the hundreds or even thousands). The function is convex (Hessian &lt;span class=&quot;math-container&quot;&gt;$\geq 0$&lt;/span&gt; everywhere) within the unit hypercube but not outside of it. Additionally, I know that the minimum of the function is always positive.&lt;/p&gt;&#xA;&lt;p&gt;I can evaluate both the function and its gradient relatively cheaply; second derivatives are quite a bit more expensive.&lt;/p&gt;&#xA;&lt;p&gt;Frank-Wolfe works, and is easy to do as I can always go in the direction of the vertex closest to the negative gradient, but the line search part is really quite slow. It also doesn't seem to make particularly good use of the convex structure or the bound on the minimum.&lt;/p&gt;&#xA;&lt;p&gt;Are there any other approaches I should research given my problem?&lt;/p&gt;&#xA;" OwnerUserId="5557" LastActivityDate="2021-05-25T23:48:01.413" Title="Convex optimization on the unit hypercube with gradients and a bounded minimum" Tags="|optimization|constraint|convex-optimization|convexity|continuous-optimization|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6314" PostTypeId="2" ParentId="6304" CreationDate="2021-05-24T19:21:22.153" Score="3" Body="&lt;p&gt;Informs has a list of case studies of different area of OR applications:&#xA;&lt;a href=&quot;https://pubsonline.informs.org/page/ited/cases&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pubsonline.informs.org/page/ited/cases&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1219" LastActivityDate="2021-05-24T19:21:22.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6315" PostTypeId="2" ParentId="6313" CreationDate="2021-05-25T01:32:47.303" Score="3" Body="&lt;p&gt;From the looks of it (simple feasible set, convex objective, gradient available), Frank-Wolfe indeed makes a lot of sense here.&#xA;I can point out that there exist many variants of the algorithm, and that several are implemented in &lt;a href=&quot;https://github.com/ZIB-IOL/FrankWolfe.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;this recent Julia package&lt;/a&gt;. This can give you a quick way to experiments various algorithmic configurations.&lt;/p&gt;&#xA;&lt;p&gt;If you do decide to look into other methodologies, since your problem is convex, then I would recommend giving conic optimization a try.&#xA;Conic optimization solvers employ robust interior-point algorithms with strong convergence guarantees; it may or may not be faster than FW depending on your problem.&#xA;The &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/expo.html#relative-entropy&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek modeling cookbook&lt;/a&gt; provides a lot of modeling tips (you mention KL divergence so I linked to the corresponding section of the cookbook).&#xA;You might also find tools such as CVX (Matlab), cvxpy (Python) or Convex.jl (Julia) useful for doing the modeling.&#xA;They will automatically reformulate the problem into conic form before passing it to a conic solver.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2021-05-25T01:32:47.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6316" PostTypeId="1" CreationDate="2021-05-25T04:54:24.467" Score="1" ViewCount="440" Body="&lt;p&gt;Consider the combinatorial optimization problem described as below.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$D=(V,A)$&lt;/span&gt; be a directed graph with &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; the set of vertices and &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; the set of arcs, i.e., &lt;span class=&quot;math-container&quot;&gt;$A=\{(i,j)\mid i,j\in V\}$&lt;/span&gt;. On each arc &lt;span class=&quot;math-container&quot;&gt;$a\in A$&lt;/span&gt;, there is a reward &lt;span class=&quot;math-container&quot;&gt;$r_a$&lt;/span&gt; associated with it. The optimization problem is to form one or more cycles using the arcs, with each arc used in no more than one cycle. The cardinality of the cycle(s) cannot be more than a given number &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;. The objective is to maximize the sum of rewards for the arcs used in the cycles.&lt;/p&gt;&#xA;&lt;p&gt;The major differences between this problem and the well-known Asymmetric Travelling Salesman Problem (ATSP) are as follows.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;A solution that contains more than one &amp;quot;subtour&amp;quot; is considered feasible, however, the size of each subtour must be no more than &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; vertices.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A feasible solution does not necessarily have to involve all vertices in &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The objective is to maximize total reward of arcs used instead of to minimize the total cost of arcs used.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Let:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j}\in\{0,1\}$&lt;/span&gt; be a binary variable with &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=1$&lt;/span&gt; indicating arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in A$&lt;/span&gt; is used in the solution and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\Bbb P_K$&lt;/span&gt; be the set of all simple paths with exactly &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; vertices; and&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\tau=(i_1,\ldots,i_K)\in\Bbb P_K$&lt;/span&gt; be an arbitrary simple path with exactly &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; vertices, i.e., the arcs in the path are &lt;span class=&quot;math-container&quot;&gt;$(i_1,i_2),(i_2,i_3),\ldots,(i_{K-1},i_K)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;An integer linear programming (ILP) model is given as below. &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad\sum_{(i,j)\in A}r_{ij}x_{ij}\tag1\\\text{s.t.}&amp;amp;\quad\sum_{(i,j)\in A}x_{ij}\le1,&amp;amp;\quad\forall i\in V\tag2\\&amp;amp;\quad\sum_{(j,i)\in A}x_{ji}=\sum_{(i,j)\in A}x_{ij},&amp;amp;\quad\forall i\in V\tag3\\&amp;amp;\quad x_{i_1,i_2}+x_{i_2,i_3}+\cdots+x_{i_{K-1},i_K}-x_{i_K,i_1}\le K-2,&amp;amp;\quad\forall(i_1,\ldots,i_K)\in\Bbb P_K\tag4\\&amp;amp;\quad x_{ij}\in\{0,1\},&amp;amp;\quad\forall(i,j)\in A\tag5.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can someone help with writing up constraint &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; in CPLEX? I don't how to write this one constraint, can you do it for &lt;span class=&quot;math-container&quot;&gt;$K=4$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;My code is currently as follows.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int K =...;&#xA;int nbVertices =166;&#xA;range Vertices =1..nbVertices;&#xA;int Reward[Vertices][Vertices] = ...;&#xA;dexpr int totalReward = sum (i in Vertices, j in Vertices)Reward[I] &#xA;[j]*Arc[i][j];&#xA;maximize totalReward;&#xA;&#xA;&#xA;subject to { &#xA;forall(i in Vertices)&#xA;sum(j in Vertices)Arc[i][j] &amp;lt;=1; //constraint (2)&#xA;forall(i in Vertices) &#xA;sum(j in Vertices)Arc[j][i] == sum(j in Vertices)Arc[i][j];//(3)&#xA;forall(i,j,k,l in Vertices: i!=j &amp;amp;&amp;amp; j!=k &amp;amp;&amp;amp; k!=l &amp;amp;&amp;amp; l!=i) Arc[i][j]+&#xA; Arc[j][k] + Arc[k][l] - Arc[k][i] &amp;lt;= K-2; //constraint (4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5559" LastEditorUserId="123" LastEditDate="2021-05-26T06:45:50.257" LastActivityDate="2021-05-26T06:45:50.257" Title="Combinatorial Optimization Problem using IBM ILOG CPLEX" Tags="|mixed-integer-programming|cplex|combinatorial-optimization|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6317" PostTypeId="1" AcceptedAnswerId="6321" CreationDate="2021-05-25T06:08:48.907" Score="3" ViewCount="569" Body="&lt;p&gt;Are there any good books that teach how to work with OPL in CPLEX? I searched but I didn't find any.&lt;/p&gt;&#xA;" OwnerUserId="5094" LastEditorUserId="2579" LastEditDate="2021-09-08T00:16:06.787" LastActivityDate="2021-09-08T00:16:06.787" Title="Book recommendations on OPL" Tags="|cplex|reference-request|books|opl|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6318" PostTypeId="1" CreationDate="2021-05-25T06:11:32.760" Score="4" ViewCount="737" Body="&lt;p&gt;I want to deploy my OR model (python, pyomo) as an Rest API (using Flask) that too on Azure Kubernet. All I have came across so far are ways to do the same for ML models, which can be uploaded as pickle file and used, but the same is not possible with my model.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for resources addressing OR models for the deployment but any help is appreciated, and a template will be a bonus.&lt;/p&gt;&#xA;" OwnerUserId="5560" LastEditorUserId="123" LastEditDate="2021-05-25T08:01:03.580" LastActivityDate="2022-08-01T08:25:06.377" Title="Deploying OR Model as an API" Tags="|api|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6320" PostTypeId="2" ParentId="6316" CreationDate="2021-05-25T06:23:27.343" Score="1" Body="&lt;p&gt;In pseudocode, you'd have to do the following:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create a binary &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; variable for every arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in A$&lt;/span&gt;. Use the &lt;code&gt;boolVar(.)&lt;/code&gt; method in the &lt;code&gt;IloCplexModeler&lt;/code&gt; class. Personally I find it convenient to create a Map that maps an edge to its variable to quickly lookup the variable that corresponds to a given arc. If you use Java, you would have to define an &lt;code&gt;Arc&lt;/code&gt; class, if you use Python, you could use a tuple.&lt;/li&gt;&#xA;&lt;li&gt;Generate the set &lt;span class=&quot;math-container&quot;&gt;$P_k$&lt;/span&gt; of all simple paths of length &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. Each path is a sequence of arcs.&lt;/li&gt;&#xA;&lt;li&gt;For every path in &lt;span class=&quot;math-container&quot;&gt;$P_k$&lt;/span&gt;, create a constraint of type 4. Iterate over the arcs in the path, and use your map to lookup the corresponding variables.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Step 3 would look something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for(Path path : paths){&#xA;  IloLinearNumExpr expr = cplex.linearNumExpr();&#xA;  for(Arc arc : path){&#xA;    expr.addTerm(1.0, varMap.get(arc));&#xA;  }&#xA;  cplex.addLe(expr, K-2, &amp;quot;cycleConstraint&amp;quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The above, simplified, code snippet does not yet include the return arc which has a negative coefficient, but I hope you get the idea.&lt;/p&gt;&#xA;&lt;p&gt;If you happen to use java, I would recommend to model the graph using the graph library JGraphT. Then you can easily iterate the desired paths.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-05-25T06:23:27.343" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6321" PostTypeId="2" ParentId="6317" CreationDate="2021-05-25T06:37:58.943" Score="7" Body="&lt;p&gt;There are many useful references that can be found by googling. In the following you can find some of them:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.ibm.com/docs/en/SSSA5P_12.8.0/ilog.odms.studio.help/pdf/opl_languser.pdf&quot; rel=&quot;noreferrer&quot;&gt;IBM ILOG CPLEX Optimization Studio OPL Language User’s Manual&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.springer.com/gp/book/9783540298786&quot; rel=&quot;noreferrer&quot;&gt;Introduction to Computational Optimization Models for Production Planning in a Supply Chain&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://networkdesignbook.com/wp-content/uploads/2018/06/A-Deep-Dive-Into-Strategic-Network-Design-Programming-by-Cacioppi-and-Watson.pdf&quot; rel=&quot;noreferrer&quot;&gt;A Deep Dive into Strategic Network Design&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;PS: About the first mentioned reference, it is about (V-12.8) that I knew the last version is 20.1. I hope they will be helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-05-25T06:37:58.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6322" PostTypeId="1" AcceptedAnswerId="6326" CreationDate="2021-05-25T07:15:37.723" Score="1" ViewCount="144" Body="&lt;p&gt;Could you please tell where I can find a method &lt;code&gt;Cplex.AddMIPStart&lt;/code&gt;? By that I mean in which library and how to link this library to my C# project.&lt;/p&gt;&#xA;" OwnerUserId="5561" LastEditorUserId="500" LastEditDate="2023-12-13T18:02:38.347" LastActivityDate="2023-12-13T18:02:38.347" Title="How to call Cplex.AddMIPStart method" Tags="|cplex|c#|warm-start|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6323" PostTypeId="2" ParentId="6318" CreationDate="2021-05-25T07:29:31.907" Score="3" Body="&lt;p&gt;I am unsure what exactly you want to pickle. Is the user posting data to your endpoint (the flask service)? In that case you probably need to re-run the algorithm.&lt;/p&gt;&#xA;&lt;p&gt;In machine learning the model is usually pickled as you have already trained it. Thus the user in that case just need to provide the input for the model and it will immediately make a prediction on the input data.&lt;/p&gt;&#xA;&lt;p&gt;As I see it you either want the user to call your model with new input, thus it needs to re-optimize. I don't think pickling anything here will help you particularly. If you just want the user to be able to access the model, then the question is why?&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2021-05-25T07:29:31.907" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6324" PostTypeId="2" ParentId="6316" CreationDate="2021-05-25T07:39:11.900" Score="1" Body="&lt;p&gt;Here (4) refers to a set of constraints, written for all possible paths with exactly &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; vertices. The formulation is therefore non-compact which means the no. of these constraints grow exponentially as the problem size (no. of nodes) increases. In this case, there would be &lt;span class=&quot;math-container&quot;&gt;$\frac1n\cdot {}^nP_r$&lt;/span&gt; constraints, where &lt;span class=&quot;math-container&quot;&gt;$n = |V|$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$r = K$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; represents permutations. Hence, it is difficult to add all such constraints in one go and also the LP model becomes unnecessarily bulky for CPLEX branch and bound.&lt;/p&gt;&#xA;&lt;p&gt;These constraints are therefore often relaxed initially and added as and when relevant violations are found using a cutting plane approach (prior to branch and bound) and then branch and cut approach (during branch and bound). In both cases you need to implement a separation routine that will check the current LP relaxed solution for possible violations of a constraint from (4) and subsequently add that constraint to the model if a violation is found. When using the branch and cut approach in CPLEX, you will need cut callback (&lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=legacy-cut-callback&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/20.1.0?topic=legacy-cut-callback&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="3640" LastEditorUserId="123" LastEditDate="2021-05-25T08:04:08.760" LastActivityDate="2021-05-25T08:04:08.760" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6325" PostTypeId="1" AcceptedAnswerId="6327" CreationDate="2021-05-25T07:39:57.107" Score="0" ViewCount="142" Body="&lt;p&gt;When I run my CPLEX model, under the Profiler tab I get the error&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Overflow occurred, please use oplrun -profile.&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;How do I setup oplrun? I looked at the IBM website but I don't understand the instruction. Can someone show an example of setting up an oplrun that includes a .mod and .dat file?&lt;/p&gt;&#xA;" OwnerUserId="5559" LastEditorUserId="123" LastEditDate="2021-05-25T07:59:31.190" LastActivityDate="2021-05-25T08:14:44.610" Title="ILOG CPLEX Overflow occurred" Tags="|cplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6326" PostTypeId="2" ParentId="6322" CreationDate="2021-05-25T08:10:10.297" Score="3" Body="&lt;p&gt;Aside&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://medium.com/@AlainChabrier/warm-start-optimization-ac73eef189e9&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://medium.com/@AlainChabrier/warm-start-optimization-ac73eef189e9&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=am-addmipstart-method-inumvar-double-int32-int32-cplexmipstarteffort-string&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Adds a MIP start, defined by a range of numeric variables and corresponding values, with its name and an effort level.&#xA;&#xA;Namespace: ILOG.CPLEX&#xA;Assembly: ILOG.CPLEX (in ILOG.CPLEX.dll) Version: 20.1.0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-05-25T08:10:10.297" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6327" PostTypeId="2" ParentId="6325" CreationDate="2021-05-25T08:14:44.610" Score="3" Body="&lt;p&gt;you may either call &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=interface-executing-oplrun-from-ide&quot; rel=&quot;nofollow noreferrer&quot;&gt;oplrun from the IDE&lt;/a&gt; or in the &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=interface-executing-oplrun-manually&quot; rel=&quot;nofollow noreferrer&quot;&gt;command line&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-05-25T08:14:44.610" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6328" PostTypeId="1" AcceptedAnswerId="6330" CreationDate="2021-05-25T08:39:23.123" Score="6" ViewCount="325" Body="&lt;p&gt;The function &lt;span class=&quot;math-container&quot;&gt;$\max(x,y)$&lt;/span&gt; can be linearized by making use of additional binary variables. I suppose global optimisers are implemented to perform this transformation automatically.&lt;/p&gt;&#xA;&lt;p&gt;Is there a global optimiser that allows this function to be treated as a non-linear function (I mean not transforming it into a MILP equivalent)?&lt;/p&gt;&#xA;&lt;p&gt;Does e.g. SCIP, Octeract, BARON, ... have an option to forbid the transformation into an MILP?&lt;/p&gt;&#xA;&lt;p&gt;The model looks like&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\max&amp;amp;\quad\text{linear function}\\\text{s.t.}&amp;amp;\quad z_i = \max(x_i,y_i),\quad i &amp;gt; 1 \\&amp;amp;\quad\text{linear block of constraints}\\&amp;amp;\quad x_i \ge 0, \hspace{0.1 cm} y_i \ge0, \hspace{0.1 cm} z_i \ge 0&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="500" LastEditDate="2021-05-25T12:33:46.167" LastActivityDate="2021-05-25T13:07:40.350" Title="Forbid transformation of max(x,y) into MILP" Tags="|mixed-integer-programming|linearization|global-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6330" PostTypeId="2" ParentId="6328" CreationDate="2021-05-25T10:41:21.267" Score="6" Body="&lt;p&gt;In YALMIP you can use arbitrary black-box operators to circumvent modelling&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;n = 5;&#xA;c = randn(3*n,1);&#xA;A = randn(10*n,3*n);&#xA;b = rand(10*n,1);&#xA;&#xA;% MILP model&#xA;x = sdpvar(2*n,1);&#xA;Domain= [0 &amp;lt;= x &amp;lt;= 1]; % Big-M should have some help&#xA;for i = 1:n&#xA;    x = [x;max([x(i),x(i+n)])];&#xA;end&#xA;optimize([Domain, A*x &amp;lt;= b], c'*x)&#xA;&#xA;% Black-box model (sdpfun is renamed to blackbox in next version...)&#xA;x = sdpvar(2*n,1);&#xA;Domain= [0 &amp;lt;= x &amp;lt;= 1];&#xA;for i = 1:n&#xA;    x = [x;sdpfun(x([i i+n]),@max)];&#xA;end&#xA;% ...with local nonlinear solver&#xA;optimize([Domain, A*x &amp;lt;= b], c'*x)&#xA;&#xA;% ...with global solver&#xA;%    which appears to have issues as it doesn't understand the thin envelopes    &#xA;%    (I will look into that)&#xA;%    However, using a blackbox inside the global solver is shaky and should not be &#xA;%    done and I would expect it to fail. A dedicated operator should be added&#xA;optimize([Domain, A*x &amp;lt;= b], c'*x, sdpsettings('solver','bmibnb'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The important question is why though? A global solver will likely have to work hard to find the logic which is nicely described by the binary structure.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: Appears the global solver thinks I am crazy sending a multivariate black-box function so it does not do any bound propagation etc. Changing to a univariate works better, and that can be done by &lt;span class=&quot;math-container&quot;&gt;$\max(x,y) = \frac{x+y+|x-y|}{2}$&lt;/span&gt;. Absolute values are MILP-represented so once again black-box needed. Still though, this is not something you want to do unless you have some very particular reason. In particular at the moment with a sampling-based blackbox to which you can have absolutely no trust (next version will allow you to append envelope generators to a black box which improves the situation)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x = sdpvar(2*n,1);&#xA;Domain = [0 &amp;lt;= x &amp;lt;= 1];&#xA;for i = 1:n        &#xA;    z = (x(i)+x(i+n)+sdpfun(x(i)-x(i+n),@abs))/2;&#xA;    x = [x;z];&#xA;end&#xA;optimize([Domain, A*x &amp;lt;= b], c'*x,sdpsettings('solver','bmibnb'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="487" LastEditorUserId="487" LastEditDate="2021-05-25T11:37:12.590" LastActivityDate="2021-05-25T11:37:12.590" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6331" PostTypeId="2" ParentId="6313" CreationDate="2021-05-25T11:58:35.990" Score="2" Body="&lt;p&gt;When you have only box constraints I don't think Frank Wofle is very efficient. Frank Wolfe can handle more complex constraints. You should try a quasi newton algorithm like l-bfgs-b or a truncated newton conjugate gradient algorithm with projection.&lt;/p&gt;&#xA;" OwnerUserId="5562" LastActivityDate="2021-05-25T11:58:35.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6332" PostTypeId="2" ParentId="6318" CreationDate="2021-05-25T12:10:28.310" Score="4" Body="&lt;p&gt;I think in your case you have to separate between the data and the model. The model itself is part of the service in some way. Either you hard code it into the service or you have some sort of abstract description of the model (for example in some modeling language that the solver can read) so that you can upload new versions of the model to the service.&lt;/p&gt;&#xA;&lt;p&gt;What the user then uploads is the data with which the model gets instantiated. This gives a problem instance that the service then solves and eventually returns a solution for.&lt;/p&gt;&#xA;&lt;p&gt;So in your scheduling example, the user would only provide the jobs/machines/... and the service would construct a model from this based on the abstract problem representation.&lt;/p&gt;&#xA;" OwnerUserId="3179" LastActivityDate="2021-05-25T12:10:28.310" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6333" PostTypeId="2" ParentId="6328" CreationDate="2021-05-25T13:07:40.350" Score="4" Body="&lt;p&gt;The default Octeract Engine behaviour is to handle this automatically without reformulating to an MILP.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-05-25T13:07:40.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6334" PostTypeId="1" AcceptedAnswerId="6343" CreationDate="2021-05-25T15:14:10.797" Score="3" ViewCount="97" Body="&lt;p&gt;A typical linear program is written as &lt;span class=&quot;math-container&quot;&gt;$$L_0:\min_{x \geq 0; A^\top x \leq b}c^\top x.$$&lt;/span&gt; Here, &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c \in \mathbb{R}^n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{m \times n}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$b \in \mathbb{R}^m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now consider a matrix &lt;span class=&quot;math-container&quot;&gt;$M \in \mathbb{R}^{m \times m}$&lt;/span&gt; which is multiplied on both sides of the inequality constraints such that the problem becomes &lt;span class=&quot;math-container&quot;&gt;$$L_1:\min_{x \geq 0; MA^\top x \leq Mb}c^\top x.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What should be the constraints on &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$L_0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L_1$&lt;/span&gt; have the same&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;feasible region;&lt;/li&gt;&#xA;&lt;li&gt;and/or the same solutions?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The answer is somewhat clear in the case of equality - &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; should be an invertible matrix (I might be wrong here too).&lt;/p&gt;&#xA;&lt;p&gt;What mathematical concepts should I use to reason about the above problem?&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; Cross-posted on &lt;a href=&quot;https://math.stackexchange.com/questions/4150346/transformations-that-leave-linear-program-unchanged&quot;&gt;Math.SE&lt;/a&gt;. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="5564" LastEditorUserId="123" LastEditDate="2021-05-25T15:30:29.717" LastActivityDate="2021-05-26T12:46:48.493" Title="Transformations that leave the linear program unchanged" Tags="|optimization|linear-programming|simplex|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6335" PostTypeId="2" ParentId="6318" CreationDate="2021-05-25T16:51:53.343" Score="3" Body="&lt;p&gt;As you have noticed there are ready-made services available for ML but not for OR. You will have to roll your own.&lt;/p&gt;&#xA;&lt;p&gt;You can get a feel for the architecture requirements by looking at the code and REST APIs of open-source projects, e.g. &lt;a href=&quot;https://docs.graphhopper.com/#tag/Route-Optimization-API&quot; rel=&quot;nofollow noreferrer&quot;&gt;graphhopper&lt;/a&gt;, &lt;a href=&quot;https://github.com/VROOM-Project&quot; rel=&quot;nofollow noreferrer&quot;&gt;vroom&lt;/a&gt;. It takes time to understand source code of others, and software architectures even more so. But the blue-prints are out there and readily available.&lt;/p&gt;&#xA;&lt;p&gt;You will find that common components for a minimal software-as-a-service architecture include:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Data exchange format (probably JSON): separated between input/request file (input data and input parameters of your optimization problem) and output/response (solution of the optimization algorithm)&lt;/li&gt;&#xA;&lt;li&gt;Server: backend that handles incoming API requests (mostly POST or PUT request), calls your optimization algorithm, and sends the solution back to the client&lt;/li&gt;&#xA;&lt;li&gt;Client: executable programm code on the client side (downloadable programm, or for example a python package) that builds the data exchange format internally and sends it to the server. This is an optional convenience feature for REST services because the clients can also build the data exchange file themselves.&lt;/li&gt;&#xA;&lt;li&gt;Licensing mechanism: checks against a database if a request has a valid API key&lt;/li&gt;&#xA;&lt;li&gt;Database: holds a record of user data and valid licenses for the licensing mechanism&lt;/li&gt;&#xA;&lt;li&gt;Website: user registration and API key purchase option for creating database entries&lt;/li&gt;&#xA;&lt;li&gt;Documentation: can be part of the website or hosted by dedicated third party providers (there are plenty good options if your project is open-source)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Obviously licensing and database is optional if your service is free of charge and small-scale.&#xA;Also, &lt;a href=&quot;https://or.stackexchange.com/questions/1117/deploying-or-solutions-and-shipping-projects&quot;&gt;related&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="869" LastActivityDate="2021-05-25T16:51:53.343" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6336" PostTypeId="2" ParentId="6317" CreationDate="2021-05-25T18:51:02.370" Score="4" Body="&lt;p&gt;There is a rather helpful list of educational resources specific to IBM Decision Optimization products &lt;a href=&quot;https://medium.com/@AlainChabrier/decision-optimization-education-a50cada93856&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. If you scroll down a bit, you will find links to some YouTube videos about optimization modeling using OPL (and the CPLEX Studio IDE).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-05-25T18:51:02.370" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6337" PostTypeId="1" AcceptedAnswerId="6350" CreationDate="2021-05-25T21:01:37.517" Score="3" ViewCount="74" Body="&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$f : \mathbb{R}^{n \times 1} \to \mathbb{R}$&lt;/span&gt; a double differentiable function with bounded hessian, not necessarily convex, is any known polynomial algorithm, in the general case, which can assert if for a given &lt;span class=&quot;math-container&quot;&gt;$C \in \mathbb{R}^{n \times 1}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\|C\| \geq k &amp;gt; 0$&lt;/span&gt; exists &lt;span class=&quot;math-container&quot;&gt;$X \in \mathcal{B}(0_{n \times 1}, R)$&lt;/span&gt; such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ f(X) + C^T \cdot X = 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Consider &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; as some positive constants. Is any work in this direction published?&lt;/p&gt;&#xA;" OwnerUserId="3200" LastEditorUserId="491" LastEditDate="2021-05-26T13:53:53.420" LastActivityDate="2021-05-28T02:34:56.300" Title="Assert the existence of a point with the following property in P time" Tags="|feasible-points|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6338" PostTypeId="2" ParentId="6313" CreationDate="2021-05-25T23:48:01.413" Score="2" Body="&lt;p&gt;I hesitate to suggest it, since gradient methods tend to be faster than non-gradient methods, but the &lt;a href=&quot;https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nelder-Mead&lt;/a&gt; &amp;quot;simplex&amp;quot; algorithm is easy to code and might be worth a try.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-05-25T23:48:01.413" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6339" PostTypeId="2" ParentId="6334" CreationDate="2021-05-26T07:59:33.773" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://www.wikiwand.com/en/Permutation_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;Permutation matrices&lt;/a&gt; will preserve the feasible region. Since you are not modifying the objective function, the solution will also be the same.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2021-05-26T07:59:33.773" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6340" PostTypeId="1" CreationDate="2021-05-26T09:16:13.480" Score="7" ViewCount="226" Body="&lt;p&gt;The Lagrangian relaxation approach is used to generate lower (upper) bounds for minimization (maximization) problems by moving some constraints to the objective function and multiplying them by &amp;quot;Lagrangian multipliers&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;The sub-gradient algorithm tries to improve the bounds by updating the Lagrangian multipliers. There are some codes which initialize the Lagrangian multipliers by the dual value of the constraints in the optimal solution of the linear relaxation of the problem (e.g.,&#xA;&lt;a href=&quot;https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_gapmin.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_gapmin.html&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;This approach is problem-independent and seems to perform better than initialization by zero vectors. However, I could not find any textbook or paper which suggested or used this initialization. I wondered if you could help by introducing such a reference.&lt;/p&gt;&#xA;" OwnerUserId="5540" LastEditorUserId="123" LastEditDate="2021-05-26T09:43:56.740" LastActivityDate="2021-05-27T13:02:34.040" Title="Is there any academic reference which suggests/uses dual values as initialization of Lagrangian multipliers?" Tags="|integer-programming|reference-request|duality|lp-relaxation|lagrangian-relaxation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6341" PostTypeId="2" ParentId="6318" CreationDate="2021-05-26T09:39:29.563" Score="6" Body="&lt;p&gt;I have made OR models accessible through APIs on Kubernetes before. It isn't too hard, no pickling involved. In general, the steps aren't unique for an OR model API, but there might be a few things to consider (for example, an OR API might take more time than an average API to return a result).&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;First of all, you need to decide on a data exchange format. The JSON format works really well for most applications. For example, let's assume your model is going to solve a TSP problem. Your model would expect a list of points and their coordinates and maybe a few parameters, such as a time limit or the optimality gap you are willing to accept. As a result, you would expect a JSON that contains the length of the solution and possibly the order in which the points are visited. A sample input could be as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{&amp;quot;points&amp;quot;: [{&amp;quot;name&amp;quot;: &amp;quot;Geneva&amp;quot;, &amp;quot;long&amp;quot;: 46.2044, &amp;quot;lat&amp;quot;: 6.1432}, {&amp;quot;name&amp;quot;: &amp;quot;Zurich&amp;quot;, &amp;quot;long&amp;quot;: 47.3769, &amp;quot;lat&amp;quot;: 8.5417}, {&amp;quot;name&amp;quot;: &amp;quot;Lucerne&amp;quot;, &amp;quot;long&amp;quot;: 47.0502 , &amp;quot;lat&amp;quot;: 8.3093}, {&amp;quot;name&amp;quot;: &amp;quot;Bern&amp;quot;, &amp;quot;long&amp;quot;: 46.9480, &amp;quot;lat&amp;quot;: 7.4474}], &amp;quot;time_limit&amp;quot;: 30}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The expected result might be something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{&amp;quot;status&amp;quot;: &amp;quot;optimal&amp;quot;, &amp;quot;order&amp;quot;: [&amp;quot;Zurich&amp;quot;, &amp;quot;Bern&amp;quot;, &amp;quot;Geneva&amp;quot;, &amp;quot;Luzern&amp;quot;], &amp;quot;score&amp;quot;: 598}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You will now need to write a Flask app that can receive the JSON input, pass it on to your OR model and then return a result as a JSON. This app will need at least one route that you can send the data to. Here's what the basic structure could look like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from flask_api import FlaskAPI&#xA;&#xA;app = FlaskAPI(__name__)&#xA;&#xA;@app.route(&amp;quot;/optimizer/&amp;quot;, methods=['POST'])&#xA;#@require_api_token # You can implement a wrapper method to authenticate requests to the API&#xA;def optimizer():&#xA;    &amp;quot;&amp;quot;&amp;quot;&#xA;    Route to start the optimizer. Expects JSON data sent as a POST request&#xA;    &amp;quot;&amp;quot;&amp;quot;&#xA;    problem_data = request.data&#xA;    result = my_or_model(problem_data)&#xA;    if result: &#xA;        return {'status': 'optimal', 'result': result}&#xA;    return {'status': 'infeasible'}&#xA;&#xA;def my_or_model(problem_data)&#xA;    # you can access the data (e.g. time_limit) as follows: problem_data['time_limit']&#xA;    # result = run your OR specific algorithm and return a result&#xA;    return 100&#xA;&#xA;if __name__ == &amp;quot;__main__&amp;quot;:&#xA;    app.run(debug=False, port = 5000, host = &amp;quot;0.0.0.0&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that I left away authentication/ licensing, but this isn't too hard to add and you will find a lot of information about it if you search for Flask api authentication.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Theoretically, this app is ready to be deployed, however, it is better to server Flask apps through Nginx or something similar. A very lightweight server is waitress-server, which is a python module that allows you to set up a very simple server:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from waitress import serve&#xA;import myflaskapp # assuming we have defined the flask app in the file myflaskapp.py&#xA;serve(myflaskapp.app, host='0.0.0.0', port=5000)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You now have everything to run your API locally. If you run &lt;code&gt;python waitress--server.py&lt;/code&gt; you will be able to access your API at http://localhost:5000/optimizer/ and send data to it.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To get this deployed on Kubernetes, all that is left is to do is to dockerize your flask app and create a Kubernetes deployment. You will find more information on this elsewhere, but the most simple Dockerfile could look as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;FROM python:3.7&#xA;RUN mkdir /app&#xA;WORKDIR /app/&#xA;ADD . /app/&#xA;RUN apt-get update&#xA;RUN pip install flask-api&#xA;CMD [&amp;quot;python&amp;quot;, &amp;quot;/app/waitress-server.py&amp;quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After building the docker image (&lt;code&gt;docker build . flask-image&lt;/code&gt;) and pushing it to a docker registry, e.g. docker hub or whatever Azure is providing, you need to create a Kubernetes deployment file. In this example I am creating a deployment that runs 4 instances of the app, but this isn't necessary:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;apiVersion: apps/v1&#xA;kind: Deployment&#xA;metadata:&#xA;  name: flask-deployment&#xA;spec:&#xA;  selector:&#xA;    matchLabels:&#xA;      app: flask&#xA;  replicas: 4&#xA;  template:&#xA;    metadata:&#xA;      labels:&#xA;        app: flask&#xA;    spec:&#xA;      containers:&#xA;      - name: flask&#xA;        image: path to your docker image on dockerhub&#xA;        ports:&#xA;          - containerPort: 5000&#xA;        imagePullPolicy: Always&#xA;      imagePullSecrets:&#xA;      - name: regcred&#xA;---&#xA;apiVersion: v1&#xA;kind: Service&#xA;metadata:&#xA;  name: flask-service&#xA;spec:&#xA;  type: LoadBalancer&#xA;  ports:&#xA;  - port: 5000&#xA;    targetPort: 5000&#xA;    name: http&#xA;  selector:&#xA;    app: flask&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;7. That's pretty much it. You now just have to connect kubectl to Azure Kubernetes and you can create the deployment: `kubectl create -f deployment.yaml`&#xA;&#xA;For further questions, I think that the Kubernetes Stackexchange would be the right place as this is really not specific to an OR model.&#xA;&#xA;If your OR model is requiring more than just a couple of seconds you probably don't want to let the requester wait and risk the connection to time out. In this case it might be best if you can send back the result later (either to an API that is receiving the result or maybe as an email, similar to what happens when you solve a model on NEOS server.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4030" LastActivityDate="2021-05-26T09:39:29.563" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6342" PostTypeId="2" ParentId="6312" CreationDate="2021-05-26T12:42:52.867" Score="2" Body="&lt;p&gt;The value of the global solution is unique, but depending on what your feasible region looks like you can have degeneracy, i.e., multiple solutions giving the same globally optimal value, so the answer is that it depends.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-05-26T12:42:52.867" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6343" PostTypeId="2" ParentId="6334" CreationDate="2021-05-26T12:46:48.493" Score="4" Body="&lt;p&gt;I'll try to give a geometrical approach.&lt;/p&gt;&#xA;&lt;p&gt;You are considering a polyhedron&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;P = \{x \in \mathbb{R}^{n} \ | \ Ax \leq b \}.&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$b \in \mathbb{R}^{m}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{n \times m}$&lt;/span&gt;.&#xA;(I'm using &lt;span class=&quot;math-container&quot;&gt;$Ax$&lt;/span&gt; and not &lt;span class=&quot;math-container&quot;&gt;$A^{T}x$&lt;/span&gt; to match the dimensions in the OP).&lt;/p&gt;&#xA;&lt;h1&gt;The easy case: no degeneracy&lt;/h1&gt;&#xA;&lt;p&gt;Let's assume that&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;there is no primal degeneracy, i.e., no constraints are redundant w.r.t each other, and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is full-dimensional (non-empty interior)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Then, &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; has exactly &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; facets, with the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th facet being described by the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j} A_{i, j} x_{j} \leq b_{i}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, let &lt;span class=&quot;math-container&quot;&gt;$M \in \mathbb{R}^{m \times m}$&lt;/span&gt;, and consider&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Q = \{x \in \mathbb{R}^{n} \ | \ (MA)x \leq Mb \}.&#xA;$$&lt;/span&gt;&#xA;Geometrically, 1. asks under which condition on &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; we have &lt;span class=&quot;math-container&quot;&gt;$Q = P$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$Q = P$&lt;/span&gt;, then each facet of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is a facet of &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;, and vice-versa.&#xA;Thus, for every &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, there exists &lt;span class=&quot;math-container&quot;&gt;$\sigma(i)$&lt;/span&gt; such that the hyperplanes&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j} A_{i, j} x_{j} \leq b_{i}&#xA;$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j} (MA)_{\sigma(i), j} x_{j} \leq (M b)_{\sigma(i)}&#xA;$$&lt;/span&gt;&#xA;are (geometrically) identical.&lt;/p&gt;&#xA;&lt;p&gt;Since the polyhedra are non-degenerate, the &lt;span class=&quot;math-container&quot;&gt;$i \leftrightarrow \sigma(i)$&lt;/span&gt; mapping is one-to-one, i.e., &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; is permutation, which gives you permutation matrices.&#xA;Assume for simplicity that &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; is the identity.&#xA;From the identity between each pair of hyperplanes, you then get that &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a diagonal matrix with positive coefficients.&lt;/p&gt;&#xA;&lt;p&gt;To conclude, we get &lt;span class=&quot;math-container&quot;&gt;$M = D \times S$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is diagonal with positive coefficients and &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is a permutation matrix.&#xA;Note that this result only holds under the above two assumptions.&lt;/p&gt;&#xA;&lt;h1&gt;The hard case: degeneracy&lt;/h1&gt;&#xA;&lt;p&gt;As it's already been pointed out, depending on the data, there may be arbitrarily many valid &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. Essentially, any redundant constraints can be aggregated in any way you want, without changing anything to the feasible region.&lt;/p&gt;&#xA;&lt;p&gt;If you can isolate a set of non-redundant constraints, then you might apply the above result, combined with some (positive?) combination of the redundant constraints.&#xA;Obviously, there may exist multiple sets of non-redundant constraints, and you will likely see a combinatorial explosion there.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2021-05-26T12:46:48.493" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6344" PostTypeId="1" AcceptedAnswerId="6346" CreationDate="2021-05-26T14:59:28.823" Score="1" ViewCount="880" Body="&lt;p&gt;I know how to assign values from a single dictionary to a 1-dimensional parameter in Pyomo. For that I use the following code&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;import pandas as pd&#xA;&#xA;&#xA;&#xA;#Define the model&#xA;model = pyo.ConcreteModel()&#xA;&#xA;#Read the dataframe from file for one building&#xA;df_buildingData = pd.read_csv(&amp;quot;C:/Users/Data/H9_HH&amp;quot; + str(1) + &amp;quot;_Day_&amp;quot; + str(4) +&amp;quot;.csv&amp;quot;, sep =&amp;quot;;&amp;quot;)&#xA;&#xA;#Define the sets&#xA;model.set_timeslots = pyo.RangeSet(1, 288)&#xA;&#xA;&#xA;#Create the dictionaries for the set&#xA;dictionaryHeatDemand_In_W= df_buildingData.set_index('Timeslot')['Q_htg'].to_dict()&#xA;&#xA;#Assign the values from a single dictionary to a 1-dimensional parameter&#xA;&#xA;model.param_heatDemand_In_W = pyo.Param(model.set_timeslots, initialize=dictionaryHeatDemand_In_W)&#xA;model.param_heatDemand_In_W.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and I get the following output&#xA;&lt;a href=&quot;https://i.stack.imgur.com/NjBWo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NjBWo.png&quot; alt=&quot;Output_1_dimensional_Parameter&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So far so good. However, now I would like to have a 2-dimensional parameter that is based on the set &amp;quot;model.set_timeslots&amp;quot; and the parameter &amp;quot;model.set_buildings&amp;quot;. To do that I used the same code but I changed it such that I always work with lists (one entry for every building). Here is the code for the 2-dimensional parameter:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;import pandas as pd&#xA;&#xA;&#xA;&#xA;#Define the model&#xA;model = pyo.ConcreteModel()&#xA;&#xA;#Reading of the data&#xA;list_df_buildingData_mHP_EV= [pd.read_csv(&amp;quot;C:/Users/Data/H9_HH&amp;quot; + str(index) + &amp;quot;_Day_&amp;quot; + str(4) +&amp;quot;.csv&amp;quot;, sep =&amp;quot;;&amp;quot;) for index in range (1,  4)]&#xA;&#xA;#Define the sets&#xA;model.set_timeslots = pyo.RangeSet(1, 288)&#xA;model.set_buildings = pyo.RangeSet(1, 3)&#xA;&#xA;&#xA;#Create the dictionaries for the set&#xA;list_dictionaryHeatDemand_In_W_mHP_EV= [list_df_buildingData_mHP_EV[index].set_index('Timeslot')['Q_htg'].to_dict() for index in range (0,  3)] &#xA;&#xA;#Define the parameters of the model in pyomo&#xA;model.param_heatDemand_In_W = pyo.Param(model.set_timeslots,model.set_buildings, initialize=list_dictionaryHeatDemand_In_W_mHP_EV)&#xA;model.param_heatDemand_In_W.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, the outcome when using &lt;code&gt;model.param_heatDemand_In_W.pprint()&lt;/code&gt; does not like the one I would like to have. Here you see a screenshot&lt;a href=&quot;https://i.stack.imgur.com/Nmv8q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Nmv8q.png&quot; alt=&quot;Output_Multiple_Dictionaries&quot; /&gt;&lt;/a&gt;. There is always a key values at the beginning starting from (1,1) to (288,3). For each of those key values there are 288 entries (288 is the number of set_timeslots). I would like to have a 2-dimensional parameter param_heatDemand_In_W (building, timeslot). So the parameter should have for each of the 3 buildings, 288 timeslots and for each of those timeslots there should be 1 value for the heatDemand.&lt;/p&gt;&#xA;&lt;p&gt;Any idea how I can do that? I'd appreciate every comment.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastActivityDate="2021-05-26T16:25:49.443" Title="How to assign values from a list of dictionaries to a 2-dimensional parameter in Pyomo" Tags="|python|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6345" PostTypeId="1" CreationDate="2021-05-26T15:26:02.457" Score="1" ViewCount="332" Body="&lt;p&gt;I'm trying to solve a TSP in different ways. I already did it with the formulation of Dantzig, Fulkerson and Johnson und now I want to do use the Miller, Tucker, Zemlin constraint. &lt;span class=&quot;math-container&quot;&gt;$$u_i-u_j+nx_{ij}\le n-1\quad\forall i,j\in N-\{1\},i\ne j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm a little bit stuck because I don't know how to implement it and I do not find anything useful on the internet. Does somebody know how to do it?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;import matplotlib.pyplot as plt&#xA;from docplex.mp.model import Model&#xA;import docplex.mp.solution as Solution&#xA;&#xA;# for sequentiel solving &#xA;&#xA;from itertools import product&#xA;&#xA;cost = np.loadtxt('matrix_time-independent_2017to2019_delete.txt')&#xA;&#xA;cities=[i for i in range(len(cost))]&#xA;#print(cities)&#xA;arcs =[(i,j) for i in cities for j in cities if i!=j]&#xA;&#xA;&#xA;distance={(i, j): cost[i,j] for i,j in arcs}&#xA;#print(distance)&#xA;&#xA;# CPLEX model&#xA;mdl=Model('TSP')&#xA;&#xA;# decision variables&#xA;&#xA;x=mdl.binary_var_dict(arcs,name='x')&#xA;d=mdl.continuous_var_dict(cities,name='d')&#xA;&#xA;mdl.minimize(mdl.sum(distance[i]*x[i] for i in arcs))&#xA;&#xA;# Constraints&#xA;for c in cities:&#xA;    mdl.add_constraint(mdl.sum(x[(i,j)] for i,j in arcs if i==c)==1, &#xA;                       ctname='out_%d'%c)&#xA;    &#xA;for c in cities:&#xA;    mdl.add_constraint(mdl.sum(x[(i,j)] for i,j in arcs if j==c)==1, &#xA;                       ctname='in_%d'%c)&#xA;&#xA;    &#xA;# conventional way to eliminate subtours (Dantzig, Fulkerson and Johnson)&#xA;for i,j in arcs:&#xA;    if j!=0:&#xA;        mdl.add_indicator(x[(i,j)],d[i]+1==d[j], &#xA;                          name='order_(%d,_%d)'%(i, j))&#xA;        &#xA;# sequential formulation (Miller, Tucker, Zemlin)&#xA;for (i, j) in arcs:&#xA;    if i != j:&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;???&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;print(mdl.export_to_string())&#xA;&#xA;# possible to add constraint&#xA;&#xA;mdl.parameters.timelimit=120&#xA;mdl.parameters.mip.strategy.branch=1&#xA;mdl.parameters.mip.tolerances.mipgap=0.15&#xA;&#xA;solution = mdl.solve(log_output=True)&#xA;&#xA;mdl.get_solve_status()&#xA;&#xA;solution.display()&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5571" LastEditorUserId="123" LastEditDate="2021-05-26T16:01:59.687" LastActivityDate="2021-05-26T16:01:59.687" Title="Implement sequential formulation in TSP (Miller, Tucker, Zemlin)" Tags="|python|cplex|traveling-salesman|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6346" PostTypeId="2" ParentId="6344" CreationDate="2021-05-26T16:25:49.443" Score="2" Body="&lt;p&gt;You can put your data in a dataframe after reading it from a csv file&#xA;then define your model as abstract&#xA;then you can do two things&#xA;1- initializing your parameter as shown in the figure&lt;br /&gt;&#xA;or&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def init_w(model,i,j):&#xA;    return df.iloc[i-1,j-1]&#xA;model.W =Param(model.i, model.j, mutable=True, initialize=init_w) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/r884C.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/r884C.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;2- filling the instance properly&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2021-05-26T16:25:49.443" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6347" PostTypeId="1" AcceptedAnswerId="6353" CreationDate="2021-05-27T12:23:19.847" Score="4" ViewCount="130" Body="&lt;p&gt;Suppose you have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; time series data where the times are in arithmetic series with difference &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;, and suppose further that some of the data are missing at random (say, &lt;span class=&quot;math-container&quot;&gt;$p=.30$&lt;/span&gt;). Now suppose you want to find an approximately evenly-spaced subsequence of length &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; of your data, with common difference approximately &lt;span class=&quot;math-container&quot;&gt;$k &amp;gt; d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; not necessarily a multiple of &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I feel like I ought to be able to formulate this as an integer program - specifically, a boolean program where the variable &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is a vector of size &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$a_i = 1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; is in the subsequence, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise, and &lt;span class=&quot;math-container&quot;&gt;$a^T \mathbf{1} = l$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The information that the original sequence is an arithmetic series with missing data could be discarded, since the problem it seems ought to have an approximate solution for an arbitrary sequence.&lt;/p&gt;&#xA;&lt;p&gt;The solution may also depend on how you enforce the objective that the subsequence is approximately evenly spaced. Does anyone know if this problem has been studied before?&lt;/p&gt;&#xA;" OwnerUserId="5593" LastEditorUserId="36" LastEditDate="2021-05-27T12:48:57.917" LastActivityDate="2021-05-28T13:47:30.260" Title="Approximately evenly-spaced subsequence" Tags="|mixed-integer-programming|time-series|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6348" PostTypeId="2" ParentId="6340" CreationDate="2021-05-27T13:02:34.040" Score="1" Body="&lt;p&gt;Short answer: Here is a paper that uses the dual values&lt;/p&gt;&#xA;&lt;p&gt;Akbari, V., &amp;amp; Salman, F. S. (2017). Multi-vehicle prize collecting arc routing for connectivity problem. Computers &amp;amp; Operations Research, 82, 52-68. &lt;a href=&quot;https://doi.org/10.1016/j.cor.2017.01.007&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.cor.2017.01.007&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Some additional points:&#xA;The sub-gradient method is a heuristic approach to solve the Lagrangian Dual problem. It gives you good but not necessarily optimal set of multipliers, after reaching an arbitrary iteration limit. Depending on the complexity of the sub-problems the method is also expected to be very quick.  In literature, the natural choice for the initial multiplier values has been 0, perhaps because over a moderate number of iterations, the choice does not significantly affect the computational time and bound quality in most cases. I have experienced the same while implementing Lagrangian relaxation to solve the Team Orienteering Problem.&lt;/p&gt;&#xA;&lt;p&gt;However, it is definitely prudent to experiment with different set of initial values and go for the one which gives best result for the particular problem. An example of a different starting point for the Generalized Assignment Problem can be found here:&lt;/p&gt;&#xA;&lt;p&gt;Fisher, M. L. (2004). The Lagrangian relaxation method for solving integer programming problems. Management science, 50(12_supplement), 1861-1871. &lt;a href=&quot;https://doi.org/10.1287/mnsc.1040.0263&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/mnsc.1040.0263&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3640" LastActivityDate="2021-05-27T13:02:34.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6349" PostTypeId="1" AcceptedAnswerId="6361" CreationDate="2021-05-27T15:34:35.890" Score="8" ViewCount="202" Body="&lt;p&gt;What kind of background in algorithms and complexity theory is needed to fully understand the computational aspects of an OR paper. To be specific, I am not always sure when a paper says 'XYZ problem is &lt;span class=&quot;math-container&quot;&gt;$\mathbf{NP}$&lt;/span&gt; hard, or &lt;span class=&quot;math-container&quot;&gt;$\mathbf{NP}$&lt;/span&gt; complete. etc.' or when the paper says 'XYZ algorithm performs in &lt;span class=&quot;math-container&quot;&gt;$\mathbf{O}$&lt;/span&gt;(something) or &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\Theta}$&lt;/span&gt;(something) (especially in scheduling literature)'. CS/Math forums typically recommend &lt;em&gt;Introduction to Algorithms&lt;/em&gt; by Cormen et al. (CLRS) for the same, but CLRS is a pretty dense book, and I am not sure whether should I go through the complete book, or should I pick and choose topics.&lt;/p&gt;&#xA;&lt;p&gt;Are there any textbooks/references that I can go through (possibly without tears), to get an idea of the computational aspects that are typical to the domain of OR?&lt;/p&gt;&#xA;" OwnerUserId="2686" LastEditorUserId="123" LastEditDate="2021-05-27T16:15:11.700" LastActivityDate="2022-03-10T15:11:53.707" Title="Reference for algorithms and complexity" Tags="|reference-request|computational-complexity|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6350" PostTypeId="2" ParentId="6337" CreationDate="2021-05-28T02:34:56.300" Score="4" Body="&lt;p&gt;I doubt you can do so in polynomial time without any additional condition.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; be an arbitrary polynomial function, and let &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; be defined by &lt;span class=&quot;math-container&quot;&gt;$f(X) = g(X) - C^{T}X$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$B(0, R)$&lt;/span&gt;, and an appropriate extension so that it's twice differentiable with bounded Hessian over &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^{n}$&lt;/span&gt;.&#xA;Then, &lt;span class=&quot;math-container&quot;&gt;$f(X) + C^{T}X = 0$&lt;/span&gt; reduces to &lt;span class=&quot;math-container&quot;&gt;$g(X) = 0$&lt;/span&gt;, i.e., your setting is equivalent to finding a root of &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$B(0, R)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(I believe that deciding whether an arbitrary polynomial has a root of at most norm &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; is already NP-hard, but I'm not 100% sure).&lt;/p&gt;&#xA;&lt;p&gt;Now, since 3SAT can be written as finding a root of a polynomial (make a polynomial for each clause and multiply all of them), finding a root of an arbitrary polynomial is NP-hard.&lt;/p&gt;&#xA;&lt;p&gt;Thus, unless P = NP, there is little chance that you can solve your problem for general &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; in polynomial time. (note that the value of &lt;span class=&quot;math-container&quot;&gt;$R, k$&lt;/span&gt; are insignificant, since we can always re-scale everything).&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2021-05-28T02:34:56.300" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6351" PostTypeId="2" ParentId="1304" CreationDate="2021-05-28T08:20:19.083" Score="3" Body="&lt;p&gt;Let me also mention the &lt;a href=&quot;https://medium.com/ibm-data-ai/4-figures-3-numbers-and-some-thoughts-about-ibm-cplex-and-ibm-research-ponder-this-7ecee7260c5b&quot; rel=&quot;nofollow noreferrer&quot;&gt;IBM Research Ponder This challenge&lt;/a&gt;.&#xA;Not always OR oriented but I have solved 50+ of those with an OR Tool : OPL CPLEX.&lt;/p&gt;&#xA;&lt;p&gt;The Decision Management Community also offers some &lt;a href=&quot;https://dmcommunity.org/challenge/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR challenges&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-05-28T08:20:19.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6352" PostTypeId="2" ParentId="5119" CreationDate="2021-05-28T10:25:55.820" Score="1" Body="&lt;p&gt;This &lt;a href=&quot;https://www.euro-online.org/websites/verolog/webinar/verolog-webinar-videos/&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Vigo, D. (2021): Integrating Machine Learning into state-of-the-art Vehicle Routing Heuristics, VeRoLog webinar series, April 29, 2021.&quot;&gt;talk&lt;/a&gt; discusses several approaches to integrate machine learning in local search algorithms by identifying&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;good solutions&lt;/li&gt;&#xA;&lt;li&gt;bad solutions&lt;/li&gt;&#xA;&lt;li&gt;promising neighborhoods&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;through offline learning of problem instance and solution features. This &lt;a href=&quot;https://www.chaitjo.com/post/deep-learning-for-routing-problems/&quot; rel=&quot;nofollow noreferrer&quot;&gt;post&lt;/a&gt; is conceptually similar but more focused on the machine learning part. It discusses several recent approaches, most if which use graph neural networks.&lt;/p&gt;&#xA;&lt;p&gt;This &lt;a href=&quot;https://doi.org/10.1016/j.patcog.2021.107957&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Arnold, F., Santana, Í., Sörensen, K., &amp;amp; Vidal, T. (2021). PILS: Exploring high-order neighborhoods by pattern mining and injection. Pattern Recognition, 107957.&quot;&gt;paper&lt;/a&gt; looks at the frequency of good (partial) paths of locally optimal solutions during runtime. Good partial solutions are injected into the search allowing to explore promising higher-order moves that would otherwise be too computationally expensive to explore.&lt;/p&gt;&#xA;" OwnerUserId="869" LastEditorUserId="869" LastEditDate="2022-03-18T07:43:59.547" LastActivityDate="2022-03-18T07:43:59.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6353" PostTypeId="2" ParentId="6347" CreationDate="2021-05-28T13:47:30.260" Score="4" Body="&lt;p&gt;I have never encountered a problem like this in literature, but here is one possible way of formulating the problem as a MIP. Notation:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;: length of the number series&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;: desired length of the subsequence&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$q_i$&lt;/span&gt;: number at position &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in the original number series (&lt;span class=&quot;math-container&quot;&gt;$i \in I = \{1,\ldots,n\}$&lt;/span&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$r_j$&lt;/span&gt;: number at position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in the subsequence (&lt;span class=&quot;math-container&quot;&gt;$j \in J = \{1,\ldots,l\}$&lt;/span&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;We will need the following binary variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j} \in \{0,1\}$&lt;/span&gt;: 1 if and only if &lt;span class=&quot;math-container&quot;&gt;$q_i = r_j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Using this notation, we can express that a number in the sequence can correspond to at most one number in the subsequence:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in J}(x_{i,j}) \leq 1 \: \: \forall i \in I$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Furthermore, each position in the subsequence needs to correspond to exactly one number in the original sequence:&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I}(x_{i,j}) = 1 \: \: \forall j \in J$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;We also want that the numbers are in the correct sequence, i.e. &lt;span class=&quot;math-container&quot;&gt;$r_j \le r_{j+1}$&lt;/span&gt;. Using our &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables, we can express that quite easily. For all &lt;span class=&quot;math-container&quot;&gt;$j \in \{1,\ldots,l-1\}$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I}(x_{i,j} \cdot q_i) &amp;lt;= \sum_{i \in I}(x_{i,j+1} \cdot q_i)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Now, this defines the problem, but the objective is still missing and depends on how you define &amp;quot;approximately evenly-spaced&amp;quot;. A simple interpretation would be to minimize the difference between the two consecutive numbers with the largest and the two consecutive numbers with the smallest gap. For this purpose we could introduce a continuous variable &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; which would be greater or equal to the gap between the numbers that are the furthest apart and a second continuous variable &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; which would be smaller or equal to the difference between the two numbers that are closest. Using these two variables we can add the following two constraints for every &lt;span class=&quot;math-container&quot;&gt;$j \in \{1,\ldots,l-1\}$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I}(x_{i,j+1}\cdot q_i) - \sum_{i \in I}(x_{i,j}\cdot q_i) \leq y_1)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I}(x_{i,j+1}\cdot q_i) - \sum_{i \in I}(x_{i,j}\cdot q_i) \geq y_2)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;We could then minimize &lt;span class=&quot;math-container&quot;&gt;$y_1 - y_2$&lt;/span&gt;. If this is 0, we have an evenly spaced sequence.&lt;/p&gt;&#xA;&lt;p&gt;We can visually verify whether this is giving a good result:&lt;/p&gt;&#xA;&lt;p&gt;Example 1:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xpXuZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xpXuZ.png&quot; alt=&quot;Example 1&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Example 2:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tUY1X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tUY1X.png&quot; alt=&quot;Example 2&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first example doesn't look great, the second one however is perfect, as the red markers (subsequence) are evenly spaced.&lt;/p&gt;&#xA;&lt;p&gt;The problem with the first sequence is that it is indeed not possible that &lt;span class=&quot;math-container&quot;&gt;$y_1 - y_2$&lt;/span&gt; is lower than 20, but visually, this example isn't pleasing, since the highest gap is twice as big as the lowest gap.&lt;/p&gt;&#xA;&lt;p&gt;A visually much more pleasant result is achieved if we are maximizing &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; instead. Just like before, the difference between the largest gap and the lowest gap is 20, however, the largest gap is 140 and lowest is 120, which means that these differences appear almost identical.&lt;/p&gt;&#xA;&lt;p&gt;Example 1a (maximizing &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt;):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/cXD5d.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cXD5d.png&quot; alt=&quot;Example 1a&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It seems like what you really want to minimize is the relative difference between &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; or the variance of the differences. However, there is a problem with that since MIP technology is limited to linear functions. However, I think maximizing &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; (or possibly a linear combination of &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;), e.g. &lt;span class=&quot;math-container&quot;&gt;$y_2-0.01y_1$&lt;/span&gt; will do something very similar.&lt;/p&gt;&#xA;&lt;p&gt;Whether this approach is useful in practice depends entirely on your actual numbers (size of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, size of &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; in comparison to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;). Alternatively, a heuristic approach, or maybe constraint programming (with a very similar formulation as this MIP model), which would allow you to use non-linear objectives, should also be good.&lt;/p&gt;&#xA;" OwnerUserId="4030" LastActivityDate="2021-05-28T13:47:30.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6354" PostTypeId="1" AcceptedAnswerId="6357" CreationDate="2021-05-28T22:09:47.740" Score="1" ViewCount="253" Body="&lt;p&gt;I have a model as below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Qxyu2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qxyu2.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have constructed the matrix of its constraints as below. I need to show the total unimodularity of its constraints matrix. However, the determinant of the below submatrix (specified by red line) is not equal to -1, 0, or 1. This means that the matrix of constraints is not totally unimodular. Can you please let me know whether I am making any mistakes?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AkyTb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AkyTb.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="500" LastEditDate="2021-05-28T22:43:14.930" LastActivityDate="2021-05-29T07:16:02.507" Title="Show the total unimodularity of constraints matrix" Tags="|constraint|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6355" PostTypeId="2" ParentId="6354" CreationDate="2021-05-28T22:41:57.197" Score="5" Body="&lt;p&gt;It is not totally unimodular.  A necessary condition is that even the &lt;span class=&quot;math-container&quot;&gt;$1\times 1$&lt;/span&gt; submatrices have determinant in &lt;span class=&quot;math-container&quot;&gt;$\{-1,0,1\}$&lt;/span&gt;.  That is, individual entries must be in &lt;span class=&quot;math-container&quot;&gt;$\{-1,0,1\}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-05-28T22:41:57.197" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6356" PostTypeId="2" ParentId="6214" CreationDate="2021-05-28T23:19:01.203" Score="1" Body="&lt;p&gt;The classic Reliability assessment assumes that a device either works or not. Additionally, you can assume some derated states. For example, consider a Power plant with &lt;span class=&quot;math-container&quot;&gt;$P_{max} = 100MW$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can model it as &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt;. You can model it as &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt;. Usually, it is for conventional power plants.&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="199" LastEditDate="2021-05-30T17:53:33.467" LastActivityDate="2021-05-30T17:53:33.467" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6357" PostTypeId="2" ParentId="6354" CreationDate="2021-05-29T07:01:17.157" Score="2" Body="&lt;p&gt;Your matrix seems to represent the given model. If you multiply any of the variables with &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; will definitely be part of the matrix. Like RobPratt pointed out, that alone is sufficient to say that the matrix isn't totally unimodular.&lt;/p&gt;&#xA;&lt;p&gt;However, assuming that &lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt; are continuous variables and &lt;span class=&quot;math-container&quot;&gt;$g_j$&lt;/span&gt; are constants (confirm please), I believe it is possible to set &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to 1 in this case. &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; has to be a sufficiently large constant relative to the expected size of your &lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_j$&lt;/span&gt;. Assuming &lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_j$&lt;/span&gt; would be quantities in kg, you could always change the constants such that &lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_j$&lt;/span&gt; will be in tonnes or even larger units of weight.&lt;/p&gt;&#xA;&lt;p&gt;With &lt;span class=&quot;math-container&quot;&gt;$M = 1$&lt;/span&gt;, you should be able to check whether the resulting matrix is unimodular or not.&lt;/p&gt;&#xA;" OwnerUserId="4030" LastEditorUserId="4030" LastEditDate="2021-05-29T07:16:02.507" LastActivityDate="2021-05-29T07:16:02.507" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6358" PostTypeId="1" CreationDate="2021-05-29T18:41:11.367" Score="1" ViewCount="428" Body="&lt;ol&gt;&#xA;&lt;li&gt;Assume we have 100% feasible solution for the model with decision variable &lt;code&gt;a[i]&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Then we are changing the objective function on something similar to &lt;code&gt;minimize sum(i in…)maxl(0, a[i]-100)&lt;/code&gt; and trying to use our feasible solution as a start solution.&lt;/li&gt;&#xA;&lt;li&gt;Sometimes we are lucky but sometimes we have a message: &amp;quot;No solution found from 1 MIP starts. Retaining values of one MIP start for possible repair&amp;quot; – in my case it means that I’ll nether get any solution because of model complexity. I suppose &lt;code&gt;maxl&lt;/code&gt; makes some magic here.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Is there any way to tell CPLEX to use my start solution on every start with &lt;code&gt;maxl&lt;/code&gt; in the objective?&lt;/p&gt;&#xA;&lt;p&gt;P.S.:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;After analizing LP file I tried to change the model by adding &lt;code&gt;b[i]&lt;/code&gt; variable (&lt;code&gt;b[i]==a[i]-100&lt;/code&gt;) with corresponding changes in objective (minimize &lt;code&gt;sum(i in…)maxl(0, b[i])&lt;/code&gt;) and providing start values for it together with starting values for &lt;code&gt;a[i]&lt;/code&gt; – no effect except increasing solving time for succeed warmstarts.&lt;/li&gt;&#xA;&lt;li&gt;I'm using OPL libraries for c#. Fixing all variables from the previous solution by GetStart and SetStart methods gives nothing. I had to use Attach method for some &amp;quot;float&amp;quot; variables to make a model accept the start solution. The list of variables for a successful warmstart was formed after experiments.&lt;/li&gt;&#xA;&lt;li&gt;I have an extra model to avoid numerical instability which fixes the precision of all numeric variables to 10^-3 and provides a feasible solution.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5561" LastEditorUserId="36" LastEditDate="2021-06-13T19:39:08.007" LastActivityDate="2021-06-13T19:39:08.007" Title="CPLEX ignores a feasible solution given as start one" Tags="|mixed-integer-programming|cplex|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6359" PostTypeId="1" AcceptedAnswerId="6362" CreationDate="2021-05-29T19:01:15.753" Score="6" ViewCount="163" Body="&lt;p&gt;Take the following optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_x&amp;amp;\quad f(x)\\\text{s.t.}&amp;amp;\quad g(x)\le0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; nonlinear functions. Suppose I want to relax the constraint by replacing it with a penalty term proportional to the extent of the violation.&lt;/p&gt;&#xA;&lt;p&gt;A straigtforward way to do this would be&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_x f(x) + c\cdot\max\{0,g(x)\}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In practice, however, I see it often implemented as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_x&amp;amp;\quad f(x) + c\cdot\xi\\\text{s.t.}&amp;amp;\quad g(x)\leq \xi,\\&amp;amp;\quad&#xA;0\leq \xi.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have heard that this is to prevent the non-differentiability in the objective function, but the non-differentiability isn't really gone with this formulation, is it? Is there something fundamentally different between the two formulations that makes general nonlinear solvers better able to cope with the latter one?&lt;/p&gt;&#xA;" OwnerUserId="4757" LastEditorUserId="123" LastEditDate="2021-05-30T08:28:08.997" LastActivityDate="2021-05-30T08:28:08.997" Title="Two equivalent soft constraint implementations" Tags="|optimization|constraint|nonlinear-programming|relaxation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6361" PostTypeId="2" ParentId="6349" CreationDate="2021-05-29T19:53:25.040" Score="5" Body="&lt;p&gt;So as I mentioned in the comment &lt;a href=&quot;/https://edutechlearners.com/download/Introduction_to_algorithms-3rd%20Edition.pdf&quot;&gt;CLRS&lt;/a&gt; is a really wonderful reference and I enjoyed learning from it in my undergraduate algorithms class. But yes, it's a big book so you probably want to pick and choose some useful topics. Here are my suggestions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ch. 2 is a fine intro to the subject, maybe skim it&lt;/li&gt;&#xA;&lt;li&gt;Ch. 3 is a &lt;strong&gt;must&lt;/strong&gt; and will teach you some of the &lt;strong&gt;asymptotic notation&lt;/strong&gt; you mentioned.&lt;/li&gt;&#xA;&lt;li&gt;Ch. 5 is good too, especially if you need to review probabilistic techniques (Ch. 9 too)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;At this point, I think you probably have a handle on most of the basics so you can start to pick and choose.&lt;/p&gt;&#xA;&lt;p&gt;For some practice of these basics, various topics on sorting in Section II may be useful.&lt;/p&gt;&#xA;&lt;p&gt;If you are more on the computational side of OR you may need to refresh/learn data structures then Section III on data structures is very good and important to know.&lt;/p&gt;&#xA;&lt;p&gt;I think Section IV Ch. 15 and 16 are useful for OR especially the sections on greedy algorithms. Similarly, I think Section VI on graph algorithms is also quite good and in particular Ch. 23 on spanning trees, Ch.24 and 25 on shortest paths, and Ch. 26 on flow problems. I think these topics are probably the most applicable to a lot of OR.&lt;/p&gt;&#xA;&lt;p&gt;The last few chapters are really up to you. There are chapters on matrix operations, linear programming, approximation theory, etc. but you probably know these already and there are better and more comprehensive places to find this kind of material. You did mention &lt;strong&gt;NP-Completeness&lt;/strong&gt; problems so Ch. 34 will probably be quite useful there.&lt;/p&gt;&#xA;&lt;p&gt;If you really want to go deep on complexity theory &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0521424267&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;this book&lt;/a&gt; is probably more advanced but also probably beyond what most OR researchers need (although it's a big field so who knows!).&lt;/p&gt;&#xA;" OwnerUserId="4978" LastEditorUserId="491" LastEditDate="2022-03-10T13:45:32.923" LastActivityDate="2022-03-10T13:45:32.923" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6362" PostTypeId="2" ParentId="6359" CreationDate="2021-05-29T21:43:32.760" Score="9" Body="&lt;p&gt;Using the max operator, your objective function has directional derivatives but is not smoothly differentiable. For instance, if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is scalar and &lt;span class=&quot;math-container&quot;&gt;$g(x) = x-2$&lt;/span&gt;, then at &lt;span class=&quot;math-container&quot;&gt;$x=2$&lt;/span&gt; the max term has directional derivative 0 in the direction of decreasing &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; in the direction of increasing &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. For a gradient-based algorithm, this makes the value of the gradient ambiguous. Some algorithms may tolerate the ambiguity better than others.&lt;/p&gt;&#xA;&lt;p&gt;With the second formulation, the objective is differentiable and the kink in the derivative has been replaced by a constraint. Since the solver already knows how to deal with inequality constraints, you get differentiability in the objective without making the problem more difficult technically (just slightly bigger, to the tune of one variable and one constraint).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-05-29T21:43:32.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6363" PostTypeId="1" AcceptedAnswerId="6417" CreationDate="2021-05-30T10:31:34.323" Score="2" ViewCount="106" Body="&lt;p&gt;I'm trying to estimate the effect of personality on exploration behavior in multi armed bandit problems. My current approach is to identify the choice strategy that most accurately fits the behavior shown by the participants and then relate the relevant exploration parameter to the personality metric I'm using. However, I can't come up with a solution to how the first part (selecting the most fitting choice strategy) could actually be achieved in practice and Google just brings up ML related information where the agent is an algorithm and not a human being. Is there a way in which something like this is typically done?&lt;/p&gt;&#xA;" OwnerUserId="5602" LastActivityDate="2021-06-09T19:27:21.113" Title="Determining which choice strategy (epsilon-greedy, softmax, UCB, etc.) fits participant behavior in a multi armed bandit study" Tags="|reinforcement-learning|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6364" PostTypeId="1" CreationDate="2021-05-30T15:12:12.933" Score="2" ViewCount="275" Body="&lt;p&gt;I am trying to solve a large-scale MIP problem. I have the following errors, I know, it's about the data, but I can't change the data. Is there a method to deal with it?&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;CPLEX Warning  1036: Decimal part of coefficient for variable 'x_9_18_0' in objective looks like 67/85 in single precision.&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;CPLEX Warning  1036: Decimal part of coefficient for variable 'x_9_18_2' in objective looks like 67/85 in single precision.&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;CPLEX Warning  1036: Too many warnings of this type have been detected.  All further warnings of this type will be ignored.&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;CPLEX Warning  1057: the objective vector has almost equal coefficients for variable 'x_55_56_1' and variable 'x_42_43_1'.&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5537" LastEditorUserId="199" LastEditDate="2021-05-30T17:41:38.777" LastActivityDate="2021-06-13T19:11:41.083" Title="Docplex, CPLEX Warning 1036 :" Tags="|optimization|mixed-integer-programming|docplex|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6365" PostTypeId="1" CreationDate="2021-05-30T16:48:08.523" Score="3" ViewCount="144" Body="&lt;p&gt;I've seen the claim (in the title) several places, but can't quite understand why it's true.&lt;/p&gt;&#xA;&lt;p&gt;From what I understand so far, the revised simplex method solves an LP in standard computational form, &lt;span class=&quot;math-container&quot;&gt;$$\min c^Tx: Ax = b, x \geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which has a corresponding dual problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max b^Ty : A^Ty \leq c$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But this isn't even an LP in standard computational form, so how do aspects of the simplex algorithm carry over? If we were to transform this dual problem into standard computational form, since &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is unconstrained we'd end up with &lt;span class=&quot;math-container&quot;&gt;$y^+, y^-$&lt;/span&gt; and a bunch of slack variables, so it's quite hard to imagine how to derive the correct pivoting rules in this scenario.&lt;/p&gt;&#xA;&lt;p&gt;Is there something I'm not getting, or is the dual revised simplex method derived in a different way?&lt;/p&gt;&#xA;" OwnerUserId="5606" LastActivityDate="2021-05-30T16:48:08.523" Title="How is the dual revised simplex method equivalent to running the RSM on the dual problem?" Tags="|linear-programming|dual-simplex|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6366" PostTypeId="1" CreationDate="2021-05-31T08:40:28.420" Score="5" ViewCount="248" Body="&lt;p&gt;I want to do a shortest path algorithm. My direct and not acyclic graph contains only positive numbers. I have to do the scan for all pairs of nodes in complete depth in python. My graph is big (100x100x100 (with time-steps) and I have to do it in a time efficient way. I tried to do it with Dijkstra but it was far too slow. I also tried a Floyd-Warshall algorithm but I think that this algorithm doesn't scan the graph in complete depth (?). I would be thankful for other algorithms and additional advices.&lt;/p&gt;&#xA;" OwnerUserId="5571" LastEditorUserId="5571" LastEditDate="2021-05-31T16:25:16.400" LastActivityDate="2021-06-08T17:24:03.783" Title="Quickest shortest path algorithm" Tags="|algorithms|graphs|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="6367" PostTypeId="1" CreationDate="2021-05-31T09:38:18.150" Score="7" ViewCount="150" Body="&lt;p&gt;The bottleneck TSP tries to find a Hamiltonian circle which minimizes the longest edge. Is there any real world application for this for example in transportation?&lt;/p&gt;&#xA;" OwnerUserId="5571" LastEditorUserId="123" LastEditDate="2021-05-31T11:26:06.170" LastActivityDate="2021-06-01T21:18:25.237" Title="Is there a real life application for the Bottleneck travelling salesman problem?" Tags="|applications|traveling-salesman|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6368" PostTypeId="2" ParentId="6364" CreationDate="2021-05-31T18:23:24.970" Score="1" Body="&lt;p&gt;If you really want to ignore them then you can often set the warning output to null (or similar) &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=cm-warning-method-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/20.1.0?topic=cm-warning-method-1&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;From where/how are you calling cplex?&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2021-05-31T18:23:24.970" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6370" PostTypeId="1" AcceptedAnswerId="6374" CreationDate="2021-06-01T10:20:24.743" Score="7" ViewCount="344" Body="&lt;p&gt;I have a general question about the effect of 'unused' variables on the result and runtime of optimization algorithms. I try to explain my question by giving an example. Let's say I have 2 type of buildings that I want to model. They have flexible electrical consumers that can vary their electrical power. We also have a time-dependent price for electricity for one day. So basically the task is a scheduling problem that can for example be modelled as a mixed-integer linear problem.&lt;/p&gt;&#xA;&lt;p&gt;Let's say buildings from type 1 have two flexible electrical consumers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A heat pump (electrical heating element) with a maximum electrical Power of P_HP and a binary (or continuous) decision variable x(t) between [0,1] for x(t) in {1,2,3,...,24}.&lt;/li&gt;&#xA;&lt;li&gt;An electric vehicle with a maximum electrical power of P_EV and a binary (or continuous) decision variable x(t) between [0,1] for y(t) in {1,2,3,...,24}.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So the current electrical power for a time slot t for the heat pump is P(t)= x(t) *P_HP for every hour of the day. Analogously, the current electrical power for a time slot t for the electric vehicle is calculated P(t)=y(t) * P_EV. Of course I have several constraints for the devices and and objective function that depend on x(t) and y(t).&lt;/p&gt;&#xA;&lt;p&gt;Building type 2 also has the heat pump as the flexible device but does not have an electric vehicle.  Now I come to my question. What effect does it have on the optimization if I model building type 2 exactly like building type 1 but set the maximum (and minimum) power of the electric vehicle P_EV to 0? By doing so, the decision variable y(t) would not have any effects on any constraint and on the&#xA;objective function and thus can be labelled as 'unused'. But still they are incorporated in the optimization and the number of variables is surely increased by that. Another way would be to use a different model for building type 2 and exclude the variables and the constraints for the electric vehicle. Thus, I would reduce the number of decision variables and constraints for building type 2 but the effort for modelling will be higher as I would have to model building type 2 separately instead of just adjusting the parameters for them.&lt;/p&gt;&#xA;&lt;p&gt;My concrete questions are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What effect do such 'unused' variables have on the runtime and the result of the optimization? We now have more decision variables but all of them could just take any value as they do not influence anything.&lt;/li&gt;&#xA;&lt;li&gt;From a modelling perspective: Is it advisable to use such variables or not? I mean the model of all buildings would be exactly the same which reduces the lines of code and the time to implement it. However, the model would not be really &amp;quot;correct&amp;quot; for certain building types as it would include variables and constraints that are not really existing for those building types.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;What is your experience regarding theses questions? I'd highly appreciate every comment and every shared experience. The motivation for my question is that in fact I have not 2 but 20 different building types with different combinations of flexible electrical consumers.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="123" LastEditDate="2021-06-02T07:55:49.977" LastActivityDate="2021-06-02T07:55:49.977" Title="Effect of 'unused' variables on the result and runtime of optimization algorithms" Tags="|modeling|solver|computational-complexity|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6371" PostTypeId="2" ParentId="5910" CreationDate="2021-06-01T12:08:31.310" Score="1" Body="&lt;p&gt;Not sure about operations research but there is a club called stackexchange in clubhouse. Do join and you can start a topic of your own.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.clubhouse.com/join/stackexchange/FrzrVmPK&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.clubhouse.com/join/stackexchange/FrzrVmPK&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5616" LastActivityDate="2021-06-01T12:08:31.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6372" PostTypeId="1" CreationDate="2021-06-01T14:28:54.000" Score="-4" ViewCount="86" Body="&lt;p&gt;So i'm working on my school project and The problem is described as follow:&lt;/p&gt;&#xA;&lt;p&gt;we have 31 baths and 4 cranes '1 axis of movement'.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/PAqYF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PAqYF.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;figure 1:  a crane imageimagen_2021-06-01_120450.png&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/H3al2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/H3al2.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;figure 2: baths and cranes&lt;/p&gt;&#xA;&lt;p&gt;1,2: are for load and unload the material&#xA;4,5: are similar baths&#xA;29,30,31,32: are similar baths&lt;/p&gt;&#xA;&lt;p&gt;the process is this:&lt;/p&gt;&#xA;&lt;p&gt;1 or 2 =&amp;gt; 16 =&amp;gt; 18=&amp;gt; 19 =&amp;gt; 20 =&amp;gt; 22 =&amp;gt; 23 =&amp;gt; 24 =&amp;gt; 25 =&amp;gt;  29 or 30 or 31or 32  =&amp;gt; 28 =&amp;gt; 27=&amp;gt; 26=&amp;gt; 13 =&amp;gt; 10=&amp;gt; 9 =&amp;gt; 8 =&amp;gt; 6=&amp;gt; 4 or 5 =&amp;gt; 1 or 2.&lt;/p&gt;&#xA;&lt;p&gt;the 'or' word significate if one of the baths is free we use it.&lt;/p&gt;&#xA;&lt;p&gt;the non colusion condition:&#xA;-we should have 1 bath between two cranes&#xA;-in baths 29,30,31,32: we have 30 min of processing time&#xA;-in baths 21,22: we have 5 min of processing time&#xA;loading and unloading time is 2s.&#xA;for each crane moving from one bath to next one takes 2s.&#xA;so from 1 to 10 is 20s and vice versa.&lt;/p&gt;&#xA;&lt;p&gt;the objectif is to optimize the cycle time and process max products.&lt;/p&gt;&#xA;&lt;p&gt;can you please give me some hints on how can i solve this problem.&lt;/p&gt;&#xA;" OwnerUserId="5617" LastActivityDate="2021-06-01T18:42:24.340" Title="multiple cranes scheduling optimization" Tags="|optimization|scheduling|" AnswerCount="2" CommentCount="1" ClosedDate="2021-06-03T09:44:47.273" ContentLicense="CC BY-SA 4.0" />
  <row Id="6373" PostTypeId="2" ParentId="6372" CreationDate="2021-06-01T16:53:14.057" Score="1" Body="&lt;p&gt;The problem is a combination of two problems:&#xA;The first is the transport with the cranes and the non crossing constraints (non colusion condition).&#xA;Check out this paper:&lt;/p&gt;&#xA;&lt;p&gt;N. Boysen, D. Briskorn, S. Emde&#xA;Parts-to-picker based order processing in a rack- moving mobile robots environment&#xA;Eur J Oper Res, 262 (2) (2017), pp. 550-562&lt;/p&gt;&#xA;&lt;p&gt;as a good starting point into non-crossing constraints.&lt;/p&gt;&#xA;&lt;p&gt;The other part is a machine scheduling problem with the baths being your machines. You probably don't even need google scholar and can just use regular google to find introductory information.&lt;/p&gt;&#xA;&lt;p&gt;If you want to go into very fast techniques but very complicated techniques, I imagine modelling this as a CVRP and dynamically generating the non-crossing constraints will get you very far.&lt;/p&gt;&#xA;" OwnerUserId="405" LastActivityDate="2021-06-01T16:53:14.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6374" PostTypeId="2" ParentId="6370" CreationDate="2021-06-01T17:34:31.837" Score="8" Body="&lt;p&gt;If variable fixings can be derived automatically (e.g. you specified a constraint saying &lt;span class=&quot;math-container&quot;&gt;$2x_1=4$&lt;/span&gt; and maybe another saying &lt;span class=&quot;math-container&quot;&gt;$x_1+x_2=1$&lt;/span&gt;), those variables will be fixed at known values. A smaller problem will then be solved, and we will restore the values for the fixed variables when we report the solution (e.g. in this case &lt;span class=&quot;math-container&quot;&gt;$x_1=2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2=-1$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;The cost of doing this for the solver is typically negligible (e.g. our Octeract Engine can reduce a 110K x 110K problem to 800 x 800 in about 1 second), but the overhead can become significant for massive problems. It's nearly always worth the time spent though because the problem becomes much easier to solve.&lt;/p&gt;&#xA;&lt;p&gt;For &amp;quot;junk&amp;quot; variables, i.e., variables that are present but do not affect the problem in any way, we would typically remove them (if we can detect them) and report a value for them by convention at the end (e.g. 0,&lt;span class=&quot;math-container&quot;&gt;$\infty$&lt;/span&gt;). For the ones we can't detect, the feasible solution reported at the end would have some junk values.&lt;/p&gt;&#xA;&lt;p&gt;From a modelling point of view it's usually best not to worry about such things and focus on getting the logic right, as long as the solver seems to be able to handle it.&lt;/p&gt;&#xA;&lt;p&gt;If you see that the solver is beginning to struggle, you can help it out by removing redundant information. Free variables in particular can be quite nasty, especially in MINLP.&lt;/p&gt;&#xA;&lt;p&gt;However, state-of-the-art solvers are generally pretty good at handling this stuff. If you notice that the solver is struggling it's more likely that there are deeper problems with your formulation that mere redundancy.&lt;/p&gt;&#xA;&lt;p&gt;One subtle thing that I would point out here is that, although &amp;quot;fixable&amp;quot; variables are a non-issue for most solvers (unless the problem is in the millions of variables/constraints), having a model with a large amount of redundant information can make it very difficult for the modeller to improve/change the model, as it's very difficult to see what the degrees of freedom of your problem are.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-06-01T17:34:31.837" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6375" PostTypeId="2" ParentId="6372" CreationDate="2021-06-01T18:42:24.340" Score="1" Body="&lt;p&gt;As far as I know, this is a special type of blocking job shop problem. Take a look at this paper: &lt;a href=&quot;https://link.springer.com/article/10.1007/s10878-014-9723-3&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/article/10.1007/s10878-014-9723-3&lt;/a&gt; If you search for BJS-RT you will find more literature that is freely available.&lt;/p&gt;&#xA;&lt;p&gt;Once you have formulated it as BJS, there are different ways of solving it. Heuristics or for smaller instances CP or even MIP will work fine.&lt;/p&gt;&#xA;" OwnerUserId="4030" LastActivityDate="2021-06-01T18:42:24.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6376" PostTypeId="2" ParentId="6214" CreationDate="2021-06-01T20:00:40.930" Score="2" Body="&lt;p&gt;In reliability studies, the availability of conventional plants is modelled with two states, available and unavailable. A plant can be unavailable due to scheduled maintenance or due to an outage. In order to model the outages, you need some information for the mean time to failure and the mean time to repair, which can be used to model the transition between the two states. From my personal experience, it is easier to work with the Forced Outage Rate, which can be estimated from above. With a fast search I found an introductory text &lt;a href=&quot;http://www.bau.edu.jo/UserPortal/UserProfile/PostsAttach/16928_5875_1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that a power plant might include several turbines and each one could be modelled separately. For example if a plant has two turbines &lt;span class=&quot;math-container&quot;&gt;$A,B$&lt;/span&gt; and each one assumes two states &lt;span class=&quot;math-container&quot;&gt;$\{available, outage\}$&lt;/span&gt;, there are 4 states in total. In most papers I would assume that plants are modelled as a single entity due to data unavailability. From my experience working at a system operator, I think it is not unheard that a plant operates below the nominal capacity due to some reason (outage or other).&lt;/p&gt;&#xA;" OwnerUserId="4150" LastActivityDate="2021-06-01T20:00:40.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6377" PostTypeId="2" ParentId="6367" CreationDate="2021-06-01T21:18:25.237" Score="3" Body="&lt;p&gt;The closest example that I could find in the literature is the following paper. The authors compared a special case of their problem when there are only two stations in the assembly line to a BTSP. I think it is a good place to start a deeper search in the applications.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Delorme, Xavier, et al. &amp;quot;Minimizing the number of workers in a paced mixed-model assembly line.&amp;quot; European Journal of Operational Research 272.1 (2019): 188-194.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-06-01T21:18:25.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6378" PostTypeId="2" ParentId="6304" CreationDate="2021-06-01T21:24:02.897" Score="4" Body="&lt;p&gt;I would suggest checking out the blog posts of Prof Powell &lt;a href=&quot;https://castlelab.princeton.edu/jungle/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. Although these mostly refer to stochastic optimization, he illustrates a problem that persists in the field of optimization, which is that different fields (dynamic programming, reinforcement learning, mathematical programming) have different notation and study similar things under different names. In the blog you can also find a link for an introductory book which is application oriented, so you can see what interests you.&lt;/p&gt;&#xA;" OwnerUserId="4150" LastActivityDate="2021-06-01T21:24:02.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6379" PostTypeId="1" CreationDate="2021-06-02T05:32:33.880" Score="1" ViewCount="240" Body="&lt;p&gt;I am wondering whether it is possible to create constraints over years and hours at the same time in Pyomo.&lt;/p&gt;&#xA;&lt;p&gt;For example, my current time variable is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.T = pyo.RangeSet(len(hourly_data.index))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, this does not allow me to distinguish between hours and years. I do have a timestamp variable, that contains the date and the time. So, I thought perhaps I could do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.T2 = pyo.Set(initialize=hourly_data.DateTime)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now the problem comes on how to manipulate this TimeStamp object. Consider that the parameters are given and the variables are outputs from the solver. Let's first assume that our objective function is a &lt;strong&gt;maximisation function&lt;/strong&gt;. We would like to create the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;Get the maximum water used, in normal circumstances, if we would like to get the maximum water usage of during all hours, we can do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.c_maxWater = pyo.ConstraintList()&#xA;for t in model.T:&#xA;     model.c_maxWater.add(model.waterUsage[t] &amp;lt;=&#xA;                          model.maxWater)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With a penalty in the objective function associated with &lt;code&gt;model.maxWater&lt;/code&gt;. The problem becomes what if we want to penalise every year differently, because we have different water costs? I can imagine that our constraint would be somewhat like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.c_maxWater = pyo.ConstraintList()&#xA;for t in model.T2:&#xA;     model.c_maxWater.add(model.waterUsage[t] &amp;lt;=&#xA;                          model.maxWater[y])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My problem is: how can I associate the &lt;code&gt;t&lt;/code&gt; variable with certain years &lt;code&gt;y&lt;/code&gt;. One index is hourly (in this case the &lt;code&gt;t&lt;/code&gt; and the other is annually (&lt;code&gt;y&lt;/code&gt;)?&lt;/p&gt;&#xA;&lt;p&gt;Note: a multi index set is possible, but how to deal with leap years etc.? Can a multi index set have different lengths in it's hourly dimensions for leap years?&lt;/p&gt;&#xA;" OwnerUserId="563" LastEditorUserId="563" LastEditDate="2021-06-02T06:11:18.963" LastActivityDate="2021-06-02T06:11:18.963" Title="How to deal with hourly and annually constraints in Pyomo?" Tags="|pyomo|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6380" PostTypeId="1" AcceptedAnswerId="6381" CreationDate="2021-06-02T09:59:54.480" Score="0" ViewCount="547" Body="&lt;p&gt;I would like to crate an constraint-equation that depends on 4 sets. For that I use the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Equations for calculating the total generation from renewable energy sources (RES)&#xA;def RESgenerationTotalRule (model, index_BT1, index_BT2, index_BT3, t):&#xA;    return model.variable_RESGenerationTotal [t] == sum (model.param_pvGenerationNominal_BT1 [index_BT1, t] * SetUpScenarios.pvPeaksOfBuildings[index_BT1] + model.param_windAssignedNominal_BT1 [index_BT1, t] * SetUpScenarios.maximalPowerOfWindTurbine for index_BT1 in model.set_buildings_BT1) + sum (model.param_pvGenerationNominal_BT2 [index_BT2, t] * SetUpScenarios.pvPeaksOfBuildings[index_BT2] + model.param_windAssignedNominal_BT2 [index_BT2, t] * SetUpScenarios.maximalPowerOfWindTurbine for index_BT2 in model.set_buildings_BT2) + sum (model.param_pvGenerationNominal_BT3 [index_BT3, t] * SetUpScenarios.pvPeaksOfBuildings[index_BT3] + model.param_windAssignedNominal_BT3 [index_BT3, t] * SetUpScenarios.maximalPowerOfWindTurbine for index_BT3 in model.set_buildings_BT3)&#xA;    &#xA;model.constraint_RESgenerationTotal = pyo.Constraint(model.set_buildings_BT1, model.set_buildings_BT2, model.set_buildings_BT3,model.set_timeslots, rule = RESgenerationTotalRule)&#xA;&#xA;model.constraint_RESgenerationTotal.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Basically I have the 4 sets &lt;code&gt;model.set_buildings_BT1, model.set_buildings_BT2, model.set_buildings_BT3,model.set_timeslots&lt;/code&gt;. When all of those sets are non-empty, the equation is defined. Howeever, if one of the 3 sets &lt;code&gt;model.set_buildings_BT1, model.set_buildings_BT2, model.set_buildings_BT3&lt;/code&gt; is empty, I get and equations Size of 0 and the equation is not defined. How can I implement in Pyomo that - even if some sets are empty - the equation should be defined because it still makes sense to define it. The equation consists of 3 sums; one for each of the 3 sets &lt;code&gt;model.set_buildings_BT1, model.set_buildings_BT2, model.set_buildings_BT3&lt;/code&gt;. If one out of those 3 sets in empty, the sum for this set should just not be considered (or set to 0). Any idea how I can do that? I appreciate every comment.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;:&#xA;I tried another solution&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Equations for calculating the total generation from renewable energy sources (RES)&#xA;def RESgenerationTotalRule (model, t):&#xA;    return model.variable_RESGenerationTotal [t] == sum (model.param_pvGenerationNominal_BT1 [index_BT1, t] * SetUpScenarios.pvPeaksOfBuildings[index_BT1] + model.param_windAssignedNominal_BT1 [index_BT1, t] * SetUpScenarios.maximalPowerOfWindTurbine for index_BT1 in model.set_buildings_BT1) + sum (model.param_pvGenerationNominal_BT2 [index_BT2, t] * SetUpScenarios.pvPeaksOfBuildings[index_BT2] + model.param_windAssignedNominal_BT2 [index_BT2, t] * SetUpScenarios.maximalPowerOfWindTurbine for index_BT2 in model.set_buildings_BT2) + sum (model.param_pvGenerationNominal_BT3 [index_BT3, t] * SetUpScenarios.pvPeaksOfBuildings[index_BT3] + model.param_windAssignedNominal_BT3 [index_BT3, t] * SetUpScenarios.maximalPowerOfWindTurbine for index_BT3 in model.set_buildings_BT3)&#xA;    &#xA;model.constraint_RESgenerationTotal = pyo.Constraint(model.set_timeslots, rule = RESgenerationTotalRule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;model.constraint_RESgenerationTotal.pprint()&lt;/p&gt;&#xA;&lt;p&gt;Here it is also the case that when the 3 sets are non-empty, the equation is defined and when one of those sets is not empty, I get an error message (opposed to the size 0 equation from the other approach) stating &amp;quot;IndexError: index 3 is out of bounds for axis 0 with size 3&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Here is the equation that I want to implement in Pyomo with the 3 independant sets BT1, BT2 and BT3. If one set is empty (or even 2) the equation should also be created&lt;a href=&quot;https://i.stack.imgur.com/s3aGY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/s3aGY.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2021-06-02T13:36:44.250" LastActivityDate="2021-06-02T14:30:00.890" Title="How to create constraint-equations in Pyomo with empty set inputs" Tags="|python|constraint|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6381" PostTypeId="2" ParentId="6380" CreationDate="2021-06-02T14:30:00.890" Score="3" Body="&lt;p&gt;Let me give you an example&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.N =Param(mutable=True, initialize=10) &#xA;model.i = RangeSet(1,model.N)&#xA;model.x = Var(model.i,initialize=0,domain=Binary)&#xA;&#xA;def rue_c1(model):&#xA;    return sum(model.x[i] for i in model.i)==5&#xA;model.C1 =Constraint(rule=rue_c1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;in the above case, if you initialize your set with N (and define it as a mutable parameter) then it will do the job for you.&#xA;you can then change it before the solve statement&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.N=20&#xA;instance = model.create_instance()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;opt = SolverFactory('glpk')&#xA;results=opt.solve(instance)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2021-06-02T14:30:00.890" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6383" PostTypeId="2" ParentId="6317" CreationDate="2021-06-02T22:07:52.400" Score="3" Body="&lt;p&gt;Here is a book that Pete Cacioppi wrote to &lt;a href=&quot;http://networkdesignbook.com/academic-use/new-book-teach-cplex-and-optimization-along-with-network-design/&quot; rel=&quot;nofollow noreferrer&quot;&gt;teach OPL&lt;/a&gt; and optimization as it relates to network design models. It was meant for beginners. It uses a network design problem as the example, but you don't need to get the Supply Chain Network Design book to use this one.&lt;/p&gt;&#xA;" OwnerUserId="191" LastActivityDate="2021-06-02T22:07:52.400" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6384" PostTypeId="2" ParentId="5979" CreationDate="2021-06-03T07:33:57.890" Score="3" Body="&lt;p&gt;I have solved the problem using pyomo and the octeract solver. I have attached the folder here for free to use. The octeract folder is missing but you can get that by applying a license and downloading their solver from &lt;a href=&quot;https://octeract.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://octeract.com/&lt;/a&gt;.&#xA;cheers!!&lt;/p&gt;&#xA;&lt;p&gt;The files can be found here:&#xA;&lt;a href=&quot;https://www.researchgate.net/post/Recommended_python_solver_for_an_online_optimisation_problem2&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.researchgate.net/post/Recommended_python_solver_for_an_online_optimisation_problem2&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4945" LastActivityDate="2021-06-03T07:33:57.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6385" PostTypeId="1" CreationDate="2021-06-03T07:52:14.850" Score="5" ViewCount="449" Body="&lt;p&gt;I have a binary integer program. It is of a large size and the solver is taking longer time.&lt;/p&gt;&#xA;&lt;p&gt;I am thinking of relaxing the binary integer variable and making it a continuous variable.&lt;/p&gt;&#xA;&lt;p&gt;How can I penalise the objective function?&lt;/p&gt;&#xA;" OwnerUserId="836" LastActivityDate="2021-06-03T14:01:58.780" Title="What is a good way to penalise LP relaxation?" Tags="|mixed-integer-programming|linear-programming|linearization|convex-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6387" PostTypeId="1" CreationDate="2021-06-03T12:41:31.480" Score="4" ViewCount="1165" Body="&lt;p&gt;I know that an unbalanced transportation problem could be made a balanced transportation problem by adding a dummy node which equals the difference between demand and supply.&lt;/p&gt;&#xA;&lt;p&gt;In literature, dummy nodes are inserted with a cost of 0.&#xA;Wouldn't this lead to the problem that the algorithm will always fulfill this dummy amount first?&#xA;So it can't be insured that we get a realistic result, can it?&lt;/p&gt;&#xA;" OwnerUserId="5624" LastEditorUserId="123" LastEditDate="2021-06-04T06:36:25.280" LastActivityDate="2021-06-21T02:05:59.533" Title="Best way to add dummy to transportation problem? Zero cost will be always chosen first?" Tags="|linear-programming|modeling|network-flow|simplex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6388" PostTypeId="2" ParentId="6385" CreationDate="2021-06-03T14:01:58.780" Score="6" Body="&lt;p&gt;You can't quite create a penalty function to enforce integrality and keep your problem linear, at best it would be quadratic (which could indeed be easier to solve sometimes).&lt;/p&gt;&#xA;&lt;p&gt;The closest thing that comes to mind along the lines of what you propose is to create a &lt;a href=&quot;http://www.dei.unipd.it/%7Esalvagni/pdf/fp2.pdf&quot; rel=&quot;noreferrer&quot;&gt;feasibility pump&lt;/a&gt; objective:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min \bar f(x)+\Delta(x,\tilde x)$&lt;/span&gt; s.t. your relaxed constraints, where:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\Delta(x,\tilde x) = \sum_{j\in I:\tilde x = 1}(1-x_j)+\sum_{j\in I:\tilde x = 0}(x_j)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and &lt;span class=&quot;math-container&quot;&gt;$\bar f(x)$&lt;/span&gt; is your relaxed objective and &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is the set of your binary variables.&lt;/p&gt;&#xA;&lt;p&gt;This does not guarantee a global solution, but it could find an integer feasible point.&lt;/p&gt;&#xA;&lt;p&gt;This is then solved in a loop where we solve the relaxed LP and feed that into the pump objective (that's where the &lt;span class=&quot;math-container&quot;&gt;$\tilde x$&lt;/span&gt; comes from).&lt;/p&gt;&#xA;&lt;p&gt;Just a heads up though - if you're using CPLEX/GUROBI you probably shouldn't bother trying it, as their heuristics are much better than this.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-06-03T14:01:58.780" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6389" PostTypeId="2" ParentId="6387" CreationDate="2021-06-03T17:46:05.567" Score="4" Body="&lt;p&gt;The &amp;quot;goods&amp;quot; going to or coming from the dummy node are not really moved; hence the cost of zero, no matter the quantity.&lt;/p&gt;&#xA;&lt;p&gt;If the problem is solved to optimality, using Network Simplex, or whatever, there is no &amp;quot;first&amp;quot; which can't be changed later as the algorithm proceeds. The algorithm ensures the total cost for moving everything is minimized. Do not think in terms of a &amp;quot;greedy&amp;quot; algorithm which initially makes an irrevocable assignment of what appears to be an attractive first assignment to make, and never reconsiders that first greedy assignment which winds up not being optimal in the grand scheme of things. Network Simplex may make some initial assignment which is not truly optimal, but then iterates until criteria ensuring optimality are reached.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2021-06-03T19:29:17.153" LastActivityDate="2021-06-03T19:29:17.153" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6390" PostTypeId="1" AcceptedAnswerId="6392" CreationDate="2021-06-03T17:53:30.790" Score="5" ViewCount="166" Body="&lt;p&gt;I think this is a very basic question, but I failed to find an algorithm for this...&lt;/p&gt;&#xA;&lt;p&gt;When I have a set of inequality constraints, &lt;span class=&quot;math-container&quot;&gt;$Ax \leq b$&lt;/span&gt; as my feasible region, I can set &lt;span class=&quot;math-container&quot;&gt;$b = 0$&lt;/span&gt; and find &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; independent rows to solve for an extreme direction, But when I'm facing equality constraints, I tried the same thing but it didn't work.&lt;/p&gt;&#xA;&lt;p&gt;So my question is: can anyone guide me or show me an algorithm for finding the extreme direction of a region given equality constraints or a combination of inequality and equality constraints, please?&lt;/p&gt;&#xA;" OwnerUserId="5626" LastEditorUserId="36" LastEditDate="2021-06-03T18:37:48.023" LastActivityDate="2021-06-04T22:36:03.717" Title="Find Extreme direction of equality constraints" Tags="|algorithms|extreme-rays|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6391" PostTypeId="1" AcceptedAnswerId="6405" CreationDate="2021-06-03T18:33:56.380" Score="7" ViewCount="229" Body="&lt;p&gt;If I want to study the smoothness of the energy landscape of a cost function, is there any metric similar to &lt;a href=&quot;https://www.edenextdata.com/?q=content/terrain-ruggedness-index-tri&quot; rel=&quot;noreferrer&quot;&gt;Terrain Ruggedness Index&lt;/a&gt; used in geology?&lt;/p&gt;&#xA;" OwnerUserId="3730" LastEditorUserId="123" LastEditDate="2021-06-03T19:47:17.373" LastActivityDate="2021-06-08T07:56:41.123" Title="Terrain Ruggedness Index for optimization problem" Tags="|optimization|combinatorial-optimization|simulated-annealing|energy|cost-matrix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6392" PostTypeId="2" ParentId="6390" CreationDate="2021-06-03T19:59:04.170" Score="6" Body="&lt;p&gt;First observation: any combination of linear equality and inequality constraints can be converted to all &lt;span class=&quot;math-container&quot;&gt;$\le $&lt;/span&gt; constraints. If you start with &lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{c}&#xA;Ax\le a\\&#xA;Bx\ge b\\&#xA;Ex=e&#xA;\end{array},&#xA;$$&lt;/span&gt;you can convert it to the equivalent system of inequalities&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left[\begin{array}{r}&#xA;A\\&#xA;-B\\&#xA;E\\&#xA;-E&#xA;\end{array}\right]x\le\left[\begin{array}{r}&#xA;a\\&#xA;-b\\&#xA;e\\&#xA;-e&#xA;\end{array}\right].&#xA;$$&lt;/span&gt;&#xA;Second observation (which requires knowledge of linear programming): if your feasible set is unbounded, you can slap an objective function on it that will improve along the ray (say, maximize the sum of the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, assuming &lt;span class=&quot;math-container&quot;&gt;$x\ge 0$&lt;/span&gt;) and get an unbounded linear program. Most LP solvers can find a ray once they have established that an LP is unbounded. If you prefer, you can try to apply the primal simplex method by hand. At some point you will encounter a basis where a variable wants to enter the basis (to improve the objective function) but there is no row in which to pivot. From that basic feasible solution you can easily identify a ray.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: How to use the all-negative simplex column. Assume a problem in &amp;quot;standard form&amp;quot; (meaning slacks/surpluses have been added) with constraints &lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; be the basis matrix when the negative column occurs, and for convenience assume the basic columns are the first few, so that &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; gets partitioned as &lt;span class=&quot;math-container&quot;&gt;$[B\  \vert\  N]$&lt;/span&gt; and your tableau corresponds to the system &lt;span class=&quot;math-container&quot;&gt;$I x_B + B^{-1}N x_N = B^{-1}b$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; be the index of the all negative column and let &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; be the column. If we freeze all the other nonbasic variables at 0, the system reduces to &lt;span class=&quot;math-container&quot;&gt;$x_B + h\cdot x_k = B^{-1}b$&lt;/span&gt;, with the right-hand side nonnegative. Since &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; is all nonnegative, you can set &lt;span class=&quot;math-container&quot;&gt;$x_k$&lt;/span&gt; as high as you want and the adjusted basic solution &lt;span class=&quot;math-container&quot;&gt;$x_B = B^{-1}b - h\cdot x_k$&lt;/span&gt; will be nonnegative. So the ray originates at the current point &lt;span class=&quot;math-container&quot;&gt;$x_B = B^{-1}b, x_N = 0$&lt;/span&gt; and moves in the direction &lt;span class=&quot;math-container&quot;&gt;$$\left[\begin{array}{c}&#xA;-h\\&#xA;1\\&#xA;0&#xA;\end{array}\right],$$&lt;/span&gt; where I am assuming that &lt;span class=&quot;math-container&quot;&gt;$x_k$&lt;/span&gt; is the first variable after the basic variables and the 0 has dimension equal to the number of nonbasic variables minus 1.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-06-04T22:36:03.717" LastActivityDate="2021-06-04T22:36:03.717" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6393" PostTypeId="1" CreationDate="2021-06-03T22:18:15.377" Score="4" ViewCount="174" Body="&lt;p&gt;For personal work, I am investigating options for commercial solvers.  Prefer a cloud solution so I don't need to invest in higher-compute machines.  I have received pricing for Gurobi Instant Cloud, but would like recommendations from others.&lt;/p&gt;&#xA;" OwnerUserId="267" LastActivityDate="2021-06-04T12:00:04.477" Title="Cloud Solver Options" Tags="|solver|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6394" PostTypeId="2" ParentId="6393" CreationDate="2021-06-04T07:19:05.747" Score="2" Body="&lt;p&gt;You can run &lt;a href=&quot;https://www.optaplanner.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner&lt;/a&gt; (open source) in the cloud, on OpenShift/AWS/Azure etc.&lt;/p&gt;&#xA;&lt;p&gt;All of the &lt;a href=&quot;https://github.com/kiegroup/optaplanner-quickstarts&quot; rel=&quot;nofollow noreferrer&quot;&gt;quickstarts&lt;/a&gt; contain a docker file. All quickstarts can run in with the JDK docker image, but all the Quarkus quickstarts also support native compilation into a normal linux executable, which is ideal for serverless setups.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2021-06-04T12:00:04.477" LastActivityDate="2021-06-04T12:00:04.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6395" PostTypeId="1" AcceptedAnswerId="6398" CreationDate="2021-06-04T22:59:22.500" Score="11" ViewCount="185" Body="&lt;p&gt;I saw some posts like this so I figured I would start my own.&lt;/p&gt;&#xA;&lt;p&gt;What are some interesting papers in OR that are related to, or even develop, the theory of statistical inference? What are some of the applications that motivate these innovations? How does it relate to more traditional stochastic optimization problems that OR deals with?&lt;/p&gt;&#xA;&lt;p&gt;I know the classical work was mostly concerned with &amp;quot;applied probability&amp;quot; models (stochastic processes, queuing theory, etc.) but I am personally very interested in statistical inference (asymptotic and finite sample properties of estimators and tests) and being in an OR department I was wondering how most OR people think about this. I know a lot of work now is also on machine learning. Is the field interested in developing inferential methods for these estimators or are they more seen as a means to an end for some forecasting problem? What about questions of causal inference, specifically those developing the theory of causal inference?&lt;/p&gt;&#xA;" OwnerUserId="4978" LastEditorUserId="4978" LastEditDate="2021-06-05T01:29:02.853" LastActivityDate="2021-06-05T18:39:35.830" Title="Interplay of OR and Statistics Research" Tags="|machine-learning|literature-research|academia|history|statistics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6396" PostTypeId="5" CreationDate="2021-06-05T01:25:02.580" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2021-06-05T01:25:02.580" LastActivityDate="2021-06-05T01:25:02.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6397" PostTypeId="4" CreationDate="2021-06-05T01:25:02.580" Score="0" Body="A catchall for questions related to the statistical sciences, including those about statistical inference, machine learning, probability, and applied statistics." OwnerUserId="4978" LastEditorUserId="4978" LastEditDate="2021-06-06T15:37:06.977" LastActivityDate="2021-06-06T15:37:06.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6398" PostTypeId="2" ParentId="6395" CreationDate="2021-06-05T18:39:35.830" Score="6" Body="&lt;p&gt;I'm going to interpret &amp;quot;in OR&amp;quot; as appearing in OR journals and/or written by people who identify as OR/MS/IE researchers. I'm a bit familiar with the intersection of optimization and statistical estimation. Machine learning, OLS and LAV regression, lasso regression etc. all rely on solving optimization problems to fit models. In addition, optimization models have been proposed for feature selection (choosing which predictors to include in a model) and classification analysis, and I imagine for other types of inference problems.&lt;/p&gt;&#xA;&lt;p&gt;As far &amp;quot;interesting&amp;quot; papers, that's in the eye of the beholder. One of the seminal papers on optimization models for classification (discriminant analysis) was Mangasarian's 1965 paper in the journal &lt;em&gt;Operations Research&lt;/em&gt; [1]. Around 1988, researchers including Fred Glover reopened interest in optimization models for classification, including in a paper in &lt;em&gt;Decision Sciences&lt;/em&gt; [2]. Following a workshop in April 1989 at the University of Florida, a number of related papers were published in a special issue of &lt;em&gt;Managerial and Decision Economics&lt;/em&gt;, including one by me [3]. (Mine is not overly interesting, but I'll use it to provide the volume information.) Based on the occasional new citation of it, I would say that research on discriminant models continues today (presumably with an improvement in models and heuristics).&lt;/p&gt;&#xA;&lt;p&gt;I'm less familiar with the work on feature selection (particularly its current state), but I'll toss in a reference to my sole contribution to the area [4], which also ties into discriminant analysis.&lt;/p&gt;&#xA;&lt;p&gt;One last disclaimer: The question mentions the theory of statistical inference, but most (all?) of the papers I've listed have to do with methods rather than theory.&lt;/p&gt;&#xA;&lt;p&gt;[1] Mangasarian, O. L. Linear and Nonlinear Separation of Patterns by Linear Programming. &lt;em&gt;Operations Research&lt;/em&gt;, &lt;strong&gt;1965&lt;/strong&gt;, &lt;em&gt;13&lt;/em&gt;, 444-452.&lt;/p&gt;&#xA;&lt;p&gt;[2] Glover, F.; Keene, S. &amp;amp; Duea, R. W. A New Class of Models for the Discriminant Problem. &lt;em&gt;Decision Sciences&lt;/em&gt;, &lt;strong&gt;1988&lt;/strong&gt;, &lt;em&gt;19&lt;/em&gt;, 269-280.&lt;/p&gt;&#xA;&lt;p&gt;[3] Rubin, P. A. Heuristic Solution Procedures for a Mixed-Integer Programming Discriminant Model. &lt;em&gt;Managerial and Decision Economics&lt;/em&gt;, &lt;strong&gt;1990&lt;/strong&gt;, &lt;em&gt;11&lt;/em&gt;, 255-266.&lt;/p&gt;&#xA;&lt;p&gt;[4] Iannarilli Jr., F. J. &amp;amp; Rubin, P. A. Feature Selection for Multi-class Discrimination via Mixed-integer Linear Programming. &lt;em&gt;IEEE Transactions on Pattern Analysis and Machine Intelligence&lt;/em&gt;, &lt;strong&gt;2003&lt;/strong&gt;, &lt;em&gt;25&lt;/em&gt;, 779-783.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-06-05T18:39:35.830" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6399" PostTypeId="2" ParentId="5167" CreationDate="2021-06-06T17:27:36.557" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;You can try to use solver implementing Simplex-method on the base of GMP, &lt;a href=&quot;https://gmplib.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gmplib.org/&lt;/a&gt;, (GNU Multiple Precision Arithmetic Library). E.g. it might be SoPLex, &lt;a href=&quot;https://soplex.zib.de&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://soplex.zib.de&lt;/a&gt;, see additional info on GMP in SoPlex here &lt;a href=&quot;https://soplex.zib.de/doc/html/INSTALL.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://soplex.zib.de/doc/html/INSTALL.php&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For a rather &amp;quot;small&amp;quot; LP problem I can you recommend &amp;quot;simplex package&amp;quot; in Maxima (Computer Algebra System based on Lisp). An exact, rational arithmetic is a native for Maxima. See examples and some instructions here &lt;a href=&quot;https://maxima.sourceforge.io/docs/manual/maxima_311.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://maxima.sourceforge.io/docs/manual/maxima_311.html&lt;/a&gt;, &lt;a href=&quot;https://maxima.sourceforge.io/docs/manual/maxima_312.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://maxima.sourceforge.io/docs/manual/maxima_312.html&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5445" LastEditorUserId="5445" LastEditDate="2021-06-06T18:47:50.003" LastActivityDate="2021-06-06T18:47:50.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6401" PostTypeId="1" CreationDate="2021-06-07T04:19:22.743" Score="6" ViewCount="126" Body="&lt;p&gt;I have an optimization problem that I'm attempting to tackle. As you can see in the image below, there's a graph network through which water flows. I've drawn out the problem in the image to explain it clearly.&lt;/p&gt;&#xA;&lt;p&gt;The objective is for Final1 node to receive water with component A having values between a range. The component A at any node is measured by a volume-weighted average of component A measures from its predecessor nodes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Node_A = (Predecessor1_Vol x Predecessor1_A + Predecessor2_Vol x Predecessor2_A .....) /(Predecessor1_Vol + Predecessor2_Vol .....)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;All of the above are decision variables (D.V.) in the optimization problem. The &amp;quot;vol&amp;quot; variables have to remain as D.V. since this is part of a bigger problem. There is flexibility on &amp;quot;component A&amp;quot; variables and can or not be D.V. as they were introduced only for this subproblem.&lt;/p&gt;&#xA;&lt;p&gt;All numbers in the image are just examples of what the optimization can come up with. In the current formulation, all are decision variables except the concentration at &amp;quot;Start&amp;quot; nodes, which are given.&lt;/p&gt;&#xA;&lt;p&gt;However, framing the problem this way makes it nonlinear (reason described in the image). Since I am using a linear solver &amp;quot;cbc&amp;quot;, the solver just says that quadratic constraints cannot be supported.&lt;/p&gt;&#xA;&lt;p&gt;I am reaching out to this community to find out if this problem can be linearised or formulated in another way to get the same output.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fhuMK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fhuMK.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5639" LastEditorUserId="36" LastEditDate="2021-06-13T13:55:30.080" LastActivityDate="2021-06-13T13:55:30.080" Title="Water quality component optimization" Tags="|optimization|mixed-integer-programming|nonlinear-programming|quadratic-programming|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6402" PostTypeId="1" CreationDate="2021-06-07T08:25:08.440" Score="4" ViewCount="104" Body="&lt;p&gt;I'm solving a time-dependent travelling salesman problem. I have data from a whole year. I'm thinking about the size of the time steps. I think that the time-steps shouldn't be too large to be realistic (in 4 hours the traffic can change significantly) but I also think that it shouldn't be too small so that the data does not have the tendency to be scewed. Is there a &amp;quot;best practice&amp;quot; size for the TD-TSP or is smaller always better?&lt;/p&gt;&#xA;" OwnerUserId="5571" LastEditorUserId="123" LastEditDate="2021-11-20T14:54:22.703" LastActivityDate="2021-11-20T14:54:22.703" Title="Size timesteps for time-dependent TSP" Tags="|traveling-salesman|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6403" PostTypeId="1" CreationDate="2021-06-07T17:36:12.847" Score="4" ViewCount="138" Body="&lt;p&gt;So we're using a fixed review period model with base stock &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, and review period &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; of 1 month - the period is not chosen optimally to minimise ordering cost like in an EOQ model, it's just a nice round number.&lt;/p&gt;&#xA;&lt;p&gt;I'm trying to work out how much to order each month. My modelling assumptions are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In one month/ review period &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mu_T$&lt;/span&gt; items are sold, and assuming demand is stochastic, I can calculate a &lt;span class=&quot;math-container&quot;&gt;$\sigma_T$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If that's the demand &amp;amp; std.dev in 1 month, then by the central limit theorem, the demand &amp;amp; std.dev over a leadtime &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; are given by&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mu_{T+L}=\mu_T \cdot (T + L)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sigma_{T+L}=\sigma_T \cdot \sqrt{T+L}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Finally, I calculate the base stock &lt;span class=&quot;math-container&quot;&gt;$S = \mu_{T+L} + z\cdot \sigma_{T+L}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is some safety factor chosen based on a 95% service level. (see &lt;a href=&quot;https://ocw.mit.edu/courses/sloan-school-of-management/15-772j-d-lab-supply-chains-fall-2014/lecture-notes/MIT15_772JF14_Lec14.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;these notes&lt;/a&gt; I found, slide 21)&lt;/p&gt;&#xA;&lt;p&gt;I'm slightly confused why this is. It looks like &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is set to cover the demand for 1 period + retrospective demand that happened over the leadtime. Isn't this double counting, I would have expected &lt;span class=&quot;math-container&quot;&gt;$\mu_T$&lt;/span&gt;, not &lt;span class=&quot;math-container&quot;&gt;$\mu_{T+L}$&lt;/span&gt;, since each order must be enough to cover the demand between now and the next order, which is &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; away?&lt;/p&gt;&#xA;&lt;p&gt;On this graph for example:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Je4IF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Je4IF.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;It feels like accounting for &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; would just shift it in time by that much, but the spacing between verticals is still &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; so surely that's all the demand &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; needs to account for, not &lt;span class=&quot;math-container&quot;&gt;$T+L$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The safety factor makes more sense; every review period must cover its own fluctuations in demand from &lt;span class=&quot;math-container&quot;&gt;$\sigma_{T}$&lt;/span&gt; as well as any uncertainty that occurs while the next review period is waiting for its order to arrive.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Can someone provide some intuition? Why is &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; set that way?&lt;/p&gt;&#xA;" OwnerUserId="5641" LastEditorUserId="5641" LastEditDate="2021-06-07T17:46:07.797" LastActivityDate="2021-06-09T08:07:05.337" Title="Confusion about how to account for leadtimes with a fixed-review period base stock(S,T) inventory policy" Tags="|inventory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6404" PostTypeId="2" ParentId="3347" CreationDate="2021-06-07T18:06:16.470" Score="4" Body="&lt;p&gt;As in some of the other answers, using the TSP to teach column generation is perhaps not your best choice, since the columns are abstract mathematical structures (e.g. matchings) which are not as intuitive as for instance the columns (routes) in a CG for VRP.&lt;/p&gt;&#xA;&lt;p&gt;If you insist on using the TSP as your CG example, the following document might be helpful as it provides a short read on a Branch-and-Price formulation for the TSP using perfect matchings: &lt;a href=&quot;http://coin-or.github.io/jorlib/manual/manual.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://coin-or.github.io/jorlib/manual/manual.pdf&lt;/a&gt;, see Section 4 Example 3 - Solving the Traveling Salesman Problem through Branch-and-Price, page 18.&lt;/p&gt;&#xA;&lt;p&gt;This manual provides a small graphical example, the master problem formulation, corresponding pricing problem, as well as a potential branching rule. Corresponding implementation can be found under &lt;a href=&quot;https://github.com/coin-or/jorlib/tree/development/jorlib-demo/src/main/java/org/jorlib/demo/frameworks/columngeneration/tspbap&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/coin-or/jorlib/tree/development/jorlib-demo/src/main/java/org/jorlib/demo/frameworks/columngeneration/tspbap&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-06-07T18:06:16.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6405" PostTypeId="2" ParentId="6391" CreationDate="2021-06-08T07:56:41.123" Score="6" Body="&lt;p&gt;Yes. The ruggedness of a landscape is a measure of how much variability is observed between neighbouring solutions, and it can be computed using the &lt;em&gt;landscape correlation function&lt;/em&gt;. Rugged landscapes (with a very low correlation) typically have lots of local minima and are more difficult to traverse than smooth landscapes (correlation close to 1).&lt;/p&gt;&#xA;&lt;p&gt;For a fixed distance &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, the landscape correlation function is defined as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\rho(i) = \frac{\langle f(s)\cdot f(s^\prime)\rangle_{d(s,s^\prime)=i}-\langle f(s)\rangle^2}{\langle f^2(s)\rangle - \langle f(s)\rangle^2}&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f(s)$&lt;/span&gt; is the objective function value of a solution &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\langle f(s) \rangle$&lt;/span&gt; is the average of the solution value for all the solutions &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; in the search space &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\langle f(s)\cdot f(s^\prime)\rangle_{d(s,s^\prime)=i}$&lt;/span&gt; is the average of &lt;span class=&quot;math-container&quot;&gt;$f(s)\cdot f(s^\prime)$&lt;/span&gt; for all the pairs of solutions &lt;span class=&quot;math-container&quot;&gt;$s,s^\prime$&lt;/span&gt; at distance &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Of course, the formula is not usable in practice, because it requires to analyze the entire search space. One alternative is to perform a random walk on the search space, and compute the &lt;em&gt;empirical autocorrelation function&lt;/em&gt; on the sequence of solution values &lt;span class=&quot;math-container&quot;&gt;$f_1, f_2, \dots, f_m$&lt;/span&gt; observed:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;r(i) = \frac{1/(m-i)\cdot \sum_{k=1}^{m-i}(f_k-\bar{f})\cdot(f_{k+i}-\bar{f})}{1/m \cdot \sum_{k=1}^m (f_k-\bar{f})^2}&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is the length of the random walk, and &lt;span class=&quot;math-container&quot;&gt;$\bar{f}$&lt;/span&gt; is the average of the sequence of values &lt;span class=&quot;math-container&quot;&gt;$f_1, f_2, \dots, f_m$&lt;/span&gt; observed in the random walk. This formula gives information about the correlation between solutions at distance &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in the random walk.&lt;/p&gt;&#xA;&lt;p&gt;As a reference, the formulas are taken from the book &amp;quot;Stochastic Local Search: Foundations and Applications&amp;quot; (Hoos and Stützle). Course slides about this topic can be found &lt;a href=&quot;https://iridia.ulb.ac.be/%7Estuetzle/Teaching/HO/Slides/Lecture11.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="224" LastActivityDate="2021-06-08T07:56:41.123" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6406" PostTypeId="1" CreationDate="2021-06-08T13:14:08.447" Score="2" ViewCount="508" Body="&lt;p&gt;I have faced a little weird problem when I use Cplex to solve my test problem. Basically, some of my data are float numbers up to three decimal numbers (For instance, 0.627). But, when I print out the model using the &lt;code&gt;exportModel&lt;/code&gt; command, I noticed that Cplex converts all the float numbers to numbers with much more degree of precision (For example, 0.627 to 0.626999974250793). As a result of this, Cplex gives me the wrong optimal solution. I'd be grateful if you could let me know what is the cause of this error and how I can prevent this convergence?&lt;/p&gt;&#xA;&lt;p&gt;I should note that I use Concert technology C++.&lt;/p&gt;&#xA;" OwnerUserId="5008" LastEditorUserId="123" LastEditDate="2021-06-08T13:38:59.630" LastActivityDate="2021-06-08T16:07:04.713" Title="The precision of the decimal number of the Cplex" Tags="|mixed-integer-programming|cplex|c++|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6407" PostTypeId="2" ParentId="6406" CreationDate="2021-06-08T16:07:04.713" Score="2" Body="&lt;p&gt;instead of exporting into a .lp you could export into a .sav filre and then you won't face those rounding issues.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;SAV is a binary file format specific to CPLEX. This format is&#xA;efficient for fast reading and writing of models and associated basis&#xA;information. For example, it can effectively reduce read and write&#xA;time for problems that are solved repetitively.&lt;/p&gt;&#xA;&lt;p&gt;Tip: CPLEX includes the basis in a SAV file only if the problem&#xA;currently in memory has been optimized and a basis exists.&lt;/p&gt;&#xA;&lt;p&gt;This format also offers the &lt;strong&gt;advantage of being numerically accurate&lt;/strong&gt;&#xA;(to the same degree as your platform) in contrast to text file formats&#xA;that may lose numerical accuracy. In other words, it provides a&#xA;greater degree of precision in data. However, since a SAV file is&#xA;binary, you cannot read nor edit it with your favorite text editor.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-06-08T16:07:04.713" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6408" PostTypeId="1" CreationDate="2021-06-08T17:07:17.317" Score="2" ViewCount="190" Body="&lt;p&gt;I'm using the Java API of CPLEX (12.6.1 version) to solve a MILP problem.&lt;/p&gt;&#xA;&lt;p&gt;This is how I create 'normal' constraints:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;public void charge_discharge_constraints() throws IloException {&#xA;&#xA;    for (int k = 0; k &amp;lt; periods; k++) {&#xA;        for (int p = 0; p &amp;lt; num_p; p++) {&#xA;            IloLinearNumExpr exp = model.linearNumExpr();&#xA;            for (int n = 0; n &amp;lt; num_n; n++)&#xA;                exp.addTerm(1, bc_p[n][p][k]);&#xA;            exp.addTerm(1.0, bd_p[p][k]);&#xA;            IloRange constr = model.addGe(1, exp, &amp;quot;Non simultaneous charge discharge&amp;quot;);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now, I'm trying to add an 'indicator constraint' such as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if bd_p[p][k] == 1, -&amp;gt; (then) h_p[p][k] &amp;gt;= 4800.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;for every &lt;code&gt;p&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; indices.&lt;/p&gt;&#xA;&lt;p&gt;I tried to achieve this by doing:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;public void indicator_constraints() throws IloException {&#xA;&#xA;    for (int p = 0; p &amp;lt; num_p; p++) {&#xA;        for (int k = 0; k &amp;lt; periods; k++) {&#xA;            IloLinearNumExpr exp = model.linearNumExpr();&#xA;            exp.addTerm(1, h_p[p][k]);&#xA;            model.add(model.ifThen(model.eq(bd_p[p][k], 1.0), model.ge(exp, 4800.0)));&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But, after having observed the generated &amp;quot;.lp&amp;quot; file, I noticed that the indicator constraints I created use the double-arrow simbol (&amp;lt;-&amp;gt;), while my aim is to use the right-arrow symbol (-&amp;gt;).&lt;/p&gt;&#xA;&lt;p&gt;How could I achieve this?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT (to add more details):&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I can confirm that I have previously assigned a name to variables &lt;code&gt;bd_p&lt;/code&gt; and &lt;code&gt;h_p&lt;/code&gt;.&#xA;Indeed, inside the LP file:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;both of them are present in the &lt;code&gt;Binaries&lt;/code&gt; section (the section which lists the binary variables of the problem);&lt;/li&gt;&#xA;&lt;li&gt;they're correctly bounded between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Anyway, while I was expecting that the &lt;code&gt;indicator constraints&lt;/code&gt; which I generated should have used variables &lt;code&gt;bd_p&lt;/code&gt; and &lt;code&gt;h_p&lt;/code&gt;, actually (after a further investigation of the LP file) I can say that only the &lt;code&gt;h_p&lt;/code&gt; variable is involved in the &lt;code&gt;indicator constraints&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Indeed, the LP file contains &lt;code&gt;indicator constraints&lt;/code&gt; formulated as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;IloI785: x38223#36652 = 1 &amp;lt;-&amp;gt; h_p(27,17)#34158 &amp;gt;= 4800&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So, while &lt;code&gt;h_p&lt;/code&gt; variable compares, &lt;code&gt;bd_p&lt;/code&gt; variable is not present.&#xA;In place of &lt;code&gt;bd_p&lt;/code&gt; there's another variable called &lt;code&gt;x&lt;/code&gt; followed by a progressive number.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;bd_p&lt;/code&gt; is a binary variable, I previously assigned a name to it, it is correctly defined/bounded in the LP file, and it is used in many other &amp;quot;normal&amp;quot; (linear) constraints without any problem.&lt;/p&gt;&#xA;&lt;p&gt;I also tried to do this small change:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;public void indicator_constraints() throws IloException {  &#xA;    for (int p = 0; p &amp;lt; num_p; p++) {&#xA;            for (int k = 0; k &amp;lt; periods; k++) {&#xA;                IloLinearNumExpr exp_if = model.linearNumExpr();&#xA;                IloLinearNumExpr exp_then = model.linearNumExpr();&#xA;                exp_if.addTerm(1, bd_p[p][k]);&#xA;                exp_then.addTerm(1, h_p[p][k]);&#xA;                model.add(model.ifThen(model.eq(exp_if, 1.0), model.ge(exp_then, 4800.0)));&#xA;            }&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or, this other alternative:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;public void indicator_constraints() throws IloException {  &#xA;    for (int p = 0; p &amp;lt; num_p; p++) {&#xA;            for (int k = 0; k &amp;lt; periods; k++) {&#xA;                IloLinearNumExpr exp_if = model.linearNumExpr();&#xA;                IloLinearNumExpr exp_then = model.linearNumExpr();&#xA;                exp_if.addTerm(1, bd_p[p][k]);&#xA;                exp_then.addTerm(1, h_p[p][k]);&#xA;                IloRange constr_if = model.addEq(1.0, exp_if);&#xA;                IloRange constr_then = model.addLe(4800.0, exp_then);&#xA;                model.add(model.ifThen(constr_if, constr_then));&#xA;            }&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but with no improvement.&lt;/p&gt;&#xA;&lt;p&gt;So, I can't understand why in the LP file, the binary variable &lt;code&gt;h_p&lt;/code&gt; is replaced by a unnamed variable.&lt;/p&gt;&#xA;&lt;p&gt;Which could be the problem?&lt;/p&gt;&#xA;" OwnerUserId="4944" LastEditorUserId="4944" LastEditDate="2021-06-08T22:52:16.353" LastActivityDate="2021-06-08T22:52:16.353" Title="CPLEX Indicator Constraints in Java API" Tags="|mixed-integer-programming|cplex|constraint|indicator-constraints|java|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6409" PostTypeId="2" ParentId="6366" CreationDate="2021-06-08T17:24:03.783" Score="1" Body="&lt;p&gt;I think these are promising options:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;floyd-warshall&lt;/strong&gt; algorithm for dense graphs&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;johnson&lt;/strong&gt; algorithm for sparse graphs&lt;/li&gt;&#xA;&lt;li&gt;(not sure if it's worth to try and it will work well) &lt;strong&gt;dijkstra&lt;/strong&gt; algorithm parallelized for each vertex&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Regarding your question, a correct floyd-warshall implementation scans all the pairs.&lt;/p&gt;&#xA;" OwnerUserId="5651" LastActivityDate="2021-06-08T17:24:03.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6410" PostTypeId="2" ParentId="6408" CreationDate="2021-06-08T20:57:13.073" Score="2" Body="&lt;p&gt;I suspect you have not assigned names to your variables. Try doing that and then exporting the .lp file, and I think you will discover that the bidirectional constraint involves a variable that CPLEX added.&lt;/p&gt;&#xA;&lt;p&gt;As a small example, I created a model with a single binary variable &amp;quot;x&amp;quot;, a single continuous variable &amp;quot;y&amp;quot; (domain [0, 10]), and a single constraint that x = 1 -&amp;gt; y &amp;lt;= 5. CPLEX added binary variables x1 and x3 and converted the one constraint I had to two constraints: x3 = 1 &amp;lt;-&amp;gt; y =&amp;lt; 5 and x = 1 -&amp;gt; x3  = 1. I'm not sure why it does that, but I presume the programmers had their reasons.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-06-08T20:57:13.073" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6411" PostTypeId="2" ParentId="6403" CreationDate="2021-06-09T08:07:05.337" Score="1" Body="&lt;p&gt;Let's say you start from zero and you order up to &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Then you know that your next inventory will come in at time &lt;span class=&quot;math-container&quot;&gt;$t+T+L$&lt;/span&gt;, because you order at time &lt;span class=&quot;math-container&quot;&gt;$t+T$&lt;/span&gt; and it takes &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; time to arrive.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;An important assumption in this order strategy is that you won't inspect inventory during two consecutives &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; periods.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;So only at periods &lt;span class=&quot;math-container&quot;&gt;$T-1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$T+1$&lt;/span&gt;, ... you will observe inventory. And at that point you will need to order up to &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, knowing that you will order at &lt;span class=&quot;math-container&quot;&gt;$T+1$&lt;/span&gt; at the earliest and it always takes &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; time units to arrive.&lt;/p&gt;&#xA;" OwnerUserId="329" LastActivityDate="2021-06-09T08:07:05.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6412" PostTypeId="1" AcceptedAnswerId="6416" CreationDate="2021-06-09T08:27:02.760" Score="2" ViewCount="145" Body="&lt;p&gt;Consider &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; finite sets of integer points &lt;span class=&quot;math-container&quot;&gt;$P_m$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$m=1,\ldots,M$&lt;/span&gt;. Let&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A = \left\{x_m\in\operatorname{conv}P_m, m=1,\dots,M, \sum_{m=1}^MN_mx_m=0\right\}$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$B =\operatorname{conv}\left\{x_m\in P_m, m=1,\dots,M, \sum_{m=1}^MN_mx_m=0\right\}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$N_m$&lt;/span&gt; is a matrix of dimension compatible with &lt;span class=&quot;math-container&quot;&gt;$x_m$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\operatorname{conv}P_m$&lt;/span&gt; is the convex hull of the points in &lt;span class=&quot;math-container&quot;&gt;$P_m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering if it is possible to prove that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$B\subseteq A$$&lt;/span&gt;&#xA;and how.&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="766" LastEditDate="2021-06-09T12:22:08.483" LastActivityDate="2021-06-09T19:19:52.517" Title="How to prove the following statement about convex hulls?" Tags="|integer-programming|convex-hull|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6413" PostTypeId="1" CreationDate="2021-06-09T10:11:07.017" Score="3" ViewCount="1208" Body="&lt;p&gt;I am solving a MILP using Gurobi and Pyomo. I would like to obtain as many &lt;em&gt;optimal&lt;/em&gt; solutions as possible. Here is what I have so far:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;opt = SolverFactory('gurobi_persistent')&#xA;n_of_s = 10&#xA;opt.set_instance(model)&#xA;opt.set_gurobi_param('PoolSolutions', n_of_s)&#xA;opt.set_gurobi_param('PoolSearchMode', 2)&#xA;opt.solve(model, tee=True)&#xA;opt.set_gurobi_param('SolutionNumber',2) &#xA;model.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;At some point Gurobi displays &lt;code&gt;Solution count 3: 5000 5000 5000&lt;/code&gt;. However, when trying to access the value of optimal variables, I can only access one solution.&lt;/p&gt;&#xA;&lt;p&gt;I have tried using the &lt;code&gt;Xn&lt;/code&gt; attribute, but Gurobi states &lt;code&gt;AttributeError: '_GeneralVarData' object has no attribute 'Xn'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5661" LastActivityDate="2021-06-25T10:49:51.423" Title="Find multiple solutions using pyomo and gurobi" Tags="|python|gurobi|pyomo|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6414" PostTypeId="1" AcceptedAnswerId="6415" CreationDate="2021-06-09T13:58:09.473" Score="2" ViewCount="432" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;A constructive heuristic is a type of heuristic method which starts with an empty solution and repeatedly extends the current solution until a complete solution is obtained. (Wikipedia)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Which constructive heuristics exist for the TSP? I know the nearest neighbour algorithm, the savings method and the Match Twice and Stitch (MTS). Which do furthermore exist?&lt;/p&gt;&#xA;" OwnerUserId="5571" LastActivityDate="2021-06-09T15:54:16.590" Title="Which constructive heuristics exist for the TSP?" Tags="|traveling-salesman|heuristics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6415" PostTypeId="2" ParentId="6414" CreationDate="2021-06-09T15:54:16.590" Score="6" Body="&lt;p&gt;These CH work:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Nearest Neighbor&lt;/li&gt;&#xA;&lt;li&gt;First Fit, First Fit Decreasing, Strongest Fit, Strongest Fit Decreasing&lt;/li&gt;&#xA;&lt;li&gt;Cheapest Insertion, Regret Insertion&lt;/li&gt;&#xA;&lt;li&gt;Christofides algorithm (doesn't really deal well with extra constraints)&lt;/li&gt;&#xA;&lt;li&gt;Clarke-Wright algorithm (more for vanilla VRP, doesn't really deal well with extra constraints)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://press.princeton.edu/books/paperback/9780691163529/in-pursuit-of-the-traveling-salesman&quot; rel=&quot;noreferrer&quot;&gt;Cook's book &amp;quot;In Pursuit of the Traveling Salesman&amp;quot;&lt;/a&gt; explains some of these very well.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-06-09T15:54:16.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6416" PostTypeId="2" ParentId="6412" CreationDate="2021-06-09T16:10:31.140" Score="3" Body="&lt;p&gt;I think it should be possible.&lt;/p&gt;&#xA;&lt;p&gt;Firstly, let us see if we can establish that &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is convex. Take&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}X &amp;amp;= (x_1,\ldots,x_M)\in A\\Y&amp;amp;=(y_1,\ldots,y_M)\in A.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$0\leq\lambda\leq 1$&lt;/span&gt;. Then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\lambda X + (1-\lambda) Y = (\lambda x_1 + (1-\lambda)y_1,\ldots,\lambda x_M + (1-\lambda)y_M).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;\begin{align}N_1x_1 + \ldots + N_Mx_M &amp;amp;= 0\\N_1y_1 + \ldots + N_My_M &amp;amp;= 0,\end{align}&lt;/span&gt; we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$N_1(\lambda x_1 + (1-\lambda) y_1) +\ldots+ N_M(\lambda x_M + (1-\lambda) y_M) = 0.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, &lt;span class=&quot;math-container&quot;&gt;$\forall i=1,\ldots,M, \lambda x_i + (1-\lambda) y_i\in\operatorname{conv}(P_i)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Thus, convexity of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is established.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is the convex hull of a subset of points of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;. Let this subset be &lt;span class=&quot;math-container&quot;&gt;$K\subseteq A$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So, &lt;span class=&quot;math-container&quot;&gt;$B = \operatorname{conv}(K)\subseteq\operatorname{conv}(A)=A$&lt;/span&gt;, since &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is convex.&lt;/p&gt;&#xA;" OwnerUserId="5669" LastEditorUserId="123" LastEditDate="2021-06-09T19:19:52.517" LastActivityDate="2021-06-09T19:19:52.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6417" PostTypeId="2" ParentId="6363" CreationDate="2021-06-09T19:27:21.113" Score="1" Body="&lt;p&gt;Figured it out. It works exactly they way I originally intended to do it in my question. See &lt;a href=&quot;https://speekenbrink-lab.github.io/modelling/2019/08/29/fit_kf_rl_2.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; tutorial for detailed information on how to actually implement the procedure with real data.&lt;/p&gt;&#xA;" OwnerUserId="5602" LastActivityDate="2021-06-09T19:27:21.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6419" PostTypeId="1" CreationDate="2021-06-10T13:56:59.843" Score="4" ViewCount="221" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$T=(V, E')$&lt;/span&gt; be a spanning tree of a graph &lt;span class=&quot;math-container&quot;&gt;$G=(V, E)$&lt;/span&gt;. Rather than verifying for any subset of vertices &lt;span class=&quot;math-container&quot;&gt;$S\subseteq V$&lt;/span&gt; that &lt;span class=&quot;math-container&quot;&gt;$|E'(S)|=|S|-1$&lt;/span&gt;, is there an efficient way to satisfy the spanning tree constraint (as the complexity for calculating all vertices subsets is exponential)?&lt;/p&gt;&#xA;" OwnerUserId="5681" LastEditorUserId="123" LastEditDate="2021-06-10T14:11:36.053" LastActivityDate="2021-06-10T19:23:08.793" Title="An efficient Integer programming model for the minimum spanning tree problem?" Tags="|linear-programming|integer-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6420" PostTypeId="1" AcceptedAnswerId="6464" CreationDate="2021-06-10T14:46:14.717" Score="4" ViewCount="214" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;A constructive heuristic is a type of heuristic method which starts&#xA;with an empty solution and repeatedly extends the current solution&#xA;until a complete solution is obtained. (Wikipedia)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Which constructive heuristics exist for the time-dependent TSP? Time dependent in the sense that the travel time depends on the departure time. I already asked about the time-independent TSP (&lt;a href=&quot;https://or.stackexchange.com/questions/6414/which-constructive-heuristics-exist-for-the-tsp&quot;&gt;Which constructive heuristics exist for the TSP?&lt;/a&gt;). I think the nearest neighbor and the &amp;quot;fit&amp;quot; heuristics like first fit also work for a time-dependent TSP.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is it possible to apply the cheapest insertion, christofides algorithm, and the Clarke-Wright algorithm for a time-dependent TSP? Right now, I think that the implementation is difficult for them because the graph is dependent on time and, for example, an insertion changes also the result of other paths.&lt;/li&gt;&#xA;&lt;li&gt;Do other constructive heuristics exist for the time-dependent TSP?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5571" LastEditorUserId="36" LastEditDate="2021-06-12T17:53:45.780" LastActivityDate="2021-06-18T23:07:01.450" Title="Which constructive heuristics exist for the time-dependent TSP?" Tags="|algorithms|traveling-salesman|heuristics|approximation-algorithms|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6421" PostTypeId="1" AcceptedAnswerId="6423" CreationDate="2021-06-10T17:32:37.877" Score="4" ViewCount="670" Body="&lt;p&gt;I know that a max flow problem for undirected graphs has a standard reduction to directed graphs in order to apply Ford–Fulkerson algorithm and getting a feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;Here's my doubt. An undirected edge &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt; with capacity &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, will correspond to two directed edges &lt;span class=&quot;math-container&quot;&gt;$(u,v), (v,u)$&lt;/span&gt; both with capacity &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. However, the solution cannot use both edges since I would lose the correspondence with the original problem.&lt;/p&gt;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="36" LastEditDate="2021-06-12T18:11:32.697" LastActivityDate="2021-06-12T18:11:32.697" Title="Max-flow of undirected graph" Tags="|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6422" PostTypeId="2" ParentId="6419" CreationDate="2021-06-10T19:23:08.793" Score="3" Body="&lt;p&gt;To confirm that &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is a tree, you need to confirm that (a) it is connected and (b) &lt;span class=&quot;math-container&quot;&gt;$\vert E'\vert = \vert V \vert - 1$&lt;/span&gt;. The second part is trivial. To confirm it is connected, start at an arbitrarily chosen node &lt;span class=&quot;math-container&quot;&gt;$v\in V$&lt;/span&gt; and label all nodes adjacent to &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;. For each freshly labeled node, label all unlabeled nodes adjacent to it and proceed recursively until you run out of nodes to process. If all nodes ended up labeled, &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is connected, and you are done.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-06-10T19:23:08.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6423" PostTypeId="2" ParentId="6421" CreationDate="2021-06-10T19:31:45.663" Score="4" Body="&lt;p&gt;If a flow somehow uses both &lt;span class=&quot;math-container&quot;&gt;$(u, v)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(v, u)$&lt;/span&gt;, it is equivalent to another flow that only uses one of them. So if &lt;span class=&quot;math-container&quot;&gt;$f_{uv} \ge f_{vu} &amp;gt; 0$&lt;/span&gt;, treat it as the equivalent flow &lt;span class=&quot;math-container&quot;&gt;$\hat{f}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\hat{f}_{a} = f_a$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$a\notin\lbrace (u, v), (v, u) \rbrace$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\hat{f}_{vu} = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\hat{f}_{uv} = f_{uv} - f_{vu}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I'm tempted to say that this will not happen -- that a maximal flow will always use at most one of &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(v,u)$&lt;/span&gt; -- but in some cases that might depend on the efficiency (or dopiness) of the algorithm being used to compute it.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-06-10T19:31:45.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6424" PostTypeId="1" CreationDate="2021-06-11T00:09:19.050" Score="0" ViewCount="153" Body="&lt;p&gt;I need some advice, any hints will be appreciated.&#xA;I have a MILP and I am using Gurobi to solve it. I have a feasible integer solution. When I use &lt;code&gt;mipstart&lt;/code&gt;, after 30 min of execution the gap is extremely high (100%). It advances a little.&lt;/p&gt;&#xA;&lt;p&gt;However, when I do not provide the known integer feasible solution, after 30 min an integer solution is found.&lt;/p&gt;&#xA;&lt;p&gt;So, should I use the feasible solution?&#xA;If not, are there any parameters in Gurobi that I can adjust and make the lower bound better?&lt;/p&gt;&#xA;" OwnerUserId="4760" LastEditorUserId="36" LastEditDate="2021-06-12T18:16:02.547" LastActivityDate="2021-06-12T18:16:02.547" Title="Problems with a MILP" Tags="|mixed-integer-programming|gurobi|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6425" PostTypeId="1" CreationDate="2021-06-11T02:09:51.803" Score="-2" ViewCount="142" Body="&lt;p&gt;I am very new to LP, Goal Seek, Decision Models etc and I have a multiple-objective decision making problem that may or may not require a mix of techniques although I am trying to solve it purely using LP + Excel Solver. I do not know where to begin.&lt;/p&gt;&#xA;&lt;p&gt;I cross-posted it in &lt;a href=&quot;https://math.stackexchange.com/questions/4169612/modm-to-create-balanced-groups-of-students-to-maximise-diversity&quot;&gt;math&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Approach Ideas&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Would it be easiest to sum each category first and then use that data? e.g. 22 females, 23 males, 20 Chinese, 13 British etc.&lt;/p&gt;&#xA;&lt;p&gt;Is it correct to say the objective functions are to &lt;code&gt;maximise the diversity of members within groups&lt;/code&gt; and &lt;code&gt;minimise the average differences between groups&lt;/code&gt;? And the constraints are 1,2,3,4 below?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Students are often allocated into syndicate groups to work together on various projects, which are subsequently assessed as a group work. The groups formed should maximise the diversity of members within groups and minimise the average differences between groups.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Data&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The data provided contains the records for 45 students with the relevant characteristics for each one of them given through the five columns: Student ID (S), Nationality (N), Cultural Background (C), Gender (G) and Quantitative Background (Q).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E3LmA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E3LmA.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Requirements&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Using any resources available to you, prepare a model that will be able to perform automatic allocation of students into groups while satisfying as much as possible these ideal targets:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Groups should be of the same size if possible. The ideal size is 5 members per group.&lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;Groups should be balanced with respect to gender (G).&lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;Groups should be balanced with respect to quantitative background (Q).&lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;Groups should be balanced with respect to ethnic background in a very specific way. According to the most up-to-date research on harnessing cultural diversity:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5682" LastEditorUserId="5682" LastEditDate="2021-06-12T02:34:33.963" LastActivityDate="2021-06-12T02:34:33.963" Title="MODM to create balanced groups of students to maximise diversity" Tags="|linear-programming|multicriteria-decision-analysis|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="6426" PostTypeId="1" AcceptedAnswerId="6431" CreationDate="2021-06-11T08:20:43.950" Score="5" ViewCount="139" Body="&lt;p&gt;I need to solve a series of single parameter black-box minimization problem. The underlying cost functions are quite simple. They always have the same shape: a global minimum inside a fixed interval (-15000; 15000).&lt;/p&gt;&#xA;&lt;p&gt;The constraints are :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The function is not differentiable;&lt;/li&gt;&#xA;&lt;li&gt;The function is slow to evaluate.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I can solve these problems using a coarse scan followed by a fine scan. But I need between 30 and 50 evaluations. I'm sure that there is a better way to do it, but I can't find how.&lt;/p&gt;&#xA;&lt;p&gt;Two examples of these cost functions :&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9UWPd.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9UWPd.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/g6HB5.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/g6HB5.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5148" LastActivityDate="2021-06-27T13:56:28.513" Title="Black-box optimization of a single parameter function with high cost evaluation" Tags="|optimization|convex-optimization|global-optimization|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6427" PostTypeId="1" AcceptedAnswerId="6433" CreationDate="2021-06-11T10:49:11.800" Score="4" ViewCount="40" Body="&lt;p&gt;I am using the incumbent callback CPXsetincumbentcallbackfunc to identify integral solutions that do not satisfy nonlinear constraints that are not explicitly part of the constraint set. When such a solution is found, I declare the solution to be infeasible by setting:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;*isfeas_p = 0;&#xA;*useraction_p = CPX_CALLBACK_SET;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My question is if I have a heuristic to convert the infeasible solution into a feasible one, could I modify the values in the provided &lt;code&gt;x[]&lt;/code&gt; array of the callback accordingly and set &lt;code&gt;*isfeas_p = 1&lt;/code&gt;? Would that make CPLEX use the incumbent that I constructed?&lt;/p&gt;&#xA;" OwnerUserId="5689" LastEditorUserId="36" LastEditDate="2021-06-11T12:20:24.080" LastActivityDate="2021-06-11T18:16:56.800" Title="behaviour of CPXsetincumbentcallbackfunc" Tags="|mixed-integer-programming|cplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6428" PostTypeId="1" AcceptedAnswerId="6429" CreationDate="2021-06-11T12:55:07.300" Score="4" ViewCount="386" Body="&lt;p&gt;I have a graph with  &lt;span class=&quot;math-container&quot;&gt;$N=12$&lt;/span&gt; nodes. Some nodes may not have any edge between them. every edge has a weight. How to find the optimal partitioning of the graph so that total weight in the system is maximised.&lt;/p&gt;&#xA;&lt;p&gt;Let the weight matrix is given by &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; of size &lt;span class=&quot;math-container&quot;&gt;$N\times N$&lt;/span&gt;. The diagonal elements of &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; are ones, therefore, if there is no edge between two nodes, the corresponding element in &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is 1.&lt;/p&gt;&#xA;&lt;p&gt;Each part can have maximum 3 nodes and minimum 1 node. I want to find the optimal number of parts, and the nodes belonging to each part.&lt;/p&gt;&#xA;&lt;p&gt;I want to find the partition that gives the maximum total weight sum.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If there is only one node in a part, its weight sum is one.&lt;/li&gt;&#xA;&lt;li&gt;If there are two nodes in a part, then the weight sum is 1+1+weight&#xA;between the nodes.&lt;/li&gt;&#xA;&lt;li&gt;If there are three nodes in a part, then the weight sum is 1+1+1+weights among the nodes.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;EDIT: Data Sample&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$N=15$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;w={{0   0.0246848918296812  0.0222939272001262  0   0   0   0   0   0   0   0   0   0   0.0222250595626355  0},&#xA;{0  0   0.0223369829389658  0   0   0   0   0.0222127811912141  0.0222755933905518  0   0   0   0.0221795079043392  0.0223864339914097  0},&#xA;{0  0   0   0   0   0   0   0   0   0   0   0   0   0.0224654059932641  0},&#xA;{0  0   0   0   0.0228810151692974  0.0263781458115140  0   0   0   0   0   0.0225237815238005  0.0222085450604959  0.0224040301919779  0.0221851115072885},&#xA;{0  0   0   0   0   0.0221812062988533  0   0   0   0   0   0   0   0   0.0221772974146853},&#xA;{0  0   0   0   0   0   0   0   0   0   0   0.0221782447553519  0.0221942685958015  0   0.0221829507373709},&#xA;{0  0   0   0   0   0   0   0.0225053331512079  0.0239075792682171  0   0   0   0   0.0222343245946427  0},&#xA;{0  0   0   0   0   0   0   0   0.0224947575431974  0.0259331832060178  0   0.0227525834204816  0.0223768752560173  0.0223839654721248  0},&#xA;{0  0   0   0   0   0   0   0   0   0   0   0   0.0223333187890952  0.0233707396802904  0},&#xA;{0  0   0   0   0   0   0   0   0   0   0.0247836632820100  0.0231195566008868  0.0237113172691831  0.0224461979778054  0.0222144718706271},&#xA;{0  0   0   0   0   0   0   0   0   0   0   0.0359523557525197  0.0232883288308498  0   0.0285710707914430},&#xA;{0  0   0   0   0   0   0   0   0   0   0   0   0.0221951174734581  0.0223024273663844  0.0225769922365633},&#xA;{0  0   0   0   0   0   0   0   0   0   0   0   0   0.0237292800085860  0.0222613790897664},&#xA;{0  0   0   0   0   0   0   0   0   0   0   0   0   0   0},&#xA;{0  0   0   0   0   0   0   0   0   0   0   0   0   0   0}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="836" LastEditorUserId="36" LastEditDate="2021-06-12T17:12:43.983" LastActivityDate="2021-06-13T03:14:46.367" Title="How to partition a graph with optimal number of groups?" Tags="|optimization|modeling|graphs|heuristics|clustering|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6429" PostTypeId="2" ParentId="6428" CreationDate="2021-06-11T14:12:31.487" Score="11" Body="&lt;p&gt;Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,g}$&lt;/span&gt; indicate whether node &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,\dots,N\}$&lt;/span&gt; appears in group &lt;span class=&quot;math-container&quot;&gt;$g\in\{1,\dots,N\}$&lt;/span&gt;, and let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j,g}$&lt;/span&gt; indicate whether edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; appears in group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;.  You want to maximize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i&amp;lt;j}\sum_g w_{i,j} y_{i,j,g}$$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_g x_{i,g} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \tag1 \\&#xA;\sum_i x_{i,g} &amp;amp;\le 3 &amp;amp;&amp;amp;\text{for all $g$} \\&#xA;y_{i,j,g} &amp;amp;\le x_{i,g} &amp;amp;&amp;amp;\text{for all $i&amp;lt;j$ and all $g$} \\&#xA;y_{i,j,g} &amp;amp;\le x_{j,g} &amp;amp;&amp;amp;\text{for all $i&amp;lt;j$ and all $g$} \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This formulation assumes the edge weights are nonnegative.  In that case, you can optionally relax the equality constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\le 1$&lt;/span&gt;.&#xA;If instead the edge weights might be negative, you also need to impose&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{i,j,g} \ge x_{i,g} + x_{j,g} - 1 \quad \text{for all $i&amp;lt;j$ and all $g$}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For solvers that don't exploit symmetry with respect to &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, you might want to add symmetry-breaking constraints.  For example, you can impose descending order of group weight as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z_g &amp;amp;= \sum_{i,j} w_{i,j} y_{i,j,g} &amp;amp;&amp;amp;\text{for all $g$} \\&#xA;z_g &amp;amp;\ge z_{g+1} &amp;amp;&amp;amp;\text{for $g&amp;lt;N$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Applying Dantzig-Wolfe decomposition with one block per group yields identical blocks and a set partitioning formulation that you can solve via &lt;em&gt;dynamic&lt;/em&gt; column generation (specifically, branch-and-price with Ryan-Foster branching).  By the way, the SAS decomposition algorithm does this for you automatically.  An alternative approach is to use &lt;em&gt;static&lt;/em&gt; column generation, as follows.  Let &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; be the set of all potential groups (node subsets of sizes &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;).  For &lt;span class=&quot;math-container&quot;&gt;$g\in G$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$N_g$&lt;/span&gt; be the nodes in group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$E_g$&lt;/span&gt; be the edges in group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, and let binary variable &lt;span class=&quot;math-container&quot;&gt;$u_g$&lt;/span&gt; indicate whether group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is used.  The problem is to maximize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{g\in G} \left(\sum_{(i,j)\in E_g} w_{i,j}\right) u_g$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{g\in G:\ i\in N_g} u_g &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \tag2&#xA;\end{align}&lt;/span&gt;&#xA;For &lt;span class=&quot;math-container&quot;&gt;$N=15$&lt;/span&gt;, this set partitioning formulation has &lt;span class=&quot;math-container&quot;&gt;$|G|=N+\binom{N}{2}+\binom{N}{3}=575$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$15$&lt;/span&gt; constraints, and the symmetry with respect to group is avoided.  If the weights &lt;span class=&quot;math-container&quot;&gt;$w_{i,j}$&lt;/span&gt; are nonnegative, you can omit the &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; groups of size &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and relax the set partitioning constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; to a set packing constraint (replacing &lt;span class=&quot;math-container&quot;&gt;$=1$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\le 1$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;By request, here is the SAS code for the static column generation formulation:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;data indata;&#xA;   input i j w;&#xA;   datalines;&#xA; 1  2 0.0246848918296812&#xA; 1  3 0.0222939272001262&#xA; 1 14 0.0222250595626355&#xA; 2  3 0.0223369829389658&#xA; 2  8 0.0222127811912141&#xA; 2  9 0.0222755933905518&#xA; 2 13 0.0221795079043392&#xA; 2 14 0.0223864339914097&#xA; 3 14 0.0224654059932641&#xA; 4  5 0.0228810151692974&#xA; 4  6 0.0263781458115140&#xA; 4 12 0.0225237815238005&#xA; 4 13 0.0222085450604959&#xA; 4 14 0.0224040301919779&#xA; 4 15 0.0221851115072885&#xA; 5  6 0.0221812062988533&#xA; 5 15 0.0221772974146853&#xA; 6 12 0.0221782447553519&#xA; 6 13 0.0221942685958015&#xA; 6 15 0.0221829507373709&#xA; 7  8 0.0225053331512079&#xA; 7  9 0.0239075792682171&#xA; 7 14 0.0222343245946427&#xA; 8  9 0.0224947575431974&#xA; 8 10 0.0259331832060178&#xA; 8 12 0.0227525834204816&#xA; 8 13 0.0223768752560173&#xA; 8 14 0.0223839654721248&#xA; 9 13 0.0223333187890952&#xA; 9 14 0.0233707396802904&#xA;10 11 0.0247836632820100&#xA;10 12 0.0231195566008868&#xA;10 13 0.0237113172691831&#xA;10 14 0.0224461979778054&#xA;10 15 0.0222144718706271&#xA;11 12 0.0359523557525197&#xA;11 13 0.0232883288308498&#xA;11 15 0.0285710707914430&#xA;12 13 0.0221951174734581&#xA;12 14 0.0223024273663844&#xA;12 15 0.0225769922365633&#xA;13 14 0.0237292800085860&#xA;13 15 0.0222613790897664&#xA;;&#xA;&#xA;proc optmodel;&#xA;   num n = 15;&#xA;   set NODES = 1..n;&#xA;   set EDGES = {i in 1..n-1, j in i+1..n};&#xA;   num w {EDGES} init 0;&#xA;   read data indata into [i j] w;&#xA;   num numGroups init 0;&#xA;   set GROUPS = 1..numGroups;&#xA;   set NODES_g {GROUPS};&#xA;   set &amp;lt;num,num&amp;gt; EDGES_g {GROUPS};&#xA;   num groupWeight {g in GROUPS} = sum {&amp;lt;i,j&amp;gt; in EDGES_g[g]} w[i,j];&#xA;   for {i in NODES} do;&#xA;      numGroups = numGroups + 1;&#xA;      NODES_g[numGroups] = {i};&#xA;      EDGES_g[numGroups] = {};&#xA;   end;&#xA;   for {&amp;lt;i,j&amp;gt; in EDGES} do;&#xA;      numGroups = numGroups + 1;&#xA;      NODES_g[numGroups] = {i,j};&#xA;      EDGES_g[numGroups] = {&amp;lt;i,j&amp;gt;};&#xA;   end;&#xA;   for {&amp;lt;i,j&amp;gt; in EDGES, &amp;lt;(j),k&amp;gt; in EDGES} do;&#xA;      numGroups = numGroups + 1;&#xA;      NODES_g[numGroups] = {i,j,k};&#xA;      EDGES_g[numGroups] = {&amp;lt;i,j&amp;gt;,&amp;lt;i,k&amp;gt;,&amp;lt;j,k&amp;gt;};&#xA;   end;&#xA;&#xA;   var IsGroup {GROUPS} binary;&#xA;   max TotalWeight = sum {g in GROUPS} groupWeight[g] * IsGroup[g];&#xA;   con OneGroupPerNode {i in NODES}:&#xA;      sum {g in GROUPS: i in NODES_g[g]} IsGroup[g] = 1;&#xA;&#xA;   solve;&#xA;   for {g in GROUPS: IsGroup[g].sol &amp;gt; 0.5} put NODES_g[g];&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Whichever approach you use, the optimal objective value for your sample data is &lt;span class=&quot;math-container&quot;&gt;$0.3693906073$&lt;/span&gt;, and an optimal partition is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\{&#xA;\{1,2,3\},&#xA;\{4,5,6\},&#xA;\{7,9,14\},&#xA;\{8,10,13\},&#xA;\{11,12,15\}&#xA;\}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-06-13T03:14:46.367" LastActivityDate="2021-06-13T03:14:46.367" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="6430" PostTypeId="2" ParentId="5211" CreationDate="2021-06-11T17:02:57.413" Score="4" Body="&lt;p&gt;A short little note about computing gaps just appeared in 4OR:&lt;/p&gt;&#xA;&lt;p&gt;Laporte, G., Toth, P. A gap in scientific reporting. 4OR-Q J Oper Res (2021). &lt;a href=&quot;https://doi.org/10.1007/s10288-021-00483-0&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1007/s10288-021-00483-0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-06-11T17:02:57.413" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6431" PostTypeId="2" ParentId="6426" CreationDate="2021-06-11T17:59:56.193" Score="5" Body="&lt;p&gt;Given that your function is apparently unimodal (single local minimum, which is global), you might try &lt;a href=&quot;https://en.wikipedia.org/wiki/Golden-section_search&quot; rel=&quot;noreferrer&quot;&gt;golden section search&lt;/a&gt;. The first four function evaluations result in about a 40% reduction in the initial interval. Each additional function thereafter again reduces the remaining interval by about 40%.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-06-11T17:59:56.193" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6432" PostTypeId="2" ParentId="6425" CreationDate="2021-06-11T18:11:42.590" Score="1" Body="&lt;p&gt;This is not a direct answer, but I can point you to two papers that are closely related to what you are working on.&lt;/p&gt;&#xA;&lt;p&gt;[1] Rubin, Paul A. and Lihui Bai (2015). “Forming Competitively Balanced Teams”. IIE Transactions 47, 6, pp. 620-633. DOI: 10.1080/0740817X.2014.953643. eprint: &lt;a href=&quot;http://dx.doi.org/10.1080/0740817X.2014.953643&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://dx.doi.org/10.1080/0740817X.2014.953643&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;[2] Daniel Solow, Jie Ning, Jieying Zhu &amp;amp; Yishen Cai (2020). Improved heuristics for finding balanced teams, IISE Transactions 52, 12, pp. 1312-1323. DOI: 10.1080/24725854.2020.1732506.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-06-11T18:11:42.590" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6433" PostTypeId="2" ParentId="6427" CreationDate="2021-06-11T18:16:56.800" Score="2" Body="&lt;p&gt;Disclaimer: I do not use the C API. That said, I am rather confident that there is no way to set a heuristic solution inside the incumbent callback. What you can do is identify the feasible solution inside the incumbent callback and queue it up somewhere in your program memory. Add a heuristic callback, and in the heuristic callback check to see if there is a solution queued and, if so, whether it is better in objective terms than the current incumbent (which might have improved between the last call to the incumbent callback and the current call to the heuristic callback). If you do have a superior solution queued up, add it in the heuristic callback (and delete it from the queue).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-06-11T18:16:56.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6434" PostTypeId="1" AcceptedAnswerId="6435" CreationDate="2021-06-11T20:08:29.647" Score="3" ViewCount="443" Body="&lt;p&gt;When I think of Benders Decomposition, I typically think of two-stage stochastic programs. However, I was wondering if there is any application to decomposing a large scale deterministic MILP with only one sub problem each iteration. A potential application could be say a large scale supply chain model where facility location decisions are binary and flow variables and inventory decisions are continuous. For illustration, assume we have an MILP problem split into a master/sub problem as in benders:&lt;/p&gt;&#xA;&lt;p&gt;The master problem (MP)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x,\theta} c^T x + \theta\\&#xA;\text{s.t. } Ax \leq b\\&#xA;x \geq 0\\&#xA;\text{opt. cuts}\\&#xA;x \in  \mathbb{Z}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The Sub problem (SP) where &lt;span class=&quot;math-container&quot;&gt;$(\hat{x_k},\hat{\theta_k})$&lt;/span&gt; is the solution to MP at iteration &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_y d^Ty\\&#xA;\text{s.t. } Wy = h-T\hat{x_k}\\&#xA;y\geq 0 \\&#xA;y \in \mathbb{R}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We would then solve the MP and SP for &lt;span class=&quot;math-container&quot;&gt;$k = 0,1,2,\dots,n$&lt;/span&gt; adding optimality cuts (assume the subproblem is always feasible for this example) to the master problem in the form &lt;span class=&quot;math-container&quot;&gt;$\theta \geq \pi_k^T(h-Tx)$&lt;/span&gt; at each iteration where &lt;span class=&quot;math-container&quot;&gt;$\pi_k$&lt;/span&gt; are the optimal dual vectors.&lt;/p&gt;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&lt;p&gt;Does having only one subproblem each iteration (as opposed to a multi-cut Benders approach to stochastic programs) limit the effectiveness and number of cuts added to the MP?&lt;/p&gt;&#xA;&lt;p&gt;For a very large MILP, would decomposing the problem in this way lead to any benefit or does the eventual large number of cuts added to the MP make it too difficult to solve?&lt;/p&gt;&#xA;&lt;p&gt;Is there a name for this approach so that I can find any literature or published applications where I could learn more?&lt;/p&gt;&#xA;" OwnerUserId="5698" LastEditorUserId="500" LastEditDate="2021-06-11T20:28:10.843" LastActivityDate="2021-06-11T20:28:10.843" Title="Benders Decomposition for deterministic MILP" Tags="|mixed-integer-programming|benders-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6435" PostTypeId="2" ParentId="6434" CreationDate="2021-06-11T20:25:58.910" Score="7" Body="&lt;p&gt;Is there a name for this? Yes: Benders decomposition. I'm pretty sure the seminal work by Jack Benders (1962) had only a single LP subproblem (and was most definitely deterministic in nature).&lt;/p&gt;&#xA;&lt;p&gt;Does having a single subproblem limit the effectiveness and number of cuts? I don't think so.&lt;/p&gt;&#xA;&lt;p&gt;Is there a benefit to doing it? I think the answer is generally no, with three exceptions. In Benders's day, mainframes had very limited memory, so decomposition might be the only way to handle an industrial-size problem. Today we have way more memory, much faster processors (and more than one per machine) and algorithms tailored for sparse matrices (which most large problems have). So while I have not tested it, my theory is that most single-subproblem decompositions are better left as a single MILP.&lt;/p&gt;&#xA;&lt;p&gt;The first exception is the current version of what I suspect motivated Benders. If your problem is so big that, even in sparse matrix form, it won't fit in memory, decomposition may be your only hope.&lt;/p&gt;&#xA;&lt;p&gt;The second exception is when the original MILP has &amp;quot;big M&amp;quot; constraints of the form &amp;quot;enforce this constraint if binary variable x is 1 but not if x is 0&amp;quot; (or vice versa), and the best known safe value of M is annoyingly large (which makes for loose bounds and possibly numerical problems). For that case, there is something I know as &amp;quot;combinatorial Benders cuts&amp;quot;, in which you may well have only one subproblem but by decomposing you are able to get rid of those pesky Ms.&lt;/p&gt;&#xA;&lt;p&gt;The third exception, sometimes known as &amp;quot;logical Benders decomposition&amp;quot; (or, when I do it, &amp;quot;illogical Benders decomposition&amp;quot;), is a bit more esoteric. It uses what may well be a single subproblem that is &lt;em&gt;not&lt;/em&gt; a linear program. It is used when the relationship between the integer (usually binary) variables and the continuous variables cannot be expressed with linear equations and inequalities.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-06-11T20:25:58.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6436" PostTypeId="1" CreationDate="2021-06-12T04:29:17.203" Score="5" ViewCount="28" Body="&lt;p&gt;In queuing theory and stochastic process, there are many papers that have applied fluid and diffusion models to approximate the original models. However, the concepts and basics of these models are not comprehensively discussed. I would be thankful if someone can recommend some references covering these topics as basic as possible.&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2021-06-12T04:29:17.203" Title="What are some references for Fluid and Diffusion models in Queuing?" Tags="|reference-request|queuing-theory|stochastic-process|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6437" PostTypeId="1" AcceptedAnswerId="6442" CreationDate="2021-06-12T23:42:24.153" Score="3" ViewCount="645" Body="&lt;p&gt;I was wondering to know whether Dijkstra's algorithm can find the optimal solution for a weighted and directed shortest paths problem where: 1) for each arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i&amp;gt;j$&lt;/span&gt; and 2) it is not always possible to go from vertex &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to vertex &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$i&amp;gt;j$&lt;/span&gt; (some other constraints should be satisfied too). Note that vising all vertices is not mandatory; we just need to go from vertex &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to vertex &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; (while respecting the problem constraints.)&lt;/p&gt;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="5598" LastActivityDate="2021-06-13T19:21:36.643" Title="Does Dijkstra's algorithm find the optimal solution for a weighted and directed shortest paths problem?" Tags="|algorithms|global-optimality|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6438" PostTypeId="1" CreationDate="2021-06-13T08:10:45.557" Score="5" ViewCount="196" Body="&lt;p&gt;I have recently been looking at some facility location problems and how they change in the presence of the motorway (or highway, freeway) etc. Tried to visualize some observations with the Voronoi diagrams. But doing it by hand becomes extremely tedious when the number of points increases. Wanted to ask for some recommendation of the software that might do the trick? Looking for a software that would allow for L1 and L2 metrics but it would be nice if could also do a general Lp. Was curious if there is a simple &amp;quot;go to&amp;quot; software among OR researchers or does everyone do it on their own?&lt;/p&gt;&#xA;" OwnerUserId="4465" LastActivityDate="2021-06-13T19:24:50.983" Title="Which software to use for Voronoi diagrams?" Tags="|software|facility-location|online-resources|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6441" PostTypeId="2" ParentId="6364" CreationDate="2021-06-13T19:11:41.083" Score="2" Body="&lt;p&gt;Assuming you are fine with turning the warnings off, you can change the verbosity level of the data consistency checks that you get from docplex by changing the value of &lt;code&gt;datacheck&lt;/code&gt; parameter. You can read more about it in the IBM doc on &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=parameters-data-consistency-checking-modeling-assistance&quot; rel=&quot;nofollow noreferrer&quot;&gt;data consistency&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;mdl = Model(name='my_model')&#xA;...&#xA;mdl.parameters.read.datacheck = 0  # possible values are 0, 1, 2 with 1 being default in python&#xA;mdl.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="36" LastActivityDate="2021-06-13T19:11:41.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6442" PostTypeId="2" ParentId="6437" CreationDate="2021-06-13T19:21:36.643" Score="3" Body="&lt;p&gt;I'm assuming the goal here is shortest (least total weight) path. As long as the &amp;quot;problem constraints&amp;quot; affect the graph only to the extent of causing arcs to exist or not exist, and as long as the graph contains no negative cycles (closed paths whose aggregate weight is negative), Dijskstra's algorithm will work fine. If all arcs go from lower to higher index vertices (or all arcs go from higher to lower index vertices), the graph will be cycle free, which eliminates any chance of a negative cycle. Similarly, if the weights are all nonnegative, you do not have to worry about a negative weight cycle.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-06-13T19:21:36.643" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6443" PostTypeId="1" CreationDate="2021-06-13T19:46:21.097" Score="4" ViewCount="243" Body="&lt;h3&gt;Problem&lt;/h3&gt;&#xA;&lt;p&gt;To ensure fairness of the game, I am writing a bot that plays against itself. I have trouble rewriting a &lt;a href=&quot;https://en.wikipedia.org/wiki/Minimax&quot; rel=&quot;nofollow noreferrer&quot;&gt;minimax&lt;/a&gt; objective to a practical maximization in mixed integer programming. The amount of units is non-discrete (e.g. 1.2).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Game&lt;/h3&gt;&#xA;&lt;p&gt;The game for two players (&lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;) is over an undirected graph consisting of nodes connected by edges. Each node has a connection to itself and can hold at most &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; units. Initially, each player has 1 unit on 1 node. A player owns a node when he has more than &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; units on the node. A bonus set is a set of nodes with a bonus. If a player owns all nodes of a bonus set, he owns the bonus set. The income of a player is the sum of the bonuses of his bonus sets.&lt;/p&gt;&#xA;&lt;p&gt;Each turn has three phases:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Deployment: Each player distributes his income over his nodes. This distribution adds a non-negative number of units to the existing units on the nodes.&lt;/li&gt;&#xA;&lt;li&gt;Transfer: Each player distributes units from each node &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; to nodes directly connected to node &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Resolution: For each node, calculate the absolute difference between the total numbers of units sent to the node by the players. If this absolute difference exceeds &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;, the number of units on the node is this absolute difference and the player who sent more units owns the node. Otherwise, the number of units on the node is zero and no one owns the node.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Conventions&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WUHCB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WUHCB.png&quot; alt=&quot;Conventions&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;We will omit an equation for the &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; player if replacing &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; yields the corresponding equation for the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; player. The equations for the constraints are boxed. All vectors are column vectors.&lt;/p&gt;&#xA;&lt;h3&gt;Definitions&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XtztE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XtztE.png&quot; alt=&quot;Definitions&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Constraints&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0kx1tm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0kx1tm.png&quot; alt=&quot;Dependency graph of the variables&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Figure 1.&lt;/strong&gt; Dependency graph for the variables. Constants and calculations are not shown.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Bonus set ownership&lt;/strong&gt;: Since owning a bonus set means&#xA;owning all nodes in the bonus set, &lt;span class=&quot;math-container&quot;&gt;$s_{k}^{\alpha} = 1$&lt;/span&gt; is equivalent&#xA;to &lt;span class=&quot;math-container&quot;&gt;$\forall i \in \mathscr{B}_{k}: w_{i}^{\alpha} = 1$&lt;/span&gt;. Therefore,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\tag{1}&#xA;\boxed{&#xA;    \forall k: \forall i \in \mathscr{B}_{k}:&#xA;        w_{i}^{\alpha} \ge s_{k}^{\alpha} \ge 0&#xA;}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Notice that optimizing the objective will push &lt;span class=&quot;math-container&quot;&gt;$s_{k}^{\alpha}$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if possible. This is because the continuous variable &lt;span class=&quot;math-container&quot;&gt;$s_{k}^{\alpha}$&lt;/span&gt; is equivalent to giving the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; player a choice to voluntarily give up the contribution of the &lt;span class=&quot;math-container&quot;&gt;$k^{\mathrm{th}}$&lt;/span&gt; bonus set to his income.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Income&lt;/strong&gt;: A player's income is sum of the bonuses for his bonus sets.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;    \tag{2}&#xA;    c_{\alpha} = \sum_{k} b_{k}s_{k}^{\alpha} = \vec{b} \cdot \vec{s}_{\alpha}&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Transfer&lt;/strong&gt;: The total number of units transferred from a node is sum of the units on the node before deployment and the deployment to the node. Therefore,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;    \left( \mathcal{R}_{\alpha}\vec{1} \right)_{i}&#xA;        &amp;amp;= \sum_{j} R_{ij}^{\alpha}&#xA;        = \left( \vec{u}_{\alpha} + \vec{d}_{\alpha} \right)_{i} \\&#xA;    \tag{3}&#xA;    \implies \vec{d}_{\alpha}&#xA;        &amp;amp;= \mathcal{R}_{\alpha}\vec{1} - \vec{u}_{\alpha}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Each transfer moves a non-negative number of units.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{4}\boxed{&#xA;    \forall i,j: R_{ij}^{\alpha} \ge 0&#xA;}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Deployment&lt;/strong&gt;: The deployment to a node is non-negative. A player must deploy a number of units that is equal to his income.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \tag{5} \boxed{&#xA;    \mathcal{R}_{\alpha}\vec{1} - \vec{u}_{\alpha}&#xA;        = \vec{d}_{\alpha} \ge \vec{0}&#xA;} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \tag{6} \boxed{&#xA;    \left (\mathcal{R}_{\alpha}\vec{1} - \vec{u}_{\alpha} \right)&#xA;        \cdot \vec{1}&#xA;        = \vec{d}_{\alpha} \cdot \vec{1} = c_{\alpha}&#xA;} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;After deployment, each player has at most &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; units on nodes that he owns and at most &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; unit on nodes that he does not own.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{7} \boxed{&#xA;    M\vec{w}_{\alpha} \ge \vec{d}_{\alpha} + \vec{u}_{\alpha}&#xA;        = \mathcal{R}_{\alpha}\vec{1}&#xA;}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Resolution&lt;/strong&gt;: The total transferal to a node is the sum of transferals from each node to the node.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \tag{8}&#xA;    \left( \vec{q}_{\alpha} \right)_{j}&#xA;        &amp;amp;= \sum_{i} R_{ij}^{\alpha} \\&#xA;    \implies \vec{q}_{\alpha}&#xA;        &amp;amp;= \mathcal{R}_{\alpha}^{\mathsf{T}}\vec{1}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The differences between the total transferals to the nodes by the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; and&#xA;&lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; players are:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;    \tag{9}&#xA;    \vec{v}_{\alpha} &amp;amp;= \vec{q}_{\alpha} - \vec{q}_{\beta} \\&#xA;    \tag{10}&#xA;    \vec{v}_{\beta}  &amp;amp;= \vec{q}_{\beta} - \vec{q}_{\alpha} =&#xA;        - \vec{v}_{\alpha}&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; player owns a node if his total transferal to the node exceeds the &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; player's total transferal to the node by &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{11}\label{11}\boxed{&#xA;    (M - \epsilon)\vec{w}_{\alpha}[t + 1] &#xA;        \ge \vec{q}_{\alpha} - \vec{\epsilon} &#xA;        \ge (M + \epsilon)(\vec{w}_{\alpha} - 1)&#xA;}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\tag{12}\label{12}\boxed{&#xA;    M(1 - \vec{w}_{\alpha}) + \vec{q} \ge \vec{u}_{\alpha}[t + 1]&#xA;}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\tag{13}\label{13}\boxed{&#xA;    M\vec{w}_{\alpha}  \ge \vec{u}_{\alpha}[t + 1]&#xA;}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Notice that maximizing the objective would require maximizing each player's number of units. That would make &lt;span class=&quot;math-container&quot;&gt;$\vec{u}_{\alpha}$&lt;/span&gt; as large as possible. Consequently, the constrains and the objective together leads to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\tag{14}\label{14}&#xA;    \left( \vec{w}_{\alpha} \right)_{i} &amp;amp;=&#xA;    \begin{cases}&#xA;        1 \quad &amp;amp;\mathrm{if } \left(\vec{q}_{\alpha}\right)_{i} \ge \epsilon \\&#xA;        0 \quad &amp;amp;\mathrm{otherwise} &#xA;    \end{cases}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\tag{15}\label{15}&#xA;    \left( \vec{u}_{\alpha} \right)_{i} &amp;amp;=&#xA;    \begin{cases}&#xA;        \left(\vec{q}_{\alpha}\right)_{i}&#xA;             \quad &amp;amp;\mathrm{if } \left(\vec{q}_{\alpha}\right)_{i} \ge \epsilon \\&#xA;        0   \quad &amp;amp;\mathrm{otherwise} &#xA;    \end{cases}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Objective&lt;/h3&gt;&#xA;&lt;p&gt;&lt;strong&gt;Minimax objective&lt;/strong&gt;: Following the minimax strategy, the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; player would choose moves that minimize his maximal loss over all possible moves of the &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; player. Expressing this objective in terms of score instead of loss, we have:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \tag{16}&#xA;    \max_{\vec{\alpha}}\min_{\vec{\beta}}&#xA;        f(\vec{\alpha}, \vec{\beta})&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\vec{\alpha}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\vec{\beta}$&lt;/span&gt; are the moves of the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; players respectively and &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; player's score.&lt;/p&gt;&#xA;&lt;p&gt;Since the game is zero-sum, sum of the scores of the two players is 0. Consequently, the minimax objective for the &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; player is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\tag{17}&#xA;    \max_{\vec{\beta}}\min_{\vec{\alpha}}&#xA;        -f(\vec{\alpha}, \vec{\beta})&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Notice that the minimax objectives of both players are equivalent. Therefore, optimizing the minimax objective would find the moves of both players if they both use the minimax strategy.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective of the game&lt;/strong&gt;: Choosing the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; player's unit advantage at turn &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; as the score, we have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \tag{18}&#xA;    f^{(T)} = a_{\alpha}[T] = \vec{1} \cdot (&#xA;        \vec{u}_{\alpha}[T]- \vec{u}_{\beta}[T])&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f^{(T)}$&lt;/span&gt; denotes the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; player's score at turn &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The minimax optimization of the objective is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\tag{19}&#xA;    \max_{\mathcal{R}_{\alpha}[0]}&#xA;    \min_{\mathcal{R}_{\beta}[0]}&#xA;    \max_{\mathcal{R}_{\alpha}[1]}&#xA;    \min_{\mathcal{R}_{\beta}[1]}&#xA;    \cdots&#xA;    \max_{\mathcal{R}_{\alpha}[T]}&#xA;    \min_{\mathcal{R}_{\beta}[T]}&#xA;    f^{(T)}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="5705" LastEditDate="2021-06-28T22:49:41.173" LastActivityDate="2021-06-28T22:49:41.173" Title="Simplified risk game: writing a pratical Minimax objective for mixed integer programming" Tags="|optimization|mixed-integer-programming|linear-programming|graphs|minimax|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6446" PostTypeId="1" CreationDate="2021-06-15T07:55:05.697" Score="5" ViewCount="196" Body="&lt;p&gt;I am trying to &lt;a href=&quot;http://www.math.uwaterloo.ca/tsp/concorde/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;install Concorde&lt;/a&gt; linked with &lt;a href=&quot;https://www.math.uwaterloo.ca/%7Ebico/qsopt/beta/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;QSOPT&lt;/a&gt; following &lt;a href=&quot;http://www.math.uwaterloo.ca/tsp/concorde/DOC/README.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;these instructions&lt;/a&gt;. Regarding QSOPT, I downloaded files from section Intel MacOS 10.6 (64-Bit). But, as I have Apple M1 chip, it does not work. I think that the problem is in the arm64 architecture in terms of QS, however with other more commercial software for Intel processor, I do not face any issue thanks to Rosetta.&lt;/p&gt;&#xA;&lt;p&gt;The error I am facing when I run&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;./configure --host=darwin --with-qsopt=fullpath/QS&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ld: symbol(s) not found for architecture arm64&#xA;clang: error: linker command failed with exit code 1 (use -v to see invocation)&#xA;make[1]: *** [concorde] Error 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;sub&gt;&lt;a href=&quot;https://stackoverflow.com/questions/67968517/concorde-with-apple-silicon-m1&quot;&gt;Cross-posted&lt;/a&gt; on StackOverflow&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="5722" LastEditorUserId="123" LastEditDate="2021-06-15T13:49:48.497" LastActivityDate="2021-06-17T15:26:40.723" Title="Concorde with Apple Silicon M1" Tags="|traveling-salesman|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6447" PostTypeId="1" CreationDate="2021-06-15T09:23:46.213" Score="1" ViewCount="117" Body="&lt;p&gt;Suppose I have three employees and I have to assign three employees based on their ranks. If an employee has rank 1 that means he is best. Say, I have the following table&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Name      Rank&#xA;Joe        3&#xA;Allen      1&#xA;Bob        2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have make one parameter &lt;span class=&quot;math-container&quot;&gt;$p_{e, rank}.$&lt;/span&gt; If I can not assign it based on rank then I have to give some penalty. This is a part of an employee allocation problem.&lt;/p&gt;&#xA;&lt;p&gt;What I did, I make a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{e, r, rank}$&lt;/span&gt; for Assignment of employees to restaurant &lt;span class=&quot;math-container&quot;&gt;$r.$&lt;/span&gt; Then I create another variable &lt;span class=&quot;math-container&quot;&gt;$\sum(x_{e, r, rank} \cdot p_{e, rank}).$&lt;/span&gt; I am minimizing this sum and this is my objective function.&lt;/p&gt;&#xA;&lt;p&gt;My query is, is it correct? Or if there is any alternative way to write it in a mathematical program let me know.&lt;/p&gt;&#xA;" OwnerUserId="3929" LastEditorUserId="123" LastEditDate="2021-06-15T13:48:34.057" LastActivityDate="2021-06-15T13:48:34.057" Title="Employee allocation based on ranking: Mathematical Model" Tags="|optimization|linear-programming|assignment-problem|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6448" PostTypeId="1" AcceptedAnswerId="6450" CreationDate="2021-06-15T10:13:45.800" Score="4" ViewCount="189" Body="&lt;p&gt;I'm working on a network design problem where the objective is to minimise the network design cost. Given a graph G = (V, E) and a set of point-to-point demands K, the task is to route the demands and capacitate the network accordingly. To that end, we consider two families of variables: routing variables &lt;span class=&quot;math-container&quot;&gt;$x^{k}_{p} \in \{0,1\}$&lt;/span&gt;, and capacity installation variables &lt;span class=&quot;math-container&quot;&gt;$y_{e} \in \mathbb{Z}_{\ge0}$&lt;/span&gt;. As to the parameters, &lt;span class=&quot;math-container&quot;&gt;$d^{k} &amp;gt; 0, \forall k\in K$&lt;/span&gt; is the volume of traffic to be routed, &lt;span class=&quot;math-container&quot;&gt;$c_{e}$&lt;/span&gt; is the cost associated with installing a capacity module &lt;span class=&quot;math-container&quot;&gt;$\kappa_{e} \in \mathbb{Z}_{+}$&lt;/span&gt;. Here is a simplified model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min \hspace{1em} \sum_{e\in E}c_{e}y_{e}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{s.t.} \hspace{1em} \sum_{p\in P^{k}}x^{k}_{p} \ge 1 \hspace{1em} \forall k \in K$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\hspace{2em} \sum_{k\in K}\sum_{p\in P^{k}}\sigma^{e}_{p}d^{k}x^{k}_{p} \le \kappa_{e}y_{e} \hspace{1em} \forall e\in E$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now for my second experiment, I'd like to introduce a constraint to select two different paths to route the traffic but under the condition that the chosen paths don't differ by more than &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; edges. So, I declare another family of variables &lt;span class=&quot;math-container&quot;&gt;$z^{k}_{p} \in \{0,1\}$&lt;/span&gt; and introduce the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{p\in P^{k}}z^{k}_{p} \ge 1 \hspace{1em} \forall k \in K$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x^{k}_{p} + z^{k}_{p} \le 1 \hspace{1em} \forall k \in K, p \in P^{k}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{e\in E} \lvert \sum_{p\in P_{k}} \sigma^{e}_{p}(x^{k}_{p} - z^{k}_{p})\rvert \le r \hspace{1em} \forall k \in K$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{k\in K}\sum_{p\in P^{k}}\sigma^{e}_{p}d^{k}(x^{k}_{p} + z^{k}_{p}) \le \kappa_{e}y_{e} \hspace{1em} \forall e\in E$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have two questions regarding the model. The first one is that the constraint ensuring the chosen paths don't differ by more than &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; edges is non-linear. Is there any way to linearise this constraint or model it differently altogether? Secondly, since I plan to extend the model to a two-stage network design problem, can a row and column generation approach be applied to solve the problem? Could you please provide some pointers on this approach?&lt;/p&gt;&#xA;" OwnerUserId="942" LastEditorUserId="491" LastEditDate="2021-12-13T15:03:16.440" LastActivityDate="2021-12-13T15:03:16.440" Title="Problems modeling a constraint in network design problem" Tags="|modeling|linearization|network-flow|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6449" PostTypeId="2" ParentId="6447" CreationDate="2021-06-15T13:16:23.853" Score="1" Body="&lt;p&gt;A) I think you might want to use a multi-level score (something like &lt;a href=&quot;https://docs.optaplanner.org/8.6.0.Final/optaplanner-docs/html_single/index.html#bendableScore&quot; rel=&quot;nofollow noreferrer&quot;&gt;our BendableScore&lt;/a&gt;):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SOFT: maximize rank 1 assignments&lt;/li&gt;&#xA;&lt;li&gt;SOFTER: maximize rank 2 assignments&lt;/li&gt;&#xA;&lt;li&gt;SOFTEST: maximize rank 3 assignments&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Otherwise, three rank 2 assignments can be considered better than one rank 1 assignments (which I presume is not the requirement).&lt;/p&gt;&#xA;&lt;p&gt;Where it gets more interesting is if your number or ranks is dynamic: One dataset can have 3 ranks, while another could have 3000 ranks. In that case, a &lt;a href=&quot;https://www.optaplanner.org/blog/2017/02/03/FormulaForMeasuringUnfairness.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;fairness like squaring technique&lt;/a&gt; probably works too, to collapse it into a single score level.&lt;/p&gt;&#xA;&lt;p&gt;B) If, on the other hand, outweighing is the requirement, just use a single score level (SOFT) with weighting (one weight between every two sequential ranks). In your current implementation: rank 1 is twice rank 2. Rank 2 is 1.5 times rank 3. That's weird. It would be more consistent weighting wise, to use rank 1 (penalty 1), rank 2 (penalty 2), rank 3 (penalty 4), rank 4 (penalty 8) and so forth.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2021-06-15T13:21:32.927" LastActivityDate="2021-06-15T13:21:32.927" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6450" PostTypeId="2" ParentId="6448" CreationDate="2021-06-15T13:47:58.320" Score="6" Body="&lt;p&gt;You can linearize by introducing a new binary variable &lt;span class=&quot;math-container&quot;&gt;$w_e^k$&lt;/span&gt; to indicate whether edge &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; appears in exactly one path for commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and imposing the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{p\in P^k} \sigma_p^e (x_p^k - z_p^k) &amp;amp;\le w_e^k &amp;amp;&amp;amp;\text{for $e\in E$ and $k\in K$} \\&#xA;\sum_{p\in P^k} \sigma_p^e (z_p^k - x_p^k) &amp;amp;\le w_e^k &amp;amp;&amp;amp;\text{for $e\in E$ and $k\in K$} \\&#xA;\sum_{e\in E} w_e^k &amp;amp;\le r &amp;amp;&amp;amp;\text{for $k\in K$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I wouldn't recommend trying column and/or row generation until you have first tried a compact (edge-based) formulation.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-06-15T13:47:58.320" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6451" PostTypeId="1" AcceptedAnswerId="6452" CreationDate="2021-06-15T14:35:46.797" Score="6" ViewCount="420" Body="&lt;p&gt;I would like some solver recommendations to solve a problem with boolean/integer variables, mostly &lt;strong&gt;linear constraints but also some quadratic constraints&lt;/strong&gt;. I also have an &lt;strong&gt;objective to minimize which is linear&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I think this kind of problem is called mixed integer quadratically constrained program (&lt;strong&gt;MIQCP&lt;/strong&gt;).&lt;/p&gt;&#xA;&lt;p&gt;The quadratic constraints are sums of linear terms and &lt;strong&gt;one quadratic term which is a constant multiplied by a squared variable&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would like to know if there is some MIP solvers that can handle this kind of problem (I think CPLEX and Gurobi can).&lt;/p&gt;&#xA;&lt;p&gt;I would also like to know if a CP (Constraint programming) solver can handle this kind of constraint ? I looked at Google's or-tools CP-SAT solver documentation and it appears that there is a function AddMultiplicationEquality() that allows for variable products.&lt;/p&gt;&#xA;&lt;p&gt;Thanks for your help!&lt;/p&gt;&#xA;" OwnerUserId="3671" LastEditorUserId="981" LastEditDate="2023-12-22T15:06:28.933" LastActivityDate="2023-12-22T15:06:28.933" Title="Solver Recommendation : Discrete Variables and Quadratic Constraints" Tags="|optimization|mixed-integer-programming|constraint-programming|quadratic-programming|cp-sat|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6452" PostTypeId="2" ParentId="6451" CreationDate="2021-06-15T15:18:01.107" Score="3" Body="&lt;p&gt;This is by no means a complete list, but this is some of the best stuff for this mathematical structure:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Open source:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Couenne, SCIP&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Commercial and free:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Octeract Engine (our own solver).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Commercial and not free:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Gurobi, Lindo Global, Baron, Antigone, LocalSolver.&lt;/p&gt;&#xA;&lt;p&gt;You might be able to get a free version of Gurobi (and maybe some of the other non-free ones) if you are an academic.&lt;/p&gt;&#xA;&lt;p&gt;If your problem is convex, you can also use Bonmin (open source), KNITRO (commercial), or MOSEK (commercial).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-06-16T13:56:03.927" LastActivityDate="2021-06-16T13:56:03.927" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6454" PostTypeId="1" CreationDate="2021-06-16T14:34:09.937" Score="3" ViewCount="204" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DZfWI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DZfWI.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;I am currently stuck on writing a linear programming model to describe the process of appointment scheduling for an Oncological Center. I wanted to share it with you guys and see if anyone here could help me. The problem regards the process of scheduling a date and hour for each patient appointment over a week, each patient has to come in do a first visit and then a transfusion, we have N beds for transfusion, thus if they are all occupied at a certain moment we have to consider a certain waiting time for the patient. I am stuck on writing the constraints for my problem.&#xA;I have as data:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;P --&amp;gt; List of patients&lt;/li&gt;&#xA;&lt;li&gt;K --&amp;gt; List of pathologies&lt;/li&gt;&#xA;&lt;li&gt;L --&amp;gt; List of laboratories&lt;/li&gt;&#xA;&lt;li&gt;T --&amp;gt; Time horizon in days&lt;/li&gt;&#xA;&lt;li&gt;H --&amp;gt; List of time slots for each day&lt;/li&gt;&#xA;&lt;li&gt;Ms --&amp;gt; Maximum ending time for transfusions&lt;/li&gt;&#xA;&lt;li&gt;Mv --&amp;gt; Maximum ending time for visits&lt;/li&gt;&#xA;&lt;li&gt;N --&amp;gt; Total number of beds for transfusions&lt;/li&gt;&#xA;&lt;li&gt;t^(v)(k) --&amp;gt; time for first visit pathology k&lt;/li&gt;&#xA;&lt;li&gt;t^(s)(k) --&amp;gt; time for transfusion pathology k&lt;/li&gt;&#xA;&lt;li&gt;S(p,k) --&amp;gt; 1 if patient p has pathology k, 0 otherwise (every patient has only one pathology)&lt;/li&gt;&#xA;&lt;li&gt;W(l,k,t) --&amp;gt; 1 if laboratory l is designed for visits of pathology k on day t, 0 otherwise&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I was thinking about using as variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;X(p,t,h) --&amp;gt; 1 if patient p begins visit on day t on time slot h, 0 otherwise&lt;/li&gt;&#xA;&lt;li&gt;Y(p,t,h) --&amp;gt; 1 if patient p begins drug transfusion on day t on time slot h, 0 otherwise&lt;/li&gt;&#xA;&lt;li&gt;R(p) --&amp;gt; Waiting time of patient p between visit and infusion&lt;/li&gt;&#xA;&lt;li&gt;U(p) --&amp;gt; 1 if patient p has to wait between visit and infusion, 0 otherwise&lt;/li&gt;&#xA;&lt;li&gt;C(p) --&amp;gt; Total time spent in the hospital for patient p&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Do you guys think these variables are enough ? We work under the assumption that nurses are always available, and thus we do not consider that as a constraint. How would you write the model ? I need serious help and would be extremely helpful to anyone wanting to help...&lt;/p&gt;&#xA;&lt;p&gt;The constraints on top of the question are what I came up with, I am not sure if they are all necessary or not. It may be possible to solve the problem using less constraints. What do you guys think ? Any feedback is appreciated it is one of my first experiences writing such a big model.&lt;/p&gt;&#xA;" OwnerUserId="5724" LastEditorUserId="5724" LastEditDate="2021-06-16T22:50:42.510" LastActivityDate="2021-06-16T22:56:10.357" Title="Need help with an appointment scheduling problem" Tags="|linear-programming|integer-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6455" PostTypeId="2" ParentId="6454" CreationDate="2021-06-16T22:38:52.453" Score="1" Body="&lt;p&gt;Assorted comments in no particular order:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Are you using &amp;quot;infusion&amp;quot; and &amp;quot;transfusion&amp;quot; interchangeably?&lt;/li&gt;&#xA;&lt;li&gt;I suspect that, in order to handle the occupancy constraints for transfusion beds, you will need a variable for the time each patient starts transfusion. You may be able to compute that from X(p,t,h) and W(p), but it might be easier to start with an explicit variable for transfusion start time and compute W from that variable and X.&lt;/li&gt;&#xA;&lt;li&gt;It is unclear what role the laboratory index (l, from set L) plays. If there are multiple laboratories set up for different pathologies on a given day, then you need bed capacity N(l) for each lab, not just one total bed capacity N.&lt;/li&gt;&#xA;&lt;li&gt;You are going to need an objective function, which means you need to settle on a criterion for choosing among possible schedules. (By &amp;quot;you&amp;quot; I mean &amp;quot;whoever is commissioning the model&amp;quot;.) This could be maximizing the number of patients seen per day, minimizing waiting times for appointments, minimizing cycle times (time from when the patient walks in to when they walk out) or possibly something else. The objective criterion may dictate the need for additional variables. By the same token, depending on the criterion, either or both of U(p) and C(p) may be unnecessary.&lt;/li&gt;&#xA;&lt;li&gt;ADDENDUM (I forgot to include this the first time around): You may need a parameter for the time to &amp;quot;refresh&amp;quot; a bed (change bed linen, change IVs, sterilize anything that can't outrun you) and constraints to enforce that. In scheduling problems that's known as a &amp;quot;setup time&amp;quot; or &amp;quot;changeover time&amp;quot;. Similarly, there is probably a capacity limit on &amp;quot;first visits&amp;quot; (perhaps staff need to go over paperwork, or doctors need to examine the patients), and there may be a minimum time gap between first visits (staff require time to regroup between patients, examining rooms need to be sterilized, ...).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-06-16T22:56:10.357" LastActivityDate="2021-06-16T22:56:10.357" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6456" PostTypeId="1" CreationDate="2021-06-17T14:05:12.500" Score="1" ViewCount="135" Body="&lt;p&gt;I have the following problem in Gurobi (Java).&lt;/p&gt;&#xA;&lt;p&gt;I have a binary variable &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; that is supposed to be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; depending on my optimisation variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.  It should be true that &lt;span class=&quot;math-container&quot;&gt;$b = 1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$c_1 \le x \le c_2$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. The values of &lt;span class=&quot;math-container&quot;&gt;$c_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_2$&lt;/span&gt; are constant.&lt;/p&gt;&#xA;&lt;p&gt;I wanted to solve the whole thing using a constraint, which then determines my binary variable with the method &lt;code&gt;model.addGenConstrIndicator&lt;/code&gt;, but it is still &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; for values above &lt;span class=&quot;math-container&quot;&gt;$c_2$&lt;/span&gt;. Maybe someone can help me or has another idea.&lt;/p&gt;&#xA;&lt;p&gt;Furthermore I have the problem, that even when i don't use the binary variable in my objective function my result and the value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; will be changed by this constraint.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for (int t = 0; t &amp;lt; 3; t++)&#xA;    {&#xA;        for (int j = 0; j &amp;lt; 5; j++)&#xA;        {&#xA;                for (int m = 0; m &amp;lt; 12; m++)&#xA;                {   &#xA;                    constra = new GRBLinExpr();&#xA;                    &#xA;                    constra.addTerm(1.0, x[m]);&#xA;                    &#xA;                    model.addGenConstrIndicator(b[t][j][m], 1, constra, GRB.GREATER_EQUAL, c1, &amp;quot;is one&amp;quot; + t + j + m);&#xA;                    model.addGenConstrIndicator(b[t][j][m], 0, constra, GRB.GREATER_EQUAL, c2, &amp;quot;is zero&amp;quot; + t + j + m);&#xA;                }&#xA;        }&#xA;}&#xA;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5092" LastEditorUserId="5092" LastEditDate="2021-06-17T16:55:29.103" LastActivityDate="2021-06-17T16:55:29.103" Title="Binary variable with two criteria in Gurobi (Java)" Tags="|optimization|gurobi|binary-variable|java|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6457" PostTypeId="1" CreationDate="2021-06-17T14:50:07.230" Score="1" ViewCount="800" Body="&lt;p&gt;I would like to create a pandas dataframe from the results (and the parameters) of an optimization problem and create a csv file out of it. In my previous example (&lt;a href=&quot;https://or.stackexchange.com/questions/6122/how-to-display-results-of-pyomo-variables-in-a-pandas-dataframe&quot;&gt;1-dimensional case&lt;/a&gt;) I have just one set &amp;quot;set_timeslots&amp;quot; and all parameters and variables depend on that (this is the 1-dimensional case). For this basically everything works as it should by using this code (extract):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Define the sets&#xA;model.set_timeslots = pyo.RangeSet(1, 288)&#xA;.....................................&#xA;#Variable definition&#xA;model.variable_heatGenerationCoefficient_SpaceHeating = pyo.Var(model.set_timeslots, bounds=(0,1))&#xA;model.variable_temperatureBufferStorage = pyo.Var(model.set_timeslots, bounds=(0 , 20))&#xA;model.param_heatDemand_In_W = pyo.Param(model.set_timeslots, initialize=dictionaryHeatDemand_In_W)&#xA;..........................&#xA;#After having solved the model&#xA;   outputVariables_list = [model.variable_heatGenerationCoefficient_SpaceHeating, model.variable_temperatureBufferStorage, model.param_heatDemand_In_W, model.set_timeslots]&#xA;    optimal_values_list = [[pyo.value(model_item[key]) for key in model_item] for model_item in outputVariables_list] &#xA;    results = pd.DataFrame(optimal_values_list)&#xA;    results= results.T&#xA;    results = results.rename(columns = {0:'variable_heatGenerationCoefficient_SpaceHeating', 1:'variable_temperatureBufferStorage', 2:'param_heatDemand_In_W', 3:'set_timeslots'})&#xA;    cols = ['set_timeslots']&#xA;    results[cols]= results [cols].round(0).astype(int)&#xA;    results.set_index('set_timeslots', inplace=True)&#xA;    results.to_csv('Results.csv', index=True,  sep =&amp;quot;;&amp;quot;) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You do not have to care about the assignment of the parameters and the model itself. It is just about printing the results after having solved the model&lt;/p&gt;&#xA;&lt;p&gt;The problem is how can I extend that to 2-dimensional variables and parameters that depend on 2 sets. As before the set &amp;quot;timeslots&amp;quot; but also the set &amp;quot;set_buildings_BT1&amp;quot;. This means that we have for every building 288 timeslots and for each of them I have a value of the parameters and the variables&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Define the sets&#xA;model.set_timeslots = pyo.RangeSet(1, 288)&#xA;model.set_buildings_BT1 = pyo.RangeSet(1, 3)&#xA;&#xA;#Index of the buildings&#xA;indexOfBuildingsOverall_BT1 =  [0,1,2]&#xA;&#xA;#Define variables and parameters&#xA;def init_heatDemand (model, i,j):&#xA;    return combinedDataframe_heatDemand_BT1.iloc[j-1, i-1]&#xA;&#xA;model.param_heatDemand_In_W = pyo.Param(model.set_buildings_BT1, model.set_timeslots, mutable = True, initialize=init_heatDemand)&#xA;&#xA;model.variable_heatGenerationCoefficient_SpaceHeating = pyo.Var(model.set_buildings_BT1, model.set_timeslots,bounds=(0,1))&#xA;model.variable_temperatureBufferStorage = pyo.Var(model.set_buildings_BT1, model.set_timeslots,  bounds=(0 , 20 ))&#xA;&#xA;    #After having solved the model&#xA;    for index_BT1 in indexOfBuildingsOverall_BT1:&#xA;       outputVariables_list = [model.variable_heatGenerationCoefficient_SpaceHeating [index_BT1 + 1], model.variable_temperatureBufferStorage [index_BT1 + 1], model.param_heatDemand_In_W [index_BT1 + 1], model.set_timeslots]&#xA;        optimal_values_list = [[pyo.value(model_item[key]) for key in model_item] for model_item in outputVariables_list] &#xA;        results = pd.DataFrame(optimal_values_list)&#xA;        results= results.T&#xA;        results = results.rename(columns = {0:'variable_heatGenerationCoefficient_SpaceHeating', 1:'variable_temperatureBufferStorage', 2:'param_heatDemand_In_W', 3:'set_timeslots'})&#xA;        cols = ['set_timeslots']&#xA;        results[cols]= results [cols].round(0).astype(int)&#xA;        results.set_index('set_timeslots', inplace=True)&#xA;        results.to_csv('Results\Result_BT1_Index_' + str(index_BT1) + '.csv', index=True,  sep =&amp;quot;;&amp;quot;) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried to loop over the index_BT1 in indexOfBuildingsOverall_BT1 and access the values of the variables and parameters for each building by e.g. &lt;code&gt;model.variable_heatGenerationCoefficient_SpaceHeating [index_BT1 + 1]&lt;/code&gt; (I tried it also without +1). However, I get the error &amp;quot;KeyError: &amp;quot;Index '1' is not valid for indexed component 'variable_heatGenerationCoefficient_SpaceHeating'&amp;quot;&amp;quot;. Do you know why I get this error and how I can tackle this? I'd appreciate every comment.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Reminder&lt;/strong&gt;: Does anybody have an idea how I can do this? I'd appreciate every suggestion.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2021-06-22T17:11:55.467" LastActivityDate="2021-06-25T13:43:38.220" Title="How to display results of 2-dimensional Pyomo variables in a pandas dataframe" Tags="|python|pyomo|pandas|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6458" PostTypeId="2" ParentId="6446" CreationDate="2021-06-17T15:26:40.723" Score="3" Body="&lt;p&gt;Thanks to the support of Bill Cook, it is now available a version of &lt;code&gt;qsopt.a&lt;/code&gt; for the M1 Apple Chip on the &lt;a href=&quot;http://www.math.uwaterloo.ca/%7Ebico/qsopt/downloads/downloads.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;QSOPT download page&lt;/a&gt;. This perfectly worked for me by run&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;./configure --host=darwin --with-qsopt=fullpath/QS&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5722" LastActivityDate="2021-06-17T15:26:40.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6459" PostTypeId="1" AcceptedAnswerId="6463" CreationDate="2021-06-17T19:10:41.527" Score="2" ViewCount="1044" Body="&lt;p&gt;I am building a variant of the maximum coverage location model and want to limit the amount of points that each &amp;quot;facility&amp;quot; can cover. I am using Gurobi optimization . I have tried using the AddConstr() function but have failed. Each K represents a facility and r a radius. My goal is to add a constraint that would limit the amount of points inside that radius. points is a 2D array of x-y coordinates. K is the inputted number of facilities, and M is the total number of points. Would I be able to accomplish this inside this function or would I need to add another variable?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;from scipy.spatial import distance_matrix&#xA;from gurobipy import *&#xA;from scipy.spatial import ConvexHull&#xA;from shapely.geometry import Polygon, Point&#xA;from numpy import random&#xA;&#xA;def generate_candidate_sites(points,M=100):&#xA;    hull = ConvexHull(points)&#xA;    polygon_points = points[hull.vertices]&#xA;    poly = Polygon(polygon_points)&#xA;    min_x, min_y, max_x, max_y = poly.bounds&#xA;    sites = []&#xA;    while len(sites) &amp;lt; M:&#xA;        random_point = Point([random.uniform(min_x, max_x),&#xA;                             random.uniform(min_y, max_y)])&#xA;        if (random_point.within(poly)):&#xA;            sites.append(random_point)&#xA;    return np.array([(p.x,p.y) for p in sites])&#xA;&#xA;def mclp(points,K,radius,M):&#xA;    print('----- Configurations -----')&#xA;    print('  Number of points %g' % points.shape[0])&#xA;    print('  K %g' % K)&#xA;    print('  Radius %g' % radius)&#xA;    print('  M %g' % M)&#xA;    import time&#xA;    start = time.time()&#xA;    sites = generate_candidate_sites(points,M)&#xA;    J = sites.shape[0]&#xA;    I = points.shape[0]&#xA;    D = distance_matrix(points,sites)&#xA;    mask1 = D&amp;lt;=radius&#xA;    D[mask1]=1&#xA;    D[~mask1]=0&#xA;    # Build model&#xA;    m = Model()&#xA;    # Add variables&#xA;    x = {}&#xA;    y = {}&#xA;    for i in range(I):&#xA;      y[i] = m.addVar(vtype=GRB.BINARY, name=&amp;quot;y%d&amp;quot; % i)&#xA;    for j in range(J):&#xA;      x[j] = m.addVar(vtype=GRB.BINARY, name=&amp;quot;x%d&amp;quot; % j)&#xA;&#xA;    m.update()&#xA;    # Add constraints&#xA;    m.addConstr(quicksum(x[j] for j in range(J)) == K)&#xA;&#xA;    for i in range(I):&#xA;        m.addConstr(quicksum(x[j] for j in np.where(D[i]==1)[0]) &amp;gt;= y[i])&#xA;&#xA;    m.setObjective(quicksum(y[i]for i in range(I)),GRB.MAXIMIZE)&#xA;    m.setParam('OutputFlag', 0)&#xA;    m.optimize()&#xA;    end = time.time()&#xA;    print('----- Output -----')&#xA;    print('  Running time : %s seconds' % float(end-start))&#xA;    print('  Optimal coverage points: %g' % m.objVal)&#xA;    &#xA;    solution = []&#xA;    if m.status == GRB.Status.OPTIMAL:&#xA;        for v in m.getVars():&#xA;            # print v.varName,v.x&#xA;            if v.x==1 and v.varName[0]==&amp;quot;x&amp;quot;:&#xA;               solution.append(int(v.varName[1:]))&#xA;    opt_sites = sites[solution]&#xA;    return opt_sites,m.objVal&#xA;&#xA;def plot_input(points):&#xA;    from matplotlib import pyplot as plt&#xA;    fig = plt.figure(figsize=(8,8))&#xA;    plt.scatter(points[:,0],points[:,1],c='C0')&#xA;    ax = plt.gca()&#xA;    ax.axis('equal')&#xA;    ax.tick_params(axis='both',left=False, top=False, right=False,&#xA;                       bottom=False, labelleft=False, labeltop=False,&#xA;                       labelright=False, labelbottom=False)&#xA;&#xA;def plot_result(points,opt_sites,radius):&#xA;    from matplotlib import pyplot as plt&#xA;    fig = plt.figure(figsize=(8,8))&#xA;    plt.scatter(points[:,0],points[:,1],c='C0')&#xA;    ax = plt.gca()&#xA;    plt.scatter(opt_sites[:,0],opt_sites[:,1],c='C1',marker='+')&#xA;    for site in opt_sites:&#xA;        circle = plt.Circle(site, radius, color='C1',fill=False,lw=2)&#xA;        ax.add_artist(circle)&#xA;    ax.axis('equal')&#xA;    ax.tick_params(axis='both',left=False, top=False, right=False,&#xA;                       bottom=False, labelleft=False, labeltop=False,&#xA;                       labelright=False, labelbottom=False)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Code to run a small sample program&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;Npoints = 300&#xA;from sklearn.datasets import make_moons&#xA;points,_ = make_moons(Npoints,noise=0.15)&#xA;K = 20&#xA;radius = 0.2&#xA;M = 100&#xA;opt_sites,f = mclp(points,K,radius,M)&#xA;plot_result(points,opt_sites,radius)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sD7bL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sD7bL.png&quot; alt=&quot;Mathematical Formulation&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5729" LastEditorUserId="5729" LastEditDate="2021-06-18T14:58:34.327" LastActivityDate="2023-01-03T16:09:54.603" Title="Capacitated Maximum Coverage Location Problem, Python and Gurobi" Tags="|optimization|python|integer-programming|gurobi|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6460" PostTypeId="1" AcceptedAnswerId="6461" CreationDate="2021-06-17T22:59:53.683" Score="4" ViewCount="631" Body="&lt;p&gt;I'm using the Java API of CPLEX 12.6.1 (with license) to solve a MILP (Mixed-Integer Linear Programming) maximization problem.&lt;/p&gt;&#xA;&lt;p&gt;The point is that, after 21 hours, CPLEX has consumed 32 GB of RAM and the whole (30 GB) Swapping Memory.&lt;/p&gt;&#xA;&lt;p&gt;While CPLEX runs I'm able to see its &amp;quot;log&amp;quot; output, and I saw that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &amp;quot;Gap&amp;quot; coloumn is always blank;&lt;/li&gt;&#xA;&lt;li&gt;the &amp;quot;Best Integer&amp;quot; coloumn is always blank;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;so, no solution has been found.&lt;/p&gt;&#xA;&lt;p&gt;Moreover (after the first few seconds where it changes a bit), the value in &amp;quot;Best Bound&amp;quot; coloumn is always the same (equal to 52.2911) during the 21 hours.&lt;/p&gt;&#xA;&lt;p&gt;This is the beginning of the CPLEX output LOG:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/YzvT8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YzvT8.png&quot; alt=&quot;CPLEX LOG&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;How could I solve this problem?&lt;/p&gt;&#xA;&lt;p&gt;I already increased the absolute and the relative MIP GAP (I set both of them to 0.1), but without solving.&lt;/p&gt;&#xA;&lt;p&gt;Are there any parameters which can I tune to help CPLEX to find a solution?&lt;/p&gt;&#xA;" OwnerUserId="4944" LastEditorUserId="4944" LastEditDate="2021-06-17T23:12:44.237" LastActivityDate="2021-06-18T16:02:24.213" Title="CPLEX log always the same after hours (&quot;Gap&quot; and &quot;Best Integer&quot; always blanks)" Tags="|optimization|mixed-integer-programming|linear-programming|cplex|solver|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6461" PostTypeId="2" ParentId="6460" CreationDate="2021-06-18T04:08:45.877" Score="10" Body="&lt;p&gt;Diagnosis: Cplex can not find a feasible solution. Interesting, as 1788 binary variables is not extremely large.&lt;/p&gt;&#xA;&lt;p&gt;You can play a bit with &lt;strong&gt;mipemphasis&lt;/strong&gt; option. (In general, I am not a fan of using all kinds of solver options, but this option is one of the very few I use on a regular basis). May be &lt;strong&gt;fpheur&lt;/strong&gt; (feasibility pump) is also worth looking at.&lt;/p&gt;&#xA;&lt;p&gt;There are also other things you can do:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Make the model more elastic. I.e. relax (some) constraints while putting penalties in the objective. Branch-and-bound algorithms work much better once there is a feasible solution. Also, this method may find some borderline infeasible solutions that are acceptable.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Try to invent a heuristic that can construct an initial feasible solution, and pass this on using MIPSTART. This may or may not be a difficult task.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Of course, if your model has no integer feasible solution, nothing will work. Unfortunately, proving a MIP model is integer infeasible is often quite difficult and time-consuming.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2021-06-18T16:02:24.213" LastActivityDate="2021-06-18T16:02:24.213" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6462" PostTypeId="1" CreationDate="2021-06-18T07:59:21.960" Score="3" ViewCount="76" Body="&lt;p&gt;I have a quadratic model of parking &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; cars in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; separate lanes as follows. Each car has an arrival time and a departure time. Departure follow the last in first out principle. The objective is to minimize the number of maneuvers.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Indices:&lt;/strong&gt;&lt;/em&gt; &lt;br /&gt;&#xA;car indices: &lt;span class=&quot;math-container&quot;&gt;$i,j \in \{1,\dots,N\}$&lt;/span&gt;, &lt;br /&gt;&#xA;lane indices: &lt;span class=&quot;math-container&quot;&gt;$m \in \{1,\dots,S\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Parameters:&lt;/strong&gt;&lt;/em&gt; &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$c_{ij} = \begin{cases} 1, &amp;amp;\text{If parking car $i$ and $j$ in the same lane will cause a maneuver when departing} \\ 0, &amp;amp;\text{otherwise} \end{cases} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Decision variables:&lt;/strong&gt;&lt;/em&gt; &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{im} = \begin{cases} 1, &amp;amp; \text{If car $i$ is parked in lane $m$} \\ 0, &amp;amp; \text{otherwise} \end{cases}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{QM}\hspace{1cm}  &amp;amp; \min{\sum_m^S \sum_{i=1}^{N-1}\sum_{j=1+1}^{N} c_{ij} x_{im} x_{jm}} \\&#xA;\text{Subject to}\\&#xA;\sum_{m=1}^{S}{x_{im}} &amp;amp;=1 &amp;amp; \forall\ &amp;amp; i \\&#xA;x_{im} &amp;amp; \in \{0,1\} &amp;amp; \forall\ &amp;amp; i,m&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have the linearized model LQM1 of QM as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Derived variables&lt;/strong&gt;&lt;/em&gt;: &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{ij} =\begin{cases} &#xA;        1, &amp;amp;\text{if cars $i$ and $j$ are parked in the same lane}\\&#xA;        0, &amp;amp;\text{otherwise}&#xA;        \end{cases}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; \text{LQM1}  &amp;amp; \min{\sum_{i=1}^{N-1}\sum_{j=1+1}^{N} c_{ij} z_{ij}} \\&#xA;\text{Subject to}\\&#xA;\sum_{m=1}^{S}{x_{im}} &amp;amp;=1 &amp;amp; \forall\ &amp;amp; i \\&#xA;x_{im} + x_{jm} &amp;amp; \leq z_{ij} + 1 &amp;amp; \forall\ &amp;amp; i,j,m, i &amp;lt; j \\&#xA;z_{ij} &amp;amp; \geq 0 &amp;amp; \forall\ &amp;amp; i,j, i &amp;lt; j \\&#xA;x_{im} &amp;amp; \in \{0,1\} &amp;amp; \forall\ &amp;amp; i,m  &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the linearized model LQM1, &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; does not need a binary restriction because &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; is nonnegative and the objective function is minimized.&lt;/p&gt;&#xA;&lt;p&gt;My concern is what is the difference if I have solved LQM2 instead of LQM1 with Gurobi? Is there a theoretical reason when linearizing the quadratic model?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; \text{LQM2}  &amp;amp; \min{\sum_{i=1}^{N-1}\sum_{j=1+1}^{N} c_{ij} z_{ij}} \\&#xA;\text{Subject to}\\&#xA;\sum_{m=1}^{S}{x_{im}} &amp;amp;=1 &amp;amp; \forall\ &amp;amp; i \\&#xA;x_{im} + x_{jm} &amp;amp; \leq z_{ij} + 1 &amp;amp; \forall\ &amp;amp; i,j,m, i &amp;lt; j \\&#xA;x_{im} &amp;amp; \in \{0,1\} &amp;amp; \forall\ &amp;amp; i,m  \\&#xA;z_{ij} &amp;amp; \in \{0,1\} &amp;amp; \forall\ &amp;amp; i,j  &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3480" LastActivityDate="2021-06-18T07:59:21.960" Title="Linearization of a quadratic model, what is the difference while using gurobi?" Tags="|mixed-integer-programming|combinatorial-optimization|linearization|gurobi|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6463" PostTypeId="2" ParentId="6459" CreationDate="2021-06-18T16:38:13.473" Score="2" Body="&lt;p&gt;Similar to the last constraint, you can define a neighborhood of points around a facility, and specify the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i \in N(j)} y_{i} \le \max{\rm Points}, \forall j \in J$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$N(j) = \{i\in I: d_{i, j} \le r\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The following code snippet should work:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for j in range(J):&#xA;    m.addConstr(quicksum(y[i] for i in np.where(D[:,j]==1)[0]) &amp;lt;= 10)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2424" LastEditorUserId="123" LastEditDate="2021-06-18T18:54:43.137" LastActivityDate="2021-06-18T18:54:43.137" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6464" PostTypeId="2" ParentId="6420" CreationDate="2021-06-18T23:07:01.450" Score="4" Body="&lt;p&gt;You could use any existing constructive heuristic to compute a TDTSP solution.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$T_{ij}(t)$&lt;/span&gt; be the travel time on arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; when departing location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. A common premises is that it is never beneficial to depart late. So for any given pair of time points &lt;span class=&quot;math-container&quot;&gt;$t_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t_2$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$t_1\leq t_2$&lt;/span&gt; it holds that &lt;span class=&quot;math-container&quot;&gt;$t_1+T_{ij}(t_1)\leq t_2+T_{ij}(t_2)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The simplest constructive heuristic would be the &lt;em&gt;nearest neighbor heuristic&lt;/em&gt;.This heuristic starts at the depot (&lt;span class=&quot;math-container&quot;&gt;$i=0$&lt;/span&gt;) at time &lt;span class=&quot;math-container&quot;&gt;$t_0=0$&lt;/span&gt;. At each iteration of the algorithm, you extend the tour with a new unvisited vertex &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and you record the arrival time &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt;. When extending the tour, you always select a new unvisited vertex &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; that minimizes &lt;span class=&quot;math-container&quot;&gt;$T_{ij}(t_i)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the last visited vertex in the partial tour. The heuristic terminates when all locations are visited.&lt;/p&gt;&#xA;&lt;p&gt;Variations of this nearest neighbor heuristic can be conceived as well, e.g. by occasionally randomly selecting the second nearest location as opposed to the nearest, or by computing a 'regret' metric for not selecting a particular vertex, or by explicitly accounting for the return segment to the depot. Any of these variants are easy to implement.&lt;/p&gt;&#xA;&lt;p&gt;The second category of constructive heuristics require you to modify the tour. Start for instance with the trivial tour &lt;span class=&quot;math-container&quot;&gt;$[0,i,0]$&lt;/span&gt;, where vertex &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is a randomly selected vertex. Next you take an unvisited vertex say &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and &lt;em&gt;insert&lt;/em&gt; it into the tour. The standard strategy is to insert the vertex into the location that increases the duration of the tour the least. You repeat this procedure until all vertices are in the tour. For the traditional TSP (without time), the cost of inserting a vertex is easy to derive. To insert a vertex &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; between two vertices &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, the cost difference (delta) equals &lt;span class=&quot;math-container&quot;&gt;$t_{ij}+t_{jk}-t_{ik}$&lt;/span&gt;. Clearly, for the time dependent variant you would have to do a little more work, because by inserting a vertex you potentially alter the departure times of the subsequent vertices in the tour, which in turn changes the travel times. So in the worst case, you would have to recompute the travel times for the portion of the tour that succeeds the inserted vertex. Naturally this is more costly.&#xA;All other heuristics that modify the tour, e.g. 2-opt/Clarke-Wright etc, suffer from this problem. With any heuristic, the faster you could evaluate a 'move', the better it is.&lt;/p&gt;&#xA;&lt;p&gt;Finally, you could also remove the time-dependency, treat the problem as if it were a traditional TSP, and solve with any existing constructive TSP heuristic. To remove the time-dependency, you could replace &lt;span class=&quot;math-container&quot;&gt;$T_{ij}(t)$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$t_{ij}=average(T_{ij}(t))$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;$t_{ij}=max_t(T_{ij}(t))$&lt;/span&gt;. Once you obtained a complete tour containing all the vertices, you would evaluate its true cost using the actual time-dependent travel times.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-06-18T23:07:01.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6465" PostTypeId="1" CreationDate="2021-06-19T01:37:47.877" Score="3" ViewCount="365" Body="&lt;p&gt;I would like to write a constraint as follows, where &lt;span class=&quot;math-container&quot;&gt;$x,y&amp;gt;0$&lt;/span&gt; are optimization variables, and &lt;span class=&quot;math-container&quot;&gt;$a,b,c,d,A$&lt;/span&gt; are positive constants. How to make it a convex constraint?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\frac{{ax}}{{\ln (b + cy)}} + dx \le A&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3864" LastEditorUserId="123" LastEditDate="2021-06-19T08:44:06.100" LastActivityDate="2021-06-22T00:19:33.197" Title="How to make following constraint a convex one?" Tags="|constraint|convex-optimization|convexity|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6466" PostTypeId="2" ParentId="6465" CreationDate="2021-06-19T12:28:14.080" Score="8" Body="&lt;p&gt;The constraint is not convex, and is not transformable to a convex constraint without substantively changing it.&lt;/p&gt;&#xA;&lt;p&gt;The additive linear term &lt;span class=&quot;math-container&quot;&gt;$dx$&lt;/span&gt; is irrelevant to convexity. So let's ignore it and look at the simple case of &lt;span class=&quot;math-container&quot;&gt;$a = b = c = 1$&lt;/span&gt;. The Hessian of &lt;span class=&quot;math-container&quot;&gt;$\frac{{ax}}{{\ln (b + cy)}}$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$x = y = 1$&lt;/span&gt; has one positive and one negative eigenvalue. Hence &lt;span class=&quot;math-container&quot;&gt;$\frac{{ax}}{{\ln (b + cy)}}$&lt;/span&gt; is neither convex nor concave. Therefore the constraint is not convex. In order for the constraint to be convex, that term would have to be convex, which it is not.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2021-06-19T12:28:14.080" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6467" PostTypeId="1" AcceptedAnswerId="6468" CreationDate="2021-06-20T15:15:40.303" Score="4" ViewCount="350" Body="&lt;p&gt;I've recently started to study how to formulate optimization problems as QUBO models through this paper/tutorial: &lt;a href=&quot;https://arxiv.org/pdf/1811.11538.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/1811.11538.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;One of the steps is to transform the inequalities of the original optimization problem (in an LP formulation for example) into equalities by adding a slack variable.&#xA;In the example below (taken from page 17) is quite trivial how the bound was found to be 7, assuming x1 = x2 = 0 and x3 = 1, which is the &amp;quot;worst case&amp;quot; or the &amp;quot;furthest&amp;quot; we can be from 6 in the right hand side.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OIfq4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OIfq4.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;==============================================================&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, in page 25 there's another example which is making me a bit puzzled:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7KKwK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7KKwK.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm failing to understand why 3 and 6 were chosen as the bounds here.&lt;/p&gt;&#xA;&lt;p&gt;For example, for the first constraint, why isn't the bound 7? (assuming x1=x2=x3=x4=x5=0)&lt;/p&gt;&#xA;&lt;p&gt;As for the third constraint, why isn't the bound 11? (assuming x1=x2=x3=x4=x5=1, so we'd have -16 + s &amp;lt;= -5)&lt;/p&gt;&#xA;&lt;p&gt;Any help will be much appreciated! Maybe there's something obvious which I haven't realized :)&lt;/p&gt;&#xA;" OwnerUserId="5739" LastEditorUserId="727" LastEditDate="2021-07-26T22:55:54.733" LastActivityDate="2021-07-26T22:55:54.733" Title="Why are the bounds 3 and 6 instead of 7, in this binary expansion of a slack variable in this QUBO problem?" Tags="|combinatorial-optimization|binary-variable|quadratic-programming|unconstrained-optimization|qubo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6468" PostTypeId="2" ParentId="6467" CreationDate="2021-06-20T15:30:32.327" Score="3" Body="&lt;p&gt;According to the equality constraint (the equal to 4 one), at least two of the &lt;span class=&quot;math-container&quot;&gt;$x_{?}$&lt;/span&gt; are 1. Therefore, the slack for the 1st constraint is at most 3.&lt;/p&gt;&#xA;&lt;p&gt;According to the equality constraint, the worst case is &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_4$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_5$&lt;/span&gt; are 1 while other xs are 0. The slack is 6 in that case for the 3rd constraint.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, we can approximate the bound of the slacks by noticing that the coefficients in each inequality constraint are all bigger than the coefficients in the equality constraint. Therefore we can at least subtract 4 from the bound of the slacks of the inequality constraints. 7 - 4 = 3 and 11 - 4 = 7 (ok, that is not 6).&lt;/p&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="5705" LastEditDate="2021-06-20T15:51:49.457" LastActivityDate="2021-06-20T15:51:49.457" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6469" PostTypeId="2" ParentId="6465" CreationDate="2021-06-20T19:18:08.773" Score="0" Body="&lt;p&gt;Transform the optimizing variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in everything (the whole model) to &lt;span class=&quot;math-container&quot;&gt;$u = \frac{ax}{\ln(b + cy)}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v = x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Transformed constraint &lt;span class=&quot;math-container&quot;&gt;$u + dv \le A$&lt;/span&gt; is linear.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, the transformed constraint in terms of &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is convex.&lt;/p&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="5705" LastEditDate="2021-06-22T00:19:33.197" LastActivityDate="2021-06-22T00:19:33.197" CommentCount="23" ContentLicense="CC BY-SA 4.0" />
  <row Id="6472" PostTypeId="2" ParentId="6402" CreationDate="2021-06-21T02:37:47.903" Score="4" Body="&lt;p&gt;[Moderators - this answer might be more appropriate in the comments - feel free to move if you agree].&lt;/p&gt;&#xA;&lt;p&gt;When you say the size of timesteps, do you mean you have estimates of travel times for an entire year and you're looking at estimating the travel speeds for every 4 hours within the year, is this correct? So by step size you mean '&lt;em&gt;period in which I assume a constant value of travel time, which I then feed into my TSP solver&lt;/em&gt;'?&lt;/p&gt;&#xA;&lt;p&gt;If this is correct, I don't believe there's any standard. However I can tell you what we do in our commercial VRP solver &lt;a href=&quot;https://odllive.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://odllive.com/&lt;/a&gt;. Using our 'standard speeds' profile, we consider travel time in hour-sized 'buckets'/timesteps, with bucket chosen based on the departure time. A journey can span several 'buckets' (e.g. several timesteps) so that also needs to be taken account of. Pretty obviously we don't store 'buckets' for an entire year though (e.g. currently we just store them for 1 weekday profile and 1 weekend profile, giving 48 max, and we then merge buckets which are basically the same).&lt;/p&gt;&#xA;&lt;p&gt;I would guesstimate an hour is about the minimum viable step size when you consider rush hour profiles from different cities around the world (e.g. see figure 2 in &lt;a href=&quot;https://www.nature.com/articles/s41597-019-0159-6&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="825" LastActivityDate="2021-06-21T02:37:47.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6475" PostTypeId="1" CreationDate="2021-06-21T14:55:21.760" Score="3" ViewCount="120" Body="&lt;h3&gt;Question&lt;/h3&gt;&#xA;&lt;p&gt;Does a transformation of the following problem to convex optimization exist?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned} \label{1}&#xA;    \min_{\vec{x}, \vec{y}} \quad &amp;amp; F(\vec{x}, \vec{y}) \\&#xA;    \textrm{s.t.} \quad&#xA;        &amp;amp;F(\vec{x}, \vec{y}) \le 0 \\&#xA;        &amp;amp;G(\vec{x}) = 0    \\&#xA;        &amp;amp;H(\vec{x}, \vec{y}) \le 0 \\&#xA;        &amp;amp; \forall n: x_n &amp;gt; 0 \\&#xA;        &amp;amp; \forall n: y_n &amp;gt; 0&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;F(\vec{x}, \vec{y}) = \left[ \sum_{n=1}^{N} f_n(x_n, y_n) \right ] - A\\&#xA;G(\vec{x}) = \left[ \sum_{n=1}^{N} x_n \right] - 1 \\&#xA;H(\vec{x}, \vec{y}) = \left[ \sum_{n=1}^{N} h_n(x_n, y_n) \right] - C&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; are positive constants and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;f_n(x_n, y_n) &amp;amp;= a_n x_n + b_n y_n \\&#xA;h_n(x_n, y_n) &amp;amp;= c_n e^{x_n / y_n}&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$a_n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_n$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$c_n$&lt;/span&gt; are positive constants.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Simplification&lt;/h3&gt;&#xA;&lt;p&gt;There are two cases. I will try case B first.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Case A.&lt;/em&gt; Rewrite &lt;span class=&quot;math-container&quot;&gt;$x_1 = 1 - \sum_{n=2}^{N} x_{n}$&lt;/span&gt; and get rid of the equality constraint. After that, we can transform both &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_n$&lt;/span&gt;. However, the Hessians are not block diagonal.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Case B.&lt;/em&gt; Keep the equality constraint. The model is a convex optimization when &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; are convex functions and &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; remains affine. The constraint containing &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; has to remain an affine equation because it is an equality constraint. That means we can only apply an affine transform to the equality constraint, which means applying the transform to &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt;. Since an affine transform doesn't change the convexity of the &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; functions, it makes sense to not transform &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The good news is that the Hessians of &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; are block diagonal. A function is convex if its Hessian is positive semi-definite. A block diagonal matrix is positive semi-definite if all of its blocks are positive semi-definite. Therefore, &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; are convex functions if the &lt;span class=&quot;math-container&quot;&gt;$f_n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h_n$&lt;/span&gt; are all convex functions.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, in case B, finding a transformation &lt;span class=&quot;math-container&quot;&gt;$y(x, z)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$f(x, y) = ax + y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h(x, y) = e^{x/y}$&lt;/span&gt; is sufficient.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Hessian for transformed &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;&lt;/h3&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$y = q(x, z)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{1} f(x, z) = ax + q$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ f_{x} = a + q_{x} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ f_{xx} = q_{xx} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ f_{xz} = q_{xz} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ f_{zz} = q_{zz} $$&lt;/span&gt;&#xA;where&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f_x = \frac{\partial f}{\partial x}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Therefore, the Hessian of the transformed &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{2} H_f = H_q = \begin{bmatrix} q_{xx} &amp;amp; q_{xz} \\ q_{zx} &amp;amp; q_{zz} \end{bmatrix}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A symmetric matrix is positive definite if all determinants of the upper-left sub-matrices are positive (&lt;a href=&quot;https://en.wikipedia.org/wiki/Sylvester%27s_criterion&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sylvester's criterion&lt;/a&gt;). Therefore, we have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{3}\label{3}q_{xx} &amp;gt; 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\tag{4}\label{4}\det(H_{q}) = q_{xx} q_{zz} - q_{xz}^{2} &amp;gt; 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Hessian for transformed &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt;&lt;/h3&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{5} h(x, z) = e^{x/q}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;h_x &amp;amp;= e^{x/q}q^{-1} \\&#xA;h_z &amp;amp;= e^{x/q}\cdot x \cdot -q^{-2} \cdot q_{z} = -e^{x/q}xq^{-2}q_{z} \\&#xA;h_{xx} &amp;amp;= e^{x/q}q^{-2} \\&#xA;h_{xz} &amp;amp;= h_{z} q^{-1} + e^{x/q} \cdot -q^{-2} \cdot q_{z}\\&#xA;       &amp;amp;= -e^{x/q}xq^{-2}q_{z}q^{-1} - e^{x/q} q^{-2} q_{z} \\&#xA;       &amp;amp;= -e^{x/q}xq^{-3}q_{z} - e^{x/q} q^{-2} q_{z} \\&#xA;       &amp;amp;= -e^{x/q}q^{-3} \left( xq_{z} + qq_{z} \right) \\&#xA;       &amp;amp;= -e^{x/q}q^{-3} q_{z} \left( x + q \right) \\&#xA;h_{zz} &amp;amp;= -h_{z}xq^{-2}q_{z} -e^{x/q}x\cdot -2q^{-3}q_{z} \cdot q_{z} - e^{x/q}xq^{-2}q_{zz} \\&#xA;       &amp;amp;= e^{x/q}xq^{-2}q_{z}xq^{-2}q_{z} + e^{x/q}q^{-3}&#xA;       \left( 2x q_{z}^{2} - xq q_{zz} \right) \\&#xA;       &amp;amp;= e^{x/q}q^{-3}\left( 2xq_{z}^{2} - xq q_{zz} - x^{2}q^{-1} q_{z}^{2} \right)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{7} H_h = q^{-3}e^{x/q}&#xA;\begin{bmatrix} q &amp;amp; - \left(x + q \right)q_{z} \\ &#xA;- \left(x + q \right)q_{z} &amp;amp;  2xq_{z}^{2} - xq q_{zz} - x^{2}q^{-1} q_{z}^{2} &#xA;\end{bmatrix}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Recall that we constraint &lt;span class=&quot;math-container&quot;&gt;$q = y &amp;gt; 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1 \ge x &amp;gt; 0$&lt;/span&gt; in the optimization problem. Therefore, &lt;span class=&quot;math-container&quot;&gt;$q^{-3}e^{x/q} &amp;gt; 0$&lt;/span&gt;. By Sylvester's criterion, we have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{8}q &amp;gt; 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\tag{9}\label{9} &#xA;\det(H_{h}) = &#xA;2xqq_{z}^{2} - xq^{2} q_{zz} - x^{2}q_{z}^{2} - \left(x + q\right)^{2}q_{z}^{2} &amp;gt; 0 \\&#xA;\iff&#xA; 2xqq_{z}^{2} - xq^{2} q_{zz} - x^{2}q_{z}^{2} - \left(x^{2} + 2qx + q^{2}\right)q_{z}^{2} &amp;gt; 0 \\&#xA;\iff&#xA;- xq^{2} q_{zz} - 2x^{2}q_{z}^{2} - q^{2}q_{z}^{2} &amp;gt; 0 \\&#xA;\iff&#xA;- xq^{2} q_{zz} &amp;gt; (2x^{2} + q^{2}) q_{z}^{2}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;But \eqref{9} implies &lt;span class=&quot;math-container&quot;&gt;$q_{zz} &amp;lt; 0$&lt;/span&gt;. \eqref{4} and &lt;span class=&quot;math-container&quot;&gt;$q_{zz} &amp;lt; 0$&lt;/span&gt; together imply &lt;span class=&quot;math-container&quot;&gt;$q_{xx} &amp;lt; 0$&lt;/span&gt;, which contradicts \eqref{3}.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, case B doesn't work.&lt;/p&gt;&#xA;&lt;p&gt;Is there an easier way to prove that case B won't work?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;What about case A?&lt;/p&gt;&#xA;&lt;p&gt;I am not sure if case A can work. Rewriting &lt;span class=&quot;math-container&quot;&gt;$x_{1}$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$1 - \sum_{n=2}^{N} x_{n}$&lt;/span&gt; is a projection from &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^{n}$&lt;/span&gt; to the standard simplex, which is within a subspace of &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^{n}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The projection of a convex set of points to a subspace is also a convex set (&lt;a href=&quot;https://inst.eecs.berkeley.edu/%7Eee127/sp21/livebook/exa_cp_proj_subspace.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Projection of a convex set on a subspace&lt;/a&gt;). But the converse is not necessarily true. Shadow of a cube with a corner pushed in (as in the difference between a big cube and small cube at one corner of the big cube) can become a square. Therefore, projection of a non-convex set can be a convex set.&lt;/p&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="5705" LastEditDate="2021-06-22T00:44:35.917" LastActivityDate="2021-06-22T00:44:35.917" Title="Existence of a transformation to convex optimization" Tags="|optimization|convex-optimization|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6476" PostTypeId="1" AcceptedAnswerId="6477" CreationDate="2021-06-21T18:30:24.747" Score="6" ViewCount="602" Body="&lt;p&gt;I see here and there, mostly in operations research courses in France that the Bellman-Ford algorithm related to shortest paths is called the Bellman-Kalaba algorithm. Could you explain the reason why it is called like that?&lt;/p&gt;&#xA;&lt;p&gt;I searched and found a scientist named Roger Kalaba who seems to have been working with Bellman a lot. Why don't we call the Bellman-Ford-Kalaba algorithm? Is Bellman-Ford more spread than Bellman-Kalaba because Ford's contribution is bigger?&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="123" LastEditDate="2021-06-21T19:30:29.210" LastActivityDate="2021-06-21T19:30:29.210" Title="Why is the Bellman-Ford's shortest path algorithm sometimes called Bellman-Kalaba?" Tags="|history|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6477" PostTypeId="2" ParentId="6476" CreationDate="2021-06-21T19:24:23.557" Score="5" Body="&lt;p&gt;Interesting historical question. In Section 8.7, Chapter 8 of &lt;a href=&quot;https://jeffe.cs.illinois.edu/teaching/algorithms/book/Algorithms-JeffE.pdf&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;Algorithms&lt;/em&gt; (2019)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;, Erickson notes that&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The simplest implementation of Ford’s generic shortest-path algorithm was&#xA;first sketched by Alfonso Shimbel in 1954, described in more detail by Edward&#xA;Moore in 1957, and independently rediscovered by Max Woodbury and George&#xA;Dantzig in 1957, by Richard Bellman in 1958, and by George Minty in 1958.&#xA;(Neither Woodbury and Dantzig nor Minty published their algorithms.) In full&#xA;compliance with Stigler’s Law, the algorithm is almost universally known as&#xA;Bellman-Ford, because Bellman explicitly used Ford’s 1956 formulation of relaxing edges, although some authors refer to &amp;quot;Bellman-Kalaba&amp;quot; and a few early sources refer to &amp;quot;Bellman-Shimbel&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In particular, the name Bellman-Kalaba is occasionally used for the following reason:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This name is most likely a reference to Richard Bellman and Robert Kalaba’s monograph on dynamic programming and control theory&lt;sup&gt;&lt;a href=&quot;https://www.elsevier.com/books/dynamic-programming-and-modern-control-theory/bellman/978-0-08-091653-8&quot; rel=&quot;noreferrer&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;, which describes Bellman’s algorithm. Bellman and Kalaba also published an extension of Bellman’s algorithm in  that computes &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;th shortest paths, for any constant &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;sup&gt;&lt;a href=&quot;https://epubs.siam.org/doi/abs/10.1137/0108044?journalCode=smjmap.1&quot; rel=&quot;noreferrer&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Erickson, J. (2019). &lt;em&gt;Algorithms.&lt;/em&gt; University of Illinois Press. &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [2] Bellman, R., Kalaba, R. E. (1965). &lt;em&gt;Dynamic programming and modern control theory&lt;/em&gt; (Vol. 81). New York: Academic Press. &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [3] Bellman, R., Kalaba, R. (1960). On &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;th best policies. &lt;em&gt;Journal of the Society for Industrial and Applied Mathematics.&lt;/em&gt; 8(4):582-588. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2021-06-21T19:29:33.387" LastActivityDate="2021-06-21T19:29:33.387" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6479" PostTypeId="1" AcceptedAnswerId="6480" CreationDate="2021-06-22T11:36:22.723" Score="5" ViewCount="623" Body="&lt;p&gt;Apologies if this question has been asked, but I haven't been able to find it. I'm modelling something with Gurobi and want to do the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{cond} &amp;lt; \dfrac{1}{3} &amp;amp;\iff x = 1,\\\dfrac{1}{3} \leq \text{cond} \leq \dfrac{2}{3} &amp;amp;\iff y = 1,\\\dfrac{2}{3} &amp;lt;\text{cond}\leq 1 &amp;amp;\iff z = 1\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (x,y,z) \in \{0,1\}^{3}, 0\leq \text{cond}\leq 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So, three indicator variables depending on &lt;span class=&quot;math-container&quot;&gt;$\text{cond}$&lt;/span&gt;. I managed to model the left implications (e.g. &lt;span class=&quot;math-container&quot;&gt;$\text{cond}\leq \dfrac{1}{3} + 2(1-x)$&lt;/span&gt;), but I'm having a bit of trouble with the right side and making sure it all ties together.&lt;/p&gt;&#xA;" OwnerUserId="5352" LastEditorUserId="500" LastEditDate="2021-06-22T13:58:08.180" LastActivityDate="2021-06-22T13:58:08.180" Title="Model &quot;if and only if&quot; indicator constraints in Linear programming" Tags="|linear-programming|linearization|logical-constraints|indicator-constraints|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6480" PostTypeId="2" ParentId="6479" CreationDate="2021-06-22T12:55:37.817" Score="7" Body="&lt;p&gt;Without using a small epsilon, you can’t enforce strict inequality.  Here’s one approach that allows ambiguity at the endpoints of each interval, as your proposed constraint does:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x+y+z=1\\&#xA;0x+\frac{1}{3}y+\frac{2}{3}z&#xA;\le \text{cond} \le&#xA;\frac{1}{3}x+\frac{2}{3}y+1z&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-06-22T12:55:37.817" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6481" PostTypeId="1" CreationDate="2021-06-22T13:50:36.333" Score="2" ViewCount="138" Body="&lt;p&gt;There are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; jobs with different processing times, and they should be scheduled on &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; identical machines such that the &lt;em&gt;smallest&lt;/em&gt; completion time is as &lt;em&gt;large&lt;/em&gt; as possible. This problem is NP-hard even for &lt;span class=&quot;math-container&quot;&gt;$m=2$&lt;/span&gt;, by reduction from partition. I am looking for an FPTAS for it.&lt;/p&gt;&#xA;&lt;p&gt;I found an FPTAS for a very similar problem: making the &lt;em&gt;largest&lt;/em&gt; completion time (the &amp;quot;makespan&amp;quot;) as &lt;em&gt;small&lt;/em&gt; as possible. It is in this paper:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Sartaj K. Sahni (1976). &lt;a href=&quot;https://doi.org/10.1145/321921.321934&quot; rel=&quot;nofollow noreferrer&quot;&gt;Algorithms for Scheduling Independent Tasks&lt;/a&gt;. Journal of the ACM. 23 (1): 116–127.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There is an algorithm that finds a schedule with makespan at most &lt;span class=&quot;math-container&quot;&gt;$1+\epsilon$&lt;/span&gt; of the minimum in time &lt;span class=&quot;math-container&quot;&gt;$O(n\cdot (n^2 / \epsilon)^{m-1})$&lt;/span&gt;. This is an FPTAS for any fixed &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For the original problem, which is to make the &lt;em&gt;smallest&lt;/em&gt; finish time as &lt;em&gt;large&lt;/em&gt; as possible, I only found a PTAS:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Gerhard Woeginger (1997). &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0167637796000557&quot; rel=&quot;nofollow noreferrer&quot;&gt;A polynomial-time approximation scheme for maximizing the minimum machine completion time&lt;/a&gt;. Operations Research Letters. 20 (4): 149-154.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;But the author considers it &amp;quot;impractical&amp;quot;. Is there an FPTAS for this problem?&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, since the 1976 paper is quite hard for me to understand: is there a simpler FPTAS for minimizing the makespan, or a paper that explains the above FPTAS in a simpler way?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="2576" LastEditDate="2021-06-22T15:39:08.260" LastActivityDate="2021-06-22T15:39:08.260" Title="Maximizing the minimum machine completion time" Tags="|scheduling|approximation-algorithms|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6482" PostTypeId="1" AcceptedAnswerId="6483" CreationDate="2021-06-22T19:14:57.353" Score="6" ViewCount="489" Body="&lt;p&gt;I'm totally new to the world of optimization and I have an optimization problem that I think it can be formulated as Mixed Integer Quadratically Constrained Quadratic Program (QCQP) but I'm not sure of it. I know that (QCQP) has the following format: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_x&amp;amp;\quad\frac12x^\top Hx+f^\top x\\\text{s.t.}&amp;amp;\quad Ax\le b\\&amp;amp;\quad A_{\rm eq}x=b_{\rm eq}\\&amp;amp;\quad\ell_b\le x\le u_b\\&amp;amp;\quad x^\top Qx+\ell^\top x\le r\\&amp;amp;\quad x_i\in\Bbb Z\\&amp;amp;\quad x_j\in\{0,1\}\end{align}&lt;/span&gt;&#xA;My optimization problem can be formulated in this form but has only cross product terms between the decision variables without any quadratic term. Here is my optimization formulation: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_{x_{ij},y_{ij}\,\forall i,j}&amp;amp;\quad\sum_{j=0}^K\sum_{i=0}^Np_{ij}y_{ij}x_{ij}\\\text{s.t.}&amp;amp;\quad\sum_{i=0}^Ny_{ij}x_{ij}=z_j^\max&amp;amp;\quad\forall j\in\{0,\cdots,K\}\\&amp;amp;\quad\sum_{j=0}^Kx_{ij}\le 1&amp;amp;\quad\forall i\in\{0,\cdots,N\}\\&amp;amp;\quad x_{ij}\in\{0,1\}&amp;amp;\quad\forall i\in\{0,\cdots,N\}\quad\text{and}\quad\forall j\in\{0,\cdots,K\}\\&amp;amp;\quad y^\min\le y_{ij}\le y^\max&amp;amp;\quad\forall i\in\{0,\cdots,N\}\quad\text{and}\quad\forall j\in\{0,\cdots,K\}\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; are my decision variables &lt;span class=&quot;math-container&quot;&gt;$\forall i, j$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$z^{\max}_j \forall j$&lt;/span&gt; are some constants. &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; are binary decision variables while &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; are continuous decision variables.&lt;/p&gt;&#xA;&lt;p&gt;I tried to formulate it and here is the &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; matrix value for &lt;span class=&quot;math-container&quot;&gt;$K = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N = 2$&lt;/span&gt; &lt;strong&gt;as an example&lt;/strong&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;H = &#xA;\begin{bmatrix}&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0\\&#xA;1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0\\&#xA;0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0\\&#xA;\end{bmatrix}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is this correct? Or do you think the problem should be linearly relaxed instead of formulating it in this way?&lt;/p&gt;&#xA;" OwnerUserId="5671" LastEditorUserId="123" LastEditDate="2021-06-23T07:13:52.210" LastActivityDate="2021-06-23T07:13:52.210" Title="Solving Quadratically Constrained Quadratic Program with Cross Product Terms Only" Tags="|optimization|mixed-integer-programming|constraint-programming|convex-optimization|quadratic-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6483" PostTypeId="2" ParentId="6482" CreationDate="2021-06-22T20:15:49.807" Score="11" Body="&lt;p&gt;Rather than solving this directly as MIQCQP, you might consider linearizing the products &lt;span class=&quot;math-container&quot;&gt;$y_{ij} x_{ij}$&lt;/span&gt;, as shown &lt;a href=&quot;https://or.stackexchange.com/questions/6028/mixed-integer-optimization-with-bilinear-constraint&quot;&gt;here&lt;/a&gt;, yielding instead an MILP problem.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-06-22T20:15:49.807" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6484" PostTypeId="1" AcceptedAnswerId="6485" CreationDate="2021-06-23T10:14:58.697" Score="11" ViewCount="633" Body="&lt;p&gt;The linear program&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA; \min &amp;amp;\sum_{i=1}^nc_{i}x_{i}\\\&#xA;\mbox{s.t.:}&amp;amp;\sum_{i=1}^nx_{i}=1,\\\&#xA;&amp;amp;x_{i}\geq 0,&amp;amp;&amp;amp;\forall i=1,\dots,n&#xA;\end{align}&lt;/span&gt;&#xA;has a trivial optimal solution which is to simply: find an &lt;span class=&quot;math-container&quot;&gt;$i^*\in\arg\min_{i=1,...,n}\{c_{i}\}$&lt;/span&gt; and then set &lt;span class=&quot;math-container&quot;&gt;$x_{i^*}=1$&lt;/span&gt; - the rest of the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;'s should be zero. However, the quadratic program&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA; \min &amp;amp;\sum_{i=1}^nc_{i}x_{i} + \sum_{i=1}^n \beta_{i}x_{i}^2\\\&#xA;\mbox{s.t.:}&amp;amp;\sum_{i=1}^nx_{i}=1,\\\&#xA;&amp;amp;x_{i}\geq 0,&amp;amp;&amp;amp;\forall i=1,\dots,n,&#xA;\end{align}&lt;/span&gt;&#xA;doesn't exhibit this nice &amp;quot;single assignment&amp;quot; property. Albeit, the structure is rather simple, and one could expect that there is a simple way to solve the program anyway. So the questions are&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Does the quadratic program have a closed form solution, that I just haven't thought of?&lt;/li&gt;&#xA;&lt;li&gt;If the answer to 1. is &amp;quot;No&amp;quot;, what would be your approach to solving (to optimality) this problem fast, given the simple  structure?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;For my purpose, we can assume that both &lt;span class=&quot;math-container&quot;&gt;$c_{i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta_{i}$&lt;/span&gt; are non-negative.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-06-25T11:08:21.927" Title="Efficient way to solve &quot;easy&quot; quadratic optimization problem" Tags="|quadratic-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6485" PostTypeId="2" ParentId="6484" CreationDate="2021-06-23T11:31:02.437" Score="8" Body="&lt;h2&gt;Fast resolution&lt;/h2&gt;&#xA;&lt;p&gt;Let's start with speeding up the solution process. For the optimal solutions, all variables will be either inactive (&lt;span class=&quot;math-container&quot;&gt;$x_i = 0$&lt;/span&gt;) or, due to &lt;span class=&quot;math-container&quot;&gt;$\sum x_i = 1$&lt;/span&gt;, contribute equally to the gradient. So, for some &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt;, either:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_i \geq \gamma$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;or &lt;span class=&quot;math-container&quot;&gt;$c_i + 2\beta_i x_i = \gamma$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In particular, the active variables will be the ones with smallest &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To solve the problem, we sort the variables by &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;, and solve the unconstrained problem with &lt;span class=&quot;math-container&quot;&gt;$1 \leq k \leq n$&lt;/span&gt; active variables.&#xA;The solution that satisfies the above equations and the non-negativity constraints is the optimal solution.&lt;/p&gt;&#xA;&lt;h2&gt;Closed form solution&lt;/h2&gt;&#xA;&lt;p&gt;Thankfully, there is a closed form solution for this problem.&lt;/p&gt;&#xA;&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$x_i = \frac{\gamma - c_i}{2\beta_i}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\sum \frac{\gamma - c_i}{2\beta_i} = 1$&lt;/span&gt;, you get &lt;span class=&quot;math-container&quot;&gt;$\gamma \sum_i \frac{1}{\beta_i} - \sum_i \frac{c_i}{\beta_i} = 2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And finally &lt;span class=&quot;math-container&quot;&gt;$\gamma = \frac{2 + \sum_i \frac{c_i}{\beta_i}}{\sum_i \frac{1}{\beta_i}}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Algorithm&lt;/h2&gt;&#xA;&lt;p&gt;So, now our algorithm is to sort the variables by &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;, then compute &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; first variables active, &lt;span class=&quot;math-container&quot;&gt;$1 \leq k \leq n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then we find &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; for which, with some tolerance:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the inactive variables satisfy &lt;span class=&quot;math-container&quot;&gt;$c_i \geq \gamma$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;the active variables satisfy &lt;span class=&quot;math-container&quot;&gt;$\frac{\gamma - c_i}{2\beta_i} \geq 0$&lt;/span&gt; i.e. &lt;span class=&quot;math-container&quot;&gt;$c_i \leq \gamma$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Please check my calculations before using ;)&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2021-06-25T11:08:21.927" LastActivityDate="2021-06-25T11:08:21.927" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6487" PostTypeId="2" ParentId="6413" CreationDate="2021-06-24T14:57:20.160" Score="3" Body="&lt;p&gt;Yes, you can. For example, with Pyomo package, the gurobi solver is selected using the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;opt = SolverFactory(&amp;quot;gurobi&amp;quot;, solver_io='python')&#xA;opt.options[&amp;quot;NonConvex&amp;quot;] = 2&#xA;opt.options['MIPGap'] = 0.01&#xA;opt.options['SolCount'] = 2&#xA;&#xA;results = opt.solve(model, load_solutions=True, tee=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The attributes of gurobi solver can be visited by using &lt;code&gt;opt._solver_model&lt;/code&gt;. For example, you can see the number of solutions by calling its attribute of &lt;code&gt;'SolCount'&lt;/code&gt; as &lt;code&gt;opt._solver_model.SolCount&lt;/code&gt;. Similarly, you can access the multiple solutions by using its attribute &lt;code&gt;Xn&lt;/code&gt; in the same way as using &amp;quot;Gurobi&amp;quot; directly. For example, you can access all the solutions in this way:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xs=[]&#xA;for s in range(opt._solver_model.SolCount):&#xA;   opt._solver_model.params.SolutionNumber = s&#xA;   x=opt._solver_model.getAttr(&amp;quot;Xn&amp;quot;)&#xA;   xs.append(x)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Similarly, you can access all gurobi solver's attributes. BTW, you can read the code under pyomo package to see how pyomo visits gurobi solver in the directory of &lt;code&gt;...\Lib\site-packages\pyomo\solvers\plugins\solvers\gurobi_direct.py&lt;/code&gt;. Hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="5756" LastEditorUserId="5705" LastEditDate="2021-06-25T10:49:51.423" LastActivityDate="2021-06-25T10:49:51.423" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6488" PostTypeId="2" ParentId="6457" CreationDate="2021-06-25T13:43:38.220" Score="2" Body="&lt;p&gt;In your specific instance you use only a single index for a two-dimensional variable matrix, causing the KeyError.&lt;/p&gt;&#xA;&lt;p&gt;You should loop over the index sets from your model to produce the results, so for example:&#xA;&lt;code&gt;outputVariables_list =  [model.variable_heatGenerationCoefficient_SpaceHeating[building, time_slot], model.variable_temperatureBufferStorage[building, time_slot], model.param_heatDemand_In_W[building, time_slot] for building in model.set_buildings_BT1 for time_slot in model.set_timeslots]&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5765" LastActivityDate="2021-06-25T13:43:38.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6489" PostTypeId="2" ParentId="6317" CreationDate="2021-06-25T14:14:51.383" Score="4" Body="&lt;p&gt;I recommand the Model Building Book by Williams and here you may see the &lt;a href=&quot;https://www.linkedin.com/pulse/model-building-oplcplex-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;examples in OPL&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3O9YL.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3O9YL.jpg&quot; alt=&quot;Model Building&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let me add some OPL links:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/pulse/how-opl-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to with OPL ?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/pulse/tips-tricks-opl-cplex-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tips and tricks&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/pulse/javascript-within-opl-cplex-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OPL Scripting&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/pulse/excel-rocket-science-optimization-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OPL and Excel&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Making Optimization Simple&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-06-25T14:14:51.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6490" PostTypeId="1" CreationDate="2021-06-25T15:49:21.430" Score="3" ViewCount="221" Body="&lt;p&gt;I am trying to convert a boolean LP to LP using LP relaxation by converting &lt;span class=&quot;math-container&quot;&gt;$x \in {0,1}$&lt;/span&gt; to both  &lt;span class=&quot;math-container&quot;&gt;$x \ge 0$&lt;/span&gt; and  &lt;span class=&quot;math-container&quot;&gt;$x \le 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then to use it in my problem analysis, I am trying to build the KKT conditions. After multiplying each of them by lagrange multipliers (&lt;span class=&quot;math-container&quot;&gt;$\lambda,\mu$&lt;/span&gt;), I get&#xA;&lt;span class=&quot;math-container&quot;&gt;$\lambda x \ge 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu x \le 1 $&lt;/span&gt;.&#xA;After differentiating and equating to zero I get these:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\frac{d}{d\lambda} = x = 0&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\frac{d}{d\mu} = x -1 = 0&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The equations can't be solved as a system of linear equations. How these can be solved?&lt;/p&gt;&#xA;" OwnerUserId="5766" LastEditorUserId="36" LastEditDate="2021-06-26T02:29:53.790" LastActivityDate="2021-06-26T06:54:17.163" Title="Linear Relaxation of Boolean Constraint for Solving Integer Linear Program Using KKT" Tags="|linear-programming|kkt-conditions|lp-relaxation|lagrange-multipliers|relaxation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6491" PostTypeId="2" ParentId="6490" CreationDate="2021-06-26T06:42:11.833" Score="1" Body="&lt;p&gt;Minimize &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$1 \le x \le 2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\min_{x} \quad &amp;amp; f(x)\\&#xA;\textrm{s.t.} \quad &amp;amp; h_{1}(x) \le 0\\&#xA;  &amp;amp;h_{2}(x) \le 0    \\&#xA;\end{aligned}&lt;/span&gt;&#xA;where&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;f(x) &amp;amp;= x^2 \\&#xA;h_{1}(x) &amp;amp;= 1 - x \\&#xA;h_{2}(x) &amp;amp;= x - 2&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;KKT conditions:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0 &amp;amp;= \nabla f(x) + \mu_{1}\nabla h_{1}(x) + \mu_{2} \nabla h_{2}(x) \\&#xA;&amp;amp;= 2x - \mu_{1} + \mu_{2} \\ &#xA;0 &amp;amp;= \mu_{1} h_{1}(x) = \mu_{1}(1-x) \\&#xA;0 &amp;amp;= \mu_{2} h_{2}(x) = \mu_{2}(x-2) \\&#xA;\mu_{1} &amp;amp;\ge 0 \\&#xA;\mu_{2} &amp;amp;\ge 0 &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$\mu_{1} = 0$&lt;/span&gt;, the &lt;span class=&quot;math-container&quot;&gt;$h_{1}(x)$&lt;/span&gt; constraint is inactive. Otherwise, the constraint is active. Active means the solution is at the boundary of the constraint.&lt;/p&gt;&#xA;&lt;p&gt;I think the KKT conditions mean there are three cases:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;span class=&quot;math-container&quot;&gt;$h_{1}$&lt;/span&gt; constraint is active and the &lt;span class=&quot;math-container&quot;&gt;$h_2$&lt;/span&gt; constraint is inactive. That means the minima is at the boundary of the feasible region and &lt;span class=&quot;math-container&quot;&gt;$x = 1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;span class=&quot;math-container&quot;&gt;$h_{1}$&lt;/span&gt; constraint is inactive and the &lt;span class=&quot;math-container&quot;&gt;$h_2$&lt;/span&gt; constraint is active. That means the minima is at the boundary of the feasible region and &lt;span class=&quot;math-container&quot;&gt;$x = 2$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Both constraints are inactive. That means the minima is in the interior of the feasible region and &lt;span class=&quot;math-container&quot;&gt;$0 = \nabla f(x)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="5705" LastEditDate="2021-06-26T06:54:17.163" LastActivityDate="2021-06-26T06:54:17.163" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6492" PostTypeId="1" AcceptedAnswerId="6494" CreationDate="2021-06-26T09:56:32.573" Score="5" ViewCount="154" Body="&lt;p&gt;Suppose we have the following objective function with one decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; is a fixed parameter for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and also, &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is a constant for the problem&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\label{eq} \max \sum^N_{i=1} p_i(a+1-x_i) = \max \bigg{(}\sum^N_{i=1} p_ia +\sum^N_{i=1}p_i -\sum^N_{i=1} p_i x_i\bigg{)}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As the first two components: &lt;span class=&quot;math-container&quot;&gt;$\sum^N_{i=1} p_ia $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum^N_{i=1}p_i$&lt;/span&gt; are fixed and changing &lt;span class=&quot;math-container&quot;&gt;$x_i  $&lt;/span&gt; won't affect them anyway. Is there any difference if I excluded the fixed components from the objective function and set the objective function to be&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} &#xA;\max \sum^N_{i=1} -p_ix_i = \min \sum^N_{i=1} p_ix_i?&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Of course, the objective function value is not the same before and after excluding the fixed components, but will the values of &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; be the same in both cases?&lt;/p&gt;&#xA;" OwnerUserId="3480" LastEditorUserId="3480" LastEditDate="2021-06-26T16:27:12.113" LastActivityDate="2021-06-26T17:56:43.377" Title="Is that Ok to exclude fixed components from an objective function?" Tags="|optimization|mixed-integer-programming|integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6494" PostTypeId="2" ParentId="6492" CreationDate="2021-06-26T17:56:43.377" Score="7" Body="&lt;p&gt;Excluding the constant portions of the objective function is perfectly fine. The optimal solutions will be unchanged and it should have no impact on how long the solver needs to solve the model.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-06-26T17:56:43.377" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6496" PostTypeId="1" CreationDate="2021-06-27T09:32:01.340" Score="1" ViewCount="264" Body="&lt;p&gt;I tried solving my model with xpress:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;pip install xpress&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And then in the model:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Solver = SolverFactory('xpress')&#xA;SolverResults = Solver.solve(myModel)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I get this error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;FICO Xpress Solver 64bit v8.5.6 Oct 17 2018&#xA;(c) Copyright Fair Isaac Corporation 1983-2017. All rights reserved&#xA; Optimizer v33.01.09    [C:\xpressmp\bin\xprs.dll]&#xA; &#xA;Reading Problem \tmp11lp1xyd.pyomo&#xA;Problem Statistics&#xA;       30975 (      0 spare) rows&#xA;        3073 (      0 spare) structural columns&#xA;      101189 (      0 spare) non-zero elements&#xA;        2304 quadratic elements in 240 quadratic constraints&#xA;Global Statistics&#xA;           0 entities        0 sets        0 set members&#xA;FICO Xpress v8.5.6, solve started 10:52:18, Jun 27, 2021&#xA;Minimizing QCQP \tmp11lp1xyd.pyomo&#xA;Original problem has:&#xA;     30975 rows         3073 cols       101189 elements&#xA;       240 qrows        2304 qrowelem&#xA;?900 Warning: The quadratic part of row 'c_u_x33568_' defines a nonconvex region. Please check your model or use Xpress-SLP&#xA;?422 Error: Solution is not available&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Any suggestions? How can I use this “Xpress-SLP” in python with pyomo? Is it some different solver that I would need to install like?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;pip install slpxpress&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5782" LastActivityDate="2021-06-27T09:32:01.340" Title="Solver issue? Xpress (slp) - Nonlinear - Python - Pyomo" Tags="|optimization|python|nonlinear-programming|pyomo|quadratic-programming|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6498" PostTypeId="2" ParentId="6426" CreationDate="2021-06-27T13:09:40.703" Score="2" Body="&lt;p&gt;I would advise Bayesian Optimization. The benefits imho are that they don’t require a gradient, work for a wide variety of optimization problems and are made for when we are dealing with functions that are hard or slow to evaluate.&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="123" LastEditDate="2021-06-27T13:56:28.513" LastActivityDate="2021-06-27T13:56:28.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6499" PostTypeId="1" CreationDate="2021-06-27T16:41:43.357" Score="2" ViewCount="295" Body="&lt;p&gt;Based on your experience, I want to know what is called an &lt;em&gt;acceptable&lt;/em&gt; lower-bound.&lt;/p&gt;&#xA;&lt;p&gt;I know it can be different based on the problem. For example, is 5% is an acceptable lower-bound gap for VRPTW? By gap, I mean (LB-OP)/OP * 100, where OP is the optimal value.&lt;/p&gt;&#xA;&lt;p&gt;Please share your thoughts with regard to the problem.&lt;/p&gt;&#xA;" OwnerUserId="172" LastActivityDate="2021-06-27T20:56:07.857" Title="What is an acceptable gap for a lower-bound?" Tags="|bounds|optimality-gap|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6500" PostTypeId="1" AcceptedAnswerId="6501" CreationDate="2021-06-27T16:58:38.467" Score="3" ViewCount="1102" Body="&lt;p&gt;A necessary condition in any quadratic programming to be convex is the matrix &lt;span class=&quot;math-container&quot;&gt;$\mathbf{Q}$&lt;/span&gt; in the formulation &lt;span class=&quot;math-container&quot;&gt;$x^\intercal \mathbf{Q}x$&lt;/span&gt; to be positive definite or positive semidefinite. Positive definiteness (PD) or semidefiniteness (PSD) requires the eigen values of the matrix either to be &lt;span class=&quot;math-container&quot;&gt;$&amp;gt; 0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\geq 0$&lt;/span&gt; respectively. Is the symmetry of the matrix &lt;span class=&quot;math-container&quot;&gt;$\mathbf{Q}$&lt;/span&gt; a necessary condition for the matrix to be PD or PSD?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.mathworks.com/help/matlab/math/determine-whether-matrix-is-positive-definite.html#DetermineWhetherMatrixIsSPDExample-2&quot; rel=&quot;nofollow noreferrer&quot;&gt;This link in Matlab documentations&lt;/a&gt; checks for the symmetry of the matrix before finding the eigen values. I can't find this information explicitly anywhere in any reference.&lt;/p&gt;&#xA;" OwnerUserId="5671" LastEditorUserId="38" LastEditDate="2022-01-24T12:44:45.870" LastActivityDate="2022-01-24T12:44:45.870" Title="Non-symmetric Positive Definite/Semidefinite Matrix in Quadratic Program" Tags="|optimization|convex-optimization|quadratic-programming|semidefinite-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6501" PostTypeId="2" ParentId="6500" CreationDate="2021-06-27T17:37:09.187" Score="9" Body="&lt;p&gt;Yes, a real PSD matrix &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a &lt;strong&gt;symmetric&lt;/strong&gt; matrix with &lt;span class=&quot;math-container&quot;&gt;$$x^TMx\ge 0$$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; (see e.g. &lt;a href=&quot;https://en.wikipedia.org/wiki/Definite_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Definite_matrix&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;However, this is not a real restriction. (We have two meanings of &amp;quot;real&amp;quot; here). We can form &lt;span class=&quot;math-container&quot;&gt;$$M' = \frac{M+M^T}{2}$$&lt;/span&gt; Now &lt;span class=&quot;math-container&quot;&gt;$M'$&lt;/span&gt; is symmetric and we have &lt;span class=&quot;math-container&quot;&gt;$$x^TM'x = x^TMx$$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. So you can make &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; symmetric by preprocessing it without affecting the solution.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2021-06-28T13:52:49.287" LastActivityDate="2021-06-28T13:52:49.287" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6502" PostTypeId="2" ParentId="6499" CreationDate="2021-06-27T20:56:07.857" Score="4" Body="&lt;p&gt;First off, I endorse Mark L. Stone's comment (which should be the answer).&lt;/p&gt;&#xA;&lt;p&gt;That said, what is considered an acceptable gap is likely to depend not only on the nature (and perhaps dimension) of the &lt;em&gt;problem&lt;/em&gt; being solved but also on the nature of the &lt;em&gt;model&lt;/em&gt; being used. If a model is known to have weak bounds, the user probably should be willing to accept a larger terminal gap. (Note that I said &lt;em&gt;should&lt;/em&gt; be.) If the model is known to have tight bounds, it would be more reasonable to hold out for a smaller terminal gap.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-06-27T20:56:07.857" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6503" PostTypeId="1" CreationDate="2021-06-27T21:28:52.543" Score="2" ViewCount="295" Body="&lt;p&gt;I am wondering if boolean constraints in a linear program can be solved (after linear relaxation from &lt;span class=&quot;math-container&quot;&gt;$x\in\{0,1\}$&lt;/span&gt; to both &lt;span class=&quot;math-container&quot;&gt;$x\ge0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x\le1$&lt;/span&gt;) using KKT analysis.&lt;/p&gt;&#xA;&lt;p&gt;Most of the algorithms that I have found were branch and bound-based, but I am trying to find an analytical solution using KKT conditions.&lt;/p&gt;&#xA;" OwnerUserId="5766" LastEditorUserId="123" LastEditDate="2021-06-27T21:32:22.843" LastActivityDate="2021-06-27T22:34:54.167" Title="KKT conditions analysis for binary constraints" Tags="|linear-programming|kkt-conditions|lp-relaxation|lagrange-multipliers|relaxation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6504" PostTypeId="2" ParentId="6503" CreationDate="2021-06-27T22:22:47.620" Score="2" Body="&lt;p&gt;Binary (Boolean) values are integer values. Therefore, optimization problems with boolean constraints are either integer programming or mixed integer programing (MIP).&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Generally&lt;/em&gt;, there is no easy algorithm that is guaranteed to find the optimal solution of MIP problems quickly. My reason to believe that is: I can implement a boolean satisfiability (b-sat) problem as a mixed integer programming problem. That means mixed integer programming problems is a super-set of b-sat problems. Since b-sat is NP-complete, mip is NP-hard.&lt;/p&gt;&#xA;&lt;p&gt;I think KKT condition is more like a check to see if a solution is a local optimum. I don't expect NP-hard problems to have simple analytical solution in general.&lt;/p&gt;&#xA;&lt;p&gt;Of course, &lt;em&gt;some&lt;/em&gt; problems with Boolean constraints can have analytical solution. But there is no general easy way to solve all MIP problems.&lt;/p&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="5705" LastEditDate="2021-06-27T22:34:54.167" LastActivityDate="2021-06-27T22:34:54.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6505" PostTypeId="1" CreationDate="2021-06-28T06:15:23.040" Score="2" ViewCount="1170" Body="&lt;p&gt;I would like to seek some advice on the following:&lt;/p&gt;&#xA;&lt;p&gt;I am currently using Pyomo to generate my MILP model in Pyomo and solve it using Gurobi, respectively.&lt;/p&gt;&#xA;&lt;p&gt;As the solution process is iterative, I would like to enquire on how to obtain the following timings for each iteration:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the time to build the Pyomo model&lt;/li&gt;&#xA;&lt;li&gt;the time to translate the Pyomo model into the format used by the solver&lt;/li&gt;&#xA;&lt;li&gt;the time spent inside the solver, i.e., the solution time&lt;/li&gt;&#xA;&lt;li&gt;the time spent loading the solver solution back into Pyomo.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="3682" LastEditDate="2021-06-28T20:44:10.500" LastActivityDate="2021-06-28T23:23:47.033" Title="Obtaining solver timings from Pyomo" Tags="|modeling|python|solver|gurobi|pyomo|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6506" PostTypeId="2" ParentId="6505" CreationDate="2021-06-28T23:23:47.033" Score="1" Body="&lt;p&gt;For timing within the gurobi solver, maybe you can call &lt;code&gt;&amp;lt;optimizer&amp;gt;.solve()&lt;/code&gt; method with &lt;code&gt;report_timing=True&lt;/code&gt;, as described in pyomo's documentation at&#xA;&lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/library_reference/solvers/gurobi_persistent.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pyomo.readthedocs.io/en/stable/library_reference/solvers/gurobi_persistent.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I haven't used Gurobi before. If gurboipy logs the starting and ending time of the optimization, then you can manually time the start and end of your whole program. That would give you 4 and 1 + 2.&lt;/p&gt;&#xA;&lt;p&gt;I think importing python library is slow. You can exclude the time for importing libraries.&lt;/p&gt;&#xA;&lt;p&gt;I don't know how to split 1 and 2 at the moment.&lt;/p&gt;&#xA;" OwnerUserId="5705" LastActivityDate="2021-06-28T23:23:47.033" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6507" PostTypeId="1" AcceptedAnswerId="6535" CreationDate="2021-06-29T08:53:06.340" Score="1" ViewCount="1299" Body="&lt;p&gt;I have been using Pyomo with a free Academic license for Gurobi and so far it worked quite well. Now my license expired and I received a new license that is stored in the folder&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;C:/Gurobi/gurobi.lic&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;However, when I now run Pyomo I get the error message:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;ApplicationError: Solver (gurobi) did not exit normally&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;and the error is thrown by the last of the following lines:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solver = pyo.SolverFactory('gurobi')&#xA;solver.options['MIPGap'] = 0.1&#xA;solver.options['TimeLimit'] = 100&#xA;solution = solver.solve(model, tee=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Do you have any idea why I now get this error? The license itself should be okay according to the Gurobi website (it expires in 2022). I just downloaded it to the before mentioned folder as recommended by Gurobi. Do I have to do anything else?&lt;/p&gt;&#xA;&lt;p&gt;I'd appreciate every comment.&lt;/p&gt;&#xA;&lt;p&gt;Update: Here is the full error message:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;runfile('C:/Users/wi9632/bwSyncShare3/Eigene Arbeit/Code/Python/Demand_Side_Management/Building_1_mHP_EV.py', wdir='C:/Users/wi9632/bwSyncShare3/Eigene Arbeit/Code/Python/Demand_Side_Management')&#xA;Traceback (most recent call last):&#xA;&#xA;  File &amp;quot;C:\Users\wi9632\bwSyncShare3\Eigene Arbeit\Code\Python\Demand_Side_Management\Building_1_mHP_EV.py&amp;quot;, line 589, in &amp;lt;module&amp;gt;&#xA;    solution = solver.solve(model, tee=True)&#xA;&#xA;  File &amp;quot;C:\Users\wi9632\Anaconda3\envs\tf\lib\site-packages\pyomo\opt\base\solvers.py&amp;quot;, line 602, in solve&#xA;    &amp;quot;Solver (%s) did not exit normally&amp;quot; % self.name)&#xA;&#xA;ApplicationError: Solver (gurobi) did not exit normally&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2021-06-29T12:43:34.417" LastActivityDate="2021-07-05T11:48:24.580" Title="Gurobi does not work any more in Pyomo after getting a new license" Tags="|solver|gurobi|pyomo|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6508" PostTypeId="2" ParentId="6507" CreationDate="2021-06-29T08:58:58.143" Score="1" Body="&lt;p&gt;You need to put the new licence in your terminal and run it&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&#xA;To install this license on a computer where Gurobi Optimizer is installed, copy and paste the following command to the Start/Run menu (Windows only) or a command/terminal prompt (any system like mac):&lt;/p&gt;&#xA;&lt;p&gt;Let's assume your licence is as follows&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;grbgetkey 58eab684-cd60-12eb-b669-0242ac120002&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The grbgetkey command requires an active internet connection.&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2021-06-30T00:15:21.280" LastActivityDate="2021-06-30T00:15:21.280" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6509" PostTypeId="2" ParentId="6507" CreationDate="2021-06-29T10:23:46.347" Score="3" Body="&lt;p&gt;This does not look like a license issue. This is a Pyomo error code. You should share some more info about the error message and other output before.&#xA;If your new license is stored in &lt;code&gt;C:\gurobi\gurobi.lic&lt;/code&gt;, Gurobi will find the license automatically and there is usually nothing else required to make it work.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&#xA;To test the license, it is better to either run &lt;code&gt;gurobi_cl&lt;/code&gt; from the full Gurobi installation or running this little Python code if only gurobipy is installed:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;m = gp.Model()&#xA;m.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="141" LastEditorUserId="141" LastEditDate="2021-06-30T20:26:49.367" LastActivityDate="2021-06-30T20:26:49.367" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="6510" PostTypeId="1" CreationDate="2021-06-29T14:55:15.370" Score="2" ViewCount="120" Body="&lt;p&gt;How to solve minimax mixed integer problem with a large high dimensional feasible region?&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\max_{\vec{x}}\min_{\vec{y}} \quad &amp;amp; \vec{r} \cdot \vec{x} + \vec{s} \cdot \vec{y}\\&#xA;\textrm{s.t.} \quad &amp;amp; A\vec{x} + B\vec{y} \succcurlyeq \vec{c}    \\&#xA;\end{aligned}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\vec{r}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\vec{s}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\vec{c}$&lt;/span&gt; are constants.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;A common trick is to introduce an auxiliary variable &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and rewrite the problem as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\max_{\vec{x}} \quad &amp;amp; \vec{r} \cdot \vec{x} + w \\&#xA;\textrm{s.t.} \quad &amp;amp; A\vec{x} + B\vec{y} \succcurlyeq \vec{c}    \\&#xA;\quad &amp;amp; \forall \vec{y}: \vec{s} \cdot \vec{y} \ge w&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\vec{y}$&lt;/span&gt; only has a few possible values, that can work. However, if &lt;span class=&quot;math-container&quot;&gt;$\vec{y}$&lt;/span&gt; has lots of possible values, implementing the constraint &lt;span class=&quot;math-container&quot;&gt;$\forall \vec{y}: -\vec{s} \cdot \vec{y} \ge w$&lt;/span&gt; by enumerating all possible &lt;span class=&quot;math-container&quot;&gt;$\vec{y}$&lt;/span&gt; is impractical.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I consider optimizing &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\vec{y}$&lt;/span&gt; alternately:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Randomly choose a feasible pair of &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\vec{y}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Fix &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt; and minimize over &lt;span class=&quot;math-container&quot;&gt;$\vec{y}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Fix &lt;span class=&quot;math-container&quot;&gt;$\vec{y}$&lt;/span&gt; and maximize over &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Repeat steps 2 and 3 till converge.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;But I worry the method might get stuck in cycles. For example, a function &lt;span class=&quot;math-container&quot;&gt;$q(x, y)$&lt;/span&gt;'s values is as follows.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;y&#xA;^ 1|2&#xA;| -+-&#xA;| 4|3&#xA;+-----&amp;gt; x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Maximizing over &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and minimizing over &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; by the above algorithm would lead to a never-ending cycle.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, alternately fixing &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\vec{y}$&lt;/span&gt; can make the algorithm get stuck in a local optima due to the constraints. For example, if one of the constraint is &lt;span class=&quot;math-container&quot;&gt;$x = y$&lt;/span&gt;, then fixing &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; means fixing &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and the algorithm would get stuck at a single point.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I also consider &amp;quot;rewriting&amp;quot; the problem as &lt;span class=&quot;math-container&quot;&gt;$\max_{\vec{x}, \vec{y}} \vec{r} \cdot \vec{x} - \vec{s} \cdot \vec{y}$&lt;/span&gt;. But I think that is wrong.&lt;/p&gt;&#xA;&lt;p&gt;Consider a prisoner's dilemma.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;             A cooperates  A defects&#xA;B cooperates    ( 0, 0)     (5, -5)&#xA;B defects       (-5, 5)     (0,  0)&#xA;&#xA;(a, b) means A's score is a and B's score is b.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A prisoner following the minimax strategy would maximize their minimal score over all possible actions of his opponent. For example, if prisoner A choose to cooperate, prisoner A's minimal score over all actions of prisoner B is -5 because prisoner B can choose to defect.&lt;/p&gt;&#xA;&lt;p&gt;If both prisoners follows the minimax strategy, they would both choose to defect. If I &amp;quot;rewrite&amp;quot; the objective, each prisoner would maximize their maximal score over all possible actions of his opponent. That means everyone cooperates is a global optima.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Bibliography&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Ghosh and Boyd. Minimax and Convex-Concave Games. 2004. &lt;a href=&quot;https://web.stanford.edu/class/ee392o/cvxccv.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://web.stanford.edu/class/ee392o/cvxccv.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Minimaximizes bilinear objective with &lt;em&gt;separable&lt;/em&gt; linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\min_{\vec{x}}\max_{\vec{y}} \quad &amp;amp; \vec{x}^{\intercal} P \vec{y} \\&#xA;\textrm{s.t.} \quad &amp;amp; A\vec{x} \preccurlyeq \vec{b} \\&#xA;  &amp;amp; C\vec{y} \preccurlyeq \vec{d}   \\&#xA;\end{aligned}&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Uses duality transform to rewrite the problem as a minimization problem solved by linear programming.&lt;/li&gt;&#xA;&lt;li&gt;Can rewrite &lt;span class=&quot;math-container&quot;&gt;$\max_{\vec{x}}\min_{\vec{y}} \vec{r} \cdot \vec{x}' + \vec{s} \cdot \vec{y}'$&lt;/span&gt; into a bilinear objective with some equality constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{bmatrix}&#xA;{\vec{x}'}^{\intercal} &amp;amp; \vec{s}^{\intercal}&#xA;\end{bmatrix}&#xA;I&#xA;\begin{bmatrix}&#xA;\vec{r} \\ \vec{y}'&#xA;\end{bmatrix}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Can I just directly add the non-separable constraints to the transformed problem?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Ahuja. Minimax linear programing problem. Operations research letters. 1985.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Linear programming. Not mixed. Looks like it is for a &lt;span class=&quot;math-container&quot;&gt;$\vec{y}$&lt;/span&gt;  with limited number of possible values. Transforming the problem to the paper's form seems not always possible.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Bazaraa and Goode. An algorithm for solving linearly constrained minimax problems. European journal of operational research. 1981.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Non-linear programming with linear inequality constraint. Not sure if the form of the constraint matches.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="5705" LastEditDate="2021-06-29T22:53:08.717" LastActivityDate="2021-06-29T22:53:08.717" Title="Minimax problem with a large high dimensional feasible region" Tags="|mixed-integer-programming|linear-programming|minimax|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6511" PostTypeId="1" CreationDate="2021-06-30T00:57:00.900" Score="2" ViewCount="110" Body="&lt;p&gt;I can explain why Lagrange multipliers work for scalar functions by vector calculus. Consider optimizing &lt;span class=&quot;math-container&quot;&gt;$f(\vec{x})$&lt;/span&gt; subjected to the constraint &lt;span class=&quot;math-container&quot;&gt;$g(\vec{x}) = c$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;At the optima, we can move infinitesimally within the feasible region without changing the value of &lt;span class=&quot;math-container&quot;&gt;$f(\vec{x})$&lt;/span&gt;. This infinitesimal movement (and any movement in the feasible region) must be along the constraint, which is one level curve of &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;. Since the infinitesimal movement doesn't change the value of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, the infinitesimal movement is also along the level curve of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As the gradient of a function at any point is perpendicular to the function's level curve, we have &lt;span class=&quot;math-container&quot;&gt;$\nabla f = \lambda \nabla g$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Where can I find a similar explanation for KKT conditions?&lt;/p&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="123" LastEditDate="2021-06-30T07:22:14.167" LastActivityDate="2021-06-30T07:22:14.167" Title="Geometric interpretation of KKT conditions" Tags="|kkt-conditions|lagrange-multipliers|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6512" PostTypeId="1" CreationDate="2021-06-30T01:23:27.040" Score="1" ViewCount="137" Body="&lt;p&gt;For example, the solution for gurobi has two solutions, as follows: [10,20,50,70] [55,79,30,80] I only want to output solutions that contain only multiples of 10. The sample example as follow:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m = Model()&#xA;R = list(range(0,6)) &#xA;&#xA;# Adding variables&#xA;z = m.addVars(6, lb=1, ub=100, vtype=GRB.INTEGER)&#xA;&#xA;m.addConstr(z.prod([1,1,1,1,1,1]) == 100, name=&amp;quot;&amp;quot;)&#xA;&#xA;m.setObjective(z.prod([1,1,1,1,1,1]), sense=GRB.MAXIMIZE)&#xA;m.update()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This program has many solutions, But I just want to output the solution for multiples of 10,like&lt;code&gt;[10,10,20,30,20,10]&lt;/code&gt;.&#xA;Please tell me how do I get the solution.Thank you very much!&lt;/p&gt;&#xA;" OwnerUserId="5789" LastEditorUserId="500" LastEditDate="2021-06-30T04:03:57.063" LastActivityDate="2021-06-30T04:03:57.063" Title="How can I set the solution of gurobi to be a multiple of 10 instead of all integers?" Tags="|modeling|python|integer-programming|gurobi|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6513" PostTypeId="1" CreationDate="2021-06-30T02:49:26.190" Score="1" ViewCount="609" Body="&lt;p&gt;If I want to use the elements of the list as the range of the solution, like list1 = [10,20,50,60,30],and the elements of the solution must belong to the elements of the list The sample example as follow:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m = Model()&#xA;&#xA;list1 = [[10,20,30],[20,30],[10],[10,30],[10,20,30,40],[10,20,30]]&#xA;&#xA;# Adding variables&#xA;f = [1,1,1,1,1,1]&#xA;z = m.addVars(6, lb=1, ub=100, vtype=GRB.INTEGER)&#xA;m.addConstr(z.prod(f) == 100, name=&amp;quot;&amp;quot;)&#xA;&#xA;m.setObjective(z.prod(f), sense=GRB.MAXIMIZE)&#xA;m.update()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The elements of the solution must belong to the corresponding list. For example,there is one solution&lt;code&gt;[10,20,10,30,20,10]&lt;/code&gt;,and the first element of the solution&lt;code&gt;10&lt;/code&gt;must belong to the list```[10,20,30]&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;.How should this be achieved?&lt;/p&gt;&#xA;" OwnerUserId="5789" LastEditorUserId="500" LastEditDate="2021-06-30T03:55:41.367" LastActivityDate="2021-06-30T11:15:07.227" Title="How to make the elements of the solution of gurobi belong to the elements of the specified list?" Tags="|modeling|python|integer-programming|gurobi|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6514" PostTypeId="2" ParentId="6513" CreationDate="2021-06-30T03:46:56.930" Score="3" Body="&lt;p&gt;Given values &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; with index set &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; (for example, &lt;span class=&quot;math-container&quot;&gt;$I=\{1,2,3,4,5\}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$v=[10,20,50,60,30]$&lt;/span&gt;), you can enforce &lt;span class=&quot;math-container&quot;&gt;$x=v_i$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; by introducing binary variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; and imposing linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i\in I} y_i &amp;amp;= 1 \tag1 \\&#xA;\sum_{i\in I} v_i y_i &amp;amp;= x \tag2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; chooses exactly one &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$y_i=1$&lt;/span&gt;, and constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; forces &lt;span class=&quot;math-container&quot;&gt;$x=v_i$&lt;/span&gt; for that &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-06-30T03:46:56.930" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6515" PostTypeId="2" ParentId="6513" CreationDate="2021-06-30T04:20:45.193" Score="1" Body="&lt;p&gt;Here is a small variation of &lt;a href=&quot;https://or.stackexchange.com/a/6514/5705&quot;&gt;RobPratt's answer&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I will use two sets, as an example. Two sets of constants are given: &lt;span class=&quot;math-container&quot;&gt;$S_1 = \lbrace x_{1,1}, x_{1,2}, x_{1,3} \rbrace$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S_2 = \lbrace x_{2,1}, x_{2,2} \rbrace$&lt;/span&gt;. The goal is to choose 1 item from each set and ensure the sum of all items chosen is 100.&lt;/p&gt;&#xA;&lt;p&gt;Make one binary variables per item: &lt;span class=&quot;math-container&quot;&gt;$b_{1,1}, b_{1,2}, b_{1,3}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_{2,1}, b_{2,2}$&lt;/span&gt;. These binary variables indicate which items are chosen. For example, if &lt;span class=&quot;math-container&quot;&gt;$b_{1,1} = 1$&lt;/span&gt;, the 1st item in the 1st set is chosen. Binary variables can only have two possible values: 0 or 1. Sometimes they are also called boolean variables.&lt;/p&gt;&#xA;&lt;p&gt;Constraints to ensure only 1 item chosen from each set:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$b_{1, 1} + b_{1,2} + b_{1,3} = 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$b_{2, 1} + b_{2,2} = 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A constraint to ensure the sum of all items chosen is 100:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$b_{1, 1} x_{1,1} + b_{1,2} x_{1,2} + b_{1,3}x_{1,3} + b_{2,1}x_{2,1} + b_{2,2}x_{2,2} = 100$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I haven't used or installed gurobipy before. Here is my guess based on the documentation and &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/quickstart_mac/cs_example_mip1_py.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;example code&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;&amp;quot;&amp;quot;A variation of subset sum problem.&#xA;&#xA;Additional constraints group the items and ensure only 1 item&#xA;chosen per group.&#xA;&amp;quot;&amp;quot;&amp;quot;&#xA;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;&#xA;&#xA;def process_group(item_values: list, m: gp.Model, prefix: str):&#xA;    # Create one binary variable per item in the group.&#xA;    shape = len(item_values)&#xA;    bns = m.addMVars(shape, vtype=GRB.BINARY,&#xA;                     name=(prefix + &amp;quot;_choice&amp;quot;)&#xA;&#xA;    # A constraint that ensures only 1 item in this group is chosen.&#xA;    m.addConstr(bns.sum() == 1, name=(prefix + &amp;quot;_choose1&amp;quot;))&#xA;&#xA;    # contribution = x11 * b11 + x12 * b12 + ...&#xA;    coefficients = item_values&#xA;    variables = bns&#xA;    contribution = gp.LinExpr(coefficients, variables)&#xA;    return contribution&#xA;&#xA;&#xA;def main():&#xA;    # Data and parameters&#xA;    group_values_list = [[10, 20, 30], [20, 30], [10],&#xA;                         [10, 30], [10, 20, 30, 40],&#xA;                         [10, 20, 30]]&#xA;    max_total_value = 100&#xA;&#xA;    # Model&#xA;    m = gp.Model()&#xA;    contributions = [process_group(g, m, &amp;quot;set%d&amp;quot; % i)&#xA;                     for i, g in enumerate(group_values_list)]&#xA;    total_value = sum(contributions)&#xA;&#xA;    # Limit the total value of the chosen items&#xA;    m.addConstr(total_value &amp;lt;= max_total_value,&#xA;                &amp;quot;total value limit&amp;quot;)&#xA;&#xA;    # Objective is to maximize the total value&#xA;    m.setObjective(total_value, GRB.MAXIMIZE)&#xA;&#xA;    # Optimize model&#xA;    m.optimize()&#xA;&#xA;    for v in m.getVars():&#xA;        print('%s %g' % (v.varName, v.x))&#xA;&#xA;    print('Obj: %g' % m.objVal)&#xA;&#xA;&#xA;main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="5705" LastEditDate="2021-06-30T11:15:07.227" LastActivityDate="2021-06-30T11:15:07.227" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6516" PostTypeId="1" CreationDate="2021-06-30T06:42:39.007" Score="1" ViewCount="275" Body="&lt;p&gt;The following error was encountered when using LinExpr in gurobi:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    contribution = LinExpr(coefficients, variables)&#xA;  File &amp;quot;src\gurobipy\linexpr.pxi&amp;quot;, line 83, in gurobipy.LinExpr.__init__&#xA;gurobipy.GurobiError: Second argument should be a list of Var&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And my code as follow:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from gurobipy import *&#xA;&#xA;&#xA;def process_group(item_values: list, m: Model, prefix: str):&#xA;    # Create one binary variable per item in the group.&#xA;    model = Model()&#xA;    shape = len(item_values)&#xA;    bns = model.addVars(shape, vtype=GRB.BINARY, name=(prefix + &amp;quot;_choice&amp;quot;))&#xA;&#xA;    # A constraint that ensures only 1 item in this set is chosen.&#xA;    model.addConstr(bns.sum() == 1, name=(prefix + &amp;quot;_choose1&amp;quot;))&#xA;&#xA;    # contribution = x11 * b11 + x12 * b12 + ...&#xA;    coefficients = item_values&#xA;    variables = tuplelist(bns)&#xA;    print(&amp;quot;coefficients:&amp;quot;, coefficients)&#xA;    print(&amp;quot;variables:&amp;quot;, variables)&#xA;    contribution = LinExpr(coefficients, variables)&#xA;    return contribution&#xA;&#xA;&#xA;def main():&#xA;    # Data and parameters&#xA;    group_values_list = [[10, 20, 30], [20, 30], [10],&#xA;                         [10, 30], [10, 20, 30, 40],&#xA;                         [10, 20, 30]]&#xA;    max_total_value = 100&#xA;    for i, g in enumerate(group_values_list):&#xA;        print(&amp;quot;i:&amp;quot;, i)&#xA;        print(&amp;quot;g:&amp;quot;, g)&#xA;&#xA;    # Model&#xA;    m = Model()&#xA;    contributions = [process_group(g, m, &amp;quot;set%d&amp;quot; % i)&#xA;                     for i, g in enumerate(group_values_list)]&#xA;    total_value = sum(contributions)&#xA;&#xA;    # Limit the total value of the chosen items&#xA;    m.addConstr(total_value &amp;lt;= max_total_value,&#xA;                &amp;quot;total value limit&amp;quot;)&#xA;&#xA;    # Objective is to maximize the total value&#xA;    m.setObjective(total_value, GRB.MAXIMIZE)&#xA;&#xA;    # Optimize model&#xA;    m.optimize()&#xA;&#xA;    for v in m.getVars():&#xA;        print('%s %g' % (v.varName, v.x))&#xA;&#xA;    print('Obj: %g' % m.objVal)&#xA;&#xA;main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The purpose of the code is to find out all the solutions which the elements of the solution must belong to the corresponding list.&#xA;How should I fix this error?&lt;/p&gt;&#xA;" OwnerUserId="5789" LastActivityDate="2021-06-30T09:54:35.537" Title="gurobipy.GurobiError: Second argument should be a list of Var" Tags="|python|gurobi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6517" PostTypeId="2" ParentId="6516" CreationDate="2021-06-30T09:54:35.537" Score="1" Body="&lt;p&gt;The problem is that you create a &lt;code&gt;tuplelist&lt;/code&gt; of a &lt;code&gt;list&lt;/code&gt;. The function &lt;code&gt;addVars&lt;/code&gt; returns a &lt;code&gt;list&lt;/code&gt; of variables objects already. This means, you should be able to simply do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;contribution = LinExpr(coefficients, bns)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="133" LastActivityDate="2021-06-30T09:54:35.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6518" PostTypeId="1" CreationDate="2021-06-30T18:12:01.233" Score="1" ViewCount="143" Body="&lt;p&gt;The multi-objective optimization problem in my case is defined below:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Objective 1: Minimize &lt;span class=&quot;math-container&quot;&gt;$f_1(X_1,X_2)=C_1X_1+C_2X_2+C_3X_1^2+C_4X_2^2+C_5X_1^2X_2^2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Objective 2: Minimize &lt;span class=&quot;math-container&quot;&gt;$f_2(X_1,X_2)=D_1X_1+D_2X_2+D_3X_1^2+D_4X_2^2+D_5X_1^2X_2^2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Objective 3: Minimize &lt;span class=&quot;math-container&quot;&gt;$f_3(X_2)=-E_1X_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 1: &lt;span class=&quot;math-container&quot;&gt;$ 0 \le X_1 \le A_1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 2: &lt;span class=&quot;math-container&quot;&gt;$ 0 \le X_2 \le A_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 3: &lt;span class=&quot;math-container&quot;&gt;$ X_1 + X_2 \le A_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$C_1,C_2,C_3,C_4,C_5,D_1,D_2,D_3,D_4,D_5,E_1,A_1,A_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_3$&lt;/span&gt; are positive constant numbers. &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_2$&lt;/span&gt; are decision variables.&lt;/p&gt;&#xA;&lt;p&gt;I have used a real-coding method for chromosome coding and used NSGA-II for optimization. I used NSGA-II since it is the most commonly adopted method for arriving at a Pareto front. However, to use NSGA-II, is it always required to prove the NP-Hardness of a problem?&lt;/p&gt;&#xA;&lt;p&gt;To calculate the computational complexity of a NSGA-II problem, we need to calculate both the complexity for each generation and the number of generations&lt;sup&gt;&lt;a href=&quot;https://core.ac.uk/download/pdf/82006684.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let's say that the complexity is &lt;span class=&quot;math-container&quot;&gt;$\mathcal O(G\cdot F\cdot P^2)=\mathcal O(100\cdot3\cdot100^2)$&lt;/span&gt;. Here, &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; is number of generations, &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is the number of objective functions, and &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is the population size.&lt;/p&gt;&#xA;&lt;p&gt;How do we justify the use of NSGA-II in this case?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Curry, D. M., Dagli, C. H. (2014). Computational Complexity Measures for Many-objective Optimization Problems. &lt;em&gt;Procedia Computer Science.&lt;/em&gt; 36:185-191. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="5794" LastEditorUserId="123" LastEditDate="2021-06-30T18:35:10.083" LastActivityDate="2021-06-30T18:35:10.083" Title="Which multi-objective optimization algorithm should one select?" Tags="|optimization|multi-objective-optimization|genetic-algorithm|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6519" PostTypeId="1" AcceptedAnswerId="6521" CreationDate="2021-07-01T06:45:40.053" Score="5" ViewCount="257" Body="&lt;p&gt;Consider a graph whose vertices can be partitioned into &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; layers. Edges exist only between vertices in successive layers. So, there are edges between layers &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;, between layers &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; and so on but never between layers &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; (since they are not successive layers) nor between vertices in the same layer.&lt;/p&gt;&#xA;&lt;p&gt;An example of such a graph with three layers is shown in the figure below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Jn9At.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Jn9At.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, I want to number the vertices in each layer from &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$m_i$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$m_i$&lt;/span&gt; being the number of vertices in layer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;) in a way that the vertices at the two ends of any edge are as close in number as possible. We can think of an objective function that is the sum of squared differences of the numbers assigned to the vertices connected by each edge, across all edges.&lt;/p&gt;&#xA;&lt;p&gt;Is there an efficient algorithm that can do this?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;One idea is to use concepts from drawing force directed graphs, where we consider that each edge has a spring force trying to make it as short as possible with the additional constraint that vertices in each layer be restricted to vertical &amp;quot;pipes&amp;quot;. Trying to implement this seems very complicated and not the most efficient method.&lt;/p&gt;&#xA;&lt;p&gt;It was mentioned in the comments that this problem is related to the bandwidth problem in graph theory: &lt;a href=&quot;https://en.wikipedia.org/wiki/Graph_bandwidth&quot; rel=&quot;noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Graph_bandwidth&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note: this is cross posted from here: &lt;a href=&quot;https://math.stackexchange.com/questions/4187496/numbering-the-vertices-of-an-n-layer-graph-so-that-edges-have-similar-numbered?noredirect=1#comment8682241_4187496&quot;&gt;https://math.stackexchange.com/questions/4187496/numbering-the-vertices-of-an-n-layer-graph-so-that-edges-have-similar-numbered?noredirect=1#comment8682241_4187496&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2436" LastActivityDate="2022-07-03T16:10:40.603" Title="Numbering the vertices of an $n$-layer graph so that edges have similar numbered vertices on their ends" Tags="|graphs|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6520" PostTypeId="2" ParentId="6519" CreationDate="2021-07-01T13:18:45.693" Score="6" Body="&lt;p&gt;I don't know whether this will be efficient enough for your real graph sizes, but with binary decision variables &lt;span class=&quot;math-container&quot;&gt;$x_{v,k}$&lt;/span&gt; to indicate whether vertex &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is assigned label &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, you can obtain a formulation that looks a lot like the quadratic assignment problem. Let &lt;span class=&quot;math-container&quot;&gt;$V_i$&lt;/span&gt; be the set of vertices in layer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{(v,w)\in E} \sum_{k_v, k_w} (k_v-k_w)^2 x_{v,k_v} x_{w,k_w}$$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{k=1}^{m_i} x_{v,k} &amp;amp;=1 &amp;amp;&amp;amp;\text{for layer $i$ and $v\in V_i$}\\&#xA;\sum_{v\in V_i} x_{v,k} &amp;amp;=1 &amp;amp;&amp;amp;\text{for layer $i$ and $k\in\{1,\dots,m_i\}$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-07-01T14:34:19.247" LastActivityDate="2021-07-01T14:34:19.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6521" PostTypeId="2" ParentId="6519" CreationDate="2021-07-01T13:37:38.213" Score="3" Body="&lt;p&gt;Maybe this can work?&lt;/p&gt;&#xA;&lt;p&gt;Numbering is same as sorting. Disregard the layers and treat the whole thing as a single graph. Use &lt;a href=&quot;https://en.wikipedia.org/wiki/Cuthill%E2%80%93McKee_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cuthill-Mckee&lt;/a&gt; (if the bandwidth is low) or other heuristics for the graph bandwidth problem to find the big ordering of nodes. For each layer, filter out the nodes of other layers in the big ordering to get the ordering of nodes in that layer.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Graph_bandwidth&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt; says the graph bandwidth problem is also called linear graph placement. Linear placement means moving all the nodes to a regular grid on a 1D line, and minimize the distances between the connected nodes by sorting the nodes on that 1D line.&lt;/p&gt;&#xA;&lt;p&gt;Here is what I guess:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;layer 2:      1 - 2&#xA;             / \ /&#xA;layer 1:    1   2&#xA;&#xA;vs&#xA;                -&#xA;               / \&#xA;big layer:  1-2-3-4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The best ordering on one 1D line is same as the best ordering over multiple lines. The relationships between the nodes in the two cases (big layer and multiple layer) are the same. Since sorting only depends on the relationships, the ordering doesn't change.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Boost and other libraries have implementation of Cuthill-Mckee:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://algorist.com/problems/Bandwidth_Reduction.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://algorist.com/problems/Bandwidth_Reduction.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;em&gt;Here is my proof that only ordering matters in the single layer case.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Define a gap transform &lt;span class=&quot;math-container&quot;&gt;$g(\vec{r}, s)$&lt;/span&gt; as increasing all numbering above &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; by 1.&lt;/p&gt;&#xA;&lt;p&gt;For example, originally we number the nodes as &lt;span class=&quot;math-container&quot;&gt;$\vec{r} = \begin{bmatrix}1 &amp;amp; 2 &amp;amp; 3 \end{bmatrix}$&lt;/span&gt;. After the gap transform with &lt;span class=&quot;math-container&quot;&gt;$s = 2$&lt;/span&gt;, we would number the nodes as &lt;span class=&quot;math-container&quot;&gt;$g(\vec{r}, 2) = \begin{bmatrix}1 &amp;amp; 2 &amp;amp; 4 \end{bmatrix}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Claim&lt;/strong&gt;: Gap transform does not change the ordering of nodes in the best numbering of the nodes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Proof&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Define the numbering of the nodes as &lt;span class=&quot;math-container&quot;&gt;$\vec{r}$&lt;/span&gt; and the total edge cost as &lt;span class=&quot;math-container&quot;&gt;$f(\vec{r})$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Define the best numbering before we insert any gap as &lt;span class=&quot;math-container&quot;&gt;$\vec{b}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Group all nodes with numbering above &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; as set &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;. Group the remaining nodes into a set &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Clearly, inserting the gap would increase the total cost by &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is the number of edges between &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; in the numbering &lt;span class=&quot;math-container&quot;&gt;$g(\vec{b}, s)$&lt;/span&gt;. In other words, &lt;span class=&quot;math-container&quot;&gt;$f(\vec{b}) + m = f(g(\vec{b}, s))$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Suppose after inserting the gap to the best numbering before gap insertion &lt;span class=&quot;math-container&quot;&gt;$\vec{b}$&lt;/span&gt;, we can permute the numbering to &lt;span class=&quot;math-container&quot;&gt;$\vec{b}^{*}$&lt;/span&gt; and obtain a better total edge cost &lt;span class=&quot;math-container&quot;&gt;$f(\vec{b}^{*}) &amp;lt; f(g(\vec{b}, s)) = f(\vec{b}) + m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;All permutations are equivalent to three steps: permute numbering in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, permute numbering in &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, exchange nodes between &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If we permute only the numbering in group &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, the total cost would stay the same or increase. Otherwise, if the cost decrease, we can simply remove the gap and find a numbering for the no gap case that is better than &lt;span class=&quot;math-container&quot;&gt;$\vec{b}$&lt;/span&gt;, a contradiction. Same situation for group &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Moving nodes from &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; or from &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is not possible because the number of nodes in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is fixed by &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Exchanging &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; nodes in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; node in &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; would decrease neither the total cost of edges in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; nor total cost of edges in &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is because 1. &lt;span class=&quot;math-container&quot;&gt;$\vec{b}$&lt;/span&gt; is the best numbering for the no gap case. 2. inserting the gap doesn't change the cost of edges in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;. Therefore, within &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, the best numbering stay the same upon inserting the gap. Any change of the numbering within &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; would make the total cost of edges in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; increase or stay the same. Same for edges in &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; because inserting the gap doesn't change the total cost of edges in &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Therefore, the total cost of edges between &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; must decrease.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There are two possibilities: we decrease the number of edges between &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; or we don't.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If we do, the total number of edges must stay the same. When we reduce the number of edges between &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, there is a corresponding increase of number of edges in either &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; or both. That means we are shifting some edges from between &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; to within &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; or within &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Each extra edge in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; has a cost of at least 1.&lt;/li&gt;&#xA;&lt;li&gt;Therefore, the total cost of edges between &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; must improve by more than &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, which is the number of edges shifted.&lt;/li&gt;&#xA;&lt;li&gt;But then, we can remove the gap and reduce the cost of edges between &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$m - n$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is again the number of edges between &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; in no gap numbering &lt;span class=&quot;math-container&quot;&gt;$\vec{b}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The total improvement of the cost of edges between &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; exceeds 0 if we compare the new numbering with gap removed and the old best numbering for the no gap case.&lt;/li&gt;&#xA;&lt;li&gt;That means and get a numbering better than &lt;span class=&quot;math-container&quot;&gt;$\vec{b}$&lt;/span&gt; for the no gap case, a contradiction.&lt;/li&gt;&#xA;&lt;li&gt;If we don't reduce the number of edges, remove the gap would again lead to a numbering better than &lt;span class=&quot;math-container&quot;&gt;$\vec{b}$&lt;/span&gt;, a contradiction.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Therefore, all permutations would not improve the total cost. &lt;span class=&quot;math-container&quot;&gt;$g(\vec{s}, b)$&lt;/span&gt; is the best numbering after we insert the gap.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;We can repeat gap transforms to get all possible numbering of the nodes with the same ordering.&lt;/p&gt;&#xA;&lt;p&gt;Consequently, the exact number on the node doesn't matter. Only the ordering in the numbering of the nodes matter.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;em&gt;Gap transform over multiple layers&lt;/em&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Define the best numbering of nodes in &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; layers as &lt;span class=&quot;math-container&quot;&gt;$\beta = \lbrace \vec{b}_{1}, \vec{b}_{2}, \ldots \vec{b}_{L} \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Apply gap transform to the &lt;span class=&quot;math-container&quot;&gt;$k^{\mathrm{th}}$&lt;/span&gt; layer: &lt;span class=&quot;math-container&quot;&gt;$g(\vec{b}_{k}, s)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Assume the gap transform preserves the combined ordering of the nodes of all layers. That means the gap transform does not increase the crossing number for the edges between 2 layers.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For each layer with index &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;, group the nodes with numbering above &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; as a set &lt;span class=&quot;math-container&quot;&gt;$A_{l}$&lt;/span&gt;. Group the remaining nodes in the layer as &lt;span class=&quot;math-container&quot;&gt;$B_{l}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For the &lt;span class=&quot;math-container&quot;&gt;$(k + 1)^{\mathbb{th}}$&lt;/span&gt; layer, there are 3 cases: &lt;span class=&quot;math-container&quot;&gt;$A_{k+1}$&lt;/span&gt; is empty, &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt; is empty, or &lt;span class=&quot;math-container&quot;&gt;$A_{k+1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt; are both not empty.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Case 1: Suppose &lt;span class=&quot;math-container&quot;&gt;$A_{k+1}$&lt;/span&gt; is empty and &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt; is nonempty.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Then the cost of edges between &lt;span class=&quot;math-container&quot;&gt;$B_{k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt; remain the same. The cost of each edge between &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt; increases by 1.&lt;/li&gt;&#xA;&lt;li&gt;After insertion of the gap, rearranging the numbering of the nodes within &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; would not decrease the total cost of edges between the &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt; for the following reasons:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The costs of the edges between &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt; are uniformly increased by 1.&lt;/li&gt;&#xA;&lt;li&gt;The best way to connect &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt; remain the same.&lt;/li&gt;&#xA;&lt;li&gt;Permuting the nodes within &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; would permute the edges between &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt;. That means deviating from the best connectivity. The total costs for these edges would not decrease. Otherwise, we can remove the gap and get a numbering that is better than &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; for the no gap case, which is a contradiction.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;After insertion of the gap, rearranging the numbering of the nodes within &lt;span class=&quot;math-container&quot;&gt;$B_{k}$&lt;/span&gt; would not decrease the total cost of edges between the &lt;span class=&quot;math-container&quot;&gt;$B_{k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt;. The reason is similar because the cost of the edges remain the same, which means these costs are uniformly increased by 0.&lt;/li&gt;&#xA;&lt;li&gt;Moving a node from &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$B_{k}$&lt;/span&gt; or from &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$B_{k}$&lt;/span&gt; is impossible because &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; fixes the number of nodes in &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;After exchanging &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; nodes in &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; nodes in &lt;span class=&quot;math-container&quot;&gt;$B_k$&lt;/span&gt;, there are 2 cases: I. The number of &amp;quot;cross&amp;quot; edges between &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt; increases. II. That number doesn't increases.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Case 1I. The number of edges between layer &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and layer &lt;span class=&quot;math-container&quot;&gt;$k + 1$&lt;/span&gt; is constant. Therefore, we are shifting &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; &amp;quot;cross&amp;quot; edges between &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt; to &amp;quot;non-cross&amp;quot; edges between &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_{k+1}$&lt;/span&gt;. This shift would decrease neither the total cost of edges between the two layers nor the total cost of all edges, for reasons similar to the single layer case.&lt;/li&gt;&#xA;&lt;li&gt;Case 1II. This permutation would not decrease the total cost. Otherwise, removing the gap would lead a numbering better than &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; for the no gap case, which is a contradiction.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Case 2: Suppose &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt; is empty and &lt;span class=&quot;math-container&quot;&gt;$A_{k+1}$&lt;/span&gt; is nonempty.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Upon insertion of the gap, the costs of each edge between &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_{k+1}$&lt;/span&gt; increases by 1. The costs of edges within &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; remain the same. The cost of edges between &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_{k+1}$&lt;/span&gt; varies.&lt;/li&gt;&#xA;&lt;li&gt;The change of the cost of the inter-layer edges among &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$A_{k+1}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$A_{k-1}$&lt;/span&gt; is the difficult part.&lt;/li&gt;&#xA;&lt;li&gt;Suppose after inserting the gap, a rearrangement of the nodes in &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt; would decrease the total edge cost.&lt;/li&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; be the total number of edge crossovers between the inter-layer edges among sets &lt;span class=&quot;math-container&quot;&gt;$A_{k}, A_{k+1}, A_{k-1}$&lt;/span&gt; plus the number of crossovers within &lt;span class=&quot;math-container&quot;&gt;$A_{k}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The rearrangement has three cases: A. &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; stay the same. B. &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; increases. C. &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; decreases.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Case 2C: decreasing the number of edge crossovers (untangling) would decrease the inter-layer edge costs for both no-gap and with gap cases. Therefore, this is impossible. Otherwise we can untangle and get a numbering better than &lt;span class=&quot;math-container&quot;&gt;$\vec{\beta}$&lt;/span&gt; for the no-gap case, a contradiction.&lt;/li&gt;&#xA;&lt;li&gt;Case 2B: Increasing the number of edge crossovers (tangling up) won't help.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There is surely one rearrangement that doesn't increase &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, which is no rearrangement.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Case 2A: The number of edge crossovers stays the same.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Case 2A0: 2 times the number of inter-layer crossover points minus the number of inter-layer edges is zero. That means each inter-layer edge from &lt;span class=&quot;math-container&quot;&gt;$A_k$&lt;/span&gt; crossover another inter-layer edge for exactly once.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In this case, the total costs of all &amp;quot;crossed&amp;quot; inter-layer edges don't change upon insertion of the gap.&lt;/li&gt;&#xA;&lt;li&gt;Define the set of nodes in &lt;span class=&quot;math-container&quot;&gt;$A_k$&lt;/span&gt; that are involved in crossovers of inter-layer edges as &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Notice that within layer &lt;span class=&quot;math-container&quot;&gt;$A_k$&lt;/span&gt;, the edge costs don't change upon insertion of the gap.&lt;/li&gt;&#xA;&lt;li&gt;The total costs of all inter-layer edges that contain nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; also don't change upon insertion of the gap.&lt;/li&gt;&#xA;&lt;li&gt;Therefore, after insertion of the gap, rearrangement of the nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; would cause an increase of cost that must be over-compensated by the remaining edges.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The source of this over-compensation can't come from the remaining edges within &lt;span class=&quot;math-container&quot;&gt;$A_k$&lt;/span&gt; because those edges are messed up too. The connectivity within &lt;span class=&quot;math-container&quot;&gt;$A_k$&lt;/span&gt; deviates from the optimal cases in &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; upon the rearrangement of the nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The over-compensation must come from non-crossing inter-layer edges.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The over-compensation can't come from nodes that only have non-crossing inter-layer edges. The reason is that the rearrangement of the nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; doesn't provide any improvement to these edges.&lt;/li&gt;&#xA;&lt;li&gt;The remaining possibility is to have a compensation from some non-crossing edge that connects a node in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; to a node in &lt;span class=&quot;math-container&quot;&gt;$B_{k}$&lt;/span&gt; that is out of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. Let's say these edges are in a set &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The crossing-edges form a crossfire. Each edge in &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; can't get caught in the crossfire. Then, each edge in &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; must be at one of the two ends of a crossfire.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Therefore, if there are &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; crossfires, there is at most &lt;span class=&quot;math-container&quot;&gt;$2\xi$&lt;/span&gt; edge &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;s.&lt;/li&gt;&#xA;&lt;li&gt;Moreover, exchanging two nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; that are from two different crossfires would spread the crossfire and kill at most two edge in &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;. So, we can't do that.&lt;/li&gt;&#xA;&lt;li&gt;Exchanging 1 node in the crossfire with another node at the edge of the same crossfire would increase the cost of the edge E.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;This last possibility won't help too!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Therefore, no rearrangement of the nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; can improve the overall cost.&lt;/li&gt;&#xA;&lt;li&gt;Consequently, case 2A0 reduces to the case without any crossover of inter-layer edges.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Case 2A1: 2 times the number of inter-layer crossover points minus the number of inter-layer edges is 1.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Only the 3 edges that form 2 crossover on 1 edge matters. The remaining edges followings case 2A0.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;In both cases, upon insertion of the gap, the cost of each inter-layer non-crossed edges change by either +1 or -1, which may not cancel out, unlike the crossed edges. I think rearranging the nodes involved in non-crossed edges won't improve the total cost if &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; remain the same.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Rearranging the nodes is a subset of re-connection of the edges among these nodes. However, If the re-connection of edges is legal (corresponds to a rearrangement of nodes), then if the improvement of cost exceed 1, we would have done it for the no-gap case. That is impossible by contradiction.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;I guess exchanging nodes involved in inter-layer crossed edges and nodes that only have inter-layer un-crossed edges would increase &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;might be easier to prove case 1 and 2 first then sequentially moves nodes into the empty set.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Suppose the gap transform doesn't change the ordering of nodes in the multi-layer case. I can find the best ordering for the big graph on 1-D line. Then rise some node onto other layers. And finally remove all the gaps in all layers. The numbering would stay optimal.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Bibliography&lt;/p&gt;&#xA;&lt;p&gt;Tangle base: &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/epdf/10.1002/net.21979&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://onlinelibrary.wiley.com/doi/epdf/10.1002/net.21979&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Gotzsch's theorem: every planar graph without triangle can be colored by 3 colors. &lt;a href=&quot;https://en.wikipedia.org/wiki/Gr%C3%B6tzsch%27s_theorem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="279" LastEditDate="2022-07-03T16:10:40.603" LastActivityDate="2022-07-03T16:10:40.603" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="6522" PostTypeId="2" ParentId="6519" CreationDate="2021-07-02T06:56:09.873" Score="2" Body="&lt;p&gt;Treat nodes in 1st and 3nd layer as extra edges in the 2st layer to make a merged layer. Minimize bandwidth of 2nd layer. Repeat for the other layers.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;layer 2: o   o   o&#xA;          \ / \ /&#xA;layer 1:   @   @&#xA;&#xA;@ becomes an edge:&#xA;&#xA;layer 2: o - o - o&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="5705" LastEditDate="2021-07-02T07:39:25.940" LastActivityDate="2021-07-02T07:39:25.940" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6524" PostTypeId="2" ParentId="6519" CreationDate="2021-07-04T00:27:23.207" Score="3" Body="&lt;p&gt;I hacked a random key genetic algorithm for the problem in Java, and ran it against a linearized version of Rob Pratt's MIP model (using CPLEX 20.1 with default parameter settings) on some small random test problems (five layers, three to nine nodes per layer, about 1/4 of all possible edges present). Because the GA stagnated very quickly, I did multiple restarts (running the GA ten times on the same problem). Using the parameters I set, the GA generally finished its ten runs in under two minutes.&lt;/p&gt;&#xA;&lt;p&gt;I then fed the best solution from the GA to CPLEX as a starting solution. I don't know whether the GA was getting an optimal solution in general, because I only gave CPLEX five minutes, and it only got the gap down to zero once (and frequently didn't get it below 50%). What I can say is that (a) in the one case where CPLEX got the gap to 0, the GA solution was indeed optimal and (b) CPLEX never improved on the GA solution in any run. None of that is conclusive, and it might or might not hold up with larger graphs (or with CPLEX given more time), but all told I would say it is an encouraging sign that the GA is &amp;quot;good enough&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-04T00:27:23.207" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6526" PostTypeId="1" AcceptedAnswerId="6527" CreationDate="2021-07-04T14:22:40.147" Score="5" ViewCount="2710" Body="&lt;p&gt;Suppose we have a model with &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; integer variables, i.e. &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{Z}^{N}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$L \leq x \leq U$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How can we represent the integer variables via binary variables? Or in other words: how can we transform an integer programming problem into a binary programming problem?&lt;/p&gt;&#xA;" OwnerUserId="5007" LastActivityDate="2024-02-19T11:45:54.370" Title="How to represent an integer variable via binary variables?" Tags="|mixed-integer-programming|modeling|binary-variable|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6527" PostTypeId="2" ParentId="6526" CreationDate="2021-07-04T14:58:58.427" Score="11" Body="&lt;p&gt;I'm not entirely sure if this is the most elegant way to model things, but here's how integer numbers are represented in a computer:&lt;/p&gt;&#xA;&lt;p&gt;Let's take an integer variable &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{Z}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$L \leq x \leq U$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L \geq 0$&lt;/span&gt;, meaning &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is non-negative. By using &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; binary variables (bits) &lt;span class=&quot;math-container&quot;&gt;$b_0, \ldots, b_{M-1}$&lt;/span&gt;, we can represent &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in base 2 as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x = (b_{M-1}b_{M-2}\ldots b_{0})_2 = \sum_{j=0}^{M-1} b_j \cdot 2^j.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To minimize the number of binary variables needed, we find the smallest &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; such that:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$U \leq \max_{b_0,\ldots,b_{M-1}} \sum_{j=0}^{M-1} b_j \cdot 2^j = \sum_{j=0}^{M-1} 1 \cdot 2^j = 2^{M} - 1,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which gives us &lt;span class=&quot;math-container&quot;&gt;$M = \left\lceil \log_2{(U + 1)} \right\rceil$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$L &amp;lt; 0$&lt;/span&gt;, the &lt;a href=&quot;https://en.wikipedia.org/wiki/Two%27s_complement&quot; rel=&quot;nofollow noreferrer&quot;&gt;two's complement representation&lt;/a&gt; can be used. It is expressed as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x = (b_{M-1}b_{M-2}\ldots b_{0})_2 = -b_{M-1} \cdot 2^{M-1} + \sum_{j=0}^{M-2} b_j \cdot 2^j,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$M = \left \lceil \log_2{( \max \{ |L|, |U| \} + 1)} + 1\right \rceil$&lt;/span&gt; represents the minimum number of binary variables needed to represent &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="3696" LastEditDate="2024-02-19T11:45:54.370" LastActivityDate="2024-02-19T11:45:54.370" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6528" PostTypeId="2" ParentId="6526" CreationDate="2021-07-04T15:20:40.073" Score="9" Body="&lt;p&gt;You can stay in base &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; with a similar approach as @joni:&#xA;introduce  &lt;span class=&quot;math-container&quot;&gt;$m=U-L+1$&lt;/span&gt; binary variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;, one for each integer value in the range &lt;span class=&quot;math-container&quot;&gt;$[L,U]$&lt;/span&gt;, and write &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x= L y_1 + (L+1)y_2 +...+(U-1)y_{m-1} + Uy_m&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, make sure only one of these values is selected:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i=1}^m y_i = 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Of course this yields more than &lt;span class=&quot;math-container&quot;&gt;$\lceil \log_2(U+1) \rceil$&lt;/span&gt; variables.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-07-04T15:50:55.167" LastActivityDate="2021-07-04T15:50:55.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6529" PostTypeId="1" AcceptedAnswerId="6530" CreationDate="2021-07-04T21:05:57.140" Score="6" ViewCount="567" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$y, x_1, x_2, x_3$&lt;/span&gt; be binary variables.&lt;/p&gt;&#xA;&lt;p&gt;The following holds: &lt;span class=&quot;math-container&quot;&gt;$y=1 \implies x_1=1, x_2=1, x_3=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I can model this by requiring  (1) &lt;span class=&quot;math-container&quot;&gt;\begin{align}x_1 &amp;amp;\ge y\\x_2 &amp;amp;\ge y\\x_3 &amp;amp;\ge y\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;or by requiring (2) &lt;span class=&quot;math-container&quot;&gt;$$\frac{x_1 + x_2 + x_3}3 \ge y$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The question is, is requirement (1) or requirement (2) more advantageous and why?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2021-07-05T07:42:55.493" LastActivityDate="2021-07-05T07:42:55.493" Title="MILP - stronger models" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6530" PostTypeId="2" ParentId="6529" CreationDate="2021-07-04T21:21:46.703" Score="13" Body="&lt;p&gt;Version (1) arises from conjunctive normal form as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y \implies (x_1 \land x_2 \land x_3) \\&#xA;\lnot y \lor (x_1 \land x_2 \land x_3) \\&#xA;(\lnot y \lor x_1) \land (\lnot y \lor x_2) \land (\lnot y \lor x_3) \\&#xA;(1 - y) + x_1 \ge 1 \land (1 - y) + x_2 \ge 1 \land (1 - y) + x_3 \ge 1 \\&#xA;x_1 \ge y \land x_2 \ge y \land x_3 \ge y&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Version (2) is an aggregation of (1) and yields a smaller but weaker linear formulation.&lt;/p&gt;&#xA;&lt;p&gt;State-of-the-art MILP solvers will generate the useful constraints in (1) from (2) dynamically as cuts, so you are probably better off with the smaller LP.  But it is worth trying both ways.&lt;/p&gt;&#xA;&lt;p&gt;Also, I recommend writing (2) as &lt;span class=&quot;math-container&quot;&gt;$x_1+x_2+x_3 \ge 3y$&lt;/span&gt; so that you have integer coefficients.  Division by 3 would introduce infinitely repeating decimals that must be approximated unless you are using an exact solver.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-07-05T01:57:45.527" LastActivityDate="2021-07-05T01:57:45.527" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6531" PostTypeId="2" ParentId="6526" CreationDate="2021-07-05T05:01:28.627" Score="2" Body="&lt;p&gt;In computer science, &amp;quot;integer&amp;quot; data types are generally a fixed-length array of bits. In earlier languages, those lengths were generally 16 or 32 bits, but later languages tend towards 64. This type of implementation does have drawbacks. For instance, they aren't really integers, in the mathematical sense, as they are members of a finite set. The idea is that they're &amp;quot;big enough&amp;quot;; how often do you have to deal with integers bigger than a quadrillion? It's possible to implement model of the integers that aren't fixed bits, but those are more complicated (e.g. linked lists), and we can't know ahead of time how much/which portion of memory to assign ahead of time.&lt;/p&gt;&#xA;&lt;p&gt;What implementation to choose depends on what we value. Once option, after putting the integers in binary, is to split its digits into blocks, and then have another block that keeps track of what blocks represent what integers. There are several ways to do that, one of which is store the block numbers where a new integer starts. Since we know the first integer starts in the first block, this means that for n integers, we now need to store n-1 integers, each of which should be on the order of the log of the original numbers.&lt;/p&gt;&#xA;&lt;p&gt;Another method is encode the information within the block. You could assign one bit in each block to recording whether it's the last block for its integer. You could compress it even further with more complicated algorithms.&lt;/p&gt;&#xA;" OwnerUserId="1302" LastActivityDate="2021-07-05T05:01:28.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6532" PostTypeId="1" CreationDate="2021-07-05T06:16:28.270" Score="4" ViewCount="253" Body="&lt;p&gt;In this article &lt;a href=&quot;https://www.researchgate.net/publication/220099835_A_new_modeling_and_solution_approach_for_the_number_partitioning_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;A new modeling and solution approach for the number partitioning problem&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;, it transforms the number partition problem into a QUBO form like equation (2.1) on page 2. &lt;span class=&quot;math-container&quot;&gt;$$\text{diff}=\sum_{j=1}^ms_j-2\sum_{j=1}^ms_jx_j=c-2\sum_{j=1}^ms_jx_j\tag{2.1}$$&lt;/span&gt; My question is how to turn (2.1) into (2.2) and (2.3)?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{diff}^2&amp;amp;=\left\{c-2\sum_{j=1}^ms_jx_j\right\}^2 \\&#xA;&amp;amp;=c^2+4xQx\tag{2.2}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$$q_{ii}=s_i(s_i-c),\quad q_{ij}=s_is_j\tag{2.3}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Alidaee, B., Glover, F., Kochenberger, G. A., Rego, C. (2005). A new modeling and solution approach for the number partitioning problem. &lt;em&gt;Journal of Applied Mathematics and Decision Sciences.&lt;/em&gt; 2005(2):113–21. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="5802" LastEditorUserId="727" LastEditDate="2021-07-26T22:56:36.943" LastActivityDate="2022-06-09T07:05:55.790" Title="How do I arrive at the form given in this paper, for the QUBO version of the number partitioning problem?" Tags="|optimization|binary-variable|quadratic-programming|unconstrained-optimization|qubo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6533" PostTypeId="1" CreationDate="2021-07-05T06:42:41.553" Score="1" ViewCount="19" Body="&lt;p&gt;I'm reading several prospective studies published in top journals where a baseline modifiable exposure was associated with a final outcome.&#xA;Just as an example might be &lt;a href=&quot;http://doi.org/10.1093/eurheartj/ehy836&quot; rel=&quot;nofollow noreferrer&quot;&gt;this study&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The Authors aimed to evaluate whether oral hygiene behaviour can alleviate cardiovascular risk. For what I understand, the &lt;strong&gt;exposure persistency&lt;/strong&gt; (oral hygiene behaviour) was not controlled during the study period, because any repeated assessment was performed during the follow-up.&#xA;Basically, they associated the final outcome (10yr later) to the baseline exposure.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is that methodologically correct?&lt;/li&gt;&#xA;&lt;li&gt;In a prospective cohort study, is there any &lt;strong&gt;need&lt;/strong&gt; to control the exposure during the study period?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5801" LastEditorUserId="123" LastEditDate="2021-07-05T07:40:25.717" LastActivityDate="2021-07-05T07:40:25.717" Title="Prospective study and ascertainment of the exposure during the follow-up period" Tags="|modeling|literature-research|experimental-optimization|" AnswerCount="0" CommentCount="1" ClosedDate="2021-07-05T07:40:50.267" ContentLicense="CC BY-SA 4.0" />
  <row Id="6534" PostTypeId="2" ParentId="6532" CreationDate="2021-07-05T07:50:50.483" Score="3" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{diff}^2&amp;amp;=c^2+4\left(\left(\sum s_jx_j\right)^2-c\sum s_jx_j\right)\\&amp;amp;=c^2+4\left(\sum s_j^2x_j^2+\sum_{\rm cyc}s_ks_\ell x_kx_\ell-c\sum s_jx_j\right)\tag1\\&amp;amp;=c^2+4\left(\sum x_j\boldsymbol{s_j(s_j-c)}x_j+\sum_{\rm cyc}x_k\boldsymbol{s_ks_\ell}x_\ell\right)\tag2\\&#xA;&amp;amp;=c^2+4x^\top Qx\tag3\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;: This is a standard expansion involving a pairwise cyclic sum.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;: We use the fact that &lt;span class=&quot;math-container&quot;&gt;$x_j=x_j^2$&lt;/span&gt; as the variable is binary, so that &lt;span class=&quot;math-container&quot;&gt;$\sum s_jx_j=\sum s_jx_j^2$&lt;/span&gt;. In the paper, it is stated directly above (2.1): &amp;quot;Let &lt;span class=&quot;math-container&quot;&gt;$x_j=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$s_j$&lt;/span&gt; is assigned to subset &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;: The form in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; indicates that diagonal elements of the matrix are &lt;span class=&quot;math-container&quot;&gt;$s_j(s_j-c)$&lt;/span&gt; and off-diagonal elements &lt;span class=&quot;math-container&quot;&gt;$s_ks_\ell$&lt;/span&gt; correspond to their row and column coordinates.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2022-06-09T07:05:55.790" LastActivityDate="2022-06-09T07:05:55.790" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6535" PostTypeId="2" ParentId="6507" CreationDate="2021-07-05T11:48:24.580" Score="1" Body="&lt;p&gt;thanks for all your answers. I just wanted to say that the problem was in fact related to the Gurobi license file. I contacted Gurobi and they could reproduce the error and they just gave me a new license. Now everything is okay again.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastActivityDate="2021-07-05T11:48:24.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6536" PostTypeId="1" CreationDate="2021-07-06T09:30:13.313" Score="3" ViewCount="82" Body="&lt;p&gt;In the distributionally robust optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\min_{x\in X}\sup_{P\in\mathfrak{P}}\mathbb{E}_P[f(x,\xi)],&#xA;\end{aligned}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f:\mathbb{R}^n\to\mathbb{R}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is a distribution function over the measurable set &lt;span class=&quot;math-container&quot;&gt;$\mathfrak{P}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}_P$&lt;/span&gt; denotes the expected value with respect to the distribution &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For a differentiable function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, if we define &lt;span class=&quot;math-container&quot;&gt;$g(x):=\sup_{P\in\mathfrak{P}} \mathbb{E}_P[f(x,\xi)]$&lt;/span&gt;, is the function &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; differentiable for the variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; like &lt;span class=&quot;math-container&quot;&gt;$\nabla g(x)=\sup_{P\in\mathfrak{P}}\mathbb{E}_P[\nabla_x f(x,\xi)]$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;In general, I guess it is not true because the interchangeability of the differentiation and expectation operators cannot hold.&#xA;But I am curious what is the condition that the following equation holds?&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\nabla g(x)=\sup_{P\in\mathfrak{P}}\mathbb{E}_P[\nabla_x f(x,\xi)].&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5821" LastEditorUserId="5821" LastEditDate="2021-07-06T10:50:38.850" LastActivityDate="2021-07-06T10:50:38.850" Title="Derivative of sup(max) functions in distributionally robust optimization" Tags="|stochastic-programming|robust-optimization|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6537" PostTypeId="1" CreationDate="2021-07-06T17:22:37.577" Score="8" ViewCount="668" Body="&lt;p&gt;When developing MILPs, often there are different alternatives possible to express a constraint. The question then arises, which of the alternatives is better, meaning, which alternative is expected to perform better during the solution process.&lt;/p&gt;&#xA;&lt;p&gt;Is the scientific community able to provide a guide for addressing the strength of a MILP formulation? Something like &amp;quot;disciplined convex programming&amp;quot; but for strong MILPs, lets call it &amp;quot;disciplined MILP programming&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;Does, possibly, such a guide already exist?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2021-07-12T16:07:38.623" Title="Guides for strong MILP Formulations" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6539" PostTypeId="2" ParentId="6078" CreationDate="2021-07-07T07:34:17.577" Score="5" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Can anyone think about a better formulation?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Another option is to use binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{it}$&lt;/span&gt; that take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; starts at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. You then need two sets of constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;one start time per task:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{t}x_{it} = 1 \quad \forall i&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;don't overlap tasks:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i}\sum_{k, t+1 - d_i \le k \le t}x_{ik} \le 1 \quad \forall t&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This formulation is more tight and should solve faster. And it does not require big-Ms.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-07-07T07:41:23.897" LastActivityDate="2021-07-07T07:41:23.897" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6540" PostTypeId="1" CreationDate="2021-07-07T07:57:20.227" Score="1" ViewCount="118" Body="&lt;p&gt;The constraint value of a variable must be an element of the specified list.A simple example is shown as follow,in which the value of the&lt;code&gt;x.prod(flow_Restrictions[0]) &lt;/code&gt; expression can only be equal to an element in &lt;code&gt;[0, 3, 5]&lt;/code&gt;,and the value of the&lt;code&gt;x.prod(flow_Restrictions[1]) &lt;/code&gt; expression can only be equal to an element in &lt;code&gt;[0, 1, 3, 5]&lt;/code&gt; and so on.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m = Model()&#xA;# Adding variables&#xA;flow_Restrictions = [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0],&#xA;                     [1.0, 0.0, 0.0, 0.0], [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0],&#xA;                     [0.0, 0.0, 1.0, 0.0], [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0],&#xA;                     [1.0, 1.0, 1.0, 1.0], [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0],&#xA;                     [0.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0],&#xA;                     [1.0, 0.0, 0.0, 0.0], [1.0, 1.0, 1.0, 1.0]]&#xA;flow_c = [1.0, 1.0, 1.0, 1.0]&#xA;component_capacity = [[0, 3, 5], [0, 1, 3, 5], [0, 3, 5], [0, 2, 5], [0, 1, 2, 3, 5],[0, 3, 5], [0, 2, 3, 5],&#xA;                      [0, 1, 3, 5], [0, 3, 5], [0, 3, 4, 5], [0, 2, 5], [0, 2, 5], [0, 3, 5, 10, 15], [0, 5, 10],&#xA;                      [0, 3, 5], [0, 1, 3, 5], [0, 3, 5], [0, 1, 2, 3, 5], [0, 2, 5], [0, 3, 5, 10], [0, 3, 5],&#xA;                      [0, 3, 10, 15]]&#xA;d = 15&#xA;x = m.addVars(4, lb=0, ub=15, vtype=GRB.INTEGER)&#xA;for i in range(len(flow_Restrictions) + 1):&#xA;    if i == len(flow_Restrictions):&#xA;        m.addConstr(x.prod(flow_c) == d, name=&amp;quot;&amp;quot;)&#xA;    else:&#xA;        m.addConstr(x.prod(flow_Restrictions[i]) &amp;lt;= component_capacity[i], name=&amp;quot;&amp;quot;)&#xA;&#xA;m.setObjective(x.prod(flow_c), sense=GRB.MAXIMIZE)&#xA;m.update()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The solution I want to obtain is shown below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[[5, 5, 0, 5], [5, 0, 5, 5]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and these solutions satisfy the following conditions:&#xA;The elements of the list flow_Restrictions multiplied by the elements of the solution whose values must belong to the elements of the list component_capacity.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[[5, 5, 0, 5, 5, 5, 5, 5, 0, 5, 5, 5, 15, 5, 5, 0, 5, 5, 5, 5, 5, 15], [5, 0, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 15, 5, 0, 5, 5, 5, 5, 5, 5, 15]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Each element of the solution belongs to the element corresponding to the list named component_capacity.&#xA;How do I achieve this?&lt;/p&gt;&#xA;" OwnerUserId="5789" LastEditorUserId="500" LastEditDate="2021-07-09T14:13:55.280" LastActivityDate="2021-07-09T14:29:58.733" Title="How to make the solution of linear programming within the specified elements" Tags="|modeling|python|gurobi|" AnswerCount="1" CommentCount="2" ClosedDate="2021-07-11T09:05:22.340" ContentLicense="CC BY-SA 4.0" />
  <row Id="6541" PostTypeId="1" CreationDate="2021-07-07T10:48:30.260" Score="1" ViewCount="67" Body="&lt;p&gt;I'm trying to model this scenario that each population group gets assigned to a hospital over a period of time. The time is divided into say a period of 30 weeks, and I have about 8 age-wise population data from every demand point. If I were to minimise the distance travelled by every patient to a hospital at every time period, how would I model this, given that the parameter for demand that I have is not sorted age wise.&lt;/p&gt;&#xA;&lt;p&gt;For a closer look:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;80+ = 70 &#xA;70 -79 = 30 &#xA;60 - 69 = 45&#xA;50 - 59 = 20&#xA;40 - 49 = 45&#xA;30 - 39 = 20 &#xA;20 - 29 = 80 &#xA;&amp;lt;= 19 = 80 &#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Currently, I have the following parameters:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_{ij}$&lt;/span&gt;: Demand allocated from location i to hospital j&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_{it}$&lt;/span&gt;: Demand at location i at according to age period t&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ijt}$&lt;/span&gt;:1, if demand from location i is allocated to hospital j at age period t&lt;/p&gt;&#xA;&lt;p&gt;Objective: Minimise &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I} \sum_{j \in J} \sum_{t \in T} x_{ijt} D_{it} D_{ij} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subject to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{ j \in J} x_{ijt} \geq 1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in I, t \in T$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The above constraint will ensure that every demand point i can be allocated to more than one facility in time t&lt;/p&gt;&#xA;&lt;p&gt;I'm quite out of ideas on how to include the weekly period given that I don't have the right parameters for it. I'd sincerely appreciate any advise on how to model this problem.&lt;/p&gt;&#xA;" OwnerUserId="5836" LastActivityDate="2021-07-07T10:48:30.260" Title="Facility location over time - Parameter" Tags="|facility-location|time-series|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6542" PostTypeId="1" CreationDate="2021-07-07T17:00:05.880" Score="1" ViewCount="501" Body="&lt;p&gt;I am using docplex in Python to solve a MILP and I am having some trouble defining the indices and sets of my model.&lt;/p&gt;&#xA;&lt;p&gt;I want to translate &lt;span class=&quot;math-container&quot;&gt;$w,v,a\in W$&lt;/span&gt; into Python.&lt;/p&gt;&#xA;&lt;p&gt;In this case, &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is a set, and &lt;span class=&quot;math-container&quot;&gt;$w, v$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; are indices of this set. I found a way to define one index for a set but I don't know how to define multiple indices for the same set.&lt;/p&gt;&#xA;&lt;p&gt;I defined the set &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;n=3&#xA;W = [j for j in range(1,n+1)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then I defined the variable: &lt;span class=&quot;math-container&quot;&gt;$Y_{ijws}^{Dt}$&lt;/span&gt; like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Y_Dt_ijws_scope = [(t,i,j,w,s) for t in T for i in I for j in J for w in W for s in S]&#xA;&#xA;Y_Dt_ijws = m.integer_var_dict(Y_Dt_ijws_scope, name='Y_Dt_ijws')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; belongs to a set &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; belongs to a set &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;, etc. I defined these sets previously as I did for &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This was working fine until I had to write this part of a constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in I}Y_{ijws}^{Dt}+\sum_{i\in I}\sum_{a\in W}Y_{ijas}^{Dt}\cdot S_{aw}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We can see that the constraint uses the variable that I defined but also uses a variable with the index &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; instead of the index &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, which is not defined.&lt;/p&gt;&#xA;&lt;p&gt;I started to write the constraint like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.add_constraints((m.sum(Y_Dt_ijws[t,i,j,w,s] for i in I) + m.sum(m.sum(Y_Dt_ijvs[t,i,j,a,s]*S_aw for a in W) for i in I))*S_DC_wv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But obviously, there's an error saying there is an undefined name &lt;code&gt;Y_Dt_ijvs&lt;/code&gt; because I used &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; inside the parenthesis the second time I wrote that variable.&lt;/p&gt;&#xA;&lt;p&gt;I'm new to all this so I don't know if the way I did things is the best one. I thought of defining &lt;code&gt;Y_Dt_ijas&lt;/code&gt; as a new variable but for me, that doesn't make sense since it is referring to the exact same thing. Can someone help me, please?&lt;/p&gt;&#xA;&lt;p&gt;(P.S.: I know some people use GAMS or other things to solve these MILP problems but I have to use Python.)&lt;/p&gt;&#xA;" OwnerUserId="5847" LastEditorUserId="123" LastEditDate="2021-07-08T09:10:38.513" LastActivityDate="2021-07-08T09:10:38.513" Title="How do I define multiple indices for the same set in python? (using CPLEX to solve a MILP)" Tags="|modeling|python|docplex|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6543" PostTypeId="1" CreationDate="2021-07-09T06:36:46.347" Score="0" ViewCount="1013" Body="&lt;p&gt;I have a question about Gurobi. How do I define a constraint that can accept multiple different values? For example, a sample constraint is shown as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;f = [1.0, 1.0, 1.0, 1.0]&#xA;x = m.addVars(4, lb=0, ub=15, vtype=GRB.INTEGER)&#xA;m.addConstr(x.prod(f) == 10 or 15, name=&amp;quot;&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This constraint can be equal to multiple values, such as 10 or 15.&#xA;Is this constraint possible in Gurobi based on the Python language? If so, how should I write the code?&lt;/p&gt;&#xA;" OwnerUserId="5789" LastEditorUserId="123" LastEditDate="2021-07-09T14:11:24.713" LastActivityDate="2021-07-09T14:11:24.713" Title="Gurobi: How to define constraints that can accept multiple different values？" Tags="|modeling|python|gurobi|" AnswerCount="1" CommentCount="0" ClosedDate="2021-07-10T10:37:30.227" ContentLicense="CC BY-SA 4.0" />
  <row Id="6544" PostTypeId="2" ParentId="6543" CreationDate="2021-07-09T06:59:17.480" Score="2" Body="&lt;p&gt;You can do something like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;possible_values = [10, 15]&#xA;&#xA;# add binary variables&#xA;b = m.addVars(len(possible_values), vtype=&amp;quot;B&amp;quot;)&#xA;&#xA;# b[0] + b[1] == 1&#xA;m.addConstr(b.sum() == 1)&#xA;&#xA;# add indicator constraints:&#xA;for i, val in enumerate(possible_values):&#xA;    # if b[i] == 1, then x.prod(f) == val&#xA;    m.addConstr((b[i] == 1) &amp;gt;&amp;gt; (x.prod(f) == val))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here, we ensure that only one of the variables &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; can be equal to 1. Hence, &lt;code&gt;x.prod(f)&lt;/code&gt; can only be equal to &lt;code&gt;possible_values[i]&lt;/code&gt;. See the &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/py_model_agc_indicator.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;docs&lt;/a&gt; for more details regarding indicator constraints.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2021-07-09T06:59:17.480" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6545" PostTypeId="1" AcceptedAnswerId="6546" CreationDate="2021-07-09T14:27:37.247" Score="12" ViewCount="552" Body="&lt;p&gt;Given finite set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; and variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, how do I linearize the set membership constraint &lt;span class=&quot;math-container&quot;&gt;$x\in S$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-07-11T16:22:49.930" Title="How to linearize membership in a finite set" Tags="|modeling|linearization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6546" PostTypeId="2" ParentId="6545" CreationDate="2021-07-09T14:27:37.247" Score="20" Body="&lt;p&gt;First, some special cases:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$S=\{c\}$&lt;/span&gt;, fix &lt;span class=&quot;math-container&quot;&gt;$x=c$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$S=\{0,1\}$&lt;/span&gt;, declare &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to be binary.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$S=\{a,b\}\not=\{0,1\}$&lt;/span&gt;, introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and impose linear constraint &lt;span class=&quot;math-container&quot;&gt;$x=a(1-y)+by$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$S=\{a,a+c,a+2c,\dots,a+kc\}$&lt;/span&gt;, introduce integer variable &lt;span class=&quot;math-container&quot;&gt;$y\in[0,k]$&lt;/span&gt; and impose linear constraint &lt;span class=&quot;math-container&quot;&gt;$x=a+cy$&lt;/span&gt;.  (The previous bullet is the special case &lt;span class=&quot;math-container&quot;&gt;$c=b-a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k=1$&lt;/span&gt;.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Otherwise proceed as follows.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$s\in S$&lt;/span&gt;, introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_s$&lt;/span&gt;.  Impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{s\in S} y_s &amp;amp;= 1 \tag1 \\&#xA;\sum_{s\in S} s y_s &amp;amp;= x \tag2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; chooses exactly one &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$y_s=1$&lt;/span&gt;, and constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; forces &lt;span class=&quot;math-container&quot;&gt;$x=s$&lt;/span&gt; for that &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Alternatively (if your modeling language does not allow arbitrary index values), let &lt;span class=&quot;math-container&quot;&gt;$I=\{1,\dots,|S|\}$&lt;/span&gt; for 1-based indexing or &lt;span class=&quot;math-container&quot;&gt;$I=\{0,\dots,|S|-1\}$&lt;/span&gt; for 0-based indexing, with &lt;span class=&quot;math-container&quot;&gt;$S=\{s_i: i \in I\}$&lt;/span&gt;.&#xA;For each &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt;, introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;.  Impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i\in I} y_i &amp;amp;= 1 \tag3 \\&#xA;\sum_{i\in I} s_i y_i &amp;amp;= x \tag4&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; chooses exactly one &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$y_i=1$&lt;/span&gt;, and constraint &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; forces &lt;span class=&quot;math-container&quot;&gt;$x=s_i$&lt;/span&gt; for that &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-07-11T16:22:49.930" LastActivityDate="2021-07-11T16:22:49.930" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6547" PostTypeId="2" ParentId="6540" CreationDate="2021-07-09T14:29:58.733" Score="1" Body="&lt;p&gt;I have added a more general question and answer that address the modeling aspect, independent of solver:&#xA;&lt;a href=&quot;https://or.stackexchange.com/questions/6545/how-to-linearize-membership-in-a-finite-set&quot;&gt;How to linearize membership in a finite set&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can apply this with &lt;span class=&quot;math-container&quot;&gt;$S=\{0,3,5\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$S=\{0,1,3,5\}$&lt;/span&gt;, and so on.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-07-09T14:29:58.733" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6548" PostTypeId="1" AcceptedAnswerId="6551" CreationDate="2021-07-10T13:07:27.980" Score="2" ViewCount="83" Body="&lt;p&gt;I need examples of linear programming problems applied to irrigation system.&#xA;My idea is to give students many examples of LP applications in the irrigation engineering.&lt;/p&gt;&#xA;" OwnerUserId="5859" LastActivityDate="2021-07-11T12:39:31.473" Title="Examples of LP problems in irrigate engineering" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6549" PostTypeId="1" AcceptedAnswerId="6550" CreationDate="2021-07-10T15:21:09.370" Score="4" ViewCount="383" Body="&lt;p&gt;I'm trying to solve a problem for human resource allocation that has a function that receives the number of people working on a project and returns the time to finish it. The number of employees in a project has a nonlinear relation with the time to end it, therefore it can be represented as a matrix, the line controlling the number of employees, and the column controlling the project. For example, in the matrix below (in days), if I allocate 3 people in the 1° project, it will end in 5 days.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;A=\begin{bmatrix}&#xA;10 &amp;amp;  9  &amp;amp; 7\\&#xA;8 &amp;amp;  7  &amp;amp; 6.5\\&#xA;5 &amp;amp;  6.5  &amp;amp; 6\\&#xA;\end{bmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I think I can use binary variables, having one of these for each position of the matrix, to transform the problem into a mixed-integer linear problem, which is what I prefer so I can assess a metaheuristic that I used to solve it. But I also think that it isn't the right approach to solve it.&lt;/p&gt;&#xA;" OwnerUserId="2900" LastEditorUserId="-1" LastEditDate="2021-07-11T08:26:35.297" LastActivityDate="2021-07-11T08:26:35.297" Title="How is this type of function treated in mathematical programming?" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6550" PostTypeId="2" ParentId="6549" CreationDate="2021-07-10T16:04:05.997" Score="5" Body="&lt;p&gt;If the time for any project fails to be a convex function of the number of employees assigned to the project, I think your best bet is indeed to use a binary variable for each combination of project and employee count. Note that, in your example, completion time is a linear function of head count for the third project and a convex function for the second project, but the time-head count relationship is nonconvex for the first project (adding the second employee is less beneficial than adding the third employee is).&lt;/p&gt;&#xA;&lt;p&gt;If the relationship is convex for all projects, you have an alternative choice for formulating it, using an integer variable (number of employees assigned) for each project. It is based on the observation that a convex piecewise-linear function is the max of the linear functions describing each segment, along with the assumption that your model would favor lower completion times over higher completion times.&lt;/p&gt;&#xA;&lt;p&gt;Suppose we change the 10 in the upper left corner of your matrix to 14. Let &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; be the number of employees assigned to project 1 and &lt;span class=&quot;math-container&quot;&gt;$t_1$&lt;/span&gt; its completion time. The first two entries in the modified column 1 give us the line &lt;span class=&quot;math-container&quot;&gt;$t_1 = 20 - 6 x_1$&lt;/span&gt;, while the second and third give us the line &lt;span class=&quot;math-container&quot;&gt;$t_1 = 14 - 3 x_1$&lt;/span&gt;. So you could just add the constraints &lt;span class=&quot;math-container&quot;&gt;$t_1 \ge 20 - 6x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_1 \ge 14 - 3x_1$&lt;/span&gt; and rely on the solver to pick the smallest value of &lt;span class=&quot;math-container&quot;&gt;$t_1$&lt;/span&gt; (given &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;) that satisfies both constraints. This generalizes to more than 3 employees on a project as long as the time-count relationship is convex.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-10T16:04:05.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6551" PostTypeId="2" ParentId="6548" CreationDate="2021-07-11T12:39:31.473" Score="2" Body="&lt;p&gt;I am not familiar with this specific subject but, do you try googling about that? There are many related papers such as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/search?qs=irrigation%20optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Developing a model for multi-objective optimization of open channels and labyrinth weirs: Theory and application in Isfahan Irrigation Networks&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.mdpi.com/journal/water/special_issues/Optimization_Irrigation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimization of Irrigation Scheduling&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://Linear%20Optimization%20Model%20for%20Efficient%20Use%20of%20Irrigation%20Water&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linear Optimization Model for Efficient Use of Irrigation Water&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;And so on. I hope they would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-07-11T12:39:31.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6552" PostTypeId="1" AcceptedAnswerId="6553" CreationDate="2021-07-11T12:39:54.967" Score="5" ViewCount="146" Body="&lt;p&gt;I'm trying to model the following:&lt;/p&gt;&#xA;&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y \ne b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a positive  integer number( &lt;span class=&quot;math-container&quot;&gt;$y\le U$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is binary and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a constant.&lt;/p&gt;&#xA;" OwnerUserId="5862" LastEditorUserId="500" LastEditDate="2021-07-11T13:15:12.200" LastActivityDate="2021-07-11T13:15:12.200" Title="if $x = 0$ then $y \ne b$" Tags="|modeling|integer-programming|constraint|binary-variable|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6553" PostTypeId="2" ParentId="6552" CreationDate="2021-07-11T13:13:40.680" Score="7" Body="&lt;p&gt;Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z_2$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z_3$&lt;/span&gt;, and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z_1+z_2 +z_3&amp;amp;= 1 \tag1\\&#xA;1z_1+bz_2+(b+1)z_3 \le y &amp;amp;\le (b-1)z_1+bz_2+Uz_3 \tag2\\&#xA;z_2&amp;amp;\le x\tag3&#xA;\end{align}&lt;/span&gt;&#xA;Constraints &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforce the three disjoint cases &lt;span class=&quot;math-container&quot;&gt;$y&amp;lt;b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y=b$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$y&amp;gt;b$&lt;/span&gt;. Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$x=0\implies z_2=0$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z_2=0$&lt;/span&gt; excludes the &lt;span class=&quot;math-container&quot;&gt;$y=b$&lt;/span&gt; case.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-07-11T13:13:40.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6554" PostTypeId="2" ParentId="6537" CreationDate="2021-07-12T16:07:38.623" Score="7" Body="&lt;p&gt;Forum users are invited to post their suggestions for tighter/better formulations of mixed integer linear programming models here. The emphasis is on getting solutions (and closing the gap) efficiently, as opposed to model expressiveness (ease of users to see what is going on in the model).&lt;/p&gt;&#xA;&lt;h1&gt;General&lt;/h1&gt;&#xA;&lt;h1&gt;Logical constraints&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For &amp;quot;big M&amp;quot; models, smaller values of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; will reduce the likelihood of numerical problems and make the bounds tighter ... provided they are not &lt;em&gt;too&lt;/em&gt; small. (Too small a value may cut off feasible, possibly optimal, solutions.)&lt;/li&gt;&#xA;&lt;li&gt;While it is common to refer to &amp;quot;big M&amp;quot; in the singular, and authors like to use a single symbol &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, in practice different constraints can and frequently should use different values of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. So, for example, &lt;span class=&quot;math-container&quot;&gt;$a^{(i)\prime} x \le b_i + M z_i$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; binary, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; continuous, &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; parameters) should be &lt;span class=&quot;math-container&quot;&gt;$a^{(i)\prime} x \le b_i + M_i z_i$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; chosen to make that particular constraint valid but as tight as possible.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;Specific problem types&lt;/h1&gt;&#xA;&lt;h2&gt;Traveling salesperson problem (TSP)&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Travelling_salesman_problem#Dantzig%E2%80%93Fulkerson%E2%80%93Johnson_formulation&quot; rel=&quot;noreferrer&quot;&gt;Dantzig-Fulkerson-Johnson formulation&lt;/a&gt;, with a complete set of subtour elimination constraints, produces a tighter relaxation than the &lt;a href=&quot;https://en.wikipedia.org/wiki/Travelling_salesman_problem#Miller%E2%80%93Tucker%E2%80%93Zemlin_formulation&quot; rel=&quot;noreferrer&quot;&gt;Miller-Tucker-Zemlin formulation&lt;/a&gt;. The MTZ formulation, however, is considerably smaller when the number of possible subtours is large.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-12T16:07:38.623" CommentCount="0" CommunityOwnedDate="2021-07-12T16:07:38.623" ContentLicense="CC BY-SA 4.0" />
  <row Id="6555" PostTypeId="1" CreationDate="2021-07-13T10:42:20.510" Score="5" ViewCount="243" Body="&lt;p&gt;Suppose that I have an MIP with a whole lot of continuous variables and some integer variables. In my case, this takes a very long to solve (in fact I wasn't able at all to solve it to optimality). So I was wondering if it would be beneficial for solving this problem to exchange my integer variables by multiple binary variables.&lt;/p&gt;&#xA;&lt;p&gt;The integer variables do have upper bounds in the range of &lt;span class=&quot;math-container&quot;&gt;$10^2$&lt;/span&gt;, so I would replace them with ~100 binary variables. Does this help my LP relaxation to get stronger?&#xA;Actually, I would suggest to slightly adjust objective function coefficients, so I don't end up with ~100 variables of the exact same nature (I guess this might help).&lt;/p&gt;&#xA;&lt;p&gt;I would appreciate any experience or expertise on this topic, Cheers.&lt;/p&gt;&#xA;" OwnerUserId="5866" LastEditorUserId="36" LastEditDate="2021-07-13T12:41:00.310" LastActivityDate="2021-07-21T07:13:33.170" Title="Does exchanging integer variables by binary variables strengthen a MIP?" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6556" PostTypeId="1" CreationDate="2021-07-13T10:57:25.277" Score="3" ViewCount="45" Body="&lt;p&gt;I have a model where investments can be done in blocks. Now I could model this with integer or binary variables. Does anybody know which one is the better choice in terms of computational performance?&lt;/p&gt;&#xA;" OwnerUserId="5865" LastActivityDate="2021-07-13T10:57:25.277" Title="MIP: Do binary variables perform better that integers?" Tags="|mixed-integer-programming|integer-programming|binary-variable|" AnswerCount="0" CommentCount="1" ClosedDate="2021-07-13T12:45:15.360" ContentLicense="CC BY-SA 4.0" />
  <row Id="6557" PostTypeId="1" AcceptedAnswerId="6562" CreationDate="2021-07-13T19:08:08.467" Score="2" ViewCount="2857" Body="&lt;p&gt;I have a simple optimization problem and would like to solve it using Microsoft Solver. However, the solver does not do what it is supposed to.&lt;/p&gt;&#xA;&lt;p&gt;Briefly to the background: In the problem the gross salary for the year 2021, 2022 and 2023 is given. Income-related expenses in the amount of 17,000.00 € are to be distributed in such a way that as much of the tax as possible is reimbursed. That is, the payments must be distributed over the year so that the amount that can be reimbursed via the tax is as high as possible.&lt;/p&gt;&#xA;&lt;p&gt;For this I have now assembled several lines.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;salary before: Is the sum of the gross salary in the respective year.&lt;/li&gt;&#xA;&lt;li&gt;taxes before: The income tax to be paid on the salary according to the formula given (in the cell).&lt;/li&gt;&#xA;&lt;li&gt;payments: The sum of payments to be paid per year (total 17000 after 3 years).&lt;/li&gt;&#xA;&lt;li&gt;salary after: is the amount of the row salary before minus the amount of payment.&lt;/li&gt;&#xA;&lt;li&gt;taxes after: Are the income taxes that are due on the salary from line 4 (again, according to the formula of the cell).&lt;/li&gt;&#xA;&lt;li&gt;taxes saved: The difference between what I paid in taxes before (line 2) and what I would have to pay after deducting the income-related expenses (line 5). The sum of this is on the right.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The sum from the line Taxes saved should now be maximized with the solver. This is my target variable (F11). My variables are the cells B6:D6. The constraint is that the sum of the payments (F6) must always be 17.000,00 €.&lt;/p&gt;&#xA;&lt;p&gt;The solver also calculates, but the result is wrong. It simply divides the payments evenly over all 3 years, one third each.&lt;/p&gt;&#xA;&lt;p&gt;My question is, why does it do that and how can I get the solver to maximize the sum of the saved taxes?&lt;/p&gt;&#xA;&lt;p&gt;Here is the excel: &lt;a href=&quot;https://drive.google.com/file/d/188mPFDB1f3OiQTlTBvbIsAUDTRgiflma/view?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://drive.google.com/file/d/188mPFDB1f3OiQTlTBvbIsAUDTRgiflma/view?usp=sharing&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Many greetings and thanks&lt;/p&gt;&#xA;" OwnerUserId="5869" LastActivityDate="2021-07-14T11:05:53.783" Title="Excel Solver is not performing as desired" Tags="|optimization|solver|excel|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6558" PostTypeId="1" CreationDate="2021-07-13T19:12:38.720" Score="2" ViewCount="89" Body="&lt;p&gt;I'm trying to construct an SDP relaxation for a non-convex quadratic program (&lt;span class=&quot;math-container&quot;&gt;$x^{\intercal}\mathbf{H}x$&lt;/span&gt;) with the following objective function:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;x_{11}y_{11} + x_{12}y_{12} + x_{21}y_{21} + x_{22}y_{22}&#xA;\end{equation}&lt;/span&gt;&#xA;Where &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \in \{0, 1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{\max} \leq y_{ij} \leq y_\min $&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; is a continuous\real decision variable)&lt;/p&gt;&#xA;&lt;p&gt;The matrix &lt;span class=&quot;math-container&quot;&gt;$\mathbf{H}$&lt;/span&gt; has the following values which makes it indefinite:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\mathbf{H} = &#xA;\begin{bmatrix}&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;\end{bmatrix}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;By replacing the negative eigen values of matrix &lt;span class=&quot;math-container&quot;&gt;$\mathbf{H}$&lt;/span&gt; with zeros and reconstructing it using the new eigen values, I got the following positive semidefinite matrix:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\mathbf{H} = &#xA;\begin{bmatrix}&#xA;0.2500&amp;amp; 0&amp;amp; 0&amp;amp; 0&amp;amp;0.2500&amp;amp; 0&amp;amp; 0&amp;amp; 0\\ &#xA;0&amp;amp;0.2500&amp;amp; 0&amp;amp; 0&amp;amp; 0&amp;amp;0.2500&amp;amp; 0&amp;amp; 0\\ &#xA;0&amp;amp; 0&amp;amp;0.2500&amp;amp; 0&amp;amp; 0&amp;amp; 0&amp;amp;0.2500&amp;amp; 0\\ &#xA;0&amp;amp; 0&amp;amp; 0&amp;amp;0.2500&amp;amp; 0&amp;amp; 0&amp;amp; 0&amp;amp;0.2500\\ &#xA;0.2500&amp;amp; 0&amp;amp; 0&amp;amp; 0&amp;amp;0.2500&amp;amp; 0&amp;amp; 0&amp;amp; 0\\ &#xA;0&amp;amp;0.2500&amp;amp; 0&amp;amp; 0&amp;amp; 0&amp;amp;0.2500&amp;amp; 0&amp;amp; 0\\ &#xA;0&amp;amp; 0&amp;amp;0.2500&amp;amp; 0&amp;amp; 0&amp;amp; 0&amp;amp;0.2500&amp;amp; 0\\ &#xA;0&amp;amp; 0&amp;amp; 0&amp;amp;0.2500&amp;amp; 0&amp;amp; 0&amp;amp; 0&amp;amp;0.2500\\ &#xA;\end{bmatrix}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now here is my final objective function in SDP relaxed program that I figured out so far:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\mathbf{H\cdot X} - \mathbf{Tr(H\cdot X})&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\mathbf{x} = &#xA;\begin{bmatrix}&#xA;x_{11}\\x_{12}\\x_{21}\\x_{11}\\y_{11}\\y_{12}\\y_{21}\\y_{22}&#xA;\end{bmatrix}, \mathbf{X} = \mathbf{xx^{\intercal}}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Are these steps correct for constructing SDP relaxation for the non-convex quadratic program?.&lt;/li&gt;&#xA;&lt;li&gt;Is the objective function correct after subtracting the trace &lt;span class=&quot;math-container&quot;&gt;$\mathbf{Tr(H\cdot X)}$&lt;/span&gt;? because as far as I know the objective function must be either positive definite or positive semedefinite.&lt;/li&gt;&#xA;&lt;li&gt;I know that there is a &lt;a href=&quot;https://or.stackexchange.com/questions/6482/solving-quadratically-constrained-quadratic-program-with-cross-product-terms-onl&quot;&gt;linearization technique&lt;/a&gt; that can solve the problem but I'm trying to find how this can be solved using SDP.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5671" LastActivityDate="2021-07-27T08:37:33.460" Title="Subtracting Values from a Positive semidefinite Matrix in a Semidefinite Program" Tags="|optimization|mixed-integer-programming|nonlinear-programming|convex-optimization|quadratic-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6559" PostTypeId="1" CreationDate="2021-07-14T04:51:40.753" Score="1" ViewCount="102" Body="&lt;p&gt;I have a nonlinear bi-variate optimization problem like &lt;span class=&quot;math-container&quot;&gt;$\max \: f(x,y)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$f(x,y)$&lt;/span&gt; is a nonlinear and differentiable function of both variables, and &lt;span class=&quot;math-container&quot;&gt;$0\le x\le 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\:0\le y \le ub$&lt;/span&gt;. In order to find the optimal solution, can I find the stationary points, &lt;span class=&quot;math-container&quot;&gt;$\nabla f(x,y)=0$&lt;/span&gt;, and boundary points and evaluate the objective function at the corners, such as &lt;span class=&quot;math-container&quot;&gt;$(0,0), (0,ub), (1,0),(1,ub)$&lt;/span&gt; points and stationary points &lt;span class=&quot;math-container&quot;&gt;$\nabla f(x,y)=0$&lt;/span&gt; (KKT points)? The highest order in the function is 3 and in form of &lt;span class=&quot;math-container&quot;&gt;$xy^2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$yx^2$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="139" LastEditDate="2021-07-14T04:57:20.923" LastActivityDate="2021-07-15T19:45:03.017" Title="Maximization of a differentiable and nonlinear function over a bounded space" Tags="|nonlinear-programming|nonconvex-programming|continuous-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6560" PostTypeId="1" AcceptedAnswerId="6561" CreationDate="2021-07-14T07:40:10.923" Score="0" ViewCount="160" Body="&lt;p&gt;Following is the initial snippet of the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# o is the model and x,y are variables and a,w are parameters. (i=1,...p and j=1,...n and k=1,....r) &#xA;&#xA;# ( X_ij,  Y_kj,  W_k,   A_ik)&#xA;&#xA;(o += w[0] *(y[0][0] + y[0][1]) &amp;gt;= xsum (a[i][0]* x[i][0] for i in p) + xsum (a[i][0]* x[i][1] for i in p)&#xA;&#xA;o += w[1] *(y[1][0] + y[1][1]) &amp;gt;= xsum (a[i][1]* x[i][0] for i in p) + xsum (a[i][1]* x[i][1] for i in p) &#xA;&#xA;o += w[2] *(y[2][0] + y[2][1]) &amp;gt;= xsum (a[i][2]* x[i][0] for i in p) + xsum (a[i][2]* x[i][1] for i in p)&#xA;#..&#xA;&#xA;#..upto r times&#xA;&#xA;o += w[0] *(y[0][0] + y[0][1] + y[0][2]) &amp;gt;= xsum (a[i][0]* x[i][0] for i in p) + xsum (a[i][0]* x[i][1] for i in p) + xsum (a[i][0]* x[i][2] for i in p)&#xA;&#xA;o += w[1] *(y[1][0] + y[1][1] + y[1][2]) &amp;gt;= xsum (a[i][1]* x[i][0] for i in p) + xsum (a[i][1]* x[i][1] for i in p) + xsum (a[i][1]* x[i][2] for i in p)&#xA;&#xA;o += w[2] *(y[2][0] + y[2][1] + y[2][2]) &amp;gt;= xsum (a[i][2]* x[i][0] for i in p) + xsum (a[i][2]* x[i][1] for i in p) + xsum (a[i][2]* x[i][2] for i in p)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I simplified the above to the following which is correct&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for k in r:&#xA;&#xA;    o += (w[k] * y[k][0]) &amp;gt;= xsum (a[i][k]* x[i][0] for i in p)&#xA;for k in r:&#xA;&#xA;    o += (w[k] * (y[k][0]+ y[k][1])) &amp;gt;= xsum (a[i][k]* x[i][1] for i in p)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But i need to simplify further, so, how to simplify further?&lt;/p&gt;&#xA;&lt;p&gt;I tried this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for j in n:&#xA;&#xA;    for k in r:&#xA;&#xA;        o += xsum(w[k] *y[k][j] for j in n) &amp;gt;= xsum (a[i][k]* x[i][j] for i in p)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But it is not correct representation as I got wrong answers.&lt;/p&gt;&#xA;&lt;p&gt;( Though I didn't explained in detail, hope this might be enough for my issue with simplification of constraints, please reply if needed more details)&lt;/p&gt;&#xA;" OwnerUserId="530" LastEditorUserId="992" LastEditDate="2021-07-14T13:13:33.180" LastActivityDate="2021-07-14T13:13:33.180" Title="How to simplify the following constraints as I'm using MIP optimization solver in python?" Tags="|optimization|mixed-integer-programming|python|convex-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6561" PostTypeId="2" ParentId="6560" CreationDate="2021-07-14T08:15:53.863" Score="2" Body="&lt;p&gt;Your question isn't entirely clear and isn't really an OR question, but I think what you are trying to do is the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for j in n:&#xA;    for k in r:&#xA;        o += xsum(w[k] *y[k][jj] for jj in n if jj &amp;lt;= j) &amp;gt;= xsum (a[i][k]* x[i][j] for i in p)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4030" LastActivityDate="2021-07-14T08:15:53.863" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6562" PostTypeId="2" ParentId="6557" CreationDate="2021-07-14T11:05:53.783" Score="4" Body="&lt;p&gt;There are different solvers in Excel that are suited for different types of problems:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Simplex LP&lt;/li&gt;&#xA;&lt;li&gt;GRG Nonlinear&lt;/li&gt;&#xA;&lt;li&gt;Evolutionary&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The Simplex LP solver is the only solver that can guarantee an optimal solution, however, the problem size is somewhat limited and all of the constraints as well as the objective function have to be linear.&lt;/p&gt;&#xA;&lt;p&gt;Your problem is small, however, there are non-linear equations:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the IF function is non-linear&lt;/li&gt;&#xA;&lt;li&gt;Within the IF statements you have quadratic equations (Welcome to bureaucracy. Germany?)&lt;/li&gt;&#xA;&lt;li&gt;You are rounding the tax payments (=INT(....))&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The rounding probably won't be necessary, so this is an easy one. The IF function is deadly in this context and can be eliminated (see piecewise linear functions) using additional variables.&lt;/p&gt;&#xA;&lt;p&gt;At this point, a solver like Gurobi could solve it since it supports quadratic terms under certain conditions. However, the Excel Simplex solver still can't do it. You could approximate the quadratic part using more piecewise linear functions, however, the problem will get way to big to model it in a reasonable way in Excel.&lt;/p&gt;&#xA;&lt;p&gt;So, what about the other solvers? Both the GRG nonlinear solver as well as the Evolutionary solver are based on heuristics. These solvers aren't guaranteed to find an optimal solution and aren't even guaranteed to find a solution at all. I use them once in a while, but most of the time it isn't even worth trying.&lt;/p&gt;&#xA;&lt;p&gt;In your case, I have used only the modelling tricks to get rid of the IF function (see piecewise linear function) and then used the GRG nonlinear solver. I was lucky and was able too find an optimal solution, which I didn't expect. The solver is usually letting you know if the solution is just &amp;quot;feasible&amp;quot; or if it is also optimal (like in this case):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kQZ2V.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kQZ2V.png&quot; alt=&quot;Optimal solution found&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The optimal solution is as follows:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/jF1mZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jF1mZ.png&quot; alt=&quot;The optimal solution&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you can see in the screenshot above, I have completely changed the way the tax payments are calculated. Instead of having one formula, I calculate the &amp;quot;potential&amp;quot; tax that would be due in each tax bracket. Furthermore, I introduced a binary variable for each year and tax bracket. This variable is 1 if the taxable salary is in the given range and 0 otherwise. All variables are yellow and all formulas that need to be added to the solver are in orange. The green line contains the &amp;quot;old&amp;quot; calculation using the &amp;quot;IF&amp;quot; statements. I kept this in there in order to verify that the new calculation is implemented correctly.&lt;/p&gt;&#xA;&lt;p&gt;For your reference, here's the file after my modifications: &lt;a href=&quot;https://drive.google.com/file/d/1pBFCyF8MvtIEJh7PXxNglwBvigXX3Kn1/view?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://drive.google.com/file/d/1pBFCyF8MvtIEJh7PXxNglwBvigXX3Kn1/view?usp=sharing&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you want to do this for more years or for more complicated tax formulas, this approach probably won't work and you won't get around using a modelling language and a commercial solver.&lt;/p&gt;&#xA;" OwnerUserId="4030" LastActivityDate="2021-07-14T11:05:53.783" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6563" PostTypeId="1" CreationDate="2021-07-15T07:48:45.827" Score="4" ViewCount="165" Body="&lt;p&gt;Local search, as the name suggests, takes a &lt;em&gt;local&lt;/em&gt; angle to the optimization problem. In deep learning, an adjacent field, the &amp;quot;local minima&amp;quot; problem is frequently mitigated by &lt;em&gt;increasing&lt;/em&gt; the number of dimensions, potentially inflating the count by orders of magnitude. At first, this may seems counter-intuitive, as a problem with many more variables may &amp;quot;feel&amp;quot; more complex than a variant of the same problem with much fewer variables.&lt;/p&gt;&#xA;&lt;p&gt;I would like to know if there are known results on such a line of thoughts - aka inflating the number of decision variables - for local search.&lt;/p&gt;&#xA;" OwnerUserId="5751" LastEditorUserId="5751" LastEditDate="2021-07-15T08:00:43.197" LastActivityDate="2021-07-18T13:03:52.503" Title="Increase the dimension to ease the local search?" Tags="|local-search|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6564" PostTypeId="2" ParentId="6563" CreationDate="2021-07-15T09:37:05.907" Score="1" Body="&lt;p&gt;In general, increasing the dimension of the neighbourhood of a local search can improve the final results, because  a local optimum for a neighbourhood is not necessarily a local optimum for a different one, but you need to find a smart way of evaluating the much larger set of solutions. The extent to which this is possible depends on the problem, the neighbourhood used, and possibly other factors such as the solution representation.&lt;/p&gt;&#xA;&lt;p&gt;The use of neighbourhoods of increasing size is the idea underlying Variable Neighbourhood Descent (VND, see e.g. &lt;a href=&quot;https://link.springer.com/content/pdf/10.1007%2F978-3-319-07124-4_9.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this book chapter&lt;/a&gt;). Large/Very Large Neighbourhood Search, (some) matheuristics, Dynasearch use efficient methods (mathematical programming, dynamic programming, etc) to explore large neighbourhoods.&lt;/p&gt;&#xA;&lt;p&gt;Which neighbourhood will work well for a problem, for the computational effort you're willing to invest, in general you won't know until you try.&lt;/p&gt;&#xA;" OwnerUserId="224" LastActivityDate="2021-07-15T09:37:05.907" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6565" PostTypeId="1" AcceptedAnswerId="6574" CreationDate="2021-07-15T13:08:16.360" Score="2" ViewCount="1390" Body="&lt;p&gt;I have a vehicle routing problem solved by linear programming, but I'm confused about the constraints (see the model in figure 1). In the model, &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are decision variables, and we set node &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; as the depot, nodes &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; as customers. Constraints 1 &amp;amp; 2 indicate that there can only be one edge for both going into and out of the CUSTOMER nodes. However, when I use Gurobi optimizer to solve it, I find the solution always includes the depot (node &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. See a solution in figure 2). Even I set the depot to an extremely far location (figure 3), the depot is still in the solution. Theoretically, to minimize the objective function, if there are no constraints about the edges into and out of the depot, then &lt;span class=&quot;math-container&quot;&gt;$x_{0i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{i0}$&lt;/span&gt; should always be 0. The constraints about the depot can be like &lt;span class=&quot;math-container&quot;&gt;$\sum x_{i0} \ge 1$&lt;/span&gt;, but there are no such constraints in the model.&lt;/p&gt;&#xA;&lt;p&gt;This is the code used for adding constraints:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mdl.addConstrs(   # mdl is the name of the model&#xA;    quicksum(x[i, j] for j in V if j != i) == 1 for i in N)  # only one edge into customer node i&#xA;mdl.addConstrs(&#xA;    quicksum(x[i, j] for i in V if i != j) == 1 for j in N)  # only one edge out of customer node i&#xA;mdl.addConstrs((x[i, j] == 1) &amp;gt;&amp;gt; (u[i] + q[i] == u[j]) for i, j in A if i != 0 and j != 0)&#xA;mdl.addConstrs(u[i] &amp;gt;= q[i] for i in N)&#xA;mdl.addConstrs(u[i] &amp;lt;= Q for i in N)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now I'm confident that my code is not problematic (if anyone want to check it I've put it on my Github: &lt;a href=&quot;https://github.com/KaiyuWei/VRP-problem-by-Gurobi--Python&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/KaiyuWei/VRP-problem-by-Gurobi--Python&lt;/a&gt;), then could anyone explain the reason why the depot is always included? Thanks!&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5xVQ9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5xVQ9.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/rB0Lm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rB0Lm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/cec4L.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cec4L.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5873" LastEditorUserId="36" LastEditDate="2021-07-15T13:16:18.570" LastActivityDate="2021-07-15T23:59:44.177" Title="Problem with vehicle routing problem in Gurobi Python" Tags="|mixed-integer-programming|gurobi|vehicle-routing|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="6566" PostTypeId="1" CreationDate="2021-07-15T14:37:44.873" Score="6" ViewCount="72" Body="&lt;p&gt;Consider the &lt;a href=&quot;https://link.springer.com/article/10.1007/BF01589101&quot; rel=&quot;noreferrer&quot;&gt;boolean quadric polytope&lt;/a&gt;, which is defined on a complete graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$QP = \{(x,z) \in \{0,1\}^{V+E} : x_ix_j=z_{ij}  \}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now we can generate for small examples with tools like porta, polymake the complete linear description. However the description becomes fast exponential increasing, which makes the output difficult to analyze and quickly makes the approach infeasible.&lt;/p&gt;&#xA;&lt;p&gt;Now one of the reason the output becomes exponential is that there is a huge symmetry in this polytope, consider for example the facet class:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_i \geq 0 \ \forall i \in V $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then the output of polymake would list each of these constraints, however one for example &lt;span class=&quot;math-container&quot;&gt;$x_1 \geq 0$&lt;/span&gt; is enough, since the other follow by symmetry.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to remove this symmetry from the polytope and be able to generate the complete reduced description (faster)?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2021-07-16T00:13:10.683" Title="Can we remove symmetry from polytopes for analyzing them?" Tags="|convex-hull|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6567" PostTypeId="1" AcceptedAnswerId="6568" CreationDate="2021-07-15T14:59:56.940" Score="6" ViewCount="514" Body="&lt;p&gt;I'm working on a MILP (Mixed-Integer Linear Programming) problem with the Java API of Cplex.&lt;/p&gt;&#xA;&lt;p&gt;In order to easily exclude some variables from my problem I thought about setting both their lower and upper bound equal to '0.0'.&lt;/p&gt;&#xA;&lt;p&gt;Now I have these questions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Could it be a good solution to achieve my goal, or does it have any particular drawbacks?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Will, in this case, the simulation time be longer than the situation where I just eliminate those variables?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If a variable, with both upper and lower bounds equal to '0.0', is multiplied by a coefficient equal to '0.0', could it be a problem for any reason (e.g.: from a numerical point of view, etc)?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4944" LastActivityDate="2021-07-15T15:35:01.650" Title="Upper and lower bounds of a variable equal" Tags="|mixed-integer-programming|linear-programming|cplex|bounds|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6568" PostTypeId="2" ParentId="6567" CreationDate="2021-07-15T15:35:01.650" Score="5" Body="&lt;p&gt;Unless you turn off the presolve step, CPLEX will eliminate the variables that are locked at zero during presolve. So the answer to your second question is that presolve may take slightly longer (but the difference will be too small to notice) and the actual branch-and-cut phase will not take any longer than if you had omitted the variables yourself. The answer to your third question is that there will be no issues, since the variables will have been eliminated. (There would be no problem in any case.)&lt;/p&gt;&#xA;&lt;p&gt;Circling around to whether it is a good idea, I would say that there are at least two potential benefits and no liabilities. The first potential benefit is that the model may be a bit easier to read by someone other than yourself, since you avoid having to define subsets of indices for which the variables should not exit. The second potential benefit is that you can create vectors or matrices of variables without having to do any reindexing. There are a number of methods in the Java API where the arguments can be IloNumVar[]. If you pass in an array in which some elements are missing/undefined, CPLEX will throw an exception. So either you get creative with indexing (sales[i] is the i-th &lt;em&gt;included&lt;/em&gt; sales variable as opposed to sales of the i-th product, or whatever), which is a PITA and prone to user error, or you pass in the full vector (sales[]) and let CPLEX skip over the variables that are fixed at zero.&lt;/p&gt;&#xA;&lt;p&gt;For what it's worth, I frequently use the lower bound = upper bound = zero technique when some variables should be fixed at zero.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-15T15:35:01.650" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6569" PostTypeId="2" ParentId="6559" CreationDate="2021-07-15T19:45:03.017" Score="3" Body="&lt;p&gt;The KKT conditions are necessary conditions for an optimum to your problem, so if you can find all feasible points satisfying them, the one with the best objective function will be your optimum. There is no need to consider the corners of the feasible region explicitly. If any of them is optimal, it will also be a KKT point.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-15T19:45:03.017" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6570" PostTypeId="1" AcceptedAnswerId="6572" CreationDate="2021-07-15T21:07:25.747" Score="2" ViewCount="127" Body="&lt;p&gt;I'm having some trouble understanding about the independent rows in a basic solution. In the book &lt;em&gt;Introduction to linear optimization&lt;/em&gt; by B&amp;amp;T, the authors give the definition of a basic solution as follows &lt;a href=&quot;https://i.stack.imgur.com/kx3h8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kx3h8.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;where they claim that all equality constraints are active. However, in a later example, I noticed the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uZT9t.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uZT9t.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Apparently, all constraints in the later picture are inequality constraints, but the authors treat them as equality constraints and claim since they are active, we then have a basic solution.&lt;/p&gt;&#xA;&lt;p&gt;So my question is: does inequality and equality matter when it comes to active constraints? Should I treat them differently?&lt;/p&gt;&#xA;" OwnerUserId="5626" LastEditorUserId="123" LastEditDate="2021-07-21T07:10:17.567" LastActivityDate="2021-07-21T07:10:17.567" Title="Linearly independent rows in simplex" Tags="|linear-programming|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6571" PostTypeId="1" CreationDate="2021-07-15T21:13:18.690" Score="1" ViewCount="136" Body="&lt;p&gt;I'm working on a vehicle routing problem, in which a vehicle need to pick up amounts of things in some nodes. I'm trying to solve it by Gurobi optimizer. Except for meeting the time windows of each nodes, it is also required that the capacity of the vehicle is limited, which causes a big problem for me. Every time when the vehicle leaves a node, it checks whether the remaining capacity can load the amount in the next node. If not, the vehicle need to unload first and then go to the next node (the unloading time can be neglected). my model for the capacity constraints are like:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/W7twn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/W7twn.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you can see, there are 4 indicator constraints, each of them has two conditions in &amp;quot;if&amp;quot; line.  Does anyone know how to deal with such format of constraints in Gurobi? Or do we have more smarter modeling method to list some constraints that is easier to input in Gurobi optimizer?&lt;/p&gt;&#xA;&lt;p&gt;Besides, since Gurobi doesn't support strict comparison signs like &amp;lt; and &amp;gt;, how do we deal with such a problem  if we find a way to input the above constraint?  I mean, if strict comparison sign is not supported then we have constraints like &lt;code&gt;if x &amp;lt;= 0, y =1; if x &amp;gt;= 0, y = 0&lt;/code&gt;, in which the value of &lt;code&gt;x&lt;/code&gt; has some overlap and it may cause problems.&lt;/p&gt;&#xA;" OwnerUserId="5873" LastEditorUserId="123" LastEditDate="2021-07-21T07:12:46.030" LastActivityDate="2021-07-21T07:12:46.030" Title="Multiple conditions in indicator constraint of Gurobi" Tags="|mixed-integer-programming|gurobi|vehicle-routing|indicator-constraints|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6572" PostTypeId="2" ParentId="6570" CreationDate="2021-07-15T21:54:13.697" Score="3" Body="&lt;p&gt;All equality constraints are active for all feasible solutions.&lt;/p&gt;&#xA;&lt;p&gt;The inequality constraints which are active for a solution are those which are satisfied (hold) with equality at that solution.&lt;/p&gt;&#xA;&lt;p&gt;From the viewpoint of determining how many active constraints are linearly independent, throw all the equality constraints plus the active inequality constraints into one hopper, with no further distinguishment needed.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="1228" LastEditDate="2021-07-16T13:49:28.900" LastActivityDate="2021-07-16T13:49:28.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6573" PostTypeId="2" ParentId="6566" CreationDate="2021-07-15T23:45:17.527" Score="4" Body="&lt;p&gt;Have a look at &lt;a href=&quot;https://link.springer.com/article/10.1007/s13675-015-0040-0&quot; rel=&quot;nofollow noreferrer&quot;&gt;PANDA&lt;/a&gt;. It's a new alternative to porta/polymake with some improvements. One of the features it has is the possibility for specifying symmetry properties to accelerate the computation. Section &lt;em&gt;2.3 (Exploitation of symmetry)&lt;/em&gt; of the paper provides relevant details (your example is also mentioned).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Here is &lt;a href=&quot;http://comopt.ifi.uni-heidelberg.de/software/PANDA/&quot; rel=&quot;nofollow noreferrer&quot;&gt;the website where PANDA can be downloaded&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastEditorUserId="1202" LastEditDate="2021-07-16T00:13:10.683" LastActivityDate="2021-07-16T00:13:10.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6574" PostTypeId="2" ParentId="6565" CreationDate="2021-07-15T23:59:44.177" Score="5" Body="&lt;p&gt;Constraints 1 and 2 ensure that there is an edge going in and out of every node. Constraint 3 works as a subtour elimination and along with the above constraints ensures that there is no subtour and as a result, you must enter and leave the depot.&lt;/p&gt;&#xA;&lt;p&gt;A simple illustration is to assume there are only 3 nodes. So: &lt;span class=&quot;math-container&quot;&gt;$ V = \{0, 1, 2\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ N = \{1,2\}$&lt;/span&gt;. Let's spell out the constraints as coded:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{10}+x_{12}&amp;amp;= 1 \tag1\\&#xA;x_{20}+x_{21}&amp;amp;= 1 \tag2\\&#xA;x_{01}+x_{21}&amp;amp;= 1 \tag3\\&#xA;x_{02}+x_{12}&amp;amp;= 1 \tag4\\&#xA;\mbox{if } x_{12} = 1 \rightarrow u_1+q_1 &amp;amp;= u_2 \tag5\\&#xA;\mbox{if } x_{21} = 1 \rightarrow u_2+q_2 &amp;amp;= u_1 \tag6\\&#xA;q_1 \le u_1 &amp;amp;\le Q \tag7\\&#xA;q_2 \le u_2 &amp;amp;\le Q \tag8\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that only the first two sets of constraints (equations 1 to 4 above) have anything to do with the depot. If you're wondering why the edges of node &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; are selected in the solution, let's consider the case that they are not and see if that's possible with the constraints above.&lt;/p&gt;&#xA;&lt;p&gt;In case you don't want to see an edge from/to depot, that means you want &lt;span class=&quot;math-container&quot;&gt;$x_{10}, x_{20}, x_{01}, x_{02}$&lt;/span&gt; to be zero. If you substitute this in the constraints above, you'll have &lt;span class=&quot;math-container&quot;&gt;$x_{12}=x_{21}=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, you cannot have &lt;span class=&quot;math-container&quot;&gt;$x_{12} = x_{21} = 1$&lt;/span&gt;, because constraints 5 and 6 above cannot both be true at the same time, unless &lt;span class=&quot;math-container&quot;&gt;$q_1 = q_2 = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, from here work backwards for yourself. For example, let &lt;span class=&quot;math-container&quot;&gt;$x_{12} = 1$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{12} = 1 \rightarrow \mbox{(equations 1 and 4) } x_{10}=x_{02}=0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mbox{if } x_{12} = 1 \rightarrow \mbox{(equations 5 and 6) } x_{21}=0 \rightarrow \mbox{(equations 2 and 3) } x_{20}=x_{01}=1$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2021-07-15T23:59:44.177" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6575" PostTypeId="1" AcceptedAnswerId="6599" CreationDate="2021-07-16T05:59:53.990" Score="3" ViewCount="143" Body="&lt;p&gt;Given a network as a directed acyclic graph with a source and sink, and non-negative edge capacities, I am interested in the extreme source-sink flows. More formally, I am interested in a characterization of the extreme points (vertices) of the capacitated flow polytope. Can someone provide me a reference to this problem or state the solution.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="500" LastEditDate="2021-07-17T15:13:55.770" LastActivityDate="2021-07-20T08:33:32.037" Title="Extreme points for capacitated flow polytope" Tags="|reference-request|network-flow|polyhedra|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6576" PostTypeId="1" AcceptedAnswerId="6580" CreationDate="2021-07-16T15:37:50.000" Score="1" ViewCount="321" Body="&lt;p&gt;The multi-objective optimization problem in my case is non-linear as it consists of three objective function of which two are nonlinear function and the third is a linear function. Lets say objective 1 is as given below:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Objective 1: Minimize &lt;span class=&quot;math-container&quot;&gt;$f_1(X_1,X_2)=230.54X_1^2+305X_2^2+554.56X_1X_2+121.59X_1+112.9X_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 1: &lt;span class=&quot;math-container&quot;&gt;$ 0 \le X_1 \le 1.5$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 2: &lt;span class=&quot;math-container&quot;&gt;$ 0 \le X_2 \le 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 3: &lt;span class=&quot;math-container&quot;&gt;$ X_1 + X_2 \le 30$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_2$&lt;/span&gt; are decision variable and are real numbers.&lt;/p&gt;&#xA;&lt;p&gt;To determine convexity of the above function, the eigenvalues of its Hessian matrix is examined.&lt;/p&gt;&#xA;&lt;p&gt;For this case, I get both positive and negative eigenvalue. The eigenvalues are 1306.5 and -235.4. Hence, it is a non-convex optimization problem. For this case, how can classify this problem as NP-Hard and use NSGA-II to solve the problem?&lt;/p&gt;&#xA;" OwnerUserId="5794" LastEditorUserId="5794" LastEditDate="2021-07-16T15:53:36.897" LastActivityDate="2021-07-18T12:01:15.537" Title="Prove NP Hardness for non-convex multi-objective optimization" Tags="|optimization|nonlinear-programming|global-optimization|genetic-algorithm|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6577" PostTypeId="2" ParentId="6576" CreationDate="2021-07-16T16:16:33.437" Score="4" Body="&lt;p&gt;The notion of NP-hardness relates to whether one class of problems can be solved by a solver for another class of problems where the translation overhead is negligible.&lt;/p&gt;&#xA;&lt;p&gt;The problem you presented is member of many classes of problems. However NP-hardness is the property of a class of problems. So it is impossible to answer whether this particular instance is NP hard as the question doesn't make sense.&lt;/p&gt;&#xA;&lt;p&gt;As for is that problem solvable via  NSGA-II, yes you can get a solution. But due it's simple structure and low dimensionality a global optimizer of this single objective (such as the Octeract Engine, Baron or a non convex QP solver) can be used to have guarantees that it is indeed the optimal solution.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-07-16T16:16:33.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6578" PostTypeId="2" ParentId="6576" CreationDate="2021-07-16T19:59:24.783" Score="3" Body="&lt;p&gt;NP-hardness is an asymptotic result of increasing problem dimensions. It is not a property of one fixed problem instance. So to ask whether your problem class is NP-hard, you would have to explain how the problem would grow with increasing numbers of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; variables.&lt;/p&gt;&#xA;&lt;p&gt;As far as solving your specific instance, a number of nonlinear solvers could probably do it, and for that matter you could probably &amp;quot;brute force&amp;quot; it by solving the Karush-Kuhn-Tucker necessary conditions. There are three possibilities for the first constraint (binding at 0, binding at 1.5, nonbinding) and similarly for the second, and two possibilities (binding or not) for the third. That gives you 3x3x2=18 sets of KKT conditions to solve, which is very manageable. The best of the 18 solutions (fewer if some combinations yield no feasible solution) is your winner.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-16T19:59:24.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6579" PostTypeId="1" CreationDate="2021-07-16T20:16:52.733" Score="3" ViewCount="278" Body="&lt;p&gt;As I know, any SAT solver such as or-tools or cplex cp optimizer converts a given problem to CNF form in the first place. Is it possible to extract the resulting CNF representation from or-tools or cplex?&lt;/p&gt;&#xA;" OwnerUserId="5875" LastEditorUserId="500" LastEditDate="2021-11-05T17:15:18.543" LastActivityDate="2022-09-19T06:30:50.090" Title="Extracting CNF representation of my problem from SAT solver" Tags="|cplex|solver|constraint-programming|or-tools|sat|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6580" PostTypeId="2" ParentId="6576" CreationDate="2021-07-16T22:03:05.230" Score="1" Body="&lt;p&gt;Considering the first given objective function, the problem is trivial to solve. The decision variables X1 and X2 are positive. Because polynomial with positive coefficients only, the objective function is thus monotonically increasing over the space of feasible solutions. The last constraint over X1 and X2 is inactive because dominated by the previous ones. Consequently, the minimum (0) is reached for X1 = 0 and X2 = 0. In the same way, if you want to maximize, you can easily show that the maximum (1950.84) is reached for X1 = 1.5 and X2 = 1.&lt;/p&gt;&#xA;&lt;p&gt;As previously suggested, you can quickly check it using any nonlinear solver. For example, below is the maximization problem solved using LocalSolver.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function model() {&#xA;    X1 &amp;lt;- float(0,1.5);&#xA;    X2 &amp;lt;- float(0,1);&#xA;    constraint X1 + X2 &amp;lt;= 30;&#xA;    obj &amp;lt;- 230.54 * X1 * X1 + 305 * X2 * X2 + 554.56 * X1 * X2 + 121.59 * X1 + 112.9 * X2; &#xA;    maximize obj;&#xA;}&#xA;&#xA;function output() {&#xA;    println(&amp;quot;X1 = &amp;quot; + X1.value + &amp;quot;, X2 = &amp;quot; + X2.value);&#xA;}&#xA;&#xA;&amp;gt; localsolver .\orstackexchange_20210716.lsp&#xA;LocalSolver 10.5.20210624-Win64. All rights reserved.&#xA;Load .\orstackexchange_20210716.lsp...&#xA;Run input...&#xA;Run model...&#xA;Run param...&#xA;Run solver...&#xA;    &#xA;Model:  expressions = 19, decisions = 2, constraints = 1, objectives = 1&#xA;Param:  no time limit, no iteration limit&#xA;&#xA;[objective direction ]:     maximize&#xA;&#xA;[  0 sec,       0 itr]:            0&#xA;[ optimality gap     ]:      100.00%&#xA;[  0 sec,       2 itr]:      1950.84&#xA;[ optimality gap     ]:           0%&#xA;&#xA;2 iterations performed in 0 seconds&#xA;&#xA;Optimal solution:&#xA;  obj    =      1950.84&#xA;  gap    =           0%&#xA;  bounds =      1950.84&#xA;&#xA;Run output...&#xA;X1 = 1.5, X2 = 1 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2021-07-18T12:01:15.537" LastActivityDate="2021-07-18T12:01:15.537" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6581" PostTypeId="2" ParentId="6579" CreationDate="2021-07-17T05:44:36.467" Score="5" Body="&lt;p&gt;CP-SAT uses a SAT backend.  But at any moment, just like with SMT solvers, the full model is never fully represented using clauses and Boolean literals. I recommend looking at the CPAIOR 2020 masterclass on CP (on YouTube) to get a better understanding of the architecture of the solver.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2021-07-17T05:44:36.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6582" PostTypeId="2" ParentId="6555" CreationDate="2021-07-17T14:06:20.897" Score="2" Body="&lt;p&gt;There are multiple ways to express a finite interval of integers using boolean variables. A different encoding would be the logarithmic one&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=0}^{\left \lceil{\log_2(10)}\right \rceil } 2^i\tilde{x}_i \text{ subject to } \sum_{i=0}^{\left \lceil{\log_2(10)}\right \rceil } 2^i\tilde{x}_i \leq 10$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can come up with many such encodings and in general the answer is, it depends try it out. In general i would not suspect this to yield better  relaxation. What you are doing by introducing this binarization of your variables is that you make branching decisions for the solver (or rather change the space of branching decisions). It could be that your branching decisions are superior to the ones a Mixed Integer solver would pick. In general i would think a pure cutting planes based MILP solver would suffer from your proposed reformulation and since presolving also become harder due to the non-standard input format you might see a drop in performance when using a MILP solver, however such a binarized MILP problem could then be solved using MaxSAT or Pseudoboolean optimization which are a different solver technology and maybe yield performance benefits.&lt;/p&gt;&#xA;&lt;p&gt;You might also consider initial assignments that break symmetries, experimenting with solver parameters, different solvers (look into Neos Server where you can test different solvers) or consider whether you actually need the global optima.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="123" LastEditDate="2021-07-21T07:13:33.170" LastActivityDate="2021-07-21T07:13:33.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6583" PostTypeId="1" CreationDate="2021-07-17T20:44:22.493" Score="9" ViewCount="184" Body="&lt;p&gt;A fair share of academic research and software development focuses on solving ever-larger problems, particularly when it comes to LPs.&lt;/p&gt;&#xA;&lt;p&gt;I am however curious to know in what contexts and to what extent &lt;em&gt;small&lt;/em&gt; LPs are solved in practice.&#xA;Let's say LPs/QPs with at most a few hundred variables &amp;amp; constraints, possibly solved repeatedly with only minor changes between successive solves.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone know of practical examples of interest?&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2021-07-20T03:47:25.077" Title="Are there small LPs out there?" Tags="|linear-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6584" PostTypeId="2" ParentId="6583" CreationDate="2021-07-18T10:09:17.057" Score="3" Body="&lt;p&gt;As batwing mentioned in a comment, optimal control applications, particularly in robotics, aerospace, and now self-driving cars, involve NLPs to be solved quickly. These NLPs are generally solved using a &lt;a href=&quot;https://en.wikipedia.org/wiki/Sequential_quadratic_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sequential Quadratic Programming (SQP)&lt;/a&gt; approach, thus involving series of small-changing QPs to be solved very efficiently. For examples of applications, have a look at this &lt;a href=&quot;https://www.optimal-control.de/index.php/applications&quot; rel=&quot;nofollow noreferrer&quot;&gt;website&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Price_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pricing optimization&lt;/a&gt; (particularly in the airline industry) and &lt;a href=&quot;https://en.wikipedia.org/wiki/Inventory_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;inventory optimization&lt;/a&gt; (essentially in supply chain management) traditionally involve series of small-changing LPs to be solved over time. Nevertheless, the models considered, originally rough approximations of the reality, tend to be larger and larger, richer and richer, mixing discrete and nonlinear features.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-07-18T10:09:17.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6586" PostTypeId="2" ParentId="6563" CreationDate="2021-07-18T13:03:52.503" Score="4" Body="&lt;p&gt;Redefining the solution space is a way to make local search heuristics perform better. This is useful for tightly constrained problems where moving from one feasible solution to another is difficult.&lt;/p&gt;&#xA;&lt;p&gt;Reformulating the problem, in particular redefining the set of decision variables, is a way to proceed. Such reformulations are well known in integer programming. They are called &amp;quot;extended formulations&amp;quot;, thus leading to a considerable (possibly exponential) increase in the number of variables. For example, have a look at the &lt;a href=&quot;https://www.math.u-bordeaux.fr/%7Ersadykov/papers/SadykovVanderbeck_CGEF.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper by Sadykov and Vanderbeck&lt;/a&gt; for an introduction to this method.&lt;/p&gt;&#xA;&lt;p&gt;For example, consider a machine scheduling problem where many complex constraints are defined to rule the way tasks can be performed together on each machine. In such a context, basic local search approaches perform poorly. Indeed, moving from one feasible schedule to another feasible schedule by exploring basic, local neighborhoods (that is, using basic moves and exchanges of tasks) is very hard. In that case, an extended reformulation consists of generating sets of feasible schedules for each machine (possibly heuristically) and then deciding the schedule for each machine (possibly heuristically). The second step can be viewed as solving a set partitioning problem, which can be done by using integer linear programming techniques, but also by using local search methods (moving and exchanging schedules, instead of tasks).&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-07-18T13:03:52.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6587" PostTypeId="1" CreationDate="2021-07-18T16:04:26.977" Score="5" ViewCount="236" Body="&lt;p&gt;What is the main difference between Breadth First Search and Best First Search? What is meant by saying Breadth First Search requires previous knowledge?&lt;/p&gt;&#xA;" OwnerUserId="5884" LastActivityDate="2021-07-19T06:09:19.407" Title="Breadth First Search vs. Best First Search" Tags="|mixed-integer-programming|branch-and-bound|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6588" PostTypeId="2" ParentId="6587" CreationDate="2021-07-19T06:09:19.407" Score="3" Body="&lt;p&gt;In Breadth First Search, nodes are processed by non-decreasing value of their depth, i.e. the next node processed in the unprocessed node with the smallest depth.&lt;/p&gt;&#xA;&lt;p&gt;In Best First Search, a value is assigned to each unprocessed node. The next node processed is the unprocessed node with the smallest value.&#xA;Therefore, Breadth First Search is equivalent to a Best First Search where the value assigned to each node is its depth.&lt;/p&gt;&#xA;&lt;p&gt;From an implementation point of view, Breadth First Search can be implemented with a simple queue while Best First Search will generally require a priority queue.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2021-07-19T06:09:19.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6589" PostTypeId="1" AcceptedAnswerId="6590" CreationDate="2021-07-19T13:22:56.173" Score="4" ViewCount="318" Body="&lt;p&gt;Working on a very large Linear Program, we tried out some primitive implementations of decomposition techniques such as Lagrangian relaxation and column generation. However, none of these were able to only come close to computation times achieved with the Barrier algorithm.&#xA;Thus, we assume that these decomposition approaches only work well on Integer Programs, which is why they are almost solely discussed for IPs in the literature. This would indicate that LPs are &amp;quot;well-solved&amp;quot; with the Simplex algorithms and methods such as Barrier or Interior-point.&#xA;Is there any literature that investigates that point or comes to an equivalent solution?&lt;/p&gt;&#xA;" OwnerUserId="5866" LastEditorUserId="123" LastEditDate="2021-07-21T07:14:17.563" LastActivityDate="2021-07-21T07:14:17.563" Title="Are decomposition methods applicable on large linear programs?" Tags="|linear-programming|lp-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6590" PostTypeId="2" ParentId="6589" CreationDate="2021-07-19T13:48:57.460" Score="4" Body="&lt;p&gt;As a general rule of thumb, I would say that if you have an LP that fits in your memory, then directly applying barrier/simplex is likely to be the best &amp;quot;out-of-the-box&amp;quot; approach.&lt;/p&gt;&#xA;&lt;p&gt;In my experience, decomposition techniques, such as Lagrangean/Benders/Dantzig-Wolfe decomposition, work best (and outperform barrier/simplex) in the following situations (the list is non-exhaustive):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The original LP is too large to fit in the memory. For instance, you have a large two-stage stochastic LP with a lot of scenarios, or your LP is the master problem in a Dantzig-Wolfe decomposition (which often has exponentially many variables).&#xA;In that case, you can't handle the problem without decomposing it.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The problem has a special structure that you know how to exploit. A famous example is the &lt;a href=&quot;https://doi.org/10.1007/s10107-003-0379-5&quot; rel=&quot;nofollow noreferrer&quot;&gt;multi-commodity network flow problem&lt;/a&gt;, where the textbook decomposition yields one min-cost-flow problem per commodity.&#xA;In that case, you can use specialized solvers for the subproblems, which may accelerate the overall method.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I should note here that, if you have a block-structured LP, then you can also apply a barrier or &lt;a href=&quot;https://mlubin.github.io/pdf/pipss.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;simplex algorithm&lt;/a&gt; with specialized, typically distributed, linear algebra. If you want more background, I can refer you to the introduction of &lt;a href=&quot;https://arxiv.org/abs/2006.08814&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; (of which I'm a co-author).&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2021-07-19T13:48:57.460" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6591" PostTypeId="1" CreationDate="2021-07-19T14:38:18.500" Score="4" ViewCount="449" Body="&lt;p&gt;I have concluded there is not, or if there is it's not openly published?&lt;/p&gt;&#xA;&lt;p&gt;I am trying to identify if there are &amp;quot;top solutions/formulations&amp;quot; for the 3d BPP. Looking to apply in a parcel packing context.&lt;/p&gt;&#xA;&lt;p&gt;Update: The problem is parcel packing, given a known set of items, their weights and dimensions, and a fixed set of possible boxes(different sizes allowed). I recognize now this is a narrow interpretation. I'm interested in any solution to this problem(it does not necessarily need to be optimizations, or be formulated in 3d, etc.) I'll consolidate any responses/findings I see posted. Thank you!&lt;/p&gt;&#xA;" OwnerUserId="32" LastEditorUserId="32" LastEditDate="2021-07-20T22:28:14.940" LastActivityDate="2021-07-20T22:28:14.940" Title="Is there a Bin Packing Library similar to TSPLIB?" Tags="|combinatorial-optimization|knapsack|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6592" PostTypeId="2" ParentId="6591" CreationDate="2021-07-19T14:43:30.437" Score="6" Body="&lt;p&gt;BPPLIB – A Bin Packing Problem Library:&#xA;&lt;a href=&quot;http://or.dei.unibo.it/library/bpplib&quot; rel=&quot;noreferrer&quot;&gt;http://or.dei.unibo.it/library/bpplib&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-07-19T14:43:30.437" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6593" PostTypeId="1" CreationDate="2021-07-19T16:02:57.540" Score="2" ViewCount="91" Body="&lt;p&gt;Recently I started using CP and translated my first MIP model into a CP model with the IBM CP Optimizer. Lately I was confronted with a question I could not answer:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;What is the consistency level (e.g. bound consistent or domain consistent) applied to the constraints of the model?&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;My Questions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What exactly is the consistency level of the constraints of the&#xA;model?&lt;/li&gt;&#xA;&lt;li&gt;How can I find out about the consistency level of the&#xA;constraints?&lt;/li&gt;&#xA;&lt;li&gt;For which reason would you want to let the reader know about the consistency level? or: Why would the reader be interested?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3418" LastEditorUserId="491" LastEditDate="2021-11-19T13:20:57.953" LastActivityDate="2021-11-19T13:20:57.953" Title="Consistency Level of Constraints" Tags="|constraint-programming|cp-optimizer|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6595" PostTypeId="2" ParentId="6583" CreationDate="2021-07-20T03:47:25.077" Score="2" Body="&lt;p&gt;Often small LP's are solved as subroutines to solve bigger discrete optimization problems.&lt;/p&gt;&#xA;&lt;p&gt;Example 1: Say you're solving a VRP with time windows and you've a nice heuristic to enumerate good feasible solutions (subgraphs with n-nodes), to figure out an optimal route schedule on the enumerated path, you wanna solve an LP that minimizes the waiting time. This subproblem is an LP with 2n variables&lt;/p&gt;&#xA;&lt;p&gt;Example 2: In several column generation algorithms, the subproblem is often a small LP (a popular case is solving a PM in bipartite graphs) that is solved to generate feasible good quality columns for the master problem in the context.&lt;/p&gt;&#xA;" OwnerUserId="4116" LastActivityDate="2021-07-20T03:47:25.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6596" PostTypeId="2" ParentId="6591" CreationDate="2021-07-20T03:52:28.263" Score="0" Body="&lt;p&gt;If you're looking for a heuristic check &lt;a href=&quot;https://github.com/skjolber/3d-bin-container-packing&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; out. The limitation is that it is written in java.&lt;/p&gt;&#xA;" OwnerUserId="4116" LastActivityDate="2021-07-20T03:52:28.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6597" PostTypeId="2" ParentId="6591" CreationDate="2021-07-20T08:18:36.830" Score="2" Body="&lt;p&gt;For the 2D and 3D variant you can find multiple instances as well as instance generators here:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Oscar-Oliveira/OR-Datasets/tree/master/Cutting-and-Packing&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Oscar-Oliveira/OR-Datasets/tree/master/Cutting-and-Packing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.euro-online.org/websites/esicup/data-sets/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.euro-online.org/websites/esicup/data-sets/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="869" LastEditorUserId="869" LastEditDate="2021-07-20T08:24:20.763" LastActivityDate="2021-07-20T08:24:20.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6598" PostTypeId="1" CreationDate="2021-07-20T08:22:53.683" Score="1" ViewCount="174" Body="&lt;p&gt;I am trying to solve a linear algebra problem: an optimization problem and I am using CVXOPT. I've split the problem into 3 components&lt;/p&gt;&#xA;&lt;p&gt;In its simplest form, The general formulation for CVXOPT is &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\frac12x^\top Px+q^\top x\\\text{s.t.}&amp;amp;\quad Gx\le h\\&amp;amp;\quad Ax=b\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1st problem component&lt;/strong&gt;&#xA;First of all I have to minimize, subject to constraint a very simple problem defined as following&lt;/p&gt;&#xA;&lt;p&gt;P=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   S   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;q=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   0   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   1   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;b=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   1   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;G=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   r   |&#xA;|   -I  |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;b=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   rmin    0   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have coded this and it is working perfectly&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;2nd problem component&lt;/strong&gt;&#xA;The second problem I have is to transform a non convex problem into convex and linear so that the turnover generated by the optimisation problem it is constrained to a max value. In this case I have modelled and coded the problem as following and again all works fine&lt;/p&gt;&#xA;&lt;p&gt;P=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  | S   0   0   |&#xA;  | 0   0   0   |&#xA;  | 0   0   0   |&#xA;  | 0   0   0   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;q=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   -x1 0   0   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   1   0   0   |&#xA;|   I   I   -I  |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;b=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   1   x0  0   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;G=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   0   1   1   |&#xA;|   -I  0   0   |&#xA;|   0   -I  0   |&#xA;|   0   0   -I  |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;h=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   T   0   0   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;3rd problem component&lt;/strong&gt;&#xA;The third problem which I am struggling with (to solve) is to combine the two above. What I have done, which is obviously not correct as it turns to be a singular matrix is doing the following&lt;/p&gt;&#xA;&lt;p&gt;P=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   S   0   0   |&#xA;|   0   0   0   |&#xA;|   0   0   0   |&#xA;|   0   0   0   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;q=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   -x1 0   0   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   1   0   0   |&#xA;|   I   I   -I  |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;b=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   1   x0  0   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;G=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   0   1   1       |&#xA;|   -I  0   0       |&#xA;|   0   -I  0       |&#xA;|   0   0   -I      |&#xA;|   0   0   rmin    |&#xA;|   0   0   -I      |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;h=&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|   T   0   0   rmin    0   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As I think the problem of the singularity comes from G, can anyone help me formulating the third problem in a correct way?&lt;/p&gt;&#xA;" OwnerUserId="3128" LastEditorUserId="491" LastEditDate="2023-01-23T12:55:24.877" LastActivityDate="2023-01-23T12:55:24.877" Title="Optimization Multiple Constraints" Tags="|optimization|linear-programming|python|quadratic-programming|cvxpy|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6599" PostTypeId="2" ParentId="6575" CreationDate="2021-07-20T08:33:32.037" Score="2" Body="&lt;p&gt;You can have a look at chapter 13, namely &amp;quot;Path and flow polyhedra and total unimodularity&amp;quot;, of &lt;a href=&quot;https://homepages.cwi.nl/%7Elex/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Alexander Schrijver&lt;/a&gt;'s masterpiece &amp;quot;Combinatorial Optimization - Polyhedra and Efficiency&amp;quot;. You will find characterizations based on cuts, which are the dual of flows in digraphs. This is linked to the famous &lt;a href=&quot;https://en.wikipedia.org/wiki/Max-flow_min-cut_theorem&quot; rel=&quot;nofollow noreferrer&quot;&gt;max-flow min-cut theorem&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-07-20T08:33:32.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6600" PostTypeId="1" CreationDate="2021-07-20T09:07:46.150" Score="13" ViewCount="1956" Body="&lt;p&gt;There are many great technologies/libraries out there to improve the speed and quality of implementing and deploying OR applications. However in my experience I &amp;quot;stumbled&amp;quot; upon many of them often by accident and they greatly improved the workflow.&lt;/p&gt;&#xA;&lt;p&gt;What are your favourites and why?&lt;/p&gt;&#xA;&lt;p&gt;Some which I found very beneficial:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;version control like git&lt;/li&gt;&#xA;&lt;li&gt;json/xml for writing data to disk&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I am mainly interested in stuff that works with Python. However if it is not applicable feel free to add it too.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="123" LastEditDate="2021-08-19T14:55:24.733" LastActivityDate="2021-08-19T14:55:32.047" Title="What are technologies or libraries which greatly improve the speed or ease of use for delivering of OR software?" Tags="|python|applications|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6601" PostTypeId="2" ParentId="6600" CreationDate="2021-07-20T09:48:54.373" Score="11" Body="&lt;p&gt;I like Stuart Mitchell's (maintainer of &lt;a href=&quot;https://coin-or.github.io/pulp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pulp&lt;/a&gt;) &lt;a href=&quot;http://www.stuartmitchell.com/journal/2012/2/3/my-top-n-tips-for-python-coding-in-optimisation-1.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;tips&lt;/a&gt;, especially tip number 2 : use a profiler to track your bottlenecks. Quoting him:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I can't tell you the number of times I have assumed the slow code was&#xA;for one reason and then found it was another.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I agree with him and use &lt;a href=&quot;https://github.com/rkern/line_profiler&quot; rel=&quot;nofollow noreferrer&quot;&gt;line_profiler&lt;/a&gt; to optimize the code (for Python). I have been able to drastically reduce computation times with this amazing tool many times.&lt;/p&gt;&#xA;&lt;p&gt;Check out &lt;a href=&quot;https://or.stackexchange.com/questions/5485/python-for-or-which-non-solver-libraries-do-you-use&quot;&gt;this post&lt;/a&gt; for some other useful Python libraries.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2021-08-19T14:55:32.047" LastActivityDate="2021-08-19T14:55:32.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6603" PostTypeId="2" ParentId="6600" CreationDate="2021-07-20T11:48:16.430" Score="6" Body="&lt;p&gt;In addition to profiler (mentioned by Kuifje), Python has quite a few unit testing libraries that can be used to test your application (&lt;a href=&quot;https://docs.python.org/3/library/unittest.html&quot; rel=&quot;noreferrer&quot;&gt;unittest&lt;/a&gt; and &lt;a href=&quot;https://docs.pytest.org/en/6.2.x/&quot; rel=&quot;noreferrer&quot;&gt;pytest&lt;/a&gt; are both common).&lt;/p&gt;&#xA;&lt;p&gt;As in any commercial application, real-world OR applications should be flexible, maintainable and modularized. It is common to change some modelling objects (variables, constraints, etc), the way they are constructed, the way your algorithm gets data, etc (as a result of customer requests, addition of new features or product improvement in general). It is important that your changes do not break other parts of the code such as your solution representation or even the correctness of your algorithm. That's where unit testing plays an important role.&lt;/p&gt;&#xA;&lt;p&gt;Your unit test in an OR application could include small problem instances that are different in some way (become infeasible in some case, become unbounded in some case, produce an expected solution in some case, etc). If your tests fail, you will find the cause of the issue a lot easier compared to the case with no unit testing.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2021-07-20T11:48:16.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6604" PostTypeId="2" ParentId="6600" CreationDate="2021-07-20T15:46:59.877" Score="4" Body="&lt;p&gt;I'll start with the lowest hanging fruit in the orchard: an IDE (with a good built-in debugger), to facilitate code development.&lt;/p&gt;&#xA;&lt;p&gt;Regarding reading/writing &amp;quot;data&amp;quot;, I use XML libraries to save and retrieve things like the parameter settings used in runs. For applications where either the input date is complicated or I'm running multiple instances with the intent of doing some statistical analysis of the run times, results etc., I prefer to use an open source SQL database to input model parameters and save model results. (I've been using SQLite in recent years, but previously had good luck with MySQL.)&lt;/p&gt;&#xA;&lt;p&gt;For inhaling data / model parameters from an outside source, it's useful to have an open source library that reads (and possibly writes) CSV and XLSX files. Again, depending on the nature of the work, I might prefer to turn the input files into an SQLite database and work with that.&lt;/p&gt;&#xA;&lt;p&gt;In many cases, I want my application to have a GUI. I work mainly with Java, so I typically use Swing, but in other cases a browser-based user interface may be best. (For instance, for R applications I will unsurprisingly use Shiny.)&lt;/p&gt;&#xA;&lt;p&gt;I don't have a lot of experience with deployment (since I don't tend to do anything useful), but for those who do need to worry about it, another technology that may be helpful is containers (such as Docker).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-20T15:46:59.877" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6605" PostTypeId="1" CreationDate="2021-07-20T18:36:37.987" Score="10" ViewCount="322" Body="&lt;p&gt;What are examples of industries or applications, which would greatly benefit from using OR, but it is not standard or common to use these technologies there?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2021-08-24T05:42:04.050" Title="What industries and applications are chronically underoptimized?" Tags="|optimization|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6606" PostTypeId="1" AcceptedAnswerId="6626" CreationDate="2021-07-20T19:37:15.443" Score="3" ViewCount="420" Body="&lt;p&gt;I am working with integer optimization. I have a problem with &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; tasks and every task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; needs &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; weeks to be completed and &lt;span class=&quot;math-container&quot;&gt;$p_{il}$&lt;/span&gt; workers on a specific week &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;. There is a total time in weeks to complete all tasks. I need to optimize (min) the max value of workers needed in any week (variables to define: starting week for every particular task, or similar). Weeks needed per task and amount of workers in each week are given as data points.&lt;/p&gt;&#xA;&lt;p&gt;There is also a constraint: once a task starts, it should be finished (can't be paused). All tasks could run in parallel if needed.&lt;/p&gt;&#xA;&lt;p&gt;How can I model this optimization problem formally?&lt;/p&gt;&#xA;" OwnerUserId="5893" LastEditorUserId="5893" LastEditDate="2021-07-21T10:12:29.883" LastActivityDate="2021-07-25T16:46:36.000" Title="Scheduling minimization Integer Programming problem formulation" Tags="|optimization|mixed-integer-programming|integer-programming|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="6607" PostTypeId="1" CreationDate="2021-07-20T20:24:31.933" Score="2" ViewCount="253" Body="&lt;p&gt;I am solving an LP (i.e 118-bus system economic dispatch for 130% loading) using Benders decomposition. The problem takes 26 iterations to converge. This means that the process adds 25 cuts to the master problem till convergence. Then I saved those 25 cuts.&lt;/p&gt;&#xA;&lt;p&gt;In the next step, I want to rerun the benders process. For the purpose of an experiment, I added the first 15 cuts (out of those 25 saved cuts) to the master problem before the first iteration. Intuitively, the problem should now converge within 11 iterations (or after generating and adding 10 cuts).&lt;/p&gt;&#xA;&lt;p&gt;However, this time the benders process does not converge within 11 iterations rather it takes 21 iterations. Why is it taking 10 (=21-11) extra iterations to solve the problem?&lt;/p&gt;&#xA;&lt;p&gt;I am using Yalmip(matlab) with cplex solver(1210).&lt;/p&gt;&#xA;" OwnerUserId="5891" LastEditorUserId="123" LastEditDate="2021-07-29T07:49:45.707" LastActivityDate="2021-07-29T07:49:45.707" Title="Benders decompositions: Number of iterations does not remain the same" Tags="|linear-programming|cplex|benders-decomposition|yalmip|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6608" PostTypeId="2" ParentId="6607" CreationDate="2021-07-20T21:29:28.903" Score="2" Body="&lt;p&gt;When you add any number of the original cuts (presumably as constraints, rather than lazy constraints or user cuts) and then restart the solver, CPLEX will go through a presolve step, the results of which may be different from the original presolve due to the presence of the extra constraints. &lt;strike&gt;It will then solve the root LP, the solution to which will likely be different from the solution to the original root LP, and so on.&lt;/p&gt;&#xA;&lt;p&gt;So the branch-and-bound tree in the second run may well be significantly different from the tree in the first run. That can lead to CPLEX encountering different &amp;quot;feasible&amp;quot; solutions along the way, leading to different Benders cuts. Whether the second run reaches optimality with more, fewer or the same number of cuts as the number of unused cuts from the first run is largely a matter of luck.&lt;/strike&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Oops! I thought the master problem was a MIP, when it was clearly stated to be an LP.&lt;/p&gt;&#xA;&lt;p&gt;The master problem in the second approach will be different from that of the first even if presolve makes no changes in either of them. If CPLEX starts the second master at a different vertex from the vertex at which the 15th cut was found, it may lead to a different master solution, triggering a different cut, and so on. It might be interesting to record the master problem basis after the 15th cut is added and the master is solved again in the first approach, add the first 15 cuts, then start again using the recorded basis as the starting solution to the LP. I'm still not sure that would generate the same sequence of cuts (partly due to presolving, partly due to random tie-breaking whenever there is a tie for the best column to enter into the basis), but perhaps it would.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-07-21T21:00:45.710" LastActivityDate="2021-07-21T21:00:45.710" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6609" PostTypeId="2" ParentId="6600" CreationDate="2021-07-20T22:10:10.570" Score="8" Body="&lt;p&gt;One useful package that I've been using for optimization modeling is &lt;a href=&quot;https://pypi.org/project/ticdat/&quot; rel=&quot;noreferrer&quot;&gt;ticdat&lt;/a&gt;, which is great for validating the input data and performing sanity and integrity checks. Because the data we receive in applications are almost never clean and a lot needs to be written to ensure they are correctly handled by either throwing an error or fixing what needs to be fixed (e.g., assigning a default value when a value is null in a certain column of a certain table).&lt;/p&gt;&#xA;&lt;p&gt;I found out that Gurobi recently added an example on how to use ticdat (&lt;a href=&quot;https://github.com/Gurobi/modeling-examples/blob/8c2830098c21e17faf8b2a225961a8ef0f394cc2/diet.py&quot; rel=&quot;noreferrer&quot;&gt;diet example&lt;/a&gt;) in their library of beginner models.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2021-07-20T22:10:10.570" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6610" PostTypeId="1" AcceptedAnswerId="6611" CreationDate="2021-07-21T13:06:29.310" Score="4" ViewCount="177" Body="&lt;p&gt;I have &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; parameters &lt;span class=&quot;math-container&quot;&gt;$a_1,a_2,a_3$&lt;/span&gt; and a variable &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; binary variables &lt;span class=&quot;math-container&quot;&gt;$b_1,b_2,b_3$&lt;/span&gt; and a &amp;quot;result&amp;quot; variable &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;. How do I model constraints so that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is between &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$s=1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is between &lt;span class=&quot;math-container&quot;&gt;$a_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_2$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$s =$&lt;/span&gt; ... complex calculation ...&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is between &lt;span class=&quot;math-container&quot;&gt;$a_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_3$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$s = 0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I have found a formulation that is as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;a_1b_1 + a_2b_2 - d \le 0 \\&#xA;-a_1b_1 - a_2b_2 - a_3b_3 + d \le 0 \\&#xA;b_1 + b_2 + b_3 = 1&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But if use this formulation in my model, the b-variables get calculated incorrectly. Does anyone see the reason why and/or has a better idea?&lt;/p&gt;&#xA;" OwnerUserId="5896" LastEditorUserId="491" LastEditDate="2021-07-22T18:03:53.330" LastActivityDate="2021-07-22T18:03:53.330" Title="How do I formulate constraints that check if a parameter is between certain values, using binary variables?" Tags="|mixed-integer-programming|modeling|constraint|constraint-programming|quadratic-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6611" PostTypeId="2" ParentId="6610" CreationDate="2021-07-21T14:09:58.720" Score="4" Body="&lt;p&gt;It looks like your first constraint should instead be&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0b_1 + a_1 b_2 + a_2 b_3 - d \le 0$$&lt;/span&gt;&#xA;With this change, the logical implications are&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;b_1 = 1 &amp;amp;\implies   0 \le d \le a_1 \\&#xA;b_2 = 1 &amp;amp;\implies a_1 \le d \le a_2 \\&#xA;b_3 = 1 &amp;amp;\implies a_2 \le d \le a_3&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To avoid ambiguous borders, introduce a small tolerance &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt; and impose instead&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0 b_1 + (a_1+\epsilon) b_2 + (a_2+\epsilon) b_3 - d \le 0$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-07-21T16:15:28.877" LastActivityDate="2021-07-21T16:15:28.877" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6612" PostTypeId="1" AcceptedAnswerId="6613" CreationDate="2021-07-22T08:09:17.150" Score="1" ViewCount="224" Body="&lt;p&gt;How do I do the change from an Eulerian tour to a Hamiltonian cycle in the Christofides algorithm? In the original paper from &lt;a href=&quot;https://apps.dtic.mil/sti/pdfs/ADA025602.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Christofides (1976)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; I found that&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A Hamiltonian circuit &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; can be found with cost &lt;span class=&quot;math-container&quot;&gt;$$C(i_H) \le C(T^*) + C(M_0^*)&amp;lt;\frac32C(i^*)$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$C(i^*)$&lt;/span&gt; is the optimal value of the TSP tour &lt;span class=&quot;math-container&quot;&gt;$i^*$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;On cs.stackexchange.com I found &lt;a href=&quot;https://cs.stackexchange.com/questions/9923/a-good-resource-for-christofides-heuristic&quot;&gt;this answer&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;However, we wanted a Hamilton cycle (another name for a TSP tour). The idea now is to follow the Eulerian tour. Whenever we're supposed to visit a vertex we have already encountered, we just &amp;quot;skip&amp;quot; this edge. Eventually the tour will reach a new vertex, and then we just connect the previous vertex with the new one.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Are there not more than one possible Hamiltonian cycle in one Eulerian tour? Is it good enough to take just some Hamiltonian cycle? Does this already satisfy the upper bound of &lt;span class=&quot;math-container&quot;&gt;$3/2$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Christofides, N. (1976). Worst-case analysis of a new heuristic for the travelling salesman problem. Carnegie-Mellon Univ Pittsburgh Pa Management Sciences Research Group. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="5571" LastEditorUserId="123" LastEditDate="2021-07-29T07:47:23.890" LastActivityDate="2021-07-29T07:47:23.890" Title="Christofides algorithm, transform from Eulerian tour to Hamiltonian cycle" Tags="|algorithms|traveling-salesman|heuristics|approximation-algorithms|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6613" PostTypeId="2" ParentId="6612" CreationDate="2021-07-22T14:33:35.443" Score="4" Body="&lt;p&gt;The weight sum of all edges in the Eulerian tour created in Christofides algorithm is already at most &lt;span class=&quot;math-container&quot;&gt;$3/2$&lt;/span&gt; times the weight sum of a TSP tour. While there are multiple ways of shortcutting the Eulerian tour into a Hamiltonian cycle, note that by the triangle inequality, any shortcut edge has a weight that is less than the total weight of the edges in the Eulerian tour it replaces. So, any Hamiltonian cycle created by shortcutting the Eulerian tour yields a &lt;span class=&quot;math-container&quot;&gt;$3/2$&lt;/span&gt;-approximate solution.&lt;/p&gt;&#xA;" OwnerUserId="232" LastActivityDate="2021-07-22T14:33:35.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6614" PostTypeId="1" CreationDate="2021-07-22T20:50:17.543" Score="2" ViewCount="94" Body="&lt;p&gt;I have an application where I want to monitor the variables over time. I declare all the variables in my model like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x = model.addVars(np.size(distances, axis = 0), np.size(distances, axis=1), lb=0.0,ub=1.0, name=&amp;quot;x&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I set the following parameters:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.Params.IterationLimit = 1.&#xA;model.Params.Method = 0&#xA;model.Params.Presolve = 0&#xA;model.Params.Sifting = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is what gets written to model when I perform &lt;code&gt;model.optimize&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Changed value of parameter IterationLimit to 1.0&#xA;   Prev: inf  Min: 0.0  Max: inf  Default: inf&#xA;Parameter Method unchanged&#xA;   Value: 0  Min: -1  Max: 5  Default: -1&#xA;Parameter Presolve unchanged&#xA;   Value: 0  Min: -1  Max: 2  Default: -1&#xA;Changed value of parameter Sifting to 0&#xA;   Prev: -1  Min: -1  Max: 2  Default: -1&#xA;Gurobi Optimizer version 9.0.1 build v9.0.1rc0 (win64)&#xA;Optimize a model with 35 rows, 125 columns and 375 nonzeros&#xA;Coefficient statistics:&#xA;  Matrix range     [1e+00, 1e+00]&#xA;  Objective range  [1e+01, 2e+02]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [1e+00, 6e+00]&#xA;Iteration    Objective       Primal Inf.    Dual Inf.      Time&#xA;       0    2.6665428e+03   2.000000e+00   5.000035e+07      0s&#xA;&#xA;Stopped in 1 iterations and 0.01 seconds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However when reaching my iteration limit and retrieve the variables I get the following vector:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;[0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,&#xA; 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, -1.0, 0.0, 0.0,&#xA; 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,&#xA; 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,&#xA; 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,&#xA; 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,&#xA; 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,&#xA; 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 1.0, 0.0,&#xA; 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,&#xA; 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The problem is the -1 and 2 which violate my bounds.&lt;/p&gt;&#xA;&lt;p&gt;Is there something I need to do when my IterationLimit is reached to clean up where my gurobi model currently stopped to get a variable vector that is observing my upper and lower bounds?&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, I do have a feasible cbasis and vbasis that I am using as a starting point for this problem and the params specify that I am forcing the primal simplex method. Presolver is also turned off.&lt;/p&gt;&#xA;&lt;p&gt;The problem is that I start in the feasible region and then I leave the feasible region in this iteration.&lt;/p&gt;&#xA;&lt;p&gt;(Edit: added sentence at the end to clarify why this vector being infeasible is so confusing)&lt;/p&gt;&#xA;" OwnerUserId="5906" LastEditorUserId="123" LastEditDate="2021-07-29T07:42:02.787" LastActivityDate="2021-07-29T07:42:02.787" Title="Variable vector violates upper and lower bounds when I hit iteration limit" Tags="|python|gurobi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6615" PostTypeId="2" ParentId="6614" CreationDate="2021-07-22T21:11:05.693" Score="4" Body="&lt;p&gt;If you look at the output log, you'll see a primal infeasibility value of 2.0 (which is the sum of the absolute values of the violations in the two values you noted). That just means it will take more than one iteration to find an initial feasible solution. In other words, your iteration limit is too small.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-22T21:11:05.693" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6617" PostTypeId="1" CreationDate="2021-07-24T14:51:44.447" Score="7" ViewCount="400" Body="&lt;p&gt;&lt;strong&gt;Inverse Ising Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The inverse ising problem means fitting the coupling &lt;span class=&quot;math-container&quot;&gt;$J_{ij}$&lt;/span&gt; and field &lt;span class=&quot;math-container&quot;&gt;$h_{i}$&lt;/span&gt; parameters given a sample of configurations of spins.&lt;/p&gt;&#xA;&lt;p&gt;Each spin &lt;span class=&quot;math-container&quot;&gt;$s_{i}$&lt;/span&gt; is either +1 or -1. The Hamiltonian of one configuration of spins &lt;span class=&quot;math-container&quot;&gt;$\vec{s}$&lt;/span&gt; is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ H(\vec{s}, \mathcal{J}, \mathcal{h}) = \sum_{i} h_{i} s_{i} + \sum_{i \ne j}J_{ij} s_{i}s_{j} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The probability of the configuration of spins &lt;span class=&quot;math-container&quot;&gt;$\vec{s}$&lt;/span&gt; is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;P(\vec{s}, \mathcal{J}, \mathcal{h}) = \frac{1}{Z(\mathcal{J}, \mathcal{h})} \exp \left [ H(\vec{s}, \mathcal{J}, \mathcal{h}) \right]&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the partition function is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Z(\mathcal{J}, \mathcal{h}) = \sum_{\vec{r}} \exp \left [ H(\vec{r}, \mathcal{J}, \mathcal{h}) \right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The summation is over all possible configurations.&lt;/p&gt;&#xA;&lt;p&gt;Fitting the parameters means maximizing the log-likelihood of the sample.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.lps.ens.fr/%7Ekrzakala/Seminars_GOLOSINO/Ricci2014.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;This PDF&lt;/a&gt; contains some slides for inverse Ising problem.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;There is a link between the Ising model and &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_unconstrained_binary_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;quadratic unconstrained binary optimization (QUBO)&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Can QUBO solve inverse Ising problem?&lt;/p&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="727" LastEditDate="2023-11-24T15:29:25.127" LastActivityDate="2023-11-24T15:29:25.127" Title="Can QUBO solve this inverse Ising problem?" Tags="|optimization|modeling|quadratic-programming|unconstrained-optimization|qubo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6618" PostTypeId="1" AcceptedAnswerId="6619" CreationDate="2021-07-24T17:45:07.440" Score="2" ViewCount="576" Body="&lt;p&gt;I have successfully implemented a program where I allocate &lt;strong&gt;N&lt;/strong&gt; &lt;code&gt;truck drivers&lt;/code&gt; to &lt;strong&gt;M&lt;/strong&gt; &lt;code&gt;gathering hubs&lt;/code&gt; for each one of the days of the week. The constraints I have implemented are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A driver cannot work more than 6 days, i.e. 1 day to rest&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A driver cannot be allocated in more than 1 hubs for each day&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each hub must satisfy its driver requirements for each day of the week&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A driver must work his days at one hub instead of many.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The program runs smoothly, satisfies the overall objective and outputs a schedule for each hub-driver pair.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;However,&lt;/strong&gt; the &lt;strong&gt;extra constraint&lt;/strong&gt; that forces the drivers to work at one hub (constraint 4), instead of their working days being split into many hubs, is violated and assigns some drivers to many hubs.&lt;/p&gt;&#xA;&lt;p&gt;How can that be fixed?&lt;/p&gt;&#xA;&lt;p&gt;Please find my code below.&lt;/p&gt;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import pulp&#xA;import pandas as pd&#xA;import numpy as np&#xA;&#xA;day_requirement = [[3, 4, 3, 4, 5, 3, 3],&#xA;             [3, 4, 4, 3, 4, 5, 5],&#xA;             [1, 1, 1, 1, 1, 1, 1],&#xA;             [2, 2, 2, 2, 2, 2, 2],&#xA;             [2, 4, 3, 2, 2, 2, 2],&#xA;             [6, 5, 3, 3, 3, 5, 4],&#xA;             [2, 3, 2, 2, 2, 1, 2]]&#xA;&#xA;total_day_requirements = ([sum(x) for x in zip(*day_requirement)])&#xA;&#xA;hub_names = {0: 'Hub 1',&#xA;             1: 'Hub 2',&#xA;             2: 'Hub 3',&#xA;             3: 'Hub 4',&#xA;             4: 'Hub 5',&#xA;             5: 'Hub 6',&#xA;             6: 'Hub 7'}&#xA;&#xA;total_drivers = max(total_day_requirements)  # number of drivers&#xA;total_hubs = len(day_requirement)  # number of hubs&#xA;&#xA;days = 7&#xA;&#xA;def schedule(drivers, hubs, day_requirement):&#xA;    # driver_names = ilm_riders['riders']&#xA;    driver_names = ['Driver_{}'.format(i) for i in range(drivers)]&#xA;    var = pulp.LpVariable.dicts('VAR', (range(hubs), range(drivers), range(days)), 0, 1, 'Binary')&#xA;    problem = pulp.LpProblem('shift', pulp.LpMinimize)&#xA;&#xA;    obj = None&#xA;    for h in range(hubs):&#xA;        for driver in range(drivers):&#xA;            for day in range(days):&#xA;                obj += var[h][driver][day]&#xA;    problem += obj&#xA;&#xA;    #  we add binary variables z indicating if a driver is active on a hub:&#xA;    z = pulp.LpVariable.dicts('Z', (range(hubs), range(drivers)), 0, 1, 'Binary')&#xA;    # minimize the sum of drivers active on hubs&#xA;    for h in range(hubs):&#xA;        for driver in range(drivers):&#xA;            obj += z[h][driver]&#xA;    problem += obj&#xA;&#xA;    # Add constraints to connect z with VAR:&#xA;    for driver in range(drivers):&#xA;        for h in range(hubs):&#xA;            problem += z[h][driver] &amp;lt;= pulp.lpSum(var[h][driver][day] for day in range(days))&#xA;            problem += days * z[h][driver] &amp;gt;= pulp.lpSum(var[h][driver][day] for day in range(days))&#xA;&#xA;    # if a driver works one day at a hub, he cannot work that day in a different hub obviously&#xA;    for driver in range(drivers):&#xA;        for day in range(days):&#xA;            problem += pulp.lpSum([var[h][driver][day] for h in range(hubs)]) &amp;lt;= 1&#xA;&#xA;    # schedule must satisfy daily requirements of each hub&#xA;    for day in range(days):&#xA;        for h in range(hubs):&#xA;            problem += pulp.lpSum(var[h][driver][day] for driver in range(drivers)) == \&#xA;                       day_requirement[h][day]&#xA;&#xA;    # a driver cannot work more than 6 days&#xA;    for driver in range(drivers):&#xA;        problem += pulp.lpSum([var[h][driver][day] for day in range(days) for h in range(hubs)]) \&#xA;                   &amp;lt;= 6&#xA;&#xA;    # for driver in range(drivers):&#xA;    #     problem += pulp.lpSum([var[h][driver][day] for day in range(days) for h in range(hubs)]) &amp;gt;= 5&#xA;&#xA;    # Solve problem. We have a very complex solution so we set a timeout at 10secs.&#xA;    status = problem.solve(pulp.PULP_CBC_CMD(msg=False, timeLimit=10))&#xA;&#xA;    idx = pd.MultiIndex.from_product([hub_names.values(), driver_names], names=['Hub', 'Driver'])&#xA;&#xA;    col = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']&#xA;    # col = ['Day_{}'.format(i) for i in range(days)]&#xA;    dashboard = pd.DataFrame(0, idx, col)&#xA;&#xA;    for h in range(hubs):&#xA;        for driver in range(drivers):&#xA;            for day in range(days):&#xA;                if var[h][driver][day].value() &amp;gt; 0.0:&#xA;                    dashboard.loc[hub_names[h], driver_names[driver]][col[day]] = 1&#xA;&#xA;    # print(dashboard)&#xA;&#xA;    driver_table = dashboard.groupby('Driver').sum()&#xA;    driver_sums = driver_table.sum(axis=1)&#xA;    # print(driver_sums)&#xA;&#xA;    day_sums = driver_table.sum(axis=0)&#xA;    # print(day_sums)&#xA;&#xA;    print(&amp;quot;Status&amp;quot;, pulp.LpStatus[status])&#xA;    return driver_sums, dashboard, status&#xA;&#xA;&#xA;driver_sums, dashboard, status = schedule(total_drivers, total_hubs, day_reqs)&#xA;while (driver_sums &amp;gt; 6).any() or status == -1:&#xA;    print('Staus infeasible OR one or more drivers have been allocated more than 6 days of work so '&#xA;          'we must add one '&#xA;          'driver: {}-&amp;gt;{}'.format(total_drivers, total_drivers + 1))&#xA;    total_drivers += 1&#xA;    driver_sums, dashboard, status = schedule(total_drivers, total_hubs, day_reqs)&#xA;&#xA;&#xA;# dashboard = schedule(total_drivers, total_hubs, day_reqs)&#xA;driver_table = dashboard.groupby('Driver').sum()&#xA;driver_sums = driver_table.sum(axis=1)&#xA;# print(driver_sums)&#xA;day_sums = driver_table.sum(axis=0)&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5220" LastEditorUserId="36" LastEditDate="2021-07-24T19:03:49.817" LastActivityDate="2021-07-24T19:03:49.817" Title="Violation of specific constraint in Pulp" Tags="|optimization|modeling|python|pulp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6619" PostTypeId="2" ParentId="6618" CreationDate="2021-07-24T18:13:45.707" Score="4" Body="&lt;p&gt;Introduce linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{\text{h}} z[\text{h}][\text{driver}] \le 1 \quad\text{for each driver}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-07-24T18:13:45.707" CommentCount="18" ContentLicense="CC BY-SA 4.0" />
  <row Id="6620" PostTypeId="2" ParentId="6617" CreationDate="2021-07-24T22:32:36.910" Score="5" Body="&#xA;&lt;p&gt;Yes it is possible, but it may not be as efficient as the other methods listed in that PDF file. In fact, I'm still not sure there's any problem for which QUBO is the best way to solve it (see this: &lt;a href=&quot;https://or.stackexchange.com/q/828/727&quot;&gt;What are some real-world applications of QUBO?&lt;/a&gt;, and if interested in this area you may also find this one interesting: &lt;a href=&quot;https://or.stackexchange.com/q/1380/727&quot;&gt;Are there any real-world problems where quadratization helps to solve something that couldn&amp;#39;t have been solved without quadratization?&lt;/a&gt;). I'll also say that there's currently an open bounty worth up to 300 points on this question: &lt;a href=&quot;https://mattermodeling.stackexchange.com/q/136/5&quot;&gt;Where/when did the fields of Operations Research and Spin Physics or Molecular Dynamics begin to cross-pollinate?&lt;/a&gt;.&#xA;Now for my answer to your question:&lt;/p&gt;&#xA;&lt;h3 id=&quot;lets-start-with-a-simpler-case-fwqb&quot;&gt;Let's start with a simpler case:&lt;/h3&gt;&#xA;&lt;p&gt;Say we have the energy &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;,  for the spin Hamiltonian &lt;span class=&quot;math-container&quot;&gt;$H = Js_1s_2 + hs_1$&lt;/span&gt; at the configuration &lt;span class=&quot;math-container&quot;&gt;$(s_1,s_2) = (1,1)$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\tag{1}&#xA;E = Js_1s_2 + hs_1.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This implies:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{2}&#xA;E - Js_1s_2 - hs_1 = 0.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now the following miniminization is equivalent to solving for the unknowns &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; in Eq. 2:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{3}&#xA;\min_{J,h}\left( E - Js_1s_2 - hs_1 \right)^2,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;because the function we're minimizing is a &lt;em&gt;square&lt;/em&gt; of a &lt;em&gt;real&lt;/em&gt; number, so it cannot be negative, and therefore the minimum cannot be less than 0, and since we know that Eq. 1 is true, we know that the function can be 0 (so the minimum is 0).&lt;/p&gt;&#xA;&lt;p&gt;Now if we represent &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; in binary, we get:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\tag{4}&#xA;J &amp;amp;= J_02^0 + J_12^1 + J_2 2^2 + J_32^3 + \ldots + J_N2^N\\\tag{5}&#xA;h &amp;amp;= h_02^0 + h_12^1 + h_2 2^2 + h_32^3 + \ldots + h_N2^N,&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\left(J_0,J_1,J_2,J_3,\ldots J_N,h_0,h_1,h_2,h_3,\ldots,h_N\right)$&lt;/span&gt; are all either 0 or 1, and then we use:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{6}&#xA;s_i = 2b_i - 1,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; are the &lt;em&gt;binary&lt;/em&gt; variables such as &lt;span class=&quot;math-container&quot;&gt;$J_i$&lt;/span&gt; and/or &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt;, then we have Eqs. 4-5 in terms of &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; variables (-1,1 rather than 0,1), &lt;em&gt;&lt;strong&gt;and Eq. 3 is then in QUBO form!&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;If we had more than one energy, such as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\tag{7}&#xA;E_1 = Js_1s_2 + hs_1, (s_1,s_2)=(1,1)\\\tag{8}&#xA;E_2 = Js_1s_2 + hs_1, (s_1,s_2)=(1,0),&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;then instead of Eq. 3 we can have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{9}&#xA;\min_{J,h}\left( \left(E_1 - J(1)(1) - h(1) \right)^2  + \left( E_2 - J(1)(0) - h(1)\right)^2\right).&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is how myself and others have converted the problem of factoring numbers into QUBO: see Eqs 10 and 11 of &lt;a href=&quot;https://arxiv.org/abs/1411.6758&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Quantum factorization of 56153 with only 4 qubits&amp;quot;&lt;/a&gt; and how they are formed from Eqs 7-9 of that paper.&lt;/p&gt;&#xA;&lt;h3 id=&quot;now-for-the-inverse-ising-problem-defined-in-the-pdf-you-gave-27zy&quot;&gt;Now for the &amp;quot;inverse Ising problem&amp;quot; defined in the PDF you gave:&lt;/h3&gt;&#xA;&lt;p&gt;Instead of Eq. 1 we have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{10}&#xA;P = \frac{e^{\left(Js_1s_2 + hs_1\right)}}{\sum_{s_1,s_2} e^{\left(Js_1s_2 + hs_1\right)}},&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and the same techniques can be used to form the QUBO problem again. If you need more assistance on that, then I suggest you ask another question on how to exponentiate binary variables in QUBO-type problems, since it's a mathematical technique that would be a bit of a tangent to the main thrust of this answer, but would need even more space to explain. It's a bit more complicated than doing the exponential in the case where no actual &lt;em&gt;variables&lt;/em&gt; have to be exponentiated, as in the other question you asked here: &lt;a href=&quot;https://or.stackexchange.com/q/6621/727&quot;&gt;How to exponentiate binary variables in QUBO-type problems?&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="727" LastEditorUserId="727" LastEditDate="2021-07-25T03:11:14.480" LastActivityDate="2021-07-25T03:11:14.480" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6621" PostTypeId="1" CreationDate="2021-07-24T22:52:47.073" Score="3" ViewCount="157" Body="&lt;p&gt;&lt;strong&gt;Ising Model&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In an Ising model, the Hamiltonian of one configuration of spins &lt;span class=&quot;math-container&quot;&gt;$\vec{s}$&lt;/span&gt; is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ H(\vec{s}, \mathcal{J}, \mathcal{h}) = \sum_{i} h_{i} s_{i} + \sum_{i \ne j}J_{ij} s_{i}s_{j} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where each spin &lt;span class=&quot;math-container&quot;&gt;$s_{i} = \pm 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The partition function of an Ising model is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Z(\mathcal{J}, \mathcal{h}) = \sum_{\vec{r}} \exp \left [ H(\vec{r}, \mathcal{J}, \mathcal{h}) \right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The summation is over all possible configurations and &lt;span class=&quot;math-container&quot;&gt;$r_{i} = \pm 1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;How to formulate the exponential of binary variables in the partition function for QUBO-type problems?&lt;/p&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="727" LastEditDate="2021-07-24T23:16:55.753" LastActivityDate="2021-07-24T23:16:55.753" Title="How to exponentiate binary variables in QUBO-type problems?" Tags="|optimization|modeling|quadratic-programming|unconstrained-optimization|qubo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6622" PostTypeId="2" ParentId="6621" CreationDate="2021-07-24T23:10:38.690" Score="2" Body="&lt;p&gt;Luckily in this case, the exponential can be treated in a way very similar to how we're already familiar. If we use the example that I chose in &lt;a href=&quot;https://or.stackexchange.com/a/6620/727&quot;&gt;my answer to your recent question&lt;/a&gt;, we would have, where your &lt;span class=&quot;math-container&quot;&gt;$\vec{r}$&lt;/span&gt; is just &lt;span class=&quot;math-container&quot;&gt;$(s_1,s_2)$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\tag{1}&#xA;Z=\sum_{s_1,s_2} e^{\left(\mathcal{J}s_1s_2 + hs_1\right)}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}=2.5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h=3$&lt;/span&gt;, then we would have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\tag{2}&#xA;\hspace{-15mm}Z &amp;amp;\hspace{-5mm}= e^{\left(2.5(-1)(-1) + 3(-1)\right)} + e^{\left(2.5(1)(-1) + 3(1)\right)} + e^{\left(2.5(-1)(1) + 3(-1)\right)} + e^{\left(2.5(1)(1) + 3(1)\right)} \!\!\! \\&#xA;\tag{3} &amp;amp;\hspace{-5mm}=e^{2.5-3}+e^{-2.5+3}+e^{-2.5-3} + e^{2.5+3}\\\tag{4}&#xA;&amp;amp;\hspace{-5mm}=246.951.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A more challenging, but separate, question would be how to keep something like Eq. 10 from that answer linked above, in QUBO format when we are exponentiating binary &lt;em&gt;variables&lt;/em&gt; such as when &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; are not known constants but are instead written using several binary variables.&lt;/p&gt;&#xA;" OwnerUserId="727" LastActivityDate="2021-07-24T23:10:38.690" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6623" PostTypeId="5" CreationDate="2021-07-24T23:16:35.053" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2021-07-24T23:16:35.053" LastActivityDate="2021-07-24T23:16:35.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6624" PostTypeId="4" CreationDate="2021-07-24T23:16:35.053" Score="0" Body="For questions about QUBO (quadratic unconstrained binary optimization)." OwnerUserId="727" LastEditorUserId="123" LastEditDate="2021-07-25T08:17:51.283" LastActivityDate="2021-07-25T08:17:51.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6625" PostTypeId="1" CreationDate="2021-07-25T08:16:32.400" Score="2" ViewCount="142" Body="&lt;p&gt;I'm working on Bus Driver Schedule with multiple add-on constraints that are complex and hence trying to figure out how this can be achieved.&lt;/p&gt;&#xA;&lt;p&gt;Reference of Bus Driver Scheduling using OR-Tools:-&#xA;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/notebook/examples/bus_driver_scheduling_sat.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/examples/notebook/examples/bus_driver_scheduling_sat.ipynb&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I'm having more than one depot and more than one office where a driver can take break. A depot and nearest Crew Office are considered&#xA;as one Region.&lt;/li&gt;&#xA;&lt;li&gt;Now coming to constraints: the driver can only take a break at Crew&#xA;Office (any) and start next no_break_driving from same Crew Office only.&lt;/li&gt;&#xA;&lt;li&gt;Driver needs to Sign/On and Sign/Off in the same Region, he can pick bus from Depot and off his duty at Crew Office but they should fall under the same Region.&lt;/li&gt;&#xA;&lt;li&gt;No breaks are required between shifts as we already have included boarding times in shifts.&lt;/li&gt;&#xA;&lt;li&gt;Breaks are not fixed, after no_break_driving Driver can be given a meal break of one hour or a tea break of half an hour. However, one meal break is necessary.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So shift looks like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[0, '05:18', '06:00','Depot','Region1', 318, 360, 42]&#xA;[1, '05:20', '05:55','Crew Office','Region1', 320, 355, 35]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5918" LastEditorUserId="5968" LastEditDate="2021-07-30T07:39:01.973" LastActivityDate="2021-07-30T07:39:01.973" Title="Multiple Depot/Crew Office Bus Driver Scheduling Modelling" Tags="|optimization|python|scheduling|constraint-programming|or-tools|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6626" PostTypeId="2" ParentId="6606" CreationDate="2021-07-25T16:46:36.000" Score="5" Body="&lt;p&gt;Well, you did not define and detail well the problem, hence, I will first write formally the problem definition based on my understanding of what you have written, and then I will propose an Integer Programming formulation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem definition&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let's first define formally the problem.&#xA;Let:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; be the number of tasks to be serviced;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T = \mathbb{N}_{\leqslant t}^{*}$&lt;/span&gt; be the set of tasks to be serviced;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; be the number of available weeks;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$M = \mathbb{N}_{\leqslant m}^{*}$&lt;/span&gt; be the set of available weeks;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$w_i \in \mathbb{Z}$&lt;/span&gt; be the number of weeks the task &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; requires;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{il} \in \mathbb{Z}$&lt;/span&gt; be the number of workers the task &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; requires in week &lt;span class=&quot;math-container&quot;&gt;$l \in M$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;A feasible solution for this variant of the classical scheduling problem is given by an allocation of the tasks in &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; in the weeks of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; in a way that, if the task &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; starts to be executed in the week &lt;span class=&quot;math-container&quot;&gt;$l \in M: l \leqslant m - w_i + 1$&lt;/span&gt;, then the task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; will be allocated, in order to guarantee the continuity of the task execution, on the weeks in {&lt;span class=&quot;math-container&quot;&gt;$l^{'} \in M: l \leqslant l^{'} &amp;lt; l + w_i$&lt;/span&gt;}. An optimal solution for this variant is a feasible solution in which the maximum amount of workers used in any week is minimum.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;An Integer Programming formulation&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let's consider the variables&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{il} = \begin{cases}&#xA;1 &amp;amp;\text{if task $i \in T$ is executed in week $l \in M$,}\\&#xA;0 &amp;amp;\text{otherwise}&#xA;\end{cases},&#xA;\\&#xA;z_{il} = \begin{cases}&#xA;1 &amp;amp;\text{if task $i \in T$ starts to be serviced in week $l \in M : l \leqslant m - w_i + 1$,}\\&#xA;0 &amp;amp;\text{otherwise}&#xA;\end{cases},&#xA;\\&#xA;\text{and}&#xA;\\&#xA;y \in \mathbb{Z} \text{ is the number of workers that the week with the}&#xA;\\&#xA;\text{maximum number of workers has in a feasible solution}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Below follows the IP formulation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Objective Function:&lt;/em&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\text{min } y&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Constraints:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;The variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; assumes a value greater than or equals to the number of workers used in each week.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y \geqslant \sum_{i \in T} p_{il} x_{il} \quad \forall l \in M;&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the task &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; begins to be serviced in the week &lt;span class=&quot;math-container&quot;&gt;$l \in M : l \leqslant m - w_i + 1$&lt;/span&gt;, then this task will be allocated to all the weeks in &lt;span class=&quot;math-container&quot;&gt;$\{l^{'} \in M : l \leqslant l^{'} &amp;lt; l + w_i\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z_{il} = x_{il^{'}} \quad \forall i \in T, &#xA;\\&#xA;\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad \forall l \in M : l \leqslant m - w_i + 1, &#xA;\\&#xA;\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad \forall l^{'} \in M : l \leqslant l^{'} &amp;lt; l + w_i;&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A task &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; must start to be serviced in exactly one feasible week, i.e., one week between &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m - w_i + 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{l \in M : l \leqslant m - w_i + 1} z_{il} = 1 \quad \forall i \in T.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you want to consider a serial, non-parallel, version of the problem. You can add the following set of constraints to the formulation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in T} x_{il} \leqslant 1 \quad \forall l \in M.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If anyone has any question or have found any error, please let me know.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastActivityDate="2021-07-25T16:46:36.000" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6627" PostTypeId="1" CreationDate="2021-07-26T00:27:25.250" Score="0" ViewCount="217" Body="&lt;p&gt;Beforehand, this is a very long thread, in case you want to know in advance, to see if this thread's interests match with yours, this thread concerns fast ways of determining whether a VRP instance is feasible.&lt;/p&gt;&#xA;&lt;p&gt;Now that you are aware of the risks. Let's go!&lt;/p&gt;&#xA;&lt;p&gt;Before I describe my current problem, I will first detail in what context it will be applied.&#xA;I am proposing a solution methodology for &lt;em&gt;Team Orienteering Problems&lt;/em&gt; (&lt;strong&gt;TOPs&lt;/strong&gt;).&#xA;In this methodology, I am considering the problem as a &lt;em&gt;knapsack&lt;/em&gt; problem variant.&#xA;Let's define the notations of the &lt;strong&gt;TOP&lt;/strong&gt; to substantiate the next results.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem definition:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$D(V, A)$&lt;/span&gt; be a digraph;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \in V$&lt;/span&gt; be the depot node;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t_a \in \mathbb{R}$&lt;/span&gt; be the arc &lt;span class=&quot;math-container&quot;&gt;$a \in A$&lt;/span&gt; traversing time;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p_i \in \mathbb{R}$&lt;/span&gt; be the node &lt;span class=&quot;math-container&quot;&gt;$i \in V$&lt;/span&gt; profit, where &lt;span class=&quot;math-container&quot;&gt;$p_0 = 0$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; be the available vehicles set;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; be each vehicle's time limit.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;A feasible solution &lt;span class=&quot;math-container&quot;&gt;$S = \{R: R \text{ is a sequence of nodes in $V$ beginning and ending at the node $0$}\}$&lt;/span&gt; for the &lt;strong&gt;TOP&lt;/strong&gt; is a set of at most &lt;span class=&quot;math-container&quot;&gt;$|M|$&lt;/span&gt; routes, such that every route respects the vehicle time limit &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;.&#xA;An optimal solution &lt;span class=&quot;math-container&quot;&gt;$S^{*}$&lt;/span&gt; for the &lt;strong&gt;TOP&lt;/strong&gt; is a set of routes that maximizes the function &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in \bigcup_{R \in S} R} p_i$&lt;/span&gt;, i.e., the sum of the profits of all visited nodes where a profit is not counted more than once even if the solution visits a node twice or more. Note that, the routes, not necessarily, will have minimum time consumption, since it is not a problem's requirement.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Knapsack&lt;/em&gt; solution methodology:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Knowing that a route, not necessarily, will have minimum time consumption.&#xA;I was thinking of solving this problem in two steps.&#xA;First, finding the set of nodes that composes an optimal solution, using the constrained &lt;em&gt;knapsack&lt;/em&gt;  problem.&#xA;And second, finding a &lt;em&gt;Distance Constrained Capacitated &lt;strong&gt;VRP&lt;/strong&gt;&lt;/em&gt; (&lt;strong&gt;DCVRP&lt;/strong&gt;), a &lt;strong&gt;VRP&lt;/strong&gt; variant where the only capacity is on the vehicle's time limit, feasible solution for the instance composed by the vehicle time limit &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; and the digraph &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; induced by the nodes found by the constrained &lt;em&gt;knapsack&lt;/em&gt; problem.&#xA;Specifically, I execute an unconstrained &lt;em&gt;knapsack&lt;/em&gt; formulation,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$K(V) = \text{max}_{y \in \mathbb{B}^{|V|}} \sum_{i \in V} y_i p_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;, and then I check whether there is a &lt;strong&gt;DCVRP&lt;/strong&gt; feasible solution for the instance composed by the vehicle time limit &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;, and the digraph &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; induced by the nodes used in &lt;span class=&quot;math-container&quot;&gt;$y^{*}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$y^{*}$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$K(V)$&lt;/span&gt; optimal solution. Formally, the induced digraph can be defined as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$D^{'}(V^{'} = (\{i \in V : y^{*}_i = 1\} \cup \{0\}), \quad A^{'} = \{(i, j) \in A : i \in V^{'} \wedge j \in V^{'}\})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the digraph &lt;span class=&quot;math-container&quot;&gt;$D^{'}$&lt;/span&gt; along with &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; results in a &lt;strong&gt;DCVRP&lt;/strong&gt; feasible instance, then we have found the set of nodes that composes an optimal &lt;strong&gt;TOP&lt;/strong&gt; solution for the &lt;strong&gt;TOP&lt;/strong&gt; instance digraph &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;, otherwise, we add the following constraint to &lt;span class=&quot;math-container&quot;&gt;$K(V)$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in V^{'}} y_i \leqslant |V^{'}| - 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And we execute &lt;span class=&quot;math-container&quot;&gt;$K(V)$&lt;/span&gt; again, till we get a set of nodes &lt;span class=&quot;math-container&quot;&gt;$V^{'}$&lt;/span&gt; that leads to a feasible &lt;strong&gt;DCVRP&lt;/strong&gt; instance. Formally, consider the algorithm &lt;em&gt;&lt;strong&gt;KnapDCVRP&lt;/strong&gt;&lt;/em&gt; below:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$y^{*}$&lt;/span&gt; be a &lt;span class=&quot;math-container&quot;&gt;$K(V)$&lt;/span&gt; optimal solution;&lt;/li&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$D^{'}(V^{'}, A^{'})$&lt;/span&gt; be the induced digraph, built over &lt;span class=&quot;math-container&quot;&gt;$y^{*}$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$(T, D^{'})$&lt;/span&gt; is a &lt;strong&gt;DCVRP&lt;/strong&gt; feasible instance, then return &lt;span class=&quot;math-container&quot;&gt;$V^{'}$&lt;/span&gt;, and exit program;&lt;/li&gt;&#xA;&lt;li&gt;Add to &lt;span class=&quot;math-container&quot;&gt;$K(V)$&lt;/span&gt; the constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in V^{'}} y_i \leqslant |V^{'}| - 1$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;Go to &lt;strong&gt;1&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;DCVRP feasibility checking:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this methodology, the major problem I am facing concerns the algorithm &lt;em&gt;&lt;strong&gt;KnapDCVRP&lt;/strong&gt;&lt;/em&gt;'s step 3, i.e. how to determine whether a &lt;strong&gt;DCVRP&lt;/strong&gt; instance is feasible.&#xA;To do this, I convert the &lt;span class=&quot;math-container&quot;&gt;$D^{'}$&lt;/span&gt; digraph into a complete digraph &lt;span class=&quot;math-container&quot;&gt;$D^{''}(V^{'}, A^{''} = A^{'} \cup \{(i, j) \in V^{'2}: (i, j) \notin A^{'} \wedge i \neq j\})$&lt;/span&gt;, and I consider the time weights as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;t^{''}_{(i, j)} = &#xA;\begin{cases}&#xA;t_{(i, j)}, \quad \text{if } (i, j) \in A^{'}\\&#xA;\text{the shortest path time between nodes $i$ and $j$ in $D^{'}$}, \quad \text{otherwise}&#xA;\end{cases}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for all &lt;span class=&quot;math-container&quot;&gt;$(i, j) \in A^{''}$&lt;/span&gt;.&#xA;And then I execute the following MILP program:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{a \in \delta^{+}(i)} x_a = \sum_{a \in \delta^{-}(i)} x_a = 1 \quad \forall i \in V^{'} \backslash \{0\} \quad (1)&#xA;\\&#xA;\sum_{a \in \delta^{+}(0)} x_a = \sum_{a \in \delta^{-}(0)} x_a = |M|  \quad (2)&#xA;\\&#xA;\sum_{i \in V^{'} : i\neq j} u_{(j, i)} - u_{(i, j)} + x_{(i, j)} t^{''}_{(i, j)} = 0 \quad \forall j \in V^{'} \backslash \{0\} \quad (3)&#xA;\\&#xA;u_{(0, i)} = 0 \quad \forall i \in V^{'} \backslash\{0\} \quad (4)&#xA;\\&#xA;u_{(j, 0)} \geqslant x_{(j, 0)} t^{''}_{(0, j)} \quad \forall j \in V^{'} \backslash \{0\} \quad (5)&#xA;\\&#xA;u_{(j, 0)} \leqslant x_{(j, 0)} (T - t^{''}_{(j, 0)}) \quad \forall j \in V^{'} \backslash \{0\} \quad (6)&#xA;\\&#xA;u_{(i, j)} \geqslant x_{(i, j)} max\{t^{''}_{(depot, j)} - t^{''}_{(i, j)}, t^{''}_{(0, i)}\} \quad \forall (i, j) \in A^{''} : i, j \neq 0 \quad (7)&#xA;\\&#xA;u_{(i, j)} \leqslant x_{(i, j)} min\{T - t^{''}_{(j, 0)} - t^{''}_{(i, j)}, T - t^{''}_{(i, depot)}\} \quad \forall (i, j) \in A^{''} : i, j \neq 0  \quad (8)&#xA;\\&#xA;x \in \mathbb{B}^{|V^{'}|} \quad (9)&#xA;\\&#xA;u \in \mathbb{R}^{A^{''}}_{+} \quad (10)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraints (1) and (2) are &lt;strong&gt;VRP&lt;/strong&gt;'s well known.&#xA;Regarding the remaining ones, (3-10), are arc flow constraints to avoid subcycles disconnected from the depot, even in fractional solutions, and, at the same time, impose the vehicle's time limit constraint.&#xA;I know they seem to be a little bit unusual since there's no big &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; on it, but they were already used in another routing problem and had proven to be very efficient (look &lt;a href=&quot;https://doi.org/10.1016/j.tre.2017.06.003&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; at subsection 3.4 on page 10, and &lt;a href=&quot;http://repositorio.unicamp.br/jspui/handle/REPOSIP/357117&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; at subsection 6.3 on page 50).&lt;/p&gt;&#xA;&lt;p&gt;I have executed the MILP formulation (1-10) in the CPLEX solver using the following parameters configuration:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CPX_PARAM_INTSOLLIM = 1 (Just find a feasible solution, if it exists);&lt;/li&gt;&#xA;&lt;li&gt;CPX_PARAM_MIPEMPHASIS = 1 (Emphasize feasibility over optimality);&lt;/li&gt;&#xA;&lt;li&gt;CPX_PARAM_VARSEL = -1 (Branch on variable with minimum infeasibility)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note that the formulation (1-10) has no objective function and that the CPLEX chosen parameters are tuned to find integer feasible solutions, rather than optimizing.&#xA;These choices were made since I just want to determine whether the &lt;strong&gt;DCVRP&lt;/strong&gt; instance is feasible.&lt;/p&gt;&#xA;&lt;p&gt;The problem regarding this procedure is that it is taking, relatively speaking, too long, about ~1 minute for 100 nodes, to check whether an instance is feasible.&#xA;In this solution methodology, the algorithm &lt;strong&gt;KnapDCVRP&lt;/strong&gt;'s step &lt;strong&gt;3&lt;/strong&gt; may be executed many times, even hundreds, thus, having a fast procedure to check the feasibility of a &lt;strong&gt;DCVRP&lt;/strong&gt; instance can make a huge difference, depending on the instance size.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, I would like to know if there is any way of determining whether a &lt;strong&gt;DCVRP&lt;/strong&gt; instance is feasible in a very fast time.&#xA;I already tried to use the Google OR-Tools and Dynamic Programming approaches, but they are taking too much time, indeed they are slower than the (1-10) MILP formulation.&lt;/p&gt;&#xA;&lt;p&gt;I know this is a very long thread, and the reader now may be thinking &amp;quot;well he could just have stated he needed some fast procedure to check a VRP instance feasibility&amp;quot;, but I think it is important to make the context clear.&#xA;If anyone has any questions or found any errors, please let me know.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="2862" LastEditDate="2021-07-26T13:35:18.290" LastActivityDate="2021-07-26T13:35:18.290" Title="Check VRP instance is feasibility" Tags="|mixed-integer-programming|integer-programming|vehicle-routing|knapsack|feasible-points|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="6628" PostTypeId="2" ParentId="6617" CreationDate="2021-07-26T01:57:21.097" Score="4" Body="&lt;p&gt;The log-likelihood function &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is continuous while QUBO is discrete. If you really wanted to formulate it as a QUBO, this is how I would do it. In summary, the steps would be as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L \to \text{ Discrete-}L \to \text{ Binary-} L \to \text{Higher-Order-Binary-} L \to \text{ QUBO } L$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$L \to \text{ Discrete-}L$&lt;/span&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This step would simply be restricting the variables&#xA;&lt;span class=&quot;math-container&quot;&gt;$J_{ij}, h_i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\mathbb{Z}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{ Discrete-}L \to \text{ Binary-} L$&lt;/span&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Binary expansion of the integer variables&lt;/li&gt;&#xA;&lt;li&gt;Note: at this step, the function is not necessarily a polynomial&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{ Binary-} L \to \text{Higher-Order-Binary-} L $&lt;/span&gt;.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Find a binary polynomial that approximates the function in the previous step&lt;/li&gt;&#xA;&lt;li&gt;This will end up being a Higher-Order Binary Optimization problem (HOBO)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$ \text{Higher-Order-Binary-} L \to \text{ QUBO } L$&lt;/span&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Convert the HOBO to a QUBO using known HOBO to QUBO techiques&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Perhaps there are some interesting applications where we directly know that &lt;span class=&quot;math-container&quot;&gt;$J_{ij}, h_i \in \{0,1\}$&lt;/span&gt;, in that case all you would need is step 3 and 4.&lt;/p&gt;&#xA;" OwnerUserId="5920" LastEditorUserId="727" LastEditDate="2021-07-26T02:51:38.260" LastActivityDate="2021-07-26T02:51:38.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6629" PostTypeId="2" ParentId="6558" CreationDate="2021-07-27T08:37:33.460" Score="3" Body="&lt;p&gt;It is not the best option to regard it as a non-convex QP. A product of a binary variable and a continuous variable is not really bilinear (or non-linear). For example, the nonlinear constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z_{ij} \geq x_{ij}y_{ij}&#xA;$$&lt;/span&gt;&#xA;could be replaced with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z_{ij} \geq y_{ij} - y_{\max}(1-x_{ij})\\&#xA;z_{ij} \geq y_{\min}x_{ij}&#xA;$$&lt;/span&gt;&#xA;(the RHS of the second line could be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$y_{\min}\geq 0$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2021-07-27T08:37:33.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6630" PostTypeId="1" CreationDate="2021-07-27T08:47:40.903" Score="3" ViewCount="330" Body="&lt;p&gt;There are sometimes variables that automatically take integer values in feasible solutions, like &lt;a href=&quot;https://en.wikipedia.org/wiki/Travelling_salesman_problem#Integer_linear_programming_formulations#Miller%E2%80%93Tucker%E2%80%93Zemlin%20formulation&quot; rel=&quot;nofollow noreferrer&quot;&gt;MTZ-formulation&lt;/a&gt; of TSP. They could be declared continuous or integer, and I find the solver performs differently, but it seems neither is generally better. I wonder if there is any experience or suggestions on this topic.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2021-07-27T15:31:20.907" Title="What is the best practice regarding &quot;automatic integer variables&quot;?" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6631" PostTypeId="1" AcceptedAnswerId="6639" CreationDate="2021-07-27T09:47:35.403" Score="7" ViewCount="84" Body="&lt;p&gt;There are classes of problems which allow for &amp;quot;natural&amp;quot; extended formulations using multiple exponential-size sets of variables.&#xA;For example, &lt;strong&gt;2-echelon routing problems&lt;/strong&gt; can be modelled considering an exponential number of variables associated with first-echelon routes, and another exponential number of variables associated with second-echelon routes.&lt;/p&gt;&#xA;&lt;p&gt;The methods I know of, such as &lt;a href=&quot;https://pubsonline.informs.org/doi/pdf/10.1287/opre.1120.1153&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;https://pubsonline.informs.org/doi/pdf/10.1287/trsc.2018.0844&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt;, enumerate one set of variables and perform pricing on the other set.&#xA;Is there any paper in the literature, in which a model with more than one set of exponential variables is solved via branch-and-price, and pricing happens over more than one set of variables?&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2021-07-29T07:39:06.237" Title="Branch and price with two sets of exponential variables" Tags="|column-generation|literature-research|branch-and-price|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6632" PostTypeId="1" CreationDate="2021-07-27T12:57:15.097" Score="2" ViewCount="141" Body="&lt;p&gt;I have several (large) Pyomo models with about 20 variables and parameters (as time series). Out of these variables and parameters I have 3 decision variables. Now my question is whether I can use this model to evaluate the solution when these 3 decision variables are externally assigned? The other variables are no decision variables. They can just be calculated once those 3 decision variables have a value (for every time slot as I use time series as variables).&lt;/p&gt;&#xA;&lt;p&gt;The notion behind this approach is that I can for example use (or implement on my own) an evolutionary algorithm (or any other metaheuristic) for determining the values of the 3 decision variables and use the Pyomo model to evaluate the created solution (as it is necessary to calculate a fitness of a given solution when using evolutionary algorithms).&lt;/p&gt;&#xA;&lt;p&gt;Of course I can also calculate a simulation for evaluating the solutions. But since I have more than 10 large models it would take quite a while to do so. This is why I would like to use my already existing Pyomo models.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastActivityDate="2021-07-27T12:57:15.097" Title="Run Pyomo model with externally assigned variables" Tags="|pyomo|metaheuristics|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6633" PostTypeId="1" AcceptedAnswerId="6635" CreationDate="2021-07-27T13:45:58.197" Score="2" ViewCount="158" Body="&lt;p&gt;I have been working on the &lt;a href=&quot;https://colab.research.google.com/github/Gurobi/modeling-examples/blob/master/facility_location/facility_location_gcl.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;problem on Facility Location Problem with Gurobi using the example provided by the Gurobi team&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;m = gp.Model('facility_location')&#xA;&#xA;select = m.addVars(num_facilities, vtype=GRB.BINARY, name='Select') # y_i&#xA;assign = m.addVars(cartesian_prod, ub=1, vtype=GRB.BINARY, name='Assign') # x_ij&#xA;&#xA;m.addConstrs((assign[(c,f)] &amp;lt;= select[f] for c,f in cartesian_prod), name='Setup2ship')&#xA;m.addConstrs((gp.quicksum(assign[(c,f)] for f in range(num_facilities)) == 1 for c in range(num_customers)), name='Demand')&#xA;m.addConstr(gp.quicksum(select[f] for f in range(num_facilities)) == 9 , name='numberoffacilities')&#xA;&#xA;m.setObjective(select.prod(setup_cost)+assign.prod(shipping_cost), GRB.MINIMIZE)&#xA;&#xA;m.optimize()&#xA;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Everything is fine with the optimization programming and the result. However, I am designing an approximation algorithm to solve the problem for large instances.&lt;/p&gt;&#xA;&lt;p&gt;In Gurobi, by using&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;obj = m.getObjective()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;print(obj.getValue())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I can access to obj value after the accomplishment of the optimization. Moreover, the numeric result for decision variables is also provided by&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.getVars()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now, my problem is that my approximation algorithm outputs different values for decisions variable ( different select and assignment values for nodes).&lt;/p&gt;&#xA;&lt;p&gt;May I use the Gurobi so as to calculate the obj value of the optimization problem using the output of my approximation algorithm? In other words, I want to pass the value of the decision variables manually to Gurobi and get the obj value of the input.&lt;/p&gt;&#xA;" OwnerUserId="5944" LastActivityDate="2021-07-27T22:49:02.293" Title="Calculating the Obj Value manually in Gurobi" Tags="|python|gurobi|facility-location|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6634" PostTypeId="2" ParentId="6630" CreationDate="2021-07-27T15:31:20.907" Score="5" Body="&lt;p&gt;If the variable is declared integer (and assuming the solver leaves it that way in the presolve stage), there is at least a chance that the solver will branch on it. In some cases this might be a good thing (getting the solver to a feasible solution faster, improving the bound faster) and in some cases this might be a bad thing (distracting the solver from more productive branching strategies). My personal inclination is to relax the integrality restriction unless something in the structure of the problem makes me think that partitioning the solution spaced based on that variable would be beneficial ... which in practice means that I pretty much always relax integrality. As with so many things MIP-related, it's a roll of the dice.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-27T15:31:20.907" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6635" PostTypeId="2" ParentId="6633" CreationDate="2021-07-27T22:49:02.293" Score="1" Body="&lt;p&gt;I think one way to accomplish what you want is to pass your solution as a MIP Start to gurobi. If it's feasible, gurobi will report the objective value of that solution. Here is Gurobi's documentation on &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/examples/mip_starts.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIP Start&lt;/a&gt;. From the link:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When you run the example, the MIP solver reports that the start produced a feasible initial solution:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;User MIP start produced solution with objective 210500 (0.01s)&#xA;&#xA;Loaded user MIP start with objective 210500&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="36" LastActivityDate="2021-07-27T22:49:02.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6636" PostTypeId="1" CreationDate="2021-07-28T09:45:06.050" Score="3" ViewCount="188" Body="&lt;p&gt;It seems to me that a multi-commodity flow problem should be treated differently when the commodity demand constraint is an equivalence and not a lower-bound. Consider a unit demand. Apparently, in such a case, the problem seems easier (and not really a flow problem).&lt;/p&gt;&#xA;&lt;p&gt;I am not considering the constraint which relates edges with commodities.&lt;/p&gt;&#xA;&lt;p&gt;My question is whether this intuition is misleading or not. Is the problem still NP-hard?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: Here's the formulation.&#xA;For a given graph &lt;span class=&quot;math-container&quot;&gt;$G = (V,E)$&lt;/span&gt; with associated capacity function &lt;span class=&quot;math-container&quot;&gt;$c : E \rightarrow \mathbb{N}$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$K_1, K_2, \dots, K_n$&lt;/span&gt; be a set of commodities, such that &lt;span class=&quot;math-container&quot;&gt;$K_i = \{s_i, t_i\}$&lt;/span&gt; -- i.e. a couple of source and sink nodes in &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; --.&lt;/p&gt;&#xA;&lt;p&gt;The objective function is a sum over all the flows &lt;span class=&quot;math-container&quot;&gt;$f_{e,i} \in \mathbb{N}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The first constraint is the flow conservation:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{e \in \delta^{-}(v)}f_{e,i} - \sum_{e \in \delta^{+}(v)} f_{e,i} = 0,\ \forall i \in \{1,\dots, n\}\text{ and }\forall v \in V\smallsetminus K_i.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The commodity demand constraint is given by:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{e \in \delta^{-}(s_i)}f_{e,i} - \sum_{e \in \delta^{+}(s_i)} f_{e,i} = -1,\ \forall i \in \{1,\dots, n\}.$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{e \in \delta^{-}(t_i)}f_{e,i} - \sum_{e \in \delta^{+}(t_i)} f_{e,i} = +1,\ \forall i \in \{1,\dots, n\}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The final constraint is on the capacity bound&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i = 1}^n{f_{e,i}} \leq c(e),\ \forall e \in E$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="5523" LastEditDate="2021-10-07T10:24:03.037" LastActivityDate="2021-10-07T10:42:17.103" Title="Multi-commodity (Integral) flow problem with unit demand; complexity" Tags="|network-flow|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6637" PostTypeId="1" CreationDate="2021-07-28T14:19:06.693" Score="1" ViewCount="41" Body="&lt;p&gt;I am implementing a quay crane optimization model. The objective is to minimize the loading time.&lt;/p&gt;&#xA;&lt;p&gt;Inputs to the model are&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$I=$&lt;/span&gt; number of nodes&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$K =$&lt;/span&gt; number of cranes&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_k =$&lt;/span&gt; crane speed in meter/minutes&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$p_{ik}$&lt;/span&gt; = processing time of crane &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in minutes&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$L_k=$&lt;/span&gt; Loading rate in tonnes/minutes of crane &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$D=$&lt;/span&gt; distance matrix for nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Variables used are&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$X_{ijk} =1$&lt;/span&gt; if the crane &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; follows the arc &lt;span class=&quot;math-container&quot;&gt;$i-j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to implement a constraint that identifies the loading is complete by all the cranes at any time. For example, after 20 minutes, 45 minutes, or 100 minutes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/abs/1604.00527&quot; rel=&quot;nofollow noreferrer&quot;&gt;Link to the problem&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5959" LastEditorUserId="491" LastEditDate="2021-07-28T14:23:03.323" LastActivityDate="2021-07-28T14:23:03.323" Title="Constraint formation help" Tags="|mixed-integer-programming|vehicle-routing|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6638" PostTypeId="1" CreationDate="2021-07-28T17:22:15.800" Score="1" ViewCount="296" Body="&lt;p&gt;I am trying to figure out what is the correct use of cplex callbacks in pyomo. In particular I am looking for the translation of the following example from gurobi to cplex:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from gurobipy import GRB&#xA;import pyomo.environ as pe&#xA;from pyomo.core.expr.taylor_series import taylor_series_expansion&#xA;&#xA;m = pe.ConcreteModel()&#xA;m.x = pe.Var(bounds=(0, 4))&#xA;m.y = pe.Var(within=pe.Integers, bounds=(0, None))&#xA;m.obj = pe.Objective(expr=2*m.x + m.y)&#xA;m.cons = pe.ConstraintList()  # for the cutting planes&#xA;&#xA;def _add_cut(xval):&#xA;    # a function to generate the cut&#xA;    m.x.value = xval&#xA;    return m.cons.add(m.y &amp;gt;= taylor_series_expansion((m.x - 2)**2))&#xA;&#xA;_add_cut(0)  # start with 2 cuts at the bounds of x&#xA;_add_cut(4)  # this is an arbitrary choice&#xA;&#xA;opt = pe.SolverFactory('gurobi_persistent')&#xA;opt.set_instance(m)&#xA;opt.set_gurobi_param('PreCrush', 1)&#xA;opt.set_gurobi_param('LazyConstraints', 1)&#xA;&#xA;def my_callback(cb_m, cb_opt, cb_where):&#xA;    if cb_where == GRB.Callback.MIPSOL:&#xA;        cb_opt.cbGetSolution(vars=[m.x, m.y])&#xA;        if m.y.value &amp;lt; (m.x.value - 2)**2 - 1e-6:&#xA;            cb_opt.cbLazy(_add_cut(m.x.value))&#xA;&#xA;opt.set_callback(my_callback)&#xA;opt.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5964" LastEditorUserId="491" LastEditDate="2021-12-16T20:15:34.783" LastActivityDate="2022-06-18T15:44:02.053" Title="CPLEX callback in pyomo" Tags="|cplex|pyomo|callback|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6639" PostTypeId="2" ParentId="6631" CreationDate="2021-07-29T06:12:43.087" Score="4" Body="&lt;p&gt;A common case where you would see 2 or more exponentially large sets of variables, is in:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;VRPs with heterogeneous vehicles: some vehicles have special equipment or larger capacity and can serve different types of routes&lt;/li&gt;&#xA;&lt;li&gt;Rostering problems with employees with different skills: some employees can perform skills that others cannot perform (e.g. drive a forklift)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For those problems, you would typically solve a pricing problem for each class. E.g. for the VRPs you would solve a separate pricing problem for each vehicle class. Naturally, for each (vehicle) class you would maintain a separate set of columns.&lt;/p&gt;&#xA;&lt;p&gt;The problem you are referencing, the 2E-VRP is different. Although there exist many variants of this problem, the basic variant typically requires:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;To compute a set of first-echelon (FE) routes. Unlike common VRPs the same location (satellite) can typically be visited by more than 1 FE. As such, it's necessary to uniquely distinguish between FEs.&lt;/li&gt;&#xA;&lt;li&gt;To compute a set of second-echelon (SE) routes, which collectively visit all the customers. Each SE route contains a single satellite as its depot, as well as one or more customers.&lt;/li&gt;&#xA;&lt;li&gt;To link the FE and SE routes in such a way that each FE supplies one or more SE routes, and, as a consequence, that each FE route has enough capacity to serve the total demand of the customers visited in these SE routes.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In the paper &lt;a href=&quot;http://www.optimization-online.org/DB_HTML/2021/04/8341.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;A Chance-Constrained Two-Echelon Vehicle Routing Problem with Stochastic Demands&lt;/a&gt; by Sluijk et al, you will find a CG approach to solve this problem without the need to enumerate the FE routes (see the 2E1P pricing algorithm). In their approach, a single column comprises of 1 FE route and one or more associated SE routes (so-called tour trees).&lt;/p&gt;&#xA;&lt;p&gt;If you would impose the limiting condition that each satellite can only be visited by a single FE route, then you could have the following CG model.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$R^{FE}$&lt;/span&gt; be the set of FE routes, &lt;span class=&quot;math-container&quot;&gt;$R^{SE}$&lt;/span&gt; the set of SE routes, &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; the set of satellites, &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; the set of customers, &lt;span class=&quot;math-container&quot;&gt;$a_{ir}$&lt;/span&gt; an indicator whether route &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; visits &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$q_r$&lt;/span&gt; the supply or demand of a route &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$c_r$&lt;/span&gt; the cost of a route.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{minimize} &amp;amp; \sum_{r\in R^{FE}}c_r y_r + \sum_{r\in R^{SE}}c_r y_r &amp;amp; \\&#xA;&amp;amp; \sum_{r\in R^{FE}}a_{ir} y_r \leq 1 &amp;amp; \forall i\in S\\&#xA;&amp;amp; \sum_{r\in R^{SE}}a_{ir} y_r = 1 &amp;amp; \forall i\in C\\&#xA;&amp;amp; \sum_{r\in R^{FE}}a_{ir}q_ry_r \geq \sum_{r\in R^{SE}}a_{ir}q_r y_r &amp;amp; \forall i\in S\\&#xA;&amp;amp; y_r \in \{0,1\} &amp;amp; \forall r \in R^{FE} \cup R^{SE}&#xA;\end{align}&lt;/span&gt;&#xA;The first constraint ensures that a satellite is visited at most once by a FE route, the 2nd constraint ensures that each customer is visited by a SE route, and the 3rd constraint links FE and SE routes together.&lt;/p&gt;&#xA;&lt;p&gt;In theory you could allow a satellite to be visited more than once using the above formulation, but that would require introducing copies of the satellites (1 copy for every FE vehicle). This will affect the scalability of the model.&lt;/p&gt;&#xA;&lt;p&gt;Nevertheless, the challenge with having more than 1 exponentially large set of variables is that you somehow need to link the variables together.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="123" LastEditDate="2021-07-29T07:39:06.237" LastActivityDate="2021-07-29T07:39:06.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6640" PostTypeId="1" AcceptedAnswerId="6652" CreationDate="2021-07-29T06:33:40.050" Score="3" ViewCount="877" Body="&lt;p&gt;I am looking for a way to solve a large scale &lt;a href=&quot;https://en.wikipedia.org/wiki/Generalized_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Generalized assignment problem&lt;/a&gt;(To be precise, it is a relaxation of the Generalized assignment problem, because the second constraint has &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt;).&#xA;Here, &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is the number of agents and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the number of tasks.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;&amp;amp;\text{maximize} &amp;amp;&amp;amp; \sum_{i}^{m} \sum_{j}^{n} p_{ij}x_{ij} \\\&#xA;&amp;amp;\text{subject to}&#xA;&amp;amp;&amp;amp; \sum_{j}^{n} w_{ij}x_{ij} \le t_{i} &amp;amp;&amp;amp;&amp;amp; \forall i \\\&#xA;&amp;amp; &amp;amp;&amp;amp; \sum_{i}^{m} x_{ij} \le 1 &amp;amp;&amp;amp;&amp;amp; \forall j \\\&#xA;&amp;amp; &amp;amp;&amp;amp; x_{ij} \in \{0, 1\}&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;data size&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$m \le 1,000$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$n \le 10,000,000$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{ij} \le 1,000$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$w_{ij} \le 1,000$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t_i \le 200,000$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;valid agent-task pair(i.e. number of non zero &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt;) &lt;span class=&quot;math-container&quot;&gt;$\le 200,000,000$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;time limit : 6 hours&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Generalized assignment problem is NP-hard, so I'm not trying to find an exact solution.&#xA;Are there any approximation algorithm or heuristic to solve this problem?&lt;/p&gt;&#xA;&lt;p&gt;Also, are there any other approaches to solving large scale NP-hard problems?&#xA;For example, I was wondering if it is possible to reduce the number of variables by clustering agents or tasks, but I did not find such a method.&lt;/p&gt;&#xA;" OwnerUserId="5966" LastEditorUserId="5966" LastEditDate="2021-07-30T06:01:43.867" LastActivityDate="2021-07-30T19:45:38.950" Title="How to solve large scale generalized assignment problem" Tags="|heuristics|assignment-problem|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6641" PostTypeId="1" AcceptedAnswerId="6649" CreationDate="2021-07-29T06:49:53.807" Score="3" ViewCount="501" Body="&lt;p&gt;How can write the following function in LP:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;s=&#xA;\begin{cases}&#xA;1 &amp;amp; 1 \leq x \leq C \\&#xA;0 &amp;amp; \text{otherwise}&#xA;\end{cases}&#xA;$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; takes only non-negative integers and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is some large constant integer.&lt;/p&gt;&#xA;&lt;p&gt;I've tried using big M, and came up with conditions for &lt;span class=&quot;math-container&quot;&gt;$s=1$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x-M \cdot (1-s) &amp;amp;\leq C\\&#xA;x+M \cdot (1-s) &amp;amp;\geq 1 \\&#xA;\end{align}&lt;/span&gt;&#xA;But I wonder how to force &lt;span class=&quot;math-container&quot;&gt;$s=0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x\ge C+1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5967" LastEditorUserId="123" LastEditDate="2021-07-29T07:36:25.923" LastActivityDate="2021-07-29T20:26:29.637" Title="Write in ILP: If $x$ within range then $s=1$, else $0$" Tags="|linear-programming|logical-constraints|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6642" PostTypeId="1" CreationDate="2021-07-29T07:32:11.050" Score="1" ViewCount="82" Body="&lt;p&gt;I tried &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/notebook/examples/bus_driver_scheduling_sat.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;this code&lt;/a&gt; and it goes on and I'm clueless when it'll end so I manually interrupt it.&lt;/p&gt;&#xA;&lt;p&gt;Is there any way we can see intermediate solutions that are feasible solutions and can we limit time or number of Feasible solution if optimal solution search takes time.&#xA;I'm having 16 Gigs of RAM yet struggle to get optimal solution if runs instance of Large Sample.&lt;/p&gt;&#xA;&lt;p&gt;Second Part:&#xA;I ran code in jupyter notebook initially and ended with error&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;DuplicateFlagError: The flag 'params' is defined twice. First from C:\Users\Dell\anaconda3\lib\site-packages\ipykernel_launcher.py, Second from C:\Users\Dell\anaconda3\lib\site-packages\ipykernel_launcher.py.  Description from first occurrence: Sat solver parameters.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is there any way of tackling this or not using FLAGS in general and declare instances as user input. After error I tried PyCharm where Small sample worked fine but others ended with no output and were utilizing 95% CPU in background so needed to interrupt.&lt;/p&gt;&#xA;" OwnerUserId="5968" LastEditorUserId="67" LastEditDate="2021-07-29T18:15:12.037" LastActivityDate="2021-07-30T21:51:43.857" Title="Print Intermediate Solutions of Scheduling Problem and tackling FLAGS in jupyter notebook" Tags="|modeling|python|constraint-programming|or-tools|assignment-problem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6643" PostTypeId="1" CreationDate="2021-07-29T12:57:56.920" Score="1" ViewCount="84" Body="&lt;p&gt;I have a problem as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\begin{array}{cl}&#xA;\underset{x \in \mathbb{R}^n_+}{\min} &amp;amp; c^\top x \\&#xA;\mathrm{s.t.} &amp;amp; Ax \leq \mathbf{1} \cdot b ,&#xA;\end{array}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{m \times n}$&lt;/span&gt; is an arbitrary data matrix and all the constraints have &lt;span class=&quot;math-container&quot;&gt;$b &amp;gt; 0 $&lt;/span&gt; on the right-hand side.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for the terminology (and in a broader sense, the relevant literature) studying &amp;quot;if we increase &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; arbitrarily small, we can also bound the change in the optimal objective value with an arbitrarily small change.&amp;quot; Or more formally maybe:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Take &lt;span class=&quot;math-container&quot;&gt;$b_1 &amp;gt; 0$&lt;/span&gt;, and denote &lt;span class=&quot;math-container&quot;&gt;$OPT_1$&lt;/span&gt; as the optimal objective value when the above problem has &lt;span class=&quot;math-container&quot;&gt;$b_1$&lt;/span&gt; on the right-hand side of the constraint. For any &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt;, there exists some &lt;span class=&quot;math-container&quot;&gt;$b_2 &amp;lt; b_1$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$OPT_2 - OPT_1 &amp;lt; \epsilon$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$b_2$&lt;/span&gt; is a function of &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$OPT_2$&lt;/span&gt; denotes the optimal objective value of the above LP when the right-hand side is &lt;span class=&quot;math-container&quot;&gt;$b_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;My main goal is to analyze this for a continuous LP where the variable becomes a Borel measure, the objective becomes &lt;span class=&quot;math-container&quot;&gt;$\int_{\mathbb z \in R} c(z) \mathrm{d}x(z) $&lt;/span&gt; and the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th constraint becomes &lt;span class=&quot;math-container&quot;&gt;$\int_{\mathbb R} a_i(z)\mathrm{d}x(z) \leq b$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; are also Borel functions. I am hoping the answer for the simpler LP example above will let me generalize to this case.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2021-07-30T11:31:50.093" Title="LPs having a 'stable' objective value wrt changes in the constraint right-hand sides" Tags="|linear-programming|sensitivity-analysis|continuous-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6644" PostTypeId="1" CreationDate="2021-07-29T14:03:18.633" Score="2" ViewCount="132" Body="&lt;p&gt;I have successfully implemented a program where I allocate &lt;strong&gt;N&lt;/strong&gt; &lt;code&gt;truck drivers&lt;/code&gt; to &lt;strong&gt;M&lt;/strong&gt; &lt;code&gt;gathering hubs&lt;/code&gt; for each one of the days of the week. The constraints I have implemented are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A driver cannot work more than 6 days, i.e. 1 day to rest&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A driver cannot be allocated in more than 1 hubs for each day&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each hub must satisfy its driver requirements for each day of the week&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A driver must work his days at one hub instead of many.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The program runs smoothly, satisfies the overall objective and outputs a schedule for each hub-driver pair.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;However,&lt;/strong&gt; the output schedule allocates 30 drivers who all work in one-hub, but unfortunately their working days are way less than 6 / week. How could that be amended?&#xA;The optimal solution would be that each driver works 6 days (one day off) and only at one hub, but this, unfortunately is not possible from what I understand.&#xA;Small tweaks in the constraints or demand are acceptable. Any ideas?&lt;/p&gt;&#xA;&lt;p&gt;Code below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import pulp&#xA;import pandas as pd&#xA;import numpy as np&#xA;&#xA;day_reqs = [[1, 1, 1, 1, 1, 1, 1],&#xA;            [3, 4, 3, 4, 5, 3, 3],&#xA;            [3, 4, 4, 3, 4, 5, 5],&#xA;            [1, 1, 1, 1, 1, 1, 2],&#xA;            [2, 2, 2, 2, 2, 2, 2],&#xA;            [2, 4, 3, 2, 2, 2, 2],&#xA;            [6, 5, 3, 3, 3, 5, 4],&#xA;            [2, 3, 2, 2, 2, 1, 2]]&#xA;&#xA;total_day_requirements = ([sum(x) for x in zip(*day_reqs)])&#xA;&#xA;hub_names = {0: 'Hub 1',&#xA;             1: 'Hub 2',&#xA;             2: 'Hub 3',&#xA;             3: 'Hub 4',&#xA;             4: 'Hub 5',&#xA;             5: 'Hub 6',&#xA;             6: 'Hub 7',&#xA;             7: 'Hub 8'}&#xA;&#xA;total_drivers = max(total_day_requirements)  # minimum number of drivers&#xA;total_hubs = len(day_reqs)  # number of hubs&#xA;days = 7&#xA;&#xA;&#xA;def crosshubbers(dashboard, driver_names):&#xA;    test = dashboard.reset_index()&#xA;    counter = 0&#xA;    for name in driver_names:&#xA;        driv = test[test['Driver'] == name]&#xA;&#xA;        temp = list(driv.sum(axis=1).values)&#xA;        cnt = 0&#xA;        for val in temp:&#xA;            if val &amp;gt; 0:&#xA;                cnt += 1&#xA;&#xA;        if cnt &amp;gt; 1:&#xA;            #     print(f'{cnt} for driver {name}')&#xA;            counter += 1&#xA;    return counter&#xA;&#xA;def schedule(drivers, hubs, day_requirement):&#xA;    driver_names = ['Driver_{}'.format(i) for i in range(drivers)]&#xA;    var = pulp.LpVariable.dicts('VAR', (range(hubs), range(drivers), range(days)), 0, 1, 'Binary')&#xA;    problem = pulp.LpProblem('shift', pulp.LpMinimize)&#xA;&#xA;    obj = None&#xA;    for h in range(hubs):&#xA;        for driver in range(drivers):&#xA;            for day in range(days):&#xA;                obj += var[h][driver][day]&#xA;    problem += obj&#xA;&#xA;    #  we add binary variables z indicating if a driver is active on a hub:&#xA;    z = pulp.LpVariable.dicts('Z', (range(hubs), range(drivers)), 0, 1, 'Binary')&#xA;    # minimize the sum of drivers active on hubs&#xA;    for h in range(hubs):&#xA;        for driver in range(drivers):&#xA;            obj += z[h][driver]&#xA;    problem += obj&#xA;&#xA;    # Add constraints to connect z with VAR:&#xA;    for driver in range(drivers):&#xA;        for h in range(hubs):&#xA;            problem += z[h][driver] &amp;lt;= pulp.lpSum(var[h][driver][day] for day in range(days))&#xA;            problem += days * z[h][driver] &amp;gt;= pulp.lpSum(var[h][driver][day] for day in range(days))&#xA;&#xA;    for driver in range(drivers):&#xA;        problem += pulp.lpSum(z[h][driver] for h in range(hubs)) &amp;lt;= 1&#xA;&#xA;    # if a driver works one day at a hub, he cannot work that day in a different hub obviously&#xA;    for driver in range(drivers):&#xA;        for day in range(days):&#xA;            problem += pulp.lpSum([var[h][driver][day] for h in range(hubs)]) &amp;lt;= 1&#xA;&#xA;    # schedule must satisfy daily requirements of each hub&#xA;    for day in range(days):&#xA;        for h in range(hubs):&#xA;            problem += pulp.lpSum(var[h][driver][day] for driver in range(drivers)) == \&#xA;                       day_requirement[h][day]&#xA;&#xA;    # a driver cannot work more than 6 days&#xA;    for driver in range(drivers):&#xA;        problem += pulp.lpSum([var[h][driver][day] for day in range(days) for h in range(hubs)]) \&#xA;                   &amp;lt;= 6&#xA;&#xA;    # Solve problem. We have a very complex solution so we set a timeout at 10secs.&#xA;    status = problem.solve(pulp.PULP_CBC_CMD(msg=False, timeLimit=30))&#xA;&#xA;    idx = pd.MultiIndex.from_product([hub_names.values(), driver_names], names=['Hub', 'Driver'])&#xA;&#xA;    # col = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']&#xA;    col = ['Day_{}'.format(i) for i in range(days)]&#xA;    dashboard = pd.DataFrame(0, idx, col)&#xA;&#xA;    for h in range(hubs):&#xA;        for driver in range(drivers):&#xA;            for day in range(days):&#xA;                if var[h][driver][day].value() &amp;gt; 0.001:&#xA;                    dashboard.loc[hub_names[h], driver_names[driver]][col[day]] = 1&#xA;&#xA;    # print(dashboard)&#xA;&#xA;    driver_table = dashboard.groupby('Driver').sum()&#xA;    driver_sums = driver_table.sum(axis=1)&#xA;    # print(driver_sums)&#xA;&#xA;    day_sums = driver_table.sum(axis=0)&#xA;    # print(day_sums)&#xA;&#xA;    print(&amp;quot;Status&amp;quot;, pulp.LpStatus[status])&#xA;    return driver_sums, dashboard, status&#xA;&#xA;&#xA;driver_sums, dashboard, status = schedule(total_drivers, total_hubs, day_reqs)&#xA;counter = crosshubbers(dashboard, ['Driver_{}'.format(i) for i in range(total_drivers)])&#xA;while (driver_sums &amp;gt; 6).any() or status == -1 or counter &amp;gt; 0:&#xA;    print('Staus infeasible or cross-hubbers or one or more drivers have been allocated more than 6 '&#xA;          'days of: {}-&amp;gt;{}'.format(total_drivers, total_drivers + 1))&#xA;    print(f'Status: {status}')&#xA;    print(f'Cross - Hubbers: {counter}')&#xA;    if counter == 0:&#xA;        print(f'Driver over limit: {driver_sums[driver_sums &amp;gt; 6].count()}')&#xA;        print(driver_sums[driver_sums &amp;gt; 6])&#xA;        print('\n')&#xA;        print(f'Driver under limit: {driver_sums[driver_sums &amp;lt; 6].count()}')&#xA;        print(driver_sums[driver_sums &amp;lt; 6])&#xA;    print('\n')&#xA;    total_drivers += 1&#xA;    driver_sums, dashboard, status = schedule(total_drivers, total_hubs, day_reqs)&#xA;    counter = crosshubbers(dashboard, ['Driver_{}'.format(i) for i in range(total_drivers)])&#xA;print('########################################################################')&#xA;print('Found solution')&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5220" LastEditorUserId="491" LastEditDate="2021-07-29T16:32:03.920" LastActivityDate="2021-07-29T16:32:03.920" Title="Seeking help in pulp scheduling problem" Tags="|pulp|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6647" PostTypeId="2" ParentId="6641" CreationDate="2021-07-29T18:05:16.047" Score="1" Body="&lt;p&gt;In addition to &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, add a binary variable &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and the constraint &lt;span class=&quot;math-container&quot;&gt;$s + u \le 1$&lt;/span&gt;. The remaining constraints would be&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;x &amp;amp; \le1+M(s+u)\\&#xA;x &amp;amp; \ge s\\&#xA;x &amp;amp; \ge Cu\\&#xA;x &amp;amp; \le C+Mu.&#xA;\end{align*}&lt;/span&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$s=0=u$&lt;/span&gt; this reduces to &lt;span class=&quot;math-container&quot;&gt;$x\le 1$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$s=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$u=0$&lt;/span&gt; and the constraints reduce to &lt;span class=&quot;math-container&quot;&gt;$1\le x\le C$&lt;/span&gt;. Finally, if &lt;span class=&quot;math-container&quot;&gt;$u=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$s=0$&lt;/span&gt; and the constraints become &lt;span class=&quot;math-container&quot;&gt;$C\le x\le 1+M$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As always, there are boundary issues, meaning that &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is ambiguous when &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; and when &lt;span class=&quot;math-container&quot;&gt;$x=C$&lt;/span&gt;. The only way to remove the ambiguity requires that you make values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; slightly less than 1 or slightly greater than &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; infeasible.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-29T18:05:16.047" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6648" PostTypeId="1" AcceptedAnswerId="6657" CreationDate="2021-07-29T18:51:19.127" Score="5" ViewCount="182" Body="&lt;p&gt;Here is a problem I thought of:&lt;/p&gt;&#xA;&lt;p&gt;Suppose there is a car repair shop and 5 mechanics work there. Everyday, new cars arrive at the shop and each mechanic has to choose 3 cars to work on. In short, the mechanics ideally want to choose cars that they think will be both :&lt;/p&gt;&#xA;&lt;p&gt;Easy to work on (i.e. require fewer hours)&lt;/p&gt;&#xA;&lt;p&gt;Pay them well (e.g. suppose the mechanics are paid 50% of the total price the customer pays)&lt;/p&gt;&#xA;&lt;p&gt;The only problem is: the mechanics have no idea how much time any given car will require for repair (let's assume that no one knows this information exactly), nor do they know the amount of money the customers were charged (e.g. let's assume that the owner of the repair shop and the owner of the car negotiate the price in private). When making a decision on which cars to work on, the mechanics only have access to the following information:&lt;/p&gt;&#xA;&lt;p&gt;Total Mileage each car has driven&lt;/p&gt;&#xA;&lt;p&gt;Price that the customer originally purchased the car for&lt;/p&gt;&#xA;&lt;p&gt;However, the mechanics have access to historical data. The mechanics have a dataset that contains all 4 of these variables - for all cars that all mechanics at this shop have serviced since the shop has opened, they have: Total Mileage, Original Price of Car, Number of Hours that were required (can consider this as a &amp;quot;supervised label&amp;quot;), Total Bill that the customer was charged (can consider this as a &amp;quot;supervised label&amp;quot;).&lt;/p&gt;&#xA;&lt;p&gt;On first glance, this problem sort of looks like the &amp;quot;Knapsack Optimization Problem&amp;quot; (&lt;a href=&quot;https://en.wikipedia.org/wiki/Knapsack_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Knapsack_problem&lt;/a&gt;) - however, in the &amp;quot;Knapsack Problem&amp;quot;, we know in advance the &amp;quot;value and cost&amp;quot; (i.e. the &amp;quot;labels&amp;quot;) of each potential item we would like to consider for the knapsack. In this car mechanic problem, we do not know the &amp;quot;labels&amp;quot; - information that will eventually be used for defining/calculating the costs and utility function.&lt;/p&gt;&#xA;&lt;p&gt;Question: Can the mechanics train two separate supervised models (e.g. regression, random forest) on the data that they have, e.g.&lt;/p&gt;&#xA;&lt;p&gt;Model 1: hours_car_requires = f(mileage, original_price)&lt;/p&gt;&#xA;&lt;p&gt;Model 2 : total_bill = g(mileage, original_price)&lt;/p&gt;&#xA;&lt;p&gt;Then, if these models are able to perform well on the training data - they can then use them to predict the &amp;quot;total bill&amp;quot; and the &amp;quot;hours required&amp;quot; for each new car that comes to the repair shop. From here, they could then turn this problem into a &amp;quot;multi objective optimization task&amp;quot; and use optimization algorithms to select cars to work on?&lt;/p&gt;&#xA;&lt;p&gt;Can someone please tell me if this approach that I have described makes sense? Or are there already well established algorithms designed for these kinds of problems? My analogy was that on some abstract level, the mechanics selecting desirable cars to work is the same as choosing portfolios with low risk and high return.&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-04-05T15:39:26.970" LastActivityDate="2022-04-05T15:39:26.970" Title="Optimization When True Costs Are Unknown" Tags="|optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6649" PostTypeId="2" ParentId="6641" CreationDate="2021-07-29T20:26:29.637" Score="5" Body="&lt;p&gt;Use three binary variables &lt;span class=&quot;math-container&quot;&gt;$r,s,t$&lt;/span&gt; for the three intervals and impose linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$r+s+t = 1 \\&#xA;0r+1s+(C+1)t \le x \le 0r+Cs+Mt&#xA;$$&lt;/span&gt;&#xA;Then&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;r = 1 &amp;amp;\implies x = 0 \\&#xA;s = 1 &amp;amp;\implies 1 \le x \le C \\&#xA;t = 1 &amp;amp;\implies C + 1 \le x \le M \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you prefer, treat &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; as a slack variable and instead impose linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$s+t\le 1 \\&#xA;1s+(C+1)t \le x \le Cs+Mt&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-07-29T20:26:29.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6650" PostTypeId="1" AcceptedAnswerId="6654" CreationDate="2021-07-29T22:00:39.730" Score="3" ViewCount="613" Body="&lt;p&gt;I am running a MIP using DOCPLEX that generates several feasible integer solutions during the Branch and Bound search.&lt;/p&gt;&#xA;&lt;p&gt;The node log updates every now and then based on &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=mip-progress-reports-interpreting-node-log&quot; rel=&quot;nofollow noreferrer&quot;&gt;the parameter setting&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, is there a way to report each solution with the elapsed time till that point(i.e. find out the elapsed time everytime a new better bound is found)? I want to generate a report/plot to track how the best integer solution changes over time.&lt;/p&gt;&#xA;" OwnerUserId="5973" LastActivityDate="2021-07-30T09:04:37.150" Title="CPLEX MILP Report all solutions found" Tags="|mixed-integer-programming|docplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6651" PostTypeId="2" ParentId="6650" CreationDate="2021-07-30T00:36:43.650" Score="3" Body="&lt;p&gt;One solution is to add an Incumbent callback (not sure whether DOCPLEX support this yet, but certainly Java/C++), and log the solution + time stamp within the the callback.&lt;/p&gt;&#xA;&lt;p&gt;Another solution which, if my memory service me well, is the following:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Set the &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=parameters-mip-integer-solution-limit&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIP integer solution limit&lt;/a&gt; to 1 (IntSolLim parameter in Cplex &amp;lt;=12.6).&lt;/li&gt;&#xA;&lt;li&gt;Invoke solve(). Cplex will return as soon as it finds a solution&lt;/li&gt;&#xA;&lt;li&gt;Log the solution and its timestamp.&lt;/li&gt;&#xA;&lt;li&gt;Re-invoke solve(). Cplex will continue its search from the previous solution. Repeat until no more solutions can be found, in which case the Cplex status will be 'optimal'. Obviously you would program this in a simple loop.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-07-30T00:36:43.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6652" PostTypeId="2" ParentId="6640" CreationDate="2021-07-30T07:07:41.180" Score="5" Body="&lt;p&gt;The instances you plan to solve are orders of magnitude larger than the ones from the datasets used in the scientific literature on the Generalized Assignment Problem. The largest instances of the literature have &lt;span class=&quot;math-container&quot;&gt;$m = 80$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n = 1600$&lt;/span&gt;. Most algorithms designed for these instances won't be suitable for you.&lt;/p&gt;&#xA;&lt;p&gt;What seems the most relevant in your case are the polynomial algorithms described in &amp;quot;Knapsack problems: algorithms and computer implementations&amp;quot; (Martello et Toth, 1990):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Greedy: sort all agent-task pairs according to a given criterion, and then assign greedily from best to worst the unassigned tasks. Complexity: &lt;span class=&quot;math-container&quot;&gt;$O(n m \log (n m))$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Regret greedy: for all tasks, sort its assignments according to a given criterion. At each step, assign the task with the greatest difference between its best assignment and its second-best assignment, and update the structures. Complexity: &lt;span class=&quot;math-container&quot;&gt;$O(n m \log m + n^2)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Various sorting criteria have been proposed: &lt;code&gt;pij&lt;/code&gt;, &lt;code&gt;pij/wij&lt;/code&gt;, &lt;code&gt;-wij&lt;/code&gt;, &lt;code&gt;-wij/ti&lt;/code&gt;... &lt;code&gt;-wij&lt;/code&gt; and &lt;code&gt;-wij/ti&lt;/code&gt; are more suited for the case where all items have to be assigned. In your case &lt;code&gt;pij&lt;/code&gt; and &lt;code&gt;pij/wij&lt;/code&gt; might yield good results&lt;/p&gt;&#xA;&lt;p&gt;Then, they propose to try to shift each task once to improve the solution. With at most one shift per task, the algorithms remain polynomial, but you can try more shifts if you have more time.&lt;/p&gt;&#xA;&lt;p&gt;Note that these algorithms might be optimized if not all pairs are possible, as you indicate in your case.&lt;/p&gt;&#xA;&lt;p&gt;I have some implementations &lt;a href=&quot;https://github.com/fontanf/generalizedassignmentsolver&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; for the standard GAP (and a min objective). You can try to play with them to get an overview of what might work or not in your case&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2021-07-30T07:07:41.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6653" PostTypeId="1" AcceptedAnswerId="6660" CreationDate="2021-07-30T07:49:52.130" Score="2" ViewCount="835" Body="&lt;p&gt;I am trying to solve the following problem:&lt;/p&gt;&#xA;&lt;p&gt;I have a set of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; requests that must be processed by vehicles. I do not know the locations of these requests. Requests can be processed by a same vehicle, and this vehicle can perform multiple trips, subject to capacity and time constraints which I will detail below. Also, the number of requests that are processed together (in one trip) must always be the same (and this number does not have to be an integer). I need to minimize the number of vehicles required to process all requests.&lt;/p&gt;&#xA;&lt;p&gt;Here is a more formal description of the problem.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$1 \le x\le N$&lt;/span&gt;) denote the number of requests that are processed in one trip&lt;/li&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$y_i \in \{0,1\}$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if vehicle &lt;span class=&quot;math-container&quot;&gt;$i \in V$&lt;/span&gt; is used. &lt;span class=&quot;math-container&quot;&gt;$|V|$&lt;/span&gt; is assumed to be large enough.&lt;/li&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$n_i \in \mathbb{N}$&lt;/span&gt; be the number of trips performed by vehicle &lt;span class=&quot;math-container&quot;&gt;$i \in V$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The number of used vehicles is minimized:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \; \sum_{i \in V} y_i&#xA;$$&lt;/span&gt;&#xA;subject to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Capacity constraints&lt;/strong&gt;: each request has a unit demand of &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt;, and the total demand in a vehicle must not exceed the vehicles capacity &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;qx \le Q&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Time constraints&lt;/strong&gt;: it takes &lt;span class=&quot;math-container&quot;&gt;$(ax+b)$&lt;/span&gt; units of time to perform one trip (&lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; are constants), and the total duration (including all trips) must not exceed some constant &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA; n_i (ax+b) \le T y_i \quad \forall i \in V&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;All requests must be processed:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x \sum_{i \in V} n_i = N&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For some reason, I think the problem is not well posed, and I am looking for ways to improve it. For starters, it is not linear (and not trivial (?)) to linearize. I could solve it as a real routing problem with random positions of the &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; points, but I don't think this is a good approach either, as &lt;span class=&quot;math-container&quot;&gt;$|N|$&lt;/span&gt; can be very large. I would like to keep it &amp;quot;high level&amp;quot; if possible.&lt;/p&gt;&#xA;&lt;p&gt;I am hoping that I am missing something obvious. Does the above formulation make sense ? And is there anyway to improve it, or linearize it? Any other approach is welcome.&lt;/p&gt;&#xA;&lt;p&gt;Thanks for any help !&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;An example to make things as clear as possible: &lt;span class=&quot;math-container&quot;&gt;$N=\{u,v,w\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$q=Q=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$T=2$&lt;/span&gt;. In this case, &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt;, one vehicle can process &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; in two trips. Another can process &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; in one trip.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Time constraints have been partially linearized based on @RobPratt's answer.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-07-30T14:58:18.457" LastActivityDate="2021-07-30T14:58:18.457" Title="How to compute the minimum number of vehicles required" Tags="|optimization|modeling|vehicle-routing|algorithms|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6654" PostTypeId="2" ParentId="6650" CreationDate="2021-07-30T09:04:37.150" Score="4" Body="&lt;p&gt;In &lt;a href=&quot;https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Making optimization simple (Python)&lt;/a&gt; I gave 2 options:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/AlexFleischerParis/zoodocplex/blob/master/zooprogresslistener.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;progress listener / MIP info callback&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/AlexFleischerParis/zoodocplex/blob/master/zoogetsolutiononebyone.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;get solutions one by one&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The models:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;from docplex.mp.progress import *&#xA;&#xA;mdl = Model(name='buses')&#xA;nbbus40 = mdl.integer_var(name='nbBus40')&#xA;nbbus30 = mdl.integer_var(name='nbBus30')&#xA;mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;mdl.minimize(nbbus40*500 + nbbus30*400)&#xA;&#xA;class pl(ProgressListener):&#xA;  &#xA;    def __init__(self):&#xA;        ProgressListener.__init__(self, ProgressClock.Gap)&#xA;    &#xA;    def notify_progress(self, pdata):&#xA;        gap = pdata.mip_gap&#xA;        ms_time = 1000* pdata.time&#xA;        print('-- new gap: {0:.1%}, time: {1:.0f} ms'.format(gap, ms_time))&#xA;        &#xA;&#xA;# connect a listener to the model&#xA;mdl.add_progress_listener(pl())&#xA;&#xA;mdl.solve(log_output=False,)&#xA;&#xA;mdl.export(&amp;quot;c:\\temp\\buses.lp&amp;quot;)&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and the second one:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;from docplex.mp.progress import *&#xA;&#xA;mdl = Model(name='buses')&#xA;nbbus40 = mdl.integer_var(name='nbBus40')&#xA;nbbus30 = mdl.integer_var(name='nbBus30')&#xA;mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;mdl.minimize(nbbus40*500 + nbbus30*400)&#xA;&#xA;mdl.parameters.mip.limits.solutions=1&#xA;&#xA;while (1==1):&#xA;    sol=mdl.solve(log_output=False)&#xA;    for v in mdl.iter_integer_vars():&#xA;       print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&#xA;    print(&amp;quot;objective = &amp;quot;,sol.get_objective_value())&#xA;    print(&amp;quot;best bound = &amp;quot;,mdl.solve_details.best_bound)&#xA;    print(&amp;quot;mip gap = &amp;quot;,mdl.solve_details.mip_relative_gap)  &#xA;       &#xA;    print(&amp;quot;status : &amp;quot;,mdl.solve_details.status)   &#xA;    if (&amp;quot;optimal solution&amp;quot; in str(mdl.solve_details.status)):&#xA;        break&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-07-30T09:04:37.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6655" PostTypeId="1" CreationDate="2021-07-30T09:13:48.417" Score="2" ViewCount="428" Body="&lt;p&gt;I have an MILP model, say&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rl}&#xA;\mbox{minimize} &amp;amp;f_1(x) + f_2(x)\\&#xA;\mbox{subject to} &amp;amp;x\in X&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;which is hard to solve. And I find it simple to solve the two problems below (&lt;span class=&quot;math-container&quot;&gt;$i=1,2$&lt;/span&gt;)&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rl}&#xA;\mbox{minimize} &amp;amp;f_i(x)\\&#xA;\mbox{subject to} &amp;amp;x\in X&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;Let's say the optimal objective value is &lt;span class=&quot;math-container&quot;&gt;$LB_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$LB_2$&lt;/span&gt;, respectively. Then &lt;span class=&quot;math-container&quot;&gt;$LB_1+LB_2$&lt;/span&gt; becomes a lower bound of the original problem. I find that in my case, the final relaxation bound of the original problem within the timelimit seems always worse than my bound, but that doesn't mean my bound can help solve the problem. The only way I think I can do to utilize it is something like&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rl}&#xA;\mbox{minimize} &amp;amp;f_1(x) + f_2(x)\\&#xA;\mbox{subject to} &amp;amp;x\in X\\&#xA;&amp;amp;f_1(x) \geq LB_1\\&#xA;&amp;amp;f_2(x) \geq LB_2&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;But that neither helps find better feasible solution (unpredictable I think?) nor further increase the objective of relaxed problem to a higher bound.&lt;/p&gt;&#xA;&lt;p&gt;Does that mean this bound is useless to this model (other than improving the gap, which could be done posterior anyway)?&lt;/p&gt;&#xA;&lt;p&gt;Edit: Maybe I should provide some more information about the model.&lt;/p&gt;&#xA;&lt;p&gt;The variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is like a permutation matrix for sorting, or variables in assignment problem. It gives out a sequence like &amp;quot;ABBAABA&amp;quot;, and &lt;span class=&quot;math-container&quot;&gt;$f_i(x)$&lt;/span&gt;'s are some complex functions to evaluate the sequence, with some more (integer or continuous) variables and constraints which is not shown above.&lt;/p&gt;&#xA;&lt;p&gt;Differents evaluation standards conflict with each other. The bound above describes how good it could be if there is no conflicts.&lt;/p&gt;&#xA;&lt;p&gt;Feasible solutions are easy to find for the solver (although I don't know how good they really are), but the bound is hard to improve. So the main concern for me is to improve the bound, or 'to prove there must be conflicts'.&lt;/p&gt;&#xA;&lt;p&gt;Thanks for all your answers and advices, and I think decomposition methods is what I should try.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastEditorUserId="4569" LastEditDate="2021-08-03T07:38:54.210" LastActivityDate="2021-08-03T07:38:54.210" Title="Does a pre-calculated lower bound of an MILP problem help?" Tags="|mixed-integer-programming|multi-objective-optimization|optimality-gap|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6656" PostTypeId="2" ParentId="6655" CreationDate="2021-07-30T10:34:58.453" Score="2" Body="&lt;p&gt;There are different approaches to solve MILP problems since you didn't mention what kind of solver you are using i assume you mean in context of branch and bound solver.&lt;/p&gt;&#xA;&lt;p&gt;Feasible solutions are found using a feasibility pump which tries to guess a low feasible solution.The feasibility pump could be positively affected by those additional constraints as a part of the relaxation is cut. However you also grew the size of constraint matrix which could make all the linear algebra slower.&lt;/p&gt;&#xA;&lt;p&gt;About the bounds of the relaxations i want to note that if your objective is linear (as MILP suggests) the solver can derive this additive structure of the sub-objectives itself. If the MILP algorithm authors found that this strategy gives benefits they could have added such functionality internally and chosen along which variables to split based on information that became available at solve time. What you are accomplishing with precalculating those bounds on the partial objective beforehand is that you make the presolver and the root node aware of this information. However this information is more worthless than you might think initially if the variables that go into &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt; interact as it the partial configurations that lead to &lt;span class=&quot;math-container&quot;&gt;$LB_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$LB_2$&lt;/span&gt; might be incompatible with regard to the constraints to lead to both. However a constraint of the type:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f_1(x) + f_2(x) \geq LB_1 + LB_2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;might help the solver when a solution &lt;span class=&quot;math-container&quot;&gt;$f_1(x) + f_2(x) = LB_1 + LB_2$&lt;/span&gt; is found, as it is be able to stop at this moment while without this information it might explore some more regions whose relaxation goes lower.&lt;/p&gt;&#xA;&lt;h3&gt;Summary&lt;/h3&gt;&#xA;&lt;p&gt;Unless you have good reason to suspect that your arbitrary division into &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt; reveals the minimum of the hard problem to be &lt;span class=&quot;math-container&quot;&gt;$LB_1 + LB_2$&lt;/span&gt; i wouldn't give the solver this information as to a linear solver this separability is obvious and it could decide to exploit it if it is sufficiently clever.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-07-30T10:42:58.323" LastActivityDate="2021-07-30T10:42:58.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6657" PostTypeId="2" ParentId="6648" CreationDate="2021-07-30T11:04:22.150" Score="4" Body="&lt;p&gt;Your approach is sensible. Knapsack can be thought of as a multi-objective problem being solved by the &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-constraint method and to uncover the complete pareto front you need to vary how much hours are interested in working.&lt;/p&gt;&#xA;&lt;p&gt;Here are things to consider:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If there are clearly preferable cars the workers might want to work on it exclusively. This is not possible. So you are left in a situation where have 2 (time spent and money earned) times 5 (workers) competing objectives you need to balance&lt;/li&gt;&#xA;&lt;li&gt;The workers are being assigned new cars every day, so you are solving the problem repeatedly and therefor need to assign cars such that assignments in total are seen as fair by the workers, otherwise one might leave since he only got unpreferable assignments.&lt;/li&gt;&#xA;&lt;li&gt;Since your estimate is uncertain, if you are able to construct a model of your estimates (for example a bayesian) that captures this uncertainty you could do robust optimization to distribute uncertainty such that no worker risk working many more hours than he wants to or getting paid an unpredictable amount.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-07-30T11:04:22.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6658" PostTypeId="2" ParentId="6643" CreationDate="2021-07-30T11:17:35.227" Score="2" Body="&lt;p&gt;The property that some infinitesimal change in one of the constraints impacts the objective is called &amp;quot;a constraint being active&amp;quot; or &amp;quot;a constraint being in conflict with the objective&amp;quot;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;if we increase &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; arbitrarily small, we can also bound the change in the optimal objective value with an arbitrarily small change.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This property is called &amp;quot;the objective being lipschitz continuous with regard to &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;&amp;quot;. In my intuition this should hold all LPs that have a non empty simplex. If you push &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; so that the simplex becomes empty you can't reason about the meaning of the objective.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Take &lt;span class=&quot;math-container&quot;&gt;$b_1 &amp;gt; 0$&lt;/span&gt;, and denote &lt;span class=&quot;math-container&quot;&gt;$OPT_1$&lt;/span&gt; as the optimal objective value when the above problem has &lt;span class=&quot;math-container&quot;&gt;$b_1$&lt;/span&gt; on the right-hand side of the constraint. For any &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt;, there exists some &lt;span class=&quot;math-container&quot;&gt;$b_2 &amp;lt; b_1$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$OPT_2 - OPT_1 &amp;lt; \epsilon$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$b_2$&lt;/span&gt; is a function of &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$OPT_2$&lt;/span&gt; denotes the optimal objective value of the above LP when the right-hand side is &lt;span class=&quot;math-container&quot;&gt;$b_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This property is called &amp;quot;the objective being continuous with regard to &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;&amp;quot; and is implied by the former under the same concerns of the simplex being non empty.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-07-30T11:31:50.093" LastActivityDate="2021-07-30T11:31:50.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6659" PostTypeId="2" ParentId="6605" CreationDate="2021-07-30T11:23:30.270" Score="6" Body="&lt;p&gt;Small businesses are often so small that the investment of modeling business processes is not worth it, however an extraordinary amount of money is left on the table when you consider the impact of the small put together. The lack of optimization is often picked up by more hours put in by the owner.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-07-30T11:23:30.270" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6660" PostTypeId="2" ParentId="6653" CreationDate="2021-07-30T14:07:36.060" Score="2" Body="&lt;p&gt;As an approximation, suppose that the &lt;em&gt;number&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; of requests per trip does need to be an integer.  Then &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; needs to be at most &lt;span class=&quot;math-container&quot;&gt;$Q/q$&lt;/span&gt; and divide &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;.  For each fixed&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x\in\{1,\dots,\min(N,\lfloor Q/q \rfloor): x \mid N\},$$&lt;/span&gt;&#xA;minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in V} y_i$&lt;/span&gt; subject to linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(ax+b)n_i &amp;amp;\le T y_i &amp;amp;&amp;amp;\text{for $i\in V$} \\&#xA;x \sum_{i\in V} n_i &amp;amp;= N&#xA;\end{align}&lt;/span&gt;&#xA;Keep whichever &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; yields the best objective value.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-07-30T14:14:49.577" LastActivityDate="2021-07-30T14:14:49.577" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6661" PostTypeId="1" CreationDate="2021-07-30T15:09:15.890" Score="0" ViewCount="166" Body="&lt;p&gt;I have the following MILP:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{2}&#xA; \nonumber \mbox{minimize } \quad  &amp;amp; \phi = \sum_{i=1}^{m-1} \sum_{f=1}^{F} \sum_{\underset{\bar{f} \neq f}{\bar{f}=1}}^F \sum_{h \in H}  \left( D_{f \bar{f}} \cdot \gamma_{i\bar{f}h} \cdot \gamma_{i+1,f,h} \right) \quad &amp;amp; + &amp;amp; \quad \sum_{f=1}^{F} \sum_{h \in H}  D_f^0 \cdot \left( \gamma_{1fh} + \gamma_{mfh} \right)  +  \\&#xA;          &amp;amp; \quad + \sum_{i=1}^{m-1} \sum_{f=1}^F \sum_{h \in H} D_f^0 \left[ \gamma_{i+1,f,h} \cdot \left( 1 - \sum_{\bar{f}=1}^F \gamma_{i \bar{f} h} \right)   \right] &amp;amp;+&amp;amp; \sum_{i=1}^{m-1} \sum_{f=1}^F \sum_{h \in H} D_f^0 \left[ \gamma_{i,f,h} \cdot \left( 1 - \sum_{\bar{f}=1}^F \gamma_{i+1, \bar{f}, h} \right)   \right]   \label{obj3}\\&#xA; \mbox{subject to} &amp;amp;&#xA;                   &amp;amp;&amp;amp; \nonumber \\&#xA;                   &amp;amp; \sum_{\ell \in B_j} g^A_{j \ell}\cdot w_{j \ell} = g^*_j + d_j^+ - d_j^-, &amp;amp;&amp;amp; \quad j=1,...,k \label{grausdias1}\\&#xA;                   &amp;amp; \sum_{\ell \in B_j} w_{j \ell} = 1           &amp;amp;&amp;amp; \quad j=1,...,k \label{grausdias2}\\&#xA;                   &amp;amp; t_j = \sum_{\ell \in B_j}  \ell \cdot w_{j \ell}  &amp;amp;&amp;amp; \quad j=1,...,k \label{tj1}\\&#xA;                   &amp;amp;  t_j + t^0_j = \sum_{i=1}^m T_i \cdot x_{ij},       &amp;amp;&amp;amp; \quad j=1,...,k \label{tj2}\\&#xA;                   &amp;amp; \sum_{i=1}^m  x_{ij} =1,                    &amp;amp;&amp;amp; \quad j=1,...,k \label{umacolheita}\\&#xA;                   &amp;amp; \sum_{j=1}^k  P_j \cdot L_j \cdot x_{ij} \geq d_i, &amp;amp;&amp;amp; \quad i=1,...,m \label{demanda}\\&#xA;%                   &amp;amp; \sum_{f \in F} y_{if} \leq \theta,                 &amp;amp;&amp;amp; \quad i=1,...,m, \label{maxfaz}\\&#xA;                   &amp;amp; \sum_{j = 1}^k z_{ijh}  \leq 1          &amp;amp;&amp;amp; \quad i=1,....,m, \quad h \in H \label{maxumamaquina}\\&#xA;                   &amp;amp; x_{ij} \leq y_{if},                         &amp;amp;&amp;amp; \quad i=1,...,m, \quad  j\in J_f, \quad f=1,...,F \label{ligacao1_x_e_y}\\&#xA;                   &amp;amp; y_{if} \leq \sum_{j \in J_f} x_{ij},         &amp;amp;&amp;amp; \quad i=1,...,m, \quad f=1,...,F \label{ligacao2_x_e_y}\\&#xA;                   &amp;amp; z_{ijh} \leq y_{if}                      &amp;amp;&amp;amp; \quad i=1,....,m, \quad h \in H, \quad f=1,...,F, \quad j \in J_f \label{ligacao_z_e_y}\\&#xA;                   &amp;amp; x_{ij} \leq \sum_{h \in H} z_{ijh}                      &amp;amp;&amp;amp; \quad i=1,....,m, \quad j \in 1,...,k \label{ligacao1_x_e_z}\\&#xA;                   &amp;amp; \sum_{h \in H} z_{ijh} \leq |H| \cdot x_{ij}            &amp;amp;&amp;amp; \quad i=1,....,m, \quad j \in 1,...,k \label{ligacao2_x_e_z}\\&#xA;                   &amp;amp; \sum_{i=1}^m \sum_{h \in H}  \left( L^{max}_i  \cdot C_h \cdot z_{ijh} \right) - e_j = P_j \cdot L_j    &amp;amp;&amp;amp; \quad j=1,...,k \label{colheita_talhao}\\&#xA;                   &amp;amp; \sum_{j \in J_f}   z_{ijh} = \gamma_{ifh}    &amp;amp;&amp;amp; \quad i=1,...,m, \quad f=1,...,F, \quad h \in H \label{def_gamma}\\&#xA;                   &amp;amp;x_{ij} \in \{0,1\}, \ y_{if} \in \{0,1\}, \ z_{ijh} \in \{0,1\}   &amp;amp;&amp;amp; \quad i=1,...,m, \quad j=1,...,k, \quad f=1,...,F, \quad h \in H \label{var_xyz}\\&#xA;                  &amp;amp;  w_{j\ell} \in \{0,1\}, \ \ t_j \geq 0   &amp;amp;&amp;amp; \quad j=1,...,k, \quad \ell \in B_j \label{var_gammat}\\&#xA;                   &amp;amp; \gamma_{ifh} \in \{0,1\}, \ \ d_j^+ \geq 0, \ \ d_j^- \geq 0            &amp;amp;&amp;amp; \quad i=1,...,m, \quad j=1,...,k, \quad f=1,...,F, \quad h \in H \label{var_wd}\\&#xA;                   &amp;amp;  0\leq e_j \leq  \min_{\substack{h \in H \\ i \in \{1,...,m\}}} \{C_h \cdot L^{max}_i\} - \varepsilon &amp;amp;&amp;amp; \quad j = 1,...,k.  \label{var_e}          &#xA;\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;the variables &lt;span class=&quot;math-container&quot;&gt;$\gamma_{ifh} \in \{0,1\}$&lt;/span&gt;. I have linerized the objective function using the constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{2}&#xA;&amp;amp; \gamma_{i\bar{f}h} + \gamma_{i+1,f,h} - u_{if\bar{fh}} \leq 1, &amp;amp;&amp;amp;  \quad i=1,...,m,\, \quad f=1,...,F, \quad \bar{f} \in \{1,...,F\} \setminus f, \quad h \in H \label{linearizacao1} \\  &#xA;&amp;amp; u_{if\bar{fh}}  \leq  \gamma_{i\bar{f}h}, &amp;amp;&amp;amp; \quad i=1,...,m,\, \quad f=1,...,F, \quad \bar{f} \in \{1,...,F\} \setminus f, \quad h \in H \label{linearizacao2} \\&#xA;&amp;amp; u_{if\bar{fh}}  \leq  \gamma_{i+1,f,h} &amp;amp;&amp;amp; \quad i=1,...,m,\, \quad f=1,...,F, \quad \bar{f} \in \{1,...,F\} \setminus f, \quad h \in H. \label{linearizacao3} &#xA;\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\{0,1\} \ni u_{if\bar{fh}} = \gamma_{i\bar{f}h} \cdot \gamma_{i+1,f,h}$&lt;/span&gt; Then I have a linerized version of the model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{2}&#xA; \nonumber  &amp;amp; \phi^L = \sum_{i=1}^{m-1} \sum_{f=1}^{F} \sum_{\underset{\bar{f} \neq f}{\bar{f}=1}}^F \sum_{h \in H}  \left( D_{f \bar{f}} \cdot u_{i,f,\bar{f},h} \right) + \sum_{f=1}^{F} \sum_{h \in H}  D_f^0 \cdot \left( \gamma_{1fh} + \gamma_{mfh} \right)\\&#xA; \nonumber          &amp;amp; \quad + \sum_{i=1}^{m-1} \sum_{f=1}^F \sum_{h \in H} D_f^0 \left( \gamma_{i+1,f,h} -  \sum_{\bar{f}=1}^F u_{i,f,\bar{f},h} \right)\\    &#xA;          &amp;amp; \quad + \sum_{i=1}^{m-1} \sum_{f=1}^F \sum_{h \in H} D_f^0 \left( \gamma_{i,f,h} -  \sum_{\bar{f}=1}^F u_{i,\bar{f},f,h} \right)&#xA;\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, when I apply the gurobi solver with default parameters setting, I have this strange report.&lt;/p&gt;&#xA;&lt;p&gt;The lower bound and integrality gap are terrible. Any hints to deal with this situation? Any parameters to set to improve this lower bound?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;Academic license - for non-commercial use only - expires 2021-08-04&#xA;Gurobi Optimizer version 9.1.1 build v9.1.1rc0 (win64)&#xA;Thread count: 6 physical cores, 12 logical processors, using up to 12 threads&#xA;Optimize a model with 85788 rows, 62396 columns and 393896 nonzeros&#xA;Model fingerprint: 0x52171686&#xA;Variable types: 3180 continuous, 59216 integer (59116 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [1e+00, 4e+03]&#xA;  Objective range  [1e+00, 9e+01]&#xA;  Bounds range     [4e+03, 4e+03]&#xA;  RHS range        [1e+00, 2e+04]&#xA;Presolve removed 44504 rows and 25844 columns&#xA;Presolve time: 0.72s&#xA;Presolved: 41284 rows, 36552 columns, 162873 nonzeros&#xA;Variable types: 0 continuous, 36552 integer (36552 binary)&#xA;&#xA;Deterministic concurrent LP optimizer: primal and dual simplex&#xA;Showing first log only...&#xA;&#xA;Concurrent spin time: 0.00s&#xA;&#xA;Solved with dual simplex&#xA;&#xA;Root relaxation: objective -1.863828e+04, 2873 iterations, 0.16 seconds&#xA;&#xA;    Nodes    |    Current Node    |     Objective Bounds      |     Work    &#xA; Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time&#xA;&#xA;     0     0 -18638.276    0 1403          - -18638.276      -     -    6s  &#xA;     0     0 -18595.473    0 1535          - -18595.473      -     -   11s&#xA;     0     0 -18560.477    0 1554          - -18560.477      -     -   12s&#xA;     0     0 -18559.369    0 1617          - -18559.369      -     -   16s&#xA;     0     0 -18556.823    0 1641          - -18556.823      -     -   17s&#xA;     0     0 -18547.137    0 1674          - -18547.137      -     -   17s&#xA;     0     0 -18546.400    0 1587          - -18546.400      -     -   17s&#xA;     0     0 -18545.283    0 1593          - -18545.283      -     -   17s&#xA;     0     0 -18545.283    0 1593          - -18545.283      -     -   17s&#xA;     0     0 -18544.704    0 1622          - -18544.704      -     -   21s&#xA;     0     0 -18543.019    0 1646          - -18543.019      -     -   23s&#xA;     0     0 -18522.569    0 1906          - -18522.569      -     -   24s&#xA;     0     0 -18515.349    0 1603          - -18515.349      -     -   25s&#xA;     0     0 -18510.954    0 1652          - -18510.954      -     -   25s&#xA;     0     0 -18509.118    0 1610          - -18509.118      -     -   25s&#xA;     0     0 -18509.101    0 1619          - -18509.101      -     -   26s&#xA;     0     0 -18026.647    0 3639          - -18026.647      -     -   34s&#xA;     0     0 -17706.742    0 3776          - -17706.742      -     -   40s&#xA;H    0     0                    4887.5398664 -17706.742   462%     -   43s&#xA;     0     0 -17672.544    0 3286 4887.53987 -17672.544   462%     -   43s&#xA;     0     0 -17647.869    0 3017 4887.53987 -17647.869   461%     -   44s&#xA;     0     0 -17636.426    0 2509 4887.53987 -17636.426   461%     -   45s&#xA;     0     0 -17634.253    0 2136 4887.53987 -17634.253   461%     -   45s&#xA;     0     0 -17631.840    0 2226 4887.53987 -17631.840   461%     -   45s&#xA;     0     0 -17626.992    0 2151 4887.53987 -17626.992   461%     -   46s&#xA;     0     0 -17626.655    0 2086 4887.53987 -17626.655   461%     -   46s&#xA;H    0     0                    2920.7576221 -17626.655   703%     -   56s&#xA;H    0     0                    2813.7406641 -17626.655   726%     -   56s&#xA;     0     0 -17153.247    0 4004 2813.74066 -17153.247   710%     -   57s&#xA;H    0     0                    2796.6752197 -17153.247   713%     -   58s&#xA;H    0     0                    2701.3257781 -17153.247   735%     -   67s&#xA;H    0     0                    2358.2463329 -17153.247   827%     -   67s&#xA;     0     0 -16903.798    0 4572 2358.24633 -16903.798   817%     -   68s&#xA;     0     0 -16804.658    0 4427 2358.24633 -16804.658   813%     -   76s&#xA;     0     0 -16781.521    0 4534 2358.24633 -16781.521   812%     -   78s&#xA;     0     0 -16767.143    0 4766 2358.24633 -16767.143   811%     -   81s&#xA;H    0     0                    2144.9390245 -16767.143   882%     -   83s&#xA;     0     0 -16760.105    0 5090 2144.93902 -16760.105   881%     -   84s&#xA;     0     0 -16755.294    0 4526 2144.93902 -16755.294   881%     -   87s&#xA;     0     0 -16749.748    0 4786 2144.93902 -16749.748   881%     -   89s&#xA;     0     0 -16747.830    0 4238 2144.93902 -16747.830   881%     -   91s&#xA;     0     0 -16747.582    0 4266 2144.93902 -16747.582   881%     -   91s&#xA;H    0     0                    2056.6362893 -16747.582   914%     -  123s&#xA;     0     0 -15620.481    0 4811 2056.63629 -15620.481   860%     -  123s&#xA;H    0     0                    2054.7356332 -15620.481   860%     -  143s&#xA;H    0     0                    2006.0886369 -15620.481   879%     -  143s&#xA;H    0     0                    1940.0886369 -15620.481   905%     -  143s&#xA;     0     0 -15265.905    0 4957 1940.08864 -15265.905   887%     -  143s&#xA;     0     0 -15062.413    0 5136 1940.08864 -15062.413   876%     -  149s&#xA;H    0     0                    1914.3523105 -15062.413   887%     -  154s&#xA;     0     0 -14930.548    0 5110 1914.35231 -14930.548   880%     -  154s&#xA;     0     0 -14847.596    0 5048 1914.35231 -14847.596   876%     -  156s&#xA;     0     0 -14828.768    0 4925 1914.35231 -14828.768   875%     -  159s&#xA;H    0     0                    1832.7541387 -14828.768   909%     -  163s&#xA;     0     0 -14808.250    0 5202 1832.75414 -14808.250   908%     -  163s&#xA;     0     0 -14793.917    0 5175 1832.75414 -14793.917   907%     -  166s&#xA;     0     0 -14784.247    0 4960 1832.75414 -14784.247   907%     -  167s&#xA;     0     0 -14780.462    0 4991 1832.75414 -14780.462   906%     -  168s&#xA;     0     0 -14777.435    0 5152 1832.75414 -14777.435   906%     -  168s&#xA;     0     0 -14771.757    0 5369 1832.75414 -14771.757   906%     -  169s&#xA;     0     0 -14767.884    0 5635 1832.75414 -14767.884   906%     -  170s&#xA;     0     0 -14766.518    0 5298 1832.75414 -14766.518   906%     -  170s&#xA;H    0     0                    1786.0598405 -14766.518   927%     -  189s&#xA;     0     0 -13825.179    0 4878 1786.05984 -13825.179   874%     -  189s&#xA;     0     0 -13565.430    0 5955 1786.05984 -13565.430   860%     -  209s&#xA;     0     0 -13408.977    0 5673 1786.05984 -13408.977   851%     -  225s&#xA;H    0     0                    1747.5341110 -13408.977   867%     -  238s&#xA;     0     0 -13309.643    0 5229 1747.53411 -13309.643   862%     -  238s&#xA;     0     0 -13250.792    0 5691 1747.53411 -13250.792   858%     -  245s&#xA;     0     0 -13227.110    0 5660 1747.53411 -13227.110   857%     -  249s&#xA;     0     0 -13193.397    0 5240 1747.53411 -13193.397   855%     -  256s&#xA;     0     0 -13181.822    0 5244 1747.53411 -13181.822   854%     -  259s&#xA;     0     0 -13177.755    0 5178 1747.53411 -13177.755   854%     -  260s&#xA;     0     0 -13171.537    0 5484 1747.53411 -13171.537   854%     -  262s&#xA;     0     0 -13166.443    0 5290 1747.53411 -13166.443   853%     -  265s&#xA;     0     0 -13158.052    0 5109 1747.53411 -13158.052   853%     -  270s&#xA;     0     0 -13154.900    0 5784 1747.53411 -13154.900   853%     -  271s&#xA;     0     0 -13154.628    0 5758 1747.53411 -13154.628   853%     -  272s&#xA;     0     0 -12294.741    0 5852 1747.53411 -12294.741   804%     -  324s&#xA;     0     0 -12036.908    0 5254 1747.53411 -12036.908   789%     -  349s&#xA;H    0     0                    1710.0011502 -12036.908   804%     -  371s&#xA;     0     0 -11906.954    0 6071 1710.00115 -11906.954   796%     -  371s&#xA;     0     0 -11843.360    0 5578 1710.00115 -11843.360   793%     -  383s&#xA;     0     0 -11818.107    0 5663 1710.00115 -11818.107   791%     -  388s&#xA;     0     0 -11795.351    0 5879 1710.00115 -11795.351   790%     -  393s&#xA;     0     0 -11777.921    0 5787 1710.00115 -11777.921   789%     -  399s&#xA;     0     0 -11764.912    0 5677 1710.00115 -11764.912   788%     -  403s&#xA;     0     0 -11760.378    0 5493 1710.00115 -11760.378   788%     -  405s&#xA;     0     0 -11758.945    0 5456 1710.00115 -11758.945   788%     -  406s&#xA;H    0     0                    1667.9113449 -11758.945   805%     -  451s&#xA;H    0     0                    1650.0106968 -11758.945   813%     -  451s&#xA;     0     0 -11069.754    0 6343 1650.01070 -11069.754   771%     -  452s&#xA;     0     0 -10884.656    0 5984 1650.01070 -10884.656   760%     -  498s&#xA;     0     0 -10785.902    0 6296 1650.01070 -10785.902   754%     -  511s&#xA;     0     0 -10746.495    0 5987 1650.01070 -10746.495   751%     -  520s&#xA;     0     0 -10731.553    0 6267 1650.01070 -10731.553   750%     -  526s&#xA;     0     0 -10721.912    0 5193 1650.01070 -10721.912   750%     -  531s&#xA;     0     0 -10715.129    0 5691 1650.01070 -10715.129   749%     -  536s&#xA;     0     0 -10710.195    0 6033 1650.01070 -10710.195   749%     -  543s&#xA;H    0     0                    1630.3646881 -10710.195   757%     -  572s&#xA;H    0     0                    1607.8503360 -10710.195   766%     -  572s&#xA;     0     0 -10385.912    0 5271 1607.85034 -10385.912   746%     -  572s&#xA;H    0     0                    1552.8515166 -10385.912   769%     -  573s&#xA;H    0     0                    1517.6361485 -10385.912   784%     -  593s&#xA;     0     0 -10294.225    0 6356 1517.63615 -10294.225   778%     -  593s&#xA;     0     0          -    0      1517.63615 -10294.225   778%     -  600s&#xA;&#xA;Cutting planes:&#xA;  Gomory: 136&#xA;  Cover: 10766&#xA;  Clique: 1179&#xA;  MIR: 33&#xA;  StrongCG: 2&#xA;  GUB cover: 157&#xA;  Zero half: 773&#xA;  RLT: 682&#xA;  BQP: 36&#xA;&#xA;Explored 1 nodes (524614 simplex iterations) in 600.10 seconds&#xA;Thread count was 12 (of 12 available processors)&#xA;&#xA;Solution count 10: 1517.64 1552.85 1607.85 ... 1832.75&#xA;&#xA;Time limit reached&#xA;Best objective 1.517636148458e+03, best bound -1.029422492545e+04, gap 778.3065%&#xA;&#xA;User-callback calls 45491, time in user-callback 0.08 sec&#xA;'''&#xA;&#xA;&#xA;  [1]: https://i.stack.imgur.com/XUQbz.png&#xA;  [2]: https://i.stack.imgur.com/XE4d8.png&#xA;  [3]: https://i.stack.imgur.com/86Riz.png&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4760" LastEditorUserId="4760" LastEditDate="2021-07-30T15:55:23.427" LastActivityDate="2021-07-30T15:55:23.427" Title="Lower bound very bad. How to improve?" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|gurobi|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6662" PostTypeId="2" ParentId="6655" CreationDate="2021-07-30T17:11:27.283" Score="1" Body="&lt;p&gt;I'm not aware of any solver that can exploit a lower bound to a minimization problem. (An upper bound can be used to prune the search tree, assuming you are using branch-and-bound/branch-and-cut.) CPLEX, for instance, will let you supply the lower bound via the LowerCutoff parameter, but it only uses that information in a maximization problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-30T17:11:27.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6663" PostTypeId="2" ParentId="6648" CreationDate="2021-07-30T17:23:16.717" Score="3" Body="&lt;p&gt;You might be interested in the following paper, in which the authors bake a predictive component (regression or neural network model) for the objective function into an optimization model.&lt;/p&gt;&#xA;&lt;p&gt;Bergman D, Huang T, Brooks P, Lodi A, Raghunathan AU (2019b) Janos: An integrated predictive and prescriptive modeling framework. arXiv preprint arXiv:1911.09461&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-30T17:23:16.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6665" PostTypeId="1" CreationDate="2021-07-30T18:54:57.560" Score="3" ViewCount="95" Body="&lt;p&gt;I have a resource assignment/scheduling problem which involves assigning jobs to &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; workers. There are 2 sets of different jobs, &lt;span class=&quot;math-container&quot;&gt;$J^1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J^2$&lt;/span&gt;, and a set of periods &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$d_{jt}$&lt;/span&gt; be the number of workers required to perform job &lt;span class=&quot;math-container&quot;&gt;$j\in J^1$&lt;/span&gt; in period &lt;span class=&quot;math-container&quot;&gt;$t\in T$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;A job &lt;span class=&quot;math-container&quot;&gt;$j\in J^2$&lt;/span&gt; requires &lt;span class=&quot;math-container&quot;&gt;$d_j$&lt;/span&gt; workers, and can be started at any one period &lt;span class=&quot;math-container&quot;&gt;$B_j\subset T$&lt;/span&gt;. Once started, &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; cannot be preempted, and must be performed by the same &lt;span class=&quot;math-container&quot;&gt;$d_j$&lt;/span&gt; workers from beginning to the end. The duration of a job &lt;span class=&quot;math-container&quot;&gt;$j\in J^2$&lt;/span&gt; is given by &lt;span class=&quot;math-container&quot;&gt;$dur(j)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; be the (exponentially large) set of all different worker schedules. Binary parameter &lt;span class=&quot;math-container&quot;&gt;$a_{sjt}$&lt;/span&gt; indicates whether job &lt;span class=&quot;math-container&quot;&gt;$j\in J^1$&lt;/span&gt; is worked on in period &lt;span class=&quot;math-container&quot;&gt;$t\in T$&lt;/span&gt; in schedule &lt;span class=&quot;math-container&quot;&gt;$s\in S$&lt;/span&gt; . Similarly, binary parameter &lt;span class=&quot;math-container&quot;&gt;$b_{sjt}$&lt;/span&gt; indicates whether job &lt;span class=&quot;math-container&quot;&gt;$j\in J^2$&lt;/span&gt; is started in schedule &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We can now formulate the problem as follows. Let &lt;span class=&quot;math-container&quot;&gt;$\lambda_s$&lt;/span&gt; indicate whether schedule &lt;span class=&quot;math-container&quot;&gt;$s\in S$&lt;/span&gt; is selected, &lt;span class=&quot;math-container&quot;&gt;$y_{jt}$&lt;/span&gt; the shortage of workers for &lt;span class=&quot;math-container&quot;&gt;$j\in J^1$&lt;/span&gt; in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Variable &lt;span class=&quot;math-container&quot;&gt;$z_{jt}$&lt;/span&gt; indicates whether &lt;span class=&quot;math-container&quot;&gt;$j\in J^2$&lt;/span&gt; is started in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; indicates whether &lt;span class=&quot;math-container&quot;&gt;$j\in J^2$&lt;/span&gt; isn't started in any period.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \label{eq:m.1}\mbox{minimize }&amp;amp; \sum_{s\in S}c_s\lambda_s + \sum_{j\in J^1}\sum_{t\in T}p_jy_{jt}+\sum_{j\in J^2}p_jy_j &amp;amp;\\&#xA;    \label{eq:m.2}\mbox{s.t. }&amp;amp;\sum_{s\in S}\lambda_s \leq m &amp;amp; \\&#xA;    \label{eq:m.3}&amp;amp; \sum_{s\in S}a_{sjt}\lambda_s + y_{jt} \geq d_{jt} &amp;amp; \forall j\in J^1,t\in T \\&#xA;    \label{eq:m.4}&amp;amp;\sum_{s\in S}b_{sjt}\lambda_s \geq d_j z_{jt} &amp;amp; \forall j\in J^2, t\in B_j\\&#xA;    \label{eq:m.5}&amp;amp;\sum_{t\in B_j}z_{jt} + y_j = 1 &amp;amp; \forall j\in J^2\\&#xA;    \label{eq:m.6}&amp;amp;\lambda_s\in \{0,1\} &amp;amp;\forall s\in S\\&#xA;    \label{eq:m.7}&amp;amp;y_{jt} \geq 0 &amp;amp; \forall j\in J^1, t\in T\\&#xA;    \label{eq:m.8}&amp;amp;z_{jt}\in \{0,1\} &amp;amp; \forall j\in J^2, t\in B_j\\&#xA;    \label{eq:m.9}&amp;amp;y_j\geq 0 &amp;amp; \forall j\in J^2&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective minimizes the cost of the schedules, the worker shortage for jobs in &lt;span class=&quot;math-container&quot;&gt;$J^1$&lt;/span&gt; and the number of unperformed jobs in &lt;span class=&quot;math-container&quot;&gt;$J^2$&lt;/span&gt; (weighted by a penalty).&#xA;At most &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; schedules can be selected (Constr 1). Constr 2 ensure that every period sufficient workers are assigned to each job in &lt;span class=&quot;math-container&quot;&gt;$J^1$&lt;/span&gt;. Constr 3 ensures that a job in &lt;span class=&quot;math-container&quot;&gt;$J^2$&lt;/span&gt; can only be started if sufficient workers are present. Constr 4 links &lt;span class=&quot;math-container&quot;&gt;$z_{jt}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$y_j=1$&lt;/span&gt; iff &lt;span class=&quot;math-container&quot;&gt;$j\in J^2$&lt;/span&gt; is not started.&lt;/p&gt;&#xA;&lt;p&gt;I'd like to solve the above problem through Column Generation. The real problem I'm trying to solve is significantly more complex. Due to the usage of a set of schedules &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, part of this complexity is hidden away. E.g. there are all sorts of legal, and operational constraints that define a 'feasible' schedule, involving breaks, working hours, worker skills, etc. Hence it would be highly desirable to generate schedules in a pricing problem as opposed to adding all these constraints to a huge ILP.&lt;/p&gt;&#xA;&lt;p&gt;The problem is that the LP relaxation of the above formulation is quite weak. Any ideas on how to strengthen it, perhaps with valid inequalities or some changes in the formulation?&lt;/p&gt;&#xA;&lt;p&gt;Example problem instance:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T=\{1,2,3,4,5\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$m=2$&lt;/span&gt; workers&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$J^1=\{1,2\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_{11}=d_{24}=d_{25}=1$&lt;/span&gt; (other &lt;span class=&quot;math-container&quot;&gt;$d_{jt}$&lt;/span&gt; parameters are 0).&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$J^2=\{3\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_3=2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B_3=\{1,2\}$&lt;/span&gt;, dur(3)=3&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Possible feasible solution:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&quot;text-align: left;&quot;&gt;S/T&lt;/th&gt;&#xA;&lt;th&gt;1&lt;/th&gt;&#xA;&lt;th&gt;2&lt;/th&gt;&#xA;&lt;th&gt;3&lt;/th&gt;&#xA;&lt;th&gt;4&lt;/th&gt;&#xA;&lt;th&gt;5&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$s_1$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$-$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$s_2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$-$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;The table indicates which job is performed in schedule &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, e.g. job &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; is performed in period 4 in schedule &lt;span class=&quot;math-container&quot;&gt;$s_1$&lt;/span&gt;. An &lt;span class=&quot;math-container&quot;&gt;$-$&lt;/span&gt; indicates idle.&#xA;In this solution &lt;span class=&quot;math-container&quot;&gt;$y_{11}=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_3=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z_{31}=1$&lt;/span&gt; and the objective value: &lt;span class=&quot;math-container&quot;&gt;$c_{s_1}+c_{s_2}+p_1$&lt;/span&gt;.&#xA;Note that no schedule exists where no penalty is incurred.&#xA;Here's what the LP relaxation would look like:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&quot;text-align: left;&quot;&gt;S/T&lt;/th&gt;&#xA;&lt;th&gt;1&lt;/th&gt;&#xA;&lt;th&gt;2&lt;/th&gt;&#xA;&lt;th&gt;3&lt;/th&gt;&#xA;&lt;th&gt;4&lt;/th&gt;&#xA;&lt;th&gt;5&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$s_1$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$-$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$s_2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$y_{11}=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_3=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z_{31}=z_{32}=\frac{1}{2}$&lt;/span&gt;, and the objective value &lt;span class=&quot;math-container&quot;&gt;$c_{s_1}+c_{s_2}$&lt;/span&gt;. Notice that the start of job 3 is no longer synchronized across the 2 schedules.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2021-07-30T21:15:45.373" LastActivityDate="2021-07-30T21:15:45.373" Title="Resource scheduling problem with synchronization constraints: Weak LP relaxation" Tags="|mixed-integer-programming|scheduling|assignment-problem|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6666" PostTypeId="2" ParentId="6640" CreationDate="2021-07-30T19:45:38.950" Score="3" Body="&lt;p&gt;You could try using the greedy heuristic to get an initial solution and then try out one of the many neighborhood-search type metaheuristics. I mentioned sorting on &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt; in a comment, but it might (or might not) be better to sort on &lt;span class=&quot;math-container&quot;&gt;$p_{ij}/w_{ij}$&lt;/span&gt; (or, time permitting, try both and pick the better solution). For improving on the starting solution, GRASP and simulated annealing would be possibilities. Tabu search is popular with some people, but the memory requirements of maintaining a table of tabu solutions might be prohibitive. I'm fond of genetic algorithms, but I think we can rule out a GA (or other &amp;quot;evolutionary&amp;quot; metaheuristic) based on memory considerations. Personally, I'd be tempted to check out GRASP first.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-07-30T19:45:38.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6667" PostTypeId="2" ParentId="6642" CreationDate="2021-07-30T21:51:43.857" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;The large instance is very hard to solve. I need to spend some time on it, but I lack ideas and time.&lt;/li&gt;&#xA;&lt;li&gt;The flags part is problematic with jupyter notebook. We will fix those.&lt;/li&gt;&#xA;&lt;li&gt;To print intermediate solution, you need a callback. See &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/sat/doc/solver.md#python-code&quot; rel=&quot;nofollow noreferrer&quot;&gt;this code sample&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="981" LastActivityDate="2021-07-30T21:51:43.857" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6668" PostTypeId="1" CreationDate="2021-07-31T14:55:21.307" Score="3" ViewCount="67" Body="&lt;p&gt;This question was originally asked on &lt;a href=&quot;https://math.stackexchange.com/questions/4212986/minimising-average-holding-cost-per-unit-time-is-equivalent-to-minimising-averag&quot;&gt;Math Stack Exchange&lt;/a&gt;. It is probably better suited here.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Introduction&lt;/h3&gt;&#xA;&lt;p&gt;When one thinks about a queue, it is natural to want to find a policy that minimises the average long-run delay (time spent in buffer) per customer &lt;span class=&quot;math-container&quot;&gt;$\bar{\mathcal{D}}_{n}$&lt;/span&gt;. However, most problems focus on minimising the average long-run holding cost per unit time &lt;span class=&quot;math-container&quot;&gt;$\bar{\mathcal{H}}_{t}$&lt;/span&gt;. This is arguably a quantity which is much easier to work with e.g. only record customers in queue &lt;span class=&quot;math-container&quot;&gt;$n(\tau)$&lt;/span&gt; at arrival and departures epochs as well as the time-stamp &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; of the epoch. It also allows for Markov Decision Processes to solve policy over state-space &lt;span class=&quot;math-container&quot;&gt;$n \in \mathbb{N}_{0}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Problem &amp;amp; Motivation&lt;/h3&gt;&#xA;&lt;p&gt;It would seem like there is a dilemma: trade in the more natural objective function for a more convenient one. However, minimising both is perhaps equivalent. This is like saying if &lt;span class=&quot;math-container&quot;&gt;$\bar{\mathcal{D}}_n$&lt;/span&gt; has a global minimum under a policy &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; and sample path &lt;span class=&quot;math-container&quot;&gt;$\omega$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\bar{\mathcal{D}}_n(\omega,\pi) \leq \bar{\mathcal{D}}_n(\omega_i,\pi_i)$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\bar{\mathcal{H}}_t(\omega,\pi) \leq \bar{\mathcal{H}}_t(\omega_i,\pi_i)$&lt;/span&gt;. This can happen if the two are related by a constant of proportionality e.g. &lt;span class=&quot;math-container&quot;&gt;$\bar{\mathcal{H}}_t = \phi \bar{\mathcal{D}}_n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would like to try and show this to be true (this result probably already exists somewhere). To do this one would need to to the following:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Show long-run delay &lt;span class=&quot;math-container&quot;&gt;$\mathcal{D}$&lt;/span&gt; to be equivalent or proportional to long-run holding cost &lt;span class=&quot;math-container&quot;&gt;$\mathcal{H}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;span class=&quot;math-container&quot;&gt;$\mathcal{H}$&lt;/span&gt; (or &lt;span class=&quot;math-container&quot;&gt;$\mathcal{D}$&lt;/span&gt;) and show its time-average &lt;span class=&quot;math-container&quot;&gt;$\bar{\mathcal{H}}_t $&lt;/span&gt; to be proportional to its customer-average &lt;span class=&quot;math-container&quot;&gt;$\bar{\mathcal{H}}_n$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Hence &lt;span class=&quot;math-container&quot;&gt;$\bar{\mathcal{D}}_n \propto \bar{\mathcal{H}}_t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Please assist me in either establishing whether my work holds true or where mistakes have been made. Let's proceed.&lt;/p&gt;&#xA;&lt;h3&gt;Proposed solution&lt;/h3&gt;&#xA;&lt;h4&gt;Part 1: &lt;span class=&quot;math-container&quot;&gt;$\mathcal{H} = \mathcal{D}$&lt;/span&gt;&lt;/h4&gt;&#xA;&lt;p&gt;Define &lt;em&gt;total&lt;/em&gt; holding cost at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\mathcal{H}(t) = c\int_{0}^{t}n(\tau) \, d\tau $$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is some cost weight. Without loss of generality, assume that &lt;span class=&quot;math-container&quot;&gt;$c=1$&lt;/span&gt;. Delay is a bit more tricky. Let &lt;span class=&quot;math-container&quot;&gt;$T_i = t_i^D - t_i^A $&lt;/span&gt; denote the time spent in the buffer for the &lt;span class=&quot;math-container&quot;&gt;$i^{th}$&lt;/span&gt; customer where &lt;span class=&quot;math-container&quot;&gt;$t_i^A$&lt;/span&gt; denotes the instance of arrival and &lt;span class=&quot;math-container&quot;&gt;$t_i^D$&lt;/span&gt; the instance it departs the queue (enters service). Hence, &lt;span class=&quot;math-container&quot;&gt;$T_i$&lt;/span&gt; is the delay that the &lt;span class=&quot;math-container&quot;&gt;$i^{th}$&lt;/span&gt; customer will experience. The issue is that at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, all departed customers &lt;span class=&quot;math-container&quot;&gt;$i \in \{D(t)\}$&lt;/span&gt; will have experienced their full delay whereas some will not: arrived but not not departed &lt;span class=&quot;math-container&quot;&gt;$\{A(t)\}\setminus \{D(t)\}$&lt;/span&gt;. Note that A(t) is the total amount of arrivals and D(t) the total departures such that &lt;span class=&quot;math-container&quot;&gt;$n(t) = A(t) - D(t)$&lt;/span&gt; whereas &lt;span class=&quot;math-container&quot;&gt;$\{A(t)\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\{D(t)\}$&lt;/span&gt; denotes sets that records arrived and departed customers, respectively. Note that &lt;span class=&quot;math-container&quot;&gt;$\forall t \in \mathbb{R}_{\geq 0}: A(t) \geq D(t)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Hence, &lt;em&gt;total&lt;/em&gt; delay at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathcal{D}(t) = c\left(\sum_{i \in \{D(t)\}} T_i + \sum_{i \in \{A(t)\}\setminus \{D(t)\}} t - t_i^A \right)&#xA;$$&lt;/span&gt;&#xA;From the below image that has been borrowed from the cited book, the expression for total delay should be clear.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oDsKY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oDsKY.png&quot; alt=&quot;Delay in open system/queue&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;We know derive &lt;span class=&quot;math-container&quot;&gt;$\mathcal{D}(t)$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$\mathcal{H}(t)$&lt;/span&gt; (Recall &lt;span class=&quot;math-container&quot;&gt;$c=1$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\mathcal{H}(t) &amp;amp;  =  \int_{0}^t A(\tau) - D(\tau)\, d\tau \\&#xA;&amp;amp; = \int_{0}^t \{ A(\tau)\} \setminus \{ D(\tau) \}\, d\tau \\&#xA;&amp;amp; = \sum_{i \in \{A(t)\}} \int_{0}^t \boldsymbol{1}_{\{t_i^A \leq \tau \leq t_i^D \}} \, d\tau \\&#xA;&amp;amp; = \sum_{i \in \{A(t)\}} T_i \boldsymbol{1}_{\{t_i^D \leq t\}} + (t-t_i^A)\boldsymbol{1}_{\{t_i^D &amp;gt; t\}} \\&#xA;&amp;amp; = \sum_{i \in \{D(t)\}} T_i + \sum_{i \in \{A(t)\}\setminus \{D(t)\}} t - t_i^A\\&#xA;&amp;amp; = \mathcal{D}(t)&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;That concludes part 1. I hope we have achieved equivalence in the right way without errors. From now one, we choose to work with &lt;span class=&quot;math-container&quot;&gt;$\mathcal{H}(t)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h4&gt;Part 2: &lt;span class=&quot;math-container&quot;&gt;$ \bar{\mathcal{H}}_t \propto \bar{\mathcal{H}}_n$&lt;/span&gt;&lt;/h4&gt;&#xA;&lt;p&gt;The average long-run holding cost &lt;em&gt;per unit time&lt;/em&gt; is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\bar{\mathcal{H}}_t = \lim_{T \to \infty} \frac{1}{T} \int_{0}^T \mathcal{H}(\tau) \, d\tau&#xA;$$&lt;/span&gt;&#xA;whereas the average long-run holding cost &lt;em&gt;per customer&lt;/em&gt; is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\bar{\mathcal{H}}_n = \lim_{T \to \infty} \frac{1}{A(T)} \int_{0}^T \mathcal{H}(\tau) \, d\tau&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A(T)$&lt;/span&gt; is interpreted as the total customers the system has seen. Next, the following time-average result holds for an &lt;a href=&quot;https://i.stack.imgur.com/oDsKY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;ergodic&lt;/a&gt; system (this can be found on page 97 of the cited book):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\lambda = \lim_{T\to \infty} \frac{A(T)}{T}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is the mean arrival rate. Using this result and assuming the system to be ergodic&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\bar{\mathcal{H}}_n &amp;amp; = \lim_{T \to \infty} \frac{T}{A(T)} \times \lim_{T \to \infty} \frac{1}{T}\int_{0}^T \mathcal{H}(\tau) \, d\tau&#xA;\\&#xA;&amp;amp; = \frac{\bar{\mathcal{H}}_t}{\lambda} &#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Hence, &lt;span class=&quot;math-container&quot;&gt;$\bar{\mathcal{H}}_t = \lambda \bar{\mathcal{H}}_n$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\bar{\mathcal{H}}_t \propto\bar{\mathcal{H}}_n$&lt;/span&gt; along with the constant of proportionality having a convenient interpretation. This is probably a variant of &lt;a href=&quot;https://en.wikipedia.org/wiki/Little%27s_law&quot; rel=&quot;nofollow noreferrer&quot;&gt;Little's Law&lt;/a&gt; (chapter 6 of the book).&lt;/p&gt;&#xA;&lt;h3&gt;Conclusion&lt;/h3&gt;&#xA;&lt;p&gt;We see that a proportional relationship holds &lt;span class=&quot;math-container&quot;&gt;$\bar{\mathcal{H}}_t = \lambda \bar{\mathcal{H}}_n$&lt;/span&gt; under the assumptions that the system is ergodic and that the long-term average effective arrival rate be a constant (time-homogeneous system).&lt;/p&gt;&#xA;&lt;p&gt;Thank you for your time. Please feel free to also suggest improvements.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;References&lt;/h3&gt;&#xA;&lt;p&gt;&lt;em&gt;Harchol-Balter, Mor&lt;/em&gt;, &lt;a href=&quot;http://dx.doi.org/10.1017/CBO9781139226424.002&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Performance modeling and design of computer systems. Queueing theory in action&lt;/strong&gt;&lt;/a&gt;, Cambridge: Cambridge University Press (ISBN 978-1-107-02750-3/hbk; 978-1-139-60396-6/ebook). xxiii, 548 p. (2013). &lt;a href=&quot;https://zbmath.org/?q=an:1282.68007&quot; rel=&quot;nofollow noreferrer&quot;&gt;ZBL1282.68007&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1241" LastEditorUserId="123" LastEditDate="2021-07-31T15:34:35.223" LastActivityDate="2021-07-31T15:34:35.223" Title="Minimising average holding cost per unit time is equivalent to minimising average delay per customer in queue" Tags="|optimization|modeling|queuing-theory|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6669" PostTypeId="2" ParentId="6655" CreationDate="2021-07-31T15:15:30.593" Score="3" Body="&lt;p&gt;My overall experience is that feeding constraints of the form &lt;span class=&quot;math-container&quot;&gt;$\rm objval \geq lb$&lt;/span&gt; is &lt;strong&gt;detrimental&lt;/strong&gt; to MIP solver performance.&lt;/p&gt;&#xA;&lt;p&gt;The main reason is the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MIP solvers rely on branch-and-bound algorithms...&lt;/li&gt;&#xA;&lt;li&gt;... whose performance depends heavily on branching decisions...&lt;/li&gt;&#xA;&lt;li&gt;... which are themselves based on how the dual (lower if you're minimizing) bound changes after branching&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Therefore, adding a constraint of the form &lt;span class=&quot;math-container&quot;&gt;$\rm objval \geq lb$&lt;/span&gt; creates two main issues:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the solver looses access to a lot of information on how the objective value changes when branching on particular variables. Branching decisions then become more or less random, which can be terrible for performance&lt;/li&gt;&#xA;&lt;li&gt;constraint also creates a lot of degeneracy in the underlying LPs that are solved at every node, which can further slow down the solution of each node.&#xA;This also affects the cut generation and heuristics.&#xA;More precisely:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;without the constraint &lt;span class=&quot;math-container&quot;&gt;$\rm objval \geq lb$&lt;/span&gt;, you can discriminate between LP solutions based on their objective value&lt;/li&gt;&#xA;&lt;li&gt;with the constraint &lt;span class=&quot;math-container&quot;&gt;$\rm objval \geq lb$&lt;/span&gt;, you loose that distinction (at least for all LP solution whose original objective value was smaller than &lt;span class=&quot;math-container&quot;&gt;$\rm lb$&lt;/span&gt;). Thus, the obtained solution will be pretty much a random guess between all these now-equivalent LP solutions ---&amp;gt; that's usually not a good thing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So what's the best way of exploiting that lower bound of yours? That'll require a deeper interaction with the solution process.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As mentioned in a previous comment, you can use a Lagrange decomposition approach, which however requires you to implement a few things yourself.&lt;/li&gt;&#xA;&lt;li&gt;If you know your bound &lt;span class=&quot;math-container&quot;&gt;$\rm lb$&lt;/span&gt; is really good, you can query the current MIP solution, manually compute its optimality gap w.r.t &lt;span class=&quot;math-container&quot;&gt;$\rm lb$&lt;/span&gt;, and terminate the solve if it fits your needs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="123" LastEditDate="2021-07-31T15:29:25.420" LastActivityDate="2021-07-31T15:29:25.420" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6670" PostTypeId="1" CreationDate="2021-08-01T16:30:36.853" Score="2" ViewCount="168" Body="&lt;p&gt;I'm facing the following problem as I am trying to model a problem where people visit facilities according to their age and per a time horizon. Additionally, I am trying to allocate specific commodity types to these demands, as in certain people cannot receive certain type of product at these facilities. Till now, I have only managed to write the following variables, parameters and constraints.&lt;/p&gt;&#xA;&lt;p&gt;J: Set of location of facilities&lt;/p&gt;&#xA;&lt;p&gt;I : Set of locations of the demand&lt;/p&gt;&#xA;&lt;p&gt;A: Set of age groups of the demand i.e., 80 and over, 70-79, and so on till 19 and below.&lt;/p&gt;&#xA;&lt;p&gt;C: Set of commodity types i.e A, B, C&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_a$&lt;/span&gt;: Social cost per age group A&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$MV_a$&lt;/span&gt;: Maximum workload that can be done by the staff per time period t&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f_j$&lt;/span&gt;: Fixed opening cost of a facility at a location j&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$HC_j$&lt;/span&gt;: People handling capacity of a facility at location j&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$SC_j$&lt;/span&gt;: Storage capacity of a facility at location j&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$IV_j$&lt;/span&gt;: Inventory holding cost of a facility at a location j&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$O_{j}$&lt;/span&gt;: Operating cost of a facility at a location j&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$VP_t$&lt;/span&gt;: Pay of staff at facility per time period t&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_{ia}$&lt;/span&gt;; Demand from location i of age group a&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_{ij}$&lt;/span&gt;: Distance between location i and location j(facility)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_{jct}$&lt;/span&gt;: Supply of commodity c at location j at time period t&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{ijat}$&lt;/span&gt;: demand at location i of a particular age group a to location j at time period t&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt;: 1, If location j is opened or not; 0 otherwise&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i_{jct}$&lt;/span&gt;: Inventory at location j of commodity c at time period t&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$vs_{jt}$&lt;/span&gt;: Staff at location j at time period t&lt;/p&gt;&#xA;&lt;p&gt;I have the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j \in J}\sum_{t \in T} \sum_{i \in I} \sum_{a \in A} z_{ijta} D_{ij} O_j + \sum_{j \in J} \sum_{t \in T} vs_{jt} VP_t  + \sum_{j in J} \sum_{c \in C} \sum_{t \in T} I_{jct} IV_{j}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{t \in T}\sum_{j \in J} z_{ijta} = D_{ia} S_{a} \forall i \in I, a \in A$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i \in I} \sum_{t \in T} \sum_{a \in A} z_{ijta} \leq MV_t* \sum_{t \in T} vs_{jt} &#xA; \forall j \in J $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ MV_{t} * vs_{jt} \leq HC_j * y_j \forall j \in J, t \in T$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i \in I} \sum_{a \in A} z_{ijta} \leq \sum_{c \in C} I_{jct} * y_j  \forall j \in J $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{c \in C} I_{jct} = \sum_{c \in C} S_{jct} - \sum_{i \in I} \sum_{a \in A} z_{ijta}, t = 1, \forall t \in T, j \in J $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{c \in C} I_{jct} = \sum_{c \in C} I_{jct-1} \sum_{c \in C} + S_{jct} - \sum_{i \in I} \sum_{a \in A} z_{ijta}, t &amp;gt; 1, \forall t \in T, j \in J $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{t \in T} \sum_{c \in C} I_{jct} \leq SC_j \forall j \in J$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraint(1) ensures that the demand from location i reaches location j as per a social cost, for instance the social cost might be 80+ - 1, 70- 79 - 0.1, etc. Constraint(2) ensures that the staff at the facilities is more than the demand received. Constraint(3) ensures that the staff at location j, is less than the handling capacity of the location. Constraint(4) ensures that the demand allocated at location is less than the inventory. Constraint(5) and constraint(6) ensure that inventory flow is maintained at each time period and it keeps getting updated for utilised demand, we minimise the inventory in the objective in order to have as small inventory as possible. Finally, constraint(7) ensures that the inventory is less than the storage at that location.&lt;/p&gt;&#xA;&lt;p&gt;Additionally, we have the following:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ y_j \in \{0,1\}, z_{ijta}, i_{jct}, vs_{jt} \in R $$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user4387" LastEditorUserId="500" LastEditDate="2021-08-07T21:46:07.907" LastActivityDate="2021-08-07T21:46:07.907" Title="Demand allocation to facilities" Tags="|facility-location|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="6671" PostTypeId="1" CreationDate="2021-08-02T14:35:52.920" Score="1" ViewCount="189" Body="&lt;p&gt;Suppose we have two lines: &lt;code&gt;L1&lt;/code&gt; and &lt;code&gt;L2&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Suppose we have 4 product types: &lt;code&gt;A1&lt;/code&gt;, &lt;code&gt;A2&lt;/code&gt;, &lt;code&gt;B1&lt;/code&gt; and &lt;code&gt;B2&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Suppose the line capacity for both of the lines are 24 hours.&lt;/p&gt;&#xA;&lt;p&gt;Suppose the changeover cost is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;                   to&#xA;             A1  A2  B1  B2&#xA;        A1   0   1   4   4&#xA; from   A2   1   0   4   4&#xA;        B1   4   4   0   1&#xA;        B2   4   4   1   0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Suppose the daily demand is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;'A1':14 hours,&#xA;'A2':10 hours,&#xA;'B1':12 hours,&#xA;'B2':12 hours,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Suppose hours of one product type can be distributed over the two lines for production.&lt;/p&gt;&#xA;&lt;p&gt;How could we use gurobi to come up with the best plan&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;L1: A1 -&amp;gt;cost 0-&amp;gt; A1 (14 hours) -&amp;gt;cost 1-&amp;gt; A2 (10 hours)&#xA;L2: A2 -&amp;gt;cost 4-&amp;gt; B1 (12 hours) -&amp;gt;cost 1-&amp;gt; B2 (12 hours)&#xA;Total changeover cost = 0 + 1 + 4 + 1 = 6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As a comparison, a suboptimal plan could be&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;L1: A1 -&amp;gt;cost 0-&amp;gt; A1 (14 hours) -&amp;gt;cost 4-&amp;gt; B1 (10 hours)&#xA;L2: A2 -&amp;gt;cost 0-&amp;gt; A2 (10 hours) -&amp;gt;cost 4-&amp;gt; B2 (12 hours) -&amp;gt;cost 1-&amp;gt; B1(2 hours)&#xA;Total changeover cost = 0 + 4 + 0 + 4 + 1 = 9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As a graphical illustration:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VdPLE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VdPLE.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;My code does not work as expected:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;##############################################################################&#xA;##################  Production Scheduling with changeovers  ##################&#xA;##############################################################################&#xA;&#xA;import os&#xA;import time&#xA;START_TIME = time.time()&#xA;import numpy as np&#xA;import pandas as pd&#xA;import gurobipy as gp&#xA;from gurobipy import GRB, quicksum, max_, and_, or_&#xA;from pathlib import Path&#xA;from matplotlib import pyplot as plt&#xA;from pathlib import Path&#xA;&#xA;###############################   Inputs   ###################################&#xA;&#xA;PRODUCTS = set(['A1','A2','B1','B2'])&#xA;&#xA;LINES = set(['L1', 'L2'])&#xA;&#xA;LAST_PRODUCTION = {&#xA;    'L1':'A1',&#xA;    'L2':'A2',&#xA;    }&#xA;&#xA;DEMAND = {&#xA;    'A1':14,&#xA;    'A2':10,&#xA;    'B1':12,&#xA;    'B2':12,&#xA;    }&#xA;&#xA;#   CHANGEOVER_COST &#xA;#     A1  A2  B1  B2&#xA;# A1   0   1   4   4&#xA;# A2   1   0   4   4&#xA;# B1   4   4   0   1&#xA;# B2   4   4   1   0&#xA;&#xA;CHANGEOVER_COST = {&#xA;    &#xA;    ('A1', 'A1'):0,&#xA;    ('A1', 'A2'):1,&#xA;    ('A1', 'B1'):4,&#xA;    ('A1', 'B2'):4,&#xA;&#xA;    ('A2', 'A1'):1,&#xA;    ('A2', 'A2'):0,&#xA;    ('A2', 'B1'):4,&#xA;    ('A2', 'B2'):4,&#xA;&#xA;    ('B1', 'A1'):4,&#xA;    ('B1', 'A2'):4,&#xA;    ('B1', 'B1'):0,&#xA;    ('B1', 'B2'):1,&#xA;&#xA;    ('B2', 'A1'):4,&#xA;    ('B2', 'A2'):4,&#xA;    ('B2', 'B1'):1,&#xA;    ('B2', 'B2'):0&#xA;    &#xA;    }&#xA;&#xA;LINE_CAPACITY = 24&#xA;&#xA;###############################   Model   ###################################&#xA;&#xA;model = gp.Model('production_scheduling_with_changeover')&#xA;&#xA;hours = model.addVars(LINES, PRODUCTS)&#xA;&#xA;flags = model.addVars(LINES, PRODUCTS, vtype = GRB.BINARY)&#xA;&#xA;paths = model.addVars(LINES, PRODUCTS, PRODUCTS, vtype = GRB.BINARY)&#xA;&#xA;# 1. Meet demand&#xA;meet_demand = model.addConstrs(&#xA;    (&#xA;     sum(hours[line, product] for line in LINES) == DEMAND[product] for product in PRODUCTS&#xA;    ),&#xA;    name = 'meet_demand_for_each_product'&#xA;)&#xA;&#xA;# 2. Line capacity&#xA;capacity = model.addConstrs(&#xA;    (&#xA;     sum(hours[line, product] for product in PRODUCTS) &amp;lt;= LINE_CAPACITY for line in LINES&#xA;    ),&#xA;    name = 'line_capacity'&#xA;)&#xA;&#xA;# 3. Constraints between flags and hours&#xA;for line in LINES:&#xA;    for product in PRODUCTS:&#xA;        model.addGenConstrIndicator(flags[line, product],&#xA;                                  0,&#xA;                                  hours[line, product] == 0&#xA;                                  &#xA;                                  )&#xA;        model.addGenConstrIndicator(flags[line, product],&#xA;                                  1,&#xA;                                  hours[line, product] &amp;gt;= 0&#xA;                                  )&#xA;&#xA;# 4. Path&#xA;&#xA;&#xA;# 1. sum == N&#xA;path_1 = model.addConstrs(&#xA;    (&#xA;    sum(paths[line, p1, p2]  for p1 in PRODUCTS for p2 in PRODUCTS) == sum(flags[line, product] for product in PRODUCTS) for line in LINES&#xA;    ),&#xA;    name = 'total_paths'&#xA;)&#xA;&#xA;# 2. no A -&amp;gt; B -&amp;gt; A&#xA;path_2 = model.addConstrs(&#xA;    (&#xA;    paths[line, p1, p2] +  paths[line, p2, p1] &amp;lt;= 1 for p1 in PRODUCTS for p2 in PRODUCTS for line in LINES if p1 != p2&#xA;    ),&#xA;    name = 'no_A_to_B_to_A'&#xA;)&#xA;&#xA;#3. Diagonal &#xA;  # Non-last type&#xA;&#xA;path_3_1 = model.addConstrs(&#xA;    (&#xA;    paths[line, p, p] == 0 for p in PRODUCTS  for line in LINES if p != LAST_PRODUCTION[line]&#xA;    ),&#xA;    name = 'diagonal_0_for_non_last_type'&#xA;)&#xA;&#xA;  # Last type&#xA;path_3_2 = model.addConstrs(&#xA;    (&#xA;    paths[line, p, p] == flags[line, p] for p in PRODUCTS for line in LINES if p == LAST_PRODUCTION[line]&#xA;    ),&#xA;    name = 'diagonal_for_last_type'&#xA;)&#xA;&#xA;&#xA;&#xA;#4. Set 0 for non_production and non_last types&#xA;&#xA;path_4_1 = model.addConstrs(&#xA;    (&#xA;    paths[line, p1, p2] &amp;lt;= flags[line, p1] for p1 in PRODUCTS for p2 in PRODUCTS for line in LINES if p1 != LAST_PRODUCTION[line] and p1 != p2&#xA;    ),&#xA;    name = 'shade_for_nonproduction_nonlast_types_row'&#xA;)&#xA;&#xA;path_4_2 = model.addConstrs(&#xA;    (&#xA;    paths[line, p1, p2] &amp;lt;= flags[line, p2] for p1 in PRODUCTS for p2 in PRODUCTS for line in LINES if p2 != LAST_PRODUCTION[line] and p1 != p2&#xA;    ),&#xA;    name = 'shade_for_nonproduction_nonlast_types_column'&#xA;)&#xA;&#xA;&#xA;&#xA;#6. Column sum &amp;lt;= 1&#xA;&#xA;path_6 = model.addConstrs(&#xA;    (&#xA;    sum(paths[line, p1, p2] for p1 in PRODUCTS) &amp;lt;= 1 for p2 in PRODUCTS for line in LINES&#xA;    ),&#xA;    name = 'column_sum_less_or_equal_to_1'&#xA;)&#xA;&#xA;&#xA;&#xA;#7 Row sum&#xA;  # Non last type&#xA;path_7_1 = model.addConstrs(&#xA;    (&#xA;     sum(paths[line, p1, p2] for p2 in PRODUCTS if p1 != p2) &amp;lt;= 1 for p1 in PRODUCTS  for line in LINES&#xA;    ),&#xA;    name = 'row_sum_less_or_equal_to_1'&#xA;)&#xA;  &#xA;  # Last type    &#xA;path_7_2_1 = model.addConstrs(&#xA;    (&#xA;      sum(paths[line, LAST_PRODUCTION[line], p2] for p2 in PRODUCTS if LAST_PRODUCTION[line] != p2) == 0 \&#xA;          for line in LINES if and_(sum(flags[line, p] for p in PRODUCTS if p != LAST_PRODUCTION[line]) ==0)&#xA;    ),&#xA;    name = 'row_sum_less_or_equal_to_0'&#xA;)&#xA;    &#xA;&#xA;path_7_2_2 = model.addConstrs(&#xA;    (&#xA;      sum(paths[line, LAST_PRODUCTION[line], p2] for p2 in PRODUCTS if LAST_PRODUCTION[line] != p2) == 1 \&#xA;          for line in LINES if and_(sum(flags[line, p] for p in PRODUCTS if p != LAST_PRODUCTION[line]) &amp;gt;=1)&#xA;    ),&#xA;    name = 'row_sum_less_or_equal_to_1'&#xA;)&#xA;&#xA;&#xA;&#xA;# There has to be way out from the last type &#xA;path_8 = model.addConstrs(&#xA;    (&#xA;        sum(paths[line, p1, p2] for p2 in PRODUCTS) &amp;gt;= paths[line, LAST_PRODUCTION[line], p1] for p1 in PRODUCTS \&#xA;            for line in LINES if  p1 != LAST_PRODUCTION[line] &#xA;    ),&#xA;    name = 'The 1st to product from last has to have its next type'&#xA;)&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;# Minimize the changeover cost&#xA;obj = sum(paths[line, p1, p2]*CHANGEOVER_COST[p1, p2] for p1 in PRODUCTS for p2 in PRODUCTS for line in LINES)&#xA;&#xA;model.setObjective(obj, GRB.MINIMIZE)&#xA;&#xA;model.setParam(&amp;quot;MIPGap&amp;quot;, 0.01)&#xA;&#xA;model.optimize()&#xA;&#xA;&#xA;print('Time', time.time() - START_TIME)&#xA;&#xA;&#xA;#####################################################################################################&#xA;###############################   info extraction from model   ######################################&#xA;#####################################################################################################&#xA;&#xA;SAVE_FOLDER = 'C:/daten/'&#xA;&#xA;rows = LINES.copy()&#xA;columns = PRODUCTS.copy()&#xA;&#xA;plan = pd.DataFrame(columns = columns, index = rows, data = 0)&#xA;indicator = pd.DataFrame(columns = columns, index = rows, data = 0)&#xA;&#xA;plan.sort_index(inplace = True)&#xA;indicator.sort_index(inplace = True)&#xA;&#xA;for line, product in hours.keys():&#xA;    #print(line, product, hours[line, product].x)&#xA;    if (abs(hours[line, product].x &amp;gt; 1e-6)):&#xA;        plan.loc[line, product] = np.round(hours[line, product].x,1)&#xA;        indicator.loc[line, product] = np.round(flags[line, product].x,1)&#xA;&#xA;plan_transposed = plan.transpose().sort_index()&#xA;plan_transposed_2 = plan_transposed#plan_transposed[(plan_transposed.T != 0).any()]&#xA;plan_transposed_2.to_csv(SAVE_FOLDER + 'hours.csv')&#xA;&#xA;indicator_transposed = indicator.transpose().sort_index()&#xA;indicator_transposed_2 = indicator_transposed[(indicator_transposed.T != 0).any()] &#xA;indicator_transposed_2.to_csv(SAVE_FOLDER + 'flags.csv')&#xA;&#xA;# Line #1 Path&#xA;rows = PRODUCTS.copy()&#xA;columns = PRODUCTS.copy()&#xA;line1 = pd.DataFrame(columns = columns, index = rows, data = 0)&#xA;for line, p1, p2 in paths.keys():&#xA;    if line == &amp;quot;L1&amp;quot;:&#xA;        line1.loc[p1, p2] = np.round(paths[line, p1, p2].x,1)&#xA;    else:&#xA;        pass&#xA;line1.sort_index()&#xA;line1.to_csv(SAVE_FOLDER + &amp;quot;L1.csv&amp;quot;)&#xA;&#xA;# Line #2 Path&#xA;rows = PRODUCTS.copy()&#xA;columns = PRODUCTS.copy()&#xA;line2 = pd.DataFrame(columns = columns, index = rows, data = 0)&#xA;for line, p1, p2 in paths.keys():&#xA;    if line == &amp;quot;L2&amp;quot;:&#xA;        line2.loc[p1, p2] = np.round(paths[line, p1, p2].x,1)&#xA;    else:&#xA;        pass&#xA;line2.sort_index(inplace = True)&#xA;line2.to_csv(SAVE_FOLDER + &amp;quot;L2.csv&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5988" LastEditorUserId="500" LastEditDate="2021-08-02T15:34:51.743" LastActivityDate="2021-08-02T15:34:51.743" Title="How to use gurobi to plan production and minimize the times of changeovers" Tags="|gurobi|scheduling|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6672" PostTypeId="1" AcceptedAnswerId="6679" CreationDate="2021-08-02T18:31:25.983" Score="6" ViewCount="649" Body="&lt;p&gt;I ran a MIP model with a max solving time of 1800 seconds. CPLEX found the optimal solution (0.00 % MIP gap) after 710 seconds, but continued processing until it was stopped by the 1800 second limit.&lt;/p&gt;&#xA;&lt;p&gt;When CPLEX already found the optimal solution after 710 seconds, why does it continue searching for more solutions? None of my &lt;code&gt;cplex_settings&lt;/code&gt; specify that CPLEX should look for more solutions.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Regarding the settings, I had specified the &lt;code&gt;dual&lt;/code&gt; to be solved with a &lt;code&gt;mipgap&lt;/code&gt; of &lt;code&gt;0.05&lt;/code&gt; and that the solver should stop on the first feasible solution it finds.&lt;/p&gt;&#xA;&lt;p&gt;As requested, here's the log file.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Tried aggregator 2 times.&#xA;MIP Presolve eliminated 26030 rows and 33 columns.&#xA;MIP Presolve modified 262893 coefficients.&#xA;Aggregator did 42 substitutions.&#xA;Reduced MIP has 62815 rows, 53516 columns, and 1587796 nonzeros.&#xA;Reduced MIP has 53512 binaries, 4 generals, 0 SOSs, and 0 indicators.&#xA;Presolve time = 2.14 sec. (2937.68 ticks)&#xA;Probing time = 0.13 sec. (20.24 ticks)&#xA;Tried aggregator 1 time.&#xA;Detecting symmetries...&#xA;Elapsed time for symmetry detection = 6.77 sec. (10008.46 ticks)&#xA;Elapsed time for symmetry detection = 16.19 sec. (20008.49 ticks)&#xA;Elapsed time for symmetry detection = 25.37 sec. (30012.78 ticks)&#xA;Found 9.054173e+11898 symmetric permutations.&#xA;Reduced MIP has 62815 rows, 53516 columns, and 1587796 nonzeros.&#xA;Reduced MIP has 53512 binaries, 4 generals, 0 SOSs, and 0 indicators.&#xA;Presolve time = 30.26 sec. (35629.93 ticks)&#xA;Probing time = 0.06 sec. (20.23 ticks)&#xA;Clique table members: 466439.&#xA;MIP emphasis: balance optimality and feasibility.&#xA;MIP search method: dynamic search.&#xA;Parallel mode: deterministic, using up to 32 threads.&#xA;Parallel mode: deterministic, using up to 4 threads for parallel tasks at root LP.&#xA;Root relaxation solution time = 17.76 sec. (18171.73 ticks)&#xA;&#xA;        Nodes                                         Cuts/&#xA;   Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap&#xA;&#xA;      0     0      855.0000  2457                    855.0000        9         &#xA;      0     0      855.0000  2457                   Cuts: 348     2147         &#xA;      0     0      855.0000  2457                  Cuts: 1665     5558         &#xA;      0     0      855.0000  2457                    Cuts: 56     7056         &#xA;      0     0      855.0000  2457                  Cuts: 1017    10443         &#xA;Heuristic still looking.&#xA;Heuristic still looking.&#xA;      0     2      855.0000   667                    855.0000    10443         &#xA;Elapsed time = 306.25 sec. (294530.46 ticks, tree = 0.02 MB)&#xA;      1     3      855.0000   795                    855.0000    18020         &#xA;      2     4      855.0000  3440                    855.0000    66067         &#xA;      3     5      855.0000  3718                    855.0000    67202         &#xA;      4     6      855.0000  3602                    855.0000    69179         &#xA;      5     7      855.0000  3557                    855.0000    74325         &#xA;      6     4      855.0000  2023                    855.0000    46708         &#xA;      7     9      855.0000  2023                    855.0000   109975         &#xA;                                                  Impl Bds: 9                  &#xA;      9    11      855.0000  2052                    855.0000   110101         &#xA;     10    11      855.0000  1756                    855.0000   110596         &#xA;     12    10      855.0000  1995                    855.0000   110796         &#xA;                                                 Impl Bds: 14                  &#xA;Elapsed time = 518.58 sec. (437339.57 ticks, tree = 0.02 MB)&#xA;     13    12      855.0000  2040                    855.0000   122462         &#xA;                                                  Impl Bds: 4                  &#xA;     17    19      855.0000  1658                    855.0000   132306         &#xA;     28    29      855.0000  2275                    855.0000   134254         &#xA;     36    36      855.0000  1762                    855.0000   135234         &#xA;     40    38      855.0000  2070                    855.0000   136817         &#xA;                                                  Impl Bds: 5                  &#xA;     52    41      855.0000  2053                    855.0000   139011         &#xA;     69    47      855.0000  1872                    855.0000   139054         &#xA;     84    56      855.0000  1224                    855.0000   140198         &#xA;     97    64      855.0000  1514                    855.0000   141954         &#xA;    112    63      855.0000  1610                    855.0000   143802         &#xA;Elapsed time = 560.10 sec. (450652.24 ticks, tree = 0.64 MB)&#xA;    120    68      855.0000  1599                    855.0000   144665         &#xA;    135    82      855.0000  1030                    855.0000   144261         &#xA;    154    79      855.0000  1413                    855.0000   147082         &#xA;    175    64      855.0000  1581                    855.0000   144448         &#xA;    199    71      855.0000  1625                    855.0000   145780         &#xA;    226    77      855.0000  1565                    855.0000   146911         &#xA;    252   150      855.0000   962                    855.0000   157477         &#xA;    271   206      855.0000   499                    855.0000   168780         &#xA;    293    94      855.0000  1225                    855.0000   150152         &#xA;    325   305      855.0000  1218                    855.0000   195880         &#xA;                                                 Impl Bds: 36                  &#xA;Elapsed time = 590.45 sec. (460750.45 ticks, tree = 6.38 MB)&#xA;    355   303      855.0000  1901                    855.0000   205160         &#xA;    393   341      855.0000   263                    855.0000   222597         &#xA;                                                  Impl Bds: 7                  &#xA;    422   351      855.0000   266                    855.0000   223359         &#xA;    459   340      855.0000  1765                    855.0000   229009         &#xA;                                                  Impl Bds: 6                  &#xA;    496   393      855.0000   986                    855.0000   249289         &#xA;                                                  Impl Bds: 7                  &#xA;    526   415      855.0000   879                    855.0000   294571         &#xA;                                                 Impl Bds: 10                  &#xA;    551   423      855.0000  1023                    855.0000   295779         &#xA;    564   490      855.0000  1120                    855.0000   321459         &#xA;    577   553      855.0000   630                    855.0000   344859         &#xA;    599   565      855.0000  1530                    855.0000   348707         &#xA;                                                  Impl Bds: 5                  &#xA;Elapsed time = 617.79 sec. (470692.71 ticks, tree = 9.89 MB)&#xA;    623   570      855.0000  1480                    855.0000   349724         &#xA;    646   597      855.0000  1550                    855.0000   358851         &#xA;                                                  Impl Bds: 1                  &#xA;    666   603      855.0000  1261                    855.0000   359511         &#xA;    683   603      855.0000  1461                    855.0000   362218         &#xA;                                                  Impl Bds: 2                  &#xA;    720   626      855.0000  1457                    855.0000   371858         &#xA;    753   675      855.0000  1736                    855.0000   382238         &#xA;    778   636      855.0000  1921                    855.0000   374288         &#xA;    818   678      855.0000   374                    855.0000   377260         &#xA;                                                  Impl Bds: 1                  &#xA;    868   688      855.0000   409                    855.0000   377835         &#xA;    910   728      855.0000  1522                    855.0000   421008         &#xA;Elapsed time = 644.11 sec. (480482.47 ticks, tree = 16.47 MB)&#xA;    952   726      855.0000   557                    855.0000   421356         &#xA;    996   856      855.0000   365                    855.0000   441037         &#xA;   1023   872      855.0000  1420                    855.0000   465385         &#xA;   1060   864      855.0000   371                    855.0000   448495         &#xA;   1118   977      855.0000  1665                    855.0000   547515         &#xA;   1176   891      855.0000  1050                    855.0000   469575         &#xA;                                                  Impl Bds: 1                  &#xA;   1212  1052      855.0000   522                    855.0000   576274         &#xA;   1257  1028      855.0000   968                    855.0000   561070         &#xA;   1302  1150      855.0000   141                    855.0000   603276         &#xA;   1357  1076      855.0000  1360                    855.0000   585541         &#xA;Elapsed time = 666.73 sec. (490171.99 ticks, tree = 43.16 MB)&#xA;   1413  1183      855.0000   811                    855.0000   606493         &#xA;   1455  1193      855.0000   250                    855.0000   607126         &#xA;   1499  1212      855.0000   366                    855.0000   607395         &#xA;   1537  1304      855.0000   271                    855.0000   626288         &#xA;   1589  1359      855.0000   287                    855.0000   643970         &#xA;   1657  1369      855.0000   229                    855.0000   644953         &#xA;   1726  1288      855.0000   396                    855.0000   624415         &#xA;   1805  1403      855.0000   323                    855.0000   646346         &#xA;                                                  Impl Bds: 5                  &#xA;   1887  1365      855.0000   542                    855.0000   629803         &#xA;   1980  1422      855.0000   309                    855.0000   647506         &#xA;Elapsed time = 690.33 sec. (499926.05 ticks, tree = 64.50 MB)&#xA;   2069  1517      855.0000   332                    855.0000   684526         &#xA;   2174  1613      855.0000   202                    855.0000   694310         &#xA;   2285  1536      855.0000   307                    855.0000   685722         &#xA;   2396  1783      855.0000   327                    855.0000   709940         &#xA;   2505  1682      855.0000   930                    855.0000   698222         &#xA;   2616  2011      855.0000   305                    855.0000   743888         &#xA;   2727  2175      855.0000   365                    855.0000   759293         &#xA;   2848  2078      855.0000   280                    855.0000   746821         &#xA;   2962  2501      855.0000  1381                    855.0000   827067         &#xA;   3048  2261      855.0000   264                    855.0000   762486         &#xA;Elapsed time = 710.75 sec. (509516.88 ticks, tree = 99.71 MB)&#xA;*  3054+ 2043                          855.0000      855.0000             0.00%&#xA;Found incumbent of value 855.000000 after 710.82 sec. (509549.52 ticks)&#xA;   3147  2610      855.0000   291      855.0000      855.0000   833946    0.00%&#xA;   3211  2576      855.0000   249      855.0000      855.0000   833103    0.00%&#xA;   3250  2585      855.0000   278      855.0000      855.0000   833743    0.00%&#xA;   3271  2595      855.0000   326      855.0000      855.0000   834668    0.00%&#xA;   3281     5      855.0000  3277      855.0000      855.0000    99161    0.00%&#xA;   3283   500      855.0000  1692      855.0000      855.0000   357237    0.00%&#xA;                                                 Impl Bds: 21                  &#xA;   3284    32      855.0000  1570      855.0000      855.0000   135251    0.00%&#xA;   3286  2484      855.0000   577      855.0000      855.0000   812189    0.00%&#xA;   3287  2154      855.0000   148      855.0000      855.0000   758606    0.00%&#xA;   3288   903      855.0000  1334      855.0000      855.0000   497120    0.00%&#xA;Elapsed time = 752.34 sec. (527635.49 ticks, tree = 29.21 MB)&#xA;   3289  2347      855.0000   389      855.0000      855.0000   773394    0.00%&#xA;   3291  2437      855.0000   546      855.0000      855.0000   802675    0.00%&#xA;   3293   820      855.0000  1265      855.0000      855.0000   441684    0.00%&#xA;   3294   558      855.0000  1333      855.0000      855.0000   349517    0.00%&#xA;   3295   616      855.0000  1287      855.0000      855.0000   364916    0.00%&#xA;   3296  2086      855.0000   255      855.0000      855.0000   747431    0.00%&#xA;   3297  2517      855.0000  1046      855.0000      855.0000   829337    0.00%&#xA;   3298     6      855.0000  3637      855.0000      855.0000    67877    0.00%&#xA;   3299     7      855.0000  4466      855.0000      855.0000   141055    0.00%&#xA;                                                 Impl Bds: 19                  &#xA;                                                 Impl Bds: 69                  &#xA;&#xA;GUB cover cuts applied:  421&#xA;Clique cuts applied:  179&#xA;Cover cuts applied:  25&#xA;Implied bound cuts applied:  159&#xA;Flow cuts applied:  100&#xA;Mixed integer rounding cuts applied:  1184&#xA;Zero-half cuts applied:  114&#xA;&#xA;Root node processing (before b&amp;amp;c):&#xA;  Real time             =  304.73 sec. (293507.17 ticks)&#xA;Parallel b&amp;amp;c, 32 threads:&#xA;  Real time             = 1495.47 sec. (1264489.70 ticks)&#xA;  Sync time (average)   =  215.72 sec.&#xA;  Wait time (average)   =    0.00 sec.&#xA;                          ------------&#xA;Total (root+branch&amp;amp;cut) = 1800.20 sec. (1557996.87 ticks)&#xA;CPLEX 12.10.0.0: optimal integer solution; objective 855&#xA;1545023 MIP simplex iterations&#xA;3300 branch-and-bound nodes&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5796" LastEditorUserId="5796" LastEditDate="2021-08-02T20:31:43.140" LastActivityDate="2021-08-03T15:32:47.550" Title="Why does CPLEX continue solving after finding the optimal solution?" Tags="|cplex|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="6673" PostTypeId="1" CreationDate="2021-08-02T20:38:44.657" Score="1" ViewCount="95" Body="&lt;p&gt;Let assume we have operation &lt;span class=&quot;math-container&quot;&gt;$r \in R$&lt;/span&gt;, machine &lt;span class=&quot;math-container&quot;&gt;$n \in N$&lt;/span&gt; and day &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$S_{r}$&lt;/span&gt; is the service duration of operation &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;. Note that &lt;span class=&quot;math-container&quot;&gt;$S_{r}$&lt;/span&gt; can be defined based on time slot (e.g., &lt;span class=&quot;math-container&quot;&gt;$S_{1}$&lt;/span&gt; can be 2 time slots). In this problem, a machine can handle multiple operations at the same time.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{rnt}$&lt;/span&gt; is a binary variable indicating whether operation &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; is allocated to machine &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$a_{rt}$&lt;/span&gt; is a non-negative variable indicating the start time of serving operation &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Given the above assumptions, how can I formulate a constraint set to restrict the number of overlapping operations on a machine to a predefined value of &lt;span class=&quot;math-container&quot;&gt;$MR$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;For more clarity, let us consider an example. For instance, we have 8 operations and one machine. If &lt;span class=&quot;math-container&quot;&gt;$S_{1}=3$&lt;/span&gt;, we should identify what operations overlap with operation &lt;span class=&quot;math-container&quot;&gt;$r=1$&lt;/span&gt; during its service. Therefore, we should check three-time slots. The below example shows the overlapping operations with operation &lt;span class=&quot;math-container&quot;&gt;$r=1$&lt;/span&gt;, where each number represents an operation and each row represents overlapping operations at each time slot.&lt;/p&gt;&#xA;&lt;p&gt;1, 2, 3, 4&lt;/p&gt;&#xA;&lt;p&gt;1, 4, 5, 6&lt;/p&gt;&#xA;&lt;p&gt;1, 5, 6, 7, 8&lt;/p&gt;&#xA;&lt;p&gt;Let me know if you need further explanation. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="5598" LastEditDate="2021-08-02T23:20:01.427" LastActivityDate="2021-08-06T07:34:23.127" Title="Formulate a constraint set to identify the number of overlapping operations" Tags="|mixed-integer-programming|constraint|scheduling|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6674" PostTypeId="1" AcceptedAnswerId="6675" CreationDate="2021-08-03T12:36:55.620" Score="5" ViewCount="774" Body="&lt;p&gt;I would like to know about the linearization of the &lt;span class=&quot;math-container&quot;&gt;$(If, Then)$&lt;/span&gt; constraints as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{l}&#xA;\text { If: } \\ &#xA;15 \leqslant x \leqslant 25 \\ &#xA;\text { then: } \quad y=\color{blue}{a} x+\color{green}{b} \\ &#xA;\text { elself: } \\&#xA;25 \leqslant x \leqslant 35 \\&#xA;\text { then: } \quad y=\color{blue}{a}^{\color{blue}{\prime}} x+\color{green}{b}^{\color{green}{\prime}} \\&#xA;\text { elself: } &#xA;\\ 35 \leqslant x \leqslant 45 \\ &#xA;\text { then: } \quad y=\color{blue}{a}^{\color{blue}{\prime \prime}} x+\color{green}{b}^{\color{green}{\prime \prime}} \\&#xA;\text { elself: } &#xA;\\ 45 \leqslant x \leqslant 55 \\&#xA;\text { then: } \quad y=\color{blue}{a}^{\color{blue}{\prime \prime \prime}} x+\color{green}{b}^{\color{green}{\prime \prime \prime}} \\&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are continuous variables and &lt;span class=&quot;math-container&quot;&gt;$\color{blue}{a}$&lt;/span&gt;'s and &lt;span class=&quot;math-container&quot;&gt;$\color{green}{b}$&lt;/span&gt;'s are constant. We have tried to introduce the binary auxiliary variables for each set of constraints and finally linking these constraints with whose specific binary variable. This approach seems to work fine, but I am facing that we will have to use the product of the binary and continuous variables. I knew that we can use specific linearization to do this.&#xA;&lt;strong&gt;I was wondering if, is there another way to formulate this problem efficiently?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-08-03T20:23:50.270" Title="How to linearize specific range constraints?" Tags="|optimization|mixed-integer-programming|linearization|logical-constraints|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="6675" PostTypeId="2" ParentId="6674" CreationDate="2021-08-03T13:02:16.813" Score="7" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; be a binary variable that equals &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is in the interval &lt;span class=&quot;math-container&quot;&gt;$i \in \{[15,25],[25,35],[35,45],[45,55]\}$&lt;/span&gt;. You can express &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; as a convex combination of the extreme points of these intervals by introducing variables &lt;span class=&quot;math-container&quot;&gt;$\lambda_0, \lambda_1,\lambda_2,\lambda_3, \lambda_4 \in \mathbb{R}^+$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; denotes your piecewise linear function, the objective function is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;&amp;amp;f(15)\lambda_0+f(25)\lambda_1+f(35)\lambda_2+f(45)\lambda_3 +f(55)\lambda_4 \\&#xA;=&amp;amp;(15a+b)\lambda_0+ (25a'+b')\lambda_1 +(35a''+b'')\lambda_2+ (45a'''+b''')\lambda_3 +(55a'''+b''')\lambda_4&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and the constraints are&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA; 1 &amp;amp;= y_1+y_2+y_3+y_4 \tag{1}\\&#xA;x &amp;amp;= 15\lambda_0+25\lambda_1+35\lambda_2+45\lambda_3+55\lambda_4\tag{2}\\&#xA;1 &amp;amp;=\lambda_0+\lambda_1+\lambda_2+\lambda_3 + \lambda_4\tag{3}\\&#xA;y_1&amp;amp;\le \lambda_0+\lambda_1\tag{4}\\&#xA;y_2&amp;amp;\le \lambda_1+\lambda_2\tag{5}\\&#xA;y_3&amp;amp;\le \lambda_2+\lambda_3\tag{6}\\&#xA;y_4&amp;amp;\le \lambda_3+\lambda_4\tag{7}\\&#xA;y&amp;amp;\in \{0,1\}\\&#xA;\lambda&amp;amp;\ge 0&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Another option, using the same binary variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;, is to rewrite &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in terms of &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;, and in terms of the ranges of each interval &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;x &amp;amp;= (15y_1+x_1)+(25y_2+x_2)+(35y_3+x_3)+(45y_4+x_4) \\&#xA;x_1 &amp;amp;\le 10 y_1 \\&#xA;x_2 &amp;amp;\le 10 y_2 \\&#xA;x_3 &amp;amp;\le 10 y_3 \\&#xA;x_4 &amp;amp;\le 10 y_4 \\&#xA;\end{align*}&lt;/span&gt;&#xA;Make sure you are on exactly one interval:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_1+y_2+y_3+y_4 = 1&#xA;$$&lt;/span&gt;&#xA;And rewrite your piecewise linear function as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;f(x) &amp;amp;= \Big(a(x_1+15y_1) +by_1\Big)  \\&#xA;&amp;amp;+\Big(a'(x_2+25y_2)+b'y_2\Big) \\&#xA;&amp;amp;+\Big(a''(x_3+35y_3)+b''y_3\Big) \\&#xA;&amp;amp;+\Big(a'''(x_4+45y_4)+b'''y_4\Big)&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;And last but not least, the &lt;em&gt;usual&lt;/em&gt; (?) way with big Ms, maximize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;1&amp;amp;=y_1+y_2+y_3+y_4 \\&#xA; x &amp;amp;\le 25y_1 + 35y_2 + 45y_3 +55 y_4 \\&#xA;x &amp;amp;\ge 15y_1 + 25y_2 + 35y_3 +45 y_4 \\&#xA; z &amp;amp;\le (ax+b) + M_1(1-y_1) \\&#xA; z &amp;amp;\le (a'x+b') + M_2(1-y_2) \\&#xA; z &amp;amp;\le  (a''x+b'') +M_3(1-y_3) \\&#xA; z &amp;amp;\le  (a'''x+b''') +M_4(1-y_4) \\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-08-03T20:23:50.270" LastActivityDate="2021-08-03T20:23:50.270" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6676" PostTypeId="1" AcceptedAnswerId="6678" CreationDate="2021-08-03T13:06:33.930" Score="5" ViewCount="555" Body="&lt;p&gt;I have k sets of items. I want to choose n items from each set, &lt;span class=&quot;math-container&quot;&gt;$n \cdot k$&lt;/span&gt; items total.&lt;/p&gt;&#xA;&lt;p&gt;I would like to choose the &lt;span class=&quot;math-container&quot;&gt;$n \cdot k$&lt;/span&gt; items under some optimization criterion, e.g. that the sum of the &lt;span class=&quot;math-container&quot;&gt;$\ell_1$&lt;/span&gt; distance between every pair of items is maximized.&lt;/p&gt;&#xA;&lt;p&gt;I am okay slightly relaxing the criterion that &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; items must be drawn from each set, as long as &lt;span class=&quot;math-container&quot;&gt;$n \cdot k$&lt;/span&gt; items total are chosen.&lt;/p&gt;&#xA;&lt;p&gt;What is this kind of optimization specifically? Where can I find an implementation, preferably a python implementation?&lt;/p&gt;&#xA;" OwnerUserId="6000" LastActivityDate="2021-08-03T18:25:27.917" Title="Combinatorial optimization, implementation needed" Tags="|combinatorial-optimization|knapsack|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6677" PostTypeId="2" ParentId="6676" CreationDate="2021-08-03T13:22:07.483" Score="4" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if item &lt;span class=&quot;math-container&quot;&gt;$i \in I_k$&lt;/span&gt; is selected.&lt;/p&gt;&#xA;&lt;p&gt;You want to choose &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; items from each set &lt;span class=&quot;math-container&quot;&gt;$I_k$&lt;/span&gt;, so impose&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i\in I_k} x_{i} = n \quad \forall k&#xA;$$&lt;/span&gt;&#xA;You can optimize whatever you want with these variables. If you want to maximize the &lt;span class=&quot;math-container&quot;&gt;$\ell_1$&lt;/span&gt; distance between each pair of items, you are going to need a pairwise variable as well. So introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if items &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are simultaneously selected:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_i + x_j \le y_{ij} +1 \\&#xA;y_{ij} \le x_i \\&#xA;y_{ij} \le x_j&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and use the following objective function:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i,j} d_{ij}^{\ell^1} y_{ij}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I don't know if this is a known optimization problem. But the above formulation is linear (with integer variables), commonly refered to as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Integer_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIP&lt;/a&gt;. You can easily implement this in Python with &lt;a href=&quot;https://coin-or.github.io/pulp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PuLp&lt;/a&gt; or &lt;a href=&quot;http://www.pyomo.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="67" LastEditDate="2021-08-03T18:25:27.917" LastActivityDate="2021-08-03T18:25:27.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6678" PostTypeId="2" ParentId="6676" CreationDate="2021-08-03T13:23:05.860" Score="5" Body="&lt;p&gt;It seems what you are looking for, is the maximum dispersion problem. The following blog post discusses a MIQP formulation along with a number of different MILP formulations&#xA;&lt;a href=&quot;http://yetanothermathprogrammingconsultant.blogspot.com/2019/06/maximum-dispersion.html?m=1&quot; rel=&quot;noreferrer&quot;&gt;http://yetanothermathprogrammingconsultant.blogspot.com/2019/06/maximum-dispersion.html?m=1&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-08-03T13:23:05.860" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6679" PostTypeId="2" ParentId="6672" CreationDate="2021-08-03T15:32:47.550" Score="5" Body="&lt;p&gt;As suggested, I'm synthesizing some comments into an &amp;quot;answer&amp;quot; ... although I'm not sure it actually answers anything.&lt;/p&gt;&#xA;&lt;p&gt;First, small values for the gap parameters can sometimes result in CPLEX printing a gap value that rounds to zero in the log but still cranking away because the actual gap is slightly larger than the parameter value. Setting mipgap (relative gap tolerance) to 0.05 and leaving absmipgap (absolute tolerance) at the default 1e-6 should definitely have stopped CPLEX. (It stops when either, not necessarily both, conditions are met.)&lt;/p&gt;&#xA;&lt;p&gt;Second, the iteration count in the log is not monotone, which it should be (there being no such thing as negative simplex pivots). Coupled with the fairly high thread count (32), I suspect that timing of thread might be a factor. Threads chewing on nodes communicate intermittently with the &amp;quot;one thread to rule them all&amp;quot;, and do not know immediately when other threads have found a new incumbent or tightened the bound. Still, the time laps between reaching a zero gap and terminating is seriously out of whack, suggesting a possible bug.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-03T15:32:47.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6680" PostTypeId="2" ParentId="6674" CreationDate="2021-08-03T18:43:46.670" Score="3" Body="&lt;p&gt;If the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; function is continuous (meaning &lt;span class=&quot;math-container&quot;&gt;$a\cdot 25 + b = a^\prime \cdot 25 + b^\prime$&lt;/span&gt; and similarly at other breakpoints), you can use an SOS2 constraint to model this. Let &lt;span class=&quot;math-container&quot;&gt;$p_0, \dots, p_n$&lt;/span&gt; be the breakpoints (&lt;span class=&quot;math-container&quot;&gt;$n=4,\,p_0 = 15,\,p_4 =55$&lt;/span&gt; in your example) and &lt;span class=&quot;math-container&quot;&gt;$\gamma_0 \dots, \gamma_n$&lt;/span&gt; be the values of the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; function at &lt;span class=&quot;math-container&quot;&gt;$p_0, \dots, p_n$&lt;/span&gt;. Add continuous variables &lt;span class=&quot;math-container&quot;&gt;$w_0, \dots, w_n \in [0,1]$&lt;/span&gt;, along with the constraints &lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;w_{0}+\dots+w_{n} &amp;amp; =1\\&#xA;p_{0}w_{0}+\dots+p_{n}w_{n} &amp;amp; =x\\&#xA;\gamma_{0}w_{0}+\dots+\gamma_{n}w_{n} &amp;amp; =y.&#xA;\end{align*}&lt;/span&gt;&#xA;Now add a constraint telling the solver that &lt;span class=&quot;math-container&quot;&gt;$w_0, \dots, w_n$&lt;/span&gt; form a type 2 special ordered set (SOS2). That tells the solver that at most two of the &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; can be nonzero, and those two must be consecutive. Combined with the first constraint, that means &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; will be a convex combination of two consecutive breakpoints and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; will be the same convex combination of the function values at those two breakpoints.&lt;/p&gt;&#xA;&lt;p&gt;This of course requires a solver that understands SOS2 constraints. Internally, the solver is likely to add a bunch of binary variables and basically do the linearization for you.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-03T18:43:46.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6681" PostTypeId="1" AcceptedAnswerId="6685" CreationDate="2021-08-03T22:58:01.467" Score="4" ViewCount="320" Body="&lt;p&gt;Let's say I have an 16 core machine and many roughly equally hard MILP problems and enough RAM. The latency of solving doesn't matter. With how many cores should I start solvers on to maximize throughput (instances solved per second)?&lt;/p&gt;&#xA;&lt;p&gt;I am looking for general advice for MILP solvers using Branch and Bound based or Local Solvers. If you have experience with a specific problem class you are welcome to answer too.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="123" LastEditDate="2021-08-04T06:50:02.030" LastActivityDate="2021-08-05T02:34:55.007" Title="When solving many MILPs how to assign CPU cores to solver instances?" Tags="|mixed-integer-programming|branch-and-bound|benchmark|parallel-computing|local-search|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6682" PostTypeId="2" ParentId="6670" CreationDate="2021-08-04T02:55:56.890" Score="1" Body="&lt;p&gt;Before I dive into the proposed solutions, let's first define the set &lt;span class=&quot;math-container&quot;&gt;$T = \mathbb{N}^{*}_{\leqslant m}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$m \in \mathbb{N}^{*}$&lt;/span&gt; is the available periods' number, since you did not define the set &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, let's analyze your problems.&#xA;From what I understood, we have two remaining requirements:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If a given age group &lt;span class=&quot;math-container&quot;&gt;$a \in A$&lt;/span&gt; is serviced in a given facility &lt;span class=&quot;math-container&quot;&gt;$j \in F$&lt;/span&gt; at the period &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt;, then all the age groups serviced in &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at the periods &lt;span class=&quot;math-container&quot;&gt;$t^{'} \in T: t^{'} &amp;gt; t$&lt;/span&gt; must have a priority lower than &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;Certain types of commodities cannot be utilized by certain age groups.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;First requirement&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;According to what you stated, what we need to ensure is that, if a given age group &lt;span class=&quot;math-container&quot;&gt;$a \in A$&lt;/span&gt; is serviced in a given facility &lt;span class=&quot;math-container&quot;&gt;$j \in F$&lt;/span&gt; at the period &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt;, then all the age groups serviced in &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at the periods &lt;span class=&quot;math-container&quot;&gt;$t^{'} \in T: t^{'} &amp;gt; t$&lt;/span&gt; must have a priority lower than &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To substantiate this requirement, let's define a function &lt;span class=&quot;math-container&quot;&gt;$P: A \mapsto \mathbb{R}$&lt;/span&gt; as being the available group ages' priority function.&#xA;In order for this function to suit your problem, we can say that &lt;span class=&quot;math-container&quot;&gt;$P(a) &amp;gt; P(a^{'})$&lt;/span&gt; whenever the minimum allowed age of age group &lt;span class=&quot;math-container&quot;&gt;$a \in A$&lt;/span&gt; is greater than or equals to the maximum allowed age of age group &lt;span class=&quot;math-container&quot;&gt;$a^{'} \in A$&lt;/span&gt;, note that I am not considering the possibility of overlapping ages between distinct periods since you did not explicit it.&#xA;Therefore, we can represent the desired requirement by the following set of constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;1 - z_{ijta} \geqslant z_{ijt^{'}a^{'}} \quad \quad \forall i \in I, &#xA;\\&#xA;\quad\quad\quad\quad\quad\quad\quad\quad\forall j \in J, &#xA;\\&#xA;\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\forall t \in T \backslash \{1\}, \forall t^{'} \in T : t^{'} &amp;lt; t, &#xA;\\&#xA;\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\forall a, a^{'} \in A : P(a^{'}) &amp;lt; P(a)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Second requirement&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;According to what you stated, what we need to ensure is that certain types of commodities cannot be utilized by certain age groups.&lt;/p&gt;&#xA;&lt;p&gt;To substantiate this requirement, let's define a function&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;B: a \mapsto \{c \in C : \text{ the commodity $c$ can not be utilized be the age group $a$}\}&#xA;$$&lt;/span&gt;&#xA;as being the commodities constricting function, and the parameter &lt;span class=&quot;math-container&quot;&gt;$M_c \in \mathbb{R}$&lt;/span&gt; as being the commodity &lt;span class=&quot;math-container&quot;&gt;$c \in C$&lt;/span&gt;' available amount.&#xA;Now, we just have to use it in a set of constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;i_{jct} \leqslant M_{c} (1 - z_{ijct}) \quad \quad \forall i \in I, &#xA;\\&#xA;\quad\quad\quad\quad\quad\quad\quad\quad\quad\forall j \in J, &#xA;\\&#xA;\quad\quad\quad\quad\quad\quad\quad\quad\quad\forall t \in T, &#xA;\\&#xA;\quad\quad\quad\quad\quad\quad\quad\quad\quad\forall a \in A&#xA;\\&#xA;\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\forall c \in B(a)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you find any errors, let me know.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastActivityDate="2021-08-04T02:55:56.890" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6683" PostTypeId="2" ParentId="6681" CreationDate="2021-08-04T03:21:55.230" Score="4" Body="&lt;p&gt;So we know that MILP instances are independent and that the total throughput is to be maximized. In practice, increasing the number of threads used by a solver to solve a MILP instance could marginally improve the runtime only up to some point. Such optimal number of threads should be checked on a case by case basis. In CPLEX, for instance, &lt;a href=&quot;https://www.ibm.com/support/pages/effects-multithread-execution-cplex-optimization-studio-models&quot; rel=&quot;nofollow noreferrer&quot;&gt;the parallelism efficiency decreases for more than 4-8 threads. Increasing the thread count past this number will not significantly reduce the execution time.&lt;/a&gt;. This may be considered as a general rule of thumb.&lt;/p&gt;&#xA;&lt;p&gt;Once you fix the number of threads used by the solver, you can use a job scheduler to allocate your jobs (solving MILP instances) to the resources (e.g., cores) that you specify. A job scheduler would start a new job automatically once the previous job is completed. I have mainly used &lt;a href=&quot;https://slurm.schedmd.com/overview.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Slurm&lt;/a&gt;. Note that in general a computer node/core may have multiple threads (see &lt;a href=&quot;https://login.scg.stanford.edu/faqs/cores/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for more details). In a linux machine running &lt;code&gt;lscpu&lt;/code&gt; in a bash terminal would show this information. Here is an example with 1 thread per core:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Architecture:          x86_64&#xA;CPU op-mode(s):        32-bit, 64-bit&#xA;Byte Order:            Little Endian&#xA;CPU(s):                16&#xA;On-line CPU(s) list:   0-15&#xA;Thread(s) per core:    1&#xA;Core(s) per socket:    8&#xA;Socket(s):             2&#xA;NUMA node(s):          2&#xA;Vendor ID:             GenuineIntel&#xA;CPU family:            6&#xA;Model:                 62&#xA;Model name:            Intel(R) Xeon(R) CPU E5-2667 v2 @ 3.30GHz&#xA;Stepping:              4&#xA;CPU MHz:               3299.910&#xA;BogoMIPS:              6599.11&#xA;Virtualization:        VT-x&#xA;L1d cache:             32K&#xA;L1i cache:             32K&#xA;L2 cache:              256K&#xA;L3 cache:              25600K&#xA;NUMA node0 CPU(s):     0,2,4,6,8,10,12,14&#xA;NUMA node1 CPU(s):     1,3,5,7,9,11,13,15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You should also test the scenario that restricts each job to one core (e.g., in the example above, the number of threads used by the solver is set to 1 and each job is allocated to one core). The operating system (OS) typically switches intensive threads between different cores to balance the thermal load of a multicore processor. This can cause latencies due to the OS bringing jobs from one core to another. So the last scenario may also prove efficient.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;One last comment!&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There is still room for improving the efficiency if you are really into it! This requires you to have/generate a profile or sample data as to how long an instance with features such as number of nonzero elements, number of variables and number of constraints would take (if your MILP instances represent different instances of the same problem, then you can also use that problem's features). Based on this sample, you can solve an optimisation problem that allocates jobs to a given number of cores/nodes such that the maximum completion time (makespan) of nodes is minimized. You can even go ahead and solve a two-stage stochastic program that minimizes the expected makespan (first-stage decisions are allocation of the jobs to nodes and second-stage decisions are the sequencing of them on each node).&lt;/p&gt;&#xA;" OwnerUserId="1202" LastEditorUserId="1202" LastEditDate="2021-08-05T02:34:55.007" LastActivityDate="2021-08-05T02:34:55.007" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6684" PostTypeId="2" ParentId="4449" CreationDate="2021-08-04T12:54:28.627" Score="2" Body="&lt;p&gt;Let's make it more clear.&lt;/p&gt;&#xA;&lt;p&gt;Stochastic Programming is not Stochastic Optimization.&#xA;When you say Stochastic Programming the above answer of @Larry is explaining more about &amp;quot;stochastic programming&amp;quot;. This is when your problem of study has some uncertainty (e.g. demand uncertainty, arrival times uncertainty). The robust optimization sets with Stochastic Programming under the classification of optimization problems with uncertainties.&lt;/p&gt;&#xA;&lt;p&gt;However, when you say stochastic optimization, this is about the technique/solution methodology you use to solve either a deterministic optimization model/problem or a stochastic optimization model/problem. In this case, the above answer of @Nikos Kazazakis describes this.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, @LarrySnyder610 tried to answer the following question: &amp;quot;Difference between stochastic programming and robust optimization?&amp;quot; whereas @Nikos Kazazakis highlighted the: Difference between stochastic optimization and deterministic optimization approaches?&lt;/p&gt;&#xA;" OwnerUserId="6006" LastEditorUserId="123" LastEditDate="2021-08-04T14:14:36.333" LastActivityDate="2021-08-04T14:14:36.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6685" PostTypeId="2" ParentId="6681" CreationDate="2021-08-04T17:05:51.903" Score="2" Body="&lt;p&gt;As far as I know, solution speed for solvers is typically a sublinear function of the number of threads/cores. This makes sense since parallel processing requires additional effort (CPU cycles) to coordinate threads, and may sometimes be subject to blocking. Based on that, and assuming a reasonably large pool of problems and adequate RAM, I would probably allocate one core per problem (or, assuming the cores each accommodate multiple threads and you are drowning in RAM) maybe one thread per problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-04T17:05:51.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6686" PostTypeId="1" AcceptedAnswerId="6713" CreationDate="2021-08-04T19:12:02.600" Score="6" ViewCount="141" Body="&lt;p&gt;I'm trying to linearise these constraints, but I am not able to do correctly do it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y_t = \max\{ y_{t-1} + a_t - z_t, 0 \}  $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My attempt was this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}y'_t &amp;amp;\geq a_t - z_t\\y'_t &amp;amp;\geq y^{'}_{t-1} + a_t - z_t \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Am I correct?&lt;/p&gt;&#xA;&lt;p&gt;Additionally, I wanted to linearize this constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_t = y_{t-1} + a_t - z_t + \min\{ y'_{t-1} + a_t - z_t,0 \}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This one I am clueless on. I will appreciate if anyone could please give any leads on this.&lt;/p&gt;&#xA;" OwnerDisplayName="user4387" LastEditorUserId="2556" LastEditDate="2021-08-05T11:30:02.757" LastActivityDate="2021-08-06T15:52:39.863" Title="Linearise $\max\{ y_{t-1} + a_t - z_t ,0\}$" Tags="|constraint|linearization|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6687" PostTypeId="2" ParentId="6686" CreationDate="2021-08-04T19:45:48.280" Score="5" Body="&lt;p&gt;If you are &lt;em&gt;maximizing&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; (or any increasing function of &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt;) and using &amp;quot;standard&amp;quot; inequalities, you  need something to preclude the solver from setting &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$+\infty$&lt;/span&gt;. You can use the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;y_t &amp;amp;\le 0 +M(1-\delta) \tag{1}\\&#xA;y_t &amp;amp;\le y_{t-1}+a_t-z_t +M\delta \tag{2}\\&#xA;\delta &amp;amp;\in \{0,1\}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\delta =1$&lt;/span&gt;, constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; is inactive and &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; will take value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, since you are maximizing &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$\delta=0$&lt;/span&gt;, constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; is inactive and &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; will take value &lt;span class=&quot;math-container&quot;&gt;$y_{t-1}+a_t-z_t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For your constraint, the same philosophy holds. You can replace &lt;span class=&quot;math-container&quot;&gt;$\min(u)$&lt;/span&gt; by a variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and add the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;x &amp;amp;\le u \tag{3}\\&#xA;x &amp;amp;\le 0 \tag{4}\\&#xA;x &amp;amp;\ge u +M(1-\omega) \tag{5}\\&#xA;x &amp;amp;\ge 0 +M\omega \tag{6}\\&#xA;\omega &amp;amp;\in \{0,1\}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-08-06T15:47:58.903" LastActivityDate="2021-08-06T15:47:58.903" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6689" PostTypeId="1" CreationDate="2021-08-04T23:05:19.403" Score="3" ViewCount="429" Body="&lt;p&gt;In my optimization problem the objective function and all the constraints are linear. The decision variables are binary. [so, it's BLP] Some of the hard constraints are very time-consuming to be solved, therefore I would like to relax them by the lagrangian multipliers (ie, putting them into the objective function in a penalized way). The optimization software I'm using (&lt;em&gt;lpSolve&lt;/em&gt;) provides the dual solution of the simplex method (it retrieves the values of the dual variables (the reduced costs)). BUT I don't know what's the relationship btw the dual solutions and the relaxed constraints to be put in the objective function.&lt;/p&gt;&#xA;" OwnerUserId="5369" LastEditorUserId="907" LastEditDate="2021-08-05T18:18:00.003" LastActivityDate="2021-08-05T18:18:00.003" Title="In binary linear programming, what's the relationship between the dual solution and the lagrangian multipliers?" Tags="|mixed-integer-programming|binary-variable|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="6690" PostTypeId="1" CreationDate="2021-08-05T10:12:30.533" Score="1" ViewCount="211" Body="&lt;p&gt;I have defined the index for time to be T = [1,2,3,4,5,6]. I want that that the demand that to be addressed twice in a given a time period, when the difference between the time the demand is addressed the first time and the demand is addressed the second time is 2.&#xA;Suppose the demand at a location is is given by &lt;span class=&quot;math-container&quot;&gt;$D_i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt; represents the location of the demand and &lt;span class=&quot;math-container&quot;&gt;$\omega_{ijt}$&lt;/span&gt; are the number of people who are meant to be located from location &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in a time period &lt;span class=&quot;math-container&quot;&gt;$t\in T$&lt;/span&gt;. Currently I have that &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j \in J} \sum_{t \in T} \omega_{ijt} = D_i $$&lt;/span&gt;, which will ensure that the demand is allocated to location &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in time t. However, how can introduce the idea of having the same demand reintroduced in my model, when the difference between the demand first addressed and the the model time is &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It will help me greatly, if someone could please help me formulate this idea.&lt;/p&gt;&#xA;&lt;p&gt;Edit: If I have a demand of 40 people at a, 50 people at b, 60 people at c. I want that all of these people at locations &lt;span class=&quot;math-container&quot;&gt;$a,b,c \in I$&lt;/span&gt; visit location &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt; within a certain time period &lt;span class=&quot;math-container&quot;&gt;$t &amp;lt; T$&lt;/span&gt;, where T can be &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; weeks and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; can be 3 weeks . This means that all of the demand can be addressed within 3 weeks. Next, I want that this demand may only visit the facility again if difference between the time that the demand first visited and next visit will be 3 weeks. I do not know how to model this.&lt;/p&gt;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerDisplayName="user4387" LastEditorDisplayName="user4387" LastEditDate="2021-08-07T18:39:33.603" LastActivityDate="2021-08-07T20:43:07.493" Title="How do I write the following constraint?" Tags="|modeling|constraint|pyomo|" AnswerCount="1" CommentCount="19" ContentLicense="CC BY-SA 4.0" />
  <row Id="6691" PostTypeId="1" CreationDate="2021-08-05T13:11:20.457" Score="3" ViewCount="150" Body="&lt;p&gt;I am searching for the academic name of the problem of computing a valid schedule for planned order. More precisely, The problem consists of: list of orders &lt;strong&gt;O&lt;/strong&gt;, available vehicle per day &lt;strong&gt;K&lt;/strong&gt;, and the quantity of stock replenishment per day. My goal is to compute a schedule of order &lt;em&gt;o&lt;/em&gt; delivered at day &lt;em&gt;j&lt;/em&gt; while making sure that stock is not below or above critical levels.&lt;/p&gt;&#xA;" OwnerUserId="6016" LastEditorUserId="491" LastEditDate="2021-12-02T14:05:04.983" LastActivityDate="2021-12-02T14:05:04.983" Title="Scheduling of planned orders while respecting certain stock levels" Tags="|modeling|reference-request|scheduling|inventory|terminology|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6692" PostTypeId="2" ParentId="6691" CreationDate="2021-08-05T13:34:07.677" Score="2" Body="&lt;p&gt;This sounds like the &lt;em&gt;inventory routing problem&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-08-05T13:34:07.677" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6693" PostTypeId="1" AcceptedAnswerId="6696" CreationDate="2021-08-05T15:52:54.237" Score="5" ViewCount="706" Body="&lt;p&gt;I am looking to form a Capacitated VRP problem like this:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have 40,000 dropping locations with Demands of each point available&lt;/li&gt;&#xA;&lt;li&gt;I have 5-6 types of vehicles available with different capacities and costs&lt;/li&gt;&#xA;&lt;li&gt;I know the cost of travelling from one point to another for all the vehicles&lt;/li&gt;&#xA;&lt;li&gt;A single Hub is considered here&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;My goal here is to select the combinations of vehicles, such that the total cost is minimized.&lt;/p&gt;&#xA;&lt;p&gt;What are some heuristics I can apply here? As I am trying to model it in R, I am trying to avoid MIP model because it might take too much time.&lt;/p&gt;&#xA;&lt;p&gt;I have searched different works of literature but couldn't find anything appropriate. So any help in this would mean a lot!&lt;/p&gt;&#xA;" OwnerUserId="5532" LastEditorUserId="5532" LastEditDate="2021-08-15T13:28:35.190" LastActivityDate="2021-08-15T13:28:35.190" Title="Solving Capacitated VRP with multiple various sized vehicles" Tags="|mixed-integer-programming|combinatorial-optimization|vehicle-routing|heuristics|r|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6694" PostTypeId="2" ParentId="6691" CreationDate="2021-08-05T15:56:38.483" Score="1" Body="&lt;p&gt;I think the &amp;quot;&lt;em&gt;drayage scheduling problem&lt;/em&gt; &amp;quot; might open a window for you.&lt;/p&gt;&#xA;" OwnerUserId="6006" LastActivityDate="2021-08-05T15:56:38.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6696" PostTypeId="2" ParentId="6693" CreationDate="2021-08-05T18:06:27.320" Score="5" Body="&lt;p&gt;You could cluster 40,000 dropping locations (by grouping them based on location/vehicle type need) to some reasonable number and can try to implement metaheuristics like Simulated annealing, Particle swarm etc. . Though they won't guarantee optimality but can tune accordingly to achieve desired solution quality.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2021-08-05T18:06:27.320" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6697" PostTypeId="2" ParentId="6693" CreationDate="2021-08-05T18:21:22.950" Score="3" Body="&lt;p&gt;I'm assuming in what follows that all demands must be met.&lt;/p&gt;&#xA;&lt;p&gt;R has a very good genetic algorithm package (&amp;quot;GA&amp;quot;) that includes support for permutation chromosomes. Assuming &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; destinations and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; vehicles (not vehicle types, but actual vehicles), you can use a GA with each chromosome a permutation of &lt;span class=&quot;math-container&quot;&gt;$1, \dots, n + m$&lt;/span&gt;. To decode a chromosome, use the first &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; values to permute the list of vehicles and the remaining &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; values to permute the list of destinations. Then assign each destination, in the permuted order, to the first vehicle (in the permuted order) that has remaining capacity sufficient to hold it. The fitness function will be the total cost of the solution.&lt;/p&gt;&#xA;&lt;p&gt;There's an implicit assumption here that your vehicle fleet has enough capacity (and individual demands are small enough relative to a vehicle's capacity) that any permutation decodes to a feasible solution. If that's not the case, one option is to allow the decoded solution to leave some demand unsatisfied and add to the fitness function a penalty for unmet demand. Another would be to just set the cost to Inf (or something really big if the GA package chokes on Inf) if the chromosome cannot be decoded to a feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;You might also want to explore the option in the GA package to do local search to try to improve a solution. The extra computation time per generation might or might not pay for itself.&lt;/p&gt;&#xA;&lt;p&gt;One more variation that might or might not work better. Rather than filling up vehicles (which would make it hard if not impossible to find a solution with level loads), it might be better to rotate through the permuted vehicle list. So each destination other than the first, gets assigned to the first vehicle with adequate capacity after the one that took the previous destination, cycling back to the top of the list as needed.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-05T18:21:22.950" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6698" PostTypeId="2" ParentId="6693" CreationDate="2021-08-05T18:26:54.353" Score="4" Body="&lt;p&gt;I'm not an expert in Vehicle Routing Problems, maybe someone else will have something more relevant to propose.&lt;/p&gt;&#xA;&lt;p&gt;I think that a good starting point is this article:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Efficiently solving very large-scale routing problems&amp;quot; (Arnold et al., 2019) &lt;a href=&quot;https://doi.org/10.1016/j.cor.2019.03.006&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt; &lt;a href=&quot;https://repository.uantwerpen.be/docman/irua/e11288/160227_2020_01_01.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;PDF&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This paper is not exactly about your problem, but about the Capacitated Vehicle Routing Problem (CVRP), which is a simplified version of your problem.&lt;/p&gt;&#xA;&lt;p&gt;However, they solve instances with up to 30000 locations, which is not far from your target, and, in Section 4.1, they describe how to adapt the classical Clark and Wright heuristic to large scale CVRPs and their experiments show that it can find pretty good solutions quickly (6% gap on average). In addition, it should be rather easy to implement.&lt;/p&gt;&#xA;&lt;p&gt;Now the question is, how to adapt this heuristic to your variant? I don't see an obvious way and I am not aware of something similar in the literature about the Heterogeneous Fleet Vehicle Routing Problems.&#xA;A simple approach would be to run the heuristic with only the vehicle type with the highest capacity, and after, try to change the vehicle type of each route for a cheaper one&lt;/p&gt;&#xA;&lt;p&gt;Note that an implementation in R will likely be slower, you might expect a factor 10 compared to the computation times from the papers&lt;/p&gt;&#xA;&lt;p&gt;EDIT&lt;/p&gt;&#xA;&lt;p&gt;The answers about cluster-first route-second approaches reminded me of another relevant approach, route-first cluster-second, as described in this article:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Route first—Cluster second methods for vehicle routing&amp;quot; (Beasley, 1983) &lt;a href=&quot;https://doi.org/10.1016/0305-0483(83)90033-6&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt; &lt;a href=&quot;http://people.brunel.ac.uk/%7Emastjjb/jeb/papers/omega_83.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;PDF&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The idea is to first solve a Travelling Salesman Problem with all nodes to get a giant tour, and then to partition this giant tour into routes by dynamic programming. The author discusses how to adapt it to the case of an heterogenous fleet at the end of the article.&lt;/p&gt;&#xA;&lt;p&gt;However, for a instance with 40000 locations, this requires to have a well optimized algorithm to solve the Travelling Salesman subproblem&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2021-08-06T09:09:45.287" LastActivityDate="2021-08-06T09:09:45.287" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6699" PostTypeId="1" AcceptedAnswerId="6702" CreationDate="2021-08-05T20:50:15.193" Score="2" ViewCount="1100" Body="&lt;pre&gt;&lt;code&gt;from mip import *&#xA;&#xA;q=[[4,5,0,2],[3,2,1,0],[0,1,4,5],[3,2,0,1],[2,1,3,2],[4,3,2,1],[3,4,2,0],[5,0,3,1],[0,4,3,3],[4,0,4,1]]&#xA;s=[11,1,1,1,1,1,1,1,1,1]&#xA;r=[6,8,4,7]&#xA;a=range(0,10)&#xA;b =range(0,20)&#xA;c = range(0,4)&#xA;d =[12,9,6,6]&#xA;o = Model()&#xA;x= [[o.add_var('x({},{})'.format(i, j), var_type=BINARY) for j in b] for i in a]&#xA;y = [[o.add_var('y({},{})'.format(k, j), var_type=BINARY) for j in b] for k in c]&#xA;g = o.add_var(name='max_i', var_type=CONTINUOUS)&#xA;h = o.add_var(name='min_i', var_type=CONTINUOUS)&#xA;&#xA;for i in a:&#xA;    o += xsum(x[i][j] for j in b) == s[i]&#xA;for j in b:&#xA;    o += xsum(x[i][j] for i in a) == 1&#xA;for k in c:&#xA;    o += xsum(y[k][j] for j in b) == d[k]&#xA;for j in b:&#xA;    for k in c:&#xA;        o += r[k] *(xsum(y[k][jj] for jj in b if jj &amp;lt;= j)) &amp;gt;= (xsum(( xsum (q[i][k]* x[i][jj] for i in a )for jj in b if jj &amp;lt;=j)))&#xA;for j in b:&#xA;    o += (xsum( xsum(r[k] * y[k][jj] for k in c) for jj in b if jj &amp;lt;= j)) - (xsum(xsum( xsum (q[i][k]* x[i][jj] for i in a) for k in c) for jj in b if jj&amp;lt;=j)) &amp;lt;= g&#xA;for j in b:&#xA;    o += (xsum( xsum(r[k] * y[k][jj] for k in c) for jj in b if jj &amp;lt;= j)) - (xsum(xsum( xsum (q[i][k]* x[i][jj] for i in a) for k in c) for jj in b if jj&amp;lt;=j)) &amp;gt;= h&#xA;o.objective = minimize(g-h)&#xA;o.optimize()&#xA;print(&amp;quot;Solution with {} found.&amp;quot;.format(o.objective_value))&#xA;for x in o.vars:&#xA;    print('{} : {}'.format(x.name, x.x))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&amp;quot;&amp;quot;&amp;quot;I have tried to solve the above MILP using python mip and tried cbc, gurobi solvers, i can able to solve it for small problem , lets say when s=[20,0,0,0,0,0,0,0,0,0] and d = [14,13,0,6], and also when length  of s is less than 5, but for the above inputs, it taking too much time (more than 8 hours and i can't wait).&lt;/p&gt;&#xA;&lt;p&gt;In the above test case, I have 282 variables and 154 constraints only and I have seen that number of variables and number of constraints alone doesn't contribute to how much time, the solver takes to solve. I have 10k variables and 7k constraints in my main problem to solve for.&#xA;I have tried constrained programming by limiting the values of variables by lb and ub, it didnt help. How can I solve it better? Help would be appreciated.&#xA;( g and h will be integers in all case, so I tried it by initializing as integer variables and giving close lb and ub, It also didn't help)&amp;quot;&amp;quot;&amp;quot;&lt;/p&gt;&#xA;" OwnerUserId="530" LastEditorUserId="123" LastEditDate="2021-08-06T07:32:55.200" LastActivityDate="2021-08-06T19:27:15.283" Title="How to solve MILP efficiently using MIP python? Any other solvers to quickly solve where I have only integer and binary variables alone?" Tags="|mixed-integer-programming|python|integer-programming|solver|gurobi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6700" PostTypeId="2" ParentId="6699" CreationDate="2021-08-05T21:10:15.227" Score="3" Body="&lt;p&gt;How big is the model? Is the time spent in the solver or in generating the model? Can you should a bit of the solver log file (say the beginning and the end)?&lt;/p&gt;&#xA;&lt;p&gt;I see one thing I don't like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for j in b:&#xA;    o += (xsum( xsum(r[k] * y[k][jj] for k in c) for jj in b if jj &amp;lt;= j)) - (xsum(xsum( xsum (q[i][k]* x[i][jj] for i in a) for k in c) for jj in b if jj&amp;lt;=j)) &amp;lt;= g&#xA;for j in b:&#xA;    o += (xsum( xsum(r[k] * y[k][jj] for k in c) for jj in b if jj &amp;lt;= j)) - (xsum(xsum( xsum (q[i][k]* x[i][jj] for i in a) for k in c) for jj in b if jj&amp;lt;=j)) &amp;gt;= h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This essentially duplicates a sizable expression. I would use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for j in b:&#xA;    o += z[j] == (xsum( xsum(r[k] * y[k][jj] for k in c) for jj in b if jj &amp;lt;= j)) - (xsum(xsum( xsum (q[i][k]* x[i][jj] for i in a) for k in c) for jj in b if jj&amp;lt;=j)) &#xA;    o += z[j] &amp;lt;= g&#xA;    o += z[j] &amp;gt;= h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;(More equations and variables but fewer nonzero elements).&lt;/p&gt;&#xA;" OwnerUserId="907" LastActivityDate="2021-08-05T21:10:15.227" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6701" PostTypeId="1" AcceptedAnswerId="6717" CreationDate="2021-08-05T21:49:07.527" Score="2" ViewCount="276" Body="&lt;p&gt;Any solvers which can be integrated in python where we can quickly solve if we have integer and binary variables alone in our model other than normal solvers for MIP, MILP?&lt;/p&gt;&#xA;" OwnerUserId="530" LastActivityDate="2021-08-07T17:41:20.427" Title="Is there any solver intended specifically for integer and binary variables alone on the optimization model other than solvers for MIP, MILP?" Tags="|optimization|mixed-integer-programming|python|integer-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6702" PostTypeId="2" ParentId="6699" CreationDate="2021-08-05T22:39:17.400" Score="5" Body="&lt;p&gt;Pushing @Erwin's idea further, I got faster solve times by instead introducing variables ry and qx:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for j in b:&#xA;    for k in c:&#xA;        o += ry[j][k] == r[k] *(xsum(y[k][jj] for jj in b if jj &amp;lt;= j))&#xA;for j in b:&#xA;    for k in c:&#xA;        o += qx[j][k] == xsum(( xsum (q[i][k]* x[i][jj] for i in a )for jj in b if jj &amp;lt;=j))&#xA;for j in b:&#xA;    for k in c:&#xA;        o += ry[j][k] &amp;gt;= qx[j][k]&#xA;for j in b:&#xA;    o += (xsum(ry[j][k] for k in c)) - (xsum(qx[j][k] for k in c)) &amp;lt;= g&#xA;for j in b:&#xA;    o += (xsum(ry[j][k] for k in c)) - (xsum(qx[j][k] for k in c)) &amp;gt;= h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The optimal objective value turns out to be &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$(g,h)=(15,12)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;As requested, here is the full SAS code, with variables ry[k,j] and qx[k,j]:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;proc optmodel;&#xA;   set ASET = 0..9;&#xA;   set BSET = 0..19;&#xA;   set CSET = 0..3;&#xA;   num q {ASET, CSET} = [&#xA;      4,5,0,2,&#xA;      3,2,1,0,&#xA;      0,1,4,5,&#xA;      3,2,0,1,&#xA;      2,1,3,2,&#xA;      4,3,2,1,&#xA;      3,4,2,0,&#xA;      5,0,3,1,&#xA;      0,4,3,3,&#xA;      4,0,4,1&#xA;   ];&#xA;   num s {ASET} = [11,1,1,1,1,1,1,1,1,1];&#xA;   num r {CSET} = [6,8,4,7];&#xA;   num d {CSET} = [12,9,6,6];&#xA;&#xA;   var x {ASET, BSET} binary;&#xA;   var y {CSET, BSET} binary;&#xA;   var g;&#xA;   var h;&#xA;&#xA;   con Con1 {i in ASET}:&#xA;      sum {j in BSET} x[i,j] = s[i];&#xA;   con Con2 {j in BSET}:&#xA;      sum {i in ASET} x[i,j] = 1;&#xA;   con Con3 {k in CSET}:&#xA;      sum {j in BSET} y[k,j] = d[k];&#xA;&#xA;   var ry {CSET, BSET};&#xA;   con ryCon {k in CSET, j in BSET}:&#xA;      ry[k,j] = r[k] * sum {jj in BSET: jj &amp;lt;= j} y[k,jj];&#xA;   var qx {CSET, BSET};&#xA;   con qxCon {k in CSET, j in BSET}:&#xA;      qx[k,j] = sum {i in ASET, jj in BSET: jj &amp;lt;= j} q[i,k] * x[i,jj];&#xA;   con Con4 {k in CSET, j in BSET}:&#xA;      ry[k,j] &amp;gt;= qx[k,j];&#xA;   con Con5 {j in BSET}:&#xA;      sum {k in CSET} (ry[k,j] - qx[k,j]) &amp;lt;= g;&#xA;   con Con6 {j in BSET}:&#xA;      sum {k in CSET} (ry[k,j] - qx[k,j]) &amp;gt;= h;&#xA;   &#xA;   minimize Range = g - h;&#xA;   solve;&#xA;&#xA;   print x;&#xA;   print y;&#xA;   print g h;&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And here is the resulting output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x &#xA;   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19  &#xA;0  0  1  0  1  1  1  1  0  1  1  1  1  0  1  1  0  0  0  0  0  &#xA;1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  &#xA;2  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  &#xA;3  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  &#xA;4  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  &#xA;5  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  &#xA;6  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  &#xA;7  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  &#xA;8  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  &#xA;9  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  &#xA;&#xA;y &#xA;   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19  &#xA;0  1  1  0  1  0  1  0  1  1  0  1  0  0  1  1  0  1  0  1  1  &#xA;1  1  0  0  1  1  1  0  0  0  1  1  0  1  0  1  1  0  0  0  0  &#xA;2  1  1  0  0  0  0  1  0  0  0  0  1  0  1  0  0  1  0  0  0  &#xA;3  1  0  1  0  0  0  1  0  1  0  0  1  0  0  0  0  0  1  0  0  &#xA;&#xA; g  h &#xA;15 12 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;An alternative reformulation for your last three constraints is as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   var ry_minus_qx {CSET, BSET} &amp;gt;= 0;&#xA;   con Con4 {k in CSET, j in BSET}:&#xA;      ry_minus_qx[k,j] = r[k] * y[k,j] - sum {i in ASET} q[i,k] * x[i,j] + (if j-1 in BSET then ry_minus_qx[k,j-1]);&#xA;   con Con5 {j in BSET}:&#xA;      sum {k in CSET} ry_minus_qx[k,j] &amp;lt;= g;&#xA;   con Con6 {j in BSET}:&#xA;      sum {k in CSET} ry_minus_qx[k,j] &amp;gt;= h;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-08-06T19:27:15.283" LastActivityDate="2021-08-06T19:27:15.283" CommentCount="18" ContentLicense="CC BY-SA 4.0" />
  <row Id="6703" PostTypeId="1" AcceptedAnswerId="6730" CreationDate="2021-08-05T23:54:41.063" Score="1" ViewCount="2153" Body="&lt;p&gt;I have the following optimization model using PuLP.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;neighborhood_lst = [&#xA;    'btm_bin',&#xA;    'hsr_bin',&#xA;    'jayanagar_bin',&#xA;    'koramangala_5th_block_bin',&#xA;    'jp_nagar_bin',&#xA;    'marathahalli_bin',&#xA;    'whitefield_bin',&#xA;    'indiranagar_bin',&#xA;    'bannerghatta_road_bin',&#xA;    'bellandur_bin'&#xA;]&#xA;&#xA;cuisines_lst = [&#xA;    'north_indian_bin',&#xA;    'chinese_bin',&#xA;    'south_indian_bin',&#xA;    'biryani_bin',&#xA;    'fast_food_bin',&#xA;    'street_food_bin',&#xA;    'seafood_bin',&#xA;    'continental_bin',&#xA;    'andhra_bin',&#xA;    'beverages_bin',&#xA;    'italian_bin',&#xA;    'other_bin'&#xA;]&#xA;&#xA;# set up model&#xA;model = LpProblem(name='restaurant_cuisine_neigborhood', sense=LpMaximize)&#xA;&#xA;# set variables&#xA;x = {i: LpVariable(name=f&amp;quot;x{i}&amp;quot;, lowBound=0, cat='Binary') for i in cuisines_lst}&#xA;y = {i: LpVariable(name=f&amp;quot;y{i}&amp;quot;, lowBound=0, cat='Binary') for i in neighborhood_lst}&#xA;&#xA;# Set objective&#xA;model += 0.0267 * x['north_indian_bin'] + 0.0243 * x['chinese_bin'] + 0.0088 * x['south_indian_bin'] + \&#xA;         0.0108 * x['biryani_bin'] + 0.0084 * x['fast_food_bin'] + 0.0022 * x['street_food_bin'] + \&#xA;         0.0030 * x['seafood_bin'] + 0.0038 * x['continental_bin'] + 0.0036 * x['andhra_bin'] + \&#xA;         0.0030 * x['beverages_bin'] + 0.0176 * x['other_bin'] + \&#xA;         0.0011 * y['btm_bin'] + 0.0018 * y['hsr_bin'] + 0.0041 * y['jayanagar_bin'] + \&#xA;         0.0039 * y['koramangala_5th_block_bin'] + 0.0005 * y['jp_nagar_bin'] + 0.0094 * y['marathahalli_bin'] + \&#xA;         0.0012 * y['whitefield_bin'] + 0.0004 * y['indiranagar_bin'] + 0.0108 * y['bannerghatta_road_bin'] + \&#xA;         0.0085 * y['bellandur_bin']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am having issues with my constraints below.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Add constraints&#xA;model += (lpSum(y.values()) == 1, 'neighborhood_selection')&#xA;model += (lpSum(x.values()) &amp;lt;= 4, 'cuisine_selection')&#xA;&#xA;# If Indiranagar then must NOT be healthy food&#xA;model += (y['indiranagar_bin'] + x['andhra_bin'] &amp;lt;= 1, 'andhra_not_in_indirangar')&#xA;&#xA;# If Koramangala 5th Block, then one must be Italian&#xA;model += (y['koramangala_5th_block_bin'] &amp;lt;= x['italian_bin'], '5th_block_italian')&#xA;# If Whitefield, then one must be Other&#xA;model += (y['whitefield_bin'] &amp;lt;= x['other_bin'], 'whitefield_other')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If I use only the &lt;code&gt;andhra_not_in_indirangar&lt;/code&gt; constraint the model will run and determine an optimal solution. When I try to add the &lt;code&gt;5th_block_italian&lt;/code&gt; and &lt;code&gt;whitefield_other&lt;/code&gt; constraints, the model will not run.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;status = model.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This returns a &lt;code&gt;PulpSolverError: PuLP: Error while executing glpsol.exe&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;My logic for the last two constraints is that the &lt;code&gt;y&lt;/code&gt; variable will be less than or equal to the &lt;code&gt;x&lt;/code&gt; variable. So if &lt;code&gt;y&lt;/code&gt; is 1, then so is &lt;code&gt;x&lt;/code&gt;, but &lt;code&gt;x&lt;/code&gt; can be 1 without &lt;code&gt;y&lt;/code&gt; having to be 1.&lt;/p&gt;&#xA;&lt;p&gt;I have read about the Big M method but wasn't sure that it applied to my model.&lt;/p&gt;&#xA;" OwnerUserId="6019" LastActivityDate="2021-08-09T17:56:04.617" Title="Conditional constraints in PuLP" Tags="|linear-programming|python|pulp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6705" PostTypeId="2" ParentId="6673" CreationDate="2021-08-06T03:13:10.663" Score="2" Body="&lt;p&gt;This seems to be a job shop scheduling problem. I am not expert in this problem, but in the job shop scheduling problem, the preventions of overlapping operations is one of the main constraints. You may use such a constraint and instead of setting the RHS of the inequality to zero (which states that overlapping is not allowed), you set your upper bound to the number of allowable overlapping operations.&lt;/p&gt;&#xA;" OwnerUserId="6006" LastEditorUserId="123" LastEditDate="2021-08-06T07:34:23.127" LastActivityDate="2021-08-06T07:34:23.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6706" PostTypeId="1" CreationDate="2021-08-06T07:43:15.083" Score="6" ViewCount="100" Body="&lt;p&gt;I am trying to model &lt;span class=&quot;math-container&quot;&gt;$t \leq 0.0 \implies P = 1.0$&lt;/span&gt; else &lt;span class=&quot;math-container&quot;&gt;$P=1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$P=0$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$0 \leq t \leq H$&lt;/span&gt; is a bounded nonnegative real, and &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is binary.&lt;/p&gt;&#xA;&lt;p&gt;I can use the expression &lt;span class=&quot;math-container&quot;&gt;$t + \epsilon P \ge \epsilon$&lt;/span&gt; which however does not do the job when &lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt; t &amp;lt; \epsilon$&lt;/span&gt;, since then it forbids &lt;span class=&quot;math-container&quot;&gt;$P=0$&lt;/span&gt; (both &lt;span class=&quot;math-container&quot;&gt;$P=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P=0$&lt;/span&gt; should be feasible in this case).&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to fix this problem? Is there a way to use tolerance settings of a solver to overcome this difficulty?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2021-08-06T07:50:28.227" LastActivityDate="2021-08-06T08:39:54.203" Title="If $t\le0$ then $P=1$, if $t &gt; 0$ then $P =0$ or $P=1$" Tags="|mixed-integer-programming|modeling|binary-variable|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6707" PostTypeId="2" ParentId="6706" CreationDate="2021-08-06T08:27:16.930" Score="2" Body="&lt;p&gt;You could define a binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta \in \{0,1\}$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$t=0$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;0\le t &amp;amp;\le H(1-\delta) \\&#xA;1-\delta &amp;amp;\le M t&#xA;\end{align*}&lt;/span&gt;&#xA;Then, enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\delta \le P&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that choosing the right value for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; may be as tricky as finding the right &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;. You need &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; big enough such that if &lt;span class=&quot;math-container&quot;&gt;$t=\epsilon$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M\epsilon \ge 1$&lt;/span&gt;, so that &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; can take value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; without violating the constraint.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-08-06T08:39:54.203" LastActivityDate="2021-08-06T08:39:54.203" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6708" PostTypeId="2" ParentId="6706" CreationDate="2021-08-06T08:36:01.103" Score="4" Body="&lt;p&gt;Your constraint is equivalent to &amp;quot;if P=0 then t&amp;gt;0&amp;quot; which involves strict inequality.&#xA;Strict inequality is not something that can be handled by a MIP solver without using some sort of epsilon.&lt;/p&gt;&#xA;&lt;p&gt;But can t actually be arbitrarily small but non-zero in your case? Maybe it is possible/acceptable to find a small enough epsilon to model your constraint so that it works in practice.&lt;/p&gt;&#xA;" OwnerUserId="3179" LastActivityDate="2021-08-06T08:36:01.103" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6709" PostTypeId="1" CreationDate="2021-08-06T10:21:25.423" Score="2" ViewCount="154" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; be element-wise positive &lt;span class=&quot;math-container&quot;&gt;$n\times 1$&lt;/span&gt; vectors and let &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; be a element-wise positive and positive-definite matrix. Consider the optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_{p\in\mathbb{R}^n}&amp;amp;\quad c^\top p\\&#xA;\text{s.t.}&amp;amp;\quad p^\top Ap-k^\top p \leq 0 \\&#xA;&amp;amp;\quad0\leq p \leq 1&#xA;\end{align}&lt;/span&gt;&#xA;What is the dual program of this optimization problem? I am interested only in the dual program due to theoretical motivations.&lt;/p&gt;&#xA;" OwnerUserId="3024" LastEditorUserId="123" LastEditDate="2021-08-06T12:06:09.087" LastActivityDate="2021-08-06T16:41:46.453" Title="Dual of quadratic program with linear objective" Tags="|constraint-programming|convex-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6710" PostTypeId="2" ParentId="6709" CreationDate="2021-08-06T11:39:17.727" Score="2" Body="&lt;p&gt;Your primal problem is equivalent to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;-\min_{p \in \mathbb{R}^n}\;\; - c^\top p \quad \text{s.t.} \quad p^\top A p - k^\top p \leq 0,\; p-1 \leq 0,\; -p \leq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, the lagrangian function &lt;span class=&quot;math-container&quot;&gt;$L : \mathbb{R}^n \times \mathbb{R} \times \mathbb{R}^n \times \mathbb{R}^n$&lt;/span&gt; reads&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;L(p, \lambda, \mu, \tau) &amp;amp;= -c^\top p + \lambda (p^\top A p - k^\top p) + \mu^\top (p - \mathbf{1})-\tau^\top p \\&#xA;&amp;amp;= p^\top \lambda A p - (c+\lambda k - \mu + \tau)^\top p - \mu^\top \mathbf{1}&#xA;%&#xA;\end{align*}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Next, we need &lt;span class=&quot;math-container&quot;&gt;$\inf_{p \in \mathbb{R}^n} L(p, \lambda, \mu, \tau)$&lt;/span&gt;. Since &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is quadratic and convex in &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, the first order necessary condition&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\nabla_p L = 2\lambda A p - (c+\lambda k - \mu + \tau) = 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is sufficient. Hence, since &lt;span class=&quot;math-container&quot;&gt;$\lambda \geq 0$&lt;/span&gt;, we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\tilde{p} = \frac12 (\lambda A)^{\dagger} (c+\lambda k - \mu + \tau),&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$(\lambda A)^{\dagger}$&lt;/span&gt; denotes the &lt;a href=&quot;https://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_inverse&quot; rel=&quot;nofollow noreferrer&quot;&gt;Moore-Penrose pseudo inverse&lt;/a&gt; of &lt;span class=&quot;math-container&quot;&gt;$\lambda A$&lt;/span&gt;. Note that because &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is symmetric and positive definite we have &lt;span class=&quot;math-container&quot;&gt;$(\lambda A)^{\dagger} = \frac{1}{\lambda} A^{-1}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\lambda &amp;gt; 0$&lt;/span&gt;. Consequently,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;\inf_{p \in \mathbb{R}^n} L(p, \lambda, \mu, \tau) &#xA;&amp;amp;= L(\tilde{p}, \lambda, \mu, \tau) \\ %&#xA;&amp;amp;= \tilde{p}^\top \lambda A \tilde{p} - (c+\lambda k - \mu + \tau)^\top \tilde{p} - \mu^\top \mathbf{1} \\&#xA;&amp;amp;= -\frac{1}{2} (c+\lambda k - \mu + \tau)^\top (\lambda A)^{\dagger} (c+\lambda k - \mu + \tau) - \mathbf{1}^\top \mu,&#xA;\end{align*}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where we used &lt;span class=&quot;math-container&quot;&gt;$(\lambda A)^{\dagger} (\lambda A) (\lambda A)^{\dagger}  = (\lambda A)^{\dagger}$&lt;/span&gt;. Finally, the &lt;em&gt;lagrangian&lt;/em&gt; dual problem reads&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max_{\lambda, \mu, \tau \geq 0} \quad -\frac{1}{2} (c+\lambda k - \mu + \tau)^\top (\lambda A)^{\dagger} (c+\lambda k - \mu + \tau) - \mathbf{1}^\top \mu.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="3696" LastEditDate="2021-08-06T16:41:46.453" LastActivityDate="2021-08-06T16:41:46.453" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6711" PostTypeId="1" CreationDate="2021-08-06T12:44:53.590" Score="4" ViewCount="246" Body="&lt;p&gt;I have received many helps to model the problem, thank's for that ! I just edited the post to make clear what my actuel problem is.&lt;/p&gt;&#xA;&lt;p&gt;The following model is giving me amazing results with few products (5 to 10 products), but it is not working at all with largest numbers of products.&lt;/p&gt;&#xA;&lt;p&gt;In fact there are so many constraints n1 that I can't even start a solving.&#xA;With 10 vehicles, 3 factories and 100 products, we have around 50B rows for this constraint... this is never going to work.&lt;/p&gt;&#xA;&lt;p&gt;So I think I have to model this differently... but I lack inspiration to be honest.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;A company is delivering bespoke products to client from several factories. Bespoke products means that we can assimilate products and clients (a client = its product).&lt;/p&gt;&#xA;&lt;p&gt;The products are very large product, so you can only deliver once at a time with a vehicle, but sometimes it is possible to deliver two products on the same vehicle (we'll have a matrix giving compatibilities). When we deliver two products with the same vehicle, we only pay once for the delivery, so it is cheaper.&lt;/p&gt;&#xA;&lt;p&gt;It is possible to transfer products from a factory to another before the final delivery.&lt;/p&gt;&#xA;&lt;p&gt;So the typical case we want our algorithm to find is :&#xA;transfer a product from a factory to another if it allows to make a grouped delivery.&lt;/p&gt;&#xA;&lt;p&gt;For example : product 1 is only possible to product in factory A, and product 2 in factory B.&#xA;But both client 1 and 2 are located next to factory B. It is probably better to transfer product 1 from A to B, before making a grouped delivery.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Actual model&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Indices&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ t \in T = \{ 0, 1, ..., T_f \} $&lt;/span&gt; : time steps&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i \in I = \{1,2,..,n\}$&lt;/span&gt; : factories&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$j \in J = \{ n+1, n+2, ..., m \}$&lt;/span&gt; : products ( = clients)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$k \in K = \{1,2,...p\} $&lt;/span&gt; : vehicles&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s \in S = \{1,2,...s_t\}$&lt;/span&gt; : product types (it is not 100% bespoke so sometimes two products are the same, but it's rare)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$V = I \bigcup J$&lt;/span&gt; : nodes of the graph of the clients and factories&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Decision variables&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{producted}_{i,j,t} \in \{0,1\} \forall i \in I, j \in J, t\in T$&lt;/span&gt; : 1 if product &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is producted in factory &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{inventory}_{i,j,t} \in \{0,1\} \forall i \in V, j \in J, t\in T$&lt;/span&gt; : 1 if product &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is located at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at end of day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{board}_{i_1,i_2,j,t,k} \in \{0,1\} \forall i_1 \in V, i_2 \in V, t\in T, j\in J, k\in, K$&lt;/span&gt; : 1 if product &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; goes from &lt;span class=&quot;math-container&quot;&gt;$i_1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$i_2$&lt;/span&gt; with the vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; during day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{road}_{i_1,i_2,t,k} \in \{0,1\} \forall i_1 \in V, i_2 \in V, t\in T, k\in, K$&lt;/span&gt; : 1 if vehicle goes from &lt;span class=&quot;math-container&quot;&gt;$i_1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$i_2$&lt;/span&gt; during day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{k\in K} \sum_{t\in T} \sum_{i_1 \in V} \sum_{i_2 \in V} c_{i_1,i_2} \text{road}_{i_1,i_2,t,k} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{i_1,i_2}$&lt;/span&gt; is the cost of the traject &lt;span class=&quot;math-container&quot;&gt;$i_1$&lt;/span&gt;-&amp;gt;&lt;span class=&quot;math-container&quot;&gt;$i_2$&lt;/span&gt; for a vehicle.&lt;/p&gt;&#xA;&lt;p&gt;** Constraints **&lt;/p&gt;&#xA;&lt;p&gt;n1 : Compatibility between products&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ board(i_1,i_2,j_1,t,k) + board(i_1,i_2,j_2,t,k) \leq 1 + m[j_1][j_2] $$&lt;/span&gt;  &lt;span class=&quot;math-container&quot;&gt;$$\forall i_1,i_2 \in V^2,  \forall j_1,j_2 \in J^2,  \forall  t \in T,  \forall k \in K $$&lt;/span&gt;&#xA;(only applied when &lt;span class=&quot;math-container&quot;&gt;$m[j_1][j_2] = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;n2 : each product is only produced one&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i} \sum_{t} \text{producted}_{i,j,t} = 1,  \forall j \in J $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;n3 : just to avoid strange behaviour&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \text{road}_{i,i,t,k} = 0, \forall i \in V, t \in T, k \in K $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;n4 : a product can only be transported by a vehicle&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \text{board}_{i_1,i_2,j,t,k} \leq \text{road}_{i_1,i_2,t,k}, \forall (i_1,i_2) \in V^2, j \in J, t \in T, k \in K $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;n5 : a product can only be producted in some factories&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \text{producted}_{i,j,t} \leq p[i][j], \forall i \in I, j \in J, t \in T $$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$p[i][j] = 1$&lt;/span&gt; if factory &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; can produce product &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;n6 : inventory formula (simplified)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \text{inventory}_{i,j,t} = \text{inventory}_{i,j,t-1} \sum_{k \in K} \sum_{i2 \in V} \text{board}_{i2,i,j,t,k} - \sum_{k \in K} \sum_{i2 \in V} \text{board}_{i,i2,j,t,k}  + producted{i,j,t-1}, \forall t \in T, i \in I $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;7n: only factories can have stocks at the end of day&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \text{inventory}_{i,j,t} = 0, \forall i \in J, \forall j in J-\{I\} \forall t \in T$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thank's for the help !&lt;/p&gt;&#xA;" OwnerUserId="6021" LastEditorUserId="2556" LastEditDate="2021-09-10T08:51:11.557" LastActivityDate="2021-09-10T08:51:11.557" Title="Multi-product distribution modeling : too many constraints" Tags="|optimization|mixed-integer-programming|linear-programming|modeling|" AnswerCount="2" CommentCount="23" ContentLicense="CC BY-SA 4.0" />
  <row Id="6712" PostTypeId="1" CreationDate="2021-08-06T14:24:44.463" Score="1" ViewCount="110" Body="&lt;p&gt;I want to implement &lt;strong&gt;MLE (Maximum likelihood estimation)&lt;/strong&gt; with &lt;code&gt;gekko&lt;/code&gt; package in python. Suppose that we have a &lt;code&gt;DataFrame&lt;/code&gt; that contains two columns: ['Loss', 'Target'] and its length is equal to 500.&lt;br /&gt;&#xA;First we have to import packages that we need:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from gekko import GEKKO&#xA;import numpy as np&#xA;import pandas as pd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then we simply create the &lt;code&gt;DataFrame&lt;/code&gt; like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;My_DataFrame = pd.DataFrame({&amp;quot;Loss&amp;quot;:np.linspace(-555.795 , 477.841 , 500) , &amp;quot;Target&amp;quot;:0.0})&#xA;My_DataFrame = My_DataFrame.sort_values(by=[&amp;quot;Loss&amp;quot;] , ascending=False).reset_index(drop=True)&#xA;My_DataFrame &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It going to be look like this:&lt;br /&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tWMfb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tWMfb.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Some components of [‘Target’] column&lt;/strong&gt; should be calculated with a formula that I wrote it right down below in the picture(and the rest of them remains zero. I explained more in continue, please keep reading) so you can see it perfectly. Two main elements of formula are ‘Kasi’ and ‘Betaa’. I want to find best value for them that maximize sum of &lt;code&gt;My_DataFrame[‘Target’]&lt;/code&gt;. So you got the idea and what is going to happen!&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0qa9u.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0qa9u.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now let me show you how I wrote the code for this purpose. First I define my &lt;strong&gt;objective function:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def obj_function(Array):&#xA;    &amp;quot;&amp;quot;&amp;quot;&#xA;    [Purpose]:&#xA;        + it will calculate each component of My_DataFrame[&amp;quot;Target&amp;quot;] column! so the i can maximize sum(My_DataFrame[&amp;quot;Target&amp;quot;]) and find best 'Kasi' and 'Betaa' for it!&#xA;    &#xA;    [Parameters]:&#xA;        + This function gets Array that contains 'Kasi' and 'Betaa'.&#xA;        Array[0] represents 'Kasi' and Array[1] represents 'Betaa'&#xA;&#xA;    [returns]:&#xA;        + returns a pandas.series.&#xA;        actually it returns new components of My_DataFrame[&amp;quot;Target&amp;quot;]&#xA;    &amp;quot;&amp;quot;&amp;quot;&#xA;    # in following code if you don't know what is `qw`, just look at the next code cell right after this cell (I mean next section).&#xA;    # in following code np.where(My_DataFrame[&amp;quot;Loss&amp;quot;] == item)[0][0] is telling me the row's index of item. &#xA;    for item in My_DataFrame[My_DataFrame[&amp;quot;Loss&amp;quot;]&amp;gt;160]['Loss']:&#xA;        My_DataFrame.iloc[np.where(My_DataFrame[&amp;quot;Loss&amp;quot;] == item)[0][0] , 1] = qw.log10((1/Array[1])*(  1 + (Array[0]*(item-160)/Array[1])**( (-1/Array[0]) - 1 )))&#xA;&#xA;    return My_DataFrame[&amp;quot;Target&amp;quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;if you got confused what's happening in &lt;code&gt;for loop&lt;/code&gt; in &lt;code&gt;obj_function&lt;/code&gt; function, check picture bellow, it contains a brief example! and if not, skip this part :&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/d9Wjk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/d9Wjk.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then just we need to go through optimization. I use &lt;code&gt;gekko&lt;/code&gt; package for this purpose. &lt;strong&gt;Note that&lt;/strong&gt; I want to find best values of ‘Kasi’ and ‘Betaa’ so I have two main variables and I don’t have any kind of constraints!&#xA;So let’s get started:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# i have 2 variables : 'Kasi' and 'Betaa', so I put nd=2&#xA;nd = 2&#xA;qw = GEKKO()&#xA;&#xA;# now i want to specify my variables ('Kasi'  and 'Betaa') with initial values --&amp;gt; Kasi = 0.7 and Betaa = 20.0&#xA;x = qw.Array(qw.Var , nd , value = [0.7 , 20])&#xA;# So i guess now x[0] represents 'Kasi' and x[1] represents 'Betaa'&#xA;&#xA;qw.Maximize(np.sum(obj_function(x)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And then when I want to solve the optimization with &lt;code&gt;qw.solve()&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;qw.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But i got this error:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Exception: This steady-state IMODE only allows scalar values.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;How can I fix this problem?&lt;/p&gt;&#xA;" OwnerUserId="6022" LastActivityDate="2021-08-06T14:24:44.463" Title="MLE application with gekko in python" Tags="|optimization|python|minimax|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6713" PostTypeId="2" ParentId="6686" CreationDate="2021-08-06T15:52:39.863" Score="2" Body="&lt;p&gt;Without relying on whether the solver &amp;quot;prefers&amp;quot; larger or smaller values of &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt;, you can introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; and the following constraints:&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;y_{t} &amp;amp; \ge y_{t-1}+a_{t}-z_{t}\\&#xA;y_{t} &amp;amp; \ge0\\&#xA;y_{t} &amp;amp; \le y_{t-1}+a_{t}-z_{t}+M\delta\\&#xA;y_{t} &amp;amp; \le M(1-\delta).&#xA;\end{align*}&lt;/span&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$\delta=0$&lt;/span&gt;, this reduces to &lt;span class=&quot;math-container&quot;&gt;$y_t =y_{t-1} +a_t -z_t \ge 0$&lt;/span&gt;, while if &lt;span class=&quot;math-container&quot;&gt;$\delta=1$&lt;/span&gt; it reduces to &lt;span class=&quot;math-container&quot;&gt;$y_t=0\ge y_{t-1} +a_t -z_t $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For the second case, introduce a new variable &lt;span class=&quot;math-container&quot;&gt;$w_t$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$\min\{ y'_{t-1} + a_t - z_t,0 \}$&lt;/span&gt; and use the preceding with &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; replaced by &lt;span class=&quot;math-container&quot;&gt;$w_t$&lt;/span&gt; and with the four inequalities reversed.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-06T15:52:39.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6714" PostTypeId="2" ParentId="4250" CreationDate="2021-08-06T16:06:45.557" Score="3" Body="&lt;p&gt;There are several new EdX courses in optimization which may be a good starting point for you (and anyone interested in OR):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.edx.org/course/linear-optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.edx.org/course/linear-optimization&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.edx.org/course/unconstrained-nonlinear-optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.edx.org/course/unconstrained-nonlinear-optimization&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.edx.org/course/network-and-discrete-optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.edx.org/course/network-and-discrete-optimization&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6018" LastActivityDate="2021-08-06T16:06:45.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6715" PostTypeId="1" CreationDate="2021-08-07T07:39:52.847" Score="3" ViewCount="52" Body="&lt;p&gt;I was searching through articles for popup facility location and could not find anything devoted to it. If anyone has come across it, can someone guide me to some papers?&lt;/p&gt;&#xA;" OwnerDisplayName="user4387" LastEditorUserId="123" LastEditDate="2021-08-07T08:04:42.990" LastActivityDate="2021-08-07T08:04:42.990" Title="Popup facility location" Tags="|reference-request|facility-location|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6716" PostTypeId="1" CreationDate="2021-08-07T16:51:36.150" Score="2" ViewCount="283" Body="&lt;p&gt;I am solving an OR scheduling problem where I assign the patient to (day,OR) tuple in Master Problem. Once the assignment is made, a subproblem can be solved for each (day,OR) tuple &lt;strong&gt;independently&lt;/strong&gt; where patients are assigned to a time slot t. A cost of overtime is incurred if OR is occupied beyond a certain time slot.&lt;/p&gt;&#xA;&lt;p&gt;It is ensured in the master problem that the assignment to each OR,day tuple is feasible. Thus, the subproblems are always feasible.&lt;/p&gt;&#xA;&lt;p&gt;The benders cut added is of the form&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GWPAG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GWPAG.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Using this form, I add a cut for each (day,OR) tuple, if &lt;span class=&quot;math-container&quot;&gt;$$\phi(x^*)_{dk} &amp;gt; \sigma^*_{dk}$$&lt;/span&gt; This cut essentially ensures that the solution is not repeated or the solution that is found is at least &amp;gt;= M (Lower Bound).&lt;/p&gt;&#xA;&lt;p&gt;The cuts added from the relaxation of SP are valid for the original problem. However, is that the case when you further separate the problem as I have done before? Can I add the cuts from LP relaxation for each (OR,day) tuple?&lt;/p&gt;&#xA;&lt;p&gt;I ask this question because I obtain the solution only when I have integer cuts of the form above, however, the lower bound is violated when I include the cuts from SP relaxation. Under what condition the cuts from LP relaxation are valid?&lt;/p&gt;&#xA;" OwnerUserId="3520" LastActivityDate="2021-08-07T18:03:19.503" Title="Benders Decomposition cuts for MILP problem with further separable subproblems" Tags="|mixed-integer-programming|linear-programming|integer-programming|benders-decomposition|decomposition|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6717" PostTypeId="2" ParentId="6701" CreationDate="2021-08-07T17:41:20.427" Score="4" Body="&lt;p&gt;For binary only there are the following classes of solvers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SAT Solvers and MaxSat for optimization&lt;/li&gt;&#xA;&lt;li&gt;Pseudo Boolean Programming or Pseudo Boolean optimization&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For integer valued there are the following approaches:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Constraint Programming&lt;/li&gt;&#xA;&lt;li&gt;Rephrasing as Boolean Problem provided the search space is finite&lt;/li&gt;&#xA;&lt;li&gt;SMT solvers and Optimization modulo theory&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As well as local solvers which might be able to solve both.&lt;/p&gt;&#xA;&lt;p&gt;As for whether such software is callable from Python:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SAT solvers: yes, for example  &lt;a href=&quot;https://pypi.org/project/pylgl/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lingeling&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Pseudo Boolean solvers: no, as far as i know, but you can generate a problem file a solver like RoundingSAT could work on and read it's output files.&lt;/li&gt;&#xA;&lt;li&gt;Contraint programming: yes, see &lt;a href=&quot;https://pypi.org/project/python-constraint/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python constraint&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;SMT solvers, yes see &lt;a href=&quot;https://ericpony.github.io/z3py-tutorial/guide-examples.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Z3Py&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Local solvers, yes see &lt;a href=&quot;https://www.localsolver.com/docs/last/quickstart/solvingyourfirstmodelinpython.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;LocalSolver&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;All those solvers use different proof systems from MILP solvers, so it is possible that they solve certain formulations of certain problems better than MILP solvers. However there is no single approach that dominates MILP on every task.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-08-07T17:41:20.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6718" PostTypeId="2" ParentId="6716" CreationDate="2021-08-07T18:03:19.503" Score="2" Body="&lt;p&gt;It sounds like your Benders master problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sigma = \sum_{d,k} \sigma_{d,k}$&lt;/span&gt;, where your independent subproblems are indexed by &lt;span class=&quot;math-container&quot;&gt;$(d,k)$&lt;/span&gt;.&#xA;For each fixed master solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$\phi(x^*)_{d,k}$&lt;/span&gt; be the optimal objective value (or any lower bound, perhaps obtained from the LP relaxation) of subproblem &lt;span class=&quot;math-container&quot;&gt;$(d,k)$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; be a valid lower bound on &lt;span class=&quot;math-container&quot;&gt;$\sigma_{d,k}$&lt;/span&gt;.  Then the following constraint (&amp;quot;combinatorial Benders optimality cut&amp;quot;) is valid:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sigma_{d,k} \ge \phi(x^*)_{d,k} - (\phi(x^*)_{d,k} - M) \left(\sum_{j: x_j^* = 0} x_j + \sum_{j: x_j^* = 1} (1-x_j)\right) \tag1$$&lt;/span&gt;&#xA;This (big-M) constraint enforces the logical implication &lt;span class=&quot;math-container&quot;&gt;$x=x^* \implies \sigma_{d,k} \ge \phi(x^*)_{d,k}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But this cut can be very weak.  If every subset of the support of &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; yields &lt;span class=&quot;math-container&quot;&gt;$\sigma_{d,k} \ge \phi(x^*)_{d,k}$&lt;/span&gt;, you can strengthen as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sigma_{d,k} \ge \phi(x^*)_{d,k} - (\phi(x^*)_{d,k} - M) \sum_{j: x_j^* = 0} x_j \tag2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Similarly, if every superset of the support of &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; yields &lt;span class=&quot;math-container&quot;&gt;$\sigma_{d,k} \ge \phi(x^*)_{d,k}$&lt;/span&gt;, you can strengthen as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sigma_{d,k} \ge \phi(x^*)_{d,k} - (\phi(x^*)_{d,k} - M) \sum_{j: x_j^* = 1} (1-x_j) \tag3$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-08-07T18:03:19.503" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="6719" PostTypeId="2" ParentId="6711" CreationDate="2021-08-07T18:22:18.747" Score="2" Body="&lt;p&gt;I assume from the question that a vehicle can visit at most one node in a given time period. Without writing out the full model (which is pretty gory), I would start with the following variables: how much of each product is produced at each factory in each period (with upper bound zero if the factory cannot produce that product); inventory of each product at each factory at the end of each period; inventory of each product on each vehicle at the end of each period; indicators for whether a vehicle travels each arc in each period; unsatisfied demand for each product at each client at the end of each period; and delivery quantity for each product at each client in each period. (If each client demands only a single product, some of those variables can be zeroed out.)&lt;/p&gt;&#xA;&lt;p&gt;For constraints, the inventory of any product at any factory at the end of any period is the sum of the starting inventory, the production in that period and the inventory of that product on all arriving vehicles minus the sum of the inventory of that product on all departing vehicles. At clients, the unsatisfied demand for any product at the end of any period is the unsatisfied demand at the start of the period minus the amount delivered (and must be zero by the end of the required delivery date), and the amount delivered is the difference between the inventory of the product on all arriving vehicles in the previous period and the inventory on all departing vehicles in the current period. You may also have capacity constraints on the vehicles.&lt;/p&gt;&#xA;&lt;p&gt;The objective function unchanged from what you have.&lt;/p&gt;&#xA;&lt;p&gt;The key idea is to introduce inventory levels, which will allow for accumulation and depletion of stocks at factories. It also opens the door to the possibility of adding inventory holding costs to the objective function (if storage is not free).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-07T18:22:18.747" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6720" PostTypeId="2" ParentId="6690" CreationDate="2021-08-07T20:20:57.067" Score="1" Body="&lt;p&gt;When you reason about sums of people moving from &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and sums of people being at &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; at time point &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; you can't reason at a level of the individual. In your formulation you can't express constraints on the position in time of the individual as you currently don't describe the position where an individual is in your model.&lt;/p&gt;&#xA;&lt;p&gt;To track the position of individuals you need to introduce a boolean array of &lt;span class=&quot;math-container&quot;&gt;$\text{is_at}_{p, l, t}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is the unique number of the person and &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; is it's location at time point &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Since you probably don't want one person to be at multiple locations at the same time you need introduce some constraint like &lt;span class=&quot;math-container&quot;&gt;$\forall p \in \text{Persons}, \forall t \in \text{Time}: \sum_{l \in L} \text{is_at}_{p, l, t} \leq 1$&lt;/span&gt; meaning one person can be at most at one location at a time.&lt;/p&gt;&#xA;&lt;p&gt;On this state it is possible to express that a certain individual needs to revisit the same place 2 time steps later:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ (\text{is_at}_{p, l, t} \land \neg \text{is_at}_{p, l, t-2}) \implies (\text{is_at}_{p, l, t+2}) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which reads as if Individual &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; visited &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; at time point &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; but not at &lt;span class=&quot;math-container&quot;&gt;$t-2$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; needs to visit &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$t+2$&lt;/span&gt;. You might have noticed that this is not in a MILP form but it can be converted into one using  &lt;a href=&quot;https://cs.stackexchange.com/a/12118/136057&quot;&gt;these equivalences&lt;/a&gt;. Note that around the boundaries of your time interval you can simplify this formulation as &lt;span class=&quot;math-container&quot;&gt;$t+2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$t-2$&lt;/span&gt; might not exist and you need to define what that means for your model. This formulation will also be a lot bigger then your current one as you are keeping track of individuals and not just sums of people.&lt;/p&gt;&#xA;&lt;p&gt;You can also modify this formulation to allow individuals to visit after 2 or 3 or 4 days if he never visited this place before:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (\text{is_at}_{p, l, t} \land \neg ( \bigvee\limits_{i=1}^{t-1} \text{is_at}_{p, l, i})) \implies (\text{is_at}_{p, l, t+2} \lor \text{is_at}_{p, l, t+3} \lor \text{is_at}_{p, l, t+4}) $$&lt;/span&gt;&#xA;Or do another large number of simple modifications that might be able to capture what you want.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-08-07T20:43:07.493" LastActivityDate="2021-08-07T20:43:07.493" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6721" PostTypeId="1" CreationDate="2021-08-07T20:47:10.187" Score="3" ViewCount="151" Body="&lt;p&gt;Here is the situation (it's a silly example just to illustrate the point):&lt;/p&gt;&#xA;&lt;p&gt;A computer repair company is primarily focused on repairing computers. However, the company has recently become interested in estimating the profits they will earn by repairing computers (e.g. let's assume that the company has no idea how much money they will actually have to spend repairing a computer until they are finished - thus, they want to predict the profit in advance before negotiating with the customer). They decide that for a given computer, the profits can be estimated by measuring three variables associated with each computer: X1, X2, X3. Thus, the general form of the model can be expressed as:&lt;/p&gt;&#xA;&lt;p&gt;Profits = f(X1, X2, X3)&lt;/p&gt;&#xA;&lt;p&gt;For this example, let's say that the company has 3 labs. The first lab is made of junior employees, the second lab is made of intermediate employees and the third lab is made of senior employees. Let's assume that employees from the third lab are on average &amp;quot;better at measuring X1, X2, X3&amp;quot; than employees from the second lab, and employees from the second lab are better than employees from the first lab. The first lab is the biggest lab, the second lab is smaller, and the third lab is the smallest.&lt;/p&gt;&#xA;&lt;p&gt;So for the same computer : an employee from the first lab might measure a value of X1, but an employee from the second lab might measure a different value of X1 for the same computer. Theoretically, it is also possible that an employee from the third lab might measure the same value of X1 as the employee from the second lab.&lt;/p&gt;&#xA;&lt;p&gt;When the company receives computers from their customers, they are generally first sent to the first lab. From here, the computers have their values of X1, X2, X3 measured, then repaired, and then sent back to customer - OR - the computers are sent to the second lab (e.g. if the junior employees don't know how to fix it), where their values of X1, X2, X3 are re-measured, repaired and sent back to the customer - OR - sent to the third lab, X1, X2, X3 remeasured, repaired and sent back to the customer.&lt;/p&gt;&#xA;&lt;p&gt;The company is interested in getting the computers back to the customers - they are not as interested in recording the more accurate measurements for X1, X2, X3 for each computer (e.g. if the junior employees from the first lab can fix the computer, the company will not waste time sending the computer to the third lab just to record a better set of measurements). For each repaired computer, the company also tracks the profits they made.&lt;/p&gt;&#xA;&lt;p&gt;Question: Now, let's assume these two scenarios for modelling&lt;/p&gt;&#xA;&lt;p&gt;Scenario 1: Suppose for any given computer, the company only keeps the last set of measurements for X1, X2, X3, because they believe that these are the most accurate set of measurements. But the company wants to make their predictions on incoming computers as early on as possible, i.e. based on measurements taken from the first lab**. This is creating a &amp;quot;mismatch&amp;quot;** : a statistical model created using the available data contains measurements of different quality. When the first lab will make measurements for a computer, it's likely that they might be somewhat incorrect and likely to change. Are there any statistical models that can be used in this scenario? Is this an example of &amp;quot;measurement error&amp;quot; models?&lt;/p&gt;&#xA;&lt;p&gt;Scenario 2: Suppose now the company decides to keep all measurements made for each computer. This means that some computers might have 3 measurements (lab 1 : X1. X2, X3), some computers might have 6 measurements (lab 1 : X1, X2, X3 AND lab 2: X1, X2, X3) and computers might have 9 measurements (lab 1: X1, X2, X3 AND lab 2: X1, X2, X3 AND lab 3: X1, X2, X3). However, the company always wants to make predictions for new predictions based on the measurement taken at the first lab. This now looking like a longitudinal/repeated measures problem - but I am still not sure.&lt;/p&gt;&#xA;&lt;p&gt;I am not sure how to make models for scenario 1 and scenario 2. I know that in this problem, it would be reasonable to believe that more complicated computers get sent to lab 3 - thus, try to cluster the data and make separate models based on how complex the computers are. But imagine if we had no way of knowing which computers will receive 3 measurements or which will receive 9 measurements.&lt;/p&gt;&#xA;&lt;p&gt;At this point, I am thinking of just giving up and creating a model that uses the data from the most recent lab - and just hoping that the differences in measurements between the first lab, second lab and third lab are negligible (and make models using the most recent data) ..... Or try and make layered hypothesis tests : take computers that reached lab 2 and compare the updates in measurements between lab 1 THEN take computers that reached lab 3 and compare the updates in measurements between lab 2 and lab 1, etc.). But in the real world, there could be thousands of &amp;quot;points&amp;quot; (i.e. &amp;quot;labs&amp;quot;) in which the observed data can get updated before it stabilizes).&lt;/p&gt;&#xA;&lt;p&gt;Has anyone worked on such kinds of problems?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2021-08-19T13:15:53.803" LastActivityDate="2021-08-19T13:15:53.803" Title="Has anyone ever worked on a OR problem like this before?" Tags="|optimization|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6723" PostTypeId="1" AcceptedAnswerId="6724" CreationDate="2021-08-08T14:06:37.607" Score="10" ViewCount="562" Body="&lt;p&gt;This question has been asked on &lt;a href=&quot;https://stats.stackexchange.com/questions/539527/significant-bias-introduced-into-simple-simulation&quot;&gt;Cross Validated&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h4&gt;Introduction&lt;/h4&gt;&#xA;&lt;p&gt;Service is allocated to an infinite source of customers i.e. there is always a service in progress. The duration of the &lt;span class=&quot;math-container&quot;&gt;$i^{th}$&lt;/span&gt; service is generally distributed &lt;span class=&quot;math-container&quot;&gt;$\Delta_i \sim F_{\Delta}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$F_{\Delta}:\mathbb{R}_{\geq0} \to \mathbb{R}[0,1]$&lt;/span&gt; is a uni-variate cumulative distribution function (cdf). This successive service process is illustrated below. An event occurrence (old customer out, new customer in) evolves as follows.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;t_{k+1} = t_k + \Delta_k&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4EV1C.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4EV1C.png&quot; alt=&quot;Interrupted service process&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The process operates long enough to be in a steady-state or to have reached a stationary distribution. The process is then interrupted at time &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; for inspection. Upon inspection, the interrupted service has an age &lt;span class=&quot;math-container&quot;&gt;$\tau_k =  T-t_{k}$&lt;/span&gt; and remaining lifetime &lt;span class=&quot;math-container&quot;&gt;$r_k = t_{k+1}-T = t_k + \Delta_k - T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am interested in obtaining distributions for both &lt;span class=&quot;math-container&quot;&gt;$\tau_k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r_k$&lt;/span&gt;. I have done so algebraically and via simulation. I will provide both the simulation in &lt;code&gt;Python&lt;/code&gt; as well as the expressions.&lt;/p&gt;&#xA;&lt;p&gt;I believe my expressions are correct but something if wrong with my simulations as some bias is introduced. It bothers me as the simulation is &lt;em&gt;very simple&lt;/em&gt; but I'm obviously missing something. Please follow along and help me identify the source of error.&lt;/p&gt;&#xA;&lt;h4&gt;Algebraic expressions&lt;/h4&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$F_u$&lt;/span&gt; be a uniform cdf defined over the interval &lt;span class=&quot;math-container&quot;&gt;$[0,F_{\Delta}^{-1}(\alpha)]$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is almost 1 but slightly less. This is done because &lt;span class=&quot;math-container&quot;&gt;$F_{\Delta}$&lt;/span&gt; may have a domain unbounded to the right. Let &lt;span class=&quot;math-container&quot;&gt;$f_u$&lt;/span&gt; be its probability density function (pdf) while &lt;span class=&quot;math-container&quot;&gt;$f_{\Delta}$&lt;/span&gt; is the service pdf of &lt;span class=&quot;math-container&quot;&gt;$F_{\Delta}$&lt;/span&gt;. We have a pdf for age of the interrupted process&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f_{\tau}(\tau) = \frac{1}{\eta}f_{u}(\tau)\left( 1-F_{\Delta}(\tau) \right)&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt; is a normalising constant. For the remaining age &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; we use convolution because &lt;span class=&quot;math-container&quot;&gt;$r = \Delta - \tau$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;f_{r}(r) &amp;amp; = \frac{1}{\eta}\left(f_{\Delta}*f_{\tau}  \right)(r)\\&#xA;&amp;amp; = \frac{1}{\eta}\int_{0}^\infty f_{\Delta}(r+\tau)\, f_{\tau}(\tau)\,d\tau&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h4&gt;Simulation&lt;/h4&gt;&#xA;&lt;p&gt;In the simulation, I allowed &lt;span class=&quot;math-container&quot;&gt;$t_k$&lt;/span&gt; to evolve until &lt;span class=&quot;math-container&quot;&gt;$t_{k+1} \geq T$&lt;/span&gt;. I then terminated and recorded &lt;span class=&quot;math-container&quot;&gt;$\tau = T - t_k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_{k+1} - T$&lt;/span&gt;. This is then repeated several times in order to plot normalised histograms as simulated pdfs.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;import matplotlib.pyplot as plt&#xA;from scipy.stats import norm,uniform,gamma&#xA;from scipy.integrate import quad&#xA;&#xA;&#xA;def get_interrupted_service(service,T):&#xA;    '''Helper function: single run simulation'''&#xA;    t = 0&#xA;    while True:&#xA;        delta = service.rvs()&#xA;        # if t + delta &amp;gt; T:&#xA;        if t + delta &amp;gt;= T:&#xA;            break&#xA;        t += delta&#xA;    age = T - t&#xA;    remain = delta - age&#xA;    # remain = t + delta - T&#xA;    return age,remain,delta&#xA;&#xA;&#xA;&#xA;def sample_interrupted_services(service,T,n_samples):&#xA;    '''Main function: collects statistics from independent runs'''&#xA;    ages = np.zeros(n_samples)&#xA;    remains = np.zeros(n_samples)&#xA;    deltas = np.zeros(n_samples)&#xA;    for i in range(n_samples):&#xA;        if i %10 == 0:&#xA;            print('{0} of {1}'.format(i+1,n_samples))&#xA;        ages[i],remains[i],deltas[i] = get_interrupted_service(service,T)&#xA;    return ages,remains,deltas&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I also add the numerical computations of the algebraic expressions.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def get_age_density(service,alpha=0.99):&#xA;    uni = uniform(loc=0,scale=service.ppf(alpha))&#xA;    def f(t,norm):  &#xA;        return uni.pdf(t)*service.sf(t)/norm&#xA;    norm = quad(func=lambda t: f(t,1),&#xA;                a=0,b=service.ppf(alpha))[0]&#xA;    return lambda t: f(t,norm)&#xA;&#xA;&#xA;&#xA;def get_remainder_density(service,alpha=0.99):&#xA;    age_pdf = get_age_density(service,alpha)&#xA;    def convolution(r,norm):&#xA;        return (quad(lambda age: service.pdf(r+age)*age_pdf(age),&#xA;                     a=0,b=np.inf)[0])/norm&#xA;    norm = quad(lambda r:convolution(r,1),&#xA;                a=0,b=np.inf)[0]&#xA;    return lambda r: convolution(r,norm)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h4&gt;Results&lt;/h4&gt;&#xA;&lt;p&gt;The code is run as follows.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if __name__ == '__main__':&#xA;    # Setup simulation&#xA;    alpha = 0.9999  # almost 1 e.g. 1 - 1e-6&#xA;    f_delta = gamma(a=7,scale=2)&#xA;    T = 10000   # Run long enough to reach steady state (bit extreme maybe?)&#xA;    samples = 5000  # Need a reasonable amount of iid samples&#xA;    # Perform simulation&#xA;    tau,r,delta = sample_interrupted_services(f_delta,T,samples)&#xA;    # Plot empirical pdfs&#xA;    fig,ax = plt.subplots(3,1)&#xA;    ax[0].hist(tau,bins=80,density=True,alpha=0.5,label='simulated ages')&#xA;    ax[1].hist(r,bins=80,density=True,alpha=0.5,label='simulated remainder')&#xA;    ax[2].hist(delta,bins=80,density=True,alpha=0.5,label='simulated service durations')&#xA;    # Plot algebraic counterparts for comparison&#xA;    t = np.linspace(0,f_delta.ppf(alpha),100)&#xA;    age_pdf = get_age_density(f_delta,alpha)&#xA;    ax[0].plot(t,age_pdf(t),label='ages')&#xA;    r_pdf = get_remainder_density(f_delta,alpha)&#xA;    ax[1].plot(t,[r_pdf(ti) for ti in t],label='remainder')  # SLOW !!!&#xA;    ax[2].plot(t,f_delta.pdf(t),label='service durations')&#xA;    # Show legend/labels&#xA;    _ = [ax[i].legend(loc='upper right') for i in range(3)]&#xA;    fig.show()&#xA;    # Assess bias&#xA;    actual_mean = f_delta.mean()&#xA;    empirical_mean = delta.mean()&#xA;    bias = empirical_mean - actual_mean&#xA;    print('actual mean: ',actual_mean)&#xA;    print('empirical mean: ',empirical_mean)&#xA;    print('bias: ',bias) # should be close to zero.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This produces the following. The concern now becomes clear once one looks at the bottom plot. &lt;strong&gt;Why is the simulated service duration pdf so biased to the right?&lt;/strong&gt;. If I look at the middle plot, the misfit is probably due to this bias. I must have not done the simulation properly. Please help me identify the errors.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UZGib.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UZGib.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1241" LastEditorUserId="1241" LastEditDate="2021-08-09T11:34:38.020" LastActivityDate="2023-05-07T13:42:42.257" Title="Significant bias introduced into simple simulation" Tags="|python|queuing-theory|simulation|time-series|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6724" PostTypeId="2" ParentId="6723" CreationDate="2021-08-08T18:20:10.837" Score="11" Body="&lt;p&gt;You have fallen victim to the renewal paradox, a.k.a. inspection paradox, a.k.a.  length-biased sampling.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$F_{\Delta}$&lt;/span&gt; is the distribution of service time for the kth customer, but it is NOT the distribution of service time for the customer being served at a preselected time &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;.  The very manner of selecting the customer based on observing at a preselected time biases the distribution of service time for that customer. It is not the same as observing the kth customer. Fixing the time and looking at the then current customer is different than fixing the customer and looking at its time.&lt;/p&gt;&#xA;&lt;p&gt;To make it simple to think about, consider a service time distribution which takes value 1 or 2 minutes, each with probability 1/2. If the system is allowed to run for a long time, about 2/3 of the time the system is running, the customer then being served has total service time of 2, and 1/3 of the time  has a total service of 1. So if we preselect a tine &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; (in steady state), the average total service time for the customer being served at that time = 5/3, not 3/2.&lt;/p&gt;&#xA;&lt;p&gt;If the service time distribution &lt;span class=&quot;math-container&quot;&gt;$F_{\Delta}$&lt;/span&gt; is exponential, then in steady state, the total service time of the customer being served at a preselected time is exponential with mean double that of &lt;span class=&quot;math-container&quot;&gt;$F_{\Delta}$&lt;/span&gt;, which is the distribution for the kth customer. If you now consider that the exponential distribution is memoryless, if we randomly pick a time at which to observe the remaining (not total) service time of the customer then being served, it should have distribution &lt;span class=&quot;math-container&quot;&gt;$F_{\Delta}$&lt;/span&gt;, i.e., the total service time of the kth customer. But on average, the preselected time will be halfway through the service time for the customer being served. So how can that be? Because the customer then being served has average total service time equal to double that of the kth customer, and so 1/2 the doubled average is equal to the average for the kth customer, thereby resolving that paradox.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I first learned about this paradox in an introductory Stochastic Processes course as an undergrad, from chapter 5 &amp;quot;Renewal Theory&amp;quot; of &lt;a href=&quot;https://www.elsevier.com/books/a-first-course-in-stochastic-processes/karlin/978-0-08-057041-9&quot; rel=&quot;nofollow noreferrer&quot;&gt;Karlin and Taylor &amp;quot;A First Course in Stochastic Processes, second edition&amp;quot;&lt;/a&gt;, where the phenomenon is called length-biased sampling. That set me on the path for stochastic thinking and intuition, which  many people who have the technical facility to perform even complicated probability calculations, unfortunately do not possess.&lt;/p&gt;&#xA;&lt;p&gt;Another outstanding book for developing stochastic thinking and intuition is &lt;a href=&quot;https://www.wiley.com/en-us/An+Introduction+to+Probability+Theory+and+Its+Applications%2C+Volume+2%2C+2nd+Edition-p-9780471257097&quot; rel=&quot;nofollow noreferrer&quot;&gt;Feller &amp;quot;An Introduction to Probability Theory and Its Applications, Volume II, second edition&amp;quot;&lt;/a&gt;. Right out of the gate in section I.4, there is a discussion of the &amp;quot;Waiting Time Paradox&amp;quot;, which is another manifestation of essentially the same phenomenon as the renewal paradox, length-biased sampling, and the inspection paradox. It is addressed again in VI.7, under the name 'Inspection Paradox&amp;quot;.  The &amp;quot;Renewal Theory&amp;quot; explaining this phenomenon is developed in XI.4. In my opinion, if you know Feller Volume II, you know probability, and should have a deep understanding of stochastic phenomena, whether out in the open, or lurking deep beneath the surface.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-05-07T13:42:42.257" LastActivityDate="2023-05-07T13:42:42.257" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6725" PostTypeId="2" ParentId="3869" CreationDate="2021-08-09T00:27:14.077" Score="2" Body="&lt;p&gt;&lt;em&gt;A Course in Combinatorial Optimization&lt;/em&gt;, by Alexander Schrijver&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://homepages.cwi.nl/%7Elex/files/dict.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://homepages.cwi.nl/~lex/files/dict.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6018" LastActivityDate="2021-08-09T00:27:14.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6726" PostTypeId="2" ParentId="117" CreationDate="2021-08-09T00:46:07.230" Score="2" Body="&lt;p&gt;For specific applications in industry, refer to this website:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://neos-guide.org/Case-Studies&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://neos-guide.org/Case-Studies&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6018" LastActivityDate="2021-08-09T00:46:07.230" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6727" PostTypeId="2" ParentId="117" CreationDate="2021-08-09T03:31:31.317" Score="2" Body="&lt;p&gt;I am surprised that no one has mentioned the classic&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Applied Mathematical Programming by Bradley, Hax, and Magnanti (Addison-Wesley, 1977)&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This book was one of the reference books in a few courses when I was an undergrad. It includes many examples and quite a few real world cases solved by mathematical programming. I read a few chapters of the book back then and found them easy to follow, yet with great relevant details. It might be considered old, but its content are still very relevant and informative. It is freely available for download from &lt;a href=&quot;http://web.mit.edu/15.053/www/AMP.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIT website&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2021-08-09T03:31:31.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6728" PostTypeId="1" CreationDate="2021-08-09T10:12:21.310" Score="1" ViewCount="59" Body="&lt;p&gt;Currently, I am working on facility location problems and I noticed why we use discrete demand setting at all. If the problem is to allocate customers to a facility and we have millions of customers, why do we do use still use discrete setting in this case?&lt;/p&gt;&#xA;&lt;p&gt;I understand the lack of literature devoted to continuous problems (for its difficulty) but does discrete demand setting make sense at all?&lt;/p&gt;&#xA;" OwnerDisplayName="user4387" LastEditorUserId="123" LastEditDate="2021-08-09T10:23:30.570" LastActivityDate="2021-08-09T10:23:30.570" Title="Why use the discrete demand setting at all?" Tags="|facility-location|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6729" PostTypeId="1" CreationDate="2021-08-09T16:17:37.777" Score="8" ViewCount="167" Body="&lt;p&gt;Given a current solution &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; and a &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-exchange move &lt;span class=&quot;math-container&quot;&gt;$(v_1, .., v_{2k+1})$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$v_1 = v_{2k+1}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$v_i \neq v_j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(v_i, v_{i+1}) \in E(S)$&lt;/span&gt; iff &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; odd, i.e. we remove all edges &lt;span class=&quot;math-container&quot;&gt;$(v_i, v_{i+1})$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; odd and add all edges &lt;span class=&quot;math-container&quot;&gt;$(v_i, v_{i+1})$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; even. Is there a way to determine in &lt;span class=&quot;math-container&quot;&gt;$O(k)$&lt;/span&gt; if the move is feasible, i.e. if the resulting solution is connected?&lt;/p&gt;&#xA;&lt;p&gt;To illustrate the question, here are a couple of examples:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vB1iA.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vB1iA.png&quot; alt=&quot;example&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2021-08-13T22:33:18.403" LastActivityDate="2021-08-13T22:33:18.403" Title="Traveling Salesman Problem: determine k-exchange feasibility" Tags="|traveling-salesman|local-search|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6730" PostTypeId="2" ParentId="6703" CreationDate="2021-08-09T17:56:04.617" Score="4" Body="&lt;p&gt;I believe the issue was with the following constraint name:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# If Koramangala 5th Block, then one must be Italian&#xA;model += (y['koramangala_5th_block_bin'] &amp;lt;= x['italian_bin'], '5th_block_italian')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It seems that PuLP did not like the name starting with a number even though it was a string.&lt;/p&gt;&#xA;&lt;p&gt;If I changed the constraint to this, the model ran.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# If Koramangala 5th Block, then one must be Italian&#xA;model += (y['koramangala_5th_block_bin'] &amp;lt;= x['italian_bin'], 'fifth_block_italian')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6019" LastActivityDate="2021-08-09T17:56:04.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6731" PostTypeId="1" AcceptedAnswerId="6736" CreationDate="2021-08-09T19:12:34.330" Score="2" ViewCount="229" Body="&lt;p&gt;I've been trying solve a specific case of the resource constrained project scheduling problem with partially renewable resources (RCPSP/&lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; in the literature e.g. &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/mnsc.45.4.543&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;). These resources are renewed after a subset of time-periods, as opposed to standard renewable resource which are renewed after every time period.&lt;/p&gt;&#xA;&lt;h2&gt;Notation&lt;/h2&gt;&#xA;&lt;h3&gt;Sets&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; - set of activities. &lt;span class=&quot;math-container&quot;&gt;$I=\{0,1,\dots,n+1\}$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; are dummy activities);&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; - set of time periods;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; - set of partially renewable resources;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; - set of precedences. If &lt;span class=&quot;math-container&quot;&gt;$(i,j) \in E$&lt;/span&gt; then activity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; must be processed after activity &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\Pi_r$&lt;/span&gt; - set of subset of periods for resource &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$\Pi_r=\{P_{r1},\dots,P_{rU}\}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$P_{ru}\subset T$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$u=1,\dots,U$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Parameters&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b_{ri}$&lt;/span&gt; - parameter (&lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^+$&lt;/span&gt;) that denotes the consumption of resource &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; for activity &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$B_{r}$&lt;/span&gt; - parameter (&lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^+$&lt;/span&gt;) that denotes the resource &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; available.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{i}$&lt;/span&gt; - parameter (&lt;span class=&quot;math-container&quot;&gt;$\mathbb{Z}^+$&lt;/span&gt;) that denotes the duration (in time periods) of activity &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Formulation&lt;/h2&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{it}$&lt;/span&gt; be a binary variable which takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if activity &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; starts at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;/p&gt;&#xA;&lt;p&gt;With this, we can formulate the IP,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\min \sum_{t}t x_{n+1,t} &amp;amp; &amp;amp; \\&#xA;&amp;amp;\textbf{st.}  \sum_{t} x_{it}=1 &amp;amp; \forall i \\&#xA;&amp;amp;  \sum_{i} b_{ri} \sum_{s\in P_{ru}} x_{is}\leq B_r &amp;amp; \forall r, P_{ru}\in \Pi_r \\&#xA;&amp;amp; \sum_{t} tx_{jt} - \sum_t tx_{it} \geq p_i &amp;amp; \forall (i,j)\in E \\&#xA;&amp;amp; x_{it}\in\{0,1\} &amp;amp; \forall i,t&#xA; \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Minimise the makespan subject to: unique start time for each activity, partially renewable resource constraints, and precedence.&lt;/p&gt;&#xA;&lt;h2&gt;Simplifications and Initial approach&lt;/h2&gt;&#xA;&lt;p&gt;In our case we have several simplifications.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The duration is unitary for all activities, &lt;span class=&quot;math-container&quot;&gt;$p_i=1, \forall i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The resource demand is either &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_{ri}\in\{0,1\}, \forall r,i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Each subset &lt;span class=&quot;math-container&quot;&gt;$P_{ru}$&lt;/span&gt; as a fixed size &lt;span class=&quot;math-container&quot;&gt;$D_r\geq1$&lt;/span&gt;. The number of these is the feasible times that don't exceed the planning horizon, &lt;span class=&quot;math-container&quot;&gt;$U=|\{t\in T: t\leq|T|-D_r + 1\}|$&lt;/span&gt;. And &lt;span class=&quot;math-container&quot;&gt;$P_{ru} = \{t\in T: u\leq t &amp;lt; u+D_r\}$&lt;/span&gt; (set of processing times for a given start time &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;Example&lt;/h4&gt;&#xA;&lt;p&gt;For example, consider an instance with &lt;span class=&quot;math-container&quot;&gt;$T=\{1,2,3,4\}$&lt;/span&gt;, and one resource with &lt;span class=&quot;math-container&quot;&gt;$D_r=3$&lt;/span&gt;.&#xA;We have &lt;span class=&quot;math-container&quot;&gt;$U=|\{1,2\}|$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$P_{r1}=\{1,2,3\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_{r2}=\{2,3,4\}$&lt;/span&gt;.&#xA;For a single activity, the resource constraints look like (letting &lt;span class=&quot;math-container&quot;&gt;$b_{r1}=1$&lt;/span&gt;),&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{11}+&amp;amp;x_{12}&amp;amp;+x_{13} &amp;amp; &amp;amp;\leq B_r\\&#xA; &amp;amp; x_{12}&amp;amp;+x_{13}&amp;amp;+x_{14} &amp;amp;\leq B_r&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As an approximation for large instances, we are translating the problem to a standard renewable resource case and solving it using the cumulative constraint in OR-Tools. For this, we force to the subsets to contain a single element (a single time period) and the upper bound on resources &lt;span class=&quot;math-container&quot;&gt;$B_r$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\left\lfloor\frac{B_r}{D_r}\right\rfloor$&lt;/span&gt;, obtaining the standard constraint,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_i b_{ri} \sum_{s=\max\{0,t-p_i+1\}}^t x_{is}\leq \left\lfloor\frac{B_r}{D_r}\right\rfloor, \forall r, t&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since, &lt;span class=&quot;math-container&quot;&gt;$p_i=1$&lt;/span&gt;, we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_i b_{ri} x_{it}\leq \left\lfloor\frac{B_r}{D_r}\right\rfloor, \forall r, t&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h2&gt;Questions&lt;/h2&gt;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Using OR-Tools, is there an efficient formulation that doesn't require a &lt;code&gt;BoolVar&lt;/code&gt; for each binary variable? E.g. enforcing the cumulative constraint for the subsets?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Also, with the simplifications mentioned, does anyone recognise the problem or some potential ways of attacking it?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4752" LastEditorUserId="4752" LastEditDate="2021-08-10T13:21:00.860" LastActivityDate="2021-08-12T13:05:52.700" Title="A specific case of a resource constrained project scheduling problem with partially renewable resources (RCPSP/$\pi$) - OR-Tools" Tags="|scheduling|or-tools|cutting-planes|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6732" PostTypeId="2" ParentId="6723" CreationDate="2021-08-10T13:14:54.510" Score="4" Body="&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This answer is intended to show what I have learned from the valuable answer provided by @Mark L.Stone. His post answered my question of why the simulation is biased. Hence, this post provides only additional insight. I chose to post it as an answer and not an edit due to the original question already being lengthy.&lt;/p&gt;&#xA;&lt;p&gt;What has been learned comes from chapter 14.4 of &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0691140626&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Probability, Markov Chains, Queues, and Simulation&lt;/a&gt; and chapter 23 of &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/1107027500&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Performance Modeling and Design of Computer Systems&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h4&gt;Service time distribution of customer observed at time &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;&lt;/h4&gt;&#xA;&lt;p&gt;Let us denote the service time distribution of a customer observed at time &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; by the random variable &lt;span class=&quot;math-container&quot;&gt;$\phi\sim F_{\phi}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$F_{\phi}$&lt;/span&gt; is its cdf and &lt;span class=&quot;math-container&quot;&gt;$f_{\phi}$&lt;/span&gt; is its pdf. Interest lies in &lt;span class=&quot;math-container&quot;&gt;$f_{\phi}$&lt;/span&gt; due to its use in computing expected values. It will also be used to derive &lt;span class=&quot;math-container&quot;&gt;$f_r$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_{\tau}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As noted by Mark and the simulation experiments, &lt;span class=&quot;math-container&quot;&gt;$f_{\phi} \neq f_{\Delta}$&lt;/span&gt;. We can argue the following about &lt;span class=&quot;math-container&quot;&gt;$f_{\phi}$&lt;/span&gt; by reasoning in terms of &lt;span class=&quot;math-container&quot;&gt;$P(t \leq \phi \leq  t + dt) = f_{\phi}(t) dt$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;f_{\phi}(t)dt &amp;amp; \propto \mbox{length of observed service interval}\\&#xA;&amp;amp; \propto t&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;f_{\phi}(t)dt &amp;amp; \propto \mbox{frequency of service intervals with length } \phi\\&#xA;&amp;amp; \propto f_{\Delta}(t) dt.&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Hence we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;f_{\phi}(t)dt &amp;amp; \propto t f_\Delta(t) dt\\&#xA;&amp;amp; = \eta\, t f_\Delta(t) dt&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;where the constant of normalisation has closed form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\eta &amp;amp; = \left( \int_{0}^{\infty} \Delta f_{\Delta}(\Delta) d\Delta  \right)^{-1}\\&#xA;&amp;amp; = \frac{1}{\mathbb{E}[\Delta]}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;which yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f_{\phi}(t)dt = \frac{t f_\Delta(t) dt}{\mathbb{E}[\Delta]}&#xA;$$&lt;/span&gt;&#xA;such that we obtain the desired result&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f_{\phi}(t) = \frac{t f_\Delta(t)}{\mathbb{E}[\Delta]}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h4&gt;Process age &lt;span class=&quot;math-container&quot;&gt;$f_{\tau}$&lt;/span&gt;&lt;/h4&gt;&#xA;&lt;p&gt;If we have observed/inspected service duration &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; then the service age &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; at observation &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; should be &lt;em&gt;uniformly&lt;/em&gt; distributed as &lt;span class=&quot;math-container&quot;&gt;$\tau \in [0,\phi]$&lt;/span&gt;. We now reason that &lt;span class=&quot;math-container&quot;&gt;$P(\tau \leq t \mid \phi) = t/\phi = F_{\tau}(t\mid \phi)$&lt;/span&gt;. Take the derivative with respect to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\frac{dF_{\tau}(t|\phi)}{dt} &amp;amp; = \frac{1}{\phi}\\&#xA;\therefore dF_{\tau}(t|\phi) &amp;amp;=  \frac{dt}{\phi} \\&#xA;&amp;amp; = P(t \leq \tau \leq t + dt| t \leq \phi) \\&#xA;&amp;amp; = f_\tau(t|\phi) dt&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;We are not interested in the conditional. Hence &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; needs to be marginalised out.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;P(t \leq \tau \leq t + dt) &amp;amp; = f_\tau(t) dt\\&#xA;&amp;amp; = \int_{0}^{\infty} f_\tau(t|\phi)\,dt \, f_{\phi}(\phi) \mathbb{1}_{\{t\leq \phi\}} \,d\phi\\&#xA;&amp;amp; = \int_{t}^{\infty} \frac{dt}{\phi} f_{\phi}(\phi) d\phi\\&#xA;&amp;amp; = \int_{t}^{\infty} \frac{dt}{\phi} \frac{\phi f_{\Delta}(\phi)}{\mathbb{E}[\Delta]} d\phi \\&#xA;&amp;amp; = \frac{1}{\mathbb{E}[\Delta]}\left( 1 - \int_{0}^{t} f_{\Delta}(\phi)\,d\phi\,dt  \right) \\&#xA;&amp;amp; = \frac{1 - F_{\Delta}(t)}{\mathbb{E}[\Delta]}dt\\&#xA;&amp;amp; = \frac{\bar{F}_{\Delta}(t)}{\mathbb{E}[\Delta]}dt\\&#xA;\therefore f_\tau(t)&amp;amp;= \frac{\bar{F}_{\Delta}(t)}{\mathbb{E}[\Delta]}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\bar{F}_{\Delta}$&lt;/span&gt; is the survival function of the per &lt;span class=&quot;math-container&quot;&gt;$k^{th}$&lt;/span&gt; customer service distribution &lt;span class=&quot;math-container&quot;&gt;$\Delta_k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h4&gt;Remaining/residual lifetime&lt;/h4&gt;&#xA;&lt;p&gt;The same process can be followed to obtain &lt;span class=&quot;math-container&quot;&gt;$f_r$&lt;/span&gt;. However, doing so will only confirm &lt;span class=&quot;math-container&quot;&gt;$f_{\tau} = f_r$&lt;/span&gt;. The simulations also confirm this.&lt;/p&gt;&#xA;&lt;p&gt;From these densities, &lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[r]$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[\tau]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[\phi]$&lt;/span&gt; can be determined. The next section takes a look at how to derive the expectations via renewal-reward theory instead. This seems appropriate as we are working with the &lt;em&gt;renewal&lt;/em&gt;/inspection paradox.&lt;/p&gt;&#xA;&lt;h4&gt;Renewal-reward theory&lt;/h4&gt;&#xA;&lt;p&gt;The work up to now comes from the first reference. The second reference takes a renewal-reward theory perspective and places emphasis on finding &lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[\tau]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[r]$&lt;/span&gt;. It argues that if the system is ergodic then the time-average of a renewal cycle should equal the ensemble average of a cycle (i.e. it expectation). In other words, if we let a renewal cycle constitute a service duration then&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\mathbb{E}[r] &amp;amp; = \frac{\mathbb{E}[\mbox{total } r \mbox{ earned over }\Delta]}{\mathbb{E}[\Delta]}\\&#xA;&amp;amp; = \frac{\mathbb{E}\left[\int_{0}^{\Delta}(\Delta - r)dr\right]}{\mathbb{E}[\Delta]}\\&#xA;&amp;amp; = \frac{\mathbb{E}[\Delta^2]}{2\mathbb{E}[\Delta]}.&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;The below figure (from the second source) should make this idea clear where &lt;span class=&quot;math-container&quot;&gt;$r = S_e$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\Delta = S$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FEJuR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FEJuR.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The same can be done for &lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[\tau]$&lt;/span&gt; where the triangles grow in reverse. The result should be &lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[r] = \mathbb{E}[\tau]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h4&gt;Bias&lt;/h4&gt;&#xA;&lt;p&gt;We can now determine the bias &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\beta &amp;amp; = \mathbb{E}[\tau]+\mathbb{E}[r]  - \mathbb{E}[\Delta] \\&#xA;&amp;amp; = \frac{\mathbb{E}[\Delta^2]}{\mathbb{E}[\Delta]}- \mathbb{E}[\Delta] \\&#xA;&amp;amp; = \frac{\mathbb{E}[\Delta^2] - \mathbb{E}[\Delta]^2}{\mathbb{E}[\Delta]}&#xA;\\&#xA;&amp;amp; = \frac{\mbox{Var}(\Delta)}{\mathbb{E}[\Delta]}\\&#xA;&amp;amp; = C_V^2(\Delta)\mathbb{E}[\Delta]&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$C_V^2(\Delta)$&lt;/span&gt; is the coefficient of variation. We see that variation is what increases bias. This is an interesting result because it explains a lot about why queues form even though the service rate exceeds the arrival rate. Due to variance, service intervals appears as long and short realisations. Queues form when arrivals meet a system where a busy server is in a long interval. Intuitively, more variance means more long intervals and more queue growth. As the system is ergodic and the mean service rate is greater than the mean arrival rate then short intervals should empty the queue sometime in the limit/long-run.&lt;/p&gt;&#xA;&lt;h4&gt;Updated code/experiment&lt;/h4&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Additional functions&#xA;&#xA;def f_phi(t,f_delta):&#xA;    return  t*f_delta.pdf(t)/f_delta.mean()&#xA;&#xA;def f_r(t,f_delta):&#xA;    return f_delta.sf(t)/f_delta.mean()&#xA;&#xA;def f_tau(t,f_delta):&#xA;    return f_r(t,f_delta)&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    # Setup simulation&#xA;    alpha = 0.9999  # almost 1 e.g. 1 - 1e-6&#xA;    # f_delta = norm(loc=15,scale=3)&#xA;    f_delta = gamma(a=0.5,scale=28)  # high cv2 = 2&#xA;    # f_delta = gamma(a=3,scale=14/3) # cv2 just below 1&#xA;    # f_delta = gamma(a=7,scale=2)  # low cv2&#xA;    # f_delta = gamma(a=14,scale=1)  # very low cv2&#xA;    # f_delta = gamma1,(scale=14)   # cv2 = 1&#xA;    cv2 = f_delta.var()/f_delta.mean()**2&#xA;    T = 1000/2   # Run long enough to reach steady state (bit extreme maybe?)&#xA;    samples = 5000  # Need a reasonable amount of iid samples&#xA;    # Perform simulation&#xA;    tau,r,delta = sample_interrupted_services(f_delta,T,samples)&#xA;    # Plot empirical pdfs&#xA;    fig,ax = plt.subplots(3,1)&#xA;    ax[0].hist(tau,bins=80,density=True,alpha=0.5,label='simulated ages')&#xA;    ax[1].hist(r,bins=80,density=True,alpha=0.5,label='simulated remainder')&#xA;    ax[2].hist(delta,bins=80,density=True,alpha=0.5,label='simulated service durations')&#xA;    # Plot algebraic counterparts for comparison&#xA;    t = np.linspace(0,f_delta.ppf(alpha),200)&#xA;    ax[0].plot(t,f_tau(t,f_delta),label='&lt;span class=&quot;math-container&quot;&gt;$f_{\\tau}$&lt;/span&gt;')&#xA;    ax[1].plot(t,f_r(t,f_delta),label='&lt;span class=&quot;math-container&quot;&gt;$f_r$&lt;/span&gt;')&#xA;    ax[2].plot(t,f_phi(t,f_delta),label='&lt;span class=&quot;math-container&quot;&gt;$f_\phi$&lt;/span&gt;')&#xA;    ax[2].plot(t,f_delta.pdf(t),label='&lt;span class=&quot;math-container&quot;&gt;$f_{\Delta}$&lt;/span&gt;')&#xA;    bias = f_delta.moment(2)/(f_delta.moment(1)) - f_delta.moment(1)&#xA;    empirical_bias = delta.mean() - f_delta.mean()&#xA;    print('Algebraic bias: ',bias)&#xA;    print('Empirical bias: ',empirical_bias)&#xA;    # Show legend/labels&#xA;    _ = [ax[i].legend(loc='upper right') for i in range(3)]&#xA;    fig.show()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; some different options with regards to &lt;span class=&quot;math-container&quot;&gt;$C_V^2$&lt;/span&gt; values have been given. We run the experiment for &lt;span class=&quot;math-container&quot;&gt;$C_V^2 = 2$&lt;/span&gt; and get a bias of &lt;span class=&quot;math-container&quot;&gt;$28$&lt;/span&gt; as opposed to the previous simulation where &lt;span class=&quot;math-container&quot;&gt;$C_V^2 = 0.143$&lt;/span&gt; gave &lt;span class=&quot;math-container&quot;&gt;$\beta = 2$&lt;/span&gt;. Here is the new experiment.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/r1d1e.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/r1d1e.png&quot; alt=&quot;New experiment&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here is the old one.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gveX2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gveX2.png&quot; alt=&quot;Old experiment&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1241" LastEditorUserId="1241" LastEditDate="2021-08-15T21:08:56.947" LastActivityDate="2021-08-15T21:08:56.947" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6733" PostTypeId="1" AcceptedAnswerId="6734" CreationDate="2021-08-10T13:22:11.107" Score="3" ViewCount="126" Body="&lt;p&gt;Could someone please check this code. I modified constraints as :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;No. of nurses - 10&lt;/li&gt;&#xA;&lt;li&gt;Max No. of nurses in Morning/Afternoon/Evening Shifts - 3/4/2&lt;/li&gt;&#xA;&lt;li&gt;Max no. of shifts in a week per nurse - 5&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;    from ortools.sat.python import cp_model    &#xA;    &#xA;    class NursesPartialSolutionPrinter(cp_model.CpSolverSolutionCallback):&#xA;        &amp;quot;&amp;quot;&amp;quot;Print intermediate solutions.&amp;quot;&amp;quot;&amp;quot;&#xA;    &#xA;        def __init__(self, shifts, num_nurses, num_days, num_shifts, sols):&#xA;            cp_model.CpSolverSolutionCallback.__init__(self)&#xA;            self._shifts = shifts&#xA;            self._num_nurses = num_nurses&#xA;            self._num_days = num_days&#xA;            self._num_shifts = num_shifts&#xA;            self._solutions = set(sols)&#xA;            self._solution_count = 0&#xA;    &#xA;        def on_solution_callback(self):&#xA;            if self._solution_count in self._solutions:&#xA;                print('Solution %i' % self._solution_count)&#xA;                for d in range(self._num_days):&#xA;                    print('Day %i' % d)&#xA;                    for n in range(self._num_nurses):&#xA;                        is_working = False&#xA;                        for s in range(self._num_shifts):&#xA;                            if self.Value(self._shifts[(n, d, s)]):&#xA;                                is_working = True&#xA;                                print('  Nurse %i works shift %i' % (n, s))&#xA;                        if not is_working:&#xA;                            print('  Nurse {} does not work'.format(n))&#xA;                print()&#xA;            self._solution_count += 1&#xA;    &#xA;        def solution_count(self):&#xA;            return self._solution_count&#xA;    &#xA;    &#xA;    &#xA;    def main():&#xA;        # Data.&#xA;        num_nurses = 10&#xA;        num_shifts = 3&#xA;        num_days = 7&#xA;        all_nurses = range(num_nurses)&#xA;        all_shifts = range(num_shifts)&#xA;        all_days = range(num_days)&#xA;        # Creates the model.&#xA;        model = cp_model.CpModel()&#xA;    &#xA;        # Creates shift variables.&#xA;        # shifts[(n, d, s)]: nurse 'n' works shift 's' on day 'd'.&#xA;        shifts = {}&#xA;        for n in all_nurses:&#xA;            for d in all_days:&#xA;                for s in all_shifts:&#xA;                    shifts[(n, d,&#xA;                            s)] = model.NewBoolVar('shift_n%id%is%i' % (n, d, s))&#xA;    &#xA;        # Each shift is assigned to exactly one nurse in the schedule period.&#xA;        for d in all_days:&#xA;            for s in all_shifts:&#xA;                if s==0:&#xA;                    model.Add(sum(shifts[(n, d, s)] for n in all_nurses) &amp;lt;= 3)&#xA;                if s==1:&#xA;                    model.Add(sum(shifts[(n, d, s)] for n in all_nurses) &amp;lt;= 4)&#xA;                if s==2:&#xA;                    model.Add(sum(shifts[(n, d, s)] for n in all_nurses) &amp;lt;= 2)&#xA;     &#xA;    &#xA;            &#xA;        # Each nurse works at most one shift per day.&#xA;        for n in all_nurses:&#xA;            for d in all_days:&#xA;                model.Add(sum(shifts[(n, d, s)] for s in all_shifts) &amp;lt;= 1)&#xA;    &#xA;        # Try to distribute the shifts evenly, so that each nurse works&#xA;        # min_shifts_per_nurse shifts. If this is not possible, because the total&#xA;        # number of shifts is not divisible by the number of nurses, some nurses will&#xA;        # be assigned one more shift.&#xA;        min_shifts_per_nurse = (num_shifts * num_days) // num_nurses&#xA;        if num_shifts * num_days % num_nurses == 0:&#xA;            max_shifts_per_nurse = min_shifts_per_nurse&#xA;        else:&#xA;            max_shifts_per_nurse = 5&#xA;        for n in all_nurses:&#xA;            num_shifts_worked = 0&#xA;            for d in all_days:&#xA;                for s in all_shifts:&#xA;                    num_shifts_worked += shifts[(n, d, s)]&#xA;            model.Add(min_shifts_per_nurse &amp;lt;= num_shifts_worked)&#xA;            model.Add(num_shifts_worked &amp;lt;= max_shifts_per_nurse)&#xA;    &#xA;        # Creates the solver and solve.&#xA;        solver = cp_model.CpSolver()&#xA;        solver.parameters.linearization_level = 0&#xA;        # Display the first five solutions.&#xA;        a_few_solutions = range(5)&#xA;        solution_printer = NursesPartialSolutionPrinter(shifts, num_nurses,&#xA;                                                        num_days, num_shifts,&#xA;                                                        a_few_solutions)&#xA;        solver.SearchForAllSolutions(model, solution_printer)&#xA;    &#xA;        # Statistics.&#xA;        print()&#xA;        print('Statistics')&#xA;        print('  - conflicts       : %i' % solver.NumConflicts())&#xA;        print('  - branches        : %i' % solver.NumBranches())&#xA;        print('  - wall time       : %f s' % solver.WallTime())&#xA;        print('  - solutions found : %i' % solution_printer.solution_count())&#xA;    &#xA;    &#xA;    if __name__ == '__main__':&#xA;        main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It's not showing correct solutions as per constraints:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Solution 0&#xA;Day 0&#xA;  Nurse 0 works shift 1&#xA;  Nurse 1 works shift 0&#xA;  Nurse 2 works shift 0&#xA;  Nurse 3 does not work&#xA;  Nurse 4 works shift 0&#xA;  Nurse 5 works shift 1&#xA;  Nurse 6 works shift 1&#xA;  Nurse 7 works shift 1&#xA;  Nurse 8 works shift 2&#xA;  Nurse 9 works shift 2&#xA;Day 1&#xA;  Nurse 0 works shift 2&#xA;  Nurse 1 does not work&#xA;  Nurse 2 works shift 1&#xA;  Nurse 3 does not work&#xA;  Nurse 4 does not work&#xA;  Nurse 5 works shift 1&#xA;  Nurse 6 works shift 1&#xA;  Nurse 7 works shift 0&#xA;  Nurse 8 works shift 0&#xA;  Nurse 9 works shift 0&#xA;Day 2&#xA;  Nurse 0 does not work&#xA;  Nurse 1 does not work&#xA;  Nurse 2 does not work&#xA;  Nurse 3 does not work&#xA;  Nurse 4 does not work&#xA;  Nurse 5 does not work&#xA;  Nurse 6 does not work&#xA;  Nurse 7 does not work&#xA;  Nurse 8 does not work&#xA;  Nurse 9 does not work&#xA;Day 3&#xA;  Nurse 0 does not work&#xA;  Nurse 1 does not work&#xA;  Nurse 2 does not work&#xA;  Nurse 3 works shift 1&#xA;  Nurse 4 works shift 1&#xA;  Nurse 5 does not work&#xA;  Nurse 6 does not work&#xA;  Nurse 7 does not work&#xA;  Nurse 8 does not work&#xA;  Nurse 9 does not work&#xA;Day 4&#xA;  Nurse 0 does not work&#xA;  Nurse 1 does not work&#xA;  Nurse 2 does not work&#xA;  Nurse 3 does not work&#xA;  Nurse 4 does not work&#xA;  Nurse 5 does not work&#xA;  Nurse 6 does not work&#xA;  Nurse 7 does not work&#xA;  Nurse 8 does not work&#xA;  Nurse 9 does not work&#xA;Day 5&#xA;  Nurse 0 does not work&#xA;  Nurse 1 does not work&#xA;  Nurse 2 does not work&#xA;  Nurse 3 does not work&#xA;  Nurse 4 does not work&#xA;  Nurse 5 does not work&#xA;  Nurse 6 does not work&#xA;  Nurse 7 does not work&#xA;  Nurse 8 does not work&#xA;  Nurse 9 does not work&#xA;Day 6&#xA;  Nurse 0 does not work&#xA;  Nurse 1 works shift 2&#xA;  Nurse 2 does not work&#xA;  Nurse 3 works shift 2&#xA;  Nurse 4 does not work&#xA;  Nurse 5 does not work&#xA;  Nurse 6 does not work&#xA;  Nurse 7 does not work&#xA;  Nurse 8 does not work&#xA;  Nurse 9 does not work&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5968" LastEditorUserId="981" LastEditDate="2023-12-29T10:51:15.657" LastActivityDate="2023-12-29T10:51:15.657" Title="Nurse Rostering Code with custom constraints Not Working" Tags="|modeling|python|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6734" PostTypeId="2" ParentId="6733" CreationDate="2021-08-10T13:58:10.377" Score="3" Body="&lt;p&gt;I didn't added lower bound for shift requirements so here's working code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    from ortools.sat.python import cp_model&#xA;&#xA;    class NursesPartialSolutionPrinter(cp_model.CpSolverSolutionCallback):&#xA;    &amp;quot;&amp;quot;&amp;quot;Print intermediate solutions.&amp;quot;&amp;quot;&amp;quot;&#xA;&#xA;    def __init__(self, shifts, num_nurses, num_days, num_shifts, sols):&#xA;        cp_model.CpSolverSolutionCallback.__init__(self)&#xA;        self._shifts = shifts&#xA;        self._num_nurses = num_nurses&#xA;        self._num_days = num_days&#xA;        self._num_shifts = num_shifts&#xA;        self._solutions = set(sols)&#xA;        self._solution_count = 0&#xA;&#xA;    def on_solution_callback(self):&#xA;        if self._solution_count in self._solutions:&#xA;            print('Solution %i' % self._solution_count)&#xA;            for d in range(self._num_days):&#xA;                print('Day %i' % d)&#xA;                for n in range(self._num_nurses):&#xA;                    is_working = False&#xA;                    for s in range(self._num_shifts):&#xA;                        if self.Value(self._shifts[(n, d, s)]):&#xA;                            is_working = True&#xA;                            print('  Nurse %i works shift %i' % (n, s))&#xA;                    if not is_working:&#xA;                        print('  Nurse {} does not work'.format(n))&#xA;            print()&#xA;        self._solution_count += 1&#xA;&#xA;    def solution_count(self):&#xA;        return self._solution_count&#xA;&#xA;&#xA;&#xA;def main():&#xA;    # Data.&#xA;    num_nurses = 10&#xA;    num_shifts = 3&#xA;    num_days = 7&#xA;    all_nurses = range(num_nurses)&#xA;    all_shifts = range(num_shifts)&#xA;    all_days = range(num_days)&#xA;    # Creates the model.&#xA;    model = cp_model.CpModel()&#xA;&#xA;    # Creates shift variables.&#xA;    # shifts[(n, d, s)]: nurse 'n' works shift 's' on day 'd'.&#xA;    shifts = {}&#xA;    for n in all_nurses:&#xA;        for d in all_days:&#xA;            for s in all_shifts:&#xA;                shifts[(n, d,&#xA;                        s)] = model.NewBoolVar('shift_n%id%is%i' % (n, d, s))&#xA;&#xA;    # Each shift is assigned to exactly one nurse in the schedule period.&#xA;    for d in all_days:&#xA;        for s in all_shifts:&#xA;            if s==0:&#xA;                model.Add(sum(shifts[(n, d, s)] for n in all_nurses) &amp;lt;= 3)&#xA;                model.Add(sum(shifts[(n, d, s)] for n in all_nurses) &amp;gt;= 2)&#xA;            if s==1:&#xA;                model.Add(sum(shifts[(n, d, s)] for n in all_nurses) &amp;lt;= 4)&#xA;                model.Add(sum(shifts[(n, d, s)] for n in all_nurses) &amp;gt;= 2)&#xA;            if s==2:&#xA;                model.Add(sum(shifts[(n, d, s)] for n in all_nurses) &amp;lt;= 2)&#xA;                model.Add(sum(shifts[(n, d, s)] for n in all_nurses) &amp;gt;= 1)&#xA;&#xA;&#xA;&#xA;    # Each nurse works at most one shift per day.&#xA;    for n in all_nurses:&#xA;        for d in all_days:&#xA;            model.Add(sum(shifts[(n, d, s)] for s in all_shifts) &amp;lt;= 1)&#xA;&#xA;    # Try to distribute the shifts evenly, so that each nurse works&#xA;    # min_shifts_per_nurse shifts. If this is not possible, because the total&#xA;    # number of shifts is not divisible by the number of nurses, some nurses will&#xA;    # be assigned one more shift.&#xA;    min_shifts_per_nurse = (num_shifts * num_days) // num_nurses&#xA;    if num_shifts * num_days % num_nurses == 0:&#xA;        max_shifts_per_nurse = min_shifts_per_nurse&#xA;    else:&#xA;        max_shifts_per_nurse = 5&#xA;    for n in all_nurses:&#xA;        num_shifts_worked = 0&#xA;        for d in all_days:&#xA;            for s in all_shifts:&#xA;                num_shifts_worked += shifts[(n, d, s)]&#xA;        model.Add(min_shifts_per_nurse &amp;lt;= num_shifts_worked)&#xA;        model.Add(num_shifts_worked &amp;lt;= max_shifts_per_nurse)&#xA;&#xA;    # Creates the solver and solve.&#xA;    solver = cp_model.CpSolver()&#xA;    solver.parameters.linearization_level = 0&#xA;    # Display the first five solutions.&#xA;    a_few_solutions = range(20)&#xA;    solution_printer = NursesPartialSolutionPrinter(shifts, num_nurses,&#xA;                                                    num_days, num_shifts,&#xA;                                                    a_few_solutions)&#xA;    solver.SearchForAllSolutions(model, solution_printer)&#xA;&#xA;    # Statistics.&#xA;    print()&#xA;    print('Statistics')&#xA;    print('  - conflicts       : %i' % solver.NumConflicts())&#xA;    print('  - branches        : %i' % solver.NumBranches())&#xA;    print('  - wall time       : %f s' % solver.WallTime())&#xA;    print('  - solutions found : %i' % solution_printer.solution_count())&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    main()&#xA;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5968" LastEditorUserId="36" LastEditDate="2021-08-14T14:58:38.177" LastActivityDate="2021-08-14T14:58:38.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6735" PostTypeId="1" CreationDate="2021-08-10T18:02:58.910" Score="3" ViewCount="123" Body="&lt;p&gt;The problem statement currently I have is very broad (or you can say very vague at the same time):&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I have a number of dropping locations (Customer locations)&lt;/li&gt;&#xA;&lt;li&gt;I have the location of the HUB&lt;/li&gt;&#xA;&lt;li&gt;I have a list of available truck sizes with different rates for per kg-km and their respective fixed costs too.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Based on the historical data, I will have to model it in a way so that the total operation cost is minimized. I can select different combination of truck sizes. The main goal is to minimise the total cost.&lt;/p&gt;&#xA;&lt;p&gt;Previously I was looking at this as a VRP with the heterogeneous fleet problem, but currently, I am feeling I'll have to model it in a different way. So far, I have reduced the number of dropping locations by clustering them and I have set a maximum demand per cluster by Capacitated clustering.&lt;/p&gt;&#xA;&lt;p&gt;Any idea how to approach this problem? Any literature or any headway will be very helpful. I am modelling it in R, so any documentation in R will be an added bonus.&lt;/p&gt;&#xA;" OwnerUserId="5532" LastEditorUserId="491" LastEditDate="2021-12-02T04:52:28.863" LastActivityDate="2021-12-02T04:52:28.863" Title="How to approach this Truck Utilisation problem?" Tags="|optimization|modeling|combinatorial-optimization|r|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6736" PostTypeId="2" ParentId="6731" CreationDate="2021-08-10T21:47:01.127" Score="2" Body="&lt;p&gt;To have resources being released at given time points, you have two options.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Have one optional interval per time interval. This interval always ends at the end of the interval. For a given demand, one of the optional intervals must be selected. And the presence literal of the optional interval implies that the start of the main interval is equal to the start of the optional interval, same thing for the end, and duration if needed.&lt;/li&gt;&#xA;&lt;li&gt;Restrict the end variable of the interval to be only and the end of the time period. Have the duration variable and greater than the processing time. The trick is to make sure the interval does not cross one of the time points. Either restrict the duration to be smaller to the distance between two time points (in case this is regular), of have one boolean var per time interval, and have this boolvar implies that the end is the end of the interval, and that the start in included in the interval.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;More details on 2:&lt;/p&gt;&#xA;&lt;p&gt;Imagine the task must end at 10, 20, 30. You can restrict the domain of the end_var to be {10, 20, 30}. If the duration of the task is &amp;lt;= 10, you have nothing else to do.  If duration is &amp;gt; 10, the problem is infeasible.&lt;/p&gt;&#xA;&lt;p&gt;In the second case, task must end at 20, 30, or 50. You can still restrict the domain of the end_var to {20, 30, 50}.  But with a duration of 15, a start of time of 15 is not valid. You have two solution for this:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the duration is fixed, you can always restrict the start to [0..5] U [30..35].&lt;/li&gt;&#xA;&lt;li&gt;If the duration is variable (i.e. in [5, 15]), this is not valid. So you create 1 boolean per time interval ([0..20], [20..30], and [30..50]) and add the implication:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;   b1 =&amp;gt; end == 20&#xA;   b1 =&amp;gt; start in [0..20]&#xA;&#xA;   b2 =&amp;gt; end == 30&#xA;   b2 =&amp;gt; start in [20..30]&#xA;&#xA;   b3 =&amp;gt; end == 50&#xA;   b3 =&amp;gt; start in [30..50]&#xA;&#xA;   b1 + b2 + b3 == 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I hope this is clear enough.&lt;/p&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2021-08-12T13:05:52.700" LastActivityDate="2021-08-12T13:05:52.700" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6737" PostTypeId="1" CreationDate="2021-08-11T10:03:45.900" Score="1" ViewCount="313" Body="&lt;p&gt;I need some set covering and column generation examples in OR-Tools python.&#xA;If anyone can provide or direct me to some resources that would be great..!&lt;/p&gt;&#xA;" OwnerUserId="5968" LastEditorUserId="36" LastEditDate="2021-08-11T12:34:51.673" LastActivityDate="2021-08-11T12:34:51.673" Title="Set Covering and Column Generation" Tags="|python|reference-request|or-tools|column-generation|set-covering|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="6738" PostTypeId="1" AcceptedAnswerId="6739" CreationDate="2021-08-11T16:12:01.883" Score="6" ViewCount="270" Body="&lt;p&gt;I am working on a graph partitioning problem. A static column generation based solution was proposed in &lt;a href=&quot;https://or.stackexchange.com/questions/6428/how-to-partition-a-graph-with-optimal-number-of-groups/6429?noredirect=1#comment13430_6429&quot;&gt;How to partition a graph with optimal number of groups?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But I need some MILP solver to solve this problem. I want a pure heuristic approach to solve this problem.&lt;/p&gt;&#xA;&lt;p&gt;What would be an efficient heuristic approach to solve this problem, i.e., solving without the need of any solver?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2021-08-12T20:28:57.143" LastActivityDate="2021-08-12T20:28:57.143" Title="Heuristic solution to the graph partitioning problem" Tags="|mixed-integer-programming|linear-programming|graphs|heuristics|column-generation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6739" PostTypeId="2" ParentId="6738" CreationDate="2021-08-11T16:45:27.727" Score="7" Body="&lt;p&gt;A greedy heuristic is natural to try here:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Declare all groups to be admissible.&lt;/li&gt;&#xA;&lt;li&gt;Find an admissible group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; with the largest weight.&lt;/li&gt;&#xA;&lt;li&gt;Set &lt;span class=&quot;math-container&quot;&gt;$u_g=1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Declare all groups &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$N_h \cap N_g \not= \emptyset$&lt;/span&gt; inadmissible.&lt;/li&gt;&#xA;&lt;li&gt;If some &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is still uncovered, go to step 2.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;For your sample data in the linked question, this greedy heuristic returns groups&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\{11,12,15\}, \{8,10,13\}, \{4,5,6\}, \{7,9,14\}, \{1,2,3\}$$&lt;/span&gt;&#xA;(in that order), and this turns out to be an optimal solution.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-08-11T18:12:38.437" LastActivityDate="2021-08-11T18:12:38.437" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6740" PostTypeId="2" ParentId="6738" CreationDate="2021-08-11T18:11:24.557" Score="4" Body="&lt;p&gt;A variant of Rob's answer would be a random key genetic algorithm. You can program a GA from scratch, although you're probably better off using an open-source library.&lt;/p&gt;&#xA;&lt;p&gt;Each &amp;quot;chromosome&amp;quot; in the GA would be a permutation of the indices &lt;span class=&quot;math-container&quot;&gt;$1,\dots, \vert G \vert$&lt;/span&gt; (or a vector of &lt;span class=&quot;math-container&quot;&gt;$\vert G \vert$&lt;/span&gt; real values whose sort order would translate to such a permutation). To decode and evaluate a chromosome, sort &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; using the permutation vector. Select the first group in permutation order. Go down the permuted list, selecting each eligible group until there are no eligible groups left. As in Rob's answer, selecting group renders ineligible any subsequent group that intersects it.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-11T18:11:24.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6741" PostTypeId="1" CreationDate="2021-08-12T20:10:38.250" Score="1" ViewCount="206" Body="&lt;p&gt;Suppose we have a parametric convex program with some constraints.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{split}&#xA;\max_{x} \: &amp;amp; f(x,\mathbf{a})\\&#xA;&amp;amp; g_1(x,\mathbf{a})\le 0 \\&#xA;&amp;amp; g_2(x,\mathbf{a}) \le 0&#xA;\end{split}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{a}$&lt;/span&gt; is a vector of parameters. I can obtain all KKT points and their corresponding Lagrangian multipliers. I am wondering if it is possible to find the optimal solution based on KKT points and multipliers by conditioning on them? I mean, I want to find conditions and then say if condition 1 is true, the optimal solution will be the first KKT point, and so on.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="491" LastEditDate="2022-10-25T02:50:40.447" LastActivityDate="2022-10-25T02:50:40.447" Title="How to find the optimal solution of a convex program given all KKT points?" Tags="|convex-optimization|kkt-conditions|lagrange-multipliers|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6742" PostTypeId="2" ParentId="6741" CreationDate="2021-08-13T07:56:06.550" Score="1" Body="&lt;p&gt;This sounds like &lt;a href=&quot;https://en.wikipedia.org/wiki/Parametric_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;parametric programming&lt;/a&gt; to me.&lt;/p&gt;&#xA;&lt;p&gt;In short, you can calculate a set of regions, typically called &amp;quot;critical regions&amp;quot;, within which the same set of constraints is active. This in return enables you to calculate &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; as an explicit function of your parameter &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There are MATLAB tools to do this, most prominently the &lt;a href=&quot;https://parametric.tamu.edu/POP/&quot; rel=&quot;nofollow noreferrer&quot;&gt;POP&lt;/a&gt; and &lt;a href=&quot;https://www.mpt3.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MPT&lt;/a&gt; toolboxes, which support linear and quadratic (mixed-integer) problems.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2021-08-13T07:56:06.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6743" PostTypeId="1" CreationDate="2021-08-13T13:15:54.840" Score="0" ViewCount="85" Body="&lt;p&gt;I have a problem of planning the distribution of products for a month. I have different unique products. A Mandate is provided for each product, and the Mandated quantity for each product is to be delivered during the month while respecting stock levels (cant deliver it all directly cause no stock available). Products are delivered through loading stations to vehicles. I need to minimize the number of vehicles used. I have developed the following model but for some reason variable &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; seeks always to be positive, rendering the problem sometimes infeasible or giving erroneous results. Can anyone help me with catching the issue, any help is very much appreciated. Even if it is some reference to close problem in the literature.&lt;/p&gt;&#xA;&lt;p&gt;Variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{p,t,j}$&lt;/span&gt; continuous variable representing the quantity of product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; to be delivered on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; using station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_{p,t}$&lt;/span&gt; quantity of available stock of product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; at day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$B_{p,t,j}$&lt;/span&gt; boolean variable equal to 1 if product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is scheduled to be delivered on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; using station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Y_{t,j}$&lt;/span&gt;  boolean variable equal to 1 if station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is open on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objective function:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;min \sum_p \sum_t \sum_j B_{p,t,j}&#xA;$$&lt;/span&gt;&#xA;Minimize the number of times a product is delivered&lt;/p&gt;&#xA;&lt;p&gt;Constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(1) \sum_t \sum_j x_{p,t,j} = Mandate_p, \forall p&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(2) S_{p,t} = S_{p,t-1} + Feed_{p,t} - \sum_j x_{p,t,j}, \forall p,t&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(3) Min_{p} \le S_{p,t} \le Max_{p}, \forall p, t&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(4)x_{p,t,j} \le M * B_{p,t,j}, \forall p,t,j&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(5) \sum_j B_{p,t,j} \le 1, \forall p,t&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(6)  B_{p,t,j} \le Y_{t,j}, \forall p,t,j&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(7) \sum_p \gamma * x_{p,t,j} \le 24 * Y_{t,j}, \forall t,j &#xA;$$&lt;/span&gt;&#xA;Constraint (1) is to assure Mandates are fulfilled for all products, constraint (2) is the stock level at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, constraint (3) fixes the maximum and minimum allowable stock per product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, constraint (4) is a fixed-charge model that says that a product is delivered only if it is assigned to a station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, constraint (5) only one station is used for a product per day, constraint (6) a product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is delivered at station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; if station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is open at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, constraint (7) is to model the time needed to charge multiple product which needs to be less than 24 hours, and it is allowed in case station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is open. &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; is a constant representing speed.&lt;/p&gt;&#xA;" OwnerUserId="6016" LastActivityDate="2021-08-13T13:15:54.840" Title="Products distribution planning model" Tags="|mixed-integer-programming|modeling|constraint|" AnswerCount="0" CommentCount="14" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6744" PostTypeId="1" AcceptedAnswerId="6745" CreationDate="2021-08-13T14:24:42.217" Score="7" ViewCount="482" Body="&lt;p&gt;I know that both bilinear programming and mixed integer linear programming are NP-hard. But is there a preference to have when choosing an approach to solve a problem that can be represented in both, especially when all variables must have binary values? For example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Bilinear version&lt;/strong&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max&amp;amp;\quad\sum_{\forall i} v_i\cdot x_i\\&#xA;\text{s.t.}&amp;amp;\quad\forall i,v,\ i\neq v,\ x_i\cdot x_v = 0\\&#xA;&amp;amp;\quad\forall i,\ x_i \leq 1\\ &#xA;&amp;amp;\quad\forall i,\ x_i \geq 0.&#xA;\end{align}&lt;/span&gt;&#xA;Note that the problem forces the values to be binary without explicitly stating it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;MILP version&lt;/strong&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max&amp;amp;\quad\sum_{\forall i} v_i\cdot x_i\\&#xA;\text{s.t.}&amp;amp;\quad\sum_{\forall i} x_i \leq 1\\&#xA;&amp;amp;\quad\forall i,\ x_i \in\{0,1\}.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;These two problems will lead to the same result, but which one is more appropriate and efficiently designed?&lt;/p&gt;&#xA;" OwnerUserId="5257" LastEditorUserId="5257" LastEditDate="2021-08-14T19:19:16.827" LastActivityDate="2021-08-14T19:19:16.827" Title="Bilinear programming vs Mixed integer linear programming performance comparison" Tags="|mixed-integer-programming|binary-variable|quadratic-programming|benchmark|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6745" PostTypeId="2" ParentId="6744" CreationDate="2021-08-13T18:01:40.610" Score="8" Body="&lt;p&gt;Constraining a variable to be binary could be expressed as a quadratic constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x\in\{0,1\} \iff x(1-x)=0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is often mentioned in non-convex QCQP articles to present non-convex QCQP is a somehow more general problem class.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\{\mbox{MILP}\}\subset\{\mbox{non-convex QCQP}\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are some off-the-shelf non-convex QCQP (global) solvers, like gurobi. But their performance are generally poor. (I guess the reason might be that the problem class is TOO general, making it hard to solve, and less applied, making solver companies paying less attention to it.)&lt;/p&gt;&#xA;&lt;p&gt;So in theory every MILP could be reformulated as a QCQP (maybe in different ways), and solved with a QCQP solver, but due to the different ways the solvers utilize the problem structure, and the efficiency difference, there is no benefit to do that. So just stick to MILP.&lt;/p&gt;&#xA;&lt;p&gt;PS. Your example model could be relaxed to continuous, and the solution should automatically be integer.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastEditorUserId="123" LastEditDate="2021-08-13T18:49:38.680" LastActivityDate="2021-08-13T18:49:38.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6746" PostTypeId="1" CreationDate="2021-08-14T03:52:28.540" Score="1" ViewCount="179" Body="&lt;p&gt;Just trying to understand the example given in Mosek Fusion handbook as shown&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4lOnE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4lOnE.jpg&quot; alt=&quot;here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm not exactly sure how to convert 7.3 to 7.4 in terms of objective function. I understand the power cone &lt;span class=&quot;math-container&quot;&gt;$P_{3}^{0.2, 0.8}$&lt;/span&gt; constraint gives &lt;span class=&quot;math-container&quot;&gt;$x_0^{0.2}x_1^{0.8} \ge |x_3|$&lt;/span&gt; =&amp;gt; &lt;span class=&quot;math-container&quot;&gt;$x^{0.2}y^{0.8} \ge |x_{3}|$&lt;/span&gt;&#xA;Similarly, &lt;span class=&quot;math-container&quot;&gt;$P_{3}^{0.4, 0.6}$&lt;/span&gt; constraint gives &lt;span class=&quot;math-container&quot;&gt;$x_2^{0.4}x_5^{0.6} \ge |x_4|$&lt;/span&gt; =&amp;gt; &lt;span class=&quot;math-container&quot;&gt;$z^{0.4} \ge |x_{4}|$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, I failed to see how to convert the new objective in 7.4 back to the objective in 7.3. I.e. &lt;span class=&quot;math-container&quot;&gt;$\max x_3 + x4 - x_0$&lt;/span&gt;  =&amp;gt;??  &lt;span class=&quot;math-container&quot;&gt;$\max |x_3| + |x_4| - x_0$&lt;/span&gt; &amp;gt;=?? &lt;span class=&quot;math-container&quot;&gt;$\max x^{0.2}y^{0.8} + z^{0.4} - x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can someone explain?&lt;/p&gt;&#xA;&lt;p&gt;Also, in the codes, it has:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/gKIDe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gKIDe.png&quot; alt=&quot;constraint&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Why is one Var.vstack and the other is Expr.vstack?&lt;/p&gt;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="6060" OwnerDisplayName="inf" LastEditorUserId="36" LastEditDate="2021-08-14T13:35:52.923" LastActivityDate="2021-08-16T06:27:14.513" Title="Questions on Mosek Fusion Power Cone example" Tags="|optimization|conic-optimization|mosek|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6747" PostTypeId="1" AcceptedAnswerId="6752" CreationDate="2021-08-14T09:53:56.627" Score="3" ViewCount="256" Body="&lt;p&gt;I have the behavior of CPLEX during a MIP search, when it finds the optimal solution in a reasonable time during a forced &amp;quot;solution polishing&amp;quot; phase only. Otherwise, if you do not switch the search process to &amp;quot;solution polishing&amp;quot;, it will work for hours without any guarantees to find the optimum! I've had unsuccessful attempts to play around with the search parameters. The point is that I need to shorten the search time and I believe that understanding the reasons of this behavior can help me.&lt;/p&gt;&#xA;" OwnerUserId="5561" LastEditorUserId="123" LastEditDate="2021-08-19T07:14:49.670" LastActivityDate="2021-08-19T07:14:49.670" Title="The optimum is achieved only by forced &quot;solution polishing&quot;" Tags="|optimization|mixed-integer-programming|cplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6748" PostTypeId="1" AcceptedAnswerId="6749" CreationDate="2021-08-14T11:20:09.980" Score="1" ViewCount="399" Body="&lt;p&gt;I am trying to update my mutable parameter Nc in my Abstract model&#xA;the initial value is 4&#xA;I constructed the instance then change instance.Nc to 5 and solve it but it is still 4 (initial value) , can any body help ?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.environ import *&#xA;import random &#xA;&#xA;model = AbstractModel()&#xA;model.i = RangeSet(40)&#xA;model.j = Set(initialize=model.i)&#xA;model.x = Var(model.i,model.j, initialize=0,within=Binary)&#xA;model.y = Var(model.i, within=Binary)&#xA;&#xA;model.Nc=Param(initialize=5,mutable=True)&#xA;def Ninit(model,i):&#xA;    return random.randint(0,1)&#xA;&#xA;model.N=Param(model.i,initialize=Ninit,mutable=True)&#xA;&#xA;def Dinit(model,i,j):&#xA;    return random.random()&#xA;model.D=Param(model.i,model.j,initialize=Dinit,mutable=True)&#xA;def rule_C1(model,i,j):&#xA;        return model.x[i,j]&amp;lt;=model.N[i]*model.y[j] &#xA;model.C1   = Constraint(model.i,model.j,rule=rule_C1)&#xA;def rule_C2(model):&#xA;        return sum(model.y[i] for i in model.i )==model.Nc&#xA;model.C2   = Constraint(rule=rule_C2)&#xA;def rule_C3(model,i):&#xA;        return sum(model.x[i,j] for j in model.j)==model.N[i]&#xA;&#xA;model.C3   = Constraint(model.i,rule=rule_C3)&#xA;&#xA;def rule_OF(model):&#xA;    return sum( model.x[i,j]*model.D[i,j] for i in model.i for j in model.j )&#xA;model.obj = Objective(rule=rule_OF, sense=minimize)&#xA;opt = SolverFactory('glpk')&#xA;&#xA;#model.NC=4&#xA;instance = model.create_instance()&#xA;instance.NC=4&#xA;results = opt.solve(instance) # solves and updates instance&#xA;print('NC= ',value(instance.Nc))&#xA;print('OF= ',value(instance.obj))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2021-08-14T11:38:34.770" LastActivityDate="2021-08-30T07:33:53.870" Title="Why my mutable parameter does not update in Pyomo?" Tags="|pyomo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6749" PostTypeId="2" ParentId="6748" CreationDate="2021-08-14T12:21:33.797" Score="1" Body="&lt;p&gt;This is because instance.NC=4 has a wrong spelling for Nc&lt;/p&gt;&#xA;&lt;p&gt;In order to fix this, the correct spelling of Nc should be used (not NC)&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2021-08-14T12:21:33.797" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6751" PostTypeId="2" ParentId="6600" CreationDate="2021-08-14T15:48:44.940" Score="3" Body="&lt;p&gt;In the vein of version control — continuous integration/deployment strategies. This, in addition to an integrated testing suite has made significant improvements to deployment cycles and could be completed through unittest and Github Actions.&lt;/p&gt;&#xA;&lt;p&gt;As prubin mentions, interfaces control for the application can also play a critical role. While he seems to prefer GUIs (and if it's client facing, this is obviously superior), I prefer command-line interfaces — specifically through Python's argparse.&lt;/p&gt;&#xA;" OwnerUserId="6062" LastEditorUserId="123" LastEditDate="2021-08-14T18:23:20.467" LastActivityDate="2021-08-14T18:23:20.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6752" PostTypeId="2" ParentId="6747" CreationDate="2021-08-14T16:13:48.143" Score="4" Body="&lt;p&gt;Sorry to be discouraging, but I think this is likely a matter of luck, and I'm not sure there is any useful way to understand it. If you have not already done so, you might try switching the MIP emphasis to 1 (feasibility) or 4 (hidden feasibility) or, if you have version 20, to the new setting 5 (heuristic), which emphasizes finding good solutions early. You can also try tweaking the RINS heuristic frequency or turn on the local branching heuristic.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-14T16:13:48.143" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6753" PostTypeId="1" CreationDate="2021-08-14T21:29:09.837" Score="5" ViewCount="199" Body="&lt;p&gt;The Steiner Tree version that I am considering is the following: given an undirected weighted graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; and a subset of vertices &lt;span class=&quot;math-container&quot;&gt;$T \subseteq V$&lt;/span&gt;, find a minimum tree that connects all the vertices in &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; which possibly contains vertices outside &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I know that both TSP and Steiner Tree are NP-hard and there are approximation algorithms for these problems that have an approximation guarantee of &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering whether there is any reduction from the Steiner Tree to TSP?&lt;/p&gt;&#xA;" OwnerUserId="6063" LastActivityDate="2021-08-14T21:29:09.837" Title="Reduction from Steiner Tree to TSP" Tags="|graphs|traveling-salesman|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6754" PostTypeId="1" CreationDate="2021-08-15T05:54:07.907" Score="3" ViewCount="52" Body="&lt;p&gt;Given two graphs with n vertices each, where apriori information regarding the similarity of each pair of vertices (between the source and target nodes) is given, is there a known concept for finding the (sub) optimal matching problem?&lt;/p&gt;&#xA;&lt;p&gt;A &amp;quot;good&amp;quot; solution will match neighbor source vertices to neighbor targets (similarly to the QAP problem), but will also try to maximize the summed source-target similarity of the graph match solution.&lt;/p&gt;&#xA;" OwnerUserId="6064" LastActivityDate="2021-08-15T05:54:07.907" Title="Graph matching with apriori information about the matches?" Tags="|graphs|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6755" PostTypeId="2" ParentId="6693" CreationDate="2021-08-15T12:48:48.527" Score="1" Body="&lt;p&gt;The question is in itself incomplete as the number of depots is not mentioned. Given that, the solutions become evident. Please correct the question.&lt;/p&gt;&#xA;&lt;p&gt;Still, the solution is in breaking down the problem, yet, keeping it minimized is the challenging part. The only feasible approach is to create Primary and Secondary routing in which Primary is Pan-Country operations and Secondary is like Last-Mile Operations. And then apply the best of Graph Decomposition.&lt;/p&gt;&#xA;&lt;p&gt;After that, completing it through Greedy approach in a graph based query mechanism .&lt;/p&gt;&#xA;&lt;p&gt;However, heuristics/algorithm/AI based solvers would still keep the output sub-optimal. A complete zero-error Graph Decomposer is available with Neural Heights Private Limited. You can refer it here -&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/in/trilok-c-508657b6&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linkedin profile of Neural Heights' founder&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Mixing and matching the load volumes to get the exact number of vehicles needed is also part of the solution suite.&lt;/p&gt;&#xA;" OwnerUserId="6065" LastActivityDate="2021-08-15T12:48:48.527" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6756" PostTypeId="1" AcceptedAnswerId="6873" CreationDate="2021-08-15T21:08:29.310" Score="11" ViewCount="15743" Body="&lt;p&gt;I have used Gurobi and cplex for solving large scale LP problems with Pyomo. However, I do need to use open source solver. Any advise?&#xA;glpk and cbc seems to be very slow in solving the problem (with 2e6 variables)&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="491" LastEditDate="2021-08-19T13:18:04.083" LastActivityDate="2021-09-06T00:23:46.167" Title="What is the best open source solver for large scale LP optimization in pyomo?" Tags="|optimization|linear-programming|solver|convex-optimization|pyomo|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6757" PostTypeId="2" ParentId="6756" CreationDate="2021-08-16T04:21:37.153" Score="3" Body="&lt;p&gt;If you mean by LP is referred to the linear programming (not mixed-integer linear programming), there are some open-source solvers like SoPlex and Clp which can be linked with Pyomo via Neos server but, I really do not know is there any way to connect those locally. If you meant is the mixed-integer linear programming one of the best options is SCIP, but as far as I know it's not quite free at all.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-08-16T04:21:37.153" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6758" PostTypeId="2" ParentId="6746" CreationDate="2021-08-16T06:27:14.513" Score="3" Body="&lt;p&gt;Maximizing &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is equivalent to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{ll}&#xA;  \mathrm{maximize} &amp;amp; t \\ &#xA;  \mathrm{subject\ to} &amp;amp; f(x)\geq t \end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is a new variable that does not appear anywhere else, since it pays off to push &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; as high as possible i.e to reach equality in the constraint. That is what happens with the extra variables in that model.&lt;/p&gt;&#xA;&lt;p&gt;Var is used for a bit of efficiency because all argmuents are variables. You could use Expr throughout.&lt;/p&gt;&#xA;" OwnerUserId="488" LastActivityDate="2021-08-16T06:27:14.513" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6759" PostTypeId="1" CreationDate="2021-08-16T10:30:52.740" Score="3" ViewCount="1132" Body="&lt;p&gt;I have a variable in Pyomo called &lt;code&gt;model.variable_objectiveCosts&lt;/code&gt; and I would like to print this value to a file. Basically it works. But when I would like to divide the value by 100 and then round to 2 decimal digits, I get an error when using the following code &lt;code&gt; &amp;quot;%.2f&amp;quot; %   model.variable_objectiveCosts/100&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The error message is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;TypeError: Implicit conversion of Pyomo NumericValue type `variable_objectiveCosts' to a float is&#xA;disabled. This error is often the result of using Pyomo components as&#xA;arguments to one of the Python built-in math module functions when&#xA;defining expressions. Avoid this error by using Pyomo-provided math&#xA;functions.&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now it tells me to use the Pyomo-provided math functions. However, I could not find a round function in Pyomo. Do you know how I can still round the result to 2 digits?&lt;/p&gt;&#xA;&lt;p&gt;Here is a part of my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Imports&#xA;import pyomo.environ as pyo&#xA;import pandas as pd&#xA;from pyomo.util.infeasible import log_infeasible_constraints&#xA;from pyomo.opt import SolverStatus, TerminationCondition&#xA;import sys&#xA;&#xA;#Check if the problem is solved or infeasible&#xA;if (solution.solver.status == SolverStatus.ok) and (solution.solver.termination_condition == TerminationCondition.optimal):&#xA;        # Do something when the solution in optimal and feasible&#xA;        print(&amp;quot;Result Status: Optimal&amp;quot;)&#xA;        #Create pandas dataframe for displaying the results&#xA;        outputVariables_list = [model.variable_heatGenerationCoefficient_SpaceHeating, model.variable_heatGenerationCoefficient_DHW, model.variable_help_OnlyOneStorage, model.variable_temperatureBufferStorage, model.variable_usableVolumeDHWTank, model.variable_surplusPowerTotal, model.variable_surplusPowerPositivePart, model.variable_surplusPowerNegativePart, model.variable_help_isSurplusPowerPositive, model.variable_electricalPowerTotal, model.variable_RESGenerationTotal, model.variable_pvGeneration, model.variable_costsPerTimeSlotPositivePart, model.variable_revenuePerTimeSlotPositivePart, model.variable_currentChargingPowerEV, model.variable_energyLevelEV, model.variable_SOC_EV, model.param_heatDemand_In_W, model.param_DHWDemand_In_W, model.param_electricalDemand_In_W, model.param_pvGenerationNominal, model.param_outSideTemperature_In_C, model.param_windAssignedNominal, model.param_electricityPrice_In_Cents, model.param_availabilityPerTimeSlotOfEV, model.param_energyConsumptionEV, model.param_COPHeatPump_SpaceHeating, model.param_COPHeatPump_DHW, model.param_BigM_Surplus_Positive, model.param_BigM_Surplus_Negative, model.param_BigM_Costs_Positive, model.param_BigM_Costs_Negative, model.variable_objectiveMaximumLoad, model.variable_objectiveSurplusEnergy ,model.variable_objectiveCosts, model.objective_combined_general, model.set_timeslots]&#xA;        optimal_values_list = [[pyo.value(model_item[key]) for key in model_item] for model_item in outputVariables_list] &#xA;        results = pd.DataFrame(optimal_values_list)&#xA;        results= results.T&#xA;        results = results.rename(columns = {0:'variable_heatGenerationCoefficient_SpaceHeating', 1:'variable_heatGenerationCoefficient_DHW', 2:'variable_help_OnlyOneStorage', 3:'variable_temperatureBufferStorage', 4:'variable_usableVolumeDHWTank', 5:'variable_surplusPowerTotal', 6:'variable_surplusPowerPositivePart', 7:'variable_surplusPowerNegativePart', 8:'variable_help_isSurplusPowerPositive', 9:'variable_electricalPowerTotal', 10:'variable_RESGenerationTotal', 11:'variable_pvGeneration', 12:'variable_costsPerTimeSlot', 13:'variable_revenuePerTimeSlot', 14:'variable_currentChargingPowerEV', 15:'variable_energyLevelEV', 16:'variable_SOC_EV', 17:'param_heatDemand_In_W', 18:'param_DHWDemand_In_W', 19:'param_electricalDemand_In_W', 20:'param_pvGenerationNominal', 21:'param_outSideTemperature_In_C', 22:'param_windAssignedNominal', 23:'param_electricityPrice_In_Cents', 24:'param_availabilityPerTimeSlotOfEV', 25:'param_energyConsumptionEV', 26:'param_COPHeatPump_SpaceHeating', 27:'param_COPHeatPump_DHW', 28:'param_BigM_Surplus_Positive', 29:'param_BigM_Surplus_Negative', 30:'param_BigM_Costs_Positive', 31:'param_BigM_Costs_Negative', 32:'variable_objectiveMaximumLoad_kW', 33:'variable_objectiveSurplusEnergy_kWH', 34:'variable_objectiveCosts_Euro', 35:'objective_combined_general', 36:'set_timeslots'})&#xA;        cols = ['set_timeslots']&#xA;    results[cols]= results [cols].round(0).astype(int)&#xA;    results.set_index('set_timeslots', inplace=True)&#xA;    results.to_csv(&amp;quot;C:/Users/wi9632/Desktop/Result_BT1.csv&amp;quot;, index=True,  sep =&amp;quot;;&amp;quot;) &#xA;elif (solution.solver.termination_condition == TerminationCondition.infeasible):&#xA;    # Do something when model in infeasible&#xA;    print (&amp;quot;Result Status: Infeasible&amp;quot;)&#xA;else:&#xA;    # Something else is wrong&#xA;    print(&amp;quot;Solver Status: &amp;quot;, solution.solver.status)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2021-08-18T12:58:41.283" LastActivityDate="2021-08-18T12:58:41.283" Title="How to round values in Pyomo" Tags="|pyomo|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="6760" PostTypeId="2" ParentId="6759" CreationDate="2021-08-16T11:04:41.783" Score="2" Body="&lt;p&gt;The best way to proceed is that&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Let the Pyomo solve the problem&lt;/li&gt;&#xA;&lt;li&gt;Use round(value(model.OF)) ,2)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2021-08-16T11:04:41.783" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6761" PostTypeId="2" ParentId="6756" CreationDate="2021-08-16T13:50:10.743" Score="12" Body="&lt;p&gt;There is a new open source solver that looks quite promising, HiGHS:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.maths.ed.ac.uk/hall/HiGHS/&quot; rel=&quot;noreferrer&quot;&gt;https://www.maths.ed.ac.uk/hall/HiGHS/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But as pointed out by others, for mixed-integer programming problems, at the moment, open-source solvers can't compete on performance and reliability with commercial solvers.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2021-08-16T13:50:10.743" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="6762" PostTypeId="1" AcceptedAnswerId="6763" CreationDate="2021-08-17T01:09:55.950" Score="6" ViewCount="442" Body="&lt;p&gt;I am looking for a formula to measure the difficulty level of a Sudoku solution.&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="38" LastEditDate="2022-04-11T00:47:31.170" LastActivityDate="2022-04-11T00:47:31.170" Title="Do you know of any formula to calculate the difficulty score of Sudoku?" Tags="|mixed-integer-programming|linear-programming|puzzles-games|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6763" PostTypeId="2" ParentId="6762" CreationDate="2021-08-17T11:04:36.323" Score="9" Body="&lt;p&gt;In &lt;a href=&quot;https://www.aaai.org/ocs/index.php/FLAIRS/FLAIRS11/paper/download/2517/3077&quot; rel=&quot;noreferrer&quot;&gt;Pelánek (2011)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;, Sudoku difficulty evaluation was investigated across four existing metrics. These are based on incidences of various logic techniques (see &lt;a href=&quot;https://en.wikipedia.org/wiki/Constant_folding&quot; rel=&quot;noreferrer&quot;&gt;constant folding&lt;/a&gt;). Results based on Spearman's correlation coefficient are given in Table 1.&lt;/p&gt;&#xA;&lt;p&gt;Evaluation of difficulty through dynamical systems has &lt;a href=&quot;https://arxiv.org/pdf/1208.0370.pdf&quot; rel=&quot;noreferrer&quot;&gt;also been explored&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt;. In this setting, one considers the association between the difficulty of a Sudoku puzzle and the system's chaotic behaviour. The result is obtained by solving a coupled system of two differential equations after converting the Sudoku satisfiability problem into conjunctive normal form.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Pelánek, R. (2011). Difficulty rating of sudoku puzzles by a computational model. In &lt;em&gt;Twenty-Fourth International FLAIRS Conference&lt;/em&gt;. &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [2] Ercsey-Ravasz, M., Toroczkai, Z. (2012). The Chaos Within Sudoku. &lt;em&gt;Scientific reports.&lt;/em&gt; 2(1):1-8. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2021-08-17T11:04:36.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6764" PostTypeId="1" CreationDate="2021-08-17T15:14:45.393" Score="7" ViewCount="889" Body="&lt;p&gt;Does a ranking of TSP heuristics exist that is based on the quality of the solutions? For example a paper or another resource that compares the performance of TSP heuristics like the nearest neighbour, nearest insertion, saving algorithm, Christofides or others and gives advice on which one should be preferred?&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Edit: For me theoretical results and computational studies are interesting.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Edit: Construction heuristics would be specially interesting for me.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5571" LastEditorUserId="5571" LastEditDate="2021-08-18T10:00:38.073" LastActivityDate="2021-08-18T10:25:01.553" Title="Is there a ranking of heuristics for the travelling salesman problem?" Tags="|reference-request|traveling-salesman|heuristics|metaheuristics|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6765" PostTypeId="1" AcceptedAnswerId="6768" CreationDate="2021-08-17T17:27:27.353" Score="8" ViewCount="917" Body="&lt;p&gt;I am with a problem that consists of determining whether a VRP instance is &lt;strong&gt;feasible&lt;/strong&gt;, this question is a continuation of an &lt;a href=&quot;https://or.stackexchange.com/questions/6627/check-vrp-instance-is-feasibility&quot;&gt;older thread&lt;/a&gt;.&#xA;In order to do it, I was thinking of using Constraint Programming (CP).&#xA;Since this is &lt;strong&gt;my first time using CP&lt;/strong&gt;, I am facing some problems, specifically, in what concerns modeling the subcycle constraints in CP.&#xA;Before I show the CP model, let's define the VRP notations to substantiate the model.&#xA;Let&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$D(V, A)$&lt;/span&gt; be a complete digraph;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; be the set of nodes;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \in V$&lt;/span&gt; be the depot node;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; be the set of arcs;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t_a$&lt;/span&gt; be the arc &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; &lt;strong&gt;metric&lt;/strong&gt; traversing time;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; be a vehicle's time limit; and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; be the set of available vehicles.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note that we are dealing with the Distance Constrained VRP (DCVRP) variant.&#xA;Since we just want to find a feasible solution, if such exists, there's no need for optimizing anything, hence model this problem as a decision problem suffices.&#xA;Let&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_a \in \mathbb{B}$&lt;/span&gt; be equals to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if arc &lt;span class=&quot;math-container&quot;&gt;$a \in A$&lt;/span&gt; is used in the solution, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mu_i \in \mathbb{R}_{+}$&lt;/span&gt; be equals to the amount of incurred time at node &lt;span class=&quot;math-container&quot;&gt;$i \in V\backslash\{0\}$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Below is presented a CP model:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{a \in \delta^{+}(i)} x_a = \sum_{a \in \delta^{-}(i)} x_a \quad \forall i \in V \quad (1)\\&#xA;\sum_{a \in \delta^{+}(i)} x_a = 1 \quad \forall i \in V \backslash \{0\} \quad (2)\\&#xA;\sum_{a \in \delta^{+}(0)} x_a \leqslant |M| \quad (3)\\&#xA;u_i \geqslant t_{0i} x_{0i} \quad \forall i \in V \backslash \{0\} \quad (4)\\&#xA;u_j \geqslant u_i + t_{ij} x_{ij} - T (1 - x_{ij}) \quad \forall i, j \in V\backslash \{0\} \quad (5)\\&#xA;u_i \leqslant T - t_{i0} x_{i0} \quad \forall i \in V\backslash \{0\} \quad (6)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraints set (1) represents the degree constraints.&#xA;The set of constraints (2) states that every customer must be visited exactly once.&#xA;The set of constraints (3) forces that every solution use at most &lt;span class=&quot;math-container&quot;&gt;$|M|$&lt;/span&gt; routes.&#xA;And, the constraints sets (4-6) are the MTZ constraints to avoid subcycles disconnected from the depot, and at the same time guarantee that a route will consume at most &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; of time.&lt;/p&gt;&#xA;&lt;p&gt;I know I can model the constraints sets (1-3) easily, however, I can not state the same for the sets of constraints (4-6) since I do not know if it is possible to create non-discrete variables in CP models, as I said, this is my first time using CP.&#xA;Therefore, I would like to know if it is possible to represent the constraints (4-6) in CP or it would require a workaround, and if yes what.&#xA;Also, I would like to know if anyone has ever solved this problem, determine whether a VRP instance is feasible or not, through CP.&lt;/p&gt;&#xA;&lt;p&gt;Many thanks for your time and regards.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 1:&lt;/strong&gt; I added the constraints set (2). And stated that the times &lt;span class=&quot;math-container&quot;&gt;$t_a$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall a \in A$&lt;/span&gt; are metric.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="36" LastEditDate="2021-08-22T16:46:35.340" LastActivityDate="2021-08-24T15:27:38.590" Title="VRP through constraint programming" Tags="|modeling|constraint-programming|vehicle-routing|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="6766" PostTypeId="2" ParentId="6764" CreationDate="2021-08-17T19:21:04.037" Score="4" Body="&lt;p&gt;What you are looking for is the term &lt;a href=&quot;https://en.wikipedia.org/wiki/Domination_analysis&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;domination analysis&lt;/em&gt;&lt;/a&gt;. For instance, see:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Punnen, A., Margot, F., Kabadi, S. (2003) TSP heuristics: domination analysis and complexity. &lt;em&gt;Algorithmica&lt;/em&gt; 35(2):111-127. &lt;a href=&quot;https://doi.org/10.1007/s00453-002-0986-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;  &lt;strong&gt;[theoretical results]&lt;/strong&gt; &lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;César, R. &lt;em&gt;et al.&lt;/em&gt; (2011) Traveling salesman problem heuristics: Leading methods, implementations and latest advances. &lt;em&gt;European Journal of Operational Research.&lt;/em&gt; 211(3):427-441. &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2010.09.010&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt; [&lt;strong&gt;computational results&lt;/strong&gt;] &lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Rosenkrantz, D. J., Stearns, R. E., Philip M. L., II. (1977) An analysis of several heuristics for the traveling salesman problem. &lt;em&gt;SIAM Journal on Computing.&lt;/em&gt; 6(3):563-581. &lt;a href=&quot;https://doi.org/10.1137/0206041&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt; [&lt;strong&gt;theoretical results&lt;/strong&gt;] &lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;These cover performances of several of your listed heuristics (nearest neighbour, Christofides, insertion variants) as well as those developed in recent years.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2021-08-18T10:25:01.553" LastActivityDate="2021-08-18T10:25:01.553" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6767" PostTypeId="1" CreationDate="2021-08-17T20:24:41.200" Score="4" ViewCount="261" Body="&lt;p&gt;Suppose we have a multivariate function like &lt;span class=&quot;math-container&quot;&gt;$f(x,y,z)$&lt;/span&gt; which should be maximized with the constraints &lt;span class=&quot;math-container&quot;&gt;$g_i(x,y,z)\le 0 \quad \forall i$&lt;/span&gt;. The general rule is to use KKT conditions and derive all KKT points. Here, we determine all variables at the same time and through the same system of equations.&lt;/p&gt;&#xA;&lt;p&gt;I think another possibility is solve the problem sequentially like &lt;span class=&quot;math-container&quot;&gt;$\max_x \max_y \max_z f(x,y,z)$&lt;/span&gt;. I am wondering if the sequential approach is always correct and can be implemented? Should the problem be convex to use it or it can be used for non-convex problems, too?&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="491" LastEditDate="2023-01-29T15:19:12.627" LastActivityDate="2023-01-29T15:19:12.627" Title="Is it always possible to optimize a multivariate function sequentially?" Tags="|nonlinear-programming|convex-optimization|nonconvex-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6768" PostTypeId="2" ParentId="6765" CreationDate="2021-08-17T23:33:00.613" Score="7" Body="&lt;p&gt;The model proposed by the OP is not a CP model, but a MIP model. Although in theory it would be possible to implement this model directly in CP, in practice it would perform terrible; you would be much better off implementing this model in a MIP solver, and strengthening it with valid inequalities (and use proper subtour separation routines instead of weak MTZ constraints).&lt;/p&gt;&#xA;&lt;p&gt;There are at least 2 common CP formulations: one formulation uses 'next' variables, the other formulation uses scheduling constructs (e.g. interval variables). Here I'll only state the former formulation.&lt;/p&gt;&#xA;&lt;p&gt;To simplify the CP formulation, let's reformulate the vertex set &lt;span class=&quot;math-container&quot;&gt;$V=\{0,n+1\}\cup V'$&lt;/span&gt;. Vertex &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; is the starting depot, vertex &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; is the ending depot (starting and ending depots can have the same physical location, but we just represent them as 2 different vertices). Vertices &lt;span class=&quot;math-container&quot;&gt;$V'=\{1,2,\dots,n\}$&lt;/span&gt; are the customers that need to be visited.&lt;/p&gt;&#xA;&lt;p&gt;For the CP model, we create &lt;span class=&quot;math-container&quot;&gt;$|M|$&lt;/span&gt; copies of the destination depot. Let &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; denote the set of destination depot copies. The model uses 2 types of variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Variable &lt;span class=&quot;math-container&quot;&gt;$next_i$&lt;/span&gt; denotes the next node visited immediately after node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Variable &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; represents the arrival time at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Variables and domain definitions:&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; next_i\in V'\cup D &amp;amp;\forall i\in V'\\&#xA;&amp;amp; S_i \in [t_{0,i},T-t_{i,n+1}] &amp;amp;\forall i\in V'\\&#xA;&amp;amp; S_i \in [0,T] &amp;amp;\forall i\in D&#xA;\end{align}&lt;/span&gt;&#xA;Note that we define a &lt;span class=&quot;math-container&quot;&gt;$next_i$&lt;/span&gt; variable for every customer, and a arrival time variable for every customer and destination depot. The notation &lt;span class=&quot;math-container&quot;&gt;$[x,y]$&lt;/span&gt; defines the continuous time interval from &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; (inclusive).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\textit{allDifferent}(next_i|i\in V') &amp;amp;\\&#xA;&amp;amp; S_{next_i} = S_i+t_{i,next_i} &amp;amp; \forall i\in V'&#xA;\end{align}&lt;/span&gt;&#xA;The allDifferent constraint is a global constraint that forces every decision variable to assume pairwise different values. In other words, this constraint ensures that for &lt;span class=&quot;math-container&quot;&gt;$i,j\in V'$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$i\neq j$&lt;/span&gt;, it holds that &lt;span class=&quot;math-container&quot;&gt;$next_i\neq next_j$&lt;/span&gt;. Practically the allDifferent constraint ensures that each customer is visited at most once. In CP a feasible solution requires that each variable is assigned exactly one value from its domain, so this will ensure that every customer is visited exactly once.&lt;/p&gt;&#xA;&lt;p&gt;The second constraint updates the arrival times. Note that in CP, we can index a variable with another variable! Again, this constraint ensures that vehicles return to the depot in time (before &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;), and that there are no subtours.&lt;/p&gt;&#xA;&lt;p&gt;Note that the above formulation is very compact and actually easier that an equivalent ILP formulation. Unfortunately I don't think this CP formulation will work well to solve the problem that the OP intends to solve, namely verifying whether a single feasible solution &lt;em&gt;exists&lt;/em&gt;. If a feasible solution exists, the CP solver might do a reasonable job at finding it. However, if no solution exists, the solver will likely do a rather poor job at proving that no such solution exists. If you have additional constraints, such as tight time windows on the customers, this would actually help the CP solver as it would narrow down the domains of the &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; variables. Moreover, in your implementation you should probably set the 'inference level' of the allDifferent constraint to 'extended' (assuming the CP solver supports different inference levels for the allDifferent constraint)&lt;/p&gt;&#xA;&lt;p&gt;Remarks:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The above CP model can be easily extended to support time-windows (i.e. VRPTW), by shrinking the domains of the &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; variables to the corresponding time-windows. To allow a vehicle to arrive early at a customer and wait till the beginning of its time-window, the equality sign (&lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt;) in the 2nd constraint must be replaced by an inequality (&lt;span class=&quot;math-container&quot;&gt;$\geq$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The above CP formulation assumes that the triangle-inequality holds. If those do not hold, the initial domains of the &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; variables for &lt;span class=&quot;math-container&quot;&gt;$i\in V'$&lt;/span&gt; must be adjusted to prevent cutting-off feasible solutions. E.g. the left-hand side of the domain should be changed from &lt;span class=&quot;math-container&quot;&gt;$t_{0,i}$&lt;/span&gt; to the shortest path from &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Similar for the RHS.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2021-08-18T04:57:51.490" LastActivityDate="2021-08-18T04:57:51.490" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6769" PostTypeId="2" ParentId="6764" CreationDate="2021-08-18T01:15:36.443" Score="5" Body="&lt;p&gt;If you are looking for an experimental/numerical comparison (rather than a theoretical one), some experiments are reported in:&lt;/p&gt;&#xA;&lt;p&gt;D. S. Johnson and L. A. McGeoch. The traveling salesman problem: A case study in local optimization. In E. H. L. Aarts and J. K. Lenstra, editors, &lt;em&gt;Local Search in Combinatorial Optimization&lt;/em&gt;, pages 215–310. John Wiley &amp;amp; Sons, New York, 1997.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2021-08-18T01:15:36.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6770" PostTypeId="2" ParentId="6767" CreationDate="2021-08-18T01:37:12.240" Score="4" Body="&lt;p&gt;This is possible to do in &lt;em&gt;&lt;strong&gt;a functional form that preserves all relevant information&lt;/strong&gt;&lt;/em&gt;. As mentioned in the Convex Optimization by Boyd (page 133, Optimizing over some variables):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;We can always minimize a function by first minimizing&#xA;over some of the variables, and then minimizing over the remaining&#xA;ones. This simple and general principle can be used to transform&#xA;problems into equivalent forms. The general case is cumbersome ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Consider, for instance, the example that I mentioned in the comments:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;z^\star = \max~~ xyz\\&#xA;\text{s.t.}~~&#xA;0\le &amp;amp;x\le1 \\&#xA;-1\le &amp;amp;y\le 0 \\&#xA;-1\le &amp;amp;z\le 0 \\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In a procedure similar to the example of the book, we first begin by &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and define &lt;span class=&quot;math-container&quot;&gt;$z^\star(x)=x \cdot \max yz$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$-1\le y,z\le 0$&lt;/span&gt; which results in &lt;span class=&quot;math-container&quot;&gt;$z^\star(x)=x$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$y^\star = z^\star = -1$&lt;/span&gt;. In the next step, we maximize &lt;span class=&quot;math-container&quot;&gt;$z^\star(x)$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$0\le x\le 1$&lt;/span&gt; which gives &lt;span class=&quot;math-container&quot;&gt;$x^\star = 1$&lt;/span&gt; and so the general solution is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$z^\star=1,x^\star=1,y^\star=z^\star=-1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This example was simple since variables are not dependent in the constraints. In theory, you can do sequential optimization, but as Boyd and Vandenberghe mention, this is very problem dependent and could see different forms in different problems. There is no need for convexity or even differentiability as long as all information is properly preserved while moving from a subset of variables to the next.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastEditorUserId="123" LastEditDate="2021-08-18T08:40:47.643" LastActivityDate="2021-08-18T08:40:47.643" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6771" PostTypeId="1" AcceptedAnswerId="6780" CreationDate="2021-08-18T04:59:34.843" Score="3" ViewCount="67" Body="&lt;p&gt;I am building a small model that trades water and buys water. For simplicity reasons, I am only discussing the relevant constraints: &lt;span class=&quot;math-container&quot;&gt;$\sf varWaterIn_h$&lt;/span&gt; is the amount in litres of water bought per hour, while &lt;span class=&quot;math-container&quot;&gt;$\sf varWaterOut_h$&lt;/span&gt; is the amount in litres of water sold per hour. We have a water price defined as &lt;span class=&quot;math-container&quot;&gt;$\sf parWaterPrice$&lt;/span&gt; and the prefixes &lt;em&gt;var&lt;/em&gt; and &lt;em&gt;par&lt;/em&gt; stand for variables and parameters. In addition &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; stands for a very large number, where we can assume it's sufficiently large. &lt;span class=&quot;math-container&quot;&gt;$\sf varFlagIn$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sf varFlagOut$&lt;/span&gt; are binary constraints.&lt;/p&gt;&#xA;&lt;p&gt;To prohibit water buying and water selling at the same time, we have the following constraints for every hour:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}{\sf varWaterIn_h} &amp;amp;\leq M\cdot\sf varFlagIn_h\\{\sf varWaterOut_h} &amp;amp;\leq M \cdot \sf varFlagOut_h\\{\sf varFlagIn_h + varFlagOut_h} &amp;amp;\leq 1\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In addition there is also somewhere a constraint that specify that all water inflows and outflows needs to be the same, as you cannot have somewhere randomly generating water out of nowhere. It looks like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sf \dots + varWaterIn_h \dots = \dots + varWaterOut_h + \dots$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let us assume that we want to maximise the objective function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sf \sum_h parWaterPrice_h \cdot (varWaterIn_h - varWaterOut_h)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, when I specify it as this, I get a satifying answer, where we &lt;strong&gt;only&lt;/strong&gt; have either &lt;span class=&quot;math-container&quot;&gt;$\sf varWaterIn_h$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\sf varWaterOut_h$&lt;/span&gt;. However, it occurs to me that if we just specify the objective function, without the binary constraints, it should work too right?&lt;/p&gt;&#xA;&lt;p&gt;Meaning:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad\sf\sum_h parWaterPrice_h \cdot (varWaterIn_h - varWaterOut_h)\\\text{s.t.}&amp;amp;\quad\sf\dots + varWaterIn_h \dots = \dots + varWaterOut_h + \dots\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since we maximize our revenue, so it is impossible that the optimum would be buying and selling water at the same time right? Or am I missing something?&lt;/p&gt;&#xA;&lt;p&gt;The reason for wanting to specify it as a LP rather than an ILP is the speed at which a LP can be solved.&lt;/p&gt;&#xA;" OwnerUserId="563" LastEditorUserId="123" LastEditDate="2021-08-19T07:10:32.823" LastActivityDate="2021-08-19T07:12:05.747" Title="How to specify an objective function that prohibits trading in both directions linearly" Tags="|linear-programming|constraint|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6772" PostTypeId="1" AcceptedAnswerId="6781" CreationDate="2021-08-18T06:49:36.917" Score="4" ViewCount="210" Body="&lt;p&gt;So, I am trying to implement a greedy search algorithm to cluster a number of points. Each point has a specific demand and each cluster shouldn't exceed that demand. Now, when I run it for a smaller sample size, the clustering looks fine. But just when the sample size gets a bit larger, it just gets worse. Greedy search has an obvious backlog that, it will search for the local maxima/minima, but even after that, the results I am getting isn't making any sense. Also, I have added one more constraint that, the total intra-distance between the points of a cluster shouldn't exceed 40 km.&lt;/p&gt;&#xA;&lt;p&gt;Sharing my sample code in R, and the output for both the smaller sample size and a larger sample size.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;library(tidyverse)&#xA;library(data.table)&#xA;#Creating a sample dataframe with 100 points &#xA;#As the algorithm depends on the starting point&#xA;#Sorting it with long so that I will have one extreme point at the start&#xA;&#xA;set.seed(123)&#xA;sc_1m &amp;lt;- data.frame(customer_lat= runif(100, 22,23),&#xA;                    customer_long= runif(100, 77, 78),&#xA;                    demand= runif(100, 10, 70))&#xA;sc_1m %&amp;gt;%&#xA;  arrange((customer_long)) -&amp;gt; sc_1m&#xA;&#xA;&#xA;#Creating the distance matrix&#xA;library(sp)&#xA;d&amp;lt;- sc_1m[,c('customer_long','customer_lat')]&#xA;dm &amp;lt;- spDists(as.matrix(d), longlat = TRUE)&#xA;&#xA;rownames(dm) &amp;lt;- seq(1:nrow(sc_1m))&#xA;colnames(dm) &amp;lt;- seq(1:nrow(sc_1m))&#xA;&#xA;&#xA;#Making the diagonals NA so that it is excluded from the counting&#xA;&#xA;diag(dm) &amp;lt;- NA&#xA;&#xA;nearestpoints &amp;lt;- data.frame(matrix(ncol = 6, nrow = 0))&#xA;colnames(nearestpoints) &amp;lt;- c(&amp;quot;from&amp;quot;, &amp;quot;to&amp;quot;, &amp;quot;lon&amp;quot;, &amp;quot;lat&amp;quot;, &amp;quot;distance&amp;quot;, &amp;quot;demand&amp;quot;)&#xA;&#xA;inputrowindex=1&#xA;outputrowindex=1&#xA;#The visited points are the 'To' points&#xA;visitedpoints &amp;lt;- c(rownames(dm)[1])&#xA;&#xA;while(length(setdiff(rownames(dm), visitedpoints)) &amp;gt; 0){&#xA;  nearest &amp;lt;- which.min(dm[inputrowindex,])&#xA;  if(length(nearest)==0) break&#xA;  &#xA;  nearestpoints[outputrowindex, 1] &amp;lt;- rownames(dm)[inputrowindex]&#xA;  nearestpoints[outputrowindex, 2] &amp;lt;- names(nearest)&#xA;  nearestpoints[outputrowindex, 5] &amp;lt;- dm[inputrowindex, nearest]&#xA;  nearestpoints[outputrowindex, 3] &amp;lt;- sc_1m[nearest, 'customer_long']&#xA;  nearestpoints[outputrowindex, 4] &amp;lt;- sc_1m[nearest, 'customer_lat']&#xA;  nearestpoints[outputrowindex, 6] &amp;lt;- sc_1m[nearest, 'demand']&#xA;  &#xA;  dm[inputrowindex,] &amp;lt;- NA&#xA;  dm[,inputrowindex] &amp;lt;- NA&#xA;  &#xA;  visitedpoints &amp;lt;- c(visitedpoints, names(nearest))&#xA;  &#xA;  inputrowindex = as.numeric(nearest) #Next point is the nearest&#xA;  outputrowindex = outputrowindex + 1&#xA;}&#xA;&#xA;#The nearestpoints dataframe gives me the point to point mapping of nearest points&#xA;nearestpoints&#xA;&#xA;#Now I will run a while loop and cluster the points after setting a capacity&#xA;d_demand&amp;lt;-0&#xA;d_distance&amp;lt;-0&#xA;cluster_number&amp;lt;-1&#xA;cluster_list&amp;lt;- c()&#xA;i&amp;lt;-1&#xA;capacity_constraint &amp;lt;- 500&#xA;distance_constraint &amp;lt;- 40&#xA;&#xA;#Only taking the points within the set limits for the time being&#xA;&#xA;nearestpoints %&amp;gt;%&#xA;  filter(distance&amp;lt;distance_constraint) %&amp;gt;%&#xA;  filter(demand&amp;lt;capacity_constraint)-&amp;gt; nearestpoints&#xA;&#xA;while (i &amp;lt;= nrow(nearestpoints)){&#xA;  d_demand &amp;lt;- d_demand+ nearestpoints&lt;span class=&quot;math-container&quot;&gt;$demand[i]&#xA;  d_distance &amp;lt;- d_distance + nearestpoints$&lt;/span&gt;distance[i]&#xA;  if(d_demand&amp;lt;=capacity_constraint &amp;amp; d_distance&amp;lt;= distance_constraint){&#xA;    cluster_list[i] &amp;lt;- cluster_number&#xA;    i&amp;lt;- i+1&#xA;  }&#xA;  else{&#xA;    cluster_number &amp;lt;- cluster_number+1&#xA;    d_demand &amp;lt;- 0&#xA;    d_distance &amp;lt;- 0&#xA;    i&amp;lt;-i&#xA;  }&#xA;}&#xA;&#xA;nearestpoints$cluster &amp;lt;- cluster_list&#xA;&#xA;#Visualise the polygon&#xA;&#xA;nearestpoints_dt&amp;lt;- data.table(nearestpoints)&#xA;hulls = nearestpoints_dt[,.SD[chull(lon,lat)],by=.(cluster)]&#xA;&#xA;ggplot() +&#xA;  geom_point(data=nearestpoints_dt,aes(x=lon,y=lat,color=as.factor(cluster))) +&#xA;  geom_polygon(data = hulls,aes(x=lon, y=lat, fill=as.factor(cluster),alpha = 0.5))+&#xA;  theme_bw()+&#xA;  coord_equal()+&#xA;  theme_bw()+&#xA;  theme(legend.position = 'none')+&#xA;  ggtitle('Clusters')&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n91H4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n91H4.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;It is not the best one but it doesn't look very bad too. But when I try to cluster it for a larger real-life dataset, everything goes for a toss.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5JuO7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5JuO7.png&quot; alt=&quot;Clustering on large data&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, I understand there would be some kind of overlapping because the solution isn't optimum but how can the points be so spread like this? I can't figure this one out! What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="5532" LastEditorUserId="491" LastEditDate="2021-12-02T04:53:05.337" LastActivityDate="2021-12-02T04:53:05.337" Title="Optimizing a capacitated clustering problem with Greedy search algorithm" Tags="|optimization|heuristics|r|clustering|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6773" PostTypeId="1" AcceptedAnswerId="6775" CreationDate="2021-08-18T07:43:19.553" Score="5" ViewCount="332" Body="&lt;p&gt;Is it possible/likely for a mixed integer linear solver (CBC in my case) to incorrectly state that a problem is infeasible when in fact it is actually feasible?&lt;/p&gt;&#xA;&lt;p&gt;Are there properties of the model that could exacerbate this? For example, large numbers.&lt;/p&gt;&#xA;&lt;p&gt;I'm asking because I'm solving a number of very similar models and some of them are being flagged as infeasible when I don't think they are.&lt;/p&gt;&#xA;" OwnerUserId="4770" LastActivityDate="2021-08-24T12:36:31.437" Title="Infeasibility False Positive" Tags="|mixed-integer-programming|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6775" PostTypeId="2" ParentId="6773" CreationDate="2021-08-18T12:42:49.657" Score="7" Body="&lt;p&gt;It is quite likely that this happens. Numerical difficulties (large and small numbers or a large range of numbers in the problem) can cause this, they can lead to the simplex algorithm failing to identify the feasibility of a node (often even the root node) correctly. If it is the root node before adding cuts that is infeasible, it can help to run IIS (I am not sure that is available for CBC/CLP).&lt;/p&gt;&#xA;&lt;p&gt;Sometimes presolve or cuts can lead to a problem being marked infeasible although it is not. If turning off presolver or cuts results in any solution being found this is typically a good indicator that the problem is indeed feasible and the default result is wrong (due to a bug somewhere or numerical issues).&lt;/p&gt;&#xA;&lt;p&gt;All that said, feasibility in a MILP solver is always &amp;quot;within tolerance&amp;quot;. Sometimes a problem can only be made feasible by slightly violating integrality, bounds or constraints. Then things get tricky. Feasible or infeasible is not always an easy decision.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2021-08-18T12:42:49.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6777" PostTypeId="1" AcceptedAnswerId="6778" CreationDate="2021-08-18T15:11:32.287" Score="5" ViewCount="186" Body="&lt;p&gt;If the objective function of a problem contains a comparison between two linear statements, can the problem still be defined as an Integer Linear Program? For example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{max} \sum_{\forall i,j} x_{i,j} - (y_{i,j}\cdot A_{i,j} \ge B_{i,j})$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; are binary variables, and &lt;span class=&quot;math-container&quot;&gt;$A_{i,j}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_{i,j}$&lt;/span&gt; are constants.&lt;/p&gt;&#xA;&lt;p&gt;Note: The value of &lt;span class=&quot;math-container&quot;&gt;$(y_{i,j}\cdot A_{i,j} \ge B_{i,j})$&lt;/span&gt; should be 1 if it evaluates to true, 0 otherwise.&lt;/p&gt;&#xA;" OwnerUserId="6075" LastEditorUserId="6075" LastEditDate="2021-08-18T16:13:48.610" LastActivityDate="2021-08-18T16:13:48.610" Title="Use of comparisons in objective function of an ILP" Tags="|modeling|integer-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6778" PostTypeId="2" ParentId="6777" CreationDate="2021-08-18T15:41:21.817" Score="5" Body="&lt;p&gt;You would have to introduce a helper variable (say &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt;) to count:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{max }&amp;amp; \sum_{\forall i,j} x_{i,j} - z_{ij} &amp;amp;\\&#xA;\text{s.t. }&amp;amp; A_{i,j} y_{i,j} \leq B_{i,j} + Mz_{ij}&amp;amp;\forall i,j\\&#xA;&amp;amp;z_{ij}\in \{0,1\} &amp;amp;\forall i,j&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a sufficiently large number.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2021-08-18T16:07:10.627" LastActivityDate="2021-08-18T16:07:10.627" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6779" PostTypeId="1" CreationDate="2021-08-18T17:17:19.223" Score="6" ViewCount="92" Body="&lt;p&gt;In the sense of the calculation of the expected value of objective functions, we have two choices to evaluate the value; 1. Sample Average Approximation (SAA):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\frac{1}{N}\sum_{i=1}^N f(x,\xi^i).&#xA;$$&lt;/span&gt;&#xA;2. Numerical Integration (e.g., Monte Carlo method):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\frac{1}{N} \sum_{\xi^i\in\Xi^N}^N f(x,\xi^i)p(\xi^i),&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$p(\cdot)$&lt;/span&gt; is a probability density function and &lt;span class=&quot;math-container&quot;&gt;$\Xi^N\subset\Xi$&lt;/span&gt; is the approximation of the support &lt;span class=&quot;math-container&quot;&gt;$\Xi$&lt;/span&gt; of the probability function.&lt;/p&gt;&#xA;&lt;p&gt;The value of SAA converges to the true expectation, which is &lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[f(x,\xi)]$&lt;/span&gt;, as &lt;span class=&quot;math-container&quot;&gt;$N\to\infty$&lt;/span&gt; as well as the Numerical Integration though it is known as the law of large numbers. However, from the numerical viewpoints in general, what is the difference between these two methods?&lt;/p&gt;&#xA;&lt;p&gt;I want to know in the stochastic optimization or the expected residual minimization in the sense of the least squared mean for a system of equations, how is the difference such as convergence rate?&lt;/p&gt;&#xA;" OwnerUserId="5821" LastEditorUserId="5821" LastEditDate="2021-08-18T18:40:01.113" LastActivityDate="2021-08-18T18:40:01.113" Title="Sample Average Approximation vs. Numerical Integration" Tags="|computational-complexity|stochastic-programming|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6780" PostTypeId="2" ParentId="6771" CreationDate="2021-08-18T18:24:10.967" Score="4" Body="&lt;p&gt;Yes, you can drop the big-M constraints and the binary variables, &lt;em&gt;if&lt;/em&gt; there are no other constraints involving &lt;span class=&quot;math-container&quot;&gt;$\sf varWaterIn$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sf varWaterOut$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that if you take any optimal solution and increase both &lt;span class=&quot;math-container&quot;&gt;$\sf varWaterIn_h$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sf varWaterOut_h$&lt;/span&gt; by the same amount, you get another optimal solution (the costs offset each other and the input-output balance is maintained). Similarly, if you have an optimal solution where both variables are positive and you decrease both by the same amount (preserving nonnegativity), you get another optimal solution. What that tells us is that, for the single-constraint model, a solution both buying and selling at the same time is not an extreme point of the feasible region. Since the simplex method (or the barrier method with crossover) only finds extreme point solutions, you can be confident the solution will not both buy and sell simultaneously.&lt;/p&gt;&#xA;&lt;p&gt;That said, if there are other constraints involving the variables, then we no longer know that bumping both variables in a period up or down by the same amount yields a feasible solution. So you would need to confirm that by additional analysis.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="123" LastEditDate="2021-08-19T07:12:05.747" LastActivityDate="2021-08-19T07:12:05.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6781" PostTypeId="2" ParentId="6772" CreationDate="2021-08-18T18:57:56.347" Score="4" Body="&lt;p&gt;Your distance constraint for each cluster limits the sum of the distance from each cluster point to its nearest neighbor (excluding the last point selected for the cluster, whose nearest neighbor is not taken). It does not look at the total distance between all pairs of points in the cluster, nor the maximum distance between any pair of points (the cluster &amp;quot;diameter&amp;quot;). So a large set of points with low individual demand and short distances to their nearest neighbors can end up in a cluster, and they can wander quite far. Picture, for instance, four points arrayed as the corners of a square, each side of the square exactly &lt;code&gt;distance_constraint / 4&lt;/code&gt; from the next and all with low demand. They could form a cluster. (In fact, they side length could be &lt;code&gt;distance_constraint / 3&lt;/code&gt;, since only three of the segments count toward the distance constraint.)&lt;/p&gt;&#xA;&lt;p&gt;So if you want more compact clusters, you might want to switch you method of limiting distance to something like cluster diameter.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-18T18:57:56.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6782" PostTypeId="1" AcceptedAnswerId="6784" CreationDate="2021-08-18T23:46:38.787" Score="2" ViewCount="410" Body="&lt;p&gt;&lt;sub&gt; &lt;a href=&quot;https://math.stackexchange.com/q/4227782/471884&quot;&gt;Cross-posted on Mathematics SE.&lt;/a&gt; &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since I have to implement an algorithm in the language of linear algebra, I'm trying to understand K-Truss Graphs which are defined as such&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The k-truss is a subset of the graph with the&#xA;same number of vertices, where each edge appears in at&#xA;least &lt;span class=&quot;math-container&quot;&gt;$ − 2$&lt;/span&gt; triangles in the original graph.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Given this example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wZSGq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wZSGq.png&quot; alt=&quot;Example&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;-Truss should be &lt;span class=&quot;math-container&quot;&gt;$2-1-4$&lt;/span&gt; since we want edges present in at least &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; triangles of the original graph:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;edge &lt;span class=&quot;math-container&quot;&gt;$1-2$&lt;/span&gt; is present in triangle &lt;span class=&quot;math-container&quot;&gt;$0-1-2$&lt;/span&gt; and triangle &lt;span class=&quot;math-container&quot;&gt;$1-2-4.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;edge &lt;span class=&quot;math-container&quot;&gt;$1-4$&lt;/span&gt; is present in triangle &lt;span class=&quot;math-container&quot;&gt;$1-3-4$&lt;/span&gt; and triangle &lt;span class=&quot;math-container&quot;&gt;$1-2-4.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Is the solution given on my example correct?&lt;/p&gt;&#xA;" OwnerUserId="6078" LastEditorUserId="123" LastEditDate="2021-08-19T14:44:43.093" LastActivityDate="2021-08-19T20:09:02.160" Title="Can't understand K-Truss Graph properties" Tags="|graphs|linear-algebra|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6783" PostTypeId="2" ParentId="6772" CreationDate="2021-08-19T11:50:53.983" Score="-3" Body="&lt;p&gt;You're working without a framework in place but algorithms never help create a framework (R) algorithms never help create a framework. That requires sound knowledge of Graph Theory (Logical Topologies) and Combinatorics. Near-Node Selection will also fail mainly because it goes by Physical Topology.&lt;/p&gt;&#xA;&lt;p&gt;So, this problem is real but the applied solutions aren't. And as long as they're conventional they will always have insurmountable limits.&lt;/p&gt;&#xA;" OwnerUserId="6065" LastEditorUserId="6065" LastEditDate="2021-08-20T17:07:34.760" LastActivityDate="2021-08-20T17:07:34.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6784" PostTypeId="2" ParentId="6782" CreationDate="2021-08-19T19:42:43.717" Score="3" Body="&lt;p&gt;The definition of a k-truss you are working with seems to deviate from the 'standard' definition. See below for a few different definitions that boil down to the same thing.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A k-truss of a graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; is the largest subgraph of &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; such that each&#xA;edge is contained in at least &lt;span class=&quot;math-container&quot;&gt;$k−2$&lt;/span&gt; triangles in this subgraph.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;source: &lt;a href=&quot;https://doi.org/10.1007/s41019-018-0068-2&quot; rel=&quot;nofollow noreferrer&quot;&gt;Li, Z., Lu, Y., Zhang, WP. et al. Discovering Hierarchical Subgraphs of K-Core-Truss. Data Sci. Eng. 3, 136–149 (2018)&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A k-truss is an inclusion-maximal subgraph &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; in which each edge&#xA;belongs to at least &lt;span class=&quot;math-container&quot;&gt;$k - 2$&lt;/span&gt; triangles inside &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;source: &lt;a href=&quot;https://doi.org/10.1109/ACCESS.2020.3011667&quot; rel=&quot;nofollow noreferrer&quot;&gt;A. Conte, D. De Sensi, R. Grossi, A. Marino and L. Versari, &amp;quot;Truly Scalable K-Truss and Max-Truss Algorithms for Community Detection in Graphs,&amp;quot; in IEEE Access, vol. 8, pp. 139096-139109, 2020&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As I stated in the comments earlier, the subgraph induced by vertex set &lt;span class=&quot;math-container&quot;&gt;$\{2,1,4\}$&lt;/span&gt; is not a 4-truss because that would require that every edge in your induced subgraph, is contained in 2 different triangles which must also be contained in the subgraph. In your case, edge &lt;span class=&quot;math-container&quot;&gt;$(1,2)$&lt;/span&gt; is only contained in 1 triangle.&lt;/p&gt;&#xA;&lt;p&gt;Following the above definitions, the subgraph induced by vertex set &lt;span class=&quot;math-container&quot;&gt;$\{2,1,4\}$&lt;/span&gt; is not a 3-truss either, because it is not maximal. A 3-truss of your graph, would be the entire graph, since that is the largest subgraph in which every edge is part of at least 1 triangle in your subgraph.&lt;/p&gt;&#xA;&lt;p&gt;Your graph does not contain a k-truss with &lt;span class=&quot;math-container&quot;&gt;$k\geq 4$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Edit: as often in mathematics, there are inconsistencies in definitions. The definitions I cited above, explicitly require a k-truss to be the largest subgraph or an inclusion-maximal subgraph &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; s.t. every edge in &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; is covered by at least &lt;span class=&quot;math-container&quot;&gt;$k-2$&lt;/span&gt; triangles in &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;. Note that there's a difference between largest (read: maximum) and maximal subgraph. Moreover, some works seem to drop this 'maximal' requirement and refer to a k-truss as any (not necessarily maximal) subgraph &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; s.t. every edge in &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; is covered by at least &lt;span class=&quot;math-container&quot;&gt;$k-2$&lt;/span&gt; triangles in &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;, see e.g.: &lt;a href=&quot;https://louridas.github.io/rwa/assignments/finding-trusses/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://louridas.github.io/rwa/assignments/finding-trusses/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2021-08-19T20:09:02.160" LastActivityDate="2021-08-19T20:09:02.160" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6785" PostTypeId="1" CreationDate="2021-08-19T22:15:41.997" Score="6" ViewCount="377" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$0\le x \le 1$&lt;/span&gt; is a decision variable and &lt;span class=&quot;math-container&quot;&gt;$\gamma(x)$&lt;/span&gt; is defined as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\gamma(x)= \begin{cases}&#xA;\theta &amp;amp; x&amp;gt;0\\&#xA;0 &amp;amp; x=0&#xA;\end{cases}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$0\le \theta\le 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In my model, I have both &lt;span class=&quot;math-container&quot;&gt;$\gamma(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x \gamma(x)$&lt;/span&gt; and I want to convert them to linear programs. I used the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\Gamma&amp;amp;\ge \theta x - (1- y )&#xA;\\&#xA;\Gamma&amp;amp;\le y&#xA;\\&#xA;\gamma&amp;amp;=\theta y&#xA;\\&#xA;y &amp;amp;\ge x&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, the problem is that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; can take value 0 and then, &lt;span class=&quot;math-container&quot;&gt;$\gamma = \theta$&lt;/span&gt; at the same time. I can add the constraint &lt;span class=&quot;math-container&quot;&gt;$y \le 10000 x$&lt;/span&gt;, but it is will exclude some parts of the solution space.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="123" LastEditDate="2021-08-20T06:43:21.307" LastActivityDate="2021-08-20T12:26:32.223" Title="How to model this expression?" Tags="|linear-programming|linearization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6786" PostTypeId="2" ParentId="6785" CreationDate="2021-08-19T23:50:14.860" Score="4" Body="&lt;p&gt;There is no perfect fix for this, since strict inequalities are not supported in MILP models. So you will have to either live with the ambiguity when &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; or exclude a portion of the solution space.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-19T23:50:14.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6787" PostTypeId="2" ParentId="6785" CreationDate="2021-08-19T23:53:46.273" Score="8" Body="&lt;p&gt;You need a tolerance &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt;, and you can strengthen your first two inequality constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\Gamma &amp;amp;= \theta x \\&#xA;\gamma &amp;amp;= \theta y \\&#xA;\epsilon y \le x &amp;amp;\le y&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-08-20T12:26:32.223" LastActivityDate="2021-08-20T12:26:32.223" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6788" PostTypeId="1" CreationDate="2021-08-20T14:40:35.950" Score="9" ViewCount="209" Body="&lt;p&gt;INTRODUCTION&lt;/p&gt;&#xA;&lt;p&gt;My research often involves solving &lt;strong&gt;MINLP problems&lt;/strong&gt; with &lt;strong&gt;few constraints&lt;/strong&gt; (usually two) and &lt;strong&gt;not many variables&lt;/strong&gt; (say between one and three integer ones, and between one and five real-valued ones).&lt;/p&gt;&#xA;&lt;p&gt;The bottlenecks of these problems are the calculation of the objective function and the constraints: they are smooth functions but are quite complex, usually including integrals and cumulative distribution functions (CDF) of continuous random variables (NB: I am not saying that I deal with stochastic problems, but just with problems that involve probability calculations). Occasionally, I have to deal also with calculations involving sparse matrices.&lt;/p&gt;&#xA;&lt;p&gt;Sometimes, explicit expressions for the gradient of the objective function can be obtained, but not always. Most of the times, the functions in the problem are not convex, strictly speaking, but they happen to be monotonous or convex or unimodal for some of the continuous variables involved (assuming that the rest of variables are fixed).&lt;/p&gt;&#xA;&lt;p&gt;My typical approach here is performing a sort of enumerative search on the integer variables, and, for each combination of the integer variables, solving the (resulting NLP) problem to optimality for the real-valued variables.&lt;/p&gt;&#xA;&lt;p&gt;I do this because I found that, sometimes, MINLP solvers get stuck in local optima or even have problems to find a feasible solution. That is why I prefer to handle the integer part of the problem myself by fixing the integer variables and then using NLP solvers for the continuous part.&lt;/p&gt;&#xA;&lt;p&gt;Besides, sometimes, as a result of the mathematical study of the behaviour of the specific functions of my problems, I am able to deduce an ad-hoc solving strategy for the NLP part (I mean, once the integer variables are fixed).&lt;/p&gt;&#xA;&lt;p&gt;An additional, general problem is that, sometimes, the calculation of the functions involved is heavily time-consuming.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;MY QUESTION&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In short, my problem is that I still have not found the right software environment or setting to solve my optimisation problems. The best software to deal with integrals, CDFs or sparse matrices (for instance: Mathematica, Matlab, Scilab...) is not the software providing the best MINLP/NLP algorithms (for instance: GAMS...).&lt;/p&gt;&#xA;&lt;p&gt;I was recently using Matlab for some problems, and it is really great, but the functions I was dealing with were really time-consuming, and therefore every optimisation strategy took too long.&lt;/p&gt;&#xA;&lt;p&gt;I am tempted to go back to C++, since it is faster, and it can handle complex calculations via the GNU Scientific Library  (GSL), for instance. But I do not know whether there are good implementations of MINLP/NLP solvers in C++.&lt;/p&gt;&#xA;&lt;p&gt;I could also consider the possibility of using heuristic algorithms, but I actually think that my problems are not purely combinatorial ones (since they do not have hundreds of (integer) variables and constraints), and that it is worth trying to solve them to optimality in an exact way.&lt;/p&gt;&#xA;&lt;p&gt;I have not studied other possibilities, such as calling precompiled C++ routines from another solving software.&lt;/p&gt;&#xA;&lt;p&gt;So, &lt;strong&gt;what software setting would you suggest for dealing with this kind of problems?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4644" LastEditorUserId="491" LastEditDate="2021-08-20T19:11:05.787" LastActivityDate="2021-08-20T20:38:09.290" Title="MINLP involving integrals, sparse matrices and CDF of random variables. Best environment?" Tags="|nonlinear-programming|software|branch-and-bound|minlp|constrained-optimization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6789" PostTypeId="2" ParentId="6788" CreationDate="2021-08-20T15:27:17.277" Score="4" Body="&lt;p&gt;So it seems your strategy (enumerative search on the integer variables) works well, and the issue is solving pure NLP problems. The choice of programming/modeling language you use is dependent on what type of NLPs you solve and that whether you rely on the existing solvers or would be willing to implement your own algorithms.&lt;/p&gt;&#xA;&lt;p&gt;In any case, it is likely that you find Python a good choice, if not the best, for various reasons. There are many libraries/solver APIs available that make your life easier. Some of these solvers have been mentioned &lt;a href=&quot;https://scicomp.stackexchange.com/questions/83/is-there-a-high-quality-nonlinear-programming-solver-for-python&quot;&gt;here&lt;/a&gt;. Even if you are going to develop your own algorithm, you could use packages such as &lt;a href=&quot;https://numpy.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Numpy&lt;/a&gt; for the heavy numerical parts. Note that some solvers already exist in &lt;a href=&quot;https://docs.scipy.org/doc/scipy/reference/optimize.nonlin.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Scipy&lt;/a&gt;. You may also use the well-known solvers CPLEX and GUROBI if they can handle the type of NLP you have. Even if not, you may still successfully employ them as part of your algorithms.&lt;/p&gt;&#xA;&lt;p&gt;In the worst case, you have the option to &lt;a href=&quot;https://docs.python.org/3/extending/extending.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;write your algorithms in C/C++ and call them from within Python&lt;/a&gt;. Python also gives you access to rich statistical, machine learning and visualization libraries that you might find useful in developing and/or analyzing your algorithms. Another important advantage of Python is that it is free (unlike, say, MATLAB).&lt;/p&gt;&#xA;" OwnerUserId="1202" LastActivityDate="2021-08-20T15:27:17.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6790" PostTypeId="2" ParentId="6788" CreationDate="2021-08-20T20:38:09.290" Score="5" Body="&lt;p&gt;I suggest you have a look at &lt;a href=&quot;https://www.localsolver.com&quot; rel=&quot;noreferrer&quot;&gt;LocalSolver&lt;/a&gt; to solve your problem. It is free for basic research and teaching.&lt;/p&gt;&#xA;&lt;p&gt;Contrarily to its name suggests, LocalSolver is a global optimization solver. It handles MINLPs. LocaLSolver uses diversification techniques to avoid getting stuck into local optima. Moreover, it allows plugging to your optimization model some external functions. These functions, for example, simulators, can be used in constraints and/or objectives. At last, LocalSolver automatically handles a time-consuming objective function by using surrogate modeling techniques.&lt;/p&gt;&#xA;&lt;p&gt;In your case, since the complexity is in the definition of the objective function, I suggest you write a function in C++ (it seems that you prefer developing in C++) that evaluates the objective given in input the values of the few decisions you have to take. Then, you model the problem analytically, defining decision variables and the two constraints. You use your C++ function as the objective function by calling it as an &lt;a href=&quot;https://www.localsolver.com/docs/last/modelingfeatures/externalfunctions.html&quot; rel=&quot;noreferrer&quot;&gt;external function&lt;/a&gt; in your LocalSolver model.&lt;/p&gt;&#xA;&lt;p&gt;If the evaluation of the C++ function takes too much time (typically, several minutes per call), maybe using surrogate modeling can be beneficial. For this, you will have to change the call to an external function into the call to a so-called &lt;a href=&quot;https://www.localsolver.com/docs/last/modelingfeatures/blackbox.html&quot; rel=&quot;noreferrer&quot;&gt;black-box function&lt;/a&gt;. Having transformed it into a black-box function, you can define a budget of calls to the time-consuming objective function. For example, you can ask to LocalSolver to call the function at most 100 times. If each call lasts 1 minute, then the overall running time will be 100 minutes approximately. Since your model involves less than 10 variables, it should work very well. Some ready-to-use C++ code examples are given in our &lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/index.html#black-box&quot; rel=&quot;noreferrer&quot;&gt;Example Tour&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you encounter any trouble, please feel free to ask support to contact@localsolver.com. The team will be glad to help you. Your problem is very interesting.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Disclaimer: LocalSolver is a commercial optimization solver; nevertheless, it can be used for free for basic research and teaching.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-08-20T20:38:09.290" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6791" PostTypeId="1" AcceptedAnswerId="6793" CreationDate="2021-08-21T19:16:50.063" Score="4" ViewCount="169" Body="&lt;p&gt;How to solve the following minimax problem quickly? The variables are all continuous.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x_{1}, x_{4}, x_{5}} \min_{x_2,x_3} \vec{c}^{\intercal} \vec{x}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A\vec{x} \ge \vec{b}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\vec{x} \ge 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$A = &#xA;\begin{bmatrix}&#xA;    1  &amp;amp;  0 &amp;amp;  0 &amp;amp;  0 &amp;amp;  0 \\&#xA;    -1 &amp;amp;  0 &amp;amp;  0 &amp;amp;  0 &amp;amp;  0 \\&#xA;    0  &amp;amp;  1 &amp;amp;  1 &amp;amp;  0 &amp;amp;  0 \\&#xA;    0  &amp;amp; -1 &amp;amp; -1 &amp;amp;  0 &amp;amp;  0 \\&#xA;    0  &amp;amp;  -1 &amp;amp;  0 &amp;amp;  0.4 &amp;amp;  0 \\&#xA;    0  &amp;amp;  0 &amp;amp;  -1 &amp;amp;  0 &amp;amp;  0.4 \\&#xA;    1  &amp;amp;  0 &amp;amp;  0 &amp;amp;  -1 &amp;amp;  -1 \\&#xA;    0  &amp;amp; -0.6 &amp;amp;  0 &amp;amp;  1 &amp;amp;  0 \\&#xA;    0  &amp;amp;  0 &amp;amp; -0.6 &amp;amp;  0 &amp;amp;  1&#xA;\end{bmatrix}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\vec{b}^{\intercal} = &#xA;\begin{bmatrix}&#xA;1 &amp;amp; -1 &amp;amp; 2 &amp;amp; -2 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 0.6 &amp;amp; 0.6&#xA;\end{bmatrix}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\vec{c}^{\intercal} = &#xA;\begin{bmatrix}&#xA;1 &amp;amp; -0.6 &amp;amp; -0.6 &amp;amp; 0 &amp;amp; 0&#xA;\end{bmatrix}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I tried to split the variables into two groups &lt;span class=&quot;math-container&quot;&gt;$x_1, x_4, x_5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2, x_3$&lt;/span&gt;. And replace the inner minimization by its dual, which is a maximization. But that makes the objective function quadratic instead of linear:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA; \max_{x_1, x_4, x_5} \left( \max_{x_2, x_3}  &#xA;\vec{b}^{\intercal} \vec{y} - \vec{x}^{\intercal}A_{1,4,5}^{\intercal} \vec{y}&#xA; \right)$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A_{1,4,5}$&lt;/span&gt; is same as &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; except columns 2 and 3 are all zeros.&lt;/p&gt;&#xA;" OwnerUserId="5705" LastActivityDate="2021-08-22T10:03:41.243" Title="Continuous minimax with linear objective and constraints" Tags="|optimization|quadratic-programming|minimax|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6793" PostTypeId="2" ParentId="6791" CreationDate="2021-08-22T09:33:16.153" Score="4" Body="&lt;p&gt;The problem is infeasible:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(c_1,c_2) \Rightarrow x_1=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(c_3,c_4) \Rightarrow x_2+x_3=2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(c_1,c_2,c_7) \Rightarrow x_4 + x_5 \le 2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(c_5,c_6) \Rightarrow -(x_2+x_3)+0.4(x_4+x_5) \ge 2 \text{ and so } (c_3,c_4,c_5,c_6)\Rightarrow x_4 + x_5 \ge 10$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The last two lines are not consistent. Note that we also obtain a conflict with &lt;span class=&quot;math-container&quot;&gt;$(c_8,c_9)$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(c_8,c_9) \Rightarrow -0.6(x_2+x_3)+(x_4+x_5) \ge 1.2 \text{ and so } (c_3,c_4,c_8,c_9)\Rightarrow x_4 + x_5 \ge 2.4$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="1202" LastEditorUserId="1202" LastEditDate="2021-08-22T10:03:41.243" LastActivityDate="2021-08-22T10:03:41.243" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6794" PostTypeId="2" ParentId="6605" CreationDate="2021-08-23T05:43:41.837" Score="9" Body="&lt;p&gt;I feel like you should ask the question other way round: &amp;quot;Which industries are not employing substantial use of OR technologies to optimize their operations?&amp;quot;. That would be much easier to answer.&lt;/p&gt;&#xA;&lt;p&gt;Having spent the last 3 years of actively using OR and optimization technologies in my career at a huge multinational Oil and Gas company, I can't emphasize it enough how much are typical day to day operations missing out on value savings just by not fully operating in an optimized manner. This occurs at every scale of operations management i.e. right from planning to execution. I sometimes feel like companies and managers (luckily not mine!) are somehow not fully aware or appreciative of huge potential that OR offers for driving optimal operations. If you compare it with the investments in ML and AI in the industries (largely because of their current popularity), we only get peanuts. But I hope things might change in the future as more and more people begin to see that very goal of OR is directly at providing value to the business.&lt;/p&gt;&#xA;&lt;p&gt;With that all said, there are a few industries that I can name where I see OR  being their main game: supply chain industry, transportation industry, aviation industry.&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="113" LastEditDate="2021-08-23T06:25:21.023" LastActivityDate="2021-08-23T06:25:21.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6795" PostTypeId="1" AcceptedAnswerId="6797" CreationDate="2021-08-23T08:41:25.563" Score="21" ViewCount="3485" Body="&lt;p&gt;Recently, I came across the below paper and found it very interesting.&lt;/p&gt;&#xA;&lt;p&gt;Solving Mixed Integer Programs Using Neural Networks; &lt;a href=&quot;https://arxiv.org/abs/2012.13349&quot; rel=&quot;noreferrer&quot;&gt;https://arxiv.org/abs/2012.13349&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The idea is to use (train with neural network models) similar problem instances to help the solver finding better incumbent solutions and branching strategies during branch-and-bound.&lt;/p&gt;&#xA;&lt;p&gt;Has anyone tested this approach on a real world business problem? Is it practical or even worth to invest?&lt;/p&gt;&#xA;&lt;p&gt;I have some doubts; SCIP is chosen as the base solver and they compare their results with tuned SCIP solver. However, to my experience, SCIP is a much slower solver than commercial solvers like Cplex, Gurobi. I understand the reason why they choose to use SCIP as the base solver as explained in the paper. However, I am still looking for an answer for the below question:&lt;/p&gt;&#xA;&lt;p&gt;Can this approach will improve the solution time of Cplex solver as much as it does for SCIP solver? Because, SCIP is a much slower solver than Cplex and has more parts to be improved. Would it worth to use such an approach for Cplex?&lt;/p&gt;&#xA;" OwnerUserId="3630" LastEditorUserId="2556" LastEditDate="2021-08-23T15:08:54.273" LastActivityDate="2021-08-29T15:44:29.773" Title="Using Neural Networks For Solving Optimization Problems" Tags="|mixed-integer-programming|cplex|machine-learning|scip|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6796" PostTypeId="2" ParentId="6795" CreationDate="2021-08-23T09:01:50.870" Score="13" Body="&lt;p&gt;SCIP is not slow. SCIP's code is roughly as fast as the commercial alternatives. What makes SCIP seem slower to the user is that, by comparison, the commercial solver heuristics (cuts, primal heuristics, branching, tuning) are superior.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, that paper actually makes a very sound comparison: &amp;quot;What if we had a machine figure out the heuristics instead of humans?&amp;quot;. Specifically they did this for primal heuristics (Neural Diving) and branching (Neural Branching).&lt;/p&gt;&#xA;&lt;p&gt;The result was matching GUROBI/CPLEX &lt;strong&gt;with SCIP&lt;/strong&gt; and even solving open problems. Not too shabby.&lt;/p&gt;&#xA;&lt;p&gt;Application-wise people have been trying to do this for ages with little success. It seems like Deepmind might have been the first to crack the problem, so we could start seeing applications in the next year or two.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-08-23T09:01:50.870" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6797" PostTypeId="2" ParentId="6795" CreationDate="2021-08-23T09:38:40.140" Score="21" Body="&lt;p&gt;Regarding the paper, it's important to remember that general purpose MIP solvers are meant to be general purpose, hence it's not surprising that they can be improved by tailoring them to the test set, either using ML or some other form of automatic tuning. MIP solvers make many decisions while solving a problem and I guess it's quite natural to assume that machine learning can help designing better algorithms to make these decisions. To the best of my knowledge, state-of-the-art solvers don't use trained neural networks inside for anything yet. There is no lack of trying, I guess, considering how hot the topic is.&lt;/p&gt;&#xA;&lt;p&gt;That does not mean that ML is not used to tune solvers. Decision trees come to mind as a technology that can be used to tune aspects of MILP solvers to deliver good default performance.&lt;/p&gt;&#xA;&lt;p&gt;A key problem for ML in MIP is the lack of large enough test sets that are actually representative. This is already a problem when benchmarking, but gets worse if you want to train things like a neural net.&lt;/p&gt;&#xA;&lt;p&gt;There is currently a competition ongoing (ML4CO, see link below) that encourages to solve optimization problems using ML/AI, the results of which might give some insight into how ML can be used in MIP solvers:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ecole.ai/2021/ml4co-competition/&quot; rel=&quot;noreferrer&quot;&gt;https://www.ecole.ai/2021/ml4co-competition/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2021-08-23T09:38:40.140" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6799" PostTypeId="2" ParentId="6773" CreationDate="2021-08-24T03:29:50.213" Score="2" Body="&lt;p&gt;Yes, solvers can sometimes render infeasibility even when you expect feasible solutions to exist. This is despite dependent on the nature of the problem is  in general expected to be encountered not very often. There are a couple of likely reasons when this can happen:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Numerical Issue.&lt;/strong&gt; The solver was not able to bring the solution inside the feasible region within tolerances.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Bad Starting Point.&lt;/strong&gt; Your starting point is not carefully chosen and the solver terminates within an infeasible solution regime.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="113" LastActivityDate="2021-08-24T03:29:50.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6800" PostTypeId="2" ParentId="6605" CreationDate="2021-08-24T05:25:15.327" Score="5" Body="&lt;p&gt;One industry which we see in our daily life that is under-optimized (mainly in developing &amp;amp; under-developed nations) is HealthCare where we see lot of OR based application. Paper[1] provided more details and survey of the same.&lt;/p&gt;&#xA;&lt;p&gt;Reference:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Bradley, B.D., Jung, T., Tandon-Verma, A. et al. Operations research in global health: a scoping review with a focus on the themes of health equity and impact. Health Res Policy Sys 15, 32 (2017). &lt;a href=&quot;https://doi.org/10.1186/s12961-017-0187-7&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1186/s12961-017-0187-7&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5880" LastEditorUserId="5880" LastEditDate="2021-08-24T05:42:04.050" LastActivityDate="2021-08-24T05:42:04.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6802" PostTypeId="2" ParentId="6765" CreationDate="2021-08-24T08:43:30.497" Score="-3" Body="&lt;p&gt;Can't speak on CP to model this but we have solved this by employing Graph Theory to model all the given constraints of yours and more on real data.&lt;/p&gt;&#xA;&lt;p&gt;Your constraints resemble the Hamiltonian Paths Problem and in our implementation we didn't have to go as far as employing CP, MIP or any solver because we understand the instance. The way I see it, it is a problem of managing multiple moving agents in a network. Since you asked, we used a basis function and developed a Graph Theory based solver in-house for this.&lt;/p&gt;&#xA;&lt;p&gt;The response time we are getting is exceptional, there is visible optimization and we are able to derive even the combinations to better utilize the fleet while following all the constraints one would like to apply. Hope it helped and gave you an alternative.&lt;/p&gt;&#xA;" OwnerUserId="6065" LastEditorUserId="6065" LastEditDate="2021-08-24T15:27:38.590" LastActivityDate="2021-08-24T15:27:38.590" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6803" PostTypeId="2" ParentId="6773" CreationDate="2021-08-24T12:36:31.437" Score="2" Body="&lt;p&gt;We observed the same problem when working with CPLEX. During Presolve, CPLEX somehow identifies the problem as infeasible. We couldn't figure out the actual reason, but it was the same problem (except some model parameters) we solve on daily basis.&lt;/p&gt;&#xA;&lt;p&gt;What was interesting is that disabling Presolve resolved the issue for that particular case and CPLEX could solve the problem.&lt;/p&gt;&#xA;" OwnerUserId="3630" LastActivityDate="2021-08-24T12:36:31.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6804" PostTypeId="1" AcceptedAnswerId="6816" CreationDate="2021-08-24T15:58:59.297" Score="4" ViewCount="557" Body="&lt;p&gt;I am modeling a big linear programming problem size with about 50,000 variables using &lt;a href=&quot;https://opensolver.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OpenSolver&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Open Solver starts setting up the problem at a constant pace of about 100 variables per second, which is quite good.&lt;/p&gt;&#xA;&lt;p&gt;However, after setting up about 24,000 variables, Open Solver suddenly changes this pace to about one variable per second.&lt;/p&gt;&#xA;&lt;p&gt;Any help or hint on this?&lt;/p&gt;&#xA;" OwnerUserId="62" LastActivityDate="2021-08-26T14:39:29.507" Title="Why does setting up a problem using Excel's OpenSolver slows down after 24,000 variables?" Tags="|linear-programming|solver|excel|open-source|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6805" PostTypeId="2" ParentId="6711" CreationDate="2021-08-24T16:39:27.330" Score="2" Body="&lt;p&gt;I have suggestions for your two recently added constraints.&lt;/p&gt;&#xA;&lt;p&gt;Your first one is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{board}(i_1,i_2,j_1,t,k) + \text{board}(i_1,i_2,j_2,t,k) \leq 1 + m[j_1][j_2]\\\forall i_1,i_2 \in V^2,  \forall j_1,j_2 \in J^2,  \forall  t \in T,  \forall k \in K \tag1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You do not need to impose &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$m[j_1][j_2] = 1$&lt;/span&gt; because it is redundant.  You can also restrict to &lt;span class=&quot;math-container&quot;&gt;$j_1 &amp;lt; j_2$&lt;/span&gt;.  When &lt;span class=&quot;math-container&quot;&gt;$m[j_1][j_2] = 0$&lt;/span&gt;, you might also consider generating these constraints dynamically only when they are violated.&lt;/p&gt;&#xA;&lt;p&gt;Your second one is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \text{board}(i_1,i_2,j,t,k) \leq \text{road}(i_1,i_2,t,k) \\&#xA;\forall i_1,i_2 \in V^2, \forall j \in J, \forall t \in T, \forall k \in K \tag2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; is already implied by your existing constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j\in J} \text{board}(i_1,i_2,j,t,k) \leq \text{road}(i_1,i_2,t,k) \\&#xA;\forall i_1,i_2 \in V^2, \forall t \in T, \forall k \in K$$&lt;/span&gt;&#xA;So you can omit &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-08-24T19:49:15.603" LastActivityDate="2021-08-24T19:49:15.603" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6806" PostTypeId="1" AcceptedAnswerId="6807" CreationDate="2021-08-24T17:26:05.710" Score="4" ViewCount="345" Body="&lt;p&gt;We are exporting a optimization problem from matrices to LP format using Cplex.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import cplex&#xA;&#xA;model = cplex.Cplex()&#xA;model.objective.set_sense(model.objective.sense.minimize)&#xA;model.objective.set_quadratic(Q_martix)&#xA;.&#xA;.&#xA;# similarly declare constraints &#xA;.&#xA;.&#xA;model.write('my_file.lp')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Questions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;After receiving the raw optimization problem (as matrices), does Cplex apply any transformations (or dumps the raw problem un-transformed)?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is Cplex's LP transformation code open-source, or available to view?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6106" LastEditorUserId="6106" LastEditDate="2021-08-25T07:08:31.973" LastActivityDate="2021-08-25T15:49:39.667" Title="Any transformation of constraints during Cplex's LP problem export?" Tags="|python|cplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6807" PostTypeId="2" ParentId="6806" CreationDate="2021-08-24T18:24:03.130" Score="6" Body="&lt;p&gt;If you export the model, then by default, Cplex will export your original, unaltered model. When you solve a model, Cplex will, by default, first invoke a presolve,during which it will attempt to simplify and tighten your model, e.g. by removing redundant constraints, solving for logical implications, etc. As per this &lt;a href=&quot;https://stackoverflow.com/questions/39223691/save-cplex-preprocessing-aggregation&quot;&gt;SO post&lt;/a&gt;, you can then also export the presolved model.&lt;/p&gt;&#xA;&lt;p&gt;Cplex is a closed source commercial solver; they don't have any open source code.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-08-24T18:24:03.130" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6808" PostTypeId="2" ParentId="6806" CreationDate="2021-08-24T20:03:42.960" Score="7" Body="&lt;p&gt;While it does not deliberately transform the problem before exporting it, using the LP file format means that double precision coefficients are being converted to character strings (and, in the process, truncated and/or rounded). So there will frequently be a little loss of precision, and sometimes that &amp;quot;little&amp;quot; loss of precision can turn into big adventures if the LP file is read back in (with another text/binary conversion) and solved. For that reason, when debugging a model it is almost always better to use the SAV file format.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-08-25T15:49:39.667" LastActivityDate="2021-08-25T15:49:39.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6809" PostTypeId="1" AcceptedAnswerId="6811" CreationDate="2021-08-25T11:06:22.843" Score="7" ViewCount="255" Body="&lt;p&gt;I'm given a problem in which I need to schedule multiple sequences. The goal is to minimize the makespan. I'm allowed to elongate all tasks, but I cannot reduce their width nor disconnect any of the tasks. Each of the tasks is indicated using a color. In the final schedule tasks of the same color cannot overlap.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/m2N8a.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/m2N8a.png&quot; alt=&quot;Example task illustration with colors&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the example above 2 sequences S1, S2 are shown with respectively 4 and 3 tasks in 3 different colors. In the example both tasks are scheduled to start at the same time but this results in 3 violations. These violations are indicated by an exclamation mark.&lt;/p&gt;&#xA;&lt;p&gt;The optimal solution for this example would be to elongate the green task of S1 and align them as seen in the optimal solution below.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/e5iFQ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/e5iFQ.png&quot; alt=&quot;Optimal Solution&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is this type of problem known and studied in literature? If so, under what name and what kind of algorithms are used to solve them? If not, what kind of algorithm would you suggest to use? I have +- 100 sequences and I am using 16 colors. Each sequence contains typically between 9 and 20 tasks.&lt;/p&gt;&#xA;&lt;p&gt;I found many problem types where disconnecting the tasks within a sequence is allowed, but not being able to disconnect changes the dynamics quite a bit.&lt;/p&gt;&#xA;" OwnerUserId="6110" LastEditorUserId="6110" LastEditDate="2021-08-25T13:18:00.823" LastActivityDate="2021-08-25T21:35:18.983" Title="What strategies to use for Scheduling of Connected Sequences?" Tags="|scheduling|algorithms|" AnswerCount="2" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="6810" PostTypeId="1" CreationDate="2021-08-25T16:00:02.980" Score="4" ViewCount="229" Body="&lt;p&gt;I am trying to efficiently solve the following optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max_{b \in \mathbb{R}_+^D}&amp;amp;\quad\sum_{n=1}^{N}\operatorname H(b^T w^{(n)} - c^{(n)}) \\\text{s.t.}&amp;amp;\quad\sum_{d=1}^D b_d \leq B,\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\operatorname H$&lt;/span&gt; is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Heaviside_step_function&quot; rel=&quot;nofollow noreferrer&quot;&gt;Heaviside step function&lt;/a&gt;, &lt;span class=&quot;math-container&quot;&gt;$b \in \mathbb{R}_+^D$&lt;/span&gt; is a real-valued vector with positive values, &lt;span class=&quot;math-container&quot;&gt;$\forall n \in \{1, \dots, N\} : w^{(n)} \in \mathbb{R}_+^D$&lt;/span&gt;, and the &lt;span class=&quot;math-container&quot;&gt;$c^{(n)}$&lt;/span&gt; are non-negative parameters.&lt;/p&gt;&#xA;&lt;p&gt;I am aware that this sort of problem can be solved via mixed-integer linear programming (see, for example, the discussion of a more general optimization problem involving step functions in &lt;a href=&quot;https://math.stackexchange.com/questions/16788/solution-technique-to-optimize-sets-of-constraint-functions-with-objective-functi/17001#17001&quot;&gt;this post&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Given the particularly simple form of this problem, I wonder:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there an efficient method for solving this problem that does not require optimization?&lt;/li&gt;&#xA;&lt;li&gt;If not: Do you know whether this problem has been discussed in literature / whether this problem has a particular name?&lt;/li&gt;&#xA;&lt;li&gt;If this is a well-studied problem: Is there some specialized solver that is more efficient than using a generic MILP solver (similar to how there are specialized solvers for flow problems)?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3948" LastEditorUserId="491" LastEditDate="2021-08-26T13:13:00.867" LastActivityDate="2021-08-26T13:13:00.867" Title="Maximizing sum of step functions under single linear constraint" Tags="|optimization|mixed-integer-programming|linear-programming|reference-request|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6811" PostTypeId="2" ParentId="6809" CreationDate="2021-08-25T19:31:36.190" Score="5" Body="&lt;p&gt;This is a blocking job shop scheduling problem.&lt;/p&gt;&#xA;&lt;p&gt;The description from &amp;quot;An iterated greedy metaheuristic for the blocking job shop scheduling problem&amp;quot; (Pranzo et Pacciarelli, 2016) &lt;a href=&quot;https://doi.org/10.1007/s10732-014-9279-5&quot; rel=&quot;noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In the job shop scheduling problem a set of jobs &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; must be processed&#xA;on a set of machines &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, each processing at most one job at a time.&#xA;The processing of a job on a machine is called an operation and cannot&#xA;be interrupted. We let &lt;span class=&quot;math-container&quot;&gt;$\{o_1, \dots , o_n \}$&lt;/span&gt; be the set of all&#xA;operations. The sequence of operations for each job is prescribed,&#xA;while the sequence of operations for each machine has to be determined&#xA;in such a way that the time needed to complete all operations, called&#xA;the makespan, is minimum. More formally, the scheduling problem&#xA;consists in assigning a starting time &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt; to operation &lt;span class=&quot;math-container&quot;&gt;$o_i$&lt;/span&gt; , &lt;span class=&quot;math-container&quot;&gt;$i =&#xA; 1, \dots, n$&lt;/span&gt;, such that: (i) precedence constraints between&#xA;consecutive operations of the same job are satisfied; (ii) each&#xA;machine hosts at most one job at a time; and (iii) the makespan is&#xA;minimized.&lt;/p&gt;&#xA;&lt;p&gt;In the blocking job shop scheduling problem no intermediate storage is&#xA;allowed between two consecutive machines. Hence, once a job completes&#xA;processing on machine &lt;span class=&quot;math-container&quot;&gt;$M_h$&lt;/span&gt; it either moves to the subsequent machine&#xA;&lt;span class=&quot;math-container&quot;&gt;$M_k$&lt;/span&gt; (if it is available) or it remains on &lt;span class=&quot;math-container&quot;&gt;$M_h$&lt;/span&gt;, thus blocking it&#xA;(if &lt;span class=&quot;math-container&quot;&gt;$M_k$&lt;/span&gt; is not available).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;From your examples, &amp;quot;sequences&amp;quot; become &amp;quot;jobs&amp;quot;, &amp;quot;tasks&amp;quot; become &amp;quot;operations&amp;quot;, and &amp;quot;colors&amp;quot; become &amp;quot;machines&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;The simplest and easiest way to get solutions is certainly to use a Constraint Programming solver.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2021-08-25T19:31:36.190" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="6812" PostTypeId="2" ParentId="6809" CreationDate="2021-08-25T19:31:49.343" Score="1" Body="&lt;p&gt;Your problem is reminiscent of the makespan minimization version of the Blocking Job Shop (BJS) problem. For a definition of the BJS problem, refer to [1]. If you consider each sequence as a job, and each color as a machine, then, it looks like the problem sizes that you are interested in are pretty large, and so local-search may be your best bet to compute good quality solutions. For local-search algorithms to solve the BJS problem efficiently, see the recent paper [2].&lt;/p&gt;&#xA;&lt;p&gt;[1] &amp;quot;Job-shop scheduling with blocking and no-wait constraints&amp;quot;, Alessandro Mascisa &amp;amp; Dario Pacciarelli, EJOR, 2002.&lt;/p&gt;&#xA;&lt;p&gt;[2] &amp;quot;Efficient primal heuristic updates for the blocking job shop problem&amp;quot;, JK Mogali, L Barbulescu, SF Smith, EJOR, 2021.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2021-08-25T21:35:18.983" LastActivityDate="2021-08-25T21:35:18.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6813" PostTypeId="2" ParentId="6810" CreationDate="2021-08-26T00:32:13.190" Score="2" Body="&lt;p&gt;&lt;em&gt;&lt;strong&gt;Dynamic Programming&lt;/strong&gt;&lt;/em&gt; is often a good method of choice for solving this class of problems. Chapter 3 of &lt;a href=&quot;https://www.sciencedirect.com/bookseries/mathematics-in-science-and-engineering/vol/130/suppl/C&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Art and Theory of Dynamic Programming&lt;/a&gt; refers to this class of problems as &lt;em&gt;Resource Allocation&lt;/em&gt; problems. There is one constraint restricting the amount of available resource, the parameter &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, with a linear or nonlinear objective function. An interesting feature of dynamic programming for such problems is that it can sometimes be used to find analytical or closed-form solutions for them.&lt;/p&gt;&#xA;&lt;p&gt;Dynamic programming is a very reasonable choice, but of course, we need to spend some time to understand the problem better (deriving some properties that allow for an efficient solution). Often we start with the basic case (&lt;span class=&quot;math-container&quot;&gt;$N=2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$D=2$&lt;/span&gt; or both) and then generalize the results to the more general case. Using &lt;em&gt;proof by induction&lt;/em&gt;, we might also be able to derive &lt;em&gt;policies&lt;/em&gt; that result in an efficient closed-form solution. An example of this approach with a nonlinear step (ceiling) function can be found &lt;a href=&quot;https://doi.org/10.1016/j.orl.2020.04.007&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. Another example is the &lt;em&gt;Discrete Budgeting Problem&lt;/em&gt; introduced in Section 2.1.2 of &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/book/10.1002/9781118029176&quot; rel=&quot;nofollow noreferrer&quot;&gt;Approximate Dynamic Programming&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1202" LastEditorUserId="1202" LastEditDate="2021-08-26T00:45:49.230" LastActivityDate="2021-08-26T00:45:49.230" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6814" PostTypeId="1" AcceptedAnswerId="6818" CreationDate="2021-08-26T13:57:17.203" Score="4" ViewCount="666" Body="&lt;p&gt;I recently started with Pyomo and I have the following Problem:&lt;/p&gt;&#xA;&lt;p&gt;I want to construct a ConstraintList with an if statement.&#xA;I already learned, that it's not possible. But the problem still exists...&#xA;My first code (with the if statement) was the following one:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.Constraint10=pyo.ConstraintList()&#xA;for i in m.Stunde:&#xA;  for j in m.Kraftwerk:&#xA;     if pyo.value(m.Kraftwerkseinsatz[i,j]) != 0:&#xA;        m.Constraint10.add(m.Kraftwerkseinsatz[i,j]&amp;gt;=m.MinOutput[j])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;m.Stunde&lt;/code&gt; and &lt;code&gt;m. Kraftwerk&lt;/code&gt; are indices.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;m.Kraftwerkseinsatz&lt;/code&gt; is a variable!&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;m.MinOutput&lt;/code&gt; is a parameter.&lt;/p&gt;&#xA;&lt;p&gt;In other words, my variable must be greater than the MinOutput parameter or zero (for every hour and every power plant).&lt;/p&gt;&#xA;&lt;p&gt;I already thought of reframing the constraint like this:&#xA;&lt;code&gt;m.Kraftwerkseinsatz[i,j]&lt;/code&gt; must not be between 0.1 and &lt;code&gt;m.MinOutput&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But I don't know how to code this either. Can anyone help me?&lt;/p&gt;&#xA;" OwnerUserId="6113" LastEditorUserId="6113" LastEditDate="2021-08-26T14:01:34.063" LastActivityDate="2021-08-28T03:10:55.887" Title="Constraintlist with two Options Pyomo" Tags="|optimization|constraint|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6815" PostTypeId="2" ParentId="4892" CreationDate="2021-08-26T14:07:42.413" Score="3" Body="&lt;p&gt;As you mentioned that you looked for python packages for RO before and didn't find any you might want to have a look at &lt;a href=&quot;https://xiongpengnus.github.io/rsome&quot; rel=&quot;nofollow noreferrer&quot;&gt;RSOME&lt;/a&gt;.&#xA;You can custom build uncertainty sets using affine constraints as well as 1, 2, and infinity norms.&#xA;For many of the uncertainty sets (if the reformulation is not linear) commercial solvers are needed.&#xA;I found that for big problems the reformulation within the package takes up some time which probably comes from the fact that it is entirely implemented in python.&lt;/p&gt;&#xA;&lt;p&gt;But it is really intuitive to use and allows to quickly build RO models without having to think about all the theory behind it.&#xA;And from what I see it is still actively maintained.&lt;/p&gt;&#xA;" OwnerUserId="4477" LastActivityDate="2021-08-26T14:07:42.413" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6816" PostTypeId="2" ParentId="6804" CreationDate="2021-08-26T14:39:29.507" Score="1" Body="&lt;p&gt;I managed to understand why the pace of building up the model using Open Solver slows down after a while.&lt;/p&gt;&#xA;&lt;p&gt;The reason is because there were several (in)equations without values, which was why model building was initially fast.&lt;/p&gt;&#xA;" OwnerUserId="62" LastActivityDate="2021-08-26T14:39:29.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6817" PostTypeId="1" CreationDate="2021-08-26T15:21:52.847" Score="2" ViewCount="81" Body="&lt;p&gt;Assume we are given MILP where &lt;span class=&quot;math-container&quot;&gt;$y \in (\mathbb{R}^+)^n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2 \in \{0, 1\}$&lt;/span&gt; are the integer variables. It is obvious that this problem when solved via branch and bound has a 2 deep b&amp;amp;b-tree.&lt;/p&gt;&#xA;&lt;p&gt;For the sake of notation let &lt;span class=&quot;math-container&quot;&gt;$\min_{(0,1),(0,1)}$&lt;/span&gt; be the minimum of relaxation at the root node and &lt;span class=&quot;math-container&quot;&gt;$\arg\min_{(0,1),(0,1)}$&lt;/span&gt; the corresponding minimizer (which assumed not be integer). &lt;span class=&quot;math-container&quot;&gt;$\min_{1,(0,1)}$&lt;/span&gt; would be the minimum of the relaxation at b&amp;amp;b tree node where &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; is set to 1 and no decision has been made about &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now to the question:&lt;/p&gt;&#xA;&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$\min_{(0,1),(0,1)}$&lt;/span&gt;,  &lt;span class=&quot;math-container&quot;&gt;$\arg\min_{(0,1),(0,1)}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\min_{0,(0,1)}$&lt;/span&gt;,  &lt;span class=&quot;math-container&quot;&gt;$\arg\min_{0,(0,1)}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\min_{1,(0,1)}$&lt;/span&gt;,  &lt;span class=&quot;math-container&quot;&gt;$\arg\min_{1,(0,1)}$&lt;/span&gt;  what does that tell me about &lt;span class=&quot;math-container&quot;&gt;$\min_{(0,1),0}$&lt;/span&gt;,  &lt;span class=&quot;math-container&quot;&gt;$\arg\min_{(0,1),0}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\min_{(0,1),1}$&lt;/span&gt; or  &lt;span class=&quot;math-container&quot;&gt;$\arg\min_{(0,1),1}$&lt;/span&gt; beside &lt;span class=&quot;math-container&quot;&gt;$\min_{(0,1),(0,1)} \leq \min_{(0,1),0}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\min_{(0,1),(0,1)} \leq \min_{(0,1),1}$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Or with a picture of directed acyclic graph that contains all search trees of this 2 level deep tree. Does having calculate the relaxations of all red encircled nodes tell me more about the possible values the yellow encircled nodes then the orange encircled root node tells me about the relaxation yellow encircled nodes&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AA7aY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AA7aY.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And if that tells me something useful:&lt;/p&gt;&#xA;&lt;p&gt;I have solved a MILP (of integer variables) and saved the search tree and nodes with their &lt;span class=&quot;math-container&quot;&gt;$\min$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\arg\min$&lt;/span&gt; and I want resolve the same MILP using different branching heuristics to compare such heuristics. Can I do better with saving calculation time then looking up whether I solved this node in the previous solve, if so use the cached results and if not calculate the relaxation normally?&lt;/p&gt;&#xA;&lt;p&gt;(It might be that even if nothing in general holds, under separability in the problem one might be able to infer the value of the relaxation at some B&amp;amp;B nodes. If you know of such results they are welcome too)&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-08-28T11:33:37.080" LastActivityDate="2021-08-28T11:33:37.080" Title="What if anything do linear relaxations of &quot;nearby&quot; MILP nodes tell us about other MILP nodes" Tags="|mixed-integer-programming|linear-programming|integer-programming|solver|branch-and-bound|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6818" PostTypeId="2" ParentId="6814" CreationDate="2021-08-26T15:24:55.803" Score="6" Body="&lt;p&gt;A variable that can assume values of zero or between some lower and upper bound is called a &lt;strong&gt;semi-continuous variable&lt;/strong&gt;. Most high-end solvers have direct support for this type of variable. If not supported, you can model this with an additional binary variable:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align} &amp;amp; \color{darkblue}L\cdot \color{darkred}\delta \le \color{darkred}x \le \color{darkblue}U \cdot \color{darkred}\delta \\&#xA;&amp;amp; \color{darkred}\delta \in \{0,1\} \\ &amp;amp;\color{darkred}x\in [0,\color{darkblue}U]\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;AFAIK, Pyomo has no direct support for semi-continuous variables. So the obvious approach is to use binary variables. An alternative would be to use Pyomo's Disjunctive Programming tools (&lt;a href=&quot;https://pyomo.readthedocs.io/en/latest/modeling_extensions/gdp/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;GDP&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Note: in the bounds for &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}x$&lt;/span&gt;, I assumed &lt;span class=&quot;math-container&quot;&gt;$\color{darkblue}L\gt 0$&lt;/span&gt;. We can make this more general by stating &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}x \in [\min(0,\color{darkblue}L),\max(0,\color{darkblue}U)]. $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2021-08-28T03:10:55.887" LastActivityDate="2021-08-28T03:10:55.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6819" PostTypeId="1" CreationDate="2021-08-27T10:41:21.200" Score="3" ViewCount="575" Body="&lt;pre&gt;&lt;code&gt;[   [0,5],&#xA;    [0,4],&#xA;    [1,6],&#xA;    [2,4],&#xA;    [3,6],&#xA;    [3,2],&#xA;    [4,5],&#xA;    [5,5],&#xA;    [6,4],&#xA;    [7,3],&#xA;    [8,2],&#xA;    [8,3],&#xA;    [9,5],&#xA;    [10,3]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Representation of Data is as Follows:&#xA;[Time Start(minutes_of_day),Time Duration(minutes)]&#xA;These are daily tasks that needs to be assigned to machines. Once we have kind of roster so as which machine will perform which tasks, we'll schedule these tasks and our job is done. We just need best roster that how many machines will be utilized and which task will be performed by which machine. For that I'm RnDing a model. Here Time Start depicts time that is 0 considered as first minute of day(00:00) and so on and Time Duration is duration of task from time it starts so [0,5] means task will start at 0th minute of day that is at 00:00 and will end at 00:05.&lt;/p&gt;&#xA;&lt;p&gt;I have n-number of machines which only works 30 minutes max a day and when their run time starts when they start first task assigned to them, One machine can continue for 14 minutes at stretch needs 3 minutes cooldown break. 14 minutes is a limit and machine can not exceed 14 minutes. It's like &lt;code&gt;IntVar(0,14)&lt;/code&gt; if I'm not wrong. But since we have discrete tasks we need to assign multiple tasks in continuation and for that I need arc which store tasks assigned to machine and check for cumulative duration of these tasks as total duration should not exceed 14 minutes. For cooldown assignment, if say we assign two tasks in an arc that totals to 10 minutes, we'll give cooldown after both tasks end and next set of tasks will be assigned after minimum of 3 minutes, this cooldown timer can extend to any length/duration but 3 is minimum.&lt;/p&gt;&#xA;&lt;p&gt;So how can I create bin of 30 minutes and within bin arc of 14 minutes and assign tasks and provide cooldown whenever machine finishes tasks assigned.&#xA;Tasks that needs to be assigned should have no break between them, they should be continuous.&#xA;For ex, if machine-1 is assigned [0,5] then next task can only be [5,5] and it can continue for [10,3] too if feasible but we want balanced works to be assigned to machines.&lt;/p&gt;&#xA;&lt;p&gt;There are such thousands of tasks and enough machines to complete work but we need feasible solution that is balanced out without giving major portion of work to few machines and rest machines sitting idle.&lt;/p&gt;&#xA;&lt;p&gt;One method I thought was making one bin per task as our variable.&#xA;Then looping through each bin and assign tasks and when tasks are emptied discarding remaining bins.&lt;/p&gt;&#xA;&lt;p&gt;I need help in modelling using CP-Solver and not Bin-Packing(MPsolver).&#xA;I've gone through OR-Tools examples but I'm lost so if anyone could help..!&lt;/p&gt;&#xA;&lt;p&gt;EDIT----------&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from ortools.linear_solver import pywraplp&#xA;&#xA;# Creates the model.&#xA;model = cp_model.CpModel()&#xA;&#xA;data =[[0,5],&#xA;    [0,4],&#xA;    [1,6],&#xA;    [2,4],&#xA;    [3,6],&#xA;    [3,2],&#xA;    [4,5],&#xA;    [5,5],&#xA;    [6,4],&#xA;    [7,3],&#xA;    [8,2],&#xA;    [8,3],&#xA;    [9,5],&#xA;    [10,3]]&#xA;&#xA;# Create the mip solver with the SCIP backend.&#xA;solver = pywraplp.Solver.CreateSolver('SCIP')&#xA;    &#xA;# Creates the variables&#xA;i=0&#xA;bins = []&#xA;total = 0&#xA;binused = 0&#xA;for d in data:&#xA;    bins.append([d[0],d[0]+30])&#xA;    i=i+1&#xA;    &#xA;&#xA;# Variables&#xA;# x[b, d] = 1 if item d is packed in bin b.&#xA;x = {}&#xA;for b in range(len(bins)):&#xA;    for d in range(len(data)):&#xA;        x[(b, d)] = solver.IntVar(0, 1, 'x_%i_%i' % (b, d))&#xA;        &#xA;# y[b] = 1 if bin b is used.&#xA;y = {}&#xA;for b in range(len(bins)):&#xA;    y[b] = solver.IntVar(0, 1, 'y[%i]' % b)&#xA; &#xA;&#xA;# Constraints&#xA;# Each item must be in exactly one bin.&#xA;for d in range(len(data)):&#xA;    solver.Add(sum(x[b, d] for b in range(len(bins))) == 1)&#xA;&#xA;# The amount packed in each bin cannot exceed its capacity.&#xA;for b in range(len(bins)):&#xA;    solver.Add(&#xA;        sum(x[(b, d)] * data[d][1] for d in range(len(data))) &amp;lt;= y[b] *&#xA;        14)&#xA;&#xA;for b in range(len(bins)):&#xA;    for d in range(len(data)):&#xA;        solver.Add(x[b,d] * data[d][0]  &amp;lt;= bins[b][0] )&#xA;&#xA;    &#xA;# Objective: minimize the number of bins used.&#xA;solver.Minimize(solver.Sum([y[b] for b in range(len(bins))]))&#xA;&#xA;&#xA;status = solver.Solve()&#xA;&#xA;if (status == pywraplp.Solver.OPTIMAL) or (status == pywraplp.Solver.FEASIBLE)  :&#xA;    num_bins = 0&#xA;    for b in range(len(bins)):&#xA;        if y[b].solution_value() == 1:&#xA;            bin_items = []&#xA;            bin_weight = 0&#xA;            for d in range(len(data)):&#xA;                if x[b, d].solution_value() &amp;gt; 0:&#xA;                    bin_items.append(data[d])&#xA;                    bin_weight += data[d][1]&#xA;            if bin_weight &amp;gt; 0:&#xA;                num_bins += 1&#xA;                print('Bin number', b)&#xA;                print('Bin',bins[b])&#xA;                print('  Items packed:', bin_items)&#xA;                print('  Total weight:', bin_weight)&#xA;                print()&#xA;    print()&#xA;    print('Number of bins used:', num_bins)&#xA;    print('Time = ', solver.WallTime(), ' milliseconds')&#xA;else:&#xA;    print('The problem does not have an optimal solution.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;OUTPUT-----&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Bin number 0&#xA;Bin [0, 30]&#xA;  Items packed: [[0, 5], [0, 4]]&#xA;  Total weight: 9&#xA;&#xA;Bin number 5&#xA;Bin [3, 33]&#xA;  Items packed: [[1, 6], [2, 4]]&#xA;  Total weight: 10&#xA;&#xA;Bin number 6&#xA;Bin [4, 34]&#xA;  Items packed: [[3, 6], [3, 2], [4, 5]]&#xA;  Total weight: 13&#xA;&#xA;Bin number 9&#xA;Bin [7, 37]&#xA;  Items packed: [[5, 5], [6, 4], [7, 3]]&#xA;  Total weight: 12&#xA;&#xA;Bin number 13&#xA;Bin [10, 40]&#xA;  Items packed: [[8, 2], [8, 3], [9, 5], [10, 3]]&#xA;  Total weight: 13&#xA;&#xA;&#xA;Number of bins used: 5&#xA;Time =  49  milliseconds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I've modelled this much after seeing some examples and lil bit RnD.&#xA;Now how I model tasks to be continuous and non-overlapping in nature.&#xA;Secondly,  &lt;code&gt;solver.Add(x[b,d] * data[d][0]  &amp;lt;= bins[b][0] )&lt;/code&gt; this constraint is working but logically it should be &amp;gt;= bins[b][0] but with this constraint it can't find optimal/feasible solution.&#xA;And lastly how to model for cooldown.&lt;/p&gt;&#xA;" OwnerUserId="5968" LastEditorUserId="981" LastEditDate="2023-12-22T14:45:18.107" LastActivityDate="2023-12-22T14:45:18.107" Title="Bin Packing with CP Solver" Tags="|optimization|python|combinatorial-optimization|or-tools|multi-objective-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6822" PostTypeId="2" ParentId="5934" CreationDate="2021-08-28T10:10:11.237" Score="3" Body="&lt;p&gt;If I am not mistaken the answer is &lt;strong&gt;NO&lt;/strong&gt; unless &lt;span class=&quot;math-container&quot;&gt;$P=NP$&lt;/span&gt;.&#xA;We can reduce &lt;a href=&quot;https://en.wikipedia.org/wiki/Boolean_satisfiability_problem#Exactly-1_3-satisfiability&quot; rel=&quot;nofollow noreferrer&quot;&gt;Exactly-1 3-satisfiability&lt;/a&gt; to your problem. For a proof of 1-IN-3SAT is NP-complete see &lt;a href=&quot;https://www.nitt.edu/home/academics/departments/cse/faculty/kvi/NPC-3SATs.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;NP-Completeness of 3SAT, 1-IN-3SAT and MAX 2SAT&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Given an instance &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; of the Exactly-1 3-satisfiability problem.&#xA;For each variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; check whether there is a solution setting it to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. This can be done solving &lt;span class=&quot;math-container&quot;&gt;$2n$&lt;/span&gt; LPs. Then there are three cases:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;All variables have a solution with &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. Then we are in the case you described and we know there is an integer solution.&lt;/li&gt;&#xA;&lt;li&gt;There is a variable with no solution for both cases (&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;). Then we know there is no solution for the entire problem.&lt;/li&gt;&#xA;&lt;li&gt;None of the above is the case and there are variables satisfying exactly one of the two cases. Then we can fix these variables to the cases that do work and reduce the problem size. During this reduction we have to do some extra work described in the following.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In step three we might end up getting constraints of the form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;a_1 &amp;amp;= \begin{cases} 0 \\ 1\end{cases}\\&#xA;a_1+a_2 &amp;amp;= 0 \\&#xA;a_1+a_2 &amp;amp;= 1.&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;In the first case we can simply fix the variable encoded in &lt;span class=&quot;math-container&quot;&gt;$a_1$&lt;/span&gt; and continue cleaning up. The same holds for the second case, where we get &lt;span class=&quot;math-container&quot;&gt;$a_1=a_2=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For the third case we can replace the variable in &lt;span class=&quot;math-container&quot;&gt;$a_2$&lt;/span&gt; by the variable in &lt;span class=&quot;math-container&quot;&gt;$a_1$&lt;/span&gt; such that the constraint is always fulfilled (&lt;span class=&quot;math-container&quot;&gt;$a_2 = 1-a_1$&lt;/span&gt;). By this it might happen that we end up getting constraint containing one &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; multiple times. This is also not a problem, as this either fixes &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; to be always &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; (in cases we have &lt;span class=&quot;math-container&quot;&gt;$2x_i$&lt;/span&gt;), always &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; (in cases we have &lt;span class=&quot;math-container&quot;&gt;$2(1-x_i)$&lt;/span&gt;) or adding a constant to the constraint (in cases &lt;span class=&quot;math-container&quot;&gt;$1-x_i+x_i$&lt;/span&gt;). In this case &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; can be removed from the constraint and either the constraint disappears entirely or we end up with something like &lt;span class=&quot;math-container&quot;&gt;$a_1 = \begin{cases} 0 \\ 1\end{cases}$&lt;/span&gt;, which we already solved.&lt;/p&gt;&#xA;&lt;p&gt;If during this reduction we find the problem to be infeasible we know it is infeasible. Otherwise we can start over on a smaller problem.&lt;/p&gt;&#xA;&lt;p&gt;After at most &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; iterations all variables were replaced or we ended up with case 1. or 2., thus the algorithm terminates in polynomial time.&lt;/p&gt;&#xA;&lt;p&gt;I hope this helps and in case I made any mistakes please point them out. ;)&lt;/p&gt;&#xA;" OwnerUserId="4477" LastEditorUserId="4777" LastEditDate="2021-08-28T13:06:09.877" LastActivityDate="2021-08-28T13:06:09.877" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="6823" PostTypeId="1" CreationDate="2021-08-28T21:53:47.577" Score="2" ViewCount="136" Body="&lt;p&gt;I'm trying to explore OR problems and wanted to know what algorithm fits here.&lt;/p&gt;&#xA;&lt;p&gt;Consider fuel stations with lithium ion battery that service replacing battery at each refuel ( you replace your batters with a new one). As an optimization problem, I'd like to identify warehouses (that have some capacity storage of battery quantity) and connect to these fuel stations such that all fuel stations run at least with 50% capacity. An added constraint is that we need to ensure the distance is less than 50 miles from the warehouses.&lt;/p&gt;&#xA;&lt;p&gt;I'm looking to seek help on what optimization problem for this situation.&lt;/p&gt;&#xA;" OwnerUserId="6127" LastEditorUserId="36" LastEditDate="2021-08-29T02:39:35.223" LastActivityDate="2021-08-31T07:11:43.367" Title="Advanced Transportation optimization problem" Tags="|optimization|network-flow|supply-chain|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6824" PostTypeId="1" AcceptedAnswerId="6828" CreationDate="2021-08-28T22:00:09.140" Score="1" ViewCount="72" Body="&lt;p&gt;I am working on a facility location problem where I want to allocate a mix of vulnerable and non-vulnerable people to the facilities. I want to make sure that most or all vulnerable people will be prioritized to be allocated to the facilities and then non-vulnerable people will be allocated. Is there a way to formulate this type of problem in facility location problem?&lt;/p&gt;&#xA;" OwnerUserId="3288" LastActivityDate="2021-08-29T15:32:51.250" Title="Prioritizing a special group in Facility Location problem" Tags="|facility-location|hub-location|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6825" PostTypeId="2" ParentId="6824" CreationDate="2021-08-29T01:51:03.623" Score="1" Body="&lt;p&gt;One way to try is to have lower assignment cost (assuming a minimization objective) to vulnerable people compared to non-vulnerable for a given facility.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2021-08-29T01:51:03.623" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6826" PostTypeId="1" CreationDate="2021-08-29T07:49:32.393" Score="3" ViewCount="156" Body="&lt;p&gt;Consider the following optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\inf_{x,y}&amp;amp;\quad(x-x_0)^\top A(x-x_0) + (y-y_0)^\top B(y-y_0)&#xA;\\\text{s.t.}&amp;amp;\quad x^\top a\geq0,\\ &amp;amp; \quad y^\top b\geq0, \\&amp;amp; \quad \|x-y\|_2^2 \leq \varepsilon,&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x,y\in\mathbb{R}^n$&lt;/span&gt; are the unknown variables, &lt;span class=&quot;math-container&quot;&gt;$x_0,y_0,a,b\in\mathbb{R}^n$&lt;/span&gt; are known vectors, &lt;span class=&quot;math-container&quot;&gt;$A,B\in\mathbb{R}^{n\times n}$&lt;/span&gt; are known positive definite matrices, and &lt;span class=&quot;math-container&quot;&gt;$\varepsilon &amp;gt; 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would like to find a closed-form solution to such a problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What I have tried:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Define the Lagrangian as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$L(\rho,x,y) = \frac{1}{2}((x-x_0)^\top A(x-x_0) + (y-y_0)^\top B(y-y_0)) - \rho_1(x^\top a) - \rho_2(y^\top b) + \rho_3(\varepsilon - \|x - y\|^2).$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt; is the vectors of Lagrange multipliers having non-negative components. Then, the optimality conditions impose:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation*}&#xA;    \begin{cases}&#xA;    \frac{\partial L}{\partial x} = A(x - x_0) - \rho_1a - 2\rho_3(x-y) = 0 \\ \frac{\partial L}{\partial y} =B(y - y_0) - \rho_2b + 2\rho_3(x-y) = 0 \\ \rho_1(x^\top a) = 0 \\ \rho_2(y^\top b) = 0 \\ \rho_3(\varepsilon - \|x - y\|^2) = 0,&#xA;    \end{cases}&#xA;     \end{equation*}&lt;/span&gt;&#xA;plus, the constraints in the primal domain must be satisfied. The main problem for me is that I cannot find a closed-form solution to the above system of equations. Any help would be very appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5005" LastEditorUserId="5005" LastEditDate="2021-08-29T08:43:23.267" LastActivityDate="2021-08-29T08:43:23.267" Title="Convex Optimization Problem with norm inequality constraint" Tags="|optimization|constraint-programming|convex-optimization|lagrange-multipliers|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6827" PostTypeId="2" ParentId="6795" CreationDate="2021-08-29T13:55:25.420" Score="9" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Has anyone tested this approach on a real world business problem?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If the question is, more generally, &lt;em&gt;&amp;quot;for a practical optimization problem, can ML somehow accelerate the performance of a state-of-the-art MIP solver, given that we have already solved a large number of similar instances in the past?&lt;/em&gt;&amp;quot;, then the answer is &lt;strong&gt;yes&lt;/strong&gt;. In the reference below, for example, we show that ML can significantly accelerate the performance of CPLEX (with default settings) on realistic, large-scale instances of the &lt;em&gt;Security-Constrained Unit Commitment&lt;/em&gt; problem. We achieve this, however, not through ML-based branching rules, but by predicting good warm starts and redundant constraints in the formulation.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Álinson S. Xavier, Feng Qiu, and Shabbir Ahmed.&lt;/strong&gt; &amp;quot;Learning to solve large-scale security-constrained unit commitment problems.&amp;quot; &lt;em&gt;INFORMS Journal on Computing 33.2 (2021)&lt;/em&gt;: 739-756. &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.2020.0976&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI:10.1287/ijoc.2020.0976&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If the question is, more strictly, &lt;em&gt;&amp;quot;for a practical optimization problem, can a MIP solver equipped with ML-based branching rules outperform a state-of-the-art MIP solver with default settings, given that we have already solved a large number of similar instances in the past?&amp;quot;&lt;/em&gt;, then the answer is less clear. To the best of my knowledge, this has not been clearly demonstrated yet.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Can [Neural Branching] improve the solution time of [commercial MIP solvers] as much as it does for SCIP solver?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I don't think we have the answer for this question yet; someone would need to implement this branching rule within a commercial MIP solver and run benchmarks, which may not be possible without assistance from the company that developed the solver. That being said, I don't see why would this method work only for SCIP and not the other solvers.&lt;/p&gt;&#xA;" OwnerUserId="6130" LastEditorUserId="6130" LastEditDate="2021-08-29T15:44:29.773" LastActivityDate="2021-08-29T15:44:29.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6828" PostTypeId="2" ParentId="6824" CreationDate="2021-08-29T15:32:51.250" Score="4" Body="&lt;p&gt;You can add a constraint that says the number of vulnerable people assigned to a facility is at least a specified fraction of the total number of vulnerable people (where the fraction is set to 1 if you want to ensure all vulnerable people are assigned, or something less than 1 indicating your tolerance for leaving vulnerable people unassigned). If you use a fraction less than 1, then you might also want to penalize unassigned people in the objective, with higher penalties for unassigned vulnerable people.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-29T15:32:51.250" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6829" PostTypeId="1" AcceptedAnswerId="6830" CreationDate="2021-08-29T17:05:22.843" Score="3" ViewCount="515" Body="&lt;p&gt;I want to linearize the following statement into a MILP: &lt;span class=&quot;math-container&quot;&gt;$\forall x\in \mathbb{R}^{m}$&lt;/span&gt; satisfying &lt;span class=&quot;math-container&quot;&gt;$Cx \le d$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\exists i\in \{1,\cdots,m\}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$a_i^Tx \ge b_i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; are given coefficients.&lt;/p&gt;&#xA;&lt;p&gt;My previous trial is based on Farkas's theorem of alternative. Specifically, I previously transform the above statement into: there is no feasible solution to &lt;span class=&quot;math-container&quot;&gt;$Ax \le b, Cx \le d$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; are the vertical concatenation of &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;, respectively. Then, such statement can be transformed into another linear system according to Farkas's lemma. However, such modeling will encounter a problem: the big-M modeling used in &lt;span class=&quot;math-container&quot;&gt;$Cx \le d$&lt;/span&gt; makes the LP relaxation quite loose, which makes the solver slow.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, I am wondering is it possible to linearize it through the following modeling idea: &lt;span class=&quot;math-container&quot;&gt;$\forall x\in \mathbb{R}^{m}$&lt;/span&gt; satisfying &lt;span class=&quot;math-container&quot;&gt;$Cx \le d$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\exists i\in \{1,\cdots,m\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\min_{x}\{a_i^Tx\} \ge b_i$&lt;/span&gt;? More specifically, I try to model such statement following the disjunctive modeling principle suggested in &amp;quot;Vielma J P. Mixed integer linear programming formulation techniques[J]. Siam Review, 2015, 57(1): 3-57.&amp;quot; However, I am unable to find an appropriate way to model the problem with disjunctive polytopes.&lt;/p&gt;&#xA;" OwnerUserId="5160" LastEditorUserId="491" LastEditDate="2021-08-31T01:59:47.240" LastActivityDate="2021-08-31T01:59:47.240" Title="How to linearize a constraint with a maximum of a linear function" Tags="|mixed-integer-programming|linearization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6830" PostTypeId="2" ParentId="6829" CreationDate="2021-08-29T17:55:25.487" Score="11" Body="&lt;p&gt;You can model the logical implication &lt;span class=&quot;math-container&quot;&gt;$$Cx &amp;lt; d \implies \bigvee_{i=1}^m \left(a_i^T x \ge b_i\right)$$&lt;/span&gt;&#xA;by introducing &lt;span class=&quot;math-container&quot;&gt;$m+1$&lt;/span&gt; binary variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$i\in\{0,\dots,m\}$&lt;/span&gt;, and linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;d - Cx &amp;amp;\le M_0 y_0 \tag1\\&#xA;\sum_{i=1}^m y_i &amp;amp;\ge y_0 \tag2 \\&#xA;b_i - a_i^T x &amp;amp;\le M_i (1-y_i) &amp;amp;&amp;amp;\text{for $i\in\{1,\dots,m\}$} \tag3&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$Cx &amp;lt; d \implies y_0=1$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y_0 = 1 \implies \bigvee_{i=1}^m \left(y_i = 1\right)$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y_i = 1 \implies a_i^T x \ge b_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is this the big-M formulation you already tried?&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-08-29T21:19:23.700" LastActivityDate="2021-08-29T21:19:23.700" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6831" PostTypeId="1" CreationDate="2021-08-29T22:30:24.543" Score="-1" ViewCount="233" Body="&lt;p&gt;In some optimization problem it is stated that the complexity is &lt;span class=&quot;math-container&quot;&gt;${\cal O}(n)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;${\cal O}(n^2)$&lt;/span&gt;. How is this calculated?&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="491" LastEditDate="2023-01-23T12:54:56.277" LastActivityDate="2023-01-23T12:54:56.277" Title="How to calculate the complexity order of an optimization model?" Tags="|optimization|computational-complexity|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6833" PostTypeId="2" ParentId="6748" CreationDate="2021-08-30T07:26:32.493" Score="2" Body="&lt;p&gt;Before creating the instance, you should provide the value for &lt;code&gt;model.Nc&lt;/code&gt; (not &lt;code&gt;model.NC&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;It should look like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;opt = SolverFactory('glpk')&#xA;&#xA;model.Nc=4 #correct this variable Nc&#xA;&#xA;instance = model.create_instance()&#xA;results = opt.solve(instance) # solves and updates instance&#xA;print('NC= ',value(instance.Nc))&#xA;print('OF= ',value(instance.obj))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6126" LastEditorUserId="123" LastEditDate="2021-08-30T07:33:53.870" LastActivityDate="2021-08-30T07:33:53.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6834" PostTypeId="2" ParentId="6831" CreationDate="2021-08-30T13:36:49.043" Score="4" Body="&lt;p&gt;I invite you to first check Wikipedia pages on &lt;a href=&quot;https://en.wikipedia.org/wiki/Computational_complexity&quot; rel=&quot;nofollow noreferrer&quot;&gt;computational complexity&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Big_O_notation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Big O notation&lt;/a&gt;. Then, I would recommend you to study the &lt;a href=&quot;https://books.google.fr/books?id=NLngYyWFl_YC&quot; rel=&quot;nofollow noreferrer&quot;&gt;celebrated book &amp;quot;Introduction to Algorithms&amp;quot; written by Cormen, Leiserson, Rivest, and Stein&lt;/a&gt;. It will allow you to improve your knowledge and understanding of problem and algorithm theoretical complexity.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2021-08-30T16:46:14.543" LastActivityDate="2021-08-30T16:46:14.543" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6835" PostTypeId="1" CreationDate="2021-08-30T14:49:01.037" Score="2" ViewCount="69" Body="&lt;p&gt;I'm trying to feed information retrieved from my neural network to my CP model to help narrow down the search on big instances of my problem. However, I also want to remove the additional imposed constraints to the model and solve it to the optimum, once the best possible solution given the additional constraints from NN is found. This can be done by &lt;code&gt;model.remove_expressions()&lt;/code&gt; function but I've noticed that the search starts from beginning without using any knowledge acquired in the previous search.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way how to transfer the already searched space from more constrained model to less constrained one (i.e. remove constraints and search only the remaining space, not all of it)?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;I've considered warm starting (using the best solution from more constrained problem) and also instead of adding additional conditions, using the data from neural network to guide the search phases. However, from my experience both of these are not so efficient, so they are only my backup options.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="6136" LastActivityDate="2021-08-30T15:23:31.987" Title="ILOG CPOptimizer soft constraints (multiple solves reusing searched space)" Tags="|cplex|constraint-programming|docplex|cp-optimizer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6836" PostTypeId="2" ParentId="6835" CreationDate="2021-08-30T15:23:31.987" Score="2" Body="&lt;p&gt;I am fairly certain that you cannot resume solution from the previous final state after altering the model. This is a known fact with CPLEX, presumably the same with CPOptimizer for essentially the same reason: the final state of the previous solve may not be valid for the modified problem. For instance, if you were to drop constraints and resume, the true optimal solution might never be found because it might have been eliminated during the first solve by one of the subsequently dropped constraints.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-30T15:23:31.987" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6838" PostTypeId="2" ParentId="6829" CreationDate="2021-08-30T16:20:21.210" Score="1" Body="&lt;p&gt;I think your constraint is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\neg \left[\begin{pmatrix} A\\ C \end{pmatrix} x \leq \begin{pmatrix} b\\ d\end{pmatrix}\right]&#xA;$$&lt;/span&gt;&#xA;because&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;&amp;amp;Cx \leq d \;\Longrightarrow\;\bigvee(a_i^Tx \geq b_i)\\&#xA;\Longleftrightarrow\;&amp;amp;\neg(Cx \leq d) \;\vee\;\neg(Ax\leq b)\\&#xA;\Longleftrightarrow\;&amp;amp;\neg(Ax\leq b \;\wedge Cx\leq d) &#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So it means at least one row is violated, which could be modeled as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Ax \geq b - M_1\circ (1-u)\\&#xA;Cx \geq d - M_2\circ (1-v)\\&#xA;\sum u_i+\sum v_j \geq 1&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\circ$&lt;/span&gt; means element-wise product.&lt;/p&gt;&#xA;&lt;p&gt;If the matrix &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is a row vector, this model is identical with RobPratt's. But   in his model, when &lt;span class=&quot;math-container&quot;&gt;$Ax \leq b$&lt;/span&gt;, it forces &lt;span class=&quot;math-container&quot;&gt;$y_0=0$&lt;/span&gt;, then forces &lt;span class=&quot;math-container&quot;&gt;$Cx \geq d$&lt;/span&gt;, which is unnecessary(?).&lt;/p&gt;&#xA;&lt;p&gt;Edit: some &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;'s are absolutely needed.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2021-08-30T16:20:21.210" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6840" PostTypeId="1" AcceptedAnswerId="6848" CreationDate="2021-08-30T22:36:52.903" Score="2" ViewCount="134" Body="&lt;p&gt;I came across the MINTO MILP solver today. A solver i wasn't aware of or at least had not paid attention too. While development seem to have stopped two decades ago however i still wouldn't mind getting access to it. However the form &lt;a href=&quot;https://coral.ise.lehigh.edu/%7Eminto/download.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt; to request access seems to have bitrotten away. I know that the solver is still available on the NEOS servers and i have made attempts to contact MINTOs developers (including a Dr. Gu who works on a different popular Mixed-Integer solver today) and people at the CORAL institute which hosts the website &lt;a href=&quot;https://coral.ise.lehigh.edu/%7Eminto/&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt; of the solver.&lt;/p&gt;&#xA;&lt;h3&gt;Do you have any other ideas how to get access to this MILP solver?&lt;/h3&gt;&#xA;&lt;h3&gt;Have you had any experience with this solver?&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://coral.ise.lehigh.edu/%7Eminto/download.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt; &lt;a href=&quot;https://coral.ise.lehigh.edu/%7Eminto/download.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Download form&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://coral.ise.lehigh.edu/%7Eminto/&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt; &lt;a href=&quot;https://coral.ise.lehigh.edu/%7Eminto/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MINTO website&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-08-31T17:26:22.887" Title="Suggestions how to get access to MINTO MILP solver?" Tags="|mixed-integer-programming|linear-programming|solver|branch-and-bound|history|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6841" PostTypeId="2" ParentId="6823" CreationDate="2021-08-31T00:46:27.763" Score="4" Body="&lt;p&gt;This sounds like a network optimization problem with inventory consideration. There could be two possible scenarios:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You have already determined the location of potential warehouses.&lt;/li&gt;&#xA;&lt;li&gt;You'd like to determine potential locations in 1 - Do a greenfield analysis aka Centre-Of-Gravity &lt;a href=&quot;https://www.anylogistix.com/solving-facility-location-problem-with-greenfield-analysis/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.anylogistix.com/solving-facility-location-problem-with-greenfield-analysis/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Tip for 2: Make sure while you generate the solutions, you should also keep in mind you'll need to keep increasing the number of centres until you satisfy your distance ( &amp;lt; 50 miles constraint).&lt;/p&gt;&#xA;&lt;p&gt;In my view, you are now given a set of potential warehouses and fuel stations. You want to map warehouses to fuel stations in such a way that no fuel station is &amp;gt; 50 miles and the looks like the demand is 50% of fuel station capacity.&lt;/p&gt;&#xA;&lt;p&gt;Decision variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; - Warehouse &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; serves fuel station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; - Number of Batteries moved from warehouse &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to fuel station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Parameters:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Demand: &lt;span class=&quot;math-container&quot;&gt;$d_j$&lt;/span&gt; - At Fuel station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Distance: &lt;span class=&quot;math-container&quot;&gt;$D_{ij}$&lt;/span&gt; - From warehouse &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to fuel station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Cost of Movement per battery &lt;span class=&quot;math-container&quot;&gt;$C_{ij}$&lt;/span&gt; - Assuming you have this kind of cost structure. If not, then you might need to introduce additional variables or transform/approximate your cost in these units of measure.&lt;/li&gt;&#xA;&lt;li&gt;A big number - &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For convenience, assume:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Warehouses &lt;span class=&quot;math-container&quot;&gt;$\in W$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Fuel Stations &lt;span class=&quot;math-container&quot;&gt;$\in F$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Formulation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad C_{ij}x_{ij}\\\text{s.t.}&amp;amp;\quad D_{ij}y_{ij} \leq 50 &amp;amp; \forall i \in W ,j \in F \\&#xA;&amp;amp;\quad x_{ij} \leq M y_{ij} &amp;amp; \forall i \in W ,j \in F \\&#xA;&amp;amp;\quad \sum_{i \in W}{x_{ij}} \geq 0.5 d_j &amp;amp; \forall j \in F \\&#xA;&amp;amp;\quad x_{ij} \geq 0 \\&#xA;&amp;amp;\quad y_{ij} \in \{0,1\}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The output of this MIP should be the solution to your problem. You can check the model.py file &lt;a href=&quot;https://github.com/mohit-mhjn/manufacturing_network_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; to know how to program this in python using the open-source packages. Few things to note:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;As you increase the number of warehouses, your fixed cost would go up. So if that is known you could add it to your objective function.&lt;/li&gt;&#xA;&lt;li&gt;If you need that, a fuel station need to served from one and only one warehouse (aka single-sourcing in Network Optimization), you could add another constraint on &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. The given math program should set the basic framework.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4116" LastEditorUserId="123" LastEditDate="2021-08-31T07:11:43.367" LastActivityDate="2021-08-31T07:11:43.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6842" PostTypeId="2" ParentId="5934" CreationDate="2021-08-31T01:02:13.637" Score="1" Body="&lt;p&gt;The question can be understand as determining the truth value of &lt;span class=&quot;math-container&quot;&gt;$$(\forall \text{assignments}: \text{relaxation feasible} )\implies \text{problem has integer solution}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However since setting up many LP problems is more expensive then solving a small MILP (or even cheaper 1-in-3 SAT). I instead try to show the opposite: &lt;span class=&quot;math-container&quot;&gt;$$(\forall \text{assignments}: \text{relaxation feasible} )\land \neg(\text{problem has integer solution)}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h3&gt;A not quiet naive approach that works for 4 variables&lt;/h3&gt;&#xA;&lt;p&gt;I tried to find an counter example but wasn't able to put in the engineering effort to remove all the symmetries so my approach only scales to 4 varibles.&lt;/p&gt;&#xA;&lt;p&gt;I attempted to do that for all 4 variable formulas with the following (hacky and ugly) Julia code.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using JuMP&#xA;using Gurobi&#xA;&#xA;coll = []&#xA;&#xA;function build_constraint(model, vars, constraint)&#xA;  rhs = 1&#xA;  signs = similar(constraint)&#xA;  for i in eachindex(constraint)&#xA;     if sign(constraint[i]) == -1&#xA;       signs[i] = -1&#xA;       rhs -= 1&#xA;     else&#xA;       signs[i] = 1&#xA;    end&#xA;  end&#xA;  @constraint(model, sum(signs[i]*vars[abs(constraint[i])] for i in eachindex(constraint) ) == rhs)&#xA;end&#xA;&#xA;&#xA;function flip_signs(head,tail,func)&#xA;  if isempty(head)&#xA;    func(tail)&#xA;  else&#xA;    hd = head[1]&#xA;    for i in Iterators.product(-1:2:1,-1:2:1,-1:2:1)&#xA;       c =  copy(tail)&#xA;       flip_signs(head[2:end], push!(c, i .* hd), func)&#xA;    end&#xA;  end&#xA;end&#xA;      &#xA;      &#xA;function build_model(constraints)&#xA;  m = Model(Gurobi.Optimizer)&#xA;  @variable(m,x[1:4],Bin)&#xA;  for c in constraints&#xA;    build_constraint(m, x, c)&#xA;  end&#xA;  set_silent(m)&#xA;  optimize!(m)&#xA;  if termination_status(m) != MOI.OPTIMAL&#xA;    println(&amp;quot;Interesting: &amp;quot;,constraints)&#xA;    push!(coll, constraints)&#xA;  end&#xA;end&#xA;&#xA;flip_signs([[1,2,3]], [], build_model)&#xA;flip_signs([[1,2,3],[1,2,4]], [], build_model)&#xA;flip_signs([[1,2,3],[1,2,4],[2,3,4]], [], build_model)&#xA;flip_signs([[1,2,3],[1,2,4],[2,3,4],[1,3,4]], [], build_model)&#xA;&#xA;counter = []&#xA;&#xA;function build_linear_models(collection)&#xA;  for constr in collection&#xA;    m = Model()&#xA;    @variable(m,0&amp;lt;=x[1:4]&amp;lt;=1)&#xA;    for c in constr&#xA;      build_constraint(m, x, c)&#xA;    end&#xA;    isalwaysfeasible = true&#xA;    for i in 1:4&#xA;      for v in 0:1&#xA;        m2 = copy(m)&#xA;        set_silent(m2)&#xA;        set_optimizer(m2, Gurobi.Optimizer)&#xA;        @constraint(m2, variable_by_name(m2,&amp;quot;x[$(1)]&amp;quot;) == v)&#xA;        optimize!(m2)&#xA;        isalwaysfeasible = isalwaysfeasible &amp;amp;&amp;amp; (termination_status(m) == MOI.OPTIMAL)&#xA;      end&#xA;    end&#xA;    if isalwaysfeasible&#xA;      push!(counter,constr)&#xA;      println(&amp;quot;Counterexample: &amp;quot;, constr)&#xA;    end&#xA;  end&#xA;end&#xA;        &#xA;build_linear_models(coll)        &#xA;        &#xA;if isempty(counter)&#xA;  println(&amp;quot;nothing found&amp;quot;)&#xA;end     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I first collect all instances Gurobi couldn't solve successfully and then check whether any of these passed the relaxation test. I found no counter examples with 4 variables. I did that by checking the 4 equivalence classes of hypergraphs made solely out of 3-hyperedges that cover a 4 element fully connected graph. There are 4 of them and then try every single sign flipped version of 5. This however scales really badly for 5 variables. As the formula containing all distinct 3 literal clauses of 5 variable are of count &lt;span class=&quot;math-container&quot;&gt;$2^{3\binom{5}{3}} = 2^{30}$&lt;/span&gt; of which a larger fraction are redundant. (Think 1 in sum over some factorials is not a duplicate, did not make a more precise analysis but 1 in 10! is an overestimate of the degree of duplication.&lt;/p&gt;&#xA;&lt;h3&gt;How would i go about it if it was my job&lt;/h3&gt;&#xA;&lt;p&gt;This problem quickly becomes intractable as naive approaches would already fail at 4 variables and my slightly advanced approach of generating the which variables are inside a clause independent of the conversion into literals fails for 5 variables. (By failing i mean takes to long and next step will be much, much worse (I think i could make a good case for super-exponentially worse))&lt;/p&gt;&#xA;&lt;p&gt;The biggest priority is write a system that generates one example for every equivalence class of non-redundant 3 sat formulas. Two formulas are in the same equivalence class if there exist an one-to-one and onto mapping from the variables and their negatives into the variables and their negatives such as the formula matches all solutions can be translated into solutions of the other formula using that mapping.&lt;/p&gt;&#xA;&lt;p&gt;The approach is to construct from the empty formula (or deconstruct from the full formula) a 3-hypger graph where each 3-edge doesn't violate the variable occurs twice rule.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/G4Cyy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/G4Cyy.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You see nodes for the literals &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; thtough &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; and their negation. A 3 hyperedge is only valid if each node it connects is directly to connected to every other node in the 3-hyperedge in the graph above. Notice the absence of connection between literal and their negation to enforce your constraint.&lt;/p&gt;&#xA;&lt;p&gt;To prevent the creation of redundant formulas it essential (and probably sufficient) to track symmetric literals/nodes &lt;a href=&quot;https://math.stackexchange.com/q/711507/870285&quot;&gt;1&lt;/a&gt; in the 3-hypergraph and when expanding the search tree on that node don't expand it in a way which would add two child nodes which have a new 3-edge that is identical given the node symmetries in the parent. Another thing to be aware is that the search tree is actually a Directed Acyclic graph, as there are multiple ways of adding hyperedges to end up with same hypergraph. So a checking for 3-hypergraph equivalence needs to be performed between every hypergraph at each depth. There are some heuristics that can allow you to bail out early when comparing and i haven't explored but find it likely that the DAG structure might also poses constraint which nodes can bring forth similar equivalent children.&lt;/p&gt;&#xA;&lt;p&gt;Also note that adding an edge can include up to 2 literals which weren't in the parent and their negation wasn't either, however not 3 literals which weren't in the parent as you are only interested in growing connected 3-hypergraphs, as non connected ones are independent sub problems with fewer literals you would have searched when you did a run with that many variables. It is possible to add 3 new literals though if one of the has a negation in the parent.&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables the will be graphs with length from 0 to &lt;span class=&quot;math-container&quot;&gt;$\binom{n}{3}$&lt;/span&gt; this search DAG however there is an symmetry in the search DAG i hinted at the beginning, namely a &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; 3-edge hypergraph has &lt;span class=&quot;math-container&quot;&gt;$\binom{n}{3} - m$&lt;/span&gt; 3-edge hypergraph as negation.&lt;/p&gt;&#xA;&lt;p&gt;An algorithm that satisfies these notes should be able generate only one and one member from all equivalence classes of that many variables. However a formal treatment might discover i missed something.&lt;/p&gt;&#xA;&lt;p&gt;The next most important thing is to speed up the batch solving of the very, very similar LP problems that arise. It is possible GPU acceleration is beneficial here.&lt;/p&gt;&#xA;&lt;p&gt;The last step at scale is to modify an existing fast starting SAT solver into an 1-in-3 SAT solver, as that the 1-in-3 SAT problems can be solved a lot faster that way than an SAT encoding. It would be furthermore advisable to remove presolving. If this becomes a larger bottleneck it might be worth to look into SAT solvers for random formulas as they have special techniques that could work well when ported over to 1-in-3 SAT.&lt;/p&gt;&#xA;&lt;p&gt;A last thing into keep in mind is that the LP check and the 1-in-3 SAT call can be easily distributed even on something with as weak coupling as BOINC. If you have more workers than you can satisfy with one computer producing the equivalence class representatives you can have a second computer works on generating problems a different number of variables. The reason why i want to discourage distributing this part is that you need and all to all nodes in the search DAG communication and 3-hypergraph equivalence checks across these links (this would be possible with MPI in an HPC environment but i imagine the pain not being worth it until you start to run out of memory on as a big a server as you can afford having many of). The equivalence class generation happens more efficiently on a single node and there are no two points you can start searching independently (expect empty and full but you can generate the other by inverting the other anyway) without risking duplicate clauses or having to check for equivalence later. One equivalence when expanded leads all children also being explored redundantly.&lt;/p&gt;&#xA;&lt;p&gt;Solving this problem in scalable way will require a non-trivial new algorithm, modifying exiting libraries, new research into batch LP solving. If it doesn't find an counter example it wouldn't completely wasted as it will probably yield new insights into SAT solvers as the study of the equivalence classes might reveal new patterns.&lt;/p&gt;&#xA;&lt;p&gt;This post should give you a good battle plan how two researchers could setup this in a few months. I can make no estimate on how much compute will be needed, as we don't know how the number of equivalence classes of 3-SAT instances (without repeated variables) scales with the number of variables.&lt;/p&gt;&#xA;&lt;p&gt;Another approach to falsification: Encode hard SAT formulas into 1-in-3 SAT and check your prediction vs the know result agreed upon multiple solvers.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://math.stackexchange.com/q/711507/870285&quot;&gt;1&lt;/a&gt; &lt;a href=&quot;https://math.stackexchange.com/q/711507/870285&quot;&gt;Generalize this notion of graph symmetry to 3-hypergraphs&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-09-02T22:57:01.500" LastActivityDate="2021-09-02T22:57:01.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6843" PostTypeId="2" ParentId="6819" CreationDate="2021-08-31T05:28:38.503" Score="2" Body="&lt;p&gt;If I understand the problem correctly, it might be modeled as a variant of the resource-constrained project schedule in which you have some parallel machines and the tasks should be performed with some limitation. From the above-given data, some noisy things should be considered.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First, limiting the start time of a task by being started from the same point in the planning horizon would cause overlap between the tasks. it means finding a feasible solution by any kind of solvers, (MILP, CP, etc), would be challenging work.&lt;/li&gt;&#xA;&lt;li&gt;Second, executing the tasks far from the planning horizon beginning point might decrease resource efficiency.&lt;/li&gt;&#xA;&lt;li&gt;Third, you would need to recalculate a specific number of resources by a bit change in the data that lead to manipulating the final solution. That is not suitable.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As a solution for the above problem please, see the following picture:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/iGTe2.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iGTe2.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this case, we need almost six bins/resources. The efficiency of resources number &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; are very low. Also, there is an overlap between tasks &lt;span class=&quot;math-container&quot;&gt;$11$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; on the last resource which comes from the noisy data.&lt;/p&gt;&#xA;&lt;p&gt;Indeed, another way might be using a heuristic algorithm but, I doubt it can produce a better solution. The result of the naive one is as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Resource &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\text{\{j1, j8, j14, cooling}\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Resource &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\text{\{j2, j7, j13}\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Resource &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\text{\{j3, j10}\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Resource &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\text{\{j4, j9}\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Resource &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\text{\{j5}\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Resource &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\text{\{j6, j11}\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Resource &lt;span class=&quot;math-container&quot;&gt;$7$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\text{\{j12}\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I hope it will be helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-08-31T05:28:38.503" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="6844" PostTypeId="1" AcceptedAnswerId="6845" CreationDate="2021-08-31T06:29:31.010" Score="2" ViewCount="286" Body="&lt;p&gt;I want to solve a problem that results in this general objective function which I want to maximize:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$a\cdot x_1+b\cdot x_2-c\cdot x_3-d\cdot x_4+e\cdot x_5$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;When I write out in full this objective function I get&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;a\cdot x_{11}+a\cdot x_{12}+a\cdot x_{13}+\cdots+a\cdot x_{1m}+ \\&#xA;&amp;amp;b\cdot x_{21}+b\cdot x_{22}+b\cdot x_{23}+\cdots+b\cdot x_{2n}- \\ &#xA;&amp;amp;c\cdot x_{31}-c\cdot x_{32}-c\cdot x_{33}+\cdots-c\cdot x_{3o}- \\&#xA;&amp;amp;d\cdot x_{41}-d\cdot x_{42}-d\cdot x_{43}+\cdots-d\cdot x_{4p}+ \\&#xA;&amp;amp;e\cdot x_{51}+e\cdot x_{52}+e\cdot x_{53}+\cdots+e\cdot x_{5q}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And with the coefficients I'm struggling, because I don't know how I should set them. Perhaps out of the task I could say coefficient &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is &lt;strong&gt;twice as important&lt;/strong&gt; as &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; - and as a consequence &lt;span class=&quot;math-container&quot;&gt;$2\cdot a=b$&lt;/span&gt;. And sometimes I simply can guess so &lt;span class=&quot;math-container&quot;&gt;$c=0.01$&lt;/span&gt;...&lt;/p&gt;&#xA;&lt;p&gt;Is there a technique that helps me determine that my coefficients are set proper? In such a way that I don't set coefficients that dominate the results - like &lt;span class=&quot;math-container&quot;&gt;$e=10^5$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I really hope that trial and error is not the only answer. But when it's the only appropriate choice then your strategy of setting coefficients would be very nice to know.&lt;/p&gt;&#xA;&lt;p&gt;Many thanks for any coefficients tuning suggestions in advance!&lt;/p&gt;&#xA;" OwnerUserId="6135" LastEditorUserId="123" LastEditDate="2021-08-31T07:13:21.710" LastActivityDate="2021-08-31T08:04:31.440" Title="Tuning the coefficients of an objective function of LP" Tags="|optimization|linear-programming|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6845" PostTypeId="2" ParentId="6844" CreationDate="2021-08-31T08:04:31.440" Score="5" Body="&lt;p&gt;When defining multiple components in an objective function, you should take care of a couple of items:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All elements (i.e.e &lt;span class=&quot;math-container&quot;&gt;$a \cdot x_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b\cdot x_2$&lt;/span&gt; etc.) should have the same unit. This sounds obvious, but I have seen adding kg and seconds together.&lt;/li&gt;&#xA;&lt;li&gt;Whenever possible, I would always normalize the sum of the coefficients to 1, so that you can think of them as percentages,  i.e.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$a + b + c + d + e = 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But in general, if you don't have a clear view, you will not get around experimenting around and seeing what provides the solution you &amp;quot;like&amp;quot; best.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2021-08-31T08:04:31.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6846" PostTypeId="1" AcceptedAnswerId="6879" CreationDate="2021-08-31T13:00:58.810" Score="2" ViewCount="265" Body="&lt;p&gt;I have an optimization problem as below.&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$g\in G$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}_g$&lt;/span&gt; be the nodes in group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, and let binary variable &lt;span class=&quot;math-container&quot;&gt;$u_g$&lt;/span&gt; indicate whether group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is used.  The problem has this following constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{g\in G:\ i\in N_g} u_g &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can Model this in Cplex?&lt;/p&gt;&#xA;&lt;p&gt;For example, G=10;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}_1={1,2}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}_2={1,3,4}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}_3={1,3,5}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}_4={1,4,5,6}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}_{10}={1,6,7,8}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The only constraint says that every node must be chosen just once.&lt;/p&gt;&#xA;&lt;p&gt;Here is what I tried so far&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;IloEnv env;&#xA;try{&#xA;&#xA;IloNum G=10;&#xA;&#xA;IloNumVarArray Ug(env, G,0,1,ILOINT)&#xA;&#xA;IloModel model(env)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In order to make it  efficient for implementation I do a reformulation. I generate a binary matrix,&lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; of size &lt;span class=&quot;math-container&quot;&gt;$N_{node}\times G$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$N_{node}$&lt;/span&gt; is the number of nodes. If node &lt;span class=&quot;math-container&quot;&gt;$n, n\in{1,2,\cdots,N_{node}}$&lt;/span&gt; is present in group &lt;span class=&quot;math-container&quot;&gt;$g, g\in{1,2,\cdots,G}$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$B_{n,g}=1$&lt;/span&gt;, otherwise 0.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;IloExpr constFun(env)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note: In Matlab, this constraint now can be expressed as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  for n=1:N&#xA;      &#xA;      sum(Ug(find(B(n,:)==1)))==1;&#xA;      &#xA;  end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2021-08-31T15:41:41.170" LastActivityDate="2021-09-07T06:41:21.327" Title="How to code this with Cplex?" Tags="|modeling|cplex|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6847" PostTypeId="1" CreationDate="2021-08-31T16:00:42.103" Score="1" ViewCount="387" Body="&lt;p&gt;This is an online assignment problem and yet can be considered as an assignment problem with a sequence. Assume that workers are coming into the system sequentially and I want to assign a task to them based on their cost for each task. I have set up the python model without the sequence constraint, I just couldn't figure out how to mandate the order:&#xA;This example from the OR-Tools:&#xA;In the example there are four workers (numbered 0-3) and four tasks (numbered 0-3).&lt;/p&gt;&#xA;&lt;p&gt;The costs of assigning workers to tasks are shown in the following table.&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;&lt;/th&gt;&#xA;&lt;th&gt;0&lt;/th&gt;&#xA;&lt;th&gt;1&lt;/th&gt;&#xA;&lt;th&gt;2&lt;/th&gt;&#xA;&lt;th&gt;3&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;90&lt;/td&gt;&#xA;&lt;td&gt;80&lt;/td&gt;&#xA;&lt;td&gt;75&lt;/td&gt;&#xA;&lt;td&gt;70&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;35&lt;/td&gt;&#xA;&lt;td&gt;85&lt;/td&gt;&#xA;&lt;td&gt;55&lt;/td&gt;&#xA;&lt;td&gt;65&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;125&lt;/td&gt;&#xA;&lt;td&gt;95&lt;/td&gt;&#xA;&lt;td&gt;90&lt;/td&gt;&#xA;&lt;td&gt;85&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;td&gt;45&lt;/td&gt;&#xA;&lt;td&gt;110&lt;/td&gt;&#xA;&lt;td&gt;95&lt;/td&gt;&#xA;&lt;td&gt;115&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;The problem is to assign each worker to at most one task, with no two workers performing the same task while minimizing the total cost. Since there are more workers than tasks, one worker will not be assigned a task.&lt;/p&gt;&#xA;&lt;p&gt;Assume that I want to force an order/ sequence. Say worker 0 has to be assigned first worker 2, then worker 3...&#xA;So in practice:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;worker 0 assigned to task 3 (lowest cost)&lt;/li&gt;&#xA;&lt;li&gt;worker 1 assigned to task 0 (lowest cost)&lt;/li&gt;&#xA;&lt;li&gt;worker 2 assigned to task 2 (task 3 has the lowest cost but since it is already assigned to worker 0 it is not available)&lt;/li&gt;&#xA;&lt;li&gt;worker 3 assigned to task 1&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;MIP solution&#xA;The following sections describe how to solve the problem using the MIP solver as an assignment problem without enforcing the order.&lt;/p&gt;&#xA;&lt;p&gt;Import the libraries&#xA;The following code imports the required libraries.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from ortools.linear_solver import pywraplp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The following code declares the MIP solver.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Create the mip solver with the SCIP backend.&#xA;solver = pywraplp.Solver.CreateSolver('SCIP')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The following code creates the data for the problem.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;costs = [&#xA;[90, 80, 75, 70],&#xA;[35, 85, 55, 65],&#xA;[125, 95, 90, 85],&#xA;[45, 110, 95, 115],&#xA;]&#xA;num_workers = len(costs)&#xA;num_tasks = len(costs[0])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The following code creates binary integer variables for the problem.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# x[i, j] is an array of 0-1 variables, which will be 1&#xA;# if worker i is assigned to task j.&#xA;x = {}&#xA;for i in range(num_workers):&#xA;   for j in range(num_tasks):&#xA;      x[i, j] = solver.IntVar(0, 1, '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The following code creates the constraints for the problem.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Each worker is assigned to at most 1 task.&#xA;for i in range(num_workers):&#xA;solver.Add(solver.Sum([x[i, j] for j in range(num_tasks)]) &amp;lt;= 1)&#xA;&#xA;# Each task is assigned to exactly one worker.&#xA;for j in range(num_tasks):&#xA;solver.Add(solver.Sum([x[i, j] for i in range(num_workers)]) == 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;HERE I want to add another constraint(s) that forces the order&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The following code creates the objective function for the problem.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;objective_terms = []&#xA;for i in range(num_workers):&#xA;   for j in range(num_tasks):&#xA;       objective_terms.append(costs[i][j] * x[i, j])&#xA;solver.Minimize(solver.Sum(objective_terms))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The value of the objective function is the total cost over all variables that are assigned the value 1 by the solver.&lt;/p&gt;&#xA;&lt;p&gt;Invoke the solver&#xA;The following code invokes the solver and prints the solution.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;status = solver.Solve()&#xA;if status == pywraplp.Solver.OPTIMAL or status == pywraplp.Solver.FEASIBLE:&#xA;print('Total cost = ', solver.Objective().Value(), '\n')&#xA;for i in range(num_workers):&#xA;    for j in range(num_tasks):&#xA;        # Test if x[i,j] is 1 (with tolerance for floating point arithmetic).&#xA;        if x[i, j].solution_value() &amp;gt; 0.5:&#xA;            print('Worker %d assigned to task %d.  Cost = %d' %&#xA;                  (i, j, costs[i][j]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6144" LastEditorUserId="981" LastEditDate="2023-12-22T14:49:04.247" LastActivityDate="2023-12-22T14:49:04.247" Title="Adding sequence constraints to the assignment problem- Python" Tags="|python|constraint|scheduling|or-tools|assignment-problem|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6848" PostTypeId="2" ParentId="6840" CreationDate="2021-08-31T17:26:22.887" Score="8" Body="&lt;p&gt;MINTO has not been updated in many years. It was innovative in its day, but most of its ideas like fractional cuts and presolve were incorporated years ago into commercial MILP solvers like CPLEX and Gurobi. For most applications today, the best option is one of the major commercial solvers like &lt;a href=&quot;https://www.ibm.com/analytics/cplex-optimizer&quot; rel=&quot;noreferrer&quot;&gt;CPLEX&lt;/a&gt; or &lt;a href=&quot;https://www.gurobi.com&quot; rel=&quot;noreferrer&quot;&gt;Gurobi&lt;/a&gt;; these are available at no-cost for academic users. For a MIP researcher who needs to modify the underlying branch-and-cut algorithms beyond what can be done with the commercial solvers, then the closest successor to MINTO is &lt;a href=&quot;https://www.scipopt.org&quot; rel=&quot;noreferrer&quot;&gt;SCIP&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Disclaimer: I was a graduate student at Georgia Tech when MINTO was developed; I worked at CPLEX previously and currently work for Gurobi.&lt;/p&gt;&#xA;" OwnerUserId="18" LastActivityDate="2021-08-31T17:26:22.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6849" PostTypeId="1" AcceptedAnswerId="6850" CreationDate="2021-08-31T19:43:26.693" Score="2" ViewCount="110" Body="&lt;p&gt;I am new to optimization, not sure if the problem described below is trivial. Any guidance on solution or nudge in the right direction would be very helpful.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are two groups – clients and service providers. Let’s represent clients as &lt;span class=&quot;math-container&quot;&gt;$u=1,2,\cdots,n$&lt;/span&gt; and service providers as &lt;span class=&quot;math-container&quot;&gt;$v=1,2,\cdots,m$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$n &amp;gt; m$&lt;/span&gt;. The task is to recommend each client the top 3 service-providers based on the propensity score &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; (which is an &lt;span class=&quot;math-container&quot;&gt;$n\times m$&lt;/span&gt; matrix).&lt;/p&gt;&#xA;&lt;p&gt;The propensity score &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt; denotes the propensity of a the client &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; accepting a service provider &lt;span class=&quot;math-container&quot;&gt;$v_j$&lt;/span&gt;. Ideally, we want to recommend top 3 service providers to a client which have the highest propensity of acceptance. Each service provider has a capacity constraint such that number of clients recommended for one service-provider should be between a certain fixed range: &lt;span class=&quot;math-container&quot;&gt;$|\mu^{-1}(v)|\le q_v\,\forall v$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; is the assignment and &lt;span class=&quot;math-container&quot;&gt;$q_v$&lt;/span&gt; is the limit to number of assignments for the &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;th service provider.&lt;/p&gt;&#xA;&lt;p&gt;The solution needs to be practically feasible. We are dealing with few millions clients and few thousands service provider.&lt;/p&gt;&#xA;&lt;p&gt;I also want to make sure the recommendations don’t change drastically. If propensity scores don't change over time, then we should be recommending more or less same service providers to the same client. If possible, there could be some variation although – say, changing one of the top 3 service providers every now and then will not be a terrible idea.&lt;/p&gt;&#xA;&lt;p&gt;What kind of techniques are usually used to solve such problems – After doing a bit of research, I found there are techniques such as Linear Programing, Bipartite Graphs to handle similar problems. But I can’t wrap my head around the best course of solution that should be employed in this case.&lt;/p&gt;&#xA;" OwnerUserId="6145" LastEditorUserId="123" LastEditDate="2021-08-31T20:01:03.293" LastActivityDate="2021-08-31T20:27:04.517" Title="Optimization Problem: Recommending Service Providers to Clients" Tags="|optimization|linear-programming|assignment-problem|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6850" PostTypeId="2" ParentId="6849" CreationDate="2021-08-31T20:27:04.517" Score="2" Body="&lt;p&gt;First, let's split this into two separate problems: making the initial assignments; and updating assignments over time. (If you already have assignments in place, you may only need the second problem.)&lt;/p&gt;&#xA;&lt;p&gt;The initial problem can be modeled a &lt;a href=&quot;https://en.wikipedia.org/wiki/Generalized_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;generalized assignment problem&lt;/a&gt; (GAP). Technically this is an integer linear program, with a zero-one variable for each combination of client and service provider, which is unworkable at your dimensions. So we're going to need to do some approximating and settle for a &amp;quot;good&amp;quot; but not provably optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;I would first look at whether it is possible to assign users to clusters such that the propensity scores for all users in the cluster and any provider are close enough to each other that you would be willing to assign an &amp;quot;average&amp;quot; propensity to all users in the cluster. That would bring the number of variables down from &lt;span class=&quot;math-container&quot;&gt;$n\cdot m$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n_c \cdot m$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$n_c$&lt;/span&gt; is the (hopefully small) number of clusters. Now solve a linear programming relaxation of the GAP to get the approximate number of clients in each cluster assigned to each provider, then make those assignments (say, by solving an actual GAP for each cluster, involving only the clients in that cluster and the providers who had a nonzero volume of assignments from that cluster in the LP), with some rounding and finessing to deal with any residual fractions.&lt;/p&gt;&#xA;&lt;p&gt;If clustering based on propensities is not possible, I would look at whether the full problem can be adequately approximated by a bunch of smaller problems, where each client and each provider exists in exactly one of the smaller problems. For instance, it might make sense to partition based on geography.&lt;/p&gt;&#xA;&lt;p&gt;Assuming you find a workable idea among those, to deal with updates over time I would use the same approach, adding or removing clients and providers if either group changes over time, and fixing most of the assignments of clients carried over to providers carried over. This leaves a smaller problem in which new clients are assigned, clients whose providers disappeared are reassigned, and possibly some other clients are reassigned to make the overall result better. You can either leave the objective as-is and assume the solver will not reassign an existing client unless there is overall benefit, or you can add a penalty for reassigning clients to discourage it being done with significant overall benefit. (How to decided which assignments are locked and which are allowed to change is left to the reader as an exercise.) The locked assignments turn into adjustments in cluster size or number of clients and capacities of volunteers, and don't directly contribute to the size of the problem being solved.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-08-31T20:27:04.517" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6851" PostTypeId="1" CreationDate="2021-09-01T00:38:57.973" Score="4" ViewCount="727" Body="&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;&lt;/th&gt;&#xA;&lt;th&gt;line1&lt;/th&gt;&#xA;&lt;th&gt;line2&lt;/th&gt;&#xA;&lt;th&gt;line3&lt;/th&gt;&#xA;&lt;th&gt;line4&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A&lt;/td&gt;&#xA;&lt;td&gt;2.3&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;3.1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;B&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;td&gt;2.2&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;C&lt;/td&gt;&#xA;&lt;td&gt;1.1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;4.6&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Let's say after optimization with certain constraints, my model will generate an optimal production allocation table similar to above. A, B, C are the three product types and the matrix displays the number of hours needed for each production line in order to finish the demand.&lt;/p&gt;&#xA;&lt;p&gt;I need to add another constraint which allows only one non-integer hour amount for each of the products. what is the easiest way or logic to do this? Please show by model.addVars() and model.addConstrs() if possible.&lt;/p&gt;&#xA;&lt;p&gt;Update:&#xA;This is what I wrote according to the answer by Rob:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;y = edm.addVars(lines, products, vtype=GRB.INTEGER)&#xA;z = edm.addVars(lines, products, vtype=GRB.BINARY)&#xA;for line in lines:&#xA;    for product in products:&#xA;        constraint1_1 = edm.addConstr(&#xA;            (&#xA;              #blocks[line, product] - y[line, product] &amp;gt;= - z[line, product]&#xA;              y[line, product] - blocks[line, product] &amp;lt;= z[line, product]&#xA;            ), &#xA;            name = 'constraint 1.1'&#xA;        )&#xA;        &#xA;        constraint1_2 = edm.addConstr(&#xA;            (&#xA;              blocks[line, product] - y[line, product] &amp;lt;= z[line, product]&#xA;            ), &#xA;            name = 'constraint 1.2'&#xA;        )&#xA;&#xA;constraint2 = edm.addConstrs(&#xA;    (&#xA;      quicksum(z[line, product] for line in lines) &amp;lt;= 1 for product in products&#xA;      ),&#xA;    name = 'constraint 2'&#xA;    )   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But my model optimization keeps running and has not given a solution for 2 hours. Any ideas what could be the issue? Thanks&lt;/p&gt;&#xA;" OwnerUserId="6149" LastEditorUserId="6149" LastEditDate="2021-09-03T04:09:31.027" LastActivityDate="2021-09-03T04:09:31.027" Title="Gurobi: how to add a constraint to make there be only one non-integer value" Tags="|mixed-integer-programming|constraint|gurobi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6852" PostTypeId="2" ParentId="6851" CreationDate="2021-09-01T00:50:41.843" Score="11" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{p,\ell}$&lt;/span&gt; be the continuous variables in your table.  Introduce integer variables &lt;span class=&quot;math-container&quot;&gt;$y_{p,\ell}$&lt;/span&gt; and binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{p,\ell}$&lt;/span&gt;, and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;-z_{p,\ell} \le x_{p,\ell} - y_{p,\ell} &amp;amp;\le z_{p,\ell} &amp;amp;&amp;amp;\text{for all $p$ and $\ell$} \tag1 \\&#xA;\sum_\ell z_{p,\ell} &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for all $p$} \tag2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$x_{p,\ell} \not= y_{p,\ell} \implies z_{p,\ell} = 1$&lt;/span&gt;.  Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; allows this to happen at most once per &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If your solver supports indicator constraints, you can replace &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$z_{p,\ell} = 0 \implies x_{p,\ell} = y_{p,\ell}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-09-02T02:28:17.743" LastActivityDate="2021-09-02T02:28:17.743" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6853" PostTypeId="2" ParentId="4943" CreationDate="2021-09-01T04:07:17.260" Score="1" Body="&lt;h1&gt;Which options to use&lt;/h1&gt;&#xA;&lt;p&gt;The problem is that the &amp;quot;time limit&amp;quot; is not handled by Pyomo (which just connects to a solver), but by the solver itself. Different solvers have different names for &amp;quot;time limit&amp;quot; options. See &lt;a href=&quot;https://stackoverflow.com/a/50950901/7951327&quot;&gt;this StackOverflow post about that&lt;/a&gt;. The &lt;code&gt;timelimit&lt;/code&gt; option you're setting above would work for CPLEX, but maybe not for GAMS (see next paragraph).&lt;/p&gt;&#xA;&lt;p&gt;I happen to use GAMS with Pyomo, and I know that GAMS uses an option called &lt;code&gt;resLim&lt;/code&gt;. &lt;a href=&quot;https://www.gams.com/33/docs/UG_OptionStatement.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;This webpage&lt;/a&gt; lists all GAMS options. Note that GAMS, like Pyomo, really just interfaces to lower-level solver executables, and some GAMS options depend on which solver you're using. The link above differentiates between &amp;quot;solver-specific&amp;quot; parameters. GAMS seems to do a good job of making this process easy - for example, the CPLEX solver has a &lt;code&gt;timelimit&lt;/code&gt; option, and GAMS will automatically pass your value for the &lt;code&gt;resLim&lt;/code&gt; option as &lt;code&gt;timelimit&lt;/code&gt; if you are calling a CPLEX solver via GAMS. (I believe you can also pass options to GAMS and specify which solver they should apply to in the case of a GAMS solver that uses subsolvers, for example &lt;code&gt;option CPLEX.timelimit=100;&lt;/code&gt;, but I can't find documentation on this).&lt;/p&gt;&#xA;&lt;h1&gt;Passing options (via Pyomo)&lt;/h1&gt;&#xA;&lt;p&gt;Usually to set a solver option, you should use &lt;code&gt;io_options&lt;/code&gt; rather than passing a keyword argument directly to &lt;code&gt;solve&lt;/code&gt; (though that may sometimes work).&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;io_options=dict(resLim=100)&#xA;results = slv.solve(model,tee=True,io_options=io_options)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that you may want to put many options for your GAMS solver in a file. This could be helpful if you call many solvers via GAMS, and you want them all to have different options specified, and you don't want this to clutter your Python code. Instead, you can just tell GAMS &amp;quot;check the DICOPT options file for DICOPT options, etc.&amp;quot;. Let's say you're using the DICOPT solver via GAMS, and you have dozens of options. You can store them in a file called &lt;code&gt;DICOPT.opt&lt;/code&gt; in your GAMS working directory that looks like this&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;max_iter 200000&#xA;resLim 100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then tell Pyomo to read from the file like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;io_options = dict(&#xA;            add_options=[&amp;quot;GAMS_MODEL.OptFile=1&amp;quot;], &#xA;            )&#xA;results = slv.solve(model,tee=True,io_options=io_options)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This tells GAMS to look for the correct file (that is, &lt;code&gt;SOLVERNAME.opt&lt;/code&gt;) and read options from it.&lt;/p&gt;&#xA;" OwnerUserId="6151" LastActivityDate="2021-09-01T04:07:17.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6854" PostTypeId="2" ParentId="6756" CreationDate="2021-09-02T07:28:31.463" Score="3" Body="&lt;p&gt;For large LPs you need an interior point solver.&lt;/p&gt;&#xA;&lt;p&gt;On top of what others have mentioned, you can use CLP's interior point method, or, interestingly, just plain old IPOPT can work perfectly fine since it will also apply an interior point algorithm.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-09-02T07:28:31.463" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6855" PostTypeId="1" AcceptedAnswerId="6856" CreationDate="2021-09-02T09:11:21.563" Score="4" ViewCount="140" Body="&lt;p&gt;I have a the following optimization problem: I have mandates,(e,g. to deliver 100 tonnes of products) that I need to schedule its delivery during the month (day 2: deliver 40 Tonnes, day 15: deliver 40 tonnes, day 28:deliver 20 tonnes, their sum is equal 100). I have limited inventory that is daily fed by the factory (forecast of production for the month is given as an input).&lt;/p&gt;&#xA;&lt;p&gt;Delivery is done using multiple vehicles with different capacities (e.g, 2T, 4T, 6T) on multiple stations along the month. For each product, a subset of stations can do the delivery, and stations can't handle more than 1 vehicle at a time.&lt;/p&gt;&#xA;&lt;p&gt;The problem can be modeled as a variant of the lot-sizing problem. However, hard to solve even for small instances because of the decision variable &lt;span class=&quot;math-container&quot;&gt;$Y_{p,t,s,c}$&lt;/span&gt; that indicate if a product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is delivered on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; on station &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; using vehicle &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;. First it has high dimensions, and second it introduces symmetry (I optimize only the stock level)&lt;/p&gt;&#xA;&lt;p&gt;However, since I don't really care on which station a product is loaded, I just need to ensure that at day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; stations are not overloaded (since two different products can use same station). Do you think removing subscript &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, and doing a row-generation in which each time I compute a solution I check if its feasible with respect to stations and I add constraint seems like a good approach? It worked on my instance but I don't know what kind of problems it may add if more complex instances are being solved.&lt;/p&gt;&#xA;&lt;p&gt;Edit: The model is:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbb{J}$&lt;/span&gt; be the set of all stations.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbb{P}$&lt;/span&gt; be the set of all products.&#xA;Moreover, let &lt;span class=&quot;math-container&quot;&gt;$\mathbb{T}$&lt;/span&gt; be the set of time periods.&#xA;Finally, let &lt;span class=&quot;math-container&quot;&gt;$\mathbb{C}$&lt;/span&gt; be the set of all vehicles&lt;/p&gt;&#xA;&lt;p&gt;The optimization variables and parameters are the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{p,t,j,c}$&lt;/span&gt; continuous variable that denotes the quantity of product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; that is served at time &lt;span class=&quot;math-container&quot;&gt;$t \in \mathbb{T}$&lt;/span&gt; on station &lt;span class=&quot;math-container&quot;&gt;$j \in \mathbb{J}$&lt;/span&gt; using vehicle &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Y_{p,t,j,c}$&lt;/span&gt; binary variable product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; that is served at time &lt;span class=&quot;math-container&quot;&gt;$t \in \mathbb{T}$&lt;/span&gt; on station &lt;span class=&quot;math-container&quot;&gt;$j \in \mathbb{J}$&lt;/span&gt; using vehicle &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_{p,t}$&lt;/span&gt; level of stock of product &lt;span class=&quot;math-container&quot;&gt;$p \in \mathbb{P}$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t \in \mathbb{T}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_{p,t}$&lt;/span&gt; is the daily production of product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;. input to the model&lt;/p&gt;&#xA;&lt;p&gt;The objective function is to stay as close as possible to a given inventory target&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_p \sum_t \lvert S_{p,t} - Target_p \rvert \tag{1}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Mandate fulfillment constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;  \sum_t \sum_j \sum_c x_{p,t,j,c} = Mandate_p \; \forall p \tag{2}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Flow balance constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;  S_{p,t} = S_{p,t-1} + d_{p,t} - \sum_{j}\sum_{c} x_{p,t,j,c}  \; \forall p \in P, \; \forall t \in T \tag{3}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Stock limits:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;  Min_p \leq S_{p,t} \leq Max_p, \forall p \forall t \tag{4}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Stations constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_p \sum_c Cap_c Y_{p,t,j,c} \leq MaxCap_j \forall j, \forall t \tag{5}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Fixed charge constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{p,t,j,c} \le Cap_c*Y_{p,t,j,c}, \forall p, \forall t, \forall j, \forall c \tag{6}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Choose the vehicle:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{p,t,j,c} + 1000 \geq Cap_c*Y_{p,t,j,c}, \forall p, \forall t, \forall j, \forall c \tag{7}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Limited vehicle per product (not have a solution with small quantities delivered every day):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_t \sum_j \sum_c Y_{p,t,j,c} \leq MaxVehicle_p ,  \forall p \tag{8}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I fix the value of variable &lt;span class=&quot;math-container&quot;&gt;$Y_{p,t,j,c}$&lt;/span&gt; to zero when the station is incompatible.&lt;/p&gt;&#xA;" OwnerUserId="6016" LastEditorUserId="2556" LastEditDate="2021-09-02T14:34:22.507" LastActivityDate="2021-09-02T15:25:59.540" Title="Lot-sizing problem variant" Tags="|mixed-integer-programming|modeling|constraint|combinatorial-optimization|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6856" PostTypeId="2" ParentId="6855" CreationDate="2021-09-02T14:59:55.670" Score="4" Body="&lt;p&gt;You could try and get rid of variables &lt;span class=&quot;math-container&quot;&gt;$Y_{p,t,j,c}$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;remove constraints &lt;span class=&quot;math-container&quot;&gt;$(6)-(7)$&lt;/span&gt;; constraints &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt; simply link &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; variables, so removing them should not have any impact on the feasibility of the solution (assuming you remove &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; variables) ; constraints &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt; are not mandatory if my understanding is correct&lt;/li&gt;&#xA;&lt;li&gt;replace constraints &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; by&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{p,c} x_{p,t,j,c}  \le MaxCap_j \\&#xA;x_{p,t,j,c} \le Cap_c&#xA;$$&lt;/span&gt;&#xA;This way, you are replacing &lt;span class=&quot;math-container&quot;&gt;$Cap_c Y_{p,t,j,c}$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$x_{p,t,j,c}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;replace constraints &lt;span class=&quot;math-container&quot;&gt;$(8)$&lt;/span&gt; by&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{t,j,c} \frac{x_{p,t,j,c}}{Cap_c} \le MaxVehicle_p &#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{t,j,c} \frac{x_{p,t,j,c}}{Cap_c}$&lt;/span&gt; is an approximation of the number of vehicles used for product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;. This may need some tweaking, as ideally you would need &lt;span class=&quot;math-container&quot;&gt;$\sum_{t,j,c} \left\lceil \frac{x_{p,t,j,c}}{Cap_c} \right \rceil \le MaxVehicle_p$&lt;/span&gt;. If your vehicles are nearly full, then the approximation should not be too bad.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-09-02T15:25:59.540" LastActivityDate="2021-09-02T15:25:59.540" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6857" PostTypeId="1" AcceptedAnswerId="6858" CreationDate="2021-09-02T16:02:05.667" Score="4" ViewCount="606" Body="&lt;p&gt;The problem being solved is finding the truss with the least weight, exactly done as on this website: &lt;a href=&quot;https://www.layopt.com/truss/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.layopt.com/truss/&lt;/a&gt;. This method is also called the ground structure method. I am aiming to add some functionallity to the method through an MILP optimization. Initially, I started with the &lt;code&gt;cvxpy&lt;/code&gt; Linear Programming (LP) solver but since it can't solve MILP I am now using the IBM ILOG CPLEX solver with the python module docplex. Unfortunately I am bumping into an problem, but first in short how the optimization works is:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Initialize: Make nodes, place a load (&lt;code&gt;f&lt;/code&gt;) and supports (&lt;code&gt;dof&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Make the potential members of the truss, with full connectivity all the nodes will be connected with each other. These potential members will form the truss and every member has two variables &lt;code&gt;a&lt;/code&gt; (area) and &lt;code&gt;q&lt;/code&gt;  (internal force) and a length &lt;code&gt;l&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Calculate the nodal equilibrium matrix &lt;code&gt;B&lt;/code&gt;, which is guaranteed sparce and symmetric.&lt;/li&gt;&#xA;&lt;li&gt;Build the LP-model, which is done via calling the &lt;code&gt;Model()&lt;/code&gt; object and start solving it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The formulation is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{ll}&#xA;\text{minimize}  &amp;amp; V = l^T a \\&#xA;\text{subject to}&amp;amp; B q = f \\&#xA;&amp;amp; q \le \sigma  a \\&#xA;&amp;amp; q \ge -\sigma  a \\&#xA;&amp;amp; a \ge 0 \\&#xA;\end{array}&lt;/span&gt;&#xA;In code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;build the model&amp;quot;&#xA;model = Model()&#xA;a = model.continuous_var_list(len(members), name='a', lb=0, ub=1)&#xA;q = []&#xA;Bcons = []&#xA;for k, fk in enumerate(f):&#xA;    qk = model.continuous_var_list(len(members), name=f'q{k}', lb=-10 ** 10, ub=10 ** 10)&#xA;    Bconsk = model.add_constraints(&#xA;        sum(B[i, j] * qk[j] for j in range(len(qk))) == fk[i] for i in range(len(dof)) if dof[i] != 0)&#xA;    model.add_constraints(qk[i] &amp;lt;= sigma * a[i] for i in range(len(qk)))&#xA;    model.add_constraints(qk[i] &amp;gt;= -sigma * a[i] for i in range(len(qk)))&#xA;    q.append(qk)&#xA;    Bcons.append(Bconsk)&#xA;model.set_objective('min', sum(a[i] * l[i] for i in range(len(a))))  &#xA;model.print_information()&#xA;&#xA;&amp;quot;solve model and update results&amp;quot;&#xA;sol = model.solve()&#xA;print(model.solve_details)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For small problem sizes (less than 1000 members) the LP converges in the CPLEX solver and works perfectly. However for larger problem sizes (e.g. more than 10 000 members) the problem is &lt;strong&gt;'optimal with unscaled infeasibilities'&lt;/strong&gt;. What does this mean and how can I solve this?&lt;/p&gt;&#xA;&lt;p&gt;What I tried so far:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Solving the same problem in cvxpy. This module can solve up to 120 000 members without any problems.. So I actually would expect that the professional solver can also do this.&lt;/li&gt;&#xA;&lt;li&gt;Found &lt;a href=&quot;https://www-eio.upc.es/lceio/manuals/cplex-11/html/usrcplex/solveLP19.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Coping with an Ill-Conditioned Problem or Handling Unscaled Infeasibilities&lt;/a&gt;, but I cant find any scaling parameters in the module &lt;code&gt;docplex&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;..&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Results:&#xA;Nodes: 231 Members: 16290&#xA;Model: docplex_model1&#xA; - number of variables: 32580&#xA;   - binary=0, integer=0, continuous=32580&#xA; - number of constraints: 33038&#xA;   - linear=33038&#xA; - parameters: defaults&#xA; - objective: minimize&#xA; - problem type is: LP&#xA;status  = optimal with unscaled infeasibilities&#xA;time    = 131.297 s.&#xA;problem = LP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7154" LastActivityDate="2021-09-02T17:53:08.987" Title="LP solver CPLEX is 'optimal with unscaled infeasabilities'?" Tags="|linear-programming|cplex|docplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6858" PostTypeId="2" ParentId="6857" CreationDate="2021-09-02T17:53:08.987" Score="4" Body="&lt;p&gt;When you turn CPLEX loose on a model, it runs a presolver that does assorted magic tricks that end up with a modified model. It then solves the modified model and, assuming it finds a solution to the modified model, transforms that solution back to the original model. I believe that the &amp;quot;unscaled infeasibilities&amp;quot; message means that CPLEX found what it considered an optimal solution to the modified model, converted it to a solution to the original model, and discovered that the solution to the original model violated the constraint tolerance in one or more constraints.&lt;/p&gt;&#xA;&lt;p&gt;One thing you can do is plug the CPLEX solution into your constraints yourself, evaluate them, and decide if they are satisfied to within an acceptable tolerance. Another possibility is to look at the range of coefficient sizes in the constraints. If you have any really large and/or really small (but nonzero) coefficients, or worse yet a mix of the two, you might have numerical difficulties (ill-conditioning). That's not the only source of ill-conditioning, but it is arguably the most common. A test of ill-conditioning is to look at the kappa value of the final basis matrix. If that's the case, you might ask yourself whether you can shrink some of the big coefficients or enlarge some of the small ones, perhaps by changing units in a consistent manner.&lt;/p&gt;&#xA;&lt;p&gt;One more thing to try is to turn on CPLEX numerical emphasis parameter, which basically tells CPLEX that there are likely to be numerical adventures and that it should try extra hard to compensate.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-09-02T17:53:08.987" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6859" PostTypeId="1" CreationDate="2021-09-03T03:18:34.177" Score="3" ViewCount="242" Body="&lt;p&gt;Sorry to ask a question about the basic Markowitz portfolio optimization. The example is from Mosek's example book.&lt;/p&gt;&#xA;&lt;p&gt;The basic Markowitz portfolio optimization is formulated as:&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/0kBl9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0kBl9.png&quot; alt=&quot;here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The book mentioned we can simply remove the constraint &lt;span class=&quot;math-container&quot;&gt;$x \ge 0$&lt;/span&gt; to allow short-sell in this formulation.&lt;/p&gt;&#xA;&lt;p&gt;However, my question is about the conic formulation of original problem, which was given as: &lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/JkDXl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JkDXl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assuming we similarly remove the constraint &lt;span class=&quot;math-container&quot;&gt;$x \ge 0$&lt;/span&gt; in this conic formulation, will it allow short-sell, i.e. &lt;span class=&quot;math-container&quot;&gt;$x \lt 0$&lt;/span&gt;? My feeling is yes since the cone &lt;span class=&quot;math-container&quot;&gt;$Q^{n+1}$&lt;/span&gt; only requires &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; which is &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; to be non-negative. I tried to change the sample codes below to remove the non-negativity constraint.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/G4JPT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/G4JPT.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But the results seems to be the same. Just would like to confirm if my understanding is correct.&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="6060" LastActivityDate="2021-09-03T06:36:04.840" Title="Are short-sell allowed in conic formulation of Markowitz optimization?" Tags="|optimization|mosek|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6860" PostTypeId="2" ParentId="6859" CreationDate="2021-09-03T04:34:03.013" Score="5" Body="&lt;p&gt;Yes, of course you can remove the &lt;span class=&quot;math-container&quot;&gt;$x\ge0$&lt;/span&gt; constraint if you like.&lt;/p&gt;&#xA;&lt;p&gt;Maybe your data is such that that short selling is not worthwhile.&#xA;Hard to say.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="123" LastEditDate="2021-09-03T06:36:04.840" LastActivityDate="2021-09-03T06:36:04.840" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6861" PostTypeId="1" AcceptedAnswerId="6865" CreationDate="2021-09-03T05:38:54.007" Score="4" ViewCount="179" Body="&lt;p&gt;I'm working on a inventory optimization problem where inventory used at a time-period is computed based on price-bucket that is selected for an item. Problem contains multiple items (around 10K), 15-20 time-periods and 10-15 price buckets. Inventory consumed at a time-period (t) is minimum of available inventory and demand (which is dependent on price bucket selected). This  particular constraint is making problem harder (not able to obtain optimal solution even in 30 mins for above scale using commercial solver) and my current modeling is shown below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;&amp;amp;\mathcal{I} \quad \text{set of items (indexed by $i$)}\\&#xA;&amp;amp;\mathcal{T} \quad \text{set of time-periods (indexed by $t$)}\\&#xA;&amp;amp;\mathcal{K} \quad \text{set of price-buckets (indexed by $k$)}\\&#xA;&amp;amp;D_{i,t,k} \quad \text{demand of item $i$ for time-period $t$ at price-bucket $k$}  \\&#xA;&amp;amp;z_{i,t,k}  \quad \text{binary variable takes value 1 if $k^{th}$ price-bucket is selected for item-i for time-period $t$} &#xA;\end{align*}&#xA;$$&lt;/span&gt;&#xA;As mentioned above, Inventory catered (&lt;span class=&quot;math-container&quot;&gt;$q_{i,t}^{supplied}$&lt;/span&gt;) at time-period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is computed as minimum of available inventory (&lt;span class=&quot;math-container&quot;&gt;$q_{i,t}$&lt;/span&gt;) and posed demand (&lt;span class=&quot;math-container&quot;&gt;$\sum_{k}D_{i,t,k} \cdot z_{i,t,k}$&lt;/span&gt;). Linearization of this is achieved by following constraints.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;q_{i,t}^{supplied} &amp;amp;\le q_{i,t} \\&#xA;q_{i,t}^{supplied} &amp;amp;\le \sum_{k}D_{i,t,k} \cdot z_{i,t,k} \\&#xA;q_{i,t}^{supplied} &amp;amp;\ge q_{i,t} - M^{big} \cdot \delta_{i,t} \\&#xA;q_{i,t}^{supplied} &amp;amp;\ge \sum_{k}D_{i,t,k} \cdot z_{i,t,k}  - M^{big} \cdot (1-\delta_{i,t})&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\delta_{i,t}$&lt;/span&gt; is a binary variable. Big-M's are chosen as tight as possible. These set of constraints are taking time while solving. Please suggest for any possible alternate formulation to achieve this or any references would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2021-09-06T15:17:26.120" Title="Alternate formulation for modeling inventory constraints" Tags="|mixed-integer-programming|linear-programming|linearization|inventory|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6862" PostTypeId="1" CreationDate="2021-09-03T07:42:23.963" Score="9" ViewCount="507" Body="&lt;p&gt;Improvement heuristics for the TSP like 2-Opt need construction heuristics (also called constructive heuristics) like the Nearest Neighbour to start. Intuitively, I would say that a better construction heuristic leads on average to better results for the improvement heuristic. I think this is difficult to prove because a worse initial solution could nevertheless lead to the global optimum. Is there a prove or anything else that makes a statement about the dependency of the quality of improvement heuristics and construction heuristics?&lt;/p&gt;&#xA;&lt;p&gt;Or more generally speaking: Do better-starting solutions lead to better performances of improvement heuristics?&lt;/p&gt;&#xA;" OwnerUserId="5571" LastEditorUserId="36" LastEditDate="2021-09-03T12:33:05.597" LastActivityDate="2021-09-23T15:22:01.073" Title="Do better construction heuristics increase the performance of improvement heuristics?" Tags="|traveling-salesman|heuristics|metaheuristics|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6863" PostTypeId="2" ParentId="6862" CreationDate="2021-09-03T12:09:55.213" Score="1" Body="&lt;p&gt;There is a mathematically justified way of saying is better than the other. The expected time to solve over all problems. When the expected value can't be computed over the distribution of problems you care about you can sample that space and run both approaches for both. This is called benchmarking and with sufficient samples the benchmark numbers will converge against the expectation values.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-09-03T12:09:55.213" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6864" PostTypeId="2" ParentId="6862" CreationDate="2021-09-03T13:32:10.953" Score="3" Body="&lt;p&gt;I am not aware of such proof. I think your question may be meaningful given a specific improvement heuristic. For example, I worked on solving large scale VRP problems using genetic algorithms as the meta-heuristic and doing local search to improve solutions. In this case, randomly generated initial solutions performed much better for me than using well-crafted construction heuristics. However, when using Large Neighborhood search, good quality initial solution gave better results. So I personally like to think that the construction + improvement heuristic are different parts of the same algorithm. And in this case, benchmarking multiple construction heuristics as suggest by @worldsmithhelper is the way to go.&lt;/p&gt;&#xA;" OwnerUserId="6016" LastActivityDate="2021-09-03T13:32:10.953" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6865" PostTypeId="2" ParentId="6861" CreationDate="2021-09-03T20:22:38.140" Score="4" Body="&lt;p&gt;If, given inventory level (&lt;span class=&quot;math-container&quot;&gt;$q_{i,t}$&lt;/span&gt;) and bucket decisions (&lt;span class=&quot;math-container&quot;&gt;$z_{i,t,k}$&lt;/span&gt;), profit is maximized by maximizing the supplied quantities, you probably can drop the big M constraints and trust the objective to prevent selection of a supplied quantity less than the min of the two upper limits. As an experiment, you could try running without those constraints and see if in fact the solution satisfied the min constraints.&lt;/p&gt;&#xA;&lt;p&gt;Otherwise, I'm not sure there is a better formulation. You could try combinatorial Benders cuts [1] in lieu of the big M constraints, but I'm not sure that would be faster (particularly if your values of M are fairly tight), and you likely would want a solver that supported user callbacks. Another possible reformulation would be to introduce new continuous variables &lt;span class=&quot;math-container&quot;&gt;$w_{i,t,k}\in [0,1]$&lt;/span&gt; along with the constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;w_{i,t,k} &amp;amp; \le z_{i,t,k}\\&#xA;w_{i,t,k} &amp;amp; \le \delta_{i,t}\\&#xA;w_{i,t,k} &amp;amp; \ge z_{i,t,k}+\delta_{i,t}-1.&#xA;\end{align*}&lt;/span&gt;&#xA;Collectively, those constraints force &lt;span class=&quot;math-container&quot;&gt;$w_{i,t,k}=z_{i,t,k}\delta_{i,t}$&lt;/span&gt;. You can now replace your fourth constraints with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$q_{i,t}^{supplied} \ge \sum_{k}D_{i,t,k}  w_{i,t,k}.$$&lt;/span&gt;&#xA;That eliminates half the big M constraints, but still leaves the other half. (I'm assuming that available inventory &lt;span class=&quot;math-container&quot;&gt;$q_{i,t}$&lt;/span&gt; is a variable and not a parameter.)&lt;/p&gt;&#xA;&lt;p&gt;[1] Codato, G. and Fischetti, M. (2006) Combinatorial Benders' Cuts for Mixed-Integer Linear Programming. &lt;em&gt;Operations Research&lt;/em&gt;, Vol. 54(4), pp. 756-766.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-09-06T15:17:26.120" LastActivityDate="2021-09-06T15:17:26.120" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6866" PostTypeId="1" CreationDate="2021-09-03T20:53:10.250" Score="11" ViewCount="971" Body="&lt;p&gt;Perhaps a silly question, I know... But just wondering if the programming language has an impact here if the solver used is the same? For instance, the same model formulation being solved using Gurobi in Python vs C++... Is the solver all that matters?&#xA;Here I'm considering only general purpose programming languages and excluding languages such as AMPL as afaik it has some presolver mechanisms to simplify a problem.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="123" LastEditDate="2021-09-04T08:20:12.737" LastActivityDate="2021-09-06T12:31:59.363" Title="From a performance/speed perspective, does the programming language matter if the solver used is the same?" Tags="|optimization|solver|modeling-languages|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6867" PostTypeId="1" CreationDate="2021-09-03T21:21:18.290" Score="2" ViewCount="231" Body="&lt;p&gt;Below is a model for maximizing a utility function, a blending of, 3 ingredients &lt;span class=&quot;math-container&quot;&gt;$(A, B,C)$&lt;/span&gt; to obtain  3 mixes of fertilizer, with the recipe given as proportions. Ingredients cost &lt;span class=&quot;math-container&quot;&gt;$A=130,\ B=150,\ C=100$&lt;/span&gt;, benefit per fertilizer &lt;span class=&quot;math-container&quot;&gt;$F1=200, F2=300, F3=150$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: left;&quot;&gt;Recipe&lt;/th&gt;&#xA;&lt;th&gt;Resource Availability&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;strong&gt;Fertilizer 1&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$A \ge 25 \%$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B\le40\%$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$A=4000$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;strong&gt;Fertilizer 2&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$A \ge 30\%$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$20\%\le B \le 30%$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$C\le15\%$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$B =6000$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;strong&gt;Fertilizer 3&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$C \le 15\%$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$C=2000$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;&lt;strong&gt;Model&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objective:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \max z= 10(7x_{11}+20x_{12}+20x_{13}+2x_{21}+15x_{22}+30x_{23}-8x_{31}+5x_{32}-10x_{33})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}0.75 x_{11}-0.25 x_{12}-0.25 x_{13} &amp;amp;\ge 0\\&#xA;-0.40 x_{11}-0.40 x_{12}+0.60 x_{13} &amp;amp;\le 0\\&#xA;0.70 x_{21}-0.30 x_{22}+ -0.30 x_{23}&amp;amp;\ge 0\\&#xA;-0.20 x_{21}+0.80 x_{22}-0.20 x_{23}&amp;amp;\ge 0\\&#xA;-0.30 x_{21}+0.70 x_{22}-0.30 x_{23} &amp;amp;\le 0\\&#xA;-0.15 x_{21} -0.15 x_{22} + 0.85 x_{23} &amp;amp;\le 0\\&#xA;-0.35 x_{31}+ 0.65 x_{32}-0.35 x_{33} &amp;amp;\ge 0\\&#xA;x_{11}+ x_{21}+ x_{31}&amp;amp;\le 4000\\&#xA;x_{12}+ x_{22}+ x_{32}&amp;amp;\le 6000\\&#xA;x_{13}+ x_{23}+ x_{33}&amp;amp;\le 2000 &#xA;\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{ij}\ge 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is uncertain to me how to proceed in building the constraint matrix &lt;span class=&quot;math-container&quot;&gt;$CM$&lt;/span&gt;, the first seven rows are:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$CM=\begin{pmatrix}&#xA;0.75 &amp;amp; -0.25 &amp;amp; -0.25\\&#xA;-0.4 &amp;amp; -0.4 &amp;amp; 0.6\\&#xA;0.7 &amp;amp; -0.3 &amp;amp; -0.3\\&#xA;-0.2 &amp;amp; 0.8 &amp;amp; -0.2\\&#xA;-0.3 &amp;amp; 0.7 &amp;amp; -0.3\\&#xA;-0.15 &amp;amp; -0.15 &amp;amp; 0.85\\&#xA;-0.35 &amp;amp; 0.65 &amp;amp; -0.35\\&#xA;\end{pmatrix}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then to me, the next row is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{11}\le 4000-(x_{12}+x_{13})\Rightarrow (1,0,0)\le 4000-(x_{12}+x_{13})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So that for all the resource constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{pmatrix}&#xA;0.75 &amp;amp; -0.25 &amp;amp; -0.25\\&#xA;-0.4 &amp;amp; -0.4 &amp;amp; 0.6\\&#xA;0.7 &amp;amp; -0.3 &amp;amp; -0.3\\&#xA;-0.2 &amp;amp; 0.8 &amp;amp; -0.2\\&#xA;-0.3 &amp;amp; 0.7 &amp;amp; -0.3\\&#xA;-0.15 &amp;amp; -0.15 &amp;amp; 0.85\\&#xA;-0.35 &amp;amp; 0.65 &amp;amp; -0.35\\&#xA;1&amp;amp;0&amp;amp;0\\&#xA;0&amp;amp;1&amp;amp;0\\&#xA;0&amp;amp;0&amp;amp;1\\&#xA;1&amp;amp;0&amp;amp;0\\&#xA;0&amp;amp;1&amp;amp;0\\&#xA;0&amp;amp;0&amp;amp;1\\&#xA;1&amp;amp;0&amp;amp;0\\&#xA;0&amp;amp;1&amp;amp;0\\&#xA;0&amp;amp;0&amp;amp;1&#xA;\end{pmatrix}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But then the right hand side &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}= \begin{pmatrix}0&amp;amp;0&amp;amp;0&amp;amp;0&amp;amp;0&amp;amp;0&amp;amp;0&amp;amp;4000 -(x_{12}+x_{13}) \ldots \end{pmatrix} $&lt;/span&gt; gets nine rows of algebraic expressions, not nice, so what's the right way? Maybe just (1,1,1) the last 3 rows.&lt;/p&gt;&#xA;&lt;p&gt;There's one last thing about the constraints they look redundant, does that mean the fertilizer mixes are the same or almost the same, so the problem is infeasible?&lt;/p&gt;&#xA;" OwnerUserId="7162" LastEditorUserId="36" LastEditDate="2021-09-03T22:11:13.217" LastActivityDate="2021-09-04T00:06:14.323" Title="How to write the constraint matrix for this blending problem?" Tags="|linear-programming|constraint|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6869" PostTypeId="2" ParentId="6866" CreationDate="2021-09-04T00:29:48.160" Score="13" Body="&lt;p&gt;The programming language used to setup the problem can matter under two circumstances. One is setup time of the problem this not only differs by programming language but also by the Gurobi interface used &lt;a href=&quot;https://assets.gurobi.com/pdfs/user-events/2016-frankfurt/Troubleshooting.pdf&quot; rel=&quot;noreferrer&quot;&gt;See page 30+&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The other situations in which it might matter are user callbacks. If one programming language is slower at those time spent in these is not available for the solver.&lt;/p&gt;&#xA;&lt;p&gt;I am aware of situations where the Gurobi solver was perceived as slow by the user when the super majority of the time was spent setting up Gurobi while the problem was solved almost instantly &lt;a href=&quot;https://assets.gurobi.com/pdfs/user-events/2017-frankfurt/Introduction-to-Tuning.pdf&quot; rel=&quot;noreferrer&quot;&gt;See page 5&lt;/a&gt;. Your programming language and in particular your modeling language can matter. However switching languages can never provide more savings than the sum of setup time and time spend in usercall backs. Gurobi allows you to track the second.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-09-04T00:29:48.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6871" PostTypeId="2" ParentId="6866" CreationDate="2021-09-04T06:42:47.140" Score="3" Body="&lt;p&gt;As far as I know, the core of many of the mathematical optimization solvers have been designed with C/C++ and other programming languages are treating as an exchange layer. It does not affect directly the solving time, but for the pre-processing or post-processing, it is important. For example, I am aware that initializing/manipulating data with python might be somewhat slower than others like java.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-09-04T06:42:47.140" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6872" PostTypeId="2" ParentId="6862" CreationDate="2021-09-04T07:49:21.927" Score="8" Body="&lt;p&gt;There are some proofs of the contrary: whatever the starting point, your local search can be stuck in solutions far away from the optimum. Here &amp;quot;local&amp;quot; means that each iteration must be done in polynomial time. Check the seminal paper &lt;a href=&quot;https://epubs.siam.org/doi/abs/10.1137/0206005&quot; rel=&quot;noreferrer&quot;&gt;&amp;quot;On the Complexity of Local Search for the Traveling Salesman Problem&amp;quot; by Papadimitriou and Steiglitz&lt;/a&gt; on this topic.&lt;/p&gt;&#xA;&lt;p&gt;As usual, in practice, things are much different than in theoretical worst-case analysis. Initial solutions can have a huge impact on the quality of the solutions reached by neighborhood search. In particular, a general practical observation is: the more your neighborhoods are small, the more your diversification strategy is poor, the more the combinatorial landscape is rugged, then the more initial solutions are critical in reaching high-quality solutions.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastActivityDate="2021-09-04T07:49:21.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6873" PostTypeId="2" ParentId="6756" CreationDate="2021-09-04T14:23:59.337" Score="9" Body="&lt;p&gt;The Mittlemann benchmarks are an excellent benchmark as ever in particular these two:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://plato.asu.edu/ftp/lpbar.html&quot; rel=&quot;noreferrer&quot;&gt;Benchmark of Barrier LP solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://plato.asu.edu/ftp/network.html&quot; rel=&quot;noreferrer&quot;&gt;Large Network-LP Benchmark (commercial vs free)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note that Pyomo doesn't have bindings for most of these locally. If you are  just looking for high-level modeling language and are not tied to Python you could use the JuMP modeling language instead which uses Julia. Julia's excellent package system means many Open Source solvers are only an &lt;code&gt;]add Tulip&lt;/code&gt;, &lt;code&gt;]add Ipopt&lt;/code&gt;, &lt;code&gt;]add HiGHS&lt;/code&gt; (you should be aware this binding it is still under active development see &lt;a href=&quot;https://github.com/jump-dev/HiGHS.jl/blob/master/README.md&quot; rel=&quot;noreferrer&quot;&gt;GitHub&lt;/a&gt; for details) or &lt;code&gt;]add Clp&lt;/code&gt; in the command line away.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-09-06T00:23:46.167" LastActivityDate="2021-09-06T00:23:46.167" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6874" PostTypeId="1" AcceptedAnswerId="6875" CreationDate="2021-09-06T09:45:05.833" Score="7" ViewCount="369" Body="&lt;p&gt;Given are two integer variables &lt;span class=&quot;math-container&quot;&gt;$L_x \leq x \leq U_x$&lt;/span&gt; and&#xA;&lt;span class=&quot;math-container&quot;&gt;$L_y \leq y \leq U_y$&lt;/span&gt;. I'd like to formulate the constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\text{If} \;\; x = k, \;\; \text{  then  } \;\; y = c,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; are given integer constants. Any help is highly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="7172" LastActivityDate="2021-09-06T13:46:13.677" Title="How to formulate the constraint If $x = k$, then $y = c$?" Tags="|mixed-integer-programming|modeling|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6875" PostTypeId="2" ParentId="6874" CreationDate="2021-09-06T10:13:31.113" Score="10" Body="&lt;p&gt;By introducing the binary helper variables &lt;span class=&quot;math-container&quot;&gt;$z_1,z_2,z_3,w_1,w_2,w_3$&lt;/span&gt;, you can use the constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;L_y z_1 + c z_2 + (c+1)z_3 &amp;amp;\leq y \leq (c-1)z_1 + c z_2 + U_y z_3, \tag{1} \\&#xA;L_x w_1 + k w_2 + (k+1)w_3 &amp;amp;\leq x \leq (k-1)w_1 + k w_2 + U_x w_3, \tag{2}\\&#xA;z_1 + z_2 + z_3 &amp;amp;= 1, \tag{3}\\&#xA;w_1 + w_2 + w_3 &amp;amp;= 1, \tag{4}\\&#xA;z_1 + z_3 &amp;amp;\leq w_1 + w_3 \tag{5}.&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Explanation: The constraint &lt;span class=&quot;math-container&quot;&gt;$x = k \implies y = c$&lt;/span&gt; is equivalent to the contraposition &lt;span class=&quot;math-container&quot;&gt;$y \neq c \implies x \neq k$&lt;/span&gt;. Hence, we want to formulate&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y \leq c - 1 \;\vee\; y \geq c+1 \implies x \leq k-1 \; \vee \; x \geq k+1. \tag{*}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, (1) and (2) model the constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;z_1 = 1 &amp;amp;\implies y \leq c - 1, \\&#xA;z_2 = 1 &amp;amp;\implies y = c, \\&#xA;z_3 = 1 &amp;amp;\implies y \geq c + 1, \\&#xA;w_1 = 1 &amp;amp;\implies x \leq k - 1, \\&#xA;w_2 = 1 &amp;amp;\implies x = k, \\&#xA;w_3 = 1 &amp;amp;\implies x \geq k + 1, \\&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;while (3) and (4) guarantee that only one of the three cases for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; can appear. Finally, (5) expresses constraint (*) by means of the binary helper variables.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="3696" LastEditDate="2021-09-06T12:04:46.190" LastActivityDate="2021-09-06T12:04:46.190" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6876" PostTypeId="2" ParentId="6874" CreationDate="2021-09-06T10:39:00.760" Score="3" Body="&lt;p&gt;Introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; and we can write following constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;k \cdot \delta + L_{x} \cdot (1-\delta) &amp;amp;\le x \le k \cdot \delta + U_{x} \cdot (1-\delta) \\&#xA;c \cdot \delta + L_{y} \cdot (1-\delta) &amp;amp;\le y \le c \cdot \delta + U_{y} \cdot (1-\delta) \\&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;The way it works is when &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; equals &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x = k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y = c$&lt;/span&gt; and when &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; equals 0, they take feasible bounds.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastEditorUserId="123" LastEditDate="2021-09-06T13:46:13.677" LastActivityDate="2021-09-06T13:46:13.677" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="6877" PostTypeId="2" ParentId="6866" CreationDate="2021-09-06T12:15:33.003" Score="4" Body="&lt;p&gt;For &lt;a href=&quot;https://www.optaplanner.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner&lt;/a&gt; (implemented in Java), we have done benchmarks and see &lt;strong&gt;no performance difference between use cases implemented in Java or Kotlin&lt;/strong&gt;. This is no surprise, because both are running on a JVM. For other JVM languages Scala, Groovy, JRuby, Closure, ..., we haven't run enough benchmarks yet, but as far as I can tell, they are in the same ballpark, maybe a bit slower.&lt;/p&gt;&#xA;&lt;p&gt;That being said, the version of JVM and the garbage collector have a &lt;a href=&quot;https://www.optaplanner.org/blog/2021/01/26/HowMuchFasterIsJava15.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;severe impact on performance&lt;/a&gt;. Basically, the latest JVM is always faster, and a high-throughput GC is always faster than a low-latency GC. No surprises there.&lt;/p&gt;&#xA;&lt;p&gt;For &lt;a href=&quot;https://github.com/optapy&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPy&lt;/a&gt;, &lt;strong&gt;use cases implemented in Python with OptaPy are currently at least 20x slower&lt;/strong&gt; than those implemented in Java with OptaPlanner. It's unclear how much is to due to the JPype magic that allows us to run in a plain Python environment. We're working with them upstream to minimize this loss.&lt;/p&gt;&#xA;&lt;p&gt;We also did some experiments in GraalPython, which are significantly faster than JPype, but don't allow us to run in a plain Python environment. The Graal guys have several benchmarks for which graalpython is significantly faster than plain python, but graalpython is not feature complete yet IIRC.&lt;/p&gt;&#xA;&lt;p&gt;Your mileage may vary.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2021-09-06T12:31:59.363" LastActivityDate="2021-09-06T12:31:59.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6878" PostTypeId="2" ParentId="6874" CreationDate="2021-09-06T12:34:26.270" Score="5" Body="&lt;p&gt;In OPL CPLEX this is very easy to read and write.&lt;/p&gt;&#xA;&lt;p&gt;Let me change &lt;a href=&quot;https://github.com/AlexFleischerParis/zooopl/blob/master/zooifthen.mod&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/AlexFleischerParis/zooopl/blob/master/zooifthen.mod&lt;/a&gt; to your exact question:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(nbBus40==6)=&amp;gt;(nbBus30==3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;means nbBus40==6 implies nbBus30==3&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int nbKids=300;&#xA;float costBus40=500;&#xA;float costBus30=400;&#xA; &#xA;dvar int+ nbBus40;&#xA;dvar int+ nbBus30;&#xA;minimize&#xA; costBus40*nbBus40  +nbBus30*costBus30;&#xA; &#xA;subject to&#xA;{&#xA; 40*nbBus40+nbBus30*30&amp;gt;=nbKids;&#xA; &#xA; // with if nb buses 40 is 6 then nb buses 30 is 3&#xA; &#xA; (nbBus40==6)=&amp;gt;(nbBus30==3);&#xA; &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-09-06T12:34:26.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6879" PostTypeId="2" ParentId="6846" CreationDate="2021-09-07T06:41:21.327" Score="3" Body="&lt;p&gt;In OPL CPLEX you could start with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int g=10;&#xA;range G=1..g;&#xA;range I=1..5;&#xA;&#xA;{int} Ng[G]=[{1,2},{3,4},{5},{},{},&#xA;{},{},{},{},{}];&#xA;&#xA;dvar boolean u[G];&#xA;&#xA;subject to&#xA;{&#xA;  forall(i in I) sum(g in G:i in Ng[g]) u[g]==1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-09-07T06:41:21.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6880" PostTypeId="1" CreationDate="2021-09-07T07:43:28.053" Score="1" ViewCount="102" Body="&lt;p&gt;I have to work on some real world data and come up with an optimization technique to handle cargo.&lt;/p&gt;&#xA;&lt;p&gt;To make thing simpler let's assume that there are 2 types of resources&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Manpower (150 ton / 8 hour)&lt;/li&gt;&#xA;&lt;li&gt;Fork lifter (1 ton / 1 hour / 1 man)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So each person can work a max of 8 hours and within those 8 hours he can handle 150 tons. In case of fork lifter a fork lifter can handle 1 ton per hour and also requires a person to operate it. &lt;strong&gt;(Note: The person operating the fork lifter should not be confused with the manpower.)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assuming that we want to handle &lt;code&gt;X&lt;/code&gt; tons of cargo in &lt;code&gt;h&lt;/code&gt; Hours and find the optimal number of resources required to handle the cargo. What algorithms can be used to tackle such problems? Is there any literature for such problem?&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, if we are provided with cost against these resources such that&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Manpower cost per hour is 20$&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fork lifter cost per hour is 30$.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If we want to minimize the cost of handling what will be algorithms that can help in such kind of problems? Any literature reference would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="3853" LastActivityDate="2021-09-08T09:48:48.080" Title="Resource Optimization For Cargo Handling" Tags="|optimization|mixed-integer-programming|linear-programming|literature-research|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6881" PostTypeId="1" CreationDate="2021-09-07T09:05:26.783" Score="2" ViewCount="161" Body="&lt;p&gt;I was thinking about exact methods for solving the &lt;a href=&quot;https://doi.org/10.1016/j.cor.2017.06.026&quot; rel=&quot;nofollow noreferrer&quot;&gt;Time Dependent TSP (TDTSP)&lt;/a&gt;. Clearly, it is at least as complex as TSP because it extends TSP, but why is it for exact approaches that difficult to solve instances with a greater number of nodes? Do the bounding steps, lower or upper bound, etc., not work the same?&lt;/p&gt;&#xA;" OwnerUserId="5571" LastEditorUserId="5571" LastEditDate="2021-09-08T08:22:33.703" LastActivityDate="2021-09-08T08:22:33.703" Title="Why is exact TDTSP solving much harder to do than TSP solving?" Tags="|mixed-integer-programming|traveling-salesman|dynamic-programming|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6882" PostTypeId="5" CreationDate="2021-09-08T04:21:18.960" Score="0" Body="&lt;p&gt;In addition, OPL models can be controlled and composed using OPLScript, a script language that simplifies the development of applications that solve sequences of models, several instances of the same model, or a combination of both as in column-generation applications.&lt;/p&gt;&#xA;" OwnerUserId="2579" LastEditorUserId="2579" LastEditDate="2021-09-08T07:21:16.207" LastActivityDate="2021-09-08T07:21:16.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6883" PostTypeId="4" CreationDate="2021-09-08T04:21:18.960" Score="0" Body="OPL is a modeling language for mathematical programming and combinatorial optimization problems. It is the first modeling language to combine high-level algebraic and set notations from modeling languages with a rich constraint language and the ability to specify search procedures and strategies that is the essence of constraint programming. " OwnerUserId="2579" LastEditorUserId="2579" LastEditDate="2021-09-08T07:21:21.057" LastActivityDate="2021-09-08T07:21:21.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6884" PostTypeId="1" AcceptedAnswerId="6893" CreationDate="2021-09-08T06:34:42.040" Score="14" ViewCount="1575" Body="&lt;p&gt;Is Hillier F. Introduction to Operations Research a good book for a data analyst? I was particularly interested in Operations Research especially when I was reading about the history about this area:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This field was created to the Necessity of Applying Maths in the World War I and II.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I researched about books here: &lt;a href=&quot;https://or.stackexchange.com/questions/117/recommended-books-materials-for-practical-applications-of-operations-research-ined&quot;&gt;Recommended books/materials for practical applications of Operations Research in industry&lt;/a&gt; but it's a broad recommendation for me and I am starting to go deeper, however I already know linear algebra, calculus, differential equations, statistics, Excel, Python, and other analytical tools for handle data. I am taking an Engineering and Math Degree so maybe that could help me.&lt;/p&gt;&#xA;&lt;p&gt;I don't want a book that only worth for me for tutoring. I want a book with real applications for possible get a job in some interesting industry related to OR. So if you would recommend me one better than Hillier for a start and take shortcuts will help me a lot.&lt;/p&gt;&#xA;&lt;p&gt;Edit: I saw a lot of software for OR in this question here, so I would like take that software and language that I already know (Python, Excel).&lt;/p&gt;&#xA;" OwnerUserId="2579" LastEditorUserId="123" LastEditDate="2021-09-08T07:23:41.377" LastActivityDate="2021-09-09T05:08:40.137" Title="Is Hillier F. Introductory to Operations Research a good book for a data analyst interested in Operation Research field?" Tags="|reference-request|applications|books|industry|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6885" PostTypeId="2" ParentId="6880" CreationDate="2021-09-08T08:30:37.990" Score="1" Body="&lt;p&gt;Rough-cut capacity planning is an essential tool for rapidly calculating the needed capacity and trade-off between the available and required resources which is frequently used in the planning software. As a &lt;a href=&quot;https://docs.oracle.com/cd/A60725_05/html/comnls/us/crp/rccp.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;reference&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;RCCP is a long-term plan capacity planning tool that marketing and production use to balance required and available capacity and to negotiate changes to the master schedule and/or available capacity. You can change your master schedules by changing master schedule dates and increasing or decreasing master schedule quantities. You can change your available capacity by adding or removing shifts, using overtime or subcontracted labor, and adding or removing machines.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It would be calculated either based on the heuristic methods like, vary workforce, Constant workforce/overtime, etc, or by mathematical modeling approach. Some useful resources are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/1259549720&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Operations and Supply Chain Management: pp280&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://opus4.kobv.de/opus4-zib/files/1269/ZR-11-14.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Solving Resource Allocation/Scheduling Problems with Constraint Integer Programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2021-09-08T09:48:48.080" LastActivityDate="2021-09-08T09:48:48.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6886" PostTypeId="2" ParentId="6884" CreationDate="2021-09-08T12:18:02.497" Score="6" Body="&lt;p&gt;I found it quite useful to start (social scientist with background in stats). I had mostly read more complicated papers using linear programming in geographical allocation contexts, and was totally baffled by it. (Relative to stats, in retrospect people using X/Y as decision variables and Greek letters as fixed values is where quite a bit of my confusion came from.)&lt;/p&gt;&#xA;&lt;p&gt;Scooped up a Hillier book from the library, went through the introductory formulating of problems, and then had a much better starting point to understand the more complicated use cases. (Don't quiz me on dynamic programming though.)&lt;/p&gt;&#xA;&lt;p&gt;The copy I used had problems in Excel, but it was not much work to follow along implementing them myself in python (I use &lt;a href=&quot;https://coin-or.github.io/pulp/&quot; rel=&quot;noreferrer&quot;&gt;pulp&lt;/a&gt;, but could use whatever library you want really).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The step from toy examples to real world applications is IMO not a big one. That is on you to formulate the real world problem in the context of your business. Pretty much all of the machine learning models I use in production have some sort of decision analysis piped on the end in practice that if I have particular constraints I use linear programming for (&lt;a href=&quot;https://andrewpwheeler.com/2020/05/29/an-intro-to-linear-programming-for-criminologists/&quot; rel=&quot;noreferrer&quot;&gt;this example is common at my workplace&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="30" LastEditorUserId="30" LastEditDate="2021-09-08T12:23:21.427" LastActivityDate="2021-09-08T12:23:21.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6887" PostTypeId="2" ParentId="6884" CreationDate="2021-09-08T13:54:38.127" Score="10" Body="&lt;p&gt;You can consider going through below blogs:&lt;br /&gt;&#xA;i) &lt;a href=&quot;http://yetanothermathprogrammingconsultant.blogspot.com/&quot; rel=&quot;noreferrer&quot;&gt;Erwin Kalvelagen's blog&lt;/a&gt;&lt;br /&gt;&#xA;ii) Prof Paul Rubin's blog (&lt;a href=&quot;https://orinanobworld.blogspot.com/&quot; rel=&quot;noreferrer&quot;&gt;https://orinanobworld.blogspot.com/&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Interesting things about above blogs is that you can see different applications, their implementations and practical issues while handling them. Another good course is by Prof. Pascal Van on Coursera (&lt;a href=&quot;https://www.coursera.org/learn/discrete-optimization&quot; rel=&quot;noreferrer&quot;&gt;https://www.coursera.org/learn/discrete-optimization&lt;/a&gt;). You can check that course. Also can follow tutorials/webinars from different solvers (mainly CPLEX, GUROBI, LOCALSOLVER, FICO, SAS etc..)&lt;/p&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2021-09-08T13:54:38.127" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6888" PostTypeId="2" ParentId="6884" CreationDate="2021-09-08T15:31:10.740" Score="10" Body="&lt;p&gt;For an idea of industrial applications of OR write large (minus the gory technical details), you might want to look at a few INFORMS publications.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pubsonline.informs.org/magazine/analytics&quot; rel=&quot;noreferrer&quot;&gt;Analytics&lt;/a&gt; (aimed at the general public) and &lt;a href=&quot;https://pubsonline.informs.org/magazine/orms-today&quot; rel=&quot;noreferrer&quot;&gt;OR/MS Today&lt;/a&gt; (for INFORMS membership) contain articles about implementations.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://www.informs.org/Publications/INFORMS-Journals/INFORMS-Journal-on-Applied-Analytics&quot; rel=&quot;noreferrer&quot;&gt;INFORMS Journal of Applied Analytics&lt;/a&gt; (formerly known as Interfaces) contains primarily articles on real-world implementations of OR methods.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Another place to look is software vendor web sites, which may display synopses of real-world solutions using their product. A quick search for &amp;quot;simulation case studies&amp;quot; yielded a page on the &lt;a href=&quot;https://www.anylogic.com/resources/case-studies/&quot; rel=&quot;noreferrer&quot;&gt;AnyLogic web site&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-09-08T15:31:10.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6889" PostTypeId="1" AcceptedAnswerId="6890" CreationDate="2021-09-08T15:37:06.877" Score="4" ViewCount="159" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$0\le X\le\bar X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0\le Y\le\bar Y$&lt;/span&gt; be nonnegative continuous variables. Let &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; be a small positive number. How can the constraint &lt;span class=&quot;math-container&quot;&gt;$X\ge\epsilon\implies X\ge Y$&lt;/span&gt; be modeled?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2021-09-08T15:40:26.127" LastActivityDate="2021-09-17T06:32:21.100" Title="How to model: If $X\ge\epsilon$ then $X\ge Y$" Tags="|modeling|constraint|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6890" PostTypeId="2" ParentId="6889" CreationDate="2021-09-08T16:33:54.837" Score="10" Body="&lt;p&gt;Introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; and linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;X - \epsilon &amp;amp;\le (\bar{X} - \epsilon) Z \tag1 \\&#xA;Y - X &amp;amp;\le (\bar{Y} - 0) (1-Z) \tag2 \\&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$X &amp;gt; \epsilon \implies Z = 1$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$Z = 1 \implies X \ge Y$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-09-08T16:33:54.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6891" PostTypeId="1" CreationDate="2021-09-08T18:02:25.857" Score="5" ViewCount="278" Body="&lt;p&gt;Shift scheduling/rostering is obviously very widely researched, with tons of papers around it. I found the review papers by Van den Bergh &lt;em&gt;et al.&lt;/em&gt; [1] and Ernst &lt;em&gt;et al.&lt;/em&gt; [2], but am looking for something that actually shows the various types of math models that have been used for this with the relevant extensions.&lt;/p&gt;&#xA;&lt;p&gt;Could you please point me to the relevant books/book chapters/papers for this? Thanks!&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;[1] Van den Berg, J.; Beliën, J.; De Bruecker, P.; Demeulemeester, E.; De Boeckab, L. Personnel scheduling: A literature review. &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221712008776&quot; rel=&quot;nofollow noreferrer&quot;&gt;EJOR&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;[2] Ernst, A. T.; Jiang, H.; Krishnamoorthy, M.; Sier, D. Staff scheduling and rostering: A review of applications, methods and models. &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S037722170300095X&quot; rel=&quot;nofollow noreferrer&quot;&gt;EJOR&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="133" LastEditorUserId="123" LastEditDate="2021-09-08T19:04:12.323" LastActivityDate="2021-09-09T08:16:43.043" Title="What are (some of) the best resources for shift scheduling/rostering?" Tags="|mixed-integer-programming|reference-request|scheduling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6892" PostTypeId="2" ParentId="6884" CreationDate="2021-09-08T21:11:53.113" Score="2" Body="&lt;p&gt;Hillier and Lieberman is a good read and solid reference to get the &amp;quot;big picture&amp;quot; of many techniques. You may also want to look into &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0534380581&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Operations Research: Applications and Algorithms&lt;/a&gt; by Winston.&lt;/p&gt;&#xA;" OwnerUserId="7185" LastActivityDate="2021-09-08T21:11:53.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6893" PostTypeId="2" ParentId="6884" CreationDate="2021-09-09T05:08:40.137" Score="4" Body="&lt;p&gt;Having previously worked in software engineering, then trained in mathematics (stats &amp;amp; OR), and since worked in OR for ~3 years, I have a strong opinion on this.&lt;/p&gt;&#xA;&lt;p&gt;If you want to work in OR then it is expected that you are familiar with the topics in the book including some theory behind LP, MIP, and so on. In practice, the real difficulty in tackling a real world problem is in framing the problem in such a way that those methods can even be used in the first place. This is a different skillset. Also recognizing when a problem is too complicated for these methods to be used and it is necessary to resort to metaheuristics and in some case custom heuristics.&lt;/p&gt;&#xA;&lt;p&gt;Having attempted many of the methods in that book including LP, MILP, MDP, graph algorithms, SA, GA, Decision trees, Markov chains, some queuing models, OptQuest..... my conclusion is that the clean mathematical methods tend not to fit many real world problems, at least not the really complicated problems, which is what I have faced almost exclusively in my work.&lt;/p&gt;&#xA;&lt;p&gt;Rather, the only things which &amp;quot;worked&amp;quot; (by worked I mean - actually solved the real, full problem, and were actually released to be used in practice... for real... in the actual real world) were heuristics, meta-heuristics, simulation based optimisation, and statistical analysis of simulation output.  To the point now where I don't bother trying the nice clean mathematical models on any big problem because it's a waste of time.&lt;/p&gt;&#xA;&lt;p&gt;The book, unfortunately, seems to talk about the nice mathematical models and theoretical side. It is necessary to be able to talk in that language to operate in the field. But don't be fooled - the success criteria for many projects in this domain is &amp;quot;I got a paper published in a good journal&amp;quot;, which in my experience is negatively correlated with &amp;quot;I got it to solve the real, full problem and got people to actually use it&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;For that reason no I don't think this book will introduce you to many practical techniques you can apply to real world problems. However, it will equip you with a useful language and set of ideas. And you will know what the options are for computing solutions if you know that it can be reasonable represented in vairous formed, like LP, MDP, parameteric black box function, etc.&lt;/p&gt;&#xA;" OwnerUserId="1071" LastActivityDate="2021-09-09T05:08:40.137" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6894" PostTypeId="2" ParentId="6889" CreationDate="2021-09-09T06:36:27.770" Score="4" Body="&lt;p&gt;With CPLEX you can use logical constraints.&#xA;In OPL for instance you can write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;float epsilon=0.01;&#xA;&#xA;dvar float X;&#xA;dvar float Y;&#xA;&#xA;subject to&#xA;{&#xA;  (X&amp;gt;=epsilon) =&amp;gt; (X&amp;gt;=Y);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And if you wonder , logical constraints are available in OPL but also in all APIs.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;float epsilon=0.01;&lt;/p&gt;&#xA;&lt;p&gt;dvar float X; dvar float Y;&lt;/p&gt;&#xA;&lt;p&gt;subject to {   (X&amp;gt;=epsilon) =&amp;gt; (X&amp;gt;=Y); }&lt;/p&gt;&#xA;&lt;p&gt;main {   thisOplModel.generate();   cplex.exportModel(&amp;quot;exp.lp&amp;quot;); }&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;gives exp.lp&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Minimize&#xA; obj1: 0 x1 + 0 X + 0 x3 + 0 Y&#xA;Subject To&#xA; i1: x1 = 1 &amp;lt;-&amp;gt; X =&amp;gt; 0.01&#xA; i2: x3 = 1 &amp;lt;-&amp;gt; X - Y =&amp;gt; 0&#xA; i3: x1 = 1 -&amp;gt; x3  = 1&#xA;Bounds&#xA; 0 &amp;lt;= x1 &amp;lt;= 1&#xA;      X Free&#xA; 0 &amp;lt;= x3 &amp;lt;= 1&#xA;      Y Free&#xA;Binaries&#xA; x1  x3 &#xA;End&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2021-09-17T06:32:21.100" LastActivityDate="2021-09-17T06:32:21.100" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6895" PostTypeId="2" ParentId="6891" CreationDate="2021-09-09T06:58:29.213" Score="3" Body="&lt;p&gt;For what it's worth, we've been gathering a bunch of &lt;a href=&quot;https://docs.optaplanner.org/8.11.0.Final/optaplanner-docs/html_single/index.html#domainModelingGuide&quot; rel=&quot;nofollow noreferrer&quot;&gt;Design Patterns in chapter 20 of OptaPlanner's User Guide&lt;/a&gt;. Here are some of the drawings:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8rTPo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8rTPo.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/oigvt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oigvt.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;There's also &lt;a href=&quot;https://www.youtube.com/watch?v=0uAoWU8m0pE&quot; rel=&quot;nofollow noreferrer&quot;&gt;a video that explains this deeper&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Besides these modeling basics, there are orthogonal features to consider (document in other places in the user guide):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pinning: allow the user to lock in a shift assignment to an employee, before solving (so the solver has to work around it)&lt;/li&gt;&#xA;&lt;li&gt;Continuous planning: every week publish the schedule 3 weeks in advance, don't paint yourself in a corner, ...&lt;/li&gt;&#xA;&lt;li&gt;Non-disruptive replanning: making changes on a published schedule&lt;/li&gt;&#xA;&lt;li&gt;Publishing, fairness constraints, rotation schedules, ...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;A drawing of Continuous Planning with Rotation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7fI6R.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7fI6R.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And there's &lt;a href=&quot;https://youtu.be/Ew6pq9nJKog&quot; rel=&quot;nofollow noreferrer&quot;&gt;a video to explain these advanced topics&lt;/a&gt; too.&lt;/p&gt;&#xA;&lt;p&gt;These patterns are illustrated in 2 implementations:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/main/optaplanner-examples/src/main/java/org/optaplanner/examples/nurserostering&quot; rel=&quot;nofollow noreferrer&quot;&gt;optaplanner-example's nurse rostering&lt;/a&gt; (based on the International Nurse Rostering Competition specs)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kiegroup/optaweb-employee-rostering&quot; rel=&quot;nofollow noreferrer&quot;&gt;optaweb-employee-rostering&lt;/a&gt; a full blown webapp&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;that have been the basis for production deployments across the globe.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2021-09-09T08:16:43.043" LastActivityDate="2021-09-09T08:16:43.043" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6896" PostTypeId="1" CreationDate="2021-09-09T14:34:09.690" Score="5" ViewCount="1127" Body="&lt;p&gt;In an MIP, how can I formulate a constraint such that a decision variable is only greater (or equal to) zero if (and only if) the sum of different decision variables is equal to something.&lt;/p&gt;&#xA;&lt;p&gt;I'm working with a path flow formulation model and I want to have a constraint that forces flow q on path p to be zero if not all routes in path p are flown.&lt;/p&gt;&#xA;&lt;p&gt;Example: flow &lt;em&gt;q&lt;/em&gt; on path &lt;em&gt;p&lt;/em&gt;, which contains flight A to B (&lt;span class=&quot;math-container&quot;&gt;$f_{AB}$&lt;/span&gt;) and flight B to C (&lt;span class=&quot;math-container&quot;&gt;$f_{BC}$&lt;/span&gt;), can be greater than zero if and only if one aircraft flies from A to B and (the same or another aircraft) flies from B to C.&lt;/p&gt;&#xA;&lt;p&gt;I) q = 0 if &lt;span class=&quot;math-container&quot;&gt;$\sum$&lt;/span&gt;(&lt;span class=&quot;math-container&quot;&gt;$f_{AB}$&lt;/span&gt; + &lt;span class=&quot;math-container&quot;&gt;$f_{BC}$&lt;/span&gt;) &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; 1&lt;/p&gt;&#xA;&lt;p&gt;II) q &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; 0 if &lt;span class=&quot;math-container&quot;&gt;$\sum$&lt;/span&gt;(&lt;span class=&quot;math-container&quot;&gt;$f_{AB}$&lt;/span&gt; + &lt;span class=&quot;math-container&quot;&gt;$f_{BC}$&lt;/span&gt;) = 2&lt;/p&gt;&#xA;&lt;p&gt;In case there are three flights in one path, constraint I becomes &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; 2, and constraint II becomes = 3, etc.&lt;/p&gt;&#xA;&lt;p&gt;(I know exactly which flow can go over which paths, and I know how many flights are contained in all of the available paths. Moreover, all &lt;span class=&quot;math-container&quot;&gt;$f_{ij}$&lt;/span&gt; are binary)&lt;/p&gt;&#xA;&lt;p&gt;Help with this would be highly appreciated! (I'm writing my problem in python, in case that matters for anything)&lt;/p&gt;&#xA;" OwnerUserId="7188" LastEditorUserId="2556" LastEditDate="2021-09-09T14:52:51.893" LastActivityDate="2021-09-10T13:21:13.140" Title="In a MIP, how to force a decision variable to be zero unless the sum of specific other decision variables is equal to a certain number?" Tags="|mixed-integer-programming|linear-programming|modeling|integer-programming|logical-constraints|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6897" PostTypeId="2" ParentId="6896" CreationDate="2021-09-09T14:49:19.167" Score="5" Body="&lt;p&gt;Introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta \in \{0,1\}$&lt;/span&gt; to indicate whether &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; is positive or not. You want:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{(i,j) \in A}f_{ij} \le |A| - 1 \quad \Longrightarrow \quad \delta=0&#xA;$$&lt;/span&gt;&#xA;or the contrapositive:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\delta=1  \quad \Longrightarrow \quad \sum_{(i,j) \in A}f_{ij} \ge |A| &#xA;$$&lt;/span&gt;&#xA;which you can achieve with:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{(i,j) \in A}f_{ij} \ge |A| \delta&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, assuming you want &lt;span class=&quot;math-container&quot;&gt;$q\ge L$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$\sum_{(i,j) \in A}f_{ij} = |A|$&lt;/span&gt;, add the constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;L\delta \le q \le M \delta&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is an upper bound on &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt;. The right hand side of this last constraint enforces &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; to take value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$\delta=0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-09-09T20:40:01.247" LastActivityDate="2021-09-09T20:40:01.247" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6898" PostTypeId="1" AcceptedAnswerId="6899" CreationDate="2021-09-09T20:55:48.507" Score="2" ViewCount="81" Body="&lt;p&gt;I am maximizing a convex function (a positive definite quadratic form, if it makes a difference) subject to &lt;span class=&quot;math-container&quot;&gt;$0\le x_1\le \ldots \le x_n\le 1$&lt;/span&gt; and a linear constraint &lt;span class=&quot;math-container&quot;&gt;$a^\top x+b=0$&lt;/span&gt;. Can I conclude that the maximum occurs where some of those inequalities are equalities, or something of the sort?&lt;/p&gt;&#xA;" OwnerUserId="7191" LastEditorUserId="123" LastEditDate="2021-09-10T07:45:50.123" LastActivityDate="2021-09-10T07:45:50.123" Title="Convex function subject to $0\le x_1\le \ldots \le x_n\le 1$ and linear constraint" Tags="|convex-optimization|quadratic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6899" PostTypeId="2" ParentId="6898" CreationDate="2021-09-09T23:45:01.250" Score="5" Body="&lt;p&gt;Yes. Your feasible region is a convex (bounded) polytope, which means that every point in the feasible region can be written as a convex combination of extreme points. Let's say that your function is &lt;span class=&quot;math-container&quot;&gt;$f()$&lt;/span&gt;, the maximum occurs at &lt;span class=&quot;math-container&quot;&gt;$\bar{x}\in [0,1]^n$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\bar{x} = \sum_{i=1}^k \alpha_i x^{(i)}$&lt;/span&gt;, where the &lt;span class=&quot;math-container&quot;&gt;$x^{(i)}\in [0,1]^n$&lt;/span&gt; are extreme points of the feasible region and the &lt;span class=&quot;math-container&quot;&gt;$\alpha_i$&lt;/span&gt; are nonnegative weights with &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^k \alpha_i = 1$&lt;/span&gt;. By the convexity of &lt;span class=&quot;math-container&quot;&gt;$f()$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$$f(\bar{x}) \le \sum_{i=1}^k \alpha_i f(x^{(i)}),$$&lt;/span&gt;so for &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; to maximize &lt;span class=&quot;math-container&quot;&gt;$f()$&lt;/span&gt; over the feasible region every &lt;span class=&quot;math-container&quot;&gt;$x^{(i)}$&lt;/span&gt; in the sum with &lt;span class=&quot;math-container&quot;&gt;$\alpha_i &amp;gt;0$&lt;/span&gt; must maximize &lt;span class=&quot;math-container&quot;&gt;$f()$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An extreme point (corner) of a polytope is the intersection of a bunch of linearly independent bounding hyperplanes (binding constraints), so there will be at least one maximizer of &lt;span class=&quot;math-container&quot;&gt;$f()$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; of the constraints are binding.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-09-09T23:45:01.250" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6900" PostTypeId="1" AcceptedAnswerId="6902" CreationDate="2021-09-10T02:58:33.643" Score="3" ViewCount="164" Body="&lt;p&gt;I would like to hire a consultant at OR to do a formulation of a mathematical optimization problem. Which website is reliable for it?&lt;/p&gt;&#xA;" OwnerUserId="5859" LastActivityDate="2021-09-12T17:11:48.233" Title="How to get professional help in OR" Tags="|optimization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6901" PostTypeId="1" CreationDate="2021-09-10T03:45:26.750" Score="3" ViewCount="139" Body="&lt;p&gt;I need to model the following problem:&lt;/p&gt;&#xA;&lt;p&gt;For a planning horizon of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; equal periods, one has &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; harvesting locations and &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; contractors who can harvest at those locations (&lt;span class=&quot;math-container&quot;&gt;$K &amp;lt; N$&lt;/span&gt;). Each harvesting site has a given volume to be harvested before a period &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$i \in \{1,\ldots,N\}$&lt;/span&gt;.&#xA;Each of the &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; contractors has one or more machines to do that job. The idea is to assign contractors to do the harvesting at each of the sites, such that travel between harvesting sites is kept to a minimum. I must also decide when a contractor starts harvesting at each location and in what period &lt;span class=&quot;math-container&quot;&gt;$ p \in \{1,\ldots,P\}$&lt;/span&gt; he will be harvesting.&#xA;I know in advance the harvesting productivity of each of the &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; sites (how much volume a machine can harvest at that site during a period).&lt;/p&gt;&#xA;&lt;p&gt;In each period, a certain harvesting demand must be met. The periods can be months of the year.&lt;/p&gt;&#xA;" OwnerUserId="7194" LastEditorUserId="67" LastEditDate="2021-09-10T17:19:56.690" LastActivityDate="2021-09-10T17:19:56.690" Title="Harvest planning problem" Tags="|optimization|mixed-integer-programming|linear-programming|scheduling|vrpy|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6902" PostTypeId="2" ParentId="6900" CreationDate="2021-09-10T03:46:25.827" Score="3" Body="&lt;p&gt;I can give you my bias opinion because I am freelancer ( I don't know anything about other specific OR websites, linkedin, glassdoor, recruitment agencies or networking methods ) but  if I were you my mainly choices were:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.fiverr.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fiverr.com&lt;/a&gt; you can check &lt;a href=&quot;https://www.fiverr.com/search/gigs?query=operations%20research&amp;amp;source=top-bar&amp;amp;search_in=everywhere&amp;amp;search-autocomplete-original-term=operations%20research&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for specific OP expert, 194 OP freelancer working there.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.upwork.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Upwork.com&lt;/a&gt; you can check &lt;a href=&quot;https://www.upwork.com/hire/operations-research-freelancers/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; 239 OP specialist working there.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://guru.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Guru.com&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://toptal.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Toptal.com&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.peopleperhour.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;PeopleperHour.com&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also you have to check his portfolio, last work done and reputation there are a lot of scammers and difficult people for both parts working freelance.&lt;/p&gt;&#xA;" OwnerUserId="2579" LastActivityDate="2021-09-10T03:46:25.827" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6903" PostTypeId="1" AcceptedAnswerId="6906" CreationDate="2021-09-10T07:07:09.580" Score="5" ViewCount="296" Body="&lt;p&gt;I recently ran a MIP model with &lt;code&gt;cplex&lt;/code&gt; specifying it should stop solving when integer feasibility was proven (&lt;code&gt;mipsolutions=1&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;When I ran the model with one easy objective function, the model did not find any feasible integer solutions after an hour. However, when I replaced the objective function with a different, also easy one—keeping all constraints the same—&lt;code&gt;cplex&lt;/code&gt; proved integer feasibility in 3–4 minutes.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, I constructed the second objective function in such a way that if I had plugged the solution from model 2 into the objective function from model 1, the objective function value would have been exactly equal the value that would have been obtained from model 1. And vice versa.&lt;/p&gt;&#xA;&lt;p&gt;This makes me wonder: why does one objective function prove feasibility faster than another?&lt;/p&gt;&#xA;" OwnerUserId="5796" LastActivityDate="2021-09-10T14:31:42.417" Title="Why does one objective function prove feasibility faster than another?" Tags="|mixed-integer-programming|cplex|feasible-points|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6905" PostTypeId="2" ParentId="6896" CreationDate="2021-09-10T13:21:13.140" Score="2" Body="&lt;p&gt;With CPLEX you can use logical constraints.&lt;/p&gt;&#xA;&lt;p&gt;For instance with the OPL API you can write:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar boolean q;&#xA;dvar int a;&#xA;dvar int b;&#xA;&#xA;subject to&#xA;{&#xA;  q==(a+b&amp;gt;=2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;q is 0 iff a+b&amp;lt;=1&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-09-10T13:21:13.140" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6906" PostTypeId="2" ParentId="6903" CreationDate="2021-09-10T14:31:42.417" Score="5" Body="&lt;p&gt;Consider maximizing &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n x_i$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; binary and &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n i x_i \leq 2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Solve relaxation and it gives &lt;span class=&quot;math-container&quot;&gt;$x_1 = 1, x_2 = 1/2$&lt;/span&gt; with remaining variables 0. Branch on &lt;span class=&quot;math-container&quot;&gt;$x_2 = 0$&lt;/span&gt; and the new solution is &lt;span class=&quot;math-container&quot;&gt;$x_1 = 1, x_3 = 1/3$&lt;/span&gt; with the rest 0. Continue in the same fashion and you will have to go through fixing all variables.&lt;/p&gt;&#xA;&lt;p&gt;Had you minimized &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n x_i$&lt;/span&gt; instead (or used another branching and variable selection strategy or simply a better solver) you would have had the optimal solution immediately.&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2021-09-10T14:31:42.417" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6907" PostTypeId="1" AcceptedAnswerId="6908" CreationDate="2021-09-10T19:07:12.720" Score="9" ViewCount="826" Body="&lt;p&gt;I am looking over for softwares recommendation in Introduction to Operations Research Hillier 11th, there are tens of options for learn and apply OR theory using software.&lt;/p&gt;&#xA;&lt;p&gt;I normally check how much focus have a book about a specific topic, counting how much words are in the book. and this is my data:&lt;/p&gt;&#xA;&lt;p&gt;Counting the words related to specific softwares in the Hillier book:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;LINGO / LINDO 100 words / 136 words&#xA;Excel 269 words ( mostly related to .xlsx files not about excel software itself)&#xA;ASPE 250&#xA;Queuing Simulator 499&#xA;MPL ( Unresearchable at the moment )&#xA;CPLEX 21 &#xA;GUROBI 11&#xA;Python 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As you all see I am saying excel word is use in Hillier mostly for handle .xlsx files and few examples for solving problems, more for ASPE &lt;code&gt;250&lt;/code&gt;, LINGO &lt;code&gt;136&lt;/code&gt; and more for Queuing Simulator &lt;code&gt;499&lt;/code&gt; ( Not Using CPLEX too much &lt;code&gt;21&lt;/code&gt; wordsa and Gurobi &lt;code&gt;11&lt;/code&gt; Words). about &amp;quot;Use excel only for handle data&amp;quot; also happen with the data science industry in this &lt;a href=&quot;https://datascience.stackexchange.com/a/5450/84263&quot;&gt;post&lt;/a&gt; in ds.se there are horror history using Excel for Data Science / Analytics. &lt;strong&gt;But what about the excel solver is good?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;As an example of comparing I use this is my data about software in &lt;a href=&quot;https://or.stackexchange.com/&quot;&gt;OR.SE&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[excel] 15 questions related to excel&#xA;[cplex] 160 questions&#xA;[gurobi] 106&#xA;[python]198&#xA;[matlab] 19&#xA;[r] 12&#xA;lingo 1 &#xA;aspe 0&#xA;mpl 1&#xA;[pyomo] 81&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Comparing we have a lack of CPLEX, Gurobi, Python in the Hillier book however this book is still useful for OR theory. but that's too much information for this question my main question is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is Excel Outdate or Useless for the OR industry?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="2579" LastEditorUserId="1202" LastEditDate="2021-09-11T00:38:57.203" LastActivityDate="2021-09-13T07:09:16.680" Title="Softwares for Operations Research. Is Excel Outdated or Useless for the OR industry?" Tags="|python|solver|applications|excel|industry|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6908" PostTypeId="2" ParentId="6907" CreationDate="2021-09-10T20:30:17.130" Score="13" Body="&lt;p&gt;Excel remains extensively used in industry for non-OR applications. That means that if you are doing an OR application that does not require access to a database, there's a good chance the data for the application will come to you in either an XLSX or CSV file. On the flip side, when it comes time to convey the solution provided by your application, it is fairly common to be asked to provide it in a spreadsheet.&lt;/p&gt;&#xA;&lt;p&gt;As far as OR applications themselves, it is possible in a few cases to embed one in an Excel spreadsheet. Sufficiently small linear programs and integer linear programs can be handled by either the built-in Solver in Excel (which I believe is a stripped down version of Frontline Solver, or the full commercial version of Frontline Solver, or OpenSolver (source plug-in for Excel). Some other simple applications might be possible using VBA and/or plugins. &amp;quot;Chewier&amp;quot; applications, whether optimization, simulation, queuing/Markov chain or whatever, will likely require a separate (likely commercial) software package, which may or may not have an Excel interface.&lt;/p&gt;&#xA;&lt;p&gt;Personally, while I might use (voluntarily or otherwise) Excel as an intermediary between my application and the user, I would not normally try to build a serious application in Excel.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-09-10T20:30:17.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6909" PostTypeId="1" CreationDate="2021-09-11T10:44:41.010" Score="6" ViewCount="363" Body="&lt;p&gt;In which time complexity operates the Savings algorithm from &lt;a href=&quot;https://www.jstor.org/stable/pdf/167703.pdf?casa_token=k_vTQBHsuy0AAAAA:0whMlhcAW4BsEjLHs1uFWM1xnd4F2n0ZETqM1QKB-8QL72zhJplTT3tueN0C-P0l8Y90baTS4rMLVZFkaBecYujZ-A4OGUhemIHvxdgwCKASd9yiCOuA&quot; rel=&quot;nofollow noreferrer&quot;&gt;Clarke and Wright&lt;/a&gt; for the TSP? I mean the parallel version of Savings. I think it is in &lt;span class=&quot;math-container&quot;&gt;$\mathcal O(|V|\log|V|)$&lt;/span&gt; with V as vertex/node because the most complex operation is sorting the savings which operate in this time for, e.g. Quicksort. The rest operates, I think, in linear time. Is this right, and is there something on the internet that covers this?&lt;/p&gt;&#xA;" OwnerUserId="5571" LastEditorUserId="5571" LastEditDate="2021-09-17T07:24:54.303" LastActivityDate="2021-09-17T08:10:09.033" Title="In which time complexity operates the Savings algorithm for the TSP?" Tags="|reference-request|vehicle-routing|computational-complexity|traveling-salesman|heuristics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6910" PostTypeId="2" ParentId="6909" CreationDate="2021-09-11T22:08:30.363" Score="4" Body="&lt;p&gt;You might want to read the paper DIFFERENT VERSIONS OF THE SAVINGS METHOD FOR THE TIME LIMITED VEHICLE ROUTING PROBLEM&lt;a href=&quot;https://pdfs.semanticscholar.org/fff6/e633081358f92f9431b6247e1e8a6b8a07b9.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;[1]&lt;/a&gt; which gives time complexities between &lt;span class=&quot;math-container&quot;&gt;$O(n^3)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$O(n^2\log(n))$&lt;/span&gt; note that in these complexity analysis the number of nodes not nodes as &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. The reason why it is &lt;span class=&quot;math-container&quot;&gt;$n^2$&lt;/span&gt; and not &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is this part of the algorithm:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/HGXHx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HGXHx.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://courses.ieor.berkeley.edu/ieor151/lecture_notes/ieor151_lec18.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Taken from EOR 151 – Lecture 18 Savings Algorithm page 1&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The number of savings grows &lt;span class=&quot;math-container&quot;&gt;$O(n^2)$&lt;/span&gt; (actually like &lt;span class=&quot;math-container&quot;&gt;$n(n+1)/2$&lt;/span&gt;) so sorting that leads to &lt;span class=&quot;math-container&quot;&gt;$O(n^2\log(n^2)) = O(2n^2\log(n)) = O(n^2\log(n))$&lt;/span&gt; time complexity unless a non-comparison based sorting like trie/radix/couting sort is used.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-09-17T08:10:09.033" LastActivityDate="2021-09-17T08:10:09.033" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6911" PostTypeId="1" AcceptedAnswerId="6912" CreationDate="2021-09-11T23:31:10.587" Score="15" ViewCount="4062" Body="&lt;p&gt;I am curious about the &lt;strong&gt;performance of Apple's M1 chip solving optimizations models&lt;/strong&gt;, MIP, LP, and in solutions approach as benders or columns generations.&#xA;I read that is a spectacular cpu to perform machine learning tasks, and was wondering how good is solving OR problems.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone have any experience with one? Is the M1 the &lt;strong&gt;best cpu (on laptops)&lt;/strong&gt; out there for this kind of tasks? Better than an AMD 5900 or Intel i7-11?&lt;/p&gt;&#xA;&lt;p&gt;I look up for references on the internet, but couldn't find any.&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="-1" LastEditDate="2021-09-12T15:34:01.983" LastActivityDate="2021-10-09T09:12:42.890" Title="Is Apple's M1 suitable for Operations Research?" Tags="|mixed-integer-programming|pyomo|benders-decomposition|ampl|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6912" PostTypeId="2" ParentId="6911" CreationDate="2021-09-12T00:35:43.013" Score="15" Body="&lt;p&gt;One problem you might encounter is that the many solvers are either not available for M1 like CPLEX[&lt;a href=&quot;https://stackoverflow.com/a/66888449&quot;&gt;1&lt;/a&gt;]. M1 support for Gurobi might be mixed in general due to issue like &amp;quot;Only use single-threaded BLAS on Mac to avoid overshooting the thread limit&amp;quot; [&lt;a href=&quot;https://www.gurobi.com/resource/fixes/&quot; rel=&quot;nofollow noreferrer&quot;&gt;3&lt;/a&gt;] and limited memory which might become a big problem for large systems.&lt;/p&gt;&#xA;&lt;p&gt;You could probably get an evaluation license for Gurobi and evaluate them on a Mac Mini with an M1 that is available for rent online. This should at least give you an idea whether it is competitive when given more power and cooling. In general the machine learning hardware and the build in GPU (which if often counted in GigaFLOP numbers for the M1)  won't be used by any solver. In general going with an AMD with more cores should be worth it as those kind of problems can easily exploit parallelism.&lt;/p&gt;&#xA;&lt;p&gt;I wouldn't expect to have a good time using an M1 based laptop for OR. Mostly for software reasons.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/66888449&quot;&gt;CPLEX&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360076175911-Gurobi-for-Mac-M1-chip&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gurobi.com/resource/fixes/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Recent Bug Fixes by Version - Gurobi&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h3&gt;Attempts at Benchmarking&lt;/h3&gt;&#xA;&lt;p&gt;Since I don't have any indication what kind of MILP problems you want to solve I just took some really fast MILP problems and ran two open source MILP solver CBC and GLPK in this &lt;a href=&quot;https://pastebin.com/8R6mJwEn&quot; rel=&quot;nofollow noreferrer&quot;&gt;Benchmark script&lt;/a&gt; using Julia/JuMP.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://pastebin.com/uRkku9L6&quot; rel=&quot;nofollow noreferrer&quot;&gt;Run on a Intel(R) Core(TM) i5-8250U CPU inside a Lenovo L380 Yoga&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I got a &lt;a href=&quot;https://github.com/staticfloat&quot; rel=&quot;nofollow noreferrer&quot;&gt;friend&lt;/a&gt; to compile GLPK for me (it is now available for everybody using Julia/JuMP on M1)  and to attempt to run the benchmark on a MacBook Pro with an M1 however not the more complicated and dependency rich CBC.&lt;/p&gt;&#xA;&lt;p&gt;While the GLPK compiled successfully JuMP uses closured run time generated functions for callbacks which are &lt;a href=&quot;https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/#Closure-cfunctions&quot; rel=&quot;nofollow noreferrer&quot;&gt;not supported&lt;/a&gt; on ARM. &lt;a href=&quot;https://github.com/JuliaLang/julia/issues/42269&quot; rel=&quot;nofollow noreferrer&quot;&gt;The issue in the Julia language is tracked here&lt;/a&gt;. Even if you use a platform independent programming language, the code base below you might use a hack for performance which is not cross platform. I haven't found anything whether Pyomo can call solvers in C on an M1. However &lt;a href=&quot;https://opencv.org/opencv-python-for-apples-m1-chip-a-detective-story-with-a-happy-ending/&quot; rel=&quot;nofollow noreferrer&quot;&gt;other Python libraries have similar callback trouble with C code on M1&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Unless you are willing to compile solvers yourself, fight with commercial vendors and debug their code and in addition don't care about the comforts of high-level languages I would not recommend you to use an MacBook M1 for Operations Research. As Erling Andersen noted, it would be hard to even exploit the capabilities of an M1 chip due to lack of documentation.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="279" LastEditDate="2021-10-09T07:24:33.993" LastActivityDate="2021-10-09T07:24:33.993" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="6913" PostTypeId="1" CreationDate="2021-09-12T11:33:59.047" Score="3" ViewCount="95" Body="&lt;h3&gt;Task / Goal&lt;/h3&gt;&#xA;&lt;p&gt;I'm considering adding some &lt;strong&gt;customized problem-specific local-search component on top of a general-purpose MILP solver&lt;/strong&gt; (= improvement heuristic).&lt;/p&gt;&#xA;&lt;p&gt;The basic idea is the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All &lt;em&gt;new feasible integer solutions&lt;/em&gt; are &lt;strong&gt;extracted&lt;/strong&gt; upon arrival&lt;/li&gt;&#xA;&lt;li&gt;There is some &lt;em&gt;concurrent code&lt;/em&gt; doing &lt;em&gt;some local search procedure&lt;/em&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(concurrently in regards to the MILP solver)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;New improvements, if found, are put into some pool and &lt;em&gt;MILP &lt;strong&gt;injects&lt;/strong&gt; these during search&lt;/em&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(simplified: let's assume there is only a &lt;em&gt;single best new solution&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;While conceptionally simple, if we take some LS procedure as given, there are probably &lt;strong&gt;tons of implementation-implied road-blocks&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I would be interested to learn about the feasibility and implementation of above using CoinOR Cbc.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Core Question / Problem&lt;/h3&gt;&#xA;&lt;p&gt;The core &lt;strong&gt;issue&lt;/strong&gt; (to me) will be the &lt;strong&gt;transformation of the problem within the solver&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The LS-procedure will need:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;extraction of integer-feasible MILP-provided solutions expressed on the original problem variables / constraints&lt;/strong&gt; (during optimization)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;injection of new integer-feasible solutions into the solver using the original problem variables / constraints&lt;/strong&gt; (during optimization)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I'm not sure how much of a problem this will be with &lt;strong&gt;CoinOR Cbc&lt;/strong&gt;, which i would like to focus on here.&lt;/p&gt;&#xA;&lt;h3&gt;Looking at other MILP solvers&lt;/h3&gt;&#xA;&lt;p&gt;Let's look at other solvers where things might be more clear (at least to me).&lt;/p&gt;&#xA;&lt;h4&gt;Cplex&lt;/h4&gt;&#xA;&lt;p&gt;The solver has what's called &lt;em&gt;generic callbacks&lt;/em&gt;. The documentation says:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;It works almost exclusively on the original model; that is, with some exceptions, there is no access to the presolved model nor information available about the presolved model.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;which helps a lot as this makes it easy to &lt;em&gt;map&lt;/em&gt; solutions in-between our MILP-solver and our &lt;em&gt;secondary component = LS&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I did implement some demo in the past where a CP-based Primal Heuristic was used in a similar manner (task: convert LP-relaxation to integer-feasible solution; no concurrency) and it seemed to work.&lt;/p&gt;&#xA;&lt;h4&gt;SCIP&lt;/h4&gt;&#xA;&lt;p&gt;SCIP, if i interpret it correctly, also looks like it would support this kind of concept.&lt;/p&gt;&#xA;&lt;p&gt;This &lt;a href=&quot;https://stackoverflow.com/questions/56877929/storing-feasible-solutions-in-terms-of-original-variables&quot;&gt;StackOverflow Question + Answer&lt;/a&gt; indicates, that there are calls:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;mapping solutions from the solvers transformed problem space to the original problem space&#xA;&lt;ul&gt;&#xA;&lt;li&gt;-&amp;gt; &lt;em&gt;extraction&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;mapping solutions from the original problem space to the solvers transformed problem space&#xA;&lt;ul&gt;&#xA;&lt;li&gt;-&amp;gt; &lt;em&gt;injection&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I never tried it and it will be probably a bit more complex to implement compared to &lt;em&gt;cplex&lt;/em&gt;, but at least there is a clear idea about how to pursue it (or where to look).&lt;/p&gt;&#xA;&lt;h3&gt;Back to our focus: &amp;quot;CoinOR Cbc&amp;quot;&lt;/h3&gt;&#xA;&lt;p&gt;I actually don't know much about Cbcs internals, especially in regards to the components needed to tackle this task.&lt;/p&gt;&#xA;&lt;p&gt;There is some general &amp;quot;Primal Heuristic&amp;quot; documentation, but it's unclear in which &amp;quot;context&amp;quot; we are working there. I guess, only the &amp;quot;transformed problem&amp;quot; makes sense.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I don't know, and this is the core question here&lt;/strong&gt;, how i could:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;extract integer-feasible solutions in original problem space&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(each time a new one is found)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;inject integer-feasible solutions from original problem space&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(we would need some callback / even which is &amp;quot;frequent&amp;quot; enough to allow this -&amp;gt; probably available)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In terms of the &lt;em&gt;abstract idea&lt;/em&gt;, i guess the solver should be ready to allow that kind of &lt;em&gt;injection&lt;/em&gt;, as it's primal heuristics should also be doing this:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;proposing new solutions (during search) to consider for follow-up search&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The only difference might be the &amp;quot;problem space&amp;quot; they are looking at.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What would be be a viable route to pursue here? Where to look at?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I guess, but you might correct me, that this kind of hybridization might be a good approach when focusing on obtaining good feasible solutions within limited time (if development-resources allow to build a second &amp;quot;solver/perspective&amp;quot;).&lt;/p&gt;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&lt;p&gt;Thanks to Florian for the comment / links.&lt;/p&gt;&#xA;&lt;p&gt;Based on that i skimmed the code a bit.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;strong&gt;extraction-part&lt;/strong&gt; of the questions looks to be solved now and the components to do this are surprisingly &amp;quot;fresh&amp;quot; in regards to Cbc-dev:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;2.10 (2019) introduced CbcModel::postProcessedSolver() which is used in the example&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The code behind this looks also non-trivial (hard to understand without knowledge of solver-internals)&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I guess there is no easy &amp;quot;just invert this&amp;quot; path&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In regards to the &lt;strong&gt;injection-part&lt;/strong&gt;, the most promising resource seems to be &lt;a href=&quot;https://github.com/coin-or/Cbc/blob/d377b61b7aded9ec412a2c41092451c277757d22/src/CbcModel.cpp#L2047&quot; rel=&quot;nofollow noreferrer&quot;&gt;hot-start processing&lt;/a&gt; but i wouldn't say i'm very optimistic about trying this (because it's hard to understand what's exactly happening and some code-comments are not improving my confidence).&lt;/p&gt;&#xA;&lt;p&gt;Funny thing: i'm currently failing to follow the MIPStart path through the solver which maybe should be even more promising.&lt;/p&gt;&#xA;" OwnerUserId="231" LastEditorUserId="231" LastEditDate="2021-09-14T17:35:06.327" LastActivityDate="2021-09-14T17:35:06.327" Title="Extract/Inject Solutions (orig problem-space) during Search in MILP -&gt; CoinOR Cbc" Tags="|mixed-integer-programming|callback|coin-or|cbc|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6914" PostTypeId="1" AcceptedAnswerId="6919" CreationDate="2021-09-12T14:51:18.623" Score="3" ViewCount="114" Body="&lt;p&gt;I am working on a unit commitment problem where I need to turn the constraints to dual. But the constraints do not deal with the same time period which makes dual process confusing. for a simple example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$min  \sum_{t=1}^T(Cx(t))$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s.t.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \quad x(t) \ge LB, -x(t) \ge -UB,\quad \forall t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \quad x(t)-x(t-1) \ge -RD,\quad 1&amp;lt; t \le T$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \quad x(1) \ge -RD+x(0),\quad \quad t = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \quad x(t) = D(t),\quad \forall t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x(t)$&lt;/span&gt; is the only variable here and  &lt;span class=&quot;math-container&quot;&gt;$x(0)$&lt;/span&gt; serves as a known initial condition. and below is my dual form of the problem and the &lt;span class=&quot;math-container&quot;&gt;$ \lambda_1(t),\ldots,\lambda_5(t)$&lt;/span&gt; represent the dual multiplier of the above constraints. Note: for simplification, I ignore the units number here.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$max  \sum_{t=1}^T(LB*\lambda_1(t))+\sum_{t=1}^T(-UB*\lambda_2(t)) + \sum_{t=2}^T(-RD*\lambda_3(t)) +(-RD+x(0))*\lambda_4+ \sum_{t=1}^T(D(t)*\lambda_5(t))$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s.t.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \quad\lambda_1(1) -\lambda_2(1) - \lambda_3(1) + \lambda_4 + \lambda_5(1) \le C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\quad \lambda_1(t) -\lambda_2(t) - \lambda_3(t) + \lambda_3(t-1) + \lambda_5(t) \le C, \quad 2 &amp;lt; t &amp;lt; T $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\quad \lambda_1(T) -\lambda_2(T) + \lambda_3(T) + \lambda_5(T) \le c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In most of the paper I read, authors either just ignore the initial condition or just use the second dual constraints above without consider the boundary of the constraints. The reason I write the constraints this way is that, for example, &lt;span class=&quot;math-container&quot;&gt;$T=4$&lt;/span&gt; the third constraint can be found like the matrix below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{bmatrix}-1&amp;amp;1&amp;amp;0&amp;amp;0\\0&amp;amp;-1&amp;amp;1&amp;amp;0\\0&amp;amp;0&amp;amp;-1&amp;amp;1\end{bmatrix}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is my formulation correct? or is there any more common mathematical representation of this type of problem? any advice will be appreciated! And sorry for poor English.&lt;/p&gt;&#xA;" OwnerUserId="5343" LastEditorUserId="36" LastEditDate="2021-09-19T15:50:04.257" LastActivityDate="2021-09-19T15:50:04.257" Title="dual variable with constraints dealing different time limit" Tags="|duality|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6915" PostTypeId="1" CreationDate="2021-09-12T15:51:38.607" Score="1" ViewCount="60" Body="&lt;p&gt;I read Chapter 19.4 of Schrijver(1986) and get to know that every totally unimodular matrix can be produced by taking operations on network matrices and two certain matrices. I find that some paper says that there are similar building blocks for unimodular matrices. Could you tell me what the building blocks for unimodular matrices are? Why does the decomposition of totally unimodular matrices apply to the decomposition of unimodular matrices?&lt;/p&gt;&#xA;" OwnerUserId="4123" LastActivityDate="2021-09-12T15:51:38.607" Title="Building blocks for unimodular matrices" Tags="|integer-programming|combinatorial-optimization|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6916" PostTypeId="2" ParentId="6900" CreationDate="2021-09-12T17:11:48.233" Score="1" Body="&lt;p&gt;You can refer to the list that is on Gurobi's website:&#xA;&lt;a href=&quot;https://www.gurobi.com/partners/consulting-services/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/partners/consulting-services/&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2021-09-12T17:11:48.233" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6917" PostTypeId="1" CreationDate="2021-09-12T17:39:42.510" Score="4" ViewCount="97" Body="&lt;p&gt;The question is a bit self explanatory I believe, but just to give a simple example (this is not the entire model of course):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = AbstractModel()&#xA;model.i = Set()&#xA;model.j = Set(initialize=model.i)&#xA;model.R = Param(model.i)&#xA;&#xA;def lowband(model,i):&#xA;    return (model.R[i],100)&#xA;model.x = Var(model.i, bounds=lowband, within=NonNegativeReals, initialize=0)&#xA;model.y = Var(model.i, bounds=lowband, within=NonNegativeReals, initialize=0)&#xA;model.W = Var( bounds=(0,100), within=NonNegativeReals, initialize=0)&#xA;model.L = Var( bounds=(0,100), within=NonNegativeReals, initialize=0)&#xA;&#xA;def rule_eq1(model,i,j):&#xA;    if i&amp;gt;j:&#xA;        return (model.x[i]-model.x[j])**2+(model.y[i]-model.y[j])**2 &amp;gt;=(model.R[i]+model.R[j])**2&#xA;    else:&#xA;        return Constraint.Skip;&#xA;model.eq1 = Constraint(model.i,model.j,rule=rule_eq1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I get really annoyed by the variable and parameter names in the constraint declarations because of the &lt;code&gt;model.&lt;/code&gt; part. If after each declaration we do something like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x = model.x&#xA;y = model.y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and so on and use &amp;quot;x&amp;quot; and &amp;quot;y&amp;quot; instead of the original name, it works just fine too. However, the vast majority of pyomo models I see on the internet follow that approach of always using &lt;code&gt;model.&lt;/code&gt;. Is there any good reason for doing this and that I still haven't realised? I think it makes the code writing process worse and it also gets harder to read the code&lt;/p&gt;&#xA;" OwnerUserId="7161" LastActivityDate="2021-09-12T23:23:47.927" Title="In pyomo, any reason for using &quot;model.&lt;nameofvariable&gt;&quot; throughout the code instead of doing &quot;&lt;nameofvariable&gt; = model.&lt;nameofvariable&gt;&quot; and using it?" Tags="|python|pyomo|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6918" PostTypeId="2" ParentId="6917" CreationDate="2021-09-12T23:23:47.927" Score="1" Body="&lt;p&gt;When you say model.x then you know that this x is a part of the model&#xA;but&lt;/p&gt;&#xA;&lt;p&gt;if you see&#xA;model.x-X==2&#xA;what  can you say about the X ?&#xA;is it a constant ? constant in the model ? var in the model ?&lt;/p&gt;&#xA;&lt;p&gt;This also applies to naming the variables&#xA;if you use model.i it works&#xA;alternatively,&#xA;if you use model.generators it works as well!&#xA;but in the second case it is more clear and easier to understand&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2021-09-12T23:23:47.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6919" PostTypeId="2" ParentId="6914" CreationDate="2021-09-13T00:08:56.360" Score="3" Body="&lt;p&gt;You're close, but your indexing is off in the middle dual constraint. I assume you mean &lt;span class=&quot;math-container&quot;&gt;$t\ge 2$&lt;/span&gt; rather than &lt;span class=&quot;math-container&quot;&gt;$t&amp;gt;2$&lt;/span&gt; in the second dual constraint (and that &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; in the last one). Keep in mind that &lt;span class=&quot;math-container&quot;&gt;$x(\tau)$&lt;/span&gt; appears in the third primal constraint with coefficient +1 when &lt;span class=&quot;math-container&quot;&gt;$t=\tau$&lt;/span&gt; and in with coefficient -1 when &lt;span class=&quot;math-container&quot;&gt;$t=\tau+1$&lt;/span&gt;, not when &lt;span class=&quot;math-container&quot;&gt;$t=\tau-1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t=\tau$&lt;/span&gt; respectively.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-09-13T00:08:56.360" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6920" PostTypeId="1" AcceptedAnswerId="6942" CreationDate="2021-09-13T03:58:10.480" Score="3" ViewCount="315" Body="&lt;p&gt;I am solving a stochastic facility location model using Benders decomposition (L-shaped algorithm). In each scenario, I want to allocate demands from origin to a fixed number of closest open facilities. For example, I have about 70 candidate facilities and about 370 demand locations (census blocks). I want to make sure in each scenario demand will be allocated to the closest 30 facilities from each demand location to ensure that people do not have to travel too far. If you worked on any similar problem, Would you share how you construct your constraints?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yAUj2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yAUj2.png&quot; alt=&quot;Deterministic Equivalent Problem&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3288" LastEditorUserId="3288" LastEditDate="2021-09-16T14:32:06.313" LastActivityDate="2021-09-16T19:27:08.897" Title="Stochastic Facility Location Model" Tags="|stochastic-programming|benders-decomposition|facility-location|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6921" PostTypeId="1" AcceptedAnswerId="6925" CreationDate="2021-09-13T05:06:20.480" Score="4" ViewCount="169" Body="&lt;p&gt;Suppose we have a bi-variate function like &lt;span class=&quot;math-container&quot;&gt;$f(x,y)$&lt;/span&gt; which is concave in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\frac{d^2f(x,y)}{dx^2} = -g(x,y)&amp;lt;0$&lt;/span&gt; (that is &lt;span class=&quot;math-container&quot;&gt;$f(x,y)$&lt;/span&gt; can be a function with high order in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; ) but convex in &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, that is &lt;span class=&quot;math-container&quot;&gt;$\frac{d^2f(x,y)}{dy^2}&amp;gt;0$&lt;/span&gt; which is a second-order polynomial function in &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. Here, if we assume that &lt;span class=&quot;math-container&quot;&gt;$0\le y \le 1$&lt;/span&gt;, I am wondering how to determine the optimal solution of the objective function? Because the function is convex in &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, is it possible to say that the optimal value of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is either 0 or 1, and we can determine the optimal value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; condition on &lt;span class=&quot;math-container&quot;&gt;$y=0,1$&lt;/span&gt;? Also, the objective function is always nonnegative for all values of decision variables.&lt;/p&gt;&#xA;&lt;p&gt;If this approach is not correct, please recommend a method to solve the problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{split}&#xA;\max_{x \in R, 0\le y\le 1} f(x,y)&#xA;\end{split}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="491" LastEditDate="2021-09-16T12:52:25.267" LastActivityDate="2021-09-16T12:52:25.267" Title="Maximization of a nonconvex bi-variate function" Tags="|convex-optimization|nonconvex-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6922" PostTypeId="2" ParentId="6907" CreationDate="2021-09-13T07:09:16.680" Score="8" Body="&lt;p&gt;Many many people know Excel and use Excel. So many OR projects start with some Excel spreadsheet. And that is why being able to read from and write to Excel is &lt;a href=&quot;https://www.linkedin.com/pulse/excel-rocket-science-optimization-alex-fleischer/&quot; rel=&quot;noreferrer&quot;&gt;key&lt;/a&gt;. You may even start the project with the &lt;a href=&quot;https://support.microsoft.com/en-us/office/define-and-solve-a-problem-by-using-solver-5d1a388f-079d-43ac-a7eb-f63e45925040&quot; rel=&quot;noreferrer&quot;&gt;Excel solver&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E87yc.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E87yc.jpg&quot; alt=&quot;Excel, Rocket science and optimization&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Moreover Excel is a common tool when companies choose &lt;a href=&quot;https://www.linkedin.com/pulse/plug-in-optimization-last-mile-alex-fleischer/&quot; rel=&quot;noreferrer&quot;&gt;plugin optimization instead of packages, custom or tailored optimization&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oMqMZ.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oMqMZ.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-09-13T07:09:16.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6923" PostTypeId="5" CreationDate="2021-09-13T07:31:32.407" Score="0" Body="&lt;p&gt;Queueing theory has its origins in research by Agner Krarup Erlang when he created models to describe the system of Copenhagen Telephone Exchange company, a Danish company.The ideas have since seen applications including telecommunication, traffic engineering, computing and, particularly in industrial engineering, in the design of factories, shops, offices and hospitals, as well as in project management.&lt;/p&gt;&#xA;" OwnerUserId="2579" LastEditorUserId="2579" LastEditDate="2021-09-13T12:52:58.417" LastActivityDate="2021-09-13T12:52:58.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6924" PostTypeId="4" CreationDate="2021-09-13T07:31:32.407" Score="0" Body="Queueing theory is the mathematical study of waiting lines, or queues. A queueing model is constructed so that queue lengths and waiting time can be predicted. Queueing theory is generally considered a branch of operations research because the results are often used when making business decisions about the resources needed to provide a service." OwnerUserId="2579" LastEditorUserId="2579" LastEditDate="2021-09-13T12:53:03.620" LastActivityDate="2021-09-13T12:53:03.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6925" PostTypeId="2" ParentId="6921" CreationDate="2021-09-13T11:33:55.107" Score="3" Body="&lt;p&gt;Concavity or convexity alone are not sufficient conditions to locate an extremum over an interval, as the function could be constant in some regions with regard to those variables. Strict concavity or strict convexity would be necessary to draw any conclusions. The mathematical condition you gave implies strict convexity and differntiability.&lt;/p&gt;&#xA;&lt;p&gt;You are correct in that if you minimize a strictly concave function the minima are on the extrema of the interval and equivalent if you maximize a strictly convex function the maxima are at extrema of the interval.&lt;/p&gt;&#xA;&lt;p&gt;For any fixed &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; the maximizers of &lt;span class=&quot;math-container&quot;&gt;$h_x(y) = f(x,y)$&lt;/span&gt; are either &lt;span class=&quot;math-container&quot;&gt;$\{0\}, \{1\}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\{0,1\}$&lt;/span&gt;. Further &lt;span class=&quot;math-container&quot;&gt;$h_x(1), h_x(0)$&lt;/span&gt; are both convex so &lt;span class=&quot;math-container&quot;&gt;$\max \{\max_x h_x(1),\max_x h_x(0)\}$&lt;/span&gt; is the maxima.&lt;/p&gt;&#xA;&lt;p&gt;For general non-convex optimization i would suggest looking into these methods.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Local optimization with restarts&lt;/li&gt;&#xA;&lt;li&gt;Interval Newton method&lt;/li&gt;&#xA;&lt;li&gt;Branch and Bound over a convex relaxation (such as McCormick envelopes) of your problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-09-14T08:58:40.560" LastActivityDate="2021-09-14T08:58:40.560" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6926" PostTypeId="1" CreationDate="2021-09-13T15:58:06.470" Score="5" ViewCount="50" Body="&lt;p&gt;In the &lt;a href=&quot;https://en.wikipedia.org/wiki/Multiway_number_partitioning&quot; rel=&quot;noreferrer&quot;&gt;k-way number partitioning&lt;/a&gt; problem, the input is a set of numbers and the goal is to partition them into &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; parts in an optimal way. The most well-studied optimization objective is to &lt;em&gt;minimize&lt;/em&gt; the &lt;em&gt;largest&lt;/em&gt; sum; this problem is equivalent to minimizing the makespan when scheduling jobs on &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; identical machines. For this objective, there are &lt;a href=&quot;https://en.wikipedia.org/wiki/Multiway_number_partitioning#Minimizing_the_largest_sum&quot; rel=&quot;noreferrer&quot;&gt;practical constant-factor approximation algorithms&lt;/a&gt;, attaining 4/3 or 6/5 or 7/6 or 13/11 approximation.&lt;/p&gt;&#xA;&lt;p&gt;I am interested in the dual objective - to &lt;em&gt;maximize&lt;/em&gt; the &lt;em&gt;smallest&lt;/em&gt; sum. For this objective, there is a PTAS - but it is considered impractical since the run-time is polynomial with a very high degree. &lt;a href=&quot;https://en.wikipedia.org/wiki/Multiway_number_partitioning#Maximizing_the_smallest_sum&quot; rel=&quot;noreferrer&quot;&gt;There is also a constant-factor approximation&lt;/a&gt;, which attains an approximation factor of 3/4. &lt;em&gt;My question is:&lt;/em&gt; are there practical algorithms that attain a better constant-factor approximation for the max-min objective? I am looking for something comparable to the min-max objective, e.g. 4/5 or 5/6 or 6/7 or 11/13.&lt;/p&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2021-09-13T15:58:06.470" Title="Constant-factor approximation algorithms for max-min number partitioning" Tags="|reference-request|scheduling|approximation-algorithms|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6927" PostTypeId="1" CreationDate="2021-09-14T02:18:33.220" Score="3" ViewCount="175" Body="&lt;p&gt;Does anyone know if there is a list of available function APIs for Mosek Fusion APIs? Namely, what functions are available, their arguments list and meaning, what they do. Something similar to UNIX man pages or standard R or python API references.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to convert a script based on Fusion APIs to its underlying Optimizer APIs? Essentially trying to understand how a simple formulation using Fusion APIs can be formulated equivalently using a lower level Optimizer APIs.&lt;/p&gt;&#xA;" OwnerUserId="6060" LastEditorUserId="123" LastEditDate="2021-09-14T06:41:00.683" LastActivityDate="2021-09-14T06:41:00.683" Title="Mosek Fusion APIs" Tags="|optimization|api|mosek|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6928" PostTypeId="2" ParentId="6927" CreationDate="2021-09-14T05:24:43.870" Score="4" Body="&lt;p&gt;The second line in the table at&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.mosek.com/documentation/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.mosek.com/documentation/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;has all the Fusion manuals. For instance&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://docs.mosek.com/latest/pythonfusion/api-reference.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.mosek.com/latest/pythonfusion/api-reference.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;is what you are looking for in the Python case. In any case we at Mosek are not aware of any other documentation.&lt;/p&gt;&#xA;&lt;p&gt;A Fusion model cannot be converted to an optimizer API model automatically. You have to do that by hand. (Btw the overhead of Fusion is in most cases insignificant.)&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2021-09-14T05:24:43.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6929" PostTypeId="2" ParentId="5563" CreationDate="2021-09-14T09:21:45.273" Score="6" Body="&lt;p&gt;Please direct licensing questions to &lt;a href=&quot;https://support.gurobi.com/&quot; rel=&quot;noreferrer&quot;&gt;Gurobi Support&lt;/a&gt; directly or check the official &lt;a href=&quot;https://support.gurobi.com/hc/en-us/sections/360001969411-Accounts-and-Licensing&quot; rel=&quot;noreferrer&quot;&gt;Knowledge Base articles&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2021-09-14T09:21:45.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6930" PostTypeId="1" CreationDate="2021-09-14T16:39:32.117" Score="2" ViewCount="148" Body="&lt;p&gt;I am trying to use &lt;code&gt;cplexAPI&lt;/code&gt; to solve quadratic programs or quadratically constrained linear program.&lt;/p&gt;&#xA;&lt;p&gt;While it seems to be pretty straightforward to use &lt;code&gt;cplexAPI&lt;/code&gt; to solve linear programs (with the vignette at &lt;a href=&quot;https://cran.r-project.org/web/packages/cplexAPI/vignettes/cplexAPI.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cran.r-project.org/web/packages/cplexAPI/vignettes/cplexAPI.pdf&lt;/a&gt;), it seems that using &lt;code&gt;cplexAPI&lt;/code&gt; to solve quadratic programs or linear programs with a quadratic constraint is much more difficult. I tried to look over the package documentation, but I have no clue on how to do so.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, may I know how to use &lt;code&gt;cplexAPI&lt;/code&gt; to solve quadratic programs or linear programs, or if there is any code samples for these two tasks?&lt;/p&gt;&#xA;&lt;p&gt;In addition, the package &lt;code&gt;Rcplex&lt;/code&gt; seems to be pretty similar, but its last update is already more than 5 years ago. So it would be really nice to know how the above two tasks can be done using &lt;code&gt;cplexAPI&lt;/code&gt; in R. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="7210" LastActivityDate="2021-09-17T09:54:52.057" Title="How to use `cplexAPI` to solve quadratic programs/quadratically constrained linear programs?" Tags="|linear-programming|cplex|quadratic-programming|r|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6931" PostTypeId="2" ParentId="6930" CreationDate="2021-09-14T17:09:21.623" Score="1" Body="&lt;p&gt;This document available on link &lt;a href=&quot;https://cran.r-project.org/web/packages/Rcplex/Rcplex.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cran.r-project.org/web/packages/Rcplex/Rcplex.pdf&lt;/a&gt; for RCplex might be helpful for you. Page 7 &amp;amp; 8 has an example of QCP.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2021-09-14T17:09:21.623" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6932" PostTypeId="5" CreationDate="2021-09-15T01:13:29.633" Score="0" Body="&lt;p&gt;These are some introductory tutorials on using Excel to solve various linear optimization problems:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=GmAuHDROslU&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lecture 5P1: IE 3340 Operations Research - Solving LP problems using Excel&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=IyzWiW7yb1g&quot; rel=&quot;nofollow noreferrer&quot;&gt;Solving linear equations using Excel&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=6xa1x_Iqjzg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linear Programming (LP) Optimization with Excel Solver&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=DT8_uod6wdY&quot; rel=&quot;nofollow noreferrer&quot;&gt;Assignment Problem Using Excel&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2579" LastEditorUserId="123" LastEditDate="2021-09-15T06:43:12.747" LastActivityDate="2021-09-15T06:43:12.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6933" PostTypeId="4" CreationDate="2021-09-15T01:13:29.633" Score="0" Body="For questions related to the use of Excel and the Excel solver. The Excel solver is an add-in that allows the solution of linear programming problems, such as product mix problems (whether maximization or minimization), transportation problems and problems for the allocation of scarce resources. The spreadsheet is easy to use and fast to raise the model. It can obtain the reports of the optimal solution and the sensitivity analysis in a matter of seconds." OwnerUserId="2579" LastEditorUserId="123" LastEditDate="2021-09-15T06:43:12.747" LastActivityDate="2021-09-15T06:43:12.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6934" PostTypeId="1" AcceptedAnswerId="6948" CreationDate="2021-09-15T07:45:38.600" Score="5" ViewCount="225" Body="&lt;p&gt;I want to formulate a game of darts as a dynamic program. The goal is to minimize the number of darts thrown while reaching checkout. A dart player has a score &lt;em&gt;s&lt;/em&gt;. If his score is &lt;em&gt;s = &lt;code&gt;2&lt;/code&gt;&lt;/em&gt;, there is only a single legal / possible move.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;He can checkout by throwing at &lt;code&gt;D1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Every other action is not legal and results in a so-called bust and&#xA;the score remains the same, &lt;em&gt;s = &lt;code&gt;2&lt;/code&gt;&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The above can be formulated as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4i27r.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4i27r.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;em&gt;z&lt;/em&gt; represents the outcome on the dartboard&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;z ∈ {S1, S2, S3, ..., D1, D2, D3, ..., T1, T2, T3, SB, DB}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The corresponding numerical scores are &lt;em&gt;h&lt;/em&gt;. So if &lt;em&gt;z=&lt;code&gt;T20&lt;/code&gt;&lt;/em&gt;, &lt;em&gt;h=&lt;code&gt;60&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now the Bellman equation for this DP satisfies:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eXA2U.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eXA2U.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;em&gt;V(s)&lt;/em&gt; is the value function when the score is equal to &lt;em&gt;s&lt;/em&gt;. In addition, &lt;em&gt;mu&lt;/em&gt; is the aiming location on the dartboard. The reward of each action is equal to &lt;code&gt;1&lt;/code&gt; (because one dart is thrown). In addition, we have &lt;em&gt;p&lt;/em&gt;, the probabilities of reaching &lt;em&gt;s_i+1&lt;/em&gt; when aiming at &lt;em&gt;mu&lt;/em&gt;, and the corresponding value function of &lt;em&gt;s_i+1&lt;/em&gt;. The terminal condition &lt;em&gt;V(0)&lt;/em&gt; is equal to &lt;code&gt;0&lt;/code&gt;. All of the above can be found op page 13 &lt;a href=&quot;http://The%20formula%20can%20be%20found%20on%20page%2013%20of%20arxiv.org/pdf/2011.11031.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So, inserting all for &lt;em&gt;s = &lt;code&gt;2&lt;/code&gt;&lt;/em&gt;, excluding the illegal moves, leads to the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;V(2) = min{1 + (V(0) * p(D1;mu))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Lets assume there are two possible values for &lt;em&gt;mu&lt;/em&gt;, namely the center of &lt;code&gt;D1&lt;/code&gt; and the center of &lt;code&gt;D19&lt;/code&gt;, which is on the opposite of the dartboard. Logically&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;p(z=D1, mu=center D1) &amp;gt; p(z=D1, mucenter D19)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, &lt;em&gt;V(0) = &lt;code&gt;0&lt;/code&gt;&lt;/em&gt;, so&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;p(z=D1, mu=center D1) * V(0) =  p(z=D1, mu=center D19) * V(0) =  0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So, if we want to minimize the Bellman curve, there is no optimal solution. Both options lead to the same result, &lt;em&gt;V(2) = &lt;code&gt;1&lt;/code&gt;&lt;/em&gt;. However, logical reasoning would suggest aiming for &lt;em&gt;mu = center D1&lt;/em&gt; is the optimal / desired solution. What am I doing wrong here?&lt;/p&gt;&#xA;&lt;p&gt;So, I thought maybe I should add the illegal moves into the Bellman equation. This would look as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;V(2) = min{1 + sum((V(0) * p(D1;mu)) + (V(2) * p(S1;mu)) + (V(2) * p(S2;mu)) + ... + (V(2) * p(T19;mu)) + (V(2) * p(T20;mu)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, now there is a circular reference for all the illegal moves. How should this be addressed? Should the illegal moves be added? Please help me explain what I am doing wrong.&lt;/p&gt;&#xA;" OwnerUserId="6138" LastEditorUserId="500" LastEditDate="2022-04-11T01:04:11.973" LastActivityDate="2022-04-11T01:04:11.973" Title="Circular reference in states of the Bellman equation" Tags="|optimization|dynamic-programming|puzzles-games|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="6935" PostTypeId="1" CreationDate="2021-09-15T15:52:43.363" Score="6" ViewCount="404" Body="&lt;p&gt;I have the following model which I am going to solve with column generation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  \max &amp;amp; \sum_{b \in B} \sum_{s \in S} \sum_{r \in \Omega_s}\beta_{bs}p_r y_{br}\label{objective-set1}\\&#xA;    \text{s.t.}&#xA;    &amp;amp; \sum_{b \in B} \sum_{s \in S} \sum_{r \in \Omega_s} a_{ir}y_{br} \leq 1 &amp;amp; i \in P \label{c1-set1}\\&#xA;    &amp;amp;\sum_{s \in S}\sum_{r \in \Omega_{s}} \beta_{bs}y_{br} \leq 1 &amp;amp; b \in B \label{c2-set1}\\&#xA;    &amp;amp;\sum_{b \in B}\sum_{r \in \Omega_{s}} \beta_{bs} y_{br} \leq V_s &amp;amp; s \in S \label{c3-set1}\\&#xA;    &amp;amp; y_{br} \in \{0,1\} &amp;amp; b \in B, s \in S,  r \in \Omega_s  \label{c5-set1}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I try to obtain the reduced costs of the variables by taking the dual of this model. I want to add new columns to the set &lt;span class=&quot;math-container&quot;&gt;$\Omega_s$&lt;/span&gt; using the pricing problem. So, I assume that the problem is decomposable into a set of pricing subproblems —one for each &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;. Based on this, I tried to write the reduced costs by forming the constraint of the dual problem. This is what I came up with.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i \in P} a_{ir}\lambda_i + \beta_{bs} \gamma_b + \beta_{bs} \theta_s \geq p_r\beta_{bs} \quad b \in B, r \in \Omega_s&#xA;\end{align}&lt;/span&gt;&#xA;Using this equation, I can write the pricing subproblems in minimization form for each &lt;span class=&quot;math-container&quot;&gt;$b \in B$&lt;/span&gt; and for each &lt;span class=&quot;math-container&quot;&gt;$s \in S$&lt;/span&gt; as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;   &amp;amp;\min \Bigg\{ \sum_{i \in P} a_{ir}\lambda_i + \beta_{bs} \gamma_b + \beta_{bs} \theta_s - p_r\beta_{bs}\Bigg\} = &#xA;&amp;amp; \min \Bigg\{ \sum_{i \in P} a_{ir}(\lambda_i - p_i \beta_{bs}) + \beta_{bs} \gamma_b + \beta_{bs} \theta_s\Bigg\}&#xA;\end{align}&lt;/span&gt;&#xA;I can say that there is a pricing subproblem corresponding to &lt;span class=&quot;math-container&quot;&gt;$b \in B$&lt;/span&gt; and each &lt;span class=&quot;math-container&quot;&gt;$s \in S$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7212" LastEditorUserId="7212" LastEditDate="2021-10-18T09:16:23.397" LastActivityDate="2021-10-18T09:16:23.397" Title="Dual of a model to obtain reduced costs" Tags="|mixed-integer-programming|duality|column-generation|branch-and-price|reduced-costs|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="6936" PostTypeId="1" CreationDate="2021-09-15T20:00:56.363" Score="3" ViewCount="196" Body="&lt;p&gt;I'm writing my thesis on the optimal location of Air-Taxi Stations. I'm using PTV VISUM for the transport model where I'll inherit the Origin-Destination demand matrix. I come from transportation engineering masters so Operations Research is quite new to me.&lt;/p&gt;&#xA;&lt;p&gt;VISUM is a software that does macrosimulation for transportation. It divides a map or a region with zones. Each zone has population, workplaces, school places, commercial places and so on.&lt;/p&gt;&#xA;&lt;p&gt;There would be one (potential) Air-Taxi station on each zone. The optimization problem is to discover which ones will be activated (0 and 1s).&lt;/p&gt;&#xA;&lt;p&gt;Now, location problems are plenty discussed in papers and books and there are a lot of tutorials of how to write them using many different (programming) languages. I'm formulating my problem as an 'Uncapacitated Facility Location Problem', as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ngyf8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ngyf8.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Cornuéjols, Gérard; Nemhauser, George; Wolsey, Laurence (1990): The uncapicitated facility location problem. In Pitu B. Mirchandani, Richard L. Francis (Eds.): Discrete location theory. New York: Wiley (Wiley-Interscience series in discrete mathematics and optimization), pp. 119–171.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; would be the total revenue from zone &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to zone &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f_j$&lt;/span&gt; is the cost for opening a new station in &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With this formulation, there isn't a set number of stations, but a balance between demand served and the opening costs of a new station.&lt;/p&gt;&#xA;&lt;h2&gt;Now comes the tricky part:&lt;/h2&gt;&#xA;&lt;p&gt;Whenever there's a new set of locations where the stations are open, the transport model would return an OD matrix, which would, in turn, change the set of open locations.&lt;/p&gt;&#xA;&lt;p&gt;I'm using Gurobi for the optimization part. Normally, a bi-level problem has 2 objective functions declared. In my case, one of the objective functions, the one which gives me the demand, comes from a different software.&lt;/p&gt;&#xA;&lt;p&gt;Question: How can I integrate both GUROBI and VISUM in order to get a 'ping-pong' between them? I didn't find a way in order to make Gurobi 'wait' for the new OD matrix values for the next step of the optimization.&lt;/p&gt;&#xA;&lt;h3&gt;Edits:&lt;/h3&gt;&#xA;&lt;p&gt;To clarify, the input for the transport model (VISUM) would be a string of 0 and 1s stating which stations would be open or now. With these stations, VISUM would then calculate the demand for the service.&lt;/p&gt;&#xA;&lt;p&gt;The output from VISUM (and input for the optimization problem on Gurobi) would be the OD matrix (and, consequently, the revenue from each OD pair &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;--&#xA;VISUM does have a Python console and can run internal or external scripts. I can also control VISUM via COM-commands from the outside (on an IDE, for example).&lt;/p&gt;&#xA;" OwnerUserId="7213" LastEditorUserId="7213" LastEditDate="2021-09-16T02:45:16.823" LastActivityDate="2021-09-16T16:19:48.893" Title="A tricky Bi-Level Location Problem using VISUM" Tags="|gurobi|binary-variable|facility-location|bilevel-optimization|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6938" PostTypeId="1" AcceptedAnswerId="6941" CreationDate="2021-09-16T16:07:08.890" Score="2" ViewCount="645" Body="&lt;p&gt;I have the following problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;number_of_machines&lt;/code&gt; is controlled by other constraints. I need to set line variable to specific value based on &amp;quot;range&amp;quot; constraint.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;number_of_machines = model.NewIntVar(0, 100, '')&#xA;&#xA;model.Add(line == 1).OnlyEnforceIf(number_of_machines &amp;gt; 5 and number_of_machines &amp;lt;= 10)&#xA;model.Add(line == 6).OnlyEnforceIf(number_of_machines &amp;gt;= 11 and number_of_machines &amp;lt;= 20)&#xA;model.Add(line == 2).OnlyEnforceIf(number_of_machines &amp;gt;= 21 and number_of_machines &amp;lt;= 50)&#xA;model.Add(line == 8).OnlyEnforceIf(number_of_machines &amp;gt;= 51 and number_of_machines &amp;lt;= 100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;for &amp;quot;AND&amp;quot; I'm getting the error: NotImplementedError: Evaluating a LinearExpr instance as a Boolean is not implemented.&#xA;And for linear expression I'm getting another error: 'BoundedLinearExpression' object has no attribute 'Index'&lt;/p&gt;&#xA;&lt;p&gt;Could you help me with how I should set such conditions in the CP-SAT model?&lt;/p&gt;&#xA;&lt;p&gt;UPDATED: fixed directions of comparisons (as noticed in the answer)&lt;/p&gt;&#xA;" OwnerUserId="5399" LastEditorUserId="981" LastEditDate="2023-12-22T15:11:50.463" LastActivityDate="2023-12-22T15:11:50.463" Title="Set value based on if other variable is in specific range" Tags="|constraint-programming|or-tools|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6939" PostTypeId="2" ParentId="6935" CreationDate="2021-09-16T16:13:09.370" Score="2" Body="&lt;p&gt;It's a bit tricky to sort out what is going on here. Given a dual solution (&lt;span class=&quot;math-container&quot;&gt;$\lambda,\gamma,\theta$&lt;/span&gt;) to the LP relaxation of the master problem, your subproblem will need to solve for &lt;span class=&quot;math-container&quot;&gt;$a_{ir}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta_{bs}$&lt;/span&gt; (or not; see below) so as to maximize the expression on the left side of your dual constraint, subject to whatever constraints there are for &lt;span class=&quot;math-container&quot;&gt;$a_{ir}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta_{bs}$&lt;/span&gt; (about which I have no idea, since the question provides no context for what columns represent). If the maximum value of the column generator objective exceeds the right side of your dual constraint, you'll add the new column to the master problem.&lt;/p&gt;&#xA;&lt;p&gt;You'll have to solve the column generation subproblem for a specific &lt;span class=&quot;math-container&quot;&gt;$b\in B$&lt;/span&gt;, which likely means iterating over &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; until a subproblem succeeds in generating a new column. That leaves the question of which &lt;span class=&quot;math-container&quot;&gt;$\Omega_s$&lt;/span&gt; gets the new column. Since &lt;span class=&quot;math-container&quot;&gt;$\beta_{bs}$&lt;/span&gt; is the same for all &lt;span class=&quot;math-container&quot;&gt;$r\in\Omega_s$&lt;/span&gt;, I can see two possibilities. If currently &lt;span class=&quot;math-container&quot;&gt;$\Omega_s = \emptyset$&lt;/span&gt;, you column generator will treat both &lt;span class=&quot;math-container&quot;&gt;$a_{ir}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta_{bs}$&lt;/span&gt; as variables. If not, the &lt;span class=&quot;math-container&quot;&gt;$\beta_{bs}$&lt;/span&gt; are fixed and only the &lt;span class=&quot;math-container&quot;&gt;$a_{ir}$&lt;/span&gt; are variables.&lt;/p&gt;&#xA;&lt;p&gt;At this point, I'm not sure whether you want to pick the &lt;span class=&quot;math-container&quot;&gt;$s\in S$&lt;/span&gt; that will get the new column up front, or iterate overall combinations of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; until you get a new column, or let the column generation problem pick &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; by introducing binary variables to select an &lt;span class=&quot;math-container&quot;&gt;$s\in S$&lt;/span&gt; (making the column generation problem a MIP if it wasn't already one).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-09-16T16:13:09.370" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6940" PostTypeId="2" ParentId="6936" CreationDate="2021-09-16T16:19:48.893" Score="3" Body="&lt;p&gt;Following is a possible way of its implementation:&#xA;First, you define a function that takes an OD matrix, solves the GUROBI model, and returns the optimal locations.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;FUNCTION OPTIMAL_LOCATION(OD):&#xA;         // This part will prepare the gurobi model and change the parameters related to OD matrix&#xA;        // Solve the model and return locations&#xA;END FUNCTION&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Second, you write a while loop that checks whether the optimal locations have changed.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;changed = TRUE&#xA;WHILE changed == TRUE do&#xA;    prev_locations = current_locations&#xA;    OD &amp;lt;- FUNCTION ESTIMATE_DEMAND(current_locations):&#xA;                  // here VISUM code will take current_locations and estimate the new OD_matrix&#xA;                  // return the new OD matrix&#xA;    current_locations &amp;lt;- OPTIMAL_LOCATION(OD)&#xA;    if current_locations  == prev_locations:&#xA;       changed == FALSE&#xA;END WHILE&#xA;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note: 1. There could be a different criterion for convergence. For example, the objective value of the optimization program. Also, above procedure may not converge.&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Even if it converges, it may not be a Stackelberg equilibrium, which I think you are trying to achieve.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2424" LastActivityDate="2021-09-16T16:19:48.893" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6941" PostTypeId="2" ParentId="6938" CreationDate="2021-09-16T19:11:05.697" Score="4" Body="&lt;p&gt;Please read &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/sat/doc/channeling.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/ortools/sat/doc/channeling.md&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;OnlyEnforceIf()&lt;/code&gt; only accept one or more Boolean literals.&lt;/p&gt;&#xA;&lt;p&gt;So for the first constraint (assuming there is an error in the direction of the comparisons):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;b1 = model.NewBoolVar()&#xA;model.AddLinearConstraint(number_of_machines, 6, 10).OnlyEnforceIf(b1)&#xA;model.Add(line == 8).OnlyEnforceIf(b1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and most likely in the end&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.Add(sum(bi) == 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="981" LastActivityDate="2021-09-16T19:11:05.697" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6942" PostTypeId="2" ParentId="6920" CreationDate="2021-09-16T19:27:08.897" Score="2" Body="&lt;p&gt;To impose the distance restriction, use a sparse index set of &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; pairs rather than the full Cartesian product &lt;span class=&quot;math-container&quot;&gt;$I \times J$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Also, you might consider omitting constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, which will naturally be satisfied unless the penalty for unmet demand is too small to encourage opening any facilities, and constraint &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt;, which is logically implied by &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt;.  It is possible for these unnecessary constraints to tighten the formulation, but it is also likely that their inclusion would just artificially inflate the problem size, making the underlying LP solves slower.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-09-16T19:27:08.897" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6943" PostTypeId="1" CreationDate="2021-09-17T08:38:59.830" Score="2" ViewCount="33" Body="&lt;p&gt;I am trying to optimise a cost function that consists of three parameters (A,B,C) using weighted sum approach for the selection of optimal technique out of three techniques.  Parameter A unit is in percentage while parameter B and C unit is milliseconds. Parameter A is beneficial attribute, while B and C are non-beneficial attributes.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;min(cost)=Aw1+Bw2+Cw3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The following data, normalised by considering beneficial and non-beneficial attributes. I am trying to minimise the cost of the function of t weighted sum approach that provides the best technique out of three technique with supplied user weights. However, I noticed that for better input the cost function is higher for instance for 4.466916 the normalised value is 1 and for 24.2542 it's 1 in below data&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Parameter B                 Min&#xA;4.466916 27.07074 24.57503 4.466916 &#xA;24.2542  27.07074 25.95272 24.2542  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Normalised data after applying formula xmin/x&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1 0.165009  0.181766&#xA;1 0.895956  0.934553&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Below is the data of Parameter A data which consists of data of three techniques T1,T2,T3&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  T1    T2      T3       Max&#xA;0.6233  0.8253  0.8324  0.8324      &#xA;0.8063  0.8253  0.8311  0.8311  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Normalised data after applying formula x=x/xmax&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;0.748799 0.991444 1&#xA;0.97016  0.993021 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, for above data I am trying to understand and couldn't understand that for better input the cost function is higher which should be minimum for instance for 4.466916 the normalised value is 1 and for 24.2542 which is not a better input its one. Would anyone please me in understand this&lt;/p&gt;&#xA;" OwnerUserId="7216" LastEditorUserId="7216" LastEditDate="2021-09-17T09:20:39.480" LastActivityDate="2021-09-17T09:20:39.480" Title="How to interpret this problem of multicriteria decision" Tags="|optimization|multi-objective-optimization|multicriteria-decision-analysis|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6944" PostTypeId="2" ParentId="6930" CreationDate="2021-09-17T09:54:52.057" Score="1" Body="&lt;p&gt;with cplexAPI you may use &lt;a href=&quot;https://rdrr.io/cran/cplexAPI/man/addQConstrCPLEX.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;addQConstrCPLEX&lt;/a&gt; to add quadratic constraints&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-09-17T09:54:52.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6945" PostTypeId="1" AcceptedAnswerId="6946" CreationDate="2021-09-17T11:22:13.107" Score="8" ViewCount="167" Body="&lt;p&gt;I am currently working on weighted perfect bipartite matching, i.e., assignment problem.&lt;/p&gt;&#xA;&lt;p&gt;Formally speaking, it could be formulated as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;min \sum\limits_{i=1}^{N}\sum_{j=1}^{N}c_{ij}x_{ij}&#xA;$$&lt;/span&gt;&#xA;, where&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum\limits_{j=1}^{N}x_{ij} = 1 (i=1...N),\\&#xA;\sum\limits_{i=1}^{N}x_{ij} = 1 (j=1...N),\\&#xA;x_{ij}\in \{0,1\}&#xA;$$&lt;/span&gt;&#xA;Here, &lt;span class=&quot;math-container&quot;&gt;$c_{ij}\in R$&lt;/span&gt; is given as the cost matrix.&lt;/p&gt;&#xA;&lt;p&gt;But now, my problem has an additional constraint on it : &lt;span class=&quot;math-container&quot;&gt;$c_{ij} &amp;lt; c_{ij'}$&lt;/span&gt; if  &lt;span class=&quot;math-container&quot;&gt;$j &amp;lt; j'$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;That is, &lt;b&gt;each row of the cost matrix is monotonically increasing&lt;/b&gt;. For example, the following cost matrix:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lyack.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lyack.png&quot; alt=&quot;cost matrix&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;(By analogy with workers and jobs, it is like that jobs in right is more difficult so every workers needs more time to get it done.)&lt;/p&gt;&#xA;&lt;p&gt;The classic Kuhn-Munkres algorithm can be used to solve assignment problem and it can be applied to this surely. But I wonder if any faster algorithm (or related research) exists. I have tried some greedy approaches but it doesn't seem to work.&lt;/p&gt;&#xA;&lt;p&gt;Thanks!!&lt;/p&gt;&#xA;" OwnerUserId="5521" LastEditorUserId="67" LastEditDate="2021-09-17T15:40:14.047" LastActivityDate="2021-09-17T15:48:09.783" Title="A variant of weighted perfect bipartite matching" Tags="|assignment-problem|cost-matrix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6946" PostTypeId="2" ParentId="6945" CreationDate="2021-09-17T15:48:09.783" Score="8" Body="&lt;p&gt;I don't think the monotonicity will help much, for the following reason. Start with any arbitrary assignment problem. Add a constant amount &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$c_{i2}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; sufficiently large to make &lt;span class=&quot;math-container&quot;&gt;$c_{i2} &amp;gt; c_{i1}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Since someone has to be assigned to sink 2, this effectively adds a constant amount &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; to the objective function, and so any optimal solution to the modified problem will be optimal in the original problem (and vice versa). Now repeat, adding a (different) constant amount to each column of the cost matrix to make it bigger than the previous column, until the monotonicity condition is satisfied.&lt;/p&gt;&#xA;&lt;p&gt;What this shows is that every assignment problem is equivalent (in the sense of having exactly the same feasible region and exactly the same set of optimal solutions) to an assignment problem satisfying the monotonicity condition. If someone had found a way to exploit monotonicity, it would be used for &lt;em&gt;all&lt;/em&gt; assignment problems. As far as I know, there is no such algorithm for the general assignment problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-09-17T15:48:09.783" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6947" PostTypeId="1" CreationDate="2021-09-17T18:23:59.923" Score="7" ViewCount="931" Body="&lt;h2&gt;In a nutshell&lt;/h2&gt;&#xA;&lt;p&gt;I have a small 2-dimensional polyhedral cone.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$C=\{(x_1,x_2): 2x_1-x_2 \leq 0, x_1+3x_2 \leq 0\}$$&lt;/span&gt;&#xA;I am looking for a simple, illustrative, procedure to get its extreme rays.&#xA;Any suggestions?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;My reasoning (if you have time)&lt;/h2&gt;&#xA;&lt;p&gt;I am looking for something along these lines, not sure if it works.&#xA;We can express &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$C=\{(x_1,x_2)=\alpha_1r_1+\alpha_2r_2, \alpha_1,\alpha_2\geq 0\}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$r_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r_2$&lt;/span&gt; are the two rays I am looking for.&#xA;To find &lt;span class=&quot;math-container&quot;&gt;$r_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r_2$&lt;/span&gt; I can probably express &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; as a function of the rays in the linear inequalities above, and use the extra condition that at an extreme rays we have &lt;span class=&quot;math-container&quot;&gt;$2-1$&lt;/span&gt; binding constraints. This should give me:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$2r_1^1-r_1^2 = 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$r_2^1+3r_2^2 = 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But I don't seem to get anywhere, since I have two equations and four unknowns. Is it perhaps correct to say that the extreme rays the following?&#xA;&lt;span class=&quot;math-container&quot;&gt;$$r_1^1=1/2r_1^2 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$r_2^1=-3r_2^2 $$&lt;/span&gt;&#xA;Thus&#xA;&lt;span class=&quot;math-container&quot;&gt;$$r_1= (1/2r_1^2, r_1^2)$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$r_2=(-3r_2^2,r_2^2)$$&lt;/span&gt;&#xA;This is any point along the hyperplanes that define the cone. Does that sound right?&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="766" LastEditDate="2021-09-18T09:50:03.300" LastActivityDate="2021-09-18T20:48:32.470" Title="Extreme rays of a small polyhedral cone: How do I get them?" Tags="|polyhedra|cone|extreme-rays|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6948" PostTypeId="2" ParentId="6934" CreationDate="2021-09-17T21:22:25.023" Score="4" Body="&lt;p&gt;For each state &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, you want to compute the value function &lt;span class=&quot;math-container&quot;&gt;$V(s)$&lt;/span&gt;, which satisfies &lt;span class=&quot;math-container&quot;&gt;$V(0)=0$&lt;/span&gt; and the Bellman equation for &lt;span class=&quot;math-container&quot;&gt;$s \not= 0$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V(s) = \min_\mu\left\{1+\sum_z V(f(s,z)) p(z;\mu)\right\}. \tag{13}$$&lt;/span&gt;&#xA;The &lt;span class=&quot;math-container&quot;&gt;$\min_\mu$&lt;/span&gt; is over all legal actions &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; in state &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.  The &lt;span class=&quot;math-container&quot;&gt;$\sum_z$&lt;/span&gt; is over all outcomes &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; that can occur when action &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; is taken in state &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.  As a consequence, &lt;span class=&quot;math-container&quot;&gt;$\sum_z p(z;\mu)=1$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;, so you can use that property to help check that you have constructed &lt;span class=&quot;math-container&quot;&gt;$(13)$&lt;/span&gt; correctly when you write everything out explicitly with actual numbers.  In particular, when &lt;span class=&quot;math-container&quot;&gt;$s=2$&lt;/span&gt; and the only legal action is &lt;span class=&quot;math-container&quot;&gt;$\mu=D_1$&lt;/span&gt;, the Bellman equation is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V(2) = 1+V(0) p(D_1;D_1) + V(2) (1-p(D_1;D_1)) = 1+ V(2) (1-p(D_1;D_1)),$$&lt;/span&gt;&#xA;which implies that &lt;span class=&quot;math-container&quot;&gt;$V(2)=1/p(D_1;D_1)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$f(s,z) &amp;lt; s$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$p(z;\mu)&amp;gt;0$&lt;/span&gt;, you can solve &lt;span class=&quot;math-container&quot;&gt;$(13)$&lt;/span&gt; recursively by considering states in increasing order.  But as you have observed, sometimes &lt;span class=&quot;math-container&quot;&gt;$f(s,z)=s$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$p(z;\mu)&amp;gt;0$&lt;/span&gt;, which leads to an equation with a circular reference in that &lt;span class=&quot;math-container&quot;&gt;$V(s)$&lt;/span&gt; appears both on the left-hand side and on the right-hand side as a minimand.  In this situation, there are several approaches to solve &lt;span class=&quot;math-container&quot;&gt;$(13)$&lt;/span&gt;, including &lt;a href=&quot;https://en.wikipedia.org/wiki/Markov_decision_process#Algorithms&quot; rel=&quot;nofollow noreferrer&quot;&gt;value iteration, policy iteration&lt;/a&gt;, and linear programming (LP).  The LP is to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_s V(s)$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;V(s) &amp;amp;\le 1+\sum_z V(f(s,z)) p(z;\mu) &amp;amp;&amp;amp;\text{for $s \not= 0$ and all $\mu$} \\&#xA;V(0) &amp;amp;= 0 \\&#xA;V(s) &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $s$} \\&#xA;\end{align}&lt;/span&gt;&#xA;The positive LP dual variables indicate which action or actions to take in each state.&lt;/p&gt;&#xA;&lt;p&gt;For an application to the casino game blackjack (where the problem is to maximize expected profit rather than minimize the expected number of darts thrown), see &lt;a href=&quot;https://blogs.sas.com/content/operations/2016/06/20/computing-an-optimal-blackjack-strategy-with-sasor/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this blog post&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-09-17T21:53:32.633" LastActivityDate="2021-09-17T21:53:32.633" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6949" PostTypeId="1" CreationDate="2021-09-18T09:43:05.630" Score="10" ViewCount="675" Body="&lt;p&gt;I have a startup idea and I am coming from a CS background.&lt;/p&gt;&#xA;&lt;p&gt;The startup tries to solve the following problem. A company having a set of employees that needs to visit several &amp;quot;customers&amp;quot; each day. The employees' mission consist of charge vending machines, repair elevators, install furniture etc.&lt;/p&gt;&#xA;&lt;p&gt;There are several aspects to take into account:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each employee has some availability: working hours, week-ends, vacancies etc.&lt;/li&gt;&#xA;&lt;li&gt;Each task can be done only by a subset of the employees that have the required set of &amp;quot;skills&amp;quot;.&lt;/li&gt;&#xA;&lt;li&gt;The &amp;quot;clients&amp;quot; have real-geographical points and the employees use the GPS in their vehicles to move between points. So, somehow the &amp;quot;distances&amp;quot; are the time to get from one point to another.&lt;/li&gt;&#xA;&lt;li&gt;Some clients have only time windows in which they are available. An employee cannot visit a non-available client.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;My questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there other real-world aspects that are crucial and that I need to take into accounts?&lt;/li&gt;&#xA;&lt;li&gt;Is there a name for this problem?&lt;/li&gt;&#xA;&lt;li&gt;Is there some books/papers etc. that talk thoroughly about the problem?&lt;/li&gt;&#xA;&lt;li&gt;Do you know about existing applications in industry that solve the same problem?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;PS: Sorry, I am not a native english-speaker.&lt;/p&gt;&#xA;" OwnerUserId="7222" LastActivityDate="2021-09-21T19:49:19.570" Title="What is the state-of-art (in industry and academy) of this scheduling + routing problem?" Tags="|scheduling|vehicle-routing|applications|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6950" PostTypeId="2" ParentId="6949" CreationDate="2021-09-18T10:27:35.280" Score="6" Body="&lt;p&gt;This is a variant of a workforce scheduling and routing problem.&lt;/p&gt;&#xA;&lt;p&gt;Here are two recent surveys where you can find variants, resolution methods and applications:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&amp;quot;Workforce scheduling and routing problems: literature survey and computational study&amp;quot; (Castillo-Salazar et al., 2016) &lt;a href=&quot;https://doi.org/10.1007/s10479-014-1687-2&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&amp;quot;Routing and scheduling in Home Health Care: A literature survey and bibliometric analysis&amp;quot; (Mascolo et al., 2021) &lt;a href=&quot;https://doi.org/10.1016/j.cie.2021.107255&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You can find many other articles on &lt;a href=&quot;https://scholar.google.com/scholar?q=workforce+routing+and+scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google scholar&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;For practical considerations, you might be interested in:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;quot;Vehicle Routing: Problems, Methods, and Applications, Second Edition&amp;quot;, Chapter 12: Software Tools and Emerging Technologies for Vehicle Routing and Intermodal Transportation (Bräysy and Hasle, 2014) &lt;a href=&quot;https://doi.org/10.1137/1.9781611973594.ch12&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2021-09-18T22:43:23.250" LastActivityDate="2021-09-18T22:43:23.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6951" PostTypeId="2" ParentId="6949" CreationDate="2021-09-18T16:01:30.937" Score="5" Body="&lt;p&gt;Real world consideration: Time to reach a customer should take into account road network layout and traffic considerations (which are time dependent).&lt;/p&gt;&#xA;&lt;p&gt;In addition to the suggestions in other answers and comments, you might want to look at the &lt;a href=&quot;https://en.wikipedia.org/wiki/Vehicle_routing_problem#VRP_variants&quot; rel=&quot;noreferrer&quot;&gt;vehicle routing problem with time windows&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-09-18T16:01:30.937" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6953" PostTypeId="2" ParentId="6947" CreationDate="2021-09-18T20:48:32.470" Score="4" Body="&lt;p&gt;For your simple (2 variable, 2 side) cone, you are on the right track. An extreme ray will be defined by &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; binding constraints, which in this case means either &lt;span class=&quot;math-container&quot;&gt;$2x_1 - x_2= 0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x_1 + 3x_2 = 0$&lt;/span&gt;. In the first case, &lt;span class=&quot;math-container&quot;&gt;$x_2 = 2x_1$&lt;/span&gt;, so the ray will be either &lt;span class=&quot;math-container&quot;&gt;$(1, 2)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$(-1, -2)$&lt;/span&gt;. The first one is not feasible, so the winner is &lt;span class=&quot;math-container&quot;&gt;$(-1, -2)$&lt;/span&gt;. In the second case, &lt;span class=&quot;math-container&quot;&gt;$x_1=-3x_2$&lt;/span&gt;, so the ray is either &lt;span class=&quot;math-container&quot;&gt;$(-3,1)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$(3,-1)$&lt;/span&gt;, of which the former is feasible and the latter is not.&lt;/p&gt;&#xA;&lt;p&gt;This approach gets tedious rather quickly as the dimension grows. If &lt;span class=&quot;math-container&quot;&gt;$x\in\Re^n$&lt;/span&gt; and you have &lt;span class=&quot;math-container&quot;&gt;$k\ge n$&lt;/span&gt; constraints, you need to solve &lt;span class=&quot;math-container&quot;&gt;$\binom{k}{n-1}$&lt;/span&gt; systems of linear equations, then find the correct orientation for each solution and verify that the cone in fact recedes in that direction (which will not automatically be the case, unless your cone is &amp;quot;pointed&amp;quot;). Also, the method relies on knowing a point in the cone. The approach above implicitly relied on knowing that the cone contains &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. If it does not, the feasibility test involves adding arbitrary multiples of the candidate ray to a known point in the cone.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-09-18T20:48:32.470" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6954" PostTypeId="2" ParentId="6949" CreationDate="2021-09-19T08:48:18.517" Score="5" Body="&lt;p&gt;Besides other useful answers, there is a nice introduction for Technician Routing and Scheduling Problem which has been found in the &lt;a href=&quot;https://gurobi.github.io/modeling-examples/technician_routing_scheduling/technician_routing_scheduling.html&quot; rel=&quot;noreferrer&quot;&gt;Gurobi host&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;About the existing application, by googling you can easily find a lot of start-up or web-based firms that use many different techniques to solve such a complex problem. (e.g. &lt;a href=&quot;https://fieldsquared.com/platform/scheduling-routing-dispatching/&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; or &lt;a href=&quot;https://optimoroute.com/&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; one would be interested.).&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-09-19T08:48:18.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6955" PostTypeId="2" ParentId="6949" CreationDate="2021-09-19T11:38:50.573" Score="4" Body="&lt;p&gt;One potentially important aspect: you will not &lt;em&gt;know&lt;/em&gt; many of your inputs, but have to &lt;em&gt;forecast&lt;/em&gt; them. The most important example is likely time requirements. You don't know ahead of time how long you will take to repair that elevator, nor how long it will really take you to get to the place where you will do so.&lt;/p&gt;&#xA;&lt;p&gt;If you spend a lot of effort in developing your optimization routine, but find out later that the uncertainty in the inputs is far more important in terms of the quality of the output, your effort investment may not have been optimal. It may be better to spend effort to forecast the inputs more accurately. Or allow for more slack.&lt;/p&gt;&#xA;&lt;p&gt;For instance, you may be able to create a perfect route that squeezes the last bit of productivity out of a day - but then the first job takes ten minutes longer, then your driver falls prey to a traffic jam, and suddenly your beautiful plan is shot, and the driver will need to push one job to the next day. Which makes the customer unhappy, who was told to expect the driver today. It might have been better to plan a different route entirely in the first place.&lt;/p&gt;&#xA;&lt;p&gt;From my (very) limited understanding of the literature, this uncertainty - and in particular &lt;em&gt;how&lt;/em&gt; to forecast the inputs - is not given the emphasis it should have. (Then again, I'm probably biased, coming from the forecasting side of things.)&lt;/p&gt;&#xA;" OwnerUserId="3589" LastActivityDate="2021-09-19T11:38:50.573" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6956" PostTypeId="1" CreationDate="2021-09-20T05:22:48.417" Score="8" ViewCount="560" Body="&lt;p&gt;I am facing a problem to multiply a term in objective function. My objective function is :&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \min \sum_{t=1}^\top p_{t} \cdot (1+r) \cdot y_{t}    &#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is the price, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is the quantity (decision variable) and &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; is the price surcharge. &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is the index for time periods.&lt;/p&gt;&#xA;&lt;p&gt;The problem is that the value of &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; depends on between which interval the value of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; (decision variable) lies as shown by the following piecewise function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    r_t (Y_t) = &#xA;    \begin{cases}&#xA;        % s_0&#xA;        0 &amp;amp; \mathrm{if }\; Y_t \leq b_0 \\&#xA;        % s_1&#xA;        0.05 &amp;amp; \mathrm{if }\; b_0 &amp;lt; Y_t \leq b_1 \\&#xA;        % s_2&#xA;        0.1 &amp;amp; \mathrm{if }\; b_1 &amp;lt; Y_t \leq b_2\\[6pt]&#xA;        ... &amp;amp; \mathrm{if }\; ...&#xA;    \end{cases}&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$b_0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_1$&lt;/span&gt; etc. are set of quantity intervals = [0, 50, 100, 150,..]&lt;/p&gt;&#xA;&lt;p&gt;Since we don't have the values of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; until at the point where objective function is specified (cause value of decision variables) are only available once we give call to optimize m.optimize(). So, how we could program this in Python interface.&lt;/p&gt;&#xA;" OwnerUserId="7227" LastEditorUserId="491" LastEditDate="2022-03-30T12:39:03.313" LastActivityDate="2022-03-30T12:39:03.313" Title="Using the values of variable in the objective function before optimizing" Tags="|optimization|modeling|python|gurobi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6957" PostTypeId="1" CreationDate="2021-09-20T10:05:12.620" Score="1" ViewCount="130" Body="&lt;p&gt;Please excuse me for the long question, if I dont prrovide this info. my post gets removed!&lt;/p&gt;&#xA;&lt;p&gt;The following optimization problem is called Mixed-Integer Quadratically Constrained Programming&#xA;(MIQCP) problem in the research paper, &amp;quot;Optimal Routing and Charging of an Electric Vehicle Fleet for High-Efficiency Dynamic Transit Systems&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Let us say there is a graph (traffic network map of a town) like below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AOYvj.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AOYvj.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5hDmV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5hDmV.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;We would like to find optimal route from start node to passenger pickup to passenger delivery location to end node by travelling through nodes in the network.&lt;/p&gt;&#xA;&lt;p&gt;The objective function is given below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/k8EDR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/k8EDR.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The decision variable is &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^k$&lt;/span&gt; which is a binary variable 1 or 0 for taking a route from node i to j using Electric Vehicle (EV) k.&lt;/p&gt;&#xA;&lt;p&gt;The first term in the objective is trying to miniize the distance travelled between pickup and delivery for all the EVs.&lt;/p&gt;&#xA;&lt;p&gt;The second term is minimizing travel time for all EVs. one EV k only carries one passenger i.&lt;/p&gt;&#xA;&lt;p&gt;The third term is minimizing the charging cost of all the EVs.&lt;/p&gt;&#xA;&lt;p&gt;Legend is given below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FWoGQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FWoGQ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3WEjn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3WEjn.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now my question is regarding the constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FNI2y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FNI2y.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;What does &lt;span class=&quot;math-container&quot;&gt;$j \in P \cup D \oplus {e_k}$&lt;/span&gt; mean?&lt;/p&gt;&#xA;&lt;p&gt;In constraint 6, destination node j is a node that can be from 'either' pickup/delivery nodes 'or' end node of vehicle k. why not just use union instead of xor (either or)?&lt;/p&gt;&#xA;&lt;p&gt;Also why is &lt;a href=&quot;https://i.stack.imgur.com/MrwdN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MrwdN.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt; also xor and not union?&lt;/p&gt;&#xA;&lt;p&gt;if it is xor then do we have to think of this as two seperate cases when &lt;span class=&quot;math-container&quot;&gt;$i  \not\in {s_k} $&lt;/span&gt; in first case and &lt;span class=&quot;math-container&quot;&gt;$i \not\in {e_k} $&lt;/span&gt; in second case?&lt;/p&gt;&#xA;&lt;p&gt;Could you please explain the physical meaning constraint 8?&lt;/p&gt;&#xA;&lt;p&gt;i is either from P or D or intermediate node. j can be any node. sum over all j nodes to a particular node i for a vehicle k which can be more than 1 minus route from r to i which can only be 1 or 0. This is bounded by &lt;a href=&quot;https://i.stack.imgur.com/rJr6v.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rJr6v.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt; and &lt;a href=&quot;https://i.stack.imgur.com/61doD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/61doD.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I dont understand the explanation from the paper below:&#xA;maybe you might find it useful.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/oYCQA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oYCQA.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Why is it called &amp;quot;Quadratically Constrained&amp;quot; ? I don't see any squared terms in the constraints.&lt;/p&gt;&#xA;&lt;p&gt;The remaining constraints are given below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Xa1co.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Xa1co.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NUtJm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NUtJm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4945" LastActivityDate="2021-09-20T10:05:12.620" Title="vehicle routing optimization, Big M method of reformulation of constraints" Tags="|optimization|constraint|scheduling|big-m|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6958" PostTypeId="2" ParentId="6956" CreationDate="2021-09-20T10:36:48.127" Score="9" Body="&lt;p&gt;There are &lt;a href=&quot;https://or.stackexchange.com/questions/6674/how-to-linearize-specific-range-constraints&quot;&gt;many ways&lt;/a&gt; to do this. Here is a popular one: define a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; per interval &lt;span class=&quot;math-container&quot;&gt;$[b_i,b_{i+1}]$&lt;/span&gt; and use the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;1&amp;amp;=x_0+x_1+\cdots+x_n \tag{1}\\&#xA;0x_0 + (b_0+\epsilon)x_1 + \cdots+ (b_{n-1}+\epsilon)x_n  \le Y_t &amp;amp;\le b_0x_0 + b_1x_1 + \cdots+ b_nx_n \tag{2}\\&#xA; r_t &amp;amp;\ge f_i - M_i(1-x_i) \tag{3}\\&#xA;x_i &amp;amp;\in \{0,1\}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces the solver to select exactly one interval. Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$x_i=1 \; \Longrightarrow \;b_{i-1} &amp;lt; Y_t \le b_i$&lt;/span&gt;. For example, if &lt;span class=&quot;math-container&quot;&gt;$x_1=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_0 + \epsilon \le Y_t \le b_1$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is your tolerance). And &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; is a &lt;em&gt;bigM&lt;/em&gt; constraint which defines the piecewise linear function &lt;span class=&quot;math-container&quot;&gt;$r_t$&lt;/span&gt; accordingly (&lt;span class=&quot;math-container&quot;&gt;$f_0 = 0, f_1=0.05,...$&lt;/span&gt;). For example, if &lt;span class=&quot;math-container&quot;&gt;$x_1=1$&lt;/span&gt;, the constraint becomes &lt;span class=&quot;math-container&quot;&gt;$r_t \ge f_1 = 0.05$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that the above solution holds for a given &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. You will need to replicate the idea over your time span &lt;span class=&quot;math-container&quot;&gt;$t=1,..,T$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-09-20T10:48:15.307" LastActivityDate="2021-09-20T10:48:15.307" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6959" PostTypeId="1" AcceptedAnswerId="6960" CreationDate="2021-09-20T14:47:44.330" Score="8" ViewCount="609" Body="&lt;p&gt;I have a huge mps file and would like to get the associated MIP model, i.e., the objective, constraint, and bounds.&#xA;Is there any tools that could get that?&lt;/p&gt;&#xA;" OwnerUserId="41" LastEditorUserId="68" LastEditDate="2021-09-20T14:49:41.793" LastActivityDate="2021-09-20T19:18:01.107" Title="Convert MPS file to the associated MIP model" Tags="|mps|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6960" PostTypeId="2" ParentId="6959" CreationDate="2021-09-20T14:54:49.067" Score="9" Body="&lt;p&gt;You can use &lt;a href=&quot;https://coin-or.github.io/pulp/guides/how_to_export_models.html&quot; rel=&quot;noreferrer&quot;&gt;PuLp's import and export functions&lt;/a&gt; (this is Python).&lt;/p&gt;&#xA;&lt;p&gt;For example, the following snippet shows you how to import an mps file and print the corresponding MIP:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var1, prob1 = LpProblem.fromMPS(&amp;quot;test.mps&amp;quot;)&#xA;var1&#xA;# {'x': x, 'y': y, 'z': z}&#xA;prob1&#xA;# test_export_dict_MIP:&#xA;# MINIMIZE&#xA;# 1*x + 4*y + 9*z + 0&#xA;# SUBJECT TO&#xA;# c1: x + y &amp;lt;= 5&#xA;# c2: x + z &amp;gt;= 10&#xA;# c3: - y + z = 7.5&#xA;# VARIABLES&#xA;# x &amp;lt;= 4 Continuous&#xA;# -1 &amp;lt;= y &amp;lt;= 1 Continuous&#xA;# 0 &amp;lt;= z Integer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2021-09-20T14:54:49.067" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6961" PostTypeId="1" CreationDate="2021-09-20T15:41:21.157" Score="7" ViewCount="755" Body="&lt;p&gt;Exists a list of categories that include possibilities to solve a travelling salesman problem (TSP)? I know, for example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Exact methods&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Integer Linear Programming&lt;/li&gt;&#xA;&lt;li&gt;Dynamic Programming&lt;/li&gt;&#xA;&lt;li&gt;Constraint Programming&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Heuristics&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Construction heuristics&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Nearest Neighbour&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Improvement heuristics&#xA;&lt;ul&gt;&#xA;&lt;li&gt;k-opt&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Metaheuristics&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ant-Colony-Optimisation&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Is there a complete list of all these possibilities? Into which categories can they be ordered?&lt;/p&gt;&#xA;" OwnerUserId="5571" LastActivityDate="2021-09-21T15:28:06.657" Title="Which approaches exist to solve a TSP?" Tags="|traveling-salesman|heuristics|metaheuristics|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="6962" PostTypeId="2" ParentId="6961" CreationDate="2021-09-20T18:39:33.277" Score="13" Body="&lt;p&gt;I doubt there is a complete listing of every possible approach to TSPs. You can find a significant amount of information on &lt;a href=&quot;https://www.math.uwaterloo.ca/tsp/index.html&quot; rel=&quot;noreferrer&quot;&gt;Bill Cook's site&lt;/a&gt;. Bill Cook wrote what I believe many consider the definitive &lt;a href=&quot;https://en.wikipedia.org/wiki/In_Pursuit_of_the_Traveling_Salesman&quot; rel=&quot;noreferrer&quot;&gt;book about TSPs&lt;/a&gt; (&amp;quot;In Pursuit of the Traveling Salesman: Mathematics at the Limits of Computation&amp;quot;, Princeton University Press, 2012) and is one of the developers of the &lt;a href=&quot;https://www.math.uwaterloo.ca/tsp/concorde.html&quot; rel=&quot;noreferrer&quot;&gt;Concorde TSP solver&lt;/a&gt;. Cook's TSP web site contains examples, teaching tools, test data, and links to some rather large solved instances.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-09-21T15:28:06.657" LastActivityDate="2021-09-21T15:28:06.657" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6963" PostTypeId="2" ParentId="6961" CreationDate="2021-09-20T18:54:52.400" Score="8" Body="&lt;p&gt;Some additional sources to help you answer your question:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Cook, W. &amp;quot;In pursuit of the traveling salesman: mathematics at the limits of computation. 2012.&amp;quot;&lt;/li&gt;&#xA;&lt;li&gt;Gutin, Gregory, and Abraham P. Punnen, eds. The traveling salesman problem and its variations. Vol. 12. Springer Science &amp;amp; Business Media, 2006.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-09-20T18:54:52.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6964" PostTypeId="2" ParentId="6959" CreationDate="2021-09-20T19:18:01.107" Score="6" Body="&lt;p&gt;Virtually any IP solver can do this for you (Cplex/Gurobi/Xpress/...). The general approach would be to:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Import the MPS file into the solver&lt;/li&gt;&#xA;&lt;li&gt;Export the model in LP format&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Note that the above can be accomplished, either programmatically, or through a command-line interface that most solvers provide. As per example, in Cplex you could simply use the &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=tutorials-interactive-optimizer-tutorial&quot; rel=&quot;noreferrer&quot;&gt;Interactive optimizer&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; read my_mip_model.mps&#xA;&amp;gt; write my_mip_model.lp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Gurobi and Xpress have similar capabilities (command line syntax is slightly  different).&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-09-20T19:18:01.107" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6965" PostTypeId="1" CreationDate="2021-09-20T19:34:19.117" Score="6" ViewCount="235" Body="&lt;p&gt;Consider the following problem of Technician Routing and Scheduling Problem.&#xA;We have:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A set of customers where each customer needs the intervention of a technician to do some job. Each customer has a time-window of presence and a geographical local. Each job requires a set of skills and has a known processing time.&lt;/li&gt;&#xA;&lt;li&gt;A set of technicians, each with some skills and with time-windows of working hours.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The TSR problem involves assignment, scheduling, and routing of multi-skilled technicians to serve customers. The objectives are to minimise the cost (involving the distance and the time to move from one location to another) and to maximise customer satisfaction (this objective needs some interpretation).&lt;/p&gt;&#xA;&lt;p&gt;The problem is that in real-life there is a lot of uncertainties. Jobs or travel-times may take longer than expected. The schedules are not so &amp;quot;robust&amp;quot;, a 10-minutes lateness may create a big chaos. Some technicians will not have the time to visit all their assigned customers, which make them unhappy.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;How to cope with that in some &amp;quot;clever&amp;quot; way? I don't have any data to forecast things.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For example, I thought about making each customer choose two time windows rather than one. This way, I always have a second chance if things go wrong.&#xA;PS: The second time slot will not be used from the beginning but only if the first one is missed. Somehow, it's like having a &amp;quot;new&amp;quot; customer. The point is we don't bother him by asking a second time &amp;quot;when will you be be available?&amp;quot;, we already know the answer (which is the time window of the second slot).&lt;/p&gt;&#xA;&lt;p&gt;Any other suggestions?&lt;/p&gt;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7222" LastEditorUserId="500" LastEditDate="2021-09-20T20:29:32.870" LastActivityDate="2021-09-20T20:29:32.870" Title="How to cope with the rigidity of solutions?" Tags="|scheduling|vehicle-routing|traveling-salesman|applications|uncertainty|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="6966" PostTypeId="2" ParentId="6965" CreationDate="2021-09-20T19:57:41.133" Score="6" Body="&lt;p&gt;There are many ways to approach your problem and there is a lot of literature on similar problems. You could look at the following article:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Gorissen, Bram L., et al. “A Practical Guide to Robust Optimization.” Omega, vol. 53, June 2015, pp. 124–37. ScienceDirect, &lt;a href=&quot;https://doi.org/10.1016/j.omega.2014.12.006&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1016/j.omega.2014.12.006&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;A simple approach would be to add 'safety slack' to your data. E.g. increasing travel times or service times by a factor of 10%.&lt;/p&gt;&#xA;&lt;p&gt;I would not follow your approach because it adds way more complexity to the model and what about the case in which the second time window is missed? And if you assign two time slots to every customer but only one is needed, this will lead to inefficient plannings.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2021-09-20T19:57:41.133" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6967" PostTypeId="1" CreationDate="2021-09-21T00:15:39.300" Score="5" ViewCount="58" Body="&lt;p&gt;I'm new to the field of sequential decision making. I got intrigued by a stochastic shortest path problem, described in Chapter 5 of this &lt;a href=&quot;https://www.overleaf.com/project/5c38f4c0dd838e54104f24b9&quot; rel=&quot;noreferrer&quot;&gt;book&lt;/a&gt; by W. Powell.&lt;/p&gt;&#xA;&lt;p&gt;Consider the following stochastic shortest path problem:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Undirected graph &lt;span class=&quot;math-container&quot;&gt;$G(V,E)$&lt;/span&gt;, a source vertex &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, and a destination vertex &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;When located at some node &lt;span class=&quot;math-container&quot;&gt;$i\in V$&lt;/span&gt;, the travel times from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to its neighboring nodes are revealed; travel times on the other edges are uncertain (stochastic).&lt;/li&gt;&#xA;&lt;li&gt;We are interested in finding the shortest path from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To solve this problem, the book sketches the following approximate DP approach:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;With every node &lt;span class=&quot;math-container&quot;&gt;$i\in V$&lt;/span&gt;, we associate a value &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt;, representing the expected cost of reaching destination &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$v_t=0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\hat{c}_{ij}$&lt;/span&gt; be a travel time realization on edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;. When located in node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and deciding to which neighboring node &lt;span class=&quot;math-container&quot;&gt;$j^*$&lt;/span&gt; to move next, we pick &lt;span class=&quot;math-container&quot;&gt;$j^*=\arg \min_{j:(i,j)\in E}\hat{c}_{ij}+v_j$&lt;/span&gt;. So, starting at node &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, we move to a neighboring node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; for which the cost &lt;span class=&quot;math-container&quot;&gt;$\hat{c}_{sj}+v_j$&lt;/span&gt; is minimum. We repeat until we reach node &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Clearly, the challenge lies in determining &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in V$&lt;/span&gt; efficiently. The book outlines the following iterative approach.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Initialize &lt;span class=&quot;math-container&quot;&gt;$v_t=0$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in V\setminus \{t\}$&lt;/span&gt; to some positive value (e.g we can set all arc costs to their expected values, run Dijkstra to compute the shortest paths from &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; to all other nodes and use the resulting costs to initialize &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Following an iterative process, we are going to learn the values &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in V$&lt;/span&gt;. Assume that &lt;span class=&quot;math-container&quot;&gt;$\hat{c}_{ij}^n$&lt;/span&gt; is the travel time realization of edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; obtained in the nth iteration. At every iteration, we step through the network, starting at node &lt;span class=&quot;math-container&quot;&gt;$i=s$&lt;/span&gt;. An iteration ends when we reach node &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. While stepping through the network, when located at some node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, we determine the next node j* to move to by: &lt;span class=&quot;math-container&quot;&gt;$j^*=\arg \min_{j:(i,j)\in E}\hat{c}_{ij}^n+v_j$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$v'_i=\hat{c}_{ij^*}^n+v_{j*}$&lt;/span&gt;. Update &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; by setting &lt;span class=&quot;math-container&quot;&gt;$v_i=(1-\alpha)v_i+\alpha v'_i$&lt;/span&gt;, and set &lt;span class=&quot;math-container&quot;&gt;$i=j^*$&lt;/span&gt;. Here, &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is a predefined parameter that determines the learning rate. Continue stepping until &lt;span class=&quot;math-container&quot;&gt;$i=t$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;An implementation of the above algorithm is given &lt;a href=&quot;https://github.com/wbpowell328/stochastic-optimization/tree/master/StochasticShortestPath_Static&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Approach related questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;In the example implementation, the authors walk from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Alternatively, we could have walked backwards, from &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;. Does this matter?&lt;/li&gt;&#xA;&lt;li&gt;In the implementation, I noticed that while walking from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, the algorithm does not track (a) which vertices have already been visited, or (b) how many segments we have traversed already. Shouldn't one include some sort of check to prevent cycling (e.g. in a walk from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, you don't want to revisit the same vertex multiple times)?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;General questions relating to the above solution framework to learn &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; by iteratively sampling a path through the network:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How does one prove for such an algorithm, whether, after &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; iterations, the algorithm converges to some steady state? Clearly, it would be undesirable if the algorithm would start to diverge from the true values of &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt;. Similarly, we don't want the algorithm to alternate between 2 solutions, i.e. in the kth iteration we would update the &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; values, and in the (k+1)th iteration we would revert those changes back to the solution we found in iteration k.&lt;/li&gt;&#xA;&lt;li&gt;Assuming the algorithm converges, how do we establish the quality of the final solution (i.e. are the learned values of &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; a good representation of the expected costs)?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-09-21T00:15:39.300" Title="Convergence of an approximate DP for a stochastic shortest path problem" Tags="|dynamic-programming|reinforcement-learning|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6968" PostTypeId="1" AcceptedAnswerId="6969" CreationDate="2021-09-21T10:20:07.960" Score="4" ViewCount="365" Body="&lt;p&gt;I was wondering what complexity a simple start-destination task in a routing software would have. Knowing the shortest path problem, it should be in P. Is there anything I am missing?&lt;/p&gt;&#xA;" OwnerUserId="7233" LastEditorUserId="36" LastEditDate="2021-09-21T13:04:10.980" LastActivityDate="2021-09-21T13:04:10.980" Title="Complexity of navigation with google maps" Tags="|combinatorial-optimization|vehicle-routing|computational-complexity|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6969" PostTypeId="2" ParentId="6968" CreationDate="2021-09-21T10:45:15.227" Score="7" Body="&lt;p&gt;The prototypical graph search algorithm &lt;a href=&quot;https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm&quot; rel=&quot;noreferrer&quot;&gt;Dijkstra's algorithm&lt;/a&gt; for finding the shortest paths between nodes in a graph which works for unbounded non-negative weights has a time complexity for &lt;span class=&quot;math-container&quot;&gt;$O(|V|^2)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$|V|$&lt;/span&gt; is the number of nodes/vertices in a graph which is in &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There are special cases where further knowledge (such as heuristics) or the graph structure allow smaller upper bounds but those would also be polynomial as long as you traverse the graph itself. If you have an indexed random access, an accurate (signed) distance function and the graph is a 1d chain binary search could be used which is faster than linear but this is a very special case.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-09-21T11:10:31.177" LastActivityDate="2021-09-21T11:10:31.177" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6970" PostTypeId="2" ParentId="797" CreationDate="2021-09-21T12:06:53.517" Score="1" Body="&lt;p&gt;@Mostafa, &lt;strong&gt;j&lt;/strong&gt; is the number of jobs while &lt;strong&gt;r&lt;/strong&gt; is the number of machines, this means  &lt;span class=&quot;math-container&quot;&gt;$NumofJobs = Tasktime.shape[1]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$NumofMachines = Tasktime.shape[0]$&lt;/span&gt;, and also, &lt;strong&gt;s&lt;/strong&gt; must be &lt;span class=&quot;math-container&quot;&gt;$s = m.addVars(NumofMachines,NumofJobs)$&lt;/span&gt;, otherwise the optimality cannot be achieved. Do this modification and run the example by using the data in Table 1 found in your reference paper(Wright, 1989), you will easily see the optimal cost of 83.&lt;/p&gt;&#xA;" OwnerUserId="7234" LastEditorUserId="7234" LastEditDate="2021-09-22T07:52:54.073" LastActivityDate="2021-09-22T07:52:54.073" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6973" PostTypeId="2" ParentId="6949" CreationDate="2021-09-21T19:35:02.047" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;Yes - Being available for work does not mean that you've not exceeded your weekly working hours. So a vehicle might be available in the problem setup, but it doesn't account for what they might have worked until that date. Regulations vary, but this will be important in the Working Time Directive with tachographs, for example.&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;Real Life&amp;quot;. I haven't found many papers that actually don't default back to ideal conditions - it's a great area for your own imagination to work. I hate to sound like the person that puts on their Facebook &amp;quot;Education: School of Life&amp;quot; crap, but it's true here. The nature of the problem itself gives you scope to be &amp;quot;smart&amp;quot;&lt;/li&gt;&#xA;&lt;li&gt;I think it would be useful to learn about Large Neighbourhood Search and also Simulated Annealing. There's &amp;quot;Ruin and Recreate&amp;quot; as a named example; but the actual problem you need to solve can be on different timescales. 1) You want a global optimum and 2) you need a sub-second answer to see whether a job fits in to the current schedule. If you know research that can cover both of these, I'd be very interested. In my opinion, that's trade secret and just systems-design.&lt;/li&gt;&#xA;&lt;li&gt;Yes; I've worked on several solutions for companies in the FTSE and continue to work for one of them in development.&#xA;I can't say too much, but this is a big problem in the real world.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7236" LastEditorUserId="7236" LastEditDate="2021-09-21T19:49:19.570" LastActivityDate="2021-09-21T19:49:19.570" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6974" PostTypeId="1" CreationDate="2021-09-22T05:03:14.373" Score="3" ViewCount="265" Body="&lt;p&gt;I am modelling a stochastic dynamic program but because I need to store all information related to former sales, the state of the dynamic program increases and potentially it can growth so much which results in curse-of-dimensionality. I am wondering if there is any general trick to convert it to a Markovian model? If not, is this model valuable to publish a paper in a top-tier journal (just based on modelling and solving appraoch)? What are the general approaches to handle this growing state space?&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2021-09-22T13:05:25.590" Title="How to solve Stochastic Dynamic Program with huge state space?" Tags="|stochastic-programming|dynamic-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6975" PostTypeId="2" ParentId="6862" CreationDate="2021-09-22T08:56:13.797" Score="1" Body="&lt;p&gt;Adding to the answer of @MarcM, there is the reason, in addition to specific heuristics, which is the given problem type, especially real-world scenario whose search space is so huge or unknown. Besides, the No Free Lunch theorem says that there is no universal optimization algorithm to solve every kind of optimization problem. In other words, the better initial solution cannot show the same percentage of the improvement for each heuristics. This means if the knowledge of the problem is not available a priori, there is still a lack of an answer to which improvement method most accurately affects which types of problems. Even if there are some studies in the literature, the studies generally have used a limited number of problems and also algorithms. I thought that it can be an answer for only specific problems and algorithms. I also think that without implementation, no one says the 2-opt heuristic is better than sweep, saving, 2-opt*... initializations to NN for TSP.&lt;/p&gt;&#xA;" OwnerUserId="7234" LastActivityDate="2021-09-22T08:56:13.797" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6976" PostTypeId="2" ParentId="6974" CreationDate="2021-09-22T13:05:25.590" Score="4" Body="&lt;p&gt;Just to expand very slightly the comments by Mark: in general exact stochastic dynamic programming scales quite poorly.&lt;/p&gt;&#xA;&lt;p&gt;Value iteration complexity for each iteration is &lt;span class=&quot;math-container&quot;&gt;$O(A S^2)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is the number of actions and &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is the number of states. And the number of iterations goes up with the discount factor &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; as the worse case number of iterations is &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{1-\beta} \log \left( \frac{1}{1-\beta} \right)$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;p&gt;see Littman, M. L., Dean, T. L., &amp;amp; Kaelbling, L. P. (1995). On the complexity of solving Markov decision problems. In Proceedings of the Eleventh conference on Uncertainty in artificial intelligence (pp. 394–402).&lt;/p&gt;&#xA;&lt;p&gt;So basically what you want is to reduce the number of states. The way &amp;quot;reinforcement learning&amp;quot;/&amp;quot;Approximate Dynamic Programming&amp;quot; goes about it is to basically substitute the problem of computing the Q-table &lt;span class=&quot;math-container&quot;&gt;$ Q(s,a) $&lt;/span&gt; with some statistical approximation (for example, you summarise any state &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; through some features &lt;span class=&quot;math-container&quot;&gt;$f(\cdot)$&lt;/span&gt; and then the value of that state is just a linear combination&#xA;&lt;span class=&quot;math-container&quot;&gt;$Q(s,a) = w_1 f_1(s) + w_2 f_2(s) + \dots + w_n f_n(s)$&lt;/span&gt; ).&lt;br /&gt;&#xA;Of course you are now stuck with the training problem, but it is usually much easier to scale.&lt;/p&gt;&#xA;" OwnerUserId="4079" LastActivityDate="2021-09-22T13:05:25.590" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6977" PostTypeId="1" CreationDate="2021-09-23T07:27:00.490" Score="3" ViewCount="225" Body="&lt;p&gt;Can someone tell if it is known that if finding global optima is unsolvable (in Turing sense). I have posted an arXiv paper &lt;a href=&quot;https://arxiv.org/pdf/2103.13821.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/2103.13821.pdf&lt;/a&gt; showing this. But I'm not sure if it is already known.&lt;/p&gt;&#xA;" OwnerUserId="7245" LastActivityDate="2021-09-28T07:12:02.903" Title="General Optimization and Unsolvability" Tags="|global-optimization|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6978" PostTypeId="2" ParentId="6862" CreationDate="2021-09-23T13:29:03.663" Score="2" Body="&lt;p&gt;Because most of the answers state that construction heuristics do not improve the quality of improvement heuristics, I want to share a paper that contradicts.&lt;/p&gt;&#xA;&lt;p&gt;The paper &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0166218X05003070&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;First vs. best improvement: An empirical study&amp;quot;&lt;/a&gt; observes in its experiments for the TSP that &amp;quot;starting with 'greedy' or 'nearest neighbor' constructive heuristics, the best improvement is better and faster on average&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="5571" LastEditorUserId="5571" LastEditDate="2021-09-23T15:22:01.073" LastActivityDate="2021-09-23T15:22:01.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6980" PostTypeId="1" CreationDate="2021-09-23T16:57:26.700" Score="1" ViewCount="351" Body="&lt;p&gt;I have built a model to minimize the operating cost and when I coded a model in CPLEX, it gave an error at Cons09: &lt;code&gt;Function operator/(int,dvar int+) not available in context CPLEX.&lt;/code&gt; I think maybe the problem lies in my model design as it is a big model. Here are my parameters:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int Numtask =...;&#xA;int Numresource =...;&#xA;&#xA;range Task = 1..Numtask;&#xA;range Resource = 1..Numresource;&#xA;&#xA;// parameters&#xA;&#xA;int h[Task]=...;// Manhour of task j&#xA;int a[Resource][Task]=...; // license of engineer t&#xA;int C[Resource]=...;// cost of engineer t&#xA;int A[Task]=...;// nightstop time of t&#xA;float B=0.15;&#xA;int M=9000;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here are my decision variables:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar float+ g[Resource];&#xA;dvar boolean x[Resource][Task];&#xA;dvar int+ m[Task];&#xA;dvar float+ b[Resource][Task];&#xA;dvar float+ n[Resource][Task];&#xA;dvar float+ nmax[Resource];&#xA;dvar float+ bmin[Resource];&#xA;dvar int+ man[Task];&#xA;&#xA;dexpr float cost =sum(t in Resource) C[t]*g[t];&#xA;&#xA;minimize (cost);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My constraints are as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  subject to{&#xA;  //cons01:&#xA;  forall(j in Task, t in Resource)&#xA;    x[t][j]==a[t][j];&#xA;  &#xA;  //cons02:&#xA;  forall(j in Task)&#xA;    sum(t in Resource) x[t][j]==1;&#xA;    &#xA;  //cons03:&#xA;  forall(t in Resource)&#xA;    sum(j in Task) x[t][j]==1;&#xA;    &#xA;  //cons04:&#xA;  forall(j in Task)&#xA;    sum(t in Resource) x[t][j]*a[t][j]&amp;lt;=2;&#xA;  &#xA;  //subcons04:&#xA;  forall(j in Task){&#xA;    man[j]==sum(t in Resource) x[t][j]*a[t][j];&#xA;    }&#xA;  &#xA;  //cons05:&#xA;  sum(t in Resource, j in Task) x[t][j]==Numtask;&#xA;  &#xA;  //cons06:&#xA;  forall(t in Resource){&#xA;     g[t]&amp;gt;=(1+B)*sum(t in Resource, j in Task)x[t][j]*a[t][j];&#xA;    }&#xA;  &#xA;  //cons07:&#xA;  forall(j in Task){&#xA;    m[j]&amp;gt;=A[j]&amp;amp;&amp;amp;m[j]&amp;lt;=A[j]+30;&#xA;    }&#xA;  &#xA;  //cons08:&#xA;  forall(t in Resource, j in Task){&#xA;    b[t][j]==M*(1-x[t][j])+m[j];&#xA;    }&#xA;  &#xA;  //cons09:&#xA;  forall(t in Resource, j in Task){&#xA;    n[t][j] == b[t][j]+h[j]/man[j];&#xA;    }&#xA;   &#xA;  //cons10:&#xA;  forall(t in Resource, j in Task){&#xA;    n[t][j]&amp;lt;=1770;&#xA;    }&#xA;  &#xA;  //cons11:&#xA;  forall(t in Resource){&#xA;    nmax[t]-bmin[t]&amp;lt;=720;&#xA;    }&#xA;  //subcons11:&#xA;  forall(t in Resource, j in Task){&#xA;    nmax[t]&amp;gt;=n[t][j];&#xA;    }&#xA;  //subcons11:&#xA;  forall(t in Resource, j in Task){&#xA;    bmin[t]&amp;lt;=b[t][j];&#xA;    }  &#xA;  //cons12:&#xA;  forall(t in Resource){&#xA;    720-sum(j in Task)x[t][j]*(n[t][j]-b[t][j])&amp;gt;=30 &amp;amp;&amp;amp; 720-sum(j in Task)x[t][j]*(n[t][j]-b[t][j])&amp;lt;=40;&#xA;    }&#xA;  &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="7235" LastEditorUserId="123" LastEditDate="2021-09-24T06:38:04.273" LastActivityDate="2021-09-24T17:09:01.327" Title="Operator error in operating cost model constraint" Tags="|cplex|constraint|opl|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6981" PostTypeId="2" ParentId="6980" CreationDate="2021-09-23T21:15:00.453" Score="6" Body="&lt;p&gt;Integer programming models solved by CPLEX (or most other solvers) require linear or, in certain very limited cases, quadratic constraints. Your constraint 9 involves dividing a parameter (&lt;code&gt;h&lt;/code&gt;) by an integer variable (&lt;code&gt;man&lt;/code&gt;), which results in a nonlinear expression. Multiplying both sides by man will not help, since that produces an equation with products of variables, which is not among the limited cases where quadratic constraints are allowed.&lt;/p&gt;&#xA;&lt;p&gt;Assuming that &lt;code&gt;man[j]&lt;/code&gt; can never be 0 and has an upper bound of &lt;code&gt;M&lt;/code&gt;, you can add binary variables &lt;code&gt;z[j][i] (j in Task, i in 1...M)&lt;/code&gt;, where &lt;code&gt;z[j][i] = 1&lt;/code&gt; means &lt;code&gt;man[j] = i&lt;/code&gt;. Add the constraint that &lt;code&gt;z[j][1] + ... + z[j][M] = 1&lt;/code&gt;, and the constraint that &lt;code&gt;man[j] = z[j][1] + 2*z[j][2] + ... + M*z[j][M]&lt;/code&gt;. The term &lt;code&gt;h[j]/man[j]&lt;/code&gt; in constraint 9 can now be replaced with &lt;code&gt;h[j]*(z[j][1] + 1/2*z[j][2] + ... + 1/M*z[j][M])&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-09-24T17:09:01.327" LastActivityDate="2021-09-24T17:09:01.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6982" PostTypeId="1" CreationDate="2021-09-26T22:48:47.277" Score="4" ViewCount="224" Body="&lt;p&gt;Is there any way I could have Gurobi/CPLEX or any other package write/export MPS and LP files in the standard LP construct loaded with slack variables and transformations required for unsigned vars?&lt;/p&gt;&#xA;&lt;p&gt;Here, by 'standard LP construct', I am referring to the LP formation ie. &lt;span class=&quot;math-container&quot;&gt;$\{ \min ~ c^\top x : Ax = b, x \geq 0 \}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: I'd also appreciate if you could share knowledge about some utility/function from Coin-OR or AMPL that can do this.&lt;/p&gt;&#xA;" OwnerUserId="4116" LastEditorUserId="123" LastEditDate="2021-09-27T06:51:16.360" LastActivityDate="2021-09-28T23:54:12.947" Title="Standard Form for LP and MPS" Tags="|cplex|solver|gurobi|presolve-preprocessing|mps|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6983" PostTypeId="1" CreationDate="2021-09-27T06:50:49.803" Score="2" ViewCount="101" Body="&lt;p&gt;I am about to start my final year thesis. The topic would be related to the queueing theory, specifically for the elevator traffic systems. I would need to do some literature review before going further into the topic and I would be very grateful if you could suggest some research papers about the topic.&lt;/p&gt;&#xA;&lt;p&gt;I would need to do some programming to perform simulations for the queueing optimization later on. Can anyone please suggest which programming language/software I would be suitable for this research?&lt;/p&gt;&#xA;" OwnerUserId="2682" LastEditorUserId="2682" LastEditDate="2021-09-27T07:01:05.637" LastActivityDate="2021-09-27T21:31:57.817" Title="Elevator Traffic (Queueing Theory) Papers" Tags="|optimization|reference-request|queuing-theory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6984" PostTypeId="1" AcceptedAnswerId="6985" CreationDate="2021-09-27T07:44:12.477" Score="7" ViewCount="178" Body="&lt;p&gt;I am having trouble formulating the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;I am looking to formulate a constraint that if a facility was opened at some point in time, then &lt;span class=&quot;math-container&quot;&gt;$Y[j,t]$&lt;/span&gt; does always have to be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; from that point in time onwards (see values below). How do I do that?&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;O[j,t]&lt;/th&gt;&#xA;&lt;th&gt;Y[j,t]&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1 &lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Edit from comments:&lt;/p&gt;&#xA;&lt;p&gt;It is also possible to close initially existing facilities using a closing variable &lt;span class=&quot;math-container&quot;&gt;$S[j,t]$&lt;/span&gt;. It is generally possible to close a facility, just not one that has been opened by the model using the &lt;span class=&quot;math-container&quot;&gt;$O[j,t]$&lt;/span&gt; variable.&lt;/p&gt;&#xA;" OwnerUserId="7258" LastEditorUserId="36" LastEditDate="2021-10-16T14:42:08.930" LastActivityDate="2021-10-16T14:42:08.930" Title="How to enforce a relation between two variables" Tags="|linear-programming|modeling|facility-location|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6985" PostTypeId="2" ParentId="6984" CreationDate="2021-09-27T07:50:37.240" Score="9" Body="&lt;p&gt;You can activate variable &lt;span class=&quot;math-container&quot;&gt;$Y[j,t]$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$O[j,t]$&lt;/span&gt; is active (&lt;span class=&quot;math-container&quot;&gt;$O[j,t] \; \Longrightarrow \; Y[j,t]$&lt;/span&gt;) with:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;O[j,t] \le Y[j,t] \tag{1}&#xA;$$&lt;/span&gt;&#xA;And then make sure &lt;span class=&quot;math-container&quot;&gt;$Y[j,t]$&lt;/span&gt; remains active (&lt;span class=&quot;math-container&quot;&gt;$Y[j,t] \; \Longrightarrow \; Y[j,t+1]$&lt;/span&gt;):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Y[j,t] \le Y[j,t+1] \tag{2a}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I suppose there is some cost on variables &lt;span class=&quot;math-container&quot;&gt;$Y[j,t]$&lt;/span&gt; ? If so, this cost should preclude the solver from activating &lt;span class=&quot;math-container&quot;&gt;$Y[j,t]$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$O[j,t]=Y[j,t-1]=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, if you can close an exising facility, then &lt;span class=&quot;math-container&quot;&gt;$Y[j,t]$&lt;/span&gt; should be active until the facility is closed, so you can adjust constraint &lt;span class=&quot;math-container&quot;&gt;$(2a)$&lt;/span&gt; as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Y[j,t] \le Y[j,t+1] + S[j,t+1] \tag{2b}&#xA;$$&lt;/span&gt;&#xA;So if &lt;span class=&quot;math-container&quot;&gt;$Y[j,t]$&lt;/span&gt; is active, in the following period you either maintain activity, or close the facility. And if you cannot reopen the facility, you need to impose:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;S[j,t] \le 1 - O[j,k] \quad \forall k=t,t+1,t+2,... \tag{3}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-09-27T08:18:46.010" LastActivityDate="2021-09-27T08:18:46.010" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6986" PostTypeId="1" AcceptedAnswerId="6989" CreationDate="2021-09-27T11:33:34.683" Score="5" ViewCount="833" Body="&lt;h1&gt;The question (very short version)&lt;/h1&gt;&#xA;&lt;p&gt;Why can I not decrease the lower boundary for the decision variable &lt;code&gt;model.v_dot&lt;/code&gt; (see implementation) below 30 ? As soon as I do so, the solver doesn't return results.&#xA;After only one iteration I get the solver error:&#xA;EXIT: Restoration Failed!&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The goal is to have the solver return results for a v_dot lower boundary equal to zero.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Long version&lt;/h1&gt;&#xA;&lt;p&gt;I am trying to optimize the diameters of a gas pipeline network.&lt;/p&gt;&#xA;&lt;p&gt;The topology is given (the node location and hence the pipeline lengths), the edges, the sources' and sinks' location and their throughput.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3tZ1I.png&quot; rel=&quot;noreferrer&quot;&gt;Network Topology&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The problem implementation inputs are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the list of nodes&lt;/li&gt;&#xA;&lt;li&gt;the list of edges&lt;/li&gt;&#xA;&lt;li&gt;the dictionary of lengths (associating a length to each edge)&lt;/li&gt;&#xA;&lt;li&gt;the dictionary of sources (associating a volume flow rate to each node)&lt;/li&gt;&#xA;&lt;li&gt;the dictionary of sinks (same thing)&#xA;(please see the data below if you want to implement the same instance as mine)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;And the outputs should be:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the diameters of each pipeline&lt;/li&gt;&#xA;&lt;li&gt;the pressure at each node&lt;/li&gt;&#xA;&lt;li&gt;the (normal) volume flow rate of each pipeline&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Important to mention is that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;there are 2 equality constraints, one physically describing the flow in a pipeline (the pressure drop equation) and one insuring the mass flow conservation in the network&lt;/li&gt;&#xA;&lt;li&gt;the pressure is bounded by a maximum and a minimum&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;Implementation&lt;/h1&gt;&#xA;&lt;p&gt;The implementation on pyomo is as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# declare the model&#xA;model = pyo.ConcreteModel()&#xA;&#xA;# declare the sets and parameters&#xA;&#xA;model.junctions = pyo.Set(initialize=junctions_pyo)&#xA;model.edges = pyo.Set(initialize=edges_pyo, within= model.junctions*model.junctions)&#xA;&#xA;p_max = 7000  # kpa&#xA;p_min = 1600&#xA;a_0 = 1  # coefficients for object fct&#xA;a_1 = 1&#xA;a_2 = 1&#xA;a = 0.3  # coefficient for pressure drop equality constraint&#xA;&#xA;model.lengths = pyo.Param(model.edges, initialize=lengths_dict_pyo)&#xA;&#xA;# declare the variables&#xA;model.d = pyo.Var(model.edges, bounds=(0.01, 100), within=pyo.NonNegativeReals) &#xA;model.pi = pyo.Var(model.junctions, bounds=(p_min ** 2, p_max ** 2), within=pyo.NonNegativeReals)&#xA;model.v_dot = pyo.Var(model.edges, bounds=(30, 1500), within=pyo.Reals)&#xA;&#xA;# define the objective function&#xA;def obj_rule(model):&#xA;    return sum((a_0 + a_1 * model.d[i, j] + a_2 * model.d[i, j] ** 2) * model.lengths[i, j] for (i, j) in model.edges)&#xA;model.obj = pyo.Objective(rule=obj_rule, sense= pyo.minimize)&#xA;&#xA;# define the constraints&#xA;# pressure drop equality constraint&#xA;def flow_rule(model, i, j):&#xA;    return ((model.pi[i] - model.pi[j]) * model.d[i, j] ** 5) == (a * model.v_dot[i, j]**2 * model.lengths[i, j])&#xA;model.flow = pyo.Constraint(model.edges, rule=flow_rule)&#xA;&#xA;def conservation_rule(model, i):&#xA;    inflow = sources_dict[i] + sum(model.v_dot[k, i] for k in model.junctions if (k, i) in model.edges)&#xA;    outflow = sinks_dict[i] + sum(model.v_dot[i, k] for k in model.junctions if (i, k) in model.edges)&#xA;    return inflow == outflow&#xA;model.conservation = pyo.Constraint(model.junctions, rule=conservation_rule)&#xA;&#xA;&#xA;# solving&#xA;solver = SolverFactory(&amp;quot;ipopt&amp;quot;)&#xA;results = solver.solve(model, tee=True)&#xA;model.display()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Results&lt;/h1&gt;&#xA;&lt;p&gt;When attaching a a single source to node 0 and a single sink to node 10 (see the data below)&#xA;the results should show the fluid flowing through the path 0-1-2-6-4-8-10. However, a lower boundary of 30 has to be assigned to vdot, otherwise the solver doesn't return results(this is discussed further in the section &lt;em&gt;Results discussion&lt;/em&gt;). The results I am getting are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;from the solver, the returned result is a point of local infeasibility&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;EXIT: Converged to a point of local infeasibility. Problem may be infeasible.&#xA;WARNING: Loading a SolverResults object with a warning status into&#xA;    model.name=&amp;quot;unknown&amp;quot;;&#xA;      - termination condition: infeasible&#xA;      - message from solver: Ipopt 3.11.1\x3a Converged to a locally&#xA;        infeasible point. Problem may be infeasible.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;objective function value&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;  Objectives:&#xA;obj : Size=1, Index=None, Active=True&#xA;&#xA;     |Key  | Active | Value|&#xA;     |-----|--------|------|&#xA;     |None |   True | 1091.8088253777207|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/R5QPg.png&quot; rel=&quot;noreferrer&quot;&gt;diameters&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nlJnt.png&quot; rel=&quot;noreferrer&quot;&gt;(squared) pressures&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UvOk2.png&quot; rel=&quot;noreferrer&quot;&gt;(normal) flow rate&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KDUO0.png&quot; rel=&quot;noreferrer&quot;&gt;pressure drop constraint&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dZ2iB.png&quot; rel=&quot;noreferrer&quot;&gt;mass conservation constraint&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Results discussion&lt;/h2&gt;&#xA;&lt;p&gt;The diameters for the pipelines/edges (path 0-1-2-4-6-8-10) on which the fluid is supposed to flow are good (consistent to the results of another python package, namely pandapipes) and the pressure values are also what they are supposed to be. However the diameters of the other edges should be reduced to zero by the solver in order to minimize the objective function. This is not the case and the reason might be the lower boundary on the volume flow rate (vdot). however, as soon as I try to lower this bound slightly, the solver returns very bad results. For lower (&amp;lt;= 20) boundary values, the solver doesn't return results at all. After only one iteration I get the solver error:&#xA;EXIT: Restoration Failed!&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The goal is to have the solver return results for v_dot lower boundary equal to 0 (in order to have no fluid flowing on the pipelines where its not supposed to flow)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;h2&gt;What I've tried to do:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I tried to initialize the decision variables at values which are near the solution point.&lt;/li&gt;&#xA;&lt;li&gt;I tried to scale down the pressures in the pressure drop equality constraint by multiplying the right hand side of the equation by 10^(-4).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;Mathematical formulation&lt;/h1&gt;&#xA;&lt;p&gt;The mathematical problem formulation is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NoXmA.gif&quot; rel=&quot;noreferrer&quot;&gt;Problem Formulation&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CLaw4.png&quot; rel=&quot;noreferrer&quot;&gt;Formulation Table&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h1&gt;The data&lt;/h1&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;junctions_pyo : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;edges_pyo : [(0, 1), (1, 2), (2, 3), (3, 4), (3, 5), (2, 6), (6, 8), (8, 9), (8, 10),(6, 7)]&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;lengths_dict_pyo: {(0, 1): 24.66, (1, 2): 45.58, (2, 3): 94.43, (3, 4): 21.97, (3, 5): 24.69, (2, 6): 77.85, (6, 8): 61.81, (8, 9): 12.30, (8, 10): 27.58, (6, 7): 27.60}&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;sources_dict: {0: 1219.33, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0}&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;sinks_dict : {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 1219.33}&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7208" LastActivityDate="2021-09-27T18:47:21.313" Title="pyomo/ipopt: nonlinear network optimization not converging" Tags="|optimization|nonlinear-programming|pyomo|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6987" PostTypeId="1" AcceptedAnswerId="6992" CreationDate="2021-09-27T11:46:54.527" Score="2" ViewCount="819" Body="&lt;p&gt;I have the following data:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A fixed depot/facility location&lt;/li&gt;&#xA;&lt;li&gt;Dropping points with demands&lt;/li&gt;&#xA;&lt;li&gt;List of available vehicles (heterogeneous fleets)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;What I am trying to do is, given the list of vehicles and dropping points, particular serving time and travelling time how should the vehicles be assigned?&lt;/p&gt;&#xA;&lt;p&gt;Progress so far:&lt;/p&gt;&#xA;&lt;p&gt;With the help of capacitated clustering, I have already clustered the locations. I have considered both the geospatial proximity and the demand of each point, such that the total radius of the cluster doesn't exceed a given radius and maximum demand doesn't exceed the lowest serving demand of the available vehicle (which in this case is 700 kg).&lt;/p&gt;&#xA;&lt;p&gt;Each of these clusters has a particular serving time which I have computed, and there is a travelling time to the center of the cluster which I can compute with &lt;a href=&quot;https://cran.r-project.org/web/packages/osrm/osrm.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;osrm&lt;/a&gt; package in &lt;code&gt;R&lt;/code&gt;.&#xA;Each vehicle can be hired for a particular duration (E.g 12 hours)&lt;/p&gt;&#xA;&lt;p&gt;Now, how to determine which clusters will be served by which vehicles given the time and capacity constraints? The cost associated is strictly a function of time, so if that can be optimized, then the total cost will be optimized too.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for some heuristics or a general approach to tackle the problem.&lt;/p&gt;&#xA;" OwnerUserId="5532" LastActivityDate="2021-09-27T21:34:13.780" Title="Adapting a cluster-first-route-second approach for VRP with heterogenous fleet" Tags="|optimization|combinatorial-optimization|vehicle-routing|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6988" PostTypeId="2" ParentId="6977" CreationDate="2021-09-27T15:41:32.007" Score="4" Body="&lt;p&gt;General global optimisation problems are solvable in finite time and in a finite number of steps, under the following assumptions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All mathematical expressions are available (i.e. not black-box problems). We use those to produce rigorous bounds that improve deterministically.&lt;/li&gt;&#xA;&lt;li&gt;The primitives do not include functions that cannot be bounded properly (in the general case), such as error functions, integrals, or differentials.&lt;/li&gt;&#xA;&lt;li&gt;The underlying software/hardware supports bounding numerical error rigorously, and the software is bug-free.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The field of optimisation that studies such algorithms is called &lt;a href=&quot;https://en.wikipedia.org/wiki/Deterministic_global_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;deterministic global optimisation&lt;/a&gt;. The basics of the theory were nicely summarised by Neumaier in &lt;a href=&quot;https://www.cambridge.org/core/books/acta-numerica-2004/E1BFF63540BCA42AD89F7EEC4B1CEBBE&quot; rel=&quot;nofollow noreferrer&quot;&gt;Acta Numerica 2004&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the general case, unless these assumptions hold, an arbitrary global optimisation problem can be solved in infinite time, unless it is bounded and discrete in which case the solutions can be enumerated in finite time.&lt;/p&gt;&#xA;&lt;p&gt;Note that &amp;quot;solving&amp;quot; a global optimisation problem means not only finding the global solution, but also proving that it is the global solution.&lt;/p&gt;&#xA;&lt;p&gt;Further note that &amp;quot;finite time&amp;quot; or &amp;quot;finite number of steps&amp;quot; often mean little in practice, as said finite time can be trillions of years. An &amp;quot;infinite time&amp;quot; algorithm can often outperform a finite time algorithm in practice.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-09-28T07:12:02.903" LastActivityDate="2021-09-28T07:12:02.903" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6989" PostTypeId="2" ParentId="6986" CreationDate="2021-09-27T16:01:02.593" Score="7" Body="&lt;p&gt;That IPOPT message means that IPOPT could not find a feasible solution to your problem. The reason could be either that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Once you set that value below 30, IPOPT can no longer find that basin of attraction (or that basin vanishes). Another feasible solution might exist (unless your problem is convex), but IPOPT can't find it.&lt;/li&gt;&#xA;&lt;li&gt;Your problem actually becomes infeasible.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Things you can do:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Start removing constraints to see if your problem will become feasible at some point.&lt;/li&gt;&#xA;&lt;li&gt;Use a deterministic global optimisation solver (e.g.  Octeract Engine, BARON, Couenne), which can actually prove whether your problem is infeasible or not. If it's not, they are much more likely to find a solution than standalone IPOPT is.&lt;/li&gt;&#xA;&lt;li&gt;Provide a feasible solution in a basin of attraction you want IPOPT to explore.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="4777" LastEditDate="2021-09-27T18:47:21.313" LastActivityDate="2021-09-27T18:47:21.313" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6990" PostTypeId="2" ParentId="6977" CreationDate="2021-09-27T20:22:36.250" Score="2" Body="&lt;p&gt;I had a look at your paper. Here are two errors that I think are worth reflecting about:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You are assuming computations in finite precision, and consider solving a continous optimization problem. We could stop there: it is impossible to represent an arbitrary real number with finite precision. Most works in continuous optimization assume an abstract computation model with arithmetic over the real numbers. Others may consider problems that are solvable over the rational numbers, that can indeed be represented by a Turing machine.&lt;/li&gt;&#xA;&lt;li&gt;A Turing machine may halt/not halt on infinitely many inputs. Consider one that detects odd numbers, for example.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Don't let a few errors discourage you. If you are interested in the mathematical aspects of optimization, I suggest you do not start right away looking for new theorems. Online courses are a good way to know the basics (MIT's opencourseware comes to mind), but a direct contact with the academic community is a must if you want to do research in the field.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2021-09-27T20:22:36.250" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6991" PostTypeId="2" ParentId="6983" CreationDate="2021-09-27T21:31:57.817" Score="3" Body="&lt;p&gt;I am not an expert in elevator traffic system simulation, but by googling you could find lots of related papers and literature. Some of them are as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.researchgate.net/publication/273761657_Modelling_of_Elevator_Traffic_Systems_Using_Queuing_Theory&quot; rel=&quot;nofollow noreferrer&quot;&gt;Modelling of Elevator Traffic Systems Using Queuing Theory&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S1474667017358226&quot; rel=&quot;nofollow noreferrer&quot;&gt;The modeling and simulation of elevator group control systems for public service buildings&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also, there are some useful simulation software like &lt;a href=&quot;https://www.rockwellautomation.com/en-us/products/software/arena-simulation.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arena&lt;/a&gt;, &lt;a href=&quot;https://www.anylogic.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Anylogic&lt;/a&gt;, etc. which either are frequently used in practice and cited in the papers. About the programming language python might be easy to use. If you are interested in software, one might be:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.anylogic.com/resources/articles/passenger-flow-simulation-to-optimize-elevator-traffic/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Passenger Flow Simulation to Optimize Elevator Traffic&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-09-27T21:31:57.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6992" PostTypeId="2" ParentId="6987" CreationDate="2021-09-27T21:34:13.780" Score="4" Body="&lt;p&gt;As per the comment of @Pedrinho, your clustering approach has a problem. A vehicle route is an &lt;em&gt;ordered sequence of customers&lt;/em&gt;. A cluster-first-route-second approach splits the problem of determining routes into 2 parts: (1) partitioning the customers into disjoint groups, s.t. every group can be assigned to a vehicle, (2) for customers that are grouped together, a route is determined. A major advantage of this approach is that step (2) can be accomplished for each vehicle independently, so the routing problem becomes relatively simple. A cluster-first-route-second approach works generally well for homogeneous vehicles, since every route can be executed by every vehicle, i.e. we don't need to assign routes to specific vehicles.&lt;/p&gt;&#xA;&lt;p&gt;In case of heterogeneous vehicles, there's a problem. You could create clusters in such a way that every cluster can be assigned to every vehicle. This implies that the total demand of customers in a single cluster cannot exceed the capacity of the &lt;em&gt;smallest&lt;/em&gt; vehicle. Essentially you create a lot of small routes, which you can then assign to all vehicles. The obvious downside is that a lot of the capacity of your larger vehicles will remain unused. If you go for this approach, you should implement an improvement heuristic as well.&lt;/p&gt;&#xA;&lt;p&gt;I would recommend to read this book chapter, which gives an overview of several heuristics for the VRP with heterogeneous vehicles: Baldacci R., Battarra M., Vigo D. (2008) Routing a Heterogeneous Fleet of Vehicles. In: Golden B., Raghavan S., Wasil E. (eds) The Vehicle Routing Problem: Latest Advances and New Challenges. Operations Research/Computer Science Interfaces, vol 43. Springer, Boston, MA. &lt;a href=&quot;https://doi.org/10.1007/978-0-387-77778-8_1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1007/978-0-387-77778-8_1&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Instead of using a cluster-first-route-second approach, I would probably opt for a simple insertion heuristic: assign customers, one-by-one to your vehicles, always inserting in a way that your objective function increases the least. This will give you a feasible initial solution, which you can then improve with an improvement heuristic (e.g. LNS/VNS).&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-09-27T21:34:13.780" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6993" PostTypeId="1" AcceptedAnswerId="6994" CreationDate="2021-09-28T01:42:55.467" Score="4" ViewCount="145" Body="&lt;p&gt;Are there any good references that provide an intuitive, motivated, or visual explanation of the conjugate gradient method?&lt;/p&gt;&#xA;" OwnerUserId="7263" LastActivityDate="2021-09-28T11:33:22.497" Title="What are some good references for understanding the conjugate gradient method?" Tags="|reference-request|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6994" PostTypeId="2" ParentId="6993" CreationDate="2021-09-28T01:42:55.467" Score="7" Body="&lt;p&gt;A great reference for the conjugate gradient method is&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.110.418&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;An Introduction to the Conjugate Gradient Method Without the Agonizing Pain&lt;/em&gt; by Jonathan Richard Shewchuk (1994)&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The author writes in the first paragraph:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When I decided to learn the Conjugate Gradient Method (henceforth, CG), I read four different descriptions, which I shall politely not identify. I understood none of them. Most of them simply wrote down the method, then proved its properties without any intuitive explanation or hint of how anybody might have invented CG in the first place. This article was born of my frustration, with the wish that future students of CG will learn a rich and elegant algorithm, rather than a confusing mass of equations.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Not only does the author provide a clear explanation of the conjugate gradient method using diagrams, but they also provide great intuitive explanations for its convergence properties.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2021-09-28T11:33:22.497" LastActivityDate="2021-09-28T11:33:22.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6996" PostTypeId="1" AcceptedAnswerId="6999" CreationDate="2021-09-28T06:05:42.627" Score="8" ViewCount="427" Body="&lt;p&gt;I am hoping someone will be able to point me in the direction of why I am experiencing floating-point outputs rather than simply model.X = [15,15] and model.Z = [15,5] as solutions to this model?&lt;/p&gt;&#xA;&lt;p&gt;Note that I use a piece-wise constraint to determine the relationship between Z and X.&lt;/p&gt;&#xA;&lt;p&gt;Scroll down to see the outputs from the model solver.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.core import *&#xA;&#xA;# Define the model type&#xA;model = ConcreteModel()&#xA;&#xA;# Piecewise components - index and variables&#xA;model.INDEX1 = Set(dimen=1, initialize=[0,1])&#xA;model.X = Var(model.INDEX1, bounds=(5,15))&#xA;model.Z = Var(model.INDEX1)&#xA;&#xA;# For indexed variables, the following must be python dictionaries with keys the same as the variable index&#xA;&#xA;DOMAIN_PTS = {0: [5, 10, 15], 1: [5, 10, 15]}&#xA;RANGE_PTS = {0: [30, 20, 15], 1: [5, 5, 5]}&#xA;&#xA;# Set piecewise constraint&#xA;model.linearized_constraint = Piecewise(model.INDEX1,        # indexing sets&#xA;                                        model.Z,model.X,     # range and domain variables&#xA;                                        pw_pts=DOMAIN_PTS,&#xA;                                        pw_constr_type='EQ',&#xA;                                        pw_repn='INC',&#xA;                                        f_rule=RANGE_PTS,&#xA;                                        unbounded_domain_var = False)&#xA;&#xA;# Maximize the sumproduct of z and x over the index&#xA;model.obj = Objective(expr= sum(model.Z[i] * model.X[i] for i in model.INDEX1) , sense=maximize)&#xA;opt = SolverFactory('gurobi')&#xA;opt.options['NonConvex'] = 2&#xA;obj_val = opt.solve(model)&#xA;&#xA;# Print results&#xA;print([value(model.X[i]) for i in model.INDEX1])&#xA;print([value(model.Z[i]) for i in model.INDEX1])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;**WARNING: Piecewise component 'linearized_constraint[(1,)]' has detected slopes of consecutive piecewise segments to be within 1e-08 of one another. Refer to the Piecewise help documentation for information on how to disable this warning.&#xA;[14.890257352941177, 15.0]&#xA;[15.109742647058823, 5.0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4256" LastActivityDate="2021-09-28T12:45:30.237" Title="Why is Gurobi output in Pyomo returning floating-point values rather than optimal integer solution?" Tags="|python|gurobi|pyomo|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6997" PostTypeId="1" CreationDate="2021-09-28T10:46:03.307" Score="5" ViewCount="441" Body="&lt;p&gt;I have a discrete event simulation (simmer package) based on probability distributions in R. I would like to optimize the variables according to several (2 or more) objectives. I used the NSGA-II algorithm, but this is only working with continous optimization. Is there a similar approach for integer optimization?&lt;/p&gt;&#xA;" OwnerUserId="7265" LastActivityDate="2021-09-28T16:43:43.417" Title="R package for multi objective integer evolutionary algorithm" Tags="|optimization|integer-programming|r|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6998" PostTypeId="1" AcceptedAnswerId="7004" CreationDate="2021-09-28T12:02:11.080" Score="-3" ViewCount="1202" Body="&lt;p&gt;Please, if someone can give me an example of the application of conflict refiner,  I have already read the documentation but I did not understand how to use it well.&lt;/p&gt;&#xA;" OwnerUserId="5537" LastEditorUserId="36" LastEditDate="2021-09-28T13:05:59.040" LastActivityDate="2021-09-28T23:01:32.597" Title="How to check infeasibility with conflict refiner (docplex mixed integer programming )?" Tags="|mixed-integer-programming|docplex|irreducible-infeasible-subset|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6999" PostTypeId="2" ParentId="6996" CreationDate="2021-09-28T12:45:30.237" Score="7" Body="&lt;p&gt;I suspect Gurobi actually only gets passed floating point values from the Python API and it only works with floating point values internally so Python or the Python API might implictly convert your integers to floating points value.&lt;/p&gt;&#xA;&lt;p&gt;If we look at the C function &lt;code&gt;GRBsetpwlobj&lt;/code&gt; which is given as example how to define piecewise functions &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/c_setpwlobj.html#routine:GRBsetpwlobj&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int     GRBsetpwlobj (  GRBmodel    *model,&#xA;        int     var,&#xA;        int     npoints,&#xA;        double  *x,&#xA;        double  *y )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; are arrays of double numbers which are floating point numbers.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The reason why you get floating point values is because Gurobi only gets floating point values to work with.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-09-28T12:45:30.237" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7000" PostTypeId="2" ParentId="6998" CreationDate="2021-09-28T13:04:35.907" Score="3" Body="&lt;p&gt;As the &lt;a href=&quot;https://ibmdecisionoptimization.github.io/docplex-doc/mp/docplex.mp.conflict_refiner.html#docplex.mp.conflict_refiner.ConflictRefiner&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;docplex&lt;/code&gt; documentation&lt;/a&gt; says:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Given an infeasible model, the conflict refiner can identify&#xA;conflicting constraints and bounds within it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So, consider you have an infeasible model (I'll call my instance &lt;code&gt;model&lt;/code&gt;). This is one way to use the conflict refiner.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import docplex.mp.conflict_refiner as cr&#xA;import docplex.mp.model as cpx&#xA;&#xA;model = cpx.Model(name='my_model')&#xA;...&#xA;model.solve()&#xA;solve_status = model.get_solve_status()&#xA;if solve_status.name == 'INFEASIBLE_SOLUTION':  # or also 'INFEASIBLE_OR_UNBOUNDED_SOLUTION'&#xA;    cref = cr.ConflictRefiner()&#xA;    print('show some of the constraints that can be removed to arrive at a minimal conflict')&#xA;    cref.refine_conflict(model, display=True)  # display flag is to show the conflicts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can create a simple model for yourself and intentionally change a constraint to make the model infeasible and observe what this code does.&lt;/p&gt;&#xA;&lt;p&gt;If you have a lot of conflicts of similar nature (e.g., it's from the same constraint), then cplex tells you about it and only shows you some of them rather than polluting your screen.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2021-09-28T13:04:35.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7001" PostTypeId="2" ParentId="6997" CreationDate="2021-09-28T14:44:02.803" Score="0" Body="&lt;p&gt;Your question title mentions &amp;quot;evolutionary algorithm&amp;quot;, so (a) I assume you are comfortable with a heuristic solution and (b) I assume you have some familiarity with evolutionary algorithms.&lt;/p&gt;&#xA;&lt;p&gt;There is an excellent genetic algorithm package for R, named &lt;a href=&quot;https://cran.r-project.org/web/packages/GA/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GA&lt;/a&gt;. I think there may be a few other genetic algorithm packages for R, but this is the only one with which I am familiar. It provides for three variable types: real, binary and permutation. So you can require your decision variables to be integer-valued by using a binary encoding, or you can just use a typical encoding as real numbers and then round the chromosomes to integers.&lt;/p&gt;&#xA;&lt;p&gt;I do not believe that GA directly supports multiple objectives. There are research papers on multiobjective genetic algorithms, but I don't think I've seen a GA library that supports multiple objectives. Since you get to define the fitness function, you can have it use a weighted sum of your objectives, if that fits your goals.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-09-28T14:44:02.803" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7002" PostTypeId="2" ParentId="6997" CreationDate="2021-09-28T14:45:02.320" Score="2" Body="&lt;p&gt;A short look into the literature shows that mixed integer multi objective algorithms are still in an early stage with people proposing different formulations and approaches. I am not aware of any open solvers that could be readily used even outside the R ecosystem. So i see multiple options for you:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Weighted sum approach and use the package GA as prubin suggested.&lt;/li&gt;&#xA;&lt;li&gt;Contact authors of &lt;a href=&quot;https://dl.acm.org/doi/10.1145/3449726.3459521&quot; rel=&quot;nofollow noreferrer&quot;&gt;papers&lt;/a&gt; &lt;a href=&quot;https://arxiv.org/pdf/1909.08748.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;such&lt;/a&gt; &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S1568494615002240&quot; rel=&quot;nofollow noreferrer&quot;&gt;as&lt;/a&gt; &lt;a href=&quot;https://aip.scitation.org/doi/pdf/10.1063/1.5090013&quot; rel=&quot;nofollow noreferrer&quot;&gt;these&lt;/a&gt; to see if you could learn whether there code works for you and could be used from R.&lt;/li&gt;&#xA;&lt;li&gt;Run a series of NSGA-II problems where you increasingly punish the distance from integer points.&lt;/li&gt;&#xA;&lt;li&gt;Run NSGA-II where you punish non integerness harshly from the beginning&lt;/li&gt;&#xA;&lt;li&gt;If you only have a few integer variables, solving it as independent problem with all the integer variables assigned in all combinations&lt;/li&gt;&#xA;&lt;li&gt;Implement your own branch and bound based multi objective which i have a sketch below.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Branch and Bound over evolutionary algorithm in a multi-ojective context&lt;/h3&gt;&#xA;&lt;p&gt;I assume that your NSGA-II implementation is hot startable (you can give it an initial population). Luckily NSGA-II is an algorithm which resumeable, running it for 10 iterations and then getting the population and then running it for another 10 iterations is as roughly good as running it for 20 iterations.&lt;/p&gt;&#xA;&lt;p&gt;There are two core concepts for branch and bound, namely a node in the branch and bound tree and the continous relaxation of a node. A node represents a hypercube in the space defined by a cartesian product of your integer variables. All variables have an interval associated with it in each node. A continous relaxtion is a pessimistic bound of the objectives that can be achieved over a node.&lt;/p&gt;&#xA;&lt;p&gt;The idea of branch and bound is to evaluate the continous relaxations of nodes, branch on some variable by making the intervals of one variable smaller or even assign an integer and once integer solutions are found to remove nodes whose continous relaxation is dominated by an integer solution.&lt;/p&gt;&#xA;&lt;p&gt;Due to the fact that we don't have access to a continous relaxation, we will call the pareto front found by NSGA-II inside our box a continous relaxation, we might miss optima but that is the inherent nature of evolutionary algorithms. Luckily &lt;code&gt;nsga2R&lt;/code&gt; which i allows you to use allows box constraints. I assume that your integers are not necessarily a choice between two numbers.&lt;/p&gt;&#xA;&lt;p&gt;I haven't made any attempts to prove anything about this algorithm i propose. So it probably has weaker properties then NSGA-II.&lt;/p&gt;&#xA;&lt;p&gt;Each nodes stores the lower bound and the upper bound of the interval of each variable, the current population and information for an early stopping criteria of your choice. Furthermore you need a list to store the points on the pareto front, it is essential that you only add integer solutions to this. You also need a queue of nodes.&lt;/p&gt;&#xA;&lt;p&gt;You make progress by processing nodes and adding at the end of the queue either the same node, no node, or child-nodes to the list. When you add the same node again, you do so after running a few rounds of NSGA-II. When you branch, you want to such that the least promosing parts (so that they can be isolated and discarded quickly) and the most promising parts (so you can find a good approximation of the pareto front quickly helping you discard not so promising parts) get branched on early.&lt;/p&gt;&#xA;&lt;p&gt;When you process a node:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You run a few rounds of NSGA-II restricted to the box described by the node&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Check for Integerness of the solution&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If all the population members are the same integer in a variable, or after rounding in that variable dominate their previous value and land on that integer then take those branching decisions and add a new node with all those branching decision taken, don't add this node back as it is dominated by the much smaller search space we found. Still run 3. though&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Attempt to add integer solutions to pareto front&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Round all integer variables to the nearest integer for the entire population (thereby making the solution worst) and try to add it to the pareto front. Maintain that the pareto front is a pareto front if you added solutions. This pareto front behaves as a pessimal bound of the parteo front that appraoches the pareto front&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Decide wheter to either throw away the node, work more on it later or branch on this node&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If the number NSGA-II iterations, rate of improvement, the past glory of Interger solutions added to the pareto front in 3. expired and the populatino in this node is not better than the pareto front and the distance to the pareto front so large that is tells you won't find anything here, don't add the node back to the list&lt;/li&gt;&#xA;&lt;li&gt;If the number NSGA-II iterations, rate of improvement tell you won't make improvement but your population (which has non integer values for pareto variables) is better than the pareto front, find a variable to branch upon produce multiple childreen you add to the list&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Calculate the average objective vector &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, for each variable take the midpoint &lt;span class=&quot;math-container&quot;&gt;$m_i$&lt;/span&gt; in the interval of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th variable then calculate the sum of &lt;span class=&quot;math-container&quot;&gt;$||\sum_{x\in\text{Pop}}(x_i-m_i)(f(x)-a)||_2$&lt;/span&gt; and select the i with the largest value.&lt;/li&gt;&#xA;&lt;li&gt;If the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th variables interval contains more than two Integers then apply the above formula for every pair of neighboring integers &lt;span class=&quot;math-container&quot;&gt;$(n, n+1)$&lt;/span&gt; in the interval with &lt;span class=&quot;math-container&quot;&gt;$n+1/2$&lt;/span&gt; being the &lt;span class=&quot;math-container&quot;&gt;$m_i$&lt;/span&gt; and all population numbers, choose &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; such that this term is minial and the create two childreen with same constraints except in the ith where one now has the upperbound &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and the otherone the lower bound &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt;. Discard the part of the population that doesn't fit in the box and replace it by randomly sampled points.&lt;/li&gt;&#xA;&lt;li&gt;If the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th variables interval contains two integer &lt;span class=&quot;math-container&quot;&gt;$n, n+1$&lt;/span&gt;, create two childreen with the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th variable set to those values respectively and set the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th component of all the population to that integer too.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is one branching heuristic, i could think of different ones. It is based on a scale as analogy that we want to find the most out of balance variable and balance it.&lt;/li&gt;&#xA;&lt;li&gt;Since we divided the integer search space completly we don't add the parent we branched from back to queue.&lt;/li&gt;&#xA;&lt;li&gt;If you have constraints, those would need to go here too.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;If none of these criterions apply we do all the book keeping and add the node with new population, same bounds and information for an early stopping criteria updated back to the list.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-09-28T16:43:43.417" LastActivityDate="2021-09-28T16:43:43.417" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7003" PostTypeId="2" ParentId="6982" CreationDate="2021-09-28T21:50:28.390" Score="6" Body="&lt;p&gt;I am not aware of anything in the Coin-OR or AMPL ecosystem that does that as i am not familiar with those ecosystems. However one can convince the open source modeling language JuMP to do what you want with a few lines of Julia.&lt;/p&gt;&#xA;&lt;p&gt;I assume you have a Julia installed and JuMP installed into your working (or global) environment.&lt;/p&gt;&#xA;&lt;p&gt;Let's first create a model:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using JuMP #assumes you did ]add JuMP [enter] [waiting] [backspace] once&#xA;&#xA;m = Model()&#xA;&#xA;@variable(m, x[1:2])&#xA;&#xA;@constraint(m, x[1] + x[2] &amp;lt;= 1)&#xA;@constraint(m, x[1] - x[2] &amp;lt;= 1)&#xA;@constraint(m, -x[1] + x[2] &amp;lt;= 1)&#xA;@constraint(m, -x[1] - x[2] &amp;lt;= 1)&#xA;&#xA;@objective(m, Max, pi*x[1] -x[2])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If we know wanted to write that into an MPS or LP file it would be as easy as &lt;code&gt;write_to_file(m, &amp;quot;test.lp&amp;quot;)&lt;/code&gt; &lt;code&gt;write_to_file(m, &amp;quot;test.mps&amp;quot;)&lt;/code&gt; however that would not be in form you want. So let's define that form by defining a new model type:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;MOI.Utilities.@model(&#xA;    MyStandardForm,&#xA;    (),&#xA;    (MOI.EqualTo,),&#xA;    (MOI.Nonnegatives,),&#xA;    (),&#xA;    (),&#xA;    (MOI.ScalarAffineFunction,),&#xA;    (MOI.VectorOfVariables,),&#xA;    (),&#xA;    false,&#xA;)&#xA;&#xA;function MOI.supports_add_constrained_variables(&#xA;    ::MyStandardForm, &#xA;    ::Type{MOI.Reals},&#xA;)&#xA;    return false&#xA;end&#xA;&#xA;function MOI.supports_add_constrained_variable(&#xA;    ::MyStandardForm,&#xA;    ::Type{S},&#xA;) where {S&amp;lt;:MOI.AbstractScalarSet}&#xA;    return false&#xA;end&#xA;&#xA;function MOI.supports_add_constrained_variables(&#xA;    ::MyStandardForm,&#xA;    ::Type{MOI.Nonnegatives},&#xA;)&#xA;    return true&#xA;end&#xA;&#xA;function bridged_copy_to(dest, src)&#xA;    MOI.copy_to(MOI.Bridges.full_bridge_optimizer(dest, Float64), src)&#xA;    return dest&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This model type uses the backend MathOptInterface to do all the transformations by only accepting a &amp;quot;standard LP construct&amp;quot;. Now we got to copy our model &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; into a model build from our newly defined type.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;std_form = MyStandardForm{Float64}()&#xA;bridged_copy_to(std_form, backend(model))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However due to it being a user defined model the exporting is a bit more incovinient as we got to convert it first into a model type MathOptInterface defined.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;MOI.write_to_file(bridged_copy_to(MOI.FileFormats.LP.Model(), std_form_m), &amp;quot;std_form.lp&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or for mps:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; MOI.write_to_file(bridged_copy_to(MOI.FileFormats.MPS.Model(), std_form_m), &amp;quot;std_form.mps&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which gives puts these files into your &lt;code&gt;pwd()&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;maximize&#xA;obj: 3.141592653589793 x1 - 3.141592653589793 x3 - 1 x2 + 1 x4&#xA;subject to&#xA;c1: -1 x1 - 1 x2 + 1 x3 + 1 x4 - 1 x5 = -1&#xA;c2: -1 x1 + 1 x2 + 1 x3 - 1 x4 - 1 x6 = -1&#xA;c3: 1 x1 + 1 x2 - 1 x3 - 1 x4 - 1 x7 = -1&#xA;c4: 1 x1 - 1 x2 - 1 x3 + 1 x4 - 1 x8 = -1&#xA;Bounds&#xA;x1 &amp;gt;= 0&#xA;x2 &amp;gt;= 0&#xA;x3 &amp;gt;= 0&#xA;x4 &amp;gt;= 0&#xA;x5 &amp;gt;= 0&#xA;x6 &amp;gt;= 0&#xA;x7 &amp;gt;= 0&#xA;x8 &amp;gt;= 0&#xA;End&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or in &amp;quot;std_form.mps&amp;quot;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;NAME          &#xA;ROWS&#xA; N  OBJ&#xA; E  c1&#xA; E  c2&#xA; E  c3&#xA; E  c4&#xA;COLUMNS&#xA;    x1        c1        -1&#xA;    x1        c2        -1&#xA;    x1        c3        1&#xA;    x1        c4        1&#xA;    x1        OBJ       -3.141592653589793 &#xA;    x2        c1        -1&#xA;    x2        c2        1&#xA;    x2        c3        1&#xA;    x2        c4        -1&#xA;    x2        OBJ       1&#xA;    x3        c1        1&#xA;    x3        c2        1&#xA;    x3        c3        -1&#xA;    x3        c4        -1&#xA;    x3        OBJ       3.141592653589793 &#xA;    x4        c1        1&#xA;    x4        c2        -1&#xA;    x4        c3        -1&#xA;    x4        c4        1&#xA;    x4        OBJ       -1&#xA;    x5        c1        -1&#xA;    x6        c2        -1&#xA;    x7        c3        -1&#xA;    x8        c4        -1&#xA;RHS&#xA;    rhs       c1        -1&#xA;    rhs       c2        -1&#xA;    rhs       c3        -1&#xA;    rhs       c4        -1&#xA;RANGES&#xA;BOUNDS&#xA; LO bounds    x1        0&#xA; PL bounds    x1&#xA; LO bounds    x2        0&#xA; PL bounds    x2&#xA; LO bounds    x3        0&#xA; PL bounds    x3&#xA; LO bounds    x4        0&#xA; PL bounds    x4&#xA; LO bounds    x5        0&#xA; PL bounds    x5&#xA; LO bounds    x6        0&#xA; PL bounds    x6&#xA; LO bounds    x7        0&#xA; PL bounds    x7&#xA; LO bounds    x8        0&#xA; PL bounds    x8&#xA;ENDATA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://jump.dev/MathOptInterface.jl/dev/submodules/FileFormats/overview/#Read-from-file&quot; rel=&quot;nofollow noreferrer&quot;&gt;You can also read in existing files&lt;/a&gt; you then can copy to into a model instance of &lt;code&gt;MyStandardFormFunctionConstraints&lt;/code&gt; and then copy that one in a new &lt;code&gt;MOI.FileFormats.LP.Model()&lt;/code&gt;and write that to disk. If you wanted to do batch processing i would recommend looping over the files in Julia so you only have to pay the compilation overhead once and not per file.&lt;/p&gt;&#xA;&lt;p&gt;If you want to use that Mixed-Integer problems &lt;code&gt;MyStandardFormFunctionConstraints&lt;/code&gt; would need to be declared to also support those and an appropiate output format that also supports would need to be chosen.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-09-28T23:54:12.947" LastActivityDate="2021-09-28T23:54:12.947" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7004" PostTypeId="2" ParentId="6998" CreationDate="2021-09-28T23:01:32.597" Score="3" Body="&lt;p&gt;ILOG Cplex 20.1 installation comes with a directory with examples. To use the conflict refiner, you want to consult the &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=conflicts-how-invoke-conflict-refiner&quot; rel=&quot;nofollow noreferrer&quot;&gt;manual&lt;/a&gt; which includes a list of files that contain examples on how to use the conflict refiner. Of particular interest are the following files:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;./examples/src/java/ConflictEx1.java&#xA;./examples/src/cpp/iloconflictex1.cpp&#xA;./examples/src/python/conflictex1.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that the last python file, does not use the Docplex python interface! &lt;em&gt;(for reasons unknown to me, ILOG maintains 2 different python interfaces for the same product, each with a different syntax and capabilities, which is very confusing if you aren't aware of this)&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Those 3 example files, plus the manual on &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=unboundedness-diagnosing-infeasibility-by-refining-conflicts&quot; rel=&quot;nofollow noreferrer&quot;&gt;Diagnosing infeasibility by refining conflicts&lt;/a&gt; should give you a pretty good idea of how to use the conflict refiner. To my knowledge, ILOG does not provide a Docplex conflict refiner example in their example &lt;a href=&quot;http://ibmdecisionoptimization.github.io/docplex-doc/mp/samples.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;directory&lt;/a&gt;, but @EhsanK provided a good example above.&lt;/p&gt;&#xA;&lt;p&gt;Finally, if you want to understand how the conflict refiner works internally (and why it may take a very long time to compute a minimal conflict), refer to this paper (and the reference in this paper): Parker, M., Ryan, J. Finding the minimum weight IIS cover of an infeasible system of linear inequalities. Ann Math Artif Intell 17, 107–126 (1996). &lt;a href=&quot;https://doi.org/10.1007/BF02284626&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1007/BF02284626&lt;/a&gt;&#xA;In particular, it has been shown that finding a minimum (irreducible) set of constraints that render your problem infeasible, is NP-hard.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-09-28T23:01:32.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7005" PostTypeId="1" CreationDate="2021-09-29T00:06:58.830" Score="3" ViewCount="107" Body="&lt;p&gt;As a followup to &lt;a href=&quot;https://or.stackexchange.com/questions/6898/convex-function-subject-to-0-le-x-1-le-ldots-le-x-n-le-1-and-linear-constrai&quot;&gt;this question&lt;/a&gt;, I am looking for references for the problem of maximizing &lt;span class=&quot;math-container&quot;&gt;$x^TQx$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is positive definite, subject to linear equality and inequality constraints bounding all variables. @prubin explained feasible region is a bounded polytope and that the maximum must occurs at a corner of this polytope. Are there textbooks that develop this theory? I'm specifically wondering about formal definition of &amp;quot;corner&amp;quot; and a proof of his point that &amp;quot;An extreme point (corner) of a polytope is the intersection of a bunch of linearly independent bounding hyperplanes (binding constraints), so there will be at least one maximizer of f() where n of the constraints are binding.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;I could have posted this as a comment to the original answer but I see at least one &lt;a href=&quot;https://stackoverflow.com/questions/39292544/maximize-quadratic-objective-function-subject-to-linear-equality-and-inequality&quot;&gt;other question&lt;/a&gt;  dealing with a similar maximization problem (one differene: my feasible region is bounded), so I thought it would be worthwhile to have references stated in a separate answer.&lt;/p&gt;&#xA;" OwnerUserId="7274" LastActivityDate="2021-09-29T16:23:14.987" Title="optimizing quadratic form over bounded polytope" Tags="|reference-request|quadratic-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7006" PostTypeId="1" AcceptedAnswerId="7007" CreationDate="2021-09-29T03:40:08.170" Score="6" ViewCount="301" Body="&lt;p&gt;We are trying to solve a large-scale MIQCQP (18K decision variables) problem via Gurobipy (v9.0.3).&lt;/p&gt;&#xA;&lt;p&gt;Gurobi is able to solve this problem in ~13 mins despite whether or not we &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360043834831-How-do-I-use-MIP-starts-#:%7E:text=v.Start&quot; rel=&quot;nofollow noreferrer&quot;&gt;initialize the decision variables&lt;/a&gt;. Ideally, we are expecting drastic reduction in runtime.&lt;/p&gt;&#xA;&lt;p&gt;Note: We are initializing with the exact optimal value of variables.&lt;/p&gt;&#xA;&lt;p&gt;In case we initialize, we found that its just the &lt;code&gt;Incumbent&lt;/code&gt; column that gets populated in &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/mip_logging.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;solver logs&lt;/a&gt;, whereas &lt;code&gt;BestBd&lt;/code&gt; and &lt;code&gt;Expl&lt;/code&gt; column are the same despite initialization.&lt;/p&gt;&#xA;&lt;p&gt;Does Gurobi search algorithm actually make any use of the initialization?&lt;/p&gt;&#xA;" OwnerUserId="6106" LastEditorUserId="4777" LastEditDate="2021-09-29T09:43:48.423" LastActivityDate="2021-09-29T16:03:21.300" Title="Gurobi searches all nodes despite variable initialization" Tags="|mixed-integer-programming|gurobi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7007" PostTypeId="2" ParentId="7006" CreationDate="2021-09-29T06:57:39.813" Score="9" Body="&lt;p&gt;Gurobi is solving the global optimisation problem. This involves (i) locating the global solution, and (ii) proving that it is the global solution.&lt;/p&gt;&#xA;&lt;p&gt;Step (i) is typically the easiest by far. By providing the solution you are helping the solver fathom more nodes from the beginning, but that's about it. It still needs to prove global optimality, which is the bulk of the calculations.&lt;/p&gt;&#xA;&lt;p&gt;In some problems having the global solution from the beginning can make a huge difference, but it seems like this is not one of them. This can happen if Gurobi has an easy time finding a MIP solution of the same quality as yours. Gurobi makes use of the initialization and the fact that the &lt;code&gt;BestBd&lt;/code&gt; column didn't change means that the solution you provided doesn't help it discard more search space than the solution it finds on its own quickly, which also explains &lt;code&gt;Expl&lt;/code&gt; being unchanged.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2021-09-29T16:03:21.300" LastActivityDate="2021-09-29T16:03:21.300" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7009" PostTypeId="1" CreationDate="2021-09-29T10:22:38.947" Score="4" ViewCount="210" Body="&lt;p&gt;I have a bi-objective MILP (Mixed Integer Linear Programming) problem, where I call the two objective functions as &lt;code&gt;Obj1&lt;/code&gt; and &lt;code&gt;Obj2&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would like to simultaneously maximize both of them via the &lt;code&gt;Augmented Epsilon-Constraint&lt;/code&gt; Method.&#xA;It will generate a set of Pareto-optimal solutions (called &amp;quot;Pareto Front&amp;quot;), where each of them represents a trade-off between the two objectives.&lt;/p&gt;&#xA;&lt;p&gt;My question is:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;code&gt;Obj1&lt;/code&gt; and &lt;code&gt;Obj2&lt;/code&gt; (which are conflicting) represent a special case where, for example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Obj1 = x1 + x2 + x3&#xA;Obj2 = - (x1 + x2 + x3) + (x4 + x5 + x6)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;so, where &lt;code&gt;Obj2&lt;/code&gt; is equal to the reversed version of &lt;code&gt;Obj1&lt;/code&gt;, plus some other terms,&lt;/p&gt;&#xA;&lt;p&gt;or, if &lt;code&gt;Obj1&lt;/code&gt; and &lt;code&gt;Obj2&lt;/code&gt; represent even a more special case where &lt;code&gt;Obj2&lt;/code&gt; is equal to &lt;code&gt;Obj1&lt;/code&gt; multiplied by &lt;code&gt;-1&lt;/code&gt;, such as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Obj1 = x1 + x2 + x3&#xA;Obj2 = - (x1 + x2 + x3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So, in both cases, the two objectives are linearly dependent.&lt;/p&gt;&#xA;&lt;p&gt;Are these special cases not recommended or problematic (for some reasons which come from Operational Research theory) to be solved as a bi-objective MILP via the &lt;code&gt;Augmented Epsilon-Constraint&lt;/code&gt; Method, or are they ok?&lt;/p&gt;&#xA;&lt;p&gt;PS: In the examples above, for a sake of simplicity, I used two objectives made up of the sum of few variables, while in my case each of them is made up by the sum of many (thousands) terms.&lt;/p&gt;&#xA;" OwnerUserId="4944" LastActivityDate="2021-09-29T12:06:16.683" Title="Bi-Objective MILP with two conflicting (and linear dependent) objectives" Tags="|optimization|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7010" PostTypeId="2" ParentId="7009" CreationDate="2021-09-29T12:06:16.683" Score="5" Body="&lt;p&gt;Your last example, is certainly not that interesting. Let &lt;span class=&quot;math-container&quot;&gt;$f_1(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2(x)$&lt;/span&gt; abe the objective functions. From multi-objective optimization theory it is well known that if we use strictly positive weights for the objectives and solve the corresponding weighted sum scalarization, any optimal solution is efficient. In this case, we choose weight vector &lt;span class=&quot;math-container&quot;&gt;$\lambda=(\tfrac{1}{2},\tfrac{1}{2})$&lt;/span&gt; and get the objective function &lt;span class=&quot;math-container&quot;&gt;$f_\lambda(x)=\tfrac{1}{2}(f_1(x)+f_2(x))=0$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$f_2(x)=-f_1(x)$&lt;/span&gt;. Hence, any feasible solution is efficient which is not very interesting.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-09-29T12:06:16.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7011" PostTypeId="2" ParentId="7005" CreationDate="2021-09-29T16:23:14.987" Score="4" Body="&lt;p&gt;You can find all the necessary theoretical elements (and a lot more) in the book &amp;quot;Convex Analysis&amp;quot; by R. Tyrrell Rockafellar. Fair warning: reading this book is tantamount to a graduate class in convex analysis. I suspect most books on mathematical programming will contain the relevant results, although quite possibly by citing other sources rather than spending the necessary space to develop them from scratch. For instance, the book &amp;quot;Combinatorial Optimization: Algorithms and Complexity&amp;quot; by Papadimitriou and Steiglitz contains a theorem (2.3) that asserts that every convex polytope is the convex hull of its vertices. Rather than including a proof, they cite three sources (including Rockafellar).&lt;/p&gt;&#xA;&lt;p&gt;If you accept that theorem, the part about the optimum being at a vertex is easy. Let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be the polytope, &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; a convex function to be maximized over &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x^*\in P$&lt;/span&gt; any maximizer of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;. By the theorem, we can write &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$$x^*=\sum_{i=1}^n \alpha_i v_i$$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$v_1,\dots,v_n$&lt;/span&gt; are the vertices of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and the &lt;span class=&quot;math-container&quot;&gt;$\alpha_i$&lt;/span&gt; are nonnegative weights such that &lt;span class=&quot;math-container&quot;&gt;$\sum_i \alpha_i = 1$&lt;/span&gt; (using the definition of a convex combination). Since &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is convex, &lt;span class=&quot;math-container&quot;&gt;$$f(x^*)=f(\sum_{i=1}^n \alpha_i v_i)\le \sum_{i=1}^n \alpha_i f(v_i)\le \sum_{i=1}^n \alpha_i f(x^*) = f(x^*),$$&lt;/span&gt;where the last inequality comes from the assumption that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; maximizes &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;. If none of the vertices with positive weight in the sum are maximizers, that inequality becomes strict and you end up with a contradiction. So at least one vertex is a maximizer.&lt;/p&gt;&#xA;&lt;p&gt;In general, that does not preclude also having a maximizer that is not a vertex, but since &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is positive definite (rather than positive semidefinite) in the question, &lt;span class=&quot;math-container&quot;&gt;$f(x)=x^\prime Q x$&lt;/span&gt; is strictly convex, making the first inequality strict (leading to a contradiction) if more than one of the &lt;span class=&quot;math-container&quot;&gt;$\alpha_i$&lt;/span&gt; is positive. If only one of them is positive, it must be 1, and so &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; must be one of the vertices.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-09-29T16:23:14.987" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7012" PostTypeId="2" ParentId="962" CreationDate="2021-09-29T16:40:05.963" Score="4" Body="&lt;p&gt;Here is a workshop that was held today. It was on Machine Learning and Optimization. Link to some speakers and their profiles are provided. Some of their works revolve around that idea.&#xA;&lt;a href=&quot;https://abs.uva.nl/shared/subsites/optimization-for-and-with-machine-learning-optimal/en/events/events/2021/09/machine-learning-for-optimization-workshop.html?origin=fD4yZ6ckTxy8BjO%2FuxWL7A&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://abs.uva.nl/shared/subsites/optimization-for-and-with-machine-learning-optimal/en/events/events/2021/09/machine-learning-for-optimization-workshop.html?origin=fD4yZ6ckTxy8BjO%2FuxWL7A&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="996" LastActivityDate="2021-09-29T16:40:05.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7013" PostTypeId="1" AcceptedAnswerId="7015" CreationDate="2021-09-29T17:36:12.487" Score="4" ViewCount="557" Body="&lt;p&gt;The non-convex multi-objective optimization problem in my case is defined below:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Objective 1: Minimize &lt;span class=&quot;math-container&quot;&gt;$f_1(X_1,X_2)=C_0+C_1(1/X_1)+C_2(X_2/X_1)+C_3X_1+C_4X_2+C_5(X_2^2/X_1)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Objective 2: Minimize &lt;span class=&quot;math-container&quot;&gt;$f_2(X_1,X_2)=D_1X_1+D_2X_2+D_3X_1^2+D_4X_2^2+D_5X_1X_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Objective 3: Minimize &lt;span class=&quot;math-container&quot;&gt;$f_3(X_2)=-E_1X_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 1: &lt;span class=&quot;math-container&quot;&gt;$ 0 \le X_1 \le A_1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 2: &lt;span class=&quot;math-container&quot;&gt;$ 0 \le X_2 \le A_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 3: &lt;span class=&quot;math-container&quot;&gt;$ X_1 + X_2 \le A_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$C_1,C_2,C_3,C_4,C_5,D_1,D_2,D_3,D_4,D_5,E_1,A_1,A_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_3$&lt;/span&gt; are positive constant numbers. &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_2$&lt;/span&gt; are decision variables.&lt;/p&gt;&#xA;&lt;p&gt;I want to linearize the objective functions and solve it using LP or MILP solvers for global optimization of &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_2$&lt;/span&gt;. However, I am not sure what is the best method to linearize. For instance, with separable programming I am facing issues with number of breaking points.&lt;/p&gt;&#xA;&lt;p&gt;Also, I have tried using evolutionary algorithms like MOPSO and NSGA-II for finding global optimum solutions. However, I want to explore if I can reduce the non-linear objective functions to linear and find global optimum solutions with less computation time.&lt;/p&gt;&#xA;" OwnerUserId="5794" LastEditorUserId="5794" LastEditDate="2021-09-29T21:46:19.553" LastActivityDate="2021-09-29T23:21:52.990" Title="How to linearize a non-convex optimization objective function?" Tags="|optimization|linearization|nonlinear-programming|nonconvex-programming|multi-objective-optimization|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="7014" PostTypeId="1" AcceptedAnswerId="7017" CreationDate="2021-09-29T19:45:20.983" Score="2" ViewCount="401" Body="&lt;p&gt;I am trying to solve a multi-objective vehicle routing problem, I want to implement a lexicographic objective function, I have already defined a function for each objective. if someone has an idea of how can implement the lexicographic function. (PS. the code is written in python).&lt;/p&gt;&#xA;" OwnerUserId="5537" LastActivityDate="2021-09-29T23:40:22.747" Title="A lexicographic objective function" Tags="|python|vehicle-routing|multi-objective-optimization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7015" PostTypeId="2" ParentId="7013" CreationDate="2021-09-29T22:16:02.763" Score="3" Body="&lt;p&gt;One traditional method to linearize multi-linear/polynomial constraints are McCormick envelopes,  which are refined over time. &lt;a href=&quot;https://optimization.mccormick.northwestern.edu/index.php/McCormick_envelopes&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here is a great resource on those.&lt;/a&gt; A single objective solver that uses them and improves them in an interesting way is &lt;a href=&quot;https://github.com/lanl-ansi/Alpine.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;Alpine&lt;/a&gt; to get an quick idea whether you could adapt ideas from it for you i would recommend &lt;a href=&quot;https://youtu.be/mwkhiEIS5JA&quot; rel=&quot;nofollow noreferrer&quot;&gt;this 22 minute presentation.&lt;/a&gt; Using McCormick relaxations would require solving a series of multi objective MILP problems. Finding new minimas of the and refining the linear relaxation there. Alpine doesn't support all the terms you have in your problem but lower bounds necessary to construct these envelopes could also be found using interval arithmetic for the division in &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt;, and additive terms &lt;span class=&quot;math-container&quot;&gt;$D_3X_1^2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$D_4X_2^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am not aware of any turn key solutions. One could also write a branch and bound solver which just uses interval arithmetic and handles the linear objective seperatly.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-09-29T23:21:52.990" LastActivityDate="2021-09-29T23:21:52.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7016" PostTypeId="1" CreationDate="2021-09-29T23:06:21.427" Score="-3" ViewCount="56" Body="&lt;p&gt;Please explain how the problem solution looks like. basically I want model to dynamically give me multiple facility locations for a given demand.&lt;/p&gt;&#xA;" OwnerUserId="6126" LastActivityDate="2021-09-29T23:43:26.477" Title="What is dynamic facility location problem ans how to formulate the same? Please help" Tags="|optimization|facility-location|logistics|" AnswerCount="1" CommentCount="0" ClosedDate="2021-09-30T10:11:10.563" ContentLicense="CC BY-SA 4.0" />
  <row Id="7017" PostTypeId="2" ParentId="7014" CreationDate="2021-09-29T23:40:22.747" Score="6" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$f(x)=(f_1(x),f_2(x),\dots,f_n(x))$&lt;/span&gt; be a lexicographic objective function, where &lt;span class=&quot;math-container&quot;&gt;$f_1(x)$&lt;/span&gt; is more important than &lt;span class=&quot;math-container&quot;&gt;$f_2(x)$&lt;/span&gt; which in turn is more important than &lt;span class=&quot;math-container&quot;&gt;$f_3(x)$&lt;/span&gt;, etc. I'll assume you are solving a minimization problem.&#xA;In a mathematical programming solver, such an objective function could be easily implemented as follows. First find the solution &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, subject to &lt;span class=&quot;math-container&quot;&gt;$x\in X$&lt;/span&gt; which scores best on objective &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; (here &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is the set of feasible solutions). Next, find the solution &lt;span class=&quot;math-container&quot;&gt;$x'$&lt;/span&gt; that scores best on objective f_2, subject to &lt;span class=&quot;math-container&quot;&gt;$x'\in X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_1(x')\leq f_1(x)$&lt;/span&gt;. Continue this iterative procedure for every objective function, in descending order of the importance of each objective function.&lt;/p&gt;&#xA;&lt;p&gt;To implement a heuristic with a lexicographic objective function, there exist different solutions.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Assign a weight &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; to each objective function &lt;span class=&quot;math-container&quot;&gt;$i=1,2,\dots,n$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$M_1\gg M_2 \gg \dots \gg M_n$&lt;/span&gt;.You can than solve &lt;span class=&quot;math-container&quot;&gt;$f(x)=M_1f_1(x)+M_2f_2(x)+\dots+M_nf_n(x)$&lt;/span&gt;. In other words, you simply combine all objective functions into a single weighted objective function.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;An example in the context of a vehicle routing problem: &lt;span class=&quot;math-container&quot;&gt;$f_1=$&lt;/span&gt; the total number of vehicles needed, &lt;span class=&quot;math-container&quot;&gt;$f_2=$&lt;/span&gt; total driving distance of the vehicles. You could minimize &lt;span class=&quot;math-container&quot;&gt;$M_1f_1(x)+f_2(x)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$M_1$&lt;/span&gt; is an upper bound on the total driving distance (e.g. the sum of the 2 longest edges out of each customer). Alternatively, if you don't want to mimic an exact lexicographic function, you could simply set &lt;span class=&quot;math-container&quot;&gt;$M_i=2^{n-i}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$M_i=10^{n-i}$&lt;/span&gt;.&#xA;Note that this kind of objective function has a major disadvantage: many common heuristics, including for instance Simulated Annealing, perform a lot better if the objective function is smooth, i.e. minor changes in the solution result in minor changes in the objective. With this multi-objective approach, a minor change in the solution might incur a big change in the objective function due to the different weights.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Another approach is to implement the Lexicographic property directly into your heuristic: first search for a solution &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; which scores best on &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt;. Next, search for the solution &lt;span class=&quot;math-container&quot;&gt;$x'$&lt;/span&gt; which scores best on &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt;, while only accepting moves to solutions that have the same score on &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;It is likely that this approach will get you stuck in a local optima quickly.&lt;/p&gt;&#xA;&lt;p&gt;References to other approaches can be found in &lt;a href=&quot;http://synergy-twinning.eu/files/synergy-2016-170104-1440.pdf&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; slide deck.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-09-29T23:40:22.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7018" PostTypeId="2" ParentId="7016" CreationDate="2021-09-29T23:43:26.477" Score="4" Body="&lt;p&gt;I am not a search engine, if you would search for &amp;quot;dynamic facility location problem&amp;quot; you would for example find &lt;a href=&quot;https://www.researchgate.net/publication/227149037_Dynamic_Facility_Location_Problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;this book&lt;/a&gt; for free. Chapter 15 covers multiple formulations from the literature and describes them.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-09-29T23:43:26.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7019" PostTypeId="1" AcceptedAnswerId="7022" CreationDate="2021-09-30T06:05:50.217" Score="5" ViewCount="727" Body="&lt;p&gt;I am looking for an optimization algorithm to minimize the cost of transportation and storage cost in warehouse.&lt;/p&gt;&#xA;&lt;p&gt;Let's assume the following table gives us the weekly forecast of Demand.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+&#xA;|              | Week 1  | Week 2  | Week 3  | Week 4  | Week 5  | Week 6  | Week 7  | Week 8  | Week 9  | Week 10 | Week 11 | Week 12 |&#xA;+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+&#xA;| Demand       |  2,300  |  1,800  |  1,100  |  2,300  |  2,000  |  1,600  |  2,200  |  2,000  |  2,900  |  1,900  |  2,000  |   1,000 |&#xA;| Buffer       |    600  |    500  |    300  |    600  |    500  |    400  |    600  |    500  |    800  |    500  |    500  |     300 |&#xA;| Total Demand |  2,900  |  2,300  |  1,400  |  2,900  |  2,500  |  2,000  |  2,800  |  2,500  |  3,700  |  2,400  |  2,500  |   1,300 |&#xA;+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The transportation cost follows the below mentioned price buckets given the ordered amount of units.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;+---------------+----------------------+&#xA;|     Units     | Delivery Cost / Unit |&#xA;+---------------+----------------------+&#xA;| Less than 500 |                   50 |&#xA;| 500 - 1000    |                   40 |&#xA;| 1000 - 1500   |                   35 |&#xA;| 1500 - 2000   |                   30 |&#xA;| 2000 - 2500   |                   25 |&#xA;| 2500 - 3000   |                   20 |&#xA;| 3000 above    |                   15 |&#xA;+---------------+----------------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There is fixed 30$ storage cost to maintain inventory in warehouse. Time for delivery of stock from order point is 5 days. So we need to order 5 days prior if a certain quantity is required today.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for an algorithm that would help minimize the total cost while meeting the demand for each week. Also the order point should be provided.&lt;/p&gt;&#xA;&lt;p&gt;Primarily, I am looking for readings or tutorial that would help understand how to solve such a problem. It would be great if someone can help with this particular example.&lt;/p&gt;&#xA;" OwnerUserId="3853" LastEditorUserId="-1" LastEditDate="2021-10-01T06:42:02.440" LastActivityDate="2021-10-04T18:11:07.913" Title="Minimizing cost of transportation and storage of items" Tags="|python|scheduling|inventory|reduced-costs|production-planning|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7021" PostTypeId="1" CreationDate="2021-09-30T12:01:50.970" Score="1" ViewCount="85" Body="&lt;p&gt;I want to formulate a game of darts as a dynamic program again. This question is closely related to my previous &lt;a href=&quot;https://or.stackexchange.com/questions/6934/circular-reference-in-states-of-the-bellman-equation&quot;&gt;post&lt;/a&gt; where I wanted to minimize the number of throws to reach checkout.&#xA;Now the goal is to minimize the number of turns.&lt;/p&gt;&#xA;&lt;p&gt;A turn consists of three darts. Each dart is used unless you win by checkout, or go bust in which case you revert to the score before the turn started. A state can be described as &lt;em&gt;(s, i, u)&lt;/em&gt; where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;s&lt;/em&gt; is the score at the beginning of the turn&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;i&lt;/em&gt; ∈ {1, 2, 3} is the number of throws remaining in the turn&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;u&lt;/em&gt; is the score within the turn&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In addition, we have &lt;em&gt;z&lt;/em&gt; that represents the outcome of the dart throw.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;z ∈ {Miss, S1, S2, S3, ..., D1, D2, D3, ..., T1, T2, T3, SB, DB}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Each &lt;em&gt;z&lt;/em&gt; represents a numerical score. For example,  &lt;em&gt;h(T20) = 60&lt;/em&gt;. We assume that a player can aim at sixty specified points on the dartboard. The aiming location is defined as &lt;em&gt;µ&lt;/em&gt;. If &lt;em&gt;µ = D1&lt;/em&gt; then the player aims at the center point of the &lt;em&gt;D1&lt;/em&gt; region. However, when the player aims at &lt;em&gt;D1&lt;/em&gt;, there is also a possibility that the dart ends up in the &lt;em&gt;S1&lt;/em&gt;. This probability is defined as &lt;em&gt;p(S1; D1)&lt;/em&gt;.&#xA;Logically, each throw results in a value for &lt;em&gt;z&lt;/em&gt;. Hence,&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8NVm5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8NVm5.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;em&gt;i = 3&lt;/em&gt;, there are three darts to be throwed. Hence &lt;em&gt;u = 0.&lt;/em&gt; The state transition now satisfies (s*, i*, u*) = f((s, i, u), z) where&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4C0J2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4C0J2.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The Bellman equation is defined as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YqGHC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YqGHC.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;With &lt;em&gt;V(0,i,u) :=0&lt;/em&gt; for any &lt;em&gt;i&lt;/em&gt;, &lt;em&gt;u&lt;/em&gt;. A turn is counted only when the turn has been completed. This is the case when there is a checkout, bust or the third dart is thrown.&#xA;There is a monotonic structure so we can solve the recursively by considering states in increasing order like &lt;em&gt;V(2,i,u), V(3,i,u), …, V(501,i ,u)&lt;/em&gt;. All of the above can be found on page 13 and 14 of the following &lt;a href=&quot;https://www.researchgate.net/publication/346143239_Play_Like_the_Pros_Solving_the_Game_of_Darts_as_a_Dynamic_Zero-Sum_Game&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let’s say that &lt;em&gt;s = 2&lt;/em&gt;. If &lt;em&gt;s = 2&lt;/em&gt;, &lt;em&gt;u&lt;/em&gt; is always equal to 0, otherwise there would be a bust. Do we start with calculating &lt;em&gt;V(2,3,0)&lt;/em&gt; or &lt;em&gt;V(2,1,0)&lt;/em&gt;? So, do we solve the states in increasing or decreasing order of &lt;em&gt;i&lt;/em&gt;?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;V(2,3,0)&lt;/strong&gt;&#xA;I believe there are three possibilities:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;checkout; throw &lt;em&gt;z = D1&lt;/em&gt; -&amp;gt; &lt;em&gt;V(0,3,0)&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;miss; throw &lt;em&gt;z = miss&lt;/em&gt; -&amp;gt; &lt;em&gt;V(2,2,0)&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;bust; throw anything other than D1 and miss -&amp;gt; &lt;em&gt;V(2,3,0)&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If we insert this in the Bellman equation, we get the following:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;V(2,3,0) = [1 + V(0,3,0)] p(D1;µ) + [0 + V(2,2,0)] p(miss;µ) + [1 +&#xA;V(2,3,0)] (1 – p(D1;µ) – p(miss;µ))&lt;/p&gt;&#xA;&lt;p&gt;V(2,3,0) = p(D1;µ) +  p(miss;µ)V(2,2,0) + 1 – p(D1;µ) – p(miss;µ) +&#xA;V(2,3,0) – p(D1;µ)V(2,3,0) – p(miss;µ)V(2,3,0)&lt;/p&gt;&#xA;&lt;p&gt;V(2,3,0) = p(miss;µ)V(2,2,0) + 1 – p(miss;µ) + V(2,3,0) –&#xA;p(D1;µ)V(2,3,0) – p(miss;µ)V(2,3,0)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;V(2,1,0)&lt;/strong&gt;&#xA;If we should start with &lt;em&gt;i = 1&lt;/em&gt; then the possible outcomes lead to the following states:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;checkout; throw &lt;em&gt;z = D1&lt;/em&gt; -&amp;gt; &lt;em&gt;V(0,3,0)&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;miss; throw &lt;em&gt;z = miss&lt;/em&gt; -&amp;gt; &lt;em&gt;V(2,3,0)&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;bust; throw anything other than D1 and miss -&amp;gt; &lt;em&gt;V(2,3,0)&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Inserting this, gives:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;V(2,1,0) = [1 + V(0,3,0)] p(D1;µ) + [1 + V(2,3,0)] (1 – p(D1;µ))&lt;/p&gt;&#xA;&lt;p&gt;V(2,1,0) = p(D1;µ) + 1 – p(D1;µ) + V(2,3,0) – p(D1;µ)V(2,3,0)&lt;/p&gt;&#xA;&lt;p&gt;V(2,1,0) + p(D1;µ)V(2,3,0) = 1 + V(2,3,0)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Both value functions have an unknown term. Please show me where I should start / how I save the Bellman equation for &lt;em&gt;s = 2&lt;/em&gt;. Thanks&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Updated&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I calculated &lt;strong&gt;V(2,2,0)&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;V(2,2,0) = [1 + V(0,3,0)] p(D1;µ) + [0 + V(2,1,0)] p(miss;µ) + [1 +&#xA;V(2,3,0)] (1 – p(D1;µ) – p(miss;µ))&lt;/p&gt;&#xA;&lt;p&gt;V(2,2,0) = p(D1;µ) + p(miss;µ)V(2,1,0) + 1 – p(D1;µ) – p(miss;µ) +&#xA;V(2,3,0) – p(D1;µ)V(2,3,0) – p(miss;µ)V(2,3,0)&lt;/p&gt;&#xA;&lt;p&gt;V(2,2,0) = p(miss;µ)V(2,1,0) + 1– p(miss;µ) + V(2,3,0) –&#xA;p(D1;µ)V(2,3,0) – p(miss;µ)V(2,3,0)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6138" LastEditorUserId="6138" LastEditDate="2021-09-30T14:35:55.513" LastActivityDate="2021-09-30T14:35:55.513" Title="Bellman equation for darts that minimizes the number of turns" Tags="|optimization|dynamic-programming|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7022" PostTypeId="2" ParentId="7019" CreationDate="2021-09-30T12:18:15.187" Score="5" Body="&lt;p&gt;I won't write a python solution as i am not familiar with any python modeling language but i can describe the approach i took in the past to solve problems like this.&lt;/p&gt;&#xA;&lt;p&gt;I would solve this problem using a technique of finite horizon optimal control where we have an &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; a state vector for each time point, a control signal &lt;span class=&quot;math-container&quot;&gt;$u_t$&lt;/span&gt;, a prediction &lt;span class=&quot;math-container&quot;&gt;$p_t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The core of idea is that you define a transition function which defines &lt;span class=&quot;math-container&quot;&gt;$x_t = f_t(x_{t-1},x_{t-2}, ... ,x_{0},u_{t-1},u_{t-2}, ... ,u_{0}, p_t, p_{t+1}, ... , p_{t+h})$&lt;/span&gt; depending on past state, past controls and future predictions of demand and those as constraint of your model the time interval your model runs over. Futhermore you define constraints involving the predictions &lt;span class=&quot;math-container&quot;&gt;$p_t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$u_t$&lt;/span&gt; that ensure you always have enough stock. You define your objective in terms of &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u_t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The idea is that on day &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; you run a the model with updated predictions, the 5 past &lt;span class=&quot;math-container&quot;&gt;$u_{\tau-1}, u_{\tau-2}, u_{\tau-3}, u_{\tau-4}, u_{\tau-5}$&lt;/span&gt; as you ordered and they will arrive, &lt;span class=&quot;math-container&quot;&gt;$x_{\tau-1}, x_{\tau-2}, x_{\tau-3}, x_{\tau-4}, x_{\tau-5}$&lt;/span&gt; as the historic stock levels and &lt;span class=&quot;math-container&quot;&gt;$p_t, ..., p_{t+h}$&lt;/span&gt; as predict the demand on these days, you leave &lt;span class=&quot;math-container&quot;&gt;$x_{\tau}, ... x_{\tau + h}$&lt;/span&gt; as free variables, constraint by transition function and leave &lt;span class=&quot;math-container&quot;&gt;$u_\tau, ... , u_{\tau + h}$&lt;/span&gt; as free variables where &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; is the length of time horizon. The choice of &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; is a trade off between model performance and amount of computation. After running the model you get an &lt;span class=&quot;math-container&quot;&gt;$u_\tau$&lt;/span&gt; and you order that many. The next day you rerun the model with updated predictions and one day further.&lt;/p&gt;&#xA;&lt;p&gt;In your case the transition constraint would look like &lt;span class=&quot;math-container&quot;&gt;$x_{t} = x_{t-1} + u_{t-5} -p_{t-1}$&lt;/span&gt;. The stock level of the next day is the stock level of the previous day plus what you order 5 days ago minus that you expect to sell. You in addition can pose a contraint how much buffer you want atleast for each &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The objective would be a sum of a piece wise function applied to how much was order plus storage costs. There is a lot of research how you can express piecewise function as mixed integer problems but some of them are about continous functions which yours is not.&lt;/p&gt;&#xA;&lt;p&gt;It think you could express this problem completly in the language of Mixed Integer Linear Programming. I hope this gave you an idea how to approach it.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-09-30T12:24:53.127" LastActivityDate="2021-09-30T12:24:53.127" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7023" PostTypeId="1" CreationDate="2021-09-30T15:25:12.010" Score="2" ViewCount="265" Body="&lt;p&gt;I am solving an OR scheduling problem where I assign the patient to (day,OR) tuple in Master Problem. Once the assignment is made, a subproblem can be solved for each (day,OR) tuple independently where patients are assigned to a time slot t. A cost of idle time/overtime is incurred.&lt;/p&gt;&#xA;&lt;p&gt;Master problem is given by&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Z_{MP} = \min \sum_{d=1}^{\delta} \sum_{k=1}^{K} [c^k Q_{dk} + \theta_{dk}] $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{N} X_{idk} \leq  Q_{dk}, \quad \forall  d \in \mathbb{D},   k \in \mathbb{K}, $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ Q_{dk} \geq Q_{dk'}, \quad \forall k, k' \in \mathbb{K}, k' &amp;gt; k,   d \in \mathbb{D},$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{d=1}^{\delta} \sum_{k=1}^{K} X_{idk} = 1 \hspace{1in} \forall i \in \mathbb{N}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{Combinatorial benders cuts} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$X_{idk} \in \{0,1\}, Q_{dk} \in \{0,1\}, \theta_{dk} \geq 0$$&lt;/span&gt;&#xA;Where Q determines whether OR is opened or not, while X is the assignment variable. Solving this problem gives me as set of surgeries for each &lt;span class=&quot;math-container&quot;&gt;$\mathbb{N}_{dk}$&lt;/span&gt; for which subproblem is solved.&#xA;The assignment in the master problem changes the structure of my subproblem. That is, it is possible to have 2 surgeries assigned to (day1, OR1) in one iteration while it could be 4 in the next iteration.&#xA;The cut added is of the form where &lt;span class=&quot;math-container&quot;&gt;$Z^{SP}_{dk}$&lt;/span&gt; is cost of subproblem for (d,k).&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{dk} \geq Z^{SP}_{dk} - (Z^{SP}_{dk} - L) (\sum_{i: X^*_{idk} = 0} X_{idk} + \sum_{i: X^*_{idk}=1} (1-X_{idk}) )&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Using this form, I add a cut for each (day = d,OR=k) tuple, if &lt;span class=&quot;math-container&quot;&gt;$\theta_{dk} &amp;lt; Z^{SP}_{dk}$&lt;/span&gt;&#xA;This cut essentially ensures that the solution is not repeated or the solution that is found is at least &amp;gt;= L (Lower Bound). The subproblem has the cost of idle time, overtime, and a cost of starting surgery &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in a particular timeslot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; i.e. &lt;span class=&quot;math-container&quot;&gt;$C_{idtk}$&lt;/span&gt;. Also must be noted that adding surgery for  (day p, OR q) another (day r,OR s) may reduce the cost of the (r,s) depending on the comparison of idle time cost vs &lt;span class=&quot;math-container&quot;&gt;$C_{it}$&lt;/span&gt; parameter. The convergence is too slow and some additional strengthening cuts do not work which are discussed &lt;a href=&quot;https://or.stackexchange.com/questions/6716/benders-decomposition-cuts-for-milp-problem-with-further-separable-subproblems&quot;&gt;Benders Decomposition cuts for MILP problem with further separable subproblems&lt;/a&gt; How can this be improved.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It is ensured in the master problem that surgeries assigned to (day, OR) do not exceed the capacity of OR. Is it beneficial to let the master problem find infeasible solutions for its subproblems and then add a feasibility cut of the above form? Does that help with the convergence?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3520" LastEditorUserId="67" LastEditDate="2021-09-30T17:38:59.967" LastActivityDate="2021-09-30T17:38:59.967" Title="About combinatorial Benders Cuts" Tags="|mixed-integer-programming|integer-programming|combinatorial-optimization|binary-variable|benders-decomposition|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7024" PostTypeId="2" ParentId="7019" CreationDate="2021-09-30T16:01:26.507" Score="6" Body="&lt;p&gt;I would approach this as a mixed integer linear programming (MILP) problem. There are a number of MILP solvers, some open source, some commercial (with some of the commercial solvers providing free licenses for educational use). Many of them either have a Python API or can be used with PuLP (mentioned in comment to the selected answer).&lt;/p&gt;&#xA;&lt;p&gt;You might want to search the web for references to integer programming models that involve &amp;quot;all units discounts&amp;quot;, which describes your delivery costs. All units discounts frequently occur in the context of order costs rather than shipping costs, but the method of modeling them would be easily transferable.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-09-30T16:01:26.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7025" PostTypeId="1" CreationDate="2021-09-30T22:01:57.240" Score="-1" ViewCount="505" Body="&lt;p&gt;Please in PSO metaheuristic when we calculate the velocity what is the advantage of using pBest?&lt;a href=&quot;https://i.stack.imgur.com/JHw3W.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JHw3W.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7281" LastEditorUserId="7281" LastEditDate="2021-09-30T22:17:54.927" LastActivityDate="2021-09-30T22:17:54.927" Title="How to interpret velocity computation in Particle Swarm Optimization?" Tags="|combinatorial-optimization|metaheuristics|genetic-algorithm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7026" PostTypeId="2" ParentId="7025" CreationDate="2021-09-30T22:09:57.907" Score="0" Body="&lt;p&gt;In PSO, you maintain a population of candidate solutions. Each candidate solution is referred to as a 'particle'. Particles move around in the search-space based on the formula you defined. A single particle's movement depends on its position and velocity. More precisely, each particle's movement is influenced by its local best known position, but is also guided toward the best known positions in the search-space, which are updated as better positions are found by other particles. This is expected to move the swarm toward the best solutions. (source: &lt;a href=&quot;https://en.wikipedia.org/wiki/Particle_swarm_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;wiki&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-09-30T22:09:57.907" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7029" PostTypeId="5" CreationDate="2021-10-01T19:03:13.547" Score="0" Body="&lt;p&gt;These two methods are the Pareto and scalarization. In the Pareto method, there is a dominated solution and a non-dominated solution obtained by a continuously updated algorithm. Meanwhile, the scalarization method creates multi-objective functions made into a single solution using weights.&lt;/p&gt;&#xA;&lt;p&gt;Multi-objective optimization has been applied in many fields of science, including engineering, economics and logistics where optimal decisions need to be taken in the presence of trade-offs between two or more conflicting objectives. Minimizing cost while maximizing comfort while buying a car, and maximizing performance whilst minimizing fuel consumption and emission of pollutants of a vehicle are examples of multi-objective optimization problems involving two and three objectives, respectively. In practical problems, there can be more than three objectives.&lt;/p&gt;&#xA;&lt;p&gt;For a nontrivial multi-objective optimization problem, no single solution exists that simultaneously optimizes each objective. In that case, the objective functions are said to be conflicting, and there exists a (possibly infinite) number of Pareto optimal solutions. A solution is called nondominated, Pareto optimal, Pareto efficient or noninferior, if none of the objective functions can be improved in value without degrading some of the other objective values. Without additional subjective preference information, all Pareto optimal solutions are considered equally good. Researchers study multi-objective optimization problems from different viewpoints and, thus, there exist different solution philosophies and goals when setting and solving them. The goal may be to find a representative set of Pareto optimal solutions, and/or quantify the trade-offs in satisfying the different objectives, and/or finding a single solution that satisfies the subjective preferences of a human decision maker (DM).&lt;/p&gt;&#xA;" OwnerUserId="2579" LastEditorUserId="2579" LastEditDate="2021-10-02T03:13:49.560" LastActivityDate="2021-10-02T03:13:49.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7030" PostTypeId="4" CreationDate="2021-10-01T19:03:13.547" Score="0" Body="Multi-objective optimization is an area of multiple criteria decision making that is concerned with mathematical optimization problems involving more than one objective function to be optimized simultaneously. Involve two or more optimization goals that are conflicting, meaning that improvement to one objective comes at the expense of another objective. The two methods for perform a multi-objetive-optimization are Pareto and scalarization." OwnerUserId="2579" LastEditorUserId="2579" LastEditDate="2021-10-02T03:13:57.590" LastActivityDate="2021-10-02T03:13:57.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7032" PostTypeId="2" ParentId="7019" CreationDate="2021-10-04T18:11:07.913" Score="1" Body="&lt;p&gt;Depending on what your decision variables are you are looking at an integer, mixed integer, or mixed integer linear programming problem.&#xA;It seems to me that you want to solve it using a Python model. If that is the case, you can look at Pyomo or PuLP systems if you're looking for open-source solvers.&lt;/p&gt;&#xA;" OwnerUserId="996" LastActivityDate="2021-10-04T18:11:07.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7033" PostTypeId="1" CreationDate="2021-10-05T11:58:26.387" Score="2" ViewCount="37" Body="&lt;p&gt;I am struggling with the understanding of the (quite famous) paper on lexicographical flows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Maximal, Lexicographic, and Dynamic Network Flows - by Edward Minieka&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The definition of the problem seems really similar to a multi-commodity flow problem. Specifically, instead of the demands constraint, there seems to be a more general (and permissive) one.&lt;/p&gt;&#xA;&lt;p&gt;I can't really get how the multi-commodity flow problem is NP-complete, while formulation by Minieka is polynomially solvable.&lt;/p&gt;&#xA;&lt;p&gt;I feel like I am missing something on the purpose of this paper. What does it mean with &amp;quot;departure pattern&amp;quot;. Can't I, indeed, always find such a &amp;quot;pattern&amp;quot; within multi-commodity formulation? Doesn't this make any multi-commodity flow problem polynomially solvable?&lt;/p&gt;&#xA;&lt;p&gt;I am sorry if my question is a bit confusing, but the world of network problems is huge and it's really hard for me to keep it rigor.&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="5523" LastEditDate="2021-10-05T12:16:36.767" LastActivityDate="2021-10-05T12:16:36.767" Title="Lexicographic flow property and consequences" Tags="|network-flow|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7034" PostTypeId="2" ParentId="4170" CreationDate="2021-10-05T17:40:06.010" Score="2" Body="&lt;p&gt;As a veteran MATLAB user, I'm horrified by some of the conventions the developers of Python chose to use. There are some inconsistencies in array notation that are very troubling. They decided to defy convention used in many other programming languages, including MATLAB, C, FORTRAN, Julia, etc. Matrix manipulation is extremely difficult and prone to error in Python. Yeah, it's free, but if it takes you a long time to try to build something that works, what good is that? There's a free MATLAB alternative in Octave, which everyone conveniently forgets, too. MATLAB is a natural language for matrix manipulation, which is crucial in every field. Practically all of the applications that Python claims to have were already developed in MATLAB.&lt;/p&gt;&#xA;" OwnerUserId="7300" LastActivityDate="2021-10-05T17:40:06.010" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7035" PostTypeId="1" CreationDate="2021-10-05T19:11:36.363" Score="2" ViewCount="572" Body="&lt;p&gt;I have a MILP but fixed the objective function, so at each iteration is constant.Therefore, I solve a constraint satisfaction problem.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there an algorithm to solve this kind of problem fast? I have a&#xA;continuous variable, two inequalities and two equalities.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;And more importantly, can I get the dual of my constraints?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;(I used AMPL so if someone knows a good solver or resource there it would be highly appreciated).&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="7200" LastEditDate="2021-10-05T19:28:12.607" LastActivityDate="2021-10-06T15:48:34.230" Title="Best way to solve a optimization problem with no objective function?" Tags="|linear-programming|solver|algorithms|terminology|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7036" PostTypeId="2" ParentId="7035" CreationDate="2021-10-05T20:42:36.503" Score="2" Body="&lt;p&gt;MILP with a fixed objective function is hard as finding a feasible solution. Since this can still encode n-queens completion or SAT it is still in the same complexity class.&lt;/p&gt;&#xA;&lt;p&gt;Depending on your problem &lt;a href=&quot;https://www.youtube.com/watch?v=V9LffQMyeJk&quot; rel=&quot;nofollow noreferrer&quot;&gt;some MILP heuristic&lt;/a&gt; might find a solution. Constraint satisfaction programming might be fast but it could be that encoding it into sat or pseudo boolean form for the integer part only then try to find a solution for the continuous variable in a tiny linear program and if no such solution can be found learn a new constraint on the integers using &lt;a href=&quot;https://en.wikipedia.org/wiki/Farkas%27_lemma&quot; rel=&quot;nofollow noreferrer&quot;&gt;Farkas' Lemma&lt;/a&gt; could work. A penalty method could also work well as could evolutionary algorithms. There is no approach that beats all others.&lt;/p&gt;&#xA;&lt;p&gt;Nothing prevents you from getting a dual of the linear relaxation of MILP problem. In how far that relaxation is strong depends on your problem but a sufficient number of (Gomory/Lift-and-project) cuts can cut of all non-integer vertices of the polytope. See &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2007/01/1569.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Duality of Mixed Integer Programs&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-10-05T23:40:30.713" LastActivityDate="2021-10-05T23:40:30.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7037" PostTypeId="1" CreationDate="2021-10-06T01:50:34.997" Score="1" ViewCount="62" Body="&lt;p&gt;Based on Markov chain context, we say a stochastic process is Markovian if the state at time &lt;span class=&quot;math-container&quot;&gt;$t+1$&lt;/span&gt;,  &lt;span class=&quot;math-container&quot;&gt;$S_{t+1}$&lt;/span&gt; just depends on the state in the previous step, that is, &lt;span class=&quot;math-container&quot;&gt;$\Pr\left( S_{t+1}|S_1, S_2, \cdots, S_t \right)= \Pr\left( S_{t+1}|S_t \right)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now consider a dynamic program where we need to store all historical data up to time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$\mathcal{H}_t$&lt;/span&gt;) as our State variable, that is, &lt;span class=&quot;math-container&quot;&gt;$S_t=\mathcal{H_t}$&lt;/span&gt;. Now, suppose that at time &lt;span class=&quot;math-container&quot;&gt;$t+1$&lt;/span&gt; a new data like &lt;span class=&quot;math-container&quot;&gt;$(t+1, a_{t+1})$&lt;/span&gt; is observed and the historical data is updated as &lt;span class=&quot;math-container&quot;&gt;$\mathcal{H}_{t+1}=\mathcal{H}_t \cup \{(t+1, a_{t+1}) \}$&lt;/span&gt; and so &lt;span class=&quot;math-container&quot;&gt;$S_{t+1}= \mathcal{H}_{t+1}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In this case, we could write the state of the problem based on the state of the previous period but we still need to store all historical data. I am wondering if this problem can be considered as a Markovian model?&lt;/p&gt;&#xA;&lt;p&gt;In the former case, suppose we extend our problem to a continuous-time case. How is it possible to write the state transition formula? Actually, new data are added based on a new Poisson process. So, the time between two new pieces of data follows an exponential distribution.&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2021-10-06T01:50:34.997" Title="How to check if the state of a dynamic program is Markovian or not?" Tags="|dynamic-programming|markov-decision-process|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7039" PostTypeId="1" CreationDate="2021-10-06T10:11:29.803" Score="1" ViewCount="400" Body="&lt;p&gt;I am reading about &lt;a href=&quot;https://en.wikipedia.org/wiki/Job-shop_scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Job-shop_scheduling&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Optimal_job_scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Optimal_job_scheduling&lt;/a&gt;. Such scheduling is possible if we know the number (amount) of operations (intensity of operations). But what about the following situation: operation A receives A1, A2 amount of materials 1 and 2 and outputs AO3, AO4 amount of materials 3 and 4. Operation B recieves B1, B3 amount of materials 1 and 3 and outputs BO5 amount of material 5.&lt;/p&gt;&#xA;&lt;p&gt;How we can incorporate in the job-shop scheduling problem the constraint, that the intensity of operation B depends on the availability of material 3 and hence the intensity of operation B is determined by the intensity of operation A which itself is dependent on the availability of materials 1, 2, the availability of respective machine and staff for operation A. And, of course, the inventory of materil 3 can also be available but with the respective costs.&lt;/p&gt;&#xA;&lt;p&gt;What is the name (term, keyword) for general job-shop scheduling problem that incorporates the flow of materials as well?&lt;/p&gt;&#xA;" OwnerUserId="7302" LastActivityDate="2021-10-06T15:59:02.857" Title="How to include material flow in job shop scheduling problem (as constraint?)?" Tags="|scheduling|network-flow|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7040" PostTypeId="1" AcceptedAnswerId="7043" CreationDate="2021-10-06T11:25:03.163" Score="3" ViewCount="506" Body="&lt;p&gt;Within paper &lt;code&gt;ON THE COMPLEXITY OF TIMETABLE AND MULTI-COMMODITY FLOW PROBLEMS&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;there's a proof that the multi-commodity is NP-hard.&lt;/p&gt;&#xA;&lt;p&gt;While in &lt;code&gt;Multicommodity flows over time: Efficient algorithms and complexity&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;authors states that &amp;quot;[...] the only known polynomial-time algorithms for static multicommodity flow computations require general linear programming techniques&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;They use word &amp;quot;static&amp;quot; only to differ from its time-dependent version. But I think it is the same problem considered in the first paper.&#xA;Authors also refer to its complexity with the wording &amp;quot;poly(&lt;span class=&quot;math-container&quot;&gt;$\simeq$&lt;/span&gt;LP)&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Can someone help me understand the right way of reading this apparent contradiction?&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="5523" LastEditDate="2021-10-06T13:34:43.943" LastActivityDate="2021-10-06T13:34:43.943" Title="Is Multicommodity Flow problem really NP-hard?" Tags="|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7042" PostTypeId="2" ParentId="5806" CreationDate="2021-10-06T11:53:58.083" Score="2" Body="&lt;p&gt;These should help:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;In the &lt;a href=&quot;https://www.optaplanner.org/learn/documentation.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner documentation&lt;/a&gt;, section 2.4 is a specific &lt;strong&gt;Quick Start guide for Spring Boot&lt;/strong&gt;. But if you're new to Spring, why not learn &lt;a href=&quot;https://quarkus.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quarkus&lt;/a&gt; instead, which is faster and supports native compilation?&lt;/li&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://github.com/kiegroup/optaplanner-quickstarts&quot; rel=&quot;nofollow noreferrer&quot;&gt;optaplanner-quickstarts&lt;/a&gt; repository has &lt;a href=&quot;https://github.com/kiegroup/optaplanner-quickstarts/tree/stable/technology/java-spring-boot&quot; rel=&quot;nofollow noreferrer&quot;&gt;one Spring Boot example&lt;/a&gt; and &lt;a href=&quot;https://github.com/kiegroup/optaplanner-quickstarts/tree/stable/use-cases&quot; rel=&quot;nofollow noreferrer&quot;&gt;several Quarkus examples&lt;/a&gt;. Just git clone that repo or &lt;a href=&quot;https://github.com/kiegroup/optaplanner-quickstarts/archive/refs/heads/stable.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;download it&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-10-06T11:53:58.083" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7043" PostTypeId="2" ParentId="7040" CreationDate="2021-10-06T12:04:16.720" Score="4" Body="&lt;p&gt;&amp;quot;ON THE COMPLEXITY OF TIMETABLE AND MULTI-COMMODITY FLOW PROBLEMS&amp;quot; talks about integral flow while &amp;quot;Multicommodity flows over time: Efficient algorithms and complexity&amp;quot; does not. The integrality constraint (flows being integer valued) is important see LP vs ILP.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-10-06T12:04:16.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7044" PostTypeId="1" CreationDate="2021-10-06T13:53:59.933" Score="1" ViewCount="29" Body="&lt;p&gt;I can't get the difference between this two problems, which seem equal to me.&lt;/p&gt;&#xA;&lt;p&gt;But, for the former, a polynomial solver is known, while, for the latter, it is not.&lt;/p&gt;&#xA;&lt;p&gt;EDIT - References:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;The quickest transhipment problem - by B. Hoppe and E. Tardos&#xA;The quickest multicommodity flow problem - by L. Fleischer and M. Skutella&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In the former paper, which has polynomial solution, authors explicitly refer to integral flows.&#xA;While in the latter one, authors state that &amp;quot;the complexity of the quickest multicommodity flow problem is still open. It has neither been proved to be NP-hard nor is it known to be solvable in polynomial time&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="5523" LastEditDate="2021-10-06T14:17:28.960" LastActivityDate="2021-10-06T14:17:28.960" Title="Is there a difference between &quot;Integral Quickest Transshipment&quot; and &quot;Integral Quickest Multicommodity flow&quot;?" Tags="|network-flow|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7045" PostTypeId="2" ParentId="7039" CreationDate="2021-10-06T14:25:14.150" Score="4" Body="&lt;p&gt;What you are looking for sounds like, combining the job-shop scheduling problem with material requirement planning or Multi-Periods Job-Shop Scheduling Problem. I am not aware how you would like to use that in the paper or real situation, but in the second one, applying mixed-integer programming (without boosting from the special algorithm like column generation) would be challenging work. Some useful references are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://tel.archives-ouvertes.fr/tel-01665198/document&quot; rel=&quot;nofollow noreferrer&quot;&gt;Complex Job-Shop Scheduling with Batching in Semiconductor Manufacturing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.researchgate.net/publication/261592346_Batch_splitting_method_for_a_job_shop_scheduling_problem_in_an_MRP_environment&quot; rel=&quot;nofollow noreferrer&quot;&gt;Batch splitting method for a job shop scheduling problem in an MRP environment&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://perso.isima.fr/%7Ejofontan/JSSP/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multi-Periods Job-Shop Scheduling Problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-10-06T14:25:14.150" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7046" PostTypeId="2" ParentId="7035" CreationDate="2021-10-06T15:48:34.230" Score="2" Body="&lt;p&gt;The question is a bit confusing, in that you say you have a MILP, mention a continuous variable but nothing about integer variables, and then ask about the dual solution (which exists for a continuous model but not for an integer model, at least not in the usual sense of &amp;quot;dual&amp;quot;).&lt;/p&gt;&#xA;&lt;p&gt;Assuming that we are talking about a linear program with the objective function fixed at 0, the dual problem will automatically have the all-zeroes solution be optimal. (It may not be the unique optimum, but it will definitely be optimal.) So the dual solution is trivial to get but likely useless.&lt;/p&gt;&#xA;&lt;p&gt;Here's a quick proof of my assertion. Assume that the primal problem is an LP of the form &lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\min_{x}0\\&#xA;\textrm{s.t. }Ax &amp;amp; \ge b\\&#xA;x &amp;amp; \ge0,&#xA;\end{align*}&lt;/span&gt;noting that equality constraints can always be rewritten as pairs of inequalities. The dual problem is&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\max_{y}b^{\prime}y\\&#xA;\textrm{s.t. }A^{\prime}y &amp;amp; \le0\\&#xA;y &amp;amp; \ge0.&#xA;\end{align*}&lt;/span&gt;&#xA;Clearly &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt; is feasible in the dual, with objective value 0, which equals the optimal value of the primal. So by weak duality, &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt; is optimal in the dual.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-06T15:48:34.230" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7047" PostTypeId="2" ParentId="7039" CreationDate="2021-10-06T15:59:02.857" Score="5" Body="&lt;p&gt;The general approach, whether you are using a mixed integer linear programming model or a constraint programming model, would be to have (nonnegative) variables representing the inventory of different materials at different times, plus flow constraints saying that the inventory at the end of each period is the starting inventory plus any production of the material minus any consumption of the material.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-06T15:59:02.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7048" PostTypeId="1" CreationDate="2021-10-06T17:26:15.653" Score="1" ViewCount="22" Body="&lt;p&gt;I read that the lexicographic flow problem is polynomially solvable. However it allows for continuous flow values.&lt;/p&gt;&#xA;&lt;p&gt;Is there any reference about the problem with integral flow (and its complexity)?&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="5523" LastEditDate="2021-10-06T17:57:13.870" LastActivityDate="2021-10-06T17:57:13.870" Title="Complexity of lexicographic integral flow" Tags="|network-flow|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7050" PostTypeId="1" AcceptedAnswerId="7057" CreationDate="2021-10-07T02:33:38.857" Score="1" ViewCount="68" Body="&lt;p&gt;Consider the following cost function&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i=1}^{100} J(\mathbf{x}_i,\theta)&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_i \in \mathbb{R}^d$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\theta \in \mathbb{R}^K$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; is some function. Suppose I want to minimize this function with respect to &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; using gradient descent. The update rule would be&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{k+1} \leftarrow \theta_k - \alpha \cdot \nabla_\theta \sum_{i=1}^{100} J(\mathbf{x}_i,\theta_k)&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is some step size. Suppose that I can't fit the entire cost function into memory, and so I split the summation up like this&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{k+1} \leftarrow \theta_k - \alpha \cdot \nabla_\theta \left(\sum_{i=1}^{10} J(\mathbf{x}_i,\theta_k) + \sum_{i=11}^{20} J(\mathbf{x}_i,\theta_k) + \cdots + \sum_{i=91}^{100} J(\mathbf{x}_i,\theta_k)\right)&#xA;$$&lt;/span&gt;&#xA;I can then distribute &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; and the gradient operator &lt;span class=&quot;math-container&quot;&gt;$\nabla_\theta$&lt;/span&gt; like this&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{k+1} \leftarrow \theta_k - \left(\alpha \cdot \sum_{i=1}^{10} \nabla_\theta J(\mathbf{x}_i,\theta_k) + \alpha \cdot \sum_{i=11}^{20} \nabla_\theta J(\mathbf{x}_i,\theta_k) + \cdots + \alpha \cdot \sum_{i=91}^{100} \nabla_\theta J(\mathbf{x}_i,\theta_k)\right)&#xA;$$&lt;/span&gt;&#xA;I could then bring out the first term in the summation like this&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{k+1} \leftarrow \theta_k - \alpha \cdot \sum_{i=1}^{10} \nabla_\theta J(\mathbf{x}_i,\theta_k) - \left(\alpha \cdot \sum_{i=11}^{20} \nabla_\theta J(\mathbf{x}_i,\theta_k) + \cdots + \alpha \cdot \sum_{i=91}^{100} \nabla_\theta J(\mathbf{x}_i,\theta_k)\right)&#xA;$$&lt;/span&gt;&#xA;Now let&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{k+\frac{1}{10}} \leftarrow \theta_k - \alpha \cdot \sum_{i=1}^{10} \nabla_\theta J(\mathbf{x}_i,\theta_k)&#xA;$$&lt;/span&gt;&#xA;such that the update rule now becomes&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{k+1} \leftarrow \theta_{k+\frac{1}{10}} - \left(\alpha \cdot \sum_{i=11}^{20} \nabla_\theta J(\mathbf{x}_i,\theta_k) + \cdots + \alpha \cdot \sum_{i=91}^{100} \nabla_\theta J(\mathbf{x}_i,\theta_k)\right)&#xA;$$&lt;/span&gt;&#xA;I can then repeat the process by bringing out the first term in the summation,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{k+1} \leftarrow \theta_{k+\frac{1}{10}} - \alpha \cdot \sum_{i=11}^{20} \nabla_\theta J(\mathbf{x}_i,\theta_k) - \left(\alpha \cdot \sum_{i=21}^{30} \nabla_\theta J(\mathbf{x}_i,\theta_k) + \cdots + \alpha \cdot \sum_{i=91}^{100} \nabla_\theta J(\mathbf{x}_i,\theta_k)\right)&#xA;$$&lt;/span&gt;&#xA;and then letting&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{k+\frac{2}{10}} \leftarrow \theta_{k+\frac{1}{10}} - \alpha \cdot \sum_{i=11}^{20} \nabla_\theta J(\mathbf{x}_i,\theta_k)&#xA;$$&lt;/span&gt;&#xA;By repeating this process, I will eventually reach the final value of &lt;span class=&quot;math-container&quot;&gt;$\theta_{k+1}$&lt;/span&gt;, but I will have done so by computing a more tractable gradient that can fit into memory. As far as I understand, stochastic (or mini-batch) gradient descent (SGD) is different from this method, as it computes the gradient with respect to the new parameter value at each step. That is, instead of using the update rule&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{k+\frac{2}{10}} \leftarrow \theta_{k+\frac{1}{10}} - \alpha \cdot \sum_{i=11}^{20} \nabla_\theta J(\mathbf{x}_i,\theta_k)&#xA;$$&lt;/span&gt;&#xA;SGD uses the update rule&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{k+\frac{2}{10}} \leftarrow \theta_{k+\frac{1}{10}} - \alpha \cdot \sum_{i=11}^{20} \nabla_\theta J(\mathbf{x}_i,\theta_{k+\frac{1}{10}})&#xA;$$&lt;/span&gt;&#xA;Is my method truly different from SGD? Or is it just SGD in disguise? Also, if my method is different, why is it not more commonly used in practice, since it achieves the same goal of SGD of allowing large-scale gradient descent?&lt;/p&gt;&#xA;" OwnerUserId="7263" LastActivityDate="2021-10-07T10:40:22.423" Title="Is this stochastic gradient descent in disguise?" Tags="|optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7051" PostTypeId="1" AcceptedAnswerId="7093" CreationDate="2021-10-07T04:23:15.140" Score="5" ViewCount="520" Body="&lt;p&gt;&lt;strong&gt;Case 1: NLP&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;When either the objective function or at least one of the constraints or both are non-linear it is a NLP. We use generalized reduced gradient or Quadratic Programming to solve NLP. However, NLP also requires the decision variables to be continuous&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Case 2: MINLP&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;When either the objective function and/or at least one constraint is non-linear it is a MINLP. We use outer approximation or branch and bound to solve MINLP. However, MINLP also requires the decision variables to be both continuous and discrete(binary/integer).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Case 3: My Case&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objective function: two non-linear functions and one linear function&lt;/p&gt;&#xA;&lt;p&gt;Decision variable: two integer variables (Bounded)&lt;/p&gt;&#xA;&lt;p&gt;Constraint: three linear constraint (two bounding constraint and one relationship constraint)&lt;/p&gt;&#xA;&lt;p&gt;Problem type: non-convex&lt;/p&gt;&#xA;&lt;p&gt;Solution required: Global optimum&lt;/p&gt;&#xA;&lt;p&gt;Will this problem require conversion to NLP or MINLP to implement the above solution methods? What &lt;strong&gt;exact&lt;/strong&gt; multi-objective optimization methods can be used for my case?&lt;/p&gt;&#xA;&lt;p&gt;Also, if the problem is converted from INLP to NLP by relaxing the decision variables to real values what &lt;strong&gt;exact&lt;/strong&gt; multi-objective optimization methods can be used?&lt;/p&gt;&#xA;" OwnerUserId="5794" LastEditorUserId="5794" LastEditDate="2021-10-12T17:18:54.750" LastActivityDate="2021-10-12T17:18:54.750" Title="What methods are used to solve multi-objective optimization problem with non-linear objective functions and integer decision variables?" Tags="|mixed-integer-programming|nonlinear-programming|nonconvex-programming|multi-objective-optimization|global-optimality|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7052" PostTypeId="2" ParentId="6911" CreationDate="2021-10-07T06:07:28.360" Score="10" Body="&lt;p&gt;We at &lt;a href=&quot;https://mosek.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek&lt;/a&gt; has started porting Mosek to the Apple M1 CPU so the upcoming version 10 will support it.&lt;/p&gt;&#xA;&lt;p&gt;Here is an initial thought.&lt;/p&gt;&#xA;&lt;p&gt;Normally optimization software links to a BLAS/LAPACK library such as Intel MKL that does dense matrix multiplication and other important operations. That the BLAS/LAPACK library is of high quality is very important for the performance of interior-point methods.&lt;/p&gt;&#xA;&lt;p&gt;Now I just started looking at Apple's offering called &lt;a href=&quot;https://developer.apple.com/documentation/accelerate?language=objc&quot; rel=&quot;nofollow noreferrer&quot;&gt;Accelerate&lt;/a&gt; and to me it seems the documentation is extremely poor. For instance how do you link with it? Is it multithreaded? If it is multithreaded then how do control the number of threads?&lt;/p&gt;&#xA;&lt;p&gt;In addition it seems Accelerate has an advanced coproccessor for matrix operation&#xA;which on purpose is not documented at all as discussed by &lt;a href=&quot;https://medium.com/swlh/apples-m1-secret-coprocessor-6599492fc1e1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Eric Engheim&lt;/a&gt;. Hence,&#xA;it is very hard as optimization software vendor to figure out how to exploit the hardware best possible.&lt;/p&gt;&#xA;&lt;p&gt;Also something like the poor answer to this &lt;a href=&quot;https://developer.apple.com/forums/thread/680307&quot; rel=&quot;nofollow noreferrer&quot;&gt;question&lt;/a&gt; is not something I find promising.&lt;/p&gt;&#xA;&lt;p&gt;So to summarize the Apple M1 CPU and AMX coprocessor is most likely great, but I think there is significant amount of work for the software vendors to figure out how to exploit the hardware best possible. Since at least for now it is a niche platform for OR, then the question is how much energy the vendors will spend on tuning their software.&lt;/p&gt;&#xA;&lt;p&gt;Update: The M1 seems very fast using MOSEK on 1 thread, However, using multiple threads made it slower. BTW my employees say a Mac can at most have 16GB RAM. That will limit the size problems that can be solved.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="279" LastEditDate="2021-10-09T09:12:42.890" LastActivityDate="2021-10-09T09:12:42.890" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7053" PostTypeId="1" AcceptedAnswerId="7060" CreationDate="2021-10-07T07:17:04.793" Score="6" ViewCount="1960" Body="&lt;p&gt;I solved a Traveling Salesman Problem (TSP) by the cutting plane method, i.e. adding violated sub-tour constraints until the LP relaxation is a tour. Now, I am realizing that, in this symmetric TSP, driving route &lt;span class=&quot;math-container&quot;&gt;$1 \to 2 \to 3 \to 4$&lt;/span&gt; is identical to driving &lt;span class=&quot;math-container&quot;&gt;$4 \to 3 \to 2 \to 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am wondering how I can add another constraint so that the symmetry is avoided. It should work by defining &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; variables only if &lt;span class=&quot;math-container&quot;&gt;$i &amp;lt; j$&lt;/span&gt;. However, I do not know how I can adapt my code to make it work.&lt;/p&gt;&#xA;&lt;p&gt;I really appreciate your help!&lt;/p&gt;&#xA;&lt;p&gt;Here is my python code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Load libraries&#xA;from itertools import product&#xA;from networkx import minimum_cut, DiGraph&#xA;from mip import Model, xsum, BINARY, OptimizationStatus, CutType&#xA;&#xA;# This is the distance matrix&#xA;#&#xA;#          1       2       3       4       5       6       7       8       9       10&#xA;# 1        0       3       7       7       5       4       6       9       2       3&#xA;# 2        3       0       10      3       2       9       10      6       8       4&#xA;# 3        7       10      0       6       6       4       1       5       1       3&#xA;# 4        7       3       6       0       9       8       3       4       4       10&#xA;# 5        5       2       6       9       0       2       5       1       10      4&#xA;# 6        4       9       4       8       2       0       4       3       5       2&#xA;# 7        6       10      1       3       5       4       0       6       5       2&#xA;# 8        9       6       5       4       1       3       6       0       8       8&#xA;# 9        2       8       1       4       10      5       5       8       0       6&#xA;# 10       3       4       3       10      4       2       2       8       6       0&#xA;# ;&#xA;&#xA;# List of locations&#xA;L = [x + 1 for x in range(10)]&#xA;&#xA;# Set up distances between locations in a dictionary that uniquely identifies the nodes by a tuple&#xA;D = {&#xA;    (1, 2): 3, (1, 3): 7, (1, 4): 7, (1, 5): 5, (1, 6): 4, (1, 7): 6, (1, 8): 9, (1, 9): 2, (1, 10): 3,&#xA;    (2, 1): 3, (2, 3): 10, (2, 4): 3, (2, 5): 2, (2, 6): 9, (2, 7): 10, (2, 8): 6, (2, 9): 8, (2,10): 4,&#xA;    (3, 1): 7, (3, 2): 10, (3, 4): 6, (3, 5): 6, (3, 6): 4, (3, 7): 1, (3, 8): 5, (3, 9): 1, (3, 10): 3,&#xA;    (4, 1): 7, (4, 2): 3, (4, 3): 6, (4, 5): 9, (4, 6): 8, (4, 7): 3, (4, 8): 4, (4, 9): 4, (4, 10): 10,&#xA;    (5, 1): 5, (5, 2): 2, (5, 3): 6, (5, 4): 9, (5, 6): 2, (5, 7): 5, (5, 8): 1, (5, 9): 10, (5, 10): 4,&#xA;    (6, 1): 4, (6, 2): 9, (6, 3): 4, (6, 4): 8, (6, 5): 2, (6, 7): 4, (6, 8): 3, (6, 9): 5, (6, 10): 2,&#xA;    (7, 1): 6, (7, 2): 10, (7, 3): 1, (7, 4): 3, (7, 5): 5, (7, 6): 4, (7, 8): 6, (7, 9): 5, (7, 10): 2,&#xA;    (8, 1): 9, (8, 2): 6, (8, 3): 5, (8, 4): 4, (8, 5): 1, (8, 6): 3, (8, 7): 6, (8, 9): 8, (8, 10): 8,&#xA;    (9, 1): 2, (9, 2): 8, (9, 3): 1, (9, 4): 4, (9, 5): 10, (9, 6): 5, (9, 7): 5, (9, 8):8, (9, 10): 6,&#xA;    (10, 1): 3, (10, 2): 4, (10, 3): 3, (10, 4): 10, (10, 5): 4, (10, 6): 2, (10, 7): 2, (10, 8): 8, (10, 9): 6,&#xA;}&#xA;&#xA;# Define movements from i to j and from j to i&#xA;Dout = {l: [d for d in D if d[0] == l] for l in L}&#xA;Din = {l: [d for d in D if d[1] == l] for l in L}&#xA;&#xA;model = Model()&#xA;x = {d: model.add_var(name=f'x({d[0]},{d[1]})', var_type=BINARY) for d in D}&#xA;&#xA;model.objective = xsum(d * x[l] for l, d in D.items())&#xA;&#xA;# Add constraints: we want to leave and enter each location only once&#xA;for l in L:&#xA;    model += xsum(x[l] for l in Dout[l]) == 1, f'out({l})'&#xA;    model += xsum(x[l] for l in Din[l]) == 1, f'in({l})'&#xA;&#xA;# Solve the relaxed model (without subtour elimination)&#xA;model.optimize(relax=True)&#xA;&#xA;# Yields the same solution as GAMS :) {VW}&#xA;relaxed_solution = {y: x[y].x for y in x if x[y].x != 0}&#xA;&#xA;# Solve TSP by the cutting plane method&#xA;violated_inequalities = True&#xA;while violated_inequalities:&#xA;    model.optimize(relax=True)&#xA;    # print(&amp;quot;status: {} objective value : {}&amp;quot;.format(m.status, m.objective_value))&#xA;&#xA;    # Base class for directed graphs. A DiGraph stores nodes and edges with data.&#xA;    # Edges of the graph G are expected to have an attribute capacity that indicates how much flow the edge can support.&#xA;    G = DiGraph()&#xA;    for d in D:&#xA;        G.add_edge(d[0], d[1], capacity=x[d].x)&#xA;&#xA;    # Separation routine:&#xA;    # Choose an arbitrary location  ∈ {1, ... , }&#xA;    # Solve a maximum flow problem from  to each location  ∈ {1, ... , }\{} with edge capacities ҧ&#xA;    # If the optimal objective value of one of these maximum flow problems is &amp;lt; 1, a subtour constraint is violated.&#xA;    # The set  of the violated subtour constraint is one half of the corresponding minimum cut.&#xA;    # A cut divides the node set into two disjoint sets  and .&#xA;    # The cut’s capacity is the sum of capacities of all edges between  and .&#xA;    violated_inequalities = False&#xA;    for (n1, n2) in [(i, j) for (i, j) in product(L, L) if i != j]:&#xA;        # The capacity of a minimum capacity cut is equal to the flow value of a maximum flow.&#xA;        cut_capacity, (S, T) = minimum_cut(G, n1, n2)&#xA;        if cut_capacity &amp;lt; 1:&#xA;            model += (xsum(x[l] for l in D if (l[0] in S and l[1] in S)) &amp;lt;= len(S) - 1)&#xA;            violated_inequalities = True&#xA;&#xA;final_solution = {y: x[y].x for y in x if x[y].x != 0}&#xA;&#xA;# The tour is complete&#xA;final_solution&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7304" LastEditorUserId="2556" LastEditDate="2021-10-07T16:03:37.510" LastActivityDate="2021-10-07T16:15:57.640" Title="Traveling Salesman Problem: How to avoid symmetry?" Tags="|optimization|modeling|python|traveling-salesman|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7054" PostTypeId="1" CreationDate="2021-10-07T08:45:38.427" Score="1" ViewCount="49" Body="&lt;p&gt;Assume that, for a given network, its multi-sink multi-source max-flow satisfies a lexicographic order. Is this enough to state that I can solve the max-flow problem, by using a lex-max solver (i.e. a solver for the lexicographic maximal flow problem)?&lt;/p&gt;&#xA;&lt;p&gt;If yes, I just need to prove my assumption. Namely, proving that the optimal solution for my max-flow problem has lexicographic order.&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="5523" LastEditDate="2021-10-07T08:55:22.507" LastActivityDate="2021-10-07T08:55:22.507" Title="Solving a max-flow problem through lex-max flow problem" Tags="|network-flow|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7055" PostTypeId="1" CreationDate="2021-10-07T09:18:31.410" Score="1" ViewCount="69" Body="&lt;p&gt;Assume to tackle a particular group of instances for the integral multi-commodity flow problem.&lt;/p&gt;&#xA;&lt;p&gt;Particularly, given a digraph &lt;span class=&quot;math-container&quot;&gt;$G = (V \cup S \cup T,E)$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$S, T, V$&lt;/span&gt; are all disjoint. Furthermore, any &lt;span class=&quot;math-container&quot;&gt;$s_i \in S$&lt;/span&gt; has only one exiting edge with capacity equal to its demand. Symmetrically, any &lt;span class=&quot;math-container&quot;&gt;$t_i \in T$&lt;/span&gt; has only one entering edge, with capacity equal to its demand.&lt;/p&gt;&#xA;&lt;p&gt;My question is, can I reduce the problem to a single-source, single-sink problem? My idea is to add a super-source and a super-sink with demand equals to the sum of original demands.&lt;/p&gt;&#xA;&lt;p&gt;If this is feasible, I should be able to solve this particular group of instances in polynomial time.&lt;/p&gt;&#xA;" OwnerUserId="5523" LastActivityDate="2021-10-07T09:18:31.410" Title="Multi-commodity flow problem reduction" Tags="|network-flow|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7056" PostTypeId="2" ParentId="7053" CreationDate="2021-10-07T10:34:21.300" Score="1" Body="&lt;p&gt;Based off on what Daniel commented:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;select all the edges used in any vehicle's tour that are asymmetrical&lt;/li&gt;&#xA;&lt;li&gt;group them by vehicle, collecting the count of the number of asymetrical edges in that vehicle's tour&lt;/li&gt;&#xA;&lt;li&gt;add a hard constraint that there must be at least one (=&amp;gt; penalize if count is zero)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Alternatives:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Make it a soft constraint: Add a soft constraint to reward that count, by the count multiplied by a certain distance weight&lt;/li&gt;&#xA;&lt;li&gt;The asymmetrical distance difference matters: Don't collect the count, but abs() value of the asymmetrical distance difference and collect that sum. Then reward the minimum sum across all vehicles.&lt;/li&gt;&#xA;&lt;li&gt;The number for all tours matters: Like 2), but apply a load-balancing technique, so the 2th minimum sum etc are reward too, but less significantly than the minimum. Usually that can be done by squaring that sum per vehicle and then summing the squares across vehicles. But that would favor the max, so you 'll need to invert the sums first.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-10-07T10:34:21.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7057" PostTypeId="2" ParentId="7050" CreationDate="2021-10-07T10:40:22.423" Score="2" Body="&lt;p&gt;The proposed method is standard gradient descent with a reordering of the computation. I doesn't change anything for memory use, since there is no need to keep every element of the sum in memory anyway.&lt;/p&gt;&#xA;&lt;p&gt;Explained differently, the strength of SGD is to take multiple steps with partial information. Your algorithm evaluates every gradient at &lt;span class=&quot;math-container&quot;&gt;$\theta_k$&lt;/span&gt;, so only performs the full gradient descent step.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2021-10-07T10:40:22.423" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7059" PostTypeId="2" ParentId="7053" CreationDate="2021-10-07T15:09:10.700" Score="7" Body="&lt;p&gt;So you are dealing with a configuration where for any path &lt;span class=&quot;math-container&quot;&gt;$A-B-...-Z$&lt;/span&gt;, the reverse path &lt;span class=&quot;math-container&quot;&gt;$Z-...-B-A$&lt;/span&gt; is also valid.&lt;/p&gt;&#xA;&lt;p&gt;To break this symmetry, you can impose that the index of node &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; must be smaller than the index of node &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{i0} \le \sum_{j| j\le i}x_{0j}\quad \forall i&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This way, if arc &lt;span class=&quot;math-container&quot;&gt;$(i,0)$&lt;/span&gt; enters the depot, then there must be a lower indexed arc &lt;span class=&quot;math-container&quot;&gt;$(0,j)$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$j\le i$&lt;/span&gt; which exits the depot.&lt;/p&gt;&#xA;&lt;p&gt;Also, regarding your idea&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;It should work by defining &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; variables only if &lt;span class=&quot;math-container&quot;&gt;$i&amp;lt;j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is too restrictive if you are working with a directed graph. Consider for example an optimal path &lt;span class=&quot;math-container&quot;&gt;$1-3-2$&lt;/span&gt;. You need variable &lt;span class=&quot;math-container&quot;&gt;$x_{32}$&lt;/span&gt;. And for the reverse path, you would need variable &lt;span class=&quot;math-container&quot;&gt;$x_{31}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-10-07T16:15:57.640" LastActivityDate="2021-10-07T16:15:57.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7060" PostTypeId="2" ParentId="7053" CreationDate="2021-10-07T16:10:02.770" Score="6" Body="&lt;p&gt;For asymmetric TSP, you can use a directed graph, with variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i \not= j$&lt;/span&gt;, and the flow balance constraints are:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{j \not= i} x_{i,j} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \\&#xA;\sum_{j \not= i} x_{j,i} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For symmetric TSP, you should use an undirected graph, with variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i &amp;lt; j$&lt;/span&gt;, and the flow balance constraints are replaced with two-matching constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{j &amp;gt; i} x_{i,j} + \sum_{j &amp;lt; i} x_{j,i} &amp;amp;= 2 &amp;amp;&amp;amp;\text{for all $i$} \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-10-07T16:10:02.770" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7061" PostTypeId="1" AcceptedAnswerId="7080" CreationDate="2021-10-07T17:17:51.487" Score="2" ViewCount="5458" Body="&lt;p&gt;I know that there are some questions concerning this type of error, for example, &lt;a href=&quot;https://stackoverflow.com/questions/64912995/applicationerror-no-executable-found-for-solver-ipopt-in-pyomo&quot;&gt;this link&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I first installed the latest version of ipopt through command line into my Pyomo environment and got the &amp;quot;&lt;em&gt;&lt;strong&gt;No executable found for solver 'ipopt'&lt;/strong&gt;&lt;/em&gt; &amp;quot; error. But after studying the stackoverflow answers, I realized that I should downgrade the version of ipopt afterwards I got the same error, again when implementing a model in Pyomo.&lt;/p&gt;&#xA;&lt;p&gt;Here is the information:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/R0Ury.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/R0Ury.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And this is the error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;WARNING: Could not locate the 'ipopt' executable, which is required for solver&#xA;    ipopt&#xA;&#xA;---------------------------------------------------------------------------&#xA;ApplicationError                          Traceback (most recent call last)&#xA;&amp;lt;ipython-input-14-44d48836faac&amp;gt; in &amp;lt;module&amp;gt;&#xA;----&amp;gt; 1 results = opt.solve(model)&#xA;&#xA;~\anaconda3\lib\site-packages\pyomo\opt\base\solvers.py in solve(self, *args, **kwds)&#xA;    514         &amp;quot;&amp;quot;&amp;quot; Solve the problem &amp;quot;&amp;quot;&amp;quot;&#xA;    515 &#xA;--&amp;gt; 516         self.available(exception_flag=True)&#xA;    517         #&#xA;    518         # If the inputs are models, then validate that they have been&#xA;&#xA;~\anaconda3\lib\site-packages\pyomo\opt\solver\shellcmd.py in available(self, exception_flag)&#xA;    116             if exception_flag:&#xA;    117                 msg = &amp;quot;No executable found for solver '%s'&amp;quot;&#xA;--&amp;gt; 118                 raise ApplicationError(msg % self.name)&#xA;    119             return False&#xA;    120         return True&#xA;&#xA;ApplicationError: No executable found for solver 'ipopt'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now, I don't know what to do.&lt;/p&gt;&#xA;" OwnerUserId="6114" LastActivityDate="2021-10-09T17:36:34.407" Title="No executable found for solver 'ipopt" Tags="|optimization|python|pyomo|modeling-languages|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7062" PostTypeId="1" AcceptedAnswerId="7068" CreationDate="2021-10-08T09:25:24.903" Score="9" ViewCount="543" Body="&lt;p&gt;In the classic Mixed-Integer Linear Programming (MILP), the variables are fixed to be either integer or real. I am interested in the following MILP variant, where only one thing different from the classic MILP:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; be the number of the MILP variables. One variable (any variable) is real and &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; variables are integers. Notice that we can choose the real variable among all the variables.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is this MILP variant NP-hard?&lt;/li&gt;&#xA;&lt;li&gt;Is there a way to know how to choose the real variable to maximize the chances to reach a feasible solution?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;One trivial but naive solution to this problem would run &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; MILPs, such that for each MILP, one different variable is allowed to be real. The output is the best output among the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; running. This solution is NP-hard.&lt;/p&gt;&#xA;" OwnerUserId="7312" LastActivityDate="2021-10-08T20:12:22.093" Title="Mixed-Integer Linear Programming With Free Variables" Tags="|mixed-integer-programming|linear-programming|integer-programming|algorithms|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7063" PostTypeId="1" AcceptedAnswerId="7078" CreationDate="2021-10-08T09:35:22.933" Score="2" ViewCount="342" Body="&lt;p&gt;I try to solve a model in docplex(python) the model was stopped after a specific time limit. I want when the model stop return the best upper bound was found.&lt;/p&gt;&#xA;" OwnerUserId="5537" LastEditorUserId="5537" LastEditDate="2021-10-08T11:09:46.230" LastActivityDate="2021-10-09T00:37:40.173" Title="How to return the last upper bound docplex?" Tags="|mixed-integer-programming|docplex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7064" PostTypeId="1" CreationDate="2021-10-08T10:19:25.613" Score="5" ViewCount="170" Body="&lt;p&gt;Usually in (integral) multi-commodity flow problems the graph is assumed to be directed. Instead, I am working with an undirected graph. Is it possible to transform it in a digraph?&lt;/p&gt;&#xA;&lt;p&gt;Does such a transformation work in both the continuous and integral case?&lt;/p&gt;&#xA;" OwnerUserId="5523" LastActivityDate="2021-10-08T12:36:17.707" Title="(Integral) multi-commodity flow on undirected graph" Tags="|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7065" PostTypeId="1" CreationDate="2021-10-08T11:12:45.450" Score="5" ViewCount="68" Body="&lt;p&gt;Suppose I have some dataset &lt;span class=&quot;math-container&quot;&gt;$X = \{x_1, x_2, \ldots, x_n\}$&lt;/span&gt; which has a mean &lt;span class=&quot;math-container&quot;&gt;$\bar{X}$&lt;/span&gt; and a standard deviation &lt;span class=&quot;math-container&quot;&gt;$\sigma_X$&lt;/span&gt;. Now, suppose that I want to trim the tails of the dataset such that the new average is &lt;span class=&quot;math-container&quot;&gt;$\bar{X}_d$&lt;/span&gt; with new standard deviation &lt;span class=&quot;math-container&quot;&gt;$\sigma_{X_d}$&lt;/span&gt;. In other words, I want to remove &lt;strong&gt;the tail&lt;/strong&gt; points in the dataset such that the new average of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is approximately &lt;span class=&quot;math-container&quot;&gt;$\bar{X}_d$&lt;/span&gt; with a new standard deviation  of approximately &lt;span class=&quot;math-container&quot;&gt;$\sigma_{X_d}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to formulate some (convex) optimization problem to accomplish this? Basically, the optimization objective might be to find the threshold value &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; which seperates the dataset. I was thinking of this kind of formulation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \|\bar{X} - \bar{X}_d\|+ \|\sigma_{X}^2 - \sigma_{X_d}^2\|$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But not sure how to formulate this with optimization variables.&lt;/p&gt;&#xA;" OwnerUserId="5179" LastEditorUserId="5179" LastEditDate="2021-10-08T12:08:33.593" LastActivityDate="2021-10-08T14:34:39.973" Title="Enforce specific mean and standard deviation on data" Tags="|optimization|convex-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7066" PostTypeId="1" CreationDate="2021-10-08T11:50:44.533" Score="4" ViewCount="115" Body="&lt;p&gt;I want to know if a combinatorial problem like the knapsack problem is linear or not. And how do we know if a given problem is convex or not?&lt;/p&gt;&#xA;" OwnerUserId="7281" LastEditorUserId="123" LastEditDate="2021-10-08T15:46:46.990" LastActivityDate="2021-10-08T16:11:28.143" Title="How to know if a combinatorial optimization problem is linear or not?" Tags="|combinatorial-optimization|linearization|convexity|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7067" PostTypeId="2" ParentId="7064" CreationDate="2021-10-08T12:36:17.707" Score="7" Body="&lt;p&gt;Replace each undirected edge with two directed arcs in opposite directions.  The original capacity constraint on each edge now applies to the sum of the arcs in both directions.  If the costs are positive, every optimal solution will have flow in at most one of the two directions.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-10-08T12:36:17.707" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7068" PostTypeId="2" ParentId="7062" CreationDate="2021-10-08T12:48:14.747" Score="8" Body="&lt;p&gt;An alternative approach that requires only one solve and no modification of the model is to modify branch and bound to prune by integrality when at most one integer variable takes a fractional value (rather than the usual requirement that all integer variables are integer-valued).  You would also need to disable any presolve/cut routines that assume integrality.  You would also need to relax the feasibility checker.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-10-08T14:00:41.447" LastActivityDate="2021-10-08T14:00:41.447" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7069" PostTypeId="2" ParentId="7065" CreationDate="2021-10-08T13:39:57.843" Score="1" Body="&lt;p&gt;I think it is not easy (at least for me) to formulate the deviation part, so let's omit it...&lt;/p&gt;&#xA;&lt;p&gt;Let decision variable &lt;span class=&quot;math-container&quot;&gt;$b_i = 1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is chosen, otherwise &lt;span class=&quot;math-container&quot;&gt;$b_i = 0$&lt;/span&gt;. The mean value is defined by&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum b_i \bar{X} = \sum b_ix_i.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To vanish the bilinear term, introduce new variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;, to ensure&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_i = b_i\bar{X},&#xA;$$&lt;/span&gt;&#xA;introduce constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;-Mb_i \leq y_i \leq Mb_i\\&#xA;-M(1-b_i)\leq y_i - \bar{X}\leq M(1-b_i)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;By 'tail points', you might mean values larger than some &lt;span class=&quot;math-container&quot;&gt;$x^\mathrm{th}$&lt;/span&gt; should be disgarded, which is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_i \leq x^\mathrm{th} + M(1-b_i).&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A better way is to sort the data first and constrain&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;b_{i-1} \geq b_i&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(If you means ruling out left side, just flip the sign. To chop both sides, you might need two sets of 0-1 variables.)&lt;/p&gt;&#xA;&lt;p&gt;I think if you are just chopping one side tail, just iterate over the size of the result and choose your favorite.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastEditorUserId="4569" LastEditDate="2021-10-08T14:34:39.973" LastActivityDate="2021-10-08T14:34:39.973" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7071" PostTypeId="2" ParentId="7066" CreationDate="2021-10-08T16:11:28.143" Score="1" Body="&lt;p&gt;In general, you need to examine the structure of all expressions.&lt;/p&gt;&#xA;&lt;p&gt;If you want an automated way for a specific model, with the Octeract Engine Python API (our free solver) you can do:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from octeract import *&#xA;&#xA;model = Model()&#xA;model.import_model_file(&amp;quot;/your/model/file&amp;quot;)&#xA;print(model) &#xA;print(model.is_problem_convex())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If I e.g.run this for &lt;code&gt;ex6_1_1.nl&lt;/code&gt;, I get the following:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;Structure : NLP&#xA;Convexity : nonconvex&#xA;------------------------------------------&#xA;var x1 &amp;gt;= 1e-07, &amp;lt;= 0.5;&#xA;var x2 &amp;gt;= 1e-07, &amp;lt;= 0.5;&#xA;var x3 &amp;gt;= 1e-07, &amp;lt;= 0.5;&#xA;var x4 &amp;gt;= 1e-07, &amp;lt;= 0.5;&#xA;var x5 &amp;gt;= 0, &amp;lt;= 1e+07;&#xA;var x6 &amp;gt;= 0, &amp;lt;= 1e+07;&#xA;var x7 &amp;gt;= 0, &amp;lt;= 1e+07;&#xA;var x8 &amp;gt;= 0, &amp;lt;= 1e+07;&#xA;&#xA;minimize obj : (x4*(log(x4)+(-1*log((x2+x4)))))+(x2*(log(x2)+(-1*log((x2+x4)))))+(x1*(log(x1)+(-1*log((x1+x3)))))+(x3*(log(x3)+(-1*log((x1+x3)))))+(0.746*x3*x5)+(0.746*x4*x6)+(0.925*x1*x7)+(0.925*x2*x8)+0;&#xA;&#xA;subject to&#xA;&#xA;c1 : (x5*((0.159*x3)+x1))+-1.0*x1+0.0 = 0;&#xA;c2 : (x6*((0.159*x4)+x2))+-1.0*x2+0.0 = 0;&#xA;c3 : (x7*(x3+(0.308*x1)))+-1.0*x3+0.0 = 0;&#xA;c4 : (x8*(x4+(0.308*x2)))+-1.0*x4+0.0 = 0;&#xA;c5 : 1.0*x2+1.0*x1+0.0 = 0.5;&#xA;c6 : 1.0*x4+1.0*x3+0.0 = 0.5;&#xA;------------------------------------------&#xA;&#xA;&#xA;Model is convex:&#xA;False&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-10-08T16:11:28.143" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7072" PostTypeId="1" AcceptedAnswerId="7073" CreationDate="2021-10-08T17:49:50.683" Score="2" ViewCount="291" Body="&lt;p&gt;Following are the characteristics of my problem:&lt;/p&gt;&#xA;&lt;p&gt;Objective function: two non-linear functions and one linear function&lt;/p&gt;&#xA;&lt;p&gt;Decision variable: two integer variables (&lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_2$&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Constraint: three (two bounding constraint and one relationship constraint)&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 1: &lt;span class=&quot;math-container&quot;&gt;$ 0 \le X_1 \le A_1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 2: &lt;span class=&quot;math-container&quot;&gt;$ 0 \le X_2 \le A_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 3: &lt;span class=&quot;math-container&quot;&gt;$ X_1 + X_2 \le A_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A_1,A_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_3$&lt;/span&gt; are positive constant numbers.&lt;/p&gt;&#xA;&lt;p&gt;Problem type: non-convex&lt;/p&gt;&#xA;&lt;p&gt;Solution required: Global optimum&lt;/p&gt;&#xA;&lt;p&gt;Can we solve this problem using brand-and-bound method?&lt;/p&gt;&#xA;" OwnerUserId="5794" LastActivityDate="2021-10-08T18:53:17.750" Title="Branch and bound method for solving non-convex integer non-linear multi-objective optimization problem?" Tags="|nonlinear-programming|nonconvex-programming|multi-objective-optimization|branch-and-bound|branch-and-cut|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7073" PostTypeId="2" ParentId="7072" CreationDate="2021-10-08T17:52:32.337" Score="3" Body="&lt;p&gt;Yes we can. Branch and bound can both deal the integer variables and with the potenial non convexities of the non-linear functions. Most branch and bound methods can also handle constraints. Depending on the solver you might need provide an relaxation for the bounding part.&lt;/p&gt;&#xA;&lt;p&gt;However multi objective branch and bound methods are harder to come by, i am still not familiar with any solver that does it directly. I would consider an &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-constraint methodology to turn the multi objective problem into a series of single objective problems which can be solved to global optimality by standard MINLP solvers. In general the notion of solving a Multi-objective problem is ill defined for anything but linear multi-objective programs.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-10-08T17:59:23.793" LastActivityDate="2021-10-08T17:59:23.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7074" PostTypeId="2" ParentId="7072" CreationDate="2021-10-08T18:53:17.750" Score="2" Body="&lt;p&gt;Julia Niebling and Gabriele Eichfelder recently published a paper on solving nonconvex multiobjective optimization problems using branch and bound. You can find the paper through the following link &lt;a href=&quot;https://doi.org/10.1137/18M1169680&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1137/18M1169680&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-10-08T18:53:17.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7075" PostTypeId="1" CreationDate="2021-10-08T19:01:48.210" Score="1" ViewCount="70" Body="&lt;p&gt;I am trying to understand how the whale optimization algorithm works. When I see the mathematical model of this algorithm there are some parameters I want to understand what they mean and what their roles are. As in the figure the exploration shows some equation. What is the role of the parameter &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; when we calculate the distance?&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The search agent (humpback whale) looks for the best solution (the prey) randomly based on the position of each agent. We update the position of a search agent during this phase by using a randomly selected search agent rather than the best search agent. Following that, if &lt;span class=&quot;math-container&quot;&gt;$|a|&amp;gt;1$&lt;/span&gt;, as defined in Equation 3. then force the search agen to move away from a reference whale. Here's the mathematical model beind this phase: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\vec D&amp;amp;=|\vec C\cdot\vec{X_{\rm rand}}-\vec X|\tag1\\\vec X(t+1)&amp;amp;=\vec{X_{\rm rand}}-\vec A\cdot\vec D\tag2\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\vec{X_{\rm rand}}$&lt;/span&gt; is a random position vector selected from the current population, and &lt;span class=&quot;math-container&quot;&gt;$\{\vec A,\vec C\}$&lt;/span&gt; are coefficient vectors. Besides, here are the equations of &lt;span class=&quot;math-container&quot;&gt;$\{\vec A,\vec C\}$&lt;/span&gt; that can be used to find the best search agents: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\vec A&amp;amp;=2\cdot\vec a\cdot\vec r-\vec a\tag3\\\vec C&amp;amp;=2\cdot\vec r\tag4\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\vec r$&lt;/span&gt; is a random vector in range &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\vec a$&lt;/span&gt; decreases linearly from &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; during the iterations.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="7281" LastEditorUserId="123" LastEditDate="2021-10-08T19:43:14.590" LastActivityDate="2021-10-08T19:43:14.590" Title="What is the role of parameters in whale optimization algorithm?" Tags="|optimization|algorithms|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7076" PostTypeId="2" ParentId="7062" CreationDate="2021-10-08T20:12:22.093" Score="9" Body="&lt;p&gt;Here's another single-solve solution. Replace each original variable &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; with a sum of two variables, &lt;span class=&quot;math-container&quot;&gt;$x_n=y_n + z_n$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$y_n$&lt;/span&gt; is integer-valued and &lt;span class=&quot;math-container&quot;&gt;$z_n\in [0,1]$&lt;/span&gt;. Now define &lt;span class=&quot;math-container&quot;&gt;$\lbrace z_1,\dots, z_n\rbrace$&lt;/span&gt; to be a type 1 special ordered set (SOS1). Assuming the solver supports SOS1 constraints, you'll end up with a solution in which at least &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; of the &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; variables are 0, meaning at least &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; of the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables are integer.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-08T20:12:22.093" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7077" PostTypeId="1" CreationDate="2021-10-09T00:29:58.603" Score="2" ViewCount="96" Body="&lt;p&gt;I am working on a two-stage facility location problem as I described in &lt;a href=&quot;https://or.stackexchange.com/questions/6920/stochastic-facility-location-model&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am solving it with the L-shaped method (Benders decomposition). The cost value between each &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is a constant. Although the recourse is integers, I converted the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; variables to a continuous variable so that I can consider the recourse as linear and can take the dual of the recourse as an approximation. However, if I consider a real road network, the cost is actually a function of the flow on the road. A common cost function for the road network is the BPR function which is expressed as &lt;span class=&quot;math-container&quot;&gt;$t(x)=t^0\left(1+\alpha\left(\dfrac xc\right)^\beta\right)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This makes the recourse function non-linear (still convex). Any idea how could this type of problem be solved in the L-shaped method?&lt;/p&gt;&#xA;" OwnerUserId="3288" LastEditorUserId="123" LastEditDate="2021-10-09T09:14:49.997" LastActivityDate="2021-10-09T09:14:49.997" Title="Two-stage stochastic with non-linear recourse" Tags="|nonlinear-programming|stochastic-programming|benders-decomposition|facility-location|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7078" PostTypeId="2" ParentId="7063" CreationDate="2021-10-09T00:37:40.173" Score="3" Body="&lt;p&gt;Once you solve a docplex model, it creates an internal &lt;code&gt;SolveDetails&lt;/code&gt; object that contains the best bound you're looking for. You can access it in two ways:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Assuming you've defined your docplex model as &lt;code&gt;model&lt;/code&gt; (an instance of the class &lt;code&gt;docplex.mp.model.Model&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;print(model.get_solve_details().best_bound)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Assuming you've stored your model's solution in &lt;code&gt;sol&lt;/code&gt; (an instance of the class &lt;code&gt;docplex.mp.solution.SolveSolution&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;sol = model.solve()&#xA;print(sol.solve_details.best_bound)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Check out the &lt;a href=&quot;http://ibmdecisionoptimization.github.io/docplex-doc/mp/docplex.mp.sdetails.html#docplex.mp.sdetails.SolveDetails.best_bound&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="562" LastActivityDate="2021-10-09T00:37:40.173" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7080" PostTypeId="2" ParentId="7061" CreationDate="2021-10-09T17:36:34.407" Score="6" Body="&lt;p&gt;One of the most important things to keep in mind is that we should install Pyomo in another environment than the base environment together with its solvers. However, this is not enough to use Pyomo properly. In the case of ipopt solver, it returns the error &lt;strong&gt;No executable found for solver 'ipopt'&lt;/strong&gt;. To overcome this error, we need to search the exe file of ipopt in our computer and add its path to the system environment paths as follows:&lt;/p&gt;&#xA;&lt;p&gt;1- Go to the search bar of the Windows&lt;/p&gt;&#xA;&lt;p&gt;2-Search for system environment variables&lt;/p&gt;&#xA;&lt;p&gt;3- Open environment variables&lt;/p&gt;&#xA;&lt;p&gt;4-In the system variables, add the ipopt.exe path to the paths.&lt;/p&gt;&#xA;" OwnerUserId="6114" LastActivityDate="2021-10-09T17:36:34.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7082" PostTypeId="1" CreationDate="2021-10-10T14:23:46.017" Score="3" ViewCount="124" Body="&lt;p&gt;As far as I know, when we talk about the term of complexity, it referred to the time complexity of the model in which how long does it take to solve a specific mathematical program by a specific algorithm. For example, solving a knapsack problem by using dynamic programming takes &lt;span class=&quot;math-container&quot;&gt;$O(N\cdot W)$&lt;/span&gt;. Now, I would like to know about the model complexity in contrast to the time complexity. I was wondering if:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there any specific relationship between these two?&lt;/li&gt;&#xA;&lt;li&gt;Is there any standard way to understand the complexity of the model, specifically, mixed-integer linear programming?&lt;/li&gt;&#xA;&lt;li&gt;Is it that fact if the complexity of the model is high (I do not know the term &amp;quot;&lt;em&gt;&lt;strong&gt;high&lt;/strong&gt;&lt;/em&gt;&amp;quot; might be true) then, it would not be a polynomial algorithm to solve such a problem?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2021-10-10T16:58:18.720" LastActivityDate="2021-10-10T16:58:18.720" Title="Mathematical model complexity Vs Time Complexity of the model" Tags="|mixed-integer-programming|combinatorial-optimization|computational-complexity|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7083" PostTypeId="1" CreationDate="2021-10-10T16:34:14.427" Score="2" ViewCount="285" Body="&lt;p&gt;I'm trying to modify the job shop example for CP-SAT solver. (&lt;a href=&quot;https://developers.google.com/optimization/scheduling/job_shop&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization/scheduling/job_shop&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;I'm limited to 8 hours working day,&#xA;So I defined a list of NewIntervalVar() to represent non-working 12h everyday and weekend 24h+24h&lt;/p&gt;&#xA;&lt;p&gt;I add this list to AddNoOverlap() for every machine interval. (Also, is there a better approach? probably I'm already made mistake with this approach)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;non_working_intervals = add_non_working_hours(model)&#xA;for machine in all_machines:&#xA;    model.AddNoOverlap(machine_to_intervals[machine] + non_working_intervals)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And this works fine if all tasks are less than 8 hours..&#xA;Obviously, the model can't fit 15h task in 8h gap and return infeasible..&lt;/p&gt;&#xA;&lt;p&gt;The question is, how I can redefine the model so it can &amp;quot;automatically&amp;quot; start 15h task on one day and finish it the next day (after 12h). For 15h task it should be like: work 0-8 then gap(no work) 9-24 and then 24-31 (finish last 7h of 15h taks).&lt;/p&gt;&#xA;&lt;p&gt;The only solution that comes to my mind is to split all tasks into smaller chunks before modeling, but then I should add a mechanism so all parts of a single task must go one by one without interruption (also, I don't know if it's possible to implement)&lt;/p&gt;&#xA;" OwnerUserId="5399" LastEditorUserId="981" LastEditDate="2023-12-22T15:12:43.180" LastActivityDate="2023-12-22T15:12:43.180" Title="Scheduling when task duration longer than working interval" Tags="|constraint-programming|or-tools|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7084" PostTypeId="2" ParentId="7083" CreationDate="2021-10-10T17:09:20.907" Score="2" Body="&lt;p&gt;You should look at this example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/sat/doc/scheduling.md#intervals-spanning-over-breaks-in-the-calendar&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/ortools/sat/doc/scheduling.md#intervals-spanning-over-breaks-in-the-calendar&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2021-10-10T17:09:20.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7085" PostTypeId="1" AcceptedAnswerId="7086" CreationDate="2021-10-10T18:18:59.713" Score="3" ViewCount="1472" Body="&lt;p&gt;Suppose I have a mixed-integer-linear programming model where the objective is maximization. I solve my model in two different ways. First, I call CPLEX (a commercial solver), and then implement Benders decomposition in the traditional way (not with the single tree version).&lt;/p&gt;&#xA;&lt;p&gt;What I mean by saying &amp;quot;traditional&amp;quot; is that I solve the master problem (MP) to optimality where the optimal provides an upper bound (UP). Then,  a Benders cut (feasibility of optimality) is generated from the subproblem (SP) and a lower bound (LB) is obtained (not necessarily improved at every iteration). The MP is updated with the Benders cut. This process is repeated until a certain criteria is met.&lt;/p&gt;&#xA;&lt;p&gt;CPLEX can return an optimality gap larger than 100 since the optimality gap is calculated as |bestbound-bestinteger|/(1e-10+|bestinteger|).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.7.1.0?topic=parameters-relative-mip-gap-tolerance&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/12.7.1.0?topic=parameters-relative-mip-gap-tolerance&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, the optimality gap in Benders is calculated as (UB-LB)/UB. In other words, it is guaranteed to be between 0 and 100 with the correct scaling.&lt;/p&gt;&#xA;&lt;p&gt;My question is how one can make a fair comparison between solving a model with a commercial solver and Benders with respect to optimality gaps?&lt;/p&gt;&#xA;&lt;p&gt;Suppose the objectives of MP and SP are &lt;span class=&quot;math-container&quot;&gt;$\max c^Tx +\gamma$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\min \beta$&lt;/span&gt;, respectively, then &lt;span class=&quot;math-container&quot;&gt;$UB=c^Tx +\gamma$&lt;/span&gt;, which is non-increasing at each iteration. As for the LB, it is calculated as &lt;span class=&quot;math-container&quot;&gt;$LB = \max\{LB, c^Tx + \beta\}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4025" LastEditorUserId="123" LastEditDate="2021-10-11T07:43:46.633" LastActivityDate="2021-10-11T07:43:46.633" Title="How to compare the optimality gaps between a commercial solver and Benders" Tags="|mixed-integer-programming|linear-programming|cplex|benders-decomposition|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7086" PostTypeId="2" ParentId="7085" CreationDate="2021-10-10T23:34:16.697" Score="2" Body="&lt;p&gt;Assuming you are comparing Benders results to CPLEX solutions, why not use the CPLEX formula for the Benders results? Best integer would be your &lt;span class=&quot;math-container&quot;&gt;$LB$&lt;/span&gt; and best bound would be the current objective value of the master problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-10T23:34:16.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7087" PostTypeId="1" CreationDate="2021-10-11T02:40:47.530" Score="3" ViewCount="180" Body="&lt;p&gt;&lt;strong&gt;Background information:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the Quality Control labs of pharmaceutical companies, analysts inspect products or raw materials in the units of ‘batches’ (which is essential a physical sample of bill, liquid or powder).&lt;/p&gt;&#xA;&lt;p&gt;Typically, analysts do a set of tests on a batch/sample according to the requirements/documents.&lt;/p&gt;&#xA;&lt;p&gt;Here we call one test applied on a batch a task.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Common constraints/objectives:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Each task has an earliest start time (release date of the task) and the latest finish time (the due date of the task). This is a hard constraint or an objective related to overall lateness. In this example, we set it as hard constraints.&lt;/li&gt;&#xA;&lt;li&gt;There is limited resource. In this example, there is only a constraint for maximum 8 hours per day for working.&lt;/li&gt;&#xA;&lt;li&gt;Typically we want to minimize the total working time. This is what we set in this example.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Key item to optimize:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There is an important practice that we can do to improve efficiency.&lt;/p&gt;&#xA;&lt;p&gt;When two product/raw material batches come and there is a common test for them, analysts can merge them so they can be processed with less total processing time.&lt;/p&gt;&#xA;&lt;p&gt;For example, (Batch #1 - Test 2) and (Batch #2 - Test 2) takes 6 hours separately. But if they are merged and processed together, the total time can is not 6*2 hours but can be only 8 hours.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;A graphical illustration:&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/PAziM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PAziM.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;How could we tell the model that we want to merge tasks whenever resources allows?&lt;/p&gt;&#xA;&lt;p&gt;A minimal reproducible code with &lt;code&gt;pyomo&lt;/code&gt; and &lt;code&gt;glpk&lt;/code&gt; :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.environ import *&#xA;import pandas as pd&#xA;&#xA;m = ConcreteModel()&#xA;&#xA;m.DAYS = (1,2,3,4)&#xA;&#xA;m.TASKS = ('Batch_1_Test_1', 'Batch_1_Test_2', 'Batch_2_Test_2', 'Batch_2_Test_3')&#xA;&#xA;m.DURATIONS = {'Batch_1_Test_1': 4, 'Batch_1_Test_2': 6, 'Batch_2_Test_2': 6, 'Batch_2_Test_3': 4}&#xA;m.RELEASES = {'Batch_1_Test_1': 1, 'Batch_1_Test_2': 1, 'Batch_2_Test_2': 2, 'Batch_2_Test_3': 2}&#xA;m.DUE_DATES = {'Batch_1_Test_1': 2, 'Batch_1_Test_2': 2, 'Batch_2_Test_2': 3, 'Batch_2_Test_3': 3}&#xA;&#xA;D = pd.DataFrame(index = m.TASKS, columns = ['Duration_hours', 'Release_date_index', 'Due_date_index'])&#xA;D.Duration_hours = m.DURATIONS.values()&#xA;D.Release_date_index = m.RELEASES.values()&#xA;D.Due_date_index = m.DUE_DATES.values()&#xA;D&#xA;&#xA;#                Duration_hours  Release_date_index  Due_date_index&#xA;#Batch_1_Test_1               4                   1               2&#xA;#Batch_1_Test_2               6                   1               2&#xA;#Batch_2_Test_2               6                   2               3&#xA;#Batch_2_Test_3               4                   2               3&#xA;&#xA;TWO_BATCH_MODE_DURATION_FOR_TEST_2 = 4&#xA;&#xA;# array for tasks x days&#xA;m.flag = Var(m.TASKS, m.DAYS, domain=Binary)&#xA;&#xA;# minimize the total processing time&#xA;m.OBJ = Objective(expr=sum([m.flag[i, j]*m.DURATIONS[i] for i in m.TASKS for j in m.DAYS]), sense=minimize)&#xA;&#xA;m.c = ConstraintList()&#xA;&#xA;# each task is done only once    &#xA;for t in m.TASKS:&#xA;    m.c.add(sum([m.flag[t, d] for d in m.DAYS]) == 1)&#xA;&#xA;# there is only 8 hours in a day    &#xA;for d in m.DAYS:&#xA;    m.c.add(sum([m.flag[t, d]*m.DURATIONS[t] for t in m.TASKS]) &amp;lt;= 8)&#xA;&#xA;# earliest and latest time for tasks&#xA;for t in m.TASKS:&#xA;    for d in m.DAYS:&#xA;        if d &amp;lt; m.RELEASES[t]:&#xA;            m.c.add(m.flag[t, d] == 0)&#xA;        if d &amp;gt; m.DUE_DATES[t]:&#xA;            m.c.add(m.flag[t, d] == 0)&#xA;&#xA;&#xA;SolverFactory('glpk').solve(m).write()&#xA;&#xA;SCHEDULE_df = pd.DataFrame(index = m.TASKS, columns= m.DAYS)&#xA;SCHEDULE_HOURS_df = pd.DataFrame(index = m.TASKS, columns= m.DAYS)&#xA;&#xA;for i in m.TASKS:&#xA;    for j in m.DAYS:&#xA;        SCHEDULE_df.loc[i,j] = m.flag[i,j]()&#xA;        SCHEDULE_HOURS_df.loc[i,j] = m.flag[i,j]()*m.DURATIONS[i]&#xA;&#xA;print('------------------------------------------')&#xA;print(SCHEDULE_df)&#xA;print('------------------------------------------')&#xA;print(SCHEDULE_HOURS_df)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;------------------------------------------&#xA;flags:&#xA;                1  2  3  4&#xA;Batch_1_Test_1  0  1  0  0&#xA;Batch_1_Test_2  1  0  0  0&#xA;Batch_2_Test_2  0  0  1  0&#xA;Batch_2_Test_3  0  1  0  0&#xA;------------------------------------------&#xA;hours:&#xA;                1  2  3  4&#xA;Batch_1_Test_1  0  4  0  0&#xA;Batch_1_Test_2  6  0  0  0&#xA;Batch_2_Test_2  0  0  6  0&#xA;Batch_2_Test_3  0  4  0  0&#xA;------------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5988" LastEditorUserId="5988" LastEditDate="2021-10-11T03:03:52.533" LastActivityDate="2021-10-11T05:16:58.430" Title="How to merge tasks or do batching in a quality control lab" Tags="|scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7088" PostTypeId="2" ParentId="7087" CreationDate="2021-10-11T05:16:58.430" Score="4" Body="&lt;p&gt;One way you can handle is to create combined tasks of (Batch #1 - Test 2) and (Batch #2 - Test 2) as a newer task (in your tasks set) and include this new task in your first set of covering/partitioning constraint. In more detail for 2 day case, Let say &lt;span class=&quot;math-container&quot;&gt;$t_{1,1}$&lt;/span&gt; represent (Batch #1 - Test 2) completing task-1 on day-1 and &lt;span class=&quot;math-container&quot;&gt;$t_{2,1}$&lt;/span&gt; represent (Batch #2 - Test 2) completing task-2 on day-1  and add new task task (&lt;span class=&quot;math-container&quot;&gt;$t_{3,1}$&lt;/span&gt;) that represent  (both Batch #1 - Test 2 &amp;amp; Batch #2 - Test 2 completion on day-1). Similarly for &lt;span class=&quot;math-container&quot;&gt;$t_{1,2}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t_{2,2}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_{3,2}$&lt;/span&gt; represents for tasks completion on day-2.&lt;br /&gt;&#xA;We can write following constraints.&#xA;For task-1:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;t_{1,1}+t_{3,1}+t_{1,2}+t_{3,2} = 1 &#xA;\end{align*}&#xA;$$&lt;/span&gt;&#xA;for task-2:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;t_{2,1}+t_{3,1}+t_{2,2}+t_{3,2} = 1 &#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2021-10-11T05:16:58.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7089" PostTypeId="1" CreationDate="2021-10-11T05:24:40.187" Score="1" ViewCount="302" Body="&lt;p&gt;I am facing a problem in my model with piecewise constraints that is making my one of the decision variables equal to zero for every value.&lt;/p&gt;&#xA;&lt;p&gt;My objective function is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \min \sum_{t=1}^T p_{t} \cdot (1+r) \cdot y_{t}    &#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is the price, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is the quantity (decision variable) and &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; is the price surcharge. &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is the index for time periods.&lt;/p&gt;&#xA;&lt;p&gt;and my constraints are:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    M q_t &amp;gt; \sum_{i=0}^N \beta_{i} X_{it} - p_t (1+r) \quad \forall t=1,\dotsc,T&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    -M (1-q_t) \leq \sum_{i=0}^N \beta_{i} X_{it} - p_t (1+r)\quad  \forall t=1,\dotsc,T&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The problem is that the value of &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; depends on which interval the value of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; (decision variable) lies as shown by the following piecewise function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    r_t (Y_t) = &#xA;    \begin{cases}&#xA;        % s_0&#xA;        0 &amp;amp; \mathrm{if }\; Y_t \leq b_0 \\&#xA;        % s_1&#xA;        0.05 &amp;amp; \mathrm{if }\; b_0 &amp;lt; Y_t \leq b_1 \\&#xA;        % s_2&#xA;        0.1 &amp;amp; \mathrm{if }\; b_1 &amp;lt; Y_t \leq b_2\\[6pt]&#xA;        ... &amp;amp; \mathrm{if }\; ...&#xA;    \end{cases}&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$b_0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_1$&lt;/span&gt; etc. are set of quantity intervals = [0, 50, 100, 150, 200, 250]&lt;/p&gt;&#xA;&lt;p&gt;I have written piecewise constraints in Gurobi (Python) as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for t in range(1, T + 1):&#xA;    m.addGenConstrPWL(quantity[t], r,&#xA;        [0, 50, 50, 100, 100, 150, 150, 200, 200, 250], &#xA;        [0, 0, 0.05, 0.05, 0.1, 0.1, 0.15, 0.15, 0.2, 0.2]&#xA;    )&#xA;    m.addConstr(-M * (1 - q[t]) &amp;lt;= gp.quicksum(beta[i] * X[i, t]&#xA;        for i in range(N + 1)) - p[t] * (1+r),&#xA;        name = &amp;quot;price threshold 1&amp;quot;&#xA;    )&#xA;&#xA;&#xA;for t in range(1, T + 1):&#xA;    m.addGenConstrPWL(quantity[t], r,&#xA;        [0, 50, 50, 100, 100, 150, 150, 200, 200, 250],&#xA;        [0, 0, 0.05, 0.05, 0.1, 0.1, 0.15, 0.15, 0.2, 0.2]&#xA;    )&#xA;    m.addConstr(M * q[t]) &amp;gt;= gp.quicksum(beta[i] * X[i, t]&#xA;        for i in range(N + 1)) - p[t] * (1+r),&#xA;        name = &amp;quot;price threshold 2&amp;quot;&#xA;    )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is big M, &lt;span class=&quot;math-container&quot;&gt;$q[t]$&lt;/span&gt; is binary variable, &lt;span class=&quot;math-container&quot;&gt;$X[i,t]$&lt;/span&gt; is a given/known value, &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; is a binary variable and &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; also a binary variable.&#xA;There are also some other constraints but the problem is with these constraints.&#xA;Although the model optimizes the program it makes all the values of &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; variable equal to zero which shouldn't be the case.&lt;/p&gt;&#xA;&lt;p&gt;Could anyone please guide me where I am making mistake, whether in writing piecewise constraint or some other thing?&lt;/p&gt;&#xA;" OwnerUserId="7227" LastEditorUserId="491" LastEditDate="2022-04-11T14:38:53.577" LastActivityDate="2022-04-11T14:38:53.577" Title="Problem with Piecewise constraint in Gurobi" Tags="|optimization|mixed-integer-programming|python|gurobi|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7091" PostTypeId="1" CreationDate="2021-10-11T14:39:00.113" Score="5" ViewCount="535" Body="&lt;p&gt;like the title suggest, I am trying to constraint a boolean with another boolean, if that makes sense.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;x&lt;/strong&gt; and &lt;strong&gt;y&lt;/strong&gt; are both booleans, where &lt;strong&gt;y=1&lt;/strong&gt; when &lt;code&gt;Parameter &amp;lt; Variable1&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;What I am trying to do is the following.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if y = 1, then 0 &amp;lt;= x &amp;lt;= 1. x can be either 0 or 1&#xA;if y = 0, then x &amp;lt;= 0. x can only be 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I hope it makes sense, and I would really appreciate any help&lt;/p&gt;&#xA;" OwnerUserId="3746" LastEditorUserId="2556" LastEditDate="2021-10-11T15:31:55.527" LastActivityDate="2021-10-11T15:31:55.527" Title="Boolean constraining another boolean" Tags="|mixed-integer-programming|linear-programming|modeling|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7092" PostTypeId="2" ParentId="7091" CreationDate="2021-10-11T15:05:30.653" Score="6" Body="&lt;p&gt;It looks like you want to model &lt;span class=&quot;math-container&quot;&gt;$x \; \Longrightarrow \; y $&lt;/span&gt;, or in conjunctive normal form :&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\lnot x \vee y \\&#xA;1-x + y \ge 1 \\&#xA;x \le y&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; when a given parameter &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is larger than a given variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, then you need to add &lt;span class=&quot;math-container&quot;&gt;$p &amp;gt; z \; \Longrightarrow y=1$&lt;/span&gt;, or its contraposition &lt;span class=&quot;math-container&quot;&gt;$y=0 \; \Longrightarrow \; p \le z$&lt;/span&gt; with, for example, a bigM constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p \le z + My&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is the &amp;quot;smallest large constant&amp;quot; you can think of.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-10-11T15:11:21.417" LastActivityDate="2021-10-11T15:11:21.417" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7093" PostTypeId="2" ParentId="7051" CreationDate="2021-10-11T17:27:19.233" Score="6" Body="&lt;p&gt;Disclaimer: One might want to look for a reformulation or a special structure to apply mathematical tools to find optimal in the feasible set. I am assuming you're already past the possibility that your problem case could be reformulated as a MILP/LP/QP etc.&lt;/p&gt;&#xA;&lt;p&gt;So, with the problem on hand, we're dealing a case where we cannot have a reformulation. Whatever I understood from your problem description is that the problem is non-convex, non-linear, and constrained. But turns out you have just two bounded variables say &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;, We'll take advantage of this fact.&lt;/p&gt;&#xA;&lt;p&gt;My following approach is a brute force but this shall be a quick solution. Given discrete domains for &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; as follows,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_1 \in \{x_1^1, x_1^2, \cdots, x_1^n\}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_2 \in \{x_2^1, x_2^2, \cdots, x_2^m\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Some Non-Linear Objective Function: &lt;span class=&quot;math-container&quot;&gt;$f(x_1,x_2)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints: &lt;span class=&quot;math-container&quot;&gt;$(x_1^i,x_2^j) \in S : ~ i \in \{1,\cdots, n\}, j \in \{1,\cdots, m\} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Determine Global Optimal Solution: &lt;span class=&quot;math-container&quot;&gt;$\underset{x_1,x_2}{\mathrm{argmin}}{\{f(x_1^i,x_2^j) : ~ i,j \in S\}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Observe that, the complexity of brute force is still O(m*n) ie. polynomial in terms of your input domains.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: You also mentioned your problem is multiobjective, so you'll have an added advantage with this approach. You could even score each solution by computing the objectives separately rather than having one single objective function.&lt;/p&gt;&#xA;&lt;p&gt;PS: @community I agree, This is a bad solution if the no. variables increase or feasible region is too big. Given the size and the information available, this could be one of the feasible approach. [Read Disclaimer]&lt;/p&gt;&#xA;" OwnerUserId="4116" LastEditorUserId="4116" LastEditDate="2021-10-11T21:55:23.853" LastActivityDate="2021-10-11T21:55:23.853" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7094" PostTypeId="1" AcceptedAnswerId="7095" CreationDate="2021-10-12T14:20:14.183" Score="1" ViewCount="163" Body="&lt;p&gt;I have been working on a Graph Theory problem for my thesis and got stuck about the linearization of some constraints. I am hiding everything, constraints, variables and so on, of my problem not needed for this StackExchange question.&lt;/p&gt;&#xA;&lt;p&gt;Suppose we have in input a set of nodes &lt;span class=&quot;math-container&quot;&gt;$V=\{1,\dots,n\}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$n\in \mathbb N,n\ge 4$&lt;/span&gt;, a subset &lt;span class=&quot;math-container&quot;&gt;$\widetilde V\subset V$&lt;/span&gt;, a symmetrical matrix of costs &lt;span class=&quot;math-container&quot;&gt;$s\in\mathcal M_n(\mathbb R)$&lt;/span&gt; and a boolean vector &lt;span class=&quot;math-container&quot;&gt;$\hat{y}\in\{0,1\}^n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My (partial) problem is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{Min} \displaystyle \sum_{i\in V}\sum_{j\in V\setminus\{i\}}s_{ij}y_{ij}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s.t. \displaystyle\sum_{\substack{j \in V \backslash\widetilde{V}\\ i\neq j}} 2 y_{ij} + \displaystyle\sum_{\substack{j \in \widetilde{V}\\ i\neq j}} y_{ij} = 2(1 - \hat{y}_{i}) \quad \forall i \in V$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\quad y_{ij}\le \hat y_{j}\quad \forall (i,j)\in V^2, i\neq j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{ij}\in \{0,1\},\quad \forall (i,j)\in V^2,i\neq j,\quad(*)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Currently the constraints are Integer and Linear. And the following example shows that using&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{ij}\in [0,1],\quad \forall (i,j)\in V^2,i\neq j,\quad (**)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is not enough to make it linear. Indeed, suppose that &lt;span class=&quot;math-container&quot;&gt;$V = \{1,2,3,4\}$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{41} = 12$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{42} = 1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{43} = 10$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\hat{y}=[1,1,1,0]$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$1\notin \widetilde V$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$2\in \widetilde V$&lt;/span&gt; as well as &lt;span class=&quot;math-container&quot;&gt;$3\in \widetilde V$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Using &lt;span class=&quot;math-container&quot;&gt;$(*)\;\,$&lt;/span&gt; and focusing on node &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; will give an optimal (partial) solution of &lt;span class=&quot;math-container&quot;&gt;$y_{42} = y_{43} = 1 = 1 - y_{41}$&lt;/span&gt; of cost &lt;span class=&quot;math-container&quot;&gt;$11$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Using &lt;span class=&quot;math-container&quot;&gt;$(**)$&lt;/span&gt; and focusing on node &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; will give an optimal (partial) solution of &lt;span class=&quot;math-container&quot;&gt;$y_{41} = y_{42} = 0.5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{43} = 0$&lt;/span&gt; of cost &lt;span class=&quot;math-container&quot;&gt;$6.5$&lt;/span&gt; which is better than with &lt;span class=&quot;math-container&quot;&gt;$(*)$&lt;/span&gt; and feasible for all constraints except integer constraints &lt;span class=&quot;math-container&quot;&gt;$(*)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I don't know how I should linearize such constraints? Thank you for your kind help :D&lt;/p&gt;&#xA;&lt;p&gt;EDIT: thanks to @Kuifje's comments, I want the same problem but with linear decision variables instead of &lt;span class=&quot;math-container&quot;&gt;$y_{ij}\in \{0,1\}$&lt;/span&gt;. Using &lt;span class=&quot;math-container&quot;&gt;$y_{ij}\in[0,1]$&lt;/span&gt; is not enough as shown in the 4 nodes example. I believe the linearization is possible because I have a polynomial algorithm solving the problem.&lt;/p&gt;&#xA;&lt;p&gt;EDIT 2: I don't know if it is going to help:&lt;/p&gt;&#xA;&lt;p&gt;The ILP you have above models a graph theory problem where, given a set of nodes &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; and a subset &lt;span class=&quot;math-container&quot;&gt;$\widetilde V$&lt;/span&gt;. Suppose that &lt;span class=&quot;math-container&quot;&gt;$\hat{y}_i$&lt;/span&gt; will be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is selected. We will try to minimize, for all non selected hubs &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, the minimum between&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the distance between &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and the closest selected hub in &lt;span class=&quot;math-container&quot;&gt;$V\setminus{\widetilde V}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;and the sum the two distances between &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and the two closest selected hubs in &lt;span class=&quot;math-container&quot;&gt;$\widetilde V$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="35" LastEditorUserId="500" LastEditDate="2021-10-13T00:12:59.160" LastActivityDate="2021-10-13T12:50:43.047" Title="Linearization of constraints in a ILP" Tags="|linear-programming|integer-programming|linearization|graphs|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="7095" PostTypeId="2" ParentId="7094" CreationDate="2021-10-12T17:18:07.393" Score="4" Body="&lt;p&gt;Try adding valid constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_{i,j} \le \sum_{(i,k): k \in \tilde{V} \setminus \{j\}} y_{i,k} \quad\text{for $(i,j)$ such that $\hat{y}_i = 0$ and $j \in \tilde{V}\setminus\{i\}$}&#xA;$$&lt;/span&gt;&#xA;that enforce the logical implications&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(y_{i,j} \land \lnot\hat{y}_i \land [j \in \tilde{V} \setminus\{i\}]) \implies \bigvee_{(i,k): k \in \tilde{V} \setminus \{j\}} y_{i,k}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-10-13T12:50:43.047" LastActivityDate="2021-10-13T12:50:43.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7096" PostTypeId="1" AcceptedAnswerId="7101" CreationDate="2021-10-13T07:02:05.857" Score="8" ViewCount="321" Body="&lt;p&gt;In mathematical optimization software, defining the weight and level (hard/soft) of each of the objectives/constraints is often difficult for the business people at software development time, due to the impact on different stakeholders. There are several ways to deal with this, one being &lt;em&gt;multi-objective optimization&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Most business people typically love the idea of &lt;strong&gt;multi-objective optimization&lt;/strong&gt;, in which they don't need to make though choices now, but the software will present them with a number of solutions (from the pareto front) to pick from, for every problem that the solver optimizes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Does it ever work in production?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;For a user to pick the best timetable out of 2 wildly different timetables on the pareto front, is very non-trivial. Especially because they didn't help to create the timetables to begin with. Often there are easily thousands of solutions on the pareto front. Making matters worse, the number of solutions in a pareto front scales exponentially with the number of objectives.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Do you know of any multi-objective optimization use cases that survived first contact with production usage?&lt;/strong&gt; Cases that are actually still used by end-users in production? How does the UI handle showing multiple solutions?&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-10-14T15:24:59.963" Title="Do you know production deployments of multi-objective optimization?" Tags="|multi-objective-optimization|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7097" PostTypeId="2" ParentId="7096" CreationDate="2021-10-13T07:32:00.477" Score="5" Body="&lt;p&gt;Not a direct answer, but I think that &amp;quot;interactive multiobjective optimization&amp;quot; has shown that it can overcome the obstacle of expontially man Pareto optimal solutions. I have attended talks and seminars by Kaisa Miettinen and her co-authors, and their approaches seem quite interesting. On her website (&lt;a href=&quot;http://users.jyu.fi/%7Emiettine/engl.html#software&quot; rel=&quot;noreferrer&quot;&gt;http://users.jyu.fi/~miettine/engl.html#software&lt;/a&gt;) , she links to some of the software they have developed.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-10-13T07:32:00.477" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7099" PostTypeId="1" AcceptedAnswerId="7100" CreationDate="2021-10-13T11:41:21.977" Score="3" ViewCount="99" Body="&lt;p&gt;I am working with multi-commodity flow at integral flow with unit demand for each operation.&lt;/p&gt;&#xA;&lt;p&gt;Since I use the MCF formulation to model path finding, in my scenario cycles are just a waste of resources. I often read that MCF models path finding problems, without making particular assumptions on the graph (which in my case is undirected).&lt;/p&gt;&#xA;&lt;p&gt;However, I can't see why an MCF solver shouldn't send a flow within a cycle to maximize the objective function, even in my scenario with unit demand.&lt;/p&gt;&#xA;" OwnerUserId="5523" LastActivityDate="2021-10-13T13:07:42.613" Title="Does multi-commodity flow problem (MCF) block cycling flows?" Tags="|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7100" PostTypeId="2" ParentId="7099" CreationDate="2021-10-13T13:07:42.613" Score="6" Body="&lt;p&gt;Traditionally, the objective of the multicommodity flow problem is to minimize cost.   The usual situation that the costs are positive naturally avoids cycles.  The same idea arises with the shortest path problem: if the costs are positive, there are no negative cycles and an LP solver returns a path rather than a path plus cycles.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-10-13T13:07:42.613" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7101" PostTypeId="2" ParentId="7096" CreationDate="2021-10-13T14:57:43.830" Score="5" Body="&lt;p&gt;I am not aware of the timetabling, but if you mean by &lt;em&gt;&lt;strong&gt;production&lt;/strong&gt;&lt;/em&gt; is something like supply chain optimization, the answer would be actually &lt;em&gt;&lt;strong&gt;yes&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As the optimization methods are widely used in supply chain improvement, applying multi-objective optimization, specifically in where the decision-makers will need to choose between the different strategies like either JIT (pull) or push would be interesting.&lt;/p&gt;&#xA;&lt;p&gt;For example, in the detailed schedule of a production line, the decision-makers need to know about what if by changing the production plan from &amp;quot;make to order&amp;quot; to &amp;quot;make to stock&amp;quot; and based on, how many the required resources have to be changed!!? (for some reason it's needed to stock WIP). In such a case, MOOP is a good choice.&lt;/p&gt;&#xA;&lt;p&gt;For representing the results to the D-Ms, an excel based output (or others like web-based software) can be created with a bit explanation of the pros and cons for the main scenarios. Indeed, to avoid having many scenarios, using the customer's real expertise is so helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-10-13T14:57:43.830" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="7102" PostTypeId="1" CreationDate="2021-10-14T03:37:00.070" Score="5" ViewCount="406" Body="&lt;p&gt;I have an LP problem of the form &lt;span class=&quot;math-container&quot;&gt;$\min\ c^Tx$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$Ax\leq b$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; consists of 30 million parameters and &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a very very sparse matrix of size 30M by 30M (with only 3 ones per row). I tried solving this using scipy.linprog (Interior Point, HiGHS), cvxpy (ECOS, OSPQ) but none of them seem to really scale to this size. Is it currently possible to solve such large LP programs (using any freely available solvers or in the worst case even commercial ones)?&lt;/p&gt;&#xA;" OwnerUserId="7343" LastEditorUserId="123" LastEditDate="2021-10-14T06:57:24.790" LastActivityDate="2021-10-14T15:36:58.380" Title="Practical open source LP solvers for large linear programming problem with $10^7$ parameters" Tags="|mixed-integer-programming|linear-programming|convex-optimization|cvxpy|interior-point-method|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7103" PostTypeId="1" AcceptedAnswerId="7104" CreationDate="2021-10-14T04:58:42.120" Score="2" ViewCount="619" Body="&lt;p&gt;We want to model our MILP problem with Google OR-Tools in .NET, and solve it using GUROBI (solver may change in the next 1-2 years). However, we couldn't find the correct syntax to call GUROBI.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://developers.google.com/optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization&lt;/a&gt; says it is &lt;code&gt;Solver solver = Solver.CreateSolver(solver_id);&lt;/code&gt;. There are examples of calling GLOP and SCIP, but not for GUROBI (or we failed to find). What we tried listed below, but &lt;code&gt;solver&lt;/code&gt; returns &lt;code&gt;null&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;using Google.OrTools.LinearSolver;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Solver solver = Solver.CreateSolver(&amp;quot;GUROBI&amp;quot;);&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Solver solver = Solver.CreateSolver(&amp;quot;GUROBI_MIXED_INTEGER_PROGRAMMING&amp;quot;);&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Question 1: What is the correct way of calling GUROBI?&lt;/p&gt;&#xA;&lt;p&gt;Question 2: Does OR-Tools allow using callbacks of GUROBI? If so, any source suggestions to refer? &lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/cb_codes.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.1/refman/cb_codes.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="3630" LastActivityDate="2021-10-14T05:13:05.587" Title="Using OR-Tools with .NET and GUROBI" Tags="|mixed-integer-programming|gurobi|or-tools|c#|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7104" PostTypeId="2" ParentId="7103" CreationDate="2021-10-14T05:13:05.587" Score="5" Body="&lt;ol&gt;&#xA;&lt;li&gt;the library needs to find the gurobi shared library before you can create the solver. You can set GUROBI_HOME to help.&lt;/li&gt;&#xA;&lt;li&gt;you can have callbacks, but only in c++. Look for or-tools/linear_solver/linear_solver.h. Search for callbacks.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="981" LastActivityDate="2021-10-14T05:13:05.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7105" PostTypeId="1" AcceptedAnswerId="7109" CreationDate="2021-10-14T08:13:20.200" Score="5" ViewCount="356" Body="&lt;p&gt;When I come across with a situation needs an if-then constraints I visit &lt;a href=&quot;https://or.stackexchange.com/questions/33/in-an-integer-program-how-i-can-force-a-binary-variable-to-equal-1-if-some-cond&quot;&gt;Larry's post&lt;/a&gt;. I am a bit confused with the titled constraint this time because I am not trying to set &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; based on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; but trying to fix &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x&amp;lt;c$&lt;/span&gt;, e.g., &lt;span class=&quot;math-container&quot;&gt;$c=0.5$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have a linear program with &lt;span class=&quot;math-container&quot;&gt;$x\in\mathbb{R}_{\geq 0}$&lt;/span&gt;, and an objective of &lt;span class=&quot;math-container&quot;&gt;$\max \textbf{Ax}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\textbf{A}\in\mathbb{R}_{&amp;gt;0}$&lt;/span&gt;. There are readily some upper bound constraints on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, where all upper bounds are strictly greater than &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;. I would like &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x&amp;lt;0.5$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If I set a constraint &lt;span class=&quot;math-container&quot;&gt;$x\geq 0.5$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; will not be allowed to be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. So, I want to exclude the range &lt;span class=&quot;math-container&quot;&gt;$(0,c)$&lt;/span&gt; from the solution space of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. How can we set such a constraint?&lt;/p&gt;&#xA;" OwnerUserId="518" LastEditorUserId="500" LastEditDate="2021-10-14T15:13:54.687" LastActivityDate="2021-10-14T15:13:54.687" Title="If continuous variable &lt; constant then same variable = 0" Tags="|mixed-integer-programming|linear-programming|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7107" PostTypeId="1" AcceptedAnswerId="7112" CreationDate="2021-10-14T09:16:25.763" Score="8" ViewCount="584" Body="&lt;p&gt;&lt;em&gt;Where is the line when an approach is called multi-objective optimization?&lt;/em&gt; For example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Presume I want to optimize an optimization problem, for example nurse rostering, with 2 soft constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Constraint A) for employee happiness: number of rejected &amp;quot;day off requests&amp;quot;&lt;/li&gt;&#xA;&lt;li&gt;Constraint B) for service quality: number of shifts that match the employee's affinity&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now, I don't know yet if A) is a higher priority than B) or visa versa.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If - instead of running an optimization to come up with a pareto front - I run a normal solver twice:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Solve once with weights &lt;code&gt;A=1 and B=1000&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Solve again with weights &lt;code&gt;A=1000 and B=1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;and then allow the user to pick from these two &lt;em&gt;simulations&lt;/em&gt; the solution which he/she prefers.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Would you still call this approach multi-objective solving? What does the literature say?&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2021-10-14T09:21:26.787" LastActivityDate="2021-12-28T20:21:26.283" Title="Are simulations a form of multi-objective optimization?" Tags="|multi-objective-optimization|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7108" PostTypeId="1" CreationDate="2021-10-14T09:29:13.877" Score="1" ViewCount="22" Body="&lt;p&gt;Consider a polynomial &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-approximation for MCF with integral flow (like the one based on LP relaxation).&lt;/p&gt;&#xA;&lt;p&gt;Can I (in general) use this algorithm as a predicate, asserting whether a solution exists or not?&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="5523" LastEditDate="2021-10-14T10:40:44.407" LastActivityDate="2021-10-14T10:40:44.407" Title="Asserting solution existence via approximation of multi-commodity integral flow" Tags="|network-flow|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7109" PostTypeId="2" ParentId="7105" CreationDate="2021-10-14T13:09:42.510" Score="9" Body="&lt;p&gt;This is a &lt;em&gt;semicontinuous variable&lt;/em&gt;, and you can enforce it by introducing a binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and imposing linear constraints &lt;span class=&quot;math-container&quot;&gt;$$cy\le x \le My.$$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x\in[c,M]$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-10-14T13:09:42.510" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7110" PostTypeId="2" ParentId="7096" CreationDate="2021-10-14T15:24:59.963" Score="3" Body="&lt;p&gt;I'm not sure if this counts, since my impression is that the end users overlap the modelers, but a contact I have at &lt;a href=&quot;https://www.nature.org/en-us/&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Nature Conservancy&lt;/a&gt; (a non-profit that works in the conservation field) confirmed to me that his group uses a multi-objective optimization model for selecting land conservation projects in which to invest. As I understand it, criteria include various impacts on both residents of neighboring properties and assorted fauna and flora species. He pointed me to an open-access paper (*) they wrote. They use a tool called &lt;a href=&quot;https://en.wikipedia.org/wiki/Marxan&quot; rel=&quot;nofollow noreferrer&quot;&gt;Marxan&lt;/a&gt;. I have no idea what the UI looks like.&lt;/p&gt;&#xA;&lt;p&gt;(*) Annis GM, Pearsall DR, Kahl KJ, Washburn EL, May CA, Franks Taylor R, et al. (2017). Designing coastal conservation to deliver ecosystem and human well-being benefits. PLoS ONE 12(2): e0172458. doi:10.1371/journal.pone.0172458&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-14T15:24:59.963" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7111" PostTypeId="2" ParentId="7102" CreationDate="2021-10-14T15:36:58.380" Score="4" Body="&lt;p&gt;If you can't find (or can't afford) a solver that will handle a problem with that many nonzero matrix coefficients, and if your problem has a structure that fits one of the following methods, you might try either &lt;a href=&quot;https://en.wikipedia.org/wiki/Dantzig%E2%80%93Wolfe_decomposition&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dantzig-Wolfe&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/Benders_decomposition&quot; rel=&quot;nofollow noreferrer&quot;&gt;Benders&lt;/a&gt; decomposition.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-14T15:36:58.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7112" PostTypeId="2" ParentId="7107" CreationDate="2021-10-14T15:45:10.130" Score="9" Body="&lt;p&gt;There's a fair sized body of research in interactive multiobjective optimization, and while I'm not familiar with most of it, I think this would fit right in. Decades ago, I (vaguely) remember two of my colleagues looking at an interactive approach for multiobjective LPs, in which they would combine the criteria using a weighted sum, solve, show the individual objective values to the user, let the user adjust the weights by increasing/decreasing the importance of various criteria, solve again and iterate &lt;em&gt;ad nauseam&lt;/em&gt; (meaning they would continue until the decision maker fatigued and begged them to stop). That was considered multiobjective optimization, so I assume your approach would be.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-14T15:45:10.130" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7113" PostTypeId="1" AcceptedAnswerId="7117" CreationDate="2021-10-14T19:58:41.700" Score="8" ViewCount="410" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; be a set of tasks. Each task &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt; has a duration &lt;span class=&quot;math-container&quot;&gt;$d_t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$T_1 \subset T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T_2 \subset T$&lt;/span&gt; such as &lt;span class=&quot;math-container&quot;&gt;$T_1 \cap T_2 = \emptyset $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I model the following constraint : all tasks from &lt;span class=&quot;math-container&quot;&gt;$T_1$&lt;/span&gt; cannot overlap all tasks of &lt;span class=&quot;math-container&quot;&gt;$T_2$&lt;/span&gt; and vice versa. So basically, tasks from a same set can overlap but when a task from a set is performed, no task from the other set can overlap it.&lt;/p&gt;&#xA;" OwnerUserId="7347" LastEditorUserId="491" LastEditDate="2021-11-19T13:19:16.933" LastActivityDate="2021-11-19T13:19:16.933" Title="How to model a non-overlap constraint between 2 groups of tasks?" Tags="|modeling|constraint|scheduling|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7114" PostTypeId="2" ParentId="7113" CreationDate="2021-10-14T21:49:57.237" Score="7" Body="&lt;p&gt;One simple approach is to impose the classical non-overlap constraints for each pair of tasks for which one task is in &lt;span class=&quot;math-container&quot;&gt;$T_1$&lt;/span&gt; and one task is in &lt;span class=&quot;math-container&quot;&gt;$T_2$&lt;/span&gt;, as shown &lt;a href=&quot;https://or.stackexchange.com/questions/6078/modelling-precedence-relations&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-10-14T21:49:57.237" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7115" PostTypeId="2" ParentId="7113" CreationDate="2021-10-14T22:05:17.093" Score="4" Body="&lt;p&gt;I assume for you have a binary matrix &lt;span class=&quot;math-container&quot;&gt;$S_{i,t}$&lt;/span&gt; (tasks)&lt;span class=&quot;math-container&quot;&gt;$\times$&lt;/span&gt;(time steps) which tells you whether some task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is active at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. This approach introduces additional variables unless you have other parallelism constraints that can only be expressed in that format or of your objective depends on it like &lt;a href=&quot;https://or.stackexchange.com/q/6200/4777&quot;&gt;it does here.&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Define a new binary matrix of &lt;span class=&quot;math-container&quot;&gt;$G_{g,t}$&lt;/span&gt;(task groups)&lt;span class=&quot;math-container&quot;&gt;$\times$&lt;/span&gt;(time steps) and impose the constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\forall t_i\in T_1 \forall t\in\text{Time}: S_{i,t} \leq G_{1,t}  $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and similar for &lt;span class=&quot;math-container&quot;&gt;$T_2$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$G_{1,t}$&lt;/span&gt; will be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if any of the tasks in &lt;span class=&quot;math-container&quot;&gt;$T_1$&lt;/span&gt; are active.  Now you can express constraints on which groups can be active at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. In your case you want:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\forall t\in\text{Time}: G_{1,t} + G_{2,t} \leq 1$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-10-15T14:57:19.357" LastActivityDate="2021-10-15T14:57:19.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7116" PostTypeId="2" ParentId="7107" CreationDate="2021-10-14T22:18:59.667" Score="8" Body="&lt;p&gt;&lt;strong&gt;&lt;em&gt;tl;dr&lt;/em&gt;–&lt;/strong&gt;  The term you're looking for is &lt;a href=&quot;https://en.wikipedia.org/wiki/Sensitivity_analysis&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;&lt;em&gt;sensitivity analysis&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Would you still call this approach multi-objective solving? What does the literature say?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Trying different possible parameters to form a portfolio of options is called doing a &lt;a href=&quot;https://en.wikipedia.org/wiki/Sensitivity_analysis&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;&lt;em&gt;sensitivity analysis&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For example, say you're an engineer designing a light-bulb.  You know you want it to last a long time, be power-efficient, cheap, and all that good stuff – though you don't want to make assumptions about the trade-offs between those things, e.g. if making it 1% cheaper at the cost of being 1% less efficient is a good trade or not.  Then you can do a &lt;em&gt;sensitivity-analysis&lt;/em&gt;: generate a portfolio of results corresponding to various plausible trade-offs.&lt;/p&gt;&#xA;&#xA;" OwnerUserId="661" LastEditorUserId="661" LastEditDate="2021-10-14T23:32:36.857" LastActivityDate="2021-10-14T23:32:36.857" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7117" PostTypeId="2" ParentId="7113" CreationDate="2021-10-15T13:48:03.050" Score="7" Body="&lt;p&gt;within CPLEX you could try CPOptimizer and use intervals.&lt;/p&gt;&#xA;&lt;p&gt;In OPL (One of CPLEX API) you could write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using CP;&#xA;int sizeT=10;&#xA;range T=1..sizeT;&#xA;int d[i in T]=i;&#xA;&#xA;dvar interval t[i in T] size d[i];&#xA;&#xA;{int} T1={i | i in T : i &amp;lt;=(sizeT div 2)};&#xA;{int} T2=asSet(T) diff T1;&#xA;&#xA;subject to&#xA;{&#xA;  forall(i in T1,j in T2) overlapLength(t[i],t[j])==0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and then see&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lKXDU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lKXDU.jpg&quot; alt=&quot;gantt view within CPLEX IDE&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This works and is a bit naive.&lt;/p&gt;&#xA;&lt;p&gt;So a better way as far as solve speed is concerned is to rely on state functions:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using CP;&#xA;int sizeT=10;&#xA;range T=1..sizeT;&#xA;int d[i in T]=i;&#xA;&#xA;dvar interval t[i in T] size d[i];&#xA;&#xA;{int} T1={i | i in T : i &amp;lt;=(sizeT div 2)};&#xA;{int} T2=asSet(T) diff T1;&#xA;&#xA;stateFunction s; // 1 or 2 according to T1 or T2&#xA;&#xA;subject to&#xA;{&#xA; &#xA;  forall(i in T1) alwaysEqual(s,t[i],1);&#xA;  forall(i in T2) alwaysEqual(s,t[i],2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which will do the same but faster.&lt;/p&gt;&#xA;&lt;p&gt;And you can see in the CPLEX IDE for s:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xsiO9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xsiO9.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2021-10-16T00:09:36.627" LastActivityDate="2021-10-16T00:09:36.627" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7118" PostTypeId="2" ParentId="7107" CreationDate="2021-10-15T15:44:04.123" Score="2" Body="&lt;p&gt;Let me add to the existing answers the following result [1]:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$f_1,f_2$&lt;/span&gt; be two convex differentiable functions on &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^N$&lt;/span&gt;, and consider the corresponding multiobjective optimization problem.&#xA;Then the set of weak Pareto solutions is exactly equal to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \bigcup\limits_{\alpha,\beta \geq 0} {\rm{argmin}}~\alpha f_1 + \beta f_2.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In other words, any minimizer of a weighted sum of your functions is a weak Pareto equilibrium, and reciprocally. If you get rid of the convexity assumption on the functions, you lose the reciproque.&lt;/p&gt;&#xA;&lt;p&gt;In your context, it means that with your chosen weights &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;B&lt;/code&gt;, you are choosing two specific Pareto equilibriums among all the possible ones. I would consider this to be multiobjective optimization.&lt;/p&gt;&#xA;&lt;p&gt;[1] : Theory of vector optimization, Dinh The Luc, 1988. See Proposition IV.2.10.&lt;/p&gt;&#xA;" OwnerUserId="7354" LastActivityDate="2021-10-15T15:44:04.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7119" PostTypeId="1" CreationDate="2021-10-15T18:19:20.013" Score="2" ViewCount="382" Body="&lt;p&gt;I've been trying to program Excel Solver to fill the values of a matrix so that the sum of rows and columns match preestablished values. See image:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/s2nSN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Excel Problem&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I understand this problem has infinite solutions that's why I want to constraint the problem by having a reference matrix whose weights (percentage of total sum) I want to match. I've tried to accomplish this by summing the differences between the weighted reference matrix and the solution matrix and solving to minimize the absolute value:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;=((SUM(B19:F31))^2)^(1/2)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/K2ycb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Excel sheet&lt;/a&gt; \&lt;br /&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/uzBSh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Solver Parameters&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately excel cannot find a feasible solution. Any ideas why?&lt;/p&gt;&#xA;" OwnerUserId="7355" LastActivityDate="2021-10-15T20:02:32.493" Title="Excel Solver: Solving matrix values to match row/column sum according to reference" Tags="|mixed-integer-programming|solver|excel|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7120" PostTypeId="2" ParentId="7119" CreationDate="2021-10-15T20:02:32.493" Score="2" Body="&lt;p&gt;The problem is feasible only if the sum of the rows equals the sum of the columns. That's true for your Reference table, but not for the other tables.&lt;/p&gt;&#xA;&lt;p&gt;I'm not clear about what your objective function is intended to do relative to the Reference table. But your formula =((SUM(B19:F31))^2)^(1/2) makes no sense. Perhaps you intend to sum the squared differences between each element of the problem table and the reference table? If so, then calculate each squared difference in another table, then sum them and set that as your objective function. Don't include the square root, as that is difficult for the solver to handle, and it won't change the solution.&lt;/p&gt;&#xA;&lt;p&gt;If Excel's Solver still doesn't work, then download the advanced version of the free add-in OpenSolver &lt;a href=&quot;https://opensolver.org/installing-opensolver&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://opensolver.org/installing-opensolver&lt;/a&gt;, and use the Bonmin or Couenne non-linear solver.&lt;/p&gt;&#xA;" OwnerUserId="5128" LastActivityDate="2021-10-15T20:02:32.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7121" PostTypeId="1" CreationDate="2021-10-16T10:52:32.333" Score="3" ViewCount="154" Body="&lt;p&gt;I would like to seek some advice on modeling the following logical condition:&lt;/p&gt;&#xA;&lt;p&gt;Given two groups of binary decision variables &lt;span class=&quot;math-container&quot;&gt;$A_{i}, i=1...n,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_{j}, j=1...m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A_{i}=1- B_{j}, \forall i, \forall j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;i.e., if one of &lt;span class=&quot;math-container&quot;&gt;$A_{i}=1$&lt;/span&gt;, all &lt;span class=&quot;math-container&quot;&gt;$B_{j}$&lt;/span&gt; must be zero, and vice-versa.&lt;/p&gt;&#xA;&lt;p&gt;Besides, the above equality constraint, I would like to include tighter cuts, but have only managed to come up with the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\lvert B\right\rvert *A_{i}\le \left\lvert B\right\rvert-\sum_{j=1}^{j=m}B_{j}, \forall i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A_{i}\ge 1-\sum_{j=1}^{j=m}B_{j}, \forall i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="3682" LastEditDate="2021-10-16T11:40:31.130" LastActivityDate="2021-10-18T12:12:14.317" Title="Assistance in formulating binary constraint(s)" Tags="|mixed-integer-programming|modeling|binary-variable|logical-constraints|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="7122" PostTypeId="2" ParentId="7121" CreationDate="2021-10-16T12:00:41.397" Score="1" Body="&lt;p&gt;I would add an auxiliary variable &lt;span class=&quot;math-container&quot;&gt;$z\in\{0,1\}$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z \geq a_i \ \ \forall a_i \in A&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then you can write:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;b_j \leq 1-z \ \ \forall b_j \in B&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$z=0$&lt;/span&gt;, then the constraint is redundant. However, if &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt;, then all elements of &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; have to be 0.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;Update: @RobPratt correctly pointed out that the above formulation allows for &lt;span class=&quot;math-container&quot;&gt;$a_i = b_j = 0$&lt;/span&gt;, which violates the requirement the initial requirements. To fix this, I suggest to add:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z \leq \sum_i a_i \\&#xA;\sum_j b_j = 1 -z&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="133" LastEditorUserId="133" LastEditDate="2021-10-18T12:12:14.317" LastActivityDate="2021-10-18T12:12:14.317" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7124" PostTypeId="2" ParentId="7121" CreationDate="2021-10-16T13:58:44.273" Score="5" Body="&lt;p&gt;Via conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;A_i \implies \bigwedge_j \lnot B_j \\&#xA;\lnot A_i \lor \bigwedge_j \lnot B_j \\&#xA;\bigwedge_j (\lnot A_i \lor \lnot B_j) \\&#xA;\bigwedge_j (1-A_i +1- B_j\ge 1) \\&#xA;\bigwedge_j (A_i +B_j\le 1) \\&#xA;$$&lt;/span&gt;&#xA;The other implication&#xA;&lt;span class=&quot;math-container&quot;&gt;$$B_j \implies \bigwedge_i \lnot A_i$$&lt;/span&gt;&#xA;yields the same linear constraints.&lt;/p&gt;&#xA;&lt;p&gt;From your comment, you also want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lnot A_i \implies \bigwedge_j B_j,$$&lt;/span&gt;&#xA;which yields &lt;span class=&quot;math-container&quot;&gt;$A_i+B_j\ge 1$&lt;/span&gt;.  Together, these two sets of inequality constraints become the equality constraints &lt;span class=&quot;math-container&quot;&gt;$A_i+B_j=1$&lt;/span&gt;.  There are only two solutions to this linear system, and you can capture that more compactly (with &lt;span class=&quot;math-container&quot;&gt;$n+m$&lt;/span&gt; constraints instead of &lt;span class=&quot;math-container&quot;&gt;$nm$&lt;/span&gt; constraints) by introducing a single binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$A_i=z$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B_j=1-z$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-10-16T14:27:39.987" LastActivityDate="2021-10-16T14:27:39.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7125" PostTypeId="1" AcceptedAnswerId="7126" CreationDate="2021-10-16T17:33:10.213" Score="8" ViewCount="184" Body="&lt;p&gt;I am considering automating testing of down-stream testing of packages that depend on other packages. There are test sets &lt;span class=&quot;math-container&quot;&gt;$T_1,\ ..., T_n$&lt;/span&gt; which can be tested or not tested, which each have a time cost &lt;span class=&quot;math-container&quot;&gt;$c_1, ... , c_n$&lt;/span&gt; and might invoke a certain functionality &lt;span class=&quot;math-container&quot;&gt;$f_1,\ ... , f_m$&lt;/span&gt; which each have an weight &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$T \in \{0,1\}^n$&lt;/span&gt; be selection of tests. A set of tests either does or doesn't test a certain functionality &lt;span class=&quot;math-container&quot;&gt;$f_j$&lt;/span&gt;, testing it twice gives no benefit. I want to maximize &lt;span class=&quot;math-container&quot;&gt;$w^Tf$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$c^T T &amp;lt; \text{max cost}$&lt;/span&gt; . &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is equal to the logical OR of all &lt;span class=&quot;math-container&quot;&gt;$T_i$&lt;/span&gt; which test &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This problem is similar to knapsack but is not knapsack, because binary values mean we put multiple things in the bag together (one test set tests multiple functionalities) and adding things twice gives no benefit.&lt;/p&gt;&#xA;&lt;h3&gt;Are you you aware of a name for this problem class and whether there are alternative formulations or specialized algorithms (like there are for knapsack) for it ?&lt;/h3&gt;&#xA;&lt;p&gt;I am aware of ILP, pseudo boolean or maxsat forumlations.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="500" LastEditDate="2021-10-16T18:33:10.937" LastActivityDate="2021-10-16T18:33:10.937" Title="Name for this ILP problem type" Tags="|mixed-integer-programming|terminology|packing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7126" PostTypeId="2" ParentId="7125" CreationDate="2021-10-16T18:33:03.510" Score="11" Body="&lt;p&gt;This is called the &lt;a href=&quot;https://en.wikipedia.org/wiki/Maximum_coverage_problem#Budgeted_maximum_coverage&quot; rel=&quot;noreferrer&quot;&gt;budgeted maximum coverage problem&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-10-16T18:33:03.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7127" PostTypeId="1" AcceptedAnswerId="7138" CreationDate="2021-10-17T02:40:26.860" Score="7" ViewCount="250" Body="&lt;p&gt;I'm working on an optimization problem with a non-linear objective function of the form &lt;span class=&quot;math-container&quot;&gt;$$\max\prod_{i=1}^{n}(1-a_{i}x_{i}).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective function represents the combined probability of success for a series of independent stochastic trials.&lt;/p&gt;&#xA;&lt;p&gt;I assert that this is equivalent to the linear objective function &lt;span class=&quot;math-container&quot;&gt;$$\min  \sum_{i=1}^{n}a_{i}x_{i}$$&lt;/span&gt; where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{i}$&lt;/span&gt; are constant weights (failure rate) in the range &lt;span class=&quot;math-container&quot;&gt;$(0,1]$&lt;/span&gt; (the assertion breaks down if any &lt;span class=&quot;math-container&quot;&gt;$a_{i}=0$&lt;/span&gt;);&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; are binary variables.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The assertion is true for the small set of cases that I've tested. That is, the optimal set of &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; variables is the same for both forms of the objective function.&lt;/p&gt;&#xA;&lt;p&gt;But is the assertion true in general? Why / why not?&lt;/p&gt;&#xA;" OwnerUserId="5128" LastEditorUserId="500" LastEditDate="2021-10-18T12:37:03.967" LastActivityDate="2021-10-18T12:37:03.967" Title="Product of weighted binary variables equivalent to sum of weighted binary variables?" Tags="|optimization|mixed-integer-programming|linearization|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7128" PostTypeId="1" AcceptedAnswerId="7148" CreationDate="2021-10-17T05:29:09.443" Score="2" ViewCount="450" Body="&lt;p&gt;I am implementing data-driven robust optimization methodology introduced &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2017/06/6057.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;in this article&lt;/a&gt; in python. Somewhere of the method, I need to use pyomo for each constraint whose parameters are uncertain to form the robust counterpart. For simplicity, suppose we have only one constraint with uncertain parameters. The method stated in the article explains how to incorporate the uncertain set to find the constraint's robust counterpart. I wanted to form the robust counterpart constraints related to this constraint separately from the other constraints (that are not uncertain) due to some technical hardnesses.&lt;/p&gt;&#xA;&lt;p&gt;Now, I have two groups of constraints, one derived from robust counterpart for uncertain constraints, and the other group is the constraints that are not uncertain, coming from the original model.&lt;/p&gt;&#xA;&lt;p&gt;My question is that can I merge these two groups of constraints together to form the robust counterpart model as a whole?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Generally speaking, if we have two models written in pyomo, can we merge their constraints together to form a new problem? I mean can we take the constraints from one model and plug them into the other model?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;And what is the syntax?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="6114" LastActivityDate="2021-10-19T16:54:08.500" Title="Can we take the constraints from one model and plug them into the other model in pyomo?" Tags="|python|constraint|pyomo|robust-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7129" PostTypeId="2" ParentId="7127" CreationDate="2021-10-17T09:35:56.307" Score="6" Body="&lt;p&gt;No it's not true in general.&lt;/p&gt;&#xA;&lt;p&gt;Consider &lt;span class=&quot;math-container&quot;&gt;$n=4$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$a=(0.3,0.7,0.5,0.5)$&lt;/span&gt; under the constraint &lt;span class=&quot;math-container&quot;&gt;$(x_1 \wedge x_2) \text{xor}(x_3\wedge x_4)$&lt;/span&gt; which can be expressed in terms of MILP by introducing helper binary variables. For the linear term, &lt;span class=&quot;math-container&quot;&gt;$(1,1,0,0)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(0,0,1,1)$&lt;/span&gt; are equally good optima while for the product term they obviously differ in quality, meaning solving the MILP can produce a sub-optimal result.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-10-17T11:32:57.063" LastActivityDate="2021-10-17T11:32:57.063" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7130" PostTypeId="1" CreationDate="2021-10-17T14:21:48.733" Score="2" ViewCount="73" Body="&lt;p&gt;I came across this textbook problem today, in which we are given three steps as below&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6NTOj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6NTOj.png&quot; alt=&quot;Setup and Process time for the steps&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The question asks, &amp;quot;for what batch size is step 3 (etching) the bottleneck?&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Now, I am aware that you can calculate the capacity of a process that has setup time by using the formula&lt;/p&gt;&#xA;&lt;p&gt;Capacity for Batch Size = Batch Size / (Setup Time + (Batch Size * Processing Time) )&lt;/p&gt;&#xA;&lt;p&gt;I did this for all three in excel and my point is, the batch size is irrelevant in this case, as the third process will always have the lowest capacity. I encountered the same question in the last problem and had the same conclusion.&lt;/p&gt;&#xA;&lt;p&gt;Am I forgetting something here?&lt;/p&gt;&#xA;" OwnerUserId="7362" LastActivityDate="2021-10-17T15:59:34.753" Title="Given a 3 step process in which all processes require setup, how does the batch size affect the bottleneck?" Tags="|modeling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7131" PostTypeId="1" CreationDate="2021-10-17T14:45:16.277" Score="2" ViewCount="253" Body="&lt;p&gt;I am a beginner in CPLEX. I have a model with about 1 million constants and 800k rows and 1.6 million columns. I implemented in both GAMS and CPLEX (C# as the platform). The final solution for both is the same but the computational time for building the model (before solve) in CPLEX is much more than GAMS( about 2 hours vs 30 seconds). I have no idea why it happens and how it can be solved.&#xA;A sample as coding one of my constraints is as follows in C#.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for (int ss = 1; ss &amp;lt;= s; ss++) {&#xA;    for (int tt = 1; tt &amp;lt;= t; tt++) {&#xA;        if (ss != source &amp;amp;&amp;amp; ss != sink) {&#xA;            string c1 = &amp;quot;const01(&amp;quot; + (ss) + &amp;quot;,&amp;quot; + (tt).ToString() + &amp;quot;): &amp;quot;;&#xA;            ILinearNumExpr eq01 = MODEL.LinearNumExpr();&#xA;                                    &#xA;             for (int nn = 1; nn &amp;lt;= n; nn++) {&#xA;                 if (nbels[nn, ss] == 1 &amp;amp;&amp;amp; pdw[nn, ss] &amp;gt; 0) {&#xA;                     eq01.AddTerm(1 / pdw[nn, ss], x[nn][ss][tt]);&#xA;                 }&#xA;             }&#xA;             eq01.AddTerm(1, sVar01[ss][tt]);&#xA;             MODEL.AddEq(eq01, cap[ss, tt], c1);&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I would appreciate if you help me to solve this problem.&lt;/p&gt;&#xA;" OwnerUserId="7363" LastEditorUserId="4777" LastEditDate="2021-10-17T19:53:49.153" LastActivityDate="2021-10-17T19:53:49.153" Title="Building model takes so much time in Cplex" Tags="|optimization|cplex|gams|c#|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="7132" PostTypeId="2" ParentId="7130" CreationDate="2021-10-17T15:59:34.753" Score="1" Body="&lt;p&gt;The third process does not always have &lt;em&gt;lowest&lt;/em&gt; capacity. In fact, it never does. Ask yourself the following question: for what batch size does etching take less total time (setup plus processing) than patterning takes?&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-17T15:59:34.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7133" PostTypeId="1" AcceptedAnswerId="7135" CreationDate="2021-10-17T17:52:12.247" Score="4" ViewCount="431" Body="&lt;p&gt;Consider a simple formulation like the one below.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max&amp;amp;\quad\sum_i x_i\\&#xA;\text{s.t.}&amp;amp;\quad x_i \leq \underset{\forall j&amp;lt;i}{\text{min}}\ f(x_j)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am just wondering if I can consider such formulation an ILP problem.&lt;/p&gt;&#xA;&lt;p&gt;I intentionally kept things undefined to understand if this is general. Hope it sounds.&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="123" LastEditDate="2021-10-17T19:20:40.423" LastActivityDate="2021-10-18T15:42:38.020" Title="When is a formulation with min function an ILP problem?" Tags="|integer-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7134" PostTypeId="1" CreationDate="2021-10-17T17:58:31.657" Score="1" ViewCount="603" Body="&lt;p&gt;I am working on a marketing optimization problem, where the goal is maximize profit by optimally allocating spend to different products. Constraint is getting at least 1 Million revenue.&lt;/p&gt;&#xA;&lt;p&gt;As a first step, I built a model to predict the revenue using XGboost (which I can use to calculate profit given spend). Now, how can I use this xgboost model as the objective function to optimize overall profit ( allocating spend across different products) given the constraint on revenue. What are some methods for this optimization ?&lt;/p&gt;&#xA;&lt;p&gt;The Xgboost model uses about 6-7 variables like spend, target population, product, month etc.I came across linear programming for optimization but noticed LP uses linear objective function. I am newbie to optimization. I am not sure if I can/how to use xgboost model as objective function in Nonlinear optimization.&lt;/p&gt;&#xA;&lt;p&gt;My XGBoost predicts revenue from log(spend), log(population), target encoded product variable, and average of revenue obtained  2 - 4 weeks ago revenue for the product (2 to 4 weeks because of business implementation constraints while predicting with the model).&#xA;Now, what I am aim is to optimize the spend for a given product (hae about 60 products) that gives maximum profit.&lt;/p&gt;&#xA;" OwnerUserId="7366" LastEditorUserId="7366" LastEditDate="2021-10-17T23:09:28.330" LastActivityDate="2021-10-17T23:09:28.330" Title="Can I use xboost as objective function in an optimization problem?" Tags="|optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7135" PostTypeId="2" ParentId="7133" CreationDate="2021-10-17T18:16:06.867" Score="11" Body="&lt;p&gt;Your constraint is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i \le f(x_j) \quad \text{for $j&amp;lt;i$},$$&lt;/span&gt;&#xA;so it is linear if &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is linear.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-10-17T18:16:06.867" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7136" PostTypeId="2" ParentId="7134" CreationDate="2021-10-17T19:21:37.730" Score="2" Body="&lt;p&gt;As the boosted trees are too complex to be modeled as an explicit mathematical function - unless maybe one is prepared to spend a tremendous amount of effort - such an objective would be considered a &lt;a href=&quot;https://or.stackexchange.com/questions/3118/black-box-optimization-with-linear-programming&quot;&gt;black box optimization&lt;/a&gt; problem.&lt;/p&gt;&#xA;&lt;p&gt;An optimization problem is called &amp;quot;black box&amp;quot; when an explicit formula for the objective function is not known, and this function is often slow to evaluate.&lt;/p&gt;&#xA;&lt;p&gt;You will find references in the question linked above. The usual methods are surrogate modeling - fitting a faster model to the function to run the optimization model - or if the function is not too slow a direct search with local search or genetic algorithm variants.&lt;/p&gt;&#xA;&lt;p&gt;In practice, I suggest trying a simple local search first. If this is not sufficient, you may develop your own solution with response surface, but it gets complicated quickly. Some industrial solvers (LocalSolver, Knitro, ...) have support for black box functions and will often do a good job with it.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2021-10-17T19:39:14.080" LastActivityDate="2021-10-17T19:39:14.080" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7137" PostTypeId="1" CreationDate="2021-10-17T23:24:22.717" Score="2" ViewCount="92" Body="&lt;p&gt;Not sure this belongs here, but I thought I'd ask: How should I come to an understanding of an optimal weld sequence for a weld robot that welds a physical item on a revolving carousel (the gray T depicted)?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oOSQd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oOSQd.png&quot; alt=&quot;Simplified not to scale weld robot system setup&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Ok, so the green points need to be welded in the horizontal position (eight on each side), i.e. 180 and 0/360 position (it is currently in the 270 position). The pink points need to be welded in a 0-15% position in the direction indicated. There is no welding from below, i.e., the downward facing pink arrows need to be welded in a downward orientation, and then flipped to weld the other side. In this depiction there are two sides, downward pink arrows can all be access in the 270 position which it currently is in, upward facing arrows need to be rotated to 90 position. The robot can reach the pink arrows in the back in both these positions. The pink arrows all need what is called a &amp;quot;root pass&amp;quot;, and need to cool for at least 10 seconds because they also need a &amp;quot;fillet cover&amp;quot; which if done one after the other too fast can cause imperfections. So all eight pink welds have a root and a cover that need to be staggered by at least 10 seconds. The idea here is to limit the travel on the robot, reduce the number of rotations of the carousel, and reduce the time it takes to weld the whole assembly. The depiction is not to scale, the cylinder with the hangman is the robot in its home position.&lt;/p&gt;&#xA;&lt;p&gt;So, you can ask questions like if I go from home and start on the left downward pink on robot side and rotate to 360 weld out all the green, then weld the right downward pink on robot side would it be the same if I weld both pink downward robot side then all green, and then move on to upward pink at 90 by that time downward pink will be cool should I rotate back to 270 to cover or should I continue to the other side. I don't know, I'm just trying to formula one this so it's as fast as possible. Any thoughts?&lt;/p&gt;&#xA;&lt;p&gt;Also, at the end it will rotate back to 270 to flip to the other side to be stripped. That is, the carousel is on a carousel.&lt;/p&gt;&#xA;&lt;p&gt;I was hoping this was the kind of thing that didn't require dimension and could be reduced to graph or something.&lt;/p&gt;&#xA;" OwnerUserId="7368" LastEditorUserId="500" LastEditDate="2021-10-17T23:57:51.720" LastActivityDate="2021-10-28T19:35:27.407" Title="How can I find the shortest path solution or even begin to finding the most optimal solution to a weld robot sequencing problem?" Tags="|optimization|traveling-salesman|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7138" PostTypeId="2" ParentId="7127" CreationDate="2021-10-18T06:50:46.263" Score="6" Body="&lt;p&gt;It is not true in general, but you can make it work with&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max\sum_{i=1}^{n}\log(1-a_{i})x_{i}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$\log$&lt;/span&gt; is monotonic, your objective is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max\log\left(\prod_{i=1}^{n}(1-a_{i}x_{i})\right)$$&lt;/span&gt;&#xA;which becomes&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max\sum_{i=1}^{n}\log(1-a_{i}x_{i})$$&lt;/span&gt;&#xA;and finally, since &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is binary and &lt;span class=&quot;math-container&quot;&gt;$\log(1) = 0$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max\sum_{i=1}^{n}\log(1-a_{i})x_{i}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I guess that your &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; are quite small, in which case &lt;span class=&quot;math-container&quot;&gt;$\log(1 + a_i) \approx a_i$&lt;/span&gt;, and the objective you tried is a good approximation.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2021-10-18T06:50:46.263" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7139" PostTypeId="1" AcceptedAnswerId="7140" CreationDate="2021-10-18T13:32:09.010" Score="6" ViewCount="808" Body="&lt;p&gt;I am using the &lt;code&gt;rDEA&lt;/code&gt; package's linear optimization function &lt;code&gt;multi_glpk_solve_LP&lt;/code&gt;(which is built on top of the &lt;code&gt;Rglpk&lt;/code&gt; package's linear optimization function &lt;code&gt;Rglpk_solve_LP&lt;/code&gt;) to optimise the following problem:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;## minimize: 20 x_1 + 34 x_2 + 22 x_3 + 27 x_3&#xA;## subject to:&#xA;## x_1 + x_2 &amp;gt;= 0&#xA;## x_1 + x_2 &amp;lt;= 4650&#xA;## x_1 + x_2 + x_3 &amp;gt;= 0&#xA;## x_1 + x_2 + x_3 &amp;lt;= 4650&#xA;## x_1 + x_2 + x_3 + x_4 == 0&#xA;## x_1, x_2, x_3, x_4 are real numbers&#xA;&#xA;## Bounds&#xA;## 0 &amp;lt;= x_1 &amp;lt;= 4650&#xA;## -4650 &amp;lt;= x_2 &amp;lt;= 4650&#xA;## -4650 &amp;lt;= x_3 &amp;lt;= 4650&#xA;## -4650 &amp;lt;= x_4 &amp;lt;= 4650&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Until now there is no issue as I wrote the problem as follows and the results are correct:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;max_wg &amp;lt;- 18600/4&#xA;max &amp;lt;- F&#xA;prices &amp;lt;- c(20, 34, 22, 27)&#xA;d_const &amp;lt;- matrix(c(1,1,1,1,1,1,0,1,1,0,0,1), nrow = length(prices) - 1)&#xA;v &amp;lt;- c(rep(2, nrow(d_const)-1),1)&#xA;d_const &amp;lt;- d_const[rep(1:nrow(d_const), times = v), ]&#xA;&#xA;dir &amp;lt;- c(rep(c(&amp;quot;&amp;gt;=&amp;quot;, &amp;quot;&amp;lt;=&amp;quot;), (nrow(d_const)-1)/2), &amp;quot;==&amp;quot;)&#xA;rhs &amp;lt;- c(rep(c(0, max_wg), (nrow(d_const)-1)/2), 0)&#xA;bounds &amp;lt;- list(lower = list(ind = c(1L, 2L, 3L, 4L), val = c(0, -max_wg, -max_wg, -max_wg )),&#xA;               upper = list(ind = c(1L, 2L, 3L, 4L), val = c(max_wg, max_wg, max_wg, max_wg)))&#xA;&#xA;multi_glpk_solve_LP(obj = prices, mat = d_const, dir = dir, rhs = rhs, bounds = bounds, max = max)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, I would like to optimize the same problem now, but where bounds are a function of the sum of x_i so I should have :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;## minimize: 20 x_1 + 34 x_2 + 22 x_3 + 27 x_3&#xA;## subject to:&#xA;## x_1 + x_2 &amp;gt;= 0&#xA;## x_1 + x_2 &amp;lt;= 4650&#xA;## x_1 + x_2 + x_3 &amp;gt;= 0&#xA;## x_1 + x_2 + x_3 &amp;lt;= 4650&#xA;## x_1 + x_2 + x_3 + x_4 == 0&#xA;## x_1, x_2, x_3, x_4 are real numbers&#xA;&#xA;## Bounds&#xA;## 0 &amp;lt;= x_1 &amp;lt;= 4650&#xA;&#xA;## -(60% + 1/4 * x_1/max_wg) * 4650 &amp;lt;= x_2 &amp;lt;= 4650 if x_1 &amp;lt;= max_wg * 60%&#xA;## -(60% + 1/4 * x_1/max_wg) * 4650 &amp;lt;= x_2 &amp;lt;= (3/2 * (100 - x_1/max_wg) + 40%) * 4650 if x_1 &amp;gt; max_wg * 60% and x_1 &amp;lt;=  max_wg * 80%&#xA;## -((20% * x_1/max_wg ) + 90%) * 4650 &amp;lt;= x_2 &amp;lt;= (3/2 * (100 - x_1/max_wg) + 40%) * 4650 if x_1 &amp;gt;  max_wg * 80%&#xA;&#xA;## -(60% + 1/4 * (x_1+x_2)/max_wg ) * 4650 &amp;lt;= x_3 &amp;lt;= 4650 if (x_1+x_2) &amp;lt;= max_wg * 60%&#xA;## -(60% + 1/4 * (x_1+x_2)/max_wg ) * 4650 &amp;lt;= x_3 &amp;lt;= (3/2 * (100 - (x_1+x_2)/max_wg ) + 40%) * 4650 if (x_1+x_2)&amp;gt; max_wg * 60% and (x_1+x_2)&amp;lt;=  max_wg * 80%&#xA;## -((20% * (x_1+x_2)/max_wg ) + 90%) * 4650 &amp;lt;= x_3 &amp;lt;= (3/2 * (100 - (x_1+x_2)/max_wg ) + 40%) * 4650 if (x_1+x_2)&amp;gt;  max_wg * 80%&#xA;&#xA;## -(60% + 1/4 * (x_1+x_2+x_3)/max_wg ) * 4650 &amp;lt;= x_4 &amp;lt;= 4650 if (x_1+x_2+x_3) &amp;lt;= max_wg * 60%&#xA;## -(60% + 1/4 * (x_1+x_2+x_3)/max_wg ) * 4650 &amp;lt;= x_4 &amp;lt;= (3/2 * (100 - (x_1+x_2+x_3)/max_wg ) + 40%) * 4650 if (x_1+x_2+x_3)&amp;gt; max_wg * 60% and (x_1+x_2+x_3)&amp;lt;=  max_wg * 80%&#xA;## -((20% * (x_1+x_2+x_3)/max_wg ) + 90%) * 4650 &amp;lt;= x_4 &amp;lt;= (3/2 * (100 - (x_1+x_2+x_3)/max_wg ) + 40%) * 4650 if (x_1+x_2+x_3)&amp;gt;  max_wg * 80%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If there is no package in R that can do this I could eventually do it in Python. Basically the bounds are a function of the cumulative sums of the values of the optimization.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&#xA;Made the bounds condition clearer. The answer that I was given does not explain how to make the y function a function of xi&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="7373" OwnerDisplayName="user9396820" LastEditorUserId="7373" LastEditDate="2021-10-20T07:59:34.127" LastActivityDate="2021-10-20T07:59:34.127" Title="How can I solve a linear optimization problem with bounds that are a function of the decision" Tags="|optimization|modeling|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7140" PostTypeId="2" ParentId="7139" CreationDate="2021-10-18T15:12:24.750" Score="6" Body="&lt;p&gt;You want to model constraints of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_1 \le a_1 \quad  \Longrightarrow \quad x_2 \in [b_2,c_2]&#xA;$$&lt;/span&gt;&#xA;Define a binary variable &lt;span class=&quot;math-container&quot;&gt;$y \in \{0,1\}$&lt;/span&gt; and use constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;0 &amp;amp;\le x_1 \le a_1 + M_1(1-y) \tag{1}\\&#xA;b_2 - M_3(1-y) &amp;amp;\le x_2 \le c_2 +M_2 (1-y) \tag{2}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y=1 \; \Longrightarrow \; x_1 \le a_1$&lt;/span&gt;, constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$y=1 \; \Longrightarrow \; x_1 \in [b_2,c_2]$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$M_1,M_2,M_3$&lt;/span&gt; are large constants, and as @Mark L. Stone mentions in the comment section, these constants should be the smallest largest constants you can think of, that is, they should be &amp;quot;big enough&amp;quot;. For example, you could use &lt;span class=&quot;math-container&quot;&gt;$M_1 := L_1 -a_1$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$L_1$&lt;/span&gt; is your upper bound on &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Define binary variables for the other intervals, adapt the equations, and make sure only one interval is used per variable with &lt;span class=&quot;math-container&quot;&gt;$\sum_i y_i = 1 $&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-10-18T15:33:07.270" LastActivityDate="2021-10-18T15:33:07.270" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7141" PostTypeId="1" CreationDate="2021-10-18T15:13:35.027" Score="3" ViewCount="108" Body="&lt;p&gt;Consider the following mixed-integer linear programming (MILP):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation*}&#xA;\begin{array}{ll@{}ll}&#xA;\text{maximize}  &amp;amp; 1 &amp;amp; \\&#xA;\text{subject to}&amp;amp; x_{i} \geq 0,  &amp;amp;i=1 ,\dots, m\\&#xA;                 &amp;amp; y_{i} \geq 0,  &amp;amp;i=1 ,\dots, m\\  &#xA;                 &amp;amp; z_{i} \geq 0,  &amp;amp;i=1 ,\dots, m\\  &#xA;                 &amp;amp; x_{i}+y_{i}+z_{i} = 1,  &amp;amp;i=1 ,\dots, m\\&#xA;                 &amp;amp; \sum_{i=1}^m a_{i}x_{i} =  \frac{\sum_{i=1}^m a_i}{3}\\&#xA;                 &amp;amp; \sum_{i=1}^m b_{i}y_{i} =  \frac{\sum_{i=1}^m b_i}{3}\\&#xA;                 &amp;amp; \sum_{i=1}^m c_{i}z_{i} =  \frac{\sum_{i=1}^m c_i}{3}\\&#xA;                 &amp;amp; \text{$x_{i}, y_{i}, z_{i}$ are integers for all $i \in \{1, ..., m\}$,} \\&#xA;                 &amp;amp; \text{except one $i \in \{1, ..., m\}$ for which $x_{i}, y_{i}, z_{i}$ are reals} \\&#xA;\end{array}&#xA;\end{equation*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is already proved that if &lt;span class=&quot;math-container&quot;&gt;$a_{i} = b_{i} = c_{i}$&lt;/span&gt;, then the problem has a polynomial time solution.&lt;/p&gt;&#xA;&lt;p&gt;Questions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is this specific case of MILP can be resolved in polynomial time?&lt;/li&gt;&#xA;&lt;li&gt;If not, how can I prove that this special case is NP-hard?&lt;/li&gt;&#xA;&lt;li&gt;In general, are there some generic ways to prove that a specific MILP is NP-hard or has a polynomial-time solution?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7312" LastEditorUserId="2576" LastEditDate="2021-10-18T15:39:57.997" LastActivityDate="2021-10-18T15:39:57.997" Title="Polynomial Time Solution For a Mixed-Integer Linear Programming Specific Case" Tags="|mixed-integer-programming|linear-programming|integer-programming|algorithms|computational-complexity|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7142" PostTypeId="2" ParentId="7133" CreationDate="2021-10-18T15:42:38.020" Score="3" Body="&lt;p&gt;Extending Robs answer slightly, taking into account that you asked about ILP (which I interpret as mixed-integer linear program), the constraint is MILP-representable as long as &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is MILP-representable (thus allowing you to have piecewise affine functions such as min/max/abs/general pwa etc)&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2021-10-18T15:42:38.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7144" PostTypeId="1" CreationDate="2021-10-18T22:54:07.557" Score="3" ViewCount="54" Body="&lt;p&gt;Consider the following cost function&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f(\mathbf{x}_1,\mathbf{x}_2,\dots,\mathbf{x}_N,\theta) = \sum_{i=1}^{N} J(\mathbf{x}_i,\theta)&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_i \in \mathbb{R}^d$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\theta \in \mathbb{R}^K$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; is some function. Suppose I want to minimize this function with respect to &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; using gradient descent. The update rule is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{k+1} \leftarrow \theta_k - \alpha_k \cdot \nabla_\theta f(\mathbf{x}_1,\mathbf{x}_2,\dots,\mathbf{x}_N,\theta_k)&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\alpha_k$&lt;/span&gt; is some step size. I am trying to choose an appropriate &lt;span class=&quot;math-container&quot;&gt;$\alpha_k$&lt;/span&gt; at each step using the secant method. More precisely, let&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\phi (\alpha_k) = f\left(\mathbf{x}_1,\mathbf{x}_2,\dots,\mathbf{x}_N,\left[\theta + \alpha_k \cdot \nabla_\theta f(\mathbf{x}_1,\mathbf{x}_2,\dots,\mathbf{x}_N,\theta_k)\right]\right)&#xA;$$&lt;/span&gt;&#xA;such that the optimal &lt;span class=&quot;math-container&quot;&gt;$\alpha_k$&lt;/span&gt; is determined using the update rule&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\alpha_{k+2} \leftarrow \alpha_{k+1} - \frac{\alpha_{k+1} - \alpha_{k}}{\frac{\text{d} \phi (\alpha_{k+1})}{\text{d} \alpha} - \frac{\text{d} \phi (\alpha_{k})}{\text{d} \alpha}} \cdot \frac{\text{d} \phi (\alpha_{k+1})}{\text{d} \alpha}&#xA;$$&lt;/span&gt;&#xA;However, my problem is that the term&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\nabla_\theta f(\mathbf{x}_1,\mathbf{x}_2,\dots,\mathbf{x}_N,\theta_k)&#xA;$$&lt;/span&gt;&#xA;is just too big &lt;span class=&quot;math-container&quot;&gt;$(&amp;gt; 10^5)$&lt;/span&gt;, and the reason for this is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\nabla_\theta f(\mathbf{x}_1,\mathbf{x}_2,\dots,\mathbf{x}_N,\theta_k) = \sum_{i=1}^{N} \nabla_\theta J(\mathbf{x}_i,\theta_k)&#xA;$$&lt;/span&gt;&#xA;When &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is large, &lt;span class=&quot;math-container&quot;&gt;$\nabla_\theta f(\mathbf{x}_1,\mathbf{x}_2,\dots,\mathbf{x}_N,\theta_k)$&lt;/span&gt; is large regardless of how small each of the gradient terms are. Although the secant method update rule above deals with large gradients through the fraction, I've observed cases where large gradients caused problems. To make the gradient small, I've tried modifying the cost function as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f(\mathbf{x}_1,\mathbf{x}_2,\dots,\mathbf{x}_N,\theta) = \frac{1}{N^\ell} \sum_{i=1}^{N} J(\mathbf{x}_i,\theta)&#xA;$$&lt;/span&gt;&#xA;For different exponents &lt;span class=&quot;math-container&quot;&gt;$\ell = 1,2,...$&lt;/span&gt;. This has worked reasonably well, but I was wondering if there are other well-known (or better) monotonically increasing functions that can be applied to &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf{x}_1,\mathbf{x}_2,\dots,\mathbf{x}_N,\theta)$&lt;/span&gt; to make its gradients smaller.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastActivityDate="2021-10-18T22:54:07.557" Title="What are some nice monotonically increasing functions that limit gradients?" Tags="|optimization|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7145" PostTypeId="1" AcceptedAnswerId="7159" CreationDate="2021-10-19T12:10:23.660" Score="4" ViewCount="2865" Body="&lt;p&gt;I need to use Pyomo with Ipopt solver on Google-Colab.&lt;/p&gt;&#xA;&lt;p&gt;In order to install it I did as follows:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/8D0Ym.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8D0Ym.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now I need to use it , I get the following error ?&#xA;&lt;strong&gt;ApplicationError: No executable found for solver 'ipopt'&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/whPHo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/whPHo.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I resolve it ?&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2023-06-21T05:27:26.490" Title="How to install Ipopt on Google Colab for Pyomo?" Tags="|optimization|pyomo|ipopt|googlecolab|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7146" PostTypeId="2" ParentId="3991" CreationDate="2021-10-19T13:03:32.353" Score="1" Body="&lt;p&gt;In GAMS, you are not allowed to perform a sum in the same set as the one the equation is defined.&lt;/p&gt;&#xA;&lt;p&gt;The answer by Optimization team is correct, although it has a small mistake in the formulation.&lt;/p&gt;&#xA;&lt;p&gt;For this case:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;EQ(h)..    e(h) =E= e(&amp;quot;0&amp;quot;) - sum(t$(ord(t) le ord(h)), pd(t)) + n*sum(t$(ord(t) le ord(h)), pc(t));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or, if you put the sums together:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;EQ(h)..    e(h) =E= e(&amp;quot;0&amp;quot;) + sum(t$(ord(t) le ord(h)), n*pc(t) - pd(t)); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7381" LastEditorUserId="7381" LastEditDate="2021-10-19T14:06:40.453" LastActivityDate="2021-10-19T14:06:40.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7147" PostTypeId="2" ParentId="6175" CreationDate="2021-10-19T14:02:40.577" Score="2" Body="&lt;p&gt;The quickest way to study this is to use Generalized Disjunctive Programming.&lt;/p&gt;&#xA;&lt;p&gt;If we use disjunctions to formulate the problem, we get:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ min/max \quad z=f(x)\\ \begin{bmatrix} Y_1 \\ x_1 = a \\ x_2 \geq c\\x_3 \geq d \end{bmatrix} \veebar \begin{bmatrix} Y_2 \\ x_1 = b·x_3  \\ x_2 \geq c\\0\leq x_3 \leq d \end{bmatrix} \veebar \begin{bmatrix} Y_3 \\ x_1 = 0  \\ x_2 \leq c\\ \end{bmatrix} \veebar \begin{bmatrix} Y_4 \\ x_1 = 0  \\ x_3 \leq 0\\ \end{bmatrix}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$Y_1, ... Y_4$&lt;/span&gt;, are Boolean variables that represent the disjunctions.&lt;/p&gt;&#xA;&lt;p&gt;What Johan answered is perfectly correct, since it is the Big-M formulation for this GDP problem. I am just gonna add the Convex Hull formulation, which for linear problems tends (not always) to produce a tighter feasible region.&lt;/p&gt;&#xA;&lt;p&gt;First you have to disaggregate the variables. Let's assume that the set of disjunctions is &lt;span class=&quot;math-container&quot;&gt;$i\in \{1,2,3,4\}$&lt;/span&gt;, we dissagregate variables &lt;span class=&quot;math-container&quot;&gt;$x_1,...x_4$&lt;/span&gt; into &lt;span class=&quot;math-container&quot;&gt;$x_1^i, ..., x_4^i$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_i x_1^i = x_1\\\sum_i x_2^i = x_2\\\sum_i x_3^i = x_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, consider a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; that will have a value of 1 if disjunction &lt;span class=&quot;math-container&quot;&gt;$Y_i$&lt;/span&gt; is active and 0 otherwise.&lt;/p&gt;&#xA;&lt;p&gt;We also need limits for all degrees of freedom. But normally it is good to have limits for all the variables. These parameters will be called &lt;span class=&quot;math-container&quot;&gt;$\overline{x_1},\overline{x_3},\overline{x_3}$&lt;/span&gt; for the upper bounds and  &lt;span class=&quot;math-container&quot;&gt;$\underline{x_1},\underline{x_3},\underline{x_3}$&lt;/span&gt; for the lower bounds.&lt;/p&gt;&#xA;&lt;p&gt;The whole formulation would therefore be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ min/max \qquad z = f(x) \\ \sum_i x_1^i = x_1\\\sum_i x_2^i = x_2\\\sum_i x_3^i = x_3 \\ x_1^1 = ay_1 \\ x_2^1 \geq cy_1 \\ x_3^1 \geq dy_1&#xA;\\ x_1^2 = bx_3^2 \\ x_2^2 \geq cy_2 \\ x_3^2 \geq 0 \\ x_3^2 \leq dy_2&#xA;\\ x_1^3 = 0 \\ x_2^3 \leq cy_3&#xA;\\ x_1^4 = 0 \\ x_3^4 \leq 0 &#xA;\\ \underline{x_1} y_i\leq x_1^i \leq \overline{x_1}y_i \qquad \forall i&#xA;\\ \underline{x_2} y_i\leq x_2^i \leq \overline{x_2}y_i \qquad \forall i&#xA;\\ \underline{x_3} y_i\leq x_3^i \leq \overline{x_3}y_i \qquad \forall i&#xA;\\ \underline{x_4} y_i\leq x_4^i \leq \overline{x_4}y_i \qquad \forall i&#xA;\\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And it is missing the logic constraints for the binaries. Since it is an exclusive OR, we have to add the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_i y_i = 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are some redundancies there in the constraints, but it is the tightest convex envelope that can be generated for this problem.&lt;/p&gt;&#xA;&lt;p&gt;However, you have to also notice that, if the disjunctions are not continuous (This meaning, &lt;span class=&quot;math-container&quot;&gt;$Y_2$&lt;/span&gt; gives a different result for &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$x_3=d$&lt;/span&gt; than &lt;span class=&quot;math-container&quot;&gt;$Y_1$&lt;/span&gt; does, for example), it will be able to choose any of the two disjunctions indistinctively. This may be the intended behavior, of course.&lt;/p&gt;&#xA;" OwnerUserId="7381" LastActivityDate="2021-10-19T14:02:40.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7148" PostTypeId="2" ParentId="7128" CreationDate="2021-10-19T16:54:08.500" Score="3" Body="&lt;p&gt;Yes, this can be done in pyomo. Pyomo implements &lt;code&gt;ConcreteModel()&lt;/code&gt; as a &lt;code&gt;Block()&lt;/code&gt; object, so you could just place one over the other. Thus, merging two models is quite straightforward. You'll have to define the objective separately. Here's how to do it:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.environ import *&#xA;&#xA;model1 = ConcreteModel()&#xA;model1.constraint1 = ...&#xA;model1.constraint2 = ... # model1's constraint expr&#xA;model1.obj = ... # model1 objective &#xA;&#xA;...&#xA;&#xA;model2 = ConcreteModel()&#xA;model2.constraint1 = ... &#xA;model2.constraint2 = ... # model2's constraint expr&#xA;model2.obj = ... # model2 objective&#xA;&#xA;... &#xA;&#xA;merged_model = ConcreteModel()&#xA;merged_model.model1 = model1. # This step will copy all components of model1 in merged_model &#xA;merged_model.model2 = model2  # This step will copy all components of model2 in merged_model&#xA;merged_model.model1.obj.deactivate()&#xA;merged_model.model2.obj.deactivate()&#xA;merged_model.obj = ... # merged_model_objective_expr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Pretty clean right!? You could verify if all constraints were copied successfully by viewing the constraints in &lt;code&gt;merged_model&lt;/code&gt; using:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in merged_model.component_objects(Constraint):&#xA;    print(i)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4116" LastActivityDate="2021-10-19T16:54:08.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7149" PostTypeId="1" CreationDate="2021-10-20T07:32:11.707" Score="2" ViewCount="1578" Body="&lt;p&gt;Is there a way to monitor the value of the &lt;code&gt;mipgap&lt;/code&gt; while running an optimization model Pyomo? I would like to know how far I am from the optimality gap. Here is my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solver = SolverFactory('cbc', executable='path/to/cbc.exe')&#xA;solver.options['mipgap'] = 1e-3&#xA;solver.options['tee'] = True&#xA;solver.options['keepfiles'] = True&#xA;results = solver.solve(Model, logfile='path/to/logfile.log')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I can report the last value of mipgap AFTER solver is finished as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;__data = results.Problem._list&#xA;&#xA;LB = __data[0].lower_bound&#xA;UB = __data[0].upper_bound&#xA;__gap = abs(UB - LB) * 100/max(0.1, abs(UB))&#xA;print(__gap)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But this is not what I am looking for. I am looking for a sort of live streaming from &lt;code&gt;solver&lt;/code&gt; which updates me about the current value of the &lt;code&gt;mipgap&lt;/code&gt;; then I can determine how far I am from the optimality; or whether there is any progress in the model.&lt;/p&gt;&#xA;" OwnerUserId="7383" LastActivityDate="2021-10-27T16:57:19.117" Title="Pyomo mipgap status monitoring" Tags="|pyomo|optimality-gap|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7150" PostTypeId="1" AcceptedAnswerId="7151" CreationDate="2021-10-20T07:44:20.757" Score="6" ViewCount="158" Body="&lt;p&gt;I am willing to bet that the problem most often used to teach students about branch-and-cut is the Travelling Salesman Problem (TSP).&#xA;It has a number of nice characteristics which make it appropriate for this task:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The problem itself is easy to explain and understand, its formulation requires little notation, it is trivial to come up with feasible solutions and to experiment with intuitive heuristics.&lt;/li&gt;&#xA;&lt;li&gt;There are at least two easy-to-explain formulations for the problem. The MTZ formulation is useful in showing how big-M constraints work. The DFJ formulation can be used to introduce (row-)extended formulations in general. Furthermore, there is an easy proof that the DFJ formulation is tighter than the MTZ. In short, it offers a lot of possible &amp;quot;learning moments&amp;quot;.&lt;/li&gt;&#xA;&lt;li&gt;There are also multiple ways to introduce branch-and-cut for the TSP. One can start with the &amp;quot;integer version&amp;quot;: separating subtour-elimination constraints for infeasible integer solutions only. Because such infeasibility can be found by inspection, this is also very easy to implement in lab classes. Next, one can talk about separation in the fractional case. This again provides other learning opportunities (Max-flow problem, Min-cut problem, duality, unimodularity, etc) and implementation challenges.&lt;/li&gt;&#xA;&lt;li&gt;It allows to introduce the concept of valid inequalities (VIs), exact and heuristic separation for VIs, faced-defining inequalities, etc. It also have an extensive library of well-understood inequalities (comb, etc).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I was wondering whether someone has ideas about other problems which share at least some of these characteristics with the TSP and can, thus, be given to students as additional material, homework material, etc.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2021-10-20T09:47:11.217" Title="Naturally branch-and-cuttable problems with high didactic value" Tags="|branch-and-cut|teaching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7151" PostTypeId="2" ParentId="7150" CreationDate="2021-10-20T09:47:11.217" Score="4" Body="&lt;p&gt;The knapsack problem. Obviously not the best way to solve it (through branch and cut) but it has many of the same characteristics as the TSP:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It's easy to understand&lt;/li&gt;&#xA;&lt;li&gt;It's easy to construct reasonably good heuristics&lt;/li&gt;&#xA;&lt;li&gt;Separating cover inequalities exactly is another knapsack problem (so we can naturally discuss separation vs optimization)&lt;/li&gt;&#xA;&lt;li&gt;Cover inequalities are easy to understand and easy to strengthen by extending the cover&lt;/li&gt;&#xA;&lt;li&gt;You may introduce lifting of the cover cut by introducing general lifted cover inequalities.&lt;/li&gt;&#xA;&lt;li&gt;Heuristically separating cover inequalities can be done using the heuristic invented/used in 2.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="278" LastActivityDate="2021-10-20T09:47:11.217" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7152" PostTypeId="1" AcceptedAnswerId="7154" CreationDate="2021-10-20T18:12:44.547" Score="4" ViewCount="3052" Body="&lt;p&gt;This might be a very basic question for this community. I am reading an article and I think I have some confusion about formulating a problem.  My understanding is that all decision variables should be present in the objective function. For any continuous function, the first derivative of the function is zero at the minima or maxima and the value of the variable for which we get the derivative equal to zero is the solution of the problem. However, the article I am reading formulated the problem as follows where some decision variables are present only in the constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BZwKt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BZwKt.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The decision variables are &lt;span class=&quot;math-container&quot;&gt;$x_a$&lt;/span&gt; ,&lt;span class=&quot;math-container&quot;&gt;$v_\pi$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$y_s$&lt;/span&gt;. However, only &lt;span class=&quot;math-container&quot;&gt;$x_a$&lt;/span&gt; is present in the objective function. Is it because the coefficients of the absent decision variables might be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; in the objective function? If we modify the problem and add the constraints to the objective function like the Lagrange method we will be able to include all variables.&lt;/p&gt;&#xA;&lt;p&gt;I would really appreciate any comments and answers.&lt;/p&gt;&#xA;" OwnerUserId="3288" LastEditorUserId="3288" LastEditDate="2021-10-20T19:07:03.433" LastActivityDate="2021-10-20T19:19:03.313" Title="Should all decision variables be present in Objective function?" Tags="|linear-programming|nonlinear-programming|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7153" PostTypeId="2" ParentId="7152" CreationDate="2021-10-20T18:26:51.080" Score="5" Body="&lt;h3&gt;NO&lt;/h3&gt;&#xA;&lt;p&gt;Not all decision variables need to be present in the objective. They can be often used to handle constraints or express other things. Consider this simple problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x,y_1,y_2,y_3,y_4,y_5 \in \mathbb{N}} x \text{ subject to }$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\forall i \in \{1,2,3,4,5\}: \ 0 \leq  y_i \leq x$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_1+y_2+y_3+y_4+y_5 = 12$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Which might answer the question how much people should come in every week day, when we need to reserve a parking spot for them but only can book parking spots for the complete week.&lt;/p&gt;&#xA;&lt;p&gt;In this case how many people come in each day is a decision, but they don't appear in the objective because we only care about how many we need at most on a single day as we would need to book that many parking spots for the week.&lt;/p&gt;&#xA;&lt;p&gt;Note that if a variable appears in the constraints and in the objective they have the same value.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If we modify the problem and add the constraints to the objective function like the Lagrange method we will be able to include all variables.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You are correct that this is an approach to solve problems, however it enforcing integrality (some decision variable being an integer) is a constraint that is hard to enforce. In general for many constraints it is advisable to handle them separately and not put them in the objective to better exploit structure.   Putting constraints in the objective can turn problems non-linear or non convex, so a global non-linear optimizer would be needed to give guarantees about the quality of the solution which is often more computationally expensive than handling the constraints separately.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-10-20T18:33:46.700" LastActivityDate="2021-10-20T18:33:46.700" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7154" PostTypeId="2" ParentId="7152" CreationDate="2021-10-20T18:36:35.137" Score="9" Body="&lt;p&gt;This answer complements that by @worldsmithhelper .&lt;/p&gt;&#xA;&lt;p&gt;Not only does an objective function not have to include all the decision variables, it need not include any of them. An &amp;quot;optimization&amp;quot; problem having a constant (zero) objective function, which is equivalent to not having an objective function, is called a feasibility problem.&lt;/p&gt;&#xA;&lt;p&gt;Your understanding of the optimality conditions is incorrect when there are constraints. When there are constraints (and suitable differentiability and constraint qualification), the first order optimality conditions are the &lt;a href=&quot;https://en.wikipedia.org/wiki/Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions&quot; rel=&quot;noreferrer&quot;&gt;Karush–Kuhn–Tucker (KKT) conditions&lt;/a&gt;, which tie together the gradients of the objective and constraints. In unconstrained problems, the KKT conditions reduce to the condition with which you are familiar; namely, that the gradient of the objective function equals zero.&lt;/p&gt;&#xA;&lt;p&gt;Edit:&lt;strong&gt;Any optimization problem can be transformed, via an epigraph formulation, to an equivalent problem containing only one decision variable in the objective function&lt;/strong&gt;. This is accomplished by introducing a new decision variable, &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, making &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; the objective function, keeping all the original constraints and decision variables, while (in the case of minimization), adding an additional constraint, &lt;span class=&quot;math-container&quot;&gt;$\text{original_objective_function} \le t$&lt;/span&gt;. By virtue of the minimization, at an optimal solution, &lt;span class=&quot;math-container&quot;&gt;$t = \text{original_objective_function}$&lt;/span&gt;, hence making the transformation correct.  Everything is the same for maximization, except the added constraint is &lt;span class=&quot;math-container&quot;&gt;$\text{original_objective_function} \ge t$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2021-10-20T19:19:03.313" LastActivityDate="2021-10-20T19:19:03.313" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7156" PostTypeId="1" CreationDate="2021-10-21T06:48:34.073" Score="2" ViewCount="151" Body="&lt;p&gt;I have investigated the literature, but I could not find proper explanations. As we know, (meta-)heuristics try to explore promising regions of optimality. The regions are then exploited.&lt;/p&gt;&#xA;&lt;p&gt;What is the definition of the promising regions in (meta-)heuristic optimization? How can we determine whether the algorithm is in the promising region or not, especially for the problems with unknown optima?&lt;/p&gt;&#xA;&lt;p&gt;My idea is only that if the algorithm shows continuous improvement, we can say that the region is found. But I am not sure if my idea is totally correct.&lt;/p&gt;&#xA;" OwnerUserId="7234" LastEditorUserId="123" LastEditDate="2021-10-21T09:36:36.080" LastActivityDate="2021-10-21T09:36:36.080" Title="Promising regions in optimization" Tags="|optimization|metaheuristics|optimality-conditions|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7157" PostTypeId="2" ParentId="7156" CreationDate="2021-10-21T09:05:17.007" Score="4" Body="&lt;p&gt;The concept of promising regions (unlike many other concepts in optimization) doesn't have a mathematical definition. It is more an analogy people use to justify why exploring some¹ neighborhood of good solutions leads in practice to other good solutions in particular in derivative free optimization.&lt;/p&gt;&#xA;&lt;p&gt;Different algorithms that exploit promising regions also exploit different things. The crossover heuristic in evolutionary algorithms which combines components of two solutions finds the result promising because assuming the objective is separable in those variables the new assignment is going to have a low value in the separate objectives². Particle Swarm Optimization instead suggest that the space between the best know and the current position of a particle is likely to yield improvements but the local optima close to the particle it knows about also should be exploited.&lt;/p&gt;&#xA;&lt;p&gt;¹&lt;sub&gt;by some I mean it doesn't have to be close with regards to &lt;span class=&quot;math-container&quot;&gt;$\|\cdot\|_2$&lt;/span&gt; or a similar metric as the crossover example shows&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;²&lt;sub&gt;Assume we minimize &lt;span class=&quot;math-container&quot;&gt;$f(x,y)=g(x)+h(y)$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_1,y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2,y_2$&lt;/span&gt; are good but &lt;span class=&quot;math-container&quot;&gt;$g(x_1)&amp;lt;g(x_2)$&lt;/span&gt; but &lt;span class=&quot;math-container&quot;&gt;$h(y_1)&amp;gt;h(y_2)$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_1,y_2$&lt;/span&gt; is going to be better. In practice this separability is not known by evolutionary algorithm but if &lt;span class=&quot;math-container&quot;&gt;$x_1,y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2,y_2$&lt;/span&gt; stay successful in the next generation because the worse &lt;span class=&quot;math-container&quot;&gt;$x_2,y_1$&lt;/span&gt; was generated there is again a 50% chance of &lt;span class=&quot;math-container&quot;&gt;$x_1,y_2$&lt;/span&gt; being generated.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="123" LastEditDate="2021-10-21T09:36:20.313" LastActivityDate="2021-10-21T09:36:20.313" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7158" PostTypeId="1" CreationDate="2021-10-21T14:36:35.157" Score="4" ViewCount="181" Body="&lt;p&gt;Suppose we do have a set of points (all on a plane ).&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How to find the smallest hull containing all these points ?&lt;/li&gt;&#xA;&lt;li&gt;How to find the points (among these given points) that are at the exterior layers of all these points ?&lt;/li&gt;&#xA;&lt;li&gt;Is there any MILP formulation for this purpose ?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ewEzy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ewEzy.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4777" LastEditDate="2021-10-21T15:27:11.977" LastActivityDate="2021-11-05T14:51:21.687" Title="How to find the point on the exterior of a given set of points?" Tags="|optimization|modeling|convex-optimization|binary-variable|nonconvex-programming|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7159" PostTypeId="2" ParentId="7145" CreationDate="2021-10-21T14:50:45.447" Score="6" Body="&lt;p&gt;The following package installation should be done before staring the Pyomo model&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;!pip install pyomo &#xA;from pyomo.environ import *&#xA;import matplotlib.pyplot as plt&#xA;!wget -N -q &amp;quot;https://matematica.unipv.it/gualandi/solvers/ipopt-linux64.zip&amp;quot;&#xA;!unzip -o -q ipopt-linux64&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then you can run your &lt;strong&gt;NLP&lt;/strong&gt; model&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = AbstractModel()&#xA;model.x = Var(bounds=(0,1.2), within=Reals)&#xA;model.obj1 = Objective(expr=model.x**2, sense=maximize)&#xA;#opt = SolverFactory('ipopt')&#xA;opt=SolverFactory('ipopt', executable='/content/ipopt')&#xA;instance = model.create_instance()&#xA;results = opt.solve(instance) # solves and updates instance&#xA;print('OF= ',value(instance.obj1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="171" LastEditDate="2023-02-22T12:37:47.980" LastActivityDate="2023-02-22T12:37:47.980" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7160" PostTypeId="2" ParentId="7158" CreationDate="2021-10-21T15:40:58.280" Score="0" Body="&lt;p&gt;You can adapt the algorithm gift wrapping algorithm for finding a convex hull to this problem. This algorithm has an explicit step where it &amp;quot;straightens&amp;quot; out the cavities you want. This can be prevented by adding an additional condition that this is only allowed to happen if the new point is more left (as is done when constructing a convex hull) and closer than the proposed point (this is to prevent that the proposed point removed if it is the leftmost at his distance). This algorithm will give you the edges of the hull set. I am not aware of many LP or MILP formulations and find that approach quiet unsuited.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-10-21T15:40:58.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7162" PostTypeId="2" ParentId="7149" CreationDate="2021-10-22T08:50:03.057" Score="4" Body="&lt;p&gt;&lt;strong&gt;Short answer&lt;/strong&gt;: Add this line - &lt;code&gt;solver.options['slog'] = 1&lt;/code&gt;, before calling the solve method.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Detailed answer&lt;/strong&gt;: In terms of logging, a user needs to pass two arguments to the solver in order to obtain the required. The first argument is &lt;code&gt;tee=True&lt;/code&gt; that enables the solver logs and the second argument is &lt;code&gt;slog=1&lt;/code&gt; that defines the logging level. MIP-gap is logged at the &lt;code&gt;info&lt;/code&gt; level but the default setting is &lt;code&gt;warning&lt;/code&gt;. So, when you override the default logging level on the solver with the argument &lt;code&gt;slog&lt;/code&gt;, you get to see those details.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://manpages.ubuntu.com/manpages/bionic/man1/cbc.1.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; page and some digging inside &lt;a href=&quot;https://github.com/coin-or/Cbc&quot; rel=&quot;nofollow noreferrer&quot;&gt;cbc's github&lt;/a&gt; helped me figure that out.&lt;/p&gt;&#xA;" OwnerUserId="4116" LastActivityDate="2021-10-22T08:50:03.057" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7163" PostTypeId="1" AcceptedAnswerId="7165" CreationDate="2021-10-22T08:52:07.427" Score="3" ViewCount="65" Body="&lt;p&gt;When assigning jobs (or tasks or projects) to a starting time, with a ready and due time for each job, there are different scenarios:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A) &lt;strong&gt;Front loading&lt;/strong&gt;: Assign all jobs as soon as possible. As close as possible to their ready time. For example, we need build 5 red cars before the end of year, so we could them now in October or wait until November or December. With Front loading, we'll build them now in October, unless there's a more urgent order (for example to build blue cars this month), which would push them out to November.&lt;/li&gt;&#xA;&lt;li&gt;B) Assign all jobs on their ideal execution time. For example, we need to clean a house once every 7 days. We cleaned it yesterday. We could clean it again today, but that will just mean we have to clean it sooner next week. Ideally, we wait 6 days (no more, no less) to clean it. But it's fine if there's sometimes a few more or less days between the cleaning, due to other more priority jobs.&lt;/li&gt;&#xA;&lt;li&gt;C) &lt;em&gt;Back loading?&lt;/em&gt;: Assign all jobs as late as possible. As close as possible to their due time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;What the canonical terminology for B) and C)?&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-10-22T11:15:14.723" Title="What are the alternatives to front loading of jobs/tasks/projects?" Tags="|job-shop-scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7164" PostTypeId="1" CreationDate="2021-10-22T09:40:56.017" Score="2" ViewCount="150" Body="&lt;p&gt;I have defined a problem which will minimize the cost of to run a pump. That is defined as the objective of the problem.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cost_cp = cp.sum(cp.multiply(cost_,selection))&#xA;objective = cp.Minimize(cost_cp)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The problem defined is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;problem = cp.Problem(objective, constraints)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have ran calculations using the &lt;code&gt;cp.multiply&lt;/code&gt; and &lt;code&gt;cp.vec&lt;/code&gt; to calculate the difference in reservoir volumes which provides my the answer I would expect with the correct differences.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;flow_in = cp.vec(cp.multiply(input_flow_, flow_in_minutes))&#xA;flow_out = cp.vec(flow_out_)&#xA;flow_diff = flow_in - flow_out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The problem arises when I calculated an accumulative summation using &lt;code&gt;cp.cumsum&lt;/code&gt;. It works and calculates correctly, but when I wish to add constraints around this is provides me with the &lt;code&gt;DCPError&lt;/code&gt;, I am unsure where I am going wrong in such calculation as it has worked previously no problem for me.&lt;/p&gt;&#xA;&lt;p&gt;The constraints I wish to define are:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;volume_constraint = volume_cp &amp;gt;= 300000&#xA;min_level_constraint = res_level &amp;gt;= min_level&#xA;max_level_constraint = res_level &amp;lt;= max_level&#xA;&#xA;constraints = [assignment_constraint, volume_constraint, min_level_constraint, max_level_constraint]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;code&gt;volume_constraint&lt;/code&gt; works perfectly. The problem is with the &lt;code&gt;min_level_constraint&lt;/code&gt; and &lt;code&gt;max_level_constraint&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I attempt a solution using&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;problem.solve(solver=cp.CPLEX, verbose=False)  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A traceback in which I am provided with is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;DCPError                                  Traceback (most recent call last)&#xA;~\AppData\Local\Temp/ipykernel_14560/1602474026.py in &amp;lt;module&amp;gt;&#xA;     33 &#xA;     34 # Problem solve&#xA;---&amp;gt; 35 problem.solve(solver=cp.CPLEX, verbose=False)&#xA;&#xA;~\AppData\Local\Programs\Python\Python38\lib\site-packages\cvxpy\problems\problem.py in solve(self, *args, **kwargs)&#xA;    457         else:&#xA;    458             solve_func = Problem._solve&#xA;--&amp;gt; 459         return solve_func(self, *args, **kwargs)&#xA;    460 &#xA;    461     @classmethod&#xA;&#xA;~\AppData\Local\Programs\Python\Python38\lib\site-packages\cvxpy\problems\problem.py in _solve(self, solver, warm_start, verbose, gp, qcp, requires_grad, enforce_dpp, **kwargs)&#xA;    936                 return self.value&#xA;    937 &#xA;--&amp;gt; 938         data, solving_chain, inverse_data = self.get_problem_data(&#xA;    939             solver, gp, enforce_dpp, verbose)&#xA;    940 &#xA;&#xA;~\AppData\Local\Programs\Python\Python38\lib\site-packages\cvxpy\problems\problem.py in get_problem_data(self, solver, gp, enforce_dpp, verbose)&#xA;    563         if key != self._cache.key:&#xA;    564             self._cache.invalidate()&#xA;--&amp;gt; 565             solving_chain = self._construct_chain(&#xA;    566                 solver=solver, gp=gp, enforce_dpp=enforce_dpp)&#xA;    567             self._cache.key = key&#xA;&#xA;~\AppData\Local\Programs\Python\Python38\lib\site-packages\cvxpy\problems\problem.py in _construct_chain(self, solver, gp, enforce_dpp)&#xA;    789         candidate_solvers = self._find_candidate_solvers(solver=solver, gp=gp)&#xA;    790         self._sort_candidate_solvers(candidate_solvers)&#xA;--&amp;gt; 791         return construct_solving_chain(self, candidate_solvers, gp=gp,&#xA;    792                                        enforce_dpp=enforce_dpp)&#xA;    793 &#xA;&#xA;~\AppData\Local\Programs\Python\Python38\lib\site-packages\cvxpy\reductions\solvers\solving_chain.py in construct_solving_chain(problem, candidates, gp, enforce_dpp)&#xA;    153     if len(problem.variables()) == 0:&#xA;    154         return SolvingChain(reductions=[ConstantSolver()])&#xA;--&amp;gt; 155     reductions = _reductions_for_problem_class(problem, candidates, gp)&#xA;    156 &#xA;    157     dpp_context = 'dcp' if not gp else 'dgp'&#xA;&#xA;~\AppData\Local\Programs\Python\Python38\lib\site-packages\cvxpy\reductions\solvers\solving_chain.py in _reductions_for_problem_class(problem, candidates, gp)&#xA;     89             append += (&amp;quot;\nHowever, the problem does follow DQCP rules. &amp;quot;&#xA;     90                        &amp;quot;Consider calling solve() with `qcp=True`.&amp;quot;)&#xA;---&amp;gt; 91         raise DCPError(&#xA;     92             &amp;quot;Problem does not follow DCP rules. Specifically:\n&amp;quot; + append)&#xA;     93     elif gp and not problem.is_dgp():&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have looked around the documentation on CVXPY and on Stack Overflow but I have found nothing in which works for my problem. I am baffled as it has worked for me in the past.&lt;/p&gt;&#xA;" OwnerUserId="7396" LastEditorUserId="68" LastEditDate="2021-10-22T17:05:32.133" LastActivityDate="2021-10-22T17:05:32.133" Title="Constraint raises DCP Error" Tags="|optimization|python|cplex|cvxpy|disciplined-convex-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7165" PostTypeId="2" ParentId="7163" CreationDate="2021-10-22T11:15:14.723" Score="2" Body="&lt;p&gt;In the scheduling literature, there are some concepts to define a sequence/schedule plan. Optimal, non-delay, active, and semi-active schedule. W.r.t this and how you would change a sequence into a schedule, also, there are some rules so-called &lt;a href=&quot;https://www.sciencedirect.com/topics/computer-science/dispatching-rule&quot; rel=&quot;nofollow noreferrer&quot;&gt;dispatching rules&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Indeed, what you are looking for sounds like, forward scheduling, JIT scheduling, and backward scheduling respectively.&lt;/p&gt;&#xA;&lt;p&gt;For more details: Scheduling: Theory, Algorithms, and system by Pinedo, Michael L.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-10-22T11:15:14.723" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="7167" PostTypeId="2" ParentId="7164" CreationDate="2021-10-22T13:31:42.227" Score="2" Body="&lt;p&gt;After a few hours extra deliberation and and working on the problem, I was able to figure out the reason.&lt;/p&gt;&#xA;&lt;p&gt;It was as I thought initially and my calculation for my &lt;code&gt;flow_in&lt;/code&gt; wasn't DCP and I am not entirely sure or understand why, but I will be definitely teaching myself this in the time going forward.&lt;/p&gt;&#xA;&lt;p&gt;I was able to adjust the calculation to look like the following if anyone comes across something like this in the future, and can see how my calculations changed in the question versus the answer.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;flow_in = cp.sum(cp.multiply(volume_,selection),axis=1)&#xA;flow_out = cp.vec(flow_out_) # Value in litres -&amp;gt; must convert to a volume&#xA;flow_diff = (flow_in - flow_out) / 1000&#xA;res_level = cp.cumsum(flow_diff) / 160.6 + 2.3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7396" LastActivityDate="2021-10-22T13:31:42.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7168" PostTypeId="1" AcceptedAnswerId="7171" CreationDate="2021-10-22T13:53:28.693" Score="4" ViewCount="118" Body="&lt;p&gt;In the mathematical optimization theory, I have taken a glance at many papers which deal with the unconstrained convex-concave or nonconvex-concave minimax optimization, i.e.,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{x\in X}\ \max_{y\in Y}\ f(x,y),&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the function &lt;span class=&quot;math-container&quot;&gt;$f\colon X\times Y\to \Re$&lt;/span&gt; is nonconvex and nonconcave w.r.t. x and y, respectively, and also is continuously differentiable (ONLY ONCE), and the sets &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; are convex on the Euclidean space.&lt;/p&gt;&#xA;&lt;p&gt;However, I cannot find a paper that treats convex-constrained nonconvex-nonconcave minimax problem.&#xA;So, for such problems, I want to ask that&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Do you know an algorithm that guarantees global convergence*?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;* I mean &amp;quot;global convergence&amp;quot; that has certain properties such as first order optimality.&lt;/p&gt;&#xA;&lt;p&gt;I have also searched from the perspective of the semi-infinite programming.&#xA;This is because this minimax problem can be reformulated as follows by the epigraphical expression:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{cl}&#xA;\displaystyle\min_{x\in X, x_0} &amp;amp; x_0\\&#xA;\text{subject to} &amp;amp; x_0\geq f(x,y)\quad\forall y\in Y.&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But in this field of studies also, many studies assume convexity of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; or sufficient smoothness of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I do NOT require the efficiency of computation.&#xA;I want to implement an algorithm that is &lt;strong&gt;surely convergent&lt;/strong&gt; to some points, not necessarily converges to a global optimal (saddle) point.&lt;/p&gt;&#xA;" OwnerUserId="5821" LastEditorUserId="491" LastEditDate="2022-10-15T11:22:44.493" LastActivityDate="2022-10-15T11:22:44.493" Title="Convex-Constrained Nonconvex-Nonconcave Minimax Problem" Tags="|nonlinear-programming|nonconvex-programming|duality|minimax|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7169" PostTypeId="1" AcceptedAnswerId="7170" CreationDate="2021-10-22T14:28:51.527" Score="5" ViewCount="1057" Body="&lt;p&gt;I am trying to estimate the order-up-to level of inventory, &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt;, according to ref [1]&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_t = \hat{D}_t^L + z \hat{\sigma}^L_{et}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\hat{D}_t^L$&lt;/span&gt; is an estimate of the mean lead-time demand, &lt;span class=&quot;math-container&quot;&gt;$\hat{\sigma}^L_{et}$&lt;/span&gt; is n estimate of the standard deviation of the &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; period forecast error, and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is a constant chosen to meet a desired service level. Assume that the retailer uses moving average to estimate &lt;span class=&quot;math-container&quot;&gt;$\hat{D}_t^L$&lt;/span&gt; based on the demand observations from the previous &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; periods, then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\hat{D}_{t}^{L}=L\left(\frac{\sum_{i=1}^{p} D_{t-i}}{p}\right)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;According to this equation, the estimated mean lead-time demand seems to only cover the demand during the lead time.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, I checked out the definition from Lokad Quantitative Supply Chain[2], &amp;quot;&lt;em&gt;The lead demand (also called lead time demand) is the total demand between now and the anticipated time for the delivery after the next one if a reorder is made now to replenish the inventory.&lt;/em&gt;&amp;quot; &lt;strong&gt;This seems to mean that the mean lead-time demand should cover the demand during the lead time in this period plus the demand during the next period&lt;/strong&gt;. This definition makes sense because assuming the safety stock factor is zero, the estimated order-up-to level is equal to the estimated lead-time demand, which should cover the demand from the current reorder time to the delivery time after the next one.&lt;/p&gt;&#xA;&lt;p&gt;Can anyone help to clarify the definition of lead-time demand?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;[1] Chen, F., Drezner, Z., Ryan, J. K., &amp;amp; Simchi-Levi, D. (2000). Quantifying the bullwhip effect in a simple supply chain: The impact of forecasting, lead times, and information. Management science, 46(3), 436-443.&lt;/p&gt;&#xA;&lt;p&gt;[2] url: &lt;a href=&quot;https://www.lokad.com/lead-demand-definition&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.lokad.com/lead-demand-definition&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7402" LastEditorUserId="491" LastEditDate="2021-10-26T14:40:56.173" LastActivityDate="2021-10-26T14:40:56.173" Title="Estimate of mean lead time demand" Tags="|inventory|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7170" PostTypeId="2" ParentId="7169" CreationDate="2021-10-22T16:08:06.560" Score="4" Body="&lt;p&gt;The lead-time demand is the cumulative demand in &lt;span class=&quot;math-container&quot;&gt;$L+R$&lt;/span&gt; consecutive periods, where &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is the lead time and &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; is the reorder interval (the number of periods between orders). (At least, that's how we define it in &lt;a href=&quot;https://coral.ise.lehigh.edu/sctheory/&quot; rel=&quot;nofollow noreferrer&quot;&gt;our book&lt;/a&gt;, and I think that definition is consistent with other usages elsewhere.) Often &lt;span class=&quot;math-container&quot;&gt;$R=1$&lt;/span&gt; and the lead-time demand is the demand over &lt;span class=&quot;math-container&quot;&gt;$L+1$&lt;/span&gt; periods.&lt;/p&gt;&#xA;&lt;p&gt;In the Chen et al. paper, they use a somewhat non-standard sequence of events, in which the demand is observed &lt;em&gt;before&lt;/em&gt; the order is placed. A lead time of &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; in the Chen sequence of events is effectively like a lead time of &lt;span class=&quot;math-container&quot;&gt;$L-1$&lt;/span&gt; in the &amp;quot;usual&amp;quot; sequence of events (in which you observe the demand &lt;em&gt;after&lt;/em&gt; the order is placed).&lt;/p&gt;&#xA;&lt;p&gt;So, for Chen et al., we have a reorder interval of &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; and an &amp;quot;effective&amp;quot; lead time of &lt;span class=&quot;math-container&quot;&gt;$L-1$&lt;/span&gt;, so the lead-time demand is the demand over &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; periods.&lt;/p&gt;&#xA;&lt;p&gt;I don't know why the website you linked to says &amp;quot;the delivery after the next one&amp;quot;. Maybe they mean &amp;quot;the delivery after the next &lt;em&gt;order&lt;/em&gt;&amp;quot;, i.e., &amp;quot;the next delivery&amp;quot;?&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2021-10-22T16:08:06.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7171" PostTypeId="2" ParentId="7168" CreationDate="2021-10-22T17:04:18.537" Score="2" Body="&lt;p&gt;I got bad news for you: The problem is as long as you care about the inner max being the actual max and not just some local maxima (which might make sense with multiple roll outs for a game theory simulation) you are stuck with calling an global optimizer to just evaluate &lt;span class=&quot;math-container&quot;&gt;$x \mapsto \max_{y_\in Y} f(x,y)$&lt;/span&gt; correctly. If &lt;span class=&quot;math-container&quot;&gt;$\dim(y)$&lt;/span&gt; is small you might want to try interval newton method for the inner, maybe branch and bound with interval arithmetic for the relaxation (unless you can come up with a better relaxation) and if not or there are constraints on &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; use some global NLP solver of your choice to sufficient precision.&lt;/p&gt;&#xA;&lt;p&gt;Maybe you can analytically define gradients for &lt;span class=&quot;math-container&quot;&gt;$x \mapsto \max_{y_\in Y} f(x,y)$&lt;/span&gt; it might be worth evaluating passing those to an local NLP solver like IPOPT, WORHP (worth it if you have 0's in the hessian structure you know about) or FilterSQP  for minimizing &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. If such gradients are not available, &lt;span class=&quot;math-container&quot;&gt;$\dim(x)$&lt;/span&gt; is big you are only left with local NLP solver (now also including COBYLA2) calling the global optimizer really often or black box optimization of &lt;span class=&quot;math-container&quot;&gt;$x \mapsto \max_{y_\in Y} f(x,y)$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$\dim(x)$&lt;/span&gt; is small you could get away with a method that construct a surrogate of &lt;span class=&quot;math-container&quot;&gt;$x \mapsto \max_{y_\in Y} f(x,y)$&lt;/span&gt; which might allow you to call it less often and spent more time picking good points to search instead evaluating bad values (recommend if evaluating &lt;span class=&quot;math-container&quot;&gt;$x \mapsto \max_{y_\in Y} f(x,y)$&lt;/span&gt; takes on the order of second). My first pick for that would be the quiet obscure &lt;a href=&quot;https://github.com/DLR-SC/sqpdfo&quot; rel=&quot;nofollow noreferrer&quot;&gt;sqpdfo&lt;/a&gt; algorithm which constructs a quadratic surrogate what should lead you to a local minima in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It is my understanding that sqpdfo, IPOPT, WORHP and FilterSQP claim to be able to be globally convergent and all handle constraints. If this is not the case then you can just hope that some black box approach (evolutionary algorithms, simulated annealing, particle swarm optimization) would work well enough for you.&lt;/p&gt;&#xA;&lt;p&gt;If there are constraints that both include &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; add those fully to other outer problem and with &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; not occurring in the objective to ensure feasibility of the inner problem and run the global optimization with &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; fixed from the outer problem. The fact that your constraints are convex is not exploited by any approach i presented, however it will make the inner optimization faster and the outer optimization more likely to find something good. Also if you have equality constraints, please see to eliminating as many inner variables as possible.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-10-22T17:30:16.680" LastActivityDate="2021-10-22T17:30:16.680" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7172" PostTypeId="2" ParentId="7169" CreationDate="2021-10-22T19:28:32.223" Score="3" Body="&lt;p&gt;I ran this past a colleague in supply chain management who confirmed my understanding of &amp;quot;demand during lead time&amp;quot; to be the demand that occurs between when a replenishment order is placed and when it arrives. I don't recall seeing it defined to include the demand occurring between orders, and in particular I think that in the (unusual? purely hypothetical?) case of immediate replenishment, the lead time demand is considered to be zero.&lt;/p&gt;&#xA;&lt;p&gt;Regarding &amp;quot;the delivery after the next one&amp;quot;, there are cases where orders overlap (you place a replenishment order and, before it shows up, place another one). As my colleague reminded me, this is usually handled by basing your reorder point on &amp;quot;inventory position&amp;quot;, which includes both on-hand inventory and replenishment orders already made, rather than just on on-hand inventory.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-22T19:28:32.223" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7173" PostTypeId="2" ParentId="7145" CreationDate="2021-10-23T09:06:09.433" Score="5" Body="&lt;p&gt;If your notebook could be executed both on Colab or on a different environment (such as a local Jupyter notebook), you could add a couple of checks, before downloading and reinstalling &lt;code&gt;pyomo&lt;/code&gt; and &lt;code&gt;ipopt&lt;/code&gt; every time, as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import shutil&#xA;import sys&#xA;import os.path&#xA;&#xA;if not shutil.which(&amp;quot;pyomo&amp;quot;):&#xA;    !pip install -q pyomo&#xA;    assert(shutil.which(&amp;quot;pyomo&amp;quot;))&#xA;&#xA;if not (shutil.which(&amp;quot;ipopt&amp;quot;) or os.path.isfile(&amp;quot;ipopt&amp;quot;)):&#xA;    if &amp;quot;google.colab&amp;quot; in sys.modules:&#xA;        !wget -N -q &amp;quot;https://matematica.unipv.it/gualandi/solvers/ipopt-linux64.zip&amp;quot;&#xA;        !unzip -o -q ipopt-linux64&#xA;    else:&#xA;        try:&#xA;            !conda install -c conda-forge ipopt &#xA;        except:&#xA;            pass&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: I have modified the link to ipopt-linux64.zip on Feb. 22nd, 2023. Older binaries of IpOpt are available at &lt;a href=&quot;https://www.coin-or.org/download/binary/Ipopt/&quot; rel=&quot;nofollow noreferrer&quot;&gt;COIN-OR&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thanks to Stefano Coniglio and Pietro Belotti for the support on this.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 2&lt;/strong&gt;: Since it was asked in a comment, you can install GLPK as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if not (shutil.which(&amp;quot;glpk&amp;quot;) or os.path.isfile(&amp;quot;glpk&amp;quot;)):&#xA;    if &amp;quot;google.colab&amp;quot; in sys.modules:&#xA;        !apt-get install -y -qq glpk-utils&#xA;    else:&#xA;        try:&#xA;            !conda install -c conda-forge glpk &#xA;        except:&#xA;            pass&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For other solvers, the process is quite similar (e.g., for CBC).&lt;/p&gt;&#xA;" OwnerUserId="171" LastEditorUserId="171" LastEditDate="2023-03-06T09:56:00.140" LastActivityDate="2023-03-06T09:56:00.140" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7174" PostTypeId="1" AcceptedAnswerId="7175" CreationDate="2021-10-24T13:53:09.483" Score="2" ViewCount="373" Body="&lt;p&gt;I am using Pyomo's concrete model to model a MILP mathematical model, coming from multiproduct pipeline scheduling. Some of our continuous variables are:    &lt;code&gt;w[i,t], R[i,t], D[i,t]&lt;/code&gt;. Fixing the indices i, t, we have the constraint&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;w[i,t] = w[i,t-1]  +  R[i,t]  -D[i,t] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where, in &lt;code&gt;R[i,t]&lt;/code&gt;, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; takes its values from &lt;span class=&quot;math-container&quot;&gt;$ I_R \subset I$&lt;/span&gt; and in D, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; comes from &lt;span class=&quot;math-container&quot;&gt;$ I_D \subset I$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now the problem is that how to model this constraint without &lt;strong&gt;conditional statements&lt;/strong&gt; inside the rule of constraint. As we know, one way is the following code using conditional statement, but I do not want to use it. &lt;strong&gt;Is there any other way?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The rule for constraint:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def _cos(i,t):&#xA;    if i not in I_D and i not in I_R:&#xA;         return w[i,t] = w[i,t-1]&#xA;    if i not in I_D and i in I_R:&#xA;         return w[i,t] = w[i,t-1] +  R[i,t]&#xA;    if i not in I_R and i in I_D:&#xA;         return w[i,t] = w[i,t-1] -D[i,t]&#xA;    if i in I_R and i in I_D:&#xA;         return w[i,t] = w[i,t-1]  +  R[i,t]  -D[i,t]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6114" LastEditorUserId="36" LastEditDate="2021-10-24T18:03:40.803" LastActivityDate="2021-10-24T18:03:40.803" Title="How to professionally write a constraint, where some variables take certain values of index and some variables should not take some values of index" Tags="|optimization|modeling|python|pyomo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7175" PostTypeId="2" ParentId="7174" CreationDate="2021-10-24T18:02:41.800" Score="3" Body="&lt;p&gt;I'm assuming your &lt;code&gt;w, R, D&lt;/code&gt; variables are not in form of dictionaries (if they are the function below becomes much simpler).&#xA;I go with &amp;quot;easier to ask for forgiveness than permission&amp;quot; (EAFP) programming.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def _cos(i,t):&#xA;    try:&#xA;        _r = R[i,t]&#xA;    except KeyError:&#xA;        _r = 0&#xA;    try:&#xA;        _d = D[i,t]&#xA;    except KeyError:&#xA;        _d = 0&#xA;    return w[i,t] = w[i,t-1]  +  _r  - _d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="36" LastActivityDate="2021-10-24T18:02:41.800" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7176" PostTypeId="1" AcceptedAnswerId="7177" CreationDate="2021-10-24T19:28:09.113" Score="4" ViewCount="259" Body="&lt;p&gt;I'm learning operations research and this is a question that I came across:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The monthly demand for your family is 10kg, which is bought monthly. The maximum retail price (MRP) is INR400, on which generally there is a discount of 20%. But due to a pandemic situation, you are expecting that the flour would be sold on MRP in the coming months. Today, 20% discounted wheat flour is available in the local grocery store. Based on the learning in your operations management course, suggest the right amount of wheat flour be purchased this time. (Wheat flour should be used within 3 to 4 months of preparation).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I'm a bit confused because this seems alarmingly simple. Nothing is mentioned about the holding constraints of flour inventory, so shouldn't I just buy 30-40kg of wheat at this discounted price to last for the next 3-4 months (while the flour hasn't gone bad.)&lt;/p&gt;&#xA;&lt;p&gt;Or should I rethink this and devise different cases and scenarios for different holding cost situations? Very perplexed on how to go about this question. Apologies if it is too basic (stupid) a question.&lt;/p&gt;&#xA;" OwnerUserId="7412" LastActivityDate="2021-10-24T20:08:20.170" Title="One-time price discount Inventory Model" Tags="|inventory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7177" PostTypeId="2" ParentId="7176" CreationDate="2021-10-24T20:08:20.170" Score="4" Body="&lt;p&gt;I'm not sure what &amp;quot;preparation&amp;quot; means here. If it is when the product is packaged for sale, the shelf life at home will perhaps be less than three to four months ... but then you should be told what the &amp;quot;preparation&amp;quot; date is.&lt;/p&gt;&#xA;&lt;p&gt;Assuming your 10kg/month consumption rate is to be treated as definitive (not just an estimated average), it does seem like a strangely easy problem. Three questions you might ask yourself are the following. First, do you have space at home to store that much wheat flour? Second, is your current inventory zero or do you have flour on hand that presumably must be used before you use the newly purchased flour? Third, do you owe money to a loan shark? (The 20% discount makes it unlikely that you are financially better off deferring the purchase, but if your cost of capital is really high then it might be better to wait and pay full price later.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-24T20:08:20.170" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7178" PostTypeId="1" CreationDate="2021-10-25T06:42:32.827" Score="3" ViewCount="700" Body="&lt;p&gt;I have seen one explanation about the difference between discrete and combinatorial optimization problems in such a way that &amp;quot;all combinatorial optimization problems are also discrete optimization problems but the converse is not true&amp;quot; [1].&lt;/p&gt;&#xA;&lt;p&gt;I am not aware of the existence of such a problem. Also, looking at the literature, from vehicle routing to the scheduling problems, all of them are discrete (of course, some of them are mixed-integer).  Could you enlighten me about how it is possible for a problem that is discrete, but not combinatorial?&lt;/p&gt;&#xA;&lt;p&gt;[1] &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-1-4613-0303-9_3&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/chapter/10.1007/978-1-4613-0303-9_3&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7234" LastActivityDate="2021-10-25T09:46:09.480" Title="Discrete problems versus Combinatorial problems" Tags="|combinatorial-optimization|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7179" PostTypeId="2" ParentId="7178" CreationDate="2021-10-25T09:46:09.480" Score="3" Body="&lt;p&gt;Based on some googling:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The versatility of the combinatorial optimization model stems from the fact that in many practical problems, activities and resources, such as machines, airplanes, and people, are indivisible. Also, many problems have only a finite number of alternative choices and consequently can appropriately be formulated as combinatorial optimization problems — the word combinatorial refers to the fact that only a finite number of alternative feasible solutions exists. Combinatorial optimization models are often referred to as integer programming models where programming refers to “planning” so that these are models used in planning where some or all of the decisions can take on only a finite number of alternative possibilities.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Combinatorial optimization emphasizes the combinatorial origin, formulation, or solution algorithm of a problem.&lt;/li&gt;&#xA;&lt;li&gt;Discrete optimization emphasizes the difference to continuous optimization.&lt;/li&gt;&#xA;&lt;li&gt;Integer programming emphasizes the usage of integer (or binary integer)-valued variables in formulation or solution.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://scicomp.stackexchange.com/questions/3367/relation-and-difference-between-combinatorial-optimization-discrete-optimizatio&quot;&gt;Relation and difference between combinatorial optimization, discrete optimization, and integer programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.esi2.us.es/%7Embilbao/combiopt.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Combinatorial and Integer Optimization&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-10-25T09:46:09.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7180" PostTypeId="1" CreationDate="2021-10-26T08:01:57.937" Score="-3" ViewCount="164" Body="&lt;p&gt;Here is a bilevel question:&lt;/p&gt;&#xA;&lt;p&gt;the master problem is &lt;span class=&quot;math-container&quot;&gt;$\max_y \sum_{n \in 1,...,N} x[n] * y[n];$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to &lt;span class=&quot;math-container&quot;&gt;$$\min_x \sum_{n \in 1,...,N} x[n] * y[n]$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$yy^T = I$$&lt;/span&gt;&#xA;and some other linear constraints.&lt;/p&gt;&#xA;&lt;p&gt;So it should be a bi-level question, with lower linear and higher quadratic.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question here.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="7419" LastEditorUserId="4777" LastEditDate="2021-10-26T14:48:35.890" LastActivityDate="2021-10-27T21:50:40.997" Title="Ask for suggestions on bilevel optimization question" Tags="|bilevel-optimization|" AnswerCount="1" CommentCount="4" ClosedDate="2021-11-01T13:49:19.590" ContentLicense="CC BY-SA 4.0" />
  <row Id="7181" PostTypeId="1" CreationDate="2021-10-26T11:12:37.517" Score="2" ViewCount="77" Body="&lt;p&gt;Architectural layouts define the position and shape of rooms in 3D space, where windows and water pipes are and as well as how humans travel between rooms (among other things). There is a lot of research based on floor plans (having all rooms defined by &lt;span class=&quot;math-container&quot;&gt;$x,y$&lt;/span&gt; coordinates only). &amp;quot;Mixed integer programming model with non-circular and guided constraints for architectural layout design optimization&amp;quot; by Kamol and Krung is a good introduction. &amp;quot;MIQP-based Layout Design for Building Interiors&amp;quot; by Wu et al proposes to design multiple floors at the same time and enforce consistency of space planned for stairs between levels. This assumes that all rooms are at a few fixed &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; coordinates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I am looking for formulations or literature where rooms are allocated as 3d objects to verify the assumption that treating things based on different floors is a justified simplification in my use case.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Formulations from other applied areas which allocates non overlapping cuboids with &amp;quot;connections&amp;quot; between some of them which impose constrains on the coordinates of the connected cuboids are also welcome in so far as they can be adapted for what i want.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-10-26T11:12:37.517" Title="Designing Multi Floor Architectural Layouts" Tags="|mixed-integer-programming|reference-request|multi-objective-optimization|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7182" PostTypeId="1" AcceptedAnswerId="7184" CreationDate="2021-10-26T13:40:43.580" Score="4" ViewCount="215" Body="&lt;p&gt;I have a problem (see my questions about Architectural layouts which poses an interesting abstract question) where there exists an implicit (symmetric) graph whose values in the adjacency matrix are implied by other constraints.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$A^m_{i,j}$&lt;/span&gt; be the entries of the &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;-th power of of the &lt;span class=&quot;math-container&quot;&gt;$p\times p$&lt;/span&gt; adjacency matrix where &lt;span class=&quot;math-container&quot;&gt;$A^{n+l}_{i,j} = \bigvee_{m\in\{1,..,p\}}\ A^n_{i,m} \wedge A^l_{m,j}$&lt;/span&gt; as the boolean algebra suggests. If &lt;span class=&quot;math-container&quot;&gt;$\sum_{m\in\{1,..,p\}} A^m_{i,j}$&lt;/span&gt; is non zero in every &lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt; then the graph is fully connected. We exploit the fact that the matrices are boolean to express the products that occur in the matrix in a MILP framework. However that means we have order at least &lt;span class=&quot;math-container&quot;&gt;$O(p^4)$&lt;/span&gt; &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$A^n_{i,m} \wedge A^l_{m,j}$&lt;/span&gt;&amp;quot; terms which i am afraid will scale poorly.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Could you suggest some alternative formulation with convex relaxations that might scale better and can be solved using standard solvers?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am aware of another &lt;a href=&quot;https://math.stackexchange.com/a/3647942&quot;&gt;approach&lt;/a&gt; using the eigenvalues of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Laplacian_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;graph Laplacian matrix &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;&lt;/a&gt;. However i haven't been able to put this approach into a single level MILP problem. I vaguely recall that cone programming might help. The Laplacian might be able to be replaced by the &lt;a href=&quot;https://en.wikipedia.org/wiki/Laplacian_matrix#Incidence_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;Incidence Matrix&lt;/a&gt; for this to make representation easier.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-10-26T15:36:10.523" LastActivityDate="2021-10-26T15:59:13.753" Title="Constrain Mixed-Integer problem such that a graph is fully connected" Tags="|mixed-integer-programming|integer-programming|constraint|logical-constraints|graphs|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7183" PostTypeId="2" ParentId="7180" CreationDate="2021-10-26T15:23:16.437" Score="4" Body="&lt;p&gt;Some tools provide facilities for specifying and solving bilevel optimization problems. GAMS and Pyomo come to mind. See e.g. &lt;a href=&quot;https://www.osti.gov/servlets/purl/1526125&quot; rel=&quot;nofollow noreferrer&quot;&gt;Modeling Bilevel Programs in Pyomo&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Otherwise, a standard approach for continuous bilevel problems is to formulate the first-order (or KKT) conditions for the inner problem and add these as constraints to the outer problem. It is always a good exercise to try this formulation. The optimality conditions for a linear inner problem lead to non-convex quadratic constraints. Global quadratic solvers can be used to solve this. As your outer problem is also non-convex quadratic, it may not be worthwhile to linearize the inner problem.&lt;/p&gt;&#xA;&lt;p&gt;Integer bilevel problems are much more difficult. Sometimes Benders Decomposition is used for such models.&lt;/p&gt;&#xA;&lt;p&gt;A standard reference on bilevel optimization is &lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4757-2836-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bard&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I see that a bit of a strange edit has been made to the original post. The added constraint containing an outer-product &lt;span class=&quot;math-container&quot;&gt;$$yy^T = I$$&lt;/span&gt; will make the problem &lt;strong&gt;infeasible&lt;/strong&gt;. Written differently: &lt;span class=&quot;math-container&quot;&gt;$$ y_iy_j = \begin{cases} 1 &amp;amp; \text{if $i=j$} \\ 0 &amp;amp; \text{if $i \ne j$}\end{cases}$$&lt;/span&gt; The diagonal implies &lt;span class=&quot;math-container&quot;&gt;$y_i=\pm 1$&lt;/span&gt;, but that makes the off-diagonal products infeasible.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2021-10-27T21:50:40.997" LastActivityDate="2021-10-27T21:50:40.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7184" PostTypeId="2" ParentId="7182" CreationDate="2021-10-26T15:59:13.753" Score="5" Body="&lt;p&gt;If you are looking for a way to ensure (in a MILP model) that a graph with &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; nodes is connected, a common approach is to treat each edge as a pair of directed edges (adding flow variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{ji}$&lt;/span&gt; for each edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, choose one node arbitrarily to have supply &lt;span class=&quot;math-container&quot;&gt;$p-1$&lt;/span&gt; of a phantom commodity, and assign a demand of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to every other node. You then add the usual flow balance constraints (flow out of node = flow into node - 1). Feasibility of the flow constraints guarantees a path from the source node to every other node, meaning the graph is connected.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-26T15:59:13.753" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7185" PostTypeId="1" CreationDate="2021-10-27T12:21:42.117" Score="4" ViewCount="262" Body="&lt;p&gt;There is a decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; which denotes the time when a person is allowed to do his work.&lt;br /&gt;&#xA;The objective function is&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\min (x_i - a_i)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; is the time when the person arrives at the workplace.&lt;br /&gt;&#xA;Suppose after solving, the values of decision variable come out to be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x1 = 10   &#xA;x2 = 6  &#xA;x3 = 8  &#xA;x4 = 3  &#xA;x5 = 9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now I need to formulate an additional objective function and a constraint with another decision variable &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; which denotes the rank or order in which these people start doing the work.&lt;br /&gt;&#xA;For instance from the above example,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;r1 = 5  &#xA;r2 = 2  &#xA;r3 = 3  &#xA;r4 = 1  &#xA;r5 = 4 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How do I determine the value of &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; in the form of a constraint in this multiobjective optimization problem?&lt;/p&gt;&#xA;" OwnerUserId="7420" LastEditorUserId="2556" LastEditDate="2021-10-27T16:01:24.190" LastActivityDate="2021-10-27T16:01:24.190" Title="Deriving order/rank variable from another decision variable" Tags="|mixed-integer-programming|modeling|integer-programming|constraint|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7186" PostTypeId="2" ParentId="7185" CreationDate="2021-10-27T14:55:27.043" Score="1" Body="&lt;p&gt;Your question prompted me to suggest multiple answers, if you would like me to elaborate on one of them please tell me which one in a comment.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Would be fine with &lt;span class=&quot;math-container&quot;&gt;$A_{ij}$&lt;/span&gt; matrix which tells you if &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is before &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt;&#xA;or otherwise, that would be a lot simpler to implement.&lt;/li&gt;&#xA;&lt;li&gt;If you don't have individual constraints on &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; (they can be&#xA;any employee, not a specific one) you could just enforce an ordering&#xA;by &lt;span class=&quot;math-container&quot;&gt;$x_1 \leq x_2 \leq ... \leq x_5$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You could implement a &lt;a href=&quot;https://en.wikipedia.org/wiki/Sorting_network&quot; rel=&quot;nofollow noreferrer&quot;&gt;sorting network&lt;/a&gt; using a simple to implement gadget that depending on the sign of the difference of it's inputs returns a linear combination of it's inputs such that the lower value is always returned at the lower output.&lt;/li&gt;&#xA;&lt;li&gt;You could define a &lt;a href=&quot;https://en.wikipedia.org/wiki/Permutation_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;permutation matrix&lt;/a&gt; &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$y = Px$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1 \leq y_2 \leq ... \leq y_5$&lt;/span&gt; and use that same matrix in &lt;span class=&quot;math-container&quot;&gt;$r = P (1,2,3,4,5)^T$&lt;/span&gt;. In this case you also want to pose additional constraints on &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; to cut off useless parts of the search space such as &lt;span class=&quot;math-container&quot;&gt;$\sum r = 15$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$1 \leq r_i \leq 5$&lt;/span&gt; and maybe that each integer can only occur once as i am not sure bound tighetening will catch this on it's own.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-10-27T14:55:27.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7187" PostTypeId="2" ParentId="7185" CreationDate="2021-10-27T15:44:14.493" Score="4" Body="&lt;p&gt;Let us introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; along with the constraint &lt;span class=&quot;math-container&quot;&gt;$y_{ij} + y_{ji} \le 1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i\neq j$&lt;/span&gt;. Add the constraints &lt;span class=&quot;math-container&quot;&gt;$$x_j - x_i \le My_{ij}\quad \forall i\neq j,$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is an upper bound on the difference between largest and smallest &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; value. This ensures that &lt;span class=&quot;math-container&quot;&gt;$y_{ij}=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_j &amp;gt; x_i$&lt;/span&gt;. The question does not indicate whether ties in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; can happen. With this formulation, if &lt;span class=&quot;math-container&quot;&gt;$x_i=x_j$&lt;/span&gt;, both &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{ji}$&lt;/span&gt; can be either 0 or 1 (though they cannot both be 1).&lt;/p&gt;&#xA;&lt;p&gt;To compute ranks, we add the constraints &lt;span class=&quot;math-container&quot;&gt;$$r_i = 1 + \sum_{j\neq i} y_{ji}\quad \forall i.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assuming starting times are integer-valued, you might want to add &lt;span class=&quot;math-container&quot;&gt;$$x_j - x_i \ge 1 - M(1-y_{ij})\quad \forall i\neq j.$$&lt;/span&gt; This eliminates the ambiguity in ties, forcing &lt;span class=&quot;math-container&quot;&gt;$y_{ij}=y_{ji}=0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_i=x_j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-27T15:44:14.493" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7188" PostTypeId="2" ParentId="7149" CreationDate="2021-10-27T16:57:19.117" Score="2" Body="&lt;p&gt;Try this: results = solver.solve(Model, logfile='path/to/logfile.log', tee=True)&lt;/p&gt;&#xA;&lt;p&gt;with tee=True, solver will display the log at runtime and you will be able to see the IP solution with the gap%.&lt;/p&gt;&#xA;" OwnerUserId="6126" LastActivityDate="2021-10-27T16:57:19.117" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7189" PostTypeId="2" ParentId="4641" CreationDate="2021-10-27T19:52:30.097" Score="1" Body="&lt;p&gt;Safety stock for a demand stream (assuming it is normally distributed without recurring lumpiness) depends on a number of factors:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Target service level&lt;/li&gt;&#xA;&lt;li&gt;Demand accuracy&lt;/li&gt;&#xA;&lt;li&gt;Lead time&lt;/li&gt;&#xA;&lt;li&gt;Supplier reliability&lt;/li&gt;&#xA;&lt;li&gt;Order cover (i.e. how long a period each replenishment order will cover)&lt;/li&gt;&#xA;&lt;li&gt;Replenishment frequency&lt;/li&gt;&#xA;&lt;li&gt;Forecast horizon (i.e. how many periods ahead you know your firm demand)&#xA;Our approach to calculating the optimal safety stock takes all of these into account by simulating the actual demand and supply lead time over 100,000 periods and then finding the stock level needed to give the service level target you require. Please see &lt;a href=&quot;https://safetystock.guru&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://safetystock.guru&lt;/a&gt; for further details.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Cycle stock is the average stock level due to the order cover period.  If each order covers two weeks of demand then the cycle stock will be equal to one week of demand.&lt;/p&gt;&#xA;&lt;p&gt;The combined stock that you should expect is a sawtooth:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/WfIH0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WfIH0.png&quot; alt=&quot;Typical inventory profile&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7429" LastActivityDate="2021-10-27T19:52:30.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7190" PostTypeId="1" AcceptedAnswerId="7192" CreationDate="2021-10-28T09:31:56.120" Score="1" ViewCount="124" Body="&lt;p&gt;In order to find the quality indicators like Generational Distance, Inverted Generational Distance, Epsilon Indicator, and HyperVolume for a Pareto front I want to normalize the values of approximation front obtained on solving the algorithm based on reference front which I assume encloses the approximation front. Is it correct to do so?&lt;/p&gt;&#xA;&lt;p&gt;Basically, rather than normalizing the approximation front and reference front. I have to normalize the approximate front between 0 to 1 based on max and min values of reference front?&lt;/p&gt;&#xA;&lt;p&gt;Also how to compute reference point? Is it the maximum of each objective value in a reference front if the problem is a min-min?&lt;/p&gt;&#xA;" OwnerUserId="5794" LastActivityDate="2021-10-28T10:40:08.150" Title="How to compute Generational Distance, Inverted Generational Distance, Epsilon Indicator, and Hypervolume for a Pareto front?" Tags="|optimization|multi-objective-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7191" PostTypeId="1" AcceptedAnswerId="7194" CreationDate="2021-10-28T10:15:03.350" Score="3" ViewCount="392" Body="&lt;p&gt;I'm trying to optimize reorder quantities for &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; products over &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; periods in PuLP. The total reorder quantity should fill a container. I've never worked with multiple periods before, and I can't get it to work. I tried to formulate it the following way:&lt;/p&gt;&#xA;&lt;p&gt;Minimize the sum over all ROQ (reorder quantity)&lt;/p&gt;&#xA;&lt;p&gt;s.t.&lt;/p&gt;&#xA;&lt;p&gt;ROQ &amp;gt; 0&lt;/p&gt;&#xA;&lt;p&gt;Inventory m+1 = Inventory m - demand m + ROQ m &amp;gt; 0&lt;/p&gt;&#xA;&lt;p&gt;sum(ROQ n) m = container * trigger&lt;/p&gt;&#xA;&lt;p&gt;I've created an integer trigger variable so I can order any quantity that's a multiple of a container, or nothing.&#xA;It seemed relatively straightforward, but the solver keeps telling me the problem is infeasible to solve. I assume the problem is where I try to set next periods inventory as this periods inventory - demand + ROQ, because turning the equation around throws an error. I can't figure out how to overcome this problem. Can you point me in the right direction?&lt;/p&gt;&#xA;&lt;p&gt;The formulation in pulp is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;import pandas as pd&#xA;import random&#xA;import pulp&#xA;&#xA;import warnings&#xA;&#xA;&#xA;SKUs = 10&#xA;periods = 12&#xA;initial_inv = 50&#xA;container = 100&#xA;&#xA;warnings.filterwarnings(&amp;quot;ignore&amp;quot;)&#xA;&#xA;df_DEM = pd.DataFrame(np.random.randint(0,200, size=(SKUs,periods)))&#xA;df_INV = pd.DataFrame(np.random.randint(0,200, size=(SKUs,periods+1)))&#xA;df_REP = pd.DataFrame(np.random.randint(0,1, size=(SKUs,periods)))&#xA;&#xA;problem = pulp.LpProblem('inventory', pulp.LpMinimize)&#xA;&#xA;#variables&#xA;ROQ = pulp.LpVariable.dicts('ROQ', ((i, j) for i in range(SKUs) for j in range(periods)), lowBound=0, cat='Continuous')&#xA;trigger = pulp.LpVariable.dicts('trigger', (i for i in range(periods)), cat='Integer')&#xA;&#xA;# set objective function&#xA;problem += pulp.lpSum((ROQ[i,j]) for i in range(SKUs) for j in range(periods))&#xA;&#xA;#constraints&#xA;#1 ROQs &amp;gt; 0&#xA;for i in range(SKUs):&#xA;    for j in range(periods):&#xA;        problem += ROQ[i,j] &amp;gt;= 0&#xA;#2 trigger &amp;gt;= 0&#xA;for j in range(periods):&#xA;    problem += trigger[i] &amp;gt;= 0&#xA;&#xA;#3 inventory in each period &amp;gt; 0&#xA;for i in range(SKUs):&#xA;    for j in range(periods):&#xA;        problem += df_INV.loc[i,j]-df_DEM.loc[i,j]+ROQ[i,j] &amp;gt;= 0&#xA;#4 inventory for the next period = inventory from this period + demand - reorder quantity&#xA;for i in range(SKUs):&#xA;    for j in range(periods):&#xA;        problem +=  df_INV.loc[i,j] - df_DEM.loc[i,j] + ROQ[i,j] == df_INV.loc[i,j+1] &#xA;#5 ROQ is in multiples of a container &#xA;for j in range(periods):&#xA;    problem += pulp.lpSum(ROQ[i,j] for i in range(SKUs)) == trigger[j] * container&#xA;&#xA;# set solver options&#xA;solver = pulp.PULP_CBC_CMD(fracGap=0.001, msg=True, warmStart=False)&#xA;&#xA;# solve problem&#xA;status = problem.solve(solver)&#xA;print(pulp.LpStatus[status], round(pulp.value(problem.objective),0))    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7430" LastEditorUserId="36" LastEditDate="2021-10-28T13:00:14.713" LastActivityDate="2023-01-25T23:29:04.803" Title="Multi period inventory / reordering MILP in PULP" Tags="|mixed-integer-programming|pulp|multi-stage|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7192" PostTypeId="2" ParentId="7190" CreationDate="2021-10-28T10:40:08.150" Score="1" Body="&lt;p&gt;The reference front is another name for the pareto front of the problem. You find it either by solving the problem symbolically, constructing a problem around some pareto front or running and global optimizer long enough. If you want to normalize the any front it is sensible to do so using the reference front. Over what (hyper) cuboid you normalize the fronts is your decision, there is no right answer just answers that don't match your usecase. The maximum of each objective value might be meaningless if it is unbounded. Consider&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x,y} x,y \ \text{ subject to: } xy = 1$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-10-28T10:40:08.150" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7194" PostTypeId="2" ParentId="7191" CreationDate="2021-10-28T13:00:24.723" Score="5" Body="&lt;p&gt;Some comments on your model:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you can remove constraints &lt;span class=&quot;math-container&quot;&gt;$\#1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\#2$&lt;/span&gt;, as you have already defined the variables as non negative&lt;/li&gt;&#xA;&lt;li&gt;the problem is infeasible, because the inventory is not a variable, it is already defined and is an input of the model. Consequently, with constraints &lt;span class=&quot;math-container&quot;&gt;$\#4$&lt;/span&gt;, &lt;code&gt;ROQ&lt;/code&gt; variables are also defined and have no other possible values than the ones imposed by these constraints, which are not compatible with constraints &lt;span class=&quot;math-container&quot;&gt;$\#5$&lt;/span&gt;. Only the initial value of the inventory should be defined.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So what you have to do is to define a new set of variables to track the inventory, and replace &lt;code&gt;df_INV&lt;/code&gt; with those variables, for example, like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;import pandas as pd&#xA;import random&#xA;import pulp&#xA;&#xA;import warnings&#xA;&#xA;&#xA;SKUs = 10&#xA;periods = 10&#xA;initial_inv = 50&#xA;container = 100&#xA;&#xA;warnings.filterwarnings(&amp;quot;ignore&amp;quot;)&#xA;&#xA;df_DEM = pd.DataFrame(np.random.randint(0,200, size=(SKUs,periods)))&#xA;df_REP = pd.DataFrame(np.random.randint(0,1, size=(SKUs,periods)))&#xA;&#xA;problem = pulp.LpProblem('inventory', pulp.LpMinimize)&#xA;&#xA;#variables&#xA;ROQ = pulp.LpVariable.dicts('ROQ', ((i, j) for i in range(SKUs) for j in range(periods)), lowBound=0, cat='Continuous')&#xA;trigger = pulp.LpVariable.dicts('trigger', (i for i in range(periods)), cat='Integer')&#xA;inventory = pulp.LpVariable.dicts('inv', ((i, j) for i in range(SKUs) for j in range(periods+1)), lowBound=0, cat='Continuous')&#xA;&#xA;# set objective function&#xA;problem += pulp.lpSum((ROQ[i,j]) for i in range(SKUs) for j in range(periods))&#xA;&#xA;#constraints&#xA;#3 inventory in each period &amp;gt; 0&#xA;for i in range(SKUs):&#xA;    for j in range(periods):&#xA;        problem += inventory[i,j]-df_DEM.loc[i,j]+ROQ[i,j] &amp;gt;= 0&#xA;&#xA;#4 inventory for the next period = inventory from this period + demand - reorder quantity&#xA;for i in range(SKUs):&#xA;    for j in range(periods):&#xA;        problem +=  inventory[i,j] - df_DEM.loc[i,j] + ROQ[i,j] == inventory[i,j+1]&#xA;    problem += inventory[i,0] == initial_inv&#xA;#5 ROQ is in multiples of a container &#xA;for j in range(periods):&#xA;    problem += pulp.lpSum(ROQ[i,j] for i in range(SKUs)) == trigger[j] * container&#xA;&#xA;# set solver options&#xA;solver = pulp.PULP_CBC_CMD(fracGap=0.001, msg=True, warmStart=False)&#xA;# solve problem&#xA;status = problem.solve(solver)&#xA;print(pulp.LpStatus[status], round(pulp.value(problem.objective),0)) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-10-28T13:06:27.570" LastActivityDate="2021-10-28T13:06:27.570" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7195" PostTypeId="2" ParentId="4667" CreationDate="2021-10-28T14:03:31.707" Score="2" Body="&lt;p&gt;You should probably also consider &lt;a href=&quot;https://optuna.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optuna&lt;/a&gt;, a fairly new but rapidly improving optimization framework. It was originally targeted at machine learning hyperparameter optimization, but it works for all kinds of problems and provides generic algorithms (Gaussian processes, NSGA-II, TPE estimators, etc.).&lt;/p&gt;&#xA;" OwnerUserId="7431" LastActivityDate="2021-10-28T14:03:31.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7196" PostTypeId="1" AcceptedAnswerId="7197" CreationDate="2021-10-28T18:07:06.783" Score="2" ViewCount="184" Body="&lt;p&gt;The black-box system shown below has 3 components.&lt;a href=&quot;https://i.stack.imgur.com/MvUme.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MvUme.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;They run sequentially to generate a final output from the input. Each component has its own parameters to optimize for better intermediate results (Output #1, Output #2, etc.). We want to find the parameters that generate best final output. There are two methods to optimize this system&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Optimize component #1 for best output #1, then component #2 for best output #2, and finally component #3.&lt;/li&gt;&#xA;&lt;li&gt;Optimize all 3 components simultaneously for best final output, regardless of the intermediate results (Output #1, Output #2).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;How to prove that method #2 is better than method #1 from the perspective of black-box optimization?&lt;/p&gt;&#xA;&lt;p&gt;Is there any formal name for optimization methods like method #1? Method #1 looks like coordinate descent but it does not go back to already optimized components. It does not go back and optimize component #1 again after optimizing component #3.&lt;/p&gt;&#xA;" OwnerUserId="7433" LastActivityDate="2021-10-29T10:43:11.107" Title="How to prove that optimizing each component of a system separately gives suboptimal result?" Tags="|optimization|combinatorial-optimization|global-optimization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7197" PostTypeId="2" ParentId="7196" CreationDate="2021-10-28T18:31:49.163" Score="4" Body="&lt;p&gt;Method #1 is called local optimization, while Method #2 is called global optimization.&lt;/p&gt;&#xA;&lt;p&gt;In practice, all modelling is local. That is, we have to draw a boundary around the parts of the whole system that we consider in our model. If done well, then the parts of the system that we excluded do not significantly influence the solution. Often the decision about where to put the boundary is based on judgement rather than analysis.&lt;/p&gt;&#xA;&lt;p&gt;As for your three-step process. Suppose that we have n resources that can be assigned to the components. A couple of potential solutions are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Local. Assign all n resources to Component 1. Let's assume that this maximizes throughput of Component 1, though we can't be sure. No resources remain to be assigned to Components 2 or 3, so zero Final Output is produced.&lt;/li&gt;&#xA;&lt;li&gt;Global. Assign the n resources across the components to maximize the Final Output. The assignment may or may not be uniform (we don't know what's best, as the components are black boxes).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The Global solution is clearly better than the Local solution.&lt;/p&gt;&#xA;&lt;p&gt;More generally, there may be cases where the Local and Global solutions are equal. But there cannot be a case where the Local solution is better than the Global solution - otherwise that Local solution would also be the Global solution.&lt;/p&gt;&#xA;" OwnerUserId="5128" LastEditorUserId="5128" LastEditDate="2021-10-28T18:48:08.867" LastActivityDate="2021-10-28T18:48:08.867" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7198" PostTypeId="2" ParentId="7137" CreationDate="2021-10-28T19:35:27.407" Score="2" Body="&lt;p&gt;Your question mentions several different possible criteria: travel distance; rotations; makespan (total time to finish all welds). You'll need to pick one. I suspect makespan is the one you will want.&lt;/p&gt;&#xA;&lt;p&gt;Assuming that welds can be done in any order, the problem can be viewed as a single machine scheduling problem with sequence-dependent setup times. The machine is obviously the robot, and the jobs to be scheduled are the welds. Processing time for a weld would the actual welding time. &amp;quot;Set up&amp;quot; time for a job would include the time spent getting the robot to it from the robot's position for the previous job and the time spent rotating the robot. Time spent flipping a pink thing could be included in either the setup time or the processing time. The sequence dependency results from the robot having to move and/or rotate differently depending on what it was last doing (and where it was doing it).&lt;/p&gt;&#xA;&lt;p&gt;The one tricky piece is the cooling time. Let's assume the robot just finished a task that needs &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; seconds to cool. The setup time for another task on the same weld point can include the full cooling time. The setup time for a task at some other point presumably need not include any of the cooling time. The tricky part is what happens when you finish the first weld, send the robot to do something else, then immediately come back for the next weld at the first location. If you can be sure that time spent doing the second weld (including moving, rotating etc.) exceeds the cooling time, you can just ignore the cooling time (meaning it is only a factor in setups when you do two consecutive welds at the same place). If the cooling time is longer than the time for an intermediate weld, the problem gets more difficult to model.&lt;/p&gt;&#xA;&lt;p&gt;There are constraint programming approaches that work very well with machine scheduling problems, and you can model machine scheduling problems (including the case where the cooling time is &amp;quot;long&amp;quot;) as mixed-integer linear programs. Hypothetically, you could model it as a dynamic program (equivalent to a shortest path problem), but I think the state space (graph) would be too large to make that practical.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-28T19:35:27.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7199" PostTypeId="1" CreationDate="2021-10-28T22:28:30.447" Score="4" ViewCount="389" Body="&lt;p&gt;We know that there are lots of formulations for traveling salesman problem. Some of them are based on the directed graph (asymmetric) and others are based on the undirected graph (symmetric). Also, there exist two well-known subtour-elimination constraints (SECs), MTZ and DFJ, that are frequently discussed in the community, like &lt;a href=&quot;https://or.stackexchange.com/questions/3667/tsp-subtour-elimination-with-multiple-formulations&quot;&gt;this&lt;/a&gt;, &lt;a href=&quot;https://or.stackexchange.com/questions/3667/tsp-subtour-elimination-with-multiple-formulations&quot;&gt;this&lt;/a&gt;, and &lt;a href=&quot;https://or.stackexchange.com/questions/6153/subtour-elimination-constraint-in-travelling-salesman-problem&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But in order to SECs and whose dependency on the defined graph, I have some questions. I was wondering if,&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there any classification to figure out which one belongs to which&#xA;graph?&lt;/li&gt;&#xA;&lt;li&gt;Is it possible to define directed graph-based SECs on the&#xA;undirected ones? for example,  The MTZ formulation is defined on the&#xA;directed and DFJ defined on the undirected. Might be it changed vise&#xA;versa?&lt;/li&gt;&#xA;&lt;li&gt;What is the difference between graph symmetry and traveling&#xA;cost symmetry? or they have the same mean?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-11-02T15:22:32.450" Title="The difference between subtour-elimination constraints in the symmetric and asymmetric TSP" Tags="|mixed-integer-programming|graphs|traveling-salesman|subtour-elimination|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7202" PostTypeId="1" CreationDate="2021-10-29T10:19:25.133" Score="4" ViewCount="161" Body="&lt;p&gt;I am trying to find a DCP formulation for the following convex objective function (using CVXPY):&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; be the &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;-dimensional vector variable on which we optimize on, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; be a &lt;strong&gt;known&lt;/strong&gt; scalar value such that &lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt; c \le 1$&lt;/span&gt; and and &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; be a &lt;strong&gt;known&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;-dimensional vector with &lt;span class=&quot;math-container&quot;&gt;$L_i &amp;gt; 0 \: \forall i=1,..., N$&lt;/span&gt;. The (convex) objective is formulated as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f(x) = \sum_{i=1}^N\left(c^{\max(x_i,0)/L_i}\cdot L_i - \ln(c)\cdot\max(x_i,0)\right)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Single out any &lt;span class=&quot;math-container&quot;&gt;$i=1,...,N$&lt;/span&gt;, the issue I am facing is that each convex element of the sum above is given by the sum of a nonconvex and a convex function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c^{\max(x_i,0)/L}\cdot L_i - \ln(c)\cdot\max(x_i,0)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The expected behavior of the above sum is to be equal to:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;c^{\max(x_i,0)/L}\cdot L_i - \ln(c)\cdot\max(x_i,0)=\begin{cases}&#xA;c^{x_i/L}\cdot L_i - \ln(c)\cdot x&amp;amp;\quad x_i \ge 0 \\&#xA;L_i &amp;amp;\quad x_i &amp;lt; 0&#xA;\end{cases}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But using standard atoms it is not trivial to provide a DCP certificate for the above due to non-convexity of the first term.&lt;/p&gt;&#xA;&lt;p&gt;Do you have any ideas/suggestions on how one could rewrite the problem and make it DCP compliant?&lt;/p&gt;&#xA;" OwnerUserId="7437" LastEditorUserId="7437" LastEditDate="2021-10-29T12:46:07.307" LastActivityDate="2021-11-05T11:38:04.653" Title="DCP formulation of sum of nonconvex and convex functions" Tags="|convex-optimization|disciplined-convex-programming|cvxpy|reformulation-linearization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7203" PostTypeId="2" ParentId="7196" CreationDate="2021-10-29T10:43:11.107" Score="3" Body="&lt;p&gt;To add the answer by @solver max (I think it is a very good answer), Please be aware that, neither method-&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; nor method-&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; has a preference over another. Specifically, for the black-box optimization, as long as, you would not optimize each stage component, obviously, you would not achieve the global solution.&lt;/p&gt;&#xA;&lt;p&gt;For example, suppose there is a complex system with three stages that produced the non-conformity parts. If in the beginning, you would try optimizing the whole system without considering the probability errors in each stage, it can happen to loos resource efficiency in some stage, as the system will try to optimize the final output.&lt;/p&gt;&#xA;&lt;p&gt;I think this is one of the best applications of black-box optimization than other methods when one would like to survey a complex system.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-10-29T10:43:11.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7204" PostTypeId="1" CreationDate="2021-10-29T12:52:26.750" Score="4" ViewCount="121" Body="&lt;p&gt;Given a model with a binary variable &lt;span class=&quot;math-container&quot;&gt;$b_s$&lt;/span&gt; that describes whether taking an item &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; from a set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; or not. Consider that some other constraint in the model depends upon whether &lt;em&gt;all&lt;/em&gt; items of the set are taken (so to say the minimum of all &lt;span class=&quot;math-container&quot;&gt;$b_s$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;That other constraint can also be described with the help of a further binary variable, but given that &lt;span class=&quot;math-container&quot;&gt;$b_s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; are &amp;quot;tightly connected&amp;quot; (for lack of a better term), I could also use a continuous variable &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; in the domain &lt;span class=&quot;math-container&quot;&gt;$[0, 1]$&lt;/span&gt; as given:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c \leq b_s \quad \forall \, s \in S \\&#xA;c \geq \sum_{s \in S} b_s - |S| + 1 \\&#xA;b_s \in \{0, 1\} \quad \forall \, s \in S \\&#xA;c \in [0, 1]&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Even though &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is continuous, in a feasible solution it can only take the values 0 or 1 due to the constraints.&lt;/p&gt;&#xA;&lt;p&gt;What are the dis/advantages in this approach compared to describing &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; as binary variable when solving such a model using existing solvers (CBC, Gurobi, CPLEX, etc.)?&lt;/p&gt;&#xA;" OwnerUserId="242" LastActivityDate="2021-10-29T12:52:26.750" Title="Modeling question on continuous variable that dependens on binary variables" Tags="|mixed-integer-programming|linear-programming|modeling|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7205" PostTypeId="1" CreationDate="2021-10-29T16:13:18.337" Score="1" ViewCount="171" Body="&lt;p&gt;I have a multi-objective optimization with the following properties:&lt;/p&gt;&#xA;&lt;p&gt;Objective function: two non-linear functions and one linear function&lt;/p&gt;&#xA;&lt;p&gt;Decision variable: two real variables (Bounded)&lt;/p&gt;&#xA;&lt;p&gt;Constraint: three linear constraint (two bounding constraint and one relationship constraint)&lt;/p&gt;&#xA;&lt;p&gt;Problem type: non-convex&lt;/p&gt;&#xA;&lt;p&gt;Solution required: Global optimum&lt;/p&gt;&#xA;&lt;p&gt;I have used two heuristic algorithms to solve the problem NSGA-II and NSGA-III.&lt;/p&gt;&#xA;&lt;p&gt;I have performed NSGA-II and NSGA-III for the following instances (population size, number of generations, maximum number of functional evaluations(i.e. pop size x no. of gen)): (100,10,1000), (100,50,5000),(100,100,10000), (500, 10, 1000), (500, 50, 25000), and (500,100,50000).&lt;/p&gt;&#xA;&lt;p&gt;My observations:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Hypervolume increases with increase in number of functional evaluations. However, for a given population size, as the number of generation increases the hypervolume reduces. Which I think should rather increase. Why am I getting such an answer?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Reference front contains 45000 points.&lt;/p&gt;&#xA;&lt;p&gt;Code used:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import os&#xA;import sys  &#xA;iter = 1  &#xA;maxIter = 3 #How many times you want to do it…&#xA;while (iter &amp;lt;= maxIter):&#xA;    from jmetal.algorithm.multiobjective.nsgaii import NSGAII&#xA;    from jmetal.operator import SBXCrossover, PolynomialMutation&#xA;    from jmetal.util.termination_criterion import StoppingByEvaluations&#xA;&#xA;    problem = MyProblem()&#xA;    MFES= 10000&#xA;&#xA;    algorithm = NSGAII(&#xA;    problem=problem,&#xA;    population_size=100,&#xA;    offspring_population_size=100,&#xA;    mutation=PolynomialMutation(probability=0.3, distribution_index=20),&#xA;    crossover=SBXCrossover(probability=0.9, distribution_index=20),&#xA;    termination_criterion=StoppingByEvaluations(max_evaluations=MFES)&#xA;    )&#xA;&#xA;    algorithm.run()&#xA;    solutions = algorithm.get_result()&#xA;   &#xA;    from jmetal.util.solution import get_non_dominated_solutions&#xA;    front = get_non_dominated_solutions(solutions)&#xA;   &#xA;    approximation_front = np.array([s.objectives for s in front])&#xA;    reference_front = RF&#xA;    from sklearn.preprocessing import MinMaxScaler&#xA;    min_max_scaler = MinMaxScaler()&#xA;    reference_front_norm = min_max_scaler.fit_transform(reference_front)&#xA;    approximation_front_norm = min_max_scaler.transform(approximation_front)&#xA;    reference_point_norm = np.array([1,1,1])&#xA;   &#xA;   &#xA;    from jmetal.core.quality_indicator import GenerationalDistance,InvertedGenerationalDistance,EpsilonIndicator,HyperVolume&#xA;&#xA;    GD = GenerationalDistance(reference_front_norm)&#xA;    IGD = InvertedGenerationalDistance(reference_front_norm)&#xA;    Epsilon = EpsilonIndicator(reference_front_norm)&#xA;    HV = HyperVolume(reference_point_norm)&#xA;   &#xA;    print('GD:', GD.compute(approximation_front_norm))&#xA;    print('IGD:', IGD.compute(approximation_front_norm))&#xA;    print('Epsilon:', Epsilon.compute(approximation_front_norm))&#xA;    print('Hypervolume:', HV.compute(approximation_front_norm))&#xA;   &#xA;    iter += 1&#xA;print('Loop ended.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5794" LastEditorUserId="5794" LastEditDate="2021-11-02T02:29:28.433" LastActivityDate="2021-11-02T02:29:28.433" Title="Relationship between Hypervolume and population size, number of generations, and number of functional evaluations?" Tags="|heuristics|metaheuristics|multi-objective-optimization|genetic-algorithm|" AnswerCount="0" CommentCount="10" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7207" PostTypeId="1" AcceptedAnswerId="7208" CreationDate="2021-10-31T16:31:55.783" Score="4" ViewCount="219" Body="&lt;p&gt;The following Big-M conjunction appears on page 14:3 of &lt;a href=&quot;https://drops.dagstuhl.de/opus/volltexte/2018/9719/pdf/OASIcs-ATMOS-2018-14.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Path&amp;amp;Cycle Formulation for the Hotspot Problem in Air Traffic Management&lt;/a&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;  \text{(i)} \quad t_{(g, \; s)} - t_{(f, \; s+1)} &amp;amp;\geq -M(1 -  y^s_{fg}) \nonumber \\&#xA;  \text{(ii)} \quad t_{(f, \; s)} - t_{(g, \; s+1)} &amp;amp;\geq -M(1 -  y^s_{gf}) \nonumber \\&#xA;  \text{(iii)} \quad t_{(g, \; s+1)} - t_{(f, \; s)} &amp;amp;\geq -M(1 -  x^s_{fg}) \label{eq:5}\\&#xA;  \text{(iv)} \quad t_{(f, \; s+1)} - t_{(g, \; s)} &amp;amp;\geq -M(1 -  x^s_{fg})\nonumber \\&#xA;  \text{where} \quad y^s_{fg}, \; y^s_{gf}, \; x^s_{fg} &amp;amp;\in \{0, \; 1\} \nonumber &#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; are a pair of flights that will visit sector &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; at some point.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If flight &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; enters &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; before &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, binary quantity &lt;span class=&quot;math-container&quot;&gt;$y^s_{fg}=1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If flight &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; enters &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; before &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, binary quantity &lt;span class=&quot;math-container&quot;&gt;$y^s_{gf}=1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If flight &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; shares &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, binary quantity &lt;span class=&quot;math-container&quot;&gt;$x^s_{fg}=1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;In a valid flight schedule, only one of these binary quantities can be 1.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The entry time of flight &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; into sector &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is given by &lt;span class=&quot;math-container&quot;&gt;$t_{(f, \; s)}$&lt;/span&gt;. The entry time for the flight's next sector is written as &lt;span class=&quot;math-container&quot;&gt;$t_{(f, \; s + 1)}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$y^s_{fg}=1$&lt;/span&gt;, then  &lt;span class=&quot;math-container&quot;&gt;$t_{(g, \; s)} - t_{(f, \; s+1)} \geq 0$&lt;/span&gt;. With a sufficiently large &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, wouldn't the inequality hold for (ii), (iii), and (iv) as well, however? Is this what is meant with redundant constraints (p. 14:4)? What do these constraints then accomplish?&lt;/p&gt;&#xA;" OwnerUserId="7448" LastEditorUserId="7448" LastEditDate="2021-10-31T16:57:43.953" LastActivityDate="2021-10-31T18:17:29.343" Title="How do constraints become redundant in a Big-M conjunction?" Tags="|mixed-integer-programming|constraint|scheduling|big-m|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7208" PostTypeId="2" ParentId="7207" CreationDate="2021-10-31T18:17:29.343" Score="6" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$y^s_{fg}=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$y^s_{gf}=0=x^s_{fg}$&lt;/span&gt;. So the right-hand sides of (ii), (iii) and (iv) become &lt;span class=&quot;math-container&quot;&gt;$-M$&lt;/span&gt; (think &lt;span class=&quot;math-container&quot;&gt;$-\infty$&lt;/span&gt; here), which means any values of the left-hand side variables will satisfy them. So, &lt;em&gt;in this case&lt;/em&gt;, constraints (ii)-(iv) have no influence on the solution. If, say, &lt;span class=&quot;math-container&quot;&gt;$y^s_{gf}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^s_{fg}=0=x^s_{fg}$&lt;/span&gt;, then (ii) becomes relevant and (i), (iii) and (iv) have no influence on the solution. This is what the authors mean by &amp;quot;redundant&amp;quot;. Note that none of the constraints is redundant overall; they are just redundant in certain portions of the solution space.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-10-31T18:17:29.343" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7209" PostTypeId="2" ParentId="3279" CreationDate="2021-11-01T12:48:24.160" Score="4" Body="&lt;p&gt;I guess it is a bit late now, but recently I have been developing a package for solving large instances of the &lt;strong&gt;capacitated multiple-depot vehicle routing problem&lt;/strong&gt; with mileage constraints, which is available here: &lt;a href=&quot;https://gitlab.com/vikplamenov/vrpoptima/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vrpoptima -  Genetic Solver for a Capacitated Multiple-Depot Vehicle Routing Problem with Mileage Constraints&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is actually a generalization of the classical single-depot vehicle routing problem, as in the current version we could have unique positions for each agent (vehicle) and also impose mileage constraints on each agent. In case anyone is interested in testing and extending this package, please do let me know. Hope this helps someone in the future.&lt;/p&gt;&#xA;" OwnerUserId="7453" LastActivityDate="2021-11-01T12:48:24.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7210" PostTypeId="1" AcceptedAnswerId="7211" CreationDate="2021-11-01T12:55:37.220" Score="7" ViewCount="1271" Body="&lt;p&gt;I have a quadratic programming model (i.e., quadratic objective function and linear constraint) and, I want to solve it on an open-source solver. Since our project developed on C#, we also would like to use C# on this model. Does anyone have experience?&lt;/p&gt;&#xA;" OwnerUserId="7451" LastEditorUserId="7451" LastEditDate="2021-11-05T09:29:17.407" LastActivityDate="2021-11-05T09:29:17.407" Title="Is there any open source quadratic programming solver with C# API" Tags="|nonlinear-programming|quadratic-programming|open-source|c#|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7211" PostTypeId="2" ParentId="7210" CreationDate="2021-11-01T13:22:51.600" Score="6" Body="&lt;p&gt;Ipopt seems to have a &lt;a href=&quot;https://github.com/cureos/csipopt&quot; rel=&quot;nofollow noreferrer&quot;&gt;C# binding&lt;/a&gt;. From my own experience &lt;a href=&quot;https://worhp.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;WORHP&lt;/a&gt; is easy to wrap in high level languages, due a variety of interfaces compatible with different programming styles.&lt;/p&gt;&#xA;&lt;p&gt;Ipopt is a local interior point solver that performs well on quadratic problems. WORHP uses as SQP algorithm, if all constraints and the objective are marked as quadratic or linear it will run the QP algorithm only once. Note that these solvers are meant for convex QPs.&lt;/p&gt;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://stackoverflow.com/questions/2687749/quadratic-programming-in-c-sharp-net&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Other solvers to consider with which i have no experience: OSQP, &lt;a href=&quot;https://github.com/stevengj/nlopt&quot; rel=&quot;nofollow noreferrer&quot;&gt;nlopt&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-11-01T15:30:25.650" LastActivityDate="2021-11-01T15:30:25.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7212" PostTypeId="1" AcceptedAnswerId="7214" CreationDate="2021-11-01T15:05:26.747" Score="5" ViewCount="760" Body="&lt;p&gt;I have the following problem: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad c^T x\\\text{s.t.}&amp;amp;\quad Ax=b\\&amp;amp;\quad x\ge0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$m\times n$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$m&amp;lt;n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have an optimal solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; in which all variables are non-zero.&#xA;I know that there must exist another optimal solution &lt;span class=&quot;math-container&quot;&gt;$x^{**}$&lt;/span&gt;, a &amp;quot;basic feasible solution&amp;quot;, in which at most &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; variables are non-zero.&lt;/p&gt;&#xA;&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;, is there an algorithm for finding &lt;span class=&quot;math-container&quot;&gt;$x^{**}$&lt;/span&gt; using polynomially-many arithmetic operations? (I know that &lt;span class=&quot;math-container&quot;&gt;$x^{**}$&lt;/span&gt; can be found using the Simplex method, but I am looking for a polynomial-time algorithm).&lt;/p&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="1160" LastEditDate="2021-11-02T12:37:56.780" LastActivityDate="2021-11-02T12:37:56.780" Title="How can I move from an optimal feasible solution to an optimal basic feasible solution?" Tags="|linear-programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7214" PostTypeId="2" ParentId="7212" CreationDate="2021-11-01T16:06:35.473" Score="5" Body="&lt;p&gt;Since the constraints are equations, solve the linear system &lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left[\begin{array}{c}&#xA;A\\&#xA;c^{\prime}&#xA;\end{array}\right]y=0&#xA;$$&lt;/span&gt;for any nonzero solution &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. You can look for an eigenvector with nonzero eigenvalue, or just tack on the equation &lt;span class=&quot;math-container&quot;&gt;$r^\prime y = 1$&lt;/span&gt; for some vector &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; randomly generated from a continuous distribution (e.g., all components uniform over &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt;). Solving a linear system should be polynomial time. Now look for the largest scalar &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$x^* + t y\ge 0$&lt;/span&gt; (and, if that is unbounded, repeat using &lt;span class=&quot;math-container&quot;&gt;$-y$&lt;/span&gt; in place of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;). Replace &lt;span class=&quot;math-container&quot;&gt;$x*$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x^* + ty$&lt;/span&gt; for that value of &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, drop the variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; which just became 0 from the problem, and repeat until you are at a corner point (BFS).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-01T16:06:35.473" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7215" PostTypeId="2" ParentId="7212" CreationDate="2021-11-02T06:31:49.303" Score="5" Body="&lt;p&gt;You can find a basic solution such that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c^T x^{**} \leq c^T x^{*}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;using at most n-m simplex pivots. That is strongly polynomial time.&lt;/p&gt;&#xA;&lt;p&gt;Any decent recent text book about the simplex method should teach you that.&#xA;You may also be able to figure it out based on description of the primal simplex method in &lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.229.3959&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;my note&lt;/a&gt;. (You just try to pivot each nonzero nonbasic variable in the basis. It is decreased if the reduced cost is negative otherwise it is increased.)&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2021-11-02T07:57:21.773" LastActivityDate="2021-11-02T07:57:21.773" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7216" PostTypeId="2" ParentId="7199" CreationDate="2021-11-02T15:22:32.450" Score="1" Body="&lt;p&gt;I would like to add an answer by &lt;a href=&quot;https://math.stackexchange.com/questions/4293407/the-difference-between-subtour-elimination-constraints-in-the-symmetric-and-asym/4293446#4293446&quot;&gt;@Misha Lavrov&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;p&gt;The MTZ constraints really need to know the direction of an edge in order to work. I have called them &amp;quot;timing constraints&amp;quot; when teaching, because they are an inequality representation of the condition&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 1$&lt;/span&gt; (if we go from vertex &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to vertex &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;) then &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt; (the MTZ variable that intuitively means &amp;quot;the time at which we visit vertex &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&amp;quot;) is at least &lt;span class=&quot;math-container&quot;&gt;$t_i + 1$&lt;/span&gt; (we visit &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt; later than &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt;). In particular, &lt;span class=&quot;math-container&quot;&gt;$t_j &amp;gt; t_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This constraint is skipped for the starting vertex, which is also the ending vertex. But there cannot be a cycle not containing that vertex, because we can't have &lt;span class=&quot;math-container&quot;&gt;$t_a &amp;lt; t_b &amp;lt; t_c &amp;lt; \dots &amp;lt; t_k &amp;lt; t_a$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If we do not know the orientation that &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; indicates, then we can't enforce this constraint. Also, it wouldn't be enough to ask &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$t_j \ge t_i + 1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$t_i \ge t_j + 1$&lt;/span&gt;&amp;quot; even if we could ask that, because then you could have an even cycle that alternates between time &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and time &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The DFJ constraints are going to be fine no matter what. In a directed formulation, for any vertex set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; not equal to &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; or the empty set, we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;    \sum_{i \in S} \sum_{j \notin S} x_{ij} \ge 1 \qquad \sum_{i \notin S} \sum_{j \in S} x_{ij} \ge 1&#xA;$$&lt;/span&gt;&#xA;and just having one of these is sufficient (they break the same subtours, and in fact given the starting constraints of the TSP, either implies the other). In an undirected formulation, we could use either one just fine, or we could technically increase the RHS to &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; (because any tour must leave &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; and come back, so there's at least &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; crossing edges).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Regarding graph symmetry and traveling cost symmetry: essentially, these are the same in the traveling salesman setting, since we assume all edges exist and just give them a very high cost if we don't want them to be used. The distinction you need to be aware of is that even if your traveling costs are symmetric (&lt;span class=&quot;math-container&quot;&gt;$c_{ij} = c_{ji}$&lt;/span&gt;) you may choose to go with a directed graph formulation of the problem (for example, if you really want to use the MTZ constraints).&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-11-02T15:22:32.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7217" PostTypeId="1" CreationDate="2021-11-02T20:10:27.720" Score="5" ViewCount="408" Body="&lt;p&gt;Are there any advantages of adding constraints in the Benders master problem that ensure the feasibility of the subproblems? This would not add any feasibility cuts. Or is it beneficial to have a master problem find an assignment and then determine feasibility in the subproblem? Or this does not matter?&lt;/p&gt;&#xA;&lt;p&gt;I am solving a scheduling problem where I assign patients to operating rooms with deterministic surgery durations in the master problem. In the subproblem, patients are sequenced and costs are calculated. I can include constraints such that no OR gets assigned the number of patients where the total surgery duration does not exceed 8 hours capacity. I am only adding the no-good type of cuts for optimality.&lt;/p&gt;&#xA;" OwnerUserId="3520" LastEditorUserId="500" LastEditDate="2023-04-02T19:50:14.127" LastActivityDate="2023-04-02T19:50:14.127" Title="Combinatorial Feasibility Cuts for Benders Decomposition" Tags="|mixed-integer-programming|benders-decomposition|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7218" PostTypeId="2" ParentId="7217" CreationDate="2021-11-02T20:25:53.023" Score="5" Body="&lt;p&gt;I'm not aware that either approach is automatically better than the other. Once consideration regarding putting feasibility constraints in the master problem is whether they would likely be violated in the subproblem were they not already present. If you are adding a large number of feasibility constraints in the master (relative to a small number that would otherwise be generated in the subproblem), you might be slowing the solver down unnecessarily.&lt;/p&gt;&#xA;&lt;p&gt;This also may be solver-dependent. With CPLEX, for instance, you could add the feasibility constraints to the master as &amp;quot;lazy constraints&amp;quot;, meaning that they for the most part sit to one side and are only checked when CPLEX thinks it has an integer-feasible candidate solution. If any lazy constraints are violated by that solution, they become active (at least for a while) and the candidate is discarded. Some other solvers may have similar features that prevent the feasibility constraints from being a drag on performance.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-02T20:25:53.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7219" PostTypeId="2" ParentId="7217" CreationDate="2021-11-03T01:36:25.167" Score="4" Body="&lt;p&gt;The trade-off you want to make is: (1) how hard is it to solve the master problem (and hence, how much time does it take), and (2) how many Benders iterations does it take to find a feasible/optimal solution (depends on what you are looking for). This you can best determine through some benchmarking.&lt;/p&gt;&#xA;&lt;p&gt;As a rule-of-thumb, you want to add a relaxation of the subproblem to the master problem, to guide the master problem in the right direction. The trick here is to keep the master problem light enough that it can be solved efficiently.&lt;/p&gt;&#xA;&lt;p&gt;A standard example is the capacitated facility location problem where the master problem determines which facilities to open while minimizing opening costs, and the subproblem solves an assignment problem to assign customers to opened facilities while minimizing assignment costs. Since the master problem attempts to minimize the total cost to open facilities, in the first iteration, in the absence of any constraints, the master problem will not open any facilities at all. Consequently, the subproblem will return a feasibility cut, because non of the customers can be assigned to a facility. Many more of these iterations may follow until finally a feasible solution is discovered. Many of these iterations could have been avoided if you had added a constraint to the master problem stating that at least a minimum number of facilities should be opened in order to permit a feasible solution (this minimum could be determined by solving a bin-packing problem).&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2021-11-03T01:36:25.167" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7220" PostTypeId="1" CreationDate="2021-11-03T07:06:15.630" Score="3" ViewCount="362" Body="&lt;p&gt;I have 6 binary variables &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; from 0 to 5. I would like to model the next if-else statement using only MILP constraints&lt;/p&gt;&#xA;&lt;p&gt;  if &lt;span class=&quot;math-container&quot;&gt;$(a_0+a_1+a_2)\mod 2=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$(a_3+a_4+a_5) \mod 2 = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I tried &lt;code&gt;constraint (a_3+a_4+a_5) mod 2 = (a_0+a_1+a_2)mod 2+1&lt;/code&gt;, but this constraint is also taking the case when &lt;span class=&quot;math-container&quot;&gt;$(a_0+a_1+a_2)\mod 2 = 0$&lt;/span&gt;. And I need to take in consideration &lt;strong&gt;only&lt;/strong&gt; the case &lt;span class=&quot;math-container&quot;&gt;$(a_0+a_1+a_2)\mod 2 = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7463" LastEditorUserId="123" LastEditDate="2021-11-03T08:34:03.413" LastActivityDate="2021-11-03T14:24:23.500" Title="Implement if-else without then part using int variables {0,1}" Tags="|mixed-integer-programming|binary-variable|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7221" PostTypeId="2" ParentId="7220" CreationDate="2021-11-03T07:48:48.720" Score="5" Body="&lt;p&gt;One way to do this is to introduce three auxiliary variables: &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are non-negative integers and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is binary. The binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; should equal 1 if and only if &lt;span class=&quot;math-container&quot;&gt;$a_0+a_1+a_2 \mbox{ mod } 2=1 $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then you may add the following constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  &amp;amp;a_0+a_2+a_2=2x+z\\&#xA;  &amp;amp;a_3+a_4+a_5=2y+(1-z)\\&#xA;  &amp;amp;x,y\in\mathbb{N}_0,\ z\in\{0,1\}&#xA;\end{align}&lt;/span&gt;&#xA;The first constraint says that &lt;span class=&quot;math-container&quot;&gt;$a_0+a_1+a_2 \mbox{ mod } 2=1 $&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt; and the other constraint says tha &lt;span class=&quot;math-container&quot;&gt;$a_3+a_4+a_5 \mbox{ mod } 2=0 $&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Edit: Based on the comment by @RobPratt my first answer was a bit too restrictive. In stead of adding one binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, introduce &lt;em&gt;two&lt;/em&gt; binary variables &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_2$&lt;/span&gt; and add the following constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  &amp;amp;a_0+a_2+a_2=2x+z_1\\&#xA;  &amp;amp;a_3+a_4+a_5=2y+z_2\\&#xA;  &amp;amp;z_1+z_2\leq 1\\&#xA;  &amp;amp;x,y\in\mathbb{N}_0,\ z_i\in\{0,1\}, i=1,2&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2021-11-03T14:24:23.500" LastActivityDate="2021-11-03T14:24:23.500" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7222" PostTypeId="1" CreationDate="2021-11-03T09:25:35.383" Score="3" ViewCount="741" Body="&lt;p&gt;In a branch and bound algorithm, what is the difference between hot and warm starting and what kind of information does each of them require to store in memory? Otherwise, for the hot starting, what does the L/U-factorization mean?&lt;/p&gt;&#xA;" OwnerUserId="5146" LastEditorUserId="500" LastEditDate="2023-12-13T18:05:08.683" LastActivityDate="2023-12-13T18:05:08.683" Title="B&amp;B hot and warm starting" Tags="|branch-and-bound|warm-start|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7223" PostTypeId="2" ParentId="7222" CreationDate="2021-11-03T12:59:56.943" Score="9" Body="&lt;p&gt;In general, the definition of what is a warm start or hot start (or &amp;quot;jump start&amp;quot;) depends on the actual solver. Different solvers allow different kind of hot/warm starts and may call things different names. So your solver manuals should tell what exactly these things are and how they differ between different solvers.&lt;/p&gt;&#xA;&lt;p&gt;All the terms refer to the same concept: providing additional information to the solver to allow the solver to start faster.&lt;/p&gt;&#xA;&lt;p&gt;For example, you could provide a feasible solution to the solver. That way the solver does not have to find a first feasible solution itself. A solver may also allow you to specify a starting basis for the simplex algorithm which then defines the initial basis matrix. &amp;quot;L/U factorization&amp;quot; refers to a factorization of that basis matrix that is required to solve linear equation systems involving the basis matrix during the simplex algorithm.&lt;/p&gt;&#xA;&lt;p&gt;Again, the solver documentation should tell you what the things are that you can provide and how these help the solver in potentially solving the problem faster.&lt;/p&gt;&#xA;" OwnerUserId="3179" LastActivityDate="2021-11-03T12:59:56.943" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7224" PostTypeId="2" ParentId="5408" CreationDate="2021-11-03T14:32:05.380" Score="1" Body="&lt;p&gt;I am not sure of the bounds of the problem, but I'll try to provide an answer.&lt;/p&gt;&#xA;&lt;p&gt;Let's consider the following two sets:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;V = \{v: vehicles\} \\&#xA;T = \{t: days\}&#xA;$$&lt;/span&gt;&#xA;Now, we have the parameters you have provided, which I understand are the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;VCAP_v: \text{capacity of vehicle v} \\&#xA;VCOST_v: \text{cost of vehicle v}\\&#xA;D_t: \text{demand of day t}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The only decision variable is the number of trucks that you have to deploy (each day?) to meet the demands. Therefore.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;n_{t,v}: \text{integer variable that indicates the number of vehicles v that are deployed on day t}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You only have one constraint, which is the demand satisfaction constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{v\in V}{n_{t,v}VCAP_v} \geq D_t \qquad \forall t\in T$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And the objective function is simply:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \min z = \sum_{v\in V}\sum_{t\in T}n_{t,v}VCOST_v$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If, on the other hand, you cannot change the election of trucks, this means, you have to decide which trucks to buy, the integer variable would lose a set (&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;If the question was however how to introduce integer variables, it depends on the progamming language. GAMS and Pyomo (I think) can directly establish a variable as integer. Otherwise, I think you have to manually use binary variables to establish the integer variables.&lt;/p&gt;&#xA;" OwnerUserId="7381" LastActivityDate="2021-11-03T14:32:05.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7225" PostTypeId="1" CreationDate="2021-11-03T17:33:47.837" Score="-3" ViewCount="158" Body="&lt;p&gt;As a new python learner, I'm supposed to implement either GENETIC ALGORITHM or TABU SEARCH. Which one would be easier for me? Both of them are constructed for the same problem.&lt;/p&gt;&#xA;" OwnerUserId="5884" LastActivityDate="2021-11-04T19:24:01.930" Title="Heuristic Algorithms Implementation" Tags="|python|heuristics|metaheuristics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7226" PostTypeId="1" CreationDate="2021-11-03T20:53:51.063" Score="4" ViewCount="119" Body="&lt;p&gt;&lt;strong&gt;The problem.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$X,A \in\mathbb{R}^{n\times m}$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$W\in\mathbb{R}^{nm\times nm}$&lt;/span&gt; be a positive definite matrix. I want to know if there is a &lt;em&gt;closed-form solution&lt;/em&gt; to this problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{X} \frac{1}{2}\text{vec}(X-A)^\top W\text{vec}(X-A) + \|X\|_*,&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\|X\|_*$&lt;/span&gt; denotes the nuclear norm of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\text{vec}(X)$&lt;/span&gt; denotes the vectorization operation of the matrix &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;A solution in the unweighted case.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$W = I$&lt;/span&gt; (the identity matrix), the problem is known as Singular Value Thresholding (SVT):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{X} \frac{1}{2}\|X-A\|_F^2 + \|X\|_*,&#xA;$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\|X\|_F$&lt;/span&gt; is the Frobenius norm of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, and a solution is found in &lt;a href=&quot;https://arxiv.org/pdf/0810.3286.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper (thm. 2.1)&lt;/a&gt;, and is nicely expressed as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$X = U\max(0,S-I)V^\top,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$A = USV^\top$&lt;/span&gt; is the SVD of the matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;. In the weighted case I am not sure whether is possible to express the solution in closed form. This problem is also known as Weighted Singular Value Thresholding (WSVT) and a closed-form solution has not been found yet.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Related work.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://ieeexplore.ieee.org/document/1166684&quot; rel=&quot;nofollow noreferrer&quot;&gt;Paper 1&lt;/a&gt; studies the problem of the Weighted Low-Rank Approximation (WLRA) problem which is more difficult than the one proposed in this question (the problem in the question is a convex relaxation of the one in the paper). They have a closed-form solution in the case &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; can be expressed as &lt;span class=&quot;math-container&quot;&gt;$W = W_1 \otimes W_2$&lt;/span&gt;. This was my initial problem, however ...&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/pdf/1012.0197.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Paper 2&lt;/a&gt; proves that the WLRA problem is NP-hard in general and that is the reason why I moved from WLRA to WSVT (actually my initial problem includes also other constraints, but that is another story).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/pdf/1707.00133.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Paper 3&lt;/a&gt; studies the WSVT problem, but they come up with a numerical solution (no analytical solution). Is there really no way one can solve the problem in closed form as for the unweighted SVT problem?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ese.wustl.edu/%7Enehorai/paper/Huang_Low_Rank_Approximation_TIP_2019.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Paper 4&lt;/a&gt; studies a related problem (the same as &lt;a href=&quot;https://math.stackexchange.com/questions/4289366/what-is-proximal-operator-of-nuclear-norm-in-weighted-space-variable-metric&quot;&gt;this related question&lt;/a&gt;), where the nuclear norm is weighted by a vector &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;. In this case, we have an analytical solution. However, I tried to recast my problem in this form with no success.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Why bother with a closed form solution?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I really need an analytical solution because the original problem is much more complex (includes other convex constraints and another outer optimization over another set of variables). To solve such optimization problem, I believe a closed-form solution for the simpler problem considered in this question would help considerably.&lt;/p&gt;&#xA;" OwnerUserId="5005" LastEditorUserId="5005" LastEditDate="2021-11-06T14:31:20.380" LastActivityDate="2021-11-06T14:31:20.380" Title="Weighted nuclear norm minimization" Tags="|optimization|convex-optimization|linear-algebra|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7227" PostTypeId="2" ParentId="7158" CreationDate="2021-11-03T23:03:36.580" Score="3" Body="&lt;p&gt;I posted a heuristic, based on a Delaunay triangulation, &lt;a href=&quot;https://orinanobworld.blogspot.com/2021/11/smallest-polygon-containing-2d-point-set.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;on my blog&lt;/a&gt;. Basically, you start with the triangulation, including the boundary of the convex hull. You then roam the boundary, looking for segments belonging to a triangle whose third vertex is not yet on the boundary. When you find one, you remove the segment and replace it with the other two sides of the triangle, effectively deleting the area of the triangle from the area of the enclosing polygon. This continues until a full lap around the boundary of the polygon produces no further changes.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-03T23:03:36.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7228" PostTypeId="2" ParentId="7158" CreationDate="2021-11-04T05:50:25.473" Score="2" Body="&lt;p&gt;Just a quick heuristic idea:&lt;/p&gt;&#xA;&lt;p&gt;Step 1) I would start with determining the convex hull of the original set of points in &lt;span class=&quot;math-container&quot;&gt;$\mathcal O(n \log n)$&lt;/span&gt; with the &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Graham_scan&quot; rel=&quot;nofollow noreferrer&quot;&gt;Graham scan&lt;/a&gt;. There are various implementations out there (in many languages). Robert Sedgewick has one in its book &lt;em&gt;Algorithms&lt;/em&gt; (1983). The Java Version can be found &lt;a href=&quot;https://algs4.cs.princeton.edu/99hull/GrahamScan.java.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Step 2) Then I would remove the points defining the incumbent hull and determine the convex hull of the remaining points. Afterwards I would merge the incumbent hull and convex hull following a greedy approach, i.e. I would check for each pair of points whether the area defining the hull decreases and if the resulting hull still is a hull.&lt;/p&gt;&#xA;&lt;p&gt;This approach limits the points to consider in each step and hopefully allows to determine good solutions.&lt;/p&gt;&#xA;&lt;p&gt;One can repeat step 2 multiple times.&lt;/p&gt;&#xA;" OwnerUserId="7468" LastEditorUserId="7468" LastEditDate="2021-11-04T07:00:29.060" LastActivityDate="2021-11-04T07:00:29.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7229" PostTypeId="1" AcceptedAnswerId="7230" CreationDate="2021-11-04T12:28:48.003" Score="3" ViewCount="156" Body="&lt;p&gt;Problem: Write the following task as a linear program: &lt;span class=&quot;math-container&quot;&gt;$\min f(x),x\in[-2,5]$&lt;/span&gt; where&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}f(x) := \begin{cases}&#xA;  -2x+2,&amp;amp;\quad-2\le x&amp;lt;-1\\    &#xA;  -x+3,&amp;amp;\quad-1\le x &amp;lt; 1\\&#xA;2,&amp;amp;\quad1\le x&amp;lt;3\\&#xA;0.5x+0.5,&amp;amp;\quad3\le x&amp;lt;4\\&#xA;3x-9.5,&amp;amp;\quad4\le x\le5.&#xA;\end{cases}\end{align}&lt;/span&gt;&#xA;TIP: f(x) can be written as the maximum of 5 affine linear functions&lt;/p&gt;&#xA;&lt;p&gt;While the solution is rather obvious (&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;), I don't quite know how I would write this as a linear program with this tip. Some thoughts of mine:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad y\\\text{s.t.}&amp;amp;\quad&#xA;y \ge -2x_1 +2\\&amp;amp;\quad&#xA;y \ge -x_2+3\\&amp;amp;\quad&#xA;y \ge 2\\&amp;amp;\quad&#xA;y \ge 0.5x_3+0.5\\&amp;amp;\quad&#xA;y \ge -3x_4+9.5\end{align}&lt;/span&gt;&#xA;for &lt;span class=&quot;math-container&quot;&gt;$x_1 \in [-2,1)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_2 \in [-1,1)$&lt;/span&gt; etc.&#xA;But this obviously leads to a wrong solution of the problem. The rest of the exercises were super easy and this is an introductory operations research course for economists, so it shouldn't be too hard. I just cant come up with a good solution to this and the tip is confusing me more than it is helping me. Is there a good way to solve this?&lt;/p&gt;&#xA;" OwnerUserId="7470" LastEditorUserId="123" LastEditDate="2021-11-04T14:22:38.717" LastActivityDate="2021-11-04T14:22:38.717" Title="Linearization of problem with affine linear functions" Tags="|linear-programming|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7230" PostTypeId="2" ParentId="7229" CreationDate="2021-11-04T12:51:35.547" Score="5" Body="&lt;p&gt;You have the right idea, but just use &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in place of each &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.  That is, you need only two variables, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$-2\le x\le 5$&lt;/span&gt;, and the problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; subject to linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y &amp;amp;\ge -2x+2 \\    &#xA;y &amp;amp;\ge -x+3 \\&#xA;y &amp;amp;\ge 2 \\&#xA;y &amp;amp;\ge 0.5x+0.5 \\&#xA;y &amp;amp;\ge 3x-9.5 \\&#xA;\end{align}&lt;/span&gt;&#xA;The corresponding feasible region looks like the topmost portion of this plot, where I have labeled the breakpoints:&#xA;&lt;a href=&quot;https://www.desmos.com/calculator/gkf5nfpvxi&quot; rel=&quot;noreferrer&quot;&gt;https://www.desmos.com/calculator/gkf5nfpvxi&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-11-04T13:59:28.000" LastActivityDate="2021-11-04T13:59:28.000" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7231" PostTypeId="1" AcceptedAnswerId="7232" CreationDate="2021-11-04T14:22:22.680" Score="14" ViewCount="1678" Body="&lt;p&gt;I am from a machine learning (ML) background and am interested in how ML is applied to Combinatorial Optimisation. As such, as I have been reading around the area and have come across the statement that essentially states 'designing heuristics requires considerable domain knowledge'.&lt;/p&gt;&#xA;&lt;p&gt;For instance, in &lt;a href=&quot;https://www.diva-portal.org/smash/get/diva2:1452303/FULLTEXT01.pdf&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt; they make the statement &amp;quot;Nonetheless, the design process of such heuristic methods requires specialized domain knowledge and involves trial-and-error as well as tuning&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Further, in &lt;a href=&quot;https://arxiv.org/pdf/1909.04063.pdf&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt; they say &amp;quot;However, the effectiveness of general algorithms is dependent on the problem being considered, and high levels of performance often require extensive tailoring and domain-specific knowledge&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Neither of these papers provide references to support such a statement so I am wondering what kind of domain knowledge they are referring to? Based on the papers that I have read where new CO heuristics are introduced, it seems that the 'domain knowledge' is a good understanding of the problem (e.g. TSP) and being good at the math required to prove bounds on the solution qualities, search strategies, etc.&lt;/p&gt;&#xA;&lt;p&gt;Also, it doesn't seem like any extra requirement on domain knowledge is required compared to if you were developing an algorithm for some other field (e.g. an ML algorithm!); in general I would argue that to develop an algorithm to solve a problem you would have to have pretty good knowledge of the area you're developing the algorithm for, that shouldn't be specific to CO.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering if anyone could provide some insight into these comments, please.&lt;/p&gt;&#xA;" OwnerUserId="7471" LastActivityDate="2021-11-05T15:48:32.237" Title="Why does the design of heuristics require considerable domain knowledge?" Tags="|combinatorial-optimization|heuristics|machine-learning|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7232" PostTypeId="2" ParentId="7231" CreationDate="2021-11-04T15:14:28.953" Score="17" Body="&lt;p&gt;The following is largely opinion/conjecture on my part. Many (though not all) heuristics involve neighborhood search. For that type of heuristic to be effective, you need &amp;quot;neighborhood&amp;quot; to be defined in a way that is both computationally convenient (moving from one solution to a &amp;quot;neighboring&amp;quot; solution is straightforward and does not involve solving an NP-nasty subproblem) and meaningful in terms of the objective. The latter boils down to defining neighborhoods so that a neighborhood of a good solution is likely to contain a better solution. If good and bad solutions are uniformly scattered around neighborhoods, neighborhood search is no better than random search. The ability to figure out a good definition of &amp;quot;neighborhood&amp;quot; may require some domain knowledge (understanding of the particular problem).&lt;/p&gt;&#xA;&lt;p&gt;Similarly, the efficacy of evolutionary metaheuristics such as genetic algorithms depends on how solutions are encoded (the &amp;quot;chromosome&amp;quot; in a GA), and possibly on how crossover, mutation and other operators are defined. You want crossover of two &amp;quot;good&amp;quot; solutions to be likely to produce a better solution, and mutation of a &amp;quot;good&amp;quot; solution to have a decent chance of producing a better solution. Otherwise, again, the metaheuristic just turns into an overengineered version of random search. Finding an effective encoding can require some understanding of how the objective value depends on &amp;quot;chunks&amp;quot; of the solution, which again is a form of domain knowledge.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-04T15:14:28.953" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7233" PostTypeId="2" ParentId="7225" CreationDate="2021-11-04T19:24:01.930" Score="1" Body="&lt;p&gt;Genetic algorithm is a lot wider family of algorithm that is a lot more tuneable. It kinda depends on your problem space whether TABU search is sensible but i would recommend implementing tabu search which basically a variation of random search.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-11-04T19:24:01.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7234" PostTypeId="2" ParentId="3476" CreationDate="2021-11-04T19:41:29.230" Score="9" Body="&lt;p&gt;Sure thing, you can download from &lt;a href=&quot;https://archive.org/details/mpx_20211104&quot; rel=&quot;nofollow noreferrer&quot;&gt;archive.org&lt;/a&gt;. You need to run it in DOSBOX.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WZlRN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WZlRN.png&quot; alt=&quot;MPX and GT Hubs&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rEEGM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rEEGM.png&quot; alt=&quot;MPX and GT Hubs&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7472" LastEditorUserId="491" LastEditDate="2022-01-12T13:58:54.260" LastActivityDate="2022-01-12T13:58:54.260" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7235" PostTypeId="2" ParentId="3476" CreationDate="2021-11-04T20:39:51.323" Score="2" Body="&lt;p&gt;Edit: Grunchy delivers the perfect answer to your question.&lt;/p&gt;&#xA;&lt;p&gt;However, if you want to try out something else, see my answer below:&lt;/p&gt;&#xA;&lt;p&gt;====&lt;/p&gt;&#xA;&lt;p&gt;I recommend &lt;a href=&quot;https://www.simio.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SIMIO&lt;/a&gt; if you just want to play around and visualize some basic qeueing concepts. It uses decent 3D Animations and you can easily apply different skins to the resources and objects, to visualize flows and processes. In order to switch from 2D to 3D mode,  just hit &amp;quot;3&amp;quot; on your keyboard. If you want to perform some advanced simulation studies, I recommend &lt;a href=&quot;https://www.anylogic.com/downloads/personal-learning-edition-download/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AnyLogic&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you prefer an open source solution, that, however, is less intuitive and requires some basic programming knowledge, you should check out &lt;a href=&quot;https://simpy.readthedocs.io/en/latest/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SimPy&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7468" LastEditorUserId="7468" LastEditDate="2021-11-05T06:39:12.920" LastActivityDate="2021-11-05T06:39:12.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7236" PostTypeId="2" ParentId="7231" CreationDate="2021-11-04T23:23:20.433" Score="6" Body="&lt;p&gt;&lt;strong&gt;&lt;em&gt;tl;dr&lt;/em&gt;–&lt;/strong&gt;  Having relevant knowledge can help folks come up with better techniques, including heuristic techniques.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Relevant knowledge can be useful in problem-solving.&lt;/h3&gt;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Heuristic&quot; rel=&quot;nofollow noreferrer&quot;&gt;Heuristic&lt;/a&gt; techniques&lt;/em&gt;&lt;/strong&gt; are those that're somehow fuzzy/approximate/unreliable.  The term &amp;quot;&lt;em&gt;heuristic&lt;/em&gt;&amp;quot; is basically a disclaimer, qualifying that a technique isn't ideal.&lt;/p&gt;&#xA;&lt;p&gt;Relevant knowledge (domain-knowledge) can help folks come up with better problem-solving techniques, including heuristic problem-solving techniques.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Example: Heuristic for video-games.&lt;/h3&gt;&#xA;&lt;p&gt;Say you're playing a video-game that you really like and a newbie asks you for advice.  Without considering their exact situation, could provide them with some general advice that'd help guide in the right direction?&lt;/p&gt;&#xA;&lt;p&gt;That'd be a heuristic, and presumably having known about the video-game helped enable you to provide a better one.  The more you know about what's possible, various benefits/costs, gains/risks, etc., the more tools you have to help craft better heuristics (better advice).&lt;/p&gt;&#xA;&lt;p&gt;Unless it's a &lt;a href=&quot;https://en.wikipedia.org/wiki/Solved_game&quot; rel=&quot;nofollow noreferrer&quot;&gt;solved game&lt;/a&gt;, where you can recommend a &lt;a href=&quot;https://en.wikipedia.org/wiki/God%27s_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;perfect strategy&lt;/a&gt;.  Then you'd be giving them a non-heuristic solution rather than a heuristic solution.&lt;/p&gt;&#xA;" OwnerUserId="661" LastEditorUserId="661" LastEditDate="2021-11-05T15:48:32.237" LastActivityDate="2021-11-05T15:48:32.237" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7237" PostTypeId="2" ParentId="5914" CreationDate="2021-11-05T10:41:26.683" Score="2" Body="&lt;p&gt;On a different note (not a course), I recently found &lt;a href=&quot;https://www.youtube.com/channel/UCKMY2i-ROJjOXCxePFewnkg/featured&quot; rel=&quot;nofollow noreferrer&quot;&gt;Subject to&lt;/a&gt;. It is more like an OR-oriented podcast.&lt;/p&gt;&#xA;" OwnerUserId="4150" LastActivityDate="2021-11-05T10:41:26.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7238" PostTypeId="2" ParentId="7202" CreationDate="2021-11-05T11:38:04.653" Score="2" Body="&lt;p&gt;For all &lt;span class=&quot;math-container&quot;&gt;$c&amp;gt;0$&lt;/span&gt; the function of one variable &lt;span class=&quot;math-container&quot;&gt;$$g(x)=c^{x/L}\cdot L - \ln(c)\cdot x=\exp(\ln(c)x/L)\cdot L-\ln(c)\cdot x$$&lt;/span&gt; is convex increasing on &lt;span class=&quot;math-container&quot;&gt;$x\geq 0$&lt;/span&gt; (derivative check) and DCP representable (verbatim). So we can model your extension to all real numbers via&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$u\geq \max(x,0),$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$t\geq g(u).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now if &lt;span class=&quot;math-container&quot;&gt;$x\geq 0$&lt;/span&gt; then we have &lt;span class=&quot;math-container&quot;&gt;$t\geq g(x)$&lt;/span&gt; and if &lt;span class=&quot;math-container&quot;&gt;$x\leq 0$&lt;/span&gt; then we have &lt;span class=&quot;math-container&quot;&gt;$t\geq g(0)=L$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="488" LastActivityDate="2021-11-05T11:38:04.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7239" PostTypeId="2" ParentId="7231" CreationDate="2021-11-05T13:59:45.000" Score="3" Body="&lt;p&gt;Heuristics are &amp;quot;rules of thumb&amp;quot; that in some cases try to estimate some quantity without explicitly computing it. The better the estimate, the better the algorithmic performance, so good heuristics are important. Domain knowledge can help to improve estimates by understanding what is possible or reasonable. Take A* search, for example, which can be used to find a minimum-length path between two points, which requires a heuristic estimate of the remaining distance to the goal. The closer the estimate is the true remaining distance, the faster the algorithm will run, but the heuristic should not overestimate. A decent place to start with the heuristic is the straight-line Euclidean distance between two points. But if you know the agent can only move along a grid, one can use that domain knowledge to instead use the Manhattan distance for a more accurate estimate. Maybe there are spots on the grid that are hard to traverse and come with extra cost, further allowing you to tune the heuristic. The more you know about your domain, the closer the heuristic will reflect the situation it actually describes.&lt;/p&gt;&#xA;&lt;p&gt;Other simple heuristics come from knowing where to look in the first place. Machine learning in high-dimensional data is often difficult, can be prone to overfitting, and can have issues with multiple hypothesis testing. But if your domain knowledge allows you to exclude many features as irrelevant, the problem becomes muh simpler. Poor prior knowledge will have you eliminate truly meaningful features, but good domain knowledge will allow you to reduce the features space to a smaller number of useful dimensions.&lt;/p&gt;&#xA;" OwnerUserId="2364" LastActivityDate="2021-11-05T13:59:45.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7241" PostTypeId="1" AcceptedAnswerId="7433" CreationDate="2021-11-05T17:13:51.920" Score="6" ViewCount="320" Body="&lt;p&gt;Nowadays, we enjoy the expressivity of modern modeling languages.  However, does it exists a modeling language  that takes in input a declarative problem definition (like &lt;a href=&quot;https://ampl.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AMPL&lt;/a&gt; or &lt;a href=&quot;https://www.minizinc.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MiniZinc&lt;/a&gt;, or similar), and produces as output a SAT instance, for instance in the &lt;a href=&quot;https://people.sc.fsu.edu/%7Ejburkardt/data/cnf/cnf.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;DIMACS format&lt;/a&gt;, which can be later solved with any SAT solver which support a standard format?&lt;/p&gt;&#xA;&lt;p&gt;This is for achieving something similar to what we do using the &lt;em&gt;.mps&lt;/em&gt; or &lt;em&gt;.lp&lt;/em&gt; format for ILP problems.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; This question is related to this other (but it is not exactly the same):&#xA;&lt;a href=&quot;https://or.stackexchange.com/questions/6579/extracting-cnf-representation-of-my-problem-from-sat-solver&quot;&gt;Extracting CNF representation of my problem from SAT solver&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="171" LastEditorUserId="491" LastEditDate="2022-11-15T20:56:41.817" LastActivityDate="2022-11-15T20:56:41.817" Title="Does a modeling language that generates SAT instances exist?" Tags="|modeling-languages|sat|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7242" PostTypeId="1" AcceptedAnswerId="7243" CreationDate="2021-11-06T07:42:49.103" Score="1" ViewCount="181" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;A factory creates different types of oils and mixes them together. There exists two types of vegetarian oils (veg1,veg2) and three types of non-vegetarian oils (oil1,oil2,oil3), the price of each oil (per ton) is: &lt;br&gt;&lt;br&gt; veg1=&lt;span class=&quot;math-container&quot;&gt;$115$&lt;/span&gt;, veg2=&lt;span class=&quot;math-container&quot;&gt;$128$&lt;/span&gt;, oil1=&lt;span class=&quot;math-container&quot;&gt;$132$&lt;/span&gt;, oil2=&lt;span class=&quot;math-container&quot;&gt;$109$&lt;/span&gt;, oil3=&lt;span class=&quot;math-container&quot;&gt;$114$&lt;/span&gt;. &lt;br&gt;&lt;br&gt; The final product is a mix of these oils and is sold for &lt;span class=&quot;math-container&quot;&gt;$180$&lt;/span&gt; dollars for each ton. The goal is to maximize the profit of the factory, under the following restrictions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We can't refine more than &lt;span class=&quot;math-container&quot;&gt;$210$&lt;/span&gt; tons of vegetarian oil, and more than &lt;span class=&quot;math-container&quot;&gt;$260$&lt;/span&gt; tons of non vegetarian oil. &lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;There exists a restrictment on the viscosities (from google translate, hope it makes sense) of the final product, it can't be lower than &lt;span class=&quot;math-container&quot;&gt;$3.5$&lt;/span&gt; and not higher than &lt;span class=&quot;math-container&quot;&gt;$6.2$&lt;/span&gt;. We assume that the oils are mixed in a linear manner and the viscosity of each oil is: &lt;br&gt;&#xA;veg1=&lt;span class=&quot;math-container&quot;&gt;$8.8$&lt;/span&gt;, veg2=&lt;span class=&quot;math-container&quot;&gt;$6.2$&lt;/span&gt;, oil1=&lt;span class=&quot;math-container&quot;&gt;$1.9$&lt;/span&gt;, oil2=&lt;span class=&quot;math-container&quot;&gt;$4.3$&lt;/span&gt;, oil3=&lt;span class=&quot;math-container&quot;&gt;$5.1$&lt;/span&gt; &lt;br&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;br&gt;&#xA;Decision Variables: &lt;br&gt;&#xA;let &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2$&lt;/span&gt; be the amount in tons that we bought from veg1 and veg2 oils. &lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_1,y_2,y_3$&lt;/span&gt; the amount in tons that we bought from oil1,oil2 and oil3.&#xA;&lt;br&gt;&#xA;&lt;br&gt;&#xA;Our goal function should be the profit of the factory, and we need to maximize that. &lt;br&gt;&#xA;First, we need to know our product sales money, and that is &lt;span class=&quot;math-container&quot;&gt;$180$&lt;/span&gt; for each ton of the mix, I got confused of how to express it, but I think the most intuitive way is &lt;span class=&quot;math-container&quot;&gt;$180*(x_1+x_2+y_1+y_2+y_3)$&lt;/span&gt;, since the mix is made from all the oils (and they didn't mention them needing to have the same proportions). &lt;br&gt;&#xA;Second, the cost of the oils which is &lt;span class=&quot;math-container&quot;&gt;$115x_1+128x_2+132y_1+109y_2+114y_3$&lt;/span&gt;. &lt;br&gt; &lt;br&gt;&#xA;So Our function is: &lt;span class=&quot;math-container&quot;&gt;$180*(x_1+x_2+y_1+y_2+y_3)-115x_1+128x_2+132y_1+109y_2+114y_3$&lt;/span&gt;. &lt;br&gt;&lt;br&gt;&#xA;From the first restriction, we get these inequalities: &lt;span class=&quot;math-container&quot;&gt;$x_1+x_2\le 210$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1+y_2+y_3\le 260$&lt;/span&gt;.&lt;br&gt;&lt;br&gt;&#xA;I was told than linear manner most likely means weighed average (I am still unsure why though), so: &lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$3.5 \le\frac{8.8x_1+6.2x_2+1.9y_1+4.3y_2+5.1y_3}{x_1+x_2+y_1+y_2+y_3}\le 6.2$&lt;/span&gt;. &lt;br&gt;&#xA;And that's it for the first part with adding the last restriction &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2,y_1,y_2,y_3\ge 0$&lt;/span&gt;. &lt;br&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Now, we add these restrictions: &lt;br&gt;&#xA;3. The final product cannot include more than &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; (types) of oils. &lt;br&gt;&#xA;4. If one oil is in use while mixing, then we must use atleast &lt;span class=&quot;math-container&quot;&gt;$30$&lt;/span&gt; tons of it. &lt;br&gt;&#xA;5. If we used any vegetarian oil, then we must use oil2.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; be a discrete variable that counts how many oils we used &lt;span class=&quot;math-container&quot;&gt;$0 \le z_1\le 5$&lt;/span&gt;. &lt;br&gt;&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$v_1,v_2,o_1,o_2,o_3$&lt;/span&gt; be indicator variables, equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if we used each oil and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise. &lt;br&gt;&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; be an indicator variable, equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if we used any vegetarian oil and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise. &lt;br&gt;&#xA;&lt;Br&gt;&#xA;From the third restriction we get &lt;span class=&quot;math-container&quot;&gt;$z \le 3$&lt;/span&gt;. &lt;br&gt;&lt;br&gt;&#xA;Now if any oil is in use or in other words, it's indicator is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, we must use &lt;span class=&quot;math-container&quot;&gt;$30$&lt;/span&gt; tons or more (&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a very big fixed variable): &lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$30-x_1 \le M(1-v_1)$&lt;/span&gt;, we add that restriction for all the four indicators. &lt;br&gt;&lt;br&gt;&#xA;For the last one, if &lt;span class=&quot;math-container&quot;&gt;$v_1\bigvee v_2 = 1$&lt;/span&gt; then we must have &lt;span class=&quot;math-container&quot;&gt;$o_2 = 1$&lt;/span&gt;, so we add: &lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$o_2 \le v_1 + v_2, o_2 \ge v_1, o_2 \ge v_2$&lt;/span&gt;. &lt;br&gt;&lt;br&gt;&#xA;Another connection I saw, is that we always have &lt;span class=&quot;math-container&quot;&gt;$z=v_1+v_2+o_1+o_2+o_3$&lt;/span&gt;. &lt;br&gt;&#xA;And that's all the new restrictions. &lt;br&gt;&lt;br&gt;&#xA;Any feedback will be really appreciated, sorry if it's too long, just wanted to explain my thoughts clearly.&lt;/p&gt;&#xA;" OwnerUserId="7477" LastActivityDate="2021-11-06T11:32:36.903" Title="Formulating a linear programming problem, with indicator variables. (Solution verification)" Tags="|optimization|linear-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7243" PostTypeId="2" ParentId="7242" CreationDate="2021-11-06T11:19:34.773" Score="1" Body="&lt;p&gt;See &lt;a href=&quot;https://documentation.sas.com/doc/en/pgmsascdc/v_018/ormpex/ormpex_ex2_toc.htm?homeOnFail&quot; rel=&quot;nofollow noreferrer&quot;&gt;this example&lt;/a&gt;, which is a multi-period version of the same problem with slightly different data, from &lt;em&gt;Model Building in Mathematical Programming&lt;/em&gt; by H. Paul Williams. Note that you do not need &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and can instead express the desired constraints in terms of the other variables.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-11-06T11:32:36.903" LastActivityDate="2021-11-06T11:32:36.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7244" PostTypeId="1" CreationDate="2021-11-06T15:13:33.260" Score="2" ViewCount="89" Body="&lt;p&gt;Suppose, there is mixed-integer programming as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned} &#xA;\min&amp;amp;\quad c^{\top} x\\ &#xA;\text{s.t.}&amp;amp; \quad A x \geq b \\ &#xA;&amp;amp;\quad B x  \geq d \\ &#xA;&amp;amp;\quad x  \geq 0 \\ &#xA;&amp;amp;\quad x_{j}  \in \mathcal{Z}, j \in I \end{aligned}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is an index set contained in &lt;span class=&quot;math-container&quot;&gt;$\{1,\cdots,n\}$&lt;/span&gt;. Defining:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\Gamma:=\left\{x \in \Re^{n} \mid B x \geq d, x \geq 0, x_{j} \in \mathcal{Z}, j \in I\right\}&#xA;$$&lt;/span&gt;&#xA;Based on the &lt;em&gt;&lt;strong&gt;Mixed-integer finite basis theorem&lt;/strong&gt;&lt;/em&gt;, if &lt;span class=&quot;math-container&quot;&gt;$\Gamma$&lt;/span&gt; is given by above set, there exists &lt;span class=&quot;math-container&quot;&gt;$x^1,\cdots,x^r$&lt;/span&gt; such that:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\operatorname{conv}(\Gamma)= \left \{x \in \Re^{n} \mid x=\sum_{i=1}^{q} z_{i} x^{i}+\sum_{i=q+1}^{r} z_{i} x^{i},\right. \&#xA;\left.\sum_{i=1}^{q} z_{i}=1, z_{i} \geq 0, i=1, \ldots, r\right\}. &#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, the &lt;em&gt;convex hull relaxation&lt;/em&gt; of the original problem is in the following form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{array}\\&#xA;\min &amp;amp; c^{\top} x &amp;amp; \\&#xA;\text { s.t. } &amp;amp; A x \geq b &amp;amp; \\&#xA;&amp;amp; x \in \operatorname{conv}(\Gamma)&#xA;\end{array}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In order to the above definitions, I would like to know:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What are exactly integer variables defined based on the model &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and definition &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Why the constraint &lt;span class=&quot;math-container&quot;&gt;$Ax \geq b$&lt;/span&gt; should be omitted from the definition &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, but should be incorporated into the &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;P.S:&lt;/strong&gt; Actually, the concept is based on Dantzig-Wolfe decomposition to re-formulate the (mixed-integer) linear programming to the equivalent problem that can be represented as the combination of the extreme points and extreme rays. After that, solving this master problem by Lagrangian dual approach. For linear programming, the approach is somewhat straightforward, but when some of the variables should be integer understanding the above definitions is a bit challenging.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2021-11-07T08:28:46.070" LastActivityDate="2021-11-07T08:28:46.070" Title="How to figure out integer variables in the relaxation set?" Tags="|mixed-integer-programming|convexity|lagrangian-relaxation|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7245" PostTypeId="1" AcceptedAnswerId="7247" CreationDate="2021-11-06T17:32:53.177" Score="4" ViewCount="828" Body="&lt;p&gt;What is the best python library to solve nonlinear problems? PuLP can solve only linear problems like &lt;span class=&quot;math-container&quot;&gt;$\max15000Z_7 + 350D_{73}Z_7 - 15000Z_8 + 350D_{86}Z_8$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7482" LastEditorUserId="36" LastEditDate="2021-11-07T13:09:10.737" LastActivityDate="2021-11-07T13:09:10.737" Title="Python library to solve nonlinear problems" Tags="|python|nonlinear-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7247" PostTypeId="2" ParentId="7245" CreationDate="2021-11-07T05:19:51.263" Score="4" Body="&lt;p&gt;You can find &lt;a href=&quot;https://ampl.com/products/solvers/open-source/&quot; rel=&quot;nofollow noreferrer&quot;&gt;non-linear solver binaries here&lt;/a&gt;. Also for academic purpose you can use &lt;a href=&quot;https://www.scipopt.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SCIP&lt;/a&gt; which is very good. For modelling interface, SCIP has own python &lt;a href=&quot;https://github.com/scipopt/PySCIPOpt&quot; rel=&quot;nofollow noreferrer&quot;&gt;interface&lt;/a&gt;. Or you can use PYOMO for all of them with jupyter notebook. (I think you have installation problem). Or you can use Google OR-TOOLS but I don't know which solvers supported except SCIP.&lt;/p&gt;&#xA;" OwnerUserId="432" LastActivityDate="2021-11-07T05:19:51.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7248" PostTypeId="1" CreationDate="2021-11-08T14:53:36.080" Score="3" ViewCount="100" Body="&lt;p&gt;Gurobi 9 can solve QCQPs, and QCQPs capture all of polynomial optimization by the obvious trick that e.g. a cubic term &lt;span class=&quot;math-container&quot;&gt;$x_1 x_2 x_3$&lt;/span&gt; can be turned into a quadratic term &lt;span class=&quot;math-container&quot;&gt;$y x_3$&lt;/span&gt; and a constraint &lt;span class=&quot;math-container&quot;&gt;$y = x_1 x_2$&lt;/span&gt;. Can pyomo do this automatically for a non-convex, non-quadratic (but polynomial) problem, so that it can then call Gurobi on it? If not, is there some intuitive reason why one should do this by hand? Or is it just a not-yet-implemented feature?&lt;/p&gt;&#xA;" OwnerUserId="7492" LastEditorUserId="36" LastEditDate="2021-11-08T15:43:36.117" LastActivityDate="2021-11-08T15:43:36.117" Title="Automatic quadratization of constraints in pyomo for gurobi" Tags="|gurobi|pyomo|quadratic-programming|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7249" PostTypeId="1" AcceptedAnswerId="7764" CreationDate="2021-11-08T19:00:09.570" Score="1" ViewCount="90" Body="&lt;p&gt;I am trying to find the software called SISCO (Simulator For Integrated Supply Chain Operations). It is developed by &lt;a href=&quot;https://pennstate.pure.elsevier.com/en/publications/sisco-an-object-oriented-supply-chain-simulation-system&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chatfield et al. (2006)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;. However, it seemed that the authors did not include the link to the software. Can anyone tell me the place to find SISCO?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Chatfield, D. C., Harrison, T. P., &amp;amp; Hayya, J. C. (2006). SISCO: an object-oriented supply chain simulation tool utilizing JAVA and XML. &lt;em&gt;Decision Support Systems.&lt;/em&gt; &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="7402" LastEditorUserId="123" LastEditDate="2021-11-10T19:34:11.873" LastActivityDate="2022-02-06T02:33:00.360" Title="Where to download SISCO-simulator for integrated supply chain operations" Tags="|simulation|supply-chain|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7250" PostTypeId="1" CreationDate="2021-11-09T06:48:27.893" Score="3" ViewCount="116" Body="&lt;p&gt;In my (simplified) problem I have a grid. Given an origin cell, I'd like to find a minimum-length path on this grid that connects to one or more target cells.&lt;/p&gt;&#xA;&lt;p&gt;My idea is to use a series of binary variables &lt;code&gt;has_path&lt;/code&gt; to indicate which cells have a path build on them.&lt;/p&gt;&#xA;&lt;p&gt;A second set of binary variables &lt;code&gt;i_can_reach_entrance&lt;/code&gt; constrains the problem such that &lt;code&gt;i_can_reach_entrance[y, x]&lt;/code&gt; can only be true if a path is built at &lt;code&gt;(y, x)&lt;/code&gt; and &lt;code&gt;i_can_reach_entrance&lt;/code&gt; is true for one of &lt;code&gt;(y,x)&lt;/code&gt;'s neighbours.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, these constraints don't induce my program (included as an MWE, below) to build paths.&lt;/p&gt;&#xA;&lt;p&gt;There are easier ways to solve this than with integer programming, of course, but this is my preferred method as the pathing will be integrated with a more complex program.&lt;/p&gt;&#xA;&lt;p&gt;Any thoughts on how to appropriately enforce contiguity would be welcome.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;#!/usr/bin/env python3&#xA;&#xA;from typing import Final, List, Tuple&#xA;&#xA;import cvxpy as cp&#xA;import numpy as np&#xA;&#xA;WIDTH: Final[int] = 16&#xA;HEIGHT: Final[int] = 16&#xA;&#xA;DXDY: Final[List[Tuple[int, int]]] = [(-1, 0), (1, 0), (0, -1), (0, 1)]&#xA;&#xA;constraints = []&#xA;&#xA;# A binary variable indicating whether we build a path at location (i, j)&#xA;has_path = cp.Variable((HEIGHT, WIDTH), boolean=True)&#xA;&#xA;# Set a target cell (note: there could be more than one)&#xA;row_temp = [False] * WIDTH&#xA;row_temp[6] = True&#xA;constraints.append(has_path[0,:] == np.array(row_temp))&#xA;&#xA;# Try to ensure contiguity&#xA;i_can_reach_entrance = cp.Variable((HEIGHT, WIDTH), boolean=True)&#xA;for y in range(HEIGHT):&#xA;  for x in range(WIDTH):&#xA;    if not (y==HEIGHT-1 and x==1):&#xA;      # Build the disjunction n_can_reach = icre[NORTH] v icre[SOUTH] v icre[EAST] v icre[WEST]&#xA;      num_reaching_neighbours = 0&#xA;      n_can_reach = cp.Variable(boolean=True)&#xA;      for dx, dy in DXDY:&#xA;        nx = x + dx&#xA;        ny = y + dy&#xA;        # Don't look outside the grid&#xA;        if ny&amp;lt;0 or nx&amp;lt;0 or ny==HEIGHT or nx==WIDTH:&#xA;          continue&#xA;        constraints.append(n_can_reach &amp;gt;= i_can_reach_entrance[ny, nx])&#xA;        num_reaching_neighbours += i_can_reach_entrance[ny,nx]&#xA;      constraints.append(n_can_reach &amp;lt;= num_reaching_neighbours)&#xA;&#xA;      # n_can_reach is now true if any neighbour can reach the entrance&#xA;&#xA;      # We can only reach the entrance if one of our neighbours can and we build&#xA;      # a path at our location&#xA;      constraints.append(i_can_reach_entrance[y, x] &amp;lt;= has_path[y,x])&#xA;      constraints.append(i_can_reach_entrance[y, x] &amp;lt;= n_can_reach)&#xA;      constraints.append(i_can_reach_entrance[y, x] + 1 &amp;gt;= n_can_reach + has_path[y,x])&#xA;    else:&#xA;      # Seed the path by specifying an origin cell&#xA;      constraints.append(i_can_reach_entrance[HEIGHT-1,1]==True)&#xA;&#xA;&#xA;# Set up the problem&#xA;objective = cp.Minimize(cp.sum(has_path))&#xA;problem = cp.Problem(objective, constraints)&#xA;&#xA;sol = problem.solve(solver='CBC', maximumSeconds=120, verbose=True)&#xA;&#xA;print(f&amp;quot;Optimized value = {sol}&amp;quot;)&#xA;&#xA;print(&amp;quot;Has path:&amp;quot;)&#xA;print(has_path.value)&#xA;&#xA;print(&amp;quot;Can I reach the entrance?&amp;quot;)&#xA;print(i_can_reach_entrance.value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="886" LastEditorUserId="886" LastEditDate="2021-11-10T06:09:11.100" LastActivityDate="2021-11-10T06:09:11.100" Title="How to build a contiguous path?" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7251" PostTypeId="1" AcceptedAnswerId="7260" CreationDate="2021-11-09T08:54:45.103" Score="1" ViewCount="95" Body="&lt;p&gt;I have a problem with three objective functions to be minimized, F1(interval value is [0,100]); F2(interval value is [0,100]); and F3(interval value is [0,20]). To solve my problem, I use Particle Swarm Optimization (PSO) algorithm and Genetic algorithm (GA) with the weighted sum method. When I run the algorithm with different weight values, always the PSO find the better solution in term of F1 and F2, whereas GA always finds the better solution for F3.&lt;/p&gt;&#xA;&lt;p&gt;I tested also to optimize only F3 without F1 and F2, the GA is always the best one.&lt;/p&gt;&#xA;&lt;p&gt;Is that logic? How we can explain that?&lt;/p&gt;&#xA;" OwnerUserId="7281" LastActivityDate="2021-11-10T09:07:25.700" Title="I didn't understand my problem with PSO and GA" Tags="|metaheuristics|genetic-algorithm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7252" PostTypeId="1" CreationDate="2021-11-09T10:16:04.680" Score="1" ViewCount="83" Body="&lt;p&gt;I'm running into an issue with a Linear Optimization Problem. The ultimate goal is to come back with an optimal production quantity (&lt;code&gt;prod_qty&lt;/code&gt;) across several items and weeks.&lt;/p&gt;&#xA;&lt;p&gt;Now, the problem is the following: As part of the optimization problem I know the demand per item and week. When solving for &lt;code&gt;prod_qty&lt;/code&gt;, I want to minimize both excess (&lt;code&gt;prod_qty - demand &amp;gt; 0&lt;/code&gt;) and unmet demand (&lt;code&gt;demand- prod_qty &amp;gt; 0&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Here's why this becomes difficult: For some items, I don't want my solver to meet any unmet demand in a given week later in my solve horizon. Essentially, when in a week &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; I cannot meet demand, I just want to forget about that in the next week. So in the next week, I would not include last week's unmet demand when calculating the new unmet demand or excess. However, if I have created excess in a given week - in the next week the optimizer has to &amp;quot;remember&amp;quot; that excess was available, hence include that in the calculation of the next week's excess or unmet demand. There are other items for which this is not the case and any unmet demand can be carried forward. I can have a situation where two items are produced concurrently, but for one of them, the demand can be carried forward, for the other it cannot.&lt;/p&gt;&#xA;&lt;p&gt;I can't seem to find a way to specify the excess and unmet demand variables correctly and wonder if it's even possible in a convex optimization framework?&lt;/p&gt;&#xA;&lt;p&gt;I have tried several things along the lines of the code below. Interestingly, the excess (&lt;code&gt;balance_pos&lt;/code&gt;) and unmet demand come out in a sensible way with objective function 1 below. Note how for items that can't carry unmet demand forward this objective function does not try to minimize the penalties due to unmet demand. As soon as I activate that piece in objective function 2, the obtained excess and unmet go all over the place even though the obtained optimal &lt;code&gt;prod_qty&lt;/code&gt; seems to be the same as before:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;balance_pos = cp.Variable(prod_qts.shape, nonneg=True)&#xA;unmet_pos = cp.Variable(prod_qts.shape, nonneg=True)&#xA;&#xA;balance_dummy = cp.Variable(prod_qts.shape, boolean = True)&#xA;&#xA;M = 1000000&#xA;&#xA;constraints.extend([balance_pos &amp;gt;=  0])&#xA;constraints.extend([unmet_pos &amp;gt;=  0])&#xA;&#xA;for dte in range(prod_qts.shape[0]):&#xA;    if dte == 0: &#xA;        constraints.extend([prod_qts[0,:] - dmd_mtrx[0,:] &amp;lt;= M *  balance_dummy[0,:]])&#xA;        constraints.extend([dmd_mtrx[0,:] - prod_qts[0,:] &amp;lt;= M * (1 - balance_dummy[0,:]) -1])&#xA;        constraints.extend([balance_pos[0,:] &amp;gt;= (prod_qts[0,:] - dmd_mtrx[0, :]) - M * (1-balance_dummy[0,:])])&#xA;        constraints.extend([unmet_pos[0,:] == (dmd_mtrx[0, :] - prod_qts[0,:]) - M * balance_dummy[0,:]])&#xA;&#xA;    else:  &#xA;        constraints.extend([balance_pos[dte-1,:] + prod_qts[dte,:] - dmd_mtrx[dte,:] &amp;lt;= M *  balance_dummy[dte,:]])&#xA;        constraints.extend([dmd_mtrx[dte,:] - prod_qts[dte,:] - balance_pos[dte-1,:] &amp;lt;= M * (1 - balance_dummy[dte,:]) -1])&#xA;        constraints.extend([balance_pos[dte,:] &amp;gt;= (balance_pos[dte-1,:] + prod_qts[dte,:] - dmd_mtrx[dte, :]) - M * (1-balance_dummy[dte,:])])&#xA;        constraints.extend([unmet_pos[dte,:] &amp;gt;= (dmd_mtrx[dte, :] - balance_pos[dte-1,:] - prod_qts[dte,:])- M * balance_dummy[dte,:]])&#xA;&#xA;objective_1 = cp.Minimize(&#xA;&#xA;       cp.sum(balance_pos) + cp.sum(unmet_pos)&#xA;&#xA;        +&#xA;&#xA;&#xA;        cp.sum(&#xA;&#xA;            cp.multiply(&#xA;&#xA;                cp.atoms.elementwise.maximum.maximum(&#xA;&#xA;                    (cp.atoms.affine.cumsum.cumsum(prod_qts[:,carry_forward_idx], axis=0) - cum_item_day_demand[:,carry_forward_idx]),  0),&#xA;&#xA;                            storage_costs[:, carry_forward_idx])&#xA;&#xA;        ) +&#xA;&#xA;        cp.sum(&#xA;&#xA;            cp.multiply(balance_pos[:,no_carry_forward_idx],&#xA;&#xA;                        storage_costs[:, no_carry_forward_idx])&#xA;&#xA;        ) +               &#xA;&#xA;        cp.sum(&#xA;&#xA;            cp.multiply(cp.atoms.elementwise.maximum.maximum(&#xA;&#xA;                (cum_item_day_demand[:,carry_forward_idx] - cp.atoms.affine.cumsum.cumsum(prod_qts[:, carry_forward_idx], axis=0)),&#xA;&#xA;                0), ind_dmd_panalties_mtrx[:, carry_forward_idx])&#xA;&#xA;        ) &#xA;&#xA;        # +&#xA;        # cp.sum(&#xA;        #     cp.multiply(unmet_pos[:, no_carry_forward_idx], &#xA;        #                 ind_dmd_panalties_mtrx[:, no_carry_forward_idx])&#xA;        # ) &#xA;&#xA;    )&#xA;&#xA;problem = cp.Problem(objective_1, constraints)&#xA;problem.solve()&#xA;&#xA;res_1 = pd.DataFrame({&amp;quot;excess&amp;quot;: balance_pos.value[:,0],&#xA;&#xA;                      &amp;quot;unmet&amp;quot;: unmet_pos.value[:,0],&#xA;&#xA;                      &amp;quot;prod&amp;quot;:prod_qts.value[:,0]})&#xA;&#xA;res_1&#xA;&#xA;&amp;gt;&amp;gt;&amp;gt; res_1&#xA;     excess         unmet          prod&#xA;0       0.0     -0.000000      0.000000&#xA;1       0.0   4852.224000      0.000000&#xA;2       0.0  71570.304000      0.000000&#xA;3       0.0  67793.792204  18333.183796&#xA;4       0.0  92192.256000      0.000000&#xA;..      ...           ...           ...&#xA;102     0.0      0.000000  62472.384000&#xA;103     0.0      0.000000  67931.136000&#xA;104     0.0      0.000000  75816.000000&#xA;105     0.0      0.000000  50341.824000&#xA;106     0.0      0.000000      0.000000&#xA;&#xA;objective_2 = cp.Minimize(&#xA;&#xA;       cp.sum(balance_pos) + cp.sum(unmet_pos)&#xA;&#xA;        +&#xA;&#xA;        cp.sum(&#xA;&#xA;            cp.multiply(&#xA;&#xA;                cp.atoms.elementwise.maximum.maximum(&#xA;&#xA;                    (cp.atoms.affine.cumsum.cumsum(prod_qts[:,carry_forward_idx], axis=0) - cum_item_day_demand[:,carry_forward_idx]),  0),&#xA;&#xA;                            storage_costs[:, carry_forward_idx])&#xA;&#xA;        ) +&#xA;&#xA;        cp.sum(&#xA;&#xA;            cp.multiply(balance_pos[:,no_carry_forward_idx],&#xA;&#xA;                        storage_costs[:, no_carry_forward_idx])&#xA;&#xA;        ) +               &#xA;&#xA;        cp.sum(&#xA;&#xA;            cp.multiply(cp.atoms.elementwise.maximum.maximum(&#xA;&#xA;                (cum_item_day_demand[:,carry_forward_idx] - cp.atoms.affine.cumsum.cumsum(prod_qts[:, carry_forward_idx], axis=0)),&#xA;&#xA;                0), ind_dmd_panalties_mtrx[:, carry_forward_idx])&#xA;&#xA;        ) &#xA;&#xA;        +&#xA;&#xA;        cp.sum(&#xA;&#xA;            cp.multiply(unmet_pos[:, no_carry_forward_idx], &#xA;&#xA;                        ind_dmd_panalties_mtrx[:, no_carry_forward_idx])&#xA;&#xA;        ) &#xA;&#xA;    )&#xA;&#xA;# create problem and solve&#xA;&#xA;problem = cp.Problem(objective_2, constraints)&#xA;problem.solve()&#xA;&#xA;res_2 = pd.DataFrame({&amp;quot;excess&amp;quot;: balance_pos.value[:,0],&#xA;                      &amp;quot;unmet&amp;quot;: unmet_pos.value[:,0],&#xA;                      &amp;quot;prod&amp;quot;:prod_qts.value[:,0]})&#xA;res_2&#xA;&#xA;&amp;gt;&amp;gt;&amp;gt; res_2&#xA;           excess  unmet          prod&#xA;0     4852.224000   -0.0      0.000000&#xA;1    71570.304000    0.0      0.000000&#xA;2    67793.792204    0.0      0.000000&#xA;3    92192.256000    0.0  18333.183796&#xA;4    72783.360000    0.0      0.000000&#xA;..            ...    ...           ...&#xA;102      0.000000    0.0  62472.384000&#xA;103      0.000000    0.0  67931.136000&#xA;104      0.000000    0.0  75816.000000&#xA;105      0.000000    0.0  50341.824000&#xA;106      0.000000    0.0      0.000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Any advice on how to correctly specify this problem to arrive at reliable results would be welcome.&lt;/p&gt;&#xA;" OwnerUserId="7495" LastEditorUserId="500" LastEditDate="2021-11-10T04:06:40.583" LastActivityDate="2021-11-10T04:06:40.583" Title="Convex Optimization with Variable Dependency / no unmet demand carry forward" Tags="|mixed-integer-programming|linear-programming|convex-optimization|inventory|cvxpy|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7253" PostTypeId="1" CreationDate="2021-11-09T13:07:58.073" Score="1" ViewCount="147" Body="&lt;p&gt;I am currently working in the area of operations research / scheduling and am attempting to write a short proof. We are working with a directed acyclic graph of activities (Activity-on-Node-representation) that need to be scheduled while adhering to precedence constraints. We are using the critical-path-method to determine earliest start times (&lt;span class=&quot;math-container&quot;&gt;$ES_j$&lt;/span&gt;) and earliest finish times (&lt;span class=&quot;math-container&quot;&gt;$EF_j$&lt;/span&gt;) of these activities, see screen shot. &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt; is the duration of an activity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n5N58.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n5N58.jpg&quot; alt=&quot;Forward-recursion earliest start times&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is very straight forward established theory.&lt;/p&gt;&#xA;&lt;p&gt;However in the problem at hand, the durations &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt; of activities are not fixed, but can be freely chosen, the only requirement being some imposed bounds (&lt;span class=&quot;math-container&quot;&gt;$p_{j,max}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_{j,min}$&lt;/span&gt;) on the activity durations.&lt;/p&gt;&#xA;&lt;p&gt;I now have to prove that when choosing &lt;span class=&quot;math-container&quot;&gt;$p_j = p_{j,min}$&lt;/span&gt;, so all activities are being processed with their minimum durations, that then the earliest start times of all activities are also minimized. This should be so trivial to show, however I have only very little experience when it comes to formalizing these thoughts.&lt;/p&gt;&#xA;&lt;p&gt;Because of this recursive nature of the algorithm in the screen shot, I believe that proof by induction is the most suitable approach here. Could anyone guide me in the right direction here? I believe that the final &amp;quot;proof&amp;quot; will boil down to a one-liner as the whole idea is fairly trivial.&lt;/p&gt;&#xA;&lt;p&gt;If all predecessors of an activity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are assigned their &amp;quot;minimum-duration&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$p_{i,min}$&lt;/span&gt;, then the earliest start of that activity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; will also be minimized.&lt;/p&gt;&#xA;&lt;p&gt;Or something along the lines of: &amp;quot;The earliest start time of the final activity &lt;span class=&quot;math-container&quot;&gt;$j=J+1$&lt;/span&gt; is minimized when all earliest finish times of its predecessors (&lt;span class=&quot;math-container&quot;&gt;$P_j$&lt;/span&gt;) are minimized. For the earliest finish times of these predecessors to be minimized, they need to be processed with their respective minimum duration &lt;span class=&quot;math-container&quot;&gt;$p_{i,min}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$i \in P_j$&lt;/span&gt; as well as having their earliest start &lt;span class=&quot;math-container&quot;&gt;$ES_i$&lt;/span&gt; minimized.&amp;quot; Then, we again are left with the problem of minimizing all &lt;span class=&quot;math-container&quot;&gt;$ES_i$&lt;/span&gt;, so basically the same problem as we started with, revealing the recursive nature of the problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Alternative approach via Linear Programming:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;An alternative I have thought of (which however might be a little &amp;quot;overkill&amp;quot;) comes from linear programming theory and is the following: Model the problem as a linear program with the objective to minimize all earliest finish times and then show that only setting the activity durations to their corresponding minimum durations will result in the optimal solution. The argument is that only when setting activity durations to their minimum [and have the corresponding constraints regarding lower bounds of activity durations bind], only then the shadow prices of all constraints  are non-negative.&lt;/p&gt;&#xA;&lt;p&gt;The LP would look something like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$min \; z = \sum^{J+1}_{j=0} ES_j$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$s.t.$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ES_i+p_i \leq ES_j  \quad\forall\; j \in J   \quad\forall\; i \in P_j  $&lt;/span&gt; &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$p_j \leq p_{j,max} \quad\forall\; j \in J$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$p_j \geq p_{j,min} \quad\forall\; j \in J$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ES_0 = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Quick verbal explanation: Minimize the sum of all finish times, subject to:&#xA;The earliest start of an activity (&lt;span class=&quot;math-container&quot;&gt;$ES_j$&lt;/span&gt;) is larger or equal than the largest finish time of all its predecessors, the set of predecessors being denoted as &lt;span class=&quot;math-container&quot;&gt;$P_j$&lt;/span&gt;. [The expression &lt;span class=&quot;math-container&quot;&gt;$ES_i + p_i$&lt;/span&gt; simply captures the earliest finish time of a predecessor &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;].&#xA;The duration of an activity is a decision variable in the model and is denoted as &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt; has to lie inbetween &lt;span class=&quot;math-container&quot;&gt;$p_{j,min}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_{j,max}$&lt;/span&gt;. The earliest start of activity &lt;span class=&quot;math-container&quot;&gt;$j=0$&lt;/span&gt; is 0: &lt;span class=&quot;math-container&quot;&gt;$ES_0 = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6082" LastEditorUserId="491" LastEditDate="2022-01-27T16:40:11.500" LastActivityDate="2022-01-27T16:40:11.500" Title="Need help with writing short proof related to Critical-Path-Method in scheduling with variable activity duration" Tags="|scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7254" PostTypeId="1" AcceptedAnswerId="7256" CreationDate="2021-11-09T14:20:55.403" Score="5" ViewCount="1898" Body="&lt;p&gt;My background: Pure math current Undergrad, learned the theory of Operations Research, but pretty basic. All we covered have been dealing with problems that have only 1 constraint matrix. I have dealt with 2-dimensional variables, but not worked with it extensively (unless just setting up the variable and letting AMPL figure it out).&lt;/p&gt;&#xA;&lt;p&gt;in the usual set-up with a single constraint matrix:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min c^T \cdot x, \text{satisfying } Ax \leq b, x \geq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this case, we can then define the reduced cost of &lt;span class=&quot;math-container&quot;&gt;$x_j:=$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$= c_j - c_B^T \cdot \bar{a_j}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is the set of basic indices (variables in the basis), and &lt;span class=&quot;math-container&quot;&gt;$\bar{a_j} = A_B^{-1}\cdot\bar{a_j}$&lt;/span&gt; . I think it is more commonly defined as &lt;span class=&quot;math-container&quot;&gt;$:=$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;=c_j - \pi^T \cdot a_j,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\pi^T = c^T_B \cdot A_B^{-1}$&lt;/span&gt;, also known as the shadow price, the optimal solution of the dual problem. I usually think of the shadow price as the reduced cost of slack variables, or how much more profit we will gain if we have one more unit of each resource.&lt;/p&gt;&#xA;&lt;p&gt;This is all fine and dandy, but what if we have multiple constraint matrices? I would assume that for each constraint matrix we will have a shadow price, which itself is an optimal solution of the dual problem of each constraint matrix. But how are the shadow prices related to the reduced cost now?&lt;/p&gt;&#xA;&lt;p&gt;In fact, what is the reduced cost for a variable now? In a paper I'm reading, supposing we have constraint matrices &lt;span class=&quot;math-container&quot;&gt;$G, H$&lt;/span&gt;, the reduced cost for &lt;span class=&quot;math-container&quot;&gt;$x_j:=$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c_j - \left( \pi^T \cdot g_j + \mu^T \cdot h_j \right)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\pi,\mu$&lt;/span&gt; are the shadow prices for &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; respectively. Why? May I see a derivation?&lt;/p&gt;&#xA;" OwnerUserId="7498" LastEditorUserId="36" LastEditDate="2021-11-09T14:34:06.320" LastActivityDate="2021-11-09T18:02:29.117" Title="What is the relation between dual variables and reduced costs?" Tags="|duality|reduced-costs|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7256" PostTypeId="2" ParentId="7254" CreationDate="2021-11-09T16:40:18.303" Score="6" Body="&lt;p&gt;First, as a note, your formulation (minimizing with &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; constraints) will produce nonpositive shadow prices. It might be easier to understand if you use &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; constraints (nonnegative shadow prices). For clarity, I'll assume we are maximizing profit with &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; constraints, which results in nonnegative shadow prices.&lt;/p&gt;&#xA;&lt;p&gt;Each shadow price represents the marginal rate at which profit increases (decreases) as the supply of a particular resource increases (decreases), assuming that the solution is adjusted optimally to the change. Now suppose that, rather than monkeying with the resources, we force the value of a variable &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; to go (down) slightly, meaning we insist that the solution do a bit more (less) of that activity. Let &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; be the change imposed. The direct impact on profit is to increase (decrease) by &lt;span class=&quot;math-container&quot;&gt;$c_j\cdot \delta$&lt;/span&gt;. The indirect effect is that we force a change of &lt;span class=&quot;math-container&quot;&gt;$-g_{ij}\cdot\delta$&lt;/span&gt; in the availability of the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th resource from the &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; portion of the constraints and &lt;span class=&quot;math-container&quot;&gt;$-h_{ij}\cdot\delta$&lt;/span&gt; in the availability of the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th resource from the &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; portion of the constraints. The &amp;quot;-&amp;quot; is because increasing (decreasing) the level of &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; increases (decreases) consumption of the resources and thus decreases (increases) the availability of those resources for the rest of the solution. The expression you subtract from &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; in the reduced cost is the marginal impact of those changes on the profit from the rest of the solution, again assuming that the remainder of the solution is adjusted optimally.&lt;/p&gt;&#xA;&lt;p&gt;For cost minimization, or when you have constraints going in the &amp;quot;noncanonical&amp;quot; direction (such as profit maximization with a lower bound on some combination of activities that are for some reason less desirable to do), the logic is similar.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-09T16:40:18.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7257" PostTypeId="2" ParentId="7254" CreationDate="2021-11-09T18:02:29.117" Score="6" Body="&lt;p&gt;If you interpret &lt;span class=&quot;math-container&quot;&gt;$$A= \begin{pmatrix}G \\ H\end{pmatrix}$$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$$\pi^TA_j = \mu^T G_j + \lambda^T H_j$$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$\pi,\mu,\lambda$&lt;/span&gt; are the corresponding duals) is not a surprise.&lt;/p&gt;&#xA;" OwnerUserId="907" LastActivityDate="2021-11-09T18:02:29.117" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7258" PostTypeId="2" ParentId="7252" CreationDate="2021-11-10T04:04:45.840" Score="2" Body="&lt;p&gt;If your costs are linear, there is no need to introduce binary variables or big-M constraints here.  Define three sets of nonnegative decision variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$I_t$&lt;/span&gt; is the inventory at the end of period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$P_t$&lt;/span&gt; is the production in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$B_t$&lt;/span&gt; is the unmet demand in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$d_t$&lt;/span&gt; be the demand in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. The inventory balance constraints are&#xA;&lt;span class=&quot;math-container&quot;&gt;$$I_{t-1}+P_t+B_t=d_t+I_t+B_{t-1}$$&lt;/span&gt;&#xA;In periods where you don’t allow previously unmet demand to be satisfied, just omit the &lt;span class=&quot;math-container&quot;&gt;$B_{t-1}$&lt;/span&gt; term.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-11-10T04:04:45.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7259" PostTypeId="2" ParentId="7250" CreationDate="2021-11-10T04:32:06.287" Score="1" Body="&lt;p&gt;For simplicity, let binary variable &lt;span class=&quot;math-container&quot;&gt;$c_{i,j}$&lt;/span&gt; indicate whether cell &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; can reach the entrance, and let binary variable &lt;span class=&quot;math-container&quot;&gt;$p_{i,j}$&lt;/span&gt; indicate whether cell &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; has a path built.  Necessary conditions are&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c_{i,j}\implies p_{i,j}$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c_{i,j}\implies \left(c_{i-1,j}\lor c_{i+1,j} \lor c_{i,j-1} \lor c_{i,j+1}\right),$$&lt;/span&gt;&#xA;both of which yield linear constraints. But these do not prevent subtours.&lt;/p&gt;&#xA;&lt;p&gt;One way to repair this approach is to include a third index &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; that represents the number of steps taken:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c_{i,j,k}\implies p_{i,j}$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c_{i,j,k}\implies \left(c_{i-1,j,k-1}\lor c_{i+1,j,k-1} \lor c_{i,j-1,k-1}\lor c_{i,j+1,k-1}\right)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-11-10T04:32:06.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7260" PostTypeId="2" ParentId="7251" CreationDate="2021-11-10T09:07:25.700" Score="3" Body="&lt;p&gt;First, let me state that it is difficult to write an answer to this question as it is very vague and lacks necessary detail. The real question here is not that GA and PSO perform differently (that's something that can be expected), but that you want to know whether there is a bias in the variation/selection operators that results in a bias towards different fitness functions.&lt;/p&gt;&#xA;&lt;p&gt;The PSO algorithm uses a variation operator that interpolates solutions. Each particle is attracted by its personal best and by the best in its &amp;quot;neighborhood&amp;quot;. The particles may however move beyond the direct path between these two attractors.&lt;/p&gt;&#xA;&lt;p&gt;The GA may use variation operators that either interpolate (for instance an arithmetic crossover, such as a uniform arithmetic crossover or a blended crossover) or combine (an N-point or discrete crossover) different solutions. It is not clear from the description which crossover is used. The N-point/discrete crossover is much more different to the particle update in the PSO. It is much less &amp;quot;local&amp;quot;. That could explain a certain bias. Potentially there is a stronger gradient with respect to F1 and F2, but a much weaker one with respect to F3, while a local minimum with respect to F3 is still quite good overall.&lt;/p&gt;&#xA;&lt;p&gt;So you could compare the performances of these algorithms if you vary their parameters or if you introduce some specific bias in the way initial solutions are generated. For instance perform experiments where the particles are produced not uniformly in the whole solution space, but rather where you select a certain point and generate them in a certain radius around that point. That way you can explore whether different starting regions bias a search trajectory that uses a more local update mechanism.&lt;/p&gt;&#xA;&lt;p&gt;In any case, it is important to really explore the parameter space of the algorithms before drawing conclusions. Some suggestions on how you can proceed:&lt;/p&gt;&#xA;&lt;p&gt;A) Automated parameter tuning. GA and PSO have many different parameters that affect the performance of the algorithm for a given problem. I assume you're comparing just two instances of these algorithms with default parameterizations. You want to tune those parameters to the actual problem. This can be done by hand through design of experiments, but automated methods exist. irace for instance is an easily accessible tool that simply requires that you provide an executable that takes parameters as input and which starts your algorithm. It needs to output a single number (the fitness) to stdout at the end. It will perform several experiments and provide the best performing parameterization as output. Of course it can take a lot of time to run (but it's automated).&lt;/p&gt;&#xA;&lt;p&gt;B) Examine the obtained solutions. In what way do the solutions of PSO differ from those of the GA? Are there large differences in the parameters, can it be attributed to a small number of parameters or is the solution entirely different? Do you have any bias in the way you generate the starting solution that differs between those algorithms. If you start PSO with solutions biased in a region where the GA found the best solution, does it perform similarily?&lt;/p&gt;&#xA;&lt;p&gt;C) Use multi-objective optimization algorithms to explore the Pareto front. MOPSO and NSGA-II are multi-objective variants of these algorithms, but any algorithm suffices. You just want to approximate the Pareto front as best as possible, so any algorithm's output can be combined. Then explore the solutions on the Pareto front. Is the Pareto front convex? Aim to identify those solutions that the single-objective algorithms would be drawn to given the weight vector (you can e.g. rank all of them by the weighted sum and highlight them on a visual representation of the Pareto front). If your Pareto Front is not convex, then the weighted sum approach cannot be used to identify any point on the front. The shape of the Pareto front can also potentially provide some explanations.&lt;/p&gt;&#xA;" OwnerUserId="242" LastActivityDate="2021-11-10T09:07:25.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7263" PostTypeId="2" ParentId="7241" CreationDate="2021-11-10T19:30:47.467" Score="5" Body="&lt;p&gt;As @sascha mentions, Picat has the option to save a SAT model to CNF, using the &lt;code&gt;dump(file.cnf)&lt;/code&gt; option (or just &lt;code&gt;dump&lt;/code&gt; to print the CNF to stdout). It's described a little more in the Picat Guide  section 12.6.3 &amp;quot;Solving Options for sat&amp;quot; (See &lt;a href=&quot;http://picat-lang.org/download/picat_guide.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://picat-lang.org/download/picat_guide.pdf&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Here's a small example how to use this for a Picat model:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import sat.&#xA;&#xA;main =&amp;gt; queens(8,Q).&#xA;&#xA;queens(N, Q) =&amp;gt;&#xA;    Q=new_list(N),&#xA;    Q :: 1..N,&#xA;    all_different(Q),&#xA;    all_different(&lt;span class=&quot;math-container&quot;&gt;$[Q[I]-I : I in 1..N]),&#xA;    all_different($&lt;/span&gt;[Q[I]+I : I in 1..N]),&#xA;&#xA;    solve($[dump(&amp;quot;sat_dump.cnf&amp;quot;),ff],Q).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The output file &lt;code&gt;sat_dump.cnf&lt;/code&gt; then contains the CNF for this model. Note that when using the &lt;code&gt;dump/1&lt;/code&gt; option, the model don't solves the problem, it just creates the CNF file.&lt;/p&gt;&#xA;&lt;p&gt;With a little tweaking one can use this to generate CNF for a MiniZinc model  using the PicatSAT program, see &lt;a href=&quot;https://github.com/nfzhou/fzn_picat/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/nfzhou/fzn_picat/&lt;/a&gt; . The fix is to add the option &lt;code&gt;dump(file.cnf)&lt;/code&gt; to the options (&lt;code&gt;Option = ... &lt;/code&gt;) in the file &lt;code&gt;fzn_picat_sat.pi&lt;/code&gt; . Note that with this simple fix, after the program generated the CNF file, there will probably be an error when the program tries to print out the solution (since there is no created solution that can be printed).&lt;/p&gt;&#xA;" OwnerUserId="260" LastEditorUserId="260" LastEditDate="2022-09-04T08:07:54.137" LastActivityDate="2022-09-04T08:07:54.137" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7264" PostTypeId="1" AcceptedAnswerId="7265" CreationDate="2021-11-10T20:35:39.270" Score="1" ViewCount="123" Body="&lt;p&gt;I want to add a KPI to calculate the percentage of occupancy of vehicles: the total travel time of occupied arcs (where the capacity of a vehicle is non-zero) over the total travel time.&lt;/p&gt;&#xA;&lt;p&gt;How can I represent that using three variables: the &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; variable equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if there is an arc between &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, the &lt;span class=&quot;math-container&quot;&gt;$q_i$&lt;/span&gt; the capacity of vehicle after serving vertex &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and the &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; the starting time of service for vertex &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5537" LastEditorUserId="123" LastEditDate="2021-11-10T21:08:43.290" LastActivityDate="2021-11-11T13:43:32.177" Title="KPIs in Docplex?" Tags="|mixed-integer-programming|docplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7265" PostTypeId="2" ParentId="7264" CreationDate="2021-11-11T13:43:32.177" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/AlexFleischerParis/zoodocplex/blob/master/zookpi.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;kpi syntax example&lt;/a&gt; in &lt;a href=&quot;https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;docplex&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;mdl = Model(name='buses')&#xA;nbbus40 = mdl.integer_var(name='nbBus40')&#xA;nbbus30 = mdl.integer_var(name='nbBus30')&#xA;&#xA;nbbus=nbbus30+nbbus40&#xA;mdl.add_kpi(nbbus,&amp;quot;nbbus&amp;quot;)&#xA;mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;mdl.minimize(nbbus40*500 + nbbus30*400)&#xA;&#xA;mdl.solve(log_output=True,)&#xA;&#xA;mdl.export(&amp;quot;c:\\temp\\buses.lp&amp;quot;)&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&#xA;for k in mdl.iter_kpis():&#xA;    print(k,&amp;quot; = &amp;quot;,k.solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-11-11T13:43:32.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7266" PostTypeId="2" ParentId="7253" CreationDate="2021-11-11T16:17:03.543" Score="1" Body="&lt;p&gt;I would go with proof by contradiction. Let S be the schedule obtained using minimal processing times and let S' be a schedule for which at least one task j starts earlier than it does in S. Now look at the predecessors of j and identify the predecessor j' of j for which j' starts earlier in S' than in S and no predecessor of j' starts earlier. Note that (a) j' could be j and (b) a &amp;quot;first&amp;quot; task j' with earlier start must exist because j has finitely many predecessors.&lt;/p&gt;&#xA;&lt;p&gt;Now derive a contradiction by showing that if all predecessors of j' start at least as early in S as in S', and they all have minimal processing time, j' cannot start earlier in S' than in S.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-11T16:17:03.543" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7267" PostTypeId="1" CreationDate="2021-11-12T02:03:39.593" Score="3" ViewCount="352" Body="&lt;p&gt;I am applying the &amp;quot;Probabilistic inventory model with safety stock&amp;quot;. There are some assumptions in this model: normally distributed demand, fixed lead time (time between placing the order of new items and their arrival). The next figure shows it clearly:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/bP1Lj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bP1Lj.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And the formula to calculate the number of items to order is the next:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ney3I.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ney3I.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is the average demand, &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is the time between orders, &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is the time that takes the new order to arrive, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is the number of standard deviation for a certain service level, &lt;span class=&quot;math-container&quot;&gt;$\sigma_{T+L}$&lt;/span&gt; is the standard deviation of the period &lt;span class=&quot;math-container&quot;&gt;$T+L$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is the current stock.&lt;/p&gt;&#xA;&lt;p&gt;My concern is that the multiplication of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sigma_{T+L}$&lt;/span&gt; is called &amp;quot;Safety Stock&amp;quot;, but I don't know why you should multiply these two values. I was thinking that it is just a rearrangement of values of the formula to calculate the probability of a certain value of a normally distributed random variable. In the next image I wrote my thoughts:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/dGXpd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dGXpd.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Am I correct or am I misunderstanding the topic? Thanks a lot in advance and sorry if I just pasted images since I don't know how to type formulas directly.&lt;/p&gt;&#xA;" OwnerUserId="7516" LastEditorUserId="36" LastEditDate="2021-11-12T02:15:52.313" LastActivityDate="2021-11-12T19:58:03.083" Title="Derivation of safety stock formula of an inventory model with probabilistic demand" Tags="|inventory|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7269" PostTypeId="1" AcceptedAnswerId="7273" CreationDate="2021-11-12T12:38:06.070" Score="6" ViewCount="281" Body="&lt;p&gt;I am looking for a heuristic that solves a budgeted variant of the max cut problem.&lt;/p&gt;&#xA;&lt;p&gt;Given a graph &lt;span class=&quot;math-container&quot;&gt;$G = (V, E)$&lt;/span&gt;, if the original problem is to find a partition of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; into two subsets &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$A \cap B = \emptyset$&lt;/span&gt; such that the size of the cut set &lt;span class=&quot;math-container&quot;&gt;$\{(u, v) \in E \mid u \in A, v \in B\}$&lt;/span&gt; is maximised, then I define the budgeted variant of this problem to be almost identical except with the constraint that &lt;span class=&quot;math-container&quot;&gt;$|A| = b $&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$b \in \mathbb{N}$&lt;/span&gt;, i.e. find the &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; nodes in &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; that maximise the cut set.&lt;/p&gt;&#xA;&lt;p&gt;Is this a well studied problem?&lt;/p&gt;&#xA;&lt;p&gt;I have found some papers that seem related to this, e.g. &lt;a href=&quot;https://dl.acm.org/doi/pdf/10.1145/1993574.1993615?casa_token=rWvu0F1xGxIAAAAA:_WT32slM3m3RddjUg369p1OKAPm0djqTI5PwVleCQKGVqJrzfk9S0Cvvb9Kbx_uhkAovch09yg&quot; rel=&quot;noreferrer&quot;&gt;[1]&lt;/a&gt;, &lt;a href=&quot;https://arxiv.org/pdf/1704.06901.pdf&quot; rel=&quot;noreferrer&quot;&gt;[2]&lt;/a&gt; and &lt;a href=&quot;https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.9791&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;noreferrer&quot;&gt;[3]&lt;/a&gt; but I am finding them difficult to read and relate back to the max cut problem. For instance [1] and [2] discuss auctions which I am finding quite confusing. [3] seems to more directly address it but is from 2001, so I am curious whether there are any more recent papers, potentially with better run time complexity, etc.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone know if there is a paper that addresses this budgeted max cut problem directly and provides a heuristic for solving it?&lt;/p&gt;&#xA;" OwnerUserId="7471" LastEditorUserId="123" LastEditDate="2021-11-12T13:06:55.387" LastActivityDate="2021-11-14T20:28:19.993" Title="Budgeted max cut heuristic" Tags="|combinatorial-optimization|heuristics|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7270" PostTypeId="1" CreationDate="2021-11-12T17:56:55.590" Score="3" ViewCount="312" Body="&lt;p&gt;I have implemented a model in cplex and even if I give it an initial feasible solution of a heuristic programmed elsewhere, it gives me the error &amp;quot;the model is infeasible&amp;quot;. Please if someone can explain what is exactly the problem ?&lt;/p&gt;&#xA;" OwnerUserId="5537" LastActivityDate="2021-11-12T18:57:37.423" Title="Docplex : model is infeasible" Tags="|mixed-integer-programming|docplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7271" PostTypeId="2" ParentId="7270" CreationDate="2021-11-12T18:57:37.423" Score="6" Body="&lt;p&gt;Short answer: The model is wrong. :-)&lt;/p&gt;&#xA;&lt;p&gt;Longer answer: After attempting to solve the model and being told it is infeasible, run the conflict refiner to get an set of mutually inconsistent constraints. Plug your heuristic solution into each of those constraints, and see which are violated. Assuming your heuristic solution really is feasible, those constraints must be incorrect.&lt;/p&gt;&#xA;&lt;p&gt;Alternate approach: You can fix all variables at their values in the heuristic solution (by setting lower bound = upper bound = heuristic value) and then try to solve, which presumably will result in CPLEX saying the model is infeasible. Then ask CPLEX for the value of the expression in each constraint. Compare those values with the right-hand sides to see where there are constraint violations. As in the previous case, constraints that are violated are presumably incorrect.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-12T18:57:37.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7272" PostTypeId="2" ParentId="7267" CreationDate="2021-11-12T19:36:35.537" Score="3" Body="&lt;p&gt;You are thinking along the right lines. There are various ways to set the safety stock, but in this case the logic is something like what you said.&lt;/p&gt;&#xA;&lt;p&gt;When you place an order at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; (say, at the first &amp;quot;Place order&amp;quot; point in your figure), that order has to last you until the end of the lead time for your &lt;em&gt;next&lt;/em&gt; order. The total demand during those &lt;span class=&quot;math-container&quot;&gt;$T+L$&lt;/span&gt; periods is a random variable (call it &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;) that has mean &lt;span class=&quot;math-container&quot;&gt;$\bar{d}(T+L)$&lt;/span&gt; and standard deviation &lt;span class=&quot;math-container&quot;&gt;$\sigma_{T+L}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you set &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; as in your formula, then when the next lead time ends, the inventory level will be &lt;span class=&quot;math-container&quot;&gt;$Q+I-D$&lt;/span&gt;, since the inventory after we order is &lt;span class=&quot;math-container&quot;&gt;$Q+I$&lt;/span&gt;. (I'm skipping some details of the inventory dynamics here.) The inventory level set by your formula will be sufficient to meet the demand iff &lt;span class=&quot;math-container&quot;&gt;$D \le Q+I$&lt;/span&gt;, and the probability that this happens is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$P(D \le Q+I) = \Phi\left(\frac{Q+I - \bar{d}(T+L)}{\sigma_{T+L}}\right) = \Phi(z).$$&lt;/span&gt;&#xA;Suppose we want the probability of not having a stockout during the lead time to be &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;. Then we set &lt;span class=&quot;math-container&quot;&gt;$z = z_\alpha \equiv \Phi^{-1}(\alpha)$&lt;/span&gt;. So the probability of not having a stockout is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\Phi(z_\alpha) = \alpha,$$&lt;/span&gt;&#xA;as desired.&lt;/p&gt;&#xA;" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2021-11-12T19:58:03.083" LastActivityDate="2021-11-12T19:58:03.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7273" PostTypeId="2" ParentId="7269" CreationDate="2021-11-12T21:50:19.877" Score="5" Body="&lt;p&gt;There are a number of metaheuristics that can be applied to this problem. One of them is a genetic algorithm. I'll assume that the vertices are denoted by the integers &lt;span class=&quot;math-container&quot;&gt;$1,\dots,N$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$N=|V|$&lt;/span&gt;. To implement a GA, you can define a &amp;quot;chromosome&amp;quot; (solution) to be a permutation of the integers . The fitness of a chromosome is the size of the cut set (or the value of the cut set in the weighted case) when &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is defined to be the vertices indexed by the first &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; elements in the permutation. There are GA libraries available in many programming languages, and some of them directly support permutation chromosomes. (The &lt;code&gt;GA&lt;/code&gt; package for R is one such.)&lt;/p&gt;&#xA;&lt;p&gt;Simpler heuristics include generating a random partition (pick &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; vertices randomly to get your initial &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;) and then looking at possible swaps of a vertex in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; with a vertex in &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;. A greedy version makes the swap only if the value of the cut set improves. A simulated annealing metaheuristic will occasionally make a swap that decreases the objective value (in the hopes of it leading to swaps that make things even better). These can be implemented with restarts (get a random solution, try to improve it for a while, then start over with a new random solution, keeping track of the best solution ever found).&lt;/p&gt;&#xA;&lt;p&gt;Being heuristics, none of these are guaranteed to produce an optimal solution, and if any of them have a performance guarantee (objective value no worse than &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; times the optimal value for some &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; hopefully not too much less than 1), I'm unaware of it.&lt;/p&gt;&#xA;&lt;p&gt;Addendum: Just for completeness, I should mention that you can get an exact solution using an integer programming (IP) model (assuming that the graph size does not exceed what your solver can handle). That in turn leads to another heuristic: set up the IP model, let the solver chew on it for a specified amount of time, then accept the (possibly suboptimal) incumbent solution.&lt;/p&gt;&#xA;&lt;p&gt;Addendum 2: I ran some tests using a MIP model to compute the optimal solution, plus a genetic algorithm and a very simple pairwise-exchange heuristic with random restarts. The GA had a stagnation limit (100 generations with no improvement) and the exchange heuristic had a fixed time limit (2 minutes). The exchange heuristic outperformed the GA, although that could be a function of parameter choices. (The GA hit its limit in well under 2 minutes, so large populations and/or longer stagnation limits might have made it competitive.) The big surprise for me, though, was that the exchange heuristic found the optimum in three of five test runs and had objective gaps of 0.4% and 1.6% in the other two. Since the exchange heuristic is very easy to program and requires no special libraries, it might be a good starting point.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-11-14T20:28:19.993" LastActivityDate="2021-11-14T20:28:19.993" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7274" PostTypeId="2" ParentId="7269" CreationDate="2021-11-13T00:00:17.227" Score="5" Body="&lt;p&gt;If you have a Max-Cut solver (or even a generic MILP solver) you can dualize the cardinality constraint and apply Dantzig-Wolfe decomposition or Lagrangian relaxation.  Explicitly, let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$i\in A$&lt;/span&gt;.  The problem is to maximize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{(i,j) \in E} (x_i(1-x_j)+x_j(1-x_i))=\sum_{(i,j) \in E} (x_i+x_j-2x_i x_j) \tag0$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i \in V} x_i &amp;amp;= b \tag1&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$|A|=b$&lt;/span&gt;.&#xA;You can linearize the objective function &lt;span class=&quot;math-container&quot;&gt;$(0)$&lt;/span&gt; by introducing binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; and linear constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_i + x_j - 1 &amp;amp;\le y_{i,j} &amp;amp;&amp;amp;\text{for $(i,j)\in E$} \tag2 \\&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$(x_i \land x_j) \implies y_{i,j}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The linearized problem is to maximize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{(i,j) \in E} (x_i+x_j-2y_{i,j}) \tag{$0^\prime$}$$&lt;/span&gt;&#xA;subject to &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;.&#xA;Now dualizing &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; yields a (weighted) Max-Cut problem for each fixed value of the dual multiplier.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-11-13T13:40:32.607" LastActivityDate="2021-11-13T13:40:32.607" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7275" PostTypeId="2" ParentId="7269" CreationDate="2021-11-13T07:05:11.543" Score="4" Body="&lt;p&gt;The problem you are proposing is closely related to the &lt;a href=&quot;https://link.springer.com/chapter/10.1007/11970125_16&quot; rel=&quot;nofollow noreferrer&quot;&gt;Maximum Cut with Limited Unbalance&lt;/a&gt; which generalizes both the &lt;em&gt;Maximum Bisection&lt;/em&gt; problem and the &lt;em&gt;Maximum Cut&lt;/em&gt; problem.&lt;/p&gt;&#xA;&lt;p&gt;The problem is defined as follows. Given vertex set &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; of cardinality &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and edge set &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;, where each edge &lt;span class=&quot;math-container&quot;&gt;$(i, j)$&lt;/span&gt; has an integer weight &lt;span class=&quot;math-container&quot;&gt;$w_{ij}$&lt;/span&gt;, and given a constant &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$0 \leq B \leq n$&lt;/span&gt;, find a cut &lt;span class=&quot;math-container&quot;&gt;$(S, V\setminus S)$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; of maximum weight such that the difference between the cardinalities of the two shores of the cut is not greater than &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;. Note that &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is equal to zero it is known as the &lt;em&gt;Max Bisection&lt;/em&gt; problem, whereas when &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is equal to &lt;span class=&quot;math-container&quot;&gt;$n − 1$&lt;/span&gt; it is well-known as the &lt;em&gt;Maximum Cut&lt;/em&gt; problem.&lt;/p&gt;&#xA;&lt;p&gt;In a later paper, we proposed an &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1002/net.20369&quot; rel=&quot;nofollow noreferrer&quot;&gt;SDP-based polynomial-time approximation algorithm&lt;/a&gt; (same style of the famous Goemans's Max Cut algorithm), based on the following model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \left\{\frac{1}{4} \sum_{ij} w_{ij} (1 - x_i x_j) \mid \sum_{ij} x_i x_j \leq B^2, x_i \in \{-1,1\},i=1,\dots,n\right\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The semidefinite relaxation of this binary quadratic program&#xA;can be formulated as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \left\{\frac{1}{4} \sum_{ij} w_{ij} (1 - X_{ij}) \mid \sum_{ij} X_{ij} \leq B^2, X_{ii} = 1,i=1,\dots,n, X \in M_n\right\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$M_n$&lt;/span&gt; is the set of real, symmetric, positive semidefinite&#xA;matrices of order &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the paper, we describe our randomized algorithm, which was implemented in C++ using the very nice &lt;a href=&quot;https://www.mcs.anl.gov/hs/software/DSDP/&quot; rel=&quot;nofollow noreferrer&quot;&gt;DSDP v5.8&lt;/a&gt; solver and the LAPACK linear algebra libraries (in particular to perform the &lt;em&gt;Cholesky decomposition&lt;/em&gt; step).&lt;/p&gt;&#xA;&lt;p&gt;If you cannot access our paper online, I can share by email an archived preprint.&lt;/p&gt;&#xA;" OwnerUserId="171" LastEditorUserId="171" LastEditDate="2021-11-13T07:23:37.090" LastActivityDate="2021-11-13T07:23:37.090" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7276" PostTypeId="1" CreationDate="2021-11-13T09:45:35.393" Score="2" ViewCount="375" Body="&lt;p&gt;In the following picture, the decision-maker has to make deliveries to node &lt;span class=&quot;math-container&quot;&gt;$V=\{1,2,3,4,5,6\}$&lt;/span&gt;. He has two options: use cars or bikes. In both cases, he has to make a stop at a relay point where the order is taken by another car for the last miles deliveries. If he chooses a car to get to the relay point, he uses the arc &lt;span class=&quot;math-container&quot;&gt;$(0-11)$&lt;/span&gt;, therefore the node &lt;span class=&quot;math-container&quot;&gt;$11$&lt;/span&gt; is the relay point if using cars. Otherwise, he uses &lt;span class=&quot;math-container&quot;&gt;$(0-12)$&lt;/span&gt;, making the node &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; the relay point if using bikes. The two options are not mutually exclusive, as the transportation cost using bike is lesser than that of using car, but using cars makes it faster.&lt;/p&gt;&#xA;&lt;p&gt;The DM assigns the flows based on the delivery deadlines of each customer (expressed in number of days from &lt;span class=&quot;math-container&quot;&gt;$t_0$&lt;/span&gt;). The decision variable is the flow of good (&lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt;) to be transported to each customer, and the DM minimizes its transportation costs (&lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt;) based on the time (the number of days) it takes to traverse the arcs (&lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt;) and the delivery deadline for each customer (&lt;span class=&quot;math-container&quot;&gt;$d_{j}$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;The problem would not thus be a path selection problem, but a minimum cost flow problem, but  how would I define the mathematical formulation of the constraint(s) related to the respect of the delivery deadline? I tried finding similar problems online, i.e., minimum cost flow problems with time constraint, but to no avail.&lt;/p&gt;&#xA;&lt;p&gt;(NB: The  image is not mine, I just use it for the purpose of this question)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xxdvI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xxdvI.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4491" LastEditorUserId="4491" LastEditDate="2021-11-13T20:38:52.047" LastActivityDate="2021-11-13T20:38:52.047" Title="How to solve a minimum cost flow problem with time constraints" Tags="|optimization|network-flow|assignment-problem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7277" PostTypeId="2" ParentId="7276" CreationDate="2021-11-13T13:52:31.697" Score="4" Body="&lt;p&gt;If I understand correctly, you can enforce the time constraint implicitly by omitting arcs.  For each customer, there is a unique path by car and a unique path by bike.  If the bike is too slow to meet a customer’s deadline, omit the arc from the bike relay point to that customer. After performing this preprocessing for all customers, solve a pure minimum-cost network flow problem.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-11-13T13:52:31.697" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7278" PostTypeId="1" CreationDate="2021-11-13T20:53:22.130" Score="3" ViewCount="114" Body="&lt;p&gt;I need to solve a large-scale &lt;strong&gt;generalized&lt;/strong&gt; network flow problem.&lt;/p&gt;&#xA;&lt;p&gt;For reference, it is a pure network-flow model with the exception that arcs have a positive coefficient applied to flow on them. In my case I have supply nodes from which I send flow to sink nodes that absorb them. The flow, however, incurs a loss depending on the distance between the two nodes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://developers.google.com/optimization/flow&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google OR-Tools&lt;/a&gt; has an excellent network-flow solver, but only for pure flow models. Is there a publicly available and reasonably mature solver for generalized network models? If not, could anyone recommend an easy-to-implement solution algorithm that I can implement myself quickly?&lt;/p&gt;&#xA;" OwnerUserId="7522" LastEditorUserId="981" LastEditDate="2023-12-22T15:05:28.220" LastActivityDate="2023-12-22T15:05:28.220" Title="Availability of library for solving generalized network flow problems" Tags="|solver|or-tools|network-flow|software|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7279" PostTypeId="1" AcceptedAnswerId="7280" CreationDate="2021-11-14T15:19:25.660" Score="6" ViewCount="1383" Body="&lt;p&gt;I am looking for an answer to a question I can't quite get behind.&lt;/p&gt;&#xA;&lt;p&gt;I am given the following mathematical optimization problem: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_{t\in T}s_t\cdot z_t+h_t\cdot i_t+p_t\cdot q_t\tag1\\\text{s.t.}&amp;amp;\quad i_0=0\tag2\\&amp;amp;\quad i_t=i_{t-1}+q_t-d_t&amp;amp;\forall t\in T\tag3\\&amp;amp;\quad q_t\le c_t\cdot z_t&amp;amp;\forall t\in T\tag4\\&amp;amp;\quad q_t,i_t\in\Bbb N_0&amp;amp;\forall t\in T\tag5\\&amp;amp;\quad z_t\in\{0,1\}&amp;amp;\forall t\in T\tag6\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, the following table is given:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;1&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;2&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;3&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;4&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;5&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;6&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;7&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;8&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;9&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;10&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;demand &lt;span class=&quot;math-container&quot;&gt;$d_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;12&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;6&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;20&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;7&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;25&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;0&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;21&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;capacity &lt;span class=&quot;math-container&quot;&gt;$c_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;20&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;15&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;30&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;20&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;20&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;21&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;10&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;10&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;set-up costs &lt;span class=&quot;math-container&quot;&gt;$s_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;25&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;30&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;40&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;20&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;80&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;80&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;150&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;30&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;40&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;60&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;storage costs &lt;span class=&quot;math-container&quot;&gt;$h_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;6&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;4&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;6&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;9&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;9&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;6&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;production costs &lt;span class=&quot;math-container&quot;&gt;$p_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;3&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;7&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;2&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;10&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;15&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;2&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Decision variables are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt;: Is day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; a production day?&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$q_t$&lt;/span&gt;: Quantity in time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$i_t$&lt;/span&gt;: Inventory in time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If I implement this problem in Excel and solve it with the Excel Solver (setting &lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt; binary and &lt;span class=&quot;math-container&quot;&gt;$q_t, i_t$&lt;/span&gt; integers and using the Simplex-LP) I get an optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;So far so good. However, what I don't understand is the following. Out of interest, I decided to drop the constraint of &lt;span class=&quot;math-container&quot;&gt;$q_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i_t$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$q_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i_t$&lt;/span&gt; can be real numbers. When I solve this problem with the Excel Solver again, I receive the exact (integer) solution as in the original model.&lt;/p&gt;&#xA;&lt;p&gt;So my questions are the following:&lt;/p&gt;&#xA;&lt;p&gt;First, why are both solutions described above exactly the same? Is that some sort of coincidence or can I conclude that for binary linear programming models with at least one continuous variable the optimal solution is an integer one? Or may the structure of the underlying problem be the reason for this observation?&lt;/p&gt;&#xA;&lt;p&gt;Second, on a more general note, how does Excel Solver actually work with Mixed Integer Programming where not all decision variables are integer but some are continuous? Is the Excel Solver applying some sort of Branch and Bound to find the optimal solution to such problems or what kind of algorithm in addition to the Simplex-LP does Excel Solver use?&lt;/p&gt;&#xA;" OwnerUserId="7525" LastEditorUserId="123" LastEditDate="2021-11-14T21:54:55.337" LastActivityDate="2021-11-14T21:54:55.337" Title="Linear Programming: Integer and non-integer decision variables" Tags="|mixed-integer-programming|linear-programming|simplex|excel|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7280" PostTypeId="2" ParentId="7279" CreationDate="2021-11-14T16:22:37.690" Score="7" Body="&lt;p&gt;For the first question, suppose you somehow knew which days would be production days and fixed the values of the &lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt; variables accordingly, while allowing &lt;span class=&quot;math-container&quot;&gt;$q_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i_t$&lt;/span&gt; to be continuous variables. You would be left with a &amp;quot;flow&amp;quot; type linear program. Since the capacities and demands are integer-valued, your flow LP would automatically produce integer values for production and inventory quantities. (This is proved in most textbooks on linear/integer programming. The phrase to look for is &amp;quot;totally unimodular&amp;quot;, in reference to the constraint matrix.) So getting integrality automatically is a consequence of two things, the structure of your model and the fact that capacities and demands are integers. Try running an example where the capacity and demand date are not integers and see what happens.&lt;/p&gt;&#xA;&lt;p&gt;For the second question, yes, Excel's Solver uses branch-and-bound for integer programs. As I understand it, Excel ships with a licensed copy of &lt;a href=&quot;https://www.solver.com/about-our-company&quot; rel=&quot;noreferrer&quot;&gt;Frontline Solver&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-14T16:22:37.690" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7282" PostTypeId="1" CreationDate="2021-11-15T19:43:30.347" Score="2" ViewCount="91" Body="&lt;p&gt;Let's consider the following minimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_{x,a,b}&amp;amp;\quad X\tag1\\&#xA;\text{s.t.}&amp;amp;\quad X = \min(A,B)\tag2\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$A,B$&lt;/span&gt; functions that depend on &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to represent &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; as a continuous constraint?&lt;/strong&gt; i.e., I don't want to use binary variables.&lt;/p&gt;&#xA;&lt;p&gt;I can't do:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;   X \leq A \\&#xA;   X \leq B &#xA;\end{align}&lt;/span&gt;&#xA;Because the minimization of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; would give me &lt;span class=&quot;math-container&quot;&gt;$X = 0$&lt;/span&gt;, and&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;   X \geq A \\&#xA;   X \geq B &#xA;\end{align}&lt;/span&gt;&#xA;would give me the max.&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="123" LastEditDate="2021-11-15T19:56:06.180" LastActivityDate="2021-11-15T22:15:55.620" Title="Represent the minimum between two terms as a continuous constraint" Tags="|constraint|logical-constraints|continuous-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7283" PostTypeId="1" AcceptedAnswerId="7288" CreationDate="2021-11-15T20:56:28.777" Score="3" ViewCount="138" Body="&lt;p&gt;My question is about how usual/strange defining constraints compactly can be (in a scientific document). Formally, I define constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f_{i,j,k}(x) \leq 0, \quad \forall i \in [I], \ \forall j \in [I], \ \forall k \in K(i,j)​$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$K(i,j) := \{ k \ : \ A_k \cap (A_i \cap A_j) \neq \emptyset \}$&lt;/span&gt;. However, for some combinations of &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, we have &lt;span class=&quot;math-container&quot;&gt;$A_{i} \cap A_j = \emptyset$&lt;/span&gt; so we have &lt;span class=&quot;math-container&quot;&gt;$K(i,j) = \emptyset$&lt;/span&gt;. I have two options:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Define the constraints for all &lt;span class=&quot;math-container&quot;&gt;$i \in [I]$&lt;/span&gt; and for all &lt;span class=&quot;math-container&quot;&gt;$j,k$&lt;/span&gt; in some (slightly more) complicated set parametrized by &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, or,&lt;/li&gt;&#xA;&lt;li&gt;Just note that if we have some constraints where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is not defined, we &lt;em&gt;ignore&lt;/em&gt; these constraints (&lt;em&gt;i.e.&lt;/em&gt;, these constraints are not defined).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I was wondering, can I &amp;quot;get away&amp;quot; with the second option? I do not want to introduce a set for &lt;span class=&quot;math-container&quot;&gt;$(j,k)$&lt;/span&gt;, rather keep it as it is, and just ignore the constraints for &lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$K(i,j) = \emptyset$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;End-notes&lt;/strong&gt;: &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is an arbitrary function, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a decision variable, &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is an abitrary natural number, e.g., &lt;span class=&quot;math-container&quot;&gt;$I = 5$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$|I|$&lt;/span&gt; denotes &lt;span class=&quot;math-container&quot;&gt;$1,\ldots, I$&lt;/span&gt;. The sets &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i \in [I]$&lt;/span&gt; are not important in this context.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2021-11-15T22:45:29.240" Title="Defining multiple constraints compactly where some index combinations are not defined" Tags="|optimization|constraint|terminology|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7284" PostTypeId="2" ParentId="7282" CreationDate="2021-11-15T20:59:12.970" Score="1" Body="&lt;p&gt;As far as i know you will have to&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;resort to a bi-level optimzation problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\min_{A,B} x $&lt;/span&gt; subject to (&lt;span class=&quot;math-container&quot;&gt;$\max_x$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$x\leq A$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$x \leq B$&lt;/span&gt;)&lt;/li&gt;&#xA;&lt;li&gt;solve a series of non linear problems where you approximate the &lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; term by something non-linear (a soft max) and let that converge against &lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;be fine with an &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{m}$&lt;/span&gt; error and turn it into an Mixed Integer problem &lt;span class=&quot;math-container&quot;&gt;$A \leq X + \frac{1}{m}(B_A) + m(1-B_A)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$B_A$&lt;/span&gt; is a boolean and &lt;span class=&quot;math-container&quot;&gt;$\sum_i B_i \geq 1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;solve the pareto frontier of minimzing both &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; and pick your winner from the pareto front&lt;/li&gt;&#xA;&lt;li&gt;solve a series of feasibility problem without optimization criteria where you say &lt;span class=&quot;math-container&quot;&gt;$X=0.033$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$A\leq X$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B \leq X$&lt;/span&gt; and tweak the X value until you are satisfied, rejecting unfeasible points. Note this approach need special attention if things are non-convex.&lt;/li&gt;&#xA;&lt;li&gt;If you know that &lt;span class=&quot;math-container&quot;&gt;$A=B$&lt;/span&gt; leaves a feasible (hopefully) convex subspace at the end of which is the minima of your problem &lt;span class=&quot;math-container&quot;&gt;$\min A$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$A=B$&lt;/span&gt; solves your problem. If you are not that sure because of bounded discontinuities relax that equality into &lt;span class=&quot;math-container&quot;&gt;$A - \varepsilon \leq B \leq A + \varepsilon$&lt;/span&gt; optimize for A and the reverse optimize for B and pick the better one. The choice of &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt; must be derived from your problem.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Or &lt;strong&gt;most simple&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Minimize &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, Minimize &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; and pick the winner comparing the minimas. Provided that makes sense for your usecase.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Depending on the nature of &lt;span class=&quot;math-container&quot;&gt;$A,B$&lt;/span&gt; and other constraints different approaches might be appropriate.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2021-11-15T22:15:55.620" LastActivityDate="2021-11-15T22:15:55.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7285" PostTypeId="1" AcceptedAnswerId="7310" CreationDate="2021-11-15T21:09:31.993" Score="2" ViewCount="73" Body="&lt;p&gt;When encoding a problem into a Mixed Integer formula one faces a trade-off between embedding domain knowledge which might require new helper variables to express the constraints thereby growing the formulation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Are you aware of any rule of thumb for mixed integer (Linear, Quadratic or Non-linear) problems whether encoding some additional constraint is worth the number of variables and constraints?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For MILP i might imagine it to look like the product of the simplex iteration time of the two variants times some function of the size of the possibilty space on both variants.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-11-18T10:09:35.000" Title="Rule of thumb for introducing known constraints in Mixed Integer problem when they grow the formula" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7286" PostTypeId="1" AcceptedAnswerId="7289" CreationDate="2021-11-15T21:31:54.927" Score="2" ViewCount="132" Body="&lt;p&gt;I have a problem where I have many products between variables drawn out of &lt;span class=&quot;math-container&quot;&gt;$\{-1,0,1\}$&lt;/span&gt;. Could you suggest a linearization in terms of variables in  &lt;span class=&quot;math-container&quot;&gt;$\{-1,0,1\}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$B_1 - B_2$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$B_i \in \{0,1\}$&lt;/span&gt; possibly with a constraint like &lt;span class=&quot;math-container&quot;&gt;$1\geq B_1 + B_2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1 \leq B_1 + B_2$&lt;/span&gt; to get rid of double encoding of &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; when found helpful.&lt;/p&gt;&#xA;&lt;p&gt;I tried to find a way to construct this using the linearization of the product of Booleans but I found no way to do so elegantly (that is do so without implementing the CNF of the Karnaugh diagram for &lt;span class=&quot;math-container&quot;&gt;$B_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B_2$&lt;/span&gt; of the result). The fact that such a CNF encoding is possible suggests that there might exist a more appropriate formulation for MILP.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="123" LastEditDate="2021-11-16T06:47:37.457" LastActivityDate="2021-11-16T06:47:37.457" Title="Linearize product of $x\cdot y \text{ with } x,y \in \{-1,0,1\}$ for MILP" Tags="|mixed-integer-programming|linearization|quadratic-programming|logical-constraints|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7287" PostTypeId="2" ParentId="7283" CreationDate="2021-11-15T21:46:29.333" Score="4" Body="&lt;p&gt;One approach is to define a sparse set &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; of triples:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$T=\{i\in [I], j \in [I], k\in [I]: A_i \cap A_j \cap A_k \not= \emptyset\}$$&lt;/span&gt;&#xA;or&#xA;&lt;span class=&quot;math-container&quot;&gt;$$T=\{(i,j,k)\in [I]^3: A_i \cap A_j \cap A_k \not= \emptyset\}.$$&lt;/span&gt;&#xA;Then write the constraint as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f_{i,j,k}(x) \le 0 \quad \text{for $(i,j,k)\in T$}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-11-15T21:46:29.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7288" PostTypeId="2" ParentId="7283" CreationDate="2021-11-15T22:45:29.240" Score="3" Body="&lt;p&gt;The constraint is defined only for triples &lt;span class=&quot;math-container&quot;&gt;$(i,j,k)$&lt;/span&gt; satisfying the domain conditions, including the requirement that &lt;span class=&quot;math-container&quot;&gt;$k\in K(i,j)$&lt;/span&gt;. So I think it is fine to just point out that &lt;span class=&quot;math-container&quot;&gt;$K(i,j)$&lt;/span&gt; can be empty and remind the reader that &lt;span class=&quot;math-container&quot;&gt;$K(i,j)=\emptyset$&lt;/span&gt; implies there are no instances of this constraint for that combination of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. In other words, I think your option 2 is perfectly acceptable.&lt;/p&gt;&#xA;&lt;p&gt;Be warned, though, that not all referees are reasonable people. :-)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-15T22:45:29.240" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7289" PostTypeId="2" ParentId="7286" CreationDate="2021-11-15T22:49:25.270" Score="4" Body="&lt;p&gt;If you write &lt;span class=&quot;math-container&quot;&gt;$x=B_1-B_2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y=B_3-B_4$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z=B_5-B_6$&lt;/span&gt; and supply the nine solutions for which &lt;span class=&quot;math-container&quot;&gt;$z=x\cdot y$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B_1+B_2 \le 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B_3+B_4 \le 1$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$B_5+B_6 \le 1$&lt;/span&gt;, PORTA returns &lt;span class=&quot;math-container&quot;&gt;$B_i \ge 0$&lt;/span&gt; and the following seven inequalities:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;- B_1        - B_3               + B_6 &amp;amp;\le 0 \\&#xA;- B_1               - B_4 + B_5        &amp;amp;\le 0 \\&#xA;       - B_2 - B_3        + B_5        &amp;amp;\le 0 \\&#xA;       - B_2        - B_4        + B_6 &amp;amp;\le 0 \\&#xA;- B_1 - B_2               + B_5 + B_6 &amp;amp;\le 0 \\&#xA;              - B_3 - B_4 + B_5 + B_6 &amp;amp;\le 0 \\&#xA;B_1 + B_2 + B_3 + B_4 - B_5 - B_6 &amp;amp;\le 1&#xA;\end{align}&lt;/span&gt;&#xA;The resulting system has only the nine originating solutions.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-11-15T22:49:25.270" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7290" PostTypeId="1" CreationDate="2021-11-16T08:11:31.793" Score="5" ViewCount="135" Body="&lt;p&gt;I am working on an MILP problem, and the project needs to output the top N best results rather than the global best. I am looking for an open source solver which has a callback function. Can anyone provide help on this?&lt;/p&gt;&#xA;" OwnerUserId="7534" LastEditorUserId="123" LastEditDate="2021-11-16T08:38:07.137" LastActivityDate="2022-06-14T01:33:07.407" Title="Is there any open source solver for MILP that can output the top N best results instead of the global best?" Tags="|mixed-integer-programming|open-source|callback|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7291" PostTypeId="1" AcceptedAnswerId="7292" CreationDate="2021-11-16T11:05:01.807" Score="6" ViewCount="5849" Body="&lt;p&gt;I am looking for an answer to a question I can't quite get behind. (continuation of &lt;a href=&quot;https://or.stackexchange.com/questions/7279/linear-programming-integer-and-non-integer-decision-variables&quot;&gt;Linear Programming: Integer and non-integer decision variables&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;I am given the following mathematical optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_{t\in T}s_t\cdot z_t+h_t\cdot i_t+p_t\cdot q_t\tag1\\\text{s.t.}&amp;amp;\quad i_0=0\tag2\\&amp;amp;\quad i_{t-1}+q_t-i_t=d_t&amp;amp;\forall t\in T\tag3\\&amp;amp;\quad q_t\le c_t\cdot z_t&amp;amp;\forall t\in T\tag4\\&amp;amp;\quad \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, the following table is given:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;1&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;2&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;3&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;4&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;5&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;6&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;7&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;8&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;9&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;10&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;demand &lt;span class=&quot;math-container&quot;&gt;$d_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;12&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;6&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;20&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;7&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;25&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;0&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;21&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;capacity &lt;span class=&quot;math-container&quot;&gt;$c_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;20&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;15&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;30&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;20&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;20&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;21&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;10&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;10&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;set-up costs &lt;span class=&quot;math-container&quot;&gt;$s_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;25&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;30&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;40&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;20&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;80&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;80&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;150&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;30&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;40&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;60&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;storage costs &lt;span class=&quot;math-container&quot;&gt;$h_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;6&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;4&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;6&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;9&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;9&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;6&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;production costs &lt;span class=&quot;math-container&quot;&gt;$p_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;3&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;7&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;2&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;10&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;15&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;2&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;production days &lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;0&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;0&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;0&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Decision variables are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$q_t$&lt;/span&gt;: quantity in time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$i_t$&lt;/span&gt;: inventory in time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If I implement this problem in Excel and solve it with the Excel Solver I get an optimal solution and a sensitivity report which look like the following.&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;1&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;2&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;3&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;4&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;5&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;6&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;7&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;8&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;9&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;10&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;quantity &lt;span class=&quot;math-container&quot;&gt;$d_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;18&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;15&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;23&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;20&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;0&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;0&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;10&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;10&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;inventory &lt;span class=&quot;math-container&quot;&gt;$c_t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;6&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;15&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;0&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;18&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;31&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;6&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;6&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;11&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;16&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lC4Zl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lC4Zl.png&quot; alt=&quot;![enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So far so good. However, what I don't understand are the reduced costs in this specific example. What is the practical interpretation of, for example, the reduced costs of 18 for 'Inventory Day 3'(marked in red in the sensitivity report)?&#xA;And also, why have some variables which are not part of the solution (=non basis variable with value 0) reduced costs of 0 (also marked in red in the sensitivity report)?&lt;/p&gt;&#xA;" OwnerUserId="7525" LastEditorUserId="123" LastEditDate="2021-11-16T11:19:28.630" LastActivityDate="2023-05-30T22:00:47.650" Title="Interpretation of Reduced Costs" Tags="|linear-programming|simplex|reduced-costs|sensitivity-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7292" PostTypeId="2" ParentId="7291" CreationDate="2021-11-16T11:21:43.043" Score="6" Body="&lt;p&gt;The reduced costs (or marginal costs), tell you by how much the objective function will increase (or decrease), if the corresponding variable increases by one unit.&lt;/p&gt;&#xA;&lt;p&gt;So if you are minimizing, the reduced costs of the variables of your optimal solution should all be non negative. Otherwise, increasing the value of the variable with negative reduced cost would decrease the objective function, contradicting the fact that the solution is optimal.&lt;/p&gt;&#xA;&lt;p&gt;In your case, the reduced costs for 'Inventory Day 3' is &lt;span class=&quot;math-container&quot;&gt;$18$&lt;/span&gt;, and the corresponding value is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. This means that if the variable took value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, the objective function would increase by &lt;span class=&quot;math-container&quot;&gt;$18$&lt;/span&gt; units.&lt;/p&gt;&#xA;&lt;p&gt;Likewise for the variables with value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and reduced cost &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. You can make them &amp;quot;part of the solution&amp;quot; as you say, but it will have no impact on the objective function (it will increase by &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; units).&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2021-11-16T11:21:43.043" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7293" PostTypeId="1" AcceptedAnswerId="7294" CreationDate="2021-11-16T13:07:40.853" Score="5" ViewCount="2275" Body="&lt;p&gt;Given two integer variables &lt;span class=&quot;math-container&quot;&gt;$L_x \leq x \leq U_x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L_y \leq y \leq U_y$&lt;/span&gt;, how can we linearize the product &lt;span class=&quot;math-container&quot;&gt;$x \cdot y$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2021-11-16T22:58:47.543" Title="How to linearize the product of two integer variables?" Tags="|mixed-integer-programming|modeling|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7294" PostTypeId="2" ParentId="7293" CreationDate="2021-11-16T13:07:40.853" Score="7" Body="&lt;p&gt;A straightforward approach is to express the integer variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in terms of binary variables. In case &lt;span class=&quot;math-container&quot;&gt;$L_x &amp;lt; 0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$L_y &amp;lt; 0$&lt;/span&gt;, we can use the two complement's representation, see &lt;a href=&quot;https://or.stackexchange.com/questions/6526/how-to-represent-an-integer-variable-via-binary-variables/6527#6527&quot;&gt;this answer&lt;/a&gt; for more details. So let's assume &lt;span class=&quot;math-container&quot;&gt;$L_x, L_y \geq 0$&lt;/span&gt;. Then, we have&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x \cdot y = \left( \sum_{i=0}^{M_x - 1} 2^i x_i \right) \cdot \left( \sum_{j=0}^{M_y - 1} 2^j y_j \right) = \sum_{i=0}^{M_x -1} \sum_{j=0}^{M_y-1} 2^{i+j} x_i y_j,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$M_x = \left\lceil \log_2{(U_x + 1)} \right\rceil$&lt;/span&gt; binary variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_y = \left\lceil \log_2{(U_y + 1)} \right\rceil$&lt;/span&gt; binary variables &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt;. Now we can linearize the products of two binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{ij} = x_iy_j$&lt;/span&gt; by introducing additional binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; and imposing the constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;z_{ij} &amp;amp;\leq x_i, \\&#xA;z_{ij} &amp;amp;\leq y_j, \\&#xA;z_{ij} &amp;amp;\geq x_i + y_j - 1,&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for all &lt;span class=&quot;math-container&quot;&gt;$i = 0, \ldots, M_x-1, j = 0, \ldots, M_y - 1$&lt;/span&gt;. Since &lt;span class=&quot;math-container&quot;&gt;$M_xM_y + M_x + M_y$&lt;/span&gt; binary variables are required to linearize the integer product &lt;span class=&quot;math-container&quot;&gt;$x \cdot y$&lt;/span&gt;, this approach is only worth if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;'s and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;'s range of values is small.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Edit: As 4er mentioned in the comments, we can significantly reduce the number of required binary variables by only expressing &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in terms of binary variables. Let again assume &lt;span class=&quot;math-container&quot;&gt;$L_x \geq 0$&lt;/span&gt;. Then,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x \cdot y = \left( \sum_{i=0}^{M_x - 1} 2^i x_i \right) \cdot y = \sum_{i=0}^{M_x - 1} 2^i x_i y.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Consequently, we only need to linearize the &lt;span class=&quot;math-container&quot;&gt;$M_x$&lt;/span&gt; products &lt;span class=&quot;math-container&quot;&gt;$z_i = x_i y$&lt;/span&gt; of a binary and an integer variable by imposing the constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;z_i &amp;amp;\leq U_y x_i \\ &#xA;z_i &amp;amp;\geq L_y x_i \\ &#xA;z_i &amp;amp;\leq y - L_y (1-x_i) \\ &#xA;z_i &amp;amp;\geq y - U_y (1-x_i) \\&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for all &lt;span class=&quot;math-container&quot;&gt;$i = 0, \ldots, M_x - 1$&lt;/span&gt;. Thus, only &lt;span class=&quot;math-container&quot;&gt;$M_x$&lt;/span&gt; binary variables and &lt;span class=&quot;math-container&quot;&gt;$M_x$&lt;/span&gt; general variables need to be introduced.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="52" LastEditDate="2021-11-16T22:58:47.543" LastActivityDate="2021-11-16T22:58:47.543" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7295" PostTypeId="1" CreationDate="2021-11-16T14:18:02.657" Score="0" ViewCount="232" Body="&lt;p&gt;For an optional ungraded assignment (see it as a complex problem that won't be graded, more to test our skills and knowledge) I was given the following problem. It is not as straightforward as all the other examples we covered and I would really like to know how to solve the problem.&lt;/p&gt;&#xA;&lt;p&gt;A hotel is estimating that in the next 7 days they will need to have available the following number of sheets:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Day&lt;/th&gt;&#xA;&lt;th&gt;1&lt;/th&gt;&#xA;&lt;th&gt;2&lt;/th&gt;&#xA;&lt;th&gt;3&lt;/th&gt;&#xA;&lt;th&gt;4&lt;/th&gt;&#xA;&lt;th&gt;5&lt;/th&gt;&#xA;&lt;th&gt;6&lt;/th&gt;&#xA;&lt;th&gt;7&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Sheet demand&lt;/td&gt;&#xA;&lt;td&gt;20&lt;/td&gt;&#xA;&lt;td&gt;15&lt;/td&gt;&#xA;&lt;td&gt;30&lt;/td&gt;&#xA;&lt;td&gt;40&lt;/td&gt;&#xA;&lt;td&gt;45&lt;/td&gt;&#xA;&lt;td&gt;45&lt;/td&gt;&#xA;&lt;td&gt;15&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Starting day 1 they have 0 sheets. They need to buy sheets at $20 per set and they can wash to reuse. There are 2 types of laundry services:&lt;/p&gt;&#xA;&lt;p&gt;$6 requiring 2 days (sheets can be used on day 1 and then again on day 3)&lt;/p&gt;&#xA;&lt;p&gt;$3 requiring 3 days (sheets can be used on day 1 and then again on day 4)&lt;/p&gt;&#xA;&lt;p&gt;The question:&lt;/p&gt;&#xA;&lt;p&gt;How can I formulate the linear programming model to determine the optimal laundry and purchasing policy? And how can I run this using Gurobi (Python)?&lt;/p&gt;&#xA;&lt;p&gt;All I know up to now is that I need to minimize &lt;em&gt;costs of buying, cheap and luxury laundry&lt;/em&gt;. Lets say buy = b_i and ranges from 1-7, luxury = x_i and ranges from 1-5 and cheap = y_ij and ranges from (1.4, 1.5, 1.6, 1.7 , 2.5, 2.6, 2.7, 3.6, 3.7 and 4.7), other than that I do not know how to go further.&lt;/p&gt;&#xA;" OwnerDisplayName="user7537" LastEditorDisplayName="user7537" LastEditDate="2021-11-16T14:58:47.723" LastActivityDate="2021-11-17T15:26:20.957" Title="How to solve the following linear programming problem using Gurobi (or at least python)?" Tags="|linear-programming|python|gurobi|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7297" PostTypeId="1" AcceptedAnswerId="7298" CreationDate="2021-11-16T18:27:10.010" Score="5" ViewCount="325" Body="&lt;p&gt;I am trying to create an LP problem which is like the knapsack problem but where there is a fixed bonus/penalty based on the number of items chosen.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There are 20 items to choose from with some weight between 1 to 20.&lt;/li&gt;&#xA;&lt;li&gt;Knapsack can hold a total weight W=40&lt;/li&gt;&#xA;&lt;li&gt;If only 1 item is chosen, there is a penalty of -3&lt;/li&gt;&#xA;&lt;li&gt;If 2 items are chosen, there is a bonus of 2&lt;/li&gt;&#xA;&lt;li&gt;If 3 items are chosen, there is a bonus of 1.5&lt;/li&gt;&#xA;&lt;li&gt;If 4 items are chosen, there is a bonus of 6&lt;/li&gt;&#xA;&lt;li&gt;If 5 or more items are chosen, there is a penalty of -4&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;While it seems like a simple problem, the bonus/penalties are constantly changing, and there are times that the bonus for 1 item is so high that it's the solution. My objective function is to maximize the total weight and the bonus/penalty associated with the number of items chosen.&lt;/p&gt;&#xA;&lt;p&gt;I tried creating a Dictionary (call it dict) for my bonus/penalties and then having my objective function be &lt;code&gt;sum(items[i]*weights[i] for i in 1:20) + dict[sum(items[i] for i in 1:20)]&lt;/code&gt; . The second part, the dictionary lookup, does not work and gives me an error so I must be doing something wrong.&lt;/p&gt;&#xA;&lt;p&gt;Are dictionary lookups valid in an LP problem? Do I need to convert this to something else?&lt;/p&gt;&#xA;" OwnerUserId="7539" LastEditorUserId="491" LastEditDate="2021-11-17T22:52:17.260" LastActivityDate="2021-11-17T22:52:17.260" Title="How to optimize on a fixed-cost based on number of results?" Tags="|optimization|linear-programming|modeling|linearization|knapsack|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7298" PostTypeId="2" ParentId="7297" CreationDate="2021-11-16T18:52:27.527" Score="9" Body="&lt;p&gt;You can linearize the objective as follows.&lt;/p&gt;&#xA;&lt;p&gt;Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; indicate whether item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is chosen, and let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_c$&lt;/span&gt; indicate whether the count of chosen items is &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.  Let &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; be the weight of item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$b_c$&lt;/span&gt; be the bonus/penalty for choosing &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; items.  The problem is to maximize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i w_i x_i + \sum_c b_c y_c$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i w_i x_i &amp;amp;\le W \tag1\\&#xA;\sum_c y_c &amp;amp;= 1 \tag2 \\&#xA;\sum_c c y_c &amp;amp;= \sum_i x_i \tag3&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; is the usual knapsack constraint.&#xA;Constraints &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; enforce &lt;span class=&quot;math-container&quot;&gt;$y_c=1 \iff \sum_i x_i = c$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-11-16T18:52:27.527" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="7300" PostTypeId="1" CreationDate="2021-11-16T23:29:40.030" Score="5" ViewCount="136" Body="&lt;p&gt;Is there a way to make Gurobi output (an estimate of) how much of the search space has already been cut off as infeasible?&lt;/p&gt;&#xA;&lt;p&gt;If not with Gurobi are you aware of any binary only (912 of them) ILP solver that does provide that information?&lt;/p&gt;&#xA;&lt;p&gt;I suspect the problem i have is infeasible and i would like to get an idea how much progress has been made or ideally an estimate how much time remaining until infeasibility is proven (which should be quiet predictable unless terminating earlier in case of stumbling into a feasible solution).&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2021-12-17T17:05:50.533" Title="What fraction of the search space has been searched for ILP?" Tags="|integer-programming|gurobi|binary-variable|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7301" PostTypeId="1" AcceptedAnswerId="7312" CreationDate="2021-11-17T08:36:58.287" Score="3" ViewCount="116" Body="&lt;p&gt;I've been working on a optimisation problem at work regarding blending. Essentially we have different types of grain stock with different properties and we bought them for different amounts. We then have a bunch of customer contracts requesting some amount of grain with certain property constraints (e.g. protein content must be less than this amount). We can blend our stocks to fulfill a contract provided that the property constraints of the contract are not violated. We can formulate this pretty easily as an LP problem where our objective function is to minimise the total price of grain stock we allocated to all of our contracts, and the constraints are given by the contracts property constraints, the grain amount specified by the contract and the amount of grain stock we have on hand.&lt;/p&gt;&#xA;&lt;p&gt;In reality however we are constantly receiving new stock throughout a given year and shipments for contracts will happen at different times. We will also receive new contracts throughout the year too. So at any point in time we potentially don't know stock and contracts we could have in the future. How would I take into account this time varying aspect to formulate this as an optimisation problem such that we could maximise profit for a given year? We were considering just optimising for each batch of contracts that correspond to the same shipping period individually using stock we would have at that point in time but is there a way to formulate this problem as one single global problem?&lt;/p&gt;&#xA;" OwnerUserId="7543" LastEditorUserId="123" LastEditDate="2021-11-20T14:53:54.533" LastActivityDate="2021-11-20T14:53:54.533" Title="How to formulate this optimisation problem that has time varying components?" Tags="|optimization|linear-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7302" PostTypeId="1" AcceptedAnswerId="7307" CreationDate="2021-11-17T10:30:03.963" Score="3" ViewCount="215" Body="&lt;p&gt;It's almost this question: &lt;a href=&quot;https://or.stackexchange.com/questions/4715/formulating-the-conditional-constraint&quot;&gt;Formulating the conditional constraint&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But there they have non-strict inequality. I have &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; a boolean decision var and &lt;span class=&quot;math-container&quot;&gt;$Q_i$&lt;/span&gt; as a nonnegative integer decision variable such that&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$x_i = 0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$Q_i = 0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$Q_i \gt 0$&lt;/span&gt; (note the strict inequality!).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Lets say I dont have upper bound on &lt;span class=&quot;math-container&quot;&gt;$Q_i$&lt;/span&gt;; is there a mathematical relation between &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q_i$&lt;/span&gt; you can write directly or is the following way to go?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar boolean x[I];&#xA;dvar int+ Q[I];&#xA;&#xA;subject to&#xA;{&#xA;  forall(i in I) {&#xA;     (x[i]==0) =&amp;gt; (Q[i] == 0);&#xA;     (x[i]==1) =&amp;gt; (Q[i] &amp;gt; 0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I can formulate the constraint other way but does it help I'm not sure:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$Q_i = 0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_i = 0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$Q_i \gt 0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7544" LastActivityDate="2021-11-18T13:31:21.890" Title="Conditional constraint with a strict inequality" Tags="|modeling|integer-programming|cplex|logical-constraints|indicator-constraints|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="7303" PostTypeId="1" AcceptedAnswerId="7311" CreationDate="2021-11-17T14:54:19.847" Score="2" ViewCount="135" Body="&lt;p&gt;I am trying to solve a Capacitated Facility Location Problem (CFLP) with a dynamic setup cost in &lt;code&gt;R&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The problem statement is this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I have the transport cost&lt;/li&gt;&#xA;&lt;li&gt;The fixed operating cost (manual labor and other expenses) is known&lt;/li&gt;&#xA;&lt;li&gt;I know the dropping points with loads and all the details&lt;/li&gt;&#xA;&lt;li&gt;The per square ft. cost of rent of a place is known&lt;/li&gt;&#xA;&lt;li&gt;The size of the Facility will be a function of the load. So the rent will depend on how much load is getting allocated in that place.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Assuming the rent will vary like this:&lt;/p&gt;&#xA;&lt;p&gt;rent= rent_per_square_ft * load* 0.10&lt;/p&gt;&#xA;&lt;p&gt;Now, I have accommodated the first 4 conditions in my code. But I am not sure how the number 5 can be accommodated.&lt;/p&gt;&#xA;&lt;p&gt;My model looks like this in &lt;code&gt;R&lt;/code&gt;(if it can be of any help):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#m is the number of potential facility/service center (SC) locations&#xA;#n is the number of customer locations&#xA;&#xA;model &amp;lt;- MIPModel() %&amp;gt;%&#xA;  # 1 if customer i gets assigned to SC j&#xA;  add_variable(x[i, j], i = 1:n, j = 1:m, type = &amp;quot;binary&amp;quot;) %&amp;gt;%&#xA;  &#xA;  # 1 if SC j is built&#xA;  add_variable(y[j], j = 1:m, type = &amp;quot;binary&amp;quot;) %&amp;gt;%&#xA;  &#xA;  # Objective function&#xA;  set_objective(sum_expr(transportcost(i, j) * x[i, j], i = 1:n, j = 1:m) + &#xA;                  sum_expr(fixedcost[j] * y[j], j = 1:m), &amp;quot;min&amp;quot;) %&amp;gt;%&#xA;  &#xA;  # Every customer needs to be assigned to a SC&#xA;  add_constraint(sum_expr(x[i, j], j = 1:m) == 1, i = 1:n) %&amp;gt;% &#xA;  &#xA;  # If a customer is assigned to a SC, then the SC must be built&#xA;  add_constraint(x[i,j] &amp;lt;= y[j], i = 1:n, j = 1:m) %&amp;gt;%&#xA;  &#xA;  #The demand of customers shouldn't exceed SC capacities&#xA;  add_constraint(sum_expr(demand[i] * x[i, j], i = 1:n) &amp;lt;= capacity[j] * y[j], j = 1:m)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am looking for any headway. Even any link to a relevant article might help.&lt;/p&gt;&#xA;" OwnerUserId="5532" LastEditorUserId="5532" LastEditDate="2021-11-17T16:12:26.160" LastActivityDate="2021-11-18T16:22:58.457" Title="Capacitated Facility Location problem with a dynamic set up cost" Tags="|optimization|mixed-integer-programming|heuristics|metaheuristics|facility-location|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7304" PostTypeId="2" ParentId="7295" CreationDate="2021-11-17T15:26:20.957" Score="1" Body="&lt;ul&gt;&#xA;&lt;li&gt;A) For each day for each required sheet, make an optimization variable that decides whether to do expensive or cheap laundry after using it that day.&lt;/li&gt;&#xA;&lt;li&gt;B) Don't make the &amp;quot;sheets to buy&amp;quot; a genuine optimization variable. Simply buy the number of missing sheets every day. Let's call that a shadow variable &lt;code&gt;sheetsToBuy&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;C) For each day, add a shadow variable &lt;code&gt;availableSheets&lt;/code&gt; to calculate the number of sheets available to use that day, before buying extra. So if &lt;code&gt;requiredSheets &amp;gt; availableSheets&lt;/code&gt;, then &lt;code&gt;sheetsToBuy = requiredSheets - availableSheets&lt;/code&gt;. Calculation for &lt;code&gt;availableSheets = previousday.availableSheets - (previousday.requiredSheets - previousDay.sheetsToBuy) + day.sheetsReturningFromLaundry&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;D) That &lt;code&gt;sheetsReturningFromLaundry&lt;/code&gt; is calculated based on the&#xA;optimization variables from A). Basically the number of expensive laundry decisions 2 days ago plus the number of cheap laundry decisions 3 days ago.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-11-17T15:26:20.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7305" PostTypeId="2" ParentId="7300" CreationDate="2021-11-17T16:01:56.607" Score="1" Body="&lt;p&gt;I would expect the measure of Xpress (and SCIP) to work reasonably well for infeasible problems. They take into account at which levels nodes have been pruned during search and that directly relates to the search space size.&lt;/p&gt;&#xA;&lt;p&gt;For a feasibility problem, where finding a solution can terminate the whole search at any time, this is different, of course.&lt;/p&gt;&#xA;" OwnerUserId="7548" LastActivityDate="2021-11-17T16:01:56.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7307" PostTypeId="2" ParentId="7302" CreationDate="2021-11-17T21:37:13.137" Score="2" Body="&lt;p&gt;As already mentioned in the comments: If &lt;span class=&quot;math-container&quot;&gt;$_i$&lt;/span&gt; is an integer variable, then &lt;span class=&quot;math-container&quot;&gt;$_i &amp;gt; 0$&lt;/span&gt; is equivalent to &lt;span class=&quot;math-container&quot;&gt;$_i \geq 1$&lt;/span&gt;. Hence, you can use the indicator constraints offered by the most commercial solvers in case you don't know upper bounds, i.e. &lt;code&gt;(x[i]==1) =&amp;gt; (Q[i] &amp;gt;= 1)&lt;/code&gt;. Note also &lt;a href=&quot;https://or.stackexchange.com/questions/7302/conditional-constraint-with-a-strict-inequality/7307#comment15375_7302&quot;&gt;prubin's comment&lt;/a&gt; on how one can calculate an upper bound:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;By the way, you can (usually) calculate an upper bound for &lt;span class=&quot;math-container&quot;&gt;$Q_i$&lt;/span&gt; by relaxing the integrality constraints and maximizing Qi subject to the constraints. The only two issues here are (1) the LP might be unbounded and (2) if the problem is big enough, solving all those LPs (one for each i) might take too much time.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="7544" LastEditDate="2021-11-18T13:31:21.890" LastActivityDate="2021-11-18T13:31:21.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7308" PostTypeId="1" CreationDate="2021-11-18T03:37:28.690" Score="5" ViewCount="353" Body="&lt;p&gt;For an Integer Linear Programming problem (ILP), an irreducible infeasible set (IIS) is an infeasible subset of constraints, variable bounds, and integer restrictions that becomes feasible if any single constraint, variable bound, or integer restriction is removed. It is possible to have more than one IIS in an infeasible ILP.&#xA;Is it possible to identify all possible Irreducible Infeasible Sets (IIS) for an infeasible Integer Linear Programming problem (ILP)?&#xA;Ideally, I aim to find the MIN IIS COVER, which is the smallest cardinality subset of constraints to remove such that at least one constraint is removed from every IIS.&lt;/p&gt;&#xA;" OwnerUserId="7554" LastEditorUserId="36" LastEditDate="2021-11-18T04:50:44.663" LastActivityDate="2021-11-18T13:58:35.583" Title="Is it possible to identify all possible Irreducible Infeasible Sets (IIS) for an infeasible Integer Linear Programming problem? (ILP)?" Tags="|optimization|mixed-integer-programming|integer-programming|irreducible-infeasible-subset|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7309" PostTypeId="2" ParentId="7308" CreationDate="2021-11-18T05:15:24.100" Score="12" Body="&lt;p&gt;Equivalently, you want to remove the smallest number of constraints so that the resulting problem is feasible.  You can do this implicitly, without enumerating all Irreducible Infeasible Sets, by solving an auxiliary ILP problem.  Introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; for each constraint (including variable bounds as a special case)&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_j a_{i,j} x_j \le b_i$$&lt;/span&gt;&#xA;and a binary variable &lt;span class=&quot;math-container&quot;&gt;$u_j$&lt;/span&gt; and integer variable &lt;span class=&quot;math-container&quot;&gt;$v_j$&lt;/span&gt; for each integer variable &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt;, which you will relax to continuous.&#xA;The problem is to minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i z_i + \sum_j u_j \tag0$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j a_{i,j} x_j - b_i \le M_i z_i \quad \text{for all $i$} \tag1 \\&#xA;-u_j \le x_j - v_j \le u_j \quad \text{for all $j$} \tag2&#xA;\end{align}&lt;/span&gt;&#xA;The objective &lt;span class=&quot;math-container&quot;&gt;$(0)$&lt;/span&gt; minimizes the number of omitted restrictions.&#xA;The linear big-M constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces the logical implication &lt;span class=&quot;math-container&quot;&gt;$$z_i = 0 \implies \sum_j a_{i,j} x_j \le b_i$$&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$x_j \not= v_j \implies u_j = 1$&lt;/span&gt; to penalize a fractional value for &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-11-18T13:58:35.583" LastActivityDate="2021-11-18T13:58:35.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7310" PostTypeId="2" ParentId="7285" CreationDate="2021-11-18T10:09:35.000" Score="5" Body="&lt;p&gt;Unfortunately it's a trial and error game.  If and only if (pun intended) we try to solve the leanest version of the model and that doesn't work, we then start adding redundant constraints.&lt;/p&gt;&#xA;&lt;p&gt;The reason is simple: it's easy to make the model more complicated, but simplifying it is much harder.&lt;/p&gt;&#xA;&lt;p&gt;In global optimisation, the more constraints we have the easiest the problem becomes to solve (usually but not always). By &amp;quot;easier&amp;quot; here I mean that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;We explore fewer nodes&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We find better feasible solutions earlier during branch and bound&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;However, there is a crossover point where the additional constraints increase the cost of computations so much, that we're better off not adding any more constraints.&lt;/p&gt;&#xA;&lt;p&gt;This cost depends on:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Any redundant constraints the solver decides to add on top of our constraints&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How fast the solver we are using is&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Chaotic effects such as the solver having more (or less) trouble factorising the equations for no obvious reason, or the solver picking different variables to branch on, leading to very unexpected outcomes.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Making it harder/easier for the solver to satisfy feasibility because of numerics.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;At the solver level, we do this dynamically. We have a pool of cuts, and on every node we add the minimum number of redundant constraints that are likely to have great impact. That number (as well as the choice of constraints) are adjusted dynamically during the solving process through heuristics as well as trial and error. This means we'll try some stuff out, and if worked well, great. If it didn't, even though we expected it to, the solver will adjust its decision making according to the data.&lt;/p&gt;&#xA;&lt;p&gt;At the solver level we also do presolve before we start solving. This involves running dozens of different algorithms usually with the intent of extracting some useful information out of some constraints and then dropping them altogether, so it's not obvious to the modeller what constraints the solver will find &amp;quot;useful&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;A rule of thumb is to write a correct model and let the solver do its job. If that doesn't work, your hint that redundant constraints are not likely to help is if the solver is already showing slow iterations, i.e., it's already struggling with the size of the problem. If iterations are blazing fast but it's getting stuck on the same numbers, adding more constraints might help but this can also be a sign that actual constraints might be missing, not just redundant ones.&lt;/p&gt;&#xA;&lt;p&gt;When we do decide that adding more constraints is the way to go, the rule of thumb is: don't try to outsmart the solver. Dozens of people spent thousands of hours putting that thing together. The new information shouldn't be redundant constraints that the solver can add itself, it should be information about the behaviour of the system the model is describing.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-11-18T10:09:35.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7311" PostTypeId="2" ParentId="7303" CreationDate="2021-11-18T16:22:58.457" Score="3" Body="&lt;p&gt;Based on the comments, the rent for facility &lt;span class=&quot;math-container&quot;&gt;$j\in \lbrace 1,\dots,m \rbrace$&lt;/span&gt; would be &lt;span class=&quot;math-container&quot;&gt;$0.1\cdot R \cdot \sum_{i=1}^n d_i x_{ij}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; is the demand for customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; is the rent per square foot. If the rent per square foot varies from facility to facility, just change &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$R_j$&lt;/span&gt;. Sum those expressions over &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and add the sum to the objective function.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-18T16:22:58.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7312" PostTypeId="2" ParentId="7301" CreationDate="2021-11-18T16:38:46.870" Score="1" Body="&lt;p&gt;You can formulate this as a multiperiod production model (where &amp;quot;production&amp;quot; in this case means blending). If we start by assuming that arrivals of grain are predetermined (and known), you need variables in each period for end-of-period inventory of each grain type and for the amount of each grain stock used in each customer order. (I'm assuming here that customer contracts must be fulfilled, meaning you have control over how you blend the order but not the amount of grain that ends up getting shipped to the customer.) Your objective function would include the acquisition cost of any grain shipped, plus holding costs for the remaining inventory (if relevant). If you suffer inventory loss (spoilage or pilferage), then ending inventory of each stock would ending inventory of the previous period minus usage minus loss, and you likely would want to include the acquisition cost of lost grain in the objective function.&lt;/p&gt;&#xA;&lt;p&gt;A model like this can suffer &amp;quot;horizon effects&amp;quot;. If you run the model with a 12 month planning period, you might find that it ends the year with a mix of grains that would not be ideal for the start of the following year. There are a couple of heuristic approaches to deal with this. One is to guess values for end-of-year inventories (meaning not acquisition costs but how much a unit of each grain would save you in the future over a unit of a different grain) and include the end-of-year values in the objective (as a &amp;quot;profit&amp;quot;, not as a cost). I suspect that might be tricky. An easier approach is called a &amp;quot;rolling horizon&amp;quot;. Solve the model over a 12 month horizon, then implement the solution in the first month, first quarter, whatever. Then solve the model again with a new horizon, based on current inventories, use the first portion of that solution, and repeat.&lt;/p&gt;&#xA;&lt;p&gt;If you have control over the acquisition of grain stocks, you can add purchase volumes as variables and switch objective from the value of the grain stock used to the cost of the grain acquisitions, subject to possible constraints on what suppliers can/will supply. Quantity discounts, if offered, can be handled (although likely requiring an integer program).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-18T16:38:46.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7313" PostTypeId="1" CreationDate="2021-11-18T19:18:53.823" Score="2" ViewCount="86" Body="&lt;p&gt;Assume that we have 3 tasks to schedule : &lt;span class=&quot;math-container&quot;&gt;$x_{a1}, x_{a2}, x_{b3}$&lt;/span&gt;. They all use the same cumulative resource : &lt;span class=&quot;math-container&quot;&gt;$r_1$&lt;/span&gt;. Each activity increases &lt;span class=&quot;math-container&quot;&gt;$r_1$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; at it starts time and decreases &lt;span class=&quot;math-container&quot;&gt;$r_1$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; at it's end time. &lt;span class=&quot;math-container&quot;&gt;$r_1$&lt;/span&gt; has a maximum capacity of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. Where things get complicated is that &lt;span class=&quot;math-container&quot;&gt;$x_{a1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{a2}$&lt;/span&gt; can be executed at the same time and only consume &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; resource of &lt;span class=&quot;math-container&quot;&gt;$r_1$&lt;/span&gt;. So in this example, &lt;span class=&quot;math-container&quot;&gt;$x_{a1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{a2}$&lt;/span&gt; can be executed at the same time while &lt;span class=&quot;math-container&quot;&gt;$x_{b3}$&lt;/span&gt; must be executed before of after both &lt;span class=&quot;math-container&quot;&gt;$x_{a1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{a2}$&lt;/span&gt; are executed. Basically, tasks from the same family only consume &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; resource even if multiple tasks from this family are overlapping.&lt;/p&gt;&#xA;&lt;p&gt;Note that the maximum capacity of the ressource could be &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With CPOptimizer I know how to use &lt;code&gt;cumulFunction()&lt;/code&gt; but I don't know how I could implement the fact that multiple activites can be scheduled simultaneously while only consuming one resource.&lt;/p&gt;&#xA;" OwnerUserId="7347" LastEditorUserId="491" LastEditDate="2021-11-19T13:18:39.587" LastActivityDate="2021-11-19T13:18:39.587" Title="How to model a cumulative resource constraint with same family condition?" Tags="|modeling|cplex|constraint|scheduling|constraint-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7314" PostTypeId="2" ParentId="7313" CreationDate="2021-11-18T20:21:59.620" Score="2" Body="&lt;p&gt;You could define more than three tasks, the additional tasks being bundles of the original tasks. You would then make the interval variables optional, with the requirement that for each task exactly one of the intervals in which it would occur (either solo or as part of a bundle) must be present.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-18T20:21:59.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7315" PostTypeId="1" AcceptedAnswerId="7316" CreationDate="2021-11-19T04:09:14.683" Score="6" ViewCount="380" Body="&lt;p&gt;I am trying to create an LP problem which is like the knapsack problem but with groups of items. Let's say there are 10 groups of items each with up to 5 items. Each group has one special item and you must choose only one, let's call that group the &amp;quot;special group&amp;quot;. There's a bonus of 4 if you take 1 more item from the special group and a bonus of 8 if you pick two.&lt;/p&gt;&#xA;&lt;p&gt;What I have tried is having &lt;code&gt;g[1:10]&lt;/code&gt; which identifies the special group, then &lt;code&gt;a[5row, 10col]&lt;/code&gt; which tells me how many items were taken from each group, then a new variable &lt;code&gt;b[1:5]&lt;/code&gt; (max # of items). I then tried this constraint: &lt;code&gt;[i=1:5], b[i] &amp;lt;= sum(g[j] * a[i,j] for j in 1:10)&lt;/code&gt;. My goal here was that since I only care about my special group, I would multiply each group's item count in &lt;code&gt;a&lt;/code&gt; by whether it's the special group in &lt;code&gt;g&lt;/code&gt;. This introduces a quadratic constraint which is not allowed in my solver.&lt;/p&gt;&#xA;&lt;p&gt;What is the right approach to this problem?&lt;/p&gt;&#xA;" OwnerUserId="7539" LastEditorUserId="491" LastEditDate="2021-11-19T13:19:44.260" LastActivityDate="2021-11-25T16:54:26.310" Title="Optimize for bonuses within a group (knapsack)" Tags="|optimization|linear-programming|modeling|linearization|knapsack|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7316" PostTypeId="2" ParentId="7315" CreationDate="2021-11-19T05:13:31.703" Score="8" Body="&lt;p&gt;If I understand correctly, binary variable &lt;span class=&quot;math-container&quot;&gt;$g_j$&lt;/span&gt; indicates whether group &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is special, binary variable &lt;span class=&quot;math-container&quot;&gt;$a_{i,j}$&lt;/span&gt; indicates whether exactly &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; items are taken from group &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and binary variable &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; indicates whether exactly &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; items are taken from the special group.  You want to enforce the logical implication&#xA;&lt;span class=&quot;math-container&quot;&gt;$$b_i \implies \bigvee_j (g_j \land a_{i,j})$$&lt;/span&gt;&#xA;One approach is to introduce a new binary variable &lt;span class=&quot;math-container&quot;&gt;$c_{i,j}$&lt;/span&gt; and enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;c_{i,j} &amp;amp;\implies (g_j \land a_{i,j}) \tag1 \\&#xA;b_i &amp;amp;\implies \bigvee_j c_{i,j} \tag2&#xA;\end{align}&lt;/span&gt;&#xA;Rewriting &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; in conjunctive normal form yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c_{i,j} \implies (g_j \land a_{i,j}) \\&#xA;\lnot c_{i,j} \lor (g_j \land a_{i,j}) \\&#xA;(\lnot c_{i,j} \lor g_j) \land (\lnot c_{i,j} \lor a_{i,j}) \\&#xA;(1 - c_{i,j} + g_j \ge 1) \land (1 - c_{i,j} + a_{i,j} \ge 1) \\&#xA;(c_{i,j} \le g_j) \land (c_{i,j} \le a_{i,j})&#xA;$$&lt;/span&gt;&#xA;Rewriting &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; in conjunctive normal form yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;b_i \implies \bigvee_j c_{i,j} \\&#xA;\lnot b_i \lor \bigvee_j c_{i,j} \\&#xA;1 - b_i + \sum_j c_{i,j} \ge 1 \\&#xA;b_i \le \sum_j c_{i,j}&#xA;$$&lt;/span&gt;&#xA;So the desired linear constraints are&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;c_{i,j} &amp;amp;\le g_j \\&#xA;c_{i,j} &amp;amp;\le a_{i,j} \\&#xA;b_i &amp;amp;\le \sum_j c_{i,j}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;From your comment, it sounds like you also want to enforce the converse of &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(g_j \land a_{i,j}) \implies c_{i,j}$$&lt;/span&gt;&#xA;One approach is to again use conjunctive normal form to obtain&#xA;&lt;span class=&quot;math-container&quot;&gt;$$g_j + a_{i,j} - 1 \le c_{i,j} \quad \text{for all $i$ and $j$} $$&lt;/span&gt;&#xA;But because there is only one count per group, you have &lt;span class=&quot;math-container&quot;&gt;$\sum_i a_{i,j}=1$&lt;/span&gt; and can instead use &amp;quot;compact linearization&amp;quot; to obtain fewer constraints.  Explicitly, summing both sides of&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c_{i,j} = g_j a_{i,j}$$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i c_{i,j} = g_j \tag3$$&lt;/span&gt;&#xA;Because there is only one special group, you have &lt;span class=&quot;math-container&quot;&gt;$\sum_j g_j=1$&lt;/span&gt; and can further sum over &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to obtain just one constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j} c_{i,j} = 1 \tag4$$&lt;/span&gt;&#xA;as you suggested.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; yields a tighter LP formulation because constraint &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; is an aggregation, but either one is sufficient to enforce your desired behavior.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-11-25T16:54:26.310" LastActivityDate="2021-11-25T16:54:26.310" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7318" PostTypeId="1" AcceptedAnswerId="7339" CreationDate="2021-11-19T11:37:13.520" Score="4" ViewCount="398" Body="&lt;p&gt;I've been tasked to generate a forecast for our newly operation business which has more than 500+ sku. Almost 90% of them are following intermittent demand pattern, with very few data points to train upon (maximum I recorded 80-90 data points for each product) I cannot train an ML model.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way or model where I can train such small data set using excel or any other tool?&lt;/p&gt;&#xA;&lt;p&gt;Link to data &lt;a href=&quot;https://docs.google.com/spreadsheets/d/1W-wmYGzLtZpqV0IcYpeV6MrgdKESGmHr/edit?usp=sharing&amp;amp;ouid=104686423957654811582&amp;amp;rtpof=true&amp;amp;sd=true&quot; rel=&quot;nofollow noreferrer&quot;&gt;Intermittent_DATA&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7558" LastEditorUserId="7558" LastEditDate="2021-11-19T12:13:15.273" LastActivityDate="2021-11-25T10:20:28.607" Title="Multiple SKU forecast for Intermittent Demand" Tags="|forecasting|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7319" PostTypeId="1" AcceptedAnswerId="7320" CreationDate="2021-11-19T20:55:31.533" Score="5" ViewCount="435" Body="&lt;p&gt;Let us suppose &lt;span class=&quot;math-container&quot;&gt;$I_1, \ldots, I_n$&lt;/span&gt; are symmetric and positive definite matrices. Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{u}$&lt;/span&gt; be the vector with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; 1s. I'm interested in the following optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \; u^T (x_1I_1+x_2I_2+\ldots + x_nI_n)^{-1}u$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;such that &lt;span class=&quot;math-container&quot;&gt;$0 \leq x_i\leq 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum x_i \leq 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Question:&lt;/em&gt; Is the above optimization problem convex over the domain of &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;s?&lt;/p&gt;&#xA;" OwnerUserId="7561" LastEditorUserId="123" LastEditDate="2021-11-20T09:15:45.020" LastActivityDate="2021-12-12T12:54:17.927" Title="Inverse of weighted sum of positive definite matrices" Tags="|convex-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7320" PostTypeId="2" ParentId="7319" CreationDate="2021-11-19T21:45:44.287" Score="9" Body="&lt;p&gt;This is a convex optimization problem, which can easily be formed (and solved), in CVX, among other convex optimization tools.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$A = x_1I_1 + x_2I_2 + ... + x_nI_n$&lt;/span&gt;, where the &lt;span class=&quot;math-container&quot;&gt;$I_i$&lt;/span&gt; are m by m matrices (this does not require &lt;span class=&quot;math-container&quot;&gt;$m = n)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is symmetric positive definite, because each &lt;span class=&quot;math-container&quot;&gt;$x_iI_i$&lt;/span&gt; is symmetric positive definite, and hence the sum of these terms also is (unless all &lt;span class=&quot;math-container&quot;&gt;$x_i = 0$&lt;/span&gt; (in which case it would still be symmetric positive semidefinite), but the optimizer would never choose that solution because it is non-optimal).&lt;/p&gt;&#xA;&lt;p&gt;The objective function is a matrix fractional form, as is shown in example 3.4 of &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/bv_cvxbook.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Convex Optimization, by Boyd and Vandenberghe&lt;/a&gt;.  This is done by use of epigraph formulation, which utilizes a semidefinite constraint, which is shown in the YALMIP code at the end of this post.&lt;/p&gt;&#xA;&lt;p&gt;CVX (under MATLAB) conveniently has a function, &lt;code&gt;matrix_frac&lt;/code&gt;, which under the hood, converts this to the epigraph formulation shown in example 3.4 (and below in the YALMIP (under MATLAB) code). That formulation can be used if using a convex optimization tool, such as YALMIP, which doesn't have a built-in &lt;code&gt;matrix_frac&lt;/code&gt; function.  The popular tool, CVXPY (under Python), also has a &lt;code&gt;matrix_frac&lt;/code&gt;, which is used the same way as CVX's.&lt;/p&gt;&#xA;&lt;p&gt;The CVX code below (as well as the YALMIP code at the end of this post) assumes that I is an m by m by n array, for which &lt;span class=&quot;math-container&quot;&gt;$I(:,:,i) = I_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin&#xA;variable x(n)&#xA;A=0;&#xA;for i=1:n&#xA;  A=A+x(i)*I(:,:,i);&#xA;end&#xA;minimize(matrix_frac(ones(m,1),A))&#xA;0 &amp;lt;= x &amp;lt;= 1&#xA;sum(x) &amp;lt;= 1&#xA;cvx_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After successful execution, x will be populated with the optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;Note: the formulation could be changed, with no effect on optimal solution, to change the constraints to &lt;code&gt;0 &amp;lt;= x , sum(x) == 1&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here is the explicit epigraph formulation, which I'll show in YALMIP.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x = sdpvar(n,1);&#xA;t = sdpvar;&#xA;A=0;&#xA;for j=1:n&#xA;  A=A+x(j)*I(:,:,j);&#xA;end&#xA;Constraints = [[A ones(m,1);ones(1,m) t] &amp;gt;= 0,0 &amp;lt;= x &amp;lt;= 1,sum(x) &amp;lt;= 1];&#xA;optimize(Constraints,t) % minimizes t, subject to Constraints&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;at the successful conclusion of which, &lt;code&gt;value(x)&lt;/code&gt; is the optimal value of x.  Note that the constraint &lt;code&gt;[A ones(m,1);ones(1,m) t] &amp;gt;= 0&lt;/code&gt; denotes in YALMIP that the matrix &lt;code&gt;[A ones(m,1);ones(1,m) t]&lt;/code&gt; is constrained to be symmetric positive semidefinite. Minimizing &lt;code&gt;t&lt;/code&gt;, subject to that semidefinite constraint is the epigraph formulation previously mentioned.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2021-12-12T12:54:17.927" LastActivityDate="2021-12-12T12:54:17.927" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7321" PostTypeId="1" CreationDate="2021-11-20T11:21:18.443" Score="2" ViewCount="1391" Body="&lt;p&gt;In my bi-objective model, the range of solution value for the first objective is large than the second objective. I decide to obtain a single solution by the weighted sum approach and solve it using metaheuristics. How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="7281" LastActivityDate="2021-11-20T17:14:01.197" Title="How to normalize the objective functions of multi-objective optimization into uniform form?" Tags="|metaheuristics|multi-objective-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7322" PostTypeId="2" ParentId="7321" CreationDate="2021-11-20T17:14:01.197" Score="4" Body="&lt;p&gt;You should scale the objective functions so that they have similar size values and then weight them. (The scaling factors effectively become part of the weights.) If your metaheuristics are fast, it would be wise to try different weightings and get a few Pareto efficient solutions.&lt;/p&gt;&#xA;&lt;p&gt;There is another approach which is similar but might produce a different solution. It involves first optimizing each objective separately, again scaling them as needed to make their magnitudes comparable. If &lt;span class=&quot;math-container&quot;&gt;$z_1^*$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_2^*$&lt;/span&gt; are the optimal values of the two scaled objectives, we refer to the point &lt;span class=&quot;math-container&quot;&gt;$z^* = (z_1^*, z_2^*)\in \mathbb{R}^2$&lt;/span&gt; as the &amp;quot;utopia point&amp;quot;. The objective function for the metaheuristics is then to minimize the norm of the distance of the scaled objective values &lt;span class=&quot;math-container&quot;&gt;$(z_1, z_2)$&lt;/span&gt; from the utopia point, using your favorite norm (1-norm, 2-norm, infinity-norm).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-20T17:14:01.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7324" PostTypeId="1" CreationDate="2021-11-21T02:42:39.573" Score="7" ViewCount="705" Body="&lt;p&gt;Suppose we have a worker-assignment problem where we seek to assign Alice, Bob, Chris, ... to jobs A, B, C, ... subject to various constraints and some objective function based on these assignments, and with the following considerations:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Many employees are identical except in name. (Workers &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; considered &amp;quot;identical&amp;quot; if for every feasible solution, the allocations for worker &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; can be swapped with those for &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; without changing the feasibility or objective-function value of the solution).&lt;/li&gt;&#xA;&lt;li&gt;Similarly, many jobs are identical except in name.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Hence, there will be many optimal solutions that differ from one another only by swaps between identical entities - let's call these &amp;quot;sibling&amp;quot; solutions.&lt;/p&gt;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strike&gt;Stability/reproducibility&lt;/strike&gt; Persistence of solutions is desired. If we rerun the same problem to optimality, we want to get the exact same solution, not one of its siblings. If we make small changes to the problem and rerun, we want to change the solution by enough to achieve optimality in the new version of the problem, but no more than that.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We may wish to do this many times, without keeping records of all the old solutions.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;How can we achieve this?&lt;/p&gt;&#xA;&lt;p&gt;If it weren't for #4, one possible solution would be to add a small term to the objective function that penalises changes from previous solutions. Unfortunately this becomes impractical if we are doing a lot of runs with small changes.&lt;/p&gt;&#xA;&lt;p&gt;I have figured out one way to do this and will post as a self-answer, but I am interested in hearing others.&lt;/p&gt;&#xA;" OwnerUserId="546" LastEditorUserId="279" LastEditDate="2022-09-25T16:44:09.950" LastActivityDate="2022-09-25T16:44:09.950" Title="How to keep solutions stable/persistent in a problem with many equally good solutions?" Tags="|assignment-problem|numerical-stability|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7325" PostTypeId="2" ParentId="7324" CreationDate="2021-11-21T02:42:39.573" Score="4" Body="&lt;h2&gt;Use worker/job identifiers to reproducibly perturb the objective function&lt;/h2&gt;&#xA;&lt;p&gt;If we didn't have to deal with possible changes to the problem, we could use a standard symmetry-breaking method: use a seeded random number generator to make small changes to the objective function in a reproducible way that creates a &amp;quot;tiebreaker&amp;quot; between siblings. As well as improving reproducibility of outcomes, this can also help solver performance in some cases.&lt;/p&gt;&#xA;&lt;p&gt;In order to accommodate minor changes to the problem, we modify this slightly:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x[i,j]$&lt;/span&gt; be the binary decision variable that indicates whether worker &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Define a function &lt;span class=&quot;math-container&quot;&gt;$f(i,j)$&lt;/span&gt; which hashes the unique names (character strings) of worker &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to a numeric value between 0 and 1, in such a way that for &lt;span class=&quot;math-container&quot;&gt;$(i,j) != (k,l)$&lt;/span&gt; the probability that &lt;span class=&quot;math-container&quot;&gt;$f(i,j)=f(k,l)$&lt;/span&gt; is very small.&lt;/p&gt;&#xA;&lt;p&gt;Modify the objective function by adding a perturbation term &lt;span class=&quot;math-container&quot;&gt;$x[i,j]f(i,j)k$&lt;/span&gt; for some small constant k.&lt;/p&gt;&#xA;&lt;p&gt;Adding new workers and jobs to the problem will require generating new perturbation terms, but under this approach it doesn't change the existing terms. Hence, in allocating jobs between Alice and Bob, the relevant tiebreakers will remain the same, and hence we can expect similar outcomes (unless the new workers/jobs &lt;em&gt;require&lt;/em&gt; significant changes to Alice &amp;amp; Bob's allocations to restore optimality).&lt;/p&gt;&#xA;&lt;p&gt;As noted by Ilmari Karonen in a comment, persistence of solutions might not always be desirable:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Since you've used worker assignment as your example problem, let me note that there's a potential pitfall with your solution, and indeed with any scheme that tries to achieve your stated goal: solutions that are equivalent from your perspective may not be equivalent from the workers' perspective, and any stable tie-breaking scheme that &amp;quot;randomly&amp;quot; perturbs the job/worker objective terms can easily end up always assigning Alice to all the &amp;quot;shitty&amp;quot; jobs (or no jobs at all!) while Bob gets the &amp;quot;nice&amp;quot; jobs (at least in Alice's opinion) for no justifiable reason. Hello, discrimination lawsuit.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="546" LastEditorUserId="546" LastEditDate="2021-11-22T22:00:34.133" LastActivityDate="2021-11-22T22:00:34.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7326" PostTypeId="2" ParentId="7324" CreationDate="2021-11-21T10:16:10.583" Score="7" Body="&lt;p&gt;IMHO, the question and posted answer confuse some different issues:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Reproducibility. This is about finding the same solution when running the algorithm again with the same input, i.e. providing deterministic behavior. Algorithm developers put in quite some effort to make this happen (not completely trivial when running in multi-threaded environments, you need to design for this). As a user, we are happy to pay a performance penalty for this compared to an opportunistic parallel implementation: staying sane is more important.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Symmetry. This is a structural property of a model. It is one of the reasons we can see multiple optimal solutions. Symmetry breaking has been extensively studied in Mixed-Integer and Constraint Programming as it can have a huge impact on performance. Advanced solvers often have options to (try to) deal with symmetries (e.g. using orbital branching [&lt;a href=&quot;https://link.springer.com/article/10.1007%2Fs10107-009-0273-x&quot; rel=&quot;noreferrer&quot;&gt;Ostrowski e.a. 2011&lt;/a&gt;]). However, adding symmetry-breaking constraints at the model level is still often a good idea.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Persistence. This is about staying close to a previously found solution after changing the model/data a little bit. Obviously, only when not too expensive in terms of objective degradation. This is a well-known problem that can be handled by adding a penalty term to the objective (see e.g. &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/inte.27.5.15&quot; rel=&quot;noreferrer&quot;&gt;Brown e.a. 1997&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;These are different issues with different solutions.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2021-11-21T11:56:49.727" LastActivityDate="2021-11-21T11:56:49.727" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7327" PostTypeId="1" AcceptedAnswerId="7328" CreationDate="2021-11-21T20:32:44.897" Score="6" ViewCount="849" Body="&lt;p&gt;I'm working on an employee scheduling program in python. Having never done this before, I've been researching different libraries that can be used to accomplish the task.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, none of the examples I have been able to find for scheduling problems (for any library) seem to address one of the most common scheduling requirements - optimally scheduling breaks and lunches.&lt;/p&gt;&#xA;&lt;p&gt;My program is ultimately going to fit the &amp;quot;coffee shop scheduling&amp;quot; model found here:&#xA;&lt;a href=&quot;https://towardsdatascience.com/how-to-solve-a-staff-scheduling-problem-with-python-63ae50435ba4&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://towardsdatascience.com/how-to-solve-a-staff-scheduling-problem-with-python-63ae50435ba4&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I know how many employees I need to meet demand every hour, but it swings wildly. So I need the program to select the optimal shifts to staff, from a list of known shifts, to be able to meet all demand.&lt;/p&gt;&#xA;&lt;p&gt;For reference, number of employees needed would look something like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AxdoN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AxdoN.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;&lt;p&gt;I'd have a list of shifts to pull from, with pre-defined breaks. It's essentially a cartesian product of all acceptable shift/break/lunch combinations:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/X1bpG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/X1bpG.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;etc.,&lt;/p&gt;&#xA;&lt;p&gt;I'm sure there are a number of ways to do this, but what would be one possible way to incorporate the break/lunch schedules into PuLP, Pyomo, or Google OR-Tools? I've researched PuLP, Pyomo, and Google OR-Tools and I'm willing to use whichever library can best solve for this problem, they all seem like they can do the rest of what I need.&lt;/p&gt;&#xA;" OwnerUserId="7573" LastEditorUserId="491" LastEditDate="2022-03-01T19:23:12.703" LastActivityDate="2022-03-01T19:23:12.703" Title="Python &quot;Coffee Shop Scheduling Problem&quot; - Scheduling Lunches/Breaks" Tags="|python|scheduling|pyomo|or-tools|pulp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7328" PostTypeId="2" ParentId="7327" CreationDate="2021-11-21T22:24:19.153" Score="5" Body="&lt;p&gt;The model you linked in the question will do the job. You just set &lt;span class=&quot;math-container&quot;&gt;$a_{jt}=0$&lt;/span&gt; if a worker on shift &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; would be taking a break at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-21T22:24:19.153" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7329" PostTypeId="2" ParentId="7324" CreationDate="2021-11-22T06:04:38.750" Score="1" Body="&lt;p&gt;At the beginning of your simulations, create a seed through some random means to use for your later random engine choices. Often simply the current floating-point time is a good and sufficient choice (and trivially allows both reproducing your results and new results from the same program)&lt;/p&gt;&#xA;&lt;p&gt;With your seed selected (and recorded for later result replication!), configure your system to base from it in a structured manner whenever you have a random choice&lt;/p&gt;&#xA;&lt;p&gt;Good examples&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;broadly, choosing one of or the ordering of N to &amp;quot;go first&amp;quot; when they are otherwise equal&lt;/li&gt;&#xA;&lt;li&gt;ordering unordered workers with the same arrival times or feeding from the same queue (should Alice take precedence over Bob at the water cooler if they both arrive at the same time? which of two equal carriages driving towards a bridge should give way?)&lt;/li&gt;&#xA;&lt;li&gt;shuffling a collection of predetermined inputs which should come randomly (ie. a hat full of numbers for who goes first in an event with an equal amount of numbers as members - the value here can be somewhat dubious, but it may model a real process)&lt;/li&gt;&#xA;&lt;li&gt;which part should be chosen from a bin with known, but random identifiers&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Bad examples&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;choosing computational system result priority when two arrive together (your results are not being determined by the seed, as workers may return at different rates based upon outside values - instead, if the worker return timings could be close, you should gate and predetermine their order based upon your seed)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1300" LastEditorUserId="1300" LastEditDate="2021-11-22T16:41:56.403" LastActivityDate="2021-11-22T16:41:56.403" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7330" PostTypeId="1" CreationDate="2021-11-22T12:06:26.650" Score="3" ViewCount="140" Body="&lt;p&gt;I am looking for articles that include min-cost flow models with binary variables for flow transportation like gas networks, traffic systems, heating systems. Is there any specific place(like OR Library) where I can find all related articles? Can you share articles you know, that use min-cost flow models which implement binary variables for transportation networks?&lt;/p&gt;&#xA;" OwnerUserId="7526" LastEditorUserId="123" LastEditDate="2021-12-02T09:53:35.967" LastActivityDate="2021-12-02T09:53:35.967" Title="Sources of Min-Cost Flow Models That Utilize Binary Variables for Transportation Networks" Tags="|reference-request|combinatorial-optimization|binary-variable|network-flow|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="7331" PostTypeId="1" CreationDate="2021-11-22T14:02:54.347" Score="5" ViewCount="153" Body="&lt;p&gt;Suppose that we have a stochastic vector &lt;span class=&quot;math-container&quot;&gt;$\psi$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; realisations of &lt;span class=&quot;math-container&quot;&gt;$\psi$&lt;/span&gt; given by &lt;span class=&quot;math-container&quot;&gt;$\psi_1,\dots,\psi_S$&lt;/span&gt; with equal probability of occurrence. In addition, we have constraints of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;h_i(x,\psi)\leq b_i,\quad \forall i=1,...,m&#xA;\end{equation}&lt;/span&gt;&#xA;for the decision vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A &lt;em&gt;joint chance constraint&lt;/em&gt; is then given by&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;P(\  h_i(x,\psi)\leq b_i , \quad \forall i=1,..,m\ )\geq \alpha &#xA;\end{equation}&lt;/span&gt;&#xA;stating that we can accept that some (or all) of these constraints are violation with a probability of &lt;span class=&quot;math-container&quot;&gt;$1-\alpha$&lt;/span&gt;. We could also write &lt;em&gt;single chance constraints&lt;/em&gt; as follows&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;P(\  h_i(x,\psi)\leq b_i \ )\geq \alpha, \quad \forall i=1,..,m&#xA;\end{equation}&lt;/span&gt;&#xA;stating that we will accept violations of the individual constraints with a probability of &lt;span class=&quot;math-container&quot;&gt;$1-\alpha$&lt;/span&gt;. Using binary variables &lt;span class=&quot;math-container&quot;&gt;$z^s$&lt;/span&gt; equalling 0 &lt;em&gt;iff&lt;/em&gt; all constraints are satisfied in realisation &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, we can formulate the joint chance constraint as the MIP&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;h_i(x,\psi_s)\leq b_i+Mz^s,&amp;amp;&amp;amp;\forall i=1,...,m,s=1,...,S\\&#xA;\sum_{s=1}^Sz^s\leq \lfloor (1-\alpha)S\rfloor&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Using binary variables &lt;span class=&quot;math-container&quot;&gt;$z^s_i$&lt;/span&gt; equalling 0 &lt;em&gt;iff&lt;/em&gt; constraint &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is statisfied in realisation &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; we can formulate the single chance constraint version as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;h_i(x,\psi_s)\leq b_i+Mz^s_i,&amp;amp;&amp;amp;\forall i=1,...,m,s=1,...,S\\&#xA;&amp;amp;\sum_{s=1}^Sz^s_i\leq \lfloor (1-\alpha)S\rfloor,&amp;amp;&amp;amp;\forall i=1,...,m&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My question is, what is the interpretation of the following MIP&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;h_i(x,\psi_s)\leq b_i+Mz^s_i,&amp;amp;&amp;amp;\forall i=1,...,m,s=1,...,S\\&#xA;&amp;amp;\sum_{i=1}^m\sum_{s=1}^Sz^s_i\leq \lfloor (1-\alpha)S\rfloor&#xA;\end{align}&lt;/span&gt;&#xA;Does it have some sensible interpretation?&lt;/p&gt;&#xA;" OwnerUserId="609" LastEditorUserId="119" LastEditDate="2021-11-23T05:26:05.223" LastActivityDate="2021-11-23T05:26:05.223" Title="Chance constrained optimization - interpretation" Tags="|stochastic-programming|chance-constraints|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7332" PostTypeId="1" CreationDate="2021-11-23T20:27:04.693" Score="2" ViewCount="42" Body="&lt;p&gt;I am an MSc student, searching for an interesting topic in operations research for NP-hard problems. I need your opinion and recommendation about: &amp;quot;Searching a polynomial time approximation algorithm for the special case of facility layout problem: single row equidistant facility layout.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Regarding the literature, there is no polynomial time approximation algorithm for this problem, only heuristic, metaheuristic, and exact algorithms (solve up to n=35). My inquires are:&lt;/p&gt;&#xA;&lt;p&gt;Is this topic interesting in scientific research?&#xA;What are the most expectations of results for such an algorithm to be acceptable for publication?&#xA;Any recommendations for journals names in this scope?&lt;/p&gt;&#xA;" OwnerUserId="7538" LastActivityDate="2021-11-23T20:27:04.693" Title="Importance of Polynomial Time Approximation algorithm for special case" Tags="|reference-request|algorithms|approximation-algorithms|" AnswerCount="0" CommentCount="1" ClosedDate="2021-12-02T09:52:35.550" ContentLicense="CC BY-SA 4.0" />
  <row Id="7333" PostTypeId="1" CreationDate="2021-11-23T21:23:14.557" Score="-2" ViewCount="2313" Body="&lt;p&gt;I'm working on an optimization model in python with the pyomo library. However I'm getting an error message in python that I cannot seem to understand. The code and error message is below.&#xA;My code is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.environ import *&#xA;from pyomo.opt import SolverFactory&#xA;import json&#xA;model = ConcreteModel()&#xA;with open('C:/Users/cindy/python/Pyomo/ADMM_Distributed_Pyomo/input_data.json') as f:&#xA;    par = json.load(f)&#xA;    &#xA;# Declaro os parametros&#xA;model.P_PV         = Param(initialize = par['P_PV']) &#xA;model.P_D          = Param(initialize = par['P_D'])&#xA;model.P_SE         = Param(initialize = par['P_SE'])&#xA;model.P_ESS_max    = Param(initialize = par['P_ESS_max'])&#xA;model.E_ESS_max    = Param(initialize = par['E_ESS_max'])&#xA;model.P_load_max   = Param(initialize = par['P_load_max'])&#xA;model.E0           = Param(initialize = par['E0'])&#xA;model.delta        = Param(initialize = par['delta'])&#xA;model.custo_venda  = Param(initialize = par['custo_venda'])&#xA;model.custo_compra = Param(initialize = par['custo_compra'])&#xA;model.custo_load   = Param(initialize = par['custo_load'])&#xA;&#xA;model.rho              = Param(initialize = par['rho'])&#xA;model.epsilon          = Param(initialize = par['epsilon'])&#xA;model.iter             = Param(initialize = par['iter'])&#xA;model.tol_lambda       = Param(initialize = par['tol_lambda'])&#xA;model.tol_var          = Param(initialize = par['tol_var'])&#xA;&#xA;model.P_SE_in_1_param  = Param(initialize = par['P_SE_in_1_param'])&#xA;model.P_SE_out_1_param = Param(initialize = par['P_SE_out_1_param'])&#xA;model.P_ESS_1_param    = Param(initialize = par['P_ESS_1_param'])    &#xA;model.E_ESS_1_param    = Param(initialize = par['E_ESS_1_param'])&#xA;model.P_load_1_param   = Param(initialize = par['P_load_1_param'])&#xA;model.P_SE_in_2_param  = Param(initialize = par['P_SE_in_2_param'])&#xA;model.P_SE_out_2_param = Param(initialize = par['P_SE_out_2_param'])&#xA;model.P_ESS_2_param    = Param(initialize = par['P_ESS_2_param'])&#xA;model.E_ESS_2_param    = Param(initialize = par['E_ESS_2_param'])&#xA;model.P_load_2_param   = Param(initialize = par['P_load_2_param'])&#xA;model.P_SE_in_3_param  = Param(initialize = par['P_SE_in_3_param'])&#xA;model.P_SE_out_3_param = Param(initialize = par['P_SE_out_3_param'])&#xA;model.P_ESS_3_param    = Param(initialize = par['P_ESS_3_param'])&#xA;model.E_ESS_3_param    = Param(initialize = par['E_ESS_3_param'])&#xA;model.P_load_3_param   = Param(initialize = par['P_load_3_param'])&#xA;&#xA;model.lambda_P_SE_in_a      = Param(initialize = par['lambda_P_SE_in_a'])   &#xA;model.lambda_P_SE_out_a     = Param(initialize = par['lambda_P_SE_out_a'])  &#xA;model.lambda_P_ESS_a        = Param(initialize = par['lambda_P_ESS_a']) &#xA;model.lambda_E_ESS_a        = Param(initialize = par['lambda_E_ESS_a'])     &#xA;model.lambda_P_load_a       = Param(initialize = par['lambda_P_load_a'])    &#xA;model.lambda_P_SE_in_b      = Param(initialize = par['lambda_P_SE_in_b'])&#xA;model.lambda_P_SE_out_b     = Param(initialize = par['lambda_P_SE_out_b'])&#xA;model.lambda_P_ESS_b        = Param(initialize = par['lambda_P_ESS_b']) &#xA;model.lambda_E_ESS_b        = Param(initialize = par['lambda_E_ESS_b']) &#xA;model.lambda_P_load_b       = Param(initialize = par['lambda_P_load_b']) &#xA;model.lambda_P_SE_in_a_ant  = Param(initialize = par['lambda_P_SE_in_a_ant'])   &#xA;model.lambda_P_SE_out_a_ant = Param(initialize = par['lambda_P_SE_out_a_ant'])  &#xA;model.lambda_P_ESS_a_ant    = Param(initialize = par['lambda_P_ESS_a_ant']) &#xA;model.lambda_E_ESS_a_ant    = Param(initialize = par['lambda_E_ESS_a_ant']) &#xA;model.lambda_P_load_a_ant   = Param(initialize = par['lambda_P_load_a_ant'])    &#xA;model.lambda_P_SE_in_b_ant  = Param(initialize = par['lambda_P_SE_in_b_ant'])   &#xA;model.lambda_P_SE_out_b_ant = Param(initialize = par['lambda_P_SE_out_b_ant'])  &#xA;model.lambda_P_ESS_b_ant    = Param(initialize = par['lambda_P_ESS_b_ant']) &#xA;model.lambda_E_ESS_b_ant    = Param(initialize = par['lambda_E_ESS_b_ant']) &#xA;model.lambda_P_load_b_ant   = Param(initialize = par['lambda_P_load_b_ant'])    &#xA;&#xA;&#xA;#Declaracao das variaveis &#xA;model.P_SE_in_1    = Var(bounds = (0,None),within=NonNegativeReals) #Potência importada 1&#xA;model.P_SE_out_1   = Var(bounds = (0,None),within=NonNegativeReals) #Potência vendida 1&#xA;model.P_ESS_1      = Var(bounds = (None,None)) #Potência do BESS 1&#xA;model.E_ESS_1      = Var(bounds = (0,None),within=NonNegativeReals) #Energia do BESS 1&#xA;model.P_load_1     = Var(bounds = (0,None),within=NonNegativeReals) #Potência da carga controlada 1&#xA;model.P_SE_in_2    = Var(bounds = (0,None),within=NonNegativeReals) #Potência importada 2&#xA;model.P_SE_out_2   = Var(bounds = (0,None),within=NonNegativeReals)#Potência vendida 2&#xA;model.P_ESS_2      = Var(bounds = (None,None))#Potência do BESS 2&#xA;model.E_ESS_2      = Var(bounds = (0,None),within=NonNegativeReals)#Energia do BESS 2&#xA;model.P_load_2     = Var(bounds = (0,None),within=NonNegativeReals)#Potência da carga controlada 2&#xA;model.P_SE_in_3    = Var(bounds = (0,None),within=NonNegativeReals)#Potência importada 3&#xA;model.P_SE_out_3   = Var(bounds = (0,None),within=NonNegativeReals)#Potência vendida 3&#xA;model.P_ESS_3      = Var(bounds = (None,None))#Potência do BESS 3&#xA;model.E_ESS_3      = Var(bounds = (0,None),within=NonNegativeReals)#Energia do BESS 3&#xA;model.P_load_3     = Var(bounds = (0,None),within=NonNegativeReals)#Potência da carga controlada 3&#xA;&#xA;#Declaro as funçoes objetivo&#xA;&#xA;#Declaro a FO1&#xA;model.obj1 = Objective(expr = model.delta * model.custo_compra * model.P_SE_in_1 &#xA;- model.delta * model.custo_venda * model.P_SE_out_1 + model.delta * model.custo_load*(model.P_load_max - model.P_load_3_param) &#xA;+ model.lambda_P_SE_in_a*(model.P_SE_in_1 - model.P_SE_in_2_param) + model.rho/2*(model.P_SE_in_1 - model.P_SE_in_2_param)**2&#xA;+ model.lambda_P_SE_out_a*(model.P_SE_out_1 - model.P_SE_out_2_param) + model.rho/2*(model.P_SE_out_1 - model.P_SE_out_2_param)**2 &#xA;+ model.lambda_P_ESS_a*(model.P_ESS_1 - model.P_ESS_2_param) + model.rho/2*(model.P_ESS_1 - model.P_ESS_2_param)**2 &#xA;+ model.lambda_E_ESS_a*(model.E_ESS_1 - model.E_ESS_2_param) + model.rho/2*(model.E_ESS_1 - model.E_ESS_2_param)**2 &#xA;+ model.lambda_P_load_a*(model.P_load_1 - model.P_load_2_param) + model.rho/2*(model.P_load_1 - model.P_load_2_param)**2 &#xA;+ model.lambda_P_SE_in_b*(model.P_SE_in_1 - model.P_SE_in_3_param) + model.rho/2*(model.P_SE_in_1 - model.P_SE_in_3_param)**2 &#xA;+ model.lambda_P_SE_out_b*(model.P_SE_out_1 - model.P_SE_out_3_param) + model.rho/2*(model.P_SE_out_1 - model.P_SE_out_3_param)**2 &#xA;+ model.lambda_P_ESS_b*(model.P_ESS_1 - model.P_ESS_3_param) + model.rho/2*(model.P_ESS_1 - model.P_ESS_3_param)**2 &#xA;+ model.lambda_E_ESS_b*(model.E_ESS_1 - model.E_ESS_3_param) + model.rho/2*(model.E_ESS_1 - model.E_ESS_3_param)**2 &#xA;+ model.lambda_P_load_b*(model.P_load_1 - model.P_load_3_param) + model.rho/2*(model.P_load_1 - model.P_load_3_param)**2)&#xA;&#xA;#Declaro as restricões da FO1&#xA;model.r1 = Constraint(expr = model.P_SE_in_1 + model.P_PV == model.P_ESS_1 + model.P_D + model.P_SE_out_1 + model.P_load_1)&#xA;model.r2 = Constraint(expr = model.P_SE_in_1 &amp;lt;= model.P_SE)&#xA;model.r3 = Constraint(expr = model.P_SE_out_1 &amp;lt;= model.P_SE)&#xA;&#xA;&#xA;#Declaro a FO2&#xA;model.obj2 = Objective(expr = model.lambda_P_SE_in_a*(model.P_SE_in_1_param - model.P_SE_in_2) &#xA;+ model.rho/2*(model.P_SE_in_1_param - model.P_SE_in_2)**2 &#xA;+ model.lambda_P_SE_out_a*(model.P_SE_out_1_param - model.P_SE_out_2) + model.rho/2*(model.P_SE_out_1_param - model.P_SE_out_2)**2 &#xA;+ model.lambda_P_ESS_a*(model.P_ESS_1_param - model.P_ESS_2) + model.rho/2*(model.P_ESS_1_param - model.P_ESS_2)**2 &#xA;+ model.lambda_E_ESS_a*(model.E_ESS_1_param - model.E_ESS_2) + model.rho/2*(model.E_ESS_1_param - model.E_ESS_2)**2 &#xA;+ model.lambda_P_load_a*(model.P_load_1_param - model.P_load_2) + model.rho/2*(model.P_load_1_param - model.P_load_2)**2)&#xA;&#xA;#Declaro as restricões da FO2&#xA;model.r5 = Constraint(expr = model.E_ESS_2 == model.E0 + model.delta * model.P_ESS_2)&#xA;model.r6 = Constraint(expr = -1*model.P_ESS_max &amp;lt;= model.P_ESS_2)&#xA;model.r7 = Constraint(expr = model.P_ESS_2 &amp;lt;= model.P_ESS_max)&#xA;model.r8 = Constraint(expr = model.E_ESS_2 &amp;lt;= model.E_ESS_max)&#xA;&#xA;&#xA;#Declaro a FO3&#xA;model.obj3 = Objective(expr = model.delta * model.custo_load *(model.P_load_max - model.P_load_3)&#xA;+ model.lambda_P_SE_in_b*(model.P_SE_in_1_param - model.P_SE_in_3) + model.rho/2*(model.P_SE_in_1_param - model.P_SE_in_3)**2 &#xA;+ model.lambda_P_SE_out_b*(model.P_SE_out_1_param - model.P_SE_out_3) +model.rho/2*(model.P_SE_out_1_param - model.P_SE_out_3)**2 &#xA;+ model.lambda_P_ESS_b*(model.P_ESS_1_param - model.P_ESS_3) + model.rho/2*(model.P_ESS_1_param - model.P_ESS_3)**2 &#xA;+ model.lambda_E_ESS_b*(model.E_ESS_1_param - model.E_ESS_3) + model.rho/2*(model.E_ESS_1_param - model.E_ESS_3)**2 &#xA;+ model.lambda_P_load_b*(model.P_load_1_param - model.P_load_3) + model.rho/2*(model.P_load_1_param - model.P_load_3)**2)&#xA;&#xA;#Declaro as restricões da FO3&#xA;model.r4 = Constraint(expr = model.P_load_3 &amp;lt;= model.P_load_max)&#xA;&#xA;&#xA;#Problem solution &#xA;while model.tol_lambda &amp;gt; 10e5 and model.tol_var &amp;gt; 10e5 :&#xA;    model.lambda_P_SE_in_a_ant          =   model.lambda_P_SE_in_a      &#xA;    model.lambda_P_SE_out_a_ant         =   model.lambda_P_SE_out_a     &#xA;    model.lambda_P_ESS_a_ant            =   model.lambda_P_ESS_a        &#xA;    model.lambda_E_ESS_a_ant            =   model.lambda_E_ESS_a        &#xA;    model.lambda_P_load_a_ant           =   model.lambda_P_load_a       &#xA;    model.lambda_P_SE_in_b_ant          =   model.lambda_P_SE_in_b      &#xA;    model.lambda_P_SE_out_b_ant         =   model.lambda_P_SE_out_b     &#xA;    model.lambda_P_ESS_b_ant            =   model.lambda_P_ESS_b    &#xA;    model.lambda_E_ESS_b_ant            =   model.lambda_E_ESS_b        &#xA;    model.lambda_P_load_b_ant           =   model.lambda_P_load_b&#xA;    &#xA;    #Solucao da FO1&#xA;    opt = SolverFactory('glpk')&#xA;    model.obj1.activate()&#xA;    model.obj2.deactivate()&#xA;    model.obj3.deactivate()&#xA;    results = opt.solve(model)&#xA;    model.P_SE_in_1_param     == model.P_SE_in_1&#xA;    model.P_SE_out_1_param    == model.P_SE_out_1&#xA;    model.P_ESS_1_param       == model.P_ESS_1&#xA;    model.E_ESS_1_param       == model.E_ESS_1  &#xA;    model.P_load_1_param      == model.P_load_1&#xA;&#xA;    #Solucao da FO2&#xA;    '''&#xA;    opt = SolverFactory('glpk')&#xA;    model.obj1.deactivate()&#xA;    model.obj3.deactivate()&#xA;    results = opt.solve(model)&#xA;    '''&#xA;    model.P_SE_in_2_param     == model.P_SE_in_2&#xA;    model.P_SE_out_2_param    == model.P_SE_out_2&#xA;    model.P_ESS_2_param       == model.P_ESS_2&#xA;    model.E_ESS_2_param       == model.E_ESS_2&#xA;    model.P_load_2_param      == model.P_load_2&#xA;&#xA;    #Solucao da FO3&#xA;    '''&#xA;    opt = SolverFactory('glpk')&#xA;    model.obj1.deactivate()&#xA;    model.obj2.deactivate()&#xA;    results = opt.solve(model)&#xA;    '''&#xA;    model.P_SE_in_3_param     == model.P_SE_in_3 &#xA;    model.P_SE_out_3_param    == model.P_SE_out_3&#xA;    model.P_ESS_3_param       == model.P_ESS_3&#xA;    model.E_ESS_3_param       == model.E_ESS_3&#xA;    model.P_load_3_param      == model.P_load_3&#xA;    &#xA;&#xA;    #atualizacao variavel dual&#xA;    model.lambda_P_SE_in_a      = model.lambda_P_SE_in_a_ant    + model.rho * (model.P_SE_in_1_param - model.P_SE_in_2_param)&#xA;    model.lambda_P_SE_out_a     = model.lambda_P_SE_out_a_ant   + model.rho * (model.P_SE_out_1_param - model.P_SE_out_2_param)&#xA;    model.lambda_P_ESS_a        = model.lambda_P_ESS_a_ant      + model.rho * (model.P_ESS_1_param - model.P_ESS_2_param)   &#xA;    model.lambda_E_ESS_a        = model.lambda_E_ESS_a_ant      + model.rho * (model.E_ESS_1_param - model.E_ESS_2_param)   &#xA;    model.lambda_P_load_a       = model.lambda_P_load_a_ant     + model.rho * (model.P_load_1_param - model.P_load_2_param) &#xA;    model.lambda_P_SE_in_b      = model.lambda_P_SE_in_b_ant    + model.rho * (model.P_SE_in_1_param - model.P_SE_in_3_param)   &#xA;    model.lambda_P_SE_out_b     = model.lambda_P_SE_out_b_ant   + model.rho * (model.P_SE_out_1_param - model.P_SE_out_3_param) &#xA;    model.lambda_P_ESS_b        = model.lambda_P_ESS_b_ant      + model.rho * (model.P_ESS_1_param - model.P_ESS_3_param)   &#xA;    model.lambda_E_ESS_b        = model.lambda_E_ESS_b_ant      + model.rho * (model.E_ESS_1_param - model.E_ESS_3_param)   &#xA;    model.lambda_P_load_b       = model.lambda_P_load_b_ant     + model.rho * (model.P_load_1_param - model.P_load_3_param) &#xA;&#xA;    # Calcula os critérios de parada&#xA;    model.tol_var = abs(model.P_SE_in_1_param - model.P_SE_in_2_param) &#xA;    + abs(model.P_SE_out_1_param - model.P_SE_out_2_param)&#xA;    + abs(model.P_ESS_1_param - model.P_ESS_2_param) &#xA;    + abs(model.E_ESS_1_param - model.E_ESS_2_param) &#xA;    + abs(model.P_load_1_param - model.P_load_2_param)&#xA;    + abs(model.P_SE_in_1_param - model.P_SE_in_3_param) &#xA;    + abs(model.P_SE_out_1_param - model.P_SE_out_3_param)&#xA;    + abs(model.P_ESS_1_param - model.P_ESS_3_param) &#xA;    + abs(model.E_ESS_1_param - model.E_ESS_3_param) &#xA;    + abs(model.P_load_1_param - model.P_load_3_param)&#xA;    &#xA;    model.tol_lambda = abs(model.lambda_P_SE_in_a - model.lambda_P_SE_in_a_ant) &#xA;    + abs(model.lambda_P_SE_out_a - model.lambda_P_SE_out_a_ant) &#xA;    + abs(model.lambda_P_ESS_a - model.lambda_P_ESS_a_ant) &#xA;    + abs(model.lambda_E_ESS_a - model.lambda_E_ESS_a_ant) &#xA;    + abs(model.lambda_P_load_a - model.lambda_P_load_a_ant)&#xA;    + abs(model.lambda_P_SE_in_b - model.lambda_P_SE_in_b_ant) &#xA;    + abs(model.lambda_P_SE_out_b   - model.lambda_P_SE_out_b_ant) &#xA;    + abs(model.lambda_P_ESS_b - model.lambda_P_ESS_b_ant) &#xA;    + abs(model.lambda_E_ESS_b - model.lambda_E_ESS_b_ant) &#xA;    + abs(model.lambda_P_load_b - model.lambda_P_load_b_ant)&#xA;&#xA;    iter = iter + 1,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The error is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ERROR: evaluating object as numeric value: P_SE_in_1&#xA;        (object: &amp;lt;class 'pyomo.core.base.var.ScalarVar'&amp;gt;)&#xA;    No value for uninitialized NumericValue object P_SE_in_1&#xA;Traceback (most recent call last):&#xA;  File &amp;quot;C:\Users\cindy\python\Pyomo\ADMM_Distributed_Pyomo\ADMM_Distributed_Pyomo.py&amp;quot;, line 218, in &amp;lt;module&amp;gt;&#xA;    FO1 = model.obj1.expr()&#xA;  File &amp;quot;pyomo\core\expr\numeric_expr.pyx&amp;quot;, line 218, in pyomo.core.expr.numeric_expr.ExpressionBase.__call__&#xA;  File &amp;quot;C:\Users\cindy\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyomo\core\expr\visitor.py&amp;quot;, line 1045, in evaluate_expression&#xA;    return visitor.dfs_postorder_stack(exp)&#xA;  File &amp;quot;C:\Users\cindy\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyomo\core\expr\visitor.py&amp;quot;, line 572, in dfs_postorder_stack&#xA;    flag, value = self.visiting_potential_leaf(_sub)&#xA;  File &amp;quot;C:\Users\cindy\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyomo\core\expr\visitor.py&amp;quot;, line 953, in visiting_potential_leaf&#xA;    return True, value(node, exception=self.exception)&#xA;  File &amp;quot;pyomo\core\expr\numvalue.pyx&amp;quot;, line 156, in pyomo.core.expr.numvalue.value&#xA;  File &amp;quot;pyomo\core\expr\numvalue.pyx&amp;quot;, line 143, in pyomo.core.expr.numvalue.value&#xA;ValueError: No value for uninitialized NumericValue object P_SE_in_1&#xA;PS C:\Users\cindy\python\Pyomo\ADMM_Distributed_Pyomo&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7581" LastEditorUserId="491" LastEditDate="2021-11-26T21:33:15.490" LastActivityDate="2021-11-26T21:33:31.090" Title="No value for uninitialized NumericValue object" Tags="|optimization|python|nonlinear-programming|pyomo|error-bounds|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7334" PostTypeId="1" CreationDate="2021-11-24T02:13:03.847" Score="7" ViewCount="193" Body="&lt;p&gt;I have a network design problem with complicating capacity constraints which I'm trying to model through a Mixed Integer Programming formulation.&lt;/p&gt;&#xA;&lt;p&gt;The problem is defined on a directed, incomplete graph &lt;span class=&quot;math-container&quot;&gt;$G(V,A)$&lt;/span&gt;. A binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{uv}^k$&lt;/span&gt; defines whether commodity &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt; is routed via arc &lt;span class=&quot;math-container&quot;&gt;$(u,v)\in A$&lt;/span&gt;. Parameter &lt;span class=&quot;math-container&quot;&gt;$q_k\in \mathbb{R}_{&amp;gt;0}$&lt;/span&gt; defines the volume of commodity &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt;. For a subset of nodes &lt;span class=&quot;math-container&quot;&gt;$U\subset V$&lt;/span&gt;, I have the following capacity constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; \sum_{v:(u,v)\in A}\Big\lceil \sum_{k\in K}q_kx_{uv}^k\Big\rceil_{\ell}\leq Q_u &amp;amp; \forall u\in U&#xA;\end{align}&lt;/span&gt;&#xA;Here, &lt;span class=&quot;math-container&quot;&gt;$Q_u$&lt;/span&gt; is the capacity of node &lt;span class=&quot;math-container&quot;&gt;$u\in U$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\lceil\cdot\rceil_{\ell}$&lt;/span&gt; is a rounding operator that rounds &lt;strong&gt;up&lt;/strong&gt; to the nearest multiple of &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt;. In my application, &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; can take the values &lt;span class=&quot;math-container&quot;&gt;$0.5$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The rounding operation makes it troublesome to formulate this constraint. In order to model this, I could associate non-negative &lt;strong&gt;integer&lt;/strong&gt; helper variables &lt;span class=&quot;math-container&quot;&gt;$p_{uv}\in \mathbb{Z}_{\geq 0}$&lt;/span&gt; with all arcs &lt;span class=&quot;math-container&quot;&gt;$(u,v)\in A$&lt;/span&gt;, and then state the following two constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; \sum_{v:(u,v)\in A}p_{uv}\leq \frac{1}{\ell}Q_u &amp;amp; \forall u\in U\\&#xA;&amp;amp; \frac{1}{\ell}\sum_{k\in K}q_kx_{uv}^k\leq p_{uv} &amp;amp; \forall (u,v)\in A&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Although these constraint work in theory, in practice they hinder the scalability of my model. Now I could simply drop the rounding operator and approximate the capacity constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; \sum_{v:(u,v)\in A} \sum_{k\in K}q_kx_{uv}^k\leq Q_u &amp;amp; \forall u\in U&#xA;\end{align}&lt;/span&gt;&#xA;but this creates significant capacity deviations. Here's a simple numerical example. Imagine a node &lt;span class=&quot;math-container&quot;&gt;$u\in U$&lt;/span&gt; with 10 arcs emanating from this node. When we evaluate the term &lt;span class=&quot;math-container&quot;&gt;$\sum_{k\in K}q_kx_{uv}^k$&lt;/span&gt; for each of these 10 arcs, we find the values: &lt;span class=&quot;math-container&quot;&gt;$4.04,0.2,0.2,\dots,0.2$&lt;/span&gt;. If we were to evaluate the left hand side of the capacity constraint with &lt;span class=&quot;math-container&quot;&gt;$\ell=0.5$&lt;/span&gt;, we find: &lt;span class=&quot;math-container&quot;&gt;$4.5+0.5+0.5+\dots+0.5=9$&lt;/span&gt;. Without the rounding operator, we would get &lt;span class=&quot;math-container&quot;&gt;$4.04+0.2+0.2+\dots+0.2=5.84$&lt;/span&gt; which is a significant underestimation. This deviation becomes worse when the number of arcs and commodities increases or when &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; is set to 1.&lt;/p&gt;&#xA;&lt;p&gt;Is there a better way to model these capacity constraints? This is an industrial application: I wouldn't mind to over or underestimate the exact capacity by some margin if this would improve scalability of the model.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="2556" LastEditDate="2021-11-24T08:51:55.970" LastActivityDate="2022-12-06T20:01:42.737" Title="Network design problem with rounded capacity constraints" Tags="|mixed-integer-programming|modeling|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7335" PostTypeId="2" ParentId="7333" CreationDate="2021-11-24T04:40:16.710" Score="2" Body="&lt;p&gt;I can't see the error in your question. First of all, please include the error message as well. Second, if you try to solve a nonlinear (from the tags that you mention) glpk is not a good idea. You may use ipopt if all variables are continuous. Third (again from the tags), you don't need to define bound on your variables if use &lt;code&gt;whitin&lt;/code&gt; and you don't have an upper bound.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-11-24T04:40:16.710" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7336" PostTypeId="1" AcceptedAnswerId="7337" CreationDate="2021-11-24T15:03:44.277" Score="3" ViewCount="310" Body="&lt;p&gt;I think its easiest to describe my goal first and continue with my implementation and the resulting problems!&lt;/p&gt;&#xA;&lt;p&gt;My goal:&#xA;Using Pyomo as interface and Gurobi as solver, if a variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,t}$&lt;/span&gt; falls below a certain value &lt;span class=&quot;math-container&quot;&gt;$b_{i,t}$&lt;/span&gt; the deviation to given threshold shall be added to the objective, but only if it is below. &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; denotes a state inside a state space representation and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; the current time step. So my objective should describe something like&#xA;&lt;span class=&quot;math-container&quot;&gt;$$J=\sum_i^S\sum_t^T(\mathrm{if}\, x_{i,t}&amp;lt;b_{i,t}:b_{i,t}-x_{i,t}, \mathrm{else}\,0).$$&lt;/span&gt;&#xA;So it is comparable to a ReLU activation function&lt;/p&gt;&#xA;&lt;p&gt;My Implementation/Problem:&#xA;I tried implementing a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,t}\in\{0;1\}$&lt;/span&gt; using BigM method&#xA;&lt;span class=&quot;math-container&quot;&gt;$$b_{i,t}-x_{i,t}\le My_{i,t}$$&lt;/span&gt;&#xA;and describing&#xA;&lt;span class=&quot;math-container&quot;&gt;$$J=\sum_i^S\sum_t^Ty_{i,t}\cdot(b_{i,t} - x_{i,j}).$$&lt;/span&gt;&#xA;The problem is if &lt;span class=&quot;math-container&quot;&gt;$x_{i,t}$&lt;/span&gt; is above the threshold the optimizer also sets &lt;span class=&quot;math-container&quot;&gt;$y_{i,t}=1$&lt;/span&gt; since this allows for negative objective terms, which minimizes the objective but is not what I intended.&lt;/p&gt;&#xA;&lt;p&gt;Is there any way on how to implement this? In addition, later I want to implement the same just with an upper threshold. Both of these thresholds should be usable independently of each other (only the upper or only the lower), but also in combination with each other, creating a band where no objective is added (this is probably just an summation of both onbjectives).&lt;/p&gt;&#xA;&lt;p&gt;Maybe as an additional note, I should mention that &lt;span class=&quot;math-container&quot;&gt;$x_{i,t+1}$&lt;/span&gt; is calculated using Pyomo DAE based on its differential &lt;span class=&quot;math-container&quot;&gt;$\dot{x}_{i,t}$&lt;/span&gt;, the systems input &lt;span class=&quot;math-container&quot;&gt;$u_{j,t}$&lt;/span&gt; and the internal integration scheme of Pyomo DAE (so basically a state stace). The first value &lt;span class=&quot;math-container&quot;&gt;$x_{i,0}$&lt;/span&gt; is fixed via an equality constraint so the optimizer can only really manipulate &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; since the differential at a given time step &lt;span class=&quot;math-container&quot;&gt;$\dot{x}_{i,t}$&lt;/span&gt; is calculated via the current values of &lt;span class=&quot;math-container&quot;&gt;$x_{i,t}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u_{j,t}$&lt;/span&gt;. Both &lt;span class=&quot;math-container&quot;&gt;$x_{i,t}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u_{j,t}$&lt;/span&gt; are bounded but not necessarily &lt;span class=&quot;math-container&quot;&gt;$\ge 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7594" LastEditorUserId="500" LastEditDate="2021-11-24T17:16:11.307" LastActivityDate="2021-11-24T17:16:11.307" Title="If variable falls below a certain value, include difference to set value in objective" Tags="|optimization|mixed-integer-programming|linear-programming|linearization|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7337" PostTypeId="2" ParentId="7336" CreationDate="2021-11-24T15:11:05.917" Score="5" Body="&lt;p&gt;You want to minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i^S\sum_t^T \max(b_{i,t}-x_{i,t}, 0).$$&lt;/span&gt;&#xA;You can do that linearly by introducing a nonnegative variable &lt;span class=&quot;math-container&quot;&gt;$z_{i,t}$&lt;/span&gt;&#xA;and minimizing&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i^S\sum_t^T z_{i,t}$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_{i,t} \ge b_{i,t}-x_{i,t} \quad \text{for all $i$ and $t$}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;More generally, to penalize violation of &lt;span class=&quot;math-container&quot;&gt;$\ell_i \le x_i \le u_i$&lt;/span&gt;, you can introduce nonnegative surplus and slack variables &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt;, respectively, and minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_i (s_i+t_i)$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\ell_i \le x_i - s_i + t_i \le u_i$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-11-24T17:10:35.307" LastActivityDate="2021-11-24T17:10:35.307" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7338" PostTypeId="1" CreationDate="2021-11-24T17:40:49.810" Score="2" ViewCount="133" Body="&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Given rectangular matrices &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; and vectors &lt;span class=&quot;math-container&quot;&gt;$\vec{a}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\vec{b}$&lt;/span&gt;, how to check if there exists an &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt; that satisfies the following conditions?&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\vec{x} \succcurlyeq \vec{0}$&lt;/span&gt; is true.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$A\vec{x} \succcurlyeq \vec{a}$&lt;/span&gt; is true.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$B\vec{x} \succcurlyeq \vec{b}$&lt;/span&gt; is false.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;For vectors &lt;span class=&quot;math-container&quot;&gt;$\vec{u}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\vec{v}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\vec{u} \succcurlyeq \vec{v}$&lt;/span&gt; means:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The vectors have the same number of elements.&lt;/li&gt;&#xA;&lt;li&gt;For all i, the i&lt;sup&gt;th&lt;/sup&gt; elements of the vectors satisfy &lt;span class=&quot;math-container&quot;&gt;$u_i &amp;gt; v_i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I can't use &lt;span class=&quot;math-container&quot;&gt;$B\vec{x} \preccurlyeq \vec{b}$&lt;/span&gt; because &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt; only have to violate at least 1 inequalities among all inequalities represented by &lt;span class=&quot;math-container&quot;&gt;$B\vec{x} \succcurlyeq \vec{b}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Each problem has about 100 variables and 150 inequalities. I want to solve at least 10,000 problems per minute on a laptop. All of the problems share a large number of inequalities.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Ideas&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Define two problems:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$P_{A}$&lt;/span&gt; means &lt;span class=&quot;math-container&quot;&gt;$\vec{x} \succcurlyeq \vec{0}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A\vec{x} \succcurlyeq \vec{a}$&lt;/span&gt; are true.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$P_{B}$&lt;/span&gt; means &lt;span class=&quot;math-container&quot;&gt;$\vec{x} \succcurlyeq \vec{0}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B\vec{x} \succcurlyeq \vec{b}$&lt;/span&gt; are true.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If I remember correctly, I think:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vectors that satisfies &lt;span class=&quot;math-container&quot;&gt;$P_{A}$&lt;/span&gt; are the convex combinations of the vertex set &lt;span class=&quot;math-container&quot;&gt;$V_{A}$&lt;/span&gt;.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The vectors in &lt;span class=&quot;math-container&quot;&gt;$V_A$&lt;/span&gt; form a matrix &lt;span class=&quot;math-container&quot;&gt;$M_{A}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The convex combinations form a convex set &lt;span class=&quot;math-container&quot;&gt;$S_{A}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Vectors that satisfies &lt;span class=&quot;math-container&quot;&gt;$P_{B}$&lt;/span&gt; are the convex combinations of the vertex set &lt;span class=&quot;math-container&quot;&gt;$V_{B}$&lt;/span&gt;.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The vectors in &lt;span class=&quot;math-container&quot;&gt;$V_B$&lt;/span&gt; form a matrix &lt;span class=&quot;math-container&quot;&gt;$M_{B}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The convex combinations form a convex set &lt;span class=&quot;math-container&quot;&gt;$S_{B}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Intersection of two convex sets is convex.&lt;/li&gt;&#xA;&lt;li&gt;Difference of two convex sets is not necessarily convex.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Idea 2&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The problem is equivalent to showing if &lt;span class=&quot;math-container&quot;&gt;$S_{A}$&lt;/span&gt; is not a subset of &lt;span class=&quot;math-container&quot;&gt;$S_{B}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;I think the problem is also equivalent to showing if there exists a vertex &lt;span class=&quot;math-container&quot;&gt;$\vec{\alpha} \in V_A$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\vec{\alpha}$&lt;/span&gt; is not a convex combination of &lt;span class=&quot;math-container&quot;&gt;$V_B$&lt;/span&gt;. That means &lt;span class=&quot;math-container&quot;&gt;$M_{B}\vec{u} = \vec{\alpha}$&lt;/span&gt; either has no solution or &lt;span class=&quot;math-container&quot;&gt;$\vec{u}\cdot\vec{1} \ne 1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I don't know how to find the vertexes. And there are potentially so many vertexes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Idea 3&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Start from an old problem without such a &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;By comparing the new &lt;span class=&quot;math-container&quot;&gt;$P_{B}$&lt;/span&gt; and old &lt;span class=&quot;math-container&quot;&gt;$P_{B}$&lt;/span&gt;, we can identify the new cuts.&lt;/li&gt;&#xA;&lt;li&gt;Invert the comparison in the new cuts. (&lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Check if each new inverted cut is compatible with the new &lt;span class=&quot;math-container&quot;&gt;$P_{A}$&lt;/span&gt;.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For each inverted new cut, add the inverted new cut to the new &lt;span class=&quot;math-container&quot;&gt;$P_A$&lt;/span&gt;. If simplex algorithm says the combined problem is feasible, the new inverted cut is compatible with the new &lt;span class=&quot;math-container&quot;&gt;$P_A$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;The new problem has such a &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt; if and only if we find a new inverted cut that is incompatible with the new &lt;span class=&quot;math-container&quot;&gt;$P_{A}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;That would be at most 60 runs of simplex per problem.&#xA;The method caches the inequalities instead of the vertices.&lt;/p&gt;&#xA;&lt;p&gt;I don't need the solution and only need to know if the new inverted cut is compatible with the existing cuts. Is there a faster way to get this?&lt;/p&gt;&#xA;" OwnerUserId="6094" LastEditorUserId="6094" LastEditDate="2021-11-24T19:40:11.627" LastActivityDate="2021-11-24T19:40:11.627" Title="Check if there exists a vector that satisfies a set of inequalities but violates another set of inequalities" Tags="|linear-programming|algorithms|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7339" PostTypeId="2" ParentId="7318" CreationDate="2021-11-24T17:48:22.957" Score="2" Body="&lt;p&gt;You can consider aggregating demand by grouping some SKU's (group that makes more business sense) and by which you can have more points for a group. You can train (though data seems less) and then forecast output &amp;amp; later post-process it by splitting them across individual SKUs based on some business rule/logic.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2021-11-24T17:48:22.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7340" PostTypeId="2" ParentId="7338" CreationDate="2021-11-24T18:34:36.573" Score="2" Body="&lt;p&gt;I am assuming your notation means &lt;span class=&quot;math-container&quot;&gt;$u_i \ge v_i$&lt;/span&gt; rather than &lt;span class=&quot;math-container&quot;&gt;$u_i &amp;gt; v_i$&lt;/span&gt;. Strict inequalities are somewhat problematic here.&lt;/p&gt;&#xA;&lt;p&gt;First comment: Regardless of how you end up modeling this, I would be very surprised if you could solve 10,000 instances per minute on a laptop, even if consecutive instances have considerable commonality.&lt;/p&gt;&#xA;&lt;p&gt;Second comment: For statement 3 to be false, there must be an index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$B^{(i)} x &amp;lt; b_i$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$B^{(i)}$&lt;/span&gt; denotes the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th row of &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;. In practice, strict inequalities likely cannot be handled (especially if you end up solving an optimization problem), so you will almost certainly have to introduce a tolerance &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; and change statement 3 to &lt;span class=&quot;math-container&quot;&gt;$B^{(i)}x \le b_i - \epsilon$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Third comment: Unless you know that the feasible regions of &lt;span class=&quot;math-container&quot;&gt;$P_A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_B$&lt;/span&gt; are bounded, the correct statement is that a point in either one is the sum of a convex combination of vertices and nonnegative combination of rays (extreme directions).&lt;/p&gt;&#xA;&lt;p&gt;Fourth comment: Identifying all vertices (and rays) of a polyhedron can be computationally expensive ... plus, for condition 3, you would need to show that the chosen &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; cannot be expressed in terms of vertices and rays, which would be tricky.&lt;/p&gt;&#xA;&lt;p&gt;Last comment: You can model this as a mixed integer linear program (though I'd be even more certain that 10K solutions per minute would be off the table). Introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; with the same dimension as the number of rows in &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;. The feasible region for your problem is defined by &lt;span class=&quot;math-container&quot;&gt;$$x\ge 0$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$Ax\ge a$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$B^{(i)}x \le b_i -\epsilon + M_i y_i \quad \forall i$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$\sum_i y_i \ge 1.$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; is a &amp;quot;large enough&amp;quot; positive constant for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. The objective function can be pretty much anything.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-24T18:34:36.573" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7341" PostTypeId="2" ParentId="7318" CreationDate="2021-11-25T10:20:28.607" Score="0" Body="&lt;p&gt;You can try facebook prophet model, I have a similar demand forecast task, the data is also limited. Prophet can provide a good forecast for my case.&lt;/p&gt;&#xA;" OwnerUserId="7534" LastActivityDate="2021-11-25T10:20:28.607" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7342" PostTypeId="2" ParentId="7333" CreationDate="2021-11-25T14:20:35.187" Score="2" Body="&lt;p&gt;First googling your Error brought me to this stackoverflow question: &lt;a href=&quot;https://stackoverflow.com/questions/51799256/pyomo-error-no-value-for-uninitialized-numericvalue-object-pyomo&quot;&gt;Pyomo: Error No value for uninitialized NumericValue object Pyomo&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Suspected answer there was that the problem couldn't be solved.That is something to look at. If you suspect that the model should be solvable with the data you have, you should investigate if all your constraints are correctly implemented. And if @Oguz Toragay is right and you should use another solver, it might very well be that the used solver cannot solve this problem.&lt;/p&gt;&#xA;&lt;p&gt;I also looked over your code. It'd be a bit quicker if your comments in your code would be English. An interested reader might grasp more quickly what you intend to do in each step. Nonetheless the error message points us to the model variable &lt;em&gt;P_SE_in_1&lt;/em&gt;. If you expect your model to solve and expect &lt;em&gt;P_SE_in_1&lt;/em&gt; to have a value after solving it, you'll probably run into errors if the model actually didn't solve. A good rule of thumb is to always check if your solver got a solution and only then access variable values.&lt;/p&gt;&#xA;&lt;p&gt;Moreover there are some lines of code that don't practically do anything:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Solucao da FO1&#xA;...&#xA;results = opt.solve(model)&#xA;model.P_SE_in_1_param == model.P_SE_in_1&#xA;model.P_SE_out_1_param == model.P_SE_out_1&#xA;model.P_ESS_1_param == model.P_ESS_1&#xA;model.E_ESS_1_param == model.E_ESS_1&#xA;model.P_load_1_param == model.P_load_1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The last 4 lines in this block are just boolean statements, which are not utilized. They default to &lt;em&gt;True&lt;/em&gt;, &lt;em&gt;False&lt;/em&gt; or result in an error if Python cannot compare these objects. But only the Error will do something in your code (it'll kill execution). I don't know the intention here, but you could remove these lines of code.&lt;/p&gt;&#xA;" OwnerUserId="296" LastEditorUserId="491" LastEditDate="2021-11-26T21:33:31.090" LastActivityDate="2021-11-26T21:33:31.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7343" PostTypeId="1" CreationDate="2021-11-26T14:51:16.200" Score="16" ViewCount="1781" Body="&lt;p&gt;The title says it all: &lt;strong&gt;Are there any open source projects, that are open to new contributers?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If not, should there be?&lt;/li&gt;&#xA;&lt;li&gt;If yes, what are they and what is the best way to get involved?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="405" LastActivityDate="2023-12-10T13:44:18.467" Title="Beginner friendly open source projects in O.R" Tags="|software|open-source|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7344" PostTypeId="2" ParentId="7343" CreationDate="2021-11-26T15:19:51.220" Score="14" Body="&lt;p&gt;&lt;a href=&quot;https://vrpy.readthedocs.io/en/latest/&quot; rel=&quot;noreferrer&quot;&gt;VRPy&lt;/a&gt; is a python library for solving a range of vehicle routing problems.&lt;/p&gt;&#xA;&lt;p&gt;It is open source and open to new contributors.&lt;/p&gt;&#xA;&lt;p&gt;There are at least two ways to contribute:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;solve one of the existing &lt;a href=&quot;https://github.com/Kuifje02/vrpy/issues&quot; rel=&quot;noreferrer&quot;&gt;issues&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;have fun with it and propose new enhancements based on your personal experience with the library&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2021-11-26T15:19:51.220" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7345" PostTypeId="2" ParentId="7343" CreationDate="2021-11-26T16:42:49.367" Score="10" Body="&lt;p&gt;There are lots of projects at &lt;a href=&quot;https://www.coin-or.org&quot; rel=&quot;noreferrer&quot;&gt;COIN-OR&lt;/a&gt;, many of which I'm sure would welcome contributions. You would need to discuss with the individual project developers what the best way to help would be, but one thing that's nearly always welcome is help with documentation, including reference manuals, tutorials, example code calling library functions, etc.&lt;/p&gt;&#xA;" OwnerUserId="165" LastActivityDate="2021-11-26T16:42:49.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7346" PostTypeId="2" ParentId="7343" CreationDate="2021-11-26T18:09:25.347" Score="9" Body="&lt;p&gt;&lt;a href=&quot;https://awesomeopensource.com/projects/linear-programming/operations-research&quot; rel=&quot;noreferrer&quot;&gt;Here&lt;/a&gt; and &lt;a href=&quot;https://github.com/topics/operations-research&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; (list is generated by Github based on the tags on the open projects) you can find long lists of open operations research projects on Github. By clicking on the &amp;quot;Open Issues&amp;quot; link on each page you can directly access the Github repository for that specific project. Note that @Kuifje's own repository &lt;em&gt;VRPy&lt;/em&gt; is a great example.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2021-11-26T18:09:25.347" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7347" PostTypeId="1" CreationDate="2021-11-26T19:25:21.283" Score="-2" ViewCount="240" Body="&lt;p&gt;Given this minimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z=100x_1+77x_2+80x_3\\10x_1+7x_2+2x_3 \geq 12\\2x_1+3x_2+4x_3 \geq 3\\x_1+2x_2+x_3 \geq 1\\x_1,x_2,x_3 \geq 0$$&lt;/span&gt;&#xA;After adding artificial variables:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z-100x_1-77x_2-80x_3-MR_1-MR_2-MR_3=0\\10x_1+7x_2+2x_3-s_1+R_1=12\\2x_1+3x_2+4x_3-s_2+R_2=3\\x_1+2x_2+x_3-s_3+R_3=1$$&lt;/span&gt;&#xA;What do you do from here?&lt;/p&gt;&#xA;" OwnerUserId="7612" OwnerDisplayName="TheInquirer" LastEditorUserId="7612" LastEditDate="2021-11-27T08:24:20.297" LastActivityDate="2021-12-07T00:00:18.447" Title="How to solve this linear programming minimization problem with the BigM method" Tags="|linear-programming|big-m|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7348" PostTypeId="1" AcceptedAnswerId="7349" CreationDate="2021-11-27T16:50:05.177" Score="3" ViewCount="234" Body="&lt;p&gt;I have a linear maximization problem with an objective as follows: &lt;span class=&quot;math-container&quot;&gt;$$\sum c_i\cdot\text{exp}_i$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; are constants (positive or negative) and &lt;span class=&quot;math-container&quot;&gt;$\text{exp}_i$&lt;/span&gt; are linear expressions of the free variables, which may be positive or negative.&lt;/p&gt;&#xA;&lt;p&gt;I want to put a floor and ceiling on the &lt;code&gt;exp[i]&lt;/code&gt; in the objective, so that no term may add or subtract more than &lt;code&gt;abs(c[i] * threshold)&lt;/code&gt; to/from the objective value.&lt;/p&gt;&#xA;&lt;p&gt;It's straight-forward to implement the ceiling for &lt;code&gt;c[i] &amp;gt; 0&lt;/code&gt; and the floor for &lt;code&gt;c[i] &amp;lt; 0&lt;/code&gt; as penalties:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if c[i] &amp;gt; 0: &#xA;    penalty[i] &amp;gt; exp[i] - threshold&#xA;    penalty[i] &amp;gt; 0&#xA;    subtract c[i] * penalty[i] from the objective function&#xA;&#xA;if c[i] &amp;lt; 0: &#xA;    penalty[i] &amp;gt; threshold - exp[i]&#xA;    penalty[i] &amp;gt; 0&#xA;    subtract c[i] * penalty[i] from the objective function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However this method does not work for a floor when &lt;code&gt;c[i] &amp;gt; 0&lt;/code&gt; or for a ceiling when &lt;code&gt;c[i] &amp;lt; 0&lt;/code&gt; because &lt;code&gt;penalty[i]&lt;/code&gt; is not bounded from above.&lt;/p&gt;&#xA;&lt;p&gt;So I am asking if there is a different &amp;quot;trick&amp;quot; that can be applied here, or can this even be done as a linear problem, or alternately is there heuristic approach etc.&lt;/p&gt;&#xA;" OwnerUserId="2564" LastEditorUserId="123" LastEditDate="2021-11-28T12:22:59.313" LastActivityDate="2021-11-28T12:22:59.313" Title="Range limits on terms in the objective function of an LP" Tags="|linear-programming|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7349" PostTypeId="2" ParentId="7348" CreationDate="2021-11-27T18:03:36.730" Score="9" Body="&lt;p&gt;It can be done by adding binary variables (making your model an integer linear program), assuming that you can deduce upper and lower bounds for your linear expressions in advance. Let &lt;span class=&quot;math-container&quot;&gt;$e_i$&lt;/span&gt; be the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th expression, and let &lt;span class=&quot;math-container&quot;&gt;$U_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L_i$&lt;/span&gt; be upper and lower bounds for it.&lt;/p&gt;&#xA;&lt;p&gt;Next, let &lt;span class=&quot;math-container&quot;&gt;$\delta_i&amp;gt;0$&lt;/span&gt; be your &amp;quot;threshold&amp;quot; on the contribution of &lt;span class=&quot;math-container&quot;&gt;$e_i$&lt;/span&gt;. I'm giving it a subscript &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in case you decided to vary the threshold from expression to expression, but of course you can use the same value for all &lt;span class=&quot;math-container&quot;&gt;$\delta_i$&lt;/span&gt;. We will introduce continuous variables &lt;span class=&quot;math-container&quot;&gt;$z_i\in [-\delta_i, \delta_i]$&lt;/span&gt; to represent the objective contribution of the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th term, so that the objective becomes &lt;span class=&quot;math-container&quot;&gt;$$\max \sum_i c_i z_i.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; we introduce three binary variables (&lt;span class=&quot;math-container&quot;&gt;$y_{i1}, y_{i2}, y_{i3}$&lt;/span&gt;) together with the constraint &lt;span class=&quot;math-container&quot;&gt;$$y_{i1} + y_{i2} + y_{i3}=1,$$&lt;/span&gt; which ensures that exactly one of them will be 1. The next two constraints define the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables in terms of your expressions.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$e_i \le -\delta_i y_{i1} + \delta_i y_{i2} + U_i y_{i3}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$e_i \ge L_i y_{i1} -\delta_i y_{i2} + \delta_i y_{i3}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So &lt;span class=&quot;math-container&quot;&gt;$$y_{i1}=1 \implies L_i \le e_i \le -\delta_i,$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$y_{i2}=1 \implies -\delta_i \le e_i \le \delta_i$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$y_{i3} = 1\implies \delta_i \le e_i \le U_i.$$&lt;/span&gt; I'm assuming here that &lt;span class=&quot;math-container&quot;&gt;$L_i \le -\delta_i \le \delta_i \le U_i$&lt;/span&gt; (i.e., that &lt;span class=&quot;math-container&quot;&gt;$e_i$&lt;/span&gt; could exceed the threshold on either the negative or positive side). If not, you can simplify things by eliminating impossible cases.&lt;/p&gt;&#xA;&lt;p&gt;Having effectively split &lt;span class=&quot;math-container&quot;&gt;$e_i$&lt;/span&gt; into three ranges, we now use the binary variables to define the objective contribution &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$z_i \le e_i - L_iy_{i1}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_i \ge e_i - U_iy_{i3}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_i \le -\delta_i y_{i1} + \delta_i(y_{i2} + y_{i3})$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_i \ge \delta_i y_{i3} - \delta_i(y_{i1} + y_{i2}).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Collectively, these say that &lt;span class=&quot;math-container&quot;&gt;$$y_{i1}=1\implies z_i=-\delta_i,$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$y_{i2}=1 \implies z_i = e_i$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$y_{i3} = 1 \implies z_i = \delta_i.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-11-27T18:03:36.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7351" PostTypeId="1" CreationDate="2021-11-29T08:27:14.753" Score="2" ViewCount="395" Body="&lt;p&gt;I'm writing a convex minimization model with a quadratic objective function and linear constraints in C#.&lt;/p&gt;&#xA;&lt;p&gt;I set CPLEX to solve the problem with the barrier algorithm. The interesting thing is when I look at the log file to follow the process of solving, I see the problem is solved in some iterations first, then again the cycle of solving starts and objectives of primal and dual problem in each iteration are equal to the former solution cycle. The problem is I can't figure out the reason of doubling the solution cycle and how to stop it.&lt;/p&gt;&#xA;&lt;p&gt;Can anyone help me with that?&lt;/p&gt;&#xA;" OwnerUserId="7616" LastEditorUserId="123" LastEditDate="2021-12-01T08:20:24.693" LastActivityDate="2022-05-06T17:51:23.427" Title="CPLEX solver for quadratic problems with barrier algorithm" Tags="|cplex|quadratic-programming|c#|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7354" PostTypeId="1" AcceptedAnswerId="7360" CreationDate="2021-11-30T19:09:04.103" Score="4" ViewCount="514" Body="&lt;p&gt;So I've been given at work a project which consist on finding optimal pathing for trucks in certain custom scenarios. When I discovered this tool I thought it worked wonders for what I understood the project was back then, but obviously we are iterating the product with the client and each time we add more depth to the problem.&lt;/p&gt;&#xA;&lt;p&gt;My question is, do you think that OR-tools is appropiate for a software that is going to evolve in a not predictable way? My concern is that it might lack the flexibility to tackle some requisite from the client and I'm forced to move to another tool.&lt;/p&gt;&#xA;&lt;p&gt;I came to this realization when I discovered that it doesn't allow for several vehicles to visit one single node which is a very limiting factor, I've found ways to get around that in the community, but it honestly made me think twice about it.&lt;/p&gt;&#xA;&lt;p&gt;I apologize in advance if the question is too vague.&lt;/p&gt;&#xA;" OwnerUserId="7633" LastEditorUserId="500" LastEditDate="2021-12-01T23:00:05.923" LastActivityDate="2021-12-01T23:00:05.923" Title="Is Google's OR-tools for professional work? Specially VRP module" Tags="|vehicle-routing|or-tools|" AnswerCount="1" CommentCount="4" ClosedDate="2021-12-02T08:49:01.947" ContentLicense="CC BY-SA 4.0" />
  <row Id="7355" PostTypeId="2" ParentId="7351" CreationDate="2021-11-30T21:47:34.840" Score="5" Body="&lt;p&gt;The barrier algorithm is an interior-point method i.e. it starts from a point inside the feasible region and iteratively moves towards the optimal one. This typically results in a solution that does not lie exactly at the vertex but in the interior. This is where you'll see the barrier algorithm terminate in the CPLEX log.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If your problem has a single optimal solution, the barrier solution will be somewhere close to the vertex but inside the feasible region. &lt;a href=&quot;https://stackoverflow.com/a/38056267/10930189&quot;&gt;Such a solution will have many variable values like 0.00001, 0.99999, etc.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;If your problem has multiple optimal solutions, the barrier solution will be somewhere close to the center of this multiple optima but inside the feasible region. &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=optimizer-differences-between-barrier-simplex-optimizers&quot; rel=&quot;nofollow noreferrer&quot;&gt;Such a solution will have many variable values between their bounds.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Once the barrier algorithm terminates, CPLEX (like most other solvers) starts a &amp;quot;crossover&amp;quot; phase, by default, where it tries to get a vertex solution (with the accompanied basis) from the barrier solution. It does so by pushing the primal &amp;amp; dual variable values to their bounds and repairing any resulting infeasibilities with simplex. In many cases, the crossover can take a long time to finish (sometimes even longer than the barrier algorithm itself). However, this is not really necessary if you're only concerned with getting the optimal solution to your problem. You can &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=optimizer-controlling-crossover&quot; rel=&quot;nofollow noreferrer&quot;&gt;disable&lt;/a&gt; it in CPLEX by setting the &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=parameters-solution-type-lp-qp&quot; rel=&quot;nofollow noreferrer&quot;&gt;solutiontype&lt;/a&gt; parameter to 2.&lt;/p&gt;&#xA;&lt;p&gt;Some benefits of crossover (which, I suspect, are the &lt;a href=&quot;https://groups.google.com/g/gurobi/c/Oym-qdUcQoE/m/4Ek5NDkUDgAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;reasons why most solvers enable it by default&lt;/a&gt;) are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Once the solver has a vertex solution, it can use it to initiate subsequent simplex solves. This is particularly useful for solving LPs sequentially where the problem changes minimally (Eg. adding or removing a few constraints, changing a few variable bounds, etc.)&lt;/li&gt;&#xA;&lt;li&gt;Without the basis (from the vertex solution), there is no convenient way of querying which variables and constraints are binding in the optimal solution.&lt;/li&gt;&#xA;&lt;li&gt;Many real-world problems have multiple optima and practitioners prefer sparse solutions with variable values set at their bounds. Lots of 0 &amp;amp; 1.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="562" LastEditorUserId="562" LastEditDate="2022-05-06T17:51:23.427" LastActivityDate="2022-05-06T17:51:23.427" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7356" PostTypeId="1" CreationDate="2021-12-01T02:35:52.557" Score="4" ViewCount="285" Body="&lt;p&gt;[EDIT] : The formula below is updated to remove the radical, 0.5 in the term &lt;span class=&quot;math-container&quot;&gt;$(I_{i,v} \cdot \Delta t)$&lt;/span&gt; and constant temperature &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; replces temperature as function of current.&lt;/p&gt;&#xA;&lt;p&gt;[EDIT] :The values of the constants are added&lt;/p&gt;&#xA;&lt;p&gt;[EDIT] : Plot of &lt;span class=&quot;math-container&quot;&gt;$$ C_{loss,cyc} \ Versus  \ I_{i,v} \ \ \ \ for \ \ SOC_{init} \in [0,1]$$&lt;/span&gt; is shown below. Is it possible to approximate these family of functions using a simpler function like &lt;span class=&quot;math-container&quot;&gt;$$(1 - e^{-x})$$&lt;/span&gt; ? Could you please suggest some functions?&lt;/p&gt;&#xA;&lt;p&gt;[EDIT] : I have added the constraints to the problem below. Constants in the constraints are &lt;span class=&quot;math-container&quot;&gt;$$ I_{max}, I_{c,max}, T^{dep}_{v},t_s,  SOC^{dep}_{v}, SOC_{-1,v}, SOC_{xtra}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Z6PXD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Z6PXD.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would like to minimize the following objective function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \min_{I_{i,v}} \ \sum^{N_v}_{v}\sum^{TT_v}_{i} \ C_{loss,cyc}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the expression for &lt;span class=&quot;math-container&quot;&gt;$C_{loss,cyc}$&lt;/span&gt; is described below.&lt;/p&gt;&#xA;&lt;p&gt;The following are constants:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ a = -4.092 \cdot 10^{-4} , b = -2.167 , c = 1.408 \cdot 10^{-5}, d = 6.130, E_a = 7806, R = 8.3145 , T_{ref} = 28, \Delta t = 0.1, SOC_{init} \in [0,1], C_{bat} = 270, T = 50 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The only continuous decision variable is&#xA;&lt;span class=&quot;math-container&quot;&gt;$ I_{i,v}$&lt;/span&gt; It is highlighted below&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UWVRh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UWVRh.png&quot; alt=&quot;![![enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[EDIT] : &lt;em&gt;&lt;strong&gt;Explaination of the optimization problem.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;In a charging station, that has &lt;span class=&quot;math-container&quot;&gt;$N_v$&lt;/span&gt; vehicles that needs to be charged to some state of charge &lt;span class=&quot;math-container&quot;&gt;$SOC^{dep}_v$&lt;/span&gt; within some departure time &lt;span class=&quot;math-container&quot;&gt;$T^{dep}_v$&lt;/span&gt;. The charging schedule for each vehicle,v is thus split into timeslots, i of width &lt;span class=&quot;math-container&quot;&gt;$\Delta t$&lt;/span&gt; each for &lt;span class=&quot;math-container&quot;&gt;$TT_{v}$&lt;/span&gt; number of slots. Within a timeslot, i the current &lt;span class=&quot;math-container&quot;&gt;$I_{i,v}$&lt;/span&gt; is constant. &lt;span class=&quot;math-container&quot;&gt;$t_s $&lt;/span&gt; is just starting time of optimization implementation. The objective is trying to minimize the Electric vehicle's battery capacity loss.&lt;/p&gt;&#xA;&lt;p&gt;I want to perform linearlization of the objective function in order to achieve near real-time performance for one hundred decision variables in an optimization problem.&lt;/p&gt;&#xA;&lt;p&gt;I know about first order taylor approximation but what are some of the other methods I can use especially with regards to this type of objective function with exponential and power terms to linearlize it.&lt;/p&gt;&#xA;&lt;p&gt;You can also suggest any similifications to this model. If there is another way to solve this quickly without having to linearize it. Please suggest as well.&lt;/p&gt;&#xA;&lt;p&gt;Assume that our solver is NOT the best so we need to simplify the model mathematically to compensate for the solvers shortcomings.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4KLlq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4KLlq.png&quot; alt=&quot;![![enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4945" LastEditorUserId="4945" LastEditDate="2021-12-13T04:03:18.793" LastActivityDate="2021-12-13T04:03:18.793" Title="Linearize a highly non-linear objective function" Tags="|linearization|nonlinear-programming|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="7357" PostTypeId="2" ParentId="541" CreationDate="2021-12-01T13:27:44.253" Score="10" Body="&lt;p&gt;Strict positivity, &lt;span class=&quot;math-container&quot;&gt;$x &amp;gt; 0$&lt;/span&gt;, is equivalent to the existence of nonnegative variable, &lt;span class=&quot;math-container&quot;&gt;$r \geq 0$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$xr \geq 1$&lt;/span&gt;. This means that it can be represented in second-order cone programming by the conic quadratic constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x+r \geq \sqrt{ (x-r)^2 + 1^2 }.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To see this, just square both sides of the inequality and expand. Conclusively, MISOCP (mixed-integer second-order cone programming) is the complexity class you are looking for, extending MILP with all the constraints you list. There is quite a lot of material on MISOCP representability, but I don't recall having seen any of the constraints you list except strict positivity. Good references for this direction of research are &lt;a href=&quot;https://books.google.dk/books?hl=en&amp;amp;lr=&amp;amp;id=CENjbXz2SDQC&amp;amp;oi=fnd&amp;amp;pg=PR2&amp;amp;dq=Lectures+on+modern+convex+optimization:+Analysis,+algorithms,+and+engineering+applications&amp;amp;ots=fO6j-Qp1fk&amp;amp;sig=iadFzoLcDU3J0KfhuPQkc47vt-A&amp;amp;redir_esc=y#v=onepage&amp;amp;q=Lectures%20on%20modern%20convex%20optimization%3A%20Analysis%2C%20algorithms%2C%20and%20engineering%20applications&amp;amp;f=false&quot; rel=&quot;noreferrer&quot;&gt;Lectures on modern convex optimization: Analysis, algorithms, and engineering applications&lt;/a&gt; by Ben-tal and Nemirovski, and &lt;a href=&quot;https://arxiv.org/abs/1611.07491&quot; rel=&quot;noreferrer&quot;&gt;Mixed-integer convex representability&lt;/a&gt; by Lubin, Zadik and Vielma.&lt;/p&gt;&#xA;&lt;p&gt;Beware, however, that the given construction has two computational issues. Firstly, in finite precision arithmetic, the constraint &lt;span class=&quot;math-container&quot;&gt;$x+r \geq \sqrt{ (x-r)^2 + 1^2 }$&lt;/span&gt; can be always be satisfied within tolerances by letting &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; tend towards infinity and therefore does not exclude &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt;. Secondly, the existences of a primal feasible ray &lt;span class=&quot;math-container&quot;&gt;$(\bar x, \bar r)=(0,1)$&lt;/span&gt; that does not change the objective value, is equivalent to the existence of a dual facial reduction certificate. This means that constraint qualification fails for this construction as discussed in the paper &lt;a href=&quot;http://linkinghub.elsevier.com/retrieve/pii/S0167637716300335&quot; rel=&quot;noreferrer&quot;&gt;Constraint qualification failure in action&lt;/a&gt; by Hijazi and Liberti.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2021-12-01T13:42:22.023" LastActivityDate="2021-12-01T13:42:22.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7360" PostTypeId="2" ParentId="7354" CreationDate="2021-12-01T22:49:55.397" Score="6" Body="&lt;p&gt;Vehicle routing problems in the real world often require custom scenarios, and no VRP solver does everything, so this is a good question.&lt;/p&gt;&#xA;&lt;p&gt;The VRP solver in OR-Tools is open source (you could fork it and add your own customizations if you wanted), and new features have been added to it continually for over a decade. And speaking for Google, we're committed to maintaining it. Hopefully that will put you at ease.&lt;/p&gt;&#xA;" OwnerUserId="7641" LastActivityDate="2021-12-01T22:49:55.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7361" PostTypeId="1" AcceptedAnswerId="7362" CreationDate="2021-12-02T07:47:03.670" Score="2" ViewCount="741" Body="&lt;p&gt;I have a binary linear program, where all my variables are binary. So, I have implemented the problem on python with Gurobi solver. I have implemented also a heuristic to find a near-optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;1- if I give the solution returned by my heuristic, can improve the performance of the Gurobi solver in terms of time complexity?&lt;/p&gt;&#xA;&lt;p&gt;2- How I can introduce the solution returned by my heuristic to the API of Gurobi solver using python? I Can't find the right instructions to do. If there is a complete example that will be very helpful.&lt;/p&gt;&#xA;" OwnerUserId="7281" LastEditorUserId="500" LastEditDate="2023-12-13T18:06:48.163" LastActivityDate="2023-12-13T18:06:48.163" Title="How to say to Gurobi solver with Python API to start from a given solution?" Tags="|mixed-integer-programming|gurobi|heuristics|metaheuristics|warm-start|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7362" PostTypeId="2" ParentId="7361" CreationDate="2021-12-02T08:29:24.223" Score="2" Body="&lt;p&gt;1- It is likely that the performance will be improved, but it is not guaranteed. In general I would always recommend to provide a start solution.&lt;/p&gt;&#xA;&lt;p&gt;2- You can use the &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/start.html#attr:Start&quot; rel=&quot;nofollow noreferrer&quot;&gt;Start&lt;/a&gt; attribute. An example would look something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = gp.Model()&#xA;x = model.addVar()&#xA;x.Start = 5  # This is the start solution&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="133" LastActivityDate="2021-12-02T08:29:24.223" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7366" PostTypeId="1" AcceptedAnswerId="7387" CreationDate="2021-12-02T14:26:27.990" Score="2" ViewCount="181" Body="&lt;p&gt;I have the following model.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-java prettyprint-override&quot;&gt;&lt;code&gt;array[int] of float: weight;&#xA;set of int: nodes = index_set(weight);&#xA;int: n = max(nodes);&#xA;&#xA;array[nodes] of var 1..n: segment_start;&#xA;array[nodes] of var 0..0: segment_length;&#xA;&#xA;function var float: segment_weight(int: s) = &#xA;  sum &#xA;    (i in segment_start[s]..(segment_start[s] + segment_length[s] - 1) where i &amp;lt;= n)&#xA;    (weight[i]);&#xA;&#xA;var float: mass = sum (s in nodes) (segment_weight(s));&#xA;&#xA;solve satisfy;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The model is unsatisfiable according to MiniZinc, however, when I get rid of the variable &lt;code&gt;mass&lt;/code&gt;, a solution is found. How can an existence of a variable (i.e. not a constraint) influence whether a model is solvable? Does it have sometime to do with optional types? And how do I fix this?&lt;/p&gt;&#xA;" OwnerUserId="3083" LastEditorUserId="3083" LastEditDate="2021-12-02T16:15:02.363" LastActivityDate="2021-12-06T23:33:31.947" Title="Adding a variable makes the model unsatisfiable in MiniZinc" Tags="|constraint-programming|minizinc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7368" PostTypeId="1" CreationDate="2021-12-03T03:51:58.873" Score="1" ViewCount="58" Body="&lt;p&gt;Company X has 3 types of products and due to the limited availability of raw materials, the production of products are also limited.&lt;/p&gt;&#xA;&lt;p&gt;They have partnered with Store A for them to sell their products. Store A has 5 branches with different amount of demands for each product type but due to the limited number of products available, not all branches will be allocated.&lt;/p&gt;&#xA;&lt;p&gt;How can I transform this into a LP model where it selects the branch while maximizing profits? Or if this doesn't make sense, how should I improve my problem?&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Product Type&lt;/th&gt;&#xA;&lt;th&gt;Profits (USD/piece)&lt;/th&gt;&#xA;&lt;th&gt;Available Supply&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1589&lt;/td&gt;&#xA;&lt;td&gt;1456&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;4798&lt;/td&gt;&#xA;&lt;td&gt;1274&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;td&gt;974&lt;/td&gt;&#xA;&lt;td&gt;1789&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Branch&lt;/th&gt;&#xA;&lt;th&gt;Type 1 Demand&lt;/th&gt;&#xA;&lt;th&gt;Type 2 Demand&lt;/th&gt;&#xA;&lt;th&gt;Type 3 Demand&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;90&lt;/td&gt;&#xA;&lt;td&gt;78&lt;/td&gt;&#xA;&lt;td&gt;140&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;204&lt;/td&gt;&#xA;&lt;td&gt;50&lt;/td&gt;&#xA;&lt;td&gt;145&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;td&gt;78&lt;/td&gt;&#xA;&lt;td&gt;40&lt;/td&gt;&#xA;&lt;td&gt;60&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;td&gt;548&lt;/td&gt;&#xA;&lt;td&gt;648&lt;/td&gt;&#xA;&lt;td&gt;105&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5&lt;/td&gt;&#xA;&lt;td&gt;789&lt;/td&gt;&#xA;&lt;td&gt;500&lt;/td&gt;&#xA;&lt;td&gt;500&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;I only came up with the parameters and decision variable so far.&lt;/p&gt;&#xA;&lt;p&gt;v = index of vendors/sellers, v= 1,2,...m&lt;/p&gt;&#xA;&lt;p&gt;Ni = minimum # of product type i for vendor/seller v&lt;/p&gt;&#xA;&lt;p&gt;Ov = maximum # of product type i for vendor/seller v&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Decision variable:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Wiv = # of allocated product type i to product for vendor/seller v&lt;/p&gt;&#xA;&lt;p&gt;**Will update this one with the LP model I formulated as soon as I'm done.&lt;/p&gt;&#xA;" OwnerUserId="7648" LastEditorUserId="491" LastEditDate="2021-12-03T15:57:04.807" LastActivityDate="2021-12-03T15:57:04.807" Title="Product allocation to vendor according to their demand" Tags="|linear-programming|integer-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7370" PostTypeId="2" ParentId="7361" CreationDate="2021-12-03T12:05:15.427" Score="3" Body="&lt;p&gt;You can try the &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/varhintval.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;VarHintVal&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/start.html#attr:Start&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Start&lt;/code&gt;&lt;/a&gt; variable attributes.&#xA;Make sure you check the solver logs to see if your heuristic provides a feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;If the solution takes longer it may be the case that your initial solution was infeasible or your heuristic is worse than those implemented in Gurobi (they have some pretty good heuristics).&#xA;In both cases the solver has to determine whether the solution is feasible or not (which takes some time), and then run mostly as usual. If either your solution is infeasible or their heuristic is better, your solution will be discarded, leading to longer times than no warm-start.&lt;/p&gt;&#xA;" OwnerUserId="4752" LastEditorUserId="491" LastEditDate="2021-12-03T15:56:22.367" LastActivityDate="2021-12-03T15:56:22.367" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7372" PostTypeId="1" AcceptedAnswerId="7384" CreationDate="2021-12-03T18:07:53.130" Score="3" ViewCount="699" Body="&lt;p&gt;I have downloaded and installed the CPLEX Studio Community Edition 20.1.0.0 on my Linux machine (KUbuntu). I want to use the &lt;code&gt;oplrun&lt;/code&gt; tool directly from the terminal. I can run it just fine. However, at the start of the program, it displays a message that says:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;IBM ILOG CPLEX Optimization Studio Community Edition.  The CPLEX Optimizers will solve problems up to 1000 variables and 1000 constraints.&#xA;Problem size limit exceeded.&#xA;CP Optimizer Community Edition solves problems with search spaces up to 2^1000.&#xA;Unrestricted version options (including academia) at https://ibm.co/2s0wqSa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The message appears whatever input I use, and then, weirdly enough, it proceeds to solve the problem. I've tested with many different OPL examples at &lt;code&gt;&amp;lt;install-dir&amp;gt;/opl/examples/opl&lt;/code&gt;. The above message in particular appeared when I used the input files at &lt;code&gt;&amp;lt;install-dir&amp;gt;/opl/examples/opl/knapsack&lt;/code&gt;, which is a small example with just a few variables. So I have two questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why does this message appear?&lt;/li&gt;&#xA;&lt;li&gt;Why it proceeds to solve the problem if the problem is &amp;quot;supposedly&amp;quot; too large? Is the solution returned valid?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5073" LastEditorUserId="5073" LastEditDate="2021-12-03T18:18:04.097" LastActivityDate="2021-12-06T15:36:27.903" Title="CPLEX oplrun says the problem size has exceeded, but then proceeds to solve the problem anyway" Tags="|cplex|opl|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7373" PostTypeId="1" AcceptedAnswerId="7374" CreationDate="2021-12-03T18:25:28.253" Score="5" ViewCount="405" Body="&lt;p&gt;I was working on solving a two-stage stochastic problem using L Shaped method (Benders Decomposition). I have discussed the model here: &lt;a href=&quot;https://or.stackexchange.com/questions/6920/stochastic-facility-location-model&quot;&gt;Stochastic Facility Location Model&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Do the single-cut/ multi-cut methods guarantee optimality? Is there any way to prove this?&lt;/p&gt;&#xA;" OwnerUserId="3288" LastEditorUserId="500" LastEditDate="2021-12-03T18:49:22.337" LastActivityDate="2021-12-07T14:57:17.507" Title="Optimality in L Shaped or Bender Decomposition" Tags="|stochastic-programming|benders-decomposition|optimality-conditions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7374" PostTypeId="2" ParentId="7373" CreationDate="2021-12-03T21:28:58.527" Score="6" Body="&lt;p&gt;As far as I can see you have binary variables in the first stage and general integer variables in the second stage. This means that classical Benders cuts (based on duality of the subproblems) do not ensure convergence.&lt;/p&gt;&#xA;&lt;p&gt;Conversely, convergence is ensured by combinatorial cuts generated as follows. Let&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Q(y)$&lt;/span&gt; be the recourse function -- the expected second-stage cost -- for a given first-stage (master problem) solution&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; be a valid lower bound to &lt;span class=&quot;math-container&quot;&gt;$Q(y)$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$L \leq \min_yQ(y)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; be the variable which approximates &lt;span class=&quot;math-container&quot;&gt;$Q(y)$&lt;/span&gt; in the master problem&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y^n$&lt;/span&gt; be the solution to MP at iteration number &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$I^n$&lt;/span&gt; be the set of the indices of &lt;span class=&quot;math-container&quot;&gt;$y^n$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, i.e., the indices of the open facilities in your specific case.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The following optimality cuts ensure convergence&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\theta\geq (Q(y^n)-L)(\sum_{i\in I^n}y_i^n-\sum_{i\notin I^n}y_i^n )- (Q(y^n)-L)(|I^n|-1)+L$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This unfriendly-looking expression does precisely one thing: binds exactly the value of &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$Q(y^n)$&lt;/span&gt; when MP generates &lt;span class=&quot;math-container&quot;&gt;$y^n$&lt;/span&gt;, and yields a generally valid (possibly weak) lower bound elsewhere.&#xA;You can check yourself that, for &lt;span class=&quot;math-container&quot;&gt;$y=y^n$&lt;/span&gt; it reduces to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\theta\geq Q(y^n)$$&lt;/span&gt;&#xA;and for &lt;span class=&quot;math-container&quot;&gt;$y\neq y^n$&lt;/span&gt; it reduces to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\theta \geq L - \text{a positive constant}$$&lt;/span&gt;&#xA;You will find a more thorough explanation in &lt;a href=&quot;https://doi.org/10.1016/0167-6377(93)90002-X&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt; which introduced them.&lt;/p&gt;&#xA;&lt;p&gt;They also provide a proof of convergence. In a nutshell, the argument is the following: Since the first-stage decisions are binary, there will be a finite number of first-stage solutions and thus, with a finite number of cuts, you will be able to bind the value of &lt;span class=&quot;math-container&quot;&gt;$Q(y)$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; exactly.&lt;/p&gt;&#xA;&lt;p&gt;Finally, as I briefly said above, ordinary L-Shaped duality-based cuts do not ensure convergence. Such cuts will only provide a lower bound to &lt;span class=&quot;math-container&quot;&gt;$Q(y)$&lt;/span&gt; but will not be able to cut off &lt;span class=&quot;math-container&quot;&gt;$(y^n,\theta^n)$&lt;/span&gt; solutions for which &lt;span class=&quot;math-container&quot;&gt;$\theta^n&amp;lt;Q(y^n)$&lt;/span&gt;. This is also proven in the article above, but the argument is the following: if you solve the LP relaxation of your second-stage problem, you end up with a lower bound to &lt;span class=&quot;math-container&quot;&gt;$Q(y)$&lt;/span&gt;, which is the expectation of the optimal solution to your integer programs.&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="766" LastEditDate="2021-12-07T14:57:17.507" LastActivityDate="2021-12-07T14:57:17.507" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7375" PostTypeId="1" CreationDate="2021-12-04T08:03:49.273" Score="0" ViewCount="118" Body="&lt;p&gt;How can I calculate the space complexity of an optimization algorithm?&lt;/p&gt;&#xA;&lt;p&gt;Otherwise, what would happen if the complexity exceeds the machine capacity, and can I use the hardware instead of RAM? In this case, what would be the impact on the resolution time?&lt;/p&gt;&#xA;" OwnerUserId="5146" LastEditorUserId="5146" LastEditDate="2021-12-06T09:38:43.273" LastActivityDate="2021-12-06T12:37:28.323" Title="Spatial complexity of optimization algorithm" Tags="|optimization|computational-complexity|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7376" PostTypeId="1" AcceptedAnswerId="7378" CreationDate="2021-12-04T20:15:47.157" Score="9" ViewCount="1016" Body="&lt;p&gt;Consider the optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\label{opt-lp}\tag{Primal}&#xA;\begin{array}{cl}&#xA;\underset{x \in \mathbb{R}^n}{\text{minimize}} &amp;amp; c^\top x \\&#xA;\text{subject to} &amp;amp; Ax = a \\&#xA;&amp;amp; Bx = b&#xA;\end{array}&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{m \times n}, a \in \mathbb{R}^m, B \in \mathbb{R}^{q \times n},  b \in \mathbb{R}^q$&lt;/span&gt; are the problem data, and the problem has a nonempty feasible set.&lt;/p&gt;&#xA;&lt;p&gt;I would like to introduce a partial Lagrange relaxation to only &lt;span class=&quot;math-container&quot;&gt;$Ax = a$&lt;/span&gt; constrains, so that the partial Lagrange function is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L(x, \lambda) =c^\top x + \lambda^\top ( Ax - a).$$&lt;/span&gt;&#xA;As this is a &amp;quot;partial&amp;quot; Lagrange relaxation, I define the Lagrange dual function as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ g(\lambda) = \underset{x : Bx = b}\inf L(x, \lambda)$$&lt;/span&gt;&#xA;that is, I add the constraint of &lt;span class=&quot;math-container&quot;&gt;$Bx = b$&lt;/span&gt; already. It is clear that &lt;span class=&quot;math-container&quot;&gt;$g(\lambda)$&lt;/span&gt; lower bounds \eqref{opt-lp}.&lt;/p&gt;&#xA;&lt;p&gt;I think the Lagrange dual problem becomes:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\label{dual}\tag{Dual}&#xA;\sup_\lambda \inf_{x : Bx =b} c^\top x + \lambda^\top (Ax - a).&#xA;\end{align}&lt;/span&gt;&#xA;My question is whether what I am doing here has a name and whether I can simply say strong duality holds between problems \eqref{opt-lp} and \eqref{dual} in a paper without going much in detail.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="491" LastEditDate="2022-03-15T13:16:31.343" LastActivityDate="2022-03-15T13:16:31.343" Title="&quot;Partial&quot; Lagrangian Dual in LP" Tags="|linear-programming|duality|terminology|lagrange-multipliers|lagrangian-relaxation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7377" PostTypeId="2" ParentId="7376" CreationDate="2021-12-04T21:43:05.510" Score="9" Body="&lt;p&gt;This is called &lt;em&gt;Lagrangian relaxation&lt;/em&gt;, no matter what subset of constraints you choose to dualize.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-12-04T21:43:05.510" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7378" PostTypeId="2" ParentId="7376" CreationDate="2021-12-05T08:51:59.477" Score="9" Body="&lt;p&gt;Based on the mentioned references, suppose the primal problem is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\begin{array}{cl}&#xA;\underset{}{\text{minimize}} &amp;amp; c x \\&#xA;\text{subject to} &amp;amp; Ax = a \\&#xA;&amp;amp; Dx \leq e \\&#xA;&amp;amp; x \geq \text{0}&#xA;\end{array}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The idea behind Lagrangian relaxation is to relax the complicating constraints to produce an easier problem by adding this constraint into the objective function with a penalty so-called Lagrange multipliers. The Lagrangian subproblem is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\begin{array}{cl}&#xA;\underset{}{\text{minimize}} &amp;amp; cx \ + \ \lambda(b \ - \ Ax)\\&#xA;\text{subject to} &amp;amp; Dx \leq e \\&#xA;&amp;amp; x \geq \text{0}&#xA;\end{array}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Solving the Lagrangian subproblem can produce a lower bound on the optimal objective&#xA;value of the primal problem. Let &lt;span class=&quot;math-container&quot;&gt;$Z^*$&lt;/span&gt; be the optimal objective value of primal and let &lt;span class=&quot;math-container&quot;&gt;$Z_{LR}(\lambda)$&lt;/span&gt; be the optimal objective value of The Lagrangian subproblem. Then we have the following result:&lt;/p&gt;&#xA;&lt;p&gt;For any &lt;span class=&quot;math-container&quot;&gt;$\lambda \in \mathbb{R}^m$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; be the number of rows in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;)&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Z_{LR}(\lambda) \leq Z^*$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since primal is a minimization problem, we want lower bounds that are as large as possible; these are the most accurate and useful bounds. Different values of &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; will give different values of &lt;span class=&quot;math-container&quot;&gt;$Z_{LR}(\lambda)$&lt;/span&gt;, and hence different bounds. We’d like to find &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; that gives the largest possible bounds. That is, we want to solve:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\begin{array}{cl}&#xA;\underset{\lambda}{\text{maximize}} &amp;amp; Z_{LR}(\lambda)\\&#xA;\end{array}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;According to the primal-dual relation: &lt;span class=&quot;math-container&quot;&gt;$Z_{LP} \leq Z_{LR}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned} z_{\mathrm{LR}} &#xA;&amp;amp;\geq \max _{\lambda}\left\{\min _{x} c x+\lambda(b-A x) \mid D x \leq e, x \geq 0\right\} \\  &#xA;&amp;amp;=\max _{\lambda}\left\{\min _{x}(c-\lambda A) x+\lambda b \mid D x \leq e, x \geq 0\right\} \\ &amp;amp;=\max _{\lambda}\left\{\max _{\mu} \mu e+\lambda b \mid \mu D \leq c-\lambda A, \mu \leq 0\right\} \\ &#xA;&amp;amp;=\max _{\lambda, \mu}\{\mu e+\lambda b \mid \mu D \leq c-\lambda A, \mu \leq 0\} \\ &#xA;&amp;amp;=\max _{\lambda, \mu}\{\mu e+\lambda b \mid \mu D+\lambda A \leq c, \mu \leq 0\} \\ &#xA;&amp;amp;=\min _{y}\{c y \mid A y=b, D y \leq e, y \geq 0\} \\ &#xA;&amp;amp;=z_{\mathrm{L} P} \end{aligned}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the last one is LP dual of the entire problem.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.wiley.com/en-us/Fundamentals+of+Supply+Chain+Theory%2C+2nd+Edition-p-9781119024842&quot; rel=&quot;noreferrer&quot;&gt;Fundamentals of Supply Chain Theory&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4615-4975-8&quot; rel=&quot;noreferrer&quot;&gt;LARGE SCALE LINEAR AND INTEGER OPTIMIZATION: A UNIFIED APPROACH&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-12-05T08:51:59.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7379" PostTypeId="1" CreationDate="2021-12-06T07:24:39.780" Score="1" ViewCount="201" Body="&lt;p&gt;I developed an LP model where it allocates the number of cassava crackers to the declared number of stores depending on their minimum demand.&lt;/p&gt;&#xA;&lt;p&gt;I have a concern because when I ran the code in AMPL, there's a negative value and I don't want to have negative values on the result.&lt;/p&gt;&#xA;&lt;p&gt;Result after running the MOD FILE&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ampl: include please.run;&#xA;CPLEX 20.1.0.0: optimal solution; objective 606000&#xA;0 dual simplex iterations (0 in phase I)&#xA;X :=&#xA;1 1   40&#xA;1 2   80&#xA;2 1   60&#xA;2 2   30&#xA;3 1   60&#xA;3 2   40&#xA;;&#xA;&#xA;Y :=&#xA;1 1 1    20&#xA;1 1 2    20&#xA;1 1 3     0&#xA;1 2 1    80&#xA;1 2 2     0&#xA;1 2 3     0&#xA;2 1 1    60&#xA;2 1 2     0&#xA;2 1 3     0&#xA;2 2 1   -10&#xA;2 2 2     0&#xA;2 2 3    40&#xA;3 1 1    20&#xA;3 1 2     0&#xA;3 1 3    40&#xA;3 2 1    20&#xA;3 2 2    20&#xA;3 2 3     0&#xA;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;MOD FILE&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Parameters&#xA;param m; #cassava cracker types&#xA;param n; #periods&#xA;param o; #process&#xA;param r; #machines&#xA;param w; #store branches&#xA;&#xA;&#xA;#Sets&#xA;set I := 1..m; #index of cassava crackers types&#xA;set J := 1..n; #index of periods&#xA;set K := 1..o; #index of process&#xA;set L := 1..r; #index of machines&#xA;set S := 1..w; #index of store branches&#xA;&#xA;&#xA;#Parameters&#xA;param Production_Cost {i in I, j in J}; #production cost of cassava crackers i per pack in period j&#xA;param Cassava_Produce {i in I, j in J}; #kg of cassava needed to produce crackers&#xA;param Cassava_Avail {j in J}; #availability of cassava in period j (kg) &#xA;param Process_Time {k in K}; #process time k&#xA;param Man_HoursAvail {k in K, j in J}; #availability of man hours for process k in period j (hour)&#xA;param Machine_Processing {l in L}; #processing time of machine l&#xA;param Machine_HoursAvail {l in L, j in J}; #availablity of machine hours l in period j&#xA;param Lowest_Sales {i in I, j in J}; #lowest sales of cassava crackers i in period j&#xA;param Highest_Sales {i in I, j in J}; #highest sales of cassava crackers i in period j&#xA;param Min_Demand {s in S}; # minimum demand of store branch s&#xA;&#xA;&#xA;#Decision Variable&#xA;var X {i in I, j in J};&#xA;var Y {i in I, j in J, s in S};&#xA;&#xA;&#xA;#Objective Function&#xA;minimize Cost: sum {i in I, j in J} Production_Cost[i,j]*X[i,j];&#xA;&#xA;#Constraints&#xA;s.t. Raw_Material {j in J}: sum {i in I} Cassava_Produce[i,j]*X[i,j] &amp;lt;= Cassava_Avail[j];&#xA;s.t. Man_Hours {k in K, j in J}: sum {i in I} Process_Time[k]*X[i,j] &amp;lt;= Man_HoursAvail[k,j];&#xA;s.t. Machine_Hours {l in L, j in J}: sum {i in I} Machine_Processing[l]*X[i,j] &amp;lt;= Machine_HoursAvail[l,j];&#xA;s.t. Product_Sale {i in I, j in J}: Lowest_Sales[i,j] &amp;lt;= X[i,j] &amp;lt;= Highest_Sales[i,j];&#xA;s.t. Nonnegative {i in I, j in J}: X[i,j] &amp;gt;= 0;&#xA;&#xA;s.t. C1 {i in I, j in J}: sum {s in S} Y[i,j,s] = X[i,j];&#xA;s.t. C2 {j in J, s in S}: sum {i in I} Y[i,j,s] &amp;gt;= Min_Demand[s];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7648" LastEditorUserId="491" LastEditDate="2021-12-06T15:05:28.877" LastActivityDate="2021-12-06T15:57:25.083" Title="Why is the value negative? AMPL" Tags="|linear-programming|ampl|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7381" PostTypeId="2" ParentId="7379" CreationDate="2021-12-06T10:08:22.893" Score="2" Body="&lt;p&gt;You are not bounding &lt;span class=&quot;math-container&quot;&gt;$Y_{i,j,s}$&lt;/span&gt; from below and hence have to add a nonnegativity constraint similar to the one for &lt;span class=&quot;math-container&quot;&gt;$X_{i,j}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As long as &lt;span class=&quot;math-container&quot;&gt;$ \sum_{s \in S} Y_{i,j,s} $&lt;/span&gt; is larger or equal to zero (ensured by C1), everything will work fine. However the individual values of &lt;span class=&quot;math-container&quot;&gt;$Y_{i,j,s}$&lt;/span&gt; can take values smaller than zero.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Minimum working example:&lt;/strong&gt;&#xA;Lets assume that you have 5 &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; variables for a given &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and a minimum demand of &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; of 100. By assumption one of the &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; variables takes a value of -100. As long as the remaining four values sum up to at least 200, no constraint will be violated.&lt;/p&gt;&#xA;" OwnerUserId="7468" LastEditorUserId="7468" LastEditDate="2021-12-06T15:57:25.083" LastActivityDate="2021-12-06T15:57:25.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7382" PostTypeId="1" AcceptedAnswerId="7385" CreationDate="2021-12-06T12:14:53.210" Score="5" ViewCount="362" Body="&lt;p&gt;If I introduce a problem, say as an ILP formulation, should I also discuss the number of introduced constraints? If yes, why?&lt;/p&gt;&#xA;" OwnerUserId="5523" LastActivityDate="2021-12-07T07:52:29.407" Title="The importance of evaluating the number of constraints" Tags="|integer-programming|constraint|computational-complexity|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7383" PostTypeId="2" ParentId="7375" CreationDate="2021-12-06T12:37:28.323" Score="3" Body="&lt;p&gt;It is very flaky to calculate this theoretically, as it's very implementation dependent. Depending on the spatial efficiency of the data structures, caching, and so on, it can vary from sublinear all the way to factorial.&lt;/p&gt;&#xA;&lt;p&gt;Let me give you a few examples. In BnB, all we really need to store is the bounds of all variables for every node of the BnB tree. Ergo, the spatial complexity should be &lt;code&gt;2*nu_vars*nu_nodes&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, we might also use some hash maps to look up information internally, and depending on the implementation this might scale cubicaly or worse. We might also use a git-style diff technique to only store bounds changes instead of actual bounds, which could reduce the average runtime complexity to sublinear.&lt;/p&gt;&#xA;&lt;p&gt;Solvers being the complex pieces of software they are, other information might be stored, such as conflicts for conflict analysis, restoration information, and so on. For (MI)NLPs, the way the hessian is calculated can also affect memory usage considerably. For a good implementation that would have a constant spatial overhead (as in it doesn't scale with the number of nodes), but some solvers don't do this very well.&lt;/p&gt;&#xA;&lt;p&gt;Solvers might also store warm starting information for some nodes (but not all of them), which can also induce a memory overhead that scales with the number of nodes in a non-obvious way (since it's governed by a heuristic).&lt;/p&gt;&#xA;&lt;p&gt;Finally, if a solver generates cuts dynamically, then this also induces a hard to calculate memory overhead. There are typically limits on pool sizes and sizes of cuts, but these can also change on the fly depending on the implementation.&lt;/p&gt;&#xA;&lt;p&gt;W.r.t. to your questions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What would happen if the complexity exceeds the machine capacity?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Typically the solver &amp;amp; the computer will crash. Some commercial solvers have ways around this, e.g. CPLEX can store part of the BnB tree on the hard drive for very large problems/trees.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In this case, what would be the impact on the resolution time?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Assuming the computer doesn't crash, performance can be abysmal, but highly depends on implementation. For a bad implementation you would expect 100x-1000x worse performance. For a good implementation, it might only be 2x-5x worse.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2021-12-06T12:37:28.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7384" PostTypeId="2" ParentId="7372" CreationDate="2021-12-06T15:36:27.903" Score="3" Body="&lt;p&gt;Indeed even for models that are small enough like knapsack you get the message&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;IBM ILOG CPLEX Optimization Studio Community Edition.  The CPLEX&#xA;Optimizers will solve problems up to 1000 variables and 1000&#xA;constraints. Problem size limit exceeded. CP Optimizer Community&#xA;Edition solves problems with search spaces up to 2^1000. Unrestricted&#xA;version options (including academia) at &lt;a href=&quot;https://ibm.co/2s0wqSa&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ibm.co/2s0wqSa&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;but you should not see&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Problem size limit exceeded.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;That's a bug. But it is normal to be able to solve this with the &lt;a href=&quot;https://www.linkedin.com/pulse/what-free-ibm-cplex-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;FREE CPLEX community edition&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-12-06T15:36:27.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7385" PostTypeId="2" ParentId="7382" CreationDate="2021-12-06T17:13:56.710" Score="7" Body="&lt;p&gt;In academic publications (where the point is to present a model and possibly computational scheme to solve an actual problem) I typically do not bother to count the constraints. First, the reader can do it themselves from the algebraic formulation. Second, the reader is more interested in whether &amp;quot;realistic&amp;quot; instances of problem are solvable with &amp;quot;reasonable&amp;quot; hardware in &amp;quot;reasonable&amp;quot; time, which they find out in the experimental results.&lt;/p&gt;&#xA;&lt;p&gt;I do agree with the comment that formulations requiring an exponential number of constraints are potentially problematic, &lt;em&gt;if&lt;/em&gt; there is a need for them to scale. I say &amp;quot;if&amp;quot; because in some cases you are presenting computational results for problems of the size that users will likely encounter. For instance, if you are creating bus routes for school children, the fact that computation time blows up as the number of kids attending the school tends to infinity is probably not very relevant.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-06T17:13:56.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7386" PostTypeId="1" CreationDate="2021-12-06T19:20:58.633" Score="3" ViewCount="195" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a random variable with pdf and cdf in forms of &lt;span class=&quot;math-container&quot;&gt;$f(X)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$F(X)$&lt;/span&gt;, with hazard-rate &lt;span class=&quot;math-container&quot;&gt;$h(X)$&lt;/span&gt;. Now, we define a new variable &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; which is a truncated random variable, &lt;span class=&quot;math-container&quot;&gt;$Y=X, \quad &#xA;\text{if } X \le a$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$Y=0, \quad  \text{if } X &amp;gt; a$&lt;/span&gt;. I am wondering what is the hazard-rate of the random variable &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;? For example, if &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a geometric random, what is the hazard-rate of &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2021-12-13T16:28:51.790" Title="What is the hazard-rate of a truncated probability distribution?" Tags="|probability-distributions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7387" PostTypeId="2" ParentId="7366" CreationDate="2021-12-06T23:33:31.947" Score="3" Body="&lt;p&gt;It seems you ran into an issue in the MiniZinc compiler. Running with &lt;code&gt;weight = [1,2,3];&lt;/code&gt; under the current release (2.5.5) does indeed give UNSAT (even though it shouldn't):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ minizinc --solver cbc ./should_work.mzn&#xA;=====UNSATISFIABLE=====&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, if you run using the current &lt;code&gt;develop&lt;/code&gt; branch of MiniZinc then it does give an asnwer:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ ./github.com/MiniZinc/libminizinc/build/Debug/minizinc --solver cbc ./should_work.mzn&#xA;segment_start = [1, 1, 1];&#xA;segment_length = [0, 0, 0];&#xA;----------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I do not know exactly where this issue was solved, but I can say that a new release of MiniZinc will soon be available that should include this fix. In the meantime you could already use the &lt;code&gt;develop&lt;/code&gt; branch of MiniZinc.&lt;/p&gt;&#xA;" OwnerUserId="97" LastActivityDate="2021-12-06T23:33:31.947" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7388" PostTypeId="2" ParentId="7347" CreationDate="2021-12-07T00:00:18.447" Score="3" Body="&lt;p&gt;Assuming you know the Simplex method, start out with &lt;span class=&quot;math-container&quot;&gt;$R_1=12$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$R_2=3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$R_4=1$&lt;/span&gt; as your initial basic feasible solution and crank out simplex pivots, treating &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; as if it were &lt;span class=&quot;math-container&quot;&gt;$\infty$&lt;/span&gt;. If you prefer, you can set &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to some really large finite number. The key is that if &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is large enough, the first few pivots you do will boot the artificial variables out of the basis. Optionally, as they drop out of the basis you can eliminate them from the problem (delete their columns from the simplex tableau), as they will never reenter the basis.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-07T00:00:18.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7389" PostTypeId="2" ParentId="7382" CreationDate="2021-12-07T07:51:51.657" Score="2" Body="&lt;p&gt;I agree with @prubin on academic publications.&lt;/p&gt;&#xA;&lt;p&gt;However if your audience consist of &amp;quot;laymen&amp;quot;, e.g. when working as a consultant, a discussion can be helpful:&#xA;Providing insight into how a change of parameters affects the number of constraints (and more importantly: the number of decisions to be made, i.e. the number of variables) helps them to get a better understanding of the complexity of the underlying problem.&lt;/p&gt;&#xA;&lt;p&gt;Reconsidering @prubin's example: One could present a table showing the number of constraints (and variables) for 5, 10, 20, .... school children.&lt;/p&gt;&#xA;" OwnerUserId="7468" LastEditorUserId="123" LastEditDate="2021-12-07T07:52:29.407" LastActivityDate="2021-12-07T07:52:29.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7390" PostTypeId="2" ParentId="7361" CreationDate="2021-12-07T13:24:23.903" Score="0" Body="&lt;p&gt;So here is my experience (and also some wisdom of other ppl i read) with setting lower bounds for minimization problems: Depending on the complexity of the model or your strategy for cutting invalid solutions of (tightness of the cuts) it might indeed be worse to set a lower bound, because it messes with the internal pricing gurobi uses. All the nodes that are still to be visited, get truncated to the same obj-value and there is no way to prioritize the more promising nodes, which mostly leads to vising random nodes, which then in turn also branch with the same obj-value and before you can derive any reasonable cuts you end up with a much bigger tree.&lt;/p&gt;&#xA;&lt;p&gt;Now back to your issue when setting a good starting solution (or an upper bound in general): It is possible that setting such good starting solution (or even an optimal one) cuts off branches of the tree, which would otherwise be examinated and might produce better cuts or direction for moving that upper bound further up or something of this sorts. But in contrary to setting lower bounds, which seems to generally perform worse, this is more of an accident. In general it should be a good idea to set better initial solutions - it might just be worse in your specific case (problem instance)&lt;/p&gt;&#xA;" OwnerUserId="7667" LastActivityDate="2021-12-07T13:24:23.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7391" PostTypeId="1" CreationDate="2021-12-07T13:50:08.690" Score="3" ViewCount="51" Body="&lt;p&gt;&lt;sub&gt; Cross-posted on &lt;a href=&quot;https://math.stackexchange.com/questions/4326279/how-to-learn-a-vandermonde-matrix-from-data&quot;&gt;Mathematics SE&lt;/a&gt;. &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I would like to discuss how to tackle an optimization problem to learn a &lt;a href=&quot;https://en.wikipedia.org/wiki/Vandermonde_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vandermonde matrix&lt;/a&gt;. In particular, I have an optimization problem in the following form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;V &amp;amp;= \operatorname{argmin}_{V}\|A -  \operatorname{diag}(Vb )C\|_F^2&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A,C$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$N \times N$&lt;/span&gt; matrices, &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$N \times K$&lt;/span&gt; Vandermonde matrix with &lt;span class=&quot;math-container&quot;&gt;$N &amp;gt;K$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$K \times 1$&lt;/span&gt; vector of coefficients.&lt;/p&gt;&#xA;&lt;p&gt;This is a generalization of FIR filter design, where instead of finding the filter coefficients &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; we search for the basis vectors &lt;span class=&quot;math-container&quot;&gt;$\{v_1, \ldots, v_k\}$&lt;/span&gt; of the Vandermonde matrix. Each of this vector is such that &lt;span class=&quot;math-container&quot;&gt;$v_{i+1}= v_i \odot v_1 $&lt;/span&gt;, i.e., it is a geometric progression over the rows.&lt;/p&gt;&#xA;&lt;p&gt;How can I learn the matrix &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;? Is there a a way to rewrite such problem in a form easier to optimize?&lt;/p&gt;&#xA;&lt;p&gt;The problem is not convex, since it is the composition of a norm with a non-affine mapping of the &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; variables contained in &lt;span class=&quot;math-container&quot;&gt;$v_1$&lt;/span&gt;. Exploiting the relationship between Frobenius norm and trace property, I could arrive at the problem of minimizing &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; over the function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\operatorname{vec}(Z)^\top \operatorname{vec}(Z) -2 \operatorname{vec}(A)^{\top}\operatorname{vec}(Z) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\operatorname{vec}(Z)= \operatorname{vec}(C)^\top (I \odot I) \operatorname{vec}(Vb)$&lt;/span&gt;.&#xA;Might this help in solving for &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;? (or better, for &lt;span class=&quot;math-container&quot;&gt;$v_1$&lt;/span&gt;?).&lt;/p&gt;&#xA;" OwnerUserId="7668" LastEditorUserId="123" LastEditDate="2021-12-07T13:53:41.507" LastActivityDate="2021-12-07T13:53:41.507" Title="Estimation of Vandermonde matrix" Tags="|optimization|convex-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7392" PostTypeId="1" CreationDate="2021-12-07T15:48:25.907" Score="5" ViewCount="134" Body="&lt;p&gt;Trying to use an opensource optimization tool in python (having used only gurobi for years) I see that the whole code (representing the optimization problem in pythonic language) must be written differently in order to use such tools (pyomo etc.). Is there a straightforward way for me to run my scripts (in the form that they are written-aligning with gurobi grammar) but using a different solver/tool/package rather than gurobi?&lt;/p&gt;&#xA;" OwnerUserId="3467" LastActivityDate="2021-12-07T18:25:44.973" Title="How to transfer an optimization problem written with GUROBI (in python) in a grammar that can be readily solved with another solver?" Tags="|mixed-integer-programming|python|gurobi|pyomo|pulp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7393" PostTypeId="2" ParentId="7392" CreationDate="2021-12-07T18:20:06.283" Score="4" Body="&lt;p&gt;I think &lt;a href=&quot;https://github.com/scipopt/PySCIPOpt&quot; rel=&quot;nofollow noreferrer&quot;&gt;pySCIPOpt&lt;/a&gt; might be a good choice, provided you are willing to make minor changes to the code.  The modelling interface is very similar to Gurobi and the underlying SCIP solver also supports handy modelling features like indicator constraints or logical AND/OR/XOR constraints. Alternatively, you could save all your models as MPS files and solve them with the solver of your choice since nearly all common modelling interfaces support the MPS file format.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="3696" LastEditDate="2021-12-07T18:25:44.973" LastActivityDate="2021-12-07T18:25:44.973" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7394" PostTypeId="1" AcceptedAnswerId="7395" CreationDate="2021-12-07T19:16:54.337" Score="4" ViewCount="328" Body="&lt;p&gt;got a lingering question from a graduate course in integer programming that's been bugging me ever since.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Is it possible to find the mean of some variables in a MIP without resorting to quadratic constraints?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here's an example of what I mean:&lt;/p&gt;&#xA;&lt;p&gt;Suppose there are &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; cities you could travel to and you've given each city a rating, &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;. In some goal program style MIP you create a binary variable, &lt;span class=&quot;math-container&quot;&gt;$X_{i}$&lt;/span&gt;, to indicate whether or not you will be travelling to city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Finding the average rating you've attributed to a city is simple enough:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bar{r} = \frac{1}{N}\sum_i{r_i}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But what if you wanted to find the average rating of the cities the program has selected, i.e., those whos &lt;span class=&quot;math-container&quot;&gt;$X_i = 1$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;This is where I am stuck - the calculations I have to find this new average are pretty simple:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bar{R} = \frac{1}{\sum_i{X_i}}\sum_i{r_iX_i}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But because I am multiplying &lt;span class=&quot;math-container&quot;&gt;$\bar{R}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_i{X_i}$&lt;/span&gt;, both decision variables that the model calculates based on its solution, the constraint used to find &lt;span class=&quot;math-container&quot;&gt;$\bar{R}$&lt;/span&gt; is quadratic.&lt;/p&gt;&#xA;&lt;p&gt;For clarification - in this problem, you're trying to find a subtour of the &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; cities to travel to, so it cannot be assumed that &lt;span class=&quot;math-container&quot;&gt;$\sum_i{X_i} = N$&lt;/span&gt;. The number of cities you travel to, &lt;span class=&quot;math-container&quot;&gt;$\sum_i{X_i}$&lt;/span&gt;, is in itself a decision variable.&lt;/p&gt;&#xA;&lt;p&gt;Is there any way to make this kind of calculation linear?&lt;/p&gt;&#xA;&lt;p&gt;The aforementioned graduate class seemed to imply such a thing could be done, but I could have just misinterpreted what the lecture was saying at that time.&lt;/p&gt;&#xA;&lt;p&gt;As of yet, I haven't been able to come up with a way to do this, so I'm wondering if the smart people of the internet might be able to tell me for certain if its impossible or not.&lt;/p&gt;&#xA;" OwnerUserId="7672" LastEditorUserId="491" LastEditDate="2021-12-08T23:22:20.577" LastActivityDate="2021-12-08T23:22:20.577" Title="Can you calculate the mean of some MIP variables using linear constraints?" Tags="|mixed-integer-programming|linear-programming|linearization|quadratic-programming|indicator-constraints|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7395" PostTypeId="2" ParentId="7394" CreationDate="2021-12-07T20:11:27.453" Score="3" Body="&lt;p&gt;You can do it if you have a fairly high pain tolerance. :-)&lt;/p&gt;&#xA;&lt;p&gt;Let's start by introducing binary variables &lt;span class=&quot;math-container&quot;&gt;$Z_1,\dots, Z_K$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is the dimension of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;) and making &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; a variable. Add constraints &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=1}^K Z_j = 1,$$&lt;/span&gt;&lt;span class=&quot;math-container&quot;&gt;$$N=\sum_{j=1}^K j\cdot Z_j$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=1}^K X_j = N.$$&lt;/span&gt;I'm assuming here that at least one of the &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; variables will be 1, since &lt;span class=&quot;math-container&quot;&gt;$N=0$&lt;/span&gt; makes the mean a bit undefined.&lt;/p&gt;&#xA;&lt;p&gt;Now comes the fun part. If variable &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is supposed to be the mean, we want to set&lt;span class=&quot;math-container&quot;&gt;$$Y\cdot N = \sum_{j=1}^K r_j \cdot X_j.$$&lt;/span&gt;The right side is linear, so that's no problem. The left side expands to &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^K j\cdot Z_j \cdot Y$&lt;/span&gt;. Each term is a product of a general variable (&lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;) and a binary variable (&lt;span class=&quot;math-container&quot;&gt;$Z_j$&lt;/span&gt;). Rob's answer to &lt;a href=&quot;https://or.stackexchange.com/questions/6028/mixed-integer-optimization-with-bilinear-constraint&quot;&gt;Mixed-integer optimization with bilinear constraint&lt;/a&gt; shows how to linearize those by adding more variables and constraints, assuming that you can bound &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-07T20:11:27.453" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7397" PostTypeId="1" CreationDate="2021-12-07T21:37:20.340" Score="6" ViewCount="134" Body="&lt;p&gt;I'm struggling with this question for several weeks already and seem to be either stuck, or the bound is not going to be any better. Let's jump right into the problem:&lt;/p&gt;&#xA;&lt;p&gt;Given a standard TSP on a graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; nodes where the triangle inequality holds, let's consider &lt;span class=&quot;math-container&quot;&gt;$L_g$&lt;/span&gt; to be the length of the TSP-Tour on this graph. Now let's consider &lt;span class=&quot;math-container&quot;&gt;$H \subseteq G$&lt;/span&gt; to be a subgraph, in which &lt;span class=&quot;math-container&quot;&gt;$0 \leq k \leq n-1$&lt;/span&gt; nodes are missing and &lt;span class=&quot;math-container&quot;&gt;$L_h$&lt;/span&gt; being the TSP-length on &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;. We can derive a lower bound for &lt;span class=&quot;math-container&quot;&gt;$L_h$&lt;/span&gt; like this:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;L_h \geq L_g - \sum_{i \in G}(1-Y_i)\theta_i&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$Y_i=1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$i \in H$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y_i=0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$i \notin H$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\theta_i=2 \cdot \max_{\forall j \in G}(c_{ij})$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; is the length of the edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So what we basically do here is say, that for each node, that is in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; but not in &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; anymore, we subtract two times the longest edge incident to this node (&lt;span class=&quot;math-container&quot;&gt;$\theta_{i}$&lt;/span&gt; represents that value) from &lt;span class=&quot;math-container&quot;&gt;$L_g$&lt;/span&gt; and get a lower bound for &lt;span class=&quot;math-container&quot;&gt;$L_h$&lt;/span&gt;. This seems to be valid, although rather a poor bound.&lt;/p&gt;&#xA;&lt;p&gt;Hence my question: does anybody know or has any idea, how we can shrink &lt;span class=&quot;math-container&quot;&gt;$\theta_{i}$&lt;/span&gt; in value by which the bound gets tighter? This should be done without increasing the number of inequalities and for any arbitrary number &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; of &amp;quot;missing&amp;quot; nodes.&lt;/p&gt;&#xA;&lt;p&gt;Edit1: I should point out, that i experimentally tried out some other values for &lt;span class=&quot;math-container&quot;&gt;$\theta_i$&lt;/span&gt; like simply adding the length of the edge leading to &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and away from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in the TSP-tour in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;. Although i still cannot find a decent example of why it would not hold, it was cutting off otherwise optimal solutions, so i simply accepted that it is wrong :)&lt;/p&gt;&#xA;" OwnerUserId="7667" LastEditorUserId="7667" LastEditDate="2021-12-08T14:04:35.740" LastActivityDate="2022-02-09T12:19:12.703" Title="Lower bounds for TSP with k missing nodes" Tags="|traveling-salesman|bounds|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7400" PostTypeId="1" CreationDate="2021-12-08T12:04:35.847" Score="3" ViewCount="303" Body="&lt;p&gt;I've tried Or-Tools and MILP solvers a couple of different ways on this, but they take a surprisingly long time to realize that the solution they generated fairly quickly is in fact minimal. Is there a better way? Does this problem have a name?&lt;/p&gt;&#xA;&lt;h3&gt;Problem&lt;/h3&gt;&#xA;&lt;p&gt;Given a fixed set of meetings, their dates, start times and end times, an individual is required to attend a subset of the meetings respecting some (pseudo-)Boolean constraints (e.g., at least &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; of a subset of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; meetings must be attended; if a particular meeting is attended, a selection of other meetings must be attended). In particular, the individual cannot attend two meetings at once.&lt;/p&gt;&#xA;&lt;h4&gt;Goal&lt;/h4&gt;&#xA;&lt;p&gt;Choose a set of meetings to attend that meets the Boolean constraints and minimizes the total time the individual spends both in meetings and waiting for the next meeting on the same day.&lt;/p&gt;&#xA;&lt;p&gt;More precisely, minimize the sum of the &lt;em&gt;day lengths&lt;/em&gt;, where the length of a day is the duration from the start of the day's earliest attended meeting to the end of the latest attended. (A solution with meetings on Monday at 9am-12pm, 3pm-5pm, and on Wednesday 10am-11am, 3pm-4pm has a total day length of 8 + 6 = 14hrs.)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;To simplify, consider one day in isolation, and on it a set &lt;span class=&quot;math-container&quot;&gt;$M_D$&lt;/span&gt; of possible meetings &lt;span class=&quot;math-container&quot;&gt;$\{m_1, \dots, m_n\}$&lt;/span&gt;, with functions &lt;span class=&quot;math-container&quot;&gt;$\mathrm{start_D}, \mathrm{end_D} : M_D \to \{0, 1, \dots, 24\}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathrm{start_D}(m_i) \lt \mathrm{end_D}(m_i)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Assume all meeting times are unique, i.e., &lt;span class=&quot;math-container&quot;&gt;$\mathrm{start_D}(m_i) = \mathrm{start_D}(m_j) \implies i = j$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\mathrm{end_D}(m_i) \neq \mathrm{end_D}(m_j)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Denote by &lt;span class=&quot;math-container&quot;&gt;$S_D$&lt;/span&gt; the solution: the (possibly empty) subset of &lt;span class=&quot;math-container&quot;&gt;$M_D$&lt;/span&gt; chosen for that day.&lt;/p&gt;&#xA;&lt;p&gt;Then the objective to minimize is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{equation} \mathrm{length_D} = \begin{cases} &#xA;          \max_{m_i \in S_D}\{\mathrm{end_D}(m_i)\} - \min_{m_i \in S_D}\{\mathrm{start_D}(m_i)\} &amp;amp; \text{if $S_D$ is non-empty}\\&#xA;          0 &amp;amp; \text{otherwise}\\ &#xA;       \end{cases} \end{equation}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h4&gt;Attempt 1 (slower)&lt;/h4&gt;&#xA;&lt;p&gt;&lt;strong&gt;Boolean variables:&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$m_1, \dots, m_n, dayNotEmpty$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Integer variables:&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$dayLength$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$latestEnd$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$earliestStart$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$earliestStart'$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective:&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$\text{minimize $dayLength$}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&amp;amp;\text{[... other Boolean constraints...]}\\\\&#xA;m_i + m_j &amp;amp;\leq 1 \text{ if $m_i$ and $m_j$'s times overlap} &amp;amp; \forall_{i, j}, i \neq j\\\\&#xA;dayLength &amp;amp;= latestEnd - earliestStart\\\\&#xA;latestEnd &amp;amp;\geq \mathrm{end_D}(m_i) \cdot m_i &amp;amp; \forall_{i} \\\\&#xA;earliestStart' &amp;amp;\geq 24 - \mathrm{start_D}(m_i) \cdot m_i &amp;amp; \forall_{i}\\&#xA;earliestStart &amp;amp;= (24 - earliestStart') - 24 \cdot (1 - dayNotEmpty)\\\\&#xA;(dayNotEmpty &amp;amp;\equiv \bigvee_i m_i)\\&#xA;dayNotEmpty &amp;amp;\leq \sum_i m_i\\&#xA;dayNotEmpty &amp;amp;\geq m_i &amp;amp;\forall_{i} &#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(So that, when no meetings are in the solution, &lt;span class=&quot;math-container&quot;&gt;$earliestStart' = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$dayLength = 0 - ((24 - 0) - 24 \cdot 1) = 0$&lt;/span&gt;.)&lt;/p&gt;&#xA;&lt;h4&gt;Attempt 2 (faster)&lt;/h4&gt;&#xA;&lt;p&gt;&lt;strong&gt;Boolean variables:&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$m_1, \dots, m_n, and_{1,2}, \dots, and_{1,n}, \dots, and_{n-1, n}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Integer variables:&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$dayLength$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective:&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$\text{minimize $dayLength$}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&amp;amp;\text{[... other Boolean constraints...]}\\\\&#xA;m_i + m_j &amp;amp;\leq 1 \text{ if $m_i$ and $m_j$'s times overlap} &amp;amp;\forall_{i, j}, i \neq j\\\\&#xA;dayLength &amp;amp;\geq (\mathrm{end_D}(m_i) - \mathrm{start_D}(m_i)) \cdot m_i &amp;amp;\forall_{i}\\&#xA;dayLength &amp;amp;\geq (\mathrm{end_D}(m_j) - \mathrm{start_D}(m_i)) \cdot and_{i,j} &amp;amp;\forall_{i, j}, i \neq j, \mathrm{end_D}(m_i) \leq \mathrm{start_D}(m_j)\\\\&#xA;(and_{i,j} &amp;amp;\equiv m_i \wedge m_j) &amp;amp; \forall_{i, j}, i \neq j\\&#xA;and_{i,j} &amp;amp;\geq m_i + m_j - 1 &amp;amp;\forall_{i, j}, i \neq j \\&#xA;and_{i,j} &amp;amp;\leq m_i &amp;amp;\forall_{i, j}, i \neq j\\&#xA;and_{i,j} &amp;amp;\leq m_j &amp;amp;\forall_{i, j}, i \neq j &#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="7680" LastEditorUserId="981" LastEditDate="2023-12-31T11:08:54.110" LastActivityDate="2023-12-31T11:08:54.110" Title="Scheduling for the shortest days using ILP" Tags="|optimization|modeling|integer-programming|scheduling|or-tools|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7401" PostTypeId="2" ParentId="7400" CreationDate="2021-12-08T13:25:11.407" Score="3" Body="&lt;p&gt;I recommend using a network formulation, as I have done for the &lt;a href=&quot;https://blogs.sas.com/content/operations/2015/04/03/the-traveling-baseball-fan-problem/&quot; rel=&quot;nofollow noreferrer&quot;&gt;traveling baseball fan problem&lt;/a&gt;. The nodes are the meetings, and the arcs represent transitions between consecutive meetings, with an arc cost that captures the additional time incurred until the end of the next meeting.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-12-08T13:25:11.407" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7402" PostTypeId="2" ParentId="3667" CreationDate="2021-12-08T13:47:25.717" Score="1" Body="&lt;p&gt;I'm not really sure what you're trying to accomplish. If you want to eliminate subtours upfront, you can add the constraints right away and then there are no sub-tours (as you observed). Like already mentioned by Daniel Junglas, the problem turns from MILP to MIQCP if the constraints were added in this form. If you are linearizing them, then there are more than &lt;span class=&quot;math-container&quot;&gt;$|S|$&lt;/span&gt; constraints, which still explains the slow down. The problem with MTZ-like constraints is, that (to the best of my knowledge) you cannot add a fraction of those, it's either all or nothing, so it doesn't really make sense to me, to add those later on as a lazy constraint.&lt;/p&gt;&#xA;&lt;p&gt;Considering the fractional solutions: I don't know how your linearized equations exactly look like, but as far as for the MTZ: the relaxations produce very poor bounds so this is also something to be aware of.&lt;/p&gt;&#xA;&lt;p&gt;Also bear in mind, that your formulation (as well as the MTZ) only work on ATSP and if you got a symmetrical TSP and are formulating it still as ATSP you are introducing a lot of symmetries, which is never good.&lt;/p&gt;&#xA;&lt;p&gt;What exactly are you trying to accomplish and is it worth it? As far as i know, solving an integer model and adding &amp;quot;standard&amp;quot; SECs as lazy constraints in the callback already gets you pretty far with the current solvers. Could you elaborate more on your goals?&lt;/p&gt;&#xA;" OwnerUserId="7667" LastEditorUserId="123" LastEditDate="2021-12-08T14:34:17.597" LastActivityDate="2021-12-08T14:34:17.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7403" PostTypeId="1" CreationDate="2021-12-08T14:16:36.540" Score="7" ViewCount="644" Body="&lt;p&gt;My target is to formulate a binary sequence with fixed size &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; = 10, such as &lt;span class=&quot;math-container&quot;&gt;$[1, 0, 0, 0 ,1, 1, 0, 1, 0, 0]$&lt;/span&gt;. However, I want to constrain this sequence so that when 1 appears, it has to appear at least three times; This is partial problem when I formulate my traffic signal optimization problem, in which 1/0 indicates green/red. I need to add such constraint to emulate minimum green time in the real world.&lt;/p&gt;&#xA;" OwnerUserId="7681" LastEditorUserId="491" LastEditDate="2021-12-08T23:23:35.853" LastActivityDate="2021-12-08T23:23:35.853" Title="How to construct my mixed integer programming problem with constraint of minimum consecutive ones" Tags="|mixed-integer-programming|modeling|binary-variable|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7404" PostTypeId="2" ParentId="7403" CreationDate="2021-12-08T14:37:09.607" Score="8" Body="&lt;p&gt;Define a two sets of binary variables : variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if the &lt;span class=&quot;math-container&quot;&gt;$i^{th}$&lt;/span&gt; term of the sequence equals &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, and variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if one of the terms equals &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You want to enforce&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y=1 \quad \Longrightarrow \quad \sum_i{x_i} \ge 3 \\&#xA;x_i = 1 \quad \Longrightarrow \quad y=1 &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can do this with&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;3 y &amp;amp;\le \sum_i{x_i} \\&#xA;x_i &amp;amp;\le y \quad \forall i&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;It is not clear in your question if the ones have to be consecutive or not. If they do, then you need to forbid all the patterns that do not satisfy this. @ErwinKalvelagen shows us how to achieve this &lt;a href=&quot;https://math.stackexchange.com/questions/3008969/binary-variables-in-time-series-integer-linear-programming&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;One simple way to enforce a run length of at least three, is to forbid&#xA;patterns &lt;code&gt;010&lt;/code&gt; and &lt;code&gt;0110&lt;/code&gt;. This can be modeled as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ -x_t + x_{t+1} - x_{t+2} \le 0 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ -x_t + x_{t+1} + x_{t+2} - x_{t+3} \le 1 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A little bit of thought is needed to decide what to do at the borders,&#xA;especially the first time period.&lt;/p&gt;&#xA;&lt;p&gt;A different approach is detailed&#xA;&lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2018/03/production-scheduling-minimum-up-time.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2021-12-08T14:48:53.613" LastActivityDate="2021-12-08T14:48:53.613" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7405" PostTypeId="2" ParentId="7400" CreationDate="2021-12-08T15:11:33.130" Score="2" Body="&lt;p&gt;This might be a silly question, but what is the incentive to attend the meetings at all? I don't see any constraints considering that. You just want to minimize the time spent on meetings and waiting on them. Solution: do not go to any meetings :) You'd have to constrain your &amp;quot;Boolean constraints&amp;quot; in the description themselves a little. Any possible constraint that could be formulated is a bit too much to be able to say anything about how that problem could be tackled. If the boolean constraint would simply say &amp;quot;you have to attend meeting &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;&amp;quot; then the problem just gets easier, because it's one variable less - but you could formulate all sorts of stuff, so that info is not really helpful.&lt;/p&gt;&#xA;&lt;p&gt;But let's say there was a constraint saying, that you have to attend at least &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; meetings, then i also would suggest modelling the meetings as nodes, with arcs between them with outgoing arcs having the time the meeting took + the time it takes for the next meeting to start. Then you start from a depot and come back there, with the depot having no waiting time and/or process time itself. What you would look for then, would be the shortest tour from the depot, over the nodes, and back to the depot, with the number of visited nodes &amp;gt;= k. Considering the constraints, that you can only attend certain meetings, if you attended other ones (not necessarily directly after one another): you could look at the &amp;quot;SOP (Sequential Ordering Problem)&amp;quot; which is a generalization of the TSP and derive the cuts from there and only cut those off in the callback if they are actually violated.&lt;/p&gt;&#xA;" OwnerUserId="7667" LastEditorUserId="7667" LastEditDate="2021-12-08T15:17:30.700" LastActivityDate="2021-12-08T15:17:30.700" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7406" PostTypeId="1" CreationDate="2021-12-08T17:03:37.567" Score="1" ViewCount="110" Body="&lt;p&gt;I was watching a video about Google &lt;a href=&quot;https://developers.google.com/optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR-Tools&lt;/a&gt; where they were solving &lt;a href=&quot;https://app.codility.com/programmers/task/cover_buildings/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this cover building problem&lt;/a&gt; from Codility challenges using constraint programming.&lt;/p&gt;&#xA;&lt;p&gt;In short, you have a list of building heights, e.g. &lt;code&gt;[3, 1, 4]&lt;/code&gt; and want to cover them with no more than two banners, minimizing the total area.&lt;/p&gt;&#xA;&lt;p&gt;Using the package, this is the model and solution:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def cover_buildings(buildings=None):&#xA;    max_h = max(buildings)&#xA;    max_w = len(buildings)&#xA;&#xA;    model = cp_model.CpModel()&#xA;    banner1 = (model.NewIntVar(1, max_w, 'banner1_w'), model.NewIntVar(1, max_h, 'banner1_h'))&#xA;    banner2 = (model.NewIntVar(0, max_w, 'banner2_w'), model.NewIntVar(0, max_h, 'banner2_h'))&#xA;    banner1_area = model.NewIntVar(1, max_w * max_h, 'banner1_area')&#xA;    banner2_area = model.NewIntVar(0, max_w * max_h, 'banner2_area')&#xA;    # tie banner 2 width to banner 1 width&#xA;    model.Add(banner2[0] == max_w - banner1[0])&#xA;    model.AddMultiplicationEquality(banner1_area, banner1)&#xA;    model.AddMultiplicationEquality(banner2_area, banner2)&#xA;&#xA;    covered_by_banner1 = []&#xA;    for x, height in enumerate(buildings):&#xA;        c1 = model.NewBoolVar('building{}({})_covered_by_banner1'.format(x, height))&#xA;        c2 = model.NewBoolVar('building{}({})_covered_by_banner2'.format(x, height))&#xA;        covered_by_banner1.append(c1)&#xA;        # this building has to be covered by one or the other, but not both&#xA;        model.AddBoolXOr((c1, c2))&#xA;        # if covered by banner 1&#xA;        model.Add(x &amp;lt; banner1[0]).OnlyEnforceIf(c1)&#xA;        model.Add(height &amp;lt;= banner1[1]).OnlyEnforceIf(c1)&#xA;        # if covered by banner 2 (offset by banner 1)&#xA;        model.Add(x &amp;gt;= banner1[0]).OnlyEnforceIf(c2)&#xA;        model.Add(height &amp;lt;= banner2[1]).OnlyEnforceIf(c2)&#xA;&#xA;    model.Minimize(banner1_area + banner2_area)&#xA;&#xA;    solver = cp_model.CpSolver()&#xA;&#xA;    if solver.Solve(model) == cp_model.OPTIMAL:&#xA;        print 'Banner 1: {}x{}'.format(solver.Value(banner1[0]), solver.Value(banner1[1]))&#xA;        print 'Banner 2: {}x{}'.format(solver.Value(banner2[0]), solver.Value(banner2[1]))&#xA;        print 'Total area: {}'.format(solver.Value(banner1_area) + solver.Value(banner2_area))&#xA;        for x, height in enumerate(buildings):&#xA;            covered_by_1 = solver.Value(covered_by_banner1[x])&#xA;            print 'Building {}({}) covered by banner {}.'.format(x, height, '1' if covered_by_1 else '2')&#xA;        print '-' * 90&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, for the case of &lt;code&gt;[7, 7, 3, 7, 7]&lt;/code&gt; the solution is using two banners: 1x7 and 4x7. Which is also optimal because the total area is 35, like the problem at Codility describes. However, I wonder how could I also minimize the total number of banners used?&lt;/p&gt;&#xA;&lt;p&gt;Bonus: how could I generalize this problem to use &lt;code&gt;N&lt;/code&gt; numbers of banners as the minimization objective instead of hardcoding 2?&lt;/p&gt;&#xA;" OwnerUserId="7682" LastEditorUserId="491" LastEditDate="2021-12-08T23:23:00.963" LastActivityDate="2021-12-08T23:23:00.963" Title="Minimizing total number of banners used in the cover buildings problem modelled" Tags="|constraint|constraint-programming|or-tools|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7407" PostTypeId="2" ParentId="7400" CreationDate="2021-12-08T17:21:50.687" Score="3" Body="&lt;p&gt;Another possibility might be column generation. The master problem would start with a predefined collection of feasible schedules for each day, where feasible means (a) no time conflicts and (b) satisfying any &amp;quot;if this meeting then that meeting&amp;quot; or &amp;quot;at least one of these meetings&amp;quot; constraints that involve only meetings on that day. There's a binary variable for each such schedule, and the master problem chooses schedules (one per day) to minimize the sum of their (known) durations subject to the remaining logical constraints (those that span days).&lt;/p&gt;&#xA;&lt;p&gt;For an exact solution, you'll end up using &lt;a href=&quot;https://en.wikipedia.org/wiki/Branch_and_price&quot; rel=&quot;nofollow noreferrer&quot;&gt;branch and price&lt;/a&gt;, which is not known for its speed (but might be faster than your models ... only testing will tell). For an approximate solution, you can apply a variant of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Cutting_stock_problem#Mathematical_formulation_and_solution_approaches&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gilmore-Gomory heuristic&lt;/a&gt; for the one-dimensional cutting stock problem. You solve the LP relaxation of the initial master (which starts with a handful of &amp;quot;obvious&amp;quot; schedules), use the dual solution to calibrate the objective function of a subproblem that generates a new schedule (one that would have a negative reduced cost in the master LP), add that column, rinse and repeat. When no new columns are found, you revert the master to an integer program and solve.&lt;/p&gt;&#xA;&lt;p&gt;Getting away from branch and price/column generation, you might also consider using a constraint programming (CP) model rather than a MIP model. Some constraint solvers are pretty good at handling scheduling models. They typically have &amp;quot;global&amp;quot; constraints for non-overlap (you can't be in two places at once), and they are adept at handling logic constraints (&amp;quot;if this then that&amp;quot;, &amp;quot;at least one of these&amp;quot;, &amp;quot;at most &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; of these&amp;quot;).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-08T17:21:50.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7408" PostTypeId="1" AcceptedAnswerId="7410" CreationDate="2021-12-08T17:59:55.903" Score="1" ViewCount="328" Body="&lt;p&gt;I am working on a scheduling problem in OR-Tools using the CP-SAT solver.&lt;/p&gt;&#xA;&lt;p&gt;I'm working with&#xA;python but I managed to rebuild this solution as starting point:&#xA;&lt;a href=&quot;https://or.stackexchange.com/questions/3653/optimal-way-to-ensure-optional-intervals-are-consecutive-in-or-tools?rq=1&amp;amp;newreg=f0ec614e71be4a8986863bc279b3175f&quot;&gt;Optimal way to ensure optional intervals are consecutive in OR-Tools&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Just like in that problem I also have the constraint, that the jobs are consecutive. This works already.&lt;/p&gt;&#xA;&lt;p&gt;My first problem is really easy in my mind, but somehow I cant make it work: the first job on each machine MUST start at 0.&lt;/p&gt;&#xA;&lt;p&gt;Second problem: lets say I produce n colors of the same product. Every one of these &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; colors has a maximum &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, which is the maximum number of jobs of the same color I can build in sequence on the same machine.&lt;/p&gt;&#xA;&lt;p&gt;My solution pretty much depends on my &lt;code&gt;x[job,machine]&lt;/code&gt; dict where &lt;code&gt;x[job,machine]&lt;/code&gt; is true if job is performed on machine.&lt;/p&gt;&#xA;" OwnerUserId="7683" LastEditorUserId="981" LastEditDate="2023-02-19T14:49:27.693" LastActivityDate="2023-02-19T14:49:27.693" Title="Circuit constraint respecting the order of the next n jobs / jobs on each machine starting at 0" Tags="|python|scheduling|or-tools|job-shop-scheduling|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7410" PostTypeId="2" ParentId="7408" CreationDate="2021-12-08T18:36:08.503" Score="1" Body="&lt;p&gt;for 1) Look at &lt;a href=&quot;https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/examples/python/jobshop_ft06_distance_sat.py#L91&quot; rel=&quot;nofollow noreferrer&quot;&gt;this literal&lt;/a&gt; in the jobshop with setup times. You just need to add:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.Add(start_of_job == 0).OnlyEnforceIf(start_lit)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For 2) For each color, add for each job a variable ranging from 0 to max_sequence_length for this color.&lt;/p&gt;&#xA;&lt;p&gt;For each &lt;a href=&quot;https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/examples/python/jobshop_ft06_distance_sat.py#L91&quot; rel=&quot;nofollow noreferrer&quot;&gt;arc&lt;/a&gt;, you know if job_i has the same color as job_j. If true, the&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.Add(sequence_length[color][j] = sequence_length[color][i] + 1).OnlyEnforceIf(lit)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;else&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.Add(sequence_length[color_i][j] == 0).OnlyEnforceIf(lit)&#xA;model.Add(sequence_length[color_j][j] == 1).OnlyEnforceIf(lit)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And do not forget to initialize all sequence lengths vars with the &lt;code&gt;start_lit&lt;/code&gt; literal.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2021-12-08T18:36:08.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7411" PostTypeId="1" CreationDate="2021-12-08T21:05:41.467" Score="6" ViewCount="318" Body="&lt;p&gt;For a logistics optimization problem I am working on, the most natural expression of the problem is using a node-arc formulation of the MCNF. It is solved using an LP/MIP solver like CPLEX/Gurobi.&lt;/p&gt;&#xA;&lt;p&gt;However, for understanding the solution, the arc-path formulation has certain attractive properties - it helps the user understand how different parts of the network's flows relate to each other. It is not possible, right now, to convert the formulation to arc-path.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for papers or tutorials which discuss how to convert a solution in node-arc form to a solution in arc-path form.&lt;/p&gt;&#xA;" OwnerUserId="7686" LastEditorUserId="2556" LastEditDate="2021-12-09T09:58:46.880" LastActivityDate="2021-12-09T09:58:46.880" Title="Multi-commodity Network Flow: Convert a node-arc solution to an arc-path solution" Tags="|linear-programming|modeling|integer-programming|reference-request|network-flow|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7412" PostTypeId="1" AcceptedAnswerId="7415" CreationDate="2021-12-08T21:52:00.620" Score="3" ViewCount="71" Body="&lt;p&gt;I want to find good incumbent solutions to the following problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\newcommand{\RR}{\mathbb{R}}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\newcommand{\norm}[1]{\left\Vert#1\right\Vert}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Given a matrix &lt;span class=&quot;math-container&quot;&gt;$W \in \RR^{m \times n}$&lt;/span&gt;, find the maximum number of nonnegative coordinates of &lt;span class=&quot;math-container&quot;&gt;$Wx$&lt;/span&gt;, over &lt;span class=&quot;math-container&quot;&gt;$x \in \RR^n \backslash \{0\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The following linear formulation solves it, however it's not efficient:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  \max_{x \in \RR^n, a \in \RR^m} \quad &amp;amp; \sum_{i=1}^m a_i \\&#xA;  \text{subject to} \quad &amp;amp; \norm{x}_1 = n \\&#xA;                          &amp;amp; -U(1 - a_i) \le w_i^T x \le Ua_i ~\text{for } 1 \le i \le m \\&#xA;                          &amp;amp; a_i \in \{0, 1\}&#xA;  \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; is a large enough scalar, say &lt;span class=&quot;math-container&quot;&gt;$U = n\norm{W}_1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would like to run it on matrices with &lt;span class=&quot;math-container&quot;&gt;$m = 700$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n = 100$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7687" LastActivityDate="2021-12-09T19:02:34.810" Title="Maximizing the number of nonnegative coordinates of $Wx$" Tags="|optimization|mixed-integer-programming|integer-programming|quadratic-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7413" PostTypeId="1" CreationDate="2021-12-08T22:16:40.157" Score="1" ViewCount="490" Body="&lt;p&gt;I am trying to build a constraint of the form &lt;code&gt;x[i j] +x[j i] &amp;lt;y[i][j]&lt;/code&gt; where &lt;code&gt;x&lt;/code&gt; is a decision variable if arc &lt;code&gt;ij&lt;/code&gt; is used.&lt;/p&gt;&#xA;&lt;p&gt;The arcs are defined in terms of tuples. However, not all arcs are available in that &lt;code&gt;[2 3]&lt;/code&gt; is presented while &lt;code&gt;[3 2]&lt;/code&gt; is not.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;y[i][j]&lt;/code&gt; is a decision variable too but it is using nodes (not tuple values) representing if the two nodes are covered by the same trip or not.&lt;/p&gt;&#xA;&lt;p&gt;How can I write this constraint?&lt;/p&gt;&#xA;&lt;p&gt;Note:&#xA;When I run it using this constraint, it uses only same arc tuples&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   forall(i,j in Setlocations :  i &amp;lt; j &amp;amp;&amp;amp; i!=j )&#xA;&#xA;   forall( g in Graph : g.o==j &amp;amp;&amp;amp; g.d==i ) &#xA;&#xA;   forall(m in Graph : m.o==j &amp;amp;&amp;amp; m.d==i) &#xA;    x[g] + x[m]  &amp;lt;= z[i][j] ; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7685" LastEditorUserId="123" LastEditDate="2021-12-09T08:28:53.553" LastActivityDate="2021-12-09T15:45:05.687" Title="Tuples OPL in VRP" Tags="|cplex|constraint|vehicle-routing|opl|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7414" PostTypeId="2" ParentId="7411" CreationDate="2021-12-08T22:31:23.670" Score="7" Body="&lt;p&gt;I don't know any references, but I can suggest a possible approach. For each commodity, generate a set of possible paths from the source of the commodity to the sink of the commodity. Let &lt;span class=&quot;math-container&quot;&gt;$x_a$&lt;/span&gt; be the flow of that commodity on arc &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; in your solution (I'm skipping commodity indices since we'll do each commodity separately) and let &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; be a matrix with &lt;span class=&quot;math-container&quot;&gt;$H_{a,p} = 1$&lt;/span&gt; if arc &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is on path &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and 0 if not. Solve&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;Hy &amp;amp; =x\\&#xA;y &amp;amp; \ge0&#xA;\end{align*}&lt;/span&gt;&#xA;to get the path flows that in aggregate explain the arc flows. You can treat this as an LP if flows are divisible or IP if flows are discrete, with any objective function you like. A more complicated IP model would add a binary variable &lt;span class=&quot;math-container&quot;&gt;$z_p$&lt;/span&gt; for each path &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_p z_p$&lt;/span&gt;, with constraints &lt;span class=&quot;math-container&quot;&gt;$y_p \le F z_p$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is the total flow of the commodity out of its source. That would pick the simplest (least cardinality) set of paths needed to explain the arc flows.&lt;/p&gt;&#xA;&lt;p&gt;One catch is that the problem might be infeasible if you do not generate enough paths, in which case you would need to go back and scrounge up more paths.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-08T22:31:23.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7415" PostTypeId="2" ParentId="7412" CreationDate="2021-12-09T00:07:44.333" Score="4" Body="&lt;p&gt;First, a comment on the MIP model. I assume that the constraint &lt;span class=&quot;math-container&quot;&gt;$\|x\|_1 = n$&lt;/span&gt; is intended to eliminate &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; as a solution. An alternative that works with probability 1 is to generate a random vector &lt;span class=&quot;math-container&quot;&gt;$r\in \mathbb{R}^n$&lt;/span&gt; from a continuous distribution, say uniform over &lt;span class=&quot;math-container&quot;&gt;$[-1,1]^n$&lt;/span&gt;, normalize it so that &lt;span class=&quot;math-container&quot;&gt;$\|r\|_2=1$&lt;/span&gt;, and use the normalization constraint &lt;span class=&quot;math-container&quot;&gt;$r^\prime x = 1$&lt;/span&gt;. This works unless the optimal &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is orthogonal to &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;, which has probability 0 of occurring given that the distribution of &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; is uniform over a region with positive volume. The reason I suggest this is that eliminates any binary variables added (either by you or the solver) to deal with absolute values.&lt;/p&gt;&#xA;&lt;p&gt;As far as generating a &amp;quot;good&amp;quot; incumbent, you can apply a number of different metaheuristics. I tried a genetic algorithm (coded in R) on a randomly generated matrix &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt;. The GA converges in under a minute on my PC using your dimensions (700 x 100), but to compare it to the optimal solution (computed using CPLEX) I scaled the matrix down to 70 x 10. (I tried 700 x 100, but CPLEX did not look as if it was going to terminate in what was an acceptable time for me.) My first trial at 70 x 10 produced an optimal solution with 54 nonzeros versus a GA solution with 51. A retry with a different random number seed yielded an optimum of 59 nonzeros and a GA solution with 57.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-12-09T19:02:34.810" LastActivityDate="2021-12-09T19:02:34.810" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7416" PostTypeId="2" ParentId="7411" CreationDate="2021-12-09T04:56:16.680" Score="6" Body="&lt;p&gt;You can generate such a &lt;em&gt;flow decomposition&lt;/em&gt; dynamically by treating each arc flow as an arc capacity and solving a maximum capacity s-t path problem to find a path.  Then reduce the arc capacities along this path by the maximum flow value.  Repeat until all arc capacities are &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For a more general approach when you do not have a specified source and sink, see Section 3.5 of &lt;em&gt;Network Flows&lt;/em&gt;, Ahuja, Magnanti, Orlin (1993).&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-12-09T05:07:08.913" LastActivityDate="2021-12-09T05:07:08.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7417" PostTypeId="2" ParentId="7413" CreationDate="2021-12-09T15:45:05.687" Score="1" Body="&lt;p&gt;in &lt;a href=&quot;https://www.linkedin.com/pulse/how-opl-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to with OPL&lt;/a&gt; I shared a few TSP starting points.&lt;/p&gt;&#xA;&lt;p&gt;TSP with remove circuits is an easy one.&lt;/p&gt;&#xA;&lt;p&gt;.mod&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; // Cities&#xA;int     n       = ...;&#xA;range   Cities  = 1..n;&#xA;&#xA;// Edges -- sparse set&#xA;tuple       edge        {int i; int j;}&#xA;setof(edge) Edges       = {&amp;lt;i,j&amp;gt; | ordered i,j in Cities};&#xA;int         dist[Edges] = ...;&#xA;&#xA;// Decision variables&#xA;dvar boolean x[Edges];&#xA;&#xA; {int} nodes={i.i | i in Edges} union {i.j | i in Edges};&#xA;&#xA;range r=1..-2+ftoi(pow(2,card(nodes)));&#xA;&#xA;&#xA;{int} nodes2 [k in r] = {i | i in nodes: ((k div (ftoi(pow(2,(ord(nodes,i))))) mod 2) == 1)};&#xA;&#xA; &#xA;&#xA; &#xA;&#xA;/*****************************************************************************&#xA; *&#xA; * MODEL&#xA; *&#xA; *****************************************************************************/&#xA;&#xA;// Objective&#xA;minimize sum (&amp;lt;i,j&amp;gt; in Edges) dist[&amp;lt;i,j&amp;gt;]*x[&amp;lt;i,j&amp;gt;];&#xA;subject to {&#xA;   &#xA;   // Each city is linked with two other cities&#xA;   forall (j in Cities)&#xA;        sum (&amp;lt;i,j&amp;gt; in Edges) x[&amp;lt;i,j&amp;gt;] + sum (&amp;lt;j,k&amp;gt; in Edges) x[&amp;lt;j,k&amp;gt;] == 2;&#xA;        &#xA;   // Subtour elimination constraints.&#xA; &#xA;   &#xA;forall(k in r)  // all subsets but empty and all&#xA;    sum(e in Edges:(e.i in nodes2[k]) &amp;amp;&amp;amp; (e.j in nodes2[k])) x[e]&amp;lt;=card(nodes2[k])-1;  &#xA;&#xA; }  &#xA; &#xA; &#xA; setof(edge) solEdges       ={e | e in Edges : x[e]==1};&#xA; execute&#xA; {&#xA;   writeln(solEdges);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2021-12-09T15:45:05.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7419" PostTypeId="1" CreationDate="2021-12-09T21:08:55.137" Score="2" ViewCount="345" Body="&lt;p&gt;I intend to generate a binary sequence with a size of &lt;span class=&quot;math-container&quot;&gt;$N = 10$&lt;/span&gt;, for example, &lt;span class=&quot;math-container&quot;&gt;$[1, 0, 0, 0, 0, 1, 1, 1, 0, 0]$&lt;/span&gt;. The constraint is that when zero appears, it must appear for at least two consecutive times, such as &lt;span class=&quot;math-container&quot;&gt;$[1, 0, 0, 1] $&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$[1, 0, 0, 0, 1]$&lt;/span&gt;. In contrast, &lt;span class=&quot;math-container&quot;&gt;$[1, 0, 1]$&lt;/span&gt; is not good since zero has appeared for only one time. Previously I have asked a similar question with minimum consecutive one requirement &lt;a href=&quot;https://or.stackexchange.com/questions/7403/how-to-construct-my-mixed-integer-programming-problem-with-constraint-of-minimum&quot;&gt;here&lt;/a&gt;. But this time the requirement is changed into zeros. I know I can simply define a new variable which convert this &amp;quot;zeros&amp;quot; constraint to &amp;quot;ones&amp;quot; constraint. But I am curious how mathematical formulations will vary.&lt;/p&gt;&#xA;" OwnerUserId="7681" LastEditorUserId="491" LastEditDate="2022-03-13T23:12:26.683" LastActivityDate="2022-03-13T23:12:26.683" Title="How to make a constraint for consecutive zeros in the mixed integer programming problems" Tags="|mixed-integer-programming|binary-variable|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7421" PostTypeId="1" CreationDate="2021-12-10T10:56:29.557" Score="1" ViewCount="148" Body="&lt;p&gt;I have a Linear program (LP) that can solve problem X with two objective functions a and b, I use the weighted sum method. I use Gurobi solver when I optimize the objective alone, the problem takes a lot of time (high complexity) and when I optimize only objective b the problem is solved in a few seconds.&lt;/p&gt;&#xA;&lt;p&gt;I have implemented metaheuristic PSO using weighted sum and compared it with several metaheuristics. The problem is that the PSO find always the best solution for objective a and finds the worst value in terms of objective b.&lt;/p&gt;&#xA;&lt;p&gt;So, I try to solve objective a using PSO, then solve objective b using Gurobi(solve my LP while making the first objective as a constraint)&lt;/p&gt;&#xA;&lt;p&gt;With such a method, can I find the Pareto front? This method can be called hybrid PSO-LP? Have you other suggestions to solve my problem?&lt;/p&gt;&#xA;" OwnerUserId="7281" LastEditorUserId="3179" LastEditDate="2021-12-10T17:24:35.357" LastActivityDate="2021-12-10T17:24:35.357" Title="Hybrid metaheuristic and linear program?" Tags="|linear-programming|gurobi|heuristics|metaheuristics|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7423" PostTypeId="1" AcceptedAnswerId="7429" CreationDate="2021-12-10T14:56:01.543" Score="4" ViewCount="1097" Body="&lt;p&gt;In solving a linear program (in specific a network optimization problem of the shortest path type) with the Excel solver, I noticed two things after running a sensitivity report on the solution suggested by the solver:&lt;/p&gt;&#xA;&lt;p&gt;First, both the allowable increase as well as the allowable decrease were positive for all variables, which indicates that the solution suggested is a unique optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;Second, the final value as well as the reduced cost were both 0 for multiple variables, which usually indicates that these variables are part of another Corner Point Feasible solution at another optimal corner.&lt;/p&gt;&#xA;&lt;p&gt;These two observations obviously contradict one another, which is quite confusing. The solution is definitely the only optimal solution for the problem.&lt;/p&gt;&#xA;&lt;p&gt;Presented below are the optimization problem and the Sensitivity Report. The objective was to find the shortest path from SE to LN.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/anE52.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/anE52.png&quot; alt=&quot;Sensitivity Report&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/PfaS7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PfaS7.png&quot; alt=&quot;Problem Setting&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7695" LastEditorUserId="491" LastEditDate="2021-12-13T15:00:15.437" LastActivityDate="2021-12-13T15:00:15.437" Title="Why are the final value and reduced cost 0 in excel sensitivity report for multiple variables even though there exists a unique optimal solution?" Tags="|excel|sensitivity-analysis|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7424" PostTypeId="1" AcceptedAnswerId="7431" CreationDate="2021-12-10T17:59:02.663" Score="2" ViewCount="361" Body="&lt;p&gt;I have a linear program, where I can use it with the same constraint to minimize objective 1 or minimize objective 2. I noted that when I use the formula of objective 2 the problem can be solved with large instances in polynomial time whereas when I use objective 1 that takes a long time for medium instance. When that can occur?&lt;/p&gt;&#xA;" OwnerUserId="7281" LastEditorUserId="123" LastEditDate="2021-12-10T22:00:52.333" LastActivityDate="2021-12-11T08:50:26.417" Title="Change the objective function formula change the complexity of a linear program?" Tags="|linear-programming|combinatorial-optimization|linearization|reformulation-linearization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7425" PostTypeId="1" AcceptedAnswerId="7428" CreationDate="2021-12-10T18:34:13.880" Score="7" ViewCount="722" Body="&lt;p&gt;I understand that RAM required for optimization problem is problem specific and some problems require much more memory. I am thinking how much RAM I need for my system and need to decide between getting 32 GB or 64 GB. The processor has 24 threads which means using more threads will require more RAM. Is 32 GB RAM enough for most optimization problems of the form LP, MILP, QP and MIQP problems?&lt;/p&gt;&#xA;" OwnerUserId="3896" LastActivityDate="2022-05-05T02:55:38.187" Title="RAM requirement for optimization problems" Tags="|mixed-integer-programming|computational-complexity|parallel-computing|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7426" PostTypeId="1" AcceptedAnswerId="7430" CreationDate="2021-12-10T19:15:52.003" Score="3" ViewCount="80" Body="&lt;p&gt;A certain goal program I've been working on has three goals that each operate at different scales.&lt;/p&gt;&#xA;&lt;p&gt;Two of the goals stay between 0-10, so any deviation from the goal is generally only a couple of &amp;quot;points&amp;quot; away from the goal.&lt;/p&gt;&#xA;&lt;p&gt;The third goal has a much larger scale (its a measure of distance travelled), so the deviations from the goal can range from 10s of &amp;quot;points&amp;quot; away to 100s, depending on the solution.&lt;/p&gt;&#xA;&lt;p&gt;Because of this difference in magnitude of the deviations derived from each goal, the model has an implicit bias towards satisfying the third goal as closely as possible.&lt;/p&gt;&#xA;&lt;p&gt;I suppose one could normalize all the goals such that they're on the same scale or maybe weight the goals such that the larger magnitude one gets truncated down to be comparable to the others.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Is there a standard practice for dealing with these scale differences in a goal program?&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="7672" LastActivityDate="2021-12-10T21:51:29.650" Title="Goal Programming -- Best practice for standardizing magnitude of deviations across goals?" Tags="|reference-request|multi-objective-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7427" PostTypeId="2" ParentId="7424" CreationDate="2021-12-10T19:16:07.567" Score="2" Body="&lt;p&gt;Draw a unit circle around the origin in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^2$&lt;/span&gt; and consider the quarter of it in the first (nonnegative) quadrant. Now pick a large number of points on the circle and make them, along with &lt;span class=&quot;math-container&quot;&gt;$(0,0)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(0,1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(1,0)$&lt;/span&gt;, the corner points of your feasible region.&lt;/p&gt;&#xA;&lt;p&gt;Now, starting at the origin, count the number of corner points you need to pass through to maximize &lt;span class=&quot;math-container&quot;&gt;$x_1 + x_2$&lt;/span&gt; (a bunch) and the number of corner points you need to pass through to maximize &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; (one). Each corner visited is one pivot of the primal simplex algorithm.&lt;/p&gt;&#xA;&lt;p&gt;If it takes a large number of pivots to reach the optimum for one objective, you might try an interior point method, which might (or might not) be faster.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-10T19:16:07.567" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7428" PostTypeId="2" ParentId="7425" CreationDate="2021-12-10T19:26:20.003" Score="10" Body="&lt;p&gt;Easy answer: 64 GB&lt;/p&gt;&#xA;&lt;p&gt;With 24 threads (is this already including hyperthreads? Maybe not, so we are actually talking about 48 threads...) you'll have about 2 and a half GB for every thread - that's not very much if you really want to make good use of those threads. So going for 32 GB is definitely the wrong move and you'll most likely regret this choice.&lt;/p&gt;&#xA;&lt;p&gt;AFAIK, every competitive optimization solver treats memory as a more or less abundant resource and will often have no difficulties filling it up. You are more likely to use some parameter settings to avoid out-of-memory issues even with 64 GB, so if possible, you should go for even more memory.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2021-12-10T19:26:20.003" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7429" PostTypeId="2" ParentId="7423" CreationDate="2021-12-10T19:55:37.113" Score="2" Body="&lt;p&gt;Consider the following LP:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\max\,3x_{1}+5x_{2}\\&#xA;\textrm{s.t. }x_{1}+2x_{2} &amp;amp; +s_{1}=3\\&#xA;2x_{1}+x_{2} &amp;amp; +s_{2}=3\\&#xA;x_{1}+x_{2} &amp;amp; +s_{3}=2\\&#xA;x,s &amp;amp; \ge0&#xA;\end{align*}&lt;/span&gt;&#xA;(&lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; being slack variables). The feasible region has corners (0, 0), (0, 1.5), (1, 1) and (1.5, 0), with (1, 1) the unique optimum. If you choose the &lt;span class=&quot;math-container&quot;&gt;$(x_1, x_2, s_3)$&lt;/span&gt; as your basis, I think you will find that variable &lt;span class=&quot;math-container&quot;&gt;$s_3$&lt;/span&gt; has reduced cost 0 and optimal value 0. This is a result of the optimal solution being degenerate. So you might want to check whether your solution is also degenerate (more 0 values, including any slacks and surpluses, than the dimension of the solution space excluding slacks and surpluses).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-10T19:55:37.113" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="7430" PostTypeId="2" ParentId="7426" CreationDate="2021-12-10T21:51:29.650" Score="2" Body="&lt;p&gt;I'm not sure I would use the word &amp;quot;standard&amp;quot;, but a common practice is to scale the goals so that they are commensurable.&lt;/p&gt;&#xA;&lt;p&gt;There are also multiobjective approaches that are less affected by scaling. For instance, if you use preemptive priorities, the solution approach is to optimize the highest priority objective, lock in its value via a constraint, optimize the second highest priority objective, etc. The scales of the objectives are irrelevant with that method. If you assign goals for each objective and prioritize them, a similar approach applies, with the difference that rather than locking in the attained value of a higher priority objective you lock in the smaller of the attained value or the goal (assuming more is better for that objective; use the higher value if less is better). The catch with either of these is that an absolute prioritization is required.&lt;/p&gt;&#xA;&lt;p&gt;Yet another possibility, albeit a costly one in many cases, is to enumerate the Pareto frontier (or at least the extreme points of the Pareto frontier), then let the decision maker pick a winner. That too makes no assumptions about scaling.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-10T21:51:29.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7431" PostTypeId="2" ParentId="7424" CreationDate="2021-12-11T08:50:26.417" Score="1" Body="&lt;p&gt;It is not uncommon that with different objective functions, there are different complexity that comes with the specific problem. For example, in the scheduling theory, it is often of interest to determine the borderline between polynomial-time problems and NP-hard problems. In order to determine the exact boundaries, it is necessary to find the “hardest” or the “most general” problems that still can be solved in polynomial time. These problems are characterized by the fact that any generalization, e.g., the inclusion of precedence constraints, results in NP-hardness, either in the ordinary sense or strongly.&lt;/p&gt;&#xA;&lt;p&gt;For comparison, in the following, there are three different classes of the problem and their specific solvable complexity:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{1} \ | \ r_j, p_j=1, prec \ | \ \sum{C_j} $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{1} \ | \ r_j, prmp \ | \ \sum{C_j} $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;are Polynomial-Time Solvable Problems while:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{1} \ |  | \ \sum{w_jU_j} $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{1} \ |  | \ \sum{T_j} $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;are NP-Hard in the Ordinary Sense and:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{1} \ | s_{j,k} | \ C_{max} $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{1} \ | \ r_j \ | \ \sum{C_j} $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;are Strongly NP-Hard Problems.&lt;/p&gt;&#xA;&lt;p&gt;The above examples obviously turn out that, changing the objective functions can significantly change the solving time, specifically, if one would like to use multi-objective optimization.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-12-11T08:50:26.417" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7432" PostTypeId="1" CreationDate="2021-12-11T09:42:59.120" Score="3" ViewCount="136" Body="&lt;p&gt;I have a problem which is formulating a linear program. To solve large instances I implement a metaheuristic to solve my problem. In my problem, I have two objective functions.&lt;/p&gt;&#xA;&lt;p&gt;With my linear program, I can minimize the second objective in polynomial time. So I test to solve the first objective function using metaheuristic and then take the result and make it a constraint in my linear program and solve the linear program to minimize the second objective. Is this method valid?&lt;/p&gt;&#xA;" OwnerUserId="7281" LastEditorUserId="123" LastEditDate="2021-12-11T10:32:38.227" LastActivityDate="2021-12-11T10:32:38.227" Title="Are there hybrid metaheuristic-solvers to solve combinatorial optimization problems?" Tags="|linear-programming|solver|combinatorial-optimization|metaheuristics|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7433" PostTypeId="2" ParentId="7241" CreationDate="2021-12-11T10:21:26.910" Score="4" Body="&lt;p&gt;While the @hakank answer is pretty nice and useful, I found exactly what I was looking for:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://pysathq.github.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PySAT, SAT Technology in Python&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;With PySAT, via the &lt;a href=&quot;https://pypi.org/project/pypblib/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PyPBLIB&lt;/a&gt;, it is possible to write high-level pseudo-boolean formulas (e.g., &lt;code&gt;at-least-k&lt;/code&gt;,&lt;code&gt;at-most-k&lt;/code&gt;,&lt;code&gt;at-exactly-k&lt;/code&gt;, &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I} a_i x_i \leq b$&lt;/span&gt;, ...), and then to get the global CNF formula, which can be dumped in a standard &lt;a href=&quot;http://www.domagoj-babic.com/uploads/ResearchProjects/Spear/dimacs-cnf.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;DIMACS SAT file&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, you can easily switch from one  SAT solver to another.&#xA;The list of &lt;a href=&quot;https://pysathq.github.io/docs/html/api/solvers.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;SAT solvers available via PySAT&lt;/a&gt; is in the online documentation.&lt;/p&gt;&#xA;&lt;p&gt;What is very nice, is that you can experiment with the different encoding of the same constraint, like &lt;em&gt;binary decision diagrams (BDD)&lt;/em&gt;, &lt;em&gt;sequential weight counters&lt;/em&gt;, &lt;em&gt;sorting networks&lt;/em&gt;, &lt;em&gt;adder networks&lt;/em&gt;, ... you can find even more encoding in the &lt;a href=&quot;https://pysathq.github.io/docs/html/api/pb.html#module-details&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And (&lt;em&gt;YES!&lt;/em&gt;) the fact that is accessible via Python is a plus.&lt;/p&gt;&#xA;" OwnerUserId="171" LastActivityDate="2021-12-11T10:21:26.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7434" PostTypeId="1" AcceptedAnswerId="7435" CreationDate="2021-12-12T15:21:46.630" Score="2" ViewCount="282" Body="&lt;p&gt;I have two random binary sequences of the same size, denoted as P1 and P2 respectively here. Let's say they are both the size of ten, like P1 = [1,0,1,1,0,0,0,1,1,1], P2 = [0,1,1,0,0,1,0,0,1,1]. I want to add a constraint such that when zero starts to appear in either P1 or P2, it must appear for exact consecutive two times in both P1 and P2.&lt;/p&gt;&#xA;&lt;p&gt;Like when P1 = [1&lt;strong&gt;00&lt;/strong&gt;00&lt;strong&gt;00&lt;/strong&gt;111], then P2 can be like [0&lt;strong&gt;00&lt;/strong&gt;11&lt;strong&gt;00&lt;/strong&gt;000]. In this example, P1 changes from 1 to 0 at the first element and the second element, hence the second element and the third element must be zero together, which also applies to P2 simultaneously. Also, P2 changes from 1 to 0 at the fifth element and sixth element. Hence, the sixth element and seventh element must be zero, which applies to P1 again.&lt;/p&gt;&#xA;&lt;p&gt;Mathematically, it will be something like if P1[i]- P1[i+1] = 1 (this indicates P1[i+1] =0 and P1[i] =1), or P2[i] - P2[i+1] =1; then P1[i+1]=P1[i+2] = 0 and P2[i+1] = P2[i+2] = 0, where i belongs to[1,8].&#xA;I wonder how to add such constraint in mixed integer programming.&lt;/p&gt;&#xA;" OwnerUserId="7681" LastEditorUserId="491" LastEditDate="2021-12-13T15:01:43.847" LastActivityDate="2021-12-13T15:01:43.847" Title="mixed integer programming with if then statement for two binary sequences" Tags="|mixed-integer-programming|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7435" PostTypeId="2" ParentId="7434" CreationDate="2021-12-12T16:48:06.997" Score="4" Body="&lt;p&gt;You want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;((P_{1.i} \land \lnot P_{1,i+1}) \lor (P_{2,i} \land \lnot P_{2,i+1})) \implies (\lnot P_{1,i+1} \land \lnot P_{1,i+2} \land \lnot P_{2,i+1} \land \lnot P_{2,i+2}) $$&lt;/span&gt;&#xA;Rewrite in conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(¬P_{1,i} ∨ P_{1,i+1} ∨ ¬P_{1,i+2}) ∧ (¬P_{1,i} ∨ P_{1,i+1} ∨ ¬P_{2,i+1}) ∧ (¬P_{1,i} ∨ P_{1,i+1} ∨ ¬P_{2,i+2}) ∧ (¬P_{1,i+1} ∨ ¬P_{2,i} ∨ P_{2,i+1}) ∧ (¬P_{1,i+2} ∨ ¬P_{2,i} ∨ P_{2,i+1}) ∧ (¬P_{2,i} ∨ P_{2,i+1} ∨ ¬P_{2,i+2})&#xA;$$&lt;/span&gt;&#xA;This immediately yields linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(1-P_{1,i} + P_{1,i+1} + 1-P_{1,i+2} \ge 1) ∧ (1-P_{1,i} + P_{1,i+1} + 1-P_{2,i+1}\ge 1) ∧ (1-P_{1,i} + P_{1,i+1} + 1-P_{2,i+2}\ge 1) ∧ (1-P_{1,i+1} + 1-P_{2,i} + P_{2,i+1}\ge 1) ∧ (1-P_{1,i+2} + 1-P_{2,i} + P_{2,i+1}\ge 1) ∧ (1-P_{2,i} + P_{2,i+1} + 1-P_{2,i+2}\ge 1)&#xA;$$&lt;/span&gt;&#xA;Equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;P_{1,i} - P_{1,i+1} + P_{1,i+2} &amp;amp;\le 1 \\&#xA;P_{1,i} - P_{1,i+1} + P_{2,i+1} &amp;amp;\le 1 \\&#xA;P_{1,i} - P_{1,i+1} + P_{2,i+2} &amp;amp;\le 1 \\&#xA;P_{2,i} - P_{2,i+1} + P_{1,i+1} &amp;amp;\le 1 \\&#xA;P_{2,i} - P_{2,i+1} + P_{1,i+2} &amp;amp;\le 1 \\&#xA;P_{2,i} - P_{2,i+1} + P_{2,i+2} &amp;amp;\le 1&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2021-12-12T16:48:06.997" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7436" PostTypeId="1" CreationDate="2021-12-12T18:24:03.067" Score="0" ViewCount="98" Body="&lt;p&gt;Given a linear program, by experimentation, I can see that the solver can solve large instances in a few seconds. How can I prove that my LP is in polynomial time, or can we say that it is just by experimentation?&lt;/p&gt;&#xA;" OwnerUserId="7281" LastEditorUserId="123" LastEditDate="2021-12-12T19:40:42.577" LastActivityDate="2021-12-12T19:40:42.577" Title="How can we prove the solvability time of a linear program?" Tags="|linear-programming|solver|computational-complexity|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7437" PostTypeId="2" ParentId="7436" CreationDate="2021-12-12T19:30:54.113" Score="2" Body="&lt;p&gt;I have not seen anyone proving something like that.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2021-12-12T19:30:54.113" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7438" PostTypeId="1" CreationDate="2021-12-13T04:20:28.630" Score="3" ViewCount="87" Body="&lt;p&gt;I would like to approximate the following objective function using a simpler function that can use be defined in gurobi.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \min_{I_{i,v}} \ \sum^{N_v}_{v}\sum^{TT_v}_{i} \ C_{loss,cyc}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9a5Ih.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9a5Ih.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The only continuous decision variable is (electrical) Current, &lt;span class=&quot;math-container&quot;&gt;$ I_{i,v}$&lt;/span&gt; The variable, &lt;span class=&quot;math-container&quot;&gt;$SOC_{init}$&lt;/span&gt; is a function of (electrical) Current values from the  previous timeslot. &lt;span class=&quot;math-container&quot;&gt;$$SOC_{init} = I_{i-1,v}* \Delta t$$&lt;/span&gt; Therefore &lt;span class=&quot;math-container&quot;&gt;$SOC_{init}$&lt;/span&gt; should NOT be considered as a constant. Everything else in the objective function is a constant. The following are constants:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ a = -4.092 \cdot 10^{-4} , b = -2.167 , c = 1.408 \cdot 10^{-5}, d = 6.130, E_a = 7806, R = 8.3145 , T_{ref} = 28, \Delta t = 0.1, SOC_{init} \in [0,1], C_{bat} = 270, T = 50 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have added the constraints to the problem below. Constants in the constraints are &lt;span class=&quot;math-container&quot;&gt;$$ I_{max}, I_{c,max}, T^{dep}_{v},t_s,  SOC^{dep}_{v}, SOC_{-1,v}, SOC_{xtra}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Y1Ewz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Y1Ewz.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Explaination of the optimization problem.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;In a charging station, that has &lt;span class=&quot;math-container&quot;&gt;$N_v$&lt;/span&gt; vehicles that needs to be charged to some state of charge &lt;span class=&quot;math-container&quot;&gt;$SOC^{dep}_v$&lt;/span&gt; within some departure time &lt;span class=&quot;math-container&quot;&gt;$T^{dep}_v$&lt;/span&gt;. The charging schedule for each vehicle, v is thus split into timeslots, i of width &lt;span class=&quot;math-container&quot;&gt;$\Delta t$&lt;/span&gt; each for &lt;span class=&quot;math-container&quot;&gt;$TT_{v}$&lt;/span&gt; number of slots. Within a timeslot, i the current &lt;span class=&quot;math-container&quot;&gt;$I_{i,v}$&lt;/span&gt; is constant. &lt;span class=&quot;math-container&quot;&gt;$t_s $&lt;/span&gt; is just starting time of optimization implementation. The objective is trying to minimize the Electric vehicle's battery capacity loss.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;QUESTION&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I plotted out the objective for different values of current &lt;span class=&quot;math-container&quot;&gt;$I_{i,v}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$SOC_{init} \in [0,1]$&lt;/span&gt; as shown below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/INYmu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/INYmu.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would like to know a simpler function to approximate this family of functions. I have already tried the MATLAB curve fitting tool and found fourier series and sum of sines to create good fits. somehow, sums of exponentials are UNABLE to fit these functions.&lt;/p&gt;&#xA;&lt;p&gt;Note we want to minimize a concave objective function.&lt;/p&gt;&#xA;&lt;p&gt;Now, I need to connect the different plots through &lt;span class=&quot;math-container&quot;&gt;$SOC_{init}$&lt;/span&gt; which is a function of current from previous timeslots. How can I do this? We need to be careful about not multiplying  &lt;span class=&quot;math-container&quot;&gt;$SOC_{init} and I_{i,v}$&lt;/span&gt; in our new function approximation as this would make the new function approximation non-linear. Can you suggest such a new function approximation?&lt;/p&gt;&#xA;&lt;p&gt;I need a linear function because this is part of a multi-objective problem that I am solving using gurobi.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to define these curves as piece-wise linear? and Could you please suggest some functions to approximate these curves.&lt;/p&gt;&#xA;&lt;p&gt;It is even possible to restrict the domain of &lt;span class=&quot;math-container&quot;&gt;$I_{i,v} \in [0,100]$&lt;/span&gt; instead of up to 300A.&lt;/p&gt;&#xA;&lt;p&gt;The following functions are avialble in gurobi to define objective functions. These functions are automatically piece-wise linearlized by gurobi. so we can add any of these functions together but cannot multiply them. I would like to use these or other gurobi functions that you can suggest.&lt;/p&gt;&#xA;&lt;p&gt;• GRBaddgenconstrMax&#xA;• GRBaddgenconstrMin&#xA;• GRBaddgenconstrAbs&#xA;• GRBaddgenconstrAnd&#xA;• GRBaddgenconstrOr&#xA;• GRBaddgenconstrIndicator&#xA;• GRBaddgenconstrPWL&#xA;• GRBaddgenconstrPoly&#xA;• GRBaddgenconstrExp&#xA;• GRBaddgenconstrExpA&#xA;• GRBaddgenconstrLog&#xA;• GRBaddgenconstrLogA&#xA;• GRBaddgenconstrPow&#xA;• GRBaddgenconstrSin&#xA;• GRBaddgenconstrCos&#xA;• GRBaddgenconstrTan:&lt;/p&gt;&#xA;" OwnerUserId="4945" LastEditorUserId="491" LastEditDate="2021-12-13T15:00:51.097" LastActivityDate="2021-12-13T15:00:51.097" Title="Function approximation of a complex objective function" Tags="|linear-programming|linearization|approximation|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7439" PostTypeId="1" AcceptedAnswerId="7442" CreationDate="2021-12-13T16:02:11.460" Score="2" ViewCount="937" Body="&lt;p&gt;In a simple cost minimizing problem, how do I model the following constraint?&lt;/p&gt;&#xA;&lt;p&gt;A dealer can supply up to 100 units at a cost of \$1240 per unit and a one time delivery fee of \$900. If however, 100 to 150 units are purchased, the dealer charges \$1210 per unit for the additional units beyond 100 with an additional delivery fee of \$700.&lt;/p&gt;&#xA;&lt;p&gt;Now I know that binary variables need to be used, but not sure how.&lt;/p&gt;&#xA;" OwnerDisplayName="user7537" LastEditorUserId="2599" LastEditDate="2021-12-13T17:00:44.927" LastActivityDate="2021-12-13T19:31:34.097" Title="How to write &quot;discount above a certain number sold&quot; constraint?" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7440" PostTypeId="2" ParentId="7386" CreationDate="2021-12-13T16:23:28.790" Score="2" Body="&lt;p&gt;The blog entry &lt;a href=&quot;https://mathmodelsblog.wordpress.com/tag/hazard-rate-function/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Defining Hazard Rate at a Point Mass&lt;/a&gt;.&#xA;&amp;quot;Applied Probability and Statistics in Actuarial Science and Financial Economics&amp;quot;, contains what is needed to answer the question.&lt;/p&gt;&#xA;&lt;p&gt;Define the Hazard Rate Function &lt;span class=&quot;math-container&quot;&gt;$h_T(t) = \frac {P(T = t)}{P(T \ge t)}$&lt;/span&gt;, at discrete mass points t.&lt;/p&gt;&#xA;&lt;p&gt;First I will assume &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a nonnegative continuous variable, as implied by mention of pdf of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;. I will also assume &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is positive.&lt;/p&gt;&#xA;&lt;p&gt;The question seems to make more sense if &lt;span class=&quot;math-container&quot;&gt;$Y = a$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$X \ge a$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$Y = \text{min}(X,a)$&lt;/span&gt;. In that case, there is a discrete mass point of &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, and the hazard rate function of &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, and the usual hazard rate applies for &lt;span class=&quot;math-container&quot;&gt;$X &amp;lt; a$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If instead, &lt;span class=&quot;math-container&quot;&gt;$Y = 0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$X \ge a$&lt;/span&gt;, then there is a discrete mass point of &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, and the hazard rate function of &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$P(X \ge a)$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; (because the denominator of the hazard rate function is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;); and the usual hazard rate applies for &lt;span class=&quot;math-container&quot;&gt;$X &amp;lt; a$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, in order to handle your question about &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; being Geometric, assume that &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a discrete nonnegative variable, and &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is a positive integer.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is Geometric with parameter &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, the hazard rate function of &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; for all nonnegative integers, except at &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;.   If &lt;span class=&quot;math-container&quot;&gt;$Y = \text{min}(X,a)$&lt;/span&gt;, the hazard rate function of &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$Y = a$&lt;/span&gt;.  If, instead, &lt;span class=&quot;math-container&quot;&gt;$Y = 0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$X \ge a$&lt;/span&gt;, the hazard rate function of &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$p + (1-p)^a$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2021-12-13T16:28:51.790" LastActivityDate="2021-12-13T16:28:51.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7441" PostTypeId="2" ParentId="7439" CreationDate="2021-12-13T16:43:49.267" Score="3" Body="&lt;p&gt;Since there is an additional &amp;quot;fixed&amp;quot; cost (delivery fee), you will need a binary variable indicating whether your order went into the upper range. You'll also want two order variables, number of units bought at \$1240 each and number bought at \$1210 each. Finally, you will need constraints that make the binary variable 1 when any units are bought at the lower price and force the number bought at full price to be 100 if the binary is set to 1.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-13T16:43:49.267" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7442" PostTypeId="2" ParentId="7439" CreationDate="2021-12-13T19:31:34.097" Score="3" Body="&lt;p&gt;We want a binary variable that will switch on when we buy over 100 units, thus allowing us to buy up to another 50 units at the reduced cost.&lt;/p&gt;&#xA;&lt;p&gt;We'll have the variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; - # of units bought at original price&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; - # of units bought at reduced price&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; - binary variable indicating we're buying more than 100 units&lt;/p&gt;&#xA;&lt;p&gt;And now our constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \leq x \leq 100$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can only purchase up to 100 units at original price&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \leq y \leq 50z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can only purchase up to 50 units at second price, &lt;em&gt;provided we bought the first 100 units at the original price.&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$100z \leq x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The only way &lt;span class=&quot;math-container&quot;&gt;$z \rightarrow 1$&lt;/span&gt; is when &lt;span class=&quot;math-container&quot;&gt;$x \rightarrow 100$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; has to stay at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; for the constraint to hold.&lt;/li&gt;&#xA;&lt;li&gt;Additionally, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; can still be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$x = 100$&lt;/span&gt;, allowing us to only purchase 100 units (if that were the optimal case).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This leaves us with the following objective:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min 900 + 1240x + 700z + 1210y$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is constrained by &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, so unless &lt;span class=&quot;math-container&quot;&gt;$z \rightarrow 1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; will stay at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7672" LastActivityDate="2021-12-13T19:31:34.097" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7444" PostTypeId="2" ParentId="7397" CreationDate="2021-12-14T12:11:30.770" Score="3" Body="&lt;p&gt;There is less suggestions than I was hoping for, but I guess it's fine, since I finally came up with some ideas of my own, so I figured I'll post it here - maybe someone might need it some day.&lt;/p&gt;&#xA;&lt;p&gt;A little bit of background before the answer: Basically the inequality comes from the work of &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.2015.0666&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tran &lt;em&gt;et al.&lt;/em&gt; (2016)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; on the Unrelated Parallel Machine Scheduling Problem with Sequence-Dependent Setup-Times. There it was used to cut off invalid solutions in their benders-decomposition approach (more exactly branch-and-check). Because of the nature of the problem, they were able to calculate and prove a much tighter &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; value, which resulted in very good cuts. Now I am trying to apply their approach to a different, but similar problem. The difference is, I have a symmetric graph on a Cartesian plane and my nodes have no &amp;quot;processing time&amp;quot; which I can use for &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;--- &lt;em&gt;Edit: I leave this part here for the sake of completeness - for the correct answer please refrain to my edit further below&lt;/em&gt; ---&lt;/p&gt;&#xA;&lt;p&gt;&lt;s&gt;I figured though, that what i can do, is to transform my graph into an asymmetric version, then define a pseudo &amp;quot;process time&amp;quot; for each node, as it's minimum length of the incoming arc, and define the lengths of the outgoing arcs from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$c((i,k)) = p_i + s_{ik}$&lt;/span&gt; and since i got the lengths of the original edges and the values &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; for each node, i can also calculate &lt;span class=&quot;math-container&quot;&gt;$s_{ik}$&lt;/span&gt;. Now that i have the values, i can simply apply their calculation of &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{i} = p_{i} + \max S_{i}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\max S_{i}$&lt;/span&gt; is the maximum value of &lt;span class=&quot;math-container&quot;&gt;$s_{ki} \forall k \in G$&lt;/span&gt;&#xA;and rely on their proof for the validity. All that's left is to prove, that my transformation is correct and bidirectional. This is something i still have to do, but before i am bothered, i ran some tests on few instances and the cuts do not seem to cut off any valid solutions so far. i might edit the answer in the future to provide more detailed explanation (with some graph-examples maybe) when i find the time for :)&lt;/p&gt;&#xA;&lt;p&gt;If by any chance, anyone spots any inconsistency or problems with this approach, i would very much appreciate the feedback!&lt;/s&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Well i did in fact myself spot the problem with this approach. Given that this process times are pseudo and depend on whether some edge is still in the graph, this doesn't work for the cuts and hence also for the lower bound. It basically only holds for a subgragh with exactly 1 fewer node. I did come up with tighter bounds though. I figured: why transforming my graph to the other problem using pseudo process times - i already have that problem, only that my process times are all 0 and all i got are sequence-dependent setup-times. So &lt;span class=&quot;math-container&quot;&gt;$p_{i} = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$max(S_{i})$&lt;/span&gt; is the longest edge adjacent to &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. There is something missing though - and that's &lt;span class=&quot;math-container&quot;&gt;$min(S_{i})$&lt;/span&gt;, the shortest edge adjacent to &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. This is 0 in case of &lt;sup&gt;1&lt;/sup&gt; because the depot is fictional and has no final setup-time so the edge to it is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; from any node. To my understanding the complete equation for &lt;span class=&quot;math-container&quot;&gt;$\delta_{i}$&lt;/span&gt; should be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\theta_{i} = p_{i} + \max_{j \in G} (c_{ji}) + \min_{j \in G} (c_{ij})&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Tran, T. T., Araujo, A., Beck, J. C. (2016). Decomposition methods for the parallel machine scheduling problem with setups. &lt;em&gt;INFORMS Journal on Computing.&lt;/em&gt; 28(1):83-95. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="7667" LastEditorUserId="7667" LastEditDate="2022-02-09T12:19:12.703" LastActivityDate="2022-02-09T12:19:12.703" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7447" PostTypeId="1" CreationDate="2021-12-16T20:52:28.350" Score="2" ViewCount="155" Body="&lt;p&gt;I have the following integer optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\sum_ix_i\\&#xA;\text{s.t.}&amp;amp;\quad Ax \geq b\\&#xA;&amp;amp;\quad x \geq 0,\\&#xA;&amp;amp;\quad x \in \mathbb{Z}^n\end{align}&lt;/span&gt; where&#xA;&lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a general vector of integers,&#xA;&lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; matrix where all entries are integers, but it has a very specific format: it is symmetric, every entry in the main diagonal is equal to the opposite of the sum of its row/column except when &lt;span class=&quot;math-container&quot;&gt;$i=j$&lt;/span&gt;, and if &lt;span class=&quot;math-container&quot;&gt;$i \neq j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$A_{ij}$&lt;/span&gt; is either 0 or 1. I will try to write that more formally.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}A_{ij} &amp;amp;\in \{0, 1\}\quad\text{if}\quad i \neq j\\A_{ii} &amp;amp;= -\sum_{j=0,j \neq i}^{n-1}A_{ij} = -\sum_{j=0,j \neq i}^{n-1}A_{ji}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Example of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{bmatrix}&#xA;-3 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0 &amp;amp; 1\\&#xA;1 &amp;amp; -3 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0\\&#xA;1 &amp;amp; 1 &amp;amp; -3 &amp;amp; 0 &amp;amp; 1\\&#xA;0 &amp;amp; 1 &amp;amp; 0 &amp;amp; -2 &amp;amp; 1\\&#xA;1 &amp;amp; 0 &amp;amp; 1 &amp;amp; 1 &amp;amp; -3\\&#xA;\end{bmatrix}&#xA;$$&lt;/span&gt;&#xA;According to wikipedia, a general ILP is NP-hard. How do I:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Prove this specific format is still NP-hard (probably by some reduction) or find that this is a special case that can be solved in polynomial time?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Find if it's feasible without actually solving the optimization problem?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8721" LastEditorUserId="8721" LastEditDate="2021-12-16T21:00:31.547" LastActivityDate="2021-12-16T22:15:39.613" Title="Is this integer optimization problem still NP?" Tags="|optimization|integer-programming|computational-complexity|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7448" PostTypeId="2" ParentId="7447" CreationDate="2021-12-16T22:15:39.613" Score="1" Body="&lt;p&gt;Here is a partial answer to the feasibility question. Let &lt;span class=&quot;math-container&quot;&gt;$e\in \mathbb{R}^n$&lt;/span&gt; be a vector with all components equal to 1. &lt;span class=&quot;math-container&quot;&gt;$Ax\ge b \implies e'Ax \ge e'b.$&lt;/span&gt; Since &lt;span class=&quot;math-container&quot;&gt;$e'A=0,$&lt;/span&gt; if the problem is feasible you must have &lt;span class=&quot;math-container&quot;&gt;$e'b\le 0.$&lt;/span&gt; So if the sum of the components of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is positive, the problem is infeasible.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-16T22:15:39.613" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7449" PostTypeId="1" CreationDate="2021-12-17T05:59:54.167" Score="3" ViewCount="66" Body="&lt;p&gt;Suppose we have two alternative solutions for a linear program. Are their corresponding dual solutions the same? (in terms of the values for each dual variable)&lt;/p&gt;&#xA;" OwnerUserId="1094" LastActivityDate="2021-12-17T05:59:54.167" Title="Dual of the alternative solutions" Tags="|linear-programming|duality|dual|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7450" PostTypeId="1" CreationDate="2021-12-17T10:24:01.130" Score="3" ViewCount="56" Body="&lt;p&gt;I am considering a Mixed Interger NonLinear Program (MINLP), and using a solver to obtain admissible solutions.&lt;/p&gt;&#xA;&lt;p&gt;Is there a general method to reduce indeterminacy of solutions (e.g. by adding additionnal constraints to the problem or by solving multiple problems in an iteravite manner)?&lt;/p&gt;&#xA;&lt;p&gt;By indeterminacy I mean the fact that multiple solutions could be returned by a solver, and therefore change from one computer to another.&lt;/p&gt;&#xA;&lt;p&gt;I am opened to any reference on the matter, even for MILPs.&lt;/p&gt;&#xA;&lt;p&gt;--&lt;/p&gt;&#xA;&lt;p&gt;What I have been doing so far is to&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Solve the initial program&lt;/li&gt;&#xA;&lt;li&gt;Add a new constraint: objective function of previous program &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt; objective value of previous program&lt;/li&gt;&#xA;&lt;li&gt;Change the objective function to a new objective function with variables which are not in the initial objective function&lt;/li&gt;&#xA;&lt;li&gt;Solve this program and iterate to stage 2.&#xA;It seem like a reasonnable procedure but I don't really know if it totally reduces indeterminacy and if some stages are unecessary (i.e. iterations for which the corresponding variables already have a unique solution).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8723" LastActivityDate="2021-12-17T10:24:01.130" Title="Indeterminacy Reduction for MINLP" Tags="|optimization|mixed-integer-programming|solver|reference-request|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7451" PostTypeId="1" AcceptedAnswerId="7452" CreationDate="2021-12-17T10:42:03.927" Score="2" ViewCount="56" Body="&lt;p&gt;This is from a paper by Laszlo Lovasz, can be found &lt;a href=&quot;http://ftp.cs.elte.hu/%7Elovasz/scans/perfect.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, chapter 4. We have a &lt;span class=&quot;math-container&quot;&gt;$(0,1)$&lt;/span&gt;-matrix &lt;span class=&quot;math-container&quot;&gt;$$A = [a_{ij}]_{i,j=1}^{i=r,j=k}.$$&lt;/span&gt; We then have 2 linear programs:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min &amp;amp;\quad y\cdot 1\\&#xA;\text{s.t.}&amp;amp;\quad yA \geq w\\&#xA;&amp;amp;\quad y \geq 0,\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad w\cdot x\\&#xA;\text{s.t.}&amp;amp;\quad Ax \leq 1\\&#xA;&amp;amp;\quad x \geq 0.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Later it is shown that &lt;span class=&quot;math-container&quot;&gt;$x = (x_1,\ldots,x_k), w = (w_1,\ldots,w_k)$&lt;/span&gt;, which is natural. The bizarre thing is &lt;span class=&quot;math-container&quot;&gt;$y = (y_1,\ldots,y_k)$&lt;/span&gt;. What is this? I initially thought &lt;span class=&quot;math-container&quot;&gt;$yA$&lt;/span&gt; is just a shorthand for &lt;span class=&quot;math-container&quot;&gt;$y^TA$&lt;/span&gt;, but now I am not sure. I thought that the first LP is the dual of the second LP, but, what?&lt;/p&gt;&#xA;" OwnerUserId="7498" LastEditorUserId="123" LastEditDate="2021-12-17T12:10:00.840" LastActivityDate="2021-12-17T12:10:00.840" Title="Confusion in dimension of the vectors, and what is this $yA$ which is not $y^TA$" Tags="|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7452" PostTypeId="2" ParentId="7451" CreationDate="2021-12-17T11:05:30.027" Score="4" Body="&lt;p&gt;There's a typo in the first occurrence of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. It's actually &lt;span class=&quot;math-container&quot;&gt;$y=(y_1,\dots,y_r)$&lt;/span&gt; not &lt;span class=&quot;math-container&quot;&gt;$y_k$&lt;/span&gt; and this is also used in all further occurrences of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in that paper.&lt;/p&gt;&#xA;&lt;p&gt;So your initial guess of &lt;span class=&quot;math-container&quot;&gt;$yA$&lt;/span&gt; being short for &lt;span class=&quot;math-container&quot;&gt;$y^TA$&lt;/span&gt; appears to be correct.&lt;/p&gt;&#xA;&lt;p&gt;I guess they just omit the transpose sign and always assume matching dimensions. Only the order of the factors in the matrix-vector-product reveals what kind of vector that is.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2021-12-17T11:05:30.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7453" PostTypeId="1" CreationDate="2021-12-17T12:55:29.203" Score="3" ViewCount="127" Body="&lt;p&gt;The questions says:&lt;/p&gt;&#xA;&lt;p&gt;A printer is used to process print jobs. The interarrival times between jobs are exponentially distributed with a mean of 70 seconds. The time that is required to perform a job is exponentially distributed with a mean of 35 seconds.&lt;/p&gt;&#xA;&lt;p&gt;a) Assume that 2 printers are used to process the incoming print jobs. Determine the mean&#xA;time an incoming job has to wait until it can be processed (in seconds).&lt;/p&gt;&#xA;&lt;p&gt;So I tried to figure this out:&lt;/p&gt;&#xA;&lt;p&gt;In seconds: &lt;span class=&quot;math-container&quot;&gt;$\lambda=70$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mu=35$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\rho=\frac{70}{35}=2$&lt;/span&gt; we have two printers so my &lt;span class=&quot;math-container&quot;&gt;$c=2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now to see if there's a steady state: &lt;span class=&quot;math-container&quot;&gt;$\frac{\rho}{c}=\frac{2}{2}=1\nless1$&lt;/span&gt;, so there is no steady state.&lt;/p&gt;&#xA;&lt;p&gt;So with the formulas I know I can't calculate the Wq, can someone help me figure this out?&lt;/p&gt;&#xA;" OwnerUserId="8724" LastEditorUserId="67" LastEditDate="2021-12-17T16:38:00.280" LastActivityDate="2024-01-22T18:05:20.623" Title="Queueing model without steady state" Tags="|queuing-theory|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7454" PostTypeId="1" CreationDate="2021-12-17T17:35:40.297" Score="3" ViewCount="247" Body="&lt;p&gt;I am not a math student so I am sometimes a bit confused when it comes to math lingo.&#xA;For me non-convex would mean its concave which means functions have local minima in case of a minimization problem...&#xA;In the paper I am working with genetic algorithms and tabu-search. I would figure the reason for the usage are the concave terms.&lt;/p&gt;&#xA;&lt;p&gt;Am I on the right track of understanding?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5sjcR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5sjcR.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This here is the non-convex contrain where z are the number of containers being unloaded and loaded.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MSc1o.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MSc1o.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4380" LastEditorUserId="4380" LastEditDate="2021-12-17T18:05:26.507" LastActivityDate="2021-12-17T18:05:26.507" Title="What does nonconvex multilinear mean?" Tags="|optimization|modeling|convex-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7455" PostTypeId="2" ParentId="7454" CreationDate="2021-12-17T17:58:12.017" Score="8" Body="&lt;p&gt;Non-convex means not convex, which could mean concave but also neither convex nor concave, such as a bilinear term &lt;span class=&quot;math-container&quot;&gt;$xy$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2021-12-17T17:58:12.017" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7456" PostTypeId="1" AcceptedAnswerId="7457" CreationDate="2021-12-17T20:29:28.970" Score="4" ViewCount="242" Body="&lt;p&gt;We are dealing with a stochastic model and one of the constraints is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_j=\frac{\sum_{i \in I}\sum_{k \in K}\mathbb{E}\left[X_{ik}^2\right]x^k_{ij}}{\sum_{i \in I} \sum_{k \in K} \mathbb{E}\left[X_{ik}\right]x^k_{ij}}.&#xA;\end{align}&lt;/span&gt;&#xA;Here, decision variables are &lt;span class=&quot;math-container&quot;&gt;$y_j\geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^k$&lt;/span&gt; which is binary and &lt;span class=&quot;math-container&quot;&gt;$X_{ik}$&lt;/span&gt; is a random variable for which we know its mean and variance.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to perhaps linearize this constraint? The only thing that came to mind for me was to use &lt;span class=&quot;math-container&quot;&gt;${Var}[X]=\mathbb{E}[X^2]-\mathbb{E}[X]^2$&lt;/span&gt;, but this was not useful.&lt;/p&gt;&#xA;&lt;p&gt;I would appreciate some hints so I try to solve it myself.&lt;/p&gt;&#xA;" OwnerDisplayName="user9659" LastEditorDisplayName="user9659" LastEditDate="2021-12-18T06:36:17.127" LastActivityDate="2021-12-18T06:36:17.127" Title="Can we simplify (perhaps linearize) this constraint?" Tags="|mixed-integer-programming|linearization|nonlinear-programming|stochastic-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7457" PostTypeId="2" ParentId="7456" CreationDate="2021-12-17T20:52:21.337" Score="6" Body="&lt;p&gt;Assuming the denominator cannot be zero (which would cause the known universe to implode) and that you can provide an upper bound for &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt;, you can multiply both sides of the equation by the denominator. The new right side (the numerator) will be linear. The new left side will be &lt;span class=&quot;math-container&quot;&gt;$\sum_i \sum_k \mu_{ik} x_{ij}^k y_j$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; is the mean of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;). Now you just need to linearize the product &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^k y_j$&lt;/span&gt;, which is a FAQ. See &lt;a href=&quot;https://or.stackexchange.com/questions/39/how-to-linearize-the-product-of-a-binary-and-a-non-negative-continuous-variable&quot;&gt;here&lt;/a&gt; for an answer.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-17T20:52:21.337" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7459" PostTypeId="1" CreationDate="2021-12-19T18:14:28.020" Score="5" ViewCount="189" Body="&lt;p&gt;I originally &lt;a href=&quot;https://math.stackexchange.com/questions/4337085/why-do-we-use-the-square-root-as-a-proportional-measure-in-this-optimisation-pro&quot;&gt;posted this on the Mathematics Stack Exchange site&lt;/a&gt;, but I think it fits more on the OR-site.&lt;/p&gt;&#xA;&lt;p&gt;I'm reading a paper where the goal is to determine the weights of a weighted arithmetic mean to create a sales forecast for a future event (e.g. a promotion).&#xA;The weights weigh a vector of historical sales of historical events, in the following equation denoted as the vector &lt;strong&gt;y&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\hat{y}_k = \frac{w^Ty}{w^T1} \tag{1} $$&lt;/span&gt; where &lt;em&gt;&lt;strong&gt;w&lt;/strong&gt;&lt;/em&gt;, &lt;em&gt;&lt;strong&gt;y&lt;/strong&gt;&lt;/em&gt; and &lt;em&gt;&lt;strong&gt;1&lt;/strong&gt;&lt;/em&gt; are all vectors of size &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now every event can be described by some numerical features of size &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; (or categorical features transformed to numerical ones). And ofcourse, the event we are trying to forecasts has this vector of features as well.&lt;/p&gt;&#xA;&lt;p&gt;What they are trying to do is to estimate the weights by looking how similar each historical event is compared to the event we are trying to forecast (by looking at these features). Then a more similar event will have more weight and the volume of that event will thus have more impact on the value of our forecast.&lt;/p&gt;&#xA;&lt;p&gt;To measure the similarity, they use the Euclidean distance on the vector of features that describes each event. &lt;em&gt;&lt;strong&gt;In the paper, they normalize each feature!&lt;/strong&gt;&lt;/em&gt; This will give us an Euclidean distance matrix &lt;strong&gt;A&lt;/strong&gt; of size &lt;span class=&quot;math-container&quot;&gt;$N \times m$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A^{(e)}  = (X - 1x^e)\space\odot\space(X-1x^e) $$&lt;/span&gt;&#xA;With the superscript (e) to indicate that the result has been calculated wrt the &lt;span class=&quot;math-container&quot;&gt;$e^{th}$&lt;/span&gt; event, matrix &lt;strong&gt;X&lt;/strong&gt; which contains the numerical features for every historical event and &lt;span class=&quot;math-container&quot;&gt;$x^e$&lt;/span&gt; the vector of features is of the event we are trying to forecast.&#xA;But every numerical feature has its relative importance, so we also want to find a vector &lt;strong&gt;v&lt;/strong&gt; that scales the matrix &lt;strong&gt;A&lt;/strong&gt; so that you eventually get a vector of size &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;. This final vector can we call the scaled Euclidean distance of every historical event compared to the event of which its volume we are trying to forecast.&lt;/p&gt;&#xA;&lt;p&gt;So the more similar -the lower the scaled Euclidean distance distance is for an event compared to the event we are trying to forecast- the more weight we want to give it. So the weights are inversely proportional to the scaled Euclidean distance which is obvious.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;And here comes the question:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the paper they take the inverse square root of the Euclidean distance matrix to define the relationship between the weights and the similarity:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{weight}_j = \frac{1}{\sqrt{a^iv}}\tag{2}$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$a^i$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;th row of the matrix &lt;strong&gt;A&lt;/strong&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; represents each of the historical events.&lt;/p&gt;&#xA;&lt;p&gt;But why do they use the square root? Why not just:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\mathrm{weight}_j= \frac{1}{a^iv}$$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$$\mathrm{weight}_j= \frac{1}{(a^iv)^2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Why do we use the inversed square root and not just the inverse or the inversed square to define the proportionality ?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I can think of some reasons but it's not clear if these are the right ones:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;A&lt;/strong&gt; is a matrix of squared distances and thus maybe they use the square root to convert back to unit distance. But in optimization theory, often squared distances are preferred, so that's kinda weird. This could be due to the fact that features are normalized (interval 0 and 1).&lt;/li&gt;&#xA;&lt;li&gt;They want to use the squared distance but the relationship between the weights and the squared distance is assumed to be non-linear (else it would just be the inverse) and twice the squared distance between two events means the impact on the forecast  will be lower than two (else it would be the inverse square root).&lt;/li&gt;&#xA;&lt;li&gt;Numerical stability (because of the normalized features and the squared distance matrix that's being built).&lt;/li&gt;&#xA;&lt;li&gt;The square root has some mathematical properties in optimization that these other two don't have (feel free to elaborate on this).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So the answer I'm looking for depends on the reason behind using the square root,&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;or it necessary to be mathematically consistent; then I want to know: how so?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;or it is just a model assumption and best practice: then I want to know: why is it best practice to use the square root?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;IMPORTANT&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;To be complete: the paper continues with using Eq. (2) and substituting it to the Eq. (1) to get an optimization problem which is used to find the vector &lt;strong&gt;v&lt;/strong&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\hat{v} =\operatorname{argmin}_{v^*}\left[ \left\lVert y_k - \frac{\sum_{i=1}^n \frac{1}{\sqrt{a^iv}}y_i}{\sum_{i=1}^n \frac{1}{\sqrt{a^iv}}}\right\rVert^2 \right]$$&lt;/span&gt;&#xA;Once &lt;strong&gt;v&lt;/strong&gt; is found, we calculate the weights with Eq. (2):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{weight}_j = \frac{1}{\sqrt{a^iv}}$$&lt;/span&gt; and using this in the Eq. (1):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\hat{y}_k = \frac{w^Ty}{w^T1}$$&lt;/span&gt; to eventually get our forecast.&lt;/p&gt;&#xA;&lt;p&gt;Reference of the paper: &lt;a href=&quot;https://oa.upm.es/67130/1/INVE_MEM_2019_334744.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://oa.upm.es/67130/1/INVE_MEM_2019_334744.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2021-12-24T11:36:07.663" LastActivityDate="2021-12-24T11:36:07.663" Title="Why do we use the square root as a proportional measure?" Tags="|optimization|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7460" PostTypeId="1" CreationDate="2021-12-20T12:36:38.143" Score="2" ViewCount="161" Body="&lt;p&gt;This seems like a natural question, but I was not able to find an answer. My question is this. Consider a CVRP where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; customers have to be serviced by &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; vehicles on any given day. All the vehicles have the same maximum capacity &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;, and all depart from a warehouse depot &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; to make the deliveries. Each customer gets a single package so that &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; packages are delivered, where, &lt;span class=&quot;math-container&quot;&gt;$\forall$&lt;/span&gt; package weights &lt;span class=&quot;math-container&quot;&gt;$w_i (i = 1,\ldots,n$&lt;/span&gt;), &lt;span class=&quot;math-container&quot;&gt;$ 0 &amp;lt; w_i \leq J$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My question is that how many paths are possible in this case? For TSP, I understand that it is &lt;span class=&quot;math-container&quot;&gt;$(n-1)!/2$&lt;/span&gt;. But, in CVRP, due to capacity constraints, there are many infeasible paths (since it will exceed the maximum weight). So, is there a way to find only the feasible paths? I am looking for an analytical formula (or some bounds?) rather than a way to enumerate all the paths (though an efficient way to do this would also be interesting to know).&lt;/p&gt;&#xA;" OwnerUserId="8736" LastEditorUserId="8736" LastEditDate="2021-12-23T09:21:01.653" LastActivityDate="2021-12-25T14:27:43.920" Title="Number of paths in asymmetric capacitated vehicle routing problem" Tags="|combinatorial-optimization|vehicle-routing|traveling-salesman|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7461" PostTypeId="1" CreationDate="2021-12-20T15:08:05.337" Score="1" ViewCount="59" Body="&lt;p&gt;I'm trying to solve a problem very similar to &lt;a href=&quot;https://or.stackexchange.com/questions/2752&quot;&gt;this one&lt;/a&gt;, where I'm trying to find an optimal order. How would I actually plug this into GAMS?&lt;/p&gt;&#xA;&lt;p&gt;It gives out a single value rather than an ordering. I could maybe have variables for each booth that correspond to their order, but I'm not sure how to prevent GAMS from selecting a booth twice.&lt;/p&gt;&#xA;" OwnerUserId="8737" LastEditorUserId="123" LastEditDate="2021-12-20T16:09:55.920" LastActivityDate="2021-12-20T16:09:55.920" Title="Ordering a set in GAMS" Tags="|combinatorial-optimization|gams|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7462" PostTypeId="1" AcceptedAnswerId="7470" CreationDate="2021-12-20T15:08:47.117" Score="0" ViewCount="87" Body="&lt;p&gt;Raw data as below:&#xA;on the left, there are teams of musicians.&#xA;On the right, there are the features of the music the team composed, for style, duration and musical instrument.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[Lucas, Liam, James] : [Indie rock, Long, Tuba]&#xA;[Mason, Isabella, James] : [Electronic, Long, Piano]&#xA;[Benjamin, William, Olivia] : [Experimental, Medium, Ukulele]&#xA;[James, Charlotte, Isabella] : [Dance, Medium, Tuba]&#xA;...&#xA;[Oliver, Olivia, Sophia] : [Ambient, Medium, Piano]&#xA;[Noah, Mason, Isabella] : [Hip-hop, Medium, Tuba]&#xA;[Isabella, Harper, Liam] : [Ambient, Short, Ukulele]&#xA;[James, Emma, Charlotte] : [Dance, Medium, Double bass]&#xA;[Mason, Mia, Ethan] : [Experimental, Clip, Flute]&#xA;[James, Sophia, Harper] : [Ambient, Short, Ukulele]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For example, “[Lucas, Liam, James] : [Indie rock, Long, Tuba]” means, Lucas, Liam and James ever worked together, composed a long Indie rock style song, used Tuba (a musical instrument)&lt;/p&gt;&#xA;&lt;p&gt;The historical data quantity is on hundreds. When giving a new team, that a combination never in the existing data. What’s the way to infer the features of the music the new team’s going to compose?&lt;/p&gt;&#xA;&lt;p&gt;I am thinking, to break the historical data into individuals. That is, taking James as an example, his history (in the teams James ever in) is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[Indie rock, Long, Tuba]&#xA;[Electronic, Long, Piano]&#xA;[Dance, Medium, Tuba]&#xA;[Dance, Medium, Double bass]&#xA;[Ambient, Short, Ukulele]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It tells when James is in the new team, there’s a higher chance that the song is Dance style, Medium in length and using Tuba.&lt;/p&gt;&#xA;&lt;p&gt;When putting all such data of all team members in the new team, it suggests the features of the new music.&lt;/p&gt;&#xA;&lt;p&gt;Does it make sense? What would be a better way?&lt;/p&gt;&#xA;" OwnerUserId="2440" LastEditorUserId="491" LastEditDate="2023-02-25T03:03:59.280" LastActivityDate="2023-02-25T03:03:59.280" Title="Conclusion from many-to-many relationship" Tags="|modeling|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="7463" PostTypeId="1" CreationDate="2021-12-20T18:45:49.177" Score="2" ViewCount="84" Body="&lt;p&gt;Please, if somebody has another approach to a similar MIP problem...&lt;/p&gt;&#xA;&lt;p&gt;Assume we have some machines &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; and their activity could be interpreted by the boolean decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j} \ i \in m, j \in n$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is &lt;code&gt;the number of machines&lt;/code&gt; and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is &lt;code&gt;a number of equal time intervals&lt;/code&gt;. The objective is to minimize the number of machine starts on all intervals: for every machine &lt;span class=&quot;math-container&quot;&gt;$i \in \{1,\cdots,m\}$&lt;/span&gt; and for all time intervals &lt;span class=&quot;math-container&quot;&gt;$j \in \{1,\cdots,n\}$&lt;/span&gt; minimize cases when &lt;span class=&quot;math-container&quot;&gt;$x[i,j]= 0$&lt;/span&gt; and in the &lt;span class=&quot;math-container&quot;&gt;$x[i,j+1]= 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To do this I'm using an idea to maximize the number of cases when &lt;span class=&quot;math-container&quot;&gt;$x[i,j] = x[i,j+1]$&lt;/span&gt; or by adding and minimizing the additional boolean variable &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; (relay previous equation to &lt;span class=&quot;math-container&quot;&gt;$x[i,j]+p[i,j+1]=x[i,j+1]+s[i,j+1]$&lt;/span&gt; and remove &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned} \text { minimize } &amp;amp; \sum_{i=1}^{m} \sum_{j=2}^{n} s_{i,j}\\ &#xA;\text { s.t: } \quad &amp;amp; x_{i,j+1} - x_{i,j} \leq s_{i,j+1}\\&#xA;&amp;amp;\forall i \in 1,\cdots,m\\&#xA;&amp;amp;\forall j \in 1,\cdots,n-1\\&#xA;\end{aligned}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The real number of machines is about &lt;span class=&quot;math-container&quot;&gt;$200$&lt;/span&gt; and the number of time intervals is also about &lt;span class=&quot;math-container&quot;&gt;$200$&lt;/span&gt;. The model also has some &lt;code&gt;material balancing&lt;/code&gt; part-total amount of variables in the model is about &lt;span class=&quot;math-container&quot;&gt;$500K$&lt;/span&gt; and a little bit less constraints. It is step by step solving process with different objectives. For every other objective, it solves fine in &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; minutes, but for the objective &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; mentioned above, the search process is nether ended. Only switching to &lt;code&gt;solution polishing&lt;/code&gt; helps to find new solutions, but it's not optimal enough and the solving time is not acceptable at all. The problem of &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt; machines and &lt;span class=&quot;math-container&quot;&gt;$200$&lt;/span&gt; time intervals is working fine.&lt;/p&gt;&#xA;&lt;p&gt;Please, could you help if any other formulation could be used? or maybe some &lt;code&gt;symmetry breaking&lt;/code&gt; constraint? MIP is not good for this?&lt;/p&gt;&#xA;" OwnerUserId="5561" LastEditorUserId="199" LastEditDate="2021-12-21T05:25:53.730" LastActivityDate="2021-12-21T05:25:53.730" Title="Minimizing the number of machine starts" Tags="|optimization|mixed-integer-programming|scheduling|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7464" PostTypeId="1" CreationDate="2021-12-20T20:53:45.320" Score="3" ViewCount="72" Body="&lt;p&gt;Suppose there are some objects with features, and the target is parametric density estimation. Density estimation is model-based. Parameters are obtained by maximizing log-likelihood.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\operatorname{LL} = \sum_{i \in I_1} \log \left( \sum_{j \in K_i} \theta_j \right) + \sum_{i \in I_2} \log \left(1 - \sum_{j \in L_i} \theta_i\right)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assume that parameters &lt;span class=&quot;math-container&quot;&gt;$\theta_j$&lt;/span&gt; are probabilities, i.e.  &lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt; \theta_j &amp;lt; 1$&lt;/span&gt;, and that &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in L_i} \theta_i &amp;lt; 1$&lt;/span&gt;. From practical perspective, it seems natural to make parameters &lt;span class=&quot;math-container&quot;&gt;$\theta_j$&lt;/span&gt; themselves functions of features, i.e. &lt;span class=&quot;math-container&quot;&gt;$\theta_j = F(x_j^1, \ldots, x_j^m)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is there any known standard method or heuristic to optimize such objective with a decision tree? (I.e. assume that our function &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is a decision tree.)&lt;/p&gt;&#xA;&lt;p&gt;Any related results are welcome.&lt;/p&gt;&#xA;" OwnerUserId="8740" LastEditorUserId="123" LastEditDate="2021-12-21T09:36:45.257" LastActivityDate="2021-12-21T13:10:15.707" Title="Optimize parametric Log-Likelihood with a Tree" Tags="|optimization|constraint-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7465" PostTypeId="1" CreationDate="2021-12-20T21:47:55.023" Score="2" ViewCount="70" Body="&lt;p&gt;I have an optimal control problem with a state vector &lt;span class=&quot;math-container&quot;&gt;$\vec x$&lt;/span&gt; and a control vector &lt;span class=&quot;math-container&quot;&gt;$\vec u\in[0,1]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If I were solving the problem without regularization I would write&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \lVert \vec x \rVert&#xA;$$&lt;/span&gt;&#xA;But this results in messy values for &lt;span class=&quot;math-container&quot;&gt;$\vec u$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have strong priors that &lt;span class=&quot;math-container&quot;&gt;$\vec u$&lt;/span&gt; is bang-bang, so what I would like to do is to have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \lVert \vec x \rVert + \lambda f(\vec u)&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is the strength of the regularization and &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; penalizes &lt;span class=&quot;math-container&quot;&gt;$\vec u$&lt;/span&gt; if it takes values other than &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;One possibility is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \lVert \vec x \rVert - \lambda \lVert \vec u - \vec 1 \cdot 0.5\rVert&#xA;$$&lt;/span&gt;&#xA;here &lt;span class=&quot;math-container&quot;&gt;$\lambda \lVert \vec u - \vec 1 \cdot 0.5\rVert$&lt;/span&gt; takes large values if &lt;span class=&quot;math-container&quot;&gt;$\vec u$&lt;/span&gt; is near 0 or 1. By subtracting this term, we create an objective that encourages such values.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, in so doing we create an objective that's non-convex, at least from a &lt;a href=&quot;https://www.cvxpy.org/tutorial/dcp/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;disciplined convex programming&lt;/a&gt; perspective.&lt;/p&gt;&#xA;&lt;p&gt;Is there another objective that will encourage bang-bang behaviours or a way to convexify this objective?&lt;/p&gt;&#xA;" OwnerUserId="886" LastActivityDate="2021-12-20T21:47:55.023" Title="Regularize for a bang-bang control" Tags="|convex-optimization|disciplined-convex-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7467" PostTypeId="1" AcceptedAnswerId="7468" CreationDate="2021-12-21T11:48:42.067" Score="4" ViewCount="341" Body="&lt;p&gt;I have a problem where I have N binary decision variables where each one of them belongs to a group (Where the number of groups G is less than N) and I have to choose a subset of them to maximize some criteria but there are two constraints on the valid solutions.&lt;/p&gt;&#xA;&lt;p&gt;1- The sum of the decision variables should not exceed a predefined value C.&lt;/p&gt;&#xA;&lt;p&gt;2- The chosen decision variables should belong to the same group.&lt;/p&gt;&#xA;&lt;p&gt;So the first constraint is pretty straightforward to model mathematically but I still have not managed to find a way to represent the second constraint in a mathematical fashion.&lt;/p&gt;&#xA;" OwnerUserId="8743" LastEditorUserId="491" LastEditDate="2022-03-08T12:50:41.187" LastActivityDate="2022-03-08T12:50:41.187" Title="Adding a group constraint to binary decision variables" Tags="|optimization|mixed-integer-programming|integer-programming|combinatorial-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7468" PostTypeId="2" ParentId="7467" CreationDate="2021-12-21T12:47:07.167" Score="3" Body="&lt;p&gt;Say your variables are &lt;span class=&quot;math-container&quot;&gt;$x_1,\ldots, x_n$&lt;/span&gt;. The first constraint could be modeled as &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n x_i \leq C.$$&lt;/span&gt; This makes sure that not more than &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; variables are chosen.&lt;/p&gt;&#xA;&lt;p&gt;If understood your question correctly the optimal solution may only have non-zero values for variables in the same group and not all variables from the group are mandatory to be selected.This can modeled as follows:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathcal{G}$&lt;/span&gt; be the set of groups. For each group &lt;span class=&quot;math-container&quot;&gt;$G \in \mathcal{G}$&lt;/span&gt; you add a new variable &lt;span class=&quot;math-container&quot;&gt;$z_G \in \{0,1\}$&lt;/span&gt; which indicates whether or not the group is picked. By adding the constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{G\in\mathcal{G}} z_G \leq 1$$&lt;/span&gt; you ensure that only 1 group makes it to the optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$s_G$&lt;/span&gt; indicate the number of variables in group &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;. The constraints &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i \in G} x_i \leq z_G \cdot s_G ~\forall G \in \mathcal{G}$$&lt;/span&gt;&#xA;enforce that variables can only be chosen if the corresponding &lt;span class=&quot;math-container&quot;&gt;$z_G$&lt;/span&gt; is equal to 1. The previous constraint, however, makes sure that this will only be the case for a single group.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, you can (following fontanf's comment below) replace these constraints by a non-aggregated version: &lt;span class=&quot;math-container&quot;&gt;$$x_i\leq z_G ~~ \forall G \in \mathcal{G}, i\in G$$&lt;/span&gt;&#xA;If only one group has to be picked and the optimal solution would additionally require that all variables belonging to that group are chosen, then it would already suffice to set them equal to each other:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_1=\ldots=x_l, ~ (1,\ldots,l)\in \mathcal{G}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Typically, the non-aggregated constraints will result in a better relaxation.&lt;/p&gt;&#xA;&lt;p&gt;In this case the presolve would eliminate all but one representative of each group automatically. But if I understood your question correctly not all variables of a group have to be picked. This can be modeled by the other two sets of constraints mentioned above.&lt;/p&gt;&#xA;" OwnerUserId="81" LastEditorUserId="81" LastEditDate="2021-12-22T11:31:32.217" LastActivityDate="2021-12-22T11:31:32.217" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7469" PostTypeId="2" ParentId="7464" CreationDate="2021-12-21T13:10:15.707" Score="3" Body="&lt;p&gt;If you read the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/expo.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek modeling cookbook&lt;/a&gt; then you will learn how to formulate the problem as a conic optimization problem. Well, at least it tells you how to deal with the objective function.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2021-12-21T13:10:15.707" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7470" PostTypeId="2" ParentId="7462" CreationDate="2021-12-21T16:49:32.893" Score="3" Body="&lt;p&gt;I hesitate to suggest this, for fear it will get one of my degrees revoked, but here goes. I'm going to use the term &amp;quot;target&amp;quot; generically for the thing you are try to guess. It might be one feature of the music (e.g., the instrument), but it also might be the triplet of style, duration and instrument. The reason for guessing triplets as a whole would be that guessing the features individually might lead you to a combination that is unlikely if not impossible (because long folk songs played on a tuba just don't exist).&lt;/p&gt;&#xA;&lt;p&gt;Let's say that Larry, Gary and Mary are a new trio. We will make three thoroughly unsupported assumptions: that individuals pick feature values randomly; that choices are made independent of who their teammates are, what their teammates pick, and anything else you can think of; and that majority rules within the team. So for the new trio to select target value &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, it must be a majority choice. If &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt; is the true probability of musician &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; picking target value &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, the probability of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; being the majority choice is &lt;span class=&quot;math-container&quot;&gt;$$p_{Lj}\cdot p_{Gj}\cdot p_{Mj} + p_{Lj}\cdot p_{Gj}\cdot (1-p_{Mj}) + p_{Lj}\cdot (1- p_{Gj})\cdot p_{Mj} + (1-p_{Lj})\cdot p_{Gj}\cdot p_{Mj},$$&lt;/span&gt;where the terms are respectively unanimous choice, Mary dissenting, Gary dissenting and Larry dissenting. For each individual &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and each possible value &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; of the target, we estimate &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt; with the proportion &lt;span class=&quot;math-container&quot;&gt;$\hat{p}_{ij}$&lt;/span&gt; of records involving individual &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; that match target value &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;That gives you a &amp;quot;likelihood&amp;quot; of each possible value &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; of the target.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-21T16:49:32.893" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7471" PostTypeId="1" AcceptedAnswerId="7474" CreationDate="2021-12-22T01:50:15.080" Score="2" ViewCount="195" Body="&lt;p&gt;I need to perform clustering of two different entities. Lets say we have transmitters and users.&#xA;The relation between a transmitters and user is defined by a weight, for example, the weight between transmitter &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; is denoted as &lt;span class=&quot;math-container&quot;&gt;$w_{t,u}, t=1,2,\cdots, T, u=1,2,\cdots, U$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Maximum cluster size (in terms of number of transmitters). There is no such constraint on the user number in a cluster.&lt;/li&gt;&#xA;&lt;li&gt;Clusters are mutually exclusive. one user or transmitter can belong to only one clusters.&lt;/li&gt;&#xA;&lt;li&gt;All the transmitters in a cluster serve only their own users.&lt;/li&gt;&#xA;&lt;li&gt;The user must belong to a cluster that has the transmitter providing the highest weight for the given user.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The clustering objective is the maximise the signal quality of all the users. The signal quality for user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$q_u$&lt;/span&gt; is defines as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$q_u=\frac{\text{Sum of weights for all the transmitters in user cluster}}{\text{Sum of weights for all the transmitters not in user cluster}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Therefore, the objective is &lt;span class=&quot;math-container&quot;&gt;$\max \sum_{u=1}^Uq_u$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am looking for optimal as well as some goo heuristic approach.&lt;/p&gt;&#xA;&lt;p&gt;Note: We do not have access to coordinates of the users, however have access to the coordinates of the transmitters. As mentioned, the weights are also known.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2021-12-26T11:21:51.137" LastActivityDate="2021-12-28T19:22:17.543" Title="How to perform clustering of two different sets of entities?" Tags="|optimization|combinatorial-optimization|clustering|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7472" PostTypeId="1" CreationDate="2021-12-22T03:03:52.817" Score="3" ViewCount="240" Body="&lt;p&gt;So I have a 0-1 knapsack problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad \sum_j c_j x_j\\&#xA;\text{s.t.}&amp;amp;\quad \sum_j a_j x_j \leq b\\&#xA;&amp;amp;\quad x_j \in \{0,1\}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;but it has an additional requirement that the number of items in an optimal knapsack should be &lt;em&gt;&lt;strong&gt;odd&lt;/strong&gt;&lt;/em&gt;. I know I can model it with one extra variable, but the assignment calls for &lt;em&gt;redefining separation procedure&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To my understanding, that means writing a callback procedure that will generate additional constraints in branch-and-cut algorithm. I know that 0-1 knapsacks have special kinds of inequalities to strengthen LP formulation, but I don't know how to incorporate them with the requirement of odd number of items.&lt;/p&gt;&#xA;" OwnerUserId="8751" LastEditorUserId="36" LastEditDate="2021-12-22T03:50:30.063" LastActivityDate="2021-12-29T21:57:49.667" Title="How to redefine separation procedure to get 0-1 knapsack with odd number of items" Tags="|knapsack|cutting-planes|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7473" PostTypeId="1" CreationDate="2021-12-22T13:01:07.577" Score="0" ViewCount="147" Body="&lt;p&gt;Thanks for the amazing performance of Gurobi.&lt;/p&gt;&#xA;&lt;p&gt;Actually we are using Gurobi Cloud (via its python binding - &lt;code&gt;Gurobipy&lt;/code&gt;) for our optimization requirements.&lt;/p&gt;&#xA;&lt;p&gt;Due to our higher number of optimization problems and their high complexity, we are executing concurrent optimization problems on Gurobi Cloud.&lt;/p&gt;&#xA;&lt;p&gt;Now, we can achieve the execution of concurrent optimization problems via 2 approaches:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Approach #1: With Common Gurobi Environment across problems&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Approach #2: With Distinct Gurobi Environment across problems&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uKPAU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uKPAU.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Doubts:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Which approach is recommended?&lt;/li&gt;&#xA;&lt;li&gt;Could you highlight the pros &amp;amp; cons of both approaches (especially on speed &amp;amp; billing aspects) ?&lt;/li&gt;&#xA;&lt;li&gt;Is this statement True: In approach #1 - same instance / machine is used on Gurobi Cloud, hence is slower but cheaper. Whereas in approach #2 - different instance / machine is used on Gurobi Cloud, hence is faster but costlier.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6106" LastActivityDate="2021-12-22T19:03:55.247" Title="Gurobi Environment should be Common or Unique for concurrent optimization problems?" Tags="|optimization|python|gurobi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7474" PostTypeId="2" ParentId="7471" CreationDate="2021-12-22T17:22:07.837" Score="2" Body="&lt;p&gt;This can be formulated as a MIP model using a gaggle of binary variables. First, we introduce some parameters. &lt;span class=&quot;math-container&quot;&gt;$\tau(u)$&lt;/span&gt; is the index of the transmitter with highest weight for user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;. I will charitably assume this is unambiguous (no ties for closest transmitter). &lt;span class=&quot;math-container&quot;&gt;$\overline{Q}_u$&lt;/span&gt; is an upper bound on the possible values of &lt;span class=&quot;math-container&quot;&gt;$q_u$&lt;/span&gt; for user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is the maximum number of transmitters in any cluster and &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is an upper bound on the number of clusters.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{t,t'}\in \lbrace 0,1 \rbrace$&lt;/span&gt; be 1 if transmitters &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t'$&lt;/span&gt; are in the same cluster, 0 if not, for &lt;span class=&quot;math-container&quot;&gt;$t\neq t'$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$x_{t,t}$&lt;/span&gt; will be 1 if transmitter &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; &amp;quot;anchors&amp;quot; a cluster and 0 if not. A cluster has exactly one anchor.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$y_{t,u}\in\lbrace 0,1 \rbrace$&lt;/span&gt; be 1 if user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; is in a cluster with transmitter &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and 0 if not.&lt;/p&gt;&#xA;&lt;p&gt;Here come the constraints. First, we require that the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables be symmetric (if &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is in the same cluster as &lt;span class=&quot;math-container&quot;&gt;$t'$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$t'$&lt;/span&gt; is in the same cluster as &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;):&lt;span class=&quot;math-container&quot;&gt;$$x_{t,t'}=x_{t',t}\quad\forall t\neq t'.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We also need to enforce transitivity. If &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t'$&lt;/span&gt; are in the same cluster, and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t''$&lt;/span&gt; are in the same cluster, then &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t''$&lt;/span&gt; are in the same cluster. So we add the following constraints. &lt;span class=&quot;math-container&quot;&gt;$$x_{t,t''} \ge x_{t,t'} + x_{t',t''} - 1\quad \forall t,t',t'' \ni t\neq t' \,\&amp;amp;\, t' \neq t'' \,\&amp;amp;\, t \neq t''.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We must force every transmitter to belong to a cluster with an anchor, which requires additional variables &lt;span class=&quot;math-container&quot;&gt;$v_{t,t'}\in [0,1]$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$t\neq t'$&lt;/span&gt;. The additional constraints are &lt;span class=&quot;math-container&quot;&gt;$$v_{t,t'} \le x_{t,t'} \quad \forall t\neq t'$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$v_{t,t'} \le x_{t',t'} \quad \forall t\neq t'$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$x_{t,t} + \sum_{t' \neq t} v_{t,t'} = 1.$$&lt;/span&gt; So if &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is an anchor (&lt;span class=&quot;math-container&quot;&gt;$x_{t,t}=1$&lt;/span&gt;), &lt;span class=&quot;math-container&quot;&gt;$v_{t,t'}=0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$t' \neq t$&lt;/span&gt;; but if &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is not an anchor (&lt;span class=&quot;math-container&quot;&gt;$x_{t,t}=0$&lt;/span&gt;), then &lt;span class=&quot;math-container&quot;&gt;$v_{t,t'} =1$&lt;/span&gt; for exactly one &lt;span class=&quot;math-container&quot;&gt;$t'\neq t$&lt;/span&gt;, and that transmitter &lt;span class=&quot;math-container&quot;&gt;$t'$&lt;/span&gt; must be an anchor (&lt;span class=&quot;math-container&quot;&gt;$x_{t',t'} = 1$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;We can limit the number of clusters by limiting the number of anchors: &lt;span class=&quot;math-container&quot;&gt;$$\sum_t x_{t,t} \le L.$$&lt;/span&gt; (Change that to an equation if you need exactly &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; clusters.)&lt;/p&gt;&#xA;&lt;p&gt;The following constraint enforces cluster capacity limits: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{t'=1}^T x_{t,t'} - x_{t,t} \le C - 1\quad \forall t.$$&lt;/span&gt;This says that the number of transmitters other than &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; in the same cluster with &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is at most &lt;span class=&quot;math-container&quot;&gt;$C-1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To avoid having multiple anchors in a single cluster, we enforce the following:&lt;span class=&quot;math-container&quot;&gt;$$x_{t,t} + x_{t',t'} + x_{t,t'}\le 2 \quad\forall t &amp;lt; t'.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Next, we enforce the requirement that each user belong to the cluster containing the best transmitter:&lt;span class=&quot;math-container&quot;&gt;$$y_{\tau(u),u} = 1 \quad\forall u.$$&lt;/span&gt;To determine what other transmitters serve &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, we add the following:&lt;span class=&quot;math-container&quot;&gt;$$y_{t,u} = x_{\tau(u),t}\quad\forall u,\forall t\neq \tau(u).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective remains to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_u q_u$&lt;/span&gt;. To linearize &lt;span class=&quot;math-container&quot;&gt;$q_u$&lt;/span&gt;, we introduce variables &lt;span class=&quot;math-container&quot;&gt;$z_{t,u}\in [0, \overline{Q}_u]$&lt;/span&gt; for all transmitters &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and users &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, along with the following constraints:&lt;span class=&quot;math-container&quot;&gt;$$z_{t,u} \le \overline{Q}_u y_{t,u} \quad\forall t,u$$&lt;/span&gt;&lt;span class=&quot;math-container&quot;&gt;$$z_{t,u} \le q_u + \overline{Q}_u(1-y_{t,u})\quad \forall t,u$$&lt;/span&gt;and&lt;span class=&quot;math-container&quot;&gt;$$z_{t,u}\ge q_u - \overline{Q}_u(1-y_{t,u})\quad \forall t,u.$$&lt;/span&gt;&#xA;The net effect of these is that&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z_{t,u}=\begin{cases}&#xA;q_{u} &amp;amp; y_{t,u}=1\\&#xA;0 &amp;amp; y_{t,u}=0&#xA;\end{cases}.$$&lt;/span&gt;&#xA;Finally, we linearize the definition of &lt;span class=&quot;math-container&quot;&gt;$q_u$&lt;/span&gt; via the constraints &lt;span class=&quot;math-container&quot;&gt;$$\sum_t w_{t,u} (q_u - z_{t,u})=\sum_t w_{t,u}y_{t,u}\quad\forall u,$$&lt;/span&gt;which is the result of multiplying both sides of the definition of &lt;span class=&quot;math-container&quot;&gt;$q_u$&lt;/span&gt; by the denominator and then simplifying.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: There's a bit of inherent (undesired) symmetry in the model. If you take any solution and change the &amp;quot;anchor&amp;quot; transmitter in a cluster to a different member of the same cluster, you get the same results but the solver sees it as a different solution. To avoid that, the following optional constraints can be added:&lt;span class=&quot;math-container&quot;&gt;$$x_{t',t'} \le 1 - x_{t,t'} \quad \forall t &amp;lt; t'.$$&lt;/span&gt;This forces the lowest index transmitter in each cluster to be the anchor. Whether these speed up the solver or not is an empirical question.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum2&lt;/strong&gt;: Details of both this and an alternate (and apparently less efficient) MIP model, along with construction and improvement heuristics that seem to work really well, are given in a &lt;a href=&quot;https://orinanobworld.blogspot.com/2021/12/revisiting-joint-clustering-problem.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;blog post&lt;/a&gt;. The blog post also contains a link to my Java code.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2021-12-28T19:22:17.543" LastActivityDate="2021-12-28T19:22:17.543" CommentCount="19" ContentLicense="CC BY-SA 4.0" />
  <row Id="7475" PostTypeId="2" ParentId="7473" CreationDate="2021-12-22T19:03:55.247" Score="4" Body="&lt;p&gt;This is a very Gurobi-specific question and you should rather open a Support ticket on &lt;a href=&quot;https://support.gurobi.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://support.gurobi.com&lt;/a&gt; for this.&lt;/p&gt;&#xA;&lt;p&gt;This is the official recommendation from the &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_env2.html#pythonmethod:Env&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi Docs on environments&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In general, you should aim to create a single Gurobi environment in your program, even if you plan to work with multiple models. Reusing one environment is much more efficient than creating and destroying multiple environments. The one exception is if you are writing a multi-threaded program, since environments are not thread safe. In this case, you will need a separate environment for each of your threads.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="141" LastActivityDate="2021-12-22T19:03:55.247" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7476" PostTypeId="2" ParentId="5981" CreationDate="2021-12-22T21:44:02.740" Score="2" Body="&lt;p&gt;We need to make &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; deliveries. Each delivery &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; units of a single product to be delivered. We have &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; box types. Each box of type &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; costs &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; and it can hold &lt;span class=&quot;math-container&quot;&gt;$s_j$&lt;/span&gt; units of the product. We would like to minimize the total cost of boxes used.&lt;/p&gt;&#xA;&lt;p&gt;Decision variable &lt;span class=&quot;math-container&quot;&gt;$b_{ij}$&lt;/span&gt; denotes the number of boxes of type &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; used in delivery &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Corresponding math programming model is as follows&#xA;\begin{array}{rrll}&#xA;\min &amp;amp; \sum_{ij} c_i b_{ij} \\&#xA;\text{s.t.} &amp;amp; \sum_j s_j b_{ij} &amp;amp; \geq a_i &amp;amp;\forall i \in {1, \ldots, n} \\&#xA;&amp;amp; b_{ij} &amp;amp;\geq 0 , \text{integer} &amp;amp; \forall i \in {1, \ldots, n}, j \in {1, \ldots, m}&#xA;\end{array}&lt;/p&gt;&#xA;&lt;p&gt;The first constraint ensures we use the correct number of boxes, while the objective ensures we use them in a cost efficient manner.&lt;/p&gt;&#xA;" OwnerUserId="8752" LastActivityDate="2021-12-22T21:44:02.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7477" PostTypeId="1" CreationDate="2021-12-23T15:49:12.187" Score="3" ViewCount="405" Body="&lt;p&gt;THE PROBLEM&lt;/p&gt;&#xA;&lt;p&gt;A refinery has 10 million barrels of type A crude and 6 million barrels of&#xA;Type B crude oil. The refinery has 3 plants to produce gasoline (it produces a profit&#xA;of 2 USD / barrel) and naphtha (produces a profit of 1 USD / barrel) with the following&#xA;features:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{|l|l|l|l|l|}&#xA; &amp;amp; Input  &amp;amp; { Input } &amp;amp; { Output } &amp;amp; { Output } \\&#xA;\hline \text { plant } &amp;amp; \text { A } &amp;amp; \text { B } &amp;amp; \text { Gasoline } &amp;amp; \text { Naphtha } \\&#xA;\hline 1 &amp;amp; 3 &amp;amp; 5 &amp;amp; 4 &amp;amp; 3 \\&#xA;\hline 2 &amp;amp; 1 &amp;amp; 1 &amp;amp; 1 &amp;amp; 1 \\&#xA;\hline 3 &amp;amp; 5 &amp;amp; 3 &amp;amp; 3 &amp;amp; 4 \\&#xA;\hline&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The data in the table above means that for example, if 3 barrels of crude oil type A and 5 barrels of type B crude enter plant 1, you can get 4 barrels of gasoline and 3 barrels of naphtha.&lt;/p&gt;&#xA;&lt;p&gt;MY SOLUTION:&lt;/p&gt;&#xA;&lt;p&gt;My approach (which is faulty) does not take into account the proportion of raw materials A and B that get into the 3 plants for its processing (no idea how to do it). Certainly, I was not able to establish the appropriate relation between input and output, consequently, my decision variable does not take into account the proportions that need to be combined to get material into the plants to get the output of the 2 final products.&lt;/p&gt;&#xA;&lt;p&gt;Thank you for any correction and guide about how to solve this problem&lt;/p&gt;&#xA;&lt;p&gt;My approach goes as follows:&lt;/p&gt;&#xA;&lt;p&gt;SETS:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P=\{1,2,3\}$&lt;/span&gt; is the set of Plants.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$TC=\{A,B\}$&lt;/span&gt; is the set of Crude Types.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Pro=\{Gasoline, Naphtha\}$&lt;/span&gt; is the set of Products afer processing in each plant.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Profit=\{Gasoline=2, Naphtha=1\}$&lt;/span&gt; profit for each barrel of each type of Product.&#xA;PARAMETERS:&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ic_{tc}^{p} \in \mathbb{R}^+$&lt;/span&gt; input coefficient for each crude type &lt;span class=&quot;math-container&quot;&gt;$tc$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall tc \in TC$&lt;/span&gt; for plant &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall p \in P$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$oc_{pro}^{p,tc} \in \mathbb{R}^+$&lt;/span&gt; is the output coefficient for each type of Product &lt;span class=&quot;math-container&quot;&gt;$pro$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall pro \in Pro$&lt;/span&gt; for plant &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall p \in P$&lt;/span&gt;, for each crude type &lt;span class=&quot;math-container&quot;&gt;$tc \in TC$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Stored_{tc}=\{ 10e^6, 6e^6 \} \in \mathbb{Z}^+$&lt;/span&gt; Barrels inventory of Crude Type &lt;span class=&quot;math-container&quot;&gt;$tc$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ \forall tc \in TC$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Profit_{pro} \in \mathbb{Z}^+$&lt;/span&gt; is the Profit for each Product &lt;span class=&quot;math-container&quot;&gt;$pro$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall pro \in Pro$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;DECISION VARIABLE&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{tc,p}\in \mathbb{Z}^+ , \; \forall tc \in TC,\; \forall p \in P &#xA;\end{align}&lt;/span&gt;&#xA;Number of crude barrel &lt;span class=&quot;math-container&quot;&gt;$tc \in TC$&lt;/span&gt; that is processed at plant &lt;span class=&quot;math-container&quot;&gt;$p \in P$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;OBJECTIVE FUNCTION&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\&#xA;&amp;amp;\textit{Maximize the profit}\\&#xA;&amp;amp; \max \sum_{pro \in PRO \\ p \in P} x_{tc,p} oc_{pro}^{p,tc} Profit_{pro} , \; \\&#xA;\textit{S.t:}\\&#xA;\\&#xA;&amp;amp;* \textit{Relation of input and output:}\\&#xA;&amp;amp; \sum_{tc \in TC} x_{tc,p} ce_{tc}^{p} = \sum_{pro \in PRO} y_{pro,p}, \forall p \in P,  \tag 1\\ &#xA;&amp;amp;* \textit{Processing each crude type throughout each plant cannot be greater than the inventory of each crude types}\\&#xA;&amp;amp; \sum_{p \in P} x_{A,p} \leq Stored_{A},\tag 2\\&#xA;&amp;amp; \sum_{p \in P} x_{B,p} \leq Stored_{B},\tag 3\\&#xA;&amp;amp;* \textit{Non-negativity of decision variable}\\&#xA;&amp;amp;   x_{tc,p} \geq 0, \; \forall tc \in TC, \forall p \in P. \tag 4&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="8764" LastEditorUserId="2556" LastEditDate="2021-12-26T21:23:38.113" LastActivityDate="2021-12-26T21:23:38.113" Title="How to construct the linear programing representation of a blending problem?" Tags="|optimization|mixed-integer-programming|linear-programming|modeling|integer-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7478" PostTypeId="2" ParentId="7477" CreationDate="2021-12-24T12:16:17.033" Score="2" Body="&lt;p&gt;I believe the following LP should satisfy your constraints. Please try to understand constraint (3) and tell me if this is what you wanted. I modeled it separately for each input, output, plant combination. Let's assume that you want to produce 1 barrel of gasoline at the first plant. Constraint 3 then states, that &lt;span class=&quot;math-container&quot;&gt;$3 \leq 4x_{00}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$5 \leq 4x_{10}$&lt;/span&gt;, so you need at least &lt;span class=&quot;math-container&quot;&gt;$\frac{3}{4}$&lt;/span&gt; barrels of input 0 and &lt;span class=&quot;math-container&quot;&gt;$\frac{5}{4}$&lt;/span&gt; of input 1.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;DECISION VARIABLES&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{ij}&#xA;\end{align}&lt;/span&gt;&#xA;Number of crude barrel &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt; processed at plant &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_{kj}&#xA;\end{align}&lt;/span&gt;&#xA;Number of output barrel &lt;span class=&quot;math-container&quot;&gt;$k \in K$&lt;/span&gt; produced at plant &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Linear Program&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\&#xA;&amp;amp; \max z = 2\sum_{j \in J} y_{0j} + \sum_{j \in J} y_{1j}  \; \\&#xA;\textit{S.t:}\\&#xA;\\&#xA;&amp;amp; \sum_{j \in J}  x_{0j} \leq 10,000,000 \tag1\\ &#xA;&amp;amp; \sum_{j \in J}  x_{1j} \leq 6,000,000 \tag2\\ &#xA;&amp;amp; ic_{ij} y_{kj} \leq oc_{jk}x_{ij} \;  \forall i \in I, j \in J, k \in K \tag3\\&#xA;&amp;amp;   x_{ij} \geq 0, \; \forall i \in I, j \in J \tag4\\&#xA;&amp;amp;   y_{kj} \geq 0, \; \forall k \in K, j \in J \tag5&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="3464" LastEditDate="2021-12-25T17:03:24.260" LastActivityDate="2021-12-25T17:03:24.260" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7480" PostTypeId="2" ParentId="7471" CreationDate="2021-12-24T23:20:12.243" Score="2" Body="&lt;p&gt;In preliminary tests, a greedy heuristic seems to do rather well for the problem.&lt;/p&gt;&#xA;&lt;p&gt;The greedy heuristic I tried starts out with each transmitter being a cluster of size 1, and then loops indefinitely. In each pass through the loop, all pairs of clusters are considered for merging. Any merger that would result in a cluster that exceeds the cluster size limit is discarded. The surviving candidate mergers (those meeting the size limit) are evaluated for how they would change the objective value, and the best possible merger is retained. If the best merger results in a net gain, it is implemented and the loop repeats. If the best merger results in a net loss but the current number of clusters exceeds the limit on cluster count, it is implemented anyway (and the loop repeats). You exit the loop when either (a) you are within the limit on number of clusters and there are no beneficial mergers or (b) you have too many clusters but there are no legal mergers (in which case the heuristic has failed to find a feasible solution).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-24T23:20:12.243" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7481" PostTypeId="2" ParentId="7460" CreationDate="2021-12-25T14:27:43.920" Score="2" Body="&lt;p&gt;I am pretty sure, this is not the best way to tackle such a problem, specifically from the computational complexity point of view, but at least it might be represented as an effort to solve small-scale problems. As you mentioned:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All the vehicles have the same maximum capacity &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Each customer gets a single package so that n packages are delivered...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I have tried to use a bin packing problem to calculate an estimate on the required vehicles as a lower bound and whose related routes. Please, be aware that, generalized assignment problem is another option to achieve the feasible routes when there are different capacities for vehicles w.r.t the route cost.&lt;/p&gt;&#xA;&lt;p&gt;As a simple example, suppose there are &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; customers with the following demands:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  item1   26, item2   57, item3   18, item4    8,&#xA;  item5   45, item6   12, item7   22, item8   29,&#xA;  item9    5, item10  11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; vehicles with the capacity of &lt;span class=&quot;math-container&quot;&gt;$60$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Actually, there are around &lt;span class=&quot;math-container&quot;&gt;$41$&lt;/span&gt; different states(!!!) to assign the required demands to the vehicles to achieve feasible solutions. If the problem size changes from &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; customers to &lt;span class=&quot;math-container&quot;&gt;$20$&lt;/span&gt;, the solving time increases exponentially and takes an age to solve such a tiny problem. Definitely, this is a case to show some feasible solution but &lt;strong&gt;NOT&lt;/strong&gt; the optimal solution, as the problem has not considered the traveling cost. I hope it would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-12-25T14:27:43.920" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7482" PostTypeId="1" CreationDate="2021-12-25T21:33:04.833" Score="3" ViewCount="190" Body="&lt;p&gt;I am currently reading research papers on optimization problems in logistics and struggle to understand the math notation. Any good beginner friendly books you would recommend?&#xA;This is the paper I read:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S1366554514002269?casa_token=7OHpodgcRnUAAAAA:_VB4tS4ZjTx5TC5HUr7QbiAhxZX07WCxC15cLTnF1nXI-QQ2sKgmoyvJrBxq_YDqtFlBAyWY2g#b0100&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sciencedirect.com/science/article/pii/S1366554514002269?casa_token=7OHpodgcRnUAAAAA:_VB4tS4ZjTx5TC5HUr7QbiAhxZX07WCxC15cLTnF1nXI-QQ2sKgmoyvJrBxq_YDqtFlBAyWY2g#b0100&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4380" LastEditorUserId="123" LastEditDate="2021-12-26T11:23:49.277" LastActivityDate="2021-12-26T11:23:49.277" Title="Good book to get familiar with the key concepts of Operations Research for a person which didn't enjoy a good math education in university?" Tags="|optimization|modeling|vehicle-routing|books|genetic-algorithm|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7483" PostTypeId="1" AcceptedAnswerId="7484" CreationDate="2021-12-26T07:06:20.783" Score="4" ViewCount="2614" Body="&lt;p&gt;I am trying to write a simple optimization problem by using DOCPLEX. I am pretty new on python+DO and What I have tried to do is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Set and parameters&#xA;I = [&amp;quot;i1&amp;quot;];&#xA;J = [&amp;quot;j1&amp;quot;];&#xA;Parameters form = {(&amp;quot;i1&amp;quot;, &amp;quot;j1&amp;quot;): number}&#xA;&#xA;# model&#xA;mdl = Model(name='name')&#xA;&#xA;# Declare variables&#xA;idx_x = [(i,j) for i in I for j in J]&#xA;x = mdl.binary_var_dict(idx_x, name=&amp;quot;x&amp;quot;);&#xA;&#xA;&#xA;# The optimization model&#xA;objective function &amp;amp; model constraints &#xA;&#xA;# output&#xA;mdl.print_information()&#xA;m = mdl.solve(log_output=True)&#xA;s = m.display()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It seems the above template is fine and the problem is solved without any issue. The problem I have faced is, when I want to invoke the variable's value, I cannot find a convenient way to get whose values and applying them again in other parts of the model. Let's say the following methods display the solution, but they are not what I am looking for.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;The first method:&#xA;for v in mdl.iter_binary_vars():&#xA;  print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&#xA;The second method:&#xA;print(mdl.solution.get_value_dict(x))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I want to write an equation as &lt;span class=&quot;math-container&quot;&gt;$Gamma_{i} = 1 - \sum_{i} \sum_{j} x_{i,j}$&lt;/span&gt; in wich &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; would be the variable's value. I also tried a method as follows, but it produces an error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(len(I)):&#xA;  for j in range(len(J)):&#xA;    print(m.x[i,j].solution_value)&#xA;==========================================&#xA;AttributeError: 'SolveSolution' object has no attribute 'x'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I was wondering if, how we can fix that?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2021-12-27T16:01:24.217" Title="How to retrieve the variable's value in DOCplex" Tags="|optimization|python|docplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7484" PostTypeId="2" ParentId="7483" CreationDate="2021-12-26T10:39:03.973" Score="4" Body="&lt;p&gt;The key is a tuple of strings and not a tuple of numbers.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;# Set and parameters&#xA;I = [&amp;quot;i1&amp;quot;];&#xA;J = [&amp;quot;j1&amp;quot;];&#xA;#Parameters form = {(&amp;quot;i1&amp;quot;, &amp;quot;j1&amp;quot;): number}&#xA;&#xA;# model&#xA;mdl = Model(name='name')&#xA;&#xA;# Declare variables&#xA;idx_x = [(i,j) for i in I for j in J]&#xA;x = mdl.binary_var_dict(idx_x, name=&amp;quot;x&amp;quot;);&#xA;&#xA;&#xA;# The optimization model&#xA;#objective function &amp;amp; model constraints &#xA;&#xA;# output&#xA;mdl.print_information()&#xA;m = mdl.solve(log_output=True)&#xA;s = m.display()&#xA;&#xA;for v in mdl.iter_binary_vars():&#xA;  print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&#xA;&#xA;&#xA;for i in I:&#xA;  for j in J:&#xA;    print(&amp;quot;i=&amp;quot;,i,&amp;quot; and j=&amp;quot;,j,&amp;quot; gives &amp;quot;,x[(i,j)].solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solution for: name&#xA;x_i1_j1  =  0&#xA;i= i1  and j= j1  gives  0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and with regards to the constraint you could try&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;gamma=0&#xA;mdl.add(gamma==1-sum(x[(i,j)] for i in I for j in J))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2021-12-27T16:01:24.217" LastActivityDate="2021-12-27T16:01:24.217" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7485" PostTypeId="1" CreationDate="2021-12-27T11:05:18.457" Score="3" ViewCount="101" Body="&lt;p&gt;I would like to know if there is a general name for the following problem:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;We will open several facilities. Each facility has an associated facility type. There exists a given number of facility types. More than one facilities of same type can be open.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We want to decide&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;locations of facilities to open (e.g. boolean &lt;span class=&quot;math-container&quot;&gt;$x_{ki}$&lt;/span&gt; which is true iff facility of type &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is open at location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;)&#xA;and&lt;/li&gt;&#xA;&lt;li&gt;one-way supplier-relationships between pairs of facilities (e.g. boolean &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; which is true iff a facility at location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is a supplier for the facility at location &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;subject to some constraints (e.g. every open facility has to be supplied), and minimize some cost function which depends on distance between facilities as is often the case.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The number and allowed facility types of suppliers for each facility type are given as a parameter, for example, as a list of relationships of the form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$m + n \to k$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;indicating that facility of type &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; must be supplied by a type &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; facility and a type &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; facility.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I think this problem somewhat resembles the &lt;a href=&quot;https://link.springer.com/article/10.1007%2Fs11066-016-9102-6&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multi-product capacitated facility location problem&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;, but not quite. In the problem described above each facility is also a customer, and there is no clear distinction between customer and facility.&lt;/p&gt;&#xA;&lt;p&gt;I also came across &amp;quot;Hierarchical facility location problem&amp;quot;, and in particular &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-030-32177-2_13&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multi-Level Facility Location Problems&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt; (MLFLP). This also seems related, but the relationships given in (3) can be arbitrarily complex; whereas, the MLFLP seems to deal with few pre-defined levels.&lt;/p&gt;&#xA;&lt;p&gt;I would like to know if there is something that is more similar.&lt;/p&gt;&#xA;&lt;p&gt;Note: I believe that the problem described above must be well-studied and there should be a better match, because it basically captures the essence of economy in general, with complex products (and associated facilities) requiring other less-complex products (and associated facilities) as defined in (3). I am trying to find existing work which studied this problem.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Montoya, A., Vélez–Gallego, M. C., Villegas, J. G. (2016). Multi-product capacitated facility location problem with general production and building costs. &lt;em&gt;NETNOMICS: Economic Research and Electronic Networking.&lt;/em&gt; 17(1):47-70. &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [2] Contreras, I., Ortiz-Astorquiza, C. (2019). Hierarchical Facility Location Problems. In &lt;em&gt;Location Science&lt;/em&gt; (pp. 365-389). Springer, Cham. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="8775" LastEditorUserId="123" LastEditDate="2021-12-27T11:20:17.810" LastActivityDate="2021-12-27T11:20:17.810" Title="What is the general name (e.g. facility location problem) for this problem (if any)?" Tags="|modeling|reference-request|facility-location|terminology|" AnswerCount="0" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7486" PostTypeId="2" ParentId="7472" CreationDate="2021-12-27T19:26:27.317" Score="3" Body="&lt;p&gt;Unfortunately, I also do not know how to embed 0-1-knapsack specific inequalities with the odd number solution requirement. However, I know how to generate cuts that will reduce the search space whenever an even number of items is picked. So, let &lt;span class=&quot;math-container&quot;&gt;$x^{*} \in \mathbb{R}^{n}$&lt;/span&gt; be an optimal, eventually fractional, solution. If &lt;span class=&quot;math-container&quot;&gt;$\sum_{j} x^{*}_j$&lt;/span&gt; is an integer even number, then we can say that &lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in I} x_j - \sum_{k \notin I} x_k \leqslant |I| - 1$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$I = \{j : x^*_j &amp;gt; 0\}$&lt;/span&gt;. With these thoughts in mind, fluidly we design the below separation algorithm (callback):&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get &lt;span class=&quot;math-container&quot;&gt;$x^{*}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$\sum_{j} x_j^{*}$&lt;/span&gt; is integer and even then:&lt;/li&gt;&#xA;&lt;li&gt;Add &lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in I} x_j - \sum_{k \notin I} x_k \leqslant |I| - 1$&lt;/span&gt; to the formulation.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Actually, we can play a little bit with the addition of a new variable; as you commented earlier. Let &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{N}$&lt;/span&gt; be a natural variable, then we can force the formulation, on its integer solution space, to consider only &lt;span class=&quot;math-container&quot;&gt;$\sum_{j} x_j$&lt;/span&gt; as odd numbers, if we say that &lt;span class=&quot;math-container&quot;&gt;$\sum_{j} x_j = 2 y + 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, we can try out new branching rules, where we basically branch on odd numbers.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get &lt;span class=&quot;math-container&quot;&gt;$x^{*}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$F = \lfloor \frac{\sum_{j} x^*_j}{2} \rfloor$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$C = \lceil \frac{\sum_{j} x^*_j}{2} \rceil$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$C = F$&lt;/span&gt; then:&lt;/li&gt;&#xA;&lt;li&gt;start &lt;em&gt;branching&lt;/em&gt; on &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;exit&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is odd then:&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;branch&lt;/em&gt; on &lt;span class=&quot;math-container&quot;&gt;$\sum_{j} x_j \leqslant F$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;branch&lt;/em&gt; on &lt;span class=&quot;math-container&quot;&gt;$\sum_{j} x_j \geqslant C + 1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;else:&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;branch&lt;/em&gt; on &lt;span class=&quot;math-container&quot;&gt;$\sum_{j} x_j \leqslant F - 1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;branch&lt;/em&gt; on &lt;span class=&quot;math-container&quot;&gt;$\sum_{j} x_j \geqslant C$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Case anyone has any questions or suggestions, please feel free.&lt;/p&gt;&#xA;&lt;p&gt;UPDATE 1: Updating step 3 of the first algorithm. ps.: thanks @RobPratt for the observation and the edge case.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="2862" LastEditDate="2021-12-29T21:57:49.667" LastActivityDate="2021-12-29T21:57:49.667" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7487" PostTypeId="2" ParentId="7107" CreationDate="2021-12-28T20:21:26.283" Score="2" Body="&lt;p&gt;I just came across this randomly. I am actually a doctoral student with a focus on interactive multiobjective methods. Typically if the constraints are soft, we can treat them as extra objective functions. Then, you definitely have a multiobjective optimization problem at hand. If you solve it with a proper method you will get a nice set of tradeoffs between constraints A and B and you will not need to change the weights over and over again.&lt;/p&gt;&#xA;" OwnerUserId="8784" LastActivityDate="2021-12-28T20:21:26.283" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7488" PostTypeId="1" AcceptedAnswerId="7490" CreationDate="2021-12-29T19:55:01.917" Score="2" ViewCount="756" Body="&lt;p&gt;I am working with the R programming language. Given a data set (&amp;quot;my_data&amp;quot;), I am trying to use an mixed integer optimization algorithm (e.g. genetic algorithm) to find out which filters applied on which variables produces the smallest percentage of zero values (subject to some constraints).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Part 1:&lt;/strong&gt; Here is the data I am using&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set.seed(123)&#xA;&#xA;num_var_1 &amp;lt;- abs(rnorm(1000, 10, 1))&#xA;num_var_2 &amp;lt;- abs(rnorm(1000, 10, 5))&#xA;num_var_3 &amp;lt;- abs(rnorm(1000, 10, 10))&#xA;num_var_4 &amp;lt;- abs(rnorm(1000, 10, 10))&#xA;num_var_5 &amp;lt;- abs(rnorm(1000, 10, 10))&#xA;&#xA;factor_1 &amp;lt;- c(&amp;quot;0&amp;quot;,&amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;)&#xA;factor_2 &amp;lt;- c(&amp;quot;0&amp;quot;,&amp;quot;BB&amp;quot;, &amp;quot;CC&amp;quot;)&#xA;factor_3 &amp;lt;- c(&amp;quot;0&amp;quot;,&amp;quot;BBB&amp;quot;, &amp;quot;CCC&amp;quot;, &amp;quot;DDD&amp;quot;)&#xA;factor_4 &amp;lt;- c(&amp;quot;0&amp;quot;,&amp;quot;BBBB&amp;quot;, &amp;quot;CCCC&amp;quot;, &amp;quot;DDDD&amp;quot;, &amp;quot;EEEE&amp;quot;)&#xA;factor_5 &amp;lt;- c(&amp;quot;0&amp;quot;,&amp;quot;BBBBB&amp;quot;, &amp;quot;CCCCC&amp;quot;, &amp;quot;DDDDD&amp;quot;, &amp;quot;EEEEE&amp;quot;, &amp;quot;FFFFFF&amp;quot;)&#xA;&#xA;factor_var_1 &amp;lt;- as.factor(sample(factor_1, 1000, replace=TRUE, prob=c(0.3, 0.5, 0.2)))&#xA;factor_var_2 &amp;lt;-  as.factor(sample(factor_2, 1000, replace=TRUE, prob=c(0.5, 0.3, 0.2)))&#xA;factor_var_3 &amp;lt;-  as.factor(sample(factor_3, 1000, replace=TRUE, prob=c(0.5, 0.2, 0.2, 0.1)))&#xA;factor_var_4 &amp;lt;-  as.factor(sample(factor_4, 1000, replace=TRUE, prob=c(0.5, 0.2, 0.1, 0.1, 0.1)))&#xA;factor_var_5 &amp;lt;-  as.factor(sample(factor_4, 1000, replace=TRUE, prob=c(0.3, 0.2, 0.1, 0.1, 0.1)))&#xA;&#xA;id = 1:1000&#xA;&#xA;my_data = data.frame(id,num_var_1, num_var_2, num_var_3, num_var_4, num_var_5, factor_var_1, factor_var_2, factor_var_3, factor_var_4, factor_var_5)&#xA;&#xA;#randomly add some zeros to the data&#xA;my_data[] &amp;lt;- lapply(my_data, function(x) {&#xA;  x[sample(seq_along(x), length(x)/2)] &amp;lt;- 0&#xA;  x&#xA;})&#xA;&#xA; head(my_data)&#xA;  id num_var_1 num_var_2 num_var_3 num_var_4 num_var_5 factor_var_1 factor_var_2 factor_var_3 factor_var_4 factor_var_5&#xA;1  1 10.357273 19.219814 27.031869   0.00000  3.865392            0           BB            0            0            0&#xA;2  2  0.000000  8.746435  0.000000   0.00000  1.047103            0            0          CCC            0            0&#xA;3  3  8.608149 10.192377  5.528652  11.39321 19.821561            0           BB            0            0         BBBB&#xA;4  0 11.555258 14.732870  8.651462  12.54166  0.000000            0           BB            0            0            0&#xA;5  5 10.125296  0.000000  8.095136   0.00000 31.131257            0            0            0         CCCC         EEEE&#xA;6  6  8.832702  9.877200  3.155799  16.06504 20.368927            0            0            0            0            0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Part 2:&lt;/strong&gt; Here are the acceptable ranges for each of the variables&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;num_var_1 has to be between range(num_var_1) : &lt;code&gt;7.029118 , 13.014451&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;num_var_2 has to be between range(num_var_2) : &lt;code&gt;0.0296502 ,  29.6070503&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;num_var_3 has to be between range(num_var_3) : &lt;code&gt;0.02422479 ,  46.72178885&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;num_var_4 has to be between range(num_var_4) : &lt;code&gt;0.03661167 ,  53.22815207&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;num_var_5 has to be between range(num_var_5) : &lt;code&gt;0.01581034 ,  41.22046108&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;factor_var_1 can take any of the following values (all possible combinations of levels) : &lt;code&gt;&amp;quot;none&amp;quot;      &amp;quot;0&amp;quot;         &amp;quot;B&amp;quot;         &amp;quot;C&amp;quot;         &amp;quot;0 &amp;amp; B&amp;quot;     &amp;quot;0 &amp;amp; C&amp;quot;     &amp;quot;B &amp;amp; C&amp;quot;     &amp;quot;0 &amp;amp; B &amp;amp; C&amp;quot;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;factor_var_2 can take any of the following values (all possible combinations of levels): &lt;code&gt;&amp;quot;none&amp;quot;        &amp;quot;0&amp;quot;           &amp;quot;BB&amp;quot;          &amp;quot;CC&amp;quot;          &amp;quot;0 &amp;amp; BB&amp;quot;      &amp;quot;0 &amp;amp; CC&amp;quot;      &amp;quot;BB &amp;amp; CC&amp;quot;     &amp;quot;0 &amp;amp; BB &amp;amp; CC&amp;quot;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;factor_var_3 can take any of the following values (all possible combinations of levels):&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt; &amp;quot;none&amp;quot;                &amp;quot;0&amp;quot;                   &amp;quot;BBB&amp;quot;                 &amp;quot;CCC&amp;quot;                 &amp;quot;DDD&amp;quot;                 &amp;quot;0 &amp;amp; BBB&amp;quot;             &amp;quot;0 &amp;amp; CCC&amp;quot;             &amp;quot;0 &amp;amp; DDD&amp;quot;             &amp;quot;BBB &amp;amp; CCC&amp;quot;           &amp;quot;BBB &amp;amp; DDD&amp;quot;           &amp;quot;CCC &amp;amp; DDD&amp;quot;           &amp;quot;0 &amp;amp; BBB &amp;amp; CCC&amp;quot;       &amp;quot;0 &amp;amp; BBB &amp;amp; DDD&amp;quot;       &amp;quot;0 &amp;amp; CCC &amp;amp; DDD&amp;quot;       &amp;quot;BBB &amp;amp; CCC &amp;amp; DDD&amp;quot;     &amp;quot;0 &amp;amp; BBB &amp;amp; CCC &amp;amp; DDD&amp;quot;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;factor_var_4 and factor_var_5 can take any of the following values (all possible combinations of levels):&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt; &amp;quot;none&amp;quot;                          &amp;quot;0&amp;quot;                             &amp;quot;BBBB&amp;quot;                          &amp;quot;CCCC&amp;quot;                          &amp;quot;DDDD&amp;quot;                          &amp;quot;EEEE&amp;quot;                          &amp;quot;0 &amp;amp; BBBB&amp;quot;                      &amp;quot;0 &amp;amp; CCCC&amp;quot;                      &amp;quot;0 &amp;amp; DDDD&amp;quot;                      &amp;quot;0 &amp;amp; EEEE&amp;quot;                      &amp;quot;BBBB &amp;amp; CCCC&amp;quot;                   &amp;quot;BBBB &amp;amp; DDDD&amp;quot;                   &amp;quot;BBBB &amp;amp; EEEE&amp;quot;                   &amp;quot;CCCC &amp;amp; DDDD&amp;quot;                   &amp;quot;CCCC &amp;amp; EEEE&amp;quot;                   &amp;quot;DDDD &amp;amp; EEEE&amp;quot;                   &amp;quot;0 &amp;amp; BBBB &amp;amp; CCCC&amp;quot;               &amp;quot;0 &amp;amp; BBBB &amp;amp; DDDD&amp;quot;               &amp;quot;0 &amp;amp; BBBB &amp;amp; EEEE&amp;quot;               &amp;quot;0 &amp;amp; CCCC &amp;amp; DDDD&amp;quot;               &amp;quot;0 &amp;amp; CCCC &amp;amp; EEEE&amp;quot;               &amp;quot;0 &amp;amp; DDDD &amp;amp; EEEE&amp;quot;               &amp;quot;BBBB &amp;amp; CCCC &amp;amp; DDDD&amp;quot;            &amp;quot;BBBB &amp;amp; CCCC &amp;amp; EEEE&amp;quot;            &amp;quot;BBBB &amp;amp; DDDD &amp;amp; EEEE&amp;quot;            &amp;quot;CCCC &amp;amp; DDDD &amp;amp; EEEE&amp;quot;            &amp;quot;0 &amp;amp; BBBB &amp;amp; CCCC &amp;amp; DDDD&amp;quot;        &amp;quot;0 &amp;amp; BBBB &amp;amp; CCCC &amp;amp; EEEE&amp;quot;        &amp;quot;0 &amp;amp; BBBB &amp;amp; DDDD &amp;amp; EEEE&amp;quot;        &amp;quot;0 &amp;amp; CCCC &amp;amp; DDDD &amp;amp; EEEE&amp;quot;        &amp;quot;BBBB &amp;amp; CCCC &amp;amp; DDDD &amp;amp; EEEE&amp;quot;     &amp;quot;0 &amp;amp; BBBB &amp;amp; CCCC &amp;amp; DDDD &amp;amp; EEEE&amp;quot;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Part 3:&lt;/strong&gt; This is the function (&amp;quot;f&amp;quot;) I am trying to optimize - this function takes 10 inputs (filters for each of the 10 variables in &amp;quot;my_data&amp;quot;), creates a new data set according to the specified filters, and then returns the overall percentage of zeros in the data set:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;library(dplyr)&#xA;&#xA;f &amp;lt;- function(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) {&#xA;&#xA;target1 = x1&#xA;target2 = x2&#xA;target3 = x3&#xA;target4 = x4&#xA;target5 = x5&#xA;target6 = x6&#xA;target7 = x7&#xA;target8 = x8&#xA;target9 = x9&#xA;target10 = x10&#xA;&#xA;result &amp;lt;-  filter(my_data[,-1], num_var_1 &amp;lt; target1 &amp;amp; num_var_2 &amp;lt; target2 &amp;amp; num_var_3 &amp;lt; target3 &amp;amp; num_var_4 &amp;lt;target4 &amp;amp; num_var_5 &amp;lt;target5 &amp;amp; &#xA;factor_var_1 %in% target6 &amp;amp; factor_var_2 %in% target7 &amp;amp; factor_var_3 %in% target8 &amp;amp; factor_var_4 %in% target9 &amp;amp; factor_var_5 %in% target10)&#xA;s = sum(result == '0', na.rm = TRUE) / prod(dim(result)) * 100&#xA;return(1 - s)&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As an example, we test to see if this function runs:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; f(10, 10, 10, 10, 10, &amp;quot;0&amp;quot;, &amp;quot;0&amp;quot;, &amp;quot;0&amp;quot;, c(&amp;quot;CCCC&amp;quot;,&amp;quot;EEEE&amp;quot;), &amp;quot;EEEE&amp;quot;)&#xA;&#xA;&#xA;&#xA;[1] 63.63636&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; Can someone please show me how to use an optimization algorithm to optimize the function &amp;quot;f&amp;quot;? In the past, I usually used the &amp;quot;GA&amp;quot; library in R (&lt;a href=&quot;https://cran.r-project.org/web/packages/GA/vignettes/GA.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cran.r-project.org/web/packages/GA/vignettes/GA.html&lt;/a&gt;) for optimizing functions where all variables can only take numerical outputs.&lt;/p&gt;&#xA;&lt;p&gt;If I only had to deal with numerical inputs, I could optimize a modified version of the function &amp;quot;f&amp;quot; using the GA library in R:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#modified version of &amp;quot;f&amp;quot; with only numerical inputs&#xA;&#xA;f_mod &amp;lt;- function(x1, x2, x3, x4, x5) {&#xA;    &#xA;    target1 = x1&#xA;    target2 = x2&#xA;    target3 = x3&#xA;    target4 = x4&#xA;    target5 = x5&#xA;    &#xA;    &#xA;    result &amp;lt;-  filter(my_data[,-1], num_var_1 &amp;lt; target1 &amp;amp; num_var_2 &amp;lt; target2 &amp;amp; num_var_3 &amp;lt; target3 &amp;amp; num_var_4 &amp;lt;target4 &amp;amp; num_var_5 &amp;lt;target5 )&#xA;    s = sum(result == '0', na.rm = TRUE) / prod(dim(result)) &#xA;    return(1 - s )&#xA;    &#xA;}&#xA;&#xA;library(GA)&#xA;&#xA;GA &amp;lt;- ga(type = &amp;quot;real-valued&amp;quot;, &#xA;         fitness = function(x)  f_mod(x[1], x[2], x[3], x[4], x[5]),&#xA;         lower = c( min(num_var_1),  min(num_var_2),  min(num_var_3),  min(num_var_4),  min(num_var_5)), upper = c( max(num_var_1),  max(num_var_2),  max(num_var_3),  max(num_var_4),  max(num_var_5)), &#xA;         popSize = 50, maxiter = 100, run = 100)&#xA;&#xA;&#xA;# results of the 100 iterations:&#xA;&#xA;GA | iter = 1 | Mean = 65.58077 | Best = 75.30529&#xA;GA | iter = 2 | Mean = 66.92623 | Best = 75.30529&#xA;&#xA;....&#xA;&#xA;GA | iter = 99 | Mean = 79.04933 | Best = 80.62201&#xA;GA | iter = 100 | Mean = 79.08810 | Best = 80.62201&#xA;&#xA;#view final solution&#xA;&#xA; GA@solution&#xA;&#xA;           x1       x2        x3       x4        x5&#xA;[1,] 7.624509 3.220958 0.3176768 2.287231 0.5194747&#xA;[2,] 7.625705 3.235704 0.3180106 2.307864 0.5196744&#xA;&#xA;GA@fitnessValue&#xA;&#xA;[1] 80.62201&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;But I do not know how I can write the above optimization algorithm to accommodate a function with numerical inputs and factor inputs.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Can someone please show me how to optimize the original function &amp;quot;f&amp;quot; using some optimization package in R (e.g. lpsolve, nloptr)?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Extra 1:&lt;/strong&gt; Visualizing the Optimization Algorithm's Progress&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;plot(GA, main = &amp;quot;Results of Optimization on f_mod&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ak8wW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ak8wW.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Extra 2:&lt;/strong&gt; Code to Obtain All Factor Levels:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;factor_1 &amp;lt;- c(&amp;quot;AAAA&amp;quot;,&amp;quot;BBBB&amp;quot;, &amp;quot;CCCC&amp;quot;, &amp;quot;DDDD&amp;quot;, &amp;quot;EEEE&amp;quot;)&#xA;factor_2 &amp;lt;- c(&amp;quot;B1&amp;quot;, &amp;quot;C1&amp;quot;, &amp;quot;D1&amp;quot;, &amp;quot;E1&amp;quot;, &amp;quot;F1&amp;quot;)&#xA;&#xA;factor_var_1 &amp;lt;-  as.factor(sample(factor_1, 1000, replace=TRUE, prob=c(0.5, 0.2, 0.1, 0.1, 0.1)))&#xA;factor_var_2 &amp;lt;-  as.factor(sample(factor_2, 1000, replace=TRUE, prob=c(0.3, 0.2, 0.1, 0.1, 0.1)))&#xA;&#xA;my_data = data.frame(factor_var_1, factor_var_2)&#xA;&#xA;fac4 = levels(my_data&lt;span class=&quot;math-container&quot;&gt;$factor_var_1)&#xA;fac5 = levels(my_data$&lt;/span&gt;factor_var_2)&#xA;   &#xA;my_list = list(fac1, fac2)&#xA;&#xA;&#xA;&#xA;st1 &amp;lt;- lapply(my_list, function(x) c(&amp;quot;none&amp;quot;, unlist(lapply(seq_len(length(x)), function(i) combn(x, i, FUN = paste, collapse = &amp;quot; &amp;amp; &amp;quot;)))));&#xA;&#xA;#view answer&#xA;&#xA; st1&#xA;&#xA;[[1]]&#xA;[1] &amp;quot;none&amp;quot;      &amp;quot;0&amp;quot;         &amp;quot;B&amp;quot;         &amp;quot;C&amp;quot;         &amp;quot;0 &amp;amp; B&amp;quot;     &amp;quot;0 &amp;amp; C&amp;quot;     &amp;quot;B &amp;amp; C&amp;quot;     &amp;quot;0 &amp;amp; B &amp;amp; C&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-01-02T20:44:50.117" LastActivityDate="2022-01-02T20:44:50.117" Title="Mixed Integer Programming/Optimization using the Genetic Algorithm" Tags="|optimization|mixed-integer-programming|linear-programming|knapsack|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7489" PostTypeId="1" CreationDate="2021-12-30T01:29:09.170" Score="1" ViewCount="71" Body="&lt;p&gt;I am currently trying to understand the concept of GENIUS.&#xA;It was a method devoloped to solve the tsp.&lt;/p&gt;&#xA;&lt;p&gt;The first step seems logical to me:&#xA;GENI (construction phase): start of with an tour of 3 nodes and randomly add the leftover nodes between the existing nodes until all nodes are in the tour.&lt;/p&gt;&#xA;&lt;p&gt;Clear so far.. now i get confused how/why the improvement is being performed&#xA;US(postoptimization phase): Unstring/Stringing&lt;/p&gt;&#xA;&lt;p&gt;Could anyone outline the idea of this procedure clearly?&lt;/p&gt;&#xA;" OwnerUserId="4380" LastActivityDate="2021-12-30T01:29:09.170" Title="GENIUS (General Insertion (GENI) + Unstringing / Stringing (US) - Anyone familiar with the procedure? I have questions" Tags="|optimization|vehicle-routing|traveling-salesman|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7490" PostTypeId="2" ParentId="7488" CreationDate="2021-12-30T17:36:35.927" Score="7" Body="&lt;p&gt;It is possible (but a bit tricky) to write a mixed-integer linear program for this problem. If you are willing to accept a good but not guaranteed optimal solution, though, the GA is easily modified to handle it. The key is to use a chromosome of 10 real values, where the sixth through tenth are rounded down to the next lower integer and used to index a filter value for each factor variable from a list of all possible filter values.&lt;/p&gt;&#xA;&lt;p&gt;I modified your code above to demonstrate this. In doing so, I corrected the output of the f function to be 100-s rather than 1-s, and also did away with the &amp;quot;none&amp;quot; option for each factor variable (which, if selected, results in no rows being chosen by the filter). You can see the results (and if desired extract the code) in this &lt;a href=&quot;https://rubin.msu.domains/code/filter.nb.html&quot; rel=&quot;noreferrer&quot;&gt;notebook file&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2021-12-30T17:36:35.927" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="7491" PostTypeId="1" CreationDate="2021-12-31T15:32:59.913" Score="1" ViewCount="77" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BzRfl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BzRfl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;I am trying to solve a large-scale MIP problem in docplex(python). I give to the model a MIP start solution, I remark that after 20 hours, the best integer still the cost of the MIP start and the best bound is fix to zero. There is any explanation to zeros in the best bound ??&lt;a href=&quot;https://i.stack.imgur.com/5I0r1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5I0r1.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5537" LastEditorUserId="5537" LastEditDate="2021-12-31T16:53:10.677" LastActivityDate="2021-12-31T16:53:10.677" Title="Meaning of zeros in the column best bound in docplex?" Tags="|mixed-integer-programming|python|docplex|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7492" PostTypeId="1" CreationDate="2021-12-31T20:08:00.523" Score="2" ViewCount="57" Body="&lt;p&gt;THE PROBLEM&lt;/p&gt;&#xA;&lt;p&gt;A refinery has 10 million barrels of type A crude and 6 million barrels of&#xA;Type B crude oil. The refinery has 3 plants to produce Gasoline (it makes a profit&#xA;of 2 USD / barrel) and Naphtha (makes a profit of 1 USD / barrel) with the following&#xA;features:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{|l|l|l|l|l|}&#xA; &amp;amp; Input  &amp;amp; { Input } &amp;amp; { Output } &amp;amp; { Output } \\&#xA;\hline \text { plant } &amp;amp; \text { A } &amp;amp; \text { B } &amp;amp; \text { Gasoline } &amp;amp; \text { Naphtha } \\&#xA;\hline 1 &amp;amp; 3 &amp;amp; 5 &amp;amp; 4 &amp;amp; 3 \\&#xA;\hline 2 &amp;amp; 1 &amp;amp; 1 &amp;amp; 1 &amp;amp; 1 \\&#xA;\hline 3 &amp;amp; 5 &amp;amp; 3 &amp;amp; 3 &amp;amp; 4 \\&#xA;\hline&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The data in the table above means that, for example, if 3 barrels of crude oil type A and 5 barrels of type B crude enter plant 1, you can get 4 barrels of Gasoline and 3 barrels of Naphtha.&lt;/p&gt;&#xA;&lt;p&gt;MY SOLUTION:&#xA;You can find my solution attempt here &lt;a href=&quot;https://or.stackexchange.com/questions/7477/how-to-construct-the-linear-programing-representation-of-a-blending-problem&quot;&gt;How to construct the linear programing representation of a blending problem?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Regarding the possible solution, it is evident that the program will be sending all of the crudes A and B to plant 3 to maximize the profit since we need 5 times of crude A and 3 times of crude B to produce 3 barrels of Gasoline and 4 barrels of Naphtha. I said, &amp;quot;evident&amp;quot; because processing all of the raw material will allow having 2 &amp;quot;batches&amp;quot; at plant 3, blending 5 million of A and 3 million of B each time, and using all the raw material.&lt;/p&gt;&#xA;&lt;p&gt;I'm having an issue traducing my logic into a restriction.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;DOUBT:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you can see in the table, for plant 1, we will have a restriction for the needed combinations of inputs to get a certain amount of Gasoline and Naphtha as a result of the blending of Crude A and Crude B:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;3A+5B &amp;amp;\geq 4G+3N&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Taking this with my decision variables we'll have:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;3x_{A,1}+5x_{B,1}=4y_{G,1}+3y_{N,1}&#xA;\end{align}&lt;/span&gt;&#xA;where:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{ij} \text{ the Qty of crude } i \in \{A,B\} \text{ to plant } j \in \{1,2,3\} \\&#xA;y_{kj} \text{ the Qty of final product } k \in \{G,N\} \text{ produced by plant } j \in \{1,2,3\}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So I'll need to establish a coefficient of proportions required for each plant, considering that we need 2 inputs with specific ratios for each plant to get 2 final products.&lt;/p&gt;&#xA;&lt;p&gt;Thank you for any correction and any guidance with this.&lt;/p&gt;&#xA;" OwnerUserId="8764" LastEditorUserId="8764" LastEditDate="2022-01-01T03:48:42.417" LastActivityDate="2022-01-01T03:48:42.417" Title="How to construct a restriction for a blending problem that has 2 inputs that are blended, and as result we get 2 outputs?" Tags="|optimization|mixed-integer-programming|linear-programming|modeling|integer-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7493" PostTypeId="1" CreationDate="2022-01-01T02:21:57.887" Score="3" ViewCount="51" Body="&lt;p&gt;HST is usually proven through the existence of a unique minimum-norm vector in a nonempty closed convex set. I think this is an existential proof.&lt;/p&gt;&#xA;&lt;p&gt;However, to actually apply the result in a real world problem, one might need to find the actual number of the minimum-norm vector through construction.&lt;/p&gt;&#xA;&lt;p&gt;Do we have a simple constructive proof for HST?&lt;/p&gt;&#xA;" OwnerUserId="3956" LastEditorUserId="3956" LastEditDate="2022-01-01T03:03:28.983" LastActivityDate="2022-01-01T03:03:28.983" Title="Constructive proof for the Hyperplane Separating Theorem (HST)?" Tags="|optimization|convex-optimization|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7494" PostTypeId="1" CreationDate="2022-01-01T11:58:48.687" Score="3" ViewCount="374" Body="&lt;p&gt;For all &lt;span class=&quot;math-container&quot;&gt;$i \in I,j\in J$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt;, define variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}, z_{ijk}\in\{0,1\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_{ij}\geq 0$&lt;/span&gt; and constants &lt;span class=&quot;math-container&quot;&gt;$c_j, e_{ijk}, d_j, f_j &amp;gt;0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We have the following constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j\in J_1}c_j\frac{x_{ij}}{\sum_{k\in K}e_{ijk}z_{ijk}} + \sum_{j\in J_2}c_jf_j x_{ij} = \sum_{j\in J_1}d_j\frac{y_{ij}}{\sum_{k\in K}e_{ijk}z_{ijk}} + \sum_{j\in J_2}d_jf_j y_{ij} \quad \forall i\in I,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$J_1, J_2 \subset J$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We also know that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k\in K}e_{ijk}z_{ijk}=1 \quad \forall i\in I,j\in J.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now is there a way to linearize these two components?&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{x_{ij}}{\sum_{k\in K}e_{ijk}z_{ijk}}, \quad \frac{y_{ij}}{\sum_{k\in K}e_{ijk}z_{ijk}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I saw some interesting answers &lt;a href=&quot;https://or.stackexchange.com/questions/6264/linearize-a-product-of-binary-variables&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;https://or.stackexchange.com/questions/2903/how-to-linearize-the-multiplication-of-an-integer-and-a-binary-integer-variable?rq=1&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/questions/39/how-to-linearize-the-product-of-a-binary-and-a-non-negative-continuous-variable?noredirect=1&amp;amp;lq=1&quot;&gt;here&lt;/a&gt; but I'm having some problems using them for our problem.&lt;/p&gt;&#xA;" OwnerUserId="7693" LastActivityDate="2022-01-01T14:24:49.320" Title="Linearizing division of two variables" Tags="|mixed-integer-programming|linearization|nonlinear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7495" PostTypeId="2" ParentId="7494" CreationDate="2022-01-01T14:24:49.320" Score="6" Body="&lt;p&gt;The two denominators are equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, so just omit the denominators, yielding a linear constraint.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-01-01T14:24:49.320" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7496" PostTypeId="1" CreationDate="2022-01-02T04:55:58.987" Score="7" ViewCount="2051" Body="&lt;p&gt;I have the following &amp;quot;logic puzzle&amp;quot; (I think this is considered as a &amp;quot;scheduling problem&amp;quot;):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iNqfi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iNqfi.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this problem, there are 5 basketball players - provided some clues about their nicknames and heights, you are required to find the correct combinations of players-nicknames-heights.&lt;/p&gt;&#xA;&lt;p&gt;In a previous post (&lt;a href=&quot;https://stackoverflow.com/questions/70527987/solving-logic-puzzles-using-r&quot;&gt;https://stackoverflow.com/questions/70527987/solving-logic-puzzles-using-r&lt;/a&gt;), I learned how to solve this problem with &amp;quot;brute force&amp;quot; using the &lt;strong&gt;R programming language&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;library(dplyr)&#xA;&#xA;dt &amp;lt;- purrr::cross_df(list(&#xA;  name = list(c(&amp;quot;Bill&amp;quot;, &amp;quot;Ernie&amp;quot;, &amp;quot;Oscar&amp;quot;, &amp;quot;Sammy&amp;quot;, &amp;quot;Tony&amp;quot;)),&#xA;  nickname = combinat::permn(c(&amp;quot;Slats&amp;quot;, &amp;quot;Stretch&amp;quot;, &amp;quot;Tiny&amp;quot;, &amp;quot;Tower&amp;quot;, &amp;quot;Tree&amp;quot;)), &#xA;  height = combinat::permn(c(6.6, 6.5, 6.3, 6.1, 6))&#xA;))&#xA;&#xA;dt %&amp;gt;%  &#xA;  group_by(id = (seq_len(n()) - 1L) %/% 5L) %&amp;gt;% &#xA;  filter(&#xA;    height[name == &amp;quot;Oscar&amp;quot;] &amp;gt; height[nickname == &amp;quot;Tree&amp;quot;], &#xA;    height[nickname == &amp;quot;Tree&amp;quot;] &amp;gt; height[name == &amp;quot;Tony&amp;quot;], &#xA;    height[name == &amp;quot;Bill&amp;quot;] &amp;gt; height[name == &amp;quot;Sammy&amp;quot;], &#xA;    height[name == &amp;quot;Bill&amp;quot;] &amp;lt; height[nickname == &amp;quot;Slats&amp;quot;], &#xA;    nickname[name == &amp;quot;Tony&amp;quot;] != &amp;quot;Tiny&amp;quot;,&#xA;    height[nickname == &amp;quot;Stretch&amp;quot;] &amp;gt; height[name == &amp;quot;Oscar&amp;quot;], &#xA;    height[nickname == &amp;quot;Stretch&amp;quot;] &amp;lt; 6.6&#xA;  )&#xA;&#xA;#output&#xA;# A tibble: 5 x 4&#xA;# Groups:   id [1]&#xA;  name  nickname height    id&#xA;  &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt;     &amp;lt;dbl&amp;gt; &amp;lt;int&amp;gt;&#xA;1 Bill  Stretch     6.5 14398&#xA;2 Ernie Slats       6.6 14398&#xA;3 Oscar Tiny        6.3 14398&#xA;4 Sammy Tree        6.1 14398&#xA;5 Tony  Tower       6   14398&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, I am curious to know if this problem can be solved using modern optimization algorithms. For instance, if there were 100,000 basketball players in this problem, it would simply be impossible to solve using brute force - to create a list containing combinations of every player-nickname-height would unlikely be storable within a computer.&lt;/p&gt;&#xA;&lt;p&gt;I have read that there modern optimization algorithms can be used instead (e.g. particle swarm optimization, simulated annealing, nelder-meade, genetic algorithm, etc.) for such problems. I have spent some time reading about the math behind these optimization algorithms and think I understand the general ideas - however, I am not sure how to define the &amp;quot;optimization functions&amp;quot; for these problems, and which &amp;quot;metric&amp;quot; should be used as a target.&lt;/p&gt;&#xA;&lt;p&gt;For example, in this problem, perhaps the &amp;quot;fraction of the optimization constraints satisfied&amp;quot; by each combination of player-height-nickname can be used as a metric?&lt;/p&gt;&#xA;&lt;p&gt;If (not factually correct, just sketching a quick example)&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Combinations 1 : Bill = Slats, Ernie = Stretch, Oscar = Tiny, Sammy = Tiny and Tony = Tree. Bill is 6'6, Ernie is 6'5, Oscar is 6'3, Sammy is 6'1 and Tony is 6'.&lt;/strong&gt; satisfies 3/4th's of the optimization constraints&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Combinations 53 : Bill = Stretch, Ernie = Slats, Oscar = Tiny, Sammy = Tiny and Tony = Tree. Bill is 6'6, Ernie is 6'5, Oscar is 6'3, Sammy is 6 and Tony is 6'1.&lt;/strong&gt; satisfies only 2/4th's of the optimization constraints&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Perhaps we might be able to say that Combination 1 had a higher &amp;quot;performance metric&amp;quot; than Combination 53, and as a result, it might be more advantageous to consider combinations that are &amp;quot;closer&amp;quot; to Combination 1 compared to Combination 53.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Can someone please show me how this basketball problem can be using modern optimization algorithms in the R programming language?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="38" LastEditDate="2022-04-11T00:46:51.877" LastActivityDate="2022-04-11T00:46:51.877" Title="Solving Logic puzzles through optimization" Tags="|optimization|mixed-integer-programming|modeling|combinatorial-optimization|puzzles-games|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7497" PostTypeId="2" ParentId="7496" CreationDate="2022-01-02T10:45:43.307" Score="7" Body="&lt;p&gt;This is similar to the well known &lt;a href=&quot;https://en.wikipedia.org/wiki/Zebra_Puzzle&quot; rel=&quot;nofollow noreferrer&quot;&gt;Zebra Puzzle&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can solve it using integer programming techniques as follows:&lt;/p&gt;&#xA;&lt;p&gt;Define binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{p,n}^h$&lt;/span&gt; that take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if player &lt;span class=&quot;math-container&quot;&gt;$p\in \{Bill,...,Tony\}$&lt;/span&gt; has nickname &lt;span class=&quot;math-container&quot;&gt;$n \in \{Slats,...,Tree\}$&lt;/span&gt; and height &lt;span class=&quot;math-container&quot;&gt;$h \in \{6,...,6'6 \}$&lt;/span&gt;. So &lt;span class=&quot;math-container&quot;&gt;$x_{p,n}^h=1$&lt;/span&gt; if and only if combination &lt;span class=&quot;math-container&quot;&gt;$(p,n,h)$&lt;/span&gt; is valid.&lt;/p&gt;&#xA;&lt;p&gt;There no objective function here, so just use a dummy one, e.g., &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, and minimize (or maximize) this function subject to the following set of constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;each player has a unique nickname and height:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{n}\sum_{h}x_{p,n}^h = 1 \quad \forall p &#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;each nickname has a unique player and height:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{p}\sum_{h}x_{p,n}^h = 1 \quad \forall n &#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;each height has a unique player and nickname:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{p}\sum_{n}x_{p,n}^h = 1 \quad \forall h &#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Oscar is taller than Tree... :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{Oscar,n}^{h_1} \le \sum_{p}\sum_{h_2| h_2 &amp;lt; h_1 } x_{p,Tree}^{h_2} \quad \forall n, \forall h_1&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;...who is taller than Tony:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{p,Tree}^{h_1} \le  \sum_{n}\sum_{h_2| h_2 &amp;lt; h_1 } x_{Tony,n}^{h_2} \quad \forall n,\; \forall h_1&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Bill is taller than Sammy...:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{Bill,n_1}^{h_1} \le \sum_{n_2}\sum_{h_2| h_2 &amp;lt; h_1 } x_{Sammy,n_2}^{h_2} \quad \forall n_1,\;\forall h_1&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;...but shorter than Slats:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{Bill,n}^{h_1} \le  \sum_{p}\sum_{h_2| h_2 &amp;gt; h_1 } x_{p,Slats}^{h_2} \quad \forall n,\; \forall h_1&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Tony's nickname is not Tiny:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{Tony,Tiny}^h = 0 \quad \forall h&#xA;$$&lt;/span&gt;&#xA;Note that you could also simply not define these variables.&lt;/li&gt;&#xA;&lt;li&gt;Stretch is taller than Oscar...:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{p,Stretch}^{h_1} \le  \sum_{n}\sum_{h_2| h_2 &amp;gt; h_1 } x_{Oscar,n}^{h_2} \quad \forall p,\; \forall h_1&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;...but not the tallest:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{p,Stretch}^{6'6} = 0 \quad \forall p&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Here is a Python implementation:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import *&#xA;&#xA;# define data&#xA;players = [&amp;quot;Bill&amp;quot;, &amp;quot;Ernie&amp;quot;, &amp;quot;Oscar&amp;quot;, &amp;quot;Sammy&amp;quot;, &amp;quot;Tony&amp;quot;]&#xA;nicknames = [&amp;quot;Slats&amp;quot;, &amp;quot;Stretch&amp;quot;, &amp;quot;Tiny&amp;quot;, &amp;quot;Tower&amp;quot;, &amp;quot;Tree&amp;quot;]&#xA;heights = [6, 6.1, 6.3, 6.5, 6.6]&#xA;&#xA;# create problem&#xA;prob = LpProblem(&amp;quot;B_Balls&amp;quot;, LpMinimize)&#xA;&#xA;# define variables&#xA;x = LpVariable.dicts(&amp;quot;x&amp;quot;, (players, nicknames, heights), cat=LpBinary)&#xA;&#xA;# add dummy objective function&#xA;prob += 0&#xA;&#xA;# each player has a unique nickame and height&#xA;for p in players:&#xA;    prob += lpSum(x[p][n][h] for n in nicknames for h in heights) == 1&#xA;&#xA;# each nickname has a unique player and height&#xA;for n in nicknames:&#xA;    prob += lpSum(x[p][n][h] for p in players for h in heights) == 1&#xA;&#xA;# each height has a unique player and nickname&#xA;for h in heights:&#xA;    prob += lpSum(x[p][n][h] for n in nicknames for p in players) == 1&#xA;&#xA;# Oscar is taller than Tree&#xA;for n in nicknames:&#xA;    for h in heights:&#xA;        prob += x[&amp;quot;Oscar&amp;quot;][n][h] &amp;lt;= lpSum(&#xA;            x[p][&amp;quot;Tree&amp;quot;][k] for p in players for k in heights if k &amp;lt; h&#xA;        )&#xA;&#xA;# Tree is taller than Tony&#xA;for p in players:&#xA;    for h in heights:&#xA;        prob += x[p][&amp;quot;Tree&amp;quot;][h] &amp;lt;= lpSum(&#xA;            x[&amp;quot;Tony&amp;quot;][n][k] for n in nicknames for k in heights if k &amp;lt; h&#xA;        )&#xA;&#xA;# Bill is taller than Sammy&#xA;for n in nicknames:&#xA;    for h in heights:&#xA;        prob += x[&amp;quot;Bill&amp;quot;][n][h] &amp;lt;= lpSum(&#xA;            x[&amp;quot;Sammy&amp;quot;][m][k] for m in nicknames for k in heights if k &amp;lt; h&#xA;        )&#xA;&#xA;# Bill is shorter than Slats&#xA;for n in nicknames:&#xA;    for h in heights:&#xA;        prob += x[&amp;quot;Bill&amp;quot;][n][h] &amp;lt;= lpSum(&#xA;            x[p][&amp;quot;Slats&amp;quot;][k] for p in players for k in heights if k &amp;gt; h&#xA;        )&#xA;&#xA;# Tony is not Tiny&#xA;for h in heights:&#xA;    prob += x[&amp;quot;Tony&amp;quot;][&amp;quot;Tiny&amp;quot;][h] == 0&#xA;&#xA;# Stretch is taller than Oscar&#xA;for p in players:&#xA;    for h in heights:&#xA;        prob += x[p][&amp;quot;Stretch&amp;quot;][h] &amp;lt;= lpSum(&#xA;            x[&amp;quot;Oscar&amp;quot;][n][k] for n in nicknames for k in heights if k &amp;lt; h&#xA;        )&#xA;&#xA;# Stretch is not the tallest&#xA;for p in players:&#xA;    prob += x[p][&amp;quot;Stretch&amp;quot;][6.6] == 0&#xA;&#xA;# solve problem, and iteratively find different solutions, if any&#xA;k = 1&#xA;while True:&#xA;   print()&#xA;   print(&amp;quot;solution %s&amp;quot; % k)&#xA;   k += 1&#xA;   prob.solve(pulp.PULP_CBC_CMD(msg=0))&#xA;   print(&amp;quot;Status:&amp;quot;, LpStatus[prob.status])&#xA;   # The solution is printed if it was deemed &amp;quot;optimal&amp;quot; i.e met the constraints&#xA;   if LpStatus[prob.status] == &amp;quot;Optimal&amp;quot;:&#xA;      # print solution&#xA;       for p in players:&#xA;          for n in nicknames:&#xA;             for h in heights:&#xA;                if value(x[p][n][h]) &amp;gt; 0.1:&#xA;                    print(p, n, h)&#xA;    # The constraint is added that the same solution cannot be returned again&#xA;    prob += lpSum(x[p][n][h] for p in players for n in nicknames for h in heights if value(x[p][n][h]) &amp;gt; 0.1) &amp;lt;= 5 - 1&#xA; &#xA;   # If a new optimal solution cannot be found, we end the program&#xA;   else:&#xA;       break&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A solution is found in 0.12 seconds with the default open-source CBC solver:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/UAB1E.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UAB1E.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And apparently this solution is unique.&lt;/p&gt;&#xA;&lt;p&gt;If I run the program with CPLEX, the problem is solved in &lt;strong&gt;0.01&lt;/strong&gt; sec:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/f12xx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/f12xx.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Another option would be to use some local search technique (e.g., tabu search), to minimize the number of &amp;quot;conflicts&amp;quot; given a configuration. You would have to define some move, for example, swap two nicknames, and count the number of times a constraint is violated. By iteratively moving around the search space while minimizing the number of violated constraints, you will (or should) converge to the desired solution. This has also been done for the Zebra Problem mentioned above.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-01-03T13:40:41.237" LastActivityDate="2022-01-03T13:40:41.237" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7498" PostTypeId="1" AcceptedAnswerId="7519" CreationDate="2022-01-02T17:12:02.437" Score="0" ViewCount="160" Body="&lt;p&gt;I have a college exercise that I need to create a linear programming model from an academic paper. This has to be written in Gusek software which uses GLPK as a resolver.&#xA;The article defines sets in this way&lt;/p&gt;&#xA;&lt;p&gt;DOI: &lt;a href=&quot;https://doi.org/10.1016/j.ijpe.2020.107742&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.ijpe.2020.107742&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/oFGRH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oFGRH.png&quot; alt=&quot;Table of sets&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;My doubt is on the &lt;span class=&quot;math-container&quot;&gt;$ K^i $&lt;/span&gt; set. I don't know how to represent the beginning and the end as the article explains for a model in GLPK code.&#xA;How could I do it? This doubt therefore solves my doubt about the &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N^i$&lt;/span&gt; set as well.&lt;/p&gt;&#xA;" OwnerUserId="8812" LastActivityDate="2022-01-04T18:47:31.473" Title="How do I get the first and last item of a set in GLPK" Tags="|linear-programming|ampl|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7499" PostTypeId="2" ParentId="7496" CreationDate="2022-01-02T20:48:54.563" Score="4" Body="&lt;p&gt;You can solve this using a constraint satisfaction/constraint programming (CP) solver (and possibly modeling language). In R, you might use the &lt;a href=&quot;https://cran.r-project.org/web/packages/rminizinc/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;rminizinc package&lt;/a&gt; package, which links to the open-source MiniZinc language, which comes with a number of solvers.&lt;/p&gt;&#xA;&lt;p&gt;CP models (which can be optimization models but are often just constraint satisfaction models) can be faster to solve than integer programming models when all variables are discrete and when logic constraints are present in the model. In particular, they generally come with built in &amp;quot;all different&amp;quot; constraints, which apply here. (No two players have the same height or the same nickname.)&lt;/p&gt;&#xA;&lt;p&gt;Some CP solvers are particularly good for scheduling problems (which this really is &lt;em&gt;not&lt;/em&gt;).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-02T20:48:54.563" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7500" PostTypeId="1" CreationDate="2022-01-02T22:17:57.720" Score="6" ViewCount="225" Body="&lt;p&gt;I am considering a bid prices (shadow price of the capacity constraint) problem (from &lt;a href=&quot;http://users.iems.northwestern.edu/%7Etito/pubs/resolving_revised.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chen, L. and Homem-de Mello, T. (2009).&lt;/a&gt;, page 14) where the acceptable classes for booking requests for itineraries need to be determined to maximize expected revenue over a time interval. Let &lt;span class=&quot;math-container&quot;&gt;$\{N_k (t)\}$&lt;/span&gt; denote the point process generated by the arrivals of class &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; customers. The demand for the booking horizon &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$\xi_k = N_k(\tau)$&lt;/span&gt;) has the following distribution for classes 1 and 2 (the distribution of &lt;span class=&quot;math-container&quot;&gt;$\xi_k$&lt;/span&gt; is approximated by a truncated Poisson):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\xi_1 =&#xA;\begin{cases}&#xA;5 &amp;amp;\text{ with prob. } 0.5\\&#xA;1 &amp;amp;\text{ with prob. } 0.5\\&#xA;\end{cases}, \&#xA;\xi_2 =&#xA;\begin{cases}&#xA;2 &amp;amp;\text{ with prob. } 0.5\\&#xA;4 &amp;amp;\text{ with prob. } 0.5\\&#xA;\end{cases}&#xA;$$&lt;/span&gt;&#xA;The capacity for seats is 4 and the fares are respectively 100 and 60. Consider the following initial problem (DLP):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_{x} &amp;amp;\quad 100 x_1 + 60 x_2\\&#xA;\text{s.t. }&amp;amp;\quad x_1 + x_2 \leq 4\\&#xA;&amp;amp;\quad 0 \leq x_i \leq \mathbb{E}[\xi_i]&#xA;\end{align}&lt;/span&gt;&#xA;For an arbitrary time &lt;span class=&quot;math-container&quot;&gt;$t \leq \tau$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$\xi_k^t$&lt;/span&gt; denote the random number of arrivals of class &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; up to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$\hat{\eta}^t$&lt;/span&gt; denote the number of sold seats up to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. The re-solving model is thus (re-solving DLP):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_{x} &amp;amp;\quad 100 x_1 + 60 x_2\\&#xA;\text{s.t. }&amp;amp;\quad x_1 + x_2 \leq 4-\hat{\eta}^t\\&#xA;&amp;amp;\quad 0 \leq x_i \leq \mathbb{E}[\xi_i - \xi_i^t]&#xA;\end{align}&lt;/span&gt;&#xA;Moreover, suppose that we can divide the time horizon into two periods such that in the first period there are two class-2 arrivals only. We have&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[\xi_1] = 3 \leq 4$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathbb{P}(\xi_1^t = 0)=1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;So &lt;span class=&quot;math-container&quot;&gt;$\mathbb{E}[\xi_1 - \xi_1^t] = 3$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The initial policy determined by the bid prices is to accept all the requests (DLP). Then, after the first period, two seats are occupied. When re-solving to obtain new bid prices after the class-2 arrivals, the policy becomes only accepting class-1 customers (I checked that the solution is &lt;span class=&quot;math-container&quot;&gt;$(2,0)^T$&lt;/span&gt; and expected revenue 150 because with probability 0.5 there is one ticket sold in class 1 for the re-solving DLP).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;However,&lt;/strong&gt; it is stated in the article that the expected revenue for the initial problem (DLP) is 155.95 in the second period, which is very unclear to me. In Julia code, the initial problem is as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using JuMP, Gurobi&#xA;&#xA;# DLP without resolving&#xA;function DLP()&#xA;    dlp = Model(Gurobi.Optimizer)&#xA;    &#xA;    class_1_dem = 0.5*5 + 0.5*1&#xA;    class_2_dem = 0.5*2 + 0.5*4&#xA;     &#xA;    @variable(dlp, x_1 &amp;gt;= 0)&#xA;    @variable(dlp, x_2 &amp;gt;= 0)&#xA;    @objective(dlp, Min, -(100*x_1 + 60*x_2))&#xA;    @constraint(dlp, cap, x_1 + x_2 &amp;lt;= 4)&#xA;    @constraint(dlp, x_1 &amp;lt;= class_1_dem)&#xA;    @constraint(dlp, x_2 &amp;lt;= class_2_dem)&#xA;    &#xA;    optimize!(dlp)&#xA;    rev = abs(objective_value(dlp))&#xA;    sol = [value(x_1), value(x_2)]&#xA;&#xA;    return sol, rev, abs(shadow_price(cap))&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and output &lt;code&gt;([3.0, 1.0], 360.0, 60.0)&lt;/code&gt;. How do I handle the realization of &lt;span class=&quot;math-container&quot;&gt;$\xi_2^1$&lt;/span&gt; to obtain 155.95 as expected revenue after the first period for the DLP?&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;155.95 = \mathbb{E}[\text{rev}] = \underbrace{0.5 (2\cdot 100 + 0 \cdot 60)}_{\text{2 seats in class 1 and 0 in class 2}} + \underbrace{0.5 (1\cdot 100 + x \cdot 60)}_{\text{1 seat in class 1 and } x \text{ in class 2}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;br /&gt;&#xA;This was probably a mistake in the article.&lt;/p&gt;&#xA;" OwnerUserId="8814" LastEditorUserId="8814" LastEditDate="2022-02-02T22:31:39.467" LastActivityDate="2022-02-02T22:31:39.467" Title="Airline revenue management re-solving problem" Tags="|linear-programming|modeling|duality|stochastic-programming|revenue|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7501" PostTypeId="1" CreationDate="2022-01-03T00:12:12.700" Score="11" ViewCount="3175" Body="&lt;p&gt;User &lt;a href=&quot;https://stackoverflow.com/users/638504/ddofborg&quot;&gt;ddofborg&lt;/a&gt; posted on Stack Overflow a programming &lt;a href=&quot;https://stackoverflow.com/questions/70508442/function-to-make-a-list-as-unsorted-as-possible/70510656&quot;&gt;question&lt;/a&gt; which hides a combinatorial optimisation problem.&lt;/p&gt;&#xA;&lt;p&gt;The idea is the following: given a list of URLs with their respective domain names, he wants to find the permutation which makes the domain names &amp;quot;as unsorted as possible&amp;quot;. By this he means that he does not want URLs with the same domain name to appear close to each other but, rather, he would like them to be as spaced apart as possible.&lt;/p&gt;&#xA;&lt;p&gt;For example, let the following be the input data to the problem:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;('host1.com', 'https://host1.com/id/4'),&#xA;('host1.com', 'https://host1.com/id/6'),&#xA;('host2.com', 'https://host2.com/abc'),&#xA;('host3.com', 'https://host3.com/x7'),&#xA;('host3.com', 'https://host3.com/f2'),&#xA;('host3.com', 'https://host3.com/l3')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In the above list all URLs associated with the same domain are close to each other, so the user wouldn't like this arrangement. The idea is that he will go through the URLs of this list and make some network request. He wants to space requests to the same domain apart, so that the corresponding server doesn't get overloaded. A solution the user would like is, e.g., the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;('host3.com', 'https://host3.com/x7'),&#xA;('host1.com', 'https://host1.com/id/4'),&#xA;('host2.com', 'https://host2.com/abc'),&#xA;('host3.com', 'https://host3.com/l3'),&#xA;('host1.com', 'https://host1.com/id/6'),&#xA;('host3.com', 'https://host3.com/f2')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To quantify his &amp;quot;unsortedness&amp;quot; criterion, the user proposes to assign an objective value to each possible permutation of URLs. Before introducing the objective function, however, let me propose some notation which will make the discussion proceed more quickly within our community.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$B = \{1, \ldots, m\}$&lt;/span&gt; be the set of &lt;em&gt;bases&lt;/em&gt; (in our case, domain names) and let &lt;span class=&quot;math-container&quot;&gt;$I = \{1, \ldots, n\}$&lt;/span&gt; be the set of items (in our case, URLs). Denote with &lt;span class=&quot;math-container&quot;&gt;$\alpha_b \in \mathbb{N}$&lt;/span&gt; the number of items with base &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, and with &lt;span class=&quot;math-container&quot;&gt;$\beta_i$&lt;/span&gt; the base of item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$x_{bj} \in \{0,1\}$&lt;/span&gt; be a binary variable with value 1 iff an item of base &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is placed in position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in the permutation.&lt;/p&gt;&#xA;&lt;p&gt;For each base &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; the user proposes to measure its &amp;quot;unsortedness&amp;quot; summing all the pairwise distances between items of base &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; (without repetitions). For example, if URLs associated with &lt;code&gt;host3.com&lt;/code&gt; take positions 4, 5 and 6 (as in the first example), then the unsortedness score of &lt;code&gt;host3.com&lt;/code&gt; is &lt;span class=&quot;math-container&quot;&gt;$|4-5| + |4-6| + |5-6| = 4$&lt;/span&gt;. However if, as in the second example, the URLs take positions 1, 4 and 6, then the score is &lt;span class=&quot;math-container&quot;&gt;$|1-4| + |1-6| + |4-6| = 10$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Formally, the objective function is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{b = 1}^m \sum_{j_1 = 1}^{n-1} \sum_{j_2 = j_1 + 1}^n (j_2 - j_1) x_{b j_1} x_{b j_2}$$&lt;/span&gt;&#xA;I.e., a quadratic function of variables &lt;span class=&quot;math-container&quot;&gt;$x_{bj}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would like to investigate further this problem, see if it's possible to model it using a classical OR problem and devise some efficient algorithm.&lt;/p&gt;&#xA;&lt;p&gt;Another Stack Overflow &lt;a href=&quot;https://stackoverflow.com/users/6817835/gold-cy&quot;&gt;user&lt;/a&gt; has proposed a &lt;a href=&quot;https://stackoverflow.com/a/70510656/436007&quot;&gt;Constraint Programming approach&lt;/a&gt; (although I am not 100% convinced of its correctness).&lt;/p&gt;&#xA;&lt;p&gt;I will mark this question as community wiki, so that everyone whose curiosity was picked by this problem can contribute.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="279" LastEditDate="2022-01-03T20:46:55.040" LastActivityDate="2022-01-04T01:44:00.120" Title="A Stack Overflow user's curious problem of maximising unsortedness" Tags="|quadratic-programming|assignment-problem|" AnswerCount="5" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="7502" PostTypeId="2" ParentId="7501" CreationDate="2022-01-03T00:12:12.700" Score="5" Body="&lt;p&gt;A first attempt is to model this problem using a special case of the Quadratic Assignment Problem (QAP), in which we want to assign URLs to positions in the permutation. To make the model smaller, we first note that we don't need to provide the exact position of each URL, because URLs with the same hostname are indistinguishable for the purpose of computing the &amp;quot;unsortedness&amp;quot; of the permutation.&lt;/p&gt;&#xA;&lt;p&gt;Using the notation introduced in the question, we can model this problem as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\max \quad &amp;amp; \sum_{b = 1}^m \sum_{j_1 = 1}^{n-1} \sum_{j_2 = j_1 + 1}^n (j_2 - j_1) x_{b j_1} x_{b j_2} \\&#xA;\text{s.t.} \quad &amp;amp; \sum_{b = 1}^m x_{bj} = 1 &amp;amp; \quad &amp;amp; \forall j \in \{1, \ldots, n\} \\&#xA;&amp;amp; \sum_{j = 1}^n x_{bj} = \alpha_b &amp;amp; \quad &amp;amp; \forall b \in \{1, \ldots, m\} \\&#xA;&amp;amp; x_{bj} \in \{0,1\} &amp;amp; \quad &amp;amp; \forall b \in \{1, \ldots, m\}, \; \forall j \in \{1, \ldots, n\}&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We can rewrite the objective function in the typical QAP form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{\phi \in \mathcal{S}(n)} \sum_{i=1}^n \sum_{j=1}^n a_{\phi(i)\phi(j)} b_{ij} x_{i \phi(i)} x_{j \phi(j)}$$&lt;/span&gt;&#xA;in which &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}(n)$&lt;/span&gt; is the set of all permutations of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; elements.&#xA;Assigning an item &lt;span class=&quot;math-container&quot;&gt;$\phi(i)$&lt;/span&gt; to position &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and an item &lt;span class=&quot;math-container&quot;&gt;$\phi(j)$&lt;/span&gt; to position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; incurs into a cost which is multiplicatively decomposable into one part which only depends on the two items (&lt;span class=&quot;math-container&quot;&gt;$a_{\phi(i)\phi(j)}$&lt;/span&gt;) and one part which only depends on their assigned positions (&lt;span class=&quot;math-container&quot;&gt;$b_{ij}$&lt;/span&gt;).&#xA;In our case, we would have:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;a_{ij} = \begin{cases}&#xA;1 &amp;amp; \text{ if } \beta_i = \beta_j \\&#xA;0 &amp;amp; \text{ otherwise }&#xA;\end{cases}\quad&#xA;b_{ij} = \begin{cases}&#xA;i - j &amp;amp; \text{ if } i &amp;lt; j \\&#xA;0 &amp;amp; \text{ otherwise }&#xA;\end{cases}&#xA;$$&lt;/span&gt;&#xA;(We use &lt;span class=&quot;math-container&quot;&gt;$i-j$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$j-i$&lt;/span&gt; to transform our maximisation problem into the canonical minimisation form of the QAP.)&lt;/p&gt;&#xA;&lt;p&gt;Such rewriting could be useful to identify special properties of matrices &lt;span class=&quot;math-container&quot;&gt;$(a_{ij})$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(b_{ij})$&lt;/span&gt;, which can help to identify if our special-case QAP is simpler to solve than the general QAP.&lt;/p&gt;&#xA;&lt;p&gt;For example, matrix &lt;span class=&quot;math-container&quot;&gt;$(b_{ij})$&lt;/span&gt; is Toeplitz because each entry only depends on the difference &lt;span class=&quot;math-container&quot;&gt;$i - j$&lt;/span&gt;.&#xA;If matrix &lt;span class=&quot;math-container&quot;&gt;$(a_{ij})$&lt;/span&gt; were anti-Monge, then we would know that our problem has &lt;a href=&quot;https://cse.hkust.edu.hk/mjg_lib/bibs/DPSu/DPSu.Files/TqapwamAMaasTmEahc.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;nice properties&lt;/a&gt;.&#xA;However, one can unfortunately build a simple example to see that &lt;span class=&quot;math-container&quot;&gt;$(a_{ij})$&lt;/span&gt; is not anti-Monge.&lt;/p&gt;&#xA;&lt;p&gt;Another observation is that it should be possible to replace the second equality constraint with a &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt; inequality: in any solution in which we place fewer than &lt;span class=&quot;math-container&quot;&gt;$\alpha_b$&lt;/span&gt; items of a base &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, because &lt;span class=&quot;math-container&quot;&gt;$\sum_{b=1}^m \alpha_b = n$&lt;/span&gt;, we must be leaving some empty space.&#xA;Assuming that &lt;span class=&quot;math-container&quot;&gt;$\alpha_b &amp;gt; 1$&lt;/span&gt;, filling this empty space with an item of base &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; strictly increases the objective function. And even if &lt;span class=&quot;math-container&quot;&gt;$\alpha_b = 1$&lt;/span&gt;, we obtain another optimal solution in which equality is satisfied.&lt;/p&gt;&#xA;&lt;p&gt;Analogously, it should be possible to replace the first equality constraint with a &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt; inequality. This follows by the validity of the second constraint and the pigeonhole principle.&lt;/p&gt;&#xA;&lt;p&gt;A &lt;a href=&quot;https://github.com/alberto-santini/ping-assignment-problem/blob/master/solvers/qap.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi implementation&lt;/a&gt; of this model takes a very long time already for small instances (&lt;span class=&quot;math-container&quot;&gt;$n=15,20$&lt;/span&gt;) so clearly some more effort is required along this route.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2022-01-03T11:20:17.613" LastActivityDate="2022-01-03T11:20:17.613" CommentCount="6" CommunityOwnedDate="2022-01-03T00:12:12.700" ContentLicense="CC BY-SA 4.0" />
  <row Id="7503" PostTypeId="2" ParentId="7501" CreationDate="2022-01-03T00:34:16.927" Score="6" Body="&lt;p&gt;Another possibility is to consider an integer linear extended formulation.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$\mathcal{A}_b$&lt;/span&gt; be the set of valid assignments for base &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. I.e., an element of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{A}_b$&lt;/span&gt; determines &lt;span class=&quot;math-container&quot;&gt;$\alpha_b$&lt;/span&gt; unique positions among the available ones &lt;span class=&quot;math-container&quot;&gt;$\{1, \ldots, n\}$&lt;/span&gt;, which are the positions taken by items of base &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; in the solution. Denote with &lt;span class=&quot;math-container&quot;&gt;$\mathcal{A} = \bigcup_{b=1}^m \mathcal{A}_b$&lt;/span&gt; the set of all assignments and with &lt;span class=&quot;math-container&quot;&gt;$c_a$&lt;/span&gt; the cost of an assignment &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;. Furthermore, let &lt;span class=&quot;math-container&quot;&gt;$\gamma_{ab} \in \{0,1\}$&lt;/span&gt; be a parameter which takes value 1 iff &lt;span class=&quot;math-container&quot;&gt;$a \in \mathcal{A}$&lt;/span&gt; is a member of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{A}_b$&lt;/span&gt; (i.e., if the assignment refers to base &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;) and let &lt;span class=&quot;math-container&quot;&gt;$\delta_{aj} \in \{0,1\}$&lt;/span&gt; be another parameter which takes value 1 iff assignment &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; covers position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Define one binary variable &lt;span class=&quot;math-container&quot;&gt;$y_a$&lt;/span&gt; for each assignment, which will take value 1 iff the assignment is used in the optimal solution.&#xA;Then a model for our problem is the following:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\max \quad &amp;amp; \sum_{a \in \mathcal{A}} c_a y_a \\&#xA;\text{s.t.} \quad &amp;amp; \sum_{a \in \mathcal{A}} \gamma_{ab} y_a = 1 &amp;amp; \quad &amp;amp; \forall b \in \{1, \ldots, m\} \\&#xA;&amp;amp; \sum_{a \in \mathcal{A}} \delta_{aj} y_a = 1 &amp;amp; \quad &amp;amp; \forall j \in \{1, \ldots, n\} \\&#xA;&amp;amp; y_a \in \{0,1\} &amp;amp; \quad &amp;amp; \forall a \in \mathcal{A}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;(Following a similar reasoning as the one for the quadratic integer model, I think we can replace both equalities with &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt; inequalities.)&lt;/p&gt;&#xA;&lt;p&gt;The continuous relaxation of this model can be solved via column generation: let &lt;span class=&quot;math-container&quot;&gt;$\pi_b$&lt;/span&gt; be the dual values associated with the first constraint and &lt;span class=&quot;math-container&quot;&gt;$\mu_j$&lt;/span&gt; those associated with the second constraint.&#xA;Then, starting with a reduced set of columns, for each base &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, one can look for improving assignments &lt;span class=&quot;math-container&quot;&gt;$a \in \mathcal{A}_b$&lt;/span&gt; such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$c_a - \sum_{j=1}^n \delta_{aj} \mu_j &amp;gt; \pi_b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Computing &lt;span class=&quot;math-container&quot;&gt;$c_a$&lt;/span&gt; in a separation problem looks non-trivial to me. For example, if we want to use an integer model for separation (for a given base &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;), we might again end up with a quadratic model such as the following:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\max \quad &amp;amp; \sum_{j_1 = 1}^{n-1} \sum_{j_2 = j_1 + 1}^n (j_2 - j_1) z_{j_1} z_{j_2} - \sum_{j=1}^n \mu_j z_j \\&#xA;\text{s.t.} \quad &amp;amp; \sum_{j=1}^n z_j = \alpha_b \\&#xA;&amp;amp; z_j \in \{0,1\} &amp;amp; \quad &amp;amp; \forall j \in \{1, \ldots, n\}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;In which binary variable &lt;span class=&quot;math-container&quot;&gt;$z_j$&lt;/span&gt; takes value 1 iff we place an item in position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To pursue this line of research one should come up with an efficient algorithm to solve the above separation problem. Small &lt;a href=&quot;https://github.com/alberto-santini/ping-assignment-problem/blob/master/solvers/colgen.py&quot; rel=&quot;noreferrer&quot;&gt;experiments&lt;/a&gt;, however, seem to show that the relaxation is tight.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2022-01-03T00:43:43.970" LastActivityDate="2022-01-03T00:43:43.970" CommentCount="0" CommunityOwnedDate="2022-01-03T00:34:16.927" ContentLicense="CC BY-SA 4.0" />
  <row Id="7504" PostTypeId="1" AcceptedAnswerId="7523" CreationDate="2022-01-03T06:33:38.707" Score="5" ViewCount="543" Body="&lt;p&gt;I am learning pick-up drop-off problems (variant of vehicle routing problems) with time windows.  My problem is as follows:&#xA;There are orders that need to to shipped from pickup locations to delivery addresses. The shipper want to minimize the number of vehicles and the miles traveled. The trucks can pickup from multiple locations and deliver at multiple addresses as well. In one route there can be a mix of sequence of pickup and delivery but these pickup and delivery will have to happen within a time window for each location. the first task on a route will be a pickup and the last task will be a delivery. One route will be covered by only one truck. The trucks do not have to be originated from a depot and do not have to go back to the depot after last delivery. Right now, I am only considering homogeneous capacity of the fleet.&lt;/p&gt;&#xA;&lt;p&gt;My understanding is that this is going to be a NP-hard problem and I will need to use some type of metaheuristic to solve it. But I would like to write down a compact mathematical formulation of the problem and use GUROBI to solve the problem with a small dataset. Is there any recent papers, books, or any other documents or online materials you can direct me to that might help me formulate the problem. If you are experienced in vehicle routing, any comments would be very helpful.&lt;/p&gt;&#xA;" OwnerUserId="3288" LastActivityDate="2022-01-04T22:03:46.987" Title="Multiple Pick-Up Delivery Problem with Time Windows" Tags="|vehicle-routing|traveling-salesman|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7505" PostTypeId="2" ParentId="7496" CreationDate="2022-01-03T10:20:53.190" Score="5" Body="&lt;p&gt;This problem can be elegantly formulated through Constraint Programming (CP). This problem does not have an objective function: it's a Constraint Satisfaction Problem, not a Constraint Optimization Problem. CP would be a natural choice for this problem, since CP, similar to how humans would solve this problem, relies on a technique called 'inference'. In CP, variables have a domain (the set of values that can possibly be assigned to a variable). Through Constraint Propagation, a Constraint solver infers which values a variable cannot take and the solver eliminates those values from the domains of the variables until each variable only has 1 value left.&lt;/p&gt;&#xA;&lt;p&gt;To solve your problem, we would define the following variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$h_p\in \{6,...,6'6 \}$&lt;/span&gt; is the height of player &lt;span class=&quot;math-container&quot;&gt;$p\in \{Bill,...,Tony\}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$name_n\in \{Bill,...,Tony\}$&lt;/span&gt; is the name of the person with nick &lt;span class=&quot;math-container&quot;&gt;$n \in \{Slats,...,Tree\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;We specify the following constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;each player has a unique height:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;alldifferent(h_p|\forall p)&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;each player has a unique nick name (i.e. no player has 2 nicks):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;alldifferent(name_n|\forall n)&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Oscar is taller than Tree... :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;h_{Oscar}&amp;gt;h_{name_{Tree}}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;...who is taller than Tony:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;h_{name_{Tree}}&amp;gt;h_{Tony}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Bill is taller than Sammy...:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;h_{Bill}&amp;gt;h_{Sammy}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;...but shorter than Slats:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;h_{Bill}&amp;lt;h_{name_{Slats}}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Tony's nickname is not Tiny:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;name_{Tiny}\neq Tony&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Stretch is taller than Oscar...:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;h_{name_{Stretch}}&amp;gt;h_{Oscar}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;...but not the tallest:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;h_{name_{Strech}}&amp;lt;6'6&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;A few remarks:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$allDifferent(\cdot)$&lt;/span&gt; is a so-called global constraint in CP that states that all the variables over which the constraint is defined must take pairwise different values&lt;/li&gt;&#xA;&lt;li&gt;in CP, unlike in LP/MIP/... you can index a variable with a variable! So &lt;span class=&quot;math-container&quot;&gt;$h_{name_{Tree}}$&lt;/span&gt; is a valid statement. This construction is called an element constraint in CP. Also notice how much more concise and readable the above formulation is compared to a MIP formulation.&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;Tony's nickname is not Tiny&amp;quot;: In CP, you would not define this as a constraint; instead, you would simply omit the value 'Tony' from the domain of variable &lt;span class=&quot;math-container&quot;&gt;$name_{Tiny}$&lt;/span&gt; when you define this variable.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;CP would solve the above problem very efficiently. Moreover, since CP is an exact approach, the solver would tell you whether a feasible solution exists at all, or perhaps whether there exist multiple solutions that satisfy the above constraints. This would be a lot more efficient than using some kind of meta heuristic such as the ones you mentioned (genetic algorithm/simulated annealing/etc). Moreover, many heuristics require an objective to guide the search. A common objective in puzzles is to define how 'close' the solution is to a feasible solution, e.g. how many conflicts there are. It is well known for puzzles that a solution with only 1 minor conflict, might still look very different than the actual optimal solution.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The above model, implemented in Python and &lt;a href=&quot;https://ibmdecisionoptimization.github.io/docplex-doc/cp/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Docplex&lt;/a&gt; (IBM CP Optimizer):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.cp.model import CpoModel&#xA;&#xA;&#xA;## Data&#xA;players = [&amp;quot;Bill&amp;quot;, &amp;quot;Ernie&amp;quot;, &amp;quot;Oscar&amp;quot;, &amp;quot;Sammy&amp;quot;, &amp;quot;Tony&amp;quot;]&#xA;nicknames = [&amp;quot;Slats&amp;quot;, &amp;quot;Stretch&amp;quot;, &amp;quot;Tiny&amp;quot;, &amp;quot;Tower&amp;quot;, &amp;quot;Tree&amp;quot;]&#xA;heights = [60, 61, 63, 65, 66]&#xA;&#xA;&#xA;## Create CPO model&#xA;mdl = CpoModel()&#xA;&#xA;&#xA;## Create model variables&#xA;&#xA;height = mdl.integer_var_dict(keys=players,domain=heights)&#xA;player = mdl.integer_var_dict(nicknames,0,len(players))&#xA;&#xA;&#xA;## Create model constraints&#xA;&#xA;# each player has a unique height:&#xA;mdl.add(mdl.all_diff([height[p] for p in players]))&#xA;&#xA;# each player has a unique nick name (i.e. no player has 2 nicks):&#xA;mdl.add(mdl.all_diff([player[n] for n in nicknames]))&#xA;&#xA;# Oscar is taller than Tree... :&#xA;mdl.add(height[&amp;quot;Oscar&amp;quot;] &amp;gt; mdl.element([height[p] for p in players],player[&amp;quot;Tree&amp;quot;]))&#xA;&#xA;# ...who is taller than Tony:&#xA;mdl.add(mdl.element([height[p] for p in players],player[&amp;quot;Tree&amp;quot;]) &amp;gt; height[&amp;quot;Tony&amp;quot;])&#xA;&#xA;# Bill is taller than Sammy...: &#xA;mdl.add(height[&amp;quot;Bill&amp;quot;] &amp;gt; height[&amp;quot;Sammy&amp;quot;])&#xA;&#xA;# ...but shorter than Slats:&#xA;mdl.add(height[&amp;quot;Bill&amp;quot;] &amp;lt; mdl.element([height[p] for p in players],player[&amp;quot;Slats&amp;quot;]))&#xA;&#xA;# Tony's nickname is not Tiny:&#xA;mdl.add(player[&amp;quot;Tiny&amp;quot;] != players.index(&amp;quot;Tony&amp;quot;))&#xA;&#xA;# Stretch is taller than Oscar...: &#xA;mdl.add(mdl.element([height[p] for p in players],player[&amp;quot;Stretch&amp;quot;]) &amp;gt; height[&amp;quot;Oscar&amp;quot;])&#xA;&#xA;# ...but not the tallest:&#xA;mdl.add(mdl.element([height[p] for p in players],player[&amp;quot;Stretch&amp;quot;]) &amp;lt; max(heights))&#xA;&#xA;&#xA;## Solve model&#xA;print(&amp;quot;\nSolving model....&amp;quot;)&#xA;msol = mdl.solve(agent='local',execfile='/opt/ILOG/CPLEX_Studio201/cpoptimizer/bin/x86-64_linux/cpoptimizer',TimeLimit=10,DefaultInferenceLevel=&amp;quot;Extended&amp;quot;)&#xA;&#xA;if msol:&#xA;    print(&amp;quot;Solution status: &amp;quot; + msol.get_solve_status())&#xA;    nick_lookup = {players[msol[player[nick]]]:nick for nick in nicknames}&#xA;    &#xA;    for name in players:&#xA;        print(name+&amp;quot;(&amp;quot;+nick_lookup[name]+&amp;quot;): &amp;quot;+str(msol[height[name]]))&#xA;&#xA;else:&#xA;    print(&amp;quot;No solution found&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A solution was found in &lt;strong&gt;0.02s&lt;/strong&gt;:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/xdQ9F.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xdQ9F.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2022-01-03T12:42:10.307" LastActivityDate="2022-01-03T12:42:10.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7506" PostTypeId="1" CreationDate="2022-01-03T12:11:50.960" Score="19" ViewCount="2461" Body="&lt;p&gt;Recently I saw the following question &lt;a href=&quot;https://mathoverflow.net/q/412437&quot;&gt;Breakthroughs in mathematics in 2021&lt;/a&gt; by &lt;a href=&quot;https://mathoverflow.net/users/46573/johnny-cage&quot;&gt;Johnny Cage&lt;/a&gt; on &lt;a href=&quot;https://mathoverflow.net/&quot;&gt;mathoverflow&lt;/a&gt;, which inspired me to ask the following question:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;As specialised operations researchers we usually miss important results outside our area of research.&lt;/p&gt;&#xA;&lt;p&gt;So, generally speaking, what are some major important breakthroughs &lt;strong&gt;since 2010&lt;/strong&gt; in different disciplines of operations research?&amp;quot;&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="232" LastEditDate="2022-01-05T08:18:55.577" LastActivityDate="2022-01-12T23:22:42.253" Title="Breakthroughs in Operations Research since 2010" Tags="|reference-request|literature-research|history|" AnswerCount="6" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7507" PostTypeId="2" ParentId="7504" CreationDate="2022-01-03T13:58:05.890" Score="3" Body="&lt;p&gt;You can get some hints regarding implementation from one of the Gurobi's &lt;a href=&quot;https://www.gurobi.com/resource/how-to-synchronize-complex-routing-operations-synched-vrps-with-gurobi/&quot; rel=&quot;nofollow noreferrer&quot;&gt;webinar&lt;/a&gt;. Though, it doesn't provide a math model but provides solution techniques that can be considered for tackling large-scale problems. Also, you can take a look at the implementation in Gurobi on this &lt;a href=&quot;https://github.com/sudhan-bhattarai/CVRPTW_MILP/blob/master/Sudhan_Bhattarai_MVRP_%20report.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;github link&lt;/a&gt;. Few papers you can start with are &lt;a href=&quot;http://dx.doi.org/10.1007/s11301-008-0033-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;3&lt;/a&gt; and &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.1030.0057&quot; rel=&quot;nofollow noreferrer&quot;&gt;4&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastEditorUserId="491" LastEditDate="2022-01-03T17:16:06.967" LastActivityDate="2022-01-03T17:16:06.967" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7508" PostTypeId="2" ParentId="7501" CreationDate="2022-01-03T16:53:00.707" Score="4" Body="&lt;p&gt;A genetic algorithm with a permutation type chromosome works well on this problem. I have an R notebook demonstrating the approach that can be &lt;a href=&quot;https://rubin.msu.domains/blog/scramble.nb.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;downloaded here&lt;/a&gt;. Since a GA is a metaheuristic, there is no guarantee of optimality, but it seems to perform pretty well (and quickly) on test problems.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-03T16:53:00.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7509" PostTypeId="2" ParentId="7501" CreationDate="2022-01-03T17:06:22.297" Score="5" Body="&lt;p&gt;So, it turns out that this problem admits a linear-time exact algorithm!&#xA;The intuition is to add to the extremes (first and last position) two items with the same base &lt;span class=&quot;math-container&quot;&gt;$b^*$&lt;/span&gt;, which must be the base with the most items (&lt;span class=&quot;math-container&quot;&gt;$b^* = \text{argmax} \{\alpha_b\}$&lt;/span&gt;).&#xA;Then one can reduce by 2 the number of items in this base (&lt;span class=&quot;math-container&quot;&gt;$\alpha_{b^*} \gets \alpha_{b^*} - 2$&lt;/span&gt;), cut off the first and last position from the assignment vector, and re-apply the same reasoning recursively.&#xA;The algorithm ends when all bases have &lt;span class=&quot;math-container&quot;&gt;$\alpha_b \leq 1$&lt;/span&gt;; at this point we trivially add all remaining items to the &amp;quot;centre&amp;quot; of the assignment vector.&lt;/p&gt;&#xA;&lt;p&gt;The reason why this algorithm works is explained in the solution to problem &amp;quot;&lt;a href=&quot;https://codeforces.com/blog/entry/97164&quot; rel=&quot;noreferrer&quot;&gt;Codeforces Educational Round 117&lt;/a&gt;&amp;quot;, as spotted by OR Stack Exchange user &lt;a href=&quot;https://or.stackexchange.com/users/8821/mees-de-vries&quot;&gt;Mees de Vries&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As a commentary, it's amazing how 1. this problem already existed (at least in recreational form) and was proposed less than 3 months ago, 2. user Mees de Vries managed to spot it both here and on Codeforces and to realise it was the same problem, 3. I really should stop trying to throw modelling-based solutions at any optimisation problems which comes my way... maybe an algorithm/math based solution exists, and is even more efficient. I will try to remember this in the future!&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2022-01-03T17:06:22.297" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="7510" PostTypeId="2" ParentId="7506" CreationDate="2022-01-03T18:28:13.850" Score="10" Body="&lt;p&gt;In terms of the metric TSP, &lt;a href=&quot;https://arxiv.org/pdf/2007.01409.pdf&quot; rel=&quot;noreferrer&quot;&gt;Karlin &lt;em&gt;et al.&lt;/em&gt; (2020)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; developed a novel approximation algorithm that beat the infamous Christofides algorithm by a very modest difference of &lt;span class=&quot;math-container&quot;&gt;$10^{-36}$&lt;/span&gt;!&lt;/p&gt;&#xA;&lt;p&gt;This was a long unresolved problem, and whilst the improvement may look minimal, the  new techniques used can pave the way for even better upper (worst-case) bounds in the near future. The history of the endeavour dating back to 2010 has been &lt;a href=&quot;https://www.quantamagazine.org/computer-scientists-break-traveling-salesperson-record-20201008/&quot; rel=&quot;noreferrer&quot;&gt;featured in &lt;em&gt;Quanta&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Karlin, A. R., Klein, N., Gharan, S. O. (2021). A (slightly) improved approximation algorithm for metric TSP. In &lt;em&gt;Proceedings of the 53rd Annual ACM SIGACT Symposium on Theory of Computing.&lt;/em&gt; 32-45. [preprint published on arXiv in 2020] &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2022-01-03T18:28:13.850" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7511" PostTypeId="2" ParentId="7501" CreationDate="2022-01-04T01:44:00.120" Score="1" Body="&lt;p&gt;I don't think I can answer from a proper OR perspective, but I had to solve approximately the same problem (have had to multiple times, actually) and got an algorithmic answer that left me saying &amp;quot;well... duh!&amp;quot; in its simplicity. Hopefully you can see the &amp;quot;well duh&amp;quot; answer to translate it mathematically / (im)prove it as appropriate. It's not optimal per the objective function above - I have no idea if it's good, or only &amp;quot;good enough&amp;quot; for what I needed to do.&lt;/p&gt;&#xA;&lt;p&gt;The only constraint I'm aware of for this answer is that any one site cannot have more entries than &lt;code&gt;(all other sites combined + 1)&lt;/code&gt;. That rule alone also means that there must be at least two sites.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create a hash with &lt;code&gt;key = domain&lt;/code&gt; and &lt;code&gt;value = empty array&lt;/code&gt;. An alternative that may work better is a priority queue with the same key / value, and priority of &lt;code&gt;length(value)&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Append every URL to the appropriate domain array for its domain.&lt;/li&gt;&#xA;&lt;li&gt;Sort the hash by length of array, longest first. Order of equal length arrays does not matter. As in (1) a priority queue would give you a continuously sorted list.&lt;/li&gt;&#xA;&lt;li&gt;Set &lt;code&gt;last_domain&lt;/code&gt; to the second entry in your list. That usually means the second-longest array domain, but may be one of &lt;code&gt;N&lt;/code&gt; equal-length domains.&lt;/li&gt;&#xA;&lt;li&gt;While hash is not empty:&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;x&lt;/code&gt; = Take the first item from the list that does not match &lt;code&gt;last_domain&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;By &amp;quot;take&amp;quot; this means remove it from the hash array, thus shortening that domain's array by one. Remove the domain entry if the array becomes length zero.&lt;/li&gt;&#xA;&lt;li&gt;Output &lt;code&gt;x&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Set &lt;code&gt;last_domain = x.domain&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;If not empty, re-sort &lt;code&gt;last_domain&lt;/code&gt;'s entry in the list based on its new length &lt;code&gt;N-1&lt;/code&gt;, putting it at the end of equal-length entries.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;For a list of URLs with nice even distribution (all length &lt;code&gt;N&lt;/code&gt; the same) you can see that it will effectively round-robin through them, always picking the longest available list to take its item. As each domain is shortened, it gets pushed to the end of the list.&lt;/p&gt;&#xA;&lt;p&gt;For a list where the distribution is massively uneven (one domain has 1000, 999 domains each have one) it will start with the longest entry, then one of a different domain, then another of the longest, etc. until it has populated the first, last, and every second item in the output with one of the 1000-length items, and 999 items in-between with one-each of the other possibilities.&lt;/p&gt;&#xA;&lt;p&gt;The options in-between are where things are iffy. If you have two entries &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;B&lt;/code&gt; with &lt;code&gt;N=10&lt;/code&gt; and then twenty different domains &lt;code&gt;C&lt;/code&gt; through &lt;code&gt;V&lt;/code&gt; each with &lt;code&gt;N=1&lt;/code&gt; then this algorithm won't meet Glorfindel's optimization, where iterating &lt;code&gt;A,B,other&lt;/code&gt; would. This algorithm will iterate between the first two, and then will eventually follow nine &lt;code&gt;A,B&lt;/code&gt; pairs with one each from &lt;code&gt;A&lt;/code&gt; through &lt;code&gt;V&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8826" LastActivityDate="2022-01-04T01:44:00.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7512" PostTypeId="1" CreationDate="2022-01-04T05:21:06.267" Score="1" ViewCount="783" Body="&lt;p&gt;Is it possible to implement custom lazy callback constraints using OR-Tool's base linear solver?&lt;/p&gt;&#xA;&lt;p&gt;Through Google's docs, I've seen their TSP examples using the constraint solver &lt;code&gt;RoutingModel&lt;/code&gt; and it appears to have a built-in lazy callback functionality (it &lt;em&gt;must&lt;/em&gt; since that's necessary to solve a TSP).&lt;/p&gt;&#xA;&lt;p&gt;The problem I'm working on is like a TSP but in a goal program format, so there are a lot of extra constraints and variables related to the other goals and not just the travel to and from each node. For that reason, I'm trying to stay away from using the &lt;code&gt;RoutingModel&lt;/code&gt; since I don't think it will work with the goal program formulation.&lt;/p&gt;&#xA;&lt;p&gt;My previous version of this formulation was using Gurobi and I was able to create the necessary lazy callback constraints using their callback APIs, so I'm hoping to be able to achieve similar functionality.&lt;/p&gt;&#xA;" OwnerUserId="7672" LastActivityDate="2022-01-08T23:27:19.897" Title="Custom lazy callback constraints using Google OR-Tools linear solver?" Tags="|mixed-integer-programming|linear-programming|constraint-programming|or-tools|callback|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7513" PostTypeId="2" ParentId="7506" CreationDate="2022-01-04T07:11:00.427" Score="11" Body="&lt;p&gt;&lt;a href=&quot;https://www.dynamic-ideas.com/books/machine-learning-under-a-modern-optimization-lens&quot; rel=&quot;noreferrer&quot; title=&quot;Machine Learning Under a Modern Optimization Lens&quot;&gt;&lt;strong&gt;Machine Learning Under a Modern Optimization Lens&lt;/strong&gt; &lt;/a&gt;  by Dimitris Bertsimas and Jack Dunn, is a fascinating book in the space of OR &amp;amp; ML.&lt;/p&gt;&#xA;&lt;p&gt;The book provides an original treatment of machine learning (ML) using convex, robust and mixed integer optimization that leads to solutions to central ML problems at a large scale that can be found in seconds/minutes, can be certified to be optimal in minutes/hours, and outperform classical heuristic approaches in out-of-sample experiments.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s10994-017-5633-9&quot; rel=&quot;noreferrer&quot; title=&quot;Optimal classification trees&quot;&gt;&lt;em&gt;Optimal classification trees&lt;/em&gt; &lt;/a&gt; - this paper presents optimal classification trees, a novel formulation of the decision tree problem using modern MIO techniques that yields the optimal decision tree.&lt;/p&gt;&#xA;" OwnerUserId="208" LastActivityDate="2022-01-04T07:11:00.427" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7514" PostTypeId="2" ParentId="7512" CreationDate="2022-01-04T07:20:08.600" Score="3" Body="&lt;p&gt;So&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the routing library does not use a MIP solver to solve TSP/VRP... problems. So the assumptions of lazy callbacks is just false.&lt;/li&gt;&#xA;&lt;li&gt;The question of goal programming is not that clear. You should look at the routing API.&lt;/li&gt;&#xA;&lt;li&gt;The linear solver wrapper do support callbacks for Gurobi and SCIP, but if you plan on using Gurobi, you should stick to the gurobi API&lt;/li&gt;&#xA;&lt;li&gt;My recommendation if the goal part does not fit in the routing library is to use the CP-SAT solver. It offers the ConstraintProgramming circuit object to model an Hamiltonian path, as well as having built-in the MIP model with the flow formulation, and the subtour elimination cuts.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="981" LastActivityDate="2022-01-04T07:20:08.600" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7515" PostTypeId="2" ParentId="7506" CreationDate="2022-01-04T08:52:16.230" Score="11" Body="&lt;p&gt;Hedetniemi &lt;a href=&quot;https://en.wikipedia.org/wiki/Hedetniemi%27s_conjecture&quot; rel=&quot;noreferrer&quot;&gt;conjectured in 1966&lt;/a&gt; that &lt;span class=&quot;math-container&quot;&gt;$χ(G×H)=\min\{χ(G),χ(H)\}$&lt;/span&gt; for all graphs &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;. Here &lt;span class=&quot;math-container&quot;&gt;$G×H$&lt;/span&gt; is the graph with vertex set &lt;span class=&quot;math-container&quot;&gt;$V(G)×V(H)$&lt;/span&gt; defined by putting &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(x',y')$&lt;/span&gt; adjacent if and only if &lt;span class=&quot;math-container&quot;&gt;$xx'∈E(G)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$yy'∈E(H)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It turns out this is not true, a Russian mathematician &lt;a href=&quot;https://arxiv.org/abs/1905.02167&quot; rel=&quot;noreferrer&quot;&gt;disproved the conjecture&lt;/a&gt; after 53 years in 2019, and this is considered a breakthrough.&lt;/p&gt;&#xA;&lt;p&gt;There is a good &lt;a href=&quot;https://www.youtube.com/watch?v=Tnu_Ws7Llo4&quot; rel=&quot;noreferrer&quot;&gt;video&lt;/a&gt; by Numberphile where everything is well explained.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2022-01-04T14:08:06.817" LastActivityDate="2022-01-04T14:08:06.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7516" PostTypeId="1" CreationDate="2022-01-04T14:12:15.700" Score="0" ViewCount="207" Body="&lt;p&gt;I tried to solve a large-scale MIP, but the poor performance of my PC makes the tests very time-consuming. If someone knows an alternative to Google Collab for paying with high-performance (e.g. 256G RAM) or any other suggestion, I would be appreciative.&lt;/p&gt;&#xA;" OwnerUserId="5537" LastEditorUserId="727" LastEditDate="2022-01-04T21:41:33.657" LastActivityDate="2022-01-13T15:21:59.680" Title="Alternative google collab?" Tags="|googlecolab|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7517" PostTypeId="2" ParentId="7516" CreationDate="2022-01-04T15:07:20.637" Score="4" Body="&lt;p&gt;If you need 256 GB of RAM &lt;a href=&quot;https://neos-server.org/neos/&quot; rel=&quot;nofollow noreferrer&quot;&gt;NEOS server org&lt;/a&gt; is probably to small for you. In terms of cheap compute i would recommend a dedicated CCX51 instance with 128GB from Hetzner Cloud available for 0.5€/h. I have a &lt;a href=&quot;https://hetzner.cloud/?ref=3NZXnvwdSifl&quot; rel=&quot;nofollow noreferrer&quot;&gt;referral link&lt;/a&gt; that should give you some credits to get started and will pay me the first 10€ if you spend money with them. Vultr has a &lt;a href=&quot;https://www.vultr.com/products/bare-metal/#pricing&quot; rel=&quot;nofollow noreferrer&quot;&gt;256 GB instance&lt;/a&gt; for around $1/hour an &lt;a href=&quot;https://www.vultr.com/?ref=8693150-6G&quot; rel=&quot;nofollow noreferrer&quot;&gt;affiliate link&lt;/a&gt; that might give you some starting credits too. Other alternatives are to buy time at some interruptible spot instance at Amazon and do take care of check-pointing the solver using DMTCP. If your MILP solver runs on ARM you might also want to explore those instances on Oracle, Amazon, Alibaba Cloud as they tend to be a bit cheaper.&lt;/p&gt;&#xA;&lt;p&gt;You could also see if you could get sign up at a local HPC center and submit a project request there. The last alternative is to excite someone else for your project so much that they pay for compute.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2022-01-04T15:26:55.290" LastActivityDate="2022-01-04T15:26:55.290" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7518" PostTypeId="1" AcceptedAnswerId="7541" CreationDate="2022-01-04T17:13:18.887" Score="2" ViewCount="555" Body="&lt;p&gt;I'm using Google's OR tools in Python to do some optimization in routing in a model where I need to pick just the bare minimum to satisfy a demand.&lt;/p&gt;&#xA;&lt;p&gt;The situation is, let's say I need 100 units of the product, but there are 300 available in the entire network. My objective is to pick an amount that satisfies that goal, but there is no need to pick up more.&lt;/p&gt;&#xA;&lt;p&gt;For that, I'm making all nodes optional using the following the following line:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for node in range(1, n_nodes):&#xA;    self.routing.AddDisjunction([self.manager.NodeToIndex(node)], 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;While, on the other hand I'm adding the following restriction to ensure we have the required amount of material at the end, which is essentially that the sum of all capacities is at least the required amount.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;capacity = self.routing.GetDimensionOrDie('Capacity')&#xA;sum_cargos = capacity.CumulVar(self.routing.End(0))&#xA;for vehicle_id in range(1, self.data['num_vehicles']):&#xA;   sum_cargos += capacity.CumulVar(self.routing.End(vehicle_id))&#xA;&#xA;solver = self.routing.solver()&#xA;solver.AddConstraint(sum_cargos &amp;gt;= self.data['final_cargo'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In theory with these restrictions the solver should stop visiting nodes after reaching the minimum amount of material, since visiting more nodes would make the objective value worse. However, the algorithm insist in visiting all nodes even with small values of &amp;quot;final_cargo&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Is there some behaviour I might be missing? Or another way to achieve the objective?&lt;/p&gt;&#xA;" OwnerUserId="7633" LastEditorUserId="500" LastEditDate="2022-01-04T17:15:33.480" LastActivityDate="2022-01-07T12:38:47.457" Title="Minimize capacity of vehicles in VRP with OR Tools" Tags="|vehicle-routing|or-tools|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7519" PostTypeId="2" ParentId="7498" CreationDate="2022-01-04T18:47:31.473" Score="4" Body="&lt;p&gt;I'm not familiar with GLPK, but since it's based on AMPL, the following AMPL implementation might be of some help:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set I;&#xA;set J;&#xA;set K {I};&#xA;&#xA;param J0 {i in I} symbolic = &amp;quot;0&amp;quot; &amp;amp; i;&#xA;param JT {i in I} symbolic = &amp;quot;T&amp;quot; &amp;amp; i;&#xA;&#xA;set N {i in I} = {J0[i],JT[i]} union J;&#xA;set Nall = (union {i in I} {J0[i],JT[i]}) union J;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;GLPK uses only a subset of AMPL, however, so to get these statements to work in GLPK you might need to make some changes.&lt;/p&gt;&#xA;" OwnerUserId="52" LastActivityDate="2022-01-04T18:47:31.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7520" PostTypeId="2" ParentId="7506" CreationDate="2022-01-04T19:15:12.977" Score="7" Body="&lt;p&gt;&lt;strong&gt;INFORMS&lt;/strong&gt; recongnizes the best contributions in OR/MS with the &lt;strong&gt;Frederick W. Lanchester prize&lt;/strong&gt;, that is:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;The Lanchester prize is awarded for the &lt;strong&gt;best contribution&lt;/strong&gt; to operations research and the management sciences published in English &lt;strong&gt;in the past five years&lt;/strong&gt;.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;The 2021 prize was awarded to D. Bertsimas and J. Dunn, as outlined in the other answer. The 2020 prize was awarded to P. Mohajerin Esfahani and D. Kuhn for their contribution on Data-driven distributionally robust optimization (DRO) using the Wasserstein metric, that can be found &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-017-1172-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. The breakthrough in the DRO method is absolutely a major one, as after years of research, the authors showed that under mild assumptions, the DRO problem can be formulated as finite convex and even tractable linear programs. Since then, this method is widely utilized to solve many problems,  and by now (05/01/2022) has been cited 800 times in &lt;a href=&quot;https://scholar.google.com/scholar?hl=en&amp;amp;as_sdt=0%2C5&amp;amp;q=Data-driven%20distributionally%20robust%20optimization%20using%20the%20Wasserstein%20metric%3A%20performance%20guarantees%20and%20tractable%20reformulations&amp;amp;btnG=&quot; rel=&quot;nofollow noreferrer&quot;&gt;google scholar&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A full list of the winners of the Frederick W. Lanchester prize can be found &lt;a href=&quot;https://www.informs.org/Recognizing-Excellence/INFORMS-Prizes/Frederick-W.-Lanchester-Prize&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2022-01-05T02:18:20.213" LastActivityDate="2022-01-05T02:18:20.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7521" PostTypeId="2" ParentId="7506" CreationDate="2022-01-04T21:37:55.310" Score="6" Body="&lt;h1&gt;&lt;a href=&quot;https://or.stackexchange.com/q/799/727&quot;&gt;Quadratization&lt;/a&gt; &lt;em&gt;without&lt;/em&gt; auxiliary variables&lt;/h1&gt;&#xA;&lt;p&gt;For decades, people have been converting arbitrary optimization problems into linear ones, which makes them far easier to solve. With so much recent progress in solving quadratic optimization problems, it's now also become customary to try to convert these problems into quadratic ones, especially if it's not practical to convert the problem all the way into a linear one.  In 1975 [1], Rosenberg gave us a method to quadratize unconstrained binary optimization problems by introducing auxiliary (or &amp;quot;slack&amp;quot;) variables. Unfortunately, quadratization using auxiliary variables often makes the number of variables so large that it completely defeats the purpose of quadratizing in the first place, as I have still not found a satisfying answer to this question: &lt;a href=&quot;https://or.stackexchange.com/q/1380/727&quot;&gt;Are there any real-world problems where quadratization helps to solve something that couldn&amp;#39;t have been solved without quadratization?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2&gt;&lt;strong&gt;What happened in the last 10 years?&lt;/strong&gt;&lt;/h2&gt;&#xA;&lt;p&gt;The number of new ways to quadratize optimization problems has exploded since the 1975 Rosenberg paper, and as I wrote in my &lt;a href=&quot;https://arxiv.org/abs/1901.04405&quot; rel=&quot;noreferrer&quot;&gt;2019 book on quadratization&lt;/a&gt; (emphasis on the last part of the sentence was added here), &amp;quot;Part I&#xA;gives more than 40 different ways to do this, &lt;em&gt;&lt;strong&gt;almost all of them published in the last 5 years&lt;/strong&gt;&lt;/em&gt;.&amp;quot; In fact only two of the 40+ methods were published before 2011, largely because of [the explosion of interest in using graph cut algorithms to solve computers vision problems in the prior decade of 2000-2010 (see &lt;a href=&quot;https://or.stackexchange.com/q/2869/727&quot;&gt;this related OR.SE question&lt;/a&gt;). &lt;strong&gt;However, every quadratization method until 2014 still needed auxiliary variables (newer methods simply used fewer auxiliary variables or improved the quadratization in some other way).&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;h2&gt;&lt;strong&gt;What happened since 2014?&lt;/strong&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Methods to quadratize arbitrary binary optimization problems &lt;em&gt;&lt;strong&gt;without&lt;/strong&gt;&lt;/em&gt; auxiliary variables.  At least five such methods popped up between 2014-2018. In my book these are presented in order of which methods I'd recommend to apply first, and are described in the following subsections of Chapter 1.1:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A) &lt;a href=&quot;https://arxiv.org/abs/1508.04816&quot; rel=&quot;noreferrer&quot;&gt;Deduction-Reduction (Dattani, Tanburn, Okada, 2015)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;B) &lt;a href=&quot;https://ieeexplore.ieee.org/document/6909573/&quot; rel=&quot;noreferrer&quot;&gt;ELC Reduction (Ishikawa, 2014)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;C) &lt;a href=&quot;https://en.wikipedia.org/wiki/Gr%C3%B6bner_basis&quot; rel=&quot;noreferrer&quot;&gt;Groebner bases&lt;/a&gt; (known for long, but first applied to a QUBO problem &lt;a href=&quot;https://www.nature.com/articles/srep43048&quot; rel=&quot;noreferrer&quot;&gt;in 2017&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;D) Application of &lt;a href=&quot;https://arxiv.org/abs/1510.07420&quot; rel=&quot;noreferrer&quot;&gt;ELM&lt;/a&gt; (Dattani 2018).&lt;/li&gt;&#xA;&lt;li&gt;E) &lt;a href=&quot;https://arxiv.org/abs/1508.07190&quot; rel=&quot;noreferrer&quot;&gt;Split-Reduction (Dattani, Okada, Tanburn)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;[1] I. G. Rosenberg, “Reduction of Bivalent Maximization to the Quadratic Case,” Cahiers du&#xA;Centre d’Etudes de Recherche Operationnelle 17, 71–74 (1975).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="727" LastActivityDate="2022-01-04T21:37:55.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7522" PostTypeId="2" ParentId="7516" CreationDate="2022-01-04T21:45:20.733" Score="2" Body="&lt;p&gt;If the calculations are for academic purposes, many countries have national supercomputing facilities with lots and lots of computers each with 250GB of RAM or even more (some XSEDE computers had 12TB of RAM as early as 2018, and maybe more now).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Many of these national supercomputing facilities are described in great detail at this thread on the Stack Exchange Network: &lt;a href=&quot;https://mattermodeling.stackexchange.com/q/1515/5&quot;&gt;Supercomputers around the world&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you are not from a country with supercomputing facilities, then the alternative question &lt;a href=&quot;https://mattermodeling.stackexchange.com/q/1613/5&quot;&gt;&lt;strong&gt;Supercomputers around the world, which allow access for researchers outside the country&lt;/strong&gt;&lt;/a&gt; may help.&lt;/p&gt;&#xA;&lt;p&gt;Also, many commercial supercomputers are available such as the ones described in answers to &lt;a href=&quot;https://mattermodeling.stackexchange.com/q/4635/5&quot;&gt;&lt;strong&gt;What are some cloud services for computing?&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="727" LastEditorUserId="727" LastEditDate="2022-01-05T16:26:52.977" LastActivityDate="2022-01-05T16:26:52.977" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7523" PostTypeId="2" ParentId="7504" CreationDate="2022-01-04T22:03:46.987" Score="2" Body="&lt;p&gt;This problem is known as the Pickup and Delivery Problem with Time Windows (PDPTW). It's a classical and well-studied problem in the scientific literature. Here are two articles describing compact MILP models:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Cordeau J-F (2006) A Branch-and-Cut Algorithm for the Dial-a-Ride Problem. Operations Research 54:573–586. &lt;a href=&quot;https://doi.org/10.1287/opre.1060.0283&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/opre.1060.0283&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Furtado MGS, Munari P, Morabito R (2017) Pickup and delivery problem with time windows: A new compact two-index formulation. Operations Research Letters 45:334–341. &lt;a href=&quot;https://doi.org/10.1016/j.orl.2017.04.013&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.orl.2017.04.013&lt;/a&gt; &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2015/07/5022.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;PDF&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;A couple of MILP models with an exponential number of constraints have also been proposed. They might work better, but are more complex to implement. For example, here:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ropke S, Cordeau J-F, Laporte G (2007) Models and branch-and-cut algorithms for pickup and delivery problems with time windows. Networks 49:258–272. &lt;a href=&quot;https://doi.org/10.1002/net.20177&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1002/net.20177&lt;/a&gt; &lt;a href=&quot;https://backend.orbit.dtu.dk/ws/portalfiles/portal/3154678/Models+and+Branch-and-Cut+Algorithms+for+Pickup+and+Delivery+Problems+with+Time+Windows_TechRep_Ropke_Cordeau_Laporte.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;PDF&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-01-04T22:03:46.987" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7525" PostTypeId="2" ParentId="7516" CreationDate="2022-01-05T16:55:50.663" Score="3" Body="&lt;p&gt;you could try &lt;a href=&quot;https://www.ibm.com/cloud/watson-studio&quot; rel=&quot;nofollow noreferrer&quot;&gt;WatsonStudio&lt;/a&gt; where you will be able to use CPLEX , SPSS and many open source&lt;/p&gt;&#xA;&lt;p&gt;NB: I work for IBM&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-01-05T16:55:50.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7526" PostTypeId="1" AcceptedAnswerId="7529" CreationDate="2022-01-05T18:05:03.420" Score="28" ViewCount="5078" Body="&lt;p&gt;Like many who participate in this site, I work on projects in both operations research (OR) and statistics/&lt;a href=&quot;https://en.wikipedia.org/wiki/Machine_learning&quot; rel=&quot;nofollow noreferrer&quot;&gt;machine learning&lt;/a&gt; (ML). The different states of open source software in these fields are often discouraging as an OR professional.&lt;/p&gt;&#xA;&lt;p&gt;In statistics, the research culture encourages researchers to implement their contributions in the domain-specific language &lt;a href=&quot;https://en.wikipedia.org/wiki/R_%28programming_language%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;R&lt;/a&gt;, so that practitioners have access to working software alongside a whitepaper.&lt;/p&gt;&#xA;&lt;p&gt;In ML, companies like Google and Facebook spend gobs of money to develop open source tools like &lt;a href=&quot;https://en.wikipedia.org/wiki/TensorFlow&quot; rel=&quot;nofollow noreferrer&quot;&gt;TensorFlow&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/PyTorch&quot; rel=&quot;nofollow noreferrer&quot;&gt;PyTorch&lt;/a&gt;, which provide state-of-the-art ML tools to the masses.&lt;/p&gt;&#xA;&lt;p&gt;The state of open source software in statistics and ML allows incremental contributions by individual researchers to be quickly incorporated and utilized by their research communities.&lt;/p&gt;&#xA;&lt;p&gt;But in OR (and &lt;a href=&quot;https://en.wikipedia.org/wiki/Integer_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;integer programming&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Combinatorial_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;combinatorial optimization&lt;/a&gt; in particular), &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi Optimizer&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/CPLEX&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPLEX&lt;/a&gt; have a stranglehold on the state of the art. Using an open source solver means you are leaving performance gains on the table. The result is that academic research in these areas has less impact, because anyone who wants to use the research must pay a small fortune in licensing fees. It's discouraging, and I believe it is one of the reasons that ML and statistics are growing increasingly popular (and perceived as an increasingly valuable skill set) relative to OR.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What explains the difference in open source software cultures between these fields? What can we do to make it better, so that we can get our work into the hands of more people who can use it?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Disclaimer&lt;/em&gt;: There are a number of &lt;em&gt;fantastic&lt;/em&gt; open source projects in OR, which deserve to be celebrated. Off the top of my head (in optimization), examples include &lt;a href=&quot;https://en.wikipedia.org/wiki/COIN-OR#CBC&quot; rel=&quot;nofollow noreferrer&quot;&gt;CBC&lt;/a&gt;/&lt;a href=&quot;https://en.wikipedia.org/wiki/COIN-OR#CLP&quot; rel=&quot;nofollow noreferrer&quot;&gt;CLP&lt;/a&gt;, &lt;a href=&quot;https://www.maths.ed.ac.uk/hall/HiGHS/&quot; rel=&quot;nofollow noreferrer&quot;&gt;HiGHS&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/IPOPT&quot; rel=&quot;nofollow noreferrer&quot;&gt;IPOPT&lt;/a&gt;, and the entire &lt;a href=&quot;https://en.wikipedia.org/wiki/COIN-OR&quot; rel=&quot;nofollow noreferrer&quot;&gt;COIN-OR&lt;/a&gt; effort.  I certainly don't mean to minimize the contributions of these projects, but the fact remains that in integer programming and combinatorial optimization, open source software lags behind its proprietary alternatives. This trend doesn't hold in other fields.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;  I've accepted the answer that I found most convincing. However, one aspect of the original question that hasn't yet been addressed very well is how to &lt;strong&gt;make it better&lt;/strong&gt;. I'm still very interested in hearing suggestions for how to improve the state of open source software in our field, in case anyone would like to add additional answers.&lt;/p&gt;&#xA;" OwnerUserId="3066" LastEditorUserId="491" LastEditDate="2022-03-15T13:17:45.943" LastActivityDate="2022-03-15T13:17:45.943" Title="Why is open source operations research software so far behind open source statistics and machine learning software?" Tags="|mixed-integer-programming|combinatorial-optimization|software|" AnswerCount="5" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7527" PostTypeId="2" ParentId="7526" CreationDate="2022-01-06T08:19:52.170" Score="19" Body="&lt;p&gt;Disclaimer: although I work for Gurobi, the views in this post are entirely my own.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;I believe there are a few reasons for this trend:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First of all, the industries were &amp;quot;born&amp;quot; in different times. Bob Bixby founded CPLEX in 1988 (or thereabouts), while PyTorch was &lt;a href=&quot;https://en.wikipedia.org/wiki/PyTorch&quot; rel=&quot;noreferrer&quot;&gt;first released in 2016&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;This also means though that these two industries are in different life cycles. The OR industry (especially around LP/MIP) has very much consolidated itself over the past 20-30 years, resulting in the situation we see today: a few commercial solvers which provide by far the best performance. This was not always the case: for example, when the &lt;a href=&quot;https://www.coin-or.org/Bonmin/&quot; rel=&quot;noreferrer&quot;&gt;bonmin&lt;/a&gt; package came out in the mid 00s, it was in quite a few cases better than the then state-of-the-art CPLEX. On the other hand, ML software is still evolving, with new methods and paradigms springing up at every conference (it seems at least). It will be interesting to see where the industry will be in 10-20 years, when a lot of the dust will have settled.&lt;/li&gt;&#xA;&lt;li&gt;Finally, related to the life cycle point is also a point around performance: the code of commercial solvers is brutally performant. To achieve this level, you cannot have too many &amp;quot;cooks in the kitchen&amp;quot;. How will TensorFlow or PyTorch achieve this performance, and is there even such a thing as a competitive performance benchmark (same training set, same algorithm types etc.) in the ML world?&lt;/li&gt;&#xA;&lt;li&gt;However, even in the OR world you have a lot of open-source activity, especially around non-linear optimization. Since academics get e.g. Gurobi for free, many of them use it as their LP/MIP solver and then solver very complex non-linear or stochastic programming models. Check out for example &lt;a href=&quot;https://github.com/cog-imperial&quot; rel=&quot;noreferrer&quot;&gt;the GitHub repo&lt;/a&gt; of Ruth Misener's group out of Imperial. This is fantastic work, all open-source and really cutting-edge in a lot of cases.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="133" LastActivityDate="2022-01-06T08:19:52.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7528" PostTypeId="1" AcceptedAnswerId="7538" CreationDate="2022-01-06T09:21:01.447" Score="2" ViewCount="125" Body="&lt;p&gt;When we are doing inventory optimization, say implementing a base-stock policy, one of the KPIs we monitor is the average on-hand inventory, which we use to calculate the average inventory holding cost.&lt;/p&gt;&#xA;&lt;p&gt;For a base-stock policy with base-stock level &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, if executed perfectly, the average on-hand inventory is the sum of the safety stock and the cycle stock, where cycle stock is defined as half of the average demand during the review period.&lt;/p&gt;&#xA;&lt;p&gt;Now my question is, is there a similar way to calculate the average on-hand inventory for a periodic review inventory policy such as the &lt;span class=&quot;math-container&quot;&gt;$(s, S)$&lt;/span&gt;-policy? Recall a &lt;span class=&quot;math-container&quot;&gt;$(s,S)$&lt;/span&gt;-policy with review period &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; operates as follows: every &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt;-period, we review the current inventory position, which includes both the on-hand and in-transit inventory, if the inventory position is less than &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; (the reorder-point), then we order inventories to bring the inventory position to level &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; (the order-up-to level), otherwise we do not order.&lt;/p&gt;&#xA;" OwnerUserId="4743" LastEditorUserId="8814" LastEditDate="2022-01-06T14:54:47.137" LastActivityDate="2022-01-07T02:56:19.083" Title="Expected onhand inventory in (s,S) policy" Tags="|inventory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7529" PostTypeId="2" ParentId="7526" CreationDate="2022-01-06T09:34:27.963" Score="33" Body="&lt;p&gt;As someone who uses a lot of commercial/open-source OR software and incidentally tried coding my own solver, the underlying question is that of continued funding and support.&lt;/p&gt;&#xA;&lt;p&gt;As mentioned in another answer, LP/MIP solvers have been around for over 30 years (fun fact: technically, solving LPs and MIPs pre-dates software itself). This means continued development over several decades, with incremental improvements every year summing up to Richard's &amp;quot;brutal performance&amp;quot;.&#xA;In my view, the main difference between open-source and commercial tools is there: the latter benefit from continuous support and improvements over many years, while the former often stale when their main developer retires or moves on.&lt;/p&gt;&#xA;&lt;p&gt;Not everything is grim though. SCIP (albeit not technically open-source) has institutional support from Zib and several industrial partners. Google's OR-Tools is open-source. More recently, the HiGHS team has managed to find some industrial partners to fund (part of?) the development.&lt;/p&gt;&#xA;&lt;p&gt;This raises the following question: why do open-source ML/Stats tool get so much company support compared to the OR ones? Why does Google invests so much money in TensorFlow but doesn't sell licenses? And why isn't there a similar situation in OR?&lt;/p&gt;&#xA;&lt;p&gt;Answer 1: culture. TensorFlow is pre-dated by Theano (now discontinued), whose academic devs wanted to be open-source. So when TensorFlow (and later Pytorch) came around, people had a strong open-source alternative, hence, there was less value in keeping it closed-source. The ML community is now very pro open-source indeed.&lt;/p&gt;&#xA;&lt;p&gt;Answer 2: intrinsic value. In ML, the core value is &lt;strong&gt;not&lt;/strong&gt; in the ML algorithm itself, it's in the data you feed it and the computing power you have. Google did open-source TF, but you don't see Google (or any other big player) open-source their data. In contrast, in OR, there is a lot of value in being able to &lt;em&gt;solve&lt;/em&gt; the problem in the first place. Data still plays a huge role, but the algorithms carry relatively more weight than in ML.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Re: &amp;quot;How to make it better?&amp;quot;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The open-source ecosystem in OR is vast. The points below focus on the area I know best, which is optimization solver.&lt;/p&gt;&#xA;&lt;p&gt;As a user&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Give credit&lt;/strong&gt;. This can be as simple as giving a &amp;quot;star&amp;quot; on GitHub or citing the paper/software in academic publications. Academic performance is driven primarily by paper citations, and researchers must show impact to secure funding.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Report bugs and hard instances&lt;/strong&gt;. Bugs can't be fixed if they go unreported. When you do report a bug, try to include a working example that someone can copy-paste to reproduce the error. Hard instances help identify where there is room for improvement (both code-wise ans math-wise), and will drive future performance.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Help fund the development&lt;/strong&gt;. This can take the form of donations (e.g. via NumFocus), paid-for support (when that's an possibility) or collaborative research. Plus, it's easier to tweak the software to fit your need when you have a hand in the development.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As a developer:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Make it easy to use&lt;/strong&gt;. As a user, ease of installation is the first (time-wise) barrier to using software. One success story I can share is the way the Julia community has streamlined using open-source sovlers. Want to use Clp? just type &amp;quot;add Clp&amp;quot; and you're good to go. It's a godsend.&lt;/p&gt;&#xA;&lt;p&gt;Nowadays, there exists many tools to host, test and distribute software, manage dependencies, all across multiple platforms/architectures/languages, etc.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Provide documentation&lt;/strong&gt;. It's tedious, it's annoying, you won't get promoted to full professor for doing it, but good documentation is a vital must-have. Similarly, there are tools to automate this, especially the rendering and hosting it online.&lt;/p&gt;&#xA;&lt;p&gt;It's also much easier for someone to contribute something if they can have access to good documentation, instead of having to figure out what each piece of code actually does and why.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interface with modeling languages&lt;/strong&gt;. More and more users only use solvers through a modeling language, e.g., &lt;a href=&quot;https://jump.dev/&quot; rel=&quot;noreferrer&quot;&gt;JuMP&lt;/a&gt;, &lt;a href=&quot;http://www.pyomo.org/&quot; rel=&quot;noreferrer&quot;&gt;Pyomo&lt;/a&gt;, &lt;a href=&quot;https://www.gravityopt.com/&quot; rel=&quot;noreferrer&quot;&gt;Gravity&lt;/a&gt;, etc. or commercial alternatives like AMPL and GAMS.&#xA;Anything that has a C interface can be interfaced to all the open-source tools above, which then makes it much easier to gain users. It also removes the need to develop your own comprehensive interface, thereby freeing up time for other things.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Make it numerically robust&lt;/strong&gt;. There's nothing worse than waiting a couple hours to see a solver crash due to numerical errors. IMO, a key to adoption is when users can trust that the solver will return a valid solution, without crashing or throwing an error, even if it means having to wait a little more.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="3598" LastEditDate="2022-01-13T02:50:24.183" LastActivityDate="2022-01-13T02:50:24.183" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7530" PostTypeId="1" CreationDate="2022-01-06T14:08:38.333" Score="2" ViewCount="202" Body="&lt;p&gt;I'm struggling with this question for weeks:&lt;/p&gt;&#xA;&lt;p&gt;What is the main difference between the role of computation lower bounds for exact methods, heuristics, and hybrid of exact and heuristics?&lt;/p&gt;&#xA;&lt;p&gt;I try to answer that by saying:&lt;/p&gt;&#xA;&lt;p&gt;Lower bound for exact methods is &amp;quot;an aid tool&amp;quot; to solve the problem but not an independent solution tool. While for heuristics methods, it is &amp;quot;a  measuring tool&amp;quot; for the quality of the solution. Is that right?&lt;/p&gt;&#xA;&lt;p&gt;What about the hybrid of exact and heuristics methods?&lt;/p&gt;&#xA;&lt;p&gt;I  need references to understand the difference.&lt;/p&gt;&#xA;" OwnerUserId="8850" LastEditorUserId="36" LastEditDate="2022-01-06T14:18:30.593" LastActivityDate="2022-01-06T16:11:40.120" Title="What is the role of computation lower bounds for exact methods, heuristics, and hybrid of exact and heuristics?" Tags="|reference-request|heuristics|bounds|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7531" PostTypeId="1" CreationDate="2022-01-06T14:51:35.440" Score="1" ViewCount="341" Body="&lt;p&gt;For a work shift optimization problem, I've defined a binary variable in PuLP as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;pulp.LpVariable.dicts('VAR', (range(D), range(N)), 0, 1, 'Binary')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$D =$&lt;/span&gt; # days in each schedule we create (= 28, or 4 weeks)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$N =$&lt;/span&gt; # of workers&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;and the variable &lt;span class=&quot;math-container&quot;&gt;$VAR$&lt;/span&gt; represents whether worker &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; works in Day &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; or not.&lt;/p&gt;&#xA;&lt;p&gt;I want to ensure that work is evenly distributed over the 28 days (a.k.a &lt;span class=&quot;math-container&quot;&gt;$VAR$&lt;/span&gt; for worker &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; should look more like &lt;code&gt;[1,0,0,0,1,0,0,0,0,1,...,var[i=27][J]]&lt;/code&gt; rather than &lt;code&gt;[1,1,1,0,0,0,0,0,...,var[i=27][J]]&lt;/code&gt; where work is clustered in the beginning). Since I can't add if statements/access the values of variables before they are defined, an approach where we minimize the range in days between work shifts doesn't seem feasible (since the work shifts themselves haven't been allocated yet). What could be a way to model this optimization problem?&lt;/p&gt;&#xA;" OwnerUserId="8832" LastEditorUserId="500" LastEditDate="2022-01-06T15:58:51.013" LastActivityDate="2022-01-07T00:43:09.223" Title="optimize days between work shift" Tags="|optimization|linear-programming|modeling|scheduling|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7532" PostTypeId="2" ParentId="7531" CreationDate="2022-01-06T15:58:20.777" Score="5" Body="&lt;p&gt;You can enforce &amp;quot;no more than &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; workdays in any consecutive &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;-day period&amp;quot; via linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=t}^{t+d-1} x_i \le w \quad \text{for all $t$}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-01-06T15:58:20.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7533" PostTypeId="2" ParentId="7530" CreationDate="2022-01-06T16:11:40.120" Score="3" Body="&lt;p&gt;I would say that a &amp;quot;best bound&amp;quot; (lower bound if you are minimizing) has essentially the same role regardless of whether the method is exact or approximate: to give you an idea of how close to optimal your current solution is, and what your worst-case risk is if you settle for the current solution. One difference I can see is that it is fairly common to use the gap between the incumbent solution and best bound as a stopping criterion when using an exact solver, whereas I don't recall seeing that done when using a heuristic.&lt;/p&gt;&#xA;&lt;p&gt;For branch-and-bound / branch-and-cut / branch-and-price type algorithms, the bounds on individual nodes obviously play a role in pruning those nodes and also in steering the algorithm (selecting the next node to explore).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-06T16:11:40.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7534" PostTypeId="2" ParentId="7531" CreationDate="2022-01-06T16:23:37.877" Score="3" Body="&lt;p&gt;If you cannot enforce a specific maximum days policy as Rob Pratt suggests, another possibility is to penalize the lumpiness of the work distribution. Pick a window size &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; (Rob's &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;-day period&amp;quot;), and add two new variables &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; along with the constraints &lt;span class=&quot;math-container&quot;&gt;$$y \ge \sum_{i=t}^{t+d-1} x_i \quad \forall t \in \lbrace1,\dots,D-d+1\rbrace$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$z \le \sum_{i=t}^{t+d-1} x_i \quad \forall t \in \lbrace1,\dots,D-d+1\rbrace.$$&lt;/span&gt;Now penalize &lt;span class=&quot;math-container&quot;&gt;$y-z$&lt;/span&gt; in your objective function.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-06T16:23:37.877" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7535" PostTypeId="1" AcceptedAnswerId="7536" CreationDate="2022-01-06T19:06:04.603" Score="1" ViewCount="154" Body="&lt;p&gt;I am evaluating a genetic algorithm that was written for a vehicle routing problem with time windows. The problem was not solved with any exact method (or with any solver). I also do not know bound of the solution. I know that at each iteration, the GA is giving better results than the initial solution. I am trying to learn the following questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there any way to make sure that the GA is converging to optimal/ near optimal solution?&lt;/p&gt;&#xA;&lt;p&gt;So far the solution at each iteration is getting better or not getting worse than the previous iteration. But I am not sure when I should stop it and how close it is to near optimal solution. Do GAs converges to optimal solution with a finite number of iteration for a feasible problem. Right now it stops after a specific number of iteration. If a GA is run for a large number of iterations, are they supposed to converge to near optimal solution eventually? or is some information lost during crossover and mutation for which it can not reach optimal solution?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Let's say we have several versions of a GA( different generation size, elite size, mutation criteria etc.). How should one determine the best of algorithm?&lt;/p&gt;&#xA;&lt;p&gt;I can compare which one is faster and giving better solution after running for a specific number of iterations. But are there are any tested or 'in general' methods that are used for evaluating GA performance?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3288" LastActivityDate="2022-01-06T20:25:40.943" Title="Genetic Algorithm" Tags="|vehicle-routing|genetic-algorithm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7536" PostTypeId="2" ParentId="7535" CreationDate="2022-01-06T20:25:40.943" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;GAs tend to &amp;quot;converge&amp;quot; in the sense that the population tends to become homogeneous after a while (which I believe is known as &amp;quot;stagnation&amp;quot;). There are various things implemented by some GAs (&amp;quot;immigration&amp;quot;, &amp;quot;island model&amp;quot;, ...) to try to ward off premature convergence, but not everyone uses them. If the GA does converge, there is in general no guarantee that it converges to an optimal solution. The only way to know if you are at or near an optimum is to have a tight bound for the optimal value (which would have to come from outside the GA). With a discrete problem (having a bounded feasible region) and a GA using either immigration (new random solutions being added in each generation) or mutation of surviving adults, it might be possible to prove that with probability 1.0 you would eventually see an optimal solution. I'm not positive about that, and in any case &amp;quot;eventually&amp;quot; and &amp;quot;within your lifetime&amp;quot; might not be synonymous. The issue is not that the GA &lt;em&gt;cannot&lt;/em&gt; reach an optimum ... just that it &lt;em&gt;might not&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As far as I know, tuning the parameters of a GA is based on a couple of criteria. One is how fast the solutions improve, or how quickly you get to an objective function that (while possibly not optimal) makes you happy. The other, which I'm pretty sure is less commonly used, is how quickly the GA stagnates. You want to avoid early stagnation. I'm not sure how many GA codes actually provide the user with measures of stagnation. You can typically tell whether the best solution has or has not improved recently, but I believe to detect stagnation you would need to look at some measure of the distribution of objective values in the population (standard deviation, interquartile range, ...). If the objective values are too close together, it may be stagnating.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Incidentally, the objective value not getting worse from iteration to iteration may be a function of parameter settings. If the GA uses &amp;quot;elitism&amp;quot; (retaining a few of the best solutions from the previous generation), the objective value will automatically be monotonic, which would not tell you anything about how the GA was doing. Also, you need to look at whether the GA is reporting &amp;quot;best in generation&amp;quot; or &amp;quot;best ever&amp;quot; (the latter obviously being monotonic). The one combination where the objective could get worse from generation to generation would be no elitism plus reporting the best in generation value.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-06T20:25:40.943" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7537" PostTypeId="2" ParentId="7531" CreationDate="2022-01-07T00:43:09.223" Score="1" Body="&lt;p&gt;Maybe you could approach it from the opposite direction?&lt;/p&gt;&#xA;&lt;p&gt;Instead of imposing a penalty on uneven distributions, first generate a set of highly even candidate work schedules. Then if the optimizer fails to find a solution, iteratively generate and add less evenly distributed work schedules.&lt;/p&gt;&#xA;&lt;p&gt;This method would allow you to use whatever metric you like for &amp;quot;evenness&amp;quot;. The major costs being that you'd almost certainly be unable to achieve optimality, and that you might not find a solution for complex problems.&lt;/p&gt;&#xA;" OwnerUserId="3888" LastActivityDate="2022-01-07T00:43:09.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7538" PostTypeId="2" ParentId="7528" CreationDate="2022-01-07T02:56:19.083" Score="3" Body="&lt;p&gt;I do not believe there is a simple way to calculate this. The inventory level in an &lt;span class=&quot;math-container&quot;&gt;$(s,S)$&lt;/span&gt; policy has a probability distribution that is not easy to characterize, and therefore neither is the expected inventory level.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://doi.org/10.1287/opre.39.4.654&quot; rel=&quot;nofollow noreferrer&quot;&gt;Zheng and Federgruen (1991)&lt;/a&gt; or &lt;a href=&quot;https://www.jstor.org/stable/2946110&quot; rel=&quot;nofollow noreferrer&quot;&gt;Veinott (1966)&lt;/a&gt; for some theory on &lt;span class=&quot;math-container&quot;&gt;$(s,S)$&lt;/span&gt; policies. I don't think either of these papers characterizes the inventory level r.v. directly. But if it &lt;em&gt;were&lt;/em&gt; easy to characterize that r.v., then it wouldn't have been such hard work for these papers to evaluate the expected cost.&lt;/p&gt;&#xA;&lt;p&gt;(Interestingly, for &lt;span class=&quot;math-container&quot;&gt;$(r,Q)$&lt;/span&gt; policies, the inventory level distribution is very easy: The IL is uniformly distributed on &lt;span class=&quot;math-container&quot;&gt;$[r,Q]$&lt;/span&gt; (for continuous demands) or on &lt;span class=&quot;math-container&quot;&gt;$[r+1,Q]$&lt;/span&gt; (for discrete demands).)&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2022-01-07T02:56:19.083" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7539" PostTypeId="1" AcceptedAnswerId="7540" CreationDate="2022-01-07T05:32:12.427" Score="3" ViewCount="3760" Body="&lt;p&gt;I have an optimization problem that I am trying to solve with PuLP.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;All the variables are Booleans.&lt;/li&gt;&#xA;&lt;li&gt;The variables that are &amp;quot;selected&amp;quot; will be true, all others false.&lt;/li&gt;&#xA;&lt;li&gt;Objective function is simple: each selected variable has a constant reward.&lt;/li&gt;&#xA;&lt;li&gt;so optimal solution if there is no constraint would be all variables turned on (true)&lt;/li&gt;&#xA;&lt;li&gt;sadly there are constraints that won't allow all to be turned on :)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;There are two types of constraints:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;simple constraint that takes a list of variable indexes, where zero or one is allowed to be turned on. That would be expressed as &lt;code&gt;pulp.lpSum(variables[str(i)] for i in indexes) &amp;lt;= 1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;more complicated constraint that takes two arrays as input.&#xA;&lt;ol&gt;&#xA;&lt;li&gt;zero or one elements may be selected from first array&lt;/li&gt;&#xA;&lt;li&gt;zero, one, or many elements may be selected from second array&lt;/li&gt;&#xA;&lt;li&gt;if no element is selected from first array, then no element should be selected from second&lt;/li&gt;&#xA;&lt;li&gt;if an element is selected from first array, then at least one element should be selected from the second. And vice-versa.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Here's some code that demonstrates it. The code does &lt;em&gt;not&lt;/em&gt; work as I would like, because I don't know how to specify the more complicated constraint type:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from unittest import TestCase&#xA;import pulp&#xA;&#xA;class IpModelTestCase(TestCase):&#xA;&#xA;    def test_pulp_with_weird_constraint(self):&#xA;        self.count = 20&#xA;        self.constrain_sums = [[0, 1, 2, 3, 4],&#xA;                               [5, 6, 7, 8, 9],&#xA;                               [10, 11, 12, 13, 14],&#xA;                               [15, 16, 17, 18, 19]]&#xA;        self.constrain_sums_both_zero_or_one_and_one_or_greater = [([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],&#xA;                                                                    [10, 11, 12, 13, 14, 15, 16, 17, 18, 19])]&#xA;&#xA;        model = pulp.LpProblem('pulp', pulp.LpMaximize)&#xA;        rewards = [3] * self.count&#xA;&#xA;        variables = pulp.LpVariable.dicts('option', indexs=[str(i) for i in range(self.count)], cat=pulp.LpBinary)&#xA;&#xA;        # set the objective function&#xA;        model += pulp.lpSum([rewards[i] * variables[str(i)] for i in range(self.count)])&#xA;&#xA;        # these constraints are straightforward. &#xA;        # enforces: pick at most one index from each list&#xA;        for indexes in self.constrain_sums:&#xA;            model += pulp.lpSum(variables[str(i)] for i in indexes) &amp;lt;= 1&#xA;&#xA;        # Here is where I am stuck. The &amp;quot;pseudocode&amp;quot; below describes what I intend the constraint to do,&#xA;        # but it does not work, I think because this whole mess is not a single pure linear expression.&#xA;        # Rather it's 3 different LP combined with and/or logic operators&#xA;        for indexes_zero_or_one, indexes_zero_or_one_or_greater in self.constrain_sums_both_zero_or_one_and_one_or_greater:&#xA;            model += (&#xA;                    (&#xA;                        # choose one index from first list AND choose one or more from the second.&#xA;                            pulp.lpSum(variables[str(i)] for i in indexes_zero_or_one) == 1&#xA;                            and&#xA;                            pulp.lpSum(variables[str(i)] for i in indexes_zero_or_one_or_greater) &amp;gt;= 1&#xA;                    )&#xA;                    or&#xA;                    (&#xA;                        # OR, if no index from first list is chosen, then don't choose any from the second list either.&#xA;                            pulp.lpSum(variables[str(i)] for i in indexes_zero_or_one) +&#xA;                            pulp.lpSum(variables[str(i)] for i in indexes_zero_or_one_or_greater) == 0&#xA;                    )&#xA;&#xA;            )&#xA;&#xA;        print(model)&#xA;        &#xA;        # solve it&#xA;        model.solve(pulp.PULP_CBC_CMD())&#xA;        selected = [int(i) for i, var in variables.items() if var.varValue &amp;gt; 0.99]&#xA;        print(selected)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See the &amp;quot;here is where I am stuck&amp;quot; comment above for the part I am stuck on. How to express the more complicated constraint as a single linear expression? Just not sure how to do it. Is it possible?&lt;/p&gt;&#xA;&lt;p&gt;Output of the code above for completeness:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;pulp:&#xA;MAXIMIZE&#xA;3*option_0 + 3*option_1 + 3*option_10 + 3*option_11 + 3*option_12 + 3*option_13 + 3*option_14 + 3*option_15 + 3*option_16 + 3*option_17 + 3*option_18 + 3*option_19 + 3*option_2 + 3*option_3 + 3*option_4 + 3*option_5 + 3*option_6 + 3*option_7 + 3*option_8 + 3*option_9 + 0&#xA;SUBJECT TO&#xA;_C1: option_0 + option_1 + option_2 + option_3 + option_4 &amp;lt;= 1&#xA;&#xA;_C2: option_5 + option_6 + option_7 + option_8 + option_9 &amp;lt;= 1&#xA;&#xA;_C3: option_10 + option_11 + option_12 + option_13 + option_14 &amp;lt;= 1&#xA;&#xA;_C4: option_15 + option_16 + option_17 + option_18 + option_19 &amp;lt;= 1&#xA;&#xA;_C5: option_10 + option_11 + option_12 + option_13 + option_14 + option_15&#xA; + option_16 + option_17 + option_18 + option_19 &amp;gt;= 1&#xA;&#xA;VARIABLES&#xA;0 &amp;lt;= option_0 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_10 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_11 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_12 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_13 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_14 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_15 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_16 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_17 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_18 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_19 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_3 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_4 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_5 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_6 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_7 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_8 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= option_9 &amp;lt;= 1 Integer&#xA;&#xA;Welcome to the CBC MILP Solver &#xA;Version: 2.10.3 &#xA;Build Date: Dec 15 2019 &#xA;&#xA;command line - /home/jhersch/.virtualenvs/gemini3.6.9/lib/python3.6/site-packages/pulp/apis/../solverdir/cbc/linux/64/cbc /tmp/938110e6df59477d9d411715c91ac428-pulp.mps max branch printingOptions all solution /tmp/938110e6df59477d9d411715c91ac428-pulp.sol (default strategy 1)&#xA;At line 2 NAME          MODEL&#xA;At line 3 ROWS&#xA;At line 10 COLUMNS&#xA;At line 101 RHS&#xA;At line 107 BOUNDS&#xA;At line 128 ENDATA&#xA;Problem MODEL has 5 rows, 20 columns and 30 elements&#xA;Coin0008I MODEL read with 0 errors&#xA;Continuous objective value is 12 - 0.00 seconds&#xA;Cgl0008I 4 inequality constraints converted to equality constraints&#xA;Cgl0004I processed model has 0 rows, 0 columns (0 integer (0 of which binary)) and 0 elements&#xA;Cbc3007W No integer variables - nothing to do&#xA;Cuts at root node changed objective from -12 to -1.79769e+308&#xA;Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;&#xA;Result - Optimal solution found&#xA;&#xA;Objective value:                12.00000000&#xA;Enumerated nodes:               0&#xA;Total iterations:               0&#xA;Time (CPU seconds):             0.00&#xA;Time (Wallclock seconds):       0.00&#xA;&#xA;Option for printingOptions changed from normal to all&#xA;Total time (CPU seconds):       0.00   (Wallclock seconds):       0.00&#xA;&#xA;[0, 5, 10, 15]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The output is not desired because:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the last constraint _C5 is incomplete. It's only part of the more complicated constraint I really want to express.&lt;/li&gt;&#xA;&lt;li&gt;the output &lt;code&gt;[0, 5, 10, 15]&lt;/code&gt; is not what I want. It violates the complicated constraint (because I wasn't able to express it correctly). It violates it because indexes 0 and 5 are not allowed to both be chosen. Only zero or one elements should be selected from &lt;code&gt;[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;EDIT: For completness, here it is fixed up with Rob's solution:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;    def test_pulp_with_weird_constraint(self):&#xA;        self.count = 20&#xA;        self.constrain_sums = [[0, 1, 2, 3, 4],&#xA;                               [5, 6, 7, 8, 9],&#xA;                               [10, 11, 12, 13, 14],&#xA;                               [15, 16, 17, 18, 19]]&#xA;        self.constrain_sums_both_zero_or_one_and_one_or_greater = [([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],&#xA;                                                                    [10, 11, 12, 13, 14, 15, 16, 17, 18, 19])]&#xA;&#xA;        model = pulp.LpProblem('pulp', pulp.LpMaximize)&#xA;        rewards = [3] * self.count&#xA;&#xA;        variables = pulp.LpVariable.dicts('option', indexs=list(range(self.count)), cat=pulp.LpBinary)&#xA;&#xA;        # set the objective function&#xA;        model += pulp.lpSum([rewards[i] * variables[i] for i in range(self.count)])&#xA;&#xA;        # these constraints are straightforward. enforces pick at most one index from each list&#xA;        for indexes in self.constrain_sums:&#xA;            model += pulp.lpSum(variables[i] for i in indexes) &amp;lt;= 1&#xA;&#xA;        for indexes_zero_or_one, indexes_zero_or_one_or_greater in self.constrain_sums_both_zero_or_one_and_one_or_greater:&#xA;            # zero or one elements selected from first array&#xA;            model += (pulp.lpSum(variables[i] for i in indexes_zero_or_one) &amp;lt;= 1)&#xA;            # if no element is selected from first array, then no element should be selected from second&#xA;            for index in indexes_zero_or_one_or_greater:&#xA;                model += (pulp.lpSum(variables[i] for i in indexes_zero_or_one) &amp;gt;= variables[index])&#xA;&#xA;            # if an element is selected from first array, then at least one element should be selected from the second&#xA;            model += (pulp.lpSum(variables[i] for i in indexes_zero_or_one) &amp;lt;=&#xA;                      pulp.lpSum(variables[i] for i in indexes_zero_or_one_or_greater))&#xA;&#xA;        # solve it&#xA;        model.solve(pulp.PULP_CBC_CMD())&#xA;        selected = [int(i) for i, var in variables.items() if var.varValue &amp;gt; 0.99]&#xA;        self.assertEqual([0, 10, 15], selected)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8857" LastEditorUserId="500" LastEditDate="2022-01-07T16:42:59.867" LastActivityDate="2022-01-07T16:42:59.867" Title="Complicated constraint with logical operators in PuLP" Tags="|python|integer-programming|constraint|logical-constraints|pulp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7540" PostTypeId="2" ParentId="7539" CreationDate="2022-01-07T05:52:03.977" Score="10" Body="&lt;p&gt;Suppose your two arrays are indexed by &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; be the binary variable.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;zero or one elements may be selected from first array:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in I} x_i \le 1 \tag1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;zero, one, or many elements may be selected from second array: no constraint needed here&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if no element is selected from first array, then no element should be selected from second:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_j \le \sum_{i\in I} x_i \quad \text{for $j\in J$} \tag2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if an element is selected from first array, then at least one element should be selected from the second:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in I} x_i \le \sum_{j\in J} x_j \tag3$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The &amp;quot;And vice-versa&amp;quot; part is already enforced by &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that a natural but weak alternative to &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i \le \sum_{j\in J} x_j \quad \text{for $i\in I$} \tag4$$&lt;/span&gt;&#xA;But &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; is a strengthening of &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; based on &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, as described in &lt;a href=&quot;https://or.stackexchange.com/questions/6187/how-can-i-strengthen-a-family-of-constraints-in-the-presence-of-a-clique-constra&quot;&gt;How can I strengthen a family of constraints in the presence of a clique constraint?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-01-07T05:52:03.977" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7541" PostTypeId="2" ParentId="7518" CreationDate="2022-01-07T12:38:47.457" Score="3" Body="&lt;p&gt;I found what the problem seemed to be. I had set the first solution strategy to automatic, which generated a first solution using all trucks.&lt;/p&gt;&#xA;&lt;p&gt;Reading the &lt;a href=&quot;https://developers.google.com/optimization/routing/routing_options&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; I found this strategy called &amp;quot;ALL_UNPERFORMED&amp;quot; which does the following.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Make all nodes inactive. Only finds a solution if nodes are optional (are element of a disjunction constraint with a finite penalty cost).&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;This way it only uses as many nodes as needed.&lt;/p&gt;&#xA;" OwnerUserId="7633" LastActivityDate="2022-01-07T12:38:47.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7542" PostTypeId="2" ParentId="7526" CreationDate="2022-01-07T16:48:59.583" Score="12" Body="&lt;p&gt;Disclaimer: I do work for Fico/Xpress, one of the leading commercial optimization solver developers, but this is my own personal opinion.&lt;/p&gt;&#xA;&lt;p&gt;I agree 100% with the comment about where the value is: the model or the algorithms. In ML the value is in the data/mode/computing power, in OR it is more in the algorithms.&lt;/p&gt;&#xA;&lt;p&gt;About cultural differences: if you are an academic writing a paper in ML you are expected to show computational results. In OR you can publish papers that are technically correct, but nobody knows if the method is worth implementing, because the author didn't do it and the journal/editor didn't make them to. All we know is that the method is correct and it converges. I'm happy to see though that this attitude has been changing recently, and more and more OR journals require computational results before an article is published.&lt;/p&gt;&#xA;&lt;p&gt;Personal side note on cultural differences: back in my academic days I once interviewed for a faculty position at an industrial engineering department, where I was told that it was not possible to get tenure for software work. Regardless of how much theoretical work went into the software or how useful it was in solving practical problems. That is not very encouraging for young faculty members hoping to do computational OR work in academia.&lt;/p&gt;&#xA;" OwnerUserId="319" LastActivityDate="2022-01-07T16:48:59.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7544" PostTypeId="1" CreationDate="2022-01-08T14:22:24.227" Score="3" ViewCount="77" Body="&lt;p&gt;I would like to solve a problem obtained from a LP by adding a second degree term to its utility.&lt;/p&gt;&#xA;&lt;p&gt;A simple example would be the following (with &lt;span class=&quot;math-container&quot;&gt;$c_i &amp;gt; 0$&lt;/span&gt;):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \min xy - c_1 z_1 - c_2 z_2  &#xA;   \\ \textrm{s.t. } &#xA;      x = z_1 + c_3, &#xA;   \\ y = z_2 + c_4, &#xA;   \\ x, y \geq 0. $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I believe the problem cannot be converted into a geometric program (due to negative coefficients) nor a mixed linear geometric program (as the variables are not partitioned).&lt;/p&gt;&#xA;&lt;p&gt;I tried to obtain a convex problem by introducing new variables &lt;span class=&quot;math-container&quot;&gt;$X := \log x, Y := \log y$&lt;/span&gt; for&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \min t - c_1 z_1 - c_2 z_2 \\&#xA;   \textrm{s.t. } &#xA;    t \geq e^{X+Y},  \\&#xA;    e^X = z_1 + c_3, \\&#xA;    e^Y = z_2 + c_4. $$&lt;/span&gt;&#xA;I thought about relaxing the equalities (&lt;span class=&quot;math-container&quot;&gt;$e^X \leq z_1 + c_3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$e^Y \leq z_2 + c_4$&lt;/span&gt;) and compensate with a penalty term in the utility -- but I stuck here.&lt;/p&gt;&#xA;&lt;p&gt;Is there an efficient way to solve such problem?&lt;/p&gt;&#xA;" OwnerUserId="8870" LastActivityDate="2022-01-08T14:22:24.227" Title="Linear program with an additional second-degree utility term" Tags="|optimization|nonlinear-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7546" PostTypeId="1" CreationDate="2022-01-09T10:29:54.807" Score="0" ViewCount="411" Body="&lt;p&gt;I want to do a &lt;strong&gt;sensitivity analysis&lt;/strong&gt; for the following problem.&#xA;I know how to add new variables or constraints, but I do not know how I can change the right-hand side (RHS) of the constraint.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#**Orginal problem**   &#xA;&#xA;from docplex.mp.model import Model  &#xA;mdl = Model(name='buses')  &#xA;nbbus40 = mdl.integer_var(name='nbBus40')  &#xA;nbbus30 = mdl.integer_var(name='nbBus30')  &#xA;ctKids=mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')   &#xA;mdl.minimize(nbbus40*500 + nbbus30*400)   &#xA;&#xA;mdl.solve()   &#xA;for v in mdl.iter_integer_vars():   &#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)    &#xA;&#xA;&#xA;#**Add new constraint**      &#xA;print(&amp;quot;Same number of 40 and 30 seats buses&amp;quot;)    &#xA;mdl.add_constraint(nbbus40==nbbus30, 'samenumberofbuses')    &#xA;mdl.minimize(nbbus40*500 + nbbus30*400)    &#xA;&#xA;mdl.solve()    &#xA;for v in mdl.iter_integer_vars():    &#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)   &#xA;&#xA;&#xA;#**Add a new variable**        &#xA;print(&amp;quot;Now with buses with 50 seats&amp;quot;)     &#xA;&#xA;nbbus50 = mdl.integer_var(name='nbBus50')    &#xA;ctKids.left_expr.add_term(nbbus50, 50)    &#xA;mdl.minimize(nbbus40*500 + nbbus30*400 + nbbus50*700)    &#xA;&#xA;mdl.solve()    &#xA;for v in mdl.iter_integer_vars():    &#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8875" LastEditorUserId="36" LastEditDate="2022-01-09T15:09:33.310" LastActivityDate="2022-01-10T07:35:52.963" Title="sensitivity analysis in python + Docplex" Tags="|optimization|python|docplex|sensitivity-analysis|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7547" PostTypeId="1" CreationDate="2022-01-09T11:51:05.427" Score="1" ViewCount="398" Body="&lt;p&gt;Requirement overview:&#xA;The trip route can have the following type of task&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Delivery only&lt;/li&gt;&#xA;&lt;li&gt;Pickup only&lt;/li&gt;&#xA;&lt;li&gt;Pickup from one location and deliver to another location&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Condition: Once a trip starts from depot, it should come back only when the trip is completed. During the trip, it shouldn’t come to depot.&lt;/p&gt;&#xA;&lt;p&gt;As we understand, OR tools need delivery and pickup location for each order else it's giving issues.&#xA;Ref: &lt;a href=&quot;https://groups.google.com/g/or-tools-discuss/c/WyEOZAv8IJs/m/PxWb7Lq7AwAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://groups.google.com/g/or-tools-discuss/c/WyEOZAv8IJs/m/PxWb7Lq7AwAJ&lt;/a&gt;&#xA;To overcome this, for all delivery orders we add depot as pick location and for all pick orders, we add depot as the delivery location. This is working fine if all orders are for delivery. However, if orders are having a mix of delivery and pick, in this scenario, during the trip if the depot location is near to the last pick node, the vehicle will go to the depot if OR-tools is optimizing like this (considering the last pick needs to be delivered at depot).&lt;/p&gt;&#xA;&lt;p&gt;This leads to wrong route optimization. Looking for help here. Please advise if we are missing something or having a wrong understanding.&lt;/p&gt;&#xA;" OwnerUserId="8873" LastEditorUserId="123" LastEditDate="2022-01-09T14:23:20.860" LastActivityDate="2022-01-09T14:23:20.860" Title="How to stop the vehicle from reaching the depot in between the trip" Tags="|vehicle-routing|or-tools|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7548" PostTypeId="2" ParentId="7547" CreationDate="2022-01-09T13:01:51.917" Score="1" Body="&lt;p&gt;I do not understand the question.&#xA;Each vehicle does only one trip from depot to depot.&#xA;And each node can only be visited once. So if a vehicle goes to the depot at one point in time, it cannot start another route after that.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2022-01-09T13:01:51.917" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7549" PostTypeId="2" ParentId="7546" CreationDate="2022-01-09T15:38:06.663" Score="2" Body="&lt;p&gt;There are several ways to do this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You already used &lt;code&gt;left_expr&lt;/code&gt; that modified the left-hand side. You can do the same thing with &lt;code&gt;right_expr&lt;/code&gt; to modify the RHS.&lt;/li&gt;&#xA;&lt;li&gt;Along the same line as above, &lt;code&gt;lhs&lt;/code&gt; and &lt;code&gt;rhs&lt;/code&gt; are the aliases for &lt;code&gt;left_expr&lt;/code&gt; and &lt;code&gt;right_expr&lt;/code&gt;, respectively. So, just simply add the new rhs to the constraints. So, for example, &lt;code&gt;ctKids.rhs = 350&lt;/code&gt; is another way.&lt;/li&gt;&#xA;&lt;li&gt;If you had a case that you didn't save the constraint and you want to alter that constraint's rhs, then you can first retrieve the constraint and then do either 1 or 2 above. So, in your example, that's the case for &lt;code&gt;mdl.add_constraint(nbbus40==nbbus30, 'samenumberofbuses')&lt;/code&gt; constraint (of course you could just simply save that, but I'm doing it for illustration here):&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;ct2 = mdl.get_constraint_by_name('samenumberofbuses')&#xA;ct2.rhs = nbbus30 + 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="36" LastActivityDate="2022-01-09T15:38:06.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7550" PostTypeId="1" CreationDate="2022-01-09T15:43:37.820" Score="1" ViewCount="82" Body="&lt;p&gt;Let us assume a single objective binary optimization problem, where you need to solve it 20,000 times (approx) in order to tune some coefficients. The objective function includes two components. The first component captures the immediate cost while the second component captures the future estimated cost. The latter component is built based on a basic function that includes some coefficients. Each time the problem is solved, the coefficient can change, which means that the main objective function is changing. Here, I need an algorithm capable of finding good quality solutions while being efficient in terms of CPU time (because I need to solve the problem several times, e.g., 20,000 times or even more).&lt;/p&gt;&#xA;&lt;p&gt;I was thinking that logic-based, population-based heuristics might be an option. However, I am not sure whether they can be capable of dealing with the variability of the objective function components. I was wondering whether you have any suggestions for such problems (pls assume that commercial solvers are not a good choice because of computational limitations).&lt;/p&gt;&#xA;&lt;p&gt;==============================================&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The problem includes one binary variable set (&lt;span class=&quot;math-container&quot;&gt;$z_{pbti}$&lt;/span&gt;), which may include 600,000 variables. The number of constraints can be also around 75,000. Below, you can find the constraint sets of the problem:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/IBfm6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IBfm6.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="5598" LastEditDate="2022-01-09T16:17:35.967" LastActivityDate="2022-01-09T16:17:35.967" Title="Optimization algorithms for problems with variable objective function" Tags="|optimization|heuristics|cpu|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7551" PostTypeId="2" ParentId="4636" CreationDate="2022-01-09T17:25:54.100" Score="2" Body="&lt;p&gt;As a partial answer, Equation 16 is a condition that leads to convergence. The replacement follows from maximization by a method that seems similar to LP rounding. I have not ran the numbers, but a factor of 3/2 seems plausible for that technique.&lt;/p&gt;&#xA;&lt;p&gt;I suppose convergence is chosen as a criterion because it doesn't know where to optimize to. I think it related to Lipschitz convergence. In practice, it is probably good to add a constant regularization term. Iterative convergence is often very fast, usually exponentially so. Basically, this method minimizes the convex hulls surrounding the solution, thereby simplifying the problem. Yes, when taken as rays, this method aligns the rays to the target.&lt;/p&gt;&#xA;&lt;p&gt;I am not aware of any relevant discriminant identities beyond the obvious one of Gaussian elimination.&lt;/p&gt;&#xA;" OwnerUserId="232" LastActivityDate="2022-01-09T17:25:54.100" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7552" PostTypeId="1" AcceptedAnswerId="7553" CreationDate="2022-01-10T00:26:50.067" Score="3" ViewCount="440" Body="&lt;p&gt;Assume a LP/MILP with a large number of variables.&lt;/p&gt;&#xA;&lt;p&gt;It is easy to formulate constraints to group variables such that each variable in a group takes the same value, if we know which variables are in a group. Consider another case, where we want to impose a constraint that in total 5 groups should be created without explicitly setting out which variable should in which group, so the solver determines the grouping. How can this constraint be formulated? (Grouping here just means that variables in a particular group takes same values)&lt;/p&gt;&#xA;" OwnerUserId="3896" LastEditorUserId="38" LastEditDate="2022-01-14T17:39:07.220" LastActivityDate="2022-01-14T17:39:07.220" Title="Constraint on groups of variables" Tags="|mixed-integer-programming|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7553" PostTypeId="2" ParentId="7552" CreationDate="2022-01-10T01:24:03.587" Score="8" Body="&lt;p&gt;For your first question, let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,g}$&lt;/span&gt; indicate whether variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is assigned to group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, and let variable &lt;span class=&quot;math-container&quot;&gt;$z_g$&lt;/span&gt; represent the common value of variables in group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;.  You want to enforce:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_g y_{i,g} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \tag1 \\&#xA;\sum_g y_{i,g} z_g &amp;amp;= x_i &amp;amp;&amp;amp;\text{for all $i$} \tag2  &#xA;\end{align}&lt;/span&gt;&#xA;You can linearize &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; via big-M constraints as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;L_{i,g}(1-y_{i,g}) \le x_i - z_g &amp;amp;\le U_{i,g}(1-y_{i,g}) &amp;amp;&amp;amp;\text{for all $i$ and $g$} \tag3&#xA;\end{align}&lt;/span&gt;&#xA;If your solver supports indicator constraints, you can replace &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; with:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{i,g} = 1 \implies x_i = z_g \tag4$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-01-10T01:24:03.587" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7554" PostTypeId="2" ParentId="7546" CreationDate="2022-01-10T07:35:52.963" Score="2" Body="&lt;p&gt;Also, besides the answer by @EhsanK, you can obtain the range of the parameters for sensitivity analysis as follows to know how much you should play around with those parameters:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;!pip install docplex&#xA;!pip install cplex&#xA;from docplex.mp.model import Model&#xA;from docplex.mp.relax_linear import LinearRelaxer&#xA;&#xA;mdl = Model(name='buses')  &#xA;nbbus40 = mdl.integer_var(name='nbBus40')  &#xA;nbbus30 = mdl.integer_var(name='nbBus30')  &#xA;ctKids=mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')   &#xA;mdl.minimize(nbbus40*500 + nbbus30*400)   &#xA;mdl.solve() &#xA;&#xA;lp = LinearRelaxer.make_relaxed_model(mdl)&#xA;m2 = lp.solve()&#xA;&#xA;cpx = lp.get_engine().get_cplex()&#xA;print(cpx.solution.sensitivity.lower_bounds())&#xA;print(cpx.solution.sensitivity.upper_bounds())&#xA;print(cpx.solution.sensitivity.bounds())&#xA;print(cpx.solution.sensitivity.objective())&#xA;print(cpx.solution.sensitivity.rhs())&#xA;&#xA;The results:&#xA;[(-1e+20, 7.5), (-1e+20, 10.0)]&#xA;[(7.5, 1e+20), (0.0, 1e+20)]&#xA;[(-1e+20, 7.5, 7.5, 1e+20), (-1e+20, 10.0, 0.0, 1e+20)]&#xA;[(0.0, 533.3333333333334), (375.0, 1e+20)]&#xA;[(0.0, 1e+20)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-01-10T07:35:52.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7559" PostTypeId="2" ParentId="7526" CreationDate="2022-01-10T10:14:41.673" Score="16" Body="&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since you updated your question might as well chip in, since I've worked with COIN-OR software a lot at the code level. In my experience, a lot of the open-source optimisation codebases (e.g. CBC) succeed in being amazing solvers, but fail in being great open-source projects. The heart of any successful open-source project (and by &amp;quot;successful&amp;quot; I mean one where many people decide to contribute) is the readability and design of its codebase, not the performance of the software per se. This is because readability and good design empower contributors to believe that they can improve things a lot, if they try long enough. What you want in an open-source project is a design where people can jump right in and start doing little things. If they need to spend months/years understanding what's happening before they can get their hands dirty, they will simply pass.&lt;/p&gt;&#xA;&lt;p&gt;From a solver developer's point of view, the foremost reason is because a lot of these projects use autotools instead of CMake as a build system. Although it might not seem like much, it is unfortunately a deal breaker. The reason is quite simple. If we take CBC as an example, it is basically one massive file of code with lots of dependencies. This is very hard to read, let alone improve, even for a person like myself who does this for a living. What I could do, if the project were built with CMake, would be to slowly refactor the code, split it into many files and classes and improve encapsulation, so that it becomes much easier to read, understand, maintain, and improve over time, not just for myself but for other people. Of course someone could argue that I could do the same thing with autotools, but the simple truth of the matter is that people just don't use autotools anymore. I would need to spend months doing that full-time, which is time I simply don't have. It would be trivial however to make tiny changes over time if the project would build with CMake.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, this would be my recommendation: migrate the projects to CMake so that many more developers are able to contribute to the open-source code bases.&lt;/p&gt;&#xA;&lt;p&gt;This is not pure conjecture btw. Even though CBC/CLP have been around for 20 years, HIGHS already has many more contributors despite being much younger. From a developer's point of view this makes perfect sense. The code is much more readable, and the project is built with CMake. This makes a massive difference. As another fun fact, building &amp;amp; linking CLP/CBC to our solver took a few weeks back in the day, especially since we also had to do it for Windows. Doing the same thing for HIGHS took 2 days - 1 days to link &amp;amp; build, and 1 day to test.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Original answer:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;As an MINLP solver developer I'd like to share my experience on just how we make our solvers faster and why that's hard to replicate in an open-source environment.&lt;/p&gt;&#xA;&lt;p&gt;Our day-to-day work revolves around meticulously running problems over and over again, analysing just what is happening, and thinking about how we can improve things:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We constantly find and eliminate code-level bottlenecks.&lt;/li&gt;&#xA;&lt;li&gt;We reason how to skip calculations that are not necessary. This is typically math-specific, i.e., if my problem has some particular structure, do I &lt;em&gt;really&lt;/em&gt; have to execute this piece of code?&lt;/li&gt;&#xA;&lt;li&gt;Once we've ran out of code-level improvements, we go back to the math and try to identify and exploit special structure. Elucidating special structure often requires spending significant time to code new features into the solver.&lt;/li&gt;&#xA;&lt;li&gt;Sometimes we find that our solver's architecture is limiting us, i.e., we actually can't code what we want at high performance because of certain design choices in the code. If we spot that enough times, we'll take the time (potentially many months) to rearchitect the entire code-base.&lt;/li&gt;&#xA;&lt;li&gt;We'll meticulously run benchmarks on thousands of problems and tweak tolerances, parameters, working limits, and all sorts of little things to squeeze out more performance for a handful of problems, without regressing in performance for the remaining 10,000 ones. Doing this over many years stacks, and performance is improved by many times.&lt;/li&gt;&#xA;&lt;li&gt;When nothing else works, we'll spend the time to figure out new algorithms, often for only a handful of problems.&lt;/li&gt;&#xA;&lt;li&gt;When we break certain performance milestones, e.g., when our solver is now 100 times faster than it was 2 years ago, we go back and re-examine whether the new performance opens up new algorithmic options that were impossible a few years ago. At this point, we rinse and repeat the entire process.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This is what it takes to make a solver performant. Patience, knowledge, and meticulous work that is often unrewarding for long periods of time, until we get it to work.&lt;/p&gt;&#xA;&lt;p&gt;There is a stark difference here between what we need to do and what ML developers need to do. In ML code, it's much more about an overall architecture that provides high throughput, and good APIs that provide users expressive freedom to create their algorithms. It is much less about manually running things and correlating performance to specific user input. This is why new ML frameworks keep popping up: once an ML framework is architected, the only way to &lt;em&gt;really&lt;/em&gt; improve it is to design a new one. At its core, this is a difference in culture. ML users are often comfortable tweaking/designing their own algorithms, whereas solver users expect it to just work out of the box.&lt;/p&gt;&#xA;&lt;p&gt;In light of the above, you might see how it's difficult for this process to happen in an open-source setting. Improving performance is not often not about doing something new and exciting. It's about taking a very long time to run the same thing over and over again until we figure out small tweaks that make that one problem 100 times faster without regressing in performance anywhere else. Even though I personally find that very satisfying, most people find it boring because they're not doing something &amp;quot;new&amp;quot;. More importantly, in an academic setting, the bulk of this work isn't really publication-worthy - people can't really write a paper about how they spent 100 hours to figure out that changing an internal tolerance from 1.e-5 to 3.45e-5 resulted in solving 5 extra problems in the test set. In case you are wondering why this is the case, unfortunately these little things are nearly always implementation specific, i.e., they work in our own solver because of how the different systems chaotically interact with each other, but they are not transferable to any other solver.&lt;/p&gt;&#xA;&lt;p&gt;Fun fact: just last week I figured out how to solve a problem I've been trying to solve for the last 2 years. During that time, I was working on that problem for a few minutes nearly every day, making tiny improvements once in a while. These improvements stacked, to the point where the very last improvement reduced the solving time from about 100 hours down to 700s on 8 cores. Even though I will admit to doing a little dance afterwards, I can't for the life of me tell you exactly why we can now solve this, as it's literally hundreds of little things over 2 years, let alone write a paper. This is very different from the ML community - if someone cracks an unsolved ML problem it will break the news the day after, simply because it's much more widely applicable. I do not consider that a bad thing, but you might see how ML would attract many more talented people, since the time/reward ratio is simply intrinsically better. This difference in the number of talented people working on the problem is, at the end of the day, one of the prime reasons for the differences we observe.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2022-01-12T11:08:08.213" LastActivityDate="2022-01-12T11:08:08.213" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7560" PostTypeId="2" ParentId="3259" CreationDate="2022-01-10T16:58:00.870" Score="3" Body="&lt;p&gt;You can check out the &lt;a href=&quot;https://github.com/minotaur-solver/minotaur&quot; rel=&quot;nofollow noreferrer&quot;&gt;MINOTAUR&lt;/a&gt; codebase, it's pretty well written and designed for people to create their own algorithms.&lt;/p&gt;&#xA;&lt;p&gt;Last time I checked (a few years ago), it wasn't very well documented, but the code itself is very readable and very well designed.&lt;/p&gt;&#xA;&lt;p&gt;The fastest way to get started is to check out their examples of how to create new algorithms (e.g. this &lt;a href=&quot;https://github.com/minotaur-solver/minotaur/blob/master/src/solvers/QG.cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;QG algorithm&lt;/a&gt;), and basically modify those files to suit your needs.&lt;/p&gt;&#xA;&lt;p&gt;The code itself is fairly high performant and already has plug-and-play interfaces to a bunch of things like IPOPT and CBC so you won't have to write them yourself. It also has an ASL interface.&lt;/p&gt;&#xA;&lt;p&gt;The reason I would recommend this over SCIP is the readability of the code - even though SCIP does come with a lot of documentation it's very hard to understand its codebase, and even harder to edit it.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2022-01-10T18:59:19.227" LastActivityDate="2022-01-10T18:59:19.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7561" PostTypeId="1" CreationDate="2022-01-11T01:24:46.087" Score="2" ViewCount="216" Body="&lt;p&gt;I'm trying to formulate a min cut algorithm&lt;/p&gt;&#xA;&lt;p&gt;There are two classes of patients: 1, 2, and the maximum number of patients that can be assigned to each bed per day is shown below as well.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{r|ccc}&#xA;\text { Patient } &amp;amp; \text { A } &amp;amp; \text { B } \\&#xA;\hline \text { 1 } &amp;amp; 5 &amp;amp; 0.8 \\&#xA;\hline \text { 2 } &amp;amp; 25 &amp;amp; 0.9  \\&#xA;\hline \text { 3 } &amp;amp; 13 &amp;amp; 11 \\&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="8867" LastEditorUserId="8867" LastEditDate="2022-01-17T22:24:31.613" LastActivityDate="2022-01-17T22:24:31.613" Title="Min cut network for patients" Tags="|linear-programming|network-flow|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7562" PostTypeId="2" ParentId="7561" CreationDate="2022-01-11T07:49:30.933" Score="0" Body="&lt;p&gt;A formulation for an &lt;a href=&quot;https://www.optaplanner.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner&lt;/a&gt; or &lt;a href=&quot;https://www.optapy.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPy&lt;/a&gt; model:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;enum PatientType {TYPE_1, TYPE_2, TYPE_3}&#xA;&#xA;class Day {&#xA;  int capacity;&#xA;  Map&amp;lt;PatientType, double&amp;gt; effectivenessMap;&#xA;}&#xA;&#xA;@PlanningEntity&#xA;class Patient {&#xA;    String name;&#xA;    PatientType type;&#xA;    @PlannningVariable Day day;&#xA;}&#xA;&#xA;// Don't plan more appointments than capacity&#xA;Constraint capacityConstraint(ConstraintFactory f) {&#xA;    return f.from(Patient.class)&#xA;        .groupBy(Patient::getDay, count())&#xA;        .filter((day, patientCount) -&amp;gt; patientCount &amp;gt; day.capacity)&#xA;        .penalize(&amp;quot;Capacity&amp;quot;, ONE_HARD,&#xA;             (day, patientCount) -&amp;gt; patientCount - day.capacity);&#xA;}&#xA;&#xA;// Don't go below 0.8 effectiveness for any patient&#xA;Constraint effectivenessLimitConstraint(ConstraintFactory f) {&#xA;    return f.from(Patient.class)&#xA;        .filter(patient -&amp;gt; patient.day.effectivenessMap.get(patient.type) &amp;lt; 0.8)&#xA;        .penalize(&amp;quot;Effectiveness limit&amp;quot;, ONE_HARD,&#xA;             patient -&amp;gt; new BigDecimal(0.8 - patient.day.effectivenessMap.get(patient.type)));&#xA;}&#xA;&#xA;// Maximize effectiveness for all patients&#xA;Constraint effectivenessRewardConstraint(ConstraintFactory f) {&#xA;    return f.from(Patient.class)&#xA;        .reward(&amp;quot;Effectiveness reward&amp;quot;, ONE_SOFT, patient -&amp;gt; {&#xA;             double effectiveness = patient.day.effectivenessMap.get(patient.type)&#xA;             return new BigDecimal(effectiveness);&#xA;    });&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="350" LastActivityDate="2022-01-11T07:49:30.933" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7563" PostTypeId="1" AcceptedAnswerId="7716" CreationDate="2022-01-11T22:11:15.210" Score="7" ViewCount="413" Body="&lt;p&gt;Optional interval is a great idea of optional interval/task that can be active or inactive based on boolean variable. I found it very useful in complex scheduling problems.&lt;/p&gt;&#xA;&lt;p&gt;It was introduced in IBM Cp Optimizer more than ten years ago. Unfortunatelly except constraint solver (not developed anymore) and cp-sat solver in or-tools optional interval is not supported by any other solver.&lt;/p&gt;&#xA;&lt;p&gt;Is there a reason why optional interval is not supported by other solvers (effort?) or exists alternative to optional intervals in other constraint solvers ?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Optional interval is defined by four variables: start, duration, end and active variable (boolean variable). In case &lt;code&gt;active=true&lt;/code&gt;, &lt;code&gt;start + duration = end&lt;/code&gt; should be satisfied and all constraints that work with the interval (like cumulative constraints) should respect it.&lt;/p&gt;&#xA;&lt;p&gt;I use optional intervals primarily to express alternatives. In case I need to choose between two or more workers for an operation, the sum of active variables equal to one guarantees that only one worker is used. Without optional intervals, I need to choose a worker for an operation too early and all other alternatives are lost during search phase until backtrack.&lt;/p&gt;&#xA;&lt;p&gt;Cumulative constraint to guarantee that a worker is not used more than once at same time doesn't work very well when assignments of a worker are unknown. Most time there's nothing to propagate since solver waits for mostly random assignments. My experience with a solver without optional intervals.&lt;/p&gt;&#xA;" OwnerUserId="4412" LastEditorUserId="981" LastEditDate="2023-12-22T14:56:26.287" LastActivityDate="2023-12-22T14:56:26.287" Title="Why most of constraint solvers do not support optional intervals?" Tags="|scheduling|constraint-programming|or-tools|cp-sat|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7564" PostTypeId="1" CreationDate="2022-01-12T02:41:21.977" Score="6" ViewCount="262" Body="&lt;p&gt;My daughter is a math major at a good liberal arts school. It doesn't seem like they have any OR courses or talk much about it as a career choice (either for a job or going to grad school in OR.)  And, some of her friends at other schools who've majored in things like Mechanical or Chemical engineering are also asking me about OR (and data science).&lt;/p&gt;&#xA;&lt;p&gt;(Full disclosure:  I did try with my daughter.  I'm guessing that now that she is away from home, it is now dawning on her all the things I talked about.)&lt;/p&gt;&#xA;&lt;p&gt;So, I'm going to pull material together. I'll share it publicly-- I think people with engineering, physics, and math degrees should all know about opportunities in OR and Data Science.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone have some good material, good websites, good blog posts, or other such material that I could refer to?  For example, Ed Rothberg recently posted a job on &lt;a href=&quot;https://www.forbes.com/sites/forbestechcouncil/2021/12/20/operations-research-analyst-the-fastest-growing-job-youve-never-heard-of/?sh=19c2cd2caaca&quot; rel=&quot;noreferrer&quot;&gt;OR being a hot job you've never heard of&lt;/a&gt;-- this could be part of the package.&lt;/p&gt;&#xA;" OwnerUserId="191" LastActivityDate="2022-02-21T17:08:25.483" Title="I'm looking for materials to share with undergrads who want to consider a career or masters degree in OR" Tags="|reference-request|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7565" PostTypeId="1" CreationDate="2022-01-12T05:54:33.460" Score="1" ViewCount="66" Body="&lt;p&gt;I am trying to solve a pick up and delivery problem with time window (variant of vehicle routing problem). Would anyone be able to direct me to some example problems with known solution or benchmark problems that you have used ?&lt;/p&gt;&#xA;" OwnerUserId="3288" LastActivityDate="2022-01-12T05:54:33.460" Title="Pick Up Delivery with Time Window example/ Benchmark Problem" Tags="|vehicle-routing|benchmark|" AnswerCount="0" CommentCount="2" ClosedDate="2022-01-14T02:42:18.620" ContentLicense="CC BY-SA 4.0" />
  <row Id="7566" PostTypeId="1" CreationDate="2022-01-12T08:23:07.167" Score="5" ViewCount="727" Body="&lt;p&gt;One can solve the linear programs using google &lt;em&gt;or-tools&lt;/em&gt; with &lt;em&gt;GLOP&lt;/em&gt; solver. I wonder if there is a way to print the sensitivity report (like &lt;em&gt;shadow prices&lt;/em&gt; etc.).&lt;/p&gt;&#xA;" OwnerUserId="8888" LastEditorUserId="500" LastEditDate="2022-12-18T22:40:07.847" LastActivityDate="2022-12-18T22:40:07.847" Title="Can I print the linear programming sensitivity analysis report using google or-tools?" Tags="|or-tools|sensitivity-analysis|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7567" PostTypeId="2" ParentId="7561" CreationDate="2022-01-12T09:24:05.340" Score="4" Body="&lt;p&gt;&lt;strong&gt;Assumption:&lt;/strong&gt; Treatment takes one day.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective:&lt;/strong&gt; We would like to maximize the total number of patients treated.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Sets:&lt;/strong&gt; Patient types are denoted with index &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt;, machines with &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt;, and days with &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Parameters:&lt;/strong&gt; Let &lt;span class=&quot;math-container&quot;&gt;$d_{it}$&lt;/span&gt; be the number of patients of type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to start treatment on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;; and &lt;span class=&quot;math-container&quot;&gt;$s_{jt}$&lt;/span&gt; denotes the number of available machines of type &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Each machine &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; has a maximum efficiency &lt;span class=&quot;math-container&quot;&gt;$e_{ij}$&lt;/span&gt; for patient type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Network flow:&lt;/strong&gt; The underlying network is given in the figure. Green nodes are source &lt;span class=&quot;math-container&quot;&gt;$(0)$&lt;/span&gt; and sink &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; respectively. Light blue nodes denote patient type and start days &lt;span class=&quot;math-container&quot;&gt;$(i,t)$&lt;/span&gt;. Dark blue nodes denote machine type and treatment days &lt;span class=&quot;math-container&quot;&gt;$(j,t')$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Light blue arcs are patient starts by type, so there is a capacity of &lt;span class=&quot;math-container&quot;&gt;$d_{it}$&lt;/span&gt; for an arc between source node &lt;span class=&quot;math-container&quot;&gt;$(0)$&lt;/span&gt; and light blue node &lt;span class=&quot;math-container&quot;&gt;$(i,t)$&lt;/span&gt;. Similarly, dark blue arcs indicate machine use, so there is a capacity of &lt;span class=&quot;math-container&quot;&gt;$s_{jt'}$&lt;/span&gt; between dark blue node &lt;span class=&quot;math-container&quot;&gt;$(j,t')$&lt;/span&gt; and sink node &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;. Red arcs don't have capacities. They exist only when &lt;span class=&quot;math-container&quot;&gt;$0 \leq t'-t \leq \left(10 e_{ij} - 8\right)^+$&lt;/span&gt; due to the minimum efficiency constraint. Finally, the green arc from sink &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; to source &lt;span class=&quot;math-container&quot;&gt;$(0)$&lt;/span&gt; is also uncapacitated. We maximize the flow through this green arc.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7cOqG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7cOqG.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note: For notation brevity I did not use &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;, but used the more general parameter &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;. Here, for instance, &lt;span class=&quot;math-container&quot;&gt;$d_{i,1} \equiv p_i$&lt;/span&gt;. I also defined the machine supply more generally. As it is a parameter, we can set &lt;span class=&quot;math-container&quot;&gt;$s_{it} = s_{i}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8752" LastActivityDate="2022-01-12T09:24:05.340" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7568" PostTypeId="2" ParentId="7563" CreationDate="2022-01-12T10:33:52.430" Score="5" Body="&lt;p&gt;I'm afraid that the answer is simply that not enough people use/request that feature from solver developers. The same is true in our company's case as well - in the 4 years since I started Octeract, no client has ever requested this feature.&lt;/p&gt;&#xA;&lt;p&gt;The secondary answer is that the feature is fairly meaningless unless the popular modelling frameworks support it as well, otherwise we can't get that information into the solver, and unfortunately many of them don't (probably for the same reason as above). In IBM's case it probably made more sense at the time since they also provided a modelling platform.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2022-01-12T10:33:52.430" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7569" PostTypeId="1" AcceptedAnswerId="7581" CreationDate="2022-01-12T13:49:48.103" Score="1" ViewCount="1806" Body="&lt;p&gt;I am new to modeling LP with Pulp in Python and I need some help with defining a constraint with multiple variables with different indexes. Please see below.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The constraint is defined on A, B, C indexes.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Start_Inv&lt;/code&gt; and &lt;code&gt;End_Inv&lt;/code&gt; variables are again defined on A, B, C indexes.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Production&lt;/code&gt; variable is defined on A, B, C, D indexes.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I want &lt;code&gt;Production&lt;/code&gt; variable to be summed by A, B, C and enter the constraint.&lt;/p&gt;&#xA;&lt;p&gt;Below is what I wrote and of course it doesn't work.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for A, B, C in Start_Inv_DF.index:&#xA;&#xA;    model += Start_Inv[(A, B, C)] + Production[(A, B, C, D)] == End_Inv[(A, B, C)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is there an easy way to model this? Probably, I need a coefficient to do &amp;quot;SUM &lt;code&gt;Production&lt;/code&gt; group by A, B, C&amp;quot;, can you please advise how to create one?&lt;/p&gt;&#xA;&lt;p&gt;Adding more details. 1/13/2022&lt;/p&gt;&#xA;&lt;p&gt;I have tried lpSUM and it works for two indexes but not for three or more. Can you please see what I am doing wrong?&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;This 2 indexes case works.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pandas as pd &#xA;import pulp as plp&#xA;&#xA;tuples1 = [('DE', 'Apple'),&#xA;          ('DE', 'Orange'),&#xA;          ('PA', 'Apple'),&#xA;          ('PA', 'Orange')]&#xA;&#xA;index1 = pd.MultiIndex.from_tuples(tuples1, names=[&amp;quot;Location&amp;quot;, &amp;quot;Product&amp;quot;])&#xA;DF1 = pd.DataFrame({'Count A': [12., 70., 30., 20.], 'Count B': [12., 70., 30., 20.]}, index=index1)&#xA;&#xA;Production1 = plp.LpVariable.dicts(&amp;quot;Production1&amp;quot;,&#xA;                              ((Location, Product) for Location, Product in DF1.index),&#xA;                              lowBound=0,&#xA;                              cat='Continuous')&#xA;&#xA;Products = ['Apple', 'Orange']&#xA;&#xA;for Location, Product in DF1.index:&#xA;    print(plp.lpSum(Production1[(Location, Product)] for Product in Products))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;This 3 indexes case errors out.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pandas as pd &#xA;import pulp as plp&#xA;&#xA;tuples1 = [('DE', 'Apple'),&#xA;          ('DE', 'Orange'),&#xA;          ('PA', 'Apple'),&#xA;          ('PA', 'Orange')]&#xA;&#xA;index1 = pd.MultiIndex.from_tuples(tuples1, names=[&amp;quot;Location&amp;quot;, &amp;quot;Product&amp;quot;])&#xA;DF1 = pd.DataFrame({'Count A': [12., 70., 30., 20.], 'Count B': [12., 70., 30., 20.]}, index=index1)&#xA;&#xA;tuples2 = [('DE', 'Apple', 'Truck'),&#xA;           ('DE', 'Orange', 'Rail'),&#xA;           ('DE', 'Apple', 'Rail'),&#xA;           ('DE', 'Orange', 'Truck'),&#xA;           ('PA', 'Apple', 'Truck'),&#xA;           ('PA', 'Orange', 'Rail')]&#xA;&#xA;index2 = pd.MultiIndex.from_tuples(tuples2, names=[&amp;quot;Location&amp;quot;, &amp;quot;Product&amp;quot;, &amp;quot;Mode&amp;quot;])&#xA;DF2 = pd.DataFrame({'Count A': [12., 70., 30., 20., 20., 40], 'Count B': [12., 70., 30., 20., 80., 30.]}, index=index2)&#xA;&#xA;Production2 = plp.LpVariable.dicts(&amp;quot;Production2&amp;quot;,&#xA;                              ((Location, Product, Mode) for Location, Product, Mode in DF2.index),&#xA;                              lowBound=0,&#xA;                              cat='Continuous')&#xA;&#xA;Modes = ['Truck', 'Rail']&#xA;&#xA;for Location, Product in DF1.index:&#xA;    print(plp.lpSum(Production2[(Location, Product, Mode)] for Mode in Modes))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8890" LastEditorUserId="36" LastEditDate="2022-01-13T14:41:22.710" LastActivityDate="2022-01-13T14:41:22.710" Title="Pulp Python - How to define a constraint with different indexes of variables" Tags="|linear-programming|python|pulp|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7570" PostTypeId="2" ParentId="7564" CreationDate="2022-01-12T19:11:50.720" Score="2" Body="&lt;p&gt;You might look at the following (largely INFORMS stuff).&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The archive of past winners of the &lt;a href=&quot;https://www.informs.org/Recognizing-Excellence/INFORMS-Prizes/Franz-Edelman-Award/Franz-Edelman-Award-Past-Winners&quot; rel=&quot;nofollow noreferrer&quot;&gt;Franz Edelman Award&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pubsonline.informs.org/magazine/orms-today&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR/MS Today&lt;/a&gt;, &lt;a href=&quot;https://www.informs.org/Publications/OR-MS-Tomorrow&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR/MS Tomorrow&lt;/a&gt; (the student-oriented analogy of OR/MS Today) and &lt;a href=&quot;https://pubsonline.informs.org/magazine/analytics&quot; rel=&quot;nofollow noreferrer&quot;&gt;Analytics Magazine&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Past winners of the INFORMS &amp;quot;&lt;a href=&quot;https://www.informs.org/Recognizing-Excellence/INFORMS-Prizes/Doing-Good-with-Good-OR-Student-Paper-Competition&quot; rel=&quot;nofollow noreferrer&quot;&gt;Doing Good with Good OR&lt;/a&gt;&amp;quot; competition. (Unfortunately, you have to drill down on each recipient to see what they did).&lt;/li&gt;&#xA;&lt;li&gt;The INFORMS &lt;a href=&quot;https://connect.informs.org/probonoanalytics/case-studies&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pro Bono Analytics&lt;/a&gt; case studies page and the analogous page for the &lt;a href=&quot;https://www.theorsociety.com/get-involved/pro-bono-or/case-studies/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pro Bono Operational Research&lt;/a&gt; program by the UK's OR Society.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The last two tend to be more analytics and general decision making than &amp;quot;hard&amp;quot; OR, but young people nowadays seem to have an appreciation for volunteering.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-12T19:11:50.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7571" PostTypeId="1" AcceptedAnswerId="7572" CreationDate="2022-01-12T19:24:25.997" Score="3" ViewCount="184" Body="&lt;p&gt;I'm trying to formulate the following logic:&lt;br /&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$y_i =1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$c_i \leq x_i$&lt;/span&gt;&lt;br /&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$y_i =0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$c_i \leq 0$&lt;/span&gt;&lt;br /&gt;&#xA;Where &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are decision variables.&lt;/p&gt;&#xA;&lt;p&gt;The easy way would be to write:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c_i \leq x_i y_i$$&lt;/span&gt;&#xA;But that is a quadratic formulation. I was wondering if there is a way to write the constraint as a linear one.&lt;/p&gt;&#xA;&lt;p&gt;Consider that &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_i \in \{0,1\}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8891" LastEditorUserId="491" LastEditDate="2022-01-13T14:28:19.767" LastActivityDate="2022-01-13T14:28:19.767" Title="If-then condition formulation to avoid variable multiplication" Tags="|mixed-integer-programming|modeling|constraint|indicator-constraints|reformulation-linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7572" PostTypeId="2" ParentId="7571" CreationDate="2022-01-12T19:42:00.820" Score="7" Body="&lt;p&gt;Something like: &lt;span class=&quot;math-container&quot;&gt;$$\begin{align} &amp;amp; c_i \le x_i + M(1-y_i)\\ &amp;amp; c_i \le My_i \end{align}$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; can be interpreted as an upperbound on &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;. If you don't like the big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;'s, consider using indicator constraints.&lt;/p&gt;&#xA;&lt;p&gt;See the comments below for some improvements on this!&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2022-01-12T21:51:40.867" LastActivityDate="2022-01-12T21:51:40.867" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7574" PostTypeId="1" AcceptedAnswerId="7575" CreationDate="2022-01-12T20:23:40.330" Score="5" ViewCount="859" Body="&lt;p&gt;I am solving a mixed-integer (binary) linear problem using CPLEX as a solver (branch-and-bound method). But I encountered the following issue. Each run I get a different solution at a different node of MILP. However, these solutions are very close to each other.&lt;/p&gt;&#xA;&lt;p&gt;According to my logic (please correct me if I'm wrong), the solver stops when the solution satisfies absolute\relative (or both?) gap tolerance, so basically, this gap could be satisfied at different nodes of the branch-and-bound algorithm.&lt;/p&gt;&#xA;&lt;p&gt;My question is: &lt;strong&gt;Which parameters&lt;/strong&gt; impact the final node where the algorithm ends? Are there any parameters that &lt;strong&gt;CPLEX chooses randomly&lt;/strong&gt; at the beginning of the algorithm (like branching variables for example or others) that I can &lt;strong&gt;fix&lt;/strong&gt; and end up on the &lt;strong&gt;same solution every run&lt;/strong&gt;?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GyMss.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GyMss.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7626" LastActivityDate="2022-01-12T21:54:02.070" Title="CPLEX gives different solutions of MILP every run" Tags="|mixed-integer-programming|cplex|pyomo|branch-and-bound|branch-and-cut|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7575" PostTypeId="2" ParentId="7574" CreationDate="2022-01-12T21:54:02.070" Score="12" Body="&lt;p&gt;There are a number of decisions CPLEX makes that can be affected by &amp;quot;randomness&amp;quot;. In some cases, CPLEX is actually using a random number generator to make decisions (such as breaking ties). In other cases, solutions can change when the order of entry of variables or constraints is changed, or when the model is read from a .lp file in one case and a .sav file in the other case, even though the model is theoretically the same. (This does not sound like your situation.) Finally, when CPLEX is running with parallel threads, the order that the computations get done is subject to the whim of the gods, since the operating system will interrupt threads to do operating systems sorts of things (background processes).&lt;/p&gt;&#xA;&lt;p&gt;You may be able to eliminate some or all of the first source of randomness by setting the RandomSeed parameter explicitly at the start of each run, although I'm not confident about that. The other parameter you can try is the &amp;quot;parallel&amp;quot; parameter (aka parallel mode switch), which you can try setting to deterministic. If that does not work, the only other suggestion I would have would be to use a single thread. That would eliminate the randomness induced by threads finishing before/after sibling threads, but it would presumably also slow the solver.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-12T21:54:02.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7576" PostTypeId="2" ParentId="7506" CreationDate="2022-01-12T23:22:42.253" Score="4" Body="&lt;p&gt;&lt;em&gt;&amp;quot;A counterexample to Hirsch Conjecture&amp;quot;&lt;/em&gt; by Francisco Santos.&lt;/p&gt;&#xA;&lt;p&gt;Warren Hirsch conjectured in 1957 that the graph of a &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;-dimensional polytope with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; facets cannot have diameter greater than &lt;span class=&quot;math-container&quot;&gt;$n−d$&lt;/span&gt;. That is, any two vertices of the polytope can be connected by a path of at most &lt;span class=&quot;math-container&quot;&gt;$n−d$&lt;/span&gt; edges. Conjecture could have strong implications, as the diameter of a polytope is a lower bound on the number of steps needed by the simplex method, whereas the upper bound was set to be exponential in the size of the problem using the Klee-Minty cubes demonstrated by Victor Klee and George Minty in 1973.&lt;/p&gt;&#xA;&lt;p&gt;Link to paper: &lt;a href=&quot;https://annals.math.princeton.edu/2012/176-1/p07&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://annals.math.princeton.edu/2012/176-1/p07&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8752" LastActivityDate="2022-01-12T23:22:42.253" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7577" PostTypeId="1" AcceptedAnswerId="7579" CreationDate="2022-01-13T11:35:14.213" Score="9" ViewCount="185" Body="&lt;p&gt;I have a clustering problem with &lt;span class=&quot;math-container&quot;&gt;$\{0,1\}$&lt;/span&gt; distances between a set of nodes, which can be stated as follows:&lt;/p&gt;&#xA;&lt;p&gt;Given: Finite set &lt;span class=&quot;math-container&quot;&gt;$\mathbb{X}$&lt;/span&gt;, a distance &lt;span class=&quot;math-container&quot;&gt;$d(x, y) \in \{0,1\}$&lt;/span&gt; for each pair &lt;span class=&quot;math-container&quot;&gt;$(x, y) \in \mathbb{X}$&lt;/span&gt;, and positive integers &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;QUESTION: Is there a partition of &lt;span class=&quot;math-container&quot;&gt;$\mathbb{X}$&lt;/span&gt; into disjoint sets &lt;span class=&quot;math-container&quot;&gt;$\mathbb{X}_1, \mathbb{X}_2, \dots, \mathbb{X}_S$&lt;/span&gt;  to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{s=1}^S \sum_{x,y \in \mathbb{X}_s} d(x,y)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$|\mathbb{X}_s| \leq H$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Is there a specific name for such a clustering problem so that I can find the complexity proof of it?&lt;/p&gt;&#xA;" OwnerUserId="3480" LastEditorUserId="500" LastEditDate="2022-01-13T16:00:30.447" LastActivityDate="2022-01-13T16:00:30.447" Title="A clustering problem with 0 or 1 distances for minimizing the summation of distances" Tags="|computational-complexity|clustering|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7578" PostTypeId="1" CreationDate="2022-01-13T12:55:49.423" Score="3" ViewCount="115" Body="&lt;p&gt;I recently asked &lt;a href=&quot;https://or.stackexchange.com/questions/7561/max-flow-network-for-hospital-patients&quot;&gt;this&lt;/a&gt; question about formulating a max flow diagram for hospital patients. I am now considering a secondary objective which is to maximize the effetiveness of the scheduled treatment. I know that if a single-objective minimum cost network flow IPs has integral parameters, then its LP relaxations has the integrality property.&lt;/p&gt;&#xA;&lt;p&gt;Would dichotomic search for biobjective LP relaxation guarantee finding a subset of the IP's nondominated frontier? Would it guarantee finding the entire nondominated frontier?&lt;/p&gt;&#xA;&lt;p&gt;Note: I do realize there are other ways to solve this, but I am specifically looking to answer these two questions, if anyone can help here.&lt;/p&gt;&#xA;" OwnerUserId="8867" LastEditorUserId="8867" LastEditDate="2022-01-14T00:58:46.653" LastActivityDate="2022-01-14T00:58:46.653" Title="Dichotomic search for biobjective linear program, max flow problem for hospital patients" Tags="|linear-programming|integer-programming|scheduling|maxflow|medical-application|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7579" PostTypeId="2" ParentId="7577" CreationDate="2022-01-13T13:39:31.943" Score="8" Body="&lt;p&gt;This is a variant of the &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Minimum_k-cut&quot; rel=&quot;noreferrer&quot;&gt;minimum &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-cut&lt;/a&gt; problem. The node set is &lt;span class=&quot;math-container&quot;&gt;$\mathbb{X}$&lt;/span&gt;, the edge weights are &lt;span class=&quot;math-container&quot;&gt;$1-d(x,y)$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$k=S$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Also related to the &lt;em&gt;wedding planner problem&lt;/em&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathbb{X}$&lt;/span&gt; is the set of guests, &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is the number of tables, and &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; is the maximum number of guests per table.  Here, &lt;span class=&quot;math-container&quot;&gt;$d(x,y)$&lt;/span&gt; measures whether &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; dislike each other.  See &lt;a href=&quot;https://blogs.sas.com/content/operations/2014/11/10/do-you-have-an-uncle-louie-optimal-wedding-seat-assignments/&quot; rel=&quot;noreferrer&quot;&gt;https://blogs.sas.com/content/operations/2014/11/10/do-you-have-an-uncle-louie-optimal-wedding-seat-assignments/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-01-13T13:59:14.477" LastActivityDate="2022-01-13T13:59:14.477" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7580" PostTypeId="2" ParentId="7578" CreationDate="2022-01-13T14:11:47.633" Score="1" Body="&lt;p&gt;The first thing that comes to mind, is, to try to model the process in something like (timed?) colored Petri nets. Then, perhaps do some process mining and network partitioning and shortest path tree computations. As long as the search converges to a local minimum, it would be locally non-dominated. So, if you add a dimension for every position in the space, it would be globally non-dominated. For finding the entire frontier, we simply solve the problem in a projected surface space. You should probably think of some separate quality statistic and search heuristic for the entire non-dominated solution space as well.&lt;/p&gt;&#xA;&lt;p&gt;Also, consider using one of the well-known process mining and modeling packages. Those should be able to do most of the things I've mentioned out of the box, and many more.&lt;/p&gt;&#xA;" OwnerUserId="232" LastActivityDate="2022-01-13T14:11:47.633" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7581" PostTypeId="2" ParentId="7569" CreationDate="2022-01-13T14:39:43.230" Score="1" Body="&lt;p&gt;I assume when you say &amp;quot;it doesn't work&amp;quot; you're getting a &lt;code&gt;KeyError&lt;/code&gt; which is expected in your 3-index model. Because you have 2 locations, 2 products, and 2 modes. Your 2-index tuple with product and location has all 4 indexes, but your 3-index tuple has 6, missing ('PA', 'Apple', 'Rail') and ('PA, 'Orange', 'Truck').&lt;/p&gt;&#xA;&lt;p&gt;If this was a mistake, correct your 3-index tuple and your &lt;code&gt;KeyError&lt;/code&gt; will be fixed. If not a mistake, then one way to fix this is to change your last line of code to the following, which checks if the key exists in &lt;code&gt;Production2&lt;/code&gt; and if it's not, replaces it with 0:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;print(plp.lpSum(Production2.get((Location, Product, Mode), 0) for Mode in Modes))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="36" LastActivityDate="2022-01-13T14:39:43.230" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7582" PostTypeId="2" ParentId="7516" CreationDate="2022-01-13T15:21:59.680" Score="2" Body="&lt;p&gt;You could try Qarnot's cloud platform:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can create an account for free &lt;a href=&quot;https://account.qarnot.com/compute&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; (no banking information required) and get several hours of free computing time. Maybe it will cover your needs? Then prices range from 0.14€/h to 0.61€/h depending on the number of cores and RAM used.&lt;/li&gt;&#xA;&lt;li&gt;You can run many open-source softwares by providing appropriate docker images. Most of open-source softwares have official docker images on &lt;a href=&quot;https://hub.docker.com/search?type=image&quot; rel=&quot;nofollow noreferrer&quot;&gt;DockerHub&lt;/a&gt; but you can also create custom ones.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://blog.qarnot.com/or-tools-on-qarnot-cloud-documentation/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is a tutorial example of how to run a simple or-tools computation on Qarnot's cloud platform.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;&lt;p&gt;NB: I work for Qarnot Computing.&lt;/p&gt;&#xA;" OwnerUserId="8894" LastActivityDate="2022-01-13T15:21:59.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7583" PostTypeId="1" CreationDate="2022-01-13T21:37:11.573" Score="7" ViewCount="741" Body="&lt;p&gt;I want to find a parallel computing method for general nonlinear convex optimization problems with constraints.&lt;/p&gt;&#xA;&lt;p&gt;A parallel method that can solve a bundle of nonlinear convex problems simultaneously, where each convex optimization problem is unrelated to each other.&lt;/p&gt;&#xA;&lt;p&gt;I am familiar with many convex solvers, like Matlab, Gurobi, Cvxpy. I don't believe none of them can solve many convex problems in a parallel manner.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there such a parallel approach to the study of convex optimization?&lt;/li&gt;&#xA;&lt;li&gt;What is the state-of-the-art of this research?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4639" LastEditorUserId="1228" LastEditDate="2022-01-14T11:07:40.590" LastActivityDate="2022-01-14T12:05:55.970" Title="Are there any parallel methods for solving multiple general nonlinear convex optimization problems?" Tags="|solver|convex-optimization|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7585" PostTypeId="2" ParentId="7583" CreationDate="2022-01-14T05:17:27.657" Score="2" Body="&lt;p&gt;I would recommend using Gravity (&lt;a href=&quot;https://github.com/coin-or/Gravity&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/coin-or/Gravity&lt;/a&gt; ) with Ipopt and just calling solve_parallel().&lt;/p&gt;&#xA;" OwnerUserId="8899" LastActivityDate="2022-01-14T05:17:27.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7586" PostTypeId="2" ParentId="7583" CreationDate="2022-01-14T06:09:54.100" Score="7" Body="&lt;p&gt;Almost all convex optimization problems can be formulated as a conic optimization problem using only the cone types we can handle in practice. See the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;noreferrer&quot;&gt;Mosek modeling cookbook&lt;/a&gt; for details. This often leads to the best solution time and you do not have to mess with derivatives. For instance &lt;a href=&quot;https://moosek.com&quot; rel=&quot;noreferrer&quot;&gt;Mosek&lt;/a&gt; can solve such conic optimization problems.&lt;/p&gt;&#xA;&lt;p&gt;The upcoming Mosek version 10 (to be released spring 2022) will have a command called&lt;/p&gt;&#xA;&lt;p&gt;optimizebatch&lt;/p&gt;&#xA;&lt;p&gt;that will take an array of optimization problems. Those optimization problems will be solved in parallel using a pool of threads. Moreover, the thread pool can also be used to parallelize the solution of each problem. This implies a good load balancing (=efficient usage of the threads) even if the optimization problems are of vastly different size.&lt;/p&gt;&#xA;&lt;p&gt;It is not that hard to solve multiple optimization problems in parallel as suggested in another reply. However, you easy use too many threads if you try to solve each optimization problem in parallel too. This will most likely lead to a performance degradation.&lt;/p&gt;&#xA;&lt;p&gt;PS. I work for Mosek but does a lot of our paralleization.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2022-01-14T08:31:58.803" LastActivityDate="2022-01-14T08:31:58.803" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7587" PostTypeId="2" ParentId="7583" CreationDate="2022-01-14T08:09:00.587" Score="4" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;solve a bundle of nonlinear convex problems simultaneously, where each&#xA;convex optimization problem is &lt;strong&gt;unrelated to each other&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If you are using Linux this will do exactly what you want:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;#!/bin/bash&#xA;&#xA;max_jobs=8&#xA;problems=$(ls problems_folder)&#xA;    &#xA;for problem in &lt;span class=&quot;math-container&quot;&gt;$problems&#xA;do&#xA;    ipopt $&lt;/span&gt;problem &amp;amp;&#xA;    if [[ &lt;span class=&quot;math-container&quot;&gt;$(jobs -r -p | wc -l) -ge $&lt;/span&gt;max_jobs ]]; then&#xA;        wait -n; &#xA;    fi&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;code&gt;&amp;amp;&lt;/code&gt; will run the command as a background process, so the Linux kernel will take care of the parallel runs. I also added a work limit (&lt;code&gt;max_jobs&lt;/code&gt;) to avoid oversaturating your CPU. This is by far the simplest way to do this in Linux, but you can write similar scripts in most languages (e.g. Python).&lt;/p&gt;&#xA;&lt;p&gt;You can substitute ipopt in the command for any solver you want.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2022-01-14T12:05:55.970" LastActivityDate="2022-01-14T12:05:55.970" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7588" PostTypeId="1" AcceptedAnswerId="7589" CreationDate="2022-01-14T13:15:05.577" Score="7" ViewCount="560" Body="&lt;p&gt;I am working through Pascal Van Hentenryck's excellent discrete optimization course on Coursera.&lt;/p&gt;&#xA;&lt;p&gt;While the course certainly touches on it in some ways, I am looking for more of a framework in terms of what kinds of solutions are likely to work well where?  For example, when would I use local search vs a mixed integer program?  If I am using local search, when would I use tabu search rather than simulated annealing?&lt;/p&gt;&#xA;" OwnerUserId="8901" LastEditorUserId="2556" LastEditDate="2022-01-14T13:38:29.523" LastActivityDate="2022-01-14T18:35:00.333" Title="Optimization Solution Framework" Tags="|optimization|algorithms|computational-complexity|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7589" PostTypeId="2" ParentId="7588" CreationDate="2022-01-14T13:29:15.783" Score="9" Body="&lt;p&gt;You have to keep in mind that MIPs can return the optimal solution, provided enough computation time is given. So if time is not an issue, I would always go for a MIP. Also, MIPs are more flexible in the sense that you can very easily add new constraints, modify the objective function, etc.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, with metaheuristics such as local search, there is no guarantee that you will reach optimality, and you might spend a lot of time designing your algorithm which may not work anymore if you need to add a new constraint. That said, they are a great alternative if computation time is an issue. And in practice, computation times are easily an issue if you are working on large data sets.&lt;/p&gt;&#xA;&lt;p&gt;The choice of the metaheuristic is, I think, a matter of taste (and trend) more than anything. I was told as a student years ago that simulated annealing is no longer considered as an efficient local search technique, and yet it is still used here and there. Perhaps a good way of choosing your algorithm is to find papers where the authors show that their technique worked on the considered type of problem. For example, there are many papers such as &lt;a href=&quot;https://link.springer.com/article/10.1007%2FBF02239976&quot; rel=&quot;noreferrer&quot;&gt;this one&lt;/a&gt; showing excellent results with Tabu Search for graph coloring.&lt;/p&gt;&#xA;&lt;p&gt;Regarding trend, there is a famous article called &lt;a href=&quot;https://www.jstor.org/stable/3010428&quot; rel=&quot;noreferrer&quot;&gt;Ants can color graphs&lt;/a&gt; from 1997. The article is fascinating, the authors show how you can implement efficient algorithms with artificial ants. But I am pretty sure that if you asked the authors what they think of their article today, they would agree that it was a lot of fun, but they would not use this technique anymore. At the time, using ants was trendy!&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-01-14T13:34:48.993" LastActivityDate="2022-01-14T13:34:48.993" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7590" PostTypeId="2" ParentId="7526" CreationDate="2022-01-14T17:25:35.467" Score="3" Body="&lt;p&gt;It seems to me like there are three worlds in OR:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;users of commercial MIP/LP solvers like Cplex or Gurobi&lt;/li&gt;&#xA;&lt;li&gt;users of free / open-source MIP/LP solvers&lt;/li&gt;&#xA;&lt;li&gt;users of other type of solvers - constraint solvers, sat solvers ...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I'm in third group since I focus on constraint solvers, and help choco solver and or-tools solvers to be better. Without source codes it would be much harder, solvers can be without my bit of contribution little bit worse and performance of my optimization problems much worse.&lt;/p&gt;&#xA;&lt;p&gt;Of course I'd like to not ignore MIP/LP solvers but it's hard to give a reason to pay high price of commercial solver only for experiments or small part of a solution.&lt;/p&gt;&#xA;&lt;p&gt;From performance view, so far fantastic support of solvers that I use (choco solver, or-tools) and access to source codes allows me to be competitive with solutions that use commercial solvers.&lt;/p&gt;&#xA;&lt;p&gt;For MIP/LP there should be some competitive alternative to commercial solvers that should be later preferred in academic world. It seems that a lot of knowledge is in IBM, Gurobi or Mosek and only way to have access to it is to be their employee. Without competitive open-source MIP/LP solver, other type of solvers can be in long run first choice and even gurobi (or cplex) ignored.&lt;/p&gt;&#xA;" OwnerUserId="4412" LastActivityDate="2022-01-14T17:25:35.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7591" PostTypeId="2" ParentId="7588" CreationDate="2022-01-14T18:35:00.333" Score="10" Body="&lt;p&gt;Here are my notes about the various discrete optimization methods.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Combinatorial branch-and-bound&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Manual implementation&lt;/li&gt;&#xA;&lt;li&gt;Provides a bound&lt;/li&gt;&#xA;&lt;li&gt;Works well when the bound is good&lt;/li&gt;&#xA;&lt;li&gt;Rarely used nowadays&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Mixed-Integer (Non)-Linear Programming&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Model-and-run, very good commercial solvers&lt;/li&gt;&#xA;&lt;li&gt;Provides a bound&lt;/li&gt;&#xA;&lt;li&gt;Works well when the (N)LP relaxation (possibly with cuts) is good (i.e. not too many big-M constraints)&lt;/li&gt;&#xA;&lt;li&gt;Handles continuous variables&lt;/li&gt;&#xA;&lt;li&gt;It might be difficult to express some components of the problem with only (non)-linear equations (e.g. scheduling constraints)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Constraint Programming&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Model-and-run, but might require manual tweaks&lt;/li&gt;&#xA;&lt;li&gt;More expressive modelling language, it might be easier to model some complex constraints&lt;/li&gt;&#xA;&lt;li&gt;On the other hand, it's easy to get lost in all the available constraints&lt;/li&gt;&#xA;&lt;li&gt;Doesn't provide a bound during the search, but proves the optimality at the end&lt;/li&gt;&#xA;&lt;li&gt;Works well on problems with many constraints&lt;/li&gt;&#xA;&lt;li&gt;Robust to the addition of constraints&lt;/li&gt;&#xA;&lt;li&gt;Not robust to changes in the objective&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Local search&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Model-and-run with LocalSolver, otherwise manual implementation&lt;/li&gt;&#xA;&lt;li&gt;Heuristic approach&lt;/li&gt;&#xA;&lt;li&gt;Works well on large problems without too many constraints&lt;/li&gt;&#xA;&lt;li&gt;Robust to changes in the objective&lt;/li&gt;&#xA;&lt;li&gt;Not robust to the addition of constraints&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Tree search&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Manual implementation&lt;/li&gt;&#xA;&lt;li&gt;Proves the optimality on small instances&lt;/li&gt;&#xA;&lt;li&gt;Works well on problems with many constraints, good dominances, and when it is simple enough to assess the quality of a partial solution&lt;/li&gt;&#xA;&lt;li&gt;Doesn't work well if a bad decision can be taken early without noticing it&lt;/li&gt;&#xA;&lt;li&gt;Robust to the addition of constraints&lt;/li&gt;&#xA;&lt;li&gt;Not robust to changes in the objective&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Large neighborhood search&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Already implemented inside some CP/MILP/MINLP solvers, otherwise manual implementation&lt;/li&gt;&#xA;&lt;li&gt;Heuristic approach&lt;/li&gt;&#xA;&lt;li&gt;Works well on large problems with many constraints&lt;/li&gt;&#xA;&lt;li&gt;Handles continuous variables if the constructive component does&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Note 1: if you work in academia, your criteria will certainly be &amp;quot;solution quality&amp;quot; and &amp;quot;computation time&amp;quot;. If you work in industry, you also need to consider development time, maintainability and flexibility.&lt;/p&gt;&#xA;&lt;p&gt;Note 2: simulated annealing, tabu search, guided local search, iterated local search.. are all variants of local search. You should be able to get good results with any of them if local search works well for your problem. If you don't have more intuition, pick the one you're the most comfortable with. I just wouldn't recommend simulated annealing since it's the hardest one to calibrate and I don't know any problem on which it's state-of-the-art&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-01-14T18:35:00.333" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7592" PostTypeId="2" ParentId="3883" CreationDate="2022-01-15T02:34:43.953" Score="1" Body="&lt;p&gt;There are a lot of good answers above if you are willing to develop your own model and visualisations.&lt;br /&gt;&#xA;There’s also an app that I’d recommend: &lt;a href=&quot;https://www.modelandoptimize.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.modelandoptimize.com&lt;/a&gt;&lt;br /&gt;&#xA;It has a simple interface and I think your use case can be represented by their Job Scheduling demo.&lt;br /&gt;&#xA;They provide the solution in excel if you like.&lt;/p&gt;&#xA;" OwnerUserId="8900" LastActivityDate="2022-01-15T02:34:43.953" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7593" PostTypeId="1" AcceptedAnswerId="7603" CreationDate="2022-01-16T19:27:57.987" Score="3" ViewCount="152" Body="&lt;p&gt;If we consider the dynamic lot sizing problem with:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; as the demand per period &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and denote &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^t d_i$&lt;/span&gt; being the total demand up to period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; can take values &lt;span class=&quot;math-container&quot;&gt;$1, \dots, T$&lt;/span&gt; in a &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;-period problem.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; is the amount ordered in period &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and denote &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^t z_i$&lt;/span&gt; being the total amount ordered up to period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, where also &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; can take values &lt;span class=&quot;math-container&quot;&gt;$1, \dots, T$&lt;/span&gt; in a &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;-period problem.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\delta_t$&lt;/span&gt; is a boolean variable that indicates whether or not an order is placed in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;And then consider to have two constraints, which can be read as:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The total supply must be at least as large as the total demand through the end of each period.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The amount purchased in a period cannot exceed the total demand in that and future periods in the planning horizon.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;One way to write out these constraints is:&lt;/p&gt;&#xA;&lt;p&gt;(1.1)&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^t z_i \ge \sum_{i=1}^t d_i,$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$t=1, \dots , T, $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(1.2)&lt;span class=&quot;math-container&quot;&gt;$$ z_t \le \delta_t \sum_{i=t}^T d_i,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$t= 1, \dots, T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But for example in the paper of Wagelmans, Hoesel and Kolen where they present their eponymous algorithm, they introduce the variable &lt;span class=&quot;math-container&quot;&gt;$z_{ti}$&lt;/span&gt;, which is said to be the amount of period &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;'s demand that is produced in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=t}^T z_{ti} = z_t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And then they rewrite the former two constraints as:&lt;/p&gt;&#xA;&lt;p&gt;(2.1) &lt;span class=&quot;math-container&quot;&gt;$$\sum_{t=1}^i z_{ti} = d_i$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$i=1, \dots, T,$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(2.2) &lt;span class=&quot;math-container&quot;&gt;$$d_i\delta_t \ge z_{ti},$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$i=t, \dots, T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t=1,\dots,T.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But (1.2) and (2.2) seem to be NOT the same. Can anyone explain why the constraint equations (1.1) and (1.2) are identical to (2.1) and (2.2) ?&lt;/p&gt;&#xA;&lt;p&gt;For those interested in the paper of WHK: &lt;a href=&quot;https://www.researchgate.net/publication/46431739_Economic_Lot_Sizing_An_On_log_n_Algorithm_That_Runs_in_Linear_Time_in_the_Wagner-Whitin_Case&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.researchgate.net/publication/46431739_Economic_Lot_Sizing_An_On_log_n_Algorithm_That_Runs_in_Linear_Time_in_the_Wagner-Whitin_Case&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I use the notations of: &lt;a href=&quot;http://eprints.stiperdharmawacana.ac.id/16/1/%5BJohn_A._Muckstadt,_Amar_Sapra%5D_Principles_of_Inve(BookFi).pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://eprints.stiperdharmawacana.ac.id/16/1/%5BJohn_A._Muckstadt,_Amar_Sapra%5D_Principles_of_Inve(BookFi).pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2022-01-17T16:23:28.400" LastActivityDate="2022-01-17T21:42:22.323" Title="Why are these constraint equations equal?" Tags="|dynamic-programming|production-planning|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="7596" PostTypeId="1" AcceptedAnswerId="7597" CreationDate="2022-01-17T10:21:55.400" Score="9" ViewCount="284" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\delta_1, \delta_2, ..., \delta_k, W$&lt;/span&gt;  are binary variables and the constraint &lt;span class=&quot;math-container&quot;&gt;$δ_1 + δ_2 + \ldots + δ_k ≤ W$&lt;/span&gt; holds.&lt;/p&gt;&#xA;&lt;p&gt;Is it better to write &lt;span class=&quot;math-container&quot;&gt;$$\delta_1 + \delta_2 + \ldots +\delta_k \leq W$$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;\begin{gathered}&#xA;\delta_1 \leq W \\&#xA;\delta_2 \leq W \\&#xA;...\\&#xA;\delta_k \leq W \\ &#xA;\end{gathered}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and why?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2022-01-17T16:56:12.220" LastActivityDate="2022-01-17T16:56:12.220" Title="Modelling stronger binary expression" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7597" PostTypeId="2" ParentId="7596" CreationDate="2022-01-17T10:47:53.963" Score="9" Body="&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is a binary variable, it follows that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_k \delta_k \le W \le 1&#xA;$$&lt;/span&gt;&#xA;And so you are in the presence of a clique constraint.&lt;/p&gt;&#xA;&lt;p&gt;@RobPratt &lt;a href=&quot;https://or.stackexchange.com/questions/6187/how-can-i-strengthen-a-family-of-constraints-in-the-presence-of-a-clique-constra&quot;&gt;shows&lt;/a&gt; how to strengthen the second group of constraints in this case, yielding the first constraint.&lt;/p&gt;&#xA;&lt;p&gt;A simple example : take &lt;span class=&quot;math-container&quot;&gt;$\delta_k = 0.9$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. It is easy to see that such a solution is valid with the second group, but not with the first one. So the first one leads to a tighter relaxation.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-01-17T10:55:24.637" LastActivityDate="2022-01-17T10:55:24.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7598" PostTypeId="1" AcceptedAnswerId="7678" CreationDate="2022-01-17T11:54:18.980" Score="2" ViewCount="541" Body="&lt;p&gt;As the title suggests, I am working on a problem that pertains to single-vehicle routing, where certain vertices in &lt;code&gt;V&lt;/code&gt; are not mandatory to be visited, but are useful for refueling the vehicle. The other vertices must be visited exactly once.&lt;/p&gt;&#xA;&lt;p&gt;For this I am using the OR-Tools GLOP Linear Solver (Python), wherein I have modeled the entire problem as a matrix of binary variables &lt;code&gt;Xij&lt;/code&gt; over all &lt;code&gt;i&lt;/code&gt; and over all &lt;code&gt;j&lt;/code&gt; belonging to &lt;code&gt;V&lt;/code&gt;. &lt;code&gt;Xij = 1&lt;/code&gt; if vehicle goes from vertex &lt;code&gt;i&lt;/code&gt; to &lt;code&gt;j&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h1&gt;Create X matrix&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;# G is an adjacency matrix&#xA;    for i in range(len(G)):&#xA;        temp=[]&#xA;        for j in range(len(G[i])):&#xA;            temp.append(solver.BoolVar(str(i)+','+str(j)))&#xA;        X.append(temp)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Objective Function&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;# The objective function states that the cost of the entire travel should be minimum&#xA;    # I think summation of X[i][j]*G[i][j] over all i and all j should be minimum&#xA;    objective=solver.Objective()&#xA;    for i in range(len(G)):&#xA;        for j in range(len(G[i])):&#xA;            objective.SetCoefficient(X[i][j], G[i][j]) # multipling the path variable with corresponding weight&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How do I model the refueling aspect of the problem? That the vehicle is refueled at certain vertices? The MILP that I am trying to solve for utilises variables like 'amount of fuel left at a vertex' etc to find the optimal route. How do I introduce these variables into the code? Am I using the wrong tool for the job?&lt;/p&gt;&#xA;" OwnerUserId="8918" LastEditorUserId="491" LastEditDate="2022-01-17T14:53:15.240" LastActivityDate="2022-01-28T21:41:03.307" Title="Modeling Refueling in Vehicle Routing Problem in OR-Tools" Tags="|vehicle-routing|or-tools|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7599" PostTypeId="2" ParentId="7598" CreationDate="2022-01-17T13:09:22.493" Score="2" Body="&lt;p&gt;Welcome to ORSE. You may have to use &lt;a href=&quot;https://developers.google.com/optimization/mip&quot; rel=&quot;nofollow noreferrer&quot;&gt;Integer optimization&lt;/a&gt; framework for such binary/integer model and also you can also explore or-tool's &lt;a href=&quot;https://developers.google.com/optimization/routing/vrp&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vehicle routing&lt;/a&gt; example that can fit your use-case with minor changes.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2022-01-17T13:09:22.493" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7600" PostTypeId="1" AcceptedAnswerId="7602" CreationDate="2022-01-17T14:17:31.160" Score="5" ViewCount="176" Body="&lt;p&gt;We have two decision variables&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; 0&amp;lt;x\le X,\\&#xA;&amp;amp; 0&amp;lt;y\le Y,&#xA;\end{align}&lt;/span&gt;&#xA;where both &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; are two sensible upper bounds on our decision variables.&lt;/p&gt;&#xA;&lt;p&gt;We also have a constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y=\frac{x^2}{1-x}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We discretize the interval &lt;span class=&quot;math-container&quot;&gt;$(0,X]$&lt;/span&gt; and denote each piece by &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is a finite number.&lt;/p&gt;&#xA;&lt;p&gt;By defining a binary decision variable say &lt;span class=&quot;math-container&quot;&gt;$z_i\in\{0,1\}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$z_i=1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$x\in(r_{i},r_{i+1}]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_i=0$&lt;/span&gt;, otherwise, we linearize this constraint as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y=\sum_{i=1}^{n}\left(\frac{r_i^2}{1-r_i}\right)z_i.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now the question is how to determine &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;I am also aware that there are other techniques of linearization we would like to focus on this method for the moment.&lt;/p&gt;&#xA;&lt;p&gt;I'm also sure this method has been used before but I could not find any reference on it, mainly because I don't know if it has a name or where to even look!&lt;/p&gt;&#xA;&lt;p&gt;Could someone help please?&lt;/p&gt;&#xA;" OwnerDisplayName="user9659" LastEditorUserId="123" LastEditDate="2022-01-17T16:55:02.403" LastActivityDate="2022-01-19T09:06:38.210" Title="Linearizing $x^2/(1-x)$ by partitioning the interval $0&lt;x\le X$" Tags="|linearization|nonlinear-programming|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7601" PostTypeId="1" AcceptedAnswerId="7604" CreationDate="2022-01-17T16:33:58.407" Score="2" ViewCount="102" Body="&lt;p&gt;We have a table of data as follows&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{c|c|c|c|c} &#xA; &amp;amp; b \leqslant a &amp;amp; a &amp;lt; b \leqslant 2a &amp;amp; 2a &amp;lt; b \leqslant 3a &amp;amp; 3a &amp;lt; b \leqslant 4a \\ \hline&#xA;i=1 &amp;amp; e &amp;amp; 2d &amp;amp; 2d &amp;amp; 2d \\ \hline&#xA;i=2 &amp;amp; - &amp;amp; e &amp;amp; d &amp;amp; d \\ \hline&#xA;i=3 &amp;amp; - &amp;amp; - &amp;amp; e &amp;amp; \frac{2}{3}d \\ \hline&#xA;i=4 &amp;amp; - &amp;amp; - &amp;amp; - &amp;amp; e \\ \hline&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The data inside every cell of this table corresponds to a parameter of the problem which we show by &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How can we formulate &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; without adding another index to &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;There seems to be a connection between the value of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and the interval to which &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; belongs (the coefficient of &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;) but I don't know how to model it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I think I should have mentioned that &lt;span class=&quot;math-container&quot;&gt;$a, b, e, d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; are all parameters of the problem.&lt;/p&gt;&#xA;" OwnerUserId="7693" LastEditorUserId="7693" LastEditDate="2022-01-17T19:08:31.763" LastActivityDate="2022-01-18T08:37:24.743" Title="Formulating a coefficient from a table" Tags="|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7602" PostTypeId="2" ParentId="7600" CreationDate="2022-01-17T16:36:47.217" Score="3" Body="&lt;p&gt;I assume &lt;span class=&quot;math-container&quot;&gt;$X\le1$&lt;/span&gt;, since the formulation is infeasible for &lt;span class=&quot;math-container&quot;&gt;$x &amp;gt; 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What you are doing is a form of &lt;em&gt;piecewise linear approximation&lt;/em&gt; of the function &lt;span class=&quot;math-container&quot;&gt;$f(x) = x^2/(1-x)$&lt;/span&gt;. Choosing &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is a matter of trial and error. Obviously, the larger &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the more accurate the approximation is. Also obvious is that larger &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; means longer solution time (and more memory usage).&lt;/p&gt;&#xA;&lt;p&gt;There are a couple of things worth noting. One is that you might (or might not) get a more accurate approximation using &lt;span class=&quot;math-container&quot;&gt;$(r_i + r_{i+1})/2$&lt;/span&gt; rather than &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; as the point in interval &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; where you evaluate &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;. Another is that it is often a good idea to concentrate evaluation points where the function has greatest curvature. So you would shrink the spacing between points as &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; progressed from 0 to 1.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: If solution times are fairly brief, one other thing that might be worth trying is to discretize, solve, add break points near the optimal solution (to get a better approximation there) and maybe remove a few breakpoints away from the optimum (to conserve model size), solve again, and repeat until satisfied (or bored).&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="123" LastEditDate="2022-01-18T08:36:44.847" LastActivityDate="2022-01-18T08:36:44.847" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7603" PostTypeId="2" ParentId="7593" CreationDate="2022-01-17T16:40:33.927" Score="5" Body="&lt;p&gt;The two sets of constraints are not the same, but both sets provide a formulation for the problem.  The relationship between the two is that if you take a solution to (2.1) and (2.2), compute &lt;span class=&quot;math-container&quot;&gt;$z_t=\sum_i z_{ti}$&lt;/span&gt;, and substitute those values for &lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt; everywhere in (1.1) and (1.2), keeping &lt;span class=&quot;math-container&quot;&gt;$\delta_t$&lt;/span&gt; from the solution to (2.1) and (2.2), the constraints (1.1) and (1.2) will be satisfied.  Actually doing this is a useful exercise for understanding.&lt;/p&gt;&#xA;&lt;p&gt;This correspondence works in only one direction, though.  The second formulation is tighter in the sense that there are (fractional) solutions to (1.1) and (1.2) that cannot be disaggregated into a solution of (2.1) and (2.2).  Finding such a solution is another useful exercise.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-01-17T21:42:22.323" LastActivityDate="2022-01-17T21:42:22.323" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7604" PostTypeId="2" ParentId="7601" CreationDate="2022-01-17T18:12:43.587" Score="4" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{j} \in \{0,1\}$&lt;/span&gt; equals 1 represents variable &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; belongs to interval &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. You can linearize interval relation as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;A_{j-1} \cdot z_{j} + \epsilon \cdot z_{j} \le b_{j} \le A_{j} \cdot  z_{j} \quad \forall j \in {1,2,3,4} &#xA;$$&lt;/span&gt;&#xA;Here, this leads to 4 binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{j}$&lt;/span&gt; and values of &lt;span class=&quot;math-container&quot;&gt;${A_0}$&lt;/span&gt;,&lt;span class=&quot;math-container&quot;&gt;${A_1}$&lt;/span&gt;,&lt;span class=&quot;math-container&quot;&gt;${A_2}$&lt;/span&gt;,&lt;span class=&quot;math-container&quot;&gt;${A_3}$&lt;/span&gt;,&lt;span class=&quot;math-container&quot;&gt;${A_4}$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$2a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$3a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$4a$&lt;/span&gt; respectively (assuming 0 to be lower bound of variable &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;). &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is introduced on LHS to handle strict less than condition.&lt;/p&gt;&#xA;&lt;p&gt;variable &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is to be defined as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;b = \sum_{j} b_{j}&#xA;$$&lt;/span&gt;&#xA;and only one of the intervals has to be selected&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j} z_{j} = 1&#xA;$$&lt;/span&gt;&#xA;To achieve above linearization, you might consider using SOS Type-1 relation as well. If a is also a variable, you might have to write some Big-M constraints to linearize the same.&#xA;finally, &lt;span class=&quot;math-container&quot;&gt;$c_{i}$&lt;/span&gt; can be defined as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c_{i}  =  \sum_{j\mid j\ge i} W_{ij} z_{j}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$W_{ij}$&lt;/span&gt; represents tabular parameters corresponding to row &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and column &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5880" LastEditorUserId="123" LastEditDate="2022-01-18T08:37:24.743" LastActivityDate="2022-01-18T08:37:24.743" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7606" PostTypeId="2" ParentId="292" CreationDate="2022-01-18T04:24:22.873" Score="3" Body="&lt;p&gt;I was having the same problem: I always had to look up the rules for taking LP duals. So I've built a small web page at &lt;a href=&quot;https://lpdual.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://lpdual.com&lt;/a&gt; that quickly gives the answer. It shows a sample primal program, and allows you to change the sense of the constraints and variables and to then see the effect on the dual.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://lpdual.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DD0I2.gif&quot; alt=&quot;Screenshot&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3781" LastActivityDate="2022-01-18T04:24:22.873" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7607" PostTypeId="2" ParentId="7600" CreationDate="2022-01-18T08:47:05.347" Score="2" Body="&lt;p&gt;Have you tried solving the problem directly? This is simply a quadratic non-convex constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y = \frac{x^2}{1-x}\implies y - yx = x^2&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So e.g. using Gurobi and Python, you can write:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;&#xA;&#xA;m = gp.Model()&#xA;x = m.addVar(0, x_ub)&#xA;y = m.addVar(0, y_ub)&#xA;m.addConstr(y - y*x == x*x)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="133" LastEditorUserId="123" LastEditDate="2022-01-19T09:06:38.210" LastActivityDate="2022-01-19T09:06:38.210" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7609" PostTypeId="1" AcceptedAnswerId="7610" CreationDate="2022-01-19T03:09:37.770" Score="4" ViewCount="199" Body="&lt;p&gt;Suppose I have an SDP&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_{X \in \mathbb{S}^{n}_{+}}&amp;amp;\quad f(X)\\\text{s.t.} &amp;amp;\quad X_{i,j} = c_{i,j} \quad \forall (i,j) \in I,\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$I \subseteq [n] \times [n]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is convex on the set of positive semidefinite matrices. Are there any methods for solving SDPs which are able to simplify the problem by eliminating the constrained variables?&lt;/p&gt;&#xA;" OwnerUserId="3066" LastEditorUserId="123" LastEditDate="2022-01-19T09:06:02.300" LastActivityDate="2022-01-19T14:11:33.927" Title="Eliminating Variables in Semidefinite Programs Using Equality Constraints" Tags="|optimization|convex-optimization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7610" PostTypeId="2" ParentId="7609" CreationDate="2022-01-19T06:05:40.347" Score="5" Body="&lt;p&gt;I doubt you can eliminate the fixed variables in general but given some special structure it might be possible.&lt;/p&gt;&#xA;&lt;p&gt;In &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-002-0349-3&quot; rel=&quot;noreferrer&quot;&gt;my paper&lt;/a&gt; I describe how to exploit fixed variables inside a primal-dual interior algorithm for conic quadratic optimization. However, I have not been able to generalize this idea to the semi-definite cone in a useful way.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2022-01-19T06:24:01.583" LastActivityDate="2022-01-19T06:24:01.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7611" PostTypeId="1" AcceptedAnswerId="7613" CreationDate="2022-01-19T11:39:30.070" Score="12" ViewCount="1508" Body="&lt;p&gt;I have set of machines with varying productivity.&lt;/p&gt;&#xA;&lt;p&gt;I want put the machines in different groups so that the groups have approximately equal productivity.&lt;/p&gt;&#xA;&lt;p&gt;Lets say, we have &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; machines.&lt;/p&gt;&#xA;&lt;p&gt;and we want to divide them into &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; groups of equal size.&lt;/p&gt;&#xA;&lt;p&gt;Size of a group, &lt;span class=&quot;math-container&quot;&gt;$S=M/G$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The productivity of machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is given by &lt;span class=&quot;math-container&quot;&gt;$P_m\ge 0$&lt;/span&gt; (some machine may have zero productivity).&lt;/p&gt;&#xA;&lt;p&gt;What is an easy LP formulation?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textbf{Tried...}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{g,m}$&lt;/span&gt; be a binary indicator. If &lt;span class=&quot;math-container&quot;&gt;$x_{g,m}=1$&lt;/span&gt;, machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; belongs to group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So, we have &lt;span class=&quot;math-container&quot;&gt;$$\sum_{m=1}^Mx_{g,m}=S, \forall g$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The productivity of group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is given by&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$T_g=\sum_{m=1}^MP_m*x_{g,m},\forall g$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I prefer &lt;span class=&quot;math-container&quot;&gt;$$T_1\approx T_2 \approx T_3 \approx \cdots\approx T_G$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What would be a good objective function?&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; is a variable.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\phi=\frac{T_a}{T_b}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;maximize &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;I am looking for an efficient implementation...&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bf{EDIT}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;All the solutions proposed are hard to solve. I am rather looking for some greedy heuristic approach to solve this problem.&lt;/p&gt;&#xA;&lt;p&gt;This is what I have tried so far...&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Choose &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; machines (machines with the G largest productivity) as the group head.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then I follow an iterative steps for the the remaining &lt;span class=&quot;math-container&quot;&gt;$M-G$&lt;/span&gt; machines. For a given machine, it is attached to a group that has the smallest productivity.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Do you think it a good heuristic?&lt;/p&gt;&#xA;&lt;p&gt;Any suggestion with better heuristic?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2022-01-24T10:00:34.407" LastActivityDate="2022-01-24T10:00:34.407" Title="Dividing machines into groups of equal sizes so that each group has approximately same productivity" Tags="|mixed-integer-programming|linear-programming|modeling|mosek|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7612" PostTypeId="2" ParentId="7611" CreationDate="2022-01-19T12:11:58.440" Score="5" Body="&lt;ul&gt;&#xA;&lt;li&gt;Minimize the greatest &lt;span class=&quot;math-container&quot;&gt;$T_g$&lt;/span&gt;:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad T_\text{max}\\&amp;amp;\quad T_g \le T_\text{max} \qquad \forall g\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The drawback is that it will minimize &lt;span class=&quot;math-container&quot;&gt;$T_g$&lt;/span&gt;, and maybe it is not what you want&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As @RobPratt suggested in the comments, minimize the difference between the greatest and the smallest &lt;span class=&quot;math-container&quot;&gt;$T_g$&lt;/span&gt;:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad T_\text{max} - T_\text{min}\\&amp;amp;\quad T_g \le T_\text{max} \qquad \forall g\\&amp;amp;\quad T_g \ge T_\text{min} \qquad \forall g \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The drawback is that it might be harder to solve&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="123" LastEditDate="2022-01-21T08:17:17.300" LastActivityDate="2022-01-21T08:17:17.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7613" PostTypeId="2" ParentId="7611" CreationDate="2022-01-19T12:12:23.590" Score="13" Body="&lt;p&gt;Here are two ideas:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Minimize &lt;span class=&quot;math-container&quot;&gt;$\max_g T_g$&lt;/span&gt;. This will naturally even out the productivities of each group. To do this you can minimize a variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and add the constraint &lt;span class=&quot;math-container&quot;&gt;$z \ge T_g \; \forall g$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Add constraints &lt;span class=&quot;math-container&quot;&gt;$T_{min} \le T_g \le T_{max}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$T_{min}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T_{max}$&lt;/span&gt; are lower and upper bounds on &lt;span class=&quot;math-container&quot;&gt;$T_g$&lt;/span&gt;, respectively. You will have to determine a &amp;quot;good&amp;quot; set of values for these parameters, by iteratively tweaking them.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;You could try and mix both approaches. Try the first one, and use the value of the objective function for &lt;span class=&quot;math-container&quot;&gt;$T_{max}$&lt;/span&gt;. If the values are not evened out enough, iteratively increase &lt;span class=&quot;math-container&quot;&gt;$T_{min}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-01-19T12:12:23.590" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7614" PostTypeId="2" ParentId="7609" CreationDate="2022-01-19T14:11:33.927" Score="3" Body="&lt;p&gt;Are you talking about doing it in some particularly clever way? If you simply intend to solve the problem in the original dual space (i.e. seeing &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; as a matrix parameterized by its elements and optimizing over those variables) it is just a matter of deriving a solution and basis for &lt;span class=&quot;math-container&quot;&gt;$Ax=c$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are the elements parameterizing &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, i.e., write &lt;span class=&quot;math-container&quot;&gt;$x = x_0 + Hz$&lt;/span&gt; and then replace in &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;. In the modelling toolbox YALMIP, that would correspond to using the option &lt;strong&gt;removeequalities&lt;/strong&gt; (which now more or less is obsolete as it most often would be best to let the solver deal with the equalities)&lt;/p&gt;&#xA;&lt;p&gt;EDIT: In your case the solution and basis is trivial as all your conditions involve single elements, so I might have misunderstood your question.&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2022-01-19T14:11:33.927" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7615" PostTypeId="1" CreationDate="2022-01-19T16:37:27.010" Score="1" ViewCount="136" Body="&lt;p&gt;I try to model a decision process in which I first need to decide about a binary variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. In case &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt;, I also need to decide upon variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and the value of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is not defined otherwise. Especially, I do not know how to correctly introduce constraints. Assume that I want to model a constraint that states that &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; needs to be greater than 5. Of course I could then just state:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{eq:cap}&#xA;     y &amp;gt; 5 &#xA;\end{equation}&lt;/span&gt;&#xA;But this would suggest that &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; has a defined value, which does not need to be the case (if &lt;span class=&quot;math-container&quot;&gt;$x = 0$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Is there a standard way how to introduce such a variable and associated constraints (e.g. in an IP or MDP)?&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="3464" LastEditDate="2022-01-19T16:49:01.490" LastActivityDate="2022-01-20T09:01:04.123" Title="How to introduce an optional decision variable" Tags="|modeling|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7616" PostTypeId="1" CreationDate="2022-01-19T16:44:26.093" Score="1" ViewCount="86" Body="&lt;p&gt;I am working on a dispatch optimization problem in the trucking industry.&lt;/p&gt;&#xA;&lt;p&gt;I have a first algorithm - a vehicle routing algorithm - that produces a series of tours.&lt;/p&gt;&#xA;&lt;p&gt;I will need a second algorithm that assigns the tours resulting from the first algorithm to individual drivers, tractors and trailers (i.e. three different kinds of resources).  I believe that the second algorithm would need to be (essentially) an assignment problem algorithm.&lt;/p&gt;&#xA;&lt;p&gt;Here are my questions&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the name for the kind of assignment problem where more than one different kind or class of resource needs to be assigned to tasks?&lt;/li&gt;&#xA;&lt;li&gt;I believe that one approach to the design of the assignment problem would be to have a binary decision variable for each task / resource / hour-of-the-day combination.  I'm thinking this approach is going to be computationally expensive.  Are there alternative approaches to this part of the design that might be less computationally expensive?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8901" LastActivityDate="2022-01-19T22:21:06.547" Title="Assignment Problems With More than One Class of Resource" Tags="|optimization|vehicle-routing|assignment-problem|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7617" PostTypeId="2" ParentId="7611" CreationDate="2022-01-19T17:24:07.893" Score="4" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\overline{P}$&lt;/span&gt; be the average (mean) productivity of all machines. The average productivity of a group will be &lt;span class=&quot;math-container&quot;&gt;$S\overline{P}$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$y_g$&lt;/span&gt; be nonnegative variables defined by the constraints &lt;span class=&quot;math-container&quot;&gt;$$y_g \ge T_g - S\overline{P}$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$ y_g \ge S\overline{P} - T_g$$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;. In the solution, &lt;span class=&quot;math-container&quot;&gt;$y_g$&lt;/span&gt; will be &lt;span class=&quot;math-container&quot;&gt;$\vert T_g - S\overline{P}\vert$&lt;/span&gt;. You can minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_g y_g$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\max_g y_g$&lt;/span&gt;. You can also minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_g y_g^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: If a heuristic is desired, one possibility is a permutation-type genetic algorithm. Each chromosome is a permutation of &lt;span class=&quot;math-container&quot;&gt;$1,\dots,M$&lt;/span&gt;. You decode a chromosome &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; into a solution by making one group with machines &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_S$&lt;/span&gt;, the next group with machines &lt;span class=&quot;math-container&quot;&gt;$x_{S+1},\dots,x_{S+G}$&lt;/span&gt;, and so on. Use whichever criterion you like as the fitness value (with the understanding that you want to maximize, not minimize, fitness).&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-01-20T17:14:19.220" LastActivityDate="2022-01-20T17:14:19.220" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7619" PostTypeId="2" ParentId="7616" CreationDate="2022-01-19T22:21:06.547" Score="1" Body="&lt;p&gt;I don't know a particular name for this type of problem. Depending on the specifics of the problem, the following approach might work. Use binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{dr}$&lt;/span&gt; indicating whether driver &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is assigned to route &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_{tr}$&lt;/span&gt; indicating whether tractor &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is assigned to route &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z_{tr}$&lt;/span&gt; indicating whether trailer &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is assigned to route &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;. If you need to know whether a route was assigned, add binary variables &lt;span class=&quot;math-container&quot;&gt;$w_r$&lt;/span&gt; for each route &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Constraints to limit how many times a driver, tractor or trailer is used are obvious.&lt;/li&gt;&#xA;&lt;li&gt;If a driver, tractor or trailer cannot be used on a given route, just eliminate the corresponding variable, or set it to zero.&lt;/li&gt;&#xA;&lt;li&gt;It probably will be unnecessary to prevent the model from assigning drivers or equipment to unused routes, but if it is needed, you can just add constraints &lt;span class=&quot;math-container&quot;&gt;$\sum_d x_{dr} = w_r$&lt;/span&gt; for each route &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; and similarly for trailers and tractors. (I'm assuming each route is driven at most once.)&lt;/li&gt;&#xA;&lt;li&gt;If you need to weed out certain combinations (e.g., driver 7 and tractor 3 can both be used on route 5, but driver 7 cannot drive tractor 3 on route 5), those are easily handled. For my example, the constraint might be &lt;span class=&quot;math-container&quot;&gt;$$x_{75} + y_{35} \le 1.$$&lt;/span&gt;If a particular combination cannot be used on any route, just iterate the constraint over all routes.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Not knowing full details of the problem, I'll stop there.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-19T22:21:06.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7620" PostTypeId="1" CreationDate="2022-01-19T22:40:44.013" Score="2" ViewCount="68" Body="&lt;p&gt;I am currently doing a coursera course on optimization. They are using minizinc and they modeled a&#xA;problem where the decision is a choice of things --&amp;gt; a set. We all know this is a knapsack and it its modeled with binary vars.&lt;/p&gt;&#xA;&lt;p&gt;They declared a set var. What is this? is this common?&#xA;Or does the solver somehow convert this into a knapsack?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rAIqT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rAIqT.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HXhaO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HXhaO.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4380" LastActivityDate="2022-01-19T23:14:52.473" Title="A variable being a set...?" Tags="|knapsack|minizinc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7621" PostTypeId="2" ParentId="7620" CreationDate="2022-01-19T23:14:52.473" Score="4" Body="&lt;p&gt;This is a constraint programming (CP) model. The &amp;quot;vocabulary&amp;quot; of MIP solvers is fairly standard. They all recognize real, integer and binary variables, linear equality and inequality constraints, maybe some quadratic stuff and maybe indicator constraints. CP languages and solvers are much less standardized. Apparently MiniZinc has a construct for variables whose values are subsets of a given set of integers. Older versions of IBM's CP Optimizer seemed to have something similar (&amp;quot;IloIntSetVar&amp;quot;), but I think it has been removed.&lt;/p&gt;&#xA;&lt;p&gt;As to how the solver implements it, that might vary from solver to solver. It could be converted internally into binary variables for each vocabulary element (1 if the element is selected for the set).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-19T23:14:52.473" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7622" PostTypeId="1" AcceptedAnswerId="7626" CreationDate="2022-01-20T08:00:18.877" Score="3" ViewCount="130" Body="&lt;p&gt;I am dealing with a large problem of MILP problem and interested to apply Benders Decomposition. I have already check the original problem and it was feasible to run in large number of computation time. I understand in some sources: &lt;a href=&quot;https://or.stackexchange.com/questions/185/how-to-determine-if-a-given-problem-seems-to-be-a-good-fit-to-be-solved-using-co&quot;&gt;stackexchangelink&lt;/a&gt; and &lt;a href=&quot;https://orinanobworld.blogspot.com/2011/10/benders-decomposition-then-and-now.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;ProfRubinblog&lt;/a&gt; that somewhat a careful implementation should be done. I found that after several iterations of unbounded dual sub problem, my master problem had become infeasible. Due to the fact that the original problem is feasible, I suppose that I have to identify cut to add in my master problem.&lt;/p&gt;&#xA;&lt;p&gt;My question is: When I can't calculate the original problem using traditional method (and that's the reason of using Benders Decomposition), is there a way to know the boundary of the cause of in-feasibility between adding a new cut in my master problem and the in-feasibility of the problem it self?&lt;/p&gt;&#xA;" OwnerUserId="8936" LastEditorUserId="491" LastEditDate="2022-01-20T13:46:15.653" LastActivityDate="2022-01-20T17:06:10.427" Title="Master Problem Infeasible after Iterations of Unbounded Sub Problem (Generic Benders Decomposition in non Stochastic MILP)" Tags="|modeling|combinatorial-optimization|benders-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7623" PostTypeId="2" ParentId="7615" CreationDate="2022-01-20T08:29:57.240" Score="2" Body="&lt;p&gt;Optional decision variables are part of the building block of scheduling within CPLEX CPOptimizer.&lt;/p&gt;&#xA;&lt;p&gt;For instance&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using CP;&#xA;&#xA;dvar interval s size 1;&#xA;dvar interval e size 1;&#xA;dvar interval itvs optional size 7;&#xA;&#xA;maximize presenceOf(itvs);&#xA;subject to&#xA;{&#xA;  startOf(s)==1;&#xA;  startOf(e)==8;&#xA;  startBeforeStart(itvs,s);&#xA;  startBeforeEnd(e,itvs);  &#xA;}&#xA;&#xA;int isPresent=presenceOf(itvs);&#xA;execute&#xA;{&#xA;  writeln(&amp;quot;isPresent=&amp;quot;,isPresent);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;isPresent=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but if I turn&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar interval itvs optional size 7;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar interval itvs optional size 5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then we get&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;isPresent=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The constraints on itvs (start and end) are valid as long as the optional interval is present.&lt;/p&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2022-01-20T09:01:04.123" LastActivityDate="2022-01-20T09:01:04.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7624" PostTypeId="2" ParentId="7611" CreationDate="2022-01-20T16:04:20.953" Score="6" Body="&lt;p&gt;This is a well-known problem with existing heuristics: &lt;a href=&quot;https://en.wikipedia.org/wiki/Multiway_number_partitioning&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Multiway_number_partitioning&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Edit: For partitioning into groups of limited sizes (eg. &lt;span class=&quot;math-container&quot;&gt;$S_{max} \le M/G+1$&lt;/span&gt;) see &lt;a href=&quot;https://en.wikipedia.org/wiki/Balanced_number_partitioning&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Balanced_number_partitioning&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and in the special case of partitioning into groups of &lt;span class=&quot;math-container&quot;&gt;$S \le 3$&lt;/span&gt; see:&#xA;&lt;a href=&quot;https://en.wikipedia.org/wiki/Balanced_number_partitioning#Balanced_triplet_partitioning&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Balanced_number_partitioning#Balanced_triplet_partitioning&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8939" LastEditorUserId="-1" LastEditDate="2022-01-21T08:07:47.183" LastActivityDate="2022-01-21T08:07:47.183" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7625" PostTypeId="2" ParentId="7611" CreationDate="2022-01-20T16:49:51.603" Score="6" Body="&lt;p&gt;By request, here's the SAS code I used for three different objectives (the first two are commented out with /* and */ delimiters):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;proc optmodel;&#xA;   num numMachines = 21;&#xA;   num groupSize = 3;&#xA;   set MACHINES = 1..numMachines;&#xA;   set GROUPS = 1..numMachines/groupSize;&#xA;   call streaminit(1);&#xA;   num p {MACHINES} = rand('INTEGER',0,10);&#xA;   print p;&#xA;&#xA;   var X {MACHINES, GROUPS} binary;&#xA;   con OneGroup {m in MACHINES}:&#xA;      sum {g in GROUPS} X[m,g] = 1;&#xA;   con Cardinality {g in GROUPS}:&#xA;      sum {m in MACHINES} X[m,g] = groupSize;&#xA;   impvar GroupSum {g in GROUPS} = sum {m in MACHINES} p[m]*X[m,g];&#xA;/*   min MinMax = max {g in GROUPS} GroupSum[g];*/&#xA;/*   max MaxMin = min {g in GROUPS} GroupSum[g];*/&#xA;   min Range = max {g in GROUPS} GroupSum[g] - min {g in GROUPS} GroupSum[g];&#xA;&#xA;   solve linearize;&#xA;   print X;&#xA;   print GroupSum;&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that the LINEARIZE option in the SOLVE statement automatically performs the linearization that other answers have already described explicitly.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-01-20T19:32:26.133" LastActivityDate="2022-01-20T19:32:26.133" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7626" PostTypeId="2" ParentId="7622" CreationDate="2022-01-20T17:06:10.427" Score="2" Body="&lt;p&gt;If the original problem was feasible, the Benders master problem should never become infeasible. You may have a formulation error in the Benders decomposition, or you may be generating the cuts incorrectly.&lt;/p&gt;&#xA;&lt;p&gt;If you can identify a feasible (not necessarily good) solution to the problem by solving the original formulation, you can use that to locate any errors in your Benders approach. Fix the master variables at their values in the feasible solution and run the subproblem. If the subproblem is infeasible (dual unbounded), fix the values of the subproblem variables at their values in the feasible solution and look for violated constraints.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-20T17:06:10.427" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7627" PostTypeId="1" CreationDate="2022-01-20T22:47:03.083" Score="3" ViewCount="170" Body="&lt;p&gt;Although this sounds like a standard minimax problem, I'm not sure how to deal with feasibility issues.&lt;/p&gt;&#xA;&lt;p&gt;Consider a maximin linear program&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max_x\min_y&amp;amp;\quad c^\top y\\\text{s.t.}&amp;amp;\quad Ay\leq b\\&amp;amp;\quad Cy\leq x\\&amp;amp;\quad Dx\leq f.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Under what conditions can I swap the  maximin to minimax  and is there any duality theory that applies to this?&lt;/p&gt;&#xA;&lt;p&gt;Note that y and x must be chosen to be feasible and we can assume that for any feasible x, there exists a feasible y. (We are not allowing infeasibility to count an &lt;span class=&quot;math-container&quot;&gt;$-\infty$&lt;/span&gt;.)&lt;/p&gt;&#xA;&lt;p&gt;EDIT: changed minimax to maximin to clarify and added a condition.&lt;/p&gt;&#xA;" OwnerUserId="8941" LastEditorUserId="8941" LastEditDate="2022-01-22T17:18:57.977" LastActivityDate="2022-01-22T17:18:57.977" Title="min max inside a linear program" Tags="|linear-programming|duality|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7628" PostTypeId="1" CreationDate="2022-01-21T11:45:56.813" Score="-3" ViewCount="99" Body="&lt;p&gt;&lt;strong&gt;I have the following problem statement:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;A company is considering to hire more operators. Starting with four machine operators&#xA;in May, the company wants to investigate if it pays off to hire more. Each operator has a&#xA;monthly cost of $3000. Due to local union agreements, once a person is hired, this&#xA;person cannot be sacked (at least not in this 4 month period), hence once hired in&#xA;one month, that person has to stay for the entire time-period.&lt;/p&gt;&#xA;&lt;p&gt;How would one model this as a constraint?&lt;/p&gt;&#xA;" OwnerUserId="8945" LastEditorUserId="8945" LastEditDate="2022-01-21T20:18:12.550" LastActivityDate="2022-01-21T20:18:12.550" Title="Modelling constraint" Tags="|mixed-integer-programming|linear-programming|modeling|integer-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7629" PostTypeId="2" ParentId="7628" CreationDate="2022-01-21T12:10:28.800" Score="3" Body="&lt;p&gt;Without the entire problem description it is hard to provide a complete answer, but you will probably need a variable &lt;span class=&quot;math-container&quot;&gt;$x_t \in \mathbb{N}$&lt;/span&gt; for the number of operators hired at time period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;With these variables, and taking into account the fact that once an operator is hired, he is hired for the entire time period, the extra cost at a given time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; equals  &lt;span class=&quot;math-container&quot;&gt;$\\\$ 3000$&lt;/span&gt; times the number of operators hired up to time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, that is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;3000 \sum_{i,i\le t} x_i&#xA;$$&lt;/span&gt;&#xA;So you want to minimize this term over the entire time span:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;3000\sum_t\sum_{i,i\le t} x_i&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-01-21T12:10:28.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7630" PostTypeId="1" CreationDate="2022-01-21T12:44:38.887" Score="4" ViewCount="129" Body="&lt;p&gt;I kindly ask for some ideas or references to exploit ordering in MILPs.&lt;/p&gt;&#xA;&lt;p&gt;In particular, there are resources &lt;span class=&quot;math-container&quot;&gt;$ r = [r_1, r_2, ..., r_K] $&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$r_{i} \leq r_{i+1} $&lt;/span&gt;. These are input to the problem.&lt;/p&gt;&#xA;&lt;p&gt;In addition, there are binary variables &lt;span class=&quot;math-container&quot;&gt;$ x = [x_1, x_2, ..., x_K] $&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$ \sum_i x_i = 1 $&lt;/span&gt;  used to select the resources. Besides, there are also continuous-valued variables &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in a convex set &lt;span class=&quot;math-container&quot;&gt;$ \Omega $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The objective is &lt;span class=&quot;math-container&quot;&gt;$ \max_{x,y} \sum_i u_i x_i $&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$ u = [u_1, u_2, ..., u_K] $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$u_{i} \leq u_{i+1} $&lt;/span&gt; represent utility.&lt;/p&gt;&#xA;&lt;p&gt;My problem looks like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \max_{x,y} \sum_i u_i x_i&#xA;\\&#xA;g_m(y) \geq  \sum_i r_i x_i, m = 1, \dots, M,&#xA;\\&#xA;\sum_i x_i = 1,&#xA;\\&#xA;y \in \Omega,&#xA;$$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;One can see that selecting &lt;span class=&quot;math-container&quot;&gt;$ x_{i+1} = 1 $&lt;/span&gt; may generate better objectives than &lt;span class=&quot;math-container&quot;&gt;$ x_{i} = 1 $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would like to exploit the fact that &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; are ordered. For instance, if allocating &lt;span class=&quot;math-container&quot;&gt;$ r_j $&lt;/span&gt; does not yield a feasible solution, then it makes no sense to try with &lt;span class=&quot;math-container&quot;&gt;$ r_{j+1} $&lt;/span&gt;. I am using MOSEK and GUROBI to solve this problem, and I understand that this kind of structure is very particular to my problem and perhaps not exploited by these solvers. I have randomly changed the order of the elements in &lt;span class=&quot;math-container&quot;&gt;$ r $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ u $&lt;/span&gt; (keeping the one-to-one correspondence) and I get comparable execution times.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to add cuts that exploit this structure and reduce the number of evaluations (branches)? I would be very grateful!&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ r = [0.5, 2.1, 3.7, 5.1] $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ u = [9.8, 12.5, 18.1, 25.2] $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x = [x_1, x_2, x_3, x_4] $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ y \in \Omega (convex) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \max_{x,y} \sum_i 9.8 x_1 +  12.5 x_2 + 18.1 x_3 + 25.2 x_4&#xA;\\&#xA;g (y) \geq  0.5 x_1 + 2.1 x_2 + 3.7x_3 + 5.1 x_4,&#xA;\\&#xA;x_1 + x_2 + x_3 + x_4 = 1,&#xA;\\&#xA;y \in \Omega,&#xA;$$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As explained above, if &lt;span class=&quot;math-container&quot;&gt;$ x_2 = 1 $&lt;/span&gt; is not feasible, that means that &lt;span class=&quot;math-container&quot;&gt;$ g (y) \geq 2.1 $&lt;/span&gt; cannot be satisfied. Thus, evaluating &lt;span class=&quot;math-container&quot;&gt;$ x_3 = 1 $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ x_4 = 1 $&lt;/span&gt; is not necessary due to the sorted strcuture of &lt;span class=&quot;math-container&quot;&gt;$ r $&lt;/span&gt;. Instead, &lt;span class=&quot;math-container&quot;&gt;$ x_1 = 1 $&lt;/span&gt; should be evaluated. I would like to add a constraint that considers this to reduce the number of evalautions.&lt;/p&gt;&#xA;" OwnerUserId="719" LastEditorUserId="719" LastEditDate="2022-01-23T11:59:31.727" LastActivityDate="2022-01-23T11:59:31.727" Title="Exploiting ordering to removing infeasible solutions in MILP" Tags="|mixed-integer-programming|integer-programming|branch-and-cut|cutting-planes|valid-inequalities|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7631" PostTypeId="2" ParentId="7630" CreationDate="2022-01-21T16:16:25.873" Score="3" Body="&lt;p&gt;Depending on the solver used, you may be able to prioritize the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables so that variables with higher indices are branched on before variables with lower indices (and elements of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are branched on before any other integer variables). You may also be able to instruct the solver, after branching on &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, to prioritize the child with &lt;span class=&quot;math-container&quot;&gt;$x_i=1$&lt;/span&gt; over the child with &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt;. Either or both of those may (or may not) speed things up.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-21T16:16:25.873" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7632" PostTypeId="1" CreationDate="2022-01-21T17:31:58.380" Score="1" ViewCount="140" Body="&lt;p&gt;There is a factory that produces one unit of stock uniformly so that &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; units of stock are produced during a day. The warehouse near a factory has the maximal capacity of &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; items, i.e. a daily production. We assume if at any given time there is an excess inventory of stock - it is destroyed. At the beginning of a day the warehouse holds &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; units of stock.&lt;/p&gt;&#xA;&lt;p&gt;There is a stochastic demand for a stock that follows a Poisson process with an intensity that is a function of premium &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; we charge for the item. For simplicity, each time there is a demand - it is for one unit. We know how the intensity depends on the charged premium and this is a convex and decreasing function in premium.&lt;/p&gt;&#xA;&lt;p&gt;We control the premium and may change it at any time. We need to find a schedule that solves the following optimisation problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\delta_t = argmax_\delta( \mbox{number of items sold during a day})&#xA;$$&lt;/span&gt;&#xA;such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;q_t &amp;gt; 0, \mbox{for all t}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$q_t$&lt;/span&gt; is the inventory of a warehouse at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. I.e. we want to sell as much items as possible never running out of the inventory at a warehouse. The time horizon for this optimisation problem is one day. We assume factory refills the warehouse at night.&lt;/p&gt;&#xA;&lt;p&gt;How one would approach this problem? If the condition on the warehouse capacity is an issue I am ok to add it to the objective function as a penalty term. Also, if there is a mathematically sound heuristic solution - this is also fine.&lt;/p&gt;&#xA;" OwnerUserId="8949" LastEditorUserId="491" LastEditDate="2022-01-23T13:19:38.187" LastActivityDate="2022-01-23T13:19:38.187" Title="Simple inventory control with stochastic demand" Tags="|inventory|dynamic-programming|stochastic-process|optimal-control|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7633" PostTypeId="2" ParentId="7627" CreationDate="2022-01-21T18:52:54.087" Score="2" Body="&lt;p&gt;Your inner problem is actually trivial. For fixed &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; satisfying &lt;span class=&quot;math-container&quot;&gt;$Ax\le b$&lt;/span&gt;, either &lt;span class=&quot;math-container&quot;&gt;$y \ge Cx$&lt;/span&gt; and the inner problem has value &lt;span class=&quot;math-container&quot;&gt;$c'x$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$y \not \ge Cx$&lt;/span&gt; and the inner problem (using the usual convention for infeasibility in a max problem) has value &lt;span class=&quot;math-container&quot;&gt;$-\infty$&lt;/span&gt;. Since there are no other constraints on &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, selecting &lt;span class=&quot;math-container&quot;&gt;$y=Cx$&lt;/span&gt; is optimal in the inner problem, with value &lt;span class=&quot;math-container&quot;&gt;$c'x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So you are now left with a simple LP:&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\min\  &amp;amp; c'x\\&#xA;\textrm{s.t. }\  &amp;amp; Ax\le b.&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-21T18:52:54.087" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7634" PostTypeId="1" AcceptedAnswerId="7635" CreationDate="2022-01-22T15:26:14.910" Score="3" ViewCount="278" Body="&lt;p&gt;We have a decision variable &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;y&amp;lt;1$&lt;/span&gt; and the following constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z=\frac{y^2-y+1}{y(1-y)},\tag{1}$$&lt;/span&gt;&#xA;We also have another constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y=f(x),\tag{2}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is a linear function of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In other words, our primary decision variable is &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; are auxiliary decision variables.&lt;/p&gt;&#xA;&lt;p&gt;We would like to linearize constraint (1) by replacing it with its piece-wise linear approximation.&lt;/p&gt;&#xA;&lt;p&gt;How can we do that?&lt;/p&gt;&#xA;&lt;p&gt;If we divide the interval &lt;span class=&quot;math-container&quot;&gt;$(0,1)$&lt;/span&gt; into &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; pieces of equal length (assuming we know what the &amp;quot;best&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is) and denote each piece by &lt;span class=&quot;math-container&quot;&gt;$r_i, i=1,\ldots,n$&lt;/span&gt;, define a new decision variable &lt;span class=&quot;math-container&quot;&gt;$w_i=1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is in the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;th interval and &lt;span class=&quot;math-container&quot;&gt;$w_i=0$&lt;/span&gt; otherwise, then can we linearize (1) as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z=\sum_{i=1}^{n}\left(\frac{r_i^2-r_i+1}{r_i(1-r_i)}\right)w_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Does this make sense? If so, since we are talking about an interval &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt;, which point in that interval is going to be the value of &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Do we need to add another constraint as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{n}w_i=1,$$&lt;/span&gt;&#xA;so we guarantee that &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is in one of those intervals?&lt;/p&gt;&#xA;" OwnerDisplayName="user9659" LastActivityDate="2022-01-23T12:47:45.773" Title="Piece-wise linear approximation of a constraint" Tags="|mixed-integer-programming|modeling|linearization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7635" PostTypeId="2" ParentId="7634" CreationDate="2022-01-22T16:50:16.647" Score="4" Body="&lt;p&gt;Adding the last constraint is required to guarantee that only one of the &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; values is selected for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, you need an additional constraint to make the relationship between &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, its piecewise linearisation variables and the remaining of the problem constraints (especially &lt;span class=&quot;math-container&quot;&gt;$y=f(x)$&lt;/span&gt;), such as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y = \sum_{i=1}^{n} r_i \times w_i$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2599" LastEditorUserId="2599" LastEditDate="2022-01-23T12:47:45.773" LastActivityDate="2022-01-23T12:47:45.773" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7636" PostTypeId="2" ParentId="7634" CreationDate="2022-01-22T17:32:45.523" Score="3" Body="&lt;p&gt;I assume that &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is constrained to the interval &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt;. (You did not state this explicitly.) Let's assume that you have selected values &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$0=r_1 &amp;lt; r_2 &amp;lt; \dots &amp;lt; r_n = 1.$&lt;/span&gt; If your solver supports &lt;a href=&quot;https://en.wikipedia.org/wiki/Special_ordered_set#Types_of_SOS&quot; rel=&quot;nofollow noreferrer&quot;&gt;SOS2 constraints&lt;/a&gt;, you can make &lt;span class=&quot;math-container&quot;&gt;$w_1, \dots, w_n$&lt;/span&gt; nonnegative variables with the constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_i w_i = 1$&lt;/span&gt; and declare &lt;span class=&quot;math-container&quot;&gt;$\lbrace w_1,\dots,w_n\rbrace$&lt;/span&gt; to be a type 2 special ordered set (meaning at most two of them can be nonzero, and those two must be consecutive). Then set &lt;span class=&quot;math-container&quot;&gt;$y=\sum_i r_i w_i.$&lt;/span&gt; Your linearized formula for &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; can be left as is, with the value of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; given &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; being a weighted average of the &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; values at the endpoints of the interval containing &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How large to make &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is an empirical question. Larger &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; means a better approximation but may increase solution time.&lt;/p&gt;&#xA;&lt;p&gt;In choosing where to place the breakpoints &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt;, you might want to refer to a plot of (1) as &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; varies from 0 to 1. To get a better approximation of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, it usually helps to make the breakpoints denser in areas of steeper curvature and less dense where the graph is closer to being linear.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-22T17:32:45.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7637" PostTypeId="1" AcceptedAnswerId="7638" CreationDate="2022-01-23T03:11:48.603" Score="5" ViewCount="733" Body="&lt;p&gt;I was thinking about the Traveling Salesman Problem the other day - for such types of discrete combinatorial optimization problems, do they have a &amp;quot;loss function&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;It seems that there is some &amp;quot;vague&amp;quot; function which takes inputs as different combinations of cities, and returns the total distance traveled if these cities are visited in that order.&lt;/p&gt;&#xA;&lt;p&gt;Would this be (along with problems such as &amp;quot;scheduling&amp;quot;) considered as &amp;quot;gradient free optimization&amp;quot;?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-01-23T13:18:59.390" LastActivityDate="2022-01-23T16:20:35.183" Title="Is the Travelling Salesman Problem Considered as &quot;Gradient Free Optimization&quot;?" Tags="|optimization|combinatorial-optimization|traveling-salesman|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7638" PostTypeId="2" ParentId="7637" CreationDate="2022-01-23T16:20:35.183" Score="8" Body="&lt;p&gt;In no particular order ...&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I wouldn't call the objective function of the TSP &amp;quot;vague&amp;quot;. It is quite explicit.&lt;/li&gt;&#xA;&lt;li&gt;The term &amp;quot;gradient-free&amp;quot; applies to algorithms, not to problems. You might find yourself choosing between gradient-based and &amp;quot;gradient-free&amp;quot; algorithms for the same problem. The confusion may arise from the fact that you have to use a &amp;quot;gradient-free&amp;quot; algorithm when the problem's objective function does not have a gradient.&lt;/li&gt;&#xA;&lt;li&gt;The simplex method is gradient-based, so any TSP algorithm that involves solving an LP will not be &amp;quot;gradient-free&amp;quot;.&lt;/li&gt;&#xA;&lt;li&gt;The Nelder-Mead algorithm for nonlinear optimization (confusingly known as the &amp;quot;simplex algorithm&amp;quot;, but not &lt;em&gt;that&lt;/em&gt; &amp;quot;simplex algorithm&amp;quot;) is an example of a gradient-free algorithm.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-23T16:20:35.183" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7639" PostTypeId="1" CreationDate="2022-01-24T06:43:34.267" Score="10" ViewCount="2411" Body="&lt;p&gt;&lt;strong&gt;Are Metaheuristics and Evolutionary Algorithms the &amp;quot;Gold Standard&amp;quot; for the Traveling Salesman Problem?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am interested in learning more about how we have been able to solve the (famous) Traveling Salesman Problem for more and more cities as new developments in Combinatorial Optimization occurred over the years.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Does anyone know which algorithms are considered to be the more &amp;quot;successful&amp;quot; algorithms for solving the Traveling Salesman Problem in modern times?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Based on what I have been reading, it seems that Metaheuristics and Evolutionary Algorithms (e.g. Genetic Algorithm) seem to showing great results in versions of the Traveling Salesman Problems where the number of cities are large - but are there any other types of algorithms that are considered to be successful in modern times for &amp;quot;solving&amp;quot; the Traveling Salesman Problem?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="8963" LastEditDate="2022-01-24T20:51:42.813" LastActivityDate="2022-01-25T13:33:04.677" Title="Are Metaheuristics and Evolutionary Algorithms the &quot;Gold Standard&quot; for the Traveling Salesman Problem?" Tags="|optimization|combinatorial-optimization|traveling-salesman|metaheuristics|genetic-algorithm|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7640" PostTypeId="2" ParentId="7639" CreationDate="2022-01-24T07:13:35.053" Score="7" Body="&lt;p&gt;Take a look at the Concorde &lt;a href=&quot;https://www.math.uwaterloo.ca/tsp/concorde.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.math.uwaterloo.ca/tsp/concorde.html&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If it's a TSP problem, not a variant, Concorde can solve it and it is a beast.&lt;/p&gt;&#xA;&lt;p&gt;When you say &amp;quot;versions of the Travelling Salesman Problems where the number of cities are large&amp;quot;, around what value are you refering to with &amp;quot;large&amp;quot;?&lt;/p&gt;&#xA;" OwnerUserId="7634" LastActivityDate="2022-01-24T07:13:35.053" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7641" PostTypeId="2" ParentId="7639" CreationDate="2022-01-24T09:32:07.957" Score="22" Body="&lt;p&gt;The answer to the question is: No.&#xA;(Although one can debate what exactly is a &amp;quot;metaheuristic&amp;quot;)&lt;/p&gt;&#xA;&lt;p&gt;The &amp;quot;gold standard&amp;quot; for finding high quality feasible solutions for the TSP is the LKH (Lin-Kernighan-Helsgaun) heuristic described in this paper:&lt;/p&gt;&#xA;&lt;p&gt;K. Helsgaun (2000). &amp;quot;An Effective Implementation of the Lin-Kernighan Traveling Salesman Heuristic&amp;quot;. European Journal of Operational Research. 126 (1): 106–130.&lt;/p&gt;&#xA;&lt;p&gt;It is a way to implement the Lin-Kernighan heuristic which is probably best described as a local improvement heuristic where &amp;quot;local&amp;quot; is dynamically increased and adapted.&lt;/p&gt;&#xA;&lt;p&gt;The talk by Bill Cook linked above is a great overview for the TSP and his software to solve TSPs called Concorde: &amp;quot;The Traveling Salesman Problem: Postcards from the Edge of Impossibility&amp;quot; (&lt;a href=&quot;https://youtu.be/5VjphFYQKj8&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://youtu.be/5VjphFYQKj8&lt;/a&gt;). It also demonstrates that huge TSPs can be solved to proven optimality and even for very large problem instances we can nowadays find very, very good solutions.&lt;/p&gt;&#xA;&lt;p&gt;Just because we can't solve TSPs by brute force does not mean we can't solve TSPs at all. It depends a little on what you mean by &amp;quot;solve&amp;quot;, but Concorde can both find very good solutions very fast and prove optimality for amazingly large and practical data sets.&lt;/p&gt;&#xA;&lt;p&gt;To find solutions, Concorde uses the LKH heuristic and probably a collection of other heuristics some of which probably classify as metaheuristics or evolutionary. See the Concorde website for details on that: &lt;a href=&quot;https://www.math.uwaterloo.ca/tsp/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.math.uwaterloo.ca/tsp/index.html&lt;/a&gt; .&lt;/p&gt;&#xA;&lt;p&gt;To prove optimality, Concorde uses Linear Programming relaxations, cutting planes and branch-and-bound. That is the best approach to prove optimality for TSPs at the moment.&lt;/p&gt;&#xA;" OwnerUserId="302" LastEditorUserId="302" LastEditDate="2022-01-25T13:33:04.677" LastActivityDate="2022-01-25T13:33:04.677" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7642" PostTypeId="2" ParentId="7639" CreationDate="2022-01-24T19:55:30.787" Score="4" Body="&lt;p&gt;There's been a brilliant development in the Traveling Salesman problem recently leveraging neuromorphic computing. Essentially, neuromorphic chips contain a massive array of (often) physical neurons with dense local connections and some routing circuitry to transmit information to other arrays. In essence, each node or &amp;quot;city&amp;quot; is represented by a neuron and the strength of the synaptic connections between them represent distances. Current is injected into the &amp;quot;departure&amp;quot; neuron and its firing activity activates adjacent neurons at a rate according to those connection strengths. This continues until the &amp;quot;destination&amp;quot; neuron fires once, then synaptic activity can be traced backwards to reveal the path of least resistance.&lt;/p&gt;&#xA;&lt;p&gt;The brilliance of this solution comes from the fact that every path in the net can be checked simultaneously, and the way neurons communicate using sparse spiking is extremely power efficient. I can't remember the exact number sbut I believe Intel's Loihi 1 chip achieved solutions with 1000x less power and 10x reduced latency over GPU solutions. With Loihi 2 which was recently released to research communities, this efficiency likely increased a further 5-fold. Just imagine, with a human-brain sized network we could check 100 billion routes between 100 million cities in far less than a second with the energy cost of a potato chip!&lt;/p&gt;&#xA;" OwnerUserId="8965" LastActivityDate="2022-01-24T19:55:30.787" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7643" PostTypeId="1" CreationDate="2022-01-25T01:40:07.323" Score="4" ViewCount="241" Body="&lt;p&gt;In a typical VRPTW MIP formulation there are constraints that keep service at each node between node-specific lower and upper bounds. Using &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}$&lt;/span&gt; as a binary variable representing whether or not vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; travels from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w_{ik}$&lt;/span&gt; is a variable representing the starting time at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$s_{i}$&lt;/span&gt; is the service time at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a_{i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_{i}$&lt;/span&gt; are the lower and upper bounds for service at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$M_{ij}$&lt;/span&gt; is a large scalar. The time-consistency constraints are:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array} \\&#xA;w_{ik} + s_{i} + t_{ij} - w_{jk} \leq (1 - x_{ijk})M_{ij}  \\&#xA;w_{ik} \geq a_{i} \\&#xA;w_{ik} \leq b_{i}&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Such constraints keep service within the time windows. But if a vehicle arrives at the node before the lower bound, it waits at the node until it can start service. Can someone point me to constraints that will prevent a vehicle from going to the node if it will get there too early? For example, is there a way to constrain the system so that vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; will not arrive at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; until &lt;span class=&quot;math-container&quot;&gt;$a_{i}$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8933" LastActivityDate="2022-01-25T16:28:45.470" Title="VRPTW: is there a way to prevent waiting at a node before starting service?" Tags="|mixed-integer-programming|vehicle-routing|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7644" PostTypeId="2" ParentId="7643" CreationDate="2022-01-25T01:54:37.307" Score="4" Body="&lt;p&gt;IMHO, whether the vehicle arrives before &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; and waits there or takes a break a block away and then shows up right on time is a matter of execution rather than something that should be explicitly enforced in the optimization model.  Just tell the driver not to loiter at the node.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-01-25T01:54:37.307" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7645" PostTypeId="2" ParentId="7643" CreationDate="2022-01-25T05:02:48.277" Score="2" Body="&lt;p&gt;Have you tried considering it as a &lt;strong&gt;waiting_time_cost&lt;/strong&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Take a look at this work by Cordeau et al. &lt;a href=&quot;http://www.bernabe.dorronsoro.es/vrp/data/articles/VRPTW.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.bernabe.dorronsoro.es/vrp/data/articles/VRPTW.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;On page 23, on the &lt;strong&gt;Time- and Load-Dependent Costs section&lt;/strong&gt;, the authors explain how waiting_time / linear waiting cost can be taken into account. They also cite the work of Desaulniers, Lavigne, and Soumis from where they show their example.&lt;/p&gt;&#xA;" OwnerUserId="7634" LastActivityDate="2022-01-25T05:02:48.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7646" PostTypeId="2" ParentId="7643" CreationDate="2022-01-25T16:28:45.470" Score="1" Body="&lt;p&gt;While I agree with @RobPratt on this one, the following tweak to your model should work. Add a variable &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; representing the combination of service time at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and time spent loitering (somewhere) after serving location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Change your first constraint to &lt;span class=&quot;math-container&quot;&gt;$$w_{ik} + z_{i} + t_{ij} - w_{jk} \leq (1 - x_{ijk})M_{ij}$$&lt;/span&gt; and add the constraint &lt;span class=&quot;math-container&quot;&gt;$$w_{ik} + z_{i} + t_{ij} - w_{jk} \ge -(1 - x_{ijk})M_{ij},$$&lt;/span&gt; so that service at &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; starts exactly at arrival from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; follows &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Finally, add the constraint &lt;span class=&quot;math-container&quot;&gt;$$z_i \ge s_i$$&lt;/span&gt;to preclude negative loitering time. I think this does what you asked in a technical sense, although in practice it may just change the problem from loitering at &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; before service there to loitering at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; after service there.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-25T16:28:45.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7647" PostTypeId="1" CreationDate="2022-01-25T19:30:48.260" Score="0" ViewCount="243" Body="&lt;p&gt;I have an MILP problem with an objective of the type &lt;span class=&quot;math-container&quot;&gt;$\max z(x,g(x))= X - \varepsilon\cdot g(X)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt; is a penalty term determined through an iterative process. What I want is to find for a given &lt;span class=&quot;math-container&quot;&gt;$z(x,g(x))$&lt;/span&gt; the optimal solution (out of all the optimal solutions) that maximizes &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; (without interfering with &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;). All the above to be implemented in GUROBI using python.&lt;/p&gt;&#xA;" OwnerUserId="3467" LastEditorUserId="123" LastEditDate="2022-01-25T20:59:21.887" LastActivityDate="2022-01-26T15:14:58.817" Title="How to find an optimal solution (out of many optimal sols) of an MILP, which satisfies a condition (maximizes a variable) in GUROBI?" Tags="|mixed-integer-programming|gurobi|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7648" PostTypeId="2" ParentId="7647" CreationDate="2022-01-25T20:16:02.747" Score="2" Body="&lt;p&gt;I'm not a Gurobi user, but what you want to look at is their &amp;quot;solution pool&amp;quot; feature. If I understand the question, you want to set the solution pool to find as many solutions as possible within a tolerance of zero (or perhaps something close to zero) of the optimal value, subject to time limits etc. This is using &lt;span class=&quot;math-container&quot;&gt;$z(x,g(x))$&lt;/span&gt; as the objective function. Once Gurobi is done doing its thing, retrieve the solutions from the pool and retain only the solution(s) with maximal &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; value.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-25T20:16:02.747" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7650" PostTypeId="1" CreationDate="2022-01-26T07:40:27.533" Score="3" ViewCount="198" Body="&lt;p&gt;A few days ago, I was reading some articles/stackexchange posts on the &amp;quot;history and origins of optimization&amp;quot;. Somewhere, there was an interesting reference to a biblical/old testament story of &amp;quot;Moses Maimonides&amp;quot; making a coin based trade and trying to determine if he was cheated.&lt;/p&gt;&#xA;&lt;p&gt;I tried to search for this article/post again, but I could not find it.&lt;/p&gt;&#xA;&lt;p&gt;Has anyone ever heard of this before?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="81" LastEditDate="2022-01-27T10:50:17.330" LastActivityDate="2023-01-02T22:56:32.073" Title="Reference of Optimization in the Bible : Moses and Coins" Tags="|optimization|reference-request|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7651" PostTypeId="1" CreationDate="2022-01-26T07:45:12.980" Score="19" ViewCount="8357" Body="&lt;p&gt;Based on the plethora of advancements in optimization algorithms and computer technology that has occurred in the past 50 years - &lt;strong&gt;is Linear Programming today as &amp;quot;Powerful&amp;quot; and &amp;quot;Indispensable&amp;quot; as it was in the past?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Are there still some problems that can only be solved using Linear Programming Methods? Do we continue to teach and learn about Linear Programming for only for it's historical importance and basis/introduction to help in understanding modern optimization methods (e.g. &amp;quot;a stepping stone&amp;quot;) - or is that in certain types of problems, methods from Linear Programming style display some &amp;quot;attractive theoretical properties&amp;quot; (e.g. convergence), even in the face of modern optimization methods such as Quasi-Newton Methods, Stochastic Gradient Descent and Evolutionary Algorithms?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Even today, are there some problems that can be ONLY solved using methods from Linear Programming?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-01-26T12:55:27.490" LastActivityDate="2022-01-27T13:13:12.057" Title="Is Linear Programming as Useful as it was 50 Years Ago?" Tags="|linear-programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7652" PostTypeId="1" CreationDate="2022-01-26T07:55:00.957" Score="6" ViewCount="451" Body="&lt;p&gt;&lt;strong&gt;What Real Life Problems Motivated the Creation of the (Famous) Simplex Algorithm?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I was reading about the (famous) Simplex Algorithm :&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZmKOU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZmKOU.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; Were there any real world problems that people (e.g. Dantzig) were working on that required the an algorithm similar to the Simplex Algorithm ? Or was the Simplex Algorithm developed as an exercise in pure mathematics, with no real intended application in mind other than to demonstrate certain theoretical properties of functions?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.phpsimplex.com/en/simplex_method_example.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.phpsimplex.com/en/simplex_method_example.htm&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-01-26T12:54:43.640" LastActivityDate="2022-01-26T17:21:56.453" Title="History of the (Famous) Simplex Algorithm?" Tags="|optimization|linear-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7653" PostTypeId="2" ParentId="7652" CreationDate="2022-01-26T08:57:21.240" Score="4" Body="&lt;p&gt;You may refer to&lt;/p&gt;&#xA;&lt;p&gt;Dantzig, G.B., 2002. Linear Programming. Operations Research 50, 42–47. &lt;a href=&quot;https://doi.org/10.1287/opre.50.1.42.17798&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1287/opre.50.1.42.17798&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;in which Dantzig introduced &amp;quot;The Story About How It (LP) Began&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2022-01-26T08:57:21.240" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7654" PostTypeId="2" ParentId="7647" CreationDate="2022-01-26T09:43:31.300" Score="2" Body="&lt;p&gt;Assuming your iterative process happened prior to formulating the problem, simply maximizing it with Gurobi (assuming that Gurobi can solve it to global optimality) will deterministically provide the &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; point that provides the best value for your objective, since &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is not a variable in your problem.&lt;/p&gt;&#xA;&lt;p&gt;This seems a bit too straightforward though, so maybe I'm missing some nuance in your question that doesn't quite come through.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2022-01-26T15:14:58.817" LastActivityDate="2022-01-26T15:14:58.817" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7655" PostTypeId="2" ParentId="7651" CreationDate="2022-01-26T13:46:11.487" Score="33" Body="&lt;p&gt;Linear Programming is probably more useful than 50 years ago.&lt;/p&gt;&#xA;&lt;p&gt;The software for solving linear programming problems has dramatically improved and more and more practical problems can be solved. Most of these practical problems are mixed integer linear programs (MILPs), but linear programming is integral to solving MILPs.&lt;/p&gt;&#xA;&lt;p&gt;To support this statement, here a few indicators:&lt;/p&gt;&#xA;&lt;p&gt;The airline industry heavily uses mathematical optimization for solving problems such as pairing optimization and crew scheduling. The same is true for public transport. The existence of companies like &lt;a href=&quot;https://www.sabre.com/&quot; rel=&quot;noreferrer&quot;&gt;Sabre&lt;/a&gt; and &lt;a href=&quot;https://www.optibus.com/&quot; rel=&quot;noreferrer&quot;&gt;Optibus&lt;/a&gt; testifies to that.&lt;/p&gt;&#xA;&lt;p&gt;The best way to find provably optimal solutions to the traveling salesman problems is based on linear programming: &lt;a href=&quot;https://www.math.uwaterloo.ca/tsp/concorde.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.math.uwaterloo.ca/tsp/concorde.html&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Companies that focus on mathematical optimization with linear programming at their core are thriving, for example &lt;a href=&quot;https://www.gurobi.com/&quot; rel=&quot;noreferrer&quot;&gt;Gurobi&lt;/a&gt;. Meanwhile, new competitor enter the market for mathematical optimization, specifically linear programming using the simplex algorithm, such as &lt;a href=&quot;https://www.shanshu.ai/copt/&quot; rel=&quot;noreferrer&quot;&gt;COPT&lt;/a&gt;, &lt;a href=&quot;https://solver.damo.alibaba.com/htmlpages/page#/en&quot; rel=&quot;noreferrer&quot;&gt;MindOpt&lt;/a&gt;, and &lt;a href=&quot;https://www.huaweicloud.com/product/modelarts/optverse.html&quot; rel=&quot;noreferrer&quot;&gt;Huawei&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Google has increased interest in linear and integer programming, including having their own linear programming solver &lt;a href=&quot;https://developers.google.com/optimization/lp&quot; rel=&quot;noreferrer&quot;&gt;GLOP&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Amazon is looking for people with skills in linear optimization: &lt;a href=&quot;https://www.amazon.jobs/de/jobs/1716646/research-scientist&quot; rel=&quot;noreferrer&quot;&gt;https://www.amazon.jobs/de/jobs/1716646/research-scientist&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="302" LastEditorUserId="279" LastEditDate="2022-01-27T13:13:12.057" LastActivityDate="2022-01-27T13:13:12.057" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7656" PostTypeId="2" ParentId="7652" CreationDate="2022-01-26T17:21:56.453" Score="2" Body="&lt;p&gt;In Dantzig, G.B., 2002. Linear Programming. Operations Research 50, 42–47. &lt;a href=&quot;https://doi.org/10.1287/opre.50.1.42.17798&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/opre.50.1.42.17798&lt;/a&gt;, Dantzig states that his research was &amp;quot;in connection with the planning activities of the military.&amp;quot; He was asked &amp;quot;to find a way to more rapidly compute a time-staged deployment, training and logistical supply program.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;However, Dantzig worked with both economists and mathematicians. An interaction with Von Neumann, in particular, connected Dantzig's research with Von Neumann and Oscar Morgenstern on game theory.&lt;/p&gt;&#xA;&lt;p&gt;He states that his research started in 1947, and the first commercial application (&amp;quot;optimal blending of petroleum products to make gasoline&amp;quot;) was in 1952.&lt;/p&gt;&#xA;" OwnerUserId="8977" LastActivityDate="2022-01-26T17:21:56.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7657" PostTypeId="1" CreationDate="2022-01-26T19:00:21.870" Score="7" ViewCount="1526" Body="&lt;p&gt;I have a question that has been bothering me for a while:&lt;/p&gt;&#xA;&lt;p&gt;In our OR-introduction course, we introduce the concept of Dynamic Programming via backward recursion: Working backwards from a final state (at the final stage), until we have have reached a single initial state in stage 0. Introducing Dynamic Programming via backward recursion also seems to be the status quo in the textbooks.&lt;/p&gt;&#xA;&lt;p&gt;However, these problems (for example: shortest path problems) can also be solved via forward recursion.&lt;/p&gt;&#xA;&lt;p&gt;Why is it claimed then, that &amp;quot;backward recursion&amp;quot; usually performs faster than forward recursion? In the small &amp;quot;toy&amp;quot; problems that we address in the lecture, using either forward or backward recursion does not make a difference in the number of calculations that we do.&lt;/p&gt;&#xA;&lt;p&gt;Especially coming from Dijkstra's Algorithm (which we introduce first) a more intuitive way would be to move through the network (and accordingly the different stages) in a forward fashion.&lt;/p&gt;&#xA;&lt;p&gt;Note that these problems involve a specific known start state and a specific known end state and no uncertainty.&lt;/p&gt;&#xA;&lt;p&gt;Also: When claiming that backward recursion executes faster: When I &amp;quot;reverse&amp;quot; the shortest-path-problem instance network [meaning: I come up with a problem instance that just interchanges start and finish node and the edges accordingly], then this would be the same as forward recursion of the original problem.&lt;/p&gt;&#xA;&lt;p&gt;I have also taken a look at the following discussion, however I found the answers not very helpful / satisfactory: &lt;a href=&quot;https://stackoverflow.com/questions/23525603/why-does-backward-recursion-execute-faster-than-forward-recursion-in-python&quot;&gt;Stackexchange Discussion DP&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Does this generally have to do with &amp;quot;keeping track of infeasible states&amp;quot; that we can only discard very late in the algorithm depending on whether we do forward or backward recursion?&lt;/p&gt;&#xA;" OwnerUserId="6082" LastEditorUserId="491" LastEditDate="2022-01-27T16:39:28.667" LastActivityDate="2022-01-27T16:39:28.667" Title="Efficiency of Forward vs. Backward Recursion in Dynamic Programming" Tags="|dynamic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7658" PostTypeId="2" ParentId="7657" CreationDate="2022-01-26T21:06:52.063" Score="5" Body="&lt;p&gt;First, what is Dynamic Programming? Everyone has its own definition. The one I use is &amp;quot;Solving a problem recursively, while storing the results of the sub-problems to avoid recomputing them multiple times&amp;quot;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Then, to exhibit a Dynamic Programming structure of a problem, the classical way is to find a recursive formula. Usually, it is more natural to write it the backward way.&lt;/p&gt;&#xA;&lt;p&gt;For example, consider a shortest path problem between vertex &lt;span class=&quot;math-container&quot;&gt;$v_s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v_t$&lt;/span&gt; on a directed acyclic graph &lt;span class=&quot;math-container&quot;&gt;$G = (V, A)$&lt;/span&gt; with distance &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$c(v)$&lt;/span&gt; be the length of the shortest path to reach vertex &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; from vertex &lt;span class=&quot;math-container&quot;&gt;$v_s$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We have the following recursive formula:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c(v) = \left\{ \begin{array}{ll}&#xA;0 &amp;amp; \text{if $v = v_s$} \\&#xA;\min\limits_{u \in \cal{N}^-(v)} c(u) + d_{u,v} &amp;amp; \text{otherwise}&#xA;\end{array} \right.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The value we are looking for is obviously &lt;span class=&quot;math-container&quot;&gt;$c(v_t)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Of course, it is possible to write it in the other direction. But it generally feels more natural this way.&lt;/p&gt;&#xA;&lt;p&gt;My advice is, if you plan to implement a Dynamic Programming algorithm, &lt;strong&gt;write the recursive formula first&lt;/strong&gt; on a paper before starting writing code, and clearly explicit the meaning of the objective.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Finally, &lt;strong&gt;once one has the recursive formula&lt;/strong&gt;, comes the implementation. There are several ways to implement the recursive formula:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Directly implementing the corresponding recursive function&lt;/li&gt;&#xA;&lt;li&gt;Computing all states iteratively&lt;/li&gt;&#xA;&lt;li&gt;Using list of states&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Directly implementing the corresponding recursive function is the easiest way. One just needs to write a programming recursive function which first checks if the requested value has already been stored, and otherwise compute it and store it.&lt;/p&gt;&#xA;&lt;p&gt;Pseudo-code for the example above:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;def rec(v):&#xA;    if memory[v] is None:&#xA;        if v == vs:&#xA;            memory[v] = 0&#xA;        else:&#xA;            memory[v] = min(rec(u) + G.distance(u, v),&#xA;                            for u in G.predecessors(v))&#xA;    return memory[v]&#xA;&#xA;memory = [None] * G.number_of_vertices()&#xA;rec(vt)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Computing all states iteratively requires to think a bit more. One needs to find the right order in which to compute the states. But this implementation is usually much faster. From my experience, I'd say that one can expect it to be about &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; times faster than the recursive implementation. The reason behind this is not mathematical, but rather related to how cache works inside the computer: it's faster to access data which are stored next to each other in memory. You can find some experimental results for the Knapsack Problem &lt;a href=&quot;https://github.com/fontanf/knapsacksolver#dynamic-programming-recursive-vs-iterative-implementation&quot; rel=&quot;nofollow noreferrer&quot;&gt;on my Github&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Pseudo-code for the example above:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;memory = [None] * G.number_of_vertices()&#xA;vertices = G.vertices_sorted_in_topological_order()&#xA;memory[vs] = 0&#xA;for v in vertices:&#xA;    memory[v] = min(memory[u] + G.distance(u, v),&#xA;                    for u in G.predecessors(v))&#xA;memory[vt]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Using list of states is a bit more tricky, and it might not work in all cases. But when it works, it is usually the most efficient way, because it can be combined with other technics such as bounding. It is usually how state-of-the-art algorithms are implemented.&lt;/p&gt;&#xA;&lt;p&gt;More details about these implementations can be found in:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Kellerer H, Pferschy U, Pisinger D (2004) Knapsack Problems. Springer Berlin Heidelberg, Berlin, Heidelberg &lt;a href=&quot;https://link.springer.com/book/10.1007/978-3-540-24777-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/book/10.1007/978-3-540-24777-7&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;2 additional notes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The question you linked is not about Dynamic Programming, since there is no memorization.&lt;/li&gt;&#xA;&lt;li&gt;It is not obvious to consider Dijkstra's algorithm as Dynamic Programming. The example I gave is Bellman algorithm for the shortest path problem in a directed acyclic graph (with possibly negative weights), which is clearly Dynamic Programming.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2022-01-27T14:39:40.753" LastActivityDate="2022-01-27T14:39:40.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7659" PostTypeId="2" ParentId="7651" CreationDate="2022-01-26T21:43:11.933" Score="6" Body="&lt;p&gt;There was very big progress in commercial solvers like cplex or gurobi over last 30 years. So there are problems that were not solvable before but can be solved today.&lt;/p&gt;&#xA;&lt;p&gt;On other side especially in integer domain we can use direct alternatives like sat or constraint solvers that can solve same problem with different approaches. Sat solvers use often learning, constraint solvers have greater expresivity of a model and very powerful global constraints. There are actually problem domains like scheduling where LP/MIP solvers aren't competitive with the alternatives.&lt;/p&gt;&#xA;&lt;p&gt;Related to your mentioned optimization methods I can talk only about evolutionary algorithms. From my experience they are not performance comparable in solvable problems with a lot of constraints.&lt;/p&gt;&#xA;" OwnerUserId="4412" LastActivityDate="2022-01-26T21:43:11.933" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7660" PostTypeId="1" CreationDate="2022-01-26T22:14:11.900" Score="4" ViewCount="280" Body="&lt;p&gt;I have the following question that compares how &amp;quot;Sensitivity Analysis&amp;quot; is perceived in the field of Optimization compared to that of Machine Learning.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Sensitivity Analysis in Machine Learning:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;At the core of every successful Machine Learning model is an underlying optimization problem that was successfully handled: For an individual problem (e.g. a computer playing chess), the final (data based) Machine Learning model that is actually used to make predictions (e.g. what piece to move next) in the real world, is &amp;quot;optimally fine tuned&amp;quot; using an optimization algorithm (e.g. Gradient Descent).&lt;/p&gt;&#xA;&lt;p&gt;In Machine Learning, a well-documented concept exists called the &lt;strong&gt;&amp;quot;Bias-Variance Tradeoff&amp;quot;&lt;/strong&gt;, which brings up the idea that &amp;quot;a good solution to an optimization problem might not be as good in the future - thus, we might be able to &amp;quot;strategically&amp;quot; find a relatively worse solution that as a result might be perform better in the future&amp;quot;. This process of &amp;quot;strategically finding a relatively worse solution to the optimization problem&amp;quot; is called &lt;strong&gt;Regularization&lt;/strong&gt; , and is achieved by adding a &amp;quot;Norm Penalty Term&amp;quot; to the objective function (corresponding to the Machine Learning model) being optimized:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/V3T1b.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/V3T1b.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Doing this above process (i.e. Regularization) is said to make the solution (i.e. the Machine Learning model) &lt;strong&gt;&amp;quot;less sensitive&amp;quot;&lt;/strong&gt; to deviations in future conditions compared to the initial conditions corresponding to the initial conditions in which the optimization problem was first solved (in this case, &amp;quot;high sensitivity&amp;quot; is associated with &amp;quot;high variance&amp;quot; : an ideal Machine Learning model has Low Bias and Low Variance).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; In the field of Optimization, are any Statistical/Machine Learning based techniques (similar to Regularization) that are used to preemptively guard solutions from optimization problems against &amp;quot;high sensitivity&amp;quot; - and thus ensure that the optimization solutions are &amp;quot;robust&amp;quot; and successfully pass &amp;quot;sensitivity analysis&amp;quot; tests?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Regularization_(mathematics)&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Regularization_(mathematics)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Bias%E2%80%93variance_tradeoff&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Bias%E2%80%93variance_tradeoff&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In Machine Learning, we almost never have a &amp;quot;deterministic objective function&amp;quot; and instead almost always have a &amp;quot;stochastic deterministic function&amp;quot; - that is, we have random measurements (e.g. these measurements might contain errors) corresponding to the function that we want to optimize (not the exact function). This means that there is an inherent stochastic/probabilistic component to Machine Learning optimization problems, and we are generally trying to optimize the &amp;quot;probabilistic expectation&amp;quot; of the objective function. Thus, Machine Learning optimization problems are always considered to be &amp;quot;noisy&amp;quot; and inherently like to display volatile behavior in future conditions - making the role of &amp;quot;sensitivity analysis&amp;quot; even more important in Machine Learning optimization problems.&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-01-28T14:12:32.200" LastActivityDate="2022-01-28T14:12:32.200" Title="&quot;Sensitivity Analysis&quot; vs. &quot;Machine Learning&quot;" Tags="|optimization|sensitivity-analysis|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7661" PostTypeId="1" CreationDate="2022-01-27T01:12:51.843" Score="6" ViewCount="1023" Body="&lt;p&gt;In the field of Optimization and Operations Research : &lt;strong&gt;Are there &amp;quot;Types&amp;quot; any Problems where Evolutionary Algorithms (significantly) Outperform Non-Evolutionary Algorithms?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For instance:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Advancements in Machine Learning has shown us that problems that have differentiable &amp;quot;objective functions&amp;quot; (i.e. the function being optimized) - even in instances where these &amp;quot;objective functions&amp;quot; are high dimensional, non-convex, complex and noisy - they are generally best handled using some variant of the Gradient Descent Algorithm.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;However, there are still some cases that even when the &amp;quot;objective function&amp;quot; is differentiable - if for some reason evaluating derivatives of the &amp;quot;objective function&amp;quot; are quite time consuming (e.g. high dimensional functions), Evolutionary Algorithms (e.g. Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing) offer advantages in such instances.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Advancements in Machine Learning has also shown us that Evolutionary Algorithms are sometimes preferred for certain types problems such as &amp;quot;games&amp;quot;, in which optimal strategies are developed by mutating and combining random strategies according to their performance with respect to some target (e.g. &lt;a href=&quot;https://en.wikipedia.org/wiki/Neuroevolution_of_augmenting_topologies&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Neuroevolution_of_augmenting_topologies&lt;/a&gt; , &lt;a href=&quot;https://www.youtube.com/watch?v=OGHA-elMrxI&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=OGHA-elMrxI&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In the case of discrete combinatorial optimization problems (where the &amp;quot;objective function&amp;quot; is non-differentiable), Evolutionary Algorithms still offer strong advantages.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; With all this being said, are there any particular &amp;quot;types&amp;quot; of problems where Evolutionary Algorithms are considered the &amp;quot;gold standard&amp;quot; for optimizing? Or in general, are there no such &amp;quot;types&amp;quot; of problems where Evolutionary Algorithms present clear advantages?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-01-28T04:21:20.007" LastActivityDate="2022-01-28T04:21:20.007" Title="&quot;Types&quot; of Problems where Evolutionary Algorithms (significantly) Outperform Non-Evolutionary Algorithms" Tags="|optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7662" PostTypeId="2" ParentId="7661" CreationDate="2022-01-27T04:09:47.983" Score="9" Body="&lt;p&gt;I don't think that there are any particular problem types where evolutionary algorithms are known to outperform all other metaheuristics or problem-specific heuristics. Looking specifically at genetic algorithms, I seem to recall reading a paper by David Goldberg in the 1980s (when GAs were fairly new) in which he stressed the importance of defining chromosomes in a way that makes it likely that crossover operations on pairs of good solutions will retain a significant amount of what makes them good. (I'm paraphrasing here, so any sloppiness is my fault, not his.) That may make GAs poor choices for some problems, either because there is no good way to express solutions as chromosomes (which I suspect would be difficult to prove) or because there is no &lt;em&gt;obvious&lt;/em&gt; good way to do it (meaning the user is likely to use a representation that more or less reduces the GA to random search).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-27T04:09:47.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7663" PostTypeId="2" ParentId="7660" CreationDate="2022-01-27T05:53:04.247" Score="3" Body="&lt;p&gt;&lt;strong&gt;Machine Learning:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Firstly, sensitivity analysis on Machine Learning models goes way beyond the Bias-Variance tradeoff.&lt;/p&gt;&#xA;&lt;p&gt;Sensitivity analysis of a Machine Learning model is done mainly to see how the changes in input affect the change in output. To do that, we may change one input while keeping the others constant. Generally, they are kept at the median for this analysis. This in turn gives a good idea about the uncertainty associated with the ML model and makes the models more interpretable which helps us in extracting 'Business values' from the model.&lt;/p&gt;&#xA;&lt;p&gt;In real life, sensitivity analysis will help convey the model results to the stakeholders so they can focus on the main parameters of the model.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Optimization/Mathematical Modelling:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The theory of sensitivity analysis is well known. I am highlighting the 'robust' part here.&lt;/p&gt;&#xA;&lt;p&gt;If you're forming a MILP or LP to solve an optimization problem then it will be robust 90% of the time (speaking from my experience). But when they are not, you can add several constraints (or may remove several depending upon the situation) to make them robust.&lt;/p&gt;&#xA;&lt;p&gt;Most heuristics and meta-heuristics work by defining the 'neighborhood'. If you can define them in an elegant way, depending upon the problem, it will be robust.&lt;/p&gt;&#xA;" OwnerUserId="5532" LastActivityDate="2022-01-27T05:53:04.247" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7664" PostTypeId="1" AcceptedAnswerId="7668" CreationDate="2022-01-27T15:49:08.660" Score="1" ViewCount="1740" Body="&lt;p&gt;I am using pyomo with gurobi (and other solvers) to solve some optimization programs.&#xA;Sometimes these programs don't have a solution and throw an error such as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;WARNING: Loading a SolverResults object with a warning status into&#xA;    model.name=&amp;quot;unknown&amp;quot;;&#xA;      - termination condition: infeasible&#xA;      - message from solver: Model was proven to be infeasible.&#xA;ERROR: evaluating object as numeric value: x[0]&#xA;        (object: &amp;lt;class 'pyomo.core.base.var._GeneralVarData'&amp;gt;)&#xA;    No value for uninitialized NumericValue object x[0]&#xA;ERROR: evaluating object as numeric value: objective&#xA;        (object: &amp;lt;class 'pyomo.core.base.objective.SimpleObjective'&amp;gt;)&#xA;    No value for uninitialized NumericValue object x[0]&#xA;&#xA;...&#xA;&#xA;  File &amp;quot;pyomo\core\expr\numvalue.pyx&amp;quot;, line 246, in pyomo.core.expr.numvalue.value&#xA;  File &amp;quot;pyomo\core\expr\numvalue.pyx&amp;quot;, line 233, in pyomo.core.expr.numvalue.value&#xA;ValueError: No value for uninitialized NumericValue object x[0]&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In this case, I would like to run a simpler program without some of the constraints, so something like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solve program&#xA;if program doesn't have a solution:&#xA;   solve simpler program &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How could I do this?&lt;/p&gt;&#xA;" OwnerUserId="8723" LastActivityDate="2022-01-27T19:19:06.033" Title="Pyomo: Check if solution exists and if not solve other problem" Tags="|python|gurobi|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7665" PostTypeId="1" AcceptedAnswerId="7666" CreationDate="2022-01-27T16:57:16.273" Score="4" ViewCount="201" Body="&lt;p&gt;I'm currently in the process of learning about column generation, so I apologize in advance if I show a gross lack of understanding about it.&lt;/p&gt;&#xA;&lt;p&gt;Anyways, what I've gathered so far is that Column Generation approaches typically run faster than standard MIP formulation algorithms because you are not calculating the reduced cost of all non-basic variables every iteration of the simplex; rather, you are solving a minimization problem on a polytope to find the non-basic variable with the smallest reduced cost.&lt;/p&gt;&#xA;&lt;p&gt;The part that is confusing me is that it seems like CG is also advertised to have a &amp;quot;simpler&amp;quot; feasible region in the reformulation which would aid in runtimes. However, aren't we simply doing all the hard work of enumerating the new variables in the beginning? For instance, when reformulating the cutting stock problem, you must enumerate all possible cutting patterns which would itself take time. Are we sure that this doesn't take more time than solving over the original formulation which also guarantees only valid patterns would be cut? In other words, are we sure that the time saved from not calculating every reduced cost, every iteration of the simplex, and solving on a &amp;quot;simpler&amp;quot; feasible region for the reformulation actually saves more time than the time spent enumerating the new variables?&lt;/p&gt;&#xA;&lt;p&gt;I think I may be missing something here, but every example of CG I've seen so far glosses over how they create the new variables and just how much time that would take.&lt;/p&gt;&#xA;" OwnerUserId="8988" LastEditorUserId="491" LastEditDate="2022-01-28T04:22:27.917" LastActivityDate="2022-01-28T04:22:27.917" Title="How do you know if Column Generation is any faster than standard MIP formulations?" Tags="|mixed-integer-programming|integer-programming|column-generation|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7666" PostTypeId="2" ParentId="7665" CreationDate="2022-01-27T17:16:02.143" Score="4" Body="&lt;p&gt;&amp;quot;are we sure that the time saved from not calculating every reduced cost, every iteration of the simplex, and solving on a &amp;quot;simpler&amp;quot; feasible region for the reformulation actually saves more time than the time spent enumerating the new variables?&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;The answer is no. You can come up with, admittedly stupid, column generation procedures, where the subproblem is the problem itself. Hence, nothing would be gained. Loosely speaking, the entire procedure is a careful trade off between strong bounds from the master as a result of difficult subprobelms and not so strong bounds as a result of easier subprolems.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-01-27T17:16:02.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7667" PostTypeId="2" ParentId="7661" CreationDate="2022-01-27T18:55:59.657" Score="6" Body="&lt;p&gt;&lt;strong&gt;They are currently used where &amp;quot;the best&amp;quot; is still under debate.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.researchgate.net/publication/272017132_Genetic_Programming_with_Alternative_Search_Drivers_for_Detection_of_Retinal_Blood_Vessels&quot; rel=&quot;nofollow noreferrer&quot;&gt;This paper&lt;/a&gt; about detecting blood vessels in the eye is a good example.  I'm heavily simplifying but there are multiple fitness functions used since there is no agreement on what &amp;quot;the best&amp;quot; is.  Of all the algorithms you mentioned, genetic algorithms would likely be the easiest to adapt to use multiple fitness functions.&lt;/p&gt;&#xA;&lt;p&gt;As for it being the &amp;quot;gold standard&amp;quot; anywhere - problems that are fuzzy generally don't have gold-standards.  It'll always be - good enough until we understand more.  If you can articulate &amp;quot;the best&amp;quot; then there are much faster ways of finding a good functional fit.  As you point out, game AI tends to be a popular choice - likely because luck plays some role in almost all games.&lt;/p&gt;&#xA;&lt;p&gt;They also are a black box, and there is no certainty they found the best or even the right answer.  From a business perspective people in charge like to have better answers than &amp;quot;the computer said it was right.&amp;quot;&lt;/p&gt;&#xA;" OwnerUserId="3544" LastEditorUserId="3544" LastEditDate="2022-01-27T22:27:05.867" LastActivityDate="2022-01-27T22:27:05.867" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7668" PostTypeId="2" ParentId="7664" CreationDate="2022-01-27T19:19:06.033" Score="4" Body="&lt;p&gt;From &lt;a href=&quot;http://www.pyomo.org/blog/2015/1/8/accessing-solver&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo's website&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.opt import SolverStatus, TerminationCondition&#xA;&#xA;…&#xA;&#xA;results = opt.solve(instance) # Solving a model instance  &#xA;instance.load(results) # Loading solution into results object&#xA;&#xA;if (results.solver.status == SolverStatus.ok) and (results.solver.termination_condition == TerminationCondition.optimal):&#xA;    # Do something when the solution in optimal and feasible&#xA;elif (results.solver.termination_condition == TerminationCondition.infeasible):&#xA;    # Do something when model in infeasible&#xA;else:&#xA;    # Something else is wrong&#xA;    print “Solver Status: ”,  result.solver.status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But be careful, because you want to ensure that your simpler model doesn't return an infeasible solution too.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2022-01-27T19:19:06.033" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7669" PostTypeId="2" ParentId="3183" CreationDate="2022-01-27T19:41:12.827" Score="-1" Body="&lt;p&gt;If I understand correctly and you want a primal-dual formulation of the lower-level problem you may want to consider that:&#xA;DG (duality gap)= cX-bλ (primal obj.- dual obj.). Given that, your problem can be equivalently written as:&#xA;min DG&#xA;s.t. primal constraints,&#xA;dual(of the relaxed primal) constraints,&#xA;z in {0,1}&lt;/p&gt;&#xA;" OwnerUserId="3467" LastActivityDate="2022-01-27T19:41:12.827" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7670" PostTypeId="1" AcceptedAnswerId="7673" CreationDate="2022-01-28T03:43:36.600" Score="2" ViewCount="361" Body="&lt;p&gt;I'm currently using Gurobi in python and trying to add a constraint that the variable will not equal to 0 at the same time, say &lt;code&gt;a != 0 or b != 0&lt;/code&gt;, both a and b can be negative or positive. But I can't find a proper way to add this constraint. Does anyone have idea about this?&lt;/p&gt;&#xA;&lt;p&gt;Edit: The problem I'm trying to solve is to find the proper plane that has the smallest distances in summation for a list of points. The equation I used is &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=0}^n \frac{|Ax_{i} + By_{i} + Cz_{i} + D|}{\sqrt{A^2 + B^2 + C^2}}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_{i}, y_{i}, z_{i}$&lt;/span&gt; refer to the point, A,B,C,D refer to the plane equation Ax + By + Cz + D = 0, and thus A,B,C cant be 0 at the same time.&lt;/p&gt;&#xA;" OwnerUserId="8993" LastEditorUserId="38" LastEditDate="2022-01-28T13:24:42.253" LastActivityDate="2022-01-28T16:28:59.113" Title="Gurobi add constraint which two variables cant be zero at the same time" Tags="|gurobi|logical-constraints|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7671" PostTypeId="1" CreationDate="2022-01-28T06:42:18.153" Score="2" ViewCount="468" Body="&lt;p&gt;Does anyone know what is meant by &amp;quot;Noisy Optimization&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;Typically, I always thought that &amp;quot;Noise&amp;quot; refers to &amp;quot;unwanted signals&amp;quot; that distort the data/function that you are studying - in many applications (e.g. signal processing, electrical engineering, time series, etc.), we are interested &amp;quot;de-noising&amp;quot; our data (i.e. removing the &amp;quot;noise&amp;quot; from the &amp;quot;true signal&amp;quot;):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dhGFV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dhGFV.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, in the context of optimization, I am not sure if &amp;quot;noisy optimization&amp;quot; refers to this, or whether it refers to something else. For instance, I have been told that in the context of Machine Learning, &amp;quot;noisy optimization&amp;quot; refers to optimizing a &amp;quot;noisy function&amp;quot; - that is, when you don't have the &amp;quot;exact deterministic form&amp;quot; of the function you want to optimize, but rather a series of measurements belonging to this function.&lt;/p&gt;&#xA;&lt;p&gt;On principle, it is impossible in many practical settings to obtain the &amp;quot;exact deterministic form&amp;quot; of the function, and you only have discrete measurements belonging to this function - and these measurements can contain &amp;quot;noise&amp;quot;. That means, if you were to record the same measurements again, the measurements may be different each time you record them.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt;  Have I correctly described what &amp;quot;Noisy Optimization&amp;quot; is? I am assuming that &amp;quot;Noisy Optimization Problems&amp;quot; was one of the reasons that &amp;quot;Evolutionary Algorithms&amp;quot; were first created, and that they continue to perform well on such problems (compared to Non-Evolutionary Problems)?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://sigopt.com/blog/uncertainty-2-bayesian-optimization-with-uncertainty/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://sigopt.com/blog/uncertainty-2-bayesian-optimization-with-uncertainty/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I always wondered if theoretical convergence results could ever be established for optimization algorithms on &amp;quot;noisy functions&amp;quot; - but I am not sure if this is possible, seeing that this would largely depend on how &amp;quot;noisy&amp;quot; the function (i.e. quality of data) is.&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-01-28T14:11:12.130" LastActivityDate="2022-01-28T14:11:12.130" Title="What is meant by &quot;Noisy Optimization&quot;?" Tags="|optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7673" PostTypeId="2" ParentId="7670" CreationDate="2022-01-28T16:28:59.113" Score="6" Body="&lt;p&gt;There's a trick I sometimes use in situations like this. First, you need to confirm that for any optimal solution &lt;span class=&quot;math-container&quot;&gt;$(A, B, C, D)$&lt;/span&gt; and any scalar &lt;span class=&quot;math-container&quot;&gt;$\lambda \neq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\lambda\cdot (A, B, C, D)$&lt;/span&gt; is also optimal. It obviously selects the same plane, so chances are good this will hold.&lt;/p&gt;&#xA;&lt;p&gt;Assuming it does, generate a random vector &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; distributed uniformly over &lt;span class=&quot;math-container&quot;&gt;$[-1, 1]^3$&lt;/span&gt; and add the constraint &lt;span class=&quot;math-container&quot;&gt;$\alpha_1 A + \alpha_2 B + \alpha_3 C = 1$&lt;/span&gt; to the model. This obviously rules out &lt;span class=&quot;math-container&quot;&gt;$A = B = C = 0$&lt;/span&gt;. For any optimal &lt;span class=&quot;math-container&quot;&gt;$(A, B, C)$&lt;/span&gt; for which the left side is not zero, we can by assumption multiply by a constant to get another optimal solution that sums to 1. So the only potential issue is whether the optimal solution might have inner product 0 with &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;. Since we chose &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; using a continuous distribution over a region with positive volume, that has probability zero of occurring. So unless you are living under a curse, this ought to work.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-28T16:28:59.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7675" PostTypeId="1" CreationDate="2022-01-28T18:23:13.143" Score="3" ViewCount="195" Body="&lt;p&gt;Sorry if this is really easy for you gurus. I'm trying to derive the reformulation of a weighted least square regression to a quadratic programming form. I understand there is a closed form solution under some assumptions. Just to clarify, it's not a homework question, it's a reduced form of a bigger problem faced in work. Tried to google but didn't find detailed steps.&lt;/p&gt;&#xA;&lt;p&gt;More specifically, the weighted least square regression is &lt;span class=&quot;math-container&quot;&gt;$min_{f} ||W(Xf-r)||^2$&lt;/span&gt; and the QP form is just the standard form&#xA;&lt;a href=&quot;https://i.stack.imgur.com/SZnVA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SZnVA.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I've made some derivation as shown at bottom. I think I got &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; but I'm not sure about &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; due to the &lt;span class=&quot;math-container&quot;&gt;$f^T$&lt;/span&gt; in the second term. Can you suggest if my &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is right and also how to get &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BIl1l.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BIl1l.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6060" LastEditorUserId="491" LastEditDate="2022-01-29T16:37:01.240" LastActivityDate="2022-01-29T16:37:01.240" Title="Translate standard weighted least square regression to quadratic programming" Tags="|quadratic-programming|regression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7676" PostTypeId="2" ParentId="7675" CreationDate="2022-01-28T19:01:20.180" Score="2" Body="&lt;p&gt;Yes, your matrix &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is right. Note that &lt;span class=&quot;math-container&quot;&gt;$f^{\top} X^{\top} W^{\top} W r$&lt;/span&gt; is scalar and the transpose of a scalar is just the scalar itself, i.e.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f^{\top} X^{\top} W^{\top} W r = (f^{\top} X^{\top} W^{\top} W r)^{\top} = (X^{\top} W^{\top} W r)^{\top} f = r^{\top} W^{\top} W X f&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and thus&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;q^{\top} f = -f^{\top} X^{\top} W^{\top} W r - r^{\top} W^{\top} W X f = -2r^{\top} W^{\top} W X f.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So we have &lt;span class=&quot;math-container&quot;&gt;$q = -2(r^{\top} W^{\top} W X)^{\top} = -2X^{\top}W^{\top}W r$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="3696" LastEditDate="2022-01-28T20:27:43.013" LastActivityDate="2022-01-28T20:27:43.013" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7677" PostTypeId="1" CreationDate="2022-01-28T20:33:56.940" Score="2" ViewCount="104" Body="&lt;p&gt;First of all, thanks for the help in previous post. The problem I'm facing is some legacy codes used Lagrange multipliers to solve a weighted regression problem. New requirements changed and I'm trying to understand how the old one worked.&lt;/p&gt;&#xA;&lt;p&gt;More specifically, the problem is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_f&amp;amp;\quad\| W(Xf-r)\|^2\\\text{s.t.}&amp;amp;\quad A^\top f=0.\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm trying to reproduce the derivation using Lagrange multiplier but I'm far off. The numerical results from legacy calculation are reasonable. So, I guess there must be something I derived wrong.&lt;/p&gt;&#xA;&lt;p&gt;My derivation is shown below. Part of the derivation was kindly corrected by Joni in my previous post here &lt;a href=&quot;https://or.stackexchange.com/questions/7675/translate-standard-weighted-least-square-regression-to-quadratic-programming&quot;&gt;Translate standard weighted least square regression to quadratic programming&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/hdu9q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hdu9q.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, the legacy technical notes has the Lagrange as&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7UIqM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7UIqM.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately like all technical notes, only results are given.&lt;/p&gt;&#xA;&lt;p&gt;I am not sure where my derivation is wrong.&lt;/p&gt;&#xA;" OwnerUserId="6060" LastEditorUserId="491" LastEditDate="2022-01-29T16:36:34.623" LastActivityDate="2022-01-29T16:36:34.623" Title="Lagrange for quadratic programming with linear constraint" Tags="|optimization|regression|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7678" PostTypeId="2" ParentId="7598" CreationDate="2022-01-28T21:41:03.307" Score="2" Body="&lt;p&gt;I have worked on this problem, but with the multi-vehicle version, during my master's degree. I will reformulate the problem described by you, but formally, present a very naive MILP formulation, and give a brief literature review you can rely on concerning this problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem definition&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$D(V = C \cup R \cup \{0\}, A)$&lt;/span&gt; be a metric weighted complete digraph; we must assume this property since the presented formulation requires it; where the nodes set is composed of three disjoint sets:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; the customers set, i.e. nodes mandatorily must be visited;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; the recharge/fuel stations set, i.e nodes eventually may be visited whenever the vehicle must refuel/recharge; and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\{0\}$&lt;/span&gt; the set containing only the depot node, from where the vehicle departs and returns.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Furthermore, let&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$d_{ij} \in \mathbb{R}^{+}$&lt;/span&gt; be the arc &lt;span class=&quot;math-container&quot;&gt;$(i, j) \in A$&lt;/span&gt; distance, that is, the distance between node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i, j \in V : i \neq j$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f_{ij} \in \mathbb{R}^{+}$&lt;/span&gt; be the arc &lt;span class=&quot;math-container&quot;&gt;$(i, j) \in A$&lt;/span&gt; required fuel, that is, the amount of fuel the vehicle will spend to go from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i, j \in V : i \neq j$&lt;/span&gt;; and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta \in \mathbb{R}^{+}$&lt;/span&gt; be the vehicle fuel capacity, i.e., the vehicle can spend at most &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; of fuel without stopping to recharge.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;A solution for our problem is composed of a walk on &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; visiting all the nodes in &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, such that the vehicle fuel capacity is always respected.&#xA;The Figure below, from &lt;a href=&quot;https://doi.org/10.1016/j.promfg.2020.01.270&quot; rel=&quot;nofollow noreferrer&quot;&gt;C.A. Gencel and B. Keçeci (2019)&lt;/a&gt; shows a solution example.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/S48Wu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S48Wu.png&quot; alt=&quot;C.A. Gencel and B. Keçeci (2019)&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The circles are the customers, the squares are our fuel stations, and the triangle is the depot.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;MILP formulation&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now let's take a look at a naive formulation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Variables&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Our formulation has the following variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_a \in \mathbb{N}$&lt;/span&gt; the amount of time the arc &lt;span class=&quot;math-container&quot;&gt;$a \in A$&lt;/span&gt; is used in the solution; and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$e_i \in \mathbb{R}^{+}$&lt;/span&gt; the vehicle remaining amount of fuel at customer &lt;span class=&quot;math-container&quot;&gt;$i \in C$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;em&gt;Objective function&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;We seek for minimizing the solution cost (distance).&lt;/p&gt;&#xA;&lt;p&gt;min &lt;span class=&quot;math-container&quot;&gt;$\sum_{a \in A} x_a d_a$&lt;/span&gt; (1)&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Constraints&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;The flow constraints: the amount of entering arcs equates to the number of exiting arcs.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{a \in \delta^{+}(i)} x_a = \sum_{a \in \delta^{-}(i)} x_a \quad \forall i \in V$&lt;/span&gt; (2)&lt;/p&gt;&#xA;&lt;p&gt;Every customer and the depot; &lt;span class=&quot;math-container&quot;&gt;$C_0 = C \cup \{0\}$&lt;/span&gt;; must be visited exactly once.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{a \in \delta^{+}(i)} x_a = 1 \quad \forall i \in C_0$&lt;/span&gt; (3)&lt;/p&gt;&#xA;&lt;p&gt;The amount of remaining fuel of the vehicle at a given customer must be enough to traverse the next arc, i.e. to reach the next selected node.&#xA;Note that, by (2) and (3), &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \in \mathbb{B}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall (i, j) \in A : i \in C_0 \vee i \in C_0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$e_i \geqslant \sum_{a \in \delta^{+}(i)} x_a f_a \quad \forall i \in C_0$&lt;/span&gt; (4)&lt;/p&gt;&#xA;&lt;p&gt;The amount of fuel must be decremented whenever the vehicle leaves the depot, or a fuel station, and goes to a customer.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta - \sum_{r \in R \cup \{0\}} x_{ri} f_{ri} \geqslant e_i \quad \forall i \in C$&lt;/span&gt; (5)&lt;/p&gt;&#xA;&lt;p&gt;The amount of fuel also must be decremented whenever the vehicle departs from one customer to another.&#xA;These constraints, famously known as Miller-Tucker-Zemlin (MTZ) constraints, prohibit subcycles composed by customers only.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$e_j \leqslant e_i - x_{ij} f_{ij} + \beta (1 - x_{ij}) \quad \forall i, j \in C : i \neq j$&lt;/span&gt; (6)&lt;/p&gt;&#xA;&lt;p&gt;Arcs with fuel consumption greater than &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; never will be used.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_a = 0 \quad \forall a \in A : f_a &amp;gt; \beta$&lt;/span&gt; (7)&lt;/p&gt;&#xA;&lt;p&gt;The final solution must be a single connected component.&#xA;The below constraints are an adaptation of the so-called Dantzig-Fulkerson-Johnson constraints.&#xA;These constraints might be, depending on your background, a little bit tough to understand, but I think some sketches of graph drawings on a paper sheet will suffice to make you see the validity of this constraint set.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{a \in \delta^{+}(S)} x_a \geqslant 1 \quad \forall S \subseteq V \backslash \{0\} : S \cap C \neq \emptyset$&lt;/span&gt; (8)&lt;/p&gt;&#xA;&lt;p&gt;And finally, the domain constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{N}^{|A|}$&lt;/span&gt; (9)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$e \in \mathbb{R}^{+|C|}$&lt;/span&gt; (10)&lt;/p&gt;&#xA;&lt;p&gt;I must warn you that, although very simple and didactic, this is a very weak formulation. I have conducted some experiments with a formulation similar to this one for this problem on its multi-vehicle version, and the results were very poor, at least for the proposed instances (&lt;a href=&quot;http://repositorio.unicamp.br/acervo/detalhe/1161412&quot; rel=&quot;nofollow noreferrer&quot;&gt;Masters dissertation&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;A brief literature review&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this section, I will give a very short literature review that can guide you on future endeavors concerning this problem. The problem you are facing is formally called the Traveling Salesman Problem with Hotel Selection (TSPHS). Follows some papers, in chronological order, regarding this problem:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.jstor.org/stable/41353923&quot; rel=&quot;nofollow noreferrer&quot;&gt;P. Vansteenwegen, W. Souffriau and K. Sörensen (2012)&lt;/a&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://doi.org/10.1016/j.cor.2013.01.006&quot; rel=&quot;nofollow noreferrer&quot;&gt;M. Castro, et al. (2013)&lt;/a&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://doi.org/10.1007/s10288-014-0264-5&quot; rel=&quot;nofollow noreferrer&quot;&gt;M. Castro, et al. (2015)&lt;/a&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://doi.org/10.1109/ACC.2016.7526547&quot; rel=&quot;nofollow noreferrer&quot;&gt;M. Radmanesh, et al. (2016)&lt;/a&gt;;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There are more recent papers about this problem, that you can find by googling . If you want to dive even further into this, you can check out some strongly related problems, such as the Black and White Traveling Salesman Problem and the Green-Vehicle Routing Problem (the multi-vehicle TSPHS version). Regarding this last one, you can find some papers in my &lt;a href=&quot;https://scholar.google.com/citations?user=fKvINRwAAAAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google Scholar&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastActivityDate="2022-01-28T21:41:03.307" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7680" PostTypeId="1" CreationDate="2022-01-29T06:08:14.223" Score="3" ViewCount="203" Body="&lt;p&gt;Someone asked me this question the other day:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;If constraints reduce the feasible region of an optimization problem (e.g. linear programming), then why is constraint optimization considered more difficult than the same optimization problem without constraints?&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I tried to use the following logic to answer this question (they used a continuous example, I answered using a discrete example):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Imagine you are trying to plan a party in the month of December, there are 31 days where you can have the party. You invite 3 guests to this party : each guest has 5 days in the month of December when they are unavailable (these are the constraints). Days amongst guests can overlap. You want all 3 guests to attend your party.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Even though there are now less days where you can have the party - it obviously becomes more difficult to accommodate everyone's schedule. Without the constraints, indeed there were more days to consider, but you could have had the party on any day. On the other hand, now there are fewer days to consider - but each day, you have to use some &amp;quot;energy&amp;quot; to check whether or not all guests are available.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;With constraints, you will spend &amp;quot;energy&amp;quot; each time you consider a potential day for the party. Without constraints, you don't need to spend any energy at all.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is my example correct? Even though constraints result in a smaller feasible region for an optimization problem - it still becomes more difficult to solve the problem?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there a better explanation I can use?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-01-29T16:35:29.867" LastActivityDate="2022-01-29T16:35:29.867" Title="Constraint Optimization and Feasible Regions" Tags="|optimization|constraint|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7681" PostTypeId="2" ParentId="7677" CreationDate="2022-01-29T06:31:30.933" Score="3" Body="&lt;p&gt;The issue is in the objective function and is caused by two conventions. First, the weights need to be for the squared error. Second. typically an optional &lt;span class=&quot;math-container&quot;&gt;$1/2$&lt;/span&gt; is added to avoid the resulting &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;'s in the gradient. So, you are dealing with the following problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\min_f \quad&amp;amp; \frac{1}{2} {(Xf - r)}^T W (Xf - r) \\&#xA;\text{s.t.} \quad&amp;amp; A^T f = 0.&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;[Note: I would rather define the constraint as  &lt;span class=&quot;math-container&quot;&gt;$Af = b$&lt;/span&gt; but followed your original problem.]&lt;/p&gt;&#xA;&lt;p&gt;The Lagrangian and its gradient w.r.t &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; are&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;L(f,\lambda) &amp;amp;= \frac{1}{2}  {(Xf - r)}^T W (Xf - r) + \lambda^T A^T f, \\&#xA;\nabla_f L(f,\lambda) &amp;amp;= X^T W (X f - r) + A \lambda \\&#xA;       &amp;amp;= X^T W X f  + A \lambda - X^T W r .&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is the dual variable for the constraint. Resulting stationarity and primal feasibility conditions you derive are found as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{bmatrix}&#xA;X^T W X &amp;amp; A \\&#xA;A^T &amp;amp; 0&#xA;\end{bmatrix}&#xA;\begin{bmatrix}&#xA;f \\&#xA;\lambda&#xA;\end{bmatrix} &#xA;=&#xA;\begin{bmatrix}&#xA;X^T W r \\&#xA;0&#xA;\end{bmatrix}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;While the scalar &lt;span class=&quot;math-container&quot;&gt;$1/2$&lt;/span&gt; is optional and only affects the dual variable, the other convention comes from how the weighted least squares is defined. The standard linear model assumes that the errors have constant variance. In weighted least squares the underlying model has errors with nonconstant variance. Indeed, the weight of an observation is proportional to the reciprocal of the error variance for that observation, &lt;span class=&quot;math-container&quot;&gt;$w_i = 1/\sigma_i^2$&lt;/span&gt;, thereby cancelling out the nonconstant variance. Therefore, &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is defined as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;W =&#xA;\begin{bmatrix}&#xA;w_1 &amp;amp; 0 &amp;amp; \ldots &amp;amp; 0 \\&#xA;0 &amp;amp; w_2 &amp;amp; \ldots &amp;amp; 0 \\&#xA;\vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp; \vdots \\&#xA;0 &amp;amp; 0 &amp;amp; \ldots &amp;amp; w_n&#xA;\end{bmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Finally, it is equivalent to transforming the particular linear model by multiplying it with &lt;span class=&quot;math-container&quot;&gt;$W^{1/2}$&lt;/span&gt;. So if you defined &lt;span class=&quot;math-container&quot;&gt;$\mathcal{W}=W^{1/2}$&lt;/span&gt; you'd be fine, too.&lt;/p&gt;&#xA;" OwnerUserId="8752" LastActivityDate="2022-01-29T06:31:30.933" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7682" PostTypeId="2" ParentId="7680" CreationDate="2022-01-29T10:21:09.797" Score="1" Body="&lt;p&gt;Please, be aware that the constraints more than reduce the feasibility space, shaping what you have tried to model that. This is usually referred the art of modeling. This is where there exists more than one unique formulation for the same problem. Also, the constraints, really, represent the limits/requirements based on what you need and NO more. Since if a problem needs to be unconstrained, what are the reasons to constraint it or vice versa!!?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-01-29T10:21:09.797" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7684" PostTypeId="1" CreationDate="2022-01-29T12:45:53.797" Score="2" ViewCount="312" Body="&lt;p&gt;Assume a mathematical optimization problem with two positive continuous variables:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;0 &amp;lt;= x &amp;lt;= 1&#xA;0 &amp;lt;= y &amp;lt;= 1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am seeking an efficient way to express the following nonlinear relationship in form of linear constraints (possibly with the use of binary/integer variables and big M), so the problem can be solved with MILP solvers:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;when   0 &amp;lt;= y &amp;lt; 200      then   x = 0&#xA;when   y = 200           then   0 &amp;lt;= x &amp;lt;= 1&#xA;when   200 &amp;lt; y &amp;lt;= 1000   then   x = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The numbers 200 and 1000 are indicatively big.&lt;/p&gt;&#xA;&lt;p&gt;Are there any direct suggestions or papers/books addressing similar problems?&lt;/p&gt;&#xA;" OwnerUserId="9005" LastEditorUserId="36" LastEditDate="2022-01-30T02:50:16.067" LastActivityDate="2022-01-30T02:50:16.067" Title="How can I linearize this nonlinear variable relationship?" Tags="|optimization|mixed-integer-programming|linearization|nonlinear-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7685" PostTypeId="2" ParentId="7684" CreationDate="2022-01-29T14:48:49.337" Score="8" Body="&lt;p&gt;Introduce three binary decision variables &lt;span class=&quot;math-container&quot;&gt;$z_1,z_2,z_3 $&lt;/span&gt; and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z_1+z_2+z_3=1\\&#xA;0z_1+0z_2+1z_3\le x\le 0z_1+1z_2+1z_3 \\&#xA;0z_1+200z_2+200z_3\le y\le &#xA;200z_1+200z_2+1000z_3&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-01-29T14:48:49.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7686" PostTypeId="1" CreationDate="2022-01-29T16:53:22.837" Score="1" ViewCount="72" Body="&lt;p&gt;Data Available:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Historical Weekly Demand&lt;/li&gt;&#xA;&lt;li&gt;Total SKU's = ~ 2500&lt;/li&gt;&#xA;&lt;li&gt;Historical Lead times (Most Suppliers' Shipping from Asia to the US)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Problem to solve:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Improve First Fulfillment Rate to the Customer from a distribution center in the US&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Questions (I will keep updating as I am working on this project):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Should I assume my demand and lead times to follow a normal distribution, if not what are some of the suggestions on testing my data w.r.t other distributions? Should I use weekly demand, monthly demand etc. to test? Same question for the lead times.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9006" LastActivityDate="2022-01-30T18:01:49.033" Title="Improving Customer First Fulfillment Rate" Tags="|inventory|supply-chain|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7687" PostTypeId="2" ParentId="7686" CreationDate="2022-01-29T19:15:40.460" Score="3" Body="&lt;p&gt;Before asking if demand and lead time have a specific distribution (normal or other), you might want to ask whether they have stationary distributions or exhibit trend and/or seasonality. If the distributions are not stationary, you need to fit a time series model to them, then ask about the distribution of the residuals. In determining the best model, I think you will want to use &lt;a href=&quot;https://en.wikipedia.org/wiki/Cross-validation_(statistics)&quot; rel=&quot;nofollow noreferrer&quot;&gt;cross-validation&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Once you are at the point of worrying about normal versus other distributions, and assuming you have enough data (the definition of &amp;quot;enough&amp;quot; being rather fuzzy), I would suggest plotting the data (actual demand/LT if stationary, residuals from the time series model if not) and looking at whether the plot looks reasonably symmetric. If not, look for a distribution that has a similar shape. I would again suggest using cross-validation to pick the right distribution(s).&lt;/p&gt;&#xA;&lt;p&gt;As far as daily v. weekly v. monthly data, I would use whatever granularity the sample has (i.e., I would not aggregate) when testing for stationarity. If the data proves to be stationary, then it might make sense to aggregate depending on what the ultimate goal of your model is. If you are trying to determine monthly order sizes, aggregating to monthly data is reasonable. If you are determining weekly order sizes, aggregating to monthly does not make sense.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-29T19:15:40.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7688" PostTypeId="2" ParentId="506" CreationDate="2022-01-29T22:59:38.683" Score="-1" Body="&lt;p&gt;There are smooth functions &lt;span class=&quot;math-container&quot;&gt;$f : \mathbb{R}^2 \to \mathbb{R}$&lt;/span&gt; such that there exists a point &lt;span class=&quot;math-container&quot;&gt;$p \in \mathbb{R}^2$&lt;/span&gt; that is not a local minimum, but when you restrict the function to any line through &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is a strict local minimum.&lt;/p&gt;&#xA;&lt;p&gt;Consider &lt;span class=&quot;math-container&quot;&gt;$f(x,y) = 2(x^2 + y^2 - 1)^2 - y^4$&lt;/span&gt; and the point &lt;span class=&quot;math-container&quot;&gt;$p = (1,0)$&lt;/span&gt; where we have &lt;span class=&quot;math-container&quot;&gt;$f(1,0) = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This point is not a local minimum: take the curve &lt;span class=&quot;math-container&quot;&gt;$(x(t),y(t)) = (cos(t),sin(t))$&lt;/span&gt;.&#xA;Then &lt;span class=&quot;math-container&quot;&gt;$f(x(t),y(t)) = -sin(t)^4$&lt;/span&gt;. If we take &lt;span class=&quot;math-container&quot;&gt;$t=0$&lt;/span&gt; we get our point &lt;span class=&quot;math-container&quot;&gt;$(1,0)$&lt;/span&gt;, but as we move away from this point along that curve, f goes negative.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, for every &lt;em&gt;straight&lt;/em&gt; line through &lt;span class=&quot;math-container&quot;&gt;$(1,0)$&lt;/span&gt;, the value of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; becomes strictly positive as we move a little away from that point:&lt;/p&gt;&#xA;&lt;p&gt;We take an arbitrary straight line &lt;span class=&quot;math-container&quot;&gt;$(x(t),y(t)) = (1,0) + t(a,b)$&lt;/span&gt;, where the direction is determined by &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. Then we have &lt;span class=&quot;math-container&quot;&gt;$f(x(t),y(t)) = 2(2at + (at)^2 + (bt)^2)^2 - (bt)^4$&lt;/span&gt;. We consider two cases:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a = 0$&lt;/span&gt;: now &lt;span class=&quot;math-container&quot;&gt;$f(x(t),y(t)) = (bt)^4$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; clearly goes positive along this line.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a \neq 0$&lt;/span&gt;: now &lt;span class=&quot;math-container&quot;&gt;$f(x(t),y(t)) = 2(2at)^2 + O(t^3)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; close to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. So &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; also goes positive along those lines with &lt;span class=&quot;math-container&quot;&gt;$a \neq 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So we have our function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and the point &lt;span class=&quot;math-container&quot;&gt;$(1,0)$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; increases as we move away from the point in a straight line, but &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; decreases as we move away from the point along a curved line.&lt;/p&gt;&#xA;" OwnerUserId="9020" LastEditorUserId="9020" LastEditDate="2022-03-15T13:59:30.233" LastActivityDate="2022-03-15T13:59:30.233" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7689" PostTypeId="1" CreationDate="2022-01-29T23:32:00.703" Score="8" ViewCount="706" Body="&lt;p&gt;I just came across the notion of Online optimization (I got a look on Wikipedia page and some other webpages), but it was not enough for me and I am looking for a more elaborated comparison, namely in terms of the modelling and solving strategies.&lt;/p&gt;&#xA;&lt;p&gt;I am keen on any academic/industrial pointers to understand better how these types of optimizations work.&lt;/p&gt;&#xA;&lt;p&gt;Can we apply Machine Learning (in any flavour) to solve Online Optimization problems (depending on the problem on hand)?&lt;/p&gt;&#xA;" OwnerUserId="2599" LastEditorUserId="2599" LastEditDate="2022-02-09T23:15:58.630" LastActivityDate="2023-03-27T09:48:24.967" Title="Difference between &quot;Online Optimization&quot; and &quot;Stochastic Optimization&quot;/&quot;Robust Optimization&quot;?" Tags="|reference-request|stochastic-programming|applications|robust-optimization|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7690" PostTypeId="2" ParentId="506" CreationDate="2022-01-29T23:42:50.693" Score="4" Body="&lt;p&gt;A classical one:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Finding the shortest path that visits all edges of a graph is in &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; (Chinese Postman Problem)&lt;/li&gt;&#xA;&lt;li&gt;Finding the shortest path that visits all nodes of a graph is NP-complete (Traveling Salesman Problem)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Another one from scheduling theory:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$P | p_j = p | \sum w_j U_j$&lt;/span&gt; is in &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$P | p_j = p, \mathrm{pmtn} | \sum w_j U_j$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$NP$&lt;/span&gt;-complete&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This is counter-intuitive since usually, preemption makes problems easier, see &amp;quot;Preemption Can Make Parallel Machine Scheduling Problems Hard&amp;quot; (Brucker et Kravchenko, 1999).&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-01-29T23:42:50.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7691" PostTypeId="1" CreationDate="2022-01-30T02:14:13.683" Score="3" ViewCount="394" Body="&lt;p&gt;&lt;strong&gt;If you can not take the derivative of your objective function - is the idea of &amp;quot;convexity&amp;quot; irrelevant?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Whenever I look at the mathematical definitions of &amp;quot;convexity&amp;quot; - there always eventually seems to be a requirement that for the idea of &amp;quot;convexity&amp;quot; to apply, the function must be differentiable (i.e. you can take the derivative). For instance: we say that a Non-Convex Function can have Saddle Points - and Saddle Points are points on a function where the second derivatives of the function are 0, but this point is not a maximum nor a minimum.&lt;/p&gt;&#xA;&lt;p&gt;In cases where you can not take the derivative of your objective function (As in most discrete combinatorics optimization problems, e.g. Travelling Salesman, Knapsack Optimization) - can we still describe the objective functions in these problems as &amp;quot;convex&amp;quot; or &amp;quot;non-convex&amp;quot;? Or does the idea of &amp;quot;convexity&amp;quot; only apply to problems where the objective function is differentiable?&lt;/p&gt;&#xA;&lt;p&gt;Note: I have informally heard that Discrete Combinatoric Optimization problems are typically more difficult than optimization problems where the search space is continuous. Is this because of the fact that the objective function in discrete problems is non-differentiable?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-03T13:51:56.087" LastActivityDate="2022-02-04T00:39:25.920" Title="If you can not take the derivative of your objective function - is &quot;convexity&quot; irrelevant?" Tags="|optimization|combinatorial-optimization|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7692" PostTypeId="2" ParentId="7691" CreationDate="2022-01-30T08:21:43.417" Score="3" Body="&lt;p&gt;If you formulate your problem as a MILP, then the formulation is convex since it is linear, but that doesn't change much for you.&lt;/p&gt;&#xA;&lt;p&gt;If you formulate it as a MINLP, (Quadratic Assignment for example), then it is important. Some algorithms for MINLP are exact only when the problem is convex (NLP-based branch-and-bound, Outer approximations...). When the problem is non-convex, other methods, such as spatial branch-and-bound, need to be used to prove the global optimality&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-01-30T08:21:43.417" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7693" PostTypeId="1" AcceptedAnswerId="7698" CreationDate="2022-01-30T09:23:47.513" Score="0" ViewCount="368" Body="&lt;p&gt;I have a MPC with two objective functions, one that minimises fuel consumption and one that minimises the travel time of a vessel. I want to combine these two objectives into one weighted objective, for which the functions should be normalised.&lt;/p&gt;&#xA;&lt;p&gt;I understand that this requires a scaling/normalisation factor, which can then be combined with the weights. However, I do not understand how exactly I arrive at this scaling factor?&lt;/p&gt;&#xA;&lt;p&gt;(The model is implemented in Matlab with yalmip)&lt;/p&gt;&#xA;" OwnerUserId="9036" LastActivityDate="2022-03-03T15:52:45.840" Title="How to normalize the objective functions of multi-objective optimization for a MPC?" Tags="|multi-objective-optimization|matlab|yalmip|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7695" PostTypeId="1" AcceptedAnswerId="7696" CreationDate="2022-01-30T12:46:02.013" Score="5" ViewCount="1160" Body="&lt;p&gt;What is the newest MIP or CP solver (which is model based exact solver)?&lt;/p&gt;&#xA;&lt;p&gt;I want to follow and wonder developments on solvers. But finding new developed solvers (experimental, academic, commercial etc.) with search is not enough, and sometimes can be missed. Answers to this question can be guiding.&lt;/p&gt;&#xA;" OwnerUserId="432" LastEditorUserId="432" LastEditDate="2022-02-01T06:29:15.360" LastActivityDate="2022-02-01T06:29:15.360" Title="What is the newest MIP and CP solver?" Tags="|mixed-integer-programming|constraint-programming|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7696" PostTypeId="2" ParentId="7695" CreationDate="2022-01-30T14:10:02.557" Score="4" Body="&lt;p&gt;Below are some popular solvers for MIP &amp;amp; CP (Not an exhaustive list though)&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;MIP Solvers&lt;/strong&gt;: Gurobi, CPLEX, XPRESS(FICO), CBC, SCIP, etc..&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;CP Solvers&lt;/strong&gt;: MiniZinc, OR-Tools, CP Optimizer(CPLEX), etc..&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;One of the newest solver that I can across recently for LP/MIP/QP was &lt;a href=&quot;https://www.maths.ed.ac.uk/hall/HiGHS/#get-started&quot; rel=&quot;nofollow noreferrer&quot;&gt;HIGHS&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastEditorUserId="5880" LastEditDate="2022-01-30T14:22:20.063" LastActivityDate="2022-01-30T14:22:20.063" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7697" PostTypeId="1" AcceptedAnswerId="7700" CreationDate="2022-01-30T15:18:37.540" Score="6" ViewCount="508" Body="&lt;p&gt;I'm starting a consulting project for a client who manufacturers perishable food.  They want to optimize their delivery schedule to each of their DSD (Direct Store Delivery) customers.&lt;/p&gt;&#xA;&lt;p&gt;For each store, I have binary decision variables that reflect whether I make a delivery to that store on Sunday, Monday, Tuesday, ... Saturday.&lt;/p&gt;&#xA;&lt;p&gt;e.g.,&#xA;x1 = binary, 1 if I make a delivery on Sunday, 0 if I don't&#xA;x2 = binary, 1 if I make a delivery on Monday, 0 if I don't&#xA;...&#xA;x7 = binary, 1 if I make a delivery on Saturday, 0 if I don't&lt;/p&gt;&#xA;&lt;p&gt;Based upon the store's demand, I may want to deliver 1x weekly, 2x weekly, 3x weekly, or 4x weekly.  I can set that delivery frequency up as a constraint on the sum of the binaries, but I am having trouble with ensuring spacing of delivery days to ensure the perishable food doesn't spoil on the store shelf.&lt;/p&gt;&#xA;&lt;p&gt;For example, if I am delivering 2x per week, having delivery days that are consecutive or only spaced by one day in between - Tuesday and Wednesday, or Saturday and Monday - shouldn't be allowed.&lt;/p&gt;&#xA;&lt;p&gt;For 2x weekly deliveries, I'd like there to be a 3 day gap and a 4 day gap between delivery days: e.g., Sunday &amp;amp; Wednesday; or Friday &amp;amp; Monday.&lt;/p&gt;&#xA;&lt;p&gt;For 3x weekly deliveries, I'd like there to be at most a 3 day gap between delivery days (Monday &amp;amp; Thursday = 3 day gap).  For 4x delivery days, I'd like there to be at most a 2 day gap between delivery days.&lt;/p&gt;&#xA;&lt;p&gt;I've figured out an (ugly) way to put this constraint together in a 2x weekly delivery schedule, but no idea how to approach for 3x weekly or 4x weekly.  Any help is appreciated.&lt;/p&gt;&#xA;&lt;p&gt;Also FYI, I haven't actually coded anything at this point, just thinking through how I'd approach the problem with pen &amp;amp; paper.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastEditorUserId="500" LastEditDate="2022-01-30T16:58:44.053" LastActivityDate="2022-01-30T18:43:07.167" Title="Integer Programming Constraints - Min/Max Days Between Deliveries" Tags="|modeling|integer-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7698" PostTypeId="2" ParentId="7693" CreationDate="2022-01-30T16:38:26.550" Score="4" Body="&lt;p&gt;The reason for minimizing fuel consumption is presumably to minimize fuel cost. If you can come up with a cost rate for travel time, then you can combine the two objectives into an overall cost function and minimize that. No normalization is required.&lt;/p&gt;&#xA;&lt;p&gt;More generally, if you cannot put the criteria in common units (such as dollars of cost), then one option is to ask the decision maker something along the lines of &amp;quot;how many additional gallons of fuel would you be willing to expend to cut travel time by one day?&amp;quot; and use that to generate weights. Again, no normalization is required; if fuel consumption is in gallons, travel time is in days and the decision maker equates one day of travel with 100 gallons of fuel, just multiply fuel consumption by 1 and travel time by 100 (putting the combined function in terms of gallons of fuel).&lt;/p&gt;&#xA;&lt;p&gt;Where I have seen normalization used, the units of the various criteria are not directly commensurable and decision makers can only give vague guidance like &amp;quot;saving fuel is twice as important as saving travel time&amp;quot;. You can guesstimate the range of values for each criterion function, subtract the min and divide by the range to put the criterion on a [0, 1] scale, and then apply weights. Whether this produces meaningful results is in my opinion a tad dubious.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-30T16:38:26.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7699" PostTypeId="2" ParentId="7697" CreationDate="2022-01-30T16:46:50.167" Score="5" Body="&lt;p&gt;To disallow any given pattern of &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, you can impose &amp;quot;no-good&amp;quot; constraints.  For example, if you want to avoid delivering on both Tuesday and Wednesday, that is, avoid&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(x_3,x_4)=(1,1),$$&lt;/span&gt;&#xA;you want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lnot (x_3 \land x_4).$$&lt;/span&gt;&#xA;Rewriting in conjunctive normal form yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lnot x_3 \lor \lnot x_4.$$&lt;/span&gt;&#xA;So the desired constraint is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(1 - x_3) + (1 - x_4) \ge 1,$$&lt;/span&gt;&#xA;equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_3+x_4 \le 1.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;More generally, for any pair &lt;span class=&quot;math-container&quot;&gt;$\{i,j\}$&lt;/span&gt; of days that cannot both have a delivery, impose the &amp;quot;conflict&amp;quot; constraint &lt;span class=&quot;math-container&quot;&gt;$x_i+x_j \le 1$&lt;/span&gt;.  The model in the linked answer &lt;a href=&quot;https://or.stackexchange.com/questions/7531/optimize-days-between-work-shift/7532#7532&quot;&gt;here&lt;/a&gt; strengthens these conflict constraints to &amp;quot;clique&amp;quot; constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-01-30T18:43:07.167" LastActivityDate="2022-01-30T18:43:07.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7700" PostTypeId="2" ParentId="7697" CreationDate="2022-01-30T16:54:52.033" Score="5" Body="&lt;p&gt;Here are two approaches, neither guaranteed to be ideal.&lt;/p&gt;&#xA;&lt;p&gt;Method 1: Create a new set of binary variables &lt;span class=&quot;math-container&quot;&gt;$y_1,\dots,y_4$&lt;/span&gt; signaling how many deliveries per week (1 to 4). Add the constraints &lt;span class=&quot;math-container&quot;&gt;$$y_1 + \dots + y_4 = 1$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$x_1 + \dots + x_7 = y_1 + 2y_2 + 3y_3 +4y_4.$$&lt;/span&gt;&#xA;To enforce your gap rules for two deliveries, add constraints &lt;span class=&quot;math-container&quot;&gt;$$x_i + x_{i + 1} + x_{i + 2} \le 3 - 2 y_2$$&lt;/span&gt; for all relevant &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. To enforce your gap rules for three deliveries, use &lt;span class=&quot;math-container&quot;&gt;$$x_i + x_{i + 1} + x_{i + 2} + x_{i + 3} \ge 2f_3.$$&lt;/span&gt; Enforcing gap rules for four deliveries is left to the reader as an exercise.&lt;/p&gt;&#xA;&lt;p&gt;Method 2: Rather than using your &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; variables, generate all possible delivery schedules for a week (Monday only; Monday and Thursday; Monday Tuesday and Thursday; etc.) and use a binary variable for each one to select which will be used. Only include schedules that meet your gap criteria. If this results in too many binary variables, use either branch-and-price or a column generation heuristic.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-30T16:54:52.033" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7701" PostTypeId="2" ParentId="7686" CreationDate="2022-01-30T18:01:49.033" Score="1" Body="&lt;p&gt;Be careful about using the Normal distribution. It allows for negative values.  Lead times are never &amp;lt; 0. Demand is almost never &amp;lt; 0 ( only if product returns &amp;gt; product sales). An obvious alternative distribution that does not allow negative values is the Poisson. If demands arrive in batches, the Compound Poisson might be useful (see Wikipedia).&#xA;If you use monthly data, the Normal assumption is safer, i.e., less likely to result in negative values when you fit a Normal distribution to the data.&#xA;Do you have demand data or just sales data? Sales underestimates true demand when you have stockouts.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-01-30T18:01:49.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7702" PostTypeId="1" CreationDate="2022-01-30T18:48:58.573" Score="0" ViewCount="466" Body="&lt;p&gt;I'm working with CPLEX using the python API (Docplex).&lt;/p&gt;&#xA;&lt;p&gt;If I set the time limit in seconds with &lt;code&gt;model.set_time_limit(60)&lt;/code&gt; the solver returns the best integer feasible solution notifying that the time is exceeded and everything is fine.&lt;/p&gt;&#xA;&lt;p&gt;Now I want to set the timeout in a deterministic manner, so I'm using &lt;code&gt;model.parameters.dettimelimit = 600000&lt;/code&gt;.&lt;br /&gt;&#xA;The problem is that now the solver doesn't return any solution even if the solution status (&lt;code&gt;model.get_cplex().solution.get_status()&lt;/code&gt;) return the state 131: &lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.8.0.0?topic=api-cpxmip-dettime-lim-feas&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPXMIP_DETTIME_LIM_FEAS&lt;/a&gt;, in fact the logs show that an integer feasible solution has been found:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; 13937  8815       -0.2108     0       -0.2108       -0.0110   531179   94.77%&#xA; 14185  8946       -0.2108     4       -0.2108       -0.0120   537954   94.29%&#xA; Elapsed time = 105.69 sec. (59749.84 ticks, tree = 258.03 MB, solutions = 19)&#xA; * 14193  8945      integral     0       -0.2108       -0.0127   537955   93.98%&#xA; * 14194  9005      integral     0       -0.2108       -0.0142   542020   93.27%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How can I force CPLEX to return the best incumbent solution even with the deterministic timelimit?&lt;/p&gt;&#xA;" OwnerUserId="3212" LastActivityDate="2022-01-30T18:48:58.573" Title="CPLEX returns no solution with deterministic time limit" Tags="|mixed-integer-programming|cplex|convex-optimization|docplex|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7704" PostTypeId="1" CreationDate="2022-01-30T20:57:20.133" Score="3" ViewCount="53" Body="&lt;p&gt;So, I'm trying to optimize MILP, which has PWL constraints. I use &lt;code&gt;gurobi&lt;/code&gt;, and when I'm optimizing model without those constraints, gurobi finds solution in a &lt;em&gt;matter of seconds&lt;/em&gt;. The problem is when I try to add PWL constraints, performance drops significantly. When I added only 419 out 4072 PWL constraints, gurobi took several minutes two solve the model, and when I added all of them, it couldn't find feasible solution (which must always exist) in several hours. PWL function I use has 11 breakpoints and has no jumps. I can't post all code (there's too much) so here super general outline:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s1 = m.addVars(indices, vtype=GRB.CONTINUOUS, name='s1')&#xA;s2 = m.addVars(indices, vtype=GRB.CONTINUOUS, name='s2')&#xA;&#xA;# Some constraints with s1 and s2&#xA;&#xA;c1 = m.addVars(indices, vtype=GRB.CONTINUOUS, name='c1')&#xA;c2 = m.addVars(indices, vtype=GRB.CONTINUOUS, name='c2')&#xA;&#xA;for i in range(M):&#xA;    for j in range(N):&#xA;        m.addGenConstrPWL(s1[i, j], c1[i, j], X, Y)&#xA;        m.addGenConstrPWL(s1[i, j], c1[i, j], X, Y)&#xA;&#xA;# also need to add constraints with c1 and c2 in the future&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So my question is it expected that PWL constraints would cause such a drop in performance, and can I do something to improve it?&lt;/p&gt;&#xA;" OwnerUserId="8751" LastActivityDate="2022-01-30T20:57:20.133" Title="PWL constraints efficiency" Tags="|mixed-integer-programming|gurobi|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7705" PostTypeId="1" CreationDate="2022-01-31T07:31:48.200" Score="1" ViewCount="105" Body="&lt;p&gt;I tried to model and solve this Pooling problem below. I used Excel and Opensolver and used Couenne solver to get the .nl problem file. I then used Neos Knitro and Scip 8 to (try to) solve the problem.&lt;/p&gt;&#xA;&lt;p&gt;I got different results than the Gurobi example page. Then I entered Gurobi numbers to my Excel model and noticed the numbers do not match.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;pool 1 input 325 + 258.3 + 500 = 1083.3 but pool 1 output is 92.8 + 990.6 = 1083.4 which is not the same number and I think they should be&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Gurobi optimal objective is 439182.xxx but in my model with the same input and output numbers the objective becomes 541278&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&amp;quot;Best objective 4.391825892869e+05, best bound 4.391825893721e+05, gap 0.0000%&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Is Gurobi example something wrong or is my model wrong?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/resource/standard-pooling-problem/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/resource/standard-pooling-problem/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://colab.research.google.com/github/Gurobi/modeling-examples/blob/master/pooling/std_pooling_gcl.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://colab.research.google.com/github/Gurobi/modeling-examples/blob/master/pooling/std_pooling_gcl.ipynb&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9050" LastActivityDate="2022-01-31T07:31:48.200" Title="Pooling problem, Gurobi example" Tags="|linear-programming|gurobi|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7706" PostTypeId="1" CreationDate="2022-01-31T07:32:34.427" Score="5" ViewCount="1078" Body="&lt;p&gt;I am looking at the Traveling Salesman Problem and I can not figure out if this problem is a type of &amp;quot;Integer Optimization Problem&amp;quot;, or is a type of &amp;quot;Combinatorial Optimization Problem&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;It seems like this is a Combinatorial Optimization Problem. Is this correct?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-03T04:48:38.080" LastActivityDate="2022-02-03T04:48:38.080" Title="Is Traveling Salesman Problem &quot;Combinatorial Optimization&quot; or &quot;Integer Optimization&quot;?" Tags="|optimization|integer-programming|combinatorial-optimization|traveling-salesman|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7707" PostTypeId="2" ParentId="7706" CreationDate="2022-01-31T07:48:20.730" Score="4" Body="&lt;p&gt;The versatility of the combinatorial optimization model stems from the fact that in many practical problems, activities and resources, such as machines, airplanes, and people, are indivisible. Also, many problems have only a finite number of alternative choices and consequently can appropriately be formulated as combinatorial optimization problems — the word combinatorial refers to the fact that only a finite number of alternative feasible solutions exists. Combinatorial optimization models are often referred to as integer programming models where programming refers to “planning” so that these are models used in planning where some or all of the decisions can take on only a finite number of alternative possibilities.&lt;/p&gt;&#xA;&lt;p&gt;Also, Combinatorial optimization is a subfield of mathematical optimization that consists of finding an optimal object from a finite set of objects where the set of feasible solutions is discrete or can be reduced to a discrete set. Typical combinatorial optimization problems are the traveling salesman problem (&amp;quot;TSP&amp;quot;), the minimum spanning tree problem (&amp;quot;MST&amp;quot;), and the knapsack problem.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-01-31T07:48:20.730" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7708" PostTypeId="2" ParentId="7695" CreationDate="2022-01-31T07:55:39.567" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://www.optapy.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPy&lt;/a&gt; might be the newest solver at the time of writing.&lt;/p&gt;&#xA;&lt;p&gt;OptaPy is an open source Python solver that uses parts of &lt;a href=&quot;https://www.optaplanner.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner&lt;/a&gt; inside (but it's considered a different solver). It was &lt;a href=&quot;https://www.optaplanner.org/blog/2021/10/05/ANewAIConstraintSolverForPythonOptaPy.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;announced on 5 October 2021&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2022-01-31T08:04:08.327" LastActivityDate="2022-01-31T08:04:08.327" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="7709" PostTypeId="1" CreationDate="2022-01-31T10:09:07.510" Score="3" ViewCount="261" Body="&lt;p&gt;Here is an extract from the BnB solution process of my problem.  The solver determines a value of 2627.452494 as being the best bound of the optimal solution. The value for the best bound remains the same for the next 80000 nodes, then it decreases very slowly (in steps of ca. 2). The optimal solution is known to be 1958.275.&lt;/p&gt;&#xA;&lt;p&gt;Is there anything I can do to help the solver calculate faster a better best bound?&lt;/p&gt;&#xA;&lt;p&gt;If this behaviour is an indication of symmetry at the value 2675.564892 how could I possibly break it?&lt;/p&gt;&#xA;&lt;p&gt;Here, the solver is XPRESS.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Node     BestSoln    BestBound   Sols Active  Depth     Gap     GInf   Time&#xA;   1   319.994373  2675.564892      4      2      1  736.13%    1130    168&#xA;   2   319.994373  2627.452537      4      1      2  721.09%     962    171&#xA;   3   319.994373  2627.452494      4      2      3  721.09%     716    173&#xA;   4   319.994373  2627.452163      4      3      4  721.09%     725    174&#xA;   5   319.994373  2627.451885      4      4      5  721.09%     725    174&#xA;   6   319.994373  2627.451885      4      5      6  721.09%     724    175&#xA;   7   319.994373  2627.451885      4      5      7  721.09%     724    175&#xA;   8   319.994373  2627.451885      4      5      7  721.09%     722    176&#xA;   9   319.994373  2627.451885      4      5      8  721.09%     722    176&#xA;  10   319.994373  2627.451885      4      5      8  721.09%     713    176&#xA;  20   319.994373  2627.451885      4      5     17  721.09%     740    192&#xA;  30   319.994373  2627.451885      4     13     10  721.09%     739    199&#xA;  40   319.994373  2627.451885      4     19     12  721.09%     777    211&#xA;  50   319.994373  2627.451676      4     23      9  721.09%     659    218&#xA;  60   319.994373  2627.451676      4     23     17  721.09%     680    223&#xA;  70   319.994373  2627.451676      4     23     24  721.09%     744    234&#xA;  80   319.994373  2627.451676      4     23     32  721.09%     648    244&#xA;  90   319.994373  2627.451642      4     44     13  721.09%     814    249&#xA; 100   319.994373  2627.451642      4     44     22  721.09%     692    256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="1269" LastEditDate="2022-01-31T21:36:33.887" LastActivityDate="2022-02-01T12:40:33.110" Title="Improving best bound within B&amp;B process" Tags="|mixed-integer-programming|bounds|symmetry|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7710" PostTypeId="2" ParentId="7709" CreationDate="2022-01-31T10:30:41.253" Score="2" Body="&lt;p&gt;You could try setting &lt;code&gt;heursearch&lt;/code&gt; to e.g. every 1000 nodes or &lt;code&gt;heurstrategy&lt;/code&gt; to 1 (only basic heuristics). Those options should free up a lot of computing time to be used on improving the bound. You could also set &lt;code&gt;mipabscutoff&lt;/code&gt; to your optimal objective value.&lt;/p&gt;&#xA;&lt;p&gt;Other things you could do is increase the number of threads, and increasing the integrality and/or constraint violation tolerances (assuming you can live with that).&lt;/p&gt;&#xA;&lt;p&gt;However, it's very hard to outsmart a commercial solver in general - the solution typically would be to reformulate your model into something that's easier for the solver to handle.&lt;/p&gt;&#xA;&lt;p&gt;Regarding symmetry, it's hard to tell without seeing your math, but a classic way if e.g. &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are symmetrical is to add a constraint &lt;span class=&quot;math-container&quot;&gt;$x \geq y$&lt;/span&gt; or vice versa.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2022-01-31T10:30:41.253" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7713" PostTypeId="2" ParentId="7689" CreationDate="2022-01-31T13:06:10.287" Score="7" Body="&lt;p&gt;Most online problems are sequential decision problems described by the following scheme:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Information --&amp;gt; Decision --&amp;gt; Information --&amp;gt; Decision --&amp;gt; Information...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;We first have some information, make a decision, get new information, make a decision and so on. As the information is (mostly) not known beforehand, we deal with a stochastic process. These problems are often modeled as Markov decision process (MDP).&lt;br /&gt;&#xA;In terms of solving these sequential decision problems, Warren Powell introduced 4 classes:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Policy function approximation: Often simple rules (e.g. order-up to levels in case of an inventory problem), but also more sophisticated methods that try to optimize a policy directly (Policy Gradient methods).&lt;/li&gt;&#xA;&lt;li&gt;Cost function approximation: Adjust objective function or constraints to account for the future (e.g., by adding slack).&lt;/li&gt;&#xA;&lt;li&gt;Value function approximation: Making a decision now using the (expected) value of being in a state&lt;/li&gt;&#xA;&lt;li&gt;Lookahead-models: Simulate into the future and use that simulated information to make a decision now&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Machine learning can be used as a tool in all these four classes and is in fact often used when one applies Value function approximation, i.e. you can try to predict the value of a state with a machine learning model. Or when using Policy function approximation such as Policy gradient methods (you can use machine learning to output an action distribution). If you have read up on reinforcement learning (RL with function approximation) this might sound familiar.&#xA;I can advise you to check out the following book (draft is freely available):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Reinforcement Learning and Stochastic Optimization: A unified&#xA;framework for sequential decisions by Warren Powell&#xA;&lt;a href=&quot;https://castlelab.princeton.edu/wp-content/uploads/2019/06/Powell-RLandSO-June192019.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://castlelab.princeton.edu/wp-content/uploads/2019/06/Powell-RLandSO-June192019.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="3464" LastEditDate="2023-03-27T09:48:24.967" LastActivityDate="2023-03-27T09:48:24.967" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7714" PostTypeId="1" CreationDate="2022-01-31T13:36:45.597" Score="5" ViewCount="400" Body="&lt;p&gt;I am relatively new to optimization and mathematical programming. I am looking for literature on rolling horizon. When I search for it on the internet, I find many articles like:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2020/05/7809.pdf&quot; rel=&quot;noreferrer&quot;&gt;Lukas Glomb et al.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0306261915007230&quot; rel=&quot;noreferrer&quot;&gt;Javier Silente et al.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0360835207002744?casa_token=xkZkvhKxsawAAAAA:ocI9X8Hmp09y9YVww-Ru84oWokObntoGkznNN1vtJHtcAHML1-NOsSMqtmeTh1l2hJP3hTzUJxg&quot; rel=&quot;noreferrer&quot;&gt;Tareq Al-Ameri et al.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;and many the like ...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;My problem: It's hard to read and understand this kind of literature -- at least for someone who isn't already familiar with this topic. I think those articles are intended for a professional audience.&lt;/p&gt;&#xA;&lt;p&gt;So my question: does anybody know recommendable literature for a gentle introduction to this topic &amp;quot;rolling horizon in optimization&amp;quot;? Something more like a textbook from school.&lt;/p&gt;&#xA;" OwnerUserId="9052" LastEditorUserId="36" LastEditDate="2022-01-31T14:06:46.107" LastActivityDate="2024-01-15T13:44:50.500" Title="is there any recommended &quot;rolling horizon in optimization&quot; literature for beginners?" Tags="|optimization|reference-request|literature-research|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7716" PostTypeId="2" ParentId="7563" CreationDate="2022-01-31T14:58:21.683" Score="4" Body="&lt;p&gt;As you say, the specific modelling primitives you mention that CP Optimizer introduced are not very common in other solvers. A big reason for this is that the backing infrastructure that makes it work well seems to be quite a lot of implementation-work even just as a starting step. I'm thinking about the logical precedence networks and timlines (see &lt;a href=&quot;https://icaps17.icaps-conference.org/tutorials/T3-Introduction-to-CP-Optimizer-for-Scheduling.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://icaps17.icaps-conference.org/tutorials/T3-Introduction-to-CP-Optimizer-for-Scheduling.pdf&lt;/a&gt; starting at slide 220). Apart from implementing the networks, all the propagators need to use them also which is a lot of work.&lt;/p&gt;&#xA;&lt;p&gt;In addition, it is not known how well those would work in another solver without all the other innovations in CP Optimizer, such as their automatic, parallel, randomized, deterministic search.&lt;/p&gt;&#xA;&lt;p&gt;As a Gecode developer, I would love to have the time to implement something similar since it seems so useful. Unfortunately, that is very unlikely to happen. What we do have are classical CP constraints such as cumulative that can operate on optional variable (for examples, see constraints &lt;a href=&quot;https://www.gecode.org/doc-latest/reference/group__TaskModelIntScheduling.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gecode.org/doc-latest/reference/group__TaskModelIntScheduling.html&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2022-01-31T14:58:21.683" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7717" PostTypeId="2" ParentId="7706" CreationDate="2022-01-31T16:05:58.973" Score="16" Body="&lt;p&gt;I'm not sure that the terminology is used consistently enough to give a firm answer. Pretty much everyone would agree (I think) that the TSP is a combinatorial optimization problem. To me, asking whether it is an &amp;quot;integer optimization problem&amp;quot; or an &amp;quot;integer programming problem&amp;quot; assumes a particular &lt;em&gt;representation&lt;/em&gt; (encoding?) of the TSP. Can I solve a TSP using an integer program? Yes (at least for modest problem sizes). Is that the only way to represent or solve it? I think not.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-31T16:05:58.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7718" PostTypeId="2" ParentId="7709" CreationDate="2022-01-31T16:12:10.987" Score="1" Body="&lt;p&gt;Sometimes a recalcitrant best bound is a sign of a loose formulation. Sometimes it might have to do with numerical issues in the model. Symmetry could be a reason. Sometimes, I think, it's just karma. (If you are able to fix that, please post the method here.)&lt;/p&gt;&#xA;&lt;p&gt;If your model is a &amp;quot;big M&amp;quot; type model, you might look for ways to shrink your &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; values, or possibly investigate an alternative approach. If you can identify inherent symmetry in the model, you might be able to add symmetry-breaking constraints (which might or might not pay for themselves). Possibly there is an entirely different and tighter formulation for your problem.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, there is no general fix (independent of the model details) for this. If there were, the commercial solvers would have it by now.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-31T16:12:10.987" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7719" PostTypeId="2" ParentId="7714" CreationDate="2022-01-31T16:36:51.560" Score="4" Body="&lt;p&gt;My introduction to &amp;quot;rolling horizons&amp;quot; (which seemed gentle enough at the time) came from a long since forgotten article or two where the technique was applied to problems in production planning and inventory management. So you might want to look for articles or textbooks in the operations management area that mention it, as opposed to the (more technical) operations research literature.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-31T16:36:51.560" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7720" PostTypeId="1" AcceptedAnswerId="7737" CreationDate="2022-01-31T16:47:49.017" Score="7" ViewCount="1854" Body="&lt;p&gt;I am running a simulation where I need to repeatedly solve a set of LPs or QPs with slightly different input parameters for a Model Predictive Control application. The problem is I need it to be fast, so exploiting some parallelization is probably required? Ideally in Python.&lt;/p&gt;&#xA;&lt;p&gt;Here is the problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \underset{u_{i,j,k}}{\text{min}} \quad J_{i,j} = \sum_{k=0}^{N=30} \Bigg( R_{i,j,k} u_{i,j,k} + x_{i,j,k}^\top Q_{i,j,k} x_{i,j,k} \Bigg) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_{i,j,k+1} = A_{i,k} x_{i,j,k} + B_{i,k} u_{i,j,k} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \underline{u}_{i,j,k} \leq u_{i,j,k} \leq \overline{u}_{i,j,k} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \underline{x}_{i,j,k} \leq x_{i,j,k} \leq \overline{x}_{i,j,k} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x_{i,j,0} = x_i^{(0)} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ i \in \{1,  ..., 30\} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ j \in \{1, ..., 30\} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$x^\top Q x$&lt;/span&gt; could also be modeled as &lt;span class=&quot;math-container&quot;&gt;$Qx$&lt;/span&gt; to keep the problem linear.&lt;/p&gt;&#xA;&lt;p&gt;Some ideas I've had so far:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Treating the set as one big optimization problem:&lt;/strong&gt; This works but is incredibly slow (using Pyomo and CPLEX and CVXPy). Maybe there is another library designed for fast repeated solving like this.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Using a GPU computing library like Pytorch and running gradient descent in parallel:&lt;/strong&gt; We would convert the constrained LP/QP into a unconstrained NLP with logarithmic barrier functions. Essentially interior point method on the GPU. Could potentially be faster but could become a pretty complex implementation.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multi-parametric programming/Explicit MPC:&lt;/strong&gt; Probably the most optimal solution but I cannot find a method to solve for the explicit solution. The difficulty is that &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; is a linear cost and can be negative. &lt;strong&gt;UPDATE:&lt;/strong&gt; This is infeasible due to the problem size and time-varying state space matrices.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Any other ideas?&lt;/p&gt;&#xA;" OwnerUserId="9053" LastEditorUserId="9053" LastEditDate="2022-02-01T13:35:06.990" LastActivityDate="2022-02-25T10:34:33.793" Title="Fast way to repeatedly solve many similar LPs/QPs in parallel" Tags="|optimization|cplex|convex-optimization|parallel-computing|optimal-control|" AnswerCount="5" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="7721" PostTypeId="2" ParentId="7720" CreationDate="2022-01-31T17:21:58.607" Score="8" Body="&lt;p&gt;The &lt;a href=&quot;https://go.documentation.sas.com/doc/en/pgmsascdc/v_022/casmopt/casmopt_optmodel_toc.htm&quot; rel=&quot;noreferrer&quot;&gt;OPTMODEL&lt;/a&gt; modeling language in SAS (disclaimer: I work at SAS) supports two features for solving independent optimization (LP or otherwise) problems concurrently:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://go.documentation.sas.com/doc/en/pgmsascdc/v_022/casmopt/casmopt_optmodel_syntax11.htm#casmopt.optmodel.npxcoforstmt&quot; rel=&quot;noreferrer&quot;&gt;COFOR&lt;/a&gt; loop, which automatically parallelizes the solver calls.&lt;/li&gt;&#xA;&lt;li&gt;The runOptmodel action supports &lt;a href=&quot;https://go.documentation.sas.com/doc/en/pgmsascdc/v_022/casactmopt/casactmopt_optimization_details05.htm&quot; rel=&quot;noreferrer&quot;&gt;BY-group processing&lt;/a&gt;, which automatically parallelizes everything (data processing, problem generation, solver calls, etc.) for problems that have the same structure but different data.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For LP and MILP, an alternative approach is to formulate as one big problem and use the &lt;a href=&quot;https://go.documentation.sas.com/doc/en/pgmsascdc/v_022/casmopt/casmopt_decomp_syntax03.htm#casmopt.decomp.dcmpmethod&quot; rel=&quot;noreferrer&quot;&gt;METHOD=CONCOMP&lt;/a&gt; option in the decomposition algorithm.&lt;/p&gt;&#xA;&lt;p&gt;All three features have Python interfaces.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-01-31T17:21:58.607" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7722" PostTypeId="2" ParentId="7720" CreationDate="2022-01-31T17:33:24.480" Score="6" Body="&lt;p&gt;A very easy way to do this is to use &lt;code&gt;multiprocessing&lt;/code&gt; alongside &lt;code&gt;cvxpy&lt;/code&gt;. It won't be fastest possible, but since you want to stick to Python and avoid low level C/C++/Fortran code it's clear that you intend to leave some performance on the table for ease of implementation (and I don't blame you).&lt;/p&gt;&#xA;&lt;p&gt;Here's an example of how to do it, taken from the &lt;a href=&quot;https://www.cvxpy.org/tutorial/intro/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;cvxpy documentation&lt;/a&gt;. This solves a Lasso problem for various values of the penalty parameter, but the extension to LPs (or what looks like QPs in your post) should be clear.&lt;/p&gt;&#xA;&lt;p&gt;As an added bonus, this only uses free and open source tools. You can optionally decide to link &lt;code&gt;cvxpy&lt;/code&gt; to a commercial solver if you have one available.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import cvxpy as cp&#xA;import numpy&#xA;import matplotlib.pyplot as plt&#xA;&#xA;# Problem data.&#xA;n = 15&#xA;m = 10&#xA;numpy.random.seed(1)&#xA;A = numpy.random.randn(n, m)&#xA;b = numpy.random.randn(n)&#xA;# gamma must be nonnegative due to DCP rules.&#xA;gamma = cp.Parameter(nonneg=True)&#xA;&#xA;# Construct the problem.&#xA;x = cp.Variable(m)&#xA;error = cp.sum_squares(A @ x - b)&#xA;obj = cp.Minimize(error + gamma*cp.norm(x, 1))&#xA;prob = cp.Problem(obj)&#xA;&#xA;from multiprocessing import Pool&#xA;# Assign a value to gamma and find the optimal x.&#xA;def get_x(gamma_value):&#xA;    gamma.value = gamma_value&#xA;    result = prob.solve()&#xA;    return x.value&#xA;&#xA;# Parallel computation (set to 1 process here).&#xA;pool = Pool(processes = 1)&#xA;x_values = pool.map(get_x, gamma_vals)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3066" LastEditorUserId="3066" LastEditDate="2022-02-01T00:30:19.187" LastActivityDate="2022-02-01T00:30:19.187" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7723" PostTypeId="2" ParentId="7720" CreationDate="2022-01-31T19:11:34.393" Score="5" Body="&lt;p&gt;If I understand this correctly, you are solving 900 QPs (one for each combination of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;), tweaking the parameters, then solving all 900 again (and again). One possibility to try would be hot-starting each problem (after the initial round of 900) using the solution to the problem from the previous round with the same &lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt; combination. This would require storing and reading the 900 current solutions. Whether hot starting helps or not depends on how much the models change (and, frankly, chance).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-01-31T19:11:34.393" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7724" PostTypeId="2" ParentId="7709" CreationDate="2022-02-01T12:40:33.110" Score="2" Body="&lt;p&gt;In a MIP that we are currently working on, one approach that was helpful was the relaxation of some constraints: This might seem counterintuitive at first, because it would result in weaker best bounds. However for this &amp;quot;relaxed model&amp;quot; many of the original decision variables could be dropped, resulting in a much smaller MIP. The B&amp;amp;B could now process the nodes much faster and made faster progress on the best bound. The best bound for the relaxed model then also presents a best bound for the more constrained original model. Ideally, this new best bound is then lower (in your case) than the best bound that you currently determine.&lt;/p&gt;&#xA;&lt;p&gt;Whether this approach is applicable to your problem or not, I do not know, but maybe it is worth investigating.&lt;/p&gt;&#xA;" OwnerUserId="6082" LastActivityDate="2022-02-01T12:40:33.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7726" PostTypeId="1" AcceptedAnswerId="7727" CreationDate="2022-02-01T14:06:44.297" Score="10" ViewCount="1727" Body="&lt;p&gt;I'm using Gurobi and trying to set a constraint that two variables &lt;code&gt;A&lt;/code&gt;, &lt;code&gt;B&lt;/code&gt; are not equal &lt;code&gt;model.addConstr(A != B)&lt;/code&gt; and seems like there isn't a not equal sign in Gurobi library. Is there any mathematical intuition that why we can't perform not equal in Optimization?&lt;/p&gt;&#xA;" OwnerUserId="8993" LastEditorUserId="2556" LastEditDate="2022-02-01T17:55:10.633" LastActivityDate="2022-02-01T17:55:10.633" Title="No &quot;not equals&quot; constraint in Gurobi" Tags="|modeling|constraint|gurobi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7727" PostTypeId="2" ParentId="7726" CreationDate="2022-02-01T14:19:18.680" Score="15" Body="&lt;p&gt;If you want &lt;span class=&quot;math-container&quot;&gt;$x_1\neq x_2$&lt;/span&gt;, you can linearize &lt;span class=&quot;math-container&quot;&gt;$|x_1-x_2|\ge \varepsilon$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt; is your tolerance.&lt;/p&gt;&#xA;&lt;p&gt;You can do this by introducing a boolean variable &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$x_1-x_2\ge \varepsilon$&lt;/span&gt;, and by imposing:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_1-x_2\le -\varepsilon +My\quad \mbox{and}\quad x_1-x_2\ge \varepsilon-(1-y)M&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is the smallest large constant you can think of.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-02-01T14:19:18.680" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7729" PostTypeId="1" CreationDate="2022-02-01T14:59:14.380" Score="3" ViewCount="123" Body="&lt;p&gt;I would appreciate any feedback on my understanding of &amp;quot;rolling horizon in optimization&amp;quot;.&#xA;I'll try to point out, what is my understanding of it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;First in simple words:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;You have an optimization problem considering several timesteps. So the decision variables are additionally indexed in the set of timesteps &lt;span class=&quot;math-container&quot;&gt;$\mathcal{T}$&lt;/span&gt;. For example, in the first horizon &lt;span class=&quot;math-container&quot;&gt;$\mathcal{T}=\{0,1,2\}$&lt;/span&gt;, then in the next horizon it is &lt;span class=&quot;math-container&quot;&gt;$\mathcal{T}=\{1,2,3\}$&lt;/span&gt; an then &lt;span class=&quot;math-container&quot;&gt;$\mathcal{T}=\{2,3,4\}$&lt;/span&gt; and so on &lt;span class=&quot;math-container&quot;&gt;$\dots$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then you solve the optimization problem for each horizon and get values for decision variables &lt;span class=&quot;math-container&quot;&gt;$\{x_0^0,x_1^0,x_2^0\}$&lt;/span&gt; in the first horizon, than &lt;span class=&quot;math-container&quot;&gt;$\{x_1^1,x_2^1,x_3^1\}$&lt;/span&gt; for the second horizon and &lt;span class=&quot;math-container&quot;&gt;$\{x_2^2,x_3^2,x_4^2\}$&lt;/span&gt; for the third horizon, where the superscripts denote the number of the current horizon.&lt;/p&gt;&#xA;&lt;p&gt;Then you take the first results of each horizon, so &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; from the first horizon, &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; from the second horizon and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; from the third horizon and so on. And you append it to a list of results, I will call it &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$X=\{x_0^0,x_1^1,x_2^2\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Further, one has to make sure, that the horizons are coupled to each other, so the value of the first timestep of the second horizon is set to the second timestep of the first horizon, so that &lt;span class=&quot;math-container&quot;&gt;$x_1^1=x_1^0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_2^2=x_2^1$&lt;/span&gt;, and so on &lt;span class=&quot;math-container&quot;&gt;$\dots$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;And now for the mathematical aspect:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let's consider the following problem: a company producing goods &lt;span class=&quot;math-container&quot;&gt;$x_{t,p}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$t\in\mathcal{T}:=\{0,1,2\}$&lt;/span&gt; is the timestep and &lt;span class=&quot;math-container&quot;&gt;$p\in\mathcal{P}:=\{0,1\}$&lt;/span&gt; is the type of good. Each good can be sold for a price &lt;span class=&quot;math-container&quot;&gt;$r_{t,p}$&lt;/span&gt;. But each good also needs some ressources to be created &lt;span class=&quot;math-container&quot;&gt;$c_{t,p,a}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$a\in\mathcal{A}:=\{0,1\}$&lt;/span&gt; denotes the type of required ressource and &lt;span class=&quot;math-container&quot;&gt;$s_{t,a}$&lt;/span&gt; is the available amount of each ressource. Only whole, positive numbers are allowed for the number of goods to produce.&lt;/p&gt;&#xA;&lt;p&gt;So a formulation could be:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\begin{split}&#xA;\mathrm{max.}\qquad&amp;amp;\sum_{t\in\mathcal{T}}\sum_{p\in\mathcal{P}}r_{t,p}\cdot x_{t,p}\\&#xA;\mathrm{s.t.}\qquad&amp;amp;\sum_{p\in\mathcal{P}}c_{t,p,a}\cdot x_{t,p}\leq s_{t,a}\qquad\forall a\in\mathcal{A}\quad\forall t\in\mathcal{T} \\&#xA;&amp;amp;x_{t,p}\in\mathbb{Z}^+\qquad\forall p\in\mathcal{P}\quad\forall t\in\mathcal{T}&#xA;\end{split}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or formulated as matrices:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \begin{split}&#xA;    \mathrm{max.}\qquad&amp;amp;c^T \cdot x \\&#xA;    \mathrm{s.t.}\qquad&amp;amp;A\cdot x\leq b \\&#xA;    &amp;amp;x_i\in\mathbb{Z}^+\qquad\forall i\in\mathcal{I}&#xA;    \end{split}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And now the &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; change their values for different horizons. For example &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; in the first horizon looks like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    c^T=&#xA;    \begin{pmatrix}&#xA;        r_{0,0} \\&#xA;        r_{0,1} \\&#xA;        r_{1,0} \\&#xA;        r_{1,1} \\&#xA;        r_{2,0} \\&#xA;        r_{2,1} \\&#xA;    \end{pmatrix}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;but then in the next horizon it becomes:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \label{c-vec}&#xA;    c^T=&#xA;    \begin{pmatrix}&#xA;        r_{1,0} \\&#xA;        r_{1,1} \\&#xA;        r_{2,0} \\&#xA;        r_{3,1} \\&#xA;        r_{3,0} \\&#xA;        r_{3,1} \\&#xA;    \end{pmatrix}&#xA;\end{equation}&lt;/span&gt;&#xA;so the values seem to shift from the bottom to the top.&lt;/p&gt;&#xA;&lt;p&gt;The same can be observed for &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    x=&#xA;    \begin{pmatrix}&#xA;        x_{0,0} \\&#xA;        x_{0,1} \\&#xA;        x_{1,0} \\&#xA;        x_{1,1} \\&#xA;        x_{2,0} \\&#xA;        x_{2,1} \\&#xA;    \end{pmatrix}&#xA;\to&#xA;\begin{pmatrix}&#xA;        x_{1,0} \\&#xA;        x_{1,1} \\&#xA;        x_{2,0} \\&#xA;        x_{2,1} \\&#xA;        x_{3,0} \\&#xA;        x_{3,1} \\&#xA;    \end{pmatrix}&#xA;\cdots&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And in the &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; matrix the values seem to shift along the main diagonal:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \label{A-mat}&#xA;    A=&#xA;    \begin{pmatrix}&#xA;        c_{0,0,0} &amp;amp; c_{0,0,1} &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;        c_{0,1,0} &amp;amp; c_{0,1,1} &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;        0 &amp;amp; 0 &amp;amp; c_{1,0,0} &amp;amp; c_{1,0,1} &amp;amp; 0 &amp;amp; 0 \\&#xA;        0 &amp;amp; 0 &amp;amp; c_{1,1,0} &amp;amp; c_{1,1,1} &amp;amp; 0 &amp;amp; 0 \\&#xA;        0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; c_{2,0,0} &amp;amp; c_{2,0,1} \\&#xA;        0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; c_{2,1,0} &amp;amp; c_{2,1,1} \\&#xA;    \end{pmatrix}&#xA;\to&#xA;\begin{pmatrix}&#xA;        c_{1,0,0} &amp;amp; c_{1,0,1} &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;        c_{1,1,0} &amp;amp; c_{1,1,1} &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\&#xA;        0 &amp;amp; 0 &amp;amp; c_{2,0,0} &amp;amp; c_{2,0,1} &amp;amp; 0 &amp;amp; 0 \\&#xA;        0 &amp;amp; 0 &amp;amp; c_{2,1,0} &amp;amp; c_{2,1,1} &amp;amp; 0 &amp;amp; 0 \\&#xA;        0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; c_{3,0,0} &amp;amp; c_{3,0,1} \\&#xA;        0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; c_{3,1,0} &amp;amp; c_{3,1,1} \\&#xA;    \end{pmatrix}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Sorry for the whole lot of text. But that is my current understanding of rolling horizon in optimization. Is it correct? And is there maybe a way to point it out in a single equation or so, or at least a form little bit shorter than what I have written?&#xA;For example, I'm not even sure, if this &lt;span class=&quot;math-container&quot;&gt;$x_n^m$&lt;/span&gt; is allowed, as one might mistake the &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; for a &amp;quot;normal&amp;quot; exponent.&lt;/p&gt;&#xA;" OwnerUserId="9052" LastEditorUserId="491" LastEditDate="2022-02-09T20:11:53.160" LastActivityDate="2022-02-09T20:11:53.160" Title="Is my understanding of rolling horizon correct?" Tags="|optimization|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7730" PostTypeId="1" AcceptedAnswerId="7742" CreationDate="2022-02-01T18:46:50.280" Score="2" ViewCount="71" Body="&lt;p&gt;Suppose a set of partially connected nodes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All nodes are in set A xor in Set B (i.e. Bipartite Graph)&lt;/li&gt;&#xA;&lt;li&gt;All nodes have a &lt;code&gt;datetime&lt;/code&gt; property.&lt;/li&gt;&#xA;&lt;li&gt;Connections in the Bipartite Graph exist if-and-only-if the (absolute) difference in &lt;code&gt;datetime&lt;/code&gt; &amp;lt; &lt;code&gt;limitValue&lt;/code&gt; (and the Nodes are in opposing sets, obviously)&lt;/li&gt;&#xA;&lt;li&gt;Nodes and Connections have no other relevant properties (weights, directions, etc.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Goal: Find a maximal Matching of the Nodes.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;Hypothesis:&lt;/p&gt;&#xA;&lt;p&gt;Whilst a normal BPG requires Ford-Fulkerson or similar to find a Maximal Matching, I suspect that a simple Greedy algorithm is sufficient to optimise this scenario, because the rules for connections exclude the sorts of situations that would break a Greedy approach.&lt;/p&gt;&#xA;&lt;p&gt;Specifically, I think you can just order all the nodes, and then walk up the list pairing adjacent opposite-set nodes, whenever you pass them.&lt;/p&gt;&#xA;&lt;p&gt;Is this correct? If so, how would one go about proving it?&lt;/p&gt;&#xA;" OwnerUserId="4568" LastEditorUserId="500" LastEditDate="2022-02-01T18:50:50.443" LastActivityDate="2022-02-03T00:01:40.783" Title="Maximal Matching in a constrained, unweighted Bipartite Graph" Tags="|optimization|graphs|matching|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7731" PostTypeId="1" CreationDate="2022-02-01T21:57:22.863" Score="2" ViewCount="35" Body="&lt;p&gt;In the &lt;a href=&quot;https://en.wikipedia.org/wiki/Graph_edit_distance&quot; rel=&quot;nofollow noreferrer&quot;&gt;graph edit distance (GED)&lt;/a&gt;, we are looking to find the cost of modifying one graph &lt;span class=&quot;math-container&quot;&gt;$G_1$&lt;/span&gt; to another graph &lt;span class=&quot;math-container&quot;&gt;$G_2$&lt;/span&gt;. Is the sequence of operations that take &lt;span class=&quot;math-container&quot;&gt;$G_1$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$G_2$&lt;/span&gt; of interest in this problem? Or is it typically just the cost that is of interest?&lt;/p&gt;&#xA;&lt;p&gt;I realise that finding the operations is likely to be one way to obtain the GED, but I am curious to know whether people are actually interested in these operations? For instance, if a heuristic could simply find(/approximate) the GED without returning the operations (for instance, machine learning based methods have been used to estimate the GED by comparing the distance in an embedding space of the two graphs) would this be considered as interesting as also knowing the operations?&lt;/p&gt;&#xA;&lt;p&gt;To me personally it seems that having a heuristic that can actually obtain the operations required to modify &lt;span class=&quot;math-container&quot;&gt;$G_1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$G_2$&lt;/span&gt; (that minimises the cost of doing so) would be the interesting part of the problem, but after having done some initial reading it seems that just estimating the GED is sufficient.&lt;/p&gt;&#xA;" OwnerUserId="7471" LastActivityDate="2022-02-01T21:57:22.863" Title="Are the operations in the Graph Edit Distance problem of interest?" Tags="|combinatorial-optimization|graphs|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7732" PostTypeId="1" CreationDate="2022-02-02T03:44:46.923" Score="1" ViewCount="51" Body="&lt;p&gt;I created a clustering algorithm to determine the optimal number of clusters from a dataset that has information on rural properties. I use hierarchical agglomerative clustering for this. Basically, I use two criteria for generating these clusters, which is production of waste from properties and logistical costs. However, I see the need to consider integrating other approaches to evaluating the optimal number of clusters to improve reliability. I thought about using some multicriteria method, but I don't know which one to use, any tips?&lt;/p&gt;&#xA;" OwnerUserId="9063" LastActivityDate="2022-02-02T03:44:46.923" Title="Use multicriteria method with clustering" Tags="|clustering|multicriteria-decision-analysis|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7733" PostTypeId="1" CreationDate="2022-02-02T03:48:30.270" Score="2" ViewCount="117" Body="&lt;p&gt;Can anyone recommend a reference which shows the amount of time required for the Traveling Salesman Problem (TSP) to be solved using brute force as the number of cities increase?&lt;/p&gt;&#xA;&lt;p&gt;I have informally heard that a computer can not solve the TSP for more than 8 cities using brute force; and after 8 cities, the run time for the TSP becomes in years.&lt;/p&gt;&#xA;&lt;p&gt;I am very curious to see a reference where a table is given that shows how long a computer takes to solve the TSP for a different number of cities, and then shows the estimated amount of time to find exact solutions as the number of cities grows to around 15 cities.&lt;/p&gt;&#xA;&lt;p&gt;Can anyone please recommend something?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I found something like this &lt;a href=&quot;https://www.sciencedirect.com/topics/earth-and-planetary-sciences/traveling-salesman-problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sciencedirect.com/topics/earth-and-planetary-sciences/traveling-salesman-problem&lt;/a&gt; ... but I would be interested in knowing how the time estimates are calculated.&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-03T04:50:44.130" LastActivityDate="2022-02-03T04:50:44.130" Title="Traveling Salesman Reference" Tags="|optimization|reference-request|computational-complexity|traveling-salesman|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7734" PostTypeId="2" ParentId="7733" CreationDate="2022-02-02T06:55:03.163" Score="3" Body="&lt;p&gt;As far as I know, the computation time heavily depends on which software/hardware to be used for that, and maybe there is not an exact reference to this. The brute force algorithm is the easiest algorithm to implement for Traveling Salesman Problem exact solutions. However, it also has the slowest time complexity because the algorithm requires every permutation of a solution to be checked. When every solution has been processed, the cheapest one is chosen. The brute force algorithm has exactly &lt;span class=&quot;math-container&quot;&gt;$n!$&lt;/span&gt; permutations that need to be checked. Thus the time complexity is &lt;span class=&quot;math-container&quot;&gt;$O{(n!)}$&lt;/span&gt;.  It turns out that there are exactly &lt;span class=&quot;math-container&quot;&gt;$n!$&lt;/span&gt; = &lt;span class=&quot;math-container&quot;&gt;$1 \cdot 2 \cdot 3 \cdot \ldots&#xA;\cdot (n-1) \cdot n$&lt;/span&gt; different permutations of the numbers from &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n&#xA;- 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Also, for computation time, the following table would be interesting:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/W74dR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/W74dR.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-02-02T06:55:03.163" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7735" PostTypeId="1" CreationDate="2022-02-02T08:50:18.610" Score="7" ViewCount="991" Body="&lt;p&gt;I have been trying to find examples of major research studies examining the properties and performance of the &amp;quot;Branch and Bound&amp;quot; Algorithm compared to &amp;quot;Evolutionary Algorithms&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;For instance, in terms of popular types of mixed integer programming and combinatorics optimization problems (e.g. scheduling, knapsack problem, traveling salesman problem, etc.), have we developed any common consensus on &amp;quot;Branch and Bound&amp;quot; vs &amp;quot;Evolutionary Algorithms&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;It would be very interesting to learn more about which of these two types of algorithms (Branch and Bound vs Evolutionary Algorithms) are preferred in the Operations Research Industry for solving different types of mixed integer programming and combinatorics optimization problems. Perhaps there might be some tradeoffs, for example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Branch and Bound works better when the search space is bigger&lt;/li&gt;&#xA;&lt;li&gt;Evolutionary Algorithms take less time to run&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-03T04:46:56.320" LastActivityDate="2022-02-03T04:46:56.320" Title="Is &quot;Branch and Bound&quot; better than Evolutionary Algorithms?" Tags="|optimization|branch-and-bound|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7736" PostTypeId="2" ParentId="7735" CreationDate="2022-02-02T10:01:52.007" Score="10" Body="&lt;p&gt;First of all, evolutionary algorithms do not &lt;em&gt;solve&lt;/em&gt; optimisation problems. They provide feasible solutions (if you are lucky) often with no measure of the quality of the solution returned - hence they are heuristics.&lt;/p&gt;&#xA;&lt;p&gt;Branch and bound algorithms on the other hand solves your optimisation problem (given enough time to massage the problem). If you terminate the branch and bound code early you will usually have a measure of the quality of the best known solution as branch and bound algorithms maintain information on global upper and lower bounds.&lt;/p&gt;&#xA;&lt;p&gt;Hence, I would argue, that evolutionary algorithms &lt;em&gt;can&lt;/em&gt; be a &amp;quot;go to&amp;quot; if&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You are in a hurry and you cannot wait for a branch and bound algorithm to terminate.&lt;/li&gt;&#xA;&lt;li&gt;You are more interested in &lt;em&gt;a solution&lt;/em&gt; than &lt;em&gt;an optimal solution&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You cannot afford a good branch and bound based solver or you do not want to code one for your particular problem.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;That said, there may be many other (meta-) heuristics that would work just as well as an evolutionary algorithm on your problem. Even some that might be significantly easier to code.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-02-02T10:01:52.007" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7737" PostTypeId="2" ParentId="7720" CreationDate="2022-02-02T14:42:33.650" Score="6" Body="&lt;p&gt;After a good bit of experimentation based on the ideas posted, here was my solution:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Do as many matrix multiplications up front using pytorch on the GPU to simplify the problem.&lt;/strong&gt; This means two things. First combine &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,k+1} = A_{i,j,k} x_{i,j,k} + B_{i,j,k} u_{i,j,k}$&lt;/span&gt; into a lower triangular block matrix equation containing all timesteps:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \mathcal{X}_{i,j} = \mathcal{A}_{i,j} \mathcal{U}_{i,j}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation*}&#xA;\begin{bmatrix}&#xA;x_0 \\ x_1 \\ ... \\ x_{N}&#xA;\end{bmatrix} = &#xA;\begin{bmatrix}&#xA;I &amp;amp; 0 &amp;amp; ... &amp;amp; 0 \\ A_{i,j,0} &amp;amp; B_{i,j,0} &amp;amp; 0 &amp;amp; ... &amp;amp; 0 \\ &#xA;A_{i,j,1} A_{i,j,0} &amp;amp; A_{i,j,1} B_{i,j,0} &amp;amp; B_{i,j,1} &amp;amp; 0 &amp;amp; 0\\ ... &amp;amp; ... &amp;amp; ... &amp;amp; ... &amp;amp; ...&#xA;\end{bmatrix} &#xA;\begin{bmatrix}&#xA;x^{(0)}_{i,j} \\ u_{i,j,0} \\  ... \\  u_{i,j,N-1}&#xA;\end{bmatrix}&#xA;\end{equation*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, &lt;span class=&quot;math-container&quot;&gt;$Q_{i,j,k}$&lt;/span&gt; is very sparse, meaning that only a few &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; values matter. Therefore we can multiply the entries of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{A}_{i,j}$&lt;/span&gt; by a block matrix &lt;span class=&quot;math-container&quot;&gt;$\mathcal{C}$&lt;/span&gt; that masks each entry and reduces the dimension by a factor of ~10:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \mathcal{Y}_{i,j} = \mathcal{C} \mathcal{A}_{i,j} \mathcal{U}_{i,j}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This essentially performs all of the time-based matrix multiplications up front on the GPU &lt;em&gt;before&lt;/em&gt; building the model.&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;strong&gt;Use Gurobi's python API directly instead of a third party library like Pyomo&lt;/strong&gt; (if possible). This speeds up model building and allows the use of the &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/multiple_scenarios.html&quot; rel=&quot;noreferrer&quot;&gt;multiscenario&lt;/a&gt; interface. To prevent rebuilding the model if certain conditions are met. I think this functions similar to a warm start.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; A 1000x speedup from my original Pyomo+Gurobi implementation!&lt;/p&gt;&#xA;" OwnerUserId="9053" LastActivityDate="2022-02-02T14:42:33.650" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7738" PostTypeId="2" ParentId="7714" CreationDate="2022-02-02T15:21:23.797" Score="6" Body="&lt;p&gt;I typically use these images to explain rolling horizons (although I tend to call it &lt;strong&gt;continuous planning&lt;/strong&gt;), for example on employee rostering (but it works just as well on other use cases):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DBncN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DBncN.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WvZkk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WvZkk.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I explain these in detail in &lt;a href=&quot;https://www.youtube.com/shorts/p6V7VdAYFIc&quot; rel=&quot;nofollow noreferrer&quot;&gt;this video&lt;/a&gt; (and &lt;a href=&quot;https://www.youtube.com/shorts/0xdCimuvAGk&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;), but the general concepts to understand are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Draft vs publish vs history&lt;/strong&gt;: A draft schedule can be changed easily. Once it's published, it's hard to change - for example employees organize social events for on evenings the published schedule says they don't work - so you should minimize disruption when making changes on published schedules.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Publish notice&lt;/strong&gt;: how many weeks/minutes in advance does the schedule need to be published? For example: 3 weeks in advance.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Final draft length&lt;/strong&gt;: how often do you publish? For example: once a week&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Draft length&lt;/strong&gt;: how big is your planning window? In many cases, this should be longer than your final draft length, to avoid painting yourself in a corner for the next planning window.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Regardless if you're dealing with weeks, days, minutes or seconds, the principles are the same.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2024-01-15T13:44:50.500" LastActivityDate="2024-01-15T13:44:50.500" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7739" PostTypeId="1" CreationDate="2022-02-02T16:25:27.160" Score="2" ViewCount="274" Body="&lt;p&gt;I was watching the following video (&lt;a href=&quot;https://www.youtube.com/watch?v=-GWze-wtu60&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=-GWze-wtu60&lt;/a&gt; @ 9:30) and came across the following graph:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/m3jX4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/m3jX4.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This graph is meant to show the number of iterations required to achieve similar results on the same function for different optimization algorithms. As we can see in this graph, it appears that &amp;quot;Gradient Free Algorithms&amp;quot; (e.g. Genetic Algorithm) seems to require far more iterations than &amp;quot;Gradient Based Algorithms&amp;quot; - especially as the number of variables increase.&lt;/p&gt;&#xA;&lt;p&gt;I have always heard the opposite remark being made. Especially in higher dimension problems (i.e. where there are more variables), evaluating the derivatives of complicated loss functions (e.g. the loss functions in machine learning models, neural networks) can become very expensive. &lt;strong&gt;This fact is supposed to be one of the main advantages of Gradient Free Algorithms - Gradient Free Algorithms make a sacrifice in terms of their ability to converge, but instead do not require as much computational costs when compared to Gradient Based Algorithms. However, the above graph seems to be negating this fact.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In general, are Gradient Free Algorithms really said to scale as poorly to higher dimensional problems as indicated in the above graph?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-03T04:45:28.500" LastActivityDate="2022-02-03T04:45:28.500" Title="Comparing Number of Iterations Between Different Optimization Algorithms" Tags="|optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7740" PostTypeId="1" CreationDate="2022-02-02T20:00:09.127" Score="2" ViewCount="115" Body="&lt;p&gt;We know that in many applied contexts (e.g. Machine Learning, Loss Functions for Neural Networks), the functions we are trying to optimize are &amp;quot;noisy&amp;quot; by definition (unlike in the classical sense, when we are only required to optimize &amp;quot;deterministic functions&amp;quot;). This is because these functions are based on measurements that we have (i.e. the data), and it is very possible that these measurements can either contain some &amp;quot;measurement error&amp;quot; or these same measurements could take different values if we were to measure them again (i.e. &amp;quot;stochastic&amp;quot;).&lt;/p&gt;&#xA;&lt;p&gt;I have heard that Bayesian Optimization techniques are generally favored for instances where the gradient of the loss function does not exist (e.g. discrete/combinatorial problems) - but I am particularly interested in learning about the effectiveness of Bayesian Optimization Methods on &amp;quot;Noisy Functions&amp;quot;. For instance, (my very limited knowledge of this topic tells me that) Bayesian Optimization uses a Gaussian Process to &amp;quot;reconstruct&amp;quot; the surface of the Loss Function based on the data we have , and our confidence in this surface is iteratively updated as we perform the optimization task.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is it because of this fact (i.e. modelling the loss surface of the objective function using a Gaussian Process) that Bayesian Optimization methods are said to be effective at optimizing &amp;quot;noisy functions&amp;quot;? Does doing so somehow result in solutions with a higher level of statistical robustness? In general - why do we say that Bayesian Optimization is more effective at optimizing noisy functions?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-03T04:43:53.717" LastActivityDate="2022-02-14T00:45:32.693" Title="Do Bayesian Optimization Methods Better Handle &quot;Noisy Functions?&quot;" Tags="|optimization|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7741" PostTypeId="2" ParentId="7739" CreationDate="2022-02-02T20:38:32.520" Score="3" Body="&lt;p&gt;I don't recall ever seeing a claim that gradient-free algorithms had lower computational costs than gradient-based algorithms. The reasons I recall for introducing gradient-free algorithms had to do with (a) cases where the function is not smooth and the gradient simply does not exist, (b) cases where the gradient exists (at least piecewise) but gradient-based algorithms tend to oscillate or get stuck and (c) cases where the gradient may exist but you do not know how to calculate it (for instance, optimizing the output of a simulation program without approximating the response surface).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-02T20:38:32.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7742" PostTypeId="2" ParentId="7730" CreationDate="2022-02-03T00:01:40.783" Score="4" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$I, J$&lt;/span&gt; be the two sets of nodes and let both be sorted by their datetime.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; be the set of valid edges.&#xA;For each &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; let &lt;span class=&quot;math-container&quot;&gt;$D_i$&lt;/span&gt; be the neighbours of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&#xA;Your proposed greedy algorithm will then do the following.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;M = {}&#xA;Q_I = {}&#xA;Q_J = J&#xA;for i in I ascending:&#xA;   if empty(intersection(D_i,Q_J)):&#xA;      Q_I.append(i)&#xA;   else:&#xA;      j = min(intersection(D_i,Q_J))&#xA;      M.append((i,j))&#xA;      Q_J.remove(j)&#xA;return M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a maximal matching.&#xA;The proof uses that a matching in a bipartite graph is maximal iff there is no augmenting path.&lt;/p&gt;&#xA;&lt;p&gt;Assume there was an augmenting path.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be an augmenting path of minimal length.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; be the smallest appearing node from set &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Case 1: &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; has only one adjacent edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;. This would imply &lt;span class=&quot;math-container&quot;&gt;$i\in Q_I$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is an augmenting path.&#xA;But as the neighbour &lt;span class=&quot;math-container&quot;&gt;$i'$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is bigger than &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; would have still been in &lt;span class=&quot;math-container&quot;&gt;$Q_J$&lt;/span&gt; at the point where the algorithm considered &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, which is a contradiction to &lt;span class=&quot;math-container&quot;&gt;$i\in Q_I$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Case 2: &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; has two adjacent edges &lt;span class=&quot;math-container&quot;&gt;$(i,j), (i,j')$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in M$&lt;/span&gt;. Then by the choice of the neighbouring edge in the algorithm &lt;span class=&quot;math-container&quot;&gt;$j&amp;lt;j'$&lt;/span&gt;.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$(i',j)$&lt;/span&gt; be the next edge following &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;.&#xA;As &lt;span class=&quot;math-container&quot;&gt;$j'&amp;gt;j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i'&amp;gt;i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(i',j)\in E$&lt;/span&gt; by your daytime property also &lt;span class=&quot;math-container&quot;&gt;$(i',j')\in E$&lt;/span&gt;.&#xA;But then removing &lt;span class=&quot;math-container&quot;&gt;$(i',j), (i,j), (i,j')$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and adding &lt;span class=&quot;math-container&quot;&gt;$(i',j')$&lt;/span&gt; would also be an augmenting path contradicting the minimality of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4477" LastActivityDate="2022-02-03T00:01:40.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7743" PostTypeId="1" CreationDate="2022-02-03T01:54:07.620" Score="2" ViewCount="168" Body="&lt;p&gt;I am trying to understand how the idea of Sensitivity Analysis would apply to the Traveling Salesman Problem.&lt;/p&gt;&#xA;&lt;p&gt;For instance, suppose my optimization algorithm returned the following path as the shortest path between 7 cities:&lt;/p&gt;&#xA;&lt;p&gt;City 5, City 3, City 2, City 6, City 1, City 4, City 7&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;In the above case, how do we study the &amp;quot;Sensitivity Analysis&amp;quot; of this solution?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If the objective function in this problem was differentiable, I could have taken the solution returned by the optimization solution and added some random noise to the solution - then, I could have seen how different the solutions with random noise were compared to the solutions without random noise. For example - suppose the solution returned was &lt;span class=&quot;math-container&quot;&gt;$(x_1 = 2.1, x_2 = 13.4)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f(x_1,x_2) = 1.9 )$&lt;/span&gt;. I could see how much &lt;span class=&quot;math-container&quot;&gt;$f(x_1,x_2)$&lt;/span&gt; deviates from 1.9 for neighboring values of &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; (e.g. &lt;span class=&quot;math-container&quot;&gt;$x_1 = 2.2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_2 = 13.5$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In the Traveling Salesman Problem, my guess would be that I can randomly change the order for some of the cities and see how much these random changes affect the existing solution? For example, if &lt;strong&gt;City 5, City 3, City 2, City 6, City 1, City 4, City 7&lt;/strong&gt; is the optimal solution (e.g. suppose this path is 641 KM) - I could try  City 5, City 3, City 2, City 6, City 1, &lt;strong&gt;City 7, City 4&lt;/strong&gt; and see how much this new path measures (e.g. 712 KM).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is this how &amp;quot;Sensitivity Analysis&amp;quot; is conducted for discrete combinatorial problems?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-03T04:42:20.177" LastActivityDate="2022-02-04T02:08:42.417" Title="Sensitivity Analysis for Traveling Salesman" Tags="|optimization|combinatorial-optimization|traveling-salesman|sensitivity-analysis|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7744" PostTypeId="1" CreationDate="2022-02-03T08:44:16.283" Score="4" ViewCount="184" Body="&lt;p&gt;I would like to run a solvers comparison on several instances of MINLPLib. I can get the .NL files for each instance. Now, I would like to reformulate several instances and I need to edit the .NL files (in particular I would like to add a term to the objective function). I would ask you if you know an easy way to read and modify directly the .NL files for instance using Pyomo via Python.&lt;/p&gt;&#xA;" OwnerUserId="5964" LastEditorUserId="491" LastEditDate="2022-02-03T13:52:51.443" LastActivityDate="2022-02-03T13:52:51.443" Title="Edit .NL files to reformulate problem instances" Tags="|python|pyomo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7745" PostTypeId="2" ParentId="7744" CreationDate="2022-02-03T11:41:34.417" Score="5" Body="&lt;p&gt;It is basically impossible to edit a .nl file by hand correctly (unless it's a trivially simple file), since information about what's happening is distributed across the file in very non-obvious, partially undocumented, and order-dependent ways.&lt;/p&gt;&#xA;&lt;p&gt;One way you could do this in practice is to use the &lt;a href=&quot;https://github.com/Octeract/reformulator&quot; rel=&quot;noreferrer&quot;&gt;Octeract Reformulator API&lt;/a&gt; (it's free) to import the .nl file, modify what you want, and write to a new .nl file:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from octeract import *&#xA;&#xA;model = Model()&#xA;model.import_model_file(&amp;quot;/home/nikos/octeract/engine/test-libraries/stability_tests/ex6_1_1.nl&amp;quot;)&#xA;print(model)&#xA;obj = model.get_objective_function_string()&#xA;model.minimize(obj+&amp;quot;+sin(x1*x2)&amp;quot;)&#xA;print(model)&#xA;model.write_problem_to_NL_file(&amp;quot;myNewProblem.nl&amp;quot;)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2022-02-03T11:41:34.417" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7746" PostTypeId="2" ParentId="7691" CreationDate="2022-02-03T12:53:55.120" Score="3" Body="&lt;p&gt;I would argue with the previous comments, that MILP problem formulation is convex and that the theory of Convex Optimization could be applied to the MILP problems.&lt;/p&gt;&#xA;&lt;p&gt;First I would recommend you to read &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Book about Convex Optimization&lt;/a&gt; by Stephen Boyd and Lieven Vandenberghe. Stephen Boyd is a very respectful and famous mathematician in the optimization field.&lt;/p&gt;&#xA;&lt;p&gt;If we look at the definition of the convex function&lt;br /&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/zW87J.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zW87J.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/f8SJ2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/f8SJ2.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can see that definition of the &lt;strong&gt;convexity does not have anything to do with whether the function is differentiable&lt;/strong&gt; or not. However, the domain of a function f has to be a &lt;strong&gt;Convex Set&lt;/strong&gt;. Now let us look at the definition of the Convex Set&#xA;&lt;a href=&quot;https://i.stack.imgur.com/69RgJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/69RgJ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/vJ3Ob.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vJ3Ob.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Therefore, if the objective function has discreet variables, then we can never call it Convex function, because it is defined on the discreet space, and in this space, we can not draw an unobstructed straight path between two points.&lt;/p&gt;&#xA;&lt;p&gt;But it could be, for example, if you have binary variables in your objective, and then you consider your function at point [ 0 ] or &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/&quot; rel=&quot;nofollow noreferrer&quot;&gt; 1 &lt;/a&gt;, the function &lt;strong&gt;could be&lt;/strong&gt; convex at exactly these points, but not on the whole discreet space.&lt;/p&gt;&#xA;" OwnerUserId="7626" LastEditorUserId="7626" LastEditDate="2022-02-03T17:18:15.080" LastActivityDate="2022-02-03T17:18:15.080" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7747" PostTypeId="1" CreationDate="2022-02-03T21:51:33.780" Score="2" ViewCount="268" Body="&lt;p&gt;I am trying to get Cplex working with pyomo.&#xA;I have followed Cplex installation instructions has explained here: &lt;a href=&quot;https://or.stackexchange.com/questions/4366/downloading-and-setting-up-cplex-for-pyomo&quot;&gt;Downloading and setting up CPLEX for Pyomo&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However when calling Cplex via pyomo I get the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;File &amp;quot;...\pyomo\opt\base\solvers.py&amp;quot;, line 607, in solve&#xA;    result = self._postsolve()&#xA;  File &amp;quot;...\pyomo\solvers\plugins\solvers\CPLEX.py&amp;quot;, line 906, in _postsolve&#xA;    results = ILMLicensedSystemCallSolver._postsolve(self)&#xA;  File &amp;quot;...\pyomo\opt\solver\shellcmd.py&amp;quot;, line 251, in _postsolve&#xA;    OUTPUT=open(self._log_file,&amp;quot;w&amp;quot;)&#xA;OSError: [Errno 22] Invalid argument: '&amp;quot;C:\\Users\\...\\AppData\\Local\\Temp\\tmppc5loeps.cplex.log&amp;quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have verified that &lt;code&gt;C:\Program Files\IBM\ILOG\CPLEX_Studio_Community201\cplex\bin\x64_win64&lt;/code&gt; is in the Path variable&lt;/p&gt;&#xA;" OwnerUserId="8723" LastEditorUserId="-1" LastEditDate="2022-02-04T09:40:41.923" LastActivityDate="2022-02-04T09:40:41.923" Title="Pyomo + Cplex - OSError: [Errno 22] Invalid argument" Tags="|python|cplex|pyomo|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7748" PostTypeId="2" ParentId="7691" CreationDate="2022-02-04T00:39:25.920" Score="6" Body="&lt;p&gt;You need to make a distinction between the problem itself, and its individual components (objective and constraints).&lt;/p&gt;&#xA;&lt;h1&gt;What is a convex problem?&lt;/h1&gt;&#xA;&lt;p&gt;Consider a generic optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    (P) \quad \min_{x \in \mathbb{R}^{n}} \quad &amp;amp; f(x)\\&#xA;    \text{s.t.} \quad &amp;amp; x \in \mathcal{X}&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{X} \subseteq \mathbb{R}^{n}$&lt;/span&gt; .&#xA;To settle the terminology: &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are the &lt;em&gt;decision variables&lt;/em&gt;, &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is the &lt;em&gt;objective function&lt;/em&gt;, and &lt;span class=&quot;math-container&quot;&gt;$x \in \mathcal{X}$&lt;/span&gt; are the &lt;em&gt;constraints&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The problem &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is &lt;strong&gt;convex&lt;/strong&gt; if&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{X}$&lt;/span&gt; is a convex set&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a convex function, which can be relaxed to &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is convex over &lt;span class=&quot;math-container&quot;&gt;$\mathcal{X}$&lt;/span&gt;&amp;quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For instance:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \quad \min_{x \in \mathbb{R}} \quad &amp;amp; x^{2}\\&#xA;    \text{s.t.} \quad &amp;amp; 0 \leq x \leq 1&#xA;\end{align}&lt;/span&gt;&#xA;is a convex problem because &lt;span class=&quot;math-container&quot;&gt;$x \rightarrow x^{2}$&lt;/span&gt; is convex and &lt;span class=&quot;math-container&quot;&gt;$\{x \in \mathbb{R} | 0 \leq x \leq 1\}$&lt;/span&gt; is a convex set.&#xA;On the other hand,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \quad \min_{x \in \mathbb{R}} \quad &amp;amp; x^{2}\\&#xA;    \text{s.t.} \quad &amp;amp; x \in \{0, 1\}&#xA;\end{align}&lt;/span&gt;&#xA;is &lt;strong&gt;not&lt;/strong&gt; a convex problem because &lt;span class=&quot;math-container&quot;&gt;$\{0, 1\}$&lt;/span&gt; is not a convex set.&lt;/p&gt;&#xA;&lt;p&gt;Note that in both examples, the objective function is well-defined, continuous, differentiable, and convex.&#xA;In the latter case, the non-convexity stems from the constraints, not in the objective.&lt;/p&gt;&#xA;&lt;h1&gt;What about differentiability?&lt;/h1&gt;&#xA;&lt;p&gt;Convexity is a &lt;em&gt;geometric&lt;/em&gt; property, which is not tied to differentiability.&#xA;For instance, the function &lt;span class=&quot;math-container&quot;&gt;$x \rightarrow |x|$&lt;/span&gt; is convex, but it is not differentiable at zero.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, a problem can be convex even if some of its components are non-differentiable.&#xA;For instance:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \quad \min_{x \in \mathbb{R}} \quad &amp;amp; |x|\\&#xA;    \text{s.t.} \quad &amp;amp; -1 \leq x \leq 1&#xA;\end{align}&lt;/span&gt;&#xA;is a convex problem.&lt;/p&gt;&#xA;&lt;p&gt;Differentiability influences the &lt;em&gt;algorithm&lt;/em&gt; you can use to solve a problem: some require derivatives, others don't.&#xA;For instance, gradient descent or Newton's method require derivatives, and cannot be applied out-of-the-box. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Ellipsoid_method&quot; rel=&quot;noreferrer&quot;&gt;ellipsoid method&lt;/a&gt; does not use gradients, and is therefore applicable to convex problems with some non-differentiable components.&lt;/p&gt;&#xA;&lt;h1&gt;Does convexity still matter when we have discrete decisions?&lt;/h1&gt;&#xA;&lt;p&gt;TLDR: Yes, yes and absolutely yes!&lt;/p&gt;&#xA;&lt;p&gt;You will often encounter in the optimization literature the term &amp;quot;Mixed-Integer XXX Programming&amp;quot;, e.g., &amp;quot;Mixed-integer Linear Programming&amp;quot;, &amp;quot;Mixed-Integer Convex Programming&amp;quot;, etc.&#xA;The first part indicates that some variables are restricted to take integer values. The second part usually refers to everything else.&lt;/p&gt;&#xA;&lt;p&gt;For instance, a Mixed-Integer Linear Programming (MILP) problem is a problem where (i) some variables must be integer and (ii) everything else is linear. For Mixed-Integer Convex Programming (MICP) problems, (i) some variables must be integer and (ii) everything else is convex.&#xA;Integrality constraints are non-convex, so mixed-integer problems are not convex.&lt;/p&gt;&#xA;&lt;p&gt;However, drop the integrality requirements from an MICP problem, and you get a convex problem! This is known as a &lt;em&gt;convex relaxation&lt;/em&gt;, and it's the fundamental building block of many optimization algorithms for mixed-integer programming.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2022-02-04T00:39:25.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7749" PostTypeId="2" ParentId="7743" CreationDate="2022-02-04T02:08:42.417" Score="3" Body="&lt;p&gt;You can certainly do sensitivity/parametric analysis on the objective function. If you are interested in the effect of changing a single coefficient in a linear objective function to be minimized, e.g. as in the TSP, then a general result is that the optimal objective value is a concave function (typically piecewise linear) of the coefficient that is being varied, even if there are integrality constraints, e.g., as in the TSP. See Geoffrion &amp;amp; Nauss, Man. Sci. 1977.  For arbitrary coefficients in the model, not just the objective, things are a little messier, e.g., see Schrage &amp;amp; Wolsey, Operations Research, 1985.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-02-04T02:08:42.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7750" PostTypeId="1" CreationDate="2022-02-04T05:43:51.997" Score="4" ViewCount="1484" Body="&lt;p&gt;We are always told that the Simplex Algorithm is meant for solving linear equations with linear constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;But how badly would the Simplex Algorithm perform if we implemented it on a typical non-linear problem that is better suited for algorithms such as the Interior Point Method?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For instance, the Simplex Algorithm &amp;quot;scans&amp;quot; different vertices on the exterior surface made by the intersection of all equations and constraints - I am not sure if the surface made by non-linear equations and non-linear constraints would even have vertexes?&lt;/p&gt;&#xA;&lt;p&gt;For argument sake, if someone insisted on using the Simplex Algorithm on a non-linear problem, would this fail instantly? Or could it still in theory return an acceptable answer, but it would be unlikely that this answer was the true optimal?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-04T13:27:08.237" LastActivityDate="2022-02-04T13:27:08.237" Title="Have we understood the limitations of the Simplex method on nonlinear programs?" Tags="|optimization|linear-programming|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7751" PostTypeId="2" ParentId="7750" CreationDate="2022-02-04T07:48:26.730" Score="8" Body="&lt;p&gt;There are two points to this:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The convergence of the Simplex algorithm relies on the fact that an optimal solution can always be found in a vertex. This does not hold for non-linear problems (consider e.g. &lt;span class=&quot;math-container&quot;&gt;$\min x^2$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x \in [-1,1]$&lt;/span&gt;). If an algorithm cannot converge, how would this then work in practice?&lt;/li&gt;&#xA;&lt;li&gt;The power of simplex is based on solving sets of linear equations. But if the problem is non-linear, then you have to solve sets of non-linear equations which is problematic from a computational, algorithmic and numeric standpoint.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So in my opinion using Simplex out of the box will not work. You could argue that you can always construct a linear inner or outer McCormick relaxation such that Simplex becomes usable again, but this will not compete with a well-written Interior Point method.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2022-02-04T07:48:26.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7752" PostTypeId="2" ParentId="7750" CreationDate="2022-02-04T08:32:05.323" Score="4" Body="&lt;p&gt;Besides the useful answer of Richard, solving the non-linear equation/constraint by Simplex came back which non-linear terms you have faced in your problem. For example, multiplication of the variables are fallen in the non-linear class problems, but many of them can be reformulated as a MILP model which might be solved by the Simplex algorithm. I think it might be applied to the MINLP class, at least theoretically, by linear relaxation of the integer term.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-02-04T08:32:05.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7753" PostTypeId="2" ParentId="7750" CreationDate="2022-02-04T12:07:53.090" Score="11" Body="&lt;p&gt;Extension of the Simplex Method to Nonlinear Programs having linear or linearized constraints is called an &lt;a href=&quot;https://en.wikipedia.org/wiki/Active-set_method&quot; rel=&quot;noreferrer&quot;&gt;Active Set method&lt;/a&gt;.  Sequential Linear Programming (SLP) and Sequential Quadratic Programming (SQP) are notable examples of such methods, which move around vertices of the constraints, rather than cutting through the interior, as Interior-Point Methods (IPM) do. Well-implemented SQP can be more numerically robust and may be faster than IPM on many problems.&lt;/p&gt;&#xA;&lt;p&gt;Active Set methods applied to Quadratic Programming are sometimes referred to as Simplex, even though they are not exactly the same as the Simplex Algorithm applied to Linear Programs. The first such published algorithm is &lt;a href=&quot;https://pages.cs.wisc.edu/%7Ebrecht/cs838docs/wolfe-qp.pdf&quot; rel=&quot;noreferrer&quot;&gt;&amp;quot;The Simplex Method for Quadratic Programming&amp;quot;, by Philip Wolfe,&#xA;Econometrica, Vol. 27, No. 3, July 1959, pp. 382-398&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-02-04T13:13:22.217" LastActivityDate="2022-02-04T13:13:22.217" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7754" PostTypeId="1" CreationDate="2022-02-04T19:18:54.587" Score="6" ViewCount="1005" Body="&lt;p&gt;I do not have a background in optimization and I am trying to teach myself more about this topic. I find myself having a lot of trouble understanding the different &amp;quot;types&amp;quot; of optimization problems that exist.&lt;/p&gt;&#xA;&lt;p&gt;For example, I understand the idea of optimizing continuous functions (e.g. &lt;span class=&quot;math-container&quot;&gt;$y = x^2$&lt;/span&gt;). For example, we could be interested in finding out the value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; that results in the smallest value of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. I also understand that continuous functions can be optimized subject to some constraints.&lt;/p&gt;&#xA;&lt;p&gt;However, I find myself very confused when trying to sort through the following types of optimization problems:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Discrete Optimization&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Integer Optimization&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Mixed Integer Optimization&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Combinatorial Optimization&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When I think of these problems, the first thing that comes to mind is that they are fundamentally different from optimizing continuous functions. For instance, the inputs of the above list of problems are usually &amp;quot;categorical&amp;quot; in nature. This is why I have heard that problems belong to the above list usually require &amp;quot;gradient free optimization methods&amp;quot; (e.g. evolutionary algorithms, branch and bound, etc.) , since it is impossible to take the derivatives of the objective functions corresponding to these problems.&lt;/p&gt;&#xA;&lt;p&gt;For example, if you take problems such as the &lt;strong&gt;&amp;quot;Traveling Salesman&amp;quot; or &amp;quot;Knapsack Problem&amp;quot;&lt;/strong&gt; (note: I have heard that these problems belong on the above list, but I am not sure), I would visualize the objective function as something like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/heo5f.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/heo5f.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This leads me to the following question:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Are 4 types of optimizations on the above list effectively the &amp;quot;same thing&amp;quot;? The way I see it, all 4 types of these problems have &amp;quot;discrete inputs&amp;quot; and in a mathematical sense, &amp;quot;integers&amp;quot; are always considered as &amp;quot;discrete&amp;quot;. In all 4 types of problems, we are interested in finding out a &amp;quot;discrete combination&amp;quot; of inputs - i.e. &amp;quot;combinatorical&amp;quot;. Thus, &lt;strong&gt;are 4 types of optimizations on the above list effectively the &amp;quot;same thing&amp;quot;?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I have heard the argument that &amp;quot;any optimization problem that can be formulated into a linear problem is always convex (because linear objective functions are always convex)&amp;quot;. If we consider continuous optimization problems, we usually say that &amp;quot;convex optimization problems are easier than non-convex optimization problems&amp;quot; because non-convex functions can have &amp;quot;saddle points&amp;quot; that can result in the optimization algorithm getting stuck in these &amp;quot;saddle points&amp;quot;. Using this logic, I have seen the objective function of the &amp;quot;Traveling Salesman Problem&amp;quot; being written as a linear function and thus the &amp;quot;Traveling Salesman Problem&amp;quot; being considered as a convex optimization problem. I have also heard the &amp;quot;Traveling Salesman Problem&amp;quot; is a very difficult problem to solve. &lt;strong&gt;If the &amp;quot;Traveling Salesman Problem&amp;quot; is convex and difficult to solve, does this imply that there are non-convex discrete/combinatorial problems that are even more difficult to solve?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I have heard the following argument: Discrete/Combinatorial Optimization Problems are more difficult to solve compared to Continuous Optimization Problems. This is apparently because discrete/combinatorial optimization problems involve &amp;quot;treating the problem as a continuous problem&amp;quot; to first come up with a solution, and then determine if the solution lies within the feasible region, thus effectively solving two optimization problems in one. &lt;strong&gt;Is this correct?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finally, I have seen both the &amp;quot;Traveling Salesman&amp;quot; and the &amp;quot;Knapsack Problem&amp;quot; being formulated as a linear problem and therefore as convex. &lt;strong&gt;Are there any well known examples of non-convex discrete/combinatorial optimization problems?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-04T20:53:47.660" LastActivityDate="2022-02-05T19:14:40.793" Title="Confusion Between Different Types of Optimization Problems" Tags="|optimization|integer-programming|traveling-salesman|knapsack|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7755" PostTypeId="2" ParentId="7754" CreationDate="2022-02-04T21:42:53.630" Score="10" Body="&lt;ul&gt;&#xA;&lt;li&gt;I'm inclined to treat &amp;quot;discrete optimization&amp;quot; and &amp;quot;combinatorial&amp;quot; optimization as synonyms, but I'm not sure everyone does.&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;Integer programing/optimization&amp;quot; is a specific approach to modeling and solving a discrete/combinatorial problem. It is not the only approach. For instance, constraint programming can be used productively to solve some combinatorial problems, and it is very different from integer programming both in terms of problem representation (modeling) and in terms of the algorithms used to solve the models.&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;Mixed integer programming/optimization)&amp;quot; generalizes integer programming (slightly) by allowing non-integral real variables in the model. The most common algorithms for IPs make no distinction between IPs and MIPs.&lt;/li&gt;&#xA;&lt;li&gt;When dealing with discrete optimization, the roles of linearity and convexity largely have to do with how easy (and perhaps how useful) it is to solve relaxations of the problem where the integrality restrictions are dropped.&lt;/li&gt;&#xA;&lt;li&gt;Yes, nonconvex discrete problems can be bigger pains in the posterior to solve than discrete problems with convex relaxations are. Note that this is not guaranteed to be the case with every instance. I could probably conjure up a nonconvex discrete problem A and a convex discrete problem B where A was easier than B. Let's just say that when confronting a new problem I am always rooting (hard) for convexity and (fairly hard) for linearity.&lt;/li&gt;&#xA;&lt;li&gt;Discrete problems tend to be harder than their continuous equivalents, in large part because the &amp;quot;move a small amount in this direction&amp;quot; logic of many continuous optimization algorithms is not applicable when the variables are discrete. A small step from an integer is not integer, hence not feasible. I would not, however, agree with characterization of solving the continuous relaxation to see if the solution is in the feasible region and calling that two problems. In branch and bound/branch and cut, for instance, you do solve the continuous relaxation, and assuming it is feasible with an objective value no worse than the current incumbent you do check whether the solution is integer-feasible ... but that check is trivial. (You just look at the values of the discrete variables and see if they are within rounding distance of integer.) The main reason for solving the relaxation, though, is not the hope of finding an integer solution but rather to get what you hope is a fairly tight bound for the objective value in that part of the solution space.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-04T21:42:53.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7756" PostTypeId="1" CreationDate="2022-02-05T02:12:55.047" Score="11" ViewCount="4156" Body="&lt;p&gt;I have the following question about why Combinatorial and Discrete Optimization Problems are  Considered to be &amp;quot;Difficult&amp;quot;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For continuous optimization problems (e.g. Loss Functions in Machine Learning Models) - we are often told that these problems are difficult because when the objective functions are non-convex, the function can have &amp;quot;saddle points&amp;quot; which can &amp;quot;trap&amp;quot; the optimization algorithm before it reaches its intended destination:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tM4yn.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tM4yn.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Recently, I have learned that &lt;strong&gt;the objective functions in discrete combinatorial optimization problems (e.g. Traveling Salesman) can also be non-convex.&lt;/strong&gt; This is because even though &lt;strong&gt;the objective function corresponding to Traveling Salesman is linear and therefore convex, when integer constraints are applied to the objective function, the feasible region and the optimization problem ends up becoming non-convex&lt;/strong&gt; (this is because the set of integers and therefore integer constraints automatically turn a problem into a non-convex problem):&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NX2om.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NX2om.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Intuitively, in the case of continuous optimization problems with non-convex functions, we can understand why these functions might be difficult to optimize. We can imagine the optimization algorithm getting stuck in the saddle points.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Mathematically, we can also understand why continuous non-convex functions and saddle points can pose an obstacle - In a saddle point, the first derivatives of the function are 0. Since optimization algorithms that are commonly used for optimizing continuous functions (e.g. gradient descent) iteratively move towards their future destination (&lt;strong&gt;k+1&lt;/strong&gt;) based on the current value (&lt;strong&gt;k&lt;/strong&gt;) of the gradient (i.e. derivative), if they are in a saddle point and the derivative at a saddle point is zero - the optimization algorithm will become perpetually stuck in the saddle point and can't move forward (without some &amp;quot;intervention&amp;quot;, e.g. stochastic momentum):&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1qo6c.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1qo6c.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;The same way, is there any visual or mathematical or visual intuition that we can use to understand why Combinatorial and Discrete Optimization Problems are difficult? For instance, what would be the equivalent of &amp;quot;saddle point&amp;quot; obstacles in discrete and combinatorial optimization problems?&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-05T14:38:43.243" LastActivityDate="2022-02-07T02:01:26.390" Title="Why is Discrete Optimization &quot;Difficult'?" Tags="|optimization|combinatorial-optimization|" AnswerCount="9" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7757" PostTypeId="1" AcceptedAnswerId="7758" CreationDate="2022-02-05T06:09:35.137" Score="6" ViewCount="394" Body="&lt;p&gt;I have a set of binary variables &lt;span class=&quot;math-container&quot;&gt;$X = \{ x_1, x_2, x_3, ... x_N \}$&lt;/span&gt; which are connect and used with the rest of the model.&lt;/p&gt;&#xA;&lt;p&gt;I want to define a set of binary variables which represents the change between the variables in &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; with adjacency. Let this set be &lt;span class=&quot;math-container&quot;&gt;$Y = \{ y_1._2, y_2._3, y_3._4, ... y_{N-1}._{N} \}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This set &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is expected to behave like this,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y_i._{i+1} = &#xA;\begin{cases}&#xA;0 &amp;amp; \text{if $x_i=x_{i+1}$ } \\&#xA;1 &amp;amp; \text{otherwise}&#xA;\end{cases}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Eventually, I wish to limit the summation of these &lt;span class=&quot;math-container&quot;&gt;$y_i._{i+1}$&lt;/span&gt; variables, but that is an easy part. Question is, how can I define &lt;span class=&quot;math-container&quot;&gt;$y_i._{i+1}$&lt;/span&gt; variables in the OR model in terms of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; variables which reflects the multi-definition above?&lt;/p&gt;&#xA;" OwnerUserId="9082" LastActivityDate="2022-02-05T07:05:33.110" Title="Binary variable switch constraints" Tags="|modeling|integer-programming|binary-variable|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7758" PostTypeId="2" ParentId="7757" CreationDate="2022-02-05T07:05:33.110" Score="7" Body="&lt;p&gt;You want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\lnot y_{i,i+1}\iff (x_i\iff x_{i+1}).&#xA;$$&lt;/span&gt;&#xA;Rewriting in conjunctive normal form yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(\lnot y_{i,i+1} \lor \lnot x_i \lor \lnot x_{i+1})\land (\lnot y_{i,i+1} \lor x_i&#xA;\lor x_{i+1}) \land (y_{i,i+1} \lor \lnot x_i \lor x_{i+1}) \land (y_{i,i+1} \lor x_i \lor \lnot x_{i+1}),&#xA;$$&lt;/span&gt;&#xA;from which we obtain linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(1-y_{i,i+1}) +(1-x_i)+(1-x_{i+1})&amp;amp;\ge1\\&#xA;(1-y_{i,i+1})+x_i+x_{i+1}&amp;amp;\ge 1\\&#xA; y_{i,i+1} +(1-x_i)+x_{i+1}&amp;amp;\ge 1\\&#xA;y_{i,i+1} +x_i +(1-x_{i+1})&amp;amp;\ge 1&#xA;\end{align}&lt;/span&gt;&#xA;Equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_{i,i+1}+x_i+x_{i+1}&amp;amp;\le 2\\&#xA;-y_{i,i+1}+x_i+x_{i+1}&amp;amp;\ge 0\\&#xA; y_{i,i+1} -x_i+x_{i+1}&amp;amp;\ge 0\\&#xA;y_{i,i+1} +x_i -x_{i+1}&amp;amp;\ge 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-02-05T07:05:33.110" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7759" PostTypeId="2" ParentId="7756" CreationDate="2022-02-05T09:14:25.620" Score="4" Body="&lt;p&gt;I am not sure about saddle points but, many of the integer programs are hard to solve in their essence. It comes back to how a modeler might be modeling a specific problem. For example, in the following trivial problem, there are only three integer variables, but many of the open-source solvers like CBC and some of the commercial solvers cannot solve this in a reasonable amount of time or without some specific tricks.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{l}&#xA;\text{minimize} \quad x_{3}\\&#xA;\text{subject to:} \\&#xA;\ 12x_{1} + 9x_{2} - x_{3}  = 0\\&#xA;\ x_{1,2} \in (-inf,+inf) \\ &#xA;\ x_{3} \geq1, \quad x_{1,2,3} \in Z\\&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, there are lots of such an example that can be found by googling. If you are willing to know how long does it take to solve an optimization problem the complexity theory would be a very good starting point.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2022-02-05T09:28:29.353" LastActivityDate="2022-02-05T09:28:29.353" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7760" PostTypeId="2" ParentId="7756" CreationDate="2022-02-05T17:33:13.543" Score="7" Body="&lt;p&gt;I doubt that there is any visual aid to understanding the difficulty of discrete optimization problems that is as intuitive as the saddle point is for continuous non-convex optimization. The branch-and-bound/branch-and-cut algorithms most commonly used problems partition the integer-feasible solution space into smaller and smaller chunks. This is usually represented by an inverted binary tree where nodes are subproblems (original problem restricted to a smaller chunk of the solution space). You could make a comparable sequence of images in the solution space (for a 2D problem) by adding cuts that would slice and dice the feasible region, but that evades the key point.&lt;/p&gt;&#xA;&lt;p&gt;What makes an integer program difficult or not is a combination of problem size (number of variables/constraints), how quickly the algorithm finds better (not necessarily optimal) solutions, and how tight the bounds of the subproblems (restricted feasible regions) are. Other than problem size, your main concern is being able to prune nodes high up in the search tree, so that you need to solve fewer subproblems. &amp;quot;Easy&amp;quot; problems have tight subproblem bounds and fast improvement of the incumbent, resulting in a lot of pruning high in the tree. &amp;quot;Difficult&amp;quot; problems have more pruning deep in the tree, making the portion of the tree actually explored bigger. You could put images of a tree pruned high up and a tree pruned lower side by side to show the difference in number of nodes visited, but I'm not sure how informative that would be.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-05T17:33:13.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7761" PostTypeId="2" ParentId="7754" CreationDate="2022-02-05T19:14:40.793" Score="3" Body="&lt;p&gt;&lt;strong&gt;----If the &amp;quot;Traveling Salesman Problem&amp;quot; is convex and difficult to solve:&lt;/strong&gt;&#xA;TSP is not convex, it belongs to a class of hard problems, &amp;quot;NP-hard&amp;quot; to be more specific (for more details, see here: &lt;a href=&quot;https://stackoverflow.com/a/49845003/9125267&quot;&gt;https://stackoverflow.com/a/49845003/9125267&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;---- Discrete/Combinatorial Optimization Problems are more difficult to solve compared to Continuous Optimization Problems:&lt;/strong&gt;&#xA;I have to disagree with this statement since you can enforce the constraint &lt;code&gt;x is binary&lt;/code&gt; just by adding the constraint &lt;code&gt;x^2=x&lt;/code&gt; and leaving your formulation continuous. The real distinction should be convex vs non-convex.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;----Are there any well known examples of non-convex discrete/combinatorial optimization problems?:&lt;/strong&gt;&#xA;Mixed-Integer Nonlinear Programs (MINLPs) are used to model non-convex discrete/continuous problems (they include mixed-integer linear and pure integer programs, see classification chart below). There are plenty of examples in the MINLP library: &lt;a href=&quot;https://www.minlplib.org/applications.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.minlplib.org/applications.html&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For a real-world example, have a look at the Grid Optimization competition: &lt;a href=&quot;https://gocompetition.energy.gov/about-competition&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gocompetition.energy.gov/about-competition&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sDdXW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sDdXW.png&quot; alt=&quot;Mathematical Optimization Classification&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="289" LastActivityDate="2022-02-05T19:14:40.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7762" PostTypeId="2" ParentId="7756" CreationDate="2022-02-05T21:50:42.530" Score="4" Body="&lt;p&gt;Let's state the obvious both non-convex continuous problems and non-convex discrete problems can in general be used to encode NP-hard problems when one searches for a global optima. I suspect that discrete optimization is generally considered hard because solving a discrete problem means something different than solving a continuous problem. In continuous optimization one is usually happy if one reaches Karush–Kuhn–Tucker (KKT) conditions or even a local minima. Many solvers (like KNITRO, Ipopt, WORHP) stop when such a condition is reached. In discrete problems finding a local optima while satisfying constraints is a bit more trivial, so solving took the meaning of &amp;quot;solving to global optimality&amp;quot;. &amp;quot;Solving to global optimality&amp;quot; for continous problems can be just as hard but that is not what most NLP solvers do on continuous problems.&lt;/p&gt;&#xA;&lt;p&gt;Saddle points also exist in discrete optimization. However translating them such that finite difference along one dimension is 0 is not very helpful as that makes assumption that the function is defined over a grid of points. The a better analog for saddle points is that you are at some value &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; which has two neighbors &lt;span class=&quot;math-container&quot;&gt;$y,z$&lt;/span&gt; which are better than &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; but &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; are not neighbors with each other. In this case the difficulty is not getting stuck in a saddle point, it is usually not difficult for continuous optimization either as that that can be detected by NLP solvers, but the challenge is to choose which way to go down.&lt;/p&gt;&#xA;&lt;p&gt;For some problem classes you can embed &lt;span class=&quot;math-container&quot;&gt;$x,y,z$&lt;/span&gt; in to a grid and get a visual metaphor however sometimes you can't do that well as discrete points with connections (also called graphs) might not embed well in euclidean geometry. For an example of such a space try to think about the space of all words of any length that can be formed from English letters connected when their edit distance (replacement, insertion and deletion) differs by one. There is no way to fit this well into an finite euclidean space.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2022-02-06T15:33:00.467" LastActivityDate="2022-02-06T15:33:00.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7763" PostTypeId="2" ParentId="7756" CreationDate="2022-02-06T01:11:54.463" Score="11" Body="&lt;p&gt;Comparing with local minima / saddle points of continuous problems is a bit of a red herring. It's like wondering why people in the stone age had it tough to find food, and comparing with “on Sunday we had such a terrible dinner, because the fridge had broken over night and the shops were all closed”. These are issues that aren't even meaningful from the stone age perspective. Fridge? &lt;em&gt;Luxury! We used to dream of having a broken fridge...&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the discrete setting, you just don't have gradients available. You can't follow paths leading downwards (even to a local minimum), because there &lt;em&gt;are&lt;/em&gt; no paths, because the domain is disconnected. All you can do is jumping between separate points. Sometimes you may of course be able to exploit heuristics, but in general you won't get around a lot of trial and error.&lt;/p&gt;&#xA;&lt;p&gt;Another way to look at it is that a discrete problem can be seen as a continuous problem with a very strong penalty term that only vanishes at the integers. That penalty is nonconvex, so even if the rest of the objective is simple linear, the overall problem has lots of bad narrow local minima.&lt;/p&gt;&#xA;" OwnerUserId="9087" LastActivityDate="2022-02-06T01:11:54.463" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7764" PostTypeId="2" ParentId="7249" CreationDate="2022-02-06T02:33:00.360" Score="1" Body="&lt;p&gt;The author of this software replied to my inquiry, but unfortunately, the author said he didn't make it freely available. It is a bit old and was developed on Windows XP. It is likely not going to run on Windows 10 or higher now.&lt;/p&gt;&#xA;" OwnerUserId="7402" LastActivityDate="2022-02-06T02:33:00.360" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7765" PostTypeId="1" CreationDate="2022-02-06T04:44:11.407" Score="3" ViewCount="219" Body="&lt;p&gt;As we know, there has been a lot of work and research done to demonstrate that the Gradient Descent Algorithm can converge on (deterministic) convex, differentiable and Lipschitz Continuous functions :&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8njLa.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8njLa.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, I am interested in learning about to what extent convergence of Gradient Descent Based Algorithms (e.g. Stochastic Gradient Descent) has been studied for (non-deterministic) Non-Convex Functions&lt;/p&gt;&#xA;&lt;p&gt;I have been trying to read about this topic over the past few weeks, but the level of math required to understand some of these results goes far beyond my ability to understand. For instance, below are some of the publications that I consulted:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1) &amp;quot;Stochastic Gradient Descent for Nonconvex Learning without Bounded Gradient Assumptions&amp;quot; (Lei et al., 2019)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this paper, the authors comment that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Stochastic Gradient Descent is being heavily used on Non-Convex Functions, but the theoretical behavior of Stochastic Gradient Descent on Non-Convex Functions is not fully understood (currently only understood for Convex Functions).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Currently, Stochastic Gradient Descent requires imposing a nontrivial assumption on the uniform boundedness of gradients.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The authors establish a theoretical foundation for Stochastic Gradient Descent for Non-Convex Functions where the boundedness assumption can be removed without affecting convergence rates.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The authors establish sufficient conditions for almost sure convergence as well as optimal convergence rates for Stochastic Gradient Descent applied to Non-Convex Functions.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;2) &amp;quot;Stochastic Gradient Descent on Nonconvex Functions with General Noise Models&amp;quot; (Patel et al 2021)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this paper, the authors comment that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Although recent advancements in Stochastic Gradient Descent have been noteworthy, these advancements have nonetheless imposed certain restrictions (e.g., Convexity, Global Lipschitz Continuity etc.) on the functions being optimized.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The authors prove that for general class of Non-Convex Functions, Stochastic Gradient Descent iterates either diverge to infinity or converge to a stationary point with probability one.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The authors make further restrictions and prove that regardless of whether the iterates diverge or remain finite — the norm of the gradient function evaluated at Stochastic Gradient Descent's iterates converges to zero with probability one and in expectation; thus broadening the scope of functions to which Stochastic Gradient Descent can be applied to while maintaining rigorous guarantees of its global behavior.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; Based on some of these publications, have we truly been able to demonstrate that (&lt;strong&gt;Stochastic) Gradient Descent has the potential to display similar global convergence properties on Non-Convex Functions&lt;/strong&gt;, to the same extent at which it had previously displayed only on Convex Functions?&lt;/p&gt;&#xA;&lt;p&gt;Or have I completely misunderstood the results from this publications, and the conditions (and class of functions) in which the respective authors explored and demonstrated the convergence behavior of Stochastic Gradient Descent is far less &amp;quot;generous&amp;quot; compared to those pertaining to Convex Functions - and these conditions are also less likely to manifest themselves in real-world applications : And thus we still have reasons to believe that (Stochastic) Gradient Descent has more difficulties converging on Non-Convex Functions compared to Convex Functions?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/abs/1902.00908&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/1902.00908&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/pdf/2104.00423.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/2104.00423.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5971" LastActivityDate="2022-02-10T10:31:22.973" Title="Non-Convex Optimization: How Well Do We Understand It?" Tags="|optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7766" PostTypeId="1" CreationDate="2022-02-06T06:32:58.403" Score="3" ViewCount="395" Body="&lt;p&gt;It seems like when the &lt;a href=&quot;https://en.wikipedia.org/wiki/Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions&quot; rel=&quot;nofollow noreferrer&quot;&gt;KKT conditions were first developed&lt;/a&gt;, these were very useful for determining whether the solution to a optimization problem was optimal or not.&lt;/p&gt;&#xA;&lt;p&gt;However, it seems like nowadays, we hear about the KKT Conditions less - for instance, when reading about all the cool things that Deep Neural Networks are doing (e.g. AlphaGO, Protein Folding, Self Driving Cars) , the KKT Conditions never seem to be mentioned that much.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering if someone could comment on the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;With the advent of approximate optimization methods such as Gradient Descent that seem to work quite well for non-convex and high dimensional problems - do the KKT Conditions have as much importance in Optimization now as they did when they were first developed?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="123" LastEditDate="2022-02-06T14:03:18.160" LastActivityDate="2022-02-06T15:20:20.997" Title="Are the KKT Conditions as Important in Optimization as they were Originally?" Tags="|optimization|kkt-conditions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7767" PostTypeId="1" AcceptedAnswerId="7798" CreationDate="2022-02-06T11:34:57.807" Score="3" ViewCount="155" Body="&lt;p&gt;So, I'm modelling a job assigning problem in OR-Tools CP-SAT. I want to maximize rescheduled jobs based on some constraints. Right now jobs in my model look like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;jobs = [(1, 1, 1, 3, 1),           # job id, job type, start time, length, worker id&#xA;         ...&#xA;        (7, 5, 9, 1, 4)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And the way I initialize data looks like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for h in range(horizon):&#xA;    ...&#xA;    for w in workers:&#xA;        ...&#xA;        for jt in job_types:&#xA;            ...&#xA;            for job in jobs:  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The data on top level is stored in smth like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; List&amp;lt;List&amp;lt;List&amp;lt;List&amp;lt;IntervalVar&amp;gt;&amp;gt;&amp;gt;&amp;gt; intervals_by_hour&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Based on all of this I find it pretty hard already to initialize everything and select some of the data ranges to make constraints. Next, I would like to widen a job definition a bit, so I feel that I'll have another layer of for loops and a hard time isolating entities from them.&lt;/p&gt;&#xA;&lt;p&gt;So the question is: &lt;strong&gt;Am I doing something wrong or is it some acceptable way of doing so?&lt;/strong&gt;&#xA;I've looked through examples and some books, and rn I dont feel neither those examples fit my needs well, nor some of them feel better in modeling part&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Initial task:&lt;/strong&gt;&#xA;I get some jobs from the ERP system that (in this example) can overlap each other by the workers attached to them. (E.g. Alex can be assigned to job1 and job2 at the same time), so I want to reschedule such jobs.&#xA;Every job consists of job ID, job type, start time, length, worker id.&#xA;Right now in my model I use BoolVars to indicate that job exists and OptionalIntervals for a job to exist if BoolVar exists.&#xA;Basically I want jobs of one type to not overlap, jobs of one worker to not overlap and to maximize the sum of scheduled jobs&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;performed_at = model.NewBoolVar(&amp;quot;performed by %dh %dw %dj %dt&amp;quot; % (h, w, job[0], jt))&#xA;start = model.NewIntVar(h, h, &amp;quot;start of %dh %dw %dj %dt&amp;quot; % (h, w, job[0], jt))&#xA;end = model.NewIntVar(0, horizon, &amp;quot;end of %dh %dw %dj %dt&amp;quot; % (h, w, job[0], jt))&#xA;optint = model.NewOptionalIntervalVar(start, job[3], end, performed_at, &amp;quot;interval of %dh %dw %dj %dt&amp;quot; % (h, w, job[0], jt))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Full source code of working model:&#xA;&lt;a href=&quot;https://pastebin.com/WVuAYJw9&quot; rel=&quot;nofollow noreferrer&quot;&gt;Model&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6027" LastEditorUserId="981" LastEditDate="2023-02-19T14:48:51.957" LastActivityDate="2023-02-19T14:48:51.957" Title="&quot;Complex&quot; scheduling problem model structure" Tags="|modeling|scheduling|or-tools|cp-sat|sat|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7768" PostTypeId="1" CreationDate="2022-02-06T11:54:40.080" Score="3" ViewCount="105" Body="&lt;p&gt;I am working on two queues in tandem; the first queue is M/G/1 with hyper-exponential service times and the second queue has exponential service times. I want to know if the second queue can be modeled as an M/M/1 queue, or equivalently, the departure process of the first queue has Poisson distribution.&lt;/p&gt;&#xA;&lt;p&gt;I have run simulations for two tandem queues and noticed that the simulation results for total delay match the sum of the analytical values for delays in M/G/1 and M/M/1 queues. I want to know if there is a good reference to show that the departure process of M/G/1 queue with hyper-exponential service times has Poisson distribution.&lt;/p&gt;&#xA;" OwnerUserId="9091" LastEditorUserId="123" LastEditDate="2022-02-06T14:02:46.773" LastActivityDate="2023-01-15T13:07:06.177" Title="Departure process of M/G/1 queue with hyper-exponential service times" Tags="|reference-request|queuing-theory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7769" PostTypeId="2" ParentId="7756" CreationDate="2022-02-06T13:29:16.190" Score="3" Body="&lt;p&gt;Unknown variables are drawn from a limited information in discrete optimization. By contrast , the feasible set in continuous optimization is usually uncountably infinite. Also, the smoothness of a continuous objective function  makes it possible to use objective and constraint information at a particular point to deduce information about the function's behavior in a neighborhood. By contrast, in discrete case, the behavior of objective and constraints may change significantly as we move from one feasible point to another.&lt;/p&gt;&#xA;" OwnerUserId="9093" LastEditorUserId="9093" LastEditDate="2022-02-06T19:15:29.140" LastActivityDate="2022-02-06T19:15:29.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7770" PostTypeId="2" ParentId="7756" CreationDate="2022-02-06T14:29:42.220" Score="1" Body="&lt;p&gt;Problems with non-convex feasible regions tend to be hard to solve to a global optimum because hill-climbing algorithms are not guaranteed to work.&#xA;A hill climbing algorithm, though typically fast, will stop at a local optimum.&#xA;(There are lots of hilltops. A hill-climbing algorithm will find one of them and stop).&#xA;In a problem with a convex feasible region and a convex objective,&#xA;a local optimum is also a global optimum. (There is only one hilltop.)&#xA;So for noncovex problems you are forced to use intelligent enumeration algorithms such as branch-and-bound to find a guaranteed global optimum. Their compute time may grow exponentially with problem size.&#xA;A feasible region is convex if for any two feasible points, any point on the continuous straight line connecting them is also feasible.&#xA;A problem with discreteness constraints on the variables is clearly not convex.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-02-06T14:29:42.220" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7771" PostTypeId="1" AcceptedAnswerId="7775" CreationDate="2022-02-06T14:32:53.277" Score="4" ViewCount="110" Body="&lt;p&gt;We have a fleet of taxis with &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; taxis available. All taxis are identical in the sense that they have the same capacity for &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; passengers and each taxi is dispatched only when its capacity is full.&lt;/p&gt;&#xA;&lt;p&gt;Each taxi takes passengers from district A to district B and returns to district A without any passengers!&lt;/p&gt;&#xA;&lt;p&gt;Passengers arrive individually at district A following a Poisson process with parameter &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and the time it takes for each taxi to go from district A to B and return back to A is &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Based on this information, I think we can view this fleet as a queuing system &lt;span class=&quot;math-container&quot;&gt;$M/D^p/t$&lt;/span&gt; that is a batch processing queue with batch size &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; with fixed service time that is &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; and multiple severs that is &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We are interested in computing the time between two consecutive dispatches. We did some calculations for different queues with different values of &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and it looks like the average time looks something like &lt;span class=&quot;math-container&quot;&gt;$\frac{\lambda T}{t}$&lt;/span&gt; but we cannot show this rigorously.&lt;/p&gt;&#xA;&lt;p&gt;Any suggestions would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="7693" LastActivityDate="2022-02-06T16:36:35.413" Title="Average time between two dispatches in a taxi fleet (probably a batch processing queuing system)" Tags="|queuing-theory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7772" PostTypeId="1" CreationDate="2022-02-06T15:17:29.763" Score="3" ViewCount="418" Body="&lt;p&gt;I have tried to solve an optimization problem using CVXPY library. This problem aims to minimize the distance between a vector of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables (&lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;), which can be positive or negative real numbers and another n-dimensional vector (&lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;) containing only positive real number, as follows&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;beta = cp.Variable(n)&#xA;problem = cp.Problem(cp.Minimize(cp.abs(cp.norm1(beta) - cp.norm1(s))))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried &lt;code&gt;cp.norm1(beta) - cp.norm1(s)&lt;/code&gt; and it worked fine, but I want to make sure that the result of the difference between both vectors must be positive. However, when I add &lt;code&gt;abs&lt;/code&gt;, I got the error saying that &amp;quot;this problem  does not follow DCP rules&amp;quot;. I am not sure how to resolve this error.&lt;/p&gt;&#xA;" OwnerUserId="9092" LastEditorUserId="8" LastEditDate="2022-02-07T09:20:30.413" LastActivityDate="2022-02-07T09:20:30.413" Title="Adding CVXPY abs to optimization problem turns out to be non-DCP" Tags="|optimization|convex-optimization|cvxpy|disciplined-convex-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7773" PostTypeId="2" ParentId="7766" CreationDate="2022-02-06T15:20:20.997" Score="5" Body="&lt;p&gt;Much (most?) of Deep Neural Network training (optimization) has been unconstrained optimization. The KKT condition(s) for unconstrained optimization is that the gradient of the objective function is zero. That's it, that's the entirety of the KKT conditions for unconstrained optimization. That condition was known for centuries prior to formulation and naming of the KKT conditions. In the context of unconstrained optimization, mention might only be made of getting the gradient (close) to zero; and KKT conditions never even mentioned as such.&lt;/p&gt;&#xA;&lt;p&gt;Many (local) numerical nonlinear optimization algorithms essentially consist of numerically solving the KKT conditions, perhaps while &amp;quot;rolling downhill&amp;quot; (for minimization). So yes, KKT conditions are still quite important in optimization.&lt;/p&gt;&#xA;&lt;p&gt;I believe there is an increasing trend toward constrained optimization for (Deep) Neural Networks. Hence I expect KKT conditions to be mentioned more frequently in the future in (Deep) Neural Network optimization&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2022-02-06T15:20:20.997" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7774" PostTypeId="2" ParentId="7772" CreationDate="2022-02-06T15:26:55.790" Score="7" Body="&lt;p&gt;I think you want &lt;code&gt;cp.norm1(beta - s)&lt;/code&gt;, with no need for &lt;code&gt;abs&lt;/code&gt;. This is DCP-compliant.&lt;/p&gt;&#xA;&lt;p&gt;Taking separate norms of &lt;code&gt;beta&lt;/code&gt; and &lt;code&gt;s&lt;/code&gt; doesn't make sense for what you describe.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Note that by using &lt;code&gt;norm1&lt;/code&gt;, you are minimizing L1 distance. That's fine if that's what you really want. However, distance, when not otherwise qualified, more commonly means L2 (Euclidean) distance, for which you would use &lt;code&gt;norm&lt;/code&gt; (with default &lt;code&gt;p&lt;/code&gt;) or &lt;code&gt;norm2&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-02-06T16:25:01.690" LastActivityDate="2022-02-06T16:25:01.690" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7775" PostTypeId="2" ParentId="7771" CreationDate="2022-02-06T16:36:35.413" Score="3" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; represent the average time between dispatches.&lt;/p&gt;&#xA;&lt;p&gt;I'm skeptical about &lt;span class=&quot;math-container&quot;&gt;$\frac{\lambda T}{t}$&lt;/span&gt; as a possible value of &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; because it fails dimensional analysis. &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; is in units of time. &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is time, &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is customers per unit time, and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is customers, so &lt;span class=&quot;math-container&quot;&gt;$\frac{\lambda T}{t}$&lt;/span&gt; is dimensionless.&lt;/p&gt;&#xA;&lt;p&gt;Queuing theory is not my &amp;quot;jam&amp;quot;, so I may be way off with the following. Assuming that you have enough taxis to keep up with demand, in steady state I would expect the time between dispatches to be (roughly?) the time required to get another &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; customers into the system. The average time for &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; arrivals is &lt;span class=&quot;math-container&quot;&gt;$\frac{p}{\lambda}$&lt;/span&gt;, so that would be my first guess for &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt;. If you don't have enough taxis to reach steady state, then the taxis would be running nonstop. Each taxi would make an average of &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{T}$&lt;/span&gt; trips per unit time, so with &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; taxis there would be an average of &lt;span class=&quot;math-container&quot;&gt;$\frac{t}{T}$&lt;/span&gt; dispatches per unit time and thus an average of &lt;span class=&quot;math-container&quot;&gt;$\frac{T}{t}$&lt;/span&gt; time between dispatches. Note that at full blast the system can carry &lt;span class=&quot;math-container&quot;&gt;$\frac{tp}{T}$&lt;/span&gt; passengers per unit time, which means that steady state requires &lt;span class=&quot;math-container&quot;&gt;$\lambda&amp;lt;\frac{tp}{T}$&lt;/span&gt; or equivalently &lt;span class=&quot;math-container&quot;&gt;$\frac{p}{\lambda}&amp;gt;\frac{T}{t}.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-06T16:36:35.413" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7776" PostTypeId="2" ParentId="7756" CreationDate="2022-02-06T20:01:52.000" Score="5" Body="&lt;p&gt;Here is 2D &lt;strong&gt;geometrical interpretation&lt;/strong&gt; of why discrete optimization is hard (in the linear case).&lt;/p&gt;&#xA;&lt;p&gt;As one knows, when solving a continuous (linear) optimization problem, the set of constraints represents a polyhedron, and the optimal solution is typically on one of the vertices of this polyhedron. Continuous optimization is &amp;quot;easy&amp;quot; partially because these vertices can be identified easily. In the image below, the green polyhedron represents the feasible set of solutions for a given problem in two dimensions. The equations of the green lines are known, and therefore identifying the vertices is relatively easy.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HOI52.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HOI52.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, if variables are integer (so optimization is now discrete), the set of feasible solutions is represented by the filled circles, and in terms of optimization, this is equivalent to working with the convex envelope of these filled circles, the blue polyhedron. Part of the difficulty comes from the fact that the equations of the blue lines are not known. The green part between the green lines and the blue lines is the gap between continuous and discrete optimization.&lt;/p&gt;&#xA;&lt;p&gt;Discrete optimization techniques try to approach these blue lines and include the following ideas (roughly speaking) :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;iteratively divide the polyhedron into pieces (branch-and-bound). The number of times the polyhedron must be divided can grow exponentially.&lt;/li&gt;&#xA;&lt;li&gt;add equations on the fly (cutting planes), hoping that the gap between the new polyhedron and the blue polyhedron shrinks. The number of such equations can also grow exponentially.&lt;/li&gt;&#xA;&lt;li&gt;both ideas are used jointly (branch-and-cut).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-02-06T21:54:40.550" LastActivityDate="2022-02-06T21:54:40.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7777" PostTypeId="2" ParentId="7756" CreationDate="2022-02-06T20:39:50.273" Score="4" Body="&lt;p&gt;Many kinds of discrete optimization problems are about as easy as continuous optimization problems in common scenarios where regions are large relative to the spacing between candidate points.  What makes things hard are scenarios involving really long skinny regions whose boundaries might extend far beyond any candidate points that are actually inside them.&lt;/p&gt;&#xA;&lt;p&gt;Suppose one has two pairs of lines and regards each as having a &amp;quot;region of interest&amp;quot; which is entirely below both of its lines; one wants to find which line's region of interest extends further up in the Y direction.&lt;/p&gt;&#xA;&lt;p&gt;To solve the continuous problem, one could simply compute where the two lines in each pair intersect; whichever pair has the higher intersection point has the region that extends further up.  To solve the discrete problem, however, it's not necessary to compute where the lines intersect, but for every candidate Y value below that one must compute whether there exists an integer value between the two X coordinates.  For the case with only two pairs of lines, this may be doable, but in higher-dimensional problems with more constraints, things can get intractibly complicated.&lt;/p&gt;&#xA;&lt;p&gt;Note that if regions are large relative to the space between candidate points, the optimal candidate point will generally be pretty close to what would be the optimal vertex for the continuous problem, and one would thus be able to ignore most of the vertices and candidate points near them.  In the &amp;quot;interesting&amp;quot; problems, however, many regions will be sufficiently skinny that it's not possible to prune many vertices or candidates while still guaranteeing that one won't prune what should have been the optimal solution.&lt;/p&gt;&#xA;" OwnerUserId="9099" LastActivityDate="2022-02-06T20:39:50.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7778" PostTypeId="1" CreationDate="2022-02-07T01:35:09.070" Score="1" ViewCount="245" Body="&lt;p&gt;&lt;strong&gt;Can Saddle Points Provide &amp;quot;Better Solutions&amp;quot; to Machine Learning Models Compared to Local Minimums?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The solution to a Machine Learning model (i.e. the final model parameters) are selected by trying to optimize the Loss Function associated with that Machine Learning model. The &amp;quot;best&amp;quot; solution (i.e. &amp;quot;best&amp;quot; choice of model parameters) are those associated with the &amp;quot;global minimum&amp;quot; of this Loss Function (i.e. the smallest value of the Loss Function). Thus, &amp;quot;relatively better&amp;quot; solutions can be considered as solutions that are located closer to the &amp;quot;Global Minimum&amp;quot;. Optimization Algorithms (e.g. Gradient Descent) try to search for the &amp;quot;Global Minimum&amp;quot; of the Loss Function by repeatedly searching in the direction of the derivatives corresponding to this Loss Function.&lt;/p&gt;&#xA;&lt;p&gt;However, there are different obstacles than can occur during this search process. For instance:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Optimization Algorithm can get stuck in a &amp;quot;Local Minimum,&amp;quot; or&lt;/li&gt;&#xA;&lt;li&gt;The Optimization Algorithm can get stuck in a &amp;quot;Saddle Point.&amp;quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I have heard &amp;quot;Saddle Points&amp;quot; as being considered &amp;quot;worse&amp;quot; than &amp;quot;Local Minimums.&amp;quot; This is because &amp;quot;Saddle Points&amp;quot; aren't actually a minimum of any sort, whereas &amp;quot;Local Minimums&amp;quot; are at least minimums at the local level. &lt;strong&gt;Thus, this would imply that model parameters chosen from a &amp;quot;Saddle Point&amp;quot; should be worse than model parameters chosen from a &amp;quot;Local Minimum&amp;quot;.&lt;/strong&gt; To further illustrate my question, I drew the following graph of a hypothetical Loss Function for some Machine Learning model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EgSCN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EgSCN.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the above picture, we can see that Loss Function has a smaller loss at the &amp;quot;Saddle Point&amp;quot; compared to the loss at the &amp;quot;Local Minimum&amp;quot;. Thus, in this case (assuming that we could not reach &amp;quot;P3&amp;quot;) if we had to choose a selection of model parameters from &amp;quot;P2&amp;quot; (&amp;quot;Saddle Point&amp;quot;) and &amp;quot;P1&amp;quot; (&amp;quot;Local Minimum&amp;quot;), it would clearly make more sense to pick model parameters from &amp;quot;P2&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; In general, do we know if solutions corresponding to &amp;quot;Local Minimums&amp;quot; points on a Loss Function are considered to be &amp;quot;better&amp;quot; corresponding to &amp;quot;Saddle Points&amp;quot; (e.g. perhaps solutions from &amp;quot;Local Minimums&amp;quot; might be more &amp;quot;stable&amp;quot;)? Or is this claim incorrect, and &lt;strong&gt;solutions corresponding to regions of the Loss Function with lower Loss values are generally &amp;quot;better&amp;quot; - regardless of whether they come from a &amp;quot;Saddle Point&amp;quot; or a &amp;quot;Local Minimum&amp;quot;?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="500" LastEditDate="2022-02-15T01:49:09.373" LastActivityDate="2022-02-15T01:49:09.373" Title="Quality of Solutions from Saddle Points vs. Local Minimums" Tags="|optimization|machine-learning|local-minimum|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7779" PostTypeId="1" CreationDate="2022-02-07T01:41:05.730" Score="7" ViewCount="1531" Body="&lt;p&gt;In the context of Computer Science and Optimization, I have heard that different problems can be classified using the &lt;strong&gt;&amp;quot;P vs NP&amp;quot; framework&lt;/strong&gt;. Essentially, there is a hierarchy of problems based on the inherent complexity of the problem itself. For example, a problem like &amp;quot;multiplying numbers&amp;quot; is considered as &amp;quot;P&amp;quot; and is considered fundamentally easier to solve than a problem like &amp;quot;solving a sudoku&amp;quot; which is &amp;quot;NP&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WAPJU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WAPJU.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In most Statistical and Machine Learning Models, there is usually an optimization problem &amp;quot;nested&amp;quot; within the model that is required to solve. For example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Regression Models:&lt;/strong&gt; In a standard regression model, we try to find the value of the &amp;quot;beta coefficients&amp;quot; that either minimize the error between the (candidate) model's prediction of the response variable and true values of the response variable &lt;strong&gt;(Ordinary Least Squares - OLS)&lt;/strong&gt;, or we try to find the &amp;quot;beta coefficients&amp;quot; such that probability of reproducing the observed response values is maximized &lt;strong&gt;(Maximum Likelihood Estimation - MLE)&lt;/strong&gt;. For simple regression models, there exists &amp;quot;exact solutions&amp;quot; to the OLS and MLE optimization problems and we can calculate these &amp;quot;beta coefficients&amp;quot; analytically - but in &lt;strong&gt;more sophisticated regression models such as Logistic Regression or Regularized Regression (e.g. LASSO, RIDGE), the corresponding optimization problem is usually solved using some approximate and iterative algorithm such as the &amp;quot;Newton-Raphson&amp;quot; Method.&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IERZo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IERZo.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Decision Trees:&lt;/strong&gt; A Decision Tree (e.g. CART) is formed by &amp;quot;splitting&amp;quot; variables into smaller subsets (i.e. &amp;quot;nodes&amp;quot;) such that &amp;quot;purity&amp;quot; increases in each subsequent subset; &amp;quot;purity&amp;quot; is often measured through some sort of &amp;quot;Information Gain&amp;quot; that is based on measures such as &amp;quot;Gini Index&amp;quot; or &amp;quot;Entropy&amp;quot;. &lt;strong&gt;Thus, Decision Trees can be interpreted as an optimization problem where &amp;quot;Information Gain&amp;quot; has to be optimized.&lt;/strong&gt; I have heard that since Decision Trees often have different variable types (e.g. continuous and categorial), &lt;strong&gt;searching for the optimal variable splits that optimize &amp;quot;Information Gain&amp;quot; is a Mixed Integer Optimization Problem having an enormous Combinatorial Search Space.&lt;/strong&gt; For the interest of creating a decent Decision Tree in a reasonable amount of time, &lt;strong&gt;&amp;quot;Information Gain&amp;quot; is optimized using a &amp;quot;Greedy Search Algorithm,&amp;quot; and as a result, the final Decision Tree (i.e. the answer to this Mixed Integer Optimization Problem) is almost certainly unlikely to be the optimal Decision Tree&lt;/strong&gt; (as there is very high probability that a better Decision Tree likely exists in this large Combinatorial Search Space, but finding this Decision Tree would take too much time):&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/STakG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/STakG.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Neural Networks:&lt;/strong&gt; Successful Neural Networks are largely attributed to the effectiveness of Optimization Algorithms (e.g. Stochastic Gradient Descent) to optimize (i.e. determine the &amp;quot;neuron weights&amp;quot;) notoriously complicated, high dimensional and non-convex Loss Functions:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rv4rn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rv4rn.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; Is it possible to categorize the optimization problems corresponding to Statistical and Machine Learning Models such as Regression Models, Decision Trees, and Neural Networks as &amp;quot;P&amp;quot; vs &amp;quot;NP&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;I am aware that categorizing these problems wont really have any effect on solving them, but I have the following guess: When provided with a candidate solution to any of these optimization problems (e.g. Regression beta coefficients, a particular Decision Tree, Neural Network Weights), we have no real way of checking whether this candidate solution is indeed the optimal solution (unlike a sudoku, in which even for an enormous &amp;quot;n x n&amp;quot; sudoku, we can instantly check if a candidate solution violates the rules or not). &lt;strong&gt;Thus, my guess is that many of these above optimization problems are likely either NP-Complete or NP-Hard.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is this correct?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I have often heard of Machine Learning Optimization Problems being described as &amp;quot;Ill-Posed Problems&amp;quot;, implying that they are inherently more difficult than &amp;quot;Well-Posed Problems&amp;quot; (Why is pattern recognition often defined as an ill-posed problem?). This is due to factors such as solutions to these optimization problems &amp;quot;may not exist&amp;quot; and &amp;quot;may not be unique&amp;quot;. However, I am not sure if &amp;quot;Ill-Posed Problems&amp;quot; automatically leave the &amp;quot;N&amp;quot; and &amp;quot;NP&amp;quot; complexity classes.&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-07T13:55:14.080" LastActivityDate="2022-02-07T13:55:14.080" Title="Can ALL Optimization Problems be Classified as &quot;P&quot; vs &quot;NP&quot;?" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7780" PostTypeId="2" ParentId="7756" CreationDate="2022-02-07T02:01:26.390" Score="3" Body="&lt;p&gt;This may or may not help but I found that the knapsack problem does a good job showing how discrete problems can be harder than their direct continuous counterparts.&lt;/p&gt;&#xA;&lt;p&gt;Another domain that helped me understand a bit more intuitively is integer programming versus linear programming.&lt;/p&gt;&#xA;" OwnerUserId="9101" LastActivityDate="2022-02-07T02:01:26.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7781" PostTypeId="2" ParentId="7779" CreationDate="2022-02-07T02:18:01.143" Score="8" Body="&lt;p&gt;No. There are optimization problems that are strictly in EXPTIME or other complexity higher complexity. Picking the optimal move in a Go game on a &lt;span class=&quot;math-container&quot;&gt;$n\times n$&lt;/span&gt; grid is EXPTIME in &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. MaxSAT on QBF (quantified boolean formulas) is in PSPACE. Those examples are of harder complexity classes then NP and because of that the P vs NP distinction is irrelevant for them.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-02-07T02:18:01.143" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7782" PostTypeId="1" CreationDate="2022-02-07T05:16:06.167" Score="11" ViewCount="2958" Body="&lt;p&gt;If you look at the Loss Function for a Neural Network:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/a4qmh.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/a4qmh.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Can we consider the above problem as a &amp;quot;Non-Linear Optimization Problem&amp;quot;?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The way I see it, the Loss Function of real world Neural Networks usually contains higher order terms that likely result in this function being Non-Linear. Seeing as the goal in Neural Networks is to effectively optimize this Non-Linear Loss Function, &lt;strong&gt;would it be technically incorrect to refer to this optimization problem as a &amp;quot;Non-Linear Optimization Problem&amp;quot; in the traditional sense?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For example, algorithms such as the &amp;quot;Interior Point Method&amp;quot; are often used to optimize typical &amp;quot;Non Linear Problems.&amp;quot; Would the Loss Function of a Neural Network fall under a similar designation?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-07T13:56:21.257" LastActivityDate="2022-02-08T16:23:13.397" Title="Are Neural Networks Technically &quot;Non-Linear Programs&quot;?" Tags="|optimization|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7783" PostTypeId="1" CreationDate="2022-02-07T05:42:35.553" Score="1" ViewCount="619" Body="&lt;p&gt;In terms of python based atypical math model as shown below, which is unlike nonlinear or quadratic form in my opinion, I have difficulty in accessing value of variable before optimization as following error message, &lt;code&gt;DOcplexException: Model&amp;lt;docplex_model1&amp;gt; has not been solved yet&lt;/code&gt;. As a matter of fact, my real module represented by &lt;code&gt;cal_spl()&lt;/code&gt; is much more complex algebraic model using numpy and pandas. The main thing is that output of the module is a term of the objective function and value of the variables in the model is transformed into input of the module.&lt;/p&gt;&#xA;&lt;p&gt;How can I get value of variable for module as a part of objective function before solved?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;import cplex&#xA;&#xA;mdl = Model()&#xA;&#xA;x = mdl.integer_var(lb=0, ub=cplex.infinity, name='var_x')&#xA;y = mdl.integer_var(lb=0, ub=cplex.infinity, name='var_y')&#xA;&#xA;mdl.add_constraint(4*x+3*y &amp;gt;=30, 'Constraint')&#xA;&#xA;def cal_spl(x, y, mdl):&#xA;    k, l = 1, 1&#xA;    for i in range(1, x.solution_value+2):&#xA;        for j in range(1, y.solution_value+3):&#xA;            k = k*i&#xA;            l = l*l&#xA;            result = k- l&#xA;    return result&#xA;&#xA;mdl.minimize(50*x+40*y-cal_spl(x, y, mdl))&#xA;&#xA;mdl.solve()&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v, &amp;quot; =&amp;quot;, v.solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9104" LastEditorUserId="491" LastEditDate="2022-02-07T13:57:08.597" LastActivityDate="2022-02-08T04:28:49.603" Title="In DOcplex, how can I get value of variable for objective function before solved?" Tags="|mixed-integer-programming|python|nonlinear-programming|docplex|cplex-python-api|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7784" PostTypeId="1" CreationDate="2022-02-07T05:46:33.033" Score="5" ViewCount="386" Body="&lt;p&gt;&lt;strong&gt;I have the following question on &amp;quot;Regularization vs. Constrained Optimization&amp;quot; :&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the context of statistical modelling, we are often taught about &amp;quot;Regularization&amp;quot; as a method of dealing with the &amp;quot;Bias-Variance Tradeoff&amp;quot; (i.e. stabilizing the inconsistent performance of complicated models). When a L1-Norm or L2-Norm Penalty Term is added to the estimation function (corresponding to the statistical model) being optimized, some of the model parameters will either &amp;quot;shrink&amp;quot; in size towards 0, thus producing a &amp;quot;sparser&amp;quot; model that is more likely to retain its &amp;quot;low bias&amp;quot; but possible reduce its &amp;quot;high variance&amp;quot;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/beQSS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/beQSS.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have often heard of functions containing these L1-Norm and L2-Norm &amp;quot;Penalty Terms&amp;quot; being referred to as &amp;quot;optimization constraints&amp;quot; (i.e. the &amp;quot;feasible region&amp;quot; from which valid choices of model parameters can belong to has now been &amp;quot;altered&amp;quot; due to these &amp;quot;norm penalty constraints&amp;quot;):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XKZCv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XKZCv.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question: When we estimate some statistical model's parameters and the estimation equation contains some &amp;quot;regularization penalty term,&amp;quot; would it be incorrect to refer to this as an example of &amp;quot;constrained optimization&amp;quot;?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is regularized optimization in Machine Learning and Statistical Modelling fundamentally any different (with the exception of usually being more difficult and solved using approximate stochastic iterative methods) from Constrained Optimization in Linear Programming?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dIKDd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dIKDd.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Regularization_(mathematics)&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Regularization_(mathematics)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://ab-initio.mit.edu/wiki/index.php?title=NLopt_Tutorial&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://ab-initio.mit.edu/wiki/index.php?title=NLopt_Tutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-07T13:49:32.073" LastActivityDate="2022-02-13T09:46:03.140" Title="Regularization in Machine Learning : Constraint Optimization in Disguise?" Tags="|optimization|linear-programming|constraint|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7785" PostTypeId="2" ParentId="7782" CreationDate="2022-02-07T10:16:02.243" Score="15" Body="&lt;p&gt;With the advent of Deep Learning, most modern machine learning is about minimising a nonlinear regression function. They even use similar techniques as we do in nonlinear optimisation, e.g., gradient descent.&lt;/p&gt;&#xA;&lt;p&gt;However, there are a few practical differences in the approach:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We typically (but not always) care about proving optimality, ML simply cares about finding a point in the neighbourhood of the minimum. This is because:&lt;/li&gt;&#xA;&lt;li&gt;The scale of computations is orders of magnitude different, and&lt;/li&gt;&#xA;&lt;li&gt;Proving optimality in ML is kind of pointless since it's a parameter fitting problem in the first place, i.e., it's not a first principles model. Since there is inherent noise in the model, the minimum itself has little physical meaning. All ML needs to achieve is to find a good enough fit.&lt;/li&gt;&#xA;&lt;li&gt;This is compounded by the fact that, unlike conventional optimisation, ML will keep changing the model dynamically until its predictive power is good enough when tested on a blind test set, which in classical nonlinear optimisation is something a human would do. In other words, while we iterate to optimise the model we have, ML iterates to find a good model.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2022-02-07T10:16:02.243" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7786" PostTypeId="2" ParentId="7784" CreationDate="2022-02-07T12:12:16.683" Score="5" Body="&lt;p&gt;Yes it is incorrect to refer to a unconstrained optimization problem as a constrained optimization problem. The idea of putting constraints into the objective is a often used technique. Example one example is using Lagrange multipliers. However i wouldn't call an optimization problem which puts all constraints into the objective a constrained problem.&lt;/p&gt;&#xA;&lt;p&gt;In addition i think that sparsity constraints is an odd way to put it. I see the tradeoff between performance and sparsity as a pareto front which arise in multi objective optimization.&lt;/p&gt;&#xA;&lt;p&gt;The fundamental difference is the set of legal states for which the objective is defined, constraints reduce the size of that set while putting the constraint into the objective does not.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-02-07T12:12:16.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7787" PostTypeId="2" ParentId="7778" CreationDate="2022-02-07T17:48:43.100" Score="2" Body="&lt;p&gt;In minimization a lower loss if preferable under all circumstances. Each saddle point has a local minima one could discover from it if one walked in the right direction. Whether an individual saddle point is better than an individual minima depends on their objective. A saddle point can be than some local minima but it can be never be better than &amp;quot;it's&amp;quot; local minima. A saddle point can never be better than all local minima and saddle points but a local minima can be better than all other local minima and all saddle points. In summary saddle points are usually disliked because their existence proves we missed a better solution.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-02-07T17:48:43.100" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7788" PostTypeId="1" CreationDate="2022-02-08T03:55:01.267" Score="0" ViewCount="447" Body="&lt;p&gt;I was watching the following (amazing) lecture on Mixed Integer Optimization (&lt;a href=&quot;https://www.youtube.com/watch?v=xEQaDiAHDWk&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=xEQaDiAHDWk&lt;/a&gt;) and came across this slide that mentions &lt;strong&gt;Slater's Condition&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kpDzI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kpDzI.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This was the first time I have heard about &lt;strong&gt;Slater's Condition&lt;/strong&gt; and I was interested in learning more about this (&lt;a href=&quot;https://www.youtube.com/watch?v=GmY3LUL6GkY&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=GmY3LUL6GkY&lt;/a&gt;):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FAwHM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FAwHM.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Based on what I saw, this is what I understood:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For a Convex Optimization Problem, if a solution &amp;quot;x&amp;quot; exists within the Feasible Region of this problem : Then this Optimization Problem has &amp;quot;strong duality&amp;quot;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Since Mixed Integer Optimization Problems are always Non-Convex (since sets of integers are always non-convex), Slater's Condition does not hold.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Since Slater's Condition does not hold, there is no Strong Duality.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The above factors result in Combinatorial Optimization Problems being more difficult than Continuous Optimization Problems.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Now, I am trying to understand the logic of the above points:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Why is it important that a solution to a Non-Convex Optimization Problem exists within the interior region or not? Are there any benefits for solutions that exist within the interior region compared to solutions that do not exist in the interior region?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Why is it important to determine whether an Optimization Problem has Strong Duality or not?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Why does the Feasible Set have no interior in a Combinatorial Optimization Problem? Do Combinatorial Optimization Problems have interior regions at all?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Why don't Slater's Conditions hold if the Feasible Set has no interior? (i.e. Why don't Slater's Conditions hold for Combinatorial Optimization Problems?)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Why does the absence of Strong Duality result in an Optimization Problem being more difficult?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Can someone please help me understand the logic behind these facts? Currently I am just accepting them without really understanding why.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-03-13T23:10:35.097" LastActivityDate="2022-03-13T23:10:35.097" Title="Why is &quot;Slater's Condition&quot; Important?" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|" AnswerCount="1" CommentCount="3" ClosedDate="2022-02-08T07:48:31.683" ContentLicense="CC BY-SA 4.0" />
  <row Id="7790" PostTypeId="2" ParentId="7788" CreationDate="2022-02-08T07:11:13.857" Score="4" Body="&lt;p&gt;Slater’s condition is a type of constraint qualification (see &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.m.wikipedia.org/wiki/Karush–Kuhn–Tucker_conditions&lt;/a&gt; for more details). These conditions are important for continuous problems and are independent from convexity.&#xA;If your optimization problem does not satisfy constraint qualification, the (local and global) optimal points do not necessarily have to be KKT points, in other words, you cannot use gradient information to look for the optimal solution (solvers look for KKT points using first and second derivatives) and you will have numerical trouble with solvers. For a simple example where this happens see: &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2014/07/4456.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.optimization-online.org/DB_FILE/2014/07/4456.pdf&lt;/a&gt; (page 5).&#xA;A lack of  constraint qualification can be interpreted as a disconnect between the algebraic description of a feasible region and its geometric nature, this tends to happen when the problem is ill formulated.&#xA;A lack of constraint qualification is not what usually makes integer programming hard, non-convexity is responsible for that. In other words, the continuous relaxation of an integer program can satisfy slater’s condition but it can still be hard to find the globally optimal solution.&lt;/p&gt;&#xA;" OwnerUserId="289" LastActivityDate="2022-02-08T07:11:13.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7791" PostTypeId="2" ParentId="7782" CreationDate="2022-02-08T08:23:47.520" Score="3" Body="&lt;p&gt;I guess it really depends on what exactly are you asking. From a mathematical point of view, a neural network is nothing more than a function that maps inputs to outputs. Now, if you are thinking about the process of training a network--that is, given the network topology and a set of inputs and outputs, finding a set of parameters that minimize some function of the error between the neural network prediction and the observed output---the problem is indeed a 'traditional' mathematical program. Whenever your objective (loss) function as well as your constraints are most likely nonlinear, then your mathematical program is nonlinear.&lt;/p&gt;&#xA;&lt;p&gt;Of course, this is not the only way of looking at the process of training your network, you may be interested in approaching the training from a bayesian perspective, then you can look at this process from a perspective other than optimization.&lt;/p&gt;&#xA;&lt;p&gt;To summarize, the trained network is a function. The problem of training a network can be cast as a 'traditional' nonlinear optimization problem.&lt;/p&gt;&#xA;" OwnerUserId="9125" LastActivityDate="2022-02-08T08:23:47.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7792" PostTypeId="1" CreationDate="2022-02-08T14:12:54.280" Score="2" ViewCount="71" Body="&lt;p&gt;In my current python code, I have used MyBranch call back of Cplex to make 2 branches and solve my model.&lt;/p&gt;&#xA;&lt;p&gt;However, I now need to generate 4 branches after the first incumbent is generated. I need advise if this is possible, and if yes, how it that executed.&lt;/p&gt;&#xA;" OwnerUserId="9129" LastEditorUserId="491" LastEditDate="2022-02-08T14:35:04.633" LastActivityDate="2022-02-08T14:35:04.633" Title="Making multiple branches in make_branch function of Cplex" Tags="|cplex|callback|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7793" PostTypeId="2" ParentId="7782" CreationDate="2022-02-08T16:23:13.397" Score="2" Body="&lt;p&gt;Maybe these will help : &lt;a href=&quot;https://www.dynamic-ideas.com/books/machine-learning-under-a-modern-optimization-lens&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.dynamic-ideas.com/books/machine-learning-under-a-modern-optimization-lens&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://arxiv.org/pdf/2112.09279.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/2112.09279.pdf&lt;/a&gt; (Robust optimization approach to Deep learning)&lt;/p&gt;&#xA;&lt;p&gt;Actually, when the ML algorithm &amp;quot;train&amp;quot;, it is equivalent to solving an optimization problem minimizing loss function. (decision variable : parameters of ML)&lt;/p&gt;&#xA;&lt;p&gt;For example, ridge and lasso regression can be modeled as a SOCP (second-order cone program). Here, their objective function is quadratic + l1, l2 norm =&amp;gt; convex optimization. Moreover, Logistic regression can be modeled as convex program with exponential cone..&lt;/p&gt;&#xA;&lt;p&gt;But most of ML depends on first-order optimization method, because interior-point type algorithm requires us to compute inverse hessian of design matrix, which is costly..&lt;/p&gt;&#xA;" OwnerUserId="4130" LastActivityDate="2022-02-08T16:23:13.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7794" PostTypeId="1" AcceptedAnswerId="7802" CreationDate="2022-02-08T16:31:42.277" Score="4" ViewCount="640" Body="&lt;p&gt;I am using Pyomo together with Gurobi (and other solvers such as cbc). I am trying to compute an Irreducible Infeasible Set (ISS).&lt;/p&gt;&#xA;&lt;p&gt;In Pyomo &lt;a href=&quot;https://readthedocs.org/projects/pyomo/downloads/pdf/latest/&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt;, &lt;code&gt;get_model_attr&lt;/code&gt; takes an attribute, among which &lt;code&gt;'IISMinimal'&lt;/code&gt;. On the other hand Gurobi &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/iisminimal.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; states that &amp;quot;this attribute is only available after you have computed an IIS on an infeasible model&amp;quot;. However I haven't found how to actually compute an IIS for a given infeasible model.&lt;/p&gt;&#xA;&lt;p&gt;To give more context to this question, I am trying to determine which constraints make my problem infeasible. I've read about the subject (&lt;a href=&quot;https://stackoverflow.com/questions/51044262/finding-out-reason-of-pyomo-model-infeasibility&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/questions/6097/how-to-find-out-which-constraint-causes-problems-in-pyomo&quot;&gt;there&lt;/a&gt; for example) but as several users user state in their comments, I haven't been able to make it work so far.&lt;/p&gt;&#xA;" OwnerUserId="8723" LastEditorUserId="500" LastEditDate="2022-02-08T17:09:03.347" LastActivityDate="2022-02-09T11:51:03.163" Title="Compute Irreducible Infeasible Set (IIS) in Pyomo" Tags="|mixed-integer-programming|python|gurobi|pyomo|irreducible-infeasible-subset|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7796" PostTypeId="1" AcceptedAnswerId="7797" CreationDate="2022-02-08T19:14:31.477" Score="5" ViewCount="427" Body="&lt;p&gt;I basically have a (somewhat bloated) assignment-problem on a boolean-matrix: (N_WORKERS, N_TASKS). Let's assume, we only look at one specific worker and therefore we have a 1d boolean assignment-vector: &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I'm trying to model a soft-constraint which penalizes a &lt;em&gt;time-interval stretch&lt;/em&gt; implied by assignments. Each task has a constant start- and end-time and the stretch is defined by the earliest start and latest end:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var_stretch = NonnegativeVariable()&#xA;&#xA;conceptional (linearization necessary):&#xA;  var_stretch = max(end(t) for t in tasks if t assigned) - min(start(t) for t in tasks if t assigned)&#xA;&#xA;var_penalty = NonnegativeVariable()&#xA;&#xA;constraint:&#xA;  var_stretch - var_penalty &amp;lt;= constant_limit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Example (minimizing var_penalty):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x_0 = Task0 = (0, 200)&#xA;x_1 = Task1 = (600, 700)&#xA;x_2 = Task2 = (1000, 1400)&#xA;&#xA;constant_limit = 480&#xA;&#xA;Solution (listed = 1, not listed = 0): x_0, x_1, x_2 -&amp;gt; (1400 - 0) - var_penalty &amp;lt;= 480   -&amp;gt; var_penalty = 920&#xA;&#xA;Solution (listed = 1, not listed = 0): x_1, x_2      -&amp;gt; (1400 - 600) - var_penalty &amp;lt;= 480 -&amp;gt; var_penalty = 320&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Now the catch:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The problem is of larger scale and a-priori enforcing those constraints does not scale: &lt;em&gt;too many constraints&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(Basically two constraints for each assignment-variable for modelling it's effect = linearization of min/max) which basically results in the solver being unable to even solve the root-relaxation, at least when follow-up MILP solving is necessary: Simplex or IPM + crossover; IPM root-relax only is less of a problem).&lt;/p&gt;&#xA;&lt;p&gt;My hope: &lt;strong&gt;lazy-constraints in modern solvers&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My context / solver: &lt;strong&gt;CPLEX 20.1.0.0&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The idea / approach:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a-priori introduce nonnegative &lt;em&gt;variable&lt;/em&gt; &lt;code&gt;var_stretch&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;a-priori introduce nonnegative &lt;em&gt;variable&lt;/em&gt; &lt;code&gt;var_penalty&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;a-priori add the &lt;em&gt;constraint&lt;/em&gt;: &lt;code&gt;var_stretch&lt;/code&gt; - &lt;code&gt;var_penalty&lt;/code&gt; &amp;lt;= &lt;code&gt;constant_limit&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;add &lt;code&gt;var_penalty&lt;/code&gt; to the &lt;em&gt;objective-term&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There is nothing preventing var_stretch being 0 yet -&amp;gt; never any penalty implied!&lt;/p&gt;&#xA;&lt;p&gt;Then lazily (&lt;code&gt;IloCplex::Callback::Context::Id::Candidate&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;get all &lt;em&gt;assigned tasks&lt;/em&gt; of the current &lt;em&gt;candidate solution&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;get &lt;code&gt;var_stretch&lt;/code&gt; value of &lt;em&gt;candidate solution&lt;/em&gt; (which should provide the lower bound of the stretch implies by all the assigned tasks)&lt;/li&gt;&#xA;&lt;li&gt;check all &lt;em&gt;pairwise-combinations&lt;/em&gt; (pairs of tasks) over those &lt;em&gt;assigned&lt;/em&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;calculate the &lt;code&gt;implied_stretch&lt;/code&gt; of this &lt;em&gt;assigned pair&lt;/em&gt; (max ends of assigned - min starts of assigned)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;IF var_stretch@candidate-solution &amp;lt; implied_stretch&lt;/code&gt;:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;rejectCandidate(var_stretch + (1-task_a) * implied_stretch + (1-task_b) * implied_stretch &amp;gt;= implied_stretch&lt;/code&gt;)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In CPLEX terms: Don't accept solution and add a constraint which &amp;quot;CPLEX may use to cut off further candidate solutions that it finds.&amp;quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So basically:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;var_penalty&lt;/code&gt; can correct stretches too big (soft-constraint) but the objective pushes it down&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;var_penalty&lt;/code&gt; will correct if &lt;code&gt;var_stretch&lt;/code&gt; becomes too big&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;var_stretch&lt;/code&gt; only origin of becoming too big is the &lt;em&gt;cut&lt;/em&gt; within the &lt;em&gt;lazy-constraint&lt;/em&gt; (which is not guaranteed to be applied according to the docs)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;~ Idea: &lt;code&gt;var_stretch&lt;/code&gt; &amp;gt;= &lt;code&gt;some_constant&lt;/code&gt; &lt;em&gt;iff&lt;/em&gt; both tasks are assigned together&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Valid Lazy-constraint usage?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm always somewhat puzzled by the formal core (requirements and guarantees) of those lazy-constraints (or user-cuts) and i guess, my approach approach does not really fit both (nor what the &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=pools-differences-between-user-cuts-lazy-constraints&quot; rel=&quot;noreferrer&quot;&gt;CPLEX DOCS&lt;/a&gt; call optimality-cuts?).&lt;/p&gt;&#xA;&lt;p&gt;I implemented this with the formentioned solver (using C++/Concert; Generic-Callback) and those two examples work out as expected. I also already observed the missing guarantee (&lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=c-callbackcontext#method_rejectCandidate&quot; rel=&quot;noreferrer&quot;&gt;CPLEX DOCS: rejectCandidate&lt;/a&gt;) in regards to the cut (&lt;em&gt;&amp;quot;If not null and not empty, then CPLEX may use these constraints to cut off further candidate solutions that it finds. (There is no guarantee that it does so, though.)&amp;quot;&lt;/em&gt;): memorizing already rejected pairs and not re-checking those is wrong! (and might result in zero penalty as we miss out rejecting it again)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I'm still worried, that i might have hidden assumptions not compatible with the internal requirements rendering my approach wrong.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The question:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is this approach correct?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For me, the core-question is probably::&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;What exactly means &lt;em&gt;rejecting a solution&lt;/em&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I guess i assume that one of the following semantics are true / &lt;strong&gt;Is one of the following semantics true?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;A: Rejection is time-local and forgotten after that&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;But i don't see how one would not cycle (at least in worst-case) if rejection would be posted without a cut (which is legal API-usage)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;B: Rejection is not time-local / not forgotten = memorized but linked to a &lt;em&gt;concept of full-solution-hashing&lt;/em&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Solution with task_a, task_b assigned with this one variable expressing the stretch being 0 was rejected and fully-equal solutions can be ignored / rejected again if necessary -&amp;gt; stretch is still 0&lt;/li&gt;&#xA;&lt;li&gt;Solution with task_a, task_b assigned with this one variable expressing the stretch CHANGED (not 0 anymore), e.g. due to the cut being respected, while all others kept the same should not be rejected -&amp;gt; totally new situation to reason about!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="231" LastActivityDate="2022-02-08T19:40:27.793" Title="Lazy-Constraints for modelling soft-constraints (CPLEX + rejectCandidate semantics)" Tags="|mixed-integer-programming|cplex|callback|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7797" PostTypeId="2" ParentId="7796" CreationDate="2022-02-08T19:40:27.793" Score="7" Body="&lt;p&gt;CPLEX does not memorize rejected solutions. When you call rejectCandidate, CPLEX adds the violated constraint to a pool of lazy constraints, applies it to the current node and re-solves the LP relaxation. Assuming the original candidate does in fact violate the constraint, CPLEX may find a new candidate at the current node or may prune the node.&lt;/p&gt;&#xA;&lt;p&gt;As CPLEX continues to chug along, the constraint you added sits in the lazy constraint pool. How it gets used is a bit of a mystery (at least to me), but I'm pretty certain that CPLEX will check whether a new candidate solution satisfies it before going into candidate context (i.e., claiming it has a new incumbent). This is not done by comparing hash codes; CPLEX will evaluate the constraint at the new candidate and see if it is satisfied to within tolerances. Even if CPLEX fails to check a new candidate against the constraint, you should be safe because it will invoke the callback and give you a chance to rediscover that constraint (or discover a new one) that rejects the new candidate.&lt;/p&gt;&#xA;&lt;p&gt;There is a &amp;quot;contract&amp;quot; between you and CPLEX in which you guarantee to CPLEX that any constraint you add via the callback does not cut off the optimal solution. It is allowed to cut off otherwise feasible integer solutions (unlike a &amp;quot;user cut&amp;quot;, which is allowed to trim the fat between the integer hull and the LP hull but is not allowed to cut off integer-feasible solutions).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-08T19:40:27.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7798" PostTypeId="2" ParentId="7767" CreationDate="2022-02-08T22:14:04.303" Score="2" Body="&lt;p&gt;So, with a great help of &lt;a href=&quot;https://or.stackexchange.com/users/981/laurent-perron&quot;&gt;Mr. Perron&lt;/a&gt; I understood my own assignment!&lt;/p&gt;&#xA;&lt;p&gt;Basically I was linking my OptionalIntervals to the particular points in time, making it time and memory consuming. I really thought that BoolVar for OptInterval should be bound to specific moment in time, yes.&lt;/p&gt;&#xA;&lt;p&gt;In fact there were no need to do it and it really is 1 interval per task and some constraints, so, flexible job-shop kinda.&lt;/p&gt;&#xA;&lt;p&gt;The final &lt;a href=&quot;https://pastebin.com/10mDwZqj&quot; rel=&quot;nofollow noreferrer&quot;&gt;look&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6027" LastActivityDate="2022-02-08T22:14:04.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7799" PostTypeId="2" ParentId="7794" CreationDate="2022-02-09T03:09:09.160" Score="-1" Body="&lt;p&gt;An excellent reference on infeasibility analysis is the book:&#xA;Chinneck, John (2008)&#xA;&amp;quot;Feasibility and Infeasibility in Optimization Algorithms and Computational Methods&amp;quot;&#xA;Springer.&#xA;Looks like it may be downloadable as a pdf.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-02-09T03:09:09.160" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7800" PostTypeId="1" CreationDate="2022-02-09T06:38:14.957" Score="7" ViewCount="6103" Body="&lt;p&gt;&lt;strong&gt;I am trying to find some real life (&amp;quot;non trivial&amp;quot;) examples of Linear Programming.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;So far, most of the examples that I come across are from introductory textbooks involving some basic example about farmers choosing between different crops to grow based on expected harvest and market price; or some similar example of a factory in which two different machines manufacture different types of items at different speeds, and again based on expected consumer demand, the manager at the factory is expected to decide how much of each machine's workload should be assigned to which type of item. Sometimes, there might be some constraints that need to be taken into consideration. Generally, these problems I come across can be solved using algebraic manipulation or through linear programming.&lt;/p&gt;&#xA;&lt;p&gt;I posted an example of one of these problems below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/r5Rj8.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/r5Rj8.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Although these types of problems are great examples to familiarize one's self with Linear Programming, the context of these problems generally appear as &amp;quot;too simple&amp;quot;, and instantly one begins to think that these are big oversimplifications of real world problems and such oversimplified problems do not fully represent the complexities that are usually encountered in the real world. I am trying to look for some examples of Linear Programming problems in more realistic situations.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;We are usually told that the real world is often characterized by non-linear relationships; apart from a stepping stone to learn about optimization and more complicated concepts, are there still instances in which pure Linear Programming problems still arise in the real world?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can someone please suggest some more realistic examples of (purely) Linear Programming problems that arise in the real world?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-09T13:15:39.947" LastActivityDate="2022-02-15T03:02:44.400" Title="Real Life Applications of Linear Programming" Tags="|optimization|linear-programming|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7801" PostTypeId="1" AcceptedAnswerId="7805" CreationDate="2022-02-09T09:58:47.697" Score="5" ViewCount="406" Body="&lt;p&gt;I have decision variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt;, real positive variables.&lt;/p&gt;&#xA;&lt;p&gt;I would like to minimize objective function&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\min \quad &amp;amp; \sum_{ij} x_iy_j \\&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;All constraints are linear and decoupled/separable in the sense that each constraint involves either only &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; or only &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt;. For example,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;x_1 \leq x_2 \\&#xA;y_1 \leq y_2&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;are acceptable constraints, but&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;x_1 \leq y_1 \\&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is not an acceptable constraint.&lt;/p&gt;&#xA;&lt;p&gt;What is a good way of solving such problems?&lt;/p&gt;&#xA;" OwnerUserId="8775" LastEditorUserId="500" LastEditDate="2022-02-09T18:37:17.227" LastActivityDate="2022-02-09T18:37:17.227" Title="How to handle a bilinear objective function in the special case of decoupled constraints?" Tags="|optimization|nonlinear-programming|quadratic-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7802" PostTypeId="2" ParentId="7794" CreationDate="2022-02-09T11:51:03.163" Score="4" Body="&lt;p&gt;The &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_model_computeiis.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi documentation&lt;/a&gt; states how you can compute and inspect the IIS:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.computeIIS()&#xA;model.write(&amp;quot;model.ilp&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am not certain how to call the &lt;code&gt;computeIIS()&lt;/code&gt; method from Pyomo, though. This &lt;a href=&quot;https://stackoverflow.com/questions/51522718/get-gurobi-iis-using-pyomo-and-gurobipy&quot;&gt;related question&lt;/a&gt; might also be helpful.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2022-02-09T11:51:03.163" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7803" PostTypeId="2" ParentId="7800" CreationDate="2022-02-09T14:19:47.653" Score="7" Body="&lt;p&gt;Starting with a Real-life applications side note: I would assume this to be true for many domains, but when you're working on OR/Analytics/Data Science related projects, one of the very essential skills to have would be 'to connect the dots'. Be it a client-facing company or a company where you're building an in-house product, you'll hardly come across a situation where you'll specifically be told to use a particular algorithm or meta-heuristic. Most of the time you'll have to 'own' the problem and come up with ways to solve it. So whether to use Linear programming or not may boil down to the problem solver i.e. You!&lt;/p&gt;&#xA;&lt;p&gt;Now coming back to your question: Yes, there are many areas where Linear Programming can still be pretty useful. If I am adding MILP in the mix, then the potential is huge but even without that, you will have a choice to use LP. Even I did something a few months back with LP. I was solving a special variant of &lt;code&gt;Facility Location Problem&lt;/code&gt;, where we were looking to add one warehouse in the network as there was a surge in the customer demand. Not going much deep into how we did it, we implemented a heuristic alongside a Linear Programming equation. We solved that with &lt;a href=&quot;https://cran.r-project.org/web/packages/lpSolve/lpSolve.pdf&quot; rel=&quot;noreferrer&quot;&gt;lpsolve&lt;/a&gt; in &lt;code&gt;R&lt;/code&gt;, then even made a dashboard of it.&lt;/p&gt;&#xA;&lt;p&gt;When you will start working you'll also face similar situations where you can implement LP. The key will be how you'll 'connect the dots'.&lt;/p&gt;&#xA;" OwnerUserId="5532" LastActivityDate="2022-02-09T14:19:47.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7804" PostTypeId="2" ParentId="7800" CreationDate="2022-02-09T17:07:57.597" Score="11" Body="&lt;p&gt;Anecdotally, the first industrial purchasers of mainframe computers were petroleum producers who need the mainframes to solve linear programming models used to schedule refinery operations. I believe LPs are still used in refinery scheduling. McKinsey &amp;quot;Energy Insights&amp;quot; has a nice &lt;a href=&quot;https://www.mckinseyenergyinsights.com/resources/refinery-reference-desk/optimization/&quot; rel=&quot;noreferrer&quot;&gt;web page&lt;/a&gt; with pertinent information.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-09T17:07:57.597" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7805" PostTypeId="2" ParentId="7801" CreationDate="2022-02-09T17:12:35.067" Score="5" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; be the (polyhedral) sets of feasible values for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; respectively. Your objective function &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j}x_i y_j$&lt;/span&gt; equates to &lt;span class=&quot;math-container&quot;&gt;$$\left(\sum_i x_i\right) \left(\sum_j y_j\right).$$&lt;/span&gt; So your problem is separable. You can just solve two LPs, &lt;span class=&quot;math-container&quot;&gt;$$\min_{x\in X}\sum_i x_i$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$\min_{y\in Y} \sum_j y_j,$$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-09T17:12:35.067" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7806" PostTypeId="1" AcceptedAnswerId="7909" CreationDate="2022-02-10T09:12:51.887" Score="5" ViewCount="209" Body="&lt;p&gt;I have a large number of (10000+) &lt;strong&gt;non-negative&lt;/strong&gt;, &lt;strong&gt;real&lt;/strong&gt; decision variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; be the index sets associated with &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, respectively.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\bar{I}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{J}$&lt;/span&gt; be non-empty subsets of &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;, respectively.&lt;/p&gt;&#xA;&lt;p&gt;The objective function I would like to &lt;strong&gt;minimize&lt;/strong&gt; (subject to some constraints) is of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\quad &amp;amp; \sum_{i\in{\bar{I}}}\sum_{j\in{\bar{J}}} a_{ij}x_iy_j + \sum_{i\in{I}} b_ix_i + \sum_{j\in{J}} c_jy_j \\&#xA;\end{aligned}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; are positive, real constants.&lt;/p&gt;&#xA;&lt;p&gt;All constraints are linear and decoupled/separable in the sense that each constraint involves either only &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; or only &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt;. For example,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;x_1 \leq x_2 \\&#xA;y_1 \leq y_2&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;are acceptable constraints, but&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;x_1 \leq y_1 \\&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is not an acceptable constraint.&lt;/p&gt;&#xA;&lt;p&gt;Number of constraints are also large (comparable to the number of variables).&lt;/p&gt;&#xA;&lt;p&gt;In summary, objective function is not separable (to an &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;-part and a &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;-part), but the constraints are. There is one paper&lt;sup&gt;1&lt;/sup&gt; from 2009 which defines such problems as &amp;quot;separable bilinear programs&amp;quot; but it does not seem to be a commonly used term.&lt;/p&gt;&#xA;&lt;p&gt;What is a good way of solving such problems, if there is any? I have a concern that a solver may use a general method for a quadratic program and not fully make use of the separability of constraints.&lt;/p&gt;&#xA;&lt;p&gt;Edit: Linking previously asked questions which seem related.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/3139/linearization-of-the-product-of-two-real-valued-variables-binary-expansion-app&quot;&gt;Linearization of the product of two real valued variables - Binary expansion approach&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/180/how-to-linearize-the-product-of-two-continuous-variables&quot;&gt;How to linearize the product of two continuous variables?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; References &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Petrik, M., &amp;amp; Zilberstein, S. (2009). A bilinear programming approach for multiagent planning. Journal of Artificial Intelligence Research, 35, 235-274. &lt;a href=&quot;https://arxiv.org/pdf/1401.3461.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/1401.3461.pdf&lt;/a&gt; &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="8775" LastEditorUserId="8775" LastEditDate="2022-02-10T12:38:31.467" LastActivityDate="2022-02-21T23:17:03.550" Title="How to handle a non-separable bilinear objective function in the special case of decoupled constraints?" Tags="|optimization|nonlinear-programming|quadratic-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7807" PostTypeId="2" ParentId="7689" CreationDate="2022-02-10T09:40:28.117" Score="3" Body="&lt;p&gt;Pedrinho covered the Online part of your question very well, so I'll answer the other two.&lt;/p&gt;&#xA;&lt;p&gt;Strictly speaking, when we pose an optimisation problem, solving it means finding its global solution. If the problem is also continuous, finding that solution also means satisfying the conditions for optimality. If the problem is discrete, it means that we need to prove there is no other discrete solution better than the one we found, which we typically do with branch and bound.&lt;/p&gt;&#xA;&lt;p&gt;This type of classical solving is often not possible in practice, either because the problem is too large or because the equations are black-box.&lt;/p&gt;&#xA;&lt;p&gt;In these cases, we would use stochastic optimisation methods, i.e., methods that seek to find some feasible solution to our problem without caring about proving much else beyond that. Examples include simulated annealing, evolutionary algorithms, particle swarm optimisation, and so on. Note that it's a bit hard to be exact in this definition, because many methods use a blend of characteristics, e.g., depending on how we do simulated annealing we could also seek to satisfy the optimality conditions like we do in local optimisation. In any case, stochastic methods will never seek to prove that a solution is globally optimal.&lt;/p&gt;&#xA;&lt;p&gt;The main characteristic of stochastic methods is that there is an element of randomness every time we run them, i.e., we can get a different result every time. Note that this is still not a necessity, as even a particle swarm method could deterministically generate a random seed which would make the results reproducible. Examples would include generating random values for variables or iterates.&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, I have also seen people use this term to describe something totally different, i.e., creating and solving models that encode real-world stochasticity (e.g. financial modelling, forecasting, and so on). I haven't seen a formal definition to distinguish between the two, but I personally use &amp;quot;stochastic optimisation methods&amp;quot; to refer to the actual algorithmic part, so that it can't be mistaken for the modelling bit.&lt;/p&gt;&#xA;&lt;p&gt;Along similar lines, I have seen the term Robust Optimisation used in two different ways. The first one is Wikipedia's definition, which says that we seek a certain level of robustness against uncertainty, e.g., to configure a power plant to run such that there is 95% probability that we will be able to meet demand every day. This is very similar to stochastic modelling, the main difference being that here we have a very specific objective, which is not necessarily true in other models that simply include stochasticity.&lt;/p&gt;&#xA;&lt;p&gt;The second definition is very deterministic: we seek to minimise fluctuations in a system, which can be modelled deterministically. For example, I once worked on optimising aircraft wings such that we achieved maximum lift whilst ensuring that they would never be able to oscillate beyond specifications due to aeroelastic effects. There was nothing stochastic there, as the aeroelasticity equations are deterministic and the turbulence models are very precise. In mechanical engineering, we call that robust optimisation, since we are not simply optimising for performance - we are ensuring that a system will be robust (not break) during its operation.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2022-02-10T09:40:28.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7808" PostTypeId="2" ParentId="7765" CreationDate="2022-02-10T10:31:22.973" Score="1" Body="&lt;p&gt;No we have not, and it doesn't.&lt;/p&gt;&#xA;&lt;p&gt;Many decades of brilliant optimisation ideas have given us an extensive array of tools to use, but every tool is best suited for a certain job.&lt;/p&gt;&#xA;&lt;p&gt;Mathematically speaking, there are very good reasons for which (stochastic) gradient descent does not have good convergence properties for non-convex problems. In fact, it is a very bad method to use on convex problems as well, assuming the problem is small enough to use better methods.&lt;/p&gt;&#xA;&lt;p&gt;What makes it shine in machine learning is that, due to the size of the problem, it's one of the best methods that are usable in practice. In other words, it's a great tool for that job.&lt;/p&gt;&#xA;&lt;p&gt;GD converges on convex problems because there's a guaranteed path for it to follow to get to the minimum. This is simply not guaranteed in the non-convex case, which is why the authors say it will either diverge or converge to a minimum. This makes perfect sense: if we happen to be very far from a basin of attraction, or if the non-convexity of the hypersurface is such that from most directions our algorithm will just slide past the basin of attraction, no amount of tricks will give us a &lt;strong&gt;guarantee&lt;/strong&gt; of getting there if we must restrict ourselves to GD. With enough black magic, it can still of course work great a lot of the time, especially under assumptions.&lt;/p&gt;&#xA;&lt;p&gt;The other aspect we must take into account here is the probability. There are many stochastic methods that have probability 1 to converge to a minimum, but what are the time assumptions? Is it after finite time, or infinite time?&lt;/p&gt;&#xA;&lt;p&gt;A way we can think of the hierarchy of methods we want to be using, is how expensive/feasible it is to use a certain tool vs the potential payoff.&lt;/p&gt;&#xA;&lt;p&gt;For instance, if a non-convex problem can be solved by a deterministic global optimisation solver, those methods guarantee global convergence in finite time and a finite number of iterations (which can still be a million years in practice).&lt;/p&gt;&#xA;&lt;p&gt;If the problem is too large for a global optimiser, we would use local optimisation with second-order information.&lt;/p&gt;&#xA;&lt;p&gt;If a problem is too large for second-order information, we would use first-order information (e.g. gradient descent).&lt;/p&gt;&#xA;&lt;p&gt;If the problem is too large and/or too non-convex for the first-order method to perform well, we would use a stochastic method.&lt;/p&gt;&#xA;&lt;p&gt;If the problem is still unsolvable, we either spend a few years/decades figuring it out, or wait until someone much smarter than us waltzes in and destroys it like it was nothing.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2022-02-10T10:31:22.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7810" PostTypeId="1" CreationDate="2022-02-10T12:48:34.300" Score="7" ViewCount="950" Body="&lt;p&gt;I am solving a MILP with cbc and gurobi (via pyomo). Gurobi states that the model is infeasible. As to cbc the solver status states that a feasible and optimal solution is found, but then it fails to access the value of the objective (which in turn crashed my program).&lt;/p&gt;&#xA;&lt;p&gt;Here is how I access the objective value&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solver_parameters = &amp;quot;ResultFile=model.lp&amp;quot;&#xA;opt = SolverFactory(solver)&#xA;        &#xA;results = opt.solve(self.model, tee=False, options_string=solver_parameters,logfile=&amp;quot;model.log&amp;quot;)&#xA;# checking status and terminiation condition&#xA;print (&amp;quot;The solver returned a status of: &amp;quot;+str(results.solver.status))&#xA;print (str(results.solver))&#xA;if (results.solver.status == SolverStatus.ok) and (results.solver.termination_condition== TerminationCondition.optimal):&#xA;   print (&amp;quot;Problem is feasible and solution is optimal&amp;quot;)&#xA;        objective_value = value(self.model.objective)&#xA;else:&#xA;   print(&amp;quot;Problem is infeasible&amp;quot;)&#xA;   objective_value = None&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With cbc I get&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;The solver returned a status of: ok&#xA;&#xA;- Status: ok&#xA;  Message: CBC 2.10.5&#xA;  Termination condition: optimal&#xA;  Id: 0&#xA;  Error rc: 0&#xA;  Time: 0.011972904205322266&#xA;&#xA;Problem is feasible and solution is optimal&#xA;&#xA;ERROR: evaluating object as numeric value: x[0]&#xA;        (object: &amp;lt;class 'pyomo.core.base.var._GeneralVarData'&amp;gt;)&#xA;    No value for uninitialized NumericValue object x[0]&#xA;ERROR: evaluating object as numeric value: objective&#xA;        (object: &amp;lt;class 'pyomo.core.base.objective.SimpleObjective'&amp;gt;)&#xA;    No value for uninitialized NumericValue object x[0]&#xA;Traceback (most recent call last):&#xA;...&#xA;  File &amp;quot;c:...&amp;quot;, line 531, in solve&#xA;    objective_value = value(self.model.objective)&#xA;  File &amp;quot;pyomo\core\expr\numvalue.pyx&amp;quot;, line 246, in pyomo.core.expr.numvalue.value&#xA;  File &amp;quot;pyomo\core\expr\numvalue.pyx&amp;quot;, line 231, in pyomo.core.expr.numvalue.value&#xA;  File &amp;quot;C:...\lib\site-packages\pyomo\core\base\expression.py&amp;quot;, line 55, in __call__&#xA;    return self.expr(exception=exception)&#xA;  File &amp;quot;pyomo\core\expr\numeric_expr.pyx&amp;quot;, line 218, in pyomo.core.expr.numeric_expr.ExpressionBase.__call__&#xA;  File &amp;quot;C:...\lib\site-packages\pyomo\core\expr\visitor.py&amp;quot;, line 1054, in evaluate_expression&#xA;    return visitor.dfs_postorder_stack(exp)&#xA;  File &amp;quot;C:...\venv\lib\site-packages\pyomo\core\expr\visitor.py&amp;quot;, line 584, in dfs_postorder_stack&#xA;    flag, value = self.visiting_potential_leaf(_sub)&#xA;  File &amp;quot;C:...\lib\site-packages\pyomo\core\expr\visitor.py&amp;quot;, line 962, in visiting_potential_leaf&#xA;    return True, value(node)&#xA;  File &amp;quot;pyomo\core\expr\numvalue.pyx&amp;quot;, line 246, in pyomo.core.expr.numvalue.value&#xA;  File &amp;quot;pyomo\core\expr\numvalue.pyx&amp;quot;, line 233, in pyomo.core.expr.numvalue.value&#xA;ValueError: No value for uninitialized NumericValue object x[0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Cbc log is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Solver command line: ['C:...\\cbc.exe', 'C:...\\AppData\\Local\\Temp\\tmp49biprhm.pyomo.nl', '-AMPL']&#xA;&#xA;CBC 2.10.5: &#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;On the other hand with gurobi I get&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;WARNING: Loading a SolverResults object with a warning status into&#xA;    model.name=&amp;quot;unknown&amp;quot;;&#xA;      - termination condition: infeasible&#xA;      - message from solver: Model was proven to be infeasible.&#xA;The solver returned a status of: warning&#xA;&#xA;- Status: warning&#xA;  Return code: 0&#xA;  Message: Model was proven to be infeasible.&#xA;  Termination condition: infeasible&#xA;  Termination message: Model was proven to be infeasible.&#xA;  Wall time: 0.0019626617431640625&#xA;  Error rc: 0&#xA;  Time: 0.08476400375366211&#xA;&#xA;Problem is infeasible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'm assuming problem is indeed infeasible and the error comes from cbc. Is this kind of error common, and what would be a way to avoid this?&lt;/p&gt;&#xA;&lt;p&gt;Finally, this is the lp model returned by gurobi&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\ Model x79&#xA;\ LP format - for model browsing. Use MPS format to capture full model detail.&#xA;Maximize&#xA;  - 100 x12 - 200 x13 - 300 x14 - 400 x15 - 70 x16 - 140 x17 - 90 x18&#xA;   - 90 x19&#xA;Subject To&#xA; c_u_x80_: x12 - 100 x1 &amp;lt;= 0&#xA; c_u_x81_: x13 - 100 x2 &amp;lt;= 0&#xA; c_u_x82_: x14 - 100 x3 &amp;lt;= 0&#xA; c_u_x83_: x15 - 100 x4 &amp;lt;= 0&#xA; c_u_x84_: x16 - 50 x5 &amp;lt;= 0&#xA; c_u_x85_: x17 - 50 x6 &amp;lt;= 0&#xA; c_u_x86_: x18 - 25 x7 &amp;lt;= 0&#xA; c_u_x87_: x19 - 25 x8 &amp;lt;= 0&#xA; c_l_x88_: x12 &amp;gt;= 0&#xA; c_l_x89_: x13 &amp;gt;= 0&#xA; c_l_x90_: x14 &amp;gt;= 0&#xA; c_l_x91_: x15 &amp;gt;= 0&#xA; c_l_x92_: x16 &amp;gt;= 0&#xA; c_l_x93_: x17 &amp;gt;= 0&#xA; c_l_x94_: x18 &amp;gt;= 0&#xA; c_l_x95_: x19 &amp;gt;= 0&#xA; c_u_x96_: x1 &amp;lt;= 1&#xA; c_u_x97_: x2 &amp;lt;= 1&#xA; c_u_x98_: x3 &amp;lt;= 1&#xA; c_u_x99_: x4 &amp;lt;= 1&#xA; c_u_x100_: x5 &amp;lt;= 1&#xA; c_u_x101_: x6 &amp;lt;= 1&#xA; c_u_x102_: x7 &amp;lt;= 1&#xA; c_u_x103_: x8 &amp;lt;= 1&#xA; c_e_x104_: x12 + x16 = 51&#xA; c_e_x105_: x13 + x17 = 51&#xA; c_e_x106_: x14 + x18 = 51&#xA; c_e_x107_: x15 + x19 = 51&#xA; c_u_x108_: - x7 + x9 &amp;lt;= 0&#xA; c_u_x109_: - x6 + x10 &amp;lt;= 0&#xA; c_u_x110_: - x2 - x3 + x11 &amp;lt;= 0&#xA; c_u_x111_: x7 - 2 x9 &amp;lt;= 0&#xA; c_u_x112_: x6 - 2 x10 &amp;lt;= 0&#xA; c_u_x113_: x2 + x3 - 2 x11 &amp;lt;= 0&#xA; c_u_x114_: 100 x13 + 20 x14 + 100 x17 + 20 x18 &amp;lt;= 6072&#xA; c_u_x115_: - 20 x18 + 1260 x9 &amp;lt;= 0&#xA; c_u_x116_: - 100 x17 + 1260 x10 &amp;lt;= 0&#xA; c_u_x117_: - 100 x13 - 20 x14 + 1260 x11 &amp;lt;= 0&#xA; c_u_x118_: 2 x1 - x24 &amp;lt;= 0&#xA; c_u_x119_: 2 x2 - x25 &amp;lt;= 0&#xA; c_u_x120_: 15 x3 - x26 &amp;lt;= 0&#xA; c_u_x121_: 10 x4 - x27 &amp;lt;= 0&#xA; c_u_x122_: 1.4 x5 - x24 &amp;lt;= 0&#xA; c_u_x123_: 1.4 x6 - x25 &amp;lt;= 0&#xA; c_u_x124_: 4.5 x7 - x26 &amp;lt;= 0&#xA; c_u_x125_: 2.25 x8 - x27 &amp;lt;= 0&#xA; c_u_x126_: 100 x12 + 200 x13 + 300 x14 + 400 x15 + 70 x16 + 140 x17&#xA;   + 90 x18 + 90 x19 - 2550 x24 - 5100 x25 - 1020 x26 - 2040 x27 + 6072 x48&#xA;   + 100 x60 + 100 x61 + 100 x62 + 100 x63 + 50 x64 + 50 x65 + 25 x66&#xA;   + 25 x67 - 1260 x76 - 1260 x77 - 1260 x78 &amp;lt;= 0&#xA; c_u_x127_: - 1000 x1 + x60 &amp;lt;= 0&#xA; c_u_x128_: - 1000 x2 + x61 &amp;lt;= 0&#xA; c_u_x129_: - 1000 x3 + x62 &amp;lt;= 0&#xA; c_u_x130_: - 1000 x4 + x63 &amp;lt;= 0&#xA; c_u_x131_: - 1000 x5 + x64 &amp;lt;= 0&#xA; c_u_x132_: - 1000 x6 + x65 &amp;lt;= 0&#xA; c_u_x133_: - 1000 x7 + x66 &amp;lt;= 0&#xA; c_u_x134_: - 1000 x8 + x67 &amp;lt;= 0&#xA; c_u_x135_: x60 - x32 &amp;lt;= 0&#xA; c_u_x136_: x61 - x33 &amp;lt;= 0&#xA; c_u_x137_: x62 - x34 &amp;lt;= 0&#xA; c_u_x138_: x63 - x35 &amp;lt;= 0&#xA; c_u_x139_: x64 - x36 &amp;lt;= 0&#xA; c_u_x140_: x65 - x37 &amp;lt;= 0&#xA; c_u_x141_: x66 - x38 &amp;lt;= 0&#xA; c_u_x142_: x67 - x39 &amp;lt;= 0&#xA; c_u_x143_: 1000 x1 - x60 + x32 &amp;lt;= 1000&#xA; c_u_x144_: 1000 x2 - x61 + x33 &amp;lt;= 1000&#xA; c_u_x145_: 1000 x3 - x62 + x34 &amp;lt;= 1000&#xA; c_u_x146_: 1000 x4 - x63 + x35 &amp;lt;= 1000&#xA; c_u_x147_: 1000 x5 - x64 + x36 &amp;lt;= 1000&#xA; c_u_x148_: 1000 x6 - x65 + x37 &amp;lt;= 1000&#xA; c_u_x149_: 1000 x7 - x66 + x38 &amp;lt;= 1000&#xA; c_u_x150_: 1000 x8 - x67 + x39 &amp;lt;= 1000&#xA; c_u_x151_: - 1000 x1 + x68 &amp;lt;= 0&#xA; c_u_x152_: - 1000 x2 + x69 &amp;lt;= 0&#xA; c_u_x153_: - 1000 x3 + x70 &amp;lt;= 0&#xA; c_u_x154_: - 1000 x4 + x71 &amp;lt;= 0&#xA; c_u_x155_: - 1000 x5 + x72 &amp;lt;= 0&#xA; c_u_x156_: - 1000 x6 + x73 &amp;lt;= 0&#xA; c_u_x157_: - 1000 x7 + x74 &amp;lt;= 0&#xA; c_u_x158_: - 1000 x8 + x75 &amp;lt;= 0&#xA; c_u_x159_: x68 - x40 &amp;lt;= 0&#xA; c_u_x160_: x69 - x41 &amp;lt;= 0&#xA; c_u_x161_: x70 - x42 &amp;lt;= 0&#xA; c_u_x162_: x71 - x43 &amp;lt;= 0&#xA; c_u_x163_: x72 - x44 &amp;lt;= 0&#xA; c_u_x164_: x73 - x45 &amp;lt;= 0&#xA; c_u_x165_: x74 - x46 &amp;lt;= 0&#xA; c_u_x166_: x75 - x47 &amp;lt;= 0&#xA; c_u_x167_: 1000 x1 - x68 + x40 &amp;lt;= 1000&#xA; c_u_x168_: 1000 x2 - x69 + x41 &amp;lt;= 1000&#xA; c_u_x169_: 1000 x3 - x70 + x42 &amp;lt;= 1000&#xA; c_u_x170_: 1000 x4 - x71 + x43 &amp;lt;= 1000&#xA; c_u_x171_: 1000 x5 - x72 + x44 &amp;lt;= 1000&#xA; c_u_x172_: 1000 x6 - x73 + x45 &amp;lt;= 1000&#xA; c_u_x173_: 1000 x7 - x74 + x46 &amp;lt;= 1000&#xA; c_u_x174_: 1000 x8 - x75 + x47 &amp;lt;= 1000&#xA; c_u_x175_: - 1000 x9 + x76 &amp;lt;= 0&#xA; c_u_x176_: - 1000 x10 + x77 &amp;lt;= 0&#xA; c_u_x177_: - 1000 x11 + x78 &amp;lt;= 0&#xA; c_u_x178_: x76 - x49 &amp;lt;= 0&#xA; c_u_x179_: x77 - x50 &amp;lt;= 0&#xA; c_u_x180_: x78 - x51 &amp;lt;= 0&#xA; c_u_x181_: 1000 x9 - x76 + x49 &amp;lt;= 1000&#xA; c_u_x182_: 1000 x10 - x77 + x50 &amp;lt;= 1000&#xA; c_u_x183_: 1000 x11 - x78 + x51 &amp;lt;= 1000&#xA; c_l_x184_: - 50 x24 + x32 - x40 &amp;gt;= -100&#xA; c_l_x185_: - 100 x25 + 100 x48 + x33 - x41 - 100 x51 &amp;gt;= -200&#xA; c_l_x186_: - 20 x26 + 20 x48 + x34 - x42 - 20 x51 &amp;gt;= -300&#xA; c_l_x187_: - 40 x27 + x35 - x43 &amp;gt;= -400&#xA; c_l_x188_: - 50 x24 + x36 - x44 &amp;gt;= -70&#xA; c_l_x189_: - 100 x25 + 100 x48 + x37 - x45 - 100 x50 &amp;gt;= -140&#xA; c_l_x190_: - 20 x26 + 20 x48 + x38 - x46 - 20 x49 &amp;gt;= -90&#xA; c_l_x191_: - 40 x27 + x39 - x47 &amp;gt;= -90&#xA; c_u_x192_: x24 &amp;lt;= 2&#xA; c_u_x193_: x25 &amp;lt;= 2&#xA; c_u_x194_: x26 &amp;lt;= 15&#xA; c_u_x195_: x27 &amp;lt;= 10&#xA; c_e_ONE_VAR_CONSTANT: ONE_VAR_CONSTANT = 1&#xA;Bounds&#xA; x24 free&#xA; x25 free&#xA; x26 free&#xA; x27 free&#xA;Binaries&#xA; x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11&#xA;End&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; MPS file below&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;NAME x79&#xA;OBJSENSE MAX&#xA;ROWS&#xA; N  OBJ&#xA; L  c_u_x80_&#xA; L  c_u_x81_&#xA; L  c_u_x82_&#xA; L  c_u_x83_&#xA; L  c_u_x84_&#xA; L  c_u_x85_&#xA; L  c_u_x86_&#xA; L  c_u_x87_&#xA; G  c_l_x88_&#xA; G  c_l_x89_&#xA; G  c_l_x90_&#xA; G  c_l_x91_&#xA; G  c_l_x92_&#xA; G  c_l_x93_&#xA; G  c_l_x94_&#xA; G  c_l_x95_&#xA; L  c_u_x96_&#xA; L  c_u_x97_&#xA; L  c_u_x98_&#xA; L  c_u_x99_&#xA; L  c_u_x100_&#xA; L  c_u_x101_&#xA; L  c_u_x102_&#xA; L  c_u_x103_&#xA; E  c_e_x104_&#xA; E  c_e_x105_&#xA; E  c_e_x106_&#xA; E  c_e_x107_&#xA; L  c_u_x108_&#xA; L  c_u_x109_&#xA; L  c_u_x110_&#xA; L  c_u_x111_&#xA; L  c_u_x112_&#xA; L  c_u_x113_&#xA; L  c_u_x114_&#xA; L  c_u_x115_&#xA; L  c_u_x116_&#xA; L  c_u_x117_&#xA; L  c_u_x118_&#xA; L  c_u_x119_&#xA; L  c_u_x120_&#xA; L  c_u_x121_&#xA; L  c_u_x122_&#xA; L  c_u_x123_&#xA; L  c_u_x124_&#xA; L  c_u_x125_&#xA; L  c_u_x126_&#xA; L  c_u_x127_&#xA; L  c_u_x128_&#xA; L  c_u_x129_&#xA; L  c_u_x130_&#xA; L  c_u_x131_&#xA; L  c_u_x132_&#xA; L  c_u_x133_&#xA; L  c_u_x134_&#xA; L  c_u_x135_&#xA; L  c_u_x136_&#xA; L  c_u_x137_&#xA; L  c_u_x138_&#xA; L  c_u_x139_&#xA; L  c_u_x140_&#xA; L  c_u_x141_&#xA; L  c_u_x142_&#xA; L  c_u_x143_&#xA; L  c_u_x144_&#xA; L  c_u_x145_&#xA; L  c_u_x146_&#xA; L  c_u_x147_&#xA; L  c_u_x148_&#xA; L  c_u_x149_&#xA; L  c_u_x150_&#xA; L  c_u_x151_&#xA; L  c_u_x152_&#xA; L  c_u_x153_&#xA; L  c_u_x154_&#xA; L  c_u_x155_&#xA; L  c_u_x156_&#xA; L  c_u_x157_&#xA; L  c_u_x158_&#xA; L  c_u_x159_&#xA; L  c_u_x160_&#xA; L  c_u_x161_&#xA; L  c_u_x162_&#xA; L  c_u_x163_&#xA; L  c_u_x164_&#xA; L  c_u_x165_&#xA; L  c_u_x166_&#xA; L  c_u_x167_&#xA; L  c_u_x168_&#xA; L  c_u_x169_&#xA; L  c_u_x170_&#xA; L  c_u_x171_&#xA; L  c_u_x172_&#xA; L  c_u_x173_&#xA; L  c_u_x174_&#xA; L  c_u_x175_&#xA; L  c_u_x176_&#xA; L  c_u_x177_&#xA; L  c_u_x178_&#xA; L  c_u_x179_&#xA; L  c_u_x180_&#xA; L  c_u_x181_&#xA; L  c_u_x182_&#xA; L  c_u_x183_&#xA; G  c_l_x184_&#xA; G  c_l_x185_&#xA; G  c_l_x186_&#xA; G  c_l_x187_&#xA; G  c_l_x188_&#xA; G  c_l_x189_&#xA; G  c_l_x190_&#xA; G  c_l_x191_&#xA; L  c_u_x192_&#xA; L  c_u_x193_&#xA; L  c_u_x194_&#xA; L  c_u_x195_&#xA; E  c_e_ONE_VAR_CONSTANT&#xA;COLUMNS&#xA;    x12       OBJ       -100&#xA;    x12       c_u_x80_  1&#xA;    x12       c_l_x88_  1&#xA;    x12       c_e_x104_  1&#xA;    x12       c_u_x126_  100&#xA;    x13       OBJ       -200&#xA;    x13       c_u_x81_  1&#xA;    x13       c_l_x89_  1&#xA;    x13       c_e_x105_  1&#xA;    x13       c_u_x114_  100&#xA;    x13       c_u_x117_  -100&#xA;    x13       c_u_x126_  200&#xA;    x14       OBJ       -300&#xA;    x14       c_u_x82_  1&#xA;    x14       c_l_x90_  1&#xA;    x14       c_e_x106_  1&#xA;    x14       c_u_x114_  20&#xA;    x14       c_u_x117_  -20&#xA;    x14       c_u_x126_  300&#xA;    x15       OBJ       -400&#xA;    x15       c_u_x83_  1&#xA;    x15       c_l_x91_  1&#xA;    x15       c_e_x107_  1&#xA;    x15       c_u_x126_  400&#xA;    x16       OBJ       -70&#xA;    x16       c_u_x84_  1&#xA;    x16       c_l_x92_  1&#xA;    x16       c_e_x104_  1&#xA;    x16       c_u_x126_  70&#xA;    x17       OBJ       -140&#xA;    x17       c_u_x85_  1&#xA;    x17       c_l_x93_  1&#xA;    x17       c_e_x105_  1&#xA;    x17       c_u_x114_  100&#xA;    x17       c_u_x116_  -100&#xA;    x17       c_u_x126_  140&#xA;    x18       OBJ       -90&#xA;    x18       c_u_x86_  1&#xA;    x18       c_l_x94_  1&#xA;    x18       c_e_x106_  1&#xA;    x18       c_u_x114_  20&#xA;    x18       c_u_x115_  -20&#xA;    x18       c_u_x126_  90&#xA;    x19       OBJ       -90&#xA;    x19       c_u_x87_  1&#xA;    x19       c_l_x95_  1&#xA;    x19       c_e_x107_  1&#xA;    x19       c_u_x126_  90&#xA;    MARKER    'MARKER'                 'INTORG'&#xA;    x1        c_u_x80_  -100&#xA;    x1        c_u_x96_  1&#xA;    x1        c_u_x118_  2&#xA;    x1        c_u_x127_  -1000&#xA;    x1        c_u_x143_  1000&#xA;    x1        c_u_x151_  -1000&#xA;    x1        c_u_x167_  1000&#xA;    x2        c_u_x81_  -100&#xA;    x2        c_u_x97_  1&#xA;    x2        c_u_x110_  -1&#xA;    x2        c_u_x113_  1&#xA;    x2        c_u_x119_  2&#xA;    x2        c_u_x128_  -1000&#xA;    x2        c_u_x144_  1000&#xA;    x2        c_u_x152_  -1000&#xA;    x2        c_u_x168_  1000&#xA;    x3        c_u_x82_  -100&#xA;    x3        c_u_x98_  1&#xA;    x3        c_u_x110_  -1&#xA;    x3        c_u_x113_  1&#xA;    x3        c_u_x120_  15&#xA;    x3        c_u_x129_  -1000&#xA;    x3        c_u_x145_  1000&#xA;    x3        c_u_x153_  -1000&#xA;    x3        c_u_x169_  1000&#xA;    x4        c_u_x83_  -100&#xA;    x4        c_u_x99_  1&#xA;    x4        c_u_x121_  10&#xA;    x4        c_u_x130_  -1000&#xA;    x4        c_u_x146_  1000&#xA;    x4        c_u_x154_  -1000&#xA;    x4        c_u_x170_  1000&#xA;    x5        c_u_x84_  -50&#xA;    x5        c_u_x100_  1&#xA;    x5        c_u_x122_  1.4&#xA;    x5        c_u_x131_  -1000&#xA;    x5        c_u_x147_  1000&#xA;    x5        c_u_x155_  -1000&#xA;    x5        c_u_x171_  1000&#xA;    x6        c_u_x85_  -50&#xA;    x6        c_u_x101_  1&#xA;    x6        c_u_x109_  -1&#xA;    x6        c_u_x112_  1&#xA;    x6        c_u_x123_  1.4&#xA;    x6        c_u_x132_  -1000&#xA;    x6        c_u_x148_  1000&#xA;    x6        c_u_x156_  -1000&#xA;    x6        c_u_x172_  1000&#xA;    x7        c_u_x86_  -25&#xA;    x7        c_u_x102_  1&#xA;    x7        c_u_x108_  -1&#xA;    x7        c_u_x111_  1&#xA;    x7        c_u_x124_  4.5&#xA;    x7        c_u_x133_  -1000&#xA;    x7        c_u_x149_  1000&#xA;    x7        c_u_x157_  -1000&#xA;    x7        c_u_x173_  1000&#xA;    x8        c_u_x87_  -25&#xA;    x8        c_u_x103_  1&#xA;    x8        c_u_x125_  2.25&#xA;    x8        c_u_x134_  -1000&#xA;    x8        c_u_x150_  1000&#xA;    x8        c_u_x158_  -1000&#xA;    x8        c_u_x174_  1000&#xA;    x9        c_u_x108_  1&#xA;    x9        c_u_x111_  -2&#xA;    x9        c_u_x115_  1260&#xA;    x9        c_u_x175_  -1000&#xA;    x9        c_u_x181_  1000&#xA;    x10       c_u_x109_  1&#xA;    x10       c_u_x112_  -2&#xA;    x10       c_u_x116_  1260&#xA;    x10       c_u_x176_  -1000&#xA;    x10       c_u_x182_  1000&#xA;    x11       c_u_x110_  1&#xA;    x11       c_u_x113_  -2&#xA;    x11       c_u_x117_  1260&#xA;    x11       c_u_x177_  -1000&#xA;    x11       c_u_x183_  1000&#xA;    MARKER    'MARKER'                 'INTEND'&#xA;    x24       c_u_x118_  -1&#xA;    x24       c_u_x122_  -1&#xA;    x24       c_u_x126_  -2550&#xA;    x24       c_l_x184_  -50&#xA;    x24       c_l_x188_  -50&#xA;    x24       c_u_x192_  1&#xA;    x25       c_u_x119_  -1&#xA;    x25       c_u_x123_  -1&#xA;    x25       c_u_x126_  -5100&#xA;    x25       c_l_x185_  -100&#xA;    x25       c_l_x189_  -100&#xA;    x25       c_u_x193_  1&#xA;    x26       c_u_x120_  -1&#xA;    x26       c_u_x124_  -1&#xA;    x26       c_u_x126_  -1020&#xA;    x26       c_l_x186_  -20&#xA;    x26       c_l_x190_  -20&#xA;    x26       c_u_x194_  1&#xA;    x27       c_u_x121_  -1&#xA;    x27       c_u_x125_  -1&#xA;    x27       c_u_x126_  -2040&#xA;    x27       c_l_x187_  -40&#xA;    x27       c_l_x191_  -40&#xA;    x27       c_u_x195_  1&#xA;    x48       c_u_x126_  6072&#xA;    x48       c_l_x185_  100&#xA;    x48       c_l_x186_  20&#xA;    x48       c_l_x189_  100&#xA;    x48       c_l_x190_  20&#xA;    x60       c_u_x126_  100&#xA;    x60       c_u_x127_  1&#xA;    x60       c_u_x135_  1&#xA;    x60       c_u_x143_  -1&#xA;    x61       c_u_x126_  100&#xA;    x61       c_u_x128_  1&#xA;    x61       c_u_x136_  1&#xA;    x61       c_u_x144_  -1&#xA;    x62       c_u_x126_  100&#xA;    x62       c_u_x129_  1&#xA;    x62       c_u_x137_  1&#xA;    x62       c_u_x145_  -1&#xA;    x63       c_u_x126_  100&#xA;    x63       c_u_x130_  1&#xA;    x63       c_u_x138_  1&#xA;    x63       c_u_x146_  -1&#xA;    x64       c_u_x126_  50&#xA;    x64       c_u_x131_  1&#xA;    x64       c_u_x139_  1&#xA;    x64       c_u_x147_  -1&#xA;    x65       c_u_x126_  50&#xA;    x65       c_u_x132_  1&#xA;    x65       c_u_x140_  1&#xA;    x65       c_u_x148_  -1&#xA;    x66       c_u_x126_  25&#xA;    x66       c_u_x133_  1&#xA;    x66       c_u_x141_  1&#xA;    x66       c_u_x149_  -1&#xA;    x67       c_u_x126_  25&#xA;    x67       c_u_x134_  1&#xA;    x67       c_u_x142_  1&#xA;    x67       c_u_x150_  -1&#xA;    x76       c_u_x126_  -1260&#xA;    x76       c_u_x175_  1&#xA;    x76       c_u_x178_  1&#xA;    x76       c_u_x181_  -1&#xA;    x77       c_u_x126_  -1260&#xA;    x77       c_u_x176_  1&#xA;    x77       c_u_x179_  1&#xA;    x77       c_u_x182_  -1&#xA;    x78       c_u_x126_  -1260&#xA;    x78       c_u_x177_  1&#xA;    x78       c_u_x180_  1&#xA;    x78       c_u_x183_  -1&#xA;    x32       c_u_x135_  -1&#xA;    x32       c_u_x143_  1&#xA;    x32       c_l_x184_  1&#xA;    x33       c_u_x136_  -1&#xA;    x33       c_u_x144_  1&#xA;    x33       c_l_x185_  1&#xA;    x34       c_u_x137_  -1&#xA;    x34       c_u_x145_  1&#xA;    x34       c_l_x186_  1&#xA;    x35       c_u_x138_  -1&#xA;    x35       c_u_x146_  1&#xA;    x35       c_l_x187_  1&#xA;    x36       c_u_x139_  -1&#xA;    x36       c_u_x147_  1&#xA;    x36       c_l_x188_  1&#xA;    x37       c_u_x140_  -1&#xA;    x37       c_u_x148_  1&#xA;    x37       c_l_x189_  1&#xA;    x38       c_u_x141_  -1&#xA;    x38       c_u_x149_  1&#xA;    x38       c_l_x190_  1&#xA;    x39       c_u_x142_  -1&#xA;    x39       c_u_x150_  1&#xA;    x39       c_l_x191_  1&#xA;    x68       c_u_x151_  1&#xA;    x68       c_u_x159_  1&#xA;    x68       c_u_x167_  -1&#xA;    x69       c_u_x152_  1&#xA;    x69       c_u_x160_  1&#xA;    x69       c_u_x168_  -1&#xA;    x70       c_u_x153_  1&#xA;    x70       c_u_x161_  1&#xA;    x70       c_u_x169_  -1&#xA;    x71       c_u_x154_  1&#xA;    x71       c_u_x162_  1&#xA;    x71       c_u_x170_  -1&#xA;    x72       c_u_x155_  1&#xA;    x72       c_u_x163_  1&#xA;    x72       c_u_x171_  -1&#xA;    x73       c_u_x156_  1&#xA;    x73       c_u_x164_  1&#xA;    x73       c_u_x172_  -1&#xA;    x74       c_u_x157_  1&#xA;    x74       c_u_x165_  1&#xA;    x74       c_u_x173_  -1&#xA;    x75       c_u_x158_  1&#xA;    x75       c_u_x166_  1&#xA;    x75       c_u_x174_  -1&#xA;    x40       c_u_x159_  -1&#xA;    x40       c_u_x167_  1&#xA;    x40       c_l_x184_  -1&#xA;    x41       c_u_x160_  -1&#xA;    x41       c_u_x168_  1&#xA;    x41       c_l_x185_  -1&#xA;    x42       c_u_x161_  -1&#xA;    x42       c_u_x169_  1&#xA;    x42       c_l_x186_  -1&#xA;    x43       c_u_x162_  -1&#xA;    x43       c_u_x170_  1&#xA;    x43       c_l_x187_  -1&#xA;    x44       c_u_x163_  -1&#xA;    x44       c_u_x171_  1&#xA;    x44       c_l_x188_  -1&#xA;    x45       c_u_x164_  -1&#xA;    x45       c_u_x172_  1&#xA;    x45       c_l_x189_  -1&#xA;    x46       c_u_x165_  -1&#xA;    x46       c_u_x173_  1&#xA;    x46       c_l_x190_  -1&#xA;    x47       c_u_x166_  -1&#xA;    x47       c_u_x174_  1&#xA;    x47       c_l_x191_  -1&#xA;    x49       c_u_x178_  -1&#xA;    x49       c_u_x181_  1&#xA;    x49       c_l_x190_  -20&#xA;    x50       c_u_x179_  -1&#xA;    x50       c_u_x182_  1&#xA;    x50       c_l_x189_  -100&#xA;    x51       c_u_x180_  -1&#xA;    x51       c_u_x183_  1&#xA;    x51       c_l_x185_  -100&#xA;    x51       c_l_x186_  -20&#xA;    ONE_VAR_CONSTANT  c_e_ONE_VAR_CONSTANT  1&#xA;RHS&#xA;    RHS1      c_u_x96_  1&#xA;    RHS1      c_u_x97_  1&#xA;    RHS1      c_u_x98_  1&#xA;    RHS1      c_u_x99_  1&#xA;    RHS1      c_u_x100_  1&#xA;    RHS1      c_u_x101_  1&#xA;    RHS1      c_u_x102_  1&#xA;    RHS1      c_u_x103_  1&#xA;    RHS1      c_e_x104_  51&#xA;    RHS1      c_e_x105_  51&#xA;    RHS1      c_e_x106_  51&#xA;    RHS1      c_e_x107_  51&#xA;    RHS1      c_u_x114_  6072&#xA;    RHS1      c_u_x143_  1000&#xA;    RHS1      c_u_x144_  1000&#xA;    RHS1      c_u_x145_  1000&#xA;    RHS1      c_u_x146_  1000&#xA;    RHS1      c_u_x147_  1000&#xA;    RHS1      c_u_x148_  1000&#xA;    RHS1      c_u_x149_  1000&#xA;    RHS1      c_u_x150_  1000&#xA;    RHS1      c_u_x167_  1000&#xA;    RHS1      c_u_x168_  1000&#xA;    RHS1      c_u_x169_  1000&#xA;    RHS1      c_u_x170_  1000&#xA;    RHS1      c_u_x171_  1000&#xA;    RHS1      c_u_x172_  1000&#xA;    RHS1      c_u_x173_  1000&#xA;    RHS1      c_u_x174_  1000&#xA;    RHS1      c_u_x181_  1000&#xA;    RHS1      c_u_x182_  1000&#xA;    RHS1      c_u_x183_  1000&#xA;    RHS1      c_l_x184_  -100&#xA;    RHS1      c_l_x185_  -200&#xA;    RHS1      c_l_x186_  -300&#xA;    RHS1      c_l_x187_  -400&#xA;    RHS1      c_l_x188_  -70&#xA;    RHS1      c_l_x189_  -140&#xA;    RHS1      c_l_x190_  -90&#xA;    RHS1      c_l_x191_  -90&#xA;    RHS1      c_u_x192_  2&#xA;    RHS1      c_u_x193_  2&#xA;    RHS1      c_u_x194_  15&#xA;    RHS1      c_u_x195_  10&#xA;    RHS1      c_e_ONE_VAR_CONSTANT  1&#xA;BOUNDS&#xA; BV BND1      x1      &#xA; BV BND1      x2      &#xA; BV BND1      x3      &#xA; BV BND1      x4      &#xA; BV BND1      x5      &#xA; BV BND1      x6      &#xA; BV BND1      x7      &#xA; BV BND1      x8      &#xA; BV BND1      x9      &#xA; BV BND1      x10     &#xA; BV BND1      x11     &#xA; FR BND1      x24     &#xA; FR BND1      x25     &#xA; FR BND1      x26     &#xA; FR BND1      x27     &#xA;ENDATA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2:&lt;/strong&gt; I've been able to produce a second program with the same issue&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 3&lt;/strong&gt;: Using the *.lp (instead of *.mps) with stand alone cbc, I indeed obtain a similar result as Kuifje (problem is infeasible according to cbc). Might it be that the problem comes from pyomo?&lt;/p&gt;&#xA;" OwnerUserId="8723" LastEditorUserId="8723" LastEditDate="2022-02-11T19:04:21.093" LastActivityDate="2022-02-11T19:04:21.093" Title="Problem is infeasible with Gurobi, feasible with cbc (but can't access objective value)" Tags="|mixed-integer-programming|python|gurobi|pyomo|cbc|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7811" PostTypeId="2" ParentId="7810" CreationDate="2022-02-10T14:30:36.137" Score="10" Body="&lt;p&gt;If I read the lp file and try solving with CPLEX:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MHeZw.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MHeZw.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So I think your assumption is correct: the bug comes from CBC, as CPLEX and GUROBI both return infeasible. The CPLEX log also tells you which row is infeasible, you could try playing with the corresponding constraint. Maybe it is a tolerance issue (CBC, CPLEX and GUROBI may use different tolerances ?) ?&lt;/p&gt;&#xA;&lt;p&gt;You can also access the ISS:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZivmL.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZivmL.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is easy to see that the constraints imply :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;100 (\underbrace{x_{13}+x_{17}}_{=51}) + 20 (\underbrace{x_{14}+x_{18}}_{=51}) \le 6072 \quad &#xA;\Longrightarrow \quad 6120 \le 6072&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which indeed is not possible. So clearly there is a problem with CBC.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;ADDENDUM&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here is my log with CBC:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/H8o4y.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/H8o4y.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This version of CBC returns infeasible. Are you using the same version ?&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-02-10T14:54:33.030" LastActivityDate="2022-02-10T14:54:33.030" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7812" PostTypeId="1" AcceptedAnswerId="7834" CreationDate="2022-02-10T15:19:31.480" Score="0" ViewCount="185" Body="&lt;p&gt;I am working through the Udemy course &amp;quot;Optimizing Travelling Salesman and Vehicle Routing Problems&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;A part of the course is looking at Tabu search as a solution to the vehicle routing problem.&lt;/p&gt;&#xA;&lt;p&gt;I am wondering whether the last line of code below might be a mistake - i.e. it seems to say that if the best result from the most recent neighbourhood search is not in the Tabu list, then we get rid of it in favour of the best solution so far.  Should we not be doing the reverse?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Aspiration Criteria&#xA;    if len(Save_Solutions_Here) &amp;gt;= 1:&#xA;        if Solution_in_Hand in Tabu_List: # If the solution is already in the tabu list&#xA;            while Solution_in_Hand[0] in Tabu_List[:,0]: # The distance of the solution is the same as one in the tabu list&#xA;                if Solution_in_Hand[0] &amp;lt; Best_So_Far[0]: # If it is less, then...&#xA;                    Solution_in_Hand = Best_So_Far # It becomes best so far&#xA;                    break # Then break&#xA;                else:&#xA;                    Solution_in_Hand = OF_Values_all_N_Ordered[t] # If it wasn't less, the current solution becomes what was chosen in the list&#xA;                    t = t+1 # Add one to move to the next element&#xA;        else:&#xA;            Solution_in_Hand = Best_So_Far # If solution was not in tabu list, the best so far becomes the current solution*****&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Variables:&lt;/h2&gt;&#xA;&lt;p&gt;Save_Solutions_Here = saving the best solutions as the search iterates&lt;/p&gt;&#xA;&lt;p&gt;Best_So_Far = the best of the best solutions as the search iterates&lt;/p&gt;&#xA;&lt;p&gt;Solution_in_Hand = the best result from the current neighbourhood search&lt;/p&gt;&#xA;&lt;p&gt;OF_Values_all_N_Ordered[t] = the t-best result from the current neighbourhood search&lt;/p&gt;&#xA;&lt;p&gt;Tabu_List = the usual tabu list&lt;/p&gt;&#xA;" OwnerUserId="8901" LastEditorUserId="8901" LastEditDate="2022-02-14T01:06:17.837" LastActivityDate="2022-02-14T14:37:51.773" Title="Question re Tabu Search" Tags="|optimization|heuristics|metaheuristics|local-search|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7813" PostTypeId="1" AcceptedAnswerId="7820" CreationDate="2022-02-10T15:55:52.653" Score="6" ViewCount="546" Body="&lt;p&gt;The shortest path problem with resource constraints is a common subproblem when doing column generation. It is often solved with a labeling algorithm. The procedure is very well explained &lt;a href=&quot;https://link.springer.com/chapter/10.1007/0-387-25486-2_2&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://nabinkafle.medium.com/shortest-path-problem-with-resources-constraint-spprc-971ce9b9643e&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To avoid complete enumeration, dominance is crucial. To check if one label dominates another, their resources need to be compared. Hence one is potentially going to check a newly created label against a huge number of other labels. That would imply that having a data structure that stores the labels sequentially in memory to so going through them is efficient as one can benefit for prefetching. However, it would also be beneficial to have the labels stored according to one or more resource, because then one can possibly stop looking for a dominating label early and hence skip many dominance checks. Having them stored makes it necessary to have a data structure that makes random insertion possible and efficient. That does not fit well with having sequential memory. Also, since an unprocessed label might get dominated, it should also be possible and efficient to erase arbitrary labels from the data structure.&lt;/p&gt;&#xA;&lt;p&gt;Since reconstruction of the optimal path requires that a label store a pointer to the previous label, the pointers also need to stay valid when new labels are added and already existing labels being dominated and deleted.&lt;/p&gt;&#xA;&lt;p&gt;I realize that a perfect data structure for this is difficult(if not impossible) to make, but what do the state of the art implementations use when doing this?&lt;/p&gt;&#xA;&lt;p&gt;I use C++ for performance, so references and advice suitable for C++ are welcomed.&lt;/p&gt;&#xA;" OwnerUserId="9151" LastActivityDate="2022-02-10T17:26:24.947" Title="What kind of data structure should be used to store labels when implementing a labeling algorithm?" Tags="|column-generation|c++|dynamic-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7814" PostTypeId="2" ParentId="6069" CreationDate="2022-02-10T16:09:10.360" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;My question is how can I avoid this error? I do not really understand&#xA;what the problem is. I also tried to use the value() function but I&#xA;got an error telling me `NameError: name 'value' is not defined&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;As stated in several comments, it seems like you're making use of endogenous &lt;code&gt;if&lt;/code&gt; statements. On the other hand, if you need an exegenous &lt;code&gt;if&lt;/code&gt; statement reliying on the value of an expression (after having solved a model for example), don't forget to&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;from pyomo.environ import value&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="8723" LastActivityDate="2022-02-10T16:09:10.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7815" PostTypeId="2" ParentId="7813" CreationDate="2022-02-10T16:29:45.737" Score="1" Body="&lt;p&gt;I can't speak to &amp;quot;state of the art implementations&amp;quot;, but I would store the labels in lexicographic order of resource levels. Let's say vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is our new label and we want to see if it is dominated by any existing label &lt;span class=&quot;math-container&quot;&gt;$y^{(1)} \prec y^{(2)} \prec \dots \prec y^{(n)},$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\prec$&lt;/span&gt; means &amp;quot;lexically less than&amp;quot; and, for dominance purposes, smaller is better. We compare &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$y^{(1)}_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i = 1, 2, \dots$&lt;/span&gt; until either we find an &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_i &amp;lt; y^{(1)}_i$&lt;/span&gt; or discover that &lt;span class=&quot;math-container&quot;&gt;$y^{(1)}$&lt;/span&gt; dominates &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; (in which case we are done). Assuming &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is not dominated by &lt;span class=&quot;math-container&quot;&gt;$y^{(1)}$&lt;/span&gt;, we move on to &lt;span class=&quot;math-container&quot;&gt;$y^{(2)}$&lt;/span&gt; and repeat the process. If we reach the point where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; would fit in lexicographic sort order, we know &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is not dominated, and we scan the remaining labels to see if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; dominates any of them.&lt;/p&gt;&#xA;&lt;p&gt;As far as how to implement this, I use Java, not C++. In Java, I would define a comparator to implement &lt;span class=&quot;math-container&quot;&gt;$\prec$&lt;/span&gt; and use a TreeSet based on that comparator. I suspect C++ has similar critters.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-10T16:29:45.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7816" PostTypeId="2" ParentId="6008" CreationDate="2022-02-10T16:37:04.003" Score="2" Body="&lt;p&gt;You should make use of sets. One way of doing it would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = ConcreteModel()&#xA;&#xA;# set&#xA;model.MNset = Set(initialize = [j for j in range(M*N))]) # j = M*(i-1) + k&#xA;&#xA;# variables&#xA;model.W = Var(model.MNset, domain=Reals)&#xA;model.G = Var(model.MNset, domain=Reals)&#xA;&#xA;# constraints&#xA;def WG_constraint_upper(m,j):&#xA;   i = floor(j/M)+1&#xA;   if tt + j*delta_t &amp;lt;= dd[i]:&#xA;      return m.W[j] + m.G[j] &amp;lt;= 0&#xA;   else :&#xA;      return m.W[j] + m.G[j] &amp;lt;= mm[i]*delta_t&#xA;&#xA;def WG_constraint_lower(m,j):&#xA;  return m.W[j] + m.G[j] &amp;gt;= 0&#xA;&#xA;model.WG_constraint_upper = Constraint(model.MNset,rule = WG_constraint_upper)&#xA;model.WG_constraint_lower = Constraint(model.MNset,rule = WG_constraint_lower )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Another way would be to define a two dimensional &lt;code&gt;MNset&lt;/code&gt; so you would directly access &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I also suggest you take a look at &lt;a href=&quot;https://www.ima.umn.edu/materials/2017-2018.2/W8.21-25.17/26326/3_PyomoFundamentals.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo Fundamentals&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8723" LastEditorUserId="8723" LastEditDate="2022-02-10T16:42:25.930" LastActivityDate="2022-02-10T16:42:25.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7817" PostTypeId="1" CreationDate="2022-02-10T17:00:00.487" Score="8" ViewCount="1423" Body="&lt;p&gt;In the famous &amp;quot;Problem of Apollonius&amp;quot; (&lt;a href=&quot;https://en.wikipedia.org/wiki/Problem_of_Apollonius&quot; rel=&quot;noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Problem_of_Apollonius&lt;/a&gt;), the goal is to &lt;strong&gt;draw three circles that are tangential to another circle&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ufpUG.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ufpUG.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Algebraically, we can write this problem as a system of equations:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$(x_s-x_1)^2+(y_s-y_1)^2=(r_s-s_1 r_1)^2$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(x_s-x_2)^2+(y_s-y_2)^2=(r_s-s_2 r_2)^2$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(x_s-x_3)^2+(y_s-y_3)^2=(r_s-s_3 r_3)^2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt;  Can we consider this above problem as a &amp;quot;constraint optimization problem&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;For instance, from the above equations:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;we want to find out values of &amp;quot;x1, y1, s1, r1, x2, y2, s2, r2, x3, y3, s3, r3&amp;quot;&lt;/li&gt;&#xA;&lt;li&gt;such that all &amp;quot;black circles&amp;quot; intersect with the &amp;quot;purple circle&amp;quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Thus: we could make a objective function&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;that takes inputs &amp;quot;x1, y1, s1, r1, x2, y2, s2, r2, x3, y3, s3, r3&amp;quot;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and that outputs a number between &amp;quot;0 and 1&amp;quot; corresponding to the proportion of &amp;quot;black circles&amp;quot; are tangential to the &amp;quot;purple circle&amp;quot; (e.g. 0, 0.33, 0.66, 0.99)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Thus, we could use some Optimization Algorithm such as the Genetic Algorithm for trying to generate &amp;quot;feasible combinations&amp;quot; of &amp;quot;x1, y1, s1, r1, x2, y2, s2, r2, x3, y3, s3, r3&amp;quot; such that &amp;quot;the proportion of black circles tangential to the purple circle&amp;quot; are optimized (hoping that we eventually get a value of 0.99, signifying that the Problem of Apollonius is solved).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is this correct?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; Does anyone know why the &amp;quot;Problem of Apollonius&amp;quot; was considered to be so difficult? Was the original objective of this problem to prove that circles can be drawn this way? Or was the original objective of this problem to prove that this can be done for more than 3 circles?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-10T20:37:48.677" LastActivityDate="2022-02-11T10:25:12.513" Title="Can the (famous) &quot;Problem of Apollonius&quot; be Considered as a &quot;Constraint Optimization&quot; Problem?" Tags="|optimization|constraint|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7818" PostTypeId="1" CreationDate="2022-02-10T17:25:30.750" Score="2" ViewCount="349" Body="&lt;p&gt;I have heard of a famous problem called the &amp;quot;&lt;strong&gt;Wolf, Goat, and Cabbage Riddle&lt;/strong&gt;&amp;quot; :(&lt;a href=&quot;https://en.wikipedia.org/wiki/Wolf,_goat_and_cabbage_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Wolf,_goat_and_cabbage_problem&lt;/a&gt;):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Gk9Io.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Gk9Io.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&amp;quot;Once upon a time a farmer went to a market and purchased a wolf, a goat, and a cabbage. On his way home, the farmer came to the bank of a river and rented a boat. But crossing the river by boat, the farmer could carry only himself and a single one of his purchases: the wolf, the goat, or the cabbage. If left unattended together, the wolf would eat the goat, or the goat would eat the cabbage. The farmer's challenge was to carry himself and his purchases to the far bank of the river, leaving each purchase intact. How did he do it?&amp;quot;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have informally heard that this riddle can be seen as an optimization problem as it can be interpreted as a discrete optimization problem with integer constraints (i.e. certain combinations of items can not be left together). I have also heard that this riddle can appear in real life when there are thousands of objects and thousands of constraints (&lt;strong&gt;but I am not sure about this&lt;/strong&gt;). It would be interesting to hear comments about this.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3NxL1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3NxL1.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; Does this &amp;quot;Wolf, Goat and Cabbage Riddle&amp;quot; have any relation to &amp;quot;Monge's Optimal Transport Problem&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;I am still trying to understand &amp;quot;Monge's Optimal Transport Problem&amp;quot; but in a general sense, it seems like this is related to the &amp;quot;Assignment Problem&amp;quot; seeking  the &amp;quot;cheapest and fastest&amp;quot; way to transport items from one location to another location.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LfTl4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LfTl4.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is there any relationship between the &amp;quot;Wolf, Goat and Cabbage Riddle&amp;quot; and &amp;quot;Monge's Optimal Transport Problem&amp;quot;? Does (a more complex version of) the &amp;quot;Wolf, Goat and Cabbage Riddle&amp;quot; ever come up in real world Optimization Problems (e.g. scheduling and transportation)?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-03-13T23:09:51.273" LastActivityDate="2022-03-13T23:09:51.273" Title="&quot;Wolf, Goat, and Cabbage Riddle&quot; as an Optimization Problem" Tags="|optimization|combinatorial-optimization|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7819" PostTypeId="2" ParentId="7817" CreationDate="2022-02-10T17:25:36.310" Score="18" Body="&lt;p&gt;You have the inputs and outputs confused.  The three black circles are given, and the purple circle is a desired output.&lt;/p&gt;&#xA;&lt;p&gt;But, yes, any system of equations can be thought of as an optimization problem with a constant zero objective.&lt;/p&gt;&#xA;&lt;p&gt;Another common approach is to modify the constraints by introducing nonnegative surplus and slack variables and then minimize their sum.  If the resulting minimum is 0, you have a feasible solution to the original constraints.  Otherwise, the problem is infeasible.  In the two-phase simplex method for LP, this is Phase I.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-02-10T17:25:36.310" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7820" PostTypeId="2" ParentId="7813" CreationDate="2022-02-10T17:26:24.947" Score="3" Body="&lt;p&gt;I have experience in writing the code implementing the labelling algorithm used by VRPSolver (&lt;a href=&quot;https://vrpsolver.math.u-bordeaux.fr&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vrpsolver.math.u-bordeaux.fr&lt;/a&gt;). You are right: it is advantageous to keep labels in a contiguous memory to benefit from using the cache. We keep labels in vectors (we called them &amp;quot;buckets&amp;quot;). There should be no dynamic data structures (pointers) inside labels. As suggested by @prubin, labels in a bucket are sorted by a resource consumption (in our case, by cost). When you want to insert a new label to a bucket, you start dominances checks from the first element and continue until you find that the new label is dominated or until you find the right place for it. In the latter case, you insert the label and you shift the remaining labels one by one in the memory while verifying at the same time whether they are dominated by the new label. You may potentially do many label copies while doing that, but copying labels is not expensive. The complexity of the algorithm does not change from such copies, as you need to check every label for dominance anyway.&lt;/p&gt;&#xA;&lt;p&gt;We do not keep pointers to previous labels as they may be displaced in the memory. Instead we keep the ID of the bucket where the previous label is stored and the ID of the label in it. So, retrieving the path from a label is more expensive than when you keep pointers to previous labels. But anyway, the time to retrieve the paths is largely dominated by the running time of the labelling algorithm itself.&lt;/p&gt;&#xA;&lt;p&gt;The bucket structure of the labelling algorithm is described in this paper: &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.2020.0985&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pubsonline.informs.org/doi/abs/10.1287/trsc.2020.0985&lt;/a&gt;. Unfortunately, it is not common in our community to present implementation details in papers. As you can see, sometimes such details are useful.&lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2022-02-10T17:26:24.947" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7821" PostTypeId="1" CreationDate="2022-02-10T17:46:29.313" Score="2" ViewCount="473" Body="&lt;p&gt;I was reading the following Wikipedia Article on &amp;quot;Assignment Problems&amp;quot; that talks about the relationship between &lt;strong&gt;Assignment Problems&lt;/strong&gt; and &lt;strong&gt;Graph Theory&lt;/strong&gt; (&lt;a href=&quot;https://en.wikipedia.org/wiki/Assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Assignment_problem&lt;/a&gt;) :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;The assignment problem is a fundamental combinatorial optimization problem. In its most general form, the problem is as follows:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;The problem instance has a number of agents and a number of tasks. Any agent can be assigned to perform any task, incurring some cost that may vary depending on the agent-task assignment. It is required to perform as many tasks as possible by assigning at most one agent to each task and at most one task to each agent, in such a way that the total cost of the assignment is minimized.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;Alternatively, describing the problem using graph theory:&#xA;The assignment problem consists of finding, in a weighted bipartite graph, a matching of a given size, in which the sum of weights of the edges is minimum.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I am familiar with both of these concepts individually, but I do not understand why these concepts are related:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1) Assignment Problems&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assignment Problems - as the name implies - are usually about determining an &amp;quot;optimal assignment of tasks to agents&amp;quot;. For example, suppose there are 4 Workers (Worker A, Worker B, Worker C, Worker D) and 4 Jobs (Job A, Job B, Job C, Job D). Each worker has a &amp;quot;certain cost&amp;quot; associated with performing each of these jobs (e.g. Worker A performs Job B better than Worker D, but Worker D performs Job D better than Worker A). The Assignment Problem involves &amp;quot;assigning&amp;quot; only one job to each worker such that the total cost is minimized:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NVXCY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NVXCY.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;2) Weighted Bipartite Graphs&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;A Bipartite Graph is a Graph in which all &amp;quot;Nodes&amp;quot; within the Graph (i.e. circles) either belong to one of two sets (e.g. red and blue). A Weighted Bipartite Graph is a Bipartite Graph in which each &amp;quot;Edge&amp;quot; has a certain cost associated with it:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gb7iI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gb7iI.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; The formal definition of a general Assignment Problem is seen below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0gROB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0gROB.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thus, can someone please explain why &amp;quot;&lt;strong&gt;the assignment problem consists of finding, in a weighted bipartite graph, a matching of a given size, in which the sum of weights of the edges is minimum&amp;quot;&lt;/strong&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-10T20:39:11.390" LastActivityDate="2022-02-10T20:39:11.390" Title="Relationship Between &quot;Assignment Problems&quot; and &quot;Graphs&quot;" Tags="|optimization|combinatorial-optimization|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7822" PostTypeId="1" CreationDate="2022-02-11T06:45:51.247" Score="8" ViewCount="1438" Body="&lt;p&gt;A situation that we are all familiar with : &lt;strong&gt;How do you decide which order to place groceries in your car or which order to place food in your fridge?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ASZ2F.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ASZ2F.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;At first glance, it appears that the &amp;quot;order&amp;quot; in which you place items might be important. For instance, if you first place a small item and then place a large item on top of the small item, it will likely be a very awkward fit and result in the smaller item being damaged (e.g. a bag of flour on top of a carton of eggs). Thus, it would seemingly make more sense to first place the bigger object and then place the smaller object on top of the bigger object. Especially for many grocery items, it would appear that &lt;strong&gt;some orderings might be more optimal compared to other orderings.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Using this framework, can we interpret the order in which you place groceries into your car or food item into a fridge as an optimization problem?&lt;/strong&gt;  I am not sure, but this looks like some type of combinatorial optimization problem that shares aspects with the &amp;quot;Knapsack Optimization Problem&amp;quot;, &amp;quot;Optimal Transport Optimization Problem&amp;quot; and &amp;quot;Traveling Salesman Problem&amp;quot; (e.g. which ordering would require lesser steps in terms of reordering items).&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-11T12:57:17.843" LastActivityDate="2022-02-11T16:31:10.707" Title="Order in which you Stack Groceries in your Car's Trunk : An Optimization Problem?" Tags="|optimization|combinatorial-optimization|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="7823" PostTypeId="1" CreationDate="2022-02-11T07:40:13.120" Score="4" ViewCount="201" Body="&lt;p&gt;I am trying to better understand the origins of Optimal Transport Problems such as &lt;strong&gt;Monge's Problem.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For instance, I came across the following references:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.math.ucdavis.edu/%7Eqlxia/Research/monge.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.math.ucdavis.edu/~qlxia/Research/monge.pdf&lt;/a&gt; , &lt;a href=&quot;https://www.youtube.com/watch?v=aio1lAE-h_I&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=aio1lAE-h_I&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EBGN2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EBGN2.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In these problems, the objective is to find the &amp;quot;most optimal way to move sand from one location to another&amp;quot;. I am trying to better understand where the original problem occurred. For instance, in the very basic set up, it would seem that moving larger amounts of sand would be faster but more difficult (e.g. lifting heavier loads of sand), and moving smaller amounts of sand would be slower but easier. At first glance, there does not seem to be a &amp;quot;real optimal transport order&amp;quot; but rather a proportional tradeoff. It depends more on how quickly and how much weight you are ready to lift.&lt;/p&gt;&#xA;&lt;p&gt;I can try to think of this problem conceptually. For example, suppose there is a central bakery that produces different types of cakes and it delivers these different cakes to different stores. Each type of cake has a cost to make, and each store has a different demand for different types of cakes, and the cost to deliver cakes depends on the location of the stores relative to the bakery. Thus, when the central bakery has to make multiple trips (e.g. a truck can only carry a certain number of cakes each time) to deliver multiple cakes to multiple bakeries, I can see that there might be &lt;strong&gt;&amp;quot;more optimal ways to transport the cakes to different bakeries&amp;quot;&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But in the case of Monge's Problem (or Kantorovich), I am trying to better understand the initial problem. I found plenty of references online, but all of these references are far too detailed in terms of the level of theoretical mathematics that they use (e.g. &lt;a href=&quot;https://arxiv.org/pdf/1701.02826.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/1701.02826.pdf&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Can anyone please try to explain the objective functions that need to be optimized in Monge's/Kantorovich's Problem, or perhaps recommend references to sources that are less mathematically intensive?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="36" LastEditDate="2022-03-06T17:58:47.873" LastActivityDate="2022-03-06T17:58:47.873" Title="Understanding Optimal Transport Problems" Tags="|optimization|reference-request|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7824" PostTypeId="2" ParentId="7817" CreationDate="2022-02-11T10:25:12.513" Score="5" Body="&lt;p&gt;Since I can't comment due to lack of reputation, here's an a note in response to your comment on RobPratt's answer: The difficulty is not so much in managing to draw something close to the desired circle in practice, but rather in the mathematical construction (using only straightedge and compass!).&lt;/p&gt;&#xA;&lt;p&gt;This turns out to have some interesting mathematical implications - cf. e.g. doubling the square, doubling the cube (&lt;a href=&quot;https://en.wikipedia.org/wiki/Doubling_the_cube&quot; rel=&quot;noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Doubling_the_cube&lt;/a&gt;), squaring the circle (&lt;a href=&quot;https://en.wikipedia.org/wiki/Squaring_the_circle&quot; rel=&quot;noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Squaring_the_circle&lt;/a&gt;), ...&lt;/p&gt;&#xA;&lt;p&gt;Note also that approximating a solution with Paint is not the same as determining a mechanism to obtain the new circle's midpoint and radius from the given ones.&lt;/p&gt;&#xA;" OwnerUserId="9159" LastActivityDate="2022-02-11T10:25:12.513" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7825" PostTypeId="2" ParentId="7822" CreationDate="2022-02-11T11:59:16.300" Score="10" Body="&lt;p&gt;Three-dimensional packing is a well studied class of problems. One of the main applications is indeed truck loading. See this review which lists the different kinds of constraints considered:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bortfeldt A, Wäscher G (2013) Constraints in container loading – A state-of-the-art review. European Journal of Operational Research 229:1–20. &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2012.12.006&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1016/j.ejor.2012.12.006&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-02-11T11:59:16.300" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7826" PostTypeId="2" ParentId="7822" CreationDate="2022-02-11T15:12:43.817" Score="6" Body="&lt;p&gt;The 3D bin packing problem is very important in &lt;a href=&quot;https://en.wikipedia.org/wiki/3D_printing&quot; rel=&quot;noreferrer&quot;&gt;additive manufacturing&lt;/a&gt;. Many researchers approach this problem as an optimization problem.&lt;/p&gt;&#xA;&lt;p&gt;So yes, &lt;strong&gt;you can approach your stated problem as an optimization problem&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;A few relevant papers including a 2020 survey below.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1016/j.addma.2020.101492&quot; rel=&quot;noreferrer&quot;&gt;Nesting and scheduling problems for additive manufacturing: A taxonomy and review&lt;/a&gt;. 2020. &lt;em&gt;Additive Manufacturing&lt;/em&gt;, Vol 36. Y. Oh, P. Witherell, Y. Lu, &amp;amp; T. Sprock.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://doi.org/10.1080/00207543.2018.1534016&quot; rel=&quot;noreferrer&quot;&gt;Analysis of irregular three-dimensional packing problems in additive manufacturing: a new taxonomy and dataset&lt;/a&gt;. 2017.&#xA;&lt;em&gt;International Journal of Production Research&lt;/em&gt;, Vol 57, No 18, 5920–5934. L. Araujo, E. Ozcan, J. Atkin, &amp;amp; M. Baumers.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Some interesting pictures of the problem:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Multi-objective Optimization of 3D Packing Problem in Additive Manufacturing. 2014. &lt;em&gt;IIE Annual Conference Proceedings&lt;/em&gt;, 1485–1494. Wu, S.; Kay, M.; King, R.; Vila-Parrish, A.; Warsing, D.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;sub&gt;&lt;sub&gt;I am not one of the authors.&lt;/sub&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2022-02-11T15:59:29.020" LastActivityDate="2022-02-11T15:59:29.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7828" PostTypeId="2" ParentId="7822" CreationDate="2022-02-11T16:31:10.707" Score="5" Body="&lt;p&gt;In addition to the size and weight considerations, there may also be &amp;quot;order of access&amp;quot; constraints. When shoving groceries in my refrigerator, I tend to use an informal LIFO ordering, which saves me having to pull a bunch of stuff out when accessing something near the back. This also comes up when loading delivery trucks (postal service, Amazon, ...), where you give the driver an ordered list of deliveries and want the boxes being delivered to be accessible in order of delivery.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-11T16:31:10.707" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7829" PostTypeId="2" ParentId="7784" CreationDate="2022-02-13T09:46:03.140" Score="3" Body="&lt;p&gt;I think regularization is a kind of constrained optimization problem. Of course, in LASSO they eliminate l-1 constraint term and get some equivalent Lagrangian objective formulation. But the nature of enforcing &lt;em&gt;sparsity&lt;/em&gt; is putting some l-1, l-2 norm constraints (and move them up to objective term)&lt;/p&gt;&#xA;&lt;p&gt;So in LASSO, concepts used in constrained optimization - (Fenchel) Duality, Proximal gradient, etc. are important.&#xA;I highly recommend this amazing book.&lt;/p&gt;&#xA;&lt;p&gt;(Statistical Learning with Sparsity)&#xA;&lt;a href=&quot;https://hastie.su.domains/StatLearnSparsity_files/SLS.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://hastie.su.domains/StatLearnSparsity_files/SLS.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;For more optimization-oriented paper, this is great.&lt;/p&gt;&#xA;&lt;p&gt;(Optimization with Sparsity-Inducing Penalties)&#xA;&lt;a href=&quot;https://arxiv.org/abs/1108.0775&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/1108.0775&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4130" LastActivityDate="2022-02-13T09:46:03.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7830" PostTypeId="1" CreationDate="2022-02-13T16:12:09.313" Score="2" ViewCount="66" Body="&lt;p&gt;In &lt;a href=&quot;https://epubs.siam.org/doi/abs/10.1137/110839072?casa_token=vUpJFGKvqjcAAAAA:qI5sdpK3YYgx47o_3cytwteA-Ncr-Qctvn9mAdMBiifGQHu2Hy2BdXp-5J1p71lB9cvJHRMOhwT9&quot; rel=&quot;nofollow noreferrer&quot;&gt;this SIAM Review paper&lt;/a&gt; the authors are giving the following necessary condition for a point being a local maximum of a convex function:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$F: \mathbb{R}^n \mapsto \mathbb{R}$&lt;/span&gt; be convex. If &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a local maximum of &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; over the nonempty compact set &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, then&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\tag{FOC}&#xA;\langle v - x, F'(x)\rangle \leq 0 \quad \forall v \in C.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Moreover, the authors state that if &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is continuously differentiable, then any &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; satisfying the above first-order condition will be referred to as a &lt;em&gt;stationary point&lt;/em&gt;, and otherwise &lt;em&gt;a point that satisfies the first-order condition&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What I do not understand is, what changes when a point is called a stationary point? It is still not guaranteed to be a local max, right? So what really changes when a point that satisfies the first-order conditions becomes a stationary point? What additional benefits do we get? (I am assuming this will be relevant when we analyze the convergence of the Frank-Wolfe algorithm or whatever we are using to find a local maximum, but I don't understand what changes with a point being &lt;em&gt;stationary&lt;/em&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2022-02-13T16:23:59.947" LastActivityDate="2022-02-13T16:23:59.947" Title="FOC point vs Stationary point in local optimization" Tags="|nonconvex-programming|convexity|optimality-conditions|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7831" PostTypeId="1" CreationDate="2022-02-14T00:29:55.547" Score="5" ViewCount="843" Body="&lt;p&gt;I have been trying to learn more about the Simplex Algorithm/Method. In particular, &lt;strong&gt;I am interested in knowing why this algorithm is called the &amp;quot;Simplex Algorithm&amp;quot;.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For instance, when reading the Wikipedia Page (&lt;a href=&quot;https://en.wikipedia.org/wiki/Simplex_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Simplex_algorithm&lt;/a&gt;) : &lt;em&gt;&amp;quot;The name of the algorithm is derived from the concept of a simplex and was suggested by T. S. Motzkin. Simplices are not actually used in the method, but one interpretation of it is that it operates on simplicial cones, and these become proper simplices with an additional constraint. The simplicial cones in question are the corners (i.e., the neighborhoods of the vertices) of a geometric object called a polytope. The shape of this polytope is defined by the constraints applied to the objective function.&amp;quot;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is a bit confusing for me to understand. Here is what I thought the reason is:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;A &amp;quot;simplex&amp;quot; is a &amp;quot;triangular shaped polygon.&amp;quot; Several &amp;quot;simplices&amp;quot; can be combined together to make unique shapes. These are called &amp;quot;simplicial complexes&amp;quot;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In Linear Programming problems, the objective functions and their constraints form irregular shapes (i.e. a combination of overlapping planes). However, due to the linear nature of these functions and constraints, the resulting shapes will have distinct vertices.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Thus, the system of objective functions and constraints from a Linear Programming problem form a &amp;quot;simplicial complex.&amp;quot;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In Linear Programming problems, we are interested in optimizing the objective functions relative to some constraints since the system of equations and constraint form a &amp;quot;simplicial complex,&amp;quot; we could say that we are interested in optimizing a simplicial complex .&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As a result, the algorithm used for optimizing the simplicial complex is called the &amp;quot;Simplex Algorithm&amp;quot;. This algorithm (strategically) &amp;quot;walks around&amp;quot; the vertices of the simplicial complex (corresponding to the system of linear equations and constraints) until it finds the vertex located at the lowest elevation point.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; Can someone please help me understand if I have correctly understood why the Simplex Algorithm is called the &amp;quot;Simplex Algorithm?&amp;quot;&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-14T14:16:40.290" LastActivityDate="2023-05-15T07:55:58.643" Title="Why is it called the &quot;Simplex&quot; Algorithm/Method?" Tags="|optimization|linear-programming|simplex|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7832" PostTypeId="1" CreationDate="2022-02-14T00:56:03.723" Score="10" ViewCount="540" Body="&lt;p&gt;I have heard that Linear Programming was first used by:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Dantzig to solve problems involving US military logistics in the Second World War&lt;/li&gt;&#xA;&lt;li&gt;Kantorovich to solve problems involving transportation of goods and soldiers in the Second World War&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I am trying to find more information about the exact circumstances of these problems. &lt;strong&gt;For instance, are there any references that show the exact objective functions and the exact constraints that were involved in these optimization problems?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would be really interested to see something which showed the equations for the objective functions and the constraints with exact numbers involved in these original problems. I have searched for this online (e.g. &lt;a href=&quot;http://www.math.toronto.edu/mccann/assignments/477/Kantorovich42.pdf&quot; rel=&quot;noreferrer&quot;&gt;http://www.math.toronto.edu/mccann/assignments/477/Kantorovich42.pdf&lt;/a&gt;, &lt;a href=&quot;https://dl.acm.org/doi/10.1145/87252.88081&quot; rel=&quot;noreferrer&quot;&gt;https://dl.acm.org/doi/10.1145/87252.88081&lt;/a&gt;), but I can't seem to find anything which provides these kinds of details.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Can someone please recommend a reference where these kinds of details are provided for the first Linear Programming problems?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="500" LastEditDate="2022-02-14T02:33:40.283" LastActivityDate="2022-03-12T21:38:35.037" Title="The First Ever Linear Programming Problems" Tags="|optimization|linear-programming|reference-request|history|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7833" PostTypeId="1" CreationDate="2022-02-14T06:58:33.067" Score="0" ViewCount="169" Body="&lt;p&gt;I have the following objective function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \min_{I_{i,v}} \ \sum^{N_v}_{v}\sum^{TT_v}_{i} \ C_{loss,cyc}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TYFbS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TYFbS.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$I_{i,v}$&lt;/span&gt; is the only positive decision variable. &lt;span class=&quot;math-container&quot;&gt;$SOC_{init}$&lt;/span&gt; is a function of &lt;span class=&quot;math-container&quot;&gt;$I_{i,v}$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$SOC_{init}$&lt;/span&gt; is equivalent to &lt;span class=&quot;math-container&quot;&gt;$SOC_{avgi,v}$&lt;/span&gt; given in the equality constraint below. Other variables are positive constants except  a = -4.092*(10^-4), b = -2.167. c = 1.408*(10^-5), d = 6.130.&lt;/p&gt;&#xA;&lt;p&gt;The plot of the objective function is shown below: y is &lt;span class=&quot;math-container&quot;&gt;$I_{i,v}$&lt;/span&gt; and x is &lt;span class=&quot;math-container&quot;&gt;$SOC_{init}$&lt;/span&gt;. The objective function value, &lt;span class=&quot;math-container&quot;&gt;$ C_{loss,cyc}$&lt;/span&gt;  is z.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kRGkg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kRGkg.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;We are minimizing a concave objective (continuous surface).&lt;/p&gt;&#xA;&lt;p&gt;The constraints are given below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/r8LOL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/r8LOL.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JGrHW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JGrHW.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ I_{max}, I_{c,max}, T^{dep}_{v},t_s,  SOC^{dep}_{v}, SOC_{-1,v}, SOC_{xtra} $&lt;/span&gt; are positive constants. please ignore &lt;span class=&quot;math-container&quot;&gt;$SOC_{devi,v}$&lt;/span&gt;, it is for state updating during optimization implementation. How can I know if these constraints are convex?&lt;/p&gt;&#xA;&lt;p&gt;I am new to convex optimization. First off all, is this a convex optimization problem as there is only a single maximum point but we are minimizing this concave objective? or is it a non-convex optimization problem. I thought non-convex problems have local minimums/maximums.&lt;/p&gt;&#xA;&lt;p&gt;What are the current algorithms that will search for a solution with an objective of this form with sum of exponentials that are functions of a first order term (and with first order term multiplying one exponential term) then all of that multiplying a first order term?&lt;/p&gt;&#xA;&lt;p&gt;Should I read convex optimization book by Boyd and Vaderberghe to get a deep understanding of the problem? Or is there any online material I can read and get by. I already know the idea of piecewise polynomial functions. Should I read about quadratic programming? I have tried 2 pieces of 2nd order polynomials to estimate this surface in Gurobi but even then what algorithms or analytical techniques are used to find the minimum? But what if I want to keep it as accurate as possible by using this exact objective function? What are the analytical techniques then?&lt;/p&gt;&#xA;&lt;p&gt;Basically, I want to have a algorithm/technique so that I know what is happening when the solution is found. Then I will be able to compare this theoretical solution and Gurobi output.&lt;/p&gt;&#xA;" OwnerUserId="4945" LastEditorUserId="4945" LastEditDate="2022-02-17T07:47:59.310" LastActivityDate="2022-02-17T21:03:54.613" Title="Algorithms and analytical solution methods/tools to solve an optimization problem for a particular objective function" Tags="|gurobi|nonlinear-programming|algorithms|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7834" PostTypeId="2" ParentId="7812" CreationDate="2022-02-14T14:37:51.773" Score="2" Body="&lt;p&gt;Your doubt is right: you should NOT go back to your best solution if the current solution is not in the tabu list. You should invert the if statement and see if the tabu search leads to better solutions. A nice summary including tips for the design of a tabu search is available here:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Gendreau, M. (2003). An Introduction to Tabu Search. In F. Glover &amp;amp; G.&#xA;A. Kochenberger (Reds), Handbook of Metaheuristics (bll 37–54).&#xA;doi:10.1007/0-306-48056-5_2&#xA;&lt;a href=&quot;https://nats-www.informatik.uni-hamburg.de/pub/WS2020/HinweiseZurSeminararbeit/Gendreau-Potvin2019_Chapter_TabuSearch.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://nats-www.informatik.uni-hamburg.de/pub/WS2020/HinweiseZurSeminararbeit/Gendreau-Potvin2019_Chapter_TabuSearch.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2022-02-14T14:37:51.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7835" PostTypeId="1" AcceptedAnswerId="7837" CreationDate="2022-02-14T21:59:35.420" Score="1" ViewCount="260" Body="&lt;p&gt;I would like to use the Weighted Sum Method (Multi Criteria Decision Making) in R in this database below. The resolution of the issue is here: &lt;a href=&quot;https://www.geeksforgeeks.org/weighted-sum-method-multi-criteria-decision-making/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.geeksforgeeks.org/weighted-sum-method-multi-criteria-decision-making/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I tried using something similar as done here: &lt;a href=&quot;https://rdrr.io/cran/MCDA/man/weightedSum.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://rdrr.io/cran/MCDA/man/weightedSum.html&lt;/a&gt;, however the result was not right.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   df1&amp;lt;- structure(list(Student = c(&amp;quot;Student1&amp;quot;, &amp;quot;Student2&amp;quot;, &amp;quot;Student3&amp;quot;, &amp;quot;Student4&amp;quot;, &amp;quot;Student5&amp;quot;), &#xA;                     CGPA = c(9, 7.6, 8.2, 8.5, 9.3), &#xA;                     `Expected Stipend` = c(12000L, 8500L, 9500L, 10000L, 14000L), &#xA;                     `Technical Exam Score` = c(72L, 68L, 63L, 70L, 72L), &#xA;                     `Aptitude Test Grade` = c(&amp;quot;B1&amp;quot;, &amp;quot;B1&amp;quot;, &amp;quot;B2&amp;quot;, &amp;quot;A2&amp;quot;, &amp;quot;A2&amp;quot;)), &#xA;                      class = &amp;quot;data.frame&amp;quot;, row.names = c(NA, -5L))&#xA;&#xA;       &amp;gt; df1&#xA;       Student CGPA Expected Stipend Technical Exam Score Aptitude Test Grade&#xA;    1 Student1  9.0            12000                   72                  B1&#xA;    2 Student2  7.6             8500                   68                  B1&#xA;    3 Student3  8.2             9500                   63                  B2&#xA;    4 Student4  8.5            10000                   70                  A2&#xA;    5 Student5  9.3            14000                   72                  A2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9063" LastEditorUserId="9063" LastEditDate="2022-02-14T23:24:08.080" LastActivityDate="2022-02-15T00:15:51.297" Title="Use the Weighted Sum Method in R" Tags="|r|multicriteria-decision-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7836" PostTypeId="1" AcceptedAnswerId="7848" CreationDate="2022-02-14T23:58:22.013" Score="6" ViewCount="88" Body="&lt;p&gt;I would like to optimize (minimize) the following expression in order to find the functional minimizer &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; (which should be at least once differentiable): &lt;span class=&quot;math-container&quot;&gt;$$ \int_0^\infty g'(x) f(x) \ dx $$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is the density of the log-normal distribution, and also subject to the following constraints: &lt;span class=&quot;math-container&quot;&gt;$$\forall x&amp;gt;0: g'(x)&amp;gt;0, g(x) &amp;gt; 0, g(0)=0, g(1)=1, \lim\limits_{x\to\infty} g(x) = +\infty, \lim\limits_{x\to\infty} g'(x) = +\infty$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Any ideas for that? It seems that the standard Euler-Lagrange equation cannot be used (maybe this means there is no minimizer?).&lt;/p&gt;&#xA;" OwnerUserId="9179" LastEditorUserId="123" LastEditDate="2022-02-16T09:08:27.100" LastActivityDate="2022-02-16T09:08:27.100" Title="Minimize $\int_0^\infty g'(x)f(x)\,dx$ where $f(x)$ has a log-normal density" Tags="|optimization|optimality-conditions|optimal-control|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7837" PostTypeId="2" ParentId="7835" CreationDate="2022-02-15T00:15:51.297" Score="3" Body="&lt;p&gt;The edited version fixed one problem (numeric fields being character strings). Before using the &lt;code&gt;weightedSum&lt;/code&gt; function (or doing any other calculations), you also need to do two things, both explained in the GeeksForGeeks page. First, you need to convert the letter grades to points, using the 1-5 scale on the GFG page (below Table 3). Next, you have to scale the columns. For three of them, you divide by their max values. For &amp;quot;Expected Stipend&amp;quot;, you divide by the min value and take a reciprocal.&lt;/p&gt;&#xA;&lt;p&gt;Here is some code using the &lt;code&gt;dplyr&lt;/code&gt; package to do data frame modifications. I calculated the scores and ranks manually, without using &lt;code&gt;weightedSum&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Convert the grades to point values.&#xA;df1 &amp;lt;- df1 |&amp;gt; mutate(`Aptitude Test Grade` = recode(`Aptitude Test Grade`, &amp;quot;A1&amp;quot; = 5, &amp;quot;A2&amp;quot; = 4, &amp;quot;B1&amp;quot; = 3, &amp;quot;B2&amp;quot; = 2, &amp;quot;C1&amp;quot; = 1))&#xA;# Set up the vector of weights.&#xA;weights &amp;lt;- c(0.3, 0.2, 0.25, 0.25)&#xA;# Copy the data frame and scale each column appropriately.&#xA;scaled &amp;lt;- df1 |&amp;gt;&#xA;            mutate(CGPA = CGPA / max(CGPA),&#xA;                   `Expected Stipend` = min(`Expected Stipend`) / `Expected Stipend`,&#xA;                   `Technical Exam Score` = `Technical Exam Score` / max(`Technical Exam Score`),&#xA;                   `Aptitude Test Grade` = `Aptitude Test Grade` / max(`Aptitude Test Grade`)&#xA;            )&#xA;# Compute the weighted scores.&#xA;scaled &amp;lt;- scaled |&amp;gt;&#xA;            rowwise() |&amp;gt;&#xA;            mutate(`Performance Score` = weighted.mean(c(CGPA, `Expected Stipend`, `Technical Exam Score`, `Aptitude Test Grade`), w = weights))&#xA;# Assign ranks.&#xA;scaled&lt;span class=&quot;math-container&quot;&gt;$Rank &amp;lt;- (nrow(scaled) + 1) - rank(scaled$&lt;/span&gt;`Performance Score`)&#xA;# View the results.&#xA;scaled&#xA;  Student   CGPA `Expected Stipend` `Technical Exam…` `Aptitude Test…` `Performance S…`  Rank&#xA;  &amp;lt;chr&amp;gt;    &amp;lt;dbl&amp;gt;              &amp;lt;dbl&amp;gt;             &amp;lt;dbl&amp;gt;            &amp;lt;dbl&amp;gt;            &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;&#xA;1 Student1 0.968              0.708             1                 0.75            0.869     3&#xA;2 Student2 0.817              1                 0.944             0.75            0.869     4&#xA;3 Student3 0.882              0.895             0.875             0.5             0.787     5&#xA;4 Student4 0.914              0.85              0.972             1               0.937     1&#xA;5 Student5 1                  0.607             1                 1               0.921     2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;code&gt;rank()&lt;/code&gt; function ranks lowest to highest, and we want highest to lowest, so we have to get a little creative. You could rank the negative of the score, or the reciprocal of the score, or (as I did here) you could rank the scores and subtract the computed ranks from 1 more than the number of scores.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-15T00:15:51.297" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7838" PostTypeId="1" AcceptedAnswerId="7839" CreationDate="2022-02-15T00:35:00.657" Score="3" ViewCount="148" Body="&lt;p&gt;I have a scheduling model where each job &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; requires three operations (with fixed precedence and they must happen in a row) for a fixed number of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; service sessions (each session on a specific day). The service duration for operations of job &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is equal to &lt;span class=&quot;math-container&quot;&gt;$S^1_p$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$S^2_p$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$S^3_p$&lt;/span&gt;. An identical machine &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; can serve multiple jobs at the same time slot &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, but not two jobs within their first operations, third operations, and first and third operations. In other words, a machine can handle multiple jobs at the same time within their second operations (&lt;span class=&quot;math-container&quot;&gt;$S^2_p$&lt;/span&gt;), but only one of jobs can be within their first or third operations:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1FdCg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1FdCg.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$a_{pjti}$&lt;/span&gt; is a binary variable indicating job &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; starts at time slot &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; for service session &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$y_{pnti}$&lt;/span&gt; is a binary variable indicating job &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is being allocated to machine &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; for its service session &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have used these constraints in my MILP model and coded it in python (shown below). However, for large-sized instances, it takes one day to generate each of the above constraint sets (on a powerful computer). Do you have any suggestions on how I can implement these constraints?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hnKUe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hnKUe.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="500" LastEditDate="2022-02-15T17:04:51.403" LastActivityDate="2022-02-15T17:04:51.403" Title="Model generation for large-sized instances" Tags="|mixed-integer-programming|modeling|constraint|job-shop-scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7839" PostTypeId="2" ParentId="7838" CreationDate="2022-02-15T01:15:00.570" Score="6" Body="&lt;p&gt;I suggest three major changes:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Omit the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables.&lt;/li&gt;&#xA;&lt;li&gt;Replace the &lt;span class=&quot;math-container&quot;&gt;$a_{p,j,t,i}$&lt;/span&gt; variables with &lt;span class=&quot;math-container&quot;&gt;$a_{p,j,t,i,n}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Instead of pairs of jobs, consider much larger subsets of jobs.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The resulting reformulation will have fewer and stronger constraints, all of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{p,j,t,i} a_{p,j,t,i,n} \le 1 \quad \text{for all $\bar{j},\bar{t},n$},$$&lt;/span&gt;&#xA;where the summation is over all &lt;span class=&quot;math-container&quot;&gt;$(p,j,t,i)$&lt;/span&gt; for which job &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; starting in slot &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; for service session &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; would be in its first or third operation in slot &lt;span class=&quot;math-container&quot;&gt;$\bar{j}$&lt;/span&gt; and day &lt;span class=&quot;math-container&quot;&gt;$\bar{t}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-02-15T01:27:14.880" LastActivityDate="2022-02-15T01:27:14.880" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="7840" PostTypeId="2" ParentId="7800" CreationDate="2022-02-15T03:02:44.400" Score="2" Body="&lt;p&gt;There are many real world applications that specialize the &lt;a href=&quot;https://www.geeksforgeeks.org/transportation-problem-set-1-introduction/&quot; rel=&quot;nofollow noreferrer&quot;&gt;transportation problem&lt;/a&gt; which may be framed as an LP. Beyond the many problems that can be framed directly in terms of the transportation problem, there are also those that use it as an important step of an algorithm. For instance in my &lt;a href=&quot;https://vtechworks.lib.vt.edu/handle/10919/78285&quot; rel=&quot;nofollow noreferrer&quot;&gt;masters&lt;/a&gt;, I show that the stochastic stacker crane problem, a generalization of the traveling salesman problem, has an almost surely linear time &lt;span class=&quot;math-container&quot;&gt;$(1+\epsilon)$&lt;/span&gt;-competitive algorithm. A crucial step is finding a good approximate solution to the Euclidean Bipartite Matching Problem by solving the transportation problem on clusters of nearby points.&lt;/p&gt;&#xA;" OwnerUserId="9180" LastActivityDate="2022-02-15T03:02:44.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7841" PostTypeId="1" AcceptedAnswerId="7876" CreationDate="2022-02-15T07:47:53.310" Score="4" ViewCount="726" Body="&lt;p&gt;I'm working on my first pulp model and something isn't going quite right. It looks like it's close, but for some reason it is not respecting one of my constraints...&lt;/p&gt;&#xA;&lt;p&gt;It's a scheduling problem and I am trying to minimize the number of labor hours used whilst meeting the workforce requirements for each time window. The model returns an &amp;quot;optimal&amp;quot; result, but the staffing figures are far short of the workforce requirements for each window.&lt;/p&gt;&#xA;&lt;p&gt;There are 120 potential shifts to choose from (&amp;quot;n&amp;quot;), and 84 time windows (t). Each time window has its own workforce requirement (number of staff, &amp;quot;d&amp;quot;). Not all shifts will be filled.&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;d&amp;quot; is the number of workers required in each of the 84 time windows, it is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VpnbE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VpnbE.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I want to minimize the number of labor hours required in total (&amp;quot;w&amp;quot;) whilst meeting the workforce requirements for each time window. &amp;quot;w&amp;quot; looks like this, in hours per shift - one entry for each of the 120 potential shifts:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TLB4Q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TLB4Q.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The final solution does not satisfy the workforce requirements for the various time windows, it's substantially short. Only 5 shifts are filled in total:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Status: Optimal&#xA;The number of workers needed for shift 0 is 1 workers&#xA;The number of workers needed for shift 90 is 2 workers&#xA;The number of workers needed for shift 91 is 1 workers&#xA;The number of workers needed for shift 92 is 1 workers&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For reference, just to show that the needed amount of labor isn't in the solution, these are the full schedules for each of the 120 shifts (asterisks on the shifts that the solver filled (1, 89 (2 employees), 90, and 91):&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Shift_Num&lt;/th&gt;&#xA;&lt;th&gt;Start_Shift&lt;/th&gt;&#xA;&lt;th&gt;First_Break_Start&lt;/th&gt;&#xA;&lt;th&gt;First_Break_End&lt;/th&gt;&#xA;&lt;th&gt;Lunch_Start&lt;/th&gt;&#xA;&lt;th&gt;Lunch_End&lt;/th&gt;&#xA;&lt;th&gt;Second_Break_Start&lt;/th&gt;&#xA;&lt;th&gt;Second_Break_End&lt;/th&gt;&#xA;&lt;th&gt;End_Shift&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;***1&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;6:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;6:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;6:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;6:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;6:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:55:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:05:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;7&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;6:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:05:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;8&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:25:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;9&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:25:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:35:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;10&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:35:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:45:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;11&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;6:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;6:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;12&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;6:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;13&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;14&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;15&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;16&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;17&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;18&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;19&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;20&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;21&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:55:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:05:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;22&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:05:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;23&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:25:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;24&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:25:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:35:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;25&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:35:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:45:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;26&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;27&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;28&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;29&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;30&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;31&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;32&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;33&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;34&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;35&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;36&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:55:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:05:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;37&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:05:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;38&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:25:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;39&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:25:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:35:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;40&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:15:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:35:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:45:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;41&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;42&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;43&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;44&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;45&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;46&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;47&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;48&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;49&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;50&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;51&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:55:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:05:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;52&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:05:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;53&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:25:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;54&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:25:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:35:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;55&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:35:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:45:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;56&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;57&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;9:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;58&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;59&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;60&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;61&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;62&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;63&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;64&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;65&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;66&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:55:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:05:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;67&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:05:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;68&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:25:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;69&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:25:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:35:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;70&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:35:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:45:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;71&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;72&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;73&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;74&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;75&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;76&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;77&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;78&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;79&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;80&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;81&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;2:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:55:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:05:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;82&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:05:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;83&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:25:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;84&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:25:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:35:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;85&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:15:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:35:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:45:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;86&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;87&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;88&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;***89&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;***90&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;***91&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;92&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;7:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;93&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;94&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;95&lt;/td&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;8:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;96&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;97&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;98&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;99&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;100&lt;/td&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;10:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;101&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;102&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;103&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;104&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;105&lt;/td&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;11:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;106&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;107&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;108&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;109&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;110&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;111&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;112&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;113&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;114&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;115&lt;/td&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;2:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;116&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;117&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;118&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;119&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;120&lt;/td&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;4:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;7:00:00 PM&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;This is the code that I'm using, I know I'm missing something, I'm just not sure what. It's not lost on me that the solver scheduled 5 shifts and the max workforce needed in any timeframe is 5, but it's not enough to cover the workforce needs for the entire day.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# create shift matrix&#xA;df = num_workers_t_window.fillna(0).applymap(lambda x: 1 if x == &amp;quot;x&amp;quot; else x)&#xA;df = df.drop(columns = [&amp;quot;startTime&amp;quot;])&#xA;&#xA;a = df.drop(columns =[&amp;quot;T_Window&amp;quot;,&amp;quot;num_workers_required&amp;quot;]).values&#xA;&#xA;# number of shifts&#xA;n = a.shape[1]&#xA;&#xA;# number of time windows&#xA;T = a.shape[0]&#xA;&#xA;# of workers required per time window&#xA;d = df[&amp;quot;num_workers_required&amp;quot;].values&#xA;&#xA;# labor hours per shift&#xA;w = shift_hours[&amp;quot;Shift_Hours&amp;quot;].values.astype(int)&#xA;&#xA;# Decision Variables&#xA;y = LpVariable.dicts(&amp;quot;num_workers&amp;quot;, list(range(n)), lowBound=0, cat=&amp;quot;Integer&amp;quot;)&#xA;&#xA;# Create Problem&#xA;prob = LpProblem(&amp;quot;Schedule_Creation&amp;quot;, LpMinimize)&#xA;&#xA;# Minimize Labor Hours&#xA;prob += lpSum([w[j] * y[j] for j in range(n)])&#xA;&#xA;# Constraint for workers required in each time window&#xA;for t in range(T):&#xA;    prob += lpSum([a[t, j] * y[j] for j in range (n)]) &amp;gt;= d[t]&#xA;&#xA;prob.solve()&#xA;&#xA;print(&amp;quot;Status:&amp;quot;, LpStatus[prob.status])&#xA;&#xA;for shift in range(n):&#xA;    print(&#xA;        f&amp;quot;The number of workers needed for shift {shift} is {(y[shift].value())} workers&amp;quot;&#xA;    )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;One of the constraints, per request in comments:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NPJIt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NPJIt.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Adding the LP Model, source for this code is from this project: &lt;a href=&quot;https://towardsdatascience.com/how-to-solve-a-staff-scheduling-problem-with-python-63ae50435ba4&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://towardsdatascience.com/how-to-solve-a-staff-scheduling-problem-with-python-63ae50435ba4&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Minimize function&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1bMkv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1bMkv.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Workforce requirement constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Qm0sU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qm0sU.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Adding a sample of data frame for shifts, workers required (last column), and associated time windows:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;T_Window&lt;/th&gt;&#xA;&lt;th&gt;Shift_1&lt;/th&gt;&#xA;&lt;th&gt;Shift_2&lt;/th&gt;&#xA;&lt;th&gt;Shift_16&lt;/th&gt;&#xA;&lt;th&gt;Shift_17&lt;/th&gt;&#xA;&lt;th&gt;Shift_31&lt;/th&gt;&#xA;&lt;th&gt;num_workers_required&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;7:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;7:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;7:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;7:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;7:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;7:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;8:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;8:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;8:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;8:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;8:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;8:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;9:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;9:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;9:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;9:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;9:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;9:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;10:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;10:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;10:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;10:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;10:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;10:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;11:00:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;11:10:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;11:20:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;11:30:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;11:40:00 AM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;11:50:00 AM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;12:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;12:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;12:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;12:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;12:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;12:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;5&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;4:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;4:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;4:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;4:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;4:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;4:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6:00:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6:10:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6:20:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6:30:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6:40:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6:50:00 PM&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;" OwnerUserId="7573" LastEditorUserId="7573" LastEditDate="2022-02-18T19:38:04.650" LastActivityDate="2022-02-21T15:01:24.177" Title="Python Pulp - LpMinimize Not Returning Expected Output - Scheduling Problem" Tags="|linear-programming|constraint|pulp|job-shop-scheduling|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="7842" PostTypeId="1" AcceptedAnswerId="7846" CreationDate="2022-02-15T08:42:26.910" Score="1" ViewCount="55" Body="&lt;p&gt;Say &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$n\times m$&lt;/span&gt; matrix with no negative entries. Assume further that every row and every column have at least a non zero element. Denote &lt;span class=&quot;math-container&quot;&gt;$\langle\mathbf{X}\rangle$&lt;/span&gt; the cone spanned by &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q},\mathbf{k}, 1$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; be vectors of the suitable dimension. In the following LP&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;  \text{maximize} &amp;amp;\quad \mathbf{q}\cdot 1\\&#xA;  \text{subject to} &amp;amp; \quad \mathbf{X}^{\top}\mathbf{q}\leq\mathbf{k}\\ &amp;amp;\quad\mathbf{q}\geq 0,&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^*$&lt;/span&gt; be its solution. I see that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\not\in\langle\mathbf{X}\rangle\implies \mathbf{X}^{\top}\mathbf{q}^*\leq\mathbf{k}$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}^{\top}\mathbf{q}^*\ne\mathbf{k}$&lt;/span&gt;), because &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\not\in\langle\mathbf{X}\rangle$&lt;/span&gt; implies that there does not exist a set of positive weights satisfying &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}^{\top}\mathbf{q}=\mathbf{k}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, I believe that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\in\langle\mathbf{X}\rangle\implies \mathbf{X}^{\top}\mathbf{q}^*=\mathbf{k}$&lt;/span&gt;. Is this true? Why?&lt;/p&gt;&#xA;" OwnerUserId="2391" LastActivityDate="2022-02-15T16:56:11.627" Title="When will constraints in an LP be satisfied as equalities?" Tags="|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7843" PostTypeId="1" AcceptedAnswerId="7854" CreationDate="2022-02-15T13:09:17.540" Score="1" ViewCount="274" Body="&lt;p&gt;I would like to use the &lt;strong&gt;weighted sum method&lt;/strong&gt; to select the best number of clusters out of the 34 options. As &lt;strong&gt;weights&lt;/strong&gt; I would like to use 0.5 for each criterion. The &lt;strong&gt;coverage&lt;/strong&gt; criterion is to minimize and the &lt;strong&gt;production&lt;/strong&gt; criterion is to maximize.&lt;/p&gt;&#xA;&lt;p&gt;This question is similar to this question: &lt;a href=&quot;https://or.stackexchange.com/questions/7835/use-the-weighted-sum-method-in-r&quot;&gt;Use the Weighted Sum Method in R&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I solved the question, but I would like to know if it is correct.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;library(dplyr)&#xA;&#xA;df1&amp;lt;-structure(list(nclusters = c(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, &#xA;12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, &#xA;28, 29, 30, 31, 32, 33, 34, 35), Coverage = c(0.0363201192049018, &#xA;0.0315198954715543, 0.112661460735583, 0.112661460735583, 0.112661460735583, &#xA;0.0813721071219816, 0.0862146652218061, 0.0697995564757394, 0.0599194966471805, &#xA;0.0507632014547115, 0.052076958349629, 0.052076958349629, 0.052076958349629, &#xA;0.052076958349629, 0.052076958349629, 0.052076958349629, 0.0410332568832433, &#xA;0.0389940601722214, 0.0441742111970355, 0.0441742111970355, 0.0441742111970355, &#xA;0.0438099091238968, 0.0409906284310306, 0.0409906284310306, 0.035480410134286, &#xA;0.035480410134286, 0.035480410134286, 0.035480410134286, 0.035480410134286, &#xA;0.035480410134286, 0.035480410134286, 0.0345381204372174, 0.0287729883480053, &#xA;0.0287729883480053), Production = c(1635156.04305, 474707.64025, &#xA;170773.40775, 64708.312, 64708.312, 64708.312, 949.72635, 949.72635, &#xA;949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 949.72635, &#xA;949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 949.72635, &#xA;949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 949.72635, &#xA;949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 949.72635, &#xA;949.72635, 949.72635)), class = &amp;quot;data.frame&amp;quot;, row.names = c(NA,-34L))&#xA;&#xA;weights &amp;lt;- c(0.5,0.5) &#xA;&#xA;scaled &amp;lt;- df1 |&amp;gt;&#xA;  mutate(Coverage = min(Coverage) / Coverage,&#xA;         Production = Production / max(Production))&#xA;&#xA;scaled &amp;lt;- scaled |&amp;gt;&#xA;  rowwise() |&amp;gt;&#xA;  mutate(`Performance Score` = weighted.mean(c(Coverage, Production), w = weights))&#xA;&#xA;scaled&lt;span class=&quot;math-container&quot;&gt;$Rank &amp;lt;- (nrow(scaled) + 1) - rank(scaled$&lt;/span&gt;`Performance Score`)&#xA;&#xA;scaled&#xA;# A tibble: 34 x 5&#xA;# Rowwise: &#xA;   nclusters Coverage Production `Performance Score`  Rank&#xA;       &amp;lt;dbl&amp;gt;    &amp;lt;dbl&amp;gt;      &amp;lt;dbl&amp;gt;               &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;&#xA; 1         2    0.792   1                     0.958    1  &#xA; 2         3    0.913   0.290                 0.415    2  &#xA; 3         4    0.255   0.104                 0.135   17  &#xA; 4         5    0.255   0.0396                0.0827  32.5&#xA; 5         6    0.255   0.0396                0.0827  32.5&#xA; 6         7    0.354   0.0396                0.102   29  &#xA; 7         8    0.334   0.000581              0.0672  34  &#xA; 8         9    0.412   0.000581              0.0829  31  &#xA; 9        10    0.480   0.000581              0.0965  30  &#xA;10        11    0.567   0.000581              0.114   22  &#xA;# ... with 24 more rows&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9063" LastEditorUserId="9063" LastEditDate="2022-02-15T14:08:56.163" LastActivityDate="2022-02-15T20:12:55.377" Title="How to Use the Weighted Sum Method in R" Tags="|r|multicriteria-decision-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7844" PostTypeId="1" CreationDate="2022-02-15T14:12:28.323" Score="3" ViewCount="3396" Body="&lt;p&gt;I have gone through &lt;a href=&quot;https://scipy.github.io/devdocs/tutorial/optimize.html#sequential-least-squares-programming-slsqp-algorithm-method-slsqp&quot; rel=&quot;nofollow noreferrer&quot;&gt;scipy constrained algos&lt;/a&gt; explanation, however, not much is mentioned about the differences, pros and cons of the 'trust-const' and 'slsqp' methods. I particularly wanted to know their suitability based on the following aspects:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Number of optimization parameters&lt;/li&gt;&#xA;&lt;li&gt;Differentiability of constraints&lt;/li&gt;&#xA;&lt;li&gt;Initialization of parameters (interior vs exterior regions)&lt;/li&gt;&#xA;&lt;li&gt;Speed&lt;/li&gt;&#xA;&lt;li&gt;Any other important metric&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="9178" LastActivityDate="2022-07-29T22:28:36.743" Title="SLSQP vs Trust Region Constrained Algorithms" Tags="|python|constraint-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7845" PostTypeId="1" AcceptedAnswerId="7853" CreationDate="2022-02-15T16:24:27.197" Score="4" ViewCount="471" Body="&lt;p&gt;If we let &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; = 1 if a machine is on during hour &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and 0 if the machine is off, how would we enforce a constraint that requires the machine to be “on” for a minimum of at least &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; hours?&lt;/p&gt;&#xA;&lt;p&gt;For example, if a machine turns on at hour 5, then that means at least &lt;span class=&quot;math-container&quot;&gt;$x_5$&lt;/span&gt; through &lt;span class=&quot;math-container&quot;&gt;$x_{5+M}$&lt;/span&gt; all equal 1.  I was thinking about introducing an auxiliary variable such that &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; = 1 if machine turns on at hour &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, but I cannot bridge how to use this to enforce a minimum run time.&lt;/p&gt;&#xA;&lt;p&gt;I would also like to enforce a minimum down time for the machine, but I imagine a similar logic can be applied.&lt;/p&gt;&#xA;" OwnerUserId="3255" LastActivityDate="2022-02-15T21:12:23.113" Title="Minimum up time for a machine in a linear program?" Tags="|optimization|mixed-integer-programming|linear-programming|modeling|integer-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7846" PostTypeId="2" ParentId="7842" CreationDate="2022-02-15T16:56:11.627" Score="3" Body="&lt;p&gt;No, it is not true. Consider &lt;span class=&quot;math-container&quot;&gt;$$X^{T}=\left[\begin{array}{cc}&#xA;1 &amp;amp; 6\\&#xA;1 &amp;amp; 3&#xA;\end{array}\right],\ k=\left[\begin{array}{c}&#xA;7\\&#xA;4&#xA;\end{array}\right].$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-15T16:56:11.627" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7848" PostTypeId="2" ParentId="7836" CreationDate="2022-02-15T17:05:17.220" Score="5" Body="&lt;p&gt;&lt;strong&gt;Proposition.&lt;/strong&gt; There is no minimiser.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Proof:&lt;/em&gt; An equivalent version of your problem is as follows.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Statement.&lt;/strong&gt;  We wish to minimise &lt;span class=&quot;math-container&quot;&gt;$$\int_{-\infty}^\infty xe^{q(x)-x^2}\,dx$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$q(x)$&lt;/span&gt; is a strictly increasing function with &lt;span class=&quot;math-container&quot;&gt;$q(a)=0$&lt;/span&gt; for a given &lt;span class=&quot;math-container&quot;&gt;$a\in\Bbb R$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$\lim_{x\to\pm\infty}q(x)=\pm\infty,\quad\lim_{x\to+\infty}q'(x)e^{q(x)-x}=+\infty.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The proof for the equivalence is provided at the end of this post.&lt;/p&gt;&#xA;&lt;p&gt;Now, since &lt;span class=&quot;math-container&quot;&gt;$\int_{-\infty}^\infty xe^{q(x)-x^2}\,dx$&lt;/span&gt; is positive by the original integral &lt;span class=&quot;math-container&quot;&gt;$\int_0^\infty g'(x)f(x)\,dx&amp;gt;0$&lt;/span&gt;, it suffices to choose a sequence of functions &lt;span class=&quot;math-container&quot;&gt;$q_A(x)$&lt;/span&gt; such that the integral becomes arbitrarily close to zero.&lt;/p&gt;&#xA;&lt;p&gt;This is &lt;a href=&quot;https://mathoverflow.net/a/416260/113397&quot;&gt;shown by Iosif Pinelis on MathOverflow&lt;/a&gt; where we take &lt;span class=&quot;math-container&quot;&gt;$$q_A(x):=k(x-a)\,1_{x\le a+A}+(kA+2(x-A))\,1_{x&amp;gt;a+A}$$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$k,A\in(0,\infty)$&lt;/span&gt;. By the dominated convergence theorem, we have &lt;span class=&quot;math-container&quot;&gt;$$\lim_{k\to0^+}\lim_{A\to+\infty}\int_{-\infty}^\infty xe^{q_A(x)-x^2}\,dx=\lim_{k\to0^+}\int_{-\infty}^\infty xe^{k(x-a)-x^2}\,dx=\int_{-\infty}^\infty xe^{-x^2}=0$$&lt;/span&gt; and so we have a zero infimum. &lt;span class=&quot;math-container&quot;&gt;$\quad\square$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Proof of Statement:&lt;/em&gt; Let &lt;span class=&quot;math-container&quot;&gt;$g=e^h$&lt;/span&gt; so that &lt;span class=&quot;math-container&quot;&gt;$g'=h'e^h$&lt;/span&gt;. Then the constraints become &lt;span class=&quot;math-container&quot;&gt;$$h'(x)&amp;gt;0,h(1)=0,\lim_{x\to0}h(x)=-\infty,\lim_{x\to\infty}h(x)=+\infty,\lim_{x\to\infty}h'(x)e^{h(x)}=+\infty$$&lt;/span&gt; and the functional is &lt;span class=&quot;math-container&quot;&gt;\begin{align}\int_0^\infty g'f\,dx&amp;amp;=[gf]_0^\infty-\int_0^\infty gf'\,dx\\&amp;amp;=\frac1{\sigma\sqrt{2\pi}}\left(\lim_{x\to\infty}e^{h(x)-\log x-\frac{(\log x-\mu)^2}{2\sigma^2}}-\int_0^\infty\frac{e^{h(x)-\frac{(\log x-\mu)^2}{2\sigma^2}}(\mu-\sigma^2-\log x)}{\sigma^2 x^2}\,dx\right)\end{align}&lt;/span&gt; where we assume the limit exists. Let &lt;span class=&quot;math-container&quot;&gt;$h(x)=p(u)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x=e^u$&lt;/span&gt;. Then &lt;span class=&quot;math-container&quot;&gt;$$p'(u)&amp;gt;0,p(0)=0,\lim_{u\to\pm\infty}p(u)=\pm\infty,\lim_{u\to+\infty}p'(u)e^{p(u)-u}=+\infty$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;\begin{align}\sigma\sqrt{2\pi}\int_0^\infty g'f\,dx&amp;amp;=\lim_{u\to\infty}e^{p(u)-u-\frac{(u-\mu)^2}{2\sigma^2}}+\frac1{\sigma^2}\int_{-\infty}^\infty e^{p(u)-u-\frac{(u-\mu)^2}{2\sigma^2}}(u+\sigma^2-\mu)\,du.\end{align}&lt;/span&gt; For both &lt;span class=&quot;math-container&quot;&gt;$\int_0^\infty$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\int_{-\infty}^0$&lt;/span&gt; to be finite, we must have &lt;span class=&quot;math-container&quot;&gt;$$\lim_{u\to\pm\infty}p(u)-u-\frac{(u-\mu)^2}{2\sigma^2}=-\infty\implies p(u)=o(u^2)$$&lt;/span&gt; since &lt;span class=&quot;math-container&quot;&gt;$p'(u)&amp;gt;0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; means &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; cannot have a quadratic term. So &lt;span class=&quot;math-container&quot;&gt;\begin{align}\sigma^3\sqrt{2\pi}\int_0^\infty g'f\,dx&amp;amp;=\int_{-\infty}^\infty e^{p(u)-u-\frac{(u-\mu)^2}{2\sigma^2}}(u+\sigma^2-\mu)\,du\\&amp;amp;=\frac{e^{\sigma^2/2-\mu}}{2\pi\sigma^2}\int_{-\infty}^\infty ve^{q(v)-v^2}\,dv\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$q(u)=p(u/\sqrt{2\sigma^2}-\sigma^2+\mu)$&lt;/span&gt; under the same constraints as &lt;span class=&quot;math-container&quot;&gt;$p(u)$&lt;/span&gt; except &lt;span class=&quot;math-container&quot;&gt;$q((\sigma^2-\mu)\sqrt{2\sigma^2})=0$&lt;/span&gt;. In the statement, we simply define &lt;span class=&quot;math-container&quot;&gt;$a:=(\sigma^2-\mu)\sqrt{2\sigma^2}$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$\quad\square$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2022-02-16T09:06:49.387" LastActivityDate="2022-02-16T09:06:49.387" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7849" PostTypeId="1" CreationDate="2022-02-15T17:44:44.943" Score="4" ViewCount="487" Body="&lt;p&gt;&lt;strong&gt;Especially in the case of Discrete and Combinatorial Optimization Problems&lt;/strong&gt; - I am trying to better understand the the idea of &amp;quot;subproblems&amp;quot; within the &amp;quot;main problem&amp;quot;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8oVz8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8oVz8.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;At a very superficial level, I can understand the idea of a &amp;quot;subproblem&amp;quot; : A complicated optimization problem might be too difficult to solve directly. Therefore, if we can &amp;quot;break&amp;quot; this complicated problem into smaller problems (provided these smaller problems are easier to solve than the original complicated problem), we can instead solve these smaller subproblems and as a result, indirectly solve the original complicated problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt; As an example, I might not be able to add two large numbers together. However, I know how to add smaller numbers together. So I might be able to &amp;quot;break&amp;quot; this addition problem into smaller subproblems. For example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Original Problem 541 + 329 = 870&lt;/li&gt;&#xA;&lt;li&gt;Subproblem 1: 500 + 300 = 800&lt;/li&gt;&#xA;&lt;li&gt;Subproblem 2: 40 + 20 = 60&lt;/li&gt;&#xA;&lt;li&gt;Subproblem 3: 1 + 9 = 10&lt;/li&gt;&#xA;&lt;li&gt;Subproblem 1 + Subproblem 2 + Subproblem 3 = 800 + 60 + 10 = 870 = Original Problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt; As another example, I might not be able to carry all my groceries from my car to my house in one trip (original problem). So instead of struggling and inevitably being unable to carry all my groceries in one trip, I might be identify subproblems as a function of the maximum weight of groceries I can carry, and solve the original problem by solving a series of subproblems (i.e. making multiple trips instead of a single trip).&lt;/p&gt;&#xA;&lt;p&gt;Now, I am trying to extend these ideas to understand the relevance of subproblems in combinatorial and discrete optimization problems (e.g. mixed integer programming). For instance, &lt;strong&gt;I have heard that almost all algorithms for discrete optimization problems always try to solve these problems by identifying subproblems&lt;/strong&gt; but I am not sure why this is.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hQYf1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hQYf1.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Logically, I can understand why this is the case as discrete/combinatorial optimization are too difficult to solve at once, thus we try to break them into mini subproblems and solve these subproblems individually. &lt;strong&gt;I have also heard that in a &amp;quot;constraint mixed integer programming problem,&amp;quot; the existence of subproblems are inevitable&lt;/strong&gt; : an optimization algorithm will treat the problem as a continuous problem when identifying a candidate solution (subproblem 1), and then check to see if this candidate solution satisfies the constraints (subproblem 2). &lt;strong&gt;But I am not sure if this analogy is correct.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; Can someone please explain why Subproblems are so &amp;quot;relevant&amp;quot; in Discrete and Combinatorial Optimization Problems?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Optimal_substructure&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Optimal_substructure&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://ibs.bfsu.edu.cn/chenxi/IntegerProgramming.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ibs.bfsu.edu.cn/chenxi/IntegerProgramming.pdf&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In Machine Learning applications where the task is to optimize a (complicated) Loss Function corresponding to a Neural Network, Optimization Algorithms such as Gradient Descent often (locally and linearly) approximate this Loss Function based on a Taylor Expansion, seeing as this local-linear approximation of the Loss Function is easier to optimize compared to the original Loss Function (e.g. less computationally expensive). Thus, could we say that the Gradient Descent algorithm in Machine Learning applications is identifying a &amp;quot;first subproblem&amp;quot; through the local-linear approximation of the Loss Function, and then solves a &amp;quot;second subproblem&amp;quot; by evaluating the derivative of this local-linear approximation?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-02-15T21:19:49.497" LastActivityDate="2022-02-15T21:19:49.497" Title="Optimization Problems vs Optimization Sub Problems" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7850" PostTypeId="1" AcceptedAnswerId="7855" CreationDate="2022-02-15T17:51:14.410" Score="1" ViewCount="84" Body="&lt;p&gt;This is a follow up of my previous &lt;a href=&quot;https://or.stackexchange.com/questions/7842/when-will-constraints-in-an-lp-be-satisfied-as-equalities&quot;&gt;question&lt;/a&gt;. I repeat it below with an additional condition (in italics).&lt;/p&gt;&#xA;&lt;p&gt;Say &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$n\times m$&lt;/span&gt; matrix with no negative entries and such that every row and every column have at least a non zero element.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^i$&lt;/span&gt; be the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th row of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt; and assume further that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^i\not\leq\mathbf{x}^j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^j\not\leq\mathbf{x}^i\;\forall i,j$&lt;/span&gt;&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Denote &lt;span class=&quot;math-container&quot;&gt;$\langle\mathbf{X}\rangle$&lt;/span&gt; the cone spanned by &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q},\mathbf{k}, 1$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; be vectors of the suitable dimension. In the following LP&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;  \text{maximize} &amp;amp;\quad \mathbf{q}\cdot 1\\&#xA;  \text{subject to} &amp;amp; \quad \mathbf{X}^{\top}\mathbf{q}\leq\mathbf{k}\\ &amp;amp;\quad\mathbf{q}\geq 0,&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^*$&lt;/span&gt; be its solution. I see that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\not\in\langle\mathbf{X}\rangle\implies \mathbf{X}^{\top}\mathbf{q}^*\leq\mathbf{k}$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}^{\top}\mathbf{q}^*\ne\mathbf{k}$&lt;/span&gt;), because &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\not\in\langle\mathbf{X}\rangle$&lt;/span&gt; implies that there does not exist a set of positive weights satisfying &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}^{\top}\mathbf{q}=\mathbf{k}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, I believe that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\in\langle\mathbf{X}\rangle\implies \mathbf{X}^{\top}\mathbf{q}^*=\mathbf{k}$&lt;/span&gt;. Is this true? Why?&lt;/p&gt;&#xA;" OwnerUserId="2391" LastActivityDate="2022-02-15T20:36:35.893" Title="Will constraints in this LP be satisfied as equalities?" Tags="|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7851" PostTypeId="2" ParentId="7849" CreationDate="2022-02-15T18:49:48.030" Score="4" Body="&lt;p&gt;I would disagree with the contentions that subproblems are &amp;quot;inevitable&amp;quot; and that algorithms almost always try to identify and exploit them. What is illustrated in your diagram (a branch-and-bound solution tree) does not really involve &amp;quot;subproblems&amp;quot;. A more accurate term for the problems at the nodes would be &amp;quot;restricted problems&amp;quot; or just &amp;quot;restrictions&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Subproblems frequently occur when a problem can be decomposed into smaller, more tractable portions. For instance, a multiperiod production problem might decompose into a set of single period subproblems and a master problem that integrates the single period solutions and handles constraints that link them. Besides decomposing over time, in some cases we decompose problems geographically or geometrically. In one project with which I was involved, we were placing a network of sensors in a body of water. The full model was too large to solve, so we approximated the body of water with a bunch of 3D cubes, made the placement of sensors in each cube a subproblem, and then had a master problem that resolved the connection of the separate networks into a single network.&lt;/p&gt;&#xA;&lt;p&gt;In addition to decomposition, another source of subproblems is models where a portion of the problem does not fit a mixed integer linear (quadratic, whatever) structure. There are techniques that combine a MILP model containing the elements that are easily modeled with an &amp;quot;oracle&amp;quot; that takes candidate solutions, does mysterious things, and either blesses the solution or conjures up a previously unknown constraint that the candidate solution violates. In the latter case, the new constraint is added to the MILP model and solution of the MILP continues or starts over. The oracle is considered a subproblem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-15T18:49:48.030" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7852" PostTypeId="1" AcceptedAnswerId="7860" CreationDate="2022-02-15T18:56:43.283" Score="2" ViewCount="71" Body="&lt;p&gt;I'm trying to model the scheduling of maintenance in some machines, and was wondering how I could ensure that, if maintenance is planned to start in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, then it has to be carried out until period &lt;span class=&quot;math-container&quot;&gt;$t+k-1$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is the duration of maintenance. This maintenance is not a one time thing, multiple maintenance actions are possible.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$m_t$&lt;/span&gt; is a binary variable saying that maintenance is scheduled in period t, then what I want is similar to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$m_t = 1 \implies \sum_{i=-k+1}^{i=k-1} m_{t+i} = k, \forall t&amp;gt;k$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But this does not model what I want, since the 1's have to be consecutive, but beyond that, I do not wish to use logical constraints and would rather avoid their direct linearizations, if possible. Is there a way to efficiently model this sort of thing? It does not need to be linear.&lt;/p&gt;&#xA;" OwnerUserId="5352" LastEditorUserId="491" LastEditDate="2022-02-15T21:17:44.347" LastActivityDate="2022-02-16T13:42:52.683" Title="Ensure that scheduled repeating maintenance has to be completed" Tags="|mixed-integer-programming|modeling|integer-programming|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7853" PostTypeId="2" ParentId="7845" CreationDate="2022-02-15T19:13:58.463" Score="2" Body="&lt;p&gt;I would also follow your idea of introducing an additional variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; if the process of switching the machine on is done at time &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. The first constraint makes sure that &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; is 1 if the machine is being switched on at time &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Constraint 2, is just an auxillary constraint for index &lt;span class=&quot;math-container&quot;&gt;$i=0$&lt;/span&gt;, and the third constraint states that &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; must be 1 if &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; is 1, for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; hours.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}y_i &amp;amp;= x_i - x_{i-1}  \quad i=1,\ldots,I \\&#xA;x_0 &amp;amp;= 0 \\&#xA;x_{\min(i+t,I)} &amp;amp;\geq y_i \quad  i=1,\ldots,I;\quad t=0,\ldots,M-1 &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="123" LastEditDate="2022-02-15T21:12:23.113" LastActivityDate="2022-02-15T21:12:23.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7854" PostTypeId="2" ParentId="7843" CreationDate="2022-02-15T20:12:55.377" Score="3" Body="&lt;p&gt;The GeeksForGeeks page linked in your previous question provides one possible way to scale your attributes. Using that scaling method, your code is correct and two clusters has the highest performance score. I tried a couple of other common scaling methods (such as normalizing each column) and it seemed pretty consistent that two clusters won, three clusters came in second, and 34 and 35 clusters tied for third.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-15T20:12:55.377" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7855" PostTypeId="2" ParentId="7850" CreationDate="2022-02-15T20:36:35.893" Score="5" Body="&lt;p&gt;Counterexample:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$X^{T}=\left[\begin{array}{cc}&#xA;1 &amp;amp; 5 &amp;amp; 6\\&#xA;0 &amp;amp; 1 &amp;amp; 0\\&#xA;6 &amp;amp; 5 &amp;amp; 1&#xA;\end{array}\right],\ k=\left[\begin{array}{c}&#xA;12\\&#xA;1\\&#xA;12&#xA;\end{array}\right].$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-15T20:36:35.893" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7856" PostTypeId="1" AcceptedAnswerId="7857" CreationDate="2022-02-15T21:13:41.573" Score="0" ViewCount="241" Body="&lt;p&gt;I am working on the scaling of a MIP using C++. I use Gurobi within CLion. The Gurobi model I use now in Clion require me to enter everything manually (model.addVar, model.addConstr...).&#xA;However, in a &lt;em&gt;large integer program with more than 1000 constraints&lt;/em&gt;, it is not feasible to define each constraint. So I need to make CLion read the Gurobi file(.lp) and solve without using things like model.addVar, model.addConstr...&lt;/p&gt;&#xA;&lt;p&gt;How to make CLion read the .lp file and make Gurobi solve that file within Clion?&lt;/p&gt;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&lt;p&gt;So far I have tried to GRBModel in Clion in the following form below but it gives an error and cannot solve the model.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;GRBEnv env = GRBEnv();&#xA;GRBModel model = GRBModel(env,&amp;quot;coins.lp&amp;quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have used coins.lp to test the model via Command line using &lt;code&gt;$gurobi_cl coins.lp&lt;/code&gt; and Gurobi is able to solve it without an issue there.&lt;/p&gt;&#xA;" OwnerUserId="7526" LastEditorUserId="7526" LastEditDate="2022-02-22T13:54:05.287" LastActivityDate="2022-02-23T05:18:33.463" Title="How to make CLion read .lp file and make Gurobi solve that file within CLion?" Tags="|mixed-integer-programming|modeling|gurobi|c++|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7857" PostTypeId="2" ParentId="7856" CreationDate="2022-02-16T04:38:50.627" Score="4" Body="&lt;p&gt;I'm assuming you have the .lp file. Check the example in the Gurobi webpage &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/examples/lp_cpp_cpp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;lp_c++.cpp&lt;/a&gt;, where they show how to create a model based on a .lp file, and optimize it (respectively, lines 23 and 25 in the code, I believe).&lt;/p&gt;&#xA;&lt;p&gt;The example above should be run from the terminal (after compiled) using the syntax below, and indicated in line 17 (else, that'll show up as an error).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;lp_c++.exe my_model.lp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now, to specify the .lp file inside your code:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Change line 23 to &lt;code&gt;GRBModel model = GRBModel(env, &amp;quot;my_model.lp&amp;quot;);&lt;/code&gt; and make sure you put &lt;code&gt;my_model.lp&lt;/code&gt; in the same folder or provide the path to it inside the quotes.&lt;/li&gt;&#xA;&lt;li&gt;Comment lines 16-19 (or you'll see the error &amp;quot;Usage:...&amp;quot; again)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Edit: I've never used CLion, so my answer is not specific to it, but I don't know how it would change if it was.&lt;/p&gt;&#xA;" OwnerUserId="2741" LastEditorUserId="2741" LastEditDate="2022-02-23T05:18:33.463" LastActivityDate="2022-02-23T05:18:33.463" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7858" PostTypeId="2" ParentId="7841" CreationDate="2022-02-16T08:15:33.790" Score="2" Body="&lt;p&gt;You expect &lt;span class=&quot;math-container&quot;&gt;$y_j &amp;gt; 0$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. Looking at the LP however, this does not need to be the case. Just the sum &lt;span class=&quot;math-container&quot;&gt;$y_j * a_{jt}$&lt;/span&gt; over every &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; needs to fulfill your demand for every &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;  (i.e. be at least 1). Your pulp code seems to be right and also the solution it gives is (most likely) valid.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="3464" LastEditDate="2022-02-16T08:54:48.090" LastActivityDate="2022-02-16T08:54:48.090" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7860" PostTypeId="2" ParentId="7852" CreationDate="2022-02-16T12:05:58.723" Score="1" Body="&lt;p&gt;Following @prubin's link in the comments, I reached Erwin Kalvelagen's &lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2018/03/production-scheduling-minimum-up-time.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;blog&lt;/a&gt;, which seems to answer my question.&lt;/p&gt;&#xA;&lt;p&gt;A way to model this would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i=t}^{t+k-1}m_{i} \geq k(m_{t}-m_{t-1}), \forall t &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i=t}^{t+k}m_{i} \leq k,\forall t&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is still forbidding two consecutive maintenance actions, but it does not matter much in my model.&lt;/p&gt;&#xA;" OwnerUserId="5352" LastEditorUserId="491" LastEditDate="2022-02-16T13:42:52.683" LastActivityDate="2022-02-16T13:42:52.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7861" PostTypeId="1" CreationDate="2022-02-16T15:58:44.763" Score="3" ViewCount="155" Body="&lt;p&gt;I am using pyomo together with a bunch of solvers (gurobi, cbc, etc.).&#xA;I am able to compute the IIS (with gurobi, not cbc), and write it in a &lt;code&gt;*.ilp&lt;/code&gt; file.&lt;/p&gt;&#xA;&lt;p&gt;What I would like to achieve would be to identifiy a constraint (or several ones) making the problem infeasible, remove it and resolve the problem.&lt;/p&gt;&#xA;&lt;p&gt;To do so I have mainly two issues:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I am not able to read the &lt;code&gt;*.ilp&lt;/code&gt; file with pyomo&lt;/li&gt;&#xA;&lt;li&gt;Even if I was, I am not sure I would be able to link constraints in the pyomo model to constraints in the &lt;code&gt;*.ilp&lt;/code&gt; file (and vice-versa)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8723" LastActivityDate="2022-02-16T15:58:44.763" Title="Pyomo: Compute IIS, remove corresponding constraint and resolve" Tags="|gurobi|pyomo|cbc|irreducible-infeasible-subset|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7862" PostTypeId="1" CreationDate="2022-02-17T03:23:56.437" Score="2" ViewCount="157" Body="&lt;p&gt;For convex functions &lt;span class=&quot;math-container&quot;&gt;$f_i, \ i \in I$&lt;/span&gt;, the KS function is defined as the following for any &lt;span class=&quot;math-container&quot;&gt;$\rho &amp;gt; 0$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$KS[\{ f_i \}_{i \in I}](x):= (1/ \rho) \ln \left[ \sum_{i \in I} \exp(\rho f_i(x)) \right].$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It can be shown that the KS function is convex and smooth.&lt;/p&gt;&#xA;&lt;p&gt;I am wondering, which algorithm should I be using to minimize &lt;span class=&quot;math-container&quot;&gt;$KS[\{ f_i \}_{i \in I}]$&lt;/span&gt; over some 'easy' constraints such as convex quadratic constraints? Is there an optimization solver that would solve this problem easily? I imagine this depends on the functions &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt;, so as a starting point, I am happy with them being convex quadratic or geometric functions.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="491" LastEditDate="2022-02-17T13:47:56.950" LastActivityDate="2022-02-17T16:09:56.547" Title="Minimizing a KS function" Tags="|solver|convex-optimization|algorithms|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7863" PostTypeId="1" CreationDate="2022-02-17T07:34:14.090" Score="7" ViewCount="1780" Body="&lt;p&gt;Recently, I thought of the following &amp;quot;game&amp;quot; that I would like to frame as an optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SqV42.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SqV42.png&quot; alt=&quot;Enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Assume there are five baskets. The first basket has five discrete objects (e.g., apples), the second basket has three discrete objects (e.g., oranges), the third basket has one discrete object (e.g., a watermelon), and the fourth and fifth baskets have 11 kilograms of some continuous object (e.g. coffee and rice - not the right analogy, but bear with me)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Assume that there exists some &amp;quot;mysterious unobservable (discrete and non-differentiable) black box function&amp;quot; which assigns a cost to combinations of objects from different baskets. For example: &lt;strong&gt;A1,A2, B2, D = (1 - 2.5), E = (6.1 - 7, 8.1 - 9.2)&lt;/strong&gt; might have a cost of &amp;quot;7.1&amp;quot; and &lt;strong&gt;A1,A3, B1, C = C1 D = (1 - 8), E = (5.1 - 5.5)&lt;/strong&gt; might have a cost of &amp;quot;8.773&amp;quot;. We have no idea how this cost is calculated, and we just have this mysterious function that assigns costs to different combinations of items from these baskets.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;For this &amp;quot;game&amp;quot;, here are the rules:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There are three players.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The first player chooses some items from some of these five baskets; they have the choice of ignoring baskets if they want (e.g. &lt;strong&gt;A1, A2, C1, D = (1 - 3.1)&lt;/strong&gt; ). From the remaining items, the second player chooses some combination of items. Finally, the third player chooses items from the remainder (at the end, some items can remain unchosen by all three players).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Once each player has made their selections, the &amp;quot;mysterious function&amp;quot; assigns a cost to each of their selections.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This function has the general form of: &lt;strong&gt;f(selection A = a, B = b, C = c, D = d, E = e) = cost&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Let's say for the purpose of this game, the cost function isn't always &amp;quot;monotonic&amp;quot;. For example f(A = A1, B = 0, C = 0, D = 0, E = 0) = 3.1, f(A = A2 , B = 0, C = 0, D = 0, E = 0) = 1.6, f(A = (A1, A2) , B = 0, C = 0, D = 0, E = 0 ) = 0.89.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;The goal of the game is for:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Objective:&lt;/strong&gt; The cost of each player's selection to be less than 10 but as close to 10 as possible&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Constraint:&lt;/strong&gt; Each player should at least have one red Square in their selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Thus - what is the optimal selection that each player should make such that the objective is maximized and the constraint is met?&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To me, this &amp;quot;game&amp;quot; seems to be some variant of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Knapsack_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;knapsack optimization problem&lt;/a&gt; or an assignment/resource allocation problem. In particular, this seems to be a discrete combinatorial gradient-free optimization problem.&lt;/p&gt;&#xA;&lt;p&gt;Suppose these three players can play this game over and over while they study &amp;quot;how their selections influence the overall cost&amp;quot; and &amp;quot;which selections result in the cost function being closer to the desired value&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;For instance:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Round 1:&lt;/strong&gt; Player_1_Cost = 12.1, Player_2_Cost = 8.5, Player_3_Cost = 19.11.  Total Cost = 30 - 39.7 = - 9 .7&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Round 2:&lt;/strong&gt; Player_1_Cost = 1.5, Player_2_Cost = 0.5, Player_3_Cost = 0.  Total Cost = 30 - 2 = + 28&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Round 1000:&lt;/strong&gt; Player_1_Cost = 9.5, Player_2_Cost = 7, Player_3_Cost = 8  Total Cost = 30 - 24.5 = + 5.5&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In this case, the players would keep playing the game until they start to &amp;quot;learn&amp;quot; which selections will result in the &amp;quot;Total Cost&amp;quot; being closest to 0. At first, the players might simply pick random selections and observe the &amp;quot;Total Cost.&amp;quot; Later, they might use a more sophisticated approach such as &lt;a href=&quot;https://en.wikipedia.org/wiki/Evolutionary_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;evolutionary algorithms&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Metaheuristic&quot; rel=&quot;nofollow noreferrer&quot;&gt;metaheuristics&lt;/a&gt; to &amp;quot;strategically combine&amp;quot; successful selections from the past and gradually progress towards more optimal selections:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WEbrE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WEbrE.png&quot; alt=&quot;Enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can this &amp;quot;game&amp;quot; that I have created be interpreted as a (discrete combinatorial) optimization problem? Does this problem that I have created correspond to some a preexisting type of optimization problem?**&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="500" LastEditDate="2022-04-11T01:01:15.307" LastActivityDate="2022-04-11T01:01:15.307" Title="Does this game that I invented correspond to a valid optimization problem?" Tags="|optimization|combinatorial-optimization|heuristics|metaheuristics|puzzles-games|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="7864" PostTypeId="1" CreationDate="2022-02-17T09:58:13.340" Score="2" ViewCount="60" Body="&lt;p&gt;I am interested in a minimum bipartite matching problem, where some edges are missing (i.e., not valid). An intuitive way to solve the problem is to add very large costs for these missing edges and then they can be treated as valid edges so the Hungarian algorithm can be used. However, if the original graph is sparse (or have massive missing edges), adding edges may increase computational complexity. So, I am wondering if there is a better way to deal with the missing edges to keep the sparse structure of the graph when using the Hungarian algorithm.&lt;/p&gt;&#xA;&lt;p&gt;Though I am not sure, maybe some data structure modification for the Hungarian algorithm can be helpful?&lt;/p&gt;&#xA;" OwnerUserId="5274" LastEditorUserId="491" LastEditDate="2022-02-17T13:45:13.757" LastActivityDate="2022-02-17T13:45:13.757" Title="Solving minimum bipartite matching with missing edges using Hungarian algorithm" Tags="|mixed-integer-programming|combinatorial-optimization|assignment-problem|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7865" PostTypeId="2" ParentId="7863" CreationDate="2022-02-17T10:33:50.103" Score="7" Body="&lt;p&gt;Your game does not fall into classical discrete optimization as the objective is unknown. As soon as the blackbox function is fully know (or one supposes a model with fixed parameters for it) it would though. However even then due to the probably nonlinear nature of your black box i doubt there is a specific name for MINLP problem that agents solve each round.&lt;/p&gt;&#xA;&lt;p&gt;Further thoughts:&lt;/p&gt;&#xA;&lt;p&gt;Given that Agents 1 objective i don't see why it would cooperate with other agents to help explore the assignment space if it found an assignment that is good enough for it. And similarly Agent 2 does not care whether Agent 3 is left with a solvable problem. So i am not sure rational agents playing this game would necessarily converge towards a solution with Total Cost &lt;span class=&quot;math-container&quot;&gt;$= 30$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Objective: The cost of each player's selection to be less than 10 ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This part of the objective is not computable, it sounds more like a constraint, if you want to express this as an objective one could say for example: the objective is &lt;span class=&quot;math-container&quot;&gt;$3||x-10||$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x&amp;lt;10$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$||x-10||$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x \geq 10$&lt;/span&gt;;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-02-17T10:33:50.103" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="7866" PostTypeId="2" ParentId="7862" CreationDate="2022-02-17T11:17:47.050" Score="2" Body="&lt;p&gt;I see two interesting options, the first one is a generic NLP solver which might use an interior point (IPOPT) or an SQP (&lt;a href=&quot;https://en.wikipedia.org/wiki/Sequential_quadratic_programming#Implementations&quot; rel=&quot;nofollow noreferrer&quot;&gt;List&lt;/a&gt;) approach. The other options is that according to my vague (and maybe wrong) understanding of conic programming that conic programming might be an interesting approach. the &lt;span class=&quot;math-container&quot;&gt;$\ln$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\exp$&lt;/span&gt; terms could be model as exponential cones while convex quadratic constraints could be expressed in a power cone. As for how far your f can be modeled in that framework i can't tell, just if it is non-convex then conic programming will not work and you have to rely on a generic NLP solver, which is no longer guaranteed to find a global optimum either. In this case you have to look into global NLP solvers and best ask a separate question.&lt;/p&gt;&#xA;&lt;p&gt;For conic problem &lt;a href=&quot;https://www.mosek.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek&lt;/a&gt; has a solver. However i would recommend using the JuMP modeling language as that can create problems that can be called by many solvers including free solvers. For an introduction have a look into &lt;a href=&quot;https://arxiv.org/abs/2005.01136&quot; rel=&quot;nofollow noreferrer&quot;&gt;this publication&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2022-02-17T11:37:01.087" LastActivityDate="2022-02-17T11:37:01.087" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7867" PostTypeId="2" ParentId="7862" CreationDate="2022-02-17T14:54:42.583" Score="1" Body="&lt;p&gt;Some NLP solvers may be sensitive to how the model is formulated/presented,&#xA;so you may wish to try alternative formulations for each NLP solver you try.&#xA;At one extreme, the &amp;quot;atomic&amp;quot; formulation is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  minimize (1/rho)*LN( w);&#xA;   w = sum( i: u_i);&#xA;   For each i:&#xA;    { u_i = exp( v_i);&#xA;      v_i = rho*f_i(x_i);&#xA;    };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So if early in the optimization iterations the solver decides that&#xA;certain of the &lt;code&gt;x_i&lt;/code&gt; should be at a bound, the solver can avoid&#xA;recomputing the associated &lt;code&gt;f_i(x_i)&lt;/code&gt; and &lt;code&gt;exp( v_i)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastEditorUserId="123" LastEditDate="2022-02-17T16:09:56.547" LastActivityDate="2022-02-17T16:09:56.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7868" PostTypeId="2" ParentId="7863" CreationDate="2022-02-17T17:22:24.073" Score="4" Body="&lt;p&gt;If we strip away the game aspects, this might be related to &lt;a href=&quot;https://en.wikipedia.org/wiki/Simulation-based_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;simulation optimization&lt;/a&gt;. Your black box is not stochastic, but simulation optimization methods do apply to deterministic simulations as well.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-17T17:22:24.073" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7869" PostTypeId="2" ParentId="7833" CreationDate="2022-02-17T21:03:54.613" Score="2" Body="&lt;p&gt;First, a note: strict inequality constraints are generally not tolerated in a math programming model. So your first constraint will be interpreted as &lt;span class=&quot;math-container&quot;&gt;$0 \le I_{i,v} \le I_{max}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As best I can tell (and assuming that the only variables are the &lt;span class=&quot;math-container&quot;&gt;$I_{i,v}$&lt;/span&gt;), your constraints are linear. However, this is &lt;em&gt;not&lt;/em&gt; a convex optimization problem. The good news is that the feasible region is convex. The bad news is that you are minimizing what you say is a concave function. (I'll take you word regarding the concavity. The plot seems consistent with it.) To have a convex optimization problem, you would need either to minimize a convex objective or maximize a concave one.&lt;/p&gt;&#xA;&lt;p&gt;If you search &amp;quot;minimization of concave function over convex set&amp;quot; you will find some references. I am not personally familiar with any of them, so I cannot make a recommendation.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-17T21:03:54.613" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7870" PostTypeId="1" CreationDate="2022-02-18T03:17:17.207" Score="4" ViewCount="36" Body="&lt;p&gt;Consider the following nonlinear optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;&amp;amp;\min f(x) \\&#xA;\text{such that } &amp;amp;h_1(x) = 0, \\&#xA;&amp;amp;h_2(x) = 0, \\&#xA;&amp;amp; \vdots \\&#xA;&amp;amp; h_m(x) = 0,&#xA;\end{align*}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^n$&lt;/span&gt;. Suppose that the linear independence constraint qualification (LICQ) holds over the entire feasible region. Then, recall that we say that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a first order critical point if there exists &lt;span class=&quot;math-container&quot;&gt;$\lambda \in \mathbb{R}^m$&lt;/span&gt; such that&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\nabla f(x) - \sum_{i = 1}^m \lambda_i \nabla  h_i(x) = 0.&#xA;\end{equation}&lt;/span&gt;&#xA;Furthermore, if such a &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; exists it is unique.&lt;/p&gt;&#xA;&lt;p&gt;First-order criticality (aka being a first-order critical point) is a necessary condition for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to be a local minimum. I know many algorithms exist which converge to first-order critical points.&lt;/p&gt;&#xA;&lt;p&gt;Now, let &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; denote a &lt;em&gt;global minimum&lt;/em&gt; for the nonlinear program above. Let &lt;span class=&quot;math-container&quot;&gt;$\lambda^*$&lt;/span&gt; denote the unique multiplier such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\nabla f(x^*) - \sum_{i = 1}^m \lambda_i^* \nabla  h_i(x^*) = 0.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Suppose I magically know &lt;span class=&quot;math-container&quot;&gt;$\lambda^*$&lt;/span&gt;, and I would like to obtain &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;. In fact, suppose I even know that every first-order critical point whose associated multiplier is &lt;span class=&quot;math-container&quot;&gt;$\lambda^*$&lt;/span&gt; is globally optimal, and vice versa. In other words, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is globally optimal if and only if&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\nabla f(y) - \sum_{i = 1}^m \lambda_i^* \nabla  h_i(y) = 0.&#xA;$$&lt;/span&gt;&#xA;So I basically know precisely what the multiplier associated with the first-order criticality condition should be for any the global minimum.&lt;/p&gt;&#xA;&lt;p&gt;Is there any nonlinear programming algorithm which could effectively use this information to converge to such a &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;? Obviously one approach would be to try to find a feasible point of the following system:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;h_1(y) = 0, \\&#xA;&amp;amp;h_2(y) = 0, \\&#xA;&amp;amp; \vdots \\&#xA;&amp;amp; h_m(y) = 0, \\&#xA;&amp;amp;\nabla f(y) - \sum_{i = 1}^m \lambda_i^* \nabla  h_i(y) = 0.&#xA;\end{align}&lt;/span&gt;&#xA;But this might be very hard, even if finding a feasible &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; for the original optimization problem is easy. Thus, I'm wondering if there is some nonlinear programming algorithm which could make use of the fact that we know what the &amp;quot;correct&amp;quot; multipliers are, without just bluntly solving the feasibility problem above, which may be very difficult to solve.&lt;/p&gt;&#xA;&lt;p&gt;There isn't much else we can assume about the original program. Strong duality, for example, doesn't hold.&lt;/p&gt;&#xA;&lt;p&gt;Even references/ideas are much appreciated, as I'm not an expert in this area!&lt;/p&gt;&#xA;" OwnerUserId="9202" LastEditorUserId="491" LastEditDate="2022-02-18T14:14:57.057" LastActivityDate="2022-02-18T14:14:57.057" Title="Does knowing the &quot;correct multipliers&quot; for globally optimal first-order critical points help you algorithmically?" Tags="|optimization|nonlinear-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7872" PostTypeId="1" CreationDate="2022-02-18T07:16:19.383" Score="1" ViewCount="73" Body="&lt;p&gt;I used &lt;code&gt;TOPSIS&lt;/code&gt; multicriteria method to select the best number of clusters out of the 34 options. As weights I used 0.5 for each criterion. The &lt;code&gt;coverage&lt;/code&gt; criterion is to minimize and the &lt;code&gt;production&lt;/code&gt; criterion is to maximize. With these same conditions, I would like to use the &lt;code&gt;PROMETHEE&lt;/code&gt; multicriteria method. From what I saw there is a PROMETHEE package in R (&lt;a href=&quot;https://cran.r-project.org/web/packages/PROMETHEE/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cran.r-project.org/web/packages/PROMETHEE/index.html&lt;/a&gt;), but unfortunately I couldn't do it for my case.&lt;/p&gt;&#xA;&lt;p&gt;Can you help me?&lt;/p&gt;&#xA;&lt;p&gt;I left the &lt;code&gt;TOPSIS&lt;/code&gt; code to give you an idea of what I want, which is to rank the best alternatives. In this case, the best option is the cluster number equal to 2, as it ranked 1st.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;library(topsis)&#xA;&#xA;df1&amp;lt;-structure(list(nclusters = c(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, &#xA;12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, &#xA;28, 29, 30, 31, 32, 33, 34, 35), Coverage = c(0.0363201192049018, &#xA;0.0315198954715543, 0.112661460735583, 0.112661460735583, 0.112661460735583, &#xA;0.0813721071219816, 0.0862146652218061, 0.0697995564757394, 0.0599194966471805, &#xA;0.0507632014547115, 0.052076958349629, 0.052076958349629, 0.052076958349629, &#xA;0.052076958349629, 0.052076958349629, 0.052076958349629, 0.0410332568832433, &#xA;0.0389940601722214, 0.0441742111970355, 0.0441742111970355, 0.0441742111970355, &#xA;0.0438099091238968, 0.0409906284310306, 0.0409906284310306, 0.035480410134286, &#xA;0.035480410134286, 0.035480410134286, 0.035480410134286, 0.035480410134286, &#xA;0.035480410134286, 0.035480410134286, 0.0345381204372174, 0.0287729883480053, &#xA;0.0287729883480053), Production = c(1635156.04305, 474707.64025, &#xA;170773.40775, 64708.312, 64708.312, 64708.312, 949.72635, 949.72635, &#xA;949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 949.72635, &#xA;949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 949.72635, &#xA;949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 949.72635, &#xA;949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 949.72635, &#xA;949.72635, 949.72635)), class = &amp;quot;data.frame&amp;quot;, row.names = c(NA,-34L))&#xA; &#xA;row.names(df1) &amp;lt;- df1$nclusters&#xA;df2 &amp;lt;- df1[c(2:3)]&#xA;df2&amp;lt;-data.matrix(df2)&#xA;w &amp;lt;- c(0.5,0.5) &#xA;i &amp;lt;- c(&amp;quot;-&amp;quot;, &amp;quot;+&amp;quot;) &#xA;result&amp;lt;-topsis(df2, w, i)&#xA;result&amp;lt;-data.frame(nclusters = df1[,1],result[,2:3])&#xA;&#xA;&amp;gt; result&#xA;   nclusters      score rank&#xA;1          2 0.97709831  1.0&#xA;2          3 0.35391229  2.0&#xA;3          4 0.09999171 30.0&#xA;4          5 0.03763326 33.5&#xA;5          6 0.03763326 33.5&#xA;6          7 0.09914059 31.0&#xA;7          8 0.07676999 32.0&#xA;8          9 0.11960647 29.0&#xA;9         10 0.14366970 28.0&#xA;10        11 0.16484786 21.0&#xA;11        12 0.16187453 24.5&#xA;12        13 0.16187453 24.5&#xA;13        14 0.16187453 24.5&#xA;14        15 0.16187453 24.5&#xA;15        16 0.16187453 24.5&#xA;16        17 0.16187453 24.5&#xA;17        18 0.18619947 16.0&#xA;18        19 0.19052672 13.0&#xA;19        20 0.17943485 19.0&#xA;20        21 0.17943485 19.0&#xA;21        22 0.17943485 19.0&#xA;22        23 0.18022565 17.0&#xA;23        24 0.18629045 14.5&#xA;24        25 0.18629045 14.5&#xA;25        26 0.19786466  9.0&#xA;26        27 0.19786466  9.0&#xA;27        28 0.19786466  9.0&#xA;28        29 0.19786466  9.0&#xA;29        30 0.19786466  9.0&#xA;30        31 0.19786466  9.0&#xA;31        32 0.19786466  9.0&#xA;32        33 0.19980731  5.0&#xA;33        34 0.21146288  3.5&#xA;34        35 0.21146288  3.5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9063" LastEditorUserId="9063" LastEditDate="2022-02-18T16:59:25.247" LastActivityDate="2022-02-20T19:05:01.880" Title="How to use PROMETHEE multicriteria method in R" Tags="|optimization|multi-objective-optimization|r|multicriteria-decision-analysis|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7873" PostTypeId="1" AcceptedAnswerId="7899" CreationDate="2022-02-18T09:31:54.373" Score="5" ViewCount="417" Body="&lt;p&gt;I'm trying to solve an MINLP problem where the following division term is appearing in the objective:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_r = \frac{x_{ry}}{\sum_r d_r x_{ry}}, \forall r, y,$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_{ry}$&lt;/span&gt; is a 2D binary variable and &lt;span class=&quot;math-container&quot;&gt;$d_r$&lt;/span&gt; is a non-zero real number. In addition, there is a constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_r x_{ry} \leq 1$&lt;/span&gt;. Is there a suitable way to linearize this division?&lt;/p&gt;&#xA;&lt;p&gt;I tried to use a new variable &lt;span class=&quot;math-container&quot;&gt;$M_r = z_r \times \sum_r d_r x_{ry}$&lt;/span&gt;, but the situation is still the same for the commercial solvers.&lt;/p&gt;&#xA;" OwnerUserId="9204" LastEditorUserId="491" LastEditDate="2022-02-18T14:14:10.980" LastActivityDate="2022-02-21T15:40:09.770" Title="Can we linearize the division of a binary variable by a continuous variable?" Tags="|mixed-integer-programming|linearization|reformulation-linearization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7874" PostTypeId="2" ParentId="7831" CreationDate="2022-02-18T09:41:39.823" Score="12" Body="&lt;p&gt;In the open-access paper &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/opre.50.1.42.17798&quot; rel=&quot;noreferrer&quot;&gt;George B. Dantzig, (2002) Linear Programming. Operations Research 50(1):42-47&lt;/a&gt;, the mathematician behind the simplex method writes:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The term simplex method arose out of a discussion with T. Motzkin who&#xA;felt that the approach that I was using, when viewed in the geometry&#xA;of the columns, was best described as a movement from one simplex to a&#xA;neighboring one.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;What exactly Motzkin had in mind is anyone's guess, but the interpretation provided by &lt;a href=&quot;https://www.youtube.com/watch?v=Ci1vBGn9yRc&quot; rel=&quot;noreferrer&quot;&gt;this lecture video of Prof. Craig Tovey&lt;/a&gt; (credit to &lt;a href=&quot;https://or.stackexchange.com/users/562/samarth&quot;&gt;Samarth&lt;/a&gt;) is noteworthy. In it, he explains that any finitely bounded problem,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min c^T x\\&#xA;Ax = b,\\&#xA;0 \leq x \leq u,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;can be scaled to &lt;span class=&quot;math-container&quot;&gt;$e^T u = 1$&lt;/span&gt; without loss of generality. Then by rewritting all upper bound constraints to equations, &lt;span class=&quot;math-container&quot;&gt;$x_j + r_j = u_j$&lt;/span&gt; for slack variables &lt;span class=&quot;math-container&quot;&gt;$r_j \geq 0$&lt;/span&gt;, we have that the sum of all variables (original and slack) equals &lt;span class=&quot;math-container&quot;&gt;$e^T u$&lt;/span&gt; equals one. Hence, all finitely bounded problems can be cast to a formulation of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min c^T x\\&#xA;Ax = b,\\&#xA;e^T x = 1,\\&#xA;x \geq 0,&#xA;$$&lt;/span&gt;&#xA;where the feasible set is simply described as the set of convex combinations of columns in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; that equal &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{m \times n}$&lt;/span&gt;, then a feasible basic solution corresponds to finding &lt;span class=&quot;math-container&quot;&gt;$m+1$&lt;/span&gt; columns of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; such that the &lt;em&gt;simplex&lt;/em&gt; generated by these &lt;span class=&quot;math-container&quot;&gt;$m+1$&lt;/span&gt; columns contains &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. In the simplex method we thus start from a simplex containing &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and iterate by moving to a neighboring simplex containing &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. This sounds a lot like what Motzkin was talking about.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2022-02-18T11:44:21.127" LastActivityDate="2022-02-18T11:44:21.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7875" PostTypeId="1" CreationDate="2022-02-18T11:57:40.910" Score="3" ViewCount="136" Body="&lt;p&gt;This is a follow up to my previous questions &lt;a href=&quot;https://or.stackexchange.com/questions/7842/when-will-constraints-in-an-lp-be-satisfied-as-equalities&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/questions/7850/will-constraints-in-this-lp-be-satisfied-as-equalities/7855#7855&quot;&gt;here&lt;/a&gt; . I've added the assumption that &lt;span class=&quot;math-container&quot;&gt;$m=2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Say &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$n\times 2$&lt;/span&gt; matrix with no negative entries and such that every row and every column have at least a non zero element.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^i$&lt;/span&gt; be the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th row of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt; and assume further that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^i\not\leq\mathbf{x}^j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^j\not\leq\mathbf{x}^i\;\forall i,j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Denote &lt;span class=&quot;math-container&quot;&gt;$\langle\mathbf{X}\rangle$&lt;/span&gt; the cone spanned by &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q},\mathbf{k}, 1$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; be vectors of the suitable dimension. In the following LP&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;  \text{maximize} &amp;amp;\quad \mathbf{q}\cdot 1\\&#xA;  \text{subject to} &amp;amp; \quad \mathbf{X}^{\top}\mathbf{q}\leq\mathbf{k}\\ &amp;amp;\quad\mathbf{q}\geq 0,&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^*$&lt;/span&gt; be its solution. I see that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\not\in\langle\mathbf{X}\rangle\implies \mathbf{X}^{\top}\mathbf{q}^*\leq\mathbf{k}$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}^{\top}\mathbf{q}^*\ne\mathbf{k}$&lt;/span&gt;), because &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\not\in\langle\mathbf{X}\rangle$&lt;/span&gt; implies that there does not exist a set of positive weights satisfying &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}^{\top}\mathbf{q}=\mathbf{k}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, I believe that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\in\langle\mathbf{X}\rangle\implies \mathbf{X}^{\top}\mathbf{q}^*=\mathbf{k}$&lt;/span&gt;. Is this true? Why?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; For my purposes, it would be enough to show that this is true for the &lt;span class=&quot;math-container&quot;&gt;$n=2$&lt;/span&gt; case. I'm trying to understand the linear case in the hope of being able to generalize the result to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;  \text{maximize} &amp;amp;\quad \mathbf{q}\cdot 1\\&#xA;  \text{subject to} &amp;amp; \quad \mathbf{X}^{\top}\mathbf{q}^{\beta}\leq\mathbf{k}\\ &amp;amp;\quad\mathbf{q}\geq 0,&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$\beta&amp;gt;1$&lt;/span&gt; and where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^{\beta}=(q_1^\beta,\dots,q_n^\beta)$&lt;/span&gt;. I believe this to be true for &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\in\langle\mathbf{Z}\rangle\subseteq\langle\mathbf{X}\rangle$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Also, ideas about why this does not hold for &lt;span class=&quot;math-container&quot;&gt;$n\times m$&lt;/span&gt; matrices (with &lt;span class=&quot;math-container&quot;&gt;$m&amp;gt;2$&lt;/span&gt;) would be appreciated.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt;&#xA;For the &lt;span class=&quot;math-container&quot;&gt;$n=2$&lt;/span&gt; case, let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt; be such that &lt;span class=&quot;math-container&quot;&gt;$0\leq x_{11}&amp;lt;x_{21}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0\leq x_{22}&amp;lt;x_{12}$&lt;/span&gt; and proceed by contradiction. Suppose without loss of generality that &lt;span class=&quot;math-container&quot;&gt;$q^*_1 x_{11}+q^*_2 x_{21}=c&amp;lt;k_1$&lt;/span&gt; while &lt;span class=&quot;math-container&quot;&gt;$q^*_1 x_{12}+q^*_2 x_{22}=k_2$&lt;/span&gt;. Consider &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\bar q}=(q^*_1-\delta_1,q^*_2+\delta_2)$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$\delta_1,\delta_2&amp;gt;0$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$(q^*_1-\delta_1) x_{12}+(q^*_2 +\delta_2) x_{22}=k_2$&lt;/span&gt;. Clearly this implies that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\delta_1=\frac{x_{22}}{x_{12}}\delta_2.$$&lt;/span&gt;&#xA;We now have&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;   (q^*_1-\delta_1) x_{11}+(q^*_2+\delta_2) x_{21}&amp;amp;=\left(q^*_1-\frac{x_{22}}{x_{12}}\delta_2\right) x_{11}+(q^*_2+\delta_2) x_{21}\\&#xA;&amp;amp;=c+\delta_2\left(x_{21}-\frac{x_{22}}{x_{12}}x_{11}\right).&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The term in parenthesis is positive and we can choose &lt;span class=&quot;math-container&quot;&gt;$$\delta_2=\frac{k_1-c}{x_{21}x_{12}-x_{22}x_{11}}x_{12}&amp;gt;0.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The change in the objective is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\delta_2-\delta_1=\delta_2\left(1-\frac{x_{22}}{x_{12}}\right)&amp;gt;0,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;because of the assumption &lt;span class=&quot;math-container&quot;&gt;$x_{22}&amp;lt;x_{12}.$&lt;/span&gt; Hence, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^*$&lt;/span&gt; is not a maximum.&lt;/p&gt;&#xA;&lt;p&gt;I believe this shows that indeed &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\in\langle\mathbf{X}\rangle\implies \mathbf{X}^{\top}\mathbf{q}^*=\mathbf{k}$&lt;/span&gt;. My questions are now&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is my proof correct?&lt;/li&gt;&#xA;&lt;li&gt;Why can't this be generalized to &lt;span class=&quot;math-container&quot;&gt;$n\times m$&lt;/span&gt; matrices when &lt;span class=&quot;math-container&quot;&gt;$m&amp;gt;2$&lt;/span&gt;? In the &lt;span class=&quot;math-container&quot;&gt;$2\times 2$&lt;/span&gt; case it was easy to identify the direction in which to perturb the claimed solution to show that it did not lead to a maximum, but the fact that this doesn't hold for &lt;span class=&quot;math-container&quot;&gt;$3\times 3$&lt;/span&gt; matrices suggests that in higher dimensions this direction may not exist altogether and I cannot see why.&lt;/li&gt;&#xA;&lt;li&gt;How should I proceed in order to extend this result to the non-linear constraints in the second program above?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2391" LastEditorUserId="2391" LastEditDate="2022-02-24T11:12:37.753" LastActivityDate="2022-02-28T16:11:57.293" Title="Will all constraints in this LP be binding?" Tags="|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7876" PostTypeId="2" ParentId="7841" CreationDate="2022-02-18T14:38:42.553" Score="4" Body="&lt;p&gt;First, it is confusing when you say&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The final solution does not satisfy the workforce requirements for the&#xA;various time windows, it's substantially short. Only 5 shifts are&#xA;filled in total.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You do not want to fill in shifts, but time windows. You select shifts in order to satisfy workforce requirements for each time slot.&lt;/p&gt;&#xA;&lt;p&gt;I suspect you have some issues with your shifts, when you translate them from the format&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Shift_Num&lt;/th&gt;&#xA;&lt;th&gt;Start_Shift&lt;/th&gt;&#xA;&lt;th&gt;First_Break_Start&lt;/th&gt;&#xA;&lt;th&gt;First_Break_End&lt;/th&gt;&#xA;&lt;th&gt;Lunch_Start&lt;/th&gt;&#xA;&lt;th&gt;Lunch_End&lt;/th&gt;&#xA;&lt;th&gt;Second_Break_Start&lt;/th&gt;&#xA;&lt;th&gt;Second_Break_End&lt;/th&gt;&#xA;&lt;th&gt;End_Shift&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;to the format with &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; min time slots. For example, shift &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; should be (if I am not mistaken) :&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kJbvt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kJbvt.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;With the table of shifts added by the OP, removing the set of time slots which cannot be covered at all (after 4:00 PM), and with &lt;span class=&quot;math-container&quot;&gt;$w_j=1$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$j=1,2,16,17,31$&lt;/span&gt;, I get a total of 9 shifts (shift &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;, shift &lt;span class=&quot;math-container&quot;&gt;$17$&lt;/span&gt; (4 times), and shift &lt;span class=&quot;math-container&quot;&gt;$31$&lt;/span&gt; (4 times)):&lt;/p&gt;&#xA;&lt;p&gt;Here is the code I used (shifts.csv is a csv file with shifts OP posted in the last table):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pulp&#xA;from pandas import read_csv&#xA;&#xA;df = read_csv(&amp;quot;shifts.csv&amp;quot;, sep=&amp;quot;;&amp;quot;)&#xA;&#xA;a = df.drop(columns=[&amp;quot;num_workers_required&amp;quot;]).values&#xA;&#xA;# number of shifts&#xA;n = a.shape[1]&#xA;&#xA;# number of time windows&#xA;T = a.shape[0]&#xA;&#xA;# of workers required per time window&#xA;d = df[&amp;quot;num_workers_required&amp;quot;].values&#xA;&#xA;# labor hours per shift&#xA;# w = shift_hours[&amp;quot;Shift_Hours&amp;quot;].values.astype(int)&#xA;&#xA;# Decision Variables&#xA;y = pulp.LpVariable.dicts(&amp;quot;num_workers&amp;quot;, list(range(n)), lowBound=0, cat=&amp;quot;Integer&amp;quot;)&#xA;&#xA;# Create Problem&#xA;prob = pulp.LpProblem(&amp;quot;Schedule_Creation&amp;quot;, pulp.LpMinimize)&#xA;&#xA;# Minimize Labor Hours&#xA;prob += pulp.lpSum([y[j] for j in range(n)])&#xA;&#xA;# Constraint for workers required in each time window&#xA;for t in range(T):&#xA;    prob += pulp.lpSum([a[t, j] * y[j] for j in range(n)]) &amp;gt;= d[t]&#xA;&#xA;prob.solve()&#xA;&#xA;print(&amp;quot;Status:&amp;quot;, pulp.LpStatus[prob.status])&#xA;&#xA;for shift in range(n):&#xA;    print(&#xA;        f&amp;quot;The number of workers needed for shift {shift} is {(y[shift].value())} workers&amp;quot;&#xA;    )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And here is the output:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OwB3N.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OwB3N.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum 2&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;With &lt;a href=&quot;https://1drv.ms/u/s!AvGYt1DQumYhg2JRJCVAd8HQXOuA?e=THaBUj&quot; rel=&quot;nofollow noreferrer&quot;&gt;this data&lt;/a&gt; (and &lt;span class=&quot;math-container&quot;&gt;$w_j=1$&lt;/span&gt; for every shift &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;), I get the following optimal solution: shifts 15, 36, 91 (twice), 94, i.e., 5 shifts. This solution is not unique. And this solution is feasible, as the orange line always lies above the blue line in the Figure below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fbQRY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fbQRY.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Cy7vt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cy7vt.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I think part of the confusion may come from the fact that in the data, the index of the first shift is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, while it is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; in the python code. So when the solver selects shifts 14, 35, 90, 93, it is actually pointing to shifts 15, 36, 91, 94 in the file with the raw data.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-02-21T15:01:24.177" LastActivityDate="2022-02-21T15:01:24.177" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7877" PostTypeId="2" ParentId="7689" CreationDate="2022-02-18T15:21:55.270" Score="1" Body="&lt;p&gt;Online optimization can be solved deterministic or in a stochastic manner.&lt;/p&gt;&#xA;&lt;p&gt;Stochastic optimization is a wide concept which includes Stochastic program, Robust optimization, MDP, ADP, RL, Model predictive control, and so on...&lt;/p&gt;&#xA;&lt;p&gt;Robust optimization is a famous area of stochastic optimization, which treats uncertainty quite differently than others. It develops an uncertainty set in which the uncertainty is realized, and solves for robust optimal/feasible solutions.&#xA;Robust feasible means that any solution x is feasible for any realization of uncertain parameters in the uncertainty set, and Robust optimal means that it is optimal among those robust feasible solutions.&lt;/p&gt;&#xA;" OwnerUserId="4130" LastActivityDate="2022-02-18T15:21:55.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7878" PostTypeId="1" AcceptedAnswerId="7897" CreationDate="2022-02-18T16:33:13.107" Score="2" ViewCount="182" Body="&lt;p&gt;Here is my simple LP problem for a constant symmetric positive matrix &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; and continuous decision variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad\sum{x_i}\\\text{s.t.}&amp;amp;\quad&#xA;x_i + x_j \leq d_{ij}\\&amp;amp;\quad&#xA;x_i \geq 0\\&amp;amp;\quad&#xA;i \in [0,n)\\&amp;amp;\quad&#xA;j \in [i+1,n)\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What is the dual form of this? What's the general approach for finding a dual of this form?&lt;/p&gt;&#xA;" OwnerUserId="7428" LastEditorUserId="123" LastEditDate="2022-02-18T16:56:26.047" LastActivityDate="2022-02-19T22:01:04.927" Title="What is the dual of this LP?" Tags="|linear-programming|duality|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7880" PostTypeId="1" AcceptedAnswerId="7881" CreationDate="2022-02-18T17:21:19.070" Score="7" ViewCount="379" Body="&lt;p&gt;Suppose I have a linear program (LP) that has many optimal solutions. Of those optima, I want to find the optimum that activates (aka, &amp;quot;pegs&amp;quot; or &amp;quot;bumps&amp;quot;) the largest number of constraints. Is there a general mechanism to achieve this?&lt;/p&gt;&#xA;&lt;p&gt;I was able to achieve what I wanted via MIP by duplicating the constraints and adding a binary variable for each of the duplicates -- an &amp;quot;enabler&amp;quot;. I then maximize the sum of those. It gives very good results. However, this takes my 30ms LP to two minutes of processing (using Gurobi), and that's not an acceptable delay.&lt;/p&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2022-02-18T19:10:00.020" Title="how can I modify my LP to activate the most constraints possible?" Tags="|linear-programming|indicator-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7881" PostTypeId="2" ParentId="7880" CreationDate="2022-02-18T17:28:44.693" Score="8" Body="&lt;p&gt;Suppose your problem is of the form &lt;span class=&quot;math-container&quot;&gt;$\min c^Tx$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$Ax+e =b$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; denotes the slack variables.&lt;/p&gt;&#xA;&lt;p&gt;You could proceed in two steps.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Solve the initial LP. Let &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt; be the value of the optimal solution.&lt;/li&gt;&#xA;&lt;li&gt;Solve the initial LP with the following modifications: add the constraint that the objective function must equal &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$c^Tx = z^*$&lt;/span&gt;), and instead minimize the sum of the slack variables (&lt;span class=&quot;math-container&quot;&gt;$\mathbb{1}^Te$&lt;/span&gt;), or perhaps the largest slack variable (&lt;span class=&quot;math-container&quot;&gt;$\max_i \{e_i\}$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Maybe it is also worth trying to directly minimize the slack variables along with &lt;span class=&quot;math-container&quot;&gt;$c^Tx$&lt;/span&gt;, but this might degrade the objective function value:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min c^T x + w^Te&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mbox{subject to } Ax+e = b&#xA;$$&lt;/span&gt;&#xA;You will have to tweak &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="500" LastEditDate="2022-02-18T18:16:43.213" LastActivityDate="2022-02-18T18:16:43.213" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7882" PostTypeId="2" ParentId="7880" CreationDate="2022-02-18T19:10:00.020" Score="4" Body="&lt;p&gt;Finding all optima of a linear program can be NP-annoying, so finding the optimum with the most binding constraints is likely also NP-annoying.&lt;/p&gt;&#xA;&lt;p&gt;The multiple optima will be vertices of a facet of the feasible region, so you can explore them by sliding along edges of the optimal facet.  A heuristic approach would be as follows. First, solve the LP. Find a nonbasic variable whose reduced cost is 0 and pivot it into the basis, taking you to another vertex. Keep track of each basis visited (you just need to record a boolean vector indicating which variables are basic or the list of basic variables; you don't need to record variable values) and if you wind up at a vertex already visited, don't pick the same nonbasic variable for the next pivot (to avoid looping). Repeat until you can't find a new pivot to make or you run out of time. Obviously, at each vertex you'll count active constraints and retain as incumbent the vertex with the most active constraints.&lt;/p&gt;&#xA;&lt;p&gt;A slightly more sophisticated approach might use something like &lt;a href=&quot;https://en.wikipedia.org/wiki/Tabu_search&quot; rel=&quot;nofollow noreferrer&quot;&gt;tabu search&lt;/a&gt; to avoid getting stuck in one area of the optimal facet.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-18T19:10:00.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7883" PostTypeId="2" ParentId="7818" CreationDate="2022-02-19T00:12:34.303" Score="3" Body="&lt;p&gt;According to my understanding Transportation theory which covers Monge's Optimal Transport Problem is not concerned with constraints temporary storage of incompatible goods. Furthermore most formulations have an time invariant transport map, meaning those formulation could not represent the time varieying differently directed flow of goods. Yes it would be possible to extend Optimal Transport problem to cover the &amp;quot;Wolf, Goat and Cabbage Riddle&amp;quot; case however calling that a relation is a bit strenous.&lt;/p&gt;&#xA;&lt;p&gt;I am not aware of &amp;quot;these items can not be stored together contraints&amp;quot; in logisitics. Such constraints might occour in cryptography however in this case not a specific problem solved but a generic protocol would be used.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-02-19T00:12:34.303" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7884" PostTypeId="1" CreationDate="2022-02-19T00:30:50.040" Score="3" ViewCount="521" Body="&lt;p&gt;I have the following constraint requirements.&lt;/p&gt;&#xA;&lt;p&gt;2.x1-x2 = 0 OR x1 - 2.x2 = 0&lt;/p&gt;&#xA;&lt;p&gt;x1,x2 are positive integers less than a given value, say 10 for the question&lt;/p&gt;&#xA;&lt;p&gt;How do I implement this? Basically its looking for integers on the line x1 = 2.x2, or x1 = 1/2.x2&lt;/p&gt;&#xA;&lt;p&gt;The solution is clearly not a convex hull. I presume there must be some formulation using a binary variable.&lt;/p&gt;&#xA;&lt;p&gt;Is there a general approach to implementing constraint1 OR constraint2?&lt;/p&gt;&#xA;" OwnerUserId="9208" LastEditorUserId="491" LastEditDate="2022-03-15T14:07:25.050" LastActivityDate="2022-03-15T14:07:25.050" Title="OR condition in a MILP" Tags="|mixed-integer-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7885" PostTypeId="2" ParentId="7884" CreationDate="2022-02-19T01:11:57.710" Score="5" Body="&lt;p&gt;Disjunctions (&amp;quot;or&amp;quot; constraints) are typically implemented by adding a binary variable to choose one disjunct or the other, plus constraints to enforce that choice. What you have in mind can be done with &amp;quot;big M&amp;quot; constraints, provided that your &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables are bounded. Let &lt;span class=&quot;math-container&quot;&gt;$y\in\lbrace 0,1 \rbrace$&lt;/span&gt; be 1 if &lt;span class=&quot;math-container&quot;&gt;$x_1 = 2x_2$&lt;/span&gt; and 0 if &lt;span class=&quot;math-container&quot;&gt;$x_2 = 2x_1$&lt;/span&gt;. Assume that we know a priori that &lt;span class=&quot;math-container&quot;&gt;$x_1 \in [L, U].$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$x_1 = 2x_2,$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$2x_1 - x_2 = 1.5x_1 \in [1.5L, 1.5U].$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$2x_1 = x_2,$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_1 - 2x_2 = -3x_1\in [-3U, -3L].$&lt;/span&gt; Using that, we add the following constraints: &lt;span class=&quot;math-container&quot;&gt;$$-3U(1-y) \le x_1 - 2x_2 \le -3L(1-y)\\ 1.5Ly \le 2x_1 - x_2 \le 1.5Uy.$$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;, the first constraint enforces &lt;span class=&quot;math-container&quot;&gt;$x_1 = 2x_2$&lt;/span&gt; and the second constraint has no effect. If &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, the second constraint enforces &lt;span class=&quot;math-container&quot;&gt;$x_2 = 2x_1$&lt;/span&gt; and the first constraint has no effect.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-19T01:11:57.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7887" PostTypeId="1" AcceptedAnswerId="7888" CreationDate="2022-02-19T02:55:35.897" Score="5" ViewCount="344" Body="&lt;p&gt;I am looking at the looking at the following classical integer programming model for assembly line balancing:&lt;/p&gt;&#xA;&lt;p&gt;R.R.Vemuganti's &amp;quot;Applications of Set Covering, Set Packing and Set Partitioning Models: A Survey&amp;quot;, in Handbook of Combinatorial Optimization (Vol.1) pp.  573-746.&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Assembly Line Balancing&amp;quot; is section 7.1.  There are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; tasks to be done on upto &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; machines (as few as possible) within a time duration &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The task processing times are &lt;span class=&quot;math-container&quot;&gt;$\{t_i |&#xA;   i=1,2,\cdots,n\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The precedence relationships&#xA;consist of a set of node pairs&#xA;&lt;span class=&quot;math-container&quot;&gt;$P=\{(i,j)\implies \text{ task } i \text{&#xA;   precedes task } j \}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is the time by which all tasks must be done&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question: What does the following mean?&lt;/strong&gt; If &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in P$&lt;/span&gt; and tasks &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are assigned to machines &lt;span class=&quot;math-container&quot;&gt;$s(i)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s(j)$&lt;/span&gt;, respectively, then &lt;span class=&quot;math-container&quot;&gt;$s(i)\le s(j)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As far as I can see, machine numbers are categorical data whose magnitudes have no meaning.&lt;/p&gt;&#xA;&lt;p&gt;It looks as if the intent is to have lower numbered machines do tasks that have higher precedence.  Wouldn't this rule out sections of the solution space that could contain better solutions?  I don't see anything that forces task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to finish before task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; just because it is assigned to a lower number machine.&lt;/p&gt;&#xA;&lt;p&gt;In case it provides missing context, here is the integer program:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Binary indicator/decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{ik}=1$&lt;/span&gt;&#xA;if task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to machine &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{ik}=0$&lt;/span&gt; otherwise&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Binary indicator/decision variable &lt;span class=&quot;math-container&quot;&gt;$y_k=1$&lt;/span&gt;&#xA;if machine &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is used and can therefore have&#xA;tasks assigned to it, &lt;span class=&quot;math-container&quot;&gt;$y_k=0$&lt;/span&gt; otherwise&#xA;(the objective function minimizes the number of&#xA;machines used)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i=1,2,\cdots,n \quad \text{and} \quad k=1,2,\cdots,n$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Objective function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\min \sum_{k=1}^n y_k&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;such that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;   \sum_{k=1}^n x_{ik}=1&#xA;   &amp;amp; \quad &amp;amp;&#xA;   i=1,2,\cdots,n&#xA;   \\&#xA;   \sum_{i=1}^n t_i x_{ik} \le c y_k&#xA;   &amp;amp; \quad &amp;amp;&#xA;   k=1,2,\cdots,n&#xA;   \\&#xA;   \sum_{k=1}^h x_{ik}\ge x_{jh}&#xA;   &amp;amp; \quad &amp;amp;&#xA;   (i,j)\in P \quad \text{and} \quad h=1,2,\cdots,n&#xA;\end{eqnarray}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first constraint assigns each task to one machine.&lt;/p&gt;&#xA;&lt;p&gt;The second constraint assgns tasks only to machines that are being used, and ensures that the total work time on that machine doesn't exceed the limit &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The third constraint enforces precedences between tasks. I can see how it forces the machine number for task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to be no smaller than the machine number for task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, but I don't see how this forces task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to finish before task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; starts.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Elaboration on my points of confusion&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The scheduling that I've passingly looked at in decades past consisted of assigning operations to CPUs and deploying assets to different missions.  There are precedence relationships, but they depend on the &lt;em&gt;availability&lt;/em&gt; of CPUs or assets, not the identity label of each CPU/asset.  Since Vemuganti's basic ALB imposes constraints based on station identity, it seems to me (maybe naively) that this unnecessarily constrains the solution space, possibly excluding better solutions than otherwise.&lt;/p&gt;&#xA;&lt;p&gt;I tried to understand the features of the operational problem that necessitate these constraints. The only one I've seen is &lt;em&gt;fontanf&lt;/em&gt;'s answer about the serial arrangement of stations.  I responded with a comment showing that even if they are arranged serially by station number, the flow of stuff don't necessarily follow that sequence. Instead, the outputs of one station can be sent to the input of &lt;em&gt;any&lt;/em&gt; station. This is a lot more like the scheduling I saw in the past, wherein precedences and station numbers are completely unrelated.&lt;/p&gt;&#xA;&lt;p&gt;That is why I think that I'm missing an assumption.  For example is there an unspoken rule that stuff can flow only forward in the sequence of stations, even if they skip stations?  Is this due to common real-world limitations in assembly line environments? It seems like a problem feature that is critical to the mathematical modelling. If it is true, then I wonder why it isn't explicit.&lt;/p&gt;&#xA;" OwnerUserId="4015" LastEditorUserId="4015" LastEditDate="2022-02-19T22:28:04.557" LastActivityDate="2022-02-20T09:12:59.580" Title="Assembly line balancing: What does machine precedence mean?" Tags="|integer-programming|production-planning|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7888" PostTypeId="2" ParentId="7887" CreationDate="2022-02-19T08:23:52.120" Score="5" Body="&lt;p&gt;The machines are in sequence, not in parallel.&lt;/p&gt;&#xA;&lt;p&gt;Consider a same product which requires a number of tasks to be built. Some of these tasks have precedence constraints. If there are &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; stations (machines), then &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; units of this product are built in parallel, one on each station. On each station, the unit built on this station is at a different level of completion. At the end of the cycle time, each station gives its unit to the next station; the first station starts a new one and the last station finishes one. Thus, the cycle time must be at least the time that requires the station with the longest assigned tasks.&lt;/p&gt;&#xA;&lt;p&gt;Once two tasks have been assigned to a station, they can be performed in any order on this station, including one that satisfies the precedence constraints.&lt;/p&gt;&#xA;&lt;p&gt;Note that this is one way to set up an assembly line, and others are possible. Another classical one is the U-line where a unit comes back towards the first station after reaching the last station. This reduces the impact of the precedence constraints. Here is an illustration from &lt;a href=&quot;https://doi.org/10.1080/00207540110051905&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/w9415.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/w9415.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0Pl8G.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0Pl8G.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2022-02-20T09:12:59.580" LastActivityDate="2022-02-20T09:12:59.580" CommentCount="17" ContentLicense="CC BY-SA 4.0" />
  <row Id="7889" PostTypeId="1" AcceptedAnswerId="7893" CreationDate="2022-02-19T09:46:49.427" Score="7" ViewCount="965" Body="&lt;p&gt;Is there a way to linearize &lt;code&gt;is prime?&lt;/code&gt; in Operations Research?&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;is prime(n)&lt;/code&gt; being true if &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is a prime number or false otherwise.&lt;/p&gt;&#xA;&lt;p&gt;If it is not possible, which I suspect, is there any other way in either:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Non linear programming&lt;/li&gt;&#xA;&lt;li&gt;Constraint programming&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;An upper bound of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is known in advance, being any positive natural number.&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="35" LastEditDate="2022-02-19T10:18:42.443" LastActivityDate="2022-02-20T12:28:35.523" Title="is prime? in Operations Research" Tags="|linear-programming|nonlinear-programming|constraint-programming|logical-constraints|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7890" PostTypeId="2" ParentId="7887" CreationDate="2022-02-19T10:26:31.150" Score="2" Body="&lt;p&gt;Besides the useful answer of @fontanf, let's say:&lt;/p&gt;&#xA;&lt;p&gt;If you wanted to try solving the line balancing problem for the first time, I strongly recommended you read some basic concepts and fundamentals of this field which could be easily found by googling. For example, &lt;a href=&quot;https://www.sciencedirect.com/topics/engineering/assembly-line-balancing#:%7E:text=ALB%2C%20or%20simply%20line%20balancing,Production%20Planning%20and%20Control%2C%202019&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; one.&lt;/p&gt;&#xA;&lt;p&gt;After that, each assembly line problem might be interpreted as a directed graph in which every node in this graph represents a task and each arc represents the relation between this task with others. This relation is so-called as a precedence constraint. Please, see the following picture:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/z9EMb.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/z9EMb.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you can see there are &lt;span class=&quot;math-container&quot;&gt;$57$&lt;/span&gt; tasks that should be processed on the pre-defined resources. As a good example for the multi-tasks precedence relationship, as long as tasks #&lt;span class=&quot;math-container&quot;&gt;$22,23,24,...$&lt;/span&gt; will not be processed, task #&lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; is not being processed too.&lt;/p&gt;&#xA;&lt;p&gt;Now, back to your question: If &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in P$&lt;/span&gt; and tasks &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are assigned to machines &lt;span class=&quot;math-container&quot;&gt;$s(i)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s(j)$&lt;/span&gt;, respectively, then &lt;span class=&quot;math-container&quot;&gt;$s(i) \leq s(j)$&lt;/span&gt;, I think &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; referred as start time of each job on machine &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and it obviously clear that by definition of the precedence set, &lt;span class=&quot;math-container&quot;&gt;$s(i) \leq s(j)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Also, if you are willing to use Mixed-integer linear programming to formulate and solve your problem, as it is a varients of the Resource-Constrained Project Scheduling, &lt;a href=&quot;https://or.stackexchange.com/questions/6254/what-kind-of-scheduling-packing-problem-is-this&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/questions/6053/how-does-the-rcpsps-precedence-constraint-work&quot;&gt;this&lt;/a&gt; links would be very useful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-02-19T10:26:31.150" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7891" PostTypeId="2" ParentId="7889" CreationDate="2022-02-19T11:01:48.760" Score="2" Body="&lt;p&gt;In Mixed-Integer Linear Programming, one could consider &amp;quot;prime&amp;quot; as a new type of variables in addition to &amp;quot;continuous&amp;quot;, &amp;quot;binary&amp;quot;, &amp;quot;integer&amp;quot;, &amp;quot;semi-continuous&amp;quot;... Then the algorithm would branch as long a as a variable of type &amp;quot;prime&amp;quot; is not prime in the relaxation. For example if a &amp;quot;prime&amp;quot; variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; has value &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; in the relaxation, then the algorithm could branch on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; with one branch &lt;span class=&quot;math-container&quot;&gt;$x \le 3$&lt;/span&gt; and the other &lt;span class=&quot;math-container&quot;&gt;$x \ge 5$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It also seems possible to consider this type of variables in Constraint Programming.&lt;/p&gt;&#xA;&lt;p&gt;But as far as I know, no MILP or CP solver supports this.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-02-19T11:01:48.760" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7892" PostTypeId="2" ParentId="7889" CreationDate="2022-02-19T11:20:51.513" Score="2" Body="&lt;p&gt;Primality is difficult to check as it requires a statement like &amp;quot;there don't exist two natural numbers &lt;span class=&quot;math-container&quot;&gt;$a,b&amp;gt;1$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$n=a\cdot b$&lt;/span&gt;&amp;quot; which for flexible a &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; require quantifiers to express. Quantified Mixed Integer (Linear) programming exists as a concept but I am not really aware of any solvers that can solve such problems.&lt;/p&gt;&#xA;&lt;p&gt;This means we need to somehow &amp;quot;unroll&amp;quot; all possibilities such an quantifier would cover. Let &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; be the upper bound of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; a naive one would be &lt;span class=&quot;math-container&quot;&gt;$\prod_{x \in \mathbb{P}} (n-x) = 0$&lt;/span&gt; or some other polynomial. Other primality tests such as the Wilson test &lt;span class=&quot;math-container&quot;&gt;$(n-1)!\ \equiv\; -1 \pmod n$&lt;/span&gt; can also be expressed but would result in even higher order polynomials.&lt;/p&gt;&#xA;&lt;p&gt;Another alternative not using products of variables is to use the absolute value &lt;span class=&quot;math-container&quot;&gt;$\forall_{x\in\mathbb{P}\leq N} |n-x| \leq N b_p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_{x\in \mathbb{P}} b_p = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_p$&lt;/span&gt; is a boolean. One could cut the number of equations almost in half by checking divisibility by 2.&lt;/p&gt;&#xA;&lt;p&gt;There are more compact &lt;code&gt;is prime&lt;/code&gt; checks and one could systematically search those for some fixed &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;. This would likely be possible using a two level Mixed Integer Quadratic problem where you try to find an constraint matrix &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{n+2\times n+2}$&lt;/span&gt; and a constraint vector &lt;span class=&quot;math-container&quot;&gt;$b \in \mathbb{R}^{n}$&lt;/span&gt; that satisfies&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\forall m\in\mathbb{N}\leq N:   A x \leq \begin{bmatrix}&#xA;           m \\&#xA;           \text{isprime}(m) \\&#xA;           b_1&#xA;           \vdots \\&#xA;           b_{n}&#xA;         \end{bmatrix}$$&lt;/span&gt;&#xA;where the parent tries to find a such a matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and an assignment &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^a \times \mathbb{B}^{N-a}$&lt;/span&gt; that satisfies this and the &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; sub problems (each has it's own &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;) try to find counter examples &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; such that for the &lt;span class=&quot;math-container&quot;&gt;$A,b$&lt;/span&gt; from the  parent problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A x \leq \begin{bmatrix}&#xA;           m \\&#xA;           1-\text{isprime}(m) \\&#xA;           b_1&#xA;           \vdots \\&#xA;           b_{n}&#xA;         \end{bmatrix}$$&lt;/span&gt;&#xA;This counter example can then be used to add a new constraint to the parent problem. If the parent problem becomes unfeasible a bigger &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; for the dimensions needs to be chosen. Note that only the parent problem is quadratic. If all subproblems are infeasible you found a constraint which encodes &lt;code&gt;is prime&lt;/code&gt;. Depending how you chose &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and whether the parent problem has an appropriate objective it might also be the smallest &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, a sparse &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; or have other properties you want and can express in quadratic programming.&lt;/p&gt;&#xA;&lt;p&gt;Note that Mixed Integer solvers are generally not great in finding feasible solutions a more different approach would be to pick a binary encoding of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; to be tested and do a similar find counter example make more constraints loop with a Pseudo boolean or a SAT solver. This will result in binary constraints which can then also be used in a MILP problem. Quantified boolean solvers also exist and there might be a way to &amp;quot;coax&amp;quot; them into finding a solution without bouncing back and forth. Another alternative on that front are &lt;a href=&quot;https://www3.cs.stonybrook.edu/%7Ecram/cse505/Fall20/Resources/bdd97.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Binary Decision Diagrams&lt;/a&gt; which are also use to reduce logic in computer chips.&lt;/p&gt;&#xA;&lt;p&gt;Getting good results using either method with some analysis of the result would probably be worth publishing a paper about. There might be some other way to derive such a look up table however i am not aware of any.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="123" LastEditDate="2022-02-19T13:44:19.440" LastActivityDate="2022-02-19T13:44:19.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7893" PostTypeId="2" ParentId="7889" CreationDate="2022-02-19T12:59:22.450" Score="7" Body="&lt;p&gt;&lt;strong&gt;TLDR&lt;/strong&gt;: Enumerate (in advance) all primes &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; upper bound on &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. Check to see whether a variable (declared as integer) equals one of the enumerated primes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Details:&lt;/strong&gt;&#xA;Declare &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; as integer.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; be the upper bound on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be an &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; by 1 vector consisting of all primes &lt;span class=&quot;math-container&quot;&gt;$\le U$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Declare &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; as an &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; by 1 vector of binary variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is constrained to be prime by &lt;span class=&quot;math-container&quot;&gt;$$x = b^TP$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$\Sigma b = 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;:  I am answering the interpretation of the question that a variable being prime (or not prime) is a constraint in an optimization or feasibility problem. Some other answers interpret the question as formulating an optimization problem whose solution determines whether a number is prime.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-02-20T12:28:35.523" LastActivityDate="2022-02-20T12:28:35.523" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7894" PostTypeId="1" AcceptedAnswerId="7902" CreationDate="2022-02-19T16:04:05.657" Score="4" ViewCount="476" Body="&lt;p&gt;Famous solvers like sedumi, sdpt3, mosek can solve conic optimization, but not more general convex optimization. Why? I know many convex problems can be formulated as conic, but still confused.&lt;/p&gt;&#xA;" OwnerUserId="9213" LastActivityDate="2022-02-23T05:44:15.213" Title="Why does some solvers can only solve conic optimization problems?" Tags="|solver|convex-optimization|conic-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7895" PostTypeId="2" ParentId="7884" CreationDate="2022-02-19T17:02:25.820" Score="2" Body="&lt;p&gt;To make things more precise, suppose we are given: 1 &amp;lt;= X1, X2 &amp;lt;= 10;&#xA;The so-called disjunctive formulation is:&lt;/p&gt;&#xA;&lt;p&gt;! Case A;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;X1A = 2 * X2A;&#xA;&#xA;X1A &amp;lt;= 10 * ZA;  ! Enforce upper bounds;&#xA;&#xA;X2A &amp;gt;= 1 * ZA;   ! Enforce lower bounds;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;! Case B;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;X2B = 2 * X1B;&#xA;&#xA;X2B &amp;lt;= 10 * ZB; ! Enforce Upper bounds;&#xA;&#xA;X1B &amp;gt;= 1 * ZB;  ! Enforce lower bounds;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;! Tie all the cases together;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ZA + ZB = 1;    !Must choose 1 of the cases;&#xA;&#xA;X1A + X1B = X1;&#xA;&#xA;X2A + X2B = X2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;! ZA and ZB = 0 or 1;&lt;/p&gt;&#xA;&lt;p&gt;Suppose we choose the arbitrary objective:&lt;/p&gt;&#xA;&lt;p&gt;Max = X1 + 0.9* X2;&lt;/p&gt;&#xA;&lt;p&gt;If you relax the requirement that ZA, ZB = 0 or 1&#xA;to:&lt;/p&gt;&#xA;&lt;p&gt;0 &amp;lt;= ZA, ZB &amp;lt;= 1, and solve the resulting Linear(not integer) program,&#xA;you get the naturally integer solution:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; Variable           Value&#xA;      X1A        10.00000&#xA;      X2A        5.000000&#xA;       ZA        1.000000&#xA;       X1        10.00000&#xA;       X2        5.000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So Branch-and-Bound is not required in this particular example for this formulation.&#xA;Other formulations may not have this nice quality.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastEditorUserId="9043" LastEditDate="2022-02-20T01:07:48.863" LastActivityDate="2022-02-20T01:07:48.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7896" PostTypeId="1" CreationDate="2022-02-19T20:41:59.217" Score="2" ViewCount="112" Body="&lt;p&gt;I'm unable to achieve true determinism in CPLEX (I'm using the DOCplex python API).&#xA;Even if the best integer optimal solution is found without going to timeout (so it is expected to be unique), two identical separate runs leads to different results.&lt;/p&gt;&#xA;&lt;p&gt;I'm setting the model parameters in this way:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cplex_model.parameters.randomseed = 42&#xA;cplex_model.parameters.threads = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also I'm fixing every random seed that could be involved:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;os.environ['PYTHONHASHSEED'] = str(seed)&#xA;np.random.seed(seed)&#xA;random.seed(seed)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3212" LastActivityDate="2022-02-19T20:41:59.217" Title="Achieve true determinism in CPLEX" Tags="|mixed-integer-programming|cplex|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7897" PostTypeId="2" ParentId="7878" CreationDate="2022-02-19T21:37:45.583" Score="2" Body="&lt;p&gt;The primal LP for &lt;span class=&quot;math-container&quot;&gt;$n=3$&lt;/span&gt; looks like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max 1^Tx\\&#xA;\text{s.t. }&#xA;\left[\matrix{&#xA;1 &amp;amp; 1 &amp;amp; 0\\&#xA;1 &amp;amp; 0 &amp;amp; 1\\&#xA;0 &amp;amp; 1 &amp;amp; 1\\&#xA;0 &amp;amp; 0 &amp;amp; 1\\&#xA;}\right]&#xA;\left[\matrix{&#xA;x_0\\x_1\\x_2&#xA;}\right]&#xA;\leq&#xA;\left[\matrix{&#xA;d_{01}\\&#xA;d_{02}\\&#xA;d_{11}\\&#xA;d_{22}\\&#xA;}\right]\\&#xA;x\geq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note, that the definition is not well defined, as &lt;span class=&quot;math-container&quot;&gt;$j\in[n,n)$&lt;/span&gt; makes not much sense, so I just removed the last constraint from the set of possible combinations of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. If your definition is meant to be understood differently, just remove the corresponding constraints.&lt;/p&gt;&#xA;&lt;p&gt;Applying the standard dualization rules results in this dual LP:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \left[\matrix{d_{01} &amp;amp; d_{02} &amp;amp; d_{11} &amp;amp; d_{22}}\right]^Ty\\&#xA;\text{s.t. }&#xA;\left[\matrix{&#xA;1 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0\\&#xA;1 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0\\&#xA;0 &amp;amp; 1 &amp;amp; 1 &amp;amp; 1\\&#xA;}\right]&#xA;\left[\matrix{&#xA;y_0\\y_1\\y_2\\y_3&#xA;}\right]&#xA;\geq&#xA;\left[\matrix{&#xA;1\\&#xA;1\\&#xA;1\\&#xA;}\right]\\&#xA;y\geq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraint matrix of the dual is simply &lt;span class=&quot;math-container&quot;&gt;$A^T$&lt;/span&gt; so the general formulation is then:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min d^Ty\\&#xA;\text{s.t. }&#xA;y_j + y_i \geq 1, \; j\in[0,m-1], \; i\in[j+1,m-1]\\&#xA;y \geq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The size of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is not completely clear as I am not sure about your initial formulation.&lt;/p&gt;&#xA;" OwnerUserId="141" LastEditorUserId="141" LastEditDate="2022-02-19T22:01:04.927" LastActivityDate="2022-02-19T22:01:04.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7898" PostTypeId="2" ParentId="7889" CreationDate="2022-02-19T22:29:10.690" Score="2" Body="&lt;p&gt;Since primes only have &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; divisors, &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and the number itself, you could use the following program to determine if an integer &lt;span class=&quot;math-container&quot;&gt;$n \in \mathbb{N}$&lt;/span&gt; is prime or not :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \; x&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\mbox{subject to  }\quad n &amp;amp;= x \cdot y \tag{1} \\ &#xA;x &amp;amp;\in \mathbb{N} \cap [0,n-1] \tag{2}\\&#xA;y &amp;amp;\in \mathbb{N} \cap [0,n] \tag{3}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With constraints &lt;span class=&quot;math-container&quot;&gt;$(1)-(3)$&lt;/span&gt;, you try to decompose &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; as a product of two integers &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; cannot equal &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. The objective function maximizes &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. So if the largest &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; you can find equals &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is prime. Otherwise it is not.&lt;/p&gt;&#xA;&lt;p&gt;For example, if &lt;span class=&quot;math-container&quot;&gt;$n:=10$&lt;/span&gt;, the following solution is optimal: &lt;span class=&quot;math-container&quot;&gt;$x=5$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y=2$&lt;/span&gt;. So &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is not prime. If &lt;span class=&quot;math-container&quot;&gt;$n=11$&lt;/span&gt;, the following solution is optimal: &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y=11$&lt;/span&gt;. So &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is prime.&lt;/p&gt;&#xA;&lt;p&gt;Of course this is not linear, but you can easily linearize the product, and you will have a problem with binary and integer variables that determine if a number &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is prime or not.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-02-20T07:32:29.057" LastActivityDate="2022-02-20T07:32:29.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7899" PostTypeId="2" ParentId="7873" CreationDate="2022-02-20T17:29:56.257" Score="8" Body="&lt;p&gt;You want to linearize&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z_r &amp;amp;= \frac{x_{ry}}{\sum_s d_s x_{sy}} &amp;amp;&amp;amp;\text{for all $r$ and $y$} \tag1 \\&#xA;\sum_s x_{sy} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $y$} \tag2&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_{ry}=0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; implies that &lt;span class=&quot;math-container&quot;&gt;$z_r=0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_{ry}=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; imply that &lt;span class=&quot;math-container&quot;&gt;$z_r=1/d_r$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So you can linearize &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; by replacing it with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_r=x_{ry}/d_r \quad \text{for all $r$ and $y$} \tag3$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-02-21T15:40:09.770" LastActivityDate="2022-02-21T15:40:09.770" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7900" PostTypeId="1" CreationDate="2022-02-21T08:01:56.787" Score="3" ViewCount="108" Body="&lt;p&gt;I have a design optimization problem where I need to connect a customer with a server via call. The scenario is as follows:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Customer-1 is connected with &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; servers out of a total pool of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; servers.&lt;/li&gt;&#xA;&lt;li&gt;Out of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; servers connected, 1 server accepts the request for his call and the remaining servers go back.&lt;/li&gt;&#xA;&lt;li&gt;Next customer now has a total of &lt;span class=&quot;math-container&quot;&gt;$P-1$&lt;/span&gt; servers, and out of &lt;span class=&quot;math-container&quot;&gt;$P-1$&lt;/span&gt; servers, &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; servers are connected with customer-2, and out of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; servers, 1 accepts the request. And so on.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I need to build a performance model for such queues. My goal is to minimize the customer wait time and minimize server utilization. While doing my research, I have come across &lt;span class=&quot;math-container&quot;&gt;$M/M/c$&lt;/span&gt; queues, but I can't find any models where server selection is highlighted.&lt;/p&gt;&#xA;&lt;p&gt;Can anyone please provide an insight or a good reference as to how to go about this problem?&lt;/p&gt;&#xA;" OwnerUserId="9230" LastEditorUserId="9230" LastEditDate="2022-02-21T21:13:15.340" LastActivityDate="2022-02-21T21:13:15.340" Title="Multiserver Queue Theory Optimization problem" Tags="|optimization|multi-objective-optimization|queuing-theory|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7901" PostTypeId="1" CreationDate="2022-02-21T08:10:13.883" Score="7" ViewCount="883" Body="&lt;p&gt;I am trying to solve a shortest path problem through Dijkstra's algorithm. However in my case, cost between nodes (nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;) are more than one- two nodes are compared based on two different properties and this results in two different cost values, &lt;span class=&quot;math-container&quot;&gt;$C_1(i,j)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_2(i,j)$&lt;/span&gt;. I would like Dijkstra to find a solution which takes &lt;span class=&quot;math-container&quot;&gt;$C_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_2$&lt;/span&gt; account, together. I have considered a linear combination (&lt;span class=&quot;math-container&quot;&gt;$αC_1+βC_2$&lt;/span&gt;), but distances are coming from different distributions- one normal and other is not. Therefore, I am not sure whether linearly combining them after scaling is mathematically correct way of doing that. Also, I would very happy to have some references for that, if possible.&lt;/p&gt;&#xA;" OwnerUserId="9231" LastEditorUserId="123" LastEditDate="2022-02-21T08:42:52.757" LastActivityDate="2022-02-21T17:05:29.697" Title="Combining Multiple Cost Values in Shortest Path Problem" Tags="|reference-request|algorithms|graphs|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7902" PostTypeId="2" ParentId="7894" CreationDate="2022-02-21T08:20:44.120" Score="13" Body="&lt;p&gt;The fundamental algorithm employed by &lt;a href=&quot;https://mosek.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek&lt;/a&gt; and SeDuMi is a primal-dual interior-point algorithm based on the work of Nesterov and Todd (NT). See for instance&#xA;&lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-002-0349-3&quot; rel=&quot;nofollow noreferrer&quot;&gt;my paper&lt;/a&gt; and the references therein. This algorithm is only applicable to conic optimization problems over the &lt;a href=&quot;https://en.wikipedia.org/wiki/Symmetric_cone&quot; rel=&quot;nofollow noreferrer&quot;&gt;symmetric cones&lt;/a&gt;. Therefore, it is not at all obvious or natural to extend those optimizers to general convex optimization. You can even argue theoretically that it is impossible to generalize it. Nevertheless&#xA;in a recent &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-021-01631-4&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt; we present a primal-dual interior-point algorithm for some nonsymmetric cones which is quite similar to the NT algorithm and seems to work well in practice.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, Mosek can currently deal with 5 cone types i.e. the linear, the quadratic, the semi-definite, the power and the exponential cone. It turns out that if you can deal with those 5 cone types you can handle almost all convex optimization that appears in practice. See the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek modeling cookbook&lt;/a&gt; for details. Also one of the more important exceptions is discussed at the &lt;a href=&quot;https://themosekblog.blogspot.com/2019/06/logarithmic-mean-temperature-difference.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek blog&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Hence, there is a little value in building an optimizer for general convex optimization because it will have little use. Moreover, a conic optimizer specialized towards a small set of the most important cones will be easier to use and more efficient than some general purpose software. At least that is the bet we have made at Mosek.&lt;/p&gt;&#xA;&lt;p&gt;PS. Up until version 8 MOSEK was capable of solving general convex optimization problems using the algorithm presented in yet &lt;a href=&quot;https://scholar.google.com/citations?view_op=view_citation&amp;amp;hl=en&amp;amp;user=3I3Gs2cAAAAJ&amp;amp;citation_for_view=3I3Gs2cAAAAJ:ufrVoPGSRksC&quot; rel=&quot;nofollow noreferrer&quot;&gt;another paper&lt;/a&gt;. However, it was rarely used and often users tried to apply it to nonconvex problems causing support issues.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2022-02-23T05:44:15.213" LastActivityDate="2022-02-23T05:44:15.213" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7903" PostTypeId="2" ParentId="7901" CreationDate="2022-02-21T09:05:31.537" Score="5" Body="&lt;p&gt;You could consider that &lt;span class=&quot;math-container&quot;&gt;$C_2$&lt;/span&gt; measures for example &lt;em&gt;time&lt;/em&gt;, and you could impose that the shortest path based on &lt;span class=&quot;math-container&quot;&gt;$C_1$&lt;/span&gt; may not be larger than a given threshold &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; based on &lt;span class=&quot;math-container&quot;&gt;$C_2$&lt;/span&gt;. In other words, you can solve this as a shortest path with a side constraint, and iteratively decrease the threshold. This cannot be solved with Dijkstra, but easily with a linear programming approach:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \; \sum_{(i,j)\in A} c^1_{ij}x_{ij}&#xA;$$&lt;/span&gt;&#xA;subject to &lt;em&gt;flow conservation constraints&lt;/em&gt; and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{(i,j)\in A} c^2_{ij}x_{ij} \le T&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that variables should be declared as integer.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-02-21T09:05:31.537" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7904" PostTypeId="2" ParentId="7901" CreationDate="2022-02-21T16:48:04.703" Score="2" Body="&lt;p&gt;I have not worked through the details, but I suspect that it would be possible to modify Dijkstra's algorithm to find all nondominated paths between two nodes. A path is nondominated if no other path is lower in both arc costs. The solution would likely not be unique, so the ultimate decision maker would need to pick one of the nondominated paths.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-21T16:48:04.703" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7905" PostTypeId="2" ParentId="7901" CreationDate="2022-02-21T17:05:29.697" Score="5" Body="&lt;p&gt;The bi-objective shortest path problem is a quite well-studied problem. You may find an overview over solution approaches in the paper &lt;em&gt;A comparison of solution strategies for biobjective shortest path problems&lt;/em&gt; by A. Raith and M. Ehrgott. You can find it here : &lt;a href=&quot;https://doi.org/10.1016/j.cor.2008.02.002&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1016/j.cor.2008.02.002&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-02-21T17:05:29.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7906" PostTypeId="2" ParentId="7564" CreationDate="2022-02-21T17:08:25.483" Score="3" Body="&lt;p&gt;Here is what I put together as a start.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://miketalksai.substack.com/p/two-careers-every-smart-college-student?utm_source=url&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://miketalksai.substack.com/p/two-careers-every-smart-college-student?utm_source=url&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="191" LastActivityDate="2022-02-21T17:08:25.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7907" PostTypeId="1" CreationDate="2022-02-21T17:53:15.023" Score="6" ViewCount="87" Body="&lt;p&gt;I'm working on a price-selection model where we need to identify price point for each time-period (could be day/week). Objective of the model is to figure out optimal price-point for each time-point to optimize revenue from all products. One price-point selected applies to all products&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;&amp;amp;\mathcal{P} \quad \text{set of products (indexed by $p$)}\\&#xA;&amp;amp;\mathcal{T} \quad \text{set of time-periods (indexed by $t$)}\\&#xA;&amp;amp;\mathcal{K} \quad \text{set of price-points (indexed by $k$)}\\&#xA;&amp;amp;D_{p,t,k} \quad \text{demand of product $p$ in time-period $t$ at price-point $k$}  \\&#xA;&amp;amp;R_{p,t,k} \quad \text{Revenue associated with product $p$ for time-period $t$ at price-point $k$}  \\&#xA;&amp;amp;&#xA;\end{align*}&#xA;$$&lt;/span&gt;&#xA;Binary variable &lt;span class=&quot;math-container&quot;&gt;$z_{t,k}$&lt;/span&gt; equals 1 if price-point &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is selected for time-period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. As same price applies for all products, objective is to maximize revenue i.e.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Maximize \quad \sum_{p,t,k} R_{p,t,k} \cdot q_{p,t,k}&#xA;$$&lt;/span&gt;&#xA;Also, main constraint is to identify quantity sold &lt;span class=&quot;math-container&quot;&gt;$q_{p,t,k}$&lt;/span&gt; for each product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; at time-period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; price-point is selected and is given by&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;q_{p,t,k} \le D_{p,t,k} \cdot z_{t,k}&#xA;$$&lt;/span&gt;&#xA;Only one price point to be selected per time-period&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{k} z_{t,k}=1&#xA;$$&lt;/span&gt;&#xA;Total inventory sold is less than initial inventory &lt;span class=&quot;math-container&quot;&gt;$I_{p}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{t,k} q_{p,t,k} \le I_{p}&#xA;$$&lt;/span&gt;&#xA;Also, there are some side constraints on price changes from one time-period to another. With this formulation, while solving as MIP (root-relaxation solve), it shows dense columns in the logs which is leading to high computational time for a larger product case. Snippet of log is provided below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Barrier statistics:&#xA; Dense cols : 74&#xA; AA' NZ     : 1.509e+06&#xA; Factor NZ  : 8.201e+06 (roughly 400 MBytes of memory)&#xA; Factor Ops : 2.808e+08 (less than 1 second per iteration)&#xA; Threads    : 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'm looking for alternate formulation to avoid these dense columns which is primarily caused by inventory constraints.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastEditorUserId="5880" LastEditDate="2022-02-21T18:14:43.997" LastActivityDate="2022-02-21T18:14:43.997" Title="Issue of Dense columns in the formulation" Tags="|mixed-integer-programming|modeling|solver|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="7908" PostTypeId="1" AcceptedAnswerId="7921" CreationDate="2022-02-21T18:34:34.987" Score="1" ViewCount="604" Body="&lt;p&gt;This is not the right question to be posting here, but is anywhere a video tutorial/ written on how to link C++ header files with Gurobi?&lt;/p&gt;&#xA;" OwnerUserId="8819" LastEditorUserId="8819" LastEditDate="2022-02-23T10:26:41.313" LastActivityDate="2022-02-23T13:25:45.353" Title="Gurobi with C++" Tags="|gurobi|c++|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7909" PostTypeId="2" ParentId="7806" CreationDate="2022-02-21T23:17:03.550" Score="4" Body="&lt;p&gt;First, there are some solvers (including CPLEX) that will let you try to solve a model with linear constraints and a nonconvex quadratic objective function. In a case like that CPLEX will let you choose a &amp;quot;target&amp;quot;, either a possibly local solution satisfying first order constraints or a provably optimal solution. The latter requires changing the problem to a mixed integer quadratic problem, possibly including using the McCormick envelopes in the page @wordsmithhelper linked.&lt;/p&gt;&#xA;&lt;p&gt;I ran some tests, on problems much smaller than yours. Using the global optimality target, CPLEX found what I suspect is an optimal solution immediately and then spent considerable time trying to prove optimality. On one test problem (50 &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables with 119 constraints, 75 &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables with 135 constraints), CPLEX did in fact prove that the early solution was optimal. So, if your solver supports this, a possible heuristic is to tell it to solve the QP and set a tight time limit (or, if you want proven optimality, set a not-so-tight time limit and cross your fingers).&lt;/p&gt;&#xA;&lt;p&gt;If you don't want to mess with QPs (or your solver won't let you), here is another heuristic that consistently matched the initial CPLEX solution in comparable time to what it took CPLEX to find that solution. Let &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; be the feasible regions (polytopes) for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. Note that for fixed (feasible) &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, the problem becomes an LP in &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; with objective coefficient &lt;span class=&quot;math-container&quot;&gt;$\sum_i a_{ij}x_i + c_j$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt;, and similarly for fixed (feasible) &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$f(x;y)$&lt;/span&gt; be the linear objective function when &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is fixed and &lt;span class=&quot;math-container&quot;&gt;$g(y;x)$&lt;/span&gt; the linear objective function when &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is fixed. The heuristic is simple.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Minimize &lt;span class=&quot;math-container&quot;&gt;$f(x;0)$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; to get &lt;span class=&quot;math-container&quot;&gt;$x^0.$&lt;/span&gt; (For this step, it does not matter whether &lt;span class=&quot;math-container&quot;&gt;$0\in Y.$&lt;/span&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Minimize &lt;span class=&quot;math-container&quot;&gt;$g(y;x^0)$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; to get &lt;span class=&quot;math-container&quot;&gt;$y^0.$&lt;/span&gt; You now have an incumbent solution &lt;span class=&quot;math-container&quot;&gt;$(x^0,y^0)$&lt;/span&gt; with cost &lt;span class=&quot;math-container&quot;&gt;$b^\prime x^0 + g(y^0;x^0).$&lt;/span&gt; Set &lt;span class=&quot;math-container&quot;&gt;$t = 0.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Minimize &lt;span class=&quot;math-container&quot;&gt;$f(x;y^t)$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; to get &lt;span class=&quot;math-container&quot;&gt;$x^{t+1}.$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$f(x^{t+1};y^t) + c^\prime y^t$&lt;/span&gt; is less than the current incumbent value, record &lt;span class=&quot;math-container&quot;&gt;$(x^{t+1}, y^t)$&lt;/span&gt; as a new incumbent and keep going, else quit.&lt;/li&gt;&#xA;&lt;li&gt;Minimize &lt;span class=&quot;math-container&quot;&gt;$g(y;x^{t+1})$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; to get &lt;span class=&quot;math-container&quot;&gt;$y^{t+1}$&lt;/span&gt; and compare &lt;span class=&quot;math-container&quot;&gt;$g(y^{t+1};x^{t+1}) + b^\prime x^{t+1}.$&lt;/span&gt; If the new solution is better, record &lt;span class=&quot;math-container&quot;&gt;$(x^{t+1}, y^{t+1})$&lt;/span&gt; as your new incumbent, increment &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and go back to step 3.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;So you solve LPs, alternating between &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, until improvement stops.&#xA;Note that each solution to either LP is feasible the next time you come back to that LP, since only the objective function is changing. Assuming your LP solver will &amp;quot;hot start&amp;quot; from a previous solution, this should speed up the process.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-21T23:17:03.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7910" PostTypeId="1" CreationDate="2022-02-22T10:18:30.670" Score="9" ViewCount="1115" Body="&lt;p&gt;I am looking for a LaTeX template where a MIP problem formulation will look well-formatted.&lt;/p&gt;&#xA;&lt;p&gt;Can anyone provide some example LaTeX code?&lt;/p&gt;&#xA;" OwnerUserId="4380" LastEditorUserId="491" LastEditDate="2022-02-22T13:42:53.123" LastActivityDate="2022-02-24T18:49:31.053" Title="Any good MIP LaTeX template?" Tags="|mixed-integer-programming|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7911" PostTypeId="2" ParentId="7910" CreationDate="2022-02-22T11:59:57.680" Score="3" Body="&lt;p&gt;Well this naturally depends on you problem. Here is something JuMP generates using the &lt;code&gt;latex_formulation&lt;/code&gt; function. I hope this helps. This is what i would use.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{aligned}&#xA;\max\quad &amp;amp; preparedness\\&#xA;\text{Subject to} \quad &amp;amp; flunk_{1} = 0.0\\&#xA; &amp;amp; 8 preparedness - workdone_{1} - 10000 flunk_{1} \leq 0.0\\&#xA; &amp;amp; 5 preparedness - workdone_{2} - 10000 flunk_{2} \leq 0.0\\&#xA; &amp;amp; preparedness \geq 0.0\\&#xA; &amp;amp; preparedness \leq 1.5\\&#xA; &amp;amp; flunk_{1} \in \{0, 1\}\\&#xA; &amp;amp; flunk_{2} \in \{0, 1\}\\&#xA;\end{aligned} $$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-02-22T11:59:57.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7912" PostTypeId="1" CreationDate="2022-02-22T14:20:22.097" Score="2" ViewCount="93" Body="&lt;p&gt;In the Conference Paper &lt;a href=&quot;https://www.researchgate.net/publication/326610245_A_Generic_Approach_for_Order_Picking_Optimization_Process_in_Different_Warehouse_Layouts&quot; rel=&quot;nofollow noreferrer&quot;&gt;A Generic Approach for Order Picking Optimization Process in Different Warehouse Layouts&lt;/a&gt;, I cannot understand the process described on page 4:&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;That is done by creating new links, even between sectors that do not have direct links. It is done in the following way: let &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; be two nonadjacent sectors, then for each exit &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and for each entrance &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; into &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;, if there exists a path from &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; which does not go through &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, calculate the distance &lt;span class=&quot;math-container&quot;&gt;$d(a, b)$&lt;/span&gt; between &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. Now a link &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; can be defined as &lt;span class=&quot;math-container&quot;&gt;$L = \{X, Y, d(a, b), a, b\}$&lt;/span&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, what is &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;? And what is an exit (from &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;) and an entrance (into &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;) in this context?&lt;/p&gt;&#xA;&lt;p&gt;I suppose that, by the definition of a link given on the same page and by the definition of &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;, that &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; must belong to &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;, and that they are two &lt;em&gt;corresponding pallet places&lt;/em&gt; (using the paper terminology) of existing links of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and other sectors (for &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;) and of &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and other sectors (for &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;), but I have no clue about the meaning of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, and it would be helpful if someone could provide a concrete example using &lt;em&gt;Figure 3&lt;/em&gt; of the paper as reference warehouse.&lt;/p&gt;&#xA;&lt;p&gt;Also, how can I compute &lt;span class=&quot;math-container&quot;&gt;$d(a, b)$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; do NOT belong to neighboring sectors? Until that point, the authors have defined the distance only for points of the same sector or for points in neighboring sectors.&lt;/p&gt;&#xA;" OwnerUserId="9244" LastEditorUserId="9244" LastEditDate="2022-02-23T07:44:48.177" LastActivityDate="2022-02-23T07:44:48.177" Title="Order picking optimization: creating links between sectors of the warehouse" Tags="|optimization|graphs|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7913" PostTypeId="1" AcceptedAnswerId="7915" CreationDate="2022-02-22T14:40:38.013" Score="1" ViewCount="424" Body="&lt;p&gt;I am working on Scaling MIP. I use Gurobi within Clion. I need to extract the coefficient of  Xs (A matrix), right-hand side (B matrix), and an objective function(c matrix) from the .lp file and create A,b,c matrices. Since my model includes more than 1000 constraints is not feasible to do it manually.&lt;/p&gt;&#xA;&lt;p&gt;How can I create A,b,c matrices from the .lp file automatically?&lt;/p&gt;&#xA;" OwnerUserId="7526" LastEditorUserId="7526" LastEditDate="2022-02-22T22:37:53.457" LastActivityDate="2022-02-23T19:36:49.093" Title="How to create A, b and c matrices from very large .lp file?" Tags="|optimization|mixed-integer-programming|modeling|gurobi|c++|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7914" PostTypeId="1" CreationDate="2022-02-22T16:33:32.030" Score="5" ViewCount="77" Body="&lt;p&gt;I aim to solve the following Bellman equation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    v(\vec{s}) = \min_{\vec{x} \in \Xi_{\vec{s}}} \big\{c(\vec{s}, \vec{x}) + \lambda \times \sum_{\vec{s}^{'}\in S} p(\vec{s}^{'} | \vec{s}, \vec{x}) \times v(\vec{s}^{'})\big\}&#xA;    \hspace{2cm} \forall \vec{s} \in S&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I use the linear programming approach to solve the above equation like below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Model 1:&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;   \max \Big\{\sum_{\vec{s} \in S} \eta(\vec{s}) \times v(\vec{s})\Big\}&#xA;\end{equation}&lt;/span&gt;&#xA;subjected to:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;   c(\vec{s}, \vec{x}) + \lambda \times \sum_{\vec{s}^{'} \in S} p(\vec{s}^{'} | \vec{s}, \vec{x}) \times v(\vec{s}^{'}) \ge v(\vec{s}) \hspace{1cm}&#xA;    \forall \vec{s} \in S; \vec{x} \in \Xi_{\vec{s}}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;   v(\vec{s}) \in \mathbb{R}_{\geq0}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Due to the curse of dimensionality, I use a basis function to approximate the value function and solve the dual of the above problem using a column generation (further detail can be found here: &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2012.06.046&quot; rel=&quot;nofollow noreferrer&quot;&gt;10.1016/j.ejor.2012.06.046&lt;/a&gt;). The column generation algorithm includes a master problem and a subproblem like below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Model 2,&lt;/strong&gt; Master problem: where the algorithm iteratively solves the dual problem - the shadow prices of constraints are equal to optimal approximation coefficients.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\min \sum_{\vec{s} \in S} \sum_{\vec{x} \in \Xi_{\vec{s}}} c(\vec{s}, \vec{x}) \times \chi(\vec{s}, \vec{x})&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subjected to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;(1 - \lambda) \times \sum_{\vec{s} \in S} \sum_{\vec{x} \in \Xi_{\vec{s}}} \chi(\vec{s}, \vec{x}) = 1&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{\vec{s} \in S} \sum_{\vec{x} \in \Xi_{\vec{s}}} \mu_{koi}(\vec{s}, \vec{x}) \times \chi(\vec{s}, \vec{x}) \geq \mathbb{E}_{\eta} [p^w_{koi}] \hspace{1cm}&#xA;    \forall k \in \mathcal{K}; o \in \mathcal{O}; i \in \mathcal{I}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{\vec{s} \in S} \sum_{\vec{x} \in \Xi_{\vec{s}}} \delta_{kti}(\vec{s}, \vec{x}) \times \chi(\vec{s}, \vec{x}) \geq \mathbb{E}_{\eta} [p^m_{kti}] \hspace{1cm}&#xA;    \forall k \in \mathcal{K}; t \in \mathcal{T}; i \in \mathcal{I}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\chi(\vec{s}, \vec{x}) \in \mathbb{R}_{\geq0}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Model 3,&lt;/strong&gt; Sub-problem: where the algorithm finds feasible state-decision pairs to be added to the master problem.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\max \Big\{(1 - \lambda) \times V^0 +  \sum_{k \in \mathcal{K}} \sum_{o \in \mathcal{O}} \sum_{i \in \mathcal{I}} V^w_{koi} \times \mu_{koi}(\vec{s}, \vec{x}) + \sum_{k \in \mathcal{K}} \sum_{t \in \mathcal{T}} \sum_{i \in \mathcal{I}} V^m_{kti} \times \delta_{kti}(\vec{s}, \vec{x}) - c(\vec{s}, \vec{x})\Big\}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subjected to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{p \in \mathcal{P}^w} \sum_{j \in \mathcal{J}} \sum_{t \in \mathcal{T}} \sum_{\substack{b \in \mathcal{B}_c \\ c \in \mathcal{C}}} z_{pjtib} \times R^1_{pk} \times R^1_{po} \leq p^w_{koi}&#xA;    \hspace{1cm} \forall k \in \mathcal{K}; o \in \mathcal{O}; i \in \mathcal{I}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{p \in \mathcal{P}^m} \sum_{j \in \mathcal{J}} \sum_{\substack{b \in \mathcal{B}_c \\ c \in \mathcal{C}}} z_{pjtib} \times R^1_{pk} = p^m_{kti}&#xA;    \hspace{1cm} \forall k \in \mathcal{K}; t \in \mathcal{T}; i \in \mathcal{I}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;(\vec{s}, \vec{x}) \in S \times \Xi_{\vec{s}}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My problem starts from here! To initiate the column generation algorithm, I need to have at least one feasible pair of state-decision for &lt;strong&gt;Model 2&lt;/strong&gt;. As suggested by &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2012.06.046&quot; rel=&quot;nofollow noreferrer&quot;&gt;Saure et al. (2012)&lt;/a&gt;, I iteratively solve &lt;strong&gt;Models 4 and 3&lt;/strong&gt; until the objective function of &lt;strong&gt;Model 4&lt;/strong&gt; becomes equal to zero (meaning that a set of feasible state-decisions is found for &lt;strong&gt;Model 2&lt;/strong&gt; so I can start the column generation). Starting from an initial hypothesized state, I solve &lt;strong&gt;Model 4&lt;/strong&gt;, finds the shadow prices of constraints and update &lt;span class=&quot;math-container&quot;&gt;$V^0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$V^w_{koi}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V^m_{kti}$&lt;/span&gt;, and solve &lt;strong&gt;Model 3&lt;/strong&gt; (to update &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; for &lt;strong&gt;Model 4&lt;/strong&gt;). Solving &lt;strong&gt;Models 4 and 3&lt;/strong&gt; for a few iterations, the objective of &lt;strong&gt;Model 4&lt;/strong&gt; improves for a while. However, &lt;strong&gt;Model 3&lt;/strong&gt; stops providing new outcomes for decision variables (generates an identical solution).&lt;/p&gt;&#xA;&lt;p&gt;What would be the reason for this issue?&lt;/p&gt;&#xA;&lt;p&gt;Let me know if you need further information.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Model 4:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\min \Big\{U^0 + \sum_{k \in \mathcal{K}} \sum_{o \in \mathcal{O}} \sum_{i \in \mathcal{I}} U^w_{koi} + \sum_{k \in \mathcal{K}} \sum_{t \in \mathcal{T}} \sum_{i \in \mathcal{I}} U^m_{kti}\Big\} &#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subjected to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;(1 - \lambda) \times \sum_{\vec{s} \in P} \sum_{\vec{x} \in \Xi_{\vec{s}}} \chi(\vec{s}, \vec{x}) + U^0 = 1&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{\vec{s} \in P} \sum_{\vec{x} \in \Xi_{\vec{s}}} \mu_{koi}(\vec{s}, \vec{x}) \times \chi(\vec{s}, \vec{x}) + U^w_{koi} \geq \mathbb{E}_{\eta} [p^w_{koi}] \hspace{1cm}&#xA;    \forall k \in \mathcal{K}; o \in \mathcal{O}; i \in \mathcal{I}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{\vec{s} \in P} \sum_{\vec{x} \in \Xi_{\vec{s}}} \delta_{kti}(\vec{s}, \vec{x}) \times \chi(\vec{s}, \vec{x}) + U^m_{kti} \geq \mathbb{E}_{\eta} [p^m_{kti}] \hspace{1cm}&#xA;    \forall k \in \mathcal{K}; t \in \mathcal{T}; i \in \mathcal{I}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;U^0, U^w_{koi}, U^m_{kti} \in \mathbb{R}_{\geq0}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="491" LastEditDate="2022-02-22T17:15:11.500" LastActivityDate="2022-02-22T17:15:11.500" Title="Linear programming approach to dynamic programming - an initial pair of state-decisions" Tags="|duality|column-generation|dynamic-programming|approximation-algorithms|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7915" PostTypeId="2" ParentId="7913" CreationDate="2022-02-22T22:07:31.010" Score="3" Body="&lt;p&gt;Since you linked to the documentation of the C++ API in the comments, I assume you are using C++. Typically, the constraint matrix A is sparse, so we use a sparse data structure. This requires significantly less storage compared to storing all matrix entries.&lt;/p&gt;&#xA;&lt;p&gt;I will use the &lt;a href=&quot;https://eigen.tuxfamily.org/dox/classEigen_1_1SparseMatrix.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Eigen::SparseMatrix&lt;/a&gt; class for this purpose, so you need to install the Eigen library. Nearly all decent C++ linear algebra libraries offer a similar sparse matrix class, so it shouldn't be hard to modify the following example.&lt;/p&gt;&#xA;&lt;p&gt;You can use the following code snippet to read the coefficient matrix A, the right-hand side vector b and the objective coefficient vector c:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/* read_lp.cpp */&#xA;#include &amp;lt;iostream&amp;gt;&#xA;#include &amp;lt;ostream&amp;gt;&#xA;#include &amp;lt;tuple&amp;gt;&#xA;#include &amp;lt;vector&amp;gt;&#xA;&#xA;#include &amp;lt;Eigen/Sparse&amp;gt;&#xA;#include &amp;quot;gurobi_c++.h&amp;quot;&#xA;&#xA;using TripletVector = std::vector&amp;lt;Eigen::Triplet&amp;lt;double&amp;gt;&amp;gt;;&#xA;using SparseMatrix  = Eigen::SparseMatrix&amp;lt;double&amp;gt;;&#xA;using Vector        = std::vector&amp;lt;double&amp;gt;;&#xA;&#xA;std::tuple&amp;lt;SparseMatrix, Vector, Vector&amp;gt; read_Abc(GRBModel&amp;amp; model) {&#xA;    // number of variables, number of constraints, number of nonzeros in A&#xA;    std::size_t n       = model.get(GRB_IntAttr_NumVars);&#xA;    std::size_t m       = model.get(GRB_IntAttr_NumConstrs);&#xA;    std::size_t num_nnz = model.get(GRB_IntAttr_NumNZs);&#xA;&#xA;    // allocate space&#xA;    TripletVector triplet(num_nnz);&#xA;    Vector b(m);&#xA;    Vector c(n);&#xA;&#xA;    // Read the objective coefficients&#xA;    auto obj_expr = model.getObjective().getLinExpr();&#xA;    for (std::size_t j = 0; j &amp;lt; n; ++j) {&#xA;        c[j] = obj_expr.getCoeff(j);&#xA;    }&#xA;&#xA;    // Read the coefficient matrix A and the rhs vector b&#xA;    std::size_t k = 0;&#xA;    for (std::size_t i = 0; i &amp;lt; m; ++i) {&#xA;        auto con      = model.getConstr(i);&#xA;        auto row      = model.getRow(con);&#xA;        for (std::size_t r = 0; r &amp;lt; row.size(); ++r) {&#xA;            auto col_idx = row.getVar(r).index();&#xA;            auto coeff   = row.getCoeff(r);&#xA;            triplet[k++] = Eigen::Triplet&amp;lt;double&amp;gt;(i, col_idx, coeff);&#xA;        }&#xA;        // read the constraint rhs&#xA;        b[i] = con.get(GRB_DoubleAttr_RHS);&#xA;    }&#xA;&#xA;    // Construct the sparse matrix.&#xA;    SparseMatrix A(m, n);&#xA;    A.setFromTriplets(triplet.begin(), triplet.end());&#xA;&#xA;    return {A, b, c};&#xA;}&#xA;&#xA;int main(int argc, char* argv[]) {&#xA;    if (argc &amp;lt; 2) {&#xA;        std::cout &amp;lt;&amp;lt; &amp;quot;Usage: read_lp filename&amp;quot; &amp;lt;&amp;lt; std::endl;&#xA;        return 1;&#xA;    }&#xA;    GRBEnv env     = GRBEnv();&#xA;    GRBModel model = GRBModel(env, argv[1]);&#xA;&#xA;    auto [A, b, c] = read_Abc(model);&#xA;&#xA;    // ... your code here. Use A.coeff(i, j) to access the element in row i&#xA;    // and column j inside the coefficient matrix A.&#xA;    std::cout &amp;lt;&amp;lt; &amp;quot;rows: &amp;quot; &amp;lt;&amp;lt; A.outerSize() &amp;lt;&amp;lt; '\n';&#xA;    std::cout &amp;lt;&amp;lt; &amp;quot;cols: &amp;quot; &amp;lt;&amp;lt; A.innerSize() &amp;lt;&amp;lt; '\n';&#xA;    std::cout &amp;lt;&amp;lt; &amp;quot;nonzeros: &amp;quot; &amp;lt;&amp;lt; A.nonZeros() &amp;lt;&amp;lt; '\n';&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Besides including the gurobi headers and linking to the gurobi shared library, we only need to include the Eigen headers and compile with C++17. On macOS and Linux (please adapt the paths) this can look like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;GUROBI_HOME=&amp;quot;/Library/gurobi950/macos_universal2&amp;quot;&#xA;EIGEN_HOME=&amp;quot;/usr/local/Cellar/eigen/3.4.0_1&amp;quot;&#xA;&#xA;clang++ read_lp.cpp -std=c++17 -Wall -I&lt;span class=&quot;math-container&quot;&gt;${EIGEN_HOME}/include/eigen3/ -I$&lt;/span&gt;{GUROBI_HOME}/include/ -L${GUROBI_HOME}/lib -lgurobi_c++ -lgurobi95 -o read_lp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Running and timing the above program with your example gives me:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt; ↪  time ./read_lp Medium_Investment_Model.lp&#xA;&#xA;Academic license - for non-commercial use only - expires 2022-02-28&#xA;Read LP format model from file Medium_Investment_Model.lp&#xA;Reading time = 0.48 seconds&#xA;: 190336 rows, 188505 columns, 419110 nonzeros&#xA;&#xA;rows: 188505&#xA;cols: 190336&#xA;nonzeros: 419110&#xA;&#xA;real    0m0.832s&#xA;user    0m0.740s&#xA;sys 0m0.078s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="3696" LastEditDate="2022-02-23T19:36:49.093" LastActivityDate="2022-02-23T19:36:49.093" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7916" PostTypeId="2" ParentId="7910" CreationDate="2022-02-22T23:44:49.650" Score="5" Body="&lt;p&gt;I like to use the align environment, as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;\sum_j c_j x_j  + \sum_i d_i y_i \\&#xA;&amp;amp;\text{subject to} &amp;amp;\sum_j a_{ij}^1 x_j &amp;amp;\le b_i^1 &amp;amp;&amp;amp;\text{for all $i$} \\ &#xA;&amp;amp;&amp;amp;\sum_j a_{ij}^2 x_j &amp;amp;\le b_i^2 y_i &amp;amp;&amp;amp;\text{for all $i$} \\ &#xA;&amp;amp;&amp;amp;x_j &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $j$} \\&#xA;&amp;amp;&amp;amp;y_i &amp;amp;\in \{0,1\} &amp;amp;&amp;amp;\text{for all $i$} &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you need to save horizontal space because you have very wide constraints:&#xA;minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_j c_j x_j  + \sum_i d_i y_i$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j a_{ij}^1 x_j &amp;amp;\le b_i^1 &amp;amp;&amp;amp;\text{for all $i$} \\ &#xA;\sum_j a_{ij}^2 x_j &amp;amp;\le b_i^2 y_i &amp;amp;&amp;amp;\text{for all $i$} \\ &#xA;x_j &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $j$} \\&#xA;y_i &amp;amp;\in \{0,1\} &amp;amp;&amp;amp;\text{for all $i$} &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you need to save horizontal space but still want to display the objective: minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_j c_j x_j  + \sum_i d_i y_i$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j a_{ij}^1 x_j &amp;amp;\le b_i^1 &amp;amp;&amp;amp;\text{for all $i$} \\ &#xA;\sum_j a_{ij}^2 x_j &amp;amp;\le b_i^2 y_i &amp;amp;&amp;amp;\text{for all $i$} \\ &#xA;x_j &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $j$} \\&#xA;y_i &amp;amp;\in \{0,1\} &amp;amp;&amp;amp;\text{for all $i$} &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-02-23T02:44:18.843" LastActivityDate="2022-02-23T02:44:18.843" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7917" PostTypeId="2" ParentId="7910" CreationDate="2022-02-23T06:00:50.750" Score="2" Body="&lt;p&gt;I prefer to work with LaTeX with the hand as it is so cool and also allows you many kinds of flexibility, but an interesting tool to compare the different kinds of LaTeX for expression is &lt;a href=&quot;https://mathpix.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SNIP&lt;/a&gt; software. You only need to capture your formulation with a camera and ask the SNIP to convert it in the different LaTeX formats. As far as I know, it has a free version. An example is:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/EoUQV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EoUQV.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-02-23T06:00:50.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7918" PostTypeId="2" ParentId="7910" CreationDate="2022-02-23T06:57:46.110" Score="2" Body="&lt;p&gt;Another package worth mentioning is &lt;a href=&quot;https://www.ctan.org/pkg/optidef&quot; rel=&quot;nofollow noreferrer&quot;&gt;optidef&lt;/a&gt;. You can find some examples in &lt;a href=&quot;https://tex.stackexchange.com/a/349348/63604&quot;&gt;this answer on TeX.SE&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="3696" LastEditDate="2022-02-23T09:07:01.730" LastActivityDate="2022-02-23T09:07:01.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7919" PostTypeId="2" ParentId="7910" CreationDate="2022-02-23T07:54:09.010" Score="5" Body="&lt;p&gt;I often use the following simple template based on the &lt;code&gt;align&lt;/code&gt; environment from &lt;code&gt;amsmath&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\documentclass{article}&#xA;\usepackage{amsmath}&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{document}&#xA;\begin{align}&#xA;&amp;amp; \min_{w,b,\xi} &amp;amp; &amp;amp; \frac{1}{2}w^{t}w+C\sum_{i=1}^{N}{\xi_{i}} \nonumber \\&#xA;&amp;amp; \textrm{s.t.} &amp;amp; &amp;amp; y_{i}(w\phi(x_{i}+b))+\xi_{i}-1 \label{opt_prob:misc} \tag{42}\\&#xA;&amp;amp; &amp;amp; &amp;amp; \xi\geq0 \nonumber \\&#xA;\end{align} &#xA;\end{document}&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that the alignment for consecutive columns will switch between left/right aligned. Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="2713" LastActivityDate="2022-02-23T07:54:09.010" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7920" PostTypeId="1" AcceptedAnswerId="7936" CreationDate="2022-02-23T09:38:51.597" Score="2" ViewCount="63" Body="&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;My goal is to come up with a Resource-Constrained Project Scheduling (RCPS) model where the resource capacity constraints are aggregated and verified on time buckets, which can be of varying size. This allows the use of more detailed planning in the near future and more aggregated planning further away.&lt;/p&gt;&#xA;&lt;p&gt;To be more specific, instead of enforcing that at all times, the resource requirement is not more than the resource availability, I would like to only look at the total resource requirement in a bucket and compare that to the total resource availability in that bucket. This introduces questions such as: what if an operation overlaps multiple buckets?&lt;/p&gt;&#xA;&lt;p&gt;As an example, assume that we have two consecutive buckets [3,6] and [6,9].  Suppose that an activity is scheduled on [5,8], resource A is required for the entire activity lead time and is available at any time (yielding 3 units of resource availability per bucket). Would we then assign 1 unit of resource requirement (e.g. hour) to the first bucket and 2 units to the second bucket?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Literature example:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;As part of literature research for this problem, I came across this &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0305048302000336&quot; rel=&quot;nofollow noreferrer&quot;&gt;publication&lt;/a&gt; from Rom et al. 2002. It is about MRP in a job shop environment and uses RCPS models to do so.&lt;/p&gt;&#xA;&lt;p&gt;The model is a continuous-time model, as it allows lead times of activities to be non-integral. Interestingly, it uses time-buckets for checking resource capacity violations. The procedure is as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The time-horizon is divided into time milestones &lt;span class=&quot;math-container&quot;&gt;$T_i, i = 1, 2, \ldots, N$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Binary variable &lt;span class=&quot;math-container&quot;&gt;$y^j_i$&lt;/span&gt; equals 1 IFF activity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; completes in bucket &lt;span class=&quot;math-container&quot;&gt;$i: [T_i, T_{i+1}]$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Parameter &lt;span class=&quot;math-container&quot;&gt;$a_{jk}$&lt;/span&gt; is the amount of resource &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; needed by activity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Parameter &lt;span class=&quot;math-container&quot;&gt;$R_{i,k}$&lt;/span&gt; is the availability of resource &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; (resources that are similar are pooled) in bucket &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The resource constraints are then given by&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=1}^{N} a_{j k} y_{i}^{j} \leqslant R_{i k} \quad \forall k, i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To me, this seems a bit odd because this equation says that for all activities that end in bucket &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, we look at the total resource amount required by those activities (not necessarily in that bucket) and restrict this quantity to be less than the resource availability in a bucket. The main issue is that whenever an activity starts in e.g. bucket &lt;span class=&quot;math-container&quot;&gt;$i-1$&lt;/span&gt; but ends in bucket &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, the resource consumption seems only to be allocated to bucket &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Continuing the example mentioned above, this means that all three units of resource requirement are assigned to the second bucket, meaning that the resource is not available anymore in that bucket as its availability was 3 units.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I wonder whether my observation is correct and if anyone knows some good approaches to using time buckets in an RCPS setting. Any publications from literature would be highly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="7399" LastEditorUserId="7399" LastEditDate="2022-02-23T12:17:40.267" LastActivityDate="2022-02-25T14:06:14.717" Title="RCPS with time buckets for resource capacity constraints" Tags="|modeling|scheduling|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7921" PostTypeId="2" ParentId="7908" CreationDate="2022-02-23T11:11:13.793" Score="5" Body="&lt;p&gt;On macOS, you can find a Makefile inside &lt;code&gt;/Library/gurobi950/macos_universal2/examples/build&lt;/code&gt; to compile all examples. Open the Terminal.app and enter the following:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;# change the directory&#xA;cd /Library/gurobi950/macos_universal2/examples/build&#xA;&#xA;# compile and run all c++ examples&#xA;make run_c++&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will compile and run all c++ examples. If you want to compile a specific c++ example, you only need to include the gurobi header and link to the gurobi library. Let's take &lt;code&gt;mip1_c++.cpp&lt;/code&gt; as an example and let's take the &lt;code&gt;clang++&lt;/code&gt; compiler:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;# define bash variable for Gurobi's path&#xA;GUROBI_HOME=&amp;quot;/Library/gurobi950/macos_universal2/&amp;quot;&#xA;&#xA;# change the directory&#xA;cd $GUROBI_HOME/examples/c++&#xA;&#xA;# Compile the program&#xA;clang++ mip1_c++.cpp -I&lt;span class=&quot;math-container&quot;&gt;${GUROBI_HOME}/include/ -L$&lt;/span&gt;{GUROBI_HOME}/lib -lgurobi_c++ -lgurobi95 -o mip1_c++&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then you can execute the program inside the Terminal.app by &lt;code&gt;./mip1_c++&lt;/code&gt;. Last but not least, if you're working with C++, it's highly recommended to make yourself familiar with Makefile-Generator tools like CMake.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2022-02-23T11:11:13.793" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7922" PostTypeId="1" AcceptedAnswerId="7926" CreationDate="2022-02-23T12:54:00.430" Score="2" ViewCount="135" Body="&lt;p&gt;I'm using the &lt;code&gt;VIKOR&lt;/code&gt; multicriteria method from the &lt;code&gt;MCDM&lt;/code&gt; package. The example can be found here: &lt;a href=&quot;https://cran.r-project.org/web/packages/MCDM/MCDM.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cran.r-project.org/web/packages/MCDM/MCDM.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, I would like a clearer explanation of this method. This is the example in the link above:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;library(MCDM)&#xA;&#xA;d &amp;lt;- matrix(c(1,2,5,3000,3750,4500),nrow = 3,ncol = 2)&#xA;&amp;gt; d&#xA;     [,1] [,2]&#xA;[1,]    1 3000&#xA;[2,]    2 3750&#xA;[3,]    5 4500&#xA;&#xA;w &amp;lt;- c(0.5,0.5)&#xA;&#xA;cb &amp;lt;- c('min','max')&#xA;&#xA;v &amp;lt;- 0.5&#xA;&#xA;VIKOR(d,w,cb,v)&#xA;&#xA;&amp;gt; VIKOR(d,w,cb,v)&#xA;  Alternatives     S    R Q Ranking&#xA;1            1 0.500 0.50 1       2&#xA;2            2 0.375 0.25 0       1&#xA;3            3 0.500 0.50 1       3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I've seen that the &lt;code&gt;ranking&lt;/code&gt; is based on &lt;code&gt;Q&lt;/code&gt;, however from what I'm seeing the lowest value is the best, right? And I also didn't quite understand this value of &lt;code&gt;v&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Could you explain me better about this method?&lt;/p&gt;&#xA;" OwnerUserId="9063" LastEditorUserId="491" LastEditDate="2022-02-23T13:38:59.293" LastActivityDate="2022-02-23T19:08:58.173" Title="Using VIKOR multicriteria method in R" Tags="|r|multicriteria-decision-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7923" PostTypeId="2" ParentId="7913" CreationDate="2022-02-23T13:20:39.223" Score="0" Body="&lt;p&gt;Your question is pretty vague - to implement a scaling method, you don't necessarily need the entire constraint matrix. Especially for equilibrium scaling (as noted here, in your &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/4460822390289-How-to-make-CLion-read-lp-file-and-make-Gurobi-solve-that-file-within-CLion-?page=1#community_comment_4469937109393&quot; rel=&quot;nofollow noreferrer&quot;&gt;crosspost in the Gurobi Forum&lt;/a&gt;) you can just go through the rows and columns iteratively.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2022-02-23T13:20:39.223" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="7924" PostTypeId="2" ParentId="7908" CreationDate="2022-02-23T13:25:45.353" Score="6" Body="&lt;p&gt;There is a dedicated section about &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/quickstart_mac/cpp_interface.html#section:C++&quot; rel=&quot;noreferrer&quot;&gt;C++ programming with Gurobi in the official documentation&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There is also a &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360039499751-How-do-I-use-CMake-to-build-Gurobi-C-C-projects-&quot; rel=&quot;noreferrer&quot;&gt;CMake example in the Gurobi Knowledge Base&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2022-02-23T13:25:45.353" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7925" PostTypeId="1" CreationDate="2022-02-23T16:07:57.540" Score="4" ViewCount="262" Body="&lt;p&gt;The range that optimal value needs to avoid is taken as infeasible region through defining it as constraints but how to simultaneously optimize it such that its as far as possible?&lt;/p&gt;&#xA;" OwnerUserId="7232" LastActivityDate="2022-02-24T09:09:03.100" Title="How to optimize such that the optimal value do not fall in range and is also as away from the range possible" Tags="|optimization|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7926" PostTypeId="2" ParentId="7922" CreationDate="2022-02-23T19:08:58.173" Score="2" Body="&lt;p&gt;Yes, lowest &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; wins. The weight &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is used to form a weighted average of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; (multiplied by &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; (multiplied by &lt;span class=&quot;math-container&quot;&gt;$1-v$&lt;/span&gt;). There is a &lt;a href=&quot;https://en.wikipedia.org/wiki/VIKOR_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia page&lt;/a&gt; that attempts to explain VIKOR.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-23T19:08:58.173" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7927" PostTypeId="1" CreationDate="2022-02-24T01:12:21.550" Score="4" ViewCount="164" Body="&lt;p&gt;The deterministic problem is to minimize operational cost subject to constraints in demand, supply and capacity. The ordering policy is periodic review, order-up-to.&lt;/p&gt;&#xA;&lt;p&gt;The stochastic version of the model is to optimize the parameters for the order-up-to policy.&lt;/p&gt;&#xA;&lt;p&gt;I've looked at the literature on using multi-stage stochastic programming with news-vendor type of models for this application, but my model has additional complexities:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Multi-period, multi-item, multi-sourcing&lt;/li&gt;&#xA;&lt;li&gt;Supply and capacity constraints are important and cannot be ignored&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;It is not clear to me how to extend existing news-vendor models with all of these complexities.&lt;/p&gt;&#xA;&lt;p&gt;The simplest approach would be to generate a number of scenarios (scenario-tree) with different realizations of demand - and solve the corresponding MILPs. Each of the scenarios would be independent of others. The final answer would be an appropriately weighted &amp;quot;expectation&amp;quot; of the variables of interest.&lt;/p&gt;&#xA;&lt;p&gt;Depending on how many scenarios, along with some cleverness in choosing realizations - I can expect to come up with a reasonable set.&lt;/p&gt;&#xA;&lt;p&gt;Will this simple approach work? For example - will the average order quantity across all the MILP runs be a good estimate of the actual optimal?&lt;/p&gt;&#xA;&lt;p&gt;Are there other approaches I am missing out on?&lt;/p&gt;&#xA;" OwnerUserId="7686" LastEditorUserId="491" LastEditDate="2022-02-24T15:38:01.597" LastActivityDate="2022-02-24T15:38:01.597" Title="Stochastic optimization for inventory management" Tags="|mixed-integer-programming|inventory|stochastic-programming|base-stock|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7928" PostTypeId="2" ParentId="7925" CreationDate="2022-02-24T07:57:54.873" Score="3" Body="&lt;p&gt;I will expand on the comment I left on the question:&lt;/p&gt;&#xA;&lt;p&gt;Suppose you have a function &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; who's value should be as far as possible from a known and given interval &lt;span class=&quot;math-container&quot;&gt;$[a,b]$&lt;/span&gt;. I will here define the distance &lt;span class=&quot;math-container&quot;&gt;$D(x)$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; to the interval as &lt;span class=&quot;math-container&quot;&gt;$D(x)=\min\{\vert a-f(x)\vert,\vert b-f(x)\vert\}$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$f(x)\not\in[a,b]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise. So if &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is smaller than &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, then the distance to the interval is the absolute difference between &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is larger than &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, it should be the absolute difference between &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$f(x)\in[a,b]$&lt;/span&gt; we simply say that the distance to the interval is zero.&lt;/p&gt;&#xA;&lt;p&gt;Lets assume that there are some other constraints as well that define the set of feasible solutions. We call the set of feasible solutions &lt;span class=&quot;math-container&quot;&gt;$\mathcal{X}$&lt;/span&gt;. Then, if you want to find a feasible solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; that maximizes &lt;span class=&quot;math-container&quot;&gt;$D(x)$&lt;/span&gt; it could either be the case that &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; can be moved furthest away from the interval below &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; or above &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. To check this, you may first minimize the value of &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$\mathcal{X}$&lt;/span&gt; to see how far below &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; you can go:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;x^{\min}\in\arg\min\{f(x):x\in \mathcal{X}\}&#xA;\end{equation}&lt;/span&gt;&#xA;Next you check how much above &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; you can move &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; (if at all) by solving the optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;  x^{\max}\in\arg\max\{f(x):x\in \mathcal{X}\}&#xA;\end{equation}&lt;/span&gt;&#xA;Then, you simply pick the &lt;span class=&quot;math-container&quot;&gt;$x\in\{x^{\min},x^{\max}\}$&lt;/span&gt; that maximizes your distance to the interval.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-02-24T07:57:54.873" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7929" PostTypeId="2" ParentId="7925" CreationDate="2022-02-24T09:09:03.100" Score="4" Body="&lt;p&gt;Expanding on @Sune's approach, you could do it one step by introducing a binary variable &lt;span class=&quot;math-container&quot;&gt;$y \in \{0,1\}$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$f(x) &amp;lt; a$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Your objective function becomes:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \; |f(x)-ay - b(1-y) |&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And you activate &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; with big-M constraints such as:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;b + \epsilon -My \le f(x) &amp;amp;\le a - \epsilon + M(1-y) \\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-02-24T09:09:03.100" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7931" PostTypeId="1" CreationDate="2022-02-24T16:31:10.863" Score="4" ViewCount="143" Body="&lt;p&gt;Are there any rules of thumb about when to implement which? For example, I am trying to solve OR scheduling problems. I see that majority of people have implemented Genetic Algorithms. However, more recently, several people have implemented Tabu Search Algorithms. I want to know if there is any guideline?&lt;/p&gt;&#xA;" OwnerUserId="3520" LastActivityDate="2022-02-24T16:31:10.863" Title="When to use Tabu Search or Genetic Algorithms and when not?" Tags="|metaheuristics|local-search|genetic-algorithm|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7932" PostTypeId="2" ParentId="7910" CreationDate="2022-02-24T18:49:31.053" Score="6" Body="&lt;p&gt;I personally like the align environment with the following syntax:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\begin{align}&#xA;\label{eq:f.0} \mbox{minimize}~&amp;amp; \;\sum_{k\in K}\sum_{(i,j)\in A}c_{ijk}x_{ijk} + f_{ij}y_{ij}&amp;amp; \\&#xA;\label{eq:f.1} \mbox{s.t. } &amp;amp;\sum_{(o_k,j)\in A}x_{o_kj}^{k}=1  &amp;amp; \forall k\in K\\&#xA;\label{eq:f.2}&amp;amp;\sum_{(j,i)\in A}x_{ji}^{k}=\sum_{(i,j)\in A}x_{ij}^{k} &amp;amp; \forall k\in K, i\in V \setminus \{o_k,d_k\}\\&#xA;\label{eq:f.3}&amp;amp;\sum_{(i,d_k)\in A}x_{id_k}^{k}=1 &amp;amp; \forall k\in K\\&#xA;\label{eq:f.4}&amp;amp;0\leq x_{ijk}\leq y_{ij} &amp;amp; \forall k\in K, (i,j)\in A\\&#xA;\label{eq:f.5}&amp;amp; y_{ij} \in \{0,1\} &amp;amp; \forall (i,j)\in A&#xA;\end{align}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The result:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\label{eq:f.0} \mbox{minimize}~&amp;amp; \;\sum_{k\in K}\sum_{(i,j)\in A}c_{ijk}x_{ijk} + f_{ij}y_{ij}&amp;amp; \\&#xA;\label{eq:f.1} \mbox{s.t. } &amp;amp;\sum_{(o_k,j)\in A}x_{o_kj}^{k}=1  &amp;amp; \forall k\in K\\&#xA;\label{eq:f.2}&amp;amp;\sum_{(j,i)\in A}x_{ji}^{k}=\sum_{(i,j)\in A}x_{ij}^{k} &amp;amp; \forall k\in K, i\in V \setminus \{o_k,d_k\}\\&#xA;\label{eq:f.3}&amp;amp;\sum_{(i,d_k)\in A}x_{id_k}^{k}=1 &amp;amp; \forall k\in K\\&#xA;\label{eq:f.4}&amp;amp;0\leq x_{ijk}\leq y_{ij} &amp;amp; \forall k\in K, (i,j)\in A\\&#xA;\label{eq:f.5}&amp;amp; y_{ij} \in \{0,1\} &amp;amp; \forall (i,j)\in A&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now it happens that your objective function has multiple terms and is quite long. This can mess up your formatting. One practical way to fix that is to use mathrlap:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\begin{align}&#xA;\label{eq:f.0} \mbox{minimize}~&amp;amp; \;\sum_{k\in K}\sum_{(i,j)\in A}c_{ijk}x_{ijk} + f_{ij}y_{ij} \mathrlap{+ \sum_{k\in K}\sum_{(i,j)\in A}c'_{ijk}x_{ijk} + f'_{ij}y_{ij}}&amp;amp; \\&#xA;\label{eq:f.1} \mbox{s.t. } &amp;amp;\sum_{(o_k,j)\in A}x_{o_kj}^{k}=1  &amp;amp; \forall k\in K\\&#xA;\label{eq:f.2}&amp;amp;\sum_{(j,i)\in A}x_{ji}^{k}=\sum_{(i,j)\in A}x_{ij}^{k} &amp;amp; \forall k\in K, i\in V \setminus \{o_k,d_k\}&#xA;\end{align}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The result (this is a picture since mathjax doesn't seem to understand mathrlap):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7TAzB.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7TAzB.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;if your objective is really long, you want to split it over multiple lines. Simply add a &lt;code&gt;\notag&lt;/code&gt; to prevent the numbering of your equations to increment. Here's again the code and corresponding result:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\begin{align}&#xA;\label{eq:f3.0} \mbox{minimize}~&amp;amp; \;\sum_{k\in K}\sum_{(i,j)\in A}c_{ijk}x_{ijk} + f_{ij}y_{ij} + xyz + &amp;amp; \\\notag&#xA;\label{eq:f3.1} &amp;amp; \sum_{k\in K}\sum_{(i,j)\in A}c'_{ijk}x_{ijk} + f'_{ij}y_{ij} &amp;amp; \\&#xA;\label{eq:f3.2} \mbox{s.t. } &amp;amp;\sum_{(o_k,j)\in A}x_{o_kj}^{k}=1  &amp;amp; \forall k\in K\\&#xA;\label{eq:f3.3}&amp;amp;\sum_{(j,i)\in A}x_{ji}^{k}=\sum_{(i,j)\in A}x_{ij}^{k} &amp;amp; \forall k\in K, i\in V \setminus \{o_k,d_k\}&#xA;\end{align}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OjF87.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OjF87.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2022-02-24T18:49:31.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7933" PostTypeId="1" CreationDate="2022-02-25T09:02:08.997" Score="6" ViewCount="245" Body="&lt;p&gt;Lets assume a complex production system that is fed by tasks of type &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; (e.g. &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; = deliver material) . Within a horizon of interest &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;, a number &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; of tasks &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; can be performed. The model of the problem results in a difficult MILP.&lt;/p&gt;&#xA;&lt;p&gt;Solving the relaxed model for &lt;span class=&quot;math-container&quot;&gt;$N=1, N=2, N=3, ... , N=5$&lt;/span&gt;, I obtain the following values for the objective function (maximization).&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;&amp;amp; N=1   &amp;amp;  1000.0 \\&#xA;&amp;amp; N=2   &amp;amp;  1200.0 \\&#xA;&amp;amp; N=3   &amp;amp;  2100.0 \\&#xA;&amp;amp; N=4   &amp;amp;  2100.0 \\&#xA;&amp;amp; N=5   &amp;amp;  1800.0 \\&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Can I assume, that setting &lt;span class=&quot;math-container&quot;&gt;$N=3$&lt;/span&gt; will not cut off the optimal solution of the original problem?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="1269" LastEditDate="2022-02-26T17:49:09.727" LastActivityDate="2022-12-25T12:02:35.997" Title="Trying to keep MILP model small" Tags="|mixed-integer-programming|heuristics|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7934" PostTypeId="1" AcceptedAnswerId="7940" CreationDate="2022-02-25T10:24:16.400" Score="4" ViewCount="303" Body="&lt;p&gt;I am trying to optimize the allocation of of products inside a fictive warehouse, having a predefined number of &lt;strong&gt;aisles&lt;/strong&gt; (&lt;code&gt;3&lt;/code&gt; in the example code below) where products can be placed. For now, the only optimization criterion that I would like to impose in the objective function is:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;products that have been frequently part of the same order (i.e., people ordering product &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; also ordered product &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;) should be placed in the same aisle&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As input I have a list of historical orders (randomly created in the example), where each order is composed of one or more products/articles. Using the list I build a &lt;strong&gt;co-occurrence matrix&lt;/strong&gt;, that shows the number of times two articles were part of the same order, for each pair of articles.&lt;/p&gt;&#xA;&lt;p&gt;The following code (full of comments) shows how I implemented the model using &lt;strong&gt;Docplex&lt;/strong&gt; (IBM Decision Optimization CPLEX Optimizer Modeling for Python):&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;import numpy as np&#xA;import pandas as pd&#xA;import docplex&#xA;&#xA;print(docplex.__version__)&#xA;# docplex version: 2.22.213&#xA;# Cplex version: 20.1.0.0&#xA;&#xA;################## Clean and Prepare Data ##################&#xA;&#xA;# number of (historical) orders containing one or more articles&#xA;num_orders = 50&#xA;# number of different articles (products) available&#xA;num_articles = 40&#xA;# number of records, i.e., couples (o, a) of order-article, meaning that the article a is part of order o&#xA;s = (250, 1)&#xA;&#xA;# aisles of the warehouse, with respective capacity (maximum number of articles that can be placed in them)&#xA;aisles = {1: 15, 2: 17, 3: 20}&#xA;&#xA;# building a dataframe from the input data&#xA;order_col = np.random.randint(low=1, high=num_orders, size=s)&#xA;arts_col = np.random.randint(low=1, high=num_articles, size=s)&#xA;temp = np.array([1]*s[0]).reshape(s)&#xA;cols = np.concatenate((order_col, arts_col, temp), axis=1)&#xA;df = pd.DataFrame(cols, columns=[&amp;quot;ORDER_NUMBER&amp;quot;, &amp;quot;ARTICLE_CODE&amp;quot;, &amp;quot;TEMP&amp;quot;])&#xA;&#xA;# missing articles due to randomness in building the &amp;quot;ARTICLE_CODE&amp;quot; column of df&#xA;missing_articles_randomness = set(range(1, num_articles+1)).difference(set(df[&amp;quot;ARTICLE_CODE&amp;quot;]))&#xA;&#xA;to_add = pd.DataFrame()&#xA;to_add[&amp;quot;ORDER_NUMBER&amp;quot;] = df[&amp;quot;ORDER_NUMBER&amp;quot;].iloc[:len(missing_articles_randomness)]&#xA;to_add[&amp;quot;ARTICLE_CODE&amp;quot;] = list(missing_articles_randomness)&#xA;to_add[&amp;quot;TEMP&amp;quot;] = 1&#xA;&#xA;# they need to be appended to the dataframe so that the corresponding row and column shows up in the co-occurrence matrix&#xA;df = df.append(to_add, ignore_index=True)&#xA;&#xA;# create the co-occurrence matrix&#xA;temp_count = df.pivot_table(index=&amp;quot;ORDER_NUMBER&amp;quot;, columns=&amp;quot;ARTICLE_CODE&amp;quot;, &#xA;                            values=&amp;quot;TEMP&amp;quot;, aggfunc=&amp;quot;count&amp;quot;).fillna(0)&#xA;&#xA;coocc = temp_count.T.dot(temp_count)&#xA;np.fill_diagonal(coocc.values, 0)&#xA;&#xA;coocc.head()&#xA;&#xA;&#xA;################## Create Optimization Model ##################&#xA;&#xA;mdl = Model(&amp;quot;coocc_v1&amp;quot;)&#xA;&#xA;R = range(1, num_articles+1)&#xA;id_1 = [(i, j) for i in R for j in R[i:]]&#xA;# binary variable indicating whether two articles are located in the same aisle&#xA;arts_same_aisle = mdl.binary_var_dict(id_1, name=&amp;quot;asa&amp;quot;)&#xA;&#xA;id_2 = [(c, j) for c in aisles for j in R]&#xA;# binary variable indicating whether an article a is located in an aisle c&#xA;art_aisle = mdl.binary_var_dict(id_2, name=&amp;quot;aa&amp;quot;)&#xA;&#xA;# each article can be placed in only one aisle&#xA;constr_1 = mdl.add_constraints([mdl.sum([art_aisle[c, j] for c in aisles]) == 1 for j in R])&#xA;&#xA;# each aisle has a maximum capacity&#xA;constr_2 = mdl.add_constraints([mdl.sum([art_aisle[c, j] for j in R]) &amp;lt;= cap for c, cap in aisles.items()])&#xA;&#xA;&#xA;# definition of arts_same_aisle_i_j: 1 if article i and article j are in the same aisle, 0 otherwise&#xA;for i in R:&#xA;    for j in R[i:]:&#xA;        arts_same_aisle[(i, j)] = mdl.logical_or(*[mdl.logical_and(art_aisle[c, i] == 1, art_aisle[c, j] == 1) for c in aisles])&#xA;&#xA;# the 'co-occurrence score', that is, positioning articles in the same aisle if they are frequently part of the same order &#xA;obj1 = mdl.sum([arts_same_aisle[i, j] * coocc.loc[i, j] for i in R for j in R[i:]])&#xA;&#xA;# the goal is to maximize the objective function&#xA;mdl.maximize(obj1)&#xA;&#xA;################## Model Solving ##################&#xA;&#xA;solution = mdl.solve(log_output=True)&#xA;# Total (root+branch&amp;amp;cut) =  759.07 sec. (477653.82 ticks)&#xA;# integer optimal solution&#xA;# objective value: 393.0&#xA;&#xA;sol_df = solution.as_df()&#xA;sol_df = sol_df.loc[sol_df[&amp;quot;name&amp;quot;].str.startswith(&amp;quot;aa&amp;quot;)]&#xA;&#xA;for n, i in zip([&amp;quot;aisle&amp;quot;, &amp;quot;article&amp;quot;], [1, 2]):&#xA;    sol_df[n] = sol_df[&amp;quot;name&amp;quot;].apply(lambda x: x.split(&amp;quot;_&amp;quot;)[i])&#xA;&#xA;s = sol_df.groupby(&amp;quot;aisle&amp;quot;)[&amp;quot;article&amp;quot;].apply(list)&#xA;print(s)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which gives&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;aisle&#xA;1                                         [15, 26, 40]&#xA;2    [1, 2, 3, 4, 5, 6, 9, 14, 17, 18, 19, 20, 23, ...&#xA;3    [7, 8, 10, 11, 12, 13, 16, 21, 22, 24, 27, 30,...&#xA;Name: article, dtype: object&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Unfortunately, the &lt;strong&gt;solving time&lt;/strong&gt; explodes when the number of different articles or aisles increases, and I could not find a non-trivial reformulation of the model that significantly reduces the solving time of the problem.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to reformulate the problem to make it usable in a real-life scenario, with thousands of articles and tens / few hundreds of aisles?&lt;/p&gt;&#xA;" OwnerUserId="9244" LastEditorUserId="9244" LastEditDate="2022-03-02T11:30:50.000" LastActivityDate="2022-03-02T11:30:50.000" Title="Reformulate CPLEX optimization model of Warehouse Product Allocation" Tags="|optimization|mixed-integer-programming|cplex|computational-complexity|docplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7935" PostTypeId="2" ParentId="7720" CreationDate="2022-02-25T10:34:33.793" Score="2" Body="&lt;p&gt;I suggest you consider the &lt;em&gt;Parameterized&lt;/em&gt; Fusion API for MOSEK (available in Python). You can use it to construct your model without passing actual data for the parameter values, and then set the parameter values before solving. Over repeated solves, this can potentially save you a &lt;em&gt;lot&lt;/em&gt; of time. While constructing some examples here at MOSEK, I have often seen Parameterized Fusion take about a fifth of the time as compared to Fusion. This was naturally for problems where constructing the model takes a significant amount of time (relative to solving it).&lt;/p&gt;&#xA;&lt;p&gt;Additionally, if you make your problem linear (as you mentioned), then you can use the warm-start functionality of the simplex solver. That should also make a huge difference. Again, in a particular instance, I saw the total time be reduced to a fifth of what it would be without warm-start.&lt;/p&gt;&#xA;" OwnerUserId="2713" LastActivityDate="2022-02-25T10:34:33.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7936" PostTypeId="2" ParentId="7920" CreationDate="2022-02-25T14:06:14.717" Score="1" Body="&lt;p&gt;There is a general PPT presentation on multi-period planning at&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.lindo.com/library/MultiPeriodPlan43.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.lindo.com/library/MultiPeriodPlan43.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It has several slides on how to choose period length, how to (and how not to) represent resource capacity constraints and precedence constraints.&lt;/p&gt;&#xA;&lt;p&gt;It also has several dozen references at the end on multi-period optimization models.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-02-25T14:06:14.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7937" PostTypeId="1" CreationDate="2022-02-25T14:42:06.593" Score="1" ViewCount="30" Body="&lt;p&gt;The dataset below presents the ranking of different multicriteria methods. My idea is to generate a final ranking based on the multicriteria methods for all alternatives, but it can be seen that in some cases both methods presented the same results as is the case for the alternative with 2 clusters. For the alternative with 5 clusters, they presented different rankings.  I spoke to an expert on this and he said the following: &amp;quot;My advice to you is this: Compare the MCDM ranking results you find statistically with a third party. In this sense, you can use the &lt;strong&gt;Spearman Rho coefficient&lt;/strong&gt;&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Do you know how I can use this coefficient in R in this dataset below?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;df1&amp;lt;-structure(list(nclusters = c(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, &#xA;    12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), Promethee = c(1L, &#xA;    6L, 4L, 5L, 2L, 3L, 23L, 24L, 22L, 21L, 20L, 19L, 17L, 18L, 9L, &#xA;    10L, 11L, 12L, 13L, 14L, 15L, 16L, 8L, 7L), WSM = c(1, 24, 20, &#xA;    19, 18, 17, 23, 22, 21, 16, 15, 14, 13, 12, 7, 6, 5, 4, 11, 10, &#xA;    9, 8, 3, 2), TOPSIS = c(1L, 24L, 20L, 21L, 18L, 19L, 22L, 23L, &#xA;    17L, 16L, 15L, 14L, 12L, 13L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, &#xA;    3L, 2L), VIKOR = c(1L, 24L, 19L, 20L, 17L, 18L, 22L, 23L, 21L, &#xA;    16L, 15L, 14L, 12L, 13L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 3L, &#xA;    2L)), class = &amp;quot;data.frame&amp;quot;, row.names = c(NA, -24L))&#xA;&#xA;    &amp;gt; df1&#xA;       nclusters Promethee WSM TOPSIS VIKOR&#xA;    1          2         1   1      1     1&#xA;    2          3         6  24     24    24&#xA;    3          4         4  20     20    19&#xA;    4          5         5  19     21    20&#xA;    5          6         2  18     18    17&#xA;    6          7         3  17     19    18&#xA;    7          8        23  23     22    22&#xA;    8          9        24  22     23    23&#xA;    9         10        22  21     17    21&#xA;    10        11        21  16     16    16&#xA;    11        12        20  15     15    15&#xA;    12        13        19  14     14    14&#xA;    13        14        17  13     12    12&#xA;    14        15        18  12     13    13&#xA;    15        16         9   7      4     4&#xA;    16        17        10   6      5     5&#xA;    17        18        11   5      6     6&#xA;    18        19        12   4      7     7&#xA;    19        20        13  11      8     8&#xA;    20        21        14  10      9     9&#xA;    21        22        15   9     10    10&#xA;    22        23        16   8     11    11&#xA;    23        24         8   3      3     3&#xA;    24        25         7   2      2     2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9063" LastActivityDate="2022-02-25T14:42:06.593" Title="How to utilize Spearman Rho coefficient" Tags="|r|multicriteria-decision-analysis|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7938" PostTypeId="2" ParentId="6169" CreationDate="2022-02-25T14:48:46.627" Score="2" Body="&lt;p&gt;Update (2023-06-06):&lt;/p&gt;&#xA;&lt;p&gt;Our &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2023.06.006&quot; rel=&quot;nofollow noreferrer&quot;&gt;recent work&lt;/a&gt; introduces a &lt;strong&gt;logic-based Benders decomposition method with sub gradient cut&lt;/strong&gt;, which can handle general integer (not binary) master variables.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Guo, P., &amp;amp; Zhu, J. (2023). Capacity reservation for humanitarian relief: A logic-based Benders decomposition method with subgradient cut. European Journal of Operational Research. &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2023.06.006&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.ejor.2023.06.006&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I have been stuck in similar problem before I found out that logic-based Benders decomposition (LBBD) is nothing but an outer-approximation technique. Consider a (continues / general integer) Benders master problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_{X \in \mathcal{X}, \theta \geq 0} c^\top X + \theta&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; is an estimator for the subproblem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;Q(X) = \min_{Y \in \mathcal{Y}} q(X, Y)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$X \in \mathcal{X}$&lt;/span&gt; denotes master problem variables and &lt;span class=&quot;math-container&quot;&gt;$Y \in \mathcal{Y}$&lt;/span&gt; denote sub problem varaibles. Then we have the logic-based Benders cut:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\theta \geq \hat{Q} - \nabla^\top \cdot (X - \bar{X})&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\hat{Q}$&lt;/span&gt; is the optimal objective of subproblem with given &lt;span class=&quot;math-container&quot;&gt;$\bar{X}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\nabla$&lt;/span&gt; is gradient of &lt;span class=&quot;math-container&quot;&gt;$q(X, Y)$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; (master variable).&#xA;Unfortunately, it is non trivial to obtain &lt;span class=&quot;math-container&quot;&gt;$\nabla$&lt;/span&gt;, even when domain of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is continues, consider that &lt;span class=&quot;math-container&quot;&gt;$q(X, Y)$&lt;/span&gt; itself is an optimization problem.&#xA;For your problem, &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is integer, you may compute &lt;span class=&quot;math-container&quot;&gt;$\nabla$&lt;/span&gt; as sub gradient (reduced cost) by domain knowledge of your problem (&lt;strong&gt;&amp;quot;logic&amp;quot;&lt;/strong&gt; in LBBD). The LBBD converges when &lt;span class=&quot;math-container&quot;&gt;$q(X, Y)$&lt;/span&gt; is convex.&lt;/p&gt;&#xA;&lt;p&gt;You may refer to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.dei.unipd.it/%7Efisch/papers/slides/2017%20Sorrento%20%5BFischetti%20on%20Benders%5D.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Benders in a nutshell&lt;/a&gt; (page6, page7)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/a/188/8718&quot;&gt;How to determine if a given problem seems to be a good fit to be solved using combinatorial Benders decomposition&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8718" LastEditorUserId="8718" LastEditDate="2023-06-07T16:50:33.943" LastActivityDate="2023-06-07T16:50:33.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7939" PostTypeId="2" ParentId="4740" CreationDate="2022-02-25T16:16:53.907" Score="2" Body="&lt;p&gt;Following are some examples that include objective functions in their logic-based Benders sub problems.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Baloch, G., Gzara, F., 2020. Strategic Network Design for Parcel Delivery with Drones Under Competition. Transportation Science 54, 204–228. &lt;a href=&quot;https://doi.org/10.1287/trsc.2019.0928&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/trsc.2019.0928&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Barzanji, R., Naderi, B., Begen, M.A., 2020. Decomposition algorithms for the integrated process planning and scheduling problem. Omega 93, 102025. &lt;a href=&quot;https://doi.org/10.1016/j.omega.2019.01.003&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.omega.2019.01.003&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Guo, C., Bodur, M., Aleman, D.M., Urbach, D.R., 2021. Logic-Based Benders Decomposition and Binary Decision Diagram Based Approaches for Stochastic Distributed Operating Room Scheduling. INFORMS Journal on Computing ijoc.2020.1036. &lt;a href=&quot;https://doi.org/10.1287/ijoc.2020.1036&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/ijoc.2020.1036&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Naderi, B., Roshanaei, V., 2020. Branch-Relax-and-Check: A tractable decomposition method for order acceptance and identical parallel machine scheduling. European Journal of Operational Research 286, 811–827. &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2019.10.014&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.ejor.2019.10.014&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Roshanaei, V., Luong, C., Aleman, D.M., Urbach, D., 2017. Propagating logic-based Benders’ decomposition approaches for distributed operating room scheduling. European Journal of Operational Research 257, 439–455. &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2016.08.024&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.ejor.2016.08.024&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Roshanaei, V., Naderi, B., 2021. Solving integrated operating room planning and scheduling: Logic-based Benders decomposition versus Branch-Price-and-Cut. European Journal of Operational Research 293, 65–78. &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2020.12.004&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.ejor.2020.12.004&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Tran, T.T., Araujo, A., Beck, J.C., 2016. Decomposition Methods for the Parallel Machine Scheduling Problem with Setups. INFORMS Journal on Computing 28, 83–95. &lt;a href=&quot;https://doi.org/10.1287/ijoc.2015.0666&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/ijoc.2015.0666&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Zhang, Y., Lin, W.-H., Huang, M., Hu, X., 2019. Multi-warehouse package consolidation for split orders in online retailing. European Journal of Operational Research. &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2019.07.004&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.ejor.2019.07.004&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When sub problem is solved by constraint programming (CP), the Benders cut is &lt;strong&gt;&amp;quot;feasibility cut&amp;quot;&lt;/strong&gt;. When sub problem have an objective function, it have to be solved with an MIP solver (when subproblem contains integer variable), and the Benders cut is &lt;strong&gt;&amp;quot;optimality cut&amp;quot;&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Based on my experience on implementing logic-based Benders decomposition (LBBD), the reason that most of previous works modeling subproblem as feasibility-checking problem is, to solve subproblem to optimum (find optimal solution / prove optimality) is far more time consuming than CP. Include objective function in subproblem make LBBD inefficient consider that subproblems have to be solved many times.&lt;/p&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2022-02-25T16:16:53.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7940" PostTypeId="2" ParentId="7934" CreationDate="2022-02-25T17:06:24.040" Score="6" Body="&lt;p&gt;This is an instance of the &lt;em&gt;quadratic assignment problem&lt;/em&gt;, which is known to be difficult.&lt;/p&gt;&#xA;&lt;p&gt;You have binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{ic}$&lt;/span&gt; to indicate whether article &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to aisle &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; to indicate whether articles &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; are assigned to the same aisle.  Your formulation maximizes the total reward &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i&amp;lt;j} r_{ij} y_{ij}$$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_c x_{ic} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \tag1 \\&#xA;\sum_i x_{ic} &amp;amp;\le b_c &amp;amp;&amp;amp;\text{for all $c$} \tag2 \\&#xA;y_{ij} &amp;amp;= \vee_c x_{ic} x_{jc} &amp;amp;&amp;amp;\text{for all $i&amp;lt;j$} \tag3&#xA;\end{align}&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; assigns each article to exactly one aisle.  Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; imposes capacity &lt;span class=&quot;math-container&quot;&gt;$b_c$&lt;/span&gt; on aisle &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.  Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; enforces the definition of &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt;, which the solver presumably linearizes in the usual way by introducing a new variable &lt;span class=&quot;math-container&quot;&gt;$z_{ijc}$&lt;/span&gt; to represent the product &lt;span class=&quot;math-container&quot;&gt;$x_{ic}x_{jc}$&lt;/span&gt; and then replacing &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; with linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z_{ijc} &amp;amp;\le x_{ic} &amp;amp;&amp;amp;\text{for all $i&amp;lt;j$ and $c$} \tag4 \\&#xA;z_{ijc} &amp;amp;\le x_{jc} &amp;amp;&amp;amp;\text{for all $i&amp;lt;j$ and $c$} \tag5 \\&#xA;y_{ij} &amp;amp;\le \sum_c z_{ijc} &amp;amp;&amp;amp;\text{for all $i&amp;lt;j$} \tag6&#xA;\end{align}&lt;/span&gt;&#xA;You can try explicitly replacing &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; through &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt;.&#xA;You can also try relaxing &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to be nonnegative rather than binary.&#xA;You can try omitting &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt; and replacing the objective function with &lt;span class=&quot;math-container&quot;&gt;$\sum_{i&amp;lt;j} r_{ij} \sum_c z_{ijc}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;An alternative approach is to use &lt;em&gt;compact linearization&lt;/em&gt; as follows.&lt;/p&gt;&#xA;&lt;p&gt;Introduce binary (or nonnegative) variable &lt;span class=&quot;math-container&quot;&gt;$w_{icjd}$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$x_{ic}x_{jd}$&lt;/span&gt;, and maximize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i&amp;lt;j}r_{ij} \sum_c w_{icjc}$$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, and&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_c w_{icjd} &amp;amp;= x_{jd} &amp;amp;&amp;amp;\text{for all $i,j,d$} \tag7 \\&#xA;w_{icjd} &amp;amp;\le x_{ic} &amp;amp;&amp;amp;\text{for all $i,j,c,d$} \tag8 \\&#xA;w_{icjd} &amp;amp;= w_{jdic} &amp;amp;&amp;amp;\text{for all $i&amp;lt;j,c,d$} \tag9 \\&#xA;w_{icic} &amp;amp;= x_{ic} &amp;amp;&amp;amp;\text{for all $i,c$} \tag{10}&#xA;\end{align}&lt;/span&gt;&#xA;Note that &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt; is obtained by multiplying &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$x_{jd}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Yet another approach is to solve this directly as a binary quadratic programming problem: maximize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i&amp;lt;j}r_{ij} \sum_c x_{ic}x_{jc}$$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-02-25T18:48:20.913" LastActivityDate="2022-02-25T18:48:20.913" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7941" PostTypeId="2" ParentId="7933" CreationDate="2022-02-25T17:39:58.107" Score="0" Body="&lt;p&gt;I'm moving my last comment to an answer.&lt;/p&gt;&#xA;&lt;p&gt;Assuming the values stated (1000 for &lt;span class=&quot;math-container&quot;&gt;$N=1$&lt;/span&gt; etc.) are optimal values for the LP relaxations, the fact that the maximum with N=5 is less than the maximum with N=3 indicates that there are solutions to the relaxation with N=3 that are not feasible when N=5. That implies that it is possible that the solution to the integer model with N=3 might not be feasible when N=5. So no, you cannot be sure the solution with N=3 is optimal for N=5.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Edit: My original answer (below) was for the original question, which has since been clarified, and is irrelevant to the clarified version.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;It's unclear what &amp;quot;the original problem&amp;quot; is. Assuming that &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; appears only as an upper limit in the constraints (e.g., &lt;span class=&quot;math-container&quot;&gt;$n\le N$&lt;/span&gt;), you can safely say that any solution that is optimal for a given value of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; will remain feasible (though possibly not optimal) for any &lt;span class=&quot;math-container&quot;&gt;$N^{'} &amp;gt; N$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-07-26T18:41:05.283" LastActivityDate="2022-07-26T18:41:05.283" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7942" PostTypeId="1" CreationDate="2022-02-25T22:16:04.700" Score="3" ViewCount="606" Body="&lt;p&gt;I'm trying to solve multi commodity multi source network flow optimization problem using Python-PuLP. Here is how my problem looks like:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/vhPB0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vhPB0.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The numbers on the arcs represent the order of priority a particular node should receive supply from. For example, D1 should get first serviced by W2, then W1, and W3 respectively.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Variables:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;W = set of all Warehouses (W1, W2, W3)&lt;/li&gt;&#xA;&lt;li&gt;D = set of all DCs (D1, D2, D3)&lt;/li&gt;&#xA;&lt;li&gt;C = set of all Commodities (C1, C2)&lt;/li&gt;&#xA;&lt;li&gt;N = set of all nodes (W1, W2, W3, D1, D2, D3)&lt;/li&gt;&#xA;&lt;li&gt;Arcs = set of all connections (w, d) for w &lt;span class=&quot;math-container&quot;&gt;$\subset$&lt;/span&gt; W and d &lt;span class=&quot;math-container&quot;&gt;$\subset$&lt;/span&gt; D&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Current assumptions:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All commodities have the same Warehouse-DC connection priorities.&lt;/li&gt;&#xA;&lt;li&gt;Transport trucks have unlimited capacities and same cost.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;QUESTION 1 -&lt;/strong&gt; I would like to know how to include this in the design since I'm currently using the priority in the arcs to identify from which source the commodity should be shipped.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Currently I'm trying to use a for-loop to find solutions for all commodities. I believe there is an elegant way to depict the same problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;QUESTION 2 -&lt;/strong&gt; How can I use the optimization design to include many commodities. Eventually I will want to add additional constraints on how much I can transport per arc.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;for c in C:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Decision variables:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;route -&amp;gt; Arcs &#xA;route_used = 1 iff route is selected, 0 otherwise&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;min &lt;span class=&quot;math-container&quot;&gt;$\sum (RouteSelected[(w,d),1]*cost[(w,d)])$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;QUESTION 3 -&lt;/strong&gt; I have not chosen another objective to ensure the maximum fulfilment to all DCs. Should I first run an iteration to solve for maximum fulfilment and then run for minimum of the route selected as defined above? Is there a better way to define this as multi-objective together?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Bounds:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for w, d in route:&#xA;    route[(w, d)] &amp;gt;= 0&#xA;    route[(w, d)] &amp;lt;= min(Supply[w], Demand[d]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;1. Flow conservation constraint&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if Total Supply &amp;lt; Total Demand:&#xA;    for n in nodes:&#xA;        (Supply[n] +  sum(route[(w, d)]) for w, d in Arcs and d==n) &amp;lt;=&#xA;        (Demand[n] +  sum(route[(w, d)]) for w, d in Arcs and w==n)&#xA;else:&#xA;    for n in nodes:&#xA;        (Supply[n] +  sum(route[(w, d)]) for w, d in Arcs and d==n) &amp;gt;=&#xA;        (Demand[n] +  sum(route[(w, d)]) for w, d in Arcs and w==n)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;em&gt;2. Specific DC priority&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;When the total supply is less than the total demand, I want to service the demand at a specific DC first irrespective of my objective function. For example, let’s consider DC D1&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if Total Supply &amp;lt; Total Demand:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;QUESTION 4a -&lt;/strong&gt; I want to satisfy the maximum possible demand for D1 from all my connected warehouses. How do I define that?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;QUESTION 4b -&lt;/strong&gt; Assuming we always run into situations where supply &amp;lt; demand, how should I let the optimizer know the order of fulfilment. For example, solve for DC1, then DC3, followed by DC2? Or is this inherently used by the choice of optimizer I use?&lt;/p&gt;&#xA;" OwnerUserId="6127" LastActivityDate="2022-02-27T00:48:30.003" Title="Designing a multi-commodity network flow optimizer" Tags="|optimization|network-flow|multi-objective-optimization|facility-location|pulp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7943" PostTypeId="1" AcceptedAnswerId="7946" CreationDate="2022-02-25T23:02:37.500" Score="2" ViewCount="57" Body="&lt;p&gt;An international company has offices in different countries. The company wants to look at the office expenditures on stationery across it's offices.&lt;/p&gt;&#xA;&lt;p&gt;Because sourcing locations are different, similar list of items costed differently.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;8 offices in Europe spent on average &lt;span class=&quot;math-container&quot;&gt;$200&#xA;8 offices in America spent on average $&lt;/span&gt;300&#xA;5 offices in Asia spent on average $100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What would be the one representative number to reflect the spending overall?&lt;/p&gt;&#xA;&lt;p&gt;Thinking to use the number of office and their averaged spends, sum them up and divide by the total number of offices, i.e.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(8 * 200 + 8 * 300 + 5 *100) / (8+8+5) = $214 (rounded)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It doesn't seem good as not considering the contributions of European and Asian offices.&lt;/p&gt;&#xA;&lt;p&gt;If it uses the medium of [100,200,300], i.e. 200. It is neither fair.&lt;/p&gt;&#xA;&lt;p&gt;In this way, it still returns $214 (rounded):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oZilq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oZilq.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;What would be the good way to consider the number of different offices and their contributions?&lt;/p&gt;&#xA;" OwnerUserId="2440" LastEditorUserId="491" LastEditDate="2022-02-26T02:14:10.777" LastActivityDate="2022-02-26T17:35:31.423" Title="Averaging the averages with weights" Tags="|applications|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7944" PostTypeId="2" ParentId="7934" CreationDate="2022-02-25T23:04:11.240" Score="2" Body="&lt;p&gt;I would try the reformulations suggested by @RobPratt first. If those don't scale sufficiently well, you might consider the following.&lt;/p&gt;&#xA;&lt;p&gt;Suppose, (very) hypothetically, that we had a list of all possible aisle layouts. Let &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; be a binary matrix with one row for every item and one column for every layout, such that &lt;span class=&quot;math-container&quot;&gt;$A_{ij}=1$&lt;/span&gt; if and only if layout &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; includes item &lt;span class=&quot;math-container&quot;&gt;$i.$&lt;/span&gt; Assume that layouts were designed to respect the capacity limit. Moreover, assume you have computed a colocation score &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; for each layout &lt;span class=&quot;math-container&quot;&gt;$j.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now create a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; for each layout &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, 1 if you use it and 0 if not. Your first constraint is &lt;span class=&quot;math-container&quot;&gt;$$\sum_j x_j \le N$$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is the number of aisles available. . For each article &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, you have a constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_j a_{ij} x_j = 1$$&lt;/span&gt; forcing you to use exactly one layout containing item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Your objective is to maximize &lt;span class=&quot;math-container&quot;&gt;$$\sum_j c_j x_j,$$&lt;/span&gt; the aggregate colocation score.&lt;/p&gt;&#xA;&lt;p&gt;Now to address the elephant in the model: the number of possible aisle layouts grows combinatorially with aisle capacity and item count, so enumerating all possible layouts will likely be prohibitive. That brings you to a couple of options.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For an exact solution (proven optimal), you could explore &lt;a href=&quot;https://en.wikipedia.org/wiki/Branch_and_price&quot; rel=&quot;nofollow noreferrer&quot;&gt;branch and price&lt;/a&gt; algorithms. These require specialized software (as well as a MIP solver) and there is no guarantee you get an answer in an acceptable amount of time and memory.&lt;/li&gt;&#xA;&lt;li&gt;If you can live with a heuristic approach, one possibility is something along the lines of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Cutting_stock_problem#Mathematical_formulation_and_solution_approaches&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gilmore-Gomory approach&lt;/a&gt; for the one dimensional cutting stock problem. The logic is relatively straightforward.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Build the model I described, but with the integrality restriction relaxed (&lt;span class=&quot;math-container&quot;&gt;$x_j \in [0,1]$&lt;/span&gt;) and with a handful of aisle layouts to start, chosen so that the model is feasible (every item is in one aisle, no aisle exceeds capacity, colocation is ignored).&lt;/li&gt;&#xA;&lt;li&gt;Solve the current LP relaxation and grab the dual solution.&lt;/li&gt;&#xA;&lt;li&gt;Use the dual in a subproblem (which I think might be a quadratic binary knapsack in your case, but don't quote me on that) to build a new aisle layout that would have a positive reduced cost in the LP relaxation of the master problem.&lt;/li&gt;&#xA;&lt;li&gt;Add that layout to the relaxed master and repeat.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You stop when the subproblem based on the latest dual values fails to find a new layout. At that point, you restore the integrality restrictions, solve the integer program and declare approximate victory.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-02-25T23:13:42.617" LastActivityDate="2022-02-25T23:13:42.617" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7945" PostTypeId="2" ParentId="7942" CreationDate="2022-02-26T15:27:34.090" Score="4" Body="&lt;p&gt;&lt;strong&gt;Question 1&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;You could simply use the priority function as the cost function on the arcs. This way, it is for example cheaper to ship a commodity to &lt;span class=&quot;math-container&quot;&gt;$D_1$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$W_2$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; unit of cost per unit of flow) than from &lt;span class=&quot;math-container&quot;&gt;$W_1$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; units of cost per unit of flow). If there are no capacities in the model, the orders of priority will be respected.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question 2&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;You should use variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^p$&lt;/span&gt; that represent the amount of commodity &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; shipped from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question 3&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;To ensure maximum fulfillment, you should use demand satisfaction constraints for each DC:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i|(i,DC)\in A}x_{i,DC}^p = \mbox{demand}_{DC}^p\quad \mbox{for each DC, for each commodity }p&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If this is not feasible because of insufficient supply, then you can try to fulfill demand as much as possible by penalizing what is missing. You can introduce slack variables &lt;span class=&quot;math-container&quot;&gt;$e_{DC}^p$&lt;/span&gt; and minimize their value in the objective function. The above constraint becomes:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i|(i,DC)\in A}x_{i,DC}^p + e_{DC}^p= \mbox{demand}_{DC}^p\quad \mbox{for each DC, for each commodity }p&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question 4a&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is covered in &lt;strong&gt;Question 3.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question 4b&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Unless you have a good reason to impose the order of fulfillment, I would let the solver choose what is best. But if you really want to impose an order, say for example &lt;span class=&quot;math-container&quot;&gt;$DC_1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$DC_2$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$DC_3$&lt;/span&gt;, then you can use weights &lt;span class=&quot;math-container&quot;&gt;$\omega_1&amp;gt;\omega_2&amp;gt;\omega_3$&lt;/span&gt; in the objective function&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \; \sum_p\sum_{(i,j)\in A}c_{ij}x_{ij}^p + \sum_p\sum_{i\in \{1,2,3\}}\omega_i e_{DC_i}^p&#xA;$$&lt;/span&gt;&#xA;This way, the solver will &lt;em&gt;try&lt;/em&gt; to fulfill &lt;span class=&quot;math-container&quot;&gt;$DC_1$&lt;/span&gt; in priority (but with no guarantee), in order to avoid the largest penalty &lt;span class=&quot;math-container&quot;&gt;$\sum_p \omega_1 e_{DC_1}^p$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You could also add the following constraint to impose that &amp;quot;what is missing&amp;quot; in &lt;span class=&quot;math-container&quot;&gt;$DC_1$&lt;/span&gt; should be smaller than &amp;quot;what is missing&amp;quot; in &lt;span class=&quot;math-container&quot;&gt;$DC_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$DC_3$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_p e_{DC_1}^p \le \sum_p e_{DC_2}^p \le \sum_p e_{DC_3}^p&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-02-26T18:19:43.460" LastActivityDate="2022-02-26T18:19:43.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7946" PostTypeId="2" ParentId="7943" CreationDate="2022-02-26T17:35:31.423" Score="4" Body="&lt;p&gt;Your weighting based approach looks probably OK,&#xA;but given that there are different categories such as Europe vs Asia, and there may be additional factors such as office size, you might want to check if Simpson's Paradox might occur:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Simpson%27s_paradox&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Simpson%27s_paradox&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-02-26T17:35:31.423" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7947" PostTypeId="2" ParentId="7942" CreationDate="2022-02-27T00:48:30.003" Score="2" Body="&lt;p&gt;In addition to what @Kuifje suggested, with the right solver you could consider using a lexicographic objective. (CPLEX now supports this.) Define &lt;span class=&quot;math-container&quot;&gt;$T_{\pi, j}$&lt;/span&gt; to be the set of priority &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; suppliers to DC &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. In your example, these are singletons (e.g., &lt;span class=&quot;math-container&quot;&gt;$T_{1, 1} = \lbrace 2\rbrace $&lt;/span&gt;), but more generally it might be that multiple suppliers would have the same priority for a DC.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{p,i,j} \ge 0$&lt;/span&gt; be the amount of product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; sent from source &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to DC &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (variable), and let &lt;span class=&quot;math-container&quot;&gt;$S_{p,i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D_{p,j}$&lt;/span&gt; be supply of &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; at source &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and demand for &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; at DC &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; respectively (parameters). The constraints are simple supply and demand limits: &lt;span class=&quot;math-container&quot;&gt;$$\sum_j x_{p,i,j} \le S_{p,i}\quad \forall p, i$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$\sum_i x_{p,i,j} \le D_{p,j} \quad \forall p,j.$$&lt;/span&gt; The lexicographic objective is to maximize &lt;span class=&quot;math-container&quot;&gt;$(z_1, z_2, \dots, z_{\Pi})$&lt;/span&gt; in descending priority order, where &lt;span class=&quot;math-container&quot;&gt;$\Pi$&lt;/span&gt; is the number of priority levels and &lt;span class=&quot;math-container&quot;&gt;$$z_{\pi} = \sum_j \sum_{i\in T_{\pi, j}} x_{p,i,j}.$$&lt;/span&gt; In your example, &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; would be the total shipments of anything from W1 to D2 and D3 and from W2 to D1. The lexicographic approach will first try to maximize all shipments from priority 1 suppliers, then maximize shipments of remaining products from priority 2 suppliers, and so on.&lt;/p&gt;&#xA;&lt;p&gt;There are a few things to note here. The model will handle both supply greater than demand and supply less than demand (or a mix, some products with excess supply and some with excess demand). If you want to prioritize suppliers by product (e.g., D2 wants C1 from W1 but wants C2 from W3), it can be adapted to do that. If you want to prioritize some customers over others (e.g., it's more important for D1 to get product from their priority 1 source than it is for D2 to get product from their priority 1 source), you can attach weights to the &lt;span class=&quot;math-container&quot;&gt;$x_{p,i,j}$&lt;/span&gt; in the formula for &lt;span class=&quot;math-container&quot;&gt;$z_{\pi}$&lt;/span&gt;, giving higher weights to more important DCs.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-27T00:48:30.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7948" PostTypeId="1" CreationDate="2022-02-27T12:44:43.940" Score="2" ViewCount="538" Body="&lt;p&gt;I am trying to solve a mixed integer quadratic programming (MIQP) problem.&lt;/p&gt;&#xA;&lt;p&gt;The objective function contains the product of two continuous decision variables, some of constraints are non-linear too. I would like to know that can docplex module in python solve this kind of the problem?&lt;/p&gt;&#xA;" OwnerUserId="9245" LastEditorUserId="123" LastEditDate="2022-02-27T15:44:16.327" LastActivityDate="2022-05-10T16:47:28.307" Title="Can docplex solve a mixed integer quadratic programming (MIQP) problem?" Tags="|mixed-integer-programming|python|cplex|quadratic-programming|docplex|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7949" PostTypeId="1" AcceptedAnswerId="7955" CreationDate="2022-02-28T09:58:32.673" Score="1" ViewCount="163" Body="&lt;p&gt;I transform my minimization problem into one with only an objective function (no constraints). I only have one variable, which is binary.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can I derivate the objective and make it equal to 0 to find the objective values?&lt;/li&gt;&#xA;&lt;li&gt;If so, How? If you can send me an example, link, or a book to check how to derivate stuff like this, it would be amazing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;My objective function is as follows,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_x \sum_{j\in J}\sum_{i \in I} C_{ij} \sum_{i'=\tau}^i X_{i'j}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Added:&lt;br /&gt;&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$\tau=min(0,i-5)$&lt;/span&gt; for example. And &lt;span class=&quot;math-container&quot;&gt;$X_{i,j} \in \{0,1\}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$i,j \in IxJ$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="7200" LastEditDate="2022-03-01T15:46:22.550" LastActivityDate="2022-03-01T15:46:22.550" Title="Taking derivatives of objective function with a binary variable to find minimum" Tags="|mixed-integer-programming|integer-programming|binary-variable|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7950" PostTypeId="1" AcceptedAnswerId="7951" CreationDate="2022-02-28T13:27:01.683" Score="1" ViewCount="110" Body="&lt;p&gt;Can branch and bound be defined as a method to search a non-convex solution space which uses linear programming models(and solving them) to guide the search?&lt;/p&gt;&#xA;" OwnerUserId="9151" LastActivityDate="2022-03-01T17:55:51.730" Title="Can branch and bound be defined as a method to search a non-convex solution space which uses linear programming models to guide the search?" Tags="|branch-and-bound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7951" PostTypeId="2" ParentId="7950" CreationDate="2022-02-28T15:09:47.347" Score="3" Body="&lt;p&gt;Not quite branch and bound is a more general algorithm that also applies to non-linear models. The important thing is that you can calculate a &amp;quot;relaxation&amp;quot; which is guaranteed to be a bound on the objective. If one restricts oneself to MILP, then yes, your suggests describes branch and bound for MILP correctly. For non-linear models there exist different solutions to get lower bounds such as generic Interval Arithmetic or more other methods to find global minima of relaxations.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2022-03-01T17:55:51.730" LastActivityDate="2022-03-01T17:55:51.730" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7952" PostTypeId="2" ParentId="7875" CreationDate="2022-02-28T16:11:57.293" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;Yes, your proof is correct.&lt;/li&gt;&#xA;&lt;li&gt;I don't think there is an easy answer to this.&lt;/li&gt;&#xA;&lt;li&gt;The result does not extend to the nonlinear version. Let &lt;span class=&quot;math-container&quot;&gt;$\beta=2$&lt;/span&gt;. Set &lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathbf{X}^{\top}=\left[\begin{array}{cc}&#xA;1 &amp;amp; 2\\&#xA;2 &amp;amp; 1&#xA;\end{array}\right]&#xA;$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$\mathbf{k}=\left[\begin{array}{c}&#xA;2\frac{1}{9}\\&#xA;1\frac{2}{9}&#xA;\end{array}\right].$$&lt;/span&gt;The vector &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\bar{q}} = (\frac{1}{3}, 1)$&lt;/span&gt; is the unique solution to &lt;span class=&quot;math-container&quot;&gt;$$\mathbf{X}^\top \mathbf{q}^\beta = \mathbf{k}$$&lt;/span&gt;and has sum &lt;span class=&quot;math-container&quot;&gt;$1\frac{1}{3}.$&lt;/span&gt; Now consider &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat{q}}=(0.4594683, 0.8944272),$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat{q}}^\beta = (0.2111111, 0.8).$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$\mathbf{X}^\top \mathbf{\hat{q}}^\beta = \left[\begin{array}{c}&#xA;1.811\\&#xA;1.222&#xA;\end{array}\right],$$&lt;/span&gt; so &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat{q}}$&lt;/span&gt; is feasible (with some slack in the first constraint). The sum of the elements of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat{q}}$&lt;/span&gt; is approximately 1.35386 &amp;gt; 1.33333, proving that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\bar{q}}$&lt;/span&gt; is not optimal.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-28T16:11:57.293" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7953" PostTypeId="1" AcceptedAnswerId="7954" CreationDate="2022-02-28T16:45:48.073" Score="3" ViewCount="286" Body="&lt;p&gt;I have the following constraint in my model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x = 0  \lor \sum_{i=1}^n y_i = 3$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; are all binary variables.&lt;/p&gt;&#xA;&lt;p&gt;How this can be linearized by means of big-M notation?&lt;/p&gt;&#xA;&lt;p&gt;Should I include additional slack variables, or?&lt;/p&gt;&#xA;" OwnerUserId="9272" LastEditorUserId="500" LastEditDate="2022-02-28T16:51:17.113" LastActivityDate="2022-02-28T16:51:17.113" Title="Disjunctive equality constraints: modelling" Tags="|modeling|combinatorial-optimization|logical-constraints|big-m|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7954" PostTypeId="2" ParentId="7953" CreationDate="2022-02-28T16:51:01.593" Score="7" Body="&lt;p&gt;You do not need another variable.  Your disjunction is equivalent to &lt;span class=&quot;math-container&quot;&gt;$$x=1 \implies \sum_{i=1}^n y_i = 3,$$&lt;/span&gt; which you can enforce via big-M constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$M_1(1-x) \le \sum_{i=1}^n y_i - 3 \le M_2(1-x).$$&lt;/span&gt;&#xA;I leave to you the determination of good (small) choices of &lt;span class=&quot;math-container&quot;&gt;$M_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Some solvers also support such indicator constraints directly, without requiring you to explicitly impose big-M constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-02-28T16:51:01.593" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7955" PostTypeId="2" ParentId="7949" CreationDate="2022-02-28T17:16:12.887" Score="4" Body="&lt;p&gt;First order stationary point conditions will usually not help when your variables are discrete.&lt;/p&gt;&#xA;&lt;p&gt;In this particular case, if &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; is a constant (and assuming &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; are the same thing), the solution is trivial. Rewrite the objective as &lt;span class=&quot;math-container&quot;&gt;$$\min_X \sum_{i\in I : i \ge \tau}\sum_{j\in J} \left[ \sum_{k\in I : k\ge i} C_{kj} \right] X_{ij}.$$&lt;/span&gt; Let &lt;span class=&quot;math-container&quot;&gt;$d_{ij} = \sum_{k\in I : k\ge i} C_{kj}.$&lt;/span&gt; The optimal solution is found by inspection:&lt;span class=&quot;math-container&quot;&gt;$$X_{ij}=\begin{cases}&#xA;1 &amp;amp; d_{ij}&amp;lt;0\\&#xA;0\textrm{ or }1 &amp;amp; d_{ij}=0\\&#xA;0 &amp;amp; d_{ij}&amp;gt;0&#xA;\end{cases}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-28T17:16:12.887" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7956" PostTypeId="1" CreationDate="2022-02-28T17:36:04.020" Score="8" ViewCount="359" Body="&lt;p&gt;We have a large-scale optimization problem (~10K vars and ~10K constraints) in the form of &lt;code&gt;LP format file&lt;/code&gt; (generated using &lt;code&gt;Cplex&lt;/code&gt; library).&lt;/p&gt;&#xA;&lt;p&gt;We wanted to solve that problem file using &lt;code&gt;Cvxpy&lt;/code&gt; (with &lt;code&gt;Gurobi&lt;/code&gt; solver - Note: &lt;code&gt;Cvxpy&lt;/code&gt; is unavoidable), which doesn't accepts &lt;code&gt;LP format file&lt;/code&gt; directly (rather constraint matrices/list).&lt;/p&gt;&#xA;&lt;p&gt;So, is it possible to somehow read (/transform/parse) that &lt;code&gt;LP format file&lt;/code&gt; into regular &lt;code&gt;Numpy matrices&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6106" LastEditorUserId="6106" LastEditDate="2022-03-01T03:36:12.587" LastActivityDate="2022-03-01T17:27:36.260" Title="Translate LP format to Numpy matrices" Tags="|cplex|gurobi|cvxpy|lp-format|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="7957" PostTypeId="1" AcceptedAnswerId="7958" CreationDate="2022-02-28T19:06:21.833" Score="3" ViewCount="70" Body="&lt;p&gt;Let :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; be a undirected graph with nodes &lt;span class=&quot;math-container&quot;&gt;$a_1, \ldots, a_n$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1, \ldots, x_m$&lt;/span&gt; a set of real values&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Var the variance function&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; the &amp;quot;distance&amp;quot; between sets : &lt;span class=&quot;math-container&quot;&gt;$d(X_1, X_2) = \min_{x_1\in X_1, x_2\in X_2, x_1\neq x_2} |x_1-x_2|$&lt;/span&gt;. It's not exactly a distance.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I'm looking at finding :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$k\in\mathbb{N}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;a partition of the nodes &lt;span class=&quot;math-container&quot;&gt;$(a_i)_i$&lt;/span&gt; in sets &lt;span class=&quot;math-container&quot;&gt;$G_1, \ldots, G_k$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;a partition of the &lt;span class=&quot;math-container&quot;&gt;$(x_i)_i$&lt;/span&gt; in sets &lt;span class=&quot;math-container&quot;&gt;$F_1, \ldots, F_k$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;such that it maximizes :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_j Var(F_j)&#xA;$$&lt;/span&gt;&#xA;under the following constraints :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For any edge &lt;span class=&quot;math-container&quot;&gt;$(a_1, a_2)$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;, denoting &lt;span class=&quot;math-container&quot;&gt;$G_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$G_j$&lt;/span&gt; the groups containing &lt;span class=&quot;math-container&quot;&gt;$a_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_2$&lt;/span&gt;, we require that &lt;span class=&quot;math-container&quot;&gt;$d(F_i, F_j) &amp;gt; \epsilon$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;For all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$|F_i| \geq |G_i|$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;How to optimize two partitions at the same time under non-linear constraints?&lt;/p&gt;&#xA;" OwnerUserId="9273" LastEditorUserId="9273" LastEditDate="2022-02-28T21:13:09.693" LastActivityDate="2022-02-28T23:52:13.607" Title="How to optimize two partitions at the same time under non linear constraints?" Tags="|optimization|integer-programming|combinatorial-optimization|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7958" PostTypeId="2" ParentId="7957" CreationDate="2022-02-28T23:52:13.607" Score="3" Body="&lt;p&gt;The simplest/most tractable dispersion measure I can think of is set&#xA;diameter (maximum absolute difference between two elements of the&#xA;set), and even then the model (a mixed integer linear program) is&#xA;going to be rather large.&lt;/p&gt;&#xA;&lt;p&gt;In what follows, indices &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; will select either numbers&#xA;(e.g., &lt;span class=&quot;math-container&quot;&gt;$x_{h}$&lt;/span&gt;) or vertices (e.g., &lt;span class=&quot;math-container&quot;&gt;$a_{h}$&lt;/span&gt;) while indices &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and&#xA;&lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; will select sets of numbers (e.g., &lt;span class=&quot;math-container&quot;&gt;$F_{j}$&lt;/span&gt;) or sets of vertices&#xA;(e.g., &lt;span class=&quot;math-container&quot;&gt;$G_{j}$&lt;/span&gt;). So the range of &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; will be either 1 to&#xA;&lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; or 1 to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, depending on context. The range of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt;&#xA;will be 1 to &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is an &lt;em&gt;a priori&lt;/em&gt; bound on the number&#xA;of sets to use in the partition. The actual number &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; of sets used&#xA;will be determined from the final solution by dropping empty sets.&#xA;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; will be a sufficiently large positive number. (It need not be&#xA;the same in every constraint, but I will omit subscripts to spare&#xA;myself some typing.) &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; represents the set of edges in &lt;span class=&quot;math-container&quot;&gt;$G.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The model will contain the following variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;binary &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; will be 1 if number &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; belongs to set &lt;span class=&quot;math-container&quot;&gt;$F_{j}$&lt;/span&gt;,&#xA;0 if not;&lt;/li&gt;&#xA;&lt;li&gt;binary &lt;span class=&quot;math-container&quot;&gt;$u_{ij}$&lt;/span&gt; will be 1 if vertex &lt;span class=&quot;math-container&quot;&gt;$a_{i}$&lt;/span&gt; belongs to set &lt;span class=&quot;math-container&quot;&gt;$G_{j}$&lt;/span&gt;,&#xA;0 if not;&lt;/li&gt;&#xA;&lt;li&gt;binary &lt;span class=&quot;math-container&quot;&gt;$v_{hij}$&lt;/span&gt; will be 1 if numbers &lt;span class=&quot;math-container&quot;&gt;$x_{h}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$h&amp;lt;i$&lt;/span&gt;)&#xA;both belong to &lt;span class=&quot;math-container&quot;&gt;$F_{j}$&lt;/span&gt; and determine the diameter of &lt;span class=&quot;math-container&quot;&gt;$F_{j}$&lt;/span&gt; (i.e.,&#xA;are the furthest apart of any pair of numbers in &lt;span class=&quot;math-container&quot;&gt;$F_{j};$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;real &lt;span class=&quot;math-container&quot;&gt;$z_{j\ell}\ge0$&lt;/span&gt; will be the distance &lt;span class=&quot;math-container&quot;&gt;$d(F_{j},F_{\ell})$&lt;/span&gt; between&#xA;sets &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt;; and&lt;/li&gt;&#xA;&lt;li&gt;real &lt;span class=&quot;math-container&quot;&gt;$w_{j}\ge0$&lt;/span&gt; will be the diameter of set &lt;span class=&quot;math-container&quot;&gt;$F_{j}.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The objective function will be to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_{j}w_{j}.$&lt;/span&gt; The constraints&#xA;are as follows.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Every number belongs to exactly one of the &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; sets.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j}y_{ij}=1\quad\forall i.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Every node belongs to exactly one of the &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; sets.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j}u_{ij}=1\quad\forall i.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The cardinality of each &lt;span class=&quot;math-container&quot;&gt;$F_{j}$&lt;/span&gt; is at least as large as the cardinality&#xA;of the corresponding &lt;span class=&quot;math-container&quot;&gt;$G_{j}$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i}y_{ij}\ge\sum_{i}u_{ij}\quad\forall j.$$&lt;/span&gt;&#xA;Note that this prevents using a set &lt;span class=&quot;math-container&quot;&gt;$G_{j}$&lt;/span&gt; while leaving &lt;span class=&quot;math-container&quot;&gt;$F_{j}$&lt;/span&gt;&#xA;empty.&lt;/li&gt;&#xA;&lt;li&gt;You cannot use &lt;span class=&quot;math-container&quot;&gt;$F_{j}$&lt;/span&gt; while leaving &lt;span class=&quot;math-container&quot;&gt;$G_{j}$&lt;/span&gt; empty.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{ij}\le\sum_{h}u_{hj}\quad\forall i,j.$$&lt;/span&gt;&#xA;Combined with the previous constraint, this ensures that the number&#xA;of sets &lt;span class=&quot;math-container&quot;&gt;$F_{\cdot}$&lt;/span&gt; and the number of sets &lt;span class=&quot;math-container&quot;&gt;$G_{\cdot}$&lt;/span&gt; that are&#xA;used will be the same (&lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;li&gt;The distance between two sets is at most the minimum distance between&#xA;(distinct) members of each set.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_{j\ell}\le\vert x_{h}-x_{i}\vert+M\left(2-y_{hj}-y_{i\ell}\right)\quad\forall j\le\ell,\forall h\neq i.$$&lt;/span&gt;&#xA;Note that this constraint is repeated for both &lt;span class=&quot;math-container&quot;&gt;$h&amp;lt;i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h&amp;gt;i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For any edge in the graph, the distance between the number sets corresponding to the vertex sets containing the endpoints of the edge must be at least &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_{j\ell}\ge\epsilon\left(u_{hj}+u_{i\ell}-1\right)\quad\forall j\le\ell,\forall h\neq i\ni(a_{h},a_{i})\in E.$$&lt;/span&gt;&#xA;Note that this constraint is repeated for both &lt;span class=&quot;math-container&quot;&gt;$(a_{h},a_{i})$&lt;/span&gt; and&#xA;&lt;span class=&quot;math-container&quot;&gt;$(a_{i},a_{h}).$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;For &lt;span class=&quot;math-container&quot;&gt;$v_{hij}$&lt;/span&gt; to be 1, it is necessary that both &lt;span class=&quot;math-container&quot;&gt;$x_{h}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt;&#xA;belong to &lt;span class=&quot;math-container&quot;&gt;$F_{j}$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$v_{hij}\le y_{hj}\quad\forall h&amp;lt;i,\forall j.$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$v_{hij}\le y_{ij}\quad\forall h&amp;lt;i,\forall j.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Exactly one pair of numbers dictates the diameter of &lt;span class=&quot;math-container&quot;&gt;$F_{j}$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{h,i:h&amp;lt;i}v_{hij}=1\quad\forall j.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The diameter of &lt;span class=&quot;math-container&quot;&gt;$F_{j}$&lt;/span&gt; is determined by the &lt;span class=&quot;math-container&quot;&gt;$v_{\cdot\cdot j}$&lt;/span&gt;&#xA;variables.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w_{j}=\sum_{h,i:h&amp;lt;i}\vert x_{h}-x_{i}\vert v_{hij}\quad\forall j.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-02-28T23:52:13.607" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7959" PostTypeId="1" AcceptedAnswerId="8036" CreationDate="2022-03-01T06:19:28.293" Score="3" ViewCount="584" Body="&lt;p&gt;I should mention up front that I'm new to this forum and operations research in general. A problem has come up recently at work that I'm having a tough time solving.&lt;/p&gt;&#xA;&lt;p&gt;Our machine shop acquires many long steel bars (typically 20 foot long, but could vary) that need to be cut to various sizes for further processing on a CNC lathe. I've been asked to minimize waste/trim from the process.&lt;/p&gt;&#xA;&lt;p&gt;A couple special constraints are making it tough for me to formulate the problem. First, we can only feed ≤2 foot segments into the CNC at a time, so we cut the stock before cutting the final product. Additionally, each segment we cut must be fixed to the CNC (e.g. normally 2.5 inches of the segment are fixed and can't be cut), introducing a certain amount of inherent waste for each segment cut from the original bar. It is probably a naïve viewpoint, but this almost seems like two nested Cutting Stock Problems.&lt;/p&gt;&#xA;&lt;p&gt;I will summarize briefly. We effectively have unlimited stock to cut from. In the usual case, we need to cut several hundred copies of two or more lengths from the stock. However, we can't feed the whole stock into the machine, so we must cut it into lengths of ≤2 feet. From each ≤2 foot segment, we can then cut the required lengths (i.e. the final product).&lt;/p&gt;&#xA;&lt;p&gt;How would I go about formulating and solving this problem? As a mathematician, I always strive to find the most general solution. If it simplifies the solution, though, feel free to consider a more specific situation. Our normal use case (&amp;gt;50% of cases), we are using 20 foot stock and cutting 2 specific lengths.&lt;/p&gt;&#xA;" OwnerUserId="9274" LastEditorUserId="491" LastEditDate="2022-03-10T13:46:25.643" LastActivityDate="2022-03-10T13:46:25.643" Title="How to formulate and solve a variant of the Cutting Stock Problem" Tags="|optimization|mixed-integer-programming|integer-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7961" PostTypeId="1" CreationDate="2022-03-01T07:09:41.377" Score="2" ViewCount="497" Body="&lt;p&gt;Recently, I found out why (most) Integer Programming and Mixed Integer Programming optimization problems are usually considered as Non-Convex. This is because even though the objective function in such problems (e.g. &lt;a href=&quot;https://en.wikipedia.org/wiki/Travelling_salesman_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Traveling Salesman Problem&lt;/a&gt; is a Convex Function - since the set of constraints that this objective function has to be optimized over is Non-Convex (e.g. the set of Integers by definition is a Non-Convex set), the entire problem becomes a Non-Convex problem.&lt;/p&gt;&#xA;&lt;p&gt;This being said, I have the following question:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1)&lt;/strong&gt; In the case of the Traveling Salesman Problem, if we look at the &amp;quot;objective function&amp;quot; in this problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/U4k5S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/U4k5S.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is this function &lt;span class=&quot;math-container&quot;&gt;$\sum_i \sum_j c_{ij}x_{ij}$&lt;/span&gt; differentiable with respect to its constraints? Can we take its derivative with respects to its constraints?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;My inclination is &amp;quot;no&amp;quot; - this function is non-differentiable, seeing how I have never seen the Traveling Salesman Problem being solved using an optimization algorithm that requires evaluating a derivative (e.g. gradient descent), and instead always solved using optimization algorithms that do not require evaluating the derivative (e.g. Branch and Bound, Evolutionary and Metaheuristic Algorithms).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;2)&lt;/strong&gt; Consider the &amp;quot;Decision Tree&amp;quot; statistical/machine learning model (e.g. CART &lt;a href=&quot;https://en.wikipedia.org/wiki/Decision_tree_learning&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Decision_tree_learning&lt;/a&gt;) that is often used for supervised classification and regression tasks.&lt;/p&gt;&#xA;&lt;p&gt;Given a dataset, a Decision Tree (e.g. CART) is formed by &amp;quot;splitting&amp;quot; variables into smaller subsets (i.e. &amp;quot;nodes&amp;quot;) such that &amp;quot;purity&amp;quot; increases in each subsequent subset; &amp;quot;purity&amp;quot; is often measured through some sort of &amp;quot;Information Gain&amp;quot; that is based on measures such as &amp;quot;Gini Index&amp;quot; or &amp;quot;Entropy&amp;quot;. Thus, Decision Trees can be interpreted as an optimization problem where &amp;quot;Information Gain&amp;quot; has to be optimized. I have heard that since Decision Trees often have different variable types (e.g. continuous and categorial), searching for the optimal variable splits that optimize &amp;quot;Information Gain&amp;quot; is a Mixed Integer Optimization Problem having an enormous Combinatorial Search Space. For the interest of creating a decent Decision Tree in a reasonable amount of time, &amp;quot;Information Gain&amp;quot; is optimized using a &amp;quot;Greedy Search Algorithm,&amp;quot; and as a result, the final Decision Tree (i.e. the answer to this Mixed Integer Optimization Problem) is almost certainly unlikely to be the optimal Decision Tree (as there is very high probability that a better Decision Tree likely exists in this large Discrete Combinatorial Search Space, but finding this Decision Tree would take too much time):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xVkLk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xVkLk.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The above equation &lt;strong&gt;is the general function for &amp;quot;Information Gain&amp;quot; - is the function differentiable with respect to its constraints (I am guessing that the &amp;quot;constraints&amp;quot; in this case refer to Decision Trees being unable to make &amp;quot;illogical splits&amp;quot; that contradict &amp;quot;previous splits&amp;quot; - or instances in which the user specifies a minimum number of observations to be contained within each split)?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Again, my inclination is &amp;quot;no&amp;quot; - this function is not differentiable, because I have never seen any references that show this optimization problem being solved using an optimization algorithm that requires evaluating the derivative (e.g. Gradient Descent), and significant research is being done on improving optimization algorithms for this problem, and these optimization algorithms do not involve derivatives (e.g. Branch and Bound &lt;a href=&quot;https://arxiv.org/pdf/1904.12847.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/1904.12847.pdf&lt;/a&gt; , Evolutionary Algorithms &lt;a href=&quot;https://cran.r-project.org/web/packages/evtree/vignettes/evtree.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cran.r-project.org/web/packages/evtree/vignettes/evtree.pdf&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Thus, my rationale as to why these above functions are non differentiable are unfortunately non-mathematical reasons, but rather anecdotal reasons.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;But in general, is relatively straightforward to establish that &amp;quot;all functions defined over Non-Convex sets are by definition non-differentiable&amp;quot;?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Could we technically still use &amp;quot;Gradient Descent&amp;quot; on problems like Traveling Salesman and Decision Trees (e.g. &amp;quot;Relax&amp;quot; the problem, use Gradient Descent, check to see if the solution falls within the feasible region, Explore for solution in neighborhood, Repeat, etc.), with the only problem being that it would be an extremely inefficient compared to Gradient-Free Optimization Methods (e.g. Metaheuristics/Evolutionary Algorithms, Branch and Bound)? Or is it by definition, we are mathematically unable to use Gradient Descent on problems like Traveling Salesman and Decision Trees?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I have heard that Gradient Descent on Traveling Salesman is like &amp;quot;Nearest Neighbor Search&amp;quot;, yet I do not fully understand why this is. I am guessing that maybe you can use Gradient Descent on Traveling Salesman - but it would be extremely ineffective as it would provide no &amp;quot;useful&amp;quot; information on which path to explore next?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-03-13T23:08:57.703" LastActivityDate="2022-03-13T23:08:57.703" Title="Traveling Salesman: Any &quot;Room&quot; for Derivatives?" Tags="|optimization|combinatorial-optimization|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7962" PostTypeId="2" ParentId="7956" CreationDate="2022-03-01T11:53:53.820" Score="8" Body="&lt;p&gt;As has been discussed in the comments already, your suggested workflow is more complicated than it needs to be without providing any advantages. Gurobi is perfectly capable of handling LP files and if you want to solve the problem with Gurobi anyway there is no reasonable benefit of routing everything through cvxpy.&lt;/p&gt;&#xA;&lt;p&gt;If you absolutely have to get the constraint matrix, then I still suggest using Gurobi:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;&#xA;m = gp.read(&amp;quot;model.lp&amp;quot;)&#xA;A = m.getA()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As was already mentioned, this matrix is stored as a sparse matrix (see &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_model_geta.html&quot; rel=&quot;noreferrer&quot;&gt;Gurobi documentation on Model.getA()&lt;/a&gt; for more details) which is vastly superior to numpy's dense storage for practically any model.&lt;/p&gt;&#xA;" OwnerUserId="141" LastEditorUserId="141" LastEditDate="2022-03-01T17:27:36.260" LastActivityDate="2022-03-01T17:27:36.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7963" PostTypeId="1" CreationDate="2022-03-01T13:40:06.543" Score="2" ViewCount="44" Body="&lt;p&gt;In the linear case (see &lt;a href=&quot;https://or.stackexchange.com/questions/7875/will-all-constraints-in-this-lp-be-binding/7952#7952&quot;&gt;here&lt;/a&gt;) and under some conditions I've been able to establish that all constraints  (except the non negativity constraints) will be binding. I'm seeking to extend this result to non linear constraints.&lt;/p&gt;&#xA;&lt;p&gt;Say &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$n\times 2$&lt;/span&gt; matrix with no negative entries and such that every row and every column have at least a non zero element.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^i$&lt;/span&gt; be the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th row of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt; and assume further that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^i\not\leq\mathbf{x}^j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^j\not\leq\mathbf{x}^i\;\forall i,j$&lt;/span&gt;. Also, let &lt;span class=&quot;math-container&quot;&gt;$\beta&amp;gt;1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$j={1,2}$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^j$&lt;/span&gt; be the solution to the problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;  \text{minimize} &amp;amp;\quad \sum_{i=1}^nx_{ij}q_i^\beta\\&#xA;  \text{subject to} &amp;amp; \quad \sum_{i=1}^nq_i=1.&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{z}^j=\mathbf{X}^\top\mathbf{q}^j$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\langle\mathbf{Z}\rangle$&lt;/span&gt; the cone spanned by &lt;span class=&quot;math-container&quot;&gt;$\mathbf{z}^j, j={1,2}$&lt;/span&gt;. I believe that if &lt;span class=&quot;math-container&quot;&gt;$\mathbf{k}\in\langle\mathbf{Z}\rangle$&lt;/span&gt;, the solution to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;  \text{maximize} &amp;amp;\quad \mathbf{q}^\top\cdot \mathbf{1}\\&#xA;  \text{subject to} &amp;amp; \quad \mathbf{X}^{\top}\mathbf{q}^{\beta}\leq\mathbf{k}\\ &amp;amp;\quad\mathbf{q}\geq \mathbf{0},&#xA;\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;denoted &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\bar q}$&lt;/span&gt;, is such that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}^{\top}\mathbf{\bar q}^{\beta}=\mathbf{k}.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2391" LastEditorUserId="491" LastEditDate="2022-03-01T19:20:15.523" LastActivityDate="2022-03-01T19:20:15.523" Title="Will all constraints in this optimization program be binding?" Tags="|optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7964" PostTypeId="1" CreationDate="2022-03-01T15:25:40.640" Score="2" ViewCount="355" Body="&lt;p&gt;Totally new to optimization. Is there an easy-to-use solver, package, (free) software for solving &lt;strong&gt;nonlinear&lt;/strong&gt; semidefinite optimization problems?&lt;/p&gt;&#xA;" OwnerUserId="9278" LastEditorUserId="9278" LastEditDate="2022-03-06T19:54:57.963" LastActivityDate="2022-03-06T19:54:57.963" Title="Solver for nonlinear semidefinite optimization" Tags="|optimization|solver|nonlinear-programming|semidefinite-programming|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7965" PostTypeId="2" ParentId="7959" CreationDate="2022-03-01T17:49:55.960" Score="2" Body="&lt;p&gt;This sounds like a fairly standard one-dimensional cutting stock problem, which can be modeled with an integer linear program.&lt;/p&gt;&#xA;&lt;p&gt;One approach is as follows. Let &lt;span class=&quot;math-container&quot;&gt;$D_j$&lt;/span&gt; be the demand for pieces of length &lt;span class=&quot;math-container&quot;&gt;$L_j$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; be the supply of bars of length &lt;span class=&quot;math-container&quot;&gt;$B_i$&lt;/span&gt;. I'm going to assume that &lt;span class=&quot;math-container&quot;&gt;$L_j$&lt;/span&gt; includes not only the length of the final piece but also any required waste (the &amp;quot;fixed&amp;quot; portion in the problem description), and I'm also going to assume that there is no scrap value to any waste. Let &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; be the cost of a length &lt;span class=&quot;math-container&quot;&gt;$B_i$&lt;/span&gt; bar.&lt;/p&gt;&#xA;&lt;p&gt;Start by enumerating possible cutting patterns for each type of bar. Pattern &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is described by the type &lt;span class=&quot;math-container&quot;&gt;$i_p$&lt;/span&gt; of bar used and the number &lt;span class=&quot;math-container&quot;&gt;$a_{pj}$&lt;/span&gt; of type &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; pieces the pattern yields. (A pattern may produce pieces of one size or pieces of a mix of sizes.) Let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be the index set for the patterns.&lt;/p&gt;&#xA;&lt;p&gt;The model contains a nonnegative integer variable &lt;span class=&quot;math-container&quot;&gt;$x_p$&lt;/span&gt; for each pattern, capturing how many rods are cut with that pattern. The objective is to minimize the cost of the bars used:&lt;span class=&quot;math-container&quot;&gt;$$\min_x \sum_{p\in P} c_{i_p}x_p.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraints are straightforward.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You cannot cut more bars than you have. &lt;span class=&quot;math-container&quot;&gt;$$\sum_{p \in P:i_p = i} x_p \le S_i \quad \forall i.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;You need to produce enough pieces to meet demand. (I am assuming here that all pieces cut are usable, i.e., no &amp;quot;spoilage&amp;quot;.) &lt;span class=&quot;math-container&quot;&gt;$$\sum_{p \in P} a_{pj} x_p \ge D_j \quad \forall j.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The one possible issue here is that if you have a lot of different piece sizes and bar sizes the number of patterns (&lt;span class=&quot;math-container&quot;&gt;$\vert P \vert$&lt;/span&gt;) can get out of hand. In that case, you can either try the branch-and-price (column generation) approach, which requires more sophisticated software, or the Gilmore-Gomory heuristic, which works well but does not guarantee an optimal solution. Both start with a handful of patterns and generate new patterns on the fly.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-01T17:49:55.960" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7966" PostTypeId="1" CreationDate="2022-03-01T20:19:24.320" Score="11" ViewCount="1921" Body="&lt;p&gt;In &lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2022/01/an-all-paths-network-problem.html&quot; rel=&quot;noreferrer&quot;&gt;this post&lt;/a&gt;, Erwin Kalvelagen describes a method to compute all paths between two nodes in a given network, such that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;no arc is used more than once&lt;/li&gt;&#xA;&lt;li&gt;a given path does not contain more than &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; arcs&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note that nodes can be revisited, and this is part of the difficulty. His approach is well described and involves using the line graph, MTZ constraints, and a solution pool approach.&lt;/p&gt;&#xA;&lt;p&gt;Are there other ways to tackle this problem (brute force excluded) ?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;This problem was initially posted on stackoverflow, but the question seems to have been removed. I believe it is of interest to the OR community, as the problem is more complicated than it looks.&lt;/p&gt;&#xA;&lt;p&gt;@ErwinKalvelagen, feel free to post bits of your answer here, will be happy to upvote it given that it originated this post.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-03-01T22:15:51.063" LastActivityDate="2022-03-07T07:40:33.137" Title="How to compute all paths between two given nodes in a network?" Tags="|modeling|integer-programming|graphs|" AnswerCount="5" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="7967" PostTypeId="2" ParentId="7966" CreationDate="2022-03-01T20:19:56.297" Score="8" Body="&lt;p&gt;I would solve this using the following approach:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Compute the shortest path with a MIP, with an additional constraint to limit the number of arcs in the path.&lt;/li&gt;&#xA;&lt;li&gt;If a path is found, store it, add a &lt;em&gt;no good cut&lt;/em&gt; to exclude this path in the next iterations, and go to step 1. If no path is found, you are done.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The tricky part is to use the right &lt;em&gt;no good cut&lt;/em&gt; for a given path &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;. It needs to exclude the path that has been found, except if it includes other edges of the network &lt;strong&gt;without forming a subtour&lt;/strong&gt; (Erwin Kalvelagen used MTZ constraints to forbid subtours).&lt;/p&gt;&#xA;&lt;p&gt;For example, if &lt;span class=&quot;math-container&quot;&gt;$P=1-8-10$&lt;/span&gt;, path &lt;span class=&quot;math-container&quot;&gt;$Q=1-8-3-8-10$&lt;/span&gt; is a candidate (if &lt;span class=&quot;math-container&quot;&gt;$M=4$&lt;/span&gt;). On the other hand, a solution with edges &lt;span class=&quot;math-container&quot;&gt;$(1,8),(8,10),(4,4)$&lt;/span&gt; (that is, &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; with an isolated self-loop) must be forbidden. In other words, the no good cuts must ensure some sort of contiguity if edges from &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; are used again.&lt;/p&gt;&#xA;&lt;p&gt;This can be done as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{(i,j)\in P}(1-x_{ij}) + \sum_{(i,j)\not \in P, i\in P \mbox{ or } j \in P}x_{ij} \ge 1&#xA;$$&lt;/span&gt;&#xA;This means that&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Either one of the edges of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; must take value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; (and so the path will be different from &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;) or&lt;/li&gt;&#xA;&lt;li&gt;Either one of the edges of the network not in &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;, but linked to &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; must be used (in which case &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; will have extra edges, without subtours).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;My &lt;a href=&quot;https://github.com/Kuifje02/or.stackexchange-simulations/blob/main/All-Paths%20Problem.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;simulations&lt;/a&gt; with this approach match Erwin's results. Downside: you have to solve a series of MIPs, possibly many. Upside: no graph transformation (line graph), and no MTZ constraints.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;EDIT&lt;/h3&gt;&#xA;&lt;p&gt;This strategy has the following flaw for graphs that have multiple subtours originating at a same node. For example consider paths &lt;span class=&quot;math-container&quot;&gt;$P=1-u-a-u-b-u-10$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q=1-u-b-u-a-u-10$&lt;/span&gt;: they have the exact same edge set, but the order of the nodes differ. Once path &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is found, path &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; will become infeasible with respect to the no good cut associated with &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;. In other words the no good cuts are too strong.&lt;/p&gt;&#xA;&lt;p&gt;There are at least two ways to fix this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Once a path is generated, check if this situation occurs and deduce all possible paths. This is doable but a bit tedious.&lt;/li&gt;&#xA;&lt;li&gt;Use the line graph. This is handy because with the line graph, no loops are possible. So the MIP can be solved on the line graph, with the following no good cuts for a given path &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\sum_{((u,v),(x,y))\in P}(1-x_{u,v,x,y}) &amp;amp;\ge 1 \tag{1} \\&#xA;\sum_{((u,v),(x,y))\not \in P}x_{u,v,x,y} &amp;amp;\ge 2 \tag{2}&#xA;\end{align*}&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Constraints &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; impose that at least one edge from &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; must be removed and constraints &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; impose that at least &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; new edges must be selected.&lt;/p&gt;&#xA;&lt;p&gt;With these new cuts, I get the following results, which match with the other approaches suggested in the other answers:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;M&lt;/th&gt;&#xA;&lt;th&gt;2&lt;/th&gt;&#xA;&lt;th&gt;3&lt;/th&gt;&#xA;&lt;th&gt;4&lt;/th&gt;&#xA;&lt;th&gt;5&lt;/th&gt;&#xA;&lt;th&gt;6&lt;/th&gt;&#xA;&lt;th&gt;7&lt;/th&gt;&#xA;&lt;th&gt;8&lt;/th&gt;&#xA;&lt;th&gt;9&lt;/th&gt;&#xA;&lt;th&gt;10&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;paths&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;td&gt;9&lt;/td&gt;&#xA;&lt;td&gt;21&lt;/td&gt;&#xA;&lt;td&gt;32&lt;/td&gt;&#xA;&lt;td&gt;53&lt;/td&gt;&#xA;&lt;td&gt;98&lt;/td&gt;&#xA;&lt;td&gt;165&lt;/td&gt;&#xA;&lt;td&gt;268&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-03-05T01:38:57.333" LastActivityDate="2022-03-05T01:38:57.333" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="7968" PostTypeId="2" ParentId="7961" CreationDate="2022-03-02T13:45:48.277" Score="5" Body="&lt;p&gt;Derivatives can be very important&#xA;for solving nonconvex problems, especially Mixed Integer NonLinear Programs (MINLP).&#xA;A standard approach in Operations Research for solving a nonconvex problem is to&#xA;form a convex hull of the feasible region, e.g., drop the integralility requirements.&#xA;Then&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Solve the convex relaxation, typically using derivatives. Generally, this is a&#xA;relatively easy problem and produces a global optimum to the relaxed problem.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Pray that the solution to the relaxed problem is also a solution (feasible)&#xA;to the original nonconvex problem.&lt;/p&gt;&#xA;&lt;p&gt;If yes, we are done,&lt;/p&gt;&#xA;&lt;p&gt;If no, split the original problem into two, hopefully easier, problems and repeat.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;This is the essence of Branch-and-Bound,&#xA;the workhorse algorithm for solving non-convex problems.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-03-02T13:45:48.277" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7969" PostTypeId="2" ParentId="7961" CreationDate="2022-03-02T16:35:33.017" Score="8" Body="&lt;p&gt;I'll address question (1) only. The objective function of the TSP formulation is linear. It is therefore differentiable. But the feasible region consists of a set of discrete points, so the objective function is not differentiable over the feasible set.&lt;/p&gt;&#xA;&lt;p&gt;And even if the feasible region were continuous—for example, if you were solving the LP relaxation of the IP formulation—differentiability doesn't help us. That's because the objective function itself has no local minima (because it is linear). So if you take a derivative of the objective function and set it to 0, there will be no solutions. (Try it—it's easy to see why.) The optimal solutions of the LP occur at corner points of the feasible region, not at stationary points of the objective function. This is true not just for the LP relaxation of the TSP, but for any LP.&lt;/p&gt;&#xA;&lt;p&gt;In fact, the simplex method for solving LPs can be viewed as a sort of gradient descent method—see &lt;a href=&quot;https://math.stackexchange.com/q/3254423/663638&quot;&gt;https://math.stackexchange.com/q/3254423/663638&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2022-03-02T16:35:33.017" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7970" PostTypeId="1" AcceptedAnswerId="8030" CreationDate="2022-03-02T17:18:27.830" Score="8" ViewCount="283" Body="&lt;p&gt;Consider the following optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\label{eq:1}&#xA;\min_{x\in\mathcal X} \max_{i\in\mathcal I}\sum_{j\in\mathcal J} f_i(x_{(j)}),&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{I}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{J}$&lt;/span&gt; are discrete and finite sets, &lt;span class=&quot;math-container&quot;&gt;$\mathcal X\subset \mathbb{R}^N$&lt;/span&gt; is a compact set, &lt;span class=&quot;math-container&quot;&gt;$(f_i)_{i\in\mathcal J}$&lt;/span&gt; are convex and differentiable functions, and &lt;span class=&quot;math-container&quot;&gt;$x_{(j)}$&lt;/span&gt; is a subvector of the global variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Note that &lt;span class=&quot;math-container&quot;&gt;$x_{(j)}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{(j')}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$j,j'\in\mathcal J$&lt;/span&gt; may overlap.&lt;/p&gt;&#xA;&lt;p&gt;For example &lt;span class=&quot;math-container&quot;&gt;$x = (x_1,x_2,x_3)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{(1)} = (x_1,x_2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{(2)} = (x_2,x_3)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am investigating whether there is a way to solve this problem in a distributed manner. Note that the problem, without the term &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$\max_{i}$&lt;/span&gt;&amp;quot;, is known as the &lt;em&gt;general form consensus problem&lt;/em&gt; and is solved nicely by ADMM (see &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/papers/pdf/admm_distr_stats.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Boyd et al.&lt;/a&gt; Sec. 7.2).&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, the term &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$\max_{i}$&lt;/span&gt;&amp;quot; seemingly makes the problem non-separable, and &lt;em&gt;the active index&lt;/em&gt;, i.e., the index &lt;span class=&quot;math-container&quot;&gt;$i^\star(x)\in\mathcal I$&lt;/span&gt; which attains the maximum, cannot be computed in a decentralized way.&lt;/p&gt;&#xA;&lt;p&gt;Is there an algorithm to separate the variable update steps for the problem above and apply an ADMM-like (or similar) algorithm in a decentralized way over &lt;span class=&quot;math-container&quot;&gt;$j\in\mathcal J$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I have found &lt;a href=&quot;https://stanford.edu/%7Eboyd/papers/pdf/prox_algs.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; monograph (Sec. 7.5) in which there is a problem of the type&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{x\in\mathcal X} \varphi(f_1(x),\dots,f_J(x)),&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\varphi(\cdot)$&lt;/span&gt; is a convex non-decreasing function.&lt;/p&gt;&#xA;&lt;p&gt;Then they formulate the problem in epigraph form and propose a method to solve it. Any idea on whether this method will work in my case?&lt;/p&gt;&#xA;" OwnerUserId="5005" LastEditorUserId="5005" LastEditDate="2022-03-10T09:39:50.730" LastActivityDate="2022-03-10T09:39:50.730" Title="Distributed optimization problem" Tags="|optimization|convex-optimization|disciplined-convex-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7971" PostTypeId="1" CreationDate="2022-03-02T21:23:48.730" Score="3" ViewCount="29" Body="&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to establish an explicit characterization of both the optimal value functions and the optimal control policy for a controlled random walk?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assume our system is a perfectly-observed stochastic control system whose state-transition map (STM) is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{t+1} = x_t + u_t + w_t.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We know that &lt;span class=&quot;math-container&quot;&gt;$x_0 \sim \mathcal{N}(0, \lambda^2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_t \sim \mathcal{N}(0, \sigma^2)$&lt;/span&gt; are normally distributed variables that are independent from one another.&lt;/p&gt;&#xA;&lt;p&gt;The goal is to find the control policy &lt;span class=&quot;math-container&quot;&gt;$\pi = (\mu_0, ..., \mu_{T-1})$&lt;/span&gt; that takes the random walk closer to a target &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt;. The expected minimum cost for the optimal policy is expressed by:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$J(\pi^*) = \inf\limits_{\pi \in \Pi} \mathbb{E}\left[(x_T^\pi - \tau)^2 + \sum_{t=0}^{T-1} (u_t^\pi)^2\right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My work so far:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;First, let's establish some facts.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$J(\pi^*)$&lt;/span&gt; is the expected cost of the optimal policy &lt;span class=&quot;math-container&quot;&gt;$\pi^*_t \in \Pi_M$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The optimal policy &lt;span class=&quot;math-container&quot;&gt;$\pi^*_t$&lt;/span&gt; is such that: {&lt;span class=&quot;math-container&quot;&gt;$\pi^*_t \in \text{argmin}_{\pi \in \Pi} J(\pi)$&lt;/span&gt;}&lt;/li&gt;&#xA;&lt;li&gt;Ergo, &lt;span class=&quot;math-container&quot;&gt;$J(\pi^*) = J^*$&lt;/span&gt; is the expected minimum cost.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$J(\pi^*) = \mathbb{E}[J^{\pi^*}_0]$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The optimal value function &lt;span class=&quot;math-container&quot;&gt;$\{V^*_t\}_{t=0}^T$&lt;/span&gt; is a sequence of functions such that:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V^*_T(x) = g_{_T}(x)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V^*_t(x) = \inf\limits_{u \in \mathbb{U}_t(x)} \{g_t(x_t,u_t) + \mathbb{E}_{w_t}[V_{t+1}^*(f_t(x_t,u_t,w_t))]\}$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Breaking down the optimal expected cost structure, we have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$g_{_T}(x_{_T}^{\pi^*}) = (x_{_T}^{\pi^*} - \tau)^2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$g_t(x_t,u_t) = g_t(u_t) = (u_t^{\pi^*})^2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With that, the optimal value function can be characterized as for its last stage &lt;span class=&quot;math-container&quot;&gt;$t = T$&lt;/span&gt; and for intermediate time steps &lt;span class=&quot;math-container&quot;&gt;$t = 0, ..., T-1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$t = T$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$V^*_T(x) = g_{_T}(x) = (x_{_T}^{\pi^*} - \tau)^2$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$t = 0, ..., T-1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$V_t^*(x) = \inf\limits_{u \in \mathbb{U}_t(x)} \{g_t(x_t,u_t) + \mathbb{E}_{w_t}[V_{t+1}^*(f_t(x_t,u_t,w_t))]\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I worked out the DP equation for stage &lt;span class=&quot;math-container&quot;&gt;$t = T-1$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$T+1$&lt;/span&gt; will be my final stage.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$V_{T-1}^*(x) = \inf\limits_{u \in \mathbb{U}_t(x)} \{  (u_{T-1}^{\pi})^2 +  \mathbb{E}_{w_t}[V_{t+1}(x_{t+1})]\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$V_{T-1}^*(x) = \inf\limits_{u \in \mathbb{U}_t(x)} \{  (u_{T-1}^{\pi})^2 +  \mathbb{E}_{w_t}[(x_{_T}^{\pi} - \tau)^2]\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$V_{T-1}^*(x) = \inf\limits_{u \in \mathbb{U}_t(x)} \{  (u_{T-1}^{\pi})^2 +  (x_{_T}^{\pi} - \tau)^2\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$V_{T-1}^*(x) = \inf\limits_{u \in \mathbb{U}_t(x)} \{  (x_{T} - x_{T-1} - w_{T-1})^2 +  (x_{_T}^{\pi} - \tau)^2\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$V_{T-1}^*(x) = \inf\limits_{u \in \mathbb{U}_t(x)} \{ 2x_T^2 - 2x_T(x_{T-1} + w_{T-1} + \tau) + x_{T-1}^2 + 2x_{T-1}w_{T-1} + w_{T-1}^2 + \tau^2\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here's where I run into problems. My minimization problem is to be taken over the actions &lt;span class=&quot;math-container&quot;&gt;$u_t$&lt;/span&gt;, however, my final solution (the last equation above) does not depend on it. If I were to try to find the optimal decision by the first-order optimality condition, I'd fail from the get-go because there's no &lt;span class=&quot;math-container&quot;&gt;$u_t$&lt;/span&gt; in my equation. This isn't surprising, after all, I made the substitution. However, I only substitute &lt;span class=&quot;math-container&quot;&gt;$u_t$&lt;/span&gt; as I did because, from my understand of the expected (minimum) optimal cost, the stage-cost structure is &lt;span class=&quot;math-container&quot;&gt;$(u_t)^2$&lt;/span&gt;. And I need that substitution when I have the optimal value function &lt;span class=&quot;math-container&quot;&gt;$V_{T-1}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Through my STM, I can isolate &lt;span class=&quot;math-container&quot;&gt;$u_t$&lt;/span&gt; and plug that result into my cost structure. However, I don't think this is the right way to go. &lt;strong&gt;How should I proceed?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I also worked out the same equation for &lt;span class=&quot;math-container&quot;&gt;$t = T-2$&lt;/span&gt; and, although different, I also ended with an equation that does not depend on &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, ergo, not useful for a first-order optimality condition that depends on &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;. This is part of an assignment; therefore, feel free to give me hints or point me into the right direction rather than writing a full answer.&lt;/p&gt;&#xA;" OwnerUserId="1129" LastEditorUserId="491" LastEditDate="2022-03-03T13:46:14.410" LastActivityDate="2022-03-03T13:46:14.410" Title="How to establish the optimal value functions and optimal control policy for a controlled random walk problem?" Tags="|dynamic-programming|optimality-conditions|stochastic-process|optimal-control|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7972" PostTypeId="2" ParentId="7964" CreationDate="2022-03-03T04:13:41.093" Score="1" Body="&lt;p&gt;If you use Python, I have found calling the &lt;code&gt;scs&lt;/code&gt; solver through &lt;code&gt;cvxpy&lt;/code&gt; to be very effective for semidefinite programming. The &lt;code&gt;scs&lt;/code&gt; solver uses ADMM as opposed to the interior point methods that are typically used for SDPs, with the result that it scales to larger problems but has a harder time achieving extremely high numerical accuracy. I haven't found this to be a limitation in my use cases.&lt;/p&gt;&#xA;&lt;p&gt;Edit: Mark Stone suggests in the comments that this question is meant to address nonconvex problems as well, in which case these tools are inappropriate. I understood this question to mean that you had a (hopefully convex) problem over semidefinite matrices but with an objective that was nonlinear (i.e. the problem is not in the standard form required by SDP solvers). In this case these tools are worth a look, because &lt;code&gt;cvxpy&lt;/code&gt; converts the problem to standard form automatically. Some of these conversions can be tricky if you're not used to them, so it's helpful to have an automated tool.&lt;/p&gt;&#xA;" OwnerUserId="3066" LastEditorUserId="3066" LastEditDate="2022-03-03T13:18:26.573" LastActivityDate="2022-03-03T13:18:26.573" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7973" PostTypeId="1" AcceptedAnswerId="7974" CreationDate="2022-03-03T06:44:55.270" Score="2" ViewCount="229" Body="&lt;p&gt;I am modelling a capacitated facility location problem in &lt;code&gt;R&lt;/code&gt; with the &lt;code&gt;ompr&lt;/code&gt; package.&lt;/p&gt;&#xA;&lt;p&gt;When I am removing the Capacity constraint, the model is giving me results. But when the constraint is added, it is showing infeasibility. I am trying to understand the implications of this result.&lt;/p&gt;&#xA;&lt;p&gt;The cumulative capacity of the potential locations is more than the demand. So, there should be feasibility in the solution, right? I would expect more Facility locations than the Uncapacitated Solution and probably a higher solution cost. But why would there be infeasibility?&lt;/p&gt;&#xA;&lt;p&gt;The code if anyone needs a reference:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model &amp;lt;- MIPModel() %&amp;gt;%&#xA;  # 1 if pin i gets assigned to warehouse j&#xA;  add_variable(x[i, j], i = 1:n, j = 1:m, type = &amp;quot;binary&amp;quot;) %&amp;gt;%&#xA;  &#xA;  # 1 if warehouse j is built&#xA;  add_variable(y[j], j = 1:m, type = &amp;quot;binary&amp;quot;) %&amp;gt;%&#xA;  &#xA;  # Objective function&#xA;  set_objective(sum_expr(transportcost_matrix[i, j] * x[i, j], i = 1:n, j = 1:m) +&#xA;                  sum_expr(fixedcost * y[j], j = 1:m) +&#xA;                  sum_expr((demand[i] * x[i, j])* rent_per_sqft[j], i = 1:n, j = 1:m), &amp;quot;min&amp;quot;) %&amp;gt;%&#xA;  &#xA;  # Every pin needs to be assigned to a warehouse&#xA;  add_constraint(sum_expr(x[i, j], j = 1:m) == 1, i = 1:n) %&amp;gt;% &#xA;  &#xA;  # If a pin is assigned to a warehouse, then the warehouse must be built&#xA;  add_constraint(x[i,j] &amp;lt;= y[j], i = 1:n, j = 1:m) %&amp;gt;%&#xA;  &#xA;  #The demand of each warehouse shouldn't exceed their capacities&#xA;  add_constraint(sum_expr(demand[i] * x[i, j], i = 1:n) &amp;lt;= capacity[j] * y[j], j = 1:m)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5532" LastEditorUserId="500" LastEditDate="2022-03-03T15:52:34.547" LastActivityDate="2022-03-03T15:52:34.547" Title="The significance of infeasibility for a Capacitated Facility Location Problem" Tags="|optimization|combinatorial-optimization|facility-location|feasible-points|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7974" PostTypeId="2" ParentId="7973" CreationDate="2022-03-03T07:26:44.627" Score="5" Body="&lt;p&gt;I think what you have faced with infeasibility came from the problem data. I tried to run the problem with the formulation you mentioned by some of the random data and the problem is being solved without any issues. The data I have used is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;parameter transportcost_matrix(i,j); transportcost_matrix(i,j)= uniform(150,300);&#xA;parameter fixedcost(j); fixedcost(j)= uniform(100,200);&#xA;parameter demand(i); demand(i)= uniform(500,900);&#xA;parameter rent_per_sqft(j); rent_per_sqft(j)= uniform(500,700);&#xA;parameter capacity(j); capacity(j)= uniform(1500,3000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Please, noted that this data is produced based on a uniform distribution function, but you may use your favorite function.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-03-03T07:26:44.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7975" PostTypeId="1" CreationDate="2022-03-03T12:54:10.833" Score="6" ViewCount="116" Body="&lt;p&gt;I'm trying to model a grid placement problem to exercise in OR.&lt;/p&gt;&#xA;&lt;p&gt;The problem is defined as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a grid of some dimension (let's say 500x500)&lt;/li&gt;&#xA;&lt;li&gt;N users that need connection. Every user has:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a defined position on the grid&lt;/li&gt;&#xA;&lt;li&gt;a speed value&lt;/li&gt;&#xA;&lt;li&gt;a latency value&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;M wifi access points to place on the grid. Every access point has:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a range&lt;/li&gt;&#xA;&lt;li&gt;a speed value&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Objective is to maximize:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{n \in N} user\_score(n)$$&lt;/span&gt;&#xA;given&#xA;&lt;span class=&quot;math-container&quot;&gt;$$user\_score(n) = \max_{m \in M} score(n, m)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$score(n, m) = &#xA;\begin{cases}&#xA;speed(n) * speed(m) - latency(n) * distance(n,m) &amp;amp; distance(n,m) &amp;lt;= range(m)\\&#xA;0 &amp;amp; distance(n,m) &amp;gt; range(m)&#xA;\end{cases}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$distance(n,m) = abs(n_x - m_x) + abs(n_y - m_y) \space\space\text{(manhattan distance)}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Additional rules:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;two access points can't share the same location on the grid&lt;/li&gt;&#xA;&lt;li&gt;an access point and a user can share the same location&lt;/li&gt;&#xA;&lt;li&gt;if no access point is in range, user score is 0&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I tried modeling it as follows, using or-tools:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;model = cp.CpModel()&#xA;&#xA;all_x = []&#xA;all_y = []&#xA;all_k = []&#xA;&#xA;for a in access_points:&#xA;    x = model.NewIntVar(0, grid_w - 1, f'x_{a.id}')&#xA;    y = model.NewIntVar(0, grid_h - 1, f'y_{a.id}')&#xA;    k = model.NewIntVar(0, (grid_w - 1) * 1000 + grid_h, f'k_{a.id}')&#xA;&#xA;    model.Add(k == x * 1000 + y)&#xA;&#xA;    all_x.append(x)&#xA;    all_y.append(y)&#xA;    all_k.append(k)&#xA;&#xA;model.AddAllDifferent(all_k)&#xA;&#xA;scores = []&#xA;for b in users&#xA;&#xA;    u_score = model.NewIntVar(0, cp.INT32_MAX, f'u_score_{b.id}')&#xA;    all_u_scores = []&#xA;    &#xA;    for ia, a in enumerate(access_points):&#xA;&#xA;        abs_x = model.NewIntVar(0, grid_w, f'abs_x_{b.id}_{a.id}')&#xA;        abs_y = model.NewIntVar(0, grid_h, f'abs_y_{b.id}_{a.id}')&#xA;&#xA;        model.AddAbsEquality(abs_x, all_x[ia] - b.x)&#xA;        model.AddAbsEquality(abs_y, all_y[ia] - b.y)&#xA;&#xA;        in_range = model.NewBoolVar(f'in_range_{b.id}_{a.id}')&#xA;        model.Add(abs_x + abs_y &amp;lt;= a.range).OnlyEnforceIf(in_range)&#xA;        model.Add(abs_x + abs_y &amp;gt; a.range).OnlyEnforceIf(in_range.Not())&#xA;&#xA;        score = model.NewIntVar(0, cp.INT32_MAX, f'score_{b.id}_{a.id}')&#xA;        model.Add(score == 0).OnlyEnforceIf(in_range.Not())&#xA;        model.Add(score == a.speed * b.speed - b.latency * (abs_x + abs_y)).OnlyEnforceIf(in_range)&#xA;&#xA;        all_b_scores.append(score)&#xA;&#xA;    model.AddMaxEquality(b_score, all_b_scores)&#xA;&#xA;    scores.append(b_score)&#xA;&#xA;model.Maximize(sum(scores))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This works well with a small grid with a few users/access points, but scales bad on bigger problem instances.&lt;/p&gt;&#xA;&lt;p&gt;Is the model good? Any better way to model the problem?&lt;/p&gt;&#xA;" OwnerUserId="9292" LastEditorUserId="981" LastEditDate="2023-12-31T11:12:30.923" LastActivityDate="2023-12-31T11:12:30.923" Title="Help modeling grid placement problem" Tags="|mixed-integer-programming|modeling|or-tools|constraint-programming|cp-sat|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7976" PostTypeId="1" AcceptedAnswerId="7978" CreationDate="2022-03-03T13:40:39.483" Score="8" ViewCount="623" Body="&lt;p&gt;I am currently working on the following problem, which is a variation of a &lt;em&gt;vehicle routing problem&lt;/em&gt;. I am looking for different ideas to tackle it.&lt;/p&gt;&#xA;&lt;h3&gt;Problem description&lt;/h3&gt;&#xA;&lt;p&gt;A set of nodes with a given demand must be visited. The driver uses his vehicle with capacity &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; to approach the nodes, finds a parking spot, transfers part of the commodities into a knapsack with capacity &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt;, and services whichever nodes he can. Once he is done, he returns to his vehicle with the empty knapsack, and either services another subset of nodes without moving the vehicle, or either moves on to find the next parking spot. The Figure below illustrates an example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ei3Fg.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ei3Fg.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The red square is the depot. The blue circles are the parking spots, which are unknown &lt;em&gt;a priori&lt;/em&gt;. And the grey squares are the nodes with known demand.&lt;/p&gt;&#xA;&lt;p&gt;So the problem involves finding big tours (in blue), where the positions of the blue nodes are not known in advance, and subtours (in dark grey), where the depots are the blue nodes. The big tours and subtours have different capacity constraints (&lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt;, respectively). Nodes are not organized into clusters as nicely as in the picture. The positions of the parking spots (blue nodes) obviously impact the quality of the subtours. And the idea is to have the right number of parking spots in order to maximize efficiency. This efficiency could be indirectly taken into account with appropriate costs on the arcs, and perhaps with time constraints. For example, it would very likely be inefficient to park in front of each node with known demand, and move on to the next one (this would result in a classical CVRP).&lt;/p&gt;&#xA;&lt;h3&gt;Is this a known problem ?&lt;/h3&gt;&#xA;&lt;p&gt;I am not sure if this is a known problem. Similar problems include the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-layer Location Routing Problem, and the Traveling Salesman Facility Location Problem.&lt;/p&gt;&#xA;&lt;h3&gt;How would you tackle this problem ?&lt;/h3&gt;&#xA;&lt;p&gt;A possible approach would be to decompose the problem into two subproblems. Subproblem &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; would be some sort of &lt;em&gt;facility location problem&lt;/em&gt; (FLP), where the facilities are the parking spots, and where the selected facilities must form a tour with minimum cost. And Subproblem &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; would be the corresponding subtours, where each facility from phase 1 is a depot. Subproblem &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; already seems hard though, as it is already a mix between two hard problems (TSP and FLP).&lt;/p&gt;&#xA;&lt;p&gt;All ideas are welcome.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-03-05T03:45:59.660" Title="How to tackle this VRP variant?" Tags="|mixed-integer-programming|modeling|reference-request|vehicle-routing|graphs|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7977" PostTypeId="2" ParentId="7976" CreationDate="2022-03-03T13:59:58.547" Score="7" Body="&lt;p&gt;This is a Two-Echelon Vehicle Routing Problem. Here is a recent review of the literature on this problem:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;quot;Two-Echelon Vehicle Routing Problems: A Literature Review&amp;quot; (Sluijk et al., 2022) &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2022.02.022&quot; rel=&quot;noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-03-03T13:59:58.547" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7978" PostTypeId="2" ParentId="7976" CreationDate="2022-03-03T14:14:56.083" Score="5" Body="&lt;p&gt;This problem is known as two-echelon location routing problem (LRP-2E). On different mathematical programming model of LRP-2E:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Boccia, M., Crainic, T.G., Sforza, A., Sterle, C., 2011. Location-routing models for designing a two-echelon freight distribution system (No. CIRRELT-2011-06). Centre interuniversitaire de recherche sur les reseaux d’entreprise, la logistique et le transport (CIRRELT).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2022-03-03T14:14:56.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7979" PostTypeId="2" ParentId="7973" CreationDate="2022-03-03T15:25:49.937" Score="7" Body="&lt;p&gt;Given that your problem has binary assignment variables (the &amp;amp;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; variables) it is not a capacitated facility location problem (CFLP) , it is a &lt;em&gt;single source&lt;/em&gt; CFLP (SSCFLP). The decision problem &amp;quot;does the SSCFLP have a feasible solution&amp;quot; is NP-complete, and hence it is not enough to look at the cumulative capacity to check feasibility.&lt;/p&gt;&#xA;&lt;p&gt;Take for instance the problem with three customers having a demand of two units each and two potential facilities with a capacity of three units each. There is a total capacity of six units, a total demand of six units, and no single source solution.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-03-03T15:25:49.937" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7980" PostTypeId="2" ParentId="7693" CreationDate="2022-03-03T15:52:45.840" Score="2" Body="&lt;p&gt;If you are interested in the tradeoff between speed and fuel consumption for an ocean going&#xA;vessel, see&lt;/p&gt;&#xA;&lt;p&gt;Gerald G. Brown, Jeffrey E. Kline, Richard E. Rosenthal, Alan R. Washburn, (2007)&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Steaming on Convex Hulls.&amp;quot; INFORMS Journal on Applied Analytics 37(4):342-352.&lt;/p&gt;&#xA;&lt;p&gt;It points out that, given the features of actual marine propulsion systems, the optimum&#xA;tradeoff between fuel consumption and travel time may be to travel part of trip at high&#xA;speed and the remainder of the trip at slow speed, rather than travel at one constant speed throughout the entire trip.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-03-03T15:52:45.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7981" PostTypeId="2" ParentId="7975" CreationDate="2022-03-03T17:43:10.090" Score="7" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^p$&lt;/span&gt; be a binary variable that indicates if user &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; is assigned to access point &lt;span class=&quot;math-container&quot;&gt;$j \in J = \{1,...,M\}$&lt;/span&gt; located in position &lt;span class=&quot;math-container&quot;&gt;$p\in P$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$z_{j}^p$&lt;/span&gt; be a binary variable that indicates if access point &lt;span class=&quot;math-container&quot;&gt;$j\in J$&lt;/span&gt; is assigned to position &lt;span class=&quot;math-container&quot;&gt;$p\in P$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For every tuple &lt;span class=&quot;math-container&quot;&gt;$(i,j,p) \in I \times J \times P$&lt;/span&gt;, a score &lt;span class=&quot;math-container&quot;&gt;$c_{ij}^p$&lt;/span&gt; is computed according OP's rules:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c_{ij}^p = \begin{cases} &#xA;      0 &amp;amp; \mbox{ if } d_{ip} &amp;gt; \mbox{range}(j) \\&#xA;      \mbox{speed}(i)\cdot\mbox{speed}(j)- \mbox{latency}(i)\cdot d_{ip}&amp;amp; \mbox{ otherwise }&#xA;  \end{cases}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You want to maximize the total score:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \; \sum_i\sum_j\sum_p c_{ij}^p x_{ij}^p&#xA;$$&lt;/span&gt;&#xA;subject to&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;assign users to access points:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_j\sum_p x_{ij}^p = 1 \quad \forall i \in I&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;each access point has a unique position:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_p z_{j}^p = 1 \quad \forall j \in J&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;each position has at most one access point:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_j z_{j}^p \le 1 \quad \forall p \in P&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;consistency between &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_{j}^p$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{ij}^p \le z_{j}^p \quad \forall i \in I, \forall j \in J, \forall p \in P&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You might want to consider maximizing the minimum score.&lt;/p&gt;&#xA;&lt;p&gt;My &lt;a href=&quot;https://github.com/Kuifje02/or.stackexchange-simulations/blob/main/AccessPoints.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;simulations&lt;/a&gt; with some random data (possibly poorly randomized and scaled) yield the following output:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u3lVX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u3lVX.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-03-05T16:40:42.380" LastActivityDate="2022-03-05T16:40:42.380" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7982" PostTypeId="1" CreationDate="2022-03-03T18:12:23.850" Score="2" ViewCount="58" Body="&lt;p&gt;I am working on an OR scheduling problem where OR opening cost is considered a fixed cost when a surgery is scheduled. If OR is used beyond a certain time, overtime cost is incurred.&lt;/p&gt;&#xA;&lt;p&gt;I would like to know how the ratio affects the problem difficulty. I understand that for ridiculously higher OR opening costs, one would try to first minimize the number of ORs open. What happens in other cases? How does a solver perceive this?&lt;/p&gt;&#xA;" OwnerUserId="3520" LastActivityDate="2022-03-03T20:53:23.493" Title="How does a ratio of fixed cost to variable cost affect the problem difficulty?" Tags="|mixed-integer-programming|linear-programming|integer-programming|combinatorial-optimization|gurobi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7983" PostTypeId="2" ParentId="7966" CreationDate="2022-03-03T19:27:14.203" Score="4" Body="&lt;p&gt;I tried an alternative (possibly over-engineered) MIP formulation, using Miller-Tucker-Zemlin variables. &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is the set of arcs in the graph, &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is the source node for all paths, and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is the sink node for all paths. &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is the maximum path length. The variables are as follows.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$u_{a}\in\left\{ 0,1\right\} $&lt;/span&gt; is 1 if and only if arc &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is used&#xA;on the path.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f_{a}\in\left\{ 0,1\right\} $&lt;/span&gt; is 1 if and only if arc &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is the&#xA;first arc on the path.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\ell_{a}\in\left\{ 0,1\right\} $&lt;/span&gt; is 1 if and only if arc &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is the last arc on the path.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{ab}\in\left\{ 0,1\right\} $&lt;/span&gt; is 1 if and only if arc &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; immediately&#xA;follows arc &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; on the path.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{a}\in\left[0,M\right]$&lt;/span&gt; will be the number of arcs preceding arc&#xA;&lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; on the path (0 if &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is not on the path).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;We can fix the values of many of the variables up front.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f_{a}=0$&lt;/span&gt; if node &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is not the tail of arc &lt;span class=&quot;math-container&quot;&gt;$a.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\ell_{a}=0$&lt;/span&gt; if node &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is not the head of arc &lt;span class=&quot;math-container&quot;&gt;$a.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{ab}=0$&lt;/span&gt; if the head of arc &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is not the tail of arc &lt;span class=&quot;math-container&quot;&gt;$b.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The constraints are as follows.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There must be one first arc and one last arc. &lt;span class=&quot;math-container&quot;&gt;$$\sum_{a\in A}f_{a}=1.$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$\sum_{a\in A}\ell_{a}=1.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;At most &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; arcs can be used. &lt;span class=&quot;math-container&quot;&gt;$$\sum_{a\in A}u_{a}\le M.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;An arc is used if and only if it is either the first arc or follows&#xA;another arc on the path. &lt;span class=&quot;math-container&quot;&gt;$$f_{a}+\sum_{b\in A}y_{ba}=u_{a}\quad\forall a\in A.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The last arc must be a used arc. &lt;span class=&quot;math-container&quot;&gt;$$\ell_{a}\le u_{a}\quad\forall a\in A.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The sequence value of an unused arc is 0. &lt;span class=&quot;math-container&quot;&gt;$$z_{a}\le Mu_{a}\quad\forall a\in A.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;No arc can follow the last arc. &lt;span class=&quot;math-container&quot;&gt;$$\ell_{a}+\sum_{b\in A}y_{ab}\le1\quad\forall a\in A.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If an arc is used, either it is the last arc or another arc follows&#xA;it. &lt;span class=&quot;math-container&quot;&gt;$$\ell_{a}+\sum_{b\in A}y_{ab}=u_{a}\quad\forall a\in A.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If an arc &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; follows arc &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, the sequence number of arc &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; must&#xA;be one higher than the sequence number of arc &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; (MTZ). &lt;span class=&quot;math-container&quot;&gt;$$z_{a}-z_{b}+\left(M+1\right)y_{ab}\le M\quad\forall a,b\in A,a\neq b.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I omitted an objective function, which is equivalent to making the objective function minimizing a constant (0).&lt;/p&gt;&#xA;&lt;p&gt;Rather than solving repeatedly with no-good constraints added after each new solution, I used the &amp;quot;populate&amp;quot; function in CPLEX with suitable parameters to get all feasible solutions in one gulp. That worked for &lt;span class=&quot;math-container&quot;&gt;$M=3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M=4$&lt;/span&gt;, but on Erwin's graph with &lt;span class=&quot;math-container&quot;&gt;$M=10$&lt;/span&gt; brute force found 268 paths and the populate function (with the highest intensity setting and a large pool capacity setting) found only 33.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-03-03T20:40:54.280" LastActivityDate="2022-03-03T20:40:54.280" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7984" PostTypeId="2" ParentId="7982" CreationDate="2022-03-03T20:53:23.493" Score="1" Body="&lt;p&gt;If by &amp;quot;problem difficulty&amp;quot; you mean how much time / how many nodes are required to solve the problem, I don't know that the effect of the ratio can be anticipated. I would not be surprised if extremely high or extremely low ratios made for easier problems (fewer nodes worth looking at), while some intermediate ratio might bring the objective values of high- and low-overtime solutions closer to each other, forcing more nodes to be explored. That's just a guess.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-03T20:53:23.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7985" PostTypeId="1" AcceptedAnswerId="7986" CreationDate="2022-03-03T21:04:55.227" Score="5" ViewCount="228" Body="&lt;p&gt;I am struggling with the following constraint on a minimization problem&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvx.max(z[:, i] + z[:, j]) == 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where &lt;code&gt;z&lt;/code&gt; is a Boolean matrix decision variable. I need to ensure that at least one row in &lt;code&gt;z&lt;/code&gt; has a &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in two given columns (&lt;code&gt;i&lt;/code&gt; and &lt;code&gt;j&lt;/code&gt;). CVXPY informs me that this is not DCP-compliant.&lt;/p&gt;&#xA;&lt;p&gt;Can you think of a DCP formulation that would enable a constraint such as &lt;code&gt;z[k, i] == 1 and z[k, j] == 1&lt;/code&gt; for at least one &lt;code&gt;k&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="7428" LastEditorUserId="500" LastEditDate="2022-03-04T15:52:20.310" LastActivityDate="2022-03-04T15:52:20.310" Title="Constraints like &quot;max(column a + column b) == 2&quot; are not DCP" Tags="|python|convex-optimization|binary-variable|disciplined-convex-programming|cvxpy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7986" PostTypeId="2" ParentId="7985" CreationDate="2022-03-03T21:17:58.303" Score="6" Body="&lt;p&gt;Not sure if it is DCP, but you can write it as a quadratic constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_k z_{k,i} z_{k,j} \ge 1$$&lt;/span&gt;&#xA;You can also linearize as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_k x_{k,i,j} &amp;amp;\ge 1 \\&#xA;x_{k,i,j} &amp;amp;\le z_{k,i} \\&#xA;x_{k,i,j} &amp;amp;\le z_{k,j}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-03-04T00:14:47.673" LastActivityDate="2022-03-04T00:14:47.673" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7987" PostTypeId="1" CreationDate="2022-03-03T23:03:27.023" Score="-5" ViewCount="271" Body="&lt;p&gt;I work on the scaling of MIP. I have scaled the A,b,c matrices of the huge original model. These matrices have more than 25000 rows and columns. I need to make Gurobi solve the scaled model. Normally, I use the .lp file and give it to the Gurobi but in this case, I only have three scaled matrices and not the model itself in a .lp file.&lt;/p&gt;&#xA;&lt;p&gt;Matrices are received as the output of a C++ program and could be transferred anywhere.&lt;/p&gt;&#xA;&lt;p&gt;How can I solve LP/IP using A,b,c matrices only?&lt;/p&gt;&#xA;&lt;p&gt;Same question, in other words, how can I place back scaled matrices to the .lp file again?&lt;/p&gt;&#xA;" OwnerUserId="7526" LastEditorUserId="7526" LastEditDate="2022-03-03T23:09:38.467" LastActivityDate="2022-03-04T11:41:46.317" Title="How to make Gurobi solve huge LP/IP model with only using A,b,c matrices?" Tags="|optimization|mixed-integer-programming|linear-programming|integer-programming|gurobi|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="7988" PostTypeId="1" AcceptedAnswerId="8003" CreationDate="2022-03-04T07:19:10.037" Score="2" ViewCount="202" Body="&lt;p&gt;I know that if &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a quasi-convex function in one dimension (that is, &lt;span class=&quot;math-container&quot;&gt;$f: \mathbb{R} \to \mathbb{R}$&lt;/span&gt;), then we can use the 'golden section' line search to find the optimizer.&lt;/p&gt;&#xA;&lt;p&gt;Now suppose I have a function &lt;span class=&quot;math-container&quot;&gt;$f: \mathbb{R}^2 \to \mathbb{R}$&lt;/span&gt; which is quasi-convex. I seek to minimize &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;. We can assume that we are initially given a bounded axis-aligned rectangle which is guaranteed to contain the minimizer.&lt;/p&gt;&#xA;&lt;p&gt;Is there an analogy to line search in 2D which I can use to minimize this function?&lt;/p&gt;&#xA;" OwnerUserId="9298" LastEditorUserId="9298" LastEditDate="2022-03-05T18:12:19.573" LastActivityDate="2022-03-05T21:25:00.677" Title="How to minimize a quasi-convex function in 2 dimensions?" Tags="|optimization|convex-optimization|disciplined-quasiconvex-programming|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7989" PostTypeId="2" ParentId="7966" CreationDate="2022-03-04T09:28:14.673" Score="5" Body="&lt;p&gt;Yet another possibility suggested by @Sune, using &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-shortest path algorithms :&lt;/p&gt;&#xA;&lt;p&gt;The python module NetworkX provides &lt;a href=&quot;https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.simple_paths.shortest_simple_paths.html#networkx.algorithms.simple_paths.shortest_simple_paths&quot; rel=&quot;noreferrer&quot;&gt;an implementation&lt;/a&gt; of  &lt;a href=&quot;http://people.csail.mit.edu/minilek/yen_kth_shortest.pdf&quot; rel=&quot;noreferrer&quot;&gt;Yens's algorithm&lt;/a&gt;. Since the algorithm computes loopless paths, using the line graph like Erwin is necessary. Once the transformation is done, it is a one liner:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# create line graph&#xA;H = nx.line_graph(G)&#xA;new_edges = []&#xA;# add source and sink nodes&#xA;for (u,v) in H.nodes():&#xA;    if u==1:&#xA;        new_edges.append((&amp;quot;source&amp;quot;,(u,v)))&#xA;    if v==10:&#xA;        new_edges.append(((u,v),&amp;quot;sink&amp;quot;))&#xA;H.add_edges_from(new_edges)&#xA;&#xA;# 9 shortest paths&#xA;list(islice(nx.shortest_simple_paths(H, source=&amp;quot;source&amp;quot;, target=&amp;quot;sink&amp;quot;), 9))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Erwin's graph is solved in less than &lt;span class=&quot;math-container&quot;&gt;$0.1$&lt;/span&gt; ms, and the output is, as expected:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FoIBW.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FoIBW.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-03-04T09:28:14.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7990" PostTypeId="2" ParentId="7987" CreationDate="2022-03-04T11:41:46.317" Score="3" Body="&lt;p&gt;You are spamming the ORExchange and Stackoverflow forums with several very related questions without providing links between them. This is bad practice and disrespectful of the time of other community members trying to answer your questions.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/7913/how-to-create-a-b-and-c-matrices-from-very-large-lp-file&quot;&gt;How to create A, b and c matrices from very large .lp file?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/7856/how-to-make-clion-read-lp-file-and-make-gurobi-solve-that-file-within-clion&quot;&gt;How to make CLion read .lp file and make Gurobi solve that file within CLion?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/71220356/how-to-make-clion-read-lp-file-and-make-gurobi-solve-that-file-within-clion/71223347#71223347&quot;&gt;SO: How to make CLion read .lp file and make Gurobi solve that file within CLion?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/71326172/how-to-find-row-i-and-column-j-of-sparse-matrix-vector-a&quot;&gt;SO: How to find row [i] and column [j] of Sparse Matrix/Vector A?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/4460822390289-How-to-make-CLion-read-lp-file-and-make-Gurobi-solve-that-file-within-CLion-&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi Community: How to make CLion read .lp file and make Gurobi solve that file within CLion?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Math programming is usually taught using matrices but in code, the common approach (at least for linear problems) is to use a constraint-based way. You should scale the matrix coefficients column-wise or row-wise by traversing the constraints (rows) and variables (columns) of your problem. It is counterproductive and way more difficult to extract the full matrix and then feed the data back into the solver. And by the way: 25k rows and columns is anything from huge.&lt;/p&gt;&#xA;&lt;p&gt;In Gurobi's &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/guidelines_for_numerical_i.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Guidelines for Numerical Issues&lt;/a&gt;, there is an example that demonstrates how you can apply scaling factors to an existing problem: &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/_code_for_the_experiment_w.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.5/refman/_code_for_the_experiment_w.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2022-03-04T11:41:46.317" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7991" PostTypeId="1" AcceptedAnswerId="7993" CreationDate="2022-03-03T09:17:12.990" Score="6" ViewCount="254" Body="&lt;p&gt;I have a linear programming problem in front of me that I am searching to solve in R (any package). It seems like an unbalanced assignment problem to me with relaxed constraints on columns (repeated assignment is possible) or more general possibly a transportation problem:&lt;/p&gt;&#xA;&lt;p&gt;I got 188 materials that I can get from 7 suppliers. Not all suppliers can provide all of the materials but each just some subset of the material demand.&lt;/p&gt;&#xA;&lt;p&gt;What I know is&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the demand for each of the material&lt;/li&gt;&#xA;&lt;li&gt;how much I can order for the month at each supplier&lt;/li&gt;&#xA;&lt;li&gt;which supplier can provide which material in which quantity.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;One can imagine the sample problem as a table where the marginals are known, the x means that I can order at that supplier(s), the quantity could be split into smaller chunks, costs let us say are constant for all material/supplier combination e.g. 1 (or could be 33):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   Sup1  Sup2 Sup3  (Demand-Quantity of the material to get)&#xA;m1  x               0.12&#xA;m2  x    x          1.8&#xA;m3            x     1.9&#xA;m4       x          2.1&#xA;m5 x     x    x     0.1&#xA;   30    50   12&#xA;   (Capacity of suppliers 1 to 3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Hence the problem is to minimise the order (cost) given I get all materials and not cross over the capacity of each suppliers. I need to get, given the demand, capacity constraints, a cost matrix and demand satisfaction matrix (which supplier provides which material), which quantities of each material to get at each supplier.&lt;/p&gt;&#xA;&lt;p&gt;A concrete case, demand and capacity in tons (cost are constant for demonstration, all = 1):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;demand &amp;lt;- c(10.994, 0.322, 0.046, 1.449, 0.253, 0.368, 5.221, 2.208, 0.989, &#xA;            11.983, 0.046, 0.092, 0.115, 0.023, 1.633, 0.253, 0.276, 0.483, &#xA;            0.966, 8.763, 0.276, 1.173, 17.963, 0.943, 4.232, 0.575, 23.138, &#xA;            0.207, 10.465, 0.138, 0.92, 11.247, 6.486, 4.807, 16.606, 0.966, &#xA;            4.554, 1.15, 0.644, 0.046, 0.046, 0.023, 0.989, 1.288, 0.966, &#xA;            13.34, 5.796, 12.213, 10.097, 5.865, 5.704, 38.916, 7.291, 18.193, &#xA;            0.184, 4.439, 58.305, 0.115, 1.38, 3.22, 8.234, 5.29, 2.369, &#xA;            0.736, 2.668, 4.968, 3.496, 0.552, 0.598, 4.922, 0.322, 0.161, &#xA;            0.483, 0.644, 0.736, 0.069, 0.644, 14.789, 3.243, 1.242, 3.381, &#xA;            41.423, 0.644, 56.603, 3.841, 9.154, 0.23, 2.07, 40.871, 0.575, &#xA;            0.276, 0.276, 4.255, 0.092, 0.253, 0.161, 0.115, 0.23, 0.092, &#xA;            0.138, 0.874, 0.184, 0.483, 0.115, 0.161, 0.069, 0.184, 1.633, &#xA;            0.184, 0.023, 0.621, 0.046, 0.184, 2.415, 4.301, 0.138, 0.667, &#xA;            3.818, 0.138, 0.276, 0.023, 0.874, 1.702, 0.253, 0.299, 0.552, &#xA;            7.153, 0.966, 1.702, 1.104, 0.713, 4.14, 0.575, 0.322, 0.115, &#xA;            0.621, 1.932, 0.759, 0.69, 0.207, 0.759, 0.966, 0.023, 3.358, &#xA;            1.357, 0.207, 1.242, 0.138, 1.265, 7.958, 0.529, 2.53, 0.552, &#xA;            0.552, 0.046, 0.207, 0.069, 0.368, 0.092, 0.023, 0.966, 1.633, &#xA;            3.151, 2.53, 9.2, 0.598, 0.138, 1.173, 0.345, 2.001, 0.506, 0.598, &#xA;            1.104, 4.278, 0.345, 1.104, 0.253, 0.736, 0.138, 0.276, 4.761, &#xA;            0.851, 2.622, 0.345, 0.92, 1.357, 0.092, 0.368)&#xA;n_demand &amp;lt;- length(demand)&#xA;capacity = c(55, 70, 60, 51, 10, 90, 10, 10, 10)&#xA;n_capacity &amp;lt;- length(capacity)&#xA;material_supplier_mat &amp;lt;- structure(c(1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, &#xA;0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, &#xA;0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, &#xA;1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, &#xA;0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, &#xA;0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, &#xA;1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, &#xA;0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, &#xA;1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, &#xA;1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, &#xA;1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, &#xA;0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, &#xA;1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, &#xA;1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, &#xA;1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, &#xA;1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, &#xA;0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, &#xA;1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, &#xA;1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, &#xA;1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, &#xA;0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, &#xA;1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, &#xA;1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, &#xA;1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, &#xA;1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, &#xA;0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, &#xA;0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, &#xA;1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, &#xA;1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, &#xA;0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, &#xA;1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, &#xA;1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, &#xA;1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, &#xA;1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, &#xA;0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, &#xA;0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, &#xA;1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, &#xA;1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, &#xA;1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, &#xA;1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, &#xA;1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, &#xA;1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, &#xA;1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, &#xA;1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, &#xA;0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, &#xA;1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, &#xA;1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, &#xA;1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, &#xA;1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, &#xA;1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, &#xA;1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, &#xA;0L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, &#xA;0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, &#xA;0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, &#xA;0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, &#xA;1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, &#xA;0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, &#xA;1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, &#xA;0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, &#xA;0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, &#xA;1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, &#xA;0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, &#xA;0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, &#xA;0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, &#xA;1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, &#xA;0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, &#xA;1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, &#xA;0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, &#xA;0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, &#xA;1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, &#xA;0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, &#xA;0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, &#xA;0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, &#xA;1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, &#xA;1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, &#xA;1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, &#xA;0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, &#xA;0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, &#xA;1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, &#xA;0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, &#xA;0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, &#xA;0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, &#xA;1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, &#xA;1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, &#xA;1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, &#xA;0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, &#xA;0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, &#xA;1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, &#xA;0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, &#xA;0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, &#xA;0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, &#xA;0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, &#xA;0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, &#xA;1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, &#xA;0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, &#xA;0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, &#xA;0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, &#xA;0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, &#xA;0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, &#xA;0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, &#xA;0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, &#xA;0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, &#xA;0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, &#xA;0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, &#xA;0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, &#xA;1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L), .Dim = c(9L, &#xA;188L))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried using &lt;code&gt;ompr&lt;/code&gt; like follows&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;library(ompr)&#xA;library(ROI)&#xA;library(ROI.plugin.glpk)&#xA;library(ompr.roi)&#xA;&#xA;model &amp;lt;- MIPModel() %&amp;gt;%&#xA;  add_variable(x[i], i = seq_len(n_demand), type = 'continuous') %&amp;gt;%&#xA;  add_variable(b[i], i = seq_len(n_demand), type = 'binary') %&amp;gt;%&#xA;  set_objective(sum_expr(x[i], i = seq_len(n_demand)), sense = 'min')&#xA;&#xA;for (el in seq_len(n_demand)) {&#xA;  model %&amp;lt;&amp;gt;% &#xA;    set_bounds(x[el], lb = demand[el]) &#xA;}&#xA;&#xA;for(el in seq_len(n_capacity)) {&#xA;  &#xA;  column_index &amp;lt;- which(material_supplier_mat[el, ] == 1L) # the sum of these columns/material quantities that need to be taken into consideration &#xA;  cat(&amp;quot;column_index:&amp;quot; , column_index, &amp;quot;\n&amp;quot;)&#xA;  nr_columns &amp;lt;- sum(material_supplier_mat[el, ] == 1L) # for the constraint to allow up to 'nr_columns' to be tried to be taken into account7&#xA;  cat(&amp;quot;nr_columns:&amp;quot; , nr_columns, rep.int(&amp;quot;\n&amp;quot;, 2L))&#xA;  &#xA;  model %&amp;lt;&amp;gt;%&#xA;    add_constraint(sum_expr(demand[i] * b[i]) &amp;lt;= capacity[el], i = column_index) %&amp;gt;%&#xA;    add_constraint(sum_expr(b[i]) &amp;lt;= nr_columns, i = column_index)&#xA;}&#xA;&#xA;result &amp;lt;- model %&amp;gt;% &#xA;  solve_model(with_ROI(solver = &amp;quot;glpk&amp;quot;, verbose = TRUE))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I don't think it is the right formulation and solution, at the end I was hoping to get the objective value as well as decision of the material quantities purchase for each supplier (for instance get m2 0.8t at S1 and 1.0t at S2).&lt;/p&gt;&#xA;" OwnerUserId="7523" OwnerDisplayName="Patrik" LastEditorUserId="279" LastEditDate="2022-07-29T22:50:07.897" LastActivityDate="2022-07-29T22:50:07.897" Title="Linear Programming problem for finding supplier" Tags="|r|optimization|linear-programming|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7992" PostTypeId="1" CreationDate="2022-03-04T14:39:46.483" Score="7" ViewCount="110" Body="&lt;p&gt;Is there somewhere a list of ongoing &lt;em&gt;Call for papers&lt;/em&gt; for special issues in OR journals?&lt;/p&gt;&#xA;&lt;p&gt;I believe that such a list would not only create a good overview for publication opportunities but also inform about current research trends in the field.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2022-03-04T14:39:46.483" Title="List of Call for papers" Tags="|journals|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7993" PostTypeId="2" ParentId="7991" CreationDate="2022-03-04T22:55:47.117" Score="2" Body="&lt;p&gt;Your code now runs, but I'm fairly certain the model is wrong.&lt;/p&gt;&#xA;&lt;p&gt;To get the values of &lt;code&gt;x&lt;/code&gt; as a vector, you can execute &lt;code&gt;get_solution(result, x[i])[, &amp;quot;value&amp;quot;]&lt;/code&gt;. To get it as a data frame (with columns for variable name, index and value), just use &lt;code&gt;get_solution(result, x[i])&lt;/code&gt;. The same approach works for &lt;code&gt;b&lt;/code&gt;. The expression &lt;code&gt;result$objective_value&lt;/code&gt; will get you the optimal objective value.&lt;/p&gt;&#xA;&lt;p&gt;For your model, the solution is trivial. Each &lt;code&gt;x[i]&lt;/code&gt; is equal to &lt;code&gt;demand[i]&lt;/code&gt; because you set that as a lower bound. Every &lt;code&gt;b[i]&lt;/code&gt; is 0.&lt;/p&gt;&#xA;&lt;p&gt;The description of your problem is a bit unclear (I have no idea what &lt;code&gt;b[]&lt;/code&gt; represents), but you might want to have a look at the &amp;quot;transportation problem&amp;quot; (which applies to more things than just transportation of goods). An easy introduction is &lt;a href=&quot;https://towardsdatascience.com/operations-research-in-r-transportation-problem-1df59961b2ad&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-04T22:55:47.117" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7994" PostTypeId="1" AcceptedAnswerId="7995" CreationDate="2022-03-05T00:31:33.477" Score="3" ViewCount="526" Body="&lt;p&gt;I am trying to understand Benders Decomposition method. I am reading this book Decomposition techniques in mathematical programming by A Conejo, E Castillo, R Minguez. The book provides an example of Benders decomposition (pages 118-120). The problem is given as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\text{minimise} \hspace{0.5cm} &amp;amp;z = -y - x/4 \\&#xA;\text{s.t.} \hspace{0.5cm} &amp;amp; y  -x \leq 5 \\&#xA;&amp;amp; y -\frac{1}{2}x  \leq \frac{15}{2} \\&#xA;&amp;amp; y + \frac{1}{2}x  \leq \frac{35}{2} \\&#xA;&amp;amp; -y+x \leq 10 \\&#xA;&amp;amp; 0 \leq x \leq 16 \\&#xA;&amp;amp; y \geq 0&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are (continuous) variables.&lt;/p&gt;&#xA;&lt;p&gt;For decomposition, the Master problem is defined as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\text{minimise} \hspace{0.5cm} &amp;amp; -\frac{1}{4}x + \alpha \\&#xA;\text{s.t.} \hspace{0.5cm} &amp;amp; 0 \leq x \leq 16 \\&#xA;&amp;amp; -25 \leq \alpha&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The sub problem is given as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\text{minimise} \hspace{0.5cm} &amp;amp; z = -y \\&#xA;\text{s.t.} \hspace{0.5cm} &amp;amp; y - x \leq 5 \\&#xA;&amp;amp; y -\frac{1}{2}x  \leq \frac{15}{2} \\&#xA;&amp;amp; y + \frac{1}{2}x  \leq \frac{35}{2} \\&#xA;&amp;amp; -y+x \leq 10 \\&#xA;&amp;amp; 0 \leq x \leq 16 \\&#xA;&amp;amp; y \geq 0 \\&#xA;&amp;amp; x = 16&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I don’t understand how this bound or constraint of -25 on &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; in the Master problem is determined and the constraint of &lt;span class=&quot;math-container&quot;&gt;$x=16$&lt;/span&gt; in the sub problem. Can someone please explain?&lt;/p&gt;&#xA;" OwnerUserId="3896" LastEditorUserId="136" LastEditDate="2022-03-15T07:46:15.230" LastActivityDate="2022-03-15T07:46:15.230" Title="Benders decomposition feasibility/ optimality cuts" Tags="|linear-programming|benders-decomposition|decomposition|lp-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7995" PostTypeId="2" ParentId="7994" CreationDate="2022-03-05T01:33:05.673" Score="7" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is a surrogate for &lt;span class=&quot;math-container&quot;&gt;$-y$&lt;/span&gt;, so the negative of any valid upper bound on &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a valid lower bound on &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;. You need such a bound since otherwise the master problem would be unbounded (pick a feasible &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$\alpha \rightarrow -\infty$&lt;/span&gt;). Why they picked -25 I can't say. Looking at the second constraint of the original problem and setting &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to its upper limit of &lt;span class=&quot;math-container&quot;&gt;$16$&lt;/span&gt;, you get &lt;span class=&quot;math-container&quot;&gt;$y\le 15.5$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$\alpha \ge -15.5$&lt;/span&gt; would be valid (and a bit tighter, not that it matters). I suspect they just picked -25 because it's valid and aesthetically pleasing in some way ... or maybe because they knew that, being smaller than &lt;span class=&quot;math-container&quot;&gt;$-y$&lt;/span&gt; can ever get, it would trigger an optimality cut (for demonstration purposes).&lt;/p&gt;&#xA;&lt;p&gt;As for the &lt;span class=&quot;math-container&quot;&gt;$x=16$&lt;/span&gt; constraint, the idea of Benders is to solve the master (getting &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha^*$&lt;/span&gt;), pass them to the subproblem as parameter values, and solve for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. If the subproblem is infeasible, you get a feasibility cut. If the subproblem is feasible but the optimal value &lt;span class=&quot;math-container&quot;&gt;$y^*$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; does not satisfy &lt;span class=&quot;math-container&quot;&gt;$-y^*\le \alpha^*$&lt;/span&gt;, you get an optimality cut. If neither of those problems arises, you have a winner. When you solve the initial master, you get &lt;span class=&quot;math-container&quot;&gt;$x^* = 16, \alpha^* = -25$&lt;/span&gt;. Rather than substitute 16 for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in the subproblem, the authors apparently chose to add a constraint that sets &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; equal to 16, which has the same effect. I will say that is more common to write the subproblem as if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; were a parameter (omitting &lt;span class=&quot;math-container&quot;&gt;$0\le x \le 16$&lt;/span&gt; since &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is not a variable in the subproblem).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-05T01:33:05.673" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7996" PostTypeId="1" AcceptedAnswerId="7999" CreationDate="2022-03-05T01:41:24.787" Score="7" ViewCount="382" Body="&lt;p&gt;It's typical that the Simplex Method implementation exits once it finds an optimum value. However, if I want to find all optima that exist at extreme points (not those that exist along a face), is it possible to walk through them in linear time? In polynomial time?&lt;/p&gt;&#xA;&lt;p&gt;In my mind, it seems I would need to search through the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; decision variables to find one I could move into my basic solution without losing my optimum status. I would then have to back up my changes somehow so I could come back in what I picture to be a backtracking tree search. Am I picturing this correctly?&lt;/p&gt;&#xA;&lt;p&gt;Can you recommend a source on this topic?&lt;/p&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2022-03-09T07:28:59.517" Title="Can the primal Simplex Method walk all optima in linear time?" Tags="|simplex|primal-simplex|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7997" PostTypeId="2" ParentId="7976" CreationDate="2022-03-05T03:40:49.090" Score="4" Body="&lt;p&gt;You can actually get good results by dealing with it relatively simply. We support what we call '&lt;em&gt;park-and-loop vehicle routing&lt;/em&gt;' in our commercial route optimiser engine &lt;a href=&quot;https://odllive.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ODL Live&lt;/a&gt;. Currently we just use a limit on number of stops in the walking loop rather than a capacity, but it's pretty much the same problem. Crucially, we get good results by using just a simple deterministic rule at each stop, where (a) if you're not already parked, the rule makes the choice whether to walk or drive to the next stop, and (b) if you are already parked, the rule makes the choice whether to continue walking to the next stop, or to return to the parking spot and drive to the next stop.&lt;/p&gt;&#xA;&lt;p&gt;Using a simple rule has the advantage that you effectively transform the problem into a standard VRP, because whether to walk or not is no longer a decision variable. So many of the standard search heuristics used on VRPs can still be used on this problem without modification.&lt;/p&gt;&#xA;&lt;p&gt;Presumably there's situations where using a simple rule will create sub-optimal solutions compared to solving it properly as say a two-echelon location routing problem. However from a practical point-of-view this scheme appears to work well, it's relatively simple to implement if you have a heuristic-based solver (probably less so for a MIP-based solver) and presumably it requires less computational resources to optimise compared to a two-echelon problem formulation.&lt;/p&gt;&#xA;&lt;p&gt;The following image shows some experiments from one of our test cases, where time for parking the vehicle is also considered. The walking loops get bigger as vehicle parking time increases because its more efficient to do larger walking loops and therefore park the vehicle less often.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/o2uF2.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/o2uF2.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="825" LastEditorUserId="825" LastEditDate="2022-03-05T03:45:59.660" LastActivityDate="2022-03-05T03:45:59.660" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7998" PostTypeId="2" ParentId="7991" CreationDate="2022-03-05T07:18:10.070" Score="4" Body="&lt;p&gt;The problem you mentioned sounds like a variant of the lot-sizing problem in which there are multiple sources to produce one of the materials. Let's say, the variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,s,t}$&lt;/span&gt; represents the amount of material &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; that is produced by supplier &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Also, the binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,t}$&lt;/span&gt; is being introduced to ensure that if any material &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; will be started in the period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, otherwise is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min&amp;amp;\quad Z=\sum_{i=1}^{I} \sum_{s=1}^{S} \sum_{t=1}^{T} c_{i,s,t}\cdot  x_{i,s,t}\\\text{s.t.}&amp;amp;\quad&#xA;\sum_{s=1}^{S} x_{i,s,t} \geq  \text{demand}_{i,t} \quad ,\forall i=1, \ldots, I, \forall t=1, \ldots, T &amp;amp; \text{(1)}\\&amp;amp;\quad&#xA;x_{i,s,t} \leq  y_{i,t}\cdot\text{lotsize}_{i} \quad ,\forall i=1, \ldots, I, \forall s=1, \ldots, S, \forall t=1, \ldots, T &amp;amp; \text{(2)}\\&amp;amp;\quad&#xA;\sum_{i=1}^{I} x_{i,s,t}\cdot a_{i,t} \leq  \text{cap}_{s} \quad ,\forall s=1, \ldots, S, \forall t=1, \ldots, T &amp;amp; \text{(3)}\\&amp;amp;\quad&#xA;x_{i,t,s} \in ℝ , y_{i,t} \in \{0,1\}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where, &lt;span class=&quot;math-container&quot;&gt;$c_{i,s,t}$&lt;/span&gt; is corresponding order cost, &lt;span class=&quot;math-container&quot;&gt;$\text{demand}_{i,t}$&lt;/span&gt; is demand of material &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\text{lotsize}_{i}$&lt;/span&gt; is the minimum lot/batch size that should be ordered, &lt;span class=&quot;math-container&quot;&gt;$a_{i,t}$&lt;/span&gt; is the required capacity to produce materials and &lt;span class=&quot;math-container&quot;&gt;$\text{cap}_{s}$&lt;/span&gt; is the capacity of supplier &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;. Indeed one can define a constraint &lt;span class=&quot;math-container&quot;&gt;$y_{i,t} \geq x_{i,s,t}/M$&lt;/span&gt; to set a lower bound on the variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Also, to extend the model into the standard material requirement planning (MRP), you can define some extra constraints to capture inventory level based on whose lead time.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2022-03-05T10:08:30.890" LastActivityDate="2022-03-05T10:08:30.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7999" PostTypeId="2" ParentId="7996" CreationDate="2022-03-05T14:09:03.350" Score="12" Body="&lt;p&gt;Converting previous comments into an answer:&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately this is not the case for general LPs. To see this, consider an LP with exponentially many extreme points and a constant objective function. For this problem all extreme points are optimal, and you need to enumerate exponentially many.&lt;/p&gt;&#xA;&lt;p&gt;A simple example of a feasible set with an exponential number of extreme points (as a function of the number of variables) is &lt;span class=&quot;math-container&quot;&gt;$P=\{ x\in \mathbb{R}^n : 0\leq x_i\leq 1\}$&lt;/span&gt;. The polytope &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; extreme points.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-03-05T14:09:03.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8000" PostTypeId="2" ParentId="7832" CreationDate="2022-03-05T14:29:19.360" Score="6" Body="&lt;p&gt;The Linear Programming and the Simplex Method were invented by Dantzig during &lt;strong&gt;October 1948&lt;/strong&gt; to &lt;strong&gt;June 1952&lt;/strong&gt; when he was the chief mathematician of Project SCOOP (Scientific Computation of Optimal Programs) of the U.S. Air Force [1].&lt;/p&gt;&#xA;&lt;p&gt;After searching for works by Dantzig from 1948 to 1952, [2] and [3] are probably what you want (though we can not assume they are &lt;strong&gt;the first&lt;/strong&gt; Linear Programing problems).&lt;/p&gt;&#xA;&lt;p&gt;Additionally, I found a collection of Dantzig papers [4] where there are some titles that have the keywords &amp;quot;military&amp;quot;, e.g. &amp;quot;Typical Military and Industrial Applications of Linear Programming&amp;quot;. Copies may be obtained by contacting the Stanford University.&lt;/p&gt;&#xA;&lt;p&gt;Then, [5] also provides some historical facts about the SCOOP and Dantzig.&lt;/p&gt;&#xA;&lt;p&gt;Finally, after June 1952, Dantzig left the Pentagon for RAND Corporation, so technical report by Dantzig in RAND may also be useful, e.g. [6]. See this &lt;a href=&quot;https://www.rand.org/pubs/authors/d/dantzig_george_bernard.html&quot; rel=&quot;noreferrer&quot;&gt;link&lt;/a&gt; for a full list.&lt;/p&gt;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;[1] Gass, S.I., Assad, A.A., 2011. History of Operations Research, in: Transforming Research into Action, INFORMS TutORials in Operations Research. INFORMS, pp. 1–14. &lt;a href=&quot;https://doi.org/10.1287/educ.1110.0084&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1287/educ.1110.0084&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;[2] Wood, M.K., Dantzig, G.B., 1949. Programming of Interdependent Activities: I General Discussion. Econometrica 17, 193–199. &lt;a href=&quot;https://doi.org/10.2307/1905522&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.2307/1905522&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;[3] Dantzig, G.B., 1949. Programming of Interdependent Activities: II Mathematical Model. Econometrica 17, 200–211. &lt;a href=&quot;https://doi.org/10.2307/1905523&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.2307/1905523&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;[4] Dantzig (George B.) Papers [WWW Document], n.d. URL &lt;a href=&quot;https://oac.cdlib.org/findaid/ark:/13030/c8s75gwd/&quot; rel=&quot;noreferrer&quot;&gt;https://oac.cdlib.org/findaid/ark:/13030/c8s75gwd/&lt;/a&gt; (accessed 3.5.22).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;[5] Rohde, J., 2014. How Reason Almost Lost Its Mind: The Strange Career of Cold War Rationality. Journal of American History 101, 656–657. &lt;a href=&quot;https://doi.org/10.1093/jahist/jau385&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1093/jahist/jau385&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;[6] Dantzig, G.B., 1957. Concepts, Origins, and Use of Linear Programming. RAND Corporation&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8718" LastEditorUserId="8718" LastEditDate="2022-03-05T14:35:23.340" LastActivityDate="2022-03-05T14:35:23.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8001" PostTypeId="1" CreationDate="2022-03-05T17:38:41.000" Score="7" ViewCount="356" Body="&lt;p&gt;I have a CS background, I took some optional courses in Optimization.&#xA;I stumbled upon classic transport problems like TSP and VRP.&#xA;Maybe I am not familiar with the domain, but I think that there aren't a lot of software apps built around those problems. Thus, I had the idea of building one.&#xA;However, I am struggling with some aspects.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to choose a variant to focus on. VRP with pickup and deliveries, CVRPs, etc.&#xA;I think what blocks me is that I don't know how each variant is applied in the real world, in which domains. I don't know which variants represent more opportunities and which ones are more &amp;quot;saturated&amp;quot; i.e. for which there are some sophisticated, hard-to-compete-with solutions.&lt;/li&gt;&#xA;&lt;li&gt;How to find users to talk to and how to convince them to talk to me. I don't think that building something in an ivory tower is going to succeed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="9306" LastEditorUserId="491" LastEditDate="2022-03-06T01:32:23.333" LastActivityDate="2022-03-06T17:18:12.470" Title="TSPs and VRPs in real world" Tags="|vehicle-routing|traveling-salesman|applications|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8002" PostTypeId="2" ParentId="8001" CreationDate="2022-03-05T17:52:56.500" Score="4" Body="&lt;p&gt;There is definitely vehicle routing software in use in industry. Quite a few years ago, I consulted with a doctoral student in our supply chain management program on his dissertation proposal, which involved truck routing. He had obtained access to a commercial routing program. I never learned the name of it or its source, but it was apparently used by commercial customers.&lt;/p&gt;&#xA;&lt;p&gt;Some companies with internal OR groups develop their own software, which may or may not be licensed to other companies. There's a nice write-up of the ORION project at UPS &lt;a href=&quot;https://www.informs.org/Impact/O.R.-Analytics-Success-Stories/UPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I suspect that industry members of the &lt;a href=&quot;https://connect.informs.org/tsl/home&quot; rel=&quot;nofollow noreferrer&quot;&gt;Transportation Science and Logistics Society&lt;/a&gt; at INFORMS would have a handle on what needs are already filled and what needs represent opportunities. I'm not sure how easy it would be to network with them if you are not an INFORMS member.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-05T17:52:56.500" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8003" PostTypeId="2" ParentId="7988" CreationDate="2022-03-05T21:25:00.677" Score="2" Body="&lt;p&gt;Without some differentiability/smoothness requirements for &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; beyond just quasi-convexity, I'm not sure if there are globally convergent analogs to golden section search. If you are willing to live with the possibility of convergence to a suboptimal point, there is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nelder-Mead algorithm&lt;/a&gt;, which generates a sequence of simplices in a manner similar to how golden section search generates a sequence of intervals. If you do a search on &amp;quot;Nelder-Mead&amp;quot;, you will find literature on some variants that, at least in some cases, may come with convergence guarantees when &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is sufficiently smooth.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-05T21:25:00.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8004" PostTypeId="2" ParentId="8001" CreationDate="2022-03-06T15:44:55.370" Score="5" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;How to choose a variant to focus on ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I would recommend to &lt;em&gt;not&lt;/em&gt; choose a variant. There are so many variants that you will be better off if you build something as generic as possible. For example, the excellent &lt;a href=&quot;https://developers.google.com/optimization/routing&quot; rel=&quot;noreferrer&quot;&gt;ortools routing package&lt;/a&gt; is able to handle many constraints and options. &lt;a href=&quot;https://github.com/Kuifje02/vrpy&quot; rel=&quot;noreferrer&quot;&gt;VRPy&lt;/a&gt; is developed with the same philosophy.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-03-06T15:44:55.370" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8005" PostTypeId="2" ParentId="8001" CreationDate="2022-03-06T17:18:12.470" Score="4" Body="&lt;p&gt;I agree with Paul Rubin, there are a lot of vendors in this space.&lt;/p&gt;&#xA;&lt;p&gt;Here a link to the &lt;a href=&quot;https://pubsonline.informs.org/do/10.1287/LYTX.2018.02.04/full/&quot; rel=&quot;nofollow noreferrer&quot;&gt;2018 Survey from OR/MS&lt;/a&gt;, and the &lt;a href=&quot;https://www.informs.org/ORMS-Today/OR-MS-Today-Software-Surveys/Vehicle-Routing-Software-Survey/Page-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;vendor list&lt;/a&gt;.  And, this is just Vendors who respond.  I think there are many more vendors than in this list.&lt;/p&gt;&#xA;&lt;p&gt;Also, there are a lot of companies who build their own routing solutions, like this one from &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/inte.2021.1090&quot; rel=&quot;nofollow noreferrer&quot;&gt;CH Robinson&lt;/a&gt; (full disclosure: I worked on that one), or have consulting firms build it for them.&lt;/p&gt;&#xA;&lt;p&gt;The space is definitely has lots of players. But, this doesn't mean there isn't room for one more.&lt;/p&gt;&#xA;&lt;p&gt;I would have mixed feelings on what to build. You could build an entire business focused on a small niche or even by doing custom solutions for clients.  Or, if you could pull it off, do something quite large scale.&lt;/p&gt;&#xA;" OwnerUserId="191" LastActivityDate="2022-03-06T17:18:12.470" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8006" PostTypeId="1" AcceptedAnswerId="8033" CreationDate="2022-03-06T17:27:44.623" Score="3" ViewCount="1115" Body="&lt;p&gt;I'd like to test how good/fast OR-Tools is in finding hamiltonian paths on some (big) directed graphs.&#xA;But I can't find simple enough (for me) examples.&lt;/p&gt;&#xA;&lt;p&gt;Something like these ones (or even simpler), usuable by beginners like me:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://developers.google.com/optimization/flow/maxflow&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization/flow/maxflow&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://developers.google.com/optimization/cp/cryptarithmetic&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization/cp/cryptarithmetic&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://developers.google.com/optimization/cp/queens&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization/cp/queens&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I made a very basic example to illustrate my question, could someone show me how to code it with OR-tools (a Python example would be easier for me, but I’ll probably be able to understand an example in another language):&lt;/p&gt;&#xA;&lt;p&gt;Given this directed graph:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5C0Pt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5C0Pt.png&quot; alt=&quot;simple directed graph&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I want OR-tools to give me the hamiltonian path connecting all the vertices (that is: A-&amp;gt;C-&amp;gt;B) :&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/h4xSn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h4xSn.png&quot; alt=&quot;hamiltonian path&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9310" LastEditorUserId="9310" LastEditDate="2022-03-07T10:45:04.010" LastActivityDate="2022-03-22T10:12:13.750" Title="Simple example of finding Hamiltonian path using Google OR-Tools?" Tags="|python|or-tools|graphs|hamiltonian-path|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8007" PostTypeId="2" ParentId="7966" CreationDate="2022-03-06T17:39:21.157" Score="3" Body="&lt;p&gt;Here's an approach that uses &lt;a href=&quot;https://go.documentation.sas.com/doc/en/pgmsascdc/v_023/casmopt/casmopt_networksolver_toc.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;the network solver in SAS&lt;/a&gt; (disclaimer: I work at SAS) to enumerate all elementary paths in the line graph up to a maximum length:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;data indata;&#xA;   input i j @@;&#xA;   from = compress(i||'');&#xA;   to   = compress(j||'');&#xA;   datalines;&#xA;1 2  1 4  1 8&#xA;2 6  2 8&#xA;3 3  3 8  3 9&#xA;4 3  4 4  4 6  4 7&#xA;5 9&#xA;6 5  6 10&#xA;7 1  7 5&#xA;8 3  8 10&#xA;9 1  9 7  9 10&#xA;;&#xA;&#xA;proc optmodel;&#xA;   /* read original data */&#xA;   set &amp;lt;str,str&amp;gt; LINKS_ORIG;&#xA;   read data indata into LINKS_ORIG=[from to];&#xA;   LINKS_ORIG = LINKS_ORIG union {&amp;lt;'source','1'&amp;gt;,&amp;lt;'10','sink'&amp;gt;};&#xA;&#xA;   /* construct line graph */&#xA;   set SOURCE = {'source_1'};&#xA;   set SINK   = {'10_sink'};&#xA;   set LINKS = setof {&amp;lt;i,j&amp;gt; in LINKS_ORIG, &amp;lt;(j),k&amp;gt; in LINKS_ORIG diff {&amp;lt;i,j&amp;gt;}} &amp;lt;i||'_'||j, j||'_'||k&amp;gt;;&#xA;&#xA;   /* call network solver */&#xA;   set &amp;lt;str,str,num,num,str,str&amp;gt; PATHSLINKS; /* &amp;lt;source,sink,id,order,from,to&amp;gt; */&#xA;   solve with network / path=(source=SOURCE sink=SINK maxlength=11) direction=directed links=(include=LINKS) out=(pathslinks=PATHSLINKS);&#xA;&#xA;   /* count path lengths */&#xA;   set PATHS = 1.._OROPTMODEL_NUM_['NUM_PATHS'];&#xA;   num length {PATHS} init -1;&#xA;   for {&amp;lt;s,t,p,o,from,to&amp;gt; in PATHSLINKS} length[p] = length[p] + 1;&#xA;   num len;&#xA;   set LENGTHS init {};&#xA;   num lengthCount {LENGTHS} init 0;&#xA;   for {p in PATHS} do;&#xA;      len = length[p];&#xA;      LENGTHS = LENGTHS union {len};&#xA;      lengthCount[len] = lengthCount[len] + 1;   &#xA;   end;&#xA;   num cumulativeLengthCount {l in LENGTHS} = lengthCount[l] + (if l-1 in LENGTHS then cumulativeLengthCount[l-1]);&#xA;   print lengthCount cumulativeLengthCount;&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/koq2S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/koq2S.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can also find the &lt;span class=&quot;math-container&quot;&gt;$9$&lt;/span&gt; shortest paths as in @Kuifje's answer by changing the SOLVE statement as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   solve with network / shortpath=(source=SOURCE sink=SINK maxPathsPerPair=9) direction=directed links=(include=LINKS) out=(pathslinks=PATHSLINKS);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-03-06T17:48:54.867" LastActivityDate="2022-03-06T17:48:54.867" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8008" PostTypeId="2" ParentId="8006" CreationDate="2022-03-06T18:45:16.173" Score="5" Body="&lt;p&gt;You can use OR-tools' routing library, and more specifically the &lt;a href=&quot;https://developers.google.com/optimization/routing/tsp&quot; rel=&quot;noreferrer&quot;&gt;TSP solver&lt;/a&gt;, with the Python API.&lt;/p&gt;&#xA;&lt;p&gt;Note that since you do not want the last arc in your example, you are solving an &lt;em&gt;open&lt;/em&gt; TSP. You can modify the distance matrix, as explained &lt;a href=&quot;https://developers.google.com/optimization/routing/routing_tasks#allowing-arbitrary-start-and-end-locations&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-03-06T18:45:16.173" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8009" PostTypeId="1" CreationDate="2022-03-07T01:00:28.593" Score="7" ViewCount="433" Body="&lt;p&gt;I am implementing a branch and bound algorithm for the knapsack program that is essentially identical to the one described &lt;a href=&quot;https://iq.opengenus.org/0-1-knapsack-using-branch-and-bound/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. I am trying to decide on the optimal data structure to store the set of candidate nodes.&lt;/p&gt;&#xA;&lt;p&gt;It seems there are two natural choices: Either a kind of &lt;strong&gt;tree&lt;/strong&gt; that represents the relationships between parent and child nodes, or a &lt;strong&gt;heap&lt;/strong&gt; sorted by the LP relaxation values.&lt;/p&gt;&#xA;&lt;p&gt;Suppose there are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; nodes in the candidate set (i.e. nodes that are not leaves and have not had their children explored). At each iteration, we&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Select the candidate node having the highest LP upper bound and generate child nodes by fixing &lt;span class=&quot;math-container&quot;&gt;$x_s = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_s = 1$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is the index of the &amp;quot;critical&amp;quot; item that takes a fractional value in the LP relaxation).&lt;/li&gt;&#xA;&lt;li&gt;If one of the child nodes yields a feasible, integral solution with a higher objective value than our best solution on hand, we inspect the remaining candidate nodes and &amp;quot;fathom&amp;quot; any for which the LP relaxation value is less than the new lower bound.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The heap has the advantage of reducing the time used in step 1 to &lt;span class=&quot;math-container&quot;&gt;$O(1)$&lt;/span&gt; rather than &lt;span class=&quot;math-container&quot;&gt;$O(n)$&lt;/span&gt;. But since the heap doesn't encode any information about the parent-child relationships among nodes, identifying the nodes that we can fathom in step 2 is &lt;span class=&quot;math-container&quot;&gt;$O(n)$&lt;/span&gt;, because a fathomable node could conceivably be anywhere on the heap (right?), and then actually removing these keys from the heap costs &lt;span class=&quot;math-container&quot;&gt;$O(\log n)$&lt;/span&gt; each.&lt;/p&gt;&#xA;&lt;p&gt;From this analysis, it would appear that the better choice is to choose the tree data structure. Then the search step (step 1) costs &lt;span class=&quot;math-container&quot;&gt;$O(n)$&lt;/span&gt;, but then the fathoming step (step 2) is also &lt;span class=&quot;math-container&quot;&gt;$O(n)$&lt;/span&gt; because each node is removed in unit time.&lt;/p&gt;&#xA;&lt;p&gt;However, this is not what I see in other implementations: When I run branch-and-bound solvers like SCIP, the terminal message at each iteration says &amp;quot;1234 nodes on heap.&amp;quot; This makes me think that they have somehow figured out a way to get the &lt;strong&gt;best of both worlds&lt;/strong&gt; from a heap, i.e. selecting the branch node in unit time and completing the fathoms in &lt;span class=&quot;math-container&quot;&gt;$O(n)$&lt;/span&gt; time. Is this possible? How?&lt;/p&gt;&#xA;" OwnerUserId="4463" LastEditorUserId="4463" LastEditDate="2022-03-07T01:34:55.900" LastActivityDate="2022-03-07T03:40:27.930" Title="Data structures for branch and bound: Efficiently finding the branch node vs. efficiently fathoming" Tags="|branch-and-bound|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8010" PostTypeId="2" ParentId="8009" CreationDate="2022-03-07T03:40:27.930" Score="4" Body="&lt;p&gt;One approach is to not &amp;quot;fathom&amp;quot; them at the time we replace our best candidate. Rather, as things get naturally pulled from the heap (because they are the min/max heap root), we then toss and repull if said best is unusable. This avoids the &lt;span class=&quot;math-container&quot;&gt;$O(n)$&lt;/span&gt; search.&lt;/p&gt;&#xA;&lt;p&gt;Also, for a large heap change, it is faster to remove all the nodes and then do a single &amp;quot;reheapify&amp;quot; operation at the end. Don't do the child tree re-org after each deletion.&lt;/p&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2022-03-07T03:40:27.930" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8011" PostTypeId="2" ParentId="7966" CreationDate="2022-03-07T07:40:33.137" Score="1" Body="&lt;p&gt;I am trying to use the critical path method with a bit of modification to find all of the paths on the directed graph. Also, this is my first attempt and I am pretty sure that it can be better with some of the trials and errors. Indeed, I should work on the capture of the second limitation (&lt;code&gt;a given path does not contain more than M arcs&lt;/code&gt;). What I do comes in the following comments of the original question.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Critical_path_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPM&lt;/a&gt; is the fundamental algorithm to find the completion time of the project schedule problems on many of the commercial software. I am using a simple example to make a comparison on what @Kuifje purposed.&lt;/p&gt;&#xA;&lt;p&gt;In the following network there are three paths:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/PHWqP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PHWqP.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;By calculation of the either forward and backward passes in the CPM, the following results are figured out:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;task id, task name, active&#xA;10,       A,          True&#xA;20,       B,          True&#xA;25,       C,          True&#xA;30,       D,          True&#xA;40,       E,          True&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In the above table, the numbers &lt;span class=&quot;math-container&quot;&gt;$10, 20, 25, 30, 40$&lt;/span&gt; are corresponding to the nodes &lt;span class=&quot;math-container&quot;&gt;$0, 1, 2, 3, 4$&lt;/span&gt; respectively and it means that all of the three paths are active. The achieved result by @Kuifje formulation is also equal to three.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-03-07T07:40:33.137" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8012" PostTypeId="1" CreationDate="2022-03-07T09:37:54.633" Score="2" ViewCount="111" Body="&lt;p&gt;Suppose there are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; tasks assigned to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; workers, and each worker can be assigned only one task. Each worker can complete any one of the tasks, but the time spent varies. Use the ant colony algorithm to find the best allocation scheme that minimizes the total time spent. And firstly, how to build a mathematical model to describe the problem?&lt;/p&gt;&#xA;" OwnerUserId="9314" LastEditorUserId="500" LastEditDate="2022-03-08T18:47:47.513" LastActivityDate="2022-03-08T21:30:22.623" Title="How to build a mathematical model to describe a problem related to ACO?" Tags="|optimization|metaheuristics|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8013" PostTypeId="2" ParentId="7996" CreationDate="2022-03-07T11:54:51.030" Score="2" Body="&lt;p&gt;Adding to @Sune 's answer, some LPs can also be degenerate, which means that the objective acquires its optimal value along an edge rather than a vertex, which means there are infinite solutions. In other words, the optimal value still lies at a vertex, but there are infinitely many points that yield the same value. Enumerating those points would take infinite time.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2022-03-07T13:06:18.853" LastActivityDate="2022-03-07T13:06:18.853" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8015" PostTypeId="1" AcceptedAnswerId="8016" CreationDate="2022-03-07T19:44:15.320" Score="4" ViewCount="113" Body="&lt;p&gt;We have decision variables &lt;span class=&quot;math-container&quot;&gt;$x\in\{0,1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y&amp;gt;0$&lt;/span&gt;. We know that &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$y\leq D$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; iff &lt;span class=&quot;math-container&quot;&gt;$y&amp;gt;D$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$D&amp;gt;0$&lt;/span&gt; is a model parameter.&lt;/p&gt;&#xA;&lt;p&gt;How I modeled these constraints is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;xy&amp;amp;\leq D\\&#xA;y&amp;amp;&amp;gt;D(1-x)&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But there are two problems, I think. It works well if &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt;, but when &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt;, in the first constraint we get &lt;span class=&quot;math-container&quot;&gt;$D\geq 0$&lt;/span&gt; is that ok?&lt;/p&gt;&#xA;&lt;p&gt;Also, the first constraint is nonlinear and we preferably would like to avoid linearization techniques here.&lt;/p&gt;&#xA;&lt;p&gt;How do I model this?&lt;/p&gt;&#xA;" OwnerDisplayName="user9659" LastEditorUserId="491" LastEditDate="2022-03-08T12:53:19.950" LastActivityDate="2022-03-08T12:53:19.950" Title="Modeling $x=1$ iff $y\leq D$ and $x=0$ otherwise (either-or-constraints)" Tags="|mixed-integer-programming|modeling|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8016" PostTypeId="2" ParentId="8015" CreationDate="2022-03-07T19:50:40.323" Score="7" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; be a small constant tolerance.&#xA;The following linear constraints enforce &lt;span class=&quot;math-container&quot;&gt;$x=1 \implies 0 \le y \le D$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x=0 \implies D+\epsilon \le y \le M$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0x + (D+\epsilon)(1-x) \le y \le Dx + M(1-x)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-03-07T19:50:40.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8017" PostTypeId="1" AcceptedAnswerId="8019" CreationDate="2022-03-07T20:33:27.307" Score="8" ViewCount="948" Body="&lt;p&gt;This is (hopefully) an easy answer but I haven't dealt with this before.&lt;/p&gt;&#xA;&lt;p&gt;I have a MILP which includes an unbounded, continuous decision variable.  However, I generally don't want this decision variable to take negative values, so I want to include a penalty in the objective function where there is zero penalty incurred for a positive value, but for negative values, the penalty is proportional to the absolute value.  Basically, I want a value of -100 to be penalized twice as much as -50, and 10x as much as -10.&lt;/p&gt;&#xA;&lt;p&gt;Right now I have formulated an indicator variable that is 1 if the decision variable is negative, which incurs a penalty; but this penalty is the same for any negative value.&lt;/p&gt;&#xA;&lt;p&gt;Any suggestions on how to implement this?&lt;/p&gt;&#xA;" OwnerUserId="3958" LastEditorUserId="500" LastEditDate="2022-03-07T20:42:21.030" LastActivityDate="2022-03-07T20:44:28.063" Title="MILP Penalty Function Only for Negative Values" Tags="|mixed-integer-programming|modeling|linearization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8018" PostTypeId="2" ParentId="8017" CreationDate="2022-03-07T20:40:39.670" Score="12" Body="&lt;p&gt;You do not need to introduce an indicator variable.  Suppose &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is your free variable.  Introduce nonnegative variables &lt;span class=&quot;math-container&quot;&gt;$x^+$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x^-$&lt;/span&gt;, replace &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x^+-x^-$&lt;/span&gt; throughout, and penalize &lt;span class=&quot;math-container&quot;&gt;$x^-$&lt;/span&gt; linearly in the objective.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-03-07T20:40:39.670" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8019" PostTypeId="2" ParentId="8017" CreationDate="2022-03-07T20:44:28.063" Score="15" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; denotes your free variable, you can penalize the term &lt;span class=&quot;math-container&quot;&gt;$f(x)=\max\{-x,0\}$&lt;/span&gt; in your objective function, which you can linearize by replacing it with a variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, and constraints &lt;span class=&quot;math-container&quot;&gt;$y\ge -x, y\ge 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-03-07T20:44:28.063" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8020" PostTypeId="1" AcceptedAnswerId="8021" CreationDate="2022-03-08T11:06:50.647" Score="4" ViewCount="159" Body="&lt;p&gt;I have a problem where I have a continuous decision variable (let's call it &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;) that is bounded between &lt;span class=&quot;math-container&quot;&gt;$(0, T]$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$T&amp;gt;0$&lt;/span&gt; is a predefined parameter. I also have another binary decision variable  (let's call it &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;) that I want to use to represent whether &lt;span class=&quot;math-container&quot;&gt;$m &amp;gt; Z$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$Z \in (0, T)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So in summary, if &lt;span class=&quot;math-container&quot;&gt;$m &amp;lt; Z$&lt;/span&gt;, then  &lt;span class=&quot;math-container&quot;&gt;$x = 0$&lt;/span&gt; and if &lt;span class=&quot;math-container&quot;&gt;$m\ge Z$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How can I enforce such relation in my program?&lt;/p&gt;&#xA;" OwnerUserId="8743" LastEditorUserId="491" LastEditDate="2022-03-08T12:50:09.967" LastActivityDate="2022-03-08T12:50:09.967" Title="Binary decision variable to indicate whether an inequality is satisfied or not" Tags="|optimization|mixed-integer-programming|modeling|integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8021" PostTypeId="2" ParentId="8020" CreationDate="2022-03-08T11:59:49.293" Score="5" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$m&amp;lt;Z \Rightarrow x=0$&lt;/span&gt; can be modelled as &lt;span class=&quot;math-container&quot;&gt;$m\geq Zx$&lt;/span&gt;: if &lt;span class=&quot;math-container&quot;&gt;$m&amp;lt;Z$&lt;/span&gt; there is only one feasible value for binary &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, namely &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$m\geq Z$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; can be both 0 and 1.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$m\geq Z\Rightarrow x=1$&lt;/span&gt; is the same as &lt;span class=&quot;math-container&quot;&gt;$x=0\Rightarrow m&amp;lt;Z$&lt;/span&gt;. This can be modelled (for a small &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt;) as &lt;span class=&quot;math-container&quot;&gt;$m\leq T-(T-Z+\epsilon)(1-x)$&lt;/span&gt;: If &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$m\leq Z-\epsilon$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; we have &lt;span class=&quot;math-container&quot;&gt;$m\leq T$&lt;/span&gt; which is always true.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-03-08T11:59:49.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8022" PostTypeId="1" AcceptedAnswerId="8023" CreationDate="2022-03-08T12:49:19.133" Score="6" ViewCount="261" Body="&lt;p&gt;Given a continuous nonnegative decision variable &lt;span class=&quot;math-container&quot;&gt;$x\in [0,T]$&lt;/span&gt; bounded by &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;, how can we enforce a relation between &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and another binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; such that when &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is &lt;strong&gt;equal to its upper bound&lt;/strong&gt; (&lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;), &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; must be one and otherwise &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; must zero?&lt;/p&gt;&#xA;" OwnerUserId="8743" LastEditorUserId="2556" LastEditDate="2022-03-08T13:48:49.413" LastActivityDate="2022-03-08T13:48:49.413" Title="Binary decision variable to indicate whether a continous decision variable is equal to its upper bound" Tags="|optimization|mixed-integer-programming|modeling|integer-programming|bounds|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8023" PostTypeId="2" ParentId="8022" CreationDate="2022-03-08T13:41:11.823" Score="7" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; be a small constant tolerance.&#xA;The following linear constraints enforce &lt;span class=&quot;math-container&quot;&gt;$y=0 \implies 0 \le x \le T-\epsilon$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y=1 \implies x=T$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0(1-y) + Ty \le x \le (T-\epsilon)(1-y) + Ty$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-03-08T13:41:11.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8024" PostTypeId="1" AcceptedAnswerId="8025" CreationDate="2022-03-08T17:22:07.133" Score="4" ViewCount="207" Body="&lt;p&gt;I'm trying to solve the below min-max nonlinear integer programming problem with the following objective functions:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x_i,y_i} \max_i \left\{\frac{x_i}{2+3y_i} + \frac{2x_i}{4+7y_i}\right\} \\ \text{subject to some linear and non-linear constraints}$$&lt;/span&gt;&#xA;Now, to solve this problem, I'm converting the min-max problem into a minimization problem as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x_i,y_i,z} z \\ \text{subject to } z \geq \left\{\frac{x_i}{2+3y_i} + \frac{2x_i}{4+7y_i}\right\},\forall i \\ \text{previous linear and non-linear constraints}$$&lt;/span&gt;&#xA;When I'm using a commercial solver to solve this reformulated problem, I'm getting a solution. However, I'm not sure if both these solutions are the same as this can be guaranteed for a linear or convex problem.&lt;/p&gt;&#xA;" OwnerUserId="9204" LastEditorUserId="9204" LastEditDate="2022-03-10T05:15:36.273" LastActivityDate="2022-03-10T05:15:36.273" Title="Can we reformulate a min-max nonlinear integer programming problem with the same optimal solution?" Tags="|integer-programming|nonlinear-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8025" PostTypeId="2" ParentId="8024" CreationDate="2022-03-08T17:42:08.810" Score="4" Body="&lt;p&gt;Whether or not the (continuous relaxation of the) problem is convex, these two formulations are equivalent, meaning they have the same global minimum objective value, and the same argmins (optimal variable values) which achieve that global minimum.&lt;/p&gt;&#xA;&lt;p&gt;Many optimization modeling systems and solvers automatically reformulate the 1st formulation as the 2nd formulation. The 2nd formulation uses the epigraph formulation  of &lt;code&gt;max&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It could be viewed that both of your formulations are single objective models; and to the extent there are &amp;quot;multiple&amp;quot; objective functions, they have already been crunched down to a single objective function by use of &lt;code&gt;max&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;That said, if the problems are not solved to global optimality, the &amp;quot;solutions&amp;quot; provided by the solver might differ between the formulations, because one or both of them might not be globally optimal. Even if solutions to both problems are globally optimal, the optimal objective values would be the same, but the argmins produced by the solver might differ between the problems (even changing the order of variables or constraints could cause that to happen).&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-03-08T18:17:48.843" LastActivityDate="2022-03-08T18:17:48.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8026" PostTypeId="1" AcceptedAnswerId="8028" CreationDate="2022-03-08T20:28:42.190" Score="3" ViewCount="70" Body="&lt;p&gt;I am building a web-based tool that needs to take input from the user and run an optimization model on a server and display results back on the webpage. Currently it is a MIP formulation solved using commercial solver and takes about a minute to run on average. (Some runs take upwards of 10 minutes to even find a solution)&lt;/p&gt;&#xA;&lt;p&gt;The problem is that customers have set acceptance criteria at 3 secs; from the time button is clicked to running optimization model on the server to rendering the outputs.&lt;/p&gt;&#xA;&lt;p&gt;I am trying to find out if there are any studies out there that analyzed how long users would be willing to wait before getting annoyed. Some factors to consider:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;End users are internal customers who will use that tool once a month to plan for resources.&lt;/li&gt;&#xA;&lt;li&gt;Users are expected to run about 5-10 experiments before finalizing their plans&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I can implement some solutions to decrease running time but before doing that, I want to determine in a scientific way what running time to target for this kind of application.&lt;/p&gt;&#xA;" OwnerUserId="8882" LastEditorUserId="36" LastEditDate="2022-03-08T22:30:38.470" LastActivityDate="2022-03-09T00:32:33.177" Title="studies to determine how much customers can wait to get outputs from a real time optimization model" Tags="|optimization|mixed-integer-programming|reference-request|heuristics|runtime|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8027" PostTypeId="2" ParentId="8012" CreationDate="2022-03-08T21:10:11.093" Score="2" Body="&lt;p&gt;If you really have to do it, perhaps for understanding the mechanics of ACO, here is a possibility.&lt;/p&gt;&#xA;&lt;p&gt;First, lets write a mathematical model for the problem. Let &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if worker &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; denote the time it takes for worker &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to complete task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. You want to minimize total time:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \; \sum_{i,j} c_{ij} x_{ij}&#xA;$$&lt;/span&gt;&#xA;subject to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;one task per worker:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j} x_{ij}=1 \quad \forall i&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;one worker per task:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i} x_{ij}=1 \quad \forall j&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;It is useful to have this model because the underlying structure is a bipartite graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,A)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$V=U_1 \cup U_2$&lt;/span&gt; is the node set with &lt;span class=&quot;math-container&quot;&gt;$U_1$&lt;/span&gt; for the workers and &lt;span class=&quot;math-container&quot;&gt;$U_2$&lt;/span&gt; for the tasks.&lt;/p&gt;&#xA;&lt;p&gt;With such a structure, you could, for example (and there are many other ways to do this), put ants on each of the vertices &lt;span class=&quot;math-container&quot;&gt;$u\in U_1$&lt;/span&gt;, and define an ant move along an edge &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt; towards a node &lt;span class=&quot;math-container&quot;&gt;$v\in U_2$&lt;/span&gt;. An ant on node &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; always moves along the first node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; that is available, such that &lt;span class=&quot;math-container&quot;&gt;$c_{uv}$&lt;/span&gt; is minimal. This defines a feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;The way an ant &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is chosen to make this move depends on two factors:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the attractiveness of node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, denoted by &lt;span class=&quot;math-container&quot;&gt;$A(i)$&lt;/span&gt;. This could be, for example, &lt;span class=&quot;math-container&quot;&gt;$A(i)=C-\min_{j\in \hat{U}_2}c_{ij}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is the highest &lt;span class=&quot;math-container&quot;&gt;$c_{uv}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\hat{U}_2$&lt;/span&gt; the set of available tasks. So a node is attractive if it is linked to another unassigned node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; with a small &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;the trail level of the node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, denoted by &lt;span class=&quot;math-container&quot;&gt;$T(i)=t(i,j)$&lt;/span&gt;, which is an indication of how proficient it has been in the past to assign node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The next ant &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; that is selected to make its move is made according to the ACO probability:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p(i) = \frac{A(i)^{\alpha}T(i)^{\beta}}{\sum_{v\in W }A(v)T(v)}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; are two parameters which give more or less importance to the attractiveness and trail level, and &lt;span class=&quot;math-container&quot;&gt;$W \subseteq U_1$&lt;/span&gt; is the set nodes that have not been processed yet.&lt;/p&gt;&#xA;&lt;p&gt;Initially, terms &lt;span class=&quot;math-container&quot;&gt;$t(i,j)$&lt;/span&gt; all have value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. At each iteration, the objective function is computed, let &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; be its value. Terms &lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt; are increased by a &lt;span class=&quot;math-container&quot;&gt;$1/z$&lt;/span&gt;, and regularly decrease with the help of &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt;, the pheromone evaporation coefficient.&lt;/p&gt;&#xA;&lt;p&gt;In essence, with this scheme, you have a randomized greedy algorithm. Greedy because given a worker &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, you assign it to task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; with lowest &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is available. Randomized because the order in which workers are processed is randomized according to the classical mechanics of ACO. There are many other options. And again, this is purely for understanding purposes, as efficient optimal algorithms exist, as mentioned in the comments.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-03-08T21:30:22.623" LastActivityDate="2022-03-08T21:30:22.623" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8028" PostTypeId="2" ParentId="8026" CreationDate="2022-03-09T00:32:33.177" Score="4" Body="&lt;p&gt;There's a classic story (which I think is legitimate) about an office building in New York City where tenants complained about how long it took to get an elevator. After determining that adding elevators was out of the question and installing warp drives on them was, um, impractical, someone got the idea of installing mirrors in the lobbies. Sure enough, complaints went down.&lt;/p&gt;&#xA;&lt;p&gt;While looking for that story online, I found a &lt;a href=&quot;https://barryborsboom.wordpress.com/2008/11/23/the-psychology-of-waiting/&quot; rel=&quot;nofollow noreferrer&quot;&gt;blog post&lt;/a&gt; you mind find useful. A couple of key points would be creating reasonable expectations and then meeting or exceeding them (so, be conservative on any quoted solution times), and keeping the users occupied (or amused, or at least informed).&lt;/p&gt;&#xA;&lt;p&gt;One possibility that comes to mind would be to provide the user every so often with information on the objective value of the current incumbent solution and maybe the optimality gap (along with a little boilerplate explaining in simple terms what the gap represents), and optionally providing the user with a button to cut the solution short and accept the incumbent as &amp;quot;good enough&amp;quot; (assuming they have the authority to do that).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-09T00:32:33.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8029" PostTypeId="2" ParentId="5948" CreationDate="2022-03-09T05:05:07.923" Score="2" Body="&lt;pre&gt;&lt;code&gt;x = m.addVars(A, B, vtype=GRB.BINARY, name=&amp;quot;x&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then &lt;code&gt;x&lt;/code&gt; becomes a dict whose key is a tuple &lt;code&gt;(a,b)&lt;/code&gt;, and the value is a Var.&lt;/p&gt;&#xA;&lt;p&gt;To add a set of constraints&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.addConstrs(x[a,b]+y[a,b]&amp;lt;=c[a,b] for a in A for b in B)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2022-03-09T05:05:07.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8030" PostTypeId="2" ParentId="7970" CreationDate="2022-03-09T05:38:46.113" Score="2" Body="&lt;p&gt;The problem could be written as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rll}&#xA;  \mbox{minimize} &amp;amp;u\\&#xA;  \mbox{subject to} &amp;amp; u \geq \sum_{j\in J}f_i(x_{(j)}) &amp;amp;i\in I&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;which is much more similar to the consensus form. Introducing &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, we got&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rll}&#xA;  \mbox{minimize} &amp;amp;u\\&#xA;  \mbox{subject to} &amp;amp; u_i \geq \sum_{j\in J}f_i(x_{i(j)}) &amp;amp;i\in I\\&#xA;  &amp;amp;u_i=u &amp;amp;i\in I\\&#xA;  &amp;amp;x_i=x &amp;amp;i\in I&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;Then we are ready to use ADMM. The argumented Lagrange is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;L(x,x_i,u,u_i,y_i,v_i)=u+\sum_i\left[v_i(u_i-u)+\rho/2(u-u_i)^2+y_i^T(x_i-x)+\rho/2\|x-x_i\|_2^2+\mathbb{I}\left(u_i\geq \sum_{j\in J}f_i(x_{i(j)})\right)\right]&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The ADMM algorithm is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;u_i^{k+1},x_i^{k+1}&amp;amp;= \arg\min\{v^k_i(u_i-u^k)+\rho/2(u^k-u_i)^2+y_i^{kT}(x_i-x^k)+\rho/2\|x^k-x_i\|_2^2,\;\mathrm{s.t.}\; u_i\geq \sum_{j\in J}f_i(x_{i(j)})\}\\&#xA;u_{k+1}&amp;amp;=\frac{\sum_i(\rho u_i^{k+1}+v_i^k)-1}{N\rho}\\&#xA;x_{k+1}&amp;amp;=\frac 1 N \sum_i(x_i^{k+1}+(1/\rho)y_i^k)\\&#xA;v_i^{k+1}&amp;amp;=v_i^k+\rho(u_i^{k+1}-u^{k+1})\\&#xA;y_i^{k+1}&amp;amp;=y_i^k+\rho(x_i^{k+1}-x^{k+1})&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2022-03-09T05:38:46.113" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8031" PostTypeId="2" ParentId="7996" CreationDate="2022-03-09T07:28:59.517" Score="4" Body="&lt;p&gt;The feasible set of an LP problem is geometrically a polyhedron. Knowing the optimal value, say &lt;span class=&quot;math-container&quot;&gt;$z^* = c^T x^*$&lt;/span&gt;, over points in the feasible set, &lt;span class=&quot;math-container&quot;&gt;$x \in P$&lt;/span&gt;, thus provides you with a polyhedral description of its optimal face, &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt;, obtained simply by adding &lt;span class=&quot;math-container&quot;&gt;$c^T x = z^*$&lt;/span&gt; to the constraint set. This means that you can use the answers in &lt;a href=&quot;https://or.stackexchange.com/q/4540/&quot;&gt;How to find all vertices of a polyhedron&lt;/a&gt;, for instance &lt;a href=&quot;https://polymake.org/doku.php/user_guide/tutorials/optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;polymake&lt;/a&gt;, to enumerate all vertices of &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt;, thereby finding all optimal extreme point solutions of the LP problem. Nevertheless, as the number of vertices of a polyhedron (including &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt;) can be exponential in the dimension, see the answer by &lt;a href=&quot;https://or.stackexchange.com/a/7999&quot;&gt;@Sune&lt;/a&gt;, no polynomial time algorithm can exist.&lt;/p&gt;&#xA;" OwnerUserId="198" LastActivityDate="2022-03-09T07:28:59.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8032" PostTypeId="2" ParentId="5256" CreationDate="2022-03-09T13:52:04.030" Score="0" Body="&lt;p&gt;OR-Tools (and most other libraries) can't split up a node for you. If you want to enable split-deliveries, you need to split up the node yourself. For example if your node has a demand of 10, you introduce two duplicate nodes with demand 5.&lt;/p&gt;&#xA;&lt;p&gt;If you want to the solver to be able to choose between split delivery and full delivery, you can introduce both nodes (so 3) and set a constraint that either the full node is active or the split node is active.&lt;/p&gt;&#xA;" OwnerUserId="3124" LastActivityDate="2022-03-09T13:52:04.030" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8033" PostTypeId="2" ParentId="8006" CreationDate="2022-03-09T14:35:45.180" Score="2" Body="&lt;p&gt;After reading some examples, I thought that I could use the AddAllowedAssignments constraint. I found some examples, and came up with a solution to my question, so here it is (I just renamed the nodes 0,1,2 instead of A,B,C).&lt;/p&gt;&#xA;&lt;p&gt;Adapting it to the ~40 nodes graph I mentionned in a comment, this also (instantly) gave me the exact hamiltonian path I expected for that graph.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Goal : To find a hamiltonian path in a directed graph&#xA;# The vertices are 0, 1 and 2&#xA;# The intented (and unique) solution is 0 -&amp;gt; 2 -&amp;gt; 1&#xA;&#xA;from ortools.sat.python import cp_model&#xA;&#xA;number_of_vertices = 3&#xA;allowed_edges = [&#xA;    (0,1),&#xA;    (0,2),&#xA;    (2,1),&#xA;]&#xA;&#xA;model = cp_model.CpModel()&#xA;&#xA;node_sequence = [model.NewIntVar(0, number_of_vertices - 1, &amp;quot;node_%i&amp;quot; % i) for i in range(number_of_vertices)]&#xA;&#xA;model.AddAllDifferent(node_sequence)&#xA;&#xA;for i, v in enumerate(node_sequence[:-1]):&#xA;    model.AddAllowedAssignments((node_sequence[i], node_sequence[i + 1]), allowed_edges)&#xA;&#xA;solver = cp_model.CpSolver()&#xA;&#xA;printer = cp_model.VarArraySolutionPrinter(node_sequence)&#xA;&#xA;status = solver.SearchForAllSolutions(model, printer)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'll try with bigger graphs to see when it blows up.&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&#xA;As my answer is what I was looking for when I asked my question, and as there's nothing new on this post, I accept my own answer !&lt;/p&gt;&#xA;" OwnerUserId="9310" LastEditorUserId="9310" LastEditDate="2022-03-22T10:12:13.750" LastActivityDate="2022-03-22T10:12:13.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8034" PostTypeId="1" AcceptedAnswerId="8035" CreationDate="2022-03-09T14:55:25.247" Score="5" ViewCount="285" Body="&lt;p&gt;I would like to choose a set of &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt;s that maximizes a simple linear objective function of the type&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\underset{\beta_j}{\operatorname{max}}\sum_{j=1}^{J}X_j\beta_j \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to the following constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j=1}^{J}C_j(\beta_j)\beta_j \le M \\&#xA;\beta_j \in \Omega \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$X_j$&lt;/span&gt; ranks the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;s using a metric, &lt;span class=&quot;math-container&quot;&gt;$C_j(\beta_j)$&lt;/span&gt; can be thought as a marginal cost function that changes with the chosen &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt; can only be from a set of pre-selected set of integers &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is some budget constraint.&lt;/p&gt;&#xA;&lt;p&gt;In addition to this, I have a hard requirement that the assigned &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt; has to be higher for a &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; with higher &lt;span class=&quot;math-container&quot;&gt;$X_j$&lt;/span&gt; -&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\beta_j &amp;gt; \beta_k \quad \text{when} \quad X_j&amp;gt;X_k&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;what would be an elegant way of implementing this?&lt;/p&gt;&#xA;" OwnerUserId="3852" LastEditorUserId="491" LastEditDate="2022-03-10T02:47:44.053" LastActivityDate="2022-03-10T02:47:44.053" Title="Writing a specific MILP problem" Tags="|optimization|linear-programming|integer-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8035" PostTypeId="2" ParentId="8034" CreationDate="2022-03-09T15:20:20.217" Score="6" Body="&lt;p&gt;A simple approach is to introduce a small constant tolerance &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt; and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\beta_j \ge \beta_k + \epsilon \quad \text{for all $j,k$ such that $X_j &amp;gt; X_k$}.$$&lt;/span&gt;&#xA;Because &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta_k$&lt;/span&gt; are integers, you can take &lt;span class=&quot;math-container&quot;&gt;$\epsilon=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An alternative approach that avoids &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is to impose conflict constraints based on the binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{i,j}$&lt;/span&gt; introduced in the linked answer:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_{i,j}+z_{\ell,k} \le 1 \quad \text{for all $i,j,k,\ell$ such that $X_j &amp;gt; X_k$ and $\omega_i \le \omega_\ell$}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-03-09T15:46:59.360" LastActivityDate="2022-03-09T15:46:59.360" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8036" PostTypeId="2" ParentId="7959" CreationDate="2022-03-09T16:21:31.087" Score="4" Body="&lt;p&gt;Here is an expanded model for the two-stage version of the problem (cutting &amp;quot;bars&amp;quot; into &amp;quot;lengths&amp;quot; and then cutting &amp;quot;lengths&amp;quot; into final product). I'm going to change the terminology slightly. I will use “stock” to refer to the long bars, “parts” to refer to segments cut from the long bars, and “product” to refer to the products cut from the parts. &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; will be the index sets for different kinds of stock, part and product respectively. &lt;span class=&quot;math-container&quot;&gt;$S_{i}&amp;gt;0$&lt;/span&gt; will be the supply of stock &lt;span class=&quot;math-container&quot;&gt;$i\in I.$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$D_{k}&amp;gt;0$&lt;/span&gt; will be the demand for product &lt;span class=&quot;math-container&quot;&gt;$k\in K.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P_{i}$&lt;/span&gt; will be the set of known patterns for cutting stock type &lt;span class=&quot;math-container&quot;&gt;$i\in I,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q_{j}$&lt;/span&gt; will be the set of known patters for cutting part type &lt;span class=&quot;math-container&quot;&gt;$j\in J.$&lt;/span&gt; For each &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p\in P_{i},$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$A_{pj}\ge 0$&lt;/span&gt; will be the number of parts of type &lt;span class=&quot;math-container&quot;&gt;$j\in J$&lt;/span&gt; produced by cutting one unit of type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; stock using pattern &lt;span class=&quot;math-container&quot;&gt;$p.$&lt;/span&gt; For each &lt;span class=&quot;math-container&quot;&gt;$j\in J$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q\in Q_{j},$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$B_{qk}\ge 0$&lt;/span&gt; will be the number of units of product &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt; produced by cutting one type &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; part using pattern &lt;span class=&quot;math-container&quot;&gt;$q.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For each combination of a stock type &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; and pattern &lt;span class=&quot;math-container&quot;&gt;$p\in P_{i}$&lt;/span&gt; we have an integer variable &lt;span class=&quot;math-container&quot;&gt;$x_{p}\ge 0$&lt;/span&gt; counting the number of units of that stock cut with that pattern. Similarly, for each part type &lt;span class=&quot;math-container&quot;&gt;$j\in J$&lt;/span&gt; and pattern &lt;span class=&quot;math-container&quot;&gt;$q\in Q_{j}$&lt;/span&gt; we have an integer variable &lt;span class=&quot;math-container&quot;&gt;$y_{q} \ge 0$&lt;/span&gt; counting the number of parts of that type cut with that pattern. The objective function is&lt;span class=&quot;math-container&quot;&gt;$$\min_{x,y}\sum_{i\in I}\sum_{p\in P_{i}}c_{i}x_{p}$$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$c_{i}$&lt;/span&gt; is the unit cost of a type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; piece of stock. The constraints are as follows.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The number of pieces of stock you cut is limited to the available supply.&lt;span class=&quot;math-container&quot;&gt;$$\sum_{p\in P_{i}}x_{p}\le S_{i}\quad\forall i\in I.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The number of parts cut is limited by the available supply.&lt;span class=&quot;math-container&quot;&gt;$$\sum_{q\in Q_{j}}y_{q}\le\sum_{i\in I}\sum_{p\in P_{i}}A_{pj}x_{p}\quad\forall j\in J.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The amount of product produced must satisfy demand.&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j\in J}\sum_{q\in Q_{j}}B_{qk}y_{q}\ge D_{k}\quad\forall k\in K.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you begin with on-hand inventory of intermediate parts, you can add the on-hand inventory to the right side of the second set of constraints.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-09T16:21:31.087" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8037" PostTypeId="1" CreationDate="2022-03-10T09:26:33.530" Score="5" ViewCount="141" Body="&lt;p&gt;The ellipsoid method is often mentioned in relation to the complexity of solving linear programs.&#xA;Is the method however polynomial in the general non-linear convex cases? Preferably I would like a reference to a work stating the complexity of the method in such cases.&lt;/p&gt;&#xA;&lt;p&gt;Note: I had a look at &lt;a href=&quot;https://or.stackexchange.com/questions/1423/why-is-the-ellipsoid-method-of-polynomial-complexity&quot;&gt;this&lt;/a&gt; question, but could not find what I am looking for.&lt;/p&gt;&#xA;" OwnerUserId="9151" LastEditorUserId="491" LastEditDate="2022-03-10T13:44:56.507" LastActivityDate="2023-12-26T16:04:15.490" Title="Complexity of the ellipsoid method in general convex problems" Tags="|reference-request|convex-optimization|computational-complexity|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8038" PostTypeId="2" ParentId="6349" CreationDate="2022-03-10T15:11:53.707" Score="1" Body="&lt;p&gt;For NP-completeness aspects from an OR point of view, I would recommend:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;quot;Computers and intractability&amp;quot; (Garey and Johnson, 1979)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-03-10T15:11:53.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8040" PostTypeId="1" CreationDate="2022-03-10T16:55:09.040" Score="2" ViewCount="113" Body="&lt;p&gt;This follows from a previous post of &lt;a href=&quot;https://or.stackexchange.com/questions/7875/will-all-constraints-in-this-lp-be-binding/7952#7952&quot;&gt;mine&lt;/a&gt; (see &lt;a href=&quot;https://or.stackexchange.com/questions/7850/will-constraints-in-this-lp-be-satisfied-as-equalities/7855#7855&quot;&gt;also&lt;/a&gt;). In that post I &lt;em&gt;assumed&lt;/em&gt; that there existed no pair of rows (denoted &lt;span class=&quot;math-container&quot;&gt;$\mathbf x^i$&lt;/span&gt;) such that &lt;span class=&quot;math-container&quot;&gt;$\mathbf x^{i'}\geq\mathbf x^i$&lt;/span&gt;. I believe that I can eliminate the assumption and make it a result as follows.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X'}=\left(x_{ij}\right) $&lt;/span&gt; be an &lt;span class=&quot;math-container&quot;&gt;$ n'\times 2 $&lt;/span&gt; matrix with &lt;span class=&quot;math-container&quot;&gt;$ x_{ij}\geq 0 $&lt;/span&gt; and such that there is every row and column has at least a non zero element. Denote &lt;span class=&quot;math-container&quot;&gt;$\mathbf x^i$&lt;/span&gt; the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th row of &lt;span class=&quot;math-container&quot;&gt;$\mathbf X'$&lt;/span&gt; and assume that rows are ordered so that &lt;span class=&quot;math-container&quot;&gt;$x_{i,1}&amp;gt;x_{i',1}\implies i&amp;gt;i'$&lt;/span&gt; (if &lt;span class=&quot;math-container&quot;&gt;$x_{i,1}=x_{i',1}$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_{i,2}&amp;gt;x_{i',2}\implies i&amp;gt;i'$&lt;/span&gt;). Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf q, \mathbf 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf 0$&lt;/span&gt; be column vectors of the appropriate dimension and &lt;span class=&quot;math-container&quot;&gt;$\mathbf k^e$&lt;/span&gt; a non negative column vector of dimension 2. Consider the problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;   \renewcommand{\arraystretch}{1.3}&#xA;   \begin{array}{ll}&#xA;      \text{maximize} &amp;amp;\quad \mathbf{q}^\top\cdot\mathbf{1}\\&#xA;      \text{subject to} &amp;amp; \quad \mathbf{X'}^{\top}\mathbf{q}\leq\mathbf{k}^e\\ &amp;amp;\quad\mathbf{q}\geq \mathbf 0,&#xA;   \end{array}&#xA;\end{equation}&lt;/span&gt;&#xA;and let &lt;span class=&quot;math-container&quot;&gt;$\mathbf q^*$&lt;/span&gt; be its solution. We claim that there can exist some &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^i$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$q_i^*=0\;\forall\,\mathbf{k}^e$&lt;/span&gt;. In particular, this will be the case for &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^{i^*}$&lt;/span&gt; if (a) there exists a set of weights  &lt;span class=&quot;math-container&quot;&gt;$0\leq \alpha_i\leq1$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\ne i^*} \alpha_i=1$&lt;/span&gt;) such that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\bar x}=\sum_{i\ne i^*}\alpha_i \mathbf x^{i}=\mathbf{x}^{i^*}/\delta$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\delta\geq 1$&lt;/span&gt;, (b) &lt;span class=&quot;math-container&quot;&gt;$\mathbf x^2\geq\mathbf x^1$&lt;/span&gt; or (c) &lt;span class=&quot;math-container&quot;&gt;$\mathbf x^{n'}\geq\mathbf x^{n'-1}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To prove it, assume that &lt;span class=&quot;math-container&quot;&gt;$q^*_{i^*}&amp;gt;0$&lt;/span&gt; and, for part (a) consider &lt;span class=&quot;math-container&quot;&gt;$\hat q_{i^*}=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\hat q_{i}=q_{i}^*+\alpha_i\delta q_{i^*}^*,\; \forall\, i\ne i^*$&lt;/span&gt;. For part (b) consider &lt;span class=&quot;math-container&quot;&gt;$\hat q_{2}=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\hat q_{1}=q_{1}^*+\delta q_{2}^*$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\delta=x_{2,1}/x_{1,1}\geq 1$&lt;/span&gt;. Similarly, for part (c) &lt;span class=&quot;math-container&quot;&gt;$\hat q_{n'}=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\hat q_{n'-1}=q_{n'}^*+\delta q_{n'}^*$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\delta=x_{n'-1,2}/x_{n',2}\geq 1$&lt;/span&gt;. Observe that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{\hat q}$&lt;/span&gt; is feasible by construction and that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n \hat q_i=(\delta-1)q_{i^*}^*+\sum_{i=1}^n q_i^*.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As the term &lt;span class=&quot;math-container&quot;&gt;$(\delta-1)q_{i^*}^*\geq 0$&lt;/span&gt;, eliminating the rows for which a solution with &lt;span class=&quot;math-container&quot;&gt;$q_i=0\,\forall\,\mathbf{k}^e$&lt;/span&gt; exists is immaterial. Reorder the rows of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt; so that such rows take indices &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n'$&lt;/span&gt; and consider matrix &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}=(x_{ij})_{1\leq i\leq n,1\leq j\leq 2}$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q}^*$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$n\times 1$&lt;/span&gt; vector that solves the following problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;   \renewcommand{\arraystretch}{1.3}&#xA;   \begin{array}{ll}&#xA;      \text{maximize} &amp;amp;\quad \mathbf{q}^\top\cdot\mathbf{1}\\&#xA;      \text{subject to} &amp;amp; \quad \mathbf{X}^{\top}\mathbf{q}\leq\mathbf{k}^e\\ &amp;amp;\quad\mathbf{q}\geq \mathbf 0,&#xA;   \end{array}&#xA;\end{equation}&lt;/span&gt;&#xA;then, appending &lt;span class=&quot;math-container&quot;&gt;$n'-n$&lt;/span&gt; zeroes to it would solve the first.&lt;/p&gt;&#xA;&lt;p&gt;I believe that this shows that the two problems are equivalent, in the sense that solving one or the other yields the same result (except for the need of adding or eliminating &lt;span class=&quot;math-container&quot;&gt;$n'-n$&lt;/span&gt; zeroes). I'd like to know whether my proof is correct.&lt;/p&gt;&#xA;" OwnerUserId="2391" LastEditorUserId="2391" LastEditDate="2022-03-11T18:36:38.840" LastActivityDate="2022-03-11T18:36:38.840" Title="Are these LP equivalent?" Tags="|linear-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8041" PostTypeId="1" CreationDate="2022-03-10T18:23:23.160" Score="1" ViewCount="704" Body="&lt;p&gt;I'm solving a large network flow problem using Gurobi to do Benders decomposition in Python. The imported .csvs contain values that typically fall in either zero, the range of [20,200], or with a magnitude of approximately 10^9. I received a warning that the matrix coefficients and RHS were too large, so I scaled down all values that represented quantities by 10^9 and others by 10^3. This solved my coefficient error but not my right-hand side error. Please note that due to some other errors, my model is not completing all its iterations. Here's my log before scaling:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Gurobi Optimizer version 9.5.1 build v9.5.1rc2 (win64)&#xA;Thread count: 4 physical cores, 8 logical processors, using up to 8 threads&#xA;Optimize a model with 1116052 rows, 575004 columns and 1984260 nonzeros&#xA;Model fingerprint: 0x223d0add&#xA;Variable types: 355740 continuous, 219264 integer (1024 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [8e-02, 2e+10]&#xA;  Objective range  [2e-13, 2e-06]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [1e-01, 2e+10]&#xA;Warning: Model contains large matrix coefficients&#xA;Warning: Model contains large rhs&#xA;         Consider reformulating model or setting NumericFocus parameter&#xA;         to avoid numerical issues.&#xA;Found heuristic solution: objective 143424.26885&#xA;Presolve removed 1116022 rows and 574935 columns&#xA;Presolve time: 1.34s&#xA;Presolved: 30 rows, 69 columns, 120 nonzeros&#xA;Found heuristic solution: objective 135423.71070&#xA;Variable types: 57 continuous, 12 integer (0 binary)&#xA;&#xA;Explored 0 nodes (0 simplex iterations) in 1.75 seconds (1.28 work units)&#xA;Thread count was 8 (of 8 available processors)&#xA;&#xA;Solution count 2: 135424 143424 &#xA;&#xA;Optimal solution found (tolerance 1.00e-04)&#xA;Best objective 1.354237107007e+05, best bound 1.354237107007e+05, gap 0.0000%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here's my log after scaling:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Set parameter Username&#xA;Academic license - for non-commercial use only - expires 2022-04-25&#xA;Gurobi Optimizer version 9.5.1 build v9.5.1rc2 (win64)&#xA;Thread count: 4 physical cores, 8 logical processors, using up to 8 threads&#xA;Optimize a model with 1116052 rows, 575004 columns and 1983740 nonzeros&#xA;Model fingerprint: 0x7eba86b8&#xA;Variable types: 355740 continuous, 219264 integer (1024 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [1e-02, 2e+01]&#xA;  Objective range  [2e-13, 2e-06]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [3e-07, 2e+09]&#xA;Warning: Model contains large rhs&#xA;         Consider reformulating model or setting NumericFocus parameter&#xA;         to avoid numerical issues.&#xA;Found heuristic solution: objective 0.0001434&#xA;Presolve removed 1116052 rows and 575004 columns&#xA;Presolve time: 1.09s&#xA;Presolve: All rows and columns removed&#xA;&#xA;Explored 0 nodes (0 simplex iterations) in 1.54 seconds (1.04 work units)&#xA;Thread count was 1 (of 8 available processors)&#xA;&#xA;Solution count 2: 0.000143426 0.000143426 &#xA;&#xA;Optimal solution found (tolerance 1.00e-04)&#xA;Best objective 1.434261369143e-04, best bound 1.434261369143e-04, gap 0.0000%et parameter Username&#xA;Academic license - for non-commercial use only - expires 2022-04-25&#xA;Gurobi Optimizer version 9.5.1 build v9.5.1rc2 (win64)&#xA;Thread count: 4 physical cores, 8 logical processors, using up to 8 threads&#xA;Optimize a model with 1116052 rows, 575004 columns and 1983740 nonzeros&#xA;Model fingerprint: 0x7eba86b8&#xA;Variable types: 355740 continuous, 219264 integer (1024 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [1e-02, 2e+01]&#xA;  Objective range  [2e-13, 2e-06]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [3e-07, 2e+09]&#xA;Warning: Model contains large rhs&#xA;         Consider reformulating model or setting NumericFocus parameter&#xA;         to avoid numerical issues.&#xA;Found heuristic solution: objective 0.0001434&#xA;Presolve removed 1116052 rows and 575004 columns&#xA;Presolve time: 1.09s&#xA;Presolve: All rows and columns removed&#xA;&#xA;Explored 0 nodes (0 simplex iterations) in 1.54 seconds (1.04 work units)&#xA;Thread count was 1 (of 8 available processors)&#xA;&#xA;Solution count 2: 0.000143426 0.000143426 &#xA;&#xA;Optimal solution found (tolerance 1.00e-04)&#xA;Best objective 1.434261369143e-04, best bound 1.434261369143e-04, gap 0.0000%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9334" LastActivityDate="2022-03-10T18:23:23.160" Title="How to eliminate large matrix coefficients and large RHS warning in Gurobi" Tags="|python|gurobi|network-flow|benders-decomposition|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8042" PostTypeId="1" CreationDate="2022-03-10T19:42:33.333" Score="2" ViewCount="309" Body="&lt;p&gt;I want to solve a problem of the form &lt;span class=&quot;math-container&quot;&gt;$\min_x\max_y f(x,y)$&lt;/span&gt; using Gurobi, where &lt;span class=&quot;math-container&quot;&gt;$x,y\in [0,1]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is there a simple way to model this in Gurobi? I've seen examples where the domain of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is finite, but in my case it can take any value in &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9335" LastEditorUserId="123" LastEditDate="2022-03-11T16:39:19.033" LastActivityDate="2022-03-11T16:39:19.033" Title="Solving minimax problems with Gurobi" Tags="|gurobi|nonlinear-programming|minimax|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8043" PostTypeId="2" ParentId="7818" CreationDate="2022-03-10T21:33:25.350" Score="1" Body="&lt;p&gt;A fundamental difference between the riddle and either Monge's problem and the more common (in my experience) Hitchcock transportation problem is that the riddle is inherently a multiperiod problem (where we can think of a time period as the duration of one trip across the river). So you would need to extend either of those models by adding a time dimension and inventory variables for the number (0 or 1) of wolves, goats and cabbages on each side of the river.&lt;/p&gt;&#xA;&lt;p&gt;A second fundamental difference is that flows are inherently discrete. If you attempt to formulate the problem as a multiperiod Hitchcock problem using exclusively continuous variables (so as to be a linear program), you will end up with fractional solutions where the farmer, for instance, leaves half a goat and half a head of cabbage untended at one point. (Arguably this might be okay, since the goat would presumably be dead and thus incapable of eating the cabbage.)&lt;/p&gt;&#xA;&lt;p&gt;It is possible to formulate this as a multiperiod integer linear program, although that seems overkill for the original riddle.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-10T21:33:25.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8044" PostTypeId="1" AcceptedAnswerId="8045" CreationDate="2022-03-11T21:43:28.293" Score="3" ViewCount="377" Body="&lt;p&gt;I'm building a production scheduling optimization model (but not exactly a jobshop, so I can't just use OR tools).  I have decision variables for both the start time of each job, and the duration.  For each pair of jobs, there is a changeover time that is unique for the permutation.  So for example, changeover from Job A to Job B may be 2 hours, but from Job B to Job A may be 3 hours.  I want to add constraints to ensure this changeover.  In a nonlinear way, I would describe it as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mbox{Start}_A + \mbox{Duration}_A + \mbox{Changeover}_{AB} \le \mbox{Start}_B  \quad \mbox{if } \mbox{Start}_A \le \mbox{Start}_B \\&#xA;\mbox{Start}_B + \mbox{Duration}_B + \mbox{Changeover}_{BA} \le \mbox{Start}_A  \quad \mbox{if } \mbox{Start}_B \le \mbox{Start}_A&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\mbox{Start}_A$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mbox{Start}_B$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mbox{Duration}_A$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mbox{Duration}_B$&lt;/span&gt; all continuous variables &lt;span class=&quot;math-container&quot;&gt;$\ge 0$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$\mbox{Changeover}_{AB}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mbox{Changeover}_{BA}$&lt;/span&gt; are scalars.&lt;/p&gt;&#xA;&lt;p&gt;How do I formulate these as constraints?  I can either produce Job_A or Job_B first, there's no requirement of order.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastEditorUserId="981" LastEditDate="2023-12-22T15:06:53.107" LastActivityDate="2023-12-22T15:06:53.107" Title="Enforce Changeover Constraints in Production Scheduling" Tags="|mixed-integer-programming|or-tools|cp-sat|production-planning|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8045" PostTypeId="2" ParentId="8044" CreationDate="2022-03-11T21:52:40.803" Score="6" Body="&lt;p&gt;If you let &lt;span class=&quot;math-container&quot;&gt;$x_{ij} $&lt;/span&gt; be a binary variable equalling 1 iff job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; comes just before job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and continuous variables &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; be the start time of job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, then you may model your constraints using MTZ constraints of the form&#xA;\[&#xA;u_i - u_j + s_i + t_{ij} \leq M(1-x_{ij})&#xA;\]&#xA;Here &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; is the processing time of job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_{ij} $&lt;/span&gt; is the change over time from job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is the smallest large enough number you can think of.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-03-11T21:52:40.803" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8046" PostTypeId="2" ParentId="5497" CreationDate="2022-03-12T00:38:20.270" Score="0" Body="&lt;p&gt;It is reasonable to divide by square root of 30. it helps to find the variance of rate of demand. The daily rate is equal to the mean of the forecast error&#xA;and the variance of rate of demand.&lt;/p&gt;&#xA;" OwnerUserId="9343" LastEditorUserId="9343" LastEditDate="2022-03-12T00:54:47.427" LastActivityDate="2022-03-12T00:54:47.427" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8047" PostTypeId="1" CreationDate="2022-03-12T06:03:55.353" Score="2" ViewCount="65" Body="&lt;p&gt;I don't know the terminology, so the title can be confusing.&#xA;Let me explain here.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We would like to find the optimal solution in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. Suppose some external theory suggests that there must be an optimal solution in &lt;span class=&quot;math-container&quot;&gt;$T\subset S$&lt;/span&gt;. Since there may be multiple optimal solutions, there may also be an optimal solution in &lt;span class=&quot;math-container&quot;&gt;$S \setminus T$&lt;/span&gt;, but if what we only care is to achieve the maximum, then failing to find all the optimal solutions is not a problem. So we can search only in &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;. Is there a name for this simplification method?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;The optimal solution is contingent. That is, the optimal solution depends on a condition that we don't know ex-ante. But some external theory suggests that whenever &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is the optimal solution, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is also the optimal solution. Then an algorithm is that ignoring &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, after knowing the condition, calculate the payoff of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and other options, then select the optimal one among them.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In sum, in either case, we rule out some options in the feasible set, knowing at least one optimal solution is still in the remaining set and only search within the remaining set.&lt;/p&gt;&#xA;&lt;p&gt;I am a layman for operations research. So the description may be messy. Let me know if you need more clarification.&lt;/p&gt;&#xA;" OwnerUserId="9347" LastEditorUserId="123" LastEditDate="2022-03-12T10:25:44.983" LastActivityDate="2022-03-12T17:39:27.860" Title="Is there a concept of shrinking the consideration set?" Tags="|optimization|terminology|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8048" PostTypeId="2" ParentId="8047" CreationDate="2022-03-12T06:05:59.707" Score="2" Body="&lt;p&gt;I think the phrase you are looking for is &amp;quot;without loss of optimality.&amp;quot;  In the branch-and-bound algorithm for mixed integer linear programming, this idea arises when you prune by bound.  If the LP bound is strictly worse than the incumbent value, you can always prune by bound.  If the LP bound is the same as the incumbent value and you don't care about finding more than one optimal solution, you can still prune by bound.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-03-12T06:11:10.457" LastActivityDate="2022-03-12T06:11:10.457" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8049" PostTypeId="1" CreationDate="2022-03-12T07:14:54.913" Score="8" ViewCount="819" Body="&lt;p&gt;We run large-scale optimization problems regularly. They have thousand of variables and tens of thousands of constraints.&lt;/p&gt;&#xA;&lt;p&gt;Those optimization problems often get numerically instable. In those cases, we fail to pin-point what exactly causes numerical instability (that is a huge pain-point).&lt;/p&gt;&#xA;&lt;p&gt;We had 2 questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is it possible to identify what is causing numerical instability in our optimization problem? [Note: Both theoretical techniques and programmatic tool (preferably python-based) would be helpful]&lt;/li&gt;&#xA;&lt;li&gt;Given a optimization problem, Is it possible to predict deterministically that would it be Numerically instable or not?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6106" LastActivityDate="2022-03-15T00:21:31.270" Title="Detect Numerical Instability with Large-scale optimization problems" Tags="|optimization|numerical-issues|numerical-stability|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8050" PostTypeId="2" ParentId="8049" CreationDate="2022-03-12T13:01:08.720" Score="7" Body="&lt;p&gt;You can take a look at this &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/guidelines_for_numerical_i.html&quot; rel=&quot;noreferrer&quot;&gt;article/web-page&lt;/a&gt; by Gurobi. It specifies some guidelines to identify &amp;amp; correct some numerical issues in models.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2022-03-12T13:01:08.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8051" PostTypeId="2" ParentId="8044" CreationDate="2022-03-12T13:58:08.310" Score="1" Body="&lt;p&gt;I was able to modify @Sune response slightly to get the intended effect.&lt;/p&gt;&#xA;&lt;p&gt;For every pair of jobs (a,b) in the set of jobs, define constraints:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;start_a - start_b + duration_a + changeover_ab &amp;lt;= M*(1 - x_ab)&#xA;start_b - start_a + duration_b + changeover_ba &amp;lt;= M*(1 - x_ba)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;start_a, start_b, duration_a, duration_b&lt;/code&gt; are continuous decision variables&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;changeover_ab&lt;/code&gt; is scalar, the changeover time from job a to job b&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;changeover_ba&lt;/code&gt; is scalar, the changeover time from job b to job a&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;x_ab, x_ba&lt;/code&gt; binary&lt;/p&gt;&#xA;&lt;p&gt;The key is to make sure &lt;code&gt;x_ab + x_ba = 1&lt;/code&gt;, so rewrite the second constraint as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;start_b - start_a + duration_b + changeover_ba &amp;lt;= M*(x_ab)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When running my MILP, the solution's job start times reflect the required minimum changeover times between subsequent jobs.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastActivityDate="2022-03-12T13:58:08.310" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8052" PostTypeId="2" ParentId="8049" CreationDate="2022-03-12T16:47:01.083" Score="4" Body="&lt;p&gt;In general, I think it is difficult if not impossible to look at a model and say, prior to any computations, that it is going to be unstable ... with one exception. If the largest and smallest absolute values of nonzero constraint coefficients differ by too many orders of magnitude, then you are living dangerously. The model might still be stable, but a wide range of coefficient magnitudes raises the likelihood of instability. Looking at the objective coefficients, I don't know that a wide range of magnitudes would signal likely instability in the sense of basis matrices having large condition numbers, but it could signal potential rounding problems that might lead to suboptimal solutions.&lt;/p&gt;&#xA;&lt;p&gt;Some solvers provide an easy means to inspect the range of magnitudes.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-12T16:47:01.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8053" PostTypeId="2" ParentId="8047" CreationDate="2022-03-12T17:39:27.860" Score="1" Body="&lt;p&gt;You do need to be careful of applying this &amp;quot;we can disregard&amp;quot; idea more than once.&lt;/p&gt;&#xA;&lt;p&gt;Suppose S contains two subsets, T and U. By some argument, typically symmetry,&#xA;you might be able to argue that&lt;/p&gt;&#xA;&lt;p&gt;a) if there is a solution in U, there must also be a solution in S-U.&lt;/p&gt;&#xA;&lt;p&gt;b) if there is a solution in T, there must also be a solution in S-T.&lt;/p&gt;&#xA;&lt;p&gt;You can then disregard either T or U, but not both. Discarding both may discard all optimal solutions. There is a literature on Symmetry in Integer Programming which may be of help.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-03-12T17:39:27.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8054" PostTypeId="2" ParentId="7832" CreationDate="2022-03-12T21:38:35.037" Score="3" Body="&lt;p&gt;Some more references on the history of Linear Programming, and Optimization more generally, can be found at&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.informs.org/Explore/History-of-O.R.-Excellence/O.R.-Methodologies/Optimization-Mathematical-Programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.informs.org/Explore/History-of-O.R.-Excellence/O.R.-Methodologies/Optimization-Mathematical-Programming&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-03-12T21:38:35.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8055" PostTypeId="1" CreationDate="2022-03-13T02:01:55.720" Score="9" ViewCount="6305" Body="&lt;p&gt;In the (famous) Trolley Problem (&lt;a href=&quot;https://en.wikipedia.org/wiki/Trolley_problem&quot; rel=&quot;noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Trolley_problem&lt;/a&gt;) - a runaway train is out of control and unfortunate people are stuck on two different railway tracks. The railway conductor has a choice to make in deciding which track he should divert the train to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wn7vL.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wn7vL.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;To me, this sounds like a very (grim and depressing) optimization problem - &lt;strong&gt;but does anyone know if this problem has ever been studied from a mathematical perspective?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For example, suppose there are many trains, many tracks and many unfortunate people stuck on these tracks - theoretically, could this be interpreted as a very (grim and depressing) scheduling/allocation problem in which the goal is to decide which tracks to divert which trains to, such that the minimum number of victims are injured?&lt;/p&gt;&#xA;&lt;p&gt;Is there any literature in which similar types of problems are studied, in which a general form of the Trolley Problem is specifically mentioned?&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-03-13T21:53:32.337" LastActivityDate="2022-03-15T15:27:54.960" Title="Can we consider the (Famous) &quot;Trolley Problem&quot; as an Optimization Problem?" Tags="|optimization|" AnswerCount="8" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8056" PostTypeId="2" ParentId="8055" CreationDate="2022-03-13T06:20:02.027" Score="9" Body="&lt;p&gt;This problem can be formulated as a network flow problem. Each train is a commodity. The train network is represented as a graph. The cost of using an arc is equal to the number of people killed. The trains need to be moved from their origin to their destination with minimum total cost.&#xA;I don't know the specifics of this bizarre problem, but things get a little weird if 2 trains can use the same arc: does the first train kill the people and the second train gets to use the arc for free? You could treat this variation as a fixed charge network flow problem.&lt;/p&gt;&#xA;&lt;p&gt;Definitely one of the weirdest questions I've seen.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2022-03-13T06:20:02.027" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8057" PostTypeId="2" ParentId="8055" CreationDate="2022-03-13T06:49:16.920" Score="37" Body="&lt;p&gt;I totally agree with @JorisKinable, that the problem can be formulated as some version of a network flow problem &lt;em&gt;if&lt;/em&gt; a clear objective function is known.&lt;/p&gt;&#xA;&lt;p&gt;But that seems to be the very essence of the Trolley problem: there is no single, clear-cut objective function. If it was just a question of injuring the least amount of people, the problem is trivial in the original version depicted in the picture&lt;sup&gt;1&lt;/sup&gt;. But it is an ethical conundrum, where you cannot objectively quantify the outcome of a decision. Hence, I am inclined to say no, this is not an optimization problem.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; It is not necessarily trivial in more complicated situations&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2022-03-14T10:27:17.023" LastActivityDate="2022-03-14T10:27:17.023" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8058" PostTypeId="1" CreationDate="2022-03-13T08:37:23.977" Score="2" ViewCount="114" Body="&lt;p&gt;&lt;strong&gt;background&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am trying to write an pyomo script to optimally dispatch a gas plant based on perfect foresight of electricity prices. I believe I am 90% of the way there, just a few issues.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The script runs, but the solver is never dispatching the plant, even where it should be, in the example provided below, its returning zero, yet if I was to manually calculate it, I can earn at least $8131 of potential profit. I suspect the problem is with how I have either defined my variables, or with how I've written the constraints.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Gas Plant takes 10 minutes to boot up from a cold start&lt;/li&gt;&#xA;&lt;li&gt;Gas Plant can only consume 9000 GJ of gas in a single day&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Help Requested&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Could someone please have a look at my code and see what I am missing in the constraint equations?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pandas as pd&#xA;from pyomo.environ import *&#xA;from pyomo.core import *&#xA;&#xA;&#xA;# ---------------------&#xA;# Main Functions&#xA;# ---------------------&#xA;def model_to_df(model, first_period, last_period):&#xA;&#xA;    # Need to increase the first &amp;amp; last period by 1 because of pyomo indexing&#xA;    # and add 1 to the value of last model period because of the range&#xA;    periods = range(model.T[first_period + 1], model.T[last_period + 1] + 1)&#xA;    rrp = [model.P.extract_values()[None][i] for i in periods]&#xA;    GasOn = [value(model.GasOn[i]) for i in periods]&#xA;    GasUnit_mw = [value(model.GasUnit_mw[i]) for i in periods]&#xA;    GasUse = [value(model.GasUse[i]) for i in periods]&#xA;&#xA;    df_dict = dict(&#xA;        period=periods,&#xA;        rrp=rrp,&#xA;        GasOn=GasOn,&#xA;        GasUnit_mw=GasUnit_mw,&#xA;        GasUse=GasUse&#xA;    )&#xA;&#xA;    df = pd.DataFrame(df_dict)&#xA;&#xA;    return df&#xA;&#xA;&#xA;def optimize_year(df, gunits, gnet, gprice, vom, cold_gas_p_unit, hr, max_gas, sys_use,&#xA;                  first_model_period, last_model_period):&#xA;&#xA;    &amp;quot;&amp;quot;&amp;quot;&#xA;    Optimize behavior of a gas plant over a time period&#xA;    Assume perfect foresight of electricity prices.&#xA;&#xA;    Parameters&#xA;    ----------&#xA;    df : dataframe&#xA;        dataframe with columns of hourly LBMP and the hour of the year&#xA;    gunits : int&#xA;        number of gas turbines&#xA;    gnet : double&#xA;        size in MW's of each gas turbine&#xA;    gprice : double&#xA;        the price of gas &lt;span class=&quot;math-container&quot;&gt;$/GJ&#xA;    vom  : double&#xA;        the variable cost of gas $&lt;/span&gt;/MWh dispatched&#xA;    cold_gas_p_unit  : double&#xA;        the amount of gas in GJ used in 5 minutes while booting up from cold start&#xA;    hr  : double&#xA;        heat rate, the amount of gas consumed per MWh produced (GJ/MWh)&#xA;    sys_use  : double&#xA;        auxillary gas usage, percentage&#xA;    max_gas  : double&#xA;        the maximum amount of gas (GJ) available to use in a period&#xA;    first_model_period : int, optional&#xA;        Set the first period of the year to be considered in the optimization&#xA;    last_model_period : int, optional&#xA;        Set the last period of the year to be considered in the optimization&#xA;&#xA;    Returns&#xA;    -------&#xA;    dataframe&#xA;        Gas plant operational stats and time stamp&#xA;    &amp;quot;&amp;quot;&amp;quot;&#xA;&#xA;    # Filter the data&#xA;    df = df.loc[first_model_period:last_model_period, :]&#xA;&#xA;    model = ConcreteModel()&#xA;&#xA;    # Define model parameters&#xA;    model.T = Set(initialize=df.period.tolist(), doc='periods of year', ordered=True)&#xA;    model.P = Param(initialize=df.rrp.tolist(), doc='price for each period', within=Any)&#xA;&#xA;    model.MaxGas = Param(initialize=max_gas, doc='Max gas usage (GJ) in 24 hour period', within=Any)&#xA;&#xA;    model.GasOn = Var(model.T, bounds=(0, 1), initialize=0)&#xA;    model.GasUnit_mw = Var(model.T, bounds=(0, (gnet * gunits) / 12), initialize=0)&#xA;    model.GasUse = Var(model.T, bounds=(0, gunits*gnet / 12 * hr * (1+sys_use)), initialize=0)&#xA;&#xA;    # *********************&#xA;    # GAS CONSTRAINTS&#xA;    # *********************&#xA;    def gas_on(model, t):&#xA;        'is gas plant on or off?'&#xA;        'gas plant needs 10 minutes (2 intervals) to boot up from a cold start'&#xA;        'during this period, it cannot output mws (energy)'&#xA;        if t &amp;lt;= 2:&#xA;            return model.GasUnit_mw[t] == 0&#xA;        elif value(model.GasOn[t-2] + model.GasOn[t-1] + model.GasOn[t]) &amp;lt;= 2:&#xA;            return model.GasUnit_mw[t] == 0&#xA;        else:&#xA;            return model.GasUnit_mw[t] &amp;gt;= 0&#xA;&#xA;    model.gas_on_check = Constraint(model.T, rule=gas_on)&#xA;&#xA;    def gas_volume_used(model, t):&#xA;        'how much gas is being used?'&#xA;        'during cold start, a small amount of gas is used'&#xA;        'during operation, gas is consumed based on the Heat Rate'&#xA;        if model.GasOn[t] == 1 and model.GasUnit_mw[t] == 0:&#xA;            return model.GasUse[t] == cold_gas_p_unit * gunits * (1+sys_use)&#xA;        else:&#xA;            return model.GasUse[t] == model.GasUnit_mw[t] * hr * (1+sys_use)&#xA;&#xA;    model.gas_vol = Constraint(model.T, rule=gas_volume_used)&#xA;&#xA;    def daily_max_gas(model, t):&#xA;        &amp;quot;only 9000 GJ of gas can be used in a single day&amp;quot;&#xA;        min_t = model.T.first()&#xA;        max_t = model.T.last()&#xA;&#xA;        # Check all t until the last 24 hours&#xA;        if t &amp;lt;= max_t:&#xA;            return sum(model.GasUse[i] for i in range(min_t, max_t+1)) &amp;lt;= model.MaxGas&#xA;        else:&#xA;            return Constraint.Skip&#xA;&#xA;    model.max_gas_vol = Constraint(model.T, rule=daily_max_gas)&#xA;&#xA;    # Define the income, expenses, and profit&#xA;    gas_income = sum(df.loc[t, 'rrp'] * model.GasUnit_mw[t] for t in model.T)&#xA;    gas_expenses = sum(model.GasUse[t] * gprice + model.GasUnit_mw[t] * vom for t in model.T)&#xA;    profit = gas_income - gas_expenses&#xA;    model.objective = Objective(expr=profit, sense=maximize)&#xA;&#xA;    # Solve the model&#xA;    solver = SolverFactory('glpk')&#xA;    solver.solve(model)&#xA;&#xA;    results_df = model_to_df(model, first_period=first_model_period, last_period=last_model_period)&#xA;    results_df['local_time'] = df.loc[:, 'local_time']&#xA;&#xA;    return results_df&#xA;&#xA;&#xA;# *********************&#xA;# RUN SCRIPT&#xA;# *********************&#xA;# Import file&#xA;df = pd.read_csv('raw_prices.csv')&#xA;&#xA;# New Index&#xA;df['period'] = df.reset_index().index&#xA;&#xA;# get current Year&#xA;first_model_period = 0&#xA;last_model_period = df['period'].iloc[-1]&#xA;&#xA;# Gas Inputs&#xA;gunits = 3 # No units&#xA;gnet = 58.5 # MW/unit&#xA;srmc = 115.49 # &lt;span class=&quot;math-container&quot;&gt;$/MWh&#xA;vom = 6.18 # $&lt;/span&gt;/MWh&#xA;gprice = 10.206 # $/GJ&#xA;cold_gas_p_unit = 15.75 # GJ/unit/5mins&#xA;hr = 10.5 # GJ/MWh&#xA;sys_use = 0.02 # %&#xA;max_gas = 9000 # GJ&#xA;&#xA;# Run Model&#xA;results_df = optimize_year(df=df, gunits=gunits, gnet=gnet, gprice=gprice, vom=vom, cold_gas_p_unit=cold_gas_p_unit,&#xA;                           hr=hr, max_gas=max_gas, sys_use=sys_use,&#xA;                           first_model_period=first_model_period, last_model_period=last_model_period)&#xA;&#xA;# ---------------------&#xA;# Write the file out and remove the index&#xA;# ---------------------&#xA;print('ran successfully')&#xA;results_df.to_csv('optimised_output.csv', index=False)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Example Data&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;local_time      rrp&#xA;3/07/2022 16:40 64.99&#xA;3/07/2022 16:45 73.10744&#xA;3/07/2022 16:50 74.21746&#xA;3/07/2022 16:55 95.90964&#xA;3/07/2022 17:00 89.60728&#xA;3/07/2022 17:05 90.37018&#xA;3/07/2022 17:10 92.52947&#xA;3/07/2022 17:15 100.1449&#xA;3/07/2022 17:20 103.70199&#xA;3/07/2022 17:25 290.2848&#xA;3/07/2022 17:30 115.40232&#xA;3/07/2022 17:35 121.00009&#xA;3/07/2022 17:40 294.62543&#xA;3/07/2022 17:45 121&#xA;3/07/2022 17:50 294.69446&#xA;3/07/2022 17:55 124.90664&#xA;3/07/2022 18:00 117.21929&#xA;3/07/2022 18:05 115.60193&#xA;3/07/2022 18:10 121&#xA;3/07/2022 18:15 148.20186&#xA;3/07/2022 18:20 123.11763&#xA;3/07/2022 18:25 120.99996&#xA;3/07/2022 18:30 121&#xA;3/07/2022 18:35 121&#xA;3/07/2022 18:40 121&#xA;3/07/2022 18:45 120.77726&#xA;3/07/2022 18:50 105.44435&#xA;3/07/2022 18:55 104.22928&#xA;3/07/2022 19:00 102.26646&#xA;3/07/2022 19:05 99.5896&#xA;3/07/2022 19:10 95.5881&#xA;3/07/2022 19:15 88&#xA;3/07/2022 19:20 88&#xA;3/07/2022 19:25 88&#xA;3/07/2022 19:30 96.97537&#xA;3/07/2022 19:35 88&#xA;3/07/2022 19:40 86.39322&#xA;3/07/2022 19:45 88&#xA;3/07/2022 19:50 85.97703&#xA;3/07/2022 19:55 86&#xA;3/07/2022 20:00 87.61047&#xA;3/07/2022 20:05 88&#xA;3/07/2022 20:10 88&#xA;3/07/2022 20:15 85.34908&#xA;3/07/2022 20:20 85.1&#xA;3/07/2022 20:25 71.01181&#xA;3/07/2022 20:30 84.88422&#xA;3/07/2022 20:35 85.39669&#xA;3/07/2022 20:40 86.02542&#xA;3/07/2022 20:45 84.87425&#xA;3/07/2022 20:50 70.0652&#xA;3/07/2022 20:55 70.65106&#xA;3/07/2022 21:00 70.53063&#xA;3/07/2022 21:05 68.27&#xA;3/07/2022 21:10 68.86159&#xA;3/07/2022 21:15 68.32018&#xA;3/07/2022 21:20 67.30473&#xA;3/07/2022 21:25 66.78292&#xA;3/07/2022 21:30 66.02195&#xA;3/07/2022 21:35 66.40755&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2022-03-13T08:37:23.977" Title="Pyomo optimisation not working (gas plant dispatch)" Tags="|optimization|linear-programming|solver|pyomo|energy|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8059" PostTypeId="2" ParentId="8055" CreationDate="2022-03-13T09:50:15.880" Score="14" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;“Nothing takes place in the world whose meaning is not that of some maximum or minimum.”&#xA;― Leonhard Euler&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;But as in many theoretical and industrial problems, the main difficulty is not to formulate the problem, but to define the objective function...&lt;/p&gt;&#xA;&lt;p&gt;I think at least two types of costs should be considered: how many people are killed and whether you take actions. Then it is an open question that how one should set the coefficient.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastEditorUserId="123" LastEditDate="2022-03-14T08:13:46.367" LastActivityDate="2022-03-14T08:13:46.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8060" PostTypeId="2" ParentId="8049" CreationDate="2022-03-13T17:09:59.303" Score="8" Body="&lt;p&gt;Some people at Xpress have worked recently (past couple of years) on automated scaling techniques for LP and MIP, which involves guessing whether a problem will run into numerical issues.&lt;/p&gt;&#xA;&lt;p&gt;I can point you to &lt;a href=&quot;http://www.optimization-online.org/DB_FILE/2020/12/8166.pdf&quot; rel=&quot;noreferrer&quot;&gt;this preprint&lt;/a&gt;, wherein the authors use the concept of &lt;em&gt;attention level&lt;/em&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The attention level is a measure between 0 and 1 that aims at estimating how likely numerical errors are to occur during an LP or MIP solve&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="3598" LastEditDate="2022-03-13T19:08:51.227" LastActivityDate="2022-03-13T19:08:51.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8061" PostTypeId="1" AcceptedAnswerId="8078" CreationDate="2022-03-13T19:20:45.303" Score="0" ViewCount="209" Body="&lt;p&gt;Why can't I generate for the &lt;code&gt;topsis&lt;/code&gt; method, choosing a &lt;code&gt;w &amp;lt;- c(1, 0)&lt;/code&gt;? As far as I know it has to be the sum of the weights equal to 1. And it's weird that if I put &lt;code&gt;w &amp;lt;- c(1, 1)&lt;/code&gt; it works. But why, since the sum of the weights must equal 1?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;library(topsis)&#xA;&#xA;df1 &amp;lt;- structure(list(n = c(2, 3, 4, 5, 6, 7, 8, 9, 10, 11), &#xA;Coverage = c(0.0363201192049018, 0.0315198954715543,&#xA;0.112661460735583, 0.112661460735583, 0.112661460735583, 0.0813721071219816,&#xA;0.0862146652218061, 0.0697995564757394, 0.0599194966471805,&#xA;0.0507632014547115), &#xA;Production =&#xA;c(1635156.04305, 474707.64025, 170773.40775, 64708.312, 64708.312, 64708.312,&#xA;949.72635, 949.72635, 949.72635, 949.72635)),&#xA;class = &amp;quot;data.frame&amp;quot;, row.names = c(NA,-10L))&#xA;&#xA;df2 &amp;lt;- df1[c(2:3)]&#xA;df2&amp;lt;-data.matrix(df2)&#xA;&#xA;w &amp;lt;- c(1, 0)&#xA;i &amp;lt;- c(&amp;quot;+&amp;quot;, &amp;quot;-&amp;quot;)&#xA;topsis(df2, w, i)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Error in topsis(df2, w, i) : weights must be positive numbers&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="9063" LastEditorUserId="491" LastEditDate="2022-03-14T12:01:08.293" LastActivityDate="2022-12-09T15:36:16.667" Title="Conflicts with weights of the topsis method in R" Tags="|r|multicriteria-decision-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8062" PostTypeId="2" ParentId="8055" CreationDate="2022-03-13T20:35:03.937" Score="6" Body="&lt;p&gt;I cover this scenario in my ethics class for IT, so I would like to share my perspective. The trolley problem is a hypothetical scenario that is often used to highlight the issue of &lt;strong&gt;imperfect information&lt;/strong&gt; in utilitarianism.&lt;/p&gt;&#xA;&lt;p&gt;A very common argument is: the five people are a family, and the single man is a railworker without a family. You calculate the lost happiness, and decide to flip the switch to kill the single man.&lt;/p&gt;&#xA;&lt;p&gt;What you don't know is that that single man was working as a railway assistant in his spare time as a student, and he was developing a cure for cancer. By sparing the lives of five, you have stopped the cure for cancer and millions will die as a result. The argument is that you &lt;em&gt;could not have known&lt;/em&gt;. Not only is this a split-second decision which would affect your access to information, but even if you had all the time in the world to deliberate, you don't know all the &amp;quot;what ifs&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;So you essentially operate under an assumption of fixed, incomplete information. What I want to say with my answer, is to consider this an imperfect information issue, on which there is of course plenty of research on.&lt;/p&gt;&#xA;" OwnerUserId="9358" LastActivityDate="2022-03-13T20:35:03.937" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8063" PostTypeId="2" ParentId="8055" CreationDate="2022-03-13T23:15:15.423" Score="14" Body="&lt;p&gt;No, the main point is the ethic behind the choice.&lt;/p&gt;&#xA;&lt;p&gt;Pulling the lever minimises the number of deaths, but it requires an active action resulting in the death of a person.&#xA;Not doing anything increase the number of deaths, but removes the burden of the decision.&#xA;How do we weight action vs inaction is subjective, and whether we should force people to &amp;quot;pull the lever&amp;quot; is also debatable.&lt;/p&gt;&#xA;&lt;p&gt;So any mathematical treatment is really missing the point and solving another problem. For instance they may solve what should we do in a complicated situation with many trains and switches, but assuming we already know what we would do in the single train scenario.&lt;/p&gt;&#xA;" OwnerUserId="9360" LastActivityDate="2022-03-13T23:15:15.423" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8064" PostTypeId="1" CreationDate="2022-03-14T09:56:32.187" Score="3" ViewCount="132" Body="&lt;p&gt;As the cutting plan algorithm is a method to strengthen the feasible space of the linear programming, specifically in the MILP problems to invoke the integer solutions, it may be a problem-based specific method in which how they can be added to the model. I know that for many of the problems, it is possible to add different kinds of cuts to get the same integer solution at least for an indexed variable. (e.g. either using a Gomory fractional cut or MIR cut to solve an IP/MIP problem as shown in &lt;a href=&quot;https://www.scipopt.org/download/slides/SCIP-cuttingPlanes.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; link).&lt;/p&gt;&#xA;&lt;p&gt;Now, if anyone wants to use a cutting plane scheme on the problem that needs to solve with a specific method like branch-cut, relaxed-cut, etc, is there any way to find out which one of the cuts should be used to make the better results? Another question that is rising to my mind is, how do mathematical solvers distinguish when and where a specific cut should be applied?&lt;/p&gt;&#xA;&lt;p&gt;Any insight about that would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-03-14T09:56:32.187" Title="When and where the cutting plane method should be applied?" Tags="|optimization|mixed-integer-programming|cutting-planes|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="8065" PostTypeId="2" ParentId="8055" CreationDate="2022-03-14T11:10:06.577" Score="4" Body="&lt;p&gt;In a way, I suppose it could be, but at the same time I don't believe it is.&lt;/p&gt;&#xA;&lt;p&gt;Assuming all variables are known then it could be considered an optimisation algorithm - and self-driving cars would probably have to face at some point (i.e. &amp;quot;I can't stop in time and there's oncoming traffic - do I plough into the pedestrian in my path, or swerve into the oncoming traffic?&amp;quot;).&lt;/p&gt;&#xA;&lt;p&gt;HOWEVER, the whole point of the trolley problem is that you can't possibly know all of the variables in those kind of situations. That's what makes it an ethical conundrum, not an optimisation algorithm... Although, the subjective decision of what to do in answer to this ethical conundrum could be used to drive optimisation algorithms.&lt;/p&gt;&#xA;" OwnerUserId="9114" LastActivityDate="2022-03-14T11:10:06.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8066" PostTypeId="1" AcceptedAnswerId="8067" CreationDate="2022-03-14T12:06:34.277" Score="1" ViewCount="422" Body="&lt;p&gt;I have been working on the Gurobi (C++ API) using its reference manual for some time. I did not see any description in the manual regarding how to create the Gurobi model using a matrix and iterate through it. For instance, I have a 50x50 matrix and would like to create a model using that. So far I have tried &lt;code&gt;GRBModel::set()&lt;/code&gt; but it did not work out.&lt;/p&gt;&#xA;" OwnerUserId="7526" LastEditorUserId="7526" LastEditDate="2022-03-14T17:05:21.317" LastActivityDate="2022-03-21T12:55:05.183" Title="How to create Gurobi model using a matrix? (C++ API)" Tags="|modeling|gurobi|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8067" PostTypeId="2" ParentId="8066" CreationDate="2022-03-14T13:08:33.537" Score="1" Body="&lt;p&gt;This answer is specific to Python API. You need to use numpy library to create matrices and leverage gurobipy library to create variables &amp;amp; constraints. Please refer to the following link for more details:&#xA;&lt;a href=&quot;https://www.gurobi.com/documentation/9.5/quickstart_mac/cs_example_matrix1_py.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.5/quickstart_mac/cs_example_matrix1_py.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Similar features should be available in other languages as well.&lt;/p&gt;&#xA;&lt;p&gt;Edit-1: Sample gurobi code in C++&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;&#xA;#include &amp;lt;vector&amp;gt;&#xA;#include &amp;quot;gurobi_c++.h&amp;quot;&#xA;&#xA;int main () {&#xA;    int n1 = 50; //Initialise variable count&#xA;    int n2 = 50;&#xA;    &#xA;    //allocate memory&#xA;    GRBVar **x = new GRBVar *[n1];&#xA;    for (int i = 0; i &amp;lt; n1; i++) {&#xA;        x[i] = new GRBVar[n2];&#xA;    }&#xA;&#xA;    //Create GRB environment&#xA;    GRBEnv *env = 0;&#xA;    env = new GRBEnv();&#xA;    GRBModel model = GRBModel(*env);&#xA;    &#xA;    //Set model name&#xA;    model.set(GRB_StringAttr_ModelName, &amp;quot;sampleModel&amp;quot;);&#xA;    &#xA;    //Create variables&#xA;    for (int i = 0; i &amp;lt; n1; i++) {&#xA;        for (int j = 0; j &amp;lt; n2; j++) {&#xA;            //Create binary variable&#xA;            x[i][j] = model.addVar(0.0, 1.0, 1.0, GRB_BINARY);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5880" LastEditorUserId="7526" LastEditDate="2022-03-21T12:55:05.183" LastActivityDate="2022-03-21T12:55:05.183" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8068" PostTypeId="1" CreationDate="2022-03-14T21:34:19.643" Score="0" ViewCount="244" Body="&lt;p&gt;Does cplex 12.10 support python 3.8? I cannot install setup.py file. I think only 3.7 and 3.6 are supported.&lt;/p&gt;&#xA;" OwnerUserId="9245" LastActivityDate="2022-03-14T23:03:09.610" Title="Cplex 12.10 and python" Tags="|python|cplex|docplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8069" PostTypeId="2" ParentId="8068" CreationDate="2022-03-14T23:03:09.610" Score="2" Body="&lt;p&gt;Googling turned up an answer immediately: &lt;a href=&quot;https://stackoverflow.com/questions/64377839/i-have-a-error-on-installing-cplex-12-10-to-python-3-8&quot;&gt;https://stackoverflow.com/questions/64377839/i-have-a-error-on-installing-cplex-12-10-to-python-3-8&lt;/a&gt;. Apparently you just have to rename a folder.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-14T23:03:09.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8070" PostTypeId="2" ParentId="8049" CreationDate="2022-03-15T00:21:31.270" Score="3" Body="&lt;p&gt;About the causes:&#xA;a) Too high or too low values in your matrix, a good rule of thumb is that the ratio of the higgest / lowest coefficient should be lower than 10^6. Take special care with big M's. If the coefficients are needed you can scale the constraint.&#xA;b) Sometimes constraints that means almost the same thing for example a bound in each node of a graph an a bound in the sum of the nodes, can lead to a close to singular matrix.&lt;/p&gt;&#xA;" OwnerUserId="9374" LastActivityDate="2022-03-15T00:21:31.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8071" PostTypeId="6" CreationDate="2022-03-15T02:22:32.027" Score="0" Body="&lt;h1&gt;EhsanK&lt;/h1&gt;&#xA;&lt;p&gt;I have been with OR.SE since its beginnings on Area 51 and I am also a pro-tem moderator since 2019. I have been one of the most active users when it comes to clearing the review queues. In all my interactions, whether directly with users or resolving flags, I have acted fairly and respectfully, and I intend to continue doing so if elected as a moderator.&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2022-03-15T02:22:32.027" LastActivityDate="2022-03-15T02:22:32.027" CommentCount="0" CommunityOwnedDate="2022-03-15T02:22:32.027" ContentLicense="CC BY-SA 4.0" />
  <row Id="8073" PostTypeId="2" ParentId="8055" CreationDate="2022-03-15T10:01:21.053" Score="4" Body="&lt;p&gt;This is an ethical problem not a mathematical one.&#xA;The main question is about determining the cost function to make the choice.&lt;/p&gt;&#xA;&lt;p&gt;If the cost function were known, there is no mathematical issue. The choice with the lower cost would be taken.&lt;/p&gt;&#xA;&lt;p&gt;Ethical impacts are much more interesting:&lt;/p&gt;&#xA;&lt;p&gt;Shall one simply count the number of human lifes?&lt;/p&gt;&#xA;&lt;p&gt;Shall one attempt to decide the value of each life concerned?&lt;/p&gt;&#xA;&lt;p&gt;Do we have enough information to decide?&lt;/p&gt;&#xA;&lt;p&gt;Might our choices intentionally or indirectly be racist or discriminating?&lt;/p&gt;&#xA;&lt;p&gt;Shall we even try to determine the value knowing we definitely have incomplete information?&lt;/p&gt;&#xA;&lt;p&gt;What are the consequences for the person making the choice?&lt;/p&gt;&#xA;&lt;p&gt;Will a (a posteriori) wrong action be punished more severly than inaction?&lt;/p&gt;&#xA;&lt;p&gt;This problem is a very interesting base for ethical discussions.&lt;/p&gt;&#xA;" OwnerUserId="9377" LastEditorUserId="9377" LastEditDate="2022-03-15T14:06:35.997" LastActivityDate="2022-03-15T14:06:35.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8074" PostTypeId="1" CreationDate="2022-03-15T13:43:10.337" Score="1" ViewCount="91" Body="&lt;p&gt;If I have two matrix&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A = \begin{bmatrix}&#xA;1 &amp;amp; 2 \\&#xA;2 &amp;amp; 3 &#xA;\end{bmatrix} $$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$B = \begin{bmatrix}&#xA;3 &amp;amp; 4 \\&#xA;5 &amp;amp; 3 &#xA;\end{bmatrix} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We have to make a matching between &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; such that the we achieve maximum weight is achieved, which is the sum of A and B, and that our matching is stable.&lt;/p&gt;&#xA;&lt;p&gt;For instance, &lt;span class=&quot;math-container&quot;&gt;$$w = \begin{bmatrix}&#xA;4 &amp;amp; 6 \\&#xA;7 &amp;amp; 6 &#xA;\end{bmatrix} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is the weight matrix, and order to get max weights, taking rows of &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; to be &lt;span class=&quot;math-container&quot;&gt;$a_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_2$&lt;/span&gt; and columns to be &lt;span class=&quot;math-container&quot;&gt;$b_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_2$&lt;/span&gt;. We would have &lt;span class=&quot;math-container&quot;&gt;$a_1$&lt;/span&gt; matches to &lt;span class=&quot;math-container&quot;&gt;$b_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_2$&lt;/span&gt; matches to &lt;span class=&quot;math-container&quot;&gt;$b_1$&lt;/span&gt;. However a stable matching is defined if there exists no blocking pair, that is, there does not exist any pair &lt;span class=&quot;math-container&quot;&gt;$i \in A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j \in B$&lt;/span&gt; that prefer each other to their current partners under the matching (preference is made according to cardinality of elements. And hence, &lt;span class=&quot;math-container&quot;&gt;$a_2$&lt;/span&gt; would prefer to be matched to &lt;span class=&quot;math-container&quot;&gt;$b_2$&lt;/span&gt;, which is not the case here. I am not sure on how to solve this problem.&lt;/p&gt;&#xA;&lt;p&gt;I have been able to compute maximum weight. I am sure this can be formulated as an IP, but not sure how to do so.&lt;/p&gt;&#xA;" OwnerUserId="8819" LastEditorUserId="67" LastEditDate="2022-03-15T17:58:03.330" LastActivityDate="2022-03-15T17:58:03.330" Title="Bipartite matching" Tags="|integer-programming|graphs|matching|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8075" PostTypeId="2" ParentId="7991" CreationDate="2022-03-15T14:14:11.257" Score="2" Body="&lt;p&gt;As @prubin corretly pointed out, the essential problem at hand is the transportation problem with some additional constraints on non-available quantities for relevant material-supplier pairs.&lt;/p&gt;&#xA;&lt;p&gt;I could model the data using &lt;code&gt;ompr&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  model &amp;lt;- MIPModel() %&amp;gt;%&#xA;    # quantity to get from the suppliers&#xA;    add_variable(x[i, j], i = 1:n_capacity, j = 1:n_demand, type = 'continuous') %&amp;gt;%&#xA;    # objective function&#xA;    set_objective(sum_over(c[i, j] * x[i, j], i = 1:n_capacity, j = 1:n_demand), 'min') %&amp;gt;%&#xA;    # constraints&#xA;    add_constraint(sum_over(x[i, j], i = 1:n_capacity) &amp;gt;= demand[j], j = 1:n_demand) %&amp;gt;%&#xA;    add_constraint(sum_over(x[i, j], j = 1:n_demand) &amp;lt;= capacity[i], i = 1:n_capacity) %&amp;gt;%&#xA;    add_constraint(x[i, j] &amp;gt;= 0, i = 1:n_capacity, j = 1:n_demand)&#xA;&#xA;  zero_constraint_on_quantity &amp;lt;- which(c == 0, arr.ind = TRUE)&#xA;  for(el in seq_len(NROW(zero_constraint_on_quantity))) {&#xA;    i_val &amp;lt;- zero_constraint_on_quantity[el, 'row']&#xA;    j_val &amp;lt;- zero_constraint_on_quantity[el, 'col']&#xA;    model %&amp;lt;&amp;gt;%&#xA;      add_constraint(x[i, j] == 0, i = i_val, j = j_val)&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where &lt;code&gt;c&lt;/code&gt; is an aditional cost matrix, with cost for every material-supplier pair.&lt;/p&gt;&#xA;&lt;p&gt;Additionaly, I find it interessting that an implementation of an elastic filter (out of scope for this question) can calculate over/under utilisation of the capacity, which is quite handy for further SCM planning.&lt;/p&gt;&#xA;" OwnerUserId="7523" LastEditorUserId="7523" LastEditDate="2022-03-15T14:28:13.643" LastActivityDate="2022-03-15T14:28:13.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8076" PostTypeId="2" ParentId="8055" CreationDate="2022-03-15T15:27:54.960" Score="3" Body="&lt;p&gt;Many discussions of the Trolley Problem ignore an important second-order effect: people who are willing to take evasive maneuvers that protect reckless people at the expense of those who would not otherwise have been in their path encourage recklessness.  In an extreme case, suppose a group of five people decided to check before crossing the tracks to check how many people were on the other line, and concluded that if there were four or fewer then they would be safe.  Should the train operator value the lives of five over the lives of one, or should he value the life of a worker who followed tag-out procedures over the lives of people who would have sacrificed him to avoid the inconvenience of waiting for the trolley to pass?&lt;/p&gt;&#xA;&lt;p&gt;Even if one replaces the situation with a driver on a road, a similar issue arises: anyone whose path might intersect with a motorist whose path ahead is presently clear should be prepared for the possibility that the motorist might continue along that path.  By contrast, it will often not be possible for all other motorists to be prepared for everything the motorist might do to avoid something on his primary path.  If a motorist swerves to successfully avoid someone who is running a red light, but ends up colliding with someone else instead, the motorist's actions will have protected a reckless driver at the cost of an innocent one.&lt;/p&gt;&#xA;&lt;p&gt;To be sure, the automotive version of the problem raises other issues, since the evasive maneuver may replace a T-bone collision with a side-swipe, and it's even possible that the alternative to the side-swipe might have been three-car collision that would have been worse for everyone involved.  In general, though, to the extent that the &amp;quot;trolley problem&amp;quot; is an optimization problem, the goal should be to optimize people's ability to avoid making bad decisions in the first place.&lt;/p&gt;&#xA;" OwnerUserId="9099" LastActivityDate="2022-03-15T15:27:54.960" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8078" PostTypeId="2" ParentId="8061" CreationDate="2022-03-15T18:21:44.753" Score="1" Body="&lt;p&gt;&lt;strong&gt;Normalizing the Weights.&lt;/strong&gt; According to the &lt;code&gt;topsis()&lt;/code&gt; &lt;a href=&quot;https://cran.r-project.org/web/packages/topsis/topsis.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt;, the argument &lt;code&gt;weights&lt;/code&gt; must be &amp;quot;[a] numeric vector with length equal to number of columns in decision matrix for&#xA;weights of criterions&amp;quot; (sic) which clearly omits certain requirements based on your error message (namely that the weights be positive).&lt;/p&gt;&#xA;&lt;p&gt;There does not appear to be a requirement for the weights to sum to 1 as the example in the documentation (copied below) uses &lt;code&gt;c(1, 1, 2)&lt;/code&gt; to yield &lt;span class=&quot;math-container&quot;&gt;$[1,\; 1,\; 2]$&lt;/span&gt; as weights.&lt;/p&gt;&#xA;&lt;p&gt;The interpretation is that the third criterion is twice as important as the other two. This implies that weights &lt;code&gt;[1 1 2]&lt;/code&gt;, &lt;code&gt;[0.25 0.25 0.50]&lt;/code&gt;, and &lt;code&gt;[2 2 4]&lt;/code&gt; are equivalent.&lt;/p&gt;&#xA;&lt;p&gt;Clearly normalizing the weights (&lt;a href=&quot;https://en.wikipedia.org/wiki/TOPSIS&quot; rel=&quot;nofollow noreferrer&quot;&gt;as seen here&lt;/a&gt;) isn't required for implementation.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# R Example&#xA;# Minimal Example for Demonstration&#xA;library(topsis)&#xA;set.seed(5)                   # Fixing the random seed for reproducibility&#xA;d &amp;lt;- matrix(rpois(12, 5), nrow = 4)&#xA;w &amp;lt;- c(1, 1, 2)               # Try a multiple of w to see for yourself&#xA;i &amp;lt;- c(&amp;quot;+&amp;quot;, &amp;quot;-&amp;quot;, &amp;quot;+&amp;quot;)&#xA;topsis(d, w, i)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This outputs the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  alt.row     score rank&#xA;1       1 0.7486787    1&#xA;2       2 0.1777717    4&#xA;3       3 0.3917848    2&#xA;4       4 0.3694949    3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that if you replace weights &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; with any &lt;span class=&quot;math-container&quot;&gt;$\alpha w$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\alpha &amp;gt; 0$&lt;/span&gt; you get the same output.  For example, I used &lt;code&gt;w &amp;lt;- c(3, 3, 6)&lt;/code&gt; and &lt;code&gt;w &amp;lt;- c(0.25, 0.25, 0.5)&lt;/code&gt; and obtained the same results in each case.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Side Note.&lt;/strong&gt; Using &lt;code&gt;c(1,0)&lt;/code&gt; results in weights &lt;span class=&quot;math-container&quot;&gt;$[0,\; 1]$&lt;/span&gt;. Since the weights must be positive based on the function's error checking, &lt;a href=&quot;https://math.stackexchange.com/q/26705/572874&quot;&gt;zero may not satisfy that&lt;/a&gt;. Logically, why give something zero weight if you want to consider it for the objective? Just remove it.&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2022-12-09T15:36:16.667" LastActivityDate="2022-12-09T15:36:16.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8079" PostTypeId="1" CreationDate="2022-03-15T19:06:18.667" Score="9" ViewCount="294" Body="&lt;p&gt;I have two questions on branch-bound-and-price.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Why does it sometimes fail? For instance, the paper by &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.1120.0445&quot; rel=&quot;noreferrer&quot;&gt;Dabia et al&lt;/a&gt; shows results where the proposed algorithm fails for some cases. The paper does not explain why it fails. Is it because of the time limit? Or is there any other reason the branch-bound-and-price fail for some problems?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;An odd behavior of the branch-bound-and-price algorithm:&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I am implementing a branch-bound-and-price algorithm with column generation for an electric vehicle routing problem to minimize a certain cost. I am modifying two software - &lt;a href=&quot;https://vrpy.readthedocs.io/en/latest/&quot; rel=&quot;noreferrer&quot;&gt;vrpy&lt;/a&gt; and &lt;a href=&quot;https://cspy.readthedocs.io/en/latest/&quot; rel=&quot;noreferrer&quot;&gt;cspy&lt;/a&gt; for implementation.&lt;/p&gt;&#xA;&lt;p&gt;My column generation currently works fine using the labeling algorithm. I know this because when I calculate the duality gap, it converges to 0 in the last iteration when there is no route found with a negative reduced cost.&lt;/p&gt;&#xA;&lt;p&gt;I have a problem during the branch and bound though. I find that sometimes the parent node in the branch-and-bound search tree has a lower bound on the objective function value that is WORSE than the child node. This means that an additional constraint on the master problem (more bounding) has IMPROVED the objective function value for the child node.&lt;/p&gt;&#xA;&lt;p&gt;I have double and triple-checked the master problem formulation with bounding but I don't see where it went wrong.&#xA;It seems to happen when I have a larger network.&#xA;It also seems to happen more when I have some negative edge costs in the network.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone know why this would be?&lt;/p&gt;&#xA;" OwnerUserId="9386" LastEditorUserId="491" LastEditDate="2022-03-16T00:05:04.117" LastActivityDate="2022-03-23T14:13:14.787" Title="Odd behavior in the branch bound and price algorithm with column generation" Tags="|vehicle-routing|column-generation|branch-and-bound|branch-and-price|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="8080" PostTypeId="1" CreationDate="2022-03-16T21:08:25.947" Score="3" ViewCount="89" Body="&lt;p&gt;What to do in these cases where I can't rank by the VIKOR multicriteria method because &lt;code&gt;Q&lt;/code&gt; has no value?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    library(MCDM)&#xA;    &#xA;    df1&amp;lt;-structure(c(14509.9423478068, 4648.5779693212, 922, 876), .Dim = c(2L, &#xA;    2L), .Dimnames = list(NULL, c(&amp;quot;Criteria1&amp;quot;, &amp;quot;Criteria2&amp;quot;)))&#xA;&#xA;&amp;gt; df1&#xA;     Criteria1 Criteria2&#xA;[1,] 14509.942       922&#xA;[2,]  4648.578       876&#xA;    &#xA;      w &amp;lt;- c(0.5,0.5)&#xA;      cb &amp;lt;- c('min','max')&#xA;      v &amp;lt;- 0.5&#xA;      result1&amp;lt;-VIKOR(df1,w,cb,v)&#xA;&#xA;&amp;gt; result1&#xA;  Alternatives   S   R   Q Ranking&#xA;1            1 0.5 0.5 NaN       -&#xA;2            2 0.5 0.5 NaN       -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9063" LastActivityDate="2022-06-06T19:23:37.920" Title="Application with VIKOR multicriteria method" Tags="|r|multicriteria-decision-analysis|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8081" PostTypeId="1" CreationDate="2022-03-17T13:41:39.613" Score="2" ViewCount="74" Body="&lt;p&gt;I have a distribution of values that are the output of a simulation(not stochastic). I want to optimize the parameter such that output distribution are a lot more flatter than they are with non-optimized parameters.&#xA;Minimize peak and variance?&lt;/p&gt;&#xA;" OwnerUserId="7232" LastActivityDate="2022-03-17T15:19:34.750" Title="Optimizing a distribution to a much more flatter distribution" Tags="|optimization|simulation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8082" PostTypeId="2" ParentId="8081" CreationDate="2022-03-17T15:19:34.750" Score="2" Body="&lt;p&gt;&amp;quot;Flatter&amp;quot; is in the eye of the beholder. Minimizing the range of values would be worth considering.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-17T15:19:34.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8084" PostTypeId="1" CreationDate="2022-03-17T21:30:20.900" Score="1" ViewCount="47" Body="&lt;p&gt;As a general rule, when building decision variables, is it computationally preferable to index along fewer dimensions instead of more when the count of permutations are identical?&lt;/p&gt;&#xA;&lt;p&gt;For context, I'm building a production optimization model on a 12 week horizon.  Production requirements are given at the monthly level for the next 3 months (presumed exactly 4 weeks / 28 days per month).&lt;/p&gt;&#xA;&lt;p&gt;For ease of building these monthly production constraints, I'm indexing my decision variables along both week and month dimensions [week = 1:4, month = 1:3].  Would it be computationally beneficial to just index along weeks 1:12, then apply monthly production constraints on weeks 1:4, 5:8, 9:12 separately?&lt;/p&gt;&#xA;" OwnerUserId="3958" LastActivityDate="2022-03-17T21:30:20.900" Title="Indexing weeks in MILP: better to have 12 weeks, or 3 months at 4 weeks each?" Tags="|optimization|linear-programming|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8085" PostTypeId="6" CreationDate="2022-03-18T09:25:21.687" Score="0" Body="&lt;h1&gt;TheSimpliFire&lt;/h1&gt;&#xA;&lt;p&gt;Along with Ehsan and Larry, I have been serving as a pro-tempore moderator since our site's first election in 2019. Other than answering questions, I have played a major part in voting, editing, reviewing and tagging. In terms of user interactions, I have been respectful and have listened to/acted on users' opinions and proposals. I have also been involved in the initiative to promote our community through Eddiee's &lt;a href=&quot;https://or.meta.stackexchange.com/questions/331/setting-up-a-community-server-for-or-enthusiasts&quot;&gt;OR Discord server&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="123" LastEditDate="2022-03-18T09:25:21.687" LastActivityDate="2022-03-18T09:25:21.687" CommentCount="0" CommunityOwnedDate="2022-03-18T09:25:21.687" ContentLicense="CC BY-SA 4.0" />
  <row Id="8087" PostTypeId="6" CreationDate="2022-03-18T10:18:38.267" Score="0" Body="&lt;h1&gt;Eduard. (25 y. technical university germany)&lt;/h1&gt;&#xA;&lt;p&gt;-finsihing currently masters in OR with focus on integrated scheduling and routing (master thesis).&lt;/p&gt;&#xA;&lt;p&gt;worked on problems like:&lt;/p&gt;&#xA;&lt;p&gt;lot-sizing, routing, scheduling,  for more info: &lt;a href=&quot;https://github.com/EduKru/An-Optimization-Portfolio-Decision-Science&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/EduKru/An-Optimization-Portfolio-Decision-Science&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;currently trying to set up a discord to make the community on researchers more interactive:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://discord.gg/k5AtFccjne&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://discord.gg/k5AtFccjne&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4380" LastEditorUserId="4380" LastEditDate="2022-03-18T10:18:38.267" LastActivityDate="2022-03-18T10:18:38.267" CommentCount="0" CommunityOwnedDate="2022-03-18T10:18:38.267" ContentLicense="CC BY-SA 4.0" />
  <row Id="8089" PostTypeId="1" AcceptedAnswerId="8095" CreationDate="2022-03-18T12:23:43.070" Score="8" ViewCount="260" Body="&lt;p&gt;Why is the tailing off effect only a problem in column generation? If all columns were pregenerated, and one used the simplex method, wouldn't one see the tailing off effect?&#xA;Is it simply not an issue because each iteration is so quick that it does not matter?&lt;/p&gt;&#xA;&lt;p&gt;If one made a figure with simplex iteration on the x-axis and objective function improvement on the y-axis, would the graph be a concave funtion converging towards 0? Wouldn't this be the same as the tailing off effect?&lt;/p&gt;&#xA;" OwnerUserId="9151" LastActivityDate="2023-04-02T19:54:40.467" Title="Why is the tailing off effect only a problem in column generation?" Tags="|column-generation|simplex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8090" PostTypeId="1" CreationDate="2022-03-18T15:30:35.697" Score="1" ViewCount="170" Body="&lt;p&gt;Suppose you have the following problem:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There are 100 basketball players : Player 1 is a pro, Player 100 has never played basketball before - and the rest follow some sort of Normal Distribution. However, let's assume we don't know this.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We have a lot of data (only the final game score) about games played between these players. For example, (Player 6 ,Player 51) beat (Player 8, Player 82, Player 75) with a score of 15-2. (Player 5) beat (Player 91, Player 92, Player 93, Player 94) with a score of 15-5. (Player 2, Player 3, Player 4) beat (Player 1) with a score of 15-11. Etc.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For simplicity sake, we can summarize games as : (Player 5) beat (Player 91, Player 92, Player 93, Player 94) = + 10 (i.e. 15 - 5 = 10)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The general goal of this problem is to find out:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Rank the players based on individual ability in order from best to worst&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I think this could be a difficult problem, because we don't always know if a player is good overall or only good because he is playing alongside good players. For example, suppose (Player 1, Player 100) often play on the same team - we have no way of knowing if Player 100 is equally contributing to the victories or if he just happens to be on the court and passively contributes.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Find out which &amp;quot;pairs of players&amp;quot; are better&lt;/strong&gt;: For example, (Player 71 and Player 43) are the best pair&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Find out which &amp;quot;triplets of players&amp;quot; are better&lt;/strong&gt;: For example, (Player 63 and Player 45, Player 9) are the best triplets&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This problem seems very difficult because there is no clear-cut way of isolating the skill of individual basketball players.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; Is there some optimization algorithm that can be used to &amp;quot;reverse engineer&amp;quot; and &amp;quot;untangle&amp;quot; the individual skills of basketball players - perhaps this problem could be framed as some sort of &amp;quot;Knapsack Optimization Problem&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;Could some algorithm try to scan through different combinations of the data and try to identify the &amp;quot;weakest links&amp;quot;? Something like&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Player 1 and Player 100 always do well together&lt;/li&gt;&#xA;&lt;li&gt;Player 1 always does well no matter who he is playing with or who is he playing against&lt;/li&gt;&#xA;&lt;li&gt;Player 100 does really bad when he plays with lower tier players&lt;/li&gt;&#xA;&lt;li&gt;Lower tier players generally perform poorly unless they are playing with upper tier players&lt;/li&gt;&#xA;&lt;li&gt;Therefore, Player 100 isn't likely a good player&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is there some algorithm that can solve a problem like this?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2022-03-18T18:39:37.473" LastActivityDate="2022-03-18T18:39:37.473" Title="Is this a version of the Knapsack Optimization Problem?" Tags="|optimization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8091" PostTypeId="2" ParentId="8090" CreationDate="2022-03-18T16:28:01.217" Score="3" Body="&lt;p&gt;I don't see how this is could be a knapsack problem if there are &amp;quot;second order&amp;quot; effects such as &amp;quot;Player 1 and Player 100 always do well together&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Even if you already have all possible playoffs results known a meaningfull way of ranking is not clear. It would also make a difference whether you want to find the best player against a particular team or the best players in general. If all possible &lt;span class=&quot;math-container&quot;&gt;$100*99*98*97*96*95=858277728000$&lt;/span&gt; 3-vs-3 playoffs results are known a robust way of ranking single players would be the winrate of teams which have that player.&lt;/p&gt;&#xA;&lt;p&gt;If you do not have all possible playoffs and making a playoff is expensive this fall under the discipline of &lt;a href=&quot;https://en.wikipedia.org/wiki/Optimal_design&quot; rel=&quot;nofollow noreferrer&quot;&gt;optimal experiment design&lt;/a&gt;. I am not aware of any model based approaches for that. Genetic algorithms would be worth looking into if you want to find good teams, however they will not yield much insight.&lt;/p&gt;&#xA;&lt;p&gt;One idea which is just barely at intersection of OR and machine learning would be to encode the features you are looking for in a mixed-integer model, such as players doing well together (f.e. quadratic terms) or how good certain players are and find a sparse models which does fit all the play-offs you did. Since you can solve this at different levels of sparsity you have multiple models which might disagree with eachother. If you have a point of disagreement you can then run that playoff until you are happy with the predictions. The idea to use sparse OR-style models to replace machine learning models is well explained in this talk &lt;a href=&quot;https://www.youtube.com/watch?v=axh1_ExNjQQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Scoring Systems: At the Extreme of Interpretable Machine Learning&lt;/a&gt;. I have not seen it used in a data generation loop i proposed and i have not tested this loop either. So it is indeed possible that you might invent novel methods to deal with your problem.&lt;/p&gt;&#xA;&lt;p&gt;Note that this entire reply doesn't address the stochastic nature (or influence of unobservable variables) which would be inherent to such a play off, as well as that players are not static but change with time. Dealing with these assumptions might additionally complicate the problem.&lt;/p&gt;&#xA;&lt;p&gt;I must agree with Prof. Rubin that this question is better addressed using machine learning tools. If you had a machine learning model with a satisfying performance you might also be able to recover a sparse model from which can derive the insights you are looking for.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-03-18T16:28:01.217" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8092" PostTypeId="1" CreationDate="2022-03-19T12:46:34.177" Score="-1" ViewCount="45" Body="&lt;p&gt;I don't know if I'm in the right place but I have a relevant problem. I need a dataset on drug supply shortages because I need it in my graduation thesis.&#xA;PS: I looked everywhere but couldn't find anything.&#xA;Please if you have any ideas where I can find some.&lt;/p&gt;&#xA;" OwnerUserId="9411" LastActivityDate="2022-03-19T16:15:19.107" Title="Supply Chain shortage drug Public Data Repository" Tags="|online-resources|supply-chain|data|" AnswerCount="1" CommentCount="0" ClosedDate="2022-03-29T07:18:55.770" ContentLicense="CC BY-SA 4.0" />
  <row Id="8093" PostTypeId="2" ParentId="8092" CreationDate="2022-03-19T16:15:19.107" Score="1" Body="&lt;p&gt;Try plugging &amp;quot;drug shortage&amp;quot; and similar phrases into Google's &lt;a href=&quot;https://datasetsearch.research.google.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;dataset search engine&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-19T16:15:19.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8094" PostTypeId="1" CreationDate="2022-03-19T18:26:18.630" Score="4" ViewCount="176" Body="&lt;p&gt;I have a fairly large network with eleven commodities and arc capacities that are commodity-dependent (i.e. an arc may have a higher capacity for one commodity than another). I'm solving a protection-interdiction-restoration problem using Benders' decomposition, and running into some initial error because (I believe) the network is unbalanced so there is unmet demand to start. What would be a potential way to check how the network is unbalanced? The supply and demand for each commodity are equal across the entire network, but there may be some issue with arc capacity or general connectivity.&lt;/p&gt;&#xA;" OwnerUserId="9334" LastActivityDate="2022-03-19T20:13:33.470" Title="How to fix unbalanced multi-commodity network flow with equal supply and demand?" Tags="|network-flow|multi-objective-optimization|benders-decomposition|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8095" PostTypeId="2" ParentId="8089" CreationDate="2022-03-19T19:42:55.300" Score="9" Body="&lt;p&gt;&amp;quot;Tailing-off effect&amp;quot; is a generic term that refers to an something like &amp;quot;the algorithm is hitting a plateau and progress becomes very slow towards the end&amp;quot;.&#xA;In other words: after some rapid progress in the beginning, the bulk of subsequent iterations only marginally improve the quality of your solution.&lt;/p&gt;&#xA;&lt;p&gt;It is not found only in column generation, but in virtually any and all optimization algorithms, whether it's gradient descent, simplex, Benders decomposition, etc.&lt;/p&gt;&#xA;&lt;p&gt;[some column generation-specific remarks are below]&lt;/p&gt;&#xA;&lt;p&gt;Here is an example for the simplex algorithm.&#xA;The following graphs show the progress made by Gurobi's dual simplex algorithm on the &lt;code&gt;braun&lt;/code&gt; instance from &lt;a href=&quot;http://plato.asu.edu/ftp/lpsimp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;H. Mittelmann's LP simplex benchmark&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FhQdN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FhQdN.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can see that, after about 750,000 iterations, the progress is much much slower when looking at the improvement in objective value. This could be referred to as tailing-off.&#xA;This same behavior can be visualized by plotting the relative objective gap over the iterations:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jIVrv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jIVrv.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here I defined the relative objective gap as &lt;span class=&quot;math-container&quot;&gt;$gap = \frac{|z_{k} - z^{*}|}{|z^{*}|}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$z_{k}$&lt;/span&gt; is the objective value at iteration &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z^{*}$&lt;/span&gt; is the optimal objective value.&#xA;Again, the gap barely improves after 750,000 iterations, and the subsequent iterations account for 25% of the total number of iterations.&lt;/p&gt;&#xA;&lt;p&gt;However, just because we don't have any &lt;em&gt;visible&lt;/em&gt; improvement, doesn't mean there's none. Indeed, let's look at the relative gap in logarithmic scale:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HxHvl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HxHvl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now the observation is reversed: the relative gap is decreased by 2 orders of magnitude in the first 750,000 iterations, and but 4 orders of magnitude in the last 250,000.&lt;/p&gt;&#xA;&lt;p&gt;The main point is that, even though we, as humans, don't see much improvement towards the end, progress is still being made. We're just not always looking at the right metric / scaling.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;A few column generation-specific remarks&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Tailing-off can be observed on both the primal side (solution objective value) and the dual side (dual bound).&lt;/li&gt;&#xA;&lt;li&gt;It is also possible to see that either bound &lt;strong&gt;does not&lt;/strong&gt; improve for a while, especially towards the end of the algorithm. This is often a combined effect of degeneracy and oscillation in the dual variables.&lt;/li&gt;&#xA;&lt;li&gt;One can look at the excellent &lt;a href=&quot;https://link.springer.com/book/10.1007/b135457&quot; rel=&quot;nofollow noreferrer&quot;&gt;Column Generation book&lt;/a&gt; by G. Desaulniers (especially the first and last chapters) for more in-depth discussion.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="500" LastEditDate="2023-04-02T19:54:40.467" LastActivityDate="2023-04-02T19:54:40.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8096" PostTypeId="2" ParentId="8094" CreationDate="2022-03-19T19:45:41.397" Score="3" Body="&lt;p&gt;From your question I gather that your problem instance is infeasible because your network capacities are not high enough. One easy trick is to include artificial arcs that directly connect a supply and a demand node. These artificial arcs have unlimited capacity (or capacity equal to the demand). Give these arcs a high cost (larger than the most expensive path that connects the supply and demand node pair in the original graph). That way, if the original network does not have enough capacity, some volume will be routed through the expensive artificial arcs and your solution is guaranteed to be feasible.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2022-03-19T19:45:41.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8097" PostTypeId="2" ParentId="8094" CreationDate="2022-03-19T20:13:33.470" Score="3" Body="&lt;p&gt;In addition to Joris's answer, another thing you might want to try is to solve a min cost flow problem on the network, without any interdiction threat and (importantly) without using Benders decomposition. If capacity is a bottleneck, this will identify it. If the min cost flow problem is feasible, then it may be that your Benders cuts are rendering the problem infeasible, in which case you might want to check that they are implemented correctly.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-19T20:13:33.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8098" PostTypeId="1" CreationDate="2022-03-20T00:43:51.993" Score="4" ViewCount="1779" Body="&lt;p&gt;When trying to solve for assignments given a cost matrix, what is the difference between&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;using Scipy's &lt;code&gt;linear_sum_assignment&lt;/code&gt; function (which I think uses the Hungarian method)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;describing the LP problem using a objective function with many boolean variables, add in the appropriate constraints and send it to a solver, such as through &lt;code&gt;scipy.optimize.linprog&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Is the later method slower than Hungarian method's &lt;code&gt;O(N^3)&lt;/code&gt; but allows for more constraints to be added?&lt;/p&gt;&#xA;" OwnerUserId="9412" LastEditorUserId="9412" LastEditDate="2022-03-20T00:53:13.797" LastActivityDate="2022-05-16T05:28:19.953" Title="Difference between solving Assignment Problem using the Hungarian Method vs. LP" Tags="|linear-programming|combinatorial-optimization|assignment-problem|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8099" PostTypeId="2" ParentId="7217" CreationDate="2022-03-20T04:38:27.813" Score="-3" Body="&lt;p&gt;If you are adding constraints to the master to ensure the subproblem is feasible you are básically adding the entire feasible region of the subproblem as constraints in the master, therefore you are defeating the point of doing the Benders partition in the first place.&lt;/p&gt;&#xA;" OwnerUserId="9413" LastActivityDate="2022-03-20T04:38:27.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8100" PostTypeId="2" ParentId="8098" CreationDate="2022-03-20T06:07:28.150" Score="7" Body="&lt;p&gt;The main differences probably are that there is a somewhat large overhead you have to pay when solving the AP as a linear program: You have to build an LP model and ship it to a solver. In addition, an LP solver is a generalist. It solves all LP problems and focus in development is to be fast on average on all LPs and also to be fast-ish in the pathological cases.&lt;/p&gt;&#xA;&lt;p&gt;When using the Hungarian method, you do not build a model, you just pass the cost matrix to a tailored algorithm. You will then use an algorithm developed for that specific problem to solve it. Hence, it will most likely solve it faster since it is a specialist.&lt;/p&gt;&#xA;&lt;p&gt;So if you want to solve an AP you should probably use the tailored algorithm. If you plan on extending your model to handle other more general constraints as well, you might need the LP after all.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; From a simple test in Python, my assumption is confirmed &lt;em&gt;in this specific setup&lt;/em&gt; (which is to the advantage of the Hungarian method, I believe). The set up is as follows:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A size is chosen in &lt;span class=&quot;math-container&quot;&gt;$n\in \{5,10,\dots,500\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;A cost matrix is generated. Each coefficient &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; is generated as a uniformly distributed integer in the range &lt;span class=&quot;math-container&quot;&gt;$[250,999]$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The instance is solved using both &lt;code&gt;linear_sum_assignment&lt;/code&gt; and as a linear program. The solution time is measured as wall clock time and only the time spent by &lt;code&gt;linear_sum_assignment&lt;/code&gt; and the &lt;code&gt;solve&lt;/code&gt; function is timed (not building the LP and not not generating the instance)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;For each size, I have generated and solved ten instances, and I report the average time only.&lt;/p&gt;&#xA;&lt;p&gt;And then there is of course the &amp;quot;but&amp;quot;. I am not a ninja in Python and I have used &lt;code&gt;pyomo&lt;/code&gt; for modelling the LPs. I believe that &lt;code&gt;pyomo&lt;/code&gt; is known to be slow-ish  whenbuilding models, hence I have only timed the &lt;code&gt;solver.solve(model)&lt;/code&gt; part of the code - not building the model. There is however possibly a hugh overhead cost coming from &lt;code&gt;pyomo&lt;/code&gt; translating the model to &amp;quot;gurobian&amp;quot; (I use gurobi as solver).&lt;/p&gt;&#xA;&lt;p&gt;A plot of the computation time (in seconds) as a function of the instance size is given below, and it is pretty clear, that the Hungarian algorithm implemented in &lt;code&gt;linear_sum_assignment&lt;/code&gt; is a lot faster than the &lt;code&gt;pyomo&lt;/code&gt;+gurobi approach:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/yr16z.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yr16z.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2022-05-16T05:28:19.953" LastActivityDate="2022-05-16T05:28:19.953" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8101" PostTypeId="1" AcceptedAnswerId="8103" CreationDate="2022-03-20T06:58:13.920" Score="3" ViewCount="171" Body="&lt;p&gt;In this example, we have a group of students that each needs to be paired with a teacher. Each student has a different number of questions to ask the teacher, and each student-teacher pairing has a different difficulty for their interactions.&lt;/p&gt;&#xA;&lt;p&gt;The workload for a teacher for a student-teacher pairing is given by the number of questions that the student has &lt;span class=&quot;math-container&quot;&gt;$Q_s$&lt;/span&gt; multiplied by the interaction difficulty &lt;span class=&quot;math-container&quot;&gt;$\beta_{s,t}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Q_s(\beta_{s,t})&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can we define the LP model for evenly distributing the workload across the teachers?&lt;/p&gt;&#xA;&lt;p&gt;Tried an objective function that minimizes&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{s=1}^{S} \sum_{t=1}^{T} Q_s(\beta_{s,t}) X_{s,t} \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$Q_s$&lt;/span&gt; is the number of questions a student &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; has,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta_{s,t}$&lt;/span&gt; is the difficulty of interaction between student &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and teacher &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{s,t}$&lt;/span&gt; is a binary variable that shows whether student &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is assigned to teacher &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, the results does not suggest that the workload for each teacher &lt;span class=&quot;math-container&quot;&gt;$\sum_{s=1}^{S} Q_s(\beta_{s,t}) X_{s,t}$&lt;/span&gt; is evenly distributed.&lt;/p&gt;&#xA;&lt;p&gt;Is there a better objective function to achieve this?&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Note: I'm doing this in Python with PuLP and Scipy&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="9412" LastEditorUserId="9412" LastEditDate="2022-03-20T07:04:58.317" LastActivityDate="2022-03-20T15:43:10.370" Title="LP Objective function for distributing workload" Tags="|linear-programming|integer-programming|combinatorial-optimization|assignment-problem|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8102" PostTypeId="2" ParentId="5256" CreationDate="2022-03-20T08:59:15.247" Score="1" Body="&lt;p&gt;As stated in the official tutorials, in order to set pickup and deliveries you must use routing.AddPickupAndDelivery() for each pickup-delivery pair, otherwise the optimization process cannot find a solution efficiently.&#xA;since we are dealing with multiple pickup options, instead of AddPickupAndDelivery, we must use routing.AddPickupAndDeliverySets() which accepts two disjunction indices as parameters.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;....&#xA;pickup_disjuncton_index = self.routing.AddDisjunction(all_pickups, 0)&#xA;          &#xA;delivery_index = self.manager.NodeToIndex(delivery_node)&#xA;&#xA;delivery_disjunction_index = self.routing.AddDisjunction([delivery_index], -1)  # Negative penalty forces the algorithm to visit the node.&#xA;&#xA;self.routing.AddPickupAndDeliverySets(pickup_disjunction_index, delivery_disjunction_index)&#xA;&#xA;self.routing.solver().Add(&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9414" LastActivityDate="2022-03-20T08:59:15.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8103" PostTypeId="2" ParentId="8101" CreationDate="2022-03-20T15:43:10.370" Score="3" Body="&lt;p&gt;There are a number of ways to approach this. One would be to minimize the sum of absolute deviations from the overall average load. To do this, add variables &lt;span class=&quot;math-container&quot;&gt;$L_t \ge 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_t$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$t=1,\dots,T$&lt;/span&gt;) plus one more variable &lt;span class=&quot;math-container&quot;&gt;$\bar{L}\ge 0.$&lt;/span&gt; New constraints are &lt;span class=&quot;math-container&quot;&gt;$$L_t = \sum_{s=1}^S \beta_{s,t}Q_sX_{s,t}\quad \forall t\in \lbrace1,\dots,T\rbrace$$&lt;/span&gt; (making &lt;span class=&quot;math-container&quot;&gt;$L_t$&lt;/span&gt; the load on teacher &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;), &lt;span class=&quot;math-container&quot;&gt;$$\bar{L}=\frac{1}{T}\sum_{t=1}^T L_t$$&lt;/span&gt; (making &lt;span class=&quot;math-container&quot;&gt;$\bar{L}$&lt;/span&gt; the average load across all teachers), and &lt;span class=&quot;math-container&quot;&gt;$$d_t \ge L_t - \bar{L}\quad \forall t$$&lt;/span&gt;&lt;span class=&quot;math-container&quot;&gt;$$d_t \ge \bar{L} - L_t\quad \forall t.$$&lt;/span&gt;The last two constraints ensure that &lt;span class=&quot;math-container&quot;&gt;$d_t \ge \vert L_t - \bar{L} \vert.$&lt;/span&gt; Now minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_t d_t$&lt;/span&gt; to get a solution that minimizes the sum of absolute deviations from mean load.&lt;/p&gt;&#xA;&lt;p&gt;Other possibilities include minimizing the sum of squared deviations (i.e., use &lt;span class=&quot;math-container&quot;&gt;$L_2$&lt;/span&gt; norm instead of &lt;span class=&quot;math-container&quot;&gt;$L_1$&lt;/span&gt; norm) or the single biggest deviation from mean (&lt;span class=&quot;math-container&quot;&gt;$L_\infty$&lt;/span&gt; norm). It is worth noting that the solution using any of these objectives (or others proposed in comments) may be inefficient in that the total time spent by all teachers might be higher than necessary, in order to get closer to parity.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-20T15:43:10.370" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8104" PostTypeId="1" AcceptedAnswerId="8119" CreationDate="2022-03-20T17:42:42.803" Score="3" ViewCount="544" Body="&lt;p&gt;I am testing to see if my network is balanced as part of a larger protection-interdiction-restoration problem. To do this, I'm solving the problem as a minimum cost network flow problem to see if the network is balanced initially. I'm returning that the network is infeasible when I run it, but I'm not sure if it's because I formulated the constraints wrong or because it's genuinely unfeasible.  Here's my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;import csv&#xA;import csv&#xA;from math import *&#xA;import numpy as np&#xA;from gurobipy import quicksum&#xA;&#xA;# input arcs names&#xA;arccap = open('C:/Users/Emma/Documents/2021-2022/Thesis/Data/poweronly/arcs-smallp.csv', 'r', encoding='utf-8-sig')&#xA;csv_arccap = csv.reader(arccap)&#xA;mydict_arccap = {}&#xA;for row in csv_arccap:&#xA;     mydict_arccap[(row[0],row[1])] = float(row[2])&#xA;        &#xA;arcs, capacity = gp.multidict(mydict_arccap)&#xA;&#xA;#import nodes&#xA;# input arcs names&#xA;inflow = open('C:/Users/Emma/Documents/2021-2022/Thesis/Data/poweronly/inflow.csv', 'r', encoding='utf-8-sig')&#xA;csv_inflow = csv.reader(inflow)&#xA;mydict_inflow = {}&#xA;for row in csv_inflow:&#xA;     mydict_inflow[(row[0])] = float(row[1])&#xA;&#xA;nodes, inflow = gp.multidict(mydict_inflow)&#xA;&#xA;# set cost of all arcs = 1&#xA;arccost = open('C:/Users/Emma/Documents/2021-2022/Thesis/Data/poweronly/arcs-smallp.csv', 'r', encoding='utf-8-sig')&#xA;csv_arccost = csv.reader(arccost)&#xA;mydict_arccost = {}&#xA;for row in csv_arccost:&#xA;     mydict_arccost[(row[0],row[1])] = float(row[3])&#xA;        &#xA;arcs, cost = gp.multidict(mydict_arccost)&#xA;&#xA;&#xA;# Create optimization model&#xA;m = gp.Model('netflow')&#xA;&#xA;# Create variables&#xA;flow = m.addVars(arcs, obj=cost, name=&amp;quot;flow&amp;quot;)&#xA;&#xA;# flow on single arc cannot exceed capacity&#xA;m.addConstrs(&#xA;    (flow.sum(i, j) &amp;lt;= capacity[i, j] for i, j in arcs), &amp;quot;cap&amp;quot;)&#xA;&#xA;# flow into/out of node must equal supply, demand, or zero for transshipment&#xA;m.addConstrs(&#xA;  (gp.quicksum(flow[i, j] for i, j in arcs.select('*', j)) + inflow[j] ==&#xA;    gp.quicksum(flow[j, k] for j, k in arcs.select(j, '*')) for j in nodes), &amp;quot;node&amp;quot;)&#xA;&#xA;# Compute optimal solution&#xA;m.optimize()&#xA;&#xA;# Print solution&#xA;if m.status == GRB.OPTIMAL:&#xA;    solution = m.getAttr('x', flow)&#xA;    for i, j in arcs:&#xA;        if solution[i, j] &amp;gt; 0:&#xA;            print('%s -&amp;gt; %s: %g' % (i, j, solution[i, j]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And my output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    Gurobi Optimizer version 9.5.1 build v9.5.1rc2 (win64)&#xA;Thread count: 4 physical cores, 8 logical processors, using up to 8 threads&#xA;Optimize a model with 298 rows, 179 columns and 537 nonzeros&#xA;Model fingerprint: 0x93312151&#xA;Coefficient statistics:&#xA;  Matrix range     [1e+00, 1e+00]&#xA;  Objective range  [1e+00, 1e+00]&#xA;  Bounds range     [0e+00, 0e+00]&#xA;  RHS range        [9e-01, 2e+04]&#xA;Presolve removed 0 rows and 2 columns&#xA;Presolve time: 0.01s&#xA;&#xA;Solved in 0 iterations and 0.01 seconds (0.00 work units)&#xA;Infeasible model&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Two questions : is this model set up correctly, and if it is genuinely unfeasible, how do I see in what way it's infeasible? Right not the &amp;quot;inflow&amp;quot; parameter has negative values for demand nodes, positive values for supply, and zero values for transshipment nodes.&lt;/p&gt;&#xA;" OwnerUserId="9334" LastEditorUserId="9334" LastEditDate="2022-03-20T21:06:11.490" LastActivityDate="2022-03-22T03:33:04.837" Title="How to see constraint violation for network flow problem" Tags="|optimization|linear-programming|gurobi|network-flow|irreducible-infeasible-subset|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8105" PostTypeId="2" ParentId="8104" CreationDate="2022-03-20T18:01:51.523" Score="3" Body="&lt;p&gt;Below constraint of flow restriction on an arc need not be summed as it is a restriction at an arc level&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;m.addConstrs(&#xA;(flow.sum(i, j) &amp;lt;= capacity[i, j] for i, j in arcs), &amp;quot;cap&amp;quot;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;hence,it has to be corrected to below:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;m.addConstr((flow[i,j] &amp;lt;= capacity[i,j] for i,j in arcs),&amp;quot;cap&amp;quot;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2022-03-20T18:01:51.523" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8106" PostTypeId="1" CreationDate="2022-03-20T18:50:11.870" Score="6" ViewCount="107" Body="&lt;p&gt;Dual instability, degeneracy, and the tailing off effect are often mentioned together in papers. However, I cannot seem to find a clear explanation on which of these cause the other and vice versa? How are they connected? Are there any other phenomena that should be included in the mix to explain the chain of effects?&lt;/p&gt;&#xA;" OwnerUserId="9151" LastEditorUserId="562" LastEditDate="2022-03-20T21:09:58.113" LastActivityDate="2022-03-20T21:09:58.113" Title="Dual instability, degeneracy, tailing off effect - Which are the causes and which are the effects?" Tags="|linear-programming|column-generation|simplex|dantzig-wolfe-decomposition|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8107" PostTypeId="2" ParentId="8104" CreationDate="2022-03-20T19:28:26.757" Score="3" Body="&lt;p&gt;There are a number of things you can try.&lt;/p&gt;&#xA;&lt;p&gt;First, the Gurobi output says the lower limit on right-hand side values is 7e-16, rather than zero, which looks a bit suspicious to me. You might want to track down where that occurs and see if the constraint has any visible issues.&lt;/p&gt;&#xA;&lt;p&gt;Next, you can ask Gurobi for an &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_model_computeiis.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;irreducible infeasible subset&lt;/a&gt; (IIS) of constraints and variable bounds. If there is a problem with the model, it will be in one of those constraints or bounds.&lt;/p&gt;&#xA;&lt;p&gt;If you know what should be a feasible solution (no matter how poor in objective terms), you can try fixing all the variables to their values in that solution (by setting lower bound = upper bound = value) and running the solver. Assuming it still says infeasible, get an IIS and check the constraints in the set by substituting your feasible solution and seeing what goes wrong.&lt;/p&gt;&#xA;&lt;p&gt;If you do not know a feasible solution, yet another possibility is to construct a small test problem for which you do know a feasible solution and try that (same code, different input files). There is no guarantee that whatever problem the model has will render your test case infeasible, but if it does you can use the previous approach.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-20T19:28:26.757" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8108" PostTypeId="2" ParentId="8104" CreationDate="2022-03-20T20:46:45.873" Score="2" Body="&lt;p&gt;The first thing to check: in order for a network flow model to be feasible, the sum of supplies and demands over all nodes must be zero.&lt;/p&gt;&#xA;&lt;p&gt;If you know that test passes, then you can start to find an initial feasible flow. You can fail if the search algorithm concludes that there is no way to flow all the supply through the network in order to satisfy all the demand. That can happen if there is a cut separating supply nodes from some set of demand nodes with a capacity smaller than the amount of the cut-off demand.&lt;/p&gt;&#xA;" OwnerUserId="165" LastActivityDate="2022-03-20T20:46:45.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8109" PostTypeId="1" CreationDate="2022-03-20T21:42:52.807" Score="2" ViewCount="299" Body="&lt;p&gt;I am modeling a problem similar to the job shop problem (tasks with start times, duration, and predecessors) and my objective is to minimize the makespan, with Python and OR-Tools.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;start[i]&lt;/strong&gt; is an integer decision variable that shows the period when task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; starts&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;start[1] = 3&lt;/code&gt; &lt;span class=&quot;math-container&quot;&gt;$\Rightarrow$&lt;/span&gt; task 1 starts on period 3&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;duration[i]&lt;/strong&gt; is a parameter that is the task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; duration (and is known)&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;duration [1] = 2&lt;/code&gt; &lt;span class=&quot;math-container&quot;&gt;$\Rightarrow$&lt;/span&gt;  task 1 takes 2 period to be completed&lt;/p&gt;&#xA;&lt;p&gt;Now I want to integrate a cost function where if a task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; starts on a specific period and ends on period &lt;code&gt;start[i]+duration[i]&lt;/code&gt;, the cost will be the sum of every period it's being worked on.&lt;/p&gt;&#xA;&lt;p&gt;I have a cost matrix:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Cost[i,j] = [[ 1, 2, 3, 6, 8], &#xA;             [5, 6, 7, 2, 1]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;cost[1,1]&lt;/strong&gt; is the cost for task 1 if it's being worked on during period 1&lt;/p&gt;&#xA;&lt;p&gt;So if task 1 has a duration of 2, and starts on period 1, then periods 1,2,3 will be the target periods, and the cost will be &lt;code&gt;cost[1,1]+cost[1,2]+cost[1,3] = 1+2+3&lt;/code&gt; from the cost matrix.&lt;/p&gt;&#xA;&lt;p&gt;I tried creating a binary matrix &lt;code&gt;BIN[i,start[i]:start[i]+duration[i]]&lt;/code&gt; that uses &lt;code&gt;start[i]&lt;/code&gt; and &lt;code&gt;duration[i]&lt;/code&gt; and returns a  style matrix, where 1 if the task is in progress and 0 if not, so then I can pass the &lt;code&gt;cost[i,j]&lt;/code&gt; and find the total cost for a scenario.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;total_cost = model.NewIntVar(0,99999,'total_cost')&#xA;b = model.newboolvar('b')&#xA;    for i in range(alltasks):&#xA;        model.Add(start[i] != 0).OnlyEnforceIf(b)&#xA;        model.Add(start[i] == 0).OnlyEnforceIf(b.Not())&#xA;&#xA;        model.Add(total_cost == sum(Cost*b)).OnlyEnforceIf(b)&#xA;        model.Add(total_cost == 0).OnlyEnforceIf(b.Not()) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But that doesn't work at all...&lt;/p&gt;&#xA;&lt;p&gt;If it can help in the understanding: My goal is to make the model choose the best period to start/end on a period knowing the duration is fixed and there is a cost to each period that this task will be worked on (so to reduce the cost)&lt;/p&gt;&#xA;" OwnerUserId="9417" LastEditorUserId="491" LastEditDate="2022-03-21T13:40:34.390" LastActivityDate="2022-03-21T13:40:34.390" Title="OR-Tools Cost Function Integration" Tags="|python|or-tools|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8110" PostTypeId="1" CreationDate="2022-03-20T22:00:06.030" Score="1" ViewCount="153" Body="&lt;p&gt;I'm running a simple MCNF model to see if my network is balanced. I'm using Gurboi in Python and with the IIS I can see that there are 2 constraint violations making it infeasible. How do I fix these constraint violations without changing the overall supply or demand?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;import csv&#xA;import csv&#xA;from math import *&#xA;import numpy as np&#xA;from gurobipy import quicksum&#xA;&#xA;# input arcs names&#xA;arccap = open('C:/Users/Emma/Documents/2021-2022/Thesis/Data/poweronly/arcs-smallp2.csv', 'r', encoding='utf-8-sig')&#xA;csv_arccap = csv.reader(arccap)&#xA;mydict_arccap = {}&#xA;for row in csv_arccap:&#xA;     mydict_arccap[(row[0],row[1])] = float(row[2])&#xA;        &#xA;arcs, capacity = gp.multidict(mydict_arccap)&#xA;&#xA;#import nodes&#xA;# input arcs names&#xA;inflow = open('C:/Users/Emma/Documents/2021-2022/Thesis/Data/poweronly/inflow2.csv', 'r', encoding='utf-8-sig')&#xA;csv_inflow = csv.reader(inflow)&#xA;mydict_inflow = {}&#xA;for row in csv_inflow:&#xA;     mydict_inflow[(row[0])] = float(row[1])&#xA;&#xA;nodes, inflow = gp.multidict(mydict_inflow)&#xA;&#xA;# set cost of all arcs = 1&#xA;arccost = open('C:/Users/Emma/Documents/2021-2022/Thesis/Data/poweronly/arcs-smallp2.csv', 'r',encoding='utf-8-sig')&#xA;csv_arccost = csv.reader(arccost)&#xA;mydict_arccost = {}&#xA;for row in csv_arccost:&#xA;     mydict_arccost[(row[0],row[1])] = float(row[3])&#xA;        &#xA;arcs, cost = gp.multidict(mydict_arccost)&#xA;&#xA;&#xA;# Create optimization model&#xA;m = gp.Model('netflow')&#xA;&#xA;# Create variables&#xA;flow = m.addVars(arcs, obj=cost, name=&amp;quot;flow&amp;quot;)&#xA;&#xA;# flow on single arc cannot exceed capacity&#xA;m.addConstrs((flow[i,j] &amp;lt;= capacity[i,j] for i,j in arcs),&amp;quot;cap&amp;quot;)&#xA;&#xA;# flow into/out of node must equal supply, demand, or zero for transshipment&#xA;m.addConstrs(&#xA;  (gp.quicksum(flow[i, j] for i, j in arcs.select('*', j)) + inflow[j] ==&#xA;    gp.quicksum(flow[j, k] for j, k in arcs.select(j, '*')) for j in nodes), &amp;quot;node&amp;quot;)&#xA;&#xA;# Compute optimal solution&#xA;m.optimize()&#xA;&#xA;# Print solution&#xA;if m.status == GRB.OPTIMAL:&#xA;    solution = m.getAttr('x', flow)&#xA;    for i, j in arcs:&#xA;        if solution[i, j] &amp;gt; 0:&#xA;            print('%s -&amp;gt; %s: %g' % (i, j, solution[i, j]))&#xA;m.computeIIS() &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Gurobi Optimizer version 9.5.1 build v9.5.1rc2 (win64)&#xA;Thread count: 4 physical cores, 8 logical processors, using up to 8 threads&#xA;Optimize a model with 298 rows, 179 columns and 537 nonzeros&#xA;Model fingerprint: 0x93312151&#xA;Coefficient statistics:&#xA;  Matrix range     [1e+00, 1e+00]&#xA;  Objective range  [1e+00, 1e+00]&#xA;  Bounds range     [0e+00, 0e+00]&#xA;  RHS range        [9e-01, 2e+04]&#xA;Presolve removed 0 rows and 2 columns&#xA;Presolve time: 0.00s&#xA;&#xA;Solved in 0 iterations and 0.00 seconds (0.00 work units)&#xA;Infeasible model&#xA;&#xA;IIS computed: 2 constraints and 2 bounds&#xA;IIS runtime: 0.00 seconds (0.00 work units)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Edit:&#xA;I was able to produce a .lp log with the following results. What does it mean and how do I fix it?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\ Model netflow_copy&#xA;\ LP format - for model browsing. Use MPS format to capture full model detail.&#xA;Minimize&#xA; &#xA;Subject To&#xA; node[1]: flow[3,1] = 500&#xA; node[3]: - flow[3,1] - flow[3,4] - flow[3,12] = 525&#xA;Bounds&#xA; flow[3,1] free&#xA;End&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9334" LastEditorUserId="500" LastEditDate="2022-03-21T00:04:04.940" LastActivityDate="2022-03-21T00:04:04.940" Title="How to see fix constraint violations found with IIS" Tags="|python|gurobi|network-flow|irreducible-infeasible-subset|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8111" PostTypeId="2" ParentId="8109" CreationDate="2022-03-21T09:11:48.557" Score="1" Body="&lt;p&gt;If the duration is fixed, then the cost is only a function of the start.&lt;/p&gt;&#xA;&lt;p&gt;I recommend looking at this &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/sat/docs/integer_arithmetic.md#step-function&quot; rel=&quot;nofollow noreferrer&quot;&gt;code sample&lt;/a&gt; on how to encode a step function.&#xA;You can also just use an Element constraint.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2022-03-21T09:11:48.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8112" PostTypeId="1" CreationDate="2022-03-21T14:28:39.453" Score="2" ViewCount="213" Body="&lt;p&gt;I am using python for CP solving.&#xA;I would like to know if there is constraint that does the opposite of no_overlap.&#xA;This will be like&#xA;overlap(&lt;em&gt;interval, arr, n&lt;/em&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;interval&lt;/em&gt; - single interval variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;arr&lt;/em&gt; - array of interval variables&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;n&lt;/em&gt; - positive integer less than length of &lt;em&gt;arr&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;this will mean that atleast &lt;em&gt;n&lt;/em&gt; interval variables from &lt;em&gt;arr&lt;/em&gt; overlap in the interval of &lt;em&gt;interval&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is for a situation in job scheduling when a job is not possible to be scheduled on a machine because there are already &lt;em&gt;n&lt;/em&gt; higher priority jobs.&lt;/p&gt;&#xA;" OwnerUserId="899" LastActivityDate="2022-03-22T06:52:13.267" Title="opposite of no_overlap constraint in docplex for CP" Tags="|python|scheduling|constraint-programming|docplex|job-shop-scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8113" PostTypeId="2" ParentId="8112" CreationDate="2022-03-21T15:06:42.083" Score="4" Body="&lt;p&gt;You can use &lt;a href=&quot;https://ibmdecisionoptimization.github.io/docplex-doc/cp/docplex.cp.modeler.py.html?highlight=overlap_length#docplex.cp.modeler.overlap_length&quot; rel=&quot;nofollow noreferrer&quot;&gt;overlap_length&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;docplex.cp.modeler.overlap_length(interval, interval2, absentValue=None)&#xA;&#xA;    Returns the length of the overlap of two interval variables.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and &lt;a href=&quot;https://github.com/AlexFleischerParis/zoodocplex/blob/master/zoocounttrueconstraints.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;count true constraints&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;# Data&#xA;&#xA;Buses=[&#xA;    (40,500),&#xA;    (30,400),&#xA;    (35,450),&#xA;    (20,300)&#xA;    ]&#xA;&#xA;nbKids=300&#xA;&#xA;# Indexes&#xA;&#xA;busSize=0;&#xA;busCost=1;&#xA;&#xA;for b in Buses:&#xA;    print(&amp;quot;buses with &amp;quot;,b[busSize],&amp;quot; seats cost &amp;quot;,b[busCost])&#xA;&#xA;print()    &#xA;&#xA;mdl = Model(name='buses')&#xA;&#xA;#decision variables&#xA;mdl.nbBus=mdl.integer_var_dict(Buses,name=&amp;quot;nbBus&amp;quot;)&#xA;&#xA;# Constraint&#xA;mdl.add_constraint(mdl.sum(mdl.nbBus[b]*b[busSize] for b in Buses) &amp;gt;= nbKids, 'kids')&#xA;&#xA;# Objective&#xA;mdl.minimize(sum(mdl.nbBus[b]*b[busCost] for b in Buses))&#xA;&#xA;mdl.solve()&#xA;&#xA;# Display solution&#xA;for b in Buses:&#xA;    print(mdl.nbBus[b].solution_value,&amp;quot; buses with &amp;quot;,b[busSize],&amp;quot; seats&amp;quot;);&#xA;&#xA;#Add a constraint&#xA;# Number of sizes where we have 1 or 2 buses should be at least 3&#xA;&#xA;mdl.add(mdl.sum(mdl.logical_and(1&amp;lt;=mdl.nbBus[b],mdl.nbBus[b]&amp;lt;=2) for b in Buses) &amp;gt;=3)&#xA;&#xA;mdl.solve()&#xA;&#xA;print()&#xA;print(&amp;quot;Number of sizes where we have 1 or 2 buses should be at least 3&amp;quot;)&#xA;print()&#xA;&#xA;# Display solution&#xA;for b in Buses:&#xA;    print(mdl.nbBus[b].solution_value,&amp;quot; buses with &amp;quot;,b[busSize],&amp;quot; seats&amp;quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;in OPL I would write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using CP;&#xA;&#xA;int N=4;&#xA;int n=2;&#xA;dvar interval itvs;&#xA;dvar interval arr[1..N];&#xA;&#xA;subject to&#xA;{&#xA;  (sum(i in 1..N) (1&amp;lt;=overlapLength(itvs,arr[i])))&amp;gt;=n;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and the same can be done with all APIs&lt;/p&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2022-03-22T06:52:13.267" LastActivityDate="2022-03-22T06:52:13.267" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8114" PostTypeId="1" CreationDate="2022-03-22T01:00:36.513" Score="3" ViewCount="206" Body="&lt;p&gt;I have been fascinated by the &lt;em&gt;&lt;strong&gt;rise and fall of graph cut algorithms&lt;/strong&gt;&lt;/em&gt; in recent years, which I described in this question: &lt;a href=&quot;https://or.stackexchange.com/q/2869/727&quot;&gt;Was there something specific that caused graph cuts to lose popularity in the last 5 years?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;On that question, I received an answer from an expert in the field. The main reason given for the &lt;em&gt;&lt;strong&gt;drop&lt;/strong&gt;&lt;/em&gt; in popularity of these algorithms, was the fact that graph cuts were mainly used for problems that &lt;strong&gt;deep neural networks are now able to solve more accurately, without the need for optimization&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But graph cuts were &lt;em&gt;&lt;strong&gt;immensely&lt;/strong&gt;&lt;/em&gt; popular during their heyday, and lead to many developments in mathematics (such as &lt;a href=&quot;https://or.stackexchange.com/questions/799/what-is-quadratization&quot;&gt;quadratization&lt;/a&gt;, as most &lt;a href=&quot;https://or.stackexchange.com/q/1380/727&quot;&gt;applications of quadratization&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/q/828/727&quot;&gt;QUBO&lt;/a&gt; involve graph cuts). I would be amazed if nothing they provided us can beat neural networks for a useful problem. 2015 was not long ago, and in that year papers on graph cuts like &lt;a href=&quot;https://scholar.google.com/citations?view_op=view_citation&amp;amp;hl=en&amp;amp;user=8Lp0W54AAAAJ&amp;amp;citation_for_view=8Lp0W54AAAAJ:u5HHmVD_uO8C&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt; got almost 1000 citations in a single year alone! (more than some researchers get across all of their papers in a lifetime).&lt;/p&gt;&#xA;&lt;p&gt;This makes me wonder: Is there any reason why I would &lt;em&gt;&lt;strong&gt;rather use graph cuts&lt;/strong&gt;&lt;/em&gt; than deep learning?&lt;/p&gt;&#xA;" OwnerUserId="727" LastActivityDate="2022-03-22T01:00:36.513" Title="What can traditional graph cut methods do well, that deep learning cannot?" Tags="|optimization|combinatorial-optimization|graphs|applications|machine-learning|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8115" PostTypeId="1" AcceptedAnswerId="8116" CreationDate="2022-03-22T02:41:49.490" Score="3" ViewCount="95" Body="&lt;p&gt;I have a larger model with a large number of binary variables among many others. For the purpose of this question, consider the effect that the binary variables impose on the model to be similar to that of a Knapsack. The variable considers to take a certain item or not and in general taking an item provides a certain benefit. However, due to the rest of the model, the change is of course more complex. The overall size and complexity of the model makes it quite difficult to identify the right items to be taken, so I introduced some dependencies among the variables that may alter the optimal solution, but which led me to the idea of adding further variables and dependencies that do not affect the optimal solution. I was wondering on the effect of solving the model by introducing additional artificial binary variables that cluster the actual variables, by means of logical-or connections. More concretely, let's consider these two models&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max c^T \cdot x \\&#xA;\text{s.t. } w^T \cdot x \leq W \\&#xA;x_i \in \{0, 1\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max c^T \cdot x \\&#xA;\text{s.t. } w^T \cdot x \leq W \\&#xA;y_k \geq x_i \quad \forall \, k, i \in H_k \\&#xA;y_k \leq \sum_{i \in H_k} x_i \\&#xA;x_i \in \{0, 1\} \\&#xA;y_k \in \{0, 1\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can there be a positive effect for solving the second model at all? And if yes, what would be the conditions (supposedly concerning &lt;span class=&quot;math-container&quot;&gt;$H_k$&lt;/span&gt;, but also the branching strategy of the solver) for such a positive effect? Or would presolve just eliminate all &lt;span class=&quot;math-container&quot;&gt;$y_k$&lt;/span&gt; anyway?&lt;/p&gt;&#xA;" OwnerUserId="242" LastEditorUserId="242" LastEditDate="2022-03-22T03:39:02.400" LastActivityDate="2022-03-22T03:39:02.400" Title="Are there examples where introducing clusters of binary variables provides a benefit for solving?" Tags="|linear-programming|modeling|integer-programming|binary-variable|knapsack|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8116" PostTypeId="2" ParentId="8115" CreationDate="2022-03-22T03:24:43.207" Score="2" Body="&lt;p&gt;Whether a presolver would eliminate the &lt;span class=&quot;math-container&quot;&gt;$y_k$&lt;/span&gt; would depend on how the presolver was programmed. Assuming the variables survived presolve, giving the &lt;span class=&quot;math-container&quot;&gt;$y_k$&lt;/span&gt; higher priority than the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; in branching would be similar to using a custom branching scheme in which early nodes are partitioned using &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in H_k} x_i \ge 1$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in H_k} x_i \le 0$$&lt;/span&gt;for some &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. (I said &amp;quot;similar&amp;quot; rather than &amp;quot;identical&amp;quot; because I'm not sure all solvers would treat branching priorities as absolute, whereas you would presumably have full control over a custom branching scheme.)&lt;/p&gt;&#xA;&lt;p&gt;Whether it would help is an empirical question. In a simple knapsack problem, I would be surprised if it did, but in a more complex model it perhaps might be productive &lt;em&gt;if&lt;/em&gt; the variable sets were defined in such a way that knowing at least one &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; took value 1 for &lt;span class=&quot;math-container&quot;&gt;$i\in H_k$&lt;/span&gt; did something significant in reducing the solution space (tightened the bound significantly, forced other variables to be either 0 or 1, ...).&lt;/p&gt;&#xA;&lt;p&gt;I have to disagree with the contention that the added binary variables and constraints &amp;quot;may result in loss of the optimal solution&amp;quot;. At least as you implemented them in the example, the projection onto the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; space of the solution space of the expanded model is the same as the solution space of the original model.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-22T03:24:43.207" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8117" PostTypeId="6" CreationDate="2022-03-22T03:27:35.213" Score="0" Body="&lt;h1&gt;Nike Dattani&lt;/h1&gt;&#xA;&lt;p&gt;Hello! I hold a PhD from Oxford University and do research in combinatorial optimization, graph theory for discrete optimization, and high-performance computing, among other areas. I wrote a &lt;strong&gt;&lt;a href=&quot;https://arxiv.org/abs/1901.04405&quot; rel=&quot;nofollow noreferrer&quot;&gt;book&lt;/a&gt;&lt;/strong&gt; on the quadratization of high-degree optimization problems into easier (quadratic) ones that have the same optimum.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/review/first-answers/stats&quot;&gt;I'm #3 behind only EhsanK and TheSimpliFire for first answer reviews&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I've been online at SE every day for many years, and will be available to help you quickly whenever you need anything. If you need to talk to me privately, you can always email me at nike@hpqc.org or ndattani@uwaterloo.ca. I welcome you to ping me in chat if you ever want to talk about anything! I'm also on the OR Discord (using my real name, in case you want to find me there).&lt;/p&gt;&#xA;&lt;p&gt;Thank you for considering me!&lt;/p&gt;&#xA;&lt;p&gt;Here's some sample posts of mine here, which have attracted high scores:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/q/828/727&quot;&gt;What are some real-world applications of QUBO?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/q/1380/727&quot;&gt;Are there any real-world problems where quadratization helps to solve something that couldn&amp;#39;t have been solved without quadratization?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/q/2869/727&quot;&gt;Was there something specific that caused graph cuts to lose popularity in the last 5 years?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="727" LastEditorUserId="727" LastEditDate="2022-03-22T03:27:35.213" LastActivityDate="2022-03-22T03:27:35.213" CommentCount="0" CommunityOwnedDate="2022-03-22T03:27:35.213" ContentLicense="CC BY-SA 4.0" />
  <row Id="8119" PostTypeId="2" ParentId="8104" CreationDate="2022-03-22T03:33:04.837" Score="1" Body="&lt;p&gt;Similar to the comment by @prubin I would recommend to create a small scale test problem by providing some simpler csv that you know are feasible. Then you can validate your model. With a valid model you can proceed to find out why your data may be invalid.&lt;/p&gt;&#xA;&lt;p&gt;I'd suggest to code some basic data validation. Given your problem the following rules must hold&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;total demand needs to be equal to total supply (resp. the absolute values of those)&lt;/li&gt;&#xA;&lt;li&gt;the sum of all incoming or outgoing arcs into a supply or demand node must be at least as large as to accomodate the respective inflow&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Furthermore, you could also first try to solve a pure maxflow prior to treating it as mincost-maxflow. Transform your graph into a network with just one source node that connects to all supply nodes with arcs having capacity equal to the supply. Then connect all demand nodes with a target node with arcs' capacity equal to the demand (respectively its absolute value). The respective maxflow should saturate all the arcs that you have added, i.e., maxflow = total demand. Otherwise, your network's capacity is too small.&lt;/p&gt;&#xA;&lt;p&gt;When solving the maxflow yields that the network's capacity is large enough, you can add the demand/supply into the flow equation and solve it as the final mincost-maxflow problem that you intended to do.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively to solving your problem as maxflow first, you can also add some variables to relax the flow conservation constraint in your existing formulation. E.g. which add or subtract an additional amount so that the model can become feasible even when inflow would not be. However, I'd suggest to make these variables just positive and apply the inflow always on the respective side of the equation where it would be negative. You can then bound each variable in the range of the inflow. Finally, you'd add them to the objective function with a high penalty term so that the solver needs to set these to 0 to achieve the feasible optimal solution. Then it's easy to check if your model would be infeasible in the original formulation by comparing whether any of those relaxation variables is non-zero.&lt;/p&gt;&#xA;" OwnerUserId="242" LastActivityDate="2022-03-22T03:33:04.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8120" PostTypeId="1" AcceptedAnswerId="8121" CreationDate="2022-03-22T10:55:20.820" Score="7" ViewCount="926" Body="&lt;p&gt;I have a problem with understanding the following mathematical model of the TSP.&#xA;Given that the TSP is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i,j\in N} d_{i,j} \cdot x_{i,j}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subjected to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{rrrr}\sum_{j\in N}x_{i,j}&amp;amp;=&amp;amp;1&amp;amp;\forall i \in N\\\ \sum_{i\in N}x_{i,j} &amp;amp;=&amp;amp; 1 &amp;amp; \forall j \in N\\ u_{i}+1 &amp;amp;\leq&amp;amp; u_{j} + |N| \cdot (1-x_{i,j})&amp;amp;\forall i,j \in N: i\neq j, j\neq 1\\ u_{1} &amp;amp;=&amp;amp; 1&amp;amp; \forall i \in N \\ x_{i,i} &amp;amp;=&amp;amp; 0 &amp;amp;\forall i \in N \\ x_{i,j} &amp;amp;\in&amp;amp; \{0,1\}&amp;amp;\forall i,j \in N\\ u_{i} &amp;amp;\in&amp;amp; \mathbb{Z}_{+} &amp;amp;\forall i \in N\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; is an integer, that determines whether the path is selected in the solution and &lt;span class=&quot;math-container&quot;&gt;$u_{i}$&lt;/span&gt; is the position of city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; along the tour. &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is a set of cities and &lt;span class=&quot;math-container&quot;&gt;$d_{i,j}$&lt;/span&gt; is the distance between city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have a hard time understanding the constraint &lt;span class=&quot;math-container&quot;&gt;$u_{i} + 1 \leq u_{j} + |N| (1-x_{i,j})$&lt;/span&gt;. I do not see the inuition behind, why this constraint would eliminate the subtours. Suppose, I have three tours (see in the figure below). The left circle is a solution to the TSP, while the right one is one with only the subtours. I am not sure how the constraint would prohibit a subtour from forming, as &lt;span class=&quot;math-container&quot;&gt;$|N|$&lt;/span&gt; seems to be big enough to allow for subtours if my &lt;span class=&quot;math-container&quot;&gt;$u_{j} = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zRgg7.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zRgg7.png&quot; alt=&quot;Subtours&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="563" LastActivityDate="2022-08-04T14:20:40.853" Title="Interpretation of a subtour elimination constraint in the TSP" Tags="|traveling-salesman|subtour-elimination|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8121" PostTypeId="2" ParentId="8120" CreationDate="2022-03-22T11:36:07.173" Score="10" Body="&lt;p&gt;These constraints are called Miller-Tucker-Zemlin (MTZ) constraints, you can find a lot of technical notes online.&lt;/p&gt;&#xA;&lt;p&gt;They impose that a node can only be visited once. You can think of the &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; variables as the order of the sequence of the visits. Every time &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1$&lt;/span&gt;, the order variable is incremented by one unit.&lt;/p&gt;&#xA;&lt;p&gt;Consider a subtour &lt;span class=&quot;math-container&quot;&gt;$A-B-A$&lt;/span&gt;. You have &lt;span class=&quot;math-container&quot;&gt;$x_{AB}=x_{BA}=1$&lt;/span&gt;. But with the MTZ constraints, without loss of generality, if &lt;span class=&quot;math-container&quot;&gt;$u_A=1$&lt;/span&gt;, then necessarily, &lt;span class=&quot;math-container&quot;&gt;$u_B\ge 2$&lt;/span&gt;. And so you cannot have &lt;span class=&quot;math-container&quot;&gt;$u_B +1 \le u_A$&lt;/span&gt;, which contradicts &lt;span class=&quot;math-container&quot;&gt;$x_{BA}=1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="869" LastEditDate="2022-03-22T14:52:13.393" LastActivityDate="2022-03-22T14:52:13.393" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8122" PostTypeId="1" AcceptedAnswerId="8698" CreationDate="2022-03-22T12:19:56.687" Score="2" ViewCount="134" Body="&lt;p&gt;I am trying to compare the performance of some algorithms for &lt;a href=&quot;https://en.wikipedia.org/wiki/Multiway_number_partitioning&quot; rel=&quot;nofollow noreferrer&quot;&gt;multiway number partitioning&lt;/a&gt;. I run them on randm instances that I generate with Python's numpy:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;values = np.random.randint(1,1000, 100000)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then I run the algorithm for partitioning the values into 10 bins. But in all instances that I try, the simple &lt;a href=&quot;https://en.wikipedia.org/wiki/Greedy_number_partitioning&quot; rel=&quot;nofollow noreferrer&quot;&gt;greedy number partitioning&lt;/a&gt; algorithm returns an optimal partition (all sums are the same up to 1).&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What is a dataset of large real-world number partitioning problems, that are hard (that is, cannot be solved easily by exhaustive search or by a greedy algorithm)?&lt;/li&gt;&#xA;&lt;li&gt;How can one generate such large instances randomly?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2022-07-18T04:04:42.677" Title="How to generate hard instances for number partitioning?" Tags="|optimization|benchmark|test-instances|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8123" PostTypeId="2" ParentId="8120" CreationDate="2022-03-22T13:42:26.093" Score="4" Body="&lt;p&gt;The constraint is nicely explained by @Kuifje. I want to add the following point concerning your comment regarding &lt;span class=&quot;math-container&quot;&gt;$|N|$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$|N|$&lt;/span&gt; is only in place if &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 0$&lt;/span&gt;, so if there is no connecting edge between &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 1$&lt;/span&gt; then the constraint equals &lt;span class=&quot;math-container&quot;&gt;$u_i +1 \leq u_j$&lt;/span&gt;, which prevents subtours as explained by @Kuifje.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2022-03-22T13:42:26.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8124" PostTypeId="1" AcceptedAnswerId="8125" CreationDate="2022-03-22T13:43:32.417" Score="2" ViewCount="154" Body="&lt;p&gt;I am formulating a MILP in which there is a continuous variable &lt;em&gt;x&lt;/em&gt; and a binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the program formulation there are the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$Ay\leq x \leq By$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$0\leq A\leq B$&lt;/span&gt;). The idea is that &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$x&amp;gt;0$&lt;/span&gt; (this is used in other constraints).&lt;/p&gt;&#xA;&lt;p&gt;However it may happen that &lt;span class=&quot;math-container&quot;&gt;$A=0$&lt;/span&gt;, in which case &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is not constrained to be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt;. I've thus reformulated the left-hand-side constraint as &lt;span class=&quot;math-container&quot;&gt;$Ay\leq x$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$A &amp;gt; 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0.1y\leq x$&lt;/span&gt; otherwise. The &lt;span class=&quot;math-container&quot;&gt;$0.1$&lt;/span&gt; factor is however arbitrary and has been chosen because in implementations it produced better results than other candidates (such as &lt;span class=&quot;math-container&quot;&gt;$10^{-2}$&lt;/span&gt; and lower).&lt;/p&gt;&#xA;&lt;p&gt;Still I'm afraid that this factor might depend on the scale of other parameters in the program, and I wondered whether there is a more robust way to implement &lt;span class=&quot;math-container&quot;&gt;$(x=0) \Rightarrow (y=0)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8723" LastEditorUserId="500" LastEditDate="2022-03-22T16:20:27.100" LastActivityDate="2022-03-22T16:20:27.100" Title="Robust way to implement $(x=0) \Rightarrow (y=0)$, with $x$ nonnegative and $y$ binary" Tags="|mixed-integer-programming|constraint|binary-variable|big-m|indicator-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8125" PostTypeId="2" ParentId="8124" CreationDate="2022-03-22T14:39:37.660" Score="5" Body="&lt;p&gt;Equivalently, you want to enforce the contrapositive &lt;span class=&quot;math-container&quot;&gt;$y = 1 \implies x &amp;gt; 0$&lt;/span&gt;.  The standard approach is to introduce a small constant tolerance &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; and enforce &lt;span class=&quot;math-container&quot;&gt;$y = 1 \implies x \ge \epsilon$&lt;/span&gt; via big-M constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\epsilon - x \le M(1-y).$$&lt;/span&gt;&#xA;With &lt;span class=&quot;math-container&quot;&gt;$M = \epsilon - 0$&lt;/span&gt;, the constraint reduces to &lt;span class=&quot;math-container&quot;&gt;$\epsilon y \le x$&lt;/span&gt;, as you had obtained.  Alternatively, you can use an indicator constraint, but you will still need &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-03-22T14:39:37.660" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8126" PostTypeId="1" CreationDate="2022-03-22T17:09:49.593" Score="5" ViewCount="152" Body="&lt;p&gt;I have a finite probability distribution &lt;span class=&quot;math-container&quot;&gt;$p_1, p_2, \ldots, p_n$&lt;/span&gt; (but these are variables of an optimization problem). Moreover, we have monotonicity, &lt;span class=&quot;math-container&quot;&gt;$p_1 \geq p_2 \geq \cdots \geq p_n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Assume we already constrained that at least one of the &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; values is zero. I want to keep track of where the zero's start.&lt;/p&gt;&#xA;&lt;p&gt;An obvious approach is to introduce a new binary variable &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,n$&lt;/span&gt; and say:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases}&#xA;b_i \geq p_i \\&#xA;M\cdot p_i \geq b_i&#xA;\end{cases}&lt;/span&gt;&#xA;and this system ensurses &lt;span class=&quot;math-container&quot;&gt;$p_i = 0 \iff b_i = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_i &amp;gt; 0 \iff b_i = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The issue is, I cannot define big-M, because the smallest non-zero probability can be arbitrarily small. Assume &lt;span class=&quot;math-container&quot;&gt;$M = 10^8$&lt;/span&gt; for example, and &lt;span class=&quot;math-container&quot;&gt;$p_i = 10^{-10}$&lt;/span&gt;. Then, the second constraint above will have &lt;span class=&quot;math-container&quot;&gt;$M \cdot p_i  = 10^{-2} &amp;lt; 1$&lt;/span&gt; hence this constraint will force &lt;span class=&quot;math-container&quot;&gt;$b_i = 0$&lt;/span&gt;. Therefore the above system will implicitly constrain &lt;span class=&quot;math-container&quot;&gt;$p_i \geq 10^{-8}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i = 1,\ldots, n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I don't want this. Is there any alternative for this approach without using &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;? I thought maybe monotonicity helps, because I can consider the sum of &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt;'s and when it hits &lt;span class=&quot;math-container&quot;&gt;$=1$&lt;/span&gt; it means the zeros are starting.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; To overcome this, sometimes dropping the big-M constraint while keeping the first one and minimizing the sum of &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;s help. However, I cannot minimize the sum of &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;s because the problem has another objective that is a function of &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt;s, and I will use &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;s to add further constraints over &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2022-03-23T00:16:46.133" LastActivityDate="2022-03-23T00:16:46.133" Title="Binary variable to indicate zero probabilities" Tags="|binary-variable|logical-constraints|indicator-constraints|probability-distributions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8127" PostTypeId="2" ParentId="8126" CreationDate="2022-03-22T18:00:22.050" Score="3" Body="&lt;p&gt;You are going to bump into a limitation of finite-precision floating point arithmetic. Basically, a small enough probability value will be indistinguishable from rounding error. Assuming you are using a MIP solver, the solver will have a tolerance value &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; such that any constraint whose left-side evaluates to withing &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; of the right side is considered satisfied. The same is true for sign restrictions (possibly using a different &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;). You may be able to set the value of &lt;span class=&quot;math-container&quot;&gt;$\epsilon,$&lt;/span&gt; but you may not be allowed to set it to 0 (and in any case setting it to 0 is not advisable).&lt;/p&gt;&#xA;&lt;p&gt;So you can change your second constraint to &lt;span class=&quot;math-container&quot;&gt;$p_i \ge \epsilon \cdot b_i.$&lt;/span&gt; While it still may artificially exclude tiny probabilities, at least you will know that you are making the minimum possible restriction to the feasible region.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-22T18:00:22.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8129" PostTypeId="6" CreationDate="2022-03-22T18:52:29.683" Score="0" Body="&lt;h1&gt;prubin&lt;/h1&gt;&#xA;&lt;p&gt;I joined OR.SE at the time Larry Snyder created it. Prior to that, I was active on (the now defunct) OR Exchange (going back to when Mike Trick created it), and helped moderate it after INFORMS started hosting it. Before that, I was active on the USENET group sci.op-research (which still exists, as a Google group, but draws exclusively spam messages). Younger readers will likely have to google &amp;quot;USENET&amp;quot;. Before that was the void. The point here is that I've been involved with OR Q&amp;amp;A sites for quite a while. During that time, I have tried to be helpful where possible and (self-reported) polite. (Disclaimer: I grew up in New York, so &amp;quot;polite&amp;quot; is in the relative topology of the metro area there.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-03-22T18:52:29.683" LastActivityDate="2022-03-22T18:52:29.683" CommentCount="0" CommunityOwnedDate="2022-03-22T18:52:29.683" ContentLicense="CC BY-SA 4.0" />
  <row Id="8131" PostTypeId="1" CreationDate="2022-03-22T19:01:12.233" Score="3" ViewCount="1745" Body="&lt;p&gt;Using DOcplex module an optimization problem is solved.&lt;/p&gt;&#xA;&lt;p&gt;There are many decision variables in the solution, for the validation of the mathematical model I want to check them.&lt;/p&gt;&#xA;&lt;p&gt;How can I write the solution (decision variables) to Excel worksheets?&lt;/p&gt;&#xA;" OwnerUserId="9245" LastEditorUserId="9435" LastEditDate="2022-03-24T16:34:28.240" LastActivityDate="2022-03-24T16:34:28.240" Title="Python to Excel" Tags="|python|docplex|excel|cplex-python-api|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8132" PostTypeId="2" ParentId="8131" CreationDate="2022-03-22T19:09:09.223" Score="7" Body="&lt;p&gt;A great option is to use the &lt;a href=&quot;https://pandas.pydata.org/docs/index.html&quot; rel=&quot;noreferrer&quot;&gt;pandas&lt;/a&gt; library, and specifically &lt;a href=&quot;https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_excel.html&quot; rel=&quot;noreferrer&quot;&gt;pandas.DataFrame.to_excel&lt;/a&gt; is what you need.&lt;/p&gt;&#xA;&lt;p&gt;I suggest you use one column per variable index, and one line per non zero variable.&lt;/p&gt;&#xA;&lt;p&gt;Here is one way of puting the solution into dataframe form. Something like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;variable_name = []&#xA;variable_value = []&#xA;for x in variables:&#xA;   if value(x)&amp;gt;0:&#xA;      variable_name.append(x)&#xA;      variable_value.append(value(x))&#xA;&#xA;keys = [&amp;quot;variable_name&amp;quot;, &amp;quot;variable_value&amp;quot;]&#xA;values = [variable_name, variable_value]&#xA;df_solution = DataFrame(dict(zip(keys,values)),columns=keys)&#xA;df_solution.to_excel(&amp;quot;my_solution.xlsx&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-03-22T20:07:39.523" LastActivityDate="2022-03-22T20:07:39.523" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8133" PostTypeId="2" ParentId="8131" CreationDate="2022-03-22T19:55:54.223" Score="4" Body="&lt;p&gt;I have used &lt;a href=&quot;https://openpyxl.readthedocs.io/en/stable/&quot; rel=&quot;nofollow noreferrer&quot;&gt;openpyxl&lt;/a&gt; several times to create or alter excel files. It is quite easy if one is familiar with Python.&#xA;With this module you can iterate through your variables and write its value to a cell.&lt;/p&gt;&#xA;" OwnerUserId="9151" LastActivityDate="2022-03-22T19:55:54.223" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8134" PostTypeId="1" CreationDate="2022-03-23T06:30:12.867" Score="5" ViewCount="113" Body="&lt;p&gt;Consider a &lt;span class=&quot;math-container&quot;&gt;$n^2 \times n^2$&lt;/span&gt; grid sudoku.&#xA;Define a clue to be composed of a coordinate &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; of the grid and a value &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;.&#xA;The goal is given &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and a set of clues, to find one solution to the sudoku problem.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; be the number of clues of the problem.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$R = 0$&lt;/span&gt;, the problem is polynomial since it can be resolved in &lt;span class=&quot;math-container&quot;&gt;$O(1)$&lt;/span&gt;: fill the first line with &lt;span class=&quot;math-container&quot;&gt;$1, 2, 3, \dots, n^2$&lt;/span&gt;, the second line with &lt;span class=&quot;math-container&quot;&gt;$n, n+1, \dots, n^2, 1, 2, \dots, n-1$&lt;/span&gt; until the last line with &lt;span class=&quot;math-container&quot;&gt;$n^2-n, \dots, n^2, 1, 2, \dots, n^2-n$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$R \geq n^4-a$&lt;/span&gt; for a constant &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, the problem is polynomial too: use brute force and try &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; different values for the &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; empty coordinate: &lt;span class=&quot;math-container&quot;&gt;$O(n^a)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;What about other &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt;? For which &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; the problem is polynomial? And for which it is NP-Hard?&lt;/p&gt;&#xA;" OwnerUserId="7312" LastEditorUserId="7312" LastEditDate="2022-03-23T16:07:32.863" LastActivityDate="2022-03-23T16:07:32.863" Title="How many clues make Sudoku polynomial" Tags="|algorithms|computational-complexity|combinatorics|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8135" PostTypeId="2" ParentId="8120" CreationDate="2022-03-23T07:30:29.453" Score="6" Body="&lt;p&gt;To add another answer that focuses on &lt;em&gt;why&lt;/em&gt; we use &lt;span class=&quot;math-container&quot;&gt;$\vert N\vert$&lt;/span&gt; in the constraint:&lt;/p&gt;&#xA;&lt;p&gt;As @Pedrinho @Kuifje stated, the &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; variables can be interpreted as the order of city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in the tour. That is, &lt;span class=&quot;math-container&quot;&gt;$u_i=k$&lt;/span&gt; means that city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is number &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; on the tour.&lt;/p&gt;&#xA;&lt;p&gt;Hence, we know that given &lt;span class=&quot;math-container&quot;&gt;$\vert N\vert$&lt;/span&gt; cities, we have &lt;span class=&quot;math-container&quot;&gt;$1\leq u_i\leq \vert N\vert$&lt;/span&gt;. Then we want to enforce the constraint &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1\Rightarrow u_i+1\leq u_j$&lt;/span&gt; meaning that if we go directly from city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to city &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; then city &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; should not be visited before city &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. We can do that with a big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA; u_i+1-u_j\leq M(1-x_{ij}) \Leftrightarrow u_i-u_j+Mx_{ij}\leq M-1&#xA;\end{equation}&lt;/span&gt;&#xA;Now, if &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1$&lt;/span&gt;, we see that the inequality reduces to &lt;span class=&quot;math-container&quot;&gt;$u_i+1\leq u_j$&lt;/span&gt; which is what we want. Next, we should find the &lt;em&gt;smallest possible value&lt;/em&gt; for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. To do so, we look at the constraint in case of &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=0$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;  u_i-u_j \leq M-1&#xA;\end{equation}&lt;/span&gt;&#xA;To find the smallest possible value of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; we need to make sure that &lt;span class=&quot;math-container&quot;&gt;$u_i-u_j$&lt;/span&gt; never exceeds &lt;span class=&quot;math-container&quot;&gt;$M-1$&lt;/span&gt;, so we find the largest possible value for &lt;span class=&quot;math-container&quot;&gt;$u_i-u_j$&lt;/span&gt;, which is when &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; is as large as possible (&lt;span class=&quot;math-container&quot;&gt;$\vert N\vert$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$u_j$&lt;/span&gt;  is as small as possible (&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;). Hence, &lt;span class=&quot;math-container&quot;&gt;$u_i-u_j\leq \vert N\vert-1$&lt;/span&gt; and we thus know the value of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, namely &lt;span class=&quot;math-container&quot;&gt;$M=\vert N\vert$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Actually, since you know your starting point (&lt;span class=&quot;math-container&quot;&gt;$u_1=1$&lt;/span&gt;), you can strengthen your MTZ constraints slightly by&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  &amp;amp;u_i-u_j + (\vert N\vert -1)x_{ij}\leq \vert N\vert -2,&amp;amp;&amp;amp;\forall i\neq j=2,\dots,\vert N\vert \\&#xA;  &amp;amp;2\leq u_i\leq \vert N\vert, &amp;amp;&amp;amp;\forall i=2,\dots,\vert N\vert &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, the MTZ-constraints provide a very weak formulation of the TSP. To see why, you may take a look at the excellent paper &amp;quot;&lt;a href=&quot;https://doi.org/10.1016/j.ejor.2013.07.038&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;Requiem&lt;/em&gt; for the Miller–Tucker–Zemlin subtour elimination constraints?&lt;/a&gt;&amp;quot; by Tolga Bektas and Luis Gouveia&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-03-23T07:30:29.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8136" PostTypeId="2" ParentId="8079" CreationDate="2022-03-23T14:13:14.787" Score="9" Body="&lt;ol&gt;&#xA;&lt;li&gt;There can be many reasons why a branch-cut-and-price algorithm fails to solve an instance to optimality in a reasonable time.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A large primal-dual gap because a heuristic solution is absent or of a pure quality. One needs to improve the quality of the heuristic algorithm to obtain the primal bound.&lt;/li&gt;&#xA;&lt;li&gt;A large primal-dual gap because the relaxation is not tight. One needs to add known cutting planes or devise new families of cutting planes. Sometimes, strong cutting planes are non-robust, i.e., they modify the structure of the pricing problem. Sometimes, quality of cut separation algorithm is not sufficient, i.e., it misses good cuts. Sometimes, the cut separation algorithm is too slow. One may also try a different decomposition to improve the strength of the relaxation.&lt;/li&gt;&#xA;&lt;li&gt;A large number of branch-and-bound nodes may come not only from a large primal-dual gap, but also because good branching candidates are not found. Strong branching may be a remedy in this case. Sometimes it is possible to enumerate all columns and solve the corresponding MIP directly.&lt;/li&gt;&#xA;&lt;li&gt;A difficult pricing problem. One needs here to devise a heuristic for the pricing problem, or work with a relaxation of the pricing problem (for example, well-known ng-path relaxation). Sometimes the pricing problem becomes hard because there are many active non-robust cuts. One may stop generating new cuts and go to branching. Or one may develop a weaker variant of non-robust cuts to speed-up pricing (search for &amp;quot;limited-memory cuts&amp;quot;). Reduced cost fixing may also be an approach to reduce the pricing problem solution time.&lt;/li&gt;&#xA;&lt;li&gt;Slow column generation convergence (especially after adding cutting planes). One should use a dual stabilization technique. There are several available, one may search or.stackexchange.com, there were already questions about dual stabilization. There is also the primal stabilization, i.e. generation of many columns in every iteration, not just the one with the smallest reduced cost.&lt;/li&gt;&#xA;&lt;li&gt;A large restricted master problem solution time by an LP algorithm. One may change the LP solver (open source -&amp;gt; commercial one, primal simplex -&amp;gt; dual simplex, etc.). Or one can use another decomposition to make the master problem lighter. One may use the column and cut clean-up techniques, i.e., remove from the master columns or cuts which do not participate in the primal or dual solution.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There can also be memory issues, not only the time limit ones. Memory usage can be decreased by using the depth-first search branch-and-bound tree exploration. See also clean-up techniques above.&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;As it was already indicated in other answers, your &amp;quot;odd behaviour&amp;quot; is definitely a bug. You should take the columns generated after branching, and calculate their reduced cost using the optimal dual master solution at the root. The reduced cost of at least one of such columns should be negative. This column is then missed by your pricing algorithm. This can give you a clue where to search a bug in your pricing algorithm.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="835" LastActivityDate="2022-03-23T14:13:14.787" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8137" PostTypeId="1" AcceptedAnswerId="8140" CreationDate="2022-03-23T15:59:09.130" Score="4" ViewCount="153" Body="&lt;p&gt;So, I have been tasked to create a formal mathematical description of problem statement on a cloud service scheduler for my team's university project, which is, honestly, a little weird of a thing to do, which is why I am unsure of how to proceed with it.&lt;/p&gt;&#xA;&lt;p&gt;I guess, first logical thing to do, is to explain, what is a scheduler's problem. Well, generally, we have two classes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Nodes&lt;/strong&gt;, which have some predetermined amount of resources;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Pods&lt;/strong&gt;, which, while while active, consume resources.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Pods&lt;/strong&gt; become active, when they are assigned to a &lt;strong&gt;node&lt;/strong&gt; and they exist for a while, until they are either completed, expired (failed to complete over a long time), or until they are brought down to be assigned to a different &lt;strong&gt;node&lt;/strong&gt;. The latter can happen when a new &lt;strong&gt;pod&lt;/strong&gt; is added by the system and the system needs to rearrange some already existing &lt;strong&gt;pods&lt;/strong&gt; to fit in a new one. This can also occur if the &lt;strong&gt;pod&lt;/strong&gt; suddenly demands more resources than it was expected to.&lt;/p&gt;&#xA;&lt;p&gt;Another important detail is, when a &lt;strong&gt;pod&lt;/strong&gt; is being set, the &lt;strong&gt;node&lt;/strong&gt; it is being set to, tries to guess, how many resources to reserve for this &lt;strong&gt;pod&lt;/strong&gt;. Reserved resources are for a specific &lt;strong&gt;pod&lt;/strong&gt; only. Not only that, a &lt;strong&gt;pod&lt;/strong&gt; cannot use resources that were not assigned to it. The only way to reassign resources to a &lt;strong&gt;pod&lt;/strong&gt;, is to kill it and recreate it (possibly on another &lt;strong&gt;node&lt;/strong&gt;) with new assigned resources to it.&lt;/p&gt;&#xA;&lt;p&gt;Some other rules of the game:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;several pods can be assigned to one node&lt;/li&gt;&#xA;&lt;li&gt;several nodes cannot share one pod&lt;/li&gt;&#xA;&lt;li&gt;resources we are talking about are not consumables — once a pod no longer exists, resources are returned to node&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Knowing that, I tried to formulate the problem on pods level and it goes like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(node - assigned_i - |assigned_i - used_t| - i \cdot w_i) \to maximize$&lt;/span&gt;, where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$node$&lt;/span&gt; — resources that were not occupied in a node&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$assigned_i$&lt;/span&gt; — resources that scheduler chose to assign to the pod. It is marked with underscored i, because scheduler can also reassign resources, so there might be several instances of it.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$used_t$&lt;/span&gt; — resources used at the time t. I believe we have to measure effectiveness of the scheduler in real time, so these are some chaotic time series. I honestly don't know if these are possible to classify&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; is some constant that is here to penalize scheduler for reassigning resources, since killing a pod and recreating it is, well, costly on the resources part&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;At the end we have a model that tries to assign as little resources as possible and gets penalised if it guesses wrongly in any direction, as well as it gets penalized if its guess is wrong to the point it has to kill and restore a pod.&lt;/p&gt;&#xA;&lt;p&gt;So, is this somewhat closely resembling the real problem? What are possible ways I can take this problem to nodes scale? I also might be missing something...&lt;/p&gt;&#xA;&lt;p&gt;UPD: I guess there should be individual layers of problem for a node and for the scheduling system as a whole. What changes for individual node level, is that all variables, except &lt;span class=&quot;math-container&quot;&gt;$node$&lt;/span&gt; become vectors (as there are typically several pods assigned to one node). This said,I do not understand how to mathematically show that &lt;span class=&quot;math-container&quot;&gt;$node$&lt;/span&gt; is determined by all pods resource assignment simultaneously. That is, if we assign &lt;span class=&quot;math-container&quot;&gt;$assigned_1$&lt;/span&gt; resources to some pod, it leaves just &lt;span class=&quot;math-container&quot;&gt;$node - assigned_1$&lt;/span&gt; resources for the rest of the pods assigned to this node.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, I am completely lost on how to formulate this on the scale of the scheduling system.&lt;/p&gt;&#xA;" OwnerUserId="9426" LastEditorUserId="9426" LastEditDate="2022-03-24T14:58:14.297" LastActivityDate="2022-06-09T13:06:47.893" Title="Mathematically formulating formal problem of a cloud service scheduler" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|scheduling|constraint-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8138" PostTypeId="2" ParentId="8131" CreationDate="2022-03-23T22:17:04.523" Score="1" Body="&lt;p&gt;There are both pandas and openpyxl recommendations here. In my experience, if you want to go read and write on the cell level, or do more than basic analysis, use Pandas. Use openpyxl If you want to script basic excel functions&lt;/p&gt;&#xA;" OwnerUserId="9433" LastActivityDate="2022-03-23T22:17:04.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8139" PostTypeId="1" CreationDate="2022-03-24T09:40:25.723" Score="6" ViewCount="143" Body="&lt;p&gt;For teaching purposes, I believe it can be good to use very light-weight proofs of deep results, as it often answers the question &amp;quot;why is it true&amp;quot; better than other types of proofs. By &amp;quot;light-weight proofs&amp;quot; I mean proofs that rely as little as possible on other deep results as possible.&lt;/p&gt;&#xA;&lt;p&gt;Regarding proofs of strong duality in linear programming, I have seen many proofs. To name a few&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Strong duality as consequence of weak duality + simplex algorithm produces optimal solutions (Introduction to linear optimization, Bertsimas &amp;amp; Tsitsiklis)&lt;/li&gt;&#xA;&lt;li&gt;Strong duality as a consequence of weak duality + a projection argument (Large scale linear and integer optimization, Kipp Martin)&lt;/li&gt;&#xA;&lt;li&gt;Strong duality as a consequence of weak duality + Farkas' lemma (Theory of linear and integer programming, Schrijver)&lt;/li&gt;&#xA;&lt;li&gt;Strong duality as a corollary of strong duality of Lagrangian duality (Noonlinear programming, Bazaraa, Sheral, Shetty)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;It can be debated how light-weight these proofs are, as most of them rely on some rather significant results. Thus, my question is&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;What good light-weight proofs of strong duality in linear programming do you know?&amp;quot;&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-03-27T03:10:14.750" Title="Light weight proof of strong duality in linear programming" Tags="|linear-programming|duality|proofs|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8140" PostTypeId="2" ParentId="8137" CreationDate="2022-03-24T14:57:14.040" Score="3" Body="&lt;p&gt;So, in case anyone is wondering, I actually figured the solution on my own. I ended up using constraint programming. For the sake of plagiarism check in my university, I am to say that this formulation was designed for «Playing the Dispatcher» project from 1C.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{X} = \{max_i, a_j, u_t, r_j, p, w_j, x_{ij}\}$&lt;/span&gt; — set of variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$max_i = \begin{bmatrix} memory_i\\cpu_i \end{bmatrix}, \space \forall i \in \mathbb{N}$&lt;/span&gt; — all the resources an ith node can offer.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a_j = \begin{bmatrix} memory_j\\cpu_j \end{bmatrix}, \space \forall j \in \mathbb{N}$&lt;/span&gt; — the resources assigned to a jth pod.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u_t = \begin{bmatrix} memory_t\\cpu_t \end{bmatrix}, \space \forall t \in \mathbb{N}$&lt;/span&gt; — resources used at a specific period of time t, typically calculated in seconds / minutes / frames. Is a chaotic time series bounded by computational constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$r_j, \space \forall j \in \mathbb{N}$&lt;/span&gt; — some constant that is brought to punish process reassignment, &lt;span class=&quot;math-container&quot;&gt;$r_j = n \cdot c$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the number of times a jth pod got reassigned and &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is a modifier.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_t, \space \forall t \in \mathbb{N}$&lt;/span&gt; — amount of pods requested to be processed at a time t.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$w_j, \space \forall j \in \mathbb{N}$&lt;/span&gt; — weight assigned to a pod by scheduler.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 1, \space \forall i \forall j \in \mathbb{N}$&lt;/span&gt; if jth pod was assigned to ith node and 0 otherwise.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{D} = \{D_{max}, D_a, D_u, D_r, D_p, D_w, D_x\}$&lt;/span&gt; — set of domains of variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_{max}, D_a, D_u \in \mathbb{N}^2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_r \in \mathbb{R}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_p, D_w \in \mathbb{N}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_x \in \{0, 1\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And the set of constraints and functionals:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{C} = \{C_0, C_1 \}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C_0: \space (max - a_j - |a_j - u_t| - r_j) \cdot (\sum_{j=1}^{p_t} (w_j \cdot x_{ij})  \cdot f(x))  \to maximize$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C_1: \space max_i - \sum_{j = 1}^{p_t} a_j \geq 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f(x) = 100 - g(x)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; — uneven distribution of resources. &lt;span class=&quot;math-container&quot;&gt;$D(g) \in [0, 100)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g(x) \in \mathbb{R}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9426" LastEditorUserId="9426" LastEditDate="2022-06-09T13:06:47.893" LastActivityDate="2022-06-09T13:06:47.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8141" PostTypeId="1" CreationDate="2022-03-24T16:07:08.060" Score="1" ViewCount="414" Body="&lt;p&gt;I am currently working on a scheduling problem (MIP) to minimize cost, and my idea is to first generate a set of discrete initial solutions, and build an LP model with the discrete initial solution to get the shadow price for each constraint. With the shadow price of each constraint, maybe I can better decide which part of the discrete initial solution should I adjust to get a better value, then put the discrete initial solution into the MIP model to solve faster.&lt;/p&gt;&#xA;&lt;p&gt;I have now solved the LP model using Gurobi and used &lt;code&gt;.pi&lt;/code&gt; attribute to get the shadow price for each constraint. However, the shadow prices I got are all positive. Is there a way I can do to get the negative shadow prices in Gurobi?&lt;/p&gt;&#xA;" OwnerUserId="9437" LastEditorUserId="36" LastEditDate="2022-03-24T16:34:02.970" LastActivityDate="2022-03-26T13:04:51.343" Title="How to get negative shadow price for minimization problem in Gurobi?" Tags="|mixed-integer-programming|linear-programming|modeling|constraint|gurobi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8142" PostTypeId="6" CreationDate="2022-03-25T15:56:01.157" Score="0" Body="&lt;h1&gt;your_boy_gorja&lt;/h1&gt;&#xA;&lt;p&gt;I am currently a professional in Operations Research/Optimization field and have been working as Operations Researcher in a well reputed large multinational firm for last 4 years. I joined OR.SE in 2019 and have been an active member since then. I have benefitted time and again from this resourceful forum. This forum has provided a much needed place for OR professionals. I would like to volunteer to serve as a moderator so that I can serve the community and contribute in making the forum beneficial.&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="113" LastEditDate="2022-03-25T15:56:01.157" LastActivityDate="2022-03-25T15:56:01.157" CommentCount="0" CommunityOwnedDate="2022-03-25T15:56:01.157" ContentLicense="CC BY-SA 4.0" />
  <row Id="8144" PostTypeId="2" ParentId="8141" CreationDate="2022-03-26T13:04:51.343" Score="4" Body="&lt;p&gt;Please note that the notion of &lt;em&gt;shadow prices&lt;/em&gt; or &lt;em&gt;dual values&lt;/em&gt; only makes sense for LPs, that is, when ignoring all integrality restrictions. One should not interpret too much into those values when the actual underlying problem is a MIP. That's also the reason why these values are not available.&lt;/p&gt;&#xA;&lt;p&gt;Instead, you might want to look into &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/specifying_multiple_scenar.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multi-Scenario optimization&lt;/a&gt; to explore different options.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2022-03-26T13:04:51.343" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8145" PostTypeId="1" CreationDate="2022-03-26T14:13:26.003" Score="2" ViewCount="419" Body="&lt;p&gt;I recently started looking into Google-OR tools. However, I do not see mathematical formulations of any of the problems the OR-tools can solve. Without looking at the model (set, objective, constraints, etc), it is hard for me to understand the problem. Does anyone know where I can find them? If you used it for your work, how did you use the tools?&lt;/p&gt;&#xA;" OwnerUserId="3288" LastActivityDate="2022-03-30T21:46:43.250" Title="Mathematical Formulations for Google-OR tools" Tags="|or-tools|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8146" PostTypeId="1" AcceptedAnswerId="8147" CreationDate="2022-03-26T20:06:29.617" Score="2" ViewCount="1355" Body="&lt;p&gt;I have a binary variable &lt;span class=&quot;math-container&quot;&gt;$X_{ijk}$&lt;/span&gt; which I have defined as the following :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;X_ijk = [LpVariable(&amp;quot;X{0}{1}{2}&amp;quot;.format(i+1, j+1, k+1), cat=&amp;quot;Binary&amp;quot;)&#xA;       for i in range(N1) for j in range(N2) for k in range (N3)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am struggling to code the following objective function&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \quad \left[\sum_{k=1}^{k=N_3} C^k \left(\sum_{i=1}^{i=N_1}\sum_{j=1}^{j=N_2}P_{ij}^k \cdot X_{ijk}\right)\right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where we know &lt;span class=&quot;math-container&quot;&gt;$C^k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_{ij}^k$&lt;/span&gt;. I have defined them as follows :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;C_k = numpy.random.uniform(0,100,size=(N3))&#xA;P_ijk = numpy.random.uniform(0,100,size=(N1,N2,N3))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Assuming the following has been defined :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;prob = LpProblem('Optimization Problem', LpMinimize)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How should I go about modeling the objective function?&lt;/p&gt;&#xA;" OwnerUserId="7320" LastEditorUserId="123" LastEditDate="2022-03-26T20:33:52.490" LastActivityDate="2022-03-27T00:32:38.997" Title="Defining Objective Function in PuLP" Tags="|linear-programming|pulp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8147" PostTypeId="2" ParentId="8146" CreationDate="2022-03-27T00:32:38.997" Score="3" Body="&lt;p&gt;I think it would be more convenient storing all the binary decision variables &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; in a python dict such that &lt;code&gt;x[i,j,k]&lt;/code&gt; directly corresponds to &lt;span class=&quot;math-container&quot;&gt;$X_{i,j,k}$&lt;/span&gt;. Then, because&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k=1}^{k=N_3} C^k \left(\sum_{i=1}^{i=N_1}\sum_{j=1}^{j=N_2}P_{ij}^k \cdot X_{ijk}\right) = \sum_{k=1}^{k=N_3}\sum_{i=1}^{i=N_1}\sum_{j=1}^{j=N_2} C^k \cdot P_{ij}^k \cdot X_{ijk},$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;writing your objective is straightforward:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import numpy as np&#xA;from pulp import *&#xA;&#xA;# your definitions of N1, N2, N3 here&#xA;C = np.random.uniform(0,100,size=(N3))&#xA;P = np.random.uniform(0,100,size=(N1,N2,N3))&#xA;&#xA;prob = LpProblem('Optimization Problem', LpMinimize)&#xA;&#xA;# add the decision variables&#xA;X = {}&#xA;for i in range(N1):&#xA;    for j in range(N2):&#xA;        for k in range(N3):&#xA;            X[i,j,k] = LpVariable(f&amp;quot;X[{i},{j},{k}]&amp;quot;, cat=&amp;quot;Binary&amp;quot;)&#xA;&#xA;# set the objective&#xA;prob.setObjective(sum(C[k]*P[i,j,k]*X[i,j,k] for i in range(N1) &#xA;                                             for j in range(N2) &#xA;                                             for k in range(N3)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2022-03-27T00:32:38.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8148" PostTypeId="2" ParentId="8139" CreationDate="2022-03-27T03:10:14.750" Score="1" Body="&lt;p&gt;Strong duality for LPs (and also convex programs) is a corollary of von Neumann's &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Minimax_theorem&quot; rel=&quot;nofollow noreferrer&quot;&gt;minimax theorem&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This is not what you asked for, since it is again appealing to a deep mathematical result. But I find that presenting duality &lt;strong&gt;first&lt;/strong&gt; from the perspective of swapping min and max and &lt;strong&gt;second&lt;/strong&gt; from the perspective of primal and dual problems makes the idea less magical and therefore more accessible to students. &amp;quot;What are the conditions under which we can swap min and max?&amp;quot; is a question everyone can get their head around.&lt;/p&gt;&#xA;&lt;p&gt;This may be the same as your number 4.&lt;/p&gt;&#xA;" OwnerUserId="3066" LastActivityDate="2022-03-27T03:10:14.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8149" PostTypeId="1" AcceptedAnswerId="8151" CreationDate="2022-03-27T12:13:34.090" Score="2" ViewCount="56" Body="&lt;p&gt;I have an ILP &lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt; that I know has feasible solution(s), and I would like to find a/all feasible solution(s). The issue is that &lt;span class=&quot;math-container&quot;&gt;$A,x,b$&lt;/span&gt; are defined over &lt;span class=&quot;math-container&quot;&gt;$\mathbb{F}_p$&lt;/span&gt;. More specifically, I need the RHS to be equal to &lt;span class=&quot;math-container&quot;&gt;$k\mod p$&lt;/span&gt;. I'm trying to solve this ILP in MatLab (due to the presence of the graph class, which makes things convenient in other steps), but I'm open to use any other solver than can be obtained for free as a student.&lt;/p&gt;&#xA;&lt;p&gt;I'm also curious if there is a way to 'Euclideanize' this ILP? As in instead of solving &lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt; defined over &lt;span class=&quot;math-container&quot;&gt;$\mathbb{F}_p$&lt;/span&gt;, we instead solve &lt;span class=&quot;math-container&quot;&gt;$A'x'=b'$&lt;/span&gt; defined over &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Just to be clear, I'm willing to accept mathematical solutions, but also MatLab/solver setting changes.&lt;/p&gt;&#xA;" OwnerUserId="7498" LastActivityDate="2022-03-27T14:24:25.167" Title="Is it possible to change the underlying field from Euclidean to $\mathbb{F}_p$?" Tags="|integer-programming|matlab|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8150" PostTypeId="1" CreationDate="2022-03-27T12:55:19.297" Score="6" ViewCount="292" Body="&lt;p&gt;We optimize large-scale optimization problems with tens of thousands of variables and constraints with Cvxpy + Commercial solvers (e.g. Gurobi, Mosek).&lt;/p&gt;&#xA;&lt;p&gt;The coefficient range easily exceeds the recommended bounds of &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/advanced_user_scaling.html#:%7E:text=less%2C%20and%20hopefully-,within,-.&quot; rel=&quot;noreferrer&quot;&gt;[1e-3, 1e+6]&lt;/a&gt;, which eventually leads to numerical instability. This is the pain-point.&lt;/p&gt;&#xA;&lt;p&gt;As a resolution, we wanted to scale the coefficients of the optimization problem (specifically linear constraints: &lt;code&gt;A@x &amp;lt;= b&lt;/code&gt;, where &lt;span class=&quot;math-container&quot;&gt;$A\in\Bbb R^2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b\in\Bbb R$&lt;/span&gt;), such that all scaled coefficients lie within &lt;code&gt;[1e-3, 1e+6]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;E.g.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Raw constraint: &lt;span class=&quot;math-container&quot;&gt;$10^5x_1 + 10^7 x_2 \le 10^9$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Now, using Scaling factor = &lt;span class=&quot;math-container&quot;&gt;$10^5$&lt;/span&gt; and Dividing both sides by scaling factor&lt;/li&gt;&#xA;&lt;li&gt;Scaled constraint: &lt;span class=&quot;math-container&quot;&gt;$x_1 + 10^2 x_2 \le 10^4$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In general, the Scaling factor should behave like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ObdMM.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ObdMM.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So, we were curious on:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What should be the (row-wise) scaling factor vector &lt;span class=&quot;math-container&quot;&gt;$α = [α_1, α_2, ...]$&lt;/span&gt;  such that &lt;span class=&quot;math-container&quot;&gt;$(A/α) @ x \le (b/α)$&lt;/span&gt; is a scaled constraint (i.e. all coefficient within [1e-3, 1e+6]) ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Note: Here &lt;span class=&quot;math-container&quot;&gt;$α_i$&lt;/span&gt; is scaling factor for the i-th row, i.e. &lt;span class=&quot;math-container&quot;&gt;$A_i @ x \le b_i$&lt;/span&gt;)&lt;/p&gt;&#xA;" OwnerUserId="6106" LastEditorUserId="123" LastEditDate="2022-03-27T13:19:40.660" LastActivityDate="2022-03-27T14:56:59.627" Title="Compute Scaling factor(s) for linear constraint ($A@x&lt;b$)" Tags="|optimization|gurobi|mosek|numerical-stability|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8151" PostTypeId="2" ParentId="8149" CreationDate="2022-03-27T14:24:25.167" Score="6" Body="&lt;p&gt;Introduce an integer variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and replace the RHS with &lt;span class=&quot;math-container&quot;&gt;$k+py$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-03-27T14:24:25.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8152" PostTypeId="2" ParentId="8150" CreationDate="2022-03-27T14:56:59.627" Score="4" Body="&lt;p&gt;You cannot necessarily achieve this by scaling only rows. Consider case 2 in your chart. The ratio of largest to smallest (nonzero) coefficient magnitude is &lt;span class=&quot;math-container&quot;&gt;$10^9/10^{-7}=10^{16}.$&lt;/span&gt; The target range (&amp;quot;output&amp;quot;) would have a ratio of &lt;span class=&quot;math-container&quot;&gt;$10^6/10^{-3}=10^9.$&lt;/span&gt; The problem is that scaling the row by a constant factor does not change the ratio.&lt;/p&gt;&#xA;&lt;p&gt;So you will need to scale both rows and columns ... and even with that, I'm not sure you can guarantee hitting all your targets.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-27T14:56:59.627" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8153" PostTypeId="1" AcceptedAnswerId="8154" CreationDate="2022-03-28T14:21:50.683" Score="3" ViewCount="84" Body="&lt;p&gt;I am working on a crew scheduling problem formulated as a MIP binary optimization where each employee is represented by a binary variable &lt;span class=&quot;math-container&quot;&gt;$X_{ids}$&lt;/span&gt; s.t. &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;th employee, &lt;span class=&quot;math-container&quot;&gt;$d \in D$&lt;/span&gt; is the day number and &lt;span class=&quot;math-container&quot;&gt;$s \in S$&lt;/span&gt; is the shift (ex: 9AM-12PM) and if the employee is scheduled to work on that day at that shift the variable is 1 otherwise 0.  The constraints are various taking into account supply &amp;gt; demand at each hour, employee shift preferences, lunch hour, consecutive days worked limits, etc.&lt;/p&gt;&#xA;&lt;p&gt;Because this is a MIP there is no duality here to study the shadow prices of the constraints.  I'm thus wondering what are some options to determine how to rank the constraints in terms of importance on their impacts on the objective function, which is a cost minimization?  Should I relax integrality constraints and analyze shadow prices of the constraints, or run various sensitivity analyses via scenarios removing different constraints from the optimization to get an estimate of the overall impact to the objective function?&lt;/p&gt;&#xA;" OwnerUserId="4581" LastEditorUserId="123" LastEditDate="2022-03-28T14:42:19.387" LastActivityDate="2022-03-28T15:05:18.577" Title="Determining constraint relevance in crew scheduling problem" Tags="|mixed-integer-programming|scheduling|sensitivity-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8154" PostTypeId="2" ParentId="8153" CreationDate="2022-03-28T15:05:18.577" Score="1" Body="&lt;p&gt;This is tricky for a variety of reasons, including the fact that relaxing a constraint that is nonbinding at the optimal solution could cause the optimum to improve. I don't think the duals of the LP relaxation will typically be all that helpful. Rather than dropping constraints, I would consider relaxing constraints a bit at a time (either individually or possibly in groups, depending on the context of the model). This assumes that solutions times are reasonably short.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-28T15:05:18.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8155" PostTypeId="1" AcceptedAnswerId="8158" CreationDate="2022-03-28T17:22:42.770" Score="-4" ViewCount="358" Body="&lt;p&gt;I have implemented an existing MIP Model into python with the python-mip solver and somehow I only get '0' as a solution to my minimization problem. What could be the problem? I am fairly new to LP and cannot really grasp, how I can fix this solution.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Welcome to the CBC MILP Solver &#xA;Version: Trunk&#xA;Build Date: Nov 15 2020 &#xA;&#xA;Starting solution of the Linear programming relaxation problem using Dual Simplex&#xA;&#xA;Coin0506I Presolve 62 (-30) rows, 49 (-49) columns and 292 (-120) elements&#xA;Clp0000I Optimal - objective value 0&#xA;Coin0511I After Postsolve, objective 0, infeasibilities - dual 0 (0), primal 0 (0)&#xA;Clp0032I Optimal objective 0 - 0 iterations time 0.002, Presolve 0.00&#xA;&#xA;Starting MIP optimization&#xA;Cgl0002I 4 variables fixed&#xA;Cgl0004I processed model has 62 rows, 49 columns (44 integer (44 of which binary)) and 292 elements&#xA;Coin3009W Conflict graph built in 0.000 seconds, density: 0.907%&#xA;Cgl0015I Clique Strengthening extended 0 cliques, 0 were dominated&#xA;Cbc0038I Initial state - 0 integers unsatisfied sum - 0&#xA;Cbc0038I Solution found of 0&#xA;Cbc0038I Relaxing continuous gives 0&#xA;Cbc0038I Before mini branch and bound, 44 integers at bound fixed and 5 continuous&#xA;Cbc0038I Mini branch and bound did not improve solution (0.00 seconds)&#xA;Cbc0038I After 0.00 seconds - Feasibility pump exiting with objective of 0 - took 0.00 seconds&#xA;Cbc0012I Integer solution of 0 found by feasibility pump after 0 iterations and 0 nodes (0.00 seconds)&#xA;Cbc0001I Search completed - best objective 0, took 0 iterations and 0 nodes (0.00 seconds)&#xA;Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost&#xA;Total time (CPU seconds):       0.00   (Wallclock seconds):       0.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9449" LastActivityDate="2022-03-29T08:04:41.273" Title="MIP gives out zero as best solution when trying to optimize MIP model for flexible job-hop" Tags="|mixed-integer-programming|python|scheduling|job-shop-scheduling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8156" PostTypeId="1" AcceptedAnswerId="8157" CreationDate="2022-03-28T17:26:32.353" Score="5" ViewCount="830" Body="&lt;p&gt;Everyone knows how to model max-min or min-max problems. I have a problem with objective to maximize min-max. So it can be called as a max-min-max problem. Any ideas how to model it efficiently?&lt;/p&gt;&#xA;&lt;p&gt;The objective function looks like: &lt;span class=&quot;math-container&quot;&gt;$$\max\quad\min_i\max_jx_{i,j}$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_{i, j}$&lt;/span&gt; are integer variables.&lt;/p&gt;&#xA;" OwnerUserId="9450" LastEditorUserId="123" LastEditDate="2022-03-29T06:56:10.517" LastActivityDate="2022-03-29T06:56:10.517" Title="How to model a max-min-max problem?" Tags="|optimization|modeling|minimax|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8157" PostTypeId="2" ParentId="8156" CreationDate="2022-03-28T18:43:11.600" Score="6" Body="&lt;p&gt;Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$\lambda_{i,j}$&lt;/span&gt; together with the constraints &lt;span class=&quot;math-container&quot;&gt;$$\sum_j \lambda_{i,j} = 1 \quad \forall i. \quad(1)$$&lt;/span&gt; Next, add continuous variables &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; defined by the constraints &lt;span class=&quot;math-container&quot;&gt;$$w_i =\sum_{j} \lambda_{i,j} x_{i,j}.\quad(2)$$&lt;/span&gt;If &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a variable, there is a trick for linearizing the products &lt;span class=&quot;math-container&quot;&gt;$\lambda_{i,j} x_{i,j},$&lt;/span&gt; documented in multiple answers on this site.&lt;/p&gt;&#xA;&lt;p&gt;Finally, introduce a variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; together with the constraints &lt;span class=&quot;math-container&quot;&gt;$$z\le w_i \quad \forall i \quad(3)$$&lt;/span&gt;and set the objective to maximize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; will be the minimum of the &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt;, and for any &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$z=w_i$&lt;/span&gt; constraints (1) to (3) plus the goal of maximizing &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; will ensure that &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; is the largest of the &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-28T18:43:11.600" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8158" PostTypeId="2" ParentId="8155" CreationDate="2022-03-29T08:04:41.273" Score="1" Body="&lt;p&gt;Although we would need to see your model to really be able to tell what's happening, as a new practitioner here's a few things that you might find helpful:&lt;/p&gt;&#xA;&lt;p&gt;First, zero can be a perfectly legitimate solution, especially since CBC proved that it's a globally optimal value. What you are interested in is the solution vector, not necessarily the optimal value of the objective per se.&lt;/p&gt;&#xA;&lt;p&gt;Second, zero is actually a very common result for MIPs, since it's the minimum of a sum of binary variables with positive coefficients (assuming you're minimising). If that's your objective formulation, getting zero implies that none of your constraints was active at the global solution. This typically indicates that you forgot to add a constraint. I'm particularly suspicious that this is the case here since all your integers are binaries.&lt;/p&gt;&#xA;&lt;p&gt;Third, especially if your objective coefficients have different signs, you should get suspicious that it might simply be that this is a legitimate answer to your problem and there's nothing wrong with your model. For sanity, double check your constraints to see if any of them are active at that solution and of course think about whether zero makes physical sense for what your objective is supposed to represent.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2022-03-29T08:04:41.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8159" PostTypeId="1" CreationDate="2022-03-29T13:04:38.363" Score="4" ViewCount="112" Body="&lt;p&gt;I have a database of real-time optional trip demands. Each with a load that needs to be delivered from a departure point to a destination:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ID,EndDateEnd,EndDateStart,StartDateEnd,StartDateStart,DepX,DepY,ArrX,ArrY&#xA;1,2021-03-04,2021-03-03,2021-03-02,2021-03-01,2.83689,47.3324,-0.5854,44.83814&#xA;2,2021-03-04,2021-03-03,2021-03-02,2021-03-01,2.44774,47.56044,0.13888,49.49015&#xA;3,2021-03-10,2021-03-09,2021-03-08,2021-03-07,2.76755,47.97472,0.65567,48.78064&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It is a list of load offers that companies need delivered at a certain location and time.&lt;/p&gt;&#xA;&lt;p&gt;My goal is to bundle pairs of loads that increase my truck's paid miles. I normally have a set destination and origin. Let's say I'm going from NYC to CHICAGO. Then I search on the trip database for loads that need to be delivered along that route. Imagine I find one with a pickup in Pittsburg and delivery in Cleveland. Then my paid miles would be the driving distance from Pittsburg to Cleveland. But I'm not getting paid for getting from NYC to Pittsburg or from Cleveland to Chicago. A picture is better for explaining:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3QDA7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3QDA7.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In blue you can see the paid miles and red the not paid miles. If I could find another load from NYC to Pittsburgh it would be great or Cleveland-Chicago as well.&lt;/p&gt;&#xA;&lt;p&gt;Now the question is how can I algorithmically find pairs of loads that &lt;strong&gt;go well together&lt;/strong&gt; given a route? I know my start and end of the trip. I just need to go through the list of trips to find the best ones for me.&lt;/p&gt;&#xA;&lt;p&gt;-Going well together is a loose definition. Generally speaking increasing the % of paid miles is the goal.&lt;/p&gt;&#xA;&lt;p&gt;One solution I have researched:&lt;/p&gt;&#xA;&lt;p&gt;You could define that two loads &amp;quot;go well together&amp;quot; if the miles driven from only one truck doing both loads is lower than two trucks doing each one of the loads.&lt;/p&gt;&#xA;&lt;p&gt;That is the intuition behind the Clark and Wright Savings Method.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/t1Hsv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/t1Hsv.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Being d your favourite distance function. In our example, start is NYC and END is Chicago. The pickups and deliveries are from the candidate pairs of bundles. If the savings are high then it is a good bundle.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;This is a type of vehicle routing problem that is sometimes called pick up and delivery with time windows(PDPTW) I'm trying to solve a smaller part of them problem. Just finding useful pairs of trips.&lt;/p&gt;&#xA;&lt;p&gt;Are there any other solutions out there? Scaleable approaches to bundling?&lt;/p&gt;&#xA;&lt;p&gt;Relevant Research Papers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0377221709002999&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pick up and delivery problems&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://api.research-repository.uwa.edu.au/ws/portalfiles/portal/33899497/THESIS_DOCTOR_OF_PHILOSOPHY_BRAUN_Hendrik_2018.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Freight market&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9452" LastEditorUserId="500" LastEditDate="2022-03-29T13:50:44.567" LastActivityDate="2022-03-30T19:53:43.897" Title="How to bundle pairs of trips?" Tags="|optimization|mixed-integer-programming|vehicle-routing|matching|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8160" PostTypeId="2" ParentId="8159" CreationDate="2022-03-29T13:50:36.033" Score="3" Body="&lt;p&gt;If you care only about pairing and not routing, you have a maximum-weight matching problem.  For each compatible pair &lt;span class=&quot;math-container&quot;&gt;$\{i,j\}$&lt;/span&gt; of loads, let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; indicate whether these loads will be paired, and let &lt;span class=&quot;math-container&quot;&gt;$s_{ij}$&lt;/span&gt; be the corresponding savings.  The problem is to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j} s_{ij} x_{ij}$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j:\ k \in \{i,j\}} x_{ij} \le 1 \quad \text{for all loads $k$}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-03-30T12:14:16.813" LastActivityDate="2022-03-30T12:14:16.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8161" PostTypeId="1" CreationDate="2022-03-29T20:47:35.397" Score="1" ViewCount="26" Body="&lt;p&gt;I want to generate 2x6 dataframe which represents a rack to optimizing a dual cycle in optimizing warehouse.Half of this dataframe are filled with storage items and the other half is with retrieval items. I want to do is random chosing half of these 12 items and say that they are storage and others are retrieval. How can I randomly choose?&lt;/p&gt;&#xA;&lt;p&gt;I tried random.sample but this chooses random columns.Actually I want to choose random items individually.&lt;/p&gt;&#xA;" OwnerUserId="9245" LastActivityDate="2022-03-29T20:58:13.380" Title="dual cycle data generation" Tags="|optimization|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8162" PostTypeId="2" ParentId="8161" CreationDate="2022-03-29T20:58:13.380" Score="1" Body="&lt;p&gt;Assign each of the 12 items a number drawn from the U[0,1] distribution. The six items with the lowest uniform values are &amp;quot;storage&amp;quot;, the six with the highest values are &amp;quot;retrieval&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-29T20:58:13.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8163" PostTypeId="1" AcceptedAnswerId="8167" CreationDate="2022-03-30T01:13:20.120" Score="5" ViewCount="226" Body="&lt;p&gt;A familiar &lt;a href=&quot;https://en.wikipedia.org/wiki/Knapsack_problem#0-1_knapsack_problem&quot; rel=&quot;noreferrer&quot;&gt;dynamic programming algorithm for the binary knapsack problem&lt;/a&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\text{maximize}\quad &amp;amp; v \cdot x \\&#xA;\text{subject to} \quad &amp;amp; w \cdot x \leq W \\&#xA;\quad&amp;amp;x_i \text{ binary}&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is as follows: Let &lt;span class=&quot;math-container&quot;&gt;$m[i, w]$&lt;/span&gt; denote the highest utility achievable in a knapsack that uses only the first &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; items and has capacity &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;. Then the optimal objective value is &lt;span class=&quot;math-container&quot;&gt;$m[n, W]$&lt;/span&gt; which can be computed using the following recursion relation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;m[0, w] &amp;amp;= 0 \\&#xA;m[i, w] &amp;amp;= \begin{cases}&#xA;m[i-1, w], \quad &amp;amp;w_i &amp;gt; W \\&#xA;\min\lbrace m[i-1, w], m[i-1, w - w_i] + v_i\rbrace, \quad&amp;amp; w_i \leq W&#xA;\end{cases}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;A standard way to implement this algorithm is to fill an &lt;span class=&quot;math-container&quot;&gt;$n \times W$&lt;/span&gt; array with the &lt;span class=&quot;math-container&quot;&gt;$m[i, w]$&lt;/span&gt;-values, then determine the optimal solution by iterating backwards from &lt;span class=&quot;math-container&quot;&gt;$m[n, W]$&lt;/span&gt; by observing that &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$m[i, w] &amp;gt; m[i-1, w]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As Wikipedia notes (emphasis mine),&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This solution will therefore run in &lt;span class=&quot;math-container&quot;&gt;$O(nW)$&lt;/span&gt; time and &lt;span class=&quot;math-container&quot;&gt;$O(nW)$&lt;/span&gt; space. &lt;strong&gt;(If we only need the value &lt;span class=&quot;math-container&quot;&gt;$m[n,W]$&lt;/span&gt;, we can modify the code so that the amount of memory required is &lt;span class=&quot;math-container&quot;&gt;$O(W)$&lt;/span&gt; which stores the recent two lines of the array &lt;code&gt;m&lt;/code&gt;.)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Wikipedia doesn't cite any sources here, and I am curious if this is truly the state of the art. Suppose that I &lt;em&gt;do&lt;/em&gt; want the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;-vector and not just the objective value. &lt;strong&gt;Is &lt;span class=&quot;math-container&quot;&gt;$O(nW)$&lt;/span&gt;-space the best we can do?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;... or is there a clever way to organize the two-line table that keeps track of whether or not each &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt; and uses &lt;span class=&quot;math-container&quot;&gt;$O(W)$&lt;/span&gt;-space after all?&lt;/li&gt;&#xA;&lt;li&gt;... or is there a way to prove that the solution cannot use less than &lt;span class=&quot;math-container&quot;&gt;$O(nW)$&lt;/span&gt;-space unless (for example) P = NP?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;N.B. This question is &lt;em&gt;exclusively&lt;/em&gt; concerned with the implementation of the item-weight-based dynamic program given above. I know that there are other algorithms for the knapsack problem with lighter space requirements.&lt;/p&gt;&#xA;" OwnerUserId="4463" LastActivityDate="2022-03-31T08:33:54.590" Title="Dynamic program for knapsack in $O(W)$ space?" Tags="|knapsack|dynamic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8165" PostTypeId="2" ParentId="8159" CreationDate="2022-03-30T07:17:31.900" Score="2" Body="&lt;p&gt;Since delivery must be done directly after pick up, it looks more like an Asymmetric Orienteering problem to me, where a visit corresponds to a pick up and its delivery. The subtlety in this case compared to the traditional Orienteering problem is that visiting a location takes some time.&lt;/p&gt;&#xA;&lt;p&gt;Input:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; locations, an &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt; matrix containing the distances between each pair of locations (not symmetric); for each location &lt;span class=&quot;math-container&quot;&gt;$j = 1..n$&lt;/span&gt;, a profit &lt;span class=&quot;math-container&quot;&gt;$p_j$&lt;/span&gt; and a visiting time &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;a time limit &lt;span class=&quot;math-container&quot;&gt;$t_\text{max}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Problem:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Find a path starting at location &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and ending at location &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; such that:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;each location is visited at most once&lt;/li&gt;&#xA;&lt;li&gt;the arrival at location &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is before &lt;span class=&quot;math-container&quot;&gt;$t_\text{max}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Objective:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Maximize the total profit of the visited locations&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I can propose you an alternative greedy approach that builds a solution following a &amp;quot;forward&amp;quot; scheme (i.e. adding the visits in the order they are performed), using the profit / time to asses the quality of the partial solutions:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solution &amp;lt;- []&#xA;current_time &amp;lt;- 0&#xA;current_profit &amp;lt;- 0&#xA;current_location &amp;lt;- 1&#xA;while True&#xA;    best_location &amp;lt;- -1&#xA;    best_value &amp;lt;- -1&#xA;    for each new_location in the remaining locations&#xA;        new_time &amp;lt;- current_time + distance(current_location, new_location) + visit_time(new_location)&#xA;        # Check time limit constraint.&#xA;        if new_time + distance(new_location, n) &amp;gt; time_limit&#xA;            continue&#xA;        new_profit &amp;lt;- current_profit + profit(new_location)&#xA;        new_value &amp;lt;- new_profit / new_time&#xA;        if best_location == -1 or best_value &amp;lt; new_value:&#xA;            best_location &amp;lt;- new_location&#xA;            best_value &amp;lt;- new_value&#xA;    # If no more visit can be added, then stop.&#xA;    if best_location == -1:&#xA;        break&#xA;    # Update current solution.&#xA;    solution.append(best_location)&#xA;    current_time &amp;lt;- current_time + distance(current_location, best_location) + visit_time(new_location)&#xA;    current_profit &amp;lt;- current_profit + profit(best_location)&#xA;    current_location &amp;lt;- best_location&#xA;return solution&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It's what looks the most natural to me. With more time for the development and the resolution, I would consider extending it into a tree search algorithm&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2022-03-30T19:53:43.897" LastActivityDate="2022-03-30T19:53:43.897" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8166" PostTypeId="1" AcceptedAnswerId="8168" CreationDate="2022-03-30T14:05:18.093" Score="7" ViewCount="566" Body="&lt;p&gt;I am currently using the &lt;code&gt;cbc&lt;/code&gt; solver with Pyomo&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;opt = SolverFactory('cbc')&#xA;opt.solve(model)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How can more options for Cbc be used, such that what we run using Pyomo is similar to:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cbc -cuts off -strong 0 -preprocess off -heuristic off -solve&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9412" LastActivityDate="2022-03-30T19:50:15.910" Title="Using CBC CLI Arguments in Pyomo" Tags="|linear-programming|pyomo|cbc|coin-or|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8167" PostTypeId="2" ParentId="8163" CreationDate="2022-03-30T18:23:53.300" Score="5" Body="&lt;p&gt;There is a recursive scheme which makes it possible to retrieve the optimal solution with an &lt;span class=&quot;math-container&quot;&gt;$O(n + W)$&lt;/span&gt; memory. It is described in Section 3.3 of the book &lt;a href=&quot;https://link.springer.com/book/10.1007/978-3-540-24777-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Knapsack Problems&amp;quot; (Kellerer et al., 2004)&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In case you're interested, I've done a C++ implementation &lt;a href=&quot;https://github.com/fontanf/knapsacksolver/blob/master/knapsacksolver/algorithms/bellman.cpp#L542&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, and a comparison between the different ways to retrieve the optimal solution &lt;a href=&quot;https://github.com/fontanf/knapsacksolver#dynamic-programming-cost-of-retrieving-an-optimal-solution&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2022-03-31T08:33:54.590" LastActivityDate="2022-03-31T08:33:54.590" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8168" PostTypeId="2" ParentId="8166" CreationDate="2022-03-30T19:50:15.910" Score="6" Body="&lt;p&gt;You can use &lt;code&gt;opt.options['Solver parameter to change']='value'&lt;/code&gt;. The following is part of the code that I tried and the generated output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;opt.options['heuristics'] = 'off'&#xA;opt.options['preprocess'] = 'off'&#xA;opt.options['loglevel'] = 50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Pyomo's output:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;command line - ampl cbc heuristics off preprocess off loglevel 50 heuristics off preprocess off loglevel 50 -solve -quit (default strategy 1)&lt;/p&gt;&#xA;&lt;p&gt;Option for heuristicsOnOff changed from on to off&lt;/p&gt;&#xA;&lt;p&gt;Option for preprocess changed from sos to off&lt;/p&gt;&#xA;&lt;p&gt;The list of options for cbc can be found &lt;a href=&quot;https://ampl.com/products/solvers/all-solvers-for-ampl/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2022-03-30T19:50:15.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8169" PostTypeId="2" ParentId="8145" CreationDate="2022-03-30T21:46:43.250" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://developers.google.com/optimization/examples&quot; rel=&quot;nofollow noreferrer&quot;&gt;This page&lt;/a&gt; includes all the codes for the instances that are written to be used in the Google-Or tool. Variety of languages such as C++, Python, DotNet and Java are used to write the codes and solve the instances using Google-OR tool.&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2022-03-30T21:46:43.250" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8170" PostTypeId="1" AcceptedAnswerId="8184" CreationDate="2022-03-30T21:47:16.113" Score="3" ViewCount="1197" Body="&lt;p&gt;I have an optimization problem and I want to convert the following if conditions to linear constraints:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$(y_1 &amp;gt; U_1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(m_1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(E_1)$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_1=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$(y_2 &amp;gt; U_2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(m_2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(E_2)$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_2=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$(y_1-U_1) \geq (y_2-U_2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(x_1)$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$X_1=1$&lt;/span&gt; elseif &lt;span class=&quot;math-container&quot;&gt;$(x_2)$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$X_2=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2, X_1, X_2 \in \{0,1\}$&lt;/span&gt; are binary variables, &lt;span class=&quot;math-container&quot;&gt;$y_1,y_2$&lt;/span&gt; are positive real decision variables, &lt;span class=&quot;math-container&quot;&gt;$m_1,m_2,E_1,E_2 \in \{0,1\}$&lt;/span&gt; are binary parameters and &lt;span class=&quot;math-container&quot;&gt;$U_1, U_2$&lt;/span&gt; are parameters.&lt;/p&gt;&#xA;&lt;p&gt;Can anybody help me to convert these conditions to linear constraints?&lt;/p&gt;&#xA;" OwnerUserId="9461" LastEditorUserId="123" LastEditDate="2022-03-31T06:54:41.560" LastActivityDate="2022-04-02T13:54:40.937" Title="Converting if conditions to linear constraints" Tags="|optimization|mixed-integer-programming|linearization|logical-constraints|indicator-constraints|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8171" PostTypeId="1" CreationDate="2022-03-30T22:51:12.273" Score="2" ViewCount="329" Body="&lt;p&gt;Within B&amp;amp;B when it comes to select variables to branch on, I can use the concept of &amp;quot;strong branching&amp;quot;. The optimizer, in my case CPLEX, then performs branching on variables it selects.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible, to allow the user to select the candidate list for strong branching at least at the root node?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2022-03-31T06:54:05.927" LastActivityDate="2022-03-31T06:54:05.927" Title="Strong branching" Tags="|mixed-integer-programming|cplex|branch-and-bound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8172" PostTypeId="2" ParentId="8170" CreationDate="2022-03-30T23:45:29.050" Score="3" Body="&lt;p&gt;Define four binary variables &lt;span class=&quot;math-container&quot;&gt;$t_1^+$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t_1^-$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t_2^+$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t_2^-$&lt;/span&gt; and also define &lt;span class=&quot;math-container&quot;&gt;$s_1=m_1E_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s_2=m_2E_2$&lt;/span&gt;. Obviously &lt;span class=&quot;math-container&quot;&gt;$s_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s_2$&lt;/span&gt; are binary parameters. The following constraints set (&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a large positive number) will do the logical constraints that you have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{rcl}&#xA;t_1^+ + t_1^-= 1\\&#xA;-t_1^-M&amp;lt;y_1-U_1&amp;lt;t_1^+M\\&#xA;(1-t_1^-)s_1&amp;lt;x_1&amp;lt;t_1^+s_1\\&#xA;\end{array}&#xA;\right.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{rcl}&#xA;t_2^+ + t_2^-= 1\\&#xA;-t_2^-M&amp;lt;y_2-U_2&amp;lt;t_2^+M\\&#xA;(1-t_2^-)s_2&amp;lt;x_2&amp;lt;t_2^+s_2\\&#xA;\end{array}&#xA;\right.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;These sets of constraints will model the first two constraints in the question. The last condition can be captured using the following set of constraints, again here two more binary variables &lt;span class=&quot;math-container&quot;&gt;$t_3^+$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t_3^-$&lt;/span&gt; need to be defined:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{rcl}&#xA;t_3^+ + t_3^-= 1\\&#xA;-t_3^-M&amp;lt;(y_1-y_2)-(U_1-U_2)&amp;lt;t_3^+M\\&#xA;X_1\leq(1-t_3^+)+x_1\\&#xA;X_2\leq(1-t_3^+)+x_2\\&#xA;X_1\leq t_3^+\\&#xA;X_2\leq t_3^+\\&#xA;\end{array}&#xA;\right.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2022-03-31T00:16:12.647" LastActivityDate="2022-03-31T00:16:12.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8173" PostTypeId="1" AcceptedAnswerId="8176" CreationDate="2022-03-31T01:18:57.243" Score="7" ViewCount="243" Body="&lt;p&gt;I'm building a manufacturing line optimization model.  Part of the model is (lightly) penalizing running the line on the weekend.  With time in minutes and &lt;code&gt;t=0&lt;/code&gt; representing 12:00:01 am Monday, the weekend begins at &lt;code&gt;t=7200&lt;/code&gt; (end of 5 days, start of Saturday) and ends at &lt;code&gt;t=10080&lt;/code&gt; (end of 7 days, start of Monday).  I have decision variables around when a manufacturing run starts and ends.  I'd like to make a decision variable to quantify how much of the manufacturing run occurs on the weekend (not just if it does or not - I want to know the magnitude.)&lt;/p&gt;&#xA;&lt;p&gt;So for example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;run start time = 7000, run end time = 7199 : 0 overlap (weekend minutes)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;run start time = 7000, run end time = 7300 : 100 overlap&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;run start time = 8000, run end time = 9000 : 1000 overlap&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;run start time = 10000, run end time = 11000 : 920 overlap&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;To clarify, a manufacturing run can overlap the weekend either not at all, partially, or entirely.  I'm modeling a monthly or longer time horizon, so I'd repeat the procedure for 4+ weekends.&lt;/p&gt;&#xA;&lt;p&gt;All the posts I've seen are just to identify if an overlap occurs, not a magnitude.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastEditorUserId="199" LastEditDate="2022-04-01T16:32:50.047" LastActivityDate="2022-04-01T16:32:50.047" Title="MILP - quantify magnitude of overlap" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8174" PostTypeId="2" ParentId="8170" CreationDate="2022-03-31T01:30:54.477" Score="4" Body="&lt;p&gt;You need only one additional binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, which will indicate whether &lt;span class=&quot;math-container&quot;&gt;$y_1 - U_1 \ge y_2 - U_2$&lt;/span&gt;, with the usual caveat that the equality case can correspond to either value of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can use indicator constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_1 = 0 &amp;amp;\implies y_1 \le U_1 &amp;amp;&amp;amp;\text{if $m_1 = 1$ and $E_1 = 1$} \\&#xA;x_2 = 0 &amp;amp;\implies y_2 \le U_2 &amp;amp;&amp;amp;\text{if $m_2 = 1$ and $E_2 = 1$} \\&#xA;z = 1 &amp;amp;\implies y_1 - U_1 \ge y_2 - U_2 \\&#xA;z = 0 &amp;amp;\implies y_1 - U_1 \le y_2 - U_2 \\&#xA;X_1 = 0 &amp;amp;\implies z + x_1 \le 1 \\&#xA;X_2 = 0 &amp;amp;\implies z \ge x_2 \\&#xA;X_2 = 0 &amp;amp;\implies x_1 \ge x_2&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, use big-M constraints.  For &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,2\}$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$\bar{y}_i$&lt;/span&gt; be an upper bound on &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; and impose:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_1 - U_1 &amp;amp;\le (\bar{y}_1 - U_1) x_1 &amp;amp;&amp;amp;\text{if $m_1 = 1$ and $E_1 = 1$} \\&#xA;y_2 - U_2 &amp;amp;\le (\bar{y}_2 - U_2) x_2 &amp;amp;&amp;amp;\text{if $m_2 = 1$ and $E_2 = 1$} \\&#xA;(y_2 - U_2) - (y_1 - U_1) &amp;amp;\le (\bar{y}_2 + U_1 - U_2)(1-z) \\&#xA;(y_1 - U_1) - (y_2 - U_2) &amp;amp;\le (\bar{y}_1 - U_1 + U_2)z \\&#xA;z + x_1 - 1 &amp;amp;\le X_1 \\&#xA;x_2 -z &amp;amp;\le X_2 \\&#xA;x_2 - x_1 &amp;amp;\le X_2&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-03-31T01:36:23.993" LastActivityDate="2022-03-31T01:36:23.993" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8175" PostTypeId="2" ParentId="8171" CreationDate="2022-03-31T02:28:19.577" Score="2" Body="&lt;p&gt;I don't think that option is explicitly supported in CPLEX. There might be a workaround, assuming you knew your candidate list before you started solving. (Warning: I'm speculating here.) You could try assigning a priority order to the integer variables, giving variables on your candidate list a priority of 1 and variables not on the list a priority of zero. Then set the variable selection parameter to strong branching and the node limit to 1 (if you want to stop at the root node) or something larger (if you want to restrict to your candidate list for a while). Once the solver hits the node limit, delete the priorities, remove the node limit and call solve() again. Since you made no changes to the model, the solver should resume from the partial tree left by the initial run. I'm not positive that priorities trump strong branching and that strong branching is used to break priority ties, but it seems plausible.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-03-31T02:28:19.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8176" PostTypeId="2" ParentId="8173" CreationDate="2022-03-31T10:20:10.877" Score="9" Body="&lt;p&gt;If you just want to know the magnitude of the overlap after optimization, then you can use the following formula for a given job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, if &lt;span class=&quot;math-container&quot;&gt;$\mbox{start}_i &amp;lt; 10800$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max\{0,\min\{\mbox{end}_i,10800\}-\max\{\mbox{start}_i,7200\}\} \tag{0}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you want to use the overlap in your model as a variable, then you can proceed as follows:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$s,e$&lt;/span&gt; denote the start and end time variables, respectively. Let &lt;span class=&quot;math-container&quot;&gt;$\ell, u$&lt;/span&gt; denote the start and end times of the weekend, respectively.&lt;/p&gt;&#xA;&lt;p&gt;Also, let &lt;span class=&quot;math-container&quot;&gt;$\delta_1 \in \{0,1\}$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$\ell &amp;lt; s &amp;lt; u$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$\delta_2 \in \{0,1\}$&lt;/span&gt; be another binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$\ell &amp;lt; e &amp;lt; u$&lt;/span&gt;,  let &lt;span class=&quot;math-container&quot;&gt;$\delta_3 \in \{0,1\}$&lt;/span&gt; be another binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$e \le \ell$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$\delta_4 \in \{0,1\}$&lt;/span&gt; be another binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$s \ge u$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And finally, let &lt;span class=&quot;math-container&quot;&gt;$O\in \mathbb{R}^+$&lt;/span&gt; denote the magnitude of the overlap.&lt;/p&gt;&#xA;&lt;p&gt;You want to model the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mRuf3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mRuf3.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or in algebraic terms:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\ell &amp;lt; s &amp;lt; u \quad &amp;amp;\Longleftrightarrow \quad \delta_1 \tag{1} \\&#xA;\ell &amp;lt; e &amp;lt; u \quad &amp;amp;\Longleftrightarrow  \quad \delta_2 \tag{2} \\&#xA;e \le \ell \quad &amp;amp;\Longleftrightarrow  \quad \delta_3 \tag{3} \\&#xA;u \le s \quad &amp;amp;\Longleftrightarrow  \quad \delta_4 \tag{4} \\&#xA;\delta_1 \wedge \delta_2 \quad &amp;amp;\Longrightarrow \quad O = e-s \tag{5} \\&#xA;\delta_1 \wedge \neg \delta_2 \quad &amp;amp;\Longrightarrow \quad O = u-s \tag{6} \\&#xA;\neg \delta_1 \wedge \delta_2 \quad &amp;amp;\Longrightarrow \quad O = e-\ell \tag{7} \\&#xA;\neg \delta_1 \wedge \neg \delta_2 \wedge (\delta_3 \vee \delta_4)   \quad &amp;amp;\Longrightarrow \quad O = 0 \tag{8} \\&#xA;\neg \delta_1 \wedge \neg \delta_2 \wedge  \neg \delta_3 \wedge  \neg \delta_4  \quad &amp;amp;\Longrightarrow \quad O = u - \ell \tag{9}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, use the following big M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\ell + \epsilon -M(1-\delta_1) \le s \le u - \epsilon + M(1-\delta_1) \tag{1a} \\&#xA;u -M(1-y_1) \le s \le \ell + M(1-y_2) \tag{1b} \\&#xA;\delta_1+y_1 +y_2 = 1 \tag{1c} \\&#xA;\delta_1,y_1, y_2 \in \{0,1\}&#xA;\end{align}&lt;/span&gt;&#xA;For &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, use the following big M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\ell + \epsilon-M(1-\delta_2) \le e \le u -\epsilon + M(1-\delta_2)  \tag{2a}\\&#xA;u -M(1-y_3) \le e \le \ell + M(1-y_4) \tag{2b} \\&#xA;\delta_2+y_3 +y_4 = 1 \tag{2c} \\&#xA;\delta_2,y_3, y_4 \in  \{0,1\}&#xA;\end{align}&lt;/span&gt;&#xA;For &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;, use the following big M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\ell + \epsilon -M\delta_3 \le e \le \ell  +M(1-\delta_3)  \tag{3a}\\&#xA;\delta_3 \in \{0,1\}&#xA;$$&lt;/span&gt;&#xA;For &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt;, use the following big M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA; u -  M(1-\delta_4)\le s \le u - \epsilon + M \delta_4  \tag{4a}  \\&#xA;\delta_4 \in \{0,1\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt;, use the following big M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;e - s - M (2-\delta_1 - \delta_2) \le O \le e - s + M (2-\delta_1 - \delta_2) \tag{5a} \\&#xA;\delta_1,\delta_2 \in \{0,1\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt;, use the following big M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;u - s - M (1-\delta_1 + \delta_2) \le O \le u - s + M (1-\delta_1 + \delta_2) \tag{6a}\\&#xA;\delta_1,\delta_2 \in \{0,1\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt;, use the following big M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;e - \ell - M (1-\delta_2 + \delta_1) \le O \le e - \ell + M (1-\delta_2 + \delta_1) \tag{7a}\\&#xA;\delta_1,\delta_2 \in \{0,1\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$(8)$&lt;/span&gt;, use the following big M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0 - M (\delta_1 + \delta_2 + 1- \delta_3) \le O \le 0 + M (\delta_1 + \delta_2 + 1-\delta_3 ) \tag{8a} \\&#xA;0 - M (\delta_1 + \delta_2 + 1 -\delta_4) \le O \le 0 + M (\delta_1 + \delta_2 + 1-\delta_4 ) \tag{8b} \\&#xA;\delta_1,\delta_2,\delta_3,\delta_4 \in \{0,1\}&#xA;\end{align}&lt;/span&gt;&#xA;For &lt;span class=&quot;math-container&quot;&gt;$(9)$&lt;/span&gt;, use the following big M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;u - \ell - M (\delta_1 + \delta_2 +  \delta_3 + \delta_4) \le O \le u - \ell + M (\delta_1 + \delta_2 + \delta_3 + \delta_4 )  \tag{9a}\\&#xA;\delta_1,\delta_2,\delta_3,\delta_4 \in \{0,1\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note also that by definition &lt;span class=&quot;math-container&quot;&gt;$\delta_1 \; \Longrightarrow \; \neg \delta_3$&lt;/span&gt;,  &lt;span class=&quot;math-container&quot;&gt;$\delta_1 \; \Longrightarrow \; \neg \delta_4$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\delta_2 \; \Longrightarrow \; \neg \delta_3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\delta_2 \; \Longrightarrow \; \neg \delta_4$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\delta_1 \le 1- \delta_3 \\&#xA;\delta_1 \le 1- \delta_4 \\&#xA;\delta_2 \le 1- \delta_3 \\&#xA;\delta_2 \le 1- \delta_4 \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Note : Ideally, distinguish the different big &lt;span class=&quot;math-container&quot;&gt;$Ms$&lt;/span&gt;. Also, I would not be surprised if the above constraints could be simplified. In particular, I am not 100% sure if the double implication is required in constraints &lt;span class=&quot;math-container&quot;&gt;$(1)-(4)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Addendum&lt;/h3&gt;&#xA;&lt;p&gt;OP uses a formulation which linearizes equation &lt;span class=&quot;math-container&quot;&gt;$(0)$&lt;/span&gt;, without any binary variables. OP minimizes &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;O &amp;amp;\ge u - \ell - \alpha - \beta \\&#xA;\alpha &amp;amp;\ge s- \ell \\&#xA;\beta &amp;amp;\ge u -e \\&#xA;\alpha, \beta, O &amp;amp;\ge 0 \\&#xA;\end{align}&lt;/span&gt;&#xA;which is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;O &amp;amp;\ge (u  - \max\{u -e, 0\}) - (\ell + \max\{s- \ell, 0\})\\&#xA;O &amp;amp;\ge 0 &#xA;\end{align}&lt;/span&gt;&#xA;or&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;O &amp;amp;\ge \min\{u,e\} - \max\{s,\ell\}\\&#xA;O &amp;amp;\ge 0 &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;O = \max\{0,\min\{u,e\} - \max\{s,\ell\}\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note however that this works because we are minimizing.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-04-01T12:12:43.077" LastActivityDate="2022-04-01T12:12:43.077" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8177" PostTypeId="1" CreationDate="2022-03-31T22:07:16.773" Score="3" ViewCount="454" Body="&lt;p&gt;I am looking to assign tasks to people. Each successive task should be started after the first one is finished and should be started at the same location as the preceding task. While the time constraint works fine, when using circuit constraints for the location constraint, I am not getting the right results. I am looking to allocate all tasks to as few people as possible.&lt;/p&gt;&#xA;&lt;p&gt;Tasks 1-3-4 are a possible sequence. So is 1-3-5, 2-3-4, etc. It is possible for 3 employees to cover all tasks here. I only get 5 employees as the optimal answer&lt;/p&gt;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from collections import defaultdict&#xA;from ortools.sat.python import cp_model&#xA;&#xA;model = cp_model.CpModel()&#xA;solver = cp_model.CpSolver()&#xA;&#xA;tasks = {&#xA;    1: [2, 3, 90, 165], # task_id: start_location, end_location, start_time, end_time&#xA;    2: [2, 3, 160, 265],&#xA;    3: [3, 1, 280, 355],&#xA;    4: [1, 2, 380, 455],&#xA;    5: [1, 2, 810, 885]&#xA;}&#xA;&#xA;employees = range(5)&#xA;assigns = {}&#xA;&#xA;employee_task_intervals = defaultdict(list)&#xA;&#xA;for e in employees:&#xA;    for t in tasks.keys():&#xA;        assigns[e, t] = model.NewBoolVar(f'{t}_{e}')&#xA;        start = model.NewIntVar(0, 1440, f'task_starts_at_{t}_{e}')&#xA;        end = model.NewIntVar(0, 1440, f'task_ends_at_{t}_{e}')&#xA;        duration = tasks[t][3] - tasks[t][2]&#xA;        interval = model.NewOptionalIntervalVar(start, duration, end, assigns[e,t], f'task_interval_{t}_{e}')&#xA;        &#xA;        employee_task_intervals[e].append(interval)&#xA;        &#xA;    model.AddNoOverlap(employee_task_intervals[e])&#xA;&#xA;&#xA;for t in tasks.keys():&#xA;    model.Add(sum(assigns[e,t] for e in employees) == 1) &#xA;&#xA;for e in employees:&#xA;    arcs = []&#xA;    #if no tasks assigned to employee then add a self loop for employee&#xA;    any_active = model.NewBoolVar(f'any_active_task_in_{e}')&#xA;    model.Add( sum(assigns[e, t] for t in tasks.keys()) == 0).OnlyEnforceIf(any_active.Not()) &#xA;    model.Add( sum(assigns[e, t] for t in tasks.keys()) &amp;gt; 0).OnlyEnforceIf(any_active)    &#xA;    arcs.append([0, 0, any_active.Not()]) &#xA;&#xA;&#xA;    for t in range(len(employee_task_intervals[e])):           &#xA;        first = model.NewBoolVar(f'first_{e}_{t}')&#xA;        last = model.NewBoolVar(f'last_{e}_{t}')&#xA;        arcs.append( [0, t+1, first] )&#xA;        arcs.append( [t+1, 0, last] )&#xA;        model.AddImplication(assigns[e,t+1].Not(), first.Not())&#xA;        model.AddImplication(assigns[e,t+1].Not(), last.Not())&#xA;        &#xA;        for i in range(len(employee_task_intervals[e])):            &#xA;            if i == t:                &#xA;                arcs.append([t+1, t+1, assigns[e,t+1].Not()])&#xA;                continue&#xA;            task_follows = model.NewBoolVar(f'task_follows_{i+1}_{t+1}_{e}')          &#xA;            arcs.append([t+1, i+1, task_follows])      &#xA;&#xA;            #next task starts at same location as current stop &#xA;            model.Add(tasks[i+1][0] == tasks[t+1][1]).OnlyEnforceIf(task_follows)&#xA;&#xA;            #if the next stop does not start at same locations, then only one of the two tasks are true for this employee&#xA;            model.Add(assigns[e, t+1]+assigns[e, i+1] &amp;lt;= 1).OnlyEnforceIf(task_follows.Not())&#xA;            &#xA;    model.AddCircuit(arcs)&#xA;&#xA;&#xA;employees_worked = {}&#xA;for e in employees:&#xA;    employee_has_task = model.NewBoolVar(f'used_{e}') &#xA;    model.Add( sum ( assigns[e, t] for t in tasks.keys() ) &amp;gt; 0 ).OnlyEnforceIf(employee_has_task)&#xA;    model.Add( sum ( assigns[e, t] for t in tasks.keys() ) == 0 ).OnlyEnforceIf(employee_has_task.Not())&#xA;    employees_worked[e] = employee_has_task&#xA;&#xA;model.Minimize(sum(employees_worked[e] for e in employees))&#xA;status = solver.Solve(model)&#xA;&#xA;assert status in [cp_model.FEASIBLE, cp_model.OPTIMAL]&#xA;&#xA;for e in employees:&#xA;    for t in tasks.keys():        &#xA;        if solver.BooleanValue(assigns[e, t]):&#xA;            print(f'Employee: {e}, Task: {t}')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Updated code that fixed the problem. I had not sequenced the tasks by time.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for e in employees:&#xA;    arcs = []&#xA;    #if no tasks assigned to employee then add a self loop for employee&#xA;    any_active = model.NewBoolVar(f'any_active_task_in_{e}')&#xA;    model.Add( sum(assigns[e, t] for t in tasks.keys()) == 0).OnlyEnforceIf(any_active.Not()) &#xA;    model.Add( sum(assigns[e, t] for t in tasks.keys()) &amp;gt; 0).OnlyEnforceIf(any_active)    &#xA;    arcs.append([0, 0, any_active.Not()]) &#xA;&#xA;&#xA;    for t in range(len(employee_task_intervals[e])):           &#xA;        first = model.NewBoolVar(f'first_{e}_{t}')&#xA;        last = model.NewBoolVar(f'last_{e}_{t}')&#xA;        arcs.append( [0, t+1, first] )&#xA;        arcs.append( [t+1, 0, last] )&#xA;        model.AddImplication(assigns[e,t+1].Not(), first.Not())&#xA;        model.AddImplication(assigns[e,t+1].Not(), last.Not())&#xA;        &#xA;        for i in range(len(employee_task_intervals[e])):            &#xA;            if i == t:                &#xA;                arcs.append([t+1, t+1, assigns[e,t+1].Not()])&#xA;                continue&#xA;            task_follows = model.NewBoolVar(f'task_follows_{i+1}_{t+1}_{e}')          &#xA;            arcs.append([t+1, i+1, task_follows]) &#xA;            #task must start after previous task &#xA;            model.Add(employee_task_intervals[e][i].StartExpr() &amp;gt;= employee_task_intervals[e][t].EndExpr()).OnlyEnforceIf(task_follows)&#xA;            #task must start at the same location as previous task&#xA;            model.Add(tasks[i+1][0] == tasks[t+1][1]).OnlyEnforceIf(task_follows)&#xA;            model.AddImplication(task_follows, assigns[e,t+1])&#xA;            model.AddImplication(task_follows, assigns[e,i+1])&#xA;                        &#xA;    model.AddCircuit(arcs)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9468" LastEditorUserId="981" LastEditDate="2023-02-19T14:47:55.513" LastActivityDate="2023-02-19T14:47:55.513" Title="Circuit constraints in ortools" Tags="|scheduling|constraint-programming|or-tools|cp-sat|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8178" PostTypeId="2" ParentId="4170" CreationDate="2022-04-01T02:57:12.683" Score="2" Body="&lt;p&gt;In 2017 I was a grizzled veteran of Matlab and a reluctant Python novice. I had just started a new position at a startup that was about to conduct their first trials of their flagship device, second generation. In the scramble of the final days before trial began, a decision was made that calibration should no longer be manual, but automated (because duh). No big deal. Simple Matlab script and Matlab compiler, and we’d be good to go. Afternoon’s worth of work, easy. But I had not yet installed Matlab on my computer. And the guy I replaced hadn’t shared the password to his computer. And we were out of licenses, and had no budget. And when I reached out to Matlab’s support team, I was ping ponged between people who were less than motivated to help our little startup put out this little fire we were dealing with. And when the licensing issue was resolved, I goofed the install (which I hadn’t done myself since I was a student) and needed more help from Matlab support. While all of this was going on, I was also beating my brains against the keyboard learning the nuances of NumPy. By the time I got Matlab up and running, I had already solved the problem, and shipped a critical piece of code in Python. I have not used Matlab again since, and I don’t miss it. A year later, I was promoted to the systems team lead, right around the time we were due to renew our Matlab support. Which we did not do. Python til I die.&lt;/p&gt;&#xA;" OwnerUserId="9469" LastActivityDate="2022-04-01T02:57:12.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8180" PostTypeId="1" CreationDate="2022-04-01T15:56:02.340" Score="2" ViewCount="157" Body="&lt;p&gt;I am working on the following problem and was wondering if anyone can give me some insight.&lt;/p&gt;&#xA;&lt;p&gt;There is a fixed route that a vehicle (V1) with a fixed capacity uses everyday to pickup orders from node 1, 2, and 3 and deliver at node 4. However occasionally the pickup demand on one of the pickup is so high that V1 cannot pickup those orders. For example, as shown in Figure 1, the pickup demand at node 1, 2, and 3 are 25%, 65%, 25% of the capacity of the vehicle. V1 can only pick up order from node 1, and node 2 as it filles up 90% of its capacity. So, it skips node 3, and directly go to node 4 to deliver the items it picked up from node 1 and 2. Another vehicle needs to be sent to node 3 to pick up and deliver at 4.&lt;/p&gt;&#xA;&lt;p&gt;Is there any known way to model and solve it? If you worked on something similar or read any related paper, would you please share?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NYwAH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NYwAH.png&quot; alt=&quot;Example Problem Description&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3288" LastActivityDate="2022-05-01T10:24:55.860" Title="Pick up drop off problem on fixed / dynamic route" Tags="|vehicle-routing|split-delivery-routing|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8181" PostTypeId="2" ParentId="8180" CreationDate="2022-04-01T18:29:48.343" Score="2" Body="&lt;p&gt;If the routes are fixed and pre-defined, the problem can be reduced to a &lt;a href=&quot;https://www.scielo.br/j/pope/a/Mp4Pd8CS86hTKMLKnGhQDsp/?lang=en#:%7E:text=The%20basic%20Container%20Loading%20Problem%20can%20be%20defined%20as%20the,proposed%20by%20W%C3%A4scher%20et%20al.&quot; rel=&quot;nofollow noreferrer&quot;&gt;container loading problem&lt;/a&gt; or a variant of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Bin_packing_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;bin-packing problem&lt;/a&gt;. In both cases, the orders might be split and assigned to the vehicle W.R.T vehicles capacity. Also, this makes flexible loading capacity.&lt;/p&gt;&#xA;&lt;p&gt;Please, be aware that if the routes also need to be optimized, the problem is in the class of VRP variants.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-04-01T18:29:48.343" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8182" PostTypeId="1" CreationDate="2022-04-01T23:38:55.270" Score="1" ViewCount="1240" Body="&lt;p&gt;I have a combinatorial optimization problem where there are three objectives F1, F2, and F3 to be minimized. The problem was formulated as a weighted sum where F=alpha&lt;em&gt;F1+beta&lt;/em&gt;F2+gamma*F3.&#xA;My question is how we choose the weights alpha, beta, and gamma. I tested someone randomly chosen &lt;a href=&quot;https://i.stack.imgur.com/GiF4M.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;. Do you think the weights I choose are logical? from the result in the picture we can see that 0.3 0.35 0.35 is the best combination with that can i use only this combination for all my rest experimentation?&lt;/p&gt;&#xA;" OwnerUserId="7281" LastActivityDate="2022-04-04T07:23:28.630" Title="weight choice in multi-objective weighted sum" Tags="|combinatorial-optimization|multi-objective-optimization|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8183" PostTypeId="1" CreationDate="2022-04-02T07:07:10.833" Score="6" ViewCount="248" Body="&lt;p&gt;I have a two-objective assignment problem that appears to converge really slowly to a solution.&lt;/p&gt;&#xA;&lt;p&gt;Even if we just have 1 objective that minimizes costs, it appears to be very slow for a worker-task matrix has a size of &lt;span class=&quot;math-container&quot;&gt;$500 \times 500$&lt;/span&gt; and using NSGA-2 with a population size of &lt;span class=&quot;math-container&quot;&gt;$500$&lt;/span&gt;. The usual constraints of 1 worker to 1 task is being used here. It takes about 1 minutes to process 1 generations of 500 evaluations.&lt;/p&gt;&#xA;&lt;p&gt;For the &lt;span class=&quot;math-container&quot;&gt;$500 \times 500$&lt;/span&gt; cost matrix, I used a made-up one with a small number &lt;span class=&quot;math-container&quot;&gt;$9$&lt;/span&gt; in the diagonals, and a large number &lt;span class=&quot;math-container&quot;&gt;$123$&lt;/span&gt; in the non-diagonals&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;&#xA;c = np.full((500,500), 123)&#xA;np.fill_diagonal(c, 9)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The objective function to be minimized is the sum of the cost of all assignments, given by&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;min\sum_{w \in W} \sum_{t \in T} C_{w,t} X_{w,t}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$500 \times 500$&lt;/span&gt; matrix containing either &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is the cost matrix containing small numbers in the diagonal.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;n_rows, n_cols = c.shape&#xA;&#xA;def func_obj(x):&#xA;    assignments = x.reshape((n_rows, n_cols))&#xA;    return sum(np.multiply(c, assignments).reshape(-1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and contraints are&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{w=1}^W X_{w,t} = 1 \quad \forall t \in \{ 1, ..., T \}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{t=1}^T X_{w,t} = 1 \quad \forall w \in \{ 1, ..., W \}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;X_{w,t} \in \{0, 1\} \quad \forall w, t&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;When defining the problem, an equality constraint penalty was also set&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ConstraintsAsPenalty(problem, penalty=1e10)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is GA the wrong approach to use for solving two-objective assignment problems, and even for single objective ones like described in the example above? Or is it more likely I've described the problem incorrectly using code, or used poor hyperparameters?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Progress of the minimization process for 50 generations:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;=======================================================&#xA;n_gen |  n_eval |  n_nds  |     eps      |  indicator  &#xA;=======================================================&#xA;    1 |     500 |       1 |            - |            -&#xA;    2 |    1000 |       1 |  1.88000E+12 |        ideal&#xA;    3 |    1500 |       1 |  4.90000E+12 |        ideal&#xA;    4 |    2000 |       1 |  3.14000E+12 |        ideal&#xA;    5 |    2500 |       1 |  3.86000E+12 |        ideal&#xA;    6 |    3000 |       1 |  9.80000E+11 |        ideal&#xA;    7 |    3500 |       1 |  3.98000E+12 |        ideal&#xA;    8 |    4000 |       1 |  2.08000E+12 |        ideal&#xA;    9 |    4500 |       1 |  6.08000E+12 |        ideal&#xA;   10 |    5000 |       1 |  2.10000E+12 |        ideal&#xA;   11 |    5500 |       1 |  2.10000E+12 |        ideal&#xA;   12 |    6000 |       1 |  2.40000E+12 |        ideal&#xA;   13 |    6500 |       1 |  4.66000E+12 |        ideal&#xA;   14 |    7000 |       1 |  1.84000E+12 |        ideal&#xA;   15 |    7500 |       1 |  6.74000E+12 |        ideal&#xA;   16 |    8000 |       1 |  1.46000E+12 |        ideal&#xA;   17 |    8500 |       1 |  4.44000E+12 |        ideal&#xA;   18 |    9000 |       1 |  1.76000E+12 |        ideal&#xA;   19 |    9500 |       1 |  1.48000E+12 |        ideal&#xA;   20 |   10000 |       1 |  4.04000E+12 |        ideal&#xA;   21 |   10500 |       1 |  3.38000E+12 |        ideal&#xA;   22 |   11000 |       1 |  1.98000E+12 |        ideal&#xA;   23 |   11500 |       1 |  5.10000E+12 |        ideal&#xA;   24 |   12000 |       1 |  5.00000E+11 |        ideal&#xA;   25 |   12500 |       1 |  5.86000E+12 |        ideal&#xA;   26 |   13000 |       1 |  0.00000E+00 |            f&#xA;   27 |   13500 |       1 |  7.28000E+12 |        ideal&#xA;   28 |   14000 |       1 |  1.08000E+12 |        ideal&#xA;   29 |   14500 |       1 |  8.80000E+11 |        ideal&#xA;   30 |   15000 |       1 |  3.22000E+12 |        ideal&#xA;   31 |   15500 |       1 |  2.96000E+12 |        ideal&#xA;   32 |   16000 |       1 |  2.44000E+12 |        ideal&#xA;   33 |   16500 |       1 |  6.16000E+12 |        ideal&#xA;   34 |   17000 |       1 |  3.40000E+11 |        ideal&#xA;   35 |   17500 |       1 |  4.22000E+12 |        ideal&#xA;   36 |   18000 |       1 |  2.24000E+12 |        ideal&#xA;   37 |   18500 |       1 |  9.46000E+12 |        ideal&#xA;   38 |   19000 |       1 |  0.00000E+00 |            f&#xA;   39 |   19500 |       1 |  2.38000E+12 |        ideal&#xA;   40 |   20000 |       1 |  2.30000E+12 |        ideal&#xA;   41 |   20500 |       1 |  0.00000E+00 |            f&#xA;   42 |   21000 |       1 |  5.10000E+12 |        ideal&#xA;   43 |   21500 |       1 |  6.80000E+11 |        ideal&#xA;   44 |   22000 |       1 |  5.64000E+12 |        ideal&#xA;   45 |   22500 |       1 |  1.94000E+12 |        ideal&#xA;   46 |   23000 |       1 |  3.64000E+12 |        ideal&#xA;   47 |   23500 |       1 |  2.66000E+12 |        ideal&#xA;   48 |   24000 |       1 |  4.46000E+12 |        ideal&#xA;   49 |   24500 |       1 |  8.00000E+11 |        ideal&#xA;   50 |   25000 |       1 |  3.18000E+12 |        ideal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;giving the following matrix in the results, clearly showing that the constraints of 1 task per worker is not being enforced.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[[ True False  True ...  True  True False]&#xA; [False False False ... False  True False]&#xA; [ True  True  True ... False  True  True]&#xA; ...&#xA; [False False False ...  True  True  True]&#xA; [False False False ...  True False  True]&#xA; [ True  True False ...  True  True  True]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9403" LastEditorUserId="9403" LastEditDate="2022-04-02T15:51:48.237" LastActivityDate="2022-04-02T19:15:29.870" Title="Use GA for Assignment Problem?" Tags="|combinatorial-optimization|assignment-problem|genetic-algorithm|combinatorics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8184" PostTypeId="2" ParentId="8170" CreationDate="2022-04-02T08:25:20.033" Score="2" Body="&lt;p&gt;I implemented both the suggested solutions above but none of them were correct. I solved it myself and the correct solution is as follows (&lt;span class=&quot;math-container&quot;&gt;$s_1=m_1E_1, s_1=m_1E_1$&lt;/span&gt;):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$  -(1-t_1)M \leq y_1-U_1 \leq t_1 M&#xA;  \\ -(1-t_2)M \leq y_2-U_2 \leq t_2 M&#xA;   \\ x_1 \leq t_1s_1 &#xA;  \\ x_2 \leq t_2s_2 &#xA;   \\ &#xA;   -(1-z_1)M\leq (y_1-y_2)-(U_1-U_2) \leq z_1M&#xA;   \\ &#xA;   -(1-z_2)M\leq (y_2-y_1)-(U_2-U_1) \leq z_2M&#xA;   \\ X_1 \leq (1-z_1)+x_1   &#xA;\\ X_2 \leq (1-z_2)+x_2  &#xA;   \\ X_1 \leq z_1 &#xA;   \\ X_2 \leq z_2  $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Hope it is useful for the other guys.&lt;/p&gt;&#xA;" OwnerUserId="9461" LastEditorUserId="9461" LastEditDate="2022-04-02T13:54:40.937" LastActivityDate="2022-04-02T13:54:40.937" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="8185" PostTypeId="1" CreationDate="2022-04-02T09:47:01.710" Score="1" ViewCount="198" Body="&lt;p&gt;I have the licence of some solvers and I want to use these solvers in Pyomo. The licence file is ampl.lic and my machine is Macbook.&#xA;I have an executable file for Baron solver which is only for demo and when I run it for my model I get a licence error. My question is how can I use ampl.lic file to use this solver?&lt;/p&gt;&#xA;" OwnerUserId="9461" LastActivityDate="2022-04-02T09:47:01.710" Title="How to use ampl.lic in Pyomo" Tags="|optimization|solver|ampl|baron|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8186" PostTypeId="2" ParentId="8183" CreationDate="2022-04-02T16:17:37.547" Score="5" Body="&lt;p&gt;I agree with @RobPratt that a GA is not the ideal way to solve an assignment problem. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Assignment_problem#Balanced_assignment&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia entry&lt;/a&gt; for assignment problems lists a few alternatives, and as Rob points out an LP solver should have no problem with it.&lt;/p&gt;&#xA;&lt;p&gt;If you really want to use a GA, I would recommend using a permutation of the task indices as the chromosome rather than using a penalty function for constraint violations. I ran a permutation GA in R, using your 500 x 500 cost matrix (values 123 off diagonal, 9 on diagonal), with a population size of 500 (which I think is too high for this type of problem). It took about 0.85 seconds per generation. I should add that improvement in the objective was very slow.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-04-02T19:15:29.870" LastActivityDate="2022-04-02T19:15:29.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8187" PostTypeId="1" CreationDate="2022-04-03T03:46:57.543" Score="2" ViewCount="119" Body="&lt;p&gt;I have a robust optimization problem where the decision variable is a matrix, and the uncertain parameter is a vector.  My matrix is &lt;code&gt;L&lt;/code&gt;, and the uncertain parameter is &lt;code&gt;x&lt;/code&gt; in the problem below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;clear all;&#xA;sdpvar L(2,2) x(2,1); &#xA;y = 4*x(2) + 3 + L(1,1) + L(2,1)*x(1) + L(2,2)*x(2); % objective function &#xA;F = [0 &amp;lt;= 3 +2*x(2) + 4 + L(1,1)*x(2)]; % constraints &#xA;F = [F, 0 &amp;lt;= L(1,1), 0 &amp;lt;= L(2,1)]; % constraints &#xA;U = [0 &amp;lt;= x(1), x(2) &amp;lt;= 1, 0 &amp;lt;= x(2) , uncertain(x)]; % uncertainty description &#xA;options = sdpsettings('solver', 'bmibnb'); &#xA;result = optimize(F + U, y, options); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The above problem is similar in structure to the problem I want to solve.  However, the scale of my problem is much larger.  This makes it very inconvenient to define the objective function and constraints in the way shown above.  So, I’d like to be able to define my objective function and constraints by passing the work to another function, which takes as input the matrix &lt;code&gt;L&lt;/code&gt; and vector &lt;code&gt;x&lt;/code&gt; as one might expect.  For example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function [result] = y(x, L)                                                  &#xA;  result= 4*x(2) + 3 + L(1,1) + L(2,1)*x(1) + L(2,2)*x(2);&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;One can imagine that this would allow things like &lt;code&gt;for&lt;/code&gt; loops, and other conveniences.  Knowing that my objective function and constraints are linear in &lt;code&gt;L&lt;/code&gt; and &lt;code&gt;x&lt;/code&gt;, I’m aware that there exist matrices that would also allow me to express the objective function in the simple example shown above.  But I’d rather not go through that if it isn’t necessary.&lt;/p&gt;&#xA;&lt;p&gt;Does YALMIP allow a user-defined function as shown above?  Or must it be expressed in one line as shown in my example?&lt;/p&gt;&#xA;" OwnerUserId="9165" LastEditorUserId="9165" LastEditDate="2022-04-03T14:20:44.483" LastActivityDate="2022-04-03T14:20:44.483" Title="Does YALMIP allow a user-defined function for the objective function and constraints?" Tags="|robust-optimization|yalmip|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8188" PostTypeId="1" AcceptedAnswerId="8189" CreationDate="2022-04-03T08:35:21.823" Score="5" ViewCount="370" Body="&lt;p&gt;Lately, I have been reading a lot of papers where the constraints have been tightened to include better formulations leading to decrease in optimiality gaps and also the time for solving the optimisation problem. I was wondering if there is a book or paper which folks would be aware about introducing constraint tightening in MIPs? I don't imagine it to be hit and trial approach, there definitely seems to be some good theory behind it.&lt;/p&gt;&#xA;" OwnerUserId="8819" LastActivityDate="2022-04-03T11:06:38.807" Title="Tightening constraints for better formulation" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8189" PostTypeId="2" ParentId="8188" CreationDate="2022-04-03T11:06:38.807" Score="4" Body="&lt;p&gt;The cutting plan algorithm is really a strange method to solve integer programming. In some cases, it works very well, and in some cases, it works vice versa. I think besides the theoretical overview of this method many trials and errors should be applied to understand how it works well on a specific problem. In this case, some resources that might be useful are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://onlinelibrary.wiley.com/doi/book/10.1002/9781119606475&quot; rel=&quot;nofollow noreferrer&quot;&gt;Integer Programming: Laurence Wolsey&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/5359/algorithm-for-simplifying-a-set-of-linear-inequalities&quot;&gt;Algorithm for simplifying a set of linear inequalities&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/1476/valid-inequalities-and-strong-inequalities&quot;&gt;Valid Inequalities and Strong Inequalities&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://math.stackexchange.com/questions/2203194/valid-inequality-verification-for-mip&quot;&gt;Valid Inequality Verification for MIP&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=e4h4ZUlUpR8&quot; rel=&quot;nofollow noreferrer&quot;&gt;Converting Weak to Strong MIP Formulations (Gurobi webinar)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/1241/performance-of-a-branch-and-bound-algorithm-vs-branch-cut-heuristics&quot;&gt;Performance of a branch and bound algorithm VS branch-cut-heuristics&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2105.13645.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learning to Select Cuts for Efficient Mixed-Integer Programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://opus4.kobv.de/opus4-zib/frontdoor/deliver/index/docId/1112/file/Achterberg_Constraint_Integer_Programming.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tobias Achtenberg PhD thesis&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.scipopt.org/download/slides/SCIP-cuttingPlanes.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cutting Plane Separators in SCIP&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-04-03T11:06:38.807" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8190" PostTypeId="2" ParentId="8182" CreationDate="2022-04-03T11:36:40.710" Score="2" Body="&lt;p&gt;In the weighted sum approach, we scale our set of goals into a single goal by multiplying each of our objectives by a user-supplied weight. This method is one of the most widely used approaches.&lt;/p&gt;&#xA;&lt;p&gt;The weight given to an objective is normally assigned to be proportional to the objective’s relative importance in our problem. However, we also need to make sure that we account for the magnitude of our objective functions. We resolve this issue by scaling all of our objective functions to the same magnitude which is called normalization. For more details, please see:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://file:///C:/Users/omidi.a/Downloads/Multiobjective_Optimization_Using_Evolutionary_Alg.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multi-objective optimization using evolutionary algorithms&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.dropbox.com/s/h33kfks98qzay7v/MOOP.pdf?dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bruce A. McCarl and Thomas H. Spreen: MULTI-OBJECTIVE PROGRAMMING&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-04-03T11:36:40.710" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8191" PostTypeId="1" AcceptedAnswerId="8192" CreationDate="2022-04-03T15:10:17.573" Score="7" ViewCount="286" Body="&lt;p&gt;I have the following equational Linear Program: &lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad c^T x\\\text{s.t.}&amp;amp;\quad Ax=b\\&amp;amp;\quad x\ge0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$m\times n$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$m\le n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c\in \mathbb{R}^n, x \in \mathbb{R}^n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b\in\mathbb{R}^m$&lt;/span&gt;. Also the rank of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now I understand the following :&lt;/p&gt;&#xA;&lt;p&gt;(1) The feasible region is a convex polytope formed by the intersection of hyperplanes (constraints).&lt;/p&gt;&#xA;&lt;p&gt;(2) At least one of the vertices of the polytope will give us the optimal solution if it exists.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What I don't understand is why only at the corner points (basic feasible solutions) &lt;span class=&quot;math-container&quot;&gt;$(m)$&lt;/span&gt; variables are not zero (basic) and rest &lt;span class=&quot;math-container&quot;&gt;$(n-m)$&lt;/span&gt; variables are zero (non-basic)?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also, let's say that we have a basic feasible solution &lt;span class=&quot;math-container&quot;&gt;$x_B$&lt;/span&gt;. Now for every &lt;span class=&quot;math-container&quot;&gt;$x&amp;gt;0 \,\,\,in\,\,\, x_B$&lt;/span&gt;, we build the &lt;span class=&quot;math-container&quot;&gt;$m \times m$&lt;/span&gt; matrix &lt;span class=&quot;math-container&quot;&gt;$A_B$&lt;/span&gt;, the columns of which form linearly independent vectors. I understand that this fact allows us to calculate the inverse of &lt;span class=&quot;math-container&quot;&gt;$A_B$&lt;/span&gt; and that is useful for calculating &lt;span class=&quot;math-container&quot;&gt;$x_B =A_B^{-1}b\,\,+A_B^{-1}A_Nx_N $&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$A_N$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$m\times(n-m)$&lt;/span&gt; matrix of non-basic variables and &lt;span class=&quot;math-container&quot;&gt;$x_N$&lt;/span&gt; is the set of non-basic variables.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;But what is the geometric significance of linear independence that is why do the corner points show such behavior?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9481" LastEditorUserId="9481" LastEditDate="2022-04-03T15:27:38.707" LastActivityDate="2022-04-03T16:17:38.277" Title="Why are several of the decision variables zero at the corner point of a polytope?" Tags="|linear-programming|simplex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8192" PostTypeId="2" ParentId="8191" CreationDate="2022-04-03T16:17:38.277" Score="5" Body="&lt;p&gt;Each equation constraint defines a hyperplane in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n$&lt;/span&gt;, as does each lower bound (&lt;span class=&quot;math-container&quot;&gt;$x_i =0$&lt;/span&gt;). When hyperplanes intersect, the dimension of the intersection is &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; minus the number of hyperplanes with linearly independent normal vectors. When &lt;span class=&quot;math-container&quot;&gt;$n=3$&lt;/span&gt;, the intersection of two independent planes is a line. If you intersect that with a third plane, you either get a point (if the planes have independent normals) or the same line (if the normal of the third hyperplane is a linear combination of the first two normals).&lt;/p&gt;&#xA;&lt;p&gt;So at a corner point there are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; binding constraints with independent normals. Note that you have &lt;span class=&quot;math-container&quot;&gt;$m+n$&lt;/span&gt; constraints total, not &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, thanks to the sign restriction &lt;span class=&quot;math-container&quot;&gt;$x\ge 0.$&lt;/span&gt; You know the equations are all binding because they are equations, which means &lt;span class=&quot;math-container&quot;&gt;$n-m$&lt;/span&gt; of the sign restrictions are binding. So at least &lt;span class=&quot;math-container&quot;&gt;$n-m$&lt;/span&gt; variables are 0 at the corner. The number of zeroes could actually be higher, as one or more basic variables could be zero.&lt;/p&gt;&#xA;&lt;p&gt;The geometric significance of linear independence is that adding another hyperplane to the intersection only drops the dimension of the intersection by 1 if the normal of the new hyperplane is independent of the normals of the hyperplanes already participating in the intersection.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-03T16:17:38.277" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8193" PostTypeId="1" AcceptedAnswerId="8210" CreationDate="2022-04-03T19:49:02.323" Score="4" ViewCount="676" Body="&lt;p&gt;Suppose you manage a machine shop with &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; machines and have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; jobs to process today. Each job &lt;span class=&quot;math-container&quot;&gt;$i=1,2,3,4,5,\ldots,n$&lt;/span&gt; requires &lt;span class=&quot;math-container&quot;&gt;$p_i&amp;gt;0$&lt;/span&gt; minutes of processing time on any machine and has a processing windows &lt;span class=&quot;math-container&quot;&gt;$[a_i,d_i]$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$a_i+p_i\le d_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We have a job become available at time &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; and must be completed by &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A job can only be processed on one machine at a time, but it can be preempted; that is, its processing on one machine can be paused and later resumed on the same or another machine, as long as it finishes by its deadline.&lt;/p&gt;&#xA;&lt;p&gt;I have to solve this problem by first creating a network with nodes and arcs, and then using a linear system to solve it.&lt;/p&gt;&#xA;&lt;p&gt;I am not sure how to build the network. I know I have a source node and a sink node. The first nodes are the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; job, and the capacity of these arcs that connect source to the job nodes is &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt;; but beyond that I am stuck.&lt;/p&gt;&#xA;&lt;p&gt;If I have &lt;span class=&quot;math-container&quot;&gt;$k=3$&lt;/span&gt; this is what the problem would look like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;job  1    2    3    4 &#xA;pi   2.5  1.5  2    4&#xA;ai   2    0    0.5  1&#xA;di   5    3    4    6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Can anyone tell me how to build this network?&lt;/p&gt;&#xA;" OwnerUserId="9483" LastEditorUserId="2556" LastEditDate="2022-04-06T07:29:41.427" LastActivityDate="2022-04-06T07:29:41.427" Title="How to use max flow to schedule machines? (building a network)" Tags="|linear-programming|modeling|maxflow|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8194" PostTypeId="1" AcceptedAnswerId="8202" CreationDate="2022-04-04T03:27:39.903" Score="2" ViewCount="138" Body="&lt;p&gt;I have an optimization problem where I'd like to maximize revenue and I have separate variables for cost and revenue.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Building a single unit of a product takes 100 hours of labor&lt;/li&gt;&#xA;&lt;li&gt;I have a list of staff, the number of hours they have available, and the cost per hour for each&lt;/li&gt;&#xA;&lt;li&gt;The projected revenue of the product changes based on the total cost to build the unit&lt;/li&gt;&#xA;&lt;li&gt;If cost is less than 2500, revenue = 40 * cost&lt;/li&gt;&#xA;&lt;li&gt;If cost is between 2500 to 5000, revenue = 25 * cost&lt;/li&gt;&#xA;&lt;li&gt;If cost is &amp;gt; 5000, revenue = 8 * cost&lt;/li&gt;&#xA;&lt;li&gt;I want my objective function to maximize the appropriate revenue formula based on what the cost might be&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I tried to use the BigM notation to determine which range the cost falls into, and then my objective function looked something like &lt;br/&gt;&#xA;&lt;code&gt;Maximize(&lt;/code&gt;&lt;br/&gt;&#xA;&lt;code&gt;is_cost_group_1 * (40 * cost) +&lt;/code&gt; &lt;br/&gt;&#xA;&lt;code&gt;is_cost_group_2 * (25 * cost) +&lt;/code&gt;&lt;br/&gt; &lt;code&gt;is_cost_group_3 * (8 * cost))&lt;/code&gt;&lt;br/&gt;&#xA;but this gave me an error'ed saying the solver does not support quadratic functions.&lt;/p&gt;&#xA;&lt;p&gt;Is this possible as a linear programming problem?&lt;/p&gt;&#xA;" OwnerUserId="7539" LastEditorUserId="491" LastEditDate="2022-04-04T15:34:40.307" LastActivityDate="2022-04-04T19:43:13.883" Title="How to optimize multiple linear regressions based on cost?" Tags="|optimization|linear-programming|modeling|constraint|linearization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8195" PostTypeId="1" AcceptedAnswerId="8196" CreationDate="2022-04-04T04:37:55.317" Score="5" ViewCount="834" Body="&lt;p&gt;I am trying to solve a variation of the knapsack problem where every pair of items in my knapsack has a bonus or penalty associated with it.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;My knapsack can hold a dozen items&lt;/li&gt;&#xA;&lt;li&gt;There are thousands of items to choose from&lt;/li&gt;&#xA;&lt;li&gt;Every pair of items has a known bonus or penalty associated with it&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;What I've tried is to create a binary variable for every pair of items which represents the logical AND of whether the pair belongs to the solution. My objective function then maximizes the total weight in the knapsack along with sum of the bonuses. The issue I'm running into is that having thousands of items creates a lot of these logical-AND helper variables and is very slow to run. Is there a better way to model this problem?&lt;/p&gt;&#xA;" OwnerUserId="7539" LastEditorUserId="500" LastEditDate="2022-04-04T15:45:03.297" LastActivityDate="2022-04-04T20:56:36.937" Title="Knapsack - How to optimize bonuses for each pair of items" Tags="|optimization|modeling|solver|linearization|knapsack|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8196" PostTypeId="2" ParentId="8195" CreationDate="2022-04-04T05:17:06.033" Score="7" Body="&lt;p&gt;One approach is to introduce the pairs dynamically only when needed. Initially, solve a relaxation where every pair yields the highest bonus.  (Note: I am suggesting to relax the objective and not to relax integrality.)  For the resulting optimal solution, compute the true objective value.  If it matches the solver’s claimed objective value, you are done.  Otherwise, introduce the variables and constraints for any newly arising pairs, and repeat until the upper bound from the relaxation matches the lower bound from the incumbent.  This idea is similar to one Bill Cook has used to solve TSP instances where the true edge cost is obtained by a Google Maps query but initially approximated by a great-circle lower bound.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;More explicitly, let &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; be the weight of item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$b_{ij}$&lt;/span&gt; be the bonus or penalty for pair &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$i&amp;lt;j$&lt;/span&gt;.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; indicate whether item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is chosen.  The original (quadratic knapsack) problem is to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_i w_i x_i + \sum_{i&amp;lt;j} b_{ij} x_i x_j$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\sum_i x_i \le 12$&lt;/span&gt;.  For small enough instances, you can solve the problem directly via MIQP, by &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;linearizing in the usual way&lt;/a&gt;, or by using &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_knapsack_problem#Glover%27s_linearization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Glover's linearization&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here are more details of the indirect approach I sketched earlier.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$M=\max_{i&amp;lt;j} b_{ij}$&lt;/span&gt; be the maximum bonus among all pairs.  Assume for the moment that it is optimal to choose exactly &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; items.  My suggested reformulation is to introduce binary (or just nonnegative) decision variable &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; and maximize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i w_i x_i + \binom{12}{2}M + \sum_{i&amp;lt;j} (b_{ij}-M) z_{ij} \tag1$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i x_i &amp;amp;= 12 \tag2 \\&#xA;x_i + x_j - 1 &amp;amp;\le z_{ij} &amp;amp;&amp;amp;\text{for $i&amp;lt;j$} \tag3&#xA;\end{align}&lt;/span&gt;&#xA;But introduce &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; and constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; dynamically only as needed.&lt;/p&gt;&#xA;&lt;p&gt;If instead it might be optimal to choose fewer than &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; items, let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_k$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; items are chosen and maximize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i w_i x_i + \sum_{k=0}^{12} \binom{k}{2}M y_k + \sum_{i&amp;lt;j} (b_{ij}-M) z_{ij} \tag4$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i x_i &amp;amp;= \sum_{k=0}^{12} k y_k \tag5 \\&#xA;\sum_{k=0}^{12} y_k &amp;amp;=1 \tag6 \\&#xA;x_i + x_j - 1 &amp;amp;\le z_{ij} &amp;amp;&amp;amp;\text{for $i&amp;lt;j$} \tag7&#xA;\end{align}&lt;/span&gt;&#xA;Now introduce &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; and constraint &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt; dynamically only as needed.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-04-04T16:21:34.443" LastActivityDate="2022-04-04T16:21:34.443" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8197" PostTypeId="2" ParentId="8182" CreationDate="2022-04-04T07:23:28.630" Score="4" Body="&lt;p&gt;&lt;strong&gt;Do you think the weights I choose are logical?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;No, I don't think they are &lt;em&gt;logical&lt;/em&gt;, but that is because you have chosen them randomly (according to your description). Hence, there is not really any logic behind the choice of weights. What is good, however, is that you have strictly positive weights in all you scenarios. This will ensure that the resulting solutions are Pareto optimal &lt;em&gt;if you solve the weighted sum problems to optimality&lt;/em&gt;. From your results shown in your attached picture we can see that you do not solve the problems to optimality, as there are &lt;em&gt;dominated&lt;/em&gt; outcomes among your results.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;From the result in the picture we can see that 0.3 0.35 0.35 is the best combination&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Generally, you cannot say that one solution (set of weights) is &lt;em&gt;better&lt;/em&gt; than another in a multi-objective optimization problem, as it depends on the preferences of the decision maker. You could argue that it is the entire idea behind multi-objective optimization: Generate (a subset of) the set of non-dominated outcomes and then let the decision maker decide which of the Pareto optimal solutions corresponding to non-dominated outcomes they find more appealing.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;with that can i use only this combination for all my rest experimentation?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you settle for one set of weights and stick to that set, I would argue that you do not really solve a multi-objective optimization problem: You have mixed apples and oranges in one bowl and you are left with the problem of interpreting the objective function. On the other hand, if you solve your problem for a small set of weight combinations, say &lt;span class=&quot;math-container&quot;&gt;$\{w^1,...,w^K\}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$w^k_i&amp;gt;0$&lt;/span&gt;, you will get at most &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; different Pareto optimal solutions you can choose from based on your or your decision maker's preferences. And then I would say that you are dealing with multi-objective optimization.&lt;/p&gt;&#xA;&lt;p&gt;To get familiar with the theory of multicriteria/multi-objective optimization I would refer to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://link.springer.com/book/10.1007/3-540-27659-9&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multicriteria Optimization&lt;/a&gt; by Matthias Ehrgott. You may look into chapter 3 for information on the weighted sum method.&lt;/li&gt;&#xA;&lt;li&gt;For more theory on how to chose the weights such that you can generate all the efficient extreme points of the set of non-dominated solutions you may look into &amp;quot;weight set decomposition&amp;quot;. For the three-objective case you can start with &lt;a href=&quot;https://doi.org/10.1007/s10898-020-00898-9&quot; rel=&quot;nofollow noreferrer&quot;&gt;An inner approximation method to compute the weight set decomposition of a triobjective mixed-integer problem&lt;/a&gt; by P. Halffmann, T. Dietz, A. Przybylski, and S. Ruzika.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-04-04T07:23:28.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8198" PostTypeId="2" ParentId="8195" CreationDate="2022-04-04T11:03:21.757" Score="3" Body="&lt;p&gt;Pyomo code&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Devrs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Devrs.png&quot; alt=&quot;Pyomo code&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;you do need a matrix for the value of each pair of items&#xA;model.V[i,j]&#xA;you also need a vector for the weight of each item&#xA;model.W[i]&#xA;I have created them randomly as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;df=pd.DataFrame()&#xA;&#xA;N=50&#xA;df['w']=[random.random() for i in range(N)]&#xA;df&#xA;dic={}&#xA;for i in range(1,1+N):&#xA;    for j in range(1,1+N):&#xA;        if i&amp;gt;j:&#xA;            dic[i,j]= 0.5-random.random()&#xA;            dic[j,i]=dic[i,j]&#xA;        if i==j:&#xA;            dic[i,j]=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now the formulation will be a classic multiobjective optimization&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is a binary variable representing select or not&#xA;&lt;span class=&quot;math-container&quot;&gt;$Z_{i,j}$&lt;/span&gt; is a real variable represinting &lt;span class=&quot;math-container&quot;&gt;$x_i*x_j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max_{x_i} OF_1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$OF_1= \sum_{i,j} V_{i,j}Z_{i,j}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$OF_2= \sum_i w_ix_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Z_{i,j} \leq x_i   \  \ \forall i\ne j $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Z_{i,j} \leq x_j \  \ \forall i\ne j $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Z_{i,j} \geq x_i+x_j-1 \  \ \forall i\ne j $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$OF_2 \geq  \epsilon$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_i x_i=12$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZTIfc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZTIfc.png&quot; alt=&quot;Pareto optima front&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2022-04-04T20:56:36.937" LastActivityDate="2022-04-04T20:56:36.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8199" PostTypeId="1" AcceptedAnswerId="8200" CreationDate="2022-04-04T11:56:02.123" Score="2" ViewCount="256" Body="&lt;p&gt;I have an MILP model, in which I am handling all &lt;em&gt;Big M&lt;/em&gt; constraints with &lt;em&gt;add_if_then&lt;/em&gt; constraints (following &lt;a href=&quot;https://www.ibm.com/support/pages/why-does-binary-or-integer-variable-take-noninteger-value-solution&quot; rel=&quot;nofollow noreferrer&quot;&gt;this topic&lt;/a&gt;). I generate this model only once (to save time) and solve it iteratively with different coefficients of the objective function (I only update the objective function) - coded via docplex in Python.&lt;/p&gt;&#xA;&lt;p&gt;After some iterations, the binary/integer variables get real values (the optimality gap is 5%). What would be the reason of this (other than having Big M constraints)? Unfortunately, I am unable to share the entire model with you. However, I can provide you with further information.&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="5598" LastEditDate="2022-04-04T12:22:41.913" LastActivityDate="2022-04-04T12:29:17.513" Title="Binary/integer variables get real values in docplex" Tags="|mixed-integer-programming|binary-variable|docplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8200" PostTypeId="2" ParentId="8199" CreationDate="2022-04-04T12:29:17.513" Score="5" Body="&lt;p&gt;All solution values will be floating-point numbers - independent of the variable types. In an optimal or feasible solution, they will simply be &lt;em&gt;close&lt;/em&gt; to an integer value, depending on the specified tolerance. Usually, there is a numeric tolerance for small violations regarding the bounds and right hand sides and another one that is only concerned about the integrality of the solution.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2022-04-04T12:29:17.513" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8201" PostTypeId="1" AcceptedAnswerId="8204" CreationDate="2022-04-04T19:27:53.463" Score="6" ViewCount="579" Body="&lt;p&gt;Suppose we have a MILP model. How can we say this model is tight or not?&#xA;How to make it more tight? Any advice or example?&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="491" LastEditDate="2022-04-04T19:57:15.323" LastActivityDate="2022-04-05T08:50:41.550" Title="How to measure the tightness of MILP models?" Tags="|mixed-integer-programming|linearization|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8202" PostTypeId="2" ParentId="8194" CreationDate="2022-04-04T19:43:13.883" Score="1" Body="&lt;p&gt;Given the discontinuities in the revenue function, you cannot use a linear program, but you can use a mixed-integer linear program. (If the revenue function were continuous with diseconomies of scale, you could use a linear program.)&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; be the cost variable and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; the revenue variable (which you will maximize). Let &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; be an upper limit on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; (the maximum cost you might encounter). Introduce three binary variables &lt;span class=&quot;math-container&quot;&gt;$z_1,z_2,z_3$&lt;/span&gt; together with the following constraints:&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;z_{1}+z_{2}+z_{3} &amp;amp; =1\\&#xA;x &amp;amp; \le2500z_{1}+5000z_{2}+Mz_{3}\\&#xA;y &amp;amp; \le40x\\&#xA;y &amp;amp; \le25x+15M(1-z_{2})\\&#xA;y &amp;amp; \le8x+32M(1-z_{3}).&#xA;\end{align*}&lt;/span&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$z_1=1$&lt;/span&gt;, your cost is up to 2500 (but no higher) and your revenue is up to 40 times the cost (and therefore will be 40 times the cost). If &lt;span class=&quot;math-container&quot;&gt;$z_2=1$&lt;/span&gt;, your cost is up to 5000 and your revenue no more than (therefore equal to) 25 times cost. If &lt;span class=&quot;math-container&quot;&gt;$z_3=1$&lt;/span&gt;, cost is up to &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; and revenue no more than 8 times cost.&lt;/p&gt;&#xA;&lt;p&gt;Note that break points qualify for the higher revenue value. For instance, a cost of exactly 2500 can result in revenue &lt;span class=&quot;math-container&quot;&gt;$40\times 2500$&lt;/span&gt;. To enforce strict inequality (revenue rate 40 only if cost strictly less than 2500) you need to change 2500 and 5000 in the second constraint to &lt;span class=&quot;math-container&quot;&gt;$2500-\epsilon$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$5000-\epsilon$&lt;/span&gt; for some small &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt; and then live with the discrepancy that cost &lt;span class=&quot;math-container&quot;&gt;$2500-\epsilon/2$&lt;/span&gt; on earns revenue multiple 25 and not 40.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-04T19:43:13.883" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8203" PostTypeId="1" CreationDate="2022-04-04T19:55:03.530" Score="4" ViewCount="388" Body="&lt;p&gt;I have previously used MOSEK for all my SDP needs. Recently, though, I am having a hard time trying to solve some large problems, due to lack of memory. In similar questions around the forum, SCS has been recommended for very large instances due to lower memory requirements. That's led me to a series of questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there some rules of thumb for choosing appropriate solvers depending on problem instances, or is my best chance just trying out all of them?&lt;/li&gt;&#xA;&lt;li&gt;What are the differences between MOSEK, SCS and other SDP solvers, and what is the trade-off of one w.r.t. the other? (i.e., is SCS generally slower? Does MOSEK generally consumes more memory? Or is it all dependent on the specific instance one tries to solve?)&lt;/li&gt;&#xA;&lt;li&gt;When dealing with dense, large SDPs, what would be my best bets, solver-wise?&lt;/li&gt;&#xA;&lt;li&gt;Does having access to a sizeable cluster helps in any way? For instance, are there solvers that can exploit distributed memory? Or is my best choice going for a single node with a large memory?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;So far I use solvers mostly as black-boxes, thus I am having some trouble trying to gather these answers.&lt;/p&gt;&#xA;" OwnerUserId="9490" LastEditorUserId="491" LastEditDate="2022-04-04T19:56:51.067" LastActivityDate="2022-04-04T19:56:51.067" Title="Adequate SDP solvers for large problem instances" Tags="|solver|convex-optimization|semidefinite-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8204" PostTypeId="2" ParentId="8201" CreationDate="2022-04-04T21:34:24.763" Score="5" Body="&lt;p&gt;I agree with @Sune: tightness generally means the difference between the integer and convex hulls (so, in practical terms, the gap between the optimal solution and the solution of the LP relaxation), and judging it is typically in comparison to other models for the same problem.&lt;/p&gt;&#xA;&lt;p&gt;As to how to tighten a model, there are no universal recipes that I've ever seen. In a &amp;quot;big M&amp;quot; type model, smaller (but adequately large) values of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; will tend to yield tighter models. Seemingly redundant constraints sometimes result in tighter relaxations (possibly by virtue of leading the presolver to a reduction it might not otherwise have found), but there are no guarantees there. Sometimes redundant constraints are just redundant.&lt;/p&gt;&#xA;&lt;p&gt;When there are multiple distinct formulations of the same problem, sometimes one will be provably tighter than another. A case in point is the traveling salesman problem. A model with subtour elimination constraints, while larger, is typically tighter than a model using the Miller-Tucker-Zemlin formulation.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-04T21:34:24.763" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8205" PostTypeId="1" CreationDate="2022-04-05T04:50:50.443" Score="1" ViewCount="41" Body="&lt;p&gt;When optimizing a two objective task assignment problem, is it generally better to use blended objectives or hierarchical objectives if&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the speed to obtaining a near-optimal solution is more important than getting the optimal results&lt;/li&gt;&#xA;&lt;li&gt;it does not really matter whether we choose blended objectives (ratio of weights are not important) or hierarchical objectives (priority is not important)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9403" LastActivityDate="2022-04-05T04:50:50.443" Title="Blended or hierarchical objectives if solving speed is more important" Tags="|optimization|mixed-integer-programming|python|multi-objective-optimization|assignment-problem|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8206" PostTypeId="2" ParentId="8201" CreationDate="2022-04-05T08:50:41.550" Score="5" Body="&lt;p&gt;On a theoretical level, you can define tightness as the difference in volume of the feasible space between the LP relaxation and the original MIP. This is a mostly theoretical point though as in practice you have no real way of calculating this volume; also, solvers will add cutting planes to reduce this volume during the solution process.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, a more practical definition is the fact that there is a gap between the LP relaxation and the MIP solution that is not easily closed. The word &amp;quot;easily&amp;quot; here refers to standard presolve and cutting plane techniques such as MIR cuts, bound strengthening etc. This also means that you often only know that a model formulation is weak once you try to solve it and the log output of the solver shows you something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;     0     0   72.70714    0   85          -   72.70714      -     -    0s&#xA;     0     0   72.70714    0  162          -   72.70714      -     -    0s&#xA;     0     0   72.70714    0  125          -   72.70714      -     -    0s&#xA;     0     0   72.70714    0   99          -   72.70714      -     -    0s&#xA;     0     0   72.70714    0   81          -   72.70714      -     -    0s&#xA;     0     2   72.70714    0   79          -   72.70714      -     -    0s&#xA;H 1774   804                      80.0000000   72.70714  9.12%  11.8    0s&#xA;H 1866   791                      78.0000000   72.70714  6.79%  12.0    0s&#xA;H 1869   783                      77.0000000   72.70714  5.58%  12.0    0s&#xA;H 2073   456                      75.0000000   72.70714  3.06%  12.4    1s&#xA;H 2106   446                      74.0000000   72.73393  1.71%  21.0    3s&#xA;H 2340   493                      73.0000000   72.73393  0.36%  25.7    4s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have found that if you want to tighten your model formulation, you should first try to increase the aggressiveness of cuts added by the solver (&lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/cuts.html&quot; rel=&quot;noreferrer&quot;&gt;Cuts&lt;/a&gt; = 3 in Gurobi for example), as well as adding cuts manually that are problem specific.&lt;/p&gt;&#xA;&lt;p&gt;Then of course you can change your model, which is though easier said than done. @prubin's example of a TSP is a good one here. Finally, you may even ask whether you can maybe change your entire approach: do you need all the variables to be integer? Can you apply some column generation or other advances techniques? Can you sacrifice some accuracy for a dramatic improvement in runtime?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I'm sorry to hear that you did not find our Tech Talk very useful. Can you elaborate what we could have done to make it more interesting to you?&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2022-04-05T08:50:41.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8207" PostTypeId="1" AcceptedAnswerId="8208" CreationDate="2022-04-05T09:15:27.857" Score="5" ViewCount="122" Body="&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$x_i&amp;gt;0, i=1,\ldots,I$&lt;/span&gt;, I tried to linearize this objective function&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min\sum_{i=1}^{I}\sum_{j=1}^{i}|x_i-x_j|$$&lt;/span&gt;&#xA;as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min\sum_{i=1}^{I}\sum_{j=1}^{i}y_{ij}$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; y_{ij} \le x_i-x_j \quad i=1,\ldots,I, j =1,\ldots,i\\&#xA;&amp;amp; y_{ij} \le x_j-x_i \quad i=1,\ldots,I, j =1,\ldots,i\\&#xA;&amp;amp; y_{ij} \ge x_i-x_j + M(1-z_{ij}) \quad i=1,\ldots,I, j =1,\ldots,i\\&#xA;&amp;amp; y_{ij} \ge x_j-x_i + Mz_{ij} \quad i=,\ldots,I, j =1,\ldots,i&#xA;\end{align}&lt;/span&gt;&#xA;and &lt;span class=&quot;math-container&quot;&gt;$z_{ij}\in\{0,1\}, \forall i=1,\ldots,I, j =1,\ldots,i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is this linearization correct? Is there a way to avoid &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;-constraints to avoid computational problems?&lt;/p&gt;&#xA;" OwnerDisplayName="user9659" LastActivityDate="2022-04-05T15:54:44.923" Title="Linearizing this absolute difference objective function $\min\sum_{i=1}^{I}\sum_{j=1}^{i}|x_i-x_j|$" Tags="|linear-programming|modeling|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8208" PostTypeId="2" ParentId="8207" CreationDate="2022-04-05T10:34:08.920" Score="12" Body="&lt;p&gt;As you are minimizing &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt;, it is sufficient to use&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_{ij} \geq x_i - x_j \quad \forall i, j \\&#xA;y_{ij} \geq x_j - x_i \quad \forall i, j&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="749" LastEditorUserId="67" LastEditDate="2022-04-05T15:54:44.923" LastActivityDate="2022-04-05T15:54:44.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8210" PostTypeId="2" ParentId="8193" CreationDate="2022-04-05T22:32:15.937" Score="2" Body="&lt;p&gt;When you have to model a problem as a flow problem, you can often interpret it as an 'assignment' or 'selection' problem. Here, your scheduling problem is equivalent to assigning jobs to machines. In other words, for every machine &lt;span class=&quot;math-container&quot;&gt;$m_1, m_2,\dots,m_k$&lt;/span&gt; and for every point in time &lt;span class=&quot;math-container&quot;&gt;$t_1,t_2,\dots,t_h$&lt;/span&gt; you need to determine which task gets executed (i.e. which task to assign to a machine/time combination). Conveniently, your jobs can be pre-empted. This simply means that you can start executing some job &lt;span class=&quot;math-container&quot;&gt;$j_1$&lt;/span&gt; on a machine, pause it, execute some other tasks, and then continue executing &lt;span class=&quot;math-container&quot;&gt;$j_1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Since this sounds like a home-work assignment, I'll not disclose the full solution. As per your suggestion you indeed need to have a source node &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; which is connected to the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; job nodes. The capacity of an arc from source node &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to job node &lt;span class=&quot;math-container&quot;&gt;$j_i$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt;. Next you'll need time-indexed machine nodes, namely one node for every machine and time pair: &lt;span class=&quot;math-container&quot;&gt;$(m_1,t_1),\dots,(m_1,t_h),(m_2,t_1),\dots,(m_2,t_h),\dots,(m_k,t_1),\dots,(m_k,t_h)$&lt;/span&gt;. I'll leave it up to you to decide (1) how to connect the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; job nodes to the machine nodes, (2) how to connect the machine nodes to the sink, and (3) how to set the arc capacities. Note that a machine can only perform 1 job at a time.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2022-04-05T22:32:15.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8211" PostTypeId="1" CreationDate="2022-04-06T05:02:47.307" Score="0" ViewCount="64" Body="&lt;p&gt;Can the following problem be formulated as a LP/IP problem, where an agent (waiter) that has just arrived at a certain table has to decide whether to visit that table now, or skip the current table and travel to the next table, where he again decides whether to serve the second table.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;                [Table1]&#xA;                   ||&#xA;                   ||&#xA;              ===================&#xA;              ||                ||&#xA;[Table4]  ====||                ||&#xA;              ||                ||====  [Table2]&#xA;              ||                ||&#xA;              ===================&#xA;                      ||  {WaiterA: 1 dishes of dishA (waiting for WaiterB, WaiterC to finish)}&#xA;                      ||  {WaiterB: 2 dishes of dishB (waiting for WaiterC to finish)}&#xA;                   [Table3]   {WaiterC: Serving 3 dishes of dishC}&#xA;                  ordered:&#xA;                    1x dishA  &#xA;                    2x dishB&#xA;                    3x dishC  &#xA;                    3x dishD&#xA;                    3x dishE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Additional details:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Waiters can only travel in a loop path in the clockwise direction&lt;/li&gt;&#xA;&lt;li&gt;There can be multiple waiters traveling on the loop path&lt;/li&gt;&#xA;&lt;li&gt;Every waiter only serves 1 dish (&lt;code&gt;waiterA&lt;/code&gt; serves only &lt;code&gt;dishA&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;When a waiter is serving a table, another waiter can visit the same table and wait in queue for the initial waiter to finish serving&lt;/li&gt;&#xA;&lt;li&gt;A table can order multiple type of dishes at once&lt;/li&gt;&#xA;&lt;li&gt;The time taken by a waiter to serve an order at the table is proportional to the number of that dishes ordered by that table&lt;/li&gt;&#xA;&lt;li&gt;All waiters serve each quantity of their dish at the same speed&lt;/li&gt;&#xA;&lt;li&gt;All waiters travel the loop path at the same speed&lt;/li&gt;&#xA;&lt;li&gt;The distance between tables are not equal&lt;/li&gt;&#xA;&lt;li&gt;The ordered dishes can be served in any sequence&lt;/li&gt;&#xA;&lt;li&gt;There is only sufficient room for 3 waiters to be waiting (and 1 actively serving) for each table&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;We want to minimize the total time taken to serve all the ordered dishes.&lt;/p&gt;&#xA;&lt;p&gt;I feel that we want to take into account&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the demand of the current table vs. demand of other tables&lt;/li&gt;&#xA;&lt;li&gt;the total number of dishes to be served by the waiters in queue at the current table&lt;/li&gt;&#xA;&lt;li&gt;the time it will take to travel to the next table (or table with most demand for the dish that this waiter serves)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;How can we formulate this as a LP problem, where we want to know a whether a waiter that has travelled to a table should join a queue to serve the table, or skip this table?&lt;/p&gt;&#xA;&lt;p&gt;I am also assuming that we will solve this problem every time a waiter has arrived at a table.&lt;/p&gt;&#xA;&lt;p&gt;Is there a problem category that this problem belongs to, such as the Traveling Salesman Problem? Looks like it shares some similarity with the TSP, but in TSP the salesman is not constrained to travel along a fixed path with a fixed direction.&lt;/p&gt;&#xA;" OwnerUserId="9499" LastEditorUserId="9499" LastEditDate="2022-04-06T05:36:19.637" LastActivityDate="2022-04-06T05:36:19.637" Title="Decision whether to serve the current table now or skip it" Tags="|optimization|linear-programming|python|integer-programming|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="8212" PostTypeId="1" CreationDate="2022-04-06T14:54:36.500" Score="0" ViewCount="107" Body="&lt;p&gt;I started studying Operations Research (OR) recently and I faced a problem in which I struggled to model it using the traditional LP models. After some attempts, I'm not sure if such a problem is a linear one nor if it can be solved using LP methods.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem Description&lt;/strong&gt;&#xA;I need to find the minimum purchase amount (T) to buy a batch of products, observing a restriction that each product must be purchased at least x% of the total purchase amount.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Table describing products and restrictions&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Data&lt;/th&gt;&#xA;&lt;th&gt;Corn(x1)&lt;/th&gt;&#xA;&lt;th&gt;Soy(x2)&lt;/th&gt;&#xA;&lt;th&gt;Wheat(x3)&lt;/th&gt;&#xA;&lt;th&gt;Rice (x4)&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Minimum Bag Weight (kg)&lt;/td&gt;&#xA;&lt;td&gt;100&lt;/td&gt;&#xA;&lt;td&gt;100&lt;/td&gt;&#xA;&lt;td&gt;100&lt;/td&gt;&#xA;&lt;td&gt;100&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Unitary Bag Price  ($)&lt;/td&gt;&#xA;&lt;td&gt;4,000&lt;/td&gt;&#xA;&lt;td&gt;3,200&lt;/td&gt;&#xA;&lt;td&gt;4,500&lt;/td&gt;&#xA;&lt;td&gt;1,600&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Perc(% of T) of each Product&lt;/td&gt;&#xA;&lt;td&gt;32%&lt;/td&gt;&#xA;&lt;td&gt;27%&lt;/td&gt;&#xA;&lt;td&gt;15%&lt;/td&gt;&#xA;&lt;td&gt;26%&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;&lt;strong&gt;Critical Condition/Requirement&lt;/strong&gt;&#xA;The amount of bags of each product (x1,x2,x3,x4) must be integer, i.e., no fractional bag is allowed.&lt;/p&gt;&#xA;&lt;p&gt;This seemed to me a very unusual condition, once the total is the target value to be minimized and at the same time is still the basis value of a condition (the amount in which percentage of each product will be based on).&lt;/p&gt;&#xA;&lt;p&gt;The objective is to determine the minimum purchase amount to buy all of the products observing the percentage of the total purchase value for each one.&lt;/p&gt;&#xA;&lt;p&gt;What kind/category of OR problem is this and which technique/method should be used to solve it?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Additional Details&lt;/strong&gt;   (an attempt to clarify the problem)&lt;/p&gt;&#xA;&lt;p&gt;1-Minimum Bag weight 100kg ==&amp;gt; it means that amounts to be purchased must be integer (bags of 100kg) and not fractions (portions of the bag or kg).&lt;/p&gt;&#xA;&lt;p&gt;2-Unitary bag Price ==&amp;gt; is the price of one bag and it contains 100kg&lt;/p&gt;&#xA;&lt;p&gt;3-Perc(% of T) of each Product ==&amp;gt;  it is the percentage of the total amount in value US$, that must be addressed to each product.&lt;/p&gt;&#xA;&lt;p&gt;For example, suppose I have US$ 10,00 to buy those products.  Then this value must be distribute according the table :&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Restriction&lt;/th&gt;&#xA;&lt;th&gt;Corn&lt;/th&gt;&#xA;&lt;th&gt;Soy&lt;/th&gt;&#xA;&lt;th&gt;Wheat&lt;/th&gt;&#xA;&lt;th&gt;Rice&lt;/th&gt;&#xA;&lt;th&gt;Total&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Min Perc%&lt;/td&gt;&#xA;&lt;td&gt;32%&lt;/td&gt;&#xA;&lt;td&gt;27%&lt;/td&gt;&#xA;&lt;td&gt;15%&lt;/td&gt;&#xA;&lt;td&gt;26%&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;100%&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Value US$&lt;/td&gt;&#xA;&lt;td&gt;3,200&lt;/td&gt;&#xA;&lt;td&gt;2,700&lt;/td&gt;&#xA;&lt;td&gt;1,500&lt;/td&gt;&#xA;&lt;td&gt;2,600&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;10,000&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Possible to buy?&lt;/td&gt;&#xA;&lt;td&gt;No&lt;/td&gt;&#xA;&lt;td&gt;No&lt;/td&gt;&#xA;&lt;td&gt;No&lt;/td&gt;&#xA;&lt;td&gt;Yes&lt;/td&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;however, the total amount of US$ 10,000 can only buy one product (Rice) because the others have bag price higher than the amount addressed to each product.&lt;/p&gt;&#xA;&lt;p&gt;Now, let's suppose we have the amount to buy at least one bag of each product, this amount would be US$ 13,300. However observe that with such amount the restriction Percent% of T (T=13,300) for each product is not attended !&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Restriction&lt;/th&gt;&#xA;&lt;th&gt;Corn&lt;/th&gt;&#xA;&lt;th&gt;Soy&lt;/th&gt;&#xA;&lt;th&gt;Wheat&lt;/th&gt;&#xA;&lt;th&gt;Rice&lt;/th&gt;&#xA;&lt;th&gt;Total&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Unitary Bag Price ($)&lt;/td&gt;&#xA;&lt;td&gt;4,000&lt;/td&gt;&#xA;&lt;td&gt;3,200&lt;/td&gt;&#xA;&lt;td&gt;4,500&lt;/td&gt;&#xA;&lt;td&gt;1,600&lt;/td&gt;&#xA;&lt;td&gt;--&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Value paid&lt;/td&gt;&#xA;&lt;td&gt;4,000&lt;/td&gt;&#xA;&lt;td&gt;3,200&lt;/td&gt;&#xA;&lt;td&gt;4,500&lt;/td&gt;&#xA;&lt;td&gt;1,600&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;13,300&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Perc% of Total&lt;/td&gt;&#xA;&lt;td&gt;30%&lt;/td&gt;&#xA;&lt;td&gt;24%&lt;/td&gt;&#xA;&lt;td&gt;34%&lt;/td&gt;&#xA;&lt;td&gt;12%&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;100%&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Min Perc% required&lt;/td&gt;&#xA;&lt;td&gt;32%&lt;/td&gt;&#xA;&lt;td&gt;27%&lt;/td&gt;&#xA;&lt;td&gt;15%&lt;/td&gt;&#xA;&lt;td&gt;26%&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;100%&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Attended Min Perc%&lt;/td&gt;&#xA;&lt;td&gt;No&lt;/td&gt;&#xA;&lt;td&gt;No&lt;/td&gt;&#xA;&lt;td&gt;No&lt;/td&gt;&#xA;&lt;td&gt;No&lt;/td&gt;&#xA;&lt;td&gt;--&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;This Min Perc% of Total , must be exactly the required number, not less, not more.&lt;/p&gt;&#xA;" OwnerUserId="9502" LastEditorUserId="9502" LastEditDate="2022-04-07T03:48:40.797" LastActivityDate="2022-04-08T16:19:57.680" Title="What kind of problem is this : LP , Multi-objective , other?" Tags="|optimization|integer-programming|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="8213" PostTypeId="1" AcceptedAnswerId="8214" CreationDate="2022-04-06T21:07:53.940" Score="1" ViewCount="211" Body="&lt;p&gt;Lets assume &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are non negative continuous variables and &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; an integer variable assuming either the value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;  or the value &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How could I possibly model the relation&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x = y$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$P = 2$&lt;/span&gt; else &lt;span class=&quot;math-container&quot;&gt;$P = 1$&lt;/span&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2022-04-07T12:35:33.173" Title="MILP constraint modelling" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8214" PostTypeId="2" ParentId="8213" CreationDate="2022-04-06T23:27:28.637" Score="5" Body="&lt;p&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$P−1$&lt;/span&gt; is binary and apply the formulation in&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/33/in-an-integer-program-how-i-can-force-a-binary-variable-to-equal-1-if-some-cond/2632#2632&quot;&gt;In an integer program, how I can force a binary variable to equal 1 if some condition holds?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;with your &lt;span class=&quot;math-container&quot;&gt;$x−y$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$P−1$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you instead wanted to enforce only &lt;span class=&quot;math-container&quot;&gt;$P=2 \implies x=y$&lt;/span&gt;, you wouldn't need any new variables.  Just let &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; be lower and upper bounds on the variables, and impose&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(L_x−U_y)(2−P) \le x − y  \le (U_x−L_y)(2−P).$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-04-07T12:35:33.173" LastActivityDate="2022-04-07T12:35:33.173" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8215" PostTypeId="1" AcceptedAnswerId="8216" CreationDate="2022-04-07T14:59:18.493" Score="7" ViewCount="512" Body="&lt;p&gt;Suppose I run a relaxation of an &lt;a href=&quot;https://en.wikipedia.org/wiki/Integer_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIP&lt;/a&gt;. If my result is all integers, I have achieved the same min/max that the MIP would achieve. However, what can I say if some portion of my result is integer?&lt;/p&gt;&#xA;&lt;p&gt;If half my decision variables come out integer, does that mean that those specific variables would/should keep the same integer value for the MIP result? Does it depend on the problem? Is it different if I'm using boolean variables only?&lt;/p&gt;&#xA;&lt;p&gt;I'm not sure what to look for to find research on this topic. What are the distinct keywords? What is the existing research on this topic?&lt;/p&gt;&#xA;" OwnerUserId="7428" LastEditorUserId="1160" LastEditDate="2022-04-08T15:55:45.940" LastActivityDate="2022-04-08T15:55:45.940" Title="I ran a relaxed MIP and got some integer results; how can I constrain MIP to match those integers?" Tags="|integer-programming|lp-relaxation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8216" PostTypeId="2" ParentId="8215" CreationDate="2022-04-07T15:42:44.727" Score="5" Body="&lt;p&gt;It depends.  It is true for the weighted node packing problem, where &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is a binary decision variable for each node and you want to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_i c_i x_i$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$x_i + x_j \le 1$&lt;/span&gt; for all edges &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Search phrase: &amp;quot;Nemhauser-Trotter local optimization theorem&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Nemhauser, G.L., Trotter, L.E. Vertex packings: Structural properties and algorithms. Mathematical Programming 8, 232–248 (1975). &lt;a href=&quot;https://doi.org/10.1007/BF01580444&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1007/BF01580444&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-04-07T15:42:44.727" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8217" PostTypeId="2" ParentId="8215" CreationDate="2022-04-07T16:12:22.790" Score="9" Body="&lt;p&gt;It is possible that your model could become infeasible if you fixed the variables with integer values in the LP relaxation. Consider, for example, the problem of minimizing &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; subject to the single constraint &lt;span class=&quot;math-container&quot;&gt;$7x - 3y = 5$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are nonnegative integer variables. The solution to the LP relaxation is &lt;span class=&quot;math-container&quot;&gt;$x=5/7,\, y=0.$&lt;/span&gt; Fix &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt; and the problem becomes infeasible.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-07T16:12:22.790" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8218" PostTypeId="2" ParentId="2730" CreationDate="2022-04-07T16:37:04.583" Score="3" Body="&lt;p&gt;Recent work on theoretical results for &amp;quot;strong&amp;quot; branching are here:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;A Theoretical and Computational Analysis of Full Strong-Branching&amp;quot;&#xA;by Santanu S. Dey, Yatharth Dubey, Marco Molinaro, Prachi Shah at&#xA;&lt;a href=&quot;https://arxiv.org/abs/2110.10754&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/2110.10754&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2022-04-07T16:37:04.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8220" PostTypeId="1" AcceptedAnswerId="8221" CreationDate="2022-04-08T13:26:57.007" Score="1" ViewCount="136" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max \lbrace 0, q_i \rbrace \le L^r_i \le \min \lbrace Q^r,Q^r+q_i \rbrace \quad \forall i\in N,r\in R$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am not sure if this type of question is allowed here but I am stuck at modeling this constraints for the pickup dropoff problem with time window in Python using Gurobi API. Can anyone point me in the right direction or show an example?&lt;/p&gt;&#xA;" OwnerUserId="3288" LastEditorUserId="67" LastEditDate="2022-04-08T15:07:17.457" LastActivityDate="2022-04-08T15:08:41.817" Title="Modeling constraints in gurobi" Tags="|modeling|python|gurobi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8221" PostTypeId="2" ParentId="8220" CreationDate="2022-04-08T15:08:41.817" Score="4" Body="&lt;p&gt;Something is greater than or equal to the maximum of several items if and only if it is greater than or equal to each individual item.&lt;/p&gt;&#xA;&lt;p&gt;Something is less than or equal to the minimum of several items if and only if it is less than or equal to each individual item.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-08T15:08:41.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8222" PostTypeId="2" ParentId="3579" CreationDate="2022-04-08T15:23:23.803" Score="5" Body="&lt;p&gt;You can download a 1 month trial licence of Knitro from &lt;a href=&quot;https://www.artelys.com/solvers/knitro/&quot; rel=&quot;noreferrer&quot;&gt;Artelys website&lt;/a&gt; and ask for an extension if needed.&#xA;Artelys also offers free licenses for teaching programs.&lt;/p&gt;&#xA;" OwnerUserId="9511" LastActivityDate="2022-04-08T15:23:23.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8223" PostTypeId="2" ParentId="8212" CreationDate="2022-04-08T15:36:11.713" Score="1" Body="&lt;p&gt;You can solve this as a mixed integer linear program. Let &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; index the products (corn, soy, etc.) with &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; the cost per bag of each product (4,000 for corn etc.) and &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; the target percentage of the total purchase cost &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; attributable to product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. We require that &lt;span class=&quot;math-container&quot;&gt;$\sum_i p_i = 1.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Besides the nonnegative variable &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; for total cost, you will have integer variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; for the number of bags of product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; purchased. The mixed integer model is as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\min\quad &amp;amp; T\\&#xA;\textrm{s.t. }\sum_{i}c_{i}x_{i} &amp;amp; =T\\&#xA;c_{i}x_{i} &amp;amp; =p_{i}T\quad\forall i\\&#xA;x_{i} &amp;amp; \ge1\quad\forall i.&#xA;\end{align*}&lt;/span&gt;&#xA;Note the lower bound of 1 for all purchase quantities &lt;span class=&quot;math-container&quot;&gt;$x_i,$&lt;/span&gt; which is necessary to prevent the solver from choosing the trivial solution. (Buying nothing has minimal cost.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-08T15:36:11.713" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8224" PostTypeId="2" ParentId="8212" CreationDate="2022-04-08T16:19:57.680" Score="1" Body="&lt;p&gt;You actually do not need to solve an optimization model to solve this, although the &amp;quot;direct&amp;quot; approach is also tedious.&lt;/p&gt;&#xA;&lt;p&gt;Consider the constraint (excluding the lower bound on &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;) in my other answer. The form an underdetermined &lt;span class=&quot;math-container&quot;&gt;$5\times 5$&lt;/span&gt; system of linear equations &lt;span class=&quot;math-container&quot;&gt;$Ax = b$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$$A=\left[\begin{array}{ccccc}&#xA;4000 &amp;amp; 3200 &amp;amp; 4500 &amp;amp; 1600 &amp;amp; -1.00\\&#xA;4000 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; -.32\\&#xA;0 &amp;amp; 3200 &amp;amp; 0 &amp;amp; 0 &amp;amp; -.27\\&#xA;0 &amp;amp; 0 &amp;amp; 4500 &amp;amp; 0 &amp;amp; -.15\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1600 &amp;amp; -.26&#xA;\end{array}\right],$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$b = (0, 0, 0, 0, 0)$&lt;/span&gt; and the fifth component of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the total purchase cost. &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; has rank 4. We add one more equation, saying that the total purchase cost is 1, which changes &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$Ax = b$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$$A=\left[\begin{array}{ccccc}&#xA;4000 &amp;amp; 3200 &amp;amp; 4500 &amp;amp; 1600 &amp;amp; -1.00\\&#xA;4000 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; -.32\\&#xA;0 &amp;amp; 3200 &amp;amp; 0 &amp;amp; 0 &amp;amp; -.27\\&#xA;0 &amp;amp; 0 &amp;amp; 4500 &amp;amp; 0 &amp;amp; -.15\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1600 &amp;amp; -.26\\&#xA;0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1&#xA;\end{array}\right]$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$(0,0,0,0,0,1).$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Although the system is undetermined, you can solve it (for example, using QR decomposition of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;), obtaining the following value for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$$x = (8.000000e-05, 8.437500e-05, 3.333333e-05, 1.625000e-04, 1.000000e+00).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now you just need to find the smallest integer &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$\lambda \cdot x$&lt;/span&gt; is integer-valued. We need to multiply by &lt;span class=&quot;math-container&quot;&gt;$10^5$&lt;/span&gt; to clear the exponents, by 3 to get rid of the fractional part of the wheat purchase, and by 16 to get rid of the other fractions. So &lt;span class=&quot;math-container&quot;&gt;$\lambda = 48e^5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$\lambda \cdot x = (384, 405, 160, 780, 4800000),$$&lt;/span&gt;which agrees with the MIP solution.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-08T16:19:57.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8225" PostTypeId="1" CreationDate="2022-04-08T18:50:17.703" Score="2" ViewCount="97" Body="&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;We’d like to optimize the delivery of loads across a network using a fleet of ships. Assume there is a set of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}$&lt;/span&gt; ships that need to deliver the set of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{L}$&lt;/span&gt; loads in a single day. Let the profit of moving load &lt;span class=&quot;math-container&quot;&gt;$j ∈ \mathcal{L}$&lt;/span&gt; with ship &lt;span class=&quot;math-container&quot;&gt;$i \in \mathcal{S}$&lt;/span&gt; be given by &lt;span class=&quot;math-container&quot;&gt;$w_{ij}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The ship can also chose to not move a load at all (and stay put) at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; profit.&lt;/li&gt;&#xA;&lt;li&gt;Assume we can only assign a ship to one load per day&lt;/li&gt;&#xA;&lt;li&gt;A load may be taken by at most one ship&lt;/li&gt;&#xA;&lt;li&gt;Not all loads necessarily need to be moved.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I need to make a model for optimizing profit by formulating the assignment problem for a single day as an integer program and a continuous LP version of it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Here is my take:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;We can model this problem as in a weighted bipartite graph, a matching of a given size, in which the sum of weights of the edges is maximum. Each edge &lt;span class=&quot;math-container&quot;&gt;$(i, j)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is in &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is in &lt;span class=&quot;math-container&quot;&gt;$\mathcal{L}$&lt;/span&gt;, has a profit &lt;span class=&quot;math-container&quot;&gt;$w_{ij}$&lt;/span&gt;. For each edge &lt;span class=&quot;math-container&quot;&gt;$(i, j)$&lt;/span&gt; we have a variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt;. The variable is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if the edge is contained in the matching and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise, so we set the domain constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{ij} = \{0, 1\} \quad \text{for} \quad i, j \in \mathcal{S},\mathcal{L}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The total weight of the matching is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{(i,j) \in \mathcal{S} \times \mathcal{L}} x_{ij} w_{ij}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The goal is to find a perfect matching that maximizes the above objective function. To guarantee that the variables represent a perfect matching, we add constraints saying that each vertex is adjacent to exactly one edge in the matching, i.e,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j \in \mathcal{L}} x_{ij} = 1 \quad \text{for} \quad i \in \mathcal{S}\\&#xA;\sum_{i \in \mathcal{S}} x_{ij} = 1 \quad \text{for} \quad j \in \mathcal{L}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Therefore, the problem can be formulated as –&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{eqnarray}&#xA;    \text{maximize} &amp;amp; \sum_{(i,j) \in \mathcal{S} \times \mathcal{L}} x_{ij}w_{ij}\\&#xA;    \text{subject to} \\&#xA;&amp;amp; \sum_{j \in \mathcal{L}} x_{ij} = 1 \quad \text{for} \quad i \in \mathcal{S}\notag \\&#xA;    &amp;amp; \sum_{i \in \mathcal{S}} x_{ij} = 1 \quad \text{for} \quad j \in \mathcal{L}\notag \\&#xA;    \text{where,} \qquad &amp;amp; x_{ij} = \{0,1\} \quad \text{for} \quad i,j \in \mathcal{S},\mathcal{L} \notag&#xA;\end{eqnarray}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;LP version:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;We can solve it without the integrality constraints, using standard methods for solving continuous linear programs. We can just use this constraint instead –&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{eqnarray}&#xA;    0 \leq x_{ij} \leq 1 \quad \text{for} \quad i,j \in \mathcal{S},\mathcal{L}&#xA;\end{eqnarray}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Am I doing it right?&lt;/p&gt;&#xA;" OwnerUserId="5208" LastEditorUserId="5208" LastEditDate="2022-04-08T19:08:36.907" LastActivityDate="2022-04-08T23:04:30.087" Title="Load to ship assignment problem" Tags="|linear-programming|integer-programming|combinatorial-optimization|assignment-problem|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8226" PostTypeId="2" ParentId="8225" CreationDate="2022-04-08T23:04:30.087" Score="2" Body="&lt;p&gt;You can treat this as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Generalized_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;generalized assignment problem&lt;/a&gt;, assigning loads to ships, with real ships having capacity one load each and with a dummy &amp;quot;ship&amp;quot; with capacity &lt;span class=&quot;math-container&quot;&gt;$\vert \mathcal{L} \vert$&lt;/span&gt; representing loads that are not moved.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-08T23:04:30.087" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8227" PostTypeId="1" CreationDate="2022-04-09T00:48:17.480" Score="7" ViewCount="355" Body="&lt;h3&gt;Motivating example&lt;/h3&gt;&#xA;&lt;p&gt;This question concerns continuous convex minimization. However, the motivating example is the classic binary knapsack problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{maximize}\quad v^T x \qquad \text{subject to}\quad w^T x \leq W, ~~x_i \in \{0, 1\}.$$&lt;/span&gt;&#xA;There is a well-known &lt;a href=&quot;https://or.stackexchange.com/questions/8163/dynamic-program-for-knapsack-in-ow-space/8167?noredirect=1#comment17259_8167&quot;&gt;dynamic program&lt;/a&gt; that solves this problem in &lt;span class=&quot;math-container&quot;&gt;$O(Wn)$&lt;/span&gt;-time. This is called &lt;strong&gt;pseudopolynomial time,&lt;/strong&gt; because it depends on the parameter &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt;. The existence of this algorithm does &lt;em&gt;not&lt;/em&gt; imply that knapsack is in P, because there is no reason to assume that &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$O(p(n))$&lt;/span&gt;.&lt;sup&gt;[1]&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;p&gt;There is also a well-known &lt;a href=&quot;https://en.wikipedia.org/wiki/Knapsack_problem#Fully_polynomial_time_approximation_scheme&quot; rel=&quot;nofollow noreferrer&quot;&gt;fully polynomial-time approximation scheme (FPTAS) for knapsack&lt;/a&gt;, which produces a &lt;span class=&quot;math-container&quot;&gt;$(1 - \varepsilon)$&lt;/span&gt;-optimal solution in &lt;span class=&quot;math-container&quot;&gt;$O(n / \varepsilon)$&lt;/span&gt; time (I think). For a &lt;em&gt;given&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;, this algorithm's runtime is &lt;span class=&quot;math-container&quot;&gt;$O(p(n))$&lt;/span&gt;, but because the runtime is also polynomial in &lt;span class=&quot;math-container&quot;&gt;$1 / \varepsilon$&lt;/span&gt;, this algorithm does &lt;em&gt;not&lt;/em&gt; amount to a proof that knapsack is in P.&lt;sup&gt;[2]&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;In general, we can prove that a problem is in P by providing a polynomial-time solution algorithm.&lt;/strong&gt; But the examples above show us two &lt;strong&gt;common pitfalls&lt;/strong&gt; in this approach:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The runtime cannot depend on the parameters of the problem.&lt;/p&gt;&#xA;&lt;p&gt;→  If it does, then you have a pseudopolynomial-time algorithm.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The solution must be exact.&lt;/p&gt;&#xA;&lt;p&gt;→  If the solution is &lt;span class=&quot;math-container&quot;&gt;$(1 - \varepsilon)$&lt;/span&gt;-optimal and the runtime is polynomial in &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1 /\varepsilon$&lt;/span&gt;, then you have an FPTAS.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Putative polynomial-time algorithms for convex minimization&lt;/h3&gt;&#xA;&lt;p&gt;Now, a common statement in convex optimization courses it that &amp;quot;convex optimization problems can be solved in polynomial time.&amp;quot; But I think this statement needs to be qualified.&lt;/p&gt;&#xA;&lt;p&gt;For linear programs (which are a type of convex optimization problem), the simplex method is known to be worst-case exponential time. Interior-point methods such as the ellipsoid method and Newton's method are often &lt;em&gt;claimed&lt;/em&gt; to be polynomial time. But examining a convergence proof&lt;sup&gt;[3]&lt;/sup&gt; reveals that the runtime depends on the permissible complementarity error &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;. Therefore, it appears that these &lt;strong&gt;interior-point methods are actually &lt;em&gt;FPTAS&lt;/em&gt;es for linear programming.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Likewise, for convex minimization problems, even if we assume strong convexity, linearly independent constraint gradients, and Slater's regularity condition, the runtime of Newton's method depends on the condition number and Lipschitz constant of the objective Hessian.&lt;sup&gt;[4]&lt;/sup&gt; So, if this convergence analysis is accurate, &lt;strong&gt;the Newton's method for convex minimization is actually psuedopolynomial-time&lt;/strong&gt; because it depends on the function parameters.&lt;/p&gt;&#xA;&lt;h3&gt;My question&lt;/h3&gt;&#xA;&lt;p&gt;&lt;strong&gt;Are there any &lt;em&gt;truly&lt;/em&gt; polynomial-time algorithms for convex minimization?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;That is, that produce an exact solution in runtime polynomial in the number of variables and constraints with no dependence on the condition number?&lt;/li&gt;&#xA;&lt;li&gt;If so, what regularity conditions do they require?&lt;/li&gt;&#xA;&lt;li&gt;I am interested in the theoretical properties of the algorithms rather than their practical efficacy.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;There was a &lt;a href=&quot;https://cstheory.stackexchange.com/questions/44324/is-convex-optimisation-in-p&quot;&gt;similar question&lt;/a&gt; on CS Theory SE but it doesn't consider the specific categories of pseudopolynomial-time algorithms and FPTASes.&lt;/p&gt;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Garey and Johnson, &lt;em&gt;Computers and Intractability: A Guide to the Theory of NP-Completeness,&lt;/em&gt; 1976&lt;/li&gt;&#xA;&lt;li&gt;Vazirani, &lt;em&gt;Approximation Algorithms,&lt;/em&gt; 2004&lt;/li&gt;&#xA;&lt;li&gt;Nocedal and Wright, &lt;em&gt;Numerical Optimization,&lt;/em&gt; 2006, section 14.2&lt;/li&gt;&#xA;&lt;li&gt;Boyd and Vanderberge, &lt;em&gt;Convex Optimization,&lt;/em&gt; 2004, section 9.5&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4463" LastEditorUserId="4463" LastEditDate="2022-04-10T00:36:37.573" LastActivityDate="2022-04-11T05:24:49.337" Title="Are &quot;polynomial-time&quot; algorithms for convex minimization actually pseudopolynomial time and/or FPTASes?" Tags="|convex-optimization|computational-complexity|approximation-algorithms|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8228" PostTypeId="1" AcceptedAnswerId="8230" CreationDate="2022-04-09T03:49:20.623" Score="8" ViewCount="769" Body="&lt;p&gt;I am interested in common problems/puzzles that have a clear set of rules/constraints and objective that lends itself to modeled and solved with a linear program.  Especially for people new to LPs, I think that translating a tangible problem into a mathematical formulation is one of the best ways to explain the applicability of LPS.&lt;/p&gt;&#xA;&lt;p&gt;Some easy examples I can think of would be sudoku and the 8-queens puzzle.  What are other examples that come to mind?&lt;/p&gt;&#xA;" OwnerUserId="3255" LastEditorUserId="38" LastEditDate="2022-04-11T00:45:52.547" LastActivityDate="2022-04-25T05:46:50.263" Title="Common problems/puzzles that can creatively be solved with linear programming?" Tags="|optimization|linear-programming|modeling|puzzles-games|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8229" PostTypeId="1" AcceptedAnswerId="8231" CreationDate="2022-04-09T15:38:10.723" Score="3" ViewCount="295" Body="&lt;p&gt;For fun, I have modeled the &lt;a href=&quot;https://en.wikipedia.org/wiki/Union-closed_sets_conjecture&quot; rel=&quot;nofollow noreferrer&quot;&gt;Union-closed sets conjecture&lt;/a&gt; for a universe of a given size  into a problem with binary variables.&lt;/p&gt;&#xA;&lt;p&gt;Each binary variable &lt;span class=&quot;math-container&quot;&gt;$x_k$&lt;/span&gt; is the indicator of the set with elements being the positions of the digit &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in the binary representation of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. For example &lt;span class=&quot;math-container&quot;&gt;$x_{13}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if the set &lt;span class=&quot;math-container&quot;&gt;$\{0,2,3\}$&lt;/span&gt; belongs to the family. Variables for sets with size less than &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; are removed because the conjecture is already proven with those sets in the family. Also, if we have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; elements, &lt;span class=&quot;math-container&quot;&gt;$x_{2^n-1}$&lt;/span&gt; can be replaced with a fixed &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; because that is the universe. I have added constraints to guarantee that the family is union-closed and that it does not have an element in at least half of the sets. The latter is impossible if the conjecture holds, therefore I expect no solution to the IP problem.&lt;/p&gt;&#xA;&lt;p&gt;For example, with &lt;span class=&quot;math-container&quot;&gt;$n=5$&lt;/span&gt; elements, the model is this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;max: x7+x11+x13+x14+x15+x19+x21+x22+x23+x25+x26+x27+x28+x29+x30;&#xA;x7+x11-x15&amp;lt;=1;&#xA;x7+x13-x15&amp;lt;=1;&#xA;x7+x14-x15&amp;lt;=1;&#xA;x7+x19-x23&amp;lt;=1;&#xA;x7+x21-x23&amp;lt;=1;&#xA;x7+x22-x23&amp;lt;=1;&#xA;x11+x13-x15&amp;lt;=1;&#xA;x11+x14-x15&amp;lt;=1;&#xA;x11+x19-x27&amp;lt;=1;&#xA;x11+x25-x27&amp;lt;=1;&#xA;x11+x26-x27&amp;lt;=1;&#xA;x13+x14-x15&amp;lt;=1;&#xA;x13+x21-x29&amp;lt;=1;&#xA;x13+x25-x29&amp;lt;=1;&#xA;x13+x28-x29&amp;lt;=1;&#xA;x14+x22-x30&amp;lt;=1;&#xA;x14+x26-x30&amp;lt;=1;&#xA;x14+x28-x30&amp;lt;=1;&#xA;x19+x21-x23&amp;lt;=1;&#xA;x19+x22-x23&amp;lt;=1;&#xA;x19+x25-x27&amp;lt;=1;&#xA;x19+x26-x27&amp;lt;=1;&#xA;x21+x22-x23&amp;lt;=1;&#xA;x21+x25-x29&amp;lt;=1;&#xA;x21+x28-x29&amp;lt;=1;&#xA;x22+x26-x30&amp;lt;=1;&#xA;x22+x28-x30&amp;lt;=1;&#xA;x25+x26-x27&amp;lt;=1;&#xA;x25+x28-x29&amp;lt;=1;&#xA;x26+x28-x30&amp;lt;=1;&#xA;x7+x11+x13-x14+x15+x19+x21-x22+x23+x25-x26+x27-x28+x29-x30&amp;lt;=-2;&#xA;x7+x11-x13+x14+x15+x19-x21+x22+x23-x25+x26+x27-x28-x29+x30&amp;lt;=-2;&#xA;x7-x11+x13+x14+x15-x19+x21+x22+x23-x25-x26-x27+x28+x29+x30&amp;lt;=-2;&#xA;x7+x11+x13+x14+x15-x19-x21-x22-x23+x25+x26+x27+x28+x29+x30&amp;lt;=-2;&#xA;x7-x11-x13-x14-x15+x19+x21+x22+x23+x25+x26+x27+x28+x29+x30&amp;lt;=-2;&#xA;bin x7,x11,x13,x14,x15,x19,x21,x22,x23,x25,x26,x27,x28,x29,x30;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have solved the problem with &lt;a href=&quot;https://sourceforge.net/projects/lpsolve/&quot; rel=&quot;nofollow noreferrer&quot;&gt;LPSolve&lt;/a&gt; and got:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Model name:  'LPSolver' - run #1&#xA;Objective:   Maximize(R0)&#xA;&#xA;SUBMITTED&#xA;Model size:       35 constraints,      15 variables,          165 non-zeros.&#xA;Sets:                                   0 GUB,                  0 SOS.&#xA;&#xA;Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.&#xA;The primal and dual simplex pricing strategy set to 'Devex'.&#xA;&#xA;The model is INFEASIBLE&#xA;lp_solve unsuccessful after 10 iter and a last best value of -1e+030&#xA;&#xA;MEMO: lp_solve version 5.5.2.11 for 32 bit OS, with 64 bit REAL variables.&#xA;In the total iteration count 10, 9 (90.0%) were bound flips.&#xA;There were 0 refactorizations, 0 triggered by time and 0 by density.&#xA;... on average 1.0 major pivots per refactorization.&#xA;The largest [LUSOL v2.2.1.0] fact(B) had 36 NZ entries, 1.0x largest basis.&#xA;The maximum B&amp;amp;B level was 1, 0.0x MIP order, with 0 nodes explored.&#xA;The constraint matrix inf-norm is 1, with a dynamic range of 1.&#xA;Time to load data was 0.002 seconds, presolve used 0.009 seconds,&#xA;... 0.012 seconds in simplex solver, in total 0.023 seconds.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The software states explicitly &amp;quot;The model is INFEASIBLE&amp;quot;, as I expected, because there can't be any solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;QUESTION 1:&lt;/strong&gt; I suppose this can be considered a rigorous proof from a mathematical point of view: am I right?&lt;/p&gt;&#xA;&lt;p&gt;The same result (&amp;quot;The model is INFEASIBLE&amp;quot;) is obtained for &lt;span class=&quot;math-container&quot;&gt;$n \le 6$&lt;/span&gt;. But for &lt;span class=&quot;math-container&quot;&gt;$n = 7$&lt;/span&gt; (and &lt;span class=&quot;math-container&quot;&gt;$n=8$&lt;/span&gt;) I get:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Model name:  'LPSolver' - run #1&#xA;Objective:   Maximize(R0)&#xA;&#xA;SUBMITTED&#xA;Model size:     3122 constraints,      98 variables,        10031 non-zeros.&#xA;Sets:                                   0 GUB,                  0 SOS.&#xA;&#xA;Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.&#xA;The primal and dual simplex pricing strategy set to 'Devex'.&#xA;&#xA;Relaxed solution                  20 after        549 iter is B&amp;amp;B base.&#xA;&#xA;lp_solve unsuccessful after 1661 iter and a last best value of -1e+030&#xA;lp_solve explored 6 nodes before termination&#xA;&#xA;MEMO: lp_solve version 5.5.2.11 for 32 bit OS, with 64 bit REAL variables.&#xA;In the total iteration count 1661, 318 (19.1%) were bound flips.&#xA;There were 18 refactorizations, 0 triggered by time and 11 by density.&#xA;... on average 74.6 major pivots per refactorization.&#xA;The largest [LUSOL v2.2.1.0] fact(B) had 10967 NZ entries, 1.0x largest basis.&#xA;The maximum B&amp;amp;B level was 4, 0.0x MIP order, with 6 nodes explored.&#xA;The constraint matrix inf-norm is 1, with a dynamic range of 1.&#xA;Time to load data was 0.005 seconds, presolve used 0.008 seconds,&#xA;... 0.609 seconds in simplex solver, in total 0.622 seconds.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;so in this case it just says &amp;quot;lp_solve unsuccessful&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;QUESTION 2:&lt;/strong&gt; Can this be considered a proof that there isn't any solution? Or the algorithm just &amp;quot;gave up&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2022-04-20&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For those who might be interested, I have found some &lt;a href=&quot;https://arxiv.org/abs/1702.05947&quot; rel=&quot;nofollow noreferrer&quot;&gt;serious research&lt;/a&gt; somewhat related to the this post.&lt;/p&gt;&#xA;" OwnerUserId="9517" LastEditorUserId="9517" LastEditDate="2022-04-10T13:57:07.930" LastActivityDate="2022-04-10T13:57:07.930" Title="Meaning of infeasible model: unsuccessful solving for an IP model with binary variables" Tags="|integer-programming|solver|binary-variable|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8230" PostTypeId="2" ParentId="8228" CreationDate="2022-04-09T16:47:00.463" Score="9" Body="&lt;p&gt;I do this all the time over at &lt;a href=&quot;https://puzzling.stackexchange.com/&quot;&gt;https://puzzling.stackexchange.com/&lt;/a&gt;.  Currently, a &lt;a href=&quot;https://puzzling.stackexchange.com/search?q=%22linear%20programming%22&quot;&gt;search for &amp;quot;linear programming&amp;quot;&lt;/a&gt; yields 44 results.  Most of these actually use integer linear programming, and several involve chessboard problems.  But here's one that uses LP and has a nice animation:&#xA;&lt;a href=&quot;https://puzzling.stackexchange.com/questions/111297/five-friends-and-two-motorcyclists/111301#111301&quot;&gt;https://puzzling.stackexchange.com/questions/111297/five-friends-and-two-motorcyclists/111301#111301&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://math.stackexchange.com/search?q=user%3A683666%20dual%20certificate&quot;&gt;these posts&lt;/a&gt;, where I have used LP duality to provide short certificates of optimality for various puzzles.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-04-09T16:47:00.463" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8231" PostTypeId="2" ParentId="8229" CreationDate="2022-04-09T17:20:56.867" Score="5" Body="&lt;p&gt;It might be worth trying this alternative formulation, with your same &lt;span class=&quot;math-container&quot;&gt;$x_k$&lt;/span&gt; variables (one for each of the &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; subsets) and nonnegative slack variables &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt;.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=0}^{n-1} s_i$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_k + x_\ell - 1 &amp;amp;\le x_{k \cup \ell} &amp;amp;&amp;amp;\text{for $k &amp;lt; \ell$} \tag1 \\&#xA;\sum_{k: i \not\in k} x_k - \sum_{k: i \in k} x_k + s_i &amp;amp;\ge 1 \tag2 &amp;amp;&amp;amp;\text{for $i\in \{0,\dots,n-1\}$} \\&#xA;\sum_{k \not= 0} x_k &amp;amp;\ge 1 \tag3  &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; enforces the union-closed property.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; prevents element &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; from appearing in at least half the sets if &lt;span class=&quot;math-container&quot;&gt;$s_i=0$&lt;/span&gt;.&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; avoids the trivial family that contains only the empty set.&#xA;(Note that I include all &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; subsets and do not fix any &lt;span class=&quot;math-container&quot;&gt;$x_k$&lt;/span&gt; variables to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.)&lt;/p&gt;&#xA;&lt;p&gt;If the LP relaxation has positive optimal objective value, the resulting optimal dual solution provides a short certificate that the conjecture is true.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-04-09T18:32:33.900" LastActivityDate="2022-04-09T18:32:33.900" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8232" PostTypeId="1" CreationDate="2022-04-10T14:32:16.353" Score="5" ViewCount="154" Body="&lt;p&gt;I have the following problem which seems related to the packing problem. I have a grid of same size rectangles and a polygon on which this grid of rectangles needs to be placed such that the number of rectangles completely withing the polygon boundaries are maximized.&#xA;I have added a picture which shows a polygon and a grid of rectangles to illustrate the problem. The polygon can also contain holes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ybUMF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ybUMF.jpg&quot; alt=&quot;polygon an rectangle grid&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;My current algorithmic approach is just to orientate the grid the same way as the longest edge in the polygon. The algorithm needs to be fast, the solution does not need to be optimal. Are there any similiar problems in literature I can read up on?&lt;/p&gt;&#xA;&lt;p&gt;Also the grid can be rotated and translated arbitrarily.&lt;/p&gt;&#xA;" OwnerUserId="9521" LastEditorUserId="9521" LastEditDate="2022-04-11T10:07:10.470" LastActivityDate="2022-04-11T10:07:10.470" Title="What kind of packing problem is this?" Tags="|optimization|heuristics|packing|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8233" PostTypeId="1" CreationDate="2022-04-10T16:10:02.917" Score="4" ViewCount="81" Body="&lt;p&gt;Imagine a fairly standard Thumbs Up/Down feedback system.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For each piece of content they consume, every user has the &lt;em&gt;ability&lt;/em&gt; to give a binary positive/negative feedback that piece of content.&lt;/li&gt;&#xA;&lt;li&gt;They're not &lt;em&gt;required&lt;/em&gt; to give feedback, and they can't give any more detail than pos/neg.&lt;/li&gt;&#xA;&lt;li&gt;The content creators want to see the overall opinion of each piece of content, but that feedback must be anonymised, and condensed to a very short numerical summary. 1 figure, maybe 2.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr&gt; &#xA;So far, so standard.&#xA;&lt;p&gt;Obviously if every user had to give feedback on every piece of content, then just the taking the ratio of positive to negative votes would be a reasonably accurate representation of the feedback.&lt;/p&gt;&#xA;&lt;p&gt;However, the fact that users can choose whether or not to give feedback at all adds new information into the system, that isn't reflected in the ratio.&lt;/p&gt;&#xA;&lt;p&gt;It would be reasonable to assert that a +1 vote from someone who only votes on 1% of content is more significant that the same +1 from someone who votes on 95% of content.&lt;/p&gt;&#xA;&lt;p&gt;Similarly, the bias in a user's vote is another source of information: a -1 vote from someone who gives upvotes on 90% of content they vote on, seems like a much bigger deal than a -1 vote who gives about 50:50 up and down votes.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;It seems like it ought to be possible for the system to apply a numerical weighting to a user's vote, given their previous voting history, so that &amp;quot;unusual&amp;quot; votes have more impact on the final normalised score.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Is this a known problem, with an established solution?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;If so, what are the search keywords I should be looking for?&lt;/p&gt;&#xA;&lt;p&gt;If not, does anyone want to make concrete suggestions?&lt;/p&gt;&#xA;" OwnerUserId="4568" LastEditorUserId="67" LastEditDate="2022-04-10T18:15:21.763" LastActivityDate="2022-04-10T18:15:21.763" Title="Is this weighted feedback concept a known, solved, problem?" Tags="|modeling|algorithms|statistics|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8234" PostTypeId="2" ParentId="8228" CreationDate="2022-04-10T18:52:32.180" Score="4" Body="&lt;p&gt;Also these posts are all linear optimization problems using Pyomo&#xA;&lt;a href=&quot;https://www.linkedin.com/newsletters/optimization-in-open-source-6874020019009859585/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.linkedin.com/newsletters/optimization-in-open-source-6874020019009859585/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2022-04-10T18:52:32.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8235" PostTypeId="5" CreationDate="2022-04-11T00:46:27.197" Score="0" Body="" OwnerUserId="38" LastEditorUserId="38" LastEditDate="2022-04-11T00:46:27.197" LastActivityDate="2022-04-11T00:46:27.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8236" PostTypeId="4" CreationDate="2022-04-11T00:46:27.197" Score="0" Body="For questions about OR as it is used to solve puzzles and games." OwnerUserId="38" LastEditorUserId="38" LastEditDate="2022-04-11T00:46:27.197" LastActivityDate="2022-04-11T00:46:27.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8237" PostTypeId="2" ParentId="8227" CreationDate="2022-04-11T03:26:03.913" Score="1" Body="&lt;p&gt;(I will take a shot at answering my own question.)&lt;/p&gt;&#xA;&lt;p&gt;I believe the answer to the question posed in the title is, basically,&lt;/p&gt;&#xA;&lt;h2&gt;Yes.&lt;/h2&gt;&#xA;&lt;p&gt;When people say that convex programs are &amp;quot;polynomially solvable,&amp;quot; they mean they are solvable in the sense that an FPTAS exists.&lt;/p&gt;&#xA;&lt;h2&gt;Linear programming&lt;/h2&gt;&#xA;&lt;p&gt;Even for &amp;quot;simple&amp;quot; convex programs such as linear programming, the existence of an &lt;em&gt;exact,&lt;/em&gt; polynomial-time algorithm is still open, as described on &lt;a href=&quot;https://en.wikipedia.org/wiki/Linear_programming#Open_problems_and_recent_work&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;. In particular,&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Simplex methods are exact (up to floating-point error), but all simplex methods so far have worst-case exponential runtime. (It is an open question whether a polynomial-time set of pivot rules exists.)&lt;/li&gt;&#xA;&lt;li&gt;Interior-point methods are, technically speaking, FPTASes. &lt;strong&gt;However,&lt;/strong&gt; for reasons that appear to have more to do with convention than theory, it is not common to refer to them as such.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Wikipedia also names&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Does LP admit a polynomial-time algorithm in the real number (unit cost) model of computation?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;as an important open problem.&lt;/p&gt;&#xA;&lt;h2&gt;Convex programming&lt;/h2&gt;&#xA;&lt;p&gt;Similar statements can be made about convex programming in general: Wikipedia says that&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Many classes of convex optimization problems admit polynomial-time algorithms, whereas mathematical optimization is in general NP-hard.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The phrases &amp;quot;many classes&amp;quot; is doing a lot of work here; if we consider the minimization a convex function over convex inequality constraints (which is only a subset of convex programming problems, which also include conic constraints and other ways of characterizing convex sets) subject to regularity constraints, then we can show that (for example) gradient descent converges at a certain guaranteed rate. That is, these problems admit FPTASes. Again, the fact that we call these solutions &amp;quot;polynomial-time&amp;quot; algorithms is a bit sloppy, but it seems to capture the difference in difficulty between convex minimization and general nonlinear programming in a legible way.&lt;/p&gt;&#xA;&lt;h2&gt;Convex programs that are &amp;quot;truly&amp;quot; in P&lt;/h2&gt;&#xA;&lt;p&gt;Finally,&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Are there any truly polynomial-time algorithms for convex minimization?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Yes,&lt;/strong&gt; for some problems. Consider the least-squares problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\text{minimize}\quad &amp;amp; ||Ax - b||_2^2 \\&#xA;\text{subject to}\quad &amp;amp; Cx = d.&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;The KKT conditions can be written as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{bmatrix}&#xA;A^T A &amp;amp; C^T \\&#xA;C &amp;amp; 0 \\&#xA;\end{bmatrix}&#xA;\begin{bmatrix}&#xA;x \\ \lambda&#xA;\end{bmatrix}&#xA;=&#xA;\begin{bmatrix}&#xA;A^T b \\ d&#xA;\end{bmatrix}&#xA;$$&lt;/span&gt;&#xA;Assuming that &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; has full row rank and &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; has full column rank, the minimum is unique and can be obtained by solving this linear system using your favorite algorithm. Algorithms for solving linear systems have worst-case polynomial runtime in the matrix dimensions, and they produce a solution that is exact up to floating-point error.&lt;/p&gt;&#xA;&lt;p&gt;Obviously, the set of convex programs that can be written in this form is very small relative to the set of convex programs overall.&lt;/p&gt;&#xA;" OwnerUserId="4463" LastActivityDate="2022-04-11T03:26:03.913" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8238" PostTypeId="2" ParentId="8227" CreationDate="2022-04-11T05:24:49.337" Score="1" Body="&lt;p&gt;There is an upper bound about some complexity of some kind interior-point method given by &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/bv_cvxbook.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;cvxbook&lt;/a&gt; in P589 Eq. (11.26), (11.27), where the tolerance appears in a constant&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;c = \log_2\log_2(1/\epsilon_{\mathrm{nt}})&#xA;\end{equation}&lt;/span&gt;&#xA;It grows extremely slow with &lt;span class=&quot;math-container&quot;&gt;$\epsilon_{\mathrm{nt}}$&lt;/span&gt; decreasing.&#xA;This is known as quadratic convergence of Newton method afaik. My teacher of convex optimization told us many times like &amp;quot;six steps, six steps&amp;quot; on convex optimization classes. And Boyd has also made a joke about it: One time he was giving a talk about Newton method. He purposely replace the constant &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; by digit &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;. An audience asked a question that where the &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; goes at the last line. He answered that the digit &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; is a symbol for &lt;span class=&quot;math-container&quot;&gt;$\log_2\log_2(1/\epsilon_{\mathrm{nt}})$&lt;/span&gt;.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/yMKWP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yMKWP.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;In my opinion it is an FPTAS, but the complexity grows so slowly about &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; that pratically the effect of &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is omitted.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2022-04-11T05:24:49.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8240" PostTypeId="2" ParentId="8228" CreationDate="2022-04-11T08:41:25.697" Score="5" Body="&lt;p&gt;Some other puzzles that you can solve with (MI)LPs:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Zebra_Puzzle&quot; rel=&quot;noreferrer&quot;&gt;Zebra Puzzle&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;This &lt;a href=&quot;https://or.stackexchange.com/questions/7496/solving-logic-puzzles-through-optimization&quot;&gt;basketball player logic puzzle&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;In the following grid, can you mark 8 black circles such that the number of marked circles is even on each column, and on each row ? Can you mark 10 ?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ITvYZ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ITvYZ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Suppose an electronic lock has 3 digits, and that the lock opens once the right code is entered, no matter what was tried just before. What is the fastest way to open the lock (the shortest sequence of numbers that will open the lock)?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-04-11T08:41:25.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8241" PostTypeId="1" CreationDate="2022-04-11T10:08:53.833" Score="2" ViewCount="269" Body="&lt;p&gt;I am solving a sourcing allocation optimization problem. Here I have let's say two brands. Each brand has a raw material demand across the 3 plants (Demand in kg)&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;Brand 1&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;Brand2&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;strong&gt;Plant 1&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;3000&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;2000&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;strong&gt;Plant 2&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;2000&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;1000&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;strong&gt;Plant 3&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;3000&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;2000&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;This demand has to be satisfied by allocating vendors to fulfill demand s.t. minimize the cost of sourcing from them.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vendor 1 : 5000 (capacity in kg)&lt;/li&gt;&#xA;&lt;li&gt;Vendor 2 : 5000&lt;/li&gt;&#xA;&lt;li&gt;Vendor 3 : 5000&lt;/li&gt;&#xA;&lt;li&gt;Vendor 4 : 5000&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I also have a cost matrix that suggests&lt;/p&gt;&#xA;&lt;p&gt;Brand1 : plant 1 : vendor 1 : 20 (cost per kg)&lt;/p&gt;&#xA;&lt;p&gt;I am struggling to define a model with a constraint as follows:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Allocate exactly two vendors for every brand&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;This is of course along with constraints&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Non-negative quantity&lt;/li&gt;&#xA;&lt;li&gt;Total allocated quantity meets the demand requirement&lt;/li&gt;&#xA;&lt;li&gt;Total allocated quantity is less than equal to the capacity of the vendor&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Here is the piece of code that I have tried. I am not able to create the equation correctly in pyomo which ensures a total number of vendors allocated at brand level is == 2. For the same brand, it can be one for a plant or repeated across plants.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;demand = {('B1','P1'):5000,('B1','P2'):3000,('B2','P1'):5000,('B2','P2'):3000}&#xA;vendor = {'v1':2000,'v2':10000,'v3':6000}&#xA;plant = {'P1':6000,'P2':10000}&#xA;brand = {'B1':8000,'B2':8000}&#xA;cost = {('B1','v1','P1'):19,('B1','v1','P2'):27,('B1','v2','P1'):23,('B1','v2','P2'):27,('B1','v3','P1'):20,('B1','v3','P2'):20,&#xA;        ('B2','v1','P1'):19,('B2','v1','P2'):27,('B2','v2','P1'):23,('B2','v2','P2'):27,('B2','v3','P1'):20,('B2','v3','P2'):20}&#xA;model = ConcreteModel()&#xA;model.dual = Suffix(direction=Suffix.IMPORT)&#xA;&#xA;model.i = Set(initialize=list(brand.keys()), doc='Brand')&#xA;model.j = Set(initialize=list(vendor.keys()), doc='Vendors')&#xA;model.k = Set(initialize=list(plant.keys()), doc='Plant')&#xA;&#xA;model.a = Param(model.j, initialize=vendor, doc='Capacity of supplier i in cases')&#xA;model.b = Param(model.i,model.k, initialize=demand, doc='Demand at plant (B,P) (i,k) in cases')&#xA;&#xA;&#xA;model.c = Param(model.i, model.j,model.k, initialize=cost, doc='Transport cost in thousands of dollar per case')&#xA;&#xA;model.x = Var(model.i, model.j,model.k, bounds=(0.0,None), doc='Shipment quantities in case')&#xA;&#xA;model.y = Var(model.i, model.j,model.k, bounds=(0.0,1.0), doc='max allocation per brand')&#xA;&#xA;def supply_rule(model, j):&#xA;  return sum(model.x[i,j,k] for i in model.i for k in model.k) &amp;lt;= model.a[j]&#xA;model.supply = Constraint(model.j, rule=supply_rule, doc='Observe supply limit at plant i')&#xA;&#xA;def demand_rule(model, i,k):&#xA;  return sum(model.x[i,j,k] for j in model.j) == model.b[i,k]  &#xA;model.demand = Constraint(model.i,model.k, rule=demand_rule, doc='Satisfy demand at market j')&#xA;&#xA;// ** This is the constraint i am struggling to code **//&#xA;&#xA;model.count_con6 = ConstraintList()&#xA;for i in model.i:&#xA;  for j in model.j:&#xA;    if model.j!=model.j[-1]: &#xA;      model.count_con6.add(sum(model.y[i,j,k] for k in model.k)==2)&#xA;&#xA;def objective_rule(model):&#xA;  return sum(model.c[i,j,k]*model.x[i,j,k]**model.y[i,j,k] for i in model.i for j in model.j for k in model.k)&#xA;model.objective = Objective(rule=objective_rule, sense=minimize, doc='Define objective function')&#xA;&#xA;//** The above model definition returns quadratic equation error in cbc solver and model errr in ipopt**//&#xA;&#xA;if __name__ == '__main__':&#xA;    # This emulates what the pyomo command-line tools does&#xA;    from pyomo.opt import SolverFactory&#xA;    import pyomo.environ&#xA;    #opt = SolverFactory(&amp;quot;mindtpy&amp;quot;)&#xA;    #results = opt.solve(model)&#xA;    #sends results to stdout&#xA;    SolverFactory('ipopt', executable='/content/ipopt').solve(model)&#xA;    results.write()&#xA;    print(&amp;quot;\nDisplaying Solution\n&amp;quot; + '-'*60)&#xA;    pyomo_postprocess(None, model, results)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9529" LastEditorUserId="39" LastEditDate="2022-04-12T19:34:44.053" LastActivityDate="2022-04-28T01:24:24.137" Title="Passing exact number of allocations as constraint to pyomo in a sourcing problem" Tags="|optimization|python|constraint|nonlinear-programming|pyomo|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8243" PostTypeId="1" CreationDate="2022-04-12T18:10:12.210" Score="2" ViewCount="179" Body="&lt;p&gt;I'm trying to solve a MILP model iteratively, and at each iteration a few constraints are added to the problem that cut off the previous optimal solution. I'm trying to figure out ways to implement a warm-starting type algorithm instead of resolving the problem from scratch. I would appreciate any helps/ideas/recent researches etc that help me start devising a smart warm start (beyond the idea of only using dual simplex) for this problem.&lt;/p&gt;&#xA;" OwnerUserId="9533" LastEditorUserId="500" LastEditDate="2023-12-13T18:04:03.557" LastActivityDate="2023-12-13T18:04:03.557" Title="Warm starting ideas for iteratively solving a model with a few additional constraints" Tags="|mixed-integer-programming|integer-programming|branch-and-bound|branch-and-cut|warm-start|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8244" PostTypeId="1" AcceptedAnswerId="8246" CreationDate="2022-04-12T19:30:28.053" Score="2" ViewCount="455" Body="&lt;p&gt;I have a question with which I am stuck and would be very grateful for help:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have multiple lists of non-negative numerical values (all of the same length)&lt;/li&gt;&#xA;&lt;li&gt;I want to find the list with the lowest &lt;code&gt;n&lt;/code&gt;, where the cumulative sum of the first &lt;code&gt;n&lt;/code&gt; elements is larger or equal than a fixed &lt;code&gt;threshold&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So in the example below with &lt;code&gt;threshold = 10&lt;/code&gt;, I expect the solver to select &amp;quot;list2&amp;quot; at &lt;code&gt;n = 3&lt;/code&gt;, because 1+1+8 == 10. My current implementation in PuLP looks like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import pulp&#xA;&#xA;threshold = 10&#xA;lists = {&#xA;    &amp;quot;list1&amp;quot;: [2,4,0,0,2],&#xA;    &amp;quot;list2&amp;quot;: [1,1,8,2,3],&#xA;    &amp;quot;list3&amp;quot;: [0,5,0,2,1],&#xA;}&#xA;&#xA;n = pulp.LpVariable(&amp;quot;list_index&amp;quot;, 0, 4, pulp.LpInteger)&#xA;lists_selected = pulp.LpVariable.dicts(&amp;quot;is_selected&amp;quot;, lists, cat=pulp.LpBinary)&#xA;&#xA;prob = pulp.LpProblem(&amp;quot;myProblem&amp;quot;, pulp.LpMinimize)&#xA;prob += (n, &amp;quot;minimize list_index&amp;quot;)&#xA;prob += (pulp.lpSum(lists_selected) == 1, &amp;quot;there can only be one selected list&amp;quot;)&#xA;for list_name, list_is_selected in lists_selected.items():&#xA;    prob += (pulp.lpSum([a for i, a in enumerate(lists[list_name]) if i &amp;lt;= n]) &amp;gt;= list_is_selected * threshold,&#xA;             f&amp;quot;if {list_name} is selected, its cumulative sum has to reach the threshold {threshold}&amp;quot;)&#xA;&#xA;status = prob.solve()&#xA;&#xA;# Manual check to see if the solution is valid&#xA;print(pulp.LpStatus[status])&#xA;for list_name, list_is_selected in lists_selected.items():&#xA;    is_valid = (sum([a for i, a in enumerate(lists[list_name]) if i &amp;lt;= pulp.value(n)]) &amp;gt;= pulp.value(list_is_selected) * threshold)&#xA;    print(f&amp;quot;{list_name} constraint is valid: {is_valid}&amp;quot;)&#xA;    if pulp.value(list_is_selected):&#xA;        print(f&amp;quot;-&amp;gt; Selected at deadline {pulp.value(n)}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Returns&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Optimal&#xA;list1 is valid: True&#xA;list2 is valid: False&#xA;-&amp;gt; Selected at deadline 0.0&#xA;list3 is valid: True&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So from my point of view, the solver sets &lt;code&gt;list_index&lt;/code&gt; to its minimum 0, which violates the threshold constraint of the selected &lt;code&gt;list2&lt;/code&gt;. I'm not sure if I am lacking understanding on integer programming or if this is a PuLP-specific problem.&lt;/p&gt;&#xA;" OwnerUserId="9535" LastEditorUserId="491" LastEditDate="2022-04-13T22:27:50.597" LastActivityDate="2022-04-14T17:43:05.267" Title="Find the list with the fewest elements whose cumulative sum reaches threshold" Tags="|mixed-integer-programming|pulp|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8245" PostTypeId="2" ParentId="8243" CreationDate="2022-04-13T06:59:15.047" Score="4" Body="&lt;p&gt;Here's a Gurobi implementation of the TSP using lazy constraints that are added iteratively throughout the solving process: &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/examples/tsp_py.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;tsp.py&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In general, this type of approach is done using callbacks and most solvers support this.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2022-04-13T06:59:15.047" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8246" PostTypeId="2" ParentId="8244" CreationDate="2022-04-13T09:31:45.820" Score="7" Body="&lt;p&gt;Your model basically reads as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;\min \quad n \quad \text{s.t.} \quad \sum_{k = 0}^{n} l_{i,k} \geq b_i \cdot \epsilon, \quad \sum_{i \in L} b_i = 1,&#xA;\end{align*}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$l_{i,k}$&lt;/span&gt; is the k-&lt;em&gt;th&lt;/em&gt; element of the i-&lt;em&gt;th&lt;/em&gt; list and &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; is a binary variable that equals one iff the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th list is selected. The problem is that &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is a variable as well and you can't use PuLP variables inside logical python expressions like &lt;code&gt;if&lt;/code&gt;. Therefore, your second constraint is not valid due to the &lt;code&gt;if I &amp;lt;= n&lt;/code&gt; inside the sum.&lt;/p&gt;&#xA;&lt;p&gt;Instead, you can define a binary variable &lt;span class=&quot;math-container&quot;&gt;$b_{i,k}$&lt;/span&gt; that equals 1 iff list &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is selected and we sum up until the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-th element. Then, our model looks like this&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \sum_{i \in L} \sum_{k = 0}^{m_i} k \cdot b_{i,k}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\sum_{k = 0}^{r} l_{i,k} &amp;amp;\geq b_{i,r} \cdot \epsilon \quad \forall i \in L, r \in \{0, \ldots, m_i\}, \\&#xA;\sum_{i \in L} \sum_{k = 0}^{m_i} b_{i,k} &amp;amp;= 1.&#xA;%&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; denotes the set of lists and &lt;span class=&quot;math-container&quot;&gt;$m_i$&lt;/span&gt; the number of elements in the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th list. In code (note that I prefer the &lt;code&gt;.addConstraint()&lt;/code&gt; and &lt;code&gt;.setObjective()&lt;/code&gt; methods over the overloaded &lt;code&gt;+=&lt;/code&gt; operator):&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import pulp&#xA;&#xA;threshold = 10&#xA;lists = {&#xA;    &amp;quot;list1&amp;quot;: [2,4,0,0,2],&#xA;    &amp;quot;list2&amp;quot;: [1,1,8,2,3],&#xA;    &amp;quot;list3&amp;quot;: [0,5,0,2,1],&#xA;}&#xA;&#xA;prob = pulp.LpProblem(&amp;quot;myProblem&amp;quot;, pulp.LpMinimize)&#xA;&#xA;# Lists&#xA;L = lists.keys()&#xA;&#xA;# Variables&#xA;b = {}&#xA;for l in L:&#xA;    for k in range(len(lists[l])):&#xA;        b[l, k] = pulp.LpVariable(f&amp;quot;b[{l}, {k}]&amp;quot;, cat=pulp.LpBinary)&#xA;&#xA;# Objective&#xA;prob.setObjective(sum(k * b[l, k] for l in L for k in range(len(lists[l]))))&#xA;&#xA;# Constraints&#xA;for l in L:&#xA;    for r in range(len(lists[l])):&#xA;        prob.addConstraint(sum(lists[l][k] for k in range(r)) &amp;gt;= b[l, r]*threshold)&#xA;&#xA;prob.addConstraint(sum(b[l, k] for l in L for k in range(len(lists[l]))) == 1)&#xA;&#xA;# solve the problem&#xA;status = prob.solve()&#xA;&#xA;# print the solution&#xA;print(pulp.LpStatus[status])&#xA;for (l, k) in b:&#xA;    print(f&amp;quot;b[{l}, {k}] = {b[l, k].varValue}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This yields:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Optimal&#xA;b[list1, 0] = 0.0&#xA;b[list1, 1] = 0.0&#xA;b[list1, 2] = 0.0&#xA;b[list1, 3] = 0.0&#xA;b[list1, 4] = 0.0&#xA;b[list2, 0] = 0.0&#xA;b[list2, 1] = 0.0&#xA;b[list2, 2] = 0.0&#xA;b[list2, 3] = 1.0&#xA;b[list2, 4] = 0.0&#xA;b[list3, 0] = 0.0&#xA;b[list3, 1] = 0.0&#xA;b[list3, 2] = 0.0&#xA;b[list3, 3] = 0.0&#xA;b[list3, 4] = 0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="3696" LastEditDate="2022-04-13T15:37:57.900" LastActivityDate="2022-04-13T15:37:57.900" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8247" PostTypeId="2" ParentId="8244" CreationDate="2022-04-13T10:04:32.527" Score="3" Body="&lt;p&gt;I think the appropriate way to do this is what was proposed by Prof. Rubin, but if you want to use a mathematical approach, the following formulation would be helpful.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;\text{Max/Min} &amp;amp; \text{Constant}\\&#xA;\text{subject to} \\&#xA;&amp;amp;\sum_{j\in \mathcal{J}} w_{ij}x_{ij} \leq Threshold \quad \text{for} \quad i \in \mathcal{I}:ok_{i}\notag \\&#xA;&amp;amp;\sum_{j\in \mathcal{J}} x_{ij} \geq 1 \quad \text{for} \quad i\in \mathcal{I}:ok_{i}\notag \\&#xA;\text{where,} \qquad &amp;amp; x_{ij} = \{0,1\} \quad \text{for} \quad i,j \in \mathcal{I},\mathcal{J} \notag&#xA;\end{eqnarray}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; indicates that if element &lt;span class=&quot;math-container&quot;&gt;$j \in \mathcal{J}$&lt;/span&gt; in the list &lt;span class=&quot;math-container&quot;&gt;$i \in \mathcal{I}$&lt;/span&gt; is allocated, &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_{ij}$&lt;/span&gt; is the lists you defined. Please be aware that, if you want to select items in each list based on a pre-defined threshold, you should be sure that the cumulative sum of the items can be achieved. According to this, a checker set &lt;span class=&quot;math-container&quot;&gt;$ok_{i}$&lt;/span&gt; is defined. By the above formulation and using solution pool technology the results are:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Okzin.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Okzin.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;For achieving the first &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; items, as Kuifje mentioned, by adding the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;&amp;amp;\sum_{j\in \mathcal{J}} x_{ij} \leq \sum_{j\in \mathcal{J}} x_{ij-1}\quad \text{for} \quad i \in \mathcal{I}:ok_{i}\notag \\&#xA;\end{eqnarray}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The solution is: (i2: j1, j2, j3, j4)&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2022-04-14T17:43:05.267" LastActivityDate="2022-04-14T17:43:05.267" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8248" PostTypeId="1" CreationDate="2022-04-13T12:00:07.543" Score="6" ViewCount="2156" Body="&lt;p&gt;Are there any useful resources to compare the performance of python and c++ languages in algorithms dedicated to solving discrete optimization problems?&lt;/p&gt;&#xA;" OwnerUserId="5537" LastActivityDate="2022-04-18T15:36:19.017" Title="Python vs C++ performance on Discrete Optimization" Tags="|python|combinatorial-optimization|c++|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8249" PostTypeId="2" ParentId="8248" CreationDate="2022-04-13T15:17:46.430" Score="19" Body="&lt;p&gt;If you are using a solver (open-source or commercial) to solve a discrete optimization problem, and if the problem is not trivial or extremely easy, chances are very high that the bulk of the computation time will be spent inside the solver. The solver will almost assured be programmed in C or C++. So the Python/C++ question likely boils down to which performs better (and by how much) when constructing the model and recovering and post-processing the solution. C++ will almost certainly be faster, but whether the difference in speed matters to you will probably depend on how large the model is and how sensitive you are to the time spent setting up the model (which, on a difficult model, will probably be a very small fraction of the total solution time).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-13T15:17:46.430" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8250" PostTypeId="2" ParentId="8243" CreationDate="2022-04-13T17:52:13.323" Score="2" Body="&lt;p&gt;I doubt it's possible to recycle the previous tree. Nodes that were pruned as infeasible before would still be infeasible, but nodes pruned on bound might have been pruned based on a &amp;quot;feasible&amp;quot; solution that is now infeasible. Also, bounds on old nodes might very well change given the new constraints. It would be theoretically possible to retain all that info and revisit the old tree, revising bounds, resuscitating (perhaps temporarily) nodes and so on, but my guess is that it would amount to more work than just starting from scratch would ... plus it would mean a lot of developer time and added code to handle and &amp;quot;edge case&amp;quot; that likely would not arise very often.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-13T17:52:13.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8251" PostTypeId="2" ParentId="8243" CreationDate="2022-04-13T19:57:56.137" Score="3" Body="&lt;p&gt;A couple of ideas, but which require to understand a bit how a MILP solver works internally, are not particularly easy to implement and are not guaranteed of success:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a branching strategy relying on pseudo-costs. Keep the pseudo-costs of the variables between the consecutive solves, or use the values of the pseudo-costs of the previous solve to initialize the pseudo-costs of the next solve or to set priorities to the variables&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run a local branching heuristic using the solution of the previous solve as reference point. Finding a good solution quickly might speed up the resolution&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Favor the type and intensiveness of cuts which worked well in the previous solve&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Basically, for every component which is learned dynamically by the solver, you can try to re-use the learned knowledge for the next solve&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-04-13T19:57:56.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8252" PostTypeId="1" CreationDate="2022-04-14T10:50:02.413" Score="3" ViewCount="90" Body="&lt;p&gt;My question is related to freight transportation, but I am stuck on the logic. So, I am considering a path between two points &lt;span class=&quot;math-container&quot;&gt;$(a, b)$&lt;/span&gt; where I am sending &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; trucks where the capacity/truck is &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. The distance is &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; and the truck speed is &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;. Let's say that I am trying to get the time required to transport one unit of freight, do I use the standard &lt;span class=&quot;math-container&quot;&gt;$ t_{a,b}=\frac{d_{a,b}}{v}$&lt;/span&gt; or do I consider road capacity (i.e., &lt;span class=&quot;math-container&quot;&gt;$path \ cpty_{a,b} =\frac{60}{headway}$&lt;/span&gt;)? If I consider&#xA;&lt;span class=&quot;math-container&quot;&gt;$ t_{a,b}=\frac{d_{a,b}}{v}$&lt;/span&gt;, and assuming that &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; vehicles are not simultaneously dispatched, then which is it ? The time to transport one unit of freight, &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; units of freight ? Finally, do I need to use queuing theory to compute the total time to transport &lt;span class=&quot;math-container&quot;&gt;$k \times n$&lt;/span&gt; units of freight ?&lt;/p&gt;&#xA;&lt;p&gt;An example would be a minimum flow time model where the objective function is to minimize the total amount of transit time or &lt;span class=&quot;math-container&quot;&gt;$Min \ Z= \sum_{a \in O}\sum_{b \in D}t_{a,b}x_{a,b}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$t_{a,b}$&lt;/span&gt; is the average time to transport 1 unit of flow over any &lt;span class=&quot;math-container&quot;&gt;$(a,b) \in A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{a,b}$&lt;/span&gt;, the total flow transiting through any &lt;span class=&quot;math-container&quot;&gt;$(a,b) \in A$&lt;/span&gt;. If I have to solve it, I would need to be able to accurately define a function to compute &lt;span class=&quot;math-container&quot;&gt;$t_{a,b}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4491" LastEditorUserId="491" LastEditDate="2022-04-14T20:51:59.450" LastActivityDate="2022-04-14T20:51:59.450" Title="How to compute the time required to transport one unit of flow on a given path?" Tags="|modeling|logistics|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8253" PostTypeId="1" CreationDate="2022-04-14T21:41:33.453" Score="1" ViewCount="85" Body="&lt;p&gt;I'm looking for optimization problem classes with inventory control constraints. Given a directed graph &lt;span class=&quot;math-container&quot;&gt;$G(V,A)$&lt;/span&gt; where vertex set &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; consists of production nodes and demand nodes. The arc set &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; contains an outgoing connection from every production node to every other node. Demand nodes only have incoming arcs. We also have a set of commodities &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;, and a set of time periods &lt;span class=&quot;math-container&quot;&gt;$T=0,1,2,\dots,H$&lt;/span&gt;. With each arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in A$&lt;/span&gt; we associate a transfer lead time &lt;span class=&quot;math-container&quot;&gt;$\tau_{ij}$&lt;/span&gt; (measured in time periods) and a per unit cost &lt;span class=&quot;math-container&quot;&gt;$c_{ijk}$&lt;/span&gt;. Let parameter &lt;span class=&quot;math-container&quot;&gt;$s_{ik}^t$&lt;/span&gt; be the amount of commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; that is produced at production facility &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. We define two types of variables, e.g. flow variables &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}^t$&lt;/span&gt; representing the quantity of commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; transferred from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, as well as inventory level variables &lt;span class=&quot;math-container&quot;&gt;$I_{ik}^t$&lt;/span&gt; representing the inventory level of production facility &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; of commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. The inventory levels can be tracked through the following type of constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;I_{ik}^t=I_{ik}^{t-1}-\sum_{(i,j)\in A}x_{ijk}^t+\sum_{(j,i)\in A}x_{jik}^{t-\tau_{ij}}+s_{ik}^t &amp;amp; \forall i\in V, k\in K, t=1,2,\dots,H\\&#xA;&amp;amp;I_{ik}^0=s_{ik}^0 &amp;amp;\forall i\in V, k\in K&#xA;\end{align}&lt;/span&gt;&#xA;In words, the first constraint states that the inventory level of facility &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; for commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; equals the inventory level in the previous time period &lt;span class=&quot;math-container&quot;&gt;$(t-1)$&lt;/span&gt; minus the volume that was transferred to other nodes plus the volume received from other facilities plus the amount &lt;span class=&quot;math-container&quot;&gt;$s_{ik}^t$&lt;/span&gt; that was produced. The second constraint sets the initial inventory levels at the start of the time horizon.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for references to papers and problem classes that contain constraints with this kind of structure. I'm particularly interested in optimization problems that minimize total transfer costs plus some fixed charge component (e.g. a costs for using an arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;). Although I can think of a variety of real-life applications that exhibit this general structure, I can't seem to find many relevant references? Perhaps this is a well-studied class of problems and I'm just searching for the wrong kind of literature. There's various kinds of fixed-charge network flow problems, but none of the variants I found track inventory levels. Any references on problem classes with inventory level constraints (with or without a fixed charge cost component) are appreciated.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="67" LastEditDate="2022-04-14T23:31:13.470" LastActivityDate="2022-04-15T12:43:17.673" Title="Literature on fixed-charge network flow problems with inventory levels" Tags="|mixed-integer-programming|inventory|literature-research|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8254" PostTypeId="1" CreationDate="2022-04-15T07:26:54.943" Score="5" ViewCount="824" Body="&lt;p&gt;I want to optimize a charging schedule for &lt;em&gt;Battery Electric Vehicles (BEV)&lt;/em&gt; along a grid line, taking into account customer wishes (when to be done with charging with what &lt;em&gt;State of Charge (SOC)&lt;/em&gt;) and other loads like households. So the goal is to load the BEV -- if possible meet the customer's wishes -- and assure that the grid is not overloaded.&lt;/p&gt;&#xA;&lt;p&gt;I will first try to explain some background. The actual question is at the end.&lt;/p&gt;&#xA;&lt;p&gt;I use python and pyomo as an optimization framework, as a solver I use glpk.&lt;/p&gt;&#xA;&lt;p&gt;That's what a generic grid line with 4 nodes looks like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PLnF8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PLnF8.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Here is, what my formulation looks like:&lt;/h1&gt;&#xA;&lt;h2&gt;Symbols&lt;/h2&gt;&#xA;&lt;h3&gt;Indices&lt;/h3&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Symbol&lt;/th&gt;&#xA;&lt;th&gt;Meaning&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;node&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;timestep&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;line&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&lt;h3&gt;Sets&lt;/h3&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Symbol&lt;/th&gt;&#xA;&lt;th&gt;Meaning&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;set of all nodes&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}_\mathrm{BEV}$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;set of nodes with attached charger&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{T}$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;set of all timesteps&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{L}$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;set of all lines&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&lt;h3&gt;Decision Variables&lt;/h3&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Symbol&lt;/th&gt;&#xA;&lt;th&gt;Meaning&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$I^\mathrm{BEV}_{t,n}$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;BEV charging current&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$SOC_{t,n}$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;BEV SOC&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&lt;h3&gt;Parameters&lt;/h3&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Symbol&lt;/th&gt;&#xA;&lt;th&gt;Meaning&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$I^\mathrm{HH}_{t,n}$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;household current&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$Z_l$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;line impedance&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$u_0$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;voltage at transformer low voltage side&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$u_n$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;voltage at node &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$u_\mathrm{min}$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;minimum permitted voltage&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$i_\mathrm{max}$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;maximum permitted current&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$P_\mathrm{trafo}$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;transformer power&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$E_n$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;BEV battery capacity&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$\Delta t$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;lenght of timestep&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;span class=&quot;math-container&quot;&gt;$\Delta SOC_\mathrm{max}$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td&gt;maximum tolerable SOC difference&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&lt;hr /&gt;&#xA;&lt;h2&gt;Target Function:&lt;/h2&gt;&#xA;&lt;p&gt;Maximize the charging current for each node at each timestep&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathrm{max.}\quad\sum_{t\in\mathcal{T}}\bigg(\sum_{n\in\mathcal{%&#xA;    N_\mathrm{BEV}}}\!\!\!\Big( I^\mathrm{BEV}_{t,n} \Big)  \bigg)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h2&gt;Constraints&lt;/h2&gt;&#xA;&lt;p&gt;Don't fall below permitted voltage&#xA;&lt;span class=&quot;math-container&quot;&gt;$$u_0-\sum_{l\in\mathcal{L}}\bigg( Z_l\cdot\sum_{\substack{%&#xA;    n\in\mathcal{N} \\ n&amp;gt;l}}\Big( I^\mathrm{BEV}_{t,n}+%&#xA;    I^\mathrm{HH}_{t,n} \Big) \bigg)\geq u_\mathrm{min}\quad&#xA;    \forall t \in\mathcal{T}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Don't exceed permitted current &lt;span class=&quot;math-container&quot;&gt;$i_\mathrm{max}=P_\mathrm{trafo}/u_0$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{n\in\mathcal{N}}\Big( I^\mathrm{BEV}_{t,n}+%&#xA;    I^\mathrm{HH}_{t,n} \Big)\leq i_\mathrm{max}\quad&#xA;    \forall t\in\mathcal{T}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Ensure energy conservation while charging&#xA;&lt;span class=&quot;math-container&quot;&gt;$$SOC_{t,n}+\frac{I^\mathrm{BEV}_{t,n}\cdot u_n\cdot\Delta t}{%&#xA;    E_{n}}\cdot 100\%=SOC_{t+1,n}\quad\forall t\in\mathcal{T}\quad\forall n\in\mathcal{%&#xA;    N_\mathrm{BEV}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Ensure equal SOCs after charging&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{SOC_{t_\mathrm{end},n}-SOC^\mathrm{start}_n}{SOC^\mathrm{target}_n-%&#xA;    SOC^\mathrm{start}_n}-\frac{SOC_{t_\mathrm{end},n-1}-SOC^\mathrm{start}%&#xA;    _{n-1}}{SOC^\mathrm{target}_{n-1}-SOC^\mathrm{start}_{n-1}}\leq\Delta &#xA;    SOC_\mathrm{max}\quad\forall n\in\mathcal{N}_\mathrm{BEV}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Results&lt;/h1&gt;&#xA;&lt;p&gt;Let's consider the following scenario: a gridline with 6 nodes, 2 charging stations (11kW each, one at the first and one at the last node). The household currents are just taken from some standard load profile. Both BEVs arrive at 15pm with 20% SOC and wish to finish charging at 20pm with 100% SOC. The transformer is only 15kVA, thus not enough to allow both BEVs to concurrently charge at nominal power.&lt;/p&gt;&#xA;&lt;p&gt;Now when I start the optimizer without the equal-SOCs-constraint activated, I get the following result:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NGRy7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NGRy7.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The optimizer clearly favors the BEV at node 6, which is not fair.&lt;/p&gt;&#xA;&lt;p&gt;Now when I activate the equal-SOCs-constraint (&lt;span class=&quot;math-container&quot;&gt;$\Delta SOC_\mathrm{max}=0$&lt;/span&gt;) and rerun, I get the following result:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/O8U0b.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/O8U0b.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Okay, both end up with the same SOC, that's nice. But the optimizer switches the chargers on and off all the time -- that's annoying and also not good for the batteries I guess.&lt;/p&gt;&#xA;&lt;h1&gt;Finally, my Question&lt;/h1&gt;&#xA;&lt;p&gt;Is there any other way to formulate the equal-SOCs-constraint, to achieve a smooth loading? E.g. something like (sorry for my bad drawing):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/D2xzb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/D2xzb.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9052" LastEditorUserId="491" LastEditDate="2022-04-15T12:31:37.280" LastActivityDate="2022-04-16T20:19:48.247" Title="how to &quot;calm down&quot; optimizer" Tags="|optimization|linear-programming|modeling|pyomo|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8255" PostTypeId="2" ParentId="8253" CreationDate="2022-04-15T10:37:27.173" Score="2" Body="&lt;p&gt;What you are looking for sounds like a variant of the inventory routing problem (IRP). There are lots of papers you can find easily by googling. Some of them that might be close to your issue are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0305054820300617&quot; rel=&quot;nofollow noreferrer&quot;&gt;The two-echelon inventory-routing problem with fleet management&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0377221721011073&quot; rel=&quot;nofollow noreferrer&quot;&gt;Comparison of formulations for the Inventory Routing Problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0305054812001773&quot; rel=&quot;nofollow noreferrer&quot;&gt;The exact solution of several classes of inventory-routing problems&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastEditorUserId="500" LastEditDate="2022-04-15T12:43:17.673" LastActivityDate="2022-04-15T12:43:17.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8256" PostTypeId="2" ParentId="8254" CreationDate="2022-04-15T15:26:21.543" Score="5" Body="&lt;p&gt;Regarding the equal-SOC constraint, you might want to consider changing &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n'$&lt;/span&gt; and enforcing it for all pairs &lt;span class=&quot;math-container&quot;&gt;$n,\ n' \in \mathcal{N}_\mathrm{BEV}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$n' &amp;lt; n.$&lt;/span&gt; This would add some constraints but perhaps make for a more &amp;quot;egalitarian&amp;quot; final state. As it stands, when there are more than two charging stations the solver can leave you with an ascending sequence of SOCs, with the first charging node at a considerably lower level than the last one.&lt;/p&gt;&#xA;&lt;p&gt;As far as the variability in current, one possibility would be to add a constraint saying that &lt;span class=&quot;math-container&quot;&gt;$I^\mathrm{BEV}_{t,n} - I^\mathrm{BEV}_{t-1,n}\ge \lambda$&lt;/span&gt; for some parameter value &lt;span class=&quot;math-container&quot;&gt;$\lambda &amp;gt; 0.$&lt;/span&gt; This limits the amount the current can drop over consecutive periods, and keeps your model as a linear program. An alternative approach would be to assert a minimum number of periods that current could be supplied. For instance, you could say that once charging is turned on it must continue for at least 3 periods. This approach would require binary variables for each combination of charging node and time period, plus additional constraints. It would turn your linear program into an mixed integer linear program.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-15T15:26:21.543" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8257" PostTypeId="2" ParentId="8254" CreationDate="2022-04-16T00:22:33.207" Score="4" Body="&lt;p&gt;The switching on-and-off reminds me of a similar phenomenon, called &amp;quot;ringing&amp;quot;, in this paper:&#xA;Case Studies in Trajectory Optimization: Trains, Planes, and Other Pastimes&#xA;Robert J. Vanderbei&#xA;Optimization and Engineering volume 2, pages 215–243 (2001)&#xA;&lt;a href=&quot;https://vanderbei.princeton.edu/tex/trajopt/trajopt.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vanderbei.princeton.edu/tex/trajopt/trajopt.pdf&lt;/a&gt;&#xA;See Figure 3 and the discussion near it. Their optimization problem is already nonlinear, so they don't mind adding a nonlinear term to the objective function: the squared difference between successive decision variables. If at some point your LP becomes an NLP, then perhaps this idea will be useful.&lt;/p&gt;&#xA;" OwnerUserId="4141" LastActivityDate="2022-04-16T00:22:33.207" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8258" PostTypeId="2" ParentId="8254" CreationDate="2022-04-16T20:14:44.087" Score="4" Body="&lt;p&gt;I see three options which do not involve extra binary variables. Although i agree that the binary variables would work.&lt;/p&gt;&#xA;&lt;p&gt;Smooth your plan after the fact with post processing while keeping the objective the same. This could either happen by an algorithm you write (which preserves optimality of solutions) or MILP solving with objective that punishes the excitement while adding the constraint that the term which was previously the objective must assume the optimal value of the previous problem.&lt;/p&gt;&#xA;&lt;p&gt;Add a penalty term which punishes the L1 norm or sign changes (discrete norm) of &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; slightly. Also MILP possible with MILP&lt;/p&gt;&#xA;&lt;p&gt;A better modeling of ramp up or down constraints which are the reason why plugging in and out is bad could help. This would possible with MILP.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2022-04-16T20:19:48.247" LastActivityDate="2022-04-16T20:19:48.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8259" PostTypeId="1" AcceptedAnswerId="8260" CreationDate="2022-04-17T15:31:36.377" Score="0" ViewCount="111" Body="&lt;p&gt;I have the following problem.&lt;/p&gt;&#xA;&lt;p&gt;I have a route which begins at node &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&#xA;I want to begin and end in &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; which is a depot.&lt;/p&gt;&#xA;&lt;p&gt;Now in this route even customer will be visited in order for example customer 2 will be second, customer 4 the fourth, customer 6 will be the sixth.&lt;/p&gt;&#xA;&lt;p&gt;However I can visit the odd label customers in any order I please.&lt;/p&gt;&#xA;&lt;p&gt;So for example if we have n=5 customers one possible tour is&#xA;(0,1,2,3,4,5,0) or (0,5,2,1,4,3,0) or (0,3,2,1,4,5,0) or some other combination.&lt;/p&gt;&#xA;&lt;p&gt;If have n=6 customers&#xA;We have (0,1,2,3,4,5,6,0) or we have (0,3,2,1,4,5,6,0) as another possibility&lt;/p&gt;&#xA;&lt;p&gt;You want to chose the position for the odd labeled customers to complete the tour at the min cost&#xA;We assume we know &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; between each pair of customer and between the depot and customers.&lt;/p&gt;&#xA;&lt;p&gt;Formula this problem as a min cost network flow.&lt;/p&gt;&#xA;&lt;p&gt;I am not sure how do this.&#xA;I know we start at 0 and for &lt;span class=&quot;math-container&quot;&gt;$n=5$&lt;/span&gt; we can visit 1,3,5 first the second node you must visit is 2 but I am not sure how you get the min distance.&lt;/p&gt;&#xA;" OwnerUserId="9483" LastEditorUserId="500" LastEditDate="2022-04-18T04:52:44.893" LastActivityDate="2022-04-18T04:52:44.893" Title="How to model a simple routing problem using nodes and arcs" Tags="|modeling|network-flow|traveling-salesman|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8260" PostTypeId="2" ParentId="8259" CreationDate="2022-04-17T16:41:19.247" Score="4" Body="&lt;p&gt;You can formulate this as a linear assignment problem in a bipartite network, which you can think of as a minimum-cost network flow problem with a supply of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; for the &amp;quot;left&amp;quot; nodes and a demand of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; for the &amp;quot;right&amp;quot; nodes.  The left nodes correspond to the odd customers, and the right nodes correspond to the odd positions.  The cost of assigning customer &lt;span class=&quot;math-container&quot;&gt;$2i+1$&lt;/span&gt; to position &lt;span class=&quot;math-container&quot;&gt;$2j+1$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$d_{2j,2i+1} + d_{2i+1,2j+2}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-04-17T16:41:19.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8261" PostTypeId="1" CreationDate="2022-04-18T08:44:56.517" Score="5" ViewCount="305" Body="&lt;p&gt;I am interested to know solving the generalized assignment problem (GAP) using the variable splitting scheme, specifically, in the context of Lagrangian relaxation. The problem is stated as follows: (named GAP2)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text { Minimize Z = } \alpha \sum_{i=1}^{m} \sum_{j=1}^{n} c_{i j} x_{i j} + \beta \sum_{i=1}^{m} \sum_{j=1}^{n} c_{i j} y_{i j}\\&#xA;S.t:&#xA;\sum_{j=1}^{n} r_{i j} x_{i j} \leq a_{i}, \quad i \in M \quad \text{(1)}\\&#xA;\sum_{i=1}^{m} y_{i j}=1, \quad j \in N \quad \text{(2)}\\&#xA;x_{i j}=y_{i j}, \quad i \in M, j \in N \quad \text{(3)}\\&#xA;x_{i j}, y_{i j} =0 \text { or } 1, \quad i \in M, j \in N \quad \text{(4)}\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where, &lt;span class=&quot;math-container&quot;&gt;$\alpha, \beta$&lt;/span&gt; are constant and &lt;span class=&quot;math-container&quot;&gt;$\alpha+\beta=1$&lt;/span&gt;. By dualizing the third constraint the remaining problem can be decomposed into two sub-problems. One is based on the &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; and the other is based on the &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt;. The dualized problem is already as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{}&#xA;\text { Minimize Z = } \alpha \sum_{i=1}^{m} \sum_{j=1}^{n} c_{i j} x_{i j} + \beta \sum_{i=1}^{m} \sum_{j=1}^{n} c_{i j} y_{i j} + \sum_{i=1}^{m} \sum_{j=1}^{n} \mu_{i j} (x_{i j} - y_{i j})\\&#xA;\quad S.t:(1), (2), (4);&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first sub-problem is &lt;span class=&quot;math-container&quot;&gt;$\{ min\sum_{i=1}^{m} \sum_{j=1}^{n} (\alpha c_{i j} + \mu_{i j})x_{i j}|S.t: (1),(4)\}$&lt;/span&gt;, and the second also would be &lt;span class=&quot;math-container&quot;&gt;$\{ min\sum_{i=1}^{m} \sum_{j=1}^{n} (\beta c_{i j} - \mu_{i j})x_{i j}|S.t: (2),(4)\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;These two sub-problems can still be solved efficiently by using a single knapsack problem and a heuristic approach respectively. Also, there are some polynomial-time approximation algorithms to solve the original problem (GAP) as well, like &lt;em&gt;MTHG&lt;/em&gt; proposed by &lt;span class=&quot;math-container&quot;&gt;$\text{Martello &amp;amp; Toth(1981)}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have tried to solve some of the variants of this problem in an LR approach by using subgradient optimization. In many cases, the original problem (GAP) can be solved very efficient to produce the lower bound even without applying any repairing mechanism to invoke a feasible solution, whereas the GAP2, in the best attempt, is a worse case LB and far quite from the solution of the GAP!!?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The main question is rising in mind is what would be a benefit of using this decomposition scheme to solve this problem?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="491" LastEditDate="2022-04-18T13:12:33.113" LastActivityDate="2022-04-18T21:25:57.933" Title="The variable splitting scheme in the context of Lagrangian relaxation" Tags="|mixed-integer-programming|heuristics|lagrangian-relaxation|lagrangian-decomposition|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8262" PostTypeId="2" ParentId="8261" CreationDate="2022-04-18T12:19:09.663" Score="4" Body="&lt;p&gt;The only occurrences of this decomposition that I am aware of are from:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Jörnsten K, Näsberg M (1986) A new Lagrangian relaxation approach to the generalized assignment problem. European Journal of Operational Research 27:313–323. &lt;a href=&quot;https://doi.org/10.1016/0377-2217(86)90328-0&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/0377-2217(86)90328-0&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Cattrysse DG, Van Wassenhove LN (1992) A survey of algorithms for the generalized assignment problem. European Journal of Operational Research 60:260–272. &lt;a href=&quot;https://doi.org/10.1016/0377-2217(92)90077-M&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/0377-2217(92)90077-M&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In the latter, the authors wrote:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The proposed bound is compared with traditional Lagrangean relaxations and it is concluded (based on a rather small set of 10 test problems with 4 agents and 25 jobs) that it is stronger than the one obtained by relaxing either constraints (3) or (2) in the original problem formulation (GAP).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So, its not very convincing. And considering that to the best of my knowledge, it has not appeared again later, I would conclude that it has not been particularly useful afterwards.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-04-18T12:19:09.663" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8263" PostTypeId="1" CreationDate="2022-04-18T12:59:09.633" Score="1" ViewCount="130" Body="&lt;p&gt;My main problem is that, when I try to solve an optimization using Gurobi with the OpenSolver add-in, I get the error that there is no feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;To summarize, my variable &lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt; has a maximum value &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; and it is a storage filling problem.&lt;/p&gt;&#xA;&lt;p&gt;The objetive function is to minimize the cost of filling:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Min \sum_{i=0}^n X_i*C_i $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With certain constrains that indicates  what are the maximun and minimum levels in certain dates.&#xA;&lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt; can be:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\le 0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\ge 0$&lt;/span&gt;, if it is lower than 0 you are selling your material, if it is higher than 0 you are injecting, so, you can buy and sell in order to minimize the cost.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; must be the minimum between a constant and a function that depends on the sum up to &lt;span class=&quot;math-container&quot;&gt;$X_i-1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$H = \text{min}\{\text{Constant}, f(V_i-1)\}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V_i-1= \text{Filling of day} D-1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;When I put the constraints separately (TEST):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_i \le Constant$&lt;/span&gt; --&amp;gt; OK, I get a solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_i \le f(V_i-1)$&lt;/span&gt; --&amp;gt; OK, I get a solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_i \le \text{Constant1}$&lt;/span&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$X_i \le Constant2$&lt;/span&gt; --&amp;gt; OK, I get a solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;BUT: When I put my real problem:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_i \le Constant1$&lt;/span&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$X_i \le f(V_i-1)$&lt;/span&gt; --&amp;gt; &lt;strong&gt;NOT OK, it doesn't give me a solution.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="9570" LastEditorUserId="9570" LastEditDate="2022-04-19T07:58:54.147" LastActivityDate="2022-04-19T07:58:54.147" Title="How to solve this problem with Gurobi add-in Opensolver excel" Tags="|optimization|linear-programming|solver|gurobi|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8264" PostTypeId="2" ParentId="8248" CreationDate="2022-04-18T15:36:19.017" Score="3" Body="&lt;p&gt;However you measure it, you'll find that the C++ is faster, but almost certainly by a linear, or sub-linear, factor.&lt;/p&gt;&#xA;&lt;p&gt;So if something takes two or three times as long to solve, does it really matter?&lt;br /&gt;&#xA;Especially when CPUs continue to be faster and cheaper each year.&lt;/p&gt;&#xA;&lt;p&gt;I'd be more concerned about the efficiency of the algorithm itself, where cutting something down from n³ to n² will more than make up for any inefficiencies of the specific language.&lt;/p&gt;&#xA;&lt;p&gt;Well-written, simple, and obvious code:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Provides confidence that it is correct.&lt;/li&gt;&#xA;&lt;li&gt;Greatly reduces the human time required for coding, debugging, maintenance, and future modification.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3482" LastActivityDate="2022-04-18T15:36:19.017" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8265" PostTypeId="1" AcceptedAnswerId="8266" CreationDate="2022-04-18T18:23:03.380" Score="2" ViewCount="579" Body="&lt;p&gt;We have a directed graph &lt;span class=&quot;math-container&quot;&gt;$G=(N,A)$&lt;/span&gt;  where &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; are the verticies &lt;span class=&quot;math-container&quot;&gt;$N=0,1,2,3,4,5,..,n$&lt;/span&gt; the starting location is node 0.&#xA;For each arc &lt;span class=&quot;math-container&quot;&gt;$a=i-j$&lt;/span&gt; in A we have a distance &lt;span class=&quot;math-container&quot;&gt;$d_a&amp;gt;0$&lt;/span&gt;&#xA;So we want to start and end at 0 in a cycle.&lt;/p&gt;&#xA;&lt;p&gt;Model the TSP as a shortest path problem. Create a modified directed graph.&lt;/p&gt;&#xA;&lt;p&gt;I am not sure how to do this. The only thing I can think of is start from 0 find the shortest path which has all the node say to &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and then do &lt;span class=&quot;math-container&quot;&gt;$u-0$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9483" LastEditorUserId="500" LastEditDate="2022-04-18T20:57:39.730" LastActivityDate="2022-04-19T03:28:21.983" Title="Model the TSP as a shortest path" Tags="|modeling|network-flow|traveling-salesman|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8266" PostTypeId="2" ParentId="8265" CreationDate="2022-04-18T20:55:02.083" Score="6" Body="&lt;p&gt;One approach is to create a node &lt;span class=&quot;math-container&quot;&gt;$(S,u)$&lt;/span&gt; for each subset &lt;span class=&quot;math-container&quot;&gt;$S\subseteq N$&lt;/span&gt; and last-visited city &lt;span class=&quot;math-container&quot;&gt;$u\in N$&lt;/span&gt;.  The main arcs are from &lt;span class=&quot;math-container&quot;&gt;$(S,u)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$(S\cup\{v\},v)$&lt;/span&gt;, with cost &lt;span class=&quot;math-container&quot;&gt;$d_{u,v}$&lt;/span&gt;.  You also need an arc from each &lt;span class=&quot;math-container&quot;&gt;$(N,u)$&lt;/span&gt; to a dummy sink node, with cost &lt;span class=&quot;math-container&quot;&gt;$d_{u,0}$&lt;/span&gt;.  The problem is to find a shortest path from source &lt;span class=&quot;math-container&quot;&gt;$(\{0\},0)$&lt;/span&gt; to sink.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-04-19T03:28:21.983" LastActivityDate="2022-04-19T03:28:21.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8267" PostTypeId="2" ParentId="8261" CreationDate="2022-04-18T21:25:57.933" Score="4" Body="&lt;p&gt;I am familiar with variable splitting (also known as &lt;em&gt;Lagrangian decomposition&lt;/em&gt;) being applied to facility location problems. We used it in our paper:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Snyder and Daskin, Stochastic &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;-robust location problems, &lt;em&gt;IIE Transactions&lt;/em&gt; 38, 971-985, 2006. &lt;a href=&quot;https://www.tandfonline.com/doi/abs/10.1080/07408170500469113&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.tandfonline.com/doi/abs/10.1080/07408170500469113&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;It is also used by&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Barcelo, et al., Computational results from a new Lagrangean relaxation algorithm for the capacitated plant location problem, &lt;em&gt;EJOR&lt;/em&gt; 53, 38-45, 1991. &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/0377221791900919&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sciencedirect.com/science/article/abs/pii/0377221791900919&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;One advantage of variable splitting is that its bound is provably at least as tight as the bound from &amp;quot;regular&amp;quot; Lagrangian relaxation, and is strictly better if neither subproblem has the integrality property (see Guignard and Kim, Lagrangean decomposition: a model&#xA;yielding strong Lagrangean bounds, &lt;em&gt;Mathematical Programming&lt;/em&gt;&#xA;39, 215–228, 1987).&lt;/p&gt;&#xA;&lt;p&gt;Sometimes it also yields subproblems that are easier to solve than regular LR does. In our paper it yields subproblems that are separable (and therefore easy to solve) whereas the more straightforward LR approach yields a non-separable subproblem.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2022-04-18T21:25:57.933" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8268" PostTypeId="1" AcceptedAnswerId="8269" CreationDate="2022-04-19T18:11:32.517" Score="5" ViewCount="230" Body="&lt;p&gt;Step 4a of the &lt;a href=&quot;https://www.cs.princeton.edu/%7Ebwk/btl.mirror/tsp.pdf&quot; rel=&quot;noreferrer&quot;&gt;original paper&lt;/a&gt;  describing the Lin-Kernighan TSP algorithm states that the choice of edge &lt;span class=&quot;math-container&quot;&gt;$x_i = (t_{2i}, t_{2i+1})$&lt;/span&gt; to be deleted is uniquely determined by the choice of edge &lt;span class=&quot;math-container&quot;&gt;$y_{i-1} = (t_{2i-1}, t_{2i})$&lt;/span&gt; previously added.&#xA;&lt;a href=&quot;http://webhotel4.ruc.dk/%7Ekeld/research/LKH/LKH-2.0/DOC/LKH_REPORT.pdf&quot; rel=&quot;noreferrer&quot;&gt;Helsgaun&lt;/a&gt; elaborates on this by saying:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;... only one&#xA;of these makes it possible to ‘close’ the tour (by the addition of &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;). The other&#xA;choice results in two disconnected subtours&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Can somebody explain why this is the case, &lt;strong&gt;and how to tell&lt;/strong&gt; which choice of &lt;span class=&quot;math-container&quot;&gt;$x_i / t_{2i}$&lt;/span&gt; given some &lt;span class=&quot;math-container&quot;&gt;$y_{2i-1}$&lt;/span&gt; is correct?&lt;/p&gt;&#xA;&lt;p&gt;I have an idea (that I'm not sure is correct) of a way to test if a tour contains disconnected subtours*, but doing so would force you to build a tour &lt;span class=&quot;math-container&quot;&gt;$T'$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$T, X, Y$&lt;/span&gt; at every step of a k-opt move, which is inefficient.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;*if &lt;code&gt;tour&lt;/code&gt; is a list of cities containing a disconnected subtour then some city must be visited twice, so you could do something like &lt;code&gt;len(set(tour)) == len(tour)&lt;/code&gt; in python&lt;/p&gt;&#xA;" OwnerUserId="9579" LastEditorUserId="9579" LastEditDate="2022-04-19T18:18:46.747" LastActivityDate="2022-04-24T14:01:05.510" Title="Lin-Kernighan TSP edge choice" Tags="|optimization|combinatorial-optimization|traveling-salesman|heuristics|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8269" PostTypeId="2" ParentId="8268" CreationDate="2022-04-19T19:47:48.097" Score="4" Body="&lt;p&gt;It might help to refer to Figure 3(a) in the Lin-Kernigan paper. Assume that you started out with the tour oriented so that the nodes were visited in the order &lt;span class=&quot;math-container&quot;&gt;$$t_1 \rightarrow t_2 \rightarrow \dots \rightarrow t_4 \rightarrow t_3 \rightarrow \hat{t} \dots -\rightarrow t_1,$$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$\hat{t}$&lt;/span&gt; is the unlabeled endpoint of the &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; edge opposite &lt;span class=&quot;math-container&quot;&gt;$t_4.$&lt;/span&gt; You choice of &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; put the focus on node &lt;span class=&quot;math-container&quot;&gt;$t_3,$&lt;/span&gt; forcing you to choose for deletion one of the two edges (&lt;span class=&quot;math-container&quot;&gt;$(t_3, t_4)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$(t_3, \hat{t})$&lt;/span&gt;) incident to &lt;span class=&quot;math-container&quot;&gt;$t_3$&lt;/span&gt; and present in the original tour. The key is that &lt;span class=&quot;math-container&quot;&gt;$t_4$&lt;/span&gt; occurs between &lt;span class=&quot;math-container&quot;&gt;$t_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_3$&lt;/span&gt; in the original tour, and &lt;span class=&quot;math-container&quot;&gt;$\hat{t}$&lt;/span&gt; does not. You are going to add the edge &lt;span class=&quot;math-container&quot;&gt;$y_1 = (t_2,t_4)$&lt;/span&gt; to the tour. If you leave &lt;span class=&quot;math-container&quot;&gt;$(t_3,t_4)$&lt;/span&gt; in the tour while adding &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;, you end up with a subtour &lt;span class=&quot;math-container&quot;&gt;$$t_2\rightarrow \dots \rightarrow t_4 \rightarrow t_3 \rightarrow t_2$$&lt;/span&gt; (the last arc courtesy of &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;More generally, if you delete an arc &lt;span class=&quot;math-container&quot;&gt;$t_i \rightarrow t_j$&lt;/span&gt; and add an arc &lt;span class=&quot;math-container&quot;&gt;$t_j \rightarrow t_k$&lt;/span&gt;, then the arc incident at &lt;span class=&quot;math-container&quot;&gt;$t_k$&lt;/span&gt; that you delete is the one whose other endpoint was between &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_k$&lt;/span&gt; before the changes when the tour is oriented &lt;span class=&quot;math-container&quot;&gt;$t_i \rightarrow t_j \rightarrow \dots \rightarrow t_k \rightarrow \dots \rightarrow t_i.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-19T19:47:48.097" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8271" PostTypeId="1" CreationDate="2022-04-20T04:54:50.157" Score="6" ViewCount="84" Body="&lt;p&gt;My engineering problem can be formulated as an LP as shown below&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_{\mathbf{x}}~~&amp;amp;\mathbf{a}^T\mathbf{x} \\&#xA;\mbox{s.t.}~~~&amp;amp;\mathbf{b}^T\mathbf{x} \leq B~~,~~\mathbf{1}^T\mathbf{x}\leq 1~~,~~\mathbf{x}\geq 0&#xA;\end{align}&lt;/span&gt;&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{a}\geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b} \geq 0$&lt;/span&gt;. Physically, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{a}^T\mathbf{x}$&lt;/span&gt; corresponds to the profit we make and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}^T\mathbf{x}$&lt;/span&gt; is the cost we incur and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is the budget available to us. Second constraint corresponds to the fact that elements &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}$&lt;/span&gt; should sum to 1. Third constraint corresponds to element-wise positivity. Due to unavoidable process errors, values of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{a}$&lt;/span&gt; is often erroneous due to inherent noise in our system. Thus, the profit predicted by the above problem may not realize (but spend will). For example, let's say we solve above optimization problem with the given &lt;span class=&quot;math-container&quot;&gt;$\mathbf{a}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}$&lt;/span&gt; and then deploy the &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}$&lt;/span&gt; in production. Then, its a common occurrence wherein we realized only 90% of the objective (profit) expected offline for the same cost. In fact, consider that we had solved the problem show below to get &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_2^*$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_{\mathbf{x}}~~&amp;amp;\mathbf{a}^T\mathbf{x} \\&#xA;\mbox{s.t.}~~~&amp;amp;\mathbf{b}^T\mathbf{x} \leq B~~,~~\mathbf{1}^T\mathbf{x}\leq &#xA;1~~,~~\mathbf{x}\geq 0 \\&#xA;&amp;amp;\mathbf{a}^T\mathbf{x} \leq 0.9*\mathbf{a}^T\mathbf{x}_1^*&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_1^*$&lt;/span&gt; is the solution from the original problem. Then, we have seen often that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_2^*$&lt;/span&gt; can be a much better solution in terms of the cost incurred. In particular, we want to avoid scenarios where the gain in profit is very marginal (say 10%) compared to the increase in cost (say 100%). What are the standard approaches in such scenarios?. Say I can assume that the errors in &lt;span class=&quot;math-container&quot;&gt;$\mathbf{a}_i$&lt;/span&gt; are uniformly distributed within a 10% interval.&lt;/p&gt;&#xA;" OwnerUserId="3024" LastActivityDate="2022-04-20T04:54:50.157" Title="Robust Linear Optimization for avoiding diminishing returns" Tags="|linear-programming|robust-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8272" PostTypeId="1" AcceptedAnswerId="8273" CreationDate="2022-04-20T07:29:52.283" Score="-1" ViewCount="198" Body="&lt;p&gt;I'm trying to solve an OR problem written using pulp framework , with gurobi, in Linux , but I'm not able to solve it . In windows,I use this command to use gurobi ,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if solver == gurobi :&#xA;&#xA; path = 'gurobi.exe'&#xA;&#xA; solver = pulp.GUROBI_CMD(path=path, msg=1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However in Linux there is no .exe file , how do I approach this?&lt;/p&gt;&#xA;" OwnerUserId="2958" LastActivityDate="2022-04-20T08:34:07.817" Title="I'm trying to solve an OR problem written using pulp framework , with gurobi, in Linux , but I'm not able to solve it" Tags="|gurobi|pulp|windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8273" PostTypeId="2" ParentId="8272" CreationDate="2022-04-20T08:34:07.817" Score="5" Body="&lt;p&gt;The &lt;code&gt;path&lt;/code&gt; in Linux has to point to the &lt;code&gt;gurobi_cl&lt;/code&gt; binary, which is located in the &lt;code&gt;bin&lt;/code&gt; folder. Therefore, you should try&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;path = r'&amp;lt;path-to-gurobi&amp;gt;/bin/gurobi_cl'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="133" LastActivityDate="2022-04-20T08:34:07.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8274" PostTypeId="1" CreationDate="2022-04-20T15:38:26.070" Score="4" ViewCount="67" Body="&lt;p&gt;In the paper &amp;quot;Some NP-complete problems in linear programming&amp;quot; (&lt;a href=&quot;https://doi.org/10.1016/0167-6377(82)90006-2&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/0167-6377(82)90006-2&lt;/a&gt;), there are several proofs given to show that testing for degeneracy in LPs is NP-complete. I don't understand the proof in section 4. Are they saying that their reduction only produces binary y values? Or are they introducing a binary variable (and thus invalidating their proof)? The statement of &amp;quot;the standard trick...&amp;quot; -- what is this trick? Does it have a name? Is someone able to write out this &amp;quot;combined system (5)&amp;quot; for me? What does it look like?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UAjtM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UAjtM.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2022-04-20T15:38:26.070" Title="bilinear problem proof for NP-completeness of degeneracy check" Tags="|linear-programming|proofs|np-complete|degeneracy|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8275" PostTypeId="1" CreationDate="2022-04-21T07:49:39.700" Score="1" ViewCount="192" Body="&lt;p&gt;There are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; jobs and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; machines.&#xA;Assigning job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to machine &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; yields a profit of &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt;.&#xA;Each job has a type &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt;.&#xA;Machine &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; can take on up to &lt;span class=&quot;math-container&quot;&gt;$a_j$&lt;/span&gt; jobs, but the number of job types must not exceed &lt;span class=&quot;math-container&quot;&gt;$b_j$&lt;/span&gt;.&#xA;How should the jobs be assigned to the machines to maximize profit?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DoM6A.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DoM6A.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;For example, in this case, it is optimal to assign job 1 to machine 1 and jobs 2 and 3 to machine 2.&lt;/p&gt;&#xA;&lt;p&gt;This problem can be solved with an integer programming solver, but I would like to know of any algorithms or related papers that solve this problem.&lt;/p&gt;&#xA;" OwnerUserId="5966" LastEditorUserId="123" LastEditDate="2022-04-21T07:51:31.887" LastActivityDate="2022-04-22T06:24:48.687" Title="How to solve assignment problem with type constraints?" Tags="|constraint|algorithms|assignment-problem|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8276" PostTypeId="1" CreationDate="2022-04-21T09:36:13.073" Score="0" ViewCount="308" Body="&lt;p&gt;The problem I have made associated with OpenSolver and Gurobi takes about 50 minutes to solve, is this normal?&lt;/p&gt;&#xA;&lt;p&gt;It has approximately 365 variables with upper and lower bands, the peculiarity is that one of those upper bands is dependent on the decision variable. Anyway, is it normal that it takes so long? Would it go faster with other software?&lt;/p&gt;&#xA;&lt;p&gt;The result it gives is correct in spite of the time it takes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SHtci.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SHtci.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9570" LastEditorUserId="491" LastEditDate="2022-04-23T12:00:11.887" LastActivityDate="2022-04-24T06:22:17.047" Title="It takes a long time to solve excel gurobi-opensolver - is this normal?" Tags="|solver|gurobi|excel|runtime|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="8277" PostTypeId="1" AcceptedAnswerId="8279" CreationDate="2022-04-21T13:46:12.817" Score="11" ViewCount="1580" Body="&lt;p&gt;I am trying to understand the motivation behind the Dual Simplex Method. However, I have run into some roadblocks while understanding the rationale behind the Dual Simplex Method. This is my current understanding of the Simplex, Primal and Dual problem:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. For a minimization problem, the Simplex Algorithm proceeds with first a basic feasible solution; then it replaces individual basis columns with an external column until &lt;span class=&quot;math-container&quot;&gt;$c_j - C_B B^{-1} A_j &amp;gt;0~\forall~j$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$jth$&lt;/span&gt; cost tuple ; &lt;span class=&quot;math-container&quot;&gt;$C_B$&lt;/span&gt; is the cost corresponding to the feasible basis &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_j$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$jth$&lt;/span&gt; column external to &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; be the primal feasible solution and &lt;span class=&quot;math-container&quot;&gt;$y_0$&lt;/span&gt; be the dual feasible solution and both satisfy the complementary slackness conditions, then &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; is the primal optimal solution and &lt;span class=&quot;math-container&quot;&gt;$y_0$&lt;/span&gt; is the dual optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$c^T x_0 = b^T y_0$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is the feasible basis, then &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; is the primal optimal solution and &lt;span class=&quot;math-container&quot;&gt;$y_0$&lt;/span&gt; forms the dual optimal solution.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Using this, my professor has tried to implement the Dual Simplex Algorithm by first accounting for a tuple of the RHS &lt;span class=&quot;math-container&quot;&gt;$:b_r &amp;lt; 0$&lt;/span&gt; and then proceeding ahead.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;However, I do not quite understand the need to consider &lt;span class=&quot;math-container&quot;&gt;$b_r &amp;lt; 0$&lt;/span&gt; nor the algorithm ahead. Could someone help me build the dual simplex algorithm from here?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="2641" LastEditorUserId="2641" LastEditDate="2022-04-21T16:10:33.093" LastActivityDate="2022-04-21T16:10:33.093" Title="Linear Programming - Motivation behind the Dual Simplex Method" Tags="|dual-simplex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8278" PostTypeId="1" CreationDate="2022-04-21T14:02:18.643" Score="6" ViewCount="146" Body="&lt;p&gt;I have a MILP feasibility problem, so the objective function is constant (0). I have read that strong branching scores measure changes in the objective value. So my question is, what would be the strong branching scores in my case?&lt;/p&gt;&#xA;" OwnerUserId="9588" LastActivityDate="2022-04-21T15:36:57.977" Title="Strong branching scores when objective function is constant" Tags="|mixed-integer-programming|branch-and-bound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8279" PostTypeId="2" ParentId="8277" CreationDate="2022-04-21T14:20:12.567" Score="17" Body="&lt;p&gt;The primal simplex starts with a feasible basis, and finds &amp;quot;a better one&amp;quot; while keeping feasibility. On the other hand, the dual simplex starts with an optimal basis (typically infeasible), and finds a feasible one while keeping optimality.&lt;/p&gt;&#xA;&lt;p&gt;In algebraic terms, the primal simplex maintains the RHS feasible, and iterates until the reduced cost is non negative (if minimization), while the dual maintains the reduced cost non negative (if minimization), and iterates until the RHS is positive.&lt;/p&gt;&#xA;&lt;p&gt;In the figure below, the primal simplex iterations are the full arrows, the dual simplex iterations are the dotted arrows. The green dots are the feasible bases, the orange ones are the infeasible bases. The yellow arrow represents the gradient of the objective function (the best direction). You can see the the primal steps remains within the polygon, while the dual steps starts outside of the polygon.&lt;/p&gt;&#xA;&lt;p&gt;The benefit of using the dual is that sometimes, it is easier to &amp;quot;fix&amp;quot; an infeasible solution close to optimality, as in the figure below, only one step is required.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hZrnv.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hZrnv.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="123" LastEditDate="2022-04-21T15:18:46.673" LastActivityDate="2022-04-21T15:18:46.673" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8280" PostTypeId="2" ParentId="8278" CreationDate="2022-04-21T15:36:57.977" Score="4" Body="&lt;p&gt;If branching on a variable leads to an infeasible subproblem, then you can either immediately branch on this variable, or change its domain in the current node.&lt;/p&gt;&#xA;&lt;p&gt;Otherwise, strong branching won't be useful in this case.&lt;/p&gt;&#xA;&lt;p&gt;A excerpt from &amp;quot;Hybrid Branching&amp;quot; (Achterberg et Berthold, 2009) &lt;a href=&quot;https://doi.org/10.1007/978-3-642-01929-6_23&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In CSP and SAT, where no objective function is available, one may better estimate the impact of a branching by taking the number of implied reductions of other variable domains into account [4]. In analogy to the pseudocosts, we call the estimated numbers of implied reductions the inference values of a variable.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-04-21T15:36:57.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8281" PostTypeId="1" AcceptedAnswerId="8282" CreationDate="2022-04-21T16:10:52.340" Score="1" ViewCount="281" Body="&lt;p&gt;I am trying to solve a graph partitioning problem for a large number of structurally similar random graphs with an 0-1 LP.&lt;/p&gt;&#xA;&lt;p&gt;Most of these problems are solved within 0.x seconds. Some graphs take the complete offered time slice of 40 min and abort. The solution is mostly seemingly optimal. Therefore I guess that the problem is not to find the optimal solution but to proof its optimality.&lt;/p&gt;&#xA;&lt;p&gt;but I am not sure about feasible values. (I am no expert in linear optimisation.)&#xA;I've tried 1% and 0.5% but the problem remained. I also experimented with MIPFocus, but since I am able to assume, based on the results I receive when the problem aborts that the solution is optimal or almost optimal I would prefer to stop the optimisation before the time limit hits. Furthermore, I would like to ensure that the optimal solutions that are solved within this small amount of times are still solved with optimal solutions while the MIPGap only applies to those slow problems.&lt;/p&gt;&#xA;&lt;p&gt;How do I determine a suitable MIPGap for my problem?&lt;/p&gt;&#xA;&lt;p&gt;(What I can't do and don't have are assumptions towards the precise reason and the properties of the graphs that cause to hit the time limit.)&lt;/p&gt;&#xA;" OwnerUserId="2989" LastEditorUserId="2989" LastEditDate="2022-04-21T16:28:09.890" LastActivityDate="2022-04-21T18:29:02.510" Title="Solving Graph Partitioning Problems with Gurobi and Pyomo" Tags="|linear-programming|gurobi|pyomo|graphs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8282" PostTypeId="2" ParentId="8281" CreationDate="2022-04-21T18:23:26.570" Score="3" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;I would like to ensure that the optimal solutions that are solved within this small amount of times are still solved with optimal solutions while the MIPGap only applies to those slow problems.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I assume you want to solve a batch of problem with the same parameter settings, e.g. TimeLimits and MIPGap.&lt;/p&gt;&#xA;&lt;p&gt;You can use the callback function. Each time an integer feasible solution is found, check whether the runtime is too long (e.g. 3600 s), if no, do nothing; else check whether the MIP gap is small enough to determine whether terminate.&lt;/p&gt;&#xA;&lt;p&gt;Pyomo callback document:&#xA;&lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/library_reference/solvers/gurobi_persistent.html#pyomo.solvers.plugins.solvers.gurobi_persistent.GurobiPersistent.set_callback&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pyomo.readthedocs.io/en/stable/library_reference/solvers/gurobi_persistent.html#pyomo.solvers.plugins.solvers.gurobi_persistent.GurobiPersistent.set_callback&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Gurobi callback document:&#xA;&lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_cb_s.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.5/refman/py_cb_s.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8718" LastEditorUserId="8718" LastEditDate="2022-04-21T18:29:02.510" LastActivityDate="2022-04-21T18:29:02.510" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8283" PostTypeId="2" ParentId="8275" CreationDate="2022-04-22T04:03:21.370" Score="1" Body="&lt;p&gt;I think your problem looks like a Multi-resource Generalized Assignment Problem. Here are two papers that describe it:&#xA;&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/mnsc.37.6.695&quot; rel=&quot;nofollow noreferrer&quot;&gt;Garvish and Pirkul (1991)&lt;/a&gt; and &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1002/nav.1029&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mazzola and Wilcox (2001)&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The amount of jobs &lt;span class=&quot;math-container&quot;&gt;$a_j$&lt;/span&gt; that can be performed by a machine can be seen as available resource. And the amount of job types &lt;span class=&quot;math-container&quot;&gt;$b_j$&lt;/span&gt; can also be seen as available resource. A job might consume both.&lt;/p&gt;&#xA;&lt;p&gt;Adapting to their notation, you would have two resources, &lt;span class=&quot;math-container&quot;&gt;$|K|=2$&lt;/span&gt;. Then, machine &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; consumes &lt;span class=&quot;math-container&quot;&gt;$a_{ijk}$&lt;/span&gt; of resource &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; when performing job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and has &lt;span class=&quot;math-container&quot;&gt;$b_{jk}$&lt;/span&gt; of resource &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; available.&lt;/p&gt;&#xA;" OwnerUserId="2741" LastActivityDate="2022-04-22T04:03:21.370" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8284" PostTypeId="2" ParentId="8275" CreationDate="2022-04-22T06:24:48.687" Score="2" Body="&lt;p&gt;Some articles dealing with constraints limiting the number of job types assigned to a given machine can be found with the keywords &amp;quot;class constrained&amp;quot; or &amp;quot;color constraints&amp;quot;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;quot;The multiple knapsack problem with color constraints&amp;quot; (Dawande et Kalagnanam, 1998) &lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.22.9533&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;PDF&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;On Two Class-Constrained Versions of the Multiple Knapsack Problem&amp;quot; (Shachnai et Tamir, 2001) &lt;a href=&quot;https://doi.org/10.1007/s004530010057&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;A Column-Generation Approach to the Multiple Knapsack Problem with Color Constraints&amp;quot; (Forrest et al., 2006) &lt;a href=&quot;https://doi.org/10.1287/ijoc.1040.0078&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt; (only two types on each machine)&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;The class constrained bin packing problem with applications to video-on-demand&amp;quot; (Xavier et Miyazawa, 2008) &lt;a href=&quot;https://doi.org/10.1016/j.tcs.2008.01.001&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;Class constrained bin packing revisited&amp;quot; (Epstein et al., 2010) &lt;a href=&quot;https://doi.org/10.1016/j.tcs.2010.04.037&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;A special case of Variable-Sized Bin Packing Problem with Color Constraints&amp;quot; (Crévits et al., 2019) &lt;a href=&quot;https://doi.org/10.1109/CoDIT.2019.8820707&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt; (only two types on each machine)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I'm not aware of any article studying the exact same problem as the one you describe.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-04-22T06:24:48.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8285" PostTypeId="1" AcceptedAnswerId="8286" CreationDate="2022-04-22T07:02:29.263" Score="3" ViewCount="659" Body="&lt;p&gt;there is an inbuilt preprocessing in CBC solver , which affects the optimality of my solution , I get the optimal output by turning this off in command prompt . How do I turn this off using pulp ?&lt;/p&gt;&#xA;" OwnerUserId="2958" LastActivityDate="2022-04-22T10:29:18.167" Title="How do I turn off preprocessing in pulp?" Tags="|mixed-integer-programming|pulp|cbc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8286" PostTypeId="2" ParentId="8285" CreationDate="2022-04-22T10:29:18.167" Score="6" Body="&lt;p&gt;You can use &lt;strong&gt;presolve&lt;/strong&gt; parameter and can pass it to solver(CBC) using following statement (model is your problem object)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.solve(pulp.PULP_CBC_CMD(presolve=False))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2022-04-22T10:29:18.167" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8288" PostTypeId="1" AcceptedAnswerId="8289" CreationDate="2022-04-22T15:54:49.500" Score="5" ViewCount="871" Body="&lt;p&gt;I have an initial solution to a CVRP instance which I am setting as input to the solver. The solver as expected returns an improved solution. I have a few questions regarding the solver.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;How does the solver improve upon the solution when I am not using any particular metaheuristic?. Does it use a mixture of meta-heuristics or just automatically select one?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This particular one is very baffling to me. When I set multiple metaheuristics (Tabu, SA, etc.) and even the time limits, the solver always returns the same solution for every one of them, and that too instantly. The solutions returned in the first case and this one is the same for every instance. Is this expected behavior?&lt;/p&gt;&#xA;&lt;p&gt;It seems that the metaheuristics and the time limits have no effect&#xA;on the solver. The solver seems to converge on some particular solution very quickly and stops there.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Relevant Code :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const Assignment* initial_solution =&#xA;        routing.ReadAssignmentFromRoutes(data.initial_routes, true);&#xA;&#xA;RoutingSearchParameters searchParameters = DefaultRoutingSearchParameters();&#xA;&#xA;// Uncommenting the following has no effect on the final solution&#xA;&#xA;/*&#xA;searchParameters.set_local_search_metaheuristic(&#xA;        LocalSearchMetaheuristic::TABU_SEARCH);&#xA;    searchParameters.mutable_time_limit()-&amp;gt;set_seconds(30);&#xA;*/&#xA;&#xA;const Assignment* solution = routing.SolveFromAssignmentWithParameters(&#xA;        initial_solution, searchParameters);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Edit :&#xA;Thanks to @Pedrinho's answer, this is how the problem should be tackled.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;RoutingSearchParameters searchParameters = DefaultRoutingSearchParameters();&#xA;&#xA;searchParameters.set_local_search_metaheuristic(&#xA;        LocalSearchMetaheuristic::TABU_SEARCH);&#xA;    searchParameters.mutable_time_limit()-&amp;gt;set_seconds(30);&#xA;&#xA;routing.CloseModelWithParameters(searchParameters);&#xA;&#xA;const Assignment* initial_solution =&#xA;        routing.ReadAssignmentFromRoutes(data.initial_routes, true);&#xA;&#xA;const Assignment* solution = routing.SolveFromAssignmentWithParameters(&#xA;        initial_solution, searchParameters);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7320" LastEditorUserId="7320" LastEditDate="2022-04-24T08:20:28.557" LastActivityDate="2022-04-24T08:20:28.557" Title="How does OR-Tools improve on an initial solution to CVRP?" Tags="|vehicle-routing|or-tools|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8289" PostTypeId="2" ParentId="8288" CreationDate="2022-04-23T18:36:48.270" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I believe the default is a greedy descent which would be in line with your observations of very fast convergence. In general, the heuristics are a combination of local search and constraint programming. You might find more information&#xA;&lt;a href=&quot;https://stackoverflow.com/a/57843273/9333142&quot;&gt;here&lt;/a&gt; and&#xA;&lt;a href=&quot;https://github.com/google/or-tools/issues/920&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you provide an initial solution, you first need to close your&#xA;model before solving. See a similar&#xA;question&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/67210102/or-tools-c-vrp-solving-from-assignment-with-parameters-problem&quot;&gt;here&lt;/a&gt;&#xA;and a github issue&#xA;&lt;a href=&quot;https://github.com/google/or-tools/issues/1841&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;routing.CloseModelWithParameters(searchParameters);&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2022-04-23T18:36:48.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8290" PostTypeId="1" AcceptedAnswerId="8293" CreationDate="2022-04-23T19:53:40.557" Score="6" ViewCount="494" Body="&lt;p&gt;Assume that I have data about a regular big company (not a salesman problem). data contains of every department's (marketing, finance, production, etc.) vehicle size, GPS track values, duration of using vehicles, etc.&lt;/p&gt;&#xA;&lt;p&gt;I want to optimize the fleet management.&lt;/p&gt;&#xA;&lt;p&gt;First option: there will be a (one or more) vehicle pool, and every department will make a car reservation from the pool when they need it.&lt;/p&gt;&#xA;&lt;p&gt;Second option: allocate certain number of cars to every department based on the data&lt;/p&gt;&#xA;&lt;p&gt;Third option: mix of first and second.&lt;/p&gt;&#xA;&lt;p&gt;Is there any model for optimization? I'm sure the problem isn't clear enough and it's hard to say for sure without seeing the data. But I need a starting point. Also, I will be glad if there is a paper about this kind of problem.&lt;/p&gt;&#xA;" OwnerUserId="9601" LastEditorUserId="36" LastEditDate="2022-04-23T21:38:00.670" LastActivityDate="2022-04-24T08:36:06.847" Title="Fleet Management: How to allocate vehicles between departments" Tags="|optimization|reference-request|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8291" PostTypeId="1" CreationDate="2022-04-23T20:37:26.927" Score="3" ViewCount="312" Body="&lt;p&gt;I have a problem formulation with binary variables &lt;code&gt;x1&lt;/code&gt;,&lt;code&gt;x2&lt;/code&gt;,&lt;code&gt;x3&lt;/code&gt;,&lt;code&gt;x4&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I want another binary variable &lt;code&gt;y&lt;/code&gt; to be required to equal 1 under the following circumstances:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;y=1&lt;/code&gt; when &lt;code&gt;x1 + x2 = 2&lt;/code&gt; or &lt;code&gt;x3 + x4 = 2&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The overall problem formulation generally penalizes &lt;code&gt;y=1&lt;/code&gt; so I'm OK with methods that allow &lt;code&gt;y=1&lt;/code&gt; under other circumstances, but ideally &lt;code&gt;y=1&lt;/code&gt; iff &lt;code&gt;x1 + x2 = 2&lt;/code&gt; or &lt;code&gt;x3 + x4 = 2&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="3958" LastEditorUserId="3958" LastEditDate="2022-04-23T20:42:27.977" LastActivityDate="2022-04-24T00:25:18.023" Title="Activate Binary if specific pairs of binaries equal 2" Tags="|mixed-integer-programming|integer-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8292" PostTypeId="2" ParentId="8291" CreationDate="2022-04-23T21:32:39.813" Score="7" Body="&lt;p&gt;You want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$((x_1 \land x_2) \lor (x_3 \land x_4)) \implies y.$$&lt;/span&gt;&#xA;Rewriting in conjunctive normal form yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(\lnot x_1 \lor \lnot x_2 \lor y) \land (\lnot x_3 \lor \lnot x_4 \lor y),$$&lt;/span&gt;&#xA;which immediately yields linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(1 - x_1) + (1 - x_2) + y &amp;amp;\ge 1\\&#xA;(1 - x_3) + (1 - x_4) + y &amp;amp;\ge 1&#xA;\end{align}&lt;/span&gt;&#xA;Equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y&amp;amp;\ge x_1+x_2-1\\&#xA;y&amp;amp;\ge x_3+x_4-1&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The converse implication is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y \implies ((x_1 \land x_2) \lor (x_3 \land x_4)).$$&lt;/span&gt;&#xA;Rewriting in conjunctive normal form yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(\lnot y \lor x_1 \lor x_3) \land (\lnot y \lor x_1 \lor x_4) \land (\lnot y \lor x_2 \lor x_3) \land (\lnot y \lor x_2 \lor x_4),$$&lt;/span&gt;&#xA;which immediately yields linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(1 - y) + x_1 + x_3 &amp;amp;\ge 1\\&#xA;(1 - y) + x_1 + x_4 &amp;amp;\ge 1\\&#xA;(1 - y) + x_2 + x_3 &amp;amp;\ge 1\\&#xA;(1 - y) + x_2 + x_4 &amp;amp;\ge 1&#xA;\end{align}&lt;/span&gt;&#xA;Equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y&amp;amp;\le x_1+x_3 \\&#xA;y&amp;amp;\le x_1+x_4 \\&#xA;y&amp;amp;\le x_2+x_3 \\&#xA;y&amp;amp;\le x_2+x_4&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-04-23T21:43:37.100" LastActivityDate="2022-04-23T21:43:37.100" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8293" PostTypeId="2" ParentId="8290" CreationDate="2022-04-23T21:34:45.493" Score="6" Body="&lt;p&gt;If the use of vehicles by departments is deterministic (which I find &lt;em&gt;very&lt;/em&gt; unlikely), then scenarios 2 and 3 can be approached as integer programming models. You might be able to do that with random vehicle usage by plugging in averages, but I would be suspicious of the results. There are also scenario-based approaches to stochastic optimization.&lt;/p&gt;&#xA;&lt;p&gt;If the data is robust enough to allow you to estimate probability distributions for things like time between vehicle requests for each department, you could try building a discrete event simulation. Once you had validated that under the current vehicle rules (whatever they are) the output resembled the historical data adequately, you could try running various scenarios (single pool, allocate this many cars to each department, allocate a different fixed number of cars to each department, allocate some cars and keep the rest in a pool) and let the simulation results guide you to an &amp;quot;optimal&amp;quot; policy. This can be done just by doing a lot of runs and comparing their results, but there are more scientific ways to do it.&lt;/p&gt;&#xA;&lt;p&gt;Under any approach, you will need to answer some additional questions, including what happens if a department requests a vehicle when none is available (do they wait and, if so, for how long) and, importantly, what you criterion for a &amp;quot;good&amp;quot; result is (your objective function).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-23T21:34:45.493" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8294" PostTypeId="2" ParentId="8291" CreationDate="2022-04-23T21:41:46.563" Score="4" Body="&lt;p&gt;Rob's answer covers the &amp;quot;if&amp;quot; case. For the &amp;quot;only if&amp;quot; case, add two more binary variables &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_2$&lt;/span&gt; plus the constraints &lt;span class=&quot;math-container&quot;&gt;$$2z_1 \le x_1 + x_2$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$2x_2 \le x_3 + x_4$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$y \le z_1 + z_2.$$&lt;/span&gt;That plus Rob's two constraints gets you to &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt; if and only if either &lt;span class=&quot;math-container&quot;&gt;$x_1 + x_2=2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x_3 + x_4=2.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-04-24T00:25:18.023" LastActivityDate="2022-04-24T00:25:18.023" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8295" PostTypeId="2" ParentId="8276" CreationDate="2022-04-24T06:22:17.047" Score="4" Body="&lt;p&gt;This is not a Gurobi issue - the log shows that the instance is solved within a second. I can only assume that the model-building process takes up a lot of time. OpenSolver apparently creates an LP file that is then read by Gurobi, so it does not use the API directly which is already suboptimal in terms of overall performance. There may also be some expensive Excel lookups being performed when constructing the model.&lt;/p&gt;&#xA;&lt;p&gt;Please also consider that this model is very dense with about 240000 nonzeros for just 365 variables.&lt;/p&gt;&#xA;&lt;p&gt;Using Excel to generate models is generally not recommended. You will have a much better experience when importing these Excel sheets using the &lt;a href=&quot;https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_excel.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python pandas framework&lt;/a&gt;. Then, you can work on the data directly and use the Gurobi Python API directly without having to write a file first.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2022-04-24T06:22:17.047" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8296" PostTypeId="2" ParentId="8290" CreationDate="2022-04-24T08:29:36.037" Score="5" Body="&lt;p&gt;Based on what you described in the question, the problem you are facing is a variant of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Vehicle_routing_problem&quot; rel=&quot;noreferrer&quot;&gt;vehicle routing problem&lt;/a&gt;. If you have faced some uncertainty, as Prof. Rubin mentioned too, the simulation technique would be useful. Also, some of the references that might be close to your problem are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://developers.google.com/optimization/routing/vrp&quot; rel=&quot;noreferrer&quot;&gt;Vehicle Routing Problem by google or-tools&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.worldscientific.com/doi/epdf/10.1142/S0217595920500189&quot; rel=&quot;noreferrer&quot;&gt;A Decision Support System for Data-Driven Driver-Experience Augmented Vehicle Routing Problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://gurobi.github.io/modeling-examples/technician_routing_scheduling/technician_routing_scheduling.html&quot; rel=&quot;noreferrer&quot;&gt;Technician Routing and Scheduling Problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://coral.ie.lehigh.edu/%7Elarry/?page_id=206&quot; rel=&quot;noreferrer&quot;&gt;VRP Solver by Larry Snyder&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2022-04-24T08:36:06.847" LastActivityDate="2022-04-24T08:36:06.847" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8297" PostTypeId="1" AcceptedAnswerId="8298" CreationDate="2022-04-24T08:31:44.297" Score="11" ViewCount="1923" Body="&lt;p&gt;I realize that this question may be off-topic, but I do not know where else can I find a 'social media' where OR practitioners hang out. I am about to finish my math BSc. and about to do my masters. I am interested in learning more OR, so I would like to know which areas of mathematics are the most useful for OR?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Which areas of mathematics should be strengthen in anticipation of doing OR? Strengthen can be understood as learning from a graduate text for subject X in the summer break.&lt;/p&gt;&#xA;&lt;p&gt;Personally,:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Linear Algebra. I haven't touched a more advanced linalg book, but I made a point to try to use it in my thesis. I don't have a more advanced knowledge but I know the undergraduate material pretty intimately by usage.&lt;/li&gt;&#xA;&lt;li&gt;Abstract Algebra. Took two courses, covered rigorously groups, rings, and fields.&lt;/li&gt;&#xA;&lt;li&gt;Graph theory. Fairly ahead of the standard graph theory classes math and cs students take (did ramsey theory, turan graphs), I just like the subject.&lt;/li&gt;&#xA;&lt;li&gt;Analysis. What you would expect to know of an undergraduate, rigorous single + multivar, rigorous real analysis, somewhat milder complex analysis (half of the class was complex analysis, the other half was intro to measure theory). In fact, I skipped a proper measure theory course, should I take this in my masters?&lt;/li&gt;&#xA;&lt;li&gt;Probability, statistics, stochastics. I did a course in each, and I am strong in them, but I don't know if they are that relevant to OR?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7498" LastActivityDate="2022-04-24T15:36:31.773" Title="Areas of mathematics to strengthen if interested in OR" Tags="|books|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8298" PostTypeId="2" ParentId="8297" CreationDate="2022-04-24T13:33:08.463" Score="11" Body="&lt;p&gt;Already I think you have a sufficiently strong math background for someone going into OR. Among your cohort in your Master's program there are likely to be students who have an undergraduate degree in IE, who will know more about OR than you do but less about math. And there will likely be some math majors, who have a similar background as yours, and folks from totally unrelated fields as well. So I would not worry that you are deficient in math as you head into your Master's.&lt;/p&gt;&#xA;&lt;p&gt;But to your specific question about &lt;em&gt;which&lt;/em&gt; math fields are most relevant, I would say it's useful to have a solid understanding of the fundamentals of:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Linear algebra (important for linear programming theory and algorithms)&lt;/li&gt;&#xA;&lt;li&gt;Graph theory (important for combinatorial optimization)&lt;/li&gt;&#xA;&lt;li&gt;Real analysis (important if you specialize in continuous optimization, but even if you don't, the mathematical maturity students typically gain in real analysis courses is useful throughout OR)&lt;/li&gt;&#xA;&lt;li&gt;Probability, stats, stochastics (all are heavily used in OR)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For a Master's program, a first course in each of these is usually sufficient, though of course having taken more won't hurt you.&lt;/p&gt;&#xA;&lt;p&gt;You most likely won't use much abstract algebra or complex analysis, but again, it won't hurt you.&lt;/p&gt;&#xA;&lt;p&gt;You didn't say much about your computing background, but if you haven't done too much coding, you might want to spend the summer improving your skills there instead of in math. Learn or improve your Python, MATLAB, Julia, etc.&lt;/p&gt;&#xA;" OwnerUserId="38" LastActivityDate="2022-04-24T13:33:08.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8299" PostTypeId="2" ParentId="8268" CreationDate="2022-04-24T14:01:05.510" Score="5" Body="&lt;p&gt;In Section 5.3 of&lt;/p&gt;&#xA;&lt;p&gt;K. Helsgaun,&#xA;General k-opt submoves for the Lin-Kernighan TSP heuristic.&#xA;Mathematical Programming Computation, 1(2-3):119-163 (2009).&lt;/p&gt;&#xA;&lt;p&gt;it is demonstrated how the feasibility of a k-opt move can be determined in O(k log k) time.&lt;/p&gt;&#xA;" OwnerUserId="9604" LastActivityDate="2022-04-24T14:01:05.510" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8300" PostTypeId="2" ParentId="8297" CreationDate="2022-04-24T15:36:31.773" Score="10" Body="&lt;p&gt;I agree with Larry that you've already got most of what you need. I would suggest taking a look at &lt;a href=&quot;https://en.wikipedia.org/wiki/Numerical_analysis&quot; rel=&quot;noreferrer&quot;&gt;numerical analysis&lt;/a&gt;. An understanding of convergence arguments for algorithms and, perhaps more importantly, how mathematics on a computer diverges from mathematics as taught in a math class can be helpful and at times critical.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-24T15:36:31.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8301" PostTypeId="1" CreationDate="2022-04-25T04:17:33.747" Score="2" ViewCount="86" Body="&lt;p&gt;Consider a general bi-level programming as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;    \min_{x\in X,y\in Y}&amp;amp;~F(x,y) \\&#xA;           s.t.&amp;amp;~ G(x,y) \leq 0, \\&#xA;               &amp;amp;~ y\in \arg\min_{z\in Y}\{f(x,z): g(x,z)\leq0\}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Suppose the upper- and lower-level variables are swapped, and we obtain&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;    \min_{x\in X,y\in Y}&amp;amp;~F(x,y) \\&#xA;           s.t.&amp;amp;~ G(x,y) \leq 0, \\&#xA;               &amp;amp;~ x\in \arg\min_{z\in X}\{f(z,y): g(z,y)\leq0\}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I understand that swapping upper- and lower-level variables lead to two problems that are not equivalent in general. But I wonder whether they can be equivalent in special conditions. I appreciate much if relevant materials are provided.&lt;/p&gt;&#xA;" OwnerUserId="9608" LastEditorUserId="67" LastEditDate="2022-04-26T18:33:10.130" LastActivityDate="2022-04-26T21:33:12.757" Title="Interchange upper- and lower-level decision variables in bi-level programming" Tags="|optimization|bilevel-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8302" PostTypeId="2" ParentId="8228" CreationDate="2022-04-25T05:46:50.263" Score="2" Body="&lt;p&gt;You can formulate construction of latin squares as an (integer) linear programming problem. Extending that, you can get sudokus this way.&lt;/p&gt;&#xA;&lt;p&gt;I have some code for the latin square part, which I will dig up later to complete this answer.&lt;/p&gt;&#xA;" OwnerUserId="166" LastActivityDate="2022-04-25T05:46:50.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8303" PostTypeId="1" AcceptedAnswerId="8306" CreationDate="2022-04-25T17:12:12.617" Score="4" ViewCount="179" Body="&lt;p&gt;In VRPTW problem, given&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$[a_i, b_i]$&lt;/span&gt;: the time window for node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ijk}$&lt;/span&gt;: a binary variable that represents that the vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; travels from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (yes 1 otherwise 0)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt;: the service time at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt;: the traveling time from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I see paper and books widely formulate the constraints related to time as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;w_{ik} + s_{i} + t_{ij} - w_{jk} \leq (1 - x_{ijk})M_{ij} \tag{1} \\&#xA;&amp;amp;w_{ik} \geq a_{i} \tag{2} \\&#xA;&amp;amp;w_{ik} \leq b_{i} \tag{3}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$w_{ik}$&lt;/span&gt; was mentioned as the arrival time of vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, (1) is actually the linearized version of&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{ijk}(w_{ik} + s_{i} + t_{ij} - w_{jk})\le0 \tag{4}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and (2) and (3) are the time window constraints.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1$&lt;/span&gt;, we expect the representation of arrival time to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to be &lt;strong&gt;(the time of arrival at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;) + (the service time at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;) + (time cost to travel from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, under the circumstance where &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$1-x_{ijk}=0$&lt;/span&gt;, we get &lt;span class=&quot;math-container&quot;&gt;$w_{ik} + s_i + t_{ij} - w_{jk} \le 0$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$w_{jk} \ge w_{ik} + s_i + t_{ij} $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This could be interpreted as: &lt;strong&gt;the arrival time at&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; &lt;strong&gt;is greater and equal to the expected time&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then I am confused that how can we prevent the case where &lt;span class=&quot;math-container&quot;&gt;$w_{jk}$&lt;/span&gt; is larger than what we expected?&lt;/p&gt;&#xA;&lt;p&gt;Of course, there is also a possibility that the expected time is below the lower bound of time window &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;, the vehicle is assumed to be waiting to &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;, and this is ensured by (2). However, still, the &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; in (2) leaves the possibility for it to be larger than &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I used to see that in some literature, the objective contains minimization of the sum of such variables so that the case can be prevented. However, here the objective is only minimizing the travel cost &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j,k}c_{ij} \cdot x_{i,j,k}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Based on the result from CPLEX, I see the values of &lt;span class=&quot;math-container&quot;&gt;$w_{jk}$&lt;/span&gt; indeed tightened to &lt;span class=&quot;math-container&quot;&gt;$\max\{a_j, w_{ik} + s_i + t_{ij}\}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9613" LastEditorUserId="491" LastEditDate="2022-04-26T17:36:28.537" LastActivityDate="2022-07-27T09:26:41.197" Title="How does the VRPTW model ensure the arrival time at next station tightened?" Tags="|mixed-integer-programming|vehicle-routing|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8304" PostTypeId="2" ParentId="8303" CreationDate="2022-04-25T19:01:58.473" Score="2" Body="&lt;p&gt;There may be some slack in the system. Suppose that there is one vehicle, and the optimal solution has the vehicle go from node 1 to node 2. Assuming everything moves as early as possible, the vehicle completes the service at node 1 at time 10. Travel time to node 2 is 3, but the window at node 2 does not open until time 20. So there is 7 time units of &amp;quot;slack&amp;quot;. You can think of the &amp;quot;arrival time&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$w_{2,1}$&lt;/span&gt; as the time the vehicle &amp;quot;enters the premises&amp;quot; or &amp;quot;officially arrives&amp;quot; at node 2. According to the constraint &lt;span class=&quot;math-container&quot;&gt;$w_{i,k}\ge a_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w_{2,1}$&lt;/span&gt; cannot be less than 20. So either the vehicle dawdles in the vicinity of node 1 before heading to node 2, or it dawdles in the vicinity of node 2 before officially arriving, or it takes the scenic route (travel time greater than &lt;span class=&quot;math-container&quot;&gt;$t_{1,2} = 3$&lt;/span&gt;), or some combination of those.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-25T19:01:58.473" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8305" PostTypeId="1" CreationDate="2022-04-25T21:07:52.497" Score="3" ViewCount="568" Body="&lt;p&gt;I'm trying to incorporate or-tools into my cmake project.&lt;/p&gt;&#xA;&lt;p&gt;I've tried some of the suggestions given by the project maintainers, who give a few different ways to integrate or-tools &lt;a href=&quot;https://stackoverflow.com/questions/2649334/difference-between-static-and-shared-libraries&quot;&gt;in the readme&lt;/a&gt; and in a &lt;a href=&quot;https://github.com/or-tools/cmake_or-tools&quot; rel=&quot;nofollow noreferrer&quot;&gt;template project&lt;/a&gt;. I've tried both, yielding the same result.&lt;/p&gt;&#xA;&lt;p&gt;The first method is building locally and using cmake's &lt;code&gt;find_package&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;################&#xA;##  OR_TOOLS  ##&#xA;################&#xA;message(STATUS &amp;quot;Installing OR-Tools...&amp;quot;)&#xA;# Download and install or-tools at configure time&#xA;configure_file(&#xA;    &lt;span class=&quot;math-container&quot;&gt;${CMAKE_CURRENT_SOURCE_DIR}/cmake/ortools.CMakeLists.txt&#xA;$&lt;/span&gt;{CMAKE_BINARY_DIR}/ortools-download/CMakeLists.txt)&#xA;# CMake configure&#xA;execute_process(COMMAND &lt;span class=&quot;math-container&quot;&gt;${CMAKE_COMMAND} -G &quot;$&lt;/span&gt;{CMAKE_GENERATOR}&amp;quot; .&#xA;  RESULT_VARIABLE result&#xA;  WORKING_DIRECTORY &lt;span class=&quot;math-container&quot;&gt;${CMAKE_BINARY_DIR}/ortools-download)&#xA;if(result)&#xA;  message(FATAL_ERROR &quot;CMake step for ortools failed: $&lt;/span&gt;{result}&amp;quot;)&#xA;endif()&#xA;# CMake Build/Install&#xA;execute_process(COMMAND &lt;span class=&quot;math-container&quot;&gt;${CMAKE_COMMAND} --build .&#xA;  RESULT_VARIABLE result&#xA;  WORKING_DIRECTORY $&lt;/span&gt;{CMAKE_BINARY_DIR}/ortools-download)&#xA;if(result)&#xA;  message(FATAL_ERROR &amp;quot;Build step for ortools failed: ${result}&amp;quot;)&#xA;endif()&#xA;message(STATUS &amp;quot;Installing OR-Tools...DONE&amp;quot;)&#xA;&#xA;list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/deps)&#xA;find_package(ortools REQUIRED)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where in the &lt;code&gt;cmake&lt;/code&gt; directory I have a file &lt;code&gt;ortools.CmakeLists.txt&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cmake_minimum_required(VERSION 3.8)&#xA;&#xA;project(ortools-download NONE)&#xA;&#xA;include(ExternalProject)&#xA;ExternalProject_Add(ortools_project&#xA;  GIT_REPOSITORY https://github.com/google/or-tools.git&#xA;  GIT_TAG &amp;quot;stable&amp;quot;&#xA;  GIT_SHALLOW TRUE&#xA;  GIT_PROGRESS TRUE&#xA;  CMAKE_ARGS&#xA;    &amp;quot;-G@CMAKE_GENERATOR@&amp;quot;&#xA;    &amp;quot;-DCMAKE_BUILD_TYPE=&lt;span class=&quot;math-container&quot;&gt;${CMAKE_BUILD_TYPE}&quot;&#xA;&quot;-DBUILD_DEPS=ON&quot;&#xA;&quot;-DBUILD_SAMPLES=OFF&quot;&#xA;&quot;-DBUILD_EXAMPLES=OFF&quot;&#xA;&quot;-DBUILD_TESTING=OFF&quot;&#xA;&quot;-DCMAKE_INSTALL_PREFIX=$&lt;/span&gt;{CMAKE_BINARY_DIR}/deps&amp;quot;&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and the second is to use cmake's &lt;code&gt;FetchContent&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    include(FetchContent)&#xA;    FetchContent_Declare(&#xA;            ortools&#xA;            GIT_REPOSITORY https://github.com/google/or-tools.git&#xA;            GIT_TAG        stable&#xA;    )&#xA;&#xA;    set(BUILD_DEPS ON)&#xA;    set(BUILD_SAMPLES OFF)&#xA;    set(BUILD_EXAMPLES OFF)&#xA;    FetchContent_MakeAvailable(ortools)&#xA;    set(requiredlibs ${requiredlibs} ortools::ortools)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Both give the same error, at runtime:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;ERROR: Something is wrong with flag 'flagfile' in file 'Users/username/project-root/cmake-build-debug/ortools-download/ortools_project-prefix/src/ortools_project-build/_deps/absl-src/absl/flags/parse.cc'. One possibility: file 'Users/username/project-root/cmake-build-debug/ortools-download/ortools_project-prefix/src/ortools_project-build/_deps/absl-src/absl/flags/parse.cc' is being linked both statically and dynamically into this executable. e.g. some files listed as srcs to a test and also listed as srcs of some shared lib deps of the same test. &lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;For reference, I'm on an Apple Silicon Mac, using cmake 3.22.3, compiling with the flag:&#xA;&lt;code&gt;-DCMAKE_APPLE_SILICON_PROCESSOR=arm64&lt;/code&gt;. I've tried both &lt;code&gt;-DCMAKE_BUILD_TYPE=Release&lt;/code&gt; and &lt;code&gt;-DCMAKE_BUILD_TYPE=Debug&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&lt;p&gt;I partially figured it out, however I still have a question: I want to compile a dynamic library from many shared libraries in my project. The static libraries need to be linked to &lt;code&gt;ortools&lt;/code&gt; because they reference that library. However, I then want to build a shared library that merges all the separate static libraries together, this doesn't work. Why is that the case, and is there a way to fix it?&lt;/p&gt;&#xA;&lt;p&gt;Below is my current solution so if anyone else has this issue they can reference. I ended up using the &lt;code&gt;FetchContent&lt;/code&gt; method, with a few modifications.&lt;/p&gt;&#xA;&lt;p&gt;The error gives a hint as to what was happening: &amp;quot;is being linked both statically and dynamically into this executable&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;In c++ there are two types of libraries: &lt;a href=&quot;https://stackoverflow.com/questions/2649334/difference-between-static-and-shared-libraries&quot;&gt;static and dynamic&lt;/a&gt;. My code builds many static libraries and links them to a dynamic library, which is then linked to the executable file.&lt;/p&gt;&#xA;&lt;p&gt;project structure:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;.&#xA;├── CMakeLists.txt&#xA;├── src&#xA;│   ├── CMakeLists.txt # creates the dynamic library&#xA;│   ├── [various .cc/.h files]&#xA;│   ├── staticlib1&#xA;│   │   ├── CMakeLists.txt # creates a static library&#xA;│   │   └── [various .cc/.h files]&#xA;│   └── staticlib2&#xA;│       ├── CMakeLists.txt # creates another static library&#xA;│       └── [various .cc/.h files]&#xA;└── main.cc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The key is that &lt;code&gt;ortools::ortools&lt;/code&gt; can only be linked to either multiple static libraries, or multiple dynamic libraries. It cannot be linked to both static and dynamic libraries.&lt;/p&gt;&#xA;&lt;p&gt;In &lt;code&gt;src/CMakelists.txt&lt;/code&gt; I create a dynamic library and was linking to ortools:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;project(project)&#xA;&#xA;SET(SOURCE_FILES_SRC&#xA;        example.cc&#xA;)&#xA;&#xA;add_subdirectory(staticlib1)&#xA;set(requiredlibs ${requiredlibs} staticlib1)&#xA;&#xA;add_subdirectory(staticlib2)&#xA;set(requiredlibs ${requiredlibs} staticlib2)&#xA;&#xA;add_library(&lt;span class=&quot;math-container&quot;&gt;${DISPATCHER_LIB} SHARED $&lt;/span&gt;{SOURCE_FILES_SRC})&#xA;target_link_libraries(&lt;span class=&quot;math-container&quot;&gt;${DISPATCHER_LIB} $&lt;/span&gt;{requiredlibs} ortools::ortools) # linking to dynamic(shared) ortools lib&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, I was also linking to &lt;code&gt;ortools::ortools&lt;/code&gt; in the static libraries in &lt;code&gt;src/staticlib1/CMakeLists.txt&lt;/code&gt; which caused the issue:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;project(project)&#xA;&#xA;set(staticlib1_SOURCE_FILES&#xA;        example2.cc)&#xA;&#xA;add_library(staticlib1 STATIC &lt;span class=&quot;math-container&quot;&gt;${staticlib1_SOURCE_FILES})&#xA;set_property(TARGET staticlib1 PROPERTY POSITION_INDEPENDENT_CODE ON)&#xA;target_link_libraries(staticlib1 $&lt;/span&gt;{requiredlibs} ortools::ortools) # linking to static ortools &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To fix this, changed the dynamic library to a static library&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;project(project)&#xA;&#xA;SET(SOURCE_FILES_SRC&#xA;        example.cc&#xA;)&#xA;&#xA;add_subdirectory(staticlib1)&#xA;set(requiredlibs ${requiredlibs} staticlib1)&#xA;&#xA;add_subdirectory(staticlib2)&#xA;set(requiredlibs ${requiredlibs} staticlib2)&#xA;&#xA;add_library(&lt;span class=&quot;math-container&quot;&gt;${DISPATCHER_LIB} $&lt;/span&gt;{SOURCE_FILES_SRC}) # now a static library&#xA;target_link_libraries(&lt;span class=&quot;math-container&quot;&gt;${DISPATCHER_LIB} $&lt;/span&gt;{requiredlibs})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I also had to change the &lt;code&gt;FetchContent&lt;/code&gt; block in &lt;code&gt;CMakeLists.txt&lt;/code&gt; to disable building the ortools dynamic libraries.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set(FETCHCONTENT_QUIET OFF)&#xA;include(FetchContent)&#xA;FetchContent_Declare(&#xA;        ortools&#xA;        GIT_REPOSITORY https://github.com/google/or-tools.git&#xA;        GIT_TAG        stable&#xA;)&#xA;set(BUILD_SHARED_LIBS OFF) # disables dynamic(shared) library building&#xA;set(BUILD_DEPS ON)&#xA;set(BUILD_SAMPLES OFF)&#xA;set(BUILD_EXAMPLES OFF)&#xA;FetchContent_MakeAvailable(ortools)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As I stated above, at the beginning of the edit, I would like this line&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;add_library(${DISPATCHER_LIB} ${SOURCE_FILES_SRC}) # now a static library&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;in &lt;code&gt;src/CMakeLists.txt&lt;/code&gt; to be a dynamic library:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;add_library(${DISPATCHER_LIB} SHARED ${SOURCE_FILES_SRC}) # now a static library&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;is there a way to make that work given that I need ortools to link to the static libraries that it is composed of?&lt;/p&gt;&#xA;" OwnerUserId="173" LastEditorUserId="173" LastEditDate="2022-04-26T17:12:49.320" LastActivityDate="2022-04-26T17:12:49.320" Title="Incorporating OR-Tools in a CMake Project" Tags="|or-tools|c++|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8306" PostTypeId="2" ParentId="8303" CreationDate="2022-04-26T08:24:06.760" Score="2" Body="&lt;p&gt;I think the confusion may stem from the fact that you minimize the cost of &lt;em&gt;being on the road&lt;/em&gt;. Hence, you do not really minimize the &lt;em&gt;time&lt;/em&gt; used on the routes. One simple way to move the focus more to the time dimension is to change your objective function to &lt;span class=&quot;math-container&quot;&gt;$\min \sum_{i\in N}\sum_{k\in K}w_{ik}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is the set of customers and &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is the set of vehicles. This way you push back the start of service as much as possible.&lt;/p&gt;&#xA;&lt;p&gt;Another approach (that I would not advice) is to &lt;em&gt;also&lt;/em&gt; require the reverse inequality: &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1\Rightarrow w_{ik}+s_i+t_{ij} \geq w_{jk}$&lt;/span&gt;. This way you will have that &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1\Rightarrow w_{ik}+s_i+t_{ij} = w_{jk}$&lt;/span&gt;. You can do this in a similar fashion as you have modelled the other time-accumulating inequalities.&lt;/p&gt;&#xA;&lt;p&gt;The problem, however, is that if you require that service &lt;em&gt;must&lt;/em&gt; start when you arrive at a customer, you may create some very strange routes where longer detours are taken in order to hit the time windows.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-04-26T08:24:06.760" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8307" PostTypeId="1" AcceptedAnswerId="8308" CreationDate="2022-04-26T12:58:10.300" Score="4" ViewCount="295" Body="&lt;p&gt;I have an mixed-integer linear optimization problem that includes a energetic difference equation for the temperature of a building for the time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$T(t) = T(t-1) + \frac{E^{\rm Heating}(t)-E^{\rm Demand}(t)}{V\cdot \rho\cdot c}, t&amp;gt;1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I used to have the temperature in the constraints with a minimum and maximum value:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$T_{\min}\leq T(t) \leq T_{\max}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now I would like to transform it from a constraint to the objective function. So what I want is to quantify the violation of this &amp;quot;constrain&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; and minimize it in the objective function. So the equations should actually look like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{if} \hspace{0,5cm}T(t) &amp;lt; T_{\min} &amp;amp;\implies Z(t) = T_{\min} - T(t)\\\text{if} \hspace{0,5cm}T(t) &amp;gt; T_{\max} &amp;amp;\implies Z(t) =  T(t) - T_{\max}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And in the objective function &lt;span class=&quot;math-container&quot;&gt;$\min \sum_{t} Z(t)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now my question is, whether this is possible to define within a mixed-integer linear problem and if so, how can I do that?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="123" LastEditDate="2022-04-26T16:40:58.680" LastActivityDate="2022-04-26T16:40:58.680" Title="How to transform a (thermal) range constraint into the objective function" Tags="|modeling|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8308" PostTypeId="2" ParentId="8307" CreationDate="2022-04-26T13:03:28.503" Score="9" Body="&lt;p&gt;Introduce nonnegative variables &lt;span class=&quot;math-container&quot;&gt;$Z^+(t)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z^-(t)$&lt;/span&gt;, impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$T_\min \le T(t)-Z^+(t)+Z^-(t) \le T_\max,$$&lt;/span&gt;&#xA;and minimize &lt;span class=&quot;math-container&quot;&gt;$$\sum_t (Z^+(t)+Z^-(t)).$$&lt;/span&gt;&#xA;Notice that this approach easily allows penalizing overage and underage differently, if you want, just by changing the objective coefficients.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-04-26T13:59:20.403" LastActivityDate="2022-04-26T13:59:20.403" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8310" PostTypeId="1" CreationDate="2022-04-26T15:53:54.987" Score="0" ViewCount="225" Body="&lt;p&gt;I am trying to solve a flexible job shop problem variant using or-tools.&#xA;And in some input configuration, in general after one month of scheduling time, I am facing a weird behavior.&lt;/p&gt;&#xA;&lt;p&gt;I am aware that the problem is NP-Hard, so I am expecting a sort of exponential growth of the time gap between the last feasible and the new one.&#xA;I am enumerating all the solutions and print them, and i noticed practically that the library find all the feasible solutions 2 minutes, and actually the last one is the optimal, but the library never exists and continues in explore not finding any other solutions for days, literally days even in on 32 cores machine, and increasing the used memory day by day. The last log line is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Bound  24.35s best:20    next:[21,22]    bool_core num_cores:2 [core:2 mw:1 d:5] assumptions:1 depth:6 fixed_bools:0/151&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The maximum score is 25, and the 20 reached is indee the best possible for this configuration. So I wonder what is the CP-SAT solver actually doing? Isn't it realizing that what it found is indeed the optimal solution? How can I help the solver to end the computation realizing the optimal?&lt;/p&gt;&#xA;" OwnerUserId="9620" LastEditorUserId="981" LastEditDate="2023-02-19T14:47:25.507" LastActivityDate="2023-02-19T14:47:25.507" Title="or-tools: job shop problem never exists not finding additional solutions" Tags="|or-tools|job-shop-scheduling|cp-sat|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8311" PostTypeId="2" ParentId="8310" CreationDate="2022-04-26T16:20:43.923" Score="1" Body="&lt;p&gt;Proving optimality is where the NP-Hard part is. A lot of small job-shops are still open (meaning not proven). In your case, you have a maximization objective. You have found a feasible value with objective 20, and CP-SAT has proven that there are no solutions higher than 22.&lt;/p&gt;&#xA;&lt;p&gt;The rest is just hard, exponential search or proof.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2022-04-26T16:20:43.923" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8312" PostTypeId="2" ParentId="8301" CreationDate="2022-04-26T21:33:12.757" Score="1" Body="&lt;p&gt;This is probably not a very interesting case, but assume the following two things. First, &lt;span class=&quot;math-container&quot;&gt;$$g(x,y)\le 0 \implies G(x,y) \le 0 \quad \forall x\in X;\forall y\in Y.$$&lt;/span&gt; Second, &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; &amp;quot;tracks&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; in the sense that &lt;span class=&quot;math-container&quot;&gt;$$f(x,y) &amp;lt; f(\tilde{x},\tilde{y})\implies F(x,y) &amp;lt; F(\tilde{x},\tilde{y})\quad \forall x,\tilde{x}\in X; \forall y,\tilde{y}\in Y.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now suppose that &lt;span class=&quot;math-container&quot;&gt;$(x^*, y^*)$&lt;/span&gt; is the optimal solution to your first problem and &lt;span class=&quot;math-container&quot;&gt;$(\hat{x},\hat{y})$&lt;/span&gt; is the optimal solution to your second problem, and suppose the objective functions differ. Without loss of generality, assume &lt;span class=&quot;math-container&quot;&gt;$F(x^*,y^*) &amp;lt; F(\hat{x},\hat{y}).$&lt;/span&gt; Then it must be that &lt;span class=&quot;math-container&quot;&gt;$(x^*,y^*)$&lt;/span&gt; is not feasible in the second problem. Since we know from the first problem that &lt;span class=&quot;math-container&quot;&gt;$G(x^*,y^*) \le 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g(x^*,y^*) \le 0,$&lt;/span&gt; it must be that &lt;span class=&quot;math-container&quot;&gt;$$\tilde{x} = \arg\min_{z\in X} \lbrace f(z,y^*) : g(z,y^*) \le 0\rbrace \neq x^*,$$&lt;/span&gt; and more specifically &lt;span class=&quot;math-container&quot;&gt;$$f(\tilde{x},y^*) &amp;lt; f(x^*,y^*).$$&lt;/span&gt; Also note that &lt;span class=&quot;math-container&quot;&gt;$$g(\tilde{x},y^*) \le 0.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now let &lt;span class=&quot;math-container&quot;&gt;$$\tilde{y} = \arg\min_{y\in Y} \lbrace f(\tilde{x}, y) : g(\tilde{x}, y) \le 0\rbrace$$&lt;/span&gt; and observe that &lt;span class=&quot;math-container&quot;&gt;$$f(\tilde{x},\tilde{y}) \le f(\tilde{x},y^*) &amp;lt; f(x^*,y^*).$$&lt;/span&gt;Since &lt;span class=&quot;math-container&quot;&gt;$$g(\tilde{x},\tilde{y}) \le 0 \implies G(\tilde{x},\tilde{y}) \le 0,$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$(\tilde{x},\tilde{y})$&lt;/span&gt; satisfies the constraints of the first problem. Using the &amp;quot;tracking&amp;quot; assumption, &lt;span class=&quot;math-container&quot;&gt;$$f(\tilde{x},\tilde{y}) &amp;lt; f(x^*,y^*)\implies F(\tilde{x},\tilde{y}) &amp;lt; F(x^*,y^*),$$&lt;/span&gt; contradicting optimality of &lt;span class=&quot;math-container&quot;&gt;$(x^*,y^*)$&lt;/span&gt; in the first problem.&lt;/p&gt;&#xA;&lt;p&gt;So the two assumptions I listed are sufficient to ensure that the two problems have the same optimal objective value.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-26T21:33:12.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8313" PostTypeId="1" AcceptedAnswerId="8315" CreationDate="2022-04-27T13:38:20.423" Score="9" ViewCount="558" Body="&lt;p&gt;Since the modeler has domain/business knowledge of the problem being solved, is it possible to manually implement Isomorphism Pruning or Orbital branching and beat the default methods implemented by the solvers  under the hood. Also, some of the advice, especially here on OR-SE is to not even add symmetry breaking constraints and let the solver exploit/handle it. Thoughts?&lt;/p&gt;&#xA;&lt;p&gt;Manually implementing isomorphism pruning or orbital branching is quite involved. Anyone can provide code sample using a commercial solver (Gurobi/Cplex/Xpress)?&lt;/p&gt;&#xA;" OwnerUserId="8882" LastEditorUserId="8882" LastEditDate="2022-04-27T17:25:20.533" LastActivityDate="2022-04-27T17:25:20.533" Title="Dealing with Symmetry. Commercial solver defaults vs manual implementations" Tags="|mixed-integer-programming|gurobi|symmetry|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8314" PostTypeId="2" ParentId="8313" CreationDate="2022-04-27T15:55:38.850" Score="7" Body="&lt;p&gt;As far as symmetry breaking constraints v. leaving the solver to deal with the symmetry, I think that is an empirical question, meaning you can try both (with reasonably short time limits) and see which is better. The solver may have parameter settings for how (or how aggressively) it deals with symmetry, so you might be trying more than two scenarios before deciding which looks most promising.&lt;/p&gt;&#xA;&lt;p&gt;For what it is worth, I have in the past had decent luck with symmetry breaking constraints using CPLEX, although in fairness I usually don't bother to test them versus the most aggressive parameter settings.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-04-27T15:55:38.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8315" PostTypeId="2" ParentId="8313" CreationDate="2022-04-27T15:58:44.350" Score="10" Body="&lt;p&gt;There might be automatic settings and tunings inside the solver that are not perfect and might choose not to use orbital branching for an instance although it might be beneficial. In that case the first thing to try would be to change a symmetry setting in a solver to something like &amp;quot;aggressive&amp;quot; (or at least non-default).&lt;/p&gt;&#xA;&lt;p&gt;Implementing orbital branching for those solvers that provide branching callbacks is not all that hard as long as you have a way to identify the orbits which can be done using open-source graph isomorphism packages (like &lt;a href=&quot;https://www3.cs.stonybrook.edu/%7Ealgorith/implement/nauty/implement.shtml&quot; rel=&quot;noreferrer&quot;&gt;nauty&lt;/a&gt; and &lt;a href=&quot;https://github.com/hrbrmstr/saucy&quot; rel=&quot;noreferrer&quot;&gt;saucy&lt;/a&gt;). It's not likely to be more efficient than what the solvers are using inside, but it is at least possible. Still I would not expect a huge gain except for solvers that don't have symmetry handling at all (like some open source solvers).&lt;/p&gt;&#xA;&lt;p&gt;Note that its not enough to know the orbits upfront, one also needs to know how the orbits change when branching, so the domain/business knowledge might not be all that helpful.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2022-04-27T15:58:44.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8316" PostTypeId="1" CreationDate="2022-04-27T16:08:43.777" Score="2" ViewCount="127" Body="&lt;p&gt;We are currently working at the intersection of metaheuristics and machine learning.&lt;/p&gt;&#xA;&lt;p&gt;As part of the scheduling problem that we are trying to solve, we have a project network (directed acylic graph) that captures the precedence relations between different activities that are to be scheduled.&lt;/p&gt;&#xA;&lt;p&gt;Now we want to use this project network as a feature for a machine learning approach. One idea that came to mind is to use the adjacency matrix or reachability matrix as feature vectors for the machine learning model. Our intention is to capture the complete network structure as a feature and not just some &amp;quot;aggregating&amp;quot; measures such as density of transitive closure or ratio of nodes to arcs, etc.&lt;/p&gt;&#xA;&lt;p&gt;The problem that we encounter is that depending on the labeling of the nodes, two identical project networks may have adjacency matrices that look very different. Ideally however, if the project networks are identical, the adjacency matrices should also be identical, independent of the labeling of the nodes.&lt;/p&gt;&#xA;&lt;p&gt;We therefore propose to re-name the nodes according to some predefined logic. One could, for example, take into consideration the number of immediate or transitive successors.&lt;/p&gt;&#xA;&lt;p&gt;Is anyone familiar with an approach like that or could guide us into the right direction with e.g. search terms to search for? The goal is to have a representation of the network that is invariant of the node labels.&lt;/p&gt;&#xA;&lt;p&gt;Maybe research in the area of image processing would have to be something to look at?&#xA;This may sound very &amp;quot;layman&amp;quot; but in the end it seems similar to the problem of having a single object but images of different perspectives. However, now we have the chance to &amp;quot;orient&amp;quot; the object in a predefined way (in this case by relabeling the nodes). Please excuse the clunky explanation.&lt;/p&gt;&#xA;&lt;p&gt;For a visual help, I have drawn a quick sketch that illustrates the problem: Even though the networks are identical, the adjacency matrices are quite different:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DrDVy.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DrDVy.jpg&quot; alt=&quot;Adjacency matrices of two identical networks&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6082" LastEditorUserId="491" LastEditDate="2022-04-27T16:28:54.213" LastActivityDate="2022-04-27T23:18:14.973" Title="Logic for Re-Labeling Nodes in a Directed Acyclic Graph" Tags="|graphs|machine-learning|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8317" PostTypeId="1" AcceptedAnswerId="8320" CreationDate="2022-04-27T17:17:56.893" Score="7" ViewCount="195" Body="&lt;p&gt;What insights/info can be gathered from visualizing the Branch &amp;amp; Bound tree. Some commercial solvers (FICO Xpress) don't seem to provide any API to readily visualize the tree. It has to be implemented using callback functions.&lt;/p&gt;&#xA;" OwnerUserId="8882" LastEditorUserId="500" LastEditDate="2022-04-28T01:08:41.007" LastActivityDate="2022-04-28T01:48:27.943" Title="What insights/info can be gathered from visualizing the Branch &amp; Bound tree" Tags="|mixed-integer-programming|branch-and-bound|visualization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8318" PostTypeId="1" CreationDate="2022-04-27T19:55:31.900" Score="5" ViewCount="154" Body="&lt;p&gt;I have a quadratic program that looks like this:&lt;/p&gt;&#xA;&lt;p&gt;For fixed vector &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, and matrices &lt;span class=&quot;math-container&quot;&gt;$A_1, ..., A_n$&lt;/span&gt;, Find column vectors &lt;span class=&quot;math-container&quot;&gt;$x_1, ..., x_n$&lt;/span&gt; that minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n x_i ^T 1 1^T x_i$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n A_i x_i = b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i\in \mathcal{X_i}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{X}_i$&lt;/span&gt; is a convex set.&lt;/p&gt;&#xA;&lt;p&gt;I've been able to solve the problem using two ways. The first is using proximal gradient methods, and the second is using ADMM (both first order methods), but both have a very slow convergence and I have to choose a &amp;quot;correct&amp;quot; learning rate.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering if there is a way to use second order methods on this problem or a practical method for speeding up the convergence.&lt;/p&gt;&#xA;" OwnerUserId="9623" LastEditorUserId="9623" LastEditDate="2022-05-03T17:06:17.217" LastActivityDate="2022-05-04T05:39:59.927" Title="What is the go-to practical method for optimizing separable quadratic programs?" Tags="|convex-optimization|quadratic-programming|decomposition|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8319" PostTypeId="2" ParentId="8316" CreationDate="2022-04-27T21:06:04.830" Score="2" Body="&lt;p&gt;I throw the following out as a possibility, but I am not at all sure that it is practical.&lt;/p&gt;&#xA;&lt;p&gt;Let's say that you have a collection of adjacency matrices &lt;span class=&quot;math-container&quot;&gt;$\mathcal{A}$&lt;/span&gt; known to be distinct, and you have a new adjacency matrix &lt;span class=&quot;math-container&quot;&gt;$\hat{A}$&lt;/span&gt;. You want to know whether it is &amp;quot;equivalent&amp;quot; to any of the matrices in &lt;span class=&quot;math-container&quot;&gt;$\mathcal{A}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Your dependency graphs are naturally layered (using the shortest number of links from the start node to each node &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; to determine the layer containing &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;). As a first cut, you could label every matrix with the number of nodes, number of layers and maybe other information (number of nodes in each layer comes to mind). The labels would be designed so that equivalent matrices would have the same labels. Comparing the label of &lt;span class=&quot;math-container&quot;&gt;$\hat{A}$&lt;/span&gt; to the label of each &lt;span class=&quot;math-container&quot;&gt;$A\in\mathcal{A}$&lt;/span&gt; would let you quickly eliminate some (hopefully many) matrices &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; from consideration because their labels did not match that of &lt;span class=&quot;math-container&quot;&gt;$\hat{A}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now suppose that &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\hat{A}$&lt;/span&gt; have the same label. &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\hat{A}$&lt;/span&gt; are equivalent from your perspective if there is a permutation matrix &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; of the same dimension as &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\hat{A} = P^T A P.$&lt;/span&gt; If you can find a labeling scheme such that two matrices have the same label if and &lt;em&gt;only if&lt;/em&gt; such a permutation matrix exists, you are done. Otherwise, you would need to take each matrix &lt;span class=&quot;math-container&quot;&gt;$A\in\mathcal{A}$&lt;/span&gt; whose label matched that of &lt;span class=&quot;math-container&quot;&gt;$\hat{A}$&lt;/span&gt; and try to solve for &lt;span class=&quot;math-container&quot;&gt;$P.$&lt;/span&gt; I cannot think of a direct way to do this using just matrix operations. Given &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\hat{A},$&lt;/span&gt; you could solve for &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; either using a binary linear program with a zero objective function (since all that matters is that the solution be feasible), or you could use a constraint solver. Either would be somewhat expensive computationally, hence the need for a quick filter (the label) to cut down on the number of problems to solve.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-04-27T23:18:14.973" LastActivityDate="2022-04-27T23:18:14.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8320" PostTypeId="2" ParentId="8317" CreationDate="2022-04-28T00:37:44.080" Score="7" Body="&lt;p&gt;Years ago I wrote an application that could visualize branch and bound trees. The tree was depicted on a scrollable canvas. You could zoom in and out and move similar to navigating Google maps. No clicking or expanding required. Nodes were colored. The colored nodes indicated where feasible solutions were found, which nodes were pruned, which nodes were infeasible, which node was optimal, etc. Arcs would show branching decisions. Vertices would show bounds, and a counter when the node was explored.&lt;/p&gt;&#xA;&lt;p&gt;While all the information visualized in the tree could also be derived from log files, I found the visualization quite informative to look at. A few things that you could learn from the trees:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;when implementing custom branching decisions, are the subtrees balanced?&lt;/li&gt;&#xA;&lt;li&gt;where in the tree are the feasible solutions found?&lt;/li&gt;&#xA;&lt;li&gt;do we run into symmetry problems where we spend a lot of time searching through subtrees representing symmetrical solutions?&lt;/li&gt;&#xA;&lt;li&gt;how do different branching orders work, e.g. Dfs versus best first search, etc&lt;/li&gt;&#xA;&lt;li&gt;how do the bounds improve throughout the search tree.&lt;/li&gt;&#xA;&lt;li&gt;are there uninteresting parts of the tree that we want to avoid, e.g. through a heuristic?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Naturally there's a point where the trees become too big to extract useful information.&lt;/p&gt;&#xA;&lt;p&gt;Although I can't seem to find the application I was referring to, here's an image I generated with a predecessor of the application in a Branch-and-Price application. This only shows a very small instance. You need the zooming capability to visualize larger trees:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/nm3nY.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nm3nY.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2022-04-28T01:48:27.943" LastActivityDate="2022-04-28T01:48:27.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8321" PostTypeId="2" ParentId="8241" CreationDate="2022-04-28T01:24:24.137" Score="1" Body="&lt;p&gt;I will first formalize the described problem in mathematical notations, I think it is more suitable, rather than a piece of code, for providing a better understanding.&lt;/p&gt;&#xA;&lt;p&gt;So, let&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; be the brands set;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$P_b$&lt;/span&gt; be the set of plants belonging to the brand &lt;span class=&quot;math-container&quot;&gt;$b \in B$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$d_p \in \mathbb{R}^{+}$&lt;/span&gt; be the plant &lt;span class=&quot;math-container&quot;&gt;$p \in P_b$&lt;/span&gt; demand, such that &lt;span class=&quot;math-container&quot;&gt;$b \in B$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; be the vendors set;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_v \in \mathbb{R}^{+}$&lt;/span&gt; be the vendor &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt; capacity; and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{vpb} \in \mathbb{R}^{+}$&lt;/span&gt; be the vendor &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt; cost to supply the plant &lt;span class=&quot;math-container&quot;&gt;$p \in P_b$&lt;/span&gt; belonging to the brand &lt;span class=&quot;math-container&quot;&gt;$b \in B$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note that, since you have not specified whether the input magnitudes are discrete, I used real domains for the parameters, however, in case you are working with integral values you can replace &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^{+}$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$\mathbb{N}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, let's go to our mathematical programming model.&#xA;The variables and the two first constraints of this model are exactly equal to the model presented in your code snippet.&#xA;The differences between my model and yours, are in the objective function and in third and so on constraints.&#xA;So, concerning the variables, let&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{vpb} \in \mathbb{R}^{+}_{\leqslant M_{vp}}$&lt;/span&gt; be the amount of supply from vendor &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt; allocated to plant &lt;span class=&quot;math-container&quot;&gt;$p \in P_b$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$b \in B$&lt;/span&gt;; and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{vb} \in \mathbb{B}$&lt;/span&gt; be the flags that tell whether vendor &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt; was allocated to brand &lt;span class=&quot;math-container&quot;&gt;$b \in B$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In this &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variable, we have the big-M &lt;span class=&quot;math-container&quot;&gt;$M_{vp} = \text{min}\{c_v, d_p\}$&lt;/span&gt; representing the maximum of supply that vendor &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt; can deliver to plant &lt;span class=&quot;math-container&quot;&gt;$p \in \bigcup_{b \in B} P_b$&lt;/span&gt;.&#xA;This constant also will be used in a further constraint.&lt;/p&gt;&#xA;&lt;p&gt;The objective function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{min }\sum_{v \in V} \sum_{b \in B} \sum_{p \in P_b} x_{vpb} s_{vpb}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Stating that each plant has its demand satisfied (demand_rule).&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{v \in V} x_{vpb} = d_p$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall b \in B, p \in P_b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Respecting the vendors' capacities (supply_rule).&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{b \in B} \sum_{p \in P_b} x_{vpb} \leqslant c_v$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall v \in V$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;From now on we have the required constraints you have not added to your model.&#xA;Updating &lt;span class=&quot;math-container&quot;&gt;$y_{vb}$&lt;/span&gt; whenever vendor &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt; is allocated to some plant &lt;span class=&quot;math-container&quot;&gt;$p \in P_b$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$b \in B$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{vb} M_{vp} \geqslant x_{vpb}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall v \in V, b \in B, p \in P_b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, we have to update  &lt;span class=&quot;math-container&quot;&gt;$y_{vb}$&lt;/span&gt; whenever vendor &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt; is not allocated to any plant &lt;span class=&quot;math-container&quot;&gt;$p \in P_b$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$b \in B$&lt;/span&gt;.&#xA;In this constraint, &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; represents a minimum of demand that vendor &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; must deliver if it is allocated to a brand &lt;span class=&quot;math-container&quot;&gt;$b \in B$&lt;/span&gt;. You can use your solver &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=parameters-epsilon-degree-tolerance-used-in-linearization&quot; rel=&quot;nofollow noreferrer&quot;&gt;degree of tolerance&lt;/a&gt; value, or just some small floating number, e.g., 1e-4.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{vb} \epsilon \leqslant \sum_{p \in P_b} x_{vpb}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall v \in V, b \in B$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Case you are working with &lt;span class=&quot;math-container&quot;&gt;$x_{vpb} \in \mathbb{N}_{\leqslant M_{vp}}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall v \in V, b \in B, p \in P_b$&lt;/span&gt;, then you can remove the &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-term, leading to the inequality below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{vb} \leqslant \sum_{p \in P_b} x_{vpb}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall v \in V, b \in B$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And finally, we force every brand to take exactly two vendors.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{v \in V} y_{vb} = 2$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall b \in B$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If anyone has any doubts or questions, let me know.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastActivityDate="2022-04-28T01:24:24.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8322" PostTypeId="1" AcceptedAnswerId="8336" CreationDate="2022-04-28T06:04:05.617" Score="3" ViewCount="976" Body="&lt;p&gt;In the simple case, with only two objectives, I would like to know if it is possible to answer a question like:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How many units of objective 1 do I need to reduce, in order to improve objective 2 by one unit? (Assuming the objectives are conflicting, and we have the pareto frontier)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To me, it kind of sounds like sensitivity analysis, but since it's about the objective function only, not including the solutions , I don't feel confident to say &amp;quot;sensitivity analysis on objective 1&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;In &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0191261513000337&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;, the authors used regression to do so (paragraph above Figure 3), but it's not clear to me which type of regression (linear?)&lt;/p&gt;&#xA;&lt;p&gt;Not limited to the two objectives case, I am asking if regression is a good way to answer the question listed, and if there are other methods.&lt;/p&gt;&#xA;" OwnerUserId="2741" LastActivityDate="2022-04-30T02:16:58.267" Title="How to calculate the trade-off between objectives in multi-objective optimization?" Tags="|multi-objective-optimization|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8323" PostTypeId="2" ParentId="8322" CreationDate="2022-04-28T08:58:43.757" Score="2" Body="&lt;p&gt;When you say &amp;quot;How many units of objective 1 do I need to reduce&amp;quot;,  I suspect that you mean that you solved your optimization problem, and then you want to do some &amp;quot;post-optimal&amp;quot; analysis, i.e. you want to analyze the tradeoff between objective 1 and 2.&lt;/p&gt;&#xA;&lt;p&gt;If this is the case, I would do the following. Suppose we start with this, where &lt;span class=&quot;math-container&quot;&gt;$f_1(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2(x)$&lt;/span&gt; are your objectives:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\min . \quad&amp;amp; f_1(x) + f_2(x) \\&#xA;\text{s.t.}\quad&amp;amp; Ax \leq b  &#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;After you solved it, I would then solve the following problem to answer your question:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\min . \quad&amp;amp; f_1(x) + f_2(x) \\&#xA;\text{s.t.}\quad&amp;amp; Ax \leq b \\&#xA;&amp;amp; f_2(x) = f_2^*(x) - 1 \\ &#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &amp;quot;improvement&amp;quot; in my example means reducing (since this is a minimization problem). The value &lt;span class=&quot;math-container&quot;&gt;$f_2^*(x)$&lt;/span&gt; is the optimal value calculated in the first optimization problem.&lt;/p&gt;&#xA;&lt;p&gt;To then find the answer to your question, you calculate &lt;span class=&quot;math-container&quot;&gt;$f_1^{**}(x) - f_1^*(x)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$f_1^{**}(x)$&lt;/span&gt; is the optimal objective function value of objective 1 in the second problem.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2022-04-28T08:58:43.757" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8324" PostTypeId="1" AcceptedAnswerId="8349" CreationDate="2022-04-28T10:38:59.183" Score="3" ViewCount="1370" Body="&lt;p&gt;I have a Multiple product LP optimization problem in which the product(B1,B2,D) will be received in variable quantity with respect to date column.&lt;/p&gt;&#xA;&lt;p&gt;The Optimizer should LP variable Output as Assy Out B1, Assy Out B2, Assy Out D, Open Assy Line (Binary decision to produce or not in given date).&lt;/p&gt;&#xA;&lt;p&gt;The target is to maximize the assembly output per day.&lt;/p&gt;&#xA;&lt;p&gt;The constraints are material receipt for each date and not allowed to produce more than material available in each date&lt;/p&gt;&#xA;&lt;p&gt;here is my data:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/PXoIS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PXoIS.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I used the code below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;dfs=dfs.set_index(dfs['t'])&#xA;&#xA;x=np.arange(1,10)&#xA;&#xA;Assy_B1=pulp.LpVariable.dicts('Assy_B1',x,0,None,'Integer')&#xA;&#xA;Assy_B2=pulp.LpVariable.dicts('Assy_B2',x,0,None,'Integer')&#xA;&#xA;Assy_D=pulp.LpVariable.dicts('Assy_D',x,0,None,'Integer')&#xA;&#xA;Open_Line=pulp.LpVariable.dicts('Open_Line',x,0,None,'Binary')&#xA;&#xA;model=LpProblem('Assembly_Plan',LpMaximize)&#xA;&#xA;model +=lpSum([ Assy_B1[t] + Assy_B2[t] + Assy_D[t] for t in x])&#xA;&#xA;for i in x:&#xA;    model+=(Assy_B1[i]+Assy_B2[i]+Assy_D[i])&amp;lt;=(dfs.loc[i,'Max_Capacity ']*Open_Line[i])&#xA;&#xA;    model+=lpSum(Assy_B1[i])&amp;lt;=dfs.loc[i,'INPUT B1']&#xA;&#xA;    model+=lpSum(Assy_B2[i])&amp;lt;=dfs.loc[i,'INPUT B2']&#xA;&#xA;    model+=lpSum(Assy_D[i])&amp;lt;=dfs.loc[i,'INPUT D']&#xA;&#xA;&#xA;model.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The Model Solution is Optimal and output as below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yNr6B.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yNr6B.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Everything is fine except the last date, the model should have capacity to produce 100 but utilized less (date 5/5/2022 cumulative produced is 60 and still 40 of model D can be produced on that day).&lt;/p&gt;&#xA;&lt;p&gt;Similarly if the input material is available and capacity is less than cumulative material available the model should fit in next best available date for the same.&lt;/p&gt;&#xA;&lt;p&gt;I am not able to fix this Constrain/Relaxation in Pulp.&lt;/p&gt;&#xA;" OwnerUserId="9625" LastEditorUserId="51" LastEditDate="2022-04-28T10:59:04.077" LastActivityDate="2022-05-03T12:25:35.197" Title="How to formulate cumulative sum of LpVariable in Pulp Python" Tags="|optimization|linear-programming|python|pulp|excel|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="8325" PostTypeId="1" CreationDate="2022-04-28T15:40:19.540" Score="3" ViewCount="1314" Body="&lt;p&gt;I have described succinctly the strengths and weaknesses of some Multiple-criteria decision-making (MCDM) methods, however, I would like if you could help me to write these points for the VIKOR and WSM methods, as well as check if I am writing something wrong of any of the methods already described.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;AHP (Analytic Hierarchy Process)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Strengths:&lt;/em&gt; It is scalable; its hierarchical structure can&#xA;easily adjust to fit many complex problems.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Weaknesses:&lt;/em&gt; It contains too many pairwise comparisons; it might have problems due to criteria and alternatives interdependence; it can lead to inconsistencies between criteria and classification.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;ELECTRE ((ELimination Et Choix Traduisant la REalité)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Strengths:&lt;/em&gt; It takes into account the uncertainty and imprecision in the analyses.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Weaknesses:&lt;/em&gt; Its process and results can be hard to explain;&#xA;ranking can make it difficult to directly identify the strengths and weaknesses of attributes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;MAUT(Multi-Attribute Utility Theory)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Strengths:&lt;/em&gt; It takes into account uncertainty; it canincorporate references.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Weaknesses:&lt;/em&gt; Needs a lot of input data; preferences must be exact.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;PROMETHEE (Preference Ranking Organization for Enrichment Evaluations)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Strengths:&lt;/em&gt; It requires no assumption about criteria being proportional.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Weaknesses:&lt;/em&gt; It does not provide a clear methodology for weighting coefficients.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;SAW (Simple Additive Weighting)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Strengths:&lt;/em&gt; It allows compensation between criteria; it has simple calculations and it does not require complex computer&#xA;programs.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Weaknesses:&lt;/em&gt; Its final scores do not always reflect the real&#xA;situation; the result might not be logical.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;TOPSIS (Technique for Order Preference by Similarity to Ideal Solution)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Strengths:&lt;/em&gt; It is simple; the number of steps remains the same regardless of the number of attributes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Weaknesses:&lt;/em&gt; It has hard-weighting coefficient attribution and attribute judgement.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;VIKOR (Vlsekriterijumska Optimizacija I Kompromisno Resenje)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Strengths:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Weaknesses:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;WSM (Weighted Sum Model)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Strengths:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Weaknesses:&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="9063" LastEditorUserId="9063" LastEditDate="2022-04-28T17:31:10.837" LastActivityDate="2022-04-28T17:38:00.163" Title="Strengths and weaknesses of some Multiple-criteria decision-making (MCDM) methods" Tags="|multicriteria-decision-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8326" PostTypeId="2" ParentId="8325" CreationDate="2022-04-28T17:38:00.163" Score="1" Body="&lt;p&gt;The MCDM methods was created to make better decisions when the decision criteria is usually non-quantitive and is needed to create a decision as fast as possible.&lt;/p&gt;&#xA;&lt;p&gt;Also, there is really no obvious difference between those as anyone can use one or more such techniques to see still which one is already perfect for the problem. It means despite of quantitiv decision making methods like mathematical programming, there is no guarantee to achieve a global solution and the results of the one method might be quite different from another one.&lt;/p&gt;&#xA;&lt;p&gt;Also, there are many of the papers that compare these methods which can be easily found by googling. E.g:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.researchgate.net/publication/320798993_Similarities_and_Differences_between_the_Ranking_Schemes_of_the_WSM_TOPSIS_AND_VIKOR_Multi_Criteria_Decision_making_methods_in_Software_Product_Selection&quot; rel=&quot;nofollow noreferrer&quot;&gt;Similarities and Differences between the Ranking Schemes of the WSM, TOPSIS AND VIKOR Multi Criteria Decision making methods in Software Product Selection&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-04-28T17:38:00.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8327" PostTypeId="2" ParentId="560" CreationDate="2022-04-28T23:33:22.917" Score="9" Body="&lt;p&gt;In 1965 I published a paper where I used linear optimization of a complex variable to analyze the complex dielectric behavior of an organic liquid. Wish I could give more details, but it's been a long time and memories are not that good.&lt;/p&gt;&#xA;&lt;p&gt;Cite: Tarlach, Thomas W. and G. E. McDuffie. “THE DIELECTRIC RELAXATION TIME OF 1,3-BUTANEDIOL AS A FUNCTION OF FREE VOLUME,.” (1965).&lt;/p&gt;&#xA;" OwnerUserId="9626" LastEditorUserId="51" LastEditDate="2022-04-28T23:49:07.720" LastActivityDate="2022-04-28T23:49:07.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8328" PostTypeId="1" CreationDate="2022-04-29T00:15:14.837" Score="8" ViewCount="286" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$r, z$&lt;/span&gt; and each of &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; be a length &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; vector. I’d like to maximize the correlation between &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; (when that correlation is positive) while keeping &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; “away” from &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt;’s. Formally,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_z &amp;amp;\quad \text{corr}^+(z,r) \\&#xA;\text{s.t.} &amp;amp;\quad \text{corr}(z,u_i)\leq a_i,\ i = 1, \dots, k&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\text{corr}(z,r) \stackrel{\text{def}}{=} \frac{z^T r}{\sqrt{z^Tz}\sqrt{r^Tr}}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\text{corr}^+(z,r) \stackrel{\text{def}}{=} \max(0, \text{corr}(z,r))$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$0 \leq a_i \leq 1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The trouble is that the constraints are non-convex. Any leads? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="9627" LastEditorUserId="9627" LastEditDate="2022-04-29T14:21:40.913" LastActivityDate="2022-04-29T21:47:21.410" Title="Maximize correlation subject to nonconvex correlation constraints" Tags="|convex-optimization|nonconvex-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8329" PostTypeId="2" ParentId="8328" CreationDate="2022-04-29T01:10:47.110" Score="8" Body="&lt;p&gt;You could add the non-convex constraint &lt;span class=&quot;math-container&quot;&gt;$z^Tz = 1$&lt;/span&gt;. That would make the objective function and other constraints linear. So this would be a Linear Programming problem, but for a single non-convex equality constraint. Use either a global non-convex optimization solver (if the problem can be solved fast enough) or local non-convex optimization solver to solve it.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-04-29T01:59:09.007" LastActivityDate="2022-04-29T01:59:09.007" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8330" PostTypeId="1" CreationDate="2022-04-29T01:45:08.477" Score="2" ViewCount="1356" Body="&lt;p&gt;I want to use conditions to my variable.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar boolean x[I][J][K][L]&#xA;dvar in h[i]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;my code is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;forall(i in IP, j in J)&#xA;  sum(k in K, l in L)&#xA;   x[i][j][k][l] - 7 == h[i];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The following condition must be satisfied:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if x[i][j][k][l] - 7 &amp;lt;=0, h[i] must be zero.&#xA;if x[i][j][k][l] - 7 &amp;gt;=0, h[i] must be calculated&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How do we formulate it in the integer programming formulation on CPLEX?&lt;/p&gt;&#xA;&lt;p&gt;Thank you for your answer.&lt;/p&gt;&#xA;" OwnerUserId="9629" LastEditorUserId="500" LastEditDate="2022-04-29T14:20:58.970" LastActivityDate="2022-05-10T07:15:40.963" Title="How to use condition in cplex?" Tags="|linear-programming|modeling|cplex|linearization|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8331" PostTypeId="2" ParentId="8330" CreationDate="2022-04-29T06:23:01.820" Score="1" Body="&lt;p&gt;Below is one way to formulate it. Need to introduce another binary variable (&lt;span class=&quot;math-container&quot;&gt;$\delta_{i,j}$&lt;/span&gt;). &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; depends on bounds of &lt;span class=&quot;math-container&quot;&gt;$h_{i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,k,l}$&lt;/span&gt; :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\sum_{k,l} x_{i,j,k,l}-7 &amp;amp;\le h_{i} + M \cdot (1-\delta_{i,j})\\&#xA;\sum_{k,l} x_{i,j,k,l}-7 &amp;amp;\ge h_{i} - M \cdot (1-\delta_{i,j}) \\&#xA;\sum_{k,l} x_{i,j,k,l}-7 &amp;amp;\le M \cdot \delta_{i,j}\\&#xA;\sum_{k,l} x_{i,j,k,l}-7 &amp;amp;\ge  -M \cdot (1-\delta_{i,j})&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Regarding CPLEX code, you need to add these constraints similar to declaration in your code (provided in question).&lt;/p&gt;&#xA;" OwnerUserId="5880" LastEditorUserId="5880" LastEditDate="2022-04-29T06:42:16.217" LastActivityDate="2022-04-29T06:42:16.217" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8332" PostTypeId="2" ParentId="8330" CreationDate="2022-04-29T14:20:12.433" Score="3" Body="&lt;p&gt;It looks like you want to enforce &lt;span class=&quot;math-container&quot;&gt;$h_i = \max(\sum_{k,l} x_{i,j,k,l}-7, 0)$&lt;/span&gt;.  Some solvers will automatically linearize this.  Depending on where &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt; appears elsewhere in the problem, you might be able to get by with enforcing instead &lt;span class=&quot;math-container&quot;&gt;$h_i \ge \max(\sum_{k,l} x_{i,j,k,l}-7, 0),$&lt;/span&gt;&#xA;which you can do without introducing new variables, by imposing&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;h_i &amp;amp;\ge \sum_{k,l} x_{i,j,k,l}-7 \tag1\\&#xA;h_i &amp;amp;\ge 0 \tag2&#xA;\end{align}&lt;/span&gt;&#xA;If necessary, you can also enforce &lt;span class=&quot;math-container&quot;&gt;$h_i \le \max(\sum_{k,l} x_{i,j,k,l}-7, 0)$&lt;/span&gt;&#xA;by introducing binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta_{i,j}$&lt;/span&gt; (as in the proposed formulation by @anjikum) and imposing&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;h_i &amp;amp;\le \sum_{k,l} x_{i,j,k,l} - 7\delta_{i,j} \tag3\\&#xA;h_i &amp;amp;\le (M_{i,j}-7)\delta_{i,j} \tag4&#xA;\end{align}&lt;/span&gt;&#xA;Here, &lt;span class=&quot;math-container&quot;&gt;$M_{i,j}$&lt;/span&gt; is a small constant upper bound on &lt;span class=&quot;math-container&quot;&gt;$\sum_{k,l} x_{i,j,k,l}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-04-29T14:38:07.397" LastActivityDate="2022-04-29T14:38:07.397" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8333" PostTypeId="1" AcceptedAnswerId="8334" CreationDate="2022-04-29T17:07:32.410" Score="7" ViewCount="2091" Body="&lt;p&gt;I would like to know which is a good theoretical book to study integer programming and mixed integer programming. Searching I found a large number of books, however each with different approaches.&lt;/p&gt;&#xA;&lt;p&gt;The approach I want to take is theoretical, starting with the linear integer and mixed integer problems. And at the end of the theoretical framework see its applications (which can suddenly be found in another book).&lt;/p&gt;&#xA;" OwnerUserId="9635" LastEditorUserId="491" LastEditDate="2022-05-01T00:13:36.650" LastActivityDate="2022-05-01T00:13:36.650" Title="Books for integer and mixed integer programming" Tags="|mixed-integer-programming|books|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8334" PostTypeId="2" ParentId="8333" CreationDate="2022-04-29T17:56:38.310" Score="13" Body="&lt;p&gt;I don't think you can start studying (mixed) integer programming without a solid understanding of Linear Programming. I would first read these 2 books:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Linear Programming by Chvátal&lt;/li&gt;&#xA;&lt;li&gt;Introduction to Linear Optimization by Bertsimas and Tsitsiklis&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The first book as by far the easiest to read book on Linear Programming. The 2nd book is a more rigorous introduction and bridges the gap to Integer Programming.&lt;/p&gt;&#xA;&lt;p&gt;If you need even more information, consider reading:&lt;/p&gt;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Optimization over Integers by Bertsimas&lt;/li&gt;&#xA;&lt;li&gt;Integer Programming by Conforti, Cornuéjols, Zambelli&lt;/li&gt;&#xA;&lt;li&gt;Integer and Combinatorial Optimization by Nemhauser and Wolsey&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Those last 2 books are very good, but not exactly light-weight reading material.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="500" LastEditDate="2022-04-29T18:09:17.357" LastActivityDate="2022-04-29T18:09:17.357" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8336" PostTypeId="2" ParentId="8322" CreationDate="2022-04-30T02:16:58.267" Score="6" Body="&lt;h2&gt;Understanding the Pareto frontier&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;In your question, you say that &amp;quot;we have the Pareto frontier.&amp;quot; This makes your question difficult to parse, because the object that represents the tradeoff between competing objectives &lt;em&gt;is&lt;/em&gt; the Pareto frontier.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here is an example from the relevant &lt;a href=&quot;https://en.wikipedia.org/wiki/Pareto_front&quot; rel=&quot;noreferrer&quot;&gt;Wikipedia page&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vkBl8.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vkBl8.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Each square in the picture represents a feasible solution &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, and they are plotted in &lt;span class=&quot;math-container&quot;&gt;$f_2, f_1$&lt;/span&gt; space. There are some points, like the one marked C, that are obviously inoptimal no matter how you appraise the relative importance of the two objectives, because point A has a better value in &lt;em&gt;both&lt;/em&gt; objectives. (Here &amp;quot;better&amp;quot; means &amp;quot;lower&amp;quot;: Wiki is assuming a minimization problem.) In other words, C is &lt;em&gt;dominated by&lt;/em&gt; A.&lt;/p&gt;&#xA;&lt;h2&gt;Why your question cannot be answered by a single number&lt;/h2&gt;&#xA;&lt;p&gt;You asked,&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;How many units of objective 1 do I need to reduce, in order to improve objective 2 by one unit?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Examining the graph, we can see that the slope of the Pareto frontier between points A and B is about &lt;span class=&quot;math-container&quot;&gt;$-2/3$&lt;/span&gt;. &lt;strong&gt;In other words, to improve (lower) objective 2 by 1 unit, we need to sacrifice (increase) objective 1 by about 2/3 of a unit.&lt;/strong&gt; In other words, the &amp;quot;tradeoff coefficient&amp;quot; &lt;em&gt;at this location on the Pareto frontier&lt;/em&gt; is &lt;span class=&quot;math-container&quot;&gt;$z = 2/3$&lt;/span&gt;. (&lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is not a standard symbol for this; I chose it arbitrarily.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Your question suggests that you would like to know a single value of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; that describes the tradeoff for the whole optimization problem. But the graph above makes it clear that &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; varies in different regions of the Pareto frontier.&lt;/strong&gt; In the upper left corner, where &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt; is prioritized over &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt;, we have &lt;span class=&quot;math-container&quot;&gt;$z \approx 2$&lt;/span&gt;, whereas it is closer to &lt;span class=&quot;math-container&quot;&gt;$z \approx 1/2$&lt;/span&gt; as we move to the bottom right.&lt;/p&gt;&#xA;&lt;p&gt;If it seems strange that your question can't be answered by a single value, consider the following question, which is analogous to yours:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;How much does the function &lt;span class=&quot;math-container&quot;&gt;$f(x) = x^2$&lt;/span&gt; increase when &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; increases by one unit?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The answer depends on which &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; you choose! If &lt;span class=&quot;math-container&quot;&gt;$x = 1$&lt;/span&gt;, the change in &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; or slope is &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;; if &lt;span class=&quot;math-container&quot;&gt;$x = -5$&lt;/span&gt;, the slope is &lt;span class=&quot;math-container&quot;&gt;$-10$&lt;/span&gt;; in general, the slope is the derivative &lt;span class=&quot;math-container&quot;&gt;$f'(x) = 2x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Why &amp;quot;regression&amp;quot;&lt;/h2&gt;&#xA;&lt;p&gt;Nonetheless, &lt;strong&gt;you may wish to describe the &lt;em&gt;average&lt;/em&gt; slope of the Pareto frontier in some region of interest. This is not technically difficult.&lt;/strong&gt; For example, we can plug all the &lt;span class=&quot;math-container&quot;&gt;$f_2, f_1$&lt;/span&gt; coordinates from the graph above into a linear regression, which will determine a straight line (i.e. a curve of constant slope) that approximates the Pareto frontier, and then report this line's slope.&lt;/p&gt;&#xA;&lt;p&gt;But &lt;strong&gt;in an operational context, this is seldom the best approach.&lt;/strong&gt; Presumably, there is some point along the Pareto frontier that represents the status quo. For example, if the decision variable is a production schedule, and &lt;span class=&quot;math-container&quot;&gt;$\bar x$&lt;/span&gt; is the current production schedule, you could plot &lt;span class=&quot;math-container&quot;&gt;$f_1(\bar x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2(\bar x)$&lt;/span&gt; onto the canvas above, identify the nearest point on the Pareto frontier, and compute the slope &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; in that region. Now you can tell your boss, &lt;strong&gt;&amp;quot;Reducing customer wait times (&lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt;) by one minute relative to the current schedule will cost (&lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt;) us &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; thousand dollars.&amp;quot; If you had computed the average slope instead, you would not be able to make such a precise statement.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;h2&gt;Discreteness&lt;/h2&gt;&#xA;&lt;p&gt;You mentioned in a comment that your problem is a discrete problem, an MIP. &lt;strong&gt;This doesn't make any practical difference in this context.&lt;/strong&gt; While there are some continuous problems for which we can express the Pareto frontier in a parametric form, and therefore take derivatives and determine the slope exactly, in practice, the typical way to solve multi-objective optimization problems (even for continuous problems) is to maximize&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$(1 - t) f_1(x) + t f_2(x) \tag{1} \label{1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for a variety of &lt;span class=&quot;math-container&quot;&gt;$t \in [0, 1]$&lt;/span&gt;, say &lt;span class=&quot;math-container&quot;&gt;$t = 0.0, 0.05, 0.10, \dots, 1.0$&lt;/span&gt;. Plotting &lt;span class=&quot;math-container&quot;&gt;$f_1(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2(x)$&lt;/span&gt; at each of the associated optima will give you a plot like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2drvD.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2drvD.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;... which is just the Pareto frontier, and we can easily estimate the slope by computing it between two adjacent points, or get the average slope by running a linear regression.&lt;/p&gt;&#xA;&lt;p&gt;The fact that you have an MIP matters only in that solving &lt;span class=&quot;math-container&quot;&gt;$\eqref{1}$&lt;/span&gt; will require an MIP solver, and therefore take some (probably much) more time. So you might not be able to choose as many values of &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. But the tradeoff analysis is completely blind to this step.&lt;/p&gt;&#xA;" OwnerUserId="4463" LastActivityDate="2022-04-30T02:16:58.267" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8337" PostTypeId="1" CreationDate="2022-04-30T14:18:49.403" Score="5" ViewCount="1133" Body="&lt;p&gt;I am using Julia's &lt;code&gt;JuMP&lt;/code&gt; package to solve a cutting-plane method. Namely, I solve a sub-problem, find the most-violated constraint in the master problem, add that to the sub-problem and &lt;strong&gt;reoptimize&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My main problem is an exponential cone problem and I am using &lt;code&gt;MOSEK&lt;/code&gt; to solve it. I don't know if it helps, but I am also solving the dual problem by using the &lt;code&gt;Dualization&lt;/code&gt; package:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = Model(dual_optimizer(MosekTools.Optimizer))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My question is following: I am only defining the model once, and in each iteration I am adding only one constraint and optimizing the model again. Is it possible that, despite this, JuMP is solving the optimization problem from scratch each time? I am worried because the solver times increase drastically by time.&lt;/p&gt;&#xA;&lt;p&gt;If there is an option for using the previous solution (not just the optimal solution) in the next optimization stage? I had a look at &lt;code&gt;JuMP&lt;/code&gt; tutorials (e.g., &lt;a href=&quot;https://jump.dev/JuMP.jl/dev/tutorials/algorithms/cutting_stock_column_generation/#Solving-the-problem&quot; rel=&quot;noreferrer&quot;&gt;Column generation&lt;/a&gt;), and even there it looks like they are just &lt;code&gt;optimize!&lt;/code&gt; ing again.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="500" LastEditDate="2023-12-13T18:07:37.180" LastActivityDate="2023-12-13T18:07:37.180" Title="Julia JuMP successive optimization" Tags="|optimization|julia|cutting-planes|mosek|warm-start|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8338" PostTypeId="2" ParentId="8337" CreationDate="2022-04-30T14:42:37.133" Score="3" Body="&lt;p&gt;I am not familiar with &lt;code&gt;Julia&lt;/code&gt;, but you can search for &lt;code&gt;callback&lt;/code&gt; and &lt;code&gt;lazycut&lt;/code&gt; which allows you to add cutting plane in the optimization process.&lt;/p&gt;&#xA;&lt;p&gt;For example this link:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://jump.dev/JuMP.jl/stable/manual/callbacks/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://jump.dev/JuMP.jl/stable/manual/callbacks/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, as you can find on this page, this is not supported for &lt;code&gt;MOSEK&lt;/code&gt; by &lt;code&gt;JuMP&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8718" LastEditorUserId="8718" LastEditDate="2022-05-01T00:26:35.757" LastActivityDate="2022-05-01T00:26:35.757" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8339" PostTypeId="2" ParentId="8337" CreationDate="2022-04-30T22:33:48.000" Score="12" Body="&lt;p&gt;Your question has a two-part answer: how JuMP handles successive solves, and how the solvers handle successive solves.&lt;/p&gt;&#xA;&lt;h1&gt;How JuMP handles successive solves&lt;/h1&gt;&#xA;&lt;p&gt;Recall that JuMP is a modeling layer, not an optimization solver.&#xA;Therefore, when you build a problem in JuMP and then call &lt;code&gt;optimize!(model)&lt;/code&gt;, what JuMP does is it passes the model to the underlying solver, then calls that solver's API to solve the model and retrieve the solution.&lt;/p&gt;&#xA;&lt;p&gt;Thus, let's assume a workflow like build the model, solve, get the solution, add one or more constraints, solve again, get the solution add one or more constraints, solve again, get the solution, add one or more constraints, etc.&lt;/p&gt;&#xA;&lt;p&gt;What happens under the hood is the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;build the model&lt;/li&gt;&#xA;&lt;li&gt;call solver XXXX API to pass the model and solve it&lt;/li&gt;&#xA;&lt;li&gt;call solver XXXX API to retrieve the solution&lt;/li&gt;&#xA;&lt;li&gt;call solver XXXX API to add one or more constraints&lt;/li&gt;&#xA;&lt;li&gt;call solver XXXX API to solve the model&lt;/li&gt;&#xA;&lt;li&gt;call solver XXXX API to retrieve the solution&lt;/li&gt;&#xA;&lt;li&gt;etc...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There is nothing in JuMP's &lt;code&gt;optimize!&lt;/code&gt; function that does something specific in the case where &amp;quot;I have just solved a very similar version of the problem&amp;quot;: this is handled by the solver.&lt;/p&gt;&#xA;&lt;p&gt;Side note: by default, JuMP caches the model in JuMP-owned data structures before passing it to the solver when the user calls &lt;code&gt;optimize!&lt;/code&gt;, which may prevent incremental solves. To bypass this and hook into the solver's API directly, use &lt;a href=&quot;https://jump.dev/JuMP.jl/stable/manual/models/#Direct-mode&quot; rel=&quot;noreferrer&quot;&gt;direct mode&lt;/a&gt;. (if you have more questions on this, I would recommend you ask them on the &lt;a href=&quot;https://discourse.julialang.org/c/domain/opt/13&quot; rel=&quot;noreferrer&quot;&gt;Julia discourse forum&lt;/a&gt; as linked by odow)&lt;/p&gt;&#xA;&lt;h1&gt;How solvers handle successive solves&lt;/h1&gt;&#xA;&lt;p&gt;TLDR: it's solver-dependent. Some are able to re-use previous information, some aren't.&lt;/p&gt;&#xA;&lt;p&gt;In the case of Mosek and nonlinear problems: Mosek will solve nonlinear conic problems with its interior-point algorithm.&#xA;This algorithm is not able to warm-start, and as far as I know, Mosek's API does not permit to pass a warm-start solution anyway. They may do something smart internally, but it's not documented and the user probably has no control over it.&lt;/p&gt;&#xA;&lt;p&gt;This is a limitation of interior-point algorithms, not Mosek as a software.&#xA;An alternative is to use a first-order solver such as SCS or COSMO (see the &lt;a href=&quot;https://jump.dev/JuMP.jl/stable/installation/#Supported-solvers&quot; rel=&quot;noreferrer&quot;&gt;supported solvers in JuMP&lt;/a&gt;), which support warm-starts. However, they are first-order methods and may not give you the same precision as interior-point solvers.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2022-04-30T22:33:48.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8340" PostTypeId="2" ParentId="8180" CreationDate="2022-05-01T10:24:55.860" Score="1" Body="&lt;p&gt;You'd model it by biasing the optimiser's cost model, so it's cheaper for the normal vehicle to serve these nodes, and in the normal sequence. e.g. the cost of assigning node 3 to v1 is 0, but assigning node 3 to v2 instead costs 100. In the literature this is sometimes called 'affinities'. I would suggest you also start optimising from an initial solution that has the normal routes, and so the optimiser just adjusts them as needed if they're infeasible. I'm not sure whether the open source solvers like jsprit, OR tools would support all this. We support this in our commercial ODL Live optimiser, by overriding the cost of a stop for certain vehicles, adding additional costs to a stop based on what the preceding stop was, and starting optimisation from an initial (and potentially infeasible) solution.&lt;/p&gt;&#xA;" OwnerUserId="825" LastActivityDate="2022-05-01T10:24:55.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8341" PostTypeId="1" CreationDate="2022-05-01T12:06:34.627" Score="6" ViewCount="143" Body="&lt;p&gt;I am following 'Application of Number Theory to Numerical Analysis', and there is a section by G.H. Bradley called 'Modulo Optimization Problems and Integer Linear Programming'. There he explains that turns a modulo integer programming problem into an equivalent integer programming problem.&lt;/p&gt;&#xA;&lt;p&gt;However, I can't follow one part. Given a modulo integer program &lt;span class=&quot;math-container&quot;&gt;$Ax=b \mod k$&lt;/span&gt;, we usually turn it into &lt;span class=&quot;math-container&quot;&gt;$Ax + Ky = b$&lt;/span&gt;, and thus from &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; equations, &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables we get &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; equations, &lt;span class=&quot;math-container&quot;&gt;$m+n$&lt;/span&gt; variables. He then outlines a procedure so that we only have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables instead of &lt;span class=&quot;math-container&quot;&gt;$m+n$&lt;/span&gt;, and this part is a bit unclear to me.&lt;/p&gt;&#xA;&lt;p&gt;I don't necessarily have to follow Bradley's section, but I do not know much (yet) about operations research books. I would like to ask if someone knows an easier to read book/article where I can find this elimination of variables procedure.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I misquoted the number of variables and constraint change. It is from &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; constraints and &lt;span class=&quot;math-container&quot;&gt;$n+m$&lt;/span&gt; variables into &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; constraints. Still very good in some cases.&lt;/p&gt;&#xA;" OwnerUserId="7498" LastEditorUserId="7498" LastEditDate="2022-05-03T09:11:51.503" LastActivityDate="2022-05-03T09:32:15.147" Title="Modulo Integer Programming, $m$ equations $n$ variables" Tags="|integer-programming|reference-request|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8342" PostTypeId="1" AcceptedAnswerId="8343" CreationDate="2022-05-02T11:58:54.617" Score="4" ViewCount="209" Body="&lt;p&gt;For a Resource-Constrained-Project-Scheduling problem, I need to calculate Critical-Path-Method (CPM) values for each of the activities. These values are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Earliest Start (ES)&lt;/li&gt;&#xA;&lt;li&gt;Earliest Finish (EF)&lt;/li&gt;&#xA;&lt;li&gt;Latest Start (LS)&lt;/li&gt;&#xA;&lt;li&gt;Latest Finish (LF)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The activity network can be represented by an Activity On Node diagram, which is a directed graph &lt;span class=&quot;math-container&quot;&gt;$G = (V,A)$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$V = \{1,2,\ldots, n\}$&lt;/span&gt; being nodes that represent the activities, &lt;span class=&quot;math-container&quot;&gt;$A=\{(i,j)\}$&lt;/span&gt; being the arcs indicating the end-start precedences between node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. Furthermore, it is assumed that the network is such that node &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; is a source and node &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is a sink node. This means that all nodes can be reached from node &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; by a path and node &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is reachable from all nodes by a path.&lt;/p&gt;&#xA;&lt;p&gt;The ES and EF values can then be calculated by a forward pass, where &lt;span class=&quot;math-container&quot;&gt;$ES_0 = 0$&lt;/span&gt;. The LS and LF values can thereafter be calculated by a backward pass with &lt;span class=&quot;math-container&quot;&gt;$LF_n = EF_n$&lt;/span&gt;. I use a topological ordering of the nodes in order to do this correctly. Python pseudo-code for this procedure is as follows, where &lt;code&gt;p&lt;/code&gt; denotes the duration of an activity and &lt;code&gt;G_reverse&lt;/code&gt; is the original graph &lt;code&gt;G&lt;/code&gt; where the precedences are reversed:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;# Forward pass ==================&#xA;Stack = topologicalSort(G)&#xA;ES[0] = 0&#xA;&#xA;while len(Stack) &amp;gt; 0:&#xA;   u = Stack[0]&#xA;   del Stack[0]&#xA;   if ES[u] = updated:&#xA;      for i in successors[u]:&#xA;         ES[i] = max(ES[i], ES[u] + p[u])&#xA;&#xA;EF = [ES[i] + p[i] for i in range(n)]&#xA;&#xA;# Backward pass ==================&#xA;Stack = topologicalSort(G_reverse)&#xA;LF[n] = EF[n]&#xA;&#xA;while len(Stack) &amp;gt; 0:&#xA;   u = Stack[0]&#xA;   del Stack[0]&#xA;   if LF[u] = updated:&#xA;      for i in predecessors[u]:&#xA;         LF[i] = min(LF[i], LF[u] - p[u])&#xA;&#xA;LS = [LF[i] - p[i] for i in range(n)]&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In my project, I am continuously adding new precedences &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; to the graph (one by one), after which at each time I need to know the new LF time values of all activities. E.g. in the following example, the precedence &lt;span class=&quot;math-container&quot;&gt;$(3,4)$&lt;/span&gt; is added to the original graph.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sjFcv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sjFcv.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Currently, I do this by recalculating the ES, EF, LS and LF values each time for all nodes. Since this is an expensive part of my algorithm, I am wondering if this can be done more efficiently, e.g. by knowing beforehand which nodes will not have to be updated and exploiting this.&lt;/p&gt;&#xA;" OwnerUserId="7399" LastEditorUserId="7399" LastEditDate="2022-05-02T12:26:50.450" LastActivityDate="2022-05-02T14:43:24.953" Title="Efficiently updating latest finish times via Critical-Path-Method" Tags="|algorithms|graphs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8343" PostTypeId="2" ParentId="8342" CreationDate="2022-05-02T14:43:24.953" Score="4" Body="&lt;p&gt;The added precedence (arc) will only affect ES and EF for the head node of the arc (node 4 in your example) and its descendants. So you can limit the ES/EF updates to all paths from the head node to the sink node. If the added arc does not change the ES/EF of the head node, no forward updates would be needed. If you do need to process paths from head node to sink, any time you bump into a node whose ES/EF does not change you can skip the remainder of any paths through it to the sink.&lt;/p&gt;&#xA;&lt;p&gt;Assuming you do in fact update some ES/EF values, if the &lt;span class=&quot;math-container&quot;&gt;$EF_n$&lt;/span&gt; does not change, you do not need a backward pass. If &lt;span class=&quot;math-container&quot;&gt;$EF_n$&lt;/span&gt; increases, you will need to do the backward pass to update LS/LF values. I don't think there is a way to avoid a full backward pass, with the qualification that if LS/LF does not change at any node, you do not need to scan backward from that node.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-02T14:43:24.953" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8344" PostTypeId="1" CreationDate="2022-05-02T16:58:41.863" Score="2" ViewCount="55" Body="&lt;p&gt;I have a least squares problem of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_{\vec{a}}&amp;amp;\quad\|\vec{y} - X\vec{a}\|^2 \\\text{s.t.}&amp;amp;\quad\|\vec{a}_{I}\|^2 \leq 1,\\&amp;amp;\quad I \in A\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\vec{a}_{I}$&lt;/span&gt; denotes a subvector of &lt;span class=&quot;math-container&quot;&gt;$\vec{a}$&lt;/span&gt; with indices &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; a set of sets, and all &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; are non overlapping.&lt;/p&gt;&#xA;&lt;p&gt;I know that coordinate descent does usually not work on constraint least squares problems, such as with linear constraints. However, I was wondering if this also holds for these kind of quadratic constraints? Can we solve such problems with coordinate descent followed by a projection if necessary or will we run into some situation where we get stuck?&lt;/p&gt;&#xA;" OwnerUserId="9645" LastEditorUserId="123" LastEditDate="2022-05-02T18:51:17.980" LastActivityDate="2022-05-02T18:51:17.980" Title="Coordinate descent for constrained least squares" Tags="|optimization|convex-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8345" PostTypeId="2" ParentId="8318" CreationDate="2022-05-02T21:08:50.340" Score="2" Body="&lt;p&gt;I see multiple approaches.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An interior point NLP solver like Ipopt&lt;/li&gt;&#xA;&lt;li&gt;An sparse SQP solver like &lt;a href=&quot;https://worhp.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;WORH&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Variable elimination, for every equality constraint you can eliminate one variable, then you should be left with an unconstrained problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-05-02T21:08:50.340" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8346" PostTypeId="1" AcceptedAnswerId="8347" CreationDate="2022-05-02T21:29:31.577" Score="3" ViewCount="319" Body="&lt;p&gt;The exponential cone is define such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$(x, y, z) \in \text{ExpCone: if }  y \exp(x / y) \leq z \land y &amp;gt; 0.$&lt;/span&gt; The inequality &lt;span class=&quot;math-container&quot;&gt;$\exp(a) \leq b$&lt;/span&gt; can be expressed as &lt;span class=&quot;math-container&quot;&gt;$[a, 1, b] \in \text{ExpCone}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How do i write &lt;span class=&quot;math-container&quot;&gt;$\exp(a) = b$&lt;/span&gt; using cone programming?&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-05-02T21:46:40.747" Title="Express equality constraint involving exponentials cones" Tags="|convex-optimization|disciplined-convex-programming|cone|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8347" PostTypeId="2" ParentId="8346" CreationDate="2022-05-02T21:46:40.747" Score="11" Body="&lt;p&gt;&lt;strong&gt;Q&lt;/strong&gt;: &amp;quot;How do i write &lt;span class=&quot;math-container&quot;&gt;$\text{exp}(a) = b$&lt;/span&gt; using cone programming?&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;A&lt;/strong&gt; You don't.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{exp}(a) = b$&lt;/span&gt; is a nonlinear equality constraint, and is therefore non-convex.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{exp}(a) \le b$&lt;/span&gt; is convex. But to produce &lt;span class=&quot;math-container&quot;&gt;$\text{exp}(a) = b$&lt;/span&gt;, it would need to be paired with &lt;span class=&quot;math-container&quot;&gt;$\text{exp}(a) \ge b$&lt;/span&gt;, which is going in the wrong direction to be convex.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2022-05-02T21:46:40.747" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8348" PostTypeId="2" ParentId="8341" CreationDate="2022-05-03T09:27:10.353" Score="3" Body="&lt;p&gt;Very briefly, what Bradley did was to consider &lt;span class=&quot;math-container&quot;&gt;$P=\small\begin{bmatrix} A&amp;amp;K\\Id&amp;amp;0 \end{bmatrix}$&lt;/span&gt;. We can then find a uni-modular matrix &lt;span class=&quot;math-container&quot;&gt;$Q=\small\begin{bmatrix} Q1&amp;amp;Q2\\Q3&amp;amp;Q4 \end{bmatrix}$&lt;/span&gt;, where the product &lt;span class=&quot;math-container&quot;&gt;$PQ$&lt;/span&gt; will be a matrix in HNF, &lt;span class=&quot;math-container&quot;&gt;$PQ=\small\begin{bmatrix} R_1&amp;amp;0\\R_2&amp;amp;H \end{bmatrix}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is uni-modular, we can then perform a substitution &lt;span class=&quot;math-container&quot;&gt;$\begin{bmatrix} x\\y\end{bmatrix}=\small\begin{bmatrix} Q1&amp;amp;Q2\\Q3&amp;amp;Q4 \end{bmatrix}\begin{bmatrix} u\\z\end{bmatrix}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;When we substitute the above equation, we will have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\small\begin{bmatrix} R_1&amp;amp;0\\R_2&amp;amp;H \end{bmatrix}\begin{bmatrix} u\\z\end{bmatrix} \circ \begin{bmatrix} b\\1\end{bmatrix},&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\circ$&lt;/span&gt; is an equality for &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. We have the &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt; due to the fact that in Modulo Optimization Problem, &lt;span class=&quot;math-container&quot;&gt;$0 \leq x \leq 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;From here, we just take &lt;span class=&quot;math-container&quot;&gt;$u= R_1^{-1}b$&lt;/span&gt;, and substitute. We will see that we have a constant in the objective function that we can ignore, and that we have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;0 \leq R_2R_1^{-1}b + Hz \leq 1\\&#xA;z \ \texttt{integer}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But really the constraints are now &lt;span class=&quot;math-container&quot;&gt;$-R_2R_1^{-1}b \leq Hz \leq -R_2R_1^{-1}b + 1$&lt;/span&gt;. You can verify that &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt;. Bradley said that the initial system of modulo equations is consistent (solvable?) if and only if &lt;span class=&quot;math-container&quot;&gt;$u=R_1^{-1}b$&lt;/span&gt; is integer, which I haven't figured out why (tho I was exhausted when I was doing this, wasn't really in my best form).&lt;/p&gt;&#xA;" OwnerUserId="7498" LastEditorUserId="7498" LastEditDate="2022-05-03T09:32:15.147" LastActivityDate="2022-05-03T09:32:15.147" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8349" PostTypeId="2" ParentId="8324" CreationDate="2022-05-03T12:25:35.197" Score="2" Body="&lt;p&gt;This is one way you can formulate/model the problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;x_{i,t} &amp;amp;\in R^{+} \text{ variable denoting amount of raw material $i$ processed/out in time $t$}\\&#xA;q_{i,t} &amp;amp;\in R^{+} \text{ variable denoting leftover raw material $i$ at end of time $t$}\\&#xA;I_{i,t} &amp;amp;\in R^{+} \text{ Parameter denoting amount of raw material $i$ that is provided in time $t$}&#xA;\end{align*}&#xA;$$&lt;/span&gt;&#xA;Quantity of raw material &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; processed/out in time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is less than available inventory &amp;amp; left over inventory needs to carry-forward&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;x_{i,t}+q_{i,t} &amp;amp;= I_{i,t} \qquad \qquad \forall i,t | t= 0 \\&#xA;x_{i,t}+q_{i,t} &amp;amp;=  q_{i,t-1} + I_{i,t} \quad \forall i,t|t&amp;gt; 0&#xA;\end{align*}&#xA;$$&lt;/span&gt;&#xA;Limit on processing capacity&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\sum_{i} x_{i,t} &amp;amp;\le C^{\text{max}} \qquad \qquad  \forall t&#xA;\end{align*}&lt;/span&gt;&#xA;Objective is minimize left over of each week to get the behaviour required for total quantity processed across all materials &amp;amp; times&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\text{minimize} \sum_{i,t} q_{i,t}&#xA;$$&lt;/span&gt;&#xA;Note: As per your formulation, openLine[i] can always take 1 for each time period and binary is not needed as per requirement.&lt;/p&gt;&#xA;" OwnerUserId="5880" LastActivityDate="2022-05-03T12:25:35.197" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8350" PostTypeId="1" CreationDate="2022-05-03T16:42:58.057" Score="4" ViewCount="399" Body="&lt;p&gt;I developed a mathematical model that contains several thousand of binary variables (in addition to several thousand continuous variables).&lt;/p&gt;&#xA;&lt;p&gt;The binary variables model different things, say &lt;span class=&quot;math-container&quot;&gt;$X(i)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Y(j)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Z(k)$&lt;/span&gt;, ...  I made the observation, that if I fix the binaries of type &lt;span class=&quot;math-container&quot;&gt;$X(i)$&lt;/span&gt; to their optimal value (even a subset of those) and optimize for the rest of the variables then I obtain the optimal solution to the problem very fast. Without this fixing, the solution time is very long.&lt;/p&gt;&#xA;&lt;p&gt;The problem is that for a new setting of the problem, I don't know the optimal values &lt;span class=&quot;math-container&quot;&gt;$X(i)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone have an idea of how I could exploit the knowledge that if I get the optimal values for &lt;span class=&quot;math-container&quot;&gt;$X(i)$&lt;/span&gt; the problem becomes easy?&lt;/p&gt;&#xA;&lt;p&gt;I tried setting high branching priorities for the &lt;span class=&quot;math-container&quot;&gt;$X(i)$&lt;/span&gt; variables but this doesn't really help. Optimizing only for &lt;span class=&quot;math-container&quot;&gt;$X(i)$&lt;/span&gt; doesn't help either.&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="491" LastEditDate="2022-05-03T17:04:32.630" LastActivityDate="2022-05-04T08:38:34.790" Title="Trying to accelerate MILP solution" Tags="|mixed-integer-programming|modeling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8351" PostTypeId="2" ParentId="8350" CreationDate="2022-05-03T18:13:53.117" Score="3" Body="&lt;p&gt;First, knowing that fixing &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; makes solution faster may not give you any leverage whatsoever. Consider a MIP model with binary variables &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and all other variables continuous. If you fix &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; at optimal values, the rest is an LP that solves quickly. That fact tells you nothing about &lt;em&gt;how&lt;/em&gt; to fix the values of &lt;span class=&quot;math-container&quot;&gt;$X.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Second, high branching priorities for &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a sound thing to try. The fact that it didn't help means either (a) the solver is already prioritizing branching on &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, (b) branching on &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; does not immediately result in much pruning of nodes or (c) both.&lt;/p&gt;&#xA;&lt;p&gt;Hypothetically there might be a way to combine prioritization of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; with something else, but that would be model-specific, so not something easily suggested with what we have to go on.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-03T18:13:53.117" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8352" PostTypeId="2" ParentId="8318" CreationDate="2022-05-03T18:53:51.970" Score="2" Body="&lt;p&gt;Don't use an optimization solver. Use a linear system solver.&lt;/p&gt;&#xA;&lt;p&gt;The Lagragian of your problem is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L(x; \lambda) = \sum x_{i}^{T} \mathbf{1} \mathbf{1}^{T} x_{i} - \lambda^{T}(\sum A_{i} x_{i} - b)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With respect to the primal variable you have stationarity when&#xA;&lt;span class=&quot;math-container&quot;&gt;$$2 \mathbf{1} \mathbf{1}^{T} \left(\sum x_{i}\right) - (\sum A_{i}^{T}) \lambda = 0$$&lt;/span&gt;&#xA;Combine this with your constraint &lt;span class=&quot;math-container&quot;&gt;$\sum A_{i} x_{i} = b$&lt;/span&gt; to get the following linear system&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\left(\begin{array}{cccc}  2 \mathbf{1} \mathbf{1}^{T} &amp;amp; \cdots &amp;amp;  2 \mathbf{1}\mathbf{1}^{T}  &amp;amp; -\sum A_{i}^{T}\\&#xA;A_{1} &amp;amp; \cdots &amp;amp; A_{n} &amp;amp; \mathbf{0}  \end{array}\right) \left(\begin{array}{c} x_{1} \\ \vdots \\ x_{n} \\ \lambda \end{array}\right) = \left(\begin{array}{c} 0\\ b\end{array} \right).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Solve it using your language of choice to get your solution.&lt;/p&gt;&#xA;" OwnerUserId="3066" LastActivityDate="2022-05-03T18:53:51.970" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8353" PostTypeId="1" AcceptedAnswerId="8359" CreationDate="2022-05-03T19:03:19.333" Score="5" ViewCount="1368" Body="&lt;p&gt;I know there are ways to handle Knapsack problems with &lt;a href=&quot;https://cs.stackexchange.com/questions/144449/knapsack-like-problem-with-nonnegative-weight-constraint/144453#144453&quot;&gt;negative weights&lt;/a&gt; or &lt;a href=&quot;https://cs.stackexchange.com/questions/123553/knapsack-problem-with-exact-required-item-number-constraint&quot;&gt;cardinality constraints&lt;/a&gt;, but I have a problem with also negative values as well as a cardinality constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max &amp;amp; \sum_{i\in N} u_i x_i \\&#xA;\text{s.t.} &amp;amp; \sum_{i\in N} w_i x_i \le W \\&#xA;&amp;amp; \sum_{i\in N} x_i = C \\&#xA;&amp;amp; x_i \in \{0,1\}, \forall i \in N&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; can both be positive or negative. Wonder if this could be formulated as a standard Knapsack problem?&lt;/p&gt;&#xA;" OwnerUserId="9647" LastEditorUserId="491" LastEditDate="2022-05-03T19:45:16.697" LastActivityDate="2022-05-05T04:58:47.977" Title="Knapsack problem with negative value and weights and cardinality constraint" Tags="|combinatorial-optimization|knapsack|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8354" PostTypeId="1" AcceptedAnswerId="8471" CreationDate="2022-05-04T05:16:26.623" Score="4" ViewCount="226" Body="&lt;p&gt;I am working on a crew scheduling problem formulated as a MIP binary optimization where each employee is represented by a binary variable &lt;span class=&quot;math-container&quot;&gt;$X_{ids}$&lt;/span&gt; s.t. &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;th employee, &lt;span class=&quot;math-container&quot;&gt;$d \in D$&lt;/span&gt; is the day number and &lt;span class=&quot;math-container&quot;&gt;$s \in S$&lt;/span&gt; is the shift (ex: 9AM-12PM) and if the employee is scheduled to work on that day at that shift the variable is 1 otherwise 0.&lt;/p&gt;&#xA;&lt;p&gt;The set &lt;span class=&quot;math-container&quot;&gt;$I = \bigcup J_i$&lt;/span&gt; subsets such that &lt;span class=&quot;math-container&quot;&gt;$J_i$&lt;/span&gt; partition the set &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; and where each &lt;span class=&quot;math-container&quot;&gt;$J_i$&lt;/span&gt; represents a subset of priority employees.  For example if &lt;span class=&quot;math-container&quot;&gt;$i \in [1,2,3]$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$J_1$&lt;/span&gt; takes precedence over &lt;span class=&quot;math-container&quot;&gt;$J_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J_2$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$J_3$&lt;/span&gt; in terms of shift scheduling.  I want to enforce this condition via the constraints in the optimization instead of the objective function coefficients, but am unsure how to do so.  The sets &lt;span class=&quot;math-container&quot;&gt;$J_i$&lt;/span&gt; that partition the set &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; are pre-defined.  I'd like to keep this as a linear optimization due to the size of the original problem.&lt;/p&gt;&#xA;" OwnerUserId="4581" LastActivityDate="2022-05-31T20:13:05.523" Title="crew scheduling problem with shift priority hard constraints" Tags="|mixed-integer-programming|scheduling|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8355" PostTypeId="2" ParentId="8318" CreationDate="2022-05-04T05:39:59.927" Score="4" Body="&lt;p&gt;Depending on the convex sets it maybe possible to pose the problem as a conic optimization problem. In the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek modeling cookbook&lt;/a&gt; you can see what you can formulated on conic form. The resulting conic optimization problem can be solved using an interior-point optimizer e.g. &lt;a href=&quot;https://mosek.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek&lt;/a&gt;. This approach exploits the convexity.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2022-05-04T05:39:59.927" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8356" PostTypeId="1" AcceptedAnswerId="8365" CreationDate="2022-05-04T07:21:25.050" Score="7" ViewCount="898" Body="&lt;p&gt;I am applying Benders decomposition and the dual is unbounded. I need to find the extreme rays to proceed, but I am not sure how to do that. Following is an example problem, can someone explain how the extreme rays (3,2) (1,3) were found in this example (graphically or simplex method)? I know how to find the extreme points, but don't know how to find the extreme rays.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$U=\{u\in\mathbb{R}_+^2 : 4u_1+2u_2\geq2, -2u_1+3u_2\geq-3, 3u_1-u_2\geq1\}$$&lt;/span&gt;&#xA;has extreme points &lt;span class=&quot;math-container&quot;&gt;$(\frac25,\frac15)^T,(\frac12,0)^T,(\frac32,0)^T$&lt;/span&gt; and extreme rays &lt;span class=&quot;math-container&quot;&gt;$(3,2)^T,(1,3)^T$&lt;/span&gt; giving the extended formulation :&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$U=\{u\in\mathbb{R}^2 :u=\begin{pmatrix}\frac25 \\\frac15 \\\end{pmatrix}\lambda_1+\begin{pmatrix}\frac12 \\0 \\\end{pmatrix}\lambda_2+\begin{pmatrix}\frac32 \\0 \\\end{pmatrix}\lambda_3+\begin{pmatrix}3\\2\\\end{pmatrix}\mu_1+\begin{pmatrix}1\\3\\\end{pmatrix}\mu_2, \\ \ \\ \lambda_1+\lambda_2+\lambda_3=1, (\lambda,\mu)\in\mathbb{R}_+^3\times\mathbb{R}_+^2\} \qquad\qquad\qquad\Box$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="9649" LastEditorUserId="500" LastEditDate="2022-05-23T18:38:24.253" LastActivityDate="2022-05-23T18:38:24.253" Title="How to find extreme rays" Tags="|benders-decomposition|extreme-rays|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8357" PostTypeId="1" AcceptedAnswerId="8360" CreationDate="2022-05-04T08:18:31.423" Score="0" ViewCount="186" Body="&lt;p&gt;Is there an example of an &lt;span class=&quot;math-container&quot;&gt;$m\times n$&lt;/span&gt; integer matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and an integer vector &lt;span class=&quot;math-container&quot;&gt;$b\in \mathbb {Z}^{m}$&lt;/span&gt; such that the polyhedron &lt;span class=&quot;math-container&quot;&gt;$P := \{ x\in \mathbb {R}^{n} \mid A x \leq b\}$&lt;/span&gt; is integer, while &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is &lt;em&gt;not&lt;/em&gt; totally unimodular?&lt;/p&gt;&#xA;&lt;p&gt;Note that a polyhedron is integer if all of its vertices are integral.&lt;/p&gt;&#xA;" OwnerUserId="9650" LastActivityDate="2022-05-06T14:25:57.117" Title="On the non-sufficiency of total unimodularity of the constraint matrix in the definition of an integer polytope" Tags="|linear-programming|integer-programming|polyhedra|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8358" PostTypeId="2" ParentId="8350" CreationDate="2022-05-04T08:38:34.790" Score="4" Body="&lt;p&gt;You could try the &lt;em&gt;cut-and-solve&lt;/em&gt;-method proposed by &lt;a href=&quot;https://doi.org/10.1016/j.artint.2006.02.005&quot; rel=&quot;nofollow noreferrer&quot;&gt;Climer and Zhang 2006&lt;/a&gt;. The idea is roughly as follows&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Somehow guess a good cut, that will limit the freedom of the &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; variables.&lt;/li&gt;&#xA;&lt;li&gt;After guessing such a cut, you solve to optimality the problem defined by the feasible set removed by the cut.&lt;/li&gt;&#xA;&lt;li&gt;If this reduced problem has a feasible solution, it will give you a primal bound. Update best primal if necessary.&lt;/li&gt;&#xA;&lt;li&gt;Then you add the cut to your original problem, and obtain a dual bound for this modified problem.&lt;/li&gt;&#xA;&lt;li&gt;Now test if &lt;span class=&quot;math-container&quot;&gt;$(\text{best primal bound} - \text{dual bound})\leq 0$&lt;/span&gt; (minimization case). If so, you have solved your problem to optimality. Otherwise go back to 1.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The method is described in Figure 4 of the linked paper. I have had good luck using this method for problems where the problem after reducing the wiggle room of the &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;-variables is significantly easier to solve, than the original full problem.&lt;/p&gt;&#xA;&lt;p&gt;The idea is somewhat similar to local branching.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-05-04T08:38:34.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8359" PostTypeId="2" ParentId="8353" CreationDate="2022-05-04T15:15:44.443" Score="6" Body="&lt;p&gt;I assume you have a solver for knapsack problems with cardinality constraints, but it wants only non-negative coefficients.&lt;/p&gt;&#xA;&lt;p&gt;Let&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\color{darkblue}U_{min} := \min\{0,\color{darkblue}u_1,...,\color{darkblue}u_N\}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\color{darkblue}W_{min} := \min\{0,\color{darkblue}w_1,...,\color{darkblue}w_N\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now update:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \color{darkblue}u_i := \color{darkblue}u_i - \color{darkblue}U_{min} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \color{darkblue}w_i := \color{darkblue}w_i - \color{darkblue}W_{min} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \color{darkblue}W := \color{darkblue}W - \color{darkblue}C\cdot \color{darkblue}W_{min} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now you have a problem with all non-negative coefficients that yields the same solution.&lt;/p&gt;&#xA;&lt;p&gt;If you want the optimal objective value to be the same as for the original problem use:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \max \color{darkblue}C\cdot \color{darkblue}U_{min} + \sum_i \color{darkblue}u_i\cdot \color{darkred}x_i&#xA;$$&lt;/span&gt;&#xA;This adds a (non-positive) constant term to the objective and will now also replicate the same objective value. You can add this constant term after calling your knapsack solver.&lt;/p&gt;&#xA;&lt;p&gt;Of course, if you use something like a MIP or CP solver, you can feed it the original problem.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2022-05-05T04:58:47.977" LastActivityDate="2022-05-05T04:58:47.977" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8360" PostTypeId="2" ParentId="8357" CreationDate="2022-05-04T15:58:38.353" Score="5" Body="&lt;p&gt;The answer is yes, and the proof is trivial. Recall that a TUM matrix has all coefficients in &lt;span class=&quot;math-container&quot;&gt;$\lbrace -1, 0, 1\rbrace.$&lt;/span&gt; Start with any &lt;span class=&quot;math-container&quot;&gt;$P := \{ x\in \mathbb {R}^{n} \mid A x \leq b\}$&lt;/span&gt; that is integer. If &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; happens to be TUM, change &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$2A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$2b$&lt;/span&gt;. The polynomial is unchanged, but the new constraint matrix &lt;span class=&quot;math-container&quot;&gt;$2A$&lt;/span&gt; cannot be TUM since it will contain components of &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; and/or &lt;span class=&quot;math-container&quot;&gt;$-2$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-04T15:58:38.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8361" PostTypeId="1" CreationDate="2022-05-04T15:59:23.250" Score="3" ViewCount="85" Body="&lt;p&gt;I'm interested in solving the following system of equations over the integers:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;x_l^3 &amp;amp;\le x_l^1x_l^2 &amp;amp; \text{ for } l = 1,\ldots,s \\&#xA;A x &amp;amp;\le b \\&#xA;0 &amp;amp;\le x&#xA;\end{align*}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x_l^j$&lt;/span&gt; are components in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. There are &lt;a href=&quot;https://www.jstor.org/stable/2946479?seq=1&quot; rel=&quot;nofollow noreferrer&quot;&gt;methods&lt;/a&gt; to solve the case where &lt;span class=&quot;math-container&quot;&gt;$x_l^1 = x_l^2$&lt;/span&gt;. But I know of no analogous results for the &amp;quot;hyperbolic&amp;quot; case. My main interesting is in checking that there is a small solution.&lt;/p&gt;&#xA;" OwnerUserId="9655" LastActivityDate="2022-05-04T17:32:00.573" Title="Methods to solve integer linear inequalities with products of two variables" Tags="|linear-programming|reference-request|nonlinear-programming|nonconvex-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8362" PostTypeId="2" ParentId="8361" CreationDate="2022-05-04T17:32:00.573" Score="2" Body="&lt;p&gt;One classic technique is to reformulate the integer variables as a bunch of binary variables. In this case i would use a encoding with powers of 2 and then use a multiplier circuit to express the multiplication. Since multiplicaiton circuits are made out of ANDs and ORs the resulting problem will be MILP.&lt;/p&gt;&#xA;&lt;p&gt;Bi-linear terms (and also monomial terms which all can be expressed as nested bi-linear terms) can be over approximated using McCormick envelopes. Some MINLP solvers (i am aware that Alpine.jl does that) use this to express products.&lt;/p&gt;&#xA;&lt;p&gt;I would recommend throwing some MINLP solvers at is first and see how they do. If that proves infeasible see if you have success with a binary linear formulation and see if MILP solvers help you. If all your variables are binary and MILP solvers fail to find feasible solutions try &lt;a href=&quot;https://gitlab.com/JoD/exact&quot; rel=&quot;nofollow noreferrer&quot;&gt;Exact&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-05-04T17:32:00.573" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8363" PostTypeId="1" CreationDate="2022-05-04T19:43:04.873" Score="1" ViewCount="122" Body="&lt;p&gt;I am studying a paper on a Pickup Dropoff Problem with Time Window (&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.1090.0272&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pubsonline.informs.org/doi/abs/10.1287/trsc.1090.0272&lt;/a&gt; ). The three index formulation is straightforward. The formulation is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Y2de0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Y2de0.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/9guPj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9guPj.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, there is a set partitioning formulation of the problem, that works with a set of all feasible routes that satisfy all PDPTW constraints, plus a constraint that limits that each node will be covered by only one route. My question is how am I going to generate those routes for this set partitioning problem? Should I generate all possible route witt all vertices in the network? Below is the set patitining formulation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VQwTU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VQwTU.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3288" LastEditorUserId="491" LastEditDate="2022-05-04T20:40:29.207" LastActivityDate="2022-05-04T20:40:29.207" Title="Set Partitioning Formulation of PDPTW" Tags="|vehicle-routing|set-covering|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8365" PostTypeId="2" ParentId="8356" CreationDate="2022-05-05T13:58:57.443" Score="6" Body="&lt;p&gt;Plot the region in two dimensions, as shown &lt;a href=&quot;https://www.desmos.com/calculator/qwcm3c5gqn&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, where &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt; corresponds to &lt;span class=&quot;math-container&quot;&gt;$(u_1,u_2)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The second and third constraints have boundary lines with slopes &lt;span class=&quot;math-container&quot;&gt;$2/3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$3/1$&lt;/span&gt;, yielding the extreme rays &lt;span class=&quot;math-container&quot;&gt;$(3,2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(1,3)$&lt;/span&gt;, respectively.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-05-05T13:58:57.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8366" PostTypeId="1" AcceptedAnswerId="8367" CreationDate="2022-05-05T15:16:19.790" Score="2" ViewCount="74" Body="&lt;p&gt;Variables &lt;span class=&quot;math-container&quot;&gt;$0\le x&amp;lt; 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y,z\ge 0$&lt;/span&gt;. We have a constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y=(z+c)\frac{x^2}{1-x},$$&lt;/span&gt;&#xA;where constant &lt;span class=&quot;math-container&quot;&gt;$c&amp;gt;0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We partitioned &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; into &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; intervals of equal length and defined a new variable &lt;span class=&quot;math-container&quot;&gt;$\phi_i=1$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,n$&lt;/span&gt; iff &lt;span class=&quot;math-container&quot;&gt;$x\in(r_i-1,r_i]$&lt;/span&gt; (we set &lt;span class=&quot;math-container&quot;&gt;$x=r_i$&lt;/span&gt;) and zero otherwise.&lt;/p&gt;&#xA;&lt;p&gt;So we have this constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y=\sum_{i=1}^n(z+c)\left(\frac{r_i^2}{1-r_i}\right)\phi_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can we linearize this new constraint?&lt;/p&gt;&#xA;&lt;p&gt;If we define a new non-negative variable &lt;span class=&quot;math-container&quot;&gt;$\xi_i=z\phi_i$&lt;/span&gt; and add the required 3 additional constraints with &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, can we rewrite the second constraint above as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y=\sum_{i=1}^n\left(\frac{r_i^2}{1-r_i}\right)(\xi_i+c\phi_i)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user9659" LastActivityDate="2022-05-05T15:35:05.887" Title="Linearizing $y=\sum_{i=1}^n(z+c)\left(\frac{r_i^2}{1-r_i}\right)\phi_i$" Tags="|modeling|linearization|nonlinear-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8367" PostTypeId="2" ParentId="8366" CreationDate="2022-05-05T15:35:05.887" Score="3" Body="&lt;p&gt;You are on the right track. Linearizing the product of a continuous variable (&lt;span class=&quot;math-container&quot;&gt;$\xi_i$&lt;/span&gt;) and a binary variable (&lt;span class=&quot;math-container&quot;&gt;$\phi_i$&lt;/span&gt;) is a FAQ. See, for instance, &lt;a href=&quot;https://or.stackexchange.com/questions/39/how-to-linearize-the-product-of-a-binary-and-a-non-negative-continuous-variable&quot;&gt;How to linearize the product of a binary and a non-negative continuous variable?&lt;/a&gt;. It requires that you be able to slap upper and lower bounds on &lt;span class=&quot;math-container&quot;&gt;$\xi_i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-05T15:35:05.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8368" PostTypeId="1" AcceptedAnswerId="8369" CreationDate="2022-05-05T16:16:30.350" Score="1" ViewCount="84" Body="&lt;p&gt;I have been dealing with a problem for sometime and although tried different things and asked some questions before, I think the problem might be somewhere that we didn't look before.&lt;/p&gt;&#xA;&lt;p&gt;Variables &lt;span class=&quot;math-container&quot;&gt;$0\le x&amp;lt; 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y,z\ge 0$&lt;/span&gt; and we have a constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y=(z+c)\frac{x^2}{1-x},$$&lt;/span&gt;&#xA;where constant &lt;span class=&quot;math-container&quot;&gt;$c&amp;gt;0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We partitioned &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; into &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; intervals of equal length and defined a new variable &lt;span class=&quot;math-container&quot;&gt;$\phi_i=1$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,n$&lt;/span&gt; iff &lt;span class=&quot;math-container&quot;&gt;$x\in(r_i-1,r_i]$&lt;/span&gt; (we set &lt;span class=&quot;math-container&quot;&gt;$x=r_i$&lt;/span&gt;) and zero otherwise.&lt;/p&gt;&#xA;&lt;p&gt;So we reformulated the constraint above and also added these constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^nr_{i-1}\phi_i\le x\le \sum_{i=1}^nr_{i}\phi_i, \qquad \sum_{i=1}^n\phi_i=1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But the problem is that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; itself is a function of an allocation vector &lt;span class=&quot;math-container&quot;&gt;$\mathbf{a}$&lt;/span&gt; and depending on data, sometimes &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf{a})&amp;gt;1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So we want to have &lt;span class=&quot;math-container&quot;&gt;$x=\min\{f(\mathbf{a}),1-\epsilon\}$&lt;/span&gt; but I think the above two constraints don't satisfy this condition and the model becomes infeasible.&lt;/p&gt;&#xA;&lt;p&gt;How should I change the partitioning constraints so for any vector &lt;span class=&quot;math-container&quot;&gt;$\mathbf{a}$&lt;/span&gt; that makes &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf{a})&amp;gt;1$&lt;/span&gt;, it forces &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to remain equal to &lt;span class=&quot;math-container&quot;&gt;$1-\epsilon$&lt;/span&gt;? Is it even possible?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There was a typo in the question.&lt;/p&gt;&#xA;&lt;p&gt;The additional constraints that we added are&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^nr_{i-1}\phi_i\le f(\mathbf{a})\le \sum_{i=1}^nr_{i}\phi_i, \qquad \sum_{i=1}^n\phi_i=1$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user9659" LastEditorDisplayName="user9659" LastEditDate="2022-05-06T06:44:04.163" LastActivityDate="2022-05-06T06:44:04.163" Title="If $x=\min\{f(\mathbf{a}),1-\epsilon\}$, how can we model and partition $x$?" Tags="|modeling|linearization|nonlinear-programming|queuing-theory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8369" PostTypeId="2" ParentId="8368" CreationDate="2022-05-05T22:22:54.287" Score="3" Body="&lt;p&gt;Start with the constraints &lt;span class=&quot;math-container&quot;&gt;$$x \le f(\mathbf{a})$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$x \le 1-\epsilon.$$&lt;/span&gt; If the nature of the problem is that larger values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are always preferable in objective terms to smaller values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, that's all you need. If that condition is not met (or you are not sure that it is), you will also need a binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; together with the constraints &lt;span class=&quot;math-container&quot;&gt;$$ x \ge f(\mathbf{a}) - My$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$x \ge 1-\epsilon -M(1-y)$$&lt;/span&gt; for some suitably large &lt;span class=&quot;math-container&quot;&gt;$M.$&lt;/span&gt; The latter two constraints ensure that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; actually equals either &lt;span class=&quot;math-container&quot;&gt;$1-\epsilon$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf{a})$&lt;/span&gt; (whichever is smaller).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-05T22:22:54.287" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8370" PostTypeId="2" ParentId="8357" CreationDate="2022-05-06T14:25:57.117" Score="3" Body="&lt;p&gt;You might want to look at MRP(Material Requirements Planning)/Leontief matrices.&lt;/p&gt;&#xA;&lt;p&gt;In an MRP/Leontief matrix/model:&lt;/p&gt;&#xA;&lt;p&gt;Each constraint is an equality,&lt;/p&gt;&#xA;&lt;p&gt;Every column has exactly one positive coefficient and it is a +1, (the output)&lt;/p&gt;&#xA;&lt;p&gt;Each column has 0 or more negative coefficients, every one of which is integer, (inputs needed)&lt;/p&gt;&#xA;&lt;p&gt;Each RHS coefficient is a nonnegative integer. (the demands)&lt;/p&gt;&#xA;&lt;p&gt;Result: An LP whose complete constraint set is an&#xA;MRP set has an optimal solution that is integer.&lt;/p&gt;&#xA;&lt;p&gt;Further, if the objective coefficients are all integer,&#xA;then there is an optimal solution with integral dual prices.&lt;/p&gt;&#xA;&lt;p&gt;Ref: Jeroslow, R., K. Martin, R. Rardin, J. Wang(1992), &amp;quot;Gainfree Leontief substitution flow problems,&amp;quot;&#xA;Mathematical Programming, 57,  pp. 375-414.;&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-05-06T14:25:57.117" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8371" PostTypeId="2" ParentId="8356" CreationDate="2022-05-07T20:21:22.440" Score="3" Body="&lt;p&gt;Add an objective function to the constraints so that you have an LP. Warning: There may be a significant amount of trial-and-error involved. First, you are looking for an objective for which the LP is unbounded. If you maximize &lt;span class=&quot;math-container&quot;&gt;$a^\prime u$&lt;/span&gt; and the problem is bounded, you can try minimizing &lt;span class=&quot;math-container&quot;&gt;$a^\prime u$&lt;/span&gt;. Also, what follows once you have an unbounded LP gets you the direction vector for one of the extreme rays. You have to keep trying direction vectors (which might find the same ray(s) over and over) until you convince yourself you have all the rays. This is related to the problem of finding all optimal extreme point solutions to an LP, which as I recall is NP-hard (not that NP-anything is a huge worry when you have two variables and five constraints counting nonnegativity).&lt;/p&gt;&#xA;&lt;p&gt;Let's say you got lucky with your objective and the problem is unbounded. In the primal simplex method, reduced costs tell you which variable is entering the basis (pivot column), and the variable leaving the basis is in the first row whose right hand side value hits zero on the way to turning negative as you increase the value of the variable in the pivot column. With an unbounded problem, you find the pivot column but no row qualifies (no RHS decreases as you increase the pivot variable). So if &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is the vector of entries in the pivot column, you can add any positive multiple of &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; to the current basic feasible solution &lt;span class=&quot;math-container&quot;&gt;$\hat{u}$&lt;/span&gt; without losing feasibility. That makes &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; one of your rays.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-07T20:21:22.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8372" PostTypeId="1" CreationDate="2022-05-08T18:08:37.887" Score="2" ViewCount="190" Body="&lt;p&gt;I am trying to solve a problem where I am provided a list of jobs that need to be scheduled to minimize the processing time. Every job has to be performed in 2 stages where the second stage can be done only after the first one is finished.&lt;/p&gt;&#xA;&lt;p&gt;There are 2 machines available for each job i.e. there are 2 machines available for stage 1 and 2 machines for stage 2. A stage 1 machine can only perform stage 1 jobs and the same holds for stage 2 machines.&lt;/p&gt;&#xA;&lt;p&gt;According to google genetic algorithms are recommended for such problems. I am slightly familiar with genetic algorithms, but do not know how to represent this problem as a chromosome and what type of cross-over would be suitable here.&lt;/p&gt;&#xA;" OwnerUserId="9668" LastEditorUserId="491" LastEditDate="2022-05-08T18:36:09.687" LastActivityDate="2022-05-08T19:50:06.317" Title="Job scheduling for a 2 stage job with 2 machines available for each stage" Tags="|scheduling|genetic-algorithm|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8373" PostTypeId="2" ParentId="8372" CreationDate="2022-05-08T19:50:06.317" Score="2" Body="&lt;p&gt;Since you did not say otherwise, I am going to assume that (a) all jobs are available for release at time 0, (b) each machine can handle any of the jobs and (c) your criterion is minimizing makespan (time the last job completes).&lt;/p&gt;&#xA;&lt;p&gt;You can use mixed integer linear programming (MILP) or constraint programming (CP) to find a provably optimal schedule. Because genetic algorithms (GAs) are metaheuristics, they do not always find optimal solutions (although they sometimes do), and even when they do you do not get a proof of optimality (so typically you cannot be sure the solution is optimal).&lt;/p&gt;&#xA;&lt;p&gt;That said, if you want to use a GA, one approach is to use a permutation chromosome. Some GA solvers support permutations directly; if not, you can work around that limitation.&lt;/p&gt;&#xA;&lt;p&gt;Assuming there are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; jobs, your chromosome represents a permutation of the indices &lt;span class=&quot;math-container&quot;&gt;$1,\dots,n$&lt;/span&gt; indicating job priorities. Whenever a machine in either stage becomes available, it is assigned the highest priority job in the queue for that stage. If a job encounters two idle machines (which will happen at the very outset in the first stage, and at least once in the second stage), assign it to the machine which will process it faster, breaking ties arbitrarily. Since GAs maximize fitness and you want to minimize makespan, the fitness of a chromosome is the difference between an upper bound on the makespan and the actual makespan for the schedule (chromosome).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-08T19:50:06.317" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8374" PostTypeId="1" AcceptedAnswerId="8375" CreationDate="2022-05-09T15:07:40.703" Score="0" ViewCount="253" Body="&lt;p&gt;I am doing an optimization problem for the filling and extraction of a warehouse.&#xA;One of the constraints is that the filling volume cannot exceed a given limit for one day:&#xA;For example, on the 3rd of April a maximum of 60 kg, on the 8th of May, 70 kg.&lt;/p&gt;&#xA;&lt;p&gt;Using pandas I import the column with the maximum inventory profile for each day and impose the restriction as follows (For the lower limit I also have a profile that I impose for each day):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=0}^i X_i \le H_i$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=0}^i X_i \ge L_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.addConstrs(sum(x[i] for i in dias)&amp;lt;=Hvol[i] for i in dias)&#xA;&#xA;m.addConstrs(sum(x[i] for i in dias)&amp;gt;= Lvol[i] for i in dias)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Days is a list associated with the index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, representing each day.&#xA;What python does is that the sum of 365 days is always less than &lt;span class=&quot;math-container&quot;&gt;$H_i$&lt;/span&gt;, instead of the sum up to day &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; being less than &lt;span class=&quot;math-container&quot;&gt;$H_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What python does:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i=0}^n X_i \le H_i$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$n=365$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$X_1+X_2+X_3+\ldots+X_{365} \le H_1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$X_1+X_2+X_3+\ldots+X_{365} \le H_2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Instead of:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}X_1&amp;amp;\le H_1\\X_1+X_2&amp;amp;\le H_2\\\cdots\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9570" LastEditorUserId="491" LastEditDate="2022-05-11T13:04:36.807" LastActivityDate="2022-05-11T13:04:36.807" Title="How to put this restriction using Gurobi in python" Tags="|linear-programming|python|constraint|gurobi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8375" PostTypeId="2" ParentId="8374" CreationDate="2022-05-09T15:28:58.703" Score="6" Body="&lt;p&gt;Firstly, your constraint should rather look this this:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=0}^{i}X_j \leq H_i \quad \forall i \in I$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=0}^{i}X_j \geq L_i \quad \forall i \in I$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In your code this should translate to:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.addConstrs(sum(x[j] for j in range(0,i))&amp;lt;=Hvol[i] for i in dias)&#xA;&#xA;m.addConstrs(sum(x[j] for j in range(0, i))&amp;gt;= Lvol[i] for i in dias)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In case dias starts with index 1, then it should be &lt;code&gt;range(1,i+1)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="3464" LastEditDate="2022-05-09T20:15:03.963" LastActivityDate="2022-05-09T20:15:03.963" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8376" PostTypeId="2" ParentId="8330" CreationDate="2022-05-10T07:15:40.963" Score="6" Body="&lt;p&gt;In OPL CPLEX you can use &lt;a href=&quot;https://github.com/AlexFleischerParis/zooopl/blob/master/zooifthen.mod&quot; rel=&quot;noreferrer&quot;&gt;if then&lt;/a&gt; logical constraints.&lt;/p&gt;&#xA;&lt;p&gt;For instance&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;range I=1..2;&#xA;range J=1..3;&#xA;range K=1..4;&#xA;range L=1..5;&#xA;&#xA;dvar boolean x[I][J][K][L];&#xA;dvar int h[I];&#xA;&#xA;subject to&#xA;{&#xA;&#xA;forall(i in I, j in J,k in K,l in L)&#xA; {&#xA;  (x[i][j][k][l] - 7 &amp;gt;=0)&#xA;  =&amp;gt; (sum(k2 in K, l2 in L) (x[i][j][k2][l2] - 7) == h[i]);&#xA;  &#xA;  (x[i][j][k][l] - 7 &amp;lt;=0)&#xA;  =&amp;gt; (0 == h[i]);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;works&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-05-10T07:15:40.963" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8377" PostTypeId="1" CreationDate="2022-05-10T12:31:13.727" Score="5" ViewCount="418" Body="&lt;p&gt;I have tried to convert the following constraint into SOCP form but can't figure it out. My issue is that whenever I create the norm, the other side has to be square rooted which invalidates the SOCP form.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The directional parameters &lt;span class=&quot;math-container&quot;&gt;${\boldsymbol w}\in\Bbb R^d$&lt;/span&gt; satisfies the following shaping constraint: &lt;span class=&quot;math-container&quot;&gt;$$\boldsymbol w^\top\boldsymbol\Sigma\boldsymbol w+\boldsymbol c^\top\boldsymbol w\le1,$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol\Sigma\in\Bbb R^{d\times d}$&lt;/span&gt; is a &lt;strong&gt;given&lt;/strong&gt; symmetric, positive definite matrix and &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol c\in\Bbb R^d$&lt;/span&gt; is a &lt;strong&gt;given&lt;/strong&gt; vector.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="9671" LastEditorUserId="491" LastEditDate="2022-05-11T13:05:13.613" LastActivityDate="2022-05-11T13:05:13.613" Title="Quadratically constrained convex optimization" Tags="|optimization|mixed-integer-programming|constraint|socp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8378" PostTypeId="2" ParentId="8377" CreationDate="2022-05-10T12:42:33.120" Score="8" Body="&lt;p&gt;For all things convex, Mosek's &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;noreferrer&quot;&gt;modeling cookbook&lt;/a&gt; and &lt;a href=&quot;https://docs.mosek.com/cheatsheets/conic.pdf&quot; rel=&quot;noreferrer&quot;&gt;conic modeling cheatsheet&lt;/a&gt; have you covered.&lt;/p&gt;&#xA;&lt;p&gt;In your case, see the section on &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/cqo.html#convex-quadratic-sets&quot; rel=&quot;noreferrer&quot;&gt;convex quadratic sets&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2022-05-10T12:42:33.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8379" PostTypeId="2" ParentId="8377" CreationDate="2022-05-10T13:30:29.387" Score="2" Body="&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol\Sigma$&lt;/span&gt; is PSD, there exists &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol Q$&lt;/span&gt; s.t. &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol Q^\top\boldsymbol Q=\boldsymbol \Sigma$&lt;/span&gt; (by Cholesky, or eigendecomposition).&lt;/p&gt;&#xA;&lt;p&gt;Then &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol w^\top\boldsymbol \Sigma\boldsymbol w =\boldsymbol w^\top\boldsymbol Q^\top\boldsymbol Q\boldsymbol w = \|\boldsymbol Q\boldsymbol w\|_2^2.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then introduce new variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; as epigraph of &lt;span class=&quot;math-container&quot;&gt;$\|\boldsymbol Q\boldsymbol w\|$&lt;/span&gt; as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}y+\boldsymbol c^\top\boldsymbol w&amp;amp;=1\tag{linear constraint}\\\|\boldsymbol Q\boldsymbol w\|_2^2&amp;amp;\le y\tag{rotated quadratic cone  constraint}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As @mtanneau posted, these modeling tricks(?) are well-explained in the MOSEK tutorial.&lt;/p&gt;&#xA;&lt;p&gt;If you use MOSEK, you can just directly use rotated quadratic cone to model second constraint.&#xA;If you want to convert into second order conic constraints,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&amp;amp;\|\boldsymbol{Qw}\|_{2}^{2} \leq y \\\iff&amp;amp;(\boldsymbol{Qw})^\intercal (\boldsymbol{Qw}) \leq y \\&#xA;\iff&amp;amp; (\boldsymbol{Qw})^\intercal (\boldsymbol{Qw})+\frac{(y-1)^2}{4} \leq \frac{(y+1)^2}{4}\\&#xA;\iff&amp;amp; \left\|\begin{pmatrix}\boldsymbol{Qw}\\ \frac{y-1}{2} \end{pmatrix}\right\|_{2} \leq \frac{y+1}{2}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Hope this is what you're looking for.&lt;br /&gt;&#xA;*Converting quadratic constraint into soc constraint is well-known tricks, you can find in &lt;a href=&quot;https://www2.isye.gatech.edu/%7Enemirovs/LMCOLN2021WithSol.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www2.isye.gatech.edu/~nemirovs/LMCOLN2021WithSol.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4130" LastEditorUserId="123" LastEditDate="2022-05-11T08:06:54.427" LastActivityDate="2022-05-11T08:06:54.427" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8380" PostTypeId="2" ParentId="7948" CreationDate="2022-05-10T16:47:28.307" Score="3" Body="&lt;p&gt;In OPL You can write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;range R = 0..2;&#xA;dvar int x[R] in 0..40;&#xA;&#xA;&#xA;maximize&#xA;  x[0] + 2 * x[1] + 10 * x[2]&#xA;  - 0.5 * ( 33 * x[0]^2 + 22 * x[1]^2 + 11 * x[2]^2 &#xA;          - 12 * x[0] * x[1] - 23 *x [1] * x[2] );&#xA;&#xA;subject to {&#xA;  ct1:  - x[0] +     x[1] + x[2] &amp;lt;= 20;&#xA;  ct2:    x[0] - 3 * x[1] + x[2] &amp;lt;= 30;&#xA;  ct3:    x[0]^2 + x[1]^2 + x[2]^2 &amp;lt;= 10.0;&#xA;}&#xA;&#xA;tuple xSolutionT{ &#xA;    int R; &#xA;    float value; &#xA;};&#xA;{xSolutionT} xSolution = {&amp;lt;i0,x[i0]&amp;gt; | i0 in R};&#xA;execute{ &#xA;    writeln(xSolution);&#xA;}   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which you can rewrite with &lt;a href=&quot;https://github.com/AlexFleischerParis/howtowithdocplex/blob/main/miqcp.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;docplex&lt;/a&gt; into&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;mdl = Model(name='miqcp')&#xA;&#xA;x=[mdl.integer_var(0,40,name=&amp;quot;x&amp;quot;+str(i)) for i in range(0,3)] &#xA;&#xA;mdl.add(- x[0] +     x[1] + x[2] &amp;lt;= 20)&#xA;mdl.add(x[0] - 3 * x[1] + x[2] &amp;lt;= 30)&#xA;mdl.add(x[0]**2 + x[1]**2 + x[2]**2 &amp;lt;= 10.0)&#xA;&#xA;mdl.maximize(x[0] + 2 * x[1] + 10 * x[2] - 0.5 * ( 33 * x[0]**2 \&#xA;+ 22 * x[1]**2 + 11 * x[2]**2 - 12 * x[0] * x[1] - 23 *x [1] * x[2] ))&#xA;&#xA;mdl.solve()&#xA;&#xA;for i in range(0,3):&#xA;    print(x[i].name,&amp;quot; = &amp;quot;,x[i].solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-05-10T16:47:28.307" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8381" PostTypeId="1" CreationDate="2022-05-10T17:42:41.743" Score="2" ViewCount="83" Body="&lt;p&gt;I'm modeling a continuous-time, two-stage manufacturing process with an MIP.  There are about 100 finished-goods SKUs, and each of those belongs to about 25 different semi-finished categories in a many-to-one fashion.  For approximation, let's say SKU1,SKU2,SKU3,SKU4 belong to semi-finished category A, SKU5,SKU6,SKU7,SKU8 belong to semi-finished cateogry B, etc.&lt;/p&gt;&#xA;&lt;p&gt;In the first stage, semi-finished WIP materials are produced in one section of the plant (four lines in this section).  If a manufacturing line produces 1000 pounds of semi-finished category A, those 1000 WIP pounds can then be &amp;quot;converted&amp;quot; into SKU1,SKU2,SKU3, or SKU4 in a different section of the plant, at different rates across about 20 lines.&lt;/p&gt;&#xA;&lt;p&gt;Right now, I am treating semi-finished production &amp;quot;as if&amp;quot; it's finished-goods production.  E.g., SKU1 is produced in the first section of the plant, then transferred to the other section for completion as a finished good.  This is causing significant model complexity that I think could be avoided if I can just model the first stage of manufacturing as 25 semi-finished goods, instead of 100 individual finished SKUs.&lt;/p&gt;&#xA;&lt;p&gt;The tricky part is that there's a time component - you can't manufacture a unit of SKU1 in the finished-goods process, without having completed sufficient production in the semi-finished section.  I'd like to be able to implement some sort of net inventory constraint in my model.  E.g., you can't begin to process X units of SKU1 in the second section, unless there are X units of semi-finished category A sitting around.  Even more troublesome is that there is a many-to-one relationship between finished-goods SKUs and semi-finished products.&lt;/p&gt;&#xA;&lt;p&gt;Any advice on how this net inventory relationship may be modeled?&lt;/p&gt;&#xA;" OwnerUserId="3958" LastEditorUserId="3958" LastEditDate="2022-05-10T18:22:05.507" LastActivityDate="2022-05-11T10:21:35.037" Title="WIP Inventory Level Constraint?" Tags="|mixed-integer-programming|modeling|supply-chain|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8383" PostTypeId="2" ParentId="8381" CreationDate="2022-05-10T18:34:55.513" Score="2" Body="&lt;p&gt;I assume this is a multiperiod problem. Create a variable &lt;span class=&quot;math-container&quot;&gt;$I_{k,t}$&lt;/span&gt; for the inventory of category of category &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; material available to the second stage at the end of time period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Production variables in the first stage are the amount of &amp;quot;category&amp;quot; material of each type produced. Production variables in the second stage are the amount of each SKU produced.&lt;/p&gt;&#xA;&lt;p&gt;There are a couple of ways to handle the intermediate inventory, depending on the granularity of your time units and how picky you are. One approach would look like this, where &lt;span class=&quot;math-container&quot;&gt;$x_{k,t}$&lt;/span&gt; is production of category &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; during time period &lt;span class=&quot;math-container&quot;&gt;$t,$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$S_k$&lt;/span&gt; is the set of SKUs in category &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$y_{s,t}$&lt;/span&gt; is the production of SKU &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; during time period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$$0\le I_{k,t} = I_{i,t-1} + x_{k,t} - \sum_{s \in S_k} y_{s,t}.$$&lt;/span&gt; The caveat here is that the constraint allows category material produced in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; to be consumed in the same period (which may not be overly permissive). An alternate approach would be to add the constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{s \in S_k} y_{s,t} \le I_{i,t-1},$$&lt;/span&gt; which would limit stage 2 consumption to category material that was available at the start of the time period (which might be overly restrictive).&lt;/p&gt;&#xA;&lt;p&gt;Of course, the accuracy of either approach can be improved by shrinking the duration of a time period, at the cost of making the model bigger.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-10T18:34:55.513" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8384" PostTypeId="2" ParentId="8381" CreationDate="2022-05-11T09:18:02.997" Score="3" Body="&lt;p&gt;What you are trying to do sounds like an MRP (material requirement planning) system. For this, you already need to define the component's precedence relations as a directed graph and apply the stages to produce semi-defined materials in your desired given planning horizon. In the following picture:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/dn03N.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dn03N.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;there are three stages. Stage three is also determined as the finished products. Each node represents each component and the arcs determine the relations between components and whose semi-defined materials. The shown number on each arc turns out the required components to produce its follow-up materials. By the above definition, the MRP system can be formulated as mixed-integer programming as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min &amp;amp; \quad \text{your desired objective function} \\&#xA;\text{s.t.} &amp;amp; \sum_{\tau=1}^{t-L T(i)} x_{i, \tau}+I(i, 0)-\sum_{\tau=1}^{t}\left(D(i, \tau)+\sum_{j=1}^{P} R(i, j) x_{j, \tau}\right) \geq 0, \quad \forall i, t\\&#xA;&amp;amp; x_{i, t}-\delta_{i, t} L S(i) \quad \geq 0, \quad \forall i, t \\&#xA;&amp;amp; \delta_{i, t}-\frac{x_{i, t}}{M} \quad \geq 0, \quad \forall i, t\\&#xA;&amp;amp; x_{i,t} \in \text{R}, \delta_{i, t}\{0,1\}, \forall i \in N&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is the number of SKUs, &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is the number of time buckets (i.e., daily, weekly, etc.), &lt;span class=&quot;math-container&quot;&gt;$LT$&lt;/span&gt; is the Lead time for SKU &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; the number of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;’s needed to make one &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is the beginning inventory and &lt;span class=&quot;math-container&quot;&gt;$LS$&lt;/span&gt; is the minimum lot size for SKU &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Also, &lt;span class=&quot;math-container&quot;&gt;$x_{i,t}$&lt;/span&gt; represents the amount of produced components in each stage and &lt;span class=&quot;math-container&quot;&gt;$\delta_{i,t}$&lt;/span&gt; is a switching variable to active/inactive producing the components.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2022-05-11T10:21:35.037" LastActivityDate="2022-05-11T10:21:35.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8385" PostTypeId="1" CreationDate="2022-05-12T11:40:40.447" Score="3" ViewCount="192" Body="&lt;p&gt;I am doing research on optimizing a simple buffer allocation and need to run my model. I am new to this but someone told me about using Gurobi and I do not for the life of me know how to create the following LP model. Can someone please help me on the right path?&lt;/p&gt;&#xA;&lt;p&gt;The situation is as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There are 5 machines in the line each with a buffer in between in the form of:&lt;/li&gt;&#xA;&lt;li&gt;b0 -&amp;gt; M1 -&amp;gt; b1 -&amp;gt; ... M5 -&amp;gt; b5, with M being the machines and b being the buffers.&lt;/li&gt;&#xA;&lt;li&gt;b0 has a continuous flow of units into the line&lt;/li&gt;&#xA;&lt;li&gt;b5 has an infinite capacity&lt;/li&gt;&#xA;&lt;li&gt;The rest of the buffers have a finite capacity and is what needs to be optimized.&lt;/li&gt;&#xA;&lt;li&gt;k is the max capacity per buffer&lt;/li&gt;&#xA;&lt;li&gt;b_i (t) is the actual amount of units per buffer at moment t, at t=0 all buffers are empty.&lt;/li&gt;&#xA;&lt;li&gt;v_i is the nominal production rate of the machine&lt;/li&gt;&#xA;&lt;li&gt;th_i(t) is the number of units moved from b_(i-1) to b_i in step t.&lt;/li&gt;&#xA;&lt;li&gt;The objective function is to maximize the sum of b_5, which is the sum of the actual amount of units in the last buffer.&lt;/li&gt;&#xA;&lt;li&gt;t = 0, ..., 360&lt;/li&gt;&#xA;&lt;li&gt;The speeds still need to be defined.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iEjQb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iEjQb.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am not an operations researcher in anyway, so this is all new and unfortunately I cannot post any producible sample or show how far I have come already, as I have nothing and don't totally understand it as of yet.&lt;/p&gt;&#xA;" OwnerUserId="9678" LastEditorUserId="9678" LastEditDate="2022-05-12T12:55:41.133" LastActivityDate="2022-05-14T11:02:04.697" Title="How to input this LP model of a buffer allocation problem in Gurobi?" Tags="|optimization|linear-programming|gurobi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8386" PostTypeId="2" ParentId="8385" CreationDate="2022-05-12T13:07:23.017" Score="4" Body="&lt;p&gt;You correctly identified that this a linear program. You could either specify this problem in the .lp file format see the &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/lp_format.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi documenation&lt;/a&gt; and consult the &lt;a href=&quot;https://www.tu-chemnitz.de/mathematik/discrete/manuals/cplex/doc/refman/html/appendixE5.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;syntax rules&lt;/a&gt; if you have questions or you could use a modeling language like PuLP in Python or JuMP in Julia. I prefer JuMP as Julia makes it really easy to install open source solvers and also can talk to Gurobi (provided you have a Gurobi install). This problem is small enough that open source solvers will not be much slower then commercial solvers like Gurobi. So if Gurobi is not already installed i would recommend the Cbc solver which can be installed automatically by Julia. Below i will add the model transcribed to JuMP. You will just have install Julia and execute this command line.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using JuMP&#xA;using Gurobi&#xA;&#xA;m = Model(Gurobi.Optimizer)&#xA;&#xA;t = 360&#xA;&#xA;@variable(m, 0 &amp;lt;= b[0:5,0:t])&#xA;@variable(m, 0 &amp;lt;= k[0:5])&#xA;@variable(m, th[0:5,0:t])&#xA;@variable(m, v[1:5,0:t])&#xA;&#xA;@constraint(m, b[5,0:t] .&amp;lt;= th[5,0:t])&#xA;&#xA;for tt in 1:t # can't constrain b[5,0] that way&#xA;  @constraint(m, b[5, tt] &amp;lt;= b[4, tt-1])&#xA;end&#xA;&#xA;for i in 1:4&#xA;  @constraint(m, b[i,1:t] .&amp;lt;= k[i])&#xA;end&#xA;&#xA;for i in 1:4, tt in 1:t #tt not 0&#xA;  @constraint(m, b[i,1:tt] .&amp;lt;= b[i,tt-1] - th[i-1,tt] + v[i,tt])&#xA;end&#xA;&#xA;&#xA;for i in 1:4, tt in 1:t #tt not 0&#xA;  @constraint(m, b[i,1:tt] .&amp;lt;= b[i,tt-1] - th[i-1,tt] + b[i-1,tt-1])&#xA;end&#xA;for tt in 0:t&#xA;  @constraint(m, th[5,tt] .== v[5, tt])&#xA;end&#xA;&#xA;for i in 1:4, tt in 2:(t-1) #tt not 1 or t&#xA;  @constraint(m, th[i,1:tt] .== b[i,tt-1] - b[i,tt-1] + th[i+1,tt])&#xA;end&#xA;&#xA;@constraint(m,sum(k[1:4]) &amp;lt;= 430)&#xA;&#xA;@objective(m, Max, sum(b[5,0:t]))&#xA;&#xA;JuMP.optimize!(m)&#xA;&#xA;@show termination_status(m)&#xA;@show primal_status(m)&#xA;@show dual_status(m)&#xA;@show objective_value(m) ## will fail from here on if there was no solution found&#xA;@show value.(k)&#xA;@show value.(b[2,1:11])&#xA;display(&amp;quot;text/plain&amp;quot;, value.(th))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This should give you an idea how to use JuMP. For more see the &lt;a href=&quot;https://jump.dev/JuMP.jl/stable/tutorials/getting_started/getting_started_with_JuMP/&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt;. The model as specified is unbounded or infeasible but using this example you should be able to encode the correct problem.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2022-05-12T14:25:14.670" LastActivityDate="2022-05-12T14:25:14.670" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8387" PostTypeId="1" CreationDate="2022-05-12T14:49:42.917" Score="4" ViewCount="355" Body="&lt;p&gt;I have an MILP problem and use CPLEX (Python interface). I am working on user heuristics for branching in the branch-and-bound procedure. With HSCallback I managed to get the information about the current subproblem (all integer variables are binary), in particular, what the variables that have been previously fixed/branched on are and how they've been fixed.&lt;/p&gt;&#xA;&lt;p&gt;Now, I would like to do something with the current subproblem. Is there a way to obtain it as a model? Do I have to construct it each time in the callback from the original model by adding the constraints corresponding to the fixed variables? Or is there a more efficient way of doing it?&lt;/p&gt;&#xA;&lt;p&gt;Below is a working example for a problem encoding Boolean satisfiability of CNF with 5 variables that has exactly one assignment (corresponding to the commented out line, uncommenting it makes the problem infeasible). I disable all possible heauristics and cuts to make sure that branch and bound has to do some work. Here I construct the subproblem by creating a copy of the original model and adding the constraints corresponding to the current branch.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import datetime&#xA;import docplex.mp.model as cpx&#xA;import cplex.callbacks as CPX_CB&#xA;from docplex.mp.relax_linear import LinearRelaxer&#xA;&#xA;&#xA;class MyHSCallback(CPX_CB.HSCallback):&#xA;    def __call__(self, *args, **kwargs):&#xA;        print()&#xA;        print(datetime.datetime.now(), &amp;quot;MyHSCallback working.............&amp;quot;)&#xA;        print(&amp;quot;node ID&amp;quot;, self.get_node_ID())&#xA;&#xA;        fixed = [(ind, int(self.get_lower_bounds(ind)))&#xA;                 for ind in range(self.var_count) if self.get_lower_bounds(ind) == self.get_upper_bounds(ind)]&#xA;        print(&amp;quot;Fixed variables&amp;quot;, &amp;quot;, &amp;quot;.join([str(ind) + &amp;quot;:&amp;quot; + str(value) for ind, value in fixed]))&#xA;        print(&amp;quot;Feasible subproblem&amp;quot;, self.solve())&#xA;&#xA;        # creating a copy of the subproblem&#xA;        model_copy = self.original_model.copy()&#xA;        for ind, value in fixed:&#xA;            model_copy.add_constraint(model_copy.get_var_by_index(ind) == value)&#xA;&#xA;        # doing something with the current subproblem&#xA;        lp_model = LinearRelaxer().linear_relaxation(mdl=model_copy)&#xA;        sol = lp_model.solve()&#xA;        if sol is not None:&#xA;            print(&amp;quot;Relaxation Values&amp;quot;, sol.get_values([lp_model.get_var_by_index(ind) for ind in range(self.var_count)]))&#xA;&#xA;&#xA;model = cpx.Model(name=&amp;quot;cnf&amp;quot;)&#xA;vars = model.binary_var_list(5, name=&amp;quot;var&amp;quot;)&#xA;x = vars[0]&#xA;y = vars[1]&#xA;z = vars[2]&#xA;w = vars[3]&#xA;v = vars[4]&#xA;&#xA;model.add_constraint(w + x + y &amp;gt;= 1)&#xA;model.add_constraint(v + w - y &amp;gt;= 0)&#xA;model.add_constraint(w - x + y + z &amp;gt;= 0)&#xA;model.add_constraint(v - x + y - z &amp;gt;= -1)&#xA;model.add_constraint(v - w + y + z &amp;gt;= 0)&#xA;model.add_constraint(v - w + x - z &amp;gt;= -1)&#xA;model.add_constraint(v - w + x - y + z &amp;gt;= -1)&#xA;model.add_constraint(- w - x - y &amp;gt;= -2)&#xA;model.add_constraint(-v + w - y + z &amp;gt;= -1)&#xA;# model.add_constraint(-v + w + x - y - z &amp;gt;= -2)&#xA;model.add_constraint(-v + w - x - z &amp;gt;= -2)&#xA;model.add_constraint(-v - w + x &amp;gt;= -1)&#xA;model.add_constraint(-v - w - x + y &amp;gt;= -2)&#xA;&#xA;hs_cb = model.register_callback(MyHSCallback)&#xA;hs_cb.var_count = len(vars)&#xA;hs_cb.original_model = model&#xA;&#xA;model.parameters.preprocessing.symmetry = 0&#xA;model.parameters.preprocessing.presolve = 0&#xA;model.parameters.preprocessing.boundstrength = 0&#xA;model.parameters.preprocessing.coeffreduce = 0&#xA;model.parameters.mip.strategy.search = 1 #traditional&#xA;model.parameters.mip.strategy.probe = -1&#xA;model.parameters.mip.strategy.heuristicfreq = -1&#xA;model.parameters.mip.strategy.fpheur = -1&#xA;model.parameters.mip.limits.cutpasses = -1&#xA;model.parameters.mip.cuts.bqp = -1&#xA;model.parameters.mip.cuts.cliques = -1&#xA;model.parameters.mip.cuts.covers = -1&#xA;model.parameters.mip.cuts.disjunctive = -1&#xA;model.parameters.mip.cuts.flowcovers = -1&#xA;model.parameters.mip.cuts.gomory = -1&#xA;model.parameters.mip.cuts.gubcovers = -1&#xA;model.parameters.mip.cuts.implied = -1&#xA;model.parameters.mip.cuts.liftproj = -1&#xA;model.parameters.mip.cuts.localimplied = -1&#xA;model.parameters.mip.cuts.mcfcut = -1&#xA;model.parameters.mip.cuts.mircut = -1&#xA;model.parameters.mip.cuts.pathcut = -1&#xA;model.parameters.mip.cuts.rlt = -1&#xA;model.parameters.mip.cuts.zerohalfcut = -1&#xA;&#xA;sol = model.solve()&#xA;print()&#xA;if sol is None:&#xA;    print(&amp;quot;Infeasible&amp;quot;)&#xA;else:&#xA;    model.print_solution()&#xA;    values = sol.get_values(vars)&#xA;    print(values)&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9588" LastActivityDate="2022-05-12T14:49:42.917" Title="CPLEX Python: Current subproblem model in branch and bound" Tags="|cplex|docplex|branch-and-bound|cplex-python-api|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8389" PostTypeId="1" AcceptedAnswerId="8390" CreationDate="2022-05-13T17:01:57.290" Score="3" ViewCount="833" Body="&lt;p&gt;I have tried to understand the method of relaxing an integer program. I am in the process of implementing and solving a MIP for the FJSSP. For this I use the python-MIP package to solve it. From my understanding, one does relax an integer program, solve it through a branch and bound algorithm which branches on specific fractional variables and possibly get an integer solution. I have tried to do this by relaxing my original integer model and solving it, which gives me an optimal solution with fractional values for my decision variable.&lt;/p&gt;&#xA;&lt;p&gt;But how do I get the integer values from my fractional solution now?&lt;/p&gt;&#xA;&lt;p&gt;Do I need to perform a Branch and Bound algorithm on the fractional solution?&lt;/p&gt;&#xA;&lt;p&gt;I am a little bit confused because in the description of python-MIP, it said that the solver already uses an Branch and Cut Algorithm to solve it, so I thought the relaxed model would give me an integer solution by branching through the tree.&lt;/p&gt;&#xA;" OwnerUserId="9449" LastEditorUserId="491" LastEditDate="2022-05-15T22:13:37.287" LastActivityDate="2022-05-15T22:13:37.287" Title="Solving a MIP by Relaxation" Tags="|mixed-integer-programming|branch-and-bound|relaxation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8390" PostTypeId="2" ParentId="8389" CreationDate="2022-05-13T18:08:42.313" Score="4" Body="&lt;p&gt;First off, the term &amp;quot;relaxation&amp;quot; is a bit ambiguous. You can relax a MIP model either by relaxing the integrality constraints (at which point it becomes a linear program) or by relaxing some of the constraints (essentially allowing infeasible solutions to be considered). I suspect you are interested in relaxing integrality.&lt;/p&gt;&#xA;&lt;p&gt;If you relax integrality, the problem is solved as a linear program (using some variant of the simplex method), &lt;em&gt;not&lt;/em&gt; by branch-and-bound. The main reason for doing this is to get a bound on the optimal objective value. The solution you get from the LP is &amp;quot;superoptimal&amp;quot;, meaning the optimal solution to the original problem cannot have a better objective value (and may have a worse objective value). There is no &amp;quot;easy&amp;quot; way to recover the true optimum from the relaxed solution. You can try rounding variables, which may produce a &amp;quot;good&amp;quot; solution but often will produce an infeasible one. You can try sequential rounding: round one variable and fix its value; solve the updated LP; rinse and repeat. Again, there is no guarantee you end up with a feasible solution, let alone an optimal one.&lt;/p&gt;&#xA;&lt;p&gt;The branch-and-cut algorithm used by the solver when you solve the original MIP model does in fact solve an LP relaxation at each node of the search tree, both to establish that there is some hope the node harbors a feasible solution and to detect whether there is any chance it harbors a better solution than what you currently have. If the answer to either question is no, the node is pruned. This is done automatically within the solver, so you do not need to do any explicit relaxation yourself.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-13T18:08:42.313" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8391" PostTypeId="1" AcceptedAnswerId="8392" CreationDate="2022-05-13T20:39:19.810" Score="1" ViewCount="299" Body="&lt;p&gt;For an &lt;span class=&quot;math-container&quot;&gt;$M/M/c$&lt;/span&gt; queue where arrivals follow a Poisson distribution with rate &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and are iid, service follows a Poisson process with rate &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; and there are &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; parallel servers, we can estimate the average queue time by&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;E[QT]\approx\frac{\rho^{\sqrt{2\left(c + 1\right)} - 1}}{c\left(1 - \rho\right)}\cdot\frac{1}{\mu},&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\rho= \lambda/c\mu$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We also know that since &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt; is the utilization rate, it must be less than equal to 1 and for system stability, we need to have &lt;span class=&quot;math-container&quot;&gt;$\rho\le1-\epsilon$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;From the structure of &lt;span class=&quot;math-container&quot;&gt;$E[QT]$&lt;/span&gt;, we can see that it's nonlinear in &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt; and both high and low utilization rate mean we are going to have a long average queue time.&lt;/p&gt;&#xA;&lt;p&gt;But let us assume that customers arrive at a very high rate and the value of ratio &lt;span class=&quot;math-container&quot;&gt;$\lambda/c\mu$&lt;/span&gt; is more than 1.&lt;/p&gt;&#xA;&lt;p&gt;How would that impact the average queue time? In the estimation formula above, it doesn't make any difference if the ratio &lt;span class=&quot;math-container&quot;&gt;$\lambda/c\mu$&lt;/span&gt; is 2 or 1000. But in reality, wouldn't a large &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; mean a very long waiting time?&lt;/p&gt;&#xA;" OwnerDisplayName="user9659" LastActivityDate="2022-05-13T21:59:33.300" Title="The impact of utilization rate of a queueing system on its average queue time" Tags="|modeling|queuing-theory|stochastic-process|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8392" PostTypeId="2" ParentId="8391" CreationDate="2022-05-13T21:59:33.300" Score="3" Body="&lt;p&gt;I do not agree with the assertion that &amp;quot;both high and low utilization rate mean we are going to have a long average queue time&amp;quot;. If &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt; is low (close to 0), &lt;span class=&quot;math-container&quot;&gt;$E[QT]$&lt;/span&gt; is close to 0. Low utilization makes for short waits.&lt;/p&gt;&#xA;&lt;p&gt;As far as &lt;span class=&quot;math-container&quot;&gt;$\rho &amp;gt; 1$&lt;/span&gt; is concerned, that will cause the queue to &amp;quot;explode&amp;quot;. In theory, wait times will diverge to infinity. In practice, either you will run out of arrivals because all possible customers are stuck in the system or, more likely, the system will become clogged and either turn off arrivals or shut down entirely.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-13T21:59:33.300" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8393" PostTypeId="1" CreationDate="2022-05-14T02:33:41.243" Score="1" ViewCount="120" Body="&lt;p&gt;When we learn about P versus NP, we are taught that a certificate for a problem in NP can be verified (or invalidated) in polynomial time.  But then &lt;a href=&quot;https://en.wikipedia.org/wiki/NP_(complexity)#Relationship_to_other_classes&quot; rel=&quot;nofollow noreferrer&quot;&gt;the proof that &lt;span class=&quot;math-container&quot;&gt;$P \subseteq NP$&lt;/span&gt;&lt;/a&gt; ignores the requirement to verify the given certificate, and says that we can just use our deterministic polynomial-time solver algorithm to determine if the true answer is &amp;quot;Yes&amp;quot; or &amp;quot;No.&amp;quot;  In doing so, we will have solved the problem, but we have not necessarily verified the certificate that was presented.&lt;/p&gt;&#xA;&lt;p&gt;For example, Djikstra's algorithm solves the shortest path problem in polynomial time, but as a constructive algorithm, it is not equipped to verify a solution.  Suppose we have a shortest path decision problem instance where the true answer is &amp;quot;Yes,&amp;quot; and suppose I give you an invalid certificate containing an incomplete path.  Finally, suppose my path length is less than the threshold, so I falsely claim to have a &amp;quot;Yes&amp;quot; certificate.  If you invoke Djikstra's algorithm, it will show that the decision problem's answer is &amp;quot;Yes,&amp;quot; but it doesn't show that my certificate is invalid.  So by invoking Djisktra's algorithm, you end up &amp;quot;verifying&amp;quot; my invalid claim.&lt;/p&gt;&#xA;&lt;p&gt;Have I missed some nuance to these definitions that establishes an equivalence between &amp;quot;verify the certificate&amp;quot; and &amp;quot;solve the problem&amp;quot;?&lt;/p&gt;&#xA;" OwnerUserId="324" LastActivityDate="2022-05-16T19:30:38.060" Title="Verifying certificates versus solving problems" Tags="|computational-complexity|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8394" PostTypeId="1" AcceptedAnswerId="8398" CreationDate="2022-05-14T06:50:06.710" Score="2" ViewCount="366" Body="&lt;p&gt;I have two sets of Boolean variables, &lt;span class=&quot;math-container&quot;&gt;$x_1, \dots, x_n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1, \dots, y_m$&lt;/span&gt; and a positive integer &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. I would like to add the constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{If }\sum_i x_i = b  \text{ then }\sum_i y_i &amp;gt; b$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can you formulate this as an integer program?&lt;/p&gt;&#xA;&lt;p&gt;I have seen similar looking questions but as a beginner in OR I can't tell if they apply directly to my question.&lt;/p&gt;&#xA;" OwnerUserId="9631" LastEditorUserId="500" LastEditDate="2022-05-14T19:20:57.620" LastActivityDate="2022-05-16T09:21:42.413" Title="How to formulate if-then for two sums in an integer program" Tags="|mixed-integer-programming|modeling|integer-programming|logical-constraints|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8395" PostTypeId="2" ParentId="8394" CreationDate="2022-05-14T09:09:14.553" Score="5" Body="&lt;p&gt;Your constraint is equivalent to the contraposition&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_i y_i \leq b \implies \sum_i x_i \neq b.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;By introducing additional binary variables &lt;span class=&quot;math-container&quot;&gt;$z_1, w_1, w_2, w_3$&lt;/span&gt;, it can be formulated as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;(b+1) (1-z_1)  &amp;amp;\leq \sum_i y_i \leq b z_1 + m (1-z_1) \tag{1} \\&#xA;b w_2 + (b+1) w_3 &amp;amp;\leq \sum_i x_i \leq (b-1)w_1 + b \cdot w_2 + n \cdot w_3, \tag{2}\\&#xA;w_1 + w_2 + w_3 &amp;amp;= 1, \tag{4}\\&#xA;z_1 &amp;amp;\leq w_1 + w_3 \tag{5}.&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2022-05-14T09:09:14.553" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8396" PostTypeId="2" ParentId="8385" CreationDate="2022-05-14T11:02:04.697" Score="1" Body="&lt;p&gt;Using a dynamic approach like simulation optimization is still one of the best ways to tackle such a problem instead of applying an LP/MIP. Based on what you mentioned, the problem you have faced might belong to a flow shop with finite buffer capacity. (E.g. this &lt;a href=&quot;https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.17.5540&amp;amp;rep=rep1&amp;amp;type=pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;one&lt;/a&gt; and lots of related papers that could be easily found by googling.). Now, by simulation approach, you can dynamically survey the behavior of the queuing system and would already see the related results of changing the problem's parameters.&lt;/p&gt;&#xA;&lt;p&gt;As an example, suppose there is a two-stage machine queuing system with the buffer stages between the machines. The following picture is showing this system:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CxISI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CxISI.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this system, one can easily change the input parameters, run the simulation, and optimize the next output based on the previous run results. In the above system, the output of the Buffer in stage_1 is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Uw6KO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Uw6KO.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As a result, there are four jobs in the buffer, and the average time would be &lt;span class=&quot;math-container&quot;&gt;$0.88$&lt;/span&gt; min.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-05-14T11:02:04.697" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8397" PostTypeId="2" ParentId="8393" CreationDate="2022-05-14T16:20:33.773" Score="2" Body="&lt;p&gt;Verifying a solution is a separate process from solving the problem. The proof that &lt;span class=&quot;math-container&quot;&gt;$P \subseteq NP$&lt;/span&gt; relies on the fact that a problem in &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is by definition of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; &lt;em&gt;assumed&lt;/em&gt; to have the ability to verify a &amp;quot;yes&amp;quot; problem (e.g., confirm that the optimal objective value is at most whatever) in polynomial time (satisfying that requirement for &lt;span class=&quot;math-container&quot;&gt;$NP$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;For the shortest path problem, checking a solution is simple (and has nothing to do with Dijkstra's algorithm): check that the first arc starts where it should (constant time); check that the last arc ends where it should (constant time); check that each arc connects to the preceding/following arc (time proportional to the number of arcs in the path, which is bounded by the number of arcs in the graph); and add up the arc lengths (time again proportional to the number of arcs) and verify it meets the threshold.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-05-16T19:30:38.060" LastActivityDate="2022-05-16T19:30:38.060" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8398" PostTypeId="2" ParentId="8394" CreationDate="2022-05-14T18:59:28.050" Score="3" Body="&lt;p&gt;The formulation by @joni is correct (+1) but can simplified and modified to use only two new binary variables, as follows.  The second &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; is not needed, and the first &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; can be replaced with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(b+1)w_2 \le \sum_i y_i \tag6$$&lt;/span&gt;&#xA;Now &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; are no longer needed. You can also eliminate &lt;span class=&quot;math-container&quot;&gt;$w_2$&lt;/span&gt;, as @joni suggested.  Think of &lt;span class=&quot;math-container&quot;&gt;$w_2$&lt;/span&gt; as a slack variable for &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt;, and substitute &lt;span class=&quot;math-container&quot;&gt;$w_2=1-w_1-w_3$&lt;/span&gt; throughout, yielding only three constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(b+1)(1-w_1-w_3)&amp;amp;\le \sum_i y_i \tag7 \\&#xA;b-b w_1+w_3\le\sum_i x_i&amp;amp;\le b-w_1+(n-b)w_3 \tag8 \\&#xA;w_1+w_3&amp;amp;\le 1 \tag9&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-05-14T19:05:31.317" LastActivityDate="2022-05-14T19:05:31.317" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8399" PostTypeId="1" CreationDate="2022-05-14T19:33:36.943" Score="6" ViewCount="507" Body="&lt;p&gt;Assuming you have a masters degree in operations research and this masters degree is offered in an economics department of your university.&lt;/p&gt;&#xA;&lt;p&gt;What would be a representative/appropriate name to describe this masters program to a stranger, acquaintance, friend, etc? Since most people probably wouldnt know what operations research is, would you still say you study 'operations research', or is it better to say something like 'economics', 'math', 'math and economics', or something equivalent? If its better to say something other than 'operations research', what would be the term you'd describe it with? (I personally think 'math and economics' is the best but idk)&lt;/p&gt;&#xA;" OwnerUserId="9693" LastActivityDate="2022-05-17T13:42:26.057" Title="What would be a representative/appropriate name for operations research?" Tags="|linear-programming|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8400" PostTypeId="2" ParentId="8399" CreationDate="2022-05-14T21:55:32.957" Score="8" Body="&lt;p&gt;I normally answer the &amp;quot;what's your field?&amp;quot; question with &amp;quot;operations research&amp;quot; and then follow up with a quick definition: &amp;quot;using mathematics and statistics to make decisions&amp;quot;. (Occasionally I'll throw in &amp;quot;nothing to do with surgery&amp;quot; just to be safe.) An alternative is to say &amp;quot;analytics&amp;quot; (Latin for &amp;quot;whatever type of consulting you're willing to pay for&amp;quot;) and then see if they want to nail it down a bit. The distinction if any between OR and analytics is a bit murky.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-14T21:55:32.957" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8401" PostTypeId="2" ParentId="8399" CreationDate="2022-05-15T02:34:15.787" Score="4" Body="&lt;p&gt;You could use a less technical term, such as the old &amp;quot;efficiency expert&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Even if they don't know what it &lt;em&gt;actually&lt;/em&gt; means, most people will at least &lt;em&gt;think&lt;/em&gt; that they know what it means.&lt;/p&gt;&#xA;&lt;p&gt;You're obviously an expert (now they're impressed), and what you do is to find ways of making things work better (and they know this must be a good thing to do).&#xA;You don't even need to define what &amp;quot;things&amp;quot; refers to, or what &amp;quot;better&amp;quot; means.&lt;/p&gt;&#xA;&lt;p&gt;If they're open to specific examples, give very practical, not blatantly mathematical applications.&#xA;Mention the shortest-path problem for scheduling delivery routes, or bin-packing for getting as much into a truck as possible.&lt;/p&gt;&#xA;&lt;p&gt;Generally, when people ask what someone does, they want to know what they accomplish, not the methods they use.&#xA;They don't care so much about &lt;em&gt;what&lt;/em&gt; you do, but more about &lt;em&gt;why&lt;/em&gt; anyone would pay you to do it.&lt;/p&gt;&#xA;&lt;p&gt;If they need more, think of analogies.&#xA;Many decades ago, when computers cost millions, I could never explain to my father what I did as a computer programmer, writing small ad hoc and general purpose programs to help people get their work done.&#xA;Eventually I told him I designed and built &amp;quot;jigs&amp;quot; to help the professors to do their jobs, and because of his industrial background, he finally understood it.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For those that don't know, a &amp;quot;jig&amp;quot; is a small tool designed for a very specific purpose and typically used for only a short time.&lt;/p&gt;&#xA;&lt;p&gt;For instance, when drilling holes for kitchen cabinet door knobs, I glued small strips of wood along two adjacent edges of a 2&amp;quot;×3&amp;quot; rectangle of Masonite, and drilled a hole in the appropriate place. Then I could simply hold this tool firmly in place on one corner of each door and drill through the hole, thereby ensuring that all the knobs would be positioned identically without having to individually measure and mark each corner. That temporary tool was a &amp;quot;jig&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="3482" LastEditorUserId="3482" LastEditDate="2022-05-17T13:42:26.057" LastActivityDate="2022-05-17T13:42:26.057" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8402" PostTypeId="1" AcceptedAnswerId="8404" CreationDate="2022-05-15T17:35:15.797" Score="4" ViewCount="1151" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; be a two-dimensional binary variable.&#xA;Is it possible to write &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; as a power to a number?&lt;/p&gt;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$1- 0.3^{x_{i,j}} $$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9245" LastEditorUserId="123" LastEditDate="2022-05-16T08:46:32.203" LastActivityDate="2022-05-16T20:28:20.773" Title="How can we write a binary variable as a power to a constant number?" Tags="|integer-programming|nonlinear-programming|binary-variable|cplex-python-api|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8403" PostTypeId="2" ParentId="8402" CreationDate="2022-05-15T18:05:59.543" Score="15" Body="&lt;p&gt;If you check the two cases for &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt;, you will see that you can rewrite the expression as a linear function of &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=0$&lt;/span&gt; yields &lt;span class=&quot;math-container&quot;&gt;$1-0.3^0=0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=1$&lt;/span&gt; yields &lt;span class=&quot;math-container&quot;&gt;$1-0.3^1=0.7$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So &lt;span class=&quot;math-container&quot;&gt;$1-0.3^{x_{i,j}} = 0.7x_{i,j}$&lt;/span&gt; for binary &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-05-15T18:05:59.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8404" PostTypeId="2" ParentId="8402" CreationDate="2022-05-15T21:10:12.497" Score="3" Body="&lt;p&gt;Suppose it is needed to linearize the expression &lt;span class=&quot;math-container&quot;&gt;$Z=P^U$&lt;/span&gt;. It can be written as &lt;span class=&quot;math-container&quot;&gt;$$Z=U\times P+1-U$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; is a binary variable and &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is a parameter. This is a general formulation for calculating &lt;span class=&quot;math-container&quot;&gt;$Z=P^U$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$U=0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$Z=1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$U=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$Z=P$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="123" LastEditDate="2022-05-16T20:28:20.773" LastActivityDate="2022-05-16T20:28:20.773" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8405" PostTypeId="1" AcceptedAnswerId="8408" CreationDate="2022-05-16T03:26:10.363" Score="1" ViewCount="595" Body="&lt;p&gt;The assignment problem is defined as:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Let there be n agents and m tasks. Any agent can be assigned to perform any task, incurring some costs that may vary depending on the agent-task assignment. We can assign at most one task for one person and at most one person for one task in such a way that the total cost of the assignment is maximized.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The Hungarian algorithm can solve this problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For example, I have a cost matrix as below:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;     T1   T2   T3&#xA;P1   2    2    2&#xA;P2   3    1    4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$T_{i}$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$i_{th}$&lt;/span&gt; task, &lt;span class=&quot;math-container&quot;&gt;$P_{i}$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$i_{th}$&lt;/span&gt; person.&lt;/p&gt;&#xA;&lt;p&gt;The number in the row &lt;span class=&quot;math-container&quot;&gt;$P_{i}$&lt;/span&gt; and col &lt;span class=&quot;math-container&quot;&gt;$T_{i}$&lt;/span&gt; is the cost when assigning task &lt;span class=&quot;math-container&quot;&gt;$T_{i}$&lt;/span&gt; to person &lt;span class=&quot;math-container&quot;&gt;$P_{i}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;One solution for the above problem is: &lt;span class=&quot;math-container&quot;&gt;$P_1 - T1, P_2 - T_3$&lt;/span&gt;, the max cost is 2 + 4 = 6.&lt;/p&gt;&#xA;&lt;p&gt;I want to add some constraints like:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Some people can do a task together (e.g: &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_2$&lt;/span&gt; can do task &lt;span class=&quot;math-container&quot;&gt;$T1$&lt;/span&gt; together with a cost of 10)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Some people can do some tasks together (e.g: &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_2$&lt;/span&gt; can do task &lt;span class=&quot;math-container&quot;&gt;$T1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T2$&lt;/span&gt; together with a cost of 10)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A person can do some tasks (e.g: &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt; can do task &lt;span class=&quot;math-container&quot;&gt;$T1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T2$&lt;/span&gt; consequently with a cost of 10)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So, the new solution for the above problem is: &lt;span class=&quot;math-container&quot;&gt;$P1,P2-T1,T2$&lt;/span&gt;, the max cost is 10&lt;/p&gt;&#xA;&lt;p&gt;How to approach solving this problem?&lt;/p&gt;&#xA;" OwnerUserId="9699" LastActivityDate="2022-05-16T15:08:27.397" Title="How to solve assignment problem with additional constraints?" Tags="|optimization|algorithms|assignment-problem|combinatorics|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8406" PostTypeId="2" ParentId="8405" CreationDate="2022-05-16T07:39:23.420" Score="2" Body="&lt;p&gt;This sounds like a special case of the parallel assignment problem in which the &lt;a href=&quot;https://web-static.stern.nyu.edu/om/faculty/pinedo/scheduling/shakhlevich/handout01.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;preemption&lt;/a&gt; (this is a standard notation in the scheduling theory) would be allowed. I am not aware of how this problem can still be solved by the Hungarian algorithm in an efficient way, but there are some algorithms to tackle such a problem, like &lt;a href=&quot;https://www.geeksforgeeks.org/longest-remaining-time-first-lrtf-cpu-scheduling-algorithm/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{LRPT}$&lt;/span&gt;&lt;/a&gt;, Longest Remaining Processing Time first. Also, another approach to solving this problem is Linear programming.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-05-16T07:39:23.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8407" PostTypeId="2" ParentId="8394" CreationDate="2022-05-16T08:45:17.467" Score="3" Body="&lt;p&gt;With many solvers like CPLEX you can directly write logical constraints.&lt;/p&gt;&#xA;&lt;p&gt;For instance with OPL CPLEX&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int n=5;&#xA;int m=4;&#xA;int b=2;&#xA;&#xA;dvar boolean x[1..n];&#xA;dvar boolean y[1..m];&#xA;&#xA;subject to&#xA;{&#xA;  (b==sum(i in 1..n) x[i]) =&amp;gt; (b&amp;lt;=-1+sum(i in 1..m) y[i]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;works fine&lt;/p&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2022-05-16T09:21:42.413" LastActivityDate="2022-05-16T09:21:42.413" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8408" PostTypeId="2" ParentId="8405" CreationDate="2022-05-16T15:08:27.397" Score="3" Body="&lt;p&gt;You can create additional &amp;quot;group agents&amp;quot; that represent combinations of actual agents (for instance, &lt;span class=&quot;math-container&quot;&gt;$P_{17}$&lt;/span&gt; might be the pairing of &lt;span class=&quot;math-container&quot;&gt;$P_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_2$&lt;/span&gt;) and/or additional &amp;quot;combo tasks&amp;quot; that are combinations of original tasks (for instance, &lt;span class=&quot;math-container&quot;&gt;$T_{9}$&lt;/span&gt; might be &lt;span class=&quot;math-container&quot;&gt;$T_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T_3$&lt;/span&gt; done together). You then assign &amp;quot;agents&amp;quot; to &amp;quot;tasks&amp;quot; using binary variables, and add constraints that preclude assigning a &amp;quot;group agent&amp;quot; to a task and also assigning one of the group's members (or another group sharing a member) to a different task, as well as constraints preventing an individual task and a &amp;quot;combo task&amp;quot; including that task (or two &amp;quot;combo tasks&amp;quot; that intersect) from being assigned simultaneously. This can be modeled as a binary integer program and solved by branch-and-bound/branch-and-cut.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-16T15:08:27.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8409" PostTypeId="1" AcceptedAnswerId="8425" CreationDate="2022-05-16T16:05:27.823" Score="3" ViewCount="358" Body="&lt;p&gt;I'm wondering about the impact of soft constraints, since no one mentioned that in &lt;a href=&quot;https://or.stackexchange.com/questions/1050/soft-constraints-and-hard-constraints&quot;&gt;Soft constraints and hard constraints&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My team makes all the constraints soft in MILP, so that a feasible solution can always be found. Furthermore, this finding helps us to locate problematic constraints.&lt;/p&gt;&#xA;&lt;p&gt;But that approach seems to cause lots of numerical issues, because some arbitrary large penalties are used. In my mind, we should only use soft constraints whenever its penalty makes sense in the real world. I need some arguments for hard constraints (mostly bounds on variables).&lt;/p&gt;&#xA;" OwnerUserId="3163" LastEditorUserId="67" LastEditDate="2022-05-23T15:12:51.447" LastActivityDate="2022-05-23T15:12:51.447" Title="Impact of soft constraints in MILP" Tags="|mixed-integer-programming|constraint|numerical-issues|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8410" PostTypeId="2" ParentId="8409" CreationDate="2022-05-16T19:09:28.097" Score="2" Body="&lt;p&gt;This is to a large extent an expanded version of Joris's comment.&lt;/p&gt;&#xA;&lt;p&gt;Things that have to be a certain way, period, require hard constraints. Examples: &amp;quot;We cannot ship more stuff than we have&amp;quot; -&amp;gt; shipments &amp;lt;= inventory. &amp;quot;We have to meet demand&amp;quot; -&amp;gt; shipments &amp;gt;= demand.&lt;/p&gt;&#xA;&lt;p&gt;Things that should be a certain way, but have prescribed (well defined, well understood) work-arounds when necessary, typically require hard constraints and a somewhat expanded model. Examples: &amp;quot;We can ship more stuff than we have, but it will require buying substitute products on the open market&amp;quot; -&amp;gt; shipments + external purchases &amp;lt;= inventory (plus perhaps a bound on external purchases). &amp;quot;Either we meet demand or we eat a penalty&amp;quot; -&amp;gt; shipments + shortfall &amp;gt;= demand (with an objective penalty for shortfall).&lt;/p&gt;&#xA;&lt;p&gt;Things that start with &amp;quot;we ought to&amp;quot;, &amp;quot;we would like to&amp;quot;, &amp;quot;gee, it would be nice if&amp;quot; etc. may turn into soft constraints (containing slack/surplus variables that are rewarded/penalized in the objective function).&lt;/p&gt;&#xA;&lt;p&gt;Personally, I would be suspicious of a model where the soft constraints outnumbered the hard ones.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-16T19:09:28.097" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8411" PostTypeId="1" AcceptedAnswerId="8412" CreationDate="2022-05-16T20:43:40.043" Score="1" ViewCount="155" Body="&lt;p&gt;Could anyone confirm me if I write the correct dual for my problem? The different sets confuse me a lot.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CjAF9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CjAF9.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is the source node and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; the sink node.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/WVhKp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WVhKp.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm uncertain if the last dual constraint in necessary.&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="500" LastEditDate="2022-05-16T21:01:53.240" LastActivityDate="2022-05-16T21:01:53.240" Title="Help with dual of a problem" Tags="|linear-programming|network-flow|duality|dual|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8412" PostTypeId="2" ParentId="8411" CreationDate="2022-05-16T20:55:08.950" Score="3" Body="&lt;p&gt;Looks almost correct to me.  Two issues:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Your &lt;span class=&quot;math-container&quot;&gt;$ \le$&lt;/span&gt; dual constraints suggest that you omitted &lt;span class=&quot;math-container&quot;&gt;$X_a \ge 0$&lt;/span&gt; in the primal.  If instead &lt;span class=&quot;math-container&quot;&gt;$X_a$&lt;/span&gt; is free, then your dual constraints should be &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Your Tail and Head are reversed in the dual.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-05-16T20:55:08.950" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8413" PostTypeId="1" AcceptedAnswerId="8415" CreationDate="2022-05-17T06:26:42.413" Score="2" ViewCount="156" Body="&lt;p&gt;As part of our constraints, we have&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;&amp;amp;\sum_{i=1}^{I}c_ix_i\ge y, \\&#xA;&amp;amp;\sum_{i=1}^{I}c_{i-1}x_i\le y, &#xA;\end{align*}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$y\ge0,x_i\in\{0,1\}, \forall i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am trying to code these two constraints in Julia and solve the problem using gurobi or cplex but we cannot define index &lt;span class=&quot;math-container&quot;&gt;$i=0$&lt;/span&gt; so we don't have &lt;span class=&quot;math-container&quot;&gt;$c_0$&lt;/span&gt; there.&lt;/p&gt;&#xA;&lt;p&gt;How can I code this? I tried this&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;c = zeros(I+1)&#xA;for i = 1:I+1&#xA;    c[i] = value&#xA;end&#xA;@variable(model, x[1:I], Bin)&#xA;@variable(model, y&amp;gt;=0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But then there's a mismatch between variable and parameter index.&lt;/p&gt;&#xA;&lt;p&gt;How should I correct this?&lt;/p&gt;&#xA;" OwnerDisplayName="user9659" LastEditorUserId="491" LastEditDate="2022-05-17T14:28:49.257" LastActivityDate="2022-05-17T14:28:49.257" Title="Coding some parameters with index zero in Julia" Tags="|modeling|cplex|solver|gurobi|julia|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8414" PostTypeId="1" AcceptedAnswerId="8416" CreationDate="2022-05-17T07:07:41.787" Score="3" ViewCount="146" Body="&lt;p&gt;I have a challenge that is a bit backwards from the usual labour resource leveling problem.&lt;/p&gt;&#xA;&lt;p&gt;In my case I have a fixed budget pool over a period to deliver some of the work packages (not enough per period to deliver all). So I need to look at how to efficiently assign work packages to the period while keeping in mind the dependencies.&lt;/p&gt;&#xA;&lt;p&gt;Thinking this through it's probably an knapsack problem with each period's budget being a bucket to be filled - so this, potentially, is more of an excel solution than a project software one - even though I face this kind of problem any time an organisation is attempting to run a program without a specific allocated budget (typical for government where applying for a budget is often artificially hard).&lt;/p&gt;&#xA;&lt;p&gt;I'm not an OR person so this is a bit vague for me :)&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&#xA;Work packages can have funds allocated against their start, even if they flow over more than one period so we can consider their start date to be the date they are fully funded and forget about them after this.&lt;/p&gt;&#xA;&lt;p&gt;Dependencies are precedence constraints&lt;/p&gt;&#xA;&lt;p&gt;Work packages can start in any time period as long as their dependencies are met but I would like to maximise the work done in a period.&lt;/p&gt;&#xA;" OwnerUserId="9705" LastEditorUserId="9705" LastEditDate="2022-05-17T14:30:02.023" LastActivityDate="2022-05-17T16:02:01.180" Title="Project task scheduling based on available budget per period" Tags="|linear-programming|scheduling|knapsack|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8415" PostTypeId="2" ParentId="8413" CreationDate="2022-05-17T07:35:09.787" Score="3" Body="&lt;p&gt;Just use &lt;code&gt;c[i+1]&lt;/code&gt; when indexing &lt;code&gt;c&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@constraint(model, sum(c[i+1] * x[i] for i in 1:I) &amp;gt;= y)&#xA;@constraint(model, sum(c[i] * x[i] for i in 1:I) &amp;lt;= y)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;P.s. feel free to post on the JuMP community forum with these questions. Not sure how many Julia people hang out here: &lt;a href=&quot;https://discourse.julialang.org/c/domain/opt/13&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://discourse.julialang.org/c/domain/opt/13&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2022-05-17T07:35:09.787" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8416" PostTypeId="2" ParentId="8414" CreationDate="2022-05-17T08:31:50.853" Score="3" Body="&lt;p&gt;Define a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{it}$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if work package &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; (i.e., work package starts at time period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;If there is a cost &lt;span class=&quot;math-container&quot;&gt;$c_{it}$&lt;/span&gt; per couple &lt;span class=&quot;math-container&quot;&gt;$(i,t)$&lt;/span&gt;, you can minimize the objective function&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i,t} c_{it}x_{it} \tag{1}&#xA;$$&lt;/span&gt;&#xA;subject to&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;One period per work package:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{t} x_{it} = 1 \quad \forall i \tag{2}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Budget constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i,t} c_{it} x_{it} \le \mbox{Budget} \tag{3}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Precedence constraints: for each work package &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$p(i)$&lt;/span&gt; be the set of work packages that must be done before &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{it} \le \sum_{h\in\{1,..., t-1\}} x_{jh} \quad \forall i, \forall j \in p(i) \tag{4}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you do not have enough budget for all work packages, you can maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,t}x_{i,t}$&lt;/span&gt; and replace constraints &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\sum_{t} x_{it} \le 1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-05-17T16:02:01.180" LastActivityDate="2022-05-17T16:02:01.180" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8417" PostTypeId="1" CreationDate="2022-05-17T15:44:01.440" Score="4" ViewCount="293" Body="&lt;p&gt;I am new to OR. Hence, I want your advice on the problem I am trying to solve:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Given:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$O_1 \rightarrow O_2 \rightarrow O_3 \rightarrow ... \rightarrow O_n$&lt;/span&gt;: the sequence of operations to produce &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; product.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;: the set of machines that can perform operations. Any machine can perform any operation.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;: the time matrix, where &lt;span class=&quot;math-container&quot;&gt;$D_{ij}$&lt;/span&gt; is the time units required by machine &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; to perform operation &lt;span class=&quot;math-container&quot;&gt;$O_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;: the cost matrix, where &lt;span class=&quot;math-container&quot;&gt;$C_{ij}$&lt;/span&gt; is the cost for running machine &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; for performing operation &lt;span class=&quot;math-container&quot;&gt;$O_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;: the total number of products required to produce.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$T_p$&lt;/span&gt;: the maximum allowed time to produce &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; products.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Find the minimum number of machines with minimum cost that can produce &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; products in time units &lt;span class=&quot;math-container&quot;&gt;$T_p$&lt;/span&gt;. The cost of adding a new machine from machines set &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; can be ignored.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Assuming that &lt;span class=&quot;math-container&quot;&gt;$T_1 \leq T_p$&lt;/span&gt;, the solution always exists. The worst-case solution will be just adding extra machines. For example: if producing &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; product in &lt;span class=&quot;math-container&quot;&gt;$T_1$&lt;/span&gt; time units requires machines &lt;span class=&quot;math-container&quot;&gt;$M_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_2$&lt;/span&gt;, then producing &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; products in &lt;span class=&quot;math-container&quot;&gt;$T_2 = T_1$&lt;/span&gt; will require adding extra &lt;span class=&quot;math-container&quot;&gt;$M_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_2$&lt;/span&gt; machines in the worst case.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$O_1 \rightarrow O_2$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$M = \{M_1, M_2 \}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$D = \begin{pmatrix} 1 &amp;amp; 5000 \\ 5000 &amp;amp; 100 \end{pmatrix}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$C = \begin{pmatrix} 1 &amp;amp; 1 \\ 1 &amp;amp; 1 \end{pmatrix}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$P = 2$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T_2 = 102$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Solution:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M_1$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;works on &lt;span class=&quot;math-container&quot;&gt;$(P_1, O_1)$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$t=0$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t=1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;works on &lt;span class=&quot;math-container&quot;&gt;$(P_2, O_1)$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$t=1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t=2$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M_2$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;works on &lt;span class=&quot;math-container&quot;&gt;$(P_1, O_2)$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$t=1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t=101$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M_2^{extra}$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;works on &lt;span class=&quot;math-container&quot;&gt;$(P_2, O_2)$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$t=2$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t=102$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Two products can be produced using 3 machines (1 &lt;span class=&quot;math-container&quot;&gt;$M_1$&lt;/span&gt; and 2 &lt;span class=&quot;math-container&quot;&gt;$M_2$&lt;/span&gt;) in &lt;span class=&quot;math-container&quot;&gt;$T_2=102$&lt;/span&gt; seconds.&lt;/p&gt;&#xA;&lt;p&gt;So far, I have been trying to model this using Assignment and Job Shop Scheduling problems. From one side, we need to assign machines to operations, but we can assume that we have infinite machine resources. So this problem is not a strict assignment problem. From the other side, it seems like JSSP where there are &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; identical jobs with the same set of operations. However, it is not JSSP because each machine can perform any operation if idle. Also, we can always add an extra machine.&lt;/p&gt;&#xA;&lt;p&gt;I would appreciate it if you let me know if there are similar problems in the OR literature or guide about modeling the above problem.&lt;/p&gt;&#xA;" OwnerUserId="9709" LastEditorUserId="67" LastEditDate="2022-05-19T18:33:42.900" LastActivityDate="2022-07-14T10:05:42.210" Title="Identifying problem: Assignment + Job Shop Scheduling" Tags="|mixed-integer-programming|scheduling|assignment-problem|job-shop-scheduling|" AnswerCount="2" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="8418" PostTypeId="1" AcceptedAnswerId="8419" CreationDate="2022-05-17T16:18:43.960" Score="4" ViewCount="626" Body="&lt;p&gt;We would like to model a constraint for an assignment problem that dictates that either assign a specific subset of nodes &lt;span class=&quot;math-container&quot;&gt;$I\subset\mathcal{I}$&lt;/span&gt; to a specific subset of nodes &lt;span class=&quot;math-container&quot;&gt;$J\subset\mathcal{J}$&lt;/span&gt;, or don't assign them at all.&lt;/p&gt;&#xA;&lt;p&gt;In other words, for variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}\in\{0,1\}, \forall i\in\mathcal{I},j\in\mathcal{J}$&lt;/span&gt;, either &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1, \forall i\in I, j \in J$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to model this?&lt;/p&gt;&#xA;" OwnerDisplayName="user9659" LastActivityDate="2022-05-17T20:28:50.263" Title="Modeling an either-or-constraint" Tags="|modeling|integer-programming|constraint|binary-variable|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8419" PostTypeId="2" ParentId="8418" CreationDate="2022-05-17T16:49:23.697" Score="4" Body="&lt;p&gt;You can introduce an additional binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if at least one node from &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is matched with another one from &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;x_{ij} &amp;amp;\le y \quad \forall i\in I, j\in J \\&#xA;x_{ij} &amp;amp;\le 1-y \quad \forall i\not\in I \; \mbox{or} \; j\not \in J \\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And then impose that if &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;, the other nodes belonging to &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; must be assigned to one node from &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y \le \sum_{j \in J} x_{ij} \quad \forall i\in I&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-05-17T16:49:23.697" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8420" PostTypeId="2" ParentId="8418" CreationDate="2022-05-17T19:23:13.260" Score="5" Body="&lt;p&gt;Based on the clarification about regions, it seems that all you have to do is add the constraints &lt;span class=&quot;math-container&quot;&gt;$$x_{ij}=0\quad\forall i\in I,j\notin J.$$&lt;/span&gt; How to handle the &amp;quot;treat it differently&amp;quot; part may require some additional model structure.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-05-17T20:28:50.263" LastActivityDate="2022-05-17T20:28:50.263" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8421" PostTypeId="1" CreationDate="2022-05-18T19:20:11.490" Score="4" ViewCount="62" Body="&lt;p&gt;In his &lt;a href=&quot;https://www.youtube.com/watch?v=ADvBM2j51U0&quot; rel=&quot;nofollow noreferrer&quot;&gt;2016 Usenix presentation&lt;/a&gt; Bryan Cantrill highlighted an issue with how conferences work in operating system research. He mentioned an alternative format called &lt;a href=&quot;https://queue.acm.org/author_guidelines.cfm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Queue by ACM&lt;/a&gt; which he describes as leading practitioners are gathered and in loose atmosphere discuss what kind of articles they want to see and then people are found to work on these topics, the paper is peer reviewed by other practitioners and guaranteed publication once it is satisfactory.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jmAjj.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jmAjj.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Are you aware of such &amp;quot;journals&amp;quot; in OR or sub-fields of OR?&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2022-05-18T20:49:57.820" LastActivityDate="2022-05-18T20:49:57.820" Title="What is the ACM Queue for operations research (or sub-disciplines)?" Tags="|academia|industry|journals|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8422" PostTypeId="5" CreationDate="2022-05-19T08:17:39.790" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2022-05-19T08:17:39.790" LastActivityDate="2022-05-19T08:17:39.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8423" PostTypeId="4" CreationDate="2022-05-19T08:17:39.790" Score="0" Body="Disciplined convex programming (DCP) is a system for constructing mathematical expressions with known curvature from a given library of base functions. " OwnerUserId="8" LastEditorUserId="8" LastEditDate="2022-05-19T12:15:21.720" LastActivityDate="2022-05-19T12:15:21.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8425" PostTypeId="2" ParentId="8409" CreationDate="2022-05-19T10:30:31.147" Score="5" Body="&lt;p&gt;From a paper on the branch-and-cut in MILP solvers:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Because cuts are often based on infeasibility, models with soft constraints&#xA;that are always feasible can present unique challenges for deriving cuts.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This seems to explain why to solve a MILP with lots of soft constraints is difficult.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Klotz, E., &amp;amp; Newman, A. M. (2013). Practical guidelines for solving difficult mixed integer linear programs. Surveys in Operations Research and Management Science, 18(1-2), 18-32.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3163" LastActivityDate="2022-05-19T10:30:31.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8426" PostTypeId="1" AcceptedAnswerId="8429" CreationDate="2022-05-19T12:04:10.867" Score="2" ViewCount="86" Body="&lt;p&gt;I'm working on a model for inventory management. I'm trying to decide for each unit if it is worth holding, or if it should be liquidated at a cost &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I'm wondering about the argument that marginal holding cost for any unit are 0, because the warehouse is there, the unit is there, etc., so there is no real cost of holding an additional unit in the warehouse other than cost of capital, with the exception that the last units that fit in start creating opportunity cost.&lt;/p&gt;&#xA;&lt;p&gt;That seems intuitively right, but brings me to the problem that I have the incentive of keeping stock with extremely high reaches - which seems intuitively wrong.&lt;/p&gt;&#xA;&lt;p&gt;Am I missing something? Is it &amp;quot;mathematically&amp;quot; correct to assume the first unit in the warehouse has all the marginal cost of the entire warehouse cost? How can I model this correctly? Is there literature on this?&lt;/p&gt;&#xA;" OwnerUserId="7430" LastEditorUserId="123" LastEditDate="2022-05-19T12:18:56.393" LastActivityDate="2022-05-19T15:51:41.057" Title="Marginal Cost of Storage vs. sum of storage cost" Tags="|modeling|inventory|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8427" PostTypeId="5" CreationDate="2022-05-19T12:21:08.103" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2022-05-19T12:21:08.103" LastActivityDate="2022-05-19T12:21:08.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8428" PostTypeId="4" CreationDate="2022-05-19T12:21:08.103" Score="0" Body="Logistics refers to the overall process of managing how resources are acquired, stored, and transported to their final destination." OwnerUserId="8" LastEditorUserId="8" LastEditDate="2022-05-19T12:34:15.507" LastActivityDate="2022-05-19T12:34:15.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8429" PostTypeId="2" ParentId="8426" CreationDate="2022-05-19T15:51:41.057" Score="2" Body="&lt;p&gt;Cost of capital is one component of holding cost, but not always the only one. If the product is subject to degradation (for instance, produce that goes bad over time), that factors into holding cost. If there is loss due to pilferage or other reasons, that contributes. If the company insures the contents of the warehouse, it is possible (I think) that the cost of the insurance might factor into holding cost. I would be inclined to ask an accountant how holding cost is computed.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-19T15:51:41.057" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8430" PostTypeId="1" AcceptedAnswerId="8437" CreationDate="2022-05-19T19:42:05.337" Score="7" ViewCount="387" Body="&lt;p&gt;Suppose that we have data (in my case, from a chemical process) which includes &lt;em&gt;input&lt;/em&gt; data &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; (characteristic of the material to be processed) and &lt;em&gt;decision&lt;/em&gt; data &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; (decisions taken by operators to process this material), which produce an output value &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, but there are no clear explanations on how these decisions impact the output.&lt;/p&gt;&#xA;&lt;p&gt;To solve this, I can construct a machine learning model &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; from the data, that represents how decisions &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; impact on the input data &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; to produce this output. For example, I can construct a linear regression model &lt;span class=&quot;math-container&quot;&gt;$\hat\beta$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$f(X,Y) := \hat\beta_X X + \hat\beta_Y Y \approx z$&lt;/span&gt;. My final objective is to optimize the resulting model. That is, given a new input data &lt;span class=&quot;math-container&quot;&gt;$X'$&lt;/span&gt;, to solve&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \min_Y f(X',Y) \text{ s.t. } Y\in\Omega$$&lt;/span&gt;&#xA;(for example, with a lineal regression mode, we can solve a linear problem subject to linear constraints easily)&lt;/p&gt;&#xA;&lt;p&gt;My question is if this kind of ML models and this use of them has been studied formally. Because, in some sense, both types of data are quite different (one is an input, the other can be controlled) but a &amp;quot;classic&amp;quot; ML model will treat them similarly. It is very probable that strong correlations exist between the input data and the decision data, which should not be eliminated. For example, high levels of a compound (an input) can require high levels of a reactant (a decision), but a classic linear regression model can remove one of them from the model for being correlated, which is exactly the opposite that I need. Also, it is quite probable that very bad decisions are never taken (so there will be no data for these cases), so you don't want that the model overestimate these regions.&lt;/p&gt;&#xA;&lt;p&gt;Probably this has been studied, and may even have a name, but I can't find it. I do found papers constructing ML models and then optimizing them, but most of them don't care about these issues between input and decision data on the construction of the ML model.&lt;/p&gt;&#xA;&lt;p&gt;Any idea or pointer to the literature on this subject?&lt;/p&gt;&#xA;" OwnerUserId="73" LastEditorUserId="73" LastEditDate="2022-05-19T19:57:33.667" LastActivityDate="2022-05-27T09:46:37.440" Title="Training ML models to be used as objectives in optimization problems" Tags="|optimization|machine-learning|regression|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8431" PostTypeId="2" ParentId="8417" CreationDate="2022-05-19T21:16:32.737" Score="2" Body="&lt;p&gt;I don't know that this problem falls neatly into any job scheduling category, although I would not be shocked if there are papers in the literature solving something equivalent or very similar. Both constraint programming (CP) and mixed integer linear programming (MILP) models are possible.&lt;/p&gt;&#xA;&lt;p&gt;Assuming a MILP model is desired, one approach (if supported by the solver) would be to specify a two dimensional objective function (machine count or cost, operating cost) to be minimized lexicographically. CPLEX, for instance, allows this. If lexicographic optimization is not supported, you would need to solve two models: first minimizing machine count/cost; then minimizing production cost with the optimal machine count/cost as a constraint.&lt;/p&gt;&#xA;&lt;p&gt;There may be multiple ways to approach this. I'll use the term &amp;quot;job&amp;quot; to refer to one unit of production. I would use the following variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}$&lt;/span&gt; indicating whether job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; uses a machine of type &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; to perform operation &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;nonnegative integer variables &lt;span class=&quot;math-container&quot;&gt;$s_{ik}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e_{ik}$&lt;/span&gt; representing the time job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; starts and ends operation &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; (respectively);&lt;/li&gt;&#xA;&lt;li&gt;nonnegative integer variables &lt;span class=&quot;math-container&quot;&gt;$z_j$&lt;/span&gt; representing the number of type &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; machines put into service;&lt;/li&gt;&#xA;&lt;li&gt;binary variables &lt;span class=&quot;math-container&quot;&gt;$u_{ikt}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v_{ikt}$&lt;/span&gt; representing respectively whether operation &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; on job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; begins on or before time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and ends on or after time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;; and&lt;/li&gt;&#xA;&lt;li&gt;binary variables &lt;span class=&quot;math-container&quot;&gt;$w_{ijkt}$&lt;/span&gt; indicating whether operation &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; on job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; occupies a machine of type &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-19T21:16:32.737" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8432" PostTypeId="2" ParentId="8430" CreationDate="2022-05-19T22:32:48.283" Score="2" Body="&lt;p&gt;This reminds me of two concepts:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The first is meta-modelling which is used in health economics  (and probably also used in other disciplines). The way it is used there is that based on some decision X in a simulation model, we try to predict the resulting objective value of that decision. It is used to substitute computationally intensive simulations by regression models. See a paper about meta-modelling in health economics  &lt;a href=&quot;https://www.tandfonline.com/doi/abs/10.1080/14737167.2019.1548279&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&#xA;I am aware that it is still  different from your problem, as you do not only have decision data but some other (external) input. But the concept of predicting the objective value is the same, so it might serve as a start point.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The second are specific types of value function approximation, such as Q-learning. In Q-learning (with function approximation), we try to approximate the value of a state action pair. In your case, a state could be described by input &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and your action is decision &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;. Again, this is also not exactly suitable for your problem, because firstly, Q-learning is meant for sequential decision problems which I assume you do not deal with and secondly, the action (decision) in Q-learning is chosen by some  strategy and not pre given. However, evaluating state action pairs is what you also want, so this might also serve as a starting point.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Additionally you should checkout inverse reinforcement learning where the goal is to learn an agent's objective by studying it's actions.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2022-05-19T22:32:48.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8433" PostTypeId="1" CreationDate="2022-05-20T09:20:11.917" Score="2" ViewCount="112" Body="&lt;p&gt;The main problem is the optimization of the filling of a tank, filling it in cheap periods and extracting in expensive periods to sell. I am using Python and gurobipy.&lt;/p&gt;&#xA;&lt;p&gt;I am not able to model this constraint:&#xA;the daily injection should be less than an expression depending on the previous day's filling.&lt;/p&gt;&#xA;&lt;p&gt;\begin{align}X_i&amp;amp;\le C_i*(\sum_{j=0}^{j=i-1} X_j )\end{align}&lt;/p&gt;&#xA;&lt;p&gt;I have tried with this expression:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;m.addConstrs((x[i]&amp;lt;= C[i]*v1) for i in index)    &#xA;v1=sum(x[j] for j in range(1,i-1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But it does not work. Note that &lt;span class=&quot;math-container&quot;&gt;$C_i$&lt;/span&gt; is a constant.&lt;/p&gt;&#xA;" OwnerUserId="9570" LastEditorUserId="491" LastEditDate="2022-05-21T19:17:15.270" LastActivityDate="2022-05-21T19:17:15.270" Title="Restriction on gurobipy problem" Tags="|optimization|mixed-integer-programming|python|constraint|gurobi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8434" PostTypeId="2" ParentId="8433" CreationDate="2022-05-20T12:04:55.003" Score="2" Body="&lt;p&gt;Try&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;m.addConstrs(x[i] &amp;lt;= C[i] * sum(x[j] for j in range(i)) for i in index)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Python's &lt;code&gt;range(n)&lt;/code&gt; yields an iterator from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;n-1&lt;/code&gt;. I also think that defining &lt;code&gt;v1&lt;/code&gt; after the constraint won't work (moreover, &lt;code&gt;i&lt;/code&gt; ist not known to &lt;code&gt;v1&lt;/code&gt;) and even if, I think the code becomes more legible if you avoid this.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2022-05-20T12:04:55.003" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8435" PostTypeId="1" AcceptedAnswerId="8438" CreationDate="2022-05-20T12:56:50.683" Score="2" ViewCount="215" Body="&lt;p&gt;I have a system with &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; resources.&lt;/p&gt;&#xA;&lt;p&gt;There are &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; users in the system demanding these resources.&lt;/p&gt;&#xA;&lt;p&gt;The demand of resources for a given user &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_k$&lt;/span&gt; follows &lt;span class=&quot;math-container&quot;&gt;$d_k\in\{1,3,6\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraints for this problem are&lt;/p&gt;&#xA;&lt;p&gt;a. The resources assigned to any user are contiguous&lt;/p&gt;&#xA;&lt;p&gt;b. One resource can be assigned to one user only.&lt;/p&gt;&#xA;&lt;p&gt;c. One or more users may not get any resources.&lt;/p&gt;&#xA;&lt;p&gt;d. An user can access only a given set of contiguous resources, its candidates.&lt;/p&gt;&#xA;&lt;p&gt;Example,&lt;/p&gt;&#xA;&lt;p&gt;For user 1, we have &lt;span class=&quot;math-container&quot;&gt;$d_1=3$&lt;/span&gt;, this means user 1 needs three resources out of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; resources.&#xA;Lets say, for this user, the number of sets of accessible contiguous resources is 4, and the sets of given resources are given as &lt;span class=&quot;math-container&quot;&gt;$\{\{1,2,3\},\{7,8,9\},\{11, 12,13\}, \{17,18,19\}\}$&lt;/span&gt;. This means, if user 1 gets its demand satisfied, the assigned resources must be of one of these 4 sets/subsets/candidates.&lt;/p&gt;&#xA;&lt;p&gt;Similarly, let the demand of user 2 be 1, &lt;span class=&quot;math-container&quot;&gt;$d_2=1$&lt;/span&gt;, i.e., needs 1 out of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; resources. And it has 5 candidates.&lt;/p&gt;&#xA;&lt;p&gt;The different sets of resources that can be assigned to this user &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; is given by&#xA;&lt;span class=&quot;math-container&quot;&gt;$S_2=\{\{1\},\{9\},\{17\},\{27\},\{33\}\}$&lt;/span&gt;. So, for user 2, we have 5 candidates/sets/subsets of contiguous resources.&lt;/p&gt;&#xA;&lt;p&gt;I want to serve as many users as possible.&lt;/p&gt;&#xA;&lt;p&gt;What is an efficient heuristic model for this user packing problem.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="67" LastEditDate="2022-05-22T15:06:09.030" LastActivityDate="2022-05-24T19:21:30.777" Title="How to model this user packing problem?" Tags="|modeling|scheduling|heuristics|packing|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8436" PostTypeId="1" CreationDate="2022-05-20T17:57:16.207" Score="5" ViewCount="210" Body="&lt;p&gt;&lt;a href=&quot;https://www.math.uwaterloo.ca/tsp/concorde/DOC/index.html&quot; rel=&quot;noreferrer&quot;&gt;Concorde&lt;/a&gt; is a well-known exact solver for instances of the traveling salesman problem. It can also be used to solve asymmetric TSPs, if the user implements a &lt;a href=&quot;https://en.wikipedia.org/wiki/Travelling_salesman_problem#Asymmetric&quot; rel=&quot;noreferrer&quot;&gt;trick&lt;/a&gt; to convert ATSP to TSP.&lt;/p&gt;&#xA;&lt;p&gt;However, if the problem size is large enough, the resulting weights can be very large. A &lt;a href=&quot;https://doi.org/10.1109/HIS.2008.30&quot; rel=&quot;noreferrer&quot;&gt;paper&lt;/a&gt; on the railway TSP says the following:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;For the symmetric TSP transformation, we still have some implementation-dependent problems with the big &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M'$&lt;/span&gt; added to the edges costs. Trying to solve instances where the salesman visits 15 cities results in integer over- flows and the branch-and-cut algorithm can only operate with integer values. Therefore, we would like to enhance the transformation procedure to overcome this difficulty.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This can be easily empirically verified, as here is the Concorde output in such a case:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Using random seed 1653068890&#xA;Problem Name: amtrak&#xA;Problem Type: TSP&#xA;Number of Nodes: 5192&#xA;Explicit Lengths (CC_MATRIXNORM)&#xA;Set initial upperbound to 1599011938 (from tour)&#xA;  LP Value  1: 1598949533.191495  (19.84 seconds)&#xA;  LP Value  2: 1598950007.500001  (22.02 seconds)&#xA;New lower bound: 1598950007.499611&#xA;  LP Value  1: 1598950007.500002  (23.67 seconds)&#xA;New upperbound from x-heuristic: 1598999315.00&#xA;Final lower bound 1598950007.499611, upper bound 1598999315.000000&#xA;OVERFLOW in CCbigguy_addmult (4)&#xA;BIGGUY errors are fatal&#xA;FATAL ERROR - received signal SIGABRT (6/6)&#xA;sleeping 1 more hours to permit debugger access&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My first thought is that this is really nothing more than an implementation issue, as I don't see a reason why numerical values in Concorde have to be stored as a specific data type. So, is there any TSP solver out there similar to Concorde that can handle such large values?&lt;/p&gt;&#xA;&lt;p&gt;I am not interested in workarounds such as &amp;quot;just scale your values down&amp;quot; as this results in a loss of precision, and if one is using Concorde to begin with then it is clear an exact precise optimal result is desired.&lt;/p&gt;&#xA;" OwnerUserId="9724" LastActivityDate="2022-05-20T17:57:16.207" Title="How to overcome overflow issues with Concorde?" Tags="|traveling-salesman|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8437" PostTypeId="2" ParentId="8430" CreationDate="2022-05-20T18:30:41.453" Score="6" Body="&lt;p&gt;There is a recent paper by Bergman et al. [1] in the INFORMS Journal on Computing that integrates various types of predictive models with optimization models. It might be of interest.&lt;/p&gt;&#xA;&lt;p&gt;[1] Bergman, D.; Huang, T.; Brooks, P.; Lodi, A. &amp;amp; Raghunathan, A. U.&#xA;JANOS: An Integrated Predictive and Prescriptive Modeling Framework.&#xA;&lt;em&gt;INFORMS Journal on Computing&lt;/em&gt;, &lt;strong&gt;2022&lt;/strong&gt;, &lt;em&gt;34&lt;/em&gt;, 807.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-05-20T18:30:41.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8438" PostTypeId="2" ParentId="8435" CreationDate="2022-05-20T18:43:58.040" Score="1" Body="&lt;p&gt;I can suggest a couple of heuristics, with absolutely no guarantee that they will perform well. They share a common data structure. Start by identifying all sets of contiguous resources useful to any user. Map each user to the set of resource sets suitable for that user (noting that a given resource set might be useful for more than one user), and each resource set to the set of users that can use it. Next, map each resource set to the set of resource sets with which it conflicts (intersects). For instance, &lt;span class=&quot;math-container&quot;&gt;$\lbrace 1, 2\rbrace$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lbrace 2, 3, 4\rbrace$&lt;/span&gt; conflict because resource 2 is contained in their intersection.&lt;/p&gt;&#xA;&lt;p&gt;You can now proceed in a number of ways. One is to prioritize the resource sets either randomly or according to how many unserved users they would serve (I would go with a smaller user set having higher priority than a larger user set) or based on the number of surviving conflicts they have (fewer means higher priority), then take the highest priority resource and assign it to one of the users it can serve (either randomly or by picking the user with the fewest remaining options). Another is to prioritize the users based on how many of their options survive, then take the user with the fewest remaining choices and assign a resource (either randomly or based on the fewest surviving conflicts). In each case, after making an assignment, delete the user from the pool of unserved users and delete the resource &lt;em&gt;and all surviving conflicted resources&lt;/em&gt; from the pool of available resources.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: I wrote a &lt;a href=&quot;https://orinanobworld.blogspot.com/2022/05/allocating-resource-sets.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;blog post&lt;/a&gt; about this that includes a link to my Java code.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-05-24T19:21:30.777" LastActivityDate="2022-05-24T19:21:30.777" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="8439" PostTypeId="2" ParentId="8430" CreationDate="2022-05-21T01:56:14.990" Score="2" Body="&lt;p&gt;So you have historical observations of &lt;span class=&quot;math-container&quot;&gt;$(X, Y, z)$&lt;/span&gt;. I'll assume that you know how to construct a model &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$f(X, Y) \simeq z$&lt;/span&gt;, and that you have such a model ready by. In other words, you've done the training, and now you focus on &lt;em&gt;optimizing&lt;/em&gt; its output, i.e., on solving a problem of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_{Y} \quad &amp;amp; f(X, Y)\\&#xA;s.t. \quad &amp;amp;  Y \in \Omega&#xA;\end{align}&lt;/span&gt;&#xA;for given &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As you have already mentioned, depending on the nature of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, this may be more or less simple. If &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is linear, then your objective is linear.&#xA;In addition to JANOS mentioned in another comment, you may find the &lt;a href=&quot;https://github.com/cog-imperial/OMLT&quot; rel=&quot;nofollow noreferrer&quot;&gt;OMLT&lt;/a&gt; software to be close to what you describe. That choice is in python,  and it supports several classes of models out-of-the-box.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2022-05-21T01:56:14.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8440" PostTypeId="1" CreationDate="2022-05-21T15:59:33.143" Score="3" ViewCount="1037" Body="&lt;p&gt;For an upcoming client project, I'm looking to do a 3D variant on the knapsack problem.  Basically, there's a bin of dimensions &lt;span class=&quot;math-container&quot;&gt;$x,y,z$&lt;/span&gt;, and I have &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; units of an item with dimensions &lt;span class=&quot;math-container&quot;&gt;$a,b,c$&lt;/span&gt;.  (Assuming rectangular prisms for both the bin and the item).&lt;/p&gt;&#xA;&lt;p&gt;I want to find the max number of units (&lt;span class=&quot;math-container&quot;&gt;$\le K$&lt;/span&gt;) that will fit in the bin.  Are there are any ready-made Python or R packages I could use for this?  Answering this question is actually a preparatory step in a larger optimization model, so even if I need to just write the MIP into the overall model that would be OK too.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastEditorUserId="123" LastEditDate="2022-05-21T16:47:41.053" LastActivityDate="2022-05-21T19:56:55.830" Title="3D Knapsack Problem: R or Python Packages?" Tags="|python|combinatorial-optimization|knapsack|r|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8442" PostTypeId="2" ParentId="8440" CreationDate="2022-05-21T19:56:55.830" Score="4" Body="&lt;p&gt;As the container loading problem is NP-hard in its essence, therefore, using a mixed-integer program might not be efficient to solve this kind of problem, except using advanced techniques like column generation to solve the large-scale instances.&lt;/p&gt;&#xA;&lt;p&gt;By the way, using CP would be a good choice than the MIP. If you are still willing to use MIP there are many papers that could be easily found by googling. (E.g. &lt;a href=&quot;http://dx.doi.org/10.1299/jsmec.46.60&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; one.).&lt;/p&gt;&#xA;&lt;p&gt;One possible way to use CP is based on non-overlap constraints. I worked on a 2D loading problem by using this kind of constraint. The result was so effective. It also would be possible to divide the height of the container by the number of equal floors and applying this system to optimize each floor separately.&#xA;Also, this needs to perform some pre-processing to categorize items by the appropriate height.&lt;/p&gt;&#xA;&lt;p&gt;Indeed, in the following there are two python packages, one excel package, and one commercial software to solve such a problem that might be helpful:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/enzoruiz/3dbinpacking&quot; rel=&quot;nofollow noreferrer&quot;&gt;3D Bin Packing implementation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Janet-19/3d-bin-packing-problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;A python model of the 3D Bin Packing problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.euro-online.org/websites/verolog/clp-spreadsheet-solver-2/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Excel-based 3D bin-packing problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.cargooptimizer.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;cargo optimizer (as a commercial software)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-05-21T19:56:55.830" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8443" PostTypeId="1" CreationDate="2022-05-21T20:01:08.627" Score="1" ViewCount="40" Body="&lt;p&gt;I have a mathematical model written in docplex python. For analysis, I have to generate different sized data with batch file which can be input for the problem. How can I generate this type of batch file?&lt;/p&gt;&#xA;" OwnerUserId="9245" LastActivityDate="2022-05-21T20:01:08.627" Title="batch file for docplex" Tags="|python|docplex|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8444" PostTypeId="1" CreationDate="2022-05-21T21:50:05.593" Score="2" ViewCount="220" Body="&lt;p&gt;For a simple traveling salesman problem, I am trying to add the &amp;quot;miller-tucker-zemlin subtour elimination constraints&amp;quot; by using ILOLAZYCONSTRAINTCALLBACK.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ILOLAZYCONSTRAINTCALLBACK3(lazycallback, BoolVarArray2, x, IloNumVarArray, u, IloCplex, tspcplex) {&#xA;        IloInt const lokasyon = u.getSize();&#xA;    for (IloInt i = 0; i &amp;lt; lokasyon; ++i) {&#xA;        for (IloInt j = 0; j &amp;lt; lokasyon; ++j) {&#xA;            IloNum ui = getValue(u[i]);&#xA;            IloNum xij = getValue(x[i][j]);&#xA;            IloNum uj = getValue(u[j]);&#xA;            if (ui - uj + lokasyon * xij &amp;lt;= lokasyon - 1) {&#xA;                cout &amp;lt;&amp;lt; &amp;quot; Adding lazy constraint. i = &amp;quot; &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot; j = &amp;quot; &amp;lt;&amp;lt; j &amp;lt;&amp;lt; endl;&#xA;&#xA;                add(u[i] - u[j] + lokasyon * x[i][j] &amp;lt;= lokasyon - 1).end();&#xA;}}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I need to getValues of my &amp;quot;decision variables&amp;quot;, which are u[i] and x[i][j], to check if the subtour elimination constraints are violated; but cplex fails to solve.&lt;/p&gt;&#xA;&lt;p&gt;I don't have anything missing with the model, environment, objective function or other constraints.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;tspcplex.use(lazycallback(tspenv, x, u, tspcplex));&#xA;tspcplex.solve();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After tspcplex.solve I enter ILOLAZY... but I don't have a solution yet. bool &amp;quot;tspcplex.solve()&amp;quot; is not true so we have an execption thrown at getValue.&lt;/p&gt;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="9726" LastEditorUserId="9726" LastEditDate="2022-05-22T19:48:21.700" LastActivityDate="2022-05-22T19:48:21.700" Title="Trying to add lazy constraints to traveling salesman problem" Tags="|optimization|combinatorial-optimization|traveling-salesman|c++|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="8445" PostTypeId="1" CreationDate="2022-05-23T16:38:24.383" Score="2" ViewCount="215" Body="&lt;p&gt;I spent some time trying to clarify the problem more succinctly.&#xA;I has a set of fixed tasks which are of a certain type/category and which can be allocated to a set of workers.&#xA;The tasks have predefined start times/durations and have an optional gap (i.e. 30) which must be honoured when the tasks are performed by the same worker.&#xA;The idea is to constrain worker allocation in the following ways&lt;/p&gt;&#xA;&lt;p&gt;a) each task is performed by a single worker,&lt;br /&gt;&#xA;b) no worker can perform an overlapping task, and&lt;br /&gt;&#xA;c) no worker can be allocated to successive tasks of the same type/category without satisfying the leaving the required gap.&lt;/p&gt;&#xA;&lt;p&gt;Constraint c) is to ensure that tasks which are deemed difficult/taxing are not allocated successively to the same worker. This is the concept /constraint that I am having difficulty in applying.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   public class Task&#xA;    {&#xA;        public Task(int taskId, int start, int duration, string type, int gap =30)&#xA;        {&#xA;            TaskId = taskId;&#xA;            Start = start;&#xA;            Duration = duration;&#xA;            Gap = gap;&#xA;            Type = type;&#xA;            Name = &amp;quot;T&amp;quot; + taskId + &amp;quot;S&amp;quot; + Start + &amp;quot;D&amp;quot; + duration;&#xA;        }&#xA;        public int TaskId { get; set; }&#xA;        public int Start { get; set; }&#xA;        public int Duration { get; set; }&#xA;        public int Gap { get; set; }&#xA;        public string Name { get; }&#xA;        public string Type { get; }&#xA;&#xA;    }&#xA;&#xA;...&#xA;     Dictionary&amp;lt;int, Task&amp;gt; allTasks = new Dictionary&amp;lt;int, Task&amp;gt;();&#xA;        allTasks.Add(0, new Task(0, 0, 30, &amp;quot;obs2&amp;quot;));&#xA;        allTasks.Add(1, new Task(1, 0, 30, &amp;quot;obs2&amp;quot;));&#xA;        allTasks.Add(2, new Task(2, 0, 60, &amp;quot;obs4&amp;quot;));&#xA;        allTasks.Add(3, new Task(3, 60, 60, &amp;quot;obs4&amp;quot;));&#xA;        allTasks.Add(4, new Task(4, 120, 60, &amp;quot;obs4&amp;quot;));&#xA;        allTasks.Add(5, new Task(5, 180, 60, &amp;quot;obs4&amp;quot;));&#xA;        allTasks.Add(6, new Task(6, 240, 30, &amp;quot;obs4&amp;quot;));&#xA;...&#xA;IntervalVar[,] task_intervals = new IntervalVar[numNurses, numTasks];&#xA;Dictionary&amp;lt;(int, int), BoolVar&amp;gt; tasks = new Dictionary&amp;lt;(int, int), BoolVar&amp;gt;(numWorkers * numTasks);&#xA;&#xA;//worker to task allocation&#xA;     foreach (int n in allNurses)&#xA;        {&#xA;            foreach (int s in allTasks.Keys)&#xA;            {&#xA;                tasks.Add((n,s), model.NewBoolVar($&amp;quot;tasks_n{n}s{s}&amp;quot;));&#xA;            }&#xA;        }&#xA;&#xA;//No worker can perform overlapping tasks&#xA; foreach (var worker in allNurses)&#xA;        {&#xA;            foreach (var task in allTasks.Values)&#xA;            {&#xA;                task_intervals[worker, task.TaskId] = model.NewOptionalIntervalVar(task.Start, task.Duration, task.Start + task.Duration, tasks[(worker, task.TaskId)], $&amp;quot;task[{task.TaskId}]&amp;quot;);&#xA;            }&#xA;        }&#xA;&#xA;        foreach (var worker in allNurses)&#xA;        {&#xA;            model.AddNoOverlap(&#xA;                (from task in allTasks.Keys&#xA;                 select task_intervals[worker, task]).ToList()&#xA;            );&#xA;        }&#xA;&#xA; // Each task is assigned to exactly one worker.&#xA;        List&amp;lt;ILiteral&amp;gt; literals = new List&amp;lt;ILiteral&amp;gt;();&#xA;        foreach (int t in allTasks.Keys)&#xA;            {&#xA;            &#xA;            foreach (int n in allWorker)&#xA;                {&#xA;                    literals.Add(tasks[(n, t)]);&#xA;                }&#xA;                model.AddExactlyOne(literals);&#xA;                literals.Clear();&#xA;            }&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9733" LastEditorUserId="981" LastEditDate="2023-12-22T15:11:12.480" LastActivityDate="2023-12-22T15:11:12.480" Title="CP sat solver approach for task assignment with pre defined task start end times" Tags="|solver|cp-sat|c#|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8446" PostTypeId="2" ParentId="8417" CreationDate="2022-05-23T18:41:17.787" Score="2" Body="&lt;p&gt;That is something like a Flow Shop Multi Machine, In Cplex CP Optimizer you will find the  Job Shop Multi Machines scheduling (jsspmm examples) which is a more general case.&lt;/p&gt;&#xA;" OwnerUserId="2797" LastActivityDate="2022-05-23T18:41:17.787" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8447" PostTypeId="1" AcceptedAnswerId="8448" CreationDate="2022-05-23T20:54:30.347" Score="6" ViewCount="556" Body="&lt;p&gt;Given a n×m grid with numbered cells and forbidden cells, the objective of the Rogo puzzle is to find a loop of fixed length through the grid such that the sum of the numbers in the cells on the loop is maximized. Some cells should be avoided. &lt;a href=&quot;https://neos-guide.org/content/rogo-puzzle&quot; rel=&quot;nofollow noreferrer&quot;&gt;ROGO Puzzle&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;How to add this constraint as a set of mixed integer linear constraints?&#xA;We need to make sure no Banned cell (black square) is trapped in the closed route?&#xA;The following red route is optimal (maxizes the total values but it contains black squares.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/0jjBw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0jjBw.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Two feasible routes are shown as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OX4ZZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OX4ZZ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2022-05-24T15:56:32.133" LastActivityDate="2022-05-24T16:04:02.753" Title="How to solve Rogo Puzzle with an extra constraint?" Tags="|optimization|mixed-integer-programming|linear-programming|linearization|puzzles-games|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8448" PostTypeId="2" ParentId="8447" CreationDate="2022-05-23T21:15:11.237" Score="7" Body="&lt;p&gt;Introduce a dummy depot (adjacent only to the &amp;quot;border&amp;quot; cells in the first or last row or column) and send one unit of flow from the depot to each banned cell.  Let nonnegative decision variable &lt;span class=&quot;math-container&quot;&gt;$z_{i,j}$&lt;/span&gt; represent the flow along the directed arc from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_k$&lt;/span&gt; indicate whether node &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is part of the loop.  Let &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; be the number of banned cells.  To prevent trapping banned cells, you need flow balance constraints along with big-M constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_{i,j} \le B(1 - y_j) \quad \text{for all $(i,j)$},$$&lt;/span&gt;&#xA;which enforces &lt;span class=&quot;math-container&quot;&gt;$z_{i,j} &amp;gt; 0 \implies y_j = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For your example instance, the maximum score turns out to be &lt;span class=&quot;math-container&quot;&gt;$33$&lt;/span&gt;:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ohjQL.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ohjQL.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-05-24T02:53:31.857" LastActivityDate="2022-05-24T02:53:31.857" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8449" PostTypeId="1" CreationDate="2022-05-24T06:07:17.157" Score="5" ViewCount="120" Body="&lt;p&gt;I am using Gurobi 9.5.1 in Python 3.10. In the context of column generation I request the duals of the master problem and set them in the objective of the subproblem. This is done repeated times.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   duals = master.getAttr(GRB.Attr.Pi, master.getConstrs())&#xA;   subprob.setAttr(&amp;quot;Obj&amp;quot;, subprob.getVars(), duals)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Around 10% of the time spent is in performing these operations. The rest is basically the solving times of the master and subproblems combined.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to reduce such overhead?&lt;/p&gt;&#xA;" OwnerUserId="8859" LastActivityDate="2022-05-24T06:07:17.157" Title="Reduce overhead Gurobi Python getting and setting attributes" Tags="|mixed-integer-programming|python|gurobi|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8450" PostTypeId="2" ParentId="8447" CreationDate="2022-05-24T16:04:02.753" Score="1" Body="&lt;p&gt;Based on a hint by @robPratt the problem is solved&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/27lYn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/27lYn.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2022-05-24T16:04:02.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8455" PostTypeId="1" CreationDate="2022-05-27T08:06:40.173" Score="0" ViewCount="138" Body="&lt;p&gt;How do I divide a variable by another variable?&lt;/p&gt;&#xA;&lt;p&gt;For example, if I have a variable max, and a variable &lt;span class=&quot;math-container&quot;&gt;$\sum\sum X_{ij}$&lt;/span&gt;, what I want to do is max divided by &lt;span class=&quot;math-container&quot;&gt;$\sum\sum X_{ij}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But the question is that Gurobi does not have &amp;quot;division&amp;quot; system. What can I do in this situation?&lt;/p&gt;&#xA;" OwnerUserId="9746" LastEditorUserId="123" LastEditDate="2022-05-27T08:34:53.117" LastActivityDate="2022-05-27T10:51:21.367" Title="Gurobi C++ - how to divide variables" Tags="|gurobi|c++|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8456" PostTypeId="2" ParentId="8455" CreationDate="2022-05-27T10:51:21.367" Score="1" Body="&lt;p&gt;If your objective function is &lt;span class=&quot;math-container&quot;&gt;$\max \frac{x}{z}$&lt;/span&gt;, you can add a constraint &lt;span class=&quot;math-container&quot;&gt;$x = zy$&lt;/span&gt;, then set the objective function to &lt;span class=&quot;math-container&quot;&gt;$\max y$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2022-05-27T10:51:21.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8457" PostTypeId="1" AcceptedAnswerId="8458" CreationDate="2022-05-27T14:35:06.173" Score="3" ViewCount="111" Body="&lt;p&gt;I am currently reading the paper &amp;quot;Alternating direction augmented Lagrangian methods for semidefinite programming&amp;quot; and was wondering about how one comes up with the Augmented Lagrangian Function that is presented in the paper (p. 207).&#xA;When the standard SDP is defined as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{X \in S_n} \langle C, X \rangle \quad s.t. \quad \mathcal{A}(X)=b, X\succeq 0 $$&lt;/span&gt;&#xA;and its dual as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min -b^T y \quad s.t.\quad \mathcal{A}^*(y)+S=C, S\succeq 0$$&lt;/span&gt;&#xA;then the Augmented Lagrangian is defined as (according to the paper)&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\mathcal{L}_\mu(X, y, S)=b^Ty + \langle X, \mathcal{A}^*(y)+S-C\rangle + \frac{1}{2\mu}\|\mathcal{A}^*(y)+S-C\|_F^2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm finding it a bit hard to interpret the Augmented Lagrangian/understand the intuition behind it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$-b^T y$&lt;/span&gt; is the original objective (which makes sense to me).&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2\mu}\|\mathcal{A}^*(y)+S-C\|_F^2$&lt;/span&gt; looks like a regularization term (also makes sense to me - we want to keep the violation of the constraint in the dual problem small)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\langle X, \mathcal{A}^*(y)+S-C\rangle$&lt;/span&gt; is the bit I really don't understand...so this enforces orthogonality between the primal iterate and the violation of the dual constraint...but why? The primal iterate doesn't even appear in the dual problem so how can it become part of the Lagrangian?&lt;/p&gt;&#xA;&lt;p&gt;Can someone maybe explain how one comes up with this Augmented Lagrangian function for the SDP by using the original notion of the Lagrange function as explained on &lt;a href=&quot;https://en.wikipedia.org/wiki/Lagrange_multiplier&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt; or at least explain the &amp;quot;orthogonality&amp;quot; condition?&lt;/p&gt;&#xA;" OwnerUserId="9747" LastEditorUserId="491" LastEditDate="2022-05-27T19:03:15.143" LastActivityDate="2022-05-28T22:19:35.557" Title="Augmented Lagrangian Function for Semidefinite Programming Problems" Tags="|lagrange-multipliers|lagrangian-relaxation|semidefinite-programming|constrained-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8458" PostTypeId="2" ParentId="8457" CreationDate="2022-05-27T17:02:29.430" Score="5" Body="&lt;p&gt;My way of reading it is &lt;span class=&quot;math-container&quot;&gt;$\langle X, \mathcal{A}^*(y)+S-C\rangle = \langle X, \mathcal{A}^*(y)-C\rangle + \langle X,S \rangle$&lt;/span&gt;. The first term is your standard inner product between dual variable and original primal constraints which you append to the objective in an augmented lagrangian method, and the second term which appeared here since they work with a slack is zero at optimality if the equality hold and complementary slackness has been achieved.&lt;/p&gt;&#xA;" OwnerUserId="487" LastActivityDate="2022-05-27T17:02:29.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8459" PostTypeId="1" CreationDate="2022-05-28T05:35:08.930" Score="2" ViewCount="181" Body="&lt;p&gt;When I solve the model, it happen &amp;quot;Error 10020: Objective Q not PSD&amp;quot; in the end.&lt;/p&gt;&#xA;&lt;p&gt;The gurobi website said, to resolve this issue, set the NonConvex parameter to 2.&lt;/p&gt;&#xA;&lt;p&gt;I type &amp;quot;model.set(GRB_IntParam_NonConvex, 2);&amp;quot;, but it said&#xA;&amp;quot;GRB_IntParam_NonConvex&amp;quot; undefined.&lt;/p&gt;&#xA;" OwnerUserId="9746" LastEditorUserId="9746" LastEditDate="2022-05-28T06:04:04.837" LastActivityDate="2022-05-29T00:04:10.537" Title="Gurobi C++-how to set the NonConvex parameter to 2" Tags="|gurobi|c++|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8462" PostTypeId="2" ParentId="8457" CreationDate="2022-05-28T22:19:35.557" Score="4" Body="&lt;p&gt;There's a good discussion of this in &lt;em&gt;Convex Optimization&lt;/em&gt; by Stephen Boyd and Lieven Vandenberghe.  See section 5.9.&lt;/p&gt;&#xA;&lt;p&gt;With an ordinary scalar inequality constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f_{i}(x) \leq 0$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;you'll have a term &lt;span class=&quot;math-container&quot;&gt;$\lambda_{i}f_{i}(x)$&lt;/span&gt; in the Lagrangian.  Note that &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is required to be nonnegative so that the product will be nonnegative if the inequality is violated.  The complementary slackness condition is that &lt;span class=&quot;math-container&quot;&gt;$\lambda_{i}f_{i}(x)=0$&lt;/span&gt; at optimality.&lt;/p&gt;&#xA;&lt;p&gt;However, with a conic inequality&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f_{i}(x) \preceq 0$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;You can't multiply &lt;span class=&quot;math-container&quot;&gt;$\lambda_{i}f_{i}(x)$&lt;/span&gt; because the result will not be a scalar and can't be added to &lt;span class=&quot;math-container&quot;&gt;$f_{0}(x)$&lt;/span&gt;.  Rather, you need to use a conic inner product between the Lagrange multiplier (which most live in the dual cone) and &lt;span class=&quot;math-container&quot;&gt;$f_{i}(x)$&lt;/span&gt;.  The complementary slackness condition is that the inner product of the Lagrange multiplier with &lt;span class=&quot;math-container&quot;&gt;$f_{i}(x)$&lt;/span&gt; is 0.&lt;/p&gt;&#xA;" OwnerUserId="103" LastActivityDate="2022-05-28T22:19:35.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8463" PostTypeId="2" ParentId="8459" CreationDate="2022-05-29T00:04:10.537" Score="2" Body="&lt;p&gt;Assume that you define your model as m. Try the following where I used the parameter's name to set the value:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m-&amp;gt;set(&amp;quot;NonConvex&amp;quot;, &amp;quot;2.0&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="39" LastActivityDate="2022-05-29T00:04:10.537" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8464" PostTypeId="1" AcceptedAnswerId="8472" CreationDate="2022-05-29T12:12:29.570" Score="1" ViewCount="146" Body="&lt;p&gt;I have recently tasked with a problem in which I have to locate electric vehicle charging points (new) keeping in mind that there continue to exist older charging points. The problem is to model the solution such that the distance between old and new charging points is maximised and the distance between new charging points and potential location is minimised. I was wondering if anyone could assist me with the domain of this problem. Trivially, this problem lies within the Facility Location domain; however, I am not able to correctly how to include the two distances within my model.&lt;/p&gt;&#xA;" OwnerUserId="8819" LastEditorUserId="67" LastEditDate="2022-05-29T20:59:44.080" LastActivityDate="2022-05-31T20:36:14.447" Title="How to model this problem?" Tags="|mixed-integer-programming|integer-programming|facility-location|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8466" PostTypeId="2" ParentId="8354" CreationDate="2022-05-30T20:40:20.843" Score="1" Body="&lt;p&gt;You state that only after every member in &lt;span class=&quot;math-container&quot;&gt;$J_i$&lt;/span&gt; (I assume you mean &lt;span class=&quot;math-container&quot;&gt;$J_1$&lt;/span&gt; in this specific example) has been assigned to at least one shift per day, you can assign shifts to members in  &lt;span class=&quot;math-container&quot;&gt;$J_2$&lt;/span&gt;. To do that you can add the following constraint which is similar to the idea of @Joris Kinable:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Y_{id} \cdot M \geq \sum_{s\in S} X_{ids} \quad \forall i\in I, d \in D $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Y_{id} \geq Y_{jd} \quad \forall k, i\in J_k, j\in J_{k+1}, d \in D $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Y_{id} \in \{0,1\} \quad \forall i \in I, d\in D$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Y_{id}$&lt;/span&gt; is a binary help variable which is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if employee &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is scheduled at least once on day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; (see the first constraint). &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a sufficiently large number, in your case that could be the cardinality of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, i.e &lt;span class=&quot;math-container&quot;&gt;$|S|$&lt;/span&gt;.&#xA;The second constraint makes sure that if any employee &lt;span class=&quot;math-container&quot;&gt;$j \in J_{k+1}$&lt;/span&gt; is scheduled on day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;, then all employees &lt;span class=&quot;math-container&quot;&gt;$i \in J_k$&lt;/span&gt; also need to be scheduled on that day.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="3464" LastEditDate="2022-05-31T20:02:20.000" LastActivityDate="2022-05-31T20:02:20.000" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8467" PostTypeId="1" CreationDate="2022-05-31T12:00:08.627" Score="1" ViewCount="67" Body="&lt;p&gt;This is my model.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_x&amp;amp;\quad\sum_{e\in E} X_e p_e \\ &#xA;\text{s.t.}&amp;amp;\quad\sum_{e \in E: T(e)=i} X_e - \sum_{e \in E: H(e)=i} X_e = \begin{cases}1, \;\text{if}\;i=s\\-1,\;\text{if}\;i=t\\0,\;\text{if}\;i\neq s,t \end{cases} \;\forall i \in I\\&#xA;&amp;amp;\quad X_e^2 - X_e = 0 \;\forall e \in E \\&#xA;&amp;amp;\quad X_e \geq 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;First, can I use strong duality?&lt;/p&gt;&#xA;&lt;p&gt;If so, which would the dual of this problem be? I don't know how to handle the second constraint.&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="123" LastEditDate="2022-05-31T14:33:51.560" LastActivityDate="2022-05-31T14:33:51.560" Title="Dual of a quadratic constraint" Tags="|nonlinear-programming|quadratic-programming|duality|dual|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8469" PostTypeId="1" AcceptedAnswerId="8476" CreationDate="2022-05-31T15:00:13.023" Score="6" ViewCount="484" Body="&lt;p&gt;I am solving a vrp and its variants (pick up drop off, milk-run problem) using genetic algorithms. The issue that I am getting with the genetic algorithm is the randomness associated with the algorithm. Although randomness is an expected property of GA as it has to search the solution space, I feel like for some problem instances I am not getting good results. Using a fixed seed number gives the same results but the GA may produce worse results if the seed number is fixed . I recently discovered that some literature used the column generation approach.&lt;/p&gt;&#xA;&lt;p&gt;Is column generation better than metaheuristics in terms of solution quality and solution runtime? If you used both metaheuristics and column generations for solving any vrp or tsp, would you share which method performed better and why?&lt;/p&gt;&#xA;" OwnerUserId="3288" LastEditorUserId="3288" LastEditDate="2022-05-31T15:15:42.197" LastActivityDate="2022-06-05T02:07:40.937" Title="Metaheuristics vs Column generation for VRP" Tags="|vehicle-routing|traveling-salesman|metaheuristics|column-generation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8470" PostTypeId="1" AcceptedAnswerId="8473" CreationDate="2022-05-31T15:27:23.670" Score="4" ViewCount="777" Body="&lt;p&gt;I am dealing with the following optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\underset{x}{\min} q(x)&#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;l_{x} \leq x \leq u_{x} \,\,\,\, \text{ and } \,\,\,\, l_{a} \leq Ax \leq u_{a}. &#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$q(x)$&lt;/span&gt; is a quadratic objective function.&lt;/p&gt;&#xA;&lt;p&gt;In my case the size of vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is large, but the matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is very sparse. One of the ways to deal with this is &lt;a href=&quot;https://ccom.ucsd.edu/%7Eoptimizers/static/pdfs/sqdoc7.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;SQOPT&lt;/a&gt; algorithm, but the implementation is only on MATLAB.&lt;/p&gt;&#xA;&lt;p&gt;I wonder which Python library can I try instead of SQOPT?&lt;/p&gt;&#xA;" OwnerUserId="9757" LastEditorUserId="491" LastEditDate="2022-06-01T15:37:04.097" LastActivityDate="2022-06-01T15:37:13.897" Title="large scale optimization with Python" Tags="|optimization|python|convex-optimization|multi-objective-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8471" PostTypeId="2" ParentId="8354" CreationDate="2022-05-31T15:32:22.430" Score="2" Body="&lt;p&gt;Another possible model uses a binary variable &lt;span class=&quot;math-container&quot;&gt;$Y_{kd}$&lt;/span&gt; to indicate whether all employees in set &lt;span class=&quot;math-container&quot;&gt;$J_k$&lt;/span&gt; have been assigned at least one shift on day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;. The defining constraint is &lt;span class=&quot;math-container&quot;&gt;$$ Y_{kd} \le \sum_{s\in S} X_{ids} \quad \forall k, \, \forall i\in {J_k}, \, \forall d\in D.$$&lt;/span&gt; This forces &lt;span class=&quot;math-container&quot;&gt;$Y_{kd}=0$&lt;/span&gt; unless each employee &lt;span class=&quot;math-container&quot;&gt;$i\in J_k$&lt;/span&gt; has gotten at least one shift on day &lt;span class=&quot;math-container&quot;&gt;$d.$&lt;/span&gt; The priority constraint is then enforced by &lt;span class=&quot;math-container&quot;&gt;$$X_{ids} \le Y_{kd} \quad \forall k, \, \forall i\in J_{k+1}, \, \forall d\in D,$$&lt;/span&gt; which says that no employee can get a shift unless the next higher priority group were all assigned that day. This introduces fewer binary variables &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and somewhat fewer constraints than does the solution proposed by @PeterD, but it is an empirical question which would solve faster.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-05-31T20:13:05.523" LastActivityDate="2022-05-31T20:13:05.523" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8472" PostTypeId="2" ParentId="8464" CreationDate="2022-05-31T15:43:28.970" Score="3" Body="&lt;p&gt;If it is desired to keep the new points somewhat close together rather than dispersed from each other, then I do not think the conditional &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; dispersion problem is applicable. If we assume a discrete set of candidate locations, this might fit into the category of generalized quadratic assignment problem (GQAP), where the quadratic portion of the objective penalizes distances between pairs of new charging stations and a linear term rewards distances between new stations and existing stations. The balance between penalties and rewards (i.e., the relative importance of keeping the new points close together versus keeping them away from existing points) would require weighting the linear term appropriately.&lt;/p&gt;&#xA;&lt;p&gt;With a discrete set of locations and a goal of keeping the new points away from each other as well as away from the existing points, this might fit the conditional &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; dispersion problem and might also be modeled as a GQAP (as above, only with both linear and quadratic objective terms rewarding distance).&lt;/p&gt;&#xA;&lt;p&gt;Addendum: Here is a model (variant of the QAP), assuming a finite grid of possible locations. The sets &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; index respectively the charging points to be placed, the available (unused) locations and the fixed locations containing existing charging stations. &lt;span class=&quot;math-container&quot;&gt;$d_{mn}$&lt;/span&gt; is the distance (in whatever metric you like) between two grid points &lt;span class=&quot;math-container&quot;&gt;$m,n \in L\bigcup F.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We will use binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{n\ell}$&lt;/span&gt; to indicate whether a charging station is placed at available location &lt;span class=&quot;math-container&quot;&gt;$\ell \in L$&lt;/span&gt; or not. The constraints are very simple: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{\ell in L} x_{n\ell} = 1 \quad \forall n\in N$$&lt;/span&gt; (every station gets placed once) and &lt;span class=&quot;math-container&quot;&gt;$$\sum_{n\in N} x_{n\ell} \le 1 \quad \forall \ell \in L$$&lt;/span&gt; (no location gets used more than once). For the problem to be feasible, you need to have at least as many available locations as you have charging points that need to be placed (&lt;span class=&quot;math-container&quot;&gt;$\vert L \vert \ge \vert N \vert$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;The objective function (to be minimized) is &lt;span class=&quot;math-container&quot;&gt;$$\sum_{n \in N} \sum_{n^\prime \in N : n^\prime &amp;gt; n} \sum_{\ell \in L} \sum_{\ell^\prime \in L} d_{\ell \ell^\prime} x_{n\ell} x_{n^\prime \ell^\prime} - \lambda \sum_{n \in N} \sum_{\ell \in L} \sum_{f \in F} d_{\ell f} x_{n\ell},$$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$\lambda &amp;gt; 0$&lt;/span&gt; is a parameter you use to control the tradeoff between minimizing the distance between pairs of new charging points and maximizing the distance between new and existing points.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-05-31T20:36:14.447" LastActivityDate="2022-05-31T20:36:14.447" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8473" PostTypeId="2" ParentId="8470" CreationDate="2022-05-31T16:17:45.627" Score="5" Body="&lt;p&gt;Quadratic programming solvers in Python with a unified API (&lt;a href=&quot;https://pypi.org/project/qpsolvers/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;) includes most of the quadratic programming solvers such as CVXOPT (can take advantage of sparsity), Gurobi, MOSEK, OSQP, etc.&lt;/p&gt;&#xA;&lt;p&gt;The performance comparison of these solvers (at least some of them) can be found &lt;a href=&quot;https://scaron.info/blog/quadratic-programming-in-python.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="491" LastEditDate="2022-06-01T15:37:13.897" LastActivityDate="2022-06-01T15:37:13.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8474" PostTypeId="1" CreationDate="2022-05-31T17:20:42.467" Score="5" ViewCount="124" Body="&lt;p&gt;I am trying to understand the CO2 emission of large scale optimization using CPLEX or Gurobi. Is there a published literature which addresses the compute usage of large scale executions?&lt;/p&gt;&#xA;" OwnerUserId="3730" LastEditorUserId="491" LastEditDate="2022-06-01T15:38:26.727" LastActivityDate="2022-06-01T15:38:26.727" Title="Scale of largest CPLEX/Gurobi execution" Tags="|cplex|gurobi|computational-complexity|docplex|computational-experiments|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8475" PostTypeId="1" AcceptedAnswerId="8477" CreationDate="2022-05-31T19:32:22.513" Score="1" ViewCount="113" Body="&lt;p&gt;I just got sent a problem that I haven't found any model for thus I do not know how to proceed in solving it, if anybody can show me a similar problem so I can use it as a starting point or if they are willing to show how to solve the following problem that I have, it is greatly appreciated!!&lt;/p&gt;&#xA;&lt;p&gt;Problem: Determine the maximum value coupling for the simple bipartite graph that has the values ​​of the arcs passed in the table below&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://cdn.discordapp.com/attachments/577911130941423646/981278533726924800/unknown.png&quot; alt=&quot;.&quot; /&gt;&lt;/p&gt;&#xA;" OwnerUserId="9758" LastEditorUserId="500" LastEditDate="2022-05-31T19:42:47.943" LastActivityDate="2022-06-01T15:02:55.760" Title="Graph Theory problem" Tags="|graphs|matching|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8476" PostTypeId="2" ParentId="8469" CreationDate="2022-05-31T19:47:15.730" Score="7" Body="&lt;p&gt;Please note that it is difficult to say something generic about all VRP variants. There are certainly a lot of counter examples of what I wrote below.&lt;/p&gt;&#xA;&lt;p&gt;First, column generation is mainly used within branch-and-cut-and-price algorithms which are the best exact methods for most VRP variants, even if branch-and-cut algorithms remain better in a few cases. You can give a look at the &lt;a href=&quot;https://vrpsolver.math.u-bordeaux.fr/&quot; rel=&quot;noreferrer&quot;&gt;VRPSolver&lt;/a&gt; package for example.&lt;/p&gt;&#xA;&lt;p&gt;Given an infinite time, branch-and-cut-and-price algorithms will find the optimal solution of a VRP problem and prove that it is optimal. Whereas local search based metaheuristics may find it, but won't prove that it is optimal.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, when branch-and-cut-and-price algorithms fail to terminate within the given time limit, they usually don't terminate with a solution as good as the solution found by local search based metaheuristics within the same time limit.&lt;/p&gt;&#xA;&lt;p&gt;A rule of thumb would be, up to 200 locations to visit, branch-and-price-and-cut algorithms should find the optimal solution quickly; above, local search based metaheuristics would yield better solutions for running times of the order of 1 hour. Of course, this depends on the variant and the dataset.&lt;/p&gt;&#xA;&lt;p&gt;In addition, column generation can also be used &lt;a href=&quot;https://doi.org/10.1287/ijoc.2018.0822&quot; rel=&quot;noreferrer&quot;&gt;in a heuristic fashion&lt;/a&gt;, which can yield better solutions than a whole branch-and-cut-and-price, and quicker. If I'm not mistaken, this is for example the approach chosen by the &lt;a href=&quot;https://vrpy.readthedocs.io/en/latest/mathematical_background.html#colgen&quot; rel=&quot;noreferrer&quot;&gt;VRPy&lt;/a&gt; package.&#xA;Something to look at to determine if it might work better than local search based metaheuristics is how much the problem is constrained. More constraints will make local search less effective, but the pricing problem of the column generation easier. Still, in the literature on VRP problems, local search based metaheuristics are far more present that column generation based heuristics.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-05-31T19:47:15.730" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8477" PostTypeId="2" ParentId="8475" CreationDate="2022-06-01T06:53:35.323" Score="3" Body="&lt;p&gt;The problem formulation is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lAEo2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lAEo2.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;Here is the Pyomo code&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = AbstractModel()&#xA;model.i = RangeSet(Ni)&#xA;model.j = RangeSet(Nj)&#xA;&#xA;model.flow = Var(model.i,model.j,bounds=(0,1),initialize=0, within=Reals)&#xA;&#xA;def rule_C1(model,i):&#xA;        return sum(model.flow[i,j] for j in model.j)&amp;lt;=1&#xA;model.C1   = Constraint(model.i,rule=rule_C1)&#xA;&#xA;def rule_C2(model,j):&#xA;        return sum(model.flow[i,j] for i in model.i)&amp;lt;=1&#xA;model.C2   = Constraint(model.j,rule=rule_C2)&#xA;&#xA;def rule_OF(model):&#xA;    return sum(model.flow[r,c]*dic[r,c] for r in model.i for c in model.j)&#xA;model.obj1 = Objective(rule=rule_OF, sense=maximize)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/o4QkO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/o4QkO.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2022-06-01T15:02:55.760" LastActivityDate="2022-06-01T15:02:55.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8478" PostTypeId="1" CreationDate="2022-06-01T12:02:30.270" Score="-1" ViewCount="102" Body="&lt;p&gt;I have to solve a problem from industry where there are a number of machines which should be assigned to a number of tasks. The difference from the general assignment problem is tough, that the decision variable x is not a binary, it is a value between [0,1]. So that one machine can do 0.5(50%) of the task and another one can complete the task,does that make sense? I definied the problem like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mhcLS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mhcLS.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;When I program this problem in python with docplex, the solver is giving me only values of 1. Why there are no continuous values like 0.5 etc. Is there even a possibility that the mathematical optimal solution is a continuous value, or will this model always give binary results because there is a mathematical reason and maybe proof to that? So Does it even make sense to declare the decision variable as contionuous rather than binary?&lt;/p&gt;&#xA;" OwnerUserId="9764" LastActivityDate="2022-06-01T14:24:15.407" Title="Assignment Problem with continuous decision variable" Tags="|binary-variable|network-flow|assignment-problem|job-shop-scheduling|continuous-optimization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8479" PostTypeId="2" ParentId="8478" CreationDate="2022-06-01T14:24:15.407" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Is there even a possibility that the mathematical optimal solution is&#xA;a continuous value&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I would say it depends on the parameterization, i.e., the values of c and t and b in your problem. From your description, it seems entirely possible to have a parameterization that leads to an optimal solution with integer values.&#xA;Generally, it is a good practise to start with a tiny example which you can fully solve and understand manually&lt;/p&gt;&#xA;&lt;p&gt;I would suggest to test your implementation with a minimal example which you construct in a way that you know the optimal solution is fractional. Here is a suggestion:&lt;/p&gt;&#xA;&lt;p&gt;Lets say there is just one task, so &lt;span class=&quot;math-container&quot;&gt;$J = \{1\}$&lt;/span&gt; and two machines &lt;span class=&quot;math-container&quot;&gt;$I = \{1,2\}$&lt;/span&gt;&#xA;You have the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$4x_1 + 2x_2 \leq 3$$&lt;/span&gt;&#xA;I am omitting the task index here. Now, &lt;span class=&quot;math-container&quot;&gt;$t_1$&lt;/span&gt; is larger than &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$x_1=1$&lt;/span&gt; would be an infeasible solution. Finally, you can prevent &lt;span class=&quot;math-container&quot;&gt;$x_2=1$&lt;/span&gt; from becoming optimal by selecting objective coefficients that favor &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;, e.g., &lt;span class=&quot;math-container&quot;&gt;$c_2=5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_1=1$&lt;/span&gt;. Independent of the values for the &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;,as long as the second machine is more expensive than the first, the optimal solution should be &lt;span class=&quot;math-container&quot;&gt;$x_1=x_2=0.5$&lt;/span&gt; because you still have the constraint that the one task has to be completely fulfilled, so&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_1 + x_2 =1$$&lt;/span&gt;&#xA;still has to be fulfilled.&lt;/p&gt;&#xA;&lt;p&gt;Hope this helps figuring out what's going on!&lt;/p&gt;&#xA;" OwnerUserId="9763" LastActivityDate="2022-06-01T14:24:15.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8480" PostTypeId="1" CreationDate="2022-06-01T15:48:30.500" Score="1" ViewCount="158" Body="&lt;p&gt;Say, we're working with an LP that is primal degenerate (optimal solution is at a vertex but with multiple bases) and &lt;i&gt;not&lt;/i&gt; dual degenerate (optimal solution is &lt;i&gt;not&lt;/i&gt; at a face).&lt;/p&gt;&#xA;&lt;p&gt;If we were to solve it with a simplex algorithm, we'd get a basic primal solution vector and a basic dual solution vector.&lt;/p&gt;&#xA;&lt;p&gt;If we were to solve it with an interior point (barrier) algorithm, we'd get a &amp;quot;near-basic&amp;quot; primal solution vector (by near-basic, I mean very close to a vertex but still in the interior of the feasible region). What would the dual solution vector look like in this case? Will it be a &amp;quot;midface&amp;quot; solution?&lt;/p&gt;&#xA;&lt;p&gt;My intuition is that it should be a midface solution since the dual of this LP will be dual degenerate, and solving this dual LP with the interior point algorithm will give us a midface solution. Is this a good way to think about it? I tested this by solving a two-variable LP example with CPLEX and it seems to confirm this, but I'm not sure if it will follow in higher dimensions.&lt;/p&gt;&#xA;" OwnerUserId="562" LastActivityDate="2022-06-01T16:13:57.063" Title="Dual solution when solving a primal degenerate LP with the interior point algorithm" Tags="|linear-programming|duality|interior-point-method|degeneracy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8481" PostTypeId="2" ParentId="8480" CreationDate="2022-06-01T16:13:57.063" Score="2" Body="&lt;p&gt;I'm not sure what you mean by a &amp;quot;dual solution&amp;quot; for an interior (suboptimal) primal solution. If you mean the marginal affect on the primal solution for changes to the constraints, it would be all zeros (since small changes to any constraint would leave the interior solution feasible, with the same objective value). That said, I don't think this is a meaningful concept.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-06-01T16:13:57.063" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8482" PostTypeId="1" AcceptedAnswerId="8483" CreationDate="2022-06-02T19:15:08.900" Score="3" ViewCount="767" Body="&lt;p&gt;After a few iterations, my master problem with optimality cuts is still unbounded. I wonder if it's possible in theory?&lt;/p&gt;&#xA;&lt;p&gt;If it's possible, how to deal with the unbounded master problem?&lt;/p&gt;&#xA;" OwnerUserId="9768" LastActivityDate="2022-06-03T23:06:22.027" Title="Unbounded master problem in Benders decomposition" Tags="|optimization|benders-decomposition|unboundedness|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8483" PostTypeId="2" ParentId="8482" CreationDate="2022-06-02T19:25:16.810" Score="7" Body="&lt;p&gt;Assuming your master problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt;, a simple way to avoid unboundedness, even before adding any cuts, is to impose a redundant lower bound &lt;span class=&quot;math-container&quot;&gt;$\eta \ge L$&lt;/span&gt; for some constant &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;.  Often, taking &lt;span class=&quot;math-container&quot;&gt;$L=0$&lt;/span&gt; is valid.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-06-02T19:25:16.810" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8484" PostTypeId="2" ParentId="8482" CreationDate="2022-06-02T20:27:25.173" Score="6" Body="&lt;p&gt;Yes, it is possible in theory.&lt;/p&gt;&#xA;&lt;p&gt;An alternative to bounding the objective function is bounding the variables. If this is a &amp;quot;real-world&amp;quot; model (where the variables represent actual decisions), they will all be bounded in practice. Adding appropriate (not overly tight, but not ridiculously loose) bounds will sometimes speed up the solution process in addition to keeping the model bounded.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I added an &lt;a href=&quot;https://or.stackexchange.com/a/8491/67&quot;&gt;answer&lt;/a&gt; to the linked question that is relevant here (and too lengthy to repeat). Basically, if the solver for the master problem is at a corner where it discovers a recession direction that makes the master unbounded, and if the subproblem generates an optimality cut (to correct the master problem under-/over-estimating the objective value at that corner), there is no guarantee that the cut causes the objective to become bounded in the recession direction. If it does not, the solver will return the same corner solution (with an amended objective value), the master will remain unbounded, and the solution process will remain stuck.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-06-03T23:06:22.027" LastActivityDate="2022-06-03T23:06:22.027" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8486" PostTypeId="2" ParentId="8482" CreationDate="2022-06-03T13:37:36.350" Score="2" Body="&lt;p&gt;RobPratt's and prubin's answer indeed solves the problem in the post.&lt;/p&gt;&#xA;&lt;p&gt;If someone wonders whether there exist other solutions, I found a class of stabilization methods in &lt;strong&gt;Frangioni, A. (2020)&lt;/strong&gt; for nonlinear nonsmooth problems to avoid oscillation called proximal and level stabilization also solving this problem to some level.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;proximal stabilization:&lt;/strong&gt; adding a proximal term to the objective of the master problem, then the MP changes from&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{x \in X} f(x)&#xA;$$&lt;/span&gt;&#xA;to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{x \in X} f(x) + \frac{\mu}{2}|| x - x_k ||_2^2&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; is a hyperparameter.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;level stabilization:&lt;/strong&gt; adding a level set constraint, then the MP becomes&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{x \in X} || x - x_k ||_2^2 \\&#xA;\text{s.t. } f(x) \le l&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; is a hyperparameter. You can choose &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; as the best primal bound you have achieved.&lt;/p&gt;&#xA;&lt;p&gt;Of course, you can combine the above 2 methods&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{x \in X} f(x) + \frac{\mu}{2}|| x - x_k ||_2^2\\&#xA;\text{s.t. } f(x) \le l&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Reference&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Frangioni, A. (2020). Standard bundle methods: untrusted models and duality. In Numerical Nonsmooth Optimization (pp. 61-116). Springer, Cham.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="9768" LastEditorUserId="9768" LastEditDate="2022-06-03T14:29:10.153" LastActivityDate="2022-06-03T14:29:10.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8487" PostTypeId="1" AcceptedAnswerId="8488" CreationDate="2022-06-03T14:49:02.653" Score="1" ViewCount="231" Body="&lt;p&gt;From the problem &lt;a href=&quot;https://or.stackexchange.com/questions/8482/unbounded-master-problem-in-benders-decomposition&quot;&gt;Unbounded master problem in Benders decomposition&lt;/a&gt;, it can happen that after adding cuts the master problem is still unbounded. The answers in the post suggest adding bound for the objective or variables to solve the unboundedness.&lt;/p&gt;&#xA;&lt;p&gt;I found that the reason why unboundedness makes benders fail is that sometimes &lt;strong&gt;the solver returns the same solution before and after adding cuts&lt;/strong&gt; since the master problem with cuts is still unbounded. I think it can also happen when adding bounds to the objective or variables since there's no assurance that the lower bound will be better with more cuts, which means more cuts don't guarantee a different solution to the master problem.&lt;/p&gt;&#xA;&lt;p&gt;I know there're some techniques like restarting to jump from incumbent to new solutions, but these techniques seem to have no guarantee.&lt;/p&gt;&#xA;" OwnerUserId="9768" LastActivityDate="2022-06-03T18:35:01.887" Title="Adding cuts doesn't change the solution of master problem in Benders decomposition" Tags="|optimization|benders-decomposition|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8488" PostTypeId="2" ParentId="8487" CreationDate="2022-06-03T15:33:54.720" Score="3" Body="&lt;p&gt;You can certainly get the same master objective value after adding optimality cuts, but you should not get the same solution in consecutive master solver calls until the final iteration, when the lower bound and upper bound are the same. Suppose the master solver claims objective value &lt;span class=&quot;math-container&quot;&gt;$\eta_1$&lt;/span&gt;, but the subproblem says the true objective value is &lt;span class=&quot;math-container&quot;&gt;$\eta_2 &amp;gt; \eta_1$&lt;/span&gt; and generates an optimality cut that conveys that information. If the cut is generated correctly and the master solver returns the same solution, the master objective value will now be &lt;span class=&quot;math-container&quot;&gt;$\eta_2$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-06-03T15:33:54.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8489" PostTypeId="1" AcceptedAnswerId="8490" CreationDate="2022-06-03T16:35:56.960" Score="2" ViewCount="460" Body="&lt;p&gt;I have been using the LpSolve package to solve a minimization problem in my final course work, but I need to reconcile this problem with a maximization problem. Conducting several researches, I believe that the problem is Multi-objective, more precisely Multi-objective linear programming (MOLP). I would like to know if it is possible to work in LpSolve using two different objective functions, my restrictions are exactly the same for both cases. If there is no way to do this using LpSolve, what is recommended to solve this problem?&lt;/p&gt;&#xA;&lt;p&gt;The expected output for my problem is a vector of 0's and 1's, this is a problem whose solution is yes or no. However, as an objective I need to maximize a certain index and minimize another.&lt;/p&gt;&#xA;" OwnerUserId="9771" LastActivityDate="2022-06-03T17:48:59.733" Title="Is it possible to merge two objective functions using the LpSolve package in R?" Tags="|linear-programming|integer-programming|multi-objective-optimization|r|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8490" PostTypeId="2" ParentId="8489" CreationDate="2022-06-03T17:48:59.733" Score="5" Body="&lt;p&gt;There are a variety of ways to deal with multiple objectives, so the answer is &amp;quot;it depends&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Probably the most common approach is to optimize a weighted sum or difference of the individual objective functions (where the weights serve the twin purposes of scaling the individual objective functions to be commensurable and assigning relative priorities). Since you are just replacing one linear objective function with a different (hybrid) linear objective function, lpSolve can definitely handle this.&lt;/p&gt;&#xA;&lt;p&gt;Another approach, sometimes called lexicographic optimization, assigns preemptive priorities to the individual objective functions. You optimize the highest priority objective first, then lock in the value of that objective and optimize the second highest priority objective, and so on. Not very many solvers support this directly (CPLEX does), and in any case lpSolve does not seem to provide for it. You can still do it, by solving multiple models. After the first model, add a constraint saying that the highest priority objective cannot be worse than its optimal value, and with that added constraint optimize the second highest priority objective. You can do this with lpSolve.&lt;/p&gt;&#xA;&lt;p&gt;A third approach is to set a cutoff for one objective (&amp;quot;don't do worse than ___&amp;quot;) and then optimize the other one. Again, this is straightforward with lpSolve.&lt;/p&gt;&#xA;&lt;p&gt;So you will need either to figure out weights (first method) or priorities (second and third methods) and maybe a cutoff value (third method), but you can do any of the in lpSolve.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-06-03T17:48:59.733" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8491" PostTypeId="2" ParentId="8487" CreationDate="2022-06-03T18:35:01.887" Score="2" Body="&lt;p&gt;Suppose that the master problem entails maximizing a variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; be the master problem variables. Somewhere along the line, the solver arrives at a solution &lt;span class=&quot;math-container&quot;&gt;$(\bar{x}, \bar{z})$&lt;/span&gt; which is feasible (so far) and discovers that the master problem is unbounded. This means it has found a direction &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$x + \lambda u$&lt;/span&gt; is feasible for all &lt;span class=&quot;math-container&quot;&gt;$\lambda &amp;gt; 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z\rightarrow \infty$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$\lambda \rightarrow \infty.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The master solution &lt;span class=&quot;math-container&quot;&gt;$(\bar{x}, \bar{z})$&lt;/span&gt; is passed to the subproblem, which generates a Benders optimality cut &lt;span class=&quot;math-container&quot;&gt;$z \le a^\prime x + b$&lt;/span&gt; violated by the current solution (meaning &lt;span class=&quot;math-container&quot;&gt;$\bar{z} &amp;gt; a^\prime \bar{x} + b$&lt;/span&gt;). Note that the recession direction &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; was not passed to the subproblem. Let &lt;span class=&quot;math-container&quot;&gt;$\hat{z} = a^\prime \bar{x} + b.$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$(\bar{x}, \hat{z})$&lt;/span&gt; is a feasible master solution (at least until some cut renders it infeasible), and &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; is still a recession direction for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. So if &lt;span class=&quot;math-container&quot;&gt;$a^\prime u &amp;gt; 0,$&lt;/span&gt; the master problem is still unbounded and the values of the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables are still unchanged (&lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt;). While it is possible that &lt;span class=&quot;math-container&quot;&gt;$a^\prime u \le 0,$&lt;/span&gt; we have no reason to expect that, particularly since the subproblem was unaware of &lt;span class=&quot;math-container&quot;&gt;$u.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So unless we get lucky and the subproblem generates an optimality cut that is limits &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; in the recession direction &lt;span class=&quot;math-container&quot;&gt;$u,$&lt;/span&gt; the only workaround for the unbounded master is to explicitly bound either &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; or all of the above.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-06-03T18:35:01.887" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8492" PostTypeId="1" CreationDate="2022-06-04T18:14:33.420" Score="5" ViewCount="534" Body="&lt;p&gt;I am solving a feasibility (No objective) problem in IPOPT. I got the following output:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fcvgw.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fcvgw.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I see that the violation of the constraints are of order 1e-15. What is the meaning of dual infeasibility 1e-07 and the overall NLP error 2e-09? I mean what do they represent if I only have constraints?&lt;/p&gt;&#xA;" OwnerUserId="9776" LastActivityDate="2022-06-07T16:32:53.460" Title="Analyzing the output of IPOPT" Tags="|nonlinear-programming|feasible-points|julia|ipopt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8493" PostTypeId="1" CreationDate="2022-06-04T19:08:46.107" Score="0" ViewCount="139" Body="&lt;p&gt;After solving the problem with docplex and having the decision variables' values, can I do some calculations in the code with decision variables?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mdl.print_information()&#xA;sol = mdl.solve()&#xA;mdl.print_solution() &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I mean can I have use the decision variables and calculate something after the code above?&lt;/p&gt;&#xA;" OwnerUserId="9245" LastActivityDate="2022-06-10T14:57:47.197" Title="calculations after the docplex solution" Tags="|optimization|python|docplex|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8494" PostTypeId="1" AcceptedAnswerId="8515" CreationDate="2022-06-04T20:45:15.997" Score="3" ViewCount="141" Body="&lt;pre&gt;&lt;code&gt;mdl.print_information()&#xA;sol = mdl.solve()&#xA;mdl.print_solution()     &#xA;&#xA;&#xA;if sol is None:&#xA;    print(&amp;quot;Infeasible&amp;quot;)&#xA;    &#xA;print(mdl.solve_details)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;At the end of the mathematical model in docplex I have the code above and &lt;strong&gt;solve time&lt;/strong&gt; is printed in the console. But I am not sure about if it is &lt;strong&gt;CPU time&lt;/strong&gt; or not.&#xA;How can I print the CPU time?&lt;/p&gt;&#xA;" OwnerUserId="9245" LastActivityDate="2022-06-09T14:56:13.420" Title="cpu time in docplex" Tags="|modeling|python|cplex|docplex|cpu|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8495" PostTypeId="2" ParentId="8469" CreationDate="2022-06-05T02:07:40.937" Score="5" Body="&lt;p&gt;I make a commercial VRP solver - &lt;a href=&quot;https://odllive.com&quot; rel=&quot;noreferrer&quot;&gt;https://odllive.com&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Speaking from my experience of commercial solvers, using local search methods (i.e. improvement heuristics like cheapest insert or cheapest move) together with controlling meta-heuristics seems to be the most common choice of algorithm. Controlling meta-heuristics could be something like iterated local search, construction-destruction methods etc. The combination of local search + controlling meta-heuristics being the 'best' algorithm to use has some backing in the academic literature as well.&lt;/p&gt;&#xA;&lt;p&gt;Genetic algorithms on their own tend not to be powerful enough to solve VRPs effectively, they take too long to find an improvement that a simple cheapest move algorithm would find straight away. Local search heuristics on their own will get stuck in a local minima as they're pure greedy, which is why you need controlling meta-heuristic too.&lt;/p&gt;&#xA;&lt;p&gt;Mathematical programming approaches like column generation tend not to be used much commercially, they're too slow. I also suspect (but don't know for sure) that it would be difficult to configure mathematical programming solvers to handle some of the rich problem features you can encounter in real-life, e.g. rush hours, modelling vehicle parking and a sub-route on foot (park-and-loop) etc.&lt;/p&gt;&#xA;" OwnerUserId="825" LastActivityDate="2022-06-05T02:07:40.937" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8496" PostTypeId="1" CreationDate="2022-06-05T04:58:23.013" Score="-1" ViewCount="355" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kpUxA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kpUxA.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The parameters are such as in the dataframe above. Can I iterate over this, and solve the model firstly for row 0 and then 1, ... etc.&lt;/p&gt;&#xA;" OwnerUserId="9245" LastActivityDate="2022-06-09T14:35:24.640" Title="How to iterate a parameter set in docplex model?" Tags="|python|cplex|docplex|cplex-python-api|parameter|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8497" PostTypeId="1" AcceptedAnswerId="8498" CreationDate="2022-06-05T19:36:00.407" Score="6" ViewCount="383" Body="&lt;p&gt;I am trying to develop a MILP for a path planning problem. I am operating on a grid of cells that represents a map. The arrangement of cells in the grid represents the placement of the cells in real life on a physical space. I would like to generate a continuous path from cell A to cell B. One constraint that I would like to add is that the solution must be such that the path is only made of transitions between physically adjacent cells. That means no diagonal (or orthogonal) skips over any cells. Only stepping from a cell to its 4 adjacent cells and so on.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tvzwz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tvzwz.png&quot; alt=&quot;Comparison of acceptable and unacceptable paths&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;How do I add this as a constraint in my problem?&lt;/p&gt;&#xA;&lt;p&gt;An idea that I had was to make the weight of edge from Cell X to any cell that is not adjacent as infinity, but that seems like a hack in implementation more than a proper constraint.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: I will be implementing this model using Google OR-Tools, and the weight of all the edges will be elements of an adjacency matrix. Therefore, every possible edge will be a part of the matrix, and hence omiting edges entirely to constraint the solution is not possible. Original question still stands: how can I add this feature of the problem as a constraint?&lt;/p&gt;&#xA;" OwnerUserId="8918" LastEditorUserId="491" LastEditDate="2022-06-08T17:00:23.923" LastActivityDate="2022-06-08T17:00:23.923" Title="How to Model Path Being Only Through Adjacent Cells" Tags="|mixed-integer-programming|modeling|or-tools|network-flow|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8498" PostTypeId="2" ParentId="8497" CreationDate="2022-06-05T19:46:02.387" Score="9" Body="&lt;p&gt;A standard approach for modeling a path from source &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to sink &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; in a directed graph with node set &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; and arc set &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is to let continuous variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \ge 0$&lt;/span&gt; represent the flow along the arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and impose flow-balance constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{(i,j)\in A} x_{ij} - \sum_{(j,i)\in A} x_{ji} = &#xA;\begin{cases}&#xA;1 &amp;amp; \text{if $i=s$}\\&#xA;-1 &amp;amp; \text{if $i=t$}\\&#xA;0 &amp;amp;\text{if $i\in N \setminus \{s,t\}$}&#xA;\end{cases}&#xA;$$&lt;/span&gt;&#xA;that send one unit of flow from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&#xA;Rather than imposing some large penalty on inadmissible arcs, just omit them from &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-06-05T19:46:02.387" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8499" PostTypeId="2" ParentId="8492" CreationDate="2022-06-06T09:00:21.397" Score="2" Body="&lt;p&gt;For a feasibility problem, you can think of the primal objective function as &lt;span class=&quot;math-container&quot;&gt;$f(x) =0$&lt;/span&gt;. These results indicate that your problem was solved—that is, IPOPT found a feasible point.&lt;/p&gt;&#xA;" OwnerUserId="4463" LastActivityDate="2022-06-06T09:00:21.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8500" PostTypeId="1" CreationDate="2022-06-06T09:28:33.463" Score="2" ViewCount="74" Body="&lt;p&gt;How would you encode the problem given by &lt;a href=&quot;https://oeis.org/A337663&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://oeis.org/A337663&lt;/a&gt; with an off-the-shelf solver?&lt;/p&gt;&#xA;&lt;p&gt;You need to lay out &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; ones and &lt;span class=&quot;math-container&quot;&gt;$2, 3, ..., m$&lt;/span&gt; on an infinite grid, for &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; as large as possible. For each &lt;span class=&quot;math-container&quot;&gt;$x &amp;gt; 1$&lt;/span&gt;, the sum of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;'s neighbors (including diagonals) less than &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; must equal &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Assume you believe &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is the right answer and you want to prove that &lt;span class=&quot;math-container&quot;&gt;$m + 1$&lt;/span&gt; is impossible.&lt;/p&gt;&#xA;&lt;p&gt;I've tried several different solvers and encodings; numerical position variables, displacement matrices with &lt;span class=&quot;math-container&quot;&gt;$d(i, k) = d(i, j) + d(j, k)$&lt;/span&gt;, only enforcing the adjacency constraints and then lazily blocking bad paths, etc.&lt;/p&gt;&#xA;&lt;p&gt;Right now CP-SAT with explicit position variables seems to work best (I don't have access to non-free solvers), but nothing is competitive with a hand-rolled solution.&lt;/p&gt;&#xA;&lt;p&gt;Maybe I need more manual symmetry breaking?&lt;/p&gt;&#xA;" OwnerUserId="7666" LastEditorUserId="981" LastEditDate="2023-12-22T15:12:30.137" LastActivityDate="2023-12-22T15:12:30.137" Title="Good encoding for grid layout problem" Tags="|integer-programming|constraint-programming|cp-sat|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8501" PostTypeId="1" CreationDate="2022-06-06T13:48:40.353" Score="3" ViewCount="47" Body="&lt;p&gt;Could anyone help me with the KKT conditions of my problem? The different sums and sets confuse me more than a little.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_x \sum_{a \in A^1} p_a^1 X_a + \sum_{a \in A^2} p_a^2 X_a + \sum_{a \in A^3} p_a^3 X_a \\&#xA;\text{s.t.} \sum_{a \in A: \text{Tail}(a) = i} X_a - \sum_{a \in A: \text{Head}(a) = i} X_a = \begin{cases} \;1, \;\; i = s \\ -1, \; i = t \\ \;0, \;\; \forall i \in N - \{s,t\} \end{cases} \\ &#xA;\sum_{a \in A^2} X_a + \sum_{a \in A^3} X_a = 1 \\&#xA;X_a \geq 0 \;\;\;\forall a \in A&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is the set of nodes, and &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is the set of edges. Furthermore, &lt;span class=&quot;math-container&quot;&gt;$A=A^1 \cup A^2 \cup A^3 \cup A^4$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have trouble deriving the stationary conditions.&lt;/p&gt;&#xA;&lt;p&gt;Edit:&#xA;Here is what I did.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/d4ic7.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/d4ic7.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="7200" LastEditDate="2022-06-06T16:49:15.887" LastActivityDate="2022-06-06T16:49:15.887" Title="Help with the KKT conditions of a SPT problem" Tags="|vehicle-routing|kkt-conditions|continuous-optimization|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8503" PostTypeId="2" ParentId="8080" CreationDate="2022-06-06T19:10:03.440" Score="2" Body="&lt;p&gt;It means that both options have the same ranking and it is up to you what to do with that information.&lt;/p&gt;&#xA;&lt;p&gt;If you look at the VIKOR paper of Opricovic &amp;amp; Tzeng (2004), you can see that &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is defined as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Q_j = v(S_j-S^*)/(S^--S^*) + (1-v)(R_j-R^*)/(R^--R^*)$$&lt;/span&gt;&#xA;where&#xA;&lt;span class=&quot;math-container&quot;&gt;$$S^* = \min_j S_j, \quad S^-=\max_j S_j$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$R^* = \min_j R_j, \quad R^-=\max_j R_j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In your example, &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S_2$&lt;/span&gt; are both &lt;span class=&quot;math-container&quot;&gt;$0.5$&lt;/span&gt;, therefore, &lt;span class=&quot;math-container&quot;&gt;$S^*=0.5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S^-=0.5$&lt;/span&gt; which leads to a division by zero and consequently, &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is not defined. This holds not only for &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; but also for &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Opricovic, S., &amp;amp; Tzeng, G.-H. (2004). Compromise solution by MCDM&#xA;methods: A comparative analysis of VIKOR and TOPSIS. European Journal&#xA;of Operational Research, 156(2), 445–455.&#xA;doi:10.1016/s0377-2217(03)00020-1&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="3464" LastEditDate="2022-06-06T19:23:37.920" LastActivityDate="2022-06-06T19:23:37.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8504" PostTypeId="2" ParentId="8492" CreationDate="2022-06-07T15:45:27.320" Score="4" Body="&lt;p&gt;It took some digging but I found the answers in &lt;a href=&quot;https://list.coin-or.org/pipermail/ipopt/2007-November/000900.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;an old email thread&lt;/a&gt;. The paper linked there is archived &lt;a href=&quot;https://web.archive.org/web/20060303150430/http://www.research.ibm.com/people/a/andreasw/papers/ipopt.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$E_{\mu}(x,\lambda,z) = \max \Big\{ \frac{\| \nabla f(x) + \nabla c(x)\lambda + z  \|_\infty}{s_d}, \|c(x)\|_\infty,\frac{\| \text{Diag}(x)\text{Diag(z)}e-\mu e\|_\infty}{s_c} \Big\}$$&lt;/span&gt;&#xA;Is the the overall NLP error. Dual infeasibility is calculated by &lt;span class=&quot;math-container&quot;&gt;$$\| \nabla f(x) + \nabla c(x)\lambda + z  \|_\infty$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The scalings &lt;span class=&quot;math-container&quot;&gt;$s_d$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$s_c$&lt;/span&gt; are explained in the paper on page four. A &lt;span class=&quot;math-container&quot;&gt;$s_d$&lt;/span&gt; value of around &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt; would explain your observation, such a value is allowed to occur. For the meaning of these in the constraint satisfaction case just think &lt;span class=&quot;math-container&quot;&gt;$\nabla f(x) = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I haven't confirmed numerically if this always holds, so let me know if you have issues. Then someone would have to dive into the code of IpOpt to find the true answer.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="123" LastEditDate="2022-06-07T16:32:53.460" LastActivityDate="2022-06-07T16:32:53.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8505" PostTypeId="1" AcceptedAnswerId="8508" CreationDate="2022-06-07T20:20:39.347" Score="3" ViewCount="847" Body="&lt;p&gt;I want to add slack variables to the following feasibility problem. Optimally I want the sum of the slack variables to be zero.&lt;/p&gt;&#xA;&lt;p&gt;Given the problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min 0$$&lt;/span&gt;&#xA;s.t.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$e(x) = 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$l(x) \leq 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$g(x) \geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is the following a correct way to add slack variables?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min 0 + |\xi_e| + \xi_l + \xi_g$$&lt;/span&gt;&#xA;s.t.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$e(x) = \xi_e$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$l(x) \leq \xi_l$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$g(x) \geq -\xi_g$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\xi_l \geq 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\xi_g \geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, if I add a slack variable to one constrain in the model, do I have to add slack variables to all other constraints?&lt;/p&gt;&#xA;" OwnerUserId="9776" LastEditorUserId="9776" LastEditDate="2022-06-07T20:59:55.600" LastActivityDate="2022-06-08T00:13:34.160" Title="Correct way to add slack variables to model" Tags="|optimization|linear-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8506" PostTypeId="1" AcceptedAnswerId="8518" CreationDate="2022-06-07T20:44:32.157" Score="1" ViewCount="253" Body="&lt;p&gt;I am trying to generate a shortest path between &lt;code&gt;source&lt;/code&gt; and &lt;code&gt;sink&lt;/code&gt; in a square grid of cells. I am using the Google CP-SAT solver as I believe it is recommended for problems with integer/boolean decision variables. In my case I have a square matrix &lt;code&gt;P&lt;/code&gt; of &lt;code&gt;NUM_CELLS*NUM_CELLS&lt;/code&gt; entries where &lt;code&gt;P[i][j]&lt;/code&gt; represents a transition from cell &lt;code&gt;i&lt;/code&gt; to &lt;code&gt;j&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have noticed that the problem becomes infeasible for &lt;code&gt;NUM_CELLS&lt;/code&gt; greater than, around 256. Is there an error in my ILP implementation, or is the problem size just too big?&lt;/p&gt;&#xA;&lt;p&gt;You may view my attempt here: &lt;a href=&quot;https://gist.github.com/raghavthakar/eafb590a3d1dc8c1c7f3d62098cb47b2&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gist.github.com/raghavthakar/eafb590a3d1dc8c1c7f3d62098cb47b2&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[EDIT]: Here is the error I received:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;CpSolverResponse summary:&#xA;status: INFEASIBLE&#xA;objective: NA&#xA;best_bound: NA&#xA;booleans: 159201&#xA;conflicts: 0&#xA;branches: 37708&#xA;propagations: 7681149&#xA;integer_propagations: 7718860&#xA;restarts: 37708&#xA;lp_iterations: 9&#xA;walltime: 44.9287&#xA;usertime: 44.9287&#xA;deterministic_time: 3.85921&#xA;gap_integral: 0&#xA;&#xA;Traceback (most recent call last):&#xA;  File &amp;quot;/home/raghav/move_box/src/scripts/cp-sat_test.py&amp;quot;, line 106, in &amp;lt;module&amp;gt;&#xA;    if solver.BooleanValue(P[i][j]):&#xA;  File &amp;quot;/home/raghav/.local/lib/python3.6/site-packages/ortools/sat/python/cp_model.py&amp;quot;, line 2165, in BooleanValue&#xA;    return EvaluateBooleanExpression(literal, self.__solution)&#xA;  File &amp;quot;/home/raghav/.local/lib/python3.6/site-packages/ortools/sat/python/cp_model.py&amp;quot;, line 2057, in EvaluateBooleanExpression&#xA;    return bool(solution.solution[index])&#xA;IndexError: list index (0) out of range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8918" LastEditorUserId="981" LastEditDate="2023-02-19T14:46:47.290" LastActivityDate="2023-02-19T14:46:47.290" Title="Google CP-SAT Infeasible ILP for Large Problem Area" Tags="|integer-programming|or-tools|cp-sat|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8507" PostTypeId="2" ParentId="8506" CreationDate="2022-06-07T21:24:47.503" Score="3" Body="&lt;p&gt;With 256, I get the optimal solution quite fast.&#xA;With &amp;gt; 256, I get the following error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;python3.9  infeasible_grid_sat.py&#xA;Traceback (most recent call last):&#xA;  File &amp;quot;infeasible_grid_sat.py&amp;quot;, line 29, in &amp;lt;module&amp;gt;&#xA;    W[i][i+1] = 1&#xA;IndexError: list assignment index out of range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;with 324 (18^2), I get an optimal solution easily.&lt;/p&gt;&#xA;&lt;p&gt;So it seems there is a problem with array boundaries.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2022-06-07T21:24:47.503" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8508" PostTypeId="2" ParentId="8505" CreationDate="2022-06-07T21:29:19.063" Score="5" Body="&lt;p&gt;You can add slacks to whatever combination of constraints you want.  But any constraint not having a slack must be satisfiable in its &amp;quot;no slack&amp;quot; form, else the model will be infeasible. And not using a slack on certain constraints might require larger slacks on other constraints; but that will not matter if the original unslacked model is feasible (technically, that the solver can find a feasible point, which if any constraints are non-convex, and the solver is not global, it might not necessarily be able to do, even if the model is actually feasible)&lt;/p&gt;&#xA;&lt;p&gt;Your formulation adds a nonlinear term to the objective (although it is still convex), because absolute value is nonlinear. The slacks can all be kept and used as continuous linear (the nicest case) by using a double-sided inequality without absolute value, and constraining the slack used on both sides of that inequality constraint to be nonnegative. In practice, some optimization modeling systems (front end to solver) might reformulate your version to essentially the same as mine.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \xi_e + \xi_l + \xi_g$$&lt;/span&gt;&#xA;s.t.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-\xi_e \le e(x)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$e(x) \le \xi_e$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\xi_e \geq 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$l(x) \leq \xi_l$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$g(x) \geq -\xi_g$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\xi_l \geq 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\xi_g \geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the first 2 inequality constraints replace your equality constraint.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-06-08T00:13:34.160" LastActivityDate="2022-06-08T00:13:34.160" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8509" PostTypeId="1" CreationDate="2022-06-08T00:36:18.510" Score="6" ViewCount="226" Body="&lt;p&gt;I've recently been exploring Reinforcement Learning (RL) methods in my work and the exploration-exploitation dilemma is always mentioned. It almost feels like the exploration-exploitation dilemma stemmed from RL research. However, when we think about Simulated Annealing (SA) and Genetic Algorithms (GA), isn't there also the notion of exploration and exploitation? Specifically, in SA, you take a random step (explore) with some probability and an improving step otherwise (exploit). In GA, you mutate (explore) with some probability and select good parents for crossover (exploit).&lt;/p&gt;&#xA;&lt;p&gt;My question: which paper first mentioned this? It feels as though &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/orsc.2.1.71&quot; rel=&quot;noreferrer&quot;&gt;https://pubsonline.informs.org/doi/abs/10.1287/orsc.2.1.71&lt;/a&gt; is when it was first mentioned but I'd like expert opinions on this.&lt;/p&gt;&#xA;" OwnerUserId="9794" LastEditorUserId="500" LastEditDate="2022-06-08T00:37:20.747" LastActivityDate="2022-06-09T17:26:48.327" Title="When was the exploration and exploitation tradeoff first mentioned in literature?" Tags="|optimization|reference-request|reinforcement-learning|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8510" PostTypeId="1" AcceptedAnswerId="8512" CreationDate="2022-06-08T18:33:11.460" Score="5" ViewCount="113" Body="&lt;p&gt;For a job-shop-like problem I have some constraints of this form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c_i \geq s_i + d_{iom} z_{iom}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{iom}$&lt;/span&gt; is a binary enabler, &lt;span class=&quot;math-container&quot;&gt;$d_{iom}$&lt;/span&gt; is the delay on job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; for operation &lt;span class=&quot;math-container&quot;&gt;$o$&lt;/span&gt; done by machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; is the start time, &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; the completion time. Suppose I know that &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; is the center of some normal distribution, and I also know &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt;, the variance for that distribution. How can I take advantage of &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt;? I'm not using it presently.&lt;/p&gt;&#xA;&lt;p&gt;This is similar to stochastic programs, but those seem to utilize many scenarios. Suppose I don't have many scenarios handy; I just know the variance. Can I use that information to come up with an improved job ordering?&lt;/p&gt;&#xA;" OwnerUserId="7428" LastEditorUserId="123" LastEditDate="2022-06-08T20:32:04.483" LastActivityDate="2022-06-09T09:14:32.120" Title="Use of variance in job ordering" Tags="|stochastic-programming|job-shop-scheduling|variance|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8511" PostTypeId="1" CreationDate="2022-06-09T07:29:54.740" Score="3" ViewCount="88" Body="&lt;p&gt;I have the time series of car rentals/demand in a location. The time axis is every hour for 3 months. The y-axis is number of car rentals/demand.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JbFr9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JbFr9.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I want to do prediction for future hours given this information. I would like to know the prediction models for this type of data.&lt;/p&gt;&#xA;&lt;p&gt;I am not sure about the performance of ARIMA or other time series predicion models given low values of car rentals at each hour (close to zero). The maximum is only 5 car rentals.&lt;/p&gt;&#xA;&lt;p&gt;What are the typical and high accuracy methods? It could be statistical or machine-learning based models.&lt;/p&gt;&#xA;" OwnerUserId="4945" LastActivityDate="2022-06-09T07:29:54.740" Title="Car rental time series forecasting" Tags="|modeling|time-series|demand-distribution|forecasting|" AnswerCount="0" CommentCount="8" ClosedDate="2023-03-20T10:29:52.470" ContentLicense="CC BY-SA 4.0" />
  <row Id="8512" PostTypeId="2" ParentId="8510" CreationDate="2022-06-09T09:14:32.120" Score="4" Body="&lt;p&gt;Just two disclaimers to start with:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I'm not using it presently.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Due to this sentence and the lack of broader context in your question (e.g., if there are any other stochastic variables in your model besides &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt;), I assume that right now you have a completely deterministic model and this is the first stochastic description you want to add to the model.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Suppose I know that di is the center of some normal distribution, and I also know vi, the variance for that distribution.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I will take your word that &lt;span class=&quot;math-container&quot;&gt;$d_{iom}$&lt;/span&gt; is normally distributed. Note that this is an assumption that often helps with the math, but is not necessarily representative. For example, you will always have some nonzero probability of a negative delay. However, if your expected value &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; is significantly larger than &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; that phenomenon can safely be neglected.&lt;/p&gt;&#xA;&lt;p&gt;With that out of the way, I think you have at least 3 directions in which you could go, two scenario based, and chance-constrained optimization.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1. Monte Carlo Sampling&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;As Penghui Guo noted, you have all the information you need to sample possible realizations of &lt;span class=&quot;math-container&quot;&gt;$d_{iom}$&lt;/span&gt;: You assume it to be normally distributed, with center (i.e., expectation) &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; and variance &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt;. Now you can use your favorite random number generator to give you several samples, in C++ this could be std::normal_distribution. Each of the samples give you one scenario, you can weigh each scenario equally, but you will need many samples to describe the normal distribution appropriately.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;2. Scenario-based modelling in 'plain-vanilla' stochastic programming style&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here you generate weighted scenarios, e.g., you know that 68.2% of all realizations are within &lt;span class=&quot;math-container&quot;&gt;$[d_i - 1v_i, d_i + 1v_i]$&lt;/span&gt;. You could represent this scenario with &lt;span class=&quot;math-container&quot;&gt;$d_{iom}=d_i$&lt;/span&gt; to stay within your notation. Then you have one scenario with probability 15.9% to represent cases where &lt;span class=&quot;math-container&quot;&gt;$d_{iom} \in [-\inf, d_i - 1v_i]$&lt;/span&gt;, which you could represent with &lt;span class=&quot;math-container&quot;&gt;$d_{iom}=d_i-2v_i$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;$d_{iom}=d_i-1.5v_i$&lt;/span&gt; (of course you can also compute the center of that tail of the distribution, which I did not bother to do). The third scenario would then represent the upper tail, so those cases where &lt;span class=&quot;math-container&quot;&gt;$d_{iom} \in [d_i + 1v_i, \inf]$&lt;/span&gt;, again with 15.9% probability.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;A general note regarding scenarios&lt;/em&gt;&#xA;Scenarios blow up the model size incredibly fast! In particular as you have the three indices &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$o$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, which depending on your model, might all be dimensions in which you can generate scenarios. As a simple example, consider this: Let's say, you have &lt;span class=&quot;math-container&quot;&gt;$i \in {1,2}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$o \in {1,2}$&lt;/span&gt; and we omit &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;. Now you already have 4 variables, &lt;span class=&quot;math-container&quot;&gt;$d_{1,1}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_{1,2}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_{2,1}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_{2,2}$&lt;/span&gt;. If you only have 2 scenarios for each of these variables, you will end up with a scenario tree of 16 (=&lt;span class=&quot;math-container&quot;&gt;$2^4$&lt;/span&gt;) leafs. If you have 3 scenarios per variable, you'd already be at &lt;span class=&quot;math-container&quot;&gt;$3^4=81$&lt;/span&gt; leafs! Thus, maybe the next framework is computationally more tractable and still an acceptable representation of reality:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;3. Chance-constraint optimization&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\Phi(x)$&lt;/span&gt; be the cumulative distribution function (or short cdf) of your delay, that means &lt;span class=&quot;math-container&quot;&gt;$\Phi(x) = \mathbb{P}(delay \leq x)$&lt;/span&gt;. This cdf depends on the variance &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt;, so you can use &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; to compute a value &lt;span class=&quot;math-container&quot;&gt;$d^{95}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$d_{iom}$&lt;/span&gt; that covers, say, 95% of all delays. The exat percentage is your choice of course. This way your model is conservative in 95% (or 80%, or 98%,... you get the idea) of all cases, in the sense that it overestimates the delay and only in the remaining few cases you will have modeled the delay to be too short. Here is how you would model it:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$d^{95} = \Phi^{-1}(95\%)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ c_i \geq s_i + d^{95}z_{iom}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where you'd only have to look up how to compute &lt;span class=&quot;math-container&quot;&gt;$\Phi^{-1}$&lt;/span&gt; as a function of your variance &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; in your computational environment. Essentially you are replacing your original inequality &lt;span class=&quot;math-container&quot;&gt;$ c_i \geq s_i + d_{iom}z_{iom}$&lt;/span&gt; with the inequality &lt;span class=&quot;math-container&quot;&gt;$ \mathbb{P}(c_i \geq s_i + d_{iom}z_{iom}) \geq 95\%$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The charm of this solution is that you would only need one additional equation per delay for which you want chance constraints.&lt;/p&gt;&#xA;&lt;p&gt;Hope this gives you some inspiration!&lt;/p&gt;&#xA;" OwnerUserId="9763" LastActivityDate="2022-06-09T09:14:32.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8513" PostTypeId="1" AcceptedAnswerId="8516" CreationDate="2022-06-09T14:21:01.177" Score="17" ViewCount="2743" Body="&lt;p&gt;I see from &lt;a href=&quot;https://news.stanford.edu/news/2005/may25/dantzigobit-052505.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and many other sources that Dantzig invented the Simplex method in 1947. After much searching, I found that the earliest publication is &lt;a href=&quot;https://www.rand.org/pubs/papers/P891.html&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; in 1956. Does anyone know where the original 1947 paper is?&lt;/p&gt;&#xA;" OwnerUserId="9794" LastEditorUserId="123" LastEditDate="2022-06-10T20:17:52.717" LastActivityDate="2024-03-12T01:53:21.077" Title="Where is the original Dantzig Simplex 1947 paper?" Tags="|reference-request|simplex|history|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8514" PostTypeId="2" ParentId="8496" CreationDate="2022-06-09T14:35:24.640" Score="1" Body="&lt;p&gt;See &lt;a href=&quot;https://github.com/AlexFleischerParis/zoodocplex/blob/master/zooscenariiindataframes.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt; in &lt;a href=&quot;https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;easy optimization with python&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;import pandas as pd&#xA;&#xA;buses = {'costBus40': [500, 550,600], 'costBus30': [400, 450,440],'nbKids': [300, 320,330]}&#xA;dfBusesScenarii = pd.DataFrame(data=buses)&#xA;&#xA;&#xA;&#xA;for s in range(0,len(dfBusesScenarii)):&#xA;    costBus40=dfBusesScenarii['costBus40'][s]&#xA;    costBus30=dfBusesScenarii['costBus30'][s]&#xA;    nbKids=dfBusesScenarii['nbKids'][s]&#xA;&#xA;    mdl = Model(name='buses')&#xA;    &#xA;    nbbus40 = mdl.integer_var(name='nbBs40')&#xA;    nbbus30 = mdl.integer_var(name='nbBus30')&#xA;&#xA;    mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= nbKids, 'kids')&#xA;    mdl.minimize(nbbus40*costBus40 + nbbus30*costBus30)&#xA;&#xA;    mdl.solve()&#xA;    cost=mdl.solution.get_objective_value()&#xA;    &#xA;    print(&amp;quot;if we need to bring &amp;quot;,nbKids,&amp;quot; kids  to the zoo&amp;quot;);&#xA;    print(&amp;quot;with costs &amp;quot;,costBus40,&amp;quot; and &amp;quot;,costBus30)&#xA;    print(int(nbbus40.solution_value),&amp;quot; buses 40 seats and &amp;quot;,int(nbbus30.solution_value), &amp;quot; buses 30 seats&amp;quot;);&#xA;    print(&amp;quot;cost = &amp;quot;,cost)&#xA;    print()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if we need to bring  300  kids  to the zoo&#xA;with costs  500  and  400&#xA;6  buses 40 seats and  2  buses 30 seats&#xA;cost =  3800.0&#xA;if we need to bring  320  kids  to the zoo&#xA;with costs  550  and  450&#xA;8  buses 40 seats and  0  buses 30 seats&#xA;cost =  4400.0&#xA;if we need to bring  330  kids  to the zoo&#xA;with costs  600  and  440&#xA;0  buses 40 seats and  11  buses 30 seats&#xA;cost =  4840.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-06-09T14:35:24.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8515" PostTypeId="2" ParentId="8494" CreationDate="2022-06-09T14:56:13.420" Score="3" Body="&lt;p&gt;Yes , that's CPU time.&#xA;If you want real time then use the python time module&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-06-09T14:56:13.420" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8516" PostTypeId="2" ParentId="8513" CreationDate="2022-06-09T16:46:50.187" Score="19" Body="&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;When Dantzig devised the algorithm, he was working at the Pentagon and thus many things would have been designated as classified in the military. There are a few more details provided in the book &lt;a href=&quot;https://press.uchicago.edu/ucp/books/book/chicago/H/bo16160491.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;How Reason Almost Lost Its Mind: The Strange Career of Cold War Rationality&amp;quot;&lt;/a&gt; by Erickson &lt;em&gt;et al.&lt;/em&gt; (2013) but I need permission from the second author before I can quote any part of that.&lt;/p&gt;&#xA;&lt;p&gt;A number of Dantzig's documents published a few years after 1947 concerning the simplex method are publicly available; for instance, Dantzig, Orden and Wolfe &lt;a href=&quot;https://web.archive.org/web/20220610061048/https://apps.dtic.mil/sti/pdfs/AD0114134.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;published the generalized simplex method&lt;/a&gt; in 1954, but it is unclear whether the original paper has since been declassified and published publicly.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Most Important Finding&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In &lt;a href=&quot;https://link.springer.com/referenceworkentry/10.1057/978-1-349-95121-5_2839-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Dantzig, George B. (1914–2005)&amp;quot;&lt;/a&gt; by Cottle, Eaves and Thapa (2016), there is this curious reference in the following biography.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Selected Works&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1947. Prospectus for the AAF electronic computer. Unpublished manuscript.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;sub&gt; &lt;em&gt;AAF = United States Army Air Force.&lt;/em&gt; &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am not certain if this really was Dantzig's publication, but if so, then it suggests it won't be publicly available. However, there is a strong hint to this in the paragraphs I quote below.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Dantzig nonetheless turned down a position in mathematics at UC Berkeley for the greater financial security of a position at the Pentagon. There he undertook the challenge to &amp;quot;mechanize&amp;quot; the planning process. War planning required the coordination of an entire nation and yet was executed with desk calculators; the need for mechanization was clear. To this end, a group in the Air Force was organized under the name Project SCOOP (Scientific Computation of Optimum Programs) and headed by M.K. Wood. Dantzig was a principal.&lt;/p&gt;&#xA;&lt;p&gt;Two movements suggested that progress was possible: Leontief's (1936) work and the emergence of the computer; &lt;strong&gt;indeed, Project SCOOP arranged for Pentagon support of computer development (see Dantzig 1947)&lt;/strong&gt;. In early 1947, Dantzig formulated the general statement of a linear program. In June of that year, he learned from T.C. Koopmans, who had been studying transportation problems  (Koopmans 1947) that economists had no algorithm for solving a linear program. By July Dantzig had designed the simplex method.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;History&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are several journal articles that describe Dantzig's invention and discovery of the method, some including his own; for instance, this unclassified technical report titled &lt;a href=&quot;https://apps.dtic.mil/sti/pdfs/ADA157659.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Impact of Linear Programming on Computer Development&amp;quot;&lt;/a&gt; by Dantzig (1985).&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;Origins of the Simplex Method, Summer 1947&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first idea that would occur to anyone as a technique for solving&#xA;a linear program, aside from the obvious one of moving through the&#xA;interior of the convex set, is that of moving from one vertex to the next&#xA;along the edges of the polyhedral set. I discarded this idea immediately as&#xA;impractical in higher dimensional spaces. It seemed intuitively obvious&#xA;that there would be far too many vertices and edges to wander over in the&#xA;general case for such a method to be efficient.&lt;/p&gt;&#xA;&lt;p&gt;When Hurwicz came to visit me at the Pentagon in the summer of 1947, I&#xA;told him how I had discarded this vertex-edge approach as Intuitively&#xA;inefficient for solving LP. I suggested Instead that we study the problem&#xA;in the geometry of columns rather than the usual one of the rows -- column&#xA;geometry incidentally was the one I had used in my Ph.D. thesis on the&#xA;Neyman-Pearson Lemma. We dubbed the new method &amp;quot;climbing the bean pole.&amp;quot;&#xA;It looked to me efficient. [...] Apparently, in one geometry the&#xA;simplex method looks efficient while in another it appeared to be very&#xA;inefficient! Thus the simplex method was born in August 1947.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Other potential avenues to track the paper&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I also found a &lt;a href=&quot;http://pdf.oac.cdlib.org/pdf/stanford/uarc/sc0826.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;comprehensive list of Dantzig's publications, talks and correspondences&lt;/a&gt;, where of interest are&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;box 10, folder 19 Letters to Laderman Simplex Algorithm Dec 1947/Sept. 1947&lt;/p&gt;&#xA;&lt;p&gt;box 10, folder 21 First Simplex Method Computations Summer 1947&lt;/p&gt;&#xA;&lt;p&gt;box 10, folder 22 AMC SCOOP Supply Procedure October 1947&lt;/p&gt;&#xA;&lt;p&gt;box 10, folder 23 Outline of Talk Given BLS (Cornfield) 6/26/1947&lt;/p&gt;&#xA;&lt;p&gt;box 16, folder 29 Copies of correspondence with Von Neumman 10/1/1947&lt;/p&gt;&#xA;&lt;p&gt;box 16, folder 34 Discussion of a Max problem Von Neumman 11/15/1947.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The first two items in particular may be of greatest relevance. Unfortunately, these are all physically archived within Stanford University Library so I am not able to access them.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="10807" LastEditDate="2024-03-12T01:53:21.077" LastActivityDate="2024-03-12T01:53:21.077" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8517" PostTypeId="2" ParentId="8509" CreationDate="2022-06-09T17:26:48.327" Score="1" Body="&lt;p&gt;With reference to the paper in the original post &amp;quot;Exploration and Exploitation in Organizational Learning&amp;quot; (E&amp;amp;E) by James G. March, the paper &amp;quot;&lt;a href=&quot;https://www.researchgate.net/publication/261758299_The_Lost_Experiment_in_Exploration_and_Exploitation&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Lost Experiment in Exploration and Exploitation&lt;/a&gt;&amp;quot; by Donncha Kavanagh provides some interesting historical context preceeding the E&amp;amp;E paper.&lt;/p&gt;&#xA;" OwnerUserId="121" LastActivityDate="2022-06-09T17:26:48.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8518" PostTypeId="2" ParentId="8506" CreationDate="2022-06-09T17:33:28.743" Score="1" Body="&lt;p&gt;So the issue here is that I have overconstrained the model. I am constraining the relationship between out_degree and in_degree while simultaneously constraining the actual value of &lt;code&gt;out_degree&lt;/code&gt; or &lt;code&gt;in_degree&lt;/code&gt; too.&lt;/p&gt;&#xA;&lt;p&gt;Instead, once the relationship between &lt;code&gt;out_degree&lt;/code&gt; and &lt;code&gt;in_degree&lt;/code&gt; has been developed, simply constrain &lt;code&gt;out_degree &amp;lt;= 1&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8918" LastEditorUserId="123" LastEditDate="2022-06-09T17:43:40.037" LastActivityDate="2022-06-09T17:43:40.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8519" PostTypeId="1" CreationDate="2022-06-10T11:52:04.447" Score="2" ViewCount="64" Body="&lt;p&gt;I'm looking at a problem that looks as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;C = \sum_{i =1}^N\sum_{j&amp;lt;i} ( A_{ij} - B_{{P(i)P(j)}} )^2&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; are square matrices and &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is a permutation matrix mapping all &lt;span class=&quot;math-container&quot;&gt;$i \in \{1,...N\}$&lt;/span&gt; to the best permuted indices. I'm thinking it's similar to an QAP, but I'm not sure.&lt;/p&gt;&#xA;" OwnerUserId="9802" LastActivityDate="2022-06-10T11:52:04.447" Title="Type of combinatorial problem" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|assignment-problem|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8521" PostTypeId="2" ParentId="8513" CreationDate="2022-06-10T14:00:41.503" Score="3" Body="&lt;p&gt;The earliest Dantzig reference I know for the simplex method is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;George B. Dantzig, &amp;quot;Maximization of a Linear Function of Variables Subject to Linear Inequalities.&amp;quot; In &lt;em&gt;&lt;a href=&quot;https://cowles.yale.edu/sites/default/files/files/pub/mon/m13-all.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Activity Analysis of Production and Allocation&lt;/a&gt;,&lt;/em&gt; Tjalling C. Koopmans, ed., Wiley (1951) 339-347.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Although this volume was published in 1951, it is based on presentations given at a conference in 1949, and Dantzig's footnotes on the title page make it clear that his investigations of the simplex method dated to 1947.&lt;/p&gt;&#xA;&lt;p&gt;This and other early references from Dantzig's work at the RAND Corporation are given in &lt;a href=&quot;https://ampl.com/MEETINGS/TALKS/2014_11_San_Francisco_MB08.2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Origins of a Practical Simplex Method&lt;/a&gt;, a talk I contributed to a celebration of Dantzig's &amp;quot;100th birthday&amp;quot; at the INFORMS Annual Meeting in 2014.&lt;/p&gt;&#xA;" OwnerUserId="52" LastActivityDate="2022-06-10T14:00:41.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8522" PostTypeId="2" ParentId="8513" CreationDate="2022-06-10T14:30:50.350" Score="2" Body="&lt;p&gt;Just to supplement a great answer by @TheSimpliFire, the chapter &amp;quot;&lt;a href=&quot;https://dl.acm.org/doi/10.1145/87252.88081&quot; rel=&quot;nofollow noreferrer&quot;&gt;Origins of the Simplex Method&lt;/a&gt;&amp;quot; by Dantzig in &amp;quot;A history of scientific computing&amp;quot; (June 1990), also gives some idea of what work was being done in the field around the time he developed his approach.&lt;/p&gt;&#xA;&lt;p&gt;A reference provided in that chapter is to:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;G. B. Dantzig, &amp;quot;Linear Programming,&amp;quot; in Problems for the Numerical&#xA;Analysis of the Future, Proceedings of the Symposium on Modern&#xA;Calculating Machinery and Numerical Methods, UCLA (July 29-31,1948);&#xA;Appl. Math. 15, National Bureau of Standards (1951): 18-21.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://ntrl.ntis.gov/NTRL/dashboard/searchResults/titleDetail/PB251866.xhtml&quot; rel=&quot;nofollow noreferrer&quot;&gt;National Technical Reports Library in 1951&lt;/a&gt; mentions that it &lt;em&gt;includes four papers presented at the Symposium on Modern Calculating Machinery and Numerical Methods, held in July 1948&lt;/em&gt; one of which is titled Linear Programing by George B. Dantzig. That report can be found &lt;a href=&quot;https://books.google.co.za/books?id=_PlFpbo6XYQC&amp;amp;pg=PP1#v=onepage&amp;amp;q&amp;amp;f=false&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="121" LastActivityDate="2022-06-10T14:30:50.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8523" PostTypeId="2" ParentId="8493" CreationDate="2022-06-10T14:57:47.197" Score="1" Body="&lt;p&gt;With docplex as with other cplex API you can do postprocess.&lt;/p&gt;&#xA;&lt;p&gt;For instance, in the &lt;a href=&quot;https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;zoo example&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;mdl = Model(name='buses')&#xA;nbbus40 = mdl.integer_var(name='nbBus40')&#xA;nbbus30 = mdl.integer_var(name='nbBus30')&#xA;mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;mdl.minimize(nbbus40*500 + nbbus30*400)&#xA;&#xA;mdl.solve()&#xA;&#xA;print(&amp;quot;nb buses (40 seats and 30 seats) = &amp;quot;,int(nbbus40.solution_value+nbbus30.solution_value))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nb buses (40 seats and 30 seats) =  8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-06-10T14:57:47.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8524" PostTypeId="2" ParentId="8513" CreationDate="2022-06-10T15:15:51.980" Score="4" Body="&lt;p&gt;Another paper you may want to look at is the Project SCOOP (Scientific Computation of Optimum Programs) report, circa 1951. SCOOP was the project under which Dantzig did his first LP work. This report is accessible here:&#xA;&lt;a href=&quot;https://www.informs.org/Explore/History-of-O.R.-Excellence/O.R.-Methodologies/Optimization-Mathematical-Programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.informs.org/Explore/History-of-O.R.-Excellence/O.R.-Methodologies/Optimization-Mathematical-Programming&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-06-10T15:15:51.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8525" PostTypeId="1" CreationDate="2022-06-11T19:06:08.813" Score="0" ViewCount="420" Body="&lt;p&gt;I tried to find the Expected Value of Perfect Information (EVPI) and the Value of the Stochastic Solution (VSS) of the following problem.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Consider a farmer who specializes in raising wheat, corn, and sugar beets on his 500 acres of land. During the winter, he wants to&#xA;decide how much land to devote to each crop. The farmer knows that at least 200 tons (T) of wheat and 240 T of corn are&#xA;needed for cattle feed. These amounts can be raised on the farm or bought from a wholesaler. Any production in excess of the&#xA;feeding requirement would be sold. Over the last decade, mean selling prices have been \$170 and \$150 per ton of wheat and&#xA;corn, respectively. The purchase prices are 40% more than this due to the wholesaler’s margin and transportation costs. Another&#xA;profitable crop is sugar beet, which he expects to sell at \$36/T; however, there is a quota restriction on sugar beet production.&#xA;Any amount in excess of the quota can be sold only at \$10/T. The farmer’s quota for next year is 6000 T. Based on past&#xA;experience, the farmer knows that the mean yield on his land is roughly 2.5 T, 3 T, and 20 T per acre for wheat, corn, and sugar&#xA;beets, respectively. &lt;br&gt;(a) Let “above” and “below” average indicate a selling price 10% above or below the mean selling price&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Rk62n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Rk62n.png&quot; alt=&quot;image&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;To help the farmer make up his mind, we can set up the following model. Let&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; = acres of land devoted to wheat,&lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; = acres of land devoted to corn,&lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; = acres of land devoted to sugar beets,&lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$w_1$&lt;/span&gt; = tons of wheat sold,&lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; = tons of wheat purchased,&lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$w_2$&lt;/span&gt; = tons of corn sold,&lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; = tons of corn purchased,&lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$w_3$&lt;/span&gt; = tons of sugar beets sold at the favorable price.&lt;br&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$w_4$&lt;/span&gt; = tons of sugar beets sold at the lower price.&lt;br&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{|r|r|r|r|}&#xA; \hline&#xA;\text{Scenario} &amp;amp; \text{Wheat} &amp;amp;\text{Corn} &amp;amp;   \text{Beet}\\ \hline&#xA;\text{Above average}&amp;amp;187 &amp;amp;165&amp;amp;39.6\text{ OR }11\\ \hline&#xA;\text{Average}&amp;amp;170 &amp;amp;150&amp;amp;36\text{ OR }10\\ \hline&#xA;\text{Below average}&amp;amp;153 &amp;amp;135&amp;amp;32.4\text{ OR }9\\ \hline&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I used Lingo to solve this LP,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;! objetive function Z for best scenario;&#xA;Min = 150*x1+230*x2+260*x3+(238*y1-187*w1)+(210*y2-165*w2)-39.6*w3-11*w4;&#xA;!land constraint;&#xA;x1+x2+x3 &amp;lt;= 500;&#xA;!Wheat constraint;&#xA;2.5*x1+y1-w1 &amp;gt;= 200;&#xA;!Corn constraint;&#xA;3*x2+y2-w2 &amp;gt;= 240;&#xA;!Sugar beet constraint;&#xA;w3+w4 &amp;lt;= 20*x3;&#xA;!Quota constraint;&#xA;w3 &amp;lt;= 6000;&#xA;!non-negative constraint;&#xA;x1 &amp;gt;= 0;&#xA;x2 &amp;gt;= 0;&#xA;x3 &amp;gt;= 0;&#xA;y1 &amp;gt;= 0;&#xA;y2 &amp;gt;= 0;&#xA;w1 &amp;gt;= 0;&#xA;w2 &amp;gt;= 0;&#xA;w3 &amp;gt;= 0;&#xA;w4 &amp;gt;= 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Solution: &lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2,x_3,y_1,w_1,y_2,w_2,w_3,w_4)^T=(120,80,300,0,100,0,0,6000,0)^T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_{\text{min}}=141900$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;! objetive function Z for average scenario;&#xA;Min = 150*x1+230*x2+260*x3+(238*y1-170*w1)+(210*y2-150*w2)-36*w3-10*w4;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Solution: &lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2,x_3,y_1,w_1,y_2,w_2,w_3,w_4)^T=(120,80,300,0,100,0,0,6000,0)^T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_{\text{min}}=118600$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;! objetive function Z for below average scenario;&#xA;Min = 150*x1+230*x2+260*x3+(238*y1-153*w1)+(210*y2-135*w2)-32.4*w3-9*w4;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Solution: &lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2,x_3,y_1,w_1,y_2,w_2,w_3,w_4)^T=(120,80,300,0,100,0,0,6000,0)^T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_{\text{min}}=95300$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But my WS (wait and see solution) and EEV (expected value of expected value problem) have the same solution and &lt;span class=&quot;math-container&quot;&gt;$z_{\text{min}}$&lt;/span&gt; which implies EVPI = &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. Isn't EVPI need to be non-zero?&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;Can anyone help me to understand what &lt;strong&gt;E&lt;/strong&gt;xpected value of &lt;strong&gt;E&lt;/strong&gt;xpected &lt;strong&gt;V&lt;/strong&gt;alue problem and &lt;strong&gt;R&lt;/strong&gt;ecourse &lt;strong&gt;P&lt;/strong&gt;roblem actually do/mean?&lt;/p&gt;&#xA;" OwnerUserId="9806" LastEditorUserId="9806" LastEditDate="2022-06-12T10:28:56.620" LastActivityDate="2022-06-12T16:14:56.207" Title="Can Expected value of perfect information be zero?" Tags="|optimization|stochastic-programming|assignment-problem|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8527" PostTypeId="2" ParentId="8525" CreationDate="2022-06-11T22:16:59.980" Score="1" Body="&lt;p&gt;EVPI needs to be &lt;em&gt;nonnegative&lt;/em&gt;; it does not need to be strictly positive. Suppose, for example, that you have an LP model with three scenarios. The variable vector is &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, the constraints are identical across scenarios, and the objective function is to optimize &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; in one scenario, &lt;span class=&quot;math-container&quot;&gt;$\lambda f(x)$&lt;/span&gt; in another, and &lt;span class=&quot;math-container&quot;&gt;$\mu f(x)$&lt;/span&gt; in the third (&lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; being positive constants). Since the objective functions are scalar multiples of each other, the optimal solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; for the first scenario will also be optimal in the other two scenarios, and so information about which scenario applies will not change the solution. Thus the EVPI will be 0.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: Now that the problem statement is fixed, we can pin down what is going on. I think your model is wrong, in that the purchase price of wheat and corn should presumably inflate or deflate with the scenario (for instance, 140% of 90% of 170 for wheat in the below average scenario). That appears not to make a difference as far as EVPI is concerned.&lt;/p&gt;&#xA;&lt;p&gt;It turns out that growing wheat or corn is cheaper than buying it in all three scenarios, given the planting costs and yields. So you buy nothing in all three scenarios.&lt;/p&gt;&#xA;&lt;p&gt;Next, look at the relative profitability of wheat and corn. Corn has a higher yield but also a higher planting cost than wheat. In the &amp;quot;average&amp;quot; scenario, wheat is more profitable, so you will only plant enough corn to cover the cattle feed requirement. Sale prices would have to increase 220% (not one of your scenarios) for corn to become attractive.&lt;/p&gt;&#xA;&lt;p&gt;Similarly, beets sold at full price are more attractive than wheat unless prices drop to about 37% of average (again, not one of your scenarios), so you will plant 300 acres of beets in all scenarios. Beets above quota are money-losers unless prices rise at least 30% (not a scenario), and at that point they would still be inferior to wheat. So in all scenarios, the planting scheme is the same, and therefore the value of information is zero.&lt;/p&gt;&#xA;&lt;p&gt;If you have scenarios with more extreme price swings, you would eventually get a nonzero EVPI.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-06-12T16:14:56.207" LastActivityDate="2022-06-12T16:14:56.207" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8528" PostTypeId="1" AcceptedAnswerId="8531" CreationDate="2022-06-12T12:42:33.203" Score="1" ViewCount="105" Body="&lt;p&gt;I am trying to formulate an optimization problem that can be described as a set of tanks &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; where each tank &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; has a maximum capacity of &lt;span class=&quot;math-container&quot;&gt;$\overline{r}_{t}$&lt;/span&gt;. I want to fill all tanks as much as possible with a common resource &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; (provided). However, the tanks should be filled according to a pre-defined weighting &lt;span class=&quot;math-container&quot;&gt;$\omega_{t}$&lt;/span&gt;, so e.g. one tank should always contain twice the resouces of another.&lt;/p&gt;&#xA;&lt;p&gt;However, when a tank hits its maximum capacity &lt;span class=&quot;math-container&quot;&gt;$\overline{r}_{t}$&lt;/span&gt; it should be excluded from this constraint. The remaining tanks should still adhere to the weighting. This is where I'm struggling, as I cannot fix the weighting-relationship between all tanks.&lt;/p&gt;&#xA;&lt;p&gt;Example (in reality all variables are continuous):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Tank1 has a capacity of 2 and a weight of 1&lt;/li&gt;&#xA;&lt;li&gt;Tank2 has a capacity of 10 and a weight of 1&lt;/li&gt;&#xA;&lt;li&gt;Tank3 has a capacity of 6 and a weight of 2&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I expect the solution (resouces per tank) to be:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;[1,1,2] if &lt;span class=&quot;math-container&quot;&gt;$r=4$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;[2,2,4] if &lt;span class=&quot;math-container&quot;&gt;$r=8$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;[2,3,6] if &lt;span class=&quot;math-container&quot;&gt;$r=11$&lt;/span&gt; (Tank1 is full and it's weighting does not need to match any more)&lt;/li&gt;&#xA;&lt;li&gt;[2,4,6] if &lt;span class=&quot;math-container&quot;&gt;$r=12$&lt;/span&gt; (only Tank2 is getting filled from here)&lt;/li&gt;&#xA;&lt;li&gt;[2,10,6] for any &lt;span class=&quot;math-container&quot;&gt;$r \ge 18$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Any solutions I identified so far seem overly complex and very inefficient. Is it possible to formulate this problem as a linear program and if not, do you have any hints on how to solve this elegantly and efficiently?&lt;/p&gt;&#xA;" OwnerUserId="9535" LastEditorUserId="67" LastEditDate="2022-06-12T18:54:48.960" LastActivityDate="2022-06-12T19:05:21.957" Title="Relaxing a relation between variables if one of them reaches its maximal value" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8529" PostTypeId="1" AcceptedAnswerId="8530" CreationDate="2022-06-12T14:19:16.193" Score="2" ViewCount="540" Body="&lt;p&gt;I want to model &lt;a href=&quot;https://en.wikipedia.org/wiki/Maximum_cut&quot; rel=&quot;nofollow noreferrer&quot;&gt;Max-Cut&lt;/a&gt; in IBM's CPLEX, but I fail at modeling the objective function.&#xA;My attempt is to use is to sum the XOR of inclusion for vertices of each edge, as exactly then an edge is included in the cut. But I don't see a way to use XOR.&lt;/p&gt;&#xA;&lt;p&gt;Is there another way to model Max-Cut that is feasible in CPLEX?&lt;/p&gt;&#xA;" OwnerUserId="9809" LastEditorUserId="500" LastEditDate="2022-06-12T16:09:45.203" LastActivityDate="2022-06-13T12:06:32.470" Title="How to model Max-Cut as ILP" Tags="|modeling|integer-programming|cplex|combinatorial-optimization|graphs|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8530" PostTypeId="2" ParentId="8529" CreationDate="2022-06-12T15:11:50.330" Score="4" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; be the sets of vertices and edges respectively. Define a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_v$&lt;/span&gt; for each vertex &lt;span class=&quot;math-container&quot;&gt;$v\in V$&lt;/span&gt; to be 1 if the vertex is on the &amp;quot;left&amp;quot; side of the cut and 0 if it is on the &amp;quot;right&amp;quot; side. Define a variable &lt;span class=&quot;math-container&quot;&gt;$y_{(i,j)}\in [0,1]$&lt;/span&gt; for each edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in E.$&lt;/span&gt; (You can make &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; either binary or continuous.) Your objective function is to maximize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{(i,j)\in E} y_{(i,j)}$$&lt;/span&gt;and your constraints are &lt;span class=&quot;math-container&quot;&gt;$$y_{(i,j)}\le x_i + x_j \quad \forall (i,j)\in E$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$y_{(i,j)}\le 2 - x_i - x_j \quad \forall (i,j)\in E.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-06-12T15:11:50.330" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8531" PostTypeId="2" ParentId="8528" CreationDate="2022-06-12T17:50:22.267" Score="3" Body="&lt;p&gt;Let variable &lt;span class=&quot;math-container&quot;&gt;$x_t\in[0,\bar{r}_t]$&lt;/span&gt; be the level of tank &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; to indicate whether tank &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is full, and introduce variable &lt;span class=&quot;math-container&quot;&gt;$z\in[0,r]$&lt;/span&gt;.  The following constraints do the job:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_t x_t &amp;amp;= \min\left(r,\sum_t \bar{r}_t\right) \tag1 \\&#xA;y_t = 0 &amp;amp;\implies x_t = \omega_t z &amp;amp;&amp;amp;\text{for all $t$} \tag2 \\&#xA;y_t = 1 &amp;amp;\implies x_t \ge \bar{r}_t &amp;amp;&amp;amp;\text{for all $t$} \tag3 \\&#xA;y_t = 1 &amp;amp;\implies \omega_t z \ge \bar{r}_t &amp;amp;&amp;amp;\text{for all $t$} \tag4&#xA;\end{align}&lt;/span&gt;&#xA;If your solver supports indicator constraints, you can use these directly.  Otherwise, you can use big-M constraints to linearize them.  For example, constraint &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; becomes &lt;span class=&quot;math-container&quot;&gt;$x_t \ge \bar{r}_t y_t$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-06-12T19:05:21.957" LastActivityDate="2022-06-12T19:05:21.957" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8532" PostTypeId="1" CreationDate="2022-06-12T18:48:28.623" Score="2" ViewCount="298" Body="&lt;p&gt;Hope my question fit this community. I have taken Stochastic Optimization course (2 credits). The course content are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Deterministic VS Stochastic Linear Program&lt;/li&gt;&#xA;&lt;li&gt;Two-Stage Recourse Problem&lt;/li&gt;&#xA;&lt;li&gt;Multi-Stage Recourse Problem&lt;/li&gt;&#xA;&lt;li&gt;Chance Constrained SP&lt;/li&gt;&#xA;&lt;li&gt;Stochastic Integer Program&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This week I had taught Two-Stage Recourse Problem but couldn't manage to understand the context like why this method works? Specially, inequality like &lt;span class=&quot;math-container&quot;&gt;$\text{EV}\geq\text{WS}\geq\text{RP}\geq\text{EEV}$&lt;/span&gt; where EV, WS, RP and EEV stand for Expected Value problem, Wait and See problem, Recourse Problem and Expected value of Expected value problem respectively. And indexes like EVPI (Expected Value of Perfect Information) and VSS (Value of Stochastic Solution). All of these seem are memorizing things without understanding what's going on under the hood. Currently, my Professor follows &amp;quot;&lt;em&gt;Introduction to Stochastic Programming&lt;/em&gt;&amp;quot; by Birge and Louveaux.&lt;/p&gt;&#xA;&lt;p&gt;Is there any Book/Resource which design those things in a deeper fashion for completely beginner people?&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;@PenghuiGuo add some citations, which is great. I have cleared some of my doubts on EV, EEV and WS. But still couldn't manage to understand the RP intuitively. Even the method seems confusing because sometimes, &lt;strong&gt;Deterministic equivalent of SP problem directly&lt;/strong&gt;, without decomposition (considering every scenario variables in a single linear programming) was called as RP and sometimes, they &lt;strong&gt;split the non-stochastic parameters&lt;/strong&gt; and solve &lt;span class=&quot;math-container&quot;&gt;$Q(x,\xi)$&lt;/span&gt; seperately.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{array}{ll}\min &amp;amp; c^{T} x+E_{\xi}[Q(x, \xi)] \qquad\text{1st stage}\\ \text { s.t. } \quad &amp;amp; A x \leq b \\ &amp;amp; x \geq 0 \\ &amp;amp;Q(x, \xi)=\min q^{T} y \qquad\text{2nd stage}\\ \text { s.t. } \quad &amp;amp; T x+W y \leq h \\ &amp;amp; y \geq 0\end{array}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9806" LastEditorUserId="9806" LastEditDate="2022-06-14T09:40:41.513" LastActivityDate="2022-06-14T10:54:45.837" Title="Resource which explain different stochastic method with some intuition" Tags="|reference-request|stochastic-programming|books|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8533" PostTypeId="2" ParentId="8532" CreationDate="2022-06-12T20:02:17.230" Score="1" Body="&lt;p&gt;Since in the question you state &lt;span class=&quot;math-container&quot;&gt;$EV \geq WS \geq {\bf RP} \geq EEV$&lt;/span&gt;, following we assume a maximization problem.&lt;/p&gt;&#xA;&lt;p&gt;We start from the &lt;em&gt;Recourse Problem&lt;/em&gt; (RP) as it is exactly the stochastic programming problem, no matter how it is formulated&#xA;(the formulation in the question or the &lt;em&gt;extensive form&lt;/em&gt;, which is also known as &lt;em&gt;deterministic equivalent&lt;/em&gt;).&#xA;The motivation of the extensive form is that the formulation with a value function &lt;span class=&quot;math-container&quot;&gt;$Q(x, \xi)$&lt;/span&gt; can not be solved with known technics in the deterministic optimization.&#xA;But the extensive form is nothing but a Linear Programming that can be solved with what we have know in the deterministic optimization, e.g. the simplex method. However, the extensive form can be difficult to solve, since it has more variables than the form in the question.&#xA;This ask for technics like the Benders Decomposition, which is not going to be detailed in this question.&lt;/p&gt;&#xA;&lt;p&gt;The stochastic programming has both &lt;em&gt;here-and-now&lt;/em&gt; decisions (first-stage) and &lt;em&gt;wait-and-see&lt;/em&gt; decisions (second-stage).&#xA;What complicating the stochastic programming is the first-stage decision is made before the second-stage information is known, and the first-stage decision has to be constant for all the second-stage information reveal.&#xA;If we &lt;strong&gt;remove&lt;/strong&gt; this requirement (constraint), independent problems will be got, i.e., the &lt;em&gt;wait-and-see problem&lt;/em&gt; (WS).&#xA;Since some constraints are removed from the RP in WS, the solution yield by WS should not be worse than that of RP.&#xA;&lt;span class=&quot;math-container&quot;&gt;$WS \geq RP$&lt;/span&gt; is thus be explained.&lt;/p&gt;&#xA;&lt;p&gt;The Expected Value of Expected Value Problem (EEV) is yield by fixing the first-stage variables to the solution of the Expected Value Problem, which is &lt;strong&gt;not necessarily optimal&lt;/strong&gt; for the original RP.&#xA;Alternatively, the Expected Value Problem solution can be replaced with the worst case problem solution or heuristics solution, which is also not optimal for RP.&#xA;Hence,  &lt;span class=&quot;math-container&quot;&gt;$RP \geq EEV$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I doubt that the Expected Value Problem (EV) has better objective value than the RP. See [1] page 33.&lt;/p&gt;&#xA;&lt;p&gt;[1] Moraza, S.L., 2015. Two-Stage Stochastic Optimization. An Application in the Third Sector. &lt;a href=&quot;https://addi.ehu.es/bitstream/handle/10810/18673/TFG_S.Laconcepcion.pdf?sequence=1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://addi.ehu.es/bitstream/handle/10810/18673/TFG_S.Laconcepcion.pdf?sequence=1&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The original paper for Value of Stochastic Solution (VSS):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Birge, J.R., 1982. The value of the stochastic solution in stochastic linear programs with fixed recourse. Mathematical Programming 24, 314–325. &lt;a href=&quot;https://doi.org/10.1007/BF01585113&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1007/BF01585113&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The original paper for Expected Value of Perfect Information (EVPI):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Raiffa, H., &amp;amp; Schlaifer, R. (1961). Applied Statistical Decision Theory. (1st ed.). Boston: Harvard University Press.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You may also refer to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Madansky, A., 1960. Inequalities for Stochastic Linear Programming Problems. Management Science 6, 197–204. &lt;a href=&quot;https://doi.org/10.1287/mnsc.6.2.197&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/mnsc.6.2.197&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;And an example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Linderoth, J., 2016. Stochastic Programming Modeling. &lt;a href=&quot;https://www.ima.umn.edu/2015-2016/ND8.1-12.16/25379&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ima.umn.edu/2015-2016/ND8.1-12.16/25379&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8718" LastEditorUserId="8718" LastEditDate="2022-06-14T10:54:45.837" LastActivityDate="2022-06-14T10:54:45.837" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8534" PostTypeId="1" AcceptedAnswerId="8536" CreationDate="2022-06-12T20:32:29.557" Score="1" ViewCount="166" Body="&lt;p&gt;I would like to implement a solution for Multi-Agent Pathfinding Problem using Google's CP-SAT Solver.&lt;/p&gt;&#xA;&lt;p&gt;How do I implement the constraint that prohibits 2 or more agents from occupying the same cell at the same time instance? I would like that when considering every individual step by an agent to be taking 1 time unit, at any time instance &lt;code&gt;ti&lt;/code&gt;, no 2 agents occupy the same node in the graph.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zqKgY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zqKgY.png&quot; alt=&quot;Paths of individual agents&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[Example:] As visible in the image, for the three agents following the trajectory as marked, at time &lt;code&gt;t=6 units&lt;/code&gt;, the green and blue agents occupy the same cell. Similarly, at &lt;code&gt;t=12 units&lt;/code&gt;, the blue and pink agents occupy the same cell. The trajectories of the pink and green agents intersecting is not an issue, as each agent occupies the cell at different time steps, therefore not causing a collision.&lt;/p&gt;&#xA;&lt;p&gt;Till now, I have implemented the problem without collision avoidance. Each agent has its corresponding matrix of decision variables, where each decision variable &lt;code&gt;Pij&lt;/code&gt; represents if there is a transition or not from cell &lt;code&gt;i&lt;/code&gt; to &lt;code&gt;j&lt;/code&gt; in the solution. I have also added flow constraints, which means each agent may traverse a cell once &lt;em&gt;each&lt;/em&gt;. Transitions are only possible in single steps between adjacent cells.&lt;/p&gt;&#xA;&lt;p&gt;You may find my code till now &lt;a href=&quot;https://gist.github.com/raghavthakar/c43a5e8c5b27d9bdd3a0520e507085f6&quot; rel=&quot;nofollow noreferrer&quot;&gt;here.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8918" LastEditorUserId="981" LastEditDate="2023-02-19T14:46:17.063" LastActivityDate="2023-02-19T14:46:17.063" Title="Modeling Multi-Agent Collision in Google CP-SAT Solver" Tags="|integer-programming|or-tools|cp-sat|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8536" PostTypeId="2" ParentId="8534" CreationDate="2022-06-13T09:28:04.793" Score="3" Body="&lt;p&gt;Here is my proposal:&lt;/p&gt;&#xA;&lt;p&gt;for each arc: (one vertical or horizontal segment of an path)&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;create a start variable&lt;/li&gt;&#xA;&lt;li&gt;compute a min duration&lt;/li&gt;&#xA;&lt;li&gt;create a end variable&lt;/li&gt;&#xA;&lt;li&gt;create an variable interval with those 3 variables&lt;/li&gt;&#xA;&lt;li&gt;add (start(current_arc) == end(previous_arc)  # no wait constraint&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For each conflicting cell:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;create a no_overlap_constraint(arcs using that cell)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Solve as a regular (scheduling) problem.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2022-06-13T09:28:04.793" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8537" PostTypeId="2" ParentId="8529" CreationDate="2022-06-13T12:06:32.470" Score="4" Body="&lt;p&gt;To start with maxcut, you can start with the &lt;a href=&quot;https://github.com/AlexFleischerParis/howtowithopl/blob/master/maxcut.mod&quot; rel=&quot;nofollow noreferrer&quot;&gt;maxcut example&lt;/a&gt; in &lt;a href=&quot;https://www.linkedin.com/pulse/how-opl-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;how to with OPL&lt;/a&gt; ?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int n=400;&#xA;range r=1..n;&#xA;&#xA;// Random graph  &#xA;float edge_prob=0.5;&#xA;int  weight_range=10;&#xA;int big=100000;&#xA; &#xA;tuple t&#xA;{&#xA;  int i;&#xA;  int j;&#xA;}&#xA;&#xA;{t} s={&amp;lt;i,j&amp;gt; | ordered i,j in r};&#xA;&#xA;int w[i in r][j in r]=(i&amp;lt;=j)?((rand(big)&amp;lt;=big*edge_prob)?rand(weight_range):0):0;&#xA;&#xA;// end of random graph&#xA;&#xA;//int n=4;&#xA;//range r=1..n;&#xA;//float w[r][r]=&#xA;//&#xA;//[[ 0. , 8. ,-9. , 0.],&#xA;// [ 8. , 0. , 7. , 9.],&#xA;// [-9. , 7.  ,0., -8.],&#xA;// [ 0. , 9., -8. , 0.]];&#xA;&#xA;assert card(s)==n*(n-1) div 2;&#xA;&#xA; // x is the unknown and 0 or 1 means in one or the other side of the fence&#xA; dvar boolean x[r];&#xA; &#xA; dexpr float obj=2*sum(&amp;lt;i,j&amp;gt; in s) w[i][j]*x[i]*(1-x[j]);&#xA; &#xA; maximize obj;&#xA; &#xA; subject to&#xA; {&#xA;   &#xA; }&#xA; &#xA; {int} x1={i| i in r:x[i]==1};&#xA; &#xA; execute&#xA; {&#xA;   writeln(&amp;quot;objective = &amp;quot;,obj);&#xA;   writeln(&amp;quot;x set to 1 : &amp;quot;,x1);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-06-13T12:06:32.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8539" PostTypeId="2" ParentId="7290" CreationDate="2022-06-14T01:33:07.407" Score="3" Body="&lt;p&gt;No, i am not aware of such a solver. However sequentially excluding previously optimal results comes with an additional pitfall: If the solver discovered symmetries and did cut them away you also exclude symmetric solutions although they would rank before the next best objective.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-06-14T01:33:07.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8541" PostTypeId="1" AcceptedAnswerId="8549" CreationDate="2022-06-14T09:51:37.170" Score="4" ViewCount="432" Body="&lt;p&gt;Bot for getting better insight and reporting purposes, I am looking for a way to visualize results to the Resource-Constrained Project Scheduling Problem (RCPSP). I am aware that such results are most often represented by a resource Gantt chart. An example of such a visualization is the following from a well-known &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-1-4615-5533-9_7&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt; by Kolisch and Hartmann:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HAz34.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HAz34.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This example instance comprises 6 activities and only one resource with capacity 4.&lt;/p&gt;&#xA;&lt;p&gt;I like this kind of visualization for its simplicity. Instead of writing a visualization script myself, I was wondering if there are any tools out there that could do this for me?&lt;/p&gt;&#xA;" OwnerUserId="7399" LastActivityDate="2022-06-14T15:24:05.873" Title="Visualizing results to the RCPSP" Tags="|scheduling|visualization|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8542" PostTypeId="1" CreationDate="2022-06-14T11:28:15.710" Score="3" ViewCount="246" Body="&lt;p&gt;We have a group project and our job is to create an algorithm for solving a TSP with Branch and Cut. (Use of lazy constraints.) We tried around but don´t know what is the best way to start. We get the first solution with the nearest neighbor heuristic. From there on we should start with the solution. We should use the Gurobi solver.&lt;/p&gt;&#xA;&lt;p&gt;What is the best way to get through this?&lt;/p&gt;&#xA;" OwnerUserId="9817" LastEditorUserId="279" LastEditDate="2022-06-15T02:37:33.430" LastActivityDate="2022-06-15T02:37:41.300" Title="Solution for a TSP with Branch and Cut for Gurobi in Java?" Tags="|gurobi|traveling-salesman|branch-and-cut|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8543" PostTypeId="2" ParentId="8541" CreationDate="2022-06-14T12:06:12.383" Score="2" Body="&lt;p&gt;You can use &lt;a href=&quot;https://plotly.com/python-api-reference/generated/plotly.express.timeline.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Plotly&lt;/a&gt; (&lt;a href=&quot;https://pythonwife.com/gantt-chart-with-plotly/&quot; rel=&quot;nofollow noreferrer&quot;&gt;examples&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-06-14T12:06:12.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8544" PostTypeId="2" ParentId="8542" CreationDate="2022-06-14T12:15:46.790" Score="3" Body="&lt;p&gt;There are some useful resources to use Gurobi and its callback functions to do that. In the following the first is based on Java and the second one is based on Python which can be translated to its Java equivalent.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/9.5/examples/tsp_java.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Solve a traveling salesman problem on a randomly generated set of points using lazy constraints&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=3dn9V2rlYUo&quot; rel=&quot;nofollow noreferrer&quot;&gt;Faster MIPs Using Custom Heuristics&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also, you might find out other helpful examples by googling, specifically, on GitHub.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="279" LastEditDate="2022-06-15T02:37:41.300" LastActivityDate="2022-06-15T02:37:41.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8545" PostTypeId="2" ParentId="8541" CreationDate="2022-06-14T12:35:13.687" Score="3" Body="&lt;p&gt;Please be aware that, there are two types of Gantt charts in the practical situation. First, &lt;a href=&quot;https://www.sinnaps.com/en/project-management-blog/resource-gantt-chart&quot; rel=&quot;nofollow noreferrer&quot;&gt;the task Gantt chart and the second resource Gantt chart&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Besides the python library proposed by @fontanf, I think still the simplest way to depict the result of such a problem is to use some useful separate sheet templates like &lt;a href=&quot;https://templates.office.com/en-us/simple-gantt-chart-tm16400962&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;. Also, some open-source libraries like &lt;a href=&quot;https://www.eclipse.org/nebula/widgets/ganttchart/ganttchart.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nebula GANTT Chart Widget&lt;/a&gt; (in java) would be interesting.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-06-14T12:35:13.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8546" PostTypeId="1" CreationDate="2022-06-14T13:01:41.157" Score="2" ViewCount="261" Body="&lt;p&gt;First off: I totally understand if &amp;quot;it depends&amp;quot; is the only feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;I'm running a large (to me) MIP using Gurobi in R on my local machine.  (~2M binary decision variables, ~15K continuous decision variables).&lt;/p&gt;&#xA;&lt;p&gt;I have 256GB RAM and the model is only using about 40GB at max, during presolve, so that's not a bottleneck.  My processor is puny though, only 4 cores and 4 threads.  I'm awaiting delivery for a 18 core / 36 thread processor.  Assuming I run the model on 35 of the 36 threads, on approximately what order of a speedup can I anticipate?  I'm assuming there's a diminishing returns with more cores.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastActivityDate="2022-06-14T15:43:30.090" Title="Approximate Speed-Up With Increasing Cores?" Tags="|mixed-integer-programming|gurobi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8548" PostTypeId="1" CreationDate="2022-06-14T14:36:25.417" Score="2" ViewCount="79" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Given an optimization problem as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{cc}&#xA;\operatorname{Max} Z=3 x_{1}+9 x_{2}-2 y_{1}-4 y_{2} \\&#xA;\text { subject to, }  y_{1}+y_{2}=15 \\&#xA;5 x_{1}+2 x_{2} \leq 10 \\&#xA;x_{1}, x_{2}, y_{1}, y_{2} \geq 0&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;Assume that variables &lt;span class=&quot;math-container&quot;&gt;$x_{1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{2}$&lt;/span&gt; are uncertain and that there are three different scenarios, &lt;span class=&quot;math-container&quot;&gt;$(1.3 X, X, 0.6 X)$&lt;/span&gt; for the values of &lt;span class=&quot;math-container&quot;&gt;$x_{1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{2}$&lt;/span&gt;, each occurring with a probability of &lt;span class=&quot;math-container&quot;&gt;$1 / 3$&lt;/span&gt;.&lt;br&gt;&#xA;(a) Formulate the scenario based stochastic models as a deterministic equivalent model&lt;br&gt;&#xA;(b) Reformulate the problem as an Expected Value problem.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;(a) Deterministic equivalent model is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\operatorname{Max} z=&amp;amp; \frac{1}{3}(1.3)\left(3 x_{11}+9 x_{21}\right)+\frac{1}{3}(1)\left(3 x_{12}+9 x_{22}\right) \\&#xA;&amp;amp;+\frac{1}{3}(0.6)\left(3 x_{13}+9 x_{23}\right)-2 y_{1}-4 y_{2}&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;subject to: &lt;span class=&quot;math-container&quot;&gt;$$\quad y_{1}+y_{2}=15$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;1.3\left(5 x_{11}+2 x_{21}\right) \leq 10 \\&#xA;1\left(5 x_{12}+2 x_{22}\right) \leq 10 \\&#xA;0.6\left(5 x_{13}+2 x_{23}\right) \leq 10&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x_{i s}, y_{i} \geq 0 ; i=1,2 ; s=1,2,3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(b) I have confusion with this problem. What I did,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\mathbb E[q]=\left( \frac13 (1.3)\left(3,9\right)+\frac13 (1)\left(3,9\right)+\frac13 (0.6)\left(3,9\right)\right)=\left(2.9,8.7\right)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\mathbb E[W]=\left( \frac13 (1.3)\left(5,2\right)+\frac13 (1)\left(5,2\right)+\frac13 (0.6)\left(5,2\right)\right)=\left(4.83333,1.93333\right)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\operatorname{Max} z=&amp;amp; \left(2.9 x_{1}+8.7 x_{2}\right)-2 y_{1}-4 y_{2}&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;subject to: &lt;span class=&quot;math-container&quot;&gt;$$\quad y_{1}+y_{2}=15$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;4.83333 x_{1}+1.93333 x_{2} \leq 10&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x_{i}, y_{i} \geq 0 ; i=1,2 $&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;p&gt;Is my approach is correct?&lt;/p&gt;&#xA;" OwnerUserId="9806" LastActivityDate="2022-06-14T14:36:25.417" Title="Reformulate the deterministic equivalent model as an Expected Value problem" Tags="|stochastic-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8549" PostTypeId="2" ParentId="8541" CreationDate="2022-06-14T14:45:48.810" Score="5" Body="&lt;p&gt;In the IBM CPLEX IDE if you run the sched_rcpsp example you will see&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LdN9I.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LdN9I.png&quot; alt=&quot;gantt in cplex IDE&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;With python you can use docplex.cp.utils_visu as can be read in medium article &lt;a href=&quot;https://Gantt%20chart%20visualizations%20with%20python%20and%20OPL%20scheduling%20models&quot; rel=&quot;noreferrer&quot;&gt;Gantt chart visualizations with python and OPL scheduling models&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pPaDT.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pPaDT.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-06-14T14:45:48.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8550" PostTypeId="1" AcceptedAnswerId="8554" CreationDate="2022-06-14T15:10:27.740" Score="7" ViewCount="3069" Body="&lt;p&gt;In many articles that use metaheuristics to solve optimization problems, the programming language of choice is C++. For example, the following two articles present state-of-the-art metaheuristics to solve the Capacitated Vehicle Routing Problem and are implemented in C++: &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.2021.1059?casa_token=qfY8kgSxjT4AAAAA:Jq8ud5gC60Jz0QKbszOv3fGpBhMuuT8wAHY47Fe09-kHXn0OZoFotiP7rlE5oQ-mRJm6X_BT_zLp&quot; rel=&quot;nofollow noreferrer&quot;&gt;Accorsi and Vigo (2021)&lt;/a&gt; and &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S030505482100349X?via%3Dihub&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vidal (2022)&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have yet to find a paper that uses Python to implement a metaheuristic for routing or scheduling problems. As I recently started my PhD in this field and I only have experience with programming in Python, I'm wondering whether it's even acceptable to use Python for my research.&lt;/p&gt;&#xA;&lt;p&gt;Assuming that the algorithmic aspects of my code are efficient (e.g., implementing local search methods in the best-known time complexity, using efficient data structures), would it hurt my chances to publish in top quality journals if I use Python in my research instead of C++ or another compiled language?&lt;/p&gt;&#xA;&lt;p&gt;Although I have not read a lot of literature on exact methods, I believe this issue is less prevalent because most people make use of commercial solvers such as CPLEX and Gurobi. But if my question also applies in this case, please feel free to share your thoughts on this as well.&lt;/p&gt;&#xA;" OwnerUserId="2886" LastEditorUserId="2671" LastEditDate="2022-06-16T07:17:16.750" LastActivityDate="2022-06-16T17:38:14.247" Title="Python vs. compiled languages in OR research using metaheuristics" Tags="|python|metaheuristics|c++|academia|journals|" AnswerCount="4" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="8551" PostTypeId="2" ParentId="8541" CreationDate="2022-06-14T15:24:05.873" Score="2" Body="&lt;p&gt;I would consider using Google Charts: &lt;a href=&quot;https://developers.google.com/chart/interactive/docs/gallery/ganttchart&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/chart/interactive/docs/gallery/ganttchart&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You would have to write a small pipeline that takes your result and plugs it into the JavaScript section of the Chart.&lt;/p&gt;&#xA;&lt;p&gt;I know you said you don't want to write a script yourself, but it may be hard to find a tool that fits on top of your existing implementation (especially if you're using different packages).&lt;/p&gt;&#xA;" OwnerUserId="8918" LastActivityDate="2022-06-14T15:24:05.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8552" PostTypeId="2" ParentId="8546" CreationDate="2022-06-14T15:35:40.347" Score="3" Body="&lt;p&gt;I don't know that anyone can give a meaningful answer. The speedup is definitely a sublinear function of the number of cores or number of threads, and is also problem-specific (and solver-specific).&lt;/p&gt;&#xA;&lt;p&gt;Regarding the new processor, there are a couple of things to keep in mind. One is processor speed. More cores is nice, but if the processor is slower than your current one the net gain will obviously be lower. Another is memory. I'm not a Gurobi user, but I would bet it is similar to CPLEX in this regard. When the solver ropes in a new core/thread, it creates a (partial?) copy of the constraint matrix and related stuff for that thread to use. So your RAM usage goes up, I think more or less linearly, with the number of threads in play. RAM may not be the limiting factor on your current box, but it could become the roadblock on your new box unless the new box boasts a proportionally bigger amount of memory.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-06-14T15:35:40.347" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8553" PostTypeId="2" ParentId="8546" CreationDate="2022-06-14T15:43:30.090" Score="3" Body="&lt;p&gt;“It depends” absolutely is the answer and while I won’t give you any numbers, I might provide a brief insight into on what it could depend:&lt;/p&gt;&#xA;&lt;p&gt;Whereas continuous LPs gain little from more cores (Gurobi runs several barrier algorithms in parallel per default, but for the simplex method, parallelization is a &lt;a href=&quot;https://www.maths.ed.ac.uk/hall/HiGHS/&quot; rel=&quot;nofollow noreferrer&quot;&gt;niche&lt;/a&gt;), MIP algorithms are typically branch-and-bound based. This allows to process parts of the B&amp;amp;B tree in parallel. As visualized very well in &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0167637704000501&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Branching rules revisited&amp;quot; by Achterberg, Koch, Martin in Operations Research Letters, Volume 33, Issue 1&lt;/a&gt;, such B&amp;amp;B trees could be deep and thin or well balanced. The former will be hard to parallelize, while the latter scale quite well.&lt;/p&gt;&#xA;&lt;p&gt;One example: If you branch on a binary variable &lt;span class=&quot;math-container&quot;&gt;$v_1$&lt;/span&gt; you create one branch where &lt;span class=&quot;math-container&quot;&gt;$v_1=0$&lt;/span&gt; is fixed and another where &lt;span class=&quot;math-container&quot;&gt;$v_1=1$&lt;/span&gt; is fixed. Assume that of all the variables &lt;span class=&quot;math-container&quot;&gt;$v_1 ... v_{100000}$&lt;/span&gt; at most/exactly one variable can be 1, all others zero. In this case, the branch where &lt;span class=&quot;math-container&quot;&gt;$v_1=1$&lt;/span&gt; is fixed implicitly also fixes &lt;span class=&quot;math-container&quot;&gt;$v_2 ... v_{100000}$&lt;/span&gt;, which reduced the problem by a lot, so this subtree will be small. On the other hand, &lt;span class=&quot;math-container&quot;&gt;$v_1=0$&lt;/span&gt; does not provide much new information, so you would likely branch on &lt;span class=&quot;math-container&quot;&gt;$v_2$&lt;/span&gt; with the same effect: &lt;span class=&quot;math-container&quot;&gt;$v_2=0$&lt;/span&gt; is almost no news, whereas &lt;span class=&quot;math-container&quot;&gt;$v_2=1$&lt;/span&gt; implicitly fixes all the other variables, so this will be a small subtree again. Thus, situations where only one/few variables from a large set of variables can be set/unset and all other variables have to have the opposite value, you are likely to get a deep and thin tree which is hard to parallelize efficiently.&lt;/p&gt;&#xA;&lt;p&gt;If you want to see some speedup numbers from GuRoBi and other ideas, I'd recommend &lt;a href=&quot;https://cdn.gurobi.com/wp-content/uploads/2020/08/How-to-Exploit-Parallelism-in-Linear-and-Mixed-Integer-Programming.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this presentation&lt;/a&gt; from page 26 on.&lt;/p&gt;&#xA;" OwnerUserId="9763" LastActivityDate="2022-06-14T15:43:30.090" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8554" PostTypeId="2" ParentId="8550" CreationDate="2022-06-14T16:01:54.287" Score="16" Body="&lt;p&gt;Speaking as an occasional reviewer for journals, when I read a paper proposing a new heuristic or metaheuristic my first question is &amp;quot;does it work?&amp;quot;, which is independent of the programming language used. My second question is &amp;quot;does it work better than existing methods?&amp;quot;, which can be interpreted in one of two ways: it gets better results than currently accepted methods in the same amount of time; or it gets comparable results faster. Depending on the underlying type of problem being solved, &amp;quot;accepted methods&amp;quot; might include running a commercial optimization solver in a heuristic way (set a time limit, tweak a few settings and see how good the incumbent solution is).&lt;/p&gt;&#xA;&lt;p&gt;So this ties into the question @PeterD put in his comment. If this is a new, previously unsolved, problem and it does not fit into a category (LP, MILP, ...) for which solvers exist, just producing &amp;quot;reasonable&amp;quot; results in &amp;quot;reasonable&amp;quot; time is grounds for publication. If there are no commonly used heuristics for the problem, getting a solution that is fairly good in a reasonable time may be enough for publication, even if commercial solvers do better, because not everyone can afford commercial solvers. If, say, the problem is frequently solved (by practitioners and/or in the research literature) using the horny snail metaheuristic, than I would expect you as author to demonstrate that your metaheuristic is faster than horny snail, either by running both of them on the same examples using the same hardware or by citing published times for horny snail on publicly available test problems and then beating those times with your heuristic (on hardware comparable to what was used for the published times).&lt;/p&gt;&#xA;&lt;p&gt;Now, can you accomplish any of that in Python. Quite possibly. The published times for other heuristics might have been generated using Python code, or code in languages &amp;quot;slower&amp;quot; than C/C++. There is also the question of coding skill: your &amp;quot;tight&amp;quot; Python code might run faster than someone else's sloppy C++ code. Also, libraries play a role. The bulk of the computing time spent by your heuristic might occur in a Python library, written in C/C++ by someone who worked to optimize their code.&lt;/p&gt;&#xA;&lt;p&gt;If nothing else, you could start by coding in Python and see if your heuristic works (valid results, reasonably close to optimal in reasonable time and memory). If you think it has merit but is not yet publishable, maybe you could bring on a coauthor with C/C++ programming chops (or hire someone to recode it).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-06-14T16:01:54.287" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8556" PostTypeId="1" AcceptedAnswerId="8557" CreationDate="2022-06-14T22:44:39.647" Score="3" ViewCount="159" Body="&lt;p&gt;I am trying to use a binary variable based on an inequality.&#xA;The value of binary variable  &lt;span class=&quot;math-container&quot;&gt;$q $&lt;/span&gt; is 1 or 0 based on the following equation.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;[&#xA;&lt;span class=&quot;math-container&quot;&gt;$q $&lt;/span&gt; =&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{cases}&#xA;0,&amp;amp; \text{if } b  \geq \pi  ,\\&#xA;1,              &amp;amp; \text{otherwise}&#xA;\end{cases}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Here, b and &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; are real numbers. Sample value b = 20 , &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; = 30.&lt;/p&gt;&#xA;&lt;p&gt;I have tried to represent this by:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;q  \geq \dfrac { (\pi  - b )} {M}    &#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;q \leq 1 +  \dfrac { (\pi  - b )} {M}         &#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;By using these two equations I am able to cover the cases for when &lt;span class=&quot;math-container&quot;&gt;$b &amp;gt; \pi $&lt;/span&gt; and when &lt;span class=&quot;math-container&quot;&gt;$b &amp;lt; \pi $&lt;/span&gt;.&#xA;Unfortunately I am unable to set &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; as 0 when &lt;span class=&quot;math-container&quot;&gt;$b=q$&lt;/span&gt; without violating other conditions.&lt;/p&gt;&#xA;" OwnerUserId="9820" LastActivityDate="2022-06-14T23:20:06.750" Title="Disjunctive Constraint , Using Binary Variable to Replace a If or condition" Tags="|modeling|binary-variable|logical-constraints|big-m|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8557" PostTypeId="2" ParentId="8556" CreationDate="2022-06-14T23:20:06.750" Score="2" Body="&lt;p&gt;The usual approach to this requires that &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; be bounded, say &lt;span class=&quot;math-container&quot;&gt;$L \le b \le U$&lt;/span&gt; for some constants &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U.$&lt;/span&gt; You can come close to what you want with the following: &lt;span class=&quot;math-container&quot;&gt;$$b \ge \pi (1-q) + L q$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$b \le \pi q + U (1-q).$$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$b &amp;gt; \pi,$&lt;/span&gt; the second constraint forces &lt;span class=&quot;math-container&quot;&gt;$q=0.$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$b &amp;lt; \pi,$&lt;/span&gt; the first constraint forces &lt;span class=&quot;math-container&quot;&gt;$q=1.$&lt;/span&gt; The tricky part comes when &lt;span class=&quot;math-container&quot;&gt;$b=\pi,$&lt;/span&gt; in which case &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; can be either 0 or 1. Because you cannot enforce a strict inequality in a MIP model, if you can't accept the ambiguity when &lt;span class=&quot;math-container&quot;&gt;$b=\pi$&lt;/span&gt; then you can change the second constraint to &lt;span class=&quot;math-container&quot;&gt;$$b \le (\pi - \epsilon) q + U (1-q),$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; is a small constant. Now &lt;span class=&quot;math-container&quot;&gt;$$b\ge \pi \implies q=0,$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$b \le \pi-\epsilon \implies q = 1,$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\pi - \epsilon &amp;lt; b &amp;lt; \pi$&lt;/span&gt; is forbidden.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-06-14T23:20:06.750" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8558" PostTypeId="1" CreationDate="2022-06-15T04:48:46.263" Score="0" ViewCount="183" Body="&lt;p&gt;Suppose there is a dynamic program that the state of the problem grows over time (more info is added to the state of the problem over time) and at each time, we need all historical data, full history, or all information gathered in a time window. My first question is if this model can be considered a Markov decision process? In an MDP, the state of the current time should be based on the state of the problem in the former time period. Here, this is true but we have gathered all information.&lt;/p&gt;&#xA;&lt;p&gt;My second question is what are the general approaches to solve history-dependent dynamic programs? If we summarize information as a probability distribution, we would lose the exact information and our results will be suboptimal. I would be thankful if you can share some references for discrete and continuous-time problems.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: I asked this question in the following group, but I don't know if it is possible to transfer the question to this group or not.&#xA;&lt;a href=&quot;https://math.stackexchange.com/questions/4270848/how-to-model-history-dependent-dynamic-program&quot;&gt;This link&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="139" LastActivityDate="2022-06-19T16:07:49.843" Title="How to model history-dependent dynamic program?" Tags="|dynamic-programming|markov-decision-process|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8559" PostTypeId="1" CreationDate="2022-06-15T07:22:49.527" Score="3" ViewCount="200" Body="&lt;p&gt;I am thinking about classic problems concerning partitions as the Multiprocessor Scheduling Problem (or Bin Packing or Number Partitioning):&lt;/p&gt;&#xA;&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; tasks, with times &lt;span class=&quot;math-container&quot;&gt;$\{t_i\}_{i\in I_n}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; machines. The goal is to assign each task to a machine such that the maximum time to finish all tasks is minimized. (&lt;span class=&quot;math-container&quot;&gt;$I_n = \{1,2,3,...,n\}$&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;It is possible to build a mathematical model for Multiprocessor Scheduling Problem as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;\min &amp;amp;&amp;amp; \label{b1} T \\&#xA;\mbox{suj. a}  &amp;amp;&amp;amp;  \label{b2} \sum_{i=1}^{n}t_i x_{i,j} \leq T, \quad \forall j\in I_m \\&#xA;&amp;amp;&amp;amp;  \label{b3} \sum_{j=1}^{m} x_{i,j} = 1,  \quad \forall i\in I_n \quad (*)\\&#xA;&amp;amp;&amp;amp;  \label{b4} \sum_{i=1}^{n} x_{i,j} \geq 1, \quad \forall j\in I_m \quad (**)\\&#xA;&amp;amp;&amp;amp;  \label{b5} x_{i,j} \in\{0,1\}, \quad \forall (i,j)\in I_n\times I_m\\&#xA;&amp;amp;&amp;amp;  \label{b6} T \in \mathbb{R}_{+}&#xA;\end{eqnarray}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where the variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; indicates if the task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned in the machine &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, or not. Assume that we change the variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$z_{i,k}$&lt;/span&gt; which means the tasks &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; are both assigned in the same machine (&lt;span class=&quot;math-container&quot;&gt;$z_{i,i}=1$&lt;/span&gt;, task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is alone in a machine). In another words,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$z_{i,k}=\sum_{j=1}^{m} x_{i,j}.x_{k,j}, \quad \forall (i,k): 1\leq i\leq k \leq n$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I know how to ensure the transitivity relationship and calculate the total time in each machine&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$z_{ij} + z_{jk} - z_{ik}\leq 1, \quad \forall (i,j,k): 1\leq i&amp;lt;j&amp;lt;k\leq n$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=k}^{n}t_i z_{i,k} \leq T $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I do not know how to translate (*) and (**). I am thinking about how to do it. Thank you for any tip you share with me.&lt;/p&gt;&#xA;" OwnerUserId="1252" LastEditorUserId="1252" LastEditDate="2022-06-15T19:38:28.143" LastActivityDate="2022-06-15T21:42:20.907" Title="Multiprocessor Scheduling Problem: How to modify some constraints after variable changing?" Tags="|mixed-integer-programming|modeling|integer-programming|binary-variable|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8560" PostTypeId="2" ParentId="8550" CreationDate="2022-06-15T10:45:06.750" Score="7" Body="&lt;p&gt;I think this is a false dichotomy.&lt;/p&gt;&#xA;&lt;p&gt;Surely, C++ is the classical language for fast programs (besides FORTRAN, maybe).&lt;/p&gt;&#xA;&lt;p&gt;But nowadays, Java is very fast as well. Julia is also an option, fast and aimed for scientific programming.&lt;/p&gt;&#xA;&lt;p&gt;So you do not necessarily go down into the depth of memory management in C++, there are alternatives.&lt;/p&gt;&#xA;" OwnerUserId="50" LastEditorUserId="50" LastEditDate="2022-06-16T07:53:06.107" LastActivityDate="2022-06-16T07:53:06.107" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8561" PostTypeId="1" AcceptedAnswerId="8562" CreationDate="2022-06-15T14:49:22.790" Score="3" ViewCount="347" Body="&lt;p&gt;I am new to mathematical programming and I am trying to implement case specific constrains in Gurobi with Python.&lt;/p&gt;&#xA;&lt;p&gt;I am wondering about how I can implement my constraints in the fastest or most common way.&lt;/p&gt;&#xA;&lt;p&gt;There are three variables:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;w_i,w_j \in \mathbb{N},&#xA;y_\text{i,j} \in \{0,1\}&#xA;$$&lt;/span&gt;&#xA;The indices &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; referes to fiction tasks since this model takes part of a task scheduling problem. Variable &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is a weight of the task and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; shows if task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; precedes &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. So there are some other constraints to provide some preceding rules.&lt;/p&gt;&#xA;&lt;p&gt;I need to implement different constraints (let's say &lt;span class=&quot;math-container&quot;&gt;$C_1, C_2, C_3$&lt;/span&gt;) depending to those variables:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;1: (w_i &amp;gt; w_j) \land (y_\text{i,j} \lor y_\text{j,i}) \rightarrow C_1 \\ &#xA;2: (w_i = w_j) \land (y_\text{i,j} \lor y_\text{j,i}) \rightarrow C_2 \\&#xA;3: (w_i &amp;lt; w_j) \land (y_\text{i,j} \lor y_\text{j,i}) \rightarrow C_3  &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To implement this constraint I need introduce new binary variables to the model (let's say &lt;span class=&quot;math-container&quot;&gt;$a_1,a_2,a_3$&lt;/span&gt;) wich are only equal &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, when the refered case is true. Since Gurobi does not implement strict less or greater operators, &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/4414392016529-How-do-I-model-conditional-statements-in-Gurobi-&quot; rel=&quot;nofollow noreferrer&quot;&gt;I need to model a bigM constraints&lt;/a&gt; for the variables &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;w_i \ge w_j + \epsilon - M(1-a_1) \\&#xA;w_i \le w_j + M \times a_1 \\&#xA;a_1 \in {0,1} \\&#xA;\epsilon &amp;lt;&amp;lt; w_i \tag{1}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since there is a constraint that says, that either &lt;span class=&quot;math-container&quot;&gt;$y_\text{i,j}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$y_\text{j,i}$&lt;/span&gt;, but not both, are equal 1, I plan to implement a constraint for each case with a new binary variable &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; to represent the logical condition:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;b_1 = a_1 \times (y_\text{i,j} + y_\text{j,i})&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Finally, I am able to implement each case with an indicator constraint like &lt;span class=&quot;math-container&quot;&gt;$b_x \rightarrow C_x; x\in {1,2,3}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;At first, I am wondering if the second equation of EQ:1 can also expressed with epsilon instead of M as &lt;span class=&quot;math-container&quot;&gt;$w_i \le (w_j - \epsilon) \times a_1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What is the difference?&lt;/p&gt;&#xA;&lt;p&gt;Second, Is this the correct way to implement a problem like this or is there a better way?&lt;/p&gt;&#xA;" OwnerUserId="9830" LastEditorUserId="51" LastEditDate="2022-06-15T15:20:23.857" LastActivityDate="2022-06-15T15:53:08.817" Title="gurobi bigM constraint vs. epsilon" Tags="|mixed-integer-programming|gurobi|logical-constraints|big-m|indicator-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8562" PostTypeId="2" ParentId="8561" CreationDate="2022-06-15T15:53:08.817" Score="1" Body="&lt;p&gt;Changing the second inequality in (1) as proposed would mean that &lt;span class=&quot;math-container&quot;&gt;$w_i \notin (w_j - \epsilon, w_j + \epsilon).$&lt;/span&gt; It would shrink the feasible region in a way that might be detrimental to the solution of the problem.&lt;/p&gt;&#xA;&lt;p&gt;To get the split you want (into three cases), you could employ three binary variables &lt;span class=&quot;math-container&quot;&gt;$z_1,z_2,z_3$&lt;/span&gt; together with the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ w_i \ge w_j + \epsilon - M(z_2 + z_3)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ w_j - Mz_2 \le w_i \le w_j + Mz_2$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ w_i \le w_j - \epsilon +M(z_1 + z_2)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_1 + z_2 + z_3 = 1.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The last equation can be used to eliminate one of the binary variables. (I would leave it to the presolver to decide whether to do that.) The three &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; variables correspond to your cases 1, 2 and 3.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-06-15T15:53:08.817" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8564" PostTypeId="1" AcceptedAnswerId="8566" CreationDate="2022-06-15T19:38:52.553" Score="3" ViewCount="111" Body="&lt;p&gt;This seems intuitive and is likely correct, but I'm looking for a paper or perhaps a more thorough proof on how a K-OPT move is equivalent to a sequence of 2-OPT moves. Or if this is wrong, something that shows why this is wrong with a counter example.&lt;/p&gt;&#xA;&lt;p&gt;For reference, there's a blog post on how a 3-OPT is a sequence of 2-OPT moves &lt;a href=&quot;https://tsp-basics.blogspot.com/2017/03/3-opt-move.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9794" LastActivityDate="2022-06-15T21:50:48.090" Title="Can a TSP K-OPT operator be completed with a sequence of 2-OPT moves?" Tags="|traveling-salesman|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8565" PostTypeId="2" ParentId="8559" CreationDate="2022-06-15T21:42:20.907" Score="3" Body="&lt;p&gt;The condition (*), that every job is assigned to exactly one machine, simply requires &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=k}^n z_{i,k} \ge 1 \quad \forall i=1,\dots,n.$$&lt;/span&gt; That ensures that every job belongs to a cluster. It cannot belong to two clusters, because transitivity would force those two clusters to be the same.&lt;/p&gt;&#xA;&lt;p&gt;The condition (**), that every machine is assigned at least one job, is unnecessary. In the unlikely event that the optimal solution leaves a machine unused, you can manually adjust the solution by taking a job off any machine tied for longest cycle time and parking that job on the idle machine. (There would have to be a tie, else the minimum cycle time would not actually be minimal.)&lt;/p&gt;&#xA;&lt;p&gt;Now the bad news: You need a constraint enforcing the rule that at most &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; clusters of jobs can be constructed. I do not see a way to do that with just the &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; variables. A workaround would be to introduce more binary variables &lt;span class=&quot;math-container&quot;&gt;$y_1,\dots,y_n$&lt;/span&gt; with the constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_{i,k} \le 1-y_i\quad \forall i, \, \forall k &amp;lt; i$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ y_i \le \sum_{k\ge i} z_{i,k} \quad \forall i$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{k &amp;lt; i} z_{i,k} \ge 1- y_i\quad \forall i.$$&lt;/span&gt;&#xA;We interpret &lt;span class=&quot;math-container&quot;&gt;$y_i=1$&lt;/span&gt; to mean that &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the lowest indexed job on whatever machine gets it. If &lt;span class=&quot;math-container&quot;&gt;$y_i=1,$&lt;/span&gt; the first constraint blocks any lower indexed job for being in its cluster, the second constraint forces at either &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; or at least one higher indexed job to be in its cluster, and the third constraint is nonbinding. If &lt;span class=&quot;math-container&quot;&gt;$y_i =0,$&lt;/span&gt; the first two constraints are nonbinding and the third constraint forces at least one lower index job to be in the cluster containing &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Armed with this, you can limit the number of machines used (equal to the number of clusters created) with &lt;span class=&quot;math-container&quot;&gt;$$\sum_i y_i \le m$$&lt;/span&gt; (or force all machines to be used by making it an equality).&lt;/p&gt;&#xA;&lt;p&gt;More (albeit mild) bad news: So far, nothing stops &lt;span class=&quot;math-container&quot;&gt;$z_{1,1} = z_{1,2} = 1$&lt;/span&gt; occurring. So your interpretation of &lt;span class=&quot;math-container&quot;&gt;$z_{i,i}=1$&lt;/span&gt; as task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; being alone on a machine is on somewhat thin ice. Again, this can be fixed manually when editing the solution. The solver has a disincentive to choose a solution like this if it increases the cycle time on a machine tied for maximum cycle time, but on a machine that gets done &amp;quot;early&amp;quot; the solver might pick this.&lt;/p&gt;&#xA;&lt;p&gt;Finally (and perhaps I should have led with this), your calculation of machine cycle time is wrong. You wrote &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=k}^n t_i z_{i,k} \le T,$$&lt;/span&gt;which I assume was meant to apply for all &lt;span class=&quot;math-container&quot;&gt;$k=1,\dots,n.$&lt;/span&gt; Suppose that jobs 1, 2 and 3 (only) are assigned to a machine. When &lt;span class=&quot;math-container&quot;&gt;$k=1$&lt;/span&gt;, the left side becomes &lt;span class=&quot;math-container&quot;&gt;$$t_1 z_{1,1} + t_2 z_{2,1} + t_3 z_{3,1} + \dots = t_2 + t_3,$$&lt;/span&gt; which is less than the actual cycle time by the amount &lt;span class=&quot;math-container&quot;&gt;$t_1.$&lt;/span&gt; For &lt;span class=&quot;math-container&quot;&gt;$k=2$&lt;/span&gt; you get &lt;span class=&quot;math-container&quot;&gt;$$t_2 z_{2,2} + t_3 z_{3,2} + \dots = t_3,$$&lt;/span&gt; which is even further off. For &lt;span class=&quot;math-container&quot;&gt;$k=3$&lt;/span&gt; the left side is zero. If you include the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables and add &lt;span class=&quot;math-container&quot;&gt;$t_k y_k$&lt;/span&gt; to the left side of your constraint and start the summation at &lt;span class=&quot;math-container&quot;&gt;$i=k+1$&lt;/span&gt; (to avoid double-counting if &lt;span class=&quot;math-container&quot;&gt;$y_1=1=z_{i,i}$&lt;/span&gt;), I think it works (but someone should check it).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-06-15T21:42:20.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8566" PostTypeId="2" ParentId="8564" CreationDate="2022-06-15T21:44:41.740" Score="3" Body="&lt;p&gt;If you consider 2-opt moves that (temporarily) result in a worse solution, then it is possible. Lets say you have a route:&lt;/p&gt;&#xA;&lt;p&gt;A → B → E → D → C → F → G → H → A&lt;/p&gt;&#xA;&lt;p&gt;A 2-opt move can be seen as reversal of a part of the tour. For example the 2-opt move that results from removing the link B→E and C→F reverses all stops between B and F.&lt;/p&gt;&#xA;&lt;p&gt;E → D → C  becomes C → D → E and the tour becomes: A → B → C → D → E → F → G → H → A&lt;/p&gt;&#xA;&lt;p&gt;We also know that, if two sequence 1 and 2 consist of the same elements, then there exists a way to transform sequence 1 into sequence 2 by solely reversing orders within sequence 1. This is called the inversion distance and there exist polynomial solutions to it.&#xA;Please checkout the following references for more information on the inversion distance:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Kececioglu, J. and Sankoff, D. (1993). Exact and approximation&#xA;algorithms for the inversion distance between two chromosomes. In&#xA;Proc. of 4th Conference on Combinatorial Pattern Matching (CPM’93)&lt;/p&gt;&#xA;&lt;p&gt;Bergeron, A., Mixtacki, J., &amp;amp; Stoye, J. (2007). The inversion distance&#xA;problem.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="3464" LastEditDate="2022-06-15T21:50:48.090" LastActivityDate="2022-06-15T21:50:48.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8567" PostTypeId="2" ParentId="8550" CreationDate="2022-06-15T22:45:39.103" Score="3" Body="&lt;p&gt;Python has something named the GIL (Global Interpreter Lock) which prevents any kind of shared memory parallelism and even sometimes message based parallelism. In theory, it is possible to serialize objects if they are small but &lt;a href=&quot;https://github.com/Z3Prover/z3/issues/4935&quot; rel=&quot;nofollow noreferrer&quot;&gt;most Python bindings don’t and won’t implement what is required for bringing parallelism capacity&lt;/a&gt;.&lt;br /&gt;&#xA;As a result, many Python programs with huge amount of work to bring serialization support across all dependencies/subdependencies &lt;strong&gt;are finding themselves having to rely on single-thread CPU performance with running during weeks on a specific problem still in 2022&lt;/strong&gt;!&lt;/p&gt;&#xA;&lt;p&gt;And unlike languages like Java, Python uses reference counting instead of garbage collection in a separate thread which adds work in an already single-thread-bound language.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, languages like C++ or Fortran don’t suffer from the warm up time of JIT languages like Java or JavaScript nor the slow execution speed of language like Python or/along the Cythonized version.&lt;/p&gt;&#xA;" OwnerUserId="9836" LastEditorUserId="2671" LastEditDate="2022-06-16T09:06:10.837" LastActivityDate="2022-06-16T09:06:10.837" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8570" PostTypeId="2" ParentId="8550" CreationDate="2022-06-16T17:38:14.247" Score="1" Body="&lt;p&gt;The most convincible way to compare the performance of the different algorithms is by implementing them in the same language and profiling on the same hardware. If one runs Python on mainframe and another C++ on your toaster, the results are largely unpredictable.&lt;/p&gt;&#xA;&lt;p&gt;Obviously you can also use other ways to convince like proving the O(n) complexity of the algorithm.&lt;/p&gt;&#xA;" OwnerUserId="937" LastActivityDate="2022-06-16T17:38:14.247" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8571" PostTypeId="2" ParentId="8558" CreationDate="2022-06-16T18:15:46.530" Score="1" Body="&lt;p&gt;Apart from some &amp;quot;current&amp;quot; values, a state of the state machine can include the history of the previous state changes. Say the state consists of the two booleans, current state and previous state. You can have a function that takes such a state and returns another, also two booleans. One is the new &amp;quot;actual state&amp;quot; and another is the previous &amp;quot;actual state&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;You can then apply all approaches created for the function that takes an integer (0..3 in our case) and returns a similar integer: x &amp;lt;- f(x), simple as that. Having longer history would just mean a larger integer that remains countable.&lt;/p&gt;&#xA;" OwnerUserId="937" LastEditorUserId="937" LastEditDate="2022-06-16T18:21:36.580" LastActivityDate="2022-06-16T18:21:36.580" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8572" PostTypeId="1" CreationDate="2022-06-16T23:05:45.640" Score="1" ViewCount="255" Body="&lt;p&gt;I try to convert a quadratic constraint to a linear one:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;w_j = \sum w_\text{j,i} \\&#xA;w_\text{j,i} = \frac{w_j}{D} \times u \\&#xA;w_j,D,u \in \mathbb{N} \\&#xA;$$&lt;/span&gt;&#xA;The values for &lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; are constant and does not change.&lt;br /&gt;&#xA;In fact, I try to divide the value of &lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt; to pieces, defined by &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;. For example: &lt;span class=&quot;math-container&quot;&gt;$D = 4$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_j = 100$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$w_\text{j,0},w_\text{j,1} \in {0,25,50,100}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;At first: Is there a way to express such a case with linear constraints?&lt;br /&gt;&#xA;At second: Is there a rule how to convert quadratic to linear constraints?&lt;/p&gt;&#xA;" OwnerUserId="9830" LastActivityDate="2022-06-16T23:05:45.640" Title="Converting quadratic constrains to linear constraint" Tags="|mixed-integer-programming|linear-programming|linearization|quadratic-programming|" AnswerCount="0" CommentCount="4" ClosedDate="2022-06-28T15:01:17.010" ContentLicense="CC BY-SA 4.0" />
  <row Id="8573" PostTypeId="1" AcceptedAnswerId="8575" CreationDate="2022-06-17T09:29:47.397" Score="4" ViewCount="649" Body="&lt;p&gt;The simple test problem I'm trying to implement is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  \min &amp;amp;\quad c_{ij}x_{ij} \\&#xA;  \text{s.t} &amp;amp;\quad \\&#xA;  &amp;amp;\quad \sum_{j\in N}x_{ij} = 1, \quad i\in N\\&#xA;  &amp;amp;\quad \sum_{i\in N}x_{ij} = 1, \quad j\in N\\&#xA;  &amp;amp;\quad x_{ii} = 0, \quad i\in N\\&#xA;  &amp;amp;\quad \sum_{i\in S}\sum_{j\in S, \ j\neq i} x_{ij} \leq |S|-1, \quad \forall S \subset N, 2\leq |S| \leq  n-1 \\&#xA;  &amp;amp; \quad x_{ij}\in\{0,1\}, \quad i,j\in{N}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$N={1,...,n}$&lt;/span&gt; is number of locations and &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is the set of sub-tours. I have the following locations with their coordinates and the corresponding distance matrix for each pair of locations named &lt;code&gt;locations_df&lt;/code&gt; and &lt;code&gt;dist_mat&lt;/code&gt; respectively.&lt;/p&gt;&#xA;&lt;p&gt;I've followed &lt;a href=&quot;https://medium.com/swlh/techniques-for-subtour-elimination-in-traveling-salesman-problem-theory-and-implementation-in-71942e0baf0c&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt; (&lt;a href=&quot;https://github.com/Ayaush/TSP-ILP/blob/main/Subtour%20elimination%20in%20TSP.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;github-link&lt;/a&gt;) and I managed to correctly implement the MTZ version, however I'm running into troubles when trying to implement the DFJ method of sub-tour elimination. More specifically, the while loop (NOT any of the while loops in the function &lt;code&gt;get_plan&lt;/code&gt; but further below, the last one) below never exits and I can't figure out why the size of sub-tour list never goes to 1 in order to exit the while loop. I've spent quite a lot of time trying to debug this and I'd appreciate any help.&lt;/p&gt;&#xA;&lt;p&gt;The code below should be completely reproducible, just copy and paste. Note that &lt;code&gt;pip install pulp&lt;/code&gt; is required.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pulp&#xA;import pandas as pd&#xA;import numpy as np&#xA;import copy&#xA;&#xA;location_df = pd.DataFrame({'Location': ['Depot','LL716','LL384','LR59','LL701','LL866','LR830','LL1034','LR80','LR220','LL804'], &#xA;                      'x': [0.00,140.21,76.48,6.37,133.84,172.07,159.33,203.94,12.75,38.24,159.33], &#xA;                      'y': [0.00,30.62,0.00,68.90,74.00,5.10,76.55,25.52,40.83,71.45,10.21]}) &#xA;&#xA;N = len(location_df)&#xA;&#xA;dist_mat = np.array([[  0.  , 170.83,  76.48,  75.27, 207.84, 177.17, 235.88, 229.46,&#xA;         53.58, 109.69, 169.54],&#xA;       [170.83,   0.  ,  94.35, 172.12,  49.75,  67.58,  65.05,  86.69,&#xA;        137.67, 142.8 ,  57.39],&#xA;       [ 76.48,  94.35,   0.  , 139.01, 131.36, 100.69, 159.4 , 152.98,&#xA;        104.56, 109.69,  93.06],&#xA;       [ 75.27, 172.12, 139.01,   0.  , 147.72, 229.5 , 170.66, 240.95,&#xA;         37.01,  54.67, 211.65],&#xA;       [207.84,  49.75, 131.36, 147.72,   0.  , 107.13,  38.09, 118.58,&#xA;        156.82, 113.3 ,  89.28],&#xA;       [177.17,  67.58, 100.69, 229.5 , 107.13,   0.  ,  84.19,  62.49,&#xA;        195.05, 200.18,  28.05],&#xA;       [235.88,  65.05, 159.4 , 170.66,  38.09,  84.19,   0.  ,  95.64,&#xA;        184.86, 136.24,  66.34],&#xA;       [229.46,  86.69, 152.98, 240.95, 118.58,  62.49,  95.64,   0.  ,&#xA;        206.5 , 211.63,  80.34],&#xA;       [ 53.58, 137.67, 104.56,  37.01, 156.82, 195.05, 184.86, 206.5 ,&#xA;          0.  ,  58.67, 177.2 ],&#xA;       [109.69, 142.8 , 109.69,  54.67, 113.3 , 200.18, 136.24, 211.63,&#xA;         58.67,   0.  , 182.33],&#xA;       [169.54,  57.39,  93.06, 211.65,  89.28,  28.05,  66.34,  80.34,&#xA;        177.2 , 182.33,   0.  ]])&#xA;&#xA;##################### Solve model using the DFJ subtour elimination&#xA;&#xA;# find all sub-tours in the solution&#xA;def get_plan(r0):&#xA;  r = copy.copy(r0)&#xA;  route = []&#xA;  while len(r) != 0:&#xA;    plan = [r[0]]&#xA;    del (r[0])&#xA;    l = 0&#xA;    while len(plan) &amp;gt; l:&#xA;      l = len(plan)&#xA;      for i, j in enumerate(r):&#xA;        if plan[-1][1] == j[0]:&#xA;          plan.append(j)&#xA;          del (r[i])&#xA;      route.append(plan)&#xA;  return(route)&#xA;&#xA;model = pulp.LpProblem('tspDFJ',pulp.LpMinimize)&#xA;#define variable&#xA;x = pulp.LpVariable.dicts(&amp;quot;x&amp;quot;,((i,j) for i in range(N) \&#xA;                                     for j in range(N)), \&#xA;                                     cat='Binary')&#xA;&#xA;#set objective&#xA;model += pulp.lpSum(dist_mat[i][j] * x[i,j] for i in range(N) \&#xA;                                            for j in range(N))&#xA;# st constraints&#xA;for i in range(len(location_df)):&#xA;    model += x[i,i] == 0&#xA;    model += pulp.lpSum(x[i,j] for j in range(N)) == 1&#xA;    model += pulp.lpSum(x[j,i] for j in range(N)) == 1&#xA;    &#xA;status = model.solve()&#xA;&#xA;route = [(i,j) for i in range(N) \&#xA;               for j in range(N) if pulp.value(x[i,j]) == 1]&#xA;&#xA;S = get_plan(route)&#xA;subtour = []&#xA;&#xA;#Check if we got subtours, if we do, we &#xA;&#xA;while len(S) != 1:&#xA;  for i in range(len(S)):&#xA;    #print(S[i])&#xA;    model += pulp.lpSum(x[S[i][j][0], S[i][j][1]] \&#xA;                          for j in range(len(S[i])) if j!=i) &amp;lt;= len(S[i]) - 1&#xA;&#xA;  status = model.solve()&#xA;  route = [(i,j) for i in range(N) \&#xA;                 for j in range(N) if pulp.value(x[i,j]) == 1]&#xA;                   &#xA;  S = get_plan(route)&#xA;  subtour.append(len(S))&#xA;&#xA;print(&amp;quot;-----------------&amp;quot;)&#xA;print(status,pulp.LpStatus[status],pulp.value(model.objective))&#xA;print(S)&#xA;print(&amp;quot;no. of times LP model is solved = &amp;quot;, len(subtour))&#xA;print(&amp;quot;subtour log (no. of subtours in each solution))&amp;quot;, subtour)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4222" LastEditorUserId="4222" LastEditDate="2022-06-17T09:35:51.327" LastActivityDate="2022-06-17T15:26:32.383" Title="Subtour elimination implementation (DFJ) using Python (PULP). While loop never exits" Tags="|python|pulp|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8574" PostTypeId="1" AcceptedAnswerId="8577" CreationDate="2022-06-17T09:32:22.537" Score="3" ViewCount="90" Body="&lt;p&gt;I am interested in an optimization problem of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{\boldsymbol z} \max_j \vert f_j(\boldsymbol z) \vert = \min_{\boldsymbol z} \Vert f_j(\boldsymbol z) \Vert_\infty. $$&lt;/span&gt;&#xA;Here, the optimization/decision variables are &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol z \in \mathbb C^{N} $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_i: \mathbb C^N \to \mathbb C$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$f_j$&lt;/span&gt; are essentially polynomials in &lt;span class=&quot;math-container&quot;&gt;$\lambda_j \in \mathbb C$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$f_j(\boldsymbol z ) = \prod_{k=1}^N \big(1 - z_k \lambda_j\big).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To provide some more context, I am essentially trying to optimize the common roots of complex polynomials. Write the polynomial &lt;span class=&quot;math-container&quot;&gt;$p(\lambda) $&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$p(0) = 1$&lt;/span&gt; as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$p(\lambda) = \prod_{k=1}^N \bigg(1 - \frac{ \lambda}{\tilde z_k} \bigg)$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\tilde z_k$&lt;/span&gt; are the roots of the polynomial. For &lt;span class=&quot;math-container&quot;&gt;$z_k := 1/\tilde z_k$&lt;/span&gt; you obtain the representation above.&lt;/p&gt;&#xA;&lt;p&gt;In principle, one has also to enforce that the roots come in complex-conjugated pairs which would give a linear constraint like&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A \boldsymbol z = \boldsymbol 0.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9847" LastEditorUserId="9847" LastEditDate="2022-06-18T12:14:10.663" LastActivityDate="2022-06-18T17:12:37.953" Title="Optimization software for real-valued functions/constraints of complex arguments" Tags="|optimization|complex-numbers|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8575" PostTypeId="2" ParentId="8573" CreationDate="2022-06-17T15:26:32.383" Score="4" Body="&lt;ol&gt;&#xA;&lt;li&gt;In constraint&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;while len(S) != 1:&#xA;  for i in range(len(S)):&#xA;    #print(S[i])&#xA;    model += pulp.lpSum(x[S[i][j][0], S[i][j][1]] \&#xA;                          for j in range(len(S[i])) if j!=i) &amp;lt;= len(S[i]) - 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;if j!=i&lt;/code&gt; doesn't make sense since &lt;code&gt;i&lt;/code&gt; is the index of the subtour, and not an index of a vertex&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Multiple identical subtour are computed in the &lt;code&gt;get_plan&lt;/code&gt; function. Replace&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;      route.append(plan)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;by&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;      if plan not in route:&#xA;          route.append(plan)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-06-17T15:26:32.383" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8577" PostTypeId="2" ParentId="8574" CreationDate="2022-06-18T17:12:37.953" Score="1" Body="&lt;p&gt;I sat down and worked a bit on this. Since I am only interested in the magnitude of the polynomial it might be helpful to employ the polar representation, i.e., &lt;span class=&quot;math-container&quot;&gt;$1 - z_j \lambda = r_j e^{i\phi_j}$&lt;/span&gt;.&#xA;Then,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\left \vert \prod_{j=1}^N 1 - z_j \lambda \right\vert  = \left \vert \prod_{j=1}^N r_j e^{i\phi_j}\right\vert = \left \vert \left(\prod_{j=1}^N r_j \right) \cdot \exp \left( \sum_{j=1}^N i\phi_j\right)\right\vert \\&#xA;=&amp;amp;\left \vert \left(\prod_{j=1}^N r_j \right) \right \vert \cdot  \left \vert \exp \left( \sum_{j=1}^N i\phi_j\right)\right\vert = \left \vert \left(\prod_{j=1}^N r_j \right) \right \vert \cdot 1= \prod_{j=1}^N r_j&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now let's take a closer look on the &lt;span class=&quot;math-container&quot;&gt;$r_j$&lt;/span&gt;. Write &lt;span class=&quot;math-container&quot;&gt;$z_j = a_j + b_j i $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\lambda = c+d i$&lt;/span&gt;.&#xA;Then, &lt;span class=&quot;math-container&quot;&gt;$$r_j = \sqrt{\big[1 - \text{Re} (z_j \lambda)\big]^2 + \text{Im}^2 (z_j \lambda)}$$&lt;/span&gt;&#xA;Note that &lt;span class=&quot;math-container&quot;&gt;$$\text{Re} (z_j \lambda) = a_jc -b_jd, \text{Im} (z_j \lambda) = a_jd + b_j c $$&lt;/span&gt;&#xA;one obtains a formulation with no complex variables involved at all! The optimization is now over &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol a, \boldsymbol b$&lt;/span&gt;. While the problem is of course highly nonlinear and most likely very complicated, my main concern could be lifted.&lt;/p&gt;&#xA;" OwnerUserId="9847" LastActivityDate="2022-06-18T17:12:37.953" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8578" PostTypeId="1" CreationDate="2022-06-19T11:46:32.863" Score="2" ViewCount="134" Body="&lt;p&gt;I have a complicated non-linear objective function of positive integer variables subject to linear constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathop {Min}\limits_{\underline x} f(\underline x)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A\underline x\leq \underline b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\underline x \in \mathbb{Z}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\underline x \geq 0$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$f(\underline x)=g(\underline x)+h(\underline x)+p(\underline x)+q(\underline x)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For the small version of the problem where A is 17×48, &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is defined as follows.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{Ca1}&#xA;C_a^1=\frac{1}{\frac{1}{\sum_{i=1}^{4} x_{i}C_i+(3-\sum_{i=1}^{4} x_{i})C_5}+\frac{1}{\sum_{i=5}^{8} x_{i}C_i+(3-\sum_{i=5}^{8} x_{i})C_5}}&#xA; \end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{Ca2}&#xA;C_a^2=\frac{1}{\frac{1}{\sum_{i=9}^{12} x_{i}C_i+(3-\sum_{i=9}^{12} x_{i})C_5}+\frac{1}{\sum_{i=13}^{16} x_{i}C_i+(3-\sum_{i=13}^{16} x_{i})C_5}}&#xA; \end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{Cb1}&#xA;C_b^1=\frac{1}{\frac{1}{\sum_{i=17}^{20} x_{i}C_i+(3-\sum_{i=17}^{20} x_{i})C_5}+\frac{1}{\sum_{i=21}^{24} x_{i}C_i+(3-\sum_{i=21}^{24} x_{i})C_5}}&#xA; \end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{Cb2}&#xA;C_b^2=\frac{1}{\frac{1}{\sum_{i=25}^{28} x_{i}C_i+(3-\sum_{i=25}^{28} x_{i})C_5}+\frac{1}{\sum_{i=29}^{32} x_{i}C_i+(3-\sum_{i=29}^{32} x_{i})C_5}}&#xA; \end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{Cc1}&#xA;C_c^1=\frac{1}{\frac{1}{\sum_{i=33}^{36} x_{i}C_i+(3-\sum_{i=33}^{36} x_{i})C_5}+\frac{1}{\sum_{i=37}^{40} x_{i}C_i+(3-\sum_{i=37}^{40} x_{i})C_5}}&#xA; \end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{Cc2}&#xA;C_c^2=\frac{1}{\frac{1}{\sum_{i=41}^{44} x_{i}C_i+(3-\sum_{i=41}^{44} x_{i})C_5}+\frac{1}{\sum_{i=45}^{48} x_{i}C_i+(3-\sum_{i=45}^{48} x_{i})C_5}}&#xA; \end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{Ca}&#xA;C_a=C_a^1+C_a^2&#xA; \end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{Cb}&#xA;C_b=C_b^1+C_b^2&#xA; \end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{Cc}&#xA;C_c=C_c^1+C_c^2&#xA; \end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{g}&#xA;g(\underline{x})=(C_a+C_b+C_c)\sqrt{[C_a-\frac{1}{2}(C_b+C_c)]^2+(C_b-Cc)^2}&#xA; \end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$C_1$&lt;/span&gt;...&lt;span class=&quot;math-container&quot;&gt;$C_{48}$&lt;/span&gt; are constant and known. &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; are as complicated.&lt;/p&gt;&#xA;&lt;p&gt;In Matlab,each of &lt;span class=&quot;math-container&quot;&gt;$g,h,p,q$&lt;/span&gt; is defined by a function which employs various other functions which contain many loops for different elements of &lt;span class=&quot;math-container&quot;&gt;$\underline x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Size of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is in the order of 100 &lt;span class=&quot;math-container&quot;&gt;$\times$&lt;/span&gt; 2000. I tried first to solve the problem in Matlab, using the &lt;em&gt;ga&lt;/em&gt; function. Unfortunately, the solutions obtained for several runs never satisfied the constraints.&lt;/p&gt;&#xA;&lt;p&gt;I have successfully implemented an algorithm in Matlab where in each iteration a random solution that satisfies the constraints is generated and &lt;span class=&quot;math-container&quot;&gt;$f(\underline x)$&lt;/span&gt; is evaluated using multiple functions defined. Using a large number of iterations, say 1e6, I could find a reasonable yet not a globally optimal solution.&#xA;My next plan was to use the CPLEX solution pool. For small &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, it was possible to have all the solutions of inequality &lt;span class=&quot;math-container&quot;&gt;$A\underline x\leq \underline b$&lt;/span&gt;, import these solutions as a CSV file in Matlab and evaluate them one by one so that the least objective function gives the globally optimal solution. This, however, does not work for actual &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; which make the CPLEX out of memory. My idea was to use an incumbent filter so that non-optimal solutions of &lt;span class=&quot;math-container&quot;&gt;$A\underline x\leq \underline b$&lt;/span&gt; get discarded and therefore the memory problem gets resolved. For example the solutions for which &lt;span class=&quot;math-container&quot;&gt;$f(\underline x)&amp;gt;c$&lt;/span&gt;, where constant &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is heuristically defined, can be discarded.&#xA;My question is:Is there a way to define my complicated objective function in GAMS environment the way I did in Matlab? Have you faced a similar situation which can be referred to so that I have a clue?&lt;/p&gt;&#xA;" OwnerUserId="9857" LastEditorUserId="491" LastEditDate="2022-06-20T14:38:39.413" LastActivityDate="2022-06-20T14:38:39.413" Title="Defining a highly non-linear function of integer variables" Tags="|cplex|gams|matlab|minlp|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8579" PostTypeId="1" AcceptedAnswerId="8580" CreationDate="2022-06-19T20:42:57.290" Score="3" ViewCount="279" Body="&lt;p&gt;Mixed Integer Conic Programs is a family of Mixed Integer Programs which are convex in all non integer variables. I am giving presentation on Mixed Integer technology. A large part of the presentation will be about MILP, it's tricks and common problem structures. I will also make people aware of MINLP by giving a practical non-convex MINLP. I aim to do the same with a convex MINLP. Is someone aware of an easy to explain[1] MIP using a Second-order, Rotated second-order, Positive semidefinite or Primal exponential which has a practical application?&lt;/p&gt;&#xA;&lt;p&gt;[1] It should not involve power networks, trajectory optimisation and ideally fit on a slide. Why the cone is needed should be obvious from the problem description.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-06-19T22:49:31.880" Title="Practical, Short example of Mixed Integer Conic Program" Tags="|mixed-integer-programming|cone|teaching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8580" PostTypeId="2" ParentId="8579" CreationDate="2022-06-19T21:54:23.833" Score="9" Body="&lt;p&gt;Your opening sentence could be more accurately written as&#xA;Mixed Integer Conic Programs are a family of Mixed Integer Programs whose continuous relaxations are (convex) conic programs.&lt;/p&gt;&#xA;&lt;p&gt;One easy to understand example is best variable subset selection by Mixed-Integer Least Squares, as presented in &lt;a href=&quot;https://projecteuclid.org/journals/annals-of-statistics/volume-44/issue-2/Best-subset-selection-via-a-modern-optimization-lens/10.1214/15-AOS1388.pdf&quot; rel=&quot;noreferrer&quot;&gt;BEST SUBSET SELECTION VIA A MODERN OPTIMIZATION LENS, D IMITRIS B ERTSIMAS, ANGELA K ING AND R AHUL M AZUMDER,The Annals of Statistics, 2016, Vol. 44, No. 2, 813–852&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/mio.html#mixed-integer-conic-case-studies&quot; rel=&quot;noreferrer&quot;&gt;Mosek Modeling Cookbook version 3.2.3 Section 9.2 Mixed integer conic case studies&lt;/a&gt; has examples&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Wireless network design&lt;/li&gt;&#xA;&lt;li&gt;Portfolio optimization subject to transaction costs, cardinality constraints, and/or trading size constraints&lt;/li&gt;&#xA;&lt;li&gt;Convex piecewise linear regression&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://yalmip.github.io/example/modellingif/&quot; rel=&quot;noreferrer&quot;&gt;YALMIP wiki&lt;/a&gt; has an example of nonconvex regression arising from non-convex penalty function, which is handled as MISOCP.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://docs.mosek.com/generic/workshop/2018/mixed-int-conic/gally.pdf&quot; rel=&quot;noreferrer&quot;&gt;Applications and Solution Approaches for Mixed-Integer Semidefinite Programming,&#xA;Tristan Gally, joint work with Marc E. Pfetsch and Stefan Ulbrich&lt;/a&gt; has MISDP examples for&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Max-Cut (very cleverly, the non-convex rank constraint for the SDP can be relaxed (omitted) with no effect on optimal solution because every integer solution satisfies the omitted rank constraint; therefore the non-convexity has been moved from the rank constraint entirely to the integer (binary) constraints)&lt;/li&gt;&#xA;&lt;li&gt;Compressed Sensing&lt;/li&gt;&#xA;&lt;li&gt;Truss Topology Design.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Section 9.2 of &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/papers/pdf/gp_tutorial.pdf&quot; rel=&quot;noreferrer&quot;&gt;A Tutorial on Geometric Programming, S. Boyd, S.-J. Kim, L. Vandenberghe, and A. Hassibi&lt;/a&gt; has a Mixed-Integer Geometric Programming example for Digital Circuit Gate Scaling in which the scale factors must take integer values. So this would be a Mixed-Integer Exponential Cone problem.&lt;/p&gt;&#xA;&lt;p&gt;You may also find the video, &lt;a href=&quot;https://www.youtube.com/watch?v=v_ZF1Tr5Rc4&quot; rel=&quot;noreferrer&quot;&gt;The conic advantage in MINLP, Henrik A. Friberg:&lt;/a&gt; to be of interest.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-06-19T22:49:31.880" LastActivityDate="2022-06-19T22:49:31.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8581" PostTypeId="1" CreationDate="2022-06-20T13:28:11.050" Score="-3" ViewCount="88" Body="&lt;p&gt;As the title suggests, I would like to test different values of parameters with the same code in C++.&lt;/p&gt;&#xA;&lt;p&gt;For example, one of the parameters is: &lt;code&gt;#define α 0.5&lt;/code&gt;. I would like to run the same code, but with different values of &lt;code&gt;α&lt;/code&gt;, like &lt;code&gt;#define α 0.6&lt;/code&gt;. How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="9746" LastEditorUserId="123" LastEditDate="2022-06-22T12:21:16.520" LastActivityDate="2022-06-22T12:21:16.520" Title="Testing Varying Parameters With the Same Script" Tags="|c++|" AnswerCount="1" CommentCount="0" ClosedDate="2022-06-22T12:22:15.313" ContentLicense="CC BY-SA 4.0" />
  <row Id="8582" PostTypeId="2" ParentId="8581" CreationDate="2022-06-20T15:51:55.347" Score="2" Body="&lt;p&gt;I'm not sure this belongs in this forum, but I am assunming these are some parameters of an optimisation function or something similar.&lt;/p&gt;&#xA;&lt;p&gt;Preprocessor directives are an unfavourable way of defining parameters in your case, I would say. Why? Because C++ takes all the instances of &lt;code&gt;α&lt;/code&gt; in your &lt;em&gt;code&lt;/em&gt; and replaces them with &lt;code&gt;0.5&lt;/code&gt;. Note, the replacement is done in the code, and not the memory.&lt;/p&gt;&#xA;&lt;p&gt;Now, you would like to run an additional layer of replacements on top of this (that changes the values of the macro in every execution), which according to me is not an option.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;: Instead of using macros, declare your parameter as a global variable. Take the value of this parameter as a command line argument. See &lt;a href=&quot;https://www.geeksforgeeks.org/command-line-arguments-in-c-cpp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; tutorial.&lt;/p&gt;&#xA;&lt;p&gt;Then, write a bash script (maybe &lt;a href=&quot;https://stackoverflow.com/questions/59768931/bash-script-to-compile-and-run-c-program&quot;&gt;this&lt;/a&gt; question helps) that builds and runs your code with the commmand line argument in a loop (or however you like), but changes the command line argument in each execution. See &lt;a href=&quot;https://linuxconfig.org/bash-scripting-tutorial&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; tutorial for help with bash scripting.&lt;/p&gt;&#xA;" OwnerUserId="8918" LastActivityDate="2022-06-20T15:51:55.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8584" PostTypeId="1" CreationDate="2022-06-21T19:34:19.330" Score="2" ViewCount="127" Body="&lt;p&gt;I have a multi-stage stochastic programming model. I have 3 groups of variables: the first group takes values at the beginning of the planning horizon before the first realization and does not change until the end of the planning horizon and has no t index (they are binary and continuous), the second option is “here and now” variables that before each realization Are taken value and are continuous, the third group are “wait and see” variables that take value after each realization (binary and continuous). The model is SMINLP. I converted it to SMILP through linearization and solved it by CPLEX solver with generating a small number of scenarios . I want to consider a continuous distribution for the stochastic parameter and generate a large number of scenarios by sampling and run an algorithm for it. nested benders decomposition  or progressive hedging algorithms are more efficient for this model?&#xA;If anyone has experience, thank you in advance for your help.&lt;/p&gt;&#xA;" OwnerUserId="9865" LastActivityDate="2022-06-22T09:15:18.513" Title="multi stage stochastic programming algorithm" Tags="|stochastic-programming|benders-decomposition|approximation-algorithms|lagrangian-decomposition|multi-stage|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8585" PostTypeId="2" ParentId="8584" CreationDate="2022-06-22T09:15:18.513" Score="3" Body="&lt;p&gt;If your question is “Are nested Benders decomposition or progressive hedging more efficient than solving a very large-scale monolithic formulation (sometimes called ‘deterministic equivalent’) with CPLEX?”, the answer is very likely a clear “Yes, if you get the implementation right”.&lt;/p&gt;&#xA;&lt;p&gt;If the question is “Is nested Benders decomposition or progressive hedging more efficient to solve a large stochastic program?”, i.e., you want to decide between the two, the answer is unclear to me, but likely a lot more intricate and intuitively I would expect the answer to be “If you want to be really sure you’d have to try both with your model.” I am not too familiar with PHA, so take my intuition with a grain of salt.&lt;/p&gt;&#xA;&lt;p&gt;A couple of general remarks:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Decomposition algorithms have demonstrated their ability to solve large-scale problem instances that could not be solved as monolithic formulations. That does not mean they can solve arbitrarily large problems! In fact, by just starting to model from scratch it is still very easy to come up with a formulation that is too large to be solved with all the techniques we have available today. I would recommend to gradually increase the problem size (in your case by increasing the number of samples gradually) until you hit the boundary of what CPLEX can solve as monolithic formulation. Then, decomposition algorithms will provide you with a juicy speedup, allowing you to gradually increase the number of samples further, until also decomposition algorithms are pushed to their limits.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As far as I understand, progressive hedging algorithms copy also the non-scenario specific variables for each scenario, i.e., instead of just one variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, the algorithm works with &lt;span class=&quot;math-container&quot;&gt;$x_s, \forall s \in \{ S \}$&lt;/span&gt; and penalizes non-implementability, so the violation of &lt;span class=&quot;math-container&quot;&gt;$x_s = x_{s’} \forall s \neq s’$&lt;/span&gt;. If you have many such variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, copying them all for all scenarios may blow up the problem size even more, whereas BD does not need these copies.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;BD is notoriously hard to implement in practise, as Steve Maher wrote about on his blog which occurs to be offline. Another resource I can recommend for its accessibility is &lt;a href=&quot;https://arthur.maheo.net/archive/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arthur Maheos blog&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Hope this helps!&lt;/p&gt;&#xA;" OwnerUserId="9763" LastActivityDate="2022-06-22T09:15:18.513" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8586" PostTypeId="1" CreationDate="2022-06-22T10:42:55.147" Score="2" ViewCount="217" Body="&lt;p&gt;I have a facility location problem with a non-linear objective;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There are fixed costs &lt;span class=&quot;math-container&quot;&gt;$S_j$&lt;/span&gt; to opening facility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Y_j$&lt;/span&gt; is a binary, &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if facility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is opened, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$D_j$&lt;/span&gt; is the number of products that will be gathered at facility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;It is cheaper to assign more products to an open facility as fixed costs can be spread. Therefore, there is a negative slope of &lt;span class=&quot;math-container&quot;&gt;$-a\cdot D_j$&lt;/span&gt; when a facility is open. Indicating that when more products are assigned to an open collection point, this will be deducted from the fixed cost.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This gives the objective function &lt;span class=&quot;math-container&quot;&gt;$$S_j \cdot Y_j - a \cdot D_j \cdot Y_j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How do I linearize this to create a linear programming problem?&lt;/p&gt;&#xA;" OwnerUserId="9867" LastEditorUserId="123" LastEditDate="2022-06-22T12:19:58.873" LastActivityDate="2022-06-22T12:19:58.873" Title="Linearize function" Tags="|optimization|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8587" PostTypeId="2" ParentId="8586" CreationDate="2022-06-22T11:46:01.347" Score="5" Body="&lt;p&gt;One approach is to perform the usual linearization of a product of a bounded variable and a binary variable, by introducing a new variable to represent the product, along with additional linear constraints to enforce the desired relationships.  A simpler approach is to replace &lt;span class=&quot;math-container&quot;&gt;$S_j Y_j - a D_j Y_j$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$S_j Y_j - a D_j$&lt;/span&gt; and enforce the logical implication &lt;span class=&quot;math-container&quot;&gt;$D_j &amp;gt; 0 \implies Y_j = 1$&lt;/span&gt;.  Equivalently, you can enforce the contrapositive &lt;span class=&quot;math-container&quot;&gt;$$Y_j = 0 \implies D_j = 0$$&lt;/span&gt; either directly as an indicator constraint or indirectly via linear big-M constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$D_j \le M_j Y_j,$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M_j$&lt;/span&gt; is a (small) upper bound on &lt;span class=&quot;math-container&quot;&gt;$D_j$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$Y_j = 1$&lt;/span&gt;.  For example, you can take &lt;span class=&quot;math-container&quot;&gt;$M_j$&lt;/span&gt; to be the total number of products.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-06-22T11:46:01.347" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8588" PostTypeId="1" CreationDate="2022-06-22T15:56:35.473" Score="2" ViewCount="71" Body="&lt;p&gt;I created the following constraint (missing what exists in this context means)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;For all a in A there exists a b in B so that for all c in C it holds &#xA;that a variable x(a, b + c) is equal to a parameter m(a, c)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;short:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\forall a \in A, \exists b \in B, \forall c \in C: x(a,b+c)=m(a,c)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What this constraint is trying to do is to ensure that for a given object &lt;code&gt;a&lt;/code&gt; the values of a given tuple &lt;code&gt;m(a,c)&lt;/code&gt; (both binary tuples) can be found in the same order. Of course that would mean that only &lt;code&gt;|B|-1&lt;/code&gt; constraints have to be true which is a problem (that I did not notice before). Can this be reformulated without the &lt;code&gt;exists&lt;/code&gt; clause?&lt;/p&gt;&#xA;&lt;p&gt;Therefore, &lt;code&gt;m(a,c)&lt;/code&gt; is the given parameter of a smaller tuple for some object &lt;code&gt;a&lt;/code&gt;. The constraint ensures that x for an object &lt;code&gt;a&lt;/code&gt; starting at some position &lt;code&gt;b&lt;/code&gt; contains the values of m(a,c) in the order of &lt;code&gt;m(a,c)&lt;/code&gt;. The tuples &lt;code&gt;m(a,c)&lt;/code&gt; all have different sizes.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, with this and additional constraints I tried to solve a knapsack problem in which a set of different tuple have to be placed within a larger tuple. The tuple contains binary values representing &lt;code&gt;1&lt;/code&gt; the position is used &lt;code&gt;0&lt;/code&gt; the position is unused.&#xA;Hence, if a position is not used (0) a different tuple can use it if it doesn't gets in conflict with the other assignments:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\forall b\in B: \sum_{a\in A} x(a,b)\leq 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;it doesn't matter whether for a object &lt;code&gt;a&lt;/code&gt; in x positions &lt;code&gt;b&lt;/code&gt; are marked as used even so they are not. It only matters to find whether for a tuple of a certain size the other tuples can be somehow fitted into.&lt;/p&gt;&#xA;&lt;p&gt;Can the first constraint somehow reformulated to be linear? If not, what is the best I could do?&lt;/p&gt;&#xA;" OwnerUserId="2989" LastEditorUserId="2989" LastEditDate="2022-06-22T16:06:53.600" LastActivityDate="2022-06-22T16:06:53.600" Title="Reformulating a constraint that is non linear?" Tags="|linear-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8589" PostTypeId="2" ParentId="4581" CreationDate="2022-06-22T17:58:41.837" Score="1" Body="&lt;p&gt;You can try the following code snippets to get the statistics just like Gurobi.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang- prettyprint-override&quot;&gt;&lt;code&gt;def get_model_stats(solver):&#xA;    cpx = solver.get_engine().get_cplex()&#xA;    stats = cpx.get_stats()&#xA;    model_stats = {}&#xA;    model_stats['Matrix range'] = [stats.min_linear_constraints, stats.max_linear_constraints]&#xA;    model_stats['Objective range'] = [stats.min_linear_objective, stats.max_linear_objective]&#xA;    model_stats['Bounds range'] = [stats.min_lower_bound, stats.max_upper_bound]&#xA;    model_stats['RHS range'] = [stats.min_linear_constraints_rhs, stats.max_linear_constraints_rhs]&#xA;    &#xA;    print('-'*100)&#xA;    print(model_stats)&#xA;    print('-'*100)&#xA;&#xA;get_model_stats(mdl)&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9871" LastActivityDate="2022-06-22T17:58:41.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8590" PostTypeId="1" CreationDate="2022-06-22T19:44:56.670" Score="2" ViewCount="150" Body="&lt;p&gt;I would like to know if anyone is aware of any Np-hard problems in scheduling or packing where there is total ordering between tasks or items to be packed together. The objective can be anything.&#xA;For example there is cost that needs to be payed if some job finishes earlier than others.&lt;/p&gt;&#xA;&lt;p&gt;Normally with total ordering problems like minimum makespan scheduling are easy to solve as there is no flexibility in this case and task orders are fixed.&lt;/p&gt;&#xA;" OwnerUserId="899" LastEditorUserId="899" LastEditDate="2022-06-22T20:04:34.873" LastActivityDate="2022-06-30T20:53:30.950" Title="Np-hard sequencing or packing problems with total ordering between elements" Tags="|optimization|scheduling|computational-complexity|packing|np-complete|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8591" PostTypeId="2" ParentId="8590" CreationDate="2022-06-22T23:28:12.933" Score="3" Body="&lt;p&gt;Scheduling problems requiring a total ordering of the tasks are generally called sequencing problems in the OR literature. Car sequencing is one of the most famous ones. The car sequencing problem is known to be NP-hard. Check &lt;a href=&quot;https://www.researchgate.net/publication/263487850_Car_sequencing_is_NP-hard_A_short_proof&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; for a short proof.&lt;/p&gt;&#xA;&lt;p&gt;A point of interest with the car sequencing is that it can be modeled simply as an assignment (that is, matching) problem with a special, nonlinear objective function. Despite the constraint matrix being totally unimodular thanks to the matching structure, it is unlikely that an optimal solution will be an extreme point of the constraint polyhedron because the objective function is nonconvex.&lt;/p&gt;&#xA;&lt;p&gt;Some sufficient conditions are identified in &lt;a href=&quot;https://www.researchgate.net/publication/41708925_Large_neighborhood_improvements_for_solving_car_sequencing_problems&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; to make the objective linear and then the problem polynomially solvable. These sufficient conditions can be exploited to search for a quality solution heuristically. Nevertheless, in the general case, the problem remains theoretically hard, and practically the linear relaxation of the problem is weak.&lt;/p&gt;&#xA;&lt;p&gt;By reading the first mentioned, you will notice that the hardness is obtained from a polynomial reduction from the TSP. Total ordering problems can be viewed as sequencing problems, and vice versa. They all can be modeled as assignment (that is, matching) problems with nonlinear objective functions, and most of them can be proved NP-hard.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2022-06-30T20:53:30.950" LastActivityDate="2022-06-30T20:53:30.950" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8592" PostTypeId="1" CreationDate="2022-06-23T14:28:55.557" Score="1" ViewCount="349" Body="&lt;p&gt;This is a sequencing problem.&lt;/p&gt;&#xA;&lt;p&gt;I've got this variables&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var z0{i in jobs} binary;&#xA;var z{i in jobs, j in jobs : i &amp;lt;&amp;gt; j} binary;&#xA;var w{i in jobs, j in jobs : i &amp;lt;&amp;gt; j};&#xA;var o{i in jobs};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;i and j come from the same set, so z0i is 1 if it's the first job in the sequence, 0 otherwise. zij is 1 if j is after i, 0 otherwise.&lt;/p&gt;&#xA;&lt;p&gt;I want to calculate w and o with this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;subject to rnueve {i in jobs, j in jobs : i &amp;lt;&amp;gt; j}: (x[j]-f[i]) - 10000 * (1 - z[i,j]) = w[i,j];&#xA;&#xA;&#xA;subject to rdiez {i in jobs}: x[i] - 10000 * (1 - z0[i]) = o[i];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The thing is, I need to put the M in from of it so when j is not after i, the variables o and w are super negative.&lt;/p&gt;&#xA;&lt;p&gt;After that, I need to make those negative values equal to zero, but I don't know how without having to make the solution nonlinear.&lt;/p&gt;&#xA;&lt;p&gt;In excel's solver, there's a button that does this. You mark: Make unconstrained variables non-negative. And this does what I described.&lt;/p&gt;&#xA;&lt;p&gt;If I try to make w and o &amp;gt;= 0 I get an infeasible solution because, with the big M, there is no possible way to find a solution with w and o being non negative.&lt;/p&gt;&#xA;&lt;p&gt;What i want to do is get a negative value, and then if it's actually negative, make it zero.&lt;/p&gt;&#xA;" OwnerUserId="9875" LastEditorUserId="491" LastEditDate="2023-04-06T12:13:39.580" LastActivityDate="2023-04-06T12:13:39.580" Title="How to make unconstrained variables non-negative (as in excel solver) in AMPL?" Tags="|cplex|solver|binary-variable|simplex|ampl|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8593" PostTypeId="1" CreationDate="2022-06-24T07:43:43.270" Score="4" ViewCount="213" Body="&lt;p&gt;Consider a &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/papers/pdf/gp_tutorial.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Geometric Program (GP)&lt;/a&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{cl}&#xA;\operatorname{minimize} &amp;amp; f_{0}(x) \\&#xA;\text { subject to } &amp;amp; f_{i}(x) \leq 1, \quad i=1, \ldots, m, \\&#xA;&amp;amp; g_{i}(x)=1, \quad i=1, \ldots, p,&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; are posynomial functions, &lt;span class=&quot;math-container&quot;&gt;$g_i$&lt;/span&gt; are monomials, and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the optimization variable.&lt;/p&gt;&#xA;&lt;p&gt;I have problems including the simple equality constraint &lt;span class=&quot;math-container&quot;&gt;$Ax - b = 0$&lt;/span&gt;, for some &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, into the GP formulation. For example, when I formulate the problem in CVX the problem is not DGP-compliant since this equality violates the disciplined GP rules. This is because standard GPs only allow monomial equality constraints in its formulation, and &lt;span class=&quot;math-container&quot;&gt;$Ax - b$&lt;/span&gt; can be interpreted as a posynomial.&lt;/p&gt;&#xA;&lt;p&gt;Is there any workaround to this? I tried to relax the constraint as &lt;span class=&quot;math-container&quot;&gt;$Ax \leq b$&lt;/span&gt; (since polynomials are allowed in inequality constraints) but strangely CVX still raise a DGP error.&lt;/p&gt;&#xA;" OwnerUserId="5005" LastEditorUserId="5005" LastEditDate="2022-06-24T09:17:07.130" LastActivityDate="2022-06-24T14:43:56.573" Title="Geometric Programming with Simple Affine Equality Constraint" Tags="|optimization|cvxpy|geometric-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8594" PostTypeId="1" AcceptedAnswerId="8595" CreationDate="2022-06-24T07:47:00.963" Score="10" ViewCount="417" Body="&lt;p&gt;Consider the following situation. I have an integer program which I want to solve using column generation. After a suitable decomposition, the master problem has decision variables that select the columns to use in order to satisfy some constraint. Unlike in ordinary Dantzig-Wolfe (DW) reformulation, here the MP variables have to be integer. This suggests using Branch and Price where (DW) is used to solve the LP relaxations at the nodes and one adopts a suitable branching strategy to recover integrality.&lt;/p&gt;&#xA;&lt;p&gt;Assume now that I do the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I solve the LP relaxation of MP using DW&lt;/li&gt;&#xA;&lt;li&gt;I retain all the columns generated in the process&lt;/li&gt;&#xA;&lt;li&gt;I solve MP again as an integer program using those columns&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;My question is&lt;/strong&gt;: Does this approach provide the optimal solution to the original problem, or it is just a heuristic? And why?&lt;/p&gt;&#xA;" OwnerUserId="9880" LastActivityDate="2022-06-24T12:01:30.767" Title="Integer column generation without branch &amp; price" Tags="|column-generation|dantzig-wolfe-decomposition|branch-and-price|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8595" PostTypeId="2" ParentId="8594" CreationDate="2022-06-24T08:31:27.000" Score="11" Body="&lt;p&gt;This approach is sometimes referred to as &lt;em&gt;price-and-branch&lt;/em&gt; (vs branch-and-price), or &lt;em&gt;solving the restricted master&lt;/em&gt;, and it does &lt;strong&gt;not&lt;/strong&gt; guarantee optimality.&lt;/p&gt;&#xA;&lt;p&gt;It is equivalent to the following question: is the gap between the optimal solution of the linear relaxation of the master problem and its integer solution &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; ?&lt;/p&gt;&#xA;&lt;p&gt;Consider for example a cutting stock problem with &lt;span class=&quot;math-container&quot;&gt;$L=90$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$l_1=30$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$l_2=45$&lt;/span&gt;, with demands &lt;span class=&quot;math-container&quot;&gt;$d_1=d_2=1$&lt;/span&gt;, and with columns &lt;span class=&quot;math-container&quot;&gt;$c_1=(0,0)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_2=(3,0)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_3=(0,2)$&lt;/span&gt;. The optimal solution is given by column &lt;span class=&quot;math-container&quot;&gt;$c_4=(1,1)$&lt;/span&gt; which is a fractional convex combination of &lt;span class=&quot;math-container&quot;&gt;$c_1,c_2,c_3$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c_4 = \frac{1}{6}c_1+\frac{1}{3}c_2+\frac{1}{2}c_3&#xA;$$&lt;/span&gt;&#xA;This means that this optimal solution cannot be returned by the master problem with integer variables, and branching is necessary to reach optimality.&lt;/p&gt;&#xA;&lt;p&gt;However, it is a good heuristic. It is used in &lt;a href=&quot;https://vrpy.readthedocs.io/en/latest/mathematical_background.html&quot; rel=&quot;noreferrer&quot;&gt;VRPy&lt;/a&gt;, a python module for solving a range of vehicle routing problems. In &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-1-4684-9309-2_8&quot; rel=&quot;noreferrer&quot;&gt;this paper&lt;/a&gt;, the authors show that asymptotically, for the VRP, the relative error using this price-and-branch strategy goes to zero as the number of customers increases. This is observed empirically: in this same paper, the authors mention other papers which report an average relative gap between the optimal solution to the linear relaxation and the integer solution of only &lt;span class=&quot;math-container&quot;&gt;$0.73$&lt;/span&gt;%.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="500" LastEditDate="2022-06-24T12:01:30.767" LastActivityDate="2022-06-24T12:01:30.767" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8596" PostTypeId="2" ParentId="8593" CreationDate="2022-06-24T10:25:40.143" Score="3" Body="&lt;p&gt;You might be able to use the suggestions in&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/expo.html#geometric-programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.mosek.com/modeling-cookbook/expo.html#geometric-programming&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;to convert your problem to a conic optimization problem. It might also make it clear to you the cause of nonconvexity.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="123" LastEditDate="2022-06-24T14:43:56.573" LastActivityDate="2022-06-24T14:43:56.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8597" PostTypeId="1" AcceptedAnswerId="8598" CreationDate="2022-06-24T12:01:51.177" Score="2" ViewCount="238" Body="&lt;p&gt;I am wondering about the characteristics and performance of some constraints with only binary variables. I assume that solving (integer) linear programs is faster than quadratic ones.&lt;br /&gt;&#xA;At first:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;a,b,c \in \{0,1\} \\&#xA;a\cdot b = c \tag{1}&#xA;$$&lt;/span&gt;&#xA;Is it a quadratic constraint because of the multiplication with two variables.&lt;br /&gt;&#xA;I try to model the logical equation &lt;span class=&quot;math-container&quot;&gt;$ a \land b = c $&lt;/span&gt; and wonder about the performance of equation 1 or 2 (&lt;a href=&quot;https://msi-jp.com/xpress/learning/square/10-mipformref.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;linearization of AND-Constraint, Chapter 2.5&lt;/a&gt;).&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;c &amp;amp;\le a \\&#xA;c &amp;amp;\le b \\&#xA;c &amp;amp;\ge a+b-1 \tag{2}&#xA;\end{align}&lt;/span&gt;&#xA;Which one should I use and why (please considering performance)?&lt;/p&gt;&#xA;&lt;p&gt;Second:&lt;br /&gt;&#xA;What is the difference between equation 3 and 4 for the logical equation &lt;span class=&quot;math-container&quot;&gt;$ a = 1 \rightarrow b = c$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$ a \in \{0,1\}; b,c \in \mathbb{N}$&lt;/span&gt;? From a logical/mathematical point of view, I do not see anyone.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;a \cdot b = a\cdot c&#xA;\tag{3}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;b-a\cdot M &amp;amp;= c-a\cdot M&#xA;\tag{4}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Summary of the questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there a performance issue between &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Which equation (&lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt;) should I use and why?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;If you know a good resource that explains these basics, please let me know.&lt;/p&gt;&#xA;" OwnerUserId="9830" LastEditorUserId="9830" LastEditDate="2022-06-24T19:07:10.333" LastActivityDate="2022-06-24T19:07:10.333" Title="Difference between constraint formulation and performance" Tags="|linear-programming|gurobi|linearization|nonlinear-programming|quadratic-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8598" PostTypeId="2" ParentId="8597" CreationDate="2022-06-24T12:27:32.697" Score="4" Body="&lt;p&gt;Instead of deciding between linear and nonlinear (quadratic) constraints, I think one should rather decide in terms of convexity as a rule of thumb. For integer problems, one should decide in terms of the convexity of the continuous relaxations. Convex problems are &lt;strong&gt;much&lt;/strong&gt; easier to solve than non-convex problems since (for a convex minimization problem) each local minimizer is guaranteed to be a global one.&lt;/p&gt;&#xA;&lt;p&gt;Note that you obtain the continuous relaxation of a problem by replacing all discrete sets with contiguous sets. For instance, in your case, you'd replace the discrete set &lt;span class=&quot;math-container&quot;&gt;$\{0,1$&lt;/span&gt;} with the contiguous set &lt;span class=&quot;math-container&quot;&gt;$[0, 1]$&lt;/span&gt;. Note also that a MIP solver always solves multiple instances of continuous relaxations during a Branch&amp;amp;Bound algorithm, so it's highly recommended to preserve a &lt;em&gt;nice&lt;/em&gt; mathematical structure of the continuous relaxations if possible. Last but not least, a quadratic equality constraint is always non-convex and a linear constraint is convex, regardless of whether it is an inequality or an equality constraint.&lt;/p&gt;&#xA;&lt;p&gt;To answer your questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The continuous relaxation of constraint (2) is convex, while (1) is not. So I'd pick constraint (2).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The continuous relaxation of constraint (4) is convex, while (3) is not. So I'd pick constraint (4).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2022-06-24T12:27:32.697" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8599" PostTypeId="1" CreationDate="2022-06-24T12:38:48.137" Score="2" ViewCount="467" Body="&lt;p&gt;I was wondering if it is possible to get the active constraints of a linear program from the Python API of Cplex? Or do I have to go through the constraints one by one and check if they bind with equality for the current solution?&lt;/p&gt;&#xA;" OwnerUserId="9588" LastActivityDate="2022-06-24T13:09:08.693" Title="Getting all active constraints of an LP from Cplex" Tags="|cplex|cplex-python-api|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8600" PostTypeId="2" ParentId="8599" CreationDate="2022-06-24T13:02:24.990" Score="3" Body="&lt;p&gt;Just look at the basis status of the rows. &lt;strong&gt;Non-basic&lt;/strong&gt; means binding.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2022-06-24T13:09:08.693" LastActivityDate="2022-06-24T13:09:08.693" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8601" PostTypeId="2" ParentId="8597" CreationDate="2022-06-24T15:36:28.150" Score="4" Body="&lt;p&gt;The answers to the questions may be solver dependent, because many solvers (including I think all the commercial ones) will either linearize the products of variables or perhaps bake them into the branching scheme.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-06-24T15:36:28.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8602" PostTypeId="1" CreationDate="2022-06-25T08:03:44.900" Score="3" ViewCount="390" Body="&lt;p&gt;I have a minimization problem with integer variables and would like to transform it to binary variables. The problem is, that my objective is to minimize the overall waiting time, which consists of number of passengers times their waiting times.&lt;/p&gt;&#xA;&lt;p&gt;My current problem is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min TWT = \sum_{l,la,h} w_{l,la,h} \,u_{l,la,h} \tag{1}$$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; are both integers.&lt;/p&gt;&#xA;&lt;p&gt;If I consider &lt;span class=&quot;math-container&quot;&gt;$w_{l,la,h,t}$&lt;/span&gt; to be binary with a time index (1 if waiting time is &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, 0 otherwise), I don't know how capture the weight &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Multiplying by &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; does not work in my model.&lt;/p&gt;&#xA;" OwnerUserId="9883" LastEditorUserId="491" LastEditDate="2022-12-29T18:16:48.707" LastActivityDate="2022-12-29T18:16:48.707" Title="Transfer an integer model to binary" Tags="|mixed-integer-programming|linear-programming|binary-variable|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8603" PostTypeId="1" AcceptedAnswerId="8604" CreationDate="2022-06-25T14:28:50.783" Score="5" ViewCount="232" Body="&lt;p&gt;I'm working on a problem with the following formulation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} &#xA;\min&amp;amp;\quad\sum_{i \in N} \sum_{j \in J} V_{ij}x_{ij}&#xA;\\&#xA;\text{s.t.}&amp;amp;\quad \sum_j  x_{ij} = 1 \quad \forall i \in N\\&#xA;&amp;amp;\quad V_{ij} = \sum_{k \in N(i)} C_kx_{kj} \quad \forall i \in N, \forall j \in J \\&#xA;&amp;amp;\quad x_{ij} \in \{0,1\}, \quad V_{ij} \ge 0&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$C_k$&lt;/span&gt; is a positive parameter, &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; is small (ie &lt;span class=&quot;math-container&quot;&gt;$\{1,2,3\}$&lt;/span&gt;). Every node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is associated to every element in the set &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;. For example, the objective would read something like: &lt;span class=&quot;math-container&quot;&gt;$$V_{a,1}x_{a,1}+V_{a,2}x_{a,2}+V_{a,3}x_{a,3}+V_{b,1}x_{b,1}+\cdots$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Essentially, I have a dense connected graph with &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; nodes, where &lt;span class=&quot;math-container&quot;&gt;$N(i)$&lt;/span&gt; is the neighboring nodes of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. The value of &lt;span class=&quot;math-container&quot;&gt;$V_{ij}$&lt;/span&gt; is only relevant to the objective function if &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; takes a value of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, however this means that &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; impacts its neighbors &lt;span class=&quot;math-container&quot;&gt;$V_{ij}$&lt;/span&gt; value.&lt;/p&gt;&#xA;&lt;p&gt;I was hoping this model would be manageable for a solver, but it doesn't seem to be the case. The solver is unable to close the MIP gap (after ~1 hour of runtime), but it does look like its finding a good solution. I do recognize that there is a bilinear term in the objective, but the solver is able to break that on its own with relative ease. Also, I've broken the bilinear term but it doesn't make much of a difference, sadly. I have attempted to break the bilinear term by trying to approached (i) applying a new variable &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; that is either &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$V_{ij}$&lt;/span&gt; depending on the value of &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt;, AND (ii) by changing the equation for &lt;span class=&quot;math-container&quot;&gt;$V_{ij}$&lt;/span&gt; directly so it either takes a value of &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or the relevant value.&lt;/p&gt;&#xA;&lt;p&gt;Is anyone aware of this type of formulation and where I can read more about it? Or any ideas on model improvements?&lt;/p&gt;&#xA;" OwnerUserId="5161" LastEditorUserId="491" LastEditDate="2024-02-21T23:08:47.923" LastActivityDate="2024-02-21T23:08:47.923" Title="Additional resources for this type of problem formulation" Tags="|mixed-integer-programming|modeling|graphs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8604" PostTypeId="2" ParentId="8603" CreationDate="2022-06-25T15:17:57.213" Score="5" Body="&lt;p&gt;The model looks really linear to me. After substituting out &lt;span class=&quot;math-container&quot;&gt;$V_{i,j}$&lt;/span&gt; you have basically terms &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}\cdot x_{k,j}$&lt;/span&gt;. Solvers may linearize that automatically or you must do it yourself. My guess is this is a fairly easy MIP (of course, I am wrong 50% of the time).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I used random data on a problem with similar size:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ontext&#xA;&#xA;   use with cuts=5 gives a total runtime of&#xA;&#xA;   --- MIQP status (102): integer optimal, tolerance.&#xA;   --- Cplex Time: 216.98sec (det. 155164.34 ticks)&#xA;&#xA;   Solution satisfies tolerances&#xA;   MIP Solution:           62.444674    (1681459 iterations, 8326 nodes)&#xA;   Final Solve:            62.444674    (0 iterations)&#xA;&#xA;   Best possible:          62.438838&#xA;   Absolute gap:            0.005837&#xA;   Relative gap:            0.000093&#xA;&#xA;$offtext&#xA;&#xA;set&#xA;   i /i1*i100/&#xA;   j /j1*j3/&#xA;;&#xA;alias(i,k);&#xA;&#xA;set n(i,k) 'neighbors (about 10 neigbors for each i)';&#xA;n(i,k) = ord(k)&amp;gt;=ord(i)-5 and ord(k)&amp;lt;=ord(i)+5 and ord(i)&amp;lt;&amp;gt;ord(k);&#xA;&#xA;parameter C(i);&#xA;c(i) = uniform(0,1);&#xA;&#xA;binary variable x(i,j);&#xA;variable z;&#xA;&#xA;equation&#xA;   obj&#xA;   e&#xA;;&#xA;&#xA;obj.. z =e= sum((i,j,k)$n(i,k), c(k)*x(i,j)*x(k,j));&#xA;e(i)..  sum(j,x(i,j)) =e= 1;&#xA;&#xA;option miqcp = cplex,threads=0;&#xA;model mod /all/;&#xA;solve mod minimizing z using miqcp;&#xA;&#xA;display x.l;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Cplex automatically linearizes this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; Classifier predicts products in MIQP should be linearized.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Interestingly, some machine learning algorithm tells Cplex what to do. (Disadvantage: this makes it a bit unpredictable whether Cplex linearizes. For more predictability set option &lt;code&gt;qtolin&lt;/code&gt;.)&lt;/p&gt;&#xA;&lt;p&gt;The original model has 300 variables and 100 constraints. After linearization this becomes:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;MIP Presolve eliminated 1455 rows and 0 columns.&#xA;Reduced MIP has 1555 rows, 1755 columns, and 4665 nonzeros.&#xA;Reduced MIP has 1755 binaries, 0 generals, 0 SOSs, and 0 indicators.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Total time &amp;lt; 4 minutes. (On a small machine). Which is quite good. Of course, random data may behave very differently than real data.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2022-06-28T15:23:34.857" LastActivityDate="2022-06-28T15:23:34.857" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="8605" PostTypeId="2" ParentId="8602" CreationDate="2022-06-25T16:20:28.153" Score="2" Body="&lt;p&gt;To avoid confusion, I will use &lt;span class=&quot;math-container&quot;&gt;$\bar{w}$&lt;/span&gt; for the original (integer) &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; variable. Assuming you have a constant upper limit &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; on possible waiting time, you can define your new binary variables via the constraints &lt;span class=&quot;math-container&quot;&gt;$$w_{\ell, \ell a, h} = \sum_{t=0}^T t \cdot w_{\ell, \ell a, h, t} \quad \forall \ell, \ell a, h$$&lt;/span&gt; plus &lt;span class=&quot;math-container&quot;&gt;$$\sum_{t=0}^T w_{\ell, \ell a, h, t} = 1 \quad \forall \ell, \ell a, h$$&lt;/span&gt; to ensure that exactly one binary variable is chosen.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-06-25T16:20:28.153" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8606" PostTypeId="1" CreationDate="2022-06-26T10:18:05.403" Score="6" ViewCount="93" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; be a graph with a set of nodes &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; and a set of edges &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$G'$&lt;/span&gt; be a graph with the same set of nodes &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; but a second set of edges &lt;span class=&quot;math-container&quot;&gt;$E'$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For a set of nodes &lt;span class=&quot;math-container&quot;&gt;$X\subset V$&lt;/span&gt;, we denote &lt;span class=&quot;math-container&quot;&gt;$f(X)$&lt;/span&gt; as the number of cliques (using the edges &lt;span class=&quot;math-container&quot;&gt;$E'$&lt;/span&gt;) when partitioning &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; in cliques. More precisely, this partition is computed by recursively finding the biggest clique. So, if &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; is the biggest clique in &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_2$&lt;/span&gt; is the biggest clique in &lt;span class=&quot;math-container&quot;&gt;$X\setminus X_1$&lt;/span&gt; and so on, we have &lt;span class=&quot;math-container&quot;&gt;$X=X_1\cup X_2\cup\cdots\cup X_k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f(X) = k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, I want to color &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; (using the set of edges &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; and not &lt;span class=&quot;math-container&quot;&gt;$E'$&lt;/span&gt;) with the minimal number of colors such that, writing this partitioning of colors as &lt;span class=&quot;math-container&quot;&gt;$V = V_1 \cup\cdots\cup V_m$&lt;/span&gt; we minimize &lt;span class=&quot;math-container&quot;&gt;$f(V_1) + \cdots+f(V_m)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I'm stuck on this problem, any hint is precious :)&lt;/p&gt;&#xA;&lt;p&gt;Right now, I have tried to colorize the graph node by node (with the DSATUR heuristic) and when there are different possible colors, I compute &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; for each choice and choose the one that minimizes &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;. But it's way too slow.&lt;/p&gt;&#xA;" OwnerUserId="9273" LastEditorUserId="123" LastEditDate="2022-06-26T10:38:26.940" LastActivityDate="2022-06-26T10:38:26.940" Title="Graph coloring problem while counting cliques" Tags="|combinatorial-optimization|constraint-programming|graphs|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8607" PostTypeId="1" CreationDate="2022-06-27T00:26:09.413" Score="2" ViewCount="175" Body="&lt;p&gt;I am working on a graph problem and want to find some link-disjoint paths between given node pairs. I was wondering if there is an efficient way to achieve this in CP. I checked OR-Tools (routing and network flows sections) but could not model this problem.&lt;/p&gt;&#xA;&lt;p&gt;The problem is simple. For example in the graph below, I want to find two diverse paths between 1 and 8 (green paths) and 3 diverse paths from 2 to 5, 6, and 8 (blue paths).&#xA;&lt;a href=&quot;https://i.stack.imgur.com/FiiuP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FiiuP.png&quot; alt=&quot;Example of the required paths&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9888" LastEditorUserId="981" LastEditDate="2023-12-31T11:14:19.167" LastActivityDate="2023-12-31T11:14:19.167" Title="Finding Diverse Paths using Constraint Programming" Tags="|or-tools|constraint-programming|graphs|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8609" PostTypeId="2" ParentId="8607" CreationDate="2022-06-27T12:08:51.947" Score="2" Body="&lt;p&gt;I not complete sure what you mean about &amp;quot;link disjoint paths&amp;quot;. Does that mean two paths cannot share any edges or that they should not be identical (in which case they are not very diverse)?&lt;/p&gt;&#xA;&lt;p&gt;If you would like a set of different (short) paths between two nodes, which may have edges in common, you could use a solver for the &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;-shortest path. You can e.g. use &lt;a href=&quot;https://en.wikipedia.org/wiki/Yen%27s_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Yen's algorithm&lt;/a&gt; for that.&lt;/p&gt;&#xA;&lt;p&gt;If the paths should be completely different (no common edges) then you could solve a series of shortest path problems where in each iteration, you remove the edges used in paths in previous iterations.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-06-27T12:08:51.947" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8610" PostTypeId="1" AcceptedAnswerId="8612" CreationDate="2022-06-27T13:28:14.803" Score="-1" ViewCount="80" Body="&lt;p&gt;In R, I want to create a random data frame of &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; coordinates, that has a certain degree of clustering. For example 15 &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-means clusters.&#xA;I currently have this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;customer_locations &amp;lt;- data.frame(&#xA;  id = 1:n,&#xA;  x = round(runif(n) * grid_size),&#xA;  y = round(runif(n) * grid_size)&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9867" LastEditorUserId="123" LastEditDate="2022-06-27T21:19:56.033" LastActivityDate="2022-06-27T21:19:56.033" Title="Create random coordinates with pre specified degree of clustering" Tags="|r|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8611" PostTypeId="1" AcceptedAnswerId="8621" CreationDate="2022-06-27T18:57:24.577" Score="3" ViewCount="85" Body="&lt;p&gt;As stated in &lt;a href=&quot;https://doi.org/10.1002/net.1035&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;, there is a technique to reformulate a multi-commodity flow problem (MCF) with undirected edges to its equivalent version with directed edges.&lt;/p&gt;&#xA;&lt;p&gt;By quoting them:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The reformulation involves adding two additional nodes and four&#xA;additional arcs for each undirected arc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;However, just from this sentence I can't figure out the shape of the new graph.&#xA;I also have problem to retrieve the original reference describing in detail such transformation.&lt;/p&gt;&#xA;&lt;p&gt;Can someone explain how to do this? Also, considering that I am working with a minimisation MCF, is there a more efficient transformation?&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="67" LastEditDate="2022-06-27T21:11:08.587" LastActivityDate="2022-06-29T10:37:03.097" Title="Reformulating undirected to directed edges for MCF" Tags="|graphs|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8612" PostTypeId="2" ParentId="8610" CreationDate="2022-06-27T20:33:22.147" Score="2" Body="&lt;p&gt;I am asking myself the same as @prubin. In case you mean with &amp;quot;degree&amp;quot; how far the clusters are from each other (and therefore also how well they are seperatable), then this might help:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;num_clusters = 5&#xA;points_per_cluster = 10&#xA;degree = 20&#xA;allPoints = list()&#xA;for (i in 1:num_clusters){&#xA;  offsets = runif(2) * degree&#xA;  x_coord = runif(points_per_cluster) + offsets[1]&#xA;  y_coord = runif(points_per_cluster) + offsets[2]&#xA;  allPoints = rbind(allPoints, cbind(x_coord, y_coord))&#xA;}  &#xA;plot(allPoints)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A degree of 5 would give you sth like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ewpEH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ewpEH.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;A degree of 20 would give you sth like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2iUpC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2iUpC.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2022-06-27T20:33:22.147" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8614" PostTypeId="1" CreationDate="2022-06-28T11:04:55.297" Score="7" ViewCount="306" Body="&lt;p&gt;I solve a nonlinear optimization problem of the form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\max x_0 \text{ such that } \\ &#xA;&amp;amp;\left[ \sum_{j=0}^N \left(\alpha_j x_0^{j} \prod_{k=3}^j x_k \right)\right]^2 + \left[ \sum_{j=1}^N \left(\beta_j x_0^{j} \prod_{k=3}^j x_k \right)\right]^2 \overset{!}{\leq} 1 &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where I know relatively tight bounds of the optimization variables &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol x$&lt;/span&gt;, something between &lt;span class=&quot;math-container&quot;&gt;$0.1\% - 30 \%$&lt;/span&gt; depending on the component. These stem from solutions for a different value of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;. I can observe that for increasing the dimensionality &lt;span class=&quot;math-container&quot;&gt;$N \to N+1$&lt;/span&gt;, the values change only merely (this is where the bounds come from). However, the optimizer I am currently using (&lt;code&gt;IpOpt&lt;/code&gt;) takes quite some time even for relatively small allowed deviations.&lt;/p&gt;&#xA;&lt;p&gt;Thus my question: &lt;em&gt;Is there a well-known way how to treat those long products of optimization variables, or are these just notoriously difficult problems?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I tested setting some variables as constant, but the constraint is very sensitive and even small deviations matter (this is also probably why this problem is hard). In that case, the optimization was often found infeasible.&lt;/p&gt;&#xA;" OwnerUserId="9847" LastEditorUserId="9847" LastEditDate="2022-06-28T22:14:38.030" LastActivityDate="2022-06-28T22:14:38.030" Title="Nonlinear optimization with constraint involving long product of optimization variables" Tags="|optimization|nonlinear-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8615" PostTypeId="2" ParentId="8614" CreationDate="2022-06-28T13:10:04.940" Score="6" Body="&lt;p&gt;You are repeating the same expressions over and over again. It may be worthwhile to see if it is better to define:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_j = \begin{cases}y_{j-1}\cdot x_j &amp;amp; \text{for $j\gt 3$}\\ &#xA; x_j &amp;amp; \text{for $j=3$}\end{cases} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and then use &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; in this constraint. No guarantee it is better; could well be much worse as we add variables and equations.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2022-06-28T15:02:35.090" LastActivityDate="2022-06-28T15:02:35.090" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8616" PostTypeId="1" CreationDate="2022-06-28T14:08:03.393" Score="2" ViewCount="429" Body="&lt;p&gt;I want to solve a relaxed version of a MILP; I am using docplex.mp.&#xA;I found LinearRelaxer in docplex.mp.relax_linear , however I keep getting this error message:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;model model1: found 1 un-relaxable elements, main cause is logical (e.g. x_25_10_0 -&amp;gt; [b_10_0 &amp;gt;= b_25_0+0.601])&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;reason: logical: 1772 unrelaxables&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def solve(model, **kwargs):&#xA;  lp = LinearRelaxer.make_relaxed_model(model)&#xA;  lp.print_information()&#xA;  sol = lp.solve(log_output=True)&#xA;&#xA;  if sol is not None:&#xA;     print(sol.solve_details.best_bound)&#xA;     print(&amp;quot;solution for a cost &#xA;       {}&amp;quot;.format(model.objective_value))&#xA;     model.print_information()&#xA;     print_solution(model, sol)&#xA;     sol.display()&#xA;     return model.objective_value&#xA; else:&#xA;     print(&amp;quot;* mdl is infeasible&amp;quot;)&#xA;     return None&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5537" LastActivityDate="2022-06-28T20:19:27.453" Title="Docplex : How can I get the objective value of the relaxation of an MILP?" Tags="|mixed-integer-programming|cplex|docplex|lp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8617" PostTypeId="1" CreationDate="2022-06-28T14:08:22.380" Score="2" ViewCount="74" Body="&lt;p&gt;I have a MILP problem that requires knowing the number of nodes within a cycle (there will be multiple depending on inputs). I believe this will involve tracing nodes/values within cycles using the node-arc matrix, but I am unsure how to construct the mathematical formulation to do so.&lt;/p&gt;&#xA;&lt;p&gt;I am required to use MATLAB and Gurobi solver.&lt;/p&gt;&#xA;&lt;p&gt;How do I accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="9899" LastEditorUserId="491" LastEditDate="2022-07-01T16:06:05.493" LastActivityDate="2022-07-01T16:06:05.493" Title="Determining the number of nodes within a cycle for an MILP problem" Tags="|optimization|mixed-integer-programming|gurobi|matlab|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8618" PostTypeId="2" ParentId="8616" CreationDate="2022-06-28T18:29:49.250" Score="1" Body="&lt;p&gt;As a simple example to work around what you want the following template would be useful:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;from docplex.mp.relax_linear import LinearRelaxer&#xA;&#xA;# The originial model name&#xA;mdl = Model(name='test')&#xA;&#xA;# Declare variables&#xA;e.g. x, y&#xA;&#xA;# The optimization model&#xA;mdl.minimize(mdl.sum(...));&#xA;mdl.add_constraints(..., 'con1');&#xA;mdl.add_constraints(..., &amp;quot;con2&amp;quot;);&#xA;&#xA;# Solving the model&#xA;mdl.print_information()&#xA;m = mdl.solve(log_output=True)&#xA;&#xA;# Solving the model again in the relaxed form &#xA;lp = LinearRelaxer.make_relaxed_model(mdl)&#xA;lp.print_information()&#xA;s_lp = lp.solve(log_output=True)&#xA;s_lp.display()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-06-28T18:29:49.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8619" PostTypeId="2" ParentId="8616" CreationDate="2022-06-28T20:19:27.453" Score="3" Body="&lt;p&gt;Disclaimer: I do not use Docplex (nor Python). That said, the following is in the documentation for LinearRelaxer:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Some constructs are not relaxable, for example, piecewise-linear expressions, SOS sets, logical constraints… When a model contains at least one of these non-relaxable constructs, a message is printed and this method returns None.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Are you using logical implication constraints in your model? The error message suggests there are a bunch of them (1772). It appears that if you want to use the relaxer you will need to replace them with big-M constraints or something similar.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-06-28T20:19:27.453" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="8621" PostTypeId="2" ParentId="8611" CreationDate="2022-06-29T10:28:04.257" Score="3" Body="&lt;p&gt;From the reference provided in the paper (exercise on page 689 of the classic book Ahuja et al., 1993). The transformation is just to turn an undirected edge to a directed version. In this case also taking care of capacities and costs. There are many more useful transformations in this book.&lt;/p&gt;&#xA;&lt;p&gt;For an undirected edge &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, we add two nodes &lt;span class=&quot;math-container&quot;&gt;$i'$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j'$&lt;/span&gt; and 4 new edges (total of 5 directed edges) with two cycles. Only the edge between &lt;span class=&quot;math-container&quot;&gt;$i'$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j'$&lt;/span&gt; has a capacity and cost associated with it. The rest have a capacity of &lt;span class=&quot;math-container&quot;&gt;$\infty$&lt;/span&gt; and a cost of 0.&lt;/p&gt;&#xA;&lt;p&gt;It is very clear with a picture:&lt;/p&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/yxT80.png&quot; width=&quot;300&quot;&gt;&#xA;&lt;p&gt;Ahuja, R., Magnanti, T., &amp;amp; Orlin, J. (1993). Network flows: theory, algorithms, and applications. PrenticeHall, Upper Saddle River, NJ.&lt;/p&gt;&#xA;" OwnerUserId="4752" LastEditorUserId="4752" LastEditDate="2022-06-29T10:37:03.097" LastActivityDate="2022-06-29T10:37:03.097" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8622" PostTypeId="1" CreationDate="2022-06-29T10:39:24.463" Score="2" ViewCount="146" Body="&lt;p&gt;I face a feasibility problem of type&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ c_i(\boldsymbol x) \leq 0, i = 1, \dots, \mathcal{I} \\ c_e(\boldsymbol x) = 0, e = 1, \dots, \mathcal{E} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{I}  + \mathcal{E}  \gg \text{dim}(\boldsymbol x) \sim \mathcal{O} (10^1) $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Currently, I solve this with &lt;a href=&quot;https://coin-or.github.io/Ipopt/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ipopt&lt;/a&gt; but since it takes quite some time I thought about looking for some special feasible point solvers.&lt;/p&gt;&#xA;&lt;p&gt;The &amp;quot;largest&amp;quot; (3) collection of feasible point solvers I could find online are mentioned in section 5.3 of &lt;a href=&quot;http://www2.math.uni-wuppertal.de/opt/preprints/prep2010/amna_opap_10_03.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;.&#xA;Unfortunately, there seems to be no implementation of the therein developed algorithm (&lt;code&gt;EFNES&lt;/code&gt;) online.&#xA;The &lt;a href=&quot;https://www.galahad.rl.ac.uk/doc/filtrane.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;FILTRANE&lt;/code&gt;&lt;/a&gt; framework of the &lt;a href=&quot;https://github.com/ralna/GALAHAD&quot; rel=&quot;nofollow noreferrer&quot;&gt;Galahad package&lt;/a&gt; might be quite effective but has a nasty Fortran API which looks even for the example problem quite difficult.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: The link in the original &lt;code&gt;TRESNEI&lt;/code&gt; paper is dead, but I found &lt;a href=&quot;https://flore.unifi.it/handle/2158/1271224&quot; rel=&quot;nofollow noreferrer&quot;&gt;this working one&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Any suggestions besides the usual suspects from nonlinear optimization, ideally free to use within academia?&lt;/p&gt;&#xA;" OwnerUserId="9847" LastEditorUserId="9847" LastEditDate="2022-06-30T08:48:52.397" LastActivityDate="2022-08-14T10:24:28.380" Title="Software for Feasibility Problems" Tags="|nonlinear-programming|constraint-programming|software|feasible-points|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8624" PostTypeId="1" CreationDate="2022-06-30T15:13:27.137" Score="1" ViewCount="60" Body="&lt;p&gt;I solve a nonlinear optimization problem with constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j=1}^S \ln \Bigg( \Big(1 -x_j c_k + y_j d_k\Big)^2 + \Big( x_j d_k + y_j c_k \Big)^2 \Bigg) \leq 0, \: k = 1, \dots , K $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the optimization variables are &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol x, \boldsymbol y \in \mathbb R^S$&lt;/span&gt; and the coefficients &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol c , \boldsymbol d \in \mathbb R^K$&lt;/span&gt;. I derived this constraint from&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \prod_{j=1}^S \Big(1 -x_j c_k + y_j d_k\Big)^2 + \Big( x_j d_k + y_j c_k \Big)^2 \leq 1, \: k = 1, \dots , K $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the sum of logs seemed more appealing to me than the product of squares.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone see further simplifications / reformulations of this constraint (e.g. to conic constraints, &amp;quot;less&amp;quot; nonlinear one, ...)?&lt;/p&gt;&#xA;&lt;p&gt;To be honest, I have not much hope since I think this problem is inherently non-convex for &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol x, \boldsymbol y, \boldsymbol c,\boldsymbol d$&lt;/span&gt; taking negative values, but I want to give it a shot, maybe someone sees something.&lt;/p&gt;&#xA;" OwnerUserId="9847" LastEditorUserId="9847" LastEditDate="2022-06-30T16:21:18.657" LastActivityDate="2022-06-30T16:21:18.657" Title="Simplification of nonlinear constraint for optimization" Tags="|optimization|constraint|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8625" PostTypeId="1" CreationDate="2022-07-01T12:51:31.323" Score="5" ViewCount="131" Body="&lt;p&gt;I use pyscipopt. I know how to add constraints while branching using handlers (kind of), but now I want also to change some parameters. I imagine is similar, but couldn’t found an example.&lt;/p&gt;&#xA;&lt;p&gt;What I want is as follows:&#xA;-Every time a feasible node is found  (or every 10 nodes) update a parameter.&lt;/p&gt;&#xA;&lt;p&gt;How do I do this?&#xA;Are there examples or documentation on this?&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="491" LastEditDate="2022-07-01T16:02:21.127" LastActivityDate="2024-01-06T13:07:20.907" Title="Changing a parameter while branching in SCIP" Tags="|python|branch-and-bound|scip|parameter|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8626" PostTypeId="1" AcceptedAnswerId="8629" CreationDate="2022-07-02T04:03:11.593" Score="2" ViewCount="99" Body="&lt;p&gt;The code below is generating the mode value considering the columns &lt;code&gt;Method1&lt;/code&gt;, &lt;code&gt;Method2&lt;/code&gt;, &lt;code&gt;Method3&lt;/code&gt; and &lt;code&gt;Method4&lt;/code&gt;. However, notice that for alternative &lt;code&gt;10&lt;/code&gt; and &lt;code&gt;12&lt;/code&gt; it has the same mode value, that is, it has a value of &lt;code&gt;2&lt;/code&gt;. However, I would like my &lt;code&gt;Mode&lt;/code&gt; column to have different values, as if it were a rank. Therefore, the alternative that had &lt;code&gt;Mode=1&lt;/code&gt; is the best, but I have no way of knowing the second best alternative, because it has two numbers &lt;code&gt;2&lt;/code&gt; in the &lt;code&gt;Mode&lt;/code&gt; column. Do you have suggestions on what approach I can take?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;database&amp;lt;-structure(list(Alternatives = c(3, 4, 5, 6, 7, 8, 9, 10, 11, 12), &#xA;    Method1 = c(1L, 10L, 7L, 8L, 9L, 6L, 5L, 3L, 4L, 2L), Method2 = c(1L, &#xA;    8L, 6L, 7L, 10L, 9L, 4L, 2L, 3L, 5L), Method3 = c(1L, &#xA;    10L, 7L, 8L, 9L, 6L, 4L, 2L, 3L, 5L), Method4 = c(1L, &#xA;    9L, 6L, 7L, 10L, 8L, 5L, 3L, 4L, 2L)), class = &amp;quot;data.frame&amp;quot;, row.names = c(NA, &#xA;10L))&#xA;&#xA; ModeFunc &amp;lt;- function(Vec) {&#xA;    tmp &amp;lt;- sort(table(Vec),decreasing = TRUE)&#xA;    Nms &amp;lt;- names(tmp)&#xA;    if(max(tmp) &amp;gt; 1) {&#xA;      as.numeric(Nms[1])&#xA;    } else NA}&#xA;  &#xA;  &#xA;  output &amp;lt;- database |&amp;gt; rowwise() |&amp;gt; &#xA;    mutate(Mode = ModeFunc(c_across(Method1:Method4))) %&amp;gt;% &#xA;    data.frame()&#xA;&#xA;&amp;gt; output&#xA;   Alternatives Method1 Method2 Method3 Method4 Mode&#xA;1             3       1       1       1       1    1&#xA;2             4      10       8      10       9   10&#xA;3             5       7       6       7       6    6&#xA;4             6       8       7       8       7    7&#xA;5             7       9      10       9      10    9&#xA;6             8       6       9       6       8    6&#xA;7             9       5       4       4       5    4&#xA;8            10       3       2       2       3    2&#xA;9            11       4       3       3       4    3&#xA;10           12       2       5       5       2    2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;@prubin answer&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;output |&amp;gt; mutate(Weight = Mode +&#xA;1/ nrow(database) * ((Method1 + Method2 + Method3 + Method4) / 4)) |&amp;gt;&#xA; mutate(rank = rank(Weight))&#xA;&#xA;     Alternatives Method1 Method2 Method3 Method4 Mode Weight rank&#xA;1             3       1       1       1       1    1  1.100    1&#xA;2             4      10       8      10       9   10 10.925   10&#xA;3             5       7       6       7       6    6  6.650    6&#xA;4             6       8       7       8       7    7  7.750    8&#xA;5             7       9      10       9      10    9  9.950    9&#xA;6             8       6       9       6       8    6  6.725    7&#xA;7             9       5       4       4       5    4  4.450    5&#xA;8            10       3       2       2       3    2  2.250    2&#xA;9            11       4       3       3       4    3  3.350    4&#xA;10           12       2       5       5       2    2  2.350    3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9063" LastEditorUserId="9063" LastEditDate="2022-07-02T23:20:54.057" LastActivityDate="2022-07-02T23:20:54.057" Title="Adjust result to equal mode values" Tags="|r|matching|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8627" PostTypeId="1" CreationDate="2022-07-02T14:54:33.553" Score="0" ViewCount="86" Body="&lt;p&gt;I would like some help with regards to understanding why the author of an article normalized differently just for the results of the &lt;code&gt;VIKOR&lt;/code&gt; multicriteria method. I'll insert an image for you to read the excerpt that talks about it. It is a study that uses 5 multi-criteria methods. However, the way to normalize &lt;code&gt;VIKOR&lt;/code&gt; he did &lt;code&gt;(max-x)/(max-min)&lt;/code&gt; and not &lt;code&gt;(x-min)/(max-min)&lt;/code&gt; like he did in the others. I read the whole article and he doesn't explain why.&lt;/p&gt;&#xA;&lt;p&gt;The reason would be because of the final result obtained &lt;code&gt;VIKOR&lt;/code&gt;, that is, index &lt;code&gt;Q&lt;/code&gt;, where the smallest value is chosen as the best, so for this reason he changed the normalization approach? In others multicriteria methods he used, the highest value is the best.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DB4ql.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DB4ql.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9063" LastEditorUserId="9063" LastEditDate="2022-07-02T15:01:33.697" LastActivityDate="2022-07-02T17:09:16.273" Title="Normalized VIKOR method multicriteria" Tags="|multicriteria-decision-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8628" PostTypeId="2" ParentId="8626" CreationDate="2022-07-02T15:30:36.973" Score="4" Body="&lt;p&gt;You are looking for a &lt;a href=&quot;https://en.wikipedia.org/wiki/Transversal_(combinatorics)&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;transversal&lt;/em&gt;&lt;/a&gt; or &lt;em&gt;system of distinct representatives&lt;/em&gt;.  One approach is to construct a bipartite graph with a left node for each alternative &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, a right node for each mode &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and an edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; if alternative &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; as a possible mode.  Now find a perfect matching in this graph.  You can do so via integer linear programming by introducing binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; to indicate whether edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is selected and imposing linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j x_{ij} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \\&#xA;\sum_i x_{ij} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $j$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Your example above has &lt;span class=&quot;math-container&quot;&gt;$10+10=20$&lt;/span&gt; nodes and &lt;span class=&quot;math-container&quot;&gt;$17$&lt;/span&gt; edges, and it turns out that there are two solutions.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-07-02T15:30:36.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8629" PostTypeId="2" ParentId="8626" CreationDate="2022-07-02T16:25:03.540" Score="3" Body="&lt;p&gt;There is no guarantee you can avoid ties using mode (or anything else, if it is possible for two alternatives to have identical scores and thus be indistinguishable). Rob's approach (which I endorse) works in your example, but with somewhat different data the integer program could wind up being infeasible.&lt;/p&gt;&#xA;&lt;p&gt;A simple way to break most (but possibly not all ties) would be to create a weight column that is equal to the mode plus a constant (maybe 0.1 or 0.01, depending on the scale of the data) times the mean for that alternative. So alternative 10 would get weight 2.25 (using 0.1 for the multiplier) while alternative 12 would get weight 2.35. That still does not exclude the possibility of ties, but it would hopefully reduce the frequency of them.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-02T16:25:03.540" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8630" PostTypeId="2" ParentId="8627" CreationDate="2022-07-02T17:09:16.273" Score="1" Body="&lt;p&gt;Yes! You're absolutely correct.&lt;/p&gt;&#xA;&lt;p&gt;Basically, whenever normalization is done in MCDM methods, the designer has to see whether the criteria is a benefit criteria (for which the higher the value, the better it is) or it is a cost criteria (for which the lower the value, the better it is). Seeing that, we normalize things.&lt;/p&gt;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&lt;p&gt;Just have a look at the table 1 of this paper:&#xA;&lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-319-31165-4_26&quot; rel=&quot;nofollow noreferrer&quot;&gt;Normalization Techniques for Multi-Criteria Decision Making: Analytical Hierarchy Process Case Study&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IL8mY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IL8mY.png&quot; alt=&quot;Max Min criteria&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5532" LastActivityDate="2022-07-02T17:09:16.273" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8631" PostTypeId="1" AcceptedAnswerId="8632" CreationDate="2022-07-02T18:57:55.637" Score="2" ViewCount="201" Body="&lt;p&gt;I am working on a branch-and-bound algorithm for number partitioning, similar to &lt;a href=&quot;https://en.wikipedia.org/wiki/Complete_greedy_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Complete greedy algorithm&lt;/a&gt;. The input is a list of positive integers and an integer &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;; the output is a partitioning of the integers into &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; bins, such that the smallest bin sum is as large as possible.&lt;/p&gt;&#xA;&lt;p&gt;For the &amp;quot;bound&amp;quot; part, I want a function that takes as input a partial partition (a partition of the first &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; integers) and the sum of the remaining integers, and returns an upper bound on the smallest sum. If this bound is not larger than the best solution found so far, then the branch can be pruned.&lt;/p&gt;&#xA;&lt;p&gt;For example, suppose &lt;span class=&quot;math-container&quot;&gt;$k=3$&lt;/span&gt;, we have a partial partition with sums: &lt;span class=&quot;math-container&quot;&gt;$70, 90, 100$&lt;/span&gt;, and the sum of all remaining inputs is 30. Then, the upper bound is &lt;span class=&quot;math-container&quot;&gt;$95$&lt;/span&gt;, since in the best case, even if the remaining inputs are perfectly divisible, we would put &lt;span class=&quot;math-container&quot;&gt;$25$&lt;/span&gt; in the first bin and &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; in the second bin, so the best partition would be &lt;span class=&quot;math-container&quot;&gt;$95,95,100$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for a fast algorithm to compute this upper bound. My current algorithm is as follows. Suppose we have a partial partition with sums &lt;span class=&quot;math-container&quot;&gt;$b_1\leq \ldots \leq b_k$&lt;/span&gt;, and the sum of remaining inputs is &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;. Then:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$b_1+s\leq b_2$&lt;/span&gt;, return &lt;span class=&quot;math-container&quot;&gt;$b_1+s$&lt;/span&gt; (- put all remaining inputs in bin 1).&lt;/li&gt;&#xA;&lt;li&gt;Else, if &lt;span class=&quot;math-container&quot;&gt;$(b_1+b_2+s)/2 \leq b_3$&lt;/span&gt;, return &lt;span class=&quot;math-container&quot;&gt;$(b_1+b_2+s)/2$&lt;/span&gt; (- divide all remaining inputs between bins 1 and 2 in a balanced way).&lt;/li&gt;&#xA;&lt;li&gt;Else, if &lt;span class=&quot;math-container&quot;&gt;$(b_1+b_2+b_3+s)/3 \leq b_4$&lt;/span&gt;, return &lt;span class=&quot;math-container&quot;&gt;$(b_1+b_2+b_3+s)/3$&lt;/span&gt;&#xA;...&lt;/li&gt;&#xA;&lt;li&gt;Else, return &lt;span class=&quot;math-container&quot;&gt;$(b_1+\cdots+b_k)/k$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Since the upper bound is calculated many times throughout the algorithm, I want the calculation to be as fast as possible.&lt;/p&gt;&#xA;&lt;p&gt;QUESTION: Is there a faster way to compute this upper bound? I am looking both for improvements in runtime complexity (e.g. runtime that is sublinear in &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;), and for improvements in the constants.&lt;/p&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2022-07-04T22:56:54.203" Title="A branch-and-bound algorithm for number partitioning" Tags="|algorithms|heuristics|branch-and-bound|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8632" PostTypeId="2" ParentId="8631" CreationDate="2022-07-02T21:17:41.810" Score="2" Body="&lt;p&gt;The following contains two modest tweaks (cumulative sum, multiplying rather than dividing) to your algorithm that might speed it up slightly.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sigma \leftarrow b_1 + s$&lt;/span&gt; (cumulative sum)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\sigma \le b_2$&lt;/span&gt; return &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; else &lt;span class=&quot;math-container&quot;&gt;$\sigma \leftarrow \sigma + b_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$j=2,\dots,k-1$&lt;/span&gt; {&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\sigma \le j \cdot b_{j+1}$&lt;/span&gt; return &lt;span class=&quot;math-container&quot;&gt;$\left\lfloor \frac{\sigma}{j}\right\rfloor $&lt;/span&gt;&#xA;else &lt;span class=&quot;math-container&quot;&gt;$\sigma \leftarrow \sigma + b_{j+1}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Return &lt;span class=&quot;math-container&quot;&gt;$\left\lfloor \frac{\sigma}{k}\right\rfloor $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Using a cumulative sum avoids repetitive additions. I'm pretty sure multiplying by &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is faster than dividing by &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and this way you do a maximum of one division.&lt;/p&gt;&#xA;&lt;p&gt;I included the floor operator in case you are using a language in which the computations are floating point, but most likely you will be using integer arithmetic and the division will produce the correct result automatically.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-02T21:17:41.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8633" PostTypeId="1" AcceptedAnswerId="8634" CreationDate="2022-07-03T14:23:31.100" Score="6" ViewCount="400" Body="&lt;p&gt;How can I represent the following set of constraints in a linear program, where &lt;span class=&quot;math-container&quot;&gt;$c_1,\ldots, c_n$&lt;/span&gt; are constants and &lt;span class=&quot;math-container&quot;&gt;$f_1,\ldots,f_n$&lt;/span&gt; are functions of the optimization variables?&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The smallest of &lt;span class=&quot;math-container&quot;&gt;$f_1(x),\ldots,f_n(x)$&lt;/span&gt; is at least &lt;span class=&quot;math-container&quot;&gt;$c_1$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;p&gt;The second-smallest of &lt;span class=&quot;math-container&quot;&gt;$f_1(x),\ldots,f_n(x)$&lt;/span&gt; is at least &lt;span class=&quot;math-container&quot;&gt;$c_2$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;p&gt;The third-smallest of &lt;span class=&quot;math-container&quot;&gt;$f_1(x),\ldots,f_n(x)$&lt;/span&gt; is at least &lt;span class=&quot;math-container&quot;&gt;$c_3$&lt;/span&gt;;&lt;/p&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;The largest of &lt;span class=&quot;math-container&quot;&gt;$f_1(x),\ldots,f_n(x)$&lt;/span&gt; is at least &lt;span class=&quot;math-container&quot;&gt;$c_n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="123" LastEditDate="2022-07-03T16:12:59.303" LastActivityDate="2022-11-18T06:00:25.677" Title="How to represent a constraint on the kth-smallest function?" Tags="|modeling|constraint|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8634" PostTypeId="2" ParentId="8633" CreationDate="2022-07-03T15:20:18.887" Score="8" Body="&lt;p&gt;The first constraint is convex, and can be handled without use of logical constraints or introduction of binary variables:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f_1(x) \ge c_1, ..., f_n(x) \ge c_1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The remaining constraints are non-convex, and so require logical constraints or binary variables to handle.&lt;/p&gt;&#xA;&lt;p&gt;For simplicity of exposition, I will assume logical constraints are available. If not, they can be handled by standard big M modeling, such as in the &amp;quot;If &lt;span class=&quot;math-container&quot;&gt;$f(x)\le0$&lt;/span&gt; then a&amp;quot; section of &lt;a href=&quot;https://yalmip.github.io/tutorial/logicprogramming&quot; rel=&quot;noreferrer&quot;&gt;Logics and integer-programming representations&lt;/a&gt;, or as found on this site.&lt;/p&gt;&#xA;&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, and for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$b_{k,i}$&lt;/span&gt; be a binary variable, and specify the logical constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$b_{k,i} = 1 \implies f_i(x) \ge c_k.$$&lt;/span&gt; For each &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, impose the constraint: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n b_{k,i} \ge n-k+1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I corrected a typo and improved the formulation, both as pointed out in the comments by @RobPratt. By switching the direction (specifying the contrapositive) of the logic constraints, the need for an &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; fudge factor was eliminated.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2022-07-03T16:12:42.813" LastActivityDate="2022-07-03T16:12:42.813" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8635" PostTypeId="1" CreationDate="2022-07-04T09:34:58.813" Score="2" ViewCount="193" Body="&lt;p&gt;Am writing a small scheduling program in C# for a group of 7 staff who will be working in three shifts daily for 4 weeks. Am using the google OR-Tools &lt;a href=&quot;https://github.com/google/or-tools/blob/master/examples/dotnet/ShiftSchedulingSat.cs&quot; rel=&quot;nofollow noreferrer&quot;&gt;Template&lt;/a&gt;, but i have &lt;a href=&quot;https://replit.com/@musudaalitsi/ShiftScheduling#main.cs&quot; rel=&quot;nofollow noreferrer&quot;&gt;modified it abit&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;This is the scope&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;We have 3 shifts(M,A,N) plus an O(off day)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each shift has ONLY one staff&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each person must work a max of four &lt;strong&gt;consecutive same shifts&lt;/strong&gt; per week(i.e NNNN) or per 7days&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each person must have a min of 3 off days per week or per 7 days&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After off days the person can change the shifs (i.e from NNNN to now&#xA;AAAA)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I have both shiftConstraints and weeklySumConstraints, should i use both or just one?&lt;/p&gt;&#xA;&lt;p&gt;Here is my shiftConstraints&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var shiftConstraints =&#xA;            new (int Shift, int HardMin, int SoftMin, int MinPenalty, int SoftMax, int HardMax, int MaxPenalty)[] {&#xA;                // One to three consecutive days of rest, this is a hard constraint.&#xA;                (0, 1, 1, 0, 3, 3, 0),&#xA;                //Make same employee to work same shifts 4 times consecutively. E.g night shift for 4 days then 3 days off&#xA;            };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here is my weekSumConstraint&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var weeklySumConstraints =&#xA;            new (int Shift, int HardMin, int SoftMin, int MinPenalty, int SoftMax, int HardMax, int MaxPenalty)[] {&#xA;                // Constraints on rests per week.               &#xA;               (0, 1, 2, 7, 2, 3, 4),&#xA;            };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The trick is just in one of there two variables or both, to implement the above requirements, or mybe somewhere else? let me know where am going wrong.&lt;/p&gt;&#xA;&lt;p&gt;Am currently getting this output below but it is obviously erroneous&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;            M T W T F S S M T W T F S S M T W T F S S M T W T F S S&#xA;Employee 0: O O O N M M N A N O A N N O N O A O M N N N M M O M N O&#xA;Employee 1: O A O N N A N N M N M O O N A N M O N O N M N N O N O A&#xA;Employee 2: O N M N N O N O N A O A N A N O N A O A N N O N A N M O&#xA;Employee 3: N M A O A O M M O N O N N M M M N O N N O N O N N O N N&#xA;Employee 4: M O O M N N N N O N N M A O O N N O N N A A N O O N N M&#xA;Employee 5: O N N A N O N N N O N O M N N N O M O M N N A N M N O O&#xA;Employee 6: A O A N O N A N A M O N O N A A O N A O M N O A A A A O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Like you see on the first Thursday 4 employees are assigned the night shift which is wrong, it should be one employee per shift the rest should be Off...&#xA;Something might be wrong with the way i set the constraints or the models, you can go through my &lt;a href=&quot;https://replit.com/@musudaalitsi/ShiftScheduling#main.cs&quot; rel=&quot;nofollow noreferrer&quot;&gt;code&lt;/a&gt; and see.&#xA;Your help will be highly appreciated&lt;/p&gt;&#xA;" OwnerUserId="9919" LastEditorUserId="981" LastEditDate="2023-02-19T14:45:15.463" LastActivityDate="2023-02-20T03:59:53.767" Title="Scheduling optimization, Adding 4 day same shift and 3 day off weekly constraint" Tags="|linear-programming|scheduling|or-tools|c#|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8636" PostTypeId="1" AcceptedAnswerId="8641" CreationDate="2022-07-04T14:27:59.117" Score="3" ViewCount="542" Body="&lt;p&gt;I would like to write the following constraint in the most compact form possible using Pyomo.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{o\in O}y_{n,o} = \sum_{o\in O} \sum_{n'\in LN}y_{n',o}\qquad \forall n$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where, the important part, is that &lt;span class=&quot;math-container&quot;&gt;$LN$&lt;/span&gt; is a relationship set, or multiset, such that its elements are tuples like &lt;span class=&quot;math-container&quot;&gt;$(n_1,n_2), (n_2, n_4), ...$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In GAMS, this is easy. The code for a small example would look like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;SETS&#xA;n       /n1*n6/&#xA;LN(n,n) /(n1.n2), (n2.n4)/&#xA;O       /1,2,3/&#xA;;&#xA;alias(n,nn);&#xA;&#xA;VARIABLES&#xA;y(n,o)&#xA;;&#xA;&#xA;EQUATIONS&#xA;EQ01;&#xA;EQ01(n)..      sum(O, y(n,o)) = sum(o, sum(nn$LN(n,nn), y(nn,o));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For example, for &lt;span class=&quot;math-container&quot;&gt;$n=n1$&lt;/span&gt;, I would want the following equation.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{n_1,1} + y_{n_1,2} + y_{n_1,3} = y_{n_2,1} + y_{n_2,2} + y_{n_2,3}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm not sure of how to translate the compactness of GAMS to Pyomo (if possible). I am working with some rules for a pyomo model in the form:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;model    = pyo.ConcreteModel()&#xA;model.N  = pyo.Set(initialize = [&amp;quot;n1&amp;quot;,&amp;quot;n2&amp;quot;,&amp;quot;n3&amp;quot;,&amp;quot;n4&amp;quot;,&amp;quot;n5&amp;quot;, &amp;quot;n6&amp;quot;]&#xA;model.LN = pyo.Set(within = model.N*model.N, initialize = [(&amp;quot;n1&amp;quot;, &amp;quot;n2&amp;quot;), (&amp;quot;n2&amp;quot;, &amp;quot;n4&amp;quot;)]&#xA;model.O  = pyo.Set(initialize = [1,2,3])&#xA;model.y  = pyo.Var(model.N, model.O)&#xA;&#xA;def _rule(model,n):&#xA;  return sum(model.y[n,o] for o in model.O) == sum(sum(model.y[nn,o] for nn in model.LN) for o in model.O) &#xA;model.equation = pyo.Constraint(model.N, rule = _rule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But it is clearly not working, since in the inner sum it does not know what nn is. The set of LN also doesn't have a way of knowing that I'm referring to the outer &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; in there, I think.&lt;/p&gt;&#xA;&lt;p&gt;I think something could be done with the advantage of Pyomo's ability to use &amp;quot;ifs&amp;quot; and other flow controls, together with ConstraintSkip for the cases where there is no &lt;span class=&quot;math-container&quot;&gt;$n'$&lt;/span&gt; associated to a &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. However, I would like to know if there is a more elegant, compact way of writing this, such as GAMS'.&lt;/p&gt;&#xA;&lt;p&gt;Thank you for your time!&lt;/p&gt;&#xA;" OwnerUserId="7381" LastEditorUserId="7381" LastEditDate="2022-07-05T08:07:25.817" LastActivityDate="2022-07-06T07:53:53.663" Title="Write constraints with relationship sets in Pyomo" Tags="|pyomo|gams|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8637" PostTypeId="1" CreationDate="2022-07-04T15:54:28.620" Score="3" ViewCount="194" Body="&lt;p&gt;I have a constrained convex optimization problem with linear equality and inequality constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\label{eq:costf}&#xA;\text{minimize}\ \ &#xA;    &amp;amp;f(x_1,\dots,x_m) = \sum_{i=1}^m \frac{1}{x_i}\\&#xA;\text{so that}\ \ &#xA;    &amp;amp;\sum_{i=1}^m x_i = ab\\ &#xA;    &amp;amp;x_1 - c  \leq 0,\\&#xA;&amp;amp;-x_m + d  \leq 0,\\&#xA;&amp;amp;c+d-b \leq 0\ .&#xA;\end{align}&lt;/span&gt;&#xA;Note that &lt;span class=&quot;math-container&quot;&gt;$x_i&amp;gt;0,\ i=1,...,m$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_1\leq...\leq x_m$&lt;/span&gt;. Also &lt;span class=&quot;math-container&quot;&gt;$a,b,c,d &amp;gt; 0$&lt;/span&gt;. Can this problem be solved analytically?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;CONSIDERATIONS:&lt;/strong&gt;&#xA;The Lagrangian and its gradient can be easily computed and set to zero&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;        \begin{cases}&#xA;         -\frac{1}{x_1^2} + \lambda_1 + \lambda_2 +\nu &amp;amp;=0\\&#xA;         - \frac{1}{x_2^2} +\nu &amp;amp;=0\\&#xA;         &amp;amp;\vdots\\&#xA;         - \frac{1}{x_{m-1}^2} +\nu &amp;amp;=0\\&#xA;         - \frac{1}{x_m^2} -\lambda_{3}-\lambda_{4} +\nu &amp;amp;=0&#xA;        \end{cases} &#xA;\end{equation}&lt;/span&gt;&#xA;and so the Karush-Kuhn-Tucker (KKT) conditions can be derived and used to find a solution. Solving the dual problem might be also a viable solution.&lt;/p&gt;&#xA;&lt;p&gt;The fact that &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_m$&lt;/span&gt; are respectively the smallest and largest variable can be expressed by including &lt;span class=&quot;math-container&quot;&gt;$x_1 - \frac{ab}{m}  \leq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$-x_m + \frac{ab}{m} \leq 0$&lt;/span&gt; among the inequality constraints.&lt;/p&gt;&#xA;" OwnerUserId="9925" LastEditorUserId="9925" LastEditDate="2022-07-04T20:08:35.547" LastActivityDate="2022-07-05T21:38:16.120" Title="Convex optimization with linear constraints. Can I solve it analytically?" Tags="|optimization|nonlinear-programming|convex-optimization|duality|constrained-optimization|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8638" PostTypeId="1" CreationDate="2022-07-04T22:13:19.140" Score="1" ViewCount="106" Body="&lt;p&gt;I want to partition a set of numbers in two sets such that their sum is equal. Here in the original master set we can have positive as well as negative numbers. Can anyone tell me about the complexity of this problem. Partition with only positive numbers is NP hard.&lt;/p&gt;&#xA;" OwnerUserId="899" LastActivityDate="2022-07-06T08:31:26.530" Title="complexity Partitioning with negative numbers" Tags="|combinatorial-optimization|computational-complexity|np-complete|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8639" PostTypeId="2" ParentId="8631" CreationDate="2022-07-04T22:56:54.203" Score="2" Body="&lt;p&gt;If &lt;em&gt;k&lt;/em&gt; is relatively large, rather than iterating through the possibilities one at a time, it might be faster to double the index of the test case each iteration, and then do a binary search between the two last found points that are too small and too large.&lt;/p&gt;&#xA;" OwnerUserId="3482" LastActivityDate="2022-07-04T22:56:54.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8640" PostTypeId="1" CreationDate="2022-07-05T16:16:27.290" Score="1" ViewCount="63" Body="&lt;p&gt;My question is with regards to a research topic: Rule-set optimization [https://www.diva-portal.org/smash/get/diva2:1392617/FULLTEXT02.]. If one were to use rule-set optimization for fraud detection. Does anyone have any ideas on how to go about this? I'm not able to find the right papers or references for this problem. Some have suggested Reinforcement Learning to penalize whenever a rule fails.&lt;/p&gt;&#xA;" OwnerUserId="8819" LastEditorUserId="491" LastEditDate="2022-11-04T14:53:56.833" LastActivityDate="2022-11-04T14:53:56.833" Title="Rule set optimization" Tags="|reinforcement-learning|open-problems|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8641" PostTypeId="2" ParentId="8636" CreationDate="2022-07-05T18:31:19.810" Score="2" Body="&lt;p&gt;First create a dictionary like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Allowed={&amp;quot;n1&amp;quot;:&amp;quot;n2&amp;quot;, &amp;quot;n2&amp;quot;:&amp;quot;n4&amp;quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and then&lt;/p&gt;&#xA;&lt;p&gt;Use this&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.environ import *&#xA;Allowed={&amp;quot;n1&amp;quot;:&amp;quot;n2&amp;quot;, &amp;quot;n2&amp;quot;:&amp;quot;n4&amp;quot;}&#xA;model    = AbstractModel()&#xA;model.N  = Set(initialize = [&amp;quot;n1&amp;quot;,&amp;quot;n2&amp;quot;,&amp;quot;n3&amp;quot;,&amp;quot;n4&amp;quot;])&#xA;model.O  = Set(initialize = [1,2,3])&#xA;model.y  = Var(model.N, model.O, within=Reals)&#xA;def yrule(model,n):&#xA;    if n in Allowed:&#xA;        return sum(model.y[n,o] for o in model.O) ==sum(model.y[nn,o] for nn in model.N for o in model.O if nn in Allowed[n])&#xA;    else:&#xA;        return Constraint.Skip&#xA;model.equation = Constraint(model.N, rule = yrule)&#xA;&#xA;instance = model.create_instance()&#xA;instance.equation.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Unw6H.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Unw6H.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2022-07-05T18:31:19.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8642" PostTypeId="2" ParentId="8637" CreationDate="2022-07-05T21:38:16.120" Score="2" Body="&lt;p&gt;You are going to be dealing with various cases depending on the values of &lt;span class=&quot;math-container&quot;&gt;$c,d,ab$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m.$&lt;/span&gt; I think I can get you part way, but I have not dealt with all the cases.&lt;/p&gt;&#xA;&lt;p&gt;Given that the objective function and the equation constraint treat&#xA;all variables &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; identically, we can ignore the requirement&#xA;that &lt;span class=&quot;math-container&quot;&gt;$x_{1}\le x_{2}\dots\le x_{m}$&lt;/span&gt; and just require that the smallest&#xA;(largest) variable be at most (at least) &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;). Since permuting&#xA;a candidate solution does not affect the objective or constraint,&#xA;we can simplify this further to &lt;span class=&quot;math-container&quot;&gt;$x_{1}\le c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{m}\ge d$&lt;/span&gt;, which&#xA;(assuming &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; satisfies the equation constraint) are sufficient to&#xA;ensure that the sorted version of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is feasible.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$[m]$&lt;/span&gt; denote the index set &lt;span class=&quot;math-container&quot;&gt;$\left\{ 1,\dots,m\right\} .$&lt;/span&gt; For&#xA;any &lt;span class=&quot;math-container&quot;&gt;$S\subseteq[m]$&lt;/span&gt; and any &lt;span class=&quot;math-container&quot;&gt;$K&amp;gt;0$&lt;/span&gt; let&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;g(S,K)=\min\left\{ \sum_{i\in S}\frac{1}{x_{i}}:x&amp;gt;0,\sum_{i\in S}x_{i}=K\right\} .&#xA;$$&lt;/span&gt;&#xA;Using the convexity of the function &lt;span class=&quot;math-container&quot;&gt;$\phi(x)=\frac{1}{x}$&lt;/span&gt;, we can&#xA;show that the minimum occurs at &lt;span class=&quot;math-container&quot;&gt;$x_{i}=\frac{K}{\vert S\vert}\ \forall i$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$g(S,K)=\frac{\vert S\vert^{2}}{K}.$&lt;/span&gt; Thus, in the absence of&#xA;the requirements that &lt;span class=&quot;math-container&quot;&gt;$x_{1}\le c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{m}\ge d$&lt;/span&gt;, the solution&#xA;to the original problem would be &lt;span class=&quot;math-container&quot;&gt;$\hat{x}=\left(\frac{ab}{m},\dots,\frac{ab}{m}\right)$&lt;/span&gt;&#xA;with value &lt;span class=&quot;math-container&quot;&gt;$g([m],ab)=\frac{m^{2}}{ab}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now suppose that &lt;span class=&quot;math-container&quot;&gt;$x_{m}$&lt;/span&gt; has been fixed at some value &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$d\le h&amp;lt;ab.$&lt;/span&gt;&#xA;The best possible solution with &lt;span class=&quot;math-container&quot;&gt;$x_{m}=h$&lt;/span&gt; is found by solving for&#xA;&lt;span class=&quot;math-container&quot;&gt;$g\left([m-1],ab-h\right).$&lt;/span&gt; To avoid division by zero, we need the strict inequality &lt;span class=&quot;math-container&quot;&gt;$ab-h-x_{1}&amp;gt;0,$&lt;/span&gt;&#xA;which we will enforce as &lt;span class=&quot;math-container&quot;&gt;$x_{1}\le ab-h-\epsilon$&lt;/span&gt; for some small&#xA;positive &lt;span class=&quot;math-container&quot;&gt;$\epsilon.$&lt;/span&gt; We can express the reduced problem as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\min_{0&amp;lt;x_1\le\gamma} &amp;amp; \frac{1}{x_1}+g\left(\left\{ 2,\dots,m-1\right\} ,ab-h-x_1\right)\\&#xA;=\min_{0&amp;lt;x_1\le\gamma} &amp;amp; \frac{1}{x_1}+\frac{(m-2)^{2}}{ab-h-x_1}&#xA;\end{align*}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\gamma=\min(c,ab-h-\epsilon).$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the absence of the requirement that &lt;span class=&quot;math-container&quot;&gt;$x_{1}\le c,$&lt;/span&gt; we know from&#xA;convexity that the optimal solution would be &lt;span class=&quot;math-container&quot;&gt;$x_1=\frac{ab-h}{m-1},$&lt;/span&gt;&#xA;where the partial derivative w.r.t. &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; changes from negative to&#xA;positive. So the optimal choice of &lt;span class=&quot;math-container&quot;&gt;$x_{1}$&lt;/span&gt; is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{1}=\begin{cases}&#xA;\frac{ab-h}{m-1} &amp;amp; \gamma\ge\frac{ab-h}{m-1}\\&#xA;\gamma &amp;amp; \gamma&amp;lt;\frac{ab-h}{m-1}&#xA;\end{cases}&#xA;$$&lt;/span&gt;&#xA;with corresponding objective values&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{cases}&#xA;\frac{(m-1)^{2}}{ab-h} &amp;amp; \gamma\ge\frac{ab-h}{m-1}\\&#xA;\frac{1}{\gamma}+\frac{(m-2)^{2}}{ab-h-\gamma} &amp;amp; \gamma&amp;lt;\frac{ab-h}{m-1}&#xA;\end{cases}.&#xA;$$&lt;/span&gt;&#xA;Now you just have to optimize that with respect to the value &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;, taking into account the requirements that &lt;span class=&quot;math-container&quot;&gt;$h\ge d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ab-h &amp;gt; 0.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-05T21:38:16.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8643" PostTypeId="2" ParentId="8636" CreationDate="2022-07-06T07:53:53.663" Score="0" Body="&lt;p&gt;I will mark the answer from Optimization team, which is completely correct, as it works for the problem given, although it does not use tuple sets. I will also put here for completion how I ended up doing it, since I found that it could be made more compact with list comprehension and without Constraint.Skip.&lt;/p&gt;&#xA;&lt;p&gt;Apparently, I was on the right track with this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;def _rule(model,n):&#xA;  return sum(model.y[n,o] for o in model.O) == sum(sum(model.y[nn,o] for nn in model.LN) for o in model.O)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I had to slightly change it to this.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;def _rule(model,n):&#xA;  return sum(model.y[n,o] for o in model.O) == sum(sum(model.y[nn,o] for nn in m.N if (n,nn) in model.LN) for o in model.O)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So now it knows where the nn should come from, the set N, and also knows that only do it for the pairs that are present in the tuple set.&lt;/p&gt;&#xA;&lt;p&gt;Thank you all who helped me!&lt;/p&gt;&#xA;" OwnerUserId="7381" LastActivityDate="2022-07-06T07:53:53.663" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8644" PostTypeId="2" ParentId="8638" CreationDate="2022-07-06T08:31:26.530" Score="2" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$I = \{a_i, i = 1, \dots, n \}$&lt;/span&gt; be an instance of &amp;quot;Partition with only positive numbers&amp;quot; that we want to solve.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$I' =  \{4 a_i, i = 1, \dots, n \} \cup \{ -1, -1 \}$&lt;/span&gt; be an instance of &amp;quot;Partition with at least one negative number&amp;quot;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$I'$&lt;/span&gt; is &amp;quot;yes&amp;quot;, then the two -1 cannot belong to the same partition. Otherwise, one would be a multiple of 4 and the other wouldn't. Therefore, &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is &amp;quot;yes&amp;quot; too.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is &amp;quot;yes&amp;quot;, then &lt;span class=&quot;math-container&quot;&gt;$I'$&lt;/span&gt; is &amp;quot;yes&amp;quot; too since we can use the same partitions and put a -1 in each partition. Therefore, if &lt;span class=&quot;math-container&quot;&gt;$I'$&lt;/span&gt; is &amp;quot;no&amp;quot;, then &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is &amp;quot;no&amp;quot; too (converse proposition).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So if we were able to solve &amp;quot;Partition with at least one negative number&amp;quot; in polynomial time, we could solve &amp;quot;Partition with only positive number&amp;quot; in polynomial time as well.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-07-06T08:31:26.530" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8646" PostTypeId="1" CreationDate="2022-07-06T13:27:06.460" Score="4" ViewCount="77" Body="&lt;p&gt;Is it always possible to escape a degenerate point by a single pivot, or is it possible that several pivots are required?&#xA;In other words is it possible to get away from a degenerate point by a single pivot regardless of which of the possible bases (given the point one is currently at) one currently has?&#xA;If no, is there an upper bound on the number of pivots needed?&lt;/p&gt;&#xA;&lt;p&gt;Edit: What is the minimum number of pivots for an omniscient user to escape a degenerate point?&lt;/p&gt;&#xA;" OwnerUserId="9151" LastEditorUserId="9151" LastEditDate="2022-07-07T08:53:17.140" LastActivityDate="2022-07-07T15:21:38.493" Title="Upper bound on number of pivots to escape a degenerate point" Tags="|simplex|degeneracy|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8647" PostTypeId="1" AcceptedAnswerId="8648" CreationDate="2022-07-06T14:59:35.907" Score="4" ViewCount="261" Body="&lt;p&gt;Phase I of the simplex method solves an auxiliary optimization problem to determine an initial basic feasible solution, or concludes that no such exists. Is there a way to use the solution of this auxiliary problem to construct a Farkas certificate for the infeasibility of the original (assume standard form), i.e., a vector &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$p^TA \geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p^Tb &amp;lt; 0$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="9933" LastActivityDate="2022-07-07T16:43:07.720" Title="Phase I of the simplex method and Farkas certificates" Tags="|optimization|duality|simplex|dual-simplex|primal-simplex|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8648" PostTypeId="2" ParentId="8647" CreationDate="2022-07-06T18:13:01.687" Score="5" Body="&lt;p&gt;If the phase 1 problem proves the problem is primal infeasible, then the optimal dual solution is a Farkas certificate. That was the conclusion I made during research when I wrote:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/article/10.1023/A:1011259103627&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/article/10.1023/A:1011259103627&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Indeed in Section 3 this is proved for one specific phase 1 problem.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2022-07-07T06:18:12.203" LastActivityDate="2022-07-07T06:18:12.203" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8649" PostTypeId="1" AcceptedAnswerId="8672" CreationDate="2022-07-07T11:03:44.680" Score="9" ViewCount="1132" Body="&lt;p&gt;I am using Gurobi (in Python through gurobipy) to solve an IP on tournament graphs.&lt;/p&gt;&#xA;&lt;p&gt;I am searching for a non-zero minimal integer weighting such that for every vertex the sum of weights put on the vertices connected through an outgoing edge is at most the sum of weights put on the vertices connected through ingoing edges. It can be proven that there exists a single such weighting for any tournament.&lt;/p&gt;&#xA;&lt;p&gt;Still I encountered problems with a tournament on 15 vertices, which induces the following optimization problem:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\ Model BP-solver&#xA;\ LP format - for model browsing. Use MPS format to capture full model detail.&#xA;Minimize&#xA;  vertices[0] + vertices[1] + vertices[2] + vertices[3] + vertices[4]&#xA;   + vertices[5] + vertices[6] + vertices[7] + vertices[8] + vertices[9]&#xA;   + vertices[10] + vertices[11] + vertices[12] + vertices[13]&#xA;   + vertices[14]&#xA;Subject To&#xA; optimality_of_node[0]: vertices[1] - vertices[2] + vertices[3]&#xA;   - vertices[4] + vertices[5] - vertices[6] + vertices[7] - vertices[8]&#xA;   - vertices[9] + vertices[10] - vertices[11] - vertices[12]&#xA;   + vertices[13] + vertices[14] &amp;lt;= 0&#xA; optimality_of_node[1]: - vertices[0] - vertices[2] + vertices[3]&#xA;   + vertices[4] + vertices[5] - vertices[6] + vertices[7] + vertices[8]&#xA;   - vertices[9] + vertices[10] + vertices[11] + vertices[12]&#xA;   - vertices[13] - vertices[14] &amp;lt;= 0&#xA; optimality_of_node[2]: vertices[0] + vertices[1] - vertices[3]&#xA;   + vertices[4] - vertices[5] + vertices[6] + vertices[7] + vertices[8]&#xA;   + vertices[9] - vertices[10] + vertices[11] - vertices[12]&#xA;   - vertices[13] - vertices[14] &amp;lt;= 0&#xA; optimality_of_node[3]: - vertices[0] - vertices[1] + vertices[2]&#xA;   - vertices[4] + vertices[5] - vertices[6] + vertices[7] + vertices[8]&#xA;   + vertices[9] + vertices[10] - vertices[11] - vertices[12]&#xA;   - vertices[13] - vertices[14] &amp;lt;= 0&#xA; optimality_of_node[4]: vertices[0] - vertices[1] - vertices[2]&#xA;   + vertices[3] - vertices[5] + vertices[6] - vertices[7] - vertices[8]&#xA;   + vertices[9] + vertices[10] + vertices[11] - vertices[12]&#xA;   - vertices[13] + vertices[14] &amp;lt;= 0&#xA; optimality_of_node[5]: - vertices[0] - vertices[1] + vertices[2]&#xA;   - vertices[3] + vertices[4] - vertices[6] + vertices[7] - vertices[8]&#xA;   - vertices[9] - vertices[10] + vertices[11] + vertices[12]&#xA;   - vertices[13] + vertices[14] &amp;lt;= 0&#xA; optimality_of_node[6]: vertices[0] + vertices[1] - vertices[2]&#xA;   + vertices[3] - vertices[4] + vertices[5] + vertices[7] - vertices[8]&#xA;   + vertices[9] - vertices[10] - vertices[11] + vertices[12]&#xA;   + vertices[13] - vertices[14] &amp;lt;= 0&#xA; optimality_of_node[7]: - vertices[0] - vertices[1] - vertices[2]&#xA;   - vertices[3] + vertices[4] - vertices[5] - vertices[6] + vertices[8]&#xA;   + vertices[9] + vertices[10] - vertices[11] + vertices[12]&#xA;   + vertices[13] + vertices[14] &amp;lt;= 0&#xA; optimality_of_node[8]: vertices[0] - vertices[1] - vertices[2]&#xA;   - vertices[3] + vertices[4] + vertices[5] + vertices[6] - vertices[7]&#xA;   + vertices[9] - vertices[10] - vertices[11] + vertices[12]&#xA;   - vertices[13] + vertices[14] &amp;lt;= 0&#xA; optimality_of_node[9]: vertices[0] + vertices[1] - vertices[2]&#xA;   - vertices[3] - vertices[4] + vertices[5] - vertices[6] - vertices[7]&#xA;   - vertices[8] + vertices[10] + vertices[11] - vertices[12]&#xA;   + vertices[13] + vertices[14] &amp;lt;= 0&#xA; optimality_of_node[10]: - vertices[0] - vertices[1] + vertices[2]&#xA;   - vertices[3] - vertices[4] + vertices[5] + vertices[6] - vertices[7]&#xA;   + vertices[8] - vertices[9] + vertices[11] + vertices[12] + vertices[13]&#xA;   - vertices[14] &amp;lt;= 0&#xA; optimality_of_node[11]: vertices[0] - vertices[1] - vertices[2]&#xA;   + vertices[3] - vertices[4] - vertices[5] + vertices[6] + vertices[7]&#xA;   + vertices[8] - vertices[9] - vertices[10] - vertices[12] + vertices[13]&#xA;   + vertices[14] &amp;lt;= 0&#xA; optimality_of_node[12]: vertices[0] - vertices[1] + vertices[2]&#xA;   + vertices[3] + vertices[4] - vertices[5] - vertices[6] - vertices[7]&#xA;   - vertices[8] + vertices[9] - vertices[10] + vertices[11] + vertices[13]&#xA;   - vertices[14] &amp;lt;= 0&#xA; optimality_of_node[13]: - vertices[0] + vertices[1] + vertices[2]&#xA;   + vertices[3] + vertices[4] + vertices[5] - vertices[6] - vertices[7]&#xA;   + vertices[8] - vertices[9] - vertices[10] - vertices[11] - vertices[12]&#xA;   + vertices[14] &amp;lt;= 0&#xA; optimality_of_node[14]: - vertices[0] + vertices[1] + vertices[2]&#xA;   + vertices[3] - vertices[4] - vertices[5] + vertices[6] - vertices[7]&#xA;   - vertices[8] - vertices[9] + vertices[10] - vertices[11] + vertices[12]&#xA;   - vertices[13] &amp;lt;= 0&#xA; non_zero_solution: vertices[0] + vertices[1] + vertices[2] + vertices[3]&#xA;   + vertices[4] + vertices[5] + vertices[6] + vertices[7] + vertices[8]&#xA;   + vertices[9] + vertices[10] + vertices[11] + vertices[12]&#xA;   + vertices[13] + vertices[14] &amp;gt;= 1&#xA;Bounds&#xA;Generals&#xA; vertices[0] vertices[1] vertices[2] vertices[3] vertices[4] vertices[5]&#xA; vertices[6] vertices[7] vertices[8] vertices[9] vertices[10] vertices[11]&#xA; vertices[12] vertices[13] vertices[14]&#xA;End&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For this problem, Gurobi concludes infeasibility with the following output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Optimize a model with 16 rows, 15 columns and 225 nonzeros&#xA;Model fingerprint: 0x32656352&#xA;Variable types: 0 continuous, 15 integer (0 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [1e+00, 1e+00]&#xA;  Objective range  [1e+00, 1e+00]&#xA;  Bounds range     [0e+00, 0e+00]&#xA;  RHS range        [1e+00, 1e+00]&#xA;Presolve time: 0.00s&#xA;Presolved: 16 rows, 15 columns, 225 nonzeros&#xA;Variable types: 0 continuous, 15 integer (0 binary)&#xA;&#xA;Root relaxation: objective 1.000000e+00, 19 iterations, 0.00 seconds (0.00 work units)&#xA;&#xA;    Nodes    |    Current Node    |     Objective Bounds      |     Work&#xA; Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time&#xA;&#xA;     0     0    1.00000    0   15          -    1.00000      -     -    0s&#xA;     0     0   34.83051    0   14          -   34.83051      -     -    0s&#xA;     0     0  264.55687    0   15          -  264.55687      -     -    0s&#xA;     0     0  642.18750    0   15          -  642.18750      -     -    0s&#xA;     0     1  642.18750    0   15          -  642.18750      -     -    0s&#xA;&#xA;Cutting planes:&#xA;  Inf proof: 1&#xA;&#xA;Explored 806 nodes (1476 simplex iterations) in 0.09 seconds (0.03 work units)&#xA;Thread count was 8 (of 8 available processors)&#xA;&#xA;Solution count 0&#xA;&#xA;Model is infeasible&#xA;Best objective -, best bound -, gap -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When running &lt;code&gt;model.feasRelaxS(1, False, False, True)&lt;/code&gt; before optimization and rounding the results I get the solution that fulfils all constraints (I checked manually).&lt;/p&gt;&#xA;&lt;p&gt;The expected weighting is [1245, 339, 1515, 519, 249, 495, 295, 705, 721, 449, 993, 377, 909, 329, 1135].&lt;/p&gt;&#xA;&lt;p&gt;&lt;s&gt;I tried enforcing these values by adding them as additional equality constraints, but this still leaves the model infeasible without relaxation and with relaxation leads to a solution that is wildly off.&lt;/s&gt;&lt;/p&gt;&#xA;&lt;p&gt;I cannot make sense of Gurobis behaviour and feel like I am either missing something obvious or am facing a quirk for which I don't nearly know enough about the technical details of Gurobi to understand. So if you have any idea, I would really appreciate any tips on what might be causing this behaviour!&lt;/p&gt;&#xA;" OwnerUserId="9938" LastEditorUserId="9938" LastEditDate="2022-07-07T17:24:23.233" LastActivityDate="2022-07-11T20:23:24.407" Title="Gurobi finishes with 'infeasible' although optimal solution exists" Tags="|integer-programming|gurobi|solver|graphs|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="8650" PostTypeId="2" ParentId="8646" CreationDate="2022-07-07T15:21:38.493" Score="2" Body="&lt;p&gt;Let's say you start with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; &amp;quot;natural&amp;quot; variables and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; inequality constraints (so &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; slacks), and you are at a degenerate vertex (&lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;). Degeneracy means that more than &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; of the variables are 0 (implying that one or more basic variables are 0). It will be useful to think in terms of binding constraints. A constraint is binding if its slack is 0, and we can think of the &amp;quot;natural&amp;quot; variables as being slacks for the sign constraints &lt;span class=&quot;math-container&quot;&gt;$x\ge 0.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Before proceeding, let's note that any set of constraints that intersect at a vertex of the feasible region corresponds to a basic feasible solution. It's a basic solution because only one point satisfies those constraints as equalities, and it is feasible because, well, the vertex is feasible.&lt;/p&gt;&#xA;&lt;p&gt;Now pick a vertex that is adjacent to &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; and construct a basis for it. The edge connecting the vertices is defined by a set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; constraints that are binding at both endpoints, meaning their slacks are zero at both endpoints. (Additional redundant constraints can be binding along the edge, but they will not affect what follows.) One new constraint (&lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;) intersects the new vertex but not &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;, meaning its slack is positive at &lt;span class=&quot;math-container&quot;&gt;$V.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So to get from &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; to the new vertex, you need to pivot the slack corresponding to &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; out of the basis, pivot any of the &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; slacks corresponding to constraints in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; out of the basis if they are currently in it, and that's about it. Since any combination of binding constraints that intersect at &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; form a basis, you can just replace any of the &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; slacks in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; with the slack from some other binding constraint, one by one, then pivot the slack for &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; out of the basis. So the omniscient user should be able to do this in at most &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; pivots.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-07T15:21:38.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8651" PostTypeId="2" ParentId="8647" CreationDate="2022-07-07T16:43:07.720" Score="5" Body="&lt;p&gt;Let me add a few details of @ErlingMOSEK's answer, so the thread is self-contained.&lt;/p&gt;&#xA;&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$A\in\mathbb{R}^{m\times n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b\in\mathbb{R}^m$&lt;/span&gt;.&#xA;To determine the feasibility of &lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x\geq 0$&lt;/span&gt;, we solve the auxiliary problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\text{minimize}\quad y_1+\cdots + y_m\quad\text{subject to}\quad&#xA;Ax + y = b,\; x,y\geq 0.&#xA;$$&lt;/span&gt;&#xA;(This is &amp;quot;Phase I&amp;quot; of the simplex method.)&lt;/p&gt;&#xA;&lt;p&gt;It's easy to see that the original problem &lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x\geq 0$&lt;/span&gt; is feasible if and only if the auxiliary problem has optimal objective value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Suppose the original problem is infeasible. Then the optimal value of the auxiliary problem is strictly positive. By strong duality, this strictly positive value is also the optimal objective value of the dual of the auxiliary problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\text{maximize}\quad p^Tb\quad\text{subject to}\quad&#xA;p^T\begin{pmatrix}A&amp;amp; I_{m\times m}\end{pmatrix}\leq&#xA;\begin{pmatrix}0_n&amp;amp;1_m\end{pmatrix}&#xA;$$&lt;/span&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; realizes the strictly positive optimal value, then &lt;span class=&quot;math-container&quot;&gt;$p^Tb &amp;gt; 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p^TA\leq 0$&lt;/span&gt;, giving a Farkas certificate for the infeasibility of &lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x\geq 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9933" LastActivityDate="2022-07-07T16:43:07.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8652" PostTypeId="2" ParentId="8649" CreationDate="2022-07-07T20:03:45.043" Score="6" Body="&lt;p&gt;Setting the Parameter MIPFocus to 1 (described in the &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/mip_models.html&quot; rel=&quot;noreferrer&quot;&gt;documentation&lt;/a&gt; as putting a bigger focus on finding feasible solutions instead of proving optimality) solves the problem (at least for this specific instance).&lt;/p&gt;&#xA;&lt;p&gt;Although it feels a bit unsatisfactory since it doesn't really explain the problem I will settle for this solution for the time being (as long as there are no further suggestions) and add some more safety nets to my surrounding implementation. Thank you for your input!&lt;/p&gt;&#xA;" OwnerUserId="9938" LastActivityDate="2022-07-07T20:03:45.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8653" PostTypeId="1" CreationDate="2022-07-08T07:22:45.560" Score="2" ViewCount="63" Body="&lt;p&gt;I am invoking &lt;code&gt;cplexbilp&lt;/code&gt; (CPLEX 12.9) from Matlab R2022a.  I request all 4 return arguments:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[x,fval,exitflag,output] = cplexbilp(...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I use the variable browser to browse the 4 outputs.  Nowhere is there a relative gap.  I set the options to terminate at a relative gap of 1e-4 (0.01%), but I'd like to know what the actual relative gap is.  I know that for lengthy enough searches, the display console will show periodic updates, but my problem is solved immediately (albeit with &amp;quot;numerical issues&amp;quot;).  Will &amp;quot;numerical issues&amp;quot; prevent the appearance of a relative gap in (say) the &amp;quot;output&amp;quot; argument above, or is the relative gap simply not returned?&lt;/p&gt;&#xA;&lt;p&gt;P.S. If instead I can just get the best-bound, it would be simple to calculate the relative gap.&lt;/p&gt;&#xA;" OwnerUserId="4015" LastEditorUserId="4015" LastEditDate="2022-07-08T17:51:24.667" LastActivityDate="2022-07-08T17:51:24.667" Title="Where is the relative gap from cplexbilp?" Tags="|cplex|matlab|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8654" PostTypeId="1" CreationDate="2022-07-08T16:57:36.347" Score="2" ViewCount="64" Body="&lt;p&gt;I would like to forecast the car rental (count time series). Given hourly integer valued car rentals for a month's period from 24th september to 24th October.  I need to forecast car rental demand from 25th october to 31st October.&lt;/p&gt;&#xA;&lt;p&gt;The given data is shown below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0OhyV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0OhyV.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;strong&gt;Ground Truth&lt;/strong&gt; forecast data is given as below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cQn1Z.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cQn1Z.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I will describe my approach below. Please correct me and give your suggestions.&lt;/p&gt;&#xA;&lt;p&gt;I am using the tscount package from R. &lt;a href=&quot;https://cran.r-project.org/web/packages/tscount/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cran.r-project.org/web/packages/tscount/index.html&lt;/a&gt;&#xA;to model this data using a negative binomial distribution having a conditional mean (time varying).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LcIH6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LcIH6.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is a linear combination of logs of past means and past observations as shown below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2QMBh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2QMBh.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note: The shape parameter, &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; controls the dispersion/variance of the neg-binomial distribution but it is NOT time varying.&lt;/p&gt;&#xA;&lt;p&gt;First I computed the ACF of the given data and it is shown below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AVe5m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AVe5m.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I save the lags of the 10 largest and 10 smallest ACF values.&lt;/p&gt;&#xA;&lt;p&gt;Similarly, I plot the PACF of the given data and extract the lags due to 10 largest and smallest PACF values. Then I take the unique lags from the combination of ACF and PACF lags. It represents p in the above equation. I am setting p = q.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KHhGe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KHhGe.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then I estimate the parameters of the model using&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ts_fit_175_mon1 = tscount::tsglm(ts=ts175_mon1, link='log', model =&#xA;    list(past_obs = reg_lags, past_mean = reg_lags),distr = 'nbinom')&#xA;&#xA;summary(ts_fit_175_mon1)&#xA;tscount::scoring(ts_fit_175_mon1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The resulting fit on the given data is given in orange and scoring rules are given below.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Ezyxj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ezyxj.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SxE7f.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SxE7f.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The forecast is given below in orange&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/x4WKT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/x4WKT.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9g9jf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9g9jf.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would like to understand what are the problems with this forecast and how to improve it?&#xA;Why is the predicted peak much higher? Some of the peaks in the ground truth are not covered. What is being missed in the forecast?&lt;/p&gt;&#xA;&lt;p&gt;I tried to increase the number of parameters by including 20 largest and smallest lags from ACF and PACF plots leads to increased peaking and worse scoring values. How to better make use of ACF and PACF plots?&lt;/p&gt;&#xA;&lt;p&gt;When should I be satisfied with my forecast? When I achieve the least scoring value for a model?&lt;/p&gt;&#xA;&lt;p&gt;Is there any step that I am missing before modelling?&lt;/p&gt;&#xA;" OwnerUserId="4945" LastEditorUserId="491" LastEditDate="2022-07-11T14:02:48.203" LastActivityDate="2022-07-11T14:02:48.203" Title="How to verify the correctness of forecast?" Tags="|r|stochastic-process|time-series|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8655" PostTypeId="1" CreationDate="2022-07-08T18:38:09.877" Score="4" ViewCount="144" Body="&lt;pre&gt;&lt;code&gt;model = pyo.ConcreteModel()&#xA;opt = SolverFactory('cplex', executable = cplex_executor_path)&#xA;model.x = Var(ftHc, within = NonNegativeIntegers)&#xA;model.y = Var(ftHc, within = NonNegativeIntegers)&#xA;model.obj = pyo.Objective(expr = xyz, sense=pyo.minimize)&#xA;model.C1 = Constraint(abc, rule=abc_rule)&#xA;results = opt.solve(model,tee=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have tried to access it this way&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for v in model.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but I am getting an error saying:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;AttributeError: 'ConcreteModel' object has no attribute 'iter_integer_vars'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9940" LastEditorUserId="9940" LastEditDate="2022-07-08T18:42:23.353" LastActivityDate="2022-07-08T18:42:23.353" Title="How to invoke a solution pool and access all the solutions in cplex using PYOMO ? this is the structure of my pyomo code" Tags="|python|cplex|pyomo|cplex-python-api|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8656" PostTypeId="1" CreationDate="2022-07-08T19:41:34.387" Score="3" ViewCount="192" Body="&lt;p&gt;Pyomo can be linked with several solvers Open source and commercial ones.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering if Pyomo can be linked with Google's GLOP or CP-SAT solvers?&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="981" LastEditDate="2023-02-05T16:43:32.787" LastActivityDate="2023-02-05T16:43:32.787" Title="Can Pyomo be linked with Google's GLOP or CP-SAT solvers?" Tags="|solver|pyomo|or-tools|cp-sat|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8657" PostTypeId="1" CreationDate="2022-07-08T22:49:43.400" Score="2" ViewCount="48" Body="&lt;p&gt;I' implementing custom branching heuristics for Cplex in python.  I have a way to choose a (binary) variable to branch on, so use the following code to create two branches from BranchCallback (following one of the Cplex examples):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;self.make_branch(self.get_objective_value(), [(var_to_branch, &amp;quot;U&amp;quot;, 0)])&#xA;self.make_branch(self.get_objective_value(), [(var_to_branch, &amp;quot;L&amp;quot;, 1)])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'd like to understand if I should be more clever with the objective value estimate as I noticed that Cplex explores the tree by first trying the branches with all variables assigned value 0, which works worse than the default behaviour of Cplex. In case I need to provide better estimates, are there efficient ways of getting them other than solving relaxations myself?&lt;/p&gt;&#xA;" OwnerUserId="9588" LastActivityDate="2022-07-09T08:39:15.107" Title="Objective value estimate for branches I create in Cplex" Tags="|cplex|branch-and-bound|cplex-python-api|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8658" PostTypeId="2" ParentId="8657" CreationDate="2022-07-09T08:39:15.107" Score="2" Body="&lt;p&gt;Since&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;branching rules are crucial for the performance of solvers they are&#xA;also a very well-guarded secret. I can say from experience that some&#xA;form of reliability branching is sufficient to get a reasonable solver&#xA;performance (not top of the class though).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Also, there are some resources that might be helpful.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/52/branching-rules-in-commercial-mip-solvers&quot;&gt;Branching rules in commercial MIP solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.researchgate.net/publication/320625081_Measuring_the_impact_of_branching_rules_for_mixed-integer_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;Measuring the impact of branching rules for mixed-integer programming by Gerald Gamrath&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://users.encs.concordia.ca/%7Echvatal/workshop06/akm.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Branching rules revisited by Tobias Achterberg&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-07-09T08:39:15.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8659" PostTypeId="2" ParentId="8654" CreationDate="2022-07-09T11:41:30.587" Score="1" Body="&lt;p&gt;I am not sure about your mentioned method to forecast what you want, but as an answer to the second question, there exist many other techniques to estimate forward on the planning horizon. So there are some useful error estimators to ensure how far bias the estimated demand would have over the real demand. For Example, &lt;a href=&quot;https://en.wikipedia.org/wiki/Mean_absolute_percentage_error&quot; rel=&quot;nofollow noreferrer&quot;&gt;MAPE&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Mean_absolute_error#:%7E:text=In%20statistics%2C%20mean%20absolute%20error,an%20alternative%20technique%20of%20measurement.&quot; rel=&quot;nofollow noreferrer&quot;&gt;MAE&lt;/a&gt;, &lt;a href=&quot;https://www.statisticshowto.com/probability-and-statistics/regression-analysis/rmse-root-mean-square-error/&quot; rel=&quot;nofollow noreferrer&quot;&gt;RMSE&lt;/a&gt;, etc, might be considered to calculate the error.&lt;/p&gt;&#xA;&lt;p&gt;Also, to reduce the forecast bias you can focus on actual usage data vs. historical data. The difference: Usage reflects the actual consumption of an item. In other words, just because a product was sold to a customer doesn’t mean that product was used.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-07-09T11:41:30.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8660" PostTypeId="2" ParentId="8654" CreationDate="2022-07-09T15:58:40.187" Score="2" Body="&lt;p&gt;Regarding when to be satisfied with your model, one thing to do is to plot the forecast residuals (predicted - actual) v. time and also v. actual. If either plot exhibits a pattern, either there is a somewhat predictable (hopefully) signal in the data that your model is missing or your model is inserting a signal that is not really there.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-09T15:58:40.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8663" PostTypeId="1" CreationDate="2022-07-10T11:53:49.910" Score="2" ViewCount="39" Body="&lt;p&gt;I once read a paper stating that under certain conditions, some simple variants of dynamic capacitated lot-sizing problems can be decomposed into subproblems along the temporal dimension and solved separately while retaining optimality of the full problem. Along the lines of, starting from &lt;span class=&quot;math-container&quot;&gt;$t = 0$&lt;/span&gt;, implement a certain policy and increment &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; until some conditions are met, then the decisions up to the current &lt;span class=&quot;math-container&quot;&gt;$t'$&lt;/span&gt; are optimal regardless of what follows for &lt;span class=&quot;math-container&quot;&gt;$t &amp;gt; t'$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I cannot remember anything else about that paper. I fear that the description is too broad for lot-sizing literature, but I want to try my luck: does someone know what paper I might have in mind? I'm also interested in results regarding approximation ratios of simple dynamic lot-sizing problems. Note that I'm specifically asking about capacitated problems and decomposition along the temporal dimension.&lt;/p&gt;&#xA;" OwnerUserId="869" LastActivityDate="2022-07-13T08:18:58.717" Title="Optimality guarantees/approximation ratios for simple dynamic capacitated lot-sizing problems" Tags="|reference-request|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8664" PostTypeId="1" CreationDate="2022-07-10T13:59:42.467" Score="-4" ViewCount="119" Body="&lt;p&gt;I was recommended to use Octeract. I went to their website but it did not open for me.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://octeract.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://octeract.com/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Am I the only one facing this problem? Where can I get the student license?&lt;/p&gt;&#xA;" OwnerUserId="9948" LastActivityDate="2022-07-10T15:24:09.220" Title="Octeract website is not working" Tags="|nonlinear-programming|" AnswerCount="1" CommentCount="2" ClosedDate="2022-07-15T15:46:54.393" ContentLicense="CC BY-SA 4.0" />
  <row Id="8665" PostTypeId="2" ParentId="8664" CreationDate="2022-07-10T15:24:09.220" Score="2" Body="&lt;p&gt;It's not just you ... and there is no need to use a forum post (which will not age well) to find out. For future reference, you might try &lt;a href=&quot;https://downforeveryoneorjustme.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Down for Everyone or Just Me&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-10T15:24:09.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8666" PostTypeId="1" CreationDate="2022-07-10T19:25:35.540" Score="2" ViewCount="74" Body="&lt;p&gt;I want to find the &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; that solves the matrix equation&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ AX = B $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; known, moreover:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$ A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; are rectangular, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$n \times m $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$m \times n$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$m &amp;gt; n$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is diagonal with non-zero entries (and is therefore invertible).&lt;/li&gt;&#xA;&lt;li&gt;The rows of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; must sum to &lt;span class=&quot;math-container&quot;&gt;$ \leq 1. $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The entries of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; lie between 0 and 1.&lt;/li&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$A_{ij} = 0 $&lt;/span&gt; then we know that &lt;span class=&quot;math-container&quot;&gt;$X_{ji} = 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is pretty sparse (in fact, usually each row will have an average of ~3 non zero entries)&lt;/li&gt;&#xA;&lt;li&gt;I expect that the system has many solutions, so that &lt;span class=&quot;math-container&quot;&gt;$ \det(A^TA) = 0 $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I was trying to solve this using different numerical iterative methods &lt;a href=&quot;https://en.wikipedia.org/wiki/Iterative_method#Convergence_of_Krylov_subspace_methods&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; but I am told given the number of inequalities, linear programming is actually the way forward.&lt;/p&gt;&#xA;&lt;p&gt;Though I am not sure the framework for setting all this up. If we take &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; as the objective function, how would one encode the very many constraints?&lt;/p&gt;&#xA;&lt;p&gt;Any hints in the right direction will be greatly appreciated!&lt;/p&gt;&#xA;&lt;p&gt;For more context:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$A_{ji}$&lt;/span&gt; represents the maximum number of spaces that an entity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; can take up, in within region &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{ij}$&lt;/span&gt; is the ratio of entity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in region &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The diagonal entries of &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; therefore present the total actual spaces taken up by entity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, across all regions &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For dimensions, specifically for my case, &lt;span class=&quot;math-container&quot;&gt;$ m = 250$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n = 15$&lt;/span&gt;. This puts &lt;span class=&quot;math-container&quot;&gt;$4000$&lt;/span&gt; unknowns in &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, although very many are zero.&lt;/li&gt;&#xA;&lt;li&gt;The regions indexed by &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;, are in this case chosen based of the different intersections of entities in a region. All entities have an influence on one another - we are making the naive assumption that within any region &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, the ratio of entity &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in this region &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is constant.&lt;/li&gt;&#xA;&lt;li&gt;So in reality this means &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is very sparse (usually, no more two or three entities are competing in a group) and also, it means that the ratio &lt;span class=&quot;math-container&quot;&gt;$X_{ij}$&lt;/span&gt; can be assumed to be zero when &lt;span class=&quot;math-container&quot;&gt;$A_{ji}$&lt;/span&gt; is zero.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9949" LastEditorUserId="9949" LastEditDate="2022-07-11T07:13:26.147" LastActivityDate="2022-07-11T07:13:26.147" Title="Formulating a matrix linear programming problem" Tags="|linear-programming|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8667" PostTypeId="1" CreationDate="2022-07-11T07:36:08.893" Score="1" ViewCount="164" Body="&lt;p&gt;For a linear optimization problem I want to include a dataframe (d_ij) which has binary variables,&#xA;1 if customer i is located within the assignable distance of facility j, 0 otherwise. So unless d_ij = 1, the customer cannot be assigned to a facility.&#xA;To create the model, I have introduced a binary variable X_ij (for customers) and Y_j (for the facilities)&lt;/p&gt;&#xA;&lt;p&gt;The dataframe is constructed as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#creating distance function&#xA;e &amp;lt;- function(i, j) {&#xA;  customer &amp;lt;- data[i, ]&#xA;  facility &amp;lt;- facility_locations[j, ]&#xA;  (sqrt((customer&lt;span class=&quot;math-container&quot;&gt;$x - facility$&lt;/span&gt;x)^2 + (customer&lt;span class=&quot;math-container&quot;&gt;$y - facility$&lt;/span&gt;y)^2))&#xA;}&#xA;&#xA;&#xA;#with ifelse function, we model if the distance between consumer and facility is smaller than z =1, 0 otherwise&#xA;&#xA;deltaframe &amp;lt;- data.frame(&#xA;  customer=data&lt;span class=&quot;math-container&quot;&gt;$ID,&#xA;  &quot;j1&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==1)&amp;lt;z,1,0),&#xA;  &quot;j2&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==2)&amp;lt;z,1,0),&#xA;  &quot;j3&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==3)&amp;lt;z,1,0),&#xA;  &quot;j4&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==4)&amp;lt;z,1,0),&#xA;  &quot;j5&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==5)&amp;lt;z,1,0),&#xA;  &quot;j6&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==6)&amp;lt;z,1,0),&#xA;  &quot;j7&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==7)&amp;lt;z,1,0),&#xA;  &quot;j8&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==8)&amp;lt;z,1,0),&#xA;  &quot;j9&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==9)&amp;lt;z,1,0),&#xA;  &quot;j10&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==10)&amp;lt;z,1,0),&#xA;  &quot;j11&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==11)&amp;lt;z,1,0),&#xA;  &quot;j12&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==12)&amp;lt;z,1,0),&#xA;  &quot;j13&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==13)&amp;lt;z,1,0),&#xA;  &quot;j14&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==14)&amp;lt;z,1,0),&#xA;  &quot;j15&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==15)&amp;lt;z,1,0),&#xA;  &quot;j16&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==16)&amp;lt;z,1,0),&#xA;  &quot;j17&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==17)&amp;lt;z,1,0),&#xA;  &quot;j18&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==18)&amp;lt;z,1,0),&#xA;  &quot;j19&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations&lt;span class=&quot;math-container&quot;&gt;$ID==19)&amp;lt;z,1,0),&#xA;  &quot;j20&quot; =ifelse(e(data$&lt;/span&gt;ID, facility_locations$ID==20)&amp;lt;z,1,0)&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here z is a parameter, set to be the maximum distance a customer is willing to travel.&lt;/p&gt;&#xA;&lt;p&gt;The constraint I try to model is&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{ij} &amp;lt;= d_{ij} * y_j $&lt;/span&gt;  for all i and for all j&lt;/p&gt;&#xA;&lt;p&gt;However, I do not know how to include this in r&lt;/p&gt;&#xA;" OwnerUserId="9867" LastEditorUserId="67" LastEditDate="2022-07-11T15:15:13.020" LastActivityDate="2022-07-13T10:42:41.403" Title="Include dataframe linear optimization in r" Tags="|integer-programming|r|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8668" PostTypeId="1" CreationDate="2022-07-11T18:34:51.873" Score="2" ViewCount="26" Body="&lt;p&gt;I'm using the TOPSIS and VIKOR multicriteria methods to generate rankings according to the decision matrix that I call a &lt;code&gt;database&lt;/code&gt;. I would like to know if the normalized decision matrix is already embedded in the &lt;code&gt;TOPSIS&lt;/code&gt; and &lt;code&gt;VIKOR&lt;/code&gt; function, since the results are generated from the normalized decision matrix. Can anyone tell me something about this? So are my results correct that way or would I need to normalize my &lt;code&gt;database&lt;/code&gt; decision matrix first?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;library(topsis)&#xA;library(MCDM)&#xA;&#xA;database &amp;lt;- structure(c(790.07529753148, 987.560758390604, 1717.41117836404, &#xA;1257.03757052034, 1155.65871783395, 1114.47680404529, 965.589449089402, &#xA;860.041671387026, 774.152044283882, 570.169757216762, 563.787227344011, &#xA;1254.976476, 1216.074832, 315.114268, 295.3384, 295.3384, 229.824, &#xA;229.824, 229.824, 229.310304, 229.310304, 29.856976), .Dim = c(11L, &#xA;2L),.Dimnames = list(NULL, c(&amp;quot;C1&amp;quot;, &amp;quot;C2&amp;quot;)))&#xA;&#xA;&amp;gt; database&#xA;             C1         C2&#xA; [1,]  790.0753 1254.97648&#xA; [2,]  987.5608 1216.07483&#xA; [3,] 1717.4112  315.11427&#xA; [4,] 1257.0376  295.33840&#xA; [5,] 1155.6587  295.33840&#xA; [6,] 1114.4768  229.82400&#xA; [7,]  965.5894  229.82400&#xA; [8,]  860.0417  229.82400&#xA; [9,]  774.1520  229.31030&#xA;[10,]  570.1698  229.31030&#xA;[11,]  563.7872   29.85698&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;TOPSIS&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;w &amp;lt;- c(0.5,0.5) &#xA;i &amp;lt;- c(&amp;quot;-&amp;quot;, &amp;quot;+&amp;quot;) &#xA;result1&amp;lt;-topsis(database, w, i)&#xA;&#xA;&amp;gt; result1&#xA;   alt.row     score rank&#xA;1        1 0.9135330    1&#xA;2        2 0.8400032    2&#xA;3        3 0.2004466   11&#xA;4        4 0.2628604   10&#xA;5        5 0.2877750    8&#xA;6        6 0.2673059    9&#xA;7        7 0.3063391    7&#xA;8        8 0.3323752    6&#xA;9        9 0.3521251    4&#xA;10      10 0.3945119    3&#xA;11      11 0.3436264    5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;VIKOR&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  w &amp;lt;- c(0.5,0.5)&#xA;  cb &amp;lt;- c('min','max')&#xA;  v &amp;lt;- 0.5&#xA;  result2&amp;lt;-VIKOR(database,w,cb,v)&#xA;&#xA;&amp;gt; result2&#xA;   Alternatives          S          R         Q Ranking&#xA;1             1 0.09807705 0.09807705 0.0000000       1&#xA;2             2 0.19954724 0.18367057 0.1710693       2&#xA;3             3 0.88357981 0.50000000 1.0000000      11&#xA;4             4 0.69211715 0.39165080 0.7433388       8&#xA;5             5 0.64817785 0.39165080 0.7153699       7&#xA;6             6 0.65706688 0.41838877 0.7542906       9&#xA;7             7 0.59253660 0.41838877 0.7132148       6&#xA;8             8 0.54679042 0.41838877 0.6840958       5&#xA;9             9 0.50977406 0.41859842 0.6607944       4&#xA;10           10 0.42136471 0.41859842 0.6045188       3&#xA;11           11 0.50000000 0.50000000 0.7558380      10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9063" LastEditorUserId="9063" LastEditDate="2022-07-11T19:00:38.283" LastActivityDate="2022-07-11T19:00:38.283" Title="Matrix normalization to use multicriteria methods" Tags="|r|multicriteria-decision-analysis|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8669" PostTypeId="1" AcceptedAnswerId="8671" CreationDate="2022-07-11T18:52:55.913" Score="5" ViewCount="556" Body="&lt;p&gt;I'm trying to schedule power of multiple prosumers in a microgrid.&#xA;The problem includes a cost function with &lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; statements since I want to distinguish between the prices for importing and exporting energy.&lt;/p&gt;&#xA;&lt;p&gt;The following is a minimal example for the cost function without summing over all timesteps at the moment:&lt;/p&gt;&#xA;&lt;p&gt;I have two decision variables &lt;span class=&quot;math-container&quot;&gt;$P_{charge}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_{discharge}$&lt;/span&gt; for the battery storage (one of it is assumed to be always zero) and one other controllable load &lt;span class=&quot;math-container&quot;&gt;$P_{load}$&lt;/span&gt;. Consumption is denoted with positive and generation with negative values. &lt;span class=&quot;math-container&quot;&gt;$C_{import}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_{export}$&lt;/span&gt; are the per unit prices for importing and exporting energy.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C = max((P_{charge} + P_{discharge} + P_{load}) \cdot \Delta T,0) \cdot C_{import} + min((P_{charge} + P_{discharge} + P_{load}) \cdot \Delta T,0) \cdot C_{export}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; functions form &lt;code&gt;if-else&lt;/code&gt; statements to check if the sum of power flows is negative or positive.&#xA;Is it possible to introduce some binary decision variables to transform it into a MILP? I want to use a Matlab solver later.&lt;/p&gt;&#xA;&lt;p&gt;Edit 1:&lt;/p&gt;&#xA;&lt;p&gt;I have tried to introduce the proposed auxiliary variables but they do not match the desired values I computed from my simulation. So maybe I have to clarify the problem. At first, I simplify power flow of battery to one bidirectional power variable to reduce the problem further.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wzsMQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wzsMQ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The image shows a part of my problem.&#xA;My objective is to maximize &lt;span class=&quot;math-container&quot;&gt;$R - C$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$R \ge 0$&lt;/span&gt; is revenue and &lt;span class=&quot;math-container&quot;&gt;$C \ge 0$&lt;/span&gt; is cost. Per unit prices are always greater than or equal to zero and &lt;span class=&quot;math-container&quot;&gt;$C_{import} &amp;gt; C_{export}$&lt;/span&gt; is valid for now. The nonlinear version would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$R = min(P_{load} + P_{BSS},0) \cdot (-1) \cdot C_{export}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$C = max(P_{load} + P_{BSS},0) \cdot C_{import}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have defined non-negative decision variables &lt;span class=&quot;math-container&quot;&gt;$X_{import}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_{export}$&lt;/span&gt; with the line capacity (energy per timestep) as upper boundary. Additionally I've introduced following equality constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$(P_{load} + P_{BSS}) \cdot \Delta T == X_{import} - X_{export}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I neglected the injected PV power at this node for now. My goal is to be somehow able to use the auxiliary variables for an upper level node.&#xA;Maybe I didn't fully understand the proposed answers which might led to the undesired result.&lt;/p&gt;&#xA;" OwnerUserId="9955" LastEditorUserId="491" LastEditDate="2024-02-21T23:13:20.960" LastActivityDate="2024-02-21T23:13:20.960" Title="Transform nonlinear cost function to get LP or MILP" Tags="|mixed-integer-programming|linear-programming|linearization|nonlinear-programming|matlab|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8670" PostTypeId="2" ParentId="8669" CreationDate="2022-07-11T19:01:17.250" Score="6" Body="&lt;p&gt;Assuming you meant &lt;span class=&quot;math-container&quot;&gt;$C=\max() - \min()$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$C=\max() + \min()$&lt;/span&gt;,&#xA;you can introduce nonnegative variables&#xA;&lt;span class=&quot;math-container&quot;&gt;$X_\text{import}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_\text{export}$&lt;/span&gt;&#xA;and linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(P_\text{charge} + P_\text{discharge} + P_\text{load}) \cdot \Delta T = X_\text{import} - X_\text{export}$$&lt;/span&gt;&#xA;and then minimize the linear function&#xA;&lt;span class=&quot;math-container&quot;&gt;$$C_\text{import} X_\text{import} + C_\text{export} X_\text{export}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-07-11T19:01:17.250" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8671" PostTypeId="2" ParentId="8669" CreationDate="2022-07-11T19:27:43.900" Score="6" Body="&lt;p&gt;Taking a different tack from Rob, I'm going to assume that the original objective function &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is correct as stated and is being minimized, with &lt;span class=&quot;math-container&quot;&gt;$C_\text{export}&amp;gt;0$&lt;/span&gt; being a per-unit compensation value for exported energy (i.e., you pay to import and get paid to export). In that case, splitting the energy expression into &lt;span class=&quot;math-container&quot;&gt;$X_\text{import} - X_\text{export}$&lt;/span&gt; as Rob does will work if &lt;span class=&quot;math-container&quot;&gt;$C_\text{import} &amp;gt; C_\text{export}$&lt;/span&gt; but will not work with &lt;span class=&quot;math-container&quot;&gt;$C_\text{import} &amp;lt; C_\text{export},$&lt;/span&gt; since in the latter case the solver could add an arbitrary amount &lt;span class=&quot;math-container&quot;&gt;$\delta &amp;gt; 0$&lt;/span&gt; to both &lt;span class=&quot;math-container&quot;&gt;$X_\text{import}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_\text{export},$&lt;/span&gt; keeping the energy value the same while reaping an undeserved profit of &lt;span class=&quot;math-container&quot;&gt;$(C_\text{export} - C_\text{import})\delta.$&lt;/span&gt; In this case, you have to introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and constraints &lt;span class=&quot;math-container&quot;&gt;$$X_\text{import}\le M_\text{import}\cdot Y$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$X_\text{export}\le M_\text{export}\cdot (1-Y),$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M_\text{import}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_\text{export}$&lt;/span&gt; are upper bounds on the amount of energy that could be imported or exported.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-11T19:27:43.900" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8672" PostTypeId="2" ParentId="8649" CreationDate="2022-07-11T20:23:24.407" Score="6" Body="&lt;p&gt;Here's a further suggestion.&lt;/p&gt;&#xA;&lt;p&gt;The Gurobi developers are looking into this.   Based on what they have found so far, setting the InfProofCuts parameter to 0 will avoid the problem consistently.  This is a more robust workaround than setting the MIPFocus parameter to 1, which does change the intensity with which Gurobi applies cuts, but I don't think it guarantees that the InfProofCuts will not be applied.&lt;/p&gt;&#xA;&lt;p&gt;Hopefully this is somewhat more satisfactory.   We'll update when we have a better idea of what happened with these cuts on this model.&lt;/p&gt;&#xA;" OwnerUserId="820" LastActivityDate="2022-07-11T20:23:24.407" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8673" PostTypeId="2" ParentId="8633" CreationDate="2022-07-12T08:05:00.067" Score="2" Body="&lt;p&gt;It is equivalent to say that there exists a permutation of &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;, say &lt;span class=&quot;math-container&quot;&gt;$c_{(i)}$&lt;/span&gt;, that satisfies&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f_i(x) \geq c_{(i)},\quad \forall i=1,\dots, n&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The permutation &lt;span class=&quot;math-container&quot;&gt;$c_{(i)}$&lt;/span&gt; could be expressed with a permutation matrix&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f_i(x) \geq \sum_{j} b_{ij}c_{j},\quad\forall i\\&#xA;\sum_{i} b_{ij} = 1,\quad\forall j\\&#xA;\sum_{j} b_{ij} = 1,\quad\forall i\\&#xA;b_{ij} \in \{0, 1\},\quad\forall i, j&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Edit: After testing, my formulation is correct but it is significantly slower than the model in the previous answer.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastEditorUserId="4569" LastEditDate="2022-07-12T08:42:22.750" LastActivityDate="2022-07-12T08:42:22.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8674" PostTypeId="1" AcceptedAnswerId="8677" CreationDate="2022-07-12T08:11:05.130" Score="4" ViewCount="206" Body="&lt;p&gt;I want to solve the &lt;em&gt;Group Closeness Centrality&lt;/em&gt; problem where the input is a graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; and integer &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and we want to find a vertex set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of size &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; minimizing the total distance of the vertices in &lt;span class=&quot;math-container&quot;&gt;$V\setminus S$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. Here, the distance of a vertex &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is defined as the length of a shortest path starting in &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; and ending at some vertex of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am using an ILP formulation with binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{v,d}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_{v,d}=1$&lt;/span&gt; if vertex &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; has distance &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d\in \{1,\ldots, diam(G)\}$&lt;/span&gt;. Here, &lt;span class=&quot;math-container&quot;&gt;$diam(G)$&lt;/span&gt; is the diameter of &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;, the length of longest shortest path in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The objective function is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{v\in V}\;\sum_{d\in \{1,\ldots,diam(G)\}} d\cdot x_{v,d}.$$&lt;/span&gt;&#xA;The constraints are&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{v\in V} x_{v,0} = k$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{d\in \{0,\ldots,diam(G)\}} x_{v,d}=1\, \forall {v\in V}$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{v,d}\le \sum_{u\in N_d(v)} x_{u,0}\, \forall {v\in V}\, \forall {d\in \{1,\ldots,diam(G)-1\}}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The first constraint ensures that we select &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; vertices, the second that the distance to &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is well-defined. The third constraint ensures that for &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; to have distance &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, we must select a vertex in the &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;-neighborhood of &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am looking at improved formulations and I want to use an approach where for every vertex we do not consider variables &lt;span class=&quot;math-container&quot;&gt;$x_{v,d}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$d\in \{0,\ldots, diam(G)\}$&lt;/span&gt; but only for values &lt;span class=&quot;math-container&quot;&gt;$d\in \{0,\ldots, d(v)\}$&lt;/span&gt;, for some value &lt;span class=&quot;math-container&quot;&gt;$d(v)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Initially, &lt;span class=&quot;math-container&quot;&gt;$d(v)=2$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$v\in V$&lt;/span&gt;. Now this means that if we select a vertex, then it contributes 0 to the objective, if we select a neighbor, then it contributes 1, and otherwise, we get a contribution of 2. Now if we find a solution where every vertex contributes 1 (i.e. if &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; has a dominating set of size &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;), then we are done. Otherwise, we find a vertex &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; that contributes &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; and increase the &lt;span class=&quot;math-container&quot;&gt;$d(v)$&lt;/span&gt;-value for this vertex. More precisely, we add a further variable &lt;span class=&quot;math-container&quot;&gt;$x_{v,d(v)}$&lt;/span&gt; and the corresponding constraint, and afterwards increase &lt;span class=&quot;math-container&quot;&gt;$d(v)$&lt;/span&gt; by one.&lt;/p&gt;&#xA;&lt;p&gt;After this long explanation, here are my questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is it appropriate to call this approach column generation or does it have another name?&lt;/li&gt;&#xA;&lt;li&gt;When I implement this (hopefully) improved formulation in CPLEX, is it necessary to solve the main problem from scratch after adding a variable, or is there some way of adding the variables in a lazy manner?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="158" LastEditorUserId="67" LastEditDate="2022-07-13T02:34:21.563" LastActivityDate="2022-07-13T02:54:09.687" Title="Is this ILP formulation for Group Closeness Centrality a column generation approach?" Tags="|integer-programming|cplex|graphs|column-generation|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8675" PostTypeId="2" ParentId="8674" CreationDate="2022-07-12T11:32:05.663" Score="3" Body="&lt;p&gt;This formulation may be helpful.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; as the value of the shortest path between vertices &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. Define&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_j\in \{0,1\}$&lt;/span&gt;; where &lt;span class=&quot;math-container&quot;&gt;$x_j=1$&lt;/span&gt; if the vertex &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is selected in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{ij}\in \{0,1\}$&lt;/span&gt;; where &lt;span class=&quot;math-container&quot;&gt;$y_{ij}=1$&lt;/span&gt; if the vertex &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to the selected vertex &lt;span class=&quot;math-container&quot;&gt;$j\in S$&lt;/span&gt;; i.e. &lt;span class=&quot;math-container&quot;&gt;$j\in S$&lt;/span&gt; and minimum distance from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, solve an ILP for minimization of &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j} d_{ij}y_{ij}$&lt;/span&gt; subject to the constraints &lt;span class=&quot;math-container&quot;&gt;$\sum_j x_j=k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_j y_{ij}=1\ \ \forall i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{ij}\le x_j \ \ \forall i,j$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9679" LastActivityDate="2022-07-12T11:32:05.663" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8676" PostTypeId="2" ParentId="8667" CreationDate="2022-07-12T13:36:12.420" Score="3" Body="&lt;p&gt;MILP modelling in R is not as advanced or convenient as it is in Python or Julia. Few exceptions I know about are &lt;a href=&quot;https://r-forge.r-project.org/projects/roi/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ROI&lt;/a&gt; and &lt;a href=&quot;https://github.com/dirkschumacher/ompr&quot; rel=&quot;nofollow noreferrer&quot;&gt;ompr&lt;/a&gt; packages. ompr seems to be actively maintained thanks to Dirk Schumacher.&lt;/p&gt;&#xA;&lt;p&gt;edit: &lt;a href=&quot;https://cran.r-project.org/web/views/Optimization.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is a more comprehensive list.&lt;/p&gt;&#xA;&lt;p&gt;If you are just looking for presenting solutions or solving in a purely functional/algebraic way you might want to check &lt;a href=&quot;https://cran.r-project.org/web/packages/plyr/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;plyr&lt;/a&gt; package for apply-style implementations such as mdply, ddply or ldply. purrr package is also a good alternative.&lt;/p&gt;&#xA;" OwnerUserId="4496" LastEditorUserId="4496" LastEditDate="2022-07-12T15:01:42.677" LastActivityDate="2022-07-12T15:01:42.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8677" PostTypeId="2" ParentId="8674" CreationDate="2022-07-12T15:48:53.220" Score="7" Body="&lt;p&gt;I would not call the approach column generation. That term is usually applied to methods where columns are constructed using information from the solution of a previous version of the problem. What you are doing is iterating over progressively larger values of a parameter (the maximum value considered for &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;). So I would characterize it as an &amp;quot;iterative&amp;quot; approach.&lt;/p&gt;&#xA;&lt;p&gt;As far as &amp;quot;hot-starting&amp;quot; CPLEX, you can try to hand CPLEX a feasible starting solution by modifying the solution to the previous problem manually. So, for instance, if you have a vertex &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; that contributes value 2 (the max allowed) and you increase the max to 3, you can construct a solution to the new problem by copying the solution to the previous problem and then setting &lt;span class=&quot;math-container&quot;&gt;$x_{v,2}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{v,3}$&lt;/span&gt; appropriately. All the APIs (as far as I know) have methods to set a candidate starting solution.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-12T15:48:53.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8678" PostTypeId="2" ParentId="8674" CreationDate="2022-07-12T17:43:05.490" Score="5" Body="&lt;p&gt;Here is an alternative model that might be easier to solve (or not -- see the update at the end). Let &lt;span class=&quot;math-container&quot;&gt;$N(i)\subseteq V$&lt;/span&gt; be the set of neighbors of &lt;span class=&quot;math-container&quot;&gt;$i\in V$&lt;/span&gt; (nodes connected to &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; by an edge). We introduce one binary variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; for each node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (1 if the node goes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, 0 if not) and two nonnegative continuous variables &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{j,i}$&lt;/span&gt; for each edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in E,$&lt;/span&gt; representing flows. The objective is &lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{(i,j)\in E} \left( y_{i,j} + y_{j,i} \right),$$&lt;/span&gt; which charges each unit of flow 1 for each edge it crosses. The constraints are &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in V} x_i = k$$&lt;/span&gt; (to get the desired size for &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j \in N(i)} \left( y_{i,j} - y_{j,i} \right) \ge 1 - M\cdot x_i \quad \forall i\in V.$$&lt;/span&gt; The latter constraints say that the flow out of a node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; must be at least one greater than the flow in unless &lt;span class=&quot;math-container&quot;&gt;$i\in S.$&lt;/span&gt; For a sufficiently large value of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; (I think &lt;span class=&quot;math-container&quot;&gt;$M = \vert V \vert - k$&lt;/span&gt; will suffice), the constraint allows a node &lt;span class=&quot;math-container&quot;&gt;$i\in S$&lt;/span&gt; to soak up any plausible amount of incoming flow without spitting out anything.&lt;/p&gt;&#xA;&lt;p&gt;Given a solution for &lt;span class=&quot;math-container&quot;&gt;$x,$&lt;/span&gt; the flows that minimize total arc &amp;quot;costs&amp;quot; will automatically have nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; soak up all incoming flow and nodes not in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; contribute one unit of flow. The unit of flow coming out of a node &lt;span class=&quot;math-container&quot;&gt;$i \notin S$&lt;/span&gt; will automatically take the shortest path to a node in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; since to do otherwise would inflate the objective value.&lt;/p&gt;&#xA;&lt;p&gt;The model contains &lt;span class=&quot;math-container&quot;&gt;$\vert V \vert$&lt;/span&gt; binary variables and &lt;span class=&quot;math-container&quot;&gt;$2\cdot \vert E \vert$&lt;/span&gt; continuous variables.&lt;/p&gt;&#xA;&lt;p&gt;Update: I tried both this model and that of question's author on a few sparse graphs, using CPLEX as the solver. The author's model beat mine handily every time.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-07-13T02:54:09.687" LastActivityDate="2022-07-13T02:54:09.687" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8679" PostTypeId="2" ParentId="8667" CreationDate="2022-07-12T19:14:43.690" Score="1" Body="&lt;p&gt;Hope this helps.  You'll need to learn the basics of &lt;code&gt;ompr&lt;/code&gt;, which is an awesome package.  I use it regularly, including with Gurobi for large-scale optimizations.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://towardsdatascience.com/supply-chain-design-using-r-unconstrained-warehouse-customer-alignment-9ec11c1e4345&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://towardsdatascience.com/supply-chain-design-using-r-unconstrained-warehouse-customer-alignment-9ec11c1e4345&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3958" LastActivityDate="2022-07-12T19:14:43.690" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8680" PostTypeId="1" CreationDate="2022-07-12T20:00:45.447" Score="2" ViewCount="457" Body="&lt;p&gt;What is currently the exact method to solve the TSP which performs best on average regarding computation time?&lt;/p&gt;&#xA;" OwnerUserId="50" LastActivityDate="2022-07-27T09:48:56.850" Title="Best exact method to solve TSP" Tags="|traveling-salesman|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8681" PostTypeId="2" ParentId="8663" CreationDate="2022-07-13T08:18:58.717" Score="1" Body="&lt;p&gt;&lt;strong&gt;First type:&lt;/strong&gt; The decomposition of the lot-sizing variant problems more than being studied as an academic literature does have a practical background. The heuristic-based decomposition approach focuses on decomposing the problem into the single item lot-sizing as a sub-problems along the temporal dimension or planning horizon is well known as a closed-loop MRP or MRP-II which is the core of many of the modern ERP/APS software. (Whose steps can be easily found by googling).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;second type:&lt;/strong&gt; As the mathematical decomposition approach, there are various decomposition algorithms:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Algorithms based on valid inequalities or extended formulations for the&#xA;subproblems&lt;/li&gt;&#xA;&lt;li&gt;Algorithms based on Lagrangian relaxation or column generation that&#xA;are the algorithms of choice for many classes of problems in which it&#xA;is relatively easy in practice to optimize over the “subproblems,” but&#xA;little is known about improved formulations&lt;/li&gt;&#xA;&lt;li&gt;Hybrid algorithms that combine both approaches&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For the second type of reformulation, I refer you to &lt;a href=&quot;https://link.springer.com/book/10.1007/0-387-33477-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Production Planning&#xA;by Mixed Integer Programming by Yves Pochet &amp;amp; Laurence A. Wolsey&lt;/em&gt;&lt;/a&gt;, specifically, chapter &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-07-13T08:18:58.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8683" PostTypeId="1" AcceptedAnswerId="8685" CreationDate="2022-07-13T11:24:22.963" Score="3" ViewCount="291" Body="&lt;p&gt;I have two data frames, the first indicating customer locations and the second indicating facility locations.&#xA;I want to calculate the average distance of all customers to the closest facility location&lt;/p&gt;&#xA;&lt;p&gt;Facility locations are calculated as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;grid_size &amp;lt;- 20&#xA;m &amp;lt;- 10&#xA;facility_locations &amp;lt;- data.frame(&#xA;  ID = 1:m,&#xA;  x = runif(m) * grid_size,&#xA;  y = runif(m) * grid_size)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And around that, customers are located in the following fashion:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;generateGaussianData &amp;lt;- function(n, center, sigma, label) {&#xA;  data = rmvnorm(n, mean = center, sigma = sigma)&#xA;  data = data.frame(data)&#xA;  names(data) = c(&amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;)&#xA;  data = data %&amp;gt;% mutate(class=factor(label))&#xA;  data&#xA;}&#xA;dataset1 &amp;lt;- {&#xA;  # cluster 1&#xA;  q = 30&#xA;  center = c(facility_locations[1,2], facility_locations[1,3])&#xA;  sigma = matrix(c(3, 0, 0, 3), nrow = 2)&#xA;  data1 = generateGaussianData(q, center, sigma, 1) &#xA;&#xA;#cluster 2 - 10 constructued in the same way#&#xA;&#xA;data = bind_rows(data1, data2, data3, data4, data5, data6, data7, data8, data9,&#xA;                   data10)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is based on : &lt;a href=&quot;https://www.r-bloggers.com/2018/11/generate-datasets-to-understand-some-clustering-algorithms-behavior/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.r-bloggers.com/2018/11/generate-datasets-to-understand-some-clustering-algorithms-behavior/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Preferably, I would get a formula that gives me the average distance of all customers to the closest facility location. Note this is can be different from the center of the cluster in which they are generated due to the spread.&lt;/p&gt;&#xA;" OwnerUserId="9867" LastActivityDate="2022-07-16T13:36:26.537" Title="How to calculate the average distance between two points in seperate dataframes in r" Tags="|r|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8684" PostTypeId="1" AcceptedAnswerId="8695" CreationDate="2022-07-13T14:17:00.403" Score="10" ViewCount="440" Body="&lt;p&gt;Given a quadratic program&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f^* \equiv x^\top Q x + b^\top x \\&#xA;x \geq 0 \\&#xA;A^\top x = d \\&#xA;x \in \mathbb{R}^n&#xA;$$&lt;/span&gt;&#xA;I would like to analyze the sensitivity of the solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; to perturbations in &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&#xA;Could anything be said regarding variations of &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; depending on for instance variations in &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; with respect to a matrix norm?&#xA;One special case that could be interesting is if the equality constraint is replaced by &lt;span class=&quot;math-container&quot;&gt;$1^\top x = 1$&lt;/span&gt;, i.e., the QP is solved on the simplex.&lt;/p&gt;&#xA;&lt;p&gt;One special case analysis I found is for the linear least squares problem, see [On the Perturbation of Pseudo-Inverses, Projections and Linear Least Squares Problems, SIAM Review Vol. 19, No. 4 (Oct., 1977), pp. 634-662].&#xA;However, this does not generalize to the quadratic program in a straightforward manner.&lt;/p&gt;&#xA;" OwnerUserId="9961" LastEditorUserId="9961" LastEditDate="2022-07-13T19:33:10.307" LastActivityDate="2022-07-15T09:40:23.420" Title="Sensitivity analysis of QP" Tags="|quadratic-programming|sensitivity-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8685" PostTypeId="2" ParentId="8683" CreationDate="2022-07-13T19:23:09.867" Score="2" Body="&lt;p&gt;It is not explicit in your question, so I am going to assume that you want to match each customer to the closest facility regardless of label (meaning a customer with label 3 might be matched with facility 7). The following function takes as input the x and y coordinates of a customer and returns the minimum euclidean distance to any facility.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;closest &amp;lt;- function(x, y) {&#xA;  apply(facility_locations, 1,&#xA;        function(x) norm(as.numeric(x[2:3]) - c(x, y), type = &amp;quot;2&amp;quot;)) %&amp;gt;% &#xA;     min()&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The next bit of code creates a new column (&lt;code&gt;MinDist&lt;/code&gt;) in the &lt;code&gt;data&lt;/code&gt; dataframe, listing the minimum distance to any facility for each customer.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;data &amp;lt;- data %&amp;gt;% rowwise() %&amp;gt;% mutate(MinDist = closest(x, y))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;From there, you can compute mean, median or any other static you like from the new column.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-13T19:23:09.867" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8688" PostTypeId="1" CreationDate="2022-07-14T10:30:39.247" Score="3" ViewCount="632" Body="&lt;p&gt;My understanding is Constraint programming (CP) is a sub-set of MILP but in MILP we not only try to find a feasible solution (like CP) but also we should optimize an objective function.&#xA;I do have a large-scale Job Shop Scheduling problem (40k binary variables) and I need to find a fast and efficient way of finding a feasible solution (preferably without any commercial solver).&#xA;I am familiar with GAMS and Pyomo (and they both use solvers).&lt;/p&gt;&#xA;&lt;p&gt;Any advice on the available resources for solving CP or MILP models?&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2022-07-14T10:38:08.400" LastActivityDate="2022-07-14T15:06:58.973" Title="What is the difference bewteen CP and MILP approaches in Job Shop Scheduling?" Tags="|python|scheduling|constraint-programming|supply-chain|job-shop-scheduling|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8689" PostTypeId="2" ParentId="8688" CreationDate="2022-07-14T12:19:02.180" Score="3" Body="&lt;p&gt;Google has a very nice library called &lt;a href=&quot;https://developers.google.com/optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR Tools&lt;/a&gt;. One of those tools is a CP-SAT solver. Even though their solver works only on integer valued variables it is not that hard to convert MILP models to integer problems.&lt;/p&gt;&#xA;&lt;p&gt;They also have some nice documentation about &lt;a href=&quot;https://developers.google.com/optimization/cp/cp_solver&quot; rel=&quot;nofollow noreferrer&quot;&gt;CP-SAT&lt;/a&gt;, &lt;a href=&quot;https://developers.google.com/optimization/cp&quot; rel=&quot;nofollow noreferrer&quot;&gt;constraint optimization&lt;/a&gt; and relevant topics.&lt;/p&gt;&#xA;" OwnerUserId="4496" LastActivityDate="2022-07-14T12:19:02.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8690" PostTypeId="1" CreationDate="2022-07-14T14:43:47.297" Score="2" ViewCount="41" Body="&lt;p&gt;In Bayesian Optimization/other model-based numeric optimization methods, is there a useful way to compress or aggregate the observation history into a single value so you don't have to keep the result of every single function evaluation during a run?&lt;/p&gt;&#xA;&lt;p&gt;I.e. rather than having a list of exact objective function values which grows ever larger the longer an optimization method runs, you could have some single numeric variable that's recalculated with each new function value seen, and which contains some useful information about the observation history, without the memory requirements of storing the entire thing.&lt;/p&gt;&#xA;" OwnerUserId="9969" LastActivityDate="2022-07-14T14:43:47.297" Title="How best to compress a list of objective function evaluations in model-based optimization?" Tags="|combinatorial-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8691" PostTypeId="2" ParentId="8688" CreationDate="2022-07-14T15:06:58.973" Score="10" Body="&lt;p&gt;CP is &lt;em&gt;not&lt;/em&gt; a subset of MILP. They are separate modeling/solving paradigms whose domains of application overlap. Both can solve for optimal solutions (in CP's case, by incorporating a constraint that says each solution must improve on the previous one) or stop with a feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;It's a bit deceptive to refer to &amp;quot;CP&amp;quot; as a single approach, the way MILP is. All MILP languages and solvers understand linear equality and inequality constraints and real, integer and binary variables. Some extend to SOS1 and SOS2 constraints, if-then constraints and quadratic cone constraints, but that's about it. CP languages and solvers vary more in terms of what constructs they understand. They all support integer and binary/logical variables, but some provide things like interval variables (typically representing a time interval) and others, I think, do not. They probably all have the &amp;quot;all different&amp;quot; constraint, but some support constraint types that others do not.&lt;/p&gt;&#xA;&lt;p&gt;Some CP languages and solvers are specifically geared to scheduling problems. They allow the problem to be expressed more directly than a MILP model would. For instance, some have a constraint with a name something like &amp;quot;EndBeforeBegin&amp;quot; which is used to enforce a precedent constraint (one job must end before the next begins).&lt;/p&gt;&#xA;&lt;p&gt;Whether you can solve a scheduling problem faster with CP or MILP is an empirical question, the answer to which depends on the specific elements of your problem, the specific CP and MILP solvers you use (and the model elements supported by whatever language or API you use), and of course your modeling skills.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-14T15:06:58.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8692" PostTypeId="1" AcceptedAnswerId="8694" CreationDate="2022-07-14T22:20:13.117" Score="2" ViewCount="113" Body="&lt;p&gt;I'm running SoPlex from the command line to solve some linear programming problems. I'd like to get the basis of the solution, so I use the &lt;code&gt;--writebas&lt;/code&gt; flag. However, I can't find a description of the file format of the basis output.  For example, running&#xA;&lt;code&gt;soplex test.lp --writebas=basis&lt;/code&gt; on&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\ test.lp&#xA;Maximize&#xA; obj: x1 + 2 x2 + 3 x3 + x4&#xA;Subject To&#xA; c1: - x1 + x2 + x3 + 10 x4 &amp;lt;= 20&#xA; c2: x1 - 3 x2 + x3 &amp;lt;= 30&#xA; c3: x2 - 3.5 x4 = 0&#xA;Bounds&#xA; 0 &amp;lt;= x1 &amp;lt;= 40&#xA; 2 &amp;lt;= x4 &amp;lt;= 3&#xA;General&#xA; x4&#xA;End&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;gives the basis file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;NAME  soplex.bas&#xA; UL x1&#xA; XU x2             c1&#xA; XU x3             c2&#xA; XL x4             c3&#xA;ENDATA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What does this mean?&lt;/p&gt;&#xA;" OwnerUserId="9933" LastActivityDate="2022-07-15T08:04:53.797" Title="SoPlex basis file format" Tags="|simplex|software|scip|mps|lp-format|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8693" PostTypeId="1" AcceptedAnswerId="8696" CreationDate="2022-07-15T08:03:38.937" Score="2" ViewCount="197" Body="&lt;p&gt;For large rectangular matrices, is this something that is easy or possible to achieve in the programming language R? Or to get all possible equations, must one solve equations by hand? I see notes about SVD here &lt;a href=&quot;https://math.stackexchange.com/questions/1694351/finding-all-left-inverses-of-a-matrix&quot;&gt;https://math.stackexchange.com/questions/1694351/finding-all-left-inverses-of-a-matrix&lt;/a&gt;, done on a 2 x 3 matrix. what if the matrix was ~ 200 x 10? how would one begin?&lt;/p&gt;&#xA;" OwnerUserId="9949" LastActivityDate="2022-07-15T15:26:16.133" Title="Finding all left inverses of a matrix" Tags="|linear-algebra|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8694" PostTypeId="2" ParentId="8692" CreationDate="2022-07-15T08:04:53.797" Score="6" Body="&lt;p&gt;This is a standard MPS Basis file. Its format goes back to ancient Roman times. Here is a good description: &lt;a href=&quot;http://lpsolve.sourceforge.net/5.5/bas-format.htm&quot; rel=&quot;noreferrer&quot;&gt;http://lpsolve.sourceforge.net/5.5/bas-format.htm&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="907" LastActivityDate="2022-07-15T08:04:53.797" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8695" PostTypeId="2" ParentId="8684" CreationDate="2022-07-15T09:40:23.420" Score="9" Body="&lt;p&gt;The sensitivity analysis of optimization problems is called &lt;a href=&quot;https://en.wikipedia.org/wiki/Parametric_programming&quot; rel=&quot;noreferrer&quot;&gt;parametric programming&lt;/a&gt; or sometimes &amp;quot;post-optimal analysis&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;The short version is that you describe the variability of your optimization problem as a function of certain parameters, typically denotes as &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;. Then, you calculate the optimization problem &lt;em&gt;as a function&lt;/em&gt; of &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;, i.e. &lt;span class=&quot;math-container&quot;&gt;$x^*(\theta)$&lt;/span&gt;. For QPs, the best way to do this is by solving the parametric version of the KKT conditions.&lt;/p&gt;&#xA;&lt;p&gt;The solution of a parametric optimization problem is a series of so-called &amp;quot;critial regions&amp;quot;, i.e. areas where an certain active set continues to be optimal despite a variation of the parameters. For each critical region you can calculate the analytical expression &lt;span class=&quot;math-container&quot;&gt;$x^*(\theta)$&lt;/span&gt; (also for the Lagrangian multipliers).&lt;/p&gt;&#xA;&lt;p&gt;There are some references around this topic that may interest you:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Fiacco (1975): Basic Sensitivity Theory. This consolidates a lot of the theory, especially for the 1D case.&lt;/li&gt;&#xA;&lt;li&gt;Oberdieck et al. (2016) &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0263876216303276&quot; rel=&quot;noreferrer&quot;&gt;On multi-parametric programming and its applications in process systems engineering&lt;/a&gt;. I wrote this review paper as a way for people who are new to the topic to learn what it is about.&lt;/li&gt;&#xA;&lt;li&gt;Pistikopoulos, Diangelakis, Oberdieck (2020) &lt;a href=&quot;https://www.wiley.com/en-us/Multi+parametric+Optimization+and+Control-p-9781119265184&quot; rel=&quot;noreferrer&quot;&gt;Multi-parametric Optimization and Control&lt;/a&gt;. We wrote this book as a continuation of the Fiacco book, summarizing a lot of the theory and known use cases for parametric programming.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Apologies for self-referencing, I genuinely think these are good references though.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="133" LastActivityDate="2022-07-15T09:40:23.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8696" PostTypeId="2" ParentId="8693" CreationDate="2022-07-15T15:26:16.133" Score="6" Body="&lt;p&gt;There will be an infinite number of left inverses. We can find a template for them using the &lt;code&gt;pracma&lt;/code&gt; library in R. Let &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; be a 200x10 matrix. The first step is to find one left inverse &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, which we do as follows.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;B &amp;lt;- pracma::pinv(A)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now suppose that &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is some other left inverse, meaning &lt;span class=&quot;math-container&quot;&gt;$C A = I = B A$&lt;/span&gt; and hence &lt;span class=&quot;math-container&quot;&gt;$(C-B)A=\mathbf{0}.$&lt;/span&gt; Then &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; plus a 10x200 matrix composed of rows from the left null space of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;. Since &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; has rank at most 10, the dimension of the left null space will be at least 200-10 = 190. We can get a basis for it as follows.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;basis &amp;lt;-  A |&amp;gt; t() |&amp;gt; pracma::nullspace() |&amp;gt; t()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Since the &lt;code&gt;nullspace()&lt;/code&gt; function computes the right null space of a matrix, we transpose &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and then transpose the resulting basis matrix. So every vector in the left null space of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a linear combination of rows of the basis matrix, and therefore every left inverse of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; can be expressed as &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; plus a matrix whose rows are linear combinations of the basis rows.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-15T15:26:16.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8697" PostTypeId="2" ParentId="8683" CreationDate="2022-07-16T13:36:26.537" Score="2" Body="&lt;p&gt;Use dist (for Cartesian coordinates) or geosphere::distm (for latitude and longitude) to create a distance matrix.  Use apply to find the minimum distance to a facility, for each customer.  Find mean from there.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastActivityDate="2022-07-16T13:36:26.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8698" PostTypeId="2" ParentId="8122" CreationDate="2022-07-18T04:04:42.677" Score="1" Body="&lt;p&gt;In &lt;a href=&quot;https://dl.acm.org/doi/abs/10.1145/3184400&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Optimal Multi-Way Number Partitioning&amp;quot;&lt;/a&gt; (Schreiber, Korf and Moffitt, JACM 2018) the authors present experiments with random integers with 16, 32 and 48 bits. 16 bit integers are relatively easy, since most random instances have a perfect partition. 32 bit integers are harder, and with 48 bit integers, almost all instances do not have a perfect partition. So, to generate hard instances for number partitioning, one can simply increase the number of bits (and then, even instances with 100 integers are already hard):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;values = np.random.randint(1,2**48-1, 100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2022-07-18T04:04:42.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8699" PostTypeId="1" AcceptedAnswerId="8700" CreationDate="2022-07-18T06:50:57.327" Score="9" ViewCount="565" Body="&lt;p&gt;Suppose that we have an mixed-integer linear optimization problem and we obtain a solution using a heuristic. How can one check 1) whether this solution is optimal and 2) how difficult is it to do so?&lt;/p&gt;&#xA;&lt;p&gt;My question is motivated by an instance of CVRP. I have seen many different metaheuristics that all converge to the same solution on &lt;a href=&quot;http://vrp.galgos.inf.puc-rio.br/index.php/en/plotted-instances?data=ORTEC-n242-k12&quot; rel=&quot;noreferrer&quot;&gt;this instance&lt;/a&gt;, so I'm wondering if we can verify whether the solution is optimal or not.&lt;/p&gt;&#xA;&lt;p&gt;One naive way I can think of is to warm-start the MILP with the found solution, but I'm particularly interested in more advanced strategies.&lt;/p&gt;&#xA;" OwnerUserId="2886" LastActivityDate="2022-07-18T08:14:32.547" Title="Verifying optimality of heuristic solutions" Tags="|mixed-integer-programming|heuristics|metaheuristics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8700" PostTypeId="2" ParentId="8699" CreationDate="2022-07-18T08:14:32.547" Score="10" Body="&lt;p&gt;Generally, the only way to prove that a given solution is optimal is to obtain a valid lower bound (assuming minimization) that matches the incumbent solution (with &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; tolerance, to be specified by the user).&lt;/p&gt;&#xA;&lt;p&gt;To my knowledge, the only way to achieve such a lower bound is by using a branch-and-bound based solver (Gurobi, CPLEX, SCIP, Xpress, MOSEK etc.). Since you already have a (very) good solution, I would increase the intensity of the cutting plane generation (in Gurobi, this is controlled by the &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/cuts.html&quot; rel=&quot;noreferrer&quot;&gt;Cuts&lt;/a&gt; parameter) in order to focus more on the generation of hopefully effective cuts. In Gurobi, you can also set the &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/mipfocus.html&quot; rel=&quot;noreferrer&quot;&gt;MIPFocus&lt;/a&gt; parameter to 2, which tells Gurobi to focus on the lower bound.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I think the other solvers have similar parameters, but I am not familiar with them as I work for Gurobi.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="133" LastActivityDate="2022-07-18T08:14:32.547" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8701" PostTypeId="1" AcceptedAnswerId="8703" CreationDate="2022-07-18T23:13:12.637" Score="2" ViewCount="45" Body="&lt;p&gt;I would like your valuable opinion on one issue:&lt;/p&gt;&#xA;&lt;p&gt;I created a decision matrix considering two criteria and 10 alternatives, as below. My problem involves determining the optimal number of clusters from a dataset that has information about rural properties. So, basically, I use two criteria to know the ideal number of clusters. The alternatives are the number of clusters it can be. This decision matrix, I obtained using agglomerative hierarchical clustering algorithm.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nclusters(Alternatives) Criterion1 Criterion2&#xA;              3           427.7037 1216.07483&#xA;              4           2067.8457  315.11427&#xA;              5           1797.6554  295.33840&#xA;              6           1797.6554  295.33840&#xA;              7           1798.7378  229.82400&#xA;              8           1468.3216  229.82400&#xA;              9           942.4955  229.82400&#xA;             10           937.1313  229.31030&#xA;             11           937.1313  229.31030&#xA;             12           629.0550   29.85698&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After obtaining this matrix, I used some multiple-criteria decision-making(MCDM), which are the weighted sum method (WSM), TOPSIS and VIKOR, to generate rankings of the alternatives. Then, I compare the rankings of both MCDM methods, and manage to generate a final ranking. So by chance, if rank = 1 is in the first row, it means that the ideal number of clusters is 3.&lt;/p&gt;&#xA;&lt;p&gt;Now, I would like to know your opinion if it makes sense to use MCDM using only two criteria, even though there are 10 alternatives? I know that to be MCDM, you need to have more than one criterion. Of course, more criteria would help, but I only got those two.&lt;/p&gt;&#xA;&lt;p&gt;What do you think?&lt;/p&gt;&#xA;" OwnerUserId="9063" LastEditorUserId="9063" LastEditDate="2022-07-18T23:23:09.793" LastActivityDate="2022-07-19T03:28:02.017" Title="Two criteria in a problem that involves multiple-criteria decision-making" Tags="|r|multicriteria-decision-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8703" PostTypeId="2" ParentId="8701" CreationDate="2022-07-19T03:22:13.997" Score="3" Body="&lt;p&gt;More criteria would not necessarily help, and in fact might make it harder to make a selection (for instance, if every alternative excels on some criterion and does badly on some other criterion). Ultimately, the relevant criteria (and, by implication, the relevant number of criteria) should be determined by the decision maker(s), based on the context of the problem.&lt;/p&gt;&#xA;&lt;p&gt;You might start by ruling out dominated alternatives (alternatives that are worse than at least one other alternative in both criteria). After that, you can try various ranking schemes, or you can ask the decision maker to do pairwise comparisons (e.g., &amp;quot;Between 5 and 7 clusters which do you prefer?&amp;quot;), or you can plot the Pareto frontier and ask the decision maker what looks good to them.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-07-19T03:28:02.017" LastActivityDate="2022-07-19T03:28:02.017" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8704" PostTypeId="1" CreationDate="2022-07-19T10:11:28.593" Score="1" ViewCount="138" Body="&lt;p&gt;I am trying to do something with user callbacks in Cplex using Python API. For instance, I will need a callback that only counts the number of explored nodes.&lt;/p&gt;&#xA;&lt;p&gt;While testing something I noticed that for one problem, without a user callback, Cplex solves it very quickly (3s). But if I register a user callback that does &lt;strong&gt;nothing&lt;/strong&gt; it does not stop even after 5 minutes. Is this normal? I would expect that such callback should not interfere with how Cplex is working. (Similarly my hope was that I could count the number of visited nodes seamlessly).&lt;/p&gt;&#xA;" OwnerUserId="9588" LastActivityDate="2022-07-19T10:11:28.593" Title="User callback doing nothing slows down Cplex" Tags="|cplex|cplex-python-api|callback|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8705" PostTypeId="1" CreationDate="2022-07-19T11:21:07.510" Score="6" ViewCount="210" Body="&lt;p&gt;I am trying to solve a large MILP, but it seems like dense problems can be very difficult for moderns solvers. I tried to solve the problem described below considering only constraints (1) and (2) that is the case where x is from the binary set B and continuous set C (so ignoring constraints (3), (4) and (5)). For 1000 variables (800 binary and 200 continuous) in total and 100k scenarios, it took 15 minutes to solve. As I increased scenarios to 200k, the problem was not solved after 7 hours.&lt;/p&gt;&#xA;&lt;p&gt;I would like to use Benders Decomposition or another method to solve the problem, but I don't know how to formulate  the master and subproblems.&lt;/p&gt;&#xA;&lt;p&gt;The problem is described below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textrm{Minimize }c^{T}x + \eta  + \frac{1}{S(1-\alpha )}\sum_{s=1}^{S}[\xi ^{T}x-\eta]^{+}\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective function can be equivalently represented as following by introducing auxiliary variables &lt;span class=&quot;math-container&quot;&gt;$z_s\geq0$&lt;/span&gt; along with constraint (2)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textrm{Minimize}_{x,y,z_s,\eta}&#xA;\sum _{i}c_{i}x_{i} + \eta+\frac{1}{S(1-\alpha)}\sum_{s=1}^{S}z_{s}\\&#xA;\textrm{Subject to}\\&#xA;\begin{align}&#xA;Ax \geq b \hspace{3cm}(1)\\&#xA;z_{s} \geq \sum_{i=1}^{n}\xi_{is}x_{i} - \eta  \hspace{1cm} \forall s \hspace{1cm} (2)\\&#xA;l_{i}y_{i} \leq x_{i} \leq u_{i}y_{i} \hspace{1cm}\forall i \in  N \hspace{0.25cm}and \hspace{0.25cm} i \in\mathbb{Z} \hspace{1cm}(3)\\&#xA;\sum_{i}^{}y_{i} \leq 10 \hspace{1cm}(4)\\&#xA;\sum_{i}^{}P_{i}x_{i} = 5000000 \hspace{1cm}\forall i \in  N \,\,and \,\, i \in\mathbb{Z}\hspace{1cm}(5)&#xA;\end{align}\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\hspace{1cm}\bullet$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$x_i\in $&lt;/span&gt;{0,1}&lt;span class=&quot;math-container&quot;&gt;$ \hspace{0.25cm}\forall i \in B\hspace{0.5cm} \textrm{B is the index set of binary variables}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\hspace{1cm}\bullet$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$0\leq x_i\leq1\hspace{0.25cm}\forall i \in C\hspace{0.5cm} \textrm{C is the index set of continuous variables bounded between 0 and 1}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\hspace{1cm}\bullet$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$l_i\leq x_i\leq u_i\hspace{0.25cm}\forall i \in N\hspace{0.5cm} \textrm{N is the index set of continuous variables bounded between } l_i$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\textrm{ and }$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\hspace{1cm}\bullet$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$l_i\leq x_i\leq u_i\hspace{0.25cm}\forall i \in \mathbb{Z}\hspace{0.5cm} \mathbb{Z}\textrm{ is the index set of integer variables}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\hspace{1cm}\bullet$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$y_i\in $&lt;/span&gt;{0,1}&lt;span class=&quot;math-container&quot;&gt;$ \hspace{0.25cm}\forall i \in N \hspace{0.25cm} and \hspace{0.25cm}\forall i \in \mathbb{Z}\hspace{0.5cm} \textrm{variables y are introduced to enforce bounds on variables x and constraints (3), (4) and (5)}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\hspace{1cm}\bullet$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\textrm{s=1,...S are set of scenarios}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\hspace{1cm}\bullet$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\xi_s$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\textrm{ are vector of uncertain coefficients or parameters associated with variable }x \textrm{ given for each scenario s}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\hspace{1cm}\bullet$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\alpha = 0.01$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\hspace{1cm}\bullet$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\textrm{ are (certain) parameters }$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Could this problem be decomposed using Benders Decomposition, and what will be master and subproblems? If considering all constraints is too much to ask for, I would be happy with answer answer considering just constraints (1) and (2) only for which x is from set B and C (i.e. binary and continuous bounded between 0 and 1). Note: Constraint (1) does not involve any uncertain parameters and is not scenario dependent. It is just like a standard LP/MILP type constraint.&lt;/p&gt;&#xA;&lt;p&gt;Does decomposition always require creating as many subproblems as the number of scenarios or could we create some subset? For example, the problem may be efficiently solved in extensive form for say 20k scenarios. I am not sure if a decomposition method could be applied if we solve extensive form(s) based on sets of 20k scenarios in each (i.e. breaking the problem in to 10 = 200k/20k large deterministic problems).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I have provided R code for a simplified example to show extensive form of the model in R, considering the continuous variable x case. OMPR package does not seem to allow defining a variable to have different types (such as continuous, binary, etc) based on index.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;suppressPackageStartupMessages(library(dplyr, quietly = TRUE)) &#xA;suppressPackageStartupMessages(library(ROI))&#xA;library(ROI.plugin.glpk)&#xA;library(ompr)&#xA;library(ompr.roi)&#xA;&#xA;&#xA;extensive &amp;lt;- function(nvar,S,alpha) {&#xA;  # Generate Random data&#xA;  p &amp;lt;- matrix(runif(nvar, min=10, max=150), 1, nvar)&#xA;  xi_temp &amp;lt;- matrix(runif(S*nvar,min=10,max=120), S, nvar)&#xA;  xi &amp;lt;- sweep(-xi_temp,2,p,FUN=&amp;quot;+&amp;quot;)&#xA;  &#xA;  &#xA;  result &amp;lt;- MIPModel() |&amp;gt;&#xA;  # Variable type x is defined as continuous only here&#xA;  add_variable(x[i],i=1:nvar, type = &amp;quot;continuous&amp;quot;,lb=0, ub=1) |&amp;gt; &#xA;  add_variable(z[i],i=1:S, type = &amp;quot;continuous&amp;quot;,lb=0) |&amp;gt;&#xA;  add_variable(eta,type = &amp;quot;continuous&amp;quot;,lb=0) |&amp;gt;&#xA;  add_constraint(sum_over(xi[j,i]*x[i], i=1:nvar)&amp;lt;= z[j] +eta, j =1:S) |&amp;gt;  # Constraint (2)&#xA;  add_constraint(sum_over(p[i]*x[i], i=1:nvar) &amp;gt;= 2000) |&amp;gt;  # Constraint (1)&#xA;  set_objective(eta+1/(1-alpha)*1/S*sum_over(z[j], j =1:S)) |&amp;gt;&#xA;  solve_model(with_ROI(solver = &amp;quot;glpk&amp;quot;)) &#xA;   solution &amp;lt;- get_solution(result,x[i])&#xA;  &#xA;}&#xA; solution &amp;lt;- extensive(100,1000,0.95)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9989" LastEditorUserId="9989" LastEditDate="2022-07-29T10:23:25.187" LastActivityDate="2022-07-29T10:23:25.187" Title="Benders decomposition for a dense MILP" Tags="|mixed-integer-programming|benders-decomposition|column-generation|dantzig-wolfe-decomposition|lagrangian-decomposition|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8706" PostTypeId="1" CreationDate="2022-07-19T12:58:17.500" Score="2" ViewCount="333" Body="&lt;p&gt;Not sure if this question is appropriate, but there is some error in my code which I just cannot seem to find. Probably been staring myself blind to this, so I could really use some help.&lt;/p&gt;&#xA;&lt;p&gt;It is a MILP, which I am solving in R&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model&amp;lt;- MIPModel() %&amp;gt;%&#xA;  # 1 if i gets assigned to facility j&#xA;  add_variable(x[i, j], i = 1:n, j = 1:m, type = &amp;quot;binary&amp;quot;) %&amp;gt;%&#xA;  &#xA;  # 1 if facility j is a collection point&#xA;  add_variable(y[j], j = 1:m, type = &amp;quot;binary&amp;quot;) %&amp;gt;%&#xA;  &#xA;  # 1 if facility j is a pick-up point&#xA;  add_variable(u[j], j = 1:m, type = &amp;quot;binary&amp;quot;)  %&amp;gt;%&#xA;  &#xA;  #C1&#xA;  add_variable(C1[j], j=1:m, type = &amp;quot;continuous&amp;quot;) %&amp;gt;%&#xA;  &#xA;  #C&#xA;  add_variable(C2[j], j=1:m, type = &amp;quot;continuous&amp;quot;) %&amp;gt;%&#xA;  &#xA;&#xA;  # minimize the total cost&#xA;  set_objective((S * sum_expr(y[j], j = 1:m)) +&#xA;                  (a * sum_expr(C1[j], j = 1:m)) +&#xA;                  (T * sum_expr(u[j], j = 1:m)) +&#xA;                  (b * sum_expr(C2[j], j = 1:m)) +&#xA;                  ((sum_expr(1-sum_expr(x[i,j], i = 1:n), j= 1:m)) * kR)&#xA;                , &amp;quot;min&amp;quot;) %&amp;gt;%&#xA;  &#xA;  #1&#xA;  add_constraint(C1[j]&amp;lt;=y[j]*(n+w), j = 1:m) %&amp;gt;%&#xA;  &#xA;  #2&#xA;  add_constraint(C1[j]&amp;gt;=0, j = 1:m) %&amp;gt;%&#xA;  &#xA;  #3&#xA;  add_constraint(C1[j]&amp;gt;=x[i,j]+w-(m+w)*(1-y[j]), i = 1:n, j = 1:m) %&amp;gt;%&#xA;  &#xA;  #4&#xA;  add_constraint(C2[j]&amp;lt;=u[j]*(n+w), j = 1:m) %&amp;gt;%&#xA;  &#xA;  #5&#xA;  add_constraint(C2[j]&amp;gt;=0, j = 1:m) %&amp;gt;%&#xA;  &#xA;  #6&#xA;  add_constraint(C2[j]&amp;gt;=x[i,j]+w-(n+w)*(1-u[j]), i = 1:n, j = 1:m) %&amp;gt;%&#xA;  &#xA;  #7&#xA;  add_constraint(sum_expr(x[i,j], j = 1:m)&amp;lt;= 1 , i=1:n) %&amp;gt;%&#xA;  &#xA;  #8 &#xA;  add_constraint(x[i,j]&amp;lt;=(delta(i,j))*(y[j]+u[j]), i =1:n, j =1:m) %&amp;gt;%&#xA;  &#xA;  #9&#xA;  add_constraint((sum_expr(x[i,j], i=1:n)+(w-p))&amp;lt;=(u[j]*(n+w)), j = 1:m) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The basic idea is that you can assign customers to a facility (Xij).&#xA;Assigning customers to a facility costs &amp;quot;a&amp;quot; without an upgrade, opening a facility without an upgrade (Y) costs S.&#xA;A facility has a capacity (p) and an internal demand (w). If the amount of customers assigned and internal demand exceeds p, the facility needs an upgrade (U).&#xA;Assigning customers to a facility costs &amp;quot;b&amp;quot; with an upgrade, opening a facility with an upgrade costs T.&#xA;Customers can only be assigned if they find themselves close enough to the facility, which is indicated by delta.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;e &amp;lt;- function(i, j) {&#xA;  customer &amp;lt;- data[i, ]&#xA;  facility &amp;lt;- facility_locations[j, ]&#xA;  (sqrt((customer&lt;span class=&quot;math-container&quot;&gt;$x - facility$&lt;/span&gt;x)^2 + (customer&lt;span class=&quot;math-container&quot;&gt;$y - facility$&lt;/span&gt;y)^2))&#xA;}&#xA;&#xA;delta &amp;lt;- function (i,j){&#xA;  ifelse(e(i,j)&amp;lt;=z,1,0)&#xA;}&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When a customer is not assigned, there is a &amp;quot;k&amp;quot; likelihood that it will undertake action, which costs &amp;quot;R&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;However, when solving the model, it gives me a minus, which should not be possible as assigning customers and opening facilities is costly.&lt;/p&gt;&#xA;" OwnerUserId="9867" LastActivityDate="2022-07-20T08:50:08.090" Title="Optimization gives me negative value" Tags="|r|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8707" PostTypeId="2" ParentId="8706" CreationDate="2022-07-19T15:17:16.043" Score="5" Body="&lt;p&gt;The &lt;code&gt;ompr::add_variable&lt;/code&gt; function has a default value of &lt;code&gt;-Inf&lt;/code&gt; for the lower bound (&lt;code&gt;lb&lt;/code&gt;) parameter. Assuming you intended C1 and C2 to be nonnegative, you need to explicitly set &lt;code&gt;lb=0&lt;/code&gt; for them.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-19T15:17:16.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8708" PostTypeId="1" AcceptedAnswerId="8709" CreationDate="2022-07-20T00:41:04.853" Score="3" ViewCount="294" Body="&lt;p&gt;I have a square like region centered at the origin, which is divided into 4 sub-regions. Region 1 can formed from by the diagonal of a square, &lt;span class=&quot;math-container&quot;&gt;$x + y \leq 0$&lt;/span&gt;. Region 2 is formed by joining the center of the square, and midpoint of one of the sides &lt;span class=&quot;math-container&quot;&gt;$x + y \geq 0, y \geq 0, x &#xA; \leq 0$&lt;/span&gt;. Region 3 is formed by joining the center of the square, and midpoint of the opposite side, &lt;span class=&quot;math-container&quot;&gt;$x + y \geq 0, y \leq 0, x \geq 0$&lt;/span&gt;. Region 4 is the remaining piece, &lt;span class=&quot;math-container&quot;&gt;$x + y \geq 0, y \geq 0, x \geq 0$&lt;/span&gt;. I want to model a function &lt;span class=&quot;math-container&quot;&gt;$g(x, y)$&lt;/span&gt; which takes the value &lt;span class=&quot;math-container&quot;&gt;$g_1(x, y)$&lt;/span&gt; in region 1, &lt;span class=&quot;math-container&quot;&gt;$g_2(x, y)$&lt;/span&gt; in region 2, &lt;span class=&quot;math-container&quot;&gt;$g_3(x, y)$&lt;/span&gt; in region 3, and &lt;span class=&quot;math-container&quot;&gt;$g_4(x, y)$&lt;/span&gt; in region 4.&lt;/p&gt;&#xA;&lt;p&gt;I thought of modeling this with disjunctive constraints using two binary variables &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_2$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$z_1 = 0, z_2 = 0$&lt;/span&gt; in region 1, &lt;span class=&quot;math-container&quot;&gt;$z_1 = 1, z_2 = 0$&lt;/span&gt; in region 2, &lt;span class=&quot;math-container&quot;&gt;$z_1 = 0, z_2 = 1$&lt;/span&gt; in region 3, and &lt;span class=&quot;math-container&quot;&gt;$z_1 = 1, z_2 = 1$&lt;/span&gt; in region 4. However, I am not sure how to use two binary variables in the region specific constraints without using product of binary variables. Is it possible to model &lt;span class=&quot;math-container&quot;&gt;$g(x, y)$&lt;/span&gt; as linear mixed integer program.&lt;/p&gt;&#xA;" OwnerUserId="3496" LastActivityDate="2022-07-20T12:57:10.560" Title="Piecewise function with two variables" Tags="|mixed-integer-programming|logical-constraints|indicator-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8709" PostTypeId="2" ParentId="8708" CreationDate="2022-07-20T01:14:20.437" Score="5" Body="&lt;p&gt;You have a disjunction of four polyhedra &lt;span class=&quot;math-container&quot;&gt;$A_i x \le b_i$&lt;/span&gt;.  Introduce four binary variables &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; (one per region) and impose linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i=1}^4 r_i &amp;amp;= 1 \\&#xA;A_i x - b_i &amp;amp;\le M_i (1 - r_i) &amp;amp;&amp;amp;\text{for $i\in\{1,2,3,4\}$} \\&#xA;\end{align}&lt;/span&gt;&#xA;Now&#xA;&lt;span class=&quot;math-container&quot;&gt;$$g(x,y) = \sum_{i=1}^4 g_i(x,y) r_i,$$&lt;/span&gt;&#xA;which you can enforce with further big-M constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_i (1-r_i) \le g(x,y) - g_i(x,y) \le U_i (1-r_i)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If you want to use only two binary variables instead of four, relax each &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; and linearize&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;r_1 &amp;amp;= (1-z_1)(1-z_2) \\&#xA;r_2 &amp;amp;= z_1(1-z_2) \\&#xA;r_3 &amp;amp;= (1-z_1)z_2 \\&#xA;r_4 &amp;amp;= z_1 z_2&#xA;\end{align}&lt;/span&gt;&#xA;by linearizing the product &lt;span class=&quot;math-container&quot;&gt;$z_1 z_2$&lt;/span&gt; in &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;the usual way&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-07-20T12:57:10.560" LastActivityDate="2022-07-20T12:57:10.560" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8710" PostTypeId="1" CreationDate="2022-07-20T05:47:03.773" Score="3" ViewCount="150" Body="&lt;p&gt;I came across Proposition 2.3.7 from Nemirovski  (&lt;a href=&quot;https://www2.isye.gatech.edu/%7Enemirovs/LMCOLN2022Fall.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www2.isye.gatech.edu/~nemirovs/LMCOLN2022Fall.pdf&lt;/a&gt;)&#xA;which states the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kr4gq.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kr4gq.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Does anybody know why they start the proof from:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\exp\{y-4y^{2} \}\leq 1+y \leq \exp\{y\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where does it come from?&lt;/p&gt;&#xA;" OwnerUserId="9994" LastEditorUserId="123" LastEditDate="2022-12-14T22:23:30.870" LastActivityDate="2022-12-15T09:03:29.703" Title="Nemirovski Proposition 2.3.7 (exponential cone)" Tags="|optimization|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8711" PostTypeId="2" ParentId="8706" CreationDate="2022-07-20T08:50:08.090" Score="2" Body="&lt;p&gt;I assume your term &lt;code&gt;sum_expr(1-sum_expr(x[i,j], i = 1:n), j= 1:m)&lt;/code&gt; in &lt;code&gt;set_objective&lt;/code&gt; is intended to be the number of unassigned customers; however, it actually evaluates to the number of &lt;em&gt;facilities&lt;/em&gt; minus the number of assigned customers. Presumably there are more customers than facilities, which means this term would probably be negative and could be responsible for driving the total cost negative.&lt;/p&gt;&#xA;" OwnerUserId="9996" LastActivityDate="2022-07-20T08:50:08.090" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8712" PostTypeId="1" CreationDate="2022-07-20T09:19:21.947" Score="3" ViewCount="396" Body="&lt;p&gt;Is it possible to work with multiple arcs between 2 nodes within Google OR?&lt;/p&gt;&#xA;&lt;p&gt;Or are there better modeling techniques?&lt;/p&gt;&#xA;&lt;p&gt;I want to optimize flow from supply to demand areas, where supply and demand are constraints on node level (each node has 1 supply/demand that the arcs can use/fulfill).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Application to liner shipping&#xA;&#xA;# Instantiate a SimpleMinCostFlow solver. min_cost_flow = pywrapgraph.SimpleMinCostFlow()&#xA;&#xA;# Define four parallel arrays: sources, destinations, capacities,&#xA;# and unit costs between each pair.&#xA;# start_nodes and end_nodes contain list of edges between nodes (both arrays have same length) start_nodes = [1, 1, 1, 2, 2] end_nodes = [2, 2, 3, 3, 3] capacities = [70, 50, 90, 60, 40] unit_costs = [100, 100, 100, 100, 100]&#xA;&#xA;# Define an array of supplies at each node. supplies = [500, 0, -500]&#xA;&#xA;# Add each arc. for arc in zip(start_nodes, end_nodes, capacities, unit_costs):&#xA;    min_cost_flow.AddArcWithCapacityAndUnitCost(arc[0], arc[1], arc[2],&#xA;                                                arc[3])&#xA;&#xA;# Add node supply. for count, supply in enumerate(supplies):&#xA;    min_cost_flow.SetNodeSupply(count, supply)&#xA;    &#xA;# Find the min cost flow. status = min_cost_flow.Solve()&#xA;&#xA;if status != min_cost_flow.OPTIMAL:&#xA;    print('There was an issue with the min cost flow input.')&#xA;    print(f'Status: {status}')&#xA;    exit(1) print('Minimum cost: ', min_cost_flow.OptimalCost()) print('') print(' Arc   Flow / Capacity  Cost') for i in range(min_cost_flow.NumArcs()):&#xA;    cost = min_cost_flow.Flow(i) * min_cost_flow.UnitCost(i)&#xA;    print('%1s -&amp;gt; %1s    %3s   / %3s   %3s' %&#xA;          (min_cost_flow.Tail(i), min_cost_flow.Head(i),&#xA;           min_cost_flow.Flow(i), min_cost_flow.Capacity(i), cost))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The example (modified from Google OR: &lt;a href=&quot;https://developers.google.com/optimization/flow/mincostflow&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization/flow/mincostflow&lt;/a&gt;) crashes immediately, because I suppose the framework was not built for this type of modeling.&lt;/p&gt;&#xA;&lt;p&gt;How can I achieve this? Has it been done before?&lt;/p&gt;&#xA;" OwnerUserId="9997" LastEditorUserId="981" LastEditDate="2023-02-05T16:42:42.333" LastActivityDate="2023-02-05T16:42:42.333" Title="Minimum cost flow problem with multiple arcs between nodes in Python / Google OR" Tags="|or-tools|network-flow|multi-objective-optimization|maxflow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8713" PostTypeId="1" AcceptedAnswerId="8745" CreationDate="2022-07-20T10:09:29.073" Score="4" ViewCount="248" Body="&lt;p&gt;I have a maximization problem that I know that the maximum value of the objective function should be 6000. When solving the problem using Xpress, I end up on something like the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    Node     BestSoln    BestBound   Sols Active  Depth     Gap     GInf   Time&#xA;   73317   912.000000  50028.29999     11  43521     64   98.18%     643    295&#xA;   74319   912.000000  50012.88158     11  44186     88   98.18%     262    298&#xA;   75325   912.000000  50012.88158     11  44921     94   98.18%     320    301&#xA;   76327   912.000000  50012.88158     11  45381     56   98.18%     432    304&#xA;   77327   912.000000  50012.88158     11  46218     52   98.18%     331    306&#xA;   78330   912.000000  50012.88158     11  46755    104   98.18%     404    308&#xA;   79331   912.000000  48985.66896     11  47487     56   98.14%     170    311&#xA;   80334   912.000000  48985.66896     11  48161     95   98.14%     185    313&#xA;   81334   912.000000  48985.66896     11  49064    114   98.14%     516    316&#xA;   82335   912.000000  48985.66896     11  49474     47   98.14%     566    318&#xA;   83335   912.000000  48985.66896     11  50223     64   98.14%     462    321&#xA;   84336   912.000000  48985.66896     11  50990     62   98.14%     445    323&#xA;   85336   912.000000  48616.50212     11  51572     86   98.12%     392    326&#xA;   86336   912.000000  48616.50212     11  52306     46   98.12%     717    329&#xA;   87341   912.000000  48616.50212     11  52893     56   98.12%     351    331&#xA;   88342   912.000000  48616.50212     11  53629     34   98.12%     585    334&#xA;   89342   912.000000  48616.50212     11  54287    104   98.12%     246    336&#xA;   90342   912.000000  48616.50212     11  54823     35   98.12%     553    338&#xA;   91344   912.000000  44334.25280     11  55541     51   97.94%     446    341&#xA;   92344   912.000000  44334.25280     11  56097     39   97.94%     672    343&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My best solution is stack (it is not optimal) but the best bound is not getting lower. At the same time the number of active nodes it gets bigger and bigger, making me wondering if it will manage to find an optimal solution in reasonable time.&lt;/p&gt;&#xA;&lt;p&gt;I have tried to add a constraint to the objective function to be less than 6000 but it did not help.&lt;/p&gt;&#xA;&lt;p&gt;Is there a good way to make the gap getting smaller, and come earlier to the optimal solution? Or do you have any other recommendations?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Imagine a 1d array which has the required number of different groceries. We have also 20 types of bags and each type contains different groceries. So a bag contains 1 apple, 1 orange, another bag contains 1 croissant and 1 apricot etc. We need to find how many of each bag we should buy to cover as much as we can the requirements, and at the same time respecting the budget we have. We want to cover as much as we can but also not having large gaps in some products. So the only constraint is the budget that we have (among with the others needed for the formulation - binary variables etc).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have the required number of each product in a 1d array: &lt;span class=&quot;math-container&quot;&gt;$\ N_{j}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I can buy up to 20 bags of groceries, and I want to cover as better as possible my grocery needs by buying the bags. So I don't want to have a shortage of apples for example. Also, if I should have a shortage, I prefer having 1 less apple, and 1 less apricot than having less 2 apples. Also I would prefer to have 2 apples missing, compared to have 1apple, 1apricot and 1orange missing (total 3 items). I want to have as less shortages as possible. So I need different weights in my objective function.&lt;/p&gt;&#xA;&lt;p&gt;I have created a 2d array &lt;span class=&quot;math-container&quot;&gt;$ a_{k,j} $&lt;/span&gt; which has the groceries for each bag type. So, &lt;span class=&quot;math-container&quot;&gt;$ a_0 = [1, 2.. ] $&lt;/span&gt; which is the number of each grocery in the bag type &lt;span class=&quot;math-container&quot;&gt;$ 0 $&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$ a_{0,0} = 1 $&lt;/span&gt; means that we have 1 apple in the bag type &lt;span class=&quot;math-container&quot;&gt;$ 0 $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Based on the bag types I will get, I will have the following groceries: &lt;span class=&quot;math-container&quot;&gt;$ \sum \limits_{i} n_{i}b_{i,j} = [2,4,3..] $&lt;/span&gt; which means that I will have 2 apples, 4 apricots, 3 croissants etc.&lt;/p&gt;&#xA;&lt;p&gt;My formulation is the following:&lt;br /&gt;&#xA;(1) &lt;span class=&quot;math-container&quot;&gt;$ \sum \limits_i n_i &amp;lt;= C $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ \sum \limits_i n_i &amp;gt;= C $&lt;/span&gt;&lt;br /&gt;&#xA;(2) &lt;span class=&quot;math-container&quot;&gt;$ n_i integer $&lt;/span&gt;  and (3) &lt;span class=&quot;math-container&quot;&gt;$ n_i &amp;gt;= 0 $&lt;/span&gt;&lt;br /&gt;&#xA;(4) &lt;span class=&quot;math-container&quot;&gt;$ q_{j,m} binary, m = \{0,1,2\} $&lt;/span&gt;&lt;br /&gt;&#xA;(5) &lt;span class=&quot;math-container&quot;&gt;$ \sum \limits_m q_{j,m} = 1 $&lt;/span&gt;&lt;br /&gt;&#xA;(6) &lt;span class=&quot;math-container&quot;&gt;$ \sum \limits_i n_i b_{i,j} - N_j &amp;gt;= -Mq_{j,0} + (-2 + \delta)q_{j,1} + (-1 + \delta)q_{j,2} $&lt;/span&gt;&lt;br /&gt;&#xA;(7) &lt;span class=&quot;math-container&quot;&gt;$ \sum \limits_i n_i b_{i,j} - N_j &amp;lt;= (-2)q_{j,0} + (-1)q_{j,1} + Mq_{j,2} $&lt;/span&gt;&lt;br /&gt;&#xA;(8) &lt;span class=&quot;math-container&quot;&gt;$ z_{j,m} integer $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ z_{j,m} &amp;gt;= 0,  m = \{0,1,2\} $&lt;/span&gt;&lt;br /&gt;&#xA;(9) &lt;span class=&quot;math-container&quot;&gt;$ z_{j,m} &amp;lt;= Mq_{j,m} $&lt;/span&gt;&lt;br /&gt;&#xA;(10) &lt;span class=&quot;math-container&quot;&gt;$ z_{j,m} &amp;lt;= \sum \limits_i n_i b_{i,j} $&lt;/span&gt;&lt;br /&gt;&#xA;(11) &lt;span class=&quot;math-container&quot;&gt;$ z_{j,m} &amp;gt;= \sum \limits_i n_i b_{i,j} - (1-q_{j,m})M $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objective:&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum \limits_j p(z_{j,0} - N_jq_{j,0}) + \theta (z_{j,1} - N_jq_{j,1}) + s(z_{j,2} - N_jq_{j,2}) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Some Explanation:&#xA;(a) total number of bags I can get&lt;br /&gt;&#xA;(b) &lt;span class=&quot;math-container&quot;&gt;$ n_i $&lt;/span&gt; how many of each bag type I get&lt;br /&gt;&#xA;(c) binary variables - get value 1 if &lt;span class=&quot;math-container&quot;&gt;$ \sum \limits_i n_i b_{i,j} - N_j $&lt;/span&gt; is in the range defined by (6) and (7)&lt;br /&gt;&#xA;(d) &lt;span class=&quot;math-container&quot;&gt;$ z_{j,m} $&lt;/span&gt; constraints to define the value of &lt;span class=&quot;math-container&quot;&gt;$ z $&lt;/span&gt;. So when the binary variable &lt;span class=&quot;math-container&quot;&gt;$ q $&lt;/span&gt; is 1 then &lt;span class=&quot;math-container&quot;&gt;$ z = \sum \limits_i n_i b_{i,j}$&lt;/span&gt; else &lt;span class=&quot;math-container&quot;&gt;$ z = 0 $&lt;/span&gt;.&lt;br /&gt;&#xA;(e) &lt;span class=&quot;math-container&quot;&gt;$p, \theta, s $&lt;/span&gt; are the weights assigned depending on the shortage I have in each grocery &lt;span class=&quot;math-container&quot;&gt;$ j $&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9957" LastEditorUserId="491" LastEditDate="2024-02-21T23:13:06.087" LastActivityDate="2024-02-21T23:13:06.087" Title="Reduce optimality gap and get a solution faster" Tags="|optimization|mixed-integer-programming|branch-and-bound|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8714" PostTypeId="1" CreationDate="2022-07-20T11:54:41.103" Score="5" ViewCount="485" Body="&lt;p&gt;I have a problem in the form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned}&#xA;   \min_a f(a,b)\\&#xA;   \text{s.t.}\ b =\ &amp;amp; \arg\min_c g(a,c)\\&#xA;   &amp;amp; \text{s.t.}\ H(a,c) \leq \vec{0}&#xA;\end{aligned}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$f, g, H$&lt;/span&gt; are all linear functions. Actually, if there are multiple &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; such that the &lt;span class=&quot;math-container&quot;&gt;$\arg\min$&lt;/span&gt; is optimal, then any of them is ok as a choice for &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I want to solve this problem (to optimality) and analyze its behavior. However, I don't know how to modelize that in standard solvers. Is there a way to convert this to a more standard setting?&lt;/p&gt;&#xA;&lt;p&gt;Actually, I even don't know what is the form of the space formed by the solutions of the argmin problem depending on &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;. I.e., if we pose&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned}&#xA;   p(a) &amp;amp; = &amp;amp;  \arg\min_c g(a,c)\\&#xA;   &amp;amp; &amp;amp;\text{s.t.}\ H(a,c) \leq \vec{0}&#xA;\end{aligned}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(let's assume &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is unique here)&lt;/p&gt;&#xA;&lt;p&gt;Are there known properties of &lt;span class=&quot;math-container&quot;&gt;$p(a)$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="9999" LastEditorUserId="500" LastEditDate="2022-07-20T12:15:20.370" LastActivityDate="2022-07-20T21:19:42.300" Title="Minimizing under argmin constraint" Tags="|linear-programming|nonlinear-programming|bilevel-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8715" PostTypeId="1" CreationDate="2022-07-20T13:43:20.590" Score="0" ViewCount="59" Body="&lt;p&gt;I have been wondering what is the meaning of this sigma with delta negative or plus in there (if my read is correct).&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in \Delta^{-}(j)} x_{i j k}-\sum_{i \in \Delta^{+}(j)} x_{j i k}=0 \quad \forall k \in K, j \in N&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10000" LastActivityDate="2022-07-20T13:46:16.570" Title="What is the meaning of this math formulation?" Tags="|mixed-integer-programming|linear-programming|integer-programming|gurobi|vehicle-routing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8716" PostTypeId="2" ParentId="8715" CreationDate="2022-07-20T13:46:16.570" Score="3" Body="&lt;p&gt;The set of equations are used to represent the conservation of flow at every node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in a network. Here, &lt;span class=&quot;math-container&quot;&gt;$\Delta^{-}(j)$&lt;/span&gt; represents the set of nodes coming into node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and  &lt;span class=&quot;math-container&quot;&gt;$\Delta^{+}(j)$&lt;/span&gt; represents the set of nodes coming out of node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2424" LastActivityDate="2022-07-20T13:46:16.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8717" PostTypeId="1" CreationDate="2022-07-20T13:51:01.710" Score="3" ViewCount="214" Body="&lt;p&gt;I would like to know which books are best to study integer programming. I can see similar questions on this website, such as this one:&#xA;&lt;a href=&quot;https://or.stackexchange.com/questions/8333/books-for-integer-and-mixed-integer-programming&quot;&gt;Books for integer and mixed integer programming&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Integer and Combinatorial Optimization by Nemhauser and Wolsey is one of the recommended books. I am trying to determine whether it is worth getting this book, but I prefer something which is not too heavy with proofs or math symbols.  This book was published in 1988 so it will not cover any recent developments. Is this book highly regarded because it provides loads of examples or any material that is not found in the other books?&lt;/p&gt;&#xA;" OwnerUserId="3896" LastActivityDate="2022-07-20T15:17:17.557" Title="Integer programming books" Tags="|integer-programming|books|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8718" PostTypeId="2" ParentId="8712" CreationDate="2022-07-20T15:08:25.330" Score="3" Body="&lt;p&gt;I'm assuming that parallel arcs between the same nodes differ in something relevant (cost?), since otherwise you could just combine them into a single arc (summing capacities, if they are capacitated). Not being a Google OR user, I can't address whether it can handle multigraphs. There is, however, a fairly common hack for a situation like this. For each set of parallel arcs, leave one alone and break each of the remaining ones into two arcs with a new (dummy) node in between them. One of the new arcs retains the cost of the original arc (if there are costs); both of the new arcs have the capacity (if pertinent) of the original arc. The dummy node neither generates nor absorbs traffic. So if there are two arcs A -&amp;gt; B, you wind up with one arc A -&amp;gt; B and two arcs forming a path A -&amp;gt; A' -&amp;gt; B, where A' is the dummy node.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-20T15:08:25.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8719" PostTypeId="2" ParentId="8717" CreationDate="2022-07-20T15:17:17.557" Score="3" Body="&lt;p&gt;There are at least three somewhat distinct aspects to integer programming: theory (e.g., why LP solutions occur at vertices of polytopes); algorithms (branch-and-bound, decomposition, cutting plane generation ...); and modeling (turning a problem into a solvable model, pros and cons of &amp;quot;big M&amp;quot;, ...). Recommended books are likely to be stronger in some aspects than others, so it might help to know which aspect(s) concern you the most.&lt;/p&gt;&#xA;&lt;p&gt;For model building, I like &amp;quot;Model Building in Mathematical Programming&amp;quot; by H. P. Williams and &amp;quot;Applications of Optimization with Xpress&amp;quot; (with the caveat that when I went shopping for optimization books, Gutenberg was still refining the details of his printing press).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-20T15:17:17.557" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8720" PostTypeId="2" ParentId="8714" CreationDate="2022-07-20T17:41:19.567" Score="3" Body="&lt;p&gt;If you are willing to roll the dice and use numerical methods to find a good, hopefully maybe possibly optimal solution, there are definitely ways to do that. The mission is to solve &lt;span class=&quot;math-container&quot;&gt;$$\min_a q(a)$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$q(a) = f(a, p(a))$&lt;/span&gt; and evaluation of &lt;span class=&quot;math-container&quot;&gt;$q(a)$&lt;/span&gt; for a given value of &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; involves solving a linear program. I would be inclined to use dual simplex, or to solve the dual LP, since at each iteration you will be altering the right-hand side of the original LP.&lt;/p&gt;&#xA;&lt;p&gt;For the outer problem, you could try any of a variety of &lt;a href=&quot;https://en.wikipedia.org/wiki/Derivative-free_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;derivative-free optimization methods&lt;/a&gt;. Some of them (genetic algorithms and particle swarm optimization) require large numbers of function evaluations (meaning here solving lots of LPs), so I think I would try something like Nelder-Mead first. Assuming your chosen algorithm converges reasonably quickly, you could consider running it multiple times with different starting points, possibly in parallel.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: Another possibility is gradient descent. Start with a feasible value &lt;span class=&quot;math-container&quot;&gt;$\hat{a}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and solve the LP for &lt;span class=&quot;math-container&quot;&gt;$p(a).$&lt;/span&gt; Using the inverse of the basis matrix, you can express &lt;span class=&quot;math-container&quot;&gt;$p(a)$&lt;/span&gt; as a linear function of &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; (locally). Substitute that linear function into the second argument of &lt;span class=&quot;math-container&quot;&gt;$f()$&lt;/span&gt; to get &lt;span class=&quot;math-container&quot;&gt;$q(a)$&lt;/span&gt; as a (locally) linear function of &lt;span class=&quot;math-container&quot;&gt;$a.$&lt;/span&gt; Calculate the gradient of that function and negate it to get a search direction in the &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; space. Go back to the LP and calculate how far from &lt;span class=&quot;math-container&quot;&gt;$\hat{a}$&lt;/span&gt; you can go in that direction before either the problem becomes infeasible or a pivot is required. Go that far to get a new value &lt;span class=&quot;math-container&quot;&gt;$\tilde{a}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and, depending on what stopped you from going further, either project the negative gradient on the constraint(s) that you were about to violate to see if you can descend further with that basis or pivot as indicated and see if you can descend with the next basis. I suspect this will require fewer LP solutions than something like Nelder-Mead, and you will typically be able to update the LP solution using a small (?) number of dual simplex pivots.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-07-20T21:19:42.300" LastActivityDate="2022-07-20T21:19:42.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8721" PostTypeId="2" ParentId="8714" CreationDate="2022-07-20T18:59:09.317" Score="7" Body="&lt;p&gt;Presuming all variables are continuous, and given that the inner and outer level problems are both Linear, this is the simplest type of &lt;a href=&quot;https://en.wikipedia.org/wiki/Bilevel_optimization&quot; rel=&quot;noreferrer&quot;&gt;Bilevel optimization&lt;/a&gt; problem.&lt;/p&gt;&#xA;&lt;p&gt;A standard formulation is to replace the argmin with the inner LP KKT (optimality) conditions. Because of the complementarity constraint in the KKT conditions, this gives rise to a (non-convex) &lt;a href=&quot;https://en.wikipedia.org/wiki/Linear_complementarity_problem&quot; rel=&quot;noreferrer&quot;&gt;Linear Complementarity Problem&lt;/a&gt; (LCP).&lt;/p&gt;&#xA;&lt;p&gt;There are LCP solvers which can be used.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, the complementarity constraint can be linearized by introduction of binary variables and use of Big M to convert this into a MLIP.  This requires however a priori bounds on the Lagrange Multipliers, which can be problematic.  However, use of indicator constraints in a MILP solver could avoid this. Or you could provide the LCP directly to a non-convex quadratic(ally-constrained) solver, such as Gurobi, which can handle all that tricky stuff itself under the hood, likely better than you would on your own. Or use any other solver having built-in special handling for complementarity constraints, of which there are several.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2022-07-20T18:59:09.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8722" PostTypeId="1" AcceptedAnswerId="8728" CreationDate="2022-07-21T08:48:13.407" Score="3" ViewCount="123" Body="&lt;p&gt;At a particular mode, there are 2 inflow arcs, a and b, and two or more outflow arcs, which is kept to 3 for this example, i.e., c, d and e&lt;/p&gt;&#xA;&lt;p&gt;The first requirement is that only one of the two inflow arcs must be selected. Having said this, I am having difficulties modeling the following, as it differs from conventional flow conservation problems:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If arc a is selected, either one of the three outflow arcs must be selected, i.e, there is freedom to select any outflow arc.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On the other hand, should arc b be selected, only one of arcs d, e can be selected as outflow.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="491" LastEditDate="2022-07-21T18:18:08.600" LastActivityDate="2022-07-21T18:18:08.600" Title="Modeling a special case of conservation of flow" Tags="|modeling|integer-programming|constraint|binary-variable|network-flow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8723" PostTypeId="1" CreationDate="2022-07-21T08:50:22.620" Score="8" ViewCount="700" Body="&lt;p&gt;I have been wondering if my code is wrong or something. But why can't I get the optimality with only 16 nodes (I have clustered it so the max now becomes 16 from a total of 54 nodes)? My model was based on VRP Time Windows by Paschos 2014. I've tried it by using Lingo and Gurobi. The formulation is this:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\text { Minimize } \sum_{k=1}^{m} \sum_{\left(v_{i}, v_{j}\right) \in \mathcal{A}} c_{i j} x_{i j k}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;\sum_{k=1}^{m} \sum_{v_{j} \in \mathcal{V}} x_{i j k}=1 &amp;amp; \begin{array}{r}&#xA;k=1\left(v_{i}, v_{j}\right) \in \mathcal{A} \\&#xA;v_{i} \in \mathcal{V} \backslash\left\{v_{0}\right\}&#xA;\end{array} \\&#xA;\sum_{v_{i} \in \mathcal{V}} x_{i \ell k}=\sum_{v_{j} \in \mathcal{V}} x_{\ell j k} &amp;amp; v_{\ell} \in \mathcal{V} \backslash\left\{v_{0}\right\}, 1 \leqslant k \leqslant m \\&#xA;\sum_{v_{j} \in \mathcal{V} \backslash\left\{v_{0}\right\}} x_{0 j k}=1 &amp;amp; 1 \leqslant k \leqslant m \\&#xA;\sum_{v_{i} \in \mathcal{V} \backslash\left\{v_{0}\right\}} x_{i 0 k}=1 &amp;amp; 1 \leqslant k \leqslant m \\&#xA;\sum_{v_{i} \in \mathcal{V} \backslash\left\{v_{0}\right\}} \sum_{v_{j} \in \mathcal{V}} q_{i} x_{i j k} \leqslant Q &amp;amp; 1 \leqslant k \leqslant m&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;&amp;amp;a_{i} \sum_{v_{j} \in \mathcal{V}} x_{i j k} \leqslant u_{i k} \leqslant b_{i} \sum_{v_{j} \in \mathcal{V}} x_{i j k}, \quad v_{i} \in \mathcal{V}, 1 \leqslant k \leqslant m \\&#xA;&amp;amp;u_{i k}+s_{i}+t_{i j}-u_{j k} \leqslant T\left(1-x_{i j k}\right), \quad\left(v_{i}, v_{j}\right) \in \mathcal{A}, 1 \leqslant k \leqslant m \\&#xA;&amp;amp;u_{i k} \geqslant 0, \quad v_{i} \in \mathcal{V}, 1 \leqslant k \leqslant m&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The weird thing is when I tried to solve it with 10 nodes, the lingo solver was able to return the optimal solution in under 1 minute. But when I tried with real data, even for 10 hours running, the solver is still running.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Gurobi Optimizer version 9.5.2 build v9.5.2rc0 (win64)&#xA;Thread count: 2 physical cores, 4 logical processors, using up to 4 threads&#xA;Optimize a model with 168 rows, 768 columns and 2976 nonzeros&#xA;Model fingerprint: 0x460da4ce&#xA;Model has 630 general constraints&#xA;Variable types: 48 continuous, 720 integer (720 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [1e+00, 8e+01]&#xA;  Objective range  [1e+00, 5e+01]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [1e+00, 1e+03]&#xA;  GenCon rhs range [1e+01, 4e+01]&#xA;  GenCon coe range [1e+00, 1e+00]&#xA;Presolve added 1272 rows and 210 columns&#xA;Presolve time: 0.17s&#xA;Presolved: 1440 rows, 978 columns, 11136 nonzeros&#xA;Variable types: 258 continuous, 720 integer (720 binary)&#xA;&#xA;Root relaxation: objective 2.700000e+01, 67 iterations, 0.03 seconds (0.00 work units)&#xA;&#xA;    Nodes    |    Current Node    |     Objective Bounds      |     Work&#xA; Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time&#xA;&#xA;     0     0   27.00000    0   30          -   27.00000      -     -    0s&#xA;     0     0   30.02381    0   37          -   30.02381      -     -    0s&#xA;     0     0   35.00000    0   36          -   35.00000      -     -    0s&#xA;     0     0   43.00000    0   31          -   43.00000      -     -    0s&#xA;H    0     0                     281.0000000   43.00000  84.7%     -    0s&#xA;     0     0   43.00000    0   31  281.00000   43.00000  84.7%     -    0s&#xA;     0     0   43.00000    0   31  281.00000   43.00000  84.7%     -    1s&#xA;     0     0   43.00000    0   30  281.00000   43.00000  84.7%     -    1s&#xA;     0     0   43.00000    0   30  281.00000   43.00000  84.7%     -    1s&#xA;     0     0   43.00000    0   30  281.00000   43.00000  84.7%     -    1s&#xA;     0     2   43.00000    0   26  281.00000   43.00000  84.7%     -    1s&#xA;H   29    35                     198.0000000   43.00000  78.3%  21.5    1s&#xA;H   88    99                     168.0000000   43.00000  74.4%  14.0    1s&#xA;*  119   123              50     127.0000000   43.00000  66.1%  12.4    1s&#xA;H  456   391                     125.0000000   43.00000  65.6%  10.3    2s&#xA;H  463   379                     119.0000000   43.00000  63.9%  10.4    2s&#xA;   817   658   43.15451   22   27  119.00000   43.00000  63.9%  15.9    5s&#xA;H 1006   719                     118.0000000   43.00000  63.6%  16.5    5s&#xA;H 1038   692                     114.0000000   43.00000  62.3%  16.6    5s&#xA;H 1073   678                     113.0000000   43.00000  61.9%  16.6    6s&#xA;H 1705   899                     111.0000000   43.00000  61.3%  16.3    7s&#xA;  3202  1880   84.97293   66   13  111.00000   43.48152  60.8%  15.5   10s&#xA;  8845  6167   93.21239   72   10  111.00000   44.28152  60.1%  15.6   15s&#xA; 14423  9889 infeasible   64       111.00000   45.12155  59.3%  14.7   20s&#xA; 19007 13198   51.85990   38   12  111.00000   45.74524  58.8%  14.4   25s&#xA; 20856 14247   67.91148   60   30  111.00000   46.00000  58.6%  14.5   31s&#xA; 20886 14267   86.76100   43   54  111.00000   46.00000  58.6%  14.4   35s&#xA; 20987 14336   46.00000   36   33  111.00000   46.00000  58.6%  14.8   40s&#xA; 22171 14926  100.20962  115   23  111.00000   46.00000  58.6%  15.1   45s&#xA; 26640 16889 infeasible   69       111.00000   47.53714  57.2%  15.0   50s&#xA; 32818 19229   69.72771   59   26  111.00000   51.16970  53.9%  14.8   55s&#xA; 38186 21010   59.97461   45   34  111.00000   53.16667  52.1%  14.9   60s&#xA; 42489 22265   90.33333   49   14  111.00000   54.63747  50.8%  14.9   65s&#xA; 47836 24148   89.49744   77   31  111.00000   56.00000  49.5%  14.9   70s&#xA; 53826 25927   65.11477   60   34  111.00000   56.79788  48.8%  14.8   75s&#xA; 59884 27894   78.77307  154   23  111.00000   57.41955  48.3%  14.9   80s&#xA; 65719 30032  101.20672   60   24  111.00000   58.09387  47.7%  14.9   85s&#xA; 71150 33633 infeasible  115       111.00000   58.72779  47.1%  14.9   90s&#xA; 74887 36114   64.05556   52   27  111.00000   59.09387  46.8%  14.9   95s&#xA; 79892 39307  109.30875   49   24  111.00000   59.51082  46.4%  14.9  100s&#xA; 83720 41742   71.64684   51   22  111.00000   59.91729  46.0%  15.0  105s&#xA; 88446 44919   98.25571   45   10  111.00000   60.10905  45.8%  15.0  110s&#xA; 93592 48237   85.96847   48   24  111.00000   60.43274  45.6%  15.1  115s&#xA; 98541 51522   64.60322   51   25  111.00000   60.72943  45.3%  15.1  120s&#xA; 102845 54267   99.00000   65   16  111.00000   60.95160  45.1%  15.1  125s&#xA; 107394 57673   69.52727   64   22  111.00000   61.00000  45.0%  15.2  130s&#xA; 112444 61028   80.75000   78   18  111.00000   61.12951  44.9%  15.2  135s&#xA; 117523 64288   67.74127   75   16  111.00000   61.26834  44.8%  15.3  140s&#xA; 122741 67689   63.32275   65   19  111.00000   61.45337  44.6%  15.3  145s&#xA; 127607 70950  101.00000   49   12  111.00000   61.57306  44.5%  15.4  150s&#xA; 132756 74210   65.47593   42   31  111.00000   61.78555  44.3%  15.4  155s&#xA; 136990 76979   92.93333   77   15  111.00000   61.93750  44.2%  15.4  160s&#xA; 142582 80382  104.00000   76   17  111.00000   62.00000  44.1%  15.4  165s&#xA; 147283 83875  109.09497   64   19  111.00000   62.00000  44.1%  15.5  170s&#xA; 152753 87143  103.55460   60   10  111.00000   62.12951  44.0%  15.5  175s&#xA; 158126 90549   93.94203   55   19  111.00000   62.23102  43.9%  15.5  180s&#xA; 163038 93669     cutoff   60       111.00000   62.32400  43.9%  15.6  185s&#xA; 166698 95951   77.50173   77   15  111.00000   62.40379  43.8%  15.6  190s&#xA; 171727 98819  105.61448   56   22  111.00000   62.52864  43.7%  15.6  195s&#xA; 176952 102393 infeasible   99       111.00000   62.64973  43.6%  15.6  200s&#xA; 181955 105410   87.20043   45   11  111.00000   62.75701  43.5%  15.6  205s&#xA; 187145 108539   87.80647   75   35  111.00000   62.89160  43.3%  15.7  210s&#xA; 192246 111837 infeasible   79       111.00000   62.99708  43.2%  15.7  215s&#xA; 197389 115062   70.75900   85   13  111.00000   63.00000  43.2%  15.7  220s&#xA; 201353 117893   93.06245   75   31  111.00000   63.02439  43.2%  15.7  225s&#xA; 206195 120822   63.47779   54   24  111.00000   63.09691  43.2%  15.7  230s&#xA; 210899 123760  105.00546   61   14  111.00000   63.14964  43.1%  15.7  235s&#xA; 216382 127092  105.00000   74   14  111.00000   63.22222  43.0%  15.7  240s&#xA; 222038 130637   90.00000   68   12  111.00000   63.32452  43.0%  15.7  245s&#xA; 226492 133185   90.91646   44   13  111.00000   63.37571  42.9%  15.7  250s&#xA; 230755 136152   64.69033   64   20  111.00000   63.41868  42.9%  15.7  255s&#xA; 235252 138714   63.86574   57   31  111.00000   63.49554  42.8%  15.8  260s&#xA; 240283 141816 infeasible   50       111.00000   63.55502  42.7%  15.7  265s&#xA; 246089 145454   79.49498   48   18  111.00000   63.64156  42.7%  15.7  270s&#xA; 250670 148171   79.08612   52   12  111.00000   63.70720  42.6%  15.7  275s&#xA; 255030 150974   80.73087   37   15  111.00000   63.75478  42.6%  15.8  280s&#xA; 258930 153198   94.81954   45   16  111.00000   63.79969  42.5%  15.8  285s&#xA; 263816 156010   76.15049   45   25  111.00000   63.88839  42.4%  15.8  290s&#xA; 268782 158824   93.50000   49    8  111.00000   63.95633  42.4%  15.8  295s&#xA; 271310 160524   84.00000   52   15  111.00000   64.00000  42.3%  15.8  300s&#xA; 274848 162583   66.86667   34   27  111.00000   64.00000  42.3%  15.8  305s&#xA; 278496 165062 infeasible   87       111.00000   64.00000  42.3%  15.8  310s&#xA; 281970 167381     cutoff   59       111.00000   64.01453  42.3%  15.8  315s&#xA; 285890 169888   97.42763   61   20  111.00000   64.06042  42.3%  15.9  320s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10000" LastEditorUserId="36" LastEditDate="2022-07-21T12:13:06.260" LastActivityDate="2024-04-04T04:21:54.027" Title="Cannot Get Optimal Solution with 16 nodes of VRP with Time Windows" Tags="|mixed-integer-programming|vehicle-routing|" AnswerCount="6" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8724" PostTypeId="2" ParentId="8723" CreationDate="2022-07-21T09:13:25.287" Score="4" Body="&lt;p&gt;If you are sure that you don't have any bugs or flows in your code, I would recommend more strong solvers like CPLEX, Gurobi, Localsolver (those have free academic licenses) or at the very least Google OR Tools with its free license SCIP solver or its specialized Constraint Programming Solver which has a special VRPTW optimizer.&lt;/p&gt;&#xA;" OwnerUserId="632" LastEditorUserId="279" LastEditDate="2022-07-29T22:50:32.473" LastActivityDate="2022-07-29T22:50:32.473" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8725" PostTypeId="1" CreationDate="2022-07-21T13:20:39.170" Score="3" ViewCount="176" Body="&lt;p&gt;I have a resource scheduling optimization model in Pyomo with &lt;strong&gt;3 constraints&lt;/strong&gt; and an &lt;strong&gt;objective&lt;/strong&gt;. The model runs well for the minimization and maximization objectives.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Constraint1: Each job is assigned to some machine.&#xA;Constraint2: Demand job &amp;lt;= Capacity of the machine.&#xA;Constraint3: Each job must be assigned to almost 1 machine.&#xA;Objective: MIN(Jobs placement cost on different machines)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;em&gt;Now, I want to write a function that varifies my pyomo model's result is &amp;quot;as&amp;quot; expected&lt;/em&gt;.  I mean the function will confirm that my model validates all the constraints before the results.&#xA;Looking for some directions&lt;/p&gt;&#xA;" OwnerUserId="9710" LastEditorUserId="36" LastEditDate="2022-07-21T13:49:30.137" LastActivityDate="2022-07-21T13:49:30.137" Title="Testing the pyomo optimization model" Tags="|optimization|pyomo|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8726" PostTypeId="1" CreationDate="2022-07-21T13:55:08.483" Score="1" ViewCount="178" Body="&lt;p&gt;Does the Cutoff parameter in Gurobi do anything other than prohibit returning solutions below/above the cutoff value?&lt;/p&gt;&#xA;&lt;p&gt;I ask in particular because I have a maximization MIP where I am trying to find a solution of at least X (don't care if it's optimal, just X or higher).  Gurobi has previously found incumbent solutions of 0.8X, with an upper bound of 1.1X, before failing to improve.&lt;/p&gt;&#xA;&lt;p&gt;So I know that 0.8X is attainable, is there any benefit to setting Cutoff to 0.8X?  Would that speed up the solve time at all to get to an incumbent &amp;gt; 0.8X?&lt;/p&gt;&#xA;" OwnerUserId="3958" LastEditorUserId="491" LastEditDate="2022-07-21T18:19:43.770" LastActivityDate="2022-07-21T18:19:43.770" Title="Cutoff parameter in Gurobi - does it help with solve time at all?" Tags="|gurobi|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8727" PostTypeId="2" ParentId="8726" CreationDate="2022-07-21T15:56:37.907" Score="3" Body="&lt;p&gt;Yes, if the solver doesn't use a pure &amp;quot;best bound&amp;quot; strategy as selection rule, then setting a cutoff might make it possible to prune some nodes which wouldn't have been pruned otherwise. So, in theory, it should slightly speed up the resolution. In practice, one can never be sure of what will happen though.&lt;/p&gt;&#xA;&lt;p&gt;However, if you already have a solution, it's better to provide the solution directly than to give its value as cutoff.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-07-21T15:56:37.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8728" PostTypeId="2" ParentId="8722" CreationDate="2022-07-21T15:59:37.587" Score="4" Body="&lt;p&gt;Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$x_a,\dots,x_e,$&lt;/span&gt; with each variable taking value 1 if the corresponding arc is used. To limit yourself to a single input, add the constraint &lt;span class=&quot;math-container&quot;&gt;$$x_a + x_b = 1$$&lt;/span&gt; (or &lt;span class=&quot;math-container&quot;&gt;$x_a + x_b \le 1$&lt;/span&gt; if it is possible to select neither input). To force selection of exactly one output arc, add &lt;span class=&quot;math-container&quot;&gt;$$x_c + x_d + x_e = 1.$$&lt;/span&gt; Finally, to enforce your rule about the connect between input choice and output choice, just add &lt;span class=&quot;math-container&quot;&gt;$$x_c \le x_a,$$&lt;/span&gt; which lets you choose arc c only if arc a is chosen.&lt;/p&gt;&#xA;&lt;p&gt;You will presumably have separate variables for the flow across each arc. If &lt;span class=&quot;math-container&quot;&gt;$y_.$&lt;/span&gt; denotes the flow variables, you need to connect them to the selection variables with constraints of the form &lt;span class=&quot;math-container&quot;&gt;$$y_i \le M_i x_i$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is one of the arcs and &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; is an upper bound on the possible flow across arc &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; if that arc is used.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-21T15:59:37.587" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8729" PostTypeId="2" ParentId="8723" CreationDate="2022-07-21T19:25:34.830" Score="3" Body="&lt;p&gt;As the comment above explains, the Capacitated Vehicle Routing Problem with Time Windows (CVRPTW) can be modeled compactly by following a list-based modeling approach instead of the classical Boolean modeling approach, as you presented in your question. This modeling approach offered by Hexaly is different from traditional MILP solvers. If you wish to get good results using Hexaly on problems like vehicle routing, job shop scheduling, or bin packing, please use this &lt;a href=&quot;https://www.hexaly.com/docs/last/modelingfeatures/collectionvariables.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;set or list-based modeling approach&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note that LocalSolver is commercial software. Nevertheless, it is free for faculty and students.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Below is the code snippet to model the CVRPTW by using Hexaly Modeler:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function model() {&#xA;    customersSequences[k in 1..nbTrucks] &amp;lt;- list(nbCustomers);&#xA;&#xA;    // All customers must be visited by the trucks&#xA;    constraint partition[k in 1..nbTrucks](customersSequences[k]);&#xA;&#xA;    for[k in 1..nbTrucks] {&#xA;        local sequence &amp;lt;- customersSequences[k];&#xA;        local c &amp;lt;- count(sequence);&#xA;&#xA;        // A truck is used if it visits at least one customer&#xA;        truckUsed[k] &amp;lt;- c &amp;gt; 0;&#xA;&#xA;        // The quantity needed in each route must not exceed the truck capacity&#xA;        routeQuantity[k] &amp;lt;- sum(0..c-1, i =&amp;gt; demands[sequence[i]]);&#xA;        constraint routeQuantity[k] &amp;lt;= truckCapacity;&#xA;&#xA;        endTime[k] &amp;lt;- array(0..c-1, (i, prev) =&amp;gt; max(earliestStart[sequence[i]],&#xA;                i == 0 ? distanceWarehouse[sequence[0]] :&#xA;                prev + distanceMatrix[sequence[i-1]][sequence[i]])&#xA;                + serviceTime[sequence[i]]);&#xA;&#xA;        homeLateness[k] &amp;lt;- truckUsed[k] ?&#xA;                max(0, endTime[k][c - 1] + distanceWarehouse[sequence[c - 1]] - maxHorizon) :&#xA;                0;&#xA;&#xA;        // Distance traveled by truck k&#xA;        routeDistances[k] &amp;lt;- sum(1..c-1,&#xA;                i =&amp;gt; distanceMatrix[sequence[i-1]][sequence[i]]) + (truckUsed[k] ?&#xA;                (distanceWarehouse[sequence[0]] + distanceWarehouse[sequence[c-1]]) :&#xA;                0);&#xA;&#xA;        lateness[k] &amp;lt;- homeLateness[k] + sum(0..c-1,&#xA;                i =&amp;gt; max(0, endTime[k][i] - latestEnd[sequence[i]]));&#xA;    }&#xA;&#xA;    // Total lateness, must be 0 for a solution to be valid&#xA;    totalLateness &amp;lt;- sum[k in 1..nbTrucks](lateness[k]);&#xA;&#xA;    nbTrucksUsed &amp;lt;- sum[k in 1..nbTrucks](truckUsed[k]);&#xA;&#xA;    // Total distance traveled (convention in Solomon's instances is to round to 2 decimals)&#xA;    totalDistance &amp;lt;- round(100 * sum[k in 1..nbTrucks](routeDistances[k])) / 100;&#xA;&#xA;    minimize totalLateness;&#xA;    minimize nbTrucksUsed;&#xA;    minimize totalDistance;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For the complete ready-to-use code in Hexaly Modeler, Python, Java, C#, or C++, please have a look at &lt;a href=&quot;https://www.hexaly.com/docs/last/exampletour/vrptw.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.hexaly.com/docs/last/exampletour/vrptw.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T04:21:54.027" LastActivityDate="2024-04-04T04:21:54.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8730" PostTypeId="1" AcceptedAnswerId="8732" CreationDate="2022-07-22T03:07:45.900" Score="3" ViewCount="205" Body="&lt;p&gt;I am currently working on a multi-objective problem where I am trying to minimize cost and time. I am using Docplex to solve it, but I did not specify any weight using the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mdl.set_multi_objective(ObjectiveSense.Minimize, [totalcost,cumultime], priorities=[1, 2])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Understandably, I did set a lexicographic order, but I would like to know what is the default weight allocation. Should I assume that by solving it, Docplex also determines the optimal weight allocation ? If you can provide the relevant documentation, I'd be grateful.&lt;/p&gt;&#xA;" OwnerUserId="4491" LastEditorUserId="4491" LastEditDate="2022-07-22T03:27:55.797" LastActivityDate="2022-07-22T12:16:53.200" Title="What is the default weight allocation in solving multi-objective on CPLEX?" Tags="|multi-objective-optimization|docplex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8731" PostTypeId="1" CreationDate="2022-07-22T04:49:36.343" Score="2" ViewCount="61" Body="&lt;p&gt;I think my model takes much time because the time windows width given the problem i want to solve.&#xA;Here is the time matrix:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;0   23  73  71  61  58  35  22  57  57  56  55  55  53  53  52  48&#xA;23  0   5   6   24  19  19  17  23  17  18  20  34  22  22  21  22&#xA;15  5   0   4   28  23  23  23  22  21  23  24  24  27  27  26  26&#xA;23  6   4   0   29  23  23  22  22  21  23  24  23  26  26  25  24&#xA;61  24  28  29  0   7   8   9   10  12  11  10  10  10  10  12  20&#xA;58  19  23  23  7   0   1   3   3   5   4   4   4   5   6   7   14&#xA;58  19  23  23  8   1   0   2   2   4   4   3   3   5   5   6   13&#xA;12  17  11  22  9   3   2   0   1   3   3   4   3   6   6   6   13&#xA;57  18  22  22  5   3   2   1   0   3   2   3   3   5   5   6   12&#xA;57  17  21  21  12  5   4   3   3   0   2   4   3   6   6   5   10&#xA;56  18  23  22  11  4   4   3   2   2   0   2   2   4   5   4   10&#xA;55  20  24  24  10  4   3   4   3   4   2   0   1   3   3   3   11&#xA;23  19  24  23  10  4   3   3   3   3   2   1   0   3   3   4   11&#xA;53  22  23  26  10  5   5   6   5   6   4   3   3   0   1   2   11&#xA;53  23  27  26  10  6   5   6   5   6   5   3   3   1   0   2   11&#xA;52  21  26  25  12  7   6   6   6   5   4   3   4   2   2   0   9&#xA;48  22  26  45  20  34  13  13  12  10  10  11  11  11  11  9   0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The case is i want a route for perishable product that deliver the product under like 8 hours, given the 17x17 time matrix above. There are nodes that are really close to each others.&#xA;So the earliest will be all 0 for all nodes. And the latest will be all 480 (in minutes) for all nodes too. The service time is about 13 minutes for each nodes. Does anyone have any advice regarding this problem?&lt;/p&gt;&#xA;" OwnerUserId="10000" LastActivityDate="2022-07-22T04:49:36.343" Title="Preprocessing Time Windows Width in Vehicle Routing Problem (VRP)" Tags="|mixed-integer-programming|vehicle-routing|supply-chain|logistics|" AnswerCount="0" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8732" PostTypeId="2" ParentId="8730" CreationDate="2022-07-22T12:16:53.200" Score="5" Body="&lt;p&gt;Weights are defined by you to tell CPLEX how objectives with the same priorities are blended together. If you don't define weights, by default they are all assumed to be equal to 1.&lt;/p&gt;&#xA;&lt;p&gt;Let's assume in your example that you have 3 objectives: &lt;code&gt;[obj1, obj2, obj3]&lt;/code&gt; with the following priorities and weights:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;mdl.set_multi_objective(ObjectiveSense.Minimize, [obj1, obj2, obj3], priorities=[1, 2, 2], weights=[1, 80, 20])&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;code&gt;obj2&lt;/code&gt; and &lt;code&gt;obj3&lt;/code&gt; have the same priority. So, they are blended together and the weights you define are used for that blending (making that objective a weighted sum).&#xA;Basically, the CPLEX first solves for &lt;code&gt;obj1&lt;/code&gt; and find &lt;code&gt;sol1&lt;/code&gt; for it. Then it adds the constraint that &lt;span class=&quot;math-container&quot;&gt;$obj1 \le sol1$&lt;/span&gt; (since you're minimizing) and solves for &lt;code&gt;80obj2 + 20obj3&lt;/code&gt;. If you don't provide any weights, you're solving for &lt;code&gt;obj2 + obj3&lt;/code&gt; (remember, we assigned the same priorities to these two objectives)&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2022-07-22T12:16:53.200" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8733" PostTypeId="2" ParentId="8723" CreationDate="2022-07-22T13:08:45.593" Score="2" Body="&lt;p&gt;Another alternative for VRPTW is &lt;a href=&quot;https://www.optaplanner.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner&lt;/a&gt; (Java) or &lt;a href=&quot;https://www.optapy.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPy&lt;/a&gt; (Python). It's &lt;strong&gt;open source&lt;/strong&gt; (Apache license, so 100% free) and used across the globe extensively, including in Fortune 500 companies that use it for VRPTW cases of 10 000+ vehicles.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kiegroup/optaplanner-quickstarts/tree/stable/use-cases/vehicle-routing#readme&quot; rel=&quot;nofollow noreferrer&quot;&gt;Java source code for VRP (with web UI)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/optapy/optapy-quickstarts/tree/stable/vehicle-routing#readme&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python source code for VRP (with Jupyter notebook)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kiegroup/optaplanner/tree/main/optaplanner-examples/src/main/java/org/optaplanner/examples/vehiclerouting/domain/timewindowed&quot; rel=&quot;nofollow noreferrer&quot;&gt;Java source code for VRPTW&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Example source code to assign each customer to a vehicle:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Model&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@PlanningEntity&#xA;public class Vehicle {&#xA;&#xA;    private long id;&#xA;    private int capacity;&#xA;    private Depot depot;&#xA;&#xA;    @PlanningListVariable(valueRangeProviderRefs = &amp;quot;customerRange&amp;quot;)&#xA;    private List&amp;lt;Customer&amp;gt; customerList;&#xA;&#xA;    ...&#xA;}&#xA;&#xA;public class Customer {&#xA;&#xA;    private long id;&#xA;    private Location location;&#xA;    private int demand;&#xA;&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;public class VehicleRoutingConstraintProvider implements ConstraintProvider {&#xA;&#xA;    @Override&#xA;    public Constraint[] defineConstraints(ConstraintFactory factory) {&#xA;        return new Constraint[] {&#xA;                vehicleCapacity(factory),&#xA;                totalDistance(factory),&#xA;        };&#xA;    }&#xA;&#xA;    // ************************************************************************&#xA;    // Hard constraints&#xA;    // ************************************************************************&#xA;&#xA;    protected Constraint vehicleCapacity(ConstraintFactory factory) {&#xA;        return factory.forEach(Vehicle.class)&#xA;                .filter(vehicle -&amp;gt; vehicle.getTotalDemand() &amp;gt; vehicle.getCapacity())&#xA;                .penalizeLong(&#xA;                        &amp;quot;vehicleCapacity&amp;quot;,&#xA;                        HardSoftLongScore.ONE_HARD,&#xA;                        vehicle -&amp;gt; vehicle.getTotalDemand() - vehicle.getCapacity());&#xA;    }&#xA;&#xA;    // ************************************************************************&#xA;    // Soft constraints&#xA;    // ************************************************************************&#xA;&#xA;    protected Constraint totalDistance(ConstraintFactory factory) {&#xA;        return factory.forEach(Vehicle.class)&#xA;                .penalizeLong(&#xA;                        &amp;quot;distanceFromPreviousStandstill&amp;quot;,&#xA;                        HardSoftLongScore.ONE_SOFT,&#xA;                        Vehicle::getTotalDistanceMeters);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="350" LastActivityDate="2022-07-22T13:08:45.593" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8734" PostTypeId="1" CreationDate="2022-07-22T15:30:44.590" Score="1" ViewCount="275" Body="&lt;p&gt;I have a multi-objective problem with three objectives F1, F2, and F3. the problem was formulated as a weighted sum. Now I didn't know how I can choose the right weight for my problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pfboh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pfboh.png&quot; alt=&quot;in the image I showed my experimentation with different weights&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9833" LastEditorUserId="9833" LastEditDate="2022-07-22T15:31:46.780" LastActivityDate="2022-07-23T10:27:22.230" Title="How can we choose the right weight to solve multi-objective problem using weighted sum method?" Tags="|metaheuristics|multi-objective-optimization|multicriteria-decision-analysis|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8735" PostTypeId="2" ParentId="8723" CreationDate="2022-07-22T15:39:40.793" Score="3" Body="&lt;p&gt;And yet another open source option (python): &lt;a href=&quot;https://pypi.org/project/vrpy/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vrpy&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An example with time windows (&lt;a href=&quot;https://developers.google.com/optimization/routing/vrptw&quot; rel=&quot;nofollow noreferrer&quot;&gt;borrowed&lt;/a&gt; from the excellent ortools module) is presented in the docs &lt;a href=&quot;https://vrpy.readthedocs.io/en/latest/examples.html#vrp-with-time-windows&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from networkx import DiGraph, from_numpy_matrix, relabel_nodes, set_node_attributes&#xA;from numpy import array&#xA;&#xA;# Distance matrix&#xA;DISTANCES = [&#xA;     [0,548,776,696,582,274,502,194,308,194,536,502,388,354,468,776,662,0], # from Source&#xA;     [0,0,684,308,194,502,730,354,696,742,1084,594,480,674,1016,868,1210,548],&#xA;     [0,684,0,992,878,502,274,810,468,742,400,1278,1164,1130,788,1552,754,776],&#xA;     [0,308,992,0,114,650,878,502,844,890,1232,514,628,822,1164,560,1358,696],&#xA;     [0,194,878,114,0,536,764,388,730,776,1118,400,514,708,1050,674,1244,582],&#xA;     [0,502,502,650,536,0,228,308,194,240,582,776,662,628,514,1050,708,274],&#xA;     [0,730,274,878,764,228,0,536,194,468,354,1004,890,856,514,1278,480,502],&#xA;     [0,354,810,502,388,308,536,0,342,388,730,468,354,320,662,742,856,194],&#xA;     [0,696,468,844,730,194,194,342,0,274,388,810,696,662,320,1084,514,308],&#xA;     [0,742,742,890,776,240,468,388,274,0,342,536,422,388,274,810,468,194],&#xA;     [0,1084,400,1232,1118,582,354,730,388,342,0,878,764,730,388,1152,354,536],&#xA;     [0,594,1278,514,400,776,1004,468,810,536,878,0,114,308,650,274,844,502],&#xA;     [0,480,1164,628,514,662,890,354,696,422,764,114,0,194,536,388,730,388],&#xA;     [0,674,1130,822,708,628,856,320,662,388,730,308,194,0,342,422,536,354],&#xA;     [0,1016,788,1164,1050,514,514,662,320,274,388,650,536,342,0,764,194,468],&#xA;     [0,868,1552,560,674,1050,1278,742,1084,810,1152,274,388,422,764,0,798,776],&#xA;     [0,1210,754,1358,1244,708,480,856,514,468,354,844,730,536,194,798,0,662],&#xA;     [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], # from Sink&#xA;     ]&#xA;&#xA;TRAVEL_TIMES = [&#xA;    [0, 6, 9, 8, 7, 3, 6, 2, 3, 2, 6, 6, 4, 4, 5, 9, 7, 0],  # from source&#xA;    [0, 0, 8, 3, 2, 6, 8, 4, 8, 8, 13, 7, 5, 8, 12, 10, 14, 6],&#xA;    [0, 8, 0, 11, 10, 6, 3, 9, 5, 8, 4, 15, 14, 13, 9, 18, 9, 9],&#xA;    [0, 3, 11, 0, 1, 7, 10, 6, 10, 10, 14, 6, 7, 9, 14, 6, 16, 8],&#xA;    [0, 2, 10, 1, 0, 6, 9, 4, 8, 9, 13, 4, 6, 8, 12, 8, 14, 7],&#xA;    [0, 6, 6, 7, 6, 0, 2, 3, 2, 2, 7, 9, 7, 7, 6, 12, 8, 3],&#xA;    [0, 8, 3, 10, 9, 2, 0, 6, 2, 5, 4, 12, 10, 10, 6, 15, 5, 6],&#xA;    [0, 4, 9, 6, 4, 3, 6, 0, 4, 4, 8, 5, 4, 3, 7, 8, 10, 2],&#xA;    [0, 8, 5, 10, 8, 2, 2, 4, 0, 3, 4, 9, 8, 7, 3, 13, 6, 3],&#xA;    [0, 8, 8, 10, 9, 2, 5, 4, 3, 0, 4, 6, 5, 4, 3, 9, 5, 2],&#xA;    [0, 13, 4, 14, 13, 7, 4, 8, 4, 4, 0, 10, 9, 8, 4, 13, 4, 6],&#xA;    [0, 7, 15, 6, 4, 9, 12, 5, 9, 6, 10, 0, 1, 3, 7, 3, 10, 6],&#xA;    [0, 5, 14, 7, 6, 7, 10, 4, 8, 5, 9, 1, 0, 2, 6, 4, 8, 4],&#xA;    [0, 8, 13, 9, 8, 7, 10, 3, 7, 4, 8, 3, 2, 0, 4, 5, 6, 4],&#xA;    [0, 12, 9, 14, 12, 6, 6, 7, 3, 3, 4, 7, 6, 4, 0, 9, 2, 5],&#xA;    [0, 10, 18, 6, 8, 12, 15, 8, 13, 9, 13, 3, 4, 5, 9, 0, 9, 9],&#xA;    [0, 14, 9, 16, 14, 8, 5, 10, 6, 5, 4, 10, 8, 6, 2, 9, 0, 7],&#xA;    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  # from sink&#xA;    ]&#xA;&#xA;# Time windows (key: node, value: lower/upper bound)&#xA;TIME_WINDOWS_LOWER = {0: 0, 1: 7, 2: 10, 3: 16, 4: 10, 5: 0, 6: 5, 7: 0, 8: 5, 9: 0, 10: 10, 11: 10, 12: 0, 13: 5, 14: 7, 15: 10, 16: 11,}&#xA;TIME_WINDOWS_UPPER = {1: 12, 2: 15, 3: 18, 4: 13, 5: 5, 6: 10, 7: 4, 8: 10, 9: 3, 10: 16, 11: 15, 12: 5, 13: 10, 14: 8, 15: 15, 16: 15,}&#xA;&#xA;# Transform distance matrix into DiGraph&#xA;A = array(DISTANCES, dtype=[(&amp;quot;cost&amp;quot;, int)])&#xA;G_d = from_numpy_matrix(A, create_using=DiGraph())&#xA;&#xA;# Transform time matrix into DiGraph&#xA;A = array(TRAVEL_TIMES, dtype=[(&amp;quot;time&amp;quot;, int)])&#xA;G_t = from_numpy_matrix(A, create_using=DiGraph())&#xA;&#xA;# Merge&#xA;G = compose(G_d, G_t)&#xA;&#xA;# Set time windows&#xA;set_node_attributes(G, values=TIME_WINDOWS_LOWER, name=&amp;quot;lower&amp;quot;)&#xA;set_node_attributes(G, values=TIME_WINDOWS_UPPER, name=&amp;quot;upper&amp;quot;)&#xA;&#xA;# The VRP is defined and solved&#xA;prob = VehicleRoutingProblem(G, time_windows=True)&#xA;prob.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-07-22T15:39:40.793" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8736" PostTypeId="1" AcceptedAnswerId="8737" CreationDate="2022-07-22T16:56:50.793" Score="2" ViewCount="106" Body="&lt;p&gt;I have a problem with my current research that I have come across repeatedly over my research career in various different fields. It goes like this.&lt;/p&gt;&#xA;&lt;p&gt;You are trying to characterise instances of some particular category that you study. This can be trees, buildings, chemical substances or English sentences. You determine a few discrete variables that you want to measure for each particular instance. For example, if we are talking about buildings, you may decide to focus on the main construction material (stone, wood, brick, etc.), use (residence, office space, public institution, etc.), construction decade (1940s, 1950s, 1960s, etc.), height bracket (under 5 m, between 5 and 100 m, between 100 and 300 m, over 300 m), plus others. Each individual instance that you observe (each building in our example) can be characterised by giving it a value for each variable. For example, building A may be made of wood, used for residence, constructed in the 1960s, and having a height in the 5-100 m bracket.&lt;/p&gt;&#xA;&lt;p&gt;In real-world situations, you may have many variables (ten or twenty is not uncommon), and each variable may be able to take multiple values (many take 5-10 values; some may take up to 40 or 50). This creates a &amp;quot;solution space&amp;quot; of as many dimensions as variables, and as many individual points as distinct combinations of values. In my current research, I am working with 6 variables, some of which may take up to 12 different values, adding up to a solution space having over 15.000 points.&lt;/p&gt;&#xA;&lt;p&gt;Now, I want to verify if every possible combination of values is possible. In other words, I want to check if there might be instances of the things I'm studying at every point in the solution space. In the example above, there aren't any buildings constructed in the 1880s and having a height of over 300 m. I have a suspicion that many areas in the solution space are similarly &amp;quot;impossible&amp;quot; areas, in the sense that there are combinations of values that are incompatible amongst each other and can't be found in the real world.&lt;/p&gt;&#xA;&lt;p&gt;Of course, I can create a multi-dimensional matrix with thousands of cells, and start evaluating the possibility of finding an instance for each one. But this would take ages and is difficult to visualise and process without making mistakes. So, my question is, is there any particular technique to tackle a problem like this?&lt;/p&gt;&#xA;" OwnerUserId="10012" LastActivityDate="2022-07-22T17:34:53.133" Title="Method to test compatibility between variable values" Tags="|modeling|reference-request|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8737" PostTypeId="2" ParentId="8736" CreationDate="2022-07-22T17:34:53.133" Score="2" Body="&lt;p&gt;I'm just spitballing here, and I'm assuming the data is discrete (which would require a preliminary, perhaps arbitrary, chopping of continuous data into intervals). Let &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; be the set of all observations. My first step would be to sort the variables into ascending size of their domains (breaking ties whimsically). Now partion &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; into the disjoint union &lt;span class=&quot;math-container&quot;&gt;$O_1 \cup \dots \cup O_n$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$1,\dots,n$&lt;/span&gt; indexes the domain of the first variable. If &lt;span class=&quot;math-container&quot;&gt;$O_i=\emptyset$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, then obviously any point in solution space using the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th value of the first variable is impossible.&lt;/p&gt;&#xA;&lt;p&gt;Now partition each nonempty &lt;span class=&quot;math-container&quot;&gt;$O_i$&lt;/span&gt; into a disjoint union &lt;span class=&quot;math-container&quot;&gt;$O_{i1}\cup\dots\cup O_{im}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$1,\dots,m$&lt;/span&gt; indexes the domain of the second variable. Again, any empty set signals a combination of values for the first two variables that never occurs. Repeat until you have gone through all variables. At that point, the list of empty sets translates to a list of unobserved (&amp;quot;impossible&amp;quot;?) combinations.&lt;/p&gt;&#xA;&lt;p&gt;The initial sort is not necessary conceptually. I'm just hoping that it will allow early &amp;quot;pruning&amp;quot; of the unions and help keep down the number of sets. The number of sets will grow, although the sum of their cardinalities will remain constant.&lt;/p&gt;&#xA;&lt;p&gt;What you end up with is a list of unobserved combinations. If you need some sort of compact characterization (e.g., you don't encounter trees with heights in categories 3 through 6 that have seed pods of types 2 or 3 in climates 1 through 5), you might want to look at something like clustering or perhaps some sort of decision tree/decision forest model (no pun intended) to aggregate the unobserved combinations.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-22T17:34:53.133" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8738" PostTypeId="2" ParentId="8734" CreationDate="2022-07-22T17:42:51.673" Score="1" Body="&lt;p&gt;I'm going to assume here that bigger is better for all criteria. Let &lt;span class=&quot;math-container&quot;&gt;$x_{a,c}$&lt;/span&gt; be the score for alternative &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; on criterion &lt;span class=&quot;math-container&quot;&gt;$c,$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$a\in \lbrace 1,\dots,A\rbrace$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c\in\lbrace 1,\dots,C\rbrace.$&lt;/span&gt; Any easy way to find a single Pareto-efficient point is to generate a random vector &lt;span class=&quot;math-container&quot;&gt;$w\in (0,1)^C$&lt;/span&gt; and compute the score &lt;span class=&quot;math-container&quot;&gt;$s_a = \sum_{c=1}^C w_c x_{a,c}$&lt;/span&gt; for each alternative &lt;span class=&quot;math-container&quot;&gt;$a.$&lt;/span&gt; The alternative with the highest score is automatically efficient, since any alternative that dominated it would have a higher score.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-22T17:42:51.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8739" PostTypeId="1" CreationDate="2022-07-22T18:43:40.407" Score="1" ViewCount="47" Body="&lt;p&gt;I'm doing a clustering algorithm to group properties. In this sense, I have geographic coordinate information for these properties. However, for the clustering process, I would like to exclude some outliers properties. For this, I made the following pseudocode.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Algorithm: Exclusion of outliers properties&#xA;&#xA;1: procedure EXCLUSION OF OUTLIERS PROPERTIES (uij)&#xA;&#xA;2: Calculate dik as in (4), which is the Euclidean distance between &#xA;   all properties to be clustered.&#xA;&#xA;dik=√(ui2- uk2)2+(ui3- uk3)² ,                     (4)&#xA;&#xA;with i and k from 1, …, n and i≠k&#xA;&#xA;m=mean (dik)                                       (5)&#xA;&#xA;sd=Standard Deviation (dik)                        (6)&#xA;&#xA;limit=m+3*sd                                       (7)&#xA;&#xA;3: Select property i from {uij} that has distance dik&amp;lt;= limit ∀k, ∀i&#xA;&#xA;4: end procedure&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, after I use the Euclidean distance between the properties in step 2, a distance matrix from each location to every other location is generated. Ex:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;         [,1]     [,2]      [,3]      [,4]&#xA; [1,]    0.000 1522.997 1693.9978 2413.0564&#xA; [2,] 1522.997    0.000 2410.7105 2748.2810&#xA; [3,] 1693.998 2410.711    0.0000  825.7868&#xA; [4,] 2413.056 2748.281  825.7868    0.0000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;From this matrix, I take the smallest distance value for each unit. For example, the smallest value between property 1 and other properties is 1522.9967. For the second property, it is 1522.9967, and so on. In this case, I have an matrix like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;         [,1]&#xA;[1,] 1522.9967&#xA;[2,] 1522.9967&#xA;[3,]  825.7868&#xA;[4,]  825.7868&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So from this matrix, I do &lt;code&gt;mean&lt;/code&gt; and &lt;code&gt;standard deviation&lt;/code&gt; and so I find &lt;code&gt;limit&lt;/code&gt; value. However, I would like to make this adjustment in the pseudocode, regarding this new change I made. Can you help me?&lt;/p&gt;&#xA;" OwnerUserId="9063" LastEditorUserId="123" LastEditDate="2022-07-22T20:43:33.553" LastActivityDate="2022-07-22T20:43:33.553" Title="Adjust pseudocode for outliers" Tags="|algorithms|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8740" PostTypeId="2" ParentId="8734" CreationDate="2022-07-23T10:27:22.230" Score="1" Body="&lt;p&gt;As far as I know, solving the multi-objective optimization by the weighted sum method should give one of the solutions that already exists on the Pareto non-dominance solution frontier. Let us make a simple example. Suppose, there is a multi-objective problem with only two objects. Named &lt;span class=&quot;math-container&quot;&gt;$Z_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z_2$&lt;/span&gt;. Now, solving this by a weighted sum and again by &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-constraints. The results are as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Weighted sum method&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Z_1 = 2800$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z_2 = 17.9$&lt;/span&gt; within the arbitrary weights for each objective.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;&lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-constraint method with an &lt;span class=&quot;math-container&quot;&gt;$\epsilon = 0.00001$&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first solution is: &lt;span class=&quot;math-container&quot;&gt;$Z_1 = 2790$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z_2 = 20$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The second solution is: &lt;span class=&quot;math-container&quot;&gt;$Z_1 = 2800$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z_2 = 17.9$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As you can see, the first method gives the second non-dominance solution. Also, I am not aware of if, there exists any contradiction to that. I hope this will be helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-07-23T10:27:22.230" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8741" PostTypeId="1" CreationDate="2022-07-23T11:35:45.787" Score="12" ViewCount="173" Body="&lt;p&gt;There are many of the formulations to linearize logical constraints by introducing new auxiliary binary or any appropriate variables and adding the corresponding constraints to the model. It can be found by a simple search on the community or other available resources on the web easily.&lt;/p&gt;&#xA;&lt;p&gt;Now, I am interested to know how the standard MIP solvers do that automatically and how they found the suitable formulation. Once I tried a simple logical expression by CPLEX. By adding one or two binary variables and their related constraints the problem was solved.&lt;/p&gt;&#xA;&lt;p&gt;But, when I tried the automatic mode by adding special if-then constraints and writing the model in the LP format, I saw there exist more than eight binary variables. I am looking for a standard method, but I cannot find any related resources.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-07-23T11:35:45.787" Title="which method has been used to automatically reformulate logical constraints in a standard MIP solver?" Tags="|mixed-integer-programming|solver|logical-constraints|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8742" PostTypeId="1" CreationDate="2022-07-24T22:14:58.423" Score="2" ViewCount="236" Body="&lt;p&gt;I have a model say &lt;strong&gt;cost.py&lt;/strong&gt; as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import statements&#xA;def mymodel():&#xA;     model = ConcreteModel()&#xA;&#xA;     model.var =  #Some variables&#xA;     moddel.par=   #Some variables&#xA;     model.const = #Some Constraints&#xA;&#xA;     model.obj1 = Objective(expr=(model.var * model.par)+(model.var2 * model.par1), sense=minimize)&#xA;&#xA;     status = SolverFactory('glpk')&#xA;     results = status.solve(model)&#xA;     assert_optimal_termination(results)&#xA;     model.display()&#xA;mymodel()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now I have another file in the same directory say &lt;strong&gt;test.py.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I want to use the model in cost.py and its &lt;strong&gt;variable, parameters and results&lt;/strong&gt; in test.py. I am doing it because I want to write a seperate &lt;em&gt;testing function&lt;/em&gt; in the &lt;strong&gt;test.py&lt;/strong&gt; to check whether my &lt;strong&gt;cost.py&lt;/strong&gt; model is functioning as it should be or not? &lt;em&gt;Please guide me on how to import the variable, parameters and result.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="9710" LastEditorUserId="491" LastEditDate="2022-12-04T20:39:32.260" LastActivityDate="2022-12-04T20:39:32.260" Title="Is it possible to import the pyomo model solution in another .py file in the same directory" Tags="|optimization|constraint|pyomo|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8743" PostTypeId="1" CreationDate="2022-07-25T04:28:17.330" Score="2" ViewCount="68" Body="&lt;p&gt;I have been wondering is there any paper that who discuss multi commodity with four index/indices like this formulation below:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{gathered}&#xA;\sum_{k} \sum_{c} F_{j, j, c, k}=1 \quad \forall j \\&#xA;\sum_{i} F_{i, j, c, k}=\sum_{i} F_{j, i, c, k} \quad \forall c, j, k \\&#xA;\sum_{i, j, c, k} F_{i, j, c, k}=q_{i} \quad \forall i \\&#xA;\sum_{i, j, c, k} F_{i, j, c, k} \leq Q * x_{i, j, k} \quad \forall i, j, c, k&#xA;\end{gathered}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10000" LastActivityDate="2022-07-28T16:27:52.930" Title="Multi Commodity VRP Time Windows Paper" Tags="|linear-programming|integer-programming|gurobi|vehicle-routing|logistics|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8744" PostTypeId="2" ParentId="8723" CreationDate="2022-07-25T07:56:02.700" Score="5" Body="&lt;p&gt;It is well-known that MIP solvers are relatively inefficient for solving VRPs. If you really want to obtain (and prove) an optimal solution, you should use branch-cut-and-price solvers like VRPSolver (&lt;a href=&quot;https://vrpsolver.math.u-bordeaux.fr&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vrpsolver.math.u-bordeaux.fr&lt;/a&gt;). If you prefer C++, there is BaPCod with VRPSolver extension (&lt;a href=&quot;https://bapcod.math.u-bordeaux.fr/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://bapcod.math.u-bordeaux.fr/&lt;/a&gt;), it has the VRPTW demo which you can use.  There is also GCG (&lt;a href=&quot;https://gcg.or.rwth-aachen.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gcg.or.rwth-aachen.de/&lt;/a&gt;), which is less efficient for VRPs, but still solving an instance with 16 nodes will be very fast with it. If it is sufficient to get just a good solution, there are heuristic solvers, like LocalSolver, OR-Tools, Optaplanner, as suggested by others.&lt;/p&gt;&#xA;" OwnerUserId="835" LastEditorUserId="835" LastEditDate="2022-07-26T11:12:06.623" LastActivityDate="2022-07-26T11:12:06.623" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8745" PostTypeId="2" ParentId="8713" CreationDate="2022-07-25T10:28:54.533" Score="6" Body="&lt;p&gt;If my understanding of the problem is correct, the following formulation should be tighter. I am assuming the types of possible bags are predefined.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; be the number of bags of type &lt;span class=&quot;math-container&quot;&gt;$i\in \{1,...,20\}$&lt;/span&gt; that are selected in the solution. In bag &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, you have &lt;span class=&quot;math-container&quot;&gt;$n_{i,k}$&lt;/span&gt; groceries of type &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You need the following requirements:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;at most 20 bags:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_i x_i \le 20 \tag{1}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;groceries requirements:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i| k \in i} n_{i,k} x_i \ge r_k \quad \mbox{for every grocery } k \tag{2}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now, if this is not feasible, you want to satisfy your requirements as much as possible. You could introduce a new variable per grocery &lt;span class=&quot;math-container&quot;&gt;$y_k$&lt;/span&gt; and replace constraints &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i| k \in i} n_{i,k} x_i + y_k \ge r_k \quad \mbox{for every grocery } k \tag{3}&#xA;$$&lt;/span&gt;&#xA;and minimize &lt;span class=&quot;math-container&quot;&gt;$\max_k{y_k}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-07-25T10:28:54.533" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8746" PostTypeId="2" ParentId="8742" CreationDate="2022-07-25T12:19:18.907" Score="2" Body="&lt;p&gt;Here is one way I can think of.&#xA;In your &lt;code&gt;cost.py&lt;/code&gt;, you have something like the following (I'm assuming you import &lt;code&gt;pyomo&lt;/code&gt; or whatever package you need):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;class MyModel:&#xA;    def __init__(self, *args, **kwargs):&#xA;        # whatever you need to pass to the class&#xA;        self.model = ConcreteModel()&#xA;        self.model.var = ...&#xA;        self.model.par = ...&#xA;        self.model.const = ...&#xA;        self.results = None  # just a placeholder. It'll be populated later&#xA;        # just an example. You don't need to define all of them in init method.&#xA;        # To give an example, I define objectives in a different method&#xA;&#xA;    def set_objective(self):&#xA;        self.model.obj1 = Objective(expr=(self.model.var * self.model.par)+(self.model.var2 * self.model.par1), sense=minimize)&#xA;        status = SolverFactory('glpk')&#xA;        self.results = status.solve(self.model)&#xA;        assert_optimal_termination(self.results)&#xA;        self.model.display()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now, in &lt;code&gt;test.py&lt;/code&gt;, you can have a function called &lt;code&gt;test_func()&lt;/code&gt;. It can be defined as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from cost import MyModel&#xA;&#xA;def test(mm):&#xA;    # mm here is the instance of MyModel class that I passed to test_func&#xA;    var = mm.model.var&#xA;    par = mm.model.par&#xA;    result = mm.results&#xA;    # do whatever you need to do here&#xA;    &#xA;&#xA;if __name__ == '__main__':&#xA;    mm = MyModel()  # pass whatever arguments you need to initialize the class&#xA;    mm.set_objective()  # after a successful run, `mm.results` will have values&#xA;    test(mm)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Something like this should do the job for you.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2022-07-25T12:19:18.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8747" PostTypeId="2" ParentId="8742" CreationDate="2022-07-25T13:53:02.990" Score="2" Body="&lt;p&gt;Yes.  The simplest thing you can do is to change &lt;code&gt;mymodel()&lt;/code&gt; to return the model that it creates, then store that object at the module scope.  That is:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;def mymodel():&#xA;    # ....&#xA;    model.display()&#xA;    return model&#xA;&#xA;model = mymodel()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then, in &lt;code&gt;test.py&lt;/code&gt;, you can get the model using &lt;code&gt;from cost import model&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In addition, you will likely find it very helpful to separate the generation of the model from the invocation of the solver.  That is, I would recommend having two functions in &lt;code&gt;cost.py&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import statements&#xA;def create_mymodel():&#xA;     model = ConcreteModel()&#xA;&#xA;     model.var =  #Some variables&#xA;     moddel.par=   #Some variables&#xA;     model.const = #Some Constraints&#xA;&#xA;     model.obj1 = Objective(expr=(model.var * model.par)+(model.var2 * model.par1), sense=minimize)&#xA;     return model&#xA;&#xA;def solve_mymodel(model):&#xA;     status = SolverFactory('glpk')&#xA;     results = status.solve(model)&#xA;     assert_optimal_termination(results)&#xA;     model.display()&#xA;&#xA;if __name__ == '__main__':&#xA;    model = create_mymodel()&#xA;    solve_mymodel(model)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Finally, note the use of the &lt;code&gt;if __name__ == '__main__':&lt;/code&gt; guard: this lets you still use &lt;code&gt;cost.py&lt;/code&gt; as a standalone script, but makes testing easier as it will not generate or solve the model when you are importing the &lt;code&gt;cost.py&lt;/code&gt; module in other contexts (e.g., from &lt;code&gt;test.py&lt;/code&gt;).  If you go down this route, your &lt;code&gt;test.py&lt;/code&gt; module might look like:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import cost&#xA;&#xA;model = cost.create_mymodel()&#xA;# test some properties of the model itself &#xA;# (e.g., number of constraints, objectives, evaluations at specific points, etc)&#xA;&#xA;cost.solve_mymodel(model)&#xA;# test the solution&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10026" LastActivityDate="2022-07-25T13:53:02.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8748" PostTypeId="1" CreationDate="2022-07-25T16:08:58.350" Score="1" ViewCount="89" Body="&lt;p&gt;I'm trying to optimize a huge model, but here is a part of it capable of creating an understanding of my question:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = ConcreteModel()&#xA;&#xA;&#xA;model.days = Set(initialize=RangeSet(31))&#xA;&#xA;T = model.days&#xA;&#xA;model.Y = Param(initialize=1) &#xA;&#xA;model.L= Param(initialize=330)  &#xA;&#xA;model.LL= Param(initialize=3300) &#xA;&#xA;model.LU= Param(initialize=3300) &#xA;&#xA;model.U=  Param(initialize=250) &#xA;&#xA;model.X0=  Param(initialize=0) &#xA;&#xA;model.M= Var(T,bounds=(0, None), initialize = 10) &#xA;&#xA;model.X= Var(T,bounds=(0, None), initialize = 10) &#xA;&#xA;def obj_rule(model):&#xA;  return sum( model.X[i] for i in model.days )&#xA;&#xA;&#xA;model.funcobj = Objective( rule =obj_rule , sense=maximize)&#xA;&#xA;def C1A_rule(model,t):&#xA;  return model.Y*model.L&amp;lt;= model.M[t]&#xA;&#xA;def C1B_rule(model,t):&#xA;  return model.M[t] &amp;lt;= model.Y*model.U&#xA;&#xA;model.C1A = Constraint(model.days, rule= C1A_rule)&#xA;model.C1B = Constraint(model.days, rule= C1B_rule)&#xA;&#xA;&#xA;def C14_rule(model,i): # constraints do balanço de massa para o setor b1&#xA;  if i == T[1]:  #Pyomo Sets are 1-indexed&#xA;    return (model.X[i] == model.M[i] + model.X0)&#xA;  if i != T[1]:   &#xA;    return (model.X[i] == model.M[i] + model.X[i-1]  )&#xA;&#xA;model.C14 = Constraint( model.days, rule = C14_rule)&#xA;&#xA;&#xA;def C15A_rule(model,t):&#xA;  return model.LL&amp;lt;=   model.M[t] / 1.15741e-5&#xA;def C15B_rule(model,t):&#xA;  return  model.M[t] / 1.15741e-5   &amp;lt;=  model.LU&#xA;&#xA;&#xA;model.C15A = Constraint( model.days, rule= C15A_rule)&#xA;model.C15B = Constraint( model.days, rule= C15B_rule)&#xA;&#xA;&#xA;&#xA;&#xA;SolverFactory('glpk', executable='/usr/bin/glpsol').solve(model).write()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When the code is executed, the following error appears:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;ValueError: Evaluating the numeric value of parameter 'ScalarParam' before the Param has been constructed (there is currently no value to return).&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this case, what should I do to avoid this error and get a normal completion status?&lt;/p&gt;&#xA;" OwnerUserId="10028" LastEditorUserId="36" LastEditDate="2022-07-25T16:13:18.650" LastActivityDate="2022-07-25T16:13:18.650" Title="Pyomo error about evaluating value of 'ScalarParam' parameter" Tags="|optimization|python|pyomo|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8749" PostTypeId="2" ParentId="8723" CreationDate="2022-07-25T19:27:32.927" Score="2" Body="&lt;p&gt;Generic MILP solvers cannot solve VRPTWs to optimality. You need to use methods specifically designed for VRPTW. Column generation methods (branch-cut-and-price) are the most effective for this class of problems.&lt;/p&gt;&#xA;" OwnerUserId="587" LastActivityDate="2022-07-25T19:27:32.927" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8750" PostTypeId="1" CreationDate="2022-07-25T20:22:10.767" Score="2" ViewCount="54" Body="&lt;p&gt;I do have a MILP problem. The decision variables are Integer ones. Let's call them &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and i &lt;span class=&quot;math-container&quot;&gt;$\in \{0,1,2,3,...,N \}$&lt;/span&gt;&#xA;I do want to find all distinct solutiuons for this problem.&lt;/p&gt;&#xA;&lt;p&gt;The problem is solved and the optimal solution is found as &lt;span class=&quot;math-container&quot;&gt;$x^*_i$&lt;/span&gt;. If the decision variables where binary ones I could add the following cut and resolve to find a distinct new solution&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(1,N+1):&#xA;    if &lt;span class=&quot;math-container&quot;&gt;$x^*_i$&lt;/span&gt;&amp;gt;0:&#xA;       expr+=1-x_i&#xA;    else:&#xA;        expr+=x_i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;add the cut as expr &lt;span class=&quot;math-container&quot;&gt;$\geq 1$&lt;/span&gt; and resolve the problem&lt;/p&gt;&#xA;&lt;p&gt;The Idea can be&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(1,N+1):&#xA;    if &lt;span class=&quot;math-container&quot;&gt;$x^*_i$&lt;/span&gt;&amp;gt;0:&#xA;       expr+=|x^*_i-x_i|&#xA;    else:&#xA;        expr+=x_i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but it is not linear ! Any advice would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2022-07-25T20:22:10.767" Title="How to add a cut to avoid previously found solution?" Tags="|optimization|mixed-integer-programming|constraint|constraint-programming|linear|" AnswerCount="0" CommentCount="0" ClosedDate="2022-07-25T21:00:55.507" ContentLicense="CC BY-SA 4.0" />
  <row Id="8751" PostTypeId="1" CreationDate="2022-07-26T06:40:09.007" Score="2" ViewCount="78" Body="&lt;p&gt;I'm using gurobi in an python enviroment and would like to Model a varying efficiency for a Battery charge/discharge without the Model losing it's MIPL characteristics.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Example Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;eta_Batt = 0.9     # Battery Efficiency&#xA;&#xA;E_Batt_StandBy = 0   # Constant Dischsarge in [W]&#xA;&#xA; &#xA;&#xA;m = Model()&#xA;&#xA;m.setParam(&amp;quot;MIPGap&amp;quot;, 0.1)&#xA;&#xA; &#xA;&#xA;x_E_Batt_discharge  = m.addVars(Horizont, name=&amp;quot;x_E_Batt_discharge&amp;quot; ,vtype=GRB.CONTINUOUS, lb = 0, ub = E_Batt_discharge_max)&#xA;&#xA;x_E_Batt_charge     = m.addVars(Horizont, name=&amp;quot;x_E_Batt_charge&amp;quot;    ,vtype=GRB.CONTINUOUS, lb = 0, ub = E_Batt_charge_max)&#xA;&#xA; &#xA;&#xA;m.addConstrs(x_SoC_Batt[t]   == x_SoC_Batt[t-1] + (x_E_Batt_charge[t] * eta_Batt - x_E_Batt_discharge[t] / eta_Batt - E_Batt_StandBy)  * (100* (delta_t/60) / Cap_Batt)  for t in T1)&#xA;&#xA;m.addConstrs(x_SoC_Batt[t]   == SoC_Batt_start + (x_E_Batt_charge[t] * eta_Batt - x_E_Batt_discharge[t] / eta_Batt - E_Batt_StandBy)  * (100* (delta_t/60) / Cap_Batt)  for t in range(1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'm searching for a way so that eta_Batt is not a constant but decreases with x_E_Batt_charge or x_E_Batt_discharge without having it directly dependent on these variables and therefore making the contrstaints quadratic.&lt;/p&gt;&#xA;&lt;p&gt;Thank you in advance&lt;/p&gt;&#xA;" OwnerUserId="10029" LastEditorUserId="2556" LastEditDate="2022-07-26T07:33:02.470" LastActivityDate="2022-07-26T15:40:29.693" Title="varying efficiency in MILP approach in python" Tags="|mixed-integer-programming|python|gurobi|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8752" PostTypeId="1" CreationDate="2022-07-26T11:33:52.340" Score="2" ViewCount="72" Body="&lt;p&gt;Given two point clouds I want to find for each point from the first point cloud the nearest neighbour from the second point cloud. &lt;strong&gt;Also, each pair of neighbours should be unique.&lt;/strong&gt; The solution was already given &lt;a href=&quot;https://stackoverflow.com/a/67371485/11738400&quot;&gt;here&lt;/a&gt; for Python. However, I was wondering if a similar approach exists for R (I'd like to avoid the suggested &lt;code&gt;cvxpy&lt;/code&gt; library from the Python solution which requires the &lt;code&gt;pyscipopt&lt;/code&gt; library which again requires the installation of the &lt;code&gt;SCIP Optimization Suite&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Some example code with two point clouds:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set.seed(666)&#xA;&#xA;# Example data&#xA;px = runif(210, min = 0, max = 100)&#xA;py = runif(210, min = 0, max = 100)&#xA;&#xA;pc1 = cbind(x = px[1:100], y = py[1:100])&#xA;pc2 = cbind(x = px[101:210], y = py[101:210])&#xA;&#xA;plot(pc1, pch = 16, col = 1)&#xA;points(pc2, pch = 16, col = 2)&#xA;&#xA;# Calculate distance matrix&#xA;# library(pdist)&#xA;# d = pdist(pc1, pc2)&#xA;# d = as.matrix(d)&#xA;&#xA;# Find closest neighbour&#xA;library(FNN)&#xA;nn = get.knnx(pc2, pc1, k = 1)&#xA;&#xA;for(i in 1:nrow(pc1)) lines(x = c(pc1[i,1], pc2[nn&lt;span class=&quot;math-container&quot;&gt;$nn.index[i,1],1]),&#xA;                            y = c(pc1[i,2], pc2[nn$&lt;/span&gt;nn.index[i,1],2]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FTdM7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FTdM7.png&quot; alt=&quot;Nearest neighbours for each point from Point Cloud 1 (black) to Point Cloud 2 (red) connected by a line. In this case, one point from Point Cloud 2 might be nearest to multiple points from Point Cloud 1.&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As shown in the image above, I'm capable of finding the nearest neighbour for each point from Point Cloud 1 (black) to Point Cloud 2 (red). Yet, multiple points from Point Cloud 2 are assigned to the same point from Point Cloud 1. Any idea how to find unique pairs with minimal overall distances instead?&lt;/p&gt;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&lt;p&gt;I tried another approach by finding the closest pair iteratively and removing that pair from the following queries:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Approach 2:&#xA;&#xA;pairs = matrix(NA, ncol = 4, nrow = nrow(pc1)) #storage for pairs&#xA;colnames(pairs) = c(&amp;quot;x(pc1)&amp;quot;, &amp;quot;y(pc1)&amp;quot;, &amp;quot;x(pc2)&amp;quot;, &amp;quot;y(pc2)&amp;quot;)&#xA;&#xA;pc2_copy = pc2 # copy of Point Cloud 2 which will shrink each iteration&#xA;&#xA;for(i in 1:nrow(pc1)){&#xA;  nn = get.knnx(pc2_copy, pc1[i,,drop = FALSE], k = 1)&#xA;  pairs[i,1:2] = pc1[i,1:2,drop = FALSE]&#xA;  pairs[i,3:4] = pc2_copy[nn&lt;span class=&quot;math-container&quot;&gt;$nn.index[1,1],1:2,drop = FALSE]&#xA;  pc2_copy = pc2_copy[-c(nn$&lt;/span&gt;nn.index[1,1]),] #remove the corresponding point from the matrix&#xA;}&#xA;&#xA;plot(pc1, pch = 16, col = 1)&#xA;points(pc2, pch = 16, col = 2)&#xA;&#xA;for(i in 1:nrow(pairs)) lines(x = pairs[i,c(1,3)], y = pairs[i, c(2,4)])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/W0fXC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/W0fXC.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;While this gives me unique pairs, I don't believe this is anywhere near an ideal solution (in my real data example some distances are very little while others are immense with an obviously much better solution by eye).&lt;/p&gt;&#xA;&lt;p&gt;A solution to this question has been provided on &lt;a href=&quot;https://stackoverflow.com/a/73122788/11738400&quot;&gt;Stackoverflow&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10030" LastEditorUserId="500" LastEditDate="2022-07-26T12:48:47.170" LastActivityDate="2022-07-26T12:48:47.170" Title="find unique neighbour pairs between two point clouds in R" Tags="|mixed-integer-programming|assignment-problem|r|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8753" PostTypeId="1" CreationDate="2022-07-26T14:37:21.487" Score="3" ViewCount="173" Body="&lt;p&gt;I have a model run in gurobipy (python api) for Gurobi solver and I want to solve it using NEOS Server. How can I send it to NEOS? What is a good way? I want to add a parameter like timelimit so my model could return the best solution so far.&lt;/p&gt;&#xA;" OwnerUserId="10000" LastEditorUserId="123" LastEditDate="2022-07-27T07:36:39.840" LastActivityDate="2022-07-27T07:36:39.840" Title="Using Gurobipy and solve in Neos Server" Tags="|linear-programming|modeling|gurobi|neos|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8754" PostTypeId="2" ParentId="8751" CreationDate="2022-07-26T15:40:29.693" Score="2" Body="&lt;p&gt;An alternative to quadratic constraints to would be to replace x_E_Batt_charge[t] * eta_Batt with a new variable z[t] and define z[t] as a piecewise linear function of x_E_Batt_charge[t]. Recent versions of Gurobi provide support for piecewise linear constraints.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-26T15:40:29.693" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8755" PostTypeId="1" CreationDate="2022-07-27T03:24:11.153" Score="5" ViewCount="1016" Body="&lt;p&gt;I want to learn about metaheuristics and start building one to solve combinatorial optimization which is pretty hard to solve. I am looking for book recommendation or any learning experience to learn this topic. Python preferred for the programming language but i'm open to anything and not limited to.&lt;/p&gt;&#xA;" OwnerUserId="10000" LastActivityDate="2022-08-12T09:28:08.350" Title="Book to learn metaheuristics" Tags="|combinatorial-optimization|heuristics|metaheuristics|local-search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8756" PostTypeId="2" ParentId="8753" CreationDate="2022-07-27T06:36:20.817" Score="2" Body="&lt;p&gt;There are some possible ways to feed a model into the Neos server:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First, directly by using an LP, MPS, or some others limited format.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Second, through connecting with a 3-th party solver like AMPL, GAMS and Pyomo.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You can already upload either GAMS or AMPL file (and also some optional files) into the Neos server, but in the solvers which are being supported by GAMS or AMPL.&lt;/p&gt;&#xA;&lt;p&gt;Please, be aware that in all of the above the options you can change are limited and it is not possible to access the full specifications.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-07-27T06:36:20.817" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8757" PostTypeId="2" ParentId="8755" CreationDate="2022-07-27T07:00:40.347" Score="10" Body="&lt;p&gt;The most famous book on metaheuristics is probably the &lt;em&gt;Handbook of Metaheuristics&lt;/em&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Michel Gendreau and Jean-Yves Potvin. 2010. Handbook of Metaheuristics (2nd. ed.). Springer Publishing Company, Incorporated.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;which is freely available &lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4419-1665-5&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. It includes a large range of metaheuristics such as &lt;em&gt;Simulated Annealing&lt;/em&gt;, &lt;em&gt;Tabu-Search&lt;/em&gt;, &lt;em&gt;Variable Neighborhood Search&lt;/em&gt; or &lt;em&gt;Genetic Algorithms&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Code wise I would suggest you to start with a problem where you find enough resources such as the TSP and a metaheuristic that you think is easy to implement (personally I started with Simulated Annealing). If you do not have experience with any other programming language, Python is a good choice, because it is fast to learn. However, starting with another language such as C++ might also be a good choice, because it will teach you the basics of programming and is more performant.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2022-07-27T07:00:40.347" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8759" PostTypeId="2" ParentId="8680" CreationDate="2022-07-27T09:40:56.723" Score="1" Body="&lt;p&gt;For small instances, i think the branch and cut will works well. You can try localsolver or concorde to prove optimality for bigger instances in reasonable time.&lt;/p&gt;&#xA;" OwnerUserId="10000" LastActivityDate="2022-07-27T09:40:56.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8760" PostTypeId="2" ParentId="8680" CreationDate="2022-07-27T09:48:56.850" Score="3" Body="&lt;p&gt;I would say &amp;quot;it depends&amp;quot;. If the instances you want to solve are small (up to, say, 10-12 nodes) then dynamic programming works wonders. If the problem is up to 30-40 nodes, you can get by using a general IP solver using a good model formulation. Above that, you need to either design your own branch and cut algorithm using problem specific cuts or figure out how to use Concorde.&lt;/p&gt;&#xA;&lt;p&gt;Concorde is without a doubt the champion when it comes to large scale TSPs.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-07-27T09:48:56.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8761" PostTypeId="1" CreationDate="2022-07-27T09:54:08.243" Score="1" ViewCount="122" Body="&lt;p&gt;I consider an LP (&lt;span class=&quot;math-container&quot;&gt;$LP^*$&lt;/span&gt;) having an objective function defined as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x, y} \sum_{i \in I} p_i(x_i) - \sum_{j \in J} q_j(y_j)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x_i = \sum_{k \in [m]} x_{ik}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_j = \sum_{l \in [n]}y_{jl}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; is a function of &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and is the objective function value of another LP (&lt;span class=&quot;math-container&quot;&gt;$LP^1_i$&lt;/span&gt;):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$p_i(x_i) = \max_{x_{ik}} \sum_{k \in [m]} x_{ik} a_{ik}\\&#xA;s.t. ...$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$q_j$&lt;/span&gt; is a function of &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; and is the objective function value of another LP (&lt;span class=&quot;math-container&quot;&gt;$LP^2_j$&lt;/span&gt;):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$q_j(y_j) = \min_{y_{jl}} \sum_{l\in[n]}y_{jl} b_{jl}\\&#xA;s.t. ...$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I want to bring &lt;span class=&quot;math-container&quot;&gt;$LP^*$&lt;/span&gt; into a form such that I can use standard LP solvers (e.g. Gurobi in Java). What I tried so far is to integrate the constraints of &lt;span class=&quot;math-container&quot;&gt;$LP^1_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$LP^2_j$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt; into &lt;span class=&quot;math-container&quot;&gt;$LP^*$&lt;/span&gt; and replace &lt;span class=&quot;math-container&quot;&gt;$p_i(x_i)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q_j(y_j)$&lt;/span&gt; with their definitions (as in &lt;span class=&quot;math-container&quot;&gt;$LP^1_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$LP^2_j$&lt;/span&gt;) in the objective function. However, this approach seems not to be correct, since I am omitting the &lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\min$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$LP^1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$LP^2$&lt;/span&gt;. That is, the resulting &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$LP^*$&lt;/span&gt; will not be optimal for &lt;span class=&quot;math-container&quot;&gt;$LP^1_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$LP^2_j$&lt;/span&gt;, but only feasible solutions.&lt;/p&gt;&#xA;&lt;p&gt;Could someone help?&lt;/p&gt;&#xA;" OwnerUserId="6063" LastActivityDate="2022-07-27T09:54:08.243" Title="How can I reformulate an LP whose variables are linked to other LPs?" Tags="|linear-programming|constraint|lp|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8762" PostTypeId="1" CreationDate="2022-07-27T14:05:46.733" Score="1" ViewCount="71" Body="&lt;p&gt;I have a multi-stage model with both binary and continuous first-stage investment variables and continuous operational next-stage variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{s} \rho_{s} \left[ x_{s} + y_{s} + \sum_{t}(y^{op}_{s,t})\right]&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With equality and inequality constraints, where a constraint exists that couples the continuous variables indexed t temporally:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_{t,s} - y_{t-1,s} \le A  &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to decompose this model by either or both time and scenario? Is there a way to decompose this model by either or both time and scenario?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt; is the probability constant. &lt;span class=&quot;math-container&quot;&gt;$y_{t,s}$&lt;/span&gt; represents the continuous operational variables. &lt;span class=&quot;math-container&quot;&gt;$x_s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_s$&lt;/span&gt; are the binary and continuous investment variables limited by non-anticipative constraints ensuring they hold a single solution for all scenarios.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_s = x_{\tilde{s}} \ \ \forall s$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ y_s = y_{\tilde{s}} \ \ \forall s$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9695" LastEditorUserId="9695" LastEditDate="2022-07-30T18:06:33.990" LastActivityDate="2022-07-30T18:06:33.990" Title="Multi-Stage Stochastic Decomposition" Tags="|optimization|binary-variable|stochastic-programming|decomposition|multi-stage|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8763" PostTypeId="1" CreationDate="2022-07-27T19:30:56.593" Score="1" ViewCount="38" Body="&lt;p&gt;Consider the following optimization/control problem:&#xA;We aim to maximize the cumulative reward &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; during the horizon &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; by every day allocating a portion of total budget &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; to our two different investment options &lt;span class=&quot;math-container&quot;&gt;$inv1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$inv2$&lt;/span&gt; and the same day seeing the response/reward for that day.&lt;/p&gt;&#xA;&lt;p&gt;Lets say we also have an maximum we can spend everyday.&lt;/p&gt;&#xA;&lt;p&gt;I.e.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\max_{inv1t, inv2t} \sum_{t=t}^{t=t+H} r(inv1t, inv2t, &amp;amp; independent \; variables) \\&#xA;\mbox{s.t.} \sum_{t=t}^{t=t+H} inv1t + inv2t &amp;amp; = B  \\ &#xA;inv1t + inv2t &amp;amp; &amp;lt;= maxdaily \; \forall_t&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that i did not explicitly write down an reward function since this is the key part of the question, we will consider different linear models later on.&lt;/p&gt;&#xA;&lt;p&gt;To our hand we have daily historical data that spans for lets say 3 months back.&lt;/p&gt;&#xA;&lt;p&gt;Algorithm to consider:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Fit our reward function to the historical data by performing bayes rule.&lt;/li&gt;&#xA;&lt;li&gt;Sample a set of parameter values from the posterior.&lt;/li&gt;&#xA;&lt;li&gt;Use this sampled set as ground truth.&lt;/li&gt;&#xA;&lt;li&gt;Maximize the reward function over the whole horizon s.t to the budget constraints.&lt;/li&gt;&#xA;&lt;li&gt;Set the allocation for the current timestep.&lt;/li&gt;&#xA;&lt;li&gt;See the reward for the current timestep.&lt;/li&gt;&#xA;&lt;li&gt;Add the allocation and reward to our dataset.&lt;/li&gt;&#xA;&lt;li&gt;Repeat step 1.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In this case however the signal-to-noise ratio might be really low, so we are really keen to get good reliable estimates of the coefficients of the linear regression model. Since the environment is non-stationary we are also keen to keep exploring even though we are quite sure about our coefficients.&lt;/p&gt;&#xA;&lt;p&gt;Lets consider a reward function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$r(inv1t, inv2t) = c1 * inv1t + c2 * inv2t$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where c1 and c2 follows some distribution.&lt;/p&gt;&#xA;&lt;p&gt;The one will place as much budget as possible to the channel that had the highest coefficient in the sampled set of coefficients, leaving the other one with zero.&lt;/p&gt;&#xA;&lt;p&gt;I assume that this introduces a large amount of multicollinearity.&lt;/p&gt;&#xA;&lt;p&gt;How will the model be able to determine if the potential decrease/increase in reward came from lowering the budget for one of the channels or increase it for the other?&lt;/p&gt;&#xA;&lt;p&gt;Lets say i could include date variables as well such as dateinmonth, day etc in the model could that help fixing this problem?&lt;/p&gt;&#xA;&lt;p&gt;Consider e.g. the reward function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$r(inv1, inv2, dayofmonth) = c1 * inv1t * dayofmonth + c2 * inv2t * dayofmonth$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where c1 and c2 follows some distribution.&lt;/p&gt;&#xA;&lt;p&gt;Now we may not distribute the same amount of budget each day, but we introduce structural multicollinearity since we are including dayofmonth on two parts...&lt;/p&gt;&#xA;&lt;p&gt;How is this problem typically treated, I have not found any literature on this particular subject. Also the method of sampling the coefficients and using it as ground truth seems suboptimal for guiding the exploration. Maybe it would be better to tackle it with a stochastic optimization approach generating scenario trees, but how would that be done when we have a somewhat non-time dependent process(even though including date variables)?&lt;/p&gt;&#xA;" OwnerUserId="10041" LastActivityDate="2022-07-27T19:30:56.593" Title="Multicollinearity w.r.t decisions in optimal control/reinforcement learning learning/resource allocation problem" Tags="|multi-objective-optimization|stochastic-programming|reinforcement-learning|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8764" PostTypeId="1" CreationDate="2022-07-28T01:05:46.527" Score="3" ViewCount="115" Body="&lt;p&gt;I'm from soft-engineering background and really having a hard time when reading and understanding the formulation from a research or published paper. For example, when looking at a container loading problem or vehicle routing problem, what does that weird symbol mean, what does that notation or that positivity, negativity really mean. I know basic calculus, but more like forgot lots of them. What is a good resources or learning material to get more understanding on this issue?&lt;/p&gt;&#xA;" OwnerUserId="10000" LastEditorUserId="123" LastEditDate="2022-07-28T07:22:35.683" LastActivityDate="2022-07-28T15:14:47.750" Title="Hard time in understanding OR Research or Paper" Tags="|optimization|modeling|combinatorial-optimization|literature-research|" AnswerCount="0" CommentCount="3" ClosedDate="2022-08-26T17:35:19.567" ContentLicense="CC BY-SA 4.0" />
  <row Id="8765" PostTypeId="1" AcceptedAnswerId="8909" CreationDate="2022-07-28T01:56:00.630" Score="4" ViewCount="224" Body="&lt;p&gt;I am working on a scheduling problem, where I am solving it through column generation. The pricing problem of this algorithm is an integer programming model as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;  F_1 \Big\{V^0 + \sum_{k \in \mathcal{K}} \sum_{o \in \mathcal{O}} \sum_{i \in \mathcal{I}_k} \mathbb{E}_{\eta} [p^w_{koi}] \times V^w_{koi} + \sum_{k \in \mathcal{K}} \sum_{t \in \mathcal{T}^{'}} \sum_{c \in \mathcal{C}} \mathbb{E}_{\eta} [p^m_{ktc}] \times V^m_{ktc} \Big\}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    F_2 = \sum_{k \in \mathcal{K}} \sum_{o \in \mathcal{O}} \sum_{i \in \mathcal{I}_k} \sum_{t \in \mathcal{T}} \sum_{c \in \mathcal{C}}&#xA;      \Big[z_{koitc} - &#xA;           \sum_{\substack{i^{'} \in \mathcal{I}_k \\ i^{'} = i+1}}&#xA;           \sum_{\substack{t^{'} \in \mathcal{T} \\ t^{'} = t-FR_k; t^{'} \geq 1}}&#xA;           z_{ko{i^{'}}{t^{'}}c} &#xA;      \Big] \times V^1_{kot} + &#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \sum_{k \in \mathcal{K}} \sum_{o \in \mathcal{O}} \sum_{i \in \mathcal{I}_k} &#xA;      \Big(p^{w}_{koi} - &#xA;      \sum_{t \in \mathcal{T}} \sum_{c \in \mathcal{C}} &#xA;      \Big[z_{koitc} - &#xA;           \sum_{\substack{i^{'} \in \mathcal{I}_k \\ i^{'} = i+1}}&#xA;           \sum_{\substack{t^{'} \in \mathcal{T} \\ t^{'} = t-FR_k; t^{'} \geq 1}}&#xA;           z_{ko{i^{'}}{t^{'}}c} &#xA;      \Big]&#xA;      \Big) \times V^2_{ko}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now I formulate the main objective function as follows (to find columns with negative reduced cost):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA; \min \{F_2 - F_1\}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subjected to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;     \sum_{t \in \mathcal{T}} \sum_{c \in \mathcal{C}}&#xA;     \Big[z_{koitc} - &#xA;          \sum_{\substack{i^{'} \in \mathcal{I}_k \\ i^{'} = i+1}} &#xA;          \sum_{\substack{t^{'} \in \mathcal{T} \\ t^{'} = t-FR_k; t^{'} \geq 1}}&#xA;          z_{ko{i^{'}}{t^{'}}c} &#xA;     \Big] \leq p^w_{koi}&#xA;     \hspace{0.5cm} \forall k \in \mathcal{K}; o \in \mathcal{O}; i \in \mathcal{I}_k \label{eqFC1}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;     z_{koitc} \geq z_{ko(i+1)(t-FR_k)c}&#xA;     \hspace{1cm} \forall k \in \mathcal{K}; o \in \mathcal{O}; i \in \mathcal{I}_k/I_k; t \in \mathcal{T}^{'}; t-FR_k \geq 1; c \in \mathcal{C} \label{eqFC2}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;     \sum_{k \in \mathcal{K}} \sum_{o \in \mathcal{O}} \sum_{i \in \mathcal{I}_k} \sum_{t \in \mathcal{T}^{'}} \sum_{\substack{c \in \mathcal{C} \\ \sum_{b \in \mathcal{B}_c} G_{kb} = 0 \: \lor \: (i == I_k \land t &amp;gt; T)}}&#xA;     z_{koitc} = 0&#xA;     \label{eqFC3}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;     \sum_{k \in \mathcal{K}}&#xA;     \sum_{o \in \mathcal{O}}&#xA;     \sum_{i \in \mathcal{I}_k}&#xA;     \sum_{\substack{t \in \mathcal{T} \\ t &amp;lt; AV_{ko} \: \lor \: t &amp;gt; T}} &#xA;     \sum_{c \in \mathcal{C}}&#xA;     \Big[z_{koitc} - &#xA;          \sum_{\substack{i^{'} \in \mathcal{I}_k \\ i^{'} = i+1}} &#xA;          \sum_{\substack{t^{'} \in \mathcal{T} \\ t^{'} = t-FR_k; t^{'} \geq 1}}&#xA;          z_{ko{i^{'}}{t^{'}}c} &#xA;     \Big] = 0 \label{eqFC4}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;     0 \leq pw_{koi} \leq UB^w_{koi} \text{ and integer} &#xA;     \hspace{2cm} \forall k \in \mathcal{K}; o \in \mathcal{O}; i \in \mathcal{I}_k&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;     0 \leq pm_{ktc} \leq UB^m_{ktc} \text{ and integer} &#xA;     \hspace{2cm} \forall k \in \mathcal{K}; t \in \mathcal{T}; c \in \mathcal{C}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;     z_{koitc} \ge 0 \text{ and integer} &#xA;     \hspace{2cm} \forall k \in \mathcal{K}; o \in \mathcal{O}; i \in \mathcal{I}_k; t \in \mathcal{T}; c \in \mathcal{C}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$V_0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$V^w_{koi}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V^m_{ktc}$&lt;/span&gt; are dual prices of constraints of the master problem (in column generation). These parameters are initialized with zero matrices, and as the algorithm moves forward, further entries in these matrices get positive values. Note that the expected values in the objective function are based on some linear computations. Also, I generate the model only once, and do not generate it again.&lt;/p&gt;&#xA;&lt;p&gt;Initially, I expected that solving this model should not be time-consuming. However, as the algorithm moves forward (further entries in the matrices of &lt;span class=&quot;math-container&quot;&gt;$V_0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$V^w_{koi}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V^m_{ktc}$&lt;/span&gt; get positive values), solving the model becomes more time-consuming. For example, the following figure shows how the computational complexity of solving the model increases (and continues to grow...):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NPu3C.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NPu3C.png&quot; alt=&quot;CPU time evolution&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;To deal with this growing complexity, I have adapted the following strategies.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Strategy 1: Set &lt;em&gt;mipgap&lt;/em&gt; to greater than zero (e.g., 5% or 10%)&lt;/li&gt;&#xA;&lt;li&gt;Strategy 2: Removing all useless constraints and variables&lt;/li&gt;&#xA;&lt;li&gt;Strategy 3: Applying a warmstart strategy (giving an initial solution to the solver - based on the solution found in the recent iteration)&lt;/li&gt;&#xA;&lt;li&gt;Strategy 4: Finding a solution with a negative reduced cost might be enough for column generation (not necessarily the most negative one). Therefore, find the first feasible solution with a negative reduced cost (start with &lt;em&gt;mipgap=1&lt;/em&gt; and decrease it until the condition is met).&lt;/li&gt;&#xA;&lt;li&gt;Strategy 5: Find a pool of solutions with negative reduced costs and pass all of them to the master problem (adding multiple columns)&lt;/li&gt;&#xA;&lt;li&gt;Strategy 6: Model the problem in another way (I am not providing the other model here for the sake of brevity. However, let me know if you would like to look at it.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Unfortunately, the above strategies are not helping! What would be your suggestion to increase the speed of this algorithm? Also, I have the following questions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Isn't it strange that the CPU time increases? I am solving the same problem (or instance) and the only input parameters that change are &lt;span class=&quot;math-container&quot;&gt;$V_0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$V^w_{koi}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V^m_{ktc}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note that developing a heuristic algorithm to solve the sub-problem is more difficult than other conventional problems (might be infeasible). This is because the right-hand side values in the first constraint set are variable (&lt;span class=&quot;math-container&quot;&gt;$p^w_{koi}$&lt;/span&gt;). Also, &lt;span class=&quot;math-container&quot;&gt;$p^m_{ktc}$&lt;/span&gt; is a variable and is used in the objective function.&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="5598" LastEditDate="2022-08-17T17:56:01.820" LastActivityDate="2022-08-19T15:07:51.387" Title="Accelerating an integer programming model" Tags="|integer-programming|scheduling|docplex|column-generation|runtime|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8766" PostTypeId="1" AcceptedAnswerId="8767" CreationDate="2022-07-28T02:43:49.307" Score="3" ViewCount="114" Body="&lt;p&gt;So if I have some quantity bounded i.e&#xA;&lt;span class=&quot;math-container&quot;&gt;$ 1-N \leq (p^i-p^{i+1}) \leq N-1,$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$N\ge1 $&lt;/span&gt;. The quantity &lt;span class=&quot;math-container&quot;&gt;$p^i-p^{i+1}$&lt;/span&gt; will be an integer as well.&lt;/p&gt;&#xA;&lt;p&gt;I was trying to figure out how to pose the constraint so that if I have binary variable &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;, then&#xA;&lt;span class=&quot;math-container&quot;&gt;$ b_i=\begin{cases} &#xA;      0 &amp;amp; (p^i-p^{i+1}) =0 \\&#xA;      1 &amp;amp; (p^i-p^{i+1}) &amp;gt;0&#xA;   \end{cases}&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I attempted to pose it as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{align} b_i \geq (p^i-p^{i+1})\\&#xA;M(p^i-p^{i+1}) \geq b_i,&#xA;\end{align}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for a large value of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; but this does not seem to be exactly what I'm looking for since the quantiy &lt;span class=&quot;math-container&quot;&gt;$(p^i-p^{i+1})$&lt;/span&gt; could be negative.&lt;/p&gt;&#xA;&lt;p&gt;Any suggestions would be greatly appreciated how to properly represent this constraint.&lt;/p&gt;&#xA;" OwnerUserId="10043" LastActivityDate="2022-07-28T02:57:13.897" Title="How to pose the constraint for binary variable to indicate if quantity is zero or greater than zero" Tags="|optimization|mixed-integer-programming|integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8767" PostTypeId="2" ParentId="8766" CreationDate="2022-07-28T02:57:13.897" Score="5" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$b_i \le p^i-p^{i+1} \le (N-1)b_i$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-07-28T02:57:13.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8768" PostTypeId="1" CreationDate="2022-07-28T04:02:00.887" Score="5" ViewCount="330" Body="&lt;p&gt;I am trying to minimize a function of the following form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(\vec{x}) = \sum_{i = 1}^n\operatorname{ReLU}(\vec{v}_i \cdot \vec{x} + b_i) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^m$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; around &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$1000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; around &lt;span class=&quot;math-container&quot;&gt;$10^5$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$10^7$&lt;/span&gt;. I wish to get to the global minimum as soon as possible. What are some methods I should try?&lt;/p&gt;&#xA;&lt;p&gt;Things I tried:&lt;/p&gt;&#xA;&lt;p&gt;a) gradient descent with line search, but it seems to get stuck and not progress due to all the discontinuous derivatives.&lt;/p&gt;&#xA;&lt;p&gt;b) When doing line search, optimum occurs at a pivot (where derivative jumps). Thus by sorting the pivots and doing cumsum to get derivatives around the pivots, I can just choose the lowest pivot point. But this has the same issue of derivative being chosen in the direction where I can't make any more progress.&lt;/p&gt;&#xA;" OwnerUserId="10044" LastEditorUserId="123" LastEditDate="2022-07-28T07:20:52.680" LastActivityDate="2022-07-28T07:20:52.680" Title="Minimize sum of ReLU" Tags="|optimization|convex-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8769" PostTypeId="2" ParentId="37" CreationDate="2022-07-28T04:09:05.093" Score="3" Body="&lt;p&gt;As the first answer:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;z &amp;amp;\leq x_i \quad \forall i = 1, \ldots, n.\\&#xA;z &amp;amp;\geq \sum_{i=1}^n x_i - (n-1).&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We should note that, the property holds for an aggregated version of these constraints (obtained from the sum of the &lt;span class=&quot;math-container&quot;&gt;$z \leq x_i \quad \forall i = 1, \ldots, n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ &#xA;\begin{align}&#xA;n.z &amp;amp; \leq \sum_{i=1}^{n} x_i \\&#xA;z &amp;amp; \geq \sum_{i=1}^n x_i -(n-1)&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I prefer to use less constraints.&lt;/p&gt;&#xA;" OwnerUserId="1252" LastActivityDate="2022-07-28T04:09:05.093" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8770" PostTypeId="2" ParentId="8768" CreationDate="2022-07-28T04:46:24.377" Score="6" Body="&lt;p&gt;Introduce nonnegative variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; and minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_i y_i$&lt;/span&gt; subject to linear constraints &lt;span class=&quot;math-container&quot;&gt;$$y_i \ge v_i \cdot x + b_i$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-07-28T04:46:24.377" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8771" PostTypeId="1" AcceptedAnswerId="8772" CreationDate="2022-07-28T04:58:04.587" Score="7" ViewCount="881" Body="&lt;p&gt;So suppose I have integer variables &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2,\dots,x_N$&lt;/span&gt; and  I enforce that the integer variables are bounded i.e &lt;span class=&quot;math-container&quot;&gt;$1 \leq x_i \leq N$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I was interested in posing a constraint so that in the collection &lt;span class=&quot;math-container&quot;&gt;$\{ x_i\}$&lt;/span&gt; I would see all values &lt;span class=&quot;math-container&quot;&gt;$1,\dots,N$&lt;/span&gt;. This is to say that each variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is assigned uniquely a value in the interval &lt;span class=&quot;math-container&quot;&gt;$1,\dots,N$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;One way to do this constraint I thought was to just do:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\prod_{i=1}^{N} x_i = N! = N(N-1)(N-2)\cdots(2)(1)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I believe this fits the bill, but is there a better way of how to pose this constraint? I would suspect integer solvers would have difficulty with this constraint - perhaps there is a better formulation? I could not figure out a straightforward linear representation, and would be interested in seeing if one exists.&#xA;I know from linear programming I could do&#xA;&lt;span class=&quot;math-container&quot;&gt;$|x_i-x_j| =|e_{i,j}|\geq 1, i\neq j$&lt;/span&gt;, but I think this eventually will lead to a similar constraint &lt;span class=&quot;math-container&quot;&gt;$e^+e^-$&lt;/span&gt;=0.&lt;/p&gt;&#xA;" OwnerUserId="10043" LastEditorUserId="500" LastEditDate="2022-07-28T14:23:24.113" LastActivityDate="2022-07-28T14:23:24.113" Title="Is there a better way of defining a constraint on positive integer variables such that no two variables are the same and are uniquely assigned a value" Tags="|mixed-integer-programming|modeling|integer-programming|linearization|constraint-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8772" PostTypeId="2" ParentId="8771" CreationDate="2022-07-28T06:54:19.180" Score="12" Body="&lt;p&gt;Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$y_{ij}\in \{0,1\}$&lt;/span&gt; that take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if  &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is assigned to value &lt;span class=&quot;math-container&quot;&gt;$j\in \{1,...,N\}$&lt;/span&gt;, and use the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_i &amp;amp;= \sum_{j=1}^N j \cdot y_{ij} \quad &amp;amp;\forall i \in \{1,...,N\}\\&#xA;\sum_{j=1}^N y_{ij} &amp;amp;= 1 \quad &amp;amp;\forall i \in \{1,...,N\}\\&#xA;\sum_{i=1}^N y_{ij} &amp;amp;= 1 \quad &amp;amp;\forall j \in \{1,...,N\} \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-07-28T06:54:19.180" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8773" PostTypeId="1" CreationDate="2022-07-28T08:38:31.047" Score="3" ViewCount="478" Body="&lt;p&gt;I am looking to maximize my probability of reaching a given target value, by creating multiple groups of 6 items with different means and variances that stay within a weight limit.&#xA;This is an example of the top of the data frame - the actual data frame is 300+ rows long.&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&quot;text-align: left;&quot;&gt;index&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;mu&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;std&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: right;&quot;&gt;Weight&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;item_a&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;73.450198&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;10.455766&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;111.&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;item_b&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;72.652175&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;9.477475&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;110.&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;item_c&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;73.033862&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;10.293721&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;108.&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;item_d&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;73.886648&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;10.426305&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;105.&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;item_e&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;68.409628&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;10.588617&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;103.&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;I want to maximise the probability that a group of 6 items exceeds a given value, whilst still under the weight limit (500).&lt;/p&gt;&#xA;&lt;p&gt;It was pointed out to me that instead of calculating the exact probability I can minimize the z score for each group using the formula:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;z_score = (target_score-mu_group) / sd_group&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I try to minimize this formula in CPLEX it minimizes the value for the sum of each z score instead of the z score of the group:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;target_score = 600&#xA;weight_limit = 500&#xA;w = df.weight&#xA;v = df.mu&#xA;y = df.std&#xA;N = len(w)&#xA;&#xA;knapsack_model = Model('knapsack')&#xA;&#xA;x = knapsack_model.binary_var_list(N, name= 'x')&#xA;&#xA;knapsack_model.add_constraint(sum(w[i]*x[i] for i in range(N)) &amp;lt;= weight_limit)&#xA;knapsack_model.add_constraint(sum(x[i] for i in range(N)) == 6)&#xA;&#xA;obj_fn = sum(((target_score-v[i])/((y[i]*y[i])) for i in range(N))&#xA;knapsack_model.set_objective('min',obj_fn)&#xA;&#xA;knapsack_model.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am aware that this is because the binary variable used for each team is not within the z score formula, and is therefore only minimizing the sum of all z scores in the group instead of the z score of the group as a whole.&lt;/p&gt;&#xA;&lt;p&gt;I imagine I will need a non-linear solver as the z score calculation is not linear, but I am not sure how to formulate this as I am reaching the edge of my understanding in this area.&lt;/p&gt;&#xA;&lt;p&gt;The other non-trivial part of the problem I would like to solve is to maximize the probability of multiple groups reaching the target score - so create x amount of groups that maximize the probability of one of them reaching the target score.&lt;/p&gt;&#xA;&lt;p&gt;I would also like to have control of the percentages of each item across these groups, for example being able to specify that &lt;code&gt;item_a&lt;/code&gt; is present in no more than 10% of groups.&lt;/p&gt;&#xA;&lt;p&gt;In my initial problem the items will be independent, but in the future I will be looking to incorporate a covariance matrix in to the solution.&lt;/p&gt;&#xA;&lt;p&gt;I have been working primarily in python.&lt;/p&gt;&#xA;&lt;p&gt;Notes: assume this problem is not solve-able using brute force. All items are normally distributed.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{'ID': {0: 23516794, 1: 23516795, 2: 23516796, 3: 23516797, 4: 23516798, 5: 23516799, 6: 23516800, 7: 23516801, 8: 23516802, 9: 23516803, 10: 23516804, 11: 23516805, 12: 23516806, 13: 23516807, 14: 23516808, 15: 23516809, 16: 23516810, 17: 23516811, 18: 23516812, 19: 23516813}, 'mu': {0: 77.22374694548756, 1: 84.05634969802539, 2: 80.96531404866622, 3: 87.57033049910319, 4: 74.78393207733146, 5: 79.82400732228508, 6: 78.16565147466483, 7: 78.14728328442523, 8: 75.98898560579204, 9: 78.8541978528528, 10: 75.07931255975794, 11: 85.11385652194893, 12: 76.72146255952251, 13: 80.29834170101859, 14: 77.86295417762425, 15: 74.70045311388368, 16: 81.24594041364621, 17: 76.21212603618336, 18: 73.42569984426565, 19: 76.1438949931049}, 'std': {0: 11.68598172116063, 1: 13.327661965136674, 2: 14.834799563943232, 3: 9.453573748770634, 4: 12.528214306044084, 5: 13.435066788790433, 6: 11.933781990021213, 7: 12.933356356518166, 8: 12.258175910542153, 9: 15.115553286074276, 10: 13.029399969876495, 11: 15.880786524364469, 12: 13.246754947691105, 13: 12.340407352537394, 14: 13.66745084735041, 15: 12.626895384909284, 16: 14.89605081596392, 17: 13.241317159371539, 18: 12.294456354577791, 19: 12.249112531502997}, 'Weight': {0: 96.0, 1: 109.0, 2: 105.0, 3: 86.0, 4: 87.0, 5: 107.0, 6: 81.0, 7: 82.0, 8: 106.0, 9: 84.0, 10: 83.0, 11: 85.0, 12: 98.0, 13: 94.0, 14: 92.0, 15: 103.0, 16: 80.0, 17: 88.0, 18: 89.0, 19: 90.0}}&#xA;&#xA;{'ID': {0: 23516794, 1: 23516795, 2: 23516796, 3: 23516797, 4: 23516798, 5: 23516799, 6: 23516800, 7: 23516801, 8: 23516802, 9: 23516803, 10: 23516804, 11: 23516805, 12: 23516806, 13: 23516807, 14: 23516808, 15: 23516809, 16: 23516810, 17: 23516811, 18: 23516812, 19: 23516813}, 0: {0: 136.56216878730032, 1: -4.494339538364646, 2: -14.73409159687065, 3: -1.8369732959606888, 4: 1.5974817060365636, 5: -9.60875988350014, 6: -2.183995750123481, 7: 2.514233365391022, 8: -1.916442017276486, 9: -11.679165869066852, 10: -6.306976154792111, 11: -11.332834201301306, 12: -2.3812635674739857, 13: 1.4835959725328676, 14: -5.657222725636583, 15: -9.79722153520659, 16: -12.603609517512604, 17: -2.6398894441141043, 18: -2.291667714493622, 19: -7.3855786001326775}, 1: {0: -4.494339538364646, 1: 177.62657345695047, 2: -12.628111759388075, 3: -4.443689614302776, 4: -10.738219362736135, 5: -2.867861039491733, 6: -8.024258930122437, 7: -5.8343736141719615, 8: -5.0856685690709735, 9: -5.810127855540393, 10: -6.486789218975431, 11: -4.536185413209171, 12: -14.60542313812631, 13: -0.600165154002184, 14: -6.212283004005756, 15: -3.4578205514451863, 16: -6.836266779603481, 17: -9.031669667810993, 18: -9.651812989565943, 19: -0.3322923570894588}, 2: {0: -14.73409159687065, 1: -12.628111759388075, 2: 220.07127810237012, 3: -5.472041080378147, 4: -0.5530251090807978, 5: -4.843046719622863, 6: 2.652486193022895, 7: -5.864881828798867, 8: -13.817643791422551, 9: -10.526409041166408, 10: -19.840091014093485, 11: -10.619099101842991, 12: -7.225864283168083, 13: 0.5735926596177876, 14: 4.0005089456860965, 15: -8.240192896686342, 16: -2.7591820700695866, 17: -8.557254208071246, 18: 0.16726741873534237, 19: -1.0993500347207696}, 3: {0: -1.8369732959606888, 1: -4.443689614302776, 2: -5.472041080378147, 3: 89.3700566234453, 4: -8.848241985121726, 5: -6.625741125767621, 6: -0.21577281576776328, 7: -0.8512025218040024, 8: 0.6751643162844593, 9: 1.0524602516495232, 10: -1.7817610644992792, 11: -5.389103259494309, 12: -3.8824825750140897, 13: -7.0157826193021755, 14: -6.87163496978418, 15: -11.560853860022556, 16: 5.356758878641404, 17: -0.9098172019944819, 18: -1.9189977283684865, 19: -0.9362378417573064}, 4: {0: 1.5974817060365636, 1: -10.738219362736135, 2: -0.5530251090807978, 3: -8.848241985121726, 4: 156.95615369816767, 5: -8.768969357976829, 6: 0.6217679553017051, 7: -0.20504497477901446, 8: -1.0831551767658514, 9: -1.3066968240860621, 10: 5.490867046711869, 11: -2.8210361046394854, 12: 6.475286818155162, 13: -8.802027521591068, 14: -7.569425287856836, 15: -9.454334011368, 16: -9.679516491054699, 17: -9.165398431012328, 18: -4.73040679319504, 19: -7.686554609840943}, 5: {0: -9.60875988350014, 1: -2.867861039491733, 2: -4.843046719622863, 3: -6.625741125767621, 4: -8.768969357976829, 5: 180.50101961925955, 6: -7.054933927313439, 7: -11.358041935082174, 8: -8.629615651443382, 9: -7.1476470240365115, 10: -13.270380194728848, 11: 2.741649714411773, 12: -3.7257538015023197, 13: -4.8121739826093135, 14: 3.894065439133523, 15: 5.628402517781505, 16: -15.985098818113466, 17: -3.0115403619146024, 18: 1.12320328990123, 19: -1.025631802973544}, 6: {0: -2.183995750123481, 1: -8.024258930122437, 2: 2.652486193022895, 3: -0.21577281576776328, 4: 0.6217679553017051, 5: -7.054933927313439, 6: 142.4151525853546, 7: -0.1342070188433831, 8: -7.908278633887033, 9: -5.3017760571802794, 10: 4.9529559923762525, 11: -3.749047764361528, 12: -4.772361787449819, 13: -8.250291267512742, 14: -0.575220665125228, 15: -10.83153808101616, 16: -1.2168714342029199, 17: -3.8947200971928373, 18: -6.738190917666668, 19: -0.9565234278762215}, 7: {0: 2.514233365391022, 1: -5.8343736141719615, 2: -5.864881828798867, 3: -0.8512025218040024, 4: -0.20504497477901446, 5: -11.358041935082174, 6: -0.1342070188433831, 7: 167.27170664468886, 8: -1.7306718846505822, 9: -19.695139284680625, 10: -7.246281550693982, 11: -6.446113218776497, 12: -8.690130833341392, 13: -4.403524906950436, 14: -14.011147795374235, 15: -5.137164556199244, 16: -11.341072122630719, 17: 0.10147369388262845, 18: -1.7697234078007908, 19: 5.975718005677391}, 8: {0: -1.916442017276486, 1: -5.0856685690709735, 2: -13.817643791422551, 3: 0.6751643162844593, 4: -1.0831551767658514, 5: -8.629615651443382, 6: -7.908278633887033, 7: -1.7306718846505822, 8: 150.262876653796, 9: -15.072231128833636, 10: -0.1496075400717749, 11: -15.449852852260035, 12: -1.7637338713840054, 13: -2.0771821311264778, 14: -9.045513112177188, 15: -3.2033101826605255, 16: -7.9132725471029035, 17: -1.5278980319764106, 18: -6.262416358407891, 19: -12.651154101625123}, 9: {0: -11.679165869066852, 1: -5.810127855540393, 2: -10.526409041166408, 3: 1.0524602516495232, 4: -1.3066968240860621, 5: -7.1476470240365115, 6: -5.3017760571802794, 7: -19.695139284680625, 8: -15.072231128833636, 9: 228.47995114415113, 10: 1.5522799948287105, 11: -7.352331898572419, 12: -12.005452429573031, 13: -11.435036416340306, 14: 0.7097071851524513, 15: -6.134332961139446, 16: -14.090526602277816, 17: -2.2206619756610806, 18: -10.242162355051265, 19: -2.6407749930270024}, 10: {0: -6.306976154792111, 1: -6.486789218975431, 2: -19.840091014093485, 3: -1.7817610644992792, 4: 5.490867046711869, 5: -13.270380194728848, 6: 4.9529559923762525, 7: -7.246281550693982, 8: -0.1496075400717749, 9: 1.5522799948287105, 10: 169.76526357501763, 11: -6.376673487808323, 12: -10.590716933267549, 13: -3.4809085348779503, 14: -6.065589307674493, 15: -4.950793172098783, 16: 1.7465983331624262, 17: -12.462347651961771, 18: -6.79247415233182, 19: 6.0659190790992215}, 11: {0: -11.332834201301306, 1: -4.536185413209171, 2: -10.619099101842991, 3: -5.389103259494309, 4: -2.8210361046394854, 5: 2.741649714411773, 6: -3.749047764361528, 7: -6.446113218776497, 8: -15.449852852260035, 9: -7.352331898572419, 10: -6.376673487808323, 11: 252.19938063243615, 12: 5.204041430308693, 13: -23.284827959906316, 14: -6.531768966914284, 15: -3.494555758287847, 16: -14.535184801941293, 17: -4.55733965420517, 18: 4.111678333396179, 19: -2.316270358926943}, 12: {0: -2.3812635674739857, 1: -14.60542313812631, 2: -7.225864283168083, 3: -3.8824825750140897, 4: 6.475286818155162, 5: -3.7257538015023197, 6: -4.772361787449819, 7: -8.690130833341392, 8: -1.7637338713840054, 9: -12.005452429573031, 10: -10.590716933267549, 11: 5.204041430308693, 12: 175.47651664417913, 13: -12.99506383181884, 14: -10.512473183364055, 15: -4.949916172219996, 16: -6.5276526791083676, 17: -7.299556696505636, 18: 3.226564599579514, 19: 2.084662921550234}, 13: {0: 1.4835959725328676, 1: -0.600165154002184, 2: 0.5735926596177876, 3: -7.0157826193021755, 4: -8.802027521591068, 5: -4.8121739826093135, 6: -8.250291267512742, 7: -4.403524906950436, 8: -2.0771821311264778, 9: -11.435036416340306, 10: -3.4809085348779503, 11: -23.284827959906316, 12: -12.99506383181884, 13: 152.2856536265588, 14: -5.372661979592924, 15: -0.8370127370548941, 16: -9.78689911529412, 17: -3.1964142604668715, 18: 8.707018182079095, 19: -8.424931545799005}, 14: {0: -5.657222725636583, 1: -6.212283004005756, 2: 4.0005089456860965, 3: -6.87163496978418, 4: -7.569425287856836, 5: 3.894065439133523, 6: -0.575220665125228, 7: -14.011147795374235, 8: -9.045513112177188, 9: 0.7097071851524513, 10: -6.065589307674493, 11: -6.531768966914284, 12: -10.512473183364055, 13: -5.372661979592924, 14: 186.79921266473949, 15: -1.5788775100724504, 16: -16.952483639367813, 17: -14.518689150558647, 18: -11.119584217756573, 19: -10.17339135612405}, 15: {0: -9.79722153520659, 1: -3.4578205514451863, 2: -8.240192896686342, 3: -11.560853860022556, 4: -9.454334011368, 5: 5.628402517781505, 6: -10.83153808101616, 7: -5.137164556199244, 8: -3.2033101826605255, 9: -6.134332961139446, 10: -4.950793172098783, 11: -3.494555758287847, 12: -4.949916172219996, 13: -0.8370127370548941, 14: -1.5788775100724504, 15: 159.43848706144342, 16: -5.604885004509065, 17: -3.7491992092835695, 18: -2.4676427841801045, 19: -6.103848391110505}, 16: {0: -12.603609517512604, 1: -6.836266779603481, 2: -2.7591820700695866, 3: 5.356758878641404, 4: -9.679516491054699, 5: -15.985098818113466, 6: -1.2168714342029199, 7: -11.341072122630719, 8: -7.9132725471029035, 9: -14.090526602277816, 10: 1.7465983331624262, 11: -14.535184801941293, 12: -6.5276526791083676, 13: -9.78689911529412, 14: -16.952483639367813, 15: -5.604885004509065, 16: 221.89232991177963, 17: -5.850040172649914, 18: -15.64551677338866, 19: -11.237751321651324}, 17: {0: -2.6398894441141043, 1: -9.031669667810993, 2: -8.557254208071246, 3: -0.9098172019944819, 4: -9.165398431012328, 5: -3.0115403619146024, 6: -3.8947200971928373, 7: 0.10147369388262845, 8: -1.5278980319764106, 9: -2.2206619756610806, 10: -12.462347651961771, 11: -4.55733965420517, 12: -7.299556696505636, 13: -3.1964142604668715, 14: -14.518689150558647, 15: -3.7491992092835695, 16: -5.850040172649914, 17: 175.3324801150675, 18: -3.2911916920963638, 19: 1.033994997644956}, 18: {0: -2.291667714493622, 1: -9.651812989565943, 2: 0.16726741873534237, 3: -1.9189977283684865, 4: -4.73040679319504, 5: 1.12320328990123, 6: -6.738190917666668, 7: -1.7697234078007908, 8: -6.262416358407891, 9: -10.242162355051265, 10: -6.79247415233182, 11: 4.111678333396179, 12: 3.226564599579514, 13: 8.707018182079095, 14: -11.119584217756573, 15: -2.4676427841801045, 16: -15.64551677338866, 17: -3.2911916920963638, 18: 151.1536570546182, 19: 0.3524880702152624}, 19: {0: -7.3855786001326775, 1: -0.3322923570894588, 2: -1.0993500347207696, 3: -0.9362378417573064, 4: -7.686554609840943, 5: -1.025631802973544, 6: -0.9565234278762215, 7: 5.975718005677391, 8: -12.651154101625123, 9: -2.6407749930270024, 10: 6.0659190790992215, 11: -2.316270358926943, 12: 2.084662921550234, 13: -8.424931545799005, 14: -10.17339135612405, 15: -6.103848391110505, 16: -11.237751321651324, 17: 1.033994997644956, 18: 0.3524880702152624, 19: 150.04075780942372}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10047" LastEditorUserId="10047" LastEditDate="2022-08-04T22:19:44.297" LastActivityDate="2022-08-04T22:19:44.297" Title="How do I solve a probability based knapsack problem?" Tags="|optimization|python|nonlinear-programming|stochastic-programming|knapsack|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="8775" PostTypeId="1" CreationDate="2022-07-28T12:57:00.480" Score="1" ViewCount="291" Body="&lt;p&gt;I am developing a linear programming model in PULP that sends material from Origin Facilities to Transfer and Final Treatment Facilities. The objective function is based on summing the transport and treatment costs for each of:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Origin to Transfer Facilities&lt;/li&gt;&#xA;&lt;li&gt;Origin to Final Facilities&lt;/li&gt;&#xA;&lt;li&gt;Transfer to Final Facilities&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The constraints are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Origin Facilities demand requirement (must equal)&lt;/li&gt;&#xA;&lt;li&gt;Transfer and Final Facility Capacity (must not exceed)&lt;/li&gt;&#xA;&lt;li&gt;All material that goes to a Transfer must then go to a Final Facility but the Transfer facility reduces the quantity by a given factor&lt;/li&gt;&#xA;&lt;li&gt;Some constraints that certain facilities cannot go to some facilities due to material type (done this for only Facility A to T1 for now)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Model&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objective Function&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_\limits{o=1}^{O}\sum_\limits{T=1}^{T}{}V_{O,T} *C{_T}*T_{O,T}+\sum_\limits{o=1}^{O}\sum_\limits{F=1}^{F}V_{O,F} *C{_F}*T_{O,F}+\sum_\limits{T=1}^{T}\sum_\limits{F=1}^{F}V_{T,F} *C{_F}*T_{T,F}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$O,T $&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$  F$&lt;/span&gt; subscripts correspond to Origin, Transfer and Final respectively and &lt;span class=&quot;math-container&quot;&gt;$V_{i,j}$&lt;/span&gt; is the material exported from facility &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to facility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$C_{i}$&lt;/span&gt; is the Treatment cost at facility type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T_{i,j}$&lt;/span&gt; is the Transport cost from facility &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to facility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. The model is to sum across all decision variables of type &lt;span class=&quot;math-container&quot;&gt;$V_{i,j}$&lt;/span&gt; in each instance - apologies but not sure how best to represent this in mathematical / LaTeX notation.&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_\limits{T=1}^{T}V_{O,T}+\sum_\limits{F=1}^{F}V_{O,F} = D{_O}        $&lt;/span&gt;        for &lt;span class=&quot;math-container&quot;&gt;$  O = 1 .... O$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$D{_O}$&lt;/span&gt; is origin facility demand.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_\limits{o=1}^{O}{}V_{O,T} \le Q{_T}    $&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$T = 1 .... T$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$Q{_T}$&lt;/span&gt; is Transfer facility capacity.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_\limits{o=1}^{O}{}V_{O,F} + \sum_\limits{T=1}^{T}{}V_{T,F} \le Q{_F} $&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$ F = 1 ... F$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$Q{_F}$&lt;/span&gt; is Final facility capacity.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_\limits{o=1}^{O}{}(V_{O,T}*S{{_O}/100}) - \sum_\limits{F=1}^{F}{}(V_{T,F}*S{_T}/100) = 0 $&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$ T = 1... T$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$S{_O}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S{_T}$&lt;/span&gt; is the Origin and Transfer facility material reduction factor respectively.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$V_{A,T1}= 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Issue&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am having issues with the Origin Demand requirement not being met according to the figures given in the OriginReq list. When printing the variable names and values, it seems that the solution only meets 20% of the demand given in the list for each Origin Facility. I'm unsure why this is given the construction of the constraint is to be equal to ORDict which is the dictionary version of the OriginReq list with the Origin Facility names as the keys. See below for the LP File, the issue seems to be in the coefficients of the constraints not being the values that I expect - especially for C1-9 as they shouldn't have a coefficient at all.&lt;/p&gt;&#xA;&lt;p&gt;See code,the value of the variables upon solving and the LP file below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import *&#xA;&#xA;&#xA;def logdictcreation(dictname, dict1, dict2):&#xA;    varlist = []&#xA;    for i in range(0, len(dict1) * len(dict2)):&#xA;        varlist.append(i)&#xA;&#xA;    y = 0&#xA;&#xA;    for i in dict1:&#xA;        dynamiclist = []&#xA;        for x in dict2:&#xA;            dynamiclist.append(varlist[y])&#xA;            y = y + 1&#xA;&#xA;        zipped = zip(dict2, dynamiclist)&#xA;        newdict = dict(zipped)&#xA;        tempdict = {i: newdict}&#xA;        dictname.update(tempdict)&#xA;&#xA;&#xA;# Defining Dictionaries&#xA;&#xA;Origin = [&amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;D&amp;quot;, &amp;quot;E&amp;quot;, &amp;quot;F&amp;quot;, &amp;quot;G&amp;quot;, &amp;quot;H&amp;quot;, &amp;quot;I&amp;quot;, &amp;quot;J&amp;quot;]&#xA;Transfer = [&amp;quot;T1&amp;quot;, &amp;quot;T2&amp;quot;, &amp;quot;T3&amp;quot;]&#xA;Final = [&amp;quot;F1&amp;quot;, &amp;quot;F2&amp;quot;, &amp;quot;F3&amp;quot;, &amp;quot;F4&amp;quot;, &amp;quot;F5&amp;quot;]&#xA;&#xA;&#xA;TransferCapacity = [500, 500, 500]&#xA;OriginReq = [100, 1000, 500, 400, 300, 600, 100, 50, 75, 90]&#xA;FinalCapacity = [2000, 3000, 500, 250, 200]&#xA;&#xA;TCZip = zip(Transfer, TransferCapacity)&#xA;ORZip = zip(Origin, OriginReq)&#xA;FCZip = zip(Final, FinalCapacity)&#xA;&#xA;TransferCost = {&amp;quot;T1&amp;quot;: 40, &amp;quot;T2&amp;quot;: 25, &amp;quot;T3&amp;quot;: 15}&#xA;FinalCost = {&amp;quot;F1&amp;quot;: 90, &amp;quot;F2&amp;quot;: 80, &amp;quot;F3&amp;quot;: 150, &amp;quot;F4&amp;quot;: 80, &amp;quot;F5&amp;quot;: 20}&#xA;&#xA;OtTLogDict = {}&#xA;OtFLogDict = {}&#xA;TtFLogDict = {}&#xA;&#xA;logdictcreation(OtTLogDict,Origin,Transfer)&#xA;logdictcreation(OtFLogDict,Origin,Final)&#xA;logdictcreation(TtFLogDict,Transfer,Final)&#xA;&#xA;TCDict = dict(TCZip)&#xA;ORDict = dict(ORZip)&#xA;FCDict = dict(FCZip)&#xA;&#xA;OriginDS = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]&#xA;TransferDS = [27, 27, 6]&#xA;&#xA;ODSZip = zip(Origin, OriginDS)&#xA;TDSZip = zip(Transfer, TransferDS)&#xA;&#xA;ODSDict = dict(ODSZip)&#xA;TDSDict = dict(TDSZip)&#xA;&#xA;OZip = zip(Origin, OriginTypes)&#xA;TZip = zip(Transfer, TransferTypes)&#xA;FZip = zip(Final, FinalTypes)&#xA;&#xA;ODict = dict(OZip)&#xA;TDict = dict(TZip)&#xA;FDict = dict(FZip)&#xA;&#xA;&#xA;&#xA;OtFroutes = [(i, j) for i in Origin for j in Final]&#xA;TtFroutes = [(i, j) for i in Transfer for j in Final]&#xA;OtTroutes = [(i, j) for i in Origin for j in Transfer]&#xA;&#xA;&#xA;&#xA;# Problem Definition&#xA;&#xA;model = LpProblem(&amp;quot;Cost Optimiser&amp;quot;, LpMinimize)&#xA;&#xA;&#xA;#Decision Variables&#xA;OtT_Vars = LpVariable.dicts(&amp;quot;Origin_to_Transfer_Volume_Exported&amp;quot;, (Origin, Transfer), lowBound=0, cat=LpContinuous)&#xA;&#xA;OtF_Vars = LpVariable.dicts(&amp;quot;Origin_to_Final_Volume_Exported&amp;quot;, (Origin, Final), lowBound=0, cat=LpContinuous)&#xA;&#xA;TtF_Vars = LpVariable.dicts(&amp;quot;Transfer_to_Final_Volume_Exported&amp;quot;, (Transfer, Final), lowBound=0, cat=LpContinuous)&#xA;&#xA;#Objective Function&#xA;&#xA;model += lpSum(OtT_Vars[i][j]*(OtTLogDict[i][j]+TransferCost[j])+(OtF_Vars[a][b]*(OtFLogDict[a][b]+FinalCost[b])) +&#xA;               (TtF_Vars[c][d]*(TtFLogDict[c][d]+FinalCost[d]))&#xA;               for (i, j) in OtTroutes for (a, b) in OtFroutes for (c, d) in TtFroutes)&#xA;&#xA;#Constraints&#xA;&#xA;for i in Origin:&#xA;   model += lpSum(OtT_Vars[i][j] + OtF_Vars[i][z] for j in Transfer for z in Final) == ORDict[i]&#xA;&#xA;for j in Transfer:&#xA;   model += lpSum(OtT_Vars[i][j] for i in Origin) &amp;lt;= TCDict[j]&#xA;&#xA;for j in Final:&#xA;    model += lpSum(OtF_Vars[i][j]+TtF_Vars[z][j] for i in Origin for z in Transfer) &amp;lt;= FCDict[j]&#xA;&#xA;for j in Transfer:&#xA;    model += lpSum((OtT_Vars[i][j]*(ODSDict[i]/100))-(TtF_Vars[j][z]*(TDSDict[j]/100))&#xA;                   for i in Origin for z in Final) == 0&#xA;&#xA;model += lpSum(OtT_Vars[&amp;quot;A&amp;quot;][&amp;quot;T1&amp;quot;]) == 0&#xA;&#xA;model.solve()&#xA;&#xA;print(&amp;quot;Status:&amp;quot;, LpStatus[model.status])&#xA;&#xA;print(&amp;quot;All Variables&amp;quot;)&#xA;for v in model.variables():&#xA;    print(v.name, &amp;quot;=&amp;quot;, v.varValue)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Variable Values&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Origin_to_Final_Volume_Exported_A_F1 = 0.0&#xA;Origin_to_Final_Volume_Exported_A_F2 = 0.0&#xA;Origin_to_Final_Volume_Exported_A_F3 = 0.0&#xA;Origin_to_Final_Volume_Exported_A_F4 = 0.0&#xA;Origin_to_Final_Volume_Exported_A_F5 = 0.0&#xA;Origin_to_Final_Volume_Exported_B_F1 = 0.0&#xA;Origin_to_Final_Volume_Exported_B_F2 = 0.0&#xA;Origin_to_Final_Volume_Exported_B_F3 = 0.0&#xA;Origin_to_Final_Volume_Exported_B_F4 = 0.0&#xA;Origin_to_Final_Volume_Exported_B_F5 = 0.0&#xA;Origin_to_Final_Volume_Exported_C_F1 = 0.0&#xA;Origin_to_Final_Volume_Exported_C_F2 = 0.0&#xA;Origin_to_Final_Volume_Exported_C_F3 = 0.0&#xA;Origin_to_Final_Volume_Exported_C_F4 = 0.0&#xA;Origin_to_Final_Volume_Exported_C_F5 = 0.0&#xA;Origin_to_Final_Volume_Exported_D_F1 = 0.0&#xA;Origin_to_Final_Volume_Exported_D_F2 = 0.0&#xA;Origin_to_Final_Volume_Exported_D_F3 = 0.0&#xA;Origin_to_Final_Volume_Exported_D_F4 = 0.0&#xA;Origin_to_Final_Volume_Exported_D_F5 = 0.0&#xA;Origin_to_Final_Volume_Exported_E_F1 = 0.0&#xA;Origin_to_Final_Volume_Exported_E_F2 = 0.0&#xA;Origin_to_Final_Volume_Exported_E_F3 = 0.0&#xA;Origin_to_Final_Volume_Exported_E_F4 = 0.0&#xA;Origin_to_Final_Volume_Exported_E_F5 = 0.0&#xA;Origin_to_Final_Volume_Exported_F_F1 = 0.0&#xA;Origin_to_Final_Volume_Exported_F_F2 = 0.0&#xA;Origin_to_Final_Volume_Exported_F_F3 = 0.0&#xA;Origin_to_Final_Volume_Exported_F_F4 = 0.0&#xA;Origin_to_Final_Volume_Exported_F_F5 = 0.0&#xA;Origin_to_Final_Volume_Exported_G_F1 = 0.0&#xA;Origin_to_Final_Volume_Exported_G_F2 = 0.0&#xA;Origin_to_Final_Volume_Exported_G_F3 = 0.0&#xA;Origin_to_Final_Volume_Exported_G_F4 = 0.0&#xA;Origin_to_Final_Volume_Exported_G_F5 = 0.0&#xA;Origin_to_Final_Volume_Exported_H_F1 = 0.0&#xA;Origin_to_Final_Volume_Exported_H_F2 = 0.0&#xA;Origin_to_Final_Volume_Exported_H_F3 = 0.0&#xA;Origin_to_Final_Volume_Exported_H_F4 = 0.0&#xA;Origin_to_Final_Volume_Exported_H_F5 = 0.0&#xA;Origin_to_Final_Volume_Exported_I_F1 = 0.0&#xA;Origin_to_Final_Volume_Exported_I_F2 = 0.0&#xA;Origin_to_Final_Volume_Exported_I_F3 = 0.0&#xA;Origin_to_Final_Volume_Exported_I_F4 = 0.0&#xA;Origin_to_Final_Volume_Exported_I_F5 = 0.0&#xA;Origin_to_Final_Volume_Exported_J_F1 = 0.0&#xA;Origin_to_Final_Volume_Exported_J_F2 = 0.0&#xA;Origin_to_Final_Volume_Exported_J_F3 = 0.0&#xA;Origin_to_Final_Volume_Exported_J_F4 = 0.0&#xA;Origin_to_Final_Volume_Exported_J_F5 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_A_T1 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_A_T2 = 20.0&#xA;Origin_to_Transfer_Volume_Exported_A_T3 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_B_T1 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_B_T2 = 200.0&#xA;Origin_to_Transfer_Volume_Exported_B_T3 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_C_T1 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_C_T2 = 100.0&#xA;Origin_to_Transfer_Volume_Exported_C_T3 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_D_T1 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_D_T2 = 80.0&#xA;Origin_to_Transfer_Volume_Exported_D_T3 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_E_T1 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_E_T2 = 60.0&#xA;Origin_to_Transfer_Volume_Exported_E_T3 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_F_T1 = 80.0&#xA;Origin_to_Transfer_Volume_Exported_F_T2 = 40.0&#xA;Origin_to_Transfer_Volume_Exported_F_T3 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_G_T1 = 20.0&#xA;Origin_to_Transfer_Volume_Exported_G_T2 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_G_T3 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_H_T1 = 10.0&#xA;Origin_to_Transfer_Volume_Exported_H_T2 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_H_T3 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_I_T1 = 15.0&#xA;Origin_to_Transfer_Volume_Exported_I_T2 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_I_T3 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_J_T1 = 18.0&#xA;Origin_to_Transfer_Volume_Exported_J_T2 = 0.0&#xA;Origin_to_Transfer_Volume_Exported_J_T3 = 0.0&#xA;Transfer_to_Final_Volume_Exported_T1_F1 = 0.0&#xA;Transfer_to_Final_Volume_Exported_T1_F2 = 0.0&#xA;Transfer_to_Final_Volume_Exported_T1_F3 = 0.0&#xA;Transfer_to_Final_Volume_Exported_T1_F4 = 0.0&#xA;Transfer_to_Final_Volume_Exported_T1_F5 = 7.9444444&#xA;Transfer_to_Final_Volume_Exported_T2_F1 = 0.0&#xA;Transfer_to_Final_Volume_Exported_T2_F2 = 15.722222&#xA;Transfer_to_Final_Volume_Exported_T2_F3 = 0.0&#xA;Transfer_to_Final_Volume_Exported_T2_F4 = 0.0&#xA;Transfer_to_Final_Volume_Exported_T2_F5 = 12.055556&#xA;Transfer_to_Final_Volume_Exported_T3_F1 = 0.0&#xA;Transfer_to_Final_Volume_Exported_T3_F2 = 0.0&#xA;Transfer_to_Final_Volume_Exported_T3_F3 = 0.0&#xA;Transfer_to_Final_Volume_Exported_T3_F4 = 0.0&#xA;Transfer_to_Final_Volume_Exported_T3_F5 = 0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;LP File&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Minimize&#xA;OBJ: 40500 Origin_to_Final_Volume_Exported_A_F1&#xA; + 36450 Origin_to_Final_Volume_Exported_A_F2&#xA; + 68400 Origin_to_Final_Volume_Exported_A_F3&#xA; + 37350 Origin_to_Final_Volume_Exported_A_F4&#xA; + 10800 Origin_to_Final_Volume_Exported_A_F5&#xA; + 42750 Origin_to_Final_Volume_Exported_B_F1&#xA; + 38700 Origin_to_Final_Volume_Exported_B_F2&#xA; + 70650 Origin_to_Final_Volume_Exported_B_F3&#xA; + 39600 Origin_to_Final_Volume_Exported_B_F4&#xA; + 13050 Origin_to_Final_Volume_Exported_B_F5&#xA; + 45000 Origin_to_Final_Volume_Exported_C_F1&#xA; + 40950 Origin_to_Final_Volume_Exported_C_F2&#xA; + 72900 Origin_to_Final_Volume_Exported_C_F3&#xA; + 41850 Origin_to_Final_Volume_Exported_C_F4&#xA; + 15300 Origin_to_Final_Volume_Exported_C_F5&#xA; + 47250 Origin_to_Final_Volume_Exported_D_F1&#xA; + 43200 Origin_to_Final_Volume_Exported_D_F2&#xA; + 75150 Origin_to_Final_Volume_Exported_D_F3&#xA; + 44100 Origin_to_Final_Volume_Exported_D_F4&#xA; + 17550 Origin_to_Final_Volume_Exported_D_F5&#xA; + 49500 Origin_to_Final_Volume_Exported_E_F1&#xA; + 45450 Origin_to_Final_Volume_Exported_E_F2&#xA; + 77400 Origin_to_Final_Volume_Exported_E_F3&#xA; + 46350 Origin_to_Final_Volume_Exported_E_F4&#xA; + 19800 Origin_to_Final_Volume_Exported_E_F5&#xA; + 51750 Origin_to_Final_Volume_Exported_F_F1&#xA; + 47700 Origin_to_Final_Volume_Exported_F_F2&#xA; + 79650 Origin_to_Final_Volume_Exported_F_F3&#xA; + 48600 Origin_to_Final_Volume_Exported_F_F4&#xA; + 22050 Origin_to_Final_Volume_Exported_F_F5&#xA; + 54000 Origin_to_Final_Volume_Exported_G_F1&#xA; + 49950 Origin_to_Final_Volume_Exported_G_F2&#xA; + 81900 Origin_to_Final_Volume_Exported_G_F3&#xA; + 50850 Origin_to_Final_Volume_Exported_G_F4&#xA; + 24300 Origin_to_Final_Volume_Exported_G_F5&#xA; + 56250 Origin_to_Final_Volume_Exported_H_F1&#xA; + 52200 Origin_to_Final_Volume_Exported_H_F2&#xA; + 84150 Origin_to_Final_Volume_Exported_H_F3&#xA; + 53100 Origin_to_Final_Volume_Exported_H_F4&#xA; + 26550 Origin_to_Final_Volume_Exported_H_F5&#xA; + 58500 Origin_to_Final_Volume_Exported_I_F1&#xA; + 54450 Origin_to_Final_Volume_Exported_I_F2&#xA; + 86400 Origin_to_Final_Volume_Exported_I_F3&#xA; + 55350 Origin_to_Final_Volume_Exported_I_F4&#xA; + 28800 Origin_to_Final_Volume_Exported_I_F5&#xA; + 60750 Origin_to_Final_Volume_Exported_J_F1&#xA; + 56700 Origin_to_Final_Volume_Exported_J_F2&#xA; + 88650 Origin_to_Final_Volume_Exported_J_F3&#xA; + 57600 Origin_to_Final_Volume_Exported_J_F4&#xA; + 31050 Origin_to_Final_Volume_Exported_J_F5&#xA; + 30000 Origin_to_Transfer_Volume_Exported_A_T1&#xA; + 19500 Origin_to_Transfer_Volume_Exported_A_T2&#xA; + 12750 Origin_to_Transfer_Volume_Exported_A_T3&#xA; + 32250 Origin_to_Transfer_Volume_Exported_B_T1&#xA; + 21750 Origin_to_Transfer_Volume_Exported_B_T2&#xA; + 15000 Origin_to_Transfer_Volume_Exported_B_T3&#xA; + 34500 Origin_to_Transfer_Volume_Exported_C_T1&#xA; + 24000 Origin_to_Transfer_Volume_Exported_C_T2&#xA; + 17250 Origin_to_Transfer_Volume_Exported_C_T3&#xA; + 36750 Origin_to_Transfer_Volume_Exported_D_T1&#xA; + 26250 Origin_to_Transfer_Volume_Exported_D_T2&#xA; + 19500 Origin_to_Transfer_Volume_Exported_D_T3&#xA; + 39000 Origin_to_Transfer_Volume_Exported_E_T1&#xA; + 28500 Origin_to_Transfer_Volume_Exported_E_T2&#xA; + 21750 Origin_to_Transfer_Volume_Exported_E_T3&#xA; + 41250 Origin_to_Transfer_Volume_Exported_F_T1&#xA; + 30750 Origin_to_Transfer_Volume_Exported_F_T2&#xA; + 24000 Origin_to_Transfer_Volume_Exported_F_T3&#xA; + 43500 Origin_to_Transfer_Volume_Exported_G_T1&#xA; + 33000 Origin_to_Transfer_Volume_Exported_G_T2&#xA; + 26250 Origin_to_Transfer_Volume_Exported_G_T3&#xA; + 45750 Origin_to_Transfer_Volume_Exported_H_T1&#xA; + 35250 Origin_to_Transfer_Volume_Exported_H_T2&#xA; + 28500 Origin_to_Transfer_Volume_Exported_H_T3&#xA; + 48000 Origin_to_Transfer_Volume_Exported_I_T1&#xA; + 37500 Origin_to_Transfer_Volume_Exported_I_T2&#xA; + 30750 Origin_to_Transfer_Volume_Exported_I_T3&#xA; + 50250 Origin_to_Transfer_Volume_Exported_J_T1&#xA; + 39750 Origin_to_Transfer_Volume_Exported_J_T2&#xA; + 33000 Origin_to_Transfer_Volume_Exported_J_T3&#xA; + 135000 Transfer_to_Final_Volume_Exported_T1_F1&#xA; + 121500 Transfer_to_Final_Volume_Exported_T1_F2&#xA; + 228000 Transfer_to_Final_Volume_Exported_T1_F3&#xA; + 124500 Transfer_to_Final_Volume_Exported_T1_F4&#xA; + 36000 Transfer_to_Final_Volume_Exported_T1_F5&#xA; + 142500 Transfer_to_Final_Volume_Exported_T2_F1&#xA; + 129000 Transfer_to_Final_Volume_Exported_T2_F2&#xA; + 235500 Transfer_to_Final_Volume_Exported_T2_F3&#xA; + 132000 Transfer_to_Final_Volume_Exported_T2_F4&#xA; + 43500 Transfer_to_Final_Volume_Exported_T2_F5&#xA; + 150000 Transfer_to_Final_Volume_Exported_T3_F1&#xA; + 136500 Transfer_to_Final_Volume_Exported_T3_F2&#xA; + 243000 Transfer_to_Final_Volume_Exported_T3_F3&#xA; + 139500 Transfer_to_Final_Volume_Exported_T3_F4&#xA; + 51000 Transfer_to_Final_Volume_Exported_T3_F5&#xA;Subject To&#xA;_C1: 3 Origin_to_Final_Volume_Exported_A_F1&#xA; + 3 Origin_to_Final_Volume_Exported_A_F2&#xA; + 3 Origin_to_Final_Volume_Exported_A_F3&#xA; + 3 Origin_to_Final_Volume_Exported_A_F4&#xA; + 3 Origin_to_Final_Volume_Exported_A_F5&#xA; + 5 Origin_to_Transfer_Volume_Exported_A_T1&#xA; + 5 Origin_to_Transfer_Volume_Exported_A_T2&#xA; + 5 Origin_to_Transfer_Volume_Exported_A_T3 = 100&#xA;_C10: 3 Origin_to_Final_Volume_Exported_J_F1&#xA; + 3 Origin_to_Final_Volume_Exported_J_F2&#xA; + 3 Origin_to_Final_Volume_Exported_J_F3&#xA; + 3 Origin_to_Final_Volume_Exported_J_F4&#xA; + 3 Origin_to_Final_Volume_Exported_J_F5&#xA; + 5 Origin_to_Transfer_Volume_Exported_J_T1&#xA; + 5 Origin_to_Transfer_Volume_Exported_J_T2&#xA; + 5 Origin_to_Transfer_Volume_Exported_J_T3 = 90&#xA;_C11: Origin_to_Transfer_Volume_Exported_A_T1&#xA; + Origin_to_Transfer_Volume_Exported_B_T1&#xA; + Origin_to_Transfer_Volume_Exported_C_T1&#xA; + Origin_to_Transfer_Volume_Exported_D_T1&#xA; + Origin_to_Transfer_Volume_Exported_E_T1&#xA; + Origin_to_Transfer_Volume_Exported_F_T1&#xA; + Origin_to_Transfer_Volume_Exported_G_T1&#xA; + Origin_to_Transfer_Volume_Exported_H_T1&#xA; + Origin_to_Transfer_Volume_Exported_I_T1&#xA; + Origin_to_Transfer_Volume_Exported_J_T1 &amp;lt;= 500&#xA;_C12: Origin_to_Transfer_Volume_Exported_A_T2&#xA; + Origin_to_Transfer_Volume_Exported_B_T2&#xA; + Origin_to_Transfer_Volume_Exported_C_T2&#xA; + Origin_to_Transfer_Volume_Exported_D_T2&#xA; + Origin_to_Transfer_Volume_Exported_E_T2&#xA; + Origin_to_Transfer_Volume_Exported_F_T2&#xA; + Origin_to_Transfer_Volume_Exported_G_T2&#xA; + Origin_to_Transfer_Volume_Exported_H_T2&#xA; + Origin_to_Transfer_Volume_Exported_I_T2&#xA; + Origin_to_Transfer_Volume_Exported_J_T2 &amp;lt;= 500&#xA;_C13: Origin_to_Transfer_Volume_Exported_A_T3&#xA; + Origin_to_Transfer_Volume_Exported_B_T3&#xA; + Origin_to_Transfer_Volume_Exported_C_T3&#xA; + Origin_to_Transfer_Volume_Exported_D_T3&#xA; + Origin_to_Transfer_Volume_Exported_E_T3&#xA; + Origin_to_Transfer_Volume_Exported_F_T3&#xA; + Origin_to_Transfer_Volume_Exported_G_T3&#xA; + Origin_to_Transfer_Volume_Exported_H_T3&#xA; + Origin_to_Transfer_Volume_Exported_I_T3&#xA; + Origin_to_Transfer_Volume_Exported_J_T3 &amp;lt;= 500&#xA;_C14: 3 Origin_to_Final_Volume_Exported_A_F1&#xA; + 3 Origin_to_Final_Volume_Exported_B_F1&#xA; + 3 Origin_to_Final_Volume_Exported_C_F1&#xA; + 3 Origin_to_Final_Volume_Exported_D_F1&#xA; + 3 Origin_to_Final_Volume_Exported_E_F1&#xA; + 3 Origin_to_Final_Volume_Exported_F_F1&#xA; + 3 Origin_to_Final_Volume_Exported_G_F1&#xA; + 3 Origin_to_Final_Volume_Exported_H_F1&#xA; + 3 Origin_to_Final_Volume_Exported_I_F1&#xA; + 3 Origin_to_Final_Volume_Exported_J_F1&#xA; + 10 Transfer_to_Final_Volume_Exported_T1_F1&#xA; + 10 Transfer_to_Final_Volume_Exported_T2_F1&#xA; + 10 Transfer_to_Final_Volume_Exported_T3_F1 &amp;lt;= 2000&#xA;_C15: 3 Origin_to_Final_Volume_Exported_A_F2&#xA; + 3 Origin_to_Final_Volume_Exported_B_F2&#xA; + 3 Origin_to_Final_Volume_Exported_C_F2&#xA; + 3 Origin_to_Final_Volume_Exported_D_F2&#xA; + 3 Origin_to_Final_Volume_Exported_E_F2&#xA; + 3 Origin_to_Final_Volume_Exported_F_F2&#xA; + 3 Origin_to_Final_Volume_Exported_G_F2&#xA; + 3 Origin_to_Final_Volume_Exported_H_F2&#xA; + 3 Origin_to_Final_Volume_Exported_I_F2&#xA; + 3 Origin_to_Final_Volume_Exported_J_F2&#xA; + 10 Transfer_to_Final_Volume_Exported_T1_F2&#xA; + 10 Transfer_to_Final_Volume_Exported_T2_F2&#xA; + 10 Transfer_to_Final_Volume_Exported_T3_F2 &amp;lt;= 3000&#xA;_C16: 3 Origin_to_Final_Volume_Exported_A_F3&#xA; + 3 Origin_to_Final_Volume_Exported_B_F3&#xA; + 3 Origin_to_Final_Volume_Exported_C_F3&#xA; + 3 Origin_to_Final_Volume_Exported_D_F3&#xA; + 3 Origin_to_Final_Volume_Exported_E_F3&#xA; + 3 Origin_to_Final_Volume_Exported_F_F3&#xA; + 3 Origin_to_Final_Volume_Exported_G_F3&#xA; + 3 Origin_to_Final_Volume_Exported_H_F3&#xA; + 3 Origin_to_Final_Volume_Exported_I_F3&#xA; + 3 Origin_to_Final_Volume_Exported_J_F3&#xA; + 10 Transfer_to_Final_Volume_Exported_T1_F3&#xA; + 10 Transfer_to_Final_Volume_Exported_T2_F3&#xA; + 10 Transfer_to_Final_Volume_Exported_T3_F3 &amp;lt;= 500&#xA;_C17: 3 Origin_to_Final_Volume_Exported_A_F4&#xA; + 3 Origin_to_Final_Volume_Exported_B_F4&#xA; + 3 Origin_to_Final_Volume_Exported_C_F4&#xA; + 3 Origin_to_Final_Volume_Exported_D_F4&#xA; + 3 Origin_to_Final_Volume_Exported_E_F4&#xA; + 3 Origin_to_Final_Volume_Exported_F_F4&#xA; + 3 Origin_to_Final_Volume_Exported_G_F4&#xA; + 3 Origin_to_Final_Volume_Exported_H_F4&#xA; + 3 Origin_to_Final_Volume_Exported_I_F4&#xA; + 3 Origin_to_Final_Volume_Exported_J_F4&#xA; + 10 Transfer_to_Final_Volume_Exported_T1_F4&#xA; + 10 Transfer_to_Final_Volume_Exported_T2_F4&#xA; + 10 Transfer_to_Final_Volume_Exported_T3_F4 &amp;lt;= 250&#xA;_C18: 3 Origin_to_Final_Volume_Exported_A_F5&#xA; + 3 Origin_to_Final_Volume_Exported_B_F5&#xA; + 3 Origin_to_Final_Volume_Exported_C_F5&#xA; + 3 Origin_to_Final_Volume_Exported_D_F5&#xA; + 3 Origin_to_Final_Volume_Exported_E_F5&#xA; + 3 Origin_to_Final_Volume_Exported_F_F5&#xA; + 3 Origin_to_Final_Volume_Exported_G_F5&#xA; + 3 Origin_to_Final_Volume_Exported_H_F5&#xA; + 3 Origin_to_Final_Volume_Exported_I_F5&#xA; + 3 Origin_to_Final_Volume_Exported_J_F5&#xA; + 10 Transfer_to_Final_Volume_Exported_T1_F5&#xA; + 10 Transfer_to_Final_Volume_Exported_T2_F5&#xA; + 10 Transfer_to_Final_Volume_Exported_T3_F5 &amp;lt;= 200&#xA;_C19: 0.15 Origin_to_Transfer_Volume_Exported_A_T1&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_B_T1&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_C_T1&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_D_T1&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_E_T1&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_F_T1&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_G_T1&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_H_T1&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_I_T1&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_J_T1&#xA; - 2.7 Transfer_to_Final_Volume_Exported_T1_F1&#xA; - 2.7 Transfer_to_Final_Volume_Exported_T1_F2&#xA; - 2.7 Transfer_to_Final_Volume_Exported_T1_F3&#xA; - 2.7 Transfer_to_Final_Volume_Exported_T1_F4&#xA; - 2.7 Transfer_to_Final_Volume_Exported_T1_F5 = 0&#xA;_C2: 3 Origin_to_Final_Volume_Exported_B_F1&#xA; + 3 Origin_to_Final_Volume_Exported_B_F2&#xA; + 3 Origin_to_Final_Volume_Exported_B_F3&#xA; + 3 Origin_to_Final_Volume_Exported_B_F4&#xA; + 3 Origin_to_Final_Volume_Exported_B_F5&#xA; + 5 Origin_to_Transfer_Volume_Exported_B_T1&#xA; + 5 Origin_to_Transfer_Volume_Exported_B_T2&#xA; + 5 Origin_to_Transfer_Volume_Exported_B_T3 = 1000&#xA;_C20: 0.15 Origin_to_Transfer_Volume_Exported_A_T2&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_B_T2&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_C_T2&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_D_T2&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_E_T2&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_F_T2&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_G_T2&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_H_T2&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_I_T2&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_J_T2&#xA; - 2.7 Transfer_to_Final_Volume_Exported_T2_F1&#xA; - 2.7 Transfer_to_Final_Volume_Exported_T2_F2&#xA; - 2.7 Transfer_to_Final_Volume_Exported_T2_F3&#xA; - 2.7 Transfer_to_Final_Volume_Exported_T2_F4&#xA; - 2.7 Transfer_to_Final_Volume_Exported_T2_F5 = 0&#xA;_C21: 0.15 Origin_to_Transfer_Volume_Exported_A_T3&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_B_T3&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_C_T3&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_D_T3&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_E_T3&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_F_T3&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_G_T3&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_H_T3&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_I_T3&#xA; + 0.15 Origin_to_Transfer_Volume_Exported_J_T3&#xA; - 0.6 Transfer_to_Final_Volume_Exported_T3_F1&#xA; - 0.6 Transfer_to_Final_Volume_Exported_T3_F2&#xA; - 0.6 Transfer_to_Final_Volume_Exported_T3_F3&#xA; - 0.6 Transfer_to_Final_Volume_Exported_T3_F4&#xA; - 0.6 Transfer_to_Final_Volume_Exported_T3_F5 = 0&#xA;_C22: Origin_to_Transfer_Volume_Exported_A_T1 = 0&#xA;_C3: 3 Origin_to_Final_Volume_Exported_C_F1&#xA; + 3 Origin_to_Final_Volume_Exported_C_F2&#xA; + 3 Origin_to_Final_Volume_Exported_C_F3&#xA; + 3 Origin_to_Final_Volume_Exported_C_F4&#xA; + 3 Origin_to_Final_Volume_Exported_C_F5&#xA; + 5 Origin_to_Transfer_Volume_Exported_C_T1&#xA; + 5 Origin_to_Transfer_Volume_Exported_C_T2&#xA; + 5 Origin_to_Transfer_Volume_Exported_C_T3 = 500&#xA;_C4: 3 Origin_to_Final_Volume_Exported_D_F1&#xA; + 3 Origin_to_Final_Volume_Exported_D_F2&#xA; + 3 Origin_to_Final_Volume_Exported_D_F3&#xA; + 3 Origin_to_Final_Volume_Exported_D_F4&#xA; + 3 Origin_to_Final_Volume_Exported_D_F5&#xA; + 5 Origin_to_Transfer_Volume_Exported_D_T1&#xA; + 5 Origin_to_Transfer_Volume_Exported_D_T2&#xA; + 5 Origin_to_Transfer_Volume_Exported_D_T3 = 400&#xA;_C5: 3 Origin_to_Final_Volume_Exported_E_F1&#xA; + 3 Origin_to_Final_Volume_Exported_E_F2&#xA; + 3 Origin_to_Final_Volume_Exported_E_F3&#xA; + 3 Origin_to_Final_Volume_Exported_E_F4&#xA; + 3 Origin_to_Final_Volume_Exported_E_F5&#xA; + 5 Origin_to_Transfer_Volume_Exported_E_T1&#xA; + 5 Origin_to_Transfer_Volume_Exported_E_T2&#xA; + 5 Origin_to_Transfer_Volume_Exported_E_T3 = 300&#xA;_C6: 3 Origin_to_Final_Volume_Exported_F_F1&#xA; + 3 Origin_to_Final_Volume_Exported_F_F2&#xA; + 3 Origin_to_Final_Volume_Exported_F_F3&#xA; + 3 Origin_to_Final_Volume_Exported_F_F4&#xA; + 3 Origin_to_Final_Volume_Exported_F_F5&#xA; + 5 Origin_to_Transfer_Volume_Exported_F_T1&#xA; + 5 Origin_to_Transfer_Volume_Exported_F_T2&#xA; + 5 Origin_to_Transfer_Volume_Exported_F_T3 = 600&#xA;_C7: 3 Origin_to_Final_Volume_Exported_G_F1&#xA; + 3 Origin_to_Final_Volume_Exported_G_F2&#xA; + 3 Origin_to_Final_Volume_Exported_G_F3&#xA; + 3 Origin_to_Final_Volume_Exported_G_F4&#xA; + 3 Origin_to_Final_Volume_Exported_G_F5&#xA; + 5 Origin_to_Transfer_Volume_Exported_G_T1&#xA; + 5 Origin_to_Transfer_Volume_Exported_G_T2&#xA; + 5 Origin_to_Transfer_Volume_Exported_G_T3 = 100&#xA;_C8: 3 Origin_to_Final_Volume_Exported_H_F1&#xA; + 3 Origin_to_Final_Volume_Exported_H_F2&#xA; + 3 Origin_to_Final_Volume_Exported_H_F3&#xA; + 3 Origin_to_Final_Volume_Exported_H_F4&#xA; + 3 Origin_to_Final_Volume_Exported_H_F5&#xA; + 5 Origin_to_Transfer_Volume_Exported_H_T1&#xA; + 5 Origin_to_Transfer_Volume_Exported_H_T2&#xA; + 5 Origin_to_Transfer_Volume_Exported_H_T3 = 50&#xA;_C9: 3 Origin_to_Final_Volume_Exported_I_F1&#xA; + 3 Origin_to_Final_Volume_Exported_I_F2&#xA; + 3 Origin_to_Final_Volume_Exported_I_F3&#xA; + 3 Origin_to_Final_Volume_Exported_I_F4&#xA; + 3 Origin_to_Final_Volume_Exported_I_F5&#xA; + 5 Origin_to_Transfer_Volume_Exported_I_T1&#xA; + 5 Origin_to_Transfer_Volume_Exported_I_T2&#xA; + 5 Origin_to_Transfer_Volume_Exported_I_T3 = 75&#xA;End&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10040" LastEditorUserId="10040" LastEditDate="2022-08-03T13:55:12.150" LastActivityDate="2022-08-03T13:55:12.150" Title="PULP : Constraint violation - multiple of expected value" Tags="|python|constraint|logical-constraints|pulp|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8776" PostTypeId="2" ParentId="8771" CreationDate="2022-07-28T14:09:16.727" Score="5" Body="&lt;p&gt;This is called an &lt;em&gt;alldifferent&lt;/em&gt; constraint and is supported directly by constraint programming solvers.  @Kuifje gave a traditional linear formulation (+1) that uses binary variables, but it is worth pointing out that there is another linear formulation that uses only the original variables.  See Theorem 19 here: &lt;a href=&quot;https://www.andrew.cmu.edu/user/vanhoeve/papers/alldiff.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://www.andrew.cmu.edu/user/vanhoeve/papers/alldiff.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-07-28T14:09:16.727" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8779" PostTypeId="1" CreationDate="2022-07-28T21:31:52.390" Score="4" ViewCount="154" Body="&lt;p&gt;In MIP, what's the difference of solving time between the following two formulations?&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i = 0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt;, and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in I} x_i = 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Suppose that &lt;span class=&quot;math-container&quot;&gt;$x_i, \forall i\in I$&lt;/span&gt; are all binary variables.&lt;/p&gt;&#xA;" OwnerUserId="10058" LastEditorUserId="491" LastEditDate="2022-07-29T22:42:53.730" LastActivityDate="2022-07-29T22:42:53.730" Title="Solution time of different formulation" Tags="|mixed-integer-programming|cplex|gurobi|solver|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8780" PostTypeId="2" ParentId="8779" CreationDate="2022-07-28T21:37:20.033" Score="6" Body="&lt;p&gt;A basic presolver will immediately remove such fixed variables and the corresponding constraints in either case, so the presolved model that the actual solver sees will be identical.  But there is some overhead in both presolving and postsolving, so either option is a bit wasteful in terms of time and memory.  An even better third option is to omit these variables from your formulation altogether (omit these indices from the index set for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-07-29T16:00:37.873" LastActivityDate="2022-07-29T16:00:37.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8781" PostTypeId="1" CreationDate="2022-07-28T23:20:17.787" Score="1" ViewCount="155" Body="&lt;p&gt;I am currently trying to work on this problem that determines the best constraints on how to place these 'bids'- please see the second column in the screenshot:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QmZN1.jpg&quot; alt=&quot;here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;The ask at hand is to uncover a model or set of rules on how to place these 'bids' to maximize the amount of net revenue. The way that generating profits is that a bid is placed at a FIXED price- which is either &lt;span class=&quot;math-container&quot;&gt;$\\\$3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\\\$35$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\\\$50$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;$\\\$75$&lt;/span&gt;. Revenue is generated when the bid is accepted (when the value in the accepted column is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;). Once the bid is accepted, the revenue is a product of the expected revenue and the expected conversion for each line.&lt;/p&gt;&#xA;&lt;p&gt;Simply put, here is an example, if we place a bid of &lt;span class=&quot;math-container&quot;&gt;$\\\$35$&lt;/span&gt; and it is accepted the profit would be the &lt;span class=&quot;math-container&quot;&gt;$(expected\_revenue \cdot expected\_conversion) - \\\$35$&lt;/span&gt;. Those entries where the bids are not excepted (value of &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;) have no revenue nor costs, so here's how the profit would be calculated per bid...&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(accepted\_bid \cdot expected\_revenue \cdot expected\_conversion) - bid\_price$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My problem with figuring out how to tackle these lies in the below constraints/context:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The likelihood of a bid being 'accepted' (equal to 1) increases as the bid price increases, and the value of the accepted_bid field can be EITHER &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;This set of data has both leads where bids were placed as well as those that weren't- I'm not exactly sure how to work with these as if no bid is place it automatically isn't accepted (0)&lt;/li&gt;&#xA;&lt;li&gt;The quantity of bids purchased must be within &lt;span class=&quot;math-container&quot;&gt;$\pm 2\%$&lt;/span&gt; of the quantity of bids in this data set&lt;/li&gt;&#xA;&lt;li&gt;The number of leads we expect to see over time are the same amount in the data set&#xA;e. The bid NEEDS to be either &lt;span class=&quot;math-container&quot;&gt;$\\\$3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\\\$35$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\\\$50$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\\\$75$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I was thinking about building a model with PuLP, but it doesn't look like it is possible with these given constraints (unless it is).&lt;/p&gt;&#xA;&lt;p&gt;Can PuLP be used to define rules? What model should I employ?&lt;/p&gt;&#xA;" OwnerUserId="10059" LastEditorUserId="491" LastEditDate="2022-08-02T19:12:53.820" LastActivityDate="2022-08-02T19:12:53.820" Title="Profit Optimization in Python with Difficult Constraints to Maximize Net Revenue" Tags="|optimization|python|pulp|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8785" PostTypeId="2" ParentId="8775" CreationDate="2022-07-29T16:30:47.703" Score="1" Body="&lt;p&gt;I think there might be an error in the following constraint: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{}(V_{O,T}*S{{_O}/100}) - \sum_{}(V_{T,F}*S{_T}/100) = 0.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You did not indicate what you are summing over, but for the sake of argument assume there is a single facility of each type (origin, transfer, final). Also assume that &lt;span class=&quot;math-container&quot;&gt;$S_O=75$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S_T=50,$&lt;/span&gt; so that the constraint becomes &lt;span class=&quot;math-container&quot;&gt;$$0.75 V_{O,T} = 0.5 V_{T,F},$$&lt;/span&gt; or equivalently &lt;span class=&quot;math-container&quot;&gt;$$V_{T,F} = 1.5V_{O,T}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So whatever amount the origin tries to move to the transfer facility, the facility somehow moves 150% of that to the final facility.&lt;/p&gt;&#xA;&lt;p&gt;I suspect what you want is two constraints, the first saying that what a transfer facility tries to transfer to a final facility (&lt;span class=&quot;math-container&quot;&gt;$V_{T,F}$&lt;/span&gt;) is a fraction of what comes in from origins, and the second saying that what a final facility actually gets is a fraction of what the transfer facilities send it.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-29T16:30:47.703" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8786" PostTypeId="1" CreationDate="2022-07-29T16:43:02.387" Score="2" ViewCount="284" Body="&lt;p&gt;Here's an applicative problem I'm trying to solve. Imagine there is a road that can be classified in 5 states. Can be something from good to bad etc. There are 4 maintenance actions possible. And the idea is to find a minimum cost policy for steady state. Which means if the road was 60% in state B and 40% in state C, and I were to apply action 1 on B and action 2 on C, they could swap but next year again, the distribution will be 60% and 40%.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s = 5 #states&#xA;a = 4 #actions&#xA;costs = [0, 25, 50, 100] #cost of actions&#xA;&#xA;tpm_1 = np.array([&#xA;[0.9, 0.1, 0, 0, 0],&#xA;[0, 0.8, 0.2, 0, 0],&#xA;[0, 0, 0.6, 0.4, 0],&#xA;[0, 0, 0, 0.7, 0.3],&#xA;[0, 0, 0, 0, 1]&#xA;])  #transition probabilities for action 1: do nothing, meaning if nothing is done and the asset is in state 1, there's 90% chance that it stays there and 10% chance it goes to state B. &#xA;&#xA;w = steady.continuous_var_matrix(s, a, lb=0, ub=1, name='a') &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I next created these action variables, representing probabilities or fractions of roads in different categories on which different actions are to be taken.&#xA;To apply steady state condition, I need to apply the constraint,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Current state*transition probabilities = current state.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, the &lt;code&gt;continuous_var_matrix()&lt;/code&gt; function creates a dictionary and not a matrix of variables. How do I go about then applying matrix multiplication on this?&#xA;Why would you name something matrix, make a dict and not give it any functions of matrix?&lt;/p&gt;&#xA;" OwnerUserId="10062" LastEditorUserId="491" LastEditDate="2023-03-29T02:41:33.390" LastActivityDate="2023-03-29T02:41:33.390" Title="How to do matrix multiplication in docplex in python?" Tags="|python|docplex|assignment-problem|cplex-python-api|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8787" PostTypeId="1" CreationDate="2022-07-29T16:50:04.730" Score="0" ViewCount="53" Body="&lt;p&gt;So, based on the &lt;a href=&quot;https://or.stackexchange.com/questions/8764/hard-time-in-understanding-or-research-or-paper&quot;&gt;last question&lt;/a&gt; about having hard time in understanding paper. I want to use this formulation in &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-005-0652-x&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; but I don't quite understand about it. I want to use the VRPTW formulation from chapter 5. Can someone help me read maybe one or two so I can get a little bit of understanding about hows it going.&lt;/p&gt;&#xA;" OwnerUserId="10000" LastActivityDate="2022-07-29T17:06:12.497" Title="Interpret the formulation from paper" Tags="|mixed-integer-programming|linear-programming|gurobi|literature-research|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8788" PostTypeId="2" ParentId="8787" CreationDate="2022-07-29T17:06:12.497" Score="1" Body="&lt;p&gt;The paper you have found is a rather technical one. The focus is on the relation between different formulations, and consequently not much space is dedicated to explaining the elements of the formulations.&lt;/p&gt;&#xA;&lt;p&gt;As I remember the paper (it's behind pay wall, and I am on my phone, so no access for me) the authors do not provide &lt;em&gt;new&lt;/em&gt; formulations. So maybe you can find papers among the references in Section 5 that go more into detail regarding the modeling. That is usually how it's done: if someone uses something in their paper without explaining much detail, you go one level up in the reference hierarchy to find the details.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-07-29T17:06:12.497" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8789" PostTypeId="2" ParentId="8773" CreationDate="2022-07-29T20:41:45.620" Score="2" Body="&lt;p&gt;I coded the initial version of the problem (finding one group of six items) in R using a permutation-based genetic algorithm. Since this is a metaheuristic, (a) you are not guaranteed an optimal solution and (b) you can futz with all sorts of parameters (including but not limited to run length/time limits), as well as trying different random number seeds (or just rerunning), and get different results. As to how good the solution is, that is an open question until you come up with a benchmark.&lt;/p&gt;&#xA;&lt;p&gt;As a caveat, I had to reduce your target score. As best I can tell, no combination of six items has even a remote chance of producing a score of 600 or more (meaning the highest probability the GA could get was around &lt;span class=&quot;math-container&quot;&gt;$10^{-12}$&lt;/span&gt;). The problem with that is that improvements are so tiny the GA code thinks it has stalled and quits early. With a target score of 450, the GA was able to find a combination with better than 15% chance of success.&lt;/p&gt;&#xA;&lt;p&gt;The general idea is that the GA plays with candidate solutions that are permutations of the indices of your items (1 to 108 for your sample data). Given a permutation of items, a somewhat cumbersome function goes down the list and selects the six items with highest rank (earliest in the list) that collectively stay within the budget, and then calculates the likelihood of meeting or exceed the target assuming their payoffs are i.i.d. normal. There is a bunch of sorting involved in the move from permutation to item list, but the GA ran in seconds nonetheless.&lt;/p&gt;&#xA;&lt;p&gt;Accommodating a covariance matrix should not be too hard. All it changes is the probability calculation given a choice of items. Accommodating &lt;em&gt;disjoint&lt;/em&gt; sets of items (e.g., select four groups of 10 with no overlap) would be a somewhat straightforward extension. Selecting multiple groups with overlap might be trickier. Calculating the probability of a win would be fairly straightforward for disjoint groups, but with overlapping groups I think it would get a bit convoluted.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-07-29T20:41:45.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8791" PostTypeId="2" ParentId="7844" CreationDate="2022-07-29T22:28:36.743" Score="1" Body="&lt;p&gt;as you mention the documentation is not very insightful when comes to comparing and choosing different algorithms, I think in &lt;a href=&quot;https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html#:%7E:text=and%20lower%20bounds.-,Constrained%20Minimization,-Method%20COBYLA%20uses&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paragraph&lt;/a&gt; I found the major takeaways, not very deep as you might want, but was helpful for me at least&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Method COBYLA uses the Constrained Optimization BY Linear Approximation (COBYLA) method [9], [10], [11]. The algorithm is based on linear approximations to the objective function and each constraint. The method wraps a FORTRAN implementation of the algorithm. The constraints functions ‘fun’ may return either a single number or an array or list of numbers.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Method SLSQP uses Sequential Least SQuares Programming to minimize a function of several variables with any combination of bounds, equality and inequality constraints. The method wraps the SLSQP Optimization subroutine originally implemented by Dieter Kraft [12]. Note that the wrapper handles infinite values in bounds by converting them into large floating values.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Method trust-constr is a trust-region algorithm for constrained optimization. It swiches between two implementations depending on the problem definition. It is the most versatile constrained minimization algorithm implemented in SciPy and the most appropriate for large-scale problems. For equality constrained problems it is an implementation of Byrd-Omojokun Trust-Region SQP method described in [17] and in [5], p. 549. When inequality constraints are imposed as well, it swiches to the trust-region interior point method described in [16]. This interior point algorithm, in turn, solves inequality constraints by introducing slack variables and solving a sequence of equality-constrained barrier problems for progressively smaller values of the barrier parameter. The previously described equality constrained SQP method is used to solve the subproblems with increasing levels of accuracy as the iterate gets closer to a solution.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10064" LastActivityDate="2022-07-29T22:28:36.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8792" PostTypeId="2" ParentId="8773" CreationDate="2022-07-30T03:23:57.970" Score="4" Body="&lt;p&gt;I'll tackle here the question of selecting a single team (of specified size with some upper limit on the weight) with maximum probability of success (which I'll operationalize by maximizing z-score &lt;code&gt;(mu_team-target_score)/sd_team&lt;/code&gt;). Though at first blush this sounds like a very difficult optimization problem (a non-linear integer optimization problem), it turns out it can be effectively handled with branch and bound. I'll first explain the high-level idea and then share some working code.&lt;/p&gt;&#xA;&lt;p&gt;Imagine you're targeting a score of 550 (subject to some team size and weight requirements, which I'll assume are added as constraints in all optimization problems). Now imagine you solved two initial optimization problems:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You optimize to maximize the mean of your team (ignoring its variance), and you get a team with a mean of 597.4 and a variance of 490.5.&lt;/li&gt;&#xA;&lt;li&gt;You optimize to minimize the variance of your team among any team whose mean is at least the target score of 550, and you learn that the minimum variance that can be achieved for an above-target team is 397.7.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;At this point, we know two things:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You have already found a team with z-score (597.4-550)/sqrt(490.5) = 2.14, so the optimal solution must have a z-score at least that good.&lt;/li&gt;&#xA;&lt;li&gt;Since every team with an above-target score has a variance of at least 397.7, no optimal solution can have a z-score of better than (597.4-550)/sqrt(397.7) = 2.38.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Now we have an upper and a lower bound -- the optimal solution's z-score falls between 2.14 and 2.38. The key question is how to proceed toward the optimal solution. The idea is an interesting one -- we pick a variance threshold of 444.1 (halfway between 397.7 and 490.5) and we optimize the team with the best mean subject to having a variance below 444.1. The optimization problem returns a team with mean 595.1 and a variance of 440.4. Now we can partition the space of solutions into two ranges:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Region 1:&lt;/strong&gt; For the set of teams with variance between 444.1 and 490.5, the best achievable mean is 597.4; the z-score of the best solution in the region must be at least (597.4-550)/sqrt(490.5) = 2.14 but can be no more than (597.4-550)/sqrt(444.1) = 2.25.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Region 2:&lt;/strong&gt; For the set of teams with variance between 397.7 and 444.1, the best achievable mean is 595.1; the z-score of the best solution in the region must be at least (595.1-550)/sqrt(440.4) = 2.15 but can be no more than (595.1-550)/sqrt(397.7) = 2.26.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Great news -- after this second round we now know that the overall optimal solution must have a z-score of at least max(2.14, 2.15) = 2.15, but can't have a z-score any bigger than max(2.25, 2.26) = 2.26. Both our upper and lower bounds have improved!&lt;/p&gt;&#xA;&lt;p&gt;Branch and bound now proceeds by iteratively identifying the region with the largest upper bound (region 2 at the moment) and splits it as we did above, always improving the upper bound at least a little bit and sometimes improving the lower bound as well. You keep the process going until the upper and lower bounds are sufficiently close.&lt;/p&gt;&#xA;&lt;p&gt;This is quite straightforward to do with any optimization solver. I'll use the python pulp package here:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import math&#xA;import pulp&#xA;&#xA;# Optimize a model&#xA;def opt(optVar, numSelect, weight_limit, varMin=None, varMax=None, muMin=None):&#xA;    allId = [x for x in df[&amp;quot;ID&amp;quot;]]&#xA;    x = pulp.LpVariable.dicts(&amp;quot;x&amp;quot;, allId, 0, 1, pulp.LpBinary)&#xA;&#xA;    # Set objective to either maximize the mean or minimize the variance&#xA;    if optVar == &amp;quot;mean&amp;quot;:&#xA;        prob = pulp.LpProblem(optVar, pulp.LpMaximize)&#xA;        prob += pulp.lpSum([df[&amp;quot;mu&amp;quot;][idx] * x[idx] for idx in allId])&#xA;    else:&#xA;        if optVar == &amp;quot;minVar&amp;quot;:&#xA;            prob = pulp.LpProblem(optVar, pulp.LpMinimize)&#xA;        else:&#xA;            prob = pulp.LpProblem(optVar, pulp.LpMaximize)&#xA;        prob += pulp.lpSum([df[&amp;quot;std&amp;quot;][idx]*df[&amp;quot;std&amp;quot;][idx]*x[idx] for idx in allId])&#xA;&#xA;    # Weight, variance, and mean limits as well as cardinality:&#xA;    prob += pulp.lpSum([df[&amp;quot;Weight&amp;quot;][idx]*x[idx] for idx in allId]) &amp;lt;= weight_limit&#xA;    prob += pulp.lpSum(x) == numSelect&#xA;    if varMin is not None:&#xA;        prob += pulp.lpSum([df[&amp;quot;std&amp;quot;][idx]*df[&amp;quot;std&amp;quot;][idx]*x[idx] for idx in allId]) &amp;gt;= varMin&#xA;    if varMax is not None:&#xA;        prob += pulp.lpSum([df[&amp;quot;std&amp;quot;][idx]*df[&amp;quot;std&amp;quot;][idx]*x[idx] for idx in allId]) &amp;lt;= varMax&#xA;    if muMin is not None:&#xA;        prob += pulp.lpSum([df[&amp;quot;mu&amp;quot;][idx]*x[idx] for idx in allId]) &amp;gt;= muMin&#xA;&#xA;    # Solve and return solution&#xA;    prob.solve(pulp.PULP_CBC_CMD(msg=0))&#xA;    selected = [idx for idx in allId if x[idx].value() &amp;gt; 0.999]&#xA;    mu = sum([df[&amp;quot;mu&amp;quot;][idx]*x[idx].value() for idx in allId])&#xA;    var = sum([df[&amp;quot;std&amp;quot;][idx]*df[&amp;quot;std&amp;quot;][idx]*x[idx].value() for idx in allId])&#xA;    return mu, var, selected&#xA;&#xA;# Optimize a team with the specified parameters&#xA;def optTeam(numSelect, target_score, weight_limit, tolerance, verbose=False):&#xA;    M, Mvar, best = opt(&amp;quot;mean&amp;quot;, numSelect, weight_limit, None, None, None)&#xA;    if M == target_score:&#xA;        return 0, 0, best&#xA;    elif M &amp;gt; target_score:&#xA;        positiveZ = True&#xA;        _, Vbest, _ = opt(&amp;quot;minVar&amp;quot;, numSelect, weight_limit, None, None, target_score)&#xA;    else:&#xA;        positiveZ = False&#xA;        _, Vbest, _ = opt(&amp;quot;maxVar&amp;quot;, numSelect, weight_limit, None, None, None)&#xA;&#xA;    nodes = [[Vbest, Mvar, M, best]]&#xA;&#xA;    while True:&#xA;        allLB = [(x[2]-target_score)/math.sqrt(x[1]) for x in nodes]&#xA;        currLB, currLBPos = max([(val, idx) for idx, val in enumerate(allLB)])&#xA;        allUB = [(x[2]-target_score)/math.sqrt(x[0]) for x in nodes]&#xA;        currUB, currUBPos = max([(val, idx) for idx, val in enumerate(allUB)])&#xA;        if verbose:&#xA;            print(len(nodes), currLB, currUB)&#xA;    &#xA;        if (positiveZ and currUB / currLB &amp;lt; tolerance) or (not positiveZ and currLB / currUB &amp;lt; tolerance):&#xA;            break&#xA;&#xA;        # Split the node with the largest upper bound&#xA;        mid = (nodes[currUBPos][0] + nodes[currUBPos][1]) / 2.0&#xA;        if positiveZ:&#xA;            newMu, newVar, newBest = opt(&amp;quot;mean&amp;quot;, numSelect, weight_limit, None, mid, None)&#xA;        else:&#xA;            newMu, newVar, newBest = opt(&amp;quot;mean&amp;quot;, numSelect, weight_limit, mid, None, None)&#xA;        nodes.append([nodes[currUBPos][0], newVar, newMu, newBest])&#xA;        nodes[currUBPos][0] = mid&#xA;&#xA;    return currLB, currUB, nodes[currLBPos][3]&#xA;&#xA;LB, UB, sol = optTeam(6, 600, 500, 1.0001, True)&#xA;print(sol)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The approach outputs the lower and upper bound from each step of the branch and bound procedure. Here I optimize with target score 600 and weight limit 500, which is done in under a second of computation time with the default CBC solver:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1 -7.1048510789624855 -6.060011148175446&#xA;2 -6.611541985047641 -6.172741906265993&#xA;3 -6.355377019877131 -6.250015803032588&#xA;4 -6.355377019877131 -6.3020359480846775&#xA;5 -6.355377019877131 -6.328537892630254&#xA;6 -6.355377019877131 -6.341914862728255&#xA;7 -6.355377019877131 -6.3486352364871745&#xA;8 -6.355377019877131 -6.352003444878156&#xA;9 -6.355377019877131 -6.353689560661244&#xA;10 -6.355377019877131 -6.354533122228607&#xA;11 -6.355377019877131 -6.354955029028778&#xA;[10, 12, 15, 23, 38, 55]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Clearly the optimal team will rarely break score 600, with probability of just 1.04e-10. Lower target scores are much more achievable -- the optimal team with target score 500 has probability 0.55%, the optimal team with target score 450 has probability 30.4%, and the optimal team with target score 400 has probability 95.7%.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2022-07-30T03:23:57.970" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8794" PostTypeId="2" ParentId="6318" CreationDate="2022-08-01T08:25:06.377" Score="3" Body="&lt;p&gt;Perhaps, you will find some software we built &lt;a href=&quot;https://fuinn.github.io/mos-docs/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://fuinn.github.io/mos-docs/&lt;/a&gt; useful. Provides a REST API for interacting with optimization models.&lt;/p&gt;&#xA;" OwnerUserId="10091" LastActivityDate="2022-08-01T08:25:06.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8795" PostTypeId="1" AcceptedAnswerId="8797" CreationDate="2022-08-01T15:46:43.487" Score="2" ViewCount="567" Body="&lt;p&gt;Say I have some products and their unit price:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Product Name&lt;/th&gt;&#xA;&lt;th&gt;Product Amount&lt;/th&gt;&#xA;&lt;th&gt;Price per unit&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A&lt;/td&gt;&#xA;&lt;td&gt;10&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;B&lt;/td&gt;&#xA;&lt;td&gt;20&lt;/td&gt;&#xA;&lt;td&gt;6&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Z&lt;/td&gt;&#xA;&lt;td&gt;30&lt;/td&gt;&#xA;&lt;td&gt;7&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;The products are financial instruments so they need not be sold in discrete amounts (i.e i can sell 50% of product A for a total price of 0.5&lt;em&gt;10&lt;/em&gt;2).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I am given a target total demand and a target average price. Say the total demand is 25 and the target price is 5.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are several product combination that can satisfy the product demand. E.g, choosing all of Product_A and 75% of Product_B:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$10 + 0.75*20 = 25.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This results in an average price of &lt;span class=&quot;math-container&quot;&gt;$(10*2+15*6)/25 = 4.4$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or I could use &lt;span class=&quot;math-container&quot;&gt;$(5/6)$&lt;/span&gt; of product Z:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(5/6)*30 = 25$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And this gives me an average price of:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(25*7)/25 = 7$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since I can choose any positive amount of each product, I am having a hard time thinking of a way of solving this in python. If I had to use whole amounts of the products I could simply check if the weighted sum adds up to my target value. But with continuous amounts I am not sure how or even if this is possible.&lt;/p&gt;&#xA;&lt;p&gt;Since I only have two constraints: that the sum of products must equal the demand and the average price must equal the target, I have too many variables for the number of unknowns. So my gut feeling is that this cannot be solved.&lt;/p&gt;&#xA;&lt;p&gt;I thought that instead of checking for an exact match with the target, I could choose product amounts such that I get as close as possible to my target, but again, I feel like this won't be possible because of the number of unknowns.&lt;/p&gt;&#xA;&lt;p&gt;Has anyone here worked with a similar problem and could provide some ideas?&lt;/p&gt;&#xA;" OwnerUserId="10093" LastEditorUserId="491" LastEditDate="2023-04-02T14:04:28.153" LastActivityDate="2023-04-02T14:04:28.153" Title="Constrained optimisation with too many degrees of freedom" Tags="|optimization|python|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8796" PostTypeId="2" ParentId="1117" CreationDate="2022-08-01T15:54:39.557" Score="-1" Body="&lt;p&gt;We built this software with the idea of automating some of the steps in deploying an optimization model solution: &lt;a href=&quot;https://fuinn.github.io/mos-docs/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://fuinn.github.io/mos-docs/&lt;/a&gt; .&lt;/p&gt;&#xA;&lt;p&gt;Perhaps it may be helpful.&lt;/p&gt;&#xA;" OwnerUserId="10091" LastActivityDate="2022-08-01T15:54:39.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8797" PostTypeId="2" ParentId="8795" CreationDate="2022-08-01T16:09:35.283" Score="4" Body="&lt;p&gt;You can solve this as a linear program. The variables are how much of each instrument to sell. The sole constraint (other than lower and upper bounds on each variable) is the demand constraint (equality). The objective is to minimize the total price (which will automatically minimize the per unit price). You do not need a constraint involving the target price; either the optimal solution has unit price less than or equal to the target, or it cannot be done.&lt;/p&gt;&#xA;&lt;p&gt;Update: If the objective is to get as close as possible to the target price &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; while exactly meeting demand &lt;span class=&quot;math-container&quot;&gt;$D,$&lt;/span&gt; you can introduce a variable &lt;span class=&quot;math-container&quot;&gt;$z \ge 0$&lt;/span&gt; to represent the deviation in average price and minimize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to the supply limits, the demand constraint (equation) and a pair of constraints &lt;span class=&quot;math-container&quot;&gt;$$z \ge (T - P)/D$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$z \ge (P - T)/D,$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is a placeholder for the expression giving the total price in terms of the other decision variables. If you want to get as close as possible to the target price &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; without exceeding it, you can replace the second constraint with &lt;span class=&quot;math-container&quot;&gt;$$T \le P\cdot D.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-08-01T19:11:16.270" LastActivityDate="2022-08-01T19:11:16.270" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8798" PostTypeId="1" AcceptedAnswerId="8801" CreationDate="2022-08-01T19:15:46.627" Score="3" ViewCount="132" Body="&lt;p&gt;I am new to the field of stochastic programming and saw that the general formulation of a two-stage stochastic programming problem is given by:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x\in X}\{ g(x)= f(x) + E_{\xi}[Q(x,\xi)]\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; is the realization of uncertain data. Techniques such as Benders' Decomposition can be applied to solve these problems. However, I did not come across examples where &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; is dependent on our decision in the first stage &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, i.e. we would deal with &lt;span class=&quot;math-container&quot;&gt;$\xi(x)$&lt;/span&gt;. Can the same solution methods be applied for such cases and if not, what are standard approaches to solve such decision dependent scenarios?&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="3464" LastEditDate="2022-08-01T19:40:57.283" LastActivityDate="2022-08-03T08:25:15.663" Title="Decision dependent scenarios in Stochastic Programming" Tags="|stochastic-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8799" PostTypeId="1" AcceptedAnswerId="8839" CreationDate="2022-08-01T21:56:15.163" Score="2" ViewCount="80" Body="&lt;p&gt;If I want to try a greedy randomized adaptive search procedure for the generalized assignment problem (assign N tasks to N workers to minimize the total costs), the GRASP method requires 2 parts&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Solution construction&lt;/li&gt;&#xA;&lt;li&gt;Local search (Best-improving neighborhood search)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qZOyB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qZOyB.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;For my local search function &lt;code&gt;N(S)&lt;/code&gt;, what are some other methods to try instead of doing 2 random assignment swaps?&lt;/p&gt;&#xA;" OwnerUserId="9522" LastEditorUserId="9522" LastEditDate="2022-08-01T22:25:24.417" LastActivityDate="2022-08-06T16:04:49.570" Title="How to do Local search when using Greedy random heuristics for GAP" Tags="|assignment-problem|local-search|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8800" PostTypeId="1" CreationDate="2022-08-02T00:33:47.963" Score="1" ViewCount="50" Body="&lt;p&gt;I have a problem involving work shifts and assembly stations.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Work shifts have the subscript = T&lt;/li&gt;&#xA;&lt;li&gt;Workstations have the subscript = J&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;My decision variable is X[t][j]&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For each turn (T) I am trying to use the value of the array below and substract a generic value like (2) through each assembly station (J).&lt;/p&gt;&#xA;&lt;p&gt;For example: AM[t][j] matrix&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xnpHE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xnpHE.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;For each shift [t]&#xA;X[t][j] = M1[t][j] + X[t][j] – 2.&lt;/p&gt;&#xA;&lt;p&gt;Example first shift (time), and each work station (j).&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;X&lt;a href=&quot;https://i.stack.imgur.com/xnpHE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt; = 100 + 0 – 2 = 98&lt;/li&gt;&#xA;&lt;li&gt;X[1][2] = 0 + 98 – 2 = 96&lt;/li&gt;&#xA;&lt;li&gt;X[1][3] = 0 + 96 – 2 = 94&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Example second shift (time), and each work station (j).&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;X&lt;a href=&quot;https://i.stack.imgur.com/xnpHE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt; = 0 + 200 – 2 = 198&lt;/li&gt;&#xA;&lt;li&gt;X[2][2] = 0 + 198 – 2 = 196&lt;/li&gt;&#xA;&lt;li&gt;X[2][3] = 0 + 196 - 2 = 194&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This is my cplex code.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;subject to {&lt;br /&gt;&#xA;forall (t in T, j in J)&lt;br /&gt;&#xA;Constrain2: X1[t][j] == sum (j in J) M1[t][j] - 2;&#xA;}&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;However, I get the following results&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;X&lt;a href=&quot;https://i.stack.imgur.com/xnpHE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt; = 98&lt;/li&gt;&#xA;&lt;li&gt;X[1][2] = 98&lt;/li&gt;&#xA;&lt;li&gt;X[1][3] = 98&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;It is not decreasing, it just puts the same value of the previous box.&lt;/p&gt;&#xA;&lt;p&gt;Could you advise me how to subtract the value through each workstation for each time.&lt;/p&gt;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;" OwnerUserId="10095" LastActivityDate="2022-08-02T00:33:47.963" Title="CPLEX OPL - Problem of arrangements and increments" Tags="|optimization|linear-programming|cplex|docplex|opl|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8801" PostTypeId="2" ParentId="8798" CreationDate="2022-08-02T08:46:16.847" Score="4" Body="&lt;p&gt;Stochastic programming with decision dependent uncertainty is far less a beaten track than stochastic programming with fully exogenous uncertainty.&lt;/p&gt;&#xA;&lt;p&gt;A short, not well thought through, answer to your question would be: No, you cannot apply Benders (L-shaped method) to such problems directly, at least not in all cases.&lt;/p&gt;&#xA;&lt;p&gt;A hopefully more useful answer would be to study the specific problem at hand. Particularly, how does your decision &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; influence &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt;? Is your &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; continuous or discrete? (probably the latter since you say &lt;em&gt;scenarios&lt;/em&gt;).&#xA;There are at least two ways in which &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; can influence &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt;. It can influence the timing when &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; is revealed (probably not your case), see for example &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-006-0715-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt;.&#xA;Or it can influence the distribution function or support of your &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; (probably your case, I guess). In the latter case, one can still distinguish a couple of cases:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A. Where you can obtain infinitely many different distributions of &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; as a result of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;B. Where you can obtain finitely many distributions&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For class B. see &lt;a href=&quot;https://link.springer.com/content/pdf/10.1023/A:1018943626786.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt; and, particularly, &lt;a href=&quot;https://link.springer.com/article/10.1007/s10287-021-00390-z&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt;. Both are presented for a multistage setting, but can equally well describe your case (after all you have a multistage problem with only two stages). You will probably see that in case B. you might be able to use Benders though within a broader scheme (e.g., you might have to solve several stochastic programs). In case A. things are a bit more involved and I am not sure there is much out there.&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="766" LastEditDate="2022-08-03T08:25:15.663" LastActivityDate="2022-08-03T08:25:15.663" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8802" PostTypeId="1" AcceptedAnswerId="8803" CreationDate="2022-08-02T09:24:29.657" Score="2" ViewCount="548" Body="&lt;p&gt;I am currently working on a project and I want to create a (multiple) decision variable in Gurobi that can only take discrete values with a pre-defined step-width (e.g. 0, 5, 10, ...).&lt;/p&gt;&#xA;&lt;p&gt;I am currently using the command:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;capacity = m.addVars(locations, lb=0.0, name=&amp;quot;capacity&amp;quot;)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, this command only produces continuous results. I know that by including the optional aspect &lt;code&gt;vType = ...&lt;/code&gt; you can define binary variables for example. Unfortunately, I couldn't find anything to extract discrete variables with a pre-defined step-width.&lt;/p&gt;&#xA;" OwnerUserId="10098" LastEditorUserId="10098" LastEditDate="2022-08-03T08:28:39.070" LastActivityDate="2022-08-05T08:54:57.593" Title="Creating discrete variables in Gurobi" Tags="|optimization|gurobi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8803" PostTypeId="2" ParentId="8802" CreationDate="2022-08-02T11:15:07.240" Score="6" Body="&lt;p&gt;You can use &lt;code&gt;vType=GRB.INTEGER&lt;/code&gt; to specify a discrete variable. A minimum working example will look as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;&#xA;&#xA;model = gp.Model()&#xA;capacity = model.addVars(locations, vType=GRB.INTEGER, name=&amp;quot;capacity&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: as mentioned by @Sune, you can get a variable that can only assume values of a multiple of 5 as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = gp.Model()&#xA;capacity_count = model.addVars(locations, vType=GRB.INTEGER, name=&amp;quot;capacity_count&amp;quot;)&#xA;capacity = model.addVars(locations, name=&amp;quot;capacity&amp;quot;)&#xA;&#xA;# Force multiple of 5&#xA;model.addConstrs(capacity[l] == 5*capacity_count[l] for l in locations)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that &lt;code&gt;capacity&lt;/code&gt; can be a left as a continuous variable, as the constraint forces it to be integer.&lt;/p&gt;&#xA;" OwnerUserId="133" LastEditorUserId="133" LastEditDate="2022-08-05T08:54:57.593" LastActivityDate="2022-08-05T08:54:57.593" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8804" PostTypeId="1" AcceptedAnswerId="8826" CreationDate="2022-08-02T14:31:00.197" Score="1" ViewCount="511" Body="&lt;p&gt;I have the model below, based on &lt;a href=&quot;https://www.researchgate.net/publication/230532347_Vehicle_routing_problems_with_split_deliveries&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;. It's a vehicle routing problem with split deliveries, i.e the locations/customers can be visited by multiple vehicles that share the demand at that vehicle. However, in this case, the &amp;quot;customers&amp;quot; are in fact pick locations and the vehicles are forklifts picking items in a warehouse. The cost is simply the distance traveled, which is to be minimized.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ijk}$&lt;/span&gt; is the indicator variable of fork-lift &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; traversing from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, if so &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1$&lt;/span&gt;, else &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{ik}$&lt;/span&gt; is the positive integer variable denoting the quantity fork-lift &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; picks at location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; is the cost of traversing location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; is the daily demand to pe picked at location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; is the weight of item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, placed at location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$kg$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; is the volume of item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, placed at location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$m^3$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is the maximum weight capacity of a fork-lift in &lt;span class=&quot;math-container&quot;&gt;$kg$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is the maximum volume capacity of a fork-lift in &lt;span class=&quot;math-container&quot;&gt;$m^3$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}$&lt;/span&gt; is the set of all fork-lifts.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}_0$&lt;/span&gt; is the set of all pick-locations, including depot.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}$&lt;/span&gt; is the set of all pick-locations, excluding depot.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}$&lt;/span&gt; is the set of all cycles on the set &lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}$&lt;/span&gt; which include the depot. The point &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; denots the depot.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h1&gt;SDVRP model&lt;/h1&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} &#xA;% objective&#xA;\min_{\boldsymbol{x}, \ (i,j)\in \mathcal{E}, \ k\in\mathcal{K}} \quad &amp;amp; z=\displaystyle\sum_{k\in\mathcal{K}}\displaystyle\sum_{i\in\mathcal{N}_0}\displaystyle\sum_{j\in\mathcal{N}_0}c_{ij}x_{ijk} \\&#xA;\nonumber\\&#xA;\textrm{subject to} \quad &amp;amp;  \displaystyle\sum_{i\in\mathcal{N}_0}\sum_{k\in\mathcal{K}} x_{ijk} \ge 1, &amp;amp; j\in \mathcal{N}_0 \tag{1} \\&#xA;&amp;amp;\displaystyle\sum_{i\in\mathcal{N}_0}x_{ipk} - \displaystyle\sum_{j\in\mathcal{N}_0}x_{pjk} = 0, &amp;amp;  p\in \mathcal{N}_0,\quad k\in\mathcal{K} \tag{2}\\&#xA;&amp;amp;\sum_{i\in\mathcal{S}}\sum_{j\in\mathcal{S}} x_{ijk} \le |\mathcal{S}|-1, &amp;amp; k \in \mathcal{K}, \quad \mathcal{S}\subseteq \mathcal{N}_0\tag{3}\\&#xA;&amp;amp;d_i\sum_{j\in\mathcal{N}_0}x_{ijk}\ge y_{ik}, &amp;amp; i \in \mathcal{N}, \quad k\in\mathcal{K}\tag{4}\\&#xA;&amp;amp; \displaystyle\sum_{k\in\mathcal{K}} y_{ik} = d_i, &amp;amp;  i\in\mathcal{N}\tag{5}\\&#xA;&amp;amp; \displaystyle\sum_{i\in\mathcal{N}} y_{ik}w_i \le W, &amp;amp;  k\in\mathcal{K}\tag{6}\\&#xA;&amp;amp; \displaystyle\sum_{i\in\mathcal{N}} y_{ik}v_i \le V, &amp;amp;  k\in\mathcal{K}\tag{7}\\&#xA;&amp;amp; x_{ijk} \in \{0,1\}, &amp;amp; i\in \mathcal{N}_0,\quad j\in \mathcal{N}_0, \quad k\in\mathcal{K}\tag{8}\\&#xA;&amp;amp; y_{ik} \in \mathbb{Z}^{+}, &amp;amp;  i\in\mathcal{N}_0, \quad k\in\mathcal{K}\tag{9}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I've implemented this using lazy constraints (callback) where i modified &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/4410235441681-Location-Routing-Problem-Lazy-Subtour-Elimination-Constraints&quot; rel=&quot;nofollow noreferrer&quot;&gt;this code&lt;/a&gt; in Gurobis website. I tested my program using 3 fork lifts (=K) and 10 pick-locations (=n) but the solution is not what I expect. See end of this post for explanation.&lt;/p&gt;&#xA;&lt;p&gt;Gurobi and I wonder how one would debug a situation like this when there is no error at all.&lt;/p&gt;&#xA;&lt;p&gt;Below is a completely reproducible example of my implementation and the  output of the variables is shown at the end. I appreciate any help!&lt;/p&gt;&#xA;&lt;p&gt;Below is a completely reproducible example of my implementation and the  output.&lt;/p&gt;&#xA;&lt;h1&gt;Gurobipy implementation&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;import sys&#xA;import math&#xA;import random&#xA;from itertools import permutations&#xA;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;&#xA;# Callback - use lazy constraints to eliminate sub-tours&#xA;def subtourelim(model, where):&#xA;    if where == GRB.Callback.MIPSOL:&#xA;        # make a list of edges selected in the solution&#xA;        vals = model.cbGetSolution(model._x)&#xA;        selected = gp.tuplelist((i,j,k) for i, j, k in model._x.keys() if vals[i, j, k] &amp;gt; 0.5)&#xA;        # find the shortest cycle in the selected edge list&#xA;        tour = subtour(selected)&#xA;        if len(tour) &amp;lt; n: &#xA;            for k in range(1,K+1): # subtouring for each fork lift&#xA;                model.cbLazy(gp.quicksum(model._x[i, j, k] for i,j,k in permutations(tour, 3)) &amp;lt;= len(tour)-1)&#xA;                             &#xA;# Given a tuplelist of edges, find the shortest subtour not containing depot&#xA;def subtour(edges):&#xA;    unvisited = list(range(1, n))&#xA;    cycle = range(n+1)  # initial length has 1 more location&#xA;    while unvisited:&#xA;        thiscycle = []&#xA;        neighbors = unvisited&#xA;        while neighbors:&#xA;            current = neighbors[0]&#xA;            thiscycle.append(current)&#xA;            if current != 0:&#xA;                unvisited.remove(current)&#xA;            neighbors = [j for i,j,k in edges.select(current,'*','*') if j == 0 or j in unvisited]&#xA;        if 0 not in thiscycle and len(cycle) &amp;gt; len(thiscycle):&#xA;            cycle = thiscycle&#xA;    return cycle&#xA;&#xA;&#xA;# Parse argument&#xA;'''&#xA;if len(sys.argv) &amp;lt; 3:&#xA;    print('Usage: vrp.py npoints nforklifts')&#xA;    print('{:7}npoints includes depot'.format(&amp;quot;&amp;quot;))&#xA;    sys.exit(1)&#xA;n = int(sys.argv[1])&#xA;K = int(sys.argv[2])&#xA;'''&#xA;n = 10 # number of items to pick, equivalen to number of locations to visit&#xA;K = 3 # number of fork-lifts to use&#xA;&#xA;w_capacity = 1000 # kg&#xA;v_capacity = 10000 # dm^3&#xA;&#xA;# Create n random points&#xA;points = [(0, 0)]&#xA;points += [(random.randint(0, 100), random.randint(0, 100))&#xA;           for i in range(n-1)]&#xA;&#xA;# Dictionary of Manhattan distance between each pair of points&#xA;dist = {(i,j,k):&#xA;        math.sqrt(sum((points[i][p]-points[j][p])**2 for p in range(2)))&#xA;        for i in range(n) for j in range(n) for k in range(1,K+1) if i != j}&#xA;#random.seed(1)&#xA;demand = [0]&#xA;demand += [random.randint(1,10) for i in range(n)]&#xA;&#xA;weight = [0]&#xA;weight += [random.randint(0,100) for i in range(n)]&#xA;&#xA;volume = [0]&#xA;volume += [random.randint(0,1000) for i in range(n)]&#xA;&#xA;print('Number of items ', n)&#xA;print('Number of pickers ', K)&#xA;print('Total demand: ', sum(demand))&#xA;print('Single picker weight capacity: ', w_capacity)&#xA;print('Single picker volume capacity: ', v_capacity)&#xA;print('Total pick weight capacity: ', K*w_capacity)&#xA;print('Total pick volume capacity: ', K*v_capacity)&#xA;print('Weights: ', weight)&#xA;print('Volumes: ', volume)&#xA;print('Demands: ', demand)&#xA;print('Total weight demand: ', sum(weight[i]*demand[i] for i in range(len(weight))))&#xA;print('Total volume demand: ', sum(volume[i]*demand[i] for i in range(len(volume))))&#xA;&#xA;m = gp.Model('SDVRP')&#xA;&#xA;# Create variables: &#xA;&#xA;# x[i,j,k] = 1, if forklift k visits and goes directly from location i to location j &#xA;x = m.addVars(dist.keys(), obj=dist, vtype=GRB.BINARY, name='x')&#xA;&#xA;# y[i,k] = number of items of type i that forklift k picks &#xA;y = m.addVars(gp.tuplelist([(i,k) for i in range(1,n) for k in range(1,K+1)]), vtype=gp.GRB.INTEGER, lb=0, name=&amp;quot;y&amp;quot;)&#xA;&#xA;# Constraints (1)&#xA;m.addConstr(gp.quicksum(x[i,j,k] for i,j,k in dist.keys()) &amp;gt;= 1)&#xA;&#xA;# Constraints (2)&#xA;m.addConstrs(gp.quicksum(x[i,p,k] for i in range(n) if i!=p) - gp.quicksum(x[p,j,k] for j in range(n) if j!=p) == 0 for p in range(n) for k in range(1,K+1))&#xA;&#xA;# Constraints (4)&#xA;m.addConstrs(demand[i]*gp.quicksum(x[i,j,k] for j in range(n) if i!=j) &amp;gt;= y[i,k] for i in range(1,n) for k in range(1,K+1))&#xA;&#xA;# Constraints (5)&#xA;m.addConstrs(gp.quicksum(y[i,k] for k in range(1,K+1)) == demand[i] for i in range(1,n))&#xA;&#xA;# Constraints (6)&#xA;m.addConstrs(gp.quicksum(y[i,k]*weight[i] for i in range(1,n)) &amp;lt;= w_capacity for k in range(1,K+1))&#xA;&#xA;# Constraints (7)&#xA;m.addConstrs(gp.quicksum(y[i,k]*volume[i] for i in range(1,n)) &amp;lt;= v_capacity for k in range(1,K+1))&#xA;&#xA;# Optimize model&#xA;&#xA;m._x = x&#xA;m.Params.LazyConstraints = 1&#xA;m.setParam('MIPGap', 0.05) # finish running once 5% gap is reached&#xA;m.setParam('Timelimit', 60) # finish running once 1 minute has passed&#xA;m.optimize(subtourelim)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Output&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;Set parameter LazyConstraints to value 1&#xA;Set parameter MIPGap to value 0.05&#xA;Set parameter TimeLimit to value 60&#xA;Gurobi Optimizer version 9.5.2 build v9.5.2rc0 (win64)&#xA;Thread count: 4 physical cores, 8 logical processors, using up to 8 threads&#xA;Optimize a model with 73 rows, 297 columns and 1161 nonzeros&#xA;Model fingerprint: 0x49013b49&#xA;Variable types: 0 continuous, 297 integer (270 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [1e+00, 1e+03]&#xA;  Objective range  [1e+01, 1e+02]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [1e+00, 1e+04]&#xA;Presolve time: 0.00s&#xA;Presolved: 73 rows, 297 columns, 1161 nonzeros&#xA;Variable types: 0 continuous, 297 integer (276 binary)&#xA;Found heuristic solution: objective 3588.1169986&#xA;Found heuristic solution: objective 3426.2294702&#xA;Found heuristic solution: objective 1246.6673887&#xA;Found heuristic solution: objective 647.2200397&#xA;&#xA;Root relaxation: objective 2.256603e+02, 100 iterations, 0.00 seconds (0.00 work units)&#xA;&#xA;    Nodes    |    Current Node    |     Objective Bounds      |     Work&#xA; Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time&#xA;...&#xA;Optimal solution found (tolerance 5.00e-02)&#xA;Best objective 2.896915417605e+02, best bound 2.801074130851e+02, gap 3.3084%&#xA;&#xA;User-callback calls 878, time in user-callback 0.01 sec&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Variable result&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;    Variable            X &#xA;-------------------------&#xA;    x[0,6,3]            1 &#xA;    x[1,9,1]            1 &#xA;    x[1,9,2]            1 &#xA;    x[2,7,2]            1 &#xA;    x[3,8,3]            1 &#xA;    x[4,5,2]            1 &#xA;    x[5,4,2]            1 &#xA;    x[6,0,3]            1 &#xA;    x[7,2,2]            1 &#xA;    x[8,3,3]            1 &#xA;    x[9,1,1]            1 &#xA;    x[9,1,2]            1 &#xA;      y[1,1]            5 &#xA;      y[2,2]            3 &#xA;      y[3,3]            1 &#xA;      y[4,2]            9 &#xA;      y[5,2]            1 &#xA;      y[6,3]           10 &#xA;      y[7,2]            4 &#xA;      y[8,3]           10 &#xA;      y[9,1]            7 &#xA;      y[9,2]            1 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The y seems fine since they all correctly sum up to the demand for each location. But the x variables building the tour are way off. Firstly, only forklift 3 starts at zero and none of the forklifts return to zero, despite the flow constraints. Secondly forklift 3 goes 0 -&amp;gt; 6 -&amp;gt;0 and then also 8 -&amp;gt; 3, this tells me that there must be something wrong with the subtour elimination.&lt;/p&gt;&#xA;&lt;h1&gt;EDIT - Following David Torres answer.&lt;/h1&gt;&#xA;&lt;p&gt;To declare the positive integer variable y I did the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;y_keys = {(i, k) for i in list(G.predecessors(&amp;quot;Sink&amp;quot;)) for k in range(K)}&#xA;&#xA;y = m.addVars(&#xA;    y_keys,&#xA;    vtype=GRB.INTEGER,&#xA;    name='y'&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To implement constraints (4),(5),(6) and (7) in the mathematical model I did the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# (4)&#xA;&#xA;for i in list(G.predecessors(&amp;quot;Sink&amp;quot;)):&#xA;        for k in range(K):&#xA;            m.addConstr(&#xA;                y[i,k] &amp;lt;= demand[i]*gp.quicksum(x[i,j,k] for j in range(1,n) if j!=i) &#xA;    )&#xA;&#xA;# (5)&#xA;&#xA;m.addConstrs(gp.quicksum(y[i,k] for k in range(K)) == demand[i] for i in list(G.predecessors(&amp;quot;Sink&amp;quot;)))&#xA;&#xA;# (6) &amp;amp; (7) Note that instead of using weights and volumes, I just use demand constraint Q = 20, i.e. each forklift can only carry 20 items.&#xA;&#xA;m.addConstrs(gp.quicksum(y[i,k] for i in list(G.predecessors(&amp;quot;Sink&amp;quot;))) &amp;lt;= Q for k in range(K))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I run this, the subtours are not eliminate. This is what I get:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;k=0&#xA;    Source-&amp;gt;2&#xA;    Source-&amp;gt;9&#xA;    1-&amp;gt;2&#xA;    1-&amp;gt;6&#xA;    2-&amp;gt;Sink&#xA;    2-&amp;gt;5&#xA;    5-&amp;gt;1&#xA;    6-&amp;gt;5&#xA;    6-&amp;gt;9&#xA;    9-&amp;gt;Sink&#xA;k=1&#xA;    Source-&amp;gt;9&#xA;    1-&amp;gt;2&#xA;    2-&amp;gt;7&#xA;    3-&amp;gt;1&#xA;    3-&amp;gt;6&#xA;    4-&amp;gt;3&#xA;    6-&amp;gt;8&#xA;    7-&amp;gt;4&#xA;    8-&amp;gt;7&#xA;    9-&amp;gt;Sink&#xA;k=2&#xA;    Source-&amp;gt;9&#xA;    2-&amp;gt;5&#xA;    5-&amp;gt;1&#xA;    6-&amp;gt;Sink&#xA;    8-&amp;gt;6&#xA;    9-&amp;gt;8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;All of the trucks go from source to sink immediately, and then there are still subtours.&lt;/p&gt;&#xA;&lt;h1&gt;Full new implementation below:&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;import math&#xA;import random&#xA;&#xA;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;import networkx as nx&#xA;import matplotlib.pyplot as plt&#xA;&#xA;# Callback - use lazy constraints to eliminate sub-tours&#xA;def subtourelim(model, where):&#xA;    if where == GRB.Callback.MIPSOL:&#xA;        # make a list of edges selected in the solution&#xA;        vals = model.cbGetSolution(model._x)&#xA;        for k in range(K):&#xA;            selected = gp.tuplelist(&#xA;                (i, j, k) for i, j in G.edges() if vals[i, j, k] &amp;gt; 0.0&#xA;            )&#xA;            tours = allsubtours(selected)&#xA;            for tour in tours:&#xA;                tourlen = len(tour)&#xA;                tour.append(tour[0])&#xA;                if tourlen &amp;lt; n:&#xA;                    model.cbLazy(&#xA;                        gp.quicksum(&#xA;                            model._x[i, j, k]&#xA;                            for i, j in zip(tour, tour[1:])&#xA;                            if (i, j) in G.edges()&#xA;                        )&#xA;                        &amp;lt;= tourlen - 1&#xA;                    )&#xA;                    print(&amp;quot;added lazy cut&amp;quot;)&#xA;&#xA;&#xA;# Given a tuplelist of edges, find all subtours&#xA;def allsubtours(edges):&#xA;    unvisited = list(range(n))&#xA;    cycles = []&#xA;    while unvisited:&#xA;        thiscycle = []&#xA;        neighbors = unvisited&#xA;        while neighbors:&#xA;            current = neighbors[0]&#xA;            thiscycle.append(current)&#xA;            unvisited.remove(current)&#xA;            neighbors = [&#xA;                j for i, j, _ in edges.select(current, &amp;quot;*&amp;quot;, &amp;quot;*&amp;quot;) if j in unvisited&#xA;            ]&#xA;        if len(thiscycle) &amp;gt; 1:&#xA;            cycles.append(thiscycle)&#xA;    print(f&amp;quot;{cycles=}&amp;quot;)&#xA;    return cycles&#xA;&#xA;&#xA;n = 10  # number of items to pick, equivalent to number of locations to visit&#xA;K = 3  # number of fork-lifts to use&#xA;&#xA;# Create n random points&#xA;points = [(0, 0)]&#xA;points += [(random.randint(0, 100), random.randint(0, 100)) for i in range(n - 1)]&#xA;&#xA;# Dictionary of Manhattan distance between each pair of points&#xA;dist = {&#xA;    (i, j): math.sqrt(sum((points[i][p] - points[j][p]) ** 2 for p in range(2)))&#xA;    for i in range(n)&#xA;    for j in range(n)&#xA;    if i != j&#xA;}&#xA;&#xA;Q = 20&#xA;random.seed(1)&#xA;demand = [0]&#xA;demand += [random.randint(1,10) for i in range(n)]&#xA;&#xA;'''&#xA;weight = [0]&#xA;weight += [random.randint(0,100) for i in range(n)]&#xA;&#xA;volume = [0]&#xA;volume += [random.randint(0,1000) for i in range(n)]&#xA;&#xA;print('Number of items ', n)&#xA;print('Number of pickers ', K)&#xA;print('Total demand: ', sum(demand))&#xA;print('Single picker weight capacity: ', w_capacity)&#xA;print('Single picker volume capacity: ', v_capacity)&#xA;print('Total pick weight capacity: ', K*w_capacity)&#xA;print('Total pick volume capacity: ', K*v_capacity)&#xA;print('Weights: ', weight)&#xA;print('Volumes: ', volume)&#xA;print('Demands: ', demand)&#xA;print('Total weight demand: ', sum(weight[i]*demand[i] for i in range(len(weight))))&#xA;print('Total volume demand: ', sum(volume[i]*demand[i] for i in range(len(volume))))'''&#xA;&#xA;&#xA;# Create graph&#xA;G = nx.DiGraph()&#xA;for k, v in dist.items():&#xA;    if k[0] == 0:&#xA;        i = &amp;quot;Source&amp;quot;&#xA;    else:&#xA;        i = k[0]&#xA;    if k[1] == 0:&#xA;        j = &amp;quot;Sink&amp;quot;&#xA;    else:&#xA;        j = k[1]&#xA;    G.add_edge(i, j, dist=v)&#xA;&#xA;m = gp.Model()&#xA;&#xA;# Create variables:&#xA;x_keys = {(e[0], e[1], k): e[2][&amp;quot;dist&amp;quot;] for e in G.edges(data=True) for k in range(K)}&#xA;&#xA;x = m.addVars(&#xA;    x_keys,&#xA;    obj=x_keys,&#xA;    vtype=GRB.BINARY,&#xA;    name=&amp;quot;x&amp;quot;,&#xA;)&#xA;&#xA;y_keys = {(i, k) for i in list(G.predecessors(&amp;quot;Sink&amp;quot;)) for k in range(K)}&#xA;&#xA;y = m.addVars(&#xA;    y_keys,&#xA;    vtype=GRB.INTEGER,&#xA;    name='y'&#xA;)&#xA;&#xA;# Visit all nodes&#xA;for j in G.nodes():&#xA;    if j not in [&amp;quot;Sink&amp;quot;]:&#xA;        pred = list(G.predecessors(j))&#xA;        if len(pred) &amp;gt; 0:&#xA;            m.addConstr(gp.quicksum(x[i, j, k] for i in pred for k in range(K)) &amp;gt;= 1)&#xA;&#xA;&#xA;# Flow-balance&#xA;for v in G.nodes():&#xA;    if v not in [&amp;quot;Source&amp;quot;, &amp;quot;Sink&amp;quot;]:&#xA;        m.addConstrs(&#xA;            gp.quicksum(x[i, v, k] for i in G.predecessors(v))&#xA;            - gp.quicksum(x[v, j, k] for j in G.successors(v))&#xA;            == 0&#xA;            for k in range(K)&#xA;        )&#xA;&#xA;# All k's must start at Source&#xA;m.addConstrs(&#xA;    gp.quicksum(x[&amp;quot;Source&amp;quot;, j, k] for j in G.successors(&amp;quot;Source&amp;quot;)) == 1&#xA;    for k in range(K)&#xA;)&#xA;&#xA;# All k's must end at Sink&#xA;m.addConstrs(&#xA;    gp.quicksum(x[i, &amp;quot;Sink&amp;quot;, k] for i in G.predecessors(&amp;quot;Sink&amp;quot;)) == 1 for k in range(K)&#xA;)&#xA;&#xA;# (4)&#xA;for i in list(G.predecessors(&amp;quot;Sink&amp;quot;)):&#xA;        for k in range(K):&#xA;            m.addConstr(&#xA;                y[i,k] &amp;lt;= demand[i]*gp.quicksum(x[i,j,k] for j in range(1,n) if j!=i) &#xA;    )&#xA;&#xA;# (5)&#xA;&#xA;m.addConstrs(gp.quicksum(y[i,k] for k in range(K)) == demand[i] for i in list(G.predecessors(&amp;quot;Sink&amp;quot;)))&#xA;&#xA;# (6) &amp;amp; (7) Note that instead of using weights and volumes, I just use demand constraint Q = 20, i.e. each forklift can only carry 20 items.&#xA;&#xA;m.addConstrs(gp.quicksum(y[i,k] for i in list(G.predecessors(&amp;quot;Sink&amp;quot;))) &amp;lt;= Q for k in range(K))&#xA;&#xA;m._x = x&#xA;m.Params.LazyConstraints = 1&#xA;m.optimize(subtourelim)&#xA;&#xA;for k in range(K):&#xA;    print(f&amp;quot;{k=}&amp;quot;)&#xA;    for i, j in G.edges():&#xA;        if x[i, j, k].X &amp;gt; 0.0:&#xA;            print(f&amp;quot;\t{i}-&amp;gt;{j}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4222" LastEditorUserId="4752" LastEditDate="2022-08-05T12:24:37.833" LastActivityDate="2022-08-05T12:24:37.833" Title="Subtour elimination in SDVRP" Tags="|python|combinatorial-optimization|gurobi|vehicle-routing|traveling-salesman|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8805" PostTypeId="2" ParentId="8804" CreationDate="2022-08-02T15:29:48.147" Score="4" Body="&lt;p&gt;Your implementations of constraints (1), (6) and (7) do not match the algebraic formulation. (You sum over different variables than what the formulation indicates.) Does fixing that solve the problem?&lt;/p&gt;&#xA;&lt;p&gt;Addendum: After modification, the new solution uses only variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,k}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$i=j$&lt;/span&gt; (and consequently &lt;span class=&quot;math-container&quot;&gt;$c_{i,j}=0.$&lt;/span&gt; Without knowing the full details of the model, I suspect that you want either to constrain &lt;span class=&quot;math-container&quot;&gt;$x_{i,i,k}=0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; or change the index of summation in (1) (and possibly elsewhere) to skip the case &lt;span class=&quot;math-container&quot;&gt;$i=j.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-08-02T18:38:51.047" LastActivityDate="2022-08-02T18:38:51.047" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8806" PostTypeId="1" CreationDate="2022-08-02T15:34:10.717" Score="2" ViewCount="304" Body="&lt;p&gt;Assuming an objective function is a multivariable polynomial with real coefficients, in variables {x1, x2, ..., xn} with all exponents no larger than 1, and with linear inequalities on the variables, what are some good sources and/or approaches?&lt;/p&gt;&#xA;&lt;p&gt;For instance:&lt;/p&gt;&#xA;&lt;p&gt;Minimize .3 x1 - .5 x2 + .4 x3 + .9 x1 x2 - x1 x2 x3&lt;/p&gt;&#xA;&lt;p&gt;subject to&lt;/p&gt;&#xA;&lt;p&gt;0 &amp;lt;= x1&lt;/p&gt;&#xA;&lt;p&gt;0 &amp;lt;= x2&lt;/p&gt;&#xA;&lt;p&gt;0 &amp;lt;= x3&lt;/p&gt;&#xA;&lt;p&gt;x1+x2 &amp;lt;= .9&lt;/p&gt;&#xA;&lt;p&gt;x2+x3 &amp;gt;=.3&lt;/p&gt;&#xA;&lt;p&gt;to find the solution (x1,x2,x3)=(0,.9,0).&lt;/p&gt;&#xA;" OwnerUserId="10102" LastEditorUserId="67" LastEditDate="2022-08-03T16:00:45.217" LastActivityDate="2022-08-03T16:00:45.217" Title="Minimizing a monomial function subject to inequality constraints" Tags="|linear-programming|nonlinear-programming|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8807" PostTypeId="2" ParentId="8806" CreationDate="2022-08-02T16:13:27.357" Score="3" Body="&lt;p&gt;To some extent, the answer depends on whether the objective function is convex (assuming minimization) or not. One general approach would be to approximate the objective with a piecewise linear function. With a convex objective, this would be an LP. Otherwise, it would be a MIP. There may also be a version/generalization of &lt;a href=&quot;https://optimization.mccormick.northwestern.edu/index.php/McCormick_envelopes&quot; rel=&quot;nofollow noreferrer&quot;&gt;McCormick envelopes&lt;/a&gt; that would be useful.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-02T16:13:27.357" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8808" PostTypeId="2" ParentId="8806" CreationDate="2022-08-02T16:36:45.843" Score="6" Body="&lt;p&gt;The objective function you described is called multilinear.&lt;/p&gt;&#xA;&lt;p&gt;Although not necessarily the best way of solving this problem, it can be &amp;quot;lifted&amp;quot; into a higher dimensional space, thereby becoming a non-convex quadratic objective subject to non-convex quadratic constraints; specifically becoming a bilinear optimization problem. That is accomplished by introducing  new variables for various products of variables in such a manner that there are no products involving more than 2 variables. Such a formulation can then be solved with a bilinear solver, such as Gurobi, which can solve it to global optimality if it doesn't run out of time or memory. (Note that CPLEX's QCQP solver could not be used because it does not allow non-convex quadratic constraints).&lt;/p&gt;&#xA;&lt;p&gt;In you example, introduce variables &lt;code&gt;x1_2&lt;/code&gt; and &lt;code&gt;x1_2_3&lt;/code&gt;, along with constraints&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x1_2 = x1*x2&#xA;x1_2_3 = x1_2*x3  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The objective can then be written as &lt;code&gt;.3 x1 - .5 x2 + .4 x3 + .9 x1_2 - x1_2_3&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This formulation can be provided to any solver which can handle any combination of non-convex quadratic objective and quadratic equality constraints (in addition to the linear constraints your problem has).&lt;/p&gt;&#xA;&lt;p&gt;If you use a more general purpose non-convex global solver, you can provide it either the &amp;quot;lifted&amp;quot; formulation as shown above, or enter your original formulation as is.  In such case, it might be better to use the original formulation, and let the solver handle any reformulations.&lt;/p&gt;&#xA;&lt;p&gt;Another approach is to directly provide one of the above formulations to a local non-convex optimizer, in which case I suspect the original formulation might be best.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2022-08-02T16:36:45.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8809" PostTypeId="1" CreationDate="2022-08-03T00:23:31.633" Score="3" ViewCount="420" Body="&lt;p&gt;I want to use pyomo to formulate MILP problems in python such as Green Vehicle Routing Problem and others but use metaheuristics algorithms (GA, Harmony search, etc.) to solve those problems instead of using pyomo solvers, its part of my PhD project and can not use derivative-based solvers such as Gurobi and cplex etc. at all; If the answer that I can not, what is the alternative to formulate the problems in python then solve them with metaheuristics algorithms because I found pyomo easy and time saving to be used in formulating the problems.&lt;/p&gt;&#xA;" OwnerUserId="10106" LastActivityDate="2022-12-05T01:14:42.757" Title="Can I formulate a green vehicle routing problem with pyomo model then solve it with metaheuristics algorithms e.g. GA,HS rather than pyomo solver?" Tags="|mixed-integer-programming|combinatorial-optimization|pyomo|vehicle-routing|metaheuristics|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8810" PostTypeId="2" ParentId="8809" CreationDate="2022-08-03T06:39:25.840" Score="2" Body="&lt;p&gt;If you are interested to write the problem as a standard formulation, like mixed-integer linear programming, you can use Pyomo as a framework and solve the problem in an exact manner with your favorite solver.&lt;/p&gt;&#xA;&lt;p&gt;About the (meta)heuristic, it is somewhat different from the exact method. In this case either you should already write your own algorithm or use some package/libraries to do it. Also, the flowing package and thread might be helpful.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://deap.readthedocs.io/en/master/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Distributed revolutionary algorithms in python&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/4667/which-python-package-is-suitable-for-multiobjective-optimization&quot;&gt;Which Python package is suitable for multiobjective optimization&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-08-03T06:39:25.840" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8811" PostTypeId="1" CreationDate="2022-08-03T09:59:34.643" Score="1" ViewCount="608" Body="&lt;p&gt;I have an BIP problem as below&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\underset{\bf b}{\max}{\bf u}^T\bf b$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{subject to}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$${\bf Ab}\le1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;${\bf b}=\{b_1,b_2,\cdots,b_N\}$&lt;/span&gt; is a column vector of decision/optimization variables&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\bf u}=\{u_1,u_2,\cdots,u_N\}$&lt;/span&gt; is a known column vector with &lt;span class=&quot;math-container&quot;&gt;$u_n\ge 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\bf A}\in\{0,1\}^{M\times N}$&lt;/span&gt; is a known binary matrix.&lt;/p&gt;&#xA;&lt;p&gt;How can I transform this into LP? What would be an efficient relaxation of the binary variables.&lt;/p&gt;&#xA;&lt;p&gt;Making the binary variables continuous and then rounding doesn't do a good job for my problem.&lt;/p&gt;&#xA;&lt;p&gt;I want to have some formulation as below&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\underset{\bf b}{\max}{\bf u}^T\bf b+\text{penalty function}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{subject to}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$${\bf Ab}\le1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0\le b_n\le1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What could be an efficient penalty function?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2022-08-04T23:35:39.297" LastActivityDate="2022-08-04T23:35:39.297" Title="How to transform this BIP into LP with the help of penalty function?" Tags="|mixed-integer-programming|linear-programming|lp-relaxation|penalty-based-optimization|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8812" PostTypeId="2" ParentId="8811" CreationDate="2022-08-03T10:17:40.933" Score="6" Body="&lt;p&gt;You can't. If there were a way to transform a MIP to an LP it would mean MIPs can be solved in polynomial time among many other things (&lt;strong&gt;edit&lt;/strong&gt;: not exactly, see below). You can relax the binaries to continuous to get a lower bound, but that's about it. Just use a MIP solver.&lt;/p&gt;&#xA;&lt;p&gt;From @1137h4xor's comment it seems like there is a method, which will add exponentially many variables to your problem (so complexity is still not polynomial as expected). In practice, the new problem will be at least as hard to solve as the original MIP.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2022-08-03T12:40:49.463" LastActivityDate="2022-08-03T12:40:49.463" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8814" PostTypeId="2" ParentId="8811" CreationDate="2022-08-03T11:01:03.543" Score="4" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is &lt;a href=&quot;https://en.wikipedia.org/wiki/Unimodular_matrix#Total_unimodularity&quot; rel=&quot;nofollow noreferrer&quot;&gt;totally unimodular&lt;/a&gt;, you can replace the binary restrictions on &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$0 \le b_i \le 1$&lt;/span&gt;, and solve as an LP.  See &lt;a href=&quot;https://mathoverflow.net/questions/31367/proving-that-a-binary-matrix-is-totally-unimodular&quot;&gt;https://mathoverflow.net/questions/31367/proving-that-a-binary-matrix-is-totally-unimodular&lt;/a&gt; for sufficient conditions on the binary matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; to be totally unimodular.&lt;/p&gt;&#xA;&lt;p&gt;Otherwise, see the comment by @1137h4xor&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-08-03T22:06:40.833" LastActivityDate="2022-08-03T22:06:40.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8815" PostTypeId="1" AcceptedAnswerId="8819" CreationDate="2022-08-03T11:38:01.913" Score="4" ViewCount="345" Body="&lt;p&gt;This might be a silly question but by 'solving' an optimization problem do we mean if an optimal solution exists we find such a solution and its optimal value and if it 'doesn't exist' (for example the optimal solution is &lt;span class=&quot;math-container&quot;&gt;$\pm\infty$&lt;/span&gt; or there is no feasible solution, etc) we say there is no optimal solution? (i.e it's like a decision problem but if the answer is yes we should also specify the optimal solution and its value) Or does it mean we try to find an optimal solution but if we fail, it doesn't mean there's no optimal solution? I think the answer is the first one. I was reading about &lt;a href=&quot;https://en.wikipedia.org/wiki/Exact_cover&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Exact_cover&lt;/a&gt; (it's actually a decision problem that is NP-complete) and I thought the CSP (a.k.a feasibility problem) associated with exact cover problem must be NP-complete as well. But after that I wondered whether solving the CSP is like a decision problem or not, so I asked this question. Another way to express my question is this: By solving an optimization problem do we mean a method (probably an algorithm) that is sound (i.e if it returns a solution it is indeed an optimal solution) and it terminates, or a method which is both sound and complete and terminates? (as a result, if it doesn't return a solution (i.e returns failure) it really means there is no optimal solution.) (complete means if at least one optimal solution exists the method will return such a solution.) I think the answer is the second one.&lt;/p&gt;&#xA;" OwnerUserId="5094" LastEditorUserId="5094" LastEditDate="2022-08-03T11:55:51.047" LastActivityDate="2022-08-03T15:27:12.077" Title="'Solving' an optimization problem" Tags="|optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8817" PostTypeId="2" ParentId="8806" CreationDate="2022-08-03T12:14:20.223" Score="1" Body="&lt;p&gt;You can directly use a Global solver such as LINGO, thus:&lt;/p&gt;&#xA;&lt;p&gt;Min= .3&lt;em&gt;x1 - .5&lt;/em&gt;x2 + .4&lt;em&gt;x3 + .9&lt;/em&gt;x1* x2 - x1&lt;em&gt;x2&lt;/em&gt; x3;&lt;/p&gt;&#xA;&lt;p&gt;!subject to;&lt;/p&gt;&#xA;&lt;p&gt;! Variables are &amp;gt;= 0 by default;&lt;/p&gt;&#xA;&lt;p&gt;x1+x2 &amp;lt;= .9;&lt;/p&gt;&#xA;&lt;p&gt;x2+x3 &amp;gt;=.3;&lt;/p&gt;&#xA;&lt;p&gt;Global optimal solution found.&lt;/p&gt;&#xA;&lt;p&gt;Objective value:    -0.4500000&lt;/p&gt;&#xA;&lt;p&gt;Objective bound:    -0.4500000&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; Variable           Value     &#xA;       X1        0.000000    &#xA;       X2        0.900000        &#xA;       X3        0.000000          &#xA;&#xA;      Row    Slack or Surplus     &#xA;        1       -0.450000         &#xA;        2        0.000000         &#xA;        3        0.600000       &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-08-03T12:14:20.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8818" PostTypeId="1" CreationDate="2022-08-03T14:03:47.767" Score="0" ViewCount="84" Body="&lt;p&gt;I want to develop a script for a decision tree, which I already know its structure, like a flowchart in which each internal node represents a &amp;quot;test&amp;quot; on an attribute (e.g. whether a coin flip comes up heads or tails), each branch represents the outcome of the test, and each leaf node represents a class label. The paths from the root to leaf represent classification rules. Something like this simple decision flow diagram: &lt;a href=&quot;https://miro.medium.com/max/1258/1*xLKdaL_RFhqFuy1iKSXvXA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://miro.medium.com/max/1258/1*xLKdaL_RFhqFuy1iKSXvXA.png&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there any library that can help me to avoid developing the whole thing (preferably python or Java)? Ideally, there should be a way to retrieve questions from the DB and when an answer is provided will give the next question until we reach a leaf node with a decision from a database like let's say SQL database entries that somehow the decision tree has been encoded there.&lt;/p&gt;&#xA;&lt;p&gt;I think implementing the idea would not be difficult. I am just sure that this is popular in certain fields like operation research and definitely there are good libraries out there doing just that.&lt;/p&gt;&#xA;&lt;p&gt;Searching for such libraries turned out to be difficult due to the similarity with the commonly used decision tree models in ML. Keyword suggestions as to what to search for would be helpful too.&lt;/p&gt;&#xA;&lt;p&gt;I intend to draw the whole decision tree in Microsoft Visio and export the flowchart into a table that describes the connections, and make a script to translate the diagram into database entries that are compatible with the decision tree library. But I am open to any other suggestion in case there is something better to do that.&lt;/p&gt;&#xA;&lt;p&gt;TL;DR:&#xA;Looking for a library or an app to:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Drawing the decision tree flowchart;&lt;/li&gt;&#xA;&lt;li&gt;exporting the rules from the flowchart to a database or a file to create a questionnaire app that starts from the root question of the decision tree until reaching a decision based on the answers of the user.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10111" LastEditorUserId="67" LastEditDate="2022-08-03T19:20:31.833" LastActivityDate="2022-08-03T19:20:31.833" Title="Decision tree for a decision analysis to identify a strategy to reach a goal" Tags="|python|java|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8819" PostTypeId="2" ParentId="8815" CreationDate="2022-08-03T15:27:12.077" Score="5" Body="&lt;p&gt;I think that the correct definition of &amp;quot;solving&amp;quot; is finding an optimal solution or proving that none exists. Trying and failing to find an optimum (because, say, the solver times out either before it finds a feasible solution or before it proves optimality) would properly be referred to as &amp;quot;attempting to solve&amp;quot; the problem.&lt;/p&gt;&#xA;&lt;p&gt;That said, not everyone picks nits as close to the ground as I do. So you will likely encounter at least occasional uses of &amp;quot;solving&amp;quot; that include trying and failing, or partially succeeding (finding a feasible solution but not proving optimality).&lt;/p&gt;&#xA;&lt;p&gt;There may also a bit of a distinction between &amp;quot;solving&amp;quot; in an academic context and a real-world context. In the real world, it is often more important to find a &amp;quot;good&amp;quot; solution in a &amp;quot;reasonably short&amp;quot; period of time than to find a proven optimum, especially in cases where the bulk of the solution time is spent proving optimality of a solution that has already been found.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-03T15:27:12.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8820" PostTypeId="2" ParentId="8811" CreationDate="2022-08-03T15:42:43.777" Score="3" Body="&lt;p&gt;This might be a candidate for a binary decision diagram (BDD) approach. It involves building a layered digraph. Each layer involves deciding whether a particular variable &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; will be 0 or 1. Each node represents the state of the system after a partial solution, which in this case could be the set of remaining variables that can still be set to 1.&lt;/p&gt;&#xA;&lt;p&gt;This approach on the surface is similar (equivalent?) to using dynamic programming. If the digraph gets to big, it is possible to restrict the graph width (and hence the node count) in one of two ways. One way is a &amp;quot;relaxed&amp;quot; BDD, which does not remove any feasible solutions but does introduce infeasible solutions. The other is a &amp;quot;restricted&amp;quot; BDD, which does not introduce any infeasible solutions but does remove some feasible solutions.  The solution to a relaxed BDD is like the best bound at a node in a branch-and-bound tree; the solution to a restricted BDD is an incumbent (not necessarily optimal) solution. There are researchers building branch-and-bound algorithms around BDDs.&lt;/p&gt;&#xA;&lt;p&gt;You can find more information about BDDs, including a very informative book about decision diagrams, at &lt;a href=&quot;https://www.andrew.cmu.edu/user/vanhoeve/mdd/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.andrew.cmu.edu/user/vanhoeve/mdd/&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-03T15:42:43.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8821" PostTypeId="1" CreationDate="2022-08-03T21:36:23.440" Score="3" ViewCount="87" Body="&lt;p&gt;I'd like to produce a model that uses very coarse inputs and produces similarly coarse outputs.&lt;/p&gt;&#xA;&lt;p&gt;For example, if I were estimating personal sources of wealth I might say that in a given year:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    There is a high likelihood that I will earn a moderate salary.&#xA;    There is a trivial chance that I will get a high lottery payout.&#xA;    There is a small chance I will inherit a large amount of money.&#xA;    Therefore...&#xA;    Salary = b * m = m&#xA;    Lottery = t * b = t&#xA;    Inheritance = s * b = s&#xA;    Total = m + t + s = m&#xA;    Where the values are either big (b), moderate (m), small (s), or trivial (t).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This example is far from perfect but describes how I'd like the front end of the model to look.&#xA;Obviously there is quite a lot more work required at the back end to ensure that the calculations are coherent.&lt;/p&gt;&#xA;&lt;p&gt;Is there a name for this kind of model?&#xA;Or a branch of mathematics that would be useful to draw upon?&lt;/p&gt;&#xA;&lt;p&gt;The approach probably looks weird, and not very useful when we could just use numbers instead, but there are a few things in its favour:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Simple to operate&lt;/li&gt;&#xA;&lt;li&gt;Intuitive verbal descriptions of input and output quantities&lt;/li&gt;&#xA;&lt;li&gt;Easier for non-mathematicians to gain insight into the reasoning and model structure&lt;/li&gt;&#xA;&lt;li&gt;Keeps the focus of analysis on big picture (rather than getting drawn into considering small differences that may be an artefact of input measurement error)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10114" LastActivityDate="2022-08-08T15:47:33.533" Title="Coarse modelling - is there a name for this?" Tags="|modeling|error-bounds|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8822" PostTypeId="1" CreationDate="2022-08-03T21:59:01.843" Score="-4" ViewCount="674" Body="&lt;p&gt;I have an LP problem (linear objective with eq and ineq constraints) in binary variables.&lt;/p&gt;&#xA;&lt;p&gt;Except for the objective, all the coefficients are integer, mostly in {-1,0,1}. Maybe the objective coeff could be discretized.&lt;/p&gt;&#xA;&lt;p&gt;I usually use an MI solver (gurobi). Since it solves a moderate problem in my case under a second, I suspect that it may have a special structure that permits employing a different specialized method that will be faster. Can you suggest other methods to solve my problem?&lt;/p&gt;&#xA;&lt;p&gt;More details in a duplicate question:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://math.stackexchange.com/questions/4504572/methods-for-binary-linear-programming/4505035&quot;&gt;https://math.stackexchange.com/questions/4504572/methods-for-binary-linear-programming/4505035&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;@worldsmithhelper suggests (in the comments) to test a problem on all solvers using&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://neos-server.org/neos/solvers/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://neos-server.org/neos/solvers/index.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm considering automating it. I'm using yalmip, which can export the following formats:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://yalmip.github.io/tags/#export-and-import&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://yalmip.github.io/tags/#export-and-import&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This can be wrapped in an XML and sent via a python client (in a loop for each solver):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://neos-guide.org/users-guide/neos-interfaces/#xml&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://neos-guide.org/users-guide/neos-interfaces/#xml&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10116" LastEditorUserId="10116" LastEditDate="2022-08-08T01:26:00.707" LastActivityDate="2022-08-12T03:08:58.693" Title="Methods for binary linear programming" Tags="|linear-programming|binary-variable|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="8823" PostTypeId="1" AcceptedAnswerId="8825" CreationDate="2022-08-04T00:37:24.840" Score="1" ViewCount="279" Body="&lt;p&gt;I am looking for MILP modeling code with stochastic/deterministic demand for Inventory ordering policy (e.g. (q,r) or (s,S) policy) with pyomo or gurobi or cplex or GAMS.  Any link?&lt;/p&gt;&#xA;" OwnerUserId="10117" LastEditorUserId="491" LastEditDate="2022-08-04T16:25:09.063" LastActivityDate="2022-08-05T12:44:39.340" Title="MILP modeling Code with pyomo or gurobi or cplex or GAMS. Any link?" Tags="|optimization|mixed-integer-programming|gurobi|pyomo|inventory|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8824" PostTypeId="1" CreationDate="2022-08-04T09:36:47.593" Score="1" ViewCount="101" Body="&lt;p&gt;I am trying to solve an optimization problem on Excel or Python. My constraints are the available number of employees (=20), the number of working days/month (=20), the number of working hours/day (=8), and the maximum number of overtime working hours/day (=6). The variable I'm trying to minimize is cost: employees get USD 20/hour for work &amp;lt;=8 hours, USD 30/hour for work &amp;gt;8 and &amp;lt;=12 hours, USD 50/hour for &amp;gt;12 and &amp;lt;=14 hours.&lt;/p&gt;&#xA;&lt;p&gt;The jobs require a set number of hours and are bound by start and end dates.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Job 1: Start 08/01/2022, End 09/01/2022, Hours 200&lt;/li&gt;&#xA;&lt;li&gt;Job 2: Start 08/15/2022, End 09/15/2022, Hours 250&lt;/li&gt;&#xA;&lt;li&gt;Job 3: Start 08/30/2022, End 09/15/2022, Hours 100&lt;/li&gt;&#xA;&lt;li&gt;Job 4: Start 08/01/2022, End 09/15/2022, Hours 300&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;How do I go about this? All the case studies I see online are for much simpler problems with not as many constraints and/or not bound by start/end dates.&lt;/p&gt;&#xA;" OwnerUserId="10118" LastEditorUserId="491" LastEditDate="2022-08-04T16:24:50.357" LastActivityDate="2022-08-04T16:24:50.357" Title="Minimize cost given working days/hours/required hours per job/start &amp; end dates" Tags="|optimization|linear-programming|constraint|scheduling|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8825" PostTypeId="2" ParentId="8823" CreationDate="2022-08-04T09:54:10.067" Score="2" Body="&lt;p&gt;One example I know of: &lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2020/11/optimal-qr-inventory-policy-as-mip.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://yetanothermathprogrammingconsultant.blogspot.com/2020/11/optimal-qr-inventory-policy-as-mip.html&lt;/a&gt; (and its Pyomo version: &lt;a href=&quot;https://sysid.github.io/inventory_management/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://sysid.github.io/inventory_management/&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="907" LastActivityDate="2022-08-04T09:54:10.067" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8826" PostTypeId="2" ParentId="8804" CreationDate="2022-08-04T10:38:55.403" Score="5" Body="&lt;p&gt;The subtour elimination constraints are not correct, they are mostly empty. Try to debug the callback calls, as you can see also from the log, none of lazy constraints are applied.&lt;/p&gt;&#xA;&lt;p&gt;You can:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use callbacks to enumerate and forbid all cycles for a given forklift. This is what the &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/4410235441681/comments/5553651253137&quot; rel=&quot;nofollow noreferrer&quot;&gt;last comment&lt;/a&gt; in the thread where you got the subtour elimination code suggested. This is very expensive for large graphs.&lt;/li&gt;&#xA;&lt;li&gt;Use MTZ constraints.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For more in-depth study of the SDVRP, please see &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/0166218X9200172I?ref=cra_js_challenge&amp;amp;fr=RR-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dror et al. (1994)&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here it is using MTZ constraints (disregarding the &lt;code&gt;y&lt;/code&gt; constraints): code modified from &lt;a href=&quot;https://github.com/Kuifje02/vrpy/blob/master/vrpy/subproblem_lp.py#L227&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kuifje02/vrpy/:vrpy/subproblem_lp.py#L227&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import math&#xA;import random&#xA;&#xA;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;import networkx as nx&#xA;import matplotlib.pyplot as plt&#xA;&#xA;n = 100  # number of items to pick, equivalent to number of locations to visit&#xA;K = 3  # number of fork-lifts to use&#xA;&#xA;# Create n random points&#xA;points = [(0, 0)]&#xA;points += [(random.randint(0, 100), random.randint(0, 100)) for i in range(n - 1)]&#xA;&#xA;# Dictionary of Manhattan distance between each pair of points&#xA;dist = {&#xA;    (i, j): math.sqrt(sum((points[i][p] - points[j][p]) ** 2 for p in range(2)))&#xA;    for i in range(n)&#xA;    for j in range(n)&#xA;    if i != j&#xA;}&#xA;&#xA;&#xA;# Create graph&#xA;G = nx.DiGraph()&#xA;for k, v in dist.items():&#xA;    if k[0] == 0:&#xA;        i = &amp;quot;Source&amp;quot;&#xA;    else:&#xA;        i = k[0]&#xA;    if k[1] == 0:&#xA;        j = &amp;quot;Sink&amp;quot;&#xA;    else:&#xA;        j = k[1]&#xA;    G.add_edge(i, j, dist=v)&#xA;&#xA;m = gp.Model()&#xA;&#xA;# Create variables:&#xA;x_keys = {(e[0], e[1], k): e[2][&amp;quot;dist&amp;quot;] for e in G.edges(data=True) for k in range(K)}&#xA;x = m.addVars(&#xA;    x_keys,&#xA;    obj=x_keys,&#xA;    vtype=GRB.BINARY,&#xA;    name=&amp;quot;x&amp;quot;,&#xA;)&#xA;&#xA;# Visit all nodes&#xA;for j in G.nodes():&#xA;    if j not in [&amp;quot;Source&amp;quot;, &amp;quot;Sink&amp;quot;]:&#xA;        pred = list(G.predecessors(j))&#xA;        m.addConstr(gp.quicksum(x[i, j, k] for i in pred for k in range(K)) &amp;gt;= 1)&#xA;&#xA;&#xA;# Flow-balance&#xA;for v in G.nodes():&#xA;    if v not in [&amp;quot;Source&amp;quot;, &amp;quot;Sink&amp;quot;]:&#xA;        m.addConstrs(&#xA;            gp.quicksum(x[i, v, k] for i in G.predecessors(v))&#xA;            - gp.quicksum(x[v, j, k] for j in G.successors(v))&#xA;            == 0&#xA;            for k in range(K)&#xA;        )&#xA;&#xA;# All k's must start at Source&#xA;m.addConstrs(&#xA;    gp.quicksum(x[&amp;quot;Source&amp;quot;, j, k] for j in G.successors(&amp;quot;Source&amp;quot;)) == 1&#xA;    for k in range(K)&#xA;)&#xA;&#xA;# All k's must end at Sink&#xA;m.addConstrs(&#xA;    gp.quicksum(x[i, &amp;quot;Sink&amp;quot;, k] for i in G.predecessors(&amp;quot;Sink&amp;quot;)) == 1 for k in range(K)&#xA;)&#xA;&#xA;# MTZ&#xA;M = len(G.nodes())&#xA;&#xA;# Add rank varibles&#xA;z = m.addVars(&#xA;    [(v, k) for v in G.nodes() for k in range(K)],&#xA;    name=&amp;quot;z&amp;quot;,&#xA;    lb=0,&#xA;    ub=len(G.nodes()),&#xA;    vtype=GRB.INTEGER,&#xA;)&#xA;# Add big-M constraints&#xA;m.addConstrs(&#xA;    (&#xA;        z[i, k] + 1 &amp;lt;= z[j, k] + M * (1 - x[i, j, k])&#xA;        for k in range(K)&#xA;        for (i, j) in G.edges()&#xA;    ),&#xA;    name=&amp;quot;elementary&amp;quot;,&#xA;)&#xA;&#xA;# Source is first, Sink is last (optional)&#xA;m.addConstrs((z[&amp;quot;Source&amp;quot;, k] == 0 for k in range(K)), name=&amp;quot;Source_is_first&amp;quot;)&#xA;m.addConstrs(&#xA;    (z[v, k] &amp;lt;= z[&amp;quot;Sink&amp;quot;, k] for k in range(K) for v in G.nodes() if v != &amp;quot;Sink&amp;quot;),&#xA;    name=&amp;quot;Sink_after_%s&amp;quot; % v,&#xA;)&#xA;&#xA;m.params.timelimit = 60&#xA;m.optimize()&#xA;&#xA;for k in range(K):&#xA;    print(f&amp;quot;{k=}&amp;quot;)&#xA;    for i, j in G.edges():&#xA;        if x[i, j, k].X &amp;gt; 0.0:&#xA;            print(f&amp;quot;\t{i}-&amp;gt;{j}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4752" LastEditorUserId="4752" LastEditDate="2022-08-05T10:40:25.543" LastActivityDate="2022-08-05T10:40:25.543" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8827" PostTypeId="2" ParentId="8120" CreationDate="2022-08-04T14:20:40.853" Score="0" Body="&lt;p&gt;A good visualization is in the video &lt;a href=&quot;https://youtu.be/SzORM1aSwQY&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://youtu.be/SzORM1aSwQY&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10119" LastActivityDate="2022-08-04T14:20:40.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8828" PostTypeId="2" ParentId="6153" CreationDate="2022-08-04T14:27:31.627" Score="0" Body="&lt;p&gt;A good visualization is in the video &lt;a href=&quot;https://youtu.be/SzORM1aSwQY&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://youtu.be/SzORM1aSwQY&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10119" LastActivityDate="2022-08-04T14:27:31.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8829" PostTypeId="2" ParentId="8821" CreationDate="2022-08-04T20:36:23.450" Score="4" Body="&lt;p&gt;It's not a direct (or even necessarily close) match to what you have described, but you might be interested in the &lt;a href=&quot;https://en.wikipedia.org/wiki/Analytic_hierarchy_process&quot; rel=&quot;nofollow noreferrer&quot;&gt;analytic hierarchy process&lt;/a&gt; (AHP). There's some math under the hood, but as I recall what the decision maker sees is just stuff along the lines of &amp;quot;which of these is better/more important/more terrifying&amp;quot; and &amp;quot;by how much on a 1 to 5 scale, where 1 is &amp;quot;pretty much a toss-up&amp;quot; and 5 is &amp;quot;absolutely this one over that one&amp;quot;. (I'm approximating from fuzzy memories here.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-04T20:36:23.450" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8831" PostTypeId="1" AcceptedAnswerId="8832" CreationDate="2022-08-05T10:05:17.077" Score="3" ViewCount="1009" Body="&lt;p&gt;How can I solve a problem such as the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\text{minimize}~~~ \sum_{i=1}^n |x_i|&#xA;\\&#xA;\text{subject to}~~~ A x \geq b&#xA;$$&lt;/span&gt;&#xA;?&#xA;Without the absolute values on the variables, it is a simple linear program. Is it possible to convert the verstion with absolute values into a standard linear program?&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt;Note: this question &lt;a href=&quot;https://or.stackexchange.com/q/114/2576&quot;&gt;How to minimize an absolute value in the objective of an LP?&lt;/a&gt; looks similar, but it is different.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="500" LastEditDate="2022-08-05T12:05:18.450" LastActivityDate="2022-08-05T12:05:18.450" Title="How to minimize the sum of absolute values" Tags="|linear-programming|linearization|absolute-value|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8832" PostTypeId="2" ParentId="8831" CreationDate="2022-08-05T12:04:59.003" Score="9" Body="&lt;p&gt;You can use the same approach as in the linked question, but with a separate variable for each summand. Explicitly, minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_i z_i$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;Ax&amp;amp;\ge b\\&#xA;z_i&amp;amp;\ge x_i &amp;amp;&amp;amp;\text{for all $i$}\\&#xA;z_i&amp;amp;\ge -x_i &amp;amp;&amp;amp;\text{for all $i$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-08-05T12:04:59.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8833" PostTypeId="1" AcceptedAnswerId="8836" CreationDate="2022-08-05T12:31:10.110" Score="2" ViewCount="221" Body="&lt;p&gt;Assume I have an infinite number of staff/supply. I have a table of how much time in hours needs to be spent on certain tasks:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Task&lt;/th&gt;&#xA;&lt;th&gt;Demand&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A&lt;/td&gt;&#xA;&lt;td&gt;0.75&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;B&lt;/td&gt;&#xA;&lt;td&gt;0.8&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;C&lt;/td&gt;&#xA;&lt;td&gt;0.65&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;D&lt;/td&gt;&#xA;&lt;td&gt;0.7&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;E&lt;/td&gt;&#xA;&lt;td&gt;0.6&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;F&lt;/td&gt;&#xA;&lt;td&gt;0.65&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;And the tasks can either be assigned to staff separately - i.e. 1 person does A (thus contributing 1 towards the demand for task A), or B, C, D, E, F - or they can be assigned in certain combinations, specified below:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Combination&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;B&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;C&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;D&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;E&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;F&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A; B; C&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A; B&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;B; C&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A; C&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;D; E&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;D; F&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;If I assign a task like (A; B; C), there is no rule as to how much time must be spent on each task, just as long as the total time spent is 1. For example, in assigning task (A; B; C) to somebody, I may tell them to do 0.75hrs of A, 0.15hrs of B, and 0.1hrs of C, or I may tell them to do 0.5hrs of A, 0.3hrs of B, and 0.2hrs of C.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;If it was the case&lt;/strong&gt; that the demand for A+B+C &amp;lt;=1, D+E &amp;lt;= 1 and D+F &amp;lt;=1 then this would be a simple linear optimisation problem, solved here &lt;a href=&quot;https://stackoverflow.com/questions/72982423/task-assignment-to-least-possible-people/72983289?noredirect=1#comment128972545_72983289&quot;&gt;https://stackoverflow.com/questions/72982423/task-assignment-to-least-possible-people/72983289?noredirect=1#comment128972545_72983289&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But it is not. And I cannot simply ignore the combinations for which this is not true and proceed with linear optimisation, because then only the one-task-to-one-person assignments (e.g. 1 person on A, 1 on B, etc.) are permissible. Hence I would end up assigning 6 people to meet the demand, whereas I ought to have given, for example, (A; B; C) to 2 people, A to 1 person, (D; E) to 1 person and (D; F) to 1 person, making up 5 &amp;lt; 6 people in total.&lt;/p&gt;&#xA;&lt;p&gt;I'm very confused as to how to optimise this. I have tried to find a way around it via for loops but things get very messy and I still don't get any closer to a problem.&lt;/p&gt;&#xA;" OwnerUserId="10126" LastEditorUserId="36" LastEditDate="2022-08-05T12:45:45.383" LastActivityDate="2022-08-06T08:31:57.130" Title="Assign jobs to least people with multiple job constraints" Tags="|optimization|linear-programming|algorithms|assignment-problem|r|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8834" PostTypeId="2" ParentId="8823" CreationDate="2022-08-05T12:44:39.340" Score="1" Body="&lt;p&gt;You may find some useful ideas in this paper on s,S policies.&lt;/p&gt;&#xA;&lt;p&gt;IYER, A. V.  AND L. SCHRAGE (1992)&lt;/p&gt;&#xA;&lt;p&gt;ANALYSIS OF THE DETERMINISTIC (s, S) INVENTORY PROBLEM&lt;/p&gt;&#xA;&lt;p&gt;MANAGEMENT SCIENCE&#xA;Vol. 38, No. 9,&lt;/p&gt;&#xA;&lt;p&gt;Part of the abstract is:&lt;/p&gt;&#xA;&lt;p&gt;The traditional or textbook approach for finding an (s, S) inventory policy is to take a demand&#xA;distribution as given and then find a reorder point s and order up to point S that are optimal for&#xA;this demand distribution. In contrast, the deterministic (s, S) inventory problem is to directly determine the (s, S) pair that would have been optimal for the original demand stream, bypassing the distribution fitting step. The deterministic (s, S) inventory problem thus chooses parameters s and S which minimize setup, holding and backorder costs when the corresponding (s, S) policy is implemented over n periods with known demands d1, d2, . . ., d,,. Our contributions are two: (a) a polynomial time algorithm for finding an optimal (s, S) for the deterministic problem, and (b) an empirical comparison of the two approaches. In (b) we compare the long&#xA;term average costs of the two approaches as a function of the amount of data available, distributional&#xA;assumptions, and order lead time.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-08-05T12:44:39.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8835" PostTypeId="1" CreationDate="2022-08-05T15:42:18.497" Score="2" ViewCount="97" Body="&lt;p&gt;I am trying to simulate a supply chain scenario. Demand is random (e.g. between 100-400 units) and lead time vary 2 to 4 days for each supply. The holding cost(h), penalty cost (p) for lost_sales, fixed costs (f) for each order, and per unit purchase cost (z) are given. My goal is to minimize the cost and fulfill the service/demand (like.. order a quantity S when dropped to R) for each period (say 365 days is time horizon).&lt;/p&gt;&#xA;&lt;p&gt;In the code, I am computing the &amp;quot;cost&amp;quot; before I find the order quantity and I was unable to fix it. Additionally, I think I am overlooking some conditions that I believe ought to be there. Please be advised that I am an undergrad level and taking a course on it.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;library(ks)&#xA;library(rgl)&#xA;library(xtable)&#xA;rm(list=ls())&#xA;&#xA;d1 = read.csv(&amp;quot;C:/Users/Data.csv&amp;quot;, header = T)&#xA;d2 = read.csv(&amp;quot;C:/Users/Lead.csv&amp;quot;, header = T)&#xA;&#xA;#Expected cost for &#xA;ExpectedCost = function(S,R,D,L){&#xA;  h = 10.01&#xA;  f = 120&#xA;  z = 60&#xA;  p = 75&#xA;  cost = 0&#xA;  lost_sales = 0&#xA;  Inventory = S&#xA;  Order = FALSE&#xA;  Lead = 0&#xA;  OrderNumber = 0&#xA;  CummInventory = 0&#xA; &#xA;  InventoryProfile &amp;lt;- c()&#xA;  &#xA;  for(i in 1:length(D)){&#xA;    if((Order == TRUE) &amp;amp; (Lead &amp;gt; 0)){&#xA;      Lead = Lead - 1&#xA;    }&#xA;    &#xA;    if((Order == TRUE) &amp;amp; (Lead == 0)){&#xA;      Inventory = Inventory + S&#xA;      Order = FALSE&#xA;    }&#xA;    &#xA;    if(Inventory &amp;gt;= D[i]){&#xA;      Inventory = Inventory - D[i]&#xA;    }&#xA;    else if((Inventory &amp;gt;= 0) &amp;amp; (Inventory &amp;lt; D[i])){&#xA;      Inventory = Inventory - Inventory&#xA;      lost_sales = lost_sales + (D[i] - Inventory)&#xA;    }&#xA;    else{&#xA;      Inventory = 0&#xA;    }&#xA;    &#xA;    if((Inventory &amp;lt;= R) &amp;amp; (Order == FALSE)){&#xA;      Order = TRUE&#xA;     Lead = sample(L, size = 1, replace = TRUE)&#xA;      OrderNumber = OrderNumber + 1&#xA;    }&#xA;    &#xA;    CummInventory = CummInventory + Inventory&#xA;    InventoryProfile &amp;lt;- c(InventoryProfile, Inventory)&#xA;    InventoryProfile&#xA;  }&#xA;  cost = CummInventory*h + f*OrderNumber + z*S + p*lost_sales&#xA;  Service = (sum(D) - lost_sales)/sum(D)&#xA;  &#xA;  return(list(COST=cost, SERVICE = Service, INVENTORY = InventoryProfile))&#xA;}&#xA;&#xA;#Create vectors for s and S&#xA;S = seq(500, 12000, 300) &#xA;R = seq(100, 6500, 100)&#xA;&#xA;Cost = matrix(nrow=length(S), ncol=length(R))&#xA;Service = matrix(nrow=length(S), ncol=length(R))&#xA;&#xA;#Bootstrapping&#xA;for(i in 1:length(S)){&#xA;  for(j in 1:length(R)){&#xA;    Output = ExpectedCost(S[i], R[j], d1&lt;span class=&quot;math-container&quot;&gt;$Demand, d2$&lt;/span&gt;Lead)&#xA;    Cost[i,j] = Output&lt;span class=&quot;math-container&quot;&gt;$COST&#xA;    Service[i,j] = Output$&lt;/span&gt;SERVICE&#xA;  }&#xA;}&#xA;&#xA;Index1 = which(Service == 1, arr.ind = T)&#xA;Index2 = which(Cost == min(Cost[Index1]), arr.ind = T)&#xA;&#xA;#Optimal (S,R) policy&#xA;S[Index2[1,1]]&#xA;R[Index2[1,2]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;N:B: I am just trying to implement a similar code to serve my purpose.&lt;/p&gt;&#xA;" OwnerUserId="10127" LastEditorUserId="491" LastEditDate="2022-12-09T13:01:21.333" LastActivityDate="2022-12-09T13:01:21.333" Title="Supply chain simulation is not working. Any help please?" Tags="|optimization|r|simulation|supply-chain|demand-distribution|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8836" PostTypeId="2" ParentId="8833" CreationDate="2022-08-05T15:43:20.713" Score="4" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; be the set of available persons (you can set this value to an upper bound, e.g. 6 in your case),and  &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; be the set of jobs. &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is the set of shifts. &lt;span class=&quot;math-container&quot;&gt;$R_j$&lt;/span&gt; is the amount of hours a job needs to be finished. The parameter &lt;span class=&quot;math-container&quot;&gt;$Y_{sj}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if shift &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; contains job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;DECISION VARIABLES&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ijs}$&lt;/span&gt; Amount of hours person &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; spend on job &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt; in shift &lt;span class=&quot;math-container&quot;&gt;$s \in S$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u_{is}$&lt;/span&gt; Binary variable: &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if person &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt; is working in shift &lt;span class=&quot;math-container&quot;&gt;$s \in S$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if not.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Linear Program&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\&#xA;&amp;amp; \min z = \sum_{i \in I}\sum_{s \in S} u_{is}  \; \\&#xA;\textit{S.t.}\\&#xA;\\&#xA;&amp;amp; \sum_{j \in J}\sum_{s \in S}  x_{ijs} \leq 1 &amp;amp; \forall i \in I \tag1\\ &#xA;&amp;amp; \sum_{j \in J}  x_{ijs} \leq u_{is} &amp;amp; \forall s \in S ,i \in I \tag2\\ &#xA;&amp;amp; \sum_{s \in S}  u_{is} \leq 1 &amp;amp; \forall i \in I \tag3\\ &#xA;&amp;amp; \sum_{i \in I}\sum_{s \in S}  x_{ijs} \geq R_j &amp;amp; \forall j \in J \tag4\\ &#xA;&amp;amp; \sum_{i \in I}  x_{ijs} \leq Y_{sj} &amp;amp; \forall j \in J, s \in S \tag5\\ &#xA;&amp;amp;   x_{ijs} \geq 0 &amp;amp; \forall i \in I, j \in J, s \in S \tag6\\&#xA;&amp;amp;   u_{is} \in \{0,1 \} &amp;amp; \forall i \in I, s \in S \tag7&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective is to limit the number of persons working. Constraint (1) states that every person cannot work more than one hour (delete it if this constraint is not needed). Constraint (2) states that if any job is performed by person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in shift &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, then the person must be assigned to that shift, i.e. &lt;span class=&quot;math-container&quot;&gt;$u_{is}$&lt;/span&gt; must be 1 (multiply &lt;span class=&quot;math-container&quot;&gt;$u_{is}$&lt;/span&gt; by big constant M in case a person can work more than one hour). Constraint (3) states that each person is assigned to a maximum of one shift. Constraint (4) states that the requirement of a job in terms of working hours needs to be met. Constraint (5) states that if a job is not in a shift, i.e. &lt;span class=&quot;math-container&quot;&gt;$Y_{sj}=0$&lt;/span&gt;, no person can be assigned to fulfill this shift/job combination.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="67" LastEditDate="2022-08-05T15:56:04.807" LastActivityDate="2022-08-05T15:56:04.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8837" PostTypeId="1" AcceptedAnswerId="8846" CreationDate="2022-08-06T07:31:12.473" Score="1" ViewCount="146" Body="&lt;p&gt;I do want to formulate a fleet assignment problem. The following table is available&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/c6Lm7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/c6Lm7.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It shows the departure/arrival location and time&lt;/p&gt;&#xA;&lt;p&gt;I am trying to find the min number of required planes to assign to each route.&lt;/p&gt;&#xA;&lt;p&gt;I first visualised the table to get some Idea&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6OUsK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6OUsK.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I formulate it as a MILP ?&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="491" LastEditDate="2022-08-09T02:56:26.277" LastActivityDate="2022-08-09T02:56:26.277" Title="How to formulate fleet Assignment Problem?" Tags="|optimization|mixed-integer-programming|scheduling|assignment-problem|job-shop-scheduling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8838" PostTypeId="2" ParentId="8833" CreationDate="2022-08-06T08:31:57.130" Score="0" Body="&lt;p&gt;There are two things that should be taken into account in your problem. First, the number of staff/resources, and the second the compilation time of all tasks. (The second one already can be changed to other objects, but in this case, I am assuming this). The mentioned problem can be formulated as a parallel machine scheduling problem for which the preemption would be allowed.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\&#xA;&amp;amp; \text{Minimize} \quad z = C_{max}  \; \\&#xA;&amp;amp; \textit{S.t.}\\&#xA;\\&#xA;&amp;amp; \sum_{i \in I}  x_{ij} = 1 &amp;amp; \forall j \in J \tag1\\ &#xA;&amp;amp; \sum_{i \in I}  p_{j}x_{ij} \leq C_{max} &amp;amp; \forall j \in J \tag2\\ &#xA;&amp;amp; \sum_{j \in J}  p_{j}x_{ij} \leq C_{max} &amp;amp; \forall i \in I \tag3\\  &#xA;&amp;amp;   x_{ij} \geq 0 &amp;amp; \forall i \in I, j \in J \tag4\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; represents the total time task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; spends on resource &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$p_{j}$&lt;/span&gt; is the processing time of task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_{max}$&lt;/span&gt; is Makespan. In this case, you can analyze how many resources are actually needed to minimize &lt;span class=&quot;math-container&quot;&gt;$C_{max}$&lt;/span&gt; to make the optimal sequence.&lt;/p&gt;&#xA;&lt;p&gt;For example, with the above data and assuming &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; resources in the first scenario, the Makespan would be &lt;span class=&quot;math-container&quot;&gt;$83$&lt;/span&gt; and within &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; resources it is around &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt;. Also, the optimal sequence for the first scenario is as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;----     41 VARIABLE x.L  the total time task j spends on resource i&#xA;&#xA;            j1          j2          j3          j4          j5          j6&#xA;&#xA;m1                   0.083                   0.095       1.000       1.000&#xA;m2                   0.917       1.000&#xA;m3       1.000                               0.905&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-08-06T08:31:57.130" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8839" PostTypeId="2" ParentId="8799" CreationDate="2022-08-06T16:04:49.570" Score="3" Body="&lt;p&gt;Shifts and swaps are already good neighborhoods for the Generalized Assignment Problems:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Shift: move a task to another worker&lt;/li&gt;&#xA;&lt;li&gt;Swap: swap the workers of two tasks&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Another neighborhood found in some good approaches for the Generalized assignment Problem based on local search is the ejection chain neighborhood.&lt;/p&gt;&#xA;&lt;p&gt;An additional improvement is to reduce the size of the neighborhoods based on lagrangian multipliers.&lt;/p&gt;&#xA;&lt;p&gt;For more details about these components, you can look at the following article:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Yagiura M, Ibaraki T, Glover F (2006) A path relinking approach with ejection chains for the generalized assignment problem. European Journal of Operational Research 169:548–569. &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2004.08.015&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.ejor.2004.08.015&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note that a &amp;quot;raw&amp;quot; GRASP scheme is not likely to work very well for the Generalized Assignment Problem since finding a good solution requires a lot of moves and requires to often get out of local optima. If a full restart is performed at the first local optimum found, the initial solution might not have improved enough&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-08-06T16:04:49.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8840" PostTypeId="1" CreationDate="2022-08-06T21:49:36.287" Score="3" ViewCount="85" Body="&lt;p&gt;I would like to obtain the number of the variable cplex branches on at the current node during B&amp;amp;B.&lt;/p&gt;&#xA;&lt;p&gt;I try this by using the callback&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;status = CPXXgetcallbacknodeinfo (env,cbdata,wherefrom,0,CPX_CALLBACK_INFO_NODE_VAR, &amp;amp;bvar) ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;bvar is supposed to hold the id of the branching variable. The statement fails as the returned value of bvar is not the correct one.&lt;/p&gt;&#xA;&lt;p&gt;Could anyone indicate what I am doing wrong?  For experimenting, I am using the code of the CPLEX example xadmipex1.c&lt;/p&gt;&#xA;" OwnerUserId="10130" LastActivityDate="2022-08-06T21:49:36.287" Title="cplex callbacks: getting the branching variable" Tags="|cplex|callback|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8841" PostTypeId="1" CreationDate="2022-08-07T04:55:06.347" Score="2" ViewCount="365" Body="&lt;p&gt;CPLEX settings&lt;/p&gt;&#xA;&lt;p&gt;LPMethod: Barrier&lt;/p&gt;&#xA;&lt;p&gt;Threads: 4&lt;/p&gt;&#xA;&lt;p&gt;Issue:&#xA;When I run my model, the barrier method will solve using the 4 threads (as expected). I noticed in the log file that the solver then follows up with its &amp;quot;deterministic&amp;quot; parallel mode in which it will start dual simplex and primal simplex but only use 1 thread for each. It is in this stage that my model run times start to grow exponentially w/ longer time periods.&lt;/p&gt;&#xA;&lt;p&gt;I have done a little bit of reading and understand that &amp;quot;deterministic&amp;quot; is the default setting for parallel mode (i.e. this is expected behavior).&lt;/p&gt;&#xA;&lt;p&gt;Question(s):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there a way to specify more threads than 1 when parallel mode kicks in? If so how?&lt;/li&gt;&#xA;&lt;li&gt;Can I remove deterministic parallel execution model all together if I accept the final results varying slightly from 1 run to another?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10131" LastEditorUserId="491" LastEditDate="2022-08-07T16:32:59.663" LastActivityDate="2022-08-07T17:52:23.890" Title="CPLEX solver, parallelism, solver parameter settings" Tags="|cplex|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8842" PostTypeId="2" ParentId="8841" CreationDate="2022-08-07T17:52:23.890" Score="2" Body="&lt;p&gt;I think there are several things to distinguish here: concurrent LP algorithms (e.g. running barrier and simplex in parallel), deterministic vs opportunistic, and crossover (which happens after barrier). Note they are controlled by different parameters.&lt;/p&gt;&#xA;&lt;p&gt;First the concurrent part, which mean &amp;quot;run multiple algorithms in parallel&amp;quot;.&#xA;If you give CPLEX an LP to solve and multiple threads, there are several strategies CPLEX can use, see &lt;a href=&quot;https://www.ibm.com/docs/en/icos/22.1.0?topic=parameters-algorithm-continuous-linear-problems&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/22.1.0?topic=parameters-algorithm-continuous-linear-problems&lt;/a&gt;.&#xA;The original post indicates &amp;quot;LPMethod: Barrier&amp;quot;, so I assume there is no simplex vs barrier running concurrently, i.e., only the barrier algorithm is executed and it uses all available threads (in your case, 4).&lt;/p&gt;&#xA;&lt;p&gt;Second, the deterministic vs opportunistic mode. This distinction exists because, as parallelism is involved, things may not be deterministic anymore, i.e., you may run the same problem on the same machine with identical settings, and get a different answer. In particular, it only makes sense when multiple algorithms are executed concurrently.&#xA;From the &lt;a href=&quot;https://www.ibm.com/docs/en/icos/22.1.0?topic=parameters-parallel-mode-switch&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPLEX docs&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;deterministic means that multiple runs with the same model at the same parameter settings on the same platform will reproduce the same solution path and results. In contrast, opportunistic implies that even slight differences in timing among threads or in the order in which tasks are executed in different threads may produce a different solution path and consequently different timings or different solution vectors during optimization executed in parallel threads. In multithreaded applications, the opportunistic setting entails less synchronization between threads and consequently may provide better performance.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Finally, crossover. This is the step of taking an interior-point solution and polishing it into a basic solution. AFAIK, CPLEX applies crossover by default.&#xA;While I cannot say for sure without seeing your exact CPLEX log, I believe what you describe is the crossover: after the barrier algorithm, CPLEX will execute a primal and/or dual simplex to perform crossover. This step is single-threaded, because simplex algorithms are single-threaded&#xA;If you're only solving an LP, and do not need a basic solution, you can switch it off; see &lt;a href=&quot;https://www.ibm.com/docs/en/icos/22.1.0?topic=parameters-barrier-crossover-algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPLEX docs&lt;/a&gt; on how to do that.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2022-08-07T17:52:23.890" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8843" PostTypeId="1" CreationDate="2022-08-08T06:31:27.340" Score="3" ViewCount="242" Body="&lt;p&gt;Can somebody help me with Localsolver? I have installed the academic license and want to solve Split Delivery VRP. I'm using the same model as seen in the website &lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/split-delivery-vehicle-routing-problem-sdvrp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and using the same instances too (I'm using S51D4). But, why is the gap is always 100% when running?&lt;/p&gt;&#xA;&lt;p&gt;Is there something wrong with my machine or installation perhaps? I'm running it on Intel i5 7th on 8GB RAM.&lt;/p&gt;&#xA;&lt;p&gt;Here is the log with a 10 minute time limit.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;LocalSolver 11.0.20220721-Win64. All rights reserved.&#xA;Load sdvrp.lsp...&#xA;Run input...&#xA;Run model...&#xA;Run param...&#xA;Run solver...&#xA;&#xA;Model:  expressions = 13905, decisions = 2550, constraints = 101, objectives = 1&#xA;Param:  time limit = 360 sec, no iteration limit&#xA;&#xA;[objective direction ]:     minimize&#xA;&#xA;[  0 sec,       0 itr]: No feasible solution found (infeas = 51)&#xA;[  1 sec,   39085 itr]:         2445&#xA;[  2 sec,  133145 itr]:         1929&#xA;[  3 sec,  232519 itr]:         1833&#xA;[  4 sec,  318825 itr]:         1784&#xA;[  5 sec,  393069 itr]:         1764&#xA;[  6 sec,  464380 itr]:         1761&#xA;[  7 sec,  535342 itr]:         1755&#xA;[  8 sec,  607587 itr]:         1747&#xA;[  9 sec,  680000 itr]:         1732&#xA;[ 10 sec,  749683 itr]:         1728&#xA;[ optimality gap     ]:      100.00%&#xA;[ 11 sec,  822365 itr]:         1727&#xA;[ 12 sec,  885106 itr]:         1708&#xA;[ 13 sec,  928483 itr]:         1708&#xA;[ 14 sec,  982151 itr]:         1708&#xA;[ 15 sec, 1034334 itr]:         1707&#xA;[ 16 sec, 1079856 itr]:         1707&#xA;[ 17 sec, 1132541 itr]:         1695&#xA;[ 18 sec, 1200000 itr]:         1695&#xA;[ 19 sec, 1274687 itr]:         1695&#xA;[ 20 sec, 1274687 itr]:         1695&#xA;[ optimality gap     ]:      100.00%&#xA;[ 21 sec, 1338878 itr]:         1695&#xA;[ 22 sec, 1466325 itr]:         1695&#xA;[ 23 sec, 1529968 itr]:         1695&#xA;[ 24 sec, 1599581 itr]:         1689&#xA;[ 25 sec, 1640000 itr]:         1686&#xA;[ 26 sec, 1688389 itr]:         1686&#xA;[ 27 sec, 1759810 itr]:         1682&#xA;[ 28 sec, 1759810 itr]:         1682&#xA;[ 29 sec, 1880854 itr]:         1682&#xA;[ 30 sec, 1880854 itr]:         1682&#xA;[ optimality gap     ]:      100.00%&#xA;[ 31 sec, 1999512 itr]:         1682&#xA;[ 32 sec, 2039631 itr]:         1678&#xA;[ 33 sec, 2085455 itr]:         1678&#xA;[ 34 sec, 2143392 itr]:         1678&#xA;[ 35 sec, 2143392 itr]:         1672&#xA;[ 36 sec, 2275360 itr]:         1672&#xA;[ 37 sec, 2336860 itr]:         1672&#xA;[ 38 sec, 2406899 itr]:         1672&#xA;[ 39 sec, 2480000 itr]:         1672&#xA;[ 40 sec, 2547043 itr]:         1672&#xA;[ optimality gap     ]:      100.00%&#xA;[ 41 sec, 2547043 itr]:         1672&#xA;[ 42 sec, 2680000 itr]:         1672&#xA;[ 43 sec, 2747689 itr]:         1672&#xA;...&#xA;[ optimality gap      ]:      100.00%&#xA;[311 sec, 19858963 itr]:         1603&#xA;[312 sec, 19926467 itr]:         1603&#xA;[313 sec, 19976892 itr]:         1603&#xA;[314 sec, 20041597 itr]:         1603&#xA;[315 sec, 20113488 itr]:         1603&#xA;[316 sec, 20148399 itr]:         1603&#xA;[317 sec, 20148399 itr]:         1603&#xA;[318 sec, 20240000 itr]:         1603&#xA;[319 sec, 20280000 itr]:         1603&#xA;[320 sec, 20314286 itr]:         1603&#xA;[ optimality gap      ]:      100.00%&#xA;[321 sec, 20356044 itr]:         1603&#xA;[322 sec, 20400000 itr]:         1603&#xA;[323 sec, 20438525 itr]:         1603&#xA;[324 sec, 20438525 itr]:         1603&#xA;[325 sec, 20481118 itr]:         1603&#xA;[326 sec, 20589307 itr]:         1603&#xA;[327 sec, 20633734 itr]:         1603&#xA;[328 sec, 20680000 itr]:         1603&#xA;[329 sec, 20720000 itr]:         1603&#xA;[330 sec, 20794236 itr]:         1603&#xA;[ optimality gap      ]:      100.00%&#xA;[331 sec, 20852580 itr]:         1603&#xA;[332 sec, 20901515 itr]:         1602&#xA;[333 sec, 20966356 itr]:         1602&#xA;[334 sec, 21024270 itr]:         1601&#xA;[335 sec, 21092709 itr]:         1601&#xA;[336 sec, 21147857 itr]:         1601&#xA;[337 sec, 21210912 itr]:         1601&#xA;[338 sec, 21263487 itr]:         1601&#xA;[339 sec, 21337642 itr]:         1601&#xA;[340 sec, 21409656 itr]:         1601&#xA;[ optimality gap      ]:      100.00%&#xA;[341 sec, 21479419 itr]:         1601&#xA;[342 sec, 21548873 itr]:         1601&#xA;[343 sec, 21601571 itr]:         1601&#xA;[344 sec, 21601571 itr]:         1601&#xA;[345 sec, 21756027 itr]:         1601&#xA;[346 sec, 21833407 itr]:         1601&#xA;[347 sec, 21909596 itr]:         1601&#xA;[348 sec, 21986893 itr]:         1601&#xA;[349 sec, 22065020 itr]:         1601&#xA;[350 sec, 22129717 itr]:         1601&#xA;[ optimality gap      ]:      100.00%&#xA;[351 sec, 22196673 itr]:         1601&#xA;[352 sec, 22196673 itr]:         1601&#xA;[353 sec, 22314615 itr]:         1601&#xA;[354 sec, 22373794 itr]:         1599&#xA;[355 sec, 22373794 itr]:         1599&#xA;[356 sec, 22440000 itr]:         1599&#xA;[357 sec, 22558681 itr]:         1599&#xA;[358 sec, 22558681 itr]:         1599&#xA;[359 sec, 22700231 itr]:         1599&#xA;[360 sec, 22767261 itr]:         1599&#xA;[ optimality gap      ]:      100.00%&#xA;[360 sec, 22767261 itr]:         1599&#xA;[ optimality gap      ]:      100.00%&#xA;&#xA;22767261 iterations performed in 360 seconds&#xA;&#xA;Feasible solution:&#xA;  obj    =         1599&#xA;  gap    =      100.00%&#xA;  bounds =            0&#xA;&#xA;Run output...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10000" LastEditorUserId="491" LastEditDate="2022-08-10T17:21:12.653" LastActivityDate="2024-04-04T04:11:24.410" Title="LocalSolver at 100% Gap" Tags="|solver|vehicle-routing|heuristics|optimality-gap|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8844" PostTypeId="1" CreationDate="2022-08-08T07:53:58.053" Score="3" ViewCount="50" Body="&lt;p&gt;How can we be sure that confounding variables/control variables don’t pickup the effect our decisions w.r.t decision variables had on the actual control variable?&lt;/p&gt;&#xA;&lt;p&gt;Since the term control variable overlap in regression and control theory I want to make it clear that I use the term “control variable” when I refer to an variable aiming to pick up confounding effects that we don’t want to pick up in our decision variables. Decision variables then being the variables that we can control in our optimization scenario.&lt;/p&gt;&#xA;&lt;p&gt;Consider the resource allocation problem where we want to allocate an portion of the total resource B to two investment options every day over an finite horizon H.&lt;/p&gt;&#xA;&lt;p&gt;Consider this reward function&#xA;&lt;span class=&quot;math-container&quot;&gt;$Y_{t} = intercept + c_{1} * x_{1t} + c_{2} * x_{2t} + c_{3} * trend_{t}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$Y_{t}$&lt;/span&gt; is sales at timestep &lt;span class=&quot;math-container&quot;&gt;${t}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{1t}$&lt;/span&gt; is budget for investmentoption 1 at timestep t, &lt;span class=&quot;math-container&quot;&gt;$x_{2t}$&lt;/span&gt; is budget for investmentoption 2 at timestep t.&#xA;&lt;span class=&quot;math-container&quot;&gt;$Trend_{t}$&lt;/span&gt; is the trend at timestep t and have been fitted on the datasets historical sales data by using fourier decomposition.&#xA;The trend variable is thought of as capturing the underlying market trend that we cannot control for.&lt;/p&gt;&#xA;&lt;p&gt;Consider the following algorithm:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Fit our reward function to the historical data by performing OLS.&lt;/li&gt;&#xA;&lt;li&gt;Maximize the reward function over the whole horizon s.t to constraints.&lt;/li&gt;&#xA;&lt;li&gt;Set the allocation for the current timestep.&lt;/li&gt;&#xA;&lt;li&gt;See the reward for the current timestep.&lt;/li&gt;&#xA;&lt;li&gt;Add the allocation and reward to our dataset.&lt;/li&gt;&#xA;&lt;li&gt;Repeat step 1.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Consider the horizon 30. Meaning that we optimize for one month.&lt;/p&gt;&#xA;&lt;p&gt;Now if I start to optimize this, the actual trend might change, hopefully the sales will start increasing... now, how can I be sure that this change is reflected in our decision variable coefficients and not our trend variable.&#xA;Two interesting scenarios is when we leave c1 as it is, a timeinvariant coefficient and if we don’t, let’s say we fit it such that we aim to capture day in month effects on our decision variables thereby letting the algorithm optimize also w.r.t day of month.&lt;/p&gt;&#xA;&lt;p&gt;I am thinking if this would impose a problem or if im missing out on something. Seems like it should be a quite normal problem in stochastic programming/reinforcement learning/model predictive control.. basically any sequential decision problem where we have a predefinied model with both decision variables and variables that aim to control confounding effects.&lt;/p&gt;&#xA;&lt;p&gt;To check if this would impose a problem I assume we could check the variance inflation factor and correlation between the trend variable and our decision variables?&lt;/p&gt;&#xA;&lt;p&gt;But what is the actual solution to the problem?&lt;/p&gt;&#xA;&lt;p&gt;Maybe fit the trend component to our historic data and then when we roll out the algorithm, we solely extrapolate the trend we saw before we started the algorithm?&lt;/p&gt;&#xA;" OwnerUserId="10138" LastEditorUserId="10138" LastEditDate="2022-08-08T08:21:22.320" LastActivityDate="2022-08-08T08:21:22.320" Title="Control variables and cofounding effects in stochastic programming/,model predictive control/reinforcement learning" Tags="|optimization|stochastic-programming|dynamic-programming|optimal-control|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8845" PostTypeId="1" AcceptedAnswerId="8847" CreationDate="2022-08-08T11:28:53.487" Score="3" ViewCount="312" Body="&lt;p&gt;The problem I'm trying to solve is a modification of the &lt;a href=&quot;https://developers.google.com/optimization/scheduling/job_shop#example&quot; rel=&quot;nofollow noreferrer&quot;&gt;original Jobshop problem&lt;/a&gt;. The additional constraints are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There is only one machine for all jobs and their tasks.&lt;/li&gt;&#xA;&lt;li&gt;Each job has a priority (integer value, greater value means greater priority). Tasks of a higher-priority job should be considered first.&lt;/li&gt;&#xA;&lt;li&gt;Tasks of a given job have same duration, for example: job_1 has 3 tasks and all of its tasks have duration of 5; job_2 has 2 tasks and all of its tasks have duration of 7, etc.&lt;/li&gt;&#xA;&lt;li&gt;Each job has time windows (integer values), within which its tasks must be scheduled, for example: 0 - 10, 5 - 30, etc. Windows timestamps of all jobs may overlap.&lt;/li&gt;&#xA;&lt;li&gt;All tasks are optional, this means that if there is no space for job's task within given job's window, algorithm should consider another window of the given job (if another window is present) and try to schedule this task within that another window.&lt;/li&gt;&#xA;&lt;li&gt;Tasks of all jobs must not overlap (machine can process only one task at a time).&lt;/li&gt;&#xA;&lt;li&gt;There must be a gap between tasks of each job (integer value; gap size depends on the job). Tasks of other jobs may be scheduled within this gap if it has enough space for them.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The objective is to schedule as many tasks of higher-priority jobs as possible.&#xA;The problem I cannot cope with is that tasks do not have gaps between them. The reason for this IMO is that tasks are not always scheduled successively, because I define constraints only between successive tasks. For example: currently, the constraint formula for gaps between each task is defined like this: &lt;code&gt;job_tasks[taskID + 1].start &amp;gt;= job_tasks[taskID].end + jobs_gaps[jobID]&lt;/code&gt;. This would work if the tasks are scheduled successively: &lt;code&gt;task_1 -&amp;gt; task_2 -&amp;gt; task_3&lt;/code&gt;. But if tasks are scheduled not successively, say: &lt;code&gt;task_1 -&amp;gt; task_3 -&amp;gt; task_2&lt;/code&gt;, then the constraints are not forced between pairs &lt;code&gt;task_1 -&amp;gt; task_3&lt;/code&gt; and &lt;code&gt;task_3 -&amp;gt; task_2&lt;/code&gt; because they only apply to the &lt;em&gt;neighboring&lt;/em&gt; tasks, according to the formula.&lt;/p&gt;&#xA;&lt;p&gt;I also use 3D array &lt;code&gt;x&lt;/code&gt; to indicate that task with &lt;code&gt;taskID&lt;/code&gt; of job with &lt;code&gt;jobID&lt;/code&gt; is scheduled within window of &lt;code&gt;windowID&lt;/code&gt;; this idea is taken from &lt;a href=&quot;https://developers.google.com/optimization/bin/multiple_knapsack#example&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multiple Knapsack problem&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The full program code is shown below:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-java prettyprint-override&quot;&gt;&lt;code&gt;public class MinimalJobshopSat {&#xA;    public static void main(String[] args) {&#xA;        Loader.loadNativeLibraries();&#xA;        // [START data]&#xA;        class Task {&#xA;            int duration;&#xA;&#xA;            public Task(int duration) {&#xA;                this.duration = duration;&#xA;            }&#xA;        }&#xA;        class TaskType {&#xA;            IntVar start;&#xA;            IntVar end;&#xA;            IntervalVar interval;&#xA;        }&#xA;&#xA;        final List&amp;lt;List&amp;lt;Task&amp;gt;&amp;gt; allJobs = Arrays.asList(&#xA;                Arrays.asList(new Task(3), new Task(3), new Task(3), new Task(3)), // Job0&#xA;                Arrays.asList(new Task(5), new Task(5), new Task(5), new Task(5)), // Job1&#xA;                Arrays.asList(new Task(10), new Task(10),new Task(10), new Task(10)) // Job2&#xA;        );&#xA;&#xA;        final int[] priorities = {9, 5, 3};&#xA;&#xA;        int numMachines = 1;&#xA;        final int[] allMachines = IntStream.range(0, numMachines).toArray();&#xA;&#xA;        int horizon = 1_000_000;&#xA;&#xA;        final int[][] windowsStarts = {&#xA;                {0, 30}, // windows starts for job 0&#xA;                {50}, // windows starts for job 1&#xA;                {100}&#xA;        };&#xA;        final int[][] windowsEnds = {&#xA;                {20, 40}, // windows ends for job 0&#xA;                {70}, // windows ends for job 1&#xA;                {120}&#xA;        };&#xA;        final int[] jobsBuffers = {5, 10, 15};&#xA;        // [END data]&#xA;&#xA;        // Creates the model.&#xA;        // [START model]&#xA;        CpModel model = new CpModel();&#xA;        // [END model]&#xA;&#xA;        // [START variables]&#xA;        Map&amp;lt;List&amp;lt;Integer&amp;gt;, TaskType&amp;gt; allTasks = new HashMap&amp;lt;&amp;gt;();&#xA;        List&amp;lt;IntervalVar&amp;gt; machineIntervals = new ArrayList&amp;lt;&amp;gt;();&#xA;&#xA;//        x[jobID][taskID][windowID] = 1 if task with 'taskID' of a job with 'jobID' is assigned to a window with 'windowID'&#xA;        List&amp;lt;List&amp;lt;List&amp;lt;Literal&amp;gt;&amp;gt;&amp;gt; x = new ArrayList&amp;lt;&amp;gt;();&#xA;        for (int jobID = 0; jobID &amp;lt; allJobs.size(); ++jobID) { // for each job&#xA;            final List&amp;lt;List&amp;lt;Literal&amp;gt;&amp;gt; jobLiterals = new ArrayList&amp;lt;&amp;gt;();&#xA;&#xA;            for (int taskID = 0; taskID &amp;lt; allJobs.get(jobID).size(); ++taskID) { // for each job's task&#xA;                final List&amp;lt;Literal&amp;gt; taskLiterals = new ArrayList&amp;lt;&amp;gt;();&#xA;&#xA;                for (int windowID = 0; windowID &amp;lt; windowsStarts[jobID].length; ++windowID) { // for each job's window&#xA;                    taskLiterals.add(model.newBoolVar(&amp;quot;x_&amp;quot; + jobID + &amp;quot;_&amp;quot; + taskID + &amp;quot;_&amp;quot; + windowID));&#xA;                }&#xA;&#xA;                jobLiterals.add(taskLiterals);&#xA;            }&#xA;&#xA;            x.add(jobLiterals);&#xA;        }&#xA;&#xA;        for (int jobID = 0; jobID &amp;lt; allJobs.size(); ++jobID) {&#xA;            List&amp;lt;Task&amp;gt; job = allJobs.get(jobID);&#xA;            final int firstWindowStart = Arrays.stream(windowsStarts[jobID]).min().getAsInt(); // job's makespan start&#xA;            final int lastWindowEnd = Arrays.stream(windowsEnds[jobID]).max().getAsInt(); // job's makespan end&#xA;&#xA;            for (int taskID = 0; taskID &amp;lt; job.size(); ++taskID) {&#xA;                Task task = job.get(taskID);&#xA;                TaskType taskType = new TaskType();&#xA;&#xA;                for (int windowID = 0; windowID &amp;lt; windowsStarts[jobID].length; ++windowID) {&#xA;                    String suffix = &amp;quot;_&amp;quot; + jobID + &amp;quot;_&amp;quot; + taskID + &amp;quot;_&amp;quot; + windowID;&#xA;&#xA;                    Literal literal = x.get(jobID).get(taskID).get(windowID);&#xA;                    taskType.start = model.newIntVar(firstWindowStart, lastWindowEnd, &amp;quot;start&amp;quot; + suffix);&#xA;                    taskType.end = model.newIntVar(firstWindowStart, lastWindowEnd, &amp;quot;end&amp;quot; + suffix);&#xA;                    taskType.interval = model.newOptionalIntervalVar(&#xA;                            taskType.start,&#xA;                            model.newConstant(task.duration),&#xA;                            taskType.end,&#xA;                            literal,&#xA;                            &amp;quot;interval&amp;quot; + suffix&#xA;                    );&#xA;&#xA;//                    task must be within window if x[jobID][taskID][windowID] is true&#xA;                    model.addGreaterOrEqual(taskType.start, model.newConstant(windowsStarts[jobID][windowID])).onlyEnforceIf(literal);&#xA;                    model.addLessOrEqual(taskType.end, model.newConstant(windowsEnds[jobID][windowID])).onlyEnforceIf(literal);&#xA;&#xA;                    List&amp;lt;Integer&amp;gt; key = Arrays.asList(jobID, taskID, windowID);&#xA;                    allTasks.put(key, taskType);&#xA;                    machineIntervals.add(taskType.interval);&#xA;                }&#xA;&#xA;            }&#xA;        }&#xA;        // [END variables]&#xA;&#xA;        // [START constraints]&#xA;        // Create and add disjunctive constraints. Tasks of all jobs must not overlap.&#xA;        model.addNoOverlap(machineIntervals);&#xA;&#xA;        // Precedences inside a job.&#xA;        for (int jobID = 0; jobID &amp;lt; allJobs.size(); ++jobID) {&#xA;            List&amp;lt;Task&amp;gt; job = allJobs.get(jobID);&#xA;            for (int taskID = 0; taskID &amp;lt; job.size() - 1; ++taskID) {&#xA;                for (int windowID = 0; windowID &amp;lt; windowsStarts[jobID].length; ++windowID) {&#xA;                    List&amp;lt;Integer&amp;gt; prevKey = Arrays.asList(jobID, taskID, windowID);&#xA;                    List&amp;lt;Integer&amp;gt; nextKey = Arrays.asList(jobID, taskID + 1, windowID);&#xA;&#xA;//                Tasks of given job must be successive&#xA;                    model.addGreaterOrEqual(allTasks.get(nextKey).start, LinearExpr.sum(new LinearArgument[] {&#xA;                            allTasks.get(prevKey).end, model.newConstant(jobsBuffers[jobID])&#xA;                    }));&#xA;                }&#xA;&#xA;            }&#xA;        }&#xA;        // [END constraints]&#xA;&#xA;        // [START objective]&#xA;        // Makespan objective.&#xA;        IntVar objVar = model.newIntVar(0, horizon, &amp;quot;makespan&amp;quot;);&#xA;        List&amp;lt;IntVar&amp;gt; ends = new ArrayList&amp;lt;&amp;gt;();&#xA;        for (int jobID = 0; jobID &amp;lt; allJobs.size(); ++jobID) {&#xA;            List&amp;lt;Task&amp;gt; job = allJobs.get(jobID);&#xA;            for (int windowID = 0; windowID &amp;lt; windowsStarts[jobID].length; ++windowID) {&#xA;                List&amp;lt;Integer&amp;gt; key = Arrays.asList(jobID, job.size() - 1, windowID);&#xA;                ends.add(allTasks.get(key).end);&#xA;            }&#xA;        }&#xA;        model.addMaxEquality(objVar, ends);&#xA;        model.minimize(objVar);&#xA;        // [END objective]&#xA;&#xA;        // Creates a solver and solves the model.&#xA;        // [START solve]&#xA;        CpSolver solver = new CpSolver();&#xA;        CpSolverStatus status = solver.solve(model);&#xA;        // [END solve]&#xA;&#xA;        // [START print_solution]&#xA;        if (status == CpSolverStatus.OPTIMAL || status == CpSolverStatus.FEASIBLE) {&#xA;            class AssignedTask {&#xA;                int jobID;&#xA;                int taskID;&#xA;                int start;&#xA;                int duration;&#xA;                int windowID;&#xA;                // Ctor&#xA;&#xA;                public AssignedTask(int jobID, int taskID, int start, int duration, int windowID) {&#xA;                    this.jobID = jobID;&#xA;                    this.taskID = taskID;&#xA;                    this.start = start;&#xA;                    this.duration = duration;&#xA;                    this.windowID = windowID;&#xA;                }&#xA;            }&#xA;            class SortTasks implements Comparator&amp;lt;AssignedTask&amp;gt; {&#xA;                @Override&#xA;                public int compare(AssignedTask a, AssignedTask b) {&#xA;                    if (a.start != b.start) {&#xA;                        return a.start - b.start;&#xA;                    } else {&#xA;                        return a.duration - b.duration;&#xA;                    }&#xA;                }&#xA;            }&#xA;            System.out.println(&amp;quot;Solution:&amp;quot;);&#xA;            // Create one list of assigned tasks per machine.&#xA;            List&amp;lt;AssignedTask&amp;gt; assignedJobs = new ArrayList&amp;lt;&amp;gt;();&#xA;            for (int jobID = 0; jobID &amp;lt; allJobs.size(); ++jobID) {&#xA;                List&amp;lt;Task&amp;gt; job = allJobs.get(jobID);&#xA;                for (int taskID = 0; taskID &amp;lt; job.size(); ++taskID) {&#xA;                    Task task = job.get(taskID);&#xA;&#xA;                    for (int windowID = 0; windowID &amp;lt; windowsStarts[jobID].length; ++windowID) {&#xA;                        List&amp;lt;Integer&amp;gt; key = Arrays.asList(jobID, taskID, windowID);&#xA;                        AssignedTask assignedTask = new AssignedTask(&#xA;                                jobID, taskID, (int) solver.value(allTasks.get(key).start), task.duration, windowID);&#xA;                        assignedJobs.add(assignedTask);&#xA;                    }&#xA;                }&#xA;            }&#xA;&#xA;            // Create per machine output lines.&#xA;            String output = &amp;quot;&amp;quot;;&#xA;            for (int machine : allMachines) {&#xA;                // Sort by starting time.&#xA;                Collections.sort(assignedJobs, new SortTasks());&#xA;                String solLineTasks = &amp;quot;Machine &amp;quot; + machine + &amp;quot;: &amp;quot;;&#xA;                String solLine = &amp;quot;           &amp;quot;;&#xA;&#xA;                for (AssignedTask assignedTask : assignedJobs) {&#xA;                    String name = &amp;quot;job_&amp;quot; + assignedTask.jobID + &amp;quot;_task_&amp;quot; + assignedTask.taskID + &amp;quot;_win_&amp;quot; + assignedTask.windowID;&#xA;                    // Add spaces to output to align columns.&#xA;                    solLineTasks += String.format(&amp;quot;%-22s&amp;quot;, name);&#xA;&#xA;                    String solTmp =&#xA;                            &amp;quot;[&amp;quot; + assignedTask.start + &amp;quot;,&amp;quot; + (assignedTask.start + assignedTask.duration) + &amp;quot;]&amp;quot;;&#xA;                    // Add spaces to output to align columns.&#xA;                    solLine += String.format(&amp;quot;%-22s&amp;quot;, solTmp);&#xA;                }&#xA;                output += solLineTasks + &amp;quot;%n&amp;quot;;&#xA;                output += solLine + &amp;quot;%n&amp;quot;;&#xA;            }&#xA;            System.out.printf(&amp;quot;Optimal Schedule Length: %f%n&amp;quot;, solver.objectiveValue());&#xA;            System.out.printf(output);&#xA;        } else {&#xA;            System.out.println(&amp;quot;No solution found.&amp;quot;);&#xA;        }&#xA;        // [END print_solution]&#xA;&#xA;        // Statistics.&#xA;        // [START statistics]&#xA;        System.out.println(&amp;quot;Statistics&amp;quot;);&#xA;        System.out.printf(&amp;quot;  conflicts: %d%n&amp;quot;, solver.numConflicts());&#xA;        System.out.printf(&amp;quot;  branches : %d%n&amp;quot;, solver.numBranches());&#xA;        System.out.printf(&amp;quot;  wall time: %f s%n&amp;quot;, solver.wallTime());&#xA;        // [END statistics]&#xA;    }&#xA;&#xA;    private MinimalJobshopSat() {}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Do you know a way/conception to force tasks to have gaps? Thank you for the answers.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I've updated &lt;code&gt;allTasks&lt;/code&gt; key to also include &lt;code&gt;windowID&lt;/code&gt;, and after that some tasks of jobs started to duplicate for some reason.&lt;/p&gt;&#xA;&lt;p&gt;Cross-reference to the same question:&#xA;&lt;a href=&quot;https://discord.com/channels/693088862481678374/719201939971113001/1005053649543778325&quot; rel=&quot;nofollow noreferrer&quot;&gt;Discord of OR-Tools&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10139" LastEditorUserId="981" LastEditDate="2023-02-19T14:44:21.283" LastActivityDate="2023-02-19T14:44:21.283" Title="Force gaps between tasks, tasks are scheduled within their job's time windows in Jobshop problem" Tags="|constraint-programming|or-tools|java|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8846" PostTypeId="2" ParentId="8837" CreationDate="2022-08-08T12:07:40.607" Score="1" Body="&lt;p&gt;You may want to have the 2 primitive sets:&lt;/p&gt;&#xA;&lt;p&gt;CITY&lt;/p&gt;&#xA;&lt;p&gt;e.g. CHI MNN KC_&lt;/p&gt;&#xA;&lt;p&gt;and&#xA;PERIOD or event points&lt;/p&gt;&#xA;&lt;p&gt;e.g. P0600 P0630 P0700  etc.&lt;/p&gt;&#xA;&lt;p&gt;The nodes of the network will be the 2-tuples&#xA;(i,p) or (CITY, PERIOD)&lt;/p&gt;&#xA;&lt;p&gt;The arcs/decision variables will be:&lt;/p&gt;&#xA;&lt;p&gt;x(i,p,j,q) = planes flying from (i,p) to (j, q)&lt;/p&gt;&#xA;&lt;p&gt;Additionally you want the idle on ground arcs:&lt;/p&gt;&#xA;&lt;p&gt;idle( i, p) = planes idle on ground at i just after point p,&lt;/p&gt;&#xA;&lt;p&gt;The flow balance constraints will be essentially, for each (i, p):&lt;/p&gt;&#xA;&lt;p&gt;idle( i, p-1) + planes arriving at (i,p) = idle( i, p) + planes departing (i,p)&lt;/p&gt;&#xA;&lt;p&gt;The demand constraints for each (i,p,j,q) will be something like:&lt;/p&gt;&#xA;&lt;p&gt;capacity flown on (i,p,j,q) &amp;gt;= demand( i,p,j,q).&lt;/p&gt;&#xA;&lt;p&gt;Send me an email, linus.schrage@chicagobooth.edu, and I can send you runnable code for your specific data set.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastEditorUserId="9043" LastEditDate="2022-08-08T15:01:51.950" LastActivityDate="2022-08-08T15:01:51.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8847" PostTypeId="2" ParentId="8845" CreationDate="2022-08-08T13:45:56.397" Score="3" Body="&lt;p&gt;Here is a working version of your code:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You need to change the objective. The obvious optimal is not to schedule any job.&lt;/li&gt;&#xA;&lt;li&gt;You need to add a &lt;code&gt;0 -&amp;gt; 0&lt;/code&gt; arc to support no schedule jobs.&lt;/li&gt;&#xA;&lt;li&gt;I use &lt;code&gt;model.AddImplication()&lt;/code&gt; for clarity&lt;/li&gt;&#xA;&lt;li&gt;ends are really not defined for unperformed intervals. I replaced the Max() by a set of enforced precedences.&lt;/li&gt;&#xA;&lt;li&gt;Furthermore, I force &lt;code&gt;start[i]&lt;/code&gt; to be equal to &lt;code&gt;release_dates[i]&lt;/code&gt; if the job is not scheduled.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;from ortools.sat.python import cp_model&#xA;&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Model.&#xA;model = cp_model.CpModel()&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Data.&#xA;job_durations = [&#xA;    1, 1, 1, 1, 3, 3, 3, 3, 5, 5, 5, 5&#xA;]&#xA;&#xA;release_dates = [&#xA;    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0&#xA;]&#xA;&#xA;due_dates = [&#xA;    0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,&#xA;    -1, -1, -1&#xA;]&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Helper data.&#xA;num_jobs = len(job_durations)&#xA;all_jobs = range(num_jobs)&#xA;&#xA;# True is job of 'job_id' is scheduled, false otherwise.&#xA;x = [model.NewBoolVar(f'x_{job_id}') for job_id in all_jobs]&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Set big enough horizon value.&#xA;horizon = sum(job_durations) + max(due_dates)&#xA;print('Horizon =', horizon)&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Global storage of variables.&#xA;intervals = []&#xA;starts = []&#xA;ends = []&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Scan the jobs and create the relevant variables and intervals.&#xA;for job_id in all_jobs:&#xA;    duration = job_durations[job_id]&#xA;    release_date = release_dates[job_id]&#xA;    due_date = due_dates[job_id] if due_dates[job_id] != -1 else horizon&#xA;    print('job %2i: start = %5i, duration = %4i, end = %6i' %&#xA;          (job_id, release_date, duration, due_date))&#xA;    name_suffix = '_%i' % job_id&#xA;    start = model.NewIntVar(release_date, due_date, 's' + name_suffix)&#xA;    end = model.NewIntVar(release_date, due_date, 'e' + name_suffix)&#xA;    interval = model.NewOptionalIntervalVar(start, duration, end, x[job_id], 'i' + name_suffix)&#xA;    starts.append(start)&#xA;    ends.append(end)&#xA;    intervals.append(interval)&#xA;&#xA;# No overlap constraint.&#xA;model.AddNoOverlap(intervals)&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Transition times using a circuit constraint.&#xA;arcs = []&#xA;&#xA;# No job scheduled.&#xA;empty_lit = model.NewBoolVar('empty_lit')&#xA;arcs.append([0, 0, empty_lit])&#xA;&#xA;for i in all_jobs:&#xA;    # Initial arc from the dummy node (0) to a job.&#xA;    start_lit = model.NewBoolVar('')&#xA;    arcs.append([0, i + 1, start_lit])&#xA;&#xA;    # If this job is the first, set to minimum starting time.&#xA;    model.Add(starts[i] == release_dates[i]).OnlyEnforceIf(start_lit)&#xA;&#xA;    # Job is scheduled if the graph starts with it.&#xA;    model.AddImplication(start_lit, x[i])&#xA;&#xA;    # Final arc from an arc to the dummy node.&#xA;    arcs.append([i + 1, 0, model.NewBoolVar('')])&#xA;&#xA;    # Add 'x[job_id].Not()' literal to each node&#xA;    arcs.append([i + 1, i + 1, x[i].Not()])&#xA;&#xA;    # Link empty_lit and x[i]&#xA;    model.AddImplication(empty_lit, x[i].Not())&#xA;&#xA;    # Fix start and end for unperformed jobs.&#xA;    model.Add(start[i] == release_dates[i]).OnlyEnforceIf(x[i].Not())&#xA;&#xA;    for j in all_jobs:&#xA;        if i == j:&#xA;            continue&#xA;&#xA;        lit = model.NewBoolVar('%i follows %i' % (j, i))&#xA;        arcs.append([i + 1, j + 1, lit])&#xA;&#xA;        model.Add(starts[j] &amp;gt;= ends[i]).OnlyEnforceIf(lit)&#xA;&#xA;        # job[i] and job[j] are scheduled if they are successively scheduled by the solver.&#xA;        model.AddImplication(lit, x[i])&#xA;        model.AddImplication(lit, x[j])&#xA;&#xA;&#xA;model.AddCircuit(arcs)&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Objective.&#xA;makespan = model.NewIntVar(0, horizon, 'makespan')&#xA;for i in all_jobs:&#xA;    model.Add(makespan &amp;gt;= ends[i]).OnlyEnforceIf(x[i])&#xA;model.Minimize(makespan)&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Solve.&#xA;solver = cp_model.CpSolver()&#xA;solver.parameters.max_time_in_seconds = 60 * 60 * 2&#xA;solver.parameters.num_search_workers = 16&#xA;solver.Solve(model)&#xA;print(solver.ResponseStats())&#xA;for job_id in all_jobs:&#xA;    if solver.BooleanValue(x[job_id]):&#xA;        print(&#xA;            f'job {job_id} starts at {solver.Value(starts[job_id])} and ends at {solver.Value(ends[job_id])}'&#xA;        )&#xA;    else:&#xA;        print(f'job {job_id} is not scheduled')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2022-08-12T17:47:57.200" LastActivityDate="2022-08-12T17:47:57.200" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="8848" PostTypeId="1" AcceptedAnswerId="8849" CreationDate="2022-08-08T14:33:51.370" Score="3" ViewCount="427" Body="&lt;p&gt;I have subtour elimination constraint but can't understand and formulate this in gurobipy. How to formulate this ?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in S} \sum_{j \in S} x_{i j}^{v} \leq|S|-1 \quad v=1, \ldots, m ; S \subseteq V-\{0\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10000" LastActivityDate="2022-08-08T22:39:40.343" Title="How to formulate this in gurobi" Tags="|combinatorial-optimization|gurobi|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8849" PostTypeId="2" ParentId="8848" CreationDate="2022-08-08T15:37:27.940" Score="4" Body="&lt;p&gt;I'm going to assume that &lt;span class=&quot;math-container&quot;&gt;$\hat{V}=V\backslash \lbrace 0 \rbrace =\lbrace 1,\dots,m\rbrace$&lt;/span&gt; for some integer &lt;span class=&quot;math-container&quot;&gt;$m.$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$\hat{V}$&lt;/span&gt; is something else, you'll need to map the elements of &lt;span class=&quot;math-container&quot;&gt;$\hat{V}$&lt;/span&gt; (in any arbitrary order) to &lt;span class=&quot;math-container&quot;&gt;$1,\dots,m.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are &lt;span class=&quot;math-container&quot;&gt;$2^m$&lt;/span&gt; subsets of &lt;span class=&quot;math-container&quot;&gt;$\hat{V},$&lt;/span&gt; including the empty set. Each subset &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is associated with a characteristic vector &lt;span class=&quot;math-container&quot;&gt;$z\in \lbrace 0,1 \rbrace^m$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$z_i=1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$i\in S.$&lt;/span&gt; Each characteristic vector in turn can be assigned a unique integer index &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^m 2^{z_i}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So to iterate over the subsets, you can iterate over the integers &lt;span class=&quot;math-container&quot;&gt;$1,\dots, 2^m.$&lt;/span&gt; For each integer in that range, express it as a binary vector and include in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; the integers in &lt;span class=&quot;math-container&quot;&gt;$\lbrace 1,\dots,m\rbrace$&lt;/span&gt; corresponding to the locations of the 1 bits.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-08T15:37:27.940" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8850" PostTypeId="2" ParentId="8821" CreationDate="2022-08-08T15:47:33.533" Score="3" Body="&lt;p&gt;A (very simple) example of coarse modelling is a &lt;a href=&quot;https://tms-outsource.com/blog/posts/risk-assessment-matrix/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Risk Assessment Matrix&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This has a few different variations but typically the severity and likelihood of individual risks are scored on a scale of one-to-five, multiplied and the result is colour coded with a verbal description to indicate the overall threat posed by each risk.&lt;/p&gt;&#xA;&lt;p&gt;Personally I think that standard implementation is numerically dubious but it offers an example of a verbal/numerical hybrid model that is popular in the real world.&lt;/p&gt;&#xA;" OwnerUserId="10114" LastActivityDate="2022-08-08T15:47:33.533" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8851" PostTypeId="1" AcceptedAnswerId="8864" CreationDate="2022-08-08T16:19:57.423" Score="3" ViewCount="69" Body="&lt;p&gt;I´ve been trying to solve a contrained assignation problem given a set of constraints based in a real-world problem. I modeled the problem in AMPL as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    set Personnel;&#xA;    &#xA;    set Shifts;&#xA;    &#xA;    param costHora{i in Personnel}; &#xA;    &#xA;    param necesidad{j in Shifts}; &#xA;    &#xA;    param t_max{i in Personnel}; &#xA;    &#xA;    param t_min{i in Personnel}; &#xA;    &#xA;    param Eqn_horas{j in Shifts}; &#xA;    &#xA;    param cost{i in Personnel, j in Shifts}= costHora[i]*Eqn_horas[j]; &#xA;    &#xA;    var x{i in Personnel, j in Shifts} binary;&#xA;    &#xA;    minimize z: &#xA;        sum{i in Personnel, j in Shifts} cost[i,j]*x[i,j];&#xA;    &#xA;    subject to N{j in Shifts}: sum{i in Personnel} x[i,j] &amp;gt;= necesidad[j];&#xA;    subject to MH{i in Personnel}: sum{j in Shifts} x[i,j]*Eqn_horas[j] &amp;lt;= t_max[i]; &#xA;    subject to Mh{i in Personnel}: sum{j in Shifts} x[i,j]*Eqn_horas[j] &amp;gt;= t_min[i];&#xA;    subject to CVS{i in Personnel}: x[i,&amp;quot;I54&amp;quot;]+x[i,&amp;quot;I61&amp;quot;] &amp;lt;= 1;&#xA;    subject to CSD{i in Personnel}: x[i,&amp;quot;I64&amp;quot;]+x[i,&amp;quot;I71&amp;quot;] &amp;lt;= 1; &#xA;    &#xA;    subject to DL{i in Personnel}: (if x[i,&amp;quot;I21&amp;quot;]+x[i,&amp;quot;I22&amp;quot;]=0 then 1 else 0) + (if x[i,&amp;quot;I31&amp;quot;]+x[i,&amp;quot;I32&amp;quot;]=0 then 1 else 0) + (if x[i,&amp;quot;I41&amp;quot;]+x[i,&amp;quot;I42&amp;quot;]=0 then 1 else 0) + (if x[i,&amp;quot;I51&amp;quot;]+x[i,&amp;quot;I52&amp;quot;]+x[i,&amp;quot;I53&amp;quot;]+x[i,&amp;quot;I54&amp;quot;]=0 then 1 else 0)  + (if x[i,&amp;quot;I61&amp;quot;]+x[i,&amp;quot;I62&amp;quot;]+x[i,&amp;quot;I63&amp;quot;]+x[i,&amp;quot;I64&amp;quot;]=0 then 1 else 0) + (if x[i,&amp;quot;I71&amp;quot;]+x[i,&amp;quot;I72&amp;quot;]=0 then 1 else 0) + (if x[i,&amp;quot;B11&amp;quot;]+x[i,&amp;quot;B12&amp;quot;]=0 then 1 else 0) + (if x[i,&amp;quot;B21&amp;quot;]+x[i,&amp;quot;B22&amp;quot;]=0 then 1 else 0) + (if x[i,&amp;quot;B31&amp;quot;]+x[i,&amp;quot;B32&amp;quot;]=0 then 1 else 0) + (if x[i,&amp;quot;B41&amp;quot;]+x[i,&amp;quot;B42&amp;quot;]=0 then 1 else 0) + (if x[i,&amp;quot;B51&amp;quot;]+x[i,&amp;quot;B52&amp;quot;]+x[i,&amp;quot;B53&amp;quot;]=0 then 1 else 0)  + (if x[i,&amp;quot;B61&amp;quot;]+x[i,&amp;quot;B62&amp;quot;]+x[i,&amp;quot;B63&amp;quot;]=0 then 1 else 0) + (if x[i,&amp;quot;B71&amp;quot;]=0 then 1 else 0)  &amp;gt;= 1;&#xA;     &#xA;    &#xA;    #subject to CT{i in Personnel}: if x[i,&amp;quot;I51&amp;quot;]=1 then x[i,&amp;quot;I52&amp;quot;]=1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I´m using the Ilogcp solver included by default on the AMPL IDE as is the only solver (included by default) that is able to handle my second to last constraint due to it having logical operators (I´m not really sure if I could use any other solver, tips are always welcome!).&lt;/p&gt;&#xA;&lt;p&gt;My problem comes when I include the last constraint (the one commented). I´m trying to make people work continuos shifts, since some shifts are less than the required working hours per day. For example, I´m trying to make workers assigned shift I51 to also be assigned shift I52. But, the solver can´t seem to hanlde the constraint as it keeps processing without reaching an optimal answer.&lt;/p&gt;&#xA;&lt;p&gt;Without said constraint, for example, I get this answer:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ilogcp 12.10.0: interrupted&#xA;16327848 choice points, 7499498 fails, objective 2726.29&#xA;z = 2726.29&#xA;&#xA;x [*,*] (tr)&#xA;# &lt;span class=&quot;math-container&quot;&gt;$1 = ADiego&#xA;# $&lt;/span&gt;2 = BDiego&#xA;# &lt;span class=&quot;math-container&quot;&gt;$3 = CEugenia&#xA;# $&lt;/span&gt;4 = CMerwin&#xA;# &lt;span class=&quot;math-container&quot;&gt;$5 = CMileidy&#xA;# $&lt;/span&gt;6 = CYolanda&#xA;# &lt;span class=&quot;math-container&quot;&gt;$7 = EJonathan&#xA;# $&lt;/span&gt;8 = FVanessa&#xA;# &lt;span class=&quot;math-container&quot;&gt;$9 = FlVanessa&#xA;# $&lt;/span&gt;10 = GAlejandro&#xA;# &lt;span class=&quot;math-container&quot;&gt;$11 = GBernardo&#xA;# $&lt;/span&gt;12 = LAnderson&#xA;# &lt;span class=&quot;math-container&quot;&gt;$13 = MEdwar&#xA;# $&lt;/span&gt;14 = PFrancisco&#xA;# &lt;span class=&quot;math-container&quot;&gt;$16 = QAdrian&#xA;# $&lt;/span&gt;17 = QCarolina&#xA;# &lt;span class=&quot;math-container&quot;&gt;$18 = RDanny&#xA;:     $&lt;/span&gt;1  &lt;span class=&quot;math-container&quot;&gt;$2  $&lt;/span&gt;3  &lt;span class=&quot;math-container&quot;&gt;$4  $&lt;/span&gt;5  &lt;span class=&quot;math-container&quot;&gt;$6  $&lt;/span&gt;7  &lt;span class=&quot;math-container&quot;&gt;$8  $&lt;/span&gt;9 &lt;span class=&quot;math-container&quot;&gt;$10 $&lt;/span&gt;11 &lt;span class=&quot;math-container&quot;&gt;$12 $&lt;/span&gt;13 &lt;span class=&quot;math-container&quot;&gt;$14 PJean $&lt;/span&gt;16 &lt;span class=&quot;math-container&quot;&gt;$17 $&lt;/span&gt;18 :=&#xA;B11    1   0   0   1   0   0   0   0   0   0   1   0   0   0    0    0   1   0&#xA;B12    1   0   1   0   0   0   0   0   0   1   0   0   0   0    0    0   1   0&#xA;B21    0   0   1   0   1   0   0   0   0   0   1   0   1   0    0    0   0   0&#xA;B22    0   0   0   0   0   0   0   0   0   1   0   1   1   0    1    1   0   0&#xA;B31    0   0   0   0   1   0   0   0   0   0   0   0   0   0    1    0   0   0&#xA;B32    0   1   0   0   0   0   1   0   1   1   0   0   0   0    0    0   0   0&#xA;B41    0   0   0   0   0   0   0   1   1   0   0   1   0   0    0    0   0   0&#xA;B42    1   0   0   0   1   1   1   0   0   0   0   1   0   0    0    1   0   0&#xA;B43    0   0   0   0   0   0   0   1   1   1   1   0   0   0    0    0   0   0&#xA;B51    1   0   0   1   0   1   0   0   0   0   0   0   0   0    0    0   0   1&#xA;B52    0   0   1   0   0   1   1   0   0   0   0   0   1   1    0    0   0   1&#xA;B53    0   1   0   1   0   0   0   0   0   0   0   0   0   1    1    0   0   0&#xA;B61    1   0   0   0   0   1   0   0   0   1   1   0   0   1    0    1   0   1&#xA;B62    0   1   1   1   0   0   0   1   1   0   1   1   0   0    0    0   1   0&#xA;B63    0   0   1   0   1   1   0   0   0   0   0   1   0   0    1    0   0   0&#xA;B71    0   1   0   1   0   0   0   0   0   0   1   0   1   1    0    0   0   0&#xA;BL21   0   0   0   1   0   0   0   0   0   0   0   0   0   0    0    0   0   1&#xA;BL31   0   0   0   0   0   0   1   0   1   0   0   0   0   0    0    0   0   0&#xA;BL41   0   0   0   0   0   0   0   0   0   1   0   0   0   0    0    1   0   0&#xA;BL51   0   0   0   1   0   0   0   0   0   0   0   0   0   0    0    1   0   0&#xA;BL52   0   0   0   0   0   1   0   1   1   0   0   0   0   0    0    0   0   0&#xA;BL61   0   0   1   0   0   0   0   0   0   0   0   0   0   0    1    0   0   0&#xA;BL62   1   0   0   0   0   0   0   0   0   0   0   0   0   0    1    0   0   1&#xA;BL71   0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    1   0   0&#xA;I21    0   1   0   0   0   0   0   0   0   0   0   0   0   0    0    1   1   1&#xA;I22    1   0   0   0   1   1   0   0   1   0   0   0   0   0    0    0   0   0&#xA;I31    0   0   0   0   0   0   0   0   0   1   1   0   1   1    0    0   1   0&#xA;I32    0   0   0   0   0   1   1   0   0   0   0   0   0   0    0    0   1   0&#xA;I41    0   0   1   0   0   0   0   1   0   0   0   0   0   1    0    1   1   0&#xA;I42    1   1   0   0   0   0   0   0   0   0   0   1   1   1    1    0   0   0&#xA;I51    0   1   0   0   0   0   0   1   0   0   0   1   0   0    0    0   0   0&#xA;I52    1   0   1   0   0   0   1   0   0   0   0   0   0   0    1    0   0   0&#xA;I53    0   0   0   0   1   1   1   1   0   0   1   1   1   1    1    0   0   0&#xA;I54    0   0   0   0   1   0   0   1   0   1   0   0   0   1    0    0   0   1&#xA;I61    0   1   1   0   0   0   0   0   0   0   1   0   0   0    0    0   0   0&#xA;I62    1   1   1   0   1   1   0   1   1   1   0   0   0   0    0    0   0   0&#xA;I63    0   1   1   1   1   0   0   0   0   1   1   1   0   0    0    0   0   1&#xA;I64    0   0   0   0   1   0   0   0   0   0   1   0   0   0    1    0   1   0&#xA;I65    1   1   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   1&#xA;I71    0   1   0   1   0   0   1   0   0   0   0   1   0   0    0    0   0   1&#xA;I72    0   0   1   1   0   0   1   1   0   0   0   1   1   1    1    0   0   0&#xA;&#xA;:    SDennis TTania VGabriela    :=&#xA;B11      0      0        0&#xA;B12      0      0        1&#xA;B21      0      0        0&#xA;B22      0      0        0&#xA;B31      1      0        1&#xA;B32      0      0        0&#xA;B41      0      1        0&#xA;B42      0      0        0&#xA;B43      0      0        0&#xA;B51      0      0        1&#xA;B52      1      1        0&#xA;B53      0      1        1&#xA;B61      1      0        0&#xA;B62      1      0        0&#xA;B63      0      0        1&#xA;B71      0      1        1&#xA;BL21     0      0        0&#xA;BL31     0      0        0&#xA;BL41     0      0        0&#xA;BL51     0      0        0&#xA;BL52     0      0        0&#xA;BL61     0      0        0&#xA;BL62     0      0        0&#xA;BL71     1      0        0&#xA;I21      0      0        1&#xA;I22      0      0        0&#xA;I31      0      0        0&#xA;I32      0      1        0&#xA;I41      0      0        0&#xA;I42      0      1        0&#xA;I51      0      0        1&#xA;I52      0      1        1&#xA;I53      0      0        1&#xA;I54      0      0        1&#xA;I61      0      1        0&#xA;I62      1      1        0&#xA;I63      1      0        1&#xA;I64      1      1        0&#xA;I65      0      1        0&#xA;I71      0      0        1&#xA;I72      1      1        0&#xA;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With my last constraint uncommented I get this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ilogcp 12.10.0: interrupted&#xA;15451615 choice points, 8621693 fails&#xA;z = 0&#xA;&#xA;x [*,*] (tr)&#xA;# &lt;span class=&quot;math-container&quot;&gt;$1 = ADiego&#xA;# $&lt;/span&gt;2 = BDiego&#xA;# &lt;span class=&quot;math-container&quot;&gt;$3 = CEugenia&#xA;# $&lt;/span&gt;4 = CMerwin&#xA;# &lt;span class=&quot;math-container&quot;&gt;$5 = CMileidy&#xA;# $&lt;/span&gt;6 = CYolanda&#xA;# &lt;span class=&quot;math-container&quot;&gt;$7 = EJonathan&#xA;# $&lt;/span&gt;8 = FVanessa&#xA;# &lt;span class=&quot;math-container&quot;&gt;$9 = FlVanessa&#xA;# $&lt;/span&gt;10 = GAlejandro&#xA;# &lt;span class=&quot;math-container&quot;&gt;$11 = GBernardo&#xA;# $&lt;/span&gt;12 = LAnderson&#xA;# &lt;span class=&quot;math-container&quot;&gt;$13 = MEdwar&#xA;# $&lt;/span&gt;14 = PFrancisco&#xA;# &lt;span class=&quot;math-container&quot;&gt;$16 = QAdrian&#xA;# $&lt;/span&gt;17 = QCarolina&#xA;# &lt;span class=&quot;math-container&quot;&gt;$18 = RDanny&#xA;:     $&lt;/span&gt;1  &lt;span class=&quot;math-container&quot;&gt;$2  $&lt;/span&gt;3  &lt;span class=&quot;math-container&quot;&gt;$4  $&lt;/span&gt;5  &lt;span class=&quot;math-container&quot;&gt;$6  $&lt;/span&gt;7  &lt;span class=&quot;math-container&quot;&gt;$8  $&lt;/span&gt;9 &lt;span class=&quot;math-container&quot;&gt;$10 $&lt;/span&gt;11 &lt;span class=&quot;math-container&quot;&gt;$12 $&lt;/span&gt;13 &lt;span class=&quot;math-container&quot;&gt;$14 PJean $&lt;/span&gt;16 &lt;span class=&quot;math-container&quot;&gt;$17 $&lt;/span&gt;18 :=&#xA;B11    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B12    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B21    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B22    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B31    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B32    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B41    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B42    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B43    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B51    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B52    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B53    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B61    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B62    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B63    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;B71    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;BL21   0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;BL31   0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;BL41   0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;BL51   0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;BL52   0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;BL61   0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;BL62   0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;BL71   0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I21    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I22    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I31    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I32    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I41    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I42    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I51    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I52    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I53    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I54    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I61    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I62    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I63    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I64    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I65    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I71    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;I72    0   0   0   0   0   0   0   0   0   0   0   0   0   0    0    0   0   0&#xA;&#xA;:    SDennis TTania VGabriela    :=&#xA;B11      0      0        0&#xA;B12      0      0        0&#xA;B21      0      0        0&#xA;B22      0      0        0&#xA;B31      0      0        0&#xA;B32      0      0        0&#xA;B41      0      0        0&#xA;B42      0      0        0&#xA;B43      0      0        0&#xA;B51      0      0        0&#xA;B52      0      0        0&#xA;B53      0      0        0&#xA;B61      0      0        0&#xA;B62      0      0        0&#xA;B63      0      0        0&#xA;B71      0      0        0&#xA;BL21     0      0        0&#xA;BL31     0      0        0&#xA;BL41     0      0        0&#xA;BL51     0      0        0&#xA;BL52     0      0        0&#xA;BL61     0      0        0&#xA;BL62     0      0        0&#xA;BL71     0      0        0&#xA;I21      0      0        0&#xA;I22      0      0        0&#xA;I31      0      0        0&#xA;I32      0      0        0&#xA;I41      0      0        0&#xA;I42      0      0        0&#xA;I51      0      0        0&#xA;I52      0      0        0&#xA;I53      0      0        0&#xA;I54      0      0        0&#xA;I61      0      0        0&#xA;I62      0      0        0&#xA;I63      0      0        0&#xA;I64      0      0        0&#xA;I65      0      0        0&#xA;I71      0      0        0&#xA;I72      0      0        0&#xA;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I can´t seem to grasp why would that constraint make the problem unsolvable, even if I remove the second to last constraint the solver won´t find an optimal answer.&lt;/p&gt;&#xA;&lt;p&gt;Is there any way I could reformulate my constraints to make the problem solvable? Is it due to the solver?&lt;/p&gt;&#xA;" OwnerUserId="10141" LastEditorUserId="500" LastEditDate="2022-08-10T01:32:07.760" LastActivityDate="2022-08-10T01:32:07.760" Title="Constrained shift assignment problem using ilogcp solver can´t find an optimal solution" Tags="|optimization|constraint-programming|logical-constraints|assignment-problem|ampl|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8852" PostTypeId="2" ParentId="8848" CreationDate="2022-08-08T18:00:56.870" Score="3" Body="&lt;p&gt;If you are using Python, look into the itertools package. To create the powerset (minus the empty set), we can do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from itertools import chain,combinations&#xA;&#xA;n = 4 &#xA;s = range(1,n+1)&#xA;list(chain.from_iterable(combinations(s, r) for r in range(1,len(s)+1)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which produces:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[(1,),&#xA; (2,),&#xA; (3,),&#xA; (4,),&#xA; (1, 2),&#xA; (1, 3),&#xA; (1, 4),&#xA; (2, 3),&#xA; (2, 4),&#xA; (3, 4),&#xA; (1, 2, 3),&#xA; (1, 2, 4),&#xA; (1, 3, 4),&#xA; (2, 3, 4),&#xA; (1, 2, 3, 4)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2022-08-08T22:39:40.343" LastActivityDate="2022-08-08T22:39:40.343" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8853" PostTypeId="1" CreationDate="2022-08-08T21:54:49.360" Score="2" ViewCount="66" Body="&lt;p&gt;I have the following problem that I do not know how to formulate.&lt;br /&gt;&#xA;There are a fixed number of workers &lt;span class=&quot;math-container&quot;&gt;$w_i \in W$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i \in [1…N]$&lt;/span&gt;.&lt;br /&gt;&#xA;Also, there are a fixed number of jobs that must be assigned to each of the workers.&lt;br /&gt;&#xA;The set of jobs is &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; and each job is &lt;span class=&quot;math-container&quot;&gt;$j_k$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$k \in [1…M]$&lt;/span&gt;.&lt;br /&gt;&#xA;Each of the &lt;span class=&quot;math-container&quot;&gt;$j_k$&lt;/span&gt; jobs span for a fixed number of days and requires a fixed number of hours each day. Also, the job is located at facility &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;.&lt;br /&gt;&#xA;There is a cost of transporting worker &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; to facility &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;.&lt;br /&gt;&#xA;I want to assign/schedule the jobs and the workers while:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The amount of job hours assigned to a particular worker cannot exceed a maximum per day.&lt;/li&gt;&#xA;&lt;li&gt;The whole job is assigned to the same worker (if a worker takes the job, he should finish it).&lt;/li&gt;&#xA;&lt;li&gt;Job overlapping is only possible if the two (or more) jobs is located at the same facility.&lt;/li&gt;&#xA;&lt;li&gt;Only certain workers can take certain jobs due to habilitations.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;My goal is to minimize the cost of transporting.&lt;br /&gt;&#xA;I particularly don’t know how to formulate the assignment of hours to consecutive days given that job &lt;span class=&quot;math-container&quot;&gt;$j_k$&lt;/span&gt; starts at any time (day).&lt;/p&gt;&#xA;" OwnerUserId="8891" LastActivityDate="2022-08-08T21:54:49.360" Title="Assignment/scheduling how to formulate considering job time and job cost" Tags="|modeling|scheduling|constraint-programming|assignment-problem|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8854" PostTypeId="2" ParentId="8851" CreationDate="2022-08-08T22:00:10.497" Score="2" Body="&lt;p&gt;Regarding the possibility of switching to a MIP model, the last constraint is easy to convert. The implication &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=1 \implies x_{i,k}=1$&lt;/span&gt; just becomes &lt;span class=&quot;math-container&quot;&gt;$x_{i,k}\ge x_{i,j}.$&lt;/span&gt; The penultimate constraint is a disjunction saying that at least one of a gaggle of clauses must hold. To handle that, you introduce new binary variables &lt;span class=&quot;math-container&quot;&gt;$z_1,z_2,\dots$&lt;/span&gt; (one for each clause) with the constraint &lt;span class=&quot;math-container&quot;&gt;$z_1+z_2+\dots \ge 1.$&lt;/span&gt; I'll show by example how to connect each &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to its clause. The fourth clause in the code reads &lt;code&gt;if x[i,&amp;quot;I51&amp;quot;]+x[i,&amp;quot;I52&amp;quot;]+x[i,&amp;quot;I53&amp;quot;]+x[i,&amp;quot;I54&amp;quot;]=0 then 1 else 0&lt;/code&gt;. The corresponding added constraints would be &lt;span class=&quot;math-container&quot;&gt;$$z_4\le 1 - x_{i,\textrm{I51}}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\cdots$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_4\le 1 - x_{i,\textrm{I54}}.$$&lt;/span&gt;&#xA;So for this clause to be satisfied (&lt;span class=&quot;math-container&quot;&gt;$z_4=1$&lt;/span&gt;), all four &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables would have to be 0. Another approach would use the single constraint &lt;span class=&quot;math-container&quot;&gt;$$x_{i,\textrm{I51}}+\dots+x_{i,\textrm{I54}}+4z_4 \le 4,$$&lt;/span&gt; (so if &lt;span class=&quot;math-container&quot;&gt;$z_4=1$&lt;/span&gt; then all the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables must be 0), but the first approach makes for a tighter model.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-08T22:00:10.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8855" PostTypeId="1" AcceptedAnswerId="8857" CreationDate="2022-08-09T05:58:05.527" Score="3" ViewCount="279" Body="&lt;p&gt;In my research class our professor discuss a paper wherein the solution is obtained via a Lagrangian duality. The original problem is given below:&lt;/p&gt;&#xA;&lt;p&gt;minimize &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to &lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in \mathcal{M_i}}\beta_{ij}x_{ij}\leq t, i \in \mathcal{N}$&lt;/span&gt; ---(1)&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{M_i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}$&lt;/span&gt; are the sets.&lt;/p&gt;&#xA;&lt;p&gt;Next, a partial Lagrangian is obtained by dualizing the constraint in (1). To do this , the authors introduced multipliers &lt;span class=&quot;math-container&quot;&gt;$\lambda = (\lambda_i)_{i \in \mathcal{N}}$&lt;/span&gt; for the first set of inequality constraints.&lt;/p&gt;&#xA;&lt;p&gt;Thus, the partial Lagrangian is given by&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L(t, x, \lambda) = t(1-\sum_{i \in \mathcal{N}}\lambda_i)+\sum_{j \in \mathcal{M}}\sum_{i \in \mathcal{N_j}}\beta_{ij}\lambda_ix_{ij}$&lt;/span&gt;  ---(2)&lt;/p&gt;&#xA;&lt;p&gt;where they used the equivalence of the following two sets&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\{(i,j)|i \in \mathcal{N}, j \in \mathcal{M_i}\}\equiv \{(n,m)|m \in \mathcal{M}, n \in \mathcal{N_m}\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am not getting how equation (2) is obtained from equation (1).&lt;/p&gt;&#xA;" OwnerUserId="10143" LastEditorUserId="491" LastEditDate="2022-08-09T12:54:11.153" LastActivityDate="2022-08-09T12:54:11.153" Title="Related to Lagrangian dual" Tags="|linear-programming|duality|terminology|lagrange-multipliers|lagrangian-relaxation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8856" PostTypeId="2" ParentId="8855" CreationDate="2022-08-09T07:23:48.963" Score="2" Body="&lt;p&gt;To ease notation, let me use B as (sum_j Beta_ij.x_ij).&#xA;Then the constraint (1) is B-t &amp;lt;=0... You multiply this with lambda_i (let me use L for short of sum_i Lambda_i) and carry to objective function, so new objective is:&#xA;t + L(B-t) = t-Lt + LB = t(1-L)+ LB&lt;/p&gt;&#xA;" OwnerUserId="632" LastActivityDate="2022-08-09T07:23:48.963" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8857" PostTypeId="2" ParentId="8855" CreationDate="2022-08-09T08:09:47.943" Score="3" Body="&lt;p&gt;Dualizing a constraint comes back to the first, the direction of the objective function, and the second, how the dualized constraint would be violated. In your case, the constraint is written as &lt;span class=&quot;math-container&quot;&gt;$LHS-RHS \leq 0$&lt;/span&gt;, and therefore it is being violated when &lt;span class=&quot;math-container&quot;&gt;$LHS-RHS \geq 0$&lt;/span&gt;. Since we add this into the objective function as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$min \quad z = t + \sum_{i}\lambda_{i}(\sum_{j}\beta_{ij}x_{ij}-t) $$&lt;/span&gt; by multiplying in the appropriate violation penalties as &lt;span class=&quot;math-container&quot;&gt;$\lambda_{i}$&lt;/span&gt; as there exist &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; number of such constraint.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-08-09T08:09:47.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8860" PostTypeId="1" AcceptedAnswerId="8862" CreationDate="2022-08-09T13:16:59.883" Score="2" ViewCount="105" Body="&lt;p&gt;I am willing to find the number of faces and facets in a convex polyhedron. Suppose, in the cube polyhedron there exists &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; vertices, &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; edges, and &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; faces. It satisfies the Euler equation as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ V - E + F = 2  ; \quad \text{where}\{v:\text{vertices}, e:\text{edges}, f: \text{faces}\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, I would calculate this for a simple polytope: &lt;span class=&quot;math-container&quot;&gt;$P=\{x_1-x_2\leq0,\ -x_1+x_2\leq1,\ 2x_2\geq5,\ 8x_1-x_2\leq16,\ x_1+x_2\geq4,\ x\in\text{R}^2 \}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qeH5B.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qeH5B.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this case, there are &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; vertices as &lt;span class=&quot;math-container&quot;&gt;$\{(3/2, 5/2), (17/7, 24/7), (37/16,5/2) \}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; edges, and based on the mentioned Euler formulation it would have &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; faces. Also, there are &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; facets. What I am looking for is, how the number of faces is &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="491" LastEditDate="2022-08-09T15:45:02.250" LastActivityDate="2022-08-10T13:06:16.033" Title="Faces and Facets in a convex polyhedron" Tags="|linear-programming|polyhedra|convex-hull|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8861" PostTypeId="2" ParentId="23" CreationDate="2022-08-09T15:27:19.473" Score="5" Body="&lt;p&gt;Jeff Linderoth thinks that the best survey of symmetry in IP was given by Francois Margot:&#xA;&lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-540-68279-0_17&quot; rel=&quot;noreferrer&quot;&gt;https://link.springer.com/chapter/10.1007/978-3-540-68279-0_17&lt;/a&gt;&#xA;Here is my summary of it.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Groups are complicated and varied. While groups can be symmetric also non symmetric groups (such as permutation groups) can express symmetries on the problem.&lt;/li&gt;&#xA;&lt;li&gt;Symmetry detection is hard. In fact as hard as solving MILPs (or more precisely checking whether a different MILP has a solution). Domain knowledge is helpful. A promising approach is to instead rely on symmetries of the linear relaxation of the MILP. Users can make detecting symmetries impossible by removing only part of a symmetry with a constraint they add.&lt;/li&gt;&#xA;&lt;li&gt;Perturbing the objective slightly to remove symmetries is a bad idea. Today there are solvers with symmetry detection. Use them!&lt;/li&gt;&#xA;&lt;li&gt;Variable fixing is useful. It might reveal new permutations which are a tractable type of symmetry. Yet even variable fixing (which shrinks the problem as opposed to cuts which grow the size of the constraint matrix) might slow a symmetry aware solver. You'll probably have to try out. Fixing variables might even weaken the relaxation compared to what a symmetry aware solver would have discovered.&lt;/li&gt;&#xA;&lt;li&gt;Objective values can often break symmetries. Consider the TSP without cost for an example. The study of these constraints only polytopes does not yet seem to have yielded usable insight how to solve problems with objective values.&#xA;Bin packing, cutting stock, scheduling on identical machines, graph coloring (either vertex-coloring or edge-coloring), and graph partitioning problems are partitioning type problems. Those have permutation of column type symmetry if the objective vector &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; has the same symmetries. In addition row permutation symmetries occur with symmetries in constraints (such as two objects having the same dimensions).&lt;/li&gt;&#xA;&lt;li&gt;Dantze-Wolfe decomposition breaks column symmetries well, usually needs column generation though. Pricing problem usually domain specific.&lt;/li&gt;&#xA;&lt;li&gt;Row wise symmetries with a Partitioning orbitope which has a description as shifted column inequalities.&lt;/li&gt;&#xA;&lt;li&gt;In case the number of partitions is to be minimized consider Asymmetric representatives. See Campelo M., Campos V., Correa R&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The fundamental region &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is the smallest set of points which allow you to cover the entire &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n$&lt;/span&gt; under application of group operations. Smallest in the sense that no group operation maps from the interior of the &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; into the interior of &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt;. A fundamental region intersect with the feasible region of the MILP contains an optima. With a huge number of inequalities one can define the fundamental region. This usually impractical. There a ways to relax this construction.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Little is know about how construct a nice &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; or relaxation of &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; beyond particular problem classes. Due to interaction with other components of MILP solvers any discussion of nice of efficient becomes drowned by other concerns and cross interactions such as variable choice.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Margot presents this rule of thumb: For problems with a symmetry group of order up to a few thousands of permutations, dynamic symmetry breaking might be very effective. Larger than, a million, dynamic symmetry breaking&#xA;inequalities needs to be coupled with other symmetry breaking techniques to be effective.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Assigning power of two weights to binary variables allows for lexicographic ordering and breaking of permutations. However the number of such breaks is sometimes to huge to be beneficial used statically. Symmetry handling in the solver can not be replaced with mere problem reformulation in practice.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Dynamic symmetry breaking uses partial assignments and remove all isomorphic partial assignments from the search sub-tree. Those cuts are in general only valid for the sub-problems subject to the partial assignment.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint programmings stronger clauses lend themself to dynamic symmetry breaking. Lexicographic ordering can be expressed without needing big coefficients that might cause numerical problems.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Partitioning weaker than splitting weaker than minimum index splitting as branching rules.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fixing the order of variables to prune leads to good result compared to symmetry unaware solvers, however can leave orders of magnitude of speed up on the table as information from domain reduction technique gained during the solve is not used.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Domain reduction techniques together with symmetry must preserve that one optimal solution that is lexicomax in its orbit under G remains feasible.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Schreier-Sims representation is an essential tool and employed in group representation and group membership detection. IsoP by Margot F. and SBS by Brown C.A., Finkelstein L., Purdom P.W.: are such algorithms. SBDD also exists and is implemented by Gent I. P., Harvey W., Kelsey T., Linton S. There is no good comparison of those approaches.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In symmetric problems even faulty algorithms may find optimal solutions, however they may fail to find a particular isomorphic solution or return multiple isomorphic solutions when requested not to so asking for all isomorphic solutions is a useful debugging tool.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;different variable choices  might yield very different symmetry group complicated the choice of problem formulation&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Automatic symmetry detection in nodes of the branch and bound tree is not worth it&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-08-09T15:27:19.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8862" PostTypeId="2" ParentId="8860" CreationDate="2022-08-09T15:58:00.250" Score="3" Body="&lt;p&gt;The Euler equation was originally for polyhedra in three dimensions. When applied in two dimensions, it is for planar graphs (graphs with no edge crossings). Your example qualifies as a planar graph. A planar graph partitions the plane into regions (including the exterior of the graph), with each region termed a &amp;quot;face&amp;quot;. See, for instance, &lt;a href=&quot;http://discrete.openmathbooks.org/dmoi3/sec_planar.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://discrete.openmathbooks.org/dmoi3/sec_planar.html&lt;/a&gt;. In your example, there are indeed two faces: the interior of the triangle and the exterior of the triangle.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-09T15:58:00.250" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8863" PostTypeId="2" ParentId="8809" CreationDate="2022-08-09T21:34:19.537" Score="3" Body="&lt;p&gt;I think what you want is a meta-heuristic you can use without relying on all the work necessary to code one from the ground. If this is the case, I would recommend you to use the Biased Random Key Genetic Algorithm (&lt;a href=&quot;https://pymoo.org/algorithms/soo/brkga.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;BRKGA&lt;/a&gt;). Suffices to have in mind the basic notations of Genetic Algorithms, specifically the notion of chromosome and decode function, and there we go. In the section 8.5 of this &lt;a href=&quot;https://doi.org/10.1007/978-3-030-45308-4_8&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt;, you can find a decode function applied for a G-VRP variant.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="491" LastEditDate="2022-12-04T20:38:11.333" LastActivityDate="2022-12-04T20:38:11.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8864" PostTypeId="2" ParentId="8851" CreationDate="2022-08-10T01:05:04.680" Score="3" Body="&lt;p&gt;There's an experimental version of &amp;quot;Gurobi for AMPL&amp;quot; that should accept your constraint &lt;code&gt;DL&lt;/code&gt; just as you have written it. It uses AMPL's new &amp;quot;MP&amp;quot; solver interface that  converts many kinds of logical constraints to forms that MIP solvers can recognize. (You can find it as &amp;quot;x-gurobi&amp;quot; in AMPL distributions and download listings.) I haven't been able to test the new interface on your example, because I do not have the data, but I verified that &amp;quot;x-gurobi&amp;quot; worked on a simplified version of the condition that you are enforcing.&lt;/p&gt;&#xA;&lt;p&gt;Concerning constraint &lt;code&gt;CT&lt;/code&gt;, AMPL interprets what follows &amp;quot;then&amp;quot; (and optionally &amp;quot;else&amp;quot;) as an expression, not as a constraint, so the ILOG CP solver may not be interpreting it as you intend. To say that one constraint implies another constraint, use the &lt;code&gt;==&amp;gt;&lt;/code&gt; (&amp;quot;implies&amp;quot;) operator:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;subject to CT {i in Personnel}: x[i,&amp;quot;I51&amp;quot;] = 1 ==&amp;gt; x[i,&amp;quot;I52&amp;quot;] = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Because &lt;code&gt;x&lt;/code&gt; is a binary variable, this is in fact an &amp;quot;indicator constraint&amp;quot; that's widely accepted by MIP solvers. (Constraint &lt;code&gt;DL&lt;/code&gt; is also easily converted to indicator constraints.)&lt;/p&gt;&#xA;" OwnerUserId="52" LastActivityDate="2022-08-10T01:05:04.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8865" PostTypeId="1" CreationDate="2022-08-10T11:44:54.577" Score="2" ViewCount="276" Body="&lt;p&gt;I need to model a problem as a linear program. However my working solution contains a (bilinear) quadratic objective term:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum x_i * y_i \\&#xA;x \in \{0,1\} \\&#xA;y \in \mathbb{R}^+&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The value of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is calculated in a constraint like this:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y = \sum\limits_{z \in Z} \sum\limits_{k \in K} f(z,k) &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Therefore, I tried to move &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to the calculation of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and remodel it to an indicator constraint for avoiding quadratic constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;x_i = 1 &amp;amp;\rightarrow y = \sum\limits_{z \in Z} \sum\limits_{k \in K} f(z,k) \\&#xA;x_i = 0 &amp;amp;\rightarrow y = 0&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This solutions eliminates quadratic objective terms. On the other side is the solution gap around 100% and my originale (quadratic) solution archive &amp;lt;1%.&lt;/p&gt;&#xA;&lt;p&gt;How can I create a stronger formulation for this case?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Fixed typo of x in equation like mentioned in the comments.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Based on the answer of Erwin Kalvelagen I linearized the quadratic constraint. The resulting performance of my model is not well and the gap is much higher in the same time like the quadratic constraint.&lt;br /&gt;&#xA;Since I understand from &lt;a href=&quot;https://or.stackexchange.com/questions/8572/converting-quadratic-constrains-to-linear-constraint&quot;&gt;this questions&lt;/a&gt;, it is a bilinear/quadratic constraint. What does this mean for my model exactly? Does this have a significant effect to scalability/performance of models in general? Is it possible to say from experience which solution should be preferred (quadratic or linearized (with bigM-Constraint (?)) version)?&lt;/p&gt;&#xA;" OwnerUserId="9830" LastEditorUserId="9830" LastEditDate="2022-08-11T12:26:25.430" LastActivityDate="2022-08-11T12:26:25.430" Title="linearize bilinear quadratic objective terms" Tags="|linear-programming|modeling|gurobi|linearization|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8866" PostTypeId="2" ParentId="8860" CreationDate="2022-08-10T13:06:16.033" Score="0" Body="&lt;p&gt;For software for characterizing facets and/or extreme points of a polytope you might look at:&#xA;&lt;a href=&quot;http://porta.zib.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://porta.zib.de/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-08-10T13:06:16.033" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8867" PostTypeId="2" ParentId="8843" CreationDate="2022-08-10T16:42:05.853" Score="2" Body="&lt;p&gt;Delivering good lower bounds in minutes is difficult, particularly regarding routing or scheduling problems. Seeing the lower bound's LocalSolver stuck to 0 after 5 minutes on such a highly combinatorial problem as the Split Delivery Vehicle Routing Problem (SDVRP) is unsurprising. We first focus on delivering high-quality feasible solutions, that is, quality primal/upper bounds. (Because this is the demand of our customers). Hence, on SDVRP, the solutions provided are very good (&amp;lt; 5%) compared to the state-of-the-art.&lt;/p&gt;&#xA;&lt;p&gt;Hexaly relies on reformulation techniques combined with column and row generation to compute lower bounds on routing-like problems. Dramatic improvements for many families of vehicle routing problems have been obtained recently; these will be available in the next version (11.5) planned for October 2022.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;For further support, I suggest you contact Hexaly support at contact@hexaly.com. This is the primary channel for getting fast and accurate support for any concern, even for academic users.&lt;/strong&gt; The support is done by our optimization science team, which develops the solver. They will be pleased to answer all your questions and help you get the best from the solver.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T04:11:24.410" LastActivityDate="2024-04-04T04:11:24.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8868" PostTypeId="2" ParentId="8865" CreationDate="2022-08-10T19:34:43.043" Score="5" Body="&lt;p&gt;If you know some good bounds, it may be worthwhile to try a formulation with just binary variables. E.g.:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\color{darkred}z = \color{darkred}x\cdot \color{darkred}y$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}x \in \{0,1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}y \in [0,\color{darkblue}U]$&lt;/span&gt; can be written as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned}&amp;amp; \color{darkred}z \le \color{darkred}x \cdot \color{darkblue}U \\ &amp;amp;\color{darkred}z \le \color{darkred}y\\ &amp;amp; \color{darkred}z \ge \color{darkred}y - \color{darkblue}U \cdot(1-\color{darkred}x)\end{aligned}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Sometimes that is faster than indicator constraints (especially if you can find a good, tight &lt;span class=&quot;math-container&quot;&gt;$\color{darkblue}U$&lt;/span&gt;). No guarantee. The real secret behind developing good integer programming models is just to try many things.&lt;/p&gt;&#xA;" OwnerUserId="907" LastActivityDate="2022-08-10T19:34:43.043" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8869" PostTypeId="1" CreationDate="2022-08-11T00:42:29.937" Score="2" ViewCount="132" Body="&lt;p&gt;An MINLP from a paper I am reading has the following expression in its constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p_{l,s}=z_lb_l\Delta\theta_{l,s}+b_l\lambda_{l,s}u_l\Delta\theta_{l,s}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where from left to right:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{l,s}$&lt;/span&gt;: continuous variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_l$&lt;/span&gt;: binary variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b_l$&lt;/span&gt;: constant&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\Delta \theta_{l,s}$&lt;/span&gt;: continuous variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\lambda_l$&lt;/span&gt;: binary variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u_l$&lt;/span&gt;: binary variable&lt;/p&gt;&#xA;&lt;p&gt;The authors of this paper replaces the second term with a continuous variable &lt;span class=&quot;math-container&quot;&gt;$\zeta$&lt;/span&gt; as shown here:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\xi_{l,s}:=b_lu_l\lambda_{l,s}\Delta\theta_{l,s}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The authors then mention:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;By substituting this new variable for the third order polynomial, we&#xA;are lifting the third order polynomial equation into a higher&#xA;dimensional space and overcoming its nonlinearity.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;What does that mean? what does overcoming the nonlinearity mean in this context?&lt;/p&gt;&#xA;" OwnerUserId="9695" LastEditorUserId="500" LastEditDate="2024-03-18T22:09:13.933" LastActivityDate="2024-03-18T22:09:13.933" Title="Lifting a 3rd order polynomial into a higher dimensional space" Tags="|optimization|constraint|linearization|nonlinear-programming|binary-variable|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8870" PostTypeId="1" AcceptedAnswerId="8873" CreationDate="2022-08-11T03:04:51.867" Score="2" ViewCount="517" Body="&lt;p&gt;Suppose we have a binary variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and two non-negative continuous variables &lt;span class=&quot;math-container&quot;&gt;$y_1\ge 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2 \ge 0$&lt;/span&gt;. How can we linearize &lt;span class=&quot;math-container&quot;&gt;$xy_1 y_2$&lt;/span&gt; ?&lt;/p&gt;&#xA;&lt;p&gt;FYI, this is a follow up question to this:&#xA;&lt;a href=&quot;https://or.stackexchange.com/questions/39/how-to-linearize-the-product-of-a-binary-and-a-non-negative-continuous-variable&quot;&gt;How to linearize the product of a binary and a non-negative continuous variable?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10156" LastActivityDate="2022-08-11T19:31:56.940" Title="Mixed Integer Programming with product of a binary variable and multiple continuous variables" Tags="|mixed-integer-programming|linear-programming|linearization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8871" PostTypeId="1" CreationDate="2022-08-11T08:18:33.857" Score="2" ViewCount="85" Body="&lt;p&gt;It was suggested that I compare between the popular optimization packages on my specific problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/8822/methods-for-binary-linear-programming&quot;&gt;Methods for binary linear programming&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I started working on it, and I'm finding myself diving into the AMPL doc to find the parameters for each solver just to print the time, e.g.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;option gurobi_options 'outlev=1';&#xA;option cplex_options 'outlev=2 timing=1 tunedisplay=3';&#xA;option copt_options 'logging=1';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then, I'll need to write a python client to interface with NEOS, parse the results, and print a nice table.&lt;/p&gt;&#xA;&lt;p&gt;I'm thinking to myself again, surely someone has done that already, or there must be an easier solution?&lt;/p&gt;&#xA;&lt;p&gt;Maybe it's not necessary to compare all the solvers, and the three that I started with should be the best for linear programming in this case? The general benchmark link in the comments can give a hint about that, but maybe someone can summarize from experience and say &amp;quot;don't bother with the others.&amp;quot;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Looks like the AMPL exporter of yalmip doesn't scale well, and I'll need some help in:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/73319460/gams-solve-a-canonical-lp-model&quot;&gt;https://stackoverflow.com/questions/73319460/gams-solve-a-canonical-lp-model&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/73319510/ampl-solve-a-canonical-lp-model&quot;&gt;https://stackoverflow.com/questions/73319510/ampl-solve-a-canonical-lp-model&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/73319936/pyomo-solve-a-canonical-lp-model&quot;&gt;https://stackoverflow.com/questions/73319936/pyomo-solve-a-canonical-lp-model&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there a format that is recognized by NEOS and supports matrix algebra?&lt;/p&gt;&#xA;&lt;p&gt;Gurbi matlab has gurobi_write(), which can export to MPS. However, the file size is 192MB. It can also compress it and generate .bz2, and the file size is down to 22MB.&lt;/p&gt;&#xA;&lt;p&gt;NEOS doesn't accept compressed files(??), but even if it did:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;NEOS encountered an error in the submission:  Files must be smaller&#xA;than 16777216 bytes.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;...?&lt;/p&gt;&#xA;" OwnerUserId="10116" LastEditorUserId="10116" LastEditDate="2022-08-11T15:37:03.793" LastActivityDate="2022-08-11T15:37:03.793" Title="Compare optimization packages on a specific problem" Tags="|optimization|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8872" PostTypeId="1" CreationDate="2022-08-11T11:29:49.067" Score="5" ViewCount="491" Body="&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I use the syntax of &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360043111231-How-do-I-use-multiprocessing-in-Python-with-Gurobi-%22%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;gurobi with multiprocessing&lt;/a&gt; to solve multiple problems in parallel. Even though multiple problems are solved concurrently, the solving time for a single problem increases significantly, so there are no benefits to use multiprocessing, which is strange.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Possible reasons that have been excluded&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The number of problems solved in parallel is much smaller than number of cpu cores. So it is not because problems are too many and my cpu cores are too few.&lt;/li&gt;&#xA;&lt;li&gt;Multiple problems are really solved concurrently. I can see the log file of each problem is written at the same time. And The number of busy cpu cores is also same with the number of problems. So it is not because running code cannot achieve multiprocessing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I solve the tsp (travelling salesman problem) already introduced in Gurobi tutorial in parallel to repeat this problem. With some modification of codes, the tsp (in &lt;code&gt;tsp.py&lt;/code&gt;) is modified as follows (someone don't need look into codes in &lt;code&gt;tsp.py&lt;/code&gt; since it won't help solve the problem).&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;#!/usr/bin/env python3.7&#xA;&#xA;# Copyright 2022, Gurobi Optimization, LLC&#xA;&#xA;# Solve a traveling salesman problem on a randomly generated set of&#xA;# points using lazy constraints.   The base MIP model only includes&#xA;# 'degree-2' constraints, requiring each node to have exactly&#xA;# two incident edges.  Solutions to this model may contain subtours -&#xA;# tours that don't visit every city.  The lazy constraint callback&#xA;# adds new constraints to cut them off.&#xA;&#xA;import math&#xA;import random&#xA;from itertools import combinations&#xA;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;from datetime import datetime&#xA;&#xA;# Callback - use lazy constraints to eliminate sub-tours&#xA;def subtourelim(model, where):&#xA;    if where == GRB.Callback.MIPSOL:&#xA;        vals = model.cbGetSolution(model._vars)&#xA;        # find the shortest cycle in the selected edge list&#xA;        tour = model._subtour(vals,model._n)&#xA;        if len(tour) &amp;lt; model._n:&#xA;            # add subtour elimination constr. for every pair of cities in tour&#xA;            model.cbLazy(gp.quicksum(model._vars[i, j]&#xA;                                    for i, j in combinations(tour, 2))&#xA;                        &amp;lt;= len(tour)-1)&#xA;&#xA;# Given a tuplelist of edges, find the shortest subtour&#xA;def subtour(vals,n):&#xA;    # make a list of edges selected in the solution&#xA;    edges = gp.tuplelist((i, j) for i, j in vals.keys()&#xA;                        if vals[i, j] &amp;gt; 0.5)&#xA;    unvisited = list(range(n))&#xA;    cycle = range(n+1)  # initial length has 1 more city&#xA;    while unvisited:  # true if list is non-empty&#xA;        thiscycle = []&#xA;        neighbors = unvisited&#xA;        while neighbors:&#xA;            current = neighbors[0]&#xA;            thiscycle.append(current)&#xA;            unvisited.remove(current)&#xA;            neighbors = [j for i, j in edges.select(current, '*')&#xA;                        if j in unvisited]&#xA;        if len(cycle) &amp;gt; len(thiscycle):&#xA;            cycle = thiscycle&#xA;    return cycle&#xA;&#xA;class TSP:&#xA;    def __init__(self,n,logFile,taskName,rndSeed,model) -&amp;gt; None:&#xA;        self.n=n&#xA;        self.logFile=logFile&#xA;        self.startTime=datetime.now()&#xA;        self.taskName=taskName&#xA;        self.rndSeed=rndSeed&#xA;        self.m=model&#xA;&#xA;    def solveTSP(self):&#xA;        # with open(self.logFile,'a') as file:&#xA;            # file.write('TaskName: {}\nRandom Seed: {}\nStart time: {}\n\n'.format(self.taskName,self.rndSeed,self.startTime))&#xA;&#xA;        # Create n random points&#xA;&#xA;        random.seed(self.rndSeed)&#xA;        points = [(random.randint(0, 100), random.randint(0, 100)) for i in range(self.n)]&#xA;&#xA;        # Dictionary of Euclidean distance between each pair of points&#xA;&#xA;        dist = {(i, j):&#xA;                math.sqrt(sum((points[i][k]-points[j][k])**2 for k in range(2)))&#xA;                for i in range(self.n) for j in range(i)}&#xA;&#xA;        self.m.setParam('Threads',1)&#xA;        self.m.setParam('logFile',self.logFile)&#xA;        self.m.setParam('LogToConsole',0)&#xA;        self.m._subtour=subtour&#xA;        self.m._n=self.n&#xA;&#xA;        # Create variables&#xA;&#xA;        vars = self.m.addVars(dist.keys(), obj=dist, vtype=GRB.BINARY, name='e')&#xA;        for i, j in vars.keys():&#xA;            vars[j, i] = vars[i, j]  # edge in opposite direction&#xA;&#xA;        # You could use Python looping constructs and self.m.addVar() to create&#xA;        # these decision variables instead.  The following would be equivalent&#xA;        # to the preceding self.m.addVars() call...&#xA;        #&#xA;        # vars = tupledict()&#xA;        # for i,j in dist.keys():&#xA;        #   vars[i,j] = self.m.addVar(obj=dist[i,j], vtype=GRB.BINARY,&#xA;        #                        name='e[%d,%d]'%(i,j))&#xA;&#xA;&#xA;        # Add degree-2 constraint&#xA;&#xA;        self.m.addConstrs(vars.sum(i, '*') == 2 for i in range(self.n))&#xA;&#xA;        # Using Python looping constructs, the preceding would be...&#xA;        #&#xA;        # for i in range(n):&#xA;        #   self.m.addConstr(sum(vars[i,j] for j in range(n)) == 2)&#xA;&#xA;&#xA;        # Optimize model&#xA;&#xA;        self.m._vars = vars&#xA;        self.m.Params.LazyConstraints = 1&#xA;        self.m.optimize(subtourelim)&#xA;&#xA;        vals = self.m.getAttr('X', vars)&#xA;        tour = subtour(vals,self.n)&#xA;&#xA;        with open(self.logFile,'a') as file:&#xA;            file.write('TaskName: {}\nRandom Seed: {}\nOptimal tour: {}\nOptimal cost: {}\nStart time: {}\nSolved time: {}\n\n'.format(self.taskName,self.rndSeed,str(tour),self.m.objVal,self.startTime,datetime.now()))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And I run it in parallel by the code:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from tsp import TSP # import from tsp.py file defined above&#xA;import multiprocessing as mp&#xA;import gurobipy as gp&#xA;&#xA;# function that every process calls&#xA;def tspSolve(params):&#xA;    n=params['n']&#xA;    logFile=params['logFile']&#xA;    taskName=params['taskName']&#xA;    rndSeed=params['rndSeed']&#xA;    with gp.Env() as env, gp.Model(env=env) as model: # new env &#xA;        tspModel=TSP(n,logFile,taskName,rndSeed,model)&#xA;        tspModel.solveTSP() # solve tsp &#xA;&#xA;if __name__ == &amp;quot;__main__&amp;quot;:&#xA;    caseNum=8 # 8 problems in parallel&#xA;    processPool=mp.Pool(processes=caseNum)&#xA;    tspParamsList=[] # collect solving parameters of every problems&#xA;    for i in range(caseNum):&#xA;        newTspParams={&#xA;            'n':300, # number of tsp nodes&#xA;            'logFile':'/home/littleqjy/workspace/code/myTSP{}.log'.format(i+1),&#xA;            'taskName':'myTSP{}'.format(i+1),&#xA;            'rndSeed':i+1&#xA;        }&#xA;        tspParamsList.append(newTspParams)&#xA;    for tspParams in tspParamsList:&#xA;        processPool.apply_async(func=tspSolve,args=(tspParams,)) # submit problems &#xA;    processPool.close()&#xA;    processPool.join() # wait for all problems to be solved&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I change the &lt;code&gt;caseNum&lt;/code&gt; from 4 to 8 (4 problem to 8 problems), I read the log file and the solving time for a single problem doubles, so there are no benefits to use multiprocessing, which is strange. Does somebody know why this happens?&lt;/p&gt;&#xA;" OwnerUserId="10158" LastEditorUserId="36" LastEditDate="2022-08-11T12:57:08.697" LastActivityDate="2022-08-12T17:24:55.550" Title="Gurobi solver with multiprocessing does not reduce total solving time" Tags="|python|gurobi|runtime|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="8873" PostTypeId="2" ParentId="8870" CreationDate="2022-08-11T15:52:18.903" Score="6" Body="&lt;p&gt;As Johan Löfberg said, it cannot be done directly. You can get an approximate solution in two steps.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First, approximate the product of &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; using a new variable &lt;span class=&quot;math-container&quot;&gt;$z.$&lt;/span&gt; See, for instance, &lt;a href=&quot;https://or.stackexchange.com/questions/180/how-to-linearize-the-product-of-two-continuous-variables&quot;&gt;this question&lt;/a&gt;, and specifically the answers involving McCormick envelopes.&lt;/li&gt;&#xA;&lt;li&gt;Now linearize the product of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; using the link in your question.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-11T15:52:18.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8874" PostTypeId="2" ParentId="8870" CreationDate="2022-08-11T19:31:56.940" Score="6" Body="&lt;p&gt;I would start with a non-convex solver like Gurobi. Gurobi can only do quadratic terms, but that is not a real limitation:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; z1 = x*y1&#xA; z2 = z1*y2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="907" LastActivityDate="2022-08-11T19:31:56.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8875" PostTypeId="2" ParentId="8822" CreationDate="2022-08-12T02:55:51.030" Score="1" Body="&lt;p&gt;Your problem can be classified as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Integer_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;0-1 integer linear program&lt;/a&gt;. Problems in this class are NP-hard in general, even when the coefficients are all integers and there is no objective function.&lt;/p&gt;&#xA;&lt;p&gt;There are specific subclasses that are easier to solve. For example, &lt;a href=&quot;https://en.wikipedia.org/wiki/Linear_programming#Integral_linear_programs&quot; rel=&quot;nofollow noreferrer&quot;&gt;integral linear programs&lt;/a&gt; can be solved in continuous variables and will still produce a 0-1 solution. The most common way of proving that a polytope is integral is through total unimodularity.&lt;/p&gt;&#xA;&lt;p&gt;Without further information, using a mixed-integer programming solver seems like your best bet. It is not surprising that small instances are solvable while larger ones are not: in general you would expect the solution time of NP-hard problems to increase exponentially. Your polytope is probably not integral: if it was the solver would detect that after solving the root relaxation in node 0 and terminate quickly.&lt;/p&gt;&#xA;&lt;p&gt;If you share more information about the problem structure, we may be able to provide more help.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2022-08-12T03:08:58.693" LastActivityDate="2022-08-12T03:08:58.693" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8876" PostTypeId="2" ParentId="8755" CreationDate="2022-08-12T09:28:08.350" Score="2" Body="&lt;p&gt;Two good (free) books are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Essentials of Metaheuristics: &lt;a href=&quot;https://cs.gmu.edu/%7Esean/book/metaheuristics/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cs.gmu.edu/~sean/book/metaheuristics/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Clever Algorithms: &lt;a href=&quot;https://github.com/clever-algorithms/CleverAlgorithms&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/clever-algorithms/CleverAlgorithms&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you want to try Julia, this is a good start point: &lt;a href=&quot;https://jmejia8.github.io/Metaheuristics.jl/stable/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://jmejia8.github.io/Metaheuristics.jl/stable/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2022-08-12T09:28:08.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8877" PostTypeId="1" AcceptedAnswerId="8878" CreationDate="2022-08-12T12:05:44.933" Score="4" ViewCount="160" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$m\times n$&lt;/span&gt; Markov matrix, and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$m\times k$&lt;/span&gt; Markov matrix. How to decide (analytically or numerically) whether there is a &lt;span class=&quot;math-container&quot;&gt;$n\times k$&lt;/span&gt; Markov matrix &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$AB=C$&lt;/span&gt;? I feel that it is a question of feasibility in linear programming.&lt;/p&gt;&#xA;" OwnerUserId="9347" LastEditorUserId="491" LastEditDate="2022-08-13T02:39:30.017" LastActivityDate="2022-08-13T02:39:30.017" Title="How to find such a Markov matrix?" Tags="|linear-programming|feasible-points|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8878" PostTypeId="2" ParentId="8877" CreationDate="2022-08-12T13:27:19.440" Score="5" Body="&lt;p&gt;You could solve this as a Linear Programming feasibility problem.&lt;/p&gt;&#xA;&lt;p&gt;A Markov Matrix is also known as a stochastic matrix.&lt;/p&gt;&#xA;&lt;p&gt;So the constraints are:&lt;/p&gt;&#xA;&lt;p&gt;All elements of B are nonnegative.&lt;/p&gt;&#xA;&lt;p&gt;All rows sums of B equal 1.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$AB = C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Adding CVX program as an easy way to formulate and solve this under MATLAB, given OP comments below.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin&#xA;variable B(n,k)&#xA;B &amp;gt;= 0&#xA;sum(B,2) == 1&#xA;A*B == C&#xA;cvx_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will either be determined to be infeasibile, or it will be solved to &amp;quot;optimality&amp;quot;, in which case &lt;code&gt;B&lt;/code&gt; will contain a feasible solution after CVX concludes.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="67" LastEditDate="2022-08-12T15:32:11.020" LastActivityDate="2022-08-12T15:32:11.020" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8879" PostTypeId="1" CreationDate="2022-08-12T16:36:49.590" Score="5" ViewCount="302" Body="&lt;p&gt;Consider the situation of Vehicle Routing. Once we have an initial solution, one can apply various local search moves to improve it.&lt;/p&gt;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Removing a single customer from a route and inserting it into another route. (Relocate)&lt;/li&gt;&#xA;&lt;li&gt;Removing a subsegment of customers from one route and inserting it into another. (Or-Exchange)&lt;/li&gt;&#xA;&lt;li&gt;Swapping two customers of different routes. (Swap)&lt;/li&gt;&#xA;&lt;li&gt;Exchanging subsegment of customers between two different routes. (Cross-exchange)&lt;/li&gt;&#xA;&lt;li&gt;2-opt&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Has there been any work in modelling local search moves as MIP?. Is it even possible?&lt;/p&gt;&#xA;" OwnerUserId="9481" LastActivityDate="2022-08-12T19:39:03.393" Title="Can Local Search Operators be formulated as a Mixed Integer Program?" Tags="|mixed-integer-programming|reference-request|local-search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8880" PostTypeId="2" ParentId="8872" CreationDate="2022-08-12T17:24:55.550" Score="4" Body="&lt;p&gt;According to &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/8329982811921-Gurobi-with-multiprocessing-has-few-benefits?page=1&quot; rel=&quot;nofollow noreferrer&quot;&gt;responses&lt;/a&gt; of Jaromił in Gurobi support team, the most possible reason is &lt;strong&gt;missing ratio of L-cache&lt;/strong&gt; increases when used processes increase, even if physical cores are still sufficient.&lt;/p&gt;&#xA;&lt;p&gt;I use &lt;code&gt;perf stat -B -e cache-references,cache-misses,cycles,instructions python &amp;lt;fileName.py&amp;gt;&lt;/code&gt; to inspect the cache-miss ratio under different number of processes. The relationship between parallelized processes, ratio of cache-miss and solving time for single problem is as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 processes, 0.783% cache-miss, 130 seconds for single problem&lt;/li&gt;&#xA;&lt;li&gt;2 processes, 1.204% cache-miss, 130 seconds for single problem&lt;/li&gt;&#xA;&lt;li&gt;4 processes, 6.583% cache-miss, 150 seconds for single problem&lt;/li&gt;&#xA;&lt;li&gt;8 processes, &lt;strong&gt;16.848%&lt;/strong&gt; cache-miss, &lt;strong&gt;300&lt;/strong&gt; seconds for single problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;According to above checks, &lt;strong&gt;high cache-miss ratio&lt;/strong&gt; is reasonable for explanation as far as I see.&lt;/p&gt;&#xA;&lt;p&gt;To make best use of Gurobi with multiprocessing, you can try different number of processes and select the best where parallelism can work well.&lt;/p&gt;&#xA;" OwnerUserId="10158" LastActivityDate="2022-08-12T17:24:55.550" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8881" PostTypeId="2" ParentId="8879" CreationDate="2022-08-12T18:03:05.993" Score="4" Body="&lt;p&gt;I'm not aware of any work on modeling local search heuristics as MIPs. It is certainly possible to come up with a MIP model for each heuristic you mentioned. What is not clear is whether it is worth doing.&lt;/p&gt;&#xA;&lt;p&gt;First, you would need to decide whether your model would look for a single feasible move (feasible here meaning produces a better feasible solution than the starting point) or would look for an &amp;quot;optimal&amp;quot; move (the single move of its type that produces the biggest improvement in the objective). Second, you would have to decide whether the MIP result was sufficiently better than the &amp;quot;standard&amp;quot; approach (using loops, say) to warrant want I am fairly certain would be a longer (possibly substantially longer) computation time. In that vein, the third question would be whether running one of these MIPs repeatedly (once per step in the parent heuristic) would be faster than just solving the entire problem once using a MIP model.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-12T18:03:05.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8882" PostTypeId="2" ParentId="8879" CreationDate="2022-08-12T19:39:03.393" Score="7" Body="&lt;p&gt;What you describe is a special case of Large Neighborhood Search.&lt;/p&gt;&#xA;&lt;p&gt;Large Neighborhood search is an optimization method that consists in destroying a part of a solution and recreating it with a constructive approach. The constructive approach can be a greedy algorithm, a constraint programming model... or a MILP model.&lt;/p&gt;&#xA;&lt;p&gt;When the constructive part is a MILP, it is often called &amp;quot;Kernel search&amp;quot;, and the destruction part takes the form of unfixing some variables (possibly restraining their domain). Here is an example for an Inventory Routing Problem:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Archetti C, Guastaroba G, Huerta‐Muñoz DL, Speranza MG (2021) A kernel search heuristic for the multivehicle inventory routing problem. International Transactions in Operational Research n/a: &lt;a href=&quot;https://doi.org/10.1111/itor.12945&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1111/itor.12945&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In this case, the neighborhood considered is larger than the neighborhood of a classical Local Search algorithm. Indeed, to explore a 2-opt neighborhood, it's faster to do a manual loop than to solve a MILP model.&lt;/p&gt;&#xA;&lt;p&gt;This approach is attractive for problems with continuous variables (such as Inventory Routing Problems) since it's not straightforward to design a classical Local Search algorithm in these cases&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-08-12T19:39:03.393" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8884" PostTypeId="1" CreationDate="2022-08-13T00:08:27.467" Score="2" ViewCount="128" Body="&lt;p&gt;I would like to ask for help to identify the research operational software that is being used in the picture&#xA;&lt;a href=&quot;https://i.stack.imgur.com/iGbsG.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iGbsG.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I think it looks nice and I'd like to use it (It doesn't seem to be Lingo nor Excel Solver).&lt;/p&gt;&#xA;" OwnerUserId="10174" LastEditorUserId="1228" LastEditDate="2022-08-15T11:04:07.280" LastActivityDate="2022-08-15T11:04:07.280" Title="Looking for a specific operations research software" Tags="|optimization|linear-programming|solver|software|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8885" PostTypeId="1" CreationDate="2022-08-13T00:25:27.633" Score="2" ViewCount="134" Body="&lt;p&gt;I would like to reproduce the output of CPLEX, when it solves an MIP problem. That is, I would like to get the entries of the following example output, so that I can work with them.&lt;/p&gt;&#xA;&lt;p&gt;I am especially interested in getting the branching variable (I suppose I can get the rest in a similar manner).&lt;/p&gt;&#xA;&lt;p&gt;I would like to use the C API.&lt;/p&gt;&#xA;&lt;p&gt;Can anyone help?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Node  Left    Objective   IInf  Best Integer    Best Bound    ItCnt     Gap         Variable B NodeID Parent  Depth&#xA;  1     3     3034.1684   588        0.0000     3034.1684     8562     ---            V5761 D      4      0      1&#xA;  3     4     3025.0305   674        0.0000     2993.5940     9283     ---            V5215 D      8      4      2&#xA;  4     5     2867.8075   542        0.0000     2993.5940    11893     ---            V5219 D      7      3      2&#xA;  8     8     2933.7516   649        0.0000     2976.2963    13510     ---            V5723 U     16     12      4&#xA; 13    12     2846.5455   528        0.0000     2976.2963    15227     ---            V7321 U     23     19      6&#xA; 18    10     2108.5714   522        0.0000     2976.2963    14249     ---            V7283 D     24     16      5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10130" LastActivityDate="2022-08-13T16:14:56.053" Title="Reproducing the CPLEX Output" Tags="|mixed-integer-programming|cplex|callback|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8886" PostTypeId="2" ParentId="8884" CreationDate="2022-08-13T00:51:50.830" Score="1" Body="&lt;p&gt;Looks like QM for windows. I'm not sure whether this software is still maintained.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2022-08-13T00:51:50.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8888" PostTypeId="2" ParentId="8885" CreationDate="2022-08-13T16:14:56.053" Score="3" Body="&lt;p&gt;You can get at least some of the information at every node (not just at the nodes where CPLEX decides to print a log entry) by attaching an information callback. See &lt;code&gt;CPXsetinfocallbackfunc&lt;/code&gt; in the docs for how to do that. In the callback, you can use &lt;code&gt;CPXgetcallbackinfo&lt;/code&gt; to get things like node counts, iteration counts, incumbent objective value etc. (basically, scalar valued things) and &lt;code&gt;CPXgetcallbackincumbent&lt;/code&gt; to get the current incumbent solution (if one exists).&lt;/p&gt;&#xA;&lt;p&gt;To get the variable (or SOS) on which CPLEX is about to branch, you would need to attach a branch callback (&lt;code&gt;CPXsetbranchcallbackfunc&lt;/code&gt;) and then decode the entries returned to figure out the variable(s) it chose. From there you can use &lt;code&gt;CPXbranchcallbackbranchasCPLEX&lt;/code&gt; to tell CPLEX to go ahead with the branch (meaning you do not want to supply a different branching decision).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-13T16:14:56.053" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8890" PostTypeId="2" ParentId="8622" CreationDate="2022-08-14T10:24:28.380" Score="4" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/svigerske&quot; rel=&quot;nofollow noreferrer&quot;&gt;Stefan Vigerske&lt;/a&gt; was kind enough to answer &lt;a href=&quot;https://github.com/coin-or/Ipopt/issues/597#issue-1337941015&quot; rel=&quot;nofollow noreferrer&quot;&gt;my question&lt;/a&gt; on the &lt;a href=&quot;https://github.com/coin-or/Ipopt&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ipopt github&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;With &lt;a href=&quot;https://github.com/coin-or/Ipopt/issues/597#issuecomment-1214193598&quot; rel=&quot;nofollow noreferrer&quot;&gt;minimal changes&lt;/a&gt; one can basically reduce &lt;code&gt;Ipopt&lt;/code&gt; to a feasibility problem solver.&lt;/p&gt;&#xA;" OwnerUserId="9847" LastActivityDate="2022-08-14T10:24:28.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8891" PostTypeId="1" CreationDate="2022-08-15T03:48:10.787" Score="4" ViewCount="77" Body="&lt;p&gt;I have the following distribution.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\operatorname{logpdf}(x) = -\sum_{i = 0}^n \max(v_i \cdot x + b_i, 0) -1/2 (x - \mu)^T M (x - \mu) + \text{const}$$&lt;/span&gt;&#xA;Where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is symmetric positive definite, &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^m$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; around &lt;span class=&quot;math-container&quot;&gt;$500$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; around &lt;span class=&quot;math-container&quot;&gt;$100,000$&lt;/span&gt;.&#xA;I want to calculate the mean and the variance in less than 1 second. I understand this is quite difficult, so I would like to find the best approximation.&lt;/p&gt;&#xA;&lt;p&gt;I have tried distributed MCMC methods&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Metropolis Hestings&lt;/li&gt;&#xA;&lt;li&gt;Metropolis-adjusted Langevin algorithm (MALA)&lt;/li&gt;&#xA;&lt;li&gt;Gibbs sampling&lt;/li&gt;&#xA;&lt;li&gt;Importance sampling (using multivariate normal distribution suggested by the quadratic term).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;MALA seems to perform the best, but it is still not good enough.&#xA;I also tried to approximate the distribution with a normal distribution using variational bayesian methods, but it seems to have too much bias.&lt;/p&gt;&#xA;&lt;p&gt;I have run out of things to try. Can I get suggestions on different sampling methods or approximations?&lt;/p&gt;&#xA;" OwnerUserId="10044" LastEditorUserId="123" LastEditDate="2022-08-16T10:32:42.820" LastActivityDate="2022-08-16T10:32:42.820" Title="Expected Value of Piecewise Exponential Function" Tags="|optimization|probability-distributions|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8892" PostTypeId="1" CreationDate="2022-08-15T10:09:22.573" Score="9" ViewCount="2147" Body="&lt;p&gt;I'm asking myself for some time if the results of optimization are random. As search for stochastic and optimization gives results about stochastic optimization but does not help with the stochasticity of optimization.&lt;/p&gt;&#xA;&lt;p&gt;Let's say we have a simple knapsack problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{align}&#xA;&amp;amp;\max\; x_1 + x_2 + 2x_3\\&#xA;&amp;amp;\text{s.t. } x_1 + x_2 + 2x_3 \le 2\\&#xA;&amp;amp;x_1, x_2, x_3 \in \{0,1\}\end{align}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are two possible results: &lt;span class=&quot;math-container&quot;&gt;$x_1 = 1, x_2 = 1$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;$x_3 = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is it true to say that, in this case, each optimal result has a probability of 50%, as we would deduce from enumeration? As I understand, this would be called random.&lt;/p&gt;&#xA;&lt;p&gt;However, a solver could apply a deterministic heuristic, which resolves knapsack problems by setting the largest values true, which would always result in &lt;span class=&quot;math-container&quot;&gt;$x_3 = 1$&lt;/span&gt;, or vice versa. In this case, when we know about this, we should call the result deterministic.&lt;/p&gt;&#xA;&lt;p&gt;For general optimization problems, it's nearly impossible to predict the interplay of all solution methods. Also, for larger problems it might not be feasible to enumerate all solutions.&lt;/p&gt;&#xA;&lt;p&gt;I would assume that, if we pick a variable of a complex optimization problem, we probably couldn't tell the probability of a solution value in an optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;But we should keep in mind that there are processes in the solver which are deterministic and thus reduce randomness.&lt;/p&gt;&#xA;&lt;p&gt;Could we say that results of &lt;em&gt;sufficiently&lt;/em&gt; complex optimization problems are stochastic?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;My question aims more in the direction of if the possibility to say that the results are stochastic, and less in the direction of &lt;a href=&quot;https://or.stackexchange.com/questions/7896/achieve-true-determinism-in-cplex&quot;&gt;how it is possible to create deterministic results&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Also, what might not have been clear in the question is that it aims at the assessment of the stochasticity of the solution &lt;em&gt;before&lt;/em&gt; the solution is known. I could ask more clearly: Can we regard the solution to a complex optimization problem, with solvers which contain random elements, as stochastic, before we solve the problem?&lt;/p&gt;&#xA;" OwnerUserId="1008" LastEditorUserId="1008" LastEditDate="2022-08-16T10:08:26.767" LastActivityDate="2022-08-31T09:07:13.220" Title="Are optimization results stochastic?" Tags="|optimization|linear-programming|stochastic-process|" AnswerCount="6" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8893" PostTypeId="2" ParentId="8892" CreationDate="2022-08-15T10:26:23.120" Score="5" Body="&lt;p&gt;In the example you give, the problem is not stochastic, but the solution that a potential solver gives you, in case multiple optimal solutions do exist. That is an important difference. Deterministic problems are, as the name suggests, not stochastic but multiple optimal solutions might exist. And in that case, it is up to the solver how to deal with this and there might (dependent on the solver) indeed be some stochasticity involved.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="491" LastEditDate="2022-08-15T12:43:55.523" LastActivityDate="2022-08-15T12:43:55.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8894" PostTypeId="2" ParentId="8892" CreationDate="2022-08-15T10:27:24.340" Score="11" Body="&lt;p&gt;Usually no. All solvers worth their salt can be deterministic, and most are by default. That is, given a fixed configuration and seed for their random number generator, they always give the same solution. So for a given solver configuration finding a solution can not be seen as a random process.&lt;/p&gt;&#xA;&lt;h2&gt;You can make it stochastic&lt;/h2&gt;&#xA;&lt;p&gt;If you add random elements, you could make it stochastic. This could be any randomization in the parameters, the random seed, the order of the formulation, enabling non-deterministic multithreading, changing machine, etc.&lt;/p&gt;&#xA;&lt;h2&gt;But it's likely not very random&lt;/h2&gt;&#xA;&lt;p&gt;Even then, it's not easy to understand how it samples the solution space: preprocessing and branching strategies create a lot of bias. It's hard to sample solutions uniformly and efficiently, and there is ongoing research on the subject (see &lt;a href=&quot;https://www.msoos.org/2022/06/checking-uniform-like-samplers/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for SAT solvers for example).&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2022-08-16T21:43:08.993" LastActivityDate="2022-08-16T21:43:08.993" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="8895" PostTypeId="2" ParentId="8892" CreationDate="2022-08-15T10:34:33.780" Score="6" Body="&lt;p&gt;Results are only stochastic if your convergence criterion allows for that. If your convergence criterion is not met but you terminate anyway, there are no results to speak of, so this statement is conveniently consistent.&lt;/p&gt;&#xA;&lt;p&gt;There is an element of stochasticity in all high performance solvers due to internal working limits, timeouts, RNG, etc., but as long as the solver will only converge if a certain criterion is met, it all really depends on what that criterion is.&lt;/p&gt;&#xA;&lt;p&gt;There are methods to deterministically solve general optimisation problems to global optimality. Even in the case of multiple global solutions (different vectors with identical objective values), there are ways to deterministically find all of them, as long as the solver is told to do so.&lt;/p&gt;&#xA;&lt;p&gt;What might vary is solution time - this is nearly always stochastic at high performance. What solution you get is something that can be controlled in many ways, even though that's not always done in practice.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2022-08-15T11:01:24.227" LastActivityDate="2022-08-15T11:01:24.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8896" PostTypeId="1" AcceptedAnswerId="8897" CreationDate="2022-08-15T19:17:55.083" Score="2" ViewCount="439" Body="&lt;p&gt;This problem is a continuation of &lt;a href=&quot;https://or.stackexchange.com/questions/8845/force-gaps-between-tasks-tasks-are-scheduled-within-their-jobs-time-windows-in&quot;&gt;this problem&lt;/a&gt;. The issue here is the solver doesn't use the whole space available for the scheduling and thus some jobs are not being scheduled. For example: we need to schedule 9 jobs of given durations: &lt;code&gt;job_durations = [10, 10, 10, 30, 30, 30, 50, 50, 50]&lt;/code&gt;. Just like in referenced higher problem, jobs have their release dates: &lt;code&gt;release_dates = [0, 0, 0, 0, 0, 0, 0, 0, 0]&lt;/code&gt; and due dates: &lt;code&gt;due_dates = [1200, 1200, 1200, 1800, 1800, 1800, 2400, 2400, 2400]&lt;/code&gt;. As you can see, jobs of indices &lt;code&gt;0-2&lt;/code&gt; require 30 of 1200 available units of time, jobs of indices &lt;code&gt;3-5&lt;/code&gt; need 90 of 1800 available units of time and jobs of indices &lt;code&gt;6-8&lt;/code&gt; require 150 of 2400 available time units. If you launch the script, you'll see that job 0 won't be scheduled at all. Now if you'll append another job, say &lt;code&gt;job_duration = 50&lt;/code&gt;, &lt;code&gt;job_due_date = 2400&lt;/code&gt; and &lt;code&gt;job_release_date = 0&lt;/code&gt; and start the program, you'll see all jobs are scheduled nicely despite having enough space for all jobs before new job appending and after it.&lt;/p&gt;&#xA;&lt;p&gt;I have set the flag &lt;code&gt;enumerate_all_solutions = True&lt;/code&gt; to make solver find all solutions, but this didn't help. I also tried using flag &lt;code&gt;num_search_workers = 6&lt;/code&gt; and sometimes the solver doesn't schedule job 0 also. Do you know what might be wrong here? Does this have something to do with circuit constraint?&lt;/p&gt;&#xA;&lt;p&gt;Here's the code in Python:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from ortools.sat.python import cp_model&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Model.&#xA;model = cp_model.CpModel()&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Data.&#xA;&#xA;job_durations = [10, 10, 10, 30, 30, 30, 50, 50, 50]&#xA;&#xA;release_dates = [0, 0, 0, 0, 0, 0, 0, 0, 0]&#xA;&#xA;due_dates = [1200, 1200, 1200, 1800, 1800, 1800, 2400, 2400, 2400]&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Helper data.&#xA;num_jobs = len(job_durations)&#xA;all_jobs = range(num_jobs)&#xA;&#xA;# True is job of 'job_id' is scheduled, false otherwise.&#xA;x = [model.NewBoolVar(f'x_{job_id}') for job_id in all_jobs]&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Set big enough horizon value.&#xA;horizon = max(due_dates)&#xA;print('Horizon =', horizon)&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Global storage of variables.&#xA;intervals = []&#xA;starts = []&#xA;ends = []&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Scan the jobs and create the relevant variables and intervals.&#xA;for job_id in all_jobs:&#xA;    duration = job_durations[job_id]&#xA;    release_date = release_dates[job_id]&#xA;    due_date = due_dates[job_id] if due_dates[job_id] != -1 else horizon&#xA;    print('job %2i: start = %5i, duration = %4i, end = %6i' %&#xA;          (job_id, release_date, duration, due_date))&#xA;    name_suffix = '_%i' % job_id&#xA;    start = model.NewIntVar(release_date, due_date, 's' + name_suffix)&#xA;    end = model.NewIntVar(release_date, due_date, 'e' + name_suffix)&#xA;    interval = model.NewOptionalIntervalVar(start, duration, end, x[job_id], 'i' + name_suffix)&#xA;    starts.append(start)&#xA;    ends.append(end)&#xA;    intervals.append(interval)&#xA;&#xA;# No overlap constraint.&#xA;model.AddNoOverlap(intervals)&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Transition times using a circuit constraint.&#xA;arcs = []&#xA;&#xA;# No job scheduled.&#xA;empty_lit = model.NewBoolVar('empty_lit')&#xA;arcs.append([0, 0, empty_lit])&#xA;&#xA;for i in all_jobs:&#xA;    # Initial arc from the dummy node (0) to a job.&#xA;    start_lit = model.NewBoolVar('')&#xA;    arcs.append([0, i + 1, start_lit])&#xA;&#xA;    # If this job is the first, set to minimum starting time.&#xA;    model.Add(starts[i] == release_dates[i]).OnlyEnforceIf(start_lit)&#xA;&#xA;    # Job is scheduled if the graph starts with it.&#xA;    model.AddImplication(start_lit, x[i])&#xA;&#xA;    # Final arc from an arc to the dummy node.&#xA;    arcs.append([i + 1, 0, model.NewBoolVar('')])&#xA;&#xA;    # Add 'x[job_id].Not()' literal to each node&#xA;    arcs.append([i + 1, i + 1, x[i].Not()])&#xA;&#xA;    # Link empty_lit and x[i]&#xA;    model.AddImplication(empty_lit, x[i].Not())&#xA;&#xA;    # Fix start and end for unperformed jobs.&#xA;    model.Add(starts[i] == release_dates[i]).OnlyEnforceIf(x[i].Not())&#xA;&#xA;    for j in all_jobs:&#xA;        if i == j:&#xA;            continue&#xA;&#xA;        lit = model.NewBoolVar('%i follows %i' % (j, i))&#xA;        arcs.append([i + 1, j + 1, lit])&#xA;&#xA;        # Force gaps between tasks of same jobs.&#xA;        model.Add(starts[j] &amp;gt;= ends[i]).OnlyEnforceIf(lit)&#xA;&#xA;        # job[i] and job[j] are scheduled if they are successively scheduled by the solver.&#xA;        model.AddImplication(lit, x[i])&#xA;        model.AddImplication(lit, x[j])&#xA;&#xA;model.AddCircuit(arcs)&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Objective.&#xA;makespan = model.NewIntVar(min(release_dates), horizon, 'makespan')&#xA;for i in all_jobs:&#xA;    model.Add(makespan &amp;gt;= ends[i]).OnlyEnforceIf(x[i])&#xA;model.Maximize(makespan)&#xA;&#xA;# ----------------------------------------------------------------------------&#xA;# Solve.&#xA;solver = cp_model.CpSolver()&#xA;# solver.parameters.max_time_in_seconds = 60 * 60 * 2&#xA;solver.parameters.enumerate_all_solutions = True&#xA;# solver.parameters.num_search_workers = 6&#xA;solver.Solve(model)&#xA;print(solver.ResponseStats())&#xA;for job_id in all_jobs:&#xA;    if solver.BooleanValue(x[job_id]):&#xA;        print(&#xA;            f'job {job_id} starts at {solver.Value(starts[job_id])} and ends at {solver.Value(ends[job_id])}'&#xA;        )&#xA;    else:&#xA;        print(f'job {job_id} is not scheduled')&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10139" LastEditorUserId="981" LastEditDate="2023-02-19T14:43:45.893" LastActivityDate="2023-02-19T14:43:45.893" Title="CP-SAT solver doesn't use all space available for scheduling" Tags="|scheduling|constraint-programming|or-tools|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8897" PostTypeId="2" ParentId="8896" CreationDate="2022-08-15T23:39:29.867" Score="2" Body="&lt;p&gt;Once again, the objective does not incentive scheduling tasks. So you rely on the randomness of the multi threaded search&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2022-08-15T23:39:29.867" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8898" PostTypeId="2" ParentId="8892" CreationDate="2022-08-15T23:54:46.327" Score="8" Body="&lt;p&gt;I suspect that the answer to your question hinges more on how you understand the word &lt;em&gt;stochastic&lt;/em&gt; than any particular insight about optimization.&lt;/p&gt;&#xA;&lt;h2&gt;Multiplicity of optima&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;In the example you gave, we have an optimization problem that has &lt;em&gt;multiple optima.&lt;/em&gt;&lt;/strong&gt; This is a fairly common situation in discrete optimization problems such as integer programs; it can also occur in nonlinear programming.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;In designing optimization algorithms, we typically do not concern ourselves with multiple optima.&lt;/strong&gt; There are cases, such as LP, where you can inspect the final tableau and state whether there are multiple optima and provide them upon request, but this is more of a &amp;quot;cool feature&amp;quot; than an &amp;quot;essential requirement&amp;quot; of a solution algorithm.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;So, why aren't multiple optima a big deal?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Well, if you made your objective function correctly—that is, if it truly orders the feasible solutions according to your preferences—then &lt;strong&gt;if a problem has multiple optima, you are &lt;em&gt;by definition indifferent&lt;/em&gt; between them.&lt;/strong&gt; Therefore, it &lt;em&gt;shouldn't&lt;/em&gt; matter to you whether the solver produces any one of the multiple optima, or selects randomly from among them, or picks the highest one according to a lexicographical tiebreaking rule like you proposed, or something else.&lt;/p&gt;&#xA;&lt;h2&gt;Viewing multiple optima stochastically&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;In general, the &amp;quot;solution&amp;quot; to an optimization problem is the set of solutions that provide the optimal objective function value.&lt;/strong&gt; This set can be empty, or have multiple elements, or be a singularity. Only if it is a singularity do we say that the problem has a unique optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;You argue that &lt;strong&gt;when the optimal solution set has many elements, we can &amp;quot;view&amp;quot; this set stochastically. But this is true only inasmuch as we can view &lt;em&gt;any&lt;/em&gt; set stochastically,&lt;/strong&gt; namely, by imposing a probability distribution over its elements and claiming that we can sample from it, calculate its CDF, etc. The question you should ponder is, &lt;strong&gt;What do we stand to gain by introducing these additional parameters?&lt;/strong&gt; More specifically:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What probability distribution over the optima makes sense?&lt;/li&gt;&#xA;&lt;li&gt;Do you want a solver to actually do this random sampling? How? Why?&lt;/li&gt;&#xA;&lt;li&gt;Is a random sample from the optimal solution set preferable, in some sense, to a specific or arbitrarily chosen element of the optimal solution set?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;If the answer to the last question is &lt;em&gt;yes,&lt;/em&gt; then I would suggest that there is a more fundamental issue with your optimization model:&lt;/strong&gt; You have defined the feasible solution set and/or objective function in a way that does not truly incorporate all of your preferences.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;One situation where multiple optima may be meaningful&lt;/h2&gt;&#xA;&lt;p&gt;One application of optimization is Lagrangian mechanics: By the laws of physics, systems tend to come to rest in the position that minimizes their potential energy, and this equilibrium state can therefore be modeled as an optimization problem. But the &lt;em&gt;process&lt;/em&gt; by which the system equilibrates is, essentially, random: Random perturbations to the system knock it this way and that until it converges to a stable state. So, &lt;em&gt;if&lt;/em&gt; a mechanical system has multiple equilibria, it may be meaningful to talk about the probability with which it attains each equilibrium according to the kinds of random perturbation present in the environment.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, real-world systems are continuous, rather than discrete, and therefore the odds of having two solutions with &lt;em&gt;exactly&lt;/em&gt; the same optimal potential energy is vanishingly rare. A more typical outcome would be that the potential energy is nonconvex in the parameters, and there are multiple local optima which can still represent an equilibrium state. Enumeration the local optima of a nonconvex problem is an hard problem in its own right, before we even get to speculating about the probability with which each equilibrium arises.&lt;/p&gt;&#xA;&lt;p&gt;(I am not a physicist, so I invite any edits that improve the terminology used here.)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Randomized rounding&lt;/h2&gt;&#xA;&lt;p&gt;This isn't really related to the ideas above, but because you brought up the knapsack problem, it is worth mentioning that one heuristic for solving integer programs is to solve the LP relaxation and treat the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;s as probability values for Bernoulli variables.&lt;/p&gt;&#xA;&lt;p&gt;By randomly sampling these variables, we can sometimes generate a &amp;quot;pretty good&amp;quot; solution (but, of course, there is no guarantee that it will be optimal or even feasible). But this is different from your example, because you are proposing choosing randomly from among integer solution vectors, whereas the randomized rounding heuristic chooses the &lt;em&gt;elements&lt;/em&gt; of the solution vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; randomly and independently.&lt;/p&gt;&#xA;" OwnerUserId="4463" LastEditorUserId="4463" LastEditDate="2022-08-16T12:04:30.393" LastActivityDate="2022-08-16T12:04:30.393" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8899" PostTypeId="1" AcceptedAnswerId="8919" CreationDate="2022-08-16T09:50:20.883" Score="5" ViewCount="331" Body="&lt;p&gt;Suppose I am minimizing a MILP and my objective is simply &lt;span class=&quot;math-container&quot;&gt;$\sum_i{x_i}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is binary. I also have a constraint saying that &lt;span class=&quot;math-container&quot;&gt;$1-\sum_j y_j = x_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall i \in \mathcal{S}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall j \in \mathcal{S}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}$&lt;/span&gt; is the set defining the indices of my variables and &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; is binary. I have many other constraints on &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;, but none other on &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;. Basically, &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is going to be 1 (and contribute to the cost function) whenever &lt;span class=&quot;math-container&quot;&gt;$\sum_j y_j$&lt;/span&gt; is not 1. Note that I have other constraints that force &lt;span class=&quot;math-container&quot;&gt;$\sum_j y_j \leq 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Does it make sense to replace &lt;span class=&quot;math-container&quot;&gt;$1-\sum_j y_j = x_i$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$1-\sum_j y_j \leq x_i$&lt;/span&gt;? Where by &amp;quot;make sense&amp;quot; I mean would the solver solve the problem more quickly by replacing the equality constraint by an inequality one?&lt;/p&gt;&#xA;&lt;p&gt;Of course, with the inequality constraint, &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; can be either 1 or 0 even when &lt;span class=&quot;math-container&quot;&gt;$\sum_j y_j$&lt;/span&gt; is 1. However, since &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; appears in the cost function and I'm minimizing, the solver would push &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; to 0 if &lt;span class=&quot;math-container&quot;&gt;$\sum_j y_j =1$&lt;/span&gt;, so we would still get the desired value for &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10208" LastEditorUserId="10208" LastEditDate="2022-08-16T14:36:50.730" LastActivityDate="2022-08-20T12:50:04.860" Title="Should I replace equality constraints by inequality constraints if the variables in the constraint appear in the objective?" Tags="|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8900" PostTypeId="2" ParentId="8892" CreationDate="2022-08-16T10:33:40.830" Score="1" Body="&lt;p&gt;As &lt;a href=&quot;https://or.stackexchange.com/users/4463/max&quot;&gt;@Max&lt;/a&gt; suggested, the answer depends on how we understand the word stochastic. For example, &lt;a href=&quot;https://twitter.com/page_eco/status/1558815679952093184&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lionel Pages pleads&lt;/a&gt; for the subjectivity of stochasticity, pointing at an ongoing scholarly debate.&lt;/p&gt;&#xA;&lt;p&gt;In the case of a complex optimization problem, in which several solutions exist, as &lt;a href=&quot;https://or.stackexchange.com/users/2479/gabriel-gouvine&quot;&gt;@Gabriel Gouvine&lt;/a&gt; said, we could sample the solution space - of solutions fulfilling our criteria - and from that deduce the probability of each solution, or solution value. However, the probabilities are only known after we solved the problem.&lt;/p&gt;&#xA;&lt;p&gt;Enumerating solutions and taking the probability of each solution is the frequentist way to understand stochasticity.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, we can understand stochasticity as &lt;em&gt;subjective&lt;/em&gt;, as a measure of uncertainty.&lt;/p&gt;&#xA;&lt;p&gt;In the case of a complex optimization problem, in which just one solution exists, the solution is already determinded, even if we are not able to know it before using a sophisticated solver.&lt;/p&gt;&#xA;&lt;p&gt;In this case, the verdict to call the solution stochastic or not depends on our judgement, if we regard subjective indeterminism as subjective stochasticality or not.&lt;/p&gt;&#xA;&lt;p&gt;If we don't accept subjective indeterminism as stochastic, the verdict to call a solution stochastic depends on the stochasticity of the solver as a random process and on the existance of several solutions. Because if there is just one solution, which is found by a random solver, it was still determined before finding it. In general, we don't know the number of solutions before solving the problem. Right now, I understand that we can only consider the unknown result of an optimization as stochastic, if we accept subjective indeterminism.&lt;/p&gt;&#xA;" OwnerUserId="1008" LastActivityDate="2022-08-16T10:33:40.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8901" PostTypeId="1" CreationDate="2022-08-16T13:51:32.673" Score="3" ViewCount="173" Body="&lt;p&gt;Is someone maintaining a repository of optimization problems for practice or homework problems?&lt;/p&gt;&#xA;&lt;p&gt;I've been talking to a few people lately who are working on building links between academia and industry. It would be nice if it was easy to access a wide variety of optimization problems that could be used for educational purposes-- the definition of the problem, the data, and maybe some answers.&lt;/p&gt;&#xA;&lt;p&gt;I know there are various sources like the Paul Williams book and &lt;a href=&quot;https://or.stackexchange.com/questions/1442/case-studies-and-real-problems-for-teaching-optimization-and-modelling&quot;&gt;this previous question&lt;/a&gt;.  But, I was curious if anyone was pulling all these sources together?&lt;/p&gt;&#xA;&lt;p&gt;If no one has done this, this might be a good project and would benefit our community.&lt;/p&gt;&#xA;" OwnerUserId="191" LastEditorUserId="36" LastEditDate="2022-08-16T16:19:27.137" LastActivityDate="2022-08-18T14:05:04.103" Title="A repository of optimization problems for educational purposes?" Tags="|optimization|teaching|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8902" PostTypeId="1" CreationDate="2022-08-16T16:47:11.030" Score="2" ViewCount="205" Body="&lt;p&gt;I am looking for a practical method to find a valid upper bound for the infinity norm of the solution to a standard linear optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad c^\top x \\&#xA;\text{s.t.}&amp;amp;\quad Ax = b\\&#xA;&amp;amp;\quad x \ge 0,\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x,c \in \mathbb{R}^n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b\in\mathbb{R}^m$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A\in \mathbb{R}^{m\times n}$&lt;/span&gt;.&#xA;We can also assume that the final precision and optimality gap is &lt;span class=&quot;math-container&quot;&gt;$\epsilon = 10^{-6}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="622" LastEditorUserId="622" LastEditDate="2022-08-16T22:29:17.857" LastActivityDate="2022-08-17T14:21:57.043" Title="An upper bound for the norm of solution to linear optimization problem" Tags="|optimization|linear-programming|interior-point-method|primal|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8903" PostTypeId="2" ParentId="8902" CreationDate="2022-08-17T14:21:57.043" Score="3" Body="&lt;p&gt;Unless I misunderstand your problem you can get a bound on the norm of x by finding upper bounds for each component of x.&lt;/p&gt;&#xA;&lt;p&gt;You can use primal and dual bound tightening to get upper bounds on each x. This is not necessarily possible for all problems but will work in many cases. Even better if your optimization problem has upper bounds already (in your formulation, as part of the matrix).&lt;/p&gt;&#xA;&lt;p&gt;One paper typically referenced is Savelsberg: &amp;quot;Preprocessing and probing techniques for mixed integer programming problems&amp;quot; in the context of MILP. Tobias Achterberg's thesis has both primal and dual bound tightening spelled out (called constraint propagation there) and more references, but also in the context of MILP.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2022-08-17T14:21:57.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8904" PostTypeId="1" CreationDate="2022-08-17T15:37:12.933" Score="4" ViewCount="1819" Body="&lt;p&gt;I have been using GAMS for several years, and I would like to do my new research in Python programming language. It is simple to do coding stuff in GAMS, however, it takes much time in complex optimization models.&lt;/p&gt;&#xA;&lt;p&gt;I usually do NLP and MILP.&lt;/p&gt;&#xA;" OwnerUserId="10219" LastEditorUserId="491" LastEditDate="2022-08-17T17:23:39.670" LastActivityDate="2022-08-23T11:25:05.547" Title="Is it better to use GAMS or Python for Optimization Models?" Tags="|optimization|python|gams|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8905" PostTypeId="2" ParentId="8904" CreationDate="2022-08-17T15:52:27.837" Score="4" Body="&lt;p&gt;Python is a programming language that needs a library to model problems. Pyomo is a good option. Here is a good comparison between modeling in Pyomo and GAMS: &lt;a href=&quot;http://yetanothermathprogrammingconsultant.blogspot.com/2021/08/a-network-model-pyomo-vs-gams.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://yetanothermathprogrammingconsultant.blogspot.com/2021/08/a-network-model-pyomo-vs-gams.html&lt;/a&gt;.&#xA;Which is better is something a bit subjective, and it will depend on what your research is about.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastEditorUserId="10165" LastEditDate="2022-08-17T15:57:31.947" LastActivityDate="2022-08-17T15:57:31.947" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8906" PostTypeId="1" CreationDate="2022-08-17T16:41:24.027" Score="1" ViewCount="100" Body="&lt;p&gt;Can someone tell me what is the meaning of this multi commodity flow formulation that I got in LINGO ? I have the brief explanation about the model but don't quite understand the logic behind, here is the information and the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Decision Variable:&#xA;Flo( i, j, c, k) = amount of commodity destined for node c, &#xA;                      carried from node i to node j on vehicle type k; &#xA;&#xA;! Model multi-commodity flow;&#xA;! Cannot have flow within a single node;&#xA;  @FOR( Set( j) :&#xA;     @SUM( Vehicle( k): @SUM( Set( c): Flo( j, j, c, k))) = 0;&#xA;    );&#xA;&#xA;! Flow into node j of commodity c = demand for c at j + flow out;&#xA;@FOR( Vehicle( k):&#xA;  @FOR( Set( j) | j #NE# Depot:&#xA;    @FOR( Set( c) | c #NE# j #AND# c #NE# Depot:&#xA;   [CFLO]  @SUM( Set( i) | i #NE# j: Flo( i, j, c, k)) =&#xA;           @SUM( Set( i) | i #NE# j: Flo( j, i, c, k)) &#xA;        );&#xA;      );&#xA;    );&#xA;&#xA;  @FOR( Set( j) | j #NE# Depot:&#xA;  ! Flow entering j of commodity for j;&#xA;   [DFLOE]  @SUM( SxSxSxV( i, j, c, k) | i #NE# j #AND# j #EQ# c: Flo( i, j, c, k)) = Demand( j);&#xA;  ! Flow departing j of commodity for j;&#xA;   [DFLOD]  @SUM( SxSxSxV( j, i, c, k) | i #NE# j #AND# j #EQ# c: Flo( j, i, c, k)) = 0;  &#xA;     );&#xA;&#xA;! Only source of supply is the Depot;&#xA; @FOR( Set( c):&#xA;   @SUM( SxSxSxV( i, j, c, k) | i #EQ# Depot: Flo( i, j, c, k)) = Demand( c)&#xA;     );&#xA;&#xA;! Any flow on arc i, j of commodity c means arc i, j, k is used;&#xA;  @FOR( SxSxSxV( i, j, c, k) | j #NE# Depot #AND# c #NE# Depot:&#xA; [FORCE]    Flo( i, j, c, k) &amp;lt;= Demand( c) * x( i, j, k)&#xA;      );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have tested with small nodes of 3:&#xA;Here is what I got:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Selected route: 1 - 3 - 2 - 1 (1 is depot)&lt;br /&gt;&#xA;&lt;code&gt;x(1,3,1) = 1&lt;/code&gt;&lt;br /&gt;&#xA;&lt;code&gt;x(3,2,1) = 1&lt;/code&gt;&lt;br /&gt;&#xA;&lt;code&gt;x(2,1,1) = 1&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;And the flow variables:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Flo(1,3,2,1) = 9&#xA;Flo(1,3,3,1) = 7&#xA;Flo(3,2,2,1) = 9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is the flow not balanced? I mean why is there not have another 7 in there?&lt;/p&gt;&#xA;" OwnerUserId="10000" LastEditorUserId="491" LastEditDate="2022-08-17T17:25:45.423" LastActivityDate="2022-08-18T17:50:33.780" Title="What is the meaning of this multi commodity formulation VRP in LINGO" Tags="|mixed-integer-programming|integer-programming|vehicle-routing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8907" PostTypeId="2" ParentId="638" CreationDate="2022-08-17T20:18:49.490" Score="2" Body="&lt;p&gt;I've seen several researchers using the NAUTY package to generate all graphs of a given size:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://pallini.di.uniroma1.it/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pallini.di.uniroma1.it/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-08-17T20:18:49.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8908" PostTypeId="1" CreationDate="2022-08-18T10:52:32.977" Score="2" ViewCount="240" Body="&lt;p&gt;I found a solution for just one term &lt;a href=&quot;https://stackoverflow.com/questions/36398506/linear-programming-absolute-value-greater-than-a-constant&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can we formulate constraints of the form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^n |x_i -a_i| \ge K $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;in Mixed Integer Linear Programming ?&lt;/p&gt;&#xA;" OwnerUserId="3256" LastEditorUserId="491" LastEditDate="2022-08-18T12:28:57.113" LastActivityDate="2022-08-25T09:30:38.887" Title="How to write constraint with sum of absolutes in Integer Programming?" Tags="|mixed-integer-programming|linear-programming|integer-programming|linearization|absolute-value|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8909" PostTypeId="2" ParentId="8765" CreationDate="2022-08-18T13:52:02.967" Score="3" Body="&lt;p&gt;&lt;strong&gt;Isn't it strange that the CPU time increases?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Imagine we are solving&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_x c^Tx$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A_nx\geq0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$A_0$&lt;/span&gt; is a zero matrix the problem simplifies after trivial presolving to &lt;span class=&quot;math-container&quot;&gt;$\min_x c^Tx$&lt;/span&gt;. If we change up &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$A_1(1,2) = A_1(1,8) = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_1(2,1) = A_1(2,5) = 1$&lt;/span&gt;. After presolving the problem now looks like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_x c^Tx \\&#xA;1x_2 + 1x_8\geq0 \\&#xA;1x_1 + 1x_5\geq0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So by making &lt;span class=&quot;math-container&quot;&gt;$A_n$&lt;/span&gt; contain less zeros can effectively increase the number of constraints after presolving. So an increase of compute time with the number of iteration is not suprising. If this effect is the case in your problem, the problem size after presolving should increase.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: Same thing could apply to the objective where less zeros in &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; means less variables eliminated during presolving or more non trivial symmetries in the problem which can not be removed during presolving.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2022-08-19T15:07:51.387" LastActivityDate="2022-08-19T15:07:51.387" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8910" PostTypeId="2" ParentId="8901" CreationDate="2022-08-18T14:05:04.103" Score="2" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://miplib.zib.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIPLIB&lt;/a&gt; for MILP problems&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://qplib.zib.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;QPLIB&lt;/a&gt; for QP problems&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ekhoda/optimization_problem_libraries&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ekhoda/optimization_problem_libraries&lt;/a&gt; contains references to many other problem collections&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;those are not specially for teaching and already formulated but many are licensed so they could be used in teaching. It honestly depends on what you want to teach.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-08-18T14:05:04.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8911" PostTypeId="2" ParentId="8906" CreationDate="2022-08-18T17:50:33.780" Score="1" Body="&lt;p&gt;Flo(i,j,c,k) is the amount of flow destined for node c that is carried by vehicle k from node i to node j. So Flo(1,3,3,1) is the amount &lt;em&gt;destined for node 3&lt;/em&gt; that is carried on vehicle 1 from node 1 to node 3. Since node 3 is its destination, there is no reason for it to be carried out of node 3.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-18T17:50:33.780" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8912" PostTypeId="1" CreationDate="2022-08-19T07:39:40.737" Score="2" ViewCount="138" Body="&lt;p&gt;Consider the following two functions:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y_t = e^{lt} \cdot e^{st} \cdot \prod_{p=0}^{n} x_{tp}^{b_{tp}}\tag1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$e^{lt}$&lt;/span&gt; captures the trend, &lt;span class=&quot;math-container&quot;&gt;$e^{st}$&lt;/span&gt; captures the seasonality and &lt;span class=&quot;math-container&quot;&gt;$x_{tp}$&lt;/span&gt; is our variable of interest, &lt;span class=&quot;math-container&quot;&gt;$0\le b_{tp}\le1$&lt;/span&gt; is the exponent for our variable of interest and is time-varying as all the other variables in the equation.&lt;/p&gt;&#xA;&lt;p&gt;Now consider this function below which is the loglog model of the previously stated multiplicative model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\ln(_) =  +  + \sum_{p=0}^{n} \ln(x_{tp})\cdot{b_{tp}}\tag2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now consider these two functions being goal-functions in an optimization problem where we want to optimize over some horizon &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; by deciding on &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt;-values.&lt;/p&gt;&#xA;&lt;p&gt;In the first case both &lt;span class=&quot;math-container&quot;&gt;$lt$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$st$&lt;/span&gt; interacts with the decision variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; but in the latter case they have zero interaction with &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To put this into a context:&#xA;I want to find &lt;span class=&quot;math-container&quot;&gt;$l_t, s_t, b_{tp}$&lt;/span&gt; by regressing function (1) on historic data spanning &lt;span class=&quot;math-container&quot;&gt;$[(t-n)....t]$&lt;/span&gt;(t is our current timestep and n is the nr of datapoints available) and then forecast these coefficients over the horizon &lt;span class=&quot;math-container&quot;&gt;$[t....t+H]$&lt;/span&gt; to be able to maximize the cumulative reward&lt;span class=&quot;math-container&quot;&gt;$(Y)$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; over the horizon. Since function 1 is not linear w.r.t parameters we log it to be able to perform OLS or such. Now we end up with function 2, lets say i perform the ols on this and retrieve &lt;span class=&quot;math-container&quot;&gt;$l_t, s_t, b_{tp}$&lt;/span&gt;, now i have to plug them back into function 1 right because keeping them in the logged form misses out on the interactions?&#xA;Do anyone see any issues with the above stated algorithm?&lt;/p&gt;&#xA;&lt;p&gt;An more extensive description of the whole problem is given at: &lt;a href=&quot;https://stats.stackexchange.com/questions/586144/understanding-log-transformations-implications-on-optimization-problems&quot;&gt;https://stats.stackexchange.com/questions/586144/understanding-log-transformations-implications-on-optimization-problems&lt;/a&gt;&#xA;where i more mathematically rigorously describe the whole context. This topis is probably better suited here since it focuses on the optimization part of the wider given context in the topic in the stats-forum.&lt;/p&gt;&#xA;&lt;p&gt;What am I missing out here?&lt;/p&gt;&#xA;" OwnerUserId="10229" LastEditorUserId="10229" LastEditDate="2022-08-20T12:08:05.053" LastActivityDate="2022-08-20T12:08:05.053" Title="Loglog transformation of optimization problem, how can the solution be equal to the nontransformed counterpart?" Tags="|optimization|reformulation-linearization|regression|time-series|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8913" PostTypeId="2" ParentId="8912" CreationDate="2022-08-19T12:51:32.290" Score="1" Body="&lt;p&gt;If you consider only one &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, you can ignore the positive constant multiplier because optimizing &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; is equivalent to optimizing &lt;span class=&quot;math-container&quot;&gt;$k_t y_t$&lt;/span&gt; (or its log) for positive constant &lt;span class=&quot;math-container&quot;&gt;$k_t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But it sounds like you want to optimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{t\in T} y_t$&lt;/span&gt;, in which case the log transformation does not preserve optimality because &lt;span class=&quot;math-container&quot;&gt;$\log$&lt;/span&gt; does not commute with &lt;span class=&quot;math-container&quot;&gt;$\sum$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-08-19T12:51:32.290" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8914" PostTypeId="2" ParentId="638" CreationDate="2022-08-19T13:59:05.360" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;https://www.gerad.ca/Gilles.Caporossi/GIG/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GraphsInGraphs&lt;/a&gt; contains a database of all undirected graphs with up to 10 nodes, and code to generate larger ones. One of the original goals was to detect sub-graphs and isomorphisms.&lt;/p&gt;&#xA;&lt;p&gt;You can find the mathematical background here: &lt;a href=&quot;https://www.gerad.ca/fr/papers/G-2016-10&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gerad.ca/fr/papers/G-2016-10&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2022-08-19T13:59:05.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8915" PostTypeId="1" CreationDate="2022-08-19T22:29:50.093" Score="6" ViewCount="222" Body="&lt;p&gt;Some solvers like Gurobi can handle mixed-integer quadratically-constrained quadratic models regardless of their nonconvexity. I have some experience that Gurobi can handle instances of the max &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-cut problem with nonconvex objective function better than the linearized version of the formulation.&lt;/p&gt;&#xA;&lt;p&gt;My question is, when should we avoid linearizing those quadratic terms?&lt;/p&gt;&#xA;" OwnerUserId="622" LastEditorUserId="622" LastEditDate="2022-08-20T03:16:59.260" LastActivityDate="2022-08-23T14:20:44.580" Title="When should we avoid linearizing a quadratic term?" Tags="|optimization|combinatorial-optimization|linearization|quadratic-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8916" PostTypeId="1" CreationDate="2022-08-20T07:33:43.627" Score="3" ViewCount="56" Body="&lt;p&gt;In a cutting plane algorithm for integer linear programming problems you would usually use an LP solver to get an extreme point of the polyhedron corresponding to the LP relaxation. Let's call that solution &lt;span class=&quot;math-container&quot;&gt;$x^1$&lt;/span&gt;. Then you would use some kind of oracle that would tell you that &lt;span class=&quot;math-container&quot;&gt;$x^1$&lt;/span&gt; is in the convex hull of integer solutions or produce a cutting plane &lt;span class=&quot;math-container&quot;&gt;$\pi x\leq\pi_0$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\pi x^1&amp;gt;\pi_0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering what could be done if one has two LP solutions at hand? Say &lt;span class=&quot;math-container&quot;&gt;$x^1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$x^1\neq x^2$&lt;/span&gt;. An obvious starting point is to separate a convex combination of the two points, &lt;span class=&quot;math-container&quot;&gt;$x_\lambda=\lambda x^1+(1-\lambda)x^2$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$x_\lambda$&lt;/span&gt; can be separated, at least one of the two original points will be separated by the same hyperplane. But can more be done? Has research been done on separating more than one point at a time using a single inequality?&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-08-20T07:33:43.627" Title="Separating two LP solutions at the same time" Tags="|mixed-integer-programming|branch-and-cut|cutting-planes|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8917" PostTypeId="2" ParentId="919" CreationDate="2022-08-20T12:09:37.667" Score="5" Body="&lt;p&gt;As another interesting source, Recently &lt;a href=&quot;https://www.gurobi.com/lp/academics/burrito-optimization-game/&quot; rel=&quot;noreferrer&quot;&gt;Burrito optimization game&lt;/a&gt; was developed by Larry Snyder and implemented by Gurobi optimization software that is a web-based app that is intended to act as an entry point for data scientists and problem solvers who could benefit from optimization.&lt;/p&gt;&#xA;&lt;p&gt;The game teaches players why optimization is valuable and important, why it’s difficult (by showcasing the scaling and added complexity of optimization throughout the round play), and why solvers and other optimization algorithms are essential in finding an optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;It has very fun gameplay and you as a player should plan where to place the burrito trucks to serve hungry customers throughout the city and maximize the profit. (Thanks @LarrySnyder610 for the great contribution to that).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5yO67.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5yO67.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-08-20T12:09:37.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8918" PostTypeId="2" ParentId="8915" CreationDate="2022-08-20T12:35:23.203" Score="3" Body="&lt;p&gt;I have a problem where &lt;a href=&quot;https://or.stackexchange.com/questions/7286/linearize-product-of-x-cdot-y-text-with-x-y-in-1-0-1-for-milp&quot;&gt;all the products over {-1,0,1}&lt;/a&gt;. I can rephrase the products in terms of binary variables. This turned out to be way more performant and interacted better with symmetry breaking constraints i introduce. In general if there exist a non trivial linear relaxation which is tight, use that linear relaxation. Using linear relaxations also allows you to run it on others solvers which can be faster for certain problems or lead to insights about the problem.&lt;/p&gt;&#xA;&lt;p&gt;You have to try both, see what works better. In case there is heterogeneity in your model, you might even want to try a combinations of both. As rules of thumb:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If it is a product of more than one continuous variable always leave those to Gurobi.&lt;/li&gt;&#xA;&lt;li&gt;Tighter bounds are particularly valuable in the objective, so linearising might hurt performance by making the branch and bound tree a lot bigger&lt;/li&gt;&#xA;&lt;li&gt;If finding an initial integer valued solution with not linearized products takes a long time, remove the objective if it is non linear and consider trying different linearizations of constraints involving products of integers of bounded range. Use this solution (or a feasible solution found by it) to warm start the non-linear solve.&lt;/li&gt;&#xA;&lt;li&gt;Mixed Integer solvers are fickle beasts. If the domain changes, always revisit your assumption. While you can almost always trust the result, you have to verify the performance if the compute is expensive enough to be worth your time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-08-20T12:35:23.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8919" PostTypeId="2" ParentId="8899" CreationDate="2022-08-20T12:50:04.860" Score="3" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Would the solver solve the problem more quickly by replacing the equality constraint by an inequality one?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;That depends. There are reasons why a solver could as the simplex might be smaller. There are reason why a solver might slow down. The &amp;quot;weaker&amp;quot; inequality constraint could break some presolving transformation.&lt;/p&gt;&#xA;&lt;p&gt;Here are things i would look out for:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;compare size of problem after presolving&lt;/li&gt;&#xA;&lt;li&gt;time taken to solve&lt;/li&gt;&#xA;&lt;li&gt;time per lp relaxtion&lt;/li&gt;&#xA;&lt;li&gt;number of nodes explored till the solution is found&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If the system after presolving is the same, it does not matter. A proxy for that is the size of the system. You ultimately care about the time it takes to solve. Differences in time per lp relaxtion and  number of nodes explored till the solution is found can give you insight how the model will perform if you solve a larger problem.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-08-20T12:50:04.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8920" PostTypeId="2" ParentId="8869" CreationDate="2022-08-20T13:04:47.523" Score="2" Body="&lt;p&gt;Products of binary variables can be expressed as the logical and operation. The MILP formulation of that introduces a new binary variable. We overcome &amp;quot;non linearity&amp;quot; by having more dimensions and formulating a linear constraint in those higher dimension that when projected onto the original variables captures the non-linearity. Here is an example involving &lt;a href=&quot;https://or.stackexchange.com/questions/7286/linearize-product-of-x-cdot-y-text-with-x-y-in-1-0-1-for-milp&quot;&gt;a product of {-1,0,1}&lt;/a&gt; originally we had 2 variables in {-1,0,1}. We introduced another variable so we had 3 variables in {-1,0,1}. Then we expressed those variables in {-1,0,1} as the difference of two booleans. So we went from the &lt;span class=&quot;math-container&quot;&gt;$\mathbb{Z}^2$&lt;/span&gt; to the &lt;span class=&quot;math-container&quot;&gt;$\mathbb{Z}^6$&lt;/span&gt; but got rid of all the non-linearity.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-08-20T13:04:47.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8921" PostTypeId="1" AcceptedAnswerId="8923" CreationDate="2022-08-21T10:57:26.730" Score="2" ViewCount="459" Body="&lt;p&gt;I am using the Google API Distance Matrix (mode 'driving') in an optimization program. If I run the program twice a day (e.g. in the morning and in the afternoon), I sometimes get different solutions. Since the Google API Distance Matrix is the only input besides my hard-coded input, I was wondering if the distance requests always return the same standardized distances or if the distances include current traffic etc. as well. Unfortunately I couldn't find anything that specific in the developers documentation.&lt;/p&gt;&#xA;&lt;p&gt;Can somebody quickly answer my question?&lt;/p&gt;&#xA;" OwnerUserId="10098" LastEditorUserId="491" LastEditDate="2023-04-06T12:13:59.293" LastActivityDate="2023-04-06T12:13:59.293" Title="Google API Distance Matrix" Tags="|api|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8922" PostTypeId="1" AcceptedAnswerId="8924" CreationDate="2022-08-21T11:25:29.500" Score="-4" ViewCount="456" Body="&lt;p&gt;Invalid constraint expression. The constraint expression resolved to a trivial Boolean (True) instead of a Pyomo object. Please modify your rule to return Constraint.Feasible instead of True.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/6FKvV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6FKvV.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10146" LastEditorUserId="10146" LastEditDate="2022-08-22T07:09:37.380" LastActivityDate="2022-08-22T08:21:41.303" Title="Pyomo - ConstriantList" Tags="|pyomo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8923" PostTypeId="2" ParentId="8921" CreationDate="2022-08-21T13:19:48.027" Score="5" Body="&lt;p&gt;The distance depends on the shortest path, which further depends on the departure time from the origin. From the documentation of Distance API [1]&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Note: If departure time is not specified, choice of route and duration are based on road network and average time-independent traffic conditions. Results for a given request may vary over time due to changes in the road network, updated average traffic conditions, and the distributed nature of the service. Results may also vary between nearly-equivalent routes at any time or frequency.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;[1] &lt;a href=&quot;https://developers.google.com/maps/documentation/javascript/distancematrix&quot; rel=&quot;noreferrer&quot;&gt;https://developers.google.com/maps/documentation/javascript/distancematrix&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;To get consistent results, I would advise specifying the &lt;code&gt;departureTime&lt;/code&gt; parameter when calling the API.&lt;/p&gt;&#xA;" OwnerUserId="2424" LastActivityDate="2022-08-21T13:19:48.027" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8924" PostTypeId="2" ParentId="8922" CreationDate="2022-08-22T08:21:41.303" Score="1" Body="&lt;p&gt;It is hard to tell what exactly is going on as your complete model is not visible. A possible cause is that both &lt;span class=&quot;math-container&quot;&gt;$lhs$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$rhs$&lt;/span&gt; are numbers, containing no variables which Python evaluates as a bool. Like &lt;span class=&quot;math-container&quot;&gt;$23 &amp;lt;= 28$&lt;/span&gt;. For debugging i suggest printing &lt;span class=&quot;math-container&quot;&gt;$lhs$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$rhs$&lt;/span&gt; before adding the constraints.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-08-22T08:21:41.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8925" PostTypeId="1" CreationDate="2022-08-22T08:28:41.963" Score="2" ViewCount="209" Body="&lt;p&gt;Due to the answers to &lt;a href=&quot;https://or.stackexchange.com/questions/8845/force-gaps-between-tasks-tasks-are-scheduled-within-their-jobs-time-windows-in&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/questions/8896/cp-sat-solver-doesnt-use-all-space-available-for-scheduling&quot;&gt;this&lt;/a&gt; questions, I was able to find the optimal solution for scheduling problem. However, if there are many tasks that must be scheduled, e.g. 1000+, then the solver takes obviously more time to solve it and OS terminates the program due to RAM lack with the following message: &lt;code&gt;Process finished with exit code 137 (interrupted by signal 9: SIGKILL)&lt;/code&gt;. My PC specs are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OS: Ubuntu 20.04.4 LTS&lt;/li&gt;&#xA;&lt;li&gt;CPU: Intel Core i5-8265U; 4 cores; 8 threads&lt;/li&gt;&#xA;&lt;li&gt;RAM: 32 GB&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;What I've tried first of all is setting the &lt;code&gt;log_search_progress = true&lt;/code&gt; flag and saw that for 1000 jobs the solver creates &lt;code&gt;2000000&lt;/code&gt; literals described in this line: &lt;code&gt;#kBoolAnd: 2000 (#enforced: 2000) (#literals: 2000000)&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The next line: &lt;code&gt;[Symmetry] Problem too large. Skipping. You can use symmetry_level:3 or more to force it.&lt;/code&gt; hints to try to use &lt;code&gt;setSymmetryLevel(3)&lt;/code&gt;. With this set, program will also get terminated. Solver uses all 8 threads available.&lt;/p&gt;&#xA;&lt;p&gt;With this in mind, my question is: should this be run on the server hardware to improve performance or can I optimise the model much better? Talking about the model optimisation, I've found answer of Laurent Perron &lt;a href=&quot;https://github.com/google/or-tools/issues/971&quot; rel=&quot;nofollow noreferrer&quot;&gt;to this issue&lt;/a&gt; that it is a challenge for the solver to schedule so many intervals without decomposition. My team leader suggested that we can firstly take tasks of higher priority jobs, schedule them and then try to schedule those tasks that left. Say, take first 100 tasks of highest priority jobs and initialize their intervals, constraints and circuit between them and solve the problem. If the solution is found, add equalities and hints to the solver to schedule next tasks. What are your thoughts about that?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.online-java.com/PyAHgMCUWN&quot; rel=&quot;nofollow noreferrer&quot;&gt;Full source code in Java&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://textdoc.co/IeygDCOE45ds2ufK&quot; rel=&quot;nofollow noreferrer&quot;&gt;log_search_progress output&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10139" LastEditorUserId="981" LastEditDate="2023-02-19T14:43:16.933" LastActivityDate="2023-02-19T14:43:16.933" Title="RAM overflow when scheduling 1000+ intervals" Tags="|constraint-programming|or-tools|java|cp-sat|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8926" PostTypeId="2" ParentId="8904" CreationDate="2022-08-22T09:56:20.887" Score="2" Body="&lt;p&gt;GAMS is an Algebraic Modeling Language (AML) whereas python is a General Purpose Language (GPL)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/pulse/optimization-aka-prescriptive-analytics-should-we-write-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimization (aka prescriptive analytics) : Should we write the model in a modeling language or a general programming language ?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Plus &lt;a href=&quot;https://medium.com/ibm-data-ai/optimization-simply-do-more-with-less-zoo-buses-and-kids-part2-python-java-c-cc04558e49b5&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; you will see the same very tiny example both in python and GAMS.&lt;/p&gt;&#xA;&lt;p&gt;python:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[from docplex.mp.model import Model&#xA;&#xA;mdl = Model(name='buses')&#xA;nbbus40 = mdl.integer_var(name='nbBus40')&#xA;nbbus30 = mdl.integer_var(name='nbBus30')&#xA;mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;mdl.minimize(nbbus40*500 + nbbus30*400)&#xA;&#xA;mdl.solve(log_output=True,)&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)][3]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;GAMS:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Variable&#xA; cost;Integer Variables&#xA; nbbus40, nbbus30;Equations&#xA; obj, c1;obj.. cost =e= 500 * nbbus40 + 400 * nbbus30;&#xA;c1..  40 * nbbus40 + 30 * nbbus30 =g= 300;option optcr = 1e-3;&#xA;Model buses / all /;&#xA;Solve buses using MIP minimizing cost;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-08-22T09:56:20.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8927" PostTypeId="2" ParentId="8925" CreationDate="2022-08-22T10:35:39.380" Score="2" Body="&lt;p&gt;A stack overflow does not necessarily mean that you ran out of RAM usually being out of RAM throws a &lt;code&gt;java.lang.OutOfMemoryError: Java heap space&lt;/code&gt;. To verify this, check ram usage just before the program dies or temporarily rent server with much more memory and see if that helps. If the program dies but RAM is not full, &lt;a href=&quot;https://www.ibm.com/support/pages/diagnosing-javalangstackoverflowerror&quot; rel=&quot;nofollow noreferrer&quot;&gt;increase the maximum stacksize of the JVM&lt;/a&gt; until the problem vanishes. The stack is a data structure stored in RAM, the JVM limits stack size to prevent an accidental recursion from eating all the RAM on the system as that would adversely affect other services on the same machine. You can increase those limits.&lt;/p&gt;&#xA;&lt;p&gt;The scheduling batches with decreasing priority approach will usually not give you a global optima. Many configurations with equal objective value for higher priorities only can give you very different results down the line as &amp;quot;fragmentation&amp;quot; which will not matter at first will result in not being able fit lower priority tasks between the higher priority tasks unless all tasks have the same length.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kK2qc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kK2qc.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-08-22T10:35:39.380" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8928" PostTypeId="1" CreationDate="2022-08-23T09:50:19.700" Score="4" ViewCount="1406" Body="&lt;p&gt;I am new to Optimization so I think the following question may be very easy, but I'm not sure how to solve it.&lt;/p&gt;&#xA;&lt;p&gt;The dual of an LP is an LP. If we solve the dual LP, we can get the optimal value for the primal problem. But:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;How do we get the optimal decision variables for the primal?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Does it make a difference if we only relax some of the constraints?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Work for Finding Dual of LP&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;&amp;amp;\text{min } &amp;amp;c^Tx \\&#xA;&amp;amp;\text{s.t. } &amp;amp;Ax = b \\&#xA;&amp;amp;&amp;amp;Bx \le d \\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We form the Lagrangian (&lt;span class=&quot;math-container&quot;&gt;$\mu \ge 0$&lt;/span&gt;):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;L(x, \lambda, \mu) &amp;amp;= c^Tx + \lambda^T (Ax - b) + \mu^T (Bx - d) \\&#xA;&amp;amp;= (c + A^T \lambda + B^T \mu)^Tx - \lambda^Tb - \mu^Td&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thus we see that the dual function is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$d(\lambda, \mu) = \inf_x L(x, \lambda, \mu) = &#xA;\begin{cases}&#xA;- \lambda^Tb - \mu^Td \ \ \ &amp;amp;\text{if } \ \ \ c + A^T \lambda + B^T \mu = 0 \\&#xA;- \infty &amp;amp; \text{otherwise}&#xA;\end{cases}$$&lt;/span&gt;&#xA;and therefore the dual problem is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;&amp;amp;\text{max } &amp;amp;-\lambda^Tb - \mu^Td \\&#xA;&amp;amp;\text{s.t. } &amp;amp;c + A^T \lambda + B^T \mu = 0\\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10271" LastEditorUserId="10271" LastEditDate="2022-08-23T15:29:07.723" LastActivityDate="2023-11-13T20:53:31.047" Title="How do you get the primal solution of an LP from the dual solution?" Tags="|optimization|linear-programming|duality|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8929" PostTypeId="2" ParentId="8904" CreationDate="2022-08-23T11:25:05.547" Score="4" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Disclaimer: I work for Gurobi.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;GAMS itself is a modeling language, while Python is a programming language. This means you need a way to write your model using an &lt;a href=&quot;https://en.wikipedia.org/wiki/API&quot; rel=&quot;nofollow noreferrer&quot;&gt;API&lt;/a&gt;. In Python, you actually have two flavors of APIs:&lt;/p&gt;&#xA;&lt;h2&gt;Modeling frameworks&lt;/h2&gt;&#xA;&lt;p&gt;These are &lt;em&gt;solver-agnostic&lt;/em&gt; ways of writing optimization models, similar to what you already have in GAMS. The most popular ones are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pypi.org/project/Pyomo/&quot; rel=&quot;nofollow noreferrer&quot;&gt;pyomo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pypi.org/project/mip/&quot; rel=&quot;nofollow noreferrer&quot;&gt;python-mip&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pypi.org/project/cvxpy/&quot; rel=&quot;nofollow noreferrer&quot;&gt;cvxpy&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pypi.org/project/PuLP/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PuLP&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR-Tools&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Personally, I think that python-mip is the best, closely followed by cvxpy.&lt;/p&gt;&#xA;&lt;h2&gt;Solver-specific APIs&lt;/h2&gt;&#xA;&lt;p&gt;Modeling frameworks offer you solver independence, but there are two potential drawbacks (these may apply to you or not):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Most modeling frameworks only offer a subset of the functionalities that a solver has to offer. For example, Gurobi allows you to formulate &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_general_constraint_help.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;general constraints&lt;/a&gt; (e.g. &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_abs_.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;absolute value&lt;/a&gt;), but these specialized elements are not available in modeling frameworks.&lt;/li&gt;&#xA;&lt;li&gt;Since modeling frameworks cater to several different solvers, they tend to be slower (but not always!) in the model building part compared to solver-specific APIs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;An alternative to modeling frameworks are APIs that the various solvers (Gurobi, Xpress etc.) have to offer. Depending on what your licensing situation is, i.e. whether you have consistent access to a commercial solver, this may be a good alternative.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2022-08-23T11:25:05.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8930" PostTypeId="2" ParentId="8915" CreationDate="2022-08-23T13:16:50.880" Score="3" Body="&lt;p&gt;The answer is that no-one knows - that's largely why quadratic programming is hard in practice.&lt;/p&gt;&#xA;&lt;p&gt;A solver is such a chaotic system that it's no use even trying to predict how such modelling decisions will affect the outcome. Most of the time something works we don't &lt;em&gt;really&lt;/em&gt; know why.&lt;/p&gt;&#xA;&lt;p&gt;My advice is to never linearise yourself &lt;em&gt;prematurely&lt;/em&gt;, as by doing so you are removing information from your model that the solver might be able to exploit. One exception to this rule is if your linearisation is not exact (e.g. you are outer approximating a continuous term). In this case, you are actually telling the solver that you are ok with sacrifising accuracy for that term, which can in turn improve performance. This is not a decision that the solver can make for you, so it needs to come from the modeller.&lt;/p&gt;&#xA;&lt;p&gt;Generally speaking though, high performance solvers are advanced enough that linearising manually should only really be done as a very last resort. I generally advice users to first play around with solver settings before making any such changes to their models.&lt;/p&gt;&#xA;&lt;p&gt;Note the &amp;quot;high performance&amp;quot; here - if you are using a less advanced solver, the situation is different and it becomes more likely that your linearisation might pay off.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2022-08-23T14:20:44.580" LastActivityDate="2022-08-23T14:20:44.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8931" PostTypeId="1" CreationDate="2022-08-23T14:20:57.880" Score="1" ViewCount="74" Body="&lt;p&gt;Based on the color distance function defined &lt;a href=&quot;https://www.compuphase.com/cmetric.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; i try to find &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; RGB colors with large inter set color distances and good color distance to white.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using JuMP&#xA;using Gurobi&#xA;&#xA;m = Model(Gurobi.Optimizer)&#xA;set_optimizer_attribute(m, &amp;quot;NonConvex&amp;quot;, 2)&#xA;&#xA;n = 32;&#xA;&#xA;@variable(m, o&amp;gt;=0);&#xA;&#xA;@variable(m, 0 &amp;lt;= r[1:n] &amp;lt;= 255, Int);&#xA;@variable(m, 0 &amp;lt;= g[1:n] &amp;lt;= 255, Int);&#xA;@variable(m, 0 &amp;lt;= b[1:n] &amp;lt;= 255, Int);&#xA;&#xA;comp = Int(n + (n*(n-1))/2);&#xA;c = 0&#xA;&#xA;@variable(m, rmean[1:comp]);&#xA;@variable(m, rd[1:comp]);&#xA;@variable(m, gd[1:comp]);&#xA;@variable(m, bd[1:comp]);&#xA;&#xA;&#xA;@variable(m, rmeanr[1:comp]);&#xA;@variable(m, rmeanb[1:comp]);&#xA;&#xA;@objective(m, Max, o);&#xA;&#xA;for i in 1:n&#xA;  c += 1&#xA;  color_dist(o, 0.8, 255,255,255, r[i],g[i],b[i], c);&#xA;end&#xA;&#xA;for i in 1:n&#xA;  for j in (i+1):n&#xA;    c += 1&#xA;    color_dist(o, 0.8+0.2*(n-max(i-1,j-1)), r[i],g[i],b[i], r[j],g[j],b[j], c);&#xA;  end&#xA;end&#xA;&#xA;@show m&#xA;&#xA;optimize!(m)&#xA;&#xA;for i in 1:n&#xA;  println(&amp;quot;\&amp;quot;#&amp;quot;,string(Int32(256^2*value(r[i]) + 256*value(g[i]) + 1*value(b[i]) ),base=16,pad=6),&amp;quot;\&amp;quot;,&amp;quot;)&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If i define &lt;code&gt;color_dist&lt;/code&gt; like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function color_diff(o,w,r1,g1,b1,r2,g2,b2,i)&#xA;  @constraint(m, rmean[i] == (r1+r2)/2)&#xA;  @constraint(m, rd[i] == r1 - r2)&#xA;  @constraint(m, gd[i] == g1 - g2)&#xA;  @constraint(m, bd[i] == b1 - b2)&#xA;  &#xA;  @constraint(m, rmeanr[i] == rd[i]*rd[i]) #square&#xA;  @constraint(m, rmeanb[i] == bd[i]*bd[i]) #terms&#xA;&#xA;  @constraint(m,o*o*(w)^2 &amp;lt;= rmeanr[i]*(512+rmean[i])/256 + 4*gd[i]*gd[i] + rmeanb[i]*(767-rmean[i])/256 )&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://pastebin.com/CHEKrvD7&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi (log) performs much better&lt;/a&gt; then if i define it like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function color_dist(o,w,r1,g1,b1,r2,g2,b2,i)&#xA;         @constraint(m, rmean[i] == (r1+r2)/2)&#xA;         @constraint(m, rd[i] == r1 - r2)&#xA;         @constraint(m, gd[i] == g1 - g2)&#xA;         @constraint(m, bd[i] == b1 - b2)&#xA;         &#xA;         @constraint(m, rmeanr[i] == (512+rmean[i])*rd[i]) #bi linear&#xA;         @constraint(m, rmeanb[i] == (767-rmean[i])*bd[i]) #terms&#xA;&#xA;         @constraint(m,o*o*(w)^2 &amp;lt;= rmeanr[i]*rd[i]/256 + 4*gd[i]*gd[i] + rmeanb[i]*bd[i]/256 )&#xA;       end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;as seen in &lt;a href=&quot;https://pastebin.com/LMRaEz0i&quot; rel=&quot;nofollow noreferrer&quot;&gt;this log&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Gurobi after presolving turns all terms into bi-linear terms (as seen in the logs), yet&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (( 512 + \text{rmean}_i ) * \text{rd}_i ) * \text{rd}_i $$&lt;/span&gt;&#xA;has much worse performance then&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(\text{rd}_i * \text{rd}_i ) * ( 512 + \text{rmean}_i)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Does that hold in general according to your experience?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2022-08-23T14:51:56.797" LastActivityDate="2022-08-23T14:51:56.797" Title="Does Gurobi solve QCQMIPs with Quadratic terms faster with then Bi-Linear terms in general?" Tags="|mixed-integer-programming|gurobi|quadratic-programming|nonconvex-programming|jump|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8932" PostTypeId="5" CreationDate="2022-08-23T14:22:43.390" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2022-08-23T14:22:43.390" LastActivityDate="2022-08-23T14:22:43.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8933" PostTypeId="4" CreationDate="2022-08-23T14:22:43.390" Score="0" Body="Questions that use or are about JuMP and other Julia packages." OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2022-08-24T01:23:36.500" LastActivityDate="2022-08-24T01:23:36.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8934" PostTypeId="2" ParentId="8928" CreationDate="2022-08-23T18:28:13.877" Score="6" Body="&lt;p&gt;The duals or shadow prices of the dual model give you a primal solution. See &lt;a href=&quot;http://yetanothermathprogrammingconsultant.blogspot.com/2022/08/primal-dual-and-equilibrium-format-of.html&quot; rel=&quot;noreferrer&quot;&gt;http://yetanothermathprogrammingconsultant.blogspot.com/2022/08/primal-dual-and-equilibrium-format-of.html&lt;/a&gt; for a simple example.&lt;/p&gt;&#xA;" OwnerUserId="907" LastActivityDate="2022-08-23T18:28:13.877" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8935" PostTypeId="1" AcceptedAnswerId="8939" CreationDate="2022-08-24T19:50:26.963" Score="2" ViewCount="107" Body="&lt;p&gt;I'm not sure how I should formulate this question as precisely as possible but at the same time retaining as much specific information as possible but I'll have a go.&lt;/p&gt;&#xA;&lt;p&gt;I have implemented a (Split Delivery Capacitated Vehicle Routing Problem) SDCVRP model for picking operations in a warehouse. That is, customers to be visited are replaced by pick locations to be picked.&lt;/p&gt;&#xA;&lt;p&gt;The model has the following sets, parameters and variables:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ijk}$&lt;/span&gt; is the indicator of travel from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; by forklift &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$v_{ik}$&lt;/span&gt; is the positive integer variable indicating how many items&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{ik}$&lt;/span&gt; is the indicator of visit of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; by forklift &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&#xA;forklift &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; picks up at location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. (Each location has a distinct item).&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$u_{ik}$&lt;/span&gt; a dummy variable used in the MTZ subtour elimination constraints.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}_0$&lt;/span&gt; is the set of all locations, including the depot.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}$&lt;/span&gt; is the set of all pick-locations, excluding the depot.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{K}$&lt;/span&gt; is the set of all forklifts.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$d_{i}$&lt;/span&gt; is the demand at location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. I.e, total number of items &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to be picked.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$w_{i}$&lt;/span&gt; is the weight of item at location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{i}$&lt;/span&gt; is the volume of item at location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is the maximum weight capacity of each forklift.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is the maximum volume capacity of each forklift.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The mathematical model is formulated as follows.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align} &#xA;% objective&#xA;\min_{\boldsymbol{x}, \ (i,j)\in \mathcal{E}, \ k\in\mathcal{K}} \quad &amp;amp; z=\displaystyle\sum_{k\in\mathcal{K}}\displaystyle\sum_{i\in\mathcal{N}_0}\displaystyle\sum_{j\in\mathcal{N}_0}c_{ij}x_{ijk} \\&#xA;\nonumber\\&#xA;% constraints&#xA;\textrm{subject to} \quad &amp;amp; \displaystyle\sum_{i\in\mathcal{N}_0 \\ i\neq p}x_{ipk} - \displaystyle\sum_{i\in\mathcal{N}_0 \\ j\neq p}x_{pjk} = 0, &amp;amp;  p\in \mathcal{N},\quad k\in\mathcal{K} \tag{1}\\&#xA;&amp;amp;u_{ik}+1-|\mathcal{N}_0|(1-x_{ijk}) \le u_{jk}, &amp;amp; i,j\in \mathcal{N}, \quad k\in\mathcal{K} \tag{2}\\&#xA;&amp;amp;d_{i}y_{ik} \ge v_{ik}, &amp;amp; i\in \mathcal{N}, \quad k\in\mathcal{K} \tag{3}\\&#xA;&amp;amp;\sum_{j\in\mathcal{N}_0 \\ j\neq i}x_{ijk} = y_{ik}, &amp;amp; i \in \mathcal{N}, \quad k\in\mathcal{K} \tag{4}\\&#xA;&amp;amp;y_{ik} \leq v_{ik}, &amp;amp; i\in \mathcal{N}, \quad k\in\mathcal{K} \tag{5}\\&#xA;&amp;amp;\sum_{j\in\mathcal{N}_0 \\ j\neq i}d_ix_{ijk} \ge v_{ik}, &amp;amp; i \in \mathcal{N}, \quad k\in\mathcal{K} \tag{6}\\&#xA;&amp;amp; \displaystyle\sum_{k\in\mathcal{K}} v_{ik} = d_i, &amp;amp;  i\in\mathcal{N} \tag{7}\\&#xA;&amp;amp; \displaystyle\sum_{i\in\mathcal{N}} v_{ik}w_i \le W, &amp;amp;  k\in\mathcal{K} \tag{8}\\&#xA;&amp;amp; \displaystyle\sum_{i\in\mathcal{N}} v_{ik}z_i \le V, &amp;amp;  k\in\mathcal{K} \tag{9}\\&#xA;&amp;amp; x_{ijk} \in \{0,1\}, &amp;amp; i,j\in \mathcal{N}_0, \quad k\in\mathcal{K} \tag{10}\\&#xA;&amp;amp; v_{ik} \in \mathbb{Z}^{+}, &amp;amp;  i\in\mathcal{N}, \quad k\in\mathcal{K} \tag{11}\\&#xA;&amp;amp; y_{ik} \in \{0,1\}, &amp;amp;  i\in\mathcal{N}, \quad k\in\mathcal{K} \tag{12}\\&#xA;&amp;amp; u_{ik} \in \mathbb{Z}^{+}, &amp;amp;  i\in\mathcal{N}, \quad k\in\mathcal{K} \tag{13}&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; is the flow conservation constraints, &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; are the subtour elimination constraints, &lt;span class=&quot;math-container&quot;&gt;$(3),(4)$&lt;/span&gt; force the binary variables to be positive if material is delivered to node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; on route &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. Constraint &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; guarantees that if a customer is visited then material is delivered, and Constraint &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt; does not allow material to be delivered unless a customer is visited. Constraints &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt; enforce that the combined load of all forklifts that pick at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; should equal the demand at location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Constraints &lt;span class=&quot;math-container&quot;&gt;$(8),(9)$&lt;/span&gt; enforce max volume and max weight capacity while constraints &lt;span class=&quot;math-container&quot;&gt;$(10)-(13)$&lt;/span&gt; specify the variables.&lt;/p&gt;&#xA;&lt;p&gt;I've implemented this model in Gurobipy and upon running it with &lt;span class=&quot;math-container&quot;&gt;$|\mathcal{K}|=5$&lt;/span&gt; forklifts and &lt;span class=&quot;math-container&quot;&gt;$|\mathcal{N}_0|=10$&lt;/span&gt; pick locations for 10 minutes I get down to 18.9% gap and the following is printed out:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Time limit reached&#xA;Best objective 1.220180000000e+03, best bound 9.900500000000e+02, gap 18.8603%&#xA;--------------------------------------------------------&#xA;Forklift 1 is not used!&#xA;--------------------------------------------------------&#xA;Forklift 2 route:    Start -&amp;gt; 5 -&amp;gt; Stop&#xA;Qty loads:          [2] pcs          total load:    2&#xA;Weight loads:       [72] kg          Total weight load: 72 kg&#xA;Volume loads:       [704] m^3        Total volume load: 704 m^3&#xA;--------------------------------------------------------&#xA;--------------------------------------------------------&#xA;Forklift 3 route:    Start -&amp;gt; 4 -&amp;gt; 3 -&amp;gt; 6 -&amp;gt; 7 -&amp;gt; 1 -&amp;gt; Stop&#xA;Qty loads:          [2, 2, 8, 8, 3] pcs          total load:    23&#xA;Weight loads:       [76, 20, 176, 184, 39] kg        Total weight load: 495 kg&#xA;Volume loads:       [334, 372, 816, 1696, 153] m^3       Total volume load: 3371 m^3&#xA;--------------------------------------------------------&#xA;--------------------------------------------------------&#xA;Forklift 4 route:    Start -&amp;gt; 8 -&amp;gt; 2 -&amp;gt; Stop&#xA;Qty loads:          [8, 10] pcs          total load:    18&#xA;Weight loads:       [232, 250] kg        Total weight load: 482 kg&#xA;Volume loads:       [520, 2780] m^3          Total volume load: 3300 m^3&#xA;--------------------------------------------------------&#xA;--------------------------------------------------------&#xA;Forklift 5 route:    Start -&amp;gt; 4 -&amp;gt; 9 -&amp;gt; 10 -&amp;gt; Stop&#xA;Qty loads:          [3, 7, 4] pcs        total load:    14&#xA;Weight loads:       [114, 238, 136] kg       Total weight load: 488 kg&#xA;Volume loads:       [501, 427, 252] m^3          Total volume load: 1180 m^3&#xA;--------------------------------------------------------&#xA;--------------------------------------------------------&#xA;Fleet weight load:       1537   kg&#xA;Fleet weight capacity:   2000   kg&#xA;Fleet volume load:   8555   m^3&#xA;Fleet volume capacity:   20000  m^3&#xA;Nr fork lifts used:  4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Needless to say, the model performs quite bad when increasing the number of pick locations so I want to develop some heuristic that solves it fast without sacrificing too much optimality. I've looked at &lt;a href=&quot;https://www.scirp.org/pdf/AJOR20120200001_58723973.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt; by Wilk and Cavalier, however I'm struggling to understand how this heuristic should be implemented. In section 3 the authors state:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The heuristic procedure presented in this section constructs a set of&#xA;feasible solutions to the SDVRP. The first procedure of the heuristic&#xA;initializes the input. The second procedure assigns customers to&#xA;vehicle routes, iteratively. The order of each route is then&#xA;determined by a traveling salesman problem (TSP) solution procedure,&#xA;finalizing the solution.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Does this mean that I should use my model above to obtain initial routes, and then switch around stuff randomly till I get a better solution? Seems very trivial and not so efficient.&lt;/p&gt;&#xA;&lt;p&gt;Also, doesn't solving the TSP also need some heuristic procedure as the number of sub tour elimination constraints increase exponentially?&lt;/p&gt;&#xA;&lt;p&gt;Given my model, how can I implement the heuristic suggested in this paper? Are there simpler heuristics for the SDCVRP that might be based on other heuristics for the CVRP?&lt;/p&gt;&#xA;" OwnerUserId="4222" LastEditorUserId="4222" LastEditDate="2022-08-25T15:39:05.083" LastActivityDate="2022-08-25T16:07:15.727" Title="Construction heuristic for SDCVRP" Tags="|combinatorial-optimization|gurobi|vehicle-routing|heuristics|metaheuristics|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8936" PostTypeId="2" ParentId="8908" CreationDate="2022-08-25T09:30:38.887" Score="1" Body="&lt;p&gt;In CPLEX you can use the absolute value.&#xA;For instance with the OPL API you can write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int n=5;&#xA;range r=1..n;&#xA;&#xA;int K=10;&#xA;&#xA;int a[i in r]=i;&#xA;dvar int x[r];&#xA;&#xA;subject to&#xA;{&#xA;  sum (i in r) abs(x[i]-a[i])&amp;gt;=K;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-08-25T09:30:38.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8937" PostTypeId="1" AcceptedAnswerId="8938" CreationDate="2022-08-25T12:26:18.237" Score="2" ViewCount="69" Body="&lt;p&gt;I have a decision variable for the power of a heating device &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; that can have the following levels: 0, 900, 1300, 2000 (Unit is Watt [W]).&lt;/p&gt;&#xA;&lt;p&gt;Now I would like to know if and how I can model in an equation. If the levels were distributed evenly, I could just use an integer variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; with 4 values &lt;span class=&quot;math-container&quot;&gt;${0, 1,2,3}$&lt;/span&gt; and calculate the output power by using&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P = x* (1/3)* P^{max}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But for my application this can't be done. A way to archieve this is to use 4 binary variables with one variable for each level and ensure in an additional constraint that only one of them can be active. However, this would create multiple additional binary variables. So I am asking you whether you are aware of a way how to model this elegantly?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastActivityDate="2022-08-25T15:23:01.160" Title="Modelling not evenly distributed discrete levels of a decision variable" Tags="|modeling|binary-variable|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8938" PostTypeId="2" ParentId="8937" CreationDate="2022-08-25T15:23:01.160" Score="3" Body="&lt;p&gt;If you plot your power levels versus the integers 0 to 3, you will see that the function is neither convex nor concave. For that reason, I am fairly confident you will need to use binary variables.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-25T15:23:01.160" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8939" PostTypeId="2" ParentId="8935" CreationDate="2022-08-25T16:07:15.727" Score="2" Body="&lt;p&gt;I don't think you would be using your model when applying the cited heuristic. The heuristic starts by having you assign customers (here, pick locations) to routes in a heuristic manner. There is no optimization model used for the assignment, just one of a number of alternative heuristic rules. Once customers are assigned to routes, the sequencing of each route is determined by solving a TSP. Presumably, in your case, &amp;quot;route&amp;quot; equates to &amp;quot;forklift&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;As far as TSPs requiring a heuristic procedure, optimal solutions can be found for fairly large TSPs, larger than you are likely to encounter in your problem (unless you have thousands of pick locations). A key question is how much computational time you are willing to spend on each route. The &lt;a href=&quot;https://www.math.uwaterloo.ca/tsp/concorde.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Concorde&lt;/a&gt; TSP solver has solved a problem with 85,900 nodes to optimality, although I don't know what the computation time was. (I'm guessing it was not trivial.)&lt;/p&gt;&#xA;&lt;p&gt;In any event, since the route partitioning step was a heuristic, you might be happy with a heuristic solution to each TSP problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-25T16:07:15.727" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8940" PostTypeId="1" CreationDate="2022-08-25T23:40:01.670" Score="2" ViewCount="149" Body="&lt;p&gt;In an Operations Research Problem:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;&amp;quot;A beverage company wants to produce a new juice with a mixed flavor, using only orange and pineapple flavors. Orange flavor&#xA;contains 5% of vitamin A and 2% of vitamin C. Pineapple flavor&#xA;contains 8% of Vitamin C. The company's quality policies indicate that&#xA;at least 20L of orange flavor should be added to the new juice and&#xA;vitamin C content should not be greater than 5%. Determine the optimum&#xA;amount of each flavor that should be used to satisfy a minimum demand&#xA;of 100L of juice.&amp;quot;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The linear programming model is as follows:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;: Amount in L of orange flavor&lt;br /&gt;&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;: Amount in L of pineapple flavor&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min Z=1000x_1+400x_2 \tag{1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$0.02x_1+0.08x_2 \le 0.05(x_1+x_2) \tag{2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_1 \ge 20 \tag{3}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_1+x_2 \ge 100 \tag{4}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;That gives &lt;span class=&quot;math-container&quot;&gt;$x_1=50$&lt;/span&gt; L and &lt;span class=&quot;math-container&quot;&gt;$x_2=50$&lt;/span&gt; L of orange and pineapple flavors.&lt;/p&gt;&#xA;&lt;p&gt;However, the company wants to know what would happen if the vitamin C requirement is to be not greater than &lt;strong&gt;7%?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this case, as the change in the coefficient of &lt;span class=&quot;math-container&quot;&gt;$(x_1+x_2)$&lt;/span&gt; in the first restriction would imply more than 1 change at a time, the model would have to be run again to determine the impact on the optimal solutions?.&lt;/p&gt;&#xA;&lt;p&gt;But also, sensitivity analysis only applies when the value of the right hand side of the restrictions is changed, so would sensitivity analysis apply here?&lt;/p&gt;&#xA;" OwnerUserId="10279" LastEditorUserId="491" LastEditDate="2024-02-21T23:12:35.720" LastActivityDate="2024-02-21T23:12:35.720" Title="Sensitivity Analysis" Tags="|linear-programming|sensitivity-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8941" PostTypeId="2" ParentId="8940" CreationDate="2022-08-26T02:43:10.700" Score="2" Body="&lt;p&gt;If you are minimizing cost, then there is no advantage to producing more than the required 100 liters of juice. Using that, you can rewrite the model so that the 5% limit on vitamin C is part of a constant right-hand side, allowing you to apply sensitivity analysis.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-26T02:43:10.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8942" PostTypeId="1" CreationDate="2022-08-26T06:35:31.660" Score="4" ViewCount="256" Body="&lt;p&gt;I am exploring what the tradeoffs are between no crossover, crossover w/ default settings, and crossover with just dual for barrier optimization.&lt;/p&gt;&#xA;&lt;p&gt;When I attempt to define my solver settings for the crossover with dual, I thought, based on the CPLEX documentation, that I would use the [barcrossalg] parameter and set it equal to 2. however, when I kick off a study, I get an error message back stating only the following parameters are available.&lt;/p&gt;&#xA;&lt;p&gt;Is &amp;quot;barrier&amp;quot; the actual setting I am looking for and not barcrossalg?&lt;/p&gt;&#xA;&lt;p&gt;I am using version 20.1.0 of CPLEX community edition.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Available options reported back to me by the solver:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;advance, barrier,benders, clocktype, conflict, cpumask, defaults, dettimelimit, distmip, emphasis, feasopt, logfile, lpmethod, mip, multiobjective, network, optimalitytarget, output, parallel,  paramdisplay, preprocessing, qpmethod, randomseed, read, record, sifting, simplex, solutiontype, threads, timelimit, tune, workdir, workmem&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10131" LastEditorUserId="123" LastEditDate="2022-08-29T19:57:47.713" LastActivityDate="2022-08-29T19:57:47.713" Title="Attempting to define dual crossover for barrier optimization in CPLEX" Tags="|cplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8944" PostTypeId="2" ParentId="8942" CreationDate="2022-08-26T08:17:27.107" Score="4" Body="&lt;p&gt;To use the barrier algorithm without crossover with cplex 20.1, you can use the following options:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;set lpmethod 4 (this selects the barrier algorithm):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/TxWVW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TxWVW.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;set solutiontype 2 (this deactivates crossover):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/pi3Pq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pi3Pq.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The log looks like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/uM7VM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uM7VM.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can see the barrier algorithm is indeed used. If you activate crossover, you can view some additional information:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/29BWM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/29BWM.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-08-26T08:57:15.157" LastActivityDate="2022-08-26T08:57:15.157" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8945" PostTypeId="2" ParentId="8942" CreationDate="2022-08-26T14:59:11.950" Score="2" Body="&lt;p&gt;If you are using the interactive optimizer, you need to type &amp;quot;set barrier crossover&amp;quot; (or just &amp;quot;set barrier&amp;quot; to get a list of available parameters related to the barrier method). When you type &amp;quot;set&amp;quot; to get a list of parameters, &amp;quot;barrier&amp;quot; refers to a submenu, not a single parameter. (Note the explanation: &amp;quot;set parameter&lt;strong&gt;s&lt;/strong&gt; for barrier optimization&amp;quot;.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-26T14:59:11.950" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8946" PostTypeId="1" CreationDate="2022-08-26T15:16:35.713" Score="1" ViewCount="115" Body="&lt;p&gt;I am trying to solve an assignment problem where all the variables are continuous. I have a set of sources S, and another set of destinations D. Each source and destination have capacity/demand expressed as continuous variables. There is a distance associated with each source-destination. I need to find the ideal allocation while minimizing the total distance in the network. A source can supply to multiple destinations, and the reverse holds true as well. The caveat is that the allocation has to be split among multiple sources for every destination. For example, we have 3 sources &lt;em&gt;S1, S2, S3&lt;/em&gt; with capacities 1081.52, 3810.48, 950.64 respectively. There are 2 destinations &lt;em&gt;D1, D2&lt;/em&gt; with demands 1759.38, and 3993.21. My final assignment looks like this:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&quot;text-align: left;&quot;&gt;Destinations&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;Sources&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: right;&quot;&gt;Supply&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: right;&quot;&gt;Total Demand at Destination&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;D1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;S1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;153.67&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;1759.38&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;D1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;S2&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;745.12&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;1759.38&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;D1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;S3&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;860.59&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;1759.38&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;D2&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;S1&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;927.85&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;3993.21&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;D2&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;S2&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;3065.36&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;3993.21&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;What type of algorithm should I be looking at for such problems? I also want to place constraints on how many times a source can be used.&lt;/p&gt;&#xA;" OwnerUserId="10282" LastEditorUserId="500" LastEditDate="2022-08-26T15:22:03.730" LastActivityDate="2022-08-26T15:22:03.730" Title="Assignment problem with continuous constraints" Tags="|mixed-integer-programming|linear-programming|network-flow|assignment-problem|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8947" PostTypeId="1" CreationDate="2022-08-27T01:45:54.187" Score="3" ViewCount="121" Body="&lt;p&gt;Has anyone ever encountered the following variation of TSP?  You have a TSP with pickups and deliveries, and in addition, for each pickup-delivery pair &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, you have a constraint that the time you arrive at &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt;, has to be at least a specified time after the time you arrived at &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt;, i.e. &lt;span class=&quot;math-container&quot;&gt;$t_j \geq t_i + \alpha_i$&lt;/span&gt;.  The interpretation here would be that you're picking up eggs, but you can't deliver them until they've hatched.  :)&lt;/p&gt;&#xA;" OwnerUserId="10284" LastActivityDate="2022-08-27T01:45:54.187" Title="TSP-PD with time constraints between pickups and deliveries" Tags="|vehicle-routing|traveling-salesman|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8948" PostTypeId="1" AcceptedAnswerId="8949" CreationDate="2022-08-27T18:45:39.153" Score="2" ViewCount="239" Body="&lt;p&gt;Say I have several portfolios of the format:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Product Name&lt;/th&gt;&#xA;&lt;th&gt;Product Amount&lt;/th&gt;&#xA;&lt;th&gt;Price per unit&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A_1&lt;/td&gt;&#xA;&lt;td&gt;10&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;B_1&lt;/td&gt;&#xA;&lt;td&gt;20&lt;/td&gt;&#xA;&lt;td&gt;6&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Z_1&lt;/td&gt;&#xA;&lt;td&gt;30&lt;/td&gt;&#xA;&lt;td&gt;7&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;We can call this &lt;span class=&quot;math-container&quot;&gt;$\text{Portfolio}_{1}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Similarly, &lt;span class=&quot;math-container&quot;&gt;$\text{Portfolio}_{2}$&lt;/span&gt; could look like:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Product Name&lt;/th&gt;&#xA;&lt;th&gt;Product Amount&lt;/th&gt;&#xA;&lt;th&gt;Price per unit&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A_2&lt;/td&gt;&#xA;&lt;td&gt;100&lt;/td&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;B_2&lt;/td&gt;&#xA;&lt;td&gt;50&lt;/td&gt;&#xA;&lt;td&gt;8&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Z_2&lt;/td&gt;&#xA;&lt;td&gt;50&lt;/td&gt;&#xA;&lt;td&gt;17&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;For simplicity's sake we can assume we have 13 distinct portfolios.&lt;/p&gt;&#xA;&lt;p&gt;I have two groups of customers. One that enters in a one year contract with me in January and the other group enters in February.&lt;/p&gt;&#xA;&lt;p&gt;I know the monthly demand for each group in each month. However, my objective is to reach an &amp;quot;average annual price target&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;For example, say the January group has monthly demand targets of&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$[10,200,300,400,500,600,700,800,900,100,110,120]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where the index of each element corresponds to the monthly demand. So I need to allocate &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; units from &lt;span class=&quot;math-container&quot;&gt;$\text{Portfolio}_{1}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$200$&lt;/span&gt; units from &lt;span class=&quot;math-container&quot;&gt;$\text{Portfolio}_{2}$&lt;/span&gt; etc.&lt;/p&gt;&#xA;&lt;p&gt;From &lt;span class=&quot;math-container&quot;&gt;$\text{Portfolio}_{1}$&lt;/span&gt; I can allocate all of product &lt;span class=&quot;math-container&quot;&gt;$A_1$&lt;/span&gt;. I then need to calculate the average price, which in this case is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$J_{1} = \frac{10*2}{10} = 2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;From &lt;span class=&quot;math-container&quot;&gt;$\text{Portfolio}_{2}$&lt;/span&gt; I could allocate all of &lt;span class=&quot;math-container&quot;&gt;$A_2, B_2, Z_2$&lt;/span&gt; to meet the monthly demand of &lt;span class=&quot;math-container&quot;&gt;$200$&lt;/span&gt; (Note that we also need to allocate products from &lt;span class=&quot;math-container&quot;&gt;$\text{Portfolio}_{2} $&lt;/span&gt; to meet the demand for the February group). And the resulting average price would be&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$J_{2}  = \frac{100*3 + 50*8 + 50*17}{200}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My objective is to reach a target of all the averages, lets say for the January group this is 50. And for the Febuary group it is 100 I.e.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$J^{*} = \frac{J_1 + J_2 + ... + J_{12}}{12} = 50$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$F^{*} = \frac{F_1 + F_2 + ... + F_{12}}{12} = 100$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;So the January group gets products from &lt;span class=&quot;math-container&quot;&gt;$\text{Portfolio}_{1},..., \text{Portfolio}_{12}$&lt;/span&gt;. The Febuary group gets products from &lt;span class=&quot;math-container&quot;&gt;$\text{Portfolio}_{2},..., \text{Portfolio}_{13}$&lt;/span&gt;. So as you can see, there is some overlap.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My approach:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have never worked with multi-objective algorithms before so I am not even sure if they are applicable. So any feedback on my naive approach would be appreciated.&lt;/p&gt;&#xA;&lt;p&gt;So, as my objective is to reach a target average value, I broke this down to linear programming problems. For example, as I know that the January group has a target of 50, I set up 12 linear programming problems where I allocated products from each portfolio with the objective of reaching a value of 50 for each component, subject to the monthly demand constraint.&lt;/p&gt;&#xA;&lt;p&gt;I.e., I wanted each &lt;span class=&quot;math-container&quot;&gt;$J_1, J_2, ... J_{12}$&lt;/span&gt; to reach a value of 50, subject to meeting the monthly demand constraints. Similarly, for February, I wanted each &lt;span class=&quot;math-container&quot;&gt;$F_1,...F_{12}$&lt;/span&gt; to be 100, subject to the monthly demand constraint for the February group.&lt;/p&gt;&#xA;&lt;p&gt;So my question is essentially if there is a better approach. Rather than having each &lt;span class=&quot;math-container&quot;&gt;$J_i, F_i$&lt;/span&gt; be the &amp;quot;annual average target&amp;quot;, is there a better distribution?&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&lt;p&gt;The confusion I am having with setting this up as a single linear program (where I aim to minimise the sum of absolute deviation from &lt;span class=&quot;math-container&quot;&gt;$J*, F*$&lt;/span&gt;) is that it seems like I have two types of decision variables now. I have the individual monthly components (the J_i, F_i) and the allocation of products. Where the allocation of products obviously affect the (J_i, F_i). So as &lt;span class=&quot;math-container&quot;&gt;$J_i, F_i$&lt;/span&gt; are functions of the product allocations I suppose there is in fact just one decision variable but I am just having a hard time formulating the problem.&lt;/p&gt;&#xA;&lt;p&gt;So would the problem look something like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min_{J_{1},...,J_{12},F_{1},...F_{12}} [(J^{*} - 50) + (F^{*} - 100)]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where I would somehow have to impose the demand constraints on each &lt;span class=&quot;math-container&quot;&gt;$J_{i}, F_{i}$&lt;/span&gt;? But since (J_i, F_i)'s are average prices, I don't quite see how I can impose demand constraint on them.&lt;/p&gt;&#xA;" OwnerUserId="10093" LastEditorUserId="10093" LastEditDate="2022-08-27T20:29:11.003" LastActivityDate="2022-08-27T21:52:05.523" Title="Multi-objective optimization for resource allocation" Tags="|linear-programming|multi-objective-optimization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8949" PostTypeId="2" ParentId="8948" CreationDate="2022-08-27T20:01:28.427" Score="2" Body="&lt;p&gt;This is not necessarily a multiobjective problem. One approach is to write a single linear program (if allocation amounts are continuous) or mixed integer linear program (if allocation amounts are integer-valued) where the objective function minimizes the sum of the absolute deviations of &lt;span class=&quot;math-container&quot;&gt;$J*$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$F*$&lt;/span&gt; from their respective targets. I'm assuming that the goal is to hit the targets exactly, rather than staying at or under the targets (or at or over the targets). If you want to prioritize one group over the other, you can weight one of the objective terms higher than the other.&lt;/p&gt;&#xA;&lt;p&gt;If one group has an absolute priority over the other (e.g., get as close as possible to the January target regardless of how much that makes you miss the February target), you can use a lexicographically ordered objective. One way to do that is to solve two problems. In the first problem, get as close as you can to the higher priority target without regard for the lower priority target. In the second problem, get as close as possible to the lower priority target with the added constraint that you cannot miss the higher priority target by more than what the optimal solution to the first model accomplished.  Another way to handle it is to use a solver that supports lexicographic objectives. (Recent versions of CPLEX do, for instance.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: Here is an LP formulation for the single objective case. I'll number&#xA;the months 1 through 13, where the January has demands &lt;span class=&quot;math-container&quot;&gt;$d_{1,1},\dots,d_{1,12}$&lt;/span&gt;&#xA;and the February group has demands &lt;span class=&quot;math-container&quot;&gt;$d_{2,2},\dots,d_{2,13}.$&lt;/span&gt; The&#xA;available amount of any product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$S_{i}$&lt;/span&gt; and its unit cost&#xA;is &lt;span class=&quot;math-container&quot;&gt;$c_{i}.$&lt;/span&gt; The set of products available in month &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is denoted&#xA;&lt;span class=&quot;math-container&quot;&gt;$P_{t}.$&lt;/span&gt; For instance, &lt;span class=&quot;math-container&quot;&gt;$P_{2}=\left\{ A\_2,\dots,Z\_2\right\} .$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Variables &lt;span class=&quot;math-container&quot;&gt;$x_{1,i}\ge0$&lt;/span&gt; capture the amount allocated of product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&#xA;to demand from the January group in the appropriate month (e.g., if&#xA;&lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is ``B_7'' then it must be month 7). &lt;span class=&quot;math-container&quot;&gt;$J_{t}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$F_{t}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$J^{*}$&lt;/span&gt;&#xA;and &lt;span class=&quot;math-container&quot;&gt;$F^{*}$&lt;/span&gt; are as in the original post. Variables &lt;span class=&quot;math-container&quot;&gt;$y_{J}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{F}$&lt;/span&gt;&#xA;capture the absolute deviations of &lt;span class=&quot;math-container&quot;&gt;$J^{*}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$F^{*}$&lt;/span&gt; from their&#xA;targets (denoted &lt;span class=&quot;math-container&quot;&gt;$T_{J}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T_{F}$&lt;/span&gt; respectively).&lt;/p&gt;&#xA;&lt;p&gt;The objective is to minimize &lt;span class=&quot;math-container&quot;&gt;$y_{J}+y_{F}.$&lt;/span&gt; The first set of constraints&#xA;ensures that each group gets their required allocation in each month.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;x_{1,A\_1}+\dots+x_{1,Z\_1} &amp;amp; =d_{1,1}\\&#xA;\cdots\\&#xA;x_{2,A\_13}+\dots+x_{2,Z\_13} &amp;amp; =d_{2,13}.&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The second set of constraints ensures that you don't allocate product&#xA;you don't have.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;x_{1,A\_1} &amp;amp; \le S_{A\_1}\\&#xA;\cdots\\&#xA;x_{1,A\_2}+x_{2,A\_2} &amp;amp; \le S_{A\_2}\\&#xA;\cdots\\&#xA;x_{2,Z\_13} &amp;amp; \le S_{Z\_13}&#xA;\end{align*}&lt;/span&gt;&#xA;where the left sides have two terms except in the first and last January&#xA;(where one of the two groups is not in play).&lt;/p&gt;&#xA;&lt;p&gt;Finally, we need constraints to define the remaining variables.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;J_{t} &amp;amp; =\frac{1}{d_{1,t}}\sum_{i\in P_{t}}c_{i}x_{1,i}\quad t=1,\dots,12\\&#xA;F_{t} &amp;amp; =\frac{1}{d_{2,t}}\sum_{i\in P_{t}}c_{i}x_{2,i}\quad t=2,\dots,13\\&#xA;J^{*} &amp;amp; =(J_{1}+\dots+J_{12})/12\\&#xA;F^{*} &amp;amp; =(F_{2}+\dots+F_{13})/12\\&#xA;y_{J} &amp;amp; \ge J^{*}-T_{J}\\&#xA;y_{J} &amp;amp; \ge T_{J}-J^{*}\\&#xA;y_{F} &amp;amp; \ge F^{*}-T_{F}\\&#xA;y_{F} &amp;amp; \ge T_{F}-F^{*}.&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-08-27T21:52:05.523" LastActivityDate="2022-08-27T21:52:05.523" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8950" PostTypeId="1" CreationDate="2022-08-28T10:14:09.817" Score="1" ViewCount="863" Body="&lt;p&gt;According to some tables in the book Operations Research by Hamdy Taha(7th edition), it seems that &lt;strong&gt;for a variable whose optimal value is zero&lt;/strong&gt;, reduced cost can be evaluated by the following formulas:&lt;/p&gt;&#xA;&lt;p&gt;reduced cost = MaxObjCoeff - CurrObjCoeff (&lt;strong&gt;for max problems&lt;/strong&gt;)&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;reduced cost = MinObjCoeff - CurrObjCoeff (&lt;strong&gt;for min problems&lt;/strong&gt;)&lt;/p&gt;&#xA;&lt;p&gt;I should note that the interval [MinObjCoeff, MaxObjCoeff] is the optimality range of CurrObjCoeff in the graphical sensitivity analysis.&lt;/p&gt;&#xA;&lt;p&gt;I wonder if these formulas always work? Could anyone explain this for me please?&lt;/p&gt;&#xA;" OwnerUserId="10291" LastEditorUserId="10291" LastEditDate="2024-03-28T11:07:25.170" LastActivityDate="2024-03-28T11:07:25.170" Title="How to obtain reduced cost in the graphical sensitivity analysis?" Tags="|linear-programming|sensitivity-analysis|reduced-costs|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8951" PostTypeId="1" CreationDate="2022-08-29T05:15:37.190" Score="4" ViewCount="487" Body="&lt;p&gt;Let's say if I have two decision variables, &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; respectively, where &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is continuous, and &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is binary.&lt;/p&gt;&#xA;&lt;p&gt;If I have a constraint like this,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ f\cdot g \le C$$&lt;/span&gt;&#xA;Does this make my model nonlinear or quadratic integer model?&lt;/p&gt;&#xA;" OwnerUserId="10000" LastEditorUserId="123" LastEditDate="2022-08-29T19:56:06.060" LastActivityDate="2022-08-29T19:56:06.060" Title="Is this a non-linear integer model?" Tags="|mixed-integer-programming|integer-programming|nonlinear-programming|quadratic-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8952" PostTypeId="2" ParentId="8951" CreationDate="2022-08-29T08:42:10.827" Score="4" Body="&lt;p&gt;Your model is linear if and only if your objective function and the functions on the left hand side of your constraints (assuming only constants are left on your right hand side) are linear and the variables may take values in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}$&lt;/span&gt;. If it is not linear, then it is non-linear (which comes in many flavours!)&lt;/p&gt;&#xA;&lt;p&gt;Your function on the LHS of your constraints is &lt;span class=&quot;math-container&quot;&gt;$h(f,g)=f\cdot g$&lt;/span&gt;, which is not linear as &lt;span class=&quot;math-container&quot;&gt;$h(\alpha f,\alpha g) = \alpha h(f,g)$&lt;/span&gt; is &lt;em&gt;not true&lt;/em&gt; for all &lt;span class=&quot;math-container&quot;&gt;$\alpha \in \mathbb{R}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-08-29T08:42:10.827" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8953" PostTypeId="1" AcceptedAnswerId="8971" CreationDate="2022-08-29T10:39:48.347" Score="5" ViewCount="187" Body="&lt;p&gt;I need to find the vertices of a polyhedron from the defining halfspaces. In a &lt;a href=&quot;https://or.stackexchange.com/questions/4540/how-to-find-all-vertices-of-a-polyhedron&quot;&gt;previous question&lt;/a&gt; libraries for enumerating all vertices were mentioned.&#xA;However i have a very large polyhedron (~100,000 halfspaces and more) where enumerating all vertices would be prohibitively expensive.&#xA;Even for pretty small problems (~500 halfspaces ~100 variables) using pypoman library for python the function &lt;code&gt;compute_polytope_vertices&lt;/code&gt; doesn't return.&#xA;I would like to use a streaming implementation where &lt;code&gt;compute_polytope_vertices&lt;/code&gt; would return a generator of the vertices. Does such an implementation exist?&lt;/p&gt;&#xA;&lt;p&gt;Any help would be appreciated.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;I tested lrs library as suggested.&#xA;For the simple example below pypoman runs very fast (~7ms) and  lrs windows binary running slowly (~7s):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;test&#xA;H-representation&#xA;begin&#xA;56 22 rational&#xA; 20  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1 &#xA; 0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1 &#xA; 40  -1  -1  -1  -1  0  0  0  0  0  1  0  0  0  0  0  0  0  1  0  0  0 &#xA; -40  1  1  1  1  0  0  0  0  0  -1  0  0  0  0  0  0  0  -1  0  0  0 &#xA; 0  1  0  0  0  -1  -1  -1  0  0  0  1  0  0  0  0  0  0  0  1  0  0 &#xA; 0  -1  0  0  0  1  1  1  0  0  0  -1  0  0  0  0  0  0  0  -1  0  0 &#xA; 0  0  1  0  0  1  0  0  -1  -1  0  0  1  0  0  0  1  0  0  0  0  0 &#xA; 0  0  -1  0  0  -1  0  0  1  1  0  0  -1  0  0  0  -1  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  -1  -1  -1  -1  -1  -1  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  1  1  1  1  1  1  0  0  0  0  0  0 &#xA; 0  0  0  1  0  0  1  0  0  0  0  0  0  1  0  0  -1  -1  0  0  1  0 &#xA; 0  0  0  -1  0  0  -1  0  0  0  0  0  0  -1  0  0  1  1  0  0  -1  0 &#xA; 0  0  0  0  0  0  0  1  1  0  0  0  0  0  1  0  0  1  -1  0  0  1 &#xA; 0  0  0  0  0  0  0  -1  -1  0  0  0  0  0  -1  0  0  -1  1  0  0  -1 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For a slightly bigger example pypoman runs for ~350ms lrs hasn't finished after several minutes.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;daniel test&#xA;H-representation&#xA;begin&#xA;72 29 rational&#xA; 20  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0 &#xA; 20  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1 &#xA; 0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1 &#xA; 80  -1  -1  -1  -1  0  0  0  0  1  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  1  0 &#xA; -80  1  1  1  1  0  0  0  0  -1  0  0  0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  -1  0 &#xA; 0  1  0  0  0  -1  -1  -1  -1  0  0  1  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0 &#xA; 0  -1  0  0  0  1  1  1  1  0  0  -1  0  0  0  0  0  0  0  0  0  0  -1  0  0  0  0  0  0 &#xA; 0  0  0  0  0  1  0  0  0  -1  -1  0  1  0  0  0  0  0  1  0  0  0  0  1  0  0  0  0  1 &#xA; 0  0  0  0  0  -1  0  0  0  1  1  0  -1  0  0  0  0  0  -1  0  0  0  0  -1  0  0  0  0  -1 &#xA; 0  0  1  0  0  0  0  0  0  0  0  -1  -1  -1  -1  -1  0  0  0  0  0  0  0  0  1  0  0  0  0 &#xA; 0  0  -1  0  0  0  0  0  0  0  0  1  1  1  1  1  0  0  0  0  0  0  0  0  -1  0  0  0  0 &#xA; 0  0  0  0  0  0  1  0  0  0  1  0  0  1  0  0  -1  -1  0  1  0  0  0  0  0  1  0  0  0 &#xA; 0  0  0  0  0  0  -1  0  0  0  -1  0  0  -1  0  0  1  1  0  -1  0  0  0  0  0  -1  0  0  0 &#xA; 0  0  0  1  0  0  0  1  0  0  0  0  0  0  1  0  0  0  -1  -1  -1  -1  0  0  0  0  0  0  0 &#xA; 0  0  0  -1  0  0  0  -1  0  0  0  0  0  0  -1  0  0  0  1  1  1  1  0  0  0  0  0  0  0 &#xA; 0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  -1  -1  -1  -1  -1  0  0 &#xA; 0  0  0  0  -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  -1  0  1  1  1  1  1  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA; 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 &#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I want to run on much bigger instances and lrs just seems very slow.&lt;/p&gt;&#xA;" OwnerUserId="10295" LastEditorUserId="10295" LastEditDate="2022-09-07T21:03:10.457" LastActivityDate="2022-09-07T21:03:10.457" Title="How to enumerate all vertices of a polyhedron as a stream" Tags="|linear-programming|python|solver|polyhedra|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8954" PostTypeId="1" CreationDate="2022-08-29T13:45:40.107" Score="5" ViewCount="246" Body="&lt;p&gt;Large MILPs with block structures can be efficiently solved with decomposition methods (e.g., the Benders' decomposition), which exploit special sparse structures of the constraint matrices.&lt;/p&gt;&#xA;&lt;p&gt;However, when a large MILP has a dense constraint matrix, it could be hard to solve directly with solvers, while existing decomposition approaches usually do not work. An example of such problems is the security-constrained unit commitment problem (SCUC) with DC power flow, where variables are tightly linked together.&lt;/p&gt;&#xA;&lt;p&gt;Is there any mature (or emerging) method dealing with dense constraint matrix in MILP solving?&lt;/p&gt;&#xA;" OwnerUserId="10155" LastActivityDate="2022-08-30T07:43:16.747" Title="How can we efficiently solve a large MILP with dense constraint matrix?" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8955" PostTypeId="2" ParentId="8954" CreationDate="2022-08-30T07:43:16.747" Score="7" Body="&lt;p&gt;Unfortunately, density kills optimization performance. Many of the implementational techniques used in solvers that allow for the efficient solution of large problems specifically exploit sparsity. The solver implementations typically try to have efficient methods for dense situations as well, but there are limits to that.&lt;/p&gt;&#xA;&lt;p&gt;The only approach I know of that might help sometimes is reformulating the problem. This typically means coming up with an extended formulation, that means a formulation that uses more variables than the original one. This leads to a larger problem but potentially with a tighter bound and a better sparsity pattern, sometimes even one that can be exploited with decomposition.&lt;/p&gt;&#xA;&lt;p&gt;A classic reformulation approach is to frame the problem in the context of a network, often a time-space-network where the nodes are duplicated for each time period.&#xA;I am not familiar with the SCUC problem you mention, but a quick search hints at the fact that MILP solvers are currently used to solve this problem, so maybe a good formulation exists.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, if a problem is large and dense and the performance is not satisfactory, solving only parts of the problem iteratively can be a good (heuristic) approach to at least find some solutions for such a problem.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2022-08-30T07:43:16.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8956" PostTypeId="1" CreationDate="2022-08-30T09:21:04.187" Score="9" ViewCount="1001" Body="&lt;p&gt;A year ago, I had taken my master's degree class Optimisation Theory, and we were learning Dantzig-Wolfe Decomposition and Benders' Decomposition. I found it very challenging to use these algorithms since there are many iterations inside of them.&lt;/p&gt;&#xA;&lt;p&gt;I would like to ask that is it now used commonly in research papers, or is it still applicable?&lt;/p&gt;&#xA;" OwnerUserId="10219" LastEditorUserId="491" LastEditDate="2022-09-14T07:00:02.500" LastActivityDate="2022-09-14T07:00:02.500" Title="Is Dantzig-Wolfe and Benders' Decomposition still applied in Operations Research?" Tags="|optimization|benders-decomposition|dantzig-wolfe-decomposition|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8957" PostTypeId="1" AcceptedAnswerId="8959" CreationDate="2022-08-30T14:06:31.497" Score="8" ViewCount="466" Body="&lt;p&gt;I want to solve this problem :&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;b&gt;Maximize&lt;/b&gt; &lt;span class=&quot;math-container&quot;&gt;\begin{equation} \sum_{i=1}^{n} \frac{x_i}{a_ix_i + b_i}\end{equation}&lt;/span&gt; with the constraints &lt;span class=&quot;math-container&quot;&gt;\begin{equation}\sum_{i=1}^{n}x_i = S  \ , \ x_i \geq 0 \ \forall \ i \end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$ a_1 , ... , a_n , b_1 , ... , b_n , S &amp;gt; 0$&lt;/span&gt; are known .&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Note that the functions &lt;span class=&quot;math-container&quot;&gt;\begin{equation}f_i(t) = \frac{t}{a_it + b_i} \end{equation}&lt;/span&gt; are strictly increasing and concave on &lt;span class=&quot;math-container&quot;&gt;$ (0 , \infty) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I solve this?&lt;/p&gt;&#xA;" OwnerUserId="10302" LastEditorUserId="123" LastEditDate="2022-10-20T21:33:51.377" LastActivityDate="2022-10-20T21:33:51.377" Title="Solving maximization problem with linear-fractional sum" Tags="|nonlinear-programming|socp|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="8958" PostTypeId="2" ParentId="8956" CreationDate="2022-08-30T15:30:52.860" Score="15" Body="&lt;p&gt;I don't know about &amp;quot;commonly&amp;quot; used, but Benders is still definitely in use, and I'm pretty sure D-W also is. Benders in particular has evolved beyond the original version created by Jack Benders. In particular, there is work on &amp;quot;combinatorial Benders cuts&amp;quot; [1], where &amp;quot;big M&amp;quot; constraints are replaced by a form of Benders cut, and &amp;quot;logic-based Benders decomposition&amp;quot;. I have used a version of the latter a couple of times, where the subproblem is not necessarily a linear program and the Benders cuts are not derived from dual solutions. (In one case, our subproblem identified negative cycles in a network, and each cut was designed to break one such cycle.) There is also recent work on what was coined &amp;quot;implicit hitting set&amp;quot; problems [2], where cuts are generated using an &amp;quot;oracle&amp;quot; (a subproblem that is not necessarily a linear program).&lt;/p&gt;&#xA;&lt;p&gt;[1] Codato, G. &amp;amp; Fischetti, M. Combinatorial Benders' Cuts for Mixed-Integer Linear Programming Operations Research, 2006, 54, 756-766&lt;/p&gt;&#xA;&lt;p&gt;[2] Moreno-Centeno, E. &amp;amp; Karp, R. M. The Implicit Hitting Set Approach to Solve Combinatorial Optimization Problems with an Application to Multigenome Alignment Operations Research, 2013, 61, 453-468&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-30T15:30:52.860" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8959" PostTypeId="2" ParentId="8957" CreationDate="2022-08-30T17:58:16.457" Score="10" Body="&lt;p&gt;Here's a second-order cone formulation, obtained by rewriting the objective function as &lt;span class=&quot;math-container&quot;&gt;$$\sum_i \frac{1}{a_i} \left(1 - \frac{b_i}{a_i x_i + b_i}\right)$$&lt;/span&gt; and introducing &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; to represent the denominator and &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$1/z_i$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{maximize} &amp;amp;\sum_i \frac{1}{a_i} (1 - b_i  y_i) \\&#xA;&amp;amp;\text{subject to} &amp;amp; \sum_i x_i &amp;amp;= S \\&#xA;&amp;amp;&amp;amp; z_i &amp;amp;= a_i x_i + b_i &amp;amp;&amp;amp;\text{for all $i$}\\&#xA;&amp;amp;&amp;amp; w &amp;amp;= \sqrt 2 \\&#xA;&amp;amp;&amp;amp; 2 y_i z_i &amp;amp;\ge w^2 &amp;amp;&amp;amp;\text{for all $i$} \tag1\label1\\&#xA;&amp;amp;&amp;amp; x_i &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $i$}\\&#xA;&amp;amp;&amp;amp; y_i &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $i$}&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} is a rotated second-order cone constraint.  Everything else is linear.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; The reformulation above arose from the development version of a new conic transformation feature in SAS, available in production today.  The following SAS code demonstrates the automatic transformation from algebraic form:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/* generate random input data */&#xA;%let n = 3;&#xA;%let s = 2;&#xA;data indata;&#xA;   do i = 1 to &amp;amp;n;&#xA;      a = rand('UNIFORM');&#xA;      b = rand('UNIFORM');&#xA;      output;&#xA;   end;&#xA;run;&#xA;&#xA;proc optmodel;&#xA;   /* declare parameters and read data */&#xA;   set OBS;&#xA;   num a {OBS};&#xA;   num b {OBS};&#xA;   read data indata into OBS=[i] a b;&#xA;&#xA;   /* declare optimization problem */&#xA;   var X {OBS} &amp;gt;= 0;&#xA;   max Objective = sum {i in OBS} (1 / a[i]) * (1 - b[i] / (a[i] * X[i] + b[i]));&#xA;   con C: sum {i in OBS} X[i] = &amp;amp;s;&#xA;&#xA;   /* optionally expand reformulated problem */&#xA;   expand / conic;&#xA;&#xA;   /* call conic solver (automatically reformulating under the hood) */&#xA;   solve with conic;&#xA;&#xA;   /* print solution */&#xA;   print a b X;&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-10-20T16:25:31.443" LastActivityDate="2022-10-20T16:25:31.443" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8960" PostTypeId="2" ParentId="8956" CreationDate="2022-08-30T19:49:19.327" Score="10" Body="&lt;p&gt;If you search for &amp;quot;Dantzig Wolfe&amp;quot; on &lt;a href=&quot;https://scholar.google.com/schhp?hl=fr&amp;amp;as_sdt=0,5&quot; rel=&quot;noreferrer&quot;&gt;Google Scholar&lt;/a&gt;, and remove all articles before 2022, you still have &lt;a href=&quot;https://scholar.google.com/scholar?start=40&amp;amp;q=dantzig%20wolfe%20decomposition&amp;amp;hl=fr&amp;amp;as_sdt=0,5&amp;amp;as_ylo=2022&quot; rel=&quot;noreferrer&quot;&gt;427&lt;/a&gt; papers that come out. So I think it is safe to say that DW is still popular and trendy in the OR field.&lt;/p&gt;&#xA;&lt;p&gt;This is probably due to the fact that many industrial applications rely on the powerful Dantzig-Wolfe decomposition.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-08-30T19:49:19.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8961" PostTypeId="2" ParentId="8892" CreationDate="2022-08-31T09:07:13.220" Score="3" Body="&lt;p&gt;In Gurobi, there is a parameter called &lt;code&gt;seed&lt;/code&gt; which &amp;quot;typically leads to different solution paths&amp;quot;. But the default value is &lt;code&gt;0&lt;/code&gt; (rather than some dynamically changing value), so that the solution is usually reproducible by default. I think randomly setting this parameter will make your solution stochastic.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2022-08-31T09:07:13.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8962" PostTypeId="1" AcceptedAnswerId="8963" CreationDate="2022-08-31T09:44:16.043" Score="2" ViewCount="283" Body="&lt;p&gt;I wish to assign customers to their nearest distribution hubs. These hubs have maximum capacities however, and if these are breached I would like to assign customers to the next most appropriate hub.&lt;/p&gt;&#xA;&lt;p&gt;Currently I am trying to use a multiple knapsack problem in or-tools (happy to use other) to code a python warehouse optimisation.&lt;/p&gt;&#xA;&lt;p&gt;In this scenario I am treating the drivetime as my value (although I actually seek to minimise it so am using the inverse square) and the capacity as a weight.&lt;/p&gt;&#xA;&lt;p&gt;The problem is that the value (drivetime) will vary by warehouse and therefore changes.&lt;/p&gt;&#xA;&lt;p&gt;Is there any solutions to solve this?&lt;/p&gt;&#xA;&lt;p&gt;I think knapsack is the correct solution, but if there is something else I should try please feel free to correct me - for example assignment feels potentially more appropriate.&lt;/p&gt;&#xA;&lt;p&gt;Am trying to do in Python as well.&lt;/p&gt;&#xA;" OwnerUserId="10306" LastEditorUserId="10306" LastEditDate="2022-08-31T12:00:44.443" LastActivityDate="2022-08-31T15:53:33.080" Title="Multiple Knapsack with Varying Values" Tags="|python|or-tools|assignment-problem|knapsack|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8963" PostTypeId="2" ParentId="8962" CreationDate="2022-08-31T15:53:33.080" Score="2" Body="&lt;p&gt;This sounds like a &lt;a href=&quot;https://en.wikipedia.org/wiki/Generalized_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;generalized assignment problem&lt;/a&gt;. You can solve it with a MIP solver and any suitable Python modeling package/interface. I'm not a Python user, but &lt;a href=&quot;https://www.pyomo.org/about&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo&lt;/a&gt; and &lt;a href=&quot;https://coin-or.github.io/pulp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PuLP&lt;/a&gt; seem to be popular choices.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-08-31T15:53:33.080" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8964" PostTypeId="1" CreationDate="2022-09-01T07:08:14.513" Score="5" ViewCount="612" Body="&lt;p&gt;What should you do when you face an infeasible solution? I have implemented the model with the dataset from the paper but found infeasible solution.&lt;/p&gt;&#xA;" OwnerUserId="10000" LastEditorUserId="2556" LastEditDate="2022-09-01T07:47:32.533" LastActivityDate="2022-09-01T15:13:37.783" Title="Model infeasible" Tags="|optimization|modeling|nonlinear-programming|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8965" PostTypeId="2" ParentId="8964" CreationDate="2022-09-01T07:46:42.490" Score="8" Body="&lt;p&gt;You could try the following approaches:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Find the &lt;a href=&quot;https://documentation.sas.com/doc/en/casmopt/8.3/casmopt_optlp_details19.htm&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;Irreducible Infeasible Set&lt;/em&gt;&lt;/a&gt; (most solvers can do this for you). This will give you an infeasible subset of constraints and variable bounds that will become feasible if any single constraint or variable bound is removed and can thus help you identify what is going on.&lt;/li&gt;&#xA;&lt;li&gt;Iteratively relax groups of constraints, and check which one is making the problem infeasible. Once you have identified which constraint is causing infeasibility, you could penalize its violation in the objective function.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You could also share your model and your code for external help. And last but not least, you could contact the authors of the paper (last resort) if the problem proves to be indeed infeasible with the published data set.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-09-01T09:49:23.750" LastActivityDate="2022-09-01T09:49:23.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8966" PostTypeId="2" ParentId="8964" CreationDate="2022-09-01T10:56:00.363" Score="3" Body="&lt;p&gt;Infeasibility in many cases comes from two things. First, the issues in the relationship between the defined variables and corresponding constraints (buggy model), and the second, the RHS values. Besides what mentioned by Kuifje, the answers of Matteo Fischetti and other community members in this &lt;a href=&quot;https://or.stackexchange.com/questions/1215/infeasibility-in-mathematical-optimization-models&quot;&gt;link&lt;/a&gt; would be very interested.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Adding slack variables (with a high penalty in the objective function)&#xA;converts hard constraints into soft ones, and can also be useful to&#xA;locate the source of infeasibility. This approach can be very useful&#xA;for feasible problems for which finding a heuristic feasible solution&#xA;is hard/very time-consuming.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-09-01T10:56:00.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8967" PostTypeId="2" ParentId="8964" CreationDate="2022-09-01T15:13:37.783" Score="2" Body="&lt;p&gt;Does the paper you mention contain the optimal solution? If so, just substitute it into each of your constraints and look for one that is violated. That constraint presumably contains an error.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-09-01T15:13:37.783" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8969" PostTypeId="1" AcceptedAnswerId="8970" CreationDate="2022-09-05T17:59:16.967" Score="8" ViewCount="1457" Body="&lt;p&gt;I'm curious whether Reinforcement Learning is or will become the state of the art solution for (mixed) integer programming. I imagine that this would fall under the umbrella of heuristics. Companies like Amazon have hundreds of thousands of vehicles to route, dozens of warehouses, and millions of items. Exact solutions through more traditional approaches are likely infeasible due to cost. And with the advent of cloud computing and state of research in deep learning, RL in this capacity seems inevitable. What is the status of research here?&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="36" LastEditDate="2022-09-05T19:37:29.273" LastActivityDate="2022-09-06T07:56:47.020" Title="Status of reinforcement learning for (mixed) integer programming?" Tags="|mixed-integer-programming|literature-research|reinforcement-learning|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8970" PostTypeId="2" ParentId="8969" CreationDate="2022-09-05T18:43:57.117" Score="9" Body="&lt;p&gt;Firstly, be ware that &amp;quot;traditional approaches&amp;quot; do not need to be exact. Heuristics are a big thing in OR for decades.&lt;/p&gt;&#xA;&lt;p&gt;Now to answer your question: Reinforcement learning is not state-of-the-art for MILP problems (as of 2022). In fact, I am not aware of a single (well-known) (MI-) LP problem where RL outperforms specifically designed heuristics. I also do not believe companies like Amazon use RL for their routing decisions. If RL is used, then typically for stochastic and dynamic routing problems.&lt;/p&gt;&#xA;&lt;p&gt;For further information I suggest you look at the following article&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Yoshua Bengio, Andrea Lodi, &amp;amp; Antoine Prouvost (2021). Machine learning for combinatorial optimization: A methodological tour d’horizon. European Journal of Operational Research, 290(2), 405-421.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2022-09-05T18:43:57.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8971" PostTypeId="2" ParentId="8953" CreationDate="2022-09-05T20:32:14.040" Score="2" Body="&lt;p&gt;You can check the &lt;a href=&quot;http://cgm.cs.mcgill.ca/%7Eavis/C/lrs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;lrs&lt;/a&gt; software implemented by David Avis from McGill. The software implements the &lt;em&gt;reverse search&lt;/em&gt; algorithm described in this serie of papers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://cgm.cs.mcgill.ca/%7Eavis/doc/rs/rsorigins.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Reverse Search: Origins&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Since the output is never stored in memory, it can handle large-size instances. Moreover, you can stop the execution after a given number of iterations (it seems you don't need all of the vertices).&lt;/p&gt;&#xA;&lt;p&gt;There is also a parallel implementation of reverse search called &lt;a href=&quot;http://cgm.cs.mcgill.ca/%7Eavis/C/lrslib/man/man1/mplrs.1.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;mplrs&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;NOTE: The tools are available from the command line, and you access to the source code written in C (I am not aware of a Python interface).&lt;/p&gt;&#xA;" OwnerUserId="171" LastEditorUserId="171" LastEditDate="2022-09-05T20:42:05.633" LastActivityDate="2022-09-05T20:42:05.633" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8972" PostTypeId="2" ParentId="8956" CreationDate="2022-09-06T01:06:44.147" Score="5" Body="&lt;p&gt;Yes. They are very popular for solving real world problems. Just search for “column generation”.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://documentation.sas.com/doc/en/ormpug/v_003/ormpug_decomp_overview.htm&quot; rel=&quot;noreferrer&quot;&gt;https://documentation.sas.com/doc/en/ormpug/v_003/ormpug_decomp_overview.htm&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="587" LastActivityDate="2022-09-06T01:06:44.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8973" PostTypeId="2" ParentId="8969" CreationDate="2022-09-06T07:56:47.020" Score="3" Body="&lt;p&gt;The combination of &amp;quot;traditional approaches&amp;quot; with, for example, RL-based approaches may be the state-of-the-art solution for the MIP (&lt;a href=&quot;https://proceedings.mlr.press/v119/tang20a.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this reference&lt;/a&gt; as an instance, in which the RL help for learning the cuts of branch-and-bound to accelerate the convergence of a traditional approach).&lt;/p&gt;&#xA;" OwnerUserId="10329" LastActivityDate="2022-09-06T07:56:47.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8974" PostTypeId="1" CreationDate="2022-09-06T12:54:20.463" Score="3" ViewCount="507" Body="&lt;p&gt;Under the hood, what algorithms does Google OR-tools support?&lt;/p&gt;&#xA;&lt;p&gt;From adjacent questions, I saw someone as this &lt;a href=&quot;https://or.stackexchange.com/questions/8145/mathematical-formulations-for-google-or-tools&quot;&gt;question&lt;/a&gt; and the answer linked to this &lt;a href=&quot;https://developers.google.com/optimization/examples&quot; rel=&quot;nofollow noreferrer&quot;&gt;repo&lt;/a&gt;. However, these sources just show how to use Google OR-tools to solve problems, not explain something akin to &amp;quot;we support Ant Colony optimization for problems A, B and C.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;I really have no idea if, on the backend, OR-tools is using established heuristic algorithms or if the developers introduced some/many novel algorithms that don't appear elsewhere in literature and/or popular solvers.&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="981" LastEditDate="2022-09-06T14:40:10.773" LastActivityDate="2022-09-06T14:40:10.773" Title="Google OR-Tools, algorithms under the hood?" Tags="|or-tools|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8975" PostTypeId="2" ParentId="8974" CreationDate="2022-09-06T13:49:29.190" Score="4" Body="&lt;p&gt;This was asked and replied multiple times&lt;/p&gt;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/54954890/what-approximate-tsp-algorithm-does-google-or-tools-use&quot;&gt;https://stackoverflow.com/questions/54954890/what-approximate-tsp-algorithm-does-google-or-tools-use&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/57123397/which-solver-do-googles-or-tools-modules-for-csp-and-vrp-use/57125734#57125734&quot;&gt;https://stackoverflow.com/questions/57123397/which-solver-do-googles-or-tools-modules-for-csp-and-vrp-use/57125734#57125734&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also: &lt;a href=&quot;https://github.com/or-tools/awesome_or-tools&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/or-tools/awesome_or-tools&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2022-09-06T13:49:29.190" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8977" PostTypeId="1" CreationDate="2022-09-06T19:29:30.720" Score="1" ViewCount="144" Body="&lt;p&gt;I have a MILP model which defines a relation between three real variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$s = f(x,y)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I want to optimize the following objective: &lt;span class=&quot;math-container&quot;&gt;$$\min_x\max_y s$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I achieve it?&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&lt;br /&gt;&#xA;The problem is MILP because the relation &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; stacks linear operations between &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; with non-linear operations that rely on binary variables.&lt;br /&gt;&#xA;To be more specific, &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a simple deep neural network with ReLU activations encoded with indicator contraints.&lt;/p&gt;&#xA;" OwnerUserId="3212" LastEditorUserId="3212" LastEditDate="2022-09-07T16:53:39.057" LastActivityDate="2022-09-07T19:15:09.260" Title="Minimax MILP problem" Tags="|mixed-integer-programming|minimax|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8978" PostTypeId="1" CreationDate="2022-09-06T21:19:52.617" Score="3" ViewCount="68" Body="&lt;p&gt;I'm investigating how I can combine a construction heuristic and a local search metaheuristic to quickly solve Capacitated Split Delivery Veichle Routing Problem (CSDVRP). The construction heuristic implemented is the one suggested in &lt;a href=&quot;https://www.scirp.org/pdf/AJOR20120200001_58723973.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;. First the heuristic creates feasible routes for each vehicle and then uses TSP to solve all the smaller instances individually to optimize the order of the visits for each vehicle. This works good and very fast.&lt;/p&gt;&#xA;&lt;p&gt;In the paper, conclusion section, the authors suggest that&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;the best solution from this construction heuristic could then be&#xA;used as a starting solution for other methods, such as ...&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I'm wondering why/how one would use other methods if the TSP already optimizes the order (gap = 0% for each route)? What exactly do they mean?&lt;/p&gt;&#xA;&lt;h4&gt;An idea for improvement of my above method&lt;/h4&gt;&#xA;&lt;p&gt;Assume I have the locations &lt;code&gt;[0,...,10]&lt;/code&gt; to visit where &lt;code&gt;0&lt;/code&gt; is the depot and I have &lt;code&gt;3&lt;/code&gt; vehicles, each with maximum capacity &lt;code&gt;Q&lt;/code&gt;, to complete the routes and each location has a certain demand associated with it. Of course the demand at the depot is zero.&lt;/p&gt;&#xA;&lt;p&gt;The construction heuristic constructs feasible routes and outputs a feasible solution like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vehicle 1 = [0,3,7,2,0]&#xA;vehicle 2 = [0,5,4,1,0]&#xA;vehicle 3 = [0,8,6,9,0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then, a TSP is run on each vehicle route and outputs an optimized order for each vehicle, given the starting solution above. As stated earlier, this works pretty well (low duality gap) and completes within 10 seconds even with very large problems (500+ locations). The downside is that the TSP only optimizes each vehicle route and not the whole fleet simultaneously, but what if I could find a better combination initially, outputted by the construction heuristic, and THEN run the TSP? Is there a way to perturb my initial solution and do some sort of local search that swaps locations between the vehicles without exceeding the capacity constraints?&lt;/p&gt;&#xA;" OwnerUserId="4222" LastActivityDate="2022-09-06T21:19:52.617" Title="How can I use a local search meta heuristic after completing construction heuristic?" Tags="|combinatorial-optimization|vehicle-routing|heuristics|metaheuristics|local-search|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8979" PostTypeId="1" AcceptedAnswerId="8983" CreationDate="2022-09-07T13:39:48.193" Score="1" ViewCount="67" Body="&lt;p&gt;I have the following linear program:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;  \min \sum_{\vec{s} \in S} \sum_{\vec{z} \in \Xi_{\vec{s}}} c(\vec{s}, \vec{z}) \times \chi(\vec{s}, \vec{z}) \label{eqADP4}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;(1 - \lambda) \times \sum_{\vec{s} \in S} \sum_{\vec{z} \in \Xi_{\vec{s}}} \chi(\vec{s}, \vec{z}) = 1&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{\vec{s} \in S} \sum_{\vec{z} \in \Xi_{\vec{s}}} \pi_{koie}(\vec{s}, \vec{z}) \times \chi(\vec{s}, \vec{z}) \geq \mathbb{E}_{\eta} [p^w_{koie}] \hspace{1cm}&#xA;    \forall k \in \mathcal{K}; o \in \mathcal{O}; i \in \mathcal{I}_k; e \in \mathcal{E}_k &#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{\vec{s} \in S} \sum_{\vec{z} \in \Xi_{\vec{s}}} \delta_{ktc}(\vec{s}, \vec{z}) \times \chi(\vec{s}, \vec{z}) \geq \mathbb{E}_{\eta} [p^m_{ktc}] \hspace{1cm}&#xA;    \forall k \in \mathcal{K}; t \in \mathcal{T}'; c \in \mathcal{C}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\chi(\vec{s}, \vec{z}) \in \mathbb{R}_{\geq0}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;By associating variables &lt;span class=&quot;math-container&quot;&gt;$y^1 \in \mathbb{R}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y^2_{koie} \in \mathbb{R}_{\ge0}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^3_{ktc} \in \mathbb{R}_{\ge0}$&lt;/span&gt; with the first, second and third constraint sets, respectively, I specify its dual model as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\max y^1 + \sum_{k,o,i,e} y^2_{koie} \times \mathbb{E}_{\eta} [p^w_{koie}] + \sum_{k,t,c} y^3_{ktc} \times \mathbb{E}_{\eta} [p^m_{ktc}]&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;(1 - \lambda) \times y^1 \leq 0&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{k,o,i,e} \pi_{koie}(\vec{s}, \vec{z}) \times y^2_{koie} + \sum_{k,t,c} \delta_{ktc}(\vec{s}, \vec{z}) \times y^3_{ktc} \leq c(\vec{s}, \vec{z}) \hspace{0.5cm} \forall \vec{s} \in S; \vec{z} \in \Xi_{\vec{s}}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;y^1 \in \mathbb{R}, y^2_{koie} \in \mathbb{R}_{\ge0}, y^3_{ktc} \in \mathbb{R}_{\ge0}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, I am not getting the same result! Please let me know if you can identify any mistakes.&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="500" LastEditDate="2022-09-07T17:19:30.443" LastActivityDate="2022-09-07T17:19:30.443" Title="Developing the dual model" Tags="|linear-programming|dual|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8980" PostTypeId="1" AcceptedAnswerId="8986" CreationDate="2022-09-07T13:40:11.673" Score="6" ViewCount="399" Body="&lt;p&gt;Consider the following convex program:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\min g(x) &amp;amp;&amp;amp; \text{such that}&#xA;\\&#xA;f_i(x) &amp;amp;\geq b_1 &amp;amp;&amp;amp; \text{ for } i \in 1,\ldots,n;&#xA;\\&#xA;f_i(x)+f_j(x) &amp;amp;\geq b_1+b_2 &amp;amp;&amp;amp; \text{ for } i,j \in 1,\ldots,n;&#xA;\\&#xA;f_i(x)+f_j(x)+f_k(x) &amp;amp;\geq b_1+b_2+b_3 &amp;amp;&amp;amp; \text{ for } i,j,k \in 1,\ldots,n;&#xA;\\&#xA;\cdots&#xA;\\&#xA;f_1(x)+\cdots+f_n(x) &amp;amp;\geq b_1+\cdots +b_n&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;That is: every function &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; is at least &lt;span class=&quot;math-container&quot;&gt;$b_1$&lt;/span&gt;; every pair of functions sum up to at least &lt;span class=&quot;math-container&quot;&gt;$b_1+b_2$&lt;/span&gt;; every three functions sum up to at least &lt;span class=&quot;math-container&quot;&gt;$b_1+b_2+b_3$&lt;/span&gt;; etc.&#xA;The &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; are constants: &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;b_1&amp;lt;\cdots &amp;lt;b_n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The problem is that the number of constraints is exponential in &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. Is there a way to attain the same outcome with a convex program of size polynomial in &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="500" LastEditDate="2022-09-08T03:01:56.640" LastActivityDate="2022-09-08T16:44:16.280" Title="How to solve this linear program with an exponential number of constraints?" Tags="|modeling|constraint|convex-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8981" PostTypeId="1" AcceptedAnswerId="8982" CreationDate="2022-09-07T14:12:54.820" Score="2" ViewCount="85" Body="&lt;p&gt;Using the CP-SAT Solver:&lt;/p&gt;&#xA;&lt;p&gt;My Model turns infeasible whenever there is no job available for a machine. Not every job can be built on every machine. Example Situtations:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Less jobs than machines&lt;/li&gt;&#xA;&lt;li&gt;No jobs buildable on a specific machine&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I have tracked down the problem to be in my circuit constraint. When i remove the AddCircuit, it works fine. But I cant tell where exactly the problem is.&lt;/p&gt;&#xA;&lt;p&gt;seq_length being an &lt;code&gt;NewIntVar (0,max_sequence,name)&lt;/code&gt; to handle the max number of similar products in sequence.&lt;/p&gt;&#xA;&lt;p&gt;Job &lt;code&gt;n&lt;/code&gt; is scheduled on machine &lt;code&gt;m&lt;/code&gt; if &lt;code&gt;x[n,m]&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for line in all_lines:&#xA;            job_starts = [job[0] for job in task_per_line[line]]&#xA;            job_ends = [job[1] for job in task_per_line[line]]&#xA;            arcs = []&#xA;            for j1 in all_orders:&#xA;                # Initial arc from the dummy node (0) to a task.&#xA;                start_lit = model.NewBoolVar('%i is first job on line %i' % (j1, line))&#xA;                arcs.append([0, j1 + 1, start_lit]&#xA;&#xA;                # Final arc from an arc to the dummy node.&#xA;                isLast = model.NewBoolVar('%i is last job on line %i' % (j1, line))&#xA;                arcs.append([j1 + 1, 0, isLast])&#xA;&#xA;                model.AddImplication(x[j1, line].Not(), start_lit.Not())&#xA;                model.AddImplication(x[j1, line].Not(), isLast.Not())&#xA;                model.Add(job_starts[j1] == 0).OnlyEnforceIf([start_lit])&#xA;&#xA;                # initializing seq lengths&#xA;                model.Add(seq_lengths[j1, line] == 1).OnlyEnforceIf(start_lit)&#xA;                for j2 in all_orders:&#xA;                    if j1 == j2:&#xA;                        arcs.append([j1 + 1, j1 + 1, x[j1, line].Not()])&#xA;                        continue&#xA;                    lit = model.NewBoolVar('%i follows %i on line %i' % (j2, j1, line))&#xA;                    model.AddImplication(lit, x[j1, line])&#xA;                    model.AddImplication(lit, x[j2, line])&#xA;                    arcs.append([j1 + 1, j2 + 1, lit])&#xA;                    model.Add(job_starts[j2] == job_ends[j1] ).OnlyEnforceIf(lit)&#xA;&#xA;                    # Respecting max sequence&#xA;                    if same_product:&#xA;                        model.Add(seq_lengths[j2, line] == seq_lengths[j1, line] + 1).OnlyEnforceIf(lit)&#xA;                    else:&#xA;                        model.Add(seq_lengths[j2, line] == 1).OnlyEnforceIf(lit)&#xA;           model.AddCircuit(arcs)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7683" LastActivityDate="2022-09-08T08:36:10.537" Title="Circuit constraint leading to infeasibility if there are 0 jobs producable one a machine" Tags="|python|or-tools|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8982" PostTypeId="2" ParentId="8981" CreationDate="2022-09-07T14:26:16.923" Score="3" Body="&lt;p&gt;you need to add a self arc 0 -&amp;gt; 0 with a Boolean variable indicating if the circuit is empty.&lt;/p&gt;&#xA;&lt;p&gt;For for all tasks, add the implication (circuit is empty =&amp;gt; task is not performed).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for line in all_lines:&#xA;            job_starts = [job[0] for job in task_per_line[line]]&#xA;            job_ends = [job[1] for job in task_per_line[line]]&#xA;            arcs = []&#xA;            no_tasks = model.NewBoolVar(f'no_tasks in {line}')&#xA;            arcs.append([0, 0, no_tasks])&#xA;            for j1 in all_orders:&#xA;                # Initial arc from the dummy node (0) to a task.&#xA;                start_lit = model.NewBoolVar('%i is first job on line %i' % (j1, line))&#xA;                arcs.append([0, j1 + 1, start_lit]&#xA;&#xA;                # Final arc from an arc to the dummy node.&#xA;                isLast = model.NewBoolVar('%i is last job on line %i' % (j1, line))&#xA;                arcs.append([j1 + 1, 0, isLast])&#xA;&#xA;                model.AddImplication(x[j1, line].Not(), start_lit.Not())&#xA;                model.AddImplication(x[j1, line].Not(), isLast.Not())&#xA;                model.Add(job_starts[j1] == 0).OnlyEnforceIf([start_lit])&#xA;&#xA;                # link with no_tasks&#xA;                model.AddImplication(no_tasks, x[j1, line].Not())&#xA;&#xA;                # initializing seq lengths&#xA;                model.Add(seq_lengths[j1, line] == 1).OnlyEnforceIf(start_lit)&#xA;                for j2 in all_orders:&#xA;                    if j1 == j2:&#xA;                        arcs.append([j1 + 1, j1 + 1, x[j1, line].Not()])&#xA;                        continue&#xA;                    lit = model.NewBoolVar('%i follows %i on line %i' % (j2, j1, line))&#xA;                    model.AddImplication(lit, x[j1, line])&#xA;                    model.AddImplication(lit, x[j2, line])&#xA;                    arcs.append([j1 + 1, j2 + 1, lit])&#xA;                    model.Add(job_starts[j2] == job_ends[j1] ).OnlyEnforceIf(lit)&#xA;&#xA;                    # Respecting max sequence&#xA;                    if same_product:&#xA;                        model.Add(seq_lengths[j2, line] == seq_lengths[j1, line] + 1).OnlyEnforceIf(lit)&#xA;                    else:&#xA;                        model.Add(seq_lengths[j2, line] == 1).OnlyEnforceIf(lit)&#xA;           model.AddCircuit(arcs)&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2022-09-08T08:36:10.537" LastActivityDate="2022-09-08T08:36:10.537" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8983" PostTypeId="2" ParentId="8979" CreationDate="2022-09-07T15:58:10.613" Score="2" Body="&lt;p&gt;Your first dual constraint is wrong. The term &lt;span class=&quot;math-container&quot;&gt;$(1-\lambda)\times y^1$&lt;/span&gt; should be included in the left side of the second dual constraint.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-09-07T15:58:10.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8984" PostTypeId="1" CreationDate="2022-09-07T18:31:02.437" Score="2" ViewCount="996" Body="&lt;p&gt;I have the following optimization model in pyomo:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;from pyomo.environ import *&#xA;from pyomo.opt import SolverFactory&#xA;&#xA;&#xA;model = pyo.ConcreteModel()&#xA;&#xA;&#xA;dictCostMatrix = {&#xA;    ('Ho', 'Dao'): 139.0,&#xA;    ('Ho', 'Co'): 135.0,&#xA;    ('Ho', 'Deo'): 134.0,&#xA;    ('Ho', 'Ao'): 132.0,&#xA;    ('Bo', 'Dao'): 176.0,&#xA;    ('Bo', 'Co'): 178.0,&#xA;    ('Bo', 'Deo'): 171.0,&#xA;    ('Bo', 'Ao'): 173.0,&#xA;    ('Hn', 'Dan'): 160.5,&#xA;    ('Hn', 'Cn'): 156.5,&#xA;    ('Hn', 'Den'): 155.5,&#xA;    ('Hn', 'An'): 153.5,&#xA;    ('Bn', 'Dan'): 157.5,&#xA;    ('Bn', 'Cn'): 159.5,&#xA;    ('Bn', 'Den'): 152.5,&#xA;    ('Bn', 'An'): 154.5,&#xA;    ('Dao', 'Dan'): 20.0,&#xA;    ('Co', 'Cn'): 20.0,&#xA;    ('Deo', 'Den'): 20.0,&#xA;    ('Ao', 'An'): 20.0&#xA;    }&#xA;&#xA;upperBounds = {&#xA;    ('Ho', 'Dao'): 200,&#xA;    ('Ho', 'Co'): 200,&#xA;    ('Ho', 'Deo'): 200,&#xA;    ('Ho', 'Ao'): 200,&#xA;    ('Bo', 'Dao'): 200,&#xA;    ('Bo', 'Co'): 200,&#xA;    ('Bo', 'Deo'): 200,&#xA;    ('Bo', 'Ao'): 200,&#xA;    ('Hn', 'Dan'): 250,&#xA;    ('Hn', 'Cn'): 250,&#xA;    ('Hn', 'Den'): 250,&#xA;    ('Hn', 'An'): 250,&#xA;    ('Bn', 'Dan'): 250,&#xA;    ('Bn', 'Cn'): 250,&#xA;    ('Bn', 'Den'): 250,&#xA;    ('Bn', 'An'): 250,&#xA;    ('Dao', 'Dan'): 50,&#xA;    ('Co', 'Cn'): 50,&#xA;    ('Deo', 'Den'): 50,&#xA;    ('Ao', 'An'): 50&#xA;    }&#xA;&#xA;lowerBounds = {&#xA;    ('Ho', 'Dao'): 0,&#xA;    ('Ho', 'Co'): 0,&#xA;    ('Ho', 'Deo'): 0,&#xA;    ('Ho', 'Ao'): 0,&#xA;    ('Bo', 'Dao'): 0,&#xA;    ('Bo', 'Co'): 0,&#xA;    ('Bo', 'Deo'): 0,&#xA;    ('Bo', 'Ao'): 0,&#xA;    ('Hn', 'Dan'): 0,&#xA;    ('Hn', 'Cn'): 0,&#xA;    ('Hn', 'Den'): 0,&#xA;    ('Hn', 'An'): 0,&#xA;    ('Bn', 'Dan'): 0,&#xA;    ('Bn', 'Cn'): 0,&#xA;    ('Bn', 'Den'): 0,&#xA;    ('Bn', 'An'): 0,&#xA;    ('Dao', 'Dan'): 0,&#xA;    ('Co', 'Cn'): 0,&#xA;    ('Deo', 'Den'): 0,&#xA;    ('Ao', 'An'): 0&#xA;    }&#xA;&#xA;&#xA;# create components of the optimization program&#xA;model.i = pyo.Set(initialize=dictCostMatrix.keys())&#xA;model.x = pyo.Var(model.i, bounds=(0,None), within=Integers)&#xA;model.c = pyo.Param(model.i, initialize=dictCostMatrix)&#xA;&#xA;&#xA;# objective function&#xA;def objective(model):&#xA;    return sum(model.c[i]*model.x[i] for i in model.i)&#xA;model.obj = pyo.Objective(rule=objective, sense=minimize)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Each key in each of the dictionaries represents a pair of nodes that are connected. &lt;em&gt;dictCostMatrix&lt;/em&gt; shows the cost of the arc between the two nodes (e.g. the cost from 'Ho' to 'Dao' is 139. The dictionaries &lt;em&gt;upperBounds&lt;/em&gt; and &lt;em&gt;lowerBounds&lt;/em&gt; are describing the lower and upper bound of allowable flow between the node pairs.&lt;/p&gt;&#xA;&lt;p&gt;From this, I want to make constraints on &lt;strong&gt;model.x&lt;/strong&gt; (the decision variables) with upper and lower bounds. I would like to use the dictionaries &lt;em&gt;upperBounds&lt;/em&gt; and &lt;em&gt;lowerBounds&lt;/em&gt; for this. Is there a clever way of doing this?&lt;/p&gt;&#xA;" OwnerUserId="9909" LastActivityDate="2022-09-07T18:31:02.437" Title="Add lower and upper bounds on decision variables in Pyomo" Tags="|optimization|linear-programming|python|pyomo|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8986" PostTypeId="2" ParentId="8980" CreationDate="2022-09-08T02:24:27.990" Score="9" Body="&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$k\in\{1,\dots,n\}$&lt;/span&gt;, you want the sum of the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; smallest &lt;span class=&quot;math-container&quot;&gt;$f_i(x)$&lt;/span&gt; to be at least &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^k b_j$&lt;/span&gt;.  Equivalently, you want the sum of the &lt;span class=&quot;math-container&quot;&gt;$n-k$&lt;/span&gt; largest &lt;span class=&quot;math-container&quot;&gt;$f_i(x)$&lt;/span&gt; to be at most &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n f_i(x) - \sum_{j=1}^k b_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Introduce variable &lt;span class=&quot;math-container&quot;&gt;$y_k$&lt;/span&gt; to represent the &lt;span class=&quot;math-container&quot;&gt;$(n-k)$&lt;/span&gt;th largest &lt;span class=&quot;math-container&quot;&gt;$f_i(x)$&lt;/span&gt; and nonnegative variable &lt;span class=&quot;math-container&quot;&gt;$z_{ik}$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$\max(f_i(x)-y_k,0)$&lt;/span&gt;.  Now impose &lt;span class=&quot;math-container&quot;&gt;$n+n^2$&lt;/span&gt; constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(n-k)y_k + \sum_{i=1}^n z_{ik} &amp;amp;\le \sum_{i=1}^n f_i(x) - \sum_{j=1}^k b_j &amp;amp;&amp;amp;\text{for all $k$} \\&#xA;z_{ik} &amp;amp;\ge f_i(x) - y_k &amp;amp;&amp;amp;\text{for all $i$ and $k$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Alternatively, a slightly more direct approach is to&#xA;introduce variable &lt;span class=&quot;math-container&quot;&gt;$y_k$&lt;/span&gt; to represent the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;th smallest &lt;span class=&quot;math-container&quot;&gt;$f_i(x)$&lt;/span&gt; and nonnegative variable &lt;span class=&quot;math-container&quot;&gt;$z_{ik}$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$\max(y_k-f_i(x),0)$&lt;/span&gt;.  Now impose &lt;span class=&quot;math-container&quot;&gt;$n+n^2$&lt;/span&gt; constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;k y_k - \sum_{i=1}^n z_{ik} &amp;amp;\ge \sum_{j=1}^k b_j &amp;amp;&amp;amp;\text{for all $k$} \\&#xA;z_{ik} &amp;amp;\ge y_k - f_i(x) &amp;amp;&amp;amp;\text{for all $i$ and $k$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-09-08T16:44:16.280" LastActivityDate="2022-09-08T16:44:16.280" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8987" PostTypeId="1" CreationDate="2022-09-08T15:47:44.013" Score="2" ViewCount="149" Body="&lt;p&gt;Good afternoon, I have the following doubts&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a command in GAMS that lets me know when my problem has multiple optimal solutions?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Suppose my nonlinear optimization problem has multiple global solutions. By solving the model with GAMS I obtain a global optimal solution of that problem. The question is how to obtain a different global optimal solution without having to solve a new problem (like Magnanti-Wong for example).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Just to narrow down some ideas and attempts I made was through the magnanti Wong subproblem (&lt;a href=&quot;https://drive.google.com/file/d/1O4gCxZQxVEvMyfx_Bh7mR3ZIuN6XDxE_/view?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://drive.google.com/file/d/1O4gCxZQxVEvMyfx_Bh7mR3ZIuN6XDxE_/view?usp=sharing&lt;/a&gt;) to obtain one of those optimal global solutions different from those obtained in a classical way, however this is very difficult and I am still doing tests.&lt;/p&gt;&#xA;" OwnerUserId="9635" LastActivityDate="2022-09-08T16:34:06.930" Title="multiple solutions to a nonlinear problem in GAMS" Tags="|nonlinear-programming|gams|global-optimality|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8988" PostTypeId="2" ParentId="8987" CreationDate="2022-09-08T16:34:06.930" Score="4" Body="&lt;p&gt;The global solver Baron can give you multiple solutions using the &lt;code&gt;numsol&lt;/code&gt; option. For an example see: &lt;a href=&quot;https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_mhw4dxx.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_mhw4dxx.html&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="907" LastActivityDate="2022-09-08T16:34:06.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8989" PostTypeId="2" ParentId="4386" CreationDate="2022-09-09T16:25:03.900" Score="-1" Body="&lt;p&gt;I personally use &lt;code&gt;networkx&lt;/code&gt; some example of transportation modelling from networkx is available in my article &lt;a href=&quot;https://medium.com/towards-data-science/spatial-data-science-network-analysis-for-transportation-planning-7be048b8f37?source=user_profile---------2----------------------------&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10344" LastActivityDate="2022-09-09T16:25:03.900" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8992" PostTypeId="1" AcceptedAnswerId="8993" CreationDate="2022-09-12T20:12:09.547" Score="2" ViewCount="344" Body="&lt;p&gt;My pyomo abstract model has 2 sets with 3 parameters for each set.&lt;/p&gt;&#xA;&lt;p&gt;I am minimizing the objective function with 4 constraints as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.environ import*&#xA;model=AbstractModel() # Model Creation&#xA;&#xA;model.SUPPLIES=Set()  #Sets&#xA;model.DEMANDS=Set()&#xA;&#xA;&#xA;model.ccpu=Param(model.SUPPLIES)  #Parameters&#xA;model.csto=Param(model.SUPPLIES)&#xA;model.cmem=Param(model.SUPPLIES)&#xA;model.dcpu=Param(model.DEMANDS)&#xA;model.dsto=Param(model.DEMANDS)&#xA;model.dmem=Param(model.DEMANDS)&#xA;&#xA;model.x=Var(model.SUPPLIES, model.DEMANDS, domain=Binary)  #Decision Variable&#xA;&#xA;def objective_rule(model): #Objective Functions&#xA;    return sum(model.x[i,j]*model.dcpu[j] + model.x[i,j]*model.dmem[j] &#xA;+model.x[i,j]*model.dsto[j] for i in model.SUPPLIES for j in model.DEMANDS)&#xA;model.mincost=Objective(rule=objective_rule, sense=minimize)&#xA;&#xA;def cpu_rule(model, i): #Constraints&#xA;    return sum(model.x[i,j]*model.dcpu[j] for j in model.DEMANDS)&amp;lt;=model.ccpu[i]&#xA;const1=Constraint(model.SUPPLIES, rule=cpu_rule)&#xA;&#xA;def mem_rule(model, i):&#xA;    return sum(model.x[i,j]*model.dmem[j] for j in model.DEMANDS)&amp;lt;=model.cmem[i]&#xA;const2=Constraint(model.SUPPLIES, rule=mem_rule)&#xA;&#xA;def sto_rule(model, i):&#xA;    return sum(model.x[i,j]*model.dsto[j] for j in model.DEMANDS)&amp;lt;=model.csto[i]&#xA;const3=Constraint(model.SUPPLIES, rule=sto_rule)&#xA;&#xA;def x_rule(model,j):&#xA;    return sum(model.x[i,j] for i in model.SUPPLIES)&amp;lt;=1&#xA;const4=Constraint(model.DEMANDS, rule=x_rule)&#xA;&#xA;&#xA;data=DataPortal() #Instance Creation and Solving&#xA;data.load(filename='transportationtry.dat', model=model)&#xA;instance = model.create_instance(data)&#xA;optimizer=SolverFactory(&amp;quot;glpk&amp;quot;)&#xA;optimizer.solve(instance)&#xA;instance.display()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &amp;quot;transportationtry.dat&amp;quot; consist of the following data:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set SUPPLIES := P1 P2 P3;&#xA;&#xA;set DEMANDS := C1 C2 C3 C4;&#xA;&#xA;param: SUPPLIES: ccpu:= &#xA;&#xA;P1 35&#xA;&#xA;P2 50&#xA;&#xA;P3 40;&#xA;&#xA;param: DEMANDS: dcpu:=&#xA;&#xA;C1 1&#xA;&#xA;C2 20&#xA;&#xA;C3 5&#xA;&#xA;C4 3;&#xA;&#xA;param: SUPPLIES: csto:=&#xA;&#xA;P1 35&#xA;&#xA;P2 50&#xA;&#xA;P3 40;&#xA;&#xA;param: DEMANDS: dsto:=&#xA;&#xA;C1 10&#xA;&#xA;C2 2&#xA;&#xA;C3 10&#xA;&#xA;C4 3;&#xA;&#xA;param: SUPPLIES: cmem:=&#xA;&#xA;P1 35&#xA;&#xA;P2 50&#xA;&#xA;P3 40;&#xA;&#xA;param: DEMANDS: dmem:=&#xA;&#xA;C1 1&#xA;&#xA;C2 2&#xA;&#xA;C3 5&#xA;&#xA;C4 3;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10356" LastEditorUserId="36" LastEditDate="2022-09-12T22:00:04.533" LastActivityDate="2022-09-12T22:00:04.533" Title="Pyomo Abstract model &quot;Empty constraint block written in LP format - solver may error&quot;" Tags="|optimization|modeling|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8993" PostTypeId="2" ParentId="8992" CreationDate="2022-09-12T20:29:10.503" Score="3" Body="&lt;p&gt;You need to attach the &lt;code&gt;Constraint&lt;/code&gt; objects to the model you are building (otherwise they are not part of the model):&lt;/p&gt;&#xA;&lt;p&gt;Instead of&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;const1 = Constraint(#...&#xA;    )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;you need to do&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;model.const1 = Constraint(#...&#xA;    )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10026" LastActivityDate="2022-09-12T20:29:10.503" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8995" PostTypeId="1" CreationDate="2022-09-14T07:05:39.217" Score="2" ViewCount="93" Body="&lt;p&gt;When I am reading an &amp;quot;lp&amp;quot; file for the problem and using a MIP start reading from a &amp;quot;sol&amp;quot; file it works.&lt;/p&gt;&#xA;&lt;p&gt;But when I pass on the same model directly to cplex (without writing lp) and try to read the solve file it says it can't find the &amp;quot;sol&amp;quot; file.&lt;/p&gt;&#xA;&lt;p&gt;Why is there a difference? Passing the model works ok by itself. It's only passing the model to cplex directly and reading a &amp;quot;sol&amp;quot; file. between the &amp;quot;lp&amp;quot; file is created by cplex equation only and the &amp;quot;sol&amp;quot; file is the solution from binary relaxed option.&lt;/p&gt;&#xA;" OwnerUserId="10358" LastEditorUserId="36" LastEditDate="2022-09-14T15:59:06.287" LastActivityDate="2022-09-14T15:59:06.287" Title="MIP start in cplex using Java" Tags="|cplex|java|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8996" PostTypeId="1" CreationDate="2022-09-14T10:19:41.120" Score="4" ViewCount="302" Body="&lt;p&gt;I have a networkX graph with few nodes and these nodes have attributes such as &amp;quot;demand&amp;quot;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def mygraph():&#xA;    G = nx.Graph()&#xA;    G.add_nodes_from([(&amp;quot;N1&amp;quot;, {&amp;quot;demand&amp;quot;: 10}),&#xA;    (&amp;quot;N2&amp;quot;{&amp;quot;demand&amp;quot;: 12}),&#xA;    (&amp;quot;N3&amp;quot;, {&amp;quot;demand&amp;quot;: 25}),&#xA;    (&amp;quot;N4&amp;quot;{&amp;quot;demand&amp;quot;: 18})])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I want my Pyomo Abstract model to create constraints and decision variables dynamically. Like,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def mymodel():&#xA;    model = AbstractModel()&#xA;    g=mygraph() #mygraph passed to abstract model&#xA;    model.nodes_range = RangeSet(1,len(g))# this creates a parameter with same size of the graph&#xA;    model.C = Param(model.nodes_range, within=pyo.NonNegativeIntegers) #one parameter for each node&#xA;&#xA;    def constraint_rule(model, i): #dummy constraint&#xA;         return sum(model.decision_var*demand_node1)&amp;lt;=something&#xA;    model.const1=Constraint(model.nodes_range, rule=constraint_rule)&#xA;    &#xA;    model.obj1 = Objective(my objective) #my dummy objective&#xA;    &#xA;    status = SolverFactory('glpk')&#xA;    results = status.solve(model)&#xA;    assert_optimal_termination(results)&#xA;    model.display()&#xA;mymodel()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But the &lt;strong&gt;model.const1.pprint()&lt;/strong&gt; command is giving 0 constraints. Can you guide me with the logic?&lt;/p&gt;&#xA;" OwnerUserId="10356" LastActivityDate="2022-09-14T14:11:01.057" Title="Creating constraints dynamically in pyomo abstract model" Tags="|optimization|pyomo|constraint-programming|graphs|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8997" PostTypeId="2" ParentId="8996" CreationDate="2022-09-14T14:11:01.057" Score="3" Body="&lt;p&gt;You are missing a &lt;code&gt;model.create_instance&lt;/code&gt; call to actually construct the abstract model into a concrete instance. Calling &lt;code&gt;pprint&lt;/code&gt; on abstract model components will always return empty components because they haven't been constructed.&lt;/p&gt;&#xA;&lt;p&gt;I don't see anything in your example model that would require an &lt;code&gt;AbstractModel&lt;/code&gt; so you could also try using a &lt;code&gt;ConcreteModel&lt;/code&gt; instead and then you could call &lt;code&gt;pprint&lt;/code&gt; on components any time after declaration.&lt;/p&gt;&#xA;" OwnerUserId="583" LastActivityDate="2022-09-14T14:11:01.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8998" PostTypeId="1" CreationDate="2022-09-14T22:24:27.357" Score="1" ViewCount="96" Body="&lt;p&gt;In my PYOMO abstract model, I am reading my data file and storing some specific attributes in a list say &lt;strong&gt;demand=[]&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am reading the data file as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; for node in G.nodes:&#xA;    demand.append(G.nodes[node][&amp;quot;demand&amp;quot;])&#xA; print(demand)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am getting the output as &lt;strong&gt;[10, 12, 22, 5, 2]&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now I want to store the values in the list as individual parameters for my model such as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.d1=10&#xA;model.d2=12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and so on.&lt;/p&gt;&#xA;&lt;p&gt;Can you guide me on the logic for storing these values as individual parameters?&lt;/p&gt;&#xA;" OwnerUserId="10356" LastEditorUserId="491" LastEditDate="2022-09-28T12:53:23.067" LastActivityDate="2022-09-28T12:53:23.067" Title="Traversing a list data dynamically in Pyomo Abstract Model" Tags="|optimization|modeling|pyomo|constraint-programming|parameter|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8999" PostTypeId="1" AcceptedAnswerId="9000" CreationDate="2022-09-14T22:30:21.643" Score="7" ViewCount="292" Body="&lt;p&gt;If a Linear Program (LP) has Totally Unimodular constraint matrix, integer RHS vector, and has an optimal solution, then it has an integer optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;But what about additional optimal solutions which are not integer? Do any mainstream LP solvers ever return a non-integer optimal solution on such a problem? If so, can/does this happen if solved  by 1) Simplex, 2a) Interior-Point with crossover, or 2b) Interior-Point without crossover?&lt;/p&gt;&#xA;&lt;p&gt;Bottom line: Are you chancing it if you need an integer solution, but submit the problem as a continuous LP?&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-09-14T23:32:05.640" LastActivityDate="2022-09-14T23:45:04.393" Title="Non-Integral Optimal Solutions of Totally Unimodular Linear Programs" Tags="|linear-programming|totally-unimodular|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9000" PostTypeId="2" ParentId="8999" CreationDate="2022-09-14T23:38:53.793" Score="6" Body="&lt;p&gt;With presolver and crossover both disabled, the SAS interior point algorithm returns &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 1/n$&lt;/span&gt; for the (TU) problem of sending one unit of flow from node &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; in a directed network with arcs &lt;span class=&quot;math-container&quot;&gt;$(0,i)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(i,n+1)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,\dots,n\}$&lt;/span&gt; and all arc costs &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-09-14T23:45:04.393" LastActivityDate="2022-09-14T23:45:04.393" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9001" PostTypeId="1" AcceptedAnswerId="9005" CreationDate="2022-09-15T09:22:27.317" Score="1" ViewCount="95" Body="&lt;p&gt;Cost: 100,99&lt;/p&gt;&#xA;&lt;p&gt;Read Speed: 545,550&lt;/p&gt;&#xA;&lt;p&gt;Write Speed: 525,520&lt;/p&gt;&#xA;&lt;p&gt;Warranty: 3,4&lt;/p&gt;&#xA;&lt;p&gt;This means that there are 2 products that cost &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$99$&lt;/span&gt;. Their read speed is 545 MB/s and 550 MB/s. Their write speed is 525 MB/s and 520 MB/s respectively. Their warranty is 3 years and 4 years respectively. Now, I need to choose the best product between the two.&lt;/p&gt;&#xA;&lt;p&gt;What technique do I use to solve this? This is just a dummy problem because I want to learn the technique to solve these kinds of problems for bigger scales like 50 different products.&lt;/p&gt;&#xA;&lt;p&gt;I've been told that under given circumstances this problem isn't solvable. Say, I put constraints like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;write speed&amp;gt;500&#xA;&#xA;read speed&amp;gt;520&#xA;&#xA;warrranty&amp;gt;3&#xA;&#xA;cost&amp;lt;$99.99&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is this solvable now? If yes, how? I've been getting told that this could be solved by linear programming. I've a background in engineering mathematics so if you can provide some insights, hopefully, I can solve this problem.&lt;/p&gt;&#xA;" OwnerUserId="10368" LastEditorUserId="123" LastEditDate="2022-09-15T18:46:57.943" LastActivityDate="2022-09-16T12:23:38.880" Title="How to find the product with best specs at least price?" Tags="|linear-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9002" PostTypeId="1" AcceptedAnswerId="9003" CreationDate="2022-09-15T10:59:37.343" Score="5" ViewCount="200" Body="&lt;p&gt;I am working on a flow problem with side constraints. More specifically, I have a usual flow problem, with constraints that require some arcs to have exactly one unit of flow on them. This makes the problem &amp;quot;hard&amp;quot;, as the classic formulation for flows may leed to subtours.&lt;/p&gt;&#xA;&lt;p&gt;The structure of my graph is such that &lt;strong&gt;the subtours can only have an even number of arcs larger than 4&lt;/strong&gt;. So if I impose that I have exactly 5 arcs, with one leaving the source, and one entering the sink, I eliminate solutions with subtours.&lt;/p&gt;&#xA;&lt;p&gt;I am interested in solutions with 7 arcs, and am trying to come up with a &amp;quot;simple&amp;quot; constraint (no MTZ constraints, nor typical subtour elimination constraints from the TSP, nor no-good cuts) that eliminates solutions with a subtour of 4 arcs, and a path from source to sink with 2 intermediate nodes.&lt;/p&gt;&#xA;&lt;p&gt;Any ideas ?&lt;/p&gt;&#xA;&lt;p&gt;For more clarity, here is an example of a solution that I would like to eliminate (the blue triangle indicates that I need a unit of flow on this arc):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Yl0U8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Yl0U8.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And here is a valid solution with 7 arcs:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gG1Dc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gG1Dc.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="500" LastEditDate="2022-09-15T15:16:34.173" LastActivityDate="2022-09-15T15:16:34.173" Title="Flow problem with side constraints: how to eliminate subtours?" Tags="|linear-programming|modeling|graphs|network-flow|subtour-elimination|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9003" PostTypeId="2" ParentId="9002" CreationDate="2022-09-15T12:35:51.103" Score="3" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; be the set of arcs in a  subtour of size &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;. No-good cuts are simple but weak: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{(i,j)\in S} x_{ij} \le 4 - 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Depending on the objective, you might get by with instead imposing no-good cuts for &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;-arc paths &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; that start at the head of a forced arc and end at the tail of that same forced arc: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{(i,j)\in P} x_{ij} \le 3 - 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For comparison, note that generalized subtour elimination constraints (GSEC), which you explicitly wanted to avoid, would cut off &lt;span class=&quot;math-container&quot;&gt;$(4-1)!$&lt;/span&gt; subtours (instead of just &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;) at a time.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-09-15T13:45:47.417" LastActivityDate="2022-09-15T13:45:47.417" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9004" PostTypeId="1" CreationDate="2022-09-15T13:39:47.533" Score="3" ViewCount="38" Body="&lt;p&gt;I have a recursive function that looks something like this. The variable x is a continuous variable. Do anyone have a reference that looks into a similar problem? &lt;span class=&quot;math-container&quot;&gt;$$f_i(y)=\min_{0\le x\le\overline{X_i}}\{f_{i-1}(y+B_i-x)+c_i(y+x)\}$$&lt;/span&gt; The base case is &lt;span class=&quot;math-container&quot;&gt;$f_0(y)=0\quad\forall y\in[0,B]$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9151" LastEditorUserId="123" LastEditDate="2022-09-15T18:46:41.317" LastActivityDate="2022-09-15T18:46:41.317" Title="Requesting references about recursive functions where the variables are continuous" Tags="|reference-request|continuous-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9005" PostTypeId="2" ParentId="9001" CreationDate="2022-09-15T15:41:15.183" Score="4" Body="&lt;p&gt;If you are just choosing between two or more products, it has nothing to do with linear programming. You are looking for a utility function to rank the products. Typically, this presumes that (a) you have multiple decision makers and (b) each is capable of looking at a pair of products and deciding which one they prefer. You might want to look at the Wikipedia entries for &lt;a href=&quot;https://en.wikipedia.org/wiki/Multi-attribute_utility&quot; rel=&quot;nofollow noreferrer&quot;&gt;multi-attribute utility&lt;/a&gt; and maybe the &lt;a href=&quot;https://en.wikipedia.org/wiki/Analytic_hierarchy_process&quot; rel=&quot;nofollow noreferrer&quot;&gt;analytic hierarchy process&lt;/a&gt;. In the latter, you ask the decision maker(s) questions like &amp;quot;which is more important, cost or warranty, and by how much?&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-09-15T15:41:15.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9006" PostTypeId="2" ParentId="9004" CreationDate="2022-09-15T15:45:09.253" Score="1" Body="&lt;p&gt;If the intent is to optimize &lt;span class=&quot;math-container&quot;&gt;$f_N(y)$&lt;/span&gt; for some fixed &lt;span class=&quot;math-container&quot;&gt;$N,$&lt;/span&gt; it might be a form of &lt;a href=&quot;https://en.wikipedia.org/wiki/Dynamic_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;dynamic programming&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-09-15T15:45:09.253" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9007" PostTypeId="1" CreationDate="2022-09-16T05:43:51.850" Score="4" ViewCount="188" Body="&lt;p&gt;The scenario is a game where each round you can buy or sell farms that make a set profit each round. I thought about applying branch-and-bound to a game tree, where each node represents the game state after each round, after buying/selling. The heuristic function I imagined is an estimate of how much money can be made &amp;quot;doing nothing from now&amp;quot; and in my case is an increasing function of depth. To my understanding, the branch-and-bound algorithm is, after initializing the queue with the initial game state, repeatedly pop a node off and branch if the bounded node heuristic value is better than an established lower bound (for a maximization problem).&lt;/p&gt;&#xA;&lt;p&gt;From reading an overview of branch-and-bound, the bound is supposed to be a provable upper bound, but how can this actually be proved for a complex game?  Instead, are the following simple bound methods I came up reasonable?&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Compute the bound as the heuristic value discounted by a fixed fraction, say 0.8, to encourage exploring locally suboptimal branches. If the bound is simply set to the heuristic value at the node, is this simply a greedy search?&lt;/li&gt;&#xA;&lt;li&gt;Instead of a fixed bounding function, consider best-first and limit the queue size to prevent considering too many nodes. But the runtime seems difficult to calculate to me as it's highly dependent on the structure of the tree and the order in which nodes are considered.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also, if best-first is used with an increasing heuristic function, will this act like a depth-first search, since the first path chosen is increasing?&lt;/p&gt;&#xA;" OwnerUserId="10374" LastActivityDate="2022-09-16T11:33:18.587" Title="Bounding function for branch-and-bound in game tree search" Tags="|branch-and-bound|puzzles-games|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9008" PostTypeId="2" ParentId="8998" CreationDate="2022-09-16T08:29:35.510" Score="1" Body="&lt;p&gt;This can be accomplished using the INDEXED COMPONENT concept of Pyomo.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.d = Param(demand, within=NonNegativeIntegers)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The Pyomo book explains this in chapter 3 and it is available at &lt;a href=&quot;https://link.springer.com/book/10.1007/978-3-030-68928-5&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10356" LastActivityDate="2022-09-16T08:29:35.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9009" PostTypeId="2" ParentId="9007" CreationDate="2022-09-16T11:33:18.587" Score="6" Body="&lt;p&gt;A classical branch-and-bound is an algorithm used to prove optimality. In the end, all nodes have been explored. The bound is exact and is a critical component of the algorithm.&lt;/p&gt;&#xA;&lt;p&gt;What you are looking for is not really a branch-and-bound algorithm, but rather just a &amp;quot;tree search&amp;quot; or &amp;quot;heuristic tree search&amp;quot; algorithm. In this case, we know in advance that there are to many nodes to be explored. Instead of looking for a bound to prune some nodes, we try to guide the search to explore in priority the regions of the search tree which look the most promising.&lt;/p&gt;&#xA;&lt;p&gt;The subject is a bit too broad to explain everything here. &lt;a href=&quot;https://raw.githubusercontent.com/fontanf/teaching/main/2021-2022%20-%20M2%20ORCO%20-%20Advanced%20OR/2%20-%20Heuristic%20Tree%20Search/slides/slides.pdf&quot; rel=&quot;noreferrer&quot;&gt;Here are the slides&lt;/a&gt; of the class I teach about heuristic tree search, which should provide a good starting point.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-09-16T11:33:18.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9010" PostTypeId="2" ParentId="9001" CreationDate="2022-09-16T12:23:38.880" Score="4" Body="&lt;p&gt;If someone told you that linear programming could be applied to this problem, it could be that they were thinking of Data Envelopment Analysis (DEA), - see Wikipedia.&#xA;DEA assumes a linear utility, i.e., you choose a weight for each feature such as read speed, cost, etc. For a given set of weights, the preferred device is the one that maximizes the weighted sum. DEA answers the questions:&lt;/p&gt;&#xA;&lt;p&gt;For each device j:&lt;br /&gt;&#xA;Is there a set of weights that makes j the preferred device, or if&#xA;the device is dominated, is there no set of weights that makes&#xA;device j preferred.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastActivityDate="2022-09-16T12:23:38.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9011" PostTypeId="1" AcceptedAnswerId="9012" CreationDate="2022-09-16T12:49:30.400" Score="2" ViewCount="113" Body="&lt;p&gt;&lt;em&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Linear programming problems (LP) have a convex space, precisely vector space, such as a convex feasible region as pointed out by @prubin. Also, they may have either unique or multiple solutions. (there are already other types).&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, there is still a concept named &lt;code&gt;strictly convex&lt;/code&gt; that interprets:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;a strictly convex space is a normed vector space (X, || ||) for which the closed unit ball is a strictly convex set.&#xA;Put another way, a strictly convex space is one for which, given any two distinct points x and y on the unit sphere ∂B&#xA;(i.e. the boundary of the unit ball B of X), the segment joining x and y meets ∂B only at x and y.&#xA;Strict convexity is somewhere between an inner product space (all inner product spaces being strictly convex) and a general&#xA;normed space in terms of structure. It also guarantees the uniqueness of the best approximation to an element in X (strictly convex)&#xA;out of a convex subspace Y, provided that such an approximation exists.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The distinction between these two concepts comes in the following (for more details please, see this &lt;a href=&quot;https://math.stackexchange.com/questions/2780443/difference-of-convexity-and-strict-convexity/2780464#2780464&quot;&gt;link&lt;/a&gt;):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A function &lt;span class=&quot;math-container&quot;&gt;$f: \mathbb{R} \to \mathbb{R}$&lt;/span&gt; is convex if for all &lt;span class=&quot;math-container&quot;&gt;$x,y&#xA;&amp;gt; \in \mathbb{R}$&lt;/span&gt; and for all &lt;span class=&quot;math-container&quot;&gt;$\lambda \in (0,1)$&lt;/span&gt; the following holds:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(\lambda x +(1-\lambda)y) \leq \lambda f(x) +(1-\lambda) f(y)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Geometrically this means that the line through two points &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; and&#xA;&lt;span class=&quot;math-container&quot;&gt;$f(y)$&lt;/span&gt; on the graph is always &lt;em&gt;above&lt;/em&gt; the graph between &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We say that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is strictly convex if the above inequality holds&#xA;strictly, i.e. &lt;span class=&quot;math-container&quot;&gt;$$f(\lambda x +(1-\lambda)y) &amp;lt; \lambda f(x)&#xA;&amp;gt; +(1-\lambda) f(y)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Since I would like to know, 1) What does exactly it mean? 2) Is there any simple example, in the context of LP and MIP, to illustrate that? 3)If an LP has a such space, might it have only a unique solution?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2022-09-20T08:34:29.743" LastActivityDate="2022-09-20T15:32:09.133" Title="Convex not strictly convex!" Tags="|mixed-integer-programming|linear-programming|convexity|polyhedra|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9012" PostTypeId="2" ParentId="9011" CreationDate="2022-09-16T16:08:35.827" Score="3" Body="&lt;p&gt;I think you are confusing two things here. A linear program has a convex &lt;em&gt;feasible region&lt;/em&gt;. The term &amp;quot;convex space&amp;quot; refers to an entire vector space, not to a particular region (such as an LP feasible region) within the space. It basically imposes a restriction on the nature of the norm used in defining the space.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Can we refer to the feasible set of linear programming as strictly convex?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The term &amp;quot;strictly convex&amp;quot; only applies to functions, not to sets.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Can we say any subset of a convex set/space would be a convex set/space?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;No. Consider the triangle &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; defined by &lt;span class=&quot;math-container&quot;&gt;$x \geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y \geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x + y&#xA; \leq 1$&lt;/span&gt;, which is convex. The subset consisting of the vertices,&#xA;&lt;span class=&quot;math-container&quot;&gt;$\{(0,0), (0,1), (1,0)\}$&lt;/span&gt; is not convex. Neither is the set &lt;span class=&quot;math-container&quot;&gt;$\{(x,y)&#xA; \in T : x^2 + y^2 \geq 1/2\}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-09-20T15:32:09.133" LastActivityDate="2022-09-20T15:32:09.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9013" PostTypeId="1" CreationDate="2022-09-18T07:14:19.070" Score="2" ViewCount="200" Body="&lt;p&gt;My question is kind of related to &lt;a href=&quot;https://stackoverflow.com/questions/28533831/find-all-alternative-basic-solutions-using-existing-linear-programming-tool&quot;&gt;this 2015 post at Stackoverflow&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;About Simplex method tableau pivoting in Linear Programming -- this is proving to be difficult in GLPK.. I am using Linux, GLPK 5.0 version, in C language.. I want to do this so as to obtain multiple (alternate) &lt;strong&gt;basic&lt;/strong&gt; optimal solutions (Optimal &lt;em&gt;BFS&lt;/em&gt;, or Optimal &lt;em&gt;Extreme Points&lt;/em&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Is it sufficient to specify the variable entering the basis?  Or do I need to specify both the entering variable &lt;strong&gt;and&lt;/strong&gt; the variable leaving the basis?&lt;/p&gt;&#xA;&lt;p&gt;What I have tried so far:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;probA = glp_create_prob();&#xA;glp_read_lp(probA, NULL, &amp;quot;Model-Old.lp&amp;quot;);   // Read original LP model (in CPLEX LP format)&#xA;glp_read_sol(probA, &amp;quot;basic-solution-old.txt&amp;quot;);  // Load basic solution created earlier&#xA;glp_set_col_stat(probA, 2, GLP_BS);   // Set variable x2 to enter the basis&#xA;glp_set_col_stat(probA, 4, GLP_NL);   // Set x4 to leave the basis (and become zero)&#xA;glp_simplex(probA, GLP_OFF);   // Turn off Pre-solver and solve the new problem.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Unfortunately the above doesn't work (I have tried with different entering and leaving variables)..  How can I fix the code above?  Or is there a better way to do re-optimisation in GLPK (with C language)?  Thanks.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I looked up my favourite book in Linear Programming, by George Hadley (this was the &lt;em&gt;textbook&lt;/em&gt; we followed 35 years ago, in 1987!).. In Section 5-7 (Page 166), he describes a method to reach alternate optimal BFS by pivoting.. I'm trying to implement this (don't know if there are better approaches now).&lt;/p&gt;&#xA;&lt;p&gt;(I've just been reading &lt;a href=&quot;https://or.stackexchange.com/questions/7996/can-the-primal-simplex-method-walk-all-optima-in-linear-time/8031#8031&quot;&gt;this answer a few months ago from Henrik Friberg&lt;/a&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="7218" LastEditorUserId="500" LastEditDate="2023-12-13T18:04:52.067" LastActivityDate="2023-12-13T18:04:52.067" Title="Simplex Method Manual pivoting in GLPK for a Warm Start" Tags="|linear-programming|solver|simplex|api|warm-start|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9014" PostTypeId="1" CreationDate="2022-09-18T21:52:31.197" Score="8" ViewCount="266" Body="&lt;p&gt;I am using column generation to solve a minimization problem.&lt;/p&gt;&#xA;&lt;p&gt;At a given iteration, my subproblem finds a column with reduced cost &lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt;, and in the following restricted master problem, this new column takes value &lt;span class=&quot;math-container&quot;&gt;$13$&lt;/span&gt;, so I would expect the objective function to decrease by &lt;span class=&quot;math-container&quot;&gt;$13$&lt;/span&gt; units. But is only decreasing by &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt;. Is there an explanation for this?&lt;/p&gt;&#xA;" OwnerUserId="10385" LastEditorUserId="500" LastEditDate="2022-09-18T22:31:34.447" LastActivityDate="2022-09-18T23:01:33.427" Title="Column generation: decreasing value of restricted master problem" Tags="|linear-programming|column-generation|simplex|reduced-costs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9015" PostTypeId="2" ParentId="9014" CreationDate="2022-09-18T23:01:33.427" Score="8" Body="&lt;p&gt;The reduced cost is the instantaneous rate of change as you increase the value of the new variable from 0. The actual impact of the new variable on the objective function is piecewise linear and concave. So as you increase the new variable from 0, initially our objective improves one unit per unit of the new variable, then beyond some amount less than rate 1, then beyond some further amount at an even lower rate, and eventually the objective begins to get worse if you keep increasing the new variable (unless you first hit a value beyond which the problem becomes infeasible). As you increase the new variable, periodically you will need to pivot (because some other variable hits an upper or lower bound), and with each pivot the rate of change of the objective function changes.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-09-18T23:01:33.427" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9016" PostTypeId="1" AcceptedAnswerId="9027" CreationDate="2022-09-19T05:55:53.113" Score="3" ViewCount="116" Body="&lt;p&gt;I'm currently studying about totally unimodular.&lt;/p&gt;&#xA;&lt;p&gt;I was reading this link: &lt;a href=&quot;https://ostad.nit.ac.ir/upload/Integer_Programming_1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ostad.nit.ac.ir/upload/Integer_Programming_1.pdf&lt;/a&gt;, from page 38-41 and I came across the statement:&lt;/p&gt;&#xA;&lt;p&gt;'It is clear that when matrix A is totally unimodular, the linear programming relaxation solves the IP:  &lt;span class=&quot;math-container&quot;&gt;$\max\{cx:Ax \leq b, x \in Z_{+}^n\}.$&lt;/span&gt;'&lt;/p&gt;&#xA;&lt;p&gt;I've read and understand about TU (totally unimodular) based on the link above and about LP relaxation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: However, I still do not know how do I prove the statement above?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What I know&lt;/strong&gt;: I know that if &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is TU then &lt;span class=&quot;math-container&quot;&gt;$(A, I)$&lt;/span&gt; is TU for an identity matrix &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;. Also, as stated in the book that&lt;/p&gt;&#xA;&lt;p&gt;'From linear programming theory, we know that basic feasible solutions take the form:. &lt;span class=&quot;math-container&quot;&gt;$x = (x_B,x_N) = (B^{-1} b, 0)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$m \times m$&lt;/span&gt; nonsingular submatrix of &lt;span class=&quot;math-container&quot;&gt;$(A, I)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$m \times m$&lt;/span&gt; identity matrix.&lt;/p&gt;&#xA;&lt;p&gt;Observation 3.1 (Sufficient Condition) If the optimal basis &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$\det(B) = ±1$&lt;/span&gt;, then the linear programming relaxation solves IP.'&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Hypothesis&lt;/strong&gt;: Does a TU matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; always have a basis B such that &lt;span class=&quot;math-container&quot;&gt;$\det(B) =  \pm 1$&lt;/span&gt;? But if &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is TU, all its square submatrix is either 0,-1, or 1 and not 1 or -1.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Extra Note&lt;/strong&gt;: I am working on some shortest path inner problem of a variable &lt;span class=&quot;math-container&quot;&gt;$X_{ij}$&lt;/span&gt; (the original model is bi-level) where &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; represents the arc in the graph. The paper stated that since the inner problem (of the bi-level) is unimodular, we can use LP relaxation in order to use KKT to turn the bi-level into single level.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What I don't know&lt;/strong&gt;: I do not know anything about polyhedron.&lt;/p&gt;&#xA;" OwnerUserId="10331" LastEditorUserId="10331" LastEditDate="2022-09-20T19:47:37.970" LastActivityDate="2022-09-20T19:47:37.970" Title="Totally unimodular towards linear programming relaxation" Tags="|linear-programming|lp-relaxation|totally-unimodular|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9017" PostTypeId="2" ParentId="6579" CreationDate="2022-09-19T06:30:50.090" Score="3" Body="&lt;p&gt;Quick hack&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Get glpk sources&lt;/li&gt;&#xA;&lt;li&gt;Edit src/api/minisat1.c&lt;/li&gt;&#xA;&lt;li&gt;Find&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;int glp_minisat1(glp_prob *P)&#xA;{     /* solve CNF-SAT problem with MiniSat solver */&#xA;      solver *s;&#xA;      GLPAIJ *aij;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Add one line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;int glp_minisat1(glp_prob *P)&#xA;{     /* solve CNF-SAT problem with MiniSat solver */&#xA;      glp_write_cnfsat(P, &amp;quot;tmptmp.cnf&amp;quot;);&#xA;      solver *s;&#xA;      GLPAIJ *aij;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Compile&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;./configure &amp;amp;&amp;amp; make&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Run&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;examples/glpsol --lp prob.lp --minisat&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Quit solving with ctrl-c&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now you have tmptmp.cnf in the same directory.&lt;/p&gt;&#xA;" OwnerUserId="9050" LastActivityDate="2022-09-19T06:30:50.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9018" PostTypeId="1" AcceptedAnswerId="9020" CreationDate="2022-09-19T15:59:20.117" Score="7" ViewCount="376" Body="&lt;p&gt;I am programming a MIP problem. There are two continuous variables but only one can have a value and the other must then be zero.&#xA;How do I give this as a constraint?&lt;/p&gt;&#xA;" OwnerUserId="10389" LastEditorUserId="491" LastEditDate="2022-09-19T16:40:08.393" LastActivityDate="2022-09-20T07:45:36.710" Title="Set constraint mip" Tags="|mixed-integer-programming|modeling|constraint|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9020" PostTypeId="2" ParentId="9018" CreationDate="2022-09-19T16:15:56.123" Score="8" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; denote your continuous variables. Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; and impose the following constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;gt; 0 \; \Longrightarrow \; y_1 = 1$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_1 \le My_1&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_2 &amp;gt; 0 \; \Longrightarrow \; y_2 = 1$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_2 \le My_2&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; cannot be active simultaneously:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_1 +y_2 \le 1&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is an upper bound on your variables. If you have different upper bounds for &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt;, use two different values of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-09-19T16:15:56.123" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9021" PostTypeId="1" AcceptedAnswerId="9023" CreationDate="2022-09-20T02:23:12.307" Score="2" ViewCount="327" Body="&lt;p&gt;During the primal simplex algorithm, a non-basic variable must be chosen to enter the basis.&lt;/p&gt;&#xA;&lt;p&gt;Many resources on the subject choose a variable based solely on its coefficient in the row of the tableau corresponding to the objective, whereas others calculate reduced costs before making a choice.&lt;/p&gt;&#xA;&lt;p&gt;Why is there not consistency, and is one more popular in practice?&lt;/p&gt;&#xA;" OwnerUserId="10392" LastEditorUserId="491" LastEditDate="2022-09-20T22:09:44.197" LastActivityDate="2022-09-20T22:09:44.197" Title="Inconsistent teachings on how to choose a non basic variable to enter the basis (primal simplex)" Tags="|linear-programming|simplex|reduced-costs|primal-simplex|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9022" PostTypeId="2" ParentId="9018" CreationDate="2022-09-20T07:45:36.710" Score="3" Body="&lt;p&gt;With many MIP solvers, you can use SOS constraints. (SOS Type 1 is a set of variables where at most one variable may be nonzero.)&lt;/p&gt;&#xA;&lt;p&gt;SOS1 &lt;a href=&quot;https://github.com/AlexFleischerParis/zoodocplex/blob/master/zoosos1.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt; with cplex docplex python api:&#xA;from docplex.mp.model import Model&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mdl = Model(name='buses')&#xA;nbbus40 = mdl.integer_var(name='nbBus40')&#xA;nbbus30 = mdl.integer_var(name='nbBus30')&#xA;mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;mdl.minimize(nbbus40*500 + nbbus30*400)&#xA;&#xA;mdl.solve()&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&#xA;print(&amp;quot;and with SOS1&amp;quot;)&#xA;&#xA;mdl.add_sos1([nbbus40,nbbus30])&#xA;&#xA;mdl.solve()&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or you can also write your SOS1 with logical constraints. For &lt;a href=&quot;https://github.com/AlexFleischerParis/zooopl/blob/master/zoosos1.mod&quot; rel=&quot;nofollow noreferrer&quot;&gt;instance, in OPL&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int nbKids=300;&#xA;float costBus40=500;&#xA;float costBus30=400;&#xA; &#xA;dvar int+ nbBus40;&#xA;dvar int+ nbBus30;&#xA; &#xA;minimize&#xA; costBus40*nbBus40  +nbBus30*costBus30;&#xA; &#xA;subject to&#xA;{&#xA; 40*nbBus40+nbBus30*30&amp;gt;=nbKids;&#xA; &#xA; // SOS1&#xA; (nbBus40&amp;gt;=1)+(nbBus30&amp;gt;=1)&amp;lt;=1;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-09-20T07:45:36.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9023" PostTypeId="2" ParentId="9021" CreationDate="2022-09-20T10:06:50.323" Score="8" Body="&lt;p&gt;As long as you choose something with a negative reduced cost, the simplex algorithm &amp;quot;works&amp;quot;.  See &lt;a href=&quot;https://people.orie.cornell.edu/dpw/orie6300/Lectures/lec13.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://people.orie.cornell.edu/dpw/orie6300/Lectures/lec13.pdf&lt;/a&gt; for examples of ways you can choose the entering variable based on how much work you want to do.  You can't just base it on the original cost: it has to be based on the reduced cost.  Normally, this is the value in the cost row of the tableau if you are doing the full tableau method; if you are doing a more compact approach, then the reduced cost might need to be calculated (hence the value of the &amp;quot;first negative reduced cost&amp;quot; approach: you don't calculate all the reduced costs).&lt;/p&gt;&#xA;" OwnerUserId="214" LastActivityDate="2022-09-20T10:06:50.323" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9024" PostTypeId="1" AcceptedAnswerId="9025" CreationDate="2022-09-20T11:22:38.593" Score="5" ViewCount="146" Body="&lt;p&gt;I got an MPS file and a best know solution value for that problem. I do not know whether the MPS file contains a minimization or an maximization problem.&lt;/p&gt;&#xA;&lt;p&gt;How do i programmatically create a copy of that MPS file and add a constraint saying that only solutions &lt;strong&gt;strictly&lt;/strong&gt; better then best known solution value should be considered feasible?&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2022-09-21T08:02:04.737" Title="Add constraint on objective of MPS file in automated way" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9025" PostTypeId="2" ParentId="9024" CreationDate="2022-09-20T12:00:52.100" Score="5" Body="&lt;p&gt;You can use &lt;a href=&quot;https://coin-or.github.io/pulp/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;PuLP&lt;/a&gt; to read the MPS file, add the constraint, and export the new problem as an MPS file :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The syntax is &lt;code&gt;var, prob = LpProblem.fromMPS(&amp;quot;prob.mps&amp;quot;)&lt;/code&gt; to &lt;a href=&quot;https://coin-or.github.io/pulp/guides/how_to_export_models.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;read&#xA;the MPS file&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then use &lt;code&gt;prob +=&lt;/code&gt; to add your constraint.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;And finally &lt;code&gt;prob.writeMPS(&amp;quot;new_prob.mps&amp;quot;)&lt;/code&gt; to export the new MPS&lt;br /&gt;&#xA;file.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you are minimizing, the constraint would be something like &lt;code&gt;prob+= obj &amp;lt;= best_sol - tol&lt;/code&gt;, where &lt;code&gt;obj&lt;/code&gt; is the objective function which you have to fetch, &lt;code&gt;best_sol&lt;/code&gt; is your best known solution, and &lt;code&gt;tol&lt;/code&gt; is your tolerance.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Once you have loaded the MPS file as a &lt;code&gt;pulp.LpProblem&lt;/code&gt; object, it is straightforward to know wether it is a minimization problem or not with the attribute &lt;code&gt;pulp.LpProblem.sense&lt;/code&gt; which returns 1 for minimization, -1 for maximization.&lt;/p&gt;&#xA;&lt;p&gt;More generally, with &lt;code&gt;pulp.LpProblem.to_dict&lt;/code&gt;, you can access all attributes of the problem, including the objective coefficients.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-09-21T08:02:04.737" LastActivityDate="2022-09-21T08:02:04.737" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9026" PostTypeId="2" ParentId="4680" CreationDate="2022-09-20T13:26:16.307" Score="4" Body="&lt;p&gt;I had this same problem for solving a CVRP with Time Windows with python. I wrote up my solution approach in &lt;a href=&quot;https://medium.com/@sean-patrick-kelley/how-to-implement-column-generation-for-vehicle-routing-bdb8027c957f&quot; rel=&quot;nofollow noreferrer&quot;&gt;a medium article&lt;/a&gt; if you'd like to have a look.&lt;/p&gt;&#xA;" OwnerUserId="342" LastActivityDate="2022-09-20T13:26:16.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9027" PostTypeId="2" ParentId="9016" CreationDate="2022-09-20T19:35:10.300" Score="2" Body="&lt;p&gt;Does a TUM matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; always have a square submatrix &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; with determinant &lt;span class=&quot;math-container&quot;&gt;$\pm 1?$&lt;/span&gt; Technically, no. A matrix entirely filled with zeroes is TUM but obviously has no nonsingular submatrices. In the context of a linear program, the logic is as follows. Assume the problem is in canonical form (all constraints other than sign restrictions are equalities, say &lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt;). If &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$m\times n$&lt;/span&gt; and has full row rank, it will have at least one nonsingular &lt;span class=&quot;math-container&quot;&gt;$m\times m$&lt;/span&gt; submatrix. If &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; does not have full row rank, either the constraints &lt;span class=&quot;math-container&quot;&gt;$Ax=b$&lt;/span&gt; are inconsistent (meaning the problem is infeasible) or you can eliminate redundant constraints until you are left with a smaller constraint matrix that does have full row rank.&lt;/p&gt;&#xA;&lt;p&gt;Now assume that &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; has full row rank. Since &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is TUM, any basis matrix &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is TUM, which means that &lt;span class=&quot;math-container&quot;&gt;$B^{-1}$&lt;/span&gt; is integer-valued. It then follows that &lt;span class=&quot;math-container&quot;&gt;$B^{-1}b$&lt;/span&gt; is integer-valued &lt;em&gt;provided that &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is integer valued&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-09-20T19:35:10.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9028" PostTypeId="1" CreationDate="2022-09-20T21:19:31.257" Score="1" ViewCount="52" Body="&lt;p&gt;Imagine you have a total number of employees assigned to a task. Each task requires N quantity of employees for it to be 100% efficient, something like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0DCSW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0DCSW.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Each employee is assigned to a task in this way:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SP8C6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SP8C6.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where in the metaheuristic, you make changes on the assigned tasks an employee has. Once you group by task you get the total quantity of employees currently working on the task. My question is, if you want to allocate the maximum possible quantity of workers in each task in the best possible way, &lt;strong&gt;which objective function will you use?&lt;/strong&gt; I was thinking on minimizing the sum of the differences but I ran into an issue: some differences might be positive and others negative, the total sum of differences can lead to a total of zero:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/h9Ren.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h9Ren.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Are there any other kinds of objective functions to use in this kind of problem?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Already tried the following:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When the difference is positive, multiply the difference by a big number&lt;/li&gt;&#xA;&lt;li&gt;Use the absolute value of the differences&lt;/li&gt;&#xA;&lt;li&gt;Use a weighted sum of percentages (instead of differences)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1301" LastActivityDate="2022-09-20T22:30:12.193" Title="Objective function for employee assignation problem solved with simulated annealing" Tags="|combinatorial-optimization|scheduling|metaheuristics|simulated-annealing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9029" PostTypeId="2" ParentId="9028" CreationDate="2022-09-20T22:30:12.193" Score="2" Body="&lt;p&gt;I think that there is not enough information to create a optimization problem in this case. If you have more (or the same number of) employees than the needed to execute the task, all the employees have the same skills and works at the same speed, so it does not matter how you assign the employees, since you assign enough employees for each task, the solutions will be equivalent.&lt;/p&gt;&#xA;&lt;p&gt;However, if you define the amount of work needed to finish the tasks in some standard  and employee independent unit (for example man-hours or packs finisheds), define a due time to each task or different speeds to each employee, then you put one employee in one task or another can change the total number of hours, maybe cause delays or make some of them work more or less than what is defined in the contract (all those things can be individually an objective function).&lt;/p&gt;&#xA;" OwnerUserId="10397" LastActivityDate="2022-09-20T22:30:12.193" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9030" PostTypeId="1" AcceptedAnswerId="9033" CreationDate="2022-09-20T22:47:05.547" Score="5" ViewCount="2813" Body="&lt;p&gt;I have a large MIP built with PuLP in python, and want to utilize the &lt;a href=&quot;https://highs.info/&quot; rel=&quot;noreferrer&quot;&gt;HiGHS Solver&lt;/a&gt;.  However, PuLP does not have the option to use HiGHS as a solver.  One option I am aware of would be to use PuLP to write an MPS file, and call HiGHS via command line on the MPS file.  I wanted to avoid this as I am trying to develop everything within python.  Another option would be to use scipy's optimize in which HiGHS is configured to be one of the solver options.  However, it appears scipy requires the MIP to be in matrix form as an input, and does not support reading MPS files.&lt;/p&gt;&#xA;&lt;p&gt;In general, Is there a better way to utilize open-source non-default solvers with the Python PuLP interface?&lt;/p&gt;&#xA;" OwnerUserId="3255" LastActivityDate="2022-09-21T07:33:59.543" Title="How to call HiGHS solver from python PuLP MIP?" Tags="|mixed-integer-programming|linear-programming|python|solver|pulp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9031" PostTypeId="1" AcceptedAnswerId="9032" CreationDate="2022-09-21T05:40:13.457" Score="4" ViewCount="440" Body="&lt;p&gt;I have learnt that the dual simplex method requires reduced costs to be non-negative or else it cannot be used.&lt;/p&gt;&#xA;&lt;p&gt;I wanted to know what could be done to find a dual feasible basis and came across this related (if not identical) question in the math stackexchange:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://math.stackexchange.com/questions/3181411/how-to-find-initial-optimaldual-feasible-basis-which-may-not-be-primal-feasibl&quot;&gt;https://math.stackexchange.com/questions/3181411/how-to-find-initial-optimaldual-feasible-basis-which-may-not-be-primal-feasibl&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I wasn't entirely convinced by the answer, which suggests there is no way forward.  I thought there would be a way of creating a dual feasible basis - perhaps adding constraints to create the equivalent of the big M method, or two phase method in the dual space.  But I cannot find anything suggesting this.  If I ask a solver to use dual simplex to solve the problem posed in that linked question will it just say &amp;quot;no&amp;quot;?&lt;/p&gt;&#xA;" OwnerUserId="10392" LastActivityDate="2022-09-21T07:10:16.557" Title="Finding a dual feasible basis for use with the dual simplex algorithm" Tags="|linear-programming|simplex|dual-simplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9032" PostTypeId="2" ParentId="9031" CreationDate="2022-09-21T07:10:16.557" Score="6" Body="&lt;p&gt;First of all, off course there are dual phase 1 methods that find a dual feasible basis that is not necessarily primal feasible as a first step in a 2-phase dual simplex method. In Maros: &amp;quot;Computational Techniques of the Simplex Method&amp;quot; chapter 10.3 you find such a method described. An alternative is the Pan-Phase-1 described in Koberstein: &amp;quot;The dual simplex method, techniques for a fast and stable implementation&amp;quot; or together with other methods in Pan: &amp;quot;Linear Programming Computation&amp;quot; chapter 13.&lt;/p&gt;&#xA;&lt;p&gt;Apart from the fact that these methods exist, it's important to consider another fact: In the general simplex method we can have the case that all variables are boxed, i.e. they have a lower and an upper bound. In that case, the trivial slack basis (all rows are basic, all variables are non-basic) is dual feasible because boxed variables can be flipped to the other bound to obtain feasibility based on the computed reduced cost. For these problems, a dual phase 1 is not needed if you are OK with starting from a slack basis. In practice, many instances have all variables boxed or presolve can find bounds for them.&lt;/p&gt;&#xA;&lt;p&gt;Based on this observation, it is also possible to obtain a dual feasible basis by imposing artificial bounds on variables that don't have them and post-process variables that end up at these bounds at the end. Not sure if this approach is written down anywhere.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2022-09-21T07:10:16.557" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9033" PostTypeId="2" ParentId="9030" CreationDate="2022-09-21T07:33:59.543" Score="7" Body="&lt;p&gt;PuLP &lt;a href=&quot;https://github.com/coin-or/pulp/blob/master/pulp/apis/highs_api.py&quot; rel=&quot;noreferrer&quot;&gt;has an API&lt;/a&gt; for HiGHS but that version is not sent to pip yet.&lt;/p&gt;&#xA;&lt;p&gt;For the time being, you should pip install PuLP from Github. See the command taken from their readme below. &lt;em&gt;(ps. You might need to remove PuLP from pip first.)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;python -m pip install -U git+https://github.com/coin-or/pulp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then you can use &lt;code&gt;'HiGHS_CMD'&lt;/code&gt; inside &lt;code&gt;pl.getSolver&lt;/code&gt; command. &lt;a href=&quot;https://coin-or.github.io/pulp/guides/how_to_configure_solvers.html&quot; rel=&quot;noreferrer&quot;&gt;See this documentation&lt;/a&gt; for a full example (replace 'CPLEX_CMD' with 'HiGHS_CMD').&lt;/p&gt;&#xA;" OwnerUserId="4496" LastActivityDate="2022-09-21T07:33:59.543" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9034" PostTypeId="1" AcceptedAnswerId="9036" CreationDate="2022-09-21T21:04:13.437" Score="2" ViewCount="118" Body="&lt;p&gt;Suppose I'm at an optimal solution of an LP relaxation in a MILP branch-and-bound descent. I want to add an additional cut of my own devices. To compute this cut I need the extreme rays of the cone originating in the LP optimum. The rays will be recessionary (aka, leading away from the optimum); I have no intention of traveling them. This data should be available in the LP tableau (assuming a simplex algorithm), right? Can you explain to me the general process for reading extreme (or all) recession rays from the tableau extending from the current optimum?&lt;/p&gt;&#xA;&lt;p&gt;A few points of my confusion on this: Some constraints should be tight at the LP optimum, and I can find those. However, I want rays, not planes. I want intersections of those constraints -- like what we walk in the simplex algorithm. Hence, it doesn't seem like a row of the tableau. It seems like it should be a column of the tableau, like the rays should be all the columns not in the optimal basis. However, the rays should have a component corresponding to each variable, and the number of rows in the tableau is not representative of the number of variables.&lt;/p&gt;&#xA;&lt;p&gt;A third point of confusion comes from looking at SCIP. SCIP has a nice interface for adding custom &amp;quot;separators&amp;quot;. It allows me to iterate through the rows and columns of the tableau, but it's not the full tableau. It seems to be missing the slack columns, but it gives me methods for getting the LHS and RHS slack values. Whatever those are, I'm not sure how I would align them between rows. Maybe this has to do with the way the &amp;quot;revised simplex algorithm&amp;quot; stores values, which thing I don't fully understand.&lt;/p&gt;&#xA;&lt;p&gt;I'm also interested in how to iterate these rays in SCIP.&lt;/p&gt;&#xA;" OwnerUserId="7428" LastEditorUserId="491" LastEditDate="2022-09-22T16:34:05.677" LastActivityDate="2022-09-22T16:34:05.677" Title="general approach to iterating extreme rays of solution cone" Tags="|branch-and-cut|cutting-planes|cone|extreme-rays|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9035" PostTypeId="1" CreationDate="2022-09-21T23:05:50.167" Score="1" ViewCount="63" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I have a functioning MIP model in CPLEX/OPL for production planning that generates a weekly plan of what finished good items to produce on which production resource using bill-of-materials, set of resources, resource-product eligibility, resource run rate per hour and other constraints etc.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Currently the model uses a sequence of resources with specified run rate per hour to decide how to maximize production while minimizing changeovers etc.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I have a new request to introduce a variety of interim WIP storage tanks of different capacity that supports one of the job steps (for example:filling).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The key issue is the tank resource with a max capacity as a constraint being attached to an existing resource that already is being throttled by a fixed run rate per hour.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10403" LastEditorUserId="491" LastEditDate="2022-09-22T16:33:09.413" LastActivityDate="2022-09-22T16:33:09.413" Title="Introducing WIP storage tanks in a discrete time bucket model" Tags="|modeling|constraint|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9036" PostTypeId="2" ParentId="9034" CreationDate="2022-09-22T00:41:53.677" Score="2" Body="&lt;p&gt;The cone you are describing is often referred to as a &lt;em&gt;basis cone&lt;/em&gt; (for instance, in Sec 2.3 of &lt;a href=&quot;https://arxiv.org/pdf/2207.13619.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;, where the concept is used to derive cuts too). Note that you have such a cone for every feasible basis, not just the optimal one.&lt;/p&gt;&#xA;&lt;p&gt;Formally, consider a polyhedron&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;P = \{x \in \mathbb{R}^{n} \mid Ax \geq b \},&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{m \times n}$&lt;/span&gt; and a basis consisting of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; linearly independent inequalities (i.e., rows of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;).&#xA;The corresponding basis cone is defined by these &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; inequalities, whose slack variables are all non-basic (the slacks are zero because the inequalities are tight at &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Each of the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; rays of the basis cone corresponds to the edge that a simplex pivot would traverse if one of these non-basic slack variables were to enter the basis. Therefore, to find the extreme rays, all you have to do is write down what a simplex pivot would look like if each of the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; slack were to enter the basis. Of course, in general, a simplex pivot may only take a finite step, because another inequality eventually becomes tight (and the corresponding slack leaves the basis).&lt;/p&gt;&#xA;&lt;p&gt;Bottom-line: write down the equation describing each non-basic slack entering the basis, and you'll get the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; extreme rays.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="123" LastEditDate="2022-09-22T07:53:23.457" LastActivityDate="2022-09-22T07:53:23.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9038" PostTypeId="1" AcceptedAnswerId="9039" CreationDate="2022-09-22T07:44:56.443" Score="6" ViewCount="1347" Body="&lt;p&gt;I am a bit new to programming and am currently working with solving optimization problems in JuMP in Julia.&lt;/p&gt;&#xA;&lt;p&gt;I got a tip from the JuMP page that I should also use &lt;code&gt;@constraint&lt;/code&gt; if a term is quadratic. However, how do I know if a constraint is quadratic?&lt;/p&gt;&#xA;&lt;p&gt;For instance, should I use &lt;code&gt;@constraint&lt;/code&gt; or &lt;code&gt;@NLconstraint&lt;/code&gt; for &lt;span class=&quot;math-container&quot;&gt;$z - 2 + 4 z y = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x - z^2 \geq 0$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;All I know is that it should have the form &lt;span class=&quot;math-container&quot;&gt;$\frac{1}2 x H  x + q  x$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the vector with all the variables.&lt;/p&gt;&#xA;" OwnerUserId="10407" LastEditorUserId="8" LastEditDate="2022-09-24T19:14:04.690" LastActivityDate="2022-09-25T08:57:54.670" Title="Quadratic constraints in JuMP" Tags="|optimization|constraint|julia|jump|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9039" PostTypeId="2" ParentId="9038" CreationDate="2022-09-22T12:37:00.090" Score="11" Body="&lt;p&gt;A &amp;quot;quadratic constraint&amp;quot; is a constraint of the form &lt;span class=&quot;math-container&quot;&gt;$f(x) \leq 0$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is a quadratic function, i.e., as you wrote,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f(x) = \frac{1}{2}x^{T}Hx + q^{T}x + b&#xA;$$&lt;/span&gt;&#xA;for some square matrix &lt;span class=&quot;math-container&quot;&gt;$H \in \mathbb{R}^{n \times n}$&lt;/span&gt;, vector &lt;span class=&quot;math-container&quot;&gt;$q \in \mathbb{R}^{n}$&lt;/span&gt;, and some scalar &lt;span class=&quot;math-container&quot;&gt;$b \in \mathbb{R}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In JuMP, you can declare such quadratic constraints with the &lt;code&gt;@constraint&lt;/code&gt; syntax directly. The &lt;code&gt;@NLconstraint&lt;/code&gt; macro is designed for more general nonlinear that require special handling of function evaluation and derivatives. For instance, if your constraints have high-order polynomial functions (&lt;span class=&quot;math-container&quot;&gt;$x^{3}$&lt;/span&gt; and above), or terms like &lt;code&gt;sin&lt;/code&gt;, &lt;code&gt;cos&lt;/code&gt;, &lt;code&gt;log&lt;/code&gt; or &lt;code&gt;exp&lt;/code&gt;, you should use &lt;code&gt;@NLconstraint&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can have a look at the &lt;a href=&quot;https://jump.dev/JuMP.jl/stable/tutorials/nonlinear/portfolio/&quot; rel=&quot;nofollow noreferrer&quot;&gt;quadratic portfolio optimization&lt;/a&gt; and &lt;a href=&quot;https://jump.dev/JuMP.jl/stable/tutorials/nonlinear/qcp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;quadratically constrained programming&lt;/a&gt; examples from the JuMP documentation.&lt;/p&gt;&#xA;&lt;p&gt;PS: there is more JuMP-centric traffic on the &lt;a href=&quot;https://discourse.julialang.org/c/domain/opt/13&quot; rel=&quot;nofollow noreferrer&quot;&gt;Julia Discourse&lt;/a&gt; forum. You are more likely to get expert feedback there, especially on code-related questions.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="8" LastEditDate="2022-09-25T08:57:54.670" LastActivityDate="2022-09-25T08:57:54.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9040" PostTypeId="2" ParentId="9035" CreationDate="2022-09-22T15:57:38.940" Score="1" Body="&lt;p&gt;It's hard to give a meaningful answer without knowing more about your model, as Joris indicated in his comment. At a guess, you may want to add variables that represent the amount added to/removed from each storage tank in each period, along with capacity constraints and flow balance constraints (tank level = previous tank level + stuff added - stuff removed; product output from any processor = stuff going to next stage plus stuff going to tanks; product received by next stage = product passed directly from previous stage plus stuff drawn from tanks; ...).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-09-22T15:57:38.940" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9041" PostTypeId="1" AcceptedAnswerId="9045" CreationDate="2022-09-22T17:01:39.777" Score="11" ViewCount="2011" Body="&lt;p&gt;I have a constraint programming problem that is easy to formulate and solve (with high solution quality) in LocalSolver.  However, I would really prefer to use something open source for reproducibility.  I tried using CP-SAT from Google OR-Tools, but it seems to be more of a global optimizer and didn't perform as well.  I really like the &amp;quot;local search&amp;quot; approach that LocalSolver takes.  Are there any other solvers that would work well for this?&lt;/p&gt;&#xA;" OwnerUserId="10284" LastEditorUserId="981" LastEditDate="2023-12-22T15:03:43.500" LastActivityDate="2024-04-04T02:50:27.180" Title="Is there an open-source equivalent to LocalSolver?" Tags="|constraint-programming|or-tools|software|cp-sat|local-search|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9042" PostTypeId="1" AcceptedAnswerId="9043" CreationDate="2022-09-22T18:09:07.490" Score="4" ViewCount="213" Body="&lt;p&gt;I could use some help understanding what's going on here. Admittedly, I am not strong in OR, but I don't fully understand the format shown below. Is it possible somebody could format this in the type of notation that is more often found in literature?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;decision variables: x(i): select score i (binary variable)&#xA;                    s(i): final score (continuous variable)&#xA;&#xA;data:               cs(i): current (old) score&#xA;                    c(i): cost&#xA;&#xA;min cost = sum(i, c(i)*x(i))&#xA;    s(i) = cs(i)*(1-x(i)) + var1*x(i)        (1)&#xA;    sum(i, s(i)*c(i)) &amp;gt;= var2*sum(i,c(i))    (2)&#xA;    x(i) ∈ {0,1}                             (3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For example, I don't quite know what to make of&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;sum(i, c(i)*x(i))&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is this &lt;code&gt;[i + c(i)*x(i)]&lt;/code&gt; for each index? Or is this &lt;code&gt;sum[c(i)*x(i)]&lt;/code&gt; for each index?&lt;/p&gt;&#xA;" OwnerUserId="10408" LastEditorUserId="36" LastEditDate="2022-09-22T18:31:26.917" LastActivityDate="2022-09-22T19:04:12.013" Title="Canonical Form of Mixed Integer Program" Tags="|lp-format|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9043" PostTypeId="2" ParentId="9042" CreationDate="2022-09-22T18:32:45.233" Score="6" Body="&lt;p&gt;In standard mathematical notation, the problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_i c_i x_i$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;s_i &amp;amp;= \text{cs}_i(1-x_i) + \text{var}_1 x_i &amp;amp;&amp;amp;\text{for all $i$} \tag1 \\&#xA;\sum_i s_i c_i &amp;amp;\ge \text{var}_2 \sum_i c_i \tag2\label2 \\&#xA;x_i &amp;amp;\in \{0,1\} &amp;amp;&amp;amp;\text{for all $i$} \tag3 \\&#xA;\end{align}&lt;/span&gt;&#xA;The intent might also be that &lt;span class=&quot;math-container&quot;&gt;$s_i \ge 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Typically, the coefficient precedes the decision variable, so I would write the LHS of \eqref{2} instead as &lt;span class=&quot;math-container&quot;&gt;$\sum_i c_i s_i$&lt;/span&gt;, but I violated this convention in order to more closely match your question.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-09-22T19:04:12.013" LastActivityDate="2022-09-22T19:04:12.013" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9044" PostTypeId="1" CreationDate="2022-09-23T08:50:26.270" Score="3" ViewCount="329" Body="&lt;p&gt;I want to figure out what problem I'm dealing with so I can move in the right direction of research. I'm still at the very beginning of formulating the problem. What I've done so far is figure out just enough to understand how little I know about optimization problems. So for me it is also about the bascis.&lt;/p&gt;&#xA;&lt;p&gt;The problem is probably a combination of several.&lt;/p&gt;&#xA;&lt;p&gt;The minimization goal: I want to minimize the total time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, or the costs, for the process.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Details:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There is one vehicle.&lt;/li&gt;&#xA;&lt;li&gt;The vehicle has limited capacity.&lt;/li&gt;&#xA;&lt;li&gt;The vehicle moves from point / node to another to complete a task. So I think that nodes are equivalent to tasks in this problem?&lt;/li&gt;&#xA;&lt;li&gt;There is a distance between nodes. This is part of the costs, since this means travel time.&lt;/li&gt;&#xA;&lt;li&gt;A task &lt;span class=&quot;math-container&quot;&gt;$T_n$&lt;/span&gt; takes a certain amount of time &lt;span class=&quot;math-container&quot;&gt;$t_T$&lt;/span&gt;, e.g. &lt;span class=&quot;math-container&quot;&gt;$t_{T_n}=3\text{minutes}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Material is consumed per task.&lt;/li&gt;&#xA;&lt;li&gt;The vehicle starts fully loaded and can recharge the material at any station.&lt;/li&gt;&#xA;&lt;li&gt;There are at least two stations.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Why I am not making progress in my research:&lt;/strong&gt; The complexity comes from the fact that a task has to happen twice in one place. Let's call them two types of tasks, &amp;quot;prepare&amp;quot; and &amp;quot;finish&amp;quot;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Two task types. Both have to be done per location.&lt;/li&gt;&#xA;&lt;li&gt;There must be a certain amount of time between &amp;quot;prepare&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$T_{pn}$&lt;/span&gt; and &amp;quot;finish&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$T_{fn}$&lt;/span&gt;, e.g. 10 minutes.&lt;/li&gt;&#xA;&lt;li&gt;However, only a certain amount of time may elapse, not more, e.g. &lt;span class=&quot;math-container&quot;&gt;$t_{max} = 30\text{minutes}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I had the feeling that this is about time windows, but what I find difficult is the fact that the task must be done twice in the same place or same node, but then with the different time windows. That means there are dependencies and they specify the starting points. So the start of &lt;span class=&quot;math-container&quot;&gt;$T_{f1}$&lt;/span&gt; will be determined by &lt;span class=&quot;math-container&quot;&gt;$T_{p1}$&lt;/span&gt;. At the same time I do not really care when a time window starts to begin with &lt;span class=&quot;math-container&quot;&gt;$T_{p1}$&lt;/span&gt;, work just has to be done. It is OK, when &lt;span class=&quot;math-container&quot;&gt;$T_{p5}$&lt;/span&gt; is done before &lt;span class=&quot;math-container&quot;&gt;$T_{p1}$&lt;/span&gt;, this is flexible. And also, when &lt;span class=&quot;math-container&quot;&gt;$T_{p1..7}$&lt;/span&gt; have been done, &lt;span class=&quot;math-container&quot;&gt;$T_{f1..7}$&lt;/span&gt; can be done afterwards sequentially but do not have to. Tasks just need to be fulfilled within the time frame that is made up by &lt;span class=&quot;math-container&quot;&gt;$T_{pn}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So I think the only hard dependency is the point of time &lt;span class=&quot;math-container&quot;&gt;$tp$&lt;/span&gt; after &lt;span class=&quot;math-container&quot;&gt;$T_{pn}$&lt;/span&gt; has been done:&lt;/p&gt;&#xA;&lt;p&gt;So, &lt;span class=&quot;math-container&quot;&gt;$T_{fn}^{tp}$&lt;/span&gt; lies within &lt;span class=&quot;math-container&quot;&gt;$[ ( T_{pn}^{tp} + 10\text{minutes} ) , ( T_{pn}^{tp} + 30\text{minutes} ) ]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;ps. Sorry, but I am not very sure about how to express all of this in the correct mathematical way w.r.t. optimization problems, this is something I would like to catch on in the near future, as soon as I know in which direction I should head now.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;So by what I know so far this is some kind of vehicle routing problem VRP with time windows TW. But TW is not very strict, so is this more about scheduling?&lt;/p&gt;&#xA;&lt;p&gt;And when I would start to implement a solution, what tools could I use for that?&lt;/p&gt;&#xA;" OwnerUserId="10406" LastEditorUserId="10406" LastEditDate="2022-09-23T13:08:55.953" LastActivityDate="2022-09-23T15:37:55.790" Title="Determining the problem type - Vehicle Routing - Task assignment" Tags="|scheduling|vehicle-routing|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9045" PostTypeId="2" ParentId="9041" CreationDate="2022-09-23T10:05:11.750" Score="10" Body="&lt;p&gt;The simple answer is no.&lt;/p&gt;&#xA;&lt;p&gt;While I haven't used LocalSolver myself, I sell a solver that solves similar types of problems (Octeract Engine) so I get asked this type of question a lot for my own solver.&lt;/p&gt;&#xA;&lt;p&gt;Commercial optimisation solvers are, on average, &lt;strong&gt;orders (note the plural) of magnitude more performant&lt;/strong&gt; than open-source alternatives. This is simple to verify, e.g. Octeract &amp;amp; Gurobi vs Couenne or even vs SCIP on &lt;a href=&quot;http://plato.asu.edu/ftp/qplib.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Binary Quadratic problems&lt;/a&gt;, or on &lt;a href=&quot;http://plato.asu.edu/ftp/cnconv.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Non-convex continuous quadratic problems&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This seems to baffle people a lot, especially people with non-optimisation backgrounds, but it is true nevertheless. People have different takes as to why, but at the end of the day, optimisation software has a single job to do - find a good solution fast. This one thing is literally all people care about. If the free alternatives were even remotely comparable to commercial code in this one thing, none of us commercial solver folk would be able to sell a single solver copy. Since we do, as evidenced by the fact that we can all afford to develop solvers full-time, the original statement has to be true.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2023-12-05T09:54:17.150" LastActivityDate="2023-12-05T09:54:17.150" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9046" PostTypeId="2" ParentId="9044" CreationDate="2022-09-23T10:23:26.353" Score="4" Body="&lt;p&gt;I think that the keyword you are looking for is &amp;quot;temporal constraints&amp;quot;. Here are a few articles related to this topic:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;quot;Combined vehicle routing and scheduling with temporal precedence and synchronization constraints&amp;quot; (Bredström et Rönnqvist, 2008) &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2007.07.033&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;The vehicle routing problem with time windows and temporal dependencies&amp;quot; (Dohn et al., 2011) &lt;a href=&quot;https://doi.org/10.1002/net.20472&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;A constraint-programming based decomposition method for the Generalised Workforce Scheduling and Routing Problem (GWSRP)&amp;quot; (Bourreau et al., 2020) &lt;a href=&quot;https://doi.org/10.1080/00207543.2020.1856436&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2022-09-23T10:23:26.353" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9047" PostTypeId="2" ParentId="9044" CreationDate="2022-09-23T15:30:02.100" Score="2" Body="&lt;p&gt;If you want to view the problem as a VRP, it might help to clone all the nodes. Rather than having a single node &lt;span class=&quot;math-container&quot;&gt;$N_j$&lt;/span&gt; for task &lt;span class=&quot;math-container&quot;&gt;$j,$&lt;/span&gt; you have node &lt;span class=&quot;math-container&quot;&gt;$N_j^p$&lt;/span&gt; for the preparation portion of the task and node &lt;span class=&quot;math-container&quot;&gt;$N_j^f$&lt;/span&gt; for the finishing portion of the task. You will also end up cloning arcs, so that arc &lt;span class=&quot;math-container&quot;&gt;$(N_i, N_j)$&lt;/span&gt; becomes &lt;span class=&quot;math-container&quot;&gt;$(N_i^h,N_j^k)$&lt;/span&gt; for all combinations of &lt;span class=&quot;math-container&quot;&gt;$h,k\in \lbrace p,f\rbrace.$&lt;/span&gt; (You may also want to include arcs &lt;span class=&quot;math-container&quot;&gt;$N_j^p \rightarrow N_j^f$&lt;/span&gt; with distance/travel time 0 to allow the vehicle to stick around after a prep task until the time window for the finish task opens.) Preventing a visit to the finish copy of a node before the visit to the prep copy is handled by the time window constraints.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-09-23T15:30:02.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9048" PostTypeId="2" ParentId="9044" CreationDate="2022-09-23T15:37:55.790" Score="2" Body="&lt;p&gt;You have a vehicle routing problem (VRP) here. Because you only have one vehicle, the problem can be reduced to a traveling salesman problem (TSP). Every Vehicle routing is an assignment problem. Basically, VRP is about the combination of assignments and knapsack. You assign a vehicle for each node and a knapsack for the commodity carried for each vehicle. From your description, besides Time Windows there are two keywords that you might perhaps want do some little digging into, which are dependent VRP and Multi-Trip VRP.&lt;/p&gt;&#xA;&lt;p&gt;For the tools, you might want to consider approximate technique (meta or heuristics) because VRP is NP-hard.&lt;/p&gt;&#xA;" OwnerUserId="10000" LastActivityDate="2022-09-23T15:37:55.790" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9049" PostTypeId="1" CreationDate="2022-09-23T15:38:13.220" Score="3" ViewCount="142" Body="&lt;p&gt;What happens when a (sparse) &lt;code&gt;csr&lt;/code&gt; matrix / array is submitted to Gurobi (via Cvxpy framework in python).&lt;/p&gt;&#xA;&lt;p&gt;Does it exploit the sparsity Information about the matrix or does everything gets converted to standard matrix / array?&lt;/p&gt;&#xA;&lt;p&gt;Secondly, is there any drawback (especially in exploiting sparsity information), when calling Gurobi through Python vs calling through Matlab?&lt;/p&gt;&#xA;" OwnerUserId="6106" LastActivityDate="2022-09-23T15:38:13.220" Title="Does Gurobipy exploits sparsity of the optimization problem?" Tags="|optimization|gurobi|cvxpy|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9050" PostTypeId="2" ParentId="9041" CreationDate="2022-09-23T21:32:50.740" Score="3" Body="&lt;p&gt;You might want to try &lt;a href=&quot;https://www.gecode.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gecode&lt;/a&gt;, although I have no idea whether it will do any better than OR-Tools. If you are not a C++ programmer, you can use &lt;a href=&quot;https://www.minizinc.org/software.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;MiniZinc&lt;/a&gt; to build the model and interface with Gecode. Both are open-source.&lt;/p&gt;&#xA;&lt;p&gt;If you are inclined to move away from constraint programming models, you could (as suggested in a comment) try a linear (integer?) program with an open-source LP/MIP solver. It may also be amenable to various metaheuristics, whether based on neighborhood search or other.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-09-23T21:32:50.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9051" PostTypeId="1" CreationDate="2022-09-24T03:43:46.743" Score="2" ViewCount="89" Body="&lt;p&gt;Consider a convex optimization problem with decision variable x. Though I'm interested in answers for any kind of convex optimization problem, let's say it's an LP, so we have something like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation*}&#xA;\begin{array}{ll@{}ll}&#xA;     \text{min} &amp;amp; \displaystyle c^\text{T}x \\&#xA;     \text{s.t.} &amp;amp; \displaystyle Ax\geq b \\&#xA;     &amp;amp; x \geq 0&#xA;\end{array}    &#xA;\end{equation*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now let's say I have a second linear program where the constraint variables are defined by the decision variables of the first, i.e. the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in what follows is the argmin of the preceding problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation*}&#xA;\begin{array}{ll@{}ll}&#xA;     \text{min} &amp;amp; \displaystyle d^\text{T}y \\&#xA;     \text{s.t.} &amp;amp; \displaystyle By\geq x \\&#xA;\end{array}    &#xA;\end{equation*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You could continue this chain of dependencies ad nauseam. This looks like it could be a common situation, where the decisions you make for one problem influence the feasible solutions of another, but I'm having a hard time finding examples in the literature. Possible examples that spring to mind include inventory management where you buy x units of something, and then use those x units to achieve some other goal &lt;span class=&quot;math-container&quot;&gt;$d^\text{T}y$&lt;/span&gt;, or optimal control where &lt;span class=&quot;math-container&quot;&gt;$c^Tx$&lt;/span&gt; is a decision made at timestep &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d^Ty$&lt;/span&gt; is a decision made a timestep &lt;span class=&quot;math-container&quot;&gt;$t+1$&lt;/span&gt;. But again I can't find any problems in this specific form.&lt;/p&gt;&#xA;&lt;p&gt;Can anyone point me to some previously studied (class of) optimization problem where this setup arises?&lt;/p&gt;&#xA;" OwnerUserId="10416" LastEditorUserId="500" LastEditDate="2022-09-24T03:46:29.613" LastActivityDate="2022-09-24T16:28:37.587" Title="Decision Variables becoming Constraints" Tags="|reference-request|convex-optimization|bilevel-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9052" PostTypeId="2" ParentId="9051" CreationDate="2022-09-24T16:28:37.587" Score="2" Body="&lt;p&gt;This structure can arise in &lt;a href=&quot;https://en.wikipedia.org/wiki/Multi-objective_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;multi-objective optimization&lt;/a&gt; problems. While it is common for multi-objective problems to express each objective function directly in terms of the same variables, there can be instances where the objectives are computed via secondary / chained problems.&lt;/p&gt;&#xA;&lt;p&gt;It also arises in &lt;a href=&quot;https://en.wikipedia.org/wiki/Stochastic_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;stochastic programming with recourse&lt;/a&gt;, where the first stage model makes decisions in the face of uncertainty and the second stage model figures out how to handle the consequences of the first stage decisions. For instance, the first stage model might make production decisions in the face of uncertainty about demand, and the second stage problem might figure out the best way to deal with any shortfalls or overproduction.&lt;/p&gt;&#xA;&lt;p&gt;Although I suspect this will not be helpful in your case, the structure you mention is similar (when things are linear) but not identical to &lt;a href=&quot;https://en.wikipedia.org/wiki/Benders_decomposition&quot; rel=&quot;nofollow noreferrer&quot;&gt;Benders decomposition&lt;/a&gt; and the recent extensions of Benders. The fundamental difference is that with Benders decomposition the solution to the second problem is used to modify the first model (adding constraints), after which the first problem is solved again.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-09-24T16:28:37.587" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9053" PostTypeId="1" CreationDate="2022-09-25T08:31:01.453" Score="4" ViewCount="186" Body="&lt;p&gt;I have a problem where there are stations, types and tasks which has to be assigned to each other. Now for me the thing is I want the variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to be not binary like in assignment problem for example but between &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt;. Now I wanted to add a constraint which says something like that: the tasks are fractional (able to split) yes but there should not be too tiny splits because it is just not good for the implication in the real production process. Therefore I thought of a parameter for example &lt;span class=&quot;math-container&quot;&gt;$Z^\min$&lt;/span&gt; which I give a value of e.g. &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt;. I need to say that the duration of every &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;-tuple (station, type, task) is larger than at least &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt;. So that even there is a split an &lt;span class=&quot;math-container&quot;&gt;$x(1,1,1) = 0.5$&lt;/span&gt; so only half of the original task is assigned, there is never an assignment of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; which makes the duration smaller than 10. Therefore I have an approach and think it is makes sense but wanted to take other opinions on that. Here the one constraint I talked about and following the  complete model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    &amp;amp; \sum_{j=1}^{J} d_{ijk}\cdot x_{ijk} \geq Z^{\min} \cdot x_{ijk}  &amp;amp;&amp;amp;\text{$\forall \, i \in I$, $\forall \, k \in K$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;    &amp;amp;\text{min} &amp;amp;&amp;amp;\sum_{i=1}^{I}\sum_{j=1}^{J}\sum_{k=1}^{K} c_{ijk}\cdot x_{ijk} &amp;amp;&amp;amp;+\sum_{i=1}^{I}\sum_{j=1}^{J} f_{ij} \cdot \gamma_{ij} \\&#xA;    &amp;amp;\text{s.t.} &amp;amp;&amp;amp;\sum_{i=1}^{I}\sum_{j=1}^{J} x_{ijk} &amp;amp;&amp;amp;= 1 &amp;amp;\text{$\forall \, k \in K$} \\&#xA;    &amp;amp;&amp;amp;&amp;amp;\sum_{j=1}^{J} \gamma_{ij} &amp;amp;&amp;amp;= 1 &amp;amp;\text{$\forall \, i \in I$} \\&#xA;    &amp;amp;&amp;amp;&amp;amp;\sum_{j=1}^{J}\sum_{k=1}^{K} d_{ijk}\cdot x_{ijk} &amp;amp;&amp;amp;\leq C ^ {\max} \cdot \gamma_{ij}  &amp;amp;\text{$\forall \, i \in I$} \\&#xA;    &amp;amp;&amp;amp;&amp;amp; \sum_{j=1}^{J} d_{ijk}\cdot x_{ijk} &amp;amp;&amp;amp;\geq Z^{\min} \cdot x_{ijk}  &amp;amp;\text{$\forall \, i \in I$, $\forall \, k \in K$} \\&#xA;    &amp;amp;&amp;amp;&amp;amp;\sum_{i=1}^{I} i \cdot x_{ik} &amp;amp;&amp;amp; \leq \sum_{i=1}^{I} i \cdot x_{im} &amp;amp;\text{$\forall \, j \in J$} \\&#xA;    &amp;amp;&amp;amp;&amp;amp; x_{ijk} \in [0,1], &amp;amp;&amp;amp; \gamma_{ij} \in \{0,1\}&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9764" LastEditorUserId="491" LastEditDate="2022-09-25T18:08:35.927" LastActivityDate="2022-09-25T18:08:35.927" Title="Do my constraints to restrict the splitting of tasks make sense?" Tags="|mixed-integer-programming|modeling|constraint|assignment-problem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9054" PostTypeId="2" ParentId="9053" CreationDate="2022-09-25T14:05:23.317" Score="3" Body="&lt;p&gt;Your proposed constraint is indexed over &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, but the expression on the RHS depends also on &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.  It sounds like you want the LHS to be either &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or at least &lt;span class=&quot;math-container&quot;&gt;$Z^\min$&lt;/span&gt;, which you can enforce by introducing a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{ik}$&lt;/span&gt;, changing the RHS to &lt;span class=&quot;math-container&quot;&gt;$Z^\min y_{ik}$&lt;/span&gt;, and imposing an additional constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_j d_{ijk} x_{ijk}\le M_{ik} y_{ik}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$M_{ik}$&lt;/span&gt; is a (small) upper bound on the LHS when &lt;span class=&quot;math-container&quot;&gt;$y_{ik}=1$&lt;/span&gt;.  Essentially, you want to enforce that &lt;span class=&quot;math-container&quot;&gt;$\sum_j d_{ijk} x_{ijk}$&lt;/span&gt; is &lt;em&gt;semicontinuous&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Your third and fifth  constraints have similar parsing errors.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-09-25T15:00:59.863" LastActivityDate="2022-09-25T15:00:59.863" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9055" PostTypeId="1" CreationDate="2022-09-25T16:10:23.760" Score="4" ViewCount="167" Body="&lt;p&gt;I'm trying to solve a &amp;quot;simple&amp;quot; (= small) optimization problem often, with only minor changes to the objective function. Therefore it's important to keep the &amp;quot;time per solve&amp;quot; as low as possible. This problem is basically a QP with &lt;span class=&quot;math-container&quot;&gt;$Q := \operatorname{diag}(\alpha, \dots, \alpha)$&lt;/span&gt; positive definite, and linear constraints, so of the following form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\min&amp;amp;\quad c'x + \alpha\cdot x'x \\&#xA;\text{s.t.}&amp;amp;\quad Ax \geq 0 \\&amp;amp;\quad x \geq 0&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with decision variable &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^n$&lt;/span&gt;, as well as fixed &lt;span class=&quot;math-container&quot;&gt;$c \in \mathbb{R}^n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{m\times n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha \in \mathbb{R}_+$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is there any way to pre-calculate a &amp;quot;somewhat&amp;quot; analytical solution that is (as) fast (as possible) to re-solve with changing values for &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Remarks: &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; are fairly small, and memory as well as pre-calculation time are (mostly) not relevant.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;To clarify what I mean with &amp;quot;somewhat&amp;quot;: If the term &lt;span class=&quot;math-container&quot;&gt;$\alpha\cdot x'x$&lt;/span&gt; did not exist, one possible way would be to precompute the polytope defined by &lt;span class=&quot;math-container&quot;&gt;$Ax \geq 0$&lt;/span&gt; and extract its vertices (&lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;). The optimal solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; must lie on one of those. Therefore we can calculate &lt;span class=&quot;math-container&quot;&gt;$c'y_i$&lt;/span&gt; and select &lt;span class=&quot;math-container&quot;&gt;$x^* := y_j$&lt;/span&gt; for one &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; that satisfies &lt;span class=&quot;math-container&quot;&gt;$y_j \leq y_i \forall i$&lt;/span&gt;. This essentially boils down to one matrix-vector multiplication and one argmax, which is really fast.&lt;/p&gt;&#xA;&lt;p&gt;Initial thought: since the set of feasible solutions is bounded, and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is positive definite, a minimum exists and can be found by looking at the KKT points (that will also be a global minimum since the objective function is convex). Finding those KKT points can be done by solving a bunch of equations (but with variable &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;, which will prevent really pre-calculating everything...).&lt;/p&gt;&#xA;" OwnerUserId="10411" LastEditorUserId="8" LastEditDate="2022-09-25T19:37:51.120" LastActivityDate="2022-09-25T19:37:51.120" Title="Analytical solution of constrained quadratic program" Tags="|optimization|convex-optimization|quadratic-programming|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9056" PostTypeId="2" ParentId="9041" CreationDate="2022-09-25T22:03:47.473" Score="8" Body="&lt;p&gt;To our knowledge, there is no equivalent of &lt;a href=&quot;https://www.hexaly.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hexaly (formerly LocalSolver)&lt;/a&gt; in open source and no equivalent of Hexaly in the market. Hexaly's uniqueness, and thus innovation, comes from the two key points:&lt;/p&gt;&#xA;&lt;p&gt;1 - The Hexaly modeling API offers nonlinear operators (prod, min, max, log, exp, pow, cos, sin, tan, if-then-else, etc.) and set-oriented operators.&lt;/p&gt;&#xA;&lt;p&gt;The &amp;quot;set&amp;quot; and &amp;quot;list&amp;quot; decisions are unique to Hexaly API. They are critical to getting compact and structured models for problems like routing, scheduling, packing, clustering, matching, assignment, and location problems, contrary to traditional solvers.&lt;/p&gt;&#xA;&lt;p&gt;It also supports black-box optimization by offering the ability to implement your own mathematical operators; if these operators are time-consuming to evaluate, Hexaly uses automatic surrogate modeling approaches to speed up the resolution.&lt;/p&gt;&#xA;&lt;p&gt;2 - Hexaly has changed a lot in 10 years. It is not a &amp;quot;local search&amp;quot; solver anymore. Today, Hexaly relies on combining many optimization methods under the hood. We cannot say more that Hexaly combines exact and heuristic algorithmic approaches. Here, &amp;quot;heuristic&amp;quot; refers to Local Search, but not only. These heuristics are unique; you will not find them in MILP or CP solvers.&lt;/p&gt;&#xA;&lt;p&gt;Once coupled with the above-described modeling API, these methods deliver fast and scalable solutions to many problems beyond traditional solvers' scope, particularly routing and scheduling problems.&lt;/p&gt;&#xA;&lt;p&gt;Hexaly looks like MILP, MINLP, or even CP, but it is not. It is in between, which is a kind of hybrid. As its name does not reflect, Hexaly is a global optimization solver with a special, unique modeling API.&lt;/p&gt;&#xA;&lt;p&gt;Your sentence, &amp;quot;I would really prefer to use something open source for reproducibility&amp;quot; is unclear. Open-source solvers are no more reproducible than commercial ones. It depends on what &amp;quot;reproducible&amp;quot; means in your statement. Could you elaborate on this?&lt;/p&gt;&#xA;&lt;p&gt;If you wish to use Hexaly for teaching or basic research, then it is free. If you are a business, we offer competitive pricing, particularly for startups and SMEs. It seems you use a pseudo here (you don't appear under this name as a user in our records), so I assume you will not explain what you really want.&lt;/p&gt;&#xA;&lt;p&gt;Disclaimer: Hexaly is commercial software. It is free for students and faculties.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T02:50:27.180" LastActivityDate="2024-04-04T02:50:27.180" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9057" PostTypeId="1" CreationDate="2022-09-26T09:35:14.767" Score="6" ViewCount="351" Body="&lt;p&gt;I was following Wolsey Example 9.3: Let &lt;span class=&quot;math-container&quot;&gt;$X = \{(x,y) \in (R^{m}_+,B^1) : \sum_{i=1}^m x_i \leq my\}$&lt;/span&gt;. Now consider the valid inequality &lt;span class=&quot;math-container&quot;&gt;$x_i \leq y$&lt;/span&gt; and show that it is facet defining.&lt;/p&gt;&#xA;&lt;p&gt;My question is why is this  a valid inequality? For example one point in &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; may be &lt;span class=&quot;math-container&quot;&gt;$(x,y) = ((0,3,0),(1))$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$0+3+0 \leq 3\times1$&lt;/span&gt;, but their valid inequality removes this solution, &lt;span class=&quot;math-container&quot;&gt;$3 \leq 1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10427" LastEditorUserId="500" LastEditDate="2022-09-26T14:22:52.283" LastActivityDate="2022-09-26T15:46:32.740" Title="Valid Inequality Example (Wolsey Example 9.3)" Tags="|combinatorial-optimization|branch-and-cut|valid-inequalities|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9058" PostTypeId="2" ParentId="9057" CreationDate="2022-09-26T14:27:24.023" Score="12" Body="&lt;p&gt;As @Kuifje suggested, an upper bound &lt;span class=&quot;math-container&quot;&gt;$x_i \le 1$&lt;/span&gt; was mistakenly omitted.  This omission was noted in &lt;a href=&quot;https://web.archive.org/web/20110127032208/www.core.ucl.ac.be/wolsey/correcti.htm&quot; rel=&quot;noreferrer&quot;&gt;this errata sheet&lt;/a&gt;, and it was corrected in the second edition of the book.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-09-26T15:46:32.740" LastActivityDate="2022-09-26T15:46:32.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9059" PostTypeId="1" AcceptedAnswerId="9060" CreationDate="2022-09-26T15:52:16.380" Score="7" ViewCount="431" Body="&lt;p&gt;I am now somewhat comfortable with delayed column generation, but one specific example has been bugging me, as it's quite simple (on the second iteration we stop) and I can't reach the optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;The instance has the following settings:&lt;/p&gt;&#xA;&lt;p&gt;item_width = [13,16]&#xA;demand = [3,3]&#xA;roll_width = 46&lt;/p&gt;&#xA;&lt;p&gt;The optimal solution is (1,2) + (2,1). But let's take it step by step. I start with an initial set of patterns, P = [(3,0),(0,2)] and compute the restricted master problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{minimize} \quad x_{0} + x_{1}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{s.t.}\quad 3\times x_{0} \geq 3$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \quad 2\times x_{1} \geq 3$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Which gives us the dual values of &lt;span class=&quot;math-container&quot;&gt;$\pi_{0} = \frac{1}{3}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\pi_{1} = \frac{1}{2}$&lt;/span&gt;. The pricing problem is then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{maximize} \quad \frac{1}{3}\times y_{0} + \frac{1}{2}\times y_{1}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{s.t.} \quad 13\times y_{0} + 16 \times y_{1} \leq 46$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where we get the new pattern (1,2). For the second and final iteration, the RMP becomes&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{minimize} \quad x_{0} + x_{1} + x_{2}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{s.t.} \quad 3\times x_{0} + x_{2} \geq 3$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$2\times x_{1} + 2\times x_{2} \geq 3$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With the dual values &lt;span class=&quot;math-container&quot;&gt;$\pi_{0} = \frac{1}{3}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\pi_{1} = \frac{1}{3}$&lt;/span&gt;. If we update the pricing problem, multiple patterns yield the optimal solution: (1,2), (2,1), (3,0). If I pick the pattern that I know should be in the optimal solution, then sure, I can reach the optimal solution, but I don't understand how that can have the same reduced cost as a pattern that I have already considered. I know that there is something I am doing wrong, but I can't see what.&lt;/p&gt;&#xA;&lt;p&gt;If the pattern (2,1) is part of the original set of Patterns in the first iteration, then I can solve the problem without issues, but that shouldn't be necessary, right?&lt;/p&gt;&#xA;" OwnerUserId="5352" LastEditorUserId="491" LastEditDate="2023-01-19T12:51:49.947" LastActivityDate="2023-01-19T12:51:49.947" Title="Can't solve a specific instance of Gilmore &amp; Gomory Cutting Stock with Delayed Column Generation" Tags="|combinatorial-optimization|algorithms|column-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9060" PostTypeId="2" ParentId="9059" CreationDate="2022-09-26T16:11:17.497" Score="7" Body="&lt;p&gt;What you have done is correct, but the final pricing problem has optimal objective value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, which corresponds to reduced cost &lt;span class=&quot;math-container&quot;&gt;$1-1=0$&lt;/span&gt;, so you do not generate a new pattern, and you have solved the master LP, which has optimal objective value &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;.  The resulting restricted master ILP has optimal objective value &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;. This is a case where the &amp;quot;price-and-branch&amp;quot; heuristic does not yield an optimal integer solution.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-09-26T16:11:17.497" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9061" PostTypeId="1" CreationDate="2022-09-26T17:15:29.657" Score="1" ViewCount="42" Body="&lt;p&gt;I have a code that uses pyomo and gurobi but when i try to run it, it doesn't give me the optimal solutions, just says that they exist. What can i do?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Xt77x.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Xt77x.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10429" LastActivityDate="2022-09-26T17:15:29.657" Title="Finding the solutions using pyomo and gurobi" Tags="|gurobi|pyomo|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9062" PostTypeId="1" AcceptedAnswerId="9063" CreationDate="2022-09-26T18:31:11.953" Score="3" ViewCount="456" Body="&lt;p&gt;I have a function as follows (updated after the clarification question):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x∈X}\left(\sum\sum c_{ij}x_{ij}-\max_{y∈Y}\sum\sum d_{ij}x_{ij}y_{ij}\right)$$&lt;/span&gt; where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij},y_{ij}$&lt;/span&gt; are decision variables.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{ij}, d_{ij}$&lt;/span&gt; are cost coefficients.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;My question is, is it possible to disregard the minus in between and write it as follows?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x∈X,y∈Y}\left(\sum\sum c_{ij}x_{ij}+\sum\sum d_{ij}x_{ij}y_{ij}\right)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If it was a plus sign in the first place instead of minus, I know that we could have written as such. But for this case, I would like to clarify it.&lt;/p&gt;&#xA;" OwnerDisplayName="user5245" LastEditorDisplayName="user5245" LastEditDate="2023-03-31T05:27:32.277" LastActivityDate="2023-03-31T05:27:32.277" Title="About Function Manipulation" Tags="|optimization|nonlinear-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9063" PostTypeId="2" ParentId="9062" CreationDate="2022-09-26T21:12:13.943" Score="3" Body="&lt;p&gt;No, you cannot change the objective to maximizing a sum, not even if &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; in the second version is different from &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; in the first version. In the first version, for given &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; you are choosing the &lt;span class=&quot;math-container&quot;&gt;$y\in Y$&lt;/span&gt; that is &lt;em&gt;worst&lt;/em&gt; for the overall objective value. In the second version, for given &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; you are choosing the &lt;span class=&quot;math-container&quot;&gt;$y\in Y$&lt;/span&gt; that is &lt;em&gt;best&lt;/em&gt; for the overall objective value.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: Given the information that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is integer and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is continuous, and assuming that &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and the convex hull of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; are polyhedral, the problem is solvable using a variant of Benders decomposition.&lt;/p&gt;&#xA;&lt;p&gt;The master problem is &lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\max &amp;amp; \sum_{i,j}c_{ij}x_{ij}-z\\&#xA;\textrm{s.t. }x &amp;amp; \in X\\&#xA; &amp;amp; \cdots&#xA;\end{align*}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is a surrogate for the inner maximization value and &lt;span class=&quot;math-container&quot;&gt;$\cdots$&lt;/span&gt; is a placeholder for linear constraints to come. Given a candidate solution &lt;span class=&quot;math-container&quot;&gt;$(\bar{x},\bar{z})$&lt;/span&gt; to the master problem, you solve the LP subproblem &lt;span class=&quot;math-container&quot;&gt;$$\max_{y\in Y} \sum_{i,j} (d_{ij}\bar{x}_{ij})y_{ij}$$&lt;/span&gt;&#xA;obtaining solution &lt;span class=&quot;math-container&quot;&gt;$\bar{y}$&lt;/span&gt; with objective value &lt;span class=&quot;math-container&quot;&gt;$v.$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$\bar{z}\ge v,$&lt;/span&gt; accept &lt;span class=&quot;math-container&quot;&gt;$(\bar{x},\bar{z})$&lt;/span&gt; as a new incumbent in the master. If not, add to the master the constraint &lt;span class=&quot;math-container&quot;&gt;$$z\ge \sum_{i,j}(d_{ij}\bar{y}_{ij})x_{ij},$$&lt;/span&gt; which is linear in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and valid for all &lt;span class=&quot;math-container&quot;&gt;$x\in X.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-10-04T15:56:38.633" LastActivityDate="2022-10-04T15:56:38.633" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9064" PostTypeId="1" CreationDate="2022-09-27T05:29:43.603" Score="1" ViewCount="314" Body="&lt;p&gt;I am new to cplex with python. I want to solve a problem using the Benders decomposition approach. Where I want to use  UserCutCallback and LazyConstraintCallback. I am writing code in script format (which means I am not defining class, object, etc.). Would I be able to code my problem in that format while using  UserCutCallback and LazyConstraintCallback? If yes, how can I use  UserCutCallback and LazyConstraintCallback? My problem is as follows:&lt;/p&gt;&#xA;&lt;h1&gt;Defining Model&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;my_bdrex_OP=Model('My Original Model',log_output=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Defining Variables&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;x_1=my_bdrex_OP.integer_var(name='x_1', lb=0)&#xA;x_2=my_bdrex_OP.integer_var(name='x_2', lb=0)&#xA;y_1=my_bdrex_OP.continuous_var(name='y_1', lb=0)&#xA;y_2=my_bdrex_OP.continuous_var(name='y_2', lb=0)&#xA;y_3=my_bdrex_OP.continuous_var(name='y_3', lb=0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Adding constraints&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;my_bdrex_OP.add_constraint(2*x_1+4*x_2+4*y_1-2*y_2+3*y_3&amp;lt;=12)&#xA;my_bdrex_OP.add_constraint(3*x_1+5*x_2+2*y_1+3*y_2-y_3&amp;lt;=10)&#xA;my_bdrex_OP.add_constraint(x_1&amp;lt;=2)&#xA;my_bdrex_OP.add_constraint(x_2&amp;lt;=2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Defining Objective function&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;objective_OP=4*x_1+7*x_2+2*y_1-3*y_2+y_3&#xA;my_bdrex_OP.maximize(objective_OP)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Solving&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;my_bdrex_OP.print_information()&#xA;print(my_bdrex_OP.export_as_lp_string())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am solving the above problem by using the Benders strategy:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;my_bdrex_OP.parameters.benders.strategy = 3&#xA;my_bdrex_OP.solve()&#xA;my_bdrex_OP.print_solution()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And I successfully got the solution.&lt;/p&gt;&#xA;&lt;p&gt;But I want to solve it by using the UserCutCallback and LazyConstraintCallback method. I request to the community please help to understand the use of UserCutCallback and LazyConstraintCallback to solve the problem in the Benders decomposition technique.&lt;/p&gt;&#xA;" OwnerUserId="10434" LastActivityDate="2024-02-03T16:47:00.087" Title="Apply Benders decomposition approach in CPLEX with python while using docplex class" Tags="|python|cplex|benders-decomposition|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9066" PostTypeId="1" CreationDate="2022-09-27T16:54:19.973" Score="2" ViewCount="105" Body="&lt;p&gt;I feel like I must be missing something obvious but this is confusing me.  Let's say I have an optimal solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; to a minimum-weight perfect bipartite matching problem on &lt;span class=&quot;math-container&quot;&gt;$2n$&lt;/span&gt; nodes, &lt;span class=&quot;math-container&quot;&gt;$$\min\sum_i\sum_j c_{ij}x_{ij}$$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\sum_i x_{ij} = \sum_j x_{ij} = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{ij}\in \{0,1\}$&lt;/span&gt;.   I'd like to recover the &lt;span class=&quot;math-container&quot;&gt;$2n$&lt;/span&gt; optimal dual variables &lt;span class=&quot;math-container&quot;&gt;$y^*$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt;.  I would think that complementary slackness handles this for me, but I am confused because I only have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; non-zero entries in &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; (for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, its partner &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;), but I need to solve for &lt;span class=&quot;math-container&quot;&gt;$2n$&lt;/span&gt; variables in the dual.  Is there a well-known way to uniquely solve for them?&lt;/p&gt;&#xA;" OwnerUserId="10284" LastActivityDate="2022-09-28T21:30:02.810" Title="How do you recover dual variables for a minimum weight bipartite perfect matching problem?" Tags="|linear-programming|duality|matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9067" PostTypeId="2" ParentId="9066" CreationDate="2022-09-27T19:12:46.280" Score="2" Body="&lt;p&gt;If we assume that &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; corresponds to the constraints &lt;span class=&quot;math-container&quot;&gt;$\sum_i x_{ij}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; corresponds to the other set of constraints, then you have a &lt;span class=&quot;math-container&quot;&gt;$(2n)\times (2n-1)$&lt;/span&gt; system of equations &lt;span class=&quot;math-container&quot;&gt;$$y_j + z_i = c_{ij}$$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; is basic in the primal solution. The system is full rank, so you can solve it for &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;[Edit: I originally described the system as &lt;span class=&quot;math-container&quot;&gt;$(2n)\times (2n),$&lt;/span&gt; but one of the constraints in the problem is redundant and should be dropped. Which constraint you drop is immaterial.&lt;/p&gt;&#xA;&lt;p&gt;Of course, if you are using an LP solver to solve the primal problem, you can with probability approaching 1 just ask the LP solver for the dual solution. :-)&lt;/p&gt;&#xA;&lt;p&gt;Cautionary note: If you declare the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables to have domain &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt; (as opposed to &lt;span class=&quot;math-container&quot;&gt;$[0,\infty)$&lt;/span&gt;), you create extra dual variables for the upper bounds (1). Here and in the comments, I assume &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \ge 0$&lt;/span&gt; with no explicit upper bound.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-09-28T21:30:02.810" LastActivityDate="2022-09-28T21:30:02.810" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9068" PostTypeId="1" AcceptedAnswerId="9070" CreationDate="2022-09-27T23:22:07.610" Score="3" ViewCount="1044" Body="&lt;p&gt;In the past I have used the academic versions of Gurobi and Mosek for solving various optimization problems using various Python and Julia libraries that call the solvers.&lt;/p&gt;&#xA;&lt;p&gt;However, I want to learn how to use freely available good solvers like &lt;a href=&quot;https://www.maths.ed.ac.uk/hall/HiGHS/&quot; rel=&quot;nofollow noreferrer&quot;&gt;HiGHS&lt;/a&gt;. From the documentation I cannot figure out how exactly one interfaces the solver to Python/Julia and the examples are not quite helpful.&lt;/p&gt;&#xA;&lt;p&gt;Is there some tutorial on how to write/implement some simple LP problem using HiGHS?&lt;/p&gt;&#xA;" OwnerUserId="10153" LastActivityDate="2022-09-28T07:48:06.803" Title="Tutorial request on implementing HiGHS solver" Tags="|optimization|linear-programming|solver|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9069" PostTypeId="2" ParentId="9068" CreationDate="2022-09-28T00:21:46.667" Score="6" Body="&lt;p&gt;To write and solve a problem in Julia, implement it using JuMP. I assume you already installed the JuMP and HiGHS package as both install like normal Julia packages.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using JuMP&#xA;using HiGHS&#xA;model = Model(HiGHS.Optimizer)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now define your variables, constraints and the objective on that model. Then a simple &lt;code&gt;optimize!&lt;/code&gt; call should do the rest.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;JuMP.optimize!(model)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You might also want to change HiGHS solver options; for that, see the README in &lt;a href=&quot;https://github.com/jump-dev/HiGHS.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;HiGHS.jl&lt;/a&gt; package.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="804" LastEditDate="2022-09-28T07:48:06.803" LastActivityDate="2022-09-28T07:48:06.803" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9070" PostTypeId="2" ParentId="9068" CreationDate="2022-09-28T06:46:27.103" Score="4" Body="&lt;p&gt;On Python side, there are two alternatives beside scipy implementation.&lt;/p&gt;&#xA;&lt;p&gt;You can use PuLP dev version as explained in question &lt;a href=&quot;https://or.stackexchange.com/questions/9030/how-to-call-highs-solver-from-python-pulp-mip/9033#9033&quot;&gt;How to call HiGHS solver from python PuLP MIP?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;There is also a Python package called highspy on pip but it is currently in pre-release mode so it does not show on google search (unfortunately no conveniently reachable documentation yet). &lt;a href=&quot;https://pypi.org/project/highspy/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pip link here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;On R side, &lt;a href=&quot;https://cran.r-project.org/web/packages/highs/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;there is a highs package.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4496" LastActivityDate="2022-09-28T06:46:27.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9071" PostTypeId="1" CreationDate="2022-09-28T08:56:59.863" Score="7" ViewCount="118" Body="&lt;p&gt;I am looking for &lt;strong&gt;examples&lt;/strong&gt; to understand what kind of &lt;strong&gt;benefits&lt;/strong&gt; a &lt;em&gt;model-and-run framework solver&lt;/em&gt; offers that a more programmatic solver doesn't do or doesn't do as well.&lt;/p&gt;&#xA;&lt;p&gt;What distinguishes a model-and-run framework?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Context: I am trying to understand what &lt;a href=&quot;https://www.optaplanner.org/&quot; rel=&quot;noreferrer&quot;&gt;OptaPlanner&lt;/a&gt; is missing to be used as a model-and-run solver. I presume it's more than just Jupyter notebook integration (which is already &lt;a href=&quot;https://github.com/optapy/optapy-quickstarts#overview-of-all-quickstarts&quot; rel=&quot;noreferrer&quot;&gt;supported for OptaPy&lt;/a&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2022-09-28T08:56:59.863" Title="What distuingishes a model-and-run framework solver from a programmatic solver?" Tags="|modeling|python|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9073" PostTypeId="1" CreationDate="2022-09-28T15:12:43.710" Score="2" ViewCount="99" Body="&lt;p&gt;I have often wondered whether there is an optimal way to spend cash denominations. For example: Suppose that Bob needs to pay Jill \$5, Jane \$10, Billy \$3.50 and John \$45.75. Furthermore suppose that Bob currently has in his position a single $100 dollar bill. Assuming that any one of the payees can give Bob change in any combination of denomination he wants, what is the optimal &amp;quot;path of payment&amp;quot; to take?&lt;/p&gt;&#xA;&lt;p&gt;Granted in the example given above, the solution can be achieved by inspection very quickly but what if we take that example, scale it up massively and introduce some restrictions? Suppose Bob needs to pay thousands of payees, what is the optimal order of payees to pay for Bob and what form of change denominations should he request from the first person he is paying, to maximise the number of people he could pay in the second round? Given that he is only allowed to pay a fixed number of people at a time.&lt;/p&gt;&#xA;&lt;p&gt;In some of the discussions I have had with people, dynamic programming seems to be the best place to start. This could lead to Reinforcement Learning as a possible approach (because this problem probably will be solved heuristically). My thought is that there could possibly be an algorithmic way to approach this which is simpler than the two methods above.&lt;/p&gt;&#xA;&lt;p&gt;However, I am also pretty confident that others have also thought of this problem. My question then is, is this a solved problem?&lt;/p&gt;&#xA;&lt;p&gt;P.S.: I am a grad student in my last semester of IE. I need to make up a couple of credits and instead of taking some kind of TE, my advisor has given allowed me to replace the coursework with an independent study. His words to me were; &amp;quot;Think of a weird nuanced problem in OR that's probably not too difficult to solve, have fun with it and give me a term paper on what you have done&amp;quot;. So I figured it would be a perfect time to attempt the &amp;quot;Cash spending problem&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="10445" LastActivityDate="2022-09-28T15:12:43.710" Title="Optimal spending of cash problem" Tags="|algorithms|dynamic-programming|reinforcement-learning|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9074" PostTypeId="1" AcceptedAnswerId="9075" CreationDate="2022-09-29T22:16:38.303" Score="2" ViewCount="181" Body="&lt;p&gt;It is well known that applying the Dantzig-Wolfe Decomposition in the one period cutting stock problem with trim loss minimization leads to an optimal real solution that shares the round up property, so directly from the decomposition it is possible to obtain an optimal integer solution for the problem, in other words, the columns (cutting patterns) generated are useful to obtain the optimal integer solution.&lt;/p&gt;&#xA;&lt;p&gt;I'm currently working with a multi-period cutting stock problem (in each period a cutting process may occur and therefore a cutting stock problem must be solved) where the periods are connected via item inventory (I have other objectives beside trim loss, like cutting pattern minimization). I've been trying to solve it via column generation. After starting the master problem, I solve knapsack subproblems for each period until no patterns with reduced costs are available, thus obtaining an optimal real solution, however the generated columns do not lead to an optimal integer solution (I modeled the problem as a MIP and use an optimization package to solve it). In fact, I've developed heuristics that generate columns and get better results than the one from the column generation via solver. Does that imply that my column generation implementation is wrong or the round up property of the one dimensional single period can't be extended to multi period scenarios?&lt;/p&gt;&#xA;" OwnerUserId="3139" LastEditorUserId="500" LastEditDate="2022-09-29T23:30:44.393" LastActivityDate="2022-09-30T13:44:47.983" Title="Dantzig-Wolfe decomposition and optimal integer solutions" Tags="|cplex|heuristics|column-generation|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9075" PostTypeId="2" ParentId="9074" CreationDate="2022-09-30T13:44:47.983" Score="5" Body="&lt;p&gt;The property does not hold even for the classical one-period problem. See &lt;a href=&quot;https://arxiv.org/ftp/arxiv/papers/2004/2004.01937.pdf&quot; rel=&quot;noreferrer&quot;&gt;Counterexamples in the Cutting Stock Problem&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-09-30T13:44:47.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9076" PostTypeId="1" CreationDate="2022-09-30T21:09:42.950" Score="3" ViewCount="222" Body="&lt;p&gt;I have a machine mapping problem.&lt;/p&gt;&#xA;&lt;p&gt;There are several machines and several tasks. Tasks are of different types and need different number of machines, such as 2,4 8, etc machines.&lt;/p&gt;&#xA;&lt;p&gt;Due to machines capability, every task can not be performed by all the machines. Once we assign some machines to a task, the machines should be adjacent.&lt;/p&gt;&#xA;&lt;p&gt;For example, the 1st task has a demand of 2 machines. The options are machines {1,2} and {5,6} and {9,10} and {13,14} and {17,18} and {21,22}. Note again that the machines mapped to any task must be contiguous.&lt;/p&gt;&#xA;&lt;p&gt;The tasks and the associated options are given below&lt;/p&gt;&#xA;&lt;p&gt;Task1: {{1,2},{5,6},{9,10},{13,14},{17,18},{21,22}};&lt;/p&gt;&#xA;&lt;p&gt;Task2: {{3,4},{7,8},{11,12},{15,16},{19,20},{23,24}};&lt;/p&gt;&#xA;&lt;p&gt;Task3: {{1,2,3,4},{13,14,15,16}};&lt;/p&gt;&#xA;&lt;p&gt;Task4: {{1,2,3,4,5,6,7,8},{17,18,19,20,21,22,23,24}};&lt;/p&gt;&#xA;&lt;p&gt;Task5: {{1,2,3,4,5,6,7,8},{9,10,11,12,13,14,15,16}};&lt;/p&gt;&#xA;&lt;p&gt;One machine can be allocated to one task only, i.e., one machine can not be shared by multiple tasks.&lt;/p&gt;&#xA;&lt;p&gt;The tasks are ordered in terms of their priority. For example, task 1 has higher priority than task 2, task 2 has higher priority than task 3, and so on.&lt;/p&gt;&#xA;&lt;p&gt;Need to assign machines to as many tasks as possible.&lt;/p&gt;&#xA;&lt;p&gt;The figure just shows one small instance of a problem.&lt;/p&gt;&#xA;&lt;p&gt;The optimal mapping is shown here. That is the first task gets assigned with its 2nd option, 2nd task gets assigned with its 2nd option, 3rd task gets assigned with its 1st option and so on.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for a purely heuristic solution. Does not prefer any meta-heuristic for some reasons. A solution than can be generalized to other similar problem instances.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bf{Objective}:$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Each task has one utility value, &lt;span class=&quot;math-container&quot;&gt;$u_p, p=1,2,\cdots, P$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is the number of tasks. We have &lt;span class=&quot;math-container&quot;&gt;$u_1&amp;gt;u_2&amp;gt;u_3&amp;gt;\cdots&amp;gt;u_P$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u_1=0.9706$&lt;/span&gt;,    &lt;span class=&quot;math-container&quot;&gt;$u_2=0.9572$&lt;/span&gt;,    &lt;span class=&quot;math-container&quot;&gt;$u_3=0.8003$&lt;/span&gt;,    &lt;span class=&quot;math-container&quot;&gt;$u_4=0.4854$&lt;/span&gt;,    &lt;span class=&quot;math-container&quot;&gt;$u_5=0.1576$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective is to maximise the sum-utility, &lt;span class=&quot;math-container&quot;&gt;$max \sum_{p=1}^Pu_p$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2022-10-14T08:11:25.400" LastActivityDate="2022-10-14T08:11:25.400" Title="How to solve this generalized set packing problem?" Tags="|optimization|convex-optimization|heuristics|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9077" PostTypeId="1" CreationDate="2022-10-01T06:12:20.367" Score="5" ViewCount="210" Body="&lt;p&gt;I'm working on my first Pyomo DAE project to teach myself how to use it for trajectory optimization.  I have generated an atmosphere lookup table with density and speed of sound as a function of altitude.  Pyomo will not accept the following code for my concrete model:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;# create a model object&#xA;m = ConcreteModel()&#xA;&#xA;# define the independent variables&#xA;m.stage  = RangeSet(0,1,bounds=(0,1))&#xA;m.tau    = ContinuousSet(bounds=(0,1))&#xA;m.t      = Var(m.stage, m.tau)&#xA;&#xA;# define the dependent variables&#xA;m.px    = Var(m.stage, m.tau)&#xA;m.py    = Var(m.stage, m.tau)&#xA;m.v     = Var(m.stage, m.tau, bounds=(vmin, None))&#xA;m.g     = Var(m.stage, m.tau, bounds=(gmin, gmax))&#xA;&#xA;# define internal function to calculate Mach number&#xA;def _Mach(alt,v):&#xA;    sos = np.interp(alt,altTab,sosTab)&#xA;    return v/sos&#xA;&#xA;# define algebraic auxiliary variables&#xA;m.Mach     = Var(m.stage, m.tau)&#xA;m.alg_Mach = Constraint(m.stage, m.tau, rule=lambda m, stage, tau: \&#xA;    m.Mach[stage,tau] == _Mach(m.py[stage,tau],m.v[stage,tau]) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;m.stage&lt;/code&gt; is a Pyomo &lt;code&gt;RangeSet&lt;/code&gt; over [0,1] to represent the two phases of my problem (boost and coast)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;m.tau&lt;/code&gt; is a &lt;code&gt;ContinuousSet&lt;/code&gt; over [0,1] which is normalized time&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;m.py&lt;/code&gt; is the altitude variable&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;m.v&lt;/code&gt; is the airspeed variable&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;altTab&lt;/code&gt; and &lt;code&gt;sosTab&lt;/code&gt; are 1D &lt;code&gt;numpy.array&lt;/code&gt; variables defined using a previous call to &lt;code&gt;pyatmos.coesa76&lt;/code&gt;, but they could be any arbitrary &lt;code&gt;numpy.array&lt;/code&gt;s for test purposes.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The error message is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ERROR: Rule failed when generating expression for Constraint alg_Mach with&#xA;    index (0, 0): TypeError: Implicit conversion of Pyomo numeric value&#xA;    (py[0,0]) to float is disabled. This error is often the result of using&#xA;    Pyomo components as arguments to one of the Python built-in math module&#xA;    functions when defining expressions. Avoid this error by using Pyomo-&#xA;    provided math functions or explicitly resolving the numeric value using&#xA;    the Pyomo value() function.&#xA;ERROR: Constructing component 'alg_Mach' from data=None failed: TypeError:&#xA;    Implicit conversion of Pyomo numeric value (py[0,0]) to float is disabled.&#xA;    This error is often the result of using Pyomo components as arguments to&#xA;    one of the Python built-in math module functions when defining&#xA;    expressions. Avoid this error by using Pyomo-provided math functions or&#xA;    explicitly resolving the numeric value using the Pyomo value() function.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What's the acceptable way to perform linear interpolation on parameters of a Pyomo DAE problem?&lt;/p&gt;&#xA;" OwnerUserId="10455" LastActivityDate="2022-10-01T06:12:20.367" Title="How to use interpolation for problem parameters in Pyomo" Tags="|optimization|python|pyomo|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9079" PostTypeId="1" AcceptedAnswerId="9080" CreationDate="2022-10-01T13:24:21.293" Score="3" ViewCount="438" Body="&lt;p&gt;Is there a benefit in using integer variables instead of binaries?&lt;/p&gt;&#xA;&lt;p&gt;I have modeled an optimization model declaring variables that equal sums of binaries to be treated as continuous variables (by declaring them to be continuous); the solver finds it obviously advantageous, during preprocessing, to change their type to integer. What could be a reason for this?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="1269" LastEditDate="2022-10-01T13:43:04.960" LastActivityDate="2022-10-02T03:19:25.687" Title="Integers instead of binaries" Tags="|mixed-integer-programming|modeling|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9080" PostTypeId="2" ParentId="9079" CreationDate="2022-10-01T16:34:20.200" Score="5" Body="&lt;p&gt;The solver may be able to use the integrality of the sums to do some bound tightening. For instance, if &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is one of your sum variables and, at some node in the tree, appears in a constraint that the solver targets for a &lt;a href=&quot;https://en.wikipedia.org/wiki/Cutting-plane_method#Gomory%27s_cut&quot; rel=&quot;noreferrer&quot;&gt;Gomory cut&lt;/a&gt;, knowing that &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is integer and cannot have a fractional portion will factor into the computation of the cut.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-01T16:34:20.200" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9081" PostTypeId="2" ParentId="9076" CreationDate="2022-10-01T20:40:04.917" Score="1" Body="&lt;p&gt;You can try a random search heuristic. To begin, enumerate all resource blocks that can be assigned (the 18 colored blocks in your diagram) and calculate which conflict with each other. If we number your blocks 1 to 18 in raster scan order, then block 2 (resources 5 and 6) conflicts with block 15 (resources 1 through 8) etc. Let &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; be the number of resource blocks (18 here).&lt;/p&gt;&#xA;&lt;p&gt;Now generate a random permutation &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$1,\dots,N$&lt;/span&gt; and go through your list people in descending priority order, assigning each person the available resource block whose index appears earliest in &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; among those compatible with that person. After making an assignment, that block and any conflicting blocks become unavailable (meaning their indices are removed from &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt;). If none of the remaining blocks are compatible, the person goes unserved.&lt;/p&gt;&#xA;&lt;p&gt;Once an assignment is complete, check to see if it is a new incumbent (objective value better than the current incumbent), then generate a new permutation and repeat the process. You can run the heuristic for either a fixed number of iterations or a fixed amount of time, and you can exit early if you get a provably optimal solution (everyone got served).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-01T20:40:04.917" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9082" PostTypeId="2" ParentId="9079" CreationDate="2022-10-02T00:53:50.370" Score="5" Body="&lt;p&gt;The solver may be able to avoid spending time unnecessarily propagating obviously-incorrect partial solutions around. Imagine for instance I have the following partial problem fragment:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;s,t,u,v,w \in R \\&#xA;c,d,e,f \in Z \\&#xA;b_{i} \in \lbrace 0,1\rbrace \\&#xA;s = b_{0} + 2^1 b_{1} + 2^2 b_{2} + 2^3 b_{3} \\&#xA;s + c = t \\&#xA;t + d = u \\&#xA;u + e = v \\&#xA;v + f = w \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Imagine the solver, while working on the larger problem, comes up with a bound for &lt;span class=&quot;math-container&quot;&gt;$1.1 \le w \le 1.9$&lt;/span&gt;, with the other variables in this fragment still unknown. If you're treating &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; as continuous, this appears to be valid thus far, and you're going to go ahead and do a bunch of work before realizing that there's no way to make this work.&lt;/p&gt;&#xA;&lt;p&gt;However, if you did some up-front work, and realized that &lt;span class=&quot;math-container&quot;&gt;$s \in Z$&lt;/span&gt; (as it is a sum of binary variables), then you can show &lt;span class=&quot;math-container&quot;&gt;$t \in Z$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$u \in Z$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$v \in Z$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$w \in Z$&lt;/span&gt;. Which then means that if you're solving and come up with a bound for &lt;span class=&quot;math-container&quot;&gt;$1.1 \le w \le 1.9$&lt;/span&gt;, you can immediately stop (and likely backtrack).&lt;/p&gt;&#xA;&lt;p&gt;Is this &lt;em&gt;always&lt;/em&gt; worth it? No. However, your solver obviously thought it advantageous in your particular case.&lt;/p&gt;&#xA;" OwnerUserId="821" LastEditorUserId="67" LastEditDate="2022-10-02T03:19:25.687" LastActivityDate="2022-10-02T03:19:25.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9083" PostTypeId="1" AcceptedAnswerId="9084" CreationDate="2022-10-02T14:12:18.333" Score="6" ViewCount="2727" Body="&lt;p&gt;I am working since a few months with gurobi and did figure out, that the gap says how far a feasible solutions is away from the optimal solution. However, what does say it exactly?&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/mipgap2.html&quot; rel=&quot;noreferrer&quot;&gt;gurobi docs says&lt;/a&gt; it depends on the upper and lower objective bound. I figured out, that this depends to duality.&lt;/p&gt;&#xA;&lt;p&gt;As I did understand this topic: The lower bound descripes an objective value for the lowest values of the decision variables that is still feasible. The upper bound does descripe the highest values for feasible objective value. So the gap for a feasible solution descripes the distances between those bounds.&#xA;However, which one do the solver exactly know and which one is a solution the solver founds during the branch-and-bound process?&lt;/p&gt;&#xA;" OwnerUserId="9830" LastActivityDate="2022-10-02T15:37:15.200" Title="What exactly is the optimality-gap or what does it say in integer linear programming?" Tags="|gurobi|optimality-gap|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9084" PostTypeId="2" ParentId="9083" CreationDate="2022-10-02T15:37:15.200" Score="12" Body="&lt;p&gt;In a minimization problem, the lower bound will be a value below which the objective value cannot go. The upper bound will be the objective value of the best solution found so far. The lower bound is found by solving a relaxation of the subproblem at each surviving node of the search tree and taking the smallest objective value of any of those nodes. So at any given point you know that the upper bound is attainable (because it comes from the current incumbent solution) and that you may or may not be able to improve on it, and you know that the optimal objective cannot be better than the lower bound (best relaxed objective value of any node). The upper bound improves each time you find a new incumbent, and the lower bound improves as nodes are pruned from the search tree.&lt;/p&gt;&#xA;&lt;p&gt;For a maximization problem, the reverse occurs. The lower bound is the incumbent objective value and the upper bound is the largest (relaxed) objective value at any live node.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-02T15:37:15.200" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9085" PostTypeId="1" CreationDate="2022-10-02T15:51:25.977" Score="1" ViewCount="84" Body="&lt;p&gt;I've written some codes in order to optimize a DEA problem using GAMS. After solving it, all the DMUs efficiencies were equal to 1.&#xA;As my GAMS program is Demo; therefore, I guess this may cause due to the higher number of digits (more than 7). I ran my codes with 2, three, four, and five digits, and I found out that for five digits and more, all DMUs will be completely efficient (=1). It seems that the software assumes the upper bound for data. How can I resolve it?&lt;/p&gt;&#xA;" OwnerUserId="10465" LastActivityDate="2022-10-02T15:51:25.977" Title="DEA problem in GAMS" Tags="|optimization|linear-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9089" PostTypeId="2" ParentId="5563" CreationDate="2022-10-05T03:04:33.790" Score="2" Body="&lt;p&gt;I have faced the same problem in getting an educational license since my college activities are fully remote. My solution (and I think the easiest way) is to open a support ticket and send several documents to validate you are the student.&lt;/p&gt;&#xA;" OwnerUserId="10000" LastActivityDate="2022-10-05T03:04:33.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9090" PostTypeId="1" AcceptedAnswerId="9091" CreationDate="2022-10-05T17:15:37.057" Score="3" ViewCount="292" Body="&lt;p&gt;I have a model that contains the sets (both ordered and Days also circular): Days and Personnel, and I'm trying to make a restriction run exaclty once per Day for every member of Personnel. I'm using AMPL python API and the X-Gurobi solver.&lt;/p&gt;&#xA;&lt;p&gt;I wrote the restriction, in AMPL, as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;subject to Continuos_Free_Days{p in Personnel}: exactly 1 {d in Days} (Free_Day[p,d] = 1 ==&amp;gt; Free_Day[p,next(d,Days)] = 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But, when I try to solve the model I get and exception raised at the terminal&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Warning:&#xA;        Error executing &amp;quot;solve&amp;quot; command:&#xA;        &#xA;                Bug: unexpected type 0x9a0c in lsimplify()&#xA; &#xA;Traceback (most recent call last):&#xA;      File &amp;quot;~/OptimizationMainProject/MainDev/K_Personnel/kopt.py&amp;quot;, line 30, in &amp;lt;module&amp;gt;&#xA;        ampl.eval(&amp;quot;table Assignation_DB OUT 'amplxl': [Personnel,Days,Restaurants,Shifts,Activities],Activated_Assignation;&amp;quot;)&#xA;      File &amp;quot;~/VirtualEnviroments/pyvenvmacos/lib/python3.10/site-packages/amplpy/ampl.py&amp;quot;, line 265, in eval&#xA;        self._impl.eval(statements)&#xA;    RuntimeError: Unexpected end of file while reading AMPL output.&#xA;    Usually this is caused by the termination of the underlying AMPL interpreter.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If I remove said constraint, the program runs smoothly and gets an optimal solution. Up until now, I have never got an exception like this one and every other project I'm currently working on runs smoothly also (none of them contains a restriction using the exactly operator).&lt;/p&gt;&#xA;&lt;p&gt;Does anyone know why is this exception being raised? Is there any other way I could rewrite the constraint to solve it?&lt;/p&gt;&#xA;" OwnerUserId="10141" LastEditorUserId="10141" LastEditDate="2022-10-05T17:55:53.023" LastActivityDate="2022-10-05T18:19:16.767" Title="Unexpected runtime error" Tags="|optimization|gurobi|constraint-programming|logical-constraints|ampl|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9091" PostTypeId="2" ParentId="9090" CreationDate="2022-10-05T18:19:16.767" Score="5" Body="&lt;p&gt;I don't think you want ==&amp;gt; here, since &lt;code&gt;Free_Day[p,d] = 1 ==&amp;gt; Free_Day[p,next(d,Days)] = 1&lt;/code&gt; is satisfied anytime &lt;code&gt;Free_Day[p,d] = 0&lt;/code&gt;. Do you maybe instead want this?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;subject to Continuous_Free_Days{p in Personnel}: &#xA;   exactly 1 {d in Days} (Free_Day[p,d] = 1 and Free_Day[p,next(d,Days)] = 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If that still gives trouble, you could also try&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;subject to Continuous_Free_Days2{p in Personnel}: &#xA;   count {d in Days} (Free_Day[p,d] = 1 and Free_Day[p,next(d,Days)] = 1) = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you can't get any of these to work, then you're seeing a more general bug. You can report it by sending a minimal example to support@ampl.com, and the developers will get a fix out pretty quickly. In the mean time, I expect someone will suggest a linearization of this constraint.&lt;/p&gt;&#xA;" OwnerUserId="52" LastActivityDate="2022-10-05T18:19:16.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9092" PostTypeId="1" CreationDate="2022-10-05T21:28:36.537" Score="3" ViewCount="264" Body="&lt;p&gt;How can I implement a callback-function to be executed at specific occurrences after having started to optimize? Specifically, I simply want the primal solution to be printed to the console every time an improved  primal solution has been found. I have tried to look at the documentation I could find, but have not found anything helpful.&lt;/p&gt;&#xA;" OwnerUserId="9151" LastEditorUserId="67" LastEditDate="2022-10-05T21:53:43.387" LastActivityDate="2022-10-07T15:45:09.597" Title="Using callbacks in pyscipopt" Tags="|python|callback|scip|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9093" PostTypeId="1" AcceptedAnswerId="9096" CreationDate="2022-10-06T09:58:00.890" Score="7" ViewCount="307" Body="&lt;p&gt;I was reading through the following notes regarding solving a 9x9 Sudoku via a binary integer program&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://vanderbei.princeton.edu/tex/talks/INFORMS_19/Sudoku.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vanderbei.princeton.edu/tex/talks/INFORMS_19/Sudoku.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The formulation is straightforward but on slide 10 the author claims that if the problem has a unique integer solution then that implies the linear relaxation has the same solution and therefore the binary constraints on the variables is unnecessary.&lt;/p&gt;&#xA;&lt;p&gt;It's really not clear to me why this would be so.  Wouldn't this contradict the fact that Sudoku is known to be NP-complete?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/d5xyl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/d5xyl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&lt;p&gt;The following Sudoku has a unique solution.  You can verify that by solving it by logical deduction alone.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;4  7     |     3     |  6  2   &#xA;9  3     |  2     6  |  7  4   &#xA;6  2  8  |  5  7  4  |  1  9  3&#xA;-------------------------------&#xA;2  1  3  |  8  4  5  |  9  7  6&#xA;   4  9  |  3  6  7  |     1  2&#xA;7     6  |        2  |  3     4&#xA;-------------------------------&#xA;1  6  7  |  4     3  |  2     9&#xA;3     4  |  7  2     |     6  1&#xA;      2  |  6     1  |  4  3  7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I adapted the PuLP sudoku example code and the LP relaxation solves with the unique integral solution.  However, I introduced auxiliary variable and constraints and changed objective function to make non integral solutions more attractive, and it found a solution where 42 of the variables had a value of 1/2.&lt;/p&gt;&#xA;&lt;p&gt;So this counts as a counter-example that a unique BIP solution gives rise to a unique LP solution.&lt;/p&gt;&#xA;" OwnerUserId="10392" LastEditorUserId="10392" LastEditDate="2022-10-10T09:10:46.663" LastActivityDate="2022-10-10T17:20:56.210" Title="BIP for Sudoku naturally integral?" Tags="|mixed-integer-programming|linear-programming|binary-variable|computational-complexity|np-complete|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9094" PostTypeId="1" CreationDate="2022-10-05T07:36:48.883" Score="2" ViewCount="54" Body="&lt;p&gt;I am working on an operations optimization problem and am describing the problem below. At first glance, it seems like a mix of vehicle route optimization and a scheduling problem.&lt;/p&gt;&#xA;&lt;p&gt;The expected solution will effectively allocate outlets for salespeople based on a combination of&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Most optimized route&lt;/li&gt;&#xA;&lt;li&gt;Other constraints based on outlet characteristics&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Consider a salesperson, a single salesperson is associated with 200 outlets. They work 24 days a month.&#xA;At a monthly level, associated outlets must be assigned daily to the salesperson based on the optimized route (travelling salesman problem). This is straightforward if all the outlets must be visited only once.&lt;/p&gt;&#xA;&lt;p&gt;However, there is a catch. Some of the outlets from the pool of 200 must be assigned multiple times for the month based on their priority (1-4 times), and the assignments should be equidistant from each other. e.g., if an outlet with priority two is assigned on day 1 of week 1, the outlet will need to be reassigned on day one of week three all the while ensuring the shortest route traveled.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for some direction to be able to address the above problem. Possible solutions, references, directions insights etc.&lt;/p&gt;&#xA;" OwnerDisplayName="prajwalram8" LastEditorUserId="491" LastEditDate="2023-04-06T12:13:49.010" LastActivityDate="2023-04-06T12:13:49.010" Title="Optimizing personnel allocation within a fixed period" Tags="|optimization|vehicle-routing|clustering|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9095" PostTypeId="1" CreationDate="2022-10-06T17:44:16.073" Score="3" ViewCount="257" Body="&lt;p&gt;I'm curious, what are the most popular heuristic algorithms? I've been making use of Genetic Algorithms via PyGAD. But I'm curious if there are other heuristic implementations that are flexible to function input.&lt;/p&gt;&#xA;&lt;p&gt;For example, &lt;a href=&quot;https://colab.research.google.com/drive/16WHc2h210Lt6z5kiesw5_SqfPK9L3UIv?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;PyGAD can be used for linear regression&lt;/a&gt; and &lt;a href=&quot;https://pygad.readthedocs.io/en/latest/&quot; rel=&quot;nofollow noreferrer&quot;&gt;parameter weighting&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10326" LastActivityDate="2022-10-06T18:37:07.520" Title="Most popular heuristic algorithms and python implementation?" Tags="|python|heuristics|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9096" PostTypeId="2" ParentId="9093" CreationDate="2022-10-06T17:55:50.200" Score="2" Body="&lt;p&gt;The creators of the Sudoku puzzles ensure players that there is a unique solution to the puzzle. Hence, the system of integer linear equalities over Boolean variables described in Vanderbei's slides has one and only one solution. This is what Vanderbei calls the &amp;quot;unique integer solution&amp;quot; in slide 10.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: THE FOLLOWING ARGUMENT IS FALSE BECAUSE THE RANK OF THE MATRIX IS NOT (NECESSARILY) FULL. SORRY FOR THIS WRONG PATH. SEE THE DISCUSSION IN THE COMMENT. Now, consider a relaxation of this system of equalities over the reals. This is what Vanderbei calls &amp;quot;linear relaxation&amp;quot; in slide 10. The unique integer solution discussed above remains a solution to this relaxed system. A system of linear equalities over the reals has no solution, one solution, or an infinite number of solutions (for a proof of this claim, or at least an intuition, please check a &lt;a href=&quot;https://www.math.ucla.edu/%7Earchristian/notes/linear-algebra/systems-of-linear-equations.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;linear algebra course&lt;/a&gt; on the web). Consequently, the linear relaxation has one solution which is the integer one.&lt;/p&gt;&#xA;&lt;p&gt;In the case where the initial assertion becomes false - &amp;quot;the creators of the Sudoku puzzles ensure players that there is a unique solution to the puzzle&amp;quot; - then the property above does not hold anymore.&lt;/p&gt;&#xA;&lt;p&gt;Then, to answer your question, the best is to cite &lt;a href=&quot;https://www.ics.uci.edu/%7Eeppstein/&quot; rel=&quot;nofollow noreferrer&quot;&gt;David Eppstein&lt;/a&gt;, a renowned computational complexity theorist, who &lt;a href=&quot;https://11011110.github.io/blog/2005/10/16/complexity-theory-and.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;blogged a lot&lt;/a&gt; about the complexity of the Sudoku puzzle in the past:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;In the meantime, when one says Sudoku is NP-complete, one should keep in mind that this refers only to an unusual type of Sudoku puzzle in which there might be multiple solutions.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;To conclude, may we recall that any KxK Sodoku puzzle with K a fixed parameter in input, that is, with K a constant, is solvable in constant time.&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2022-10-10T17:20:56.210" LastActivityDate="2022-10-10T17:20:56.210" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="9097" PostTypeId="2" ParentId="9095" CreationDate="2022-10-06T18:37:07.520" Score="6" Body="&lt;p&gt;Good luck running a metaheuristic popularity contest. Every one has its (ardent) proponents. You might want to take a look at the &lt;a href=&quot;https://github.com/fcampelo/EC-Bestiary&quot; rel=&quot;noreferrer&quot;&gt;Evolution Computation Bestiary&lt;/a&gt;, a glossary of just the zillions of metaheuristics based (however loosely) on some aspect of evolution. My personal favorite is slime mold optimization, not due to its performance (I've never tried it) but just due to the name.&lt;/p&gt;&#xA;&lt;p&gt;Since you are already using GAs, let me point out that they may be more flexible than they appear. When they were first introduced, there was always a 1-1 relation between &amp;quot;genes&amp;quot; (positions in a &amp;quot;chromosome&amp;quot;) and variables in the original problem. That is still the most common use, but a while back people introduced the idea of a decoding step (a transformation from the chromosome to a solution), which adds some flexibility. In conjunction with the idea of permutation-type chromosomes (where the chromosome is a permutation of integer indices &lt;span class=&quot;math-container&quot;&gt;$1,\dots,n$&lt;/span&gt;), this made GAs more useful for scheduling and sequencing problems, among others.&lt;/p&gt;&#xA;&lt;p&gt;I've used GAs for a number of problems, and I can't recall the last time I used any other metaheuristic -- but that's partly because I'm too lazy to research other metaheuristics if I can get a GA to do a decent job. (Problem-specific heuristics are a separate matter.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-06T18:37:07.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9098" PostTypeId="2" ParentId="1392" CreationDate="2022-10-06T19:29:12.727" Score="2" Body="&lt;p&gt;thanks Niko and all; I'd add a few things to this nice discussion.&lt;/p&gt;&#xA;&lt;p&gt;When you say &amp;quot;first feasible point&amp;quot;, do you mean &amp;quot;any&amp;quot; point ? We have boundary feasible points, interior, and bases.&lt;/p&gt;&#xA;&lt;p&gt;For a strictly interior point, a (polynomial) infeasible IPM can quickly give you one without the need to converge to the optimal solution (if such exists). You just set your objective vector to zero and therefore the first feasible point will also be optimal so the algorithm terminates. With todays LP solvers this is very fast (and parallel).&lt;/p&gt;&#xA;&lt;p&gt;For a basis, you better use a Simplex-type algorithm that pivots. You can find a feasible basis with the big-M method or the Two-Phases method. None requires a feasible point to begin with and they will find one if the problem is feasible (in the two phase method eventually the artificial variable will exit the basis).&lt;/p&gt;&#xA;&lt;p&gt;Apologies if the question was more from a theoretical point of view, as my answer is mainly of practical interest.&lt;/p&gt;&#xA;" OwnerUserId="10490" LastActivityDate="2022-10-06T19:29:12.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9099" PostTypeId="1" CreationDate="2022-10-06T20:14:04.960" Score="3" ViewCount="46" Body="&lt;p&gt;I'm looking for E. Balas' original paper &amp;quot;Finding a Minimaximal Path in a Disjunctive PERT Network&amp;quot;. Is this paper available via the web? Google and my campus library are unable to help me find a copy of this paper. It appears that it was originally published in a French journal, and I speak no French. Is the paper even in English?&lt;/p&gt;&#xA;&lt;p&gt;My purpose in looking for it: it is common now to represent job-shop problems as disjunctive graphs, with &lt;span class=&quot;math-container&quot;&gt;$C_{max}$&lt;/span&gt; as its minimax path. But how does one prove that the two representations are equivalent?&lt;/p&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2022-10-06T20:14:04.960" Title="Looking for Balas' original JSP-as-digraph paper" Tags="|graphs|job-shop-scheduling|journals|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9101" PostTypeId="1" CreationDate="2022-10-07T12:09:23.090" Score="3" ViewCount="130" Body="&lt;p&gt;I am currently following this guide in the hopes of building a linear programming model in python and solving using gurobi.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://towardsdatascience.com/schedule-optimisation-using-linear-programming-in-python-9b3e1bc241e1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://towardsdatascience.com/schedule-optimisation-using-linear-programming-in-python-9b3e1bc241e1&lt;/a&gt;&#xA;However, when using his generate disjunctions function on my data set, it has taken over 12 hours to complete with unknown progress&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   def _generate_disjunctions(self):&#xA;    &amp;quot;&amp;quot;&amp;quot;&#xA;    #TODO&#xA;    Returns:&#xA;        disjunctions (list): list of tuples containing disjunctions&#xA;    &amp;quot;&amp;quot;&amp;quot;&#xA;    cases = self.df_cases[&amp;quot;CaseID&amp;quot;].to_list()&#xA;    sessions = self.df_sessions[&amp;quot;SessionID&amp;quot;].to_list()&#xA;    disjunctions = []&#xA;    for (case1, case2, session) in product(cases, cases, sessions):&#xA;        if (case1 != case2) and (case2, case1, session) not in disjunctions:&#xA;            disjunctions.append((case1, case2, session))&#xA;&#xA;    return disjunctions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For reference, my equivalent data set to cases is about 9000 long, and sessions is about 11000 long. I was wondering if there was any way I could improve this code or replace it with something else that could speed up the process.&lt;/p&gt;&#xA;" OwnerUserId="10495" LastEditorUserId="491" LastEditDate="2022-10-07T18:24:22.647" LastActivityDate="2022-10-07T18:24:22.647" Title="Creating Disjunctions for MIP Model. Code taking too long to execute" Tags="|optimization|mixed-integer-programming|pyomo|job-shop-scheduling|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9102" PostTypeId="2" ParentId="9092" CreationDate="2022-10-07T15:45:09.597" Score="3" Body="&lt;p&gt;You want a custom separator that doesn't actually do anything. Here's an example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;class Cutter(scip.Sepa):&#xA;    def __init__(self):&#xA;        pass&#xA;&#xA;    def sepaexeclp(self):&#xA;        m: scip.Model = self.model&#xA;        if not m.getLPSolstat() or not m.isLPSolBasic():&#xA;            return {&amp;quot;result&amp;quot;: scip.PY_SCIP_RESULT.DIDNOTRUN}&#xA;&#xA;        cols = m.getLPColsData()&#xA;        rows = m.getLPRowsData()&#xA;        bases = m.getLPBasisInd()&#xA;&#xA;        table = [[col.getPrimsol() for col in cols]]&#xA;&#xA;        for row in rows:&#xA;            coefs = row.getVals()&#xA;            cols = row.getCols()&#xA;            data = []&#xA;            for col, coef in zip(cols, coefs):&#xA;                data.append(col.getPrimsol() * coef)&#xA;            table.append(data)&#xA;&#xA;        print(table)&#xA;        return {&amp;quot;result&amp;quot;: scip.PY_SCIP_RESULT.DIDNOTRUN}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And somewhere after you make your model, you need something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.includeSepa(Cutter(), &amp;quot;my_cutter&amp;quot;, &amp;quot;a good one&amp;quot;, 10000000, 1, 0.0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2022-10-07T15:45:09.597" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9103" PostTypeId="1" CreationDate="2022-10-07T21:49:31.693" Score="6" ViewCount="314" Body="&lt;p&gt;What is the best way to model or represent an equality constraint which includes an absolute term in the expression:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x = |y| $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R^+}$&lt;/span&gt; and  &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{R}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9695" LastEditorUserId="500" LastEditDate="2022-10-08T00:19:07.757" LastActivityDate="2022-10-08T00:19:07.757" Title="Absolute value in an equality constraint" Tags="|mixed-integer-programming|constraint|linearization|absolute-value|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9104" PostTypeId="2" ParentId="9103" CreationDate="2022-10-08T00:16:29.413" Score="7" Body="&lt;p&gt;If the objective function and the remaining constraints are such that the solver will always prefer smaller values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; over larger values, you can get by with two constraints: &lt;span class=&quot;math-container&quot;&gt;$x\ge y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x\ge -y.$&lt;/span&gt; Otherwise, assuming you know an upper bound &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\vert y\vert,$&lt;/span&gt; you can introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and the constraints &lt;span class=&quot;math-container&quot;&gt;$$0\le x-y \le 2U\cdot z$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$0 \le x+y \le 2U\cdot (1-z).$$&lt;/span&gt; When &lt;span class=&quot;math-container&quot;&gt;$z=0,$&lt;/span&gt; the first constraint forces &lt;span class=&quot;math-container&quot;&gt;$x=y$&lt;/span&gt; (meaning &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; must be &lt;span class=&quot;math-container&quot;&gt;$\ge 0$&lt;/span&gt;) and the second constraint is harmless (since &lt;span class=&quot;math-container&quot;&gt;$x+y=2y=2\vert y\vert \le 2U$&lt;/span&gt;). When &lt;span class=&quot;math-container&quot;&gt;$z=1,$&lt;/span&gt; the second constraint forces &lt;span class=&quot;math-container&quot;&gt;$x=-y$&lt;/span&gt; (meaning &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; must be &lt;span class=&quot;math-container&quot;&gt;$\le 0$&lt;/span&gt;) and the first constraint is harmless (since &lt;span class=&quot;math-container&quot;&gt;$x-y=2\vert y\vert$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-08T00:16:29.413" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9105" PostTypeId="1" AcceptedAnswerId="9106" CreationDate="2022-10-08T16:48:43.453" Score="5" ViewCount="244" Body="&lt;p&gt;Let's say I want to linearize the restrictions: &lt;span class=&quot;math-container&quot;&gt;$ \min(0, y) \leq x \leq \max(0, y) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then I can define &lt;span class=&quot;math-container&quot;&gt;$y_{\max}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{\min}$&lt;/span&gt; such that:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ y_{\max} \geq 0 \\ y_{\max} \geq y \\ y_{\min} \leq 0 \\ y_{\min} \leq y \\ y_{\max} + y_{\min} = y $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If I now reformulate the original restriction as &lt;span class=&quot;math-container&quot;&gt;$ y_{\min} \leq x \leq y_{\max} $&lt;/span&gt;, have I now successfully linearized the constraint &lt;em&gt;without&lt;/em&gt; needing to add binary decision variables? E.g. can I use this restriction in a simple LP?&lt;/p&gt;&#xA;" OwnerUserId="10496" LastEditorUserId="10496" LastEditDate="2022-10-13T13:32:15.203" LastActivityDate="2022-10-13T13:32:15.203" Title="Linearize minimum and maximum constraint with variable and constant" Tags="|linear-programming|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9106" PostTypeId="2" ParentId="9105" CreationDate="2022-10-08T17:04:51.247" Score="10" Body="&lt;p&gt;Consider &lt;span class=&quot;math-container&quot;&gt;$(x,y,y_\min,y_\max)=(1,0,-1,1)$&lt;/span&gt;, which satisfies your proposed linearization but violates the original constraints.&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, notice that &lt;span class=&quot;math-container&quot;&gt;$(x,y)=(1,0)$&lt;/span&gt; is halfway between two points &lt;span class=&quot;math-container&quot;&gt;$(2,2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(0,-2)$&lt;/span&gt; that do satisfy the original constraints, so the feasible region is not convex, which implies that no LP formulation is possible.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-10-08T20:36:26.173" LastActivityDate="2022-10-08T20:36:26.173" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9107" PostTypeId="1" CreationDate="2022-10-10T09:05:05.930" Score="2" ViewCount="136" Body="&lt;p&gt;My directed graph &lt;em&gt;f&lt;/em&gt; with any node &lt;em&gt;u&lt;/em&gt; has a set of outgoing and incoming links as &lt;em&gt;uv ∈ O(u)&lt;/em&gt; and &lt;em&gt;vu ∈ I(u)&lt;/em&gt; respectively.&#xA;I am trying to write this constraint&lt;a href=&quot;https://i.stack.imgur.com/Edtgg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Edtgg.png&quot; alt=&quot;structural constraint&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;here &lt;em&gt;ϕ&lt;/em&gt; refers to a binary decision variable while &lt;em&gt;u_bar, v_bar&lt;/em&gt; and &lt;em&gt;uv_bar&lt;/em&gt; refers to nodes and link in another graph.&#xA;I am trying to model it this way.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Dictionary of Node as key with its outgoing edges as value pair&#xA;out_edges_node_map = {}&#xA;for out_going in G_SERVER.nodes:&#xA;    out_new_item = {out_going: list(G_SERVER.out_edges(out_going))}&#xA;    out_edges_node_map.update(out_new_item)&#xA;print(&amp;quot;Testing to print dictionary&amp;quot;, out_edges_node_map)   &#xA;&#xA;#list of list where index is node and list elements are destinations of the outgoing edge of that node&#xA;    out_main_list = []&#xA;    for out_index_list, out_value_list in out_edges_node_map.items():&#xA;        out_list = []&#xA;        for i in out_value_list:&#xA;            out_list.append(int(i[1]))&#xA;        out_main_list.append(out_list)&#xA;    print(&amp;quot;printing the list of list for all nodes and their destinations in the out going edges&amp;quot;, out_main_list)  &#xA;&#xA;model.capacity_BW_out=Param(model.capacity_BW_set, initialize=out_main_list)&#xA;&#xA;#Dictionary of Node as key with its incoming edges as value pair&#xA;    in_edges_node_map = {}&#xA;    for in_coming in G_SERVER.nodes:&#xA;        in_new_item = {in_coming: list(G_SERVER.in_edges(in_coming))}&#xA;        in_edges_node_map.update(in_new_item)&#xA;    print(&amp;quot;Testing to print incoming dictionary&amp;quot;, in_edges_node_map)&#xA;&#xA;#list of list where index is node and list elements are destinations of incoming edge of that node&#xA;    in_main_list = []&#xA;    for in_index_list, in_value_list in in_edges_node_map.items():&#xA;        in_list = []&#xA;        for i in in_value_list:&#xA;            in_list.append(int(i[0]))&#xA;        in_main_list.append(in_list)&#xA;    print(&amp;quot;printing the list of list for all nodes and their destinations in the in coming edges&amp;quot;, in_main_list)&#xA;&#xA;model.capacity_BW_in=Param(model.capacity_BW_set, initialize=in_main_list)&#xA;&#xA;model.out_going_link_u_set=RangeSet(0, len(in_edges_node_map)-1)&#xA;model.in_coming_link_u_set=RangeSet(0, len(out_edges_node_map)-1)&#xA;&#xA;model.out_going_destination_u_set=RangeSet(0, len(in_main_list)-1)&#xA;model.in_going_destination_u_set=RangeSet(0, len(out_main_list)-1)&#xA; &#xA;def structural_rule1(model, u, uvb, ub, vb):&#xA;    return sum(model.fil[uvb, uv] for uv in model.out_going_link_u_set) - sum(&#xA;        model.fil[uvb, vu] for vu in model.in_coming_link_u_set) &amp;lt;= model.fi[ub, u] - model.fi[vb, u]&#xA;&#xA;model.structural_constraint1 = Constraint(model.out_going_destination_u_set, model.demand_BW_set, model.demand_CPU_set, model.demand_CPU_set, rule=structural_rule1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Pyomo is asking me to define &lt;em&gt;ub and vb&lt;/em&gt; (from right side of constriant) Where I should define these? I have tried passing that as arguments and defining these on right side as well.&lt;/p&gt;&#xA;" OwnerUserId="10356" LastEditorUserId="10356" LastEditDate="2022-10-21T10:10:00.127" LastActivityDate="2022-10-21T10:10:00.127" Title="Fixing a complex linear constraint in pyomo" Tags="|optimization|linear-programming|constraint|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9108" PostTypeId="2" ParentId="9107" CreationDate="2022-10-10T09:22:40.497" Score="2" Body="&lt;p&gt;Names you use should be defined somewhere, either as arguments of the function, or as elements of some set you are iterating/summing over. In this case you havent defined &lt;em&gt;ub&lt;/em&gt; and &lt;em&gt;uv&lt;/em&gt; anywhere. You can fix this by adding them as arguments of your constraint function and specifying the proper indexsets when adding the constraint to the model.&lt;/p&gt;&#xA;" OwnerUserId="3898" LastActivityDate="2022-10-10T09:22:40.497" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9109" PostTypeId="1" CreationDate="2022-10-11T11:44:01.223" Score="2" ViewCount="345" Body="&lt;p&gt;I am solving a (rather large) MILP in CPLEX in Java. I also wrote a solution extractor method, which works most of the time. However, when CPLEX tries to solve my problem with the dual simplex method it seems to get stuck in the solve method? Hence, it now seems as if for some instances I get feasible solutions and for some instances I do not get any results. Could someone tell me how to extract the solution after &lt;code&gt;Dual simplex solved model.&lt;/code&gt; is shown?&lt;/p&gt;&#xA;&lt;p&gt;See below the output when I run my program for a particular instance where this happens&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Version identifier: 20.1.0.0 | 2020-11-10 | 9bedb6d68&#xA;CPXPARAM_MIP_Display                             4&#xA;Tried aggregator 4 times.&#xA;Aggregator has done 6411 substitutions...&#xA;MIP Presolve eliminated 256991 rows and 123355 columns.&#xA;Aggregator did 6411 substitutions.&#xA;Reduced MIP has 362983 rows, 181240 columns, and 4585972 nonzeros.&#xA;Reduced MIP has 181240 binaries, 0 generals, 0 SOSs, and 0 indicators.&#xA;Presolve time = 39.05 sec. (17751.56 ticks)&#xA;Found incumbent of value 32237.000000 after 39.61 sec. (18374.96 ticks)&#xA;Probing time = 21.42 sec. (2888.50 ticks)&#xA;Tried aggregator 1 time.&#xA;Detecting symmetries...&#xA;MIP Presolve eliminated 4741 rows and 2406 columns.&#xA;Reduced MIP has 358242 rows, 178834 columns, and 4570728 nonzeros.&#xA;Reduced MIP has 178834 binaries, 0 generals, 0 SOSs, and 0 indicators.&#xA;Presolve time = 18.57 sec. (9204.98 ticks)&#xA;Probing time = 20.17 sec. (3421.28 ticks)&#xA;Clique table members: 2377190.&#xA;MIP emphasis: balance optimality and feasibility.&#xA;MIP search method: dynamic search.&#xA;Parallel mode: deterministic, using up to 8 threads.&#xA;Parallel mode: deterministic, using up to 2 threads for parallel tasks at root LP.&#xA;Parallel mode: deterministic, using up to 6 threads for concurrent optimization:&#xA; * Starting dual Simplex on 1 thread...&#xA; * Starting Barrier on 4 threads...&#xA; * Starting primal Simplex on 1 thread...&#xA;Tried aggregator 1 time.&#xA;No LP presolve or aggregator reductions.&#xA;Presolve time = 0.47 sec. (369.39 ticks)&#xA;Initializing dual steep norms . . .&#xA;&#xA;Iteration log . . .&#xA;Iteration:     1   Dual objective     =       1291014.000000&#xA;Perturbation started.&#xA;Iteration:  4747   Dual objective     =        714309.000000&#xA;Iteration:  5555   Dual objective     =        523779.984383&#xA;Iteration: 10103   Dual objective     =         46821.953292&#xA;Iteration: 10521   Dual objective     =         46718.953200&#xA;Iteration: 11120   Dual objective     =         46483.953192&#xA;Iteration: 12129   Dual objective     =         45479.953182&#xA;Iteration: 13402   Dual objective     =         45416.453121&#xA;Iteration: 13886   Dual objective     =         45416.453096&#xA;Iteration: 16049   Dual objective     =         45373.452990&#xA;Iteration: 16504   Dual objective     =         45352.452976&#xA;Iteration: 18783   Dual objective     =         45174.452915&#xA;Iteration: 19302   Dual objective     =         45157.452894&#xA;Iteration: 21563   Dual objective     =         45003.952882&#xA;Iteration: 21999   Dual objective     =         45003.952855&#xA;Iteration: 24088   Dual objective     =         45002.952775&#xA;Iteration: 24511   Dual objective     =         45002.952757&#xA;Iteration: 26440   Dual objective     =         44996.952672&#xA;Iteration: 26883   Dual objective     =         44996.952651&#xA;Iteration: 28880   Dual objective     =         44951.952592&#xA;Iteration: 29350   Dual objective     =         44951.952565&#xA;Iteration: 31194   Dual objective     =         44951.952511&#xA;Iteration: 31614   Dual objective     =         44951.952500&#xA;Iteration: 33440   Dual objective     =         44951.952454&#xA;Iteration: 33816   Dual objective     =         44951.952445&#xA;Iteration: 35776   Dual objective     =         44939.952389&#xA;Iteration: 36188   Dual objective     =         44939.952378&#xA;Iteration: 37895   Dual objective     =         44934.952342&#xA;Iteration: 38258   Dual objective     =         44934.952334&#xA;Iteration: 39992   Dual objective     =         44934.952290&#xA;Iteration: 40415   Dual objective     =         44934.952276&#xA;Iteration: 42148   Dual objective     =         44934.952218&#xA;Iteration: 42596   Dual objective     =         44934.952207&#xA;Iteration: 44288   Dual objective     =         44934.952166&#xA;Iteration: 44696   Dual objective     =         44934.952157&#xA;Iteration: 46364   Dual objective     =         44934.952117&#xA;Elapsed time = 11.94 sec. (10072.72 ticks, 46750 iterations)&#xA;Iteration: 46750   Dual objective     =         44934.952109&#xA;Iteration: 48418   Dual objective     =         44934.952063&#xA;Iteration: 48800   Dual objective     =         44934.952053&#xA;Iteration: 50478   Dual objective     =         44933.952017&#xA;Iteration: 50855   Dual objective     =         44933.952008&#xA;Iteration: 52495   Dual objective     =         44932.951967&#xA;Iteration: 52871   Dual objective     =         44932.951939&#xA;Iteration: 54498   Dual objective     =         44932.951894&#xA;Iteration: 54891   Dual objective     =         44932.951884&#xA;Iteration: 56494   Dual objective     =         44932.951842&#xA;Iteration: 56893   Dual objective     =         44932.951832&#xA;Iteration: 58507   Dual objective     =         44932.951794&#xA;Iteration: 58930   Dual objective     =         44932.951785&#xA;Iteration: 60503   Dual objective     =         44932.951744&#xA;Iteration: 60947   Dual objective     =         44932.951727&#xA;Iteration: 62484   Dual objective     =         44932.951691&#xA;Iteration: 62893   Dual objective     =         44932.951681&#xA;Iteration: 64455   Dual objective     =         44932.951646&#xA;Iteration: 64803   Dual objective     =         44932.951638&#xA;Iteration: 66337   Dual objective     =         44932.951604&#xA;Iteration: 66764   Dual objective     =         44932.951595&#xA;Iteration: 68275   Dual objective     =         44931.951606&#xA;Iteration: 68681   Dual objective     =         44931.951596&#xA;Iteration: 70148   Dual objective     =         44931.951546&#xA;Iteration: 70503   Dual objective     =         44931.951537&#xA;Iteration: 71959   Dual objective     =         44931.951498&#xA;Iteration: 72367   Dual objective     =         44931.951489&#xA;Iteration: 73825   Dual objective     =         44930.951523&#xA;Iteration: 74213   Dual objective     =         44930.951515&#xA;Iteration: 75638   Dual objective     =         44930.951481&#xA;Iteration: 76028   Dual objective     =         44930.951472&#xA;Iteration: 77482   Dual objective     =         44928.951558&#xA;Iteration: 77830   Dual objective     =         44928.951550&#xA;Elapsed time = 29.53 sec. (20072.92 ticks, 78930 iterations)&#xA;Iteration: 79190   Dual objective     =         44923.951818&#xA;Iteration: 79546   Dual objective     =         44923.951776&#xA;Iteration: 80689   Dual objective     =         44923.951738&#xA;Iteration: 81117   Dual objective     =         44923.951686&#xA;Iteration: 82374   Dual objective     =         44923.451750&#xA;Iteration: 82908   Dual objective     =         44923.451737&#xA;Iteration: 83963   Dual objective     =         44923.451721&#xA;Iteration: 84621   Dual objective     =         44923.451714&#xA;Iteration: 85808   Dual objective     =         44923.451700&#xA;Iteration: 86535   Dual objective     =         44922.951750&#xA;Iteration: 87513   Dual objective     =         44922.951741&#xA;Iteration: 88444   Dual objective     =         44922.951734&#xA;Elapsed time = 49.14 sec. (30075.03 ticks, 89122 iterations)&#xA;Iteration: 89482   Dual objective     =         44922.951728&#xA;Iteration: 90388   Dual objective     =         44922.951724&#xA;Iteration: 91240   Dual objective     =         44922.951723&#xA;Iteration: 91955   Dual objective     =         44922.951677&#xA;Iteration: 92467   Dual objective     =         44922.951604&#xA;Iteration: 93907   Dual objective     =         44922.951510&#xA;Iteration: 94436   Dual objective     =         44922.951486&#xA;Iteration: 95844   Dual objective     =         44922.951456&#xA;Iteration: 96160   Dual objective     =         44921.951557&#xA;Iteration: 97240   Dual objective     =         44921.951508&#xA;Iteration: 97679   Dual objective     =         44921.951496&#xA;Iteration: 99022   Dual objective     =         44921.951449&#xA;Iteration: 99486   Dual objective     =         44921.951442&#xA;Iteration: 100587   Dual objective     =         44921.951422&#xA;Elapsed time = 78.04 sec. (40075.21 ticks, 101042 iterations)&#xA;Iteration: 101199   Dual objective     =         44921.951415&#xA;Iteration: 102215   Dual objective     =         44921.951405&#xA;Iteration: 103030   Dual objective     =         44921.951399&#xA;Iteration: 103844   Dual objective     =         44921.951396&#xA;Iteration: 104803   Dual objective     =         44921.951390&#xA;Elapsed time = 98.67 sec. (50077.16 ticks, 105500 iterations)&#xA;Iteration: 105553   Dual objective     =         44921.951389&#xA;Iteration: 106271   Dual objective     =         44921.951376&#xA;Iteration: 107425   Dual objective     =         44921.951361&#xA;Iteration: 108079   Dual objective     =         44921.951353&#xA;Iteration: 109143   Dual objective     =         44921.951339&#xA;Iteration: 109949   Dual objective     =         44921.951333&#xA;Iteration: 110720   Dual objective     =         44921.951327&#xA;Iteration: 111893   Dual objective     =         44921.951314&#xA;Elapsed time = 124.84 sec. (60077.82 ticks, 112539 iterations)&#xA;Iteration: 112866   Dual objective     =         44921.951309&#xA;Iteration: 113557   Dual objective     =         44921.951304&#xA;Iteration: 114346   Dual objective     =         44921.951302&#xA;Iteration: 115001   Dual objective     =         44921.951294&#xA;Iteration: 115927   Dual objective     =         44921.951284&#xA;Iteration: 116682   Dual objective     =         44921.951275&#xA;Elapsed time = 152.09 sec. (70078.53 ticks, 117075 iterations)&#xA;Iteration: 117666   Dual objective     =         44921.951263&#xA;Iteration: 118605   Dual objective     =         44921.951244&#xA;Iteration: 119619   Dual objective     =         44921.951234&#xA;Iteration: 120489   Dual objective     =         44921.951228&#xA;Iteration: 121253   Dual objective     =         44921.951222&#xA;Elapsed time = 175.56 sec. (80078.92 ticks, 121646 iterations)&#xA;Iteration: 121909   Dual objective     =         44921.951218&#xA;Iteration: 122949   Dual objective     =         44921.951208&#xA;Iteration: 123999   Dual objective     =         44921.951196&#xA;Iteration: 125006   Dual objective     =         44921.951184&#xA;Iteration: 125730   Dual objective     =         44921.951180&#xA;Iteration: 126557   Dual objective     =         44921.951169&#xA;Elapsed time = 201.92 sec. (90079.88 ticks, 126803 iterations)&#xA;Iteration: 127660   Dual objective     =         44921.951159&#xA;Iteration: 128702   Dual objective     =         44921.951151&#xA;Iteration: 129649   Dual objective     =         44921.951136&#xA;Iteration: 130473   Dual objective     =         44921.951131&#xA;Iteration: 131335   Dual objective     =         44921.951122&#xA;Elapsed time = 224.98 sec. (100080.62 ticks, 131595 iterations)&#xA;Iteration: 132398   Dual objective     =         44921.951110&#xA;Iteration: 133270   Dual objective     =         44921.951100&#xA;Iteration: 134153   Dual objective     =         44921.951089&#xA;Iteration: 135137   Dual objective     =         44921.951086&#xA;Elapsed time = 247.17 sec. (110082.18 ticks, 135427 iterations)&#xA;Iteration: 136050   Dual objective     =         44921.951084&#xA;Iteration: 136841   Dual objective     =         44921.951078&#xA;Iteration: 137798   Dual objective     =         44921.951069&#xA;Iteration: 138701   Dual objective     =         44921.951064&#xA;Iteration: 139608   Dual objective     =         44921.951053&#xA;Elapsed time = 275.51 sec. (120082.63 ticks, 139834 iterations)&#xA;Iteration: 140291   Dual objective     =         44921.951048&#xA;Iteration: 141246   Dual objective     =         44921.951042&#xA;Iteration: 142083   Dual objective     =         44921.951023&#xA;Iteration: 143085   Dual objective     =         44921.951015&#xA;Elapsed time = 299.14 sec. (130086.30 ticks, 143505 iterations)&#xA;Iteration: 143914   Dual objective     =         44921.951013&#xA;Iteration: 144608   Dual objective     =         44921.951002&#xA;Iteration: 145777   Dual objective     =         44921.950974&#xA;Elapsed time = 319.66 sec. (140089.17 ticks, 146556 iterations)&#xA;Iteration: 146663   Dual objective     =         44921.950966&#xA;Iteration: 147499   Dual objective     =         44921.950957&#xA;Iteration: 148424   Dual objective     =         44921.950944&#xA;Iteration: 149273   Dual objective     =         44921.950936&#xA;Elapsed time = 342.05 sec. (150092.52 ticks, 149796 iterations)&#xA;Iteration: 150182   Dual objective     =         44921.950925&#xA;Iteration: 151207   Dual objective     =         44921.950910&#xA;Iteration: 152107   Dual objective     =         44921.950892&#xA;Iteration: 153006   Dual objective     =         44921.950875&#xA;Iteration: 154175   Dual objective     =         44921.950865&#xA;Elapsed time = 366.08 sec. (160094.15 ticks, 154489 iterations)&#xA;Iteration: 155283   Dual objective     =         44921.950847&#xA;Iteration: 156355   Dual objective     =         44921.950835&#xA;Iteration: 157760   Dual objective     =         44921.950814&#xA;Iteration: 158940   Dual objective     =         44921.950798&#xA;Elapsed time = 390.36 sec. (170095.40 ticks, 159574 iterations)&#xA;Iteration: 160390   Dual objective     =         44921.950783&#xA;Removing perturbation.&#xA;&#xA;Dual simplex solved model.&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10518" LastActivityDate="2022-10-11T17:00:05.067" Title="CPLEX stuck in solve method - dual simplex solved model" Tags="|mixed-integer-programming|cplex|solver|java|dual|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9110" PostTypeId="1" AcceptedAnswerId="9113" CreationDate="2022-10-11T12:22:42.990" Score="3" ViewCount="438" Body="&lt;p&gt;I am solving my first model in CPLEX 22.1. I have setup a quadratic MIP with 100 variables and the model has been running for a day already with the best integer and best bound solutions barely changing over long periods of time. Can I pause the solver and inspect the current best solution (i.e. the vector which gives the currently best objective)?&lt;/p&gt;&#xA;&lt;p&gt;I am also looking to apply heuristics and read in the guide that I need to modify the &amp;quot;MIP emphasis&amp;quot; parameter. Is there a way of doing this in the GUI? All I can find is &amp;quot;Effort level of heuristics&amp;quot; in the settings menus.&lt;/p&gt;&#xA;&lt;p&gt;Select lines of log file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; 792048744 673300881    -6301.3749    44    -6445.0357    -5107.4712 1.25e+09   20.75%&#xA; 793176911 674258778    -5809.5478    40    -6445.0357    -5107.4712 1.26e+09   20.75%&#xA; 794483516 675327730    -6200.1004    39    -6445.0357    -5107.4712 1.26e+09   20.75%&#xA; 795699033 676334114    -5866.9399    44    -6445.0357    -5107.4712 1.26e+09   20.75%&#xA; 796881017 677353115    -6046.6600    29    -6445.0357    -5107.4712 1.26e+09   20.75%&#xA; 798100378 678340092    -5791.3480    40    -6445.0357    -5107.4712 1.26e+09   20.75%&#xA; 799266501 679307405    -6375.3359    19    -6445.0357    -5107.4712 1.27e+09   20.75%&#xA; 800420755 680306754    -6069.4608    38    -6445.0357    -5107.4712 1.27e+09   20.75%&#xA; 801596874 681269721    -6139.7369    48    -6445.0357    -5107.4712 1.27e+09   20.75%&#xA; 802801954 682318405    -6178.6201    38    -6445.0357    -5107.4712 1.27e+09   20.75%&#xA;Elapsed time = 88392.21 sec. (10809704.28 ticks, tree = 107998.33 MB, solutions = 18)&#xA;Nodefile size = 105949.75 MB (60962.62 MB after compression)&#xA; 804132565 683432372    -6403.1240    36    -6445.0357    -5107.4712 1.27e+09   20.75%&#xA; 805516854 684546042    -6351.3038    19    -6445.0357    -5107.4712 1.27e+09   20.75%&#xA; 806906424 685751197    -6284.1826    34    -6445.0357    -5107.4712 1.28e+09   20.75%&#xA; 808030807 686676273    -5887.6066    32    -6445.0357    -5107.4712 1.28e+09   20.75%&#xA; 809085620 687532713    -6363.9349    39    -6445.0357    -5107.4712 1.28e+09   20.75%&#xA; 810261526 688511803    -6379.0674    27    -6445.0357    -5107.4712 1.28e+09   20.75%&#xA; 811582033 689657380    -5846.0319    46    -6445.0357    -5107.4712 1.28e+09   20.75%&#xA; 812908853 690734080        cutoff          -6445.0357    -5107.4712 1.29e+09   20.75%&#xA; 814150976 691725836    -5972.4972    48    -6445.0357    -5107.4712 1.29e+09   20.75%&#xA; 815305277 692747078    -6420.1132    36    -6445.0357    -5107.4712 1.29e+09   20.75%&#xA;Elapsed time = 89865.24 sec. (10962292.30 ticks, tree = 109639.60 MB, solutions = 18)&#xA;Nodefile size = 107591.62 MB (61918.08 MB after compression)&#xA; 816563579 693798990        cutoff          -6445.0357    -5107.4712 1.29e+09   20.75%&#xA; 817767032 694779345    -5895.8407    46    -6445.0357    -5107.4712 1.29e+09   20.75%&#xA; 818848532 695715558    -6344.1731    41    -6445.0357    -5107.4712 1.30e+09   20.75%&#xA; 819939414 696617487    -6167.8911    31    -6445.0357    -5107.4712 1.30e+09   20.75%&#xA; 821120160 697570971    -6134.0994    40    -6445.0357    -5107.4712 1.30e+09   20.75%&#xA; 822226031 698509095    -5664.0570    53    -6445.0357    -5107.4712 1.30e+09   20.75%&#xA; 823365192 699460730    -5863.1686    46    -6445.0357    -5107.4712 1.30e+09   20.75%&#xA; 824396734 700363247    -6051.7562    41    -6445.0357    -5107.4712 1.30e+09   20.75%&#xA; 825483340 701249449    -5883.8240    41    -6445.0357    -5107.4712 1.31e+09   20.75%&#xA; 826595881 702168454    -6258.2970    37    -6445.0357    -5107.4712 1.31e+09   20.75%&#xA;Elapsed time = 91239.09 sec. (11114880.47 ticks, tree = 111122.80 MB, solutions = 18)&#xA;Nodefile size = 109073.51 MB (62783.13 MB after compression)&#xA; 827829998 703194454    -5935.0349    33    -6445.0357    -5107.4712 1.31e+09   20.75%&#xA; 828977361 704158153    -6020.6346    49    -6445.0357    -5107.4712 1.31e+09   20.75%&#xA; 830088428 705093199    -6147.7426    48    -6445.0357    -5107.4712 1.31e+09   20.75%&#xA; 831139007 706006645    -5822.0882    40    -6445.0357    -5107.4712 1.32e+09   20.75%&#xA; 832274394 706907577    -5950.6839    50    -6445.0357    -5107.4712 1.32e+09   20.75%&#xA; 833345602 707785250    -6263.2685    34    -6445.0357    -5107.4712 1.32e+09   20.75%&#xA; 834504877 708778888    -6330.0896    43    -6445.0357    -5107.4712 1.32e+09   20.75%&#xA; 835431354 709547316    -5811.8426    52    -6445.0357    -5107.4712 1.32e+09   20.75%&#xA; 836393855 710382419    -6215.7973    39    -6445.0357    -5107.4712 1.32e+09   20.75%&#xA; 837398864 711222106    -5947.9031    53    -6445.0357    -5107.4712 1.32e+09   20.75%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10519" LastEditorUserId="491" LastEditDate="2022-10-12T12:10:26.050" LastActivityDate="2022-10-12T12:10:26.050" Title="How to view pause and view current solution in CPLEX Optimization Studio?" Tags="|mixed-integer-programming|cplex|solver|quadratic-programming|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9111" PostTypeId="2" ParentId="9109" CreationDate="2022-10-11T14:54:10.163" Score="2" Body="&lt;p&gt;You are solving a MIP not just an LP. Dual simplex solves the LP relaxation of the MIP. After that, the branch and cut process starts. That will usually take even more time than solving the root node/LP relaxation.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2022-10-11T17:00:05.067" LastActivityDate="2022-10-11T17:00:05.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9112" PostTypeId="2" ParentId="9110" CreationDate="2022-10-11T15:42:53.497" Score="2" Body="&lt;p&gt;I don't think you can pause the current run. If you stop the run, inspect the solution and then instruct the solver to solve again, without changing anything in the model, it should resume where it left off (assuming warm starts are turned on, which they are by default). This works when using one of the programming APIs (C++, Java etc.), but I have not tried it from the Studio IDE, so I would recommend testing it before using it in a production run.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-11T15:42:53.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9113" PostTypeId="2" ParentId="9110" CreationDate="2022-10-11T16:33:43.950" Score="4" Body="&lt;p&gt;See &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=toolbars-execution-toolbar&quot; rel=&quot;nofollow noreferrer&quot;&gt;execution toolbar&lt;/a&gt; in the CPLEX IDE&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QTudp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QTudp.png&quot; alt=&quot;execution toolbar&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Pause / Resume will help and you can also use breakpoints with the debugger that you can use for the scripting part within OPL&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-10-11T16:33:43.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9114" PostTypeId="1" CreationDate="2022-10-11T21:25:46.773" Score="3" ViewCount="70" Body="&lt;p&gt;I am currently attempting to use a MIP to optimize the agglomeration of sites to fit a minimum size.&lt;/p&gt;&#xA;&lt;p&gt;Take for example the following simplified situation of 9 sites which could be any range of sizes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EBGSZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EBGSZ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I need a constraint to ensure that the grouped sites work based on their connections. For example {1,2,3}, {1,2,7,8}, {1,2,8,9} all work but {1,6,3} does not because 3 is not connected to either 1 or 6 and {1,2,4,5} wouldn't work because although each site has one connection, they are not connected to each other.&lt;/p&gt;&#xA;&lt;p&gt;If we let: &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$G_{ki}$&lt;/span&gt; = 1 if site i is in Group k and 0 if not. &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt; = 1 if site i and j are connected and 0 if not.&lt;br /&gt;&#xA;n = number of sites (9 in this example).&lt;/p&gt;&#xA;&lt;p&gt;Would it be possible to write a mathematical (ideally linear) constraint to define whether a group is valid?&lt;/p&gt;&#xA;&lt;p&gt;At a base level this leads to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$G_{ki} * G_{kj} &amp;lt;= a_{ij}$&lt;/span&gt; which says sites i and j can only be in the same group if they are connected. But this would invalidate groups like {1,2,3} as 1 and 3 are not connected.&lt;/p&gt;&#xA;&lt;p&gt;I then tried:&#xA;&lt;span class=&quot;math-container&quot;&gt;$G_{ki} * G_{kj} &amp;lt;= a_{ij} + \sum_{L=1}^n (a_{iL} * G_{kL} * a_{Lj}) $&lt;/span&gt;&#xA;This works for situations like {1,2,3} as :&#xA;&lt;span class=&quot;math-container&quot;&gt;$G_{k1} * G_{k3} &amp;lt;=a_{13} + a_{12} * G_{k2} * a_{23}$&lt;/span&gt; &lt;br /&gt;&#xA;but not {1,2,3,4} for 1 and 4.&lt;/p&gt;&#xA;&lt;p&gt;While I could expand that formulation to 4 or even 5, I am hoping there is a better approach that allows for any number of sites to be in a single group.&lt;/p&gt;&#xA;&lt;p&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; gets as high as 110 sites for the actual problem I am trying to solve.&lt;/p&gt;&#xA;" OwnerUserId="10516" LastEditorUserId="491" LastEditDate="2022-10-12T12:12:25.070" LastActivityDate="2022-10-12T15:52:17.127" Title="How to write a constraint to define valid agglomerations of sites?" Tags="|constraint|graphs|clustering|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9116" PostTypeId="1" CreationDate="2022-10-12T09:14:31.507" Score="0" ViewCount="70" Body="&lt;p&gt;I am working on two graphs having nodes and edges.&#xA;Graph1: VNF Graph with node demand and bandwidth demand.&#xA;Graph2: Server Graph with node capacity and bandwidth capacity.&lt;/p&gt;&#xA;&lt;p&gt;The nodes and links of graph1 can be optimally mapped on graph 2 when the demanded resources ≤ capacity. I have written and executed that successfully.&lt;/p&gt;&#xA;&lt;p&gt;Right now, I am trying to write the following constraint.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fKqZW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fKqZW.png&quot; alt=&quot;this constraint&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here&lt;/p&gt;&#xA;&lt;p&gt;uv∈O(u)     = outgoing links of any node (u) in the SERVER graph&lt;/p&gt;&#xA;&lt;p&gt;Φf          = Decision Variable referring to mapping of nodes and links&lt;/p&gt;&#xA;&lt;p&gt;uv BAR      = link in VNF graph&lt;/p&gt;&#xA;&lt;p&gt;uv∈I(u)     = incoming links of any node (u) in the SERVER graph&lt;/p&gt;&#xA;&lt;p&gt;uBAR,vBAR   = any node in VNF graph&lt;/p&gt;&#xA;&lt;p&gt;u           = node in SERVER graph&lt;/p&gt;&#xA;&lt;p&gt;My minimal code to do so is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Graph Reading&#xA;def SERVER_graph():  # SERVER Graph with few nodes&#xA;    SERVER = nx.DiGraph()&#xA;    SERVER.add_nodes_from([(&amp;quot;S1&amp;quot;, {&amp;quot;C_CPU&amp;quot;: 10}),&#xA;                           (&amp;quot;S2&amp;quot;, {&amp;quot;C_CPU&amp;quot;: 20}),&#xA;                           (&amp;quot;S3&amp;quot;, {&amp;quot;C_CPU&amp;quot;: 30})])&#xA;    SERVER.add_edge(&amp;quot;S1&amp;quot;, &amp;quot;S2&amp;quot;, bw_capacity=50)&#xA;    SERVER.add_edge(&amp;quot;S2&amp;quot;, &amp;quot;S1&amp;quot;, bw_capacity=50)&#xA;    SERVER.add_edge(&amp;quot;S2&amp;quot;, &amp;quot;S3&amp;quot;, bw_capacity=70)&#xA;    SERVER.add_edge(&amp;quot;S3&amp;quot;, &amp;quot;S2&amp;quot;, bw_capacity=70)&#xA;    SERVER.add_edge(&amp;quot;S3&amp;quot;, &amp;quot;S1&amp;quot;, bw_capacity=60)&#xA;    SERVER.add_edge(&amp;quot;S1&amp;quot;, &amp;quot;S3&amp;quot;, bw_capacity=60)&#xA;    return SERVER&#xA;SERVER_graph()&#xA;def VNF_graph():  # VNF Graph with few nodes and links&#xA;    VNF = nx.DiGraph()&#xA;    VNF.add_nodes_from([(&amp;quot;VNF1&amp;quot;, {&amp;quot;D_CPU&amp;quot;: 10}),&#xA;                        (&amp;quot;VNF2&amp;quot;, {&amp;quot;D_CPU&amp;quot;: 5}),&#xA;                        (&amp;quot;VNF3&amp;quot;, {&amp;quot;D_CPU&amp;quot;: 10}),&#xA;                        (&amp;quot;VNF4&amp;quot;, {&amp;quot;D_CPU&amp;quot;: 5}),&#xA;                        (&amp;quot;VNF5&amp;quot;, {&amp;quot;D_CPU&amp;quot;: 5})])&#xA;&#xA;    VNF.add_edge(&amp;quot;VNF1&amp;quot;, &amp;quot;VNF2&amp;quot;, bw_demand=20)&#xA;    VNF.add_edge(&amp;quot;VNF2&amp;quot;, &amp;quot;VNF3&amp;quot;, bw_demand=20)&#xA;    VNF.add_edge(&amp;quot;VNF3&amp;quot;, &amp;quot;VNF4&amp;quot;, bw_demand=10)&#xA;    VNF.add_edge(&amp;quot;VNF5&amp;quot;, &amp;quot;VNF4&amp;quot;, bw_demand=5)&#xA;    VNF.add_edge(&amp;quot;VNF1&amp;quot;, &amp;quot;VNF3&amp;quot;, bw_demand=30)&#xA;    VNF.add_edge(&amp;quot;VNF2&amp;quot;, &amp;quot;VNF5&amp;quot;, bw_demand=40)&#xA;    return VNF&#xA;VNF_graph()&#xA;enter code here&#xA;def mymodel():&#xA;model = ConcreteModel() # Model Creation&#xA;&#xA;my_VNF_graph=VNF_graph()&#xA;my_SERVER_graph=SERVER_graph()&#xA;&#xA;D_CPU = []  # List for extracting the CPU and BW demands from VNFs&#xA;for Dcpunode in my_VNF_graph.nodes:&#xA;    D_CPU.append(my_VNF_graph.nodes[Dcpunode][&amp;quot;D_CPU&amp;quot;])&#xA;D_BW = []&#xA;for Dbwlink in my_VNF_graph.edges:&#xA;    D_BW.append(my_VNF_graph.edges[Dbwlink][&amp;quot;bw_demand&amp;quot;])&#xA;&#xA;C_CPU = []  # List for extracting the CPU and BW capacity from SERVER&#xA;for Ccpunode in my_SERVER_graph.nodes:&#xA;    C_CPU.append(my_SERVER_graph.nodes[Ccpunode][&amp;quot;C_CPU&amp;quot;])&#xA;C_BW = []&#xA;for Cbwlink in my_SERVER_graph.edges:&#xA;    C_BW.append(my_SERVER_graph.edges[Cbwlink][&amp;quot;bw_capacity&amp;quot;])&#xA;&#xA;model.demand_CPU_set = RangeSet(0, len(D_CPU)-1) # define the set of parameters&#xA;model.demand_BW_set = RangeSet(0, len(D_BW)-1)&#xA;model.capacity_CPU_set = RangeSet(0, len(C_CPU)-1)&#xA;model.capacity_BW_set = RangeSet(0, len(C_BW)-1)&#xA;&#xA;#model decision variables using the set definitions&#xA;model.fi=Var(model.demand_CPU_set, model.capacity_CPU_set, within=Binary) #for node&#xA;model.fil=Var(model.demand_BW_set, model.capacity_BW_set, within=Binary) #for link&#xA;&#xA;#Structural constraint for link mapping&#xA;out_edge_list=list(my_SERVER_graph.out_edges)&#xA;in_edge_list = list(my_SERVER_graph.in_edges)&#xA;&#xA;model.out_link_set=Set(initialize=(out_edge_list[i] for i in range(len(out_edge_list))), dimen=2)&#xA;model.in_link_set=Set(initialize=(in_edge_list[i] for i in range(len(in_edge_list))), dimen=2)&#xA;&#xA;def structural_rule1 (model, u, uvb):&#xA;    return sum(model.fil[uvb, uv] for uv in model.out_link_set)- sum(model.fil[uvb, vu] for vu in model.in_link_set )==model.fi[ub, u]-model.fi[vb, u]&#xA;model.structural_constraint1=Constraint(model.capacity_CPU_set, model.demand_BW_set, rule=structural_rule1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10356" LastActivityDate="2022-10-12T09:14:31.507" Title="Looking for correction in pyomo constraint" Tags="|optimization|linear-programming|constraint|pyomo|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9118" PostTypeId="2" ParentId="9114" CreationDate="2022-10-12T15:39:16.353" Score="2" Body="&lt;p&gt;I don't think there is any way to get a single constraint for each group establishing contiguity.&lt;/p&gt;&#xA;&lt;p&gt;Assume that we represent the sites as nodes in a graph, with edges between adjacent sites. The link provided by @RobPratt in a comment contains methods for constraining contiguity using flow variables. The catch in this case is that the number of flow variables will be on the order of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; times the number of edges in the graph (which is &lt;span class=&quot;math-container&quot;&gt;$O(n^2)$&lt;/span&gt;), so your model could get rather big rather fast.&lt;/p&gt;&#xA;&lt;p&gt;Another approach would be to enumerate all possible contiguous groups of sites and use binary variables to select which groups are used (subject to nonoverlap constraints and whatever else is going on in your problem). Enumerating the contiguous groups is logically straightforward if possibly somewhat tedious, but it again will likely jack up the size of the model.&lt;/p&gt;&#xA;&lt;p&gt;That leads to a couple of additional alternatives, both of which involve identifying &lt;em&gt;some&lt;/em&gt; but hopefully not all of the contiguous groups. An exact approach uses the &amp;quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Branch_and_price&quot; rel=&quot;nofollow noreferrer&quot;&gt;branch price and cut&lt;/a&gt;&amp;quot; approach. A heuristic version works along the lines of the Gilmore-Gomory heuristic for the 1-D &lt;a href=&quot;https://en.wikipedia.org/wiki/Cutting_stock_problem#Mathematical_formulation_and_solution_approaches&quot; rel=&quot;nofollow noreferrer&quot;&gt;cutting stock problem&lt;/a&gt;. Basically, you start with an arbitrary set of contiguous groups, solve the LP relaxation of the problem, and use the dual solution to solve a subproblem that finds one or more new groups that are contiguous and look like they would improve the solution of the master problem. Add them in and repeat until no new groups are found, then reinstate the integrality restrictions and solve the resulting MIP.&lt;/p&gt;&#xA;&lt;p&gt;I'll mention one other approach for completeness, but I definitely do not recommend it. You can try a version of &amp;quot;logical Benders decomposition&amp;quot;, in which you add contiguity constraints on the fly as you solve a master MIP problem. When the solver has a candidate solution, it passes the solution to an &amp;quot;oracle&amp;quot; that checks whether each proposed group is contiguous and, if not, sends back one or more constraints to be added to the master problem. The catch is that these will be what are known as &amp;quot;no good&amp;quot; constraints, which are notoriously weak and likely to pile up in large numbers. Using your example, if the proposed solution said that group 1 will consist of sites 6, 7 and 8, a no-good constraint would look like &lt;span class=&quot;math-container&quot;&gt;$$G_{16} + G_{17} + G_{18} - \sum_{i\in \lbrace 1,\dots,5,9\rbrace} G_{1i} \le 2,$$&lt;/span&gt; which invalidates that solution but not much else. You could improve the no-good constraints with a bit of work (for instance, by dropping &lt;span class=&quot;math-container&quot;&gt;$G_{19}$&lt;/span&gt; in this example since site 9 is not contiguous to either of sites 6 or 7), but I still think the (weak) constraints would pile up awfully quickly.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-10-12T15:52:17.127" LastActivityDate="2022-10-12T15:52:17.127" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9119" PostTypeId="1" CreationDate="2022-10-12T20:20:16.930" Score="3" ViewCount="176" Body="&lt;p&gt;I am also looking to solve a MIP with heuristic algorithms and read in the guide that I need to modify the &amp;quot;MIP emphasis&amp;quot; parameter. Is there a way of doing this in the CPLEX IDE? All I can find is &amp;quot;Effort level of heuristics&amp;quot; in the settings menus. Or do I need to move to python/C++ to modify this setting?&lt;/p&gt;&#xA;" OwnerUserId="10519" LastActivityDate="2022-10-12T20:33:21.477" Title="Where to find &quot;MIP Emphasis&quot; parameter in the CPLEX IDE?" Tags="|mixed-integer-programming|cplex|solver|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9120" PostTypeId="2" ParentId="9119" CreationDate="2022-10-12T20:33:21.477" Score="5" Body="&lt;p&gt;You can do that in scripting:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;execute&#xA;{&#xA;  cplex.mipemphasis=3;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or in the IDE&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IBYj8.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IBYj8.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-10-12T20:33:21.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9121" PostTypeId="1" AcceptedAnswerId="9150" CreationDate="2022-10-13T03:42:40.697" Score="1" ViewCount="60" Body="&lt;p&gt;Tree search over a state space often assumes that the state can be represented compactly and repeated in each node of the search tree.&lt;/p&gt;&#xA;&lt;p&gt;Suppose I have a large simulation with 100000's of entities each with a rich complex state. If performing a tree search over the full simulation state space, where each action affects a small number of entity, it will be inefficient to replicate the full simulation state in each node of the tree. However, the simulation constraints are tightly coupled and factoring the simulation into smaller sub-simulations is not possible.&lt;/p&gt;&#xA;&lt;p&gt;What methods exist for performing tree search over a problem space where the state representation is huge and complex?&lt;/p&gt;&#xA;" OwnerUserId="1071" LastActivityDate="2022-10-19T12:58:04.663" Title="What methods exist for tree search over a large complex state representation?" Tags="|simulation|local-search|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9122" PostTypeId="1" AcceptedAnswerId="9124" CreationDate="2022-10-13T14:07:42.653" Score="2" ViewCount="122" Body="&lt;p&gt;I have the following inequality that I would want to linearize.&#xA;Consider that &lt;span class=&quot;math-container&quot;&gt;$r_{ij}, x_{ij}, y_{ij}$&lt;/span&gt; are binary variables defined for every pair of nodes &lt;span class=&quot;math-container&quot;&gt;$(i,j) \in A$&lt;/span&gt;. Also, I have a set of nodes &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; which its used later.&lt;/p&gt;&#xA;&lt;p&gt;The following constraint holds:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$r_{ij} \leq \sum_{k \ne i, k \ne j}x_{ik}y_{jk}\qquad \forall (i,j) \in A$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;At first I thought that I should introduce a new family of 3-index binary variables &lt;span class=&quot;math-container&quot;&gt;$l^k_{ij}$&lt;/span&gt; and define:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$l^k_{ij} \leq x_{ik}\qquad \forall (i,j) \in A, k\in V: i \ne k, j\ne k\\l^k_{ij}\leq y_{jk}\qquad \forall (i,j) \in A,k \in V:i\ne k, j\ne k\\&#xA;l^k_{ij} \geq x_{ik}+y_{jk}-1 \qquad \forall (i,j) \in A,k \in V:i\ne k, j\ne k$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My ultimate goal is to be able to come up with a linearization that maintains the original number of indexes (although so far i haven't been able to do so and I think it may not be possible).&lt;/p&gt;&#xA;&lt;p&gt;I've read this survey &lt;a href=&quot;https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;ved=2ahUKEwjao4j2rd36AhUPkBoKHQmoAQ8QFnoECA4QAQ&amp;amp;url=https%3A%2F%2Fwww.mdpi.com%2F2227-7390%2F10%2F2%2F283%2Fpdf&amp;amp;usg=AOvVaw107PvP8w5WrEVzUeE-Yytx&quot; rel=&quot;nofollow noreferrer&quot;&gt;Transformation and Linearization Techniques in Optimization:&#xA;A State-of-the-Art Survey&lt;/a&gt; and was wondering if there are any others papers like it that I could check as inspiration.&lt;/p&gt;&#xA;" OwnerUserId="10439" LastEditorUserId="491" LastEditDate="2022-10-14T11:43:41.027" LastActivityDate="2022-10-14T11:43:41.027" Title="Linearize a product of binary variables with 2 indexes" Tags="|integer-programming|linearization|binary-variable|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9123" PostTypeId="1" AcceptedAnswerId="9126" CreationDate="2022-10-13T14:31:32.143" Score="2" ViewCount="97" Body="&lt;p&gt;Since all supported efficient solutions in a multi-objective optimization problem are actually the optimal solutions for some weighted sum scalarization single-objective optimization problem with the positive multiplier &lt;span class=&quot;math-container&quot;&gt;$\sum_k \lambda_k = 1$&lt;/span&gt;. Does the above theorem proposed by Geoffrion implies that other non-supported efficient solutions can also be the optimal solutions for some parameterized single-objective problem but with a multiplier &lt;span class=&quot;math-container&quot;&gt;$\sum_k \lambda_k \neq 1$&lt;/span&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="5681" LastActivityDate="2022-10-14T07:28:31.350" Title="Could non-supported efficient solutions in multi-objective optimization problem be an optimal solution of a parameterized single-objective problem?" Tags="|integer-programming|multi-objective-optimization|" AnswerCount="1" CommentCount="0" FavoriteCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9124" PostTypeId="2" ParentId="9122" CreationDate="2022-10-13T14:59:29.337" Score="2" Body="&lt;p&gt;With your &lt;span class=&quot;math-container&quot;&gt;$\ell_{ij}^k$&lt;/span&gt; variables, a linearization is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\ell_{ij}^k &amp;amp;\le x_{ik} \\&#xA;\ell_{ij}^k &amp;amp;\le y_{jk} \\&#xA;r_{ij} &amp;amp;\le \sum_k \ell_{ij}^k &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Without introducing new variables, an alternative formulation arises from rewriting the implication &lt;span class=&quot;math-container&quot;&gt;$$r_{ij} \implies \bigvee_k (x_{ik} \land y_{jk}) $$&lt;/span&gt; in conjunctive normal form, but doing this yields exponentially many constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$r_{ij} \le \sum_k *_k,$$&lt;/span&gt;&#xA;where each &lt;span class=&quot;math-container&quot;&gt;$*_k$&lt;/span&gt; is either &lt;span class=&quot;math-container&quot;&gt;$x_{ik}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$y_{jk}$&lt;/span&gt;.&#xA;Explicitly, for &lt;span class=&quot;math-container&quot;&gt;$|V|=3$&lt;/span&gt;, there are &lt;span class=&quot;math-container&quot;&gt;$2^3$&lt;/span&gt; constraints for each &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;r_{ij} &amp;amp;\le x_{i,1} + x_{i,2} + x_{i,3} \\&#xA;r_{ij} &amp;amp;\le x_{i,1} + x_{i,2} + y_{j,3} \\&#xA;r_{ij} &amp;amp;\le x_{i,1} + y_{j,2} + x_{i,3} \\&#xA;r_{ij} &amp;amp;\le x_{i,1} + y_{j,2} + y_{j,3} \\&#xA;r_{ij} &amp;amp;\le y_{j,1} + x_{i,2} + x_{i,3} \\&#xA;r_{ij} &amp;amp;\le y_{j,1} + x_{i,2} + y_{j,3} \\&#xA;r_{ij} &amp;amp;\le y_{j,1} + y_{j,2} + x_{i,3} \\&#xA;r_{ij} &amp;amp;\le y_{j,1} + y_{j,2} + y_{j,3}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-10-13T16:11:57.927" LastActivityDate="2022-10-13T16:11:57.927" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9125" PostTypeId="1" AcceptedAnswerId="9127" CreationDate="2022-10-13T15:26:39.037" Score="8" ViewCount="585" Body="&lt;p&gt;Reduced cost fixing is a technique used by mixed integer programming (MIP) solvers to safely fix variables to certain values. While this technique is well-known among the MIP community, I don't know of any standard/definitive references on it. For example, I cannot find it mentioned in the usual textbooks (Nemhauser and Wolsey; Conforti, Cornuéjols, and Zambelli; R Kipp Martin; etc), although it &lt;em&gt;is&lt;/em&gt; mentioned in Wolsey's book but only as an exercise. It is often mentioned in research articles, but usually only in passing.&lt;/p&gt;&#xA;&lt;p&gt;Are there any &lt;strong&gt;textbooks or surveys&lt;/strong&gt; that cover (LP-based) reduced cost fixing, preferably with examples? I am looking for something that could be shared with students who are unfamiliar with the idea.&lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="500" LastEditDate="2022-10-13T17:23:37.560" LastActivityDate="2022-10-14T13:06:45.023" Title="Good references for reduced cost fixing?" Tags="|mixed-integer-programming|reference-request|reduced-costs|presolve-preprocessing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9126" PostTypeId="2" ParentId="9123" CreationDate="2022-10-13T17:08:32.773" Score="3" Body="&lt;p&gt;No. If you have strictly positive weights you will get a supported efficient solution by solving the weighted sum scalarization, regardless of whether the weights sum to one or not. Requiring the weights to sum to 1 is the same as multiplying the objective by a constant, which does not change the set of optimal solutions.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Edit: if you allow your weights to be both positive and negative, all sorts of things may happen. If your problem is a pure binary problem, &lt;em&gt;all&lt;/em&gt; feasible solutions are extreme points of the convex hull of feasible solutions. Hence, you may be able to construct weighted sum scalarizations of the objectives with some negative weights, that leads to non-supported efficient solutions.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2022-10-14T07:28:31.350" LastActivityDate="2022-10-14T07:28:31.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9127" PostTypeId="2" ParentId="9125" CreationDate="2022-10-14T08:32:23.927" Score="9" Body="&lt;p&gt;Unfortunately, I can't provide you with a perfect reference or a textbook including examples but I can point you to a trail of papers/surveys pointing out the origin of reduced cost fixing.&lt;/p&gt;&#xA;&lt;p&gt;One survey paper about presolve for MILPs that also includes some examples (but not one for reduced cost fixing) is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/BF01299207&quot; rel=&quot;noreferrer&quot;&gt;Suhl and Szymanski: Supdernode Processing of Mixed-Integer Models (1994)&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;They start the section on &amp;quot;reduced costs(!) fixing&amp;quot; with &amp;quot;It is long known that...&amp;quot;. This is potentially a good reference because they also call it by the name we use today (with an extra &amp;quot;s&amp;quot; that can be overlooked). They give another nice presolve paper as reference:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.jstor.org/stable/170888#metadata_info_tab_contents&quot; rel=&quot;noreferrer&quot;&gt;Crowder, Johnson, Padberg: Solving Large-Scale Zero-One Linear Programming Problems (1982)&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;They call it &amp;quot;Continuous Reduced Cost Implications&amp;quot;. That paper does not give a reference (but has an interesting note about them having to restart after fixings for implementation reasons, which solvers do nowadays because it turns out to be actually good sometimes).&lt;/p&gt;&#xA;&lt;p&gt;As far as I know and based on this paper&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S1572528607000412&quot; rel=&quot;noreferrer&quot;&gt;Grötschel and Nemhauser: George Dantzig’s contributions to integer programming (2008)&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I think it's save to say that the origin of reduced cost fixing (and many other basic techniques to solve MIPs) is the famous 49-city TSP paper:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/opre.2.4.393&quot; rel=&quot;noreferrer&quot;&gt;Dantzig, Fulkerson, Johnson: Solution of a Large-Scale Traveling-Salesman Problem (1954)&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The notation in that paper is a bit cryptic for us these days so I would not recommend it as a reference on that topic. But explaining reduced cost fixing on the example of the TSP is probably a good idea.&lt;/p&gt;&#xA;" OwnerUserId="302" LastEditorUserId="302" LastEditDate="2022-10-14T13:06:45.023" LastActivityDate="2022-10-14T13:06:45.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9128" PostTypeId="1" CreationDate="2022-10-14T15:28:05.903" Score="2" ViewCount="337" Body="&lt;p&gt;&lt;strong&gt;Question1:&lt;/strong&gt; Northam Airlines is trying to decide how to partition a new plane for its Chicago–&#xA;Detroit route. The plane can seat &lt;span class=&quot;math-container&quot;&gt;$200$&lt;/span&gt; economy class, passengers. A section can be partitioned off for first-class seats, but each of these seats takes the space of &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; economy class seats. A business class section can also be included, but each of these seats takes as much space as &lt;span class=&quot;math-container&quot;&gt;$1.5$&lt;/span&gt; economy class seats. The profit on a first-class ticket is, however, three times the profit of an economy ticket. A business class ticket has a profit of two times an economy ticket’s profit. Once the plane is partitioned into these seating classes, it cannot be changed. Northam knows, however, that the plane will not always be full in each section. They have decided that three scenarios will occur with about the same frequency:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;scenario &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;: weekday morning and evening traffic,&lt;/li&gt;&#xA;&lt;li&gt;scenario &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;: weekend traffic, and&lt;/li&gt;&#xA;&lt;li&gt;scenario &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;: weekday midday traffic.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Under Scenario &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, they think they can sell as many as &lt;span class=&quot;math-container&quot;&gt;$20$&lt;/span&gt; first-class tickets, &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt; business-class tickets,&#xA;and &lt;span class=&quot;math-container&quot;&gt;$200$&lt;/span&gt; economy tickets. Under Scenario &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;, these figures are &lt;span class=&quot;math-container&quot;&gt;$10, 25,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$175$&lt;/span&gt;. Under Scenario &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;, they are &lt;span class=&quot;math-container&quot;&gt;$5, 10,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$150$&lt;/span&gt;. You can assume they cannot sell more tickets than seats in each of the sections.&lt;/p&gt;&#xA;&lt;p&gt;(a) Assume that the data in Question1 correspond to the demand for seat reservations. Assume&#xA;that there is a &lt;span class=&quot;math-container&quot;&gt;$50\%$&lt;/span&gt; probability that all clients with a reservation effectively show up and that &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$20\%$&lt;/span&gt; no-shows occur with equal probability. Model this situation as a three-stage program, with first-stage decisions as before, second-stage decisions corresponding to the number of accepted reservations, and third-stage decisions corresponding to effective seat occupation. &lt;strong&gt;Show that the&#xA;third stage is a simple recourse program with a reward for each occupied seat and a penalty for each denied reservation.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;I couldn't understand how to solve this exercise (&lt;em&gt;Introduction to Stochastic Programming&lt;/em&gt;, 2nd edition. John R. Birge and Francois Louveaux. Springer, page: 83, Section: 2.8). In fact, and I am facing a hard time doing any exercise of that book.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is there any book where many examples were given before the exercises?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&lt;p&gt;I need just the concept to tackle this problem (&lt;strong&gt;construct the constraints&lt;/strong&gt;). I know this is a lengthy problem; you can skip the complete solution and cite the central conceptual part. It will be a great help if you can help me to construct those constraints for the first stage (I will try to write other stage by my own).&lt;/p&gt;&#xA;&lt;h2&gt;Update 2&lt;/h2&gt;&#xA;&lt;p&gt;I can construct the constraints of first 2 stage but could not understand what they mean by,&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;...Show that the third stage is a simple recourse program with a reward for each occupied seat and a penalty for each denied reservation.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="9806" LastEditorUserId="9806" LastEditDate="2022-10-22T09:33:32.573" LastActivityDate="2022-10-22T23:14:22.097" Title="Create constraint only for a recourse problem in stochastic linear programming" Tags="|linear-programming|constraint|stochastic-programming|chance-constraints|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9129" PostTypeId="1" CreationDate="2022-10-15T04:53:24.293" Score="2" ViewCount="171" Body="&lt;p&gt;I would like to know which are the advantage to do not convert quadratic expressions into linear expression in MiniZinc. For example let be the following simple MiniZinc code&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var -1.0..1.0:  x1;&#xA;var -1.0..1.0:  y1;&#xA;constraint (x1*y1) = 1.0;&#xA;solve satisfy;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The flatzinc code of that portion of code is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var -1.0..1.0: x1:: output_var;&#xA;var -1.0..1.0: y1:: output_var;&#xA;var -1.0..1.0: X_INTRODUCED_0_ ::var_is_introduced :: is_defined_var;&#xA;constraint float_eq(X_INTRODUCED_0_,1.0);&#xA;constraint float_times(x1,y1,X_INTRODUCED_0_):: defines_var(X_INTRODUCED_0_);&#xA;solve  satisfy;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As you can see, the quadratic term &lt;code&gt;x1*y1&lt;/code&gt; is still quadratic &lt;code&gt;float_times(x1,y1,X_INTRODUCED_0_)&lt;/code&gt;. Why MiniZinc does not convert &lt;code&gt;x1*y1&lt;/code&gt; to linear constraints?&lt;/p&gt;&#xA;" OwnerUserId="7463" LastEditorUserId="500" LastEditDate="2022-10-15T11:27:58.233" LastActivityDate="2022-10-15T11:31:02.163" Title="Why MiniZinc do not do convert to linear constraint a quadratic constraint?" Tags="|linearization|minizinc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9130" PostTypeId="2" ParentId="9129" CreationDate="2022-10-15T06:07:33.147" Score="4" Body="&lt;p&gt;What formulation do you expect MiniZinc to produce?&lt;/p&gt;&#xA;&lt;p&gt;MiniZinc does not convert &lt;code&gt;x1 * y1 = 1&lt;/code&gt; to a linear constraint because &lt;code&gt;x1 * y1 = 1&lt;/code&gt; cannot be represented by a linear constraint.&lt;/p&gt;&#xA;" OwnerUserId="804" LastEditorUserId="500" LastEditDate="2022-10-15T11:31:02.163" LastActivityDate="2022-10-15T11:31:02.163" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9131" PostTypeId="1" CreationDate="2022-10-15T06:32:50.440" Score="2" ViewCount="61" Body="&lt;p&gt;I would like to know which methods/algorithms MiniZinc uses to decrease terms of degree &amp;gt; 2 to quadratic terms. For example in the following code&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var -1.0..1.0:  x1; &#xA;var -1.0..1.0:  y1; &#xA;var -1.0..1.0:  z1;&#xA;constraint (x1*y1*z1) = 1.0;&#xA;solve satisfy;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The flatzinc code is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var -1.0..1.0: x1:: output_var;&#xA;var -1.0..1.0: y1:: output_var;&#xA;var -1.0..1.0: z1:: output_var;&#xA;var -1.0..1.0: X_INTRODUCED_0_ ::var_is_introduced :: is_defined_var;&#xA;var -1.0..1.0: X_INTRODUCED_1_ ::var_is_introduced :: is_defined_var;&#xA;constraint float_eq(X_INTRODUCED_1_,1.0);&#xA;constraint float_times(x1,y1,X_INTRODUCED_0_):: defines_var(X_INTRODUCED_0_);&#xA;constraint float_times(X_INTRODUCED_0_,z1,X_INTRODUCED_1_):: defines_var(X_INTRODUCED_1_);&#xA;solve  satisfy;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As you can see two new variables a constraints were introduced here. Which methods/algorithms support this conversion? Is there any loss using those methods/algorithms?&lt;/p&gt;&#xA;" OwnerUserId="7463" LastActivityDate="2022-10-15T09:21:38.793" Title="Which method MiniZinc uses to decrease terms of degree &gt; 2 to quadratic terms?" Tags="|minizinc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9132" PostTypeId="2" ParentId="9131" CreationDate="2022-10-15T09:21:38.793" Score="2" Body="&lt;p&gt;It's not a particular method or algorithm. The reformulation just lifts out bilinear terms and replaces them with a new variable:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(x1*y1*z1) = 1.0&#xA;&#xA;# into &#xA;&#xA;x1 * y1 = a&#xA;a  * z1 = b&#xA;b       = 1.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The problems are equivalent, so it's not making the problem easier to solve (there is still non-convex quadratic equality constraints). The reformulation might be needed if the solver supports quadratic terms but not higher powers.&lt;/p&gt;&#xA;&lt;p&gt;This is related to your other question: &lt;a href=&quot;https://or.stackexchange.com/questions/9129/why-minizinc-do-not-do-convert-to-linear-constraint-a-quadratic-constraint&quot;&gt;Why MiniZinc do not do convert to linear constraint a quadratic constraint?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2022-10-15T09:21:38.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9133" PostTypeId="1" AcceptedAnswerId="9134" CreationDate="2022-10-15T11:16:53.600" Score="2" ViewCount="92" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$f_k\colon\Bbb R^n\to\Bbb R$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$k=1,\dots,K$&lt;/span&gt;, be differentiable (possibly nonconvex) functions and &lt;span class=&quot;math-container&quot;&gt;$X\subset\Bbb R^n$&lt;/span&gt; be a convex set.&#xA;Consider the following optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{x\in X}\max_{k\in\{1,\dots,K\}} f_k(x).&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is minimax problem but the inner optimization is a maximization discrete set.&#xA;Rather than a general minimax problem,  I guess this may be easier to deal with.&#xA;I am interested in the following things:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Are there any papers which propose algorithms for such structured problem?&lt;/li&gt;&#xA;&lt;li&gt;Do the papers show non-asymptotic convergence analysis?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5821" LastEditorUserId="500" LastEditDate="2022-10-15T11:32:28.550" LastActivityDate="2022-10-15T14:38:21.213" Title="How do we call this optimization problem?" Tags="|nonconvex-programming|minimax|bilevel-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9134" PostTypeId="2" ParentId="9133" CreationDate="2022-10-15T14:38:21.213" Score="3" Body="&lt;p&gt;You can rewrite your problem as &lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\min y\\&#xA;\textrm{s.t. }y &amp;amp; \ge f_{k}(x)\quad k=1,\dots,K\\&#xA;x &amp;amp; \in X.&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What algorithms are applicable (and whether they converge in finitely many steps) will depend on the specifics of the &lt;span class=&quot;math-container&quot;&gt;$f_k()$&lt;/span&gt; functions.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-15T14:38:21.213" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9135" PostTypeId="1" CreationDate="2022-10-16T21:05:35.050" Score="3" ViewCount="113" Body="&lt;p&gt;Consider the following (Lp).&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad\mathbf{c} \cdot \mathbf{x}\\&#xA;\text{s.t. }&amp;amp;\quad A\mathbf{x} \geq \mathbf{b} \\&#xA;&amp;amp;\quad\mathbf{x} \geq \mathbf{0}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is the feasible set of (Lp), Prove that the following definitions are equivalent.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;(Lp) is unbounded if &lt;span class=&quot;math-container&quot;&gt;$\; ∃ \{x^v\}_{v}⊆ S $&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$  ;cx^v → −∞ \;$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$v → ∞.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;(Lp) is unbounded if &lt;span class=&quot;math-container&quot;&gt;$\; ∀x ∈ S,\; ∃ \,y ∈ S\;;\; c y &amp;lt; cx.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Proving 1 &lt;span class=&quot;math-container&quot;&gt;$\Rightarrow$&lt;/span&gt; 2  is an easy result from the definition of limits.&lt;/p&gt;&#xA;&lt;p&gt;Proving 2 &lt;span class=&quot;math-container&quot;&gt;$\Rightarrow$&lt;/span&gt; 1 is not easy! There is no guarantee that you can find a sequence whose limit goes to &lt;span class=&quot;math-container&quot;&gt;$−∞$&lt;/span&gt;. The fact that we have a decreasing sequence of &lt;span class=&quot;math-container&quot;&gt;$cx$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$x ∈ S$&lt;/span&gt; does not necessarily imply (1). Maybe this sequence doesn't get less than a specific number, i.e, it has an infimum in &lt;span class=&quot;math-container&quot;&gt;$\Bbb R$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Remark : If all coordinates of &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; are positive, since we know that &lt;span class=&quot;math-container&quot;&gt;$ x \ge 0$&lt;/span&gt; it results that for any &lt;span class=&quot;math-container&quot;&gt;$x ∈ S$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$cx \ge 0.$&lt;/span&gt; In this case of course the limit of any such sequence is not &lt;span class=&quot;math-container&quot;&gt;$−∞$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What are your thoughts? Are these 2 definitions really equivalent?&lt;/p&gt;&#xA;" OwnerUserId="10562" LastEditorUserId="10562" LastEditDate="2022-10-17T14:31:04.843" LastActivityDate="2022-10-20T15:42:48.770" Title="Does a linear program always attains its (finite) infimum?" Tags="|linear-programming|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9136" PostTypeId="1" AcceptedAnswerId="9138" CreationDate="2022-10-16T22:00:26.787" Score="2" ViewCount="249" Body="&lt;p&gt;My question up front with context below:&lt;/p&gt;&#xA;&lt;p&gt;Is there a generalized linearization possible for a higher order polynomial (max degree 6 in my case) involving a mix of binary and real variables?  If not, does anybody see a way to re-formulate the problem below in linear form?  And if the answer to that is also no, is there an optimization programming technique that can handle this problem form?  If at all possible I'd like to stick to a method that can be handled by CPLEX.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I'm trying to solve an optimization problem as an MILP using docplex.  All constraints are linear and all constraint variables are binary.  However, I have a condition where decision variables belong to subsets and if any variable within an arbitrary subset is 'active' in the solution, then the objective function cost terms corresponding to all variables in the set are modified by a scalar.&lt;/p&gt;&#xA;&lt;p&gt;In plain terms, if a decision variable appears in a solution, then the cost for other members of its subset to appear in the same solution are reduced.  Note that variables can be members of multiple subsets.&lt;/p&gt;&#xA;&lt;p&gt;For example, for a variable subset&#xA;&lt;span class=&quot;math-container&quot;&gt;$\left (x_1, x_2, x_3, x_4, x_5  \right )$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;If:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{5}x_i \geq 1$$&lt;/span&gt;&#xA;Then:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c_i = \left(1-b\right)c_{i} \quad \mathrm{for \ all} \quad i \in \left (1, ..., 5  \right ) \quad \mathrm{with} \quad 0 \le b\le 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a percentage reduction in cost for members of the subset, and the objective function is in the form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$min \sum_{i=1}^{n}c_{i}x_{i}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My plan was to implement this by adding dummy variables to the objective function in the form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$min\sum_{i=1}^{n}c_{i}x_{i}\prod_{j}^{m} \left (1-b_{j}y_{j}  \right ) \quad \mathrm{with} \quad c_{i}, b_{j}  \in \mathbb{R} \quad \mathrm{and} \quad x_{i}, y_{j} \in \left ( 0, 1 \right )$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is the number of variable subsets that &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; belongs to. I would add boolean constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{j}==&#xA;\begin{equation}&#xA;    \begin{cases}&#xA;        1 &amp;amp; \text{if } \sum x_{i} \geq 1\\&#xA;        0 &amp;amp; \text{if } \sum x_{i} = 0\\&#xA;    \end{cases}&#xA;\end{equation} \quad \text{for }i \in \left (\text{subset }j  \right )$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then I planned to linearize the objective function using the general case of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; binary variables here:&#xA;&lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables/38#38&quot;&gt;How to linearize the product of two binary variables?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i} \sum_{j} c_{i}x_{i}y_{j}$&lt;/span&gt; could be linearized trivially, but as far as I can tell the method falls apart with inclusion of the &lt;span class=&quot;math-container&quot;&gt;$b_j$&lt;/span&gt; scalar.  The &lt;span class=&quot;math-container&quot;&gt;$b_jy_j$&lt;/span&gt; term causes problems when for a given &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; it's &lt;span class=&quot;math-container&quot;&gt;$\in \left ( 0, 0.8 \right )$&lt;/span&gt;, for example, instead of &lt;span class=&quot;math-container&quot;&gt;$\in \left ( 0, 1 \right )$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;EDIT:&#xA;Fixed my representation of the objective function above thanks to @RobPratt comment.&lt;/p&gt;&#xA;&lt;p&gt;So for example, assuming &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; belongs to &lt;span class=&quot;math-container&quot;&gt;$m=5$&lt;/span&gt; subsets, the term with &lt;span class=&quot;math-container&quot;&gt;$i=1$&lt;/span&gt; becomes:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$c_1x_1\left(1-b_1y_1 \right)\left(1-b_2y_2 \right)\left(1-b_3y_3 \right)\left(1-b_4y_4 \right)\left(1-b_5y_5 \right)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is what I'm trying to linearize.&lt;/p&gt;&#xA;" OwnerUserId="10559" LastEditorUserId="10559" LastEditDate="2022-10-17T21:34:04.917" LastActivityDate="2022-10-17T21:34:04.917" Title="Linearize a higher order polynomial objective function?" Tags="|optimization|mixed-integer-programming|linearization|docplex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9137" PostTypeId="1" CreationDate="2022-10-17T08:05:10.547" Score="2" ViewCount="112" Body="&lt;p&gt;I arrived at this site as a result of &lt;a href=&quot;https://meta.stackexchange.com/questions/382954/looking-for-a-supply-chain-site-or-tag&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Last week, two colleagues were having a discussion about the term &amp;quot;Transport Order&amp;quot; in supply chain management. (Is it a recursive definition or can it only consist of different Vehicle Orders or other sub-orders, are there limitations about what a Transport Order NOT can be, ...?)&lt;/p&gt;&#xA;&lt;p&gt;I wonder if there is an official definition for terms like &amp;quot;Transport Order&amp;quot;, &amp;quot;Vehicle Order&amp;quot;, &amp;quot;Robot Order&amp;quot;, ...&lt;/p&gt;&#xA;" OwnerUserId="10563" LastEditorUserId="491" LastEditDate="2022-10-17T13:09:28.800" LastActivityDate="2022-10-20T17:42:27.507" Title="What is a transport order in supply chain management?" Tags="|terminology|supply-chain|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9138" PostTypeId="2" ParentId="9136" CreationDate="2022-10-17T11:46:45.753" Score="3" Body="&lt;p&gt;To linearize &lt;span class=&quot;math-container&quot;&gt;$c_i x_i b_j y_j$&lt;/span&gt;, rewrite as &lt;span class=&quot;math-container&quot;&gt;$c_i b_j z_{ij}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; arises from the usual linearization of a product of two binary variables, as in the link you provided. The constant &lt;span class=&quot;math-container&quot;&gt;$b_j$&lt;/span&gt; does not cause any issue; just think of &lt;span class=&quot;math-container&quot;&gt;$c_i b_j$&lt;/span&gt; as another constant.&lt;/p&gt;&#xA;&lt;p&gt;But I don’t see any sixth-degree polynomial in your formulation. You have only a quadratic polynomial.  Did you maybe instead want &lt;span class=&quot;math-container&quot;&gt;$$\sum_i c_i x_i \prod_j (1-b_j y_j)$$&lt;/span&gt; as the objective function? In any case, polynomials of binary variables can be linearized by linearizing each product of binary variables.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-10-17T12:53:32.247" LastActivityDate="2022-10-17T12:53:32.247" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9139" PostTypeId="1" CreationDate="2022-10-17T14:06:29.740" Score="1" ViewCount="170" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j\in M}\sum_{k=i}^{\rm until}x_{aijk}\cdot b_{kj}=d_{ai},\quad\forall i\in N,\forall a\in B\cap A_1;{\rm until}=\min(i+v_a,n)$$&lt;/span&gt; How to code this linear program in CPLEX?&lt;/p&gt;&#xA;" OwnerUserId="10564" LastEditorUserId="123" LastEditDate="2022-10-17T19:50:22.050" LastActivityDate="2022-11-14T17:25:34.590" Title="How to code this constraint in CPLEX?" Tags="|optimization|linear-programming|cplex|constraint|scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9140" PostTypeId="1" CreationDate="2022-10-18T00:30:13.170" Score="2" ViewCount="54" Body="&lt;p&gt;I'm trying to solve the network problem below in GAMS Cplex. I have a piecewise constraint that are depending on the node situations (whether a node is an origin (o) node, inbetween node, and destination (d) node).&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Zk7Jd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Zk7Jd.png&quot; alt=&quot;piecewise constraint&quot; /&gt;&lt;/a&gt;&#xA;How do I write these piecewise contraints?&lt;/p&gt;&#xA;&lt;p&gt;In the program below, I've write:&#xA;eq1 represents node 1 as an origin node,&#xA;eq2 eq3 eq4 represents node 2,3, and 4 as inbetween nodes,&#xA;eq5 represents node 5 as a destination node.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Set&#xA;&#xA;i   nodes /1,2,3,4,5/;&#xA;&#xA;Alias(i,j);&#xA;&#xA;Set&#xA;arc(i,j) arcs from node i to j &#xA;/1 .2&#xA; 2 .1&#xA; 1 .3&#xA; 3 .1&#xA; 1 .4&#xA; 4 .1&#xA; 2 .3&#xA; 3 .2&#xA; 2 .5&#xA; 5 .2&#xA; 3 .5&#xA; 5 .3&#xA; 4 .5&#xA; 5 .4/;&#xA;&#xA;Table c(i,j) population exposed from node i to node j&#xA;         1          2           3           4           5&#xA;&#xA;1        0          105000      90000       65000       0&#xA;&#xA;2        105000     0           100000      0           85000      &#xA;&#xA;3        90000      100000      0           0           80000&#xA;&#xA;4        65000      0           0           0           55000&#xA;&#xA;5        0          85000       80000       55000       0&#xA;;&#xA;&#xA;Table l(i,j) distance from node i to node j&#xA;         1          2           3           4           5&#xA;&#xA;1        0          5           8           10          0&#xA;&#xA;2        5          0           2           0           7      &#xA;&#xA;3        8          2           0           0           11&#xA;&#xA;4        10         0           0           0           8&#xA;&#xA;5        0          7           11          8           0&#xA;&#xA;Binary Variables&#xA;x(i,j)&#xA;y(i,j);&#xA;    &#xA;Positive Variables&#xA;    v(i,j)&#xA;    lambda(i,j);&#xA;&#xA;Free Variables&#xA;    w(i) node i&#xA;    w(j) node j&#xA;    z optimization solution;&#xA;    &#xA;Scalar&#xA;    R very large number;&#xA;&#xA;R = 10000000000000000;&#xA;&#xA;Equations&#xA;    sol optimization solution&#xA;    eq1(i,j) constraint 1&#xA;    eq2(i,j) constraint 2&#xA;    eq3(i,j) constraint 3&#xA;    eq4(i,j) constraint 4&#xA;    eq5(i,j) constraint 5&#xA;    eq6(i,j) constraint 6&#xA;    eq7(i,j) constraint 7&#xA;    eq8(i,j) constraint 8&#xA;    eq9(i,j) constraint 9;&#xA;    &#xA;sol.. z =e= sum(arc(i,j),c(arc)*x(arc));&#xA;eq1(i,j).. x(1,2) - x(2,1) + x(1,3) - x(3,1) + x(1,4) - x(4,1) =e= 1;&#xA;eq2(i,j).. - x(1,2) + x(2,1) + x(2,3) - x(3,2) + x(2,5) - x(5,2) =e= 0;&#xA;eq3(i,j).. - x(1,3) + x(3,1) - x(2,3) + x(3,2) + x(3,5) - x(5,3) =e= 0;&#xA;eq4(i,j).. - x(1,4) + x(4,1) + x(4,5) - x(5,4) =e= 0;&#xA;eq5(i,j).. - x(2,5) + x(5,2) - x(3,5) + x(5,3) - x(4,5) + x(5,4) =e= -1;&#xA;eq6(i,j).. - y(i,j) + x(i,j) =l= 0;&#xA;eq7(i,j).. l(i,j) - w(i) + w(j) - v(i,j) + lambda(i,j) =e= 0;&#xA;eq8(i,j).. v(i,j) - R * (1 - x(i,j)) =l= 0;&#xA;eq9(i,j).. lambda(i,j) - R * (1 - (y(i,j) - x(i,j))) =l= 0;&#xA;Model contohTMB /all/;&#xA;&#xA;Solve contohTMB using MIP Minimizing z;&#xA;&#xA;Display &amp;quot;Solution values:&amp;quot;&#xA;Display&#xA;    x.l, z.l;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10331" LastActivityDate="2022-10-18T13:40:55.133" Title="Piecewise constraints in GAMS" Tags="|gams|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9141" PostTypeId="1" CreationDate="2022-10-18T01:15:29.373" Score="2" ViewCount="68" Body="&lt;p&gt;Suppose that I am trying to solve a standard multi-objective optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;    \min_{&#xA;    \begin{array}{c}&#xA;        \textbf{x} \in S&#xA;    \end{array}&#xA;    }&#xA;    \left [ f_1(\textbf{x}),f_2(\textbf{x}),\ldots,f_m(\textbf{x}) \right ]&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\textbf{x}$&lt;/span&gt; has to satisfy the constraints in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. Let us define these as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;    S = \left \{ \textbf{x} \in \mathbb{R}^d:&#xA;        \begin{aligned}&#xA;            g_i (\textbf{x}) &amp;amp;= c_i \text{ for } i=1,\ldots,k_j \\&#xA;            h_j (\textbf{x}) &amp;amp;\geq c_j \text{ for } i=1,\ldots,k_h&#xA;        \end{aligned}&#xA;        \right \}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But in addition, suppose I also know the variable dependency structure amongst the variables in &lt;span class=&quot;math-container&quot;&gt;$\textbf{x}$&lt;/span&gt; via a directed graph.&lt;/p&gt;&#xA;&lt;p&gt;Here's an example:&lt;/p&gt;&#xA;&lt;h2&gt;&lt;a href=&quot;https://i.stack.imgur.com/7NIps.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7NIps.png&quot; alt=&quot;Variable dependencies.&quot; /&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;In this instance, I know that e.g. &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; does not affect the response &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; directly but rather via &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;. Similar for &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My two questions are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Would I be better off encoding my graphical constraints as 'normal' constraints as found in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; or are there other methods for dealing with this type of 'extra' information?&lt;/li&gt;&#xA;&lt;li&gt;What sort of methods could one use to deal with this type of problem? Clearly, we are looking for a Pareto optimal solution but we have this extra graphical information? &lt;span class=&quot;math-container&quot;&gt;$\textbf{x}$&lt;/span&gt; can be either continuous or discrete it doesn't really matter, but the knowledge of the graph matters. I think it can be construed as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Constraint_satisfaction_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;constraint satisfaction problem&lt;/a&gt; (CSP) but I cannot seem to find a version of CSP which deals with directed graphs.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Any advice would be most welcome. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="10512" LastActivityDate="2022-10-18T01:15:29.373" Title="Multi-objective optimization with known variable dependencies (via a graph) -- what is this called?" Tags="|constraint-programming|graphs|multi-objective-optimization|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9143" PostTypeId="1" AcceptedAnswerId="9144" CreationDate="2022-10-18T07:43:51.627" Score="3" ViewCount="76" Body="&lt;p&gt;I need to optimize number of workers in my Warehouse. Suppose, there are three positions in the warehouse - A, B and C. Every person can work in all positions. Each day, some amount of goods arrives. Each piece of goods goes to position A, then B and finally C. I need to maximize the number of goods at position C at the end of the day by shifting my workers through the positions.&lt;/p&gt;&#xA;&lt;p&gt;Mathematically speaking:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A + B + C = 40$&lt;/span&gt; ... Total number of workers is 40&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A \leq 10$&lt;/span&gt; ... capacity of position A is 10&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$B \leq 25$&lt;/span&gt; ... capacity of position B is 25&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C \leq 15$&lt;/span&gt; ... capacity of position C is 15&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; be the total amount of goods that arrives each morning. Workers have different productivity based on their position:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$G_{A} = min\{62 \cdot A; G\}&#xA;$&lt;/span&gt; ... in other words, one worker in position A can process 62 pieces of goods, but obviously he cannot process more than is the total number of goods that arrives at the beginning of the day.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$G_{B} = min\{52 \cdot B - 1.1 \cdot B^{2}; G_{A}\}$&lt;/span&gt; ... productivity of the worker B is concave. Same as above, total number of goods processed in B cannot be greater than number of goods from A, because A is an input for B.&lt;/p&gt;&#xA;&lt;p&gt;Finally:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$G_{C} = min\{53 \cdot C - 0.9 \cdot C^{2}; G_{B}\}$&lt;/span&gt;... interpretation same as in B.&lt;/p&gt;&#xA;&lt;p&gt;Do you have any idea, how to solve this type of problems, please? I was thinking about some linear programming, but the problem is that &lt;span class=&quot;math-container&quot;&gt;$G_{B}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$G_{C}$&lt;/span&gt; is quadratic.. If you have any suggestions or link to similar problems, please share.&lt;/p&gt;&#xA;" OwnerUserId="10569" OwnerDisplayName="vojtam" LastActivityDate="2022-10-18T12:24:24.550" Title="Optimization problem in warehouse" Tags="|optimization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9144" PostTypeId="2" ParentId="9143" CreationDate="2022-10-18T11:26:55.587" Score="3" Body="&lt;p&gt;I wouldn't recommend this for this type of problem in general, but for this specific problem, the search space is so small that an exhaustive search is trivial.&lt;/p&gt;&#xA;&lt;p&gt;First, notice that &lt;span class=&quot;math-container&quot;&gt;$\text{max}(G_B)=614$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$B=23$&lt;/span&gt;. Start by enumerating all 45 possible arrangements of &lt;span class=&quot;math-container&quot;&gt;$\{A\leq10,B\leq23,C\leq15\}$&lt;/span&gt; that satisfy &lt;span class=&quot;math-container&quot;&gt;$A+B+C=40$&lt;/span&gt;. Then determine the value of &lt;span class=&quot;math-container&quot;&gt;$G_C$&lt;/span&gt; of each arrangement for some value &lt;span class=&quot;math-container&quot;&gt;$G\geq614$&lt;/span&gt; (or &lt;span class=&quot;math-container&quot;&gt;$G\geq592$&lt;/span&gt;, which is the maximum value of &lt;span class=&quot;math-container&quot;&gt;$G_C$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$C=15$&lt;/span&gt;), and select the arrangement with the largest value for &lt;span class=&quot;math-container&quot;&gt;$G_C$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In R:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;W &amp;lt;- expand.grid(list(A = 1:10, C = 1:15))&#xA;W&lt;span class=&quot;math-container&quot;&gt;$B &amp;lt;- 40 - rowSums(W)&#xA;W &amp;lt;- W[W$&lt;/span&gt;B &amp;lt;= 23,][c(1, 3, 2)]&#xA;&#xA;GC &amp;lt;- with(&#xA;  W,&#xA;  pmin(floor(53*C - 0.9*C^2), pmin(floor(52*B - 1.1*B^2), pmin(62*A, 614)))&#xA;)&#xA;idx &amp;lt;- which.max(GC)&#xA;c(GC = GC[idx], W[idx,])&#xA;#&amp;gt; &lt;span class=&quot;math-container&quot;&gt;$GC&#xA;#&amp;gt; [1] 558&#xA;#&amp;gt; &#xA;#&amp;gt; $&lt;/span&gt;A&#xA;#&amp;gt; [1] 9&#xA;#&amp;gt; &#xA;#&amp;gt; &lt;span class=&quot;math-container&quot;&gt;$B&#xA;#&amp;gt; [1] 17&#xA;#&amp;gt; &#xA;#&amp;gt; $&lt;/span&gt;C&#xA;#&amp;gt; [1] 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="jblood94" LastActivityDate="2022-10-18T12:10:43.227" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9145" PostTypeId="2" ParentId="9140" CreationDate="2022-10-18T13:40:55.133" Score="2" Body="&lt;p&gt;This can be done with $ (&amp;quot;such-that&amp;quot;) conditions on the constraints. Or better: use a single parameter so that a single equation can be used for all cases  (see:  &lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2018/02/modeling-vs-programming-python-vs-gams.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://yetanothermathprogrammingconsultant.blogspot.com/2018/02/modeling-vs-programming-python-vs-gams.html&lt;/a&gt; for an example).&lt;/p&gt;&#xA;&lt;p&gt;Your model can be improved a bit.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use meaningful names.&lt;/li&gt;&#xA;&lt;li&gt;Never use a big M constant of this size.&lt;/li&gt;&#xA;&lt;li&gt;Use explanatory text on all symbols to explain what they mean. Something better than &amp;quot;&lt;em&gt;constraint 3&lt;/em&gt;&amp;quot;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;You may want to discuss this with your teacher.&lt;/p&gt;&#xA;" OwnerUserId="907" LastActivityDate="2022-10-18T13:40:55.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9146" PostTypeId="1" CreationDate="2022-10-18T18:01:08.160" Score="3" ViewCount="129" Body="&lt;p&gt;Suppose function &lt;span class=&quot;math-container&quot;&gt;$\mu_i(y):\mathbb{R} \rightarrow \mathbb{R}$&lt;/span&gt; is a logit function, &lt;span class=&quot;math-container&quot;&gt;$\mu_i(y)=1/(1+\exp(-y))$&lt;/span&gt;. Also, we assume that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}_i\in \mathbb{R}^d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\theta \in \mathbb{R}^d$&lt;/span&gt;. I am wondering how it is possible to find the robust counterpart of the following problem?&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{split}&#xA;\min_{\theta \in \mathbb{R}^d} &amp;amp;\left\{\sum_{i=1}^{n} a_i \mu_i(\mathbf{x}^T \theta)\: \:\: s.t. \:\:\:\|\theta-\hat{\theta}\|_H \le \gamma  \right\} \ge b&#xA;\end{split}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; is a positive definite matrix and &lt;span class=&quot;math-container&quot;&gt;$a_i, \gamma, b$&lt;/span&gt; are positive numbers. If it is not possible to find an exact robust counterpart, I would be thankful for any idea about how to find a conservative approximation.&lt;/p&gt;&#xA;&lt;p&gt;I crossposted to Math.SE as well:  &lt;a href=&quot;https://math.stackexchange.com/questions/4554732/dual-of-sum-of-two-sigmoid-functions&quot;&gt;Dual of sum of two sigmoid functions&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="491" LastEditDate="2022-11-02T14:49:31.110" LastActivityDate="2022-11-02T14:49:31.110" Title="How to find robust counterpart of sum of logit functions?" Tags="|nonlinear-programming|duality|dual|robust-optimization|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9149" PostTypeId="1" AcceptedAnswerId="9166" CreationDate="2022-10-19T07:30:02.430" Score="2" ViewCount="67" Body="&lt;p&gt;Is there any recommendation in any journal or learning material (like some kind of tutorials) specified in Operation Research/Management Science/Quantitative Analysis/or similar? For example, I found it interesting to read &lt;a href=&quot;https://pubsonline.informs.org/journal/ited&quot; rel=&quot;nofollow noreferrer&quot;&gt;INFORMS Journal Transaction of Education&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10000" LastActivityDate="2022-10-20T15:54:15.147" Title="Any journal on OR Education" Tags="|journals|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9150" PostTypeId="2" ParentId="9121" CreationDate="2022-10-19T12:58:04.663" Score="1" Body="&lt;p&gt;Here's a few ideas:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Only store the full state in the leaf nodes. Remove it from the parent nodes once all their children are created.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Only store the full state in the parent/internal nodes. Each leaf node would store the diff from parent only.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Store the full state every &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; levels in the tree; the intermediate nodes would store the diff from their parent only.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a backtracking algorithm instead of B&amp;amp;B so that you can 'unapply' the change when you backtrack to the parent node.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you're using B&amp;amp;B, you might still be able to find a common ancestor between the incoming change and the previous change; you would only have to undo changes up to the common ancestor and then reapply changes from that point to the new leaf.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Maybe you can organize your tree branches by the variables that they manipulate. Then you can have each node contain a pointer to the last node with the full state. You start with that full state but refer to your local node for some specific row of variables.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It may be that that your large state doesn't have to be fully reset. Consider the LP relaxation in the MIP tree; you can change the starting point without having to reset all the data in the LP.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2022-10-19T12:58:04.663" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9151" PostTypeId="1" CreationDate="2022-10-19T15:15:30.087" Score="1" ViewCount="118" Body="&lt;p&gt;I have a system with &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; tasks, where each task is a state in a Markov chain. I am working on allocating agents to each task. I would like to achieve a specific distribution of the agents among these tasks in the steady state. How do I optimize the Transition Probability Matrix (TPM) using OR-Tools?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Some info of my system:&lt;/strong&gt; The system exists as a simulation of the process. Hence, each agent is simulated to &lt;em&gt;make an actual choice about which state to go to from its current state&lt;/em&gt; based on the TPM. In one iteration, every agent makes a transition. I run this for a very large number of iterations to simulate the steady state.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Variable:&lt;/strong&gt; TPM&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt; Standard constraints of a TPM&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Optimization:&lt;/strong&gt; Minimize difference between desired distribution vector and actual distribution vector&lt;/p&gt;&#xA;&lt;p&gt;Edit: While I appreciate the analytical means of arriving at the values of the TPM, I am interested in optimizing the TPM based on the results of simulation. I suppose this shifts the focus from the conceptual approach behind finding the values in the TPM, to how I may use my own function/method to determine the suitability of each intermediate solution generated by the solver (and how the solver uses the suitability determined by the custom function) specifically in OR-Tools.&lt;/p&gt;&#xA;" OwnerUserId="8918" LastEditorUserId="491" LastEditDate="2022-11-11T20:07:06.833" LastActivityDate="2022-11-11T20:07:06.833" Title="(OR-Tools) Custom Function to Evaluate Intermediate Solutons" Tags="|or-tools|markov-decision-process|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9152" PostTypeId="2" ParentId="1318" CreationDate="2022-10-19T15:49:20.973" Score="1" Body="&lt;p&gt;We built MOS in response to experiencing this issue ourselves. It attempts to automate much of this process, providing a model with an API and a frontend &lt;a href=&quot;https://fuinn.github.io/mos-docs/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://fuinn.github.io/mos-docs/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Docker image available so it can be as easy to try out as possible&lt;/p&gt;&#xA;&lt;p&gt;Very happy to discuss how it could be applied to your particular problem.&lt;/p&gt;&#xA;" OwnerUserId="10091" LastActivityDate="2022-10-19T15:49:20.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9153" PostTypeId="1" CreationDate="2022-10-19T16:05:11.337" Score="2" ViewCount="61" Body="&lt;p&gt;At page 7 from &lt;a href=&quot;https://cs.gmu.edu/%7Elifei/teaching/cs684spring17/lec8.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;these slides&lt;/a&gt; there is a Greedy algorithm I want to implement.&lt;/p&gt;&#xA;&lt;p&gt;It says&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;let &lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt; be the shortest path (if one exists) that [...]&lt;br /&gt;&#xA;connects some (&lt;span class=&quot;math-container&quot;&gt;$s_j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt;) pair that is not yet connected.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(s_j,t_j)$&lt;/span&gt; comes from a set of &lt;em&gt;commodities&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Without getting into the theoretical implication of the whole algorithm, I only wonder how to implement such a statement.&lt;/p&gt;&#xA;&lt;p&gt;It is stated to be greedy, hence it should have an easy implementation.&lt;/p&gt;&#xA;&lt;p&gt;Is there a standard way to do that?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: Is there also any better reference than slides?&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="5523" LastEditDate="2022-10-19T16:19:25.253" LastActivityDate="2022-10-20T12:34:05.733" Title="Find the shortest path connecting some (s,t) - a greedy (?) criterion to a multi-commodity flow problem" Tags="|reference-request|algorithms|network-flow|approximation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9154" PostTypeId="1" AcceptedAnswerId="9159" CreationDate="2022-10-19T19:25:02.650" Score="1" ViewCount="64" Body="&lt;p&gt;Is it possible to determine if a Geometric Program (GP) has one, none, or infinite (primal) solutions by its structure (e.g., in terms of the number of variables, constraints, or product terms involved in the problem)?&lt;/p&gt;&#xA;&lt;p&gt;It is known that the &amp;quot;degree of difficulty&amp;quot; (see e.g. &lt;a href=&quot;https://link.springer.com/content/pdf/10.1007/BF01580667.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this def.&lt;/a&gt;) determines the number of solutions to the dual problem, but how that relates to the number of primal solutions?&lt;/p&gt;&#xA;&lt;p&gt;I am interested in proving that a GP has a unique solution, i.e. when the set of optimal solutions is a singleton.&lt;/p&gt;&#xA;" OwnerUserId="5005" LastEditorUserId="5005" LastEditDate="2022-10-20T11:14:45.283" LastActivityDate="2022-10-20T12:46:05.630" Title="Number of solutions to geometric program" Tags="|optimization|convex-optimization|duality|global-optimality|geometric-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9155" PostTypeId="2" ParentId="9153" CreationDate="2022-10-19T19:40:06.947" Score="2" Body="&lt;p&gt;Only the outer algorithm is greedy, in the sense of removing the path links in each iteration and never looking back. Use any algorithm (like Dijkstra) to find a shortest path for each remaining &lt;span class=&quot;math-container&quot;&gt;$(s_j,t_j)$&lt;/span&gt; in each iteration. As a possible speed-up, you can skip Dijkstra for all &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; for which none of its shortest-path links have been removed because in that case the previously computed shortest path will still be shortest.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-10-20T12:34:05.733" LastActivityDate="2022-10-20T12:34:05.733" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9156" PostTypeId="2" ParentId="9151" CreationDate="2022-10-19T23:09:11.660" Score="3" Body="&lt;p&gt;Given target vector &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt;, if there is such a transition probability matrix &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; as its limiting distribution, you can find one via linear programming (LP), as shown in my answer &lt;a href=&quot;https://math.stackexchange.com/a/3301963/683666&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Otherwise, you can minimize the absolute error via LP by minimizing &lt;span class=&quot;math-container&quot;&gt;$\sum_j (s_j + t_j)$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i \mu_i P_{ij} &amp;amp;= \mu_j &amp;amp;&amp;amp;\text{for all $j$} \label1\tag1 \\&#xA;\sum_j P_{ij} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \label2\tag2 \\&#xA;P_{ij} &amp;amp;\ge \epsilon &amp;amp;&amp;amp; \text{for all $i$ and $j$} \label3\tag3 \\&#xA;\mu_j - s_j + t_j &amp;amp;= \pi_j &amp;amp;&amp;amp;\text{for all $j$} \\&#xA;s_j &amp;amp;\ge 0 &amp;amp;&amp;amp; \text{for all $j$} \\&#xA;t_j &amp;amp;\ge 0 &amp;amp;&amp;amp; \text{for all $j$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, you can minimize the sum of squares error via quadratic programming by minimizing &lt;span class=&quot;math-container&quot;&gt;$\sum_j (\mu_j - \pi_j)^2$&lt;/span&gt; subject to \eqref{1}-\eqref{3}.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-10-19T23:09:11.660" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9157" PostTypeId="2" ParentId="9128" CreationDate="2022-10-19T23:55:20.053" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;I know this is a lengthy problem; you can skip the complete solution and cite the central conceptual part&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This too is a hard challenge. Stochastic programming is difficult to explain, and I find the classical way of formulating problems non-intuitive.&lt;/p&gt;&#xA;&lt;p&gt;My general approach is:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What are the decisions. In this case, we need to decide how many seats to build, how may to sell, and then work out profit/loss depending on who turns up.&lt;/li&gt;&#xA;&lt;li&gt;When does the uncertainty get revealed. In this case, after we build the seats we learn the demand, and then after we've sold the seats we learn who turns up.&lt;/li&gt;&#xA;&lt;li&gt;With the decisions and the uncertainty, you can figure out the staging in the form of decision-uncertainty-decision-uncertainty-etc. In this case, we have three main decisions and two sources of uncertainty, so it's a three stage problem.&lt;/li&gt;&#xA;&lt;li&gt;What's the first stage? It's to choose how many seats of each type to build, subject to the constraint that we can only have 200 seat equivalents. The number of seats built in the first stage are needed in later stages, so they are a state variable.&lt;/li&gt;&#xA;&lt;li&gt;What's the next stage? In stage 2, we need as input the seats from the first stage, and also a realization of demand. Our decision is how many seats to sell. We can oversubscribe, because there's a chance of no-shows. The number of seats we well is needed in stage 3, so that's also a state variable.&lt;/li&gt;&#xA;&lt;li&gt;And so on to the remaining stages. In this case, there's only one more stage. We need the number of seats built and the number of seats sold as input, as well as a realization of no-shows. Then we can compute our profit/loss.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;If you're interested in multistage (i.e., t &amp;gt; 2) problems, you might like to read &lt;a href=&quot;https://odow.github.io/SDDP.jl/stable/tutorial/basic/01_first_steps&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://odow.github.io/SDDP.jl/stable/tutorial/basic/01_first_steps&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are a bunch of ways to solve this problem. SDDP isn't really intended for such small problems with diverse stage structures, but it works anyway. Here's some code if that helps:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using SDDP&#xA;import HiGHS&#xA;&#xA;model = SDDP.LinearPolicyGraph(&#xA;    stages = 3,&#xA;    sense = :Max,&#xA;    optimizer = HiGHS.Optimizer,&#xA;    upper_bound = 800.0,&#xA;) do sp, stage&#xA;    cabins = [:first, :business, :economy]&#xA;    # State variables: because of SDDP.jl's quirks, we need to define them all&#xA;    # up front.&#xA;    #&#xA;    # First stage variables: Number of seats to choose&#xA;    @variable(sp, seats[cabins] &amp;gt;= 0, SDDP.State, initial_value = 0)&#xA;    # Second stage variables: Number of seats to sell&#xA;    @variable(sp, sell[cabins] &amp;gt;= 0, SDDP.State, initial_value = 0)&#xA;    if stage == 1&#xA;        # First stage: choose seat distribution&#xA;        scale = Dict(:first =&amp;gt; 2.0, :business =&amp;gt; 1.5, :economy =&amp;gt; 1.0)&#xA;        @constraint(sp, sum(scale[c] * seats[c].out for c in cabins) &amp;lt;= 200.0)&#xA;        # We don't use `sell` in the first stage and there is no objective&#xA;        # contribution&#xA;        @constraint(sp, [c in cabins], sell[c].in == sell[c].out)&#xA;        @stageobjective(sp, 0.0)&#xA;    elseif stage == 2&#xA;        # Second stage: choose how many seats to sell&#xA;        Ω = [&#xA;            Dict(:first =&amp;gt; 20, :business =&amp;gt; 50, :economy =&amp;gt; 200),&#xA;            Dict(:first =&amp;gt; 10, :business =&amp;gt; 25, :economy =&amp;gt; 175),&#xA;            Dict(:first =&amp;gt; 5, :business =&amp;gt; 10, :economy =&amp;gt; 150),&#xA;        ]&#xA;        SDDP.parameterize(sp, Ω) do ω&#xA;            for (cabin, demand) in ω&#xA;                set_upper_bound(sell[cabin].out, demand)&#xA;            end&#xA;        end&#xA;        # We can't change the number of seats, and there is no objective&#xA;        # contribution&#xA;        @constraint(sp, [c in cabins], seats[c].in == seats[c].out)&#xA;        @stageobjective(sp, 0.0)&#xA;    else&#xA;        # Third stage: Find out who turns up, and pay penalty for over-selling&#xA;        @assert stage == 3&#xA;        # Variable to compute oversold seats&#xA;        @variable(sp, Δ[cabins] &amp;gt;= 0)&#xA;        # Seat balance constraint to compute Δ&#xA;        @constraint(sp, bal[c in cabins], 1.0 * sell[c].in - Δ[c] &amp;lt;= seats[c].in)&#xA;        # 100, 90, and 80% of clients turn up with 50, 25, and 25% probability.&#xA;        SDDP.parameterize(sp, [1.0, 0.9, 0.8], [0.5, 0.25, 0.25]) do ω&#xA;            for c in cabins&#xA;                # Update the seat balance constraint with the true multiplier&#xA;                set_normalized_coefficient(bal[c], sell[c].in, ω)&#xA;            end&#xA;            scale = Dict(:first =&amp;gt; 3.0, :business =&amp;gt; 2.0, :economy =&amp;gt; 1.0)&#xA;            @stageobjective(sp, sum(scale[c] * (sell[c].in - 2.5 * Δ[c]) for c in cabins))&#xA;        end&#xA;    end&#xA;end&#xA;&#xA;SDDP.train(model, iteration_limit = 30)&#xA;simulations = SDDP.simulate(model, 10, Symbol[:seats, :sell]);&#xA;&#xA;julia&amp;gt; getfield.(simulations[1][1][:seats], :out)&#xA;1-dimensional DenseAxisArray{Float64,1,...} with index sets:&#xA;    Dimension 1, [:first, :business, :economy]&#xA;And data, a 3-element Vector{Float64}:&#xA;  10.0&#xA;  20.000000000000018&#xA; 149.99999999999997&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="804" LastActivityDate="2022-10-19T23:55:20.053" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9158" PostTypeId="1" CreationDate="2022-10-20T09:58:46.793" Score="2" ViewCount="219" Body="&lt;p&gt;I'm new to Gurobi in Python and I am wondering if there is way to code the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1-&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$\sum x_i =0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i\in A$&lt;/span&gt; OR   for all &lt;span class=&quot;math-container&quot;&gt;$i \in B$&lt;/span&gt;&lt;br /&gt;&#xA;where A and B are distinch sets of integers and &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are binary variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;2-&lt;/strong&gt;  &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=0}^{10} x_i =0$&lt;/span&gt; OR &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=0}^{10}  x_i =1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Question:&#xA;Is there a way to express the &amp;quot;Or&amp;quot; in one of the above constraints ?/code in Gurobi (maybe something like addConstrOr instead of addConstr)&lt;/p&gt;&#xA;&lt;p&gt;My thoughts: maybe something like that would work for (1) and (2), but I am not sure if it is possible&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;model. addConstr (sum( x [ i] for i in A) ==0) or model. addConstr (sum( x [ i] for i in B) ) ==0)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;model. addConstr (sum( x [ i] for i in range(0,10) ) ==0) or model. addConstr (sum( x [ i] for i in range(0,10) ) ==1)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10520" LastEditorUserId="491" LastEditDate="2022-10-20T12:27:03.503" LastActivityDate="2022-10-20T12:27:03.503" Title="OR constraint in Gurobi - Python" Tags="|linear-programming|modeling|python|gurobi|constraint|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9159" PostTypeId="2" ParentId="9154" CreationDate="2022-10-20T11:24:21.057" Score="3" Body="&lt;p&gt;I general, you can't determine infeasibility or unboundedness by the structure.&lt;/p&gt;&#xA;&lt;p&gt;But, if after &lt;a href=&quot;https://en.wikipedia.org/wiki/Geometric_programming#Conve_%20form&quot; rel=&quot;nofollow noreferrer&quot;&gt;change of variables to convex form&lt;/a&gt;, the objective is strictly convex, the solution, if it exists, is unique. &lt;em&gt;However, lack of strict convexity does not imply the solution is not unique&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So solve the GP using a numerical optimizer (preferably designed to specially handle Geometric Programs).  Assuming no numerical difficulties, it will be determined to be either&lt;/p&gt;&#xA;&lt;p&gt;a) Infeasible&lt;/p&gt;&#xA;&lt;p&gt;b) Unbounded&lt;/p&gt;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&lt;p&gt;c)  An optimal solution will be found. If (after the change of variables to convex form) the objective function is strictly convex, the optimal solution is unique. &lt;em&gt;If the objective is not strictly convex, we are left not knowing whether the solution is unique.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I agree with everything @ErlingMOSEK wrote and added two italicized sentences to make his point explicit.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-10-20T12:46:05.630" LastActivityDate="2022-10-20T12:46:05.630" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9160" PostTypeId="1" AcceptedAnswerId="9162" CreationDate="2022-10-20T11:26:48.210" Score="3" ViewCount="276" Body="&lt;p&gt;I'm new to Gurobi in Python and I am wondering if there is way to express/code &amp;quot;for some&amp;quot; in the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i+x_j +x_k+x_l =2$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$i, j, k,l \in \{0,1,2,...., 10\}$&lt;/span&gt;,&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;  are binary variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&#xA;Is there a way to express  the &amp;quot;for some&amp;quot;  &lt;span class=&quot;math-container&quot;&gt;$i, j,k,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; in a certain set ?&lt;/p&gt;&#xA;" OwnerUserId="10520" LastEditorUserId="491" LastEditDate="2022-10-20T12:26:23.337" LastActivityDate="2022-10-20T12:49:16.337" Title="Gurobi - Python: is there a way to express &quot;for some&quot; in a constraint?" Tags="|linear-programming|modeling|python|gurobi|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9161" PostTypeId="2" ParentId="9154" CreationDate="2022-10-20T12:02:09.793" Score="3" Body="&lt;p&gt;This is a follow-up to the post of Mark Stone.&lt;/p&gt;&#xA;&lt;p&gt;The problem can be formulated in a conic form using&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/expo.html#geometric-programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.mosek.com/modeling-cookbook/expo.html#geometric-programming&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and solves quite well on that form. Clearly, on that form the objective is linear, but the problem might still have a unique solution. So the method of Mark is only sufficient.&lt;/p&gt;&#xA;&lt;p&gt;A reasonable conjecture is that the Hessian of Langrangian should be strictly convex at the optimum. This generalizes the proposal of Mark.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2022-10-20T12:02:09.793" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9162" PostTypeId="2" ParentId="9160" CreationDate="2022-10-20T12:49:16.337" Score="6" Body="&lt;p&gt;The existence of some &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;-subset with sum &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; is equivalent to having at least two &lt;span class=&quot;math-container&quot;&gt;$x_i=1$&lt;/span&gt; and at least two &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt;, so impose &lt;span class=&quot;math-container&quot;&gt;$2\le \sum_i x_i \le 9$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-10-20T12:49:16.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9163" PostTypeId="1" AcceptedAnswerId="9167" CreationDate="2022-10-20T14:30:47.940" Score="3" ViewCount="349" Body="&lt;p&gt;I am trying to formulate indicator-type of constraints. &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is binary &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a continuous variable.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ y = &#xA;  \begin{cases}&#xA;    1, &amp;amp; \text{ if } a \leq x \leq b \\&#xA;    0, &amp;amp; \text{ Otherwise } &#xA;  \end{cases}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The question is how to model this using linear constraints? I have researched and done my homework below with thoughts:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Define binary &lt;span class=&quot;math-container&quot;&gt;$$ y_1 = &#xA;  \begin{cases}&#xA;    1, &amp;amp; \text{ if } a \leq x  \\&#xA;    0, &amp;amp; \text{ Otherwise } &#xA;  \end{cases}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Define binary &lt;span class=&quot;math-container&quot;&gt;$$ y_2 = &#xA;  \begin{cases}&#xA;    1, &amp;amp; \text{ if } x \leq b  \\&#xA;    0, &amp;amp; \text{ Otherwise } &#xA;  \end{cases}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Big-M methods can be used to define linear constraints for &lt;span class=&quot;math-container&quot;&gt;$ x, y_1 $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ y_2.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Enforce &lt;span class=&quot;math-container&quot;&gt;$ y=1 $&lt;/span&gt; if both &lt;span class=&quot;math-container&quot;&gt;$ y_1=1 $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ y_2=1 $&lt;/span&gt;; &lt;span class=&quot;math-container&quot;&gt;$ y=0 $&lt;/span&gt; otherwise, as follows: &lt;span class=&quot;math-container&quot;&gt;$$ y \leq y_1, y \leq y_2, y \geq y_1+y_2-1 $$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;However I ended up with two many ( 4 with Big-M methods and 3 above) constraints. I was wondering if anyone has other more efficient or better approaches?&lt;/p&gt;&#xA;" OwnerUserId="10586" LastEditorUserId="491" LastEditDate="2022-10-24T18:49:51.103" LastActivityDate="2022-10-24T18:49:51.103" Title="How to model logic constraint: $y=1$ if $a\le x\le b$ and $y=0$ otherwise?" Tags="|modeling|integer-programming|linearization|logical-constraints|indicator-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9164" PostTypeId="1" AcceptedAnswerId="9178" CreationDate="2022-10-20T15:42:34.443" Score="3" ViewCount="130" Body="&lt;p&gt;I cannot find references for a Minimum Disjointed Path Cover ILP formulation.&lt;/p&gt;&#xA;&lt;p&gt;Given a directed graph G=(V,A), a disjointed path cover is a path cover with no common nodes between paths. We want to find a path cover with the minimum number of paths.&lt;/p&gt;&#xA;&lt;p&gt;My idea is to count nodes with no entering edges as the number of paths.&#xA;That is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z = \sum_{u \in V} \big(1 - \sum_{v \in V} x_{uv}\big)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then we can add degree constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{ (u,v) \in A}x_{uv} \leq 1 \ \ \  \forall u \in V$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{ (v,u) \in A}x_{vu} \leq 1  \ \ \ \forall u \in V$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And then subtour elimination constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{ (u,v) \in S}x_{uv} \leq |S|-1  \ \ \ \forall S \subseteq A |\ S\textrm{ is a cycle}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with binary vars that select edges&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{uv} \in \{ 0,1 \} \ \ \ \forall (u,v) \in A$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I don't know how to properly break cycles except by manually checking them.&lt;/p&gt;&#xA;" OwnerUserId="10587" LastEditorUserId="67" LastEditDate="2022-10-21T19:46:04.807" LastActivityDate="2022-10-23T14:55:00.340" Title="Minimum Disjointed Path Cover ILP formulation" Tags="|modeling|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9166" PostTypeId="2" ParentId="9149" CreationDate="2022-10-20T15:54:15.147" Score="3" Body="&lt;p&gt;You might want to check out the &lt;a href=&quot;https://onlinelibrary.wiley.com/journal/15404609&quot; rel=&quot;nofollow noreferrer&quot;&gt;Decision Sciences Journal of Innovative Education&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-20T15:54:15.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9167" PostTypeId="2" ParentId="9163" CreationDate="2022-10-20T16:02:28.653" Score="3" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$\ell \le a \le b \le u$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; are constants.  Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$y^-$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^+$&lt;/span&gt;, and impose the following linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\ell y^- + a y + b y^+ \le x \le a y^- + b y + u y^+ \\&#xA;y^- + y + y^+ = 1$$&lt;/span&gt;&#xA;If you want to avoid the ambiguity at &lt;span class=&quot;math-container&quot;&gt;$x=a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x=b$&lt;/span&gt;, introduce a small constant &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; and instead impose&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\ell y^- + a y + (b + \epsilon) y^+ \le x \le (a - \epsilon) y^- + b y + u y^+ \\&#xA;y^- + y + y^+ = 1$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-10-20T16:29:40.537" LastActivityDate="2022-10-20T16:29:40.537" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9168" PostTypeId="2" ParentId="9137" CreationDate="2022-10-20T17:42:27.507" Score="3" Body="&lt;p&gt;According to a colleague in supply chain management (who is not 100% confident in his answer), the phrase &amp;quot;transport order&amp;quot; frequently (usually?) means an order to move stock from one facility to another within the same company (meaning there is no purchase or sale involved).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-20T17:42:27.507" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9169" PostTypeId="1" AcceptedAnswerId="9171" CreationDate="2022-10-20T20:00:19.533" Score="5" ViewCount="377" Body="&lt;p&gt;I am following this tutorial to learn column generation.&#xA;`&#xA;&lt;a href=&quot;https://co-at-work.zib.de/slides/Donnerstag_24.9/cgbpdw-coatwork-annotated.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://co-at-work.zib.de/slides/Donnerstag_24.9/cgbpdw-coatwork-annotated.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have a couple of questions I thought someone experienced in this topic could help me understand.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;How are the initial columns selected for the restricted master problem (RMP)?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After solving the restricted master problem and obtaining dual variables, do we compute the reduced cost of the other variables that were not included in the RMP or all variables? This applies to pricing problems too. Does the pricing problem include all variables or only the variables that were not included in the RMP?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Here are the slides that describes column generation and pricing problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kcn0z.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kcn0z.png&quot; alt=&quot;![enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rrWmJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rrWmJ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/UpiDE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UpiDE.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7wpuH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7wpuH.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3288" LastEditorUserId="491" LastEditDate="2022-10-21T01:45:59.850" LastActivityDate="2022-10-21T01:45:59.850" Title="Reduced cost in column generation" Tags="|column-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9170" PostTypeId="1" CreationDate="2022-10-20T20:57:55.393" Score="3" ViewCount="149" Body="&lt;p&gt;I am trying to write down the steps in Benders decomposition for the Fixed Charge Transportation Problem and was hoping someone could confirm/deny whether my understanding of it is correct. The original problem is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\newcommand{\mc}[1]{\mathcal{#1}}&#xA;\begin{align*}&#xA;  \min~&amp;amp;\sum_{i\in \mc{I}}\sum_{j\in \mc{J}}c_{ij}x_{ij}+\sum_{i\in \mc{I}}\sum_{j\in \mc{J}}f_{ij}y_{ij}&amp;amp;\\&#xA;  \text{s.t.}~&amp;amp;\sum_{j\in \mc{J}}x_{ij} \leq S_i&amp;amp; i\in \mc{I}\\&#xA;       &amp;amp;\sum_{i\in \mc{I}}x_{ij} \geq D_j&amp;amp; j\in \mc{J}\\&#xA;       &amp;amp;x_{ij}\leq u_{ij}y_{ij}&amp;amp;  i\in\mc{I}, j\in \mc{J}\\&#xA;       &amp;amp;y_{ij}\in\{0,1\},x_{ij}\geq 0&amp;amp; i\in \mc{I}, j\in\mc{J}.&#xA;\end{align*}&#xA;$$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$u_{ij}=\min(S_i,D_j)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables are complicating, thus the master problem becomes&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;    \min &amp;amp;\sum_{i\in\mathcal{I}}\sum_{j\in\mathcal{J}}f_{ij}y_{ij} + \alpha\\&#xA;    &amp;amp;y_{i,j}\in \{0,1\}\hspace{25pt} i=1,2,...,I,j=1,2,...,J\\&#xA;    &amp;amp;\alpha \geq 0&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With the subproblem being&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;    \alpha(y) = &amp;amp;\min \sum_{i\in \mc{I}}\sum_{j\in \mc{J}}c_{ij}x_{ij}\\&#xA;    &amp;amp;\sum_{j\in \mc{J}}x_{ij} \leq S_i \hspace{25pt} (\tau_i)&amp;amp; i\in \mc{I}\\&#xA;    &amp;amp;\sum_{i\in \mc{I}}x_{ij} \geq D_j \hspace{25pt} (\phi_j)&amp;amp; j\in \mc{J}\\&#xA;    &amp;amp;x_{ij}\leq u_{ij}y_{ij} \hspace{25pt} (\psi_{ij})&amp;amp;  i\in\mc{I}, j\in \mc{J}\\&#xA;    &amp;amp;x_{ij}\geq 0&amp;amp; i\in \mc{I}, j\in\mc{J}&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where I have put in parentheses the dual variables to the constraints. Is it then correct that if the subproblem is infeasible we will add a cut to the master problem that is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;    \sum_{i\in\mathcal{I}}\tau_iS_i + \sum_{j\in\mathcal{J}}\phi_jD_j + \sum_{i\in\mathcal{i}}\sum_{j\in\mathcal{J}}\psi_{ij}u_{ij}y_{ij}\leq0&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and if it feasible but the solution is not optimal in the original problem, then an optimality cut will be added:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;    \sum_{i\in\mathcal{I}}\tau_iS_i + \sum_{j\in\mathcal{J}}\phi_jD_j + \sum_{i\in\mathcal{i}}\sum_{j\in\mathcal{J}}\psi_{ij}u_{ij}y_{ij}\leq\alpha&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Am I understanding that right?&lt;/p&gt;&#xA;" OwnerUserId="10590" LastEditorUserId="500" LastEditDate="2022-10-20T22:54:38.583" LastActivityDate="2022-10-21T15:06:06.200" Title="Benders Decomposition for Fixed Charge Transportation Problem" Tags="|mixed-integer-programming|algorithms|benders-decomposition|decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9171" PostTypeId="2" ParentId="9169" CreationDate="2022-10-20T22:00:52.743" Score="5" Body="&lt;p&gt;You typically give the initial RMP enough columns to make it feasible. A common approach is to apply some heuristic or metaheuristic to the underlying problem and use the columns corresponding to the solution it provides (assuming the heuristic succeeds in finding at least one solution). In some cases, there may be a problem-specific &amp;quot;obvious&amp;quot; feasible solution, so you can start with the columns employed by that solution.&lt;/p&gt;&#xA;&lt;p&gt;If you know all of &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; (highly unlikely in practice), in the pricing problem you evaluate &lt;span class=&quot;math-container&quot;&gt;$\bar{c}_j$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$j\in J\backslash J'.$&lt;/span&gt; You already know &lt;span class=&quot;math-container&quot;&gt;$\bar{c}_j$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$j\in J'$&lt;/span&gt; (and know that they are nonnegative) because those are the reduced costs in the final simplex tableau from solving the RMP. In practice, the pricing subproblem is typically some sort of LP, whose objective function is computed using &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; and whose solution and objective value are respectively a new column (in &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; but not &lt;span class=&quot;math-container&quot;&gt;$J'$&lt;/span&gt;) and the reduced cost of the corresponding variable &lt;span class=&quot;math-container&quot;&gt;$\lambda_j$&lt;/span&gt; that you will introduce in the master problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-20T22:00:52.743" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9172" PostTypeId="2" ParentId="9170" CreationDate="2022-10-20T23:04:11.870" Score="5" Body="&lt;p&gt;Yes, this looks correct.  For comparison, check out Erwin Kalvelagen's &lt;em&gt;&lt;a href=&quot;https://amsterdamoptimization.com/pdf/benders.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Benders Decomposition with GAMS&lt;/a&gt;&lt;/em&gt;, which uses an equality-constrained version of this fixed charge transportation problem for illustration.  Note that the equivalent dual LP is solved instead.  Also, he provides two sets of valid constraints on &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; that you can include a priori to strengthen the master problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i S_i y_{ij} &amp;amp;\ge D_j &amp;amp;&amp;amp;\text{for all $j$} \tag1\label1\\&#xA;\sum_j D_j y_{ij} &amp;amp;\ge S_i &amp;amp;&amp;amp;\text{for all $i$} \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Note that \eqref{2} assumes &lt;span class=&quot;math-container&quot;&gt;$\sum_i S_i = \sum_j D_j$&lt;/span&gt;, so omit \eqref{2} if that assumption is violated.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-10-21T15:06:06.200" LastActivityDate="2022-10-21T15:06:06.200" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9173" PostTypeId="2" ParentId="9128" CreationDate="2022-10-20T23:34:06.477" Score="-1" Body="&lt;p&gt;Ok, Stage=1: design&#xA;Capacity=200&#xA;Vars: f, b, e #or set of section&lt;/p&gt;&#xA;&lt;p&gt;Subject to:&lt;/p&gt;&#xA;&lt;p&gt;stage:1 designing&lt;/p&gt;&#xA;&lt;p&gt;2f+1.5b+e &amp;lt;= capacity&lt;/p&gt;&#xA;&lt;p&gt;Stage:2 booking&lt;/p&gt;&#xA;&lt;p&gt;Vars: sf1, sf2, sf3, sb1,...&lt;/p&gt;&#xA;&lt;p&gt;S[s,c] &amp;lt;= demand[s,c] v c € section, s€scenarios&lt;/p&gt;&#xA;&lt;p&gt;Linking stage 1 &amp;amp; stage 2 vars&lt;/p&gt;&#xA;&lt;p&gt;Sf[s,c] &amp;lt;= f...&lt;/p&gt;&#xA;&lt;p&gt;Stage 3: overbooking?&lt;/p&gt;&#xA;&lt;p&gt;unclear if each no show have joint&#xA;Probability, like 0.33*0.33 (probs for&#xA;Each scenario &amp;amp; no show)&#xA;Also if tickets sold limited by seats then where is overbooking?&lt;/p&gt;&#xA;" OwnerUserId="10576" LastEditorUserId="10576" LastEditDate="2022-10-20T23:38:44.093" LastActivityDate="2022-10-20T23:38:44.093" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9174" PostTypeId="1" AcceptedAnswerId="9175" CreationDate="2022-10-21T03:45:07.137" Score="6" ViewCount="3140" Body="&lt;p&gt;No single programming language will meet every need. However, there should be a language that most operations research scientists prefer to master.&lt;/p&gt;&#xA;&lt;p&gt;I have coded different algorithms in Matlab and Python so far, but they may not be fast enough in comparison to C++ or C#. I would like to learn a new programming language and want to ensure that I choose the most appropriate language. Please note that my expertise revolves around the applications of heuristics, metaheuristics, column generation, Benders decomposition and approximate dynamic programming.&lt;/p&gt;&#xA;&lt;p&gt;Please share your thought with me.&lt;/p&gt;&#xA;" OwnerUserId="5598" LastActivityDate="2023-08-10T12:41:26.610" Title="Ideal programming language for an operations researcher" Tags="|python|java|matlab|c#|" AnswerCount="8" CommentCount="7" FavoriteCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9175" PostTypeId="2" ParentId="9174" CreationDate="2022-10-21T06:02:51.413" Score="16" Body="&lt;p&gt;For modelling, mainly Python. Julia works too but is much less commonly used in companies.&lt;/p&gt;&#xA;&lt;p&gt;For dedicated algorithm implementations, mainly C++. C works too but will require more lines of code and development time. Rust works too but is much less commonly used in companies.&lt;/p&gt;&#xA;&lt;p&gt;In academia, the goal is to develop the most efficient algorithms and it is usually possible to choose which language to use. In industry, the choice of the language might be imposed by the client anyway; or might depend on how easy it will be to find people to develop and maintain the project. In this case, Java is also common.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2022-10-21T06:08:07.117" LastActivityDate="2022-10-21T06:08:07.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9176" PostTypeId="2" ParentId="9174" CreationDate="2022-10-21T09:50:48.327" Score="6" Body="&lt;p&gt;This is an interesting debate. And key if you remember Sapir - Whorf theory (&amp;quot;linguistic categories influence perception&amp;quot;)&lt;/p&gt;&#xA;&lt;p&gt;You may use an Algebraic Modeling Language like AMPL or OPL or GAMS or you may choose a GPL General Programming Language like C++ or python.&lt;/p&gt;&#xA;&lt;p&gt;I discussed pros and cons at&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/pulse/optimization-aka-prescriptive-analytics-should-we-write-fleischer/&quot; rel=&quot;noreferrer&quot;&gt;Optimization (aka prescriptive analytics) : Should we write the model in a modeling language or a general programming language ?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;To see this on a &lt;a href=&quot;https://medium.com/p/cc04558e49b5&quot; rel=&quot;noreferrer&quot;&gt;small example&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;All options have advantages and issues.&lt;/p&gt;&#xA;&lt;p&gt;My favourite language to deal with OR problems : OPL that is linked to CPLEX&#xA;Second choice : python docplex&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yDVWq.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yDVWq.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;NB:&lt;/p&gt;&#xA;&lt;p&gt;I work for IBM&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-10-21T09:50:48.327" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9177" PostTypeId="1" CreationDate="2022-10-21T12:59:48.733" Score="3" ViewCount="102" Body="&lt;p&gt;I need to find a reasonable maximum for a linear programming problem, for which standard solvers for linear programming are just too slow. I was thinking of using projected gradient ascent, but do not know how to use it with my contraints.&lt;/p&gt;&#xA;&lt;p&gt;A toy example:&#xA;For &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}=(x,y)$&lt;/span&gt; I want to find&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{(x,y)\in\mathbb{R}^2} \mathbf{c}^\top\mathbf{x}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$c=[5,3]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with the constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{bmatrix}&#xA;1&amp;amp;1 \\&#xA;5&amp;amp;1&#xA;\end{bmatrix}&#xA;\begin{bmatrix}&#xA;x \\&#xA;y&#xA;\end{bmatrix} \leq&#xA;\begin{bmatrix}&#xA;20 \\&#xA;50&#xA;\end{bmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The maximum for this problem is &lt;span class=&quot;math-container&quot;&gt;$f(7.5,12.5)=75$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Rewriting this for gradient ascent: The objective function &lt;span class=&quot;math-container&quot;&gt;$f(x_1,x_2)=5x+3y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\nabla f = [5,3]^T$&lt;/span&gt;. Using this, I want to do projected gradient ascent. My initial intuition was to scale &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt; back if they are outside the constraint area. However, this doesn't work. As you can see, it always converges to a suboptimal solution:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Qz839.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qz839.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;(Red and orange are my constraints, the dots are the path of my gradient ascent).&lt;/p&gt;&#xA;&lt;p&gt;Here is the code for the constraint and projection:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def constraint(x,y):&#xA;    return np.array([[1,1],[5,1]]) @ np.array([x,y])&#xA;&#xA;def projection(x,y):&#xA;    if np.all(constraint(x,y) &amp;lt;= np.array([20,50])):&#xA;        return np.array([x,y])&#xA;    v = np.array([x,y])&#xA;    Av = constraint(x,y)&#xA;    b = np.array([20,50]) &#xA;    sol = b/Av&#xA;    t = sol.min()&#xA;    return t*v&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10594" LastActivityDate="2022-10-21T12:59:48.733" Title="Projected Gradient Ascent for linear programming" Tags="|optimization|linear-programming|constraint|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9178" PostTypeId="2" ParentId="9164" CreationDate="2022-10-21T14:23:19.460" Score="4" Body="&lt;p&gt;Here's a compact, MTZ-based formulation.  In addition to your binary &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; variables, introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt; to indicate whether node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is a source or sink, respectively.  (A source is a node with no entering arcs, and a sink is a node with no leaving arcs.) Also let &lt;span class=&quot;math-container&quot;&gt;$u_i\in[0,|V|-1]$&lt;/span&gt; be the MTZ variable that represents when node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is visited.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in V} s_i$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{(i,j) \in A} x_{ij} - \sum_{(j,i) \in A} x_{ji}&#xA;    &amp;amp;= s_i - t_i&#xA;   &amp;amp;&amp;amp;\text{for $i \in V$} \tag1\label1 \\&#xA;      \sum_{(i,j) \in A} x_{ij} + t_i &amp;amp;= 1&#xA;   &amp;amp;&amp;amp;\text{for $i \in V$} \tag2\label2 \\&#xA;      u_i - u_j + 1 &amp;amp;\le |V| (1 - x_{ij})&#xA;   &amp;amp;&amp;amp;\text{for $(i,j) \in A$} \tag3\label3&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} enforces flow balance.&#xA;Constraint \eqref{2} covers every node exactly once.&#xA;Constraint \eqref{3} prevents subtours by enforcing the logical implication &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1 \implies u_i &amp;lt; u_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$(j,i)\in A$&lt;/span&gt;, you can strengthen \eqref{3} by lifting:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$u_i - u_j + 1 \le |V| (1 - x_{ij}) - (|V|-2)x_{ji}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-10-21T14:23:19.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9179" PostTypeId="2" ParentId="9164" CreationDate="2022-10-21T20:01:16.663" Score="2" Body="&lt;p&gt;I like the MTZ formulation, so I vote for Rob's model. That said, MTZ is sometimes a bit weak, hurting solution speed. So here are a couple of other possibilities (which I personally would try only if MTZ let me down).&lt;/p&gt;&#xA;&lt;p&gt;In the original formulation proposed, you can either add subtour elimination constraints for all possible cycles up front (practical only for really small graphs) or, if your solver supports callbacks, use a callback to inspect each candidate incumbent for any cycles and, when found, add the corresponding subtour elimination constraints (a &amp;quot;one tree logical Benders&amp;quot; approach).&lt;/p&gt;&#xA;&lt;p&gt;Benders is basically a &amp;quot;row generation&amp;quot; approach. You can also use column generation. Let &lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}$&lt;/span&gt; be respectively the set of all nodes and the set of all paths in the graph, let &lt;span class=&quot;math-container&quot;&gt;$\hat{\mathcal{P}}\subseteq \mathcal{P}$&lt;/span&gt; be some set of known paths, and let &lt;span class=&quot;math-container&quot;&gt;$a_{np}$&lt;/span&gt; be 1 if node &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is on path &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and 0 if not. Our master problem is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\min\sum_{p\in\hat{\mathcal{P}}}x_{p}\\&#xA;\textrm{s.t. }\sum_{p\in\hat{\mathcal{P}}}a_{np}x_{p} &amp;amp; =1\quad\forall n\in\mathcal{N}\\&#xA;x_{p} &amp;amp; \in\left\{ 0,1\right\} \quad\forall p\in\hat{\mathcal{P}}&#xA;\end{align*}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x_p$&lt;/span&gt; is an indicator for whether we use path &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and the lone constraint says that every node lives on exactly one chosen path. For a small graph, you can enumerate &lt;span class=&quot;math-container&quot;&gt;$\mathcal{P}$&lt;/span&gt; manually, set &lt;span class=&quot;math-container&quot;&gt;$\hat{\mathcal{P}}=\mathcal{P},$&lt;/span&gt; solve once and be done. For larger graphs, you can get an exact solution using branch-price-and-cut (starting with some arbitrary set &lt;span class=&quot;math-container&quot;&gt;$\hat{\mathcal{P}}$&lt;/span&gt; of paths sufficient to get a feasible solution and generating new paths on the fly in a pricing problem) or a heuristic solution by solving the LP relaxation of the master problem, using the dual values for the equation constraints to set prices in a path generating subproblem (looking for a path with a negative reduced cost in the master), adding any such path found to the master, and repeating until you don't find any more attractive paths. At that point, you restore integrality, solve the now IP master problem one last time, and hope for the best.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-21T20:01:16.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9180" PostTypeId="2" ParentId="9174" CreationDate="2022-10-21T21:42:58.927" Score="10" Body="&lt;p&gt;I am an academic who works on large projects in OR &amp;amp; power systems. This involves a mixture of machine learning (ML), optimization, data-processing, simulations, and more data processing. Our group uses Julia for optimization, simulation, and most of the data processing, and Python for ML.&#xA;I recently gave a &lt;a href=&quot;https://youtu.be/61fnHmri7_Q&quot; rel=&quot;nofollow noreferrer&quot;&gt;talk&lt;/a&gt; about the reasons why we chose Julia for optimization.&lt;/p&gt;&#xA;&lt;p&gt;Almost everyone I know in the academic world uses either C/C++, Julia or Python (I listed them in alphabetical order). In recent years, C++ seems to lose popularity (at least around me) in favor of Python and, to a large extent, Julia.&lt;br /&gt;&#xA;Almost no company I know uses Julia; there are a few, but TBH it's still a niche. As far as I know (remember I'm from academia), the more popular choices for in industry, for optimization, are C/C++, Java, and Python (also in alphabetical order). I believe most ML is done in Python nowadays.&lt;/p&gt;&#xA;&lt;p&gt;In terms of ecosystems, I find Julia (and &lt;a href=&quot;https://jump.dev/&quot; rel=&quot;nofollow noreferrer&quot;&gt;JuMP&lt;/a&gt; in particular) to have the broadest, most performant and best-documented support for (MI)LP, (MI)-conic/convex and (MI)NLP. The fact I don't have to manually install external solvers is a godsend (I wouldn't know how to compile C/C++ code). In Python, you will find a few open-source modeling tools like pyomo, plus each solver's own modeling layer. Commercial solvers have better support for their C++ and python APIs than in Julia (likely because few people both use Julia and pay for the licenses).&lt;/p&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="4507" LastEditDate="2022-10-22T21:26:46.840" LastActivityDate="2022-10-22T21:26:46.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9181" PostTypeId="2" ParentId="9174" CreationDate="2022-10-21T22:03:23.880" Score="5" Body="&lt;p&gt;Operations research covers a lot of territory. Most of the answers posted are oriented toward optimization, which is fine but a bit limited. For analytics / data analysis, the two most popular languages seem to be Python and R. For simulation, you might use either Python or R, but you might also want to use a dedicated simulation package. So I'm not sure any one language suffices. (For the record, I use Java most things and R for some things.)&lt;/p&gt;&#xA;&lt;p&gt;One thing to keep in mind is that, regardless of your choice of language, it is likely you will leave the &amp;quot;heavy lifting&amp;quot; to library packages or third party (likely commercial) programs. So the bulk of the computation time will probably be spent in some code that you did not write. If your work involves substantial processing of inputs before running your model or substantial processing of outputs after running it, you may want a language that is fast (many would say C or C++, although Java is I think not too far behind these days). Otherwise, I think it is better to pick a language in which you will be productive (comfortable using it, less prone to coding errors, more likely to adequately document the code, ...) and not worry too much about the computational speed.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-21T22:03:23.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9183" PostTypeId="2" ParentId="5764" CreationDate="2022-10-22T11:44:10.760" Score="2" Body="&lt;p&gt;There is no reason for dealing the situation differently where your cycle period is shorter than your lead time. Your ordering strategy uses the inventory position as the state variable to describe your inventory system. This means there will always be multiple orders outstanding but you don't need to deviate from your ordering strategy (e.g. order cycles in advance). When you are dealing with a higher degree of complexity (e.g. perishability), this change of assumption dóes changes things.&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2022-10-22T14:35:00.933" LastActivityDate="2022-10-22T14:35:00.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9184" PostTypeId="2" ParentId="9174" CreationDate="2022-10-22T12:20:41.640" Score="4" Body="&lt;p&gt;Like said in the other answers, first of all, OR covers a big territory. And then you have the business side of things where you are often bounded to certain languages and tools.&lt;/p&gt;&#xA;&lt;p&gt;I think it is useful to have a default programming language to go to (e.g. Python) and find different OR-problems and how to solve them via that language. Look at the solution of the packages you use and try to find the abstract representation of these solutions. Probably most packages have very similar representations. This way, you get familiar in solving OR-problems in practice and when bounded to a certain language, other then your go-to language, you can probably rapidly find the right package and the way to implement it.&#xA;At least, that's my experience.&lt;/p&gt;&#xA;&lt;p&gt;When you have an OR-problem that can't be solved with your go-to language, you can look for other languages. But I feel that languages like Python &amp;amp; Julia have almost everything covered.&lt;/p&gt;&#xA;" OwnerUserId="329" LastActivityDate="2022-10-22T12:20:41.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9185" PostTypeId="2" ParentId="9128" CreationDate="2022-10-22T14:23:43.787" Score="2" Body="&lt;p&gt;Ok, my last post for this Q perhaps:&#xA;regarding: update 2, Stage 3, you can introduce a recourse variable, a random variable for each section to capture overbooking like:&lt;/p&gt;&#xA;&lt;p&gt;S[s,c] - c &amp;gt;= O[c] where O[c] is overbooking for section c, c = [F,B,E], s=scenarios &amp;amp; S[s,c] is ticket sales for scenario s.&#xA;Similar to Oscar's.&lt;/p&gt;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&lt;p&gt;Remove this constraint in stage 2:&#xA;S[s,c] &amp;lt;= c, since the assumption of bookings limited to seat capacity will no longer exit, add Constraint&lt;/p&gt;&#xA;&lt;p&gt;S[s,c] &amp;gt;= c and so for Stage 3:&lt;/p&gt;&#xA;&lt;p&gt;Overbooking = S[s,c]-c&lt;/p&gt;&#xA;&lt;p&gt;With no-show into account, add a Penalty like:&lt;/p&gt;&#xA;&lt;p&gt;P[c]&lt;em&gt;(0.5&lt;/em&gt;S[s,c] - c), where P[c] is penalty for section c.&#xA;Penalty for airline will be for ticket holders who are still in excess of capacity for each section even after no-shows. Also there's no assumption of excess passengers being upgraded.&lt;/p&gt;&#xA;&lt;p&gt;Also, since its Stage 3 depending upon Stage 2&#xA;Joint probability for 50% no-show for Scenario 1 is: 0.33*0.5&lt;/p&gt;&#xA;&lt;p&gt;So Total Penalty =&lt;/p&gt;&#xA;&lt;p&gt;Sum of (0.33)&lt;em&gt;(0.5)&lt;em&gt;P[c]&lt;/em&gt;(0.5&lt;/em&gt;S[s,c]-c) for all s &amp;amp; c&lt;/p&gt;&#xA;&lt;p&gt;Objective = Total Ticket Price - Total Penalty&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-10-22T23:14:22.097" LastActivityDate="2022-10-22T23:14:22.097" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9186" PostTypeId="2" ParentId="9174" CreationDate="2022-10-22T14:59:00.780" Score="6" Body="&lt;p&gt;&lt;strong&gt;Gretzky: Skate to where the puck is going to be.&lt;/strong&gt;  Or in this case, pucks, Julia being one of the pucks..&lt;/p&gt;&#xA;&lt;p&gt;Putting on my O.R. hat and viewing language usage as a dynamic system, Julia is on a significant upward trajectory in academia. The increasing number of undergraduate and graduate students using Julia in school seems likely to lead, with some lag, to increasing use in industry. Yes, some of these students who eagerly arrive at their new workplace, bright-eyed and bushy-tailed, wanting to use Julia at work, will confront the harsh reality of being forced to use other language(s). But given the increasing flow of Julia users/enthusiasts into the workplace, they are bound to break through. And once they start to do so in a meaningful way, Julia usage could start to pick up quickly in industry.  Knee of the curve, and all that.&lt;/p&gt;&#xA;&lt;p&gt;I say this as primarily a MATLAB user (yes, I'm a dinosaur). But MATLAB was the new language I increasingly switched to from FORTRAN and various defunct Algol derivatives and other dead languages, and C,  which I was forced to use for various things (and back in 1982, I had to grade stochastic simulation homework, with some of the programs written in Pascal, even though I didn't know Pascal).  BTW, MATLAB is still heavily used for design analysis and algorithm prototyping at some very large companies in the engineering arena, even though for real-time use, algorithms are generally implemented in an appropriate language (and that's not usually Python).&lt;/p&gt;&#xA;&lt;p&gt;This answer is meant to be complementary to the existing excellent answers.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-10-22T17:30:20.587" LastActivityDate="2022-10-22T17:30:20.587" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9187" PostTypeId="1" CreationDate="2022-10-22T20:55:24.383" Score="5" ViewCount="110" Body="&lt;p&gt;I am not too familiar with variants of knapsack problems (or variants of possibly other classical OR problems), but I would like to identify the following Integer Programming problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x_i,y_{i,j}} \sum_i c_i x_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to  &lt;span class=&quot;math-container&quot;&gt;$$\sum_i y_{i,j} \le s_j \  \forall j $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i u_{i,j} y_{i,j} \ge v \  \forall j $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{i,j} \le x_i \  \forall j $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i,y_{i,j} \in \{0,1\}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Does this integer program belong to some sorts of variants of famous problems?&lt;/p&gt;&#xA;" OwnerUserId="10606" LastEditorUserId="500" LastEditDate="2022-10-24T02:29:22.700" LastActivityDate="2022-10-24T02:29:22.700" Title="Identifying the variant of such a knapsack-like problem" Tags="|mixed-integer-programming|integer-programming|knapsack|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9188" PostTypeId="2" ParentId="9187" CreationDate="2022-10-22T23:40:12.980" Score="3" Body="&lt;p&gt;Looks like a variant of the &lt;em&gt;minimum-weight multiset multicover problem&lt;/em&gt; with the additional restriction that the required copies of item &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; must be coverable by at most &lt;span class=&quot;math-container&quot;&gt;$s_j$&lt;/span&gt; chosen multisets &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.  What is the source of your problem?&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-10-22T23:40:12.980" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9189" PostTypeId="2" ParentId="9164" CreationDate="2022-10-23T04:57:54.177" Score="3" Body="&lt;p&gt;Two more alternative solution approaches:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Approach 1&lt;/strong&gt; - convert problem to Vehicle routing problem.&lt;/p&gt;&#xA;&lt;p&gt;Add a dummy vertex to the graph representing the depot. Add outgoing and incoming arcs from/to the depot to every other vertex. Solve the problem as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Vehicle_routing_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;vehicle routing problem&lt;/a&gt;. When solving the VRP, minimize the number of routes (&lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;) instead of the total arc cost. Once a solution is obtained, remove the depot and the resulting paths form a Minimum disjoint path cover. Note that, when solving the VRP, you can simply separate the stronger DFJ subtour constraints, so you don't have to rely on the MTZ constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Approach 2&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Construct an auxiliary undirected graph &lt;span class=&quot;math-container&quot;&gt;$G'$&lt;/span&gt; as follows. For every vertex &lt;span class=&quot;math-container&quot;&gt;$i\in V$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;, add two vertices &lt;span class=&quot;math-container&quot;&gt;$i^1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i^2$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$G'$&lt;/span&gt;. For every arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in A$&lt;/span&gt; in graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;, add undirected edge &lt;span class=&quot;math-container&quot;&gt;$(i^1,j^2)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$G'$&lt;/span&gt;. A Minimum disjoint path cover can now be found  by solving a maximum matching in &lt;span class=&quot;math-container&quot;&gt;$G'$&lt;/span&gt;. Proof: see &lt;a href=&quot;https://courses.engr.illinois.edu/cs473/sp2017/notes/11-maxflowapps.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chapter 11&lt;/a&gt; of the book 'Algorithms' by Jeff Erickson.&lt;/p&gt;&#xA;&lt;p&gt;To solve the max matching problem, you could use a MIP formulation, but in general a dedicated algorithm for the max matching problem is significantly faster(see: &lt;a href=&quot;https://doi.org/10.1145/3381449&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dimitrios, Kinable, et al. 2020. JGraphT—A Java Library for Graph Data Structures and Algorithms. ACM Trans. Math. Softw. 46, 2.&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Final remark: if the input graph is a Directed Acyclic Graph (DAG), you can obtain the desired cover by solving a minimum flow problem.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2022-10-23T14:55:00.340" LastActivityDate="2022-10-23T14:55:00.340" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9190" PostTypeId="1" CreationDate="2022-10-23T10:12:48.130" Score="2" ViewCount="61" Body="&lt;p&gt;Usually, the modeling involves those steps :&lt;/p&gt;&#xA;&lt;p&gt;Fuzzy Description ----(1)----&amp;gt; Clearer Description -----(2)-----&amp;gt; Mathematical model.&lt;/p&gt;&#xA;&lt;p&gt;Of course, it's not linear and a lot of iteration and re-modeling is involved.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for resources on the (1) part. How to do the problem discovery? How to ask the customer the right questions? Are there some tools/methods that help with that? etc.&lt;/p&gt;&#xA;&lt;p&gt;It's more like the soft aspects of modelling and not about writing mathematical equations down.&lt;/p&gt;&#xA;" OwnerUserId="7222" LastEditorUserId="491" LastEditDate="2022-10-24T02:02:41.000" LastActivityDate="2022-10-24T02:02:41.000" Title="Resources on the soft aspects of modelling" Tags="|modeling|applications|or-careers|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9191" PostTypeId="1" AcceptedAnswerId="9193" CreationDate="2022-10-23T13:56:06.670" Score="2" ViewCount="113" Body="&lt;p&gt;I am implementing a &lt;strong&gt;Stochastic Dual Dynamic Programming (SDDP)&lt;/strong&gt; algorithm for multi-stage linear stochastic program. To validate the solution by SDDP, I also implemented an extensive form (deterministic equivalent, DE) based on discrete scenario tree. However, it turns out that the SDDP solution is different from DE's, even when SDDP draws samples from the scenario tree for DE.&lt;/p&gt;&#xA;&lt;p&gt;In each &lt;em&gt;Forward Simulation&lt;/em&gt; process, a sample path is randomly drawn from the scenario tree. In each &lt;em&gt;Backward Recursion&lt;/em&gt; process, all the possible sample paths are used for cuts generation.&#xA;I calculated the SDDP lower bound (LB) as in &lt;a href=&quot;https://doi.org/10.1007/BF01582895&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1007/BF01582895&lt;/a&gt;. To be brief, the LB is the initial stage objective + estimator (bounded by &lt;em&gt;cuts&lt;/em&gt; added) of the future expected costs.&#xA;I calculated the SDDP upper bound (UB) by recursively solving problems from stage 0 to T with all the possible sample paths from the scenario tree. The UB is calculated as the expected cost over all the possibilities.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My questions are:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Should I expect the SDDP UB (based on my definition) to be equal to DE's objective?&lt;/li&gt;&#xA;&lt;li&gt;If not 1, what is the possible relationship between SDDP's LB and UB with DE's objective?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2022-10-23T21:08:28.580" Title="Does SDDP converge to the deterministic equivalent objective when the underlying scenario tree is the same?" Tags="|sddp|stochastic-dual-dynamic-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9192" PostTypeId="1" CreationDate="2022-10-23T19:37:54.190" Score="2" ViewCount="112" Body="&lt;p&gt;Assume I have the following convex optimization problem, with a convex objective function on conventional non-negativity constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} &#xA;    \min_{x \geq 0}  \sum_{i=1}^{I} a_{i}x_{i}  - f(\bf{x}),&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\bf{x}$&lt;/span&gt; is a vector of dimension I, &lt;span class=&quot;math-container&quot;&gt;$f(\bf{x})$&lt;/span&gt; is a concave function, and the dimension of &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is very large. The solution is sparse, meaning that in the optimal vector there is a large amount of zeros. This comes from the fact that for some entries &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;a_{i} &amp;gt; f_{i}(\bf{x}^{*})&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$f_{i}(\bf{x})$&lt;/span&gt; corresponds to &lt;span class=&quot;math-container&quot;&gt;$\partial f(\bf{x}^{*})/x_{i}$&lt;/span&gt;. Since the function is convex, I know that the KKT conditions are necessary and sufficient for global optimality, all local optima are also global, and the set of solutions is convex.&lt;/p&gt;&#xA;&lt;p&gt;However, I have questions about how to solve for the optimum numerically,&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If I use a Projected Gradient Method, I have seen on the internet that the projection step of the algorithm is just&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x^{k+1} = \max\left\{0,x^{k}-\alpha_{k}(a-\nabla f(x^{k}))\right\} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, I have not found a proof or a paper that shows this. Can someone provide a proof or reference?&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;The other option is to use Interior-Point methods. However, what confuses me in this case is that when one uses barrier methods, how does it work if the solution is not interior, but in the boundary for some entries?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10612" LastEditorUserId="10612" LastEditDate="2022-10-24T12:36:57.437" LastActivityDate="2022-10-24T14:12:16.980" Title="Convex Optimization, Non-negativity constraints, Interior-Point or Projected Gradient?" Tags="|nonlinear-programming|convex-optimization|interior-point-method|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9193" PostTypeId="2" ParentId="9191" CreationDate="2022-10-23T21:08:28.580" Score="2" Body="&lt;p&gt;Once converged, the objective of the first-stage problem in SDDP (if minimizing, this is your SDDP lower bound) will equal the objective value of the deterministic equivalent. In theory, if you can simulate every possible scenario, then the mean of those simulation values (if minimizing, this is your SDDP upper bound) will also equal the deterministic equivalent objective value. But usually there are too many scenarios to simulate, so you get a statistical estimate for the upper bound.&lt;/p&gt;&#xA;&lt;p&gt;Having said that, the &lt;em&gt;in theory&lt;/em&gt; part is important. There are a variety of computational reasons why, when simulated, you might not recover the same objective value, but that's a much longer explanation. Moreover, everything I have said relates &lt;strong&gt;only&lt;/strong&gt; to the first stage objective value. The state and control variables may be different, and the objective values deeper in the tree may also be different.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I am implementing a Stochastic Dual Dynamic Programming (SDDP) algorithm for multi-stage linear stochastic program.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I general, I would encourage you not to code your own implementation of the algorithm. As you're probably starting to find, it's really tricky to get right.&lt;/p&gt;&#xA;&lt;p&gt;Use an (shameless self-promotion) general purpose implementation like: &lt;a href=&quot;https://github.com/odow/SDDP.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/odow/SDDP.jl&lt;/a&gt;. It is battle-tested, and implements a much greater bag of tricks than the classical T-stage linear SDDP.&lt;/p&gt;&#xA;&lt;p&gt;If you do decide to keep coding your own algorithm, SDDP.jl has a number of tutorials that might be helpful: &lt;a href=&quot;https://odow.github.io/SDDP.jl/stable/tutorial/theory/21_theory_intro/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://odow.github.io/SDDP.jl/stable/tutorial/theory/21_theory_intro/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2022-10-23T21:08:28.580" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9194" PostTypeId="2" ParentId="9163" CreationDate="2022-10-24T04:18:51.240" Score="1" Body="&lt;p&gt;I can think of:&lt;/p&gt;&#xA;&lt;p&gt;a &amp;lt;= xy, since a/x will b smaller than 1, so y ==1.&lt;/p&gt;&#xA;&lt;p&gt;Similarly, x &amp;lt;= by.&lt;/p&gt;&#xA;&lt;p&gt;If want to avoid bilinear terms then z+y =1, then&#xA;az &amp;lt;= x&lt;/p&gt;&#xA;&lt;p&gt;If it's AND situation which means both have to be true:&lt;/p&gt;&#xA;&lt;p&gt;a &amp;lt;= xy1&lt;/p&gt;&#xA;&lt;p&gt;x &amp;lt;= by2&lt;/p&gt;&#xA;&lt;p&gt;both y1 &amp;amp; y2 are binary followed by&lt;/p&gt;&#xA;&lt;p&gt;2y &amp;lt;= y1+y2&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-10-24T15:21:04.383" LastActivityDate="2022-10-24T15:21:04.383" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9195" PostTypeId="1" AcceptedAnswerId="9196" CreationDate="2022-10-24T09:05:09.300" Score="4" ViewCount="299" Body="&lt;p&gt;I was going through the Shapley-Folkman-Starr Lemma (&lt;a href=&quot;https://simons.berkeley.edu/sites/default/files/docs/3605/simons2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://simons.berkeley.edu/sites/default/files/docs/3605/simons2.pdf&lt;/a&gt;) and I came across the term &amp;quot;endowment&amp;quot; of an agent.&lt;/p&gt;&#xA;&lt;p&gt;My assumption is that it represents a (sub)set of the agent's preferred bundles. Could someone please clarify this term?&lt;/p&gt;&#xA;" OwnerUserId="6063" LastEditorUserId="500" LastEditDate="2022-10-24T14:39:42.730" LastActivityDate="2022-10-25T02:58:32.303" Title="Endowment of an agent" Tags="|nonconvex-programming|terminology|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9196" PostTypeId="2" ParentId="9195" CreationDate="2022-10-24T11:25:45.020" Score="5" Body="&lt;p&gt;&lt;em&gt;Endowment&lt;/em&gt; is a term from economics. It is the (initial) amount of goods (or factors depending on the type of agent) an agent possesses. In models, this is an exogenous value (constant). Usually, there are different types of goods, so for each agent this is a vector. Of course, in many models, this agent starts trading (or producing) with this.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2022-10-25T02:58:32.303" LastActivityDate="2022-10-25T02:58:32.303" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9197" PostTypeId="2" ParentId="9192" CreationDate="2022-10-24T13:30:28.807" Score="1" Body="&lt;p&gt;If a lot of variables are on their bounds at optimality, you may be well-served by an active-set method such as Sequential Quadratic Programming (SQP). Because your constraints are all linear (and all simple bound constraints at that), there is none of the drama SQP methods have to deal with when linearizing constraints.&lt;/p&gt;&#xA;&lt;p&gt;A nullspace version of SQP, sometimes called Reduced Hessian, could be especially effective if the number of active constraints at optimality is high, i.e., variables on their bound of zero. Nullspace (a.k.a. Reduced Space a.k.a. Reduced Hessian) methods form and update the Hessian of free variables, i.e., variables not on bound (given your problem only has bound constraints).  So if your problem has 100,000 variables, of which 99,000 are at zero (on their bound), the Nullspace method works with a 1000 by 1000 Hessian, and solves Quadratic Programming (QP) subproblems of dimension 1000. As the algorithm proceeds, variables might go on or off their bound. At each iteration, only the non-zero variables are &amp;quot;in&amp;quot; the Hessian and corresponding QP subproblem whose &amp;quot;quadratic&amp;quot; matrix is the Hessian in that reduced space of non-zero variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gams.com/latest/docs/S_SNOPT.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;SNOPT&lt;/a&gt; is a well-known solver implementing a Nullsapce (Reduced Hessian) SQP algorithm, and can be quite effective on very large problems, if the number of free variables (non-zero variables in your case) is (relatively) small. Generally speaking, the better your starting values (initial guess) is of which variables will be non-zero at optimality, the faster the algorithm will converge to the optimum solution.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-10-24T14:12:16.980" LastActivityDate="2022-10-24T14:12:16.980" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9198" PostTypeId="1" AcceptedAnswerId="9199" CreationDate="2022-10-24T20:12:04.667" Score="1" ViewCount="1231" Body="&lt;p&gt;I am using Pyomo. I got successes in setting up options for Cbc and scip solvers as shown below. But I am unable to figure out how to set up TIME LIMIT and MIP Relative Gap limit for GLPK solver after my researches. Does anyone know how to set those options up for GLPK in Pyomo such that when either of these limits reached, we can still get the best solutions out?&lt;/p&gt;&#xA;&lt;p&gt;import pyomo.environ as pe&lt;/p&gt;&#xA;&lt;p&gt;opt = pe.SolverFactory(Pyomo_Solver)&lt;/p&gt;&#xA;&lt;p&gt;if (Pyomo_Solver == 'cbc'):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; opt.options ={ 'sec':60, 'ratio': 0.0001  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;elif (Pyomo_Solver == 'scip'):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; opt.options ={ 'limits/time':60,  'limits/gap': 0.0001 }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;elif (Pyomo_Solver == 'glpk'):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; opt.options ={ ????}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;results = opt.solve(model, tee=True, symbolic_solver_labels=True )&lt;/p&gt;&#xA;" OwnerUserId="10586" LastActivityDate="2022-10-24T22:05:35.090" Title="Pyomo (GLPK): How to set up options with TIME LIMIT or Relative Gap Limit?" Tags="|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9199" PostTypeId="2" ParentId="9198" CreationDate="2022-10-24T22:05:35.090" Score="1" Body="&lt;p&gt;You can see all the options by running, at a command prompt:&#xA;glpsol --help&lt;/p&gt;&#xA;&lt;p&gt;The time limit and mip gap options are tmlim and mipgap respectively.&lt;/p&gt;&#xA;" OwnerUserId="5128" LastActivityDate="2022-10-24T22:05:35.090" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9200" PostTypeId="1" CreationDate="2022-10-25T04:12:38.523" Score="-2" ViewCount="87" Body="&lt;p&gt;We want to arrange 8 tables in 2 rooms. How to write the following constraints?&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Either table 3 or table 6 must be in room 1 (or both).&lt;/li&gt;&#xA;&lt;li&gt;Exactly one of tables 7 and 8 must be in room 2.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10596" LastActivityDate="2022-10-25T12:12:31.870" Title="constraints for a zero-one integer programming problem" Tags="|optimization|integer-programming|combinatorial-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9201" PostTypeId="2" ParentId="9200" CreationDate="2022-10-25T10:11:20.113" Score="3" Body="&lt;p&gt;With OPL CPLEX Mathematical Programming you can write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// We want to arrange 8 tables in 2 rooms.&#xA;&#xA;range tables=1..8;&#xA;range rooms=1..2;&#xA;&#xA;dvar boolean x[tables][rooms];&#xA;&#xA;subject to&#xA;{&#xA;  &#xA;  forall(t in tables) sum(r in rooms) x[t][r]==1;&#xA;&#xA;    //Either table 3 or table 6 must be in room 1 (or both).&#xA;    x[3][1]+x[6][1]&amp;gt;=1;&#xA;    &#xA;    //Exactly one of tables 7 and 8 must be in room 2.&#xA;    sum(t in 7..8) x[t][2]==1;&#xA;    &#xA;}   &#xA;&#xA;{int} tablesPerRoom[r in rooms]={i | i in tables : x[i][r]==1};&#xA;&#xA;execute&#xA;{&#xA;  writeln(tablesPerRoom);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which can give&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[{1 2 3 4 5 6 8} {7}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Within CPLEX you can also rely on Constraint Programming CPOptimizer. Then you can write &amp;quot;using CP&amp;quot;; at the beginning of the model.&lt;/p&gt;&#xA;&lt;p&gt;Or within CPOptimizer you can rely on specific CP constraints and write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using CP;&#xA;&#xA;// We want to arrange 8 tables in 2 rooms.&#xA;&#xA;range tables=1..8;&#xA;range rooms=1..2;&#xA;&#xA;dvar int x[tables] in rooms;&#xA;&#xA;subject to&#xA;{&#xA;  &#xA;  &#xA;&#xA;    //Either table 3 or table 6 must be in room 1 (or both).&#xA;    (x[6]==1)||(x[3]==1);&#xA;    &#xA;    //Exactly one of tables 7 and 8 must be in room 2.&#xA;    count(all(i in 7..8)x[i],2)==1;&#xA;    &#xA;}   &#xA;&#xA;&#xA;&#xA;execute&#xA;{&#xA;  writeln(x);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which can give&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[1 1 2 1 1 1 1 2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastEditorUserId="627" LastEditDate="2022-10-25T12:12:31.870" LastActivityDate="2022-10-25T12:12:31.870" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9202" PostTypeId="1" CreationDate="2022-10-25T14:32:09.663" Score="1" ViewCount="101" Body="&lt;p&gt;I need to find optimum weekly targets for an 8-week period for a group of employees. The end result expected is maximum of sum of percentage of times the employees met the goal in each week.  I am doing the &amp;quot;percentage met&amp;quot; calculation on a dataset containing past performance of employees on the tasks.&lt;/p&gt;&#xA;&lt;p&gt;My decision variable is the weekly improvement percentage (weekly_share). This will reduce the existing goals by the said percentage in each week, starting from 10% in Week 1 and ending at 100% in Week 8.&lt;/p&gt;&#xA;&lt;p&gt;For each week, percentage of meeting revised goal calculated using&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;weekly improvement= 100 x (count of Tasks Completed x 3600) / (Total work time in week x existing goal x weekly_share)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I wanted to maximize the sum of these percentages for all 08 weeks&lt;/p&gt;&#xA;&lt;p&gt;I have set the following constraints:&#xA;a)  for week 1, weekly_share&amp;gt;= 10%&#xA;b)  for all weeks from 2-8, weekly_share &amp;gt;= weekly_share in previous week (week 2&amp;gt;= week 2, etc)&#xA;c)  weekly_share for 8th week = 100%&lt;/p&gt;&#xA;&lt;p&gt;When using Excel Solver, I do not get a solution in Simplex LP (error in either objective or constraint cell). With GRG Nonlinear and Evolutionary, the weekly_share are set to the lower limit (since it is in the denominator, the lowest value gives the highest ratio).&lt;/p&gt;&#xA;&lt;p&gt;How can I solve this?&lt;/p&gt;&#xA;" OwnerUserId="10625" LastActivityDate="2022-10-26T13:06:34.980" Title="Optimization of Weekly Productivity Goals" Tags="|optimization|linear-programming|excel|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9203" PostTypeId="1" CreationDate="2022-10-25T17:18:49.667" Score="1" ViewCount="123" Body="&lt;p&gt;I am trying to create an optimizing model for a roadtrip:&#xA;10 cities in 14 weeks.&lt;/p&gt;&#xA;&lt;p&gt;For each city I have:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a distance matrix to every city&lt;/li&gt;&#xA;&lt;li&gt;The rain for every week of the year&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;My goal is to minimize the traveling distance and the rain for each stop.&lt;/p&gt;&#xA;&lt;p&gt;I already have a gurobi model but it has difficulties for the weeks without a new city: 1: Paris, 2: nothing, 3: Rome —&amp;gt; Traveling distance = 0 because D(Paris,nothing) = 0&lt;/p&gt;&#xA;&lt;p&gt;Edit for a better understanding:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;My rain map has the following structure:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;week&lt;/th&gt;&#xA;&lt;th&gt;city1_rain_in_mm&lt;/th&gt;&#xA;&lt;th&gt;city2_rain_in_mm&lt;/th&gt;&#xA;&lt;th&gt;...&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;45&lt;/td&gt;&#xA;&lt;td&gt;12&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;42&lt;/td&gt;&#xA;&lt;td&gt;17&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;td&gt;37&lt;/td&gt;&#xA;&lt;td&gt;27&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;30&lt;/td&gt;&#xA;&lt;td&gt;35&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;td&gt;...&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;# variables&#xA;is_planned = model.addVars(cities, weeks, vtype=GRB.BINARY, name='x')&#xA;print(is_planned)&#xA;&#xA;following_city = model.addVars(cities, cities, vtype=GRB.BINARY, lb=0, name='y')&#xA;print(following_city)&#xA;&#xA;planned_week = model.addVars(cities, cities, vtype=GRB.BINARY, lb=0, name='z')&#xA;print(planned_week)&#xA;&#xA;# minimize distance and rain&#xA;obj = gp.quicksum((following_city[city1, city2]*(dist[city1, city2])+(is_planned[city1,week]*(rain[city1,week])))&#xA;                    for city1 in cities for city2 in cities for week in weeks)&#xA;&#xA;model.setObjective(obj, GRB.MINIMIZE)&#xA;&#xA;# visit every city a single time&#xA;for track in tracks:&#xA;    model.addConstr(gp.quicksum(is_planned[city, week] for week in weeks) == 1)&#xA;&#xA;# one city per week&#xA;for week in weeks:&#xA;    model.addConstr(gp.quicksum(is_planned[city, week] for city in cities) &amp;lt;= 1)&#xA;&#xA;&#xA;# is city1 followed by city2?&#xA;for week in weeks:&#xA;    if week &amp;lt; 47:&#xA;    for city1 in cities:&#xA;        for city2 in cities:&#xA;        if city1 != city2:&#xA;            model.addConstr((is_planned[city1,week] == 1) &amp;gt;&amp;gt; (following_city[city1, city2] == (is_planned[city1, week] + is_planned[city2, week + 1] - 1)))&#xA;        else:&#xA;            model.addConstr((is_planned[city1,week] == 0) &amp;gt;&amp;gt; (following_city[city1, city2] == 0))&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10622" LastEditorUserId="500" LastEditDate="2022-10-30T16:25:30.610" LastActivityDate="2022-10-30T16:58:53.667" Title="Gurobipy trip scheduling empty stop problem" Tags="|modeling|gurobi|scheduling|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9204" PostTypeId="2" ParentId="9202" CreationDate="2022-10-25T19:16:32.810" Score="1" Body="&lt;p&gt;Assuming weekly_share = x[d] where d is the day of the week&#xA;you can add constraints:&#xA;y[d] * x[d] = 1.&#xA;Then replace weekly_share with y.&lt;/p&gt;&#xA;&lt;p&gt;As for other constraints, solver will simply choose 10% for weeks 2-7.&#xA;You are looking for cumulative, right, so last constraint would be?&lt;br /&gt;&#xA;So &lt;span class=&quot;math-container&quot;&gt;$\sum_{d=2}^8 x_d = 0.9$&lt;/span&gt; &lt;br /&gt;&#xA;The above constraint for y can be written as:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_2*(0.1+x_2) = 1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_d * (\sum_{day=2}^dx_{day}) = 1$&lt;/span&gt; for d = [3...8]&lt;br /&gt;&#xA;Bound constraint&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_d E \{0.1,1\}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$d = \{2...8\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objective:&lt;br /&gt;&#xA;Total = &lt;span class=&quot;math-container&quot;&gt;$(3600)[\frac{(NTasks)}{(0.1)*workTime_Wk[1]*Goal[1]}+\sum_{d=2}^8\frac{(NTasks)(y_d)}{workTime_Wk[d]*Goal[d]}]$&lt;/span&gt;&#xA;Basically am trying to reduce variable for week1, since you know it's 0.1&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-10-25T23:00:56.633" LastActivityDate="2022-10-25T23:00:56.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9205" PostTypeId="2" ParentId="9203" CreationDate="2022-10-25T22:28:22.457" Score="1" Body="&lt;pre&gt;&lt;code&gt;model= Model('travel')&#xA;is_planned = model.addVars(cities,weeks,vtype='b',name='x')&#xA;following = model.addVars(cities,cities,weeks[1:],vtype='b',name='y')&#xA;#visit every city a single time&amp;quot;&#xA;C1 = model.addConstrs((is_planned.sum(city,'*') &amp;gt;= 1 for city in cities),'CityOnce')&#xA;#Per week only One city&amp;quot;\&#xA;C2 = model.addConstrs((is_planned.sum('*',week) == 1 for week in weeks),'OneCityperWeek')&#xA;#If remaining in same city for more than a week&amp;quot;&#xA;C3 = model.addConstrs((following[city1,city2,week+1]&amp;gt;=is_planned[city2,week+1]+is_planned[city1,week]-1 for city1 in cities for city2 in cities for week in weeks[:-1]),'Following')&#xA;#Objective&amp;quot;&#xA;Distance = quicksum(dist[city1,city2]*following[city1,city2,week] &#xA;                for city1 in cities for city2 in cities for week in weeks[1:])&#xA;Rain = quicksum(is_planned[city,week]*rain[week,city] for &#xA;            city in cities for week in weeks)&#xA;obj = Distance+Rain&#xA;model.setObjective(obj,GRB.MINIMIZE)&#xA;model.update()&#xA;model.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-10-30T16:58:53.667" LastActivityDate="2022-10-30T16:58:53.667" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9206" PostTypeId="1" CreationDate="2022-10-26T08:16:40.403" Score="5" ViewCount="1077" Body="&lt;p&gt;I am facing a problem understanding the L-shaped algorithm in a two-stage stochastic problem.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\operatorname{Min} z=100 x_1+150 x_2+E_{\xi}\left(q_1 y_1+q_2 y_2\right)$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;&amp;amp;x_1+x_2 \leq 120 \\&#xA;&amp;amp;6 y_1+10 y_2 \leq 60 x_1 \\&#xA;&amp;amp;8 y_1+5 y_2 \leq 80 x_2 \\&#xA;&amp;amp;x_1 \geq 40, x_2 \geq 20, y_1 \leq d_1, y_2 \leq d_2 \\&#xA;&amp;amp;y_1, y_2 \geq 0&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\xi^T=\left(d_1, d_2, q_1, q_2\right)$&lt;/span&gt; takes the values &lt;span class=&quot;math-container&quot;&gt;$(400,100,-20,-24)$&lt;/span&gt; with probability &lt;span class=&quot;math-container&quot;&gt;$0.4$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(300,200,-24,-28)$&lt;/span&gt; with probability &lt;span class=&quot;math-container&quot;&gt;$0.6$&lt;/span&gt;. Use an L-shaped algorithm and carry out one iteration.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I have the solution,&lt;/p&gt;&#xA;&lt;p&gt;Step 1. Ignoring &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;, the master program is simply &lt;span class=&quot;math-container&quot;&gt;$z=\min \left\{100 x_1+150 x_2 \mid x_1+x_2 \leq\right.$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\left.120, x_1 \geq 40, x_2 \geq 20\right\}$&lt;/span&gt; with solution &lt;span class=&quot;math-container&quot;&gt;$x^1=(40,20)^T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\theta^1=-\infty$&lt;/span&gt;.&#xA;Step 3.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For &lt;span class=&quot;math-container&quot;&gt;$\xi=\xi_1$&lt;/span&gt;, solve the program&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{r}&#xA;w=\min \left\{-24 y_1-28 y_2 \mid 6 y_1+10 y_2 \leq 2400,8 y_1+5 y_2 \leq 1600,\right. \\&#xA;\left.0 \leq y_1 \leq 500,0 \leq y_2 \leq 100\right\} .&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;The solution is &lt;span class=&quot;math-container&quot;&gt;$w_1=-6100, y^T=(137.5,100), \pi_1^T=(0,-3,0,-13)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For &lt;span class=&quot;math-container&quot;&gt;$\xi=\xi_2$&lt;/span&gt;, solve the program&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{r}&#xA;w=\min \left\{-28 y_1-32 y_2 \mid 6 y_1+10 y_2 \leq 2400,8 y_1+5 y_2 \leq 1600\right. \\&#xA;\left.0 \leq y_1 \leq 300,0 \leq y_2 \leq 300\right\} .&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;The solution is &lt;span class=&quot;math-container&quot;&gt;$w_2=-8384, \quad y^T=(80,192), \quad \pi_2^T=(-2.32,-1.76$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0,0)$&lt;/span&gt;.&#xA;Using &lt;span class=&quot;math-container&quot;&gt;$h_1=(0,0,500,100)^T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h_2=(0,0,300,300)^T$&lt;/span&gt;, one obtains&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;e_1=0.4 \cdot \pi_1^T \cdot h_1+0.6 \cdot \pi_2^T \cdot h_2=0.4 \cdot(-1300)+0.6 \cdot(0)=-520 .&#xA;$$&lt;/span&gt;&#xA;The matrix &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is identical in the two scenarios. It consists of two columns &lt;span class=&quot;math-container&quot;&gt;$(-60,0,0,0)^T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(0,-80,0,0)^T$&lt;/span&gt;. Thus,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;E_1=0.4 \cdot \pi_1^T T+0.6 \cdot \pi_2^T T &amp;amp;=0.4(0,240)+0.6(139.2,140.8) \\&#xA;&amp;amp;=(83.52,180.48)&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;Finally, as &lt;span class=&quot;math-container&quot;&gt;$x^1=(40,20)^T, w^1=-520-(83.52,180.48) \cdot x^1=-7470.4$&lt;/span&gt;. Thus, &lt;span class=&quot;math-container&quot;&gt;$w^1=-7470.4&amp;gt;\theta^1=-\infty$&lt;/span&gt;, add the cut &lt;span class=&quot;math-container&quot;&gt;$83.52x_1+180.48x_2+\theta ≥ −520 $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I couldn't understand the solution (Introduction to Stochastic Programming, 2nd edition. John R. Birge and Francois Louveaux. Springer, page: 185, Section: 5.1). There was no clear explanation.&lt;/p&gt;&#xA;&lt;p&gt;What the algorithm was doing and how the steps were taken was unclear.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&lt;p&gt;To get the shadow price, &lt;span class=&quot;math-container&quot;&gt;$$\tau^T=c_B (A^B)^{-1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/t7C90.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/t7C90.png&quot; alt=&quot;image1&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iBaKs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iBaKs.png&quot; alt=&quot;image2&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Hence, I got,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{pmatrix}0&amp;amp;-24&amp;amp;0&amp;amp;-28\end{pmatrix}\begin{pmatrix}1&amp;amp;-0.75&amp;amp;0&amp;amp;0\\ \:\:0&amp;amp;0.125&amp;amp;0&amp;amp;0\\ \:\:0&amp;amp;-0.125&amp;amp;1&amp;amp;0\\ \:\:0&amp;amp;0&amp;amp;0&amp;amp;1\end{pmatrix}=\begin{pmatrix}0&amp;amp;-3&amp;amp;0&amp;amp;-28\end{pmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where I did mistake to get the shadow price?&lt;/p&gt;&#xA;" OwnerUserId="9806" LastEditorUserId="9806" LastEditDate="2022-11-06T02:26:36.710" LastActivityDate="2022-11-06T02:26:36.710" Title="Understanding L-shaped algorithm in a two-stage stochastic problem" Tags="|linear-programming|algorithms|stochastic-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9207" PostTypeId="1" AcceptedAnswerId="9208" CreationDate="2022-10-26T12:29:43.747" Score="3" ViewCount="119" Body="&lt;p&gt;Given a convex compact set &lt;span class=&quot;math-container&quot;&gt;$K\subset\mathbb{R}^D$&lt;/span&gt; and convex function &lt;span class=&quot;math-container&quot;&gt;$f:K\rightarrow \mathbb{R}$&lt;/span&gt;, the sublevel set&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;X_\alpha = \{ x \in K : f(x) \leq \alpha \}&#xA;$$&lt;/span&gt;&#xA;defines a convex closed set (assuming it is non-empty).&#xA;I would like to compute the projection operator &lt;span class=&quot;math-container&quot;&gt;$\Pi_{X_\alpha}$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$X_\alpha$&lt;/span&gt; for any point in &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;.&#xA;Are there known methods and iteration complexity results for computing &lt;span class=&quot;math-container&quot;&gt;$\Pi_{X_\alpha}$&lt;/span&gt; when f is convex or strongly convex?&lt;/p&gt;&#xA;&lt;p&gt;I couldn't find references on this, even though such projections could appear frequently in constrained convex optimisation.&#xA;I'm especially curious if strong convexity could lead to linear convergence when computing such projections.&lt;/p&gt;&#xA;" OwnerUserId="9961" LastActivityDate="2022-10-26T12:51:32.463" Title="Projection to sublevel sets of convex/strongly convex function" Tags="|constraint|convex-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9208" PostTypeId="2" ParentId="9207" CreationDate="2022-10-26T12:51:32.463" Score="5" Body="&lt;p&gt;The projection can be written as a convex optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\Pi_{X_{\alpha}}(\bar{x}) \in \arg\min_{x} \quad &amp;amp; \| x - \bar{x} \|\\&#xA;\text{s.t.} \quad &amp;amp; f(x) \leq \alpha&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\bar{x} \in K$&lt;/span&gt; is the point you want to project, and &lt;span class=&quot;math-container&quot;&gt;$\|\cdot\|$&lt;/span&gt; is the norm you use for the projection. Note that depending on the nature of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and your norm (especially if they are polyhedral), the projection may not be unique.&lt;/p&gt;&#xA;&lt;p&gt;You can solve this problem using any algorithm for convex optimization, e.g., an interior-point method which has polynomial complexity. This is the most general case.&lt;/p&gt;&#xA;&lt;p&gt;There are special cases where you can have closed-form solutions, or more efficient algorithms.&#xA;For instance, if &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a quadratic function, and you use Euclidean distances, then you can compute the projection by solving a linear system. If &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a polyhedral function, the above problem is a quadratic optimization problem, which you can also solve using simplex.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2022-10-26T12:51:32.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9209" PostTypeId="2" ParentId="9202" CreationDate="2022-10-26T13:06:34.980" Score="1" Body="&lt;p&gt;One possible way to achieve what you want is by modeling the problem as a Resource-Constrained project scheduling problem. In which the project plan is around &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; weeks, and in each week you can define the desired tasks that should be completed by employees. In this case, there are many free tools, like excel based templates, that you can easily use to calculate the compilation percentage of tasks in each week and in the whole horizon.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-10-26T13:06:34.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9210" PostTypeId="1" CreationDate="2022-10-27T05:30:11.833" Score="3" ViewCount="91" Body="&lt;p&gt;The inequality &lt;span class=&quot;math-container&quot;&gt;$x^3\leq y$&lt;/span&gt; is not convex. But &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;x$&lt;/span&gt; added to the above provides a convex region.&lt;/p&gt;&#xA;&lt;p&gt;My question is whether in convex programming it is allowed to use both inequalities together and use convex programming techniques to solve?&lt;/p&gt;&#xA;" OwnerUserId="5282" LastActivityDate="2022-10-28T21:23:59.680" Title="On a clarification on usage of inequalities in convex programming" Tags="|reference-request|convex-optimization|convexity|disciplined-quasiconvex-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9211" PostTypeId="1" AcceptedAnswerId="9215" CreationDate="2022-10-27T10:34:47.967" Score="5" ViewCount="362" Body="&lt;p&gt;My question is a follow-up to this one: &lt;a href=&quot;https://or.stackexchange.com/questions/474/relationship-between-benders-decomposition-and-dantzig-wolfe-decomposition&quot;&gt;Relationship between Benders’ decomposition and Dantzig-Wolfe decomposition&lt;/a&gt;. Here what is being discussed is the relationship between the two methods, and it is commented that while theoretically equivalent, there may be some computational differences. I want to learn about these computational differences. When does it make sense to switch to the dual in these circumstances?&lt;/p&gt;&#xA;" OwnerUserId="5352" LastEditorUserId="500" LastEditDate="2022-10-27T12:42:20.583" LastActivityDate="2022-10-28T19:30:23.147" Title="Dantzig-Wolfe vs Benders Decomposition on the dual problem - Computational differences" Tags="|reference-request|duality|benders-decomposition|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9212" PostTypeId="1" CreationDate="2022-10-27T14:13:04.183" Score="2" ViewCount="184" Body="&lt;p&gt;I am facing this kind of error&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;Row 'eq1(14)' infeasible, all entries at implied bounds&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;in a problem that a GAMS script gets data from MATLAB. I have seen some posts about conflict refiner (e.g., irreducible infeasible subset), but I really can not understand the way it is going to work what am I passing as an argument and whether I write this command in GAMS or in MATLAB and how exactly.&lt;/p&gt;&#xA;" OwnerUserId="10634" LastEditorUserId="491" LastEditDate="2022-10-27T20:10:11.470" LastActivityDate="2022-10-28T10:57:07.220" Title="How to solve infeasible cplex model in GAMS?" Tags="|modeling|cplex|gams|irreducible-infeasible-subset|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9213" PostTypeId="2" ParentId="9212" CreationDate="2022-10-27T15:08:39.910" Score="1" Body="&lt;p&gt;I've not worked with the GAMS/Matlab interface, but iis is a CPLEX option and not a GAMS option. So when you're in GAMS, you just need to put it in a cplex option file (i.e., cplex.opt that is by default put in the GAMS projdir folder). If you're calling a gms file from Matlab, you can create the option file as I described and add a &lt;code&gt;model.optfile = 1;&lt;/code&gt; line to your GAMS code.&lt;/p&gt;&#xA;" OwnerUserId="119" LastEditorUserId="119" LastEditDate="2022-10-28T10:57:07.220" LastActivityDate="2022-10-28T10:57:07.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9214" PostTypeId="2" ParentId="9210" CreationDate="2022-10-28T09:54:36.333" Score="2" Body="&lt;p&gt;Since you requested a reference I suggest you look into &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/bv_cvxbook.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Convex Optimization by Boyd and Vandenberghe&lt;/a&gt;. In Section &amp;quot;4.2.1 Convex optimization problems in standard form&amp;quot; you can see that they write &lt;span class=&quot;math-container&quot;&gt;$f(x) \leq 0$&lt;/span&gt; for convex &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;, and in the beginning of Chapter 3 you see that convex &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; really means convex on &lt;span class=&quot;math-container&quot;&gt;${\rm dom}(f)$&lt;/span&gt; which must be a convex domain. So in your example, i.e., &lt;span class=&quot;math-container&quot;&gt;$f(x,y) = x^3 - y \leq 0$&lt;/span&gt;, you just limit the domain to &lt;span class=&quot;math-container&quot;&gt;${\rm dom}(f) = \mathbb{R}_+ \times \mathbb{R}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In practice I guess it might depend on the algorithm, but back in the days when MOSEK had a general convex programming solver we treated variable bounds (such as &lt;span class=&quot;math-container&quot;&gt;$0 \leq $&lt;/span&gt;) as the domain on which functions were safe to evaluate, and made sure that these bounds were strictly satisfied in every iteration. Similar to Boyd and Vandenberghe, our algorithm only required that constraints were convex and twice differential within those variable bounds.&lt;/p&gt;&#xA;&lt;p&gt;Note that general convex programming is nowadays almost obsolete as modern conic optimization has proven overall to be faster, better behaved and able to cover most usecases. Your example, &lt;span class=&quot;math-container&quot;&gt;$x^3 \leq y$&lt;/span&gt;, is equivalent on the domain, &lt;span class=&quot;math-container&quot;&gt;$0 \leq x$&lt;/span&gt;, to the power cone, &lt;span class=&quot;math-container&quot;&gt;$|x| \leq y^{1/3} z^{2/3}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2022-10-28T21:23:59.680" LastActivityDate="2022-10-28T21:23:59.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9215" PostTypeId="2" ParentId="9211" CreationDate="2022-10-28T19:30:23.147" Score="4" Body="&lt;p&gt;A terminology note: Dantzig-Wolfe (DW) and Benders (BD) decomposition are &lt;em&gt;formulations&lt;/em&gt;, not algorithms. DW decomposition is usually solved via column generation because, in general, it yields exponentially many variables. BD is usually solved via cutting plane because, similarly, it yields an exponential number of constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;TLDR&lt;/strong&gt;: if you work with continuous problems, it probably doesn't matter too much, but if you have a mixed-integer problem, the choice will likely be imposed on you.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If you start from a linear program (P) then, as you know, DW decomposition on the primal is equivalent to Benders decomposition on the dual.&#xA;Both approaches have identical sub-problems.&#xA;Assuming the same sequence of sub-problem solves,  the master problem in BD decomposition is the dual of the master problem in DW decomposition.&#xA;As outlined by Marco Lübbecke in &lt;a href=&quot;https://or.stackexchange.com/a/512/&quot;&gt;his answer to the original question&lt;/a&gt;, computational differences can arise if, e.g., the sequence of iterates is not the same.&#xA;While most mainstream solvers will automatically dualize a problem if they deem it preferable, solving one or the other may give you a different solution and, in the end, different performance.&#xA;Furthermore, although equivalent, there are, e.g., stabilization techniques, that can be more easily formulated in the dual problem than the primal.&#xA;For instance, it's easier to add a box constraint on your dual multipliers if you're working with the dual (the primal would require artificial slack variables), or a quadratic proximal regularization.&lt;/p&gt;&#xA;&lt;p&gt;That being said, DW and BD decomposition are not always applied to pure LP problems.&#xA;In many practical settings, they arise from mixed-integer problems.&#xA;In that case, you may not have the luxury of switching to the dual.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;One very desirable trait of BD decomposition is that you can implement it easily on top of a MIP solver, especially if it supports adding constraints via callbacks.&#xA;It would be &lt;em&gt;a lot&lt;/em&gt; harder to work on a DW formulation, because you wouldn't be able to use the solver's cuts, heuristics, branching, etc...&lt;/li&gt;&#xA;&lt;li&gt;If you have integer variables in your subproblem, then BD won't directly apply, because it normally relies on dual variables from the subproblem (you can get around that, but it's not trivial). When that happens, DW is your friend.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2022-10-28T19:30:23.147" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9217" PostTypeId="1" AcceptedAnswerId="9218" CreationDate="2022-10-29T16:01:30.597" Score="7" ViewCount="239" Body="&lt;p&gt;In &lt;a href=&quot;https://otexts.com/fpp2/holt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Holt's linear trend method&lt;/a&gt;, given a time series &lt;span class=&quot;math-container&quot;&gt;$y_1,\cdots,y_t$&lt;/span&gt;, the forecasting equation at time &lt;span class=&quot;math-container&quot;&gt;$t+h$&lt;/span&gt; based on data up to time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is given by&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\hat{y}_{t+h|t}= \ell_t + h b_t \tag{1}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\ell_t$&lt;/span&gt; is an estimate of the level of the series at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; which satisfies&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\ell_{t}=\alpha y_t + (1-\alpha)(\ell_{t-1}+b_{t-1}) \tag{2}&#xA;$$&lt;/span&gt;&#xA;and &lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt; an estimate of the trend (slope) of the series at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; which satisfies&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;b_{t}=\beta \color{blue}{(\ell_t-\ell_{t-1})}+ (1-\beta)b_{t-1} \tag{3}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\alpha \in [0,1]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta \in [0,1]$&lt;/span&gt; are the smoothing parameters.&lt;/p&gt;&#xA;&lt;p&gt;The trend equation &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; shows that &lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt; is a weighted average of the estimated trend at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; based on &lt;span class=&quot;math-container&quot;&gt;$\ell_t-\ell_{t-1}$&lt;/span&gt; and the previous estimate of the trend, &lt;span class=&quot;math-container&quot;&gt;$b_{t-1}$&lt;/span&gt;.&#xA;My question is, why not compute this average based on the real trend between &lt;span class=&quot;math-container&quot;&gt;$t-1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;? as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;b_{t}=\beta \color{red}{(y_t-y_{t-1})}+ (1-\beta)b_{t-1} \tag{3}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-10-29T23:31:10.303" LastActivityDate="2022-10-30T19:40:32.317" Title="Forecasting with Holt's linear trend method" Tags="|forecasting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9218" PostTypeId="2" ParentId="9217" CreationDate="2022-10-29T16:40:33.497" Score="6" Body="&lt;p&gt;You could of course do that if you chose to, so I assume you are asking why Holt did not choose that formula.&lt;/p&gt;&#xA;&lt;p&gt;Suppose that the series &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; actually satisfies a linear trend model, say &lt;span class=&quot;math-container&quot;&gt;$$y_t = a_0 + a_1 t + \epsilon_t$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\epsilon_t$&lt;/span&gt; is some i.i.d. random noise (mean 0, constant variance). Let's also assume that we are far enough along in applying whichever smoothing formulas we chose so that &lt;span class=&quot;math-container&quot;&gt;$\ell_{\tau} \approx a_0 + a_1 \tau$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_{\tau}\approx a_1.$&lt;/span&gt; According to the first Holt formula,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\ell_{t} &amp;amp; =\alpha(a_{0}+a_{1}t+\epsilon_{t})+(1-\alpha)(\ell_{t-1}+b_{t-1})\\&#xA; &amp;amp; \approx\alpha(a_{0}+a_{1}t+\epsilon_{t})+(1-\alpha)(a_{0}+a_{1}[t-1]+a_{1})\\&#xA; &amp;amp; =a_{0}+a_{1}t+\alpha\epsilon_{t}.&#xA;\end{align*}&lt;/span&gt;&#xA;Using Holt's second formula as stated, we get&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;b_{t} &amp;amp; =\beta(\ell_{t}-\ell_{t-1})+(1-\beta)b_{t-1}\\&#xA; &amp;amp; \approx\beta(a_{0}+a_{1}t+\alpha\epsilon_{t}-[a_{0}+a_{1}(t-1)])+(1-\beta)a_{1}\\&#xA; &amp;amp; =a_{1}+\beta\alpha\epsilon_{t},&#xA;\end{align*}&lt;/span&gt;&#xA;whereas with your second formula we get&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;b_{t} &amp;amp; =\beta(y_{t}-y_{t-1})+(1-\beta)b_{t-1}\\&#xA; &amp;amp; \approx\beta(a_{1}+\epsilon_{t}-\epsilon_{t-1})+(1-\beta)a_{1}\\&#xA; &amp;amp; =a_{1}+\beta(\epsilon_{t}-\epsilon_{t-1}).&#xA;\end{align*}&lt;/span&gt;&#xA;Both estimates of slope are unbiased, but yours contains more noise.&lt;/p&gt;&#xA;&lt;p&gt;Addendum: That was a bit hand-wavy even by my lax standards, so let me try to make it &lt;em&gt;slightly&lt;/em&gt; more rigorous. Let &lt;span class=&quot;math-container&quot;&gt;$\lambda_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\eta_t$&lt;/span&gt; be the errors in &lt;span class=&quot;math-container&quot;&gt;$\ell_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt; respectively, i.e., &lt;span class=&quot;math-container&quot;&gt;$$\ell_t = a_0 + a_1 t +\lambda_t$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$b_t = a_1 + \eta_t.$$&lt;/span&gt; The Holt formula for &lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt; reduces to &lt;span class=&quot;math-container&quot;&gt;$$b_t = a_1 + \beta(\lambda_t - \lambda_{t-1}) + (1-\beta)\eta_t$$&lt;/span&gt;and the proposed alternative reduces to &lt;span class=&quot;math-container&quot;&gt;$$b_t = a_1 + \beta(\epsilon_t - \epsilon_{t-1}) + (1-\beta)\eta_t.$$&lt;/span&gt; Assuming that the exponential smoothing is actually smoothing things, we expect &lt;span class=&quot;math-container&quot;&gt;$\lambda_t$&lt;/span&gt; to have lower variance than &lt;span class=&quot;math-container&quot;&gt;$\epsilon_t.$&lt;/span&gt; I'm pretty sure you can prove that via an induction argument.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-10-30T19:40:32.317" LastActivityDate="2022-10-30T19:40:32.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9219" PostTypeId="1" AcceptedAnswerId="9227" CreationDate="2022-10-29T19:30:38.137" Score="3" ViewCount="265" Body="&lt;p&gt;This questions stems from my original question &lt;a href=&quot;https://or.stackexchange.com/questions/9151/or-tools-custom-function-to-evaluate-intermediate-solutons&quot;&gt;here&lt;/a&gt;. I have a system, where each 'run' is a simulation of agents switching between tasks (or states) as in a Markov Chain. I would like to find ways to optimize the Transition Probability Matrix (TPM) to achieve a desired distribution of the agents among the states (which is determined by each run of the simulation) in the steady state.&lt;/p&gt;&#xA;&lt;p&gt;What exactly do I call such a system, and where can I learn more about working with these systems (names of topics, keywords, authors etc.)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware of the analytical methods and relations for arriving at the exact values in the TPM.&lt;/p&gt;&#xA;" OwnerUserId="8918" LastEditorUserId="727" LastEditDate="2022-11-07T19:44:45.133" LastActivityDate="2022-11-07T19:44:45.133" Title="Optimization for Stochastic Simulations" Tags="|simulation|stochastic-process|markov-decision-process|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9220" PostTypeId="1" CreationDate="2022-10-29T21:09:45.037" Score="1" ViewCount="32" Body="&lt;p&gt;Say you have the following table:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&quot;text-align: left;&quot;&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;Season Crop Price&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: right;&quot;&gt;&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;Spring&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;Cauliflower&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;175g&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;Spring&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;Coffee&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;15g&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;Summer&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;Blueberry&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;50g&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;Fall&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;Beet&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;100g&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;Fall&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;Eggplant&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;60g&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;I want to choose the best selling crop for each season, or what gives the maximal price.&lt;/p&gt;&#xA;&lt;p&gt;How do I write a model that captures this?&lt;/p&gt;&#xA;&lt;p&gt;I know that my maximal function must be something like :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;decision variable&#xA;x = crop&#xA;&#xA;list = price_of_crop&#xA;&#xA;maximize(x[i] *list[i])&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But how to get the distinction for each section?&lt;/p&gt;&#xA;&lt;p&gt;Feel free to add more to this if it helps make it clearer, I am not an OR expert.&lt;/p&gt;&#xA;" OwnerUserId="10645" LastEditorUserId="51" LastEditDate="2022-10-29T23:16:26.943" LastActivityDate="2022-10-29T23:16:26.943" Title="How to create distinct groups in LP?" Tags="|linear-programming|minimax|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9221" PostTypeId="1" AcceptedAnswerId="9230" CreationDate="2022-10-30T00:34:39.267" Score="2" ViewCount="107" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; be a decision variable, and let &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; be the coefficient for the decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An integer programming problem is where the goal is to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{maximize} \quad \sum_i c_ix_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{subject to} \quad A\vec{x} \leq \vec{b}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{subject to} \quad x_i \geq 0, \quad x_i \in \mathbb Z \quad \text{for all} \ i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a constraint design matrix, &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt; is a vector of decision variables, and &lt;span class=&quot;math-container&quot;&gt;$\vec{b}$&lt;/span&gt; is a vector of bounds.&lt;/p&gt;&#xA;&lt;p&gt;In an integer programming problem, &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; takes a scalar value.&lt;/p&gt;&#xA;&lt;p&gt;Let us consider a separate problem below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{maximize} \quad f( \sum_i {C_ix_i} )$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{subject to} \quad A\vec{x} \leq \vec{b}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{subject to} \quad x_i \geq 0, \quad x_i \in \mathbb Z \quad \text{for all} \ i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$C_i$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$p \times p$&lt;/span&gt; matrix, and &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a function that converts the matrix into a scalar, such as &lt;span class=&quot;math-container&quot;&gt;$\det$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is there a name for this class of problems?&lt;/p&gt;&#xA;" OwnerUserId="10646" LastEditorUserId="500" LastEditDate="2022-10-31T13:20:08.873" LastActivityDate="2022-10-31T14:26:31.713" Title="Is there a name for this type of integer programming?" Tags="|optimization|linear-programming|integer-programming|terminology|constrained-optimization|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9222" PostTypeId="2" ParentId="9221" CreationDate="2022-10-30T02:56:31.083" Score="3" Body="&lt;p&gt;Technically, the first problem you described is an &lt;em&gt;integer linear program&lt;/em&gt;. The phrase &lt;em&gt;integer program&lt;/em&gt; can be used for any constrained optimization problem involving integer variables (and &lt;em&gt;mixed integer program&lt;/em&gt; can be used when some but not all variables are integer). People often shorten &amp;quot;integer linear program&amp;quot;, &amp;quot;mixed integer linear program&amp;quot; or some other cases (e.g., &amp;quot;quadratic integer program&amp;quot;) to just &amp;quot;integer program&amp;quot;, but I do not believe that the phrase &amp;quot;integer program&amp;quot; automatically restricts either the constraints or the objective to linear or quadratic functions.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-30T02:56:31.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9223" PostTypeId="1" AcceptedAnswerId="9225" CreationDate="2022-10-30T06:50:43.530" Score="6" ViewCount="892" Body="&lt;p&gt;My question is about a Linear Program (LP) of the form &lt;span class=&quot;math-container&quot;&gt;$\bf Ax\ge b$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\bf x\ge0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;From a theoretical standpoint: Given a feasible solution &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x^{(0)}}$&lt;/span&gt;, how can we check (verify) whether it is an extreme point?&lt;/p&gt;&#xA;&lt;p&gt;I found &lt;a href=&quot;https://people.math.carleton.ca/%7Ekcheung/math/notes/MATH5801/08/8_2_extreme_points.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this on the web&lt;/a&gt;, but I don't know if this is correct.&lt;/p&gt;&#xA;&lt;p&gt;Can anyone please comment on the above method? Or aware of other methods to check whether a point &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x^{(0)}}$&lt;/span&gt; is an extreme point of the LP feasible space?&lt;/p&gt;&#xA;" OwnerUserId="7218" LastEditorUserId="7218" LastEditDate="2022-10-31T19:51:37.597" LastActivityDate="2022-10-31T19:51:37.597" Title="Linear Program: Verify whether a feasible solution is an extreme point" Tags="|linear-programming|polyhedra|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9224" PostTypeId="2" ParentId="9223" CreationDate="2022-10-30T13:53:18.643" Score="3" Body="&lt;p&gt;In&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://scholar.google.com/citations?view_op=view_citation&amp;amp;hl=da&amp;amp;user=kEOeI2gAAAAJ&amp;amp;cstart=20&amp;amp;pagesize=80&amp;amp;citation_for_view=kEOeI2gAAAAJ:KlAtU1dfN6UC&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://scholar.google.com/citations?view_op=view_citation&amp;amp;hl=da&amp;amp;user=kEOeI2gAAAAJ&amp;amp;cstart=20&amp;amp;pagesize=80&amp;amp;citation_for_view=kEOeI2gAAAAJ:KlAtU1dfN6UC&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Nimrod Megiddo proves that if you have a primal dual optimal solution you can find an optimal basis solution in strongly polynomial time. A basis solution specifies a vertex solution.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, unless there is a strongly polynomial algorithm for LP then you really need both a primal and dual optimal solution for that to be true.&lt;/p&gt;&#xA;&lt;p&gt;Hence, you can use the idea of Megiddo and I doubt that can be improved much since it is strongly polynomial.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2022-10-30T13:53:18.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9225" PostTypeId="2" ParentId="9223" CreationDate="2022-10-30T15:32:32.067" Score="4" Body="&lt;p&gt;The page you linked is correct. Note that &lt;span class=&quot;math-container&quot;&gt;$Ax\ge b$&lt;/span&gt; there includes any nonnegativity constraints, so their &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; combines your &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and an identity matrix.&lt;/p&gt;&#xA;&lt;p&gt;For a feasible solution &lt;span class=&quot;math-container&quot;&gt;$x\in\mathbb{R}^n$&lt;/span&gt; to be an extreme point, there must be at least &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; bounding hyperplanes of the feasible region that pass through &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; (meaning at least &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; constraints, including sign constraints, that are binding at &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;), and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; of those hyperplanes must have linearly independent normals. The constraints corresponding to those &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; hyperplanes are satisfied as equalities (since they are binding) and have rank &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; (since the constraints intersect only at one point, namely &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-10-30T15:32:32.067" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9226" PostTypeId="2" ParentId="9203" CreationDate="2022-10-30T16:22:31.707" Score="1" Body="&lt;p&gt;Here's a network-based formulation with a directed acyclic network.  There is a node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; for each city-week pair &lt;span class=&quot;math-container&quot;&gt;$(c_i,w_i)$&lt;/span&gt;, as well as a dummy source node &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and a dummy sink node &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.  There is an arc from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$c_i \not= c_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_i &amp;lt; w_j$&lt;/span&gt;.  For every node other than &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, there are arcs from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.  The cost for arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is the sum of the travel cost from &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; and the rain cost at city &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; in week &lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt;.  Arcs &lt;span class=&quot;math-container&quot;&gt;$(s,j)$&lt;/span&gt; from the source have zero travel cost, and arcs &lt;span class=&quot;math-container&quot;&gt;$(i,t)$&lt;/span&gt; to the sink have zero cost.  The problem is to find a shortest path from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, with a side constraint that every city is visited.&lt;/p&gt;&#xA;&lt;p&gt;For a similar formulation for the &lt;em&gt;traveling baseball fan problem&lt;/em&gt;, see &lt;a href=&quot;https://blogs.sas.com/content/operations/2015/04/03/the-traveling-baseball-fan-problem/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://blogs.sas.com/content/operations/2015/04/03/the-traveling-baseball-fan-problem/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-10-30T16:22:31.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9227" PostTypeId="2" ParentId="9219" CreationDate="2022-10-30T16:25:51.427" Score="4" Body="&lt;p&gt;&lt;strong&gt;Simulation Optimization&lt;/strong&gt; is the name of the field you are looking for. It is closely related to, and overlaps with. Machine Learning, such as training Deep Learning models.&lt;/p&gt;&#xA;&lt;p&gt;In Simulation Optimization, there is no such thing as training on all the data, because there are an infinite number of data points which could be generated, not only at different values of the optimization variables, but the number of replications increasing to infinity.&lt;/p&gt;&#xA;&lt;p&gt;There are a number of general approaches, including stochastic gradient descent (originally called Kiefer-Wolfowitz when it was invented 70 years ago, although that was the finite difference version, and only in one dimension), Gradient based methods, to include Quasi-Newton, or even Newton (simulating for Hessian).&lt;/p&gt;&#xA;&lt;p&gt;Any algorithm which uses averages of sample for objective function and gradients (or Hessian) can be called Sample Average Approximation (SAA). The term is generic enough that it can refer to anything. But SAA is often used as a synonym for any algorithm using common random numbers, which is also called Sample Path Optimization, although that too can mean almost anything.&lt;/p&gt;&#xA;&lt;p&gt;It is noteworthy, especially in conjunction with derivative based methods, but also for zeroth order (Objective function only) methods, use of common random numbers can be extremely important for performance. If calculating a finite difference derivative at two nearby points, if the errors are independent, the variances add, and get divided by a small number, which creates a huge variance in the finite difference derivative; that's not a good thing. However, if common random numbers are used, and particularity if there is good synchronization in the implementation so that very high positive correlation is achieved at nearby points, the individual data point errors might cancel out to a large extent, and finite difference derivatives could potentially be more accurate than evaluation of the objective at an individual point Similarly for differencing gradients from adjacent iterations in order to feed a Quasi-Newton Hessian update - this concept seems foreign to many Machine Learning people.&lt;/p&gt;&#xA;&lt;p&gt;Surrogate models (sometime known as Response Surface Methodology) fit a model to objective values at sampled points, and then optimize the surrogate function; then additional points ere sampled to improve the model, then re-optimized, etc. One manifestation is fitting a Gaussian Process, then optimizing that. (a form of Bayesian Optimization) Stochastic Kriging is another term for essentially the same thing. The uncertainty in the fitted model expands between sampled data points. There are also a variety of smoothing methods, involving some form of splines, or otherwise.&lt;/p&gt;&#xA;&lt;p&gt;Evolutionary algorithms and various &amp;quot;animal&amp;quot; algorithms are used by some people, but I don't have a very positive view of them. Perhaps they have their use. You seem to have a handle on those, so I won't further elaborate.&lt;/p&gt;&#xA;&lt;p&gt;Going back to derivative based methods, there are several possibilities.  Finite difference gradient are always applicable if the objective function is theoretically differentiable. A method called Likelihood Ratio Method  (it was my question over 40 years ago to the then student who developed LRM, of how you could simulate for a derivative, which I wanted for use in optimization, that stimulated him to invent the method) is fairly broadly applicable to directly simulate for derivatives, but is usually not very fast (has high variance), and not used that widely - it basically involves differentiating under the expectation, but instead of differentiating the (unintegrated) objective function, i.e., the integrand, it differentiates the probability measure driving the simulation) A closely related method, known as week derivatives, is essentially a more modern version of Likelihood Ratio Method, but as of yet, no one has created an Automatic Differentiation (AD) like machinery to make it &amp;quot;easy&amp;quot; to use on complicated models - I think that it might be doable by marrying the expertise of an AD expert to modify existing AD tools to incorporate different end node rules needed for weak derivatives (there might be some theoretical applicability issues though).&lt;/p&gt;&#xA;&lt;p&gt;If the objective function is continuous (smooth) per sample path, not just in expected value, then it is generally valid to interchange differentiation and expectation (simulation evaluates  expectation, even when estimating probabilities). This is known as Infinitesimal Perturbation Analysis (IPA). The objective function is differentiated, hen simulated. Automatic Differentiation (a.k.a. Algorithmic Differentiation) can be used to directly simulate for the gradient, especially using the so-called Reverse Mode of Automatic Differentiation, which computes the entire gradient, no matter how many components, at a fixed overhead ratio to just the objective function (presuming three is enough memento). The Reverse Mode of AD applied to Neural Networks is better known as Backpropagation. Sometimes Backpropagation is used to refer just to the Reveres Mode AD, while sometime it is used sued to refer to the whole stochastic gradient descent algorithm using Reverse Mode AD.&lt;/p&gt;&#xA;&lt;p&gt;IPA using the Reverse Mode of Automatic Differentiation can compute (simulate) an entire gradient &amp;quot;at once&amp;quot;. By contrast, LRM calculates the gradient one component at a time, by separately simulating with respect to the probability measure (partially) differentiated with respect to one component at a time. This can be a big disadvantage relative to IPA in models having a large number of optimization variables.&lt;/p&gt;&#xA;&lt;p&gt;Complex Step Differentiation is a method of doing finite differences using complex numbers. Despite looking very different from Automatic Differentiation, it essentially amounts to the same thing (once the simulation is suitably modified to handle complex inputs), and achieves the same accuracy as Automatic Differentiation,. Unfortunately, its scope of applicability is the same as IPA, not that of finite differences, i.e., it requires each sample path be differentiable, not just in expectation.  Further, Complex Step Differentiation really corresponds to the Forward Mode of Automatic Differentiation; and therefore, computes only one component of the gradient at a time. This places it at a disadvantage to RM Automatic Differentiation when the number of optimization variables sis large, but might be advantageous for a small number of variables, due to avoiding the overhead of RM Automatic Differentiation.&lt;/p&gt;&#xA;&lt;p&gt;If some or all of the optimization variables are discrete, that's a whole different ball game which I won't get into here.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-11-04T00:26:40.050" LastActivityDate="2022-11-04T00:26:40.050" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9228" PostTypeId="1" CreationDate="2022-10-30T22:35:37.507" Score="1" ViewCount="95" Body="&lt;p&gt;Seems like we can convert &lt;code&gt;&amp;gt;=&lt;/code&gt; constraints to &lt;code&gt;&amp;lt;=&lt;/code&gt;, either by multiplying by -1 or using variable substitution. But for &lt;code&gt;=&lt;/code&gt; constraints, seems like we need artificial variables.&lt;/p&gt;&#xA;&lt;p&gt;How do we incorporate artificial variables into the revised simplex method?&lt;/p&gt;&#xA;" OwnerUserId="10630" LastEditorUserId="10630" LastEditDate="2022-10-31T15:11:33.297" LastActivityDate="2022-10-31T15:11:33.297" Title="How to incorporate artificial variables into the revised simplex method" Tags="|simplex|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9229" PostTypeId="1" CreationDate="2022-10-30T00:31:01.670" Score="1" ViewCount="40" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; be a decision variable, and let &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; be the coefficient for the decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An integer programming problem is where the goal is to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{maximize} \quad \sum_i c_ix_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{subject to} \quad A\vec{x} \leq \vec{b}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{subject to} \quad x_i \geq 0, \quad x_i \in \mathbb Z \quad \text{for all} \ i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a constraint design matrix, &lt;span class=&quot;math-container&quot;&gt;$\vec{x}$&lt;/span&gt; is a vector of decision variables, and &lt;span class=&quot;math-container&quot;&gt;$\vec{b}$&lt;/span&gt; is a vector of bounds.&lt;/p&gt;&#xA;&lt;p&gt;In an integer programming problem, &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; takes a scalar value.&lt;/p&gt;&#xA;&lt;p&gt;Let us consider a separate problem below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{maximize} \quad f( \sum_i {C_ix_i} )$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{subject to} \quad A\vec{x} \leq \vec{b}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{subject to} \quad x_i \geq 0, \quad x_i \in \mathbb Z \quad \text{for all} \ i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$C_i$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$p \times p$&lt;/span&gt; matrix, and &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a function that converts the matrix into a scalar, such as &lt;span class=&quot;math-container&quot;&gt;$\det$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\text{tr}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is there a name for this class of problems?&lt;/p&gt;&#xA;" OwnerUserId="10646" OwnerDisplayName="LambdaPsi" LastActivityDate="2022-10-31T09:00:17.360" Title="Is there a name for this type of integer programming?" Tags="|optimization|constrained-optimization|linear-programming|integer-programming|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ClosedDate="2022-10-31T12:41:44.623" ContentLicense="CC BY-SA 4.0" />
  <row Id="9230" PostTypeId="2" ParentId="9221" CreationDate="2022-10-31T09:00:17.360" Score="2" Body="&lt;p&gt;You have is a linear integer programming problem with a generalized objective function of the form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$g(x) = f\big( \sum_i C_i x_i \big).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$f(X) = {\rm tr}(X)$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; is an ordinary linear objective function, and your problem class is just standard linear integer programming.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$f(X) = \det(X)$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; is a general nonlinear and nonconcave objective function (super hard), but you can easily transform it to a convex objective function by using &lt;span class=&quot;math-container&quot;&gt;$f(X) = \log\det(X)$&lt;/span&gt; instead, which notably does not affect the set of optimal solutions. This transformation would make your problem within the class of conic integer programming, requiring one semidefinite variable and one power cone (see &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/sdo.html#log-determinant&quot; rel=&quot;nofollow noreferrer&quot;&gt;the MOSEK modeling cookbook on log-determinant&lt;/a&gt; for details).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="198" LastEditorUserId="123" LastEditDate="2022-10-31T14:26:31.713" LastActivityDate="2022-10-31T14:26:31.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9231" PostTypeId="1" CreationDate="2022-10-31T13:46:27.630" Score="5" ViewCount="109" Body="&lt;p&gt;How to determine whether a convex polyhedron described by a set of linear inequalities contains at least a or no integer point in polynomial time, which is to say detecting the IP feasibility ?&lt;/p&gt;&#xA;&lt;p&gt;Specially in binary case, it's sufficient to see if the polyhedron contains at least a binary(integer) vertex. Does the problem become easier in binary case ?&lt;/p&gt;&#xA;" OwnerUserId="5681" LastEditorUserId="5681" LastEditDate="2022-10-31T14:31:33.347" LastActivityDate="2022-11-01T23:48:44.957" Title="Is there an efficient/polynomial way to detect/determine whether a polyhedon contains at least an integer point?" Tags="|mixed-integer-programming|integer-programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9232" PostTypeId="1" CreationDate="2022-11-01T02:02:49.543" Score="2" ViewCount="199" Body="&lt;p&gt;I have been working on an applied problem with Big M constraints (due to several security issues in the company, I cannot write the formulation I am working on).&lt;/p&gt;&#xA;&lt;p&gt;While solving with a partially LP-relaxed version of the problem and the original mixed integer linear program, I realized&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;With small (tight) big M, the LP relaxed version is far from the IP optimal.&lt;/li&gt;&#xA;&lt;li&gt;With somewhat large big M, the LP relaxed version converges to the IP optimal (and also its solutions).&lt;/li&gt;&#xA;&lt;li&gt;With an extremely large big M, the LP relaxed version indeed returns the IP optimal solution, while being SLOWER to solve.&lt;/li&gt;&#xA;&lt;li&gt;Too tight big M makes IP solution time longer (I was expecting this to be helpful, since the tighter big-M value is, the tighter LP relaxation should be (in terms of convex hull approximation))&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I was using Google OR tools + SCIP combination to solve the MILP model.&lt;/p&gt;&#xA;&lt;p&gt;And I was wondering if there is any insights on this issue, from any perspective, e.g. polyhedral theory, convex optimization, etc.&lt;/p&gt;&#xA;&lt;p&gt;There is no explicit question on this post, as I wanted to collect as much insights as possible, for my curiosity satisfaction.&lt;/p&gt;&#xA;" OwnerUserId="10658" LastEditorUserId="981" LastEditDate="2023-12-22T14:59:53.747" LastActivityDate="2023-12-22T14:59:53.747" Title="Big M and convergence of LP to IP" Tags="|mixed-integer-programming|linear-programming|or-tools|big-m|lp-relaxation|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="9233" PostTypeId="2" ParentId="9231" CreationDate="2022-11-01T15:10:48.760" Score="1" Body="&lt;p&gt;Given that the feasible set of your problem is a nonempty finite set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of integer points in Euclidean space, if you can find a linear representation of conv(&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;) (the convex hull of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, which will be a polytope), you can use linear programming to find an extreme point of conv(&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;). This can be done in polynomial time by using interior point methods. As the points of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; are all integers, the extreme points of conv(&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;) are also all integers, so that finding an extreme point of conv(&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;) is equivalent to finding a feasible (integer) solution to your problem. The caveat is that finding conv(&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;) is generally hard.&lt;/p&gt;&#xA;" OwnerUserId="10656" LastEditorUserId="10656" LastEditDate="2022-11-01T16:31:18.230" LastActivityDate="2022-11-01T16:31:18.230" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9234" PostTypeId="1" CreationDate="2022-11-01T21:51:31.433" Score="2" ViewCount="227" Body="&lt;p&gt;Say we have a constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x-2y+z \ge 3 \tag{1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Typically to actually solve it, we would need to introduce a surplus variable and an artificial variable:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x-2y+z-s+a=3 \tag{2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, is it really necessary to maintain a positive right hand side (RHS) and if so why? Yes that's standard form, but I am guessing it's not necessary to solve it computationally.&lt;/p&gt;&#xA;&lt;p&gt;Why not transform Equation (1) to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-x + 2y -z \le -3 \tag{3}, $$&lt;/span&gt;&#xA;so that we have a positive slack variable coefficient and no artificial variable with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-x +2y -z + s =-3 \tag{4}?$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Do we really need a positive RHS? I don't see the reason other than that's standard form, but how necessary is it to have non-negative b-values/RHS?&lt;/p&gt;&#xA;" OwnerUserId="10630" LastEditorUserId="491" LastEditDate="2022-11-02T11:37:53.113" LastActivityDate="2022-11-02T11:37:53.113" Title="Negative values for b-vector (RHS) for LP solvers" Tags="|linear-programming|lp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9235" PostTypeId="2" ParentId="9234" CreationDate="2022-11-01T22:06:43.590" Score="2" Body="&lt;p&gt;If you are talking about applying the simplex method by hand, there is a problem with what you propose. When solving by hand, you acquire an initial basic feasible solution by using the identity matrix formed by slack and artificial variables and setting the corresponding variables equal to the RHS. In your case, that basis matrix would include the &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; column, which would be set to -3, an infeasible value. So when solving by hand you do need the artificial variables.&lt;/p&gt;&#xA;&lt;p&gt;Software solvers do all sorts of preprocessing and might in some cases use either dual simplex or an interior point method from the outset, so I am not 100% sure they would use the two-phase method (which employs those artificial variables). Perhaps someone with experience writing solvers can answer for that case.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-01T22:06:43.590" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9236" PostTypeId="2" ParentId="9231" CreationDate="2022-11-01T23:48:44.957" Score="1" Body="&lt;p&gt;As pointed out in a comment, the general answer would be &amp;quot;most likely no&amp;quot;, because that would mean P is equal to NP.&lt;/p&gt;&#xA;&lt;p&gt;Assume you have an oracle that, given a polyhedron &lt;span class=&quot;math-container&quot;&gt;$P = \{ x | A x \geq b\}$&lt;/span&gt;, can decide whether &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; contains at least one integer point in polynomial time (polynomial in the size of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;).&#xA;This would allow you to answer the decision form of, say, graph coloring (which can embedded in a polynomial-size IP), in polynomial time.&#xA;Namely, write down the IP, consider the polyhedron given by the continuous relaxation, add an objective constraint, and call your oracle.&#xA;This would give you a polynomial-time oracle for graph coloring, which is an NP-complete problem. Therefore, graph coloring is in P and P = NP.&lt;/p&gt;&#xA;&lt;p&gt;In some specific cases, the answer is trivially &amp;quot;yes&amp;quot;.&#xA;This includes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Polyhedra that have a flow structure. Their extreme points are integer, so to prove there exists an integer point, all you need is to show it's not empty&lt;/li&gt;&#xA;&lt;li&gt;Packing polyhedra, which are defined with constraints of the form &lt;span class=&quot;math-container&quot;&gt;$a^{T}x \leq b$&lt;/span&gt; where all coefficients in &lt;span class=&quot;math-container&quot;&gt;$a, b$&lt;/span&gt; are non-negative. The origin (zero) is trivially feasible, and it's integer.&lt;/li&gt;&#xA;&lt;li&gt;Graph coloring without any restriction on the number of colors being used. Give a different color to each node.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2022-11-01T23:48:44.957" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9237" PostTypeId="1" CreationDate="2022-11-02T01:13:10.513" Score="1" ViewCount="123" Body="&lt;p&gt;I assume that &amp;quot;less than or equal to&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$\left( \leq \right)$&lt;/span&gt; and &amp;quot;greater than or equal to&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$\left( \geq \right)$&lt;/span&gt; constraints avoid degeneracy because each of those has at least one unique slack/surplus variable attached.&#xA;So, therefore, I assume that degeneracy can only exist for equality &lt;span class=&quot;math-container&quot;&gt;$(=)$&lt;/span&gt; constraints.&lt;/p&gt;&#xA;&lt;p&gt;And so I am postulating that a good way to avoid degeneracy is then to introduce slack/surplus variables to equality constraints (as perturbations) and then constrain those slack/surplus variables to some small quantity (0.00000001), etc. Is this accurate?&lt;/p&gt;&#xA;" OwnerUserId="10630" LastEditorUserId="491" LastEditDate="2022-11-02T11:31:47.987" LastActivityDate="2022-11-02T11:31:47.987" Title="Avoiding degeneracy in an LP formulation" Tags="|linear-programming|degeneracy|perturbation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9238" PostTypeId="2" ParentId="9237" CreationDate="2022-11-02T03:14:58.273" Score="6" Body="&lt;p&gt;The premise is wrong. Degeneracy occurs when a vertex &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; of a feasible region in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n$&lt;/span&gt; lies on more than &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; bounding hyperplanes, or equivalently if more than &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; constraints (including any sign restrictions) are binding at &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. This can happen even when all constraints are inequality constraints. Consider a problem with two variables and the constraints &lt;span class=&quot;math-container&quot;&gt;$x\ge 0,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$x_1 + x_2 \le 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_1 - x_2 \ge -1.$&lt;/span&gt; The point &lt;span class=&quot;math-container&quot;&gt;$(0,1)$&lt;/span&gt; is a vertex of the feasible region and three constraints (both &amp;quot;functional&amp;quot; constraints and &lt;span class=&quot;math-container&quot;&gt;$x_1 \ge 0$&lt;/span&gt;) are binding there, making it degenerate.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-02T03:14:58.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9239" PostTypeId="1" CreationDate="2022-11-02T12:34:52.933" Score="0" ViewCount="142" Body="&lt;p&gt;I have to minimize the inventory remaining at end of the period(28 days). Each item would perish after a fixed number of days and we can order items only on certain weekdays(M,T,S,S). Demand is allowed not to be met if not possible. but no stockout situation. The inventory continuity constraint is giving infeasibility to me because of situations when all inventory has perished on a day, we can't order on the same day also so ending inventory equals demand and is conflicting with other equations, how to model the situation when &lt;strong&gt;demand may or may not be met?&lt;/strong&gt; Below is the code.&#xA;Days are from 241-269.&#xA;Day 240 is the day of initial on-hand availability.&#xA;Inv can be continuous but order qty is integer.&lt;/p&gt;&#xA;&lt;p&gt;Here is formulation:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;item=[1...10], days=[241...269]&#xA;dvar's --&amp;gt; x(i,d) {Binary} y(i,d) {Integer purchase qty.} I(i,d) {Continuous, &amp;gt;0 inventory at EOD}&#xA;&#xA;Min: lpSum over i,d (I(i,d) if d==269)&#xA;&#xA;s.t. C_1 : x(i,d)=0 if d in {Mon,Thu,Sat,Sun}&#xA;     C_2 : I(i,d)= On-hand inv at beginning of period(data given) if d=240&#xA;     C_3 : for all days 80 &amp;lt;= lpSum over i (y(i,d)) &amp;lt;=150&#xA;     C_4 : I(i,d+s)] &amp;lt;= (1-x(i,d))*M&#xA;(Inventory to be salvaged if shelf life days are passed, s is shelf days for each item)&#xA;     C_5 :  y(i,d)&amp;lt;= M*x(i,d)&#xA;     C_6 : for all i,d &#xA;             if demand_forcast(i,d) &amp;gt;= I(i,d-1):&#xA;                  I(i,d) == y(i,d)&#xA;             else:&#xA;                  I(i,d) = I(i,d-1) + y(i,d) -demand_forcast(i,d)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And here is python code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;item = demand['item_code'].unique()&#xA;days = range(240,270,1)&#xA;&#xA;item_days = [(i,d) for i in item for d in days]&#xA;&#xA;dmd_forecast = demand.set_index(['item_code','doy']).forecast_quantity.to_dict()&#xA;onhand_qty = onhand.set_index(['item_code','doy']).onhand_quantity.to_dict()&#xA;no_order = no_purchase_days.set_index(['item_code','doy']).delivery.to_dict()  ## list of item-days for no order&#xA;shelf_days = shelf_life.set_index(['item_code']).item_shelf_life.to_dict()&#xA;&#xA;#------------------------------------------&#xA;prob = LpProblem(&amp;quot;Min_wastage&amp;quot;,LpMinimize)&#xA;&#xA;x = LpVariable.dicts(&amp;quot;Order-y-n&amp;quot;,item_days, cat=&amp;quot;Binary&amp;quot;)  ## x at 240 also to be set zero&#xA;&#xA;y = LpVariable.dicts(&amp;quot;Order-Qty&amp;quot;,item_days,lowBound = 0, cat=&amp;quot;Integer&amp;quot;)&#xA;&#xA;I = LpVariable.dicts(&amp;quot;EOD_Inv&amp;quot;,item_days, lowBound = 0, cat=&amp;quot;Continuous&amp;quot;) &#xA;&#xA;# objective function&#xA;&#xA;## Minimize the inventory left at end of period of 29 days&#xA;&#xA;prob += (&#xA;    lpSum(I[(i,d)] for i in item for d in days if d == 269 )&#xA;)&#xA;&#xA;## Constraint 1: No Delivery on Mon, Thu, Sat, Sun&#xA;&#xA;for i in no_order:&#xA;    prob += (&#xA;           y[i] == 0&#xA;    )&#xA;    &#xA;## Also At time period 240 no order&#xA;&#xA;for i in item:&#xA;    for d in days:&#xA;        if d==240:&#xA;            prob += (&#xA;                y[(i,d)] == 0&#xA;            )&#xA;## Constraint 2: Fix on hand inventory values at start of period, start of day&#xA;            &#xA;for i in onhand_qty:&#xA;    prob += (&#xA;        I[i] == onhand_qty[i]&#xA;    )&#xA;&#xA;## Constraint 3 : Inv-continuity Equation&#xA;&#xA;            &#xA;for i in item:&#xA;    for d in days:&#xA;        if d&amp;gt;=241:&#xA;            if dmd_forecast[(i,d)] &amp;gt;= I[(i,d-1)]:&#xA;                prob += (&#xA;                    I[(i,d)] == dmd_forecast[(i,d)]- I[(i,d-1)] + y[(i,d)]&#xA;                )&#xA;            else:&#xA;                prob += (&#xA;                    I[(i,d)] == I[(i,d-1)] + y[(i,d)] - dmd_forecast[(i,d)]&#xA;                )&#xA;## Constraint 5: Inventory to be salvaged if shelf life days are passed.&#xA;&#xA;## 250 as max. shelf days over all items is 19 days. Also this constraint needs to be written in better way for each item.&#xA;&#xA;for i in item:&#xA;    for d in days:&#xA;        if d &amp;lt;= 260:&#xA;            prob += (&#xA;                    I[(i,d+shelf_days[i])] &amp;lt;= (1-x[(i,d)])*1000&#xA;            )&#xA;&#xA;## Constraint 6: if x is 1, the order can placed y &amp;gt; 0, 170 is the value of Big-M, when y is zero... x is forced zero.&#xA;&#xA;for i in item:&#xA;    for d in days:&#xA;        prob += (&#xA;            x[(i,d)] &amp;lt;= y[(i,d)]&#xA;        )&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10422" LastEditorUserId="10422" LastEditDate="2022-11-02T19:15:52.373" LastActivityDate="2022-11-03T19:40:07.707" Title="Inventory Continuity Equation" Tags="|python|inventory|pulp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9240" PostTypeId="1" CreationDate="2022-11-02T15:41:50.417" Score="1" ViewCount="211" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x \ge 1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y = y + x$&lt;/span&gt;. And, if &lt;span class=&quot;math-container&quot;&gt;$x \le 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y = y$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are non-negative integer decision variables. I am using GLPK solver.&lt;/p&gt;&#xA;&lt;p&gt;How do I linearize this if-then constraint?&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="491" LastEditDate="2022-11-02T18:18:33.670" LastActivityDate="2022-11-09T03:11:15.523" Title="How to linearize this if-then constraint?" Tags="|mixed-integer-programming|linear-programming|logical-constraints|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9241" PostTypeId="2" ParentId="9239" CreationDate="2022-11-02T15:56:38.180" Score="1" Body="&lt;p&gt;Shouldn't the right side of the first part of your constraint 3 (if today's demand forecast is greater than or equal to yesterday's closing inventory) be y[(i, d)]? Assuming stuff you order cannot be used to satisfy demand in the same day, when demand exceeds previous day's inventory you use up all of the previous day's inventory filling demand, drop the excess demand and end up with inventory containing any new orders arriving that day.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-02T15:56:38.180" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9242" PostTypeId="2" ParentId="9240" CreationDate="2022-11-02T17:21:30.617" Score="3" Body="&lt;p&gt;If you just want to update &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and not declare a constraint, then assigning &lt;span class=&quot;math-container&quot;&gt;$y = y + x$&lt;/span&gt; already handles both cases &lt;span class=&quot;math-container&quot;&gt;$x \ge 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-11-02T17:21:30.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9243" PostTypeId="1" AcceptedAnswerId="9254" CreationDate="2022-11-02T18:05:12.293" Score="5" ViewCount="476" Body="&lt;p&gt;I'm using the &lt;a href=&quot;https://developers.google.com/optimization/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR-Tools&lt;/a&gt; &lt;a href=&quot;https://developers.google.com/optimization/cp/cp_solver&quot; rel=&quot;nofollow noreferrer&quot;&gt;CP-SAT&lt;/a&gt; solver on a list of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; boolean variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;. I'm trying to maximize the minimal distance between two true variables in this list, as illustrated by the following figure.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+&#xA;| 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |&#xA;+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+&#xA;           &amp;lt;-------------&amp;gt; &amp;lt;---------&amp;gt; &amp;lt;-----------------&amp;gt;&#xA;                  4             3               5&#xA;                            (minimum)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In other words, mathematically, I'm trying to maximize the expression :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min(j-i \mid 0 &amp;lt; i &amp;lt; j &amp;lt; n, x_i = x_j = 1)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;At the moment, I'm using this algorithm, basically brute-forcing all the possible intervals:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;minimalDistance = model.NewIntVar(0, n);&#xA;for (k = 1; k &amp;lt; n; ++k) {&#xA;    isIntervalAtLeastOfGivenSize[k] = model.NewBoolVar();&#xA;    model.AddEquivalence(&#xA;        isIntervalAtLeastOfGivenSize[k],&#xA;        minimalDistance &amp;gt;= k&#xA;    );&#xA;}&#xA;&#xA;for (i = 0; i &amp;lt; n; ++i) {&#xA;    for (j = i + 1; j &amp;lt; n; ++j) {&#xA;        model.AddImplication(&#xA;            x[i] and isIntervalAtLeastOfGivenSize[j - i + 1],&#xA;            x[j] = false&#xA;        )&#xA;    }&#xA;}&#xA;&#xA;model.maximize(minimalDistance)&#xA;model.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It works, but I have a feeling that it's not the best approach: it adds a lot of constraints, and it doesn't scale well when &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; gets bigger. Is there a better way to do it?&lt;/p&gt;&#xA;" OwnerUserId="1223" LastEditorUserId="981" LastEditDate="2023-12-22T15:12:10.277" LastActivityDate="2023-12-22T15:12:10.277" Title="Maximize the minimal distance between true variables in a list" Tags="|modeling|constraint-programming|or-tools|cp-sat|minimax|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9244" PostTypeId="2" ParentId="9243" CreationDate="2022-11-02T18:24:27.647" Score="6" Body="&lt;p&gt;You can maximize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to linear big-M constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z - (j-i) \le M_{ij} (2 - x_i - x_j),$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$M_{ij} = n-(j-i)$&lt;/span&gt;.&#xA;Each such constraint enforces the logical implication &lt;span class=&quot;math-container&quot;&gt;$(x_i \land x_j) \implies z \le j - i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you also know a lower bound &lt;span class=&quot;math-container&quot;&gt;$\sum_i x_i \ge k$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$k &amp;gt; 1$&lt;/span&gt;, you can impose a valid constraint &lt;span class=&quot;math-container&quot;&gt;$$z \le \left\lfloor\frac{n-1}{k-1}\right\rfloor$$&lt;/span&gt; that dominates some of the other constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-11-02T18:55:02.820" LastActivityDate="2022-11-02T18:55:02.820" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="9245" PostTypeId="1" AcceptedAnswerId="9248" CreationDate="2022-11-02T19:21:02.707" Score="2" ViewCount="584" Body="&lt;p&gt;I am trying to implement a delayed column generation approach in pyomo.&#xA;However, I cannot find a way to add a variable to a constraint. I can add variables to the objective function, simply by adding to the objective expression, but that does not seem to work with constraints. So my question is &amp;quot;can you add a variable to an existing constraint in pyomo&amp;quot;? To illustrate what I want to do, here is small example (which does not work):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyomo&#xA;# Create model and variable&#xA;model = pyomo.ConcreteModel()&#xA;model.x = pyomo.Var(within=pyomo.NonNegativeReals)&#xA;# Create simple initial model&#xA;model.obj = pyomo.Objective(expr=model.x, sense=pyomo.minimize)&#xA;model.cst = pyomo.Constraint(expr=model.x &amp;gt;= 2)&#xA;# Solve the model&#xA;solver = pyomo.SolverFactory('gurobi')&#xA;solver.solve(model, tee=True)&#xA;# Create new variable&#xA;model.y = pyomo.Var(within=pyomo.NonNegativeReals)&#xA;# Add a new variable to the objective and to the constraint&#xA;model.obj.expr += model.y&#xA;model.cst.body += model.y # This does not work!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2022-11-02T21:16:39.463" LastActivityDate="2022-11-02T23:15:58.617" Title="Adding variable to constraint in pyomo" Tags="|python|pyomo|column-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9246" PostTypeId="2" ParentId="8786" CreationDate="2022-11-02T19:22:16.420" Score="1" Body="&lt;p&gt;I think you can try something like this &lt;code&gt;list(w.values())&lt;/code&gt; , because continuous_var_matrix returns a dictionary of continuous_var, just convert it to list, and it should work.&lt;/p&gt;&#xA;" OwnerUserId="10651" LastActivityDate="2022-11-02T19:22:16.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9248" PostTypeId="2" ParentId="9245" CreationDate="2022-11-02T23:15:58.617" Score="2" Body="&lt;p&gt;You can do this using an &lt;code&gt;Expression&lt;/code&gt; object to hold the part of the constraint you want to modify:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyomo&#xA;&#xA;# Create model and variable&#xA;model = pyomo.ConcreteModel()&#xA;model.x = pyomo.Var(within=pyomo.NonNegativeReals)&#xA;&#xA;# Create simple initial model&#xA;model.obj = pyomo.Objective(expr=model.x, sense=pyomo.minimize)&#xA;model.lhs_expr = pyomo.Expression(expr=model.x)&#xA;model.cst = pyomo.Constraint(expr=model.lhs_expr &amp;gt;= 2)&#xA;&#xA;# Solve the model&#xA;solver = pyomo.SolverFactory('gurobi')&#xA;solver.solve(model, tee=True)&#xA;&#xA;# Create new variable&#xA;model.y = pyomo.Var(within=pyomo.NonNegativeReals)&#xA;&#xA;# Add a new variable to the objective and to the constraint&#xA;model.obj.expr += model.y&#xA;model.lhs_expr += model.y &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="583" LastActivityDate="2022-11-02T23:15:58.617" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9251" PostTypeId="2" ParentId="9243" CreationDate="2022-11-03T13:56:03.287" Score="1" Body="&lt;p&gt;Probably I'm not understanding correctly the problem, but to me the solution looks like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(n - X) / (X - 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;with &lt;code&gt;X&lt;/code&gt; being the number of 1 (True values) in the array of lenght &lt;code&gt;n&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Suppose you have an array of 9 variables. 3 True, 6 False: the above formula gives you:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(9 - 3) / (3 - 1) = 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In fact you can arrange your 9 variable this way:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10678" LastEditorUserId="10678" LastEditDate="2022-11-03T14:04:30.060" LastActivityDate="2022-11-03T14:04:30.060" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9252" PostTypeId="2" ParentId="9206" CreationDate="2022-11-03T14:09:53.410" Score="2" Body="&lt;p&gt;I will attempt to answer some of your questions. We can write the extensive form of the problem as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z = min\hspace{0.25cm} 100x_{1}+150x_{2}+\sum\limits_{s}P_{s}(q_{1,s}y_{1}+q_{2,s}y_{2})\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    &amp;amp; x_{1}+x_{2} \leq 120 \\&#xA;    &amp;amp; 6y_{1}+10y_{2} \leq 60x_{1} \\&#xA;    &amp;amp; 8y_{1}+5y_{2} \leq 80x_{2} \\&#xA;    &amp;amp; 0\leq y_{1} \leq d_{1,s}, 0\leq y_{2} \leq d_{2,s}, \forall s \\&#xA;    &amp;amp; x_{1} \geq 40, x_{2} \geq 20 \\&#xA; \end{align}&lt;/span&gt;&#xA;We are provided the following data:&lt;/p&gt;&#xA;&lt;p&gt;Probabilty of scenarios: &lt;span class=&quot;math-container&quot;&gt;$P_{1} = 0.4, P_{2} = 0.6 \\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$q_{1,1} = -24, q_{1,2} = -28, q_{2,1}= -28, q_{2,2} = -32\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_{1,1} = 500, d_{1,2} =300, d_{2,1} = 100, d_{2,2} = 300\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The extensive form simply means that we solve it as one large problem. The two set of variables bounds given by (4) would need to be set up for all the scenarios, i.e. (4) becomes:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\\ y_{1} \leq d_{1,1}, y_{1} \leq d_{1,2}\\\\$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_{2} \leq d_{2,1}, y_{2} \leq d_{2,2}\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This problem has only two scenarios, so the extensive form is easy to solve. However, if the number of scenarios is large then methods such as L-shaped can be used. This requires separating the problem in to a master and sub-problems. The master problem is defined as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\\ z = min\hspace{0.25cm} 100x_{1}+150x_{2}+\theta\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; is a variable that approximates subproblems.&lt;/p&gt;&#xA;&lt;p&gt;The master problem generates a first stage decision &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. The subproblems are the recourse problems and will take the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; from the master problem and then find the best recourse decisions. If all subproblems are optimal for given &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, then optimality cut (a constraint) is added to the master problem.&#xA;L-shaped method relies on an iterative procedure that solves for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; values without considering subproblems except through a set of cut constraints that are created and passed from subproblems to the master problem.&lt;/p&gt;&#xA;&lt;p&gt;The matrix &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is the technology matrix describing the relationship between the variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\\ T=\begin{bmatrix}&#xA;-60 &amp;amp; 0\\&#xA;0 &amp;amp; -80\\&#xA;0 &amp;amp; 0 \\&#xA;0 &amp;amp; 0&#xA;\end{bmatrix}\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The matrix T contains coefficients of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in the subproblem. If you rewrite constraints in the subproblem as below and create a matrix of coefficients of &lt;span class=&quot;math-container&quot;&gt;$x_{1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{2}$&lt;/span&gt;, this will give you T:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    &amp;amp; -60x_{1}+0x_{2}+6y_{1}+10y_{2} \leq 0 \tag{1}\\&#xA;    &amp;amp; 0x_{1}-80x_{2}+8y_{1}+5y_{2} \leq 0 \tag{2}\\&#xA;    &amp;amp; 0x_{1}+0x_{2}+y_{1} \leq d_{1,s} , \forall s\tag{3} \\&#xA;    &amp;amp; 0x_{1}+0x_{2}+y_{2} \leq d_{2,s}  , \forall s \tag{3}&#xA;\end{align}&lt;/span&gt;&#xA;The T is same in both scenarios as constraints (3) will contains &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; as coefficient in both scenarios.&lt;/p&gt;&#xA;&lt;p&gt;The matrix &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; represents RHS of the uncertainty, i.e. data for &lt;span class=&quot;math-container&quot;&gt;$d_{1,s}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_{2,s}$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$h_{1} = \begin{bmatrix}&#xA;    0\\&#xA;0   \\&#xA;500\\&#xA;100&#xA;\end{bmatrix}$&lt;/span&gt;&#xA;, &lt;span class=&quot;math-container&quot;&gt;$h_{2} = \begin{bmatrix}&#xA;    0\\&#xA;0\\&#xA;300\\&#xA;300&#xA;\end{bmatrix}\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We start with solving the master problem considering constraint (1) only and ignoring &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;. We assume &lt;span class=&quot;math-container&quot;&gt;$\theta = -\infty$&lt;/span&gt; initially. This gives &lt;span class=&quot;math-container&quot;&gt;$x_{1} = 40$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{2} = 20\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are then substituted into constraints (2) and (3).&#xA;The first subproblem is then given by:&#xA;&lt;span class=&quot;math-container&quot;&gt;$w_{1} = min -24y_{1} - 28y_{2}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    &amp;amp; 6y_{1}+10y_{2} \leq 2400 \tag{2.1} \\&#xA;    &amp;amp; 8y_{1}+5y_{2} \leq 1600 \tag{3.1} \\&#xA;    &amp;amp; 0 \leq y_{1} \leq 500, 0 \leq y_{2} \leq 100 \tag{4.1}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Similarly, the second subproblem is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\\w_{2} = min-24y_{1}-28y_{2} \\ $&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    &amp;amp; 6y_{1}+10y_{2} \leq 2400 \tag{2.2} \\&#xA;    &amp;amp; 8y_{1}+5y_{2} \leq 1600 \tag{3.2} \\&#xA;    &amp;amp; 0 \leq y_{1} \leq 300, 0 \leq y_{2} \leq 300 \tag{4.2}&#xA;\end{align}&lt;/span&gt;&#xA;The vector &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; contains the dual values of constraints and upper bounds on variables &lt;span class=&quot;math-container&quot;&gt;$y_{1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{2}$&lt;/span&gt;&#xA;To get the dual values, you can use Excel solver and generate the sensitivity report. It should show you the dual values or shadow prices for all of the constraints.&#xA;For the first subproblem, we get:&#xA;objective value &lt;span class=&quot;math-container&quot;&gt;$w_{1} = -6100$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_{1} = 137.5$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_{2} = 100$&lt;/span&gt; and dual values &lt;span class=&quot;math-container&quot;&gt;$\tau^{T}_{1} = (0,-3,0-13)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the second subproblem, we get:&#xA;objective value &lt;span class=&quot;math-container&quot;&gt;$w_{2} = -8384$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_{1} = 80.5$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_{2} = 192$&lt;/span&gt; and dual values &lt;span class=&quot;math-container&quot;&gt;$\tau^{T}_{2} = (-2.32,-1.76,0,0)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Given above solutions to the subproblems, we then calculate &lt;span class=&quot;math-container&quot;&gt;$e_{1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$E_{1}\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$e_{1} = \sum\limits_{s}P_{s} \tau^{T}_{s}h_{k} = -520\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$E_{1} = \sum\limits_{s}P_{s} \tau^{T}_{s}T_{k} = (83.52,180.48)\\\\$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\\ w^{1} = e_{1} - E_{1}x = -520 - (83.52x_{1}+180.48x_{2})=-520 - (83.52*40+180.48*20) = -7470.4\\\\$&lt;/span&gt;&#xA;As &lt;span class=&quot;math-container&quot;&gt;$w^{1} = -7470.4 &amp;gt; \theta = -\infty$&lt;/span&gt; add a cut (constraint) to the master problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\\83.52x_{1}+180.48x_{2}+\theta \geq -520\\\\$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This constraint is defined as  &lt;span class=&quot;math-container&quot;&gt;$w^{v} = e_{s+1} - E_{s+1}x^{v}$&lt;/span&gt; in the book. You repeat the process with this additional constraint added to the master problem, finding values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in the master problem and substituting values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to subproblems. These iterations are repeated until the difference between &lt;span class=&quot;math-container&quot;&gt;$w_{k}$&lt;/span&gt; as defined above and &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; is within a tolerance- in the example the convergence is exact.&lt;/p&gt;&#xA;&lt;p&gt;I suggest reading about linear programming duality, to understand how these cuts approximates the recourse function.&lt;/p&gt;&#xA;" OwnerUserId="3896" LastEditorUserId="3896" LastEditDate="2022-11-05T20:46:16.697" LastActivityDate="2022-11-05T20:46:16.697" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9253" PostTypeId="2" ParentId="9239" CreationDate="2022-11-03T19:40:07.707" Score="1" Body="&lt;p&gt;It seems you would need to tweak the mentioned model to be close to the standard &lt;em&gt;&lt;strong&gt;Multi item-Multi period lot-sizing&lt;/strong&gt;&lt;/em&gt; problem. The following formulation can give you some good starting points.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}&#xA;\text{Min} \quad \mathbb{Z} = \sum_i \sum_t s_{i,t} \\&#xA;\text{S.t:} \\&#xA;s_{i,t-1} + x_{i,t} = D_{i,t} + s_{i,t} \quad \forall i,t &amp;amp; (1)\\&#xA;s_{i,0} = SS_{i,0} \quad \forall i &amp;amp; (2)\\&#xA;s_{i,t} \geq SS_{i,t} \quad \forall i,t &amp;amp; (3)\\&#xA;x_{i,t} \leq M_{i,t}.y_{i,t} \quad \forall i,t &amp;amp; (4)\\&#xA;x_{i,t}, s_{i,t} \in \mathbb{R}_{+}, y_{i,t} \in\{0,1\} \quad \forall i,t &amp;amp; (5)\\&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where, &lt;span class=&quot;math-container&quot;&gt;$x_{i,t}$&lt;/span&gt; represents the amount of product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; produced during time period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_{i,t}$&lt;/span&gt; is the switching to produce a batch, &lt;span class=&quot;math-container&quot;&gt;$s_{i,t}$&lt;/span&gt; represents the inventory level of product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at the end of the time period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Also, &lt;span class=&quot;math-container&quot;&gt;$SS_{i,t}$&lt;/span&gt; represents the initial stock of item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at the beginning of the planning&#xA;horizon that can be assumed to be zero, and &lt;span class=&quot;math-container&quot;&gt;$D_{i,t}$&lt;/span&gt; is the demand forecast.&lt;/p&gt;&#xA;&lt;p&gt;Now, one possible way to capture the perished inventory constraint is to define the new auxiliary variable &lt;span class=&quot;math-container&quot;&gt;$ps_{i,t} \in \mathbb{R}_{+}$&lt;/span&gt;, adding this constraint &lt;span class=&quot;math-container&quot;&gt;$ps_{i,t} = \max(0, s_{i,t+t^{'}}-s_{i,t})$&lt;/span&gt; that &lt;span class=&quot;math-container&quot;&gt;$t^{'}$&lt;/span&gt; is fixed number of days to perish, and its appropriate penalty in the objective function. I think actually the above model does not allow to produce the excess inventory.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-11-03T19:40:07.707" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9254" PostTypeId="2" ParentId="9243" CreationDate="2022-11-04T00:00:13.993" Score="5" Body="&lt;p&gt;I have no idea (i) whether the following can be encoded in a CP solver and (ii) how efficient it would be. On the pro side, it only requires a linear number of variables and constraints.&lt;/p&gt;&#xA;&lt;p&gt;Say you have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; boolean variables &lt;span class=&quot;math-container&quot;&gt;$x_{0}, ..., x_{n-1}$&lt;/span&gt;.&#xA;You can introduce an integer-valued counter &lt;span class=&quot;math-container&quot;&gt;$s_{0}, ..., s_{n-1}$&lt;/span&gt; such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;s_{0} = \left\{&#xA;    \begin{array}{ll}&#xA;        n &amp;amp; \text{ if } x_{0} = 0\\&#xA;        0 &amp;amp; \text{ if } x_{0} = 1&#xA;    \end{array}&#xA;\right.&#xA;\qquad&#xA;s_{i} = \left\{&#xA;    \begin{array}{ll}&#xA;        n &amp;amp; \text{ if } x_{i} = 0 \land s_{i-1}=n\\&#xA;        s_{i-1} + 1 &amp;amp; \text{ if } x_{i} = 0\land s_{i-1} \neq n\\&#xA;        0 &amp;amp; \text{ if } x_{i} = 1&#xA;    \end{array}&#xA;\right.&#xA;$$&lt;/span&gt;&#xA;This counter starts from &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, is incremented as long as &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; remains zero and if it's not equal to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, and is reset to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; every time &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; takes value one.&lt;/p&gt;&#xA;&lt;p&gt;From there, we can just maximize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, subject to the additional constraints :&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_i = 1 \Rightarrow z \leq s_{i-i}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the example you gave in the original question, this would yield something like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+&#xA;x | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |&#xA;  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+&#xA;s | n | n | 0 | 1 | 2 | 3 | 0 | 1 | 2 | 0 | 1 | 2 | 3 | 4 | 0 | 1 | 2 | 3 |&#xA;  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+&#xA;            ↑               ↑           ↑                   ↑&#xA;          z ≤ n           z ≤ 3       z ≤ 2               z ≤ 4&#xA;        (trivial)                   (stronger)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="1223" LastEditDate="2022-11-05T12:56:43.373" LastActivityDate="2022-11-05T12:56:43.373" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9255" PostTypeId="2" ParentId="9240" CreationDate="2022-11-04T03:24:28.370" Score="-2" Body="&lt;p&gt;How about small &lt;span class=&quot;math-container&quot;&gt;$m = 1e-6$&lt;/span&gt;?&lt;br /&gt;&#xA;So &lt;span class=&quot;math-container&quot;&gt;$ y &amp;gt;= y + \frac{x^2}{x+m}$&lt;/span&gt;&lt;br /&gt;&#xA;So if x&amp;gt;0 y is updated by x else not.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-11-04T03:32:57.417" LastActivityDate="2022-11-04T03:32:57.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9256" PostTypeId="1" CreationDate="2022-11-04T11:23:59.750" Score="3" ViewCount="290" Body="&lt;p&gt;I am trying to model a MIP for a Capacitated Facility Location problem in a way that a number of selected candidate locations will always be there. How can I model it?&lt;/p&gt;&#xA;&lt;p&gt;My approach:&lt;/p&gt;&#xA;&lt;p&gt;Add a cost parameter which will be 0 for the selected candidate locations and it will take some values (depending on the problem) for all the other candidate locations. This will gravitate the model towards having the desired candidate locations in the solutions but it might not scale properly.&lt;/p&gt;&#xA;" OwnerUserId="5532" LastEditorUserId="491" LastEditDate="2022-11-04T13:01:23.340" LastActivityDate="2022-11-04T18:13:09.840" Title="Modelling a Capacitated Facility Location Problem in such a way that a few candidate locations are always selected" Tags="|optimization|mixed-integer-programming|modeling|combinatorial-optimization|facility-location|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9257" PostTypeId="2" ParentId="9256" CreationDate="2022-11-04T13:06:46.593" Score="3" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum{x_i} = N$&lt;/span&gt;&lt;br /&gt;&#xA;where N is desired number of locations and x is binary, i is index of candidates&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-11-04T13:06:46.593" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9258" PostTypeId="2" ParentId="9256" CreationDate="2022-11-04T18:13:09.840" Score="5" Body="&lt;p&gt;I assume that you have some sort of &amp;quot;solver&amp;quot; for solving a capacitated facility location problem, which you want to utilize.&lt;/p&gt;&#xA;&lt;p&gt;If you need a specific facility, say facility &lt;span class=&quot;math-container&quot;&gt;$\tilde{i}$&lt;/span&gt;, to be open, it may not be enough to set the opening cost for that facility to zero, as you may still have &lt;span class=&quot;math-container&quot;&gt;$x_{\tilde{i}}=0$&lt;/span&gt; in an optimal solution. What you can do is to add a dummy customer &lt;span class=&quot;math-container&quot;&gt;$j'$&lt;/span&gt; with an assignment cost of &lt;span class=&quot;math-container&quot;&gt;$c_{\tilde{i}j'}=0$&lt;/span&gt; and a demand of &lt;span class=&quot;math-container&quot;&gt;$d_{j'}=0$&lt;/span&gt;. The remaining assignment costs should be &lt;span class=&quot;math-container&quot;&gt;$c_{ij'}=\infty$&lt;/span&gt; for all other facilities. Given assignment constraints requiring to assign all customers, this will force the facility &lt;span class=&quot;math-container&quot;&gt;$\tilde{i}$&lt;/span&gt; to be open in any optimal solution.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-11-04T18:13:09.840" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9259" PostTypeId="2" ParentId="102" CreationDate="2022-11-06T13:28:26.930" Score="7" Body="&lt;p&gt;Article: &lt;a href=&quot;https://www.researchgate.net/publication/369926923_Loss_functions_for_inventory_control&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.researchgate.net/publication/369926923_Loss_functions_for_inventory_control&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$L_1(r)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$L_c(r)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L_2(r)$&lt;/span&gt; be the first-order, complementary and second-order loss functions respectively. Also, define &lt;span class=&quot;math-container&quot;&gt;$F(x)$&lt;/span&gt; as the CDF of a distribution defined at &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; with a set of parameters and &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; as the PDF or PMF (continuous vs discrete) defined at &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; with a set of parameters.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/em&gt; Observe that from the answer of @TheSimpliFire, the first-order loss function can be expressed as&lt;span class=&quot;math-container&quot;&gt;$$ n(x)=\Bbb E(X)-L(x).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this post &lt;span class=&quot;math-container&quot;&gt;$n(x)$&lt;/span&gt; is given directly. So for example, in the case of the exponential distribution, you can see that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$n(x)=\frac{1}{\lambda}-\left(\frac{1}{\lambda}(1-e^{-\lambda x})\right)$$&lt;/span&gt;, which gives &lt;span class=&quot;math-container&quot;&gt;$$n(x) = \frac{e^{-\lambda x}}{\lambda}$$&lt;/span&gt;, which is the same as &lt;span class=&quot;math-container&quot;&gt;$L_1(r) = \frac{e^{-\beta r}}{\beta}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\lambda=\beta$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Normal distribution&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p = \frac{r-\mu}{\sigma}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$F(.)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f(.)$&lt;/span&gt; are the CDF and PDF of the standard normal distribution respectively.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_1(r) = (\mu-r)[1-F(p)]+\sigma f(p)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_c(r) = (r-\mu)F(p)+\sigma f(p)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_2(r) = \frac{1}{2}[(r-\mu)^2+\sigma^2][1-F(p)]-\frac{1}{2}\sigma f(p)[r-\mu]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Log-normal distribution&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_1 = \frac{ln(r)-\mu-2\sigma^2}{\sigma}$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$p_2 = \frac{ln(r)-\mu-\sigma^2}{\sigma}$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$p_3 = \frac{ln(r)-\mu}{\sigma}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$L_1(r) = e^{\mu+\frac{\sigma^2}{2}}[1-F(p_2)]-r[1-F(p_3)]$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_c(r) = rF(p_3) - e^{\mu+\frac{\sigma^2}{2}}F(p_2)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_2(r) = \frac{r^2}{2}[1-F(p_3)]-re^{\mu+\frac{\sigma^2}{2}}[1-F(p_2)]+\frac{1}{2}e^{2\left(\mu+\frac{\sigma^2}{2}\right)}[1-F(P_1)]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Exponential distribution&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$L_1(r) = \frac{e^{-\beta r}}{\beta}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_c(r) = r-\left(\frac{1-e^{-\beta r}}{\beta}\right)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_2(r) = \frac{e^{-\beta r}}{\beta^2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Gamma distribution&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$L_1(r) = \frac{\alpha}{\beta}[1-F(r; \alpha+1, \beta)]-r[1-F(r; \alpha, \beta)]$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_c(r) = rF(r; \alpha, \beta)-\frac{\alpha}{\beta}F(r; \alpha+1, \beta)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_2(r) = \frac{r^2}{2}[1-F(r; \alpha, \beta)]-\frac{r\alpha}{\beta}[1-F(r; \alpha+1, \beta)]+\frac{\alpha(\alpha+1)}{2\beta^2}[1-F(r;\alpha+2, \beta)]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Negative binomial distribution&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$L_1(r) = \frac{np}{1-p}[1-F(r-2; n+1, p)]-r[1-F(r-1; n, p)]$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_c(r) = rF(r-1; n, p) - \frac{np}{1-p}F(r-2; n+1, p)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_2(r) = \left(\frac{r^2+r}{2}\right)[1-F(r-1; n, p)]-\frac{rnp}{(1-p)}[1-F(r-2;n+1, p)]+\frac{(np)^2+np^2}{2(1-p)^2}[1-F(r-3; n+2, p)]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Geometric distribution&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$L_1(r) = \frac{(1-p)^r}{p}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_c(r) = \frac{(1-p)^r+pr-1}{p}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_2(r) = \frac{(1-p)^{r+1}}{p^2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Logarithmic distribution&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta = -\frac{1}{\ln(1-p)}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$L_1(r) = \frac{\beta p^r}{1-p}-r[1-F(r-1)]$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_c(r) = rF(r) - \beta\left[\frac{1-p^{r+1}}{1-p}-1\right]$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_2(r) = \frac{1}{2}[r^2+r][1-F(r-1)]+\frac{\beta (2r+1)p^r}{2(p-1)}-\frac{\beta p^r[p(r-1)-r]}{2(1-p)^2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Poisson distribution&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$L_1(r) = -(r-\lambda)[1-F(r)]+\lambda f(r)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_c(r) = (r-\lambda)F(r) + \lambda f(r)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$L_2(r) = \frac{1}{2}\left([(r-\lambda)^2 + r][1-F(r)]-\lambda(r-\lambda)f(r)\right)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2023-07-30T09:20:14.170" LastActivityDate="2023-07-30T09:20:14.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9260" PostTypeId="1" CreationDate="2022-11-06T20:53:54.110" Score="3" ViewCount="175" Body="&lt;p&gt;For my research, I am interested in finding the trajectory outlined by the pivots along the way of optimizing an LP problem, but I only know how to use Python PuLP to obtain the optimal solution. Is there any way to also obtain the intermediate solutions using PuLP or any solver? I saw Gurobi has callback functions, how would that work? (It is intended for Mixed Integer Problem, but I have just a regular LP problem.) Other programming languages are also okay.&lt;/p&gt;&#xA;" OwnerUserId="10692" LastEditorUserId="491" LastEditDate="2022-11-07T12:53:09.983" LastActivityDate="2022-11-07T12:53:09.983" Title="Find all pivots that the simplex algorithm visited, i.e., the intermediate solutions, using Python" Tags="|optimization|linear-programming|python|solver|pulp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9261" PostTypeId="1" CreationDate="2022-11-07T02:34:42.170" Score="3" ViewCount="128" Body="&lt;p&gt;I would like to model the following constraint set in gurobi-java.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;t^n_{ij} \geq t^n_{(i-1)j}+S_{(i-1)j} - (1 - \sum_{\substack{m \in \mathcal{M} \\ G_{ijm} = 1}}\sum_{k \in \mathcal{K}} x^n_{ijmk}) \times \Omega&#xA;    \hspace{1cm} \forall j \in \mathcal{J}; i \in \mathcal{I}_j/1; n \in \mathcal{N}_j&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$t^n_{ij} \in \mathbb{R}_{\geq0}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x^n_{ijmk} \in \{0,1\}$&lt;/span&gt; are decision variables. I have modeled this constraint set in gurobi-java as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;GRBVar[][][][][] x = new GRBVar[i_idx][j_idx][n_idx][m_idx][k_idx];&#xA;for (int j : j_set) {&#xA;    for (int i : i_set[j]) {&#xA;        for (int n : n_set[j]) {&#xA;            for (int m : m_set) {&#xA;                if (G[i][j][m] == true) {&#xA;                    for (int k : k_set) {&#xA;                        x[i][j][n][m][k] = model.addVar(0, 1, 1, GRB.BINARY,&#xA;                                i + &amp;quot;_&amp;quot; + j + &amp;quot;_&amp;quot; + n + &amp;quot;_&amp;quot; + m + &amp;quot;_&amp;quot; + k);&#xA;                    }&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;GRBVar[][][] t = new GRBVar[i_idx][j_idx][n_idx];&#xA;for (int j : j_set) {&#xA;    for (int i : i_set[j]) {&#xA;        for (int n : n_set[j]) {&#xA;            t[i][j][n] = model.addVar(0, GRB.INFINITY, 0, GRB.CONTINUOUS,&#xA;                    i + &amp;quot;_&amp;quot; + j + &amp;quot;_&amp;quot; + n);&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;GRBVar[][][] auxvar1 = new GRBVar[i_idx][j_idx][n_idx];&#xA;for (int j : j_set) {&#xA;    for (int i : i_set[j]) {&#xA;        for (int n : n_set[j]) {&#xA;            auxvar1[i][j][n] = model.addVar(0, 1, 1, GRB.BINARY,&#xA;                    i + &amp;quot;_&amp;quot; + j + &amp;quot;_&amp;quot; + n);&#xA;&#xA;            GRBLinExpr lhs = new GRBLinExpr();&#xA;            GRBLinExpr rhs = new GRBLinExpr();&#xA;&#xA;            lhs.addTerm(1, auxvar1[i][j][n]);&#xA;            rhs.addConstant(1);&#xA;            for (int m : m_set) {&#xA;                if (G[i][j][m] == true) {&#xA;                    for (int k : k_set) {&#xA;                        rhs.addTerm(-1, x[i][j][n][m][k]);&#xA;                    }&#xA;                }&#xA;            }&#xA;&#xA;            model.addConstr(lhs, GRB.EQUAL, rhs, &amp;quot;auxiliary_&amp;quot; + i + &amp;quot;_&amp;quot; + j + &amp;quot;_&amp;quot; + n);&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;&#xA;for (int j : j_set) {&#xA;    for (int i = 1; i &amp;lt; i_set[j].length; i++) {&#xA;        for (int n : n_set[j]) {&#xA;            GRBLinExpr lhs = new GRBLinExpr();&#xA;            GRBLinExpr rhs = new GRBLinExpr();&#xA;&#xA;            lhs.addTerm(1, t[i][j][n]);&#xA;&#xA;            rhs.addTerm(1, t[i-1][j][n]);&#xA;            rhs.addConstant(S[j][i-1]);&#xA;            rhs.addTerm(-Omega, auxvar1[i][j][n]);&#xA;&#xA;            model.addConstr(lhs, GRB.GREATER_EQUAL, rhs, &amp;quot;time_flow_&amp;quot; + i + &amp;quot;_&amp;quot; + j + &amp;quot;_&amp;quot; + n);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In comparison to docplex-python, it is much less readable and requires much more lines of code.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mdl.add_constraints(t[i, j ,n] &amp;gt;= t[i-1, j, n] + S[i-1, j] - (1 - mdl.sum(x[i, j, n, m, k] for m in m_set if G[i, j, m] == 1 for k in k_set) * Omega for j in j_set for i in i_set[j] if i &amp;gt; 0 for n in n_set[j]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am new to gurobi-java. Are there any better ways to model this constraint set.&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="491" LastEditDate="2022-11-07T12:55:02.447" LastActivityDate="2022-11-07T12:55:02.447" Title="Efficient modelling via Gurobi" Tags="|modeling|constraint|gurobi|java|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9262" PostTypeId="2" ParentId="9261" CreationDate="2022-11-07T03:35:06.810" Score="2" Body="&lt;p&gt;Probably not the answer you want, but Gurobi has a very nice Python interface. I'd be surprised if there was anything you liked from &lt;code&gt;docplex&lt;/code&gt; that you wouldn't find to be at least as good or better in &lt;code&gt;gurobipy&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;When porting Python code to Java code, as a rule, there will probably a loss in readability/brevity. That's why Python is far more popular for data science, and now, for even general purpose programming.&lt;/p&gt;&#xA;" OwnerUserId="339" LastActivityDate="2022-11-07T03:35:06.810" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9263" PostTypeId="2" ParentId="9260" CreationDate="2022-11-07T11:02:04.217" Score="3" Body="&lt;p&gt;I doubt that Gurobi has a callback to give you all intermediate solutions and even if it did I am not sure that this would be useful for you. Simplex solvers perturb the problem to avoid degeneracy and switch back and forth between  primal and dual simplex (not too mention special algorithms like sifting and folding), so you would probably not be able to do much with these intermediate solutions without exactly understanding their context.&lt;/p&gt;&#xA;&lt;p&gt;It is probably possible to look into one of the open source solvers code (HiGHs, CLP, SoPlex, GLPK) but because of the aforementioned reasons this is not exactly easy without a deep understanding of how modern simplex solvers work and sadly there are no good textbooks for that.&lt;/p&gt;&#xA;&lt;p&gt;In the end the question remains, what do you want to do with the intermediate solutions? Do you want primal feasible solutions (i.e. heuristic solutions to an LP), those you can get from the iterations of a primal simplex, but the problem might be perturbed. There might be other ways to get those. Or do you want optimality bounds by looking at dual feasible solutions and maybe stop early? Some simplex solvers allow you to do that by setting a stopping bound before you start to solve. If you elaborate on that, maybe I can give a more helpful answer.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2022-11-07T11:02:04.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9264" PostTypeId="2" ParentId="9260" CreationDate="2022-11-07T12:27:18.007" Score="3" Body="&lt;p&gt;I'm not completely sure that its a viable way to go, but Gurobi has a parameter called &lt;code&gt;IterationLimit&lt;/code&gt;. As I understand it, it sets an upper limit on the number of simplex iterations performed during the solution process. So in principle, you can set &lt;code&gt;IterationLimit=1&lt;/code&gt; and then switch between solving and expecting the solution returned. You can read about the parameter &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/iterationlimit.html#parameter:IterationLimit&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="609" LastActivityDate="2022-11-07T12:27:18.007" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9265" PostTypeId="1" CreationDate="2022-11-07T15:09:54.737" Score="2" ViewCount="328" Body="&lt;p&gt;I have many quadratic programming problems of the following form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x\in\mathbb{R}^n} { \tfrac{1}{2} {\lVert Cx-d \rVert}^2} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\textrm{s.t.}\ x_1\le 0,\ x_n\le 0,\ x_n\le a_1^\top x_{1:n-1},\ \dots,\ x_n\le a_m^\top x_{1:n-1},$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$a_1,\dots,a_m\in\mathbb{R}^{n-1}$&lt;/span&gt;, and where &lt;span class=&quot;math-container&quot;&gt;$x_{1:n-1}$&lt;/span&gt; is a vector containg the first &lt;span class=&quot;math-container&quot;&gt;$n-1$&lt;/span&gt; elements of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have been trying to solve these numerically using a standard quadratic programming solver (OSQP). However, the problem is numerically ill-conditioned, with huge differences in scale across elements of &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$a_m$&lt;/span&gt;. I have experimented with various normalizations of these quantities, but they have all resulted in extremely inaccurate &amp;quot;solutions&amp;quot;. (The solver found these &amp;quot;solutions&amp;quot; much more easily, but this is still not very helpful.)&lt;/p&gt;&#xA;&lt;p&gt;I was wondering if the special structure of my problem would permit a more direct solution method which would preserve greater numerical accuracy.&lt;/p&gt;&#xA;&lt;p&gt;In particular, given a point &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; that is not necessarily feasible, we can convert it into a feasible point by setting:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_1\leftarrow \min{\lbrace x_1,0\rbrace}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_n\leftarrow \min{\lbrace x_n,0,a_1^\top x_{1:n-1},\dots,a_m^\top x_{1:n-1} \rbrace}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can this fact be used to produce an efficient algorithm for the problem? (Non-negative least squares style, perhaps.)&lt;/p&gt;&#xA;" OwnerUserId="3830" LastEditorUserId="3830" LastEditDate="2022-11-07T17:16:52.770" LastActivityDate="2022-11-08T07:58:53.133" Title="Poorly conditioned quadratic programming with &quot;simple&quot; linear constraints" Tags="|quadratic-programming|numerical-issues|numerical-stability|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9266" PostTypeId="2" ParentId="9265" CreationDate="2022-11-07T16:42:05.617" Score="5" Body="&lt;p&gt;I would recommend you try an interior-point based optimizer. As far I recall OSQP employs a first-order method which is less robust than interior-point based optimizers.&lt;/p&gt;&#xA;&lt;p&gt;Also, I would recommend you remove the square in the objective and hence minimize the norm directly. That often leads to a better-conditioned problem. If you do that, then you need a conic optimizer.&lt;/p&gt;&#xA;&lt;p&gt;Personally, I prefer &lt;a href=&quot;https://wwww.mosek.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek&lt;/a&gt; for obvious reasons.&lt;/p&gt;&#xA;&lt;p&gt;PS. The second sin shown at&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://nhigham.com/2022/10/11/seven-sins-of-numerical-linear-algebra/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://nhigham.com/2022/10/11/seven-sins-of-numerical-linear-algebra/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;explains one potential reason for the ill-conditioning of using the QP formulation.&lt;/p&gt;&#xA;&lt;p&gt;PPS: Reformulating the QP as a conic problem does not lead to a loss in computational complexity. Hence, no one can prove the QP formulation is superior in theory.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2022-11-08T07:58:53.133" LastActivityDate="2022-11-08T07:58:53.133" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9267" PostTypeId="1" CreationDate="2022-11-07T20:42:59.393" Score="1" ViewCount="101" Body="&lt;p&gt;In this case, the shop want to maximise the profit that is there &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; products the shop can procure, but the shop only has &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; budget. The cost of each product &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I used prediction model and predict each product &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; will have total &lt;span class=&quot;math-container&quot;&gt;$N_i$&lt;/span&gt; sales in the future 10 days. The selling price of each product &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So, I give the objective function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;max f=\sum_{i}^{n}(s_i - c_i)x_i \\&#xA;s.t.\\&#xA;x_i \in Z \\&#xA;\sum_{i}^{n} c_ix_i \leq w \\&#xA;x_i \leq N_i\\ i = 1,2, ..., n&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N_i$&lt;/span&gt; are all constants.&lt;/p&gt;&#xA;&lt;p&gt;I want to solve this &lt;strong&gt;integer programming&lt;/strong&gt; by python. But what I find online is more about linear programming. Is there any friendly Python package solver?&lt;/p&gt;&#xA;" OwnerUserId="10697" LastEditorUserId="10697" LastEditDate="2022-11-07T22:59:00.843" LastActivityDate="2022-11-07T23:20:03.437" Title="convert x=min(x, N) function into a constraint, integer programming python" Tags="|mixed-integer-programming|integer-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9268" PostTypeId="2" ParentId="9267" CreationDate="2022-11-07T23:20:03.437" Score="2" Body="&lt;p&gt;Both &lt;a href=&quot;https://github.com/coin-or/Pulp&quot; rel=&quot;nofollow noreferrer&quot;&gt;PuLP&lt;/a&gt; and &lt;a href=&quot;https://www.pyomo.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo&lt;/a&gt; are widely used open-source Python modeling libraries with links to a variety of solver packages, both open-source and commercial.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-07T23:20:03.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9269" PostTypeId="1" AcceptedAnswerId="9270" CreationDate="2022-11-08T01:54:51.673" Score="3" ViewCount="186" Body="&lt;p&gt;I have the following problem&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min \sum_{i\in I} \sum_{j \in J} c_{ij} x_{ij} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s.t.  \sum_{j \in J} x_{ij} \leq b_i, \forall i \in I$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in S_l} x_{ij} \leq 1, \forall l \in L, i \in I $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I} x_{ij} = 1, \forall j \in J$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; is 0 or 1 for all &lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; is a non-negative integer, and &lt;span class=&quot;math-container&quot;&gt;$\cup_{l \in L} S_l = J$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S_{l1} \cap S_{l2} = \emptyset$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$l1, l2 \in L$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I wonder if it has an integer polyhedron. I'd really appreciate your help.&lt;/p&gt;&#xA;" OwnerUserId="10699" LastEditorUserId="10699" LastEditDate="2022-11-08T01:56:18.733" LastActivityDate="2022-11-08T02:23:42.520" Title="Assignment problem with mutually exclusive constraints has an integral polyhedron?" Tags="|optimization|integer-programming|combinatorial-optimization|assignment-problem|totally-unimodular|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9270" PostTypeId="2" ParentId="9269" CreationDate="2022-11-08T02:08:32.613" Score="4" Body="&lt;p&gt;Hint: Reformulate as a minimum-cost network flow problem in a directed network with supply nodes &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;, demand nodes &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;, and transshipment nodes &lt;span class=&quot;math-container&quot;&gt;$I \times L$&lt;/span&gt;.  You can model the upper bound of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; on flow into each &lt;span class=&quot;math-container&quot;&gt;$(i,\ell)\in I \times L$&lt;/span&gt; by a node-splitting transformation that moves these upper bounds to the arcs.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-11-08T02:23:42.520" LastActivityDate="2022-11-08T02:23:42.520" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9271" PostTypeId="2" ParentId="9240" CreationDate="2022-11-08T07:23:21.893" Score="1" Body="&lt;p&gt;I think @RobPratt 's anwser can surely handle your problem.&lt;br /&gt;&#xA;While if you want to extend x, y to real number, here's an idea in wider range to use:&lt;br /&gt;&#xA;You can introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;, and add the following constraints:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x\le M(1-\mu)\tag{1}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x\ge 1-M\mu\tag{2}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y'\ge y+x-M\mu\tag{3}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y'\le y+x+M\mu\tag{4}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y'\le y+M(1-\mu)\tag{5}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y'\ge y-M(1-\mu)\tag{6}$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$y'$&lt;/span&gt; means &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; after update in order to distinguish y before and after update, and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a big number.&lt;/p&gt;&#xA;&lt;p&gt;when &lt;span class=&quot;math-container&quot;&gt;$x\le 0$&lt;/span&gt;, constraints (1) and (2) forces &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; to be 1, so (5)(6) are active while the others are not, which indicates &lt;span class=&quot;math-container&quot;&gt;$y'\le y$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y'\ge y$&lt;/span&gt;, therefore when &lt;span class=&quot;math-container&quot;&gt;$x\le 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y'=y$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;when &lt;span class=&quot;math-container&quot;&gt;$x\ge 1$&lt;/span&gt;, constraints (1) and (2) forces &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; to be 0, so (3)(4) are active while the others are not, which indicates &lt;span class=&quot;math-container&quot;&gt;$y'\le y+x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y'\ge y+x$&lt;/span&gt;, therefore when &lt;span class=&quot;math-container&quot;&gt;$x\ge 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y'=y+x$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="6152" LastEditorUserId="6152" LastEditDate="2022-11-09T03:11:15.523" LastActivityDate="2022-11-09T03:11:15.523" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9272" PostTypeId="1" AcceptedAnswerId="9278" CreationDate="2022-11-08T12:03:47.420" Score="5" ViewCount="605" Body="&lt;p&gt;Considering the definition of upper incomplete gamma function: &lt;span class=&quot;math-container&quot;&gt;$\Gamma(a, x) =$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\int_{x}^{\infty}t^{a-1}e^{-t} dt$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Given that &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is fixed and &lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt; x &amp;lt; a$&lt;/span&gt;, can we prove the function is convex over &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10701" LastEditorUserId="491" LastEditDate="2022-11-10T21:55:01.647" LastActivityDate="2022-11-10T21:55:01.647" Title="Is upper incomplete gamma function convex?" Tags="|convexity|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9273" PostTypeId="1" AcceptedAnswerId="9275" CreationDate="2022-11-08T16:44:37.527" Score="1" ViewCount="195" Body="&lt;p&gt;I have an interesting assignment problem in which I have a cost matrix for workers and tasks, and need to assign each worker to exactly one task to minimize the cost.&lt;/p&gt;&#xA;&lt;p&gt;However, this is all subject to the constraint that there must be no more than &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; tasks being performed overall, by any worker.&lt;/p&gt;&#xA;&lt;p&gt;I have not been able to find any literature about this specific problem and was wondering if it is known, and how best to solve it?&lt;/p&gt;&#xA;" OwnerUserId="10704" LastEditorUserId="491" LastEditDate="2022-11-10T21:54:20.327" LastActivityDate="2022-11-10T21:54:20.327" Title="Assignment problem with constrained number of unique tasks" Tags="|constraint-programming|assignment-problem|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9274" PostTypeId="2" ParentId="9272" CreationDate="2022-11-08T17:25:50.470" Score="10" Body="&lt;p&gt;The incomplete gamma function is not convex with respect to x for fixed a for 0 &amp;lt; x &amp;lt; a, as evidenced by the following counterexample.&lt;/p&gt;&#xA;&lt;p&gt;Counterexample for a = 10, and x = 1, 5, 9:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;gammainc(5,10,'upper')&#xA;    0.9682&#xA;&#xA;0.5*(gammainc(1,10,'upper')+gammainc(9,10,'upper'))&#xA;    0.7937&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="68" LastActivityDate="2022-11-08T17:25:50.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9275" PostTypeId="2" ParentId="9273" CreationDate="2022-11-08T17:35:17.100" Score="3" Body="&lt;p&gt;You could formulate it as an Integer linear program (ILP), then implement it in e.g. Pythons pulp library and ​solve it with a standard solver such as the open source COIN solver.&lt;/p&gt;&#xA;&lt;p&gt;Based on the comment given below this answer, the ILP could then look as follows:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt; be a task and &lt;span class=&quot;math-container&quot;&gt;$w\in W$&lt;/span&gt; be the workers. The costs of assigning a worker &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; to a task &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; are given by &lt;span class=&quot;math-container&quot;&gt;$c_{wt}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;DECISION VARIABLES&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{wt}$&lt;/span&gt; Binary variable: &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if worker &lt;span class=&quot;math-container&quot;&gt;$w \in W$&lt;/span&gt; is working on task &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if not.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{t}$&lt;/span&gt; Binary variable: &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if task &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt; is performed and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if not.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Linear Program&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\&#xA;&amp;amp; \min z = \sum_{w \in W}\sum_{t \in T} x_{wt} \cdot c_{wt}  \; \\&#xA;\textit{S.t.}\\&#xA;\\&#xA;&amp;amp; \sum_{t \in T}  x_{wt} = 1 &amp;amp; \forall w \in W \tag1 \\ &#xA;&amp;amp;  x_{wt} \leq y_t &amp;amp; \forall t \in T, w \in W \tag2 \\ &#xA;&amp;amp; \sum_{t \in T}  y_{t} \leq 3 &amp;amp;  \tag3 \\ &#xA;&amp;amp;   x_{wt} \in \{0,1 \} &amp;amp; \forall w \in W, t \in T \tag4 \\&#xA;&amp;amp;   y_{t} \in \{0,1 \} &amp;amp; \forall t \in T \tag5&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective is to minimize overall costs. Constraint (1) assures that each worker is assigned to exactly one task. Constraint (2) assures that the binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is set to 1 if a worker is assigned to it. Constraint (3) assures that no more than 3 tasks are performed.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="3464" LastEditDate="2022-11-09T12:19:32.960" LastActivityDate="2022-11-09T12:19:32.960" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9278" PostTypeId="2" ParentId="9272" CreationDate="2022-11-08T18:13:34.220" Score="10" Body="&lt;p&gt;No, you cannot prove it is convex in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; because it is not, as Mark's counterexample indicates. For fixed &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\Gamma$&lt;/span&gt; is concave for &lt;span class=&quot;math-container&quot;&gt;$x\in (0, a-1)$&lt;/span&gt; and convex for &lt;span class=&quot;math-container&quot;&gt;$x\in (a-1, a).$&lt;/span&gt; Differentiating twice tells the story:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{\partial \Gamma}{\partial x} = -x^{a-1} e^{-x}$$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$$\frac{\partial^2 \Gamma}{\partial x^2} = e^{-x} x^{a-2} (x - a + 1).$$&lt;/span&gt; The sign of &lt;span class=&quot;math-container&quot;&gt;$x-a+1$&lt;/span&gt; determines the sign of the second partial derivative.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-08T18:13:34.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9279" PostTypeId="1" AcceptedAnswerId="9281" CreationDate="2022-11-09T00:45:03.883" Score="2" ViewCount="435" Body="&lt;p&gt;I am currently new to pyomo and modelling techniques but I came across information mentioning that the CPLEX and Gurobi APIs offer a functionality where you can re-use already computed values and feed them before solving the same model again. It should be useful when performing several similar computations where information from already computed models can be re-used to optimize new computations.&lt;/p&gt;&#xA;&lt;p&gt;Is someone aware of such functionality?&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="500" LastEditDate="2023-12-13T18:02:52.203" LastActivityDate="2023-12-13T18:02:52.203" Title="Re-optimizing pyomo model based on previous computation" Tags="|python|cplex|gurobi|pyomo|warm-start|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9281" PostTypeId="2" ParentId="9279" CreationDate="2022-11-09T14:47:04.727" Score="2" Body="&lt;p&gt;What you are looking for is called &lt;em&gt;warm starting&lt;/em&gt;. In the &lt;a href=&quot;https://pyomo.readthedocs.io/en/stable/working_models.html#warm-starts&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo documentation&lt;/a&gt; you can find more information on this.&lt;/p&gt;&#xA;&lt;p&gt;Quoting directly from the manual:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Some solvers support a warm start based on current values of variables. To use this feature, set the values of variables in the instance and pass warmstart=True to the solve() method. E.g.,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;instance = model.create()&#xA;instance.y[0] = 1&#xA;instance.y[1] = 0&#xA;&#xA;opt = pyo.SolverFactory(&amp;quot;cplex&amp;quot;)&#xA;&#xA;results = opt.solve(instance, warmstart=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-11-09T14:47:04.727" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9282" PostTypeId="1" CreationDate="2022-11-09T19:52:55.640" Score="1" ViewCount="326" Body="&lt;p&gt;I am aware that the types provided by pyomo are immutable and often cause issues when we feed the same data twice in consecutive computations (e.g. when trying to solve an instance a couple of times) What is the best way to reset model parameters after solving?&lt;/p&gt;&#xA;&lt;p&gt;In my case, I use a model which I need to solve several times with minor changes in the input that is fed to it. Solving the model does not seem to produce any errors but it outputs a warning saying&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;WARNING ELEMENT already exists in Set Ordered ScalarSet.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I also noticed that the objective value gets updated by building on top of the previously calculated objective value. Does someone know a good way to fix this problem?&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="491" LastEditDate="2022-11-10T21:53:06.500" LastActivityDate="2022-11-10T21:53:06.500" Title="Resetting Pyomo model after computation" Tags="|linear-programming|python|pyomo|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9283" PostTypeId="1" CreationDate="2022-11-10T10:57:53.027" Score="3" ViewCount="118" Body="&lt;p&gt;Is there a way that i can let Anylogic Collaborate with OptaPlanner?&lt;/p&gt;&#xA;&lt;p&gt;I need to do both Simulation and Optimization for a logistic project.&lt;/p&gt;&#xA;" OwnerUserId="10715" LastEditorUserId="491" LastEditDate="2022-11-10T21:52:35.307" LastActivityDate="2022-11-10T21:52:35.307" Title="OptaPlanner Collaboration with Anylogic" Tags="|multi-objective-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9284" PostTypeId="2" ParentId="9283" CreationDate="2022-11-10T16:18:56.660" Score="4" Body="&lt;p&gt;If you want o have OptaPlanner create schedules and then measure the quality (= the score) of each schedule through that Anylogic simulator, &lt;a href=&quot;https://www.optaplanner.org/docs/optaplanner/latest/score-calculation/score-calculation.html#easyJavaScoreCalculation&quot; rel=&quot;nofollow noreferrer&quot;&gt;take a look at the &lt;code&gt;EasyScoreCalculator&lt;/code&gt; interface in the docs&lt;/a&gt;. It's not incremental, so this approach won't scale well, but it does allow plugging in external score calculation easily.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2022-11-10T16:18:56.660" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9285" PostTypeId="1" AcceptedAnswerId="9286" CreationDate="2022-11-10T17:52:32.280" Score="3" ViewCount="366" Body="&lt;p&gt;I am having a constraint in the form :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x_i \leq z_j, \quad \forall i, j \in \{1, 2, .., n\}$$&lt;/span&gt;&#xA;I know that if the right part of the equation was a constant so something like &lt;span class=&quot;math-container&quot;&gt;$x_i \leq c[i]$&lt;/span&gt; I could write something like:&lt;br /&gt;&#xA;&lt;code&gt;@constraint(m, [i = 1:n], x[i] &amp;lt;= c[i]) &lt;/code&gt;&#xA;But know that they have not always the same index , what can I do ?&lt;/p&gt;&#xA;" OwnerUserId="10716" LastEditorUserId="10716" LastEditDate="2022-11-11T09:05:59.837" LastActivityDate="2022-11-11T09:05:59.837" Title="Jump, Julia : How to add constraints with different indexes a.c.a $x_i \leq z_j, \; \forall i, j$" Tags="|mixed-integer-programming|modeling|julia|jump|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9286" PostTypeId="2" ParentId="9285" CreationDate="2022-11-10T19:52:58.790" Score="4" Body="&lt;p&gt;Use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@constraint(m, [i=1:n, j=1:n], x[i] &amp;lt;= z[j])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in 1:n, j in 1:n&#xA;    @constraint(m, x[i] &amp;lt;= z[j])&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You might want to read the documentation: &lt;a href=&quot;https://jump.dev/JuMP.jl/stable/manual/constraints/#Containers-of-constraints&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://jump.dev/JuMP.jl/stable/manual/constraints/#Containers-of-constraints&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or look at similar problems in the tutorials: &lt;a href=&quot;https://jump.dev/JuMP.jl/stable/tutorials/linear/facility_location/#JuMP-implementation&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://jump.dev/JuMP.jl/stable/tutorials/linear/facility_location/#JuMP-implementation&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can also ask JuMP-specific questions on our forum: &lt;a href=&quot;https://discourse.julialang.org/c/domain/opt/13&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://discourse.julialang.org/c/domain/opt/13&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2022-11-10T19:52:58.790" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9287" PostTypeId="2" ParentId="5721" CreationDate="2022-11-11T09:15:30.060" Score="1" Body="&lt;p&gt;probably not the solution of you problem, but best fitting to you question in header:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.add_component('abc', Var(idx, domain=pmo.Boolean))&#xA;model.component('abc').pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10719" LastEditorUserId="10719" LastEditDate="2022-11-11T09:26:15.623" LastActivityDate="2022-11-11T09:26:15.623" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9288" PostTypeId="1" AcceptedAnswerId="9291" CreationDate="2022-11-11T09:31:53.603" Score="3" ViewCount="342" Body="&lt;p&gt;Given the following degenerate&#xA;optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad c^Tx\\\text{s.t.}&amp;amp;\quad Ax=b,\\&amp;amp;\quad x\ge 0\end{align}&lt;/span&gt;&#xA;Using primal simplex algorithm (either revised or tabular)&#xA;what exactly is implied when all directions given by negative elements of &lt;span class=&quot;math-container&quot;&gt;$c_N^T-c_B^TB^{-1}N$&lt;/span&gt; don't improve solution. if this case doesn't exist can we prove it, otherwise will &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; be optimal in such situation.&#xA;&lt;br&gt;&lt;br&gt;&#xA;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;&lt;br&gt;&#xA;we only are considering single column pivots. And similarly a case where a given basic solution, simplex indicates there is improvement yet non of the pivot actually improve objective function regardless of whether the basic solution is optimal.&lt;/p&gt;&#xA;" OwnerUserId="10668" LastEditorUserId="123" LastEditDate="2022-11-11T17:22:51.807" LastActivityDate="2022-11-11T17:22:51.807" Title="Question regarding primal Simplex method" Tags="|linear-programming|simplex|primal-simplex|" AnswerCount="3" CommentCount="2" FavoriteCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9289" PostTypeId="2" ParentId="9288" CreationDate="2022-11-11T10:10:02.473" Score="3" Body="&lt;p&gt;Assuming the current basis B is primal feasible, i.e. the primal solution x* computed for basis B satisfies all constraints, and that I interpret your notation correctly, this would imply that the dual solution (all equalities means duals are free) and reduced costs (only lower bounds) are dual feasible, which means B is an optimal basis.&lt;/p&gt;&#xA;&lt;p&gt;Edit: I interpreted &amp;quot;don't improve solution&amp;quot; as there are no negative reduced cost, i.e. there are no negative elements. This might not be how the question was intended. I guess the answer then is, if there are negative directions, they improve the solution, so this case does not exist.&lt;/p&gt;&#xA;&lt;p&gt;Edit again: Well, in the case of degeneracy, the step length for all negative elements can be zero, so that means a single pivot might not change the objective, but we can also not conclude optimality in this case because the reduced cost are not feasible and we hence have no certificate of optimality. I clearly misunderstood the question the first time I read it, sorry about that.&lt;/p&gt;&#xA;" OwnerUserId="302" LastEditorUserId="302" LastEditDate="2022-11-11T10:33:16.143" LastActivityDate="2022-11-11T10:33:16.143" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9290" PostTypeId="2" ParentId="9288" CreationDate="2022-11-11T11:42:42.997" Score="2" Body="&lt;p&gt;This can be a case where you already reached optimality, and at last iterations you are stuck at degeneracy&lt;/p&gt;&#xA;" OwnerUserId="10723" LastActivityDate="2022-11-11T11:42:42.997" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9291" PostTypeId="2" ParentId="9288" CreationDate="2022-11-11T12:11:32.447" Score="4" Body="&lt;p&gt;In the simplex method we only consider univariate search directions relative to the considered basis (i.e., picking one column from &lt;span class=&quot;math-container&quot;&gt;$x_N$&lt;/span&gt; to move). In the situation you describe, all univariate search directions that are improving (i.e., negative reduced cost) are assumed degenerate (i.e., maximum step length within feasible set is zero). This is indeed possible, but doesn't exclude the existence of improving multivariate search directions and so doesn't imply anything about your solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&#xA;Let&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min c^Tx\\\text{s.t}Ax=b,\\x\ge 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and let's throw some data into Julia:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;c = [1 1 0 1 -2]';&#xA;A = [1 0 0 1 -1; &#xA;     0 1 0 1 -1; &#xA;     0 0 1 0  1]&#xA;b = [0 0 1]';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In the initial singleton basis there is only one improving univariate search direction (&lt;span class=&quot;math-container&quot;&gt;$x_4$&lt;/span&gt;), but you can't increase the value of &lt;span class=&quot;math-container&quot;&gt;$x_4$&lt;/span&gt; from zero without breaking bounds on &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;. Hence this is a case where, to quote the question, &amp;quot;simplex indicates there is improvement yet non of the pivot actually improve objective function&amp;quot;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;bas=[1,2,3]&#xA;B=A[:,bas];&#xA;x=zeros(5); x[bas]=B\b; x    # 0 0 1  0 0&#xA;y=B'\c[bas]; c-A'*y          # 0 0 0 -1 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Nevertheless, after the degenerate pivot with steplength 0, we find a new improving univariate search direction (&lt;span class=&quot;math-container&quot;&gt;$x_5$&lt;/span&gt;):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;bas=[1,4,3];&#xA;B=A[:,bas];&#xA;x=zeros(5); x[bas]=B\b; x    # 0 0 1 0 0&#xA;y=B'\c[bas]; c-A'*y          # 0 1 0 0 -1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This time it is a nondegenerate pivot with steplength=1, leading to the optimal solution:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;bas=[1,4,5]; B=A[:,bas];&#xA;x=zeros(5); x[bas]=B\b; x    # 0 0 0 1 1&#xA;y=B'\c[bas]; c-A'*y          # 0 1 1 0 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This behavior occurs because the improving multivariate search direction &lt;span class=&quot;math-container&quot;&gt;$(\Delta x_4, \Delta x_5) = (1,1)$&lt;/span&gt; was available to us in the initial basis, but we couldn't follow it using the simplex method, so we had to go through a degenerate pivot (in general there can be more) to turn it into a univariate search direction.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2022-11-11T13:37:34.650" LastActivityDate="2022-11-11T13:37:34.650" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9292" PostTypeId="1" AcceptedAnswerId="9301" CreationDate="2022-11-12T04:10:53.783" Score="2" ViewCount="66" Body="&lt;p&gt;In the case of multiple stages with risk averse decision maker, there can be a decision situation where multiple resources has to be scheduled for consumption. These resources can have varying degree of risk associated with them, e.g., if you have two dishes and you want to decide which one you should eat first, you may want to eat the dish which has more chance of deterioration (if we assume no other factors like shortsightedness, taste preferences etc. will effect the decision).&#xA;This will prevent risk propagation to future time periods and make the overall solution of risk-averse optimization surly optimum give this decision will not effect cost etc.&lt;/p&gt;&#xA;" OwnerUserId="10727" LastActivityDate="2022-11-16T01:10:35.367" Title="In the context of risk-averse multi-stage programming and scheduling of resources consumption, is it always optimum to most risky resource first?" Tags="|optimization|multi-stage|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9293" PostTypeId="1" AcceptedAnswerId="9320" CreationDate="2022-11-12T07:38:44.287" Score="2" ViewCount="198" Body="&lt;p&gt;do all degenerate LP have have an equivalent non degenerate LP?&#xA;for example the following is a degenerate LP&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A=\begin{bmatrix}1&amp;amp;0&amp;amp;0&amp;amp;0&amp;amp;1&amp;amp;1&amp;amp;0\\0&amp;amp;1&amp;amp;0&amp;amp;1&amp;amp;0&amp;amp;1&amp;amp;0\\0&amp;amp;0&amp;amp;1&amp;amp;1&amp;amp;1&amp;amp;1&amp;amp;0\\0&amp;amp;0&amp;amp;1&amp;amp;0&amp;amp;0&amp;amp;1&amp;amp;1\end{bmatrix},\\b=\begin{bmatrix}1\\1\\1\\1\end{bmatrix}$$&lt;/span&gt;&#xA;you can choose initial basis indices as &lt;code&gt;[0,1,2,any]&lt;/code&gt;.and also &lt;span class=&quot;math-container&quot;&gt;$x\ge0$&lt;/span&gt;, what could be the non degenerate case? I must warn you this program isn't unbounded yet Mathematica identifies it as unbounded.&lt;/p&gt;&#xA;&lt;p&gt;&lt;br&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;br&gt; With prubin's answer i have reduced the system to &lt;span class=&quot;math-container&quot;&gt;$$x1+x2-x3+x6=1\\x3+x6+x7=1$$&lt;/span&gt; which is also degenerate assuming &lt;span class=&quot;math-container&quot;&gt;$x1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x2$&lt;/span&gt; are included in the basis on some other 2 additional rows. And also this system isn't totally unimodular due to &lt;span class=&quot;math-container&quot;&gt;$$\begin{bmatrix}1&amp;amp;1\\1&amp;amp;-1\end{bmatrix}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10668" LastEditorUserId="10668" LastEditDate="2022-11-18T10:52:48.483" LastActivityDate="2022-11-18T10:52:48.483" Title="Proof on Degenerate LP program" Tags="|linear-programming|primal-simplex|degeneracy|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9295" PostTypeId="1" CreationDate="2022-11-12T23:40:59.633" Score="2" ViewCount="166" Body="&lt;p&gt;I have recently tried to use the CPLEX solver to solve one of my Pyomo models. I first installed the community version that is available:&lt;a href=&quot;https://pypi.org/project/cplex/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pypi.org/project/cplex/&lt;/a&gt; using &lt;code&gt;pip&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, I am trying to switch to the academic license of the solver and I am facing several problems.&#xA;The main issue is that when I call &lt;code&gt;SolverFactory('cplex')&lt;/code&gt; I get the following error:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;pyomo.common.errors.ApplicationError: No executable found for solver 'cplex'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If I use &amp;quot;cplex_direct&amp;quot; the solver works as expected but the community edition is used instead. I also tried running the &lt;code&gt;setup.py&lt;/code&gt; script available at &lt;code&gt;/Applications/CPLEX_Studio221/cplex/python/3.9/x86-64_osx&lt;/code&gt; but I could not fix the problem. How do I resolve this?&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="491" LastEditDate="2022-11-13T03:18:00.627" LastActivityDate="2023-08-10T16:59:25.590" Title="Using CPLEX academic version with Pyomo on MacOS" Tags="|python|pyomo|cplex-python-api|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9297" PostTypeId="1" CreationDate="2022-11-13T02:09:05.950" Score="1" ViewCount="70" Body="&lt;p&gt;This is a peculiar question but I have two variables &lt;span class=&quot;math-container&quot;&gt;$s_{ik}$&lt;/span&gt; (integer) and &lt;span class=&quot;math-container&quot;&gt;$y_{it}$&lt;/span&gt; (binary). What I want is the following relationship: If &lt;span class=&quot;math-container&quot;&gt;$s_{ik} = 8$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$y_{i8} = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Basically, if &lt;span class=&quot;math-container&quot;&gt;$s_{ik}$&lt;/span&gt; takes a particular value then &lt;span class=&quot;math-container&quot;&gt;$y_{it}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$t = s_{ik}$&lt;/span&gt; should be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$y_{it}$&lt;/span&gt; should be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. Is this thing possible?&lt;/p&gt;&#xA;" OwnerUserId="10735" LastEditorUserId="123" LastEditDate="2022-11-13T08:30:01.107" LastActivityDate="2022-11-13T23:40:05.457" Title="Can I get value from a variable and use it on a specific index of a different variable?" Tags="|modeling|constraint|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9298" PostTypeId="1" AcceptedAnswerId="9299" CreationDate="2022-11-13T02:45:09.950" Score="0" ViewCount="85" Body="&lt;p&gt;I am not sure how to model this.&#xA;I have like this table&#xA;that has dates and orders&lt;/p&gt;&#xA;&lt;p&gt;``&lt;/p&gt;&#xA;&lt;p&gt;dates             order&lt;/p&gt;&#xA;&lt;p&gt;1/16/2021      12 units&lt;/p&gt;&#xA;&lt;p&gt;1/21/201       13 unit&lt;/p&gt;&#xA;&lt;p&gt;1/27/2021       21&lt;/p&gt;&#xA;&lt;p&gt;1/29/2021      14&lt;/p&gt;&#xA;&lt;p&gt;2/23/2021        15&lt;/p&gt;&#xA;&lt;p&gt;2/24/2022        27&lt;/p&gt;&#xA;&lt;p&gt;2/25/2022        39&lt;/p&gt;&#xA;&lt;p&gt;I am trying to create an optimization model.&#xA;Basically I have a FC which fulfill customer order.&#xA;We have orders listed in the above following dates&#xA;The orders are basically on the column orders.&#xA;We have a starting inventory of 50.&lt;/p&gt;&#xA;&lt;p&gt;Basically the FC orders from a DC with unlimited inventory to satisfy the order.&#xA;We have a lead time of 3 days between shipping the order and fulfilling it.&lt;/p&gt;&#xA;&lt;p&gt;We have the decision variable &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;,&lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;,...,&lt;span class=&quot;math-container&quot;&gt;$x_{365}$&lt;/span&gt; this is how much the FC orders from the distribution center.&#xA;Where 1=January 1 and 365=Dec 31 2021&#xA;Our time frame is 1 year.&lt;/p&gt;&#xA;&lt;p&gt;But I am not sure how to model this.&#xA;I know the time between ordering something and getting it to the FC is 3 days.&#xA;We have order cost of 50 dollar per unit.&#xA;We have holding cost of 5 dollar per unit&#xA;We have lost sales cost of 30 dollar per unit.&#xA;We have min order quantity of 25 and batch size of multiple of 5.&lt;/p&gt;&#xA;&lt;p&gt;We have our FC inventory depletes as we fulfill the orders.&#xA;We have the FC can hold at most 100 units.&#xA;The FC will run out of inventory at some time and have to order from the DC&lt;/p&gt;&#xA;&lt;p&gt;But I am not sure how to model this as linear optomization problem.&lt;/p&gt;&#xA;&lt;p&gt;I think I would have 365 decision variables.&lt;/p&gt;&#xA;&lt;p&gt;We want to minimize all the different cost and know on which days of the year to place orders.&lt;/p&gt;&#xA;" OwnerUserId="9483" LastEditorUserId="9483" LastEditDate="2022-11-13T02:56:13.703" LastActivityDate="2022-11-13T04:03:39.507" Title="How to build a deterministic optimization model for the following fc" Tags="|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9299" PostTypeId="2" ParentId="9298" CreationDate="2022-11-13T04:03:39.507" Score="2" Body="&lt;p&gt;For each day, you will want to have variables representing how many units you ship to customers, how many units of sales you lose, how much inventory you have at the end of the day, and how many five you batches you order from the DC. Most of those variables can be continuous (they will naturally take integer values), but the DC order size variables will need to be integers with domain 0, 5, 6, ... (so that you cannot order 1 to 4 five-unit batches in any day). The rest of the model should fall into place given those variables.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-13T04:03:39.507" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9300" PostTypeId="2" ParentId="9295" CreationDate="2022-11-13T20:33:06.803" Score="2" Body="&lt;p&gt;One of the following will probably solve the problem:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Add Cplex to the system Path in your laptop&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;add &lt;code&gt;executable=&lt;/code&gt; to the Solver factory:&lt;/p&gt;&#xA;&lt;p&gt;solver = SolverFactory(cplex, executable='C:/Program Files/...')&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="39" LastActivityDate="2022-11-13T20:33:06.803" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9301" PostTypeId="2" ParentId="9292" CreationDate="2022-11-13T20:40:40.057" Score="2" Body="&lt;p&gt;No. It depends on the data and how you quantify risk.&lt;/p&gt;&#xA;&lt;p&gt;Consider two products &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;B&lt;/code&gt; with costs:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;&lt;/th&gt;&#xA;&lt;th&gt;t=1&lt;/th&gt;&#xA;&lt;th&gt;t=2&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A&lt;/td&gt;&#xA;&lt;td&gt;&lt;code&gt;-1&lt;/code&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;code&gt;-0.95&lt;/code&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;B&lt;/td&gt;&#xA;&lt;td&gt;&lt;code&gt;-1&lt;/code&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;code&gt;{-1 w.p. 0.99, -0 w.p. 0.01}&lt;/code&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;A then B gives:&#xA;&lt;code&gt;{-2 w.p. 0.99, -1 w.p. 0.01}&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;B then A gives:&#xA;&lt;code&gt;{-1.95 w.p. 1.0} = -1.95&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;If we want to minimize costs, then in expectation, you'd pick A then B for a cost of -1.99.&lt;/p&gt;&#xA;&lt;p&gt;To maximize the worst-case cost, you'd pick B then A for a cost of -1.95.&lt;/p&gt;&#xA;&lt;p&gt;If you use a risk measure like CVaR:&#xA;&lt;code&gt;CVaRₐ(x) = min_z { z + 1 / (1 - α) * E[(xᵢ - z)₊] }&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;then if α is 0 the optimal choice is A then B and lim α -&amp;gt; 1 is B then A.&#xA;There's a cross over point at α = 0.2 where things are equal.&lt;/p&gt;&#xA;" OwnerUserId="804" LastEditorUserId="804" LastEditDate="2022-11-15T22:08:52.447" LastActivityDate="2022-11-15T22:08:52.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9302" PostTypeId="2" ParentId="9297" CreationDate="2022-11-13T23:40:05.457" Score="5" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_t y_{it} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$}\\&#xA;\sum_t t y_{it} &amp;amp;= s_{ik} &amp;amp;&amp;amp;\text{for all $i$ and $k$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-11-13T23:40:05.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9304" PostTypeId="1" AcceptedAnswerId="9309" CreationDate="2022-11-14T13:44:54.590" Score="3" ViewCount="609" Body="&lt;p&gt;I'm new to Gurobi in Python and I am wondering if there is way to express/code &amp;quot;or&amp;quot; in the following constraint, where &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;  are binary variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i-x_i*x_{i-1} =0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;OR&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i*x_{i+1} =1.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to express &amp;quot;Or&amp;quot; between the above two constraints?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Approch:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I tried the following&#xA;model.addConstr((x[i]-x[i]*x[i-1]) * (x[i]*x[i+1] -1 )==0)&#xA;however this leads to an error:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;gurobipy.GurobiError: Invalid argument to QuadExpr multiplication&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I think that &lt;code&gt;addConstr&lt;/code&gt; can take at max three multiplications.&lt;/p&gt;&#xA;" OwnerUserId="10520" LastEditorUserId="491" LastEditDate="2022-11-14T19:16:31.233" LastActivityDate="2022-11-16T14:11:45.800" Title="Gurobi - Python: is there a way to express &quot;OR&quot; in a constraint?" Tags="|linear-programming|modeling|python|constraint|gurobi|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9305" PostTypeId="1" CreationDate="2022-11-14T17:20:50.077" Score="1" ViewCount="46" Body="&lt;p&gt;I'm attempting to write a blending/production planning type linear program but am struggling due to the complexity of the manufacturing process.&lt;/p&gt;&#xA;&lt;p&gt;I am formulating the problem as such:&lt;/p&gt;&#xA;&lt;p&gt;Objective: Maximize Profit = z = (Sum of component qty in each product) * Profit/Unit of product&lt;/p&gt;&#xA;&lt;p&gt;D.V.'s:&#xA;Xij = units of components (ingredients) i in product j&lt;/p&gt;&#xA;&lt;p&gt;i = set of components (i = 1,2,...n)&#xA;j = set of products (j = 1,2,...n)&lt;/p&gt;&#xA;&lt;p&gt;Constraints:&lt;/p&gt;&#xA;&lt;p&gt;Recipe Constraint: Component Requirement &amp;lt;= (Qty of Component in Product j) / (Total Qty of Product j)&lt;/p&gt;&#xA;&lt;p&gt;Inventory Constraint: Sum of component qty used in each product &amp;lt;= total inventory for each component&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The issue I'm having is with the units of measure in the recipes of each product. Unlike a classic blending problem, the units of measure vary and I do not have conversion factors to align them all to the same unit as the finished product.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n2LgR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n2LgR.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you can see in the picture above, I have unit factor requirements, so 0.0116 pounds of C1 yields 1 Square Yard of finished good and so on. Unfortunately, the component quantities xij would not be additive because the units differ in the objective function and I would have a similar issue in the recipe constraint.&lt;/p&gt;&#xA;&lt;p&gt;Has anyone found a workaround for an issue like this?&lt;/p&gt;&#xA;" OwnerUserId="10747" LastEditorUserId="491" LastEditDate="2022-11-14T19:15:40.860" LastActivityDate="2022-11-14T19:15:40.860" Title="Blending Problem Without Percents and Varying Units of Measure" Tags="|optimization|linear-programming|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9306" PostTypeId="2" ParentId="9139" CreationDate="2022-11-14T17:25:34.590" Score="2" Body="&lt;p&gt;You could start with OPL:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int n=10;&#xA;range N=1..n;&#xA;&#xA;&#xA;{int} A={1,3,5};&#xA;&#xA;int v[A]=[0,1,2];&#xA;&#xA;range M=1..4;&#xA;&#xA;int b[N][M]=[[1,1]];&#xA;int d[A][N]=[[1,2]];&#xA;&#xA;dvar boolean x[A][N][M][N];&#xA;&#xA;subject to&#xA;{&#xA;  forall(i in N,a in A) sum(j in M,k in N:k &amp;lt;=minl(n,i+v[a])) x[a,i,j,k]*b[k,j]==d[a,i];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-11-14T17:25:34.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9307" PostTypeId="1" AcceptedAnswerId="9308" CreationDate="2022-11-15T06:35:16.563" Score="3" ViewCount="191" Body="&lt;p&gt;I am working on DoCplex to run a large model with several variables and constraints. I used the following link from &lt;a href=&quot;https://or.stackexchange.com/questions/7546/sensitivity-analysis-in-python-docplex&quot;&gt;sensitivity analysis in python + Docplex&lt;/a&gt; to run the sensitivity analysis. In that example, there was a limited number of constraints and variables, which made it easy to interpret, but with a very large instance, the task becomes more tedious.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, I have a question if I name the set of constraints as &lt;code&gt;mdl.add_constraint(nbbus40==nbbus30, 'samenumberofbuses')&lt;/code&gt;, will it be possible to run sensitivity analysis on the values on the right-hand side of a specific set of constraints? Instead of having the values for &lt;code&gt;print(cpx.solution.sensitivity.rhs())&lt;/code&gt; which will give me the values on all constraints, I would only have it for what I am focusing on.&lt;/p&gt;&#xA;" OwnerUserId="4491" LastActivityDate="2022-11-15T07:52:31.207" Title="Sensitivity analysis for specific sets of constraints on DoCplex" Tags="|optimization|python|docplex|cplex-python-api|sensitivity-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9308" PostTypeId="2" ParentId="9307" CreationDate="2022-11-15T07:52:31.207" Score="4" Body="&lt;p&gt;You can filter the results you get from sensitivity.rhs :&lt;/p&gt;&#xA;&lt;p&gt;See small example out of the &lt;a href=&quot;https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;zoo example&lt;/a&gt; again:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;from docplex.mp.relax_linear import LinearRelaxer&#xA;&#xA;mdl = Model(name='buses')  &#xA;nbbus40 = mdl.integer_var(name='nbBus40')  &#xA;nbbus30 = mdl.integer_var(name='nbBus30')  &#xA;ctKids=mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;ctKids2=mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 290, 'kids2') &#xA;mdl.minimize(nbbus40*500 + nbbus30*400)   &#xA;mdl.solve() &#xA;&#xA;lp = LinearRelaxer.make_relaxed_model(mdl)&#xA;m2 = lp.solve()&#xA;&#xA;cpx = lp.get_engine().get_cplex()&#xA;&#xA;&#xA;&#xA;print(cpx.solution.sensitivity.rhs())&#xA;&#xA;rhs=cpx.solution.sensitivity.rhs()&#xA;&#xA;names = cpx.linear_constraints.get_names()&#xA;print(names)&#xA;&#xA;#Now we want the result only for constraint &amp;quot;kids&amp;quot;&#xA;&#xA;indexConstraint=names.index(&amp;quot;kids&amp;quot;)&#xA;&#xA;print(&amp;quot;right info for the constraint &amp;quot;,rhs[indexConstraint])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[(290.0, 1e+20), (-1e+20, 300.0)]&#xA;['kids', 'kids2']&#xA;right info for the constraint  (290.0, 1e+20)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-11-15T07:52:31.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9309" PostTypeId="2" ParentId="9304" CreationDate="2022-11-15T10:16:18.460" Score="7" Body="&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;'s are binary:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;&amp;amp;(x_i(1 - x_{i-1}) = 0) \vee (x_ix_{i+1}=1)\\&#xA;\Leftrightarrow&amp;amp;(\neg x_i \vee x_{i-1})\vee(x_i \wedge x_{i+1})\\&#xA;\Leftrightarrow&amp;amp;\neg x_i \vee x_{i-1}\vee(x_i \wedge x_{i+1})\\&#xA;\Leftrightarrow&amp;amp;(\neg x_i \vee x_{i-1}\vee x_i) \wedge (\neg x_i \vee x_{i-1}\vee x_{i+1})\\&#xA;\Leftrightarrow&amp;amp; 1 \wedge (\neg x_i \vee x_{i-1} \vee x_{i+1})\\&#xA;\Leftrightarrow&amp;amp; \neg x_i \vee x_{i-1} \vee x_{i+1}\\&#xA;\Leftrightarrow&amp;amp; (1-x_i) + x_{i-1} + x_{i+1} \geq 1\\&#xA;\Leftrightarrow&amp;amp; x_{i-1} - x_i + x_{i+1} \geq 0&#xA;\end{align*}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2022-11-15T10:16:18.460" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9310" PostTypeId="2" ParentId="9304" CreationDate="2022-11-15T11:36:23.687" Score="4" Body="&lt;p&gt;Edit: This is actually the &amp;quot;English&amp;quot; version of @xd y's accepted answer.&lt;/p&gt;&#xA;&lt;p&gt;In your specific case I think adding just &lt;span class=&quot;math-container&quot;&gt;$x_{i+1} \ge x_i-x_{i-1}$&lt;/span&gt; works. Let's enumerate&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_i = 0$&lt;/span&gt; then your OR constraint is satisfied since LHS will be 0 for both constraints. Other variables are free.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{i+1} = 1$&lt;/span&gt; then the second constraint is satisfied. &lt;span class=&quot;math-container&quot;&gt;$x_{i-1}$&lt;/span&gt; is free.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{i+1} = 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_{i-1}$&lt;/span&gt; should be 1.&lt;/p&gt;&#xA;&lt;p&gt;So if you add &lt;span class=&quot;math-container&quot;&gt;$x_{i+1} \ge x_i-x_{i-1}$&lt;/span&gt;, you ensure that if &lt;span class=&quot;math-container&quot;&gt;$x_{i} = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{i-1} = 0$&lt;/span&gt; you will get &lt;span class=&quot;math-container&quot;&gt;$x_{i+1} = 1$&lt;/span&gt;. Otherwise, &lt;span class=&quot;math-container&quot;&gt;$x_{i+1}$&lt;/span&gt; is free.&lt;/p&gt;&#xA;" OwnerUserId="4496" LastEditorUserId="4496" LastEditDate="2022-11-15T14:26:29.397" LastActivityDate="2022-11-15T14:26:29.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9312" PostTypeId="2" ParentId="9304" CreationDate="2022-11-15T22:38:51.623" Score="1" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i*(1-x_{i-1} = 0\ or \ x_i*x_{i+1}=1$&lt;/span&gt; implies&lt;br /&gt;&#xA;Cons(1): &lt;span class=&quot;math-container&quot;&gt;$x_i*(1-x_{i-1}) &amp;gt;=0$&lt;/span&gt;;&lt;br /&gt;&#xA;Cons(2): &lt;span class=&quot;math-container&quot;&gt;$x_i*x_{i+1} &amp;lt;=1$&lt;/span&gt;;&lt;br /&gt;&#xA;Cons(3): &lt;span class=&quot;math-container&quot;&gt;$x_i*(1-x_{i-1} + x_{i+1}) =1$&lt;/span&gt;&lt;br /&gt;&#xA;So if you are looking for 0 or 1 for cons(1) &amp;amp; cons(2) &amp;amp; not either way then constraints are:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{i+1} &amp;gt;= x_{i-1}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-11-16T14:11:45.800" LastActivityDate="2022-11-16T14:11:45.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9313" PostTypeId="1" AcceptedAnswerId="9314" CreationDate="2022-11-15T23:42:24.657" Score="3" ViewCount="293" Body="&lt;p&gt;I have an objective function that I want to linearize but want to confirm that I'm doing it correctly. There are some constraints that are linear in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; but they're unimportant for the problem. The objective is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x}p^Tx-\rho\|Ax\|_q$$&lt;/span&gt;&#xA;Subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A\in \mathbf{R}^{nxn}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$p\in \mathbf{R}^n$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x\in\{0,1\}^n$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\rho\in\mathbf{R}^+$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm investigating the cases where &lt;span class=&quot;math-container&quot;&gt;$q=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q=\infty$&lt;/span&gt;. This is what I've simplified &lt;span class=&quot;math-container&quot;&gt;$q=1$&lt;/span&gt; to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x, z}p^Tx-\rho \sum_{i=1}^{n} z_i$$&lt;/span&gt;&#xA;Subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A\in \mathbf{R}^{nxn}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-z\leq Ax \leq z $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z\in \mathbf{R}^n$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x\in\{0,1\}^n$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\rho\in\mathbf{R}^+$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This feels straight forward from standard LP but just want to confirm this would hold for MILP as well. I may be missing something where this doesn't extend to MILP.&lt;/p&gt;&#xA;&lt;p&gt;For the &lt;span class=&quot;math-container&quot;&gt;$q=\infty$&lt;/span&gt; case, the objective is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max_{}\{p^Tx-\rho*\max_{}\{|Ax|\}\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I've simplified this to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x, z}p^Tx-\rho z$$&lt;/span&gt;&#xA;Subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z\geq (Ax)_i \hspace{0.5cm} \forall i \; in \;1 \;to \;n$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z\geq -(Ax)_i \hspace{0.5cm} \forall i \; in \;1 \;to \;n$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A\in \mathbf{R}^{nxn}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z\in \mathbf{R}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x\in\{0,1\}^n$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\rho\in\mathbf{R}^+$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm not sure I can transform the inner maximization like that. I know this works for &lt;span class=&quot;math-container&quot;&gt;$\min\{\max\{Ax\}\}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\max\{\min\{Ax\}\}$&lt;/span&gt; but does this follow for &lt;span class=&quot;math-container&quot;&gt;$\max\{-\max\{Ax\}\}$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10751" LastActivityDate="2022-11-15T23:58:40.810" Title="Linearize objective function in MILP" Tags="|mixed-integer-programming|linear-programming|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9314" PostTypeId="2" ParentId="9313" CreationDate="2022-11-15T23:58:40.810" Score="4" Body="&lt;p&gt;Both linearizations are correct.  Here's a derivation for &lt;span class=&quot;math-container&quot;&gt;$\max\{-\max\{\}\}$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_x\left\{-\max_i f_i(x)\right\}&#xA;&amp;amp;= \max_x\left\{\min_i \{-f_i(x)\}\right\} \\&#xA;&amp;amp;= \max_x\left\{y: y \le -f_i(x) \text{ for all $i$}\right\} \\&#xA;&amp;amp;= \max_x\left\{y: -y \ge f_i(x) \text{ for all $i$}\right\} \\&#xA;&amp;amp;= \max_x\left\{-z: z \ge f_i(x) \text{ for all $i$}\right\} &amp;amp;&amp;amp;\text{[take $z=-y$]}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-11-15T23:58:40.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9316" PostTypeId="1" CreationDate="2022-11-16T08:23:41.010" Score="2" ViewCount="63" Body="&lt;p&gt;I have a number of variables each assigned an integer value. I need to split these variables in three groups with a predefined number of variables going into each group while optimizing towards predefined sums of the values in each group. Each group sum should be as close as possible to the predefined value, but can be above or below. All variables should be used and each variable can only be used once.&lt;/p&gt;&#xA;&lt;p&gt;For example, I might have 10 variables...&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Variable&lt;/th&gt;&#xA;&lt;th&gt;Value&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A1&lt;/td&gt;&#xA;&lt;td&gt;98&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A2&lt;/td&gt;&#xA;&lt;td&gt;20&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A3&lt;/td&gt;&#xA;&lt;td&gt;30&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A4&lt;/td&gt;&#xA;&lt;td&gt;50&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A5&lt;/td&gt;&#xA;&lt;td&gt;18&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A6&lt;/td&gt;&#xA;&lt;td&gt;34&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A7&lt;/td&gt;&#xA;&lt;td&gt;43&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A8&lt;/td&gt;&#xA;&lt;td&gt;21&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A9&lt;/td&gt;&#xA;&lt;td&gt;32&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A10&lt;/td&gt;&#xA;&lt;td&gt;54&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;...and the goal could be to create three groups:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Group&lt;/th&gt;&#xA;&lt;th&gt;#Variables&lt;/th&gt;&#xA;&lt;th&gt;Sum optimized towards&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;X&lt;/td&gt;&#xA;&lt;td&gt;6&lt;/td&gt;&#xA;&lt;td&gt;200&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Y&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;100&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Z&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;100&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;So group X should hold 6 variables and their sums should be as close as possible to 200 - but I need to optimize for each of the groups simultanously.&lt;/p&gt;&#xA;&lt;p&gt;I've tried to set up &lt;code&gt;PuLP&lt;/code&gt; to perform this task. I seem to have found a solution for creating a single group, but I cannot figure out how to split the variables into groups and optimize the assignments based on the sums for each group. Is there a way to do this?&lt;/p&gt;&#xA;&lt;p&gt;Below is my code for producing the first group with the presented variables.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import LpMaximize, LpMinimize, LpProblem, lpSum, LpVariable, PULP_CBC_CMD, value, LpStatus&#xA;&#xA;keys = [&amp;quot;A1&amp;quot;, &amp;quot;A2&amp;quot;, &amp;quot;A3&amp;quot;, &amp;quot;A4&amp;quot;, &amp;quot;A5&amp;quot;, &amp;quot;A6&amp;quot;, &amp;quot;A7&amp;quot;, &amp;quot;A8&amp;quot;, &amp;quot;A9&amp;quot;, &amp;quot;A10&amp;quot;]&#xA;data = [98,20,30,50,20,34,43,21,32,54]&#xA;&#xA;problem_name = 'repex'&#xA;&#xA;prob = LpProblem(problem_name, LpMaximize)&#xA;&#xA;optiSum = 200 # Optimize towards this sum&#xA;variableCount = 6 # Number of variables that should be in the group&#xA;&#xA;# Create decision variables&#xA;decision_variables = []&#xA;for i,n in enumerate(data):&#xA;    variable = i&#xA;    variable = LpVariable(str(variable), lowBound = 0, upBound = 1, cat= 'Binary')&#xA;    decision_variables.append(variable)&#xA;&#xA;&#xA;# Add constraints&#xA;sumConstraint = &amp;quot;&amp;quot; # Constraint on sum of data elements&#xA;for i, n in enumerate(decision_variables):&#xA;    formula = data[i]*n&#xA;    sumConstraint += formula&#xA;&#xA;countConstraint = &amp;quot;&amp;quot; # Constrain on number of elements used&#xA;for i, n in enumerate(decision_variables):&#xA;        formula = n&#xA;        countConstraint += formula&#xA;&#xA;prob += (sumConstraint &amp;lt;= optiSum)&#xA;prob += (countConstraint == variableCount)&#xA;prob += sumConstraint&#xA;&#xA;# Solve&#xA;optimization_result = prob.solve(PULP_CBC_CMD(msg=0))&#xA;prob.writeLP(problem_name + &amp;quot;.lp&amp;quot; )&#xA;print(&amp;quot;Status:&amp;quot;, LpStatus[prob.status])&#xA;print(&amp;quot;Optimal Solution to the problem: &amp;quot;, value(prob.objective))&#xA;print (&amp;quot;Individual decision_variables: &amp;quot;)&#xA;for v in prob.variables():&#xA;    print(v.name, &amp;quot;=&amp;quot;, v.varValue)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Which produces the following output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Status: Optimal&#xA;Optimal Solution to the problem:  200.0&#xA;Individual decision_variables:&#xA;0 = 0.0&#xA;1 = 1.0&#xA;2 = 0.0&#xA;3 = 1.0&#xA;4 = 0.0&#xA;5 = 1.0&#xA;6 = 1.0&#xA;7 = 1.0&#xA;8 = 1.0&#xA;9 = 0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10757" LastActivityDate="2022-11-16T23:25:02.307" Title="Split variables into groups, each constrained to hold a specific number of variables, while optimizing group sums towards specific values" Tags="|optimization|python|pulp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9317" PostTypeId="2" ParentId="9293" CreationDate="2022-11-16T09:46:00.480" Score="4" Body="&lt;p&gt;This is a really interesting question that I don't think is completely understood yet.&lt;/p&gt;&#xA;&lt;p&gt;One research paper you may want to look into is &lt;a href=&quot;http://arxiv.org/abs/2203.02795&quot; rel=&quot;nofollow noreferrer&quot;&gt;Im, Jiyoung, and Henry Wolkowicz. “Strict Feasibility and Degeneracy in Linear Programming,” 2022, 1–20&lt;/a&gt; who make the following definition:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;For a general polyhedron &lt;span class=&quot;math-container&quot;&gt;$P \subseteq \mathbb{R}^n$&lt;/span&gt;, a point &lt;span class=&quot;math-container&quot;&gt;$p \in P$&lt;/span&gt; is called a basic solution if there are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; linearly independent active constraints at &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;. In addition, if there are more than &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; active constraints at the point &lt;span class=&quot;math-container&quot;&gt;$p \subseteq P$&lt;/span&gt;, then the point &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is called degenerate.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;Note: With respect to the primal problem, &lt;span class=&quot;math-container&quot;&gt;$Ax=b \in \mathbb{R}^m, x \in \mathbb{R}_+^n$&lt;/span&gt;, we have &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; active constraints from the equality system (by feasibility), &lt;span class=&quot;math-container&quot;&gt;$n-m$&lt;/span&gt; active constraints from bounds of &lt;span class=&quot;math-container&quot;&gt;$x_\mathcal{N}$&lt;/span&gt; (in basic solutions), and degeneracy holds if any bounds of &lt;span class=&quot;math-container&quot;&gt;$x_\mathcal{B}$&lt;/span&gt; are active.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;The authors then go on to show that the absence of strict feasibility implies that all basic solutions are degenerate, and point to facial reduction as a method to obtain strict feasibility via a series of reformulations which ultimately reduce the degree of degeneracy.&lt;/p&gt;&#xA;&lt;p&gt;Note, however, that the above method is not capable of removing all types of degeneracy and to further your understanding it may be beneficial to look at the classic assignment problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{lll}&#xA;\textrm{minimize}   &amp;amp; \sum_{i=1}^T \sum_{j=1}^T c_{ij} x_{ij} \\&#xA;\textrm{subject to} &amp;amp; \sum_{i=1}^T x_{ij} = 1,&amp;amp;\text{for all $j=1,\ldots,T$},\\&#xA; &amp;amp; \sum_{j=1}^T x_{ij} = 1, &amp;amp;\text{for all $i=1,\ldots,T$},\\&#xA;&amp;amp; 0 \leq x_{ij} \leq 1, &amp;amp;\text{for all $i=1,\ldots,T$, $j=1,\ldots,T$}.&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This formulation is totally unimodular causing all basic solutions to be integer feasible, &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \in \{0,1\}$&lt;/span&gt;, with exactly &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; variables equal to 1. Since &lt;span class=&quot;math-container&quot;&gt;$x_\mathcal{B} \in \mathbb{R}^{2T}$&lt;/span&gt;, this means that all basic solutions are degenerate. Trying to reformulate it you find that one constraint is redundant and can be thrown away (tonnes of degeneracy remains however). Furthermore, facial reduction is not applicable because strict feasibility is satisfied (just let &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 1/T$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,T$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j=1,\ldots,T$&lt;/span&gt; to see this).&lt;/p&gt;&#xA;&lt;p&gt;It is not at all obvious if there exists a formulation of the assignment problem that is nondegenerate, and it should serve well to test any ideas that comes up. What you can always do, however, at least in theory, is to randomly perturb all bounds by the tiniest amounts to obtain a nondegenerate problem whose optimal basis is also an optimal basis in the unperturbed problem with probability 1. This is one of the main motivations for using perturbation strategies in simplex implementations. I hope this answers your question.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2022-11-16T12:16:19.580" LastActivityDate="2022-11-16T12:16:19.580" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9318" PostTypeId="1" CreationDate="2022-11-16T10:58:25.553" Score="3" ViewCount="87" Body="&lt;p&gt;I am looking for some guidance on how to better state my problem formally and practically (e.g., relevant Python libraries).&lt;/p&gt;&#xA;&lt;p&gt;Let's assume I have a set of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; unique products to buy. I have &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; days in total to buy them, and I can only buy a fraction &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; of these products per day. The price of the product may vary with each day. My main constraint is that I can only buy each product once. An optional constraint is that I cannot buy a product above a price &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt;. The objective is to buy as much of these unique products as possible (ideally &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;) by minimizing the total cost of the operation.&lt;/p&gt;&#xA;&lt;p&gt;Here is some very simple sample data, assuming I can only buy two products a day, looking to minimize the total cost at buying all 4 products over those 3 days.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Product   Cost, D1   Cost, D2   Cost, D3&#xA;  A          05         19         12   &#xA;  B          54         24         32&#xA;  C          89         04         56 &#xA;  D          31         78         21&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where should I start looking?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;First edit&lt;/strong&gt;: I am working on the mathematical formulation, and I also have been reading on similar problems. It does look similar to an assignment problem, with the difference that the amount of jobs (here, the different days/costs) and workers (products) is not symmetrical. Is this an apt observation? Would duplicating the jobs, &lt;a href=&quot;https://stackoverflow.com/a/45807471&quot;&gt;as suggested here&lt;/a&gt;, be a possible solution?&lt;/p&gt;&#xA;" OwnerUserId="10758" LastEditorUserId="10758" LastEditDate="2022-11-16T21:33:38.800" LastActivityDate="2022-11-16T21:33:38.800" Title="Minimize total cost to buy unique products over timespan" Tags="|modeling|python|integer-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9319" PostTypeId="2" ParentId="9316" CreationDate="2022-11-16T16:38:33.350" Score="1" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$N_g$&lt;/span&gt; be the number of variables you need to assign to group &lt;span class=&quot;math-container&quot;&gt;$g,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$V_g$&lt;/span&gt; the target sum for group &lt;span class=&quot;math-container&quot;&gt;$g,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_v$&lt;/span&gt; the value assigned to variable &lt;span class=&quot;math-container&quot;&gt;$v.$&lt;/span&gt; I'm going to assume you measure &amp;quot;closeness&amp;quot; via absolute values (&lt;span class=&quot;math-container&quot;&gt;$L_1$&lt;/span&gt; norm).&lt;/p&gt;&#xA;&lt;p&gt;We will use binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{v,g}$&lt;/span&gt; to indicate whether variable &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is assigned to group &lt;span class=&quot;math-container&quot;&gt;$g,$&lt;/span&gt; continuous variables &lt;span class=&quot;math-container&quot;&gt;$s_g$&lt;/span&gt; to capture the sum of the values assigned to each group &lt;span class=&quot;math-container&quot;&gt;$g,$&lt;/span&gt; and nonnegative variables &lt;span class=&quot;math-container&quot;&gt;$d_g=\vert s_g-V_g\vert$&lt;/span&gt; to capture the absolute deviations from group targets. The objective is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_g d_g,$&lt;/span&gt; the total absolute error in group sums. The constraints are as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{g}x_{v,g} =1\quad \forall v$$&lt;/span&gt;(assign each variable to exactly one group),&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{v}x_{v,g} =N_{g}\quad \forall g$$&lt;/span&gt;(assign the desired number of variables to each group),&#xA;&lt;span class=&quot;math-container&quot;&gt;$$s_{g} =\sum_{v}a_{v}x_{v,g} \quad \forall g$$&lt;/span&gt;(defining the sum &lt;span class=&quot;math-container&quot;&gt;$s_g$&lt;/span&gt; of each group), and finally&#xA;&lt;span class=&quot;math-container&quot;&gt;$$d_{g} \ge s_{g}-V_{g}\quad \forall g$$&lt;/span&gt;and&lt;span class=&quot;math-container&quot;&gt;$$d_{g} \ge V_{g}-s_{g}\quad \forall g$$&lt;/span&gt;(forcing &lt;span class=&quot;math-container&quot;&gt;$d_g$&lt;/span&gt; to be the absolute difference &lt;span class=&quot;math-container&quot;&gt;$\vert s_g-V_g\vert$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-11-16T23:25:02.307" LastActivityDate="2022-11-16T23:25:02.307" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9320" PostTypeId="2" ParentId="9293" CreationDate="2022-11-16T17:21:01.657" Score="4" Body="&lt;p&gt;First comment: LPs are not degenerate; corner points of their feasible regions (equivalently, basic feasible solutions) can be degenerate. As stated in Henrik's answer, degeneracy occurs when more than &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; of the defining hyperplanes (including those corresponding to bounds on the variables) are binding at a corner, where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the number of variables. Here &lt;span class=&quot;math-container&quot;&gt;$n=7$&lt;/span&gt; and at &lt;span class=&quot;math-container&quot;&gt;$x=(1,1,1,0,0,0,0)$&lt;/span&gt; we have 8 binding hyperplanes (four from the equation constraints, four from the nonnegativity of variables &lt;span class=&quot;math-container&quot;&gt;$x_4,\dots,x_7.$&lt;/span&gt; Note that I'm assuming that all seven variables are required to be nonnegative, even though it is not stated in the problem.&lt;/p&gt;&#xA;&lt;p&gt;Suppose we use the four equations to solve for four variables in terms of the other three, as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_1 = 1 - x_5 - x_6$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_2 = 1 - x_4 - x_6$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_3 = 1 - x_4 - x_5 - x_6$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_4 = 1 - x_3 - x_6 = x_4 + x_5.$$&lt;/span&gt;&#xA;Using that, we can express the feasible region in terms of &lt;span class=&quot;math-container&quot;&gt;$x_5,\dots,x_7$&lt;/span&gt;, with the nonnegativity of &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_4$&lt;/span&gt; translating into the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_5 + x_6 \le 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x_4 + x_6 \le 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_4 + x_5 + x_6\le 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_4 + x_5 \ge 0.$$&lt;/span&gt;&#xA;At &lt;span class=&quot;math-container&quot;&gt;$(x_4,x_5,x_6) = (0,0,0)$&lt;/span&gt; we have three nonnegative constraints plus the fourth inequality binding, so the corner is degenerate. Note, though, that the fourth inequality is redundant (implied by nonnegativity of &lt;span class=&quot;math-container&quot;&gt;$x_4$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_5$&lt;/span&gt;), so we can drop it and get an equivalent problem (same feasible region) where the corner is no longer degenerate.&lt;/p&gt;&#xA;&lt;p&gt;So there is an equivalent formulation where the corner is nondegenerate, but it is not obvious from the original formulation. In particular, just dropping any one of the four equation constraints or any one of the nonnegativity requirements in the original model changes the feasible region.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-16T17:21:01.657" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9321" PostTypeId="1" AcceptedAnswerId="9901" CreationDate="2022-11-16T21:10:09.340" Score="7" ViewCount="170" Body="&lt;p&gt;I'm using the &lt;a href=&quot;https://www.scipopt.org/doc/html/BINPACKING_BRANCHING.php&quot; rel=&quot;noreferrer&quot;&gt;Ryan-Foster branching&lt;/a&gt; in my Branch and Price algorithm for a pickup and delivery problem, but I'm having trouble keeping track of all the pairs as I go down the search tree.&lt;/p&gt;&#xA;&lt;p&gt;Let's say that at a given point, I create a new node with the rule that elements 1 and 2 should be chosen together. Further down, in the same branch, a new node is created with the rule that 1 and 3 should not be chosen together. Given this new rule, it's clear that elements 2 and 3 should not be chosen together as well, and I could add this new rule to my set. I believe that whenever a new rule is generated I could create a graph G with the elements as nodes and the rules as weighted edges: w(a,b) = 1 if a and b should be together, and -1 if they can't be together. Some traversal in G would allow the generation of new rules or even the detection of a infeasibility. The image below translates my example in G with the dotted edge being the possible new generated edge.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/q0gA4.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/q0gA4.png&quot; alt=&quot;Given edges (1,2) and (1,3). The edge (2,3) could be generated with w(2,3) = -1&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;My question is: Is there a known algorithm that does this kind of generation of new edges mentioned above?&lt;/p&gt;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&lt;p&gt;I've implemented the following search, that seems to be working with all my instances. If there's a known algorithm I would love to know if it's better than this or if I'm doing something wrong here:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// M is the adjacency matrix for the graph above. s is the &#xA;// initial node (it can be any of the elements of the new rule)&#xA;void expand_conflicts(vector&amp;lt;vector&amp;lt;short&amp;gt;&amp;gt;&amp;amp; M, short s){&#xA;    using namespace std;&#xA;    const short n = M.size();&#xA;    queue&amp;lt;short&amp;gt; Q;&#xA;    vector&amp;lt;bool&amp;gt; visited(n, false);&#xA;    Q.push(s);&#xA;    while(!Q.empty()){&#xA;        short u = Q.front(); Q.pop();&#xA;        visited[u] = true;&#xA;        queue&amp;lt;short&amp;gt; Q_u;&#xA;        for(short v = 0; v &amp;lt; n; ++v){&#xA;            if(u != v &amp;amp;&amp;amp; M[u][v] != 0){&#xA;                Q_u.push(v);&#xA;            }&#xA;        }&#xA;        while(!Q_u.empty()){&#xA;            short v = Q_u.front(); Q_u.pop();&#xA;            short c_uv = M[u][v];&#xA;            for(short w = 0; w &amp;lt; n; ++w){&#xA;                auto c_vw = M[v][w];&#xA;                if(v != w &amp;amp;&amp;amp; M[u][w] == 0 &amp;amp;&amp;amp;&#xA;                    ((c_uv == -1 &amp;amp;&amp;amp; c_vw == 1) ||&#xA;                    (c_uv == 1 &amp;amp;&amp;amp; c_vw == -1))){&#xA;                    M[u][w] = M[w][u] = -1;&#xA;                    Q_u.push(w);&#xA;                }else if(v != w &amp;amp;&amp;amp; c_uv == 1 &amp;amp;&amp;amp; c_vw == 1 &amp;amp;&amp;amp;&#xA;                    M[u][w] == 0){&#xA;                    M[u][w] = M[w][u] = 1;&#xA;                    Q_u.push(w);&#xA;                }&#xA;            }&#xA;            if(!visited[v]){&#xA;                Q.push(v);&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6073" LastEditorUserId="6073" LastEditDate="2022-11-17T12:53:41.307" LastActivityDate="2023-02-08T15:48:43.103" Title="Name of graph algorithm arising while using the Ryan Foster Branching" Tags="|graphs|branch-and-bound|c++|branch-and-price|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9322" PostTypeId="2" ParentId="8950" CreationDate="2022-11-17T00:06:14.500" Score="1" Body="&lt;p&gt;As I understand suppose &lt;span class=&quot;math-container&quot;&gt;$z= 6x+2y-1$&lt;/span&gt; then max of z would be at&#xA;&lt;span class=&quot;math-container&quot;&gt;$x,y=(6,0)$&lt;/span&gt; for x bounded by &lt;span class=&quot;math-container&quot;&gt;$[0,6]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y=[0,3]$&lt;/span&gt;. Imagine z is the negative sloping line or contour in x-y plane.&#xA;Slope of contour z is -3. What's the minimum amt by which coeff of y to be increased to make value of &lt;span class=&quot;math-container&quot;&gt;$y&amp;gt;0$&lt;/span&gt; and increase max value of z? In other words how much slope needs to be reduced to make y a basic variable.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-11-17T12:06:57.083" LastActivityDate="2022-11-17T12:06:57.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9323" PostTypeId="1" AcceptedAnswerId="9324" CreationDate="2022-11-17T00:11:55.730" Score="2" ViewCount="289" Body="&lt;p&gt;Writing some GAMS code, getting some syntax errors:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eBHqe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eBHqe.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Anyone recognize the problem?&lt;/p&gt;&#xA;" OwnerUserId="10630" LastActivityDate="2022-11-17T00:31:06.417" Title="gams syntax issue - &quot;set identifier or quoted element expected&quot;" Tags="|cplex|gams|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9324" PostTypeId="2" ParentId="9323" CreationDate="2022-11-17T00:31:06.417" Score="3" Body="&lt;p&gt;On line 134, I suspect you meant X(J) instead of X(Y) and XX(J) instead of XX(Y).  Also, it looks you have an inconsistency with months as strings JAN, ..., DEC versus integers &lt;span class=&quot;math-container&quot;&gt;$1, \dots, 12$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-11-17T00:31:06.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9325" PostTypeId="1" CreationDate="2022-11-17T17:11:48.827" Score="4" ViewCount="372" Body="&lt;p&gt;I'm sure this is a straightforward question, but since I started learning integer programming recently this isn't clear to me.&lt;/p&gt;&#xA;&lt;p&gt;Consider solving a 1 dimensional cutting stock problem using delayed column generation / branch and price. You start by considering possible combinations of trivial patterns and through checking reduced costs and REPLACING columns, you eventually deduce an optimal solution for the LP relaxation with fractional numbers of rolls.&lt;/p&gt;&#xA;&lt;p&gt;I have seen 3 resources online, all of which say something to the effect of:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The correct thing to do would be to apply Branch and Bound to the LP-optimal solution, but ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;and then proceed to use a rounding / observation argument.&lt;/p&gt;&#xA;&lt;p&gt;My question is, how do we apply branch and bound?&lt;/p&gt;&#xA;&lt;p&gt;Say we are in a 'nice' situation where we have found the LP-optimal solution with a square matrix and column vector where the column vector is positive and fractional. Do we simply choose a fractional entry of the vector and split into the two natural cases?&lt;/p&gt;&#xA;&lt;p&gt;An example that I have been practising with is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;We have access to rolls of length &lt;span class=&quot;math-container&quot;&gt;$20$&lt;/span&gt;. Minimise the number of rolls required for &lt;span class=&quot;math-container&quot;&gt;$301$&lt;/span&gt; length-&lt;span class=&quot;math-container&quot;&gt;$9$&lt;/span&gt; rolls, &lt;span class=&quot;math-container&quot;&gt;$401$&lt;/span&gt; length-&lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; rolls, &lt;span class=&quot;math-container&quot;&gt;$201$&lt;/span&gt; length-&lt;span class=&quot;math-container&quot;&gt;$7$&lt;/span&gt; rolls, and &lt;span class=&quot;math-container&quot;&gt;$501$&lt;/span&gt; length-&lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; rolls.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I start with &lt;span class=&quot;math-container&quot;&gt;$A_0=[2e_1,2e_2,2e_3,3e_4]$&lt;/span&gt; and solve&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_x \sum_1^4 x_j \text{    subject to } A_0x=b=[301,401,201,501]^\text{T}&#xA;$$&lt;/span&gt;&#xA;and replace columns twice to obtain&#xA;&lt;span class=&quot;math-container&quot;&gt;$$A_2= \begin{pmatrix}&#xA;2&amp;amp;0&amp;amp;0&amp;amp;0\\&#xA;0&amp;amp;2&amp;amp;0&amp;amp;1\\&#xA;0&amp;amp;0&amp;amp;2&amp;amp;0\\&#xA;0&amp;amp;0&amp;amp;1&amp;amp;2&#xA;\end{pmatrix} \text{} x_2=\begin{pmatrix}&#xA;150.5\\100.375\\100.5\\200.25\end{pmatrix}$$&lt;/span&gt;&#xA;as an optimal solution after checking all dual constraints are satisfied.&lt;/p&gt;&#xA;&lt;p&gt;So how exactly do I proceed from this stage in a Branch and Bound fashion?&lt;/p&gt;&#xA;&lt;p&gt;Say we branch into the 2 cases with the first variable &lt;span class=&quot;math-container&quot;&gt;$\leqslant 150$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\geqslant 151$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;From my understanding, the first case means we add an extra constraint to the problem and hence an extra slack variable giving the system&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{pmatrix}&#xA;2&amp;amp;0&amp;amp;0&amp;amp;0&amp;amp;0\\&#xA;0&amp;amp;2&amp;amp;0&amp;amp;1&amp;amp;0\\&#xA;0&amp;amp;0&amp;amp;2&amp;amp;0&amp;amp;0\\&#xA;0&amp;amp;0&amp;amp;1&amp;amp;2&amp;amp;0\\&#xA;1&amp;amp;0&amp;amp;0&amp;amp;0&amp;amp;1&#xA;\end{pmatrix} x = \begin{pmatrix}301\\401\\201\\501\\150 \end{pmatrix}&#xA;$$&lt;/span&gt;&#xA;however it's clear this can't be right since the exact solution in this case still gives the first variable as &lt;span class=&quot;math-container&quot;&gt;$301/2&amp;gt;150$&lt;/span&gt; and the slack variable is negative. Or even just noting that only column 1 contributes to the &lt;span class=&quot;math-container&quot;&gt;$301$&lt;/span&gt; orders of length-&lt;span class=&quot;math-container&quot;&gt;$9$&lt;/span&gt; rolls so we certainly can't solve the problem with these patterns in this case.&lt;/p&gt;&#xA;&lt;p&gt;I'm unsure if I should classify this case as infeasible since it's probably just because I don't have the right columns generated (assuming I've done this correctly in the first place...).&lt;/p&gt;&#xA;" OwnerUserId="10762" LastEditorUserId="123" LastEditDate="2022-11-17T22:06:09.497" LastActivityDate="2022-11-17T22:06:09.497" Title="How do we branch a Cutting Stock problem using Branch and Price?" Tags="|column-generation|branch-and-bound|lp-relaxation|branch-and-price|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9326" PostTypeId="2" ParentId="9325" CreationDate="2022-11-17T18:19:57.453" Score="2" Body="&lt;p&gt;At this stage you have the following options :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you could solve the restricted master problem with integer variables (this is also called &lt;em&gt;price-and-branch&lt;/em&gt;). In this case you are using classical branch-and-bound, but potentially with not the right variables to reach optimality. So this is a heuristic.&lt;/li&gt;&#xA;&lt;li&gt;you could keep variables continuous, perform proper &lt;em&gt;branch-and-price&lt;/em&gt;, and branch  on the variables of your master problem (&lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;), but this is typically not efficient&lt;/li&gt;&#xA;&lt;li&gt;you could keep variables continuous and branch differently,  within the subproblem.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-11-17T18:29:11.460" LastActivityDate="2022-11-17T18:29:11.460" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9327" PostTypeId="1" AcceptedAnswerId="9369" CreationDate="2022-11-17T20:11:52.610" Score="2" ViewCount="99" Body="&lt;p&gt;Given a directed network (or graph) &lt;span class=&quot;math-container&quot;&gt;$G = (V,E)$&lt;/span&gt; with each edge &lt;span class=&quot;math-container&quot;&gt;$e_{ij}$&lt;/span&gt; having a non-negative cost as the travel time from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. Each node has an associated demand &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt;. If the demand is positive, then that node is a pick-up node; if the demand is negative then that node is a delivery node. Furthermore, we have a source and a target node such that the source node always has non-negative demand. The model that I have made is to minimize the total travel time between the source and the target such that it visits all nodes, i.e satisfies all the demands and the truck does not arrive at a node before the earliest allowed time:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{lrclll}&#xA; \min &amp;amp; \sum\limits_{i \in N} \sum\limits_{j \in N} {x_{i, j}} \cdot T_{i, j} &amp;amp;&amp;amp;&amp;amp;&amp;amp;  \\&#xA; \mbox{s.t.} &amp;amp; \sum\limits_{j \in N \setminus \{i\}} x_{i, j} &amp;amp; = &amp;amp; 1 &amp;amp; \forall i \in N \setminus \{t\} &amp;amp; \\&#xA; &amp;amp; \sum\limits_{i \in N \setminus \{j\}} x_{i, j} &amp;amp; = &amp;amp; 1 &amp;amp; \forall j \in N \setminus \{s\} &amp;amp; \\\\ &amp;amp; \tau_i + T_{i, j} &amp;amp; \leq &amp;amp; \tau_j + (1 - x_{i, j})\cdot M_\text{arrival_time} &amp;amp; \forall (i, j) \in N \times N &amp;amp; \scriptstyle\\&#xA; &amp;amp; r_i &amp;amp; \leq &amp;amp; \tau_i &amp;amp; \forall i \in N &amp;amp; \\\\&#xA; &amp;amp; \ell_s &amp;amp; = &amp;amp; d_s &amp;amp;&amp;amp;  \\&#xA; &amp;amp; \ell_i + d_j &amp;amp; \leq&amp;amp; \ell_j + (1 - x_{i, j})\cdot M_\text{load} &amp;amp; \forall (i, j) \in N \times N &amp;amp; \\&#xA; &amp;amp; \ell_i + d_j &amp;amp; \geq&amp;amp; \ell_j - (1 - x_{i, j})\cdot M_\text{load} &amp;amp; \forall (i, j) \in N \times N &amp;amp; \\\\&#xA; &amp;amp; \tau_i &amp;amp; \geq &amp;amp; 0 &amp;amp; \forall i \in N &amp;amp; \\&#xA; &amp;amp; \ell_i &amp;amp; \geq &amp;amp; 0 &amp;amp; \forall i \in N &amp;amp; \\&#xA; &amp;amp; x_{i, j} &amp;amp; \in &amp;amp; \mathbb{B} &amp;amp; \forall (i, j) \in N \times N &amp;amp;  \\&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$T_{i,j}$&lt;/span&gt; is the travel time between &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; node, &lt;span class=&quot;math-container&quot;&gt;$x_{i,j} = 1$&lt;/span&gt; if the edge &lt;span class=&quot;math-container&quot;&gt;$ij$&lt;/span&gt; is chosen and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise, &lt;span class=&quot;math-container&quot;&gt;$\ell_i$&lt;/span&gt; the load of the vehicle at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; the demand of a node, &lt;span class=&quot;math-container&quot;&gt;$\tau_i$&lt;/span&gt; the arrival time at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; the earliest allowed time for arrival at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. My question is how can I expand this model to accommodate for &lt;span class=&quot;math-container&quot;&gt;$k \geq 2$&lt;/span&gt; vehicles with &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; sources and targets?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: Assume that each node can not be visited by more than 1 vehicle and the source, target nodes are fixed. Also, assume that it does not matter which vehicle ends up in which locations so the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-th vehicle does not have to end up at &lt;span class=&quot;math-container&quot;&gt;$t_k$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10764" LastEditorUserId="500" LastEditDate="2022-11-18T00:50:40.100" LastActivityDate="2022-11-24T03:14:38.057" Title="Modify the network model to accommodate multiple vehicles" Tags="|optimization|linear-programming|constraint-programming|vehicle-routing|network-flow|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9328" PostTypeId="1" CreationDate="2022-11-17T22:23:21.780" Score="3" ViewCount="269" Body="&lt;p&gt;I have an integer optimization problem with one constraint per decision variable and no objective function. It can be coded and solved using &lt;code&gt;docplex&lt;/code&gt;, however I am struggling to implement an equivalent model in &lt;code&gt;PuLP&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h1&gt;Problem&lt;/h1&gt;&#xA;&lt;p&gt;Given a series with indices &lt;code&gt;0...n&lt;/code&gt;, find integer values of the series such that the value for each index &lt;code&gt;i&lt;/code&gt; corresponds to the number of occurrences of &lt;code&gt;i&lt;/code&gt; in the series.&lt;/p&gt;&#xA;&lt;p&gt;For example, a solution for &lt;code&gt;n = 4&lt;/code&gt; is:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;0&lt;/th&gt;&#xA;&lt;th&gt;1&lt;/th&gt;&#xA;&lt;th&gt;2&lt;/th&gt;&#xA;&lt;th&gt;3&lt;/th&gt;&#xA;&lt;th&gt;4&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;For index &lt;code&gt;i=0&lt;/code&gt;, the value is &lt;code&gt;2&lt;/code&gt;, which corresponds to the series &amp;quot;2, 1, 2, 0, 0&amp;quot; containing two occurrences of the value &lt;code&gt;0&lt;/code&gt;. Index &lt;code&gt;i=1&lt;/code&gt; has a value of &lt;code&gt;1&lt;/code&gt;, corresponding to the single occurrence of &lt;code&gt;1&lt;/code&gt; in the series. And so on.&lt;/p&gt;&#xA;&lt;h1&gt;Docplex implementation works!&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.cp.model import CpoModel&#xA;&#xA;# Data&#xA;n = 5&#xA;NUMBERS = range(n)&#xA;&#xA;# Model instance&#xA;mdl = CpoModel(name='find series')&#xA;&#xA;# Decision variables&#xA;s = mdl.integer_var_list(n, 0, n-1, &amp;quot;series&amp;quot;)&#xA;&#xA;# Constraint: Value should equal the # of occurrences of the index in the series&#xA;&#xA;for i in NUMBERS:&#xA;    mdl.add(sum(s[j] == i for j in NUMBERS) == s[i])&#xA;&#xA;# Solve&#xA;msol = mdl.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;PuLP attempts do NOT work!&lt;/h1&gt;&#xA;&lt;p&gt;Not sure if it matters, but I'm using the default CBC &lt;code&gt;PuLP&lt;/code&gt; solver in both attempts below.&lt;/p&gt;&#xA;&lt;h2&gt;Attempt 1&lt;/h2&gt;&#xA;&lt;p&gt;In this attempt, the &lt;code&gt;if&lt;/code&gt; statement of the constraint seems to always evaluate to &lt;code&gt;True&lt;/code&gt;, such that the constraints become &lt;code&gt;X[i] = 5&lt;/code&gt;, which is infeasible since the maximum value of the decision variables is &lt;code&gt;n = 4&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import *&#xA;&#xA;# Data&#xA;n = 4&#xA;NUMBERS = range(n+1)&#xA;&#xA;# Model instance&#xA;model = LpProblem(&amp;quot;FindSeries&amp;quot;)&#xA;&#xA;# Decision variables&#xA;X = LpVariable.dicts('X', NUMBERS, lowBound=0, upBound=n, cat=LpInteger)&#xA;&#xA;# Constraint: Value should equal the # of occurrences of the index in the series&#xA;for i in NUMBERS:&#xA;    model += lpSum([1 for j in NUMBERS if X[j]==i]) - X[i] == 0&#xA;&#xA;# Solve&#xA;model.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The constraints look like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;_C1: - X_0  = -5&#xA;_C2: - X_1  = -5&#xA;_C3: - X_2  = -5&#xA;_C4: - X_3  = -5&#xA;_C5: - X_4  = -5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Attempt 2&lt;/h2&gt;&#xA;&lt;p&gt;When the above failed, I tried implementing the constraint another way, more similar to the &lt;code&gt;docplex&lt;/code&gt; code.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Constraint: Value should equal the # of occurrences of the index in the series&#xA;for i in NUMBERS:&#xA;    model += lpSum([X[j]==i for j in NUMBERS]) == X[i]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This time, I'm totally confused about what is going on. The model constraints look like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;_C1: 0 X_0 + X_1 + X_2 + X_3 + X_4 = 0&#xA;_C2: X_0 + 0 X_1 + X_2 + X_3 + X_4 = 5&#xA;_C3: X_0 + X_1 + 0 X_2 + X_3 + X_4 = 10&#xA;_C4: X_0 + X_1 + X_2 + 0 X_3 + X_4 = 15&#xA;_C5: X_0 + X_1 + X_2 + X_3 + 0 X_4 = 20&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Questions&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is it possible to solve this using &lt;code&gt;PuLP&lt;/code&gt; + default CBC solver?&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If not, why not?&lt;/li&gt;&#xA;&lt;li&gt;If so,&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I code the model correctly in &lt;code&gt;PuLP&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Why did my &lt;code&gt;PuLP&lt;/code&gt; attempts fail as they did?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10765" LastEditorUserId="491" LastEditDate="2022-11-18T17:39:55.207" LastActivityDate="2022-11-19T00:09:51.537" Title="Simple Integer Optimization Problem: docplex CP model works but equivalent PuLP+CBC model is infeasible?" Tags="|python|integer-programming|constraint-programming|docplex|pulp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9330" PostTypeId="2" ParentId="9328" CreationDate="2022-11-18T09:48:45.977" Score="2" Body="&lt;p&gt;It looks like you are confusing the variables of your problem (&lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;) with the parameters (the number of occurrences &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt;). The way I understand your problem is as follows:&lt;/p&gt;&#xA;&lt;p&gt;The mathematical expression of your constraint is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j}x_j = s_i \quad \mbox{for all }i&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; denotes the number of occurrences of value &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in the series.&lt;/p&gt;&#xA;&lt;p&gt;With PuLP:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in s:&#xA;   model += lpSum(x[j] for j in x) == s[i]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I misunderstood the question and am editing according the comments below. So the constraint is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j}|\{j : x_j=i\}| = x_i \quad \mbox{for all }i&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is not a linear constraint and thus cannot be implemented as is in PuLp. I suggest to use Erwin's MIP below, which can be solved with PuLp.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-11-18T14:42:11.943" LastActivityDate="2022-11-18T14:42:11.943" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9331" PostTypeId="2" ParentId="9328" CreationDate="2022-11-18T14:12:54.540" Score="3" Body="&lt;p&gt;A simple equivalent MIP model can be built as follows.&lt;/p&gt;&#xA;&lt;p&gt;Introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}\in\{0,1\}$&lt;/span&gt; such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_{i,j}=1\Leftrightarrow x_i=j$&lt;/span&gt;. The problem can now be formulated as a straight MIP model (just add a dummy objective):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;   &amp;amp;x_i = \sum_j j\cdot y_{i,j}&amp;amp;&amp;amp; \forall i &amp;amp;&amp;amp; \text{extract value}\\&#xA;   &amp;amp;\sum_j y_{i,j} = 1 &amp;amp;&amp;amp; \forall i &amp;amp;&amp;amp; \text{exactly one value in each row of $y$}\\&#xA;   &amp;amp;x_i = \sum_j y_{j,i} &amp;amp;&amp;amp; \forall i &amp;amp;&amp;amp; \text{count occurrences}\\&#xA;   &amp;amp;y_{i,j} \in \{0,1\}&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you want, you can substitute out &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and recover those values during reporting.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2022-11-19T00:09:51.537" LastActivityDate="2022-11-19T00:09:51.537" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9332" PostTypeId="1" CreationDate="2022-11-18T16:07:41.080" Score="2" ViewCount="276" Body="&lt;p&gt;Is it possible in a linear model to include a penalty if both variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are greater than zero? I would like to have no penalty, if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; OR &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is zero.&lt;/p&gt;&#xA;&lt;p&gt;For example, I have a model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;&amp;amp;\min_{x,y} c x + dy \\&#xA;\text{s.t.}&amp;amp; \\&#xA;&amp;amp; ax \le b \\&#xA;&amp;amp; zy \le e \\&#xA;&amp;amp; x,y \ge 0&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9883" LastEditorUserId="491" LastEditDate="2022-11-18T17:37:03.393" LastActivityDate="2022-11-20T06:32:59.333" Title="How can I include a penalty to my (linear) model?" Tags="|linear-programming|modeling|penalty-based-optimization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9333" PostTypeId="2" ParentId="9332" CreationDate="2022-11-18T16:24:53.880" Score="4" Body="&lt;p&gt;You cannot do this within a linear program. If the penalty is a fixed amount (not proportional to the size of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;), and assuming you can infer upper bounds &lt;span class=&quot;math-container&quot;&gt;$M_X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_Y$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y,$&lt;/span&gt; you can do it by introducing binary variables &lt;span class=&quot;math-container&quot;&gt;$W_X,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$W_Y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z.$&lt;/span&gt; In the objective function, add the product of &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; and the penalty value you want. New constraints are &lt;span class=&quot;math-container&quot;&gt;$$X \le M_X \cdot W_X,$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$Y \le M_Y \cdot W_Y$$&lt;/span&gt;and&lt;span class=&quot;math-container&quot;&gt;$$Z\ge W_X + W_Y - 1.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-18T16:24:53.880" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9334" PostTypeId="1" AcceptedAnswerId="9337" CreationDate="2022-11-18T20:17:02.897" Score="4" ViewCount="554" Body="&lt;p&gt;I am trying to solve this ILP with all &lt;strong&gt;binary variables&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{1\leq i&amp;lt;j\leq n-1-h} t_{i,j}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{n-1-h} a_{k,i} = \lfloor (n-1)/2\rfloor \qquad \text{for }k\in[h];$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{k,i} + a_{k,j} \leq 2 d_{k,i,j}\qquad \text{for }1\leq i&amp;lt;j\leq n-1-h,\ k\in[h];$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k=1}^h d_{k,i,j} \leq h - 1 + t_{i,j}\quad \text{for }1\leq i&amp;lt;j\leq n-1-h$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;thanks to an answer to my problem &lt;a href=&quot;https://mathoverflow.net/a/434465/136218&quot;&gt;here&lt;/a&gt;, for &lt;span class=&quot;math-container&quot;&gt;$n=53$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h=13$&lt;/span&gt;. If I compute the minimum in the original problem by means of many random cases I have a minimum value of &lt;span class=&quot;math-container&quot;&gt;$113$&lt;/span&gt;, therefore the actual minimum will be less or equal than that.&lt;/p&gt;&#xA;&lt;p&gt;I am using the free program LPSolve IDE 5.5.2.11 and the full problem for my &lt;span class=&quot;math-container&quot;&gt;$n=53$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h=13$&lt;/span&gt; case is &lt;a href=&quot;https://pastebin.com/quUaiR86&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; (too long to copy within the question). I have encoded multiple variable indexes in one unique integer index for the software model.&lt;/p&gt;&#xA;&lt;p&gt;There are 10387 constraints and 10881 variables.&lt;/p&gt;&#xA;&lt;p&gt;The partial result after a couple of minutes was this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Model name:  'LPSolver' - run #1&#xA;Objective:   Minimize(R0)&#xA;&#xA;SUBMITTED&#xA;Model size:    10387 constraints,   10881 variables,        39780 non-zeros.&#xA;Sets:                                   0 GUB,                  0 SOS.&#xA;&#xA;Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.&#xA;The primal and dual simplex pricing strategy set to 'Devex'.&#xA;&#xA;Relaxed solution                   0 after      10774 iter is B&amp;amp;B base.&#xA;&#xA;Feasible solution                320 after      22515 iter,      7838 nodes (gap 32000.0%)&#xA;Improved solution                319 after      23350 iter,      8716 nodes (gap 31900.0%)&#xA;Improved solution                318 after      24221 iter,      9633 nodes (gap 31800.0%)&#xA;Improved solution                317 after      25192 iter,     10569 nodes (gap 31700.0%)&#xA;Improved solution                316 after      26182 iter,     11556 nodes (gap 31600.0%)&#xA;Improved solution                315 after      27604 iter,     12611 nodes (gap 31500.0%)&#xA;Improved solution                314 after      28657 iter,     13614 nodes (gap 31400.0%)&#xA;Improved solution                313 after      29865 iter,     14645 nodes (gap 31300.0%)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now the software has done about 4,000,000 iterations in about two hours without further progress.&lt;/p&gt;&#xA;&lt;p&gt;I have very little knowledge of linear programming, so I am asking:&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to make that ILP problem faster by modifying it, use another software or change solver parameters?&lt;/p&gt;&#xA;&lt;p&gt;Can we say anything about the expected completion time?&lt;/p&gt;&#xA;" OwnerUserId="9517" LastEditorUserId="9517" LastEditDate="2022-11-18T21:20:12.177" LastActivityDate="2022-11-19T18:11:05.593" Title="Expected ILP solving time and how to improve speed" Tags="|integer-programming|solver|binary-variable|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9335" PostTypeId="1" CreationDate="2022-11-18T20:29:31.567" Score="2" ViewCount="285" Body="&lt;p&gt;I have a (I guess) simple constrained optimization problem that I'm hoping to find a closed-form solution for using Lagrangian analysis and KKT conditions. I figured out the solution but there is one Lagrangian multiplier that I can't find a solution for.&lt;/p&gt;&#xA;&lt;p&gt;The vector of decision variables that I have is denoted by &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{\gamma}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$|\boldsymbol{\gamma}| = m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min_{\gamma_j}&amp;amp;\quad\sum_{j=0}^m(\gamma_j - \frac{n}{m}\gamma_j^{\text{priority}})^2&amp;amp;\qquad(1\text{a})&#xA;\\\text{s.t.}&#xA;\\&amp;amp;\quad0 &amp;lt; \sum_{j=0}^m\gamma_j\leq n&amp;amp;\qquad(1\text{b})\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\gamma^{\text{priority}}_j\; \forall j \in \boldsymbol{\gamma}$&lt;/span&gt; are constants.&lt;/p&gt;&#xA;&lt;p&gt;Here is the full Lagrangian analysis solution:&lt;/p&gt;&#xA;&lt;p&gt;I start the solution by deriving the Lagrangian function:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\mathcal{L}(\boldsymbol{\gamma}, \lambda^{(1)}, \lambda^{(2)}) = \sum^m_{j=1} (\gamma_j - \frac{n}{m}\gamma^{\text{priority}}_j)^2 + \lambda^{(1)}\left(\sum^m_{j=1}\gamma_j\right)&#xA;- \lambda^{(1)}n - \lambda^{(2)}\sum^m_{j=1}\gamma_j\qquad(2)\end{align}&lt;/span&gt;&#xA;Then I derive the partial derivatives with respect to the decision variables and the Lagrangian multipliers:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\frac{\partial \mathcal{L}}{\partial \gamma_j} &amp;amp;= 2(\gamma_j - \frac{n}{m}\gamma^{\text{prioirty}}_j) + \lambda^{(1)} - \lambda^{(2)} &amp;amp;= 0\qquad (3)\\&#xA;\frac{\partial\mathcal{L}}{\partial \lambda^{(1)}} &amp;amp;= \sum^m_{j=1}\gamma_j = n\qquad(4)\\&#xA;\frac{\partial \mathcal{L}}{\partial \lambda^{(2)}} &amp;amp;= -\sum^m_{j=1}\gamma_j \qquad (5)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;KKT conditions:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\lambda^{(1)}\sum^m_{j=1}\gamma_j &amp;amp;= \lambda^{(1)}n\qquad(6)\\&#xA;\lambda^{(2)}\sum^m_{j=1}\gamma_j&amp;amp;=0\qquad (7)&#xA;\end{align}&lt;/span&gt;&#xA;From (3) we can conclude that:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\gamma_j = \frac{n}{m}\gamma^{\text{priority}}_j + \frac{\lambda^{(1)} - \lambda^{(2)}}{2} \qquad(8)&#xA;\end{align}&lt;/span&gt;&#xA;From (7) we conclude that &lt;span class=&quot;math-container&quot;&gt;$\lambda^{(2)} = 0$&lt;/span&gt; because the term &lt;span class=&quot;math-container&quot;&gt;$\sum^m_{j=1}\gamma_j$&lt;/span&gt; will never equal to zero. Thus we have:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\gamma_j = \frac{n}{m}\gamma^{\text{priority}}_j + \frac{\lambda^{(1)}}{2} \qquad(9)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now plugging (9) in (4) we get:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\lambda^{(1)} = \frac{2n}{m}\left(1 - \frac{1}{m}\sum^m_{j=1}\gamma^{\text{priority}}_j\right)\qquad(10)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;According to the previous steps, the closed-form solution is attainable but, when I try different values of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\gamma^{\text{priority}}_j$&lt;/span&gt; sometimes I get values for &lt;span class=&quot;math-container&quot;&gt;$\gamma_j$&lt;/span&gt; that violate constraint (1b) ,i.e., the summation of all &lt;span class=&quot;math-container&quot;&gt;$\gamma_j$&lt;/span&gt; can sometimes exceeds the value of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. For instance, when &lt;span class=&quot;math-container&quot;&gt;$n=85$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$m=42$&lt;/span&gt;, the term &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=0}^m\gamma_j$&lt;/span&gt; evaluates to &lt;span class=&quot;math-container&quot;&gt;$166$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Have I done something wrong?&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The full matlab code to simulate and test different values of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\gamma^{\text{priority}}_j$&lt;/span&gt; &lt;a href=&quot;https://github.com/ibrahim-amer/ClosedForm-KKT&quot; rel=&quot;nofollow noreferrer&quot;&gt;can be found here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/1p8FNcWLd7mZKxi4xhPWgu-6GTKetiLu6/view?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;The link to goodnotes pdf notes for the full solution of the problem can be found here.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5671" LastEditorUserId="5671" LastEditDate="2022-11-19T22:30:08.477" LastActivityDate="2022-11-22T04:53:21.127" Title="Constrained Optimization Closed Form Solution Using KKT Gives Wrong Values" Tags="|optimization|convex-optimization|kkt-conditions|lagrange-multipliers|constrained-optimization|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9336" PostTypeId="2" ParentId="9334" CreationDate="2022-11-18T21:50:13.107" Score="5" Body="&lt;p&gt;Here are the &lt;span class=&quot;math-container&quot;&gt;$a_{k,i}$&lt;/span&gt; values for a feasible solution with objective value &lt;span class=&quot;math-container&quot;&gt;$61$&lt;/span&gt;, obtained in a few minutes with a different solver.  Please verify.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1 0 1 1 1 1 0 1 1 1 0 1 1 0 1 0 1 0 1 1 0 1 1 1 1 1 1 0 0 0 1 1 0 0 1 1 0 1 1 &#xA;1 1 1 0 0 0 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 0 0 1 0 0 0 &#xA;1 1 1 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 0 &#xA;0 0 1 1 1 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 &#xA;1 1 1 1 1 0 1 0 0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 0 1 &#xA;1 1 0 1 1 1 1 1 0 1 0 1 0 1 1 0 1 1 1 0 0 0 1 0 1 1 1 0 1 1 0 1 1 1 1 0 1 0 1 &#xA;0 1 0 1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 0 1 0 0 0 1 1 &#xA;0 1 1 0 1 1 0 0 1 0 1 1 1 1 0 1 0 1 1 1 1 1 1 1 0 0 1 0 0 1 0 1 1 1 0 1 1 1 1 &#xA;1 1 1 0 0 1 1 1 1 0 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 1 1 1 0 1 1 1 1 &#xA;0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 0 1 1 1 0 0 0 0 1 1 1 0 1 1 0 &#xA;1 1 0 1 0 0 0 0 1 1 1 0 1 0 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 &#xA;0 0 1 1 0 1 1 1 1 1 1 1 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 1 1 0 0 1 0 1 0 1 &#xA;1 0 1 1 1 1 1 0 1 0 1 1 1 0 1 1 1 1 1 0 1 0 1 1 1 0 0 1 1 1 1 0 0 0 1 1 0 1 0 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Here's a better solution with objective value &lt;span class=&quot;math-container&quot;&gt;$57$&lt;/span&gt;, obtained by relaxing the first constraint from &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt;.  Each row still has exactly &lt;span class=&quot;math-container&quot;&gt;$26$&lt;/span&gt; ones.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1 1 0 0 1 0 1 1 1 1 1 1 1 0 1 1 1 1 0 1 0 1 1 0 1 1 0 1 0 1 0 1 1 1 0 0 1 0 1&#xA;1 1 0 0 1 1 1 1 1 1 0 0 1 1 1 1 0 1 1 1 1 0 1 1 0 0 0 1 1 0 1 0 1 1 1 0 0 1 1&#xA;0 1 1 0 1 1 0 0 1 1 1 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 0 1 1 0 0&#xA;1 0 1 1 1 1 0 0 1 0 1 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 1 0 1 1 0 0 1 0&#xA;1 0 0 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 1 0 0 1 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 0 1&#xA;1 1 1 1 0 1 1 1 0 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 1 0 1 1 1&#xA;1 1 1 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 1 0 1 1 1 0 1 0 1 1 0 0 1 1 1 0&#xA;0 0 1 1 1 0 1 1 1 0 1 1 0 1 1 1 1 0 0 0 1 0 1 1 0 1 1 0 0 1 1 0 1 1 1 1 1 1 1&#xA;0 1 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 0 1 1 1 0 1&#xA;1 1 0 1 1 0 1 0 0 1 1 1 1 1 1 0 1 0 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 1 1 1 1 1 1&#xA;1 0 1 1 1 1 1 0 0 1 0 1 1 1 0 1 0 1 0 0 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 1 1 0&#xA;1 0 1 0 0 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 0 0 1 0 1 0 1 0 0 1&#xA;0 1 0 0 0 1 1 1 0 0 1 1 0 0 0 0 1 1 1 1 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The minimum is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1 1 0 1 1 0 1 1 1 1 1 0 1 1 0 1 1 1 0 1 0 1 1 0 1 1 0 1 1 1 0 1 1 0 0 0 1 0 1 &#xA;0 0 1 0 1 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0 1 0 1 1 0 0 1 1 0 1 1 0 1 1 1 1 1 1 1 &#xA;1 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 1 0 1 1 1 1 1 1 0 1 0 0 1 1 1 1 1 0 1 0 1 1 0 &#xA;1 0 1 0 1 0 1 0 1 0 0 1 0 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 &#xA;1 1 1 1 1 1 0 1 1 0 1 0 0 0 1 1 1 1 1 0 1 0 1 1 1 0 1 0 1 1 0 0 1 1 0 1 1 0 1 &#xA;1 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 1 1 1 0 0 1 0 1 0 1 1 0 1 0 1 1 1 0 1 1 1 &#xA;1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 1 0 0 1 0 0 1 1 1 1 1 1 0 0 0 1 1 0 1 0 &#xA;1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 0 1 1 0 1 0 1 0 1 1 1 0 1 1 1 1 0 &#xA;1 0 0 0 1 1 0 1 1 1 0 1 1 1 0 1 0 1 1 0 0 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 &#xA;0 1 1 0 1 1 1 0 1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 1 1 0 0 &#xA;0 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 0 0 0 0 1 1 1 0 1 1 0 0 1 1 &#xA;1 0 1 1 0 1 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 0 0 1 0 1 0 1 0 0 1 &#xA;0 1 0 1 0 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;By focusing on the locations of the zeros, you can interpret a solution with objective value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; as a &lt;span class=&quot;math-container&quot;&gt;$(39,13,2)$&lt;/span&gt;-covering design with &lt;span class=&quot;math-container&quot;&gt;$13$&lt;/span&gt; blocks, like the one found here: &lt;a href=&quot;https://ljcr.dmgordon.org/show_cover.php?v=39&amp;amp;k=13&amp;amp;t=2&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ljcr.dmgordon.org/show_cover.php?v=39&amp;amp;k=13&amp;amp;t=2&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-11-19T02:07:24.403" LastActivityDate="2022-11-19T02:07:24.403" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9337" PostTypeId="2" ParentId="9334" CreationDate="2022-11-18T22:43:23.480" Score="4" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Is it possible to make that ILP problem faster by modifying it, use&#xA;another software or change solver parameters?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Using other software: Definitely, as Rob Pratt's answer indicates. (I got an incumbent solution with value 67 in about 30 seconds with CPLEX, after which progress stalled.)&lt;/p&gt;&#xA;&lt;p&gt;Changing solver parameters: This depends to some extent on the solver (different solvers have different parameters). For example, I set the &amp;quot;MIP emphasis&amp;quot; parameter in CPLEX to 5 (heavy emphasis on heuristics) to encourage it to get a &amp;quot;good&amp;quot; solution quickly.&lt;/p&gt;&#xA;&lt;p&gt;Modifying the model: This is the tricky part. One problem with your model is that it has a &amp;quot;weak&amp;quot; formulation, meaning that relaxing integrality and solving it as an LP produces an answer with a very low objective value (0).* I tried switching the MIP emphasis in CPLEX to improvement of the lower bound, but after five minutes (the limit of my patience) the lower bound was still 0. So a stronger (tighter) formulation would definitely help ... if you could find one.&lt;/p&gt;&#xA;&lt;p&gt;An obvious weakness is the constraint &lt;span class=&quot;math-container&quot;&gt;$a_{k,i} + a_{k,j} \leq 2 d_{k,i,j},$&lt;/span&gt; which is presumably intended to say that &lt;span class=&quot;math-container&quot;&gt;$d_{k,i,j}$&lt;/span&gt; must be 1 if either &lt;span class=&quot;math-container&quot;&gt;$a_{k,i}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$a_{k,j}$&lt;/span&gt; is 1. You can get the same restriction using two constraints (&lt;span class=&quot;math-container&quot;&gt;$a_{k,i}\le d_{k,i,j}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_{k,j} \le d_{k,i,j}$&lt;/span&gt; at the cost of a modest increase in model size. Using separate constraints is somewhat stronger. For instance, if in an LP relaxation the solver sets &lt;span class=&quot;math-container&quot;&gt;$a_{k,i}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_{k,j}=0,$&lt;/span&gt; the revised formulation forces &lt;span class=&quot;math-container&quot;&gt;$d_{k,i,j}=1$&lt;/span&gt; whereas the original formulation only forces &lt;span class=&quot;math-container&quot;&gt;$d_{k,i,j}=0.5.$&lt;/span&gt; Unfortunately, in my tests, that change did not accomplish anything useful by itself.&lt;/p&gt;&#xA;&lt;p&gt;Another issue with the model is symmetry. Branch and bound solvers can bog down when equivalent solutions exist in multiple branches of the search tree. In your case, permuting the rows of the &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; matrix in any solution produces another solution with identical objective value.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Can we say anything about the expected completion time?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You will get a provable optimum within your lifetime ... if you are immortal (and assuming your computer does not run out of power or memory). Seriously, predicting solution times for integer programs is somewhere between impossible and not even that easy.&lt;/p&gt;&#xA;&lt;p&gt;* Unless the actual optimal value is 0, in which case the problem is not a weak formulation but rather difficulty improving the primal bound (best feasible solution).&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-11-19T18:11:05.593" LastActivityDate="2022-11-19T18:11:05.593" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9338" PostTypeId="1" AcceptedAnswerId="9339" CreationDate="2022-11-19T20:55:58.740" Score="3" ViewCount="103" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is a set &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is a set &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; are from the same set such that &lt;span class=&quot;math-container&quot;&gt;$j\neq k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; is a parameter.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; is a binary variable.&lt;/p&gt;&#xA;&lt;p&gt;How to model: If&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c_{ij}\cdot x_{ij} \ge c_{ik}, \forall i,j,k,j\neq k$$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$$x_{ij} \ge x_{ik}, \forall i,j,k,j\neq k$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The goal is to select &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; with the highest coefficient.&lt;/p&gt;&#xA;" OwnerDisplayName="user5245" LastEditorDisplayName="user5245" LastEditDate="2023-03-31T05:28:22.543" LastActivityDate="2023-03-31T05:28:22.543" Title="How to model if-then?" Tags="|optimization|linear-programming|integer-programming|binary-variable|logical-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9339" PostTypeId="2" ParentId="9338" CreationDate="2022-11-19T21:49:19.997" Score="4" Body="&lt;p&gt;I suspect your quantifiers are misplaced and you instead want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\bigwedge_{i,j,k,j\neq k} \left(c_{ij}x_{ij} \ge c_{ik} \implies x_{ij} \ge x_{ik}\right)$$&lt;/span&gt;&#xA;Equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\bigwedge_{i,j,k,j\neq k} \left(x_{ij} &amp;lt; x_{ik} \implies c_{ij}x_{ij} &amp;lt; c_{ik} \right)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\bigwedge_{i,j,k,j\neq k} \left(\lnot x_{ij} \land x_{ik} \implies c_{ij}x_{ij} &amp;lt; c_{ik} \right)$$&lt;/span&gt;&#xA;Introduce constants &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_{ijk} = \max(c_{ij},0) - c_{ik} + \epsilon$&lt;/span&gt; and binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{ijk}$&lt;/span&gt;, and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(1 - x_{ij}) + x_{ik} - 1 &amp;amp;\le y_{ijk} \tag1\label1 \\&#xA;c_{ij}x_{ij} - c_{ik} + \epsilon &amp;amp;\le M_{ijk}(1 - y_{ijk}) \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$\lnot x_{ij} \land x_{ik} \implies y_{ijk}$&lt;/span&gt;.&#xA;Constraint \eqref{2} enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_{ijk} \implies c_{ij}x_{ij}+ \epsilon \le c_{ik}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;From your last sentence, maybe what you really want is much simpler:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{ij} \ge x_{ik} \quad \text{for all $i,j,k$ such that $j \not= k$ and $c_{ij} &amp;gt; c_{ik}$}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-11-19T21:58:36.390" LastActivityDate="2022-11-19T21:58:36.390" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9340" PostTypeId="2" ParentId="9338" CreationDate="2022-11-19T23:53:44.833" Score="1" Body="&lt;p&gt;As I understand if &lt;span class=&quot;math-container&quot;&gt;$c_{ij}&amp;gt;c_{ik}$&lt;/span&gt; then when &lt;span class=&quot;math-container&quot;&gt;$x_{ij}&amp;gt;= {c_{ik}\over c_{ij}}$&lt;/span&gt; implies &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 1$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;${c_{ik}\over c_{ij}}$&lt;/span&gt; will be &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt;. So in that case &lt;span class=&quot;math-container&quot;&gt;$x_{ij}&amp;gt;=x_{ik}$&lt;/span&gt; is obvious and moot as &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; is binary and will be 1.&lt;br /&gt;&#xA;Game begins if &lt;span class=&quot;math-container&quot;&gt;${c_{ik}\over c_{ij}} &amp;lt; 0$&lt;/span&gt;.&lt;br /&gt;&#xA;Then &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; can be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=0$&lt;/span&gt; then need to ensure &lt;span class=&quot;math-container&quot;&gt;$x_{ik}=0$&lt;/span&gt;.&lt;br /&gt;&#xA;So introduce M (just big enough, say slightly larger than &lt;span class=&quot;math-container&quot;&gt;$\lvert{c_{ik}\over c_{ij}}\rvert$&lt;/span&gt; and introduce a constraint&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{ik} &amp;lt;= {M+ {c_{ik}\over c_{ij}}\over M}$&lt;/span&gt;.&lt;br /&gt;&#xA;This ensures if &lt;span class=&quot;math-container&quot;&gt;${c_{ik}\over c_{ij}} &amp;lt;0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_{ik} &amp;lt; 1$&lt;/span&gt; and hence is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-11-20T00:03:04.573" LastActivityDate="2022-11-20T00:03:04.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9341" PostTypeId="2" ParentId="9332" CreationDate="2022-11-20T05:37:42.927" Score="1" Body="&lt;p&gt;Obj: &lt;span class=&quot;math-container&quot;&gt;$min \ cx + dy + w\epsilon$&lt;/span&gt;&lt;br /&gt;&#xA;3 additional constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y &amp;gt;= w$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x &amp;gt;= w$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$w &amp;gt;= {{x+y}\over M} - 1$&lt;/span&gt; where we is binary and M could be chosen such that &lt;span class=&quot;math-container&quot;&gt;$1 &amp;lt; {{x+y}\over M} &amp;lt;= 2$&lt;/span&gt;. My estimate M should be in this range &lt;span class=&quot;math-container&quot;&gt;$[\lvert{b\over a}-{e\over z}\rvert,\max({b\over a}, {e\over z})]$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-11-20T06:32:59.333" LastActivityDate="2022-11-20T06:32:59.333" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9342" PostTypeId="1" CreationDate="2022-11-20T09:44:35.330" Score="3" ViewCount="45" Body="&lt;p&gt;As a distance-based MCDM method, unlike &lt;a href=&quot;https://en.wikipedia.org/wiki/TOPSIS&quot; rel=&quot;nofollow noreferrer&quot;&gt;TOPSIS&lt;/a&gt;, for &lt;a href=&quot;https://en.wikipedia.org/wiki/VIKOR_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;VIKOR&lt;/a&gt;, there is an &amp;quot;acceptability&amp;quot; check at the final step which confuses me, particularly for &amp;quot;Acceptable advantage&amp;quot;, i.e., check if the first two ranked alternatives have sufficient gap.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Acceptable advantage:&lt;span class=&quot;math-container&quot;&gt;$$Q(a'')-Q(a')\geq DQ$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$a''$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a'$&lt;/span&gt; are alternatives with second and first position respectfully in the ranking list by &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;; &lt;span class=&quot;math-container&quot;&gt;$DQ=1/(J-1)$&lt;/span&gt;; &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; is the number of alternatives.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I'm curious why this is brought up in the method at first but other MCDM methods, e.g., TOPSIS, COPRAS, ELECTRE, have no such requirements. Well, I tried to find the original thesis &lt;em&gt;Opricovic, S. (1998) Multicriteria Optimization of Civil Engineering Systems. PhD Thesis, Faculty of Civil Engineering, Belgrade, 302 p.&lt;/em&gt; but no luck.&lt;/p&gt;&#xA;" OwnerUserId="4417" LastEditorUserId="491" LastEditDate="2022-11-21T23:04:20.437" LastActivityDate="2022-11-21T23:04:20.437" Title="Understanding acceptable advantage in MCDM method VIKOR" Tags="|multicriteria-decision-analysis|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9343" PostTypeId="1" AcceptedAnswerId="9344" CreationDate="2022-11-20T18:10:57.557" Score="4" ViewCount="191" Body="&lt;p&gt;My previous &lt;a href=&quot;https://or.stackexchange.com/q/9334/9517&quot;&gt;question&lt;/a&gt; was about this ILP with all &lt;strong&gt;binary variables&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{1\leq i&amp;lt;j\leq n-1-h} t_{i,j}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{n-1-h} a_{k,i} = \lfloor (n-1)/2\rfloor \qquad \text{for }k\in[h];$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{k,i} + a_{k,j} \leq 2 d_{k,i,j}\qquad \text{for }1\leq i&amp;lt;j\leq n-1-h,\ k\in[h];$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k=1}^h d_{k,i,j} \leq h - 1 + t_{i,j}\quad \text{for }1\leq i&amp;lt;j\leq n-1-h$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for &lt;span class=&quot;math-container&quot;&gt;$n=53$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$h=13$&lt;/span&gt;. Only as a background, in case someone is interested, it was related to this &lt;a href=&quot;https://mathoverflow.net/q/414690/136218&quot;&gt;setup&lt;/a&gt; for the union-closed sets conjecture.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, the minimum found in one answer to the linked question is &lt;a href=&quot;https://or.stackexchange.com/a/9336/9517&quot;&gt;zero&lt;/a&gt;. I hoped to get a fairly high value.&lt;/p&gt;&#xA;&lt;p&gt;However, not all restrictions were put into the problem.&lt;/p&gt;&#xA;&lt;p&gt;Another one that could be added, due to the original problem, is this: add to the matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; of variables &lt;span class=&quot;math-container&quot;&gt;$a_{i,j}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$1 \le i \le h$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$1 \le j \le n-1-h$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$13$&lt;/span&gt; additional columns forming an identity matrix, plus one all zero column. After that, verify that the logical AND of any two columns of the so expanded matrix is an existing column of the same expanded matrix (although obviously it is not necessary to check the identity matrix). Intuitively, this tends to increase the number of zeroes per column, or at least does not allow a solution where the zeroes are uniformly distributed among the columns.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to add that restriction in an integer linear program?&lt;/p&gt;&#xA;&lt;p&gt;I understand that might be quite difficult, but maybe there is a way not to add the full restriction, but a reduced version of it, easier to implement, maybe some property (e.g. in the count of &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;s) implied by it.&lt;/p&gt;&#xA;&lt;p&gt;Any hint?&lt;/p&gt;&#xA;" OwnerUserId="9517" LastEditorUserId="9517" LastEditDate="2022-11-21T09:08:39.253" LastActivityDate="2022-11-21T09:08:39.253" Title="Difficult linearization of a constraint" Tags="|linear-programming|modeling|integer-programming|constraint|binary-variable|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9344" PostTypeId="2" ParentId="9343" CreationDate="2022-11-20T20:51:18.153" Score="3" Body="&lt;p&gt;One way to do it involves adding binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{i,j,\ell},$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$i&amp;lt;j$&lt;/span&gt; index a pair of original columns and &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; indexes a column in the expanded matrix. We will enforce &lt;span class=&quot;math-container&quot;&gt;$z_{i,j,\ell}=1 \implies a_{k,\ell} = a_{k,i} \cdot a_{k,j}$&lt;/span&gt; for all rows &lt;span class=&quot;math-container&quot;&gt;$k,$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$[a_{.,.}]$&lt;/span&gt; is your expanded matrix. To ensure that the AND of any two original columns is a column in the expanded matrix, you just need the constraints &lt;span class=&quot;math-container&quot;&gt;$$\sum_\ell z_{i,j,\ell} = 1 \quad\forall i &amp;lt; j.$$&lt;/span&gt;Constraints to enforce the definition of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; are:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{k,\ell} \le a_{k,i} + 1 - z_{i,j,\ell}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{k,\ell} \le a_{k,j} + 1 - z_{i,j, \ell}$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{k,\ell} \ge a_{k,i} + a_{k,j} + z_{i,j,\ell} - 2,$$&lt;/span&gt;&#xA;where all these constraints are enforced for all rows &lt;span class=&quot;math-container&quot;&gt;$k,$&lt;/span&gt; original columns &lt;span class=&quot;math-container&quot;&gt;$i&amp;lt;j$&lt;/span&gt; and expanded columns &lt;span class=&quot;math-container&quot;&gt;$\ell.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-11-20T22:28:33.047" LastActivityDate="2022-11-20T22:28:33.047" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9345" PostTypeId="1" AcceptedAnswerId="9346" CreationDate="2022-11-20T22:39:13.380" Score="-1" ViewCount="166" Body="&lt;p&gt;I am trying to solve the following problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/9298/how-to-build-a-deterministic-optimization-model-for-the-following-fc&quot;&gt;How to build a deterministic optimization model for the following fc&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;we have &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2,...,x_365$&lt;/span&gt; are the order shipped from an FC to a customer for 365 days&#xA;We have  &lt;span class=&quot;math-container&quot;&gt;$o_1,..,o_365$&lt;/span&gt; the amount that we ship from the DC to the FC.&#xA;We have the parameter &lt;span class=&quot;math-container&quot;&gt;$d1,d2,d3,...,d365$&lt;/span&gt; is the the demand for the day.&lt;/p&gt;&#xA;&lt;p&gt;We have &lt;span class=&quot;math-container&quot;&gt;$l_1,l_2,l_3,l_4,l_5,...,l_365$&lt;/span&gt; is the lost sales for the day.&lt;/p&gt;&#xA;&lt;p&gt;We also have &lt;span class=&quot;math-container&quot;&gt;$I_1,I_2,I_3,...,I_(365)$&lt;/span&gt; is the inventory stored in the FC.&lt;/p&gt;&#xA;&lt;p&gt;I have the following definition for my lost sales&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$l_i=d_i-x_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and we have inventory&#xA;is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$I_1=50-x_1$&lt;/span&gt; starting iventory is 50&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$I_2=i_1-x_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i_3=i_2-x3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i_4=i_3-x_4+o_1$&lt;/span&gt; [take 3 day for an order to reach ]&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i_365=i_{364}-x_{365}+o_{362}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Problem is I am not sure how to code this in python pulp.&lt;/p&gt;&#xA;&lt;p&gt;I have the following objective function I want to minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$50(x_1+..+x365)+2(o_1+...+o_365$&lt;/span&gt;)+3(ls_1+...+l_365)+1(o_1+..+o_365$)&lt;/p&gt;&#xA;&lt;p&gt;I got final which is a csv file&#xA;which shows how much I ordered for the 365 days of the year. It is where I get my demand&lt;/p&gt;&#xA;&lt;p&gt;But my model return all the zeroes and this cannot be right because my lost sales constraint is not satisfied.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;days    orders&#xA;1       0&#xA;2      4&#xA;3     1&#xA;4    4&#xA;5    0&#xA;6   1&#xA;7   2&#xA;8   0&#xA;9        5&#xA;10       2&#xA;11      5&#xA;&#xA;mport pandas as pd &#xA;from pulp import LpMaximize, LpProblem, LpStatus, lpSum, LpVariable,LpMinimize,LpInteger&#xA;from pulp import LpBinary&#xA;from pulp import LpSolverDefault&#xA;import pulp &#xA;&#xA;&#xA;&#xA;&#xA;&#xA;k3=pd.read_csv(&amp;quot;final.csv&amp;quot;)&#xA;w2=k3[&amp;quot;orders&amp;quot;]&#xA;demandStore=w2.tolist()&#xA;&#xA;&#xA;#DAY shipped &#xA;#WE HAVE ONE DAY MAY HAVE MULTIPLE ORDERS&#xA;xArray=[]&#xA;&#xA;    &#xA;model = LpProblem(name=&amp;quot;small&amp;quot;, sense=LpMinimize)&#xA;&#xA;&#xA;xs = [LpVariable(&amp;quot;xs{}_var&amp;quot;.format(i+1),lowBound=0,upBound=50, cat=&amp;quot;Integer&amp;quot;) for i in range(0,365)]  &#xA;&#xA;#ORDERS&#xA;os=  [LpVariable(&amp;quot;os{}_var&amp;quot;.format(i+1),lowBound=0,upBound=50, cat=&amp;quot;Integer&amp;quot;) for i in range(0,365)] &#xA;&#xA;#lost sale&#xA;ls=  [LpVariable(&amp;quot;ls{}_var&amp;quot;.format(i+1),lowBound=0,upBound=50, cat=&amp;quot;Integer&amp;quot;) for i in range(0,365)] &#xA;&#xA;&#xA;#inventory&#xA;iv=[LpVariable(&amp;quot;iv{}_var&amp;quot;.format(i+1),lowBound=0,upBound=50, cat=&amp;quot;Integer&amp;quot;) for i in range(0,365)]&#xA;&#xA;k=[]&#xA;#we have here the lost sales &#xA;&#xA;&#xA;for i in range(0,365):&#xA;#lost sales constraint is demand-orders&#xA;   w=ls[i]==demandStore[i]-xs[i]&#xA;   k.append(w)&#xA;for i in range(0,365):&#xA;    model+=k[i]&#xA;   &#xA;    &#xA;cons1=iv[0]==50-xs[0]&#xA;cons2=iv[1]==iv[0]-xs[1]+os[0]&#xA;cons3=iv[2]==iv[1]-xs[2]+os[1]&#xA;model+=cons1&#xA;model+=cons2&#xA;model+=cons3&#xA;k2=[]&#xA;for i in range(0,365):&#xA;    cool2=xs[i]&amp;lt;=iv[i]&#xA;    k2.append(cool2)&#xA;for i in range(0,365):&#xA;    model+=k2[i]&#xA;k3=[]&#xA;for i in range(3,365):&#xA;    cool=iv[i]==iv[i-1]-xs[i]+os[i-1]&#xA;    k3.append(cool)&#xA;for i in range(0,362):&#xA;    model+=k3[i]&#xA;    &#xA;&#xA;&#xA;&#xA;&#xA;One=pulp.lpSum([50*xs[i]+2*os[i]+60*ls[i]+1*iv[i] for i in range(0,365)])&#xA;#Two=pulp.lpSum([os[i]*2 for i in range(0,365)])&#xA;#Three=pulp.lpSum([iv[i]*1 for i in range(0,365)])&#xA;#four=pulp.lpSum([ls[i]*30 for i in range(0,365)])&#xA;model+=One&#xA;#model+=Two&#xA;#model+=Three&#xA;#model+=four&#xA;model.solve()&#xA;#model.solve()&#xA;name=[]&#xA;value=[]&#xA;for var in model.variables():&#xA;    print(var.name, &amp;quot; &amp;quot;,var.value())&#xA;    name.append(var.name)&#xA;    value.append(var.value())&#xA;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9483" LastEditorUserId="9483" LastEditDate="2022-11-21T19:37:26.380" LastActivityDate="2022-11-21T19:37:26.380" Title="Modeling a problem with python pulp transportation problem" Tags="|pulp|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9346" PostTypeId="2" ParentId="9345" CreationDate="2022-11-20T23:14:51.660" Score="2" Body="&lt;p&gt;I see same name used for vars ls, os and iv. Try to change that.&#xA;Also a single line to define xArray is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xArray = [*range(365)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-11-20T23:14:51.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9347" PostTypeId="1" AcceptedAnswerId="9368" CreationDate="2022-11-20T23:23:53.793" Score="2" ViewCount="96" Body="&lt;p&gt;I am considering a scheduling problem in which the events are officiated, likely as a MILP problem. I'm getting hung up on how best to model a particular requirement of how the judged events are scheduled. Any advice would be most welcome.&lt;/p&gt;&#xA;&lt;p&gt;Here is a small description with the salient details:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$E = \{1, 2, ..., n_e\}$&lt;/span&gt; : set of events to be judged&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_e$&lt;/span&gt; : anticipated duration of event &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; in minutes, &lt;span class=&quot;math-container&quot;&gt;$\forall e \in E$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$J = \{1, 2, ..., n_j\}$&lt;/span&gt; : set of judges&lt;/p&gt;&#xA;&lt;p&gt;A judge from &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; is pre-assigned to officiate one or more events from &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$V = \{1, 2, ..., n_v\}$&lt;/span&gt; : set of venues for the events&lt;/p&gt;&#xA;&lt;p&gt;The day's activity in each venue commences at the same start time.&lt;/p&gt;&#xA;&lt;p&gt;A judge's assignments are to be partitioned into &amp;quot;blocks&amp;quot; of events of no more than 60 minutes. If an event &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;'s duration &lt;span class=&quot;math-container&quot;&gt;$D_e &amp;gt;= 60$&lt;/span&gt; minutes, then it is to be in a block on its own.&lt;/p&gt;&#xA;&lt;p&gt;Then, these blocks are to be scheduled in venues from &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;, to start on a 5-minute marker (e.g. 8:00, 8:05, 8:10, ...). For example, suppose from the table below that we choose a block [1, 2, 3] for a judge, and choose to schedule it at 8:00 a.m. in venue 6. Then event 1 will begin at 8:00 a.m., event 2 at roughly 8:20 a.m., and event 3 at 8:34 a.m.; and the next block of events at venue 6 could begin no sooner than 8:45 a.m. (the nearest 5-minute marker past 8:42 a.m., the putative end time of the [1, 2, 3] block).&lt;/p&gt;&#xA;&lt;p&gt;There are constraints and penalties for certain characteristics of these block schedulings:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use all venues&lt;/li&gt;&#xA;&lt;li&gt;prevent overlap of blocks in same venue&lt;/li&gt;&#xA;&lt;li&gt;prevent overlap of a judge's blocks scheduled in different venues&lt;/li&gt;&#xA;&lt;li&gt;afford some time gap between blocks in same venue&lt;/li&gt;&#xA;&lt;li&gt;afford some time for each judge to have lunch&lt;/li&gt;&#xA;&lt;li&gt;encourage finishing all events as soon as possible&lt;/li&gt;&#xA;&lt;li&gt;encourage solutions that minimize:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the number of times a judge must switch venues&lt;/li&gt;&#xA;&lt;li&gt;the number of equipment changes needed between events&lt;/li&gt;&#xA;&lt;li&gt;overlaps between multiple events in which a participant is entered&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For a given judge, there are potentially lots of possibilities for blocks of their judging assignments. I'm getting hung up on how best to represent these possibilities and the choices thereof.&lt;/p&gt;&#xA;&lt;p&gt;Suppose a judge is pre-assigned to officiate these events:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;event number (e)&lt;/th&gt;&#xA;&lt;th&gt;D_e&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;20&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;14&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3&lt;/td&gt;&#xA;&lt;td&gt;8&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;4&lt;/td&gt;&#xA;&lt;td&gt;30&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5&lt;/td&gt;&#xA;&lt;td&gt;36&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6&lt;/td&gt;&#xA;&lt;td&gt;18&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Then &lt;span class=&quot;math-container&quot;&gt;$\{[1, 2], [3, 4], [5, 6]\}$&lt;/span&gt; is a legitimate judging assignment (I'm using square brackets here to represent sequences: event 1 is followed immediately by event 2). So is &lt;span class=&quot;math-container&quot;&gt;$\{[2, 1], [4, 3], [6, 5]\}$&lt;/span&gt;...or any other set of permutations of &lt;span class=&quot;math-container&quot;&gt;$\{1, 2\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\{3, 4\}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\{5, 6\}$&lt;/span&gt;. It's as though we can find any partition of &lt;span class=&quot;math-container&quot;&gt;$\{1, 2, 3, 4, 5, 6\}$&lt;/span&gt; in which each of the subsets obeys the 60-minute duration limit ... and then any of those subsets can be permuted to give a different sequencing for the block it represents.&lt;/p&gt;&#xA;&lt;p&gt;One possibility might be to pre-enumerate such block partitions/permutations for each judge, then have decision variables &lt;span class=&quot;math-container&quot;&gt;$PP_{ij} \in \{0, 1\}$&lt;/span&gt; where 1 = that partition/permutation possibility is used, so that &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in B} PP_{ij} = 1, \forall j \in J$&lt;/span&gt;. Then choose start times for each block in the partition/permutation possibilities chosen. This yields possibly way too many variables.&lt;/p&gt;&#xA;&lt;p&gt;Another possibility I've considered: Suppose a judge &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;'s assignment is &lt;span class=&quot;math-container&quot;&gt;$\{e_1, e_2, ..., e_{m_j}\}$&lt;/span&gt;. Then let each judge &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; have a maximum of &lt;span class=&quot;math-container&quot;&gt;$m_j$&lt;/span&gt; blocks&#xA;available. Then let &lt;span class=&quot;math-container&quot;&gt;$b_{ijk} = 1$&lt;/span&gt; if event &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; occupies position &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in block &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, else 0. Constrain &lt;span class=&quot;math-container&quot;&gt;$b_{ijk}$&lt;/span&gt; appropriately so that every event occupies exactly one&#xA;position in exactly one block; and for every block &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, if it's unused, then so is block &lt;span class=&quot;math-container&quot;&gt;$b + 1$&lt;/span&gt;; and that the sum of the durations of the events in each block is acceptable.&lt;/p&gt;&#xA;" OwnerUserId="333" LastEditorUserId="333" LastEditDate="2022-11-22T16:19:19.127" LastActivityDate="2022-11-23T21:12:13.337" Title="Modeling advice: scheduling problem with judged events and &quot;blocks&quot; of judging assignments" Tags="|mixed-integer-programming|modeling|constraint-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9348" PostTypeId="1" AcceptedAnswerId="9349" CreationDate="2022-11-21T09:51:33.300" Score="5" ViewCount="710" Body="&lt;p&gt;If I have a matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; of binary variables &lt;span class=&quot;math-container&quot;&gt;$a_{i,j}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$1 \le i \le n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$1 \le j \le m$&lt;/span&gt;, how can I enforce in an Integer Linear Program with binary variables, the condition that every two columns must be different?&lt;/p&gt;&#xA;&lt;p&gt;I know from &lt;a href=&quot;https://cs.stackexchange.com/a/12118/148736&quot;&gt;here&lt;/a&gt; how to do it for a single row (two elements), for example requiring that the XOR of the two values be equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, but how to do it on the full column? Is making the OR over all the rows the only option?&lt;/p&gt;&#xA;" OwnerUserId="9517" LastEditorUserId="2415" LastEditDate="2022-11-22T20:34:19.443" LastActivityDate="2022-11-23T02:05:55.927" Title="Constraint for two binary vectors to be different" Tags="|linear-programming|modeling|integer-programming|binary-variable|logical-constraints|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9349" PostTypeId="2" ParentId="9348" CreationDate="2022-11-21T10:21:45.687" Score="5" Body="&lt;p&gt;If you &lt;em&gt;encode&lt;/em&gt; the column to be a single binary number, the first column is either larger or less than the second column. Define binary variables &lt;span class=&quot;math-container&quot;&gt;$b_{j, j'}$&lt;/span&gt; forall &lt;span class=&quot;math-container&quot;&gt;$1 \leq j &amp;lt; j' \leq m$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i} 2^i(a_{i, j} - a_{i, j'}) \geq 1 - 2^{n+1} b_{j, j'}\\&#xA;\sum_{i} 2^i(a_{i, j} - a_{i, j'}) \leq -1 + 2^{n+1}(1 - b_{j, j'})&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This model has less auxiliary variables but many large coefficients.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastEditorUserId="4569" LastEditDate="2022-11-22T02:03:15.743" LastActivityDate="2022-11-22T02:03:15.743" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9350" PostTypeId="2" ParentId="9348" CreationDate="2022-11-21T13:31:03.283" Score="11" Body="&lt;p&gt;Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}$&lt;/span&gt; indicate whether columns &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$j&amp;lt;k$&lt;/span&gt;) differ in row &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i x_{ijk} &amp;amp;\ge 1 &amp;amp;&amp;amp;\text{for $j&amp;lt;k$} \tag1\label1\\&#xA;x_{ijk} \le a_{ij} + a_{ik} &amp;amp;\le 2-x_{ijk} &amp;amp;&amp;amp;\text{for all $i$ and $j&amp;lt;k$} \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} enforces &lt;span class=&quot;math-container&quot;&gt;$\bigvee_i x_{ijk}$&lt;/span&gt; for column pair &lt;span class=&quot;math-container&quot;&gt;$(j,k)$&lt;/span&gt;.  Constraint \eqref{2} enforces &lt;span class=&quot;math-container&quot;&gt;$x_{ijk} \implies a_{ij} + a_{ik} = 1$&lt;/span&gt;.  Because &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is binary, &lt;span class=&quot;math-container&quot;&gt;$a_{ij} + a_{ik} = 1$&lt;/span&gt; is equivalent to &lt;span class=&quot;math-container&quot;&gt;$a_{ij} \not= a_{ik}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-11-22T01:43:57.463" LastActivityDate="2022-11-22T01:43:57.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9351" PostTypeId="2" ParentId="9335" CreationDate="2022-11-22T04:53:21.127" Score="3" Body="&lt;p&gt;For convenience, let &lt;span class=&quot;math-container&quot;&gt;$x_j = \gamma_j / n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_j = \gamma_j^\mathrm{priority} / m$&lt;/span&gt;, then the problem is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align*}&#xA;\min_{x_j} \quad&amp;amp;\sum_{j=0}^m(x_j - c_j)^2\\&#xA;\mathrm{s.t.} \quad&amp;amp;0\leq\sum_{j=0}^m x_j \leq 1&#xA;\end{align*}&#xA;$$&lt;/span&gt;&#xA;The Lagrangian function is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathcal{L}(x, \lambda^{(1)}, \lambda^{(2)}) = \sum (x_j - c_j)^2 + \lambda^{(1)}(\sum x_j - 1) - \lambda^{(2)}\sum x_j&#xA;$$&lt;/span&gt;&#xA;The gradient is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\frac{\partial \mathcal{L}}{\partial x_j} = 2(x_j - c_j) + \lambda^{(1)} - \lambda^{(2)} = 0, \forall j&#xA;$$&lt;/span&gt;&#xA;So&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_j = c_j + \frac {\lambda^{(2)} - \lambda^{(1)}} {2}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Complenmentary slackness&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\lambda^{(1)}(\sum x_j - 1) = 0\\&#xA;\lambda^{(2)}\sum x_j = 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Case 1: &lt;span class=&quot;math-container&quot;&gt;$\lambda^{(1)} = \lambda^{(2)} = 0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_j = c_j$&lt;/span&gt;. The primal feasibility condition is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum x_j = \sum c_j \in [0, 1]&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Case 2: &lt;span class=&quot;math-container&quot;&gt;$\lambda^{(1)} = 0, \lambda^{(2)} \neq 0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\sum x_j = 0$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\lambda^{(2)} = -2\bar{c}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\bar{c} = \sum c_j / m$&lt;/span&gt;. The dual feasibility condition is &lt;span class=&quot;math-container&quot;&gt;$\sum c_j \leq 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Case 3: &lt;span class=&quot;math-container&quot;&gt;$\lambda^{(2)} = 0, \lambda^{(1)} \neq 0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\sum x_j = 1$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\lambda^{(1)} = 2 \bar{c} - \frac {2}{m}&#xA;$$&lt;/span&gt;&#xA;The dual feasibility condition is &lt;span class=&quot;math-container&quot;&gt;$\sum c_j \geq 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Case 4: &lt;span class=&quot;math-container&quot;&gt;$\lambda^{(1)}\lambda^{(2)}\neq 0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\sum x_j=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum x_j=1$&lt;/span&gt;, which is not possible.&lt;/p&gt;&#xA;&lt;p&gt;To summarize, there might be one or two KKT points depending on the value of &lt;span class=&quot;math-container&quot;&gt;$\sum c_j$&lt;/span&gt;. When &lt;span class=&quot;math-container&quot;&gt;$\sum c_j = 0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, there are two KKT points, but they are always identical: &lt;span class=&quot;math-container&quot;&gt;$x_j = c_j$&lt;/span&gt;. Other than that, the KKT point is always unique, therefore optimal. So the solution is as follows.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum c_j &amp;lt; 0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_j = c_j - \bar c$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum c_j \in [0,1]$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_j = c_j$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum c_j &amp;gt; 1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_j = c_j - \bar c + \frac {1} {m}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;When &lt;span class=&quot;math-container&quot;&gt;$\sum c_j \leq 0$&lt;/span&gt;, the above solution gives &lt;span class=&quot;math-container&quot;&gt;$\sum x_j = 0$&lt;/span&gt;. If the actual feasible region is &lt;span class=&quot;math-container&quot;&gt;$\sum x_j &amp;gt; 0$&lt;/span&gt;, then there is no optimal solution for the problem.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2022-11-22T04:53:21.127" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9353" PostTypeId="1" CreationDate="2022-11-22T10:03:32.220" Score="2" ViewCount="43" Body="&lt;p&gt;I expect this to be an NP-complete problem, as it may reduce to the Hamiltonian Path problem.&lt;/p&gt;&#xA;&lt;p&gt;Anyway, I was wondering whether there exists some study and (aproximated) solutions for this particular problem.&lt;/p&gt;&#xA;&lt;p&gt;Formaly, for an undirected graph &lt;span class=&quot;math-container&quot;&gt;$G = (V,E)$&lt;/span&gt;, a source node &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and a subset &lt;span class=&quot;math-container&quot;&gt;$S\subseteq V$&lt;/span&gt;. Find the shortest path starting from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and passing through as many as possible nodes in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;EDIT 1: it may relate to the Spanning Tree as well. However, the Spanning Tree assume &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; to be connected, which is not a necessary condition here.&lt;/p&gt;&#xA;&lt;p&gt;EDIT 2: a possible solver might be to greedily choose a source-target pair of nodes and solve the problem described in &lt;a href=&quot;https://cs.stackexchange.com/questions/134798/shortest-path-including-all-nodes-in-a-subset&quot;&gt;here&lt;/a&gt;.&#xA;Nevertheless, this is not the same problem. Also notice that it works on directed graphs. Not really efficient this my case so.&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="5523" LastEditDate="2022-11-22T14:14:38.853" LastActivityDate="2022-11-22T14:14:38.853" Title="Shortest (undirected) path constrained to a sub-set of nodes" Tags="|reference-request|set-covering|hamiltonian-path|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9354" PostTypeId="1" AcceptedAnswerId="9355" CreationDate="2022-11-22T13:21:03.363" Score="4" ViewCount="76" Body="&lt;p&gt;How can I add to this ILP with all &lt;strong&gt;binary variables&lt;/strong&gt; (again related to this &lt;a href=&quot;https://or.stackexchange.com/q/9334/9517&quot;&gt;question&lt;/a&gt;):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{1\leq i&amp;lt;j\leq n-1-h} t_{i,j}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{n-1-h} a_{k,i} \ge \lfloor (n-1)/2\rfloor \qquad \text{for }k\in[h];$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{k,i} + a_{k,j} \leq 2 d_{k,i,j}\qquad \text{for }1\leq i&amp;lt;j\leq n-1-h,\ k\in[h];$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k=1}^h d_{k,i,j} \leq h - 1 + t_{i,j}\quad \text{for }1\leq i&amp;lt;j\leq n-1-h$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where I have modified &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; into &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; with respect to the linked question, the requirement that for each row &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; of the &lt;span class=&quot;math-container&quot;&gt;$h \times n-h-1$&lt;/span&gt; matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; with elements &lt;span class=&quot;math-container&quot;&gt;$a_{k,i}$&lt;/span&gt; there exists at least another row &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; with elements &lt;span class=&quot;math-container&quot;&gt;$a_{p,i}$&lt;/span&gt; such that there are at least &lt;span class=&quot;math-container&quot;&gt;$m = \lceil(n+1)/4\rceil-1$&lt;/span&gt; indexes &lt;span class=&quot;math-container&quot;&gt;$1 \le i_1 \le \ldots \le i_m \le n-1-h$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$a_{k,i_j}=1 \land a_{p,i_j}=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$1 \le j \le m$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="9517" LastActivityDate="2022-11-22T17:18:49.653" Title="Another difficult constraint for an ILP" Tags="|linear-programming|modeling|integer-programming|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9355" PostTypeId="2" ParentId="9354" CreationDate="2022-11-22T17:18:49.653" Score="2" Body="&lt;p&gt;For lack of anything better, I will use the term &amp;quot;complements&amp;quot; to indicate that a row &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; satisfies the desired condition with respect to a different row &lt;span class=&quot;math-container&quot;&gt;$k.$&lt;/span&gt; For &lt;span class=&quot;math-container&quot;&gt;$k \neq p$&lt;/span&gt; and all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; we can introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{k,p,i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_{k,p},$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$z_{k,p,i}=1 \implies a_{k,i}=1\wedge a_{p,i}=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_{k,p}=1\implies$&lt;/span&gt; row &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; complements row &lt;span class=&quot;math-container&quot;&gt;$k.$&lt;/span&gt; The requirement that some row complement row &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is just &lt;span class=&quot;math-container&quot;&gt;$$\sum_{p \neq k} w_{k,p} \ge 1.$$&lt;/span&gt; The constraints defining &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$$z_{k,p,i} \le a_{k,i}$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$z_{k,p,i} \le 1 - a_{p,i}.$$&lt;/span&gt; Finally, the connection between &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$$m\cdot w_{k,p} \le \sum_i z_{k,p,i}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-22T17:18:49.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9356" PostTypeId="1" AcceptedAnswerId="9358" CreationDate="2022-11-22T17:58:50.453" Score="1" ViewCount="163" Body="&lt;p&gt;I have a simple constraint programming model which can be solved using the &lt;code&gt;docplex&lt;/code&gt; library, however I am struggling to implement the same model using &lt;code&gt;ortools&lt;/code&gt; (see the examples below).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Is there a fundamental limitation of &lt;code&gt;ortools&lt;/code&gt; which prevents implementing this solution, or is there a problem with my syntax?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I am NOT interested in alternative problem formulations, e.g., reformulating this as an MIP. This is a toy problem and I know different formulations are possible. &lt;em&gt;My goal is to understand the differences and limitations of different solvers when it comes to implementing a constraint like this.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Problem&lt;/h1&gt;&#xA;&lt;p&gt;Given a series with indices &lt;code&gt;0...n&lt;/code&gt;, find integer values of the series such that the value for each index &lt;code&gt;i&lt;/code&gt; corresponds to the number of occurrences of &lt;code&gt;i&lt;/code&gt; in the series.&lt;/p&gt;&#xA;&lt;p&gt;For example, a solution for &lt;code&gt;n = 4&lt;/code&gt; is:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;0&lt;/th&gt;&#xA;&lt;th&gt;1&lt;/th&gt;&#xA;&lt;th&gt;2&lt;/th&gt;&#xA;&lt;th&gt;3&lt;/th&gt;&#xA;&lt;th&gt;4&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;1&lt;/td&gt;&#xA;&lt;td&gt;2&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;td&gt;0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;For index &lt;code&gt;i=0&lt;/code&gt;, the value is &lt;code&gt;2&lt;/code&gt;, which corresponds to the series &amp;quot;2, 1, 2, 0, 0&amp;quot; containing two occurrences of the value &lt;code&gt;0&lt;/code&gt;. Index &lt;code&gt;i=1&lt;/code&gt; has a value of &lt;code&gt;1&lt;/code&gt;, corresponding to the single occurrence of &lt;code&gt;1&lt;/code&gt; in the series. And so on.&lt;/p&gt;&#xA;&lt;h1&gt;Example input data&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Input: Series length&#xA;n = 5&#xA;&#xA;# Define data&#xA;max_value = n - 1&#xA;NUMBERS = range(n)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;&lt;code&gt;docplex&lt;/code&gt; implementation works!&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.cp.model import CpoModel&#xA;&#xA;# Model instance&#xA;model = CpoModel(name='find series')&#xA;&#xA;# Decision variables&#xA;s = model.integer_var_list(n, 0, max_value, &amp;quot;series&amp;quot;)&#xA;&#xA;# Constraint: Value should equal the # of occurrences of the index in the series&#xA;for i in NUMBERS:&#xA;    model.add(sum(s[j] == i for j in NUMBERS) == s[i])&#xA;&#xA;# Solve&#xA;model.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;&lt;code&gt;ortools&lt;/code&gt; implementation does NOT work!&lt;/h1&gt;&#xA;&lt;p&gt;When attempting to run the code below, I get an error when I try to define the constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;TypeError: unsupported operand type(s) for +: 'int' and 'BoundedLinearExpression'&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I've tried adjusting the syntax a few different ways, but it never reads the constraint as I intend it to.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from ortools.sat.python import cp_model&#xA;&#xA;# Model instance&#xA;model = cp_model.CpModel()&#xA;&#xA;# Decision variables&#xA;X = {}&#xA;for i in NUMBERS:&#xA;    X[i] = model.NewIntVar(0, max_value, f'X_{i}')&#xA;&#xA;# Add constraints (CODE FAILS HERE)&#xA;for i in NUMBERS:&#xA;    model.Add(X[i] == sum([X[j]==i for j in NUMBERS]))&#xA;&#xA;# Solve&#xA;solver = cp_model.CpSolver()&#xA;solver.Solve(model)&#xA;&#xA;# Solution&#xA;print('Solve status: %s' % solver.StatusName())&#xA;if solver.StatusName() in ['FEASIBLE', 'OPTIMAL']:&#xA;    for i in NUMBERS:&#xA;        print(f'  X_{i}: {solver.Value(X[i])}')&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10765" LastEditorUserId="981" LastEditDate="2023-02-19T14:42:18.463" LastActivityDate="2023-02-19T14:42:18.463" Title="Simple Constraint Programming Problem: docplex works but equivalent ortools model is infeasible" Tags="|python|constraint-programming|or-tools|docplex|cp-sat|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9357" PostTypeId="1" AcceptedAnswerId="9404" CreationDate="2022-11-22T19:28:30.233" Score="2" ViewCount="66" Body="&lt;p&gt;So I have this constraint to write in CPLEX:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad Z=\sum_{(i,j)\in A}c_{ij}x_{ij}\tag1\\\text{s.t.}&amp;amp;\quad\sum_{j:(s,j)\in A}x_{sj}=K\tag{2.2}\\&amp;amp;\quad\sum_{i:(i,t)\in A}x_{it}=K\tag{3.2}\\&amp;amp;\quad\sum_{i\ne t:(i,j)\in A}x_{ij}-\sum_{i\ne s:(j,i)\in A}x_{ji}=0&amp;amp;\quad j\in V\setminus\{s,t\}\tag4\\&amp;amp;\quad x_{\{i,j\}}\in\{0,1\}&amp;amp;\quad(i,j)\in A\tag5\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is what I have:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    int n=...;&#xA;    range ns =1..n;&#xA;&#xA;    int s=...;// 1&#xA;    int t=...;// 50&#xA;    int k=...;// 2&#xA;&#xA;    int dist [ns][ns]=...;&#xA;    int mi [ns][ns]=...; &#xA;&#xA;    dvar boolean x [ns][ns];&#xA;&#xA;    minimize sum(i in ns, j in ns) dist[i][j] * x[i][j];&#xA;&#xA;    subject to{&#xA;&#xA;       sum (j in ns)mi[s][j]*x[s][j]==k;&#xA;  &#xA;       sum (i in ns)mi[i][t]*x[i][t]==k;&#xA;  &#xA;       forall(j in ns: j!=s &amp;amp;&amp;amp; j!=t){&#xA;         sum(i in ns)x[i][j] - sum(i in ns)x[j][i] != 1 ;&#xA;       }&#xA;     }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The data that I am using is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mi= [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];&#xA;&#xA;&#xA;dist = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 121, 0, 74, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 175],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 139, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 167, 0, 0, 0, 0, 0, 0, 0, 0, 175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 173, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 142, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, 0, 0, 130, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, 57, 0, 0, 128, 0, 0, 0, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 78, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 188, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 113, 0, 0, 0, 0, 0, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 153],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 50, 0, 0, 0, 0, 0, 0, 0, 0, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 0, 0, 0, 0, 0, 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 89],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 103, 0, 0, 59, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 0, 0, 0, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 94, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 157, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 163, 0, 0, 147, 102, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 80],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 0, 0, 0, 0, 0, 0, 0, 0, 229, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 0, 132],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];&#xA;&#xA;n = 50;&#xA;s = 1;&#xA;t = 50;&#xA;k = 2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And I am not getting the right result.&lt;/p&gt;&#xA;" OwnerUserId="10784" LastEditorUserId="123" LastEditDate="2022-11-22T23:35:09.077" LastActivityDate="2022-11-26T19:46:08.737" Title="Disjoint Paths and Minimum Total Cost Disjoint Paths Problem in CPLEX" Tags="|cplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9358" PostTypeId="2" ParentId="9356" CreationDate="2022-11-22T19:43:47.710" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Please read &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/sat/docs/channeling.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;this doc section&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;cp-sat prefers Boolean variables. Here is a c++ &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/cpp/magic_sequence_sat.cc&quot; rel=&quot;nofollow noreferrer&quot;&gt;version&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="981" LastEditorUserId="10765" LastEditDate="2022-11-22T21:05:45.380" LastActivityDate="2022-11-22T21:05:45.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9359" PostTypeId="2" ParentId="9357" CreationDate="2022-11-22T20:01:39.113" Score="2" Body="&lt;p&gt;Your third constraint&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;forall(j in ns: j!=s &amp;amp;&amp;amp; j!=t){&#xA;     sum(i in ns)x[i][j] - sum(i in ns)x[j][i] != 1 ;&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;does not match flow balance constraint (4) because you sum over all i,j pairs rather than just those with arcs (i.e., you fail to multiply by mi[.][.]) and because != 1 is not the same as == 0.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-22T20:01:39.113" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9360" PostTypeId="1" AcceptedAnswerId="9361" CreationDate="2022-11-22T21:40:43.550" Score="3" ViewCount="294" Body="&lt;p&gt;What constraints would you write to ensure that if &lt;span class=&quot;math-container&quot;&gt;$x = 1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y = 0$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x, y$&lt;/span&gt; are binary variables?&lt;/p&gt;&#xA;&lt;p&gt;Until now I only learnt how to build the constraint with 3 binary variables, therefore the difficulty level of this task is very high for me.&lt;/p&gt;&#xA;" OwnerUserId="10750" LastEditorUserId="123" LastEditDate="2022-11-22T23:36:00.713" LastActivityDate="2022-11-22T23:36:00.713" Title="Binary variables constraint" Tags="|linear-programming|constraint|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9361" PostTypeId="2" ParentId="9360" CreationDate="2022-11-22T21:45:30.770" Score="6" Body="&lt;p&gt;Via conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x \implies \lnot y \\&#xA;\lnot x \lor \lnot y \\&#xA;(1 - x ) + (1 - y) \ge 1 \\&#xA;x + y \le 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-11-22T21:45:30.770" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9362" PostTypeId="1" CreationDate="2022-11-23T00:42:54.493" Score="0" ViewCount="163" Body="&lt;p&gt;I am trying solve a scheduling problem adopting a rolling horizon approach. I have developed an Integer programming model and seek to speed up execution.&lt;/p&gt;&#xA;&lt;p&gt;I am seeking advice on beginner level literature on the topic - papers/articles/books and any other materials that would help me to learn this approach. I found it difficult to find sufficient information as most of it is mainly from research papers where it is either too complex or too vaguely described with no examples at all.&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="491" LastEditDate="2022-11-23T17:02:20.560" LastActivityDate="2022-12-13T12:37:30.337" Title="Rolling Horizon approach for solving a job scheduling problem" Tags="|optimization|mixed-integer-programming|linear-programming|reference-request|scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9363" PostTypeId="2" ParentId="9348" CreationDate="2022-11-23T02:05:55.927" Score="2" Body="&lt;p&gt;This is an &amp;quot;alldifferent&amp;quot; constraint.  In addition to the two approaches already described, I'll describe two more.&lt;/p&gt;&#xA;&lt;h1&gt;Binary encoding&lt;/h1&gt;&#xA;&lt;p&gt;Yet another way is to use a binary encoding of a location that differs, rather than a one-hot encoding as in &lt;a href=&quot;https://or.stackexchange.com/a/9350/2415&quot;&gt;RobPratt's answer&lt;/a&gt;.  In particular, we'll have binary decision variables &lt;span class=&quot;math-container&quot;&gt;$x_{jk\ell}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x_{jk\lg n} \cdots x_{jk1} x_{jk0}$&lt;/span&gt; is intended to be interpreted as the binary representation of a row &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$a_{i,j} \ne a_{i,k}$&lt;/span&gt;.  To ensure this representation is valid, we add the constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$(x_{jk0} \ne i_0) \lor (x_{jk1} \ne i_1) \lor \dots \lor (x_{jk\lg n} \ne i_{\lg n})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for every &lt;span class=&quot;math-container&quot;&gt;$i,j,k$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$a_{i,j} = a_{i,k}$&lt;/span&gt;.  Here I write &lt;span class=&quot;math-container&quot;&gt;$i_\ell$&lt;/span&gt; for the &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt;th bit of the binary representation of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.  The above constraint can be expressed as a linear inequality as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$1 \le \sum_{i_\ell=0} x_{jk\ell} + \sum_{i_\ell=1} (1-x_{jk\ell}),$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the first sum ranges over &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$i_\ell=0$&lt;/span&gt; and the second sum ranges over &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$i_\ell=1$&lt;/span&gt;, and we have one linear inequality per &lt;span class=&quot;math-container&quot;&gt;$i,j,k$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$a_{i,j}=a_{i,k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j&amp;lt;k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This approach uses about &lt;span class=&quot;math-container&quot;&gt;$0.5 m^2 \lg n$&lt;/span&gt; binary variables and &lt;span class=&quot;math-container&quot;&gt;$0.5 m^2 n$&lt;/span&gt; linear inequalities.  Compare to RobPratt's answer, which uses &lt;span class=&quot;math-container&quot;&gt;$m^2 n$&lt;/span&gt; binary variables and &lt;span class=&quot;math-container&quot;&gt;$m^2 n$&lt;/span&gt; linear inequalities.  So, this approach is more concise than RobPratt's answer: it uses significantly fewer variables and &lt;span class=&quot;math-container&quot;&gt;$2\times$&lt;/span&gt; fewer inequalities.  However, it is possible that it might play less well with solvers (e.g., because randomized rounding is less likely to be effective).&lt;/p&gt;&#xA;&lt;h1&gt;Sorting networks&lt;/h1&gt;&#xA;&lt;p&gt;Another approach is to build a &lt;a href=&quot;https://en.wikipedia.org/wiki/Sorting_network&quot; rel=&quot;nofollow noreferrer&quot;&gt;sorting network&lt;/a&gt; to sort the &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; columns, then after they are put into sorted order, add constraints to ensure that each adjacent pair of columns are different.&lt;/p&gt;&#xA;&lt;p&gt;You can build a sorting network to sort the &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; columns using &lt;span class=&quot;math-container&quot;&gt;$O(\log^2 m)$&lt;/span&gt; layers, where each layer has &lt;span class=&quot;math-container&quot;&gt;$O(m)$&lt;/span&gt; comparators.  You can express each comparator in ILP using &lt;span class=&quot;math-container&quot;&gt;$O(n)$&lt;/span&gt; binary variables and &lt;span class=&quot;math-container&quot;&gt;$O(n)$&lt;/span&gt; linear inequalities.  This leads to a sorting network that uses &lt;span class=&quot;math-container&quot;&gt;$O(mn\log^2 m)$&lt;/span&gt; variables and inequalities.  The final check that each adjacent pair of columns are different can be done with &lt;span class=&quot;math-container&quot;&gt;$O(mn)$&lt;/span&gt; variables and inequalities.&lt;/p&gt;&#xA;&lt;p&gt;So, in total, this gives a solution that encodes your problem as an ILP instance with &lt;span class=&quot;math-container&quot;&gt;$O(mn \log^2 m)$&lt;/span&gt; variables and inequalities.  For small &lt;span class=&quot;math-container&quot;&gt;$m,n$&lt;/span&gt;, this is probably worse than the other approaches, but for large values of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, it is possible that this might work better.&lt;/p&gt;&#xA;" OwnerUserId="2415" LastActivityDate="2022-11-23T02:05:55.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9364" PostTypeId="1" AcceptedAnswerId="9370" CreationDate="2022-11-23T04:10:42.823" Score="3" ViewCount="100" Body="&lt;p&gt;I have a question like&lt;/p&gt;&#xA;&lt;p&gt;Let, &lt;span class=&quot;math-container&quot;&gt;$\mu = (\mu_1,\ldots, \mu_K),$&lt;/span&gt; given &lt;span class=&quot;math-container&quot;&gt;$M: K \times m$&lt;/span&gt; a full rank matrix&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min_{\mu \in \mathbb R^K} \sum^n_{i=1}\sum^K_{k=1}(y_{ik} - \mu_k)^2$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\log \mu = M\beta,~\beta \in \mathbb R^m.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$\log$&lt;/span&gt; here is an element-wise log transform of a vector.&lt;/p&gt;&#xA;&lt;p&gt;I think this problem is a nonlinear problem due to the log constraint.&lt;/p&gt;&#xA;&lt;p&gt;Initially, I thought a gradient descent method with a projection to the constraint set &lt;span class=&quot;math-container&quot;&gt;$\{\mu: \mu = \exp(M\beta), \beta \in \mathbb R^m\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, this cannot guarantee a solution because it is not a convex problem.&lt;/p&gt;&#xA;&lt;p&gt;How can I solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="10790" LastEditorUserId="491" LastEditDate="2022-11-23T17:01:34.783" LastActivityDate="2022-11-25T15:11:08.747" Title="Problems involve exponential equality constraints" Tags="|optimization|nonlinear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9365" PostTypeId="1" AcceptedAnswerId="9366" CreationDate="2022-11-23T09:29:52.023" Score="5" ViewCount="403" Body="&lt;p&gt;The task is to ensure that if &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt; for at least &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; of the possible indices &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$\{1,...,n\}$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$y = 1$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; are parameters, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a binary variable vector with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; elements, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a binary variable.&lt;/p&gt;&#xA;&lt;p&gt;I already tried to build constraints, but it is difficult to me to find the one that ensures the feasibility / infeasibility of certain combinations.&lt;/p&gt;&#xA;" OwnerUserId="10750" LastEditorUserId="491" LastEditDate="2022-11-23T17:00:45.977" LastActivityDate="2023-02-02T01:22:36.423" Title="Binary variable constraint" Tags="|linear-programming|modeling|constraint-programming|binary-variable|logical-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9366" PostTypeId="2" ParentId="9365" CreationDate="2022-11-23T10:11:37.757" Score="6" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i=1}^n x_i \leq k-1 + (n-k+1)y&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2022-11-23T10:11:37.757" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9367" PostTypeId="1" AcceptedAnswerId="9462" CreationDate="2022-11-23T18:52:29.567" Score="2" ViewCount="430" Body="&lt;p&gt;&lt;em&gt;Pyomo&lt;/em&gt; has two solver managers to execute external solvers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;neos&lt;/code&gt; (remote execution)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;serial&lt;/code&gt; (local execution).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;pyomo help --solvers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;yields &lt;strong&gt;a list of solvers&lt;/strong&gt; available for each manager. It states&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;The following solver interfaces are available with YOUR CURRENT SYSTEM configuration: ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;That list&lt;/strong&gt; does NOT contain &lt;code&gt;Gurobi&lt;/code&gt; for the &lt;code&gt;neos&lt;/code&gt; manager, which I want to use for my task.&lt;/p&gt;&#xA;&lt;p&gt;Does it depend on my&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;current system configuration&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;or is it a feature not implemented ? What configuration would be necessary ?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;current system:&#xA;&#xA;Pyomo 6.4.2 (CPython 3.9.13 on Windows 10)&#xA;Python 3.9.13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="814" LastActivityDate="2022-12-02T13:05:53.317" Title="Pyomo supported solvers on NEOS" Tags="|optimization|python|gurobi|pyomo|neos|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9368" PostTypeId="2" ParentId="9347" CreationDate="2022-11-23T20:41:58.437" Score="3" Body="&lt;p&gt;Pre-define nB number of blocks where &lt;span class=&quot;math-container&quot;&gt;$n \le \lvert E \rvert$&lt;/span&gt; where E is set of events, e. Blocks could be set as time slots alternatively.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$B =\{b_1,b_2,..b_n \}$&lt;/span&gt;&#xA;Combinations already available: judge pre-assigned to events.&#xA;&lt;span class=&quot;math-container&quot;&gt;$JE =\{je_{1,1},je_{2,1},..je_{j,e} \}$&lt;/span&gt;&#xA;Venue, &lt;span class=&quot;math-container&quot;&gt;$V = \{v_1,v_2,..v_n \}$&lt;/span&gt;&#xA;Define more combinations of events, E with Venue, V. Instead of adding constraints latter better to define combinations of possible events with venues along with blocks.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$EBV =\{ebv_{1,1,1},ebv_{2,1,1},..ebv_{e,b,v} \}$&lt;/span&gt;&lt;br /&gt;&#xA;Also assuming every venue will have total time, &lt;span class=&quot;math-container&quot;&gt;$T_v$&lt;/span&gt; available&lt;br /&gt;&#xA;Define DVs:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{e,b,v}, \ y_{j,v} \ and \ z_{j,b} $&lt;/span&gt; as binary.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$bigM = \lvert E \rvert*\lvert V \rvert*\lvert B \rvert$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{b}\sum_{v} x_{e,b,v} = 1\quad \forall\ e \in E$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\quad$&lt;/span&gt;Event can be assigned to one block in one venue.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{e} x_{e,b,v}*D_e \le 60\quad  \forall\ b  \in B \quad \forall\ v \in V$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\quad$&lt;/span&gt; Total duration of blocks.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{b}(\sum_{e} x_{e,b,v}*D_e + \sum_{e} x_{e,b,v}*D_e\pmod 5) = T_v \quad \forall\ v  \in V$&lt;/span&gt;:  This ensures blocks are sequenced in a way that takes care of 5 minute marker.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$bigM*y_{j,v} \ge \sum_{e \in\ JE}\sum_{b \in B} X_{e,b,v} \quad \forall\ v \in V \quad\ \forall\ j \in J$&lt;/span&gt;: Counts number of venues a judge is assigned&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$bigM*z_{j,b} \ge \sum_{e \in\ EJ}\sum_{v \in JV} X_{e,b,v} \quad \forall b \in B \quad \forall J \in J$&lt;/span&gt;: Counts number of blocks a judge is assigned&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_e x_{e,b+1,v} \le bigM*\sum_{e} x_{e,b,v} \ \forall b \in B \quad \forall v \in V$&lt;/span&gt;: Condition for b+1 to be empty if b is empty at a venue, v&lt;/p&gt;&#xA;&lt;p&gt;totalDuration = &lt;span class=&quot;math-container&quot;&gt;$\sum_{e,b,v \in EBV} x_{e,b,v}$&lt;/span&gt;&lt;br /&gt;&#xA;venueChange = &lt;span class=&quot;math-container&quot;&gt;$\sum_{j}\sum_{v} y_{j,v}$&lt;/span&gt;&lt;br /&gt;&#xA;NblockJudge = &lt;span class=&quot;math-container&quot;&gt;$\sum_{j}\sum_{b} z_{j,b}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$Minimize \ \{venueChange+ NblockJudge + totalDuration\}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-11-23T21:12:13.337" LastActivityDate="2022-11-23T21:12:13.337" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9369" PostTypeId="2" ParentId="9327" CreationDate="2022-11-23T23:46:50.720" Score="2" Body="&lt;p&gt;Let's use &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; as the index set for sources and sinks (targets). We're assuming that each vehicle leaves a source, visits some nodes and lands at a sink, with each node (including sources and sinks) being visited by exactly one vehicle. I think the following model will work, with the caveat that some of the variable values will be nonsense and will need to be ignored.&lt;/p&gt;&#xA;&lt;p&gt;We add a superscript &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; to all the variables, indicating they belong to the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-th vehicle. We will denote the sources and sinks &lt;span class=&quot;math-container&quot;&gt;$s_k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_k$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt;). Without loss of generality, we can assume that vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; leaves &lt;span class=&quot;math-container&quot;&gt;$s_k$&lt;/span&gt; and arrives at &lt;span class=&quot;math-container&quot;&gt;$t_k,$&lt;/span&gt; since we can reindex the vehicles to match the source nodes and reindex the sink nodes to match the vehicles. Here is the modified model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{lrclll}&#xA;\min &amp;amp; \sum_{k\in K}\sum_{i\in N}\sum_{j\in N}x_{i,j}^{k}\cdot T_{i,j} &amp;amp;  &amp;amp;  &amp;amp;  &amp;amp; (1)\\&#xA;\mbox{s.t.} &amp;amp; \sum_{j\in N\backslash\left\{ s_{k}\right\} }x_{s_{h},j}^{k} &amp;amp; = &amp;amp; \begin{cases}&#xA;1 &amp;amp; h=k\\&#xA;0 &amp;amp; h\neq k&#xA;\end{cases} &amp;amp; \forall h,k\in K &amp;amp; (2)\\&#xA; &amp;amp; \sum_{j\in N\backslash\left\{ t_{k}\right\} }x_{j,t_{h}}^{k} &amp;amp; = &amp;amp; \begin{cases}&#xA;1 &amp;amp; h=k\\&#xA;0 &amp;amp; h\neq k&#xA;\end{cases} &amp;amp; \forall h,k\in K &amp;amp; (3)\\&#xA; &amp;amp; \sum_{k\in K}\sum_{j\in N\backslash\left\{ i\right\} }x_{i,j}^{k} &amp;amp; = &amp;amp; 1 &amp;amp; \forall i\in N\setminus\bigcup\{s_{k},t_{k}\} &amp;amp; (4)\\&#xA; &amp;amp; \sum_{i\in N\backslash\left\{ j\right\} }x_{i,j}^{k} &amp;amp; = &amp;amp; \sum_{i\in N\backslash\left\{ j\right\} }x_{j,i}^{k} &amp;amp; \forall j\in N\setminus\bigcup\{s_{k},t_{k}\},\forall k\in K &amp;amp; (5)\\&#xA;\\&#xA; &amp;amp; \tau_{i}^{k}+T_{i,j} &amp;amp; \leq &amp;amp; \tau_{j}^{k}+(1-x_{i,j}^{k})\cdot M_{\text{arrival_time}} &amp;amp; \forall(i,j)\in N\times N,\forall k\in K &amp;amp; (6)\\&#xA; &amp;amp; r_{i} &amp;amp; \leq &amp;amp; \tau_{i}^{k} &amp;amp; \forall i\in N,\forall k\in K &amp;amp; (7)\\&#xA;\\&#xA; &amp;amp; \ell_{s_{h}}^{k} &amp;amp; = &amp;amp; \begin{cases}&#xA;d_{s_{k}} &amp;amp; h=k\\&#xA;0 &amp;amp; h\neq k&#xA;\end{cases} &amp;amp; \forall j,k\in K &amp;amp; (8)\\&#xA; &amp;amp; \ell_{i}^{k}+d_{j} &amp;amp; \leq &amp;amp; \ell_{j}^{k}+(1-x_{i,j}^{k})\cdot M_{\text{load}} &amp;amp; \forall(i,j)\in N\times N,\forall k\in K &amp;amp; (9)\\&#xA; &amp;amp; \ell_{i}^{k}+d_{j}^{k} &amp;amp; \geq &amp;amp; \ell_{j}^{k}-(1-x_{i,j}^{k})\cdot M_{\text{load}} &amp;amp; \forall(i,j)\in N\times N,\forall k\in K &amp;amp; (10)\\&#xA;\\&#xA; &amp;amp; \tau_{i}^{k} &amp;amp; \geq &amp;amp; 0 &amp;amp; \forall i\in N,\forall k\in K &amp;amp; (11)\\&#xA; &amp;amp; \ell_{i}^{k} &amp;amp; \geq &amp;amp; 0 &amp;amp; \forall i\in N,\forall k\in K &amp;amp; (12)\\&#xA; &amp;amp; x_{i,j}^{k} &amp;amp; \in &amp;amp; \mathbb{B} &amp;amp; \forall(i,j)\in N\times N,\forall k\in K &amp;amp; (13)&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objective (1) minimizes the combined travel time of all vehicles. Constraints (2) and (3) say that vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; leaves source &lt;span class=&quot;math-container&quot;&gt;$s_k$&lt;/span&gt; once and never leaves any other source, and enters sink &lt;span class=&quot;math-container&quot;&gt;$t_k$&lt;/span&gt; once and never enters any other sink. Constraint (4) says that each intermediate node is entered exactly once, by a single vehicle. Constraint (5) says that each vehicle enters each intermediate node the same number of times that it exits that node. Combine that with (4), and you have one vehicle entering and exiting each intermediate node and the other vehicles bypassing the node.&lt;/p&gt;&#xA;&lt;p&gt;Constraint (6) says that if a vehicle visits two nodes consecutively, the arrival time at the second node is at least the arrival time at the first node plus the transit time. Constraint (7) says that each vehicle's arrival time at each node cannot be earlier than the node's time window opening. Here is where thinks get slightly funky. If a vehicle &lt;em&gt;does not&lt;/em&gt; visit a node, the solver is free to assign any &amp;quot;arrival time&amp;quot; greater than or equal to the window time for that vehicle at the node. So the solution will say that each vehicle has an arrival time at a given node, even though all but one of the vehicles bypassed that node. This should prove harmless. For the one vehicle that actually visits the node, the arrival time will respect transit times and time windows.&lt;/p&gt;&#xA;&lt;p&gt;Similar, we will have &amp;quot;loads&amp;quot; for each vehicle at each node, regardless of whether the vehicle really visits the node. Constraint (8) says that the load of any vehicle at any source node is the actual load there if the source node is the right one for the vehicle and 0 otherwise. Constraints (9) and (10) say that if a vehicle visits two nodes consecutively, the load changes correctly.&lt;/p&gt;&#xA;&lt;p&gt;If the phantom arrival times and loads are too disconcerting, another approach would be to add binary variables for each combination of vehicle and node, indicating whether that vehicle visits that node, and weave them into the formulation.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-11-24T03:14:38.057" LastActivityDate="2022-11-24T03:14:38.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9370" PostTypeId="2" ParentId="9364" CreationDate="2022-11-24T03:22:16.093" Score="4" Body="&lt;p&gt;Is &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; also part of the decision variables?&lt;/p&gt;&#xA;&lt;p&gt;Using the constraints &lt;span class=&quot;math-container&quot;&gt;$\log \mu = M \beta$&lt;/span&gt;, you can substitute out &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; in the objective, which yields an unconstrained problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \min_{\beta} \quad \sum_{i=1}^{N} \sum_{k=1}^{K} \left( y_{ik} - \exp(M_{k} \beta) \right)^2&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$M_{k}$&lt;/span&gt; denotes the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-th row of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This is indeed a non-convex function so, in that form, unless you have few variables, it's unlikely that you'll find a global minimizer efficiently. If you're OK with local minimizers, quasi-Newton methods like L-BFGS may give you better convergence than gradient descent.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;[Edit: &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; has full column rank, not row rank, so the approach below does not guarantee a feasible solution]&lt;/p&gt;&#xA;&lt;p&gt;That being said, you mention that &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; has full rank.&#xA;Is that full row rank, i.e., does the system &lt;span class=&quot;math-container&quot;&gt;$M \beta = \log \mu$&lt;/span&gt; always has a solution (for any choice of &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;)?&#xA;If that's the case, then you can solve&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \min_{\mu} \quad &amp;amp; \sum_{i=1}^{N} \sum_{k=1}^{K} \left( y_{ik} - \mu_{k} \right)^2\\&#xA;\text{s.t.} \quad &amp;amp; \mu &amp;gt; 0&#xA;\end{align}&lt;/span&gt;&#xA;then retrieve &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; by solving &lt;span class=&quot;math-container&quot;&gt;$M \beta = \log \mu$&lt;/span&gt;.&#xA;This yields a convex quadratic program, which can be solved very efficiently, followed by a linear system solve.&#xA;There is one catch: optimization solvers do not like &amp;quot;strictly positive&amp;quot; constraints. You can handle this by adding a small, positive lower bound &lt;span class=&quot;math-container&quot;&gt;$\mu \geq \epsilon$&lt;/span&gt;. If none of the lower bounds are active, you have a global minimizer. Otherwise, you have a (presumably good) solution.&lt;/p&gt;&#xA;&lt;p&gt;Note that solving the above quadratic problem with constraints &lt;span class=&quot;math-container&quot;&gt;$\mu \geq 0$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$\mu &amp;gt; 0$&lt;/span&gt; will give you a valid lower bound on the optimal objective value of the original problem. You can use this to gauge the quality of the solution you obtain when solving with &lt;span class=&quot;math-container&quot;&gt;$\mu \geq \epsilon$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;[Edit] when &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; does not have full row rank, one can solve the above quadratic program, obtain &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;, then project &lt;span class=&quot;math-container&quot;&gt;$\log \mu$&lt;/span&gt; onto the column space of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; and recover a feasible &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;. While this always yields a feasible solution, it has no guarantee on the quality of the resulting objective objective value.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="3598" LastEditDate="2022-11-25T15:11:08.747" LastActivityDate="2022-11-25T15:11:08.747" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9371" PostTypeId="1" CreationDate="2022-11-24T08:25:00.183" Score="3" ViewCount="123" Body="&lt;p&gt;There's a supply network design problem that I'm trying to solve, which is as follows:&lt;/p&gt;&#xA;&lt;p&gt;A certain amount of goods need to be transported from point A to B, and can have stoppages in between with a limit of lets say n. These stoppages can be used to consolidate the goods and send further. The task is to achieve the transportation with minimum cost for the source-destination pairs. These potential stoppages can be any node from the graph G =(V,E).&lt;/p&gt;&#xA;&lt;p&gt;My first attempt was to use to find the best path between source and destination pair individually, which I'm able to do, but that's not ideal as its not total cost minimization. I'm new to Pyomo and gurobi type modelling. Any advice how can i model the below data would be appreciated.&lt;/p&gt;&#xA;&lt;p&gt;For optimizing for each src-dest piar, I did this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;stop1 = m.addVars(stops_len, vtype=GRB.BINARY, name='select stop1')&#xA;stop2 = m.addVars(stops_len, vtype=GRB.BINARY, name='select stop2')&#xA;assign = m.addVars(prod_stop1_stop2, ub=2, vtype=GRB.CONTINUOUS, name='Assign')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Which let me choose the combnination of stop1 and stop2. But this is not enough as i minimizes indiv scr-dest paths, not global cost.&lt;/p&gt;&#xA;&lt;p&gt;What i wish to solve looks like below format of data:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Source&lt;/th&gt;&#xA;&lt;th&gt;Dest&lt;/th&gt;&#xA;&lt;th&gt;Potential stop1&lt;/th&gt;&#xA;&lt;th&gt;Potential stop2&lt;/th&gt;&#xA;&lt;th&gt;Goods&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;A&lt;/td&gt;&#xA;&lt;td&gt;D&lt;/td&gt;&#xA;&lt;td&gt;[]&lt;/td&gt;&#xA;&lt;td&gt;[]&lt;/td&gt;&#xA;&lt;td&gt;x1&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;B&lt;/td&gt;&#xA;&lt;td&gt;D&lt;/td&gt;&#xA;&lt;td&gt;[]&lt;/td&gt;&#xA;&lt;td&gt;[]&lt;/td&gt;&#xA;&lt;td&gt;x2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Potential stops1 and 2 are list of potential stops i find via some meta-heuristic.&#xA;So, my question is how can i model the data shown above in Pyomo or gurobi or any other tool? Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="10797" LastEditorUserId="10797" LastEditDate="2022-11-24T08:33:42.707" LastActivityDate="2022-11-24T18:41:09.367" Title="Transportation problem with consolidation within path" Tags="|optimization|network-flow|supply-chain|global-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9372" PostTypeId="2" ParentId="9371" CreationDate="2022-11-24T09:28:41.307" Score="3" Body="&lt;p&gt;If your demands are per source-destination pairs, then you are very likely dealing with a variation of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Multi-commodity_flow_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;multi-commodity flow problem&lt;/a&gt;, where each source-destination pair is a commodity.&lt;/p&gt;&#xA;&lt;p&gt;The variation is that the edges of your graph have variable capacities (the number of trucks on each edge). Or to be more precise, the capacities are defined in a step-wise fashion. Each time you add a new truck on the edge, the capacity increases (by the capacity of the truck), yielding an extra cost in the cost function.&lt;/p&gt;&#xA;&lt;p&gt;It is a good idea to define a pool of paths with potential stops for each source-destination pair. The idea is then to select the right combinations, in order to maximize consolidation, which is equivalent to minimizing the total number of trucks used.&lt;/p&gt;&#xA;&lt;p&gt;You can checkout &lt;a href=&quot;https://or.stackexchange.com/questions/6290/how-to-model-this-multi-commodity-flow-problem-with-a-twist&quot;&gt;this post&lt;/a&gt; for some insights on the problem (including the linear formulation which selects the bests paths).&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-11-24T13:46:55.553" LastActivityDate="2022-11-24T13:46:55.553" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9373" PostTypeId="1" CreationDate="2022-11-24T10:44:13.617" Score="0" ViewCount="145" Body="&lt;p&gt;I am facing difficulties to install &lt;code&gt;pyomo.solvers&lt;/code&gt; for anaconda&lt;/p&gt;&#xA;&lt;p&gt;I do need &lt;code&gt;glpk cbc ipopt&lt;/code&gt; for my anaconda&#xA;I tried the following but none of them worked&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;conda install -c conda-forge pyomo.solvers conda install -c&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;conda-forge/label/cf201901&amp;quot; pyomo.solvers conda install -c&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;conda-forge/label/cf202003&amp;quot; pyomo.solvers&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Homebrew&lt;/strong&gt; was also tested but not working (anaconda can't find the path)&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="491" LastEditDate="2022-11-29T21:57:02.440" LastActivityDate="2022-11-29T21:57:02.440" Title="Pyomo.solvers on anaconda mac Ventura 13.0.1 (22A400)" Tags="|solver|pyomo|cbc|glpk|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9374" PostTypeId="2" ParentId="8928" CreationDate="2022-11-24T13:53:06.197" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rJ3pK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rJ3pK.jpg&quot; alt=&quot;an intuitive transformation&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm also interested in this problem. I think the transformation between the dual solution and the primal solution must be related to KKT conditions, so I give my intuitive solution.&lt;/p&gt;&#xA;" OwnerUserId="10799" LastActivityDate="2022-11-24T13:53:06.197" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9375" PostTypeId="1" AcceptedAnswerId="9377" CreationDate="2022-11-24T16:00:36.923" Score="2" ViewCount="73" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is a set &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is a set &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; are from the same set such that &lt;span class=&quot;math-container&quot;&gt;$j\neq k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; is a parameter.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{j}$&lt;/span&gt; are binary variables.&lt;/p&gt;&#xA;&lt;p&gt;How to model: If&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c_{ij}\cdot y_{j} \ge c_{ik}\cdot y_{k}, \forall i,j,k,j\neq k$$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$$x_{ij} \ge x_{ik}, \forall i,j,k,j\neq k$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user5245" LastEditorDisplayName="user5245" LastEditDate="2023-03-31T05:18:13.933" LastActivityDate="2023-03-31T05:18:13.933" Title="How to model this?" Tags="|optimization|linear-programming|integer-programming|binary-variable|logical-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9376" PostTypeId="2" ParentId="9371" CreationDate="2022-11-24T16:46:48.093" Score="1" Body="&lt;p&gt;I see it more like a variation of Travelling salesman Problem (TSP) with a limit to intervening/transhipment nodes. Gurobi has a solution to that &lt;a href=&quot;https://www.gurobi.com/jupyter_models/traveling-salesman/.&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The formulation goes like this:&#xA;A,B are src-dest pairs and nodes be &lt;span class=&quot;math-container&quot;&gt;$V=\{n_1,n_2,...n_m\}$&lt;/span&gt;.&lt;br /&gt;&#xA;Define &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; be binary with &lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt; as indices for intervening nodes from V and &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; be cost/selection of shipment(edge) from nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;br /&gt;&#xA;Define M (or bigM) = large integral number, say number NxN where N is max number of transshipment nodes selected.&lt;/p&gt;&#xA;&lt;p&gt;Assignment (if bi-directional):&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{ij} = x_{ji} \ \forall (i,j) \in\ V\times V$&lt;/span&gt;: Ensures arc is selected either way.&lt;/p&gt;&#xA;&lt;p&gt;Constraints:&lt;br /&gt;&#xA;C1 = &lt;span class=&quot;math-container&quot;&gt;$\sum_i y_i \le N$&lt;/span&gt;:  Max no. of transshipment nodes selected&lt;br /&gt;&#xA;C2 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in\ V} x_{i,j} \le M*y_i \ \forall i \in\ V, i \neq j$&lt;/span&gt;: Edges/arcs selected for a node only when node is in solution.&lt;br /&gt;&#xA;C2_1= &lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in\ V} x_{i,j} \ge y_i \ \forall i \in\ V, j \neq i$&lt;/span&gt;: Ensure if node is selected at least 1 associated edge is selected.&lt;br /&gt;&#xA;C3 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in\ V} (x_{ij} - x_{ji}) = 0 \quad \forall i \in\ V, j \neq i$&lt;/span&gt;:  All nodes selected are transshipment nodes&lt;br /&gt;&#xA;C4 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j \in\ V} x_{ij} \le \sum_{i\in\ V} y_i - 1$&lt;/span&gt;:  Ensure there's no subtour with transhippment nodes but you may have a look at Gurobi model.&lt;br /&gt;&#xA;C5 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in\ V} x_{A,i} = 1$&lt;/span&gt;: Ensure A is connected to one of the nodes.&lt;br /&gt;&#xA;C6 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in\ V} x_{i,B} = 1$&lt;/span&gt;: Ensure B is connected to one of the nodes.&lt;br /&gt;&#xA;C7 = &lt;span class=&quot;math-container&quot;&gt;$x_{A,i} + x_{i,B} \le 1 \ \forall i \in\ V$&lt;/span&gt;: (Optional) Ensure it doesn't end up choosing just one transshipment node. Optional because need to run couple of times if this is happening.&lt;br /&gt;&#xA;C8 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in\ V} y_i \ge 2$&lt;/span&gt;: (Optional), this makes Constr C7 redundant with just 1 constraint.&lt;/p&gt;&#xA;&lt;p&gt;Objective:&lt;br /&gt;&#xA;Cost = &lt;span class=&quot;math-container&quot;&gt;$\sum_i (cost_{A,i}*x_{A,i}+ cost_{i,B}*x_{i,B}) + \sum_{i,j \in\ V} cost_{i,j}*x_{i,j}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-11-24T18:41:09.367" LastActivityDate="2022-11-24T18:41:09.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9377" PostTypeId="2" ParentId="9375" CreationDate="2022-11-24T16:53:35.173" Score="1" Body="&lt;p&gt;I suspect your quantifiers are misplaced and you instead want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\bigwedge_{i,j,k,j\neq k} \left(c_{ij} y_j \ge c_{ik} y_k \implies x_{ij} \ge x_{ik}\right)$$&lt;/span&gt;&#xA;Equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\bigwedge_{i,j,k,j\neq k} \left(x_{ij} &amp;lt; x_{ik} \implies c_{ij} y_j &amp;lt; c_{ik} y_k \right)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\bigwedge_{i,j,k,j\neq k} \left(\lnot x_{ij} \land x_{ik} \implies c_{ij} y_j &amp;lt; c_{ik} y_k \right)$$&lt;/span&gt;&#xA;Introduce constants &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_{ijk} = \max(c_{ij},0) -\min(c_{ik},0) + \epsilon$&lt;/span&gt; and binary variable &lt;span class=&quot;math-container&quot;&gt;$z_{ijk}$&lt;/span&gt;, and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(1 - x_{ij}) + x_{ik} - 1 &amp;amp;\le z_{ijk} \tag1\label1 \\&#xA;c_{ij} y_j - c_{ik} y_k + \epsilon &amp;amp;\le M_{ijk}(1 - z_{ijk}) \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$\lnot x_{ij} \land x_{ik} \implies z_{ijk}$&lt;/span&gt;.&#xA;Constraint \eqref{2} enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{ijk} \implies c_{ij} y_j + \epsilon \le c_{ik} y_k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is integer-valued, you can take &lt;span class=&quot;math-container&quot;&gt;$\epsilon=1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-11-24T16:53:35.173" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9378" PostTypeId="2" ParentId="9375" CreationDate="2022-11-24T16:53:59.950" Score="1" Body="&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is binary, &lt;span class=&quot;math-container&quot;&gt;$c_{ij}\cdot y_j - c_{ik}\cdot y_k \in S_{ijk} = \lbrace0,-c_{ik},c_{ij},c_{ij}-c_{ik}\rbrace.$&lt;/span&gt; For each combination of subscripts let &lt;span class=&quot;math-container&quot;&gt;$P_{ijk}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N_{ijk}$&lt;/span&gt; be respectively the largest nonnegative value and the largest strictly negative value in &lt;span class=&quot;math-container&quot;&gt;$S_{ijk}.$&lt;/span&gt; (For now we will assume that at least one set element is negative.) Now consider the constraint &lt;span class=&quot;math-container&quot;&gt;$$c_{ij}\cdot y_j - c_{ik}\cdot y_k \le P_{ijk} + (P_{ijk}-N_{ijk})(x_{ij}-x_{ik}).$$&lt;/span&gt; Note that &lt;span class=&quot;math-container&quot;&gt;$N_{ijk}&amp;lt;0\implies P_{ijk}-N_{ijk} &amp;gt; 0.$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$x_{ij} - x_{ik} \ge 0,$&lt;/span&gt; the constraint puts no limits on &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_k.$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$x_{ij}-x_{ik}=-1,$&lt;/span&gt; however, you have &lt;span class=&quot;math-container&quot;&gt;$c_{ij}\cdot y_j - c_{ik}\cdot y_k \le N_{ijk} &amp;lt; 0.$&lt;/span&gt; So we have enforced the contrapositive of your constraint.&lt;/p&gt;&#xA;&lt;p&gt;If all elements of &lt;span class=&quot;math-container&quot;&gt;$S_{ijk}$&lt;/span&gt; are nonnegative, your antecedent is automatically true, so you can just add &lt;span class=&quot;math-container&quot;&gt;$x_{ij}\ge x_{ik}$&lt;/span&gt; as a constraint.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-24T16:53:59.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9379" PostTypeId="1" AcceptedAnswerId="9380" CreationDate="2022-11-24T19:16:16.097" Score="0" ViewCount="84" Body="&lt;p&gt;I would appreciate any help to solve the following task:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_i=1$&lt;/span&gt; for at least &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; of the possible indices &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,\cdots,n\}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; are parameters, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a binary variable vector with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; elements, and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a binary variable.&lt;/p&gt;&#xA;" OwnerUserId="10750" LastEditorUserId="2556" LastEditDate="2022-11-25T07:38:32.147" LastActivityDate="2022-11-25T07:38:32.147" Title="Conditional constraint for binary variables" Tags="|linear-programming|modeling|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9380" PostTypeId="2" ParentId="9379" CreationDate="2022-11-24T19:19:46.063" Score="3" Body="&lt;p&gt;You want to enforce &lt;span class=&quot;math-container&quot;&gt;$y=1 \implies \sum_i x_i \ge k$&lt;/span&gt;.  You can do so by imposing linear big-M constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$k - \sum_i x_i \le (k - 0) (1 - y),$$&lt;/span&gt;&#xA;which simplifies to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i x_i \ge k y.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-11-24T19:19:46.063" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9381" PostTypeId="1" AcceptedAnswerId="9382" CreationDate="2022-11-24T19:56:59.230" Score="2" ViewCount="183" Body="&lt;p&gt;I am trying to solve the following task:&#xA;If &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$z=0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My approach:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$z=0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x+y \le 2 + Mz \implies x+y \le 2+2z \quad$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$M = 2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x+y=1 \\&#xA;\implies &#xA;x+y \le 1, \quad x+y \ge 1 - M(1-z) \\&#xA;\implies x+y \ge z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$M = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I already tried to add the constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$y-x \ge 0$&lt;/span&gt; to ensure that combination &lt;span class=&quot;math-container&quot;&gt;$x=1, y=0, z=1$&lt;/span&gt; should be satisfied and combination &lt;span class=&quot;math-container&quot;&gt;$x=1, y=0, z=1$&lt;/span&gt; should be not satisfied.&lt;/p&gt;&#xA;&lt;p&gt;But then the combination &lt;span class=&quot;math-container&quot;&gt;$x=1, y=0, z=0$&lt;/span&gt; isn’t satisfied, although it should be.&lt;/p&gt;&#xA;&lt;p&gt;In 1 combination the sum of &lt;span class=&quot;math-container&quot;&gt;$x+y = 2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would be grateful for any hints regarding the task or showing where my approach is wrong.&lt;/p&gt;&#xA;" OwnerUserId="10750" LastEditorUserId="491" LastEditDate="2023-04-02T14:03:07.033" LastActivityDate="2023-04-02T14:03:07.033" Title="Binary variable constraint for condition" Tags="|linear-programming|modeling|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9382" PostTypeId="2" ParentId="9381" CreationDate="2022-11-24T20:10:12.240" Score="6" Body="&lt;p&gt;Via conjunctive normal form,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(x \lor \lnot y) \implies \lnot z \\&#xA;\lnot (x \lor \lnot y) \lor \lnot z \\&#xA;(\lnot x \land y) \lor \lnot z \\&#xA;(\lnot x \lor \lnot z) \land (y \lor \lnot z) \\&#xA;((1 - x) + (1 - z) \ge 1) \land (y + (1 - z) \ge 1) \\&#xA;(x + z \le 1) \land (y \ge z)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-11-24T20:10:12.240" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9383" PostTypeId="1" AcceptedAnswerId="9406" CreationDate="2022-11-24T21:48:29.900" Score="3" ViewCount="145" Body="&lt;p&gt;In the question:&#xA;&lt;a href=&quot;https://or.stackexchange.com/questions/7376/partial-lagrangian-dual-in-lp&quot;&gt;&amp;quot;Partial&amp;quot; Lagrangian Dual in LP&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is argued that considering a partial Lagrangian &lt;span class=&quot;math-container&quot;&gt;$L_{partial}$&lt;/span&gt;, where we Dualize only some of the constraints, results in a tighter relaxation. Therefore optimizing w.r.t. the dual variables in the partial relaxation should result in a &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; duality gap.&lt;/p&gt;&#xA;&lt;p&gt;If there is 0 duality gap, for the optimal lagrange multiplier &lt;span class=&quot;math-container&quot;&gt;$\lambda^\star$&lt;/span&gt;, by optimizing &lt;span class=&quot;math-container&quot;&gt;$\max_{x\in D} L_{partial}(x,\lambda^\star)$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; corresponding to the region that is not dualized), one would expect to find the optimal primal solution &lt;span class=&quot;math-container&quot;&gt;$x^\star$&lt;/span&gt; (which is true in standard duality with 0 duality gap).&lt;/p&gt;&#xA;&lt;p&gt;However, that leads to the confusing following argument: Dualizing only the capacity constraints in the max flow problem, results in a problem which is the uncapacited max-flow problem (for given multipliers &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;). Then by finding &lt;span class=&quot;math-container&quot;&gt;$\lambda^\star$&lt;/span&gt;, one can solve the max-flow problem by solving a shortest-path problem. Of course this doesn't make a lot of sense, since the max-flow solution would typically not be a single-path. Therefore there should be some error in the above reasoning.&lt;/p&gt;&#xA;" OwnerUserId="10811" LastEditorUserId="500" LastEditDate="2022-11-27T17:45:30.737" LastActivityDate="2022-11-27T17:45:30.737" Title="Partial Lagrangian in the Max-Flow problem" Tags="|optimization|network-flow|duality|lagrangian-relaxation|maxflow|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9384" PostTypeId="1" AcceptedAnswerId="9388" CreationDate="2022-11-24T22:41:07.900" Score="3" ViewCount="73" Body="&lt;p&gt;I am new to the fields of operations research. I have a Binary IP model for solving a scheduling problem and I am seeking to find information whether I can somehow transform it to a problem that can be solved using local search techniques. Is it possible? If yes, can you point me to some further materials on the topic?&lt;/p&gt;&#xA;&lt;p&gt;I am aware the branch and bound technique builds a graph for the solution space. However, solving the problem does not scale particularly well due to the symmetry in scheduling problems and I wanted to explore an alternative technique such as local search. I am also happy to hear alternative suggestions.&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="10707" LastEditDate="2022-11-24T22:49:43.153" LastActivityDate="2022-11-25T04:00:32.047" Title="Can we turn a Binary IP model into a problem solvable using Local search?" Tags="|optimization|mixed-integer-programming|integer-programming|reference-request|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9385" PostTypeId="1" CreationDate="2022-11-25T00:48:12.400" Score="2" ViewCount="240" Body="&lt;p&gt;Hi I have a problem related to the vehicle routing problem, where I want to implement the subtour constraints &lt;span class=&quot;math-container&quot;&gt;$\sum_{(i,j)\in S} x_{ij} \leq \lvert S \rvert - r(S), \: \forall S \subseteq N, S &amp;gt; 2$&lt;/span&gt; for the set of costumers &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r(S)$&lt;/span&gt; is the number of vehicles needed to serve the set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My problem is to create all the &lt;span class=&quot;math-container&quot;&gt;$S \subseteq N$&lt;/span&gt; in python, I think I run out of memory (8gb) when creating the list of all sets &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. So far I have tried to use the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;powerset = list(itertools.chain.from_iterable(itertools.combinations(N, r) for r in range(2, len(N)+1)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is this just a general problem with the size of the sets &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; or am I missing something?&lt;/p&gt;&#xA;" OwnerUserId="10812" LastEditorUserId="500" LastEditDate="2022-11-25T14:59:07.027" LastActivityDate="2022-11-26T17:47:48.007" Title="Implementing subtour constraints to a VRP in python" Tags="|python|combinatorial-optimization|gurobi|vehicle-routing|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9386" PostTypeId="1" AcceptedAnswerId="9387" CreationDate="2022-11-25T01:18:40.443" Score="1" ViewCount="69" Body="&lt;p&gt;I'm working on a set of interconnected problems and I'm not sure how I can solve across the connection. First, a set of variables, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, is solved using the following:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x}f(x)$$&lt;/span&gt;&#xA;Subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w^Tx \geq d$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assuming that the objective is finite, the solution is then input to a second problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{w,d}g(x)$$&lt;/span&gt;&#xA;Subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w \geq 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$d \geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In other words &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is selected solely to maximize &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;, essentially in a completely separate process, but the choice of &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; affect what &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is selected which affects the final minimization problem. The overall objective is the minimization problem.&lt;/p&gt;&#xA;&lt;p&gt;It doesn't seem there's a way to combine these problems. I'm considering an alternating solution where &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is maximized for fixed &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; is evaluated. The knowledge of &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; informs how I update &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;, however it's not clear to me how to update &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; as I can't just differentiate a function with respect to &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;. Is this possible at all?&lt;/p&gt;&#xA;" OwnerUserId="10751" LastEditorUserId="500" LastEditDate="2022-11-25T02:37:33.953" LastActivityDate="2022-11-25T02:37:33.953" Title="Connected optimization problems" Tags="|bilevel-optimization|multi-stage|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9387" PostTypeId="2" ParentId="9386" CreationDate="2022-11-25T02:14:15.470" Score="1" Body="&lt;p&gt;If I understand the OP correctly, this is an example of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Bilevel_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;bi-level optimization&lt;/a&gt; problem.&lt;/p&gt;&#xA;&lt;p&gt;It can be formulated as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \min_{w, d} \quad &amp;amp; g(x)\\&#xA;    \text{s.t.} \quad &amp;amp; w \geq 0\\&#xA;    &amp;amp; d \geq 0\\&#xA;    &amp;amp; \begin{array}{rl}&#xA;        \displaystyle x \in \arg \max_{x} &amp;amp; f(x) \\&#xA;        \text{s.t.} &amp;amp; w^{T}x \geq d&#xA;    \end{array}&#xA;\end{align}&lt;/span&gt;&#xA;where the outer minimization is referred to as the \emph{upper-level} (or leader) and the inner maximization as the \emph{lower-level} (or follower) problem.&#xA;Note that, when solving the lower level problem, &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; are fixed.&lt;/p&gt;&#xA;&lt;p&gt;In other words: the leader chooses &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; so as to minimize &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is chosen by the follower so as to maximize &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; given &lt;span class=&quot;math-container&quot;&gt;$w, d$&lt;/span&gt; chosen by the leader.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2022-11-25T02:14:15.470" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9388" PostTypeId="2" ParentId="9384" CreationDate="2022-11-25T04:00:32.047" Score="3" Body="&lt;p&gt;Constraint programming is often a good way to solve scheduling problems. You might want to look into that.&lt;/p&gt;&#xA;&lt;p&gt;Beyond that, any advice on heuristics, local search etc. may be contingent on the specific nature of the problem. For some job shop problems, I have had good luck using genetic algorithms with a permutation-type chromosome. Given &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; jobs to be scheduled on one machine, each chromosome would be a permutation of &lt;span class=&quot;math-container&quot;&gt;$1,\dots, n.$&lt;/span&gt; Given &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; jobs to be assigned to &lt;span class=&quot;math-container&quot;&gt;$m &amp;lt; n$&lt;/span&gt; machines (multiple jobs per machine, one machine per job) I've used a variation on the permutation chromosome. I can't say, though, that GAs are a good choice for every type of scheduling problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-25T04:00:32.047" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9389" PostTypeId="1" AcceptedAnswerId="9393" CreationDate="2022-11-25T10:54:00.037" Score="6" ViewCount="845" Body="&lt;p&gt;I have to maximize the function &lt;span class=&quot;math-container&quot;&gt;$f= \sum_{i=1}^na_ix_i $&lt;/span&gt; subject to the constraints &lt;span class=&quot;math-container&quot;&gt;$g = \sum_{i=1}^n x_i = 0 $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$-1\leq x_i \leq 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_i&amp;gt;0$&lt;/span&gt;. &lt;a href=&quot;https://math.libretexts.org/Bookshelves/Calculus/Book%3A_Vector_Calculus_(Corral)/02%3A_Functions_of_Several_Variables/2.07%3A_Constrained_Optimization_-_Lagrange_Multipliers&quot; rel=&quot;noreferrer&quot;&gt;Lagrange multiplier method&lt;/a&gt; doesn't work because &lt;span class=&quot;math-container&quot;&gt;$\nabla f=\lambda\nabla g$&lt;/span&gt; only yields &lt;span class=&quot;math-container&quot;&gt;$\lambda=a_i$&lt;/span&gt; which is incorrect. Any help is appreciated. Also, I am an engineer not a mathematician.&lt;/p&gt;&#xA;" OwnerUserId="10814" LastActivityDate="2023-11-13T06:25:29.937" Title="Constrained optimization of a sum" Tags="|optimization|constraint|constrained-optimization|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9390" PostTypeId="1" AcceptedAnswerId="9392" CreationDate="2022-11-25T13:33:45.917" Score="2" ViewCount="115" Body="&lt;p&gt;I have one variable called OS which is the number of orders.&#xA;And I have a variable &lt;code&gt;nt&lt;/code&gt; which is the number of trucks.&lt;/p&gt;&#xA;&lt;p&gt;And 20 orders can fit into one truck.&#xA;I am not sure how to set this up this constraint.&#xA;I want to return the number of truck I would need&#xA;For example&#xA;20 order=2 trucks&#xA;25 orders=3 trucks&lt;/p&gt;&#xA;&lt;p&gt;I did&#xA;&lt;code&gt;os[i]==10*nt[i]&lt;/code&gt;&#xA;where &lt;code&gt;nt&lt;/code&gt; is the number of trucks but this does not seem to work.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(0,364):&#xA;    constraintTruckload=os[i]==(nt[i]*10)&#xA;    k4.append(constraintTruckload)&#xA;for i in range(0,364):&#xA;   model+=k4[i]&#xA;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9483" LastEditorUserId="123" LastEditDate="2022-11-25T18:43:23.703" LastActivityDate="2022-11-25T18:43:23.703" Title="How to add batch constraint to an optimization problem" Tags="|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9391" PostTypeId="2" ParentId="9389" CreationDate="2022-11-25T13:37:09.170" Score="0" Body="&lt;p&gt;As an engineer if you intend to quickly solve it, you'd need a solver for it. Solvers like Lingo( academic but simple) with its own modeling language, GAMS: both solver and modeling, Gurobi: solver with API for python, c++, java, CPLEX: same as Gurobi, Xpress: solver package and so on. Or the &lt;a href=&quot;https://neos-server.org/neos/solvers/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;NEOS&lt;/a&gt; site hosts solvers that can do the task for free with some limits to capacity. There's a free library- scipy that has optimization package to solve multi variate optimization problems. It has API for python.&#xA;If you want to know how Lagrangian method can solve constraints optimization with soft and hard constraints, then this &lt;a href=&quot;https://machinelearningmastery.com/lagrange-multiplier-approach-with-inequality-constraints/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt; is helpful.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-11-25T13:46:52.197" LastActivityDate="2022-11-25T13:46:52.197" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9392" PostTypeId="2" ParentId="9390" CreationDate="2022-11-25T14:20:00.133" Score="4" Body="&lt;p&gt;Assuming you want at most &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; orders per truck, the constraint is &lt;span class=&quot;math-container&quot;&gt;$\text{os} \le 10 \text{nt}$&lt;/span&gt;.  You would need to declare &lt;span class=&quot;math-container&quot;&gt;$\text{nt}$&lt;/span&gt; (and presumably also &lt;span class=&quot;math-container&quot;&gt;$\text{os}$&lt;/span&gt;) as an integer variable. If there are no other constraints on the trucks, the minimum number of trucks would then be &lt;span class=&quot;math-container&quot;&gt;$\text{nt}=\lceil\text{os}/10\rceil$&lt;/span&gt;, but this is not a linear constraint.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-11-25T14:32:00.720" LastActivityDate="2022-11-25T14:32:00.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9393" PostTypeId="2" ParentId="9389" CreationDate="2022-11-25T14:55:22.383" Score="11" Body="&lt;p&gt;You also need to account for Lagrange multipliers for the bound constraints &lt;span class=&quot;math-container&quot;&gt;$-1\le x_i \le 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Given all &lt;span class=&quot;math-container&quot;&gt;$a_i&amp;gt;0$&lt;/span&gt;, the (linear programming) problem is to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_i a_i x_i$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i x_i &amp;amp;= 0 \\&#xA;-x_i &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for all $i$}\\&#xA;x_i &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for all $i$}&#xA;\end{align}&lt;/span&gt;&#xA;The dual linear programming problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_i (\alpha_i + \beta_i)$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\lambda - \alpha_i + \beta_i &amp;amp;= a_i &amp;amp;&amp;amp;\text{for all $i$} \\&#xA;\alpha_i &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $i$} \\&#xA;\beta_i &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $i$}&#xA;\end{align}&lt;/span&gt;&#xA;You can interpret this as finding &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; to minimize the sum of (absolute value) distances from the various &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;, and the median is known to achieve that. Then &lt;span class=&quot;math-container&quot;&gt;$\alpha_i =\max(\lambda-a_i,0)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta_i = \max(a_i-\lambda, 0)$&lt;/span&gt;. Now complementary slackness implies that &lt;span class=&quot;math-container&quot;&gt;$x_i=-1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$\alpha_i&amp;gt;0$&lt;/span&gt; (below the median) and &lt;span class=&quot;math-container&quot;&gt;$x_i=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$\beta_i&amp;gt;0$&lt;/span&gt; (above the median).  Otherwise, &lt;span class=&quot;math-container&quot;&gt;$\lambda=a_i$&lt;/span&gt;, and you can take &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;By the way, this result does not depend on the assumption that all &lt;span class=&quot;math-container&quot;&gt;$a_i&amp;gt;0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-11-25T15:50:52.183" LastActivityDate="2022-11-25T15:50:52.183" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9394" PostTypeId="1" CreationDate="2022-11-25T18:07:39.503" Score="0" ViewCount="206" Body="&lt;p&gt;How to convert this one to a linear program:&lt;/p&gt;&#xA;&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$B=1$&lt;/span&gt;; otherwise, &lt;span class=&quot;math-container&quot;&gt;$B=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If I use the Big M method: &lt;span class=&quot;math-container&quot;&gt;\begin{align}x&amp;amp;\ge1-M(1-B)\\x&amp;amp;\le1+M(1-B)\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A) with &lt;span class=&quot;math-container&quot;&gt;$B=1$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;\begin{align}x&amp;amp;\ge1\\x&amp;amp;\le1\end{align}&lt;/span&gt;&#xA;That is corresponding to &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;B) with &lt;span class=&quot;math-container&quot;&gt;$B=0$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;\begin{align}x&amp;amp;\ge1-M\\x&amp;amp;\le1+M\end{align}&lt;/span&gt;&#xA;That is corresponding to any value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; even &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt;. How do I exclude &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$B=0$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10454" LastEditorUserId="123" LastEditDate="2022-11-25T18:45:51.037" LastActivityDate="2022-11-26T03:39:49.093" Title="How to formulate &quot;If statement with equality constraints&quot; using big m?" Tags="|linear-programming|big-m|" AnswerCount="2" CommentCount="4" ClosedDate="2022-11-26T05:36:52.493" ContentLicense="CC BY-SA 4.0" />
  <row Id="9395" PostTypeId="2" ParentId="9394" CreationDate="2022-11-25T19:10:52.360" Score="-1" Body="&lt;p&gt;if x and B both are binary then x+B&amp;gt;=2 should work. this contriant is satisfactory only under one condition that is both x and B should be 1. for every other condition the constraint will be voilated.&lt;/p&gt;&#xA;" OwnerUserId="6123" LastActivityDate="2022-11-25T19:10:52.360" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9396" PostTypeId="2" ParentId="9394" CreationDate="2022-11-25T20:44:32.423" Score="0" Body="&lt;p&gt;I think the two constraints put in there, lead to the same thing, just change the sign of one of those and then add the two constraints, it will lead to &lt;span class=&quot;math-container&quot;&gt;$M \ge 0$&lt;/span&gt;.&#xA;Assuming &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is continuous, then you need:&lt;br /&gt;&#xA;C1 = &lt;span class=&quot;math-container&quot;&gt;$B \ E \ [0,1] \ and \ z \le 0$&lt;/span&gt;:  B is binary.&lt;br /&gt;&#xA;Choose U such that it's the upper bound for x&lt;br /&gt;&#xA;C2 = &lt;span class=&quot;math-container&quot;&gt;$Uz \le x$&lt;/span&gt;:   z is &amp;lt;0 for x=99, z will remain &amp;lt;0 for x=-99 as U is larger than x and when x=1, z=0&lt;br /&gt;&#xA;C3 = &lt;span class=&quot;math-container&quot;&gt;$Uz+L(z-1) \ge (1-x)*(L-U)$&lt;/span&gt;: if x=1 z is forced to 0 due to C2, if x=99, z remains &amp;lt;0, if x=-99, z is again &amp;lt;0&lt;br /&gt;&#xA;C4 = &lt;span class=&quot;math-container&quot;&gt;$B \ge z+1$&lt;/span&gt;:   z &amp;lt;0, B can be 0 but when z=0, B =1&lt;br /&gt;&#xA;and&#xA;Choose &lt;span class=&quot;math-container&quot;&gt;$M \gt \lvert {x} \rvert+1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is lower bound of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and should be &amp;lt;0 and &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; is upper bound of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &amp;gt;0&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-11-26T03:39:49.093" LastActivityDate="2022-11-26T03:39:49.093" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9397" PostTypeId="1" CreationDate="2022-11-25T20:50:49.193" Score="3" ViewCount="148" Body="&lt;p&gt;I have a big LP program with around &lt;span class=&quot;math-container&quot;&gt;$91,000$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$2,900,000$&lt;/span&gt; constraints. They are all binary variables, but I want to try also relaxing the problem putting &lt;span class=&quot;math-container&quot;&gt;$0 \le x \le 1$&lt;/span&gt; bounds. I am not very knowledgeable on the subject because I took only one university course on operations research about 30 years ago and didn't use it afterwards, so I forgot nearly everything.&lt;/p&gt;&#xA;&lt;p&gt;The problem is aimed at trying to prove the &lt;a href=&quot;https://en.wikipedia.org/wiki/Union-closed_sets_conjecture&quot; rel=&quot;nofollow noreferrer&quot;&gt;union closed sets conjecture&lt;/a&gt; for a given fixed number of sets. I have formulated it implementing &lt;a href=&quot;https://or.stackexchange.com/a/9350/9517&quot;&gt;this answer&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/a/9344/9517&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The formulation is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max \sum_{i=1}^n a_{1,i} \tag1\label1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n a_{k,i} \ge \lfloor n/2 \rfloor + 1, \space 2 \le k \le q \tag2\label2$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{k,\ell} \le a_{k,i} + 1 - z_{i,j,\ell}, \space 1 \le k \le q, 1 \le i \lt j \le n, 1 \le \ell \le n \tag3\label3$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{k,\ell} \le a_{k,j} + 1 - z_{i,j, \ell}, \space 1 \le k \le q, 1 \le i \lt j \le n, 1 \le \ell \le n \tag4\label4$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{k,\ell} \ge a_{k,i} + a_{k,j} + z_{i,j,\ell} - 2, \space 1 \le k \le q, 1 \le i \lt j \le n, 1 \le \ell \le n \tag5\label5$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{\ell=1}^n z_{i,j,\ell} = 1, \space 1 \le i \lt j \le n \tag6\label6$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{k,i,j} \le a_{k,i} + a_{k,j} \le 2-x_{k,i,j}, \space 1 \le k \le q, 1 \le i \lt j \le n \tag7\label7$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k=1}^q x_{k,i,j} \ge 1, \space 1 \le k \le q, 1 \le i \lt j \le n \tag8\label8$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with all binary values. Some of the &lt;span class=&quot;math-container&quot;&gt;$\eqref{3}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\eqref{4}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\eqref{5}$&lt;/span&gt;, can be eliminated or simplified when &lt;span class=&quot;math-container&quot;&gt;$\ell = i$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\ell = j$&lt;/span&gt;. There are many alternatives for &lt;span class=&quot;math-container&quot;&gt;$\eqref{1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\eqref{2}$&lt;/span&gt;, for example we can order the occurrences of elements from element &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; and then again search the maximum occurrence of element &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This is actually the dual formulation of the union closed sets conjecture, because we are considering intersection-closed families of sets (the intersection of any two sets must still belong to the family), and if the conjecture is true there must exist at least one element in at most &lt;span class=&quot;math-container&quot;&gt;$\lfloor n/2 \rfloor$&lt;/span&gt; sets.&lt;/p&gt;&#xA;&lt;p&gt;The matrix with elements &lt;span class=&quot;math-container&quot;&gt;$a_{i,j}$&lt;/span&gt; represent the family of sets: a column is one set, while a row represents an element (well, there can be two or more identical rows, in which case we can think they represent a single element). There are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; columns (the given fixed number of sets) and &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; rows (the maximum number of elements).&lt;/p&gt;&#xA;&lt;p&gt;Therefore &lt;span class=&quot;math-container&quot;&gt;$\eqref{1}$&lt;/span&gt; checks the occurrences of an element (element 1) that we expect to be at most &lt;span class=&quot;math-container&quot;&gt;$\lfloor n/2 \rfloor$&lt;/span&gt;. Constraint &lt;span class=&quot;math-container&quot;&gt;$\eqref{2}$&lt;/span&gt; forces all the other elements to be in more than &lt;span class=&quot;math-container&quot;&gt;$\lfloor n/2 \rfloor$&lt;/span&gt; sets. &lt;span class=&quot;math-container&quot;&gt;$\eqref{3}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\eqref{4}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\eqref{5}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\eqref{6}$&lt;/span&gt; require that the family be intersection closed (the intersection of any two sets [columns] must still belong to the family [matrix]) and finally &lt;span class=&quot;math-container&quot;&gt;$\eqref{7}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\eqref{8}$&lt;/span&gt; forces all sets to be different. Note that we can also use these last two constraints, needed by the problem, that enforce all sets to be different, for the purpose of replacing &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$\eqref{6}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have written a smaller version of the program (&lt;span class=&quot;math-container&quot;&gt;$n=11$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$q=4$&lt;/span&gt;) with LP file format and submitted it successfully to the NEOS server. At the moment I am producing the LP files through a specific C program for my problem.&lt;/p&gt;&#xA;&lt;p&gt;However, the &amp;quot;big&amp;quot; case, with &lt;span class=&quot;math-container&quot;&gt;$n=53$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q=13$&lt;/span&gt;, has an LP file of size &lt;span class=&quot;math-container&quot;&gt;$130$&lt;/span&gt; MByte. NEOS server accepts a maximum of &lt;span class=&quot;math-container&quot;&gt;$16$&lt;/span&gt; MByte.&lt;/p&gt;&#xA;&lt;p&gt;The conjecture has been proven for &lt;span class=&quot;math-container&quot;&gt;$n \lt 53$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$n = 53$&lt;/span&gt; is the lowest number of sets for which a proof is missing, as of today. Note that there is a theorem that limits the maximum number of elements of a counterexample to &lt;span class=&quot;math-container&quot;&gt;$13$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$n = 53$&lt;/span&gt; (the minimal counterexample must have &lt;span class=&quot;math-container&quot;&gt;$n \ge 4q+1$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the number of sets and &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; the number of elements).&lt;/p&gt;&#xA;&lt;p&gt;Any suggestion for a file format which is both concise in size and quick to learn?&#xA;Also, are &lt;span class=&quot;math-container&quot;&gt;$91,000$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$2,900,000$&lt;/span&gt; constraints too much for the NEOS server?&lt;/p&gt;&#xA;&lt;p&gt;I have run cases &lt;span class=&quot;math-container&quot;&gt;$n=23, q=6$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n=29, q=7$&lt;/span&gt; at NEOS with Gurobi, but it timed out after 8 hours.&lt;/p&gt;&#xA;&lt;p&gt;Any other suggestion for attempting the &lt;span class=&quot;math-container&quot;&gt;$n=53$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q=13$&lt;/span&gt; case?&lt;/p&gt;&#xA;" OwnerUserId="9517" LastEditorUserId="9517" LastEditDate="2022-11-26T10:12:27.070" LastActivityDate="2022-11-26T10:12:27.070" Title="Big LP program to be submitted to NEOS Server (union-closed sets conjecture)" Tags="|linear-programming|online-resources|lp-format|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="9399" PostTypeId="2" ParentId="9397" CreationDate="2022-11-26T06:05:37.727" Score="-1" Body="&lt;p&gt;May be combine cons 3,4 &amp;amp; 5 into a single constraint &lt;span class=&quot;math-container&quot;&gt;$a_{k,l}+3z_{i,j,l}&amp;lt;=4$&lt;/span&gt; and&lt;br /&gt;&#xA;Similarly cons 7, 8 can be combined and &lt;span class=&quot;math-container&quot;&gt;$x_{k,i,j}$&lt;/span&gt; eliminated. Like cons (7) can be changed to &lt;span class=&quot;math-container&quot;&gt;$a_{k,i}+a_{k,j}&amp;lt;=1$&lt;/span&gt; and con(8) as &lt;span class=&quot;math-container&quot;&gt;$\sum_{l=1}^k a_{k,i}+a_{k,j}&amp;gt;=1$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-11-26T06:05:37.727" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9400" PostTypeId="2" ParentId="9385" CreationDate="2022-11-26T13:17:48.723" Score="3" Body="&lt;p&gt;As @RobPratt said, there are an exponential number of those constraints, so it is better to add them when they are violated. So, solve the problem without subtour constraints, then check if some subtour constraints are violated. If there are, add those constraints to the problem, solve again and repeat.&lt;/p&gt;&#xA;&lt;p&gt;To check if they are violated, networkx is a good tool. Something like this should allow you to detect subtours:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import networkx&#xA;&#xA;EPS = 1.e-6&#xA;&#xA;for k in range(n_vehicles):&#xA;    subtour_violated = False&#xA;    edges_to_add = []&#xA;    for i in range(n_stops):&#xA;        for j in range(n_stops):&#xA;            if x[i][j][k]&amp;gt;EPS: &#xA;                edges_to_add.append((i,j))&#xA;&#xA;    g = networkx.Graph()&#xA;    g.add_edges_from(edges_to_add)&#xA;    aux_components = list(networkx.connected_components(g))&#xA;&#xA;    if len(aux_components) != 1:&#xA;        subtour_violated = True&#xA;        # Add subtour constraints, ie the content of aux_components, to the model&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where &lt;em&gt;n_vehicles&lt;/em&gt; is the number of vehicles, &lt;em&gt;n_stops&lt;/em&gt; is the number of stops, &lt;em&gt;x&lt;/em&gt; id a dict of dict of dict which stores the value of &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;PS: I got part of the previous code from somewhere, some years ago, but I couldn't find it to add the reference. If someone know it, please share it.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastEditorUserId="10165" LastEditDate="2022-11-26T17:47:48.007" LastActivityDate="2022-11-26T17:47:48.007" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9401" PostTypeId="1" AcceptedAnswerId="9405" CreationDate="2022-11-26T15:27:22.310" Score="7" ViewCount="494" Body="&lt;p&gt;I wrote a profit maximization LP with inventory, component usage, production, and machine hours constraints. When I optimize the model, it solves as expected. When applied towards a business case, however, the end user will generally look to make a handful of production changes rather than the several hundred the model suggests at once. I would like to modify the LP so that when a handful of recommendations from the optimal solution are applied to the baseline (i.e. increase maximum production qty of 5 products), the model only makes changes to the decision variables required to solve feasibly (i.e. reduction in production of a low or negative margin product, reduction in production to free up machine hours, etc.), rather than solving everything as optimal and making hundreds of changes.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to incentivize the model to maintain baseline conditions and to only make the changes needed to solve feasibly?&lt;/p&gt;&#xA;&lt;p&gt;Here's the objective:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vPcbi.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vPcbi.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/srGOL.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/srGOL.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10747" LastActivityDate="2022-11-27T10:11:03.343" Title="Profit Maximization LP and Incentives Scenarios" Tags="|linear-programming|python|gurobi|nonlinear-programming|binary-variable|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9402" PostTypeId="2" ParentId="9401" CreationDate="2022-11-26T15:44:13.420" Score="5" Body="&lt;p&gt;This is indeed often an issue when dealing with an industrial/real-life problem.&lt;/p&gt;&#xA;&lt;p&gt;One way of handling this is as follows. First, create a baseline which reproduces the existing system. So when you solve your optimization problem, it is constrained so as to maintain baseline conditions. You can, for example, only define the variables with values equal to the existing baseline.&lt;/p&gt;&#xA;&lt;p&gt;Then, gradually, add new variables to allow the solver some diversification. You can control the amount of new variables that you put in the system, and this way, you can &amp;quot;keep close&amp;quot; to the baseline if you wish to.&lt;/p&gt;&#xA;&lt;p&gt;As an example, in a logistics problem, for your baseline, you only define existing flows. Then, you can gradually add non existing flows and see how the solver reacts, and how far off you end up from the baseline. You can iteratively constrain the model in order to identify some optimizations, while maintaining (constraining) some variables to their value in the baseline.&lt;/p&gt;&#xA;&lt;p&gt;Note that in this case, you are not trying to find the global optimal solution. You are looking for a local optimal solution, which is better than your baseline, and which satisfies your customer. This is an iterative process.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-11-27T10:11:03.343" LastActivityDate="2022-11-27T10:11:03.343" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9403" PostTypeId="2" ParentId="9401" CreationDate="2022-11-26T16:21:45.800" Score="2" Body="&lt;p&gt;Couple of ways to keep the model close to the baseline:&lt;br /&gt;&#xA;1&amp;gt; Define something like &lt;span class=&quot;math-container&quot;&gt;$d^+$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d^-$&lt;/span&gt; as deviations from the baseline objective and try to solve by minimizing the sum of deviations. You can put baseline objective as a constraint.&lt;br /&gt;&#xA;2&amp;gt; Sensitivity analysis will identify the slacks/surpluses which can imply certain changes need not be implemented while maintaining feasibility/optimality.&lt;br /&gt;&#xA;3&amp;gt; Constrained programming: No objective, just solves to feasibility.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-11-26T16:21:45.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9404" PostTypeId="2" ParentId="9357" CreationDate="2022-11-26T19:46:08.737" Score="1" Body="&lt;p&gt;So, after many hours of searching, i solved the problem..&#xA;It was the matrix itself&#xA;Basically for the third constraint to work, you have to have a matrix that have for a value in i and j, the same value on j and i.&lt;/p&gt;&#xA;" OwnerUserId="10784" LastActivityDate="2022-11-26T19:46:08.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9405" PostTypeId="2" ParentId="9401" CreationDate="2022-11-26T19:53:51.747" Score="5" Body="&lt;p&gt;One approach is to introduce binary variables. Let &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; be the variable determining production of item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{p}_i$&lt;/span&gt; the planned/baseline production volume. We also need known lower and upper bounds &lt;span class=&quot;math-container&quot;&gt;$L_i$&lt;/span&gt; (possibly 0) and &lt;span class=&quot;math-container&quot;&gt;$U_i$&lt;/span&gt; for the volume of item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Let binary variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; indicate whether we are deviating from baseline on item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; or not. Add constraints &lt;span class=&quot;math-container&quot;&gt;$$p_i \le \bar{p_i} + (U_i - \bar{p}_i)y_i$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$p_i \ge \bar{p_i} + (L_i - \bar{p}_i)y_i$$&lt;/span&gt;to define &lt;span class=&quot;math-container&quot;&gt;$y_i.$&lt;/span&gt; One option is to set a fixed limit for the number of items changed, adding the constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_i y_i \le C$$&lt;/span&gt; for some constant &lt;span class=&quot;math-container&quot;&gt;$C.$&lt;/span&gt; Another is to subtract &lt;span class=&quot;math-container&quot;&gt;$\alpha \sum_i y_i$&lt;/span&gt; from the objective function for some value &lt;span class=&quot;math-container&quot;&gt;$\alpha &amp;gt; 0.$&lt;/span&gt; If your solver supports lexicographically ordered multiple objectives, a third possibility is to maximize profit and secondarily minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_i y_i.$&lt;/span&gt; Note that the choice of &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is arbitrary and may require some experimentation to produce results that make the boss happy (although you might be able to get a hard limit &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; on changes from the Powers That Be).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-26T19:53:51.747" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9406" PostTypeId="2" ParentId="9383" CreationDate="2022-11-26T20:30:25.423" Score="2" Body="&lt;p&gt;The error comes in assuming that, given a zero duality gap, the solution to the relaxed LP (which I agree becomes a shortest path problem) would be the optimal flow solution.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; the set of all nonnegative flow vectors &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; that satisfy&#xA;the flow conservation constraints on the network, ignoring capacities,&#xA;let &lt;span class=&quot;math-container&quot;&gt;$c\in\mathbb{R}_{+}^{n}$&lt;/span&gt; be the vector of arc capacities, and&#xA;let &lt;span class=&quot;math-container&quot;&gt;$a'x$&lt;/span&gt; be the original objective function (any expression that&#xA;computes the total flow out of the source or into the sink). Note&#xA;that &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is a pointed cone, since &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; is a feasible flow and,&#xA;for any valid flow &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and scalar &lt;span class=&quot;math-container&quot;&gt;$t&amp;gt;0,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$t\cdot x$&lt;/span&gt; is also a valid&#xA;flow. The relaxed problem becomes&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{\lambda\ge0}\max_{x\in X}\left[a'x-\lambda'(x-c)\right]&#xA;$$&lt;/span&gt;&#xA;or equivalently&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{\lambda\ge0}\max_{x\in X}\left[(a-\lambda)'x+\lambda'c\right]&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is the vector of Lagrange multipliers for the capacity&#xA;limits.&lt;/p&gt;&#xA;&lt;p&gt;For fixed &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; one of two things happens. If a unit flow &lt;span class=&quot;math-container&quot;&gt;$x\in X$&lt;/span&gt;&#xA;on any path from source to sink satisfies &lt;span class=&quot;math-container&quot;&gt;$(a-\lambda)'x&amp;gt;0,$&lt;/span&gt; the&#xA;inner problem is unbounded, since we can scale &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; upward indefinitely.&#xA;On the other hand, if every unit flow from source to sink has &lt;span class=&quot;math-container&quot;&gt;$(a-\lambda)'x\le0,$&lt;/span&gt;&#xA;the optimal solution to the inner problem is &lt;span class=&quot;math-container&quot;&gt;$x=0,$&lt;/span&gt; resulting in&#xA;objective value &lt;span class=&quot;math-container&quot;&gt;$\lambda'c.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So Lagrangian relaxation will search, among just those &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;&#xA;for which no path has positive objective value, for the one that minimizes&#xA;&lt;span class=&quot;math-container&quot;&gt;$\lambda'c.$&lt;/span&gt; That will turn out to be the capacity portion of the optimal&#xA;solution to the dual of the original max flow LP. Using that &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$\lambda'c$&lt;/span&gt; is the objective value of the dual to the full LP (since&#xA;the dual multipliers of the flow balance constraints are multiplied&#xA;by 0 in the dual objective), meaning &lt;span class=&quot;math-container&quot;&gt;$\lambda'c$&lt;/span&gt; equals the maximum&#xA;flow. The optimal solution to the relaxed flow problem will be 0,&#xA;or at least &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; will be &lt;em&gt;an&lt;/em&gt; optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;So, bottom line, relaxation gives you the objective value (the maximum possible flow volume) but not the solution (the flow producing that result).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-11-26T20:30:25.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9407" PostTypeId="2" ParentId="9383" CreationDate="2022-11-26T20:32:29.183" Score="2" Body="&lt;p&gt;Unfortunately, there is NO guarantee to find the primal feasible solution in the context of Lagrangian relaxation, especially when it comes to solving integer programming.&lt;/p&gt;&#xA;&lt;p&gt;In order to get a feasible primal solution, at least as far as I know, you would need to repair the achieved solution (usually an infeasible one) in each iteration by using some manipulations. This is what the so-called Lagrangian heuristic. For more details please, see the following links. Also, you could find more useful topics either by searching in the community or by googling.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/q/5426/199&quot;&gt;Using LR-based method to solve mixed integer programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://cs.pwr.edu.pl/zielinski/lectures/om/relaks.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lagrangian relaxation and network optimization&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-11-26T20:32:29.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9408" PostTypeId="1" AcceptedAnswerId="9411" CreationDate="2022-11-28T02:49:08.513" Score="0" ViewCount="109" Body="&lt;p&gt;I have the following table&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Day State Orders&#xA;1     GA    20&#xA;1      FL   21&#xA;2      OH   22&#xA;3      FL    23&#xA;4      CA    25 &#xA;5      ID   22&#xA;6     IA    23&#xA;6     CA    22&#xA;7    NM     11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is where the day columns is one the 365 days. The state is one of the 50 states and orders is how much each customer ordered.&lt;/p&gt;&#xA;&lt;p&gt;I have 3 Fulfillment Center and 2 DC centers.&#xA;I want basically certain orders for example in Georgia to be fufilled by my FC 1 and ones in ALASKA to be fulfilled by the FC 2 and the ones New Mexico by the FC 3.&#xA;Certain states must be fulfilled by certain FC.&lt;/p&gt;&#xA;&lt;p&gt;If they cannot be fulfilled by that FC then they must be fulfilled by the next closest fc.&#xA;I am not sure how to model for example that certain states orders must be fulfilled using inventory&#xA;from the preferred FC first and then if nothing is left over try another FC.&lt;/p&gt;&#xA;&lt;p&gt;So I have the following decision variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{1,1},x_{1,2},..,x_{1,365}$&lt;/span&gt; this is what we ship from the first FC FOR THE various day&lt;/p&gt;&#xA;&lt;p&gt;I have got this formula this what we ship from the second fc to the customer for day &lt;span class=&quot;math-container&quot;&gt;$1,..,365$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{21},x_{22},...,x_{2,365}$&lt;/span&gt; this is what we ship from the second FC.&#xA;I have got&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{3,1},x_{3,2},x_{3,3},...,x_{3,365}$&lt;/span&gt; is how much we send from the third FC&lt;/p&gt;&#xA;&lt;p&gt;We have the parameters are&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_1,d_2,d_3,...,d_{365}$&lt;/span&gt; for all the demand.&lt;/p&gt;&#xA;&lt;p&gt;The demand is equal to all the orders from a particular day.&lt;/p&gt;&#xA;&lt;p&gt;We have the following decision variable the orders being shipped from the dc to the dc so we have six possible combinations.&lt;/p&gt;&#xA;&lt;p&gt;FC=1 dc=1 and at a day=1&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$O_{1,1,1)},O_{1,1,2},...,O_{1,1,365}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We also have from FC=1 DC=2 AT AND DAY 1&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$O_{1,2,1},..,O_{1,2,365}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;FC=2 DC=1 DAY=365&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$O_{2,1,1},..,O_{2,1,365}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We also have FC=2 DC=2 so we ship from the second dc to the second FDC&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$O_{2,2,1},..,O_{2,2,365}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;WE ALSO HAVE FC=3 AND DC=1&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$O_{3,1,1},O_{3,1,2},..,O_{3,1,365}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;FC=3 DC=2 how much FC 3 orders from dc&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$O_{3,2,1},O_{3,2,2},⋯,O_{3,2,365}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We have &lt;span class=&quot;math-container&quot;&gt;$O_{i,j,k}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the fc&#xA;where &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is the dc&#xA;where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is the day&lt;/p&gt;&#xA;&lt;p&gt;we have lost sales for the first day is the demand for first day minues all we ship from the various FC&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$l_1=d_1-(x_{11}+x_{21}+x_{31}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;demand for day 2 minus&#xA;&lt;span class=&quot;math-container&quot;&gt;$l_2=d2-(x_{12}+x_{22}+x_{32})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;we do this for all the 365 days&lt;/p&gt;&#xA;&lt;p&gt;We also have the following for the inventory&#xA;FOR FC=1, the starting inventory is 50&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$I_{1,1}=50-(x_{11})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$I_{12}$&lt;/span&gt; is the amount of inventory the 1 FC has on the second day&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$I_{1,2}=I_{11}-(x_{1,1} )+(o_{1,1,1}+o_{1,2,1}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;FOR FC=2&#xA;we have a starting inventory of 60&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$I_{2,1}=60-x_{21}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;we also have for the second day inventory&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i_{22}=i_{2,1}-x_{2,2}+(o_{2,1,1})+o_{2,2,1}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We have FC =3 inventory&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$i_{31}=70-x_{1,3}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We have then&#xA;this is the amount of inventory for fc 3 at day number 2&#xA;&lt;span class=&quot;math-container&quot;&gt;$I_{32}=I_{31}-x_{32}+o_{3,1,1}+o_{3,2,1}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We have truck constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$o_{113}&amp;lt;=nt*10$&lt;/span&gt; where nt is the number of trucks&lt;/p&gt;&#xA;&lt;p&gt;We have the following objective function&#xA;&lt;span class=&quot;math-container&quot;&gt;$30(l_1+..+l_{365})+1(I_{11}+..+I_{1,365} )+1(I_{2,1}+..+I_{2,365}+1(I_{31}+I_{32}+⋯+I_{3,365}+5(O_{1,1,1}+⋯+O{3,2,365})$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9483" LastEditorUserId="9483" LastEditDate="2022-11-28T13:36:04.447" LastActivityDate="2022-11-29T09:45:06.020" Title="How to create a transportation model with preferences" Tags="|linear-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9409" PostTypeId="1" AcceptedAnswerId="9416" CreationDate="2022-11-28T10:27:46.557" Score="1" ViewCount="105" Body="&lt;p&gt;I am interested to know whether there are any performance overheads for specifying Pyomo Constraints in different ways. For example, which of the two ways is better? I am trying to speed up one of my models who uses the second option. Can someone provide more information?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Option 1:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def teaOKrule(model):&#xA;    return(model.x['butter'] + model.x['scones'] == 3)&#xA;model.TeaConst = Constraint(rule=teaOKrule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Option 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@model.Constraint(model.s)&#xA;def hello_wor(model, i, j):&#xA;    return model.s[i, j] &amp;lt;= model.b[i, j]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10707" LastActivityDate="2022-11-28T19:32:08.620" Title="Are there any performance overheads if we specify Pyomo Constraints in different way?" Tags="|mixed-integer-programming|linear-programming|python|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9410" PostTypeId="1" AcceptedAnswerId="9469" CreationDate="2022-11-28T12:55:35.407" Score="2" ViewCount="305" Body="&lt;p&gt;I am performing several max-flow computations on extremely similar networks and I seek to improve their execution time based on information from previous computations (As there is a lot of repetitive computation). The code below is from the following repository + some additional details that I've added: &lt;a href=&quot;https://github.com/Pyomo/PyomoGallery/blob/master/maxflow/maxflow.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Pyomo/PyomoGallery/blob/master/maxflow/maxflow.py&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am interested in the solutions for computations which are equal to a &lt;code&gt;predefined_sum&lt;/code&gt; parameter. In addition I've added the &lt;code&gt;additional_rule&lt;/code&gt; which aims to apply a constraint that the maximum flow in the sink node should be equal to &lt;code&gt;predefined_sum&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, this seems to slow down the computation and does not improve the running time. Does someone have information about why this happens? Additionally, please let me know if you know some additional way to speed up the computation. I was also advised that the CPLEX API offers more functionality for such improvements so if someone knows some specific resources that can be used would be very helpful.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.environ import *&#xA;&#xA;model = AbstractModel()&#xA;#Specified flow&#xA;model.predefined_sum = pyo.Param(within=NonNegativeReals)&#xA;# Nodes in the network&#xA;model.N = Set()&#xA;# Network arcs&#xA;model.A = Set(within=model.N*model.N)&#xA;&#xA;# Source node&#xA;model.s = Param(within=model.N)&#xA;# Sink node&#xA;model.t = Param(within=model.N)&#xA;# Flow capacity limits&#xA;model.c = Param(model.A)&#xA;&#xA;# The flow over each arc&#xA;model.f = Var(model.A, within=NonNegativeReals)&#xA;&#xA;# Maximize the flow into the sink nodes&#xA;def total_rule(model):&#xA;    return sum(model.f[i,j] for (i, j) in model.A if j == value(model.t))&#xA;model.total = Objective(rule=total_rule, sense=maximize)&#xA;&#xA;# Enforce an upper limit on the flow across each arc&#xA;def limit_rule(model, i, j):&#xA;    return model.f[i,j] &amp;lt;= model.c[i, j]&#xA;model.limit = Constraint(model.A, rule=limit_rule)&#xA;&#xA;# Enforce flow through each node&#xA;def flow_rule(model, k):&#xA;    if k == value(model.s) or k == value(model.t):&#xA;        return Constraint.Skip&#xA;    inFlow  = sum(model.f[i,j] for (i,j) in model.A if j == k)&#xA;    outFlow = sum(model.f[i,j] for (i,j) in model.A if i == k)&#xA;    return inFlow == outFlow&#xA;model.flow = Constraint(model.N, rule=flow_rule)&#xA;&#xA;def additional_rule(model):&#xA;    return sum(model.f[i,j] for (i, j) in model.A if j == value(model.t)) == model.predefined_sum&#xA;model.additional_rule = pyo.Constraint(rule=additional_rule)&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="10707" LastEditDate="2022-11-29T17:02:03.930" LastActivityDate="2022-12-04T20:18:29.377" Title="Improve Network Flow computation with additional Pyomo constraints based on previous computation" Tags="|optimization|mixed-integer-programming|python|pyomo|network-flow|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9411" PostTypeId="2" ParentId="9408" CreationDate="2022-11-28T13:51:20.583" Score="2" Body="&lt;p&gt;Create combinations of FC, Day, State, Preferred(1,0) like OS(1,1, &amp;quot;Alaska&amp;quot;, 1) if FC=1 is preferred FC for Alaska, else OS(1,1, &amp;quot;Alaska&amp;quot;, 0)&lt;br /&gt;&#xA;If certain states can't be serviced by an FC, just don't create that combination. This will save variables and constraints.&lt;br /&gt;&#xA;Define &lt;span class=&quot;math-container&quot;&gt;$b_{f,s}=1 \forall f \in\ FC \ \forall s \in\ states$&lt;/span&gt; as binary initialized to 0.&lt;br /&gt;&#xA;Then&lt;br /&gt;&#xA;C1 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{s \in\ states} os_{f,d,s, p} \le x_{f,d} \forall f,d \in\ O$&lt;/span&gt; : Choosing FC and day from set O will sum it for DCs used.&lt;/p&gt;&#xA;&lt;p&gt;C2 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{dc \in\ DC} o_{f,dc,s} = os_{f,d,s,p} \forall d \in\ day, \ \forall s \in\ states \ \forall f \in\ FC$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;C3 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{f} os_{f,d,s,p} \le demand_{d,s} \ \forall s \in\ states \ \forall d \in\ days$&lt;/span&gt;. May be not required if you've a similar constraint with &lt;span class=&quot;math-container&quot;&gt;$o_{f,d,s}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;C4 = &lt;span class=&quot;math-container&quot;&gt;$p*I_{f,d} \le M*b_{s,f}$&lt;/span&gt;: b is 1 if I &amp;gt; 0 for &lt;span class=&quot;math-container&quot;&gt;$\forall f \in\ FC \ d \in\ day$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;C5 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{f,p=0} (1-p)*b_{f,s} \le M*(1- p*b_{f,s}) \ \forall s \in\ states, S$&lt;/span&gt;:&lt;br /&gt;&#xA;M can be big enough, say more than &lt;span class=&quot;math-container&quot;&gt;$max(I_{f,d})$&lt;/span&gt;: c4, C5 ensure b flips for inventory for preferred state, FC but remains 1 for non preferred.&lt;/p&gt;&#xA;&lt;p&gt;C6 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{f,p=0} (1-p)*os_{f,d,s,p} \le (1-p)\sum_{f} b_{s,f}*I_{f,d}$&lt;/span&gt;: ensures flow from non-preferred only when inventory in preferred FC =0 for a state s\&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-11-29T03:56:02.870" LastActivityDate="2022-11-29T03:56:02.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9412" PostTypeId="1" AcceptedAnswerId="9415" CreationDate="2022-11-28T13:53:06.260" Score="2" ViewCount="339" Body="&lt;p&gt;I noticed some people specify the solver as &lt;strong&gt;&amp;quot;cplex_direct&amp;quot;&lt;/strong&gt; whereas others as &lt;strong&gt;&amp;quot;cplex&amp;quot;&lt;/strong&gt; when passing the option to &lt;code&gt;SolverFactory&lt;/code&gt; in Pyomo. Is there any difference between the two options? If so, what it is the difference between the two?&lt;/p&gt;&#xA;" OwnerUserId="10707" LastActivityDate="2022-11-28T18:34:11.027" Title="Difference between cplex_direct and cplex in Pyomo SolverFactory" Tags="|python|cplex|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9413" PostTypeId="1" AcceptedAnswerId="9419" CreationDate="2022-11-28T16:15:05.933" Score="1" ViewCount="279" Body="&lt;p&gt;My problem is described in this picture:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/oHYEP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oHYEP.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{l}&#xA;\left\{\begin{array}{l}&#xA;\text { objective function: } \\&#xA;f = \min \sum_\limits{l=1}^2  \sum_\limits{i=0}^{2^l-1} \sum_\limits{j=0}^{2^l-2}\left(A_{i j}^l / A_{j +l}^l-D_{i j}^l / D_{ijH}^l\right)^2&#xA; \\&#xA;\text { constraints: } \\&#xA;A_{i j}^l-A_{2i \ 2j}^{l+1}-A_{2iH \ 2 j}^{l+1}-A_{2i \ 2jH}^{l+1}-A_{2iH \ &#xA;2jH }^{l+1}=0 \\&#xA;A_{i j}^l \leqslant V_{i j}^l \\&#xA;\end{array}\right.&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&lt;p&gt;In this problem, D and V is known, A is the object that I want to get. It is a layered structure, each block in the upper layer is divided into four sub-blocks in the figure below.&lt;/p&gt;&#xA;&lt;p&gt;What I want to do is simulate the distribution of D with A, so in the objective function is the ratio of two adjacent squares in each row in A compared to the value in D. I do this comparison on each layer and sum them. Then it is all of my objective function.&lt;/p&gt;&#xA;&lt;p&gt;Also I have two constraints. The first is in A the value in the upper cell is equal to the sum of the four child nodes in the lower layer, just like the D and V. The second is the value in A is no more than the value in V in the same position.&lt;/p&gt;&#xA;&lt;p&gt;I have tried the CVXPY library in python. But it seems my objective function is not a convex function so it can't solve it. My code is like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;first_layer = cp.Variable((2,2), integer=True)&#xA;second_layer = cp.Variable((4,4), integer=True)&#xA;&#xA;for i in range(0,2):&#xA;    for j in range(0,1):&#xA;        cost += (first_layer[i][j] / first_layer[i][j+1] - D[1][i][j] / D[1][i][j+1])**2&#xA;&#xA;for i in range(0,4):&#xA;    for j in range(0,3):&#xA;        cost += (second_layer[i][j] / second_layer[i][j+1] - D[2][i][j] / D[2][i][j+1])**2&#xA;&#xA;constraints = []&#xA;for i in range(0,2):&#xA;    for j in range(0,2):&#xA;        constraints += [A[i][j] - A[2*i][2*j] - A[2*i+1][2*j] - A[2*i][2*j+1] - A[2*i+1][2*j+1] == 0]&#xA;&#xA;for i in range(0,2):&#xA;    for j in range(0,2):&#xA;        constraints += [A[i][j] - V[i][j] &amp;lt;= 0]&#xA;&#xA;objective = cp.Minimize(cost)&#xA;prob = cp.Problem(objective,constraints)&#xA;prob.solve(solver='ECOS_BB')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And the result is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvxpy.error.DCPError: Problem does not follow DCP rules. Specifically:&#xA;The objective is not DCP. Its following subexpressions are not:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It seems I violation the DCP rules&#xA;[https://www.cvxpy.org/tutorial/dcp/index.html], because it says&lt;code&gt;expr1*expr2, expr1/expr2, and expr1@expr2 can only be DCP when one of the expressions is constant.&lt;/code&gt;My objective function has the term &lt;code&gt;x1/x2&lt;/code&gt; so it can't works.&#xA;But is DGP rules [https://www.cvxpy.org/tutorial/dgp/index.html] or DQP rules[https://www.cvxpy.org/tutorial/dqcp/index.html] works? I'm not sure.&lt;/p&gt;&#xA;&lt;p&gt;So, I really don't know how to solve this type of problem? I'm even not sure it is what type of question.  What type of objective function is this and how can I solve it?&lt;/p&gt;&#xA;" OwnerUserId="10825" LastEditorUserId="51" LastEditDate="2022-11-28T18:04:43.553" LastActivityDate="2022-11-28T22:06:12.487" Title="How to solve this mixed integer quadratic program using cvxpy or other method?" Tags="|optimization|python|convex-optimization|quadratic-programming|cvxpy|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9414" PostTypeId="2" ParentId="9413" CreationDate="2022-11-28T16:30:47.330" Score="-1" Body="&lt;p&gt;Try with constraint:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{i}*y_{i}=1$&lt;/span&gt;.&lt;br /&gt;&#xA;Then replace &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; in the objective.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-11-28T16:30:47.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9415" PostTypeId="2" ParentId="9412" CreationDate="2022-11-28T18:34:11.027" Score="4" Body="&lt;p&gt;Pyomo has a number of interfaces to the CPLEX solver:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;cplex&lt;/code&gt; is a wrapper around a number of (primarily file-based) interfaces to the cplex solver executable.  By default, that interface writes &amp;quot;LP&amp;quot; files, but can be configured to use MPS or NL files (through the &lt;code&gt;solver_io&lt;/code&gt; argument to the &lt;code&gt;SolverFactory()&lt;/code&gt; call)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cplex_direct&lt;/code&gt; is an interface that communicates the model to CPLEX through the CPLEX Python bindings.  In theory this can be more efficient as it avoids writing/reading text files and spawning an external subprocess.  This interface can also be obtained with &lt;code&gt;SolverFactory(&amp;quot;cplex&amp;quot;, solver_io=&amp;quot;python&amp;quot;)&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cplex_persistent&lt;/code&gt; is an extension of the &lt;code&gt;cplex_direct&lt;/code&gt; interface that supports a &amp;quot;persistent&amp;quot; interface to the CPLEX environment and supports more efficient &amp;quot;resolves&amp;quot; (i.e., solving a slightly modified model)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;appsi_cplex&lt;/code&gt; is a complete rewrite of the direct/persistent interface to CPLEX as part of APPSI (the &amp;quot;auto-persistent Pyomo solver interface&amp;quot; project).  This interface is significantly more performant, and can &amp;quot;automatically&amp;quot; detect the changed parts of the model with relatively low overhead.  That said, APPSI is still very much &amp;quot;under development&amp;quot; (as of 2022), so interfaces and APIs are still subject to change.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10026" LastActivityDate="2022-11-28T18:34:11.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9416" PostTypeId="2" ParentId="9409" CreationDate="2022-11-28T19:32:08.620" Score="1" Body="&lt;p&gt;Short answer: To within the tolerances measurable within Python, those two approaches perform equivalently.&lt;/p&gt;&#xA;&lt;p&gt;Longer answer: there is in fact a slight overhead using the decorator notation instead of the explicit notation (the decorator effectively generates the explicit form automatically for you).  This amounts to only a handful of function calls and a little bit of logic.  The thing to remember is that overhead is only encountered once when declaring the component (there is NO additional overhead for each index within the Component), so is for all intents and purposes not measurable.&lt;/p&gt;&#xA;" OwnerUserId="10026" LastActivityDate="2022-11-28T19:32:08.620" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9417" PostTypeId="1" AcceptedAnswerId="9418" CreationDate="2022-11-28T19:44:48.837" Score="2" ViewCount="608" Body="&lt;p&gt;I am trying to solve an optimization problem where the constraint contains absolute values and I am not sure how I can express this in a '&lt;a href=&quot;http://www.pyomo.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo&lt;/a&gt;-friendly' way.&lt;/p&gt;&#xA;&lt;p&gt;Consider the following optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{b_{n}} \sum_{n} \space a_{n}(b_{n} - c_{n})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to &lt;span class=&quot;math-container&quot;&gt;$a_{n} &amp;gt; 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_{n} = \begin{cases} c_{n}, &amp;amp; |b_{n} - c_{n}|\leq \epsilon \\ b_{n}, &amp;amp; |b_{n} - c_{n}| &amp;gt; \epsilon \end{cases}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As this is not a linear constraint, my guess is that this is not solvable. I also found &lt;a href=&quot;https://stackoverflow.com/q/40873161&quot;&gt;this&lt;/a&gt; question where it is mentioned that there are some modelling tricks.&lt;/p&gt;&#xA;" OwnerUserId="10093" LastEditorUserId="8" LastEditDate="2022-11-29T14:02:16.100" LastActivityDate="2022-11-29T14:02:16.100" Title="Optimization problem with if condition as constraint" Tags="|linear-programming|constraint|linearization|pyomo|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9418" PostTypeId="2" ParentId="9417" CreationDate="2022-11-28T20:10:04.617" Score="4" Body="&lt;p&gt;It looks like you want to enforce the disjunction&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(b_n - c_n &amp;lt; -\epsilon) \lor (b_n - c_n = 0) \lor (b_n - c_n &amp;gt; \epsilon).$$&lt;/span&gt;&#xA;You can instead enforce the following disjunction:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(b_n - c_n \le -\epsilon) \lor (b_n - c_n = 0) \lor (b_n - c_n \ge \epsilon).$$&lt;/span&gt;&#xA;Assume finite bounds &lt;span class=&quot;math-container&quot;&gt;$L \le b_n - c_n \le U$&lt;/span&gt;.  Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_n$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z_n$&lt;/span&gt;, and impose the following linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_n + y_n + z_n &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $n$}\\&#xA;Lx_n + 0y_n + \epsilon z_n \le b_n - c_n &amp;amp;\le -\epsilon x_n + 0y_n + Uz_n &amp;amp;&amp;amp;\text{for all $n$}\\&#xA;\end{align}&lt;/span&gt;&#xA;Alternatively, omit &lt;span class=&quot;math-container&quot;&gt;$y_n$&lt;/span&gt; and instead impose:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_n + z_n &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for all $n$}\\&#xA;Lx_n + \epsilon z_n \le b_n - c_n &amp;amp;\le -\epsilon x_n + Uz_n &amp;amp;&amp;amp;\text{for all $n$}\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-11-28T20:10:04.617" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9419" PostTypeId="2" ParentId="9413" CreationDate="2022-11-28T20:47:28.037" Score="4" Body="&lt;p&gt;Maybe work with a slightly different objective. Basically, you want:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ A_{i j}^l / A_{j +l}^l \approx D_{i j}^l / D_{ijH}^l $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You could do:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \min \sum |A_{i j}^l - A_{j +l}^l \cdot D_{i j}^l / D_{ijH}^l | $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is now linear (CVXPY can linearize the absolute value for you).&lt;/p&gt;&#xA;&lt;p&gt;A detail: maybe exclude: &lt;span class=&quot;math-container&quot;&gt;$A_{j +l}^l=0$&lt;/span&gt;. That may need an extra binary variable if &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; can be negative. (I am not sure how you want to interpret &lt;span class=&quot;math-container&quot;&gt;$A_{j +l}^l=0$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Note that this approach will give somewhat different solutions than your model. But it will do a similar thing. If you want to stick to your objective, I think you may need to look at a different tool, such as a (global) MINLP solver.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2022-11-28T22:06:12.487" LastActivityDate="2022-11-28T22:06:12.487" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9420" PostTypeId="1" AcceptedAnswerId="9451" CreationDate="2022-11-29T05:49:05.740" Score="5" ViewCount="464" Body="&lt;p&gt;How to formulate the following constraint using gurobipy&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sqrt{x^2 + y^2} \le z$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where  &lt;span class=&quot;math-container&quot;&gt;$x, y, z$&lt;/span&gt; are continuous optimization variables?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I saw how to formulate it using CVXPY:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;cp.norm(cp.hstack([x, y])) &amp;lt;= z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am now wondering how to formulate it in gurobipy. I did not find any information on how to formulate the norm convex function in the gurobipy documentation.&lt;/p&gt;&#xA;&lt;p&gt;If take the square of both sides,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x^2 + y^2 \le z^2 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;gurobipy solves it but doesn't this constraint violate DCP rules? I thought the constraint will be following the DCP rules if convex &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt; constant, convex &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt; concave, but here it is convex &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt; convex.&lt;/p&gt;&#xA;" OwnerUserId="10454" LastEditorUserId="8" LastEditDate="2022-12-26T12:59:59.253" LastActivityDate="2022-12-26T12:59:59.253" Title="How to formulate the inequality constraint $\sqrt{x^2+y^2} \leq z$ using gurobipy?" Tags="|python|gurobi|convex-optimization|disciplined-convex-programming|socp|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9421" PostTypeId="2" ParentId="9408" CreationDate="2022-11-29T09:45:06.020" Score="2" Body="&lt;p&gt;The mentioned problem sounds like a variant of &lt;em&gt;&lt;strong&gt;Multi echelon-Multi stage&lt;/strong&gt;&lt;/em&gt; supply chain optimization problem in which you are willing to minimize transportation, inventory, and loading/unloading costs/units respectively. Let's describe that with a simple example as follows:&lt;/p&gt;&#xA;&lt;p&gt;There are three suppliers (fulfillment centers), two distribution centers (DC), and three customers (Georgia, ALASKA, and New Mexico). We already assume a period of time around three days union the based line. &lt;span class=&quot;math-container&quot;&gt;$\text{T} = \{ 0 \cup t1, t2, t3\}$&lt;/span&gt;. The schematic of the network would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uIOuz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uIOuz.png&quot; alt=&quot;Network diagram&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;where, indices &lt;span class=&quot;math-container&quot;&gt;$c, d, s, t$&lt;/span&gt; denote &lt;em&gt;customers, DC, Suppliers, and Planning horizon&lt;/em&gt; respectively. Let &lt;span class=&quot;math-container&quot;&gt;$x_{(s,d,t)}$&lt;/span&gt; be the number of products that would be supplied from supplier &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to DC &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Also, &lt;span class=&quot;math-container&quot;&gt;$y_{(d,c,t)}$&lt;/span&gt; denotes the amount of shifted goods from DC &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; to customer &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. The variables &lt;span class=&quot;math-container&quot;&gt;$inv{^s}_{(s,t)}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N{^v}_{(t)}$&lt;/span&gt; declare the inventory of suppliers and the number of vehicles needed to transport goods between nodes. The linear programming formulation is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}&#xA;\text{Min} \quad \mathbb{Z} = \sum_{s,d,t} x_{(s,d,t)}.cost{^{s}}_{(s,d)} + \sum_{c,d,t} y_{(c,d,t)}.cost{^{d}}_{(c,d)} + \sum_{s,t} inv{^s}_{(s,t)} + \sum_{t} N{^v}_{(t)}\\&#xA;\text{S.t:} \\&#xA;\sum_{d} y_{(c,d,t)} \geq Demand_{(c)} \quad \forall c,t &amp;amp; (1)\\&#xA;\sum_{d} x_{(s,d,t)} \leq cap{^{s}}_{(s)} \quad \forall s,t &amp;amp; (2)\\&#xA;\sum_{s} inv{^s}_{(s,t-1)} + \sum_{s} x_{(s,d,t)} = \sum_{c} y_{(c,d,t)} + \sum_{s} inv{^s}_{(s,t)} \quad \forall d,t &amp;amp; (3)\\&#xA;s_{(s,0)} = SS_{(s,0)} \quad \forall s &amp;amp; (4)\\&#xA;s_{(s,t)} \geq SS_{(s,t)} \quad \forall s,t &amp;amp; (5)\\&#xA;\sum_{s,d} x_{(s,d,t)} \leq N{^v}_{(t)}.cap^{v} \quad \forall t &amp;amp; (6)\\&#xA;x_{(s,d,t)}, y_{(c,d,t)}, inv{^s}_{(s,t)}, N{^v}_{(t)} \in \mathbb{R}_{+} \quad \forall s,d,c,t &amp;amp; (7)\\&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So, &lt;span class=&quot;math-container&quot;&gt;$cost{^{s}}_{(s,d)}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$cost{^{d}}_{(c,d)}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Demand_{(c)}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$cap{^{s}}_{(s)}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$SS_{(s,t)}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$cap^{v}$&lt;/span&gt; are the problem data/parameters to define appropriate costs of shipping between nodes, &lt;span class=&quot;math-container&quot;&gt;$ s \rightarrow d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ d \rightarrow c$&lt;/span&gt;, customers demand/orders, the suppliers capacity, initial inventory on hand, and capacity of the vehicles. Please, be aware that if you would like to prefer an assignment, you can change its related cost to get what you want. By the way, these costs may be still calculated easily based on the distances between the nodes.&lt;/p&gt;&#xA;&lt;p&gt;Some notes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I assume the number of vehicles as a decision variable, but you can set it up as a parameter.&lt;/li&gt;&#xA;&lt;li&gt;Inventory position is usually defined for a specific item than to imply the amount of supply. (I think it would be somehow waired). Another way to capture this is to use auxiliaries variables, slack and surplus, with whose appropriate penalties in the objective function to violate some limitations.&lt;/li&gt;&#xA;&lt;li&gt;I am not sure to understand what you mean by &lt;em&gt;lost sales&lt;/em&gt;. You can assert the number of orders in each period with the suppliers capacities to ensure there is NO violation of that. If so, the second note would be helpful.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Finally, the results of the problem by assuming a constant order would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;----     49 VARIABLE x.L  &#xA;&#xA;               t1          t2          t3&#xA;&#xA;s1.d1      60.000      60.000      60.000&#xA;s1.d2      20.000      20.000      20.000&#xA;s2.d2      90.000      90.000      90.000&#xA;&#xA;&#xA;----     49 VARIABLE y.L  &#xA;&#xA;                      t1          t2          t3&#xA;&#xA;d1.Georgia        60.000      60.000      60.000&#xA;d2.ALASKA         40.000      40.000      40.000&#xA;d2.NewMexico      70.000      70.000      70.000&#xA;&#xA;&#xA;----     49 VARIABLE N_v.L  &#xA;&#xA;t1 17.000,    t2 17.000,    t3 17.000&#xA;&#xA;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-11-29T09:45:06.020" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9423" PostTypeId="1" AcceptedAnswerId="9501" CreationDate="2022-11-29T15:28:02.053" Score="2" ViewCount="63" Body="&lt;p&gt;I'm coding in Julia and use the JuMP package. My IP solver stops by a fixed node limitation. I noticed that I can only get the feasible primal and dual solution if has any, however I would like to get the fractional solution who gives the best lower bound so far. Is there a way to get the &lt;strong&gt;fractional solution&lt;/strong&gt; (and objective value) of a node in a b&amp;amp;c tree ?&lt;/p&gt;&#xA;" OwnerUserId="5681" LastActivityDate="2022-12-04T20:08:09.640" Title="How to get the fractional solution of a node in a MIP model using JuMP package?" Tags="|mixed-integer-programming|integer-programming|cplex|julia|jump|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9424" PostTypeId="1" CreationDate="2022-11-29T16:22:05.850" Score="3" ViewCount="72" Body="&lt;p&gt;I am using the algorithm implemented by the library &lt;code&gt;networkx&lt;/code&gt; to solve a Steiner minimal tree problem.&lt;/p&gt;&#xA;&lt;p&gt;They claim their algorithm to give an approximated solution.&lt;/p&gt;&#xA;&lt;p&gt;However, I am working on a specific group of graphs, namely, grid lattices (with capacity 1).&lt;/p&gt;&#xA;&lt;p&gt;I believe this group of circuit belongs the Euclidean group, which should be hard to solve as well(?).&lt;/p&gt;&#xA;&lt;p&gt;On my experiments I keep getting the optimal solutions, so I wonder what property my graph has to guarantee that. Is it because of the capacity? Or maybe because it is a grid?&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="123" LastEditDate="2022-12-11T10:12:41.693" LastActivityDate="2022-12-11T10:12:41.693" Title="Steiner tree sub-optimal algorithm always finds the optimal solution. Why?" Tags="|reference-request|approximation-algorithms|spanning-trees|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9425" PostTypeId="1" AcceptedAnswerId="9427" CreationDate="2022-11-29T17:17:10.930" Score="1" ViewCount="321" Body="&lt;p&gt;What is the best way to specify whether a given variable is within a given range in Pyomo? Here I have a binary decision variable &lt;code&gt;assign[t, e]&lt;/code&gt; which I want to initialise with 0 when t is within some range specified as below. I read that this might not be the best way to do so and might cause solvers to violate this constraint. Is that the case?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def rule1(model, t, e):&#xA;   if t &amp;lt; model.start[e] or t &amp;gt;= model.end[e]:&#xA;            return model.assign[t, e] == 0&#xA;        else:&#xA;            return pyo.Constraint.Skip&#xA;    model.rule1 = pyo.Constraint(model.times, model.elements, rule=rule1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="10707" LastEditDate="2022-11-29T19:12:18.913" LastActivityDate="2022-11-29T20:54:00.673" Title="Create constraint when variable is within a given range MILP" Tags="|mixed-integer-programming|python|integer-programming|pyomo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9426" PostTypeId="2" ParentId="9373" CreationDate="2022-11-29T18:00:39.383" Score="2" Body="&lt;p&gt;The &lt;code&gt;pyomo.solvers&lt;/code&gt; conda-forge package is no longer maintained. You can install the solvers you mentioned manually using something like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;conda install -c conda-forge glpk coincbc ipopt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="583" LastActivityDate="2022-11-29T18:00:39.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9427" PostTypeId="2" ParentId="9425" CreationDate="2022-11-29T18:58:32.370" Score="1" Body="&lt;p&gt;When you say:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;initialise with 0 when t is within some range specified&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I'm assuming you mean that you want to &lt;strong&gt;fix&lt;/strong&gt; the variable to 0 given your code snippet. Instead of using a constraint for this I would recommend just fixing the variable using something like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for t in model.times:&#xA;    for e in model.elements:&#xA;        if t &amp;lt; pyo.value(model.start[e]) or t &amp;gt;= pyo.value(model.end[e]):&#xA;            model.assign[t,e].fix(0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also, it looks like you might have a typo in your constraint rule. You implemented &lt;code&gt;model.end[w]&lt;/code&gt; but &lt;code&gt;w&lt;/code&gt; is not defined.&lt;/p&gt;&#xA;" OwnerUserId="583" LastEditorUserId="583" LastEditDate="2022-11-29T20:54:00.673" LastActivityDate="2022-11-29T20:54:00.673" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9428" PostTypeId="1" CreationDate="2022-11-29T22:13:47.970" Score="1" ViewCount="112" Body="&lt;p&gt;A &lt;a href=&quot;https://mathoverflow.net/q/435372/136218&quot;&gt;question in mathoverflow&lt;/a&gt; asks if there exists a &lt;a href=&quot;https://en.wikipedia.org/wiki/Centrosymmetric_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;centrosymmetric&lt;/a&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Hadamard_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hadamard matrix&lt;/a&gt; of order 36.&lt;/p&gt;&#xA;&lt;p&gt;An &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt; matrix &lt;span class=&quot;math-container&quot;&gt;$A = (a_{i,j})$&lt;/span&gt; is &lt;em&gt;centrosymmetric&lt;/em&gt; if:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{i,j} = a_{n-i+1, n-j+1}, \space i=1,\dots,n, j=1,\dots,n \tag0\label0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In a Hadamard matrix, each pair of rows has matching entries in exactly half of their columns and mismatched entries in the remaining columns, and each pair of columns has matching entries in exactly half of their rows and mismatched entries in the remaining rows. It is sufficient to enforce the property for rows or columns to have it verified for columns or rows respectively.&lt;/p&gt;&#xA;&lt;p&gt;Using some answers from this site, I have modeled the problem as an ILP with all &lt;strong&gt;binary variables&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min a_{1,1} \tag1\label1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{k,i,j} \le a_{k,i} + a_{k,j} \le 2-x_{k,i,j}, \space 1 \le k \le n, 1 \le i \lt j \le n \tag2\label2$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{k,i} - a_{k,j} - x_{k,i,j} \le 0, \space 1 \le k \le n, 1 \le i \lt j \le n \tag3\label3$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{k,j} - a_{k,i} - x_{k,i,j} \le 0, \space 1 \le k \le n, 1 \le i \lt j \le n \tag4\label4$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k=1}^n x_{k,i,j} = n/2, \space 1 \le k \le n, 1 \le i \lt j \le n \tag5\label5$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\eqref{2}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\eqref{3}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\eqref{4}$&lt;/span&gt; are equivalent to &lt;span class=&quot;math-container&quot;&gt;$x_{k,i,j} = 1 \iff a_{k,i} \not = a_{k,j}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\eqref{5}$&lt;/span&gt; requires that exactly half of the entries of the two columns &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; match at the same row.&lt;/p&gt;&#xA;&lt;p&gt;Values &lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt; in the Hadamard matrix are mapped to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; in the program formulation.&lt;/p&gt;&#xA;&lt;p&gt;In the actual implementation, I have replaced the variables when equal due to &lt;span class=&quot;math-container&quot;&gt;$\eqref{0}$&lt;/span&gt;, therefore the actual variables in the implementation are the entries of the first full &lt;span class=&quot;math-container&quot;&gt;$n/2$&lt;/span&gt; rows of the matrix.&lt;/p&gt;&#xA;&lt;p&gt;An example in LP format for &lt;span class=&quot;math-container&quot;&gt;$n=4$&lt;/span&gt; is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Minimize&#xA; obj: a1,1&#xA;Subject To&#xA; c1: a1,1 + a1,2 - x1,1,2 &amp;gt;= 0&#xA; c2: a1,1 + a1,2 + x1,1,2 &amp;lt;= 2&#xA; c3: a1,1 - a1,2 - x1,1,2 &amp;lt;= 0&#xA; c4: a1,2 - a1,1 - x1,1,2 &amp;lt;= 0&#xA; c5: a2,1 + a2,2 - x2,1,2 &amp;gt;= 0&#xA; c6: a2,1 + a2,2 + x2,1,2 &amp;lt;= 2&#xA; c7: a2,1 - a2,2 - x2,1,2 &amp;lt;= 0&#xA; c8: a2,2 - a2,1 - x2,1,2 &amp;lt;= 0&#xA; c9: a2,4 + a2,3 - x3,1,2 &amp;gt;= 0&#xA; c10: a2,4 + a2,3 + x3,1,2 &amp;lt;= 2&#xA; c11: a2,4 - a2,3 - x3,1,2 &amp;lt;= 0&#xA; c12: a2,3 - a2,4 - x3,1,2 &amp;lt;= 0&#xA; c13: a1,4 + a1,3 - x4,1,2 &amp;gt;= 0&#xA; c14: a1,4 + a1,3 + x4,1,2 &amp;lt;= 2&#xA; c15: a1,4 - a1,3 - x4,1,2 &amp;lt;= 0&#xA; c16: a1,3 - a1,4 - x4,1,2 &amp;lt;= 0&#xA; c17: a1,1 + a1,3 - x1,1,3 &amp;gt;= 0&#xA; c18: a1,1 + a1,3 + x1,1,3 &amp;lt;= 2&#xA; c19: a1,1 - a1,3 - x1,1,3 &amp;lt;= 0&#xA; c20: a1,3 - a1,1 - x1,1,3 &amp;lt;= 0&#xA; c21: a2,1 + a2,3 - x2,1,3 &amp;gt;= 0&#xA; c22: a2,1 + a2,3 + x2,1,3 &amp;lt;= 2&#xA; c23: a2,1 - a2,3 - x2,1,3 &amp;lt;= 0&#xA; c24: a2,3 - a2,1 - x2,1,3 &amp;lt;= 0&#xA; c25: a2,4 + a2,2 - x3,1,3 &amp;gt;= 0&#xA; c26: a2,4 + a2,2 + x3,1,3 &amp;lt;= 2&#xA; c27: a2,4 - a2,2 - x3,1,3 &amp;lt;= 0&#xA; c28: a2,2 - a2,4 - x3,1,3 &amp;lt;= 0&#xA; c29: a1,4 + a1,2 - x4,1,3 &amp;gt;= 0&#xA; c30: a1,4 + a1,2 + x4,1,3 &amp;lt;= 2&#xA; c31: a1,4 - a1,2 - x4,1,3 &amp;lt;= 0&#xA; c32: a1,2 - a1,4 - x4,1,3 &amp;lt;= 0&#xA; c33: a1,1 + a1,4 - x1,1,4 &amp;gt;= 0&#xA; c34: a1,1 + a1,4 + x1,1,4 &amp;lt;= 2&#xA; c35: a1,1 - a1,4 - x1,1,4 &amp;lt;= 0&#xA; c36: a1,4 - a1,1 - x1,1,4 &amp;lt;= 0&#xA; c37: a2,1 + a2,4 - x2,1,4 &amp;gt;= 0&#xA; c38: a2,1 + a2,4 + x2,1,4 &amp;lt;= 2&#xA; c39: a2,1 - a2,4 - x2,1,4 &amp;lt;= 0&#xA; c40: a2,4 - a2,1 - x2,1,4 &amp;lt;= 0&#xA; c41: a2,4 + a2,1 - x3,1,4 &amp;gt;= 0&#xA; c42: a2,4 + a2,1 + x3,1,4 &amp;lt;= 2&#xA; c43: a2,4 - a2,1 - x3,1,4 &amp;lt;= 0&#xA; c44: a2,1 - a2,4 - x3,1,4 &amp;lt;= 0&#xA; c45: a1,4 + a1,1 - x4,1,4 &amp;gt;= 0&#xA; c46: a1,4 + a1,1 + x4,1,4 &amp;lt;= 2&#xA; c47: a1,4 - a1,1 - x4,1,4 &amp;lt;= 0&#xA; c48: a1,1 - a1,4 - x4,1,4 &amp;lt;= 0&#xA; c49: a1,2 + a1,3 - x1,2,3 &amp;gt;= 0&#xA; c50: a1,2 + a1,3 + x1,2,3 &amp;lt;= 2&#xA; c51: a1,2 - a1,3 - x1,2,3 &amp;lt;= 0&#xA; c52: a1,3 - a1,2 - x1,2,3 &amp;lt;= 0&#xA; c53: a2,2 + a2,3 - x2,2,3 &amp;gt;= 0&#xA; c54: a2,2 + a2,3 + x2,2,3 &amp;lt;= 2&#xA; c55: a2,2 - a2,3 - x2,2,3 &amp;lt;= 0&#xA; c56: a2,3 - a2,2 - x2,2,3 &amp;lt;= 0&#xA; c57: a2,3 + a2,2 - x3,2,3 &amp;gt;= 0&#xA; c58: a2,3 + a2,2 + x3,2,3 &amp;lt;= 2&#xA; c59: a2,3 - a2,2 - x3,2,3 &amp;lt;= 0&#xA; c60: a2,2 - a2,3 - x3,2,3 &amp;lt;= 0&#xA; c61: a1,3 + a1,2 - x4,2,3 &amp;gt;= 0&#xA; c62: a1,3 + a1,2 + x4,2,3 &amp;lt;= 2&#xA; c63: a1,3 - a1,2 - x4,2,3 &amp;lt;= 0&#xA; c64: a1,2 - a1,3 - x4,2,3 &amp;lt;= 0&#xA; c65: a1,2 + a1,4 - x1,2,4 &amp;gt;= 0&#xA; c66: a1,2 + a1,4 + x1,2,4 &amp;lt;= 2&#xA; c67: a1,2 - a1,4 - x1,2,4 &amp;lt;= 0&#xA; c68: a1,4 - a1,2 - x1,2,4 &amp;lt;= 0&#xA; c69: a2,2 + a2,4 - x2,2,4 &amp;gt;= 0&#xA; c70: a2,2 + a2,4 + x2,2,4 &amp;lt;= 2&#xA; c71: a2,2 - a2,4 - x2,2,4 &amp;lt;= 0&#xA; c72: a2,4 - a2,2 - x2,2,4 &amp;lt;= 0&#xA; c73: a2,3 + a2,1 - x3,2,4 &amp;gt;= 0&#xA; c74: a2,3 + a2,1 + x3,2,4 &amp;lt;= 2&#xA; c75: a2,3 - a2,1 - x3,2,4 &amp;lt;= 0&#xA; c76: a2,1 - a2,3 - x3,2,4 &amp;lt;= 0&#xA; c77: a1,3 + a1,1 - x4,2,4 &amp;gt;= 0&#xA; c78: a1,3 + a1,1 + x4,2,4 &amp;lt;= 2&#xA; c79: a1,3 - a1,1 - x4,2,4 &amp;lt;= 0&#xA; c80: a1,1 - a1,3 - x4,2,4 &amp;lt;= 0&#xA; c81: a1,3 + a1,4 - x1,3,4 &amp;gt;= 0&#xA; c82: a1,3 + a1,4 + x1,3,4 &amp;lt;= 2&#xA; c83: a1,3 - a1,4 - x1,3,4 &amp;lt;= 0&#xA; c84: a1,4 - a1,3 - x1,3,4 &amp;lt;= 0&#xA; c85: a2,3 + a2,4 - x2,3,4 &amp;gt;= 0&#xA; c86: a2,3 + a2,4 + x2,3,4 &amp;lt;= 2&#xA; c87: a2,3 - a2,4 - x2,3,4 &amp;lt;= 0&#xA; c88: a2,4 - a2,3 - x2,3,4 &amp;lt;= 0&#xA; c89: a2,2 + a2,1 - x3,3,4 &amp;gt;= 0&#xA; c90: a2,2 + a2,1 + x3,3,4 &amp;lt;= 2&#xA; c91: a2,2 - a2,1 - x3,3,4 &amp;lt;= 0&#xA; c92: a2,1 - a2,2 - x3,3,4 &amp;lt;= 0&#xA; c93: a1,2 + a1,1 - x4,3,4 &amp;gt;= 0&#xA; c94: a1,2 + a1,1 + x4,3,4 &amp;lt;= 2&#xA; c95: a1,2 - a1,1 - x4,3,4 &amp;lt;= 0&#xA; c96: a1,1 - a1,2 - x4,3,4 &amp;lt;= 0&#xA; c97: x1,1,2 + x2,1,2 + x3,1,2 + x4,1,2 = 2&#xA; c98: x1,1,3 + x2,1,3 + x3,1,3 + x4,1,3 = 2&#xA; c99: x1,1,4 + x2,1,4 + x3,1,4 + x4,1,4 = 2&#xA; c100: x1,2,3 + x2,2,3 + x3,2,3 + x4,2,3 = 2&#xA; c101: x1,2,4 + x2,2,4 + x3,2,4 + x4,2,4 = 2&#xA; c102: x1,3,4 + x2,3,4 + x3,3,4 + x4,3,4 = 2&#xA;Binary&#xA; a1,1 a1,2 a1,3 a1,4 a2,1 a2,2 a2,3 a2,4 x1,1,2 x2,1,2 x3,1,2 x4,1,2 x1,1,3 x2,1,3 x3,1,3 x4,1,3 x1,1,4 x2,1,4 x3,1,4 x4,1,4 x1,2,3 x2,2,3 x3,2,3 x4,2,3 x1,2,4 x2,2,4 x3,2,4 x4,2,4 x1,3,4 x2,3,4 x3,3,4 x4,3,4&#xA;End&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have uploaded &lt;a href=&quot;https://tio.run/##vVTBbtswDD1bX8F5cJHMzhoHPc1JDgN23Gm7LT04kp3KSZhBdoZtRb/dIyUntjNjbVGsF5Pikx4faVFyspGyrsVbjXJ3VBnMy0rpw/u7ZS9kNG4uY2qn1/1YpfcZR4TGCkozYmMiYINjcS88ncPIwHwBeD0bC88zWXU0CCYRXrYrszaCExPGiXhoqGSXSj6BUQ4wyg7jPtVoOVOzIT55lxp4R/6Pb7eOlhMkzuaJEB7CAm7Y4YR8CJYQc8KylCnmI3s2vo3AD5QfwRWO6bTwvlPjqnzkf9ao9/p3tkI4rIsP4DN8AtM4ijnQRlb45bguMlnB18MKHWZLL0kGVeHlBwNWv7YBMtwCsmHIos5wQbCmuslxGwq3od2xdQTbBt82@D1/znpABopEU6NKwpMelgYqChSE0DgT@Gkd9pcLmJL@iC/DNqJfFvG/JE83i4tw4RZuQ3GR6Dkiwo4IKmz2miImQ52Yv3InnieiGBahB0TQAL349tnL9Y9i8uaWP/Wa8ky@yW2gwxu6KWv4pv02nZvi/1Vfl2MBgbId4@eF8YfOlH7UmJpfp/kclno9O4t9pGtt0rQrrM/9v8a9TT7cmO7T9AnVqebmbZ3ad7Wu65s/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; the C code for generating the ILP program. It can be run there setting as inline parameter the value of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have tried some &lt;span class=&quot;math-container&quot;&gt;$n=4k$&lt;/span&gt; cases successfully with up to few seconds of solving time for &lt;span class=&quot;math-container&quot;&gt;$n=4,8,16$&lt;/span&gt; with Gurobi and CPLEX at NEOS Server. Case &lt;span class=&quot;math-container&quot;&gt;$n=20$&lt;/span&gt; has been solved in 10 seconds by Gurobi. Strangely, CPLEX took about two hours for &lt;span class=&quot;math-container&quot;&gt;$n=20$&lt;/span&gt;, while it solved &lt;span class=&quot;math-container&quot;&gt;$n=24$&lt;/span&gt; in a few minutes. Case &lt;span class=&quot;math-container&quot;&gt;$n=24$&lt;/span&gt; with Gurobi was solved in about five hours. Cases &lt;span class=&quot;math-container&quot;&gt;$n=32$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n=36$&lt;/span&gt; (Gurobi and CPLEX) timed out at NEOS after the 8 hours maximum.&lt;/p&gt;&#xA;&lt;p&gt;Note that due to the linked question, &lt;span class=&quot;math-container&quot;&gt;$n = 2^k, k \gt 1$&lt;/span&gt;, is guaranteed to have a solution. The same question conjectures that &lt;span class=&quot;math-container&quot;&gt;$n=4(4k+3), k \ge 0$&lt;/span&gt; has no solution.&lt;/p&gt;&#xA;&lt;p&gt;Is there any way to optimize or parallelize the above problem to get a solution for &lt;span class=&quot;math-container&quot;&gt;$n=36$&lt;/span&gt;, assuming it exists? Or at least for &lt;span class=&quot;math-container&quot;&gt;$n=32$&lt;/span&gt;, where it surely exists?&lt;/p&gt;&#xA;" OwnerUserId="9517" LastEditorUserId="9517" LastEditDate="2022-11-30T08:29:20.447" LastActivityDate="2022-11-30T08:29:20.447" Title="ILP program to find a centrosymmetric Hadamard matrix" Tags="|linear-programming|integer-programming|binary-variable|computational-complexity|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9429" PostTypeId="2" ParentId="9428" CreationDate="2022-11-29T23:24:59.900" Score="-1" Body="&lt;p&gt;In case you don't want to linearize as @robpratt suggests another way is:&#xA;Initialize &lt;span class=&quot;math-container&quot;&gt;$x_{kij}=0$&lt;/span&gt;.&lt;br /&gt;&#xA;Couple of constraints:&lt;br /&gt;&#xA;C1 = &lt;span class=&quot;math-container&quot;&gt;$a_{kj}-a_{ki} \le x_{kij}$&lt;/span&gt;&lt;br /&gt;&#xA;C2 = &lt;span class=&quot;math-container&quot;&gt;$a_{ki} - a_{kj} \le x_{kij}$&lt;/span&gt;.&lt;br /&gt;&#xA;Only thing remains when &lt;span class=&quot;math-container&quot;&gt;$a_{ki} - a_{kj}=0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is free. But if initialized to 0 and last constraint on how many &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to turn 1, solver will not change any &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to 1 unless forced.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-11-29T23:59:16.693" LastActivityDate="2022-11-29T23:59:16.693" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9430" PostTypeId="1" AcceptedAnswerId="9445" CreationDate="2022-11-30T07:17:38.953" Score="2" ViewCount="425" Body="&lt;p&gt;I am a user of Google OR Tools, which can interface with many LP &amp;amp; MIP solvers, plus it's own SAT based constraint programming solver.&lt;/p&gt;&#xA;&lt;p&gt;My question, in the context of OR-Tools, is: how should I best handle optimization problems where there are multiple objectives? For example if I want to minimize distance traveled in a warehouse while also minimizing proximity of workers.&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="981" LastEditDate="2023-12-22T14:42:20.213" LastActivityDate="2023-12-22T14:42:20.213" Title="Simplex method for multiple objectives" Tags="|mixed-integer-programming|linear-programming|or-tools|simplex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9431" PostTypeId="1" CreationDate="2022-11-30T07:38:34.200" Score="3" ViewCount="286" Body="&lt;p&gt;I am using or-tools to solve a CVRP with multiple time window, and multiple location.&#xA;Meaning that a customer can move during the day.&#xA;I can't achieve to add constraint like if i deliver the customer once i don't need to deliver him again in his next/previous location.&#xA;For now i tried defined Sets of delivery but i'm not sure to really understand how it works.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def solve(self):&#xA;        print(&amp;quot;INIT SOLVER&amp;quot;)&#xA;        self.manager = pywrapcp.RoutingIndexManager(len(self.data['time_matrix']), self.data[&amp;quot;num_vehicles&amp;quot;], self.data['depot'])&#xA;        self.routing = pywrapcp.RoutingModel(self.manager)&#xA;&#xA;        def time_callback(from_index, to_index):&#xA;            # Convert from self.routing variable Index to time matrix NodeIndex.&#xA;            from_node = self.manager.IndexToNode(from_index)&#xA;            to_node = self.manager.IndexToNode(to_index)&#xA;            return self.data['time_matrix'][from_node][to_node]&#xA;&#xA;        def demand_callback(from_index):&#xA;            # Convert from self.routing variable Index to demands NodeIndex.&#xA;            from_node = self.manager.IndexToNode(from_index)&#xA;            return self.data['demands'][from_node]&#xA;&#xA;        transit_callback_index = self.routing.RegisterTransitCallback(time_callback)&#xA;        self.routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)&#xA;&#xA;        #transit_callback_index = self.routing.RegisterTransitCallback(self.distance_callback)&#xA;        #self.routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)&#xA;&#xA;        demand_callback_index = self.routing.RegisterUnaryTransitCallback(demand_callback)&#xA;        self.routing.AddDimensionWithVehicleCapacity(demand_callback_index,0,  # null capacity slack&#xA;            self.data['vehicle_capacities'],  # vehicle maximum capacities&#xA;            True,  # start cumul to zero&#xA;            'Capacity')&#xA;&#xA;        time = 'Time'&#xA;        self.routing.AddDimension(transit_callback_index, 30,  self.T, False, time)&#xA;        time_dimension = self.routing.GetDimensionOrDie(time)&#xA;&#xA;        #SETTING UP TIME WINDOWS&#xA;        for location_idx, time_window in enumerate(self.data['time_windows']):&#xA;            if location_idx == self.data['depot']:&#xA;                continue&#xA;            index = self.manager.NodeToIndex(location_idx)&#xA;            time_dimension.CumulVar(index).SetRange(time_window[0], time_window[1])&#xA;&#xA;&#xA;&#xA;        depot_idx = self.data['depot']&#xA;        for vehicle_id in range(self.data['num_vehicles']):&#xA;            index = self.routing.Start(vehicle_id)&#xA;            time_dimension.CumulVar(index).SetRange(&#xA;                self.data['time_windows'][depot_idx][0],&#xA;                self.data['time_windows'][depot_idx][1])&#xA;&#xA;        for i in range(self.data['num_vehicles']):&#xA;            self.routing.AddVariableMinimizedByFinalizer(time_dimension.CumulVar(self.routing.Start(i)))&#xA;            self.routing.AddVariableMinimizedByFinalizer(time_dimension.CumulVar(self.routing.End(i)))&#xA;&#xA;        #DEFINING CUSTOMER CLUSTER&#xA;        print(self.data[&amp;quot;index&amp;quot;])&#xA;        for i in self.data['index']:&#xA;            print(i)&#xA;            delivery_node = i.copy()&#xA;            delivery_index = []&#xA;            for z in delivery_node:&#xA;                delivery_index.append(self.manager.NodeToIndex(z))&#xA;            delivery_disjunction_index = self.routing.AddDisjunction(delivery_index, -1)&#xA;            self.routing.AddPickupAndDeliverySets(0, delivery_disjunction_index)&#xA;        print(&amp;quot;Done&amp;quot;)&#xA;&#xA;        search_parameters = pywrapcp.DefaultRoutingSearchParameters()&#xA;        search_parameters.first_solution_strategy = (&#xA;        routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)&#xA;        #search_parameters.local_search_metaheuristic = (&#xA;        #routing_enums_pb2.LocalSearchMetaheuristic.GUIDED_LOCAL_SEARCH)&#xA;        #search_parameters.time_limit.FromSeconds(10)&#xA;&#xA;        print(&amp;quot;Start solver&amp;quot;)&#xA;&#xA;        self.solution = self.routing.SolveWithParameters(search_parameters)&#xA;&#xA;        if self.solution:&#xA;            self.display_solution()&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10838" LastActivityDate="2022-11-30T07:38:34.200" Title="Or-tools : CVRP multiple time window with multiple location" Tags="|vehicle-routing|or-tools|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9432" PostTypeId="1" CreationDate="2022-11-30T09:00:57.913" Score="2" ViewCount="89" Body="&lt;p&gt;Let's say we have the following problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x∈X}(cx - \min_{y∈Y}dxy)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are decision variables and &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; are parameters. Then, we take the dual of the inner maximization problem.&lt;/p&gt;&#xA;&lt;p&gt;Assume that this is the new objective function of the inner problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{z∈Z}(mz)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is a parameter and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is the dual variable.&lt;/p&gt;&#xA;&lt;p&gt;After that, how do we handle the &lt;span class=&quot;math-container&quot;&gt;$-$&lt;/span&gt; sign before the inner minimization problem. Do we only multiply the new objective function like given below or do we need to follow a different path?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x∈X,z∈Z}(cx - mz)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Why I am asking this is, after multiplying by minus, I observe that I end up having an unbounded problem. Do we need to change the constraints of the subproblem as well?&lt;/p&gt;&#xA;" OwnerDisplayName="user5245" LastEditorUserId="123" LastEditDate="2022-12-03T11:04:01.220" LastActivityDate="2022-12-03T20:34:51.933" Title="Dualization of the subproblem in bilevel programs" Tags="|optimization|bilevel-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9433" PostTypeId="2" ParentId="9430" CreationDate="2022-11-30T11:53:49.587" Score="3" Body="&lt;p&gt;Please be aware that, &lt;a href=&quot;https://en.wikipedia.org/wiki/Simplex_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Simplex&lt;/a&gt; is an algorithm to solve Linear programming and Not a method to solve &lt;em&gt;&lt;strong&gt;MOO&lt;/strong&gt;&lt;/em&gt;. In the context of linear or mixed-integer linear programming, there are some ways to do what you want. For example, &lt;em&gt;the weighted sum method, goal programming, and &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-constraint&lt;/em&gt; have frequently been used in literature and industries. For more details about MMO using google or-tools sat solver, the following &lt;a href=&quot;https://stackoverflow.com/questions/65515182/are-multiple-objectives-possible-or-tools-constraint-programming&quot;&gt;example&lt;/a&gt; and link would be helpful.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from ortools.sat.python import cp_model&#xA;&#xA;model = cp_model.CpModel()&#xA;solver = cp_model.CpSolver()&#xA;x = model.NewIntVar(0, 10, &amp;quot;x&amp;quot;)&#xA;y = model.NewIntVar(0, 10, &amp;quot;y&amp;quot;)&#xA;&#xA;# Maximize x&#xA;model.Maximize(x)&#xA;solver.Solve(model)&#xA;print(&amp;quot;x&amp;quot;, solver.Value(x))&#xA;print(&amp;quot;y&amp;quot;, solver.Value(y))&#xA;print()&#xA;&#xA;# Hint (speed up solving)&#xA;model.AddHint(x, solver.Value(x))&#xA;model.AddHint(y, solver.Value(y))&#xA;&#xA;# Maximize y (and constraint prev objective)&#xA;model.Add(x == round(solver.ObjectiveValue()))  # use &amp;lt;= or &amp;gt;= if not optimal&#xA;model.Maximize(y)&#xA;solver.Solve(model)&#xA;&#xA;print(&amp;quot;x&amp;quot;, solver.Value(x))&#xA;print(&amp;quot;y&amp;quot;, solver.Value(y))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/google/or-tools/issues/1344&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multi-objective optimization with CP-Sat&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2022-11-30T11:58:52.907" LastActivityDate="2022-11-30T11:58:52.907" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9434" PostTypeId="1" AcceptedAnswerId="9436" CreationDate="2022-11-30T11:55:12.103" Score="4" ViewCount="444" Body="&lt;p&gt;Consider the binary variables &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2 \in \{0,1\}$&lt;/span&gt; and the integer variable &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{Z}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$0 \leq y \leq 3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I'd like to formulate the following logical constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_1 = 1 \wedge y \geq 2 \implies x_2 = 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and I don't have access to commercial solvers or modelling frameworks. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="5007" LastActivityDate="2022-12-03T14:23:49.570" Title="How to transform a logical constraint with integer variables?" Tags="|mixed-integer-programming|modeling|integer-programming|logical-constraints|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9435" PostTypeId="2" ParentId="9434" CreationDate="2022-11-30T12:40:57.813" Score="7" Body="&lt;p&gt;The range of values of the variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is quite small, so you could use the binary representation &lt;span class=&quot;math-container&quot;&gt;$y = b_0 + 2b_1$&lt;/span&gt; with two binary variables &lt;span class=&quot;math-container&quot;&gt;$b_0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_1$&lt;/span&gt; instead of the integer variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then your logical constraint is equivalent to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_1 = 1 \wedge b_1 = 1 \implies x_2 = 1,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which can be modelled by&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_1 + b_1 \leq 1 + x_2.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2022-11-30T12:40:57.813" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9436" PostTypeId="2" ParentId="9434" CreationDate="2022-11-30T13:51:51.737" Score="11" Body="&lt;p&gt;You can derive the desired linear constraint by rewriting in conjunctive normal form and rearranging to an equivalent implication:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(x_1 \land (y\ge 2)) \implies x_2 \\&#xA;\lnot (x_1 \land (y\ge 2)) \lor x_2 \\&#xA;\lnot x_1 \lor (y\le 1) \lor x_2 \\&#xA;\lnot x_1 \lor x_2 \lor (y\le 1) \\&#xA;\lnot (x_1 \land \lnot x_2) \lor (y\le 1) \\ &#xA;(x_1 \land \lnot x_2) \implies (y\le 1) \\&#xA;(x_1 \land \lnot x_2) \implies (2\le 3-y) \\&#xA;2(x_1 + (1 - x_2) - 1) \le 3-y \\&#xA;2(x_1 - x_2) + y \le 3&#xA;$$&lt;/span&gt;&#xA;You can alternatively view this as a big-M constraint arising from the implication &lt;span class=&quot;math-container&quot;&gt;$x_1-x_2=1 \implies y \le 1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-11-30T14:02:00.340" LastActivityDate="2022-11-30T14:02:00.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9437" PostTypeId="1" AcceptedAnswerId="9439" CreationDate="2022-11-30T18:51:13.087" Score="3" ViewCount="156" Body="&lt;p&gt;I'm thinking about the following problem:&lt;/p&gt;&#xA;&lt;p&gt;Suppose you have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; items and every item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; has constants &lt;span class=&quot;math-container&quot;&gt;$D_i, p_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$D_i$&lt;/span&gt; is the demand for an item and &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; is the price for that item.&#xA;Now &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; is the cumulative demand, so &lt;span class=&quot;math-container&quot;&gt;$c_i = \sum_{j=1}^i D_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i = 1, 2, \dots, n$&lt;/span&gt; and all the items are ranked in a descending order in function of &lt;span class=&quot;math-container&quot;&gt;$D_i$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$D_i \ge D_{i+1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_n = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_1 = \frac{D_1}{\sum_{i=1}^n D_i}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then I got a function &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; that takes in as arguments &lt;span class=&quot;math-container&quot;&gt;$c_i, b_1, b_2, x_1, x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$b_1, b_2, x_1, x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; will be my decision variables.&lt;/p&gt;&#xA;&lt;p&gt;This function &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; returns a number for every item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; based on the cumulative demand &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;, 2 boundary variables &lt;span class=&quot;math-container&quot;&gt;$b_1, b_2$&lt;/span&gt; and 3 variables &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2, x_3$&lt;/span&gt; that are linked to &lt;span class=&quot;math-container&quot;&gt;$b_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_2$&lt;/span&gt; via a logical, conditional expression.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$b_1, b_2 \in [0, 1 ]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_1 \le b_2$&lt;/span&gt;. For &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2, x_3$&lt;/span&gt;, there is the constraint &lt;span class=&quot;math-container&quot;&gt;$0 \le x_1, x_2, x_3 \lt 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To show the output of the function &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, say&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b_1 = 0.80, b_2 = 0.95$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1 = 0.99, x_2 = 0.96, x_3 = 0.92$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;, then for an item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, if we have &lt;span class=&quot;math-container&quot;&gt;$c_i = 0.82$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$g_i(c_i, b_1, b_2, x_1, x_2, x_3) = 0.96$&lt;/span&gt; So the function &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; evaluates &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; by performing the following if statement:&lt;/p&gt;&#xA;&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$c_i \le b_1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;,&#xA;if &lt;span class=&quot;math-container&quot;&gt;$b_1 \lt c_i \le b_2$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;,&#xA;else &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The function &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; thus returns one of the variables &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;.&#xA;Now the cost function that I want to minimize is a nonlinear function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; that takes arguments &lt;span class=&quot;math-container&quot;&gt;$D_i, p_i$&lt;/span&gt; and the function &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; and I want to minimize wrt &lt;span class=&quot;math-container&quot;&gt;$b_1, b_2, x_1, x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;One major constraint is &lt;span class=&quot;math-container&quot;&gt;$$\frac{\sum_{i=1}^n D_i g_i(c_i, b_1, b_2, x_1, x_2, x_3)}{\sum_{i=1}^n D_i} = \beta$$&lt;/span&gt; , where &lt;span class=&quot;math-container&quot;&gt;$0 \le \beta \lt 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So if I think about it, I would write this minimization problem as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x_1, x_2, x_3, b_1, b_2} \sum_{i=1}^n f(D_i, p_i, g_i(c_i, b_1, b_2, x_1, x_2, x_3))$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{\sum_{i=1}^n D_i g_i(c_i, b_1, b_2, x_1, x_2, x_3)}{\sum_{i=1}^n D_i} = \beta$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$0 \le b_1 \le b_2 \le 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0\le x_1, x_2, x_3 \lt 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, is this something feasible?&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2022-12-01T14:25:50.713" LastActivityDate="2022-12-02T19:03:45.970" Title="Modelling a nonlinear minimization problem with a nested function" Tags="|nonlinear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9438" PostTypeId="1" CreationDate="2022-11-30T22:47:02.003" Score="2" ViewCount="76" Body="&lt;p&gt;I am fairly new to statistics. I am working on a list of items in stochastic vehicle routing problem with Poisson distribution and I need to do a normal approximation. I read a paper with the following formulation (image attached). I am not sure what I am missing in my algebraic skills but I can't get to the final equation. &lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&amp;amp;\operatorname{Prob}\left\{z\ge\frac{c-\bar\mu}{\sqrt{\bar\mu}}\right\}=\alpha\\\implies&amp;amp;(c-\bar\mu)=z_{1-\alpha}\sqrt{\bar\mu}\\\implies&amp;amp;(c-\bar\mu)^2=\bar\mu z_{1-\alpha}^2\quad\text{which, after some algebra, yields}\end{align}\\\bar\mu=\frac{2c+z_{1-\alpha}^2-\sqrt{z_{1-\alpha}^4+4cz_{1-\alpha}^2}}2.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10837" LastEditorUserId="123" LastEditDate="2022-12-03T11:11:21.503" LastActivityDate="2022-12-03T11:11:21.503" Title="Normal approximation of Poisson distribution" Tags="|approximation|statistics|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9439" PostTypeId="2" ParentId="9437" CreationDate="2022-11-30T23:43:35.630" Score="2" Body="&lt;p&gt;Change the const:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\frac{\sum_{i=1}^n D_i g_i(c_i, b_1, b_2, x_1, x_2, x_3)}{\sum_{i=1}^n D_i} = \beta$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n D_i g_i(c_i, b_1, b_2, x_1, x_2, x_3) = \beta \sum_{i=1}^n D_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Your &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; can be expressed as constraints instead of writing a func.&lt;br /&gt;&#xA;Initialize 3 binary variables &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; to 0.&lt;br /&gt;&#xA;For all i introduce the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;C1 = &lt;span class=&quot;math-container&quot;&gt;$b_1 - c_i \le Ma_1$&lt;/span&gt; with M just big enough, say 10 or slightly more than &lt;span class=&quot;math-container&quot;&gt;$max(c_i, b_2,b_1)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;C2 = &lt;span class=&quot;math-container&quot;&gt;$(c_i-b_1)(b_2-c_i) \le Ma_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;C3 = &lt;span class=&quot;math-container&quot;&gt;$c_i-b_2 \le Ma_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;C4 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{j}^3 a_j = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;C5 = &lt;span class=&quot;math-container&quot;&gt;$z_i = \sum_{j}^3 a_jx_j \ \forall i$&lt;/span&gt;: This will choose one of x's when corresponding a = 1.&lt;/p&gt;&#xA;&lt;p&gt;Replace g(x,c,b) with z in the objective and first constraint.&lt;br /&gt;&#xA;First constraint turns to:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n D_{i} z_{i} = \beta \sum_{i=1}^n D_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objective: &lt;span class=&quot;math-container&quot;&gt;$\min_{x_1, x_2, x_3, b_1, b_2} \sum_{i=1}^n f(D_i, p_i, z_i)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In case you want to linearize C2, then taking cue from &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables%5D&quot;&gt;here&lt;/a&gt;: &lt;br /&gt;&#xA;Two constraints: &lt;span class=&quot;math-container&quot;&gt;$c_i-b_i \le Mk_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_2-c_i \le Mk_2$&lt;/span&gt;&lt;br /&gt;&#xA;Then &lt;span class=&quot;math-container&quot;&gt;$k_1+k_2 -1 \le a_2$&lt;/span&gt;. k's are also binary initialized to 0.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Summarized this would look like the following optimization problem:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{i1}, a_{i2}, a_{i3} \in \{0, 1\}$&lt;/span&gt; and initialized to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \le x_1, x_2, x_3 \lt 1$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b_1, b_2 \in [0, 1]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$k_{i1}, k_{i2} \in \{0, 1\}$&lt;/span&gt; and initialized to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \le z_i \lt 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constants&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M = 10$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min f(D_i, P_i, z_i)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_i = a_{i1}x_1 + a_{i2}x_2 +a_{i3}x_3$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b_1-c_i \le a_{i1}M$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_i -b_2 \le a_{i3}M$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{i1}+a_{i2}+a_{i3} = 1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_i-b_1 \le Mk_{i1}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b_2 - c_i \le Mk_{i2}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$k_{i1}+ k_{i2} - 1 \le a_{i2}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n D_iz_i = \beta \sum_{i=1}^n D_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="329" LastEditDate="2022-12-02T19:03:45.970" LastActivityDate="2022-12-02T19:03:45.970" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="9440" PostTypeId="1" AcceptedAnswerId="9447" CreationDate="2022-12-01T07:42:48.470" Score="2" ViewCount="575" Body="&lt;p&gt;How to formulate this problem as MIP:&lt;/p&gt;&#xA;&lt;p&gt;For example, we have the following vector of binary variables:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x= [0, 0, 0, 1, 0, 1, 1]&#xA;$$&lt;/span&gt;&#xA;How to find out when the first &amp;quot;1&amp;quot; is recorded? For example, the index of the first &amp;quot;1&amp;quot; is 4. How to let the solver return for example, &lt;span class=&quot;math-container&quot;&gt;$y =[0, 0, 0, 1, 0, 0, 0].$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10454" LastEditorUserId="2556" LastEditDate="2022-12-01T13:59:52.987" LastActivityDate="2022-12-03T16:46:04.907" Title="How to find the index of the item, the first time appears?" Tags="|linear-programming|modeling|integer-programming|convex-optimization|big-m|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9441" PostTypeId="1" CreationDate="2022-12-01T08:18:28.413" Score="2" ViewCount="78" Body="&lt;p&gt;currently I am working on a model to simulate the supply chain of a group of warehouses in a country using Anylogic. Then I need to multi-optimize these outputs to get the best one based on optimizing several functions. As I know, I can use an optimization experiment in Anylogic, but what about multi-optimization ?&lt;/p&gt;&#xA;&lt;p&gt;Any ideas to multi-optimize inside Anylogic environment ?&lt;/p&gt;&#xA;" OwnerUserId="10715" LastActivityDate="2022-12-01T10:04:12.487" Title="Need a multi-optimization environment or plugin in Anylogic" Tags="|multi-objective-optimization|simulation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9442" PostTypeId="2" ParentId="9440" CreationDate="2022-12-01T08:50:48.993" Score="7" Body="&lt;p&gt;Suppose the index is 1-based and set constant &lt;span class=&quot;math-container&quot;&gt;$u_0 = 0$&lt;/span&gt;. With binary variables &lt;span class=&quot;math-container&quot;&gt;$u_i, y_i, i=1,\dots,n$&lt;/span&gt; and constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;u_i &amp;amp;\geq x_i\\&#xA;u_i &amp;amp;\geq u_{i-1}\\&#xA;u_i &amp;amp;\leq x_i + u_{i-1}\\&#xA;y_i &amp;amp;\leq u_i\\&#xA;y_i &amp;amp;\leq 1 - u_{i-1}\\&#xA;y_i &amp;amp;\geq u_i - u_{i-1}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; indicate the first &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In logic expressions:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;u_i = x_i \vee u_{i-1}\\&#xA;y_i = u_i \wedge \neg u_{i-1}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is just my first thought and I have no idea if it is efficient.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Second formulation:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_i \leq x_i\\&#xA;y_i \geq x_i - \sum_{i' &amp;lt; i} x_{i'}\\&#xA;y_i \leq 1 - \sum_{i' &amp;lt; i} y_{i'}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4569" LastEditorUserId="500" LastEditDate="2022-12-01T15:03:12.780" LastActivityDate="2022-12-01T15:03:12.780" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9443" PostTypeId="2" ParentId="9362" CreationDate="2022-12-01T09:23:50.507" Score="5" Body="&lt;p&gt;Here are some papers you could read. &lt;a href=&quot;https://optimization-online.org/wp-content/uploads/2020/05/7809.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; makes an introduction to the topic, explains why it is useful, what are some drawbacks and proposes an algorithm to deal with them. Also, it provides two different use cases, lot sizing optimization and tail optimization. &lt;a href=&quot;https://www.hindawi.com/journals/mpe/2019/4739376/&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; provides an example of a crane scheduling problem, with very complete explanations.  And also, you could check &lt;a href=&quot;https://or.stackexchange.com/a/7738/10165&quot;&gt;this very good answer&lt;/a&gt; to a question posted some time ago, in which the logic about rolling periods is explained.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastEditorUserId="10165" LastEditDate="2022-12-13T12:37:30.337" LastActivityDate="2022-12-13T12:37:30.337" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9444" PostTypeId="2" ParentId="9441" CreationDate="2022-12-01T10:04:12.487" Score="2" Body="&lt;p&gt;Well, if you can do multi-objective optimization in Anylogic, you could assign weights to all of your cost functions and consolidate them into a unique objective function. In that way, you obtain one solution, but you could make several scenarios changing the weights.&lt;/p&gt;&#xA;&lt;p&gt;But also, you could check &lt;a href=&quot;https://www.researchgate.net/profile/Andranik-Akopov/publication/262166627_A_Multi-agent_Genetic_Algorithm_for_Multi-objective_Optimization/links/5c802c60299bf1268d404df5/A-Multi-agent-Genetic-Algorithm-for-Multi-objective-Optimization.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; and try to replicate in a modern version of Anylogic. In that way, you can obtain the Pareto Frontier.&lt;/p&gt;&#xA;&lt;p&gt;Another different approach is the one &lt;a href=&quot;https://www.youtube.com/watch?v=XR5dS6bczIA&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://www.anylogic.com/resources/case-studies/pet-food-production-optimization-using-manufacturing-process-simulation-software/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2022-12-01T10:04:12.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9445" PostTypeId="2" ParentId="9430" CreationDate="2022-12-01T10:36:54.817" Score="3" Body="&lt;p&gt;I would say that you first of all need to figure out what you mean by an optimal solution to a multi objective optimisation problem. Are you searching for all Pareto optimal solutions (a set of solutions), just one (more or less arbitrary) Pareto optimal solution, a lexicographic optimal solution, a max-ordering solution, or something else?&lt;/p&gt;&#xA;&lt;p&gt;When you have decided on your notation of optimality, you should find a &lt;em&gt;method&lt;/em&gt; that uses your single objective SAT solver to find a solution meeting your criteria.&lt;/p&gt;&#xA;&lt;p&gt;One popular approach is to simply weigh each of your &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; objective functions, &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt;, using positive weights, &lt;span class=&quot;math-container&quot;&gt;$w_i&amp;gt;0$&lt;/span&gt; and then solve the single objective optimisation problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;  \min_{x\in {X}} \sum_{i=1}^p w_if_i(x)&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is your set of feasible solutions. This approach will guarantee a Pareto optimal solution, but it can be quite difficult to predict which values of the weights will lead to solutions of your liking. This require some experimentation.&lt;/p&gt;&#xA;&lt;p&gt;If you are after a lexigraphically optimal solution, the &lt;a href=&quot;https://or.stackexchange.com/a/9433/278&quot;&gt;approach described by @A.Omidi&lt;/a&gt; in the code sample is the way to go:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Optimise the most important objective &lt;span class=&quot;math-container&quot;&gt;$f_1(x)$&lt;/span&gt; and find an optimal solution with value &lt;span class=&quot;math-container&quot;&gt;$f_1^*$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Add a constraint to your model: &lt;span class=&quot;math-container&quot;&gt;$f_1(x)=f_1^*$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Change the objective from &lt;span class=&quot;math-container&quot;&gt;$f_1(x)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$f_2(x)$&lt;/span&gt; and optimize.&lt;/li&gt;&#xA;&lt;li&gt;Continue this approach until you have no more objetive functions, or the feasible set is a singleton.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;This last approach requires a strict ordering of your objectives from most important to least important. This will give you more control over what  solution you end up with, but you also restrict the search for interesting solutions quite considerably. The resulting solution is also guaranteed to be Pareto optimal.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2022-12-01T10:36:54.817" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9446" PostTypeId="1" CreationDate="2022-12-01T11:40:02.137" Score="3" ViewCount="133" Body="&lt;p&gt;I have a problem with linear constraints but in the objective function I want to have some linear terms along with a &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt; term. So it is like the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum \limits _i \sum \limits _j (a[i,j] + b[i,j]^2)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ a[i,j] $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ b[i,j]$&lt;/span&gt; are integer decision variables.&lt;/p&gt;&#xA;&lt;p&gt;All my constraints are linear. So my question is, how I can linearize the quadratic objective function and convert the problem to a linear one.&lt;/p&gt;&#xA;&lt;p&gt;I had an idea to convert it to piecewise linear function, with derivatives at specific points, but I am looking for another solution, as my problem includes many binary and integer variables, and adding more it will make it more complex and slow to solve.&lt;/p&gt;&#xA;" OwnerUserId="9957" LastEditorUserId="123" LastEditDate="2022-12-03T11:04:12.900" LastActivityDate="2022-12-03T11:04:12.900" Title="Linearize objective function with non-linear terms" Tags="|linear-programming|linearization|nonlinear-programming|quadratic-programming|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9447" PostTypeId="2" ParentId="9440" CreationDate="2022-12-01T13:20:58.363" Score="8" Body="&lt;p&gt;Here's a formulation if at least one &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; must be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i y_i &amp;amp;= 1 \tag1\label1\\&#xA;y_i &amp;amp;\le x_i &amp;amp;&amp;amp;\text{for all $i$} \tag2\label2\\&#xA;y_i &amp;amp;\le 1-x_j &amp;amp;&amp;amp;\text{for $j&amp;lt;i$} \tag3\label3&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} selects exactly one &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; to be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&#xA;Constraint \eqref{2} enforces the implication &lt;span class=&quot;math-container&quot;&gt;$y_i \implies x_i$&lt;/span&gt;.&#xA;Constraint \eqref{3} enforces the implication &lt;span class=&quot;math-container&quot;&gt;$y_i \implies \lnot x_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If instead it is possible that &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, relax \eqref{1} to &lt;span class=&quot;math-container&quot;&gt;$\le 1$&lt;/span&gt; and impose&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_i &amp;amp;\ge x_i - \sum_{j&amp;lt;i} x_j &amp;amp;&amp;amp;\text{for all $i$} \tag4&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In either case, you can use \eqref{1} to strengthen \eqref{3} as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i&amp;gt;j} y_i &amp;amp;\le 1-x_j &amp;amp;&amp;amp;\text{for all $j$} \tag5&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://or.stackexchange.com/questions/6187/how-can-i-strengthen-a-family-of-constraints-in-the-presence-of-a-clique-constra&quot;&gt;How can I strengthen a family of constraints in the presence of a clique constraint?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For the general case where &lt;span class=&quot;math-container&quot;&gt;$x \equiv 0$&lt;/span&gt; is feasible, &lt;a href=&quot;https://porta.zib.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PORTA&lt;/a&gt; yields the following formulation:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i y_i &amp;amp;\le 1 \\&#xA;y_i &amp;amp;\le x_i &amp;amp;&amp;amp;\text{for all $i$} \\&#xA;x_i &amp;amp;\le \sum_{j \le i} y_j &amp;amp;&amp;amp;\text{for all $i$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-12-02T05:03:06.907" LastActivityDate="2022-12-02T05:03:06.907" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9448" PostTypeId="2" ParentId="9440" CreationDate="2022-12-01T15:28:00.733" Score="2" Body="&lt;p&gt;If number is non-binary, say non negative continuous number &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, introduce a vector of binary &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; initialized to 0.&lt;br /&gt;&#xA;Have two binary variables &lt;span class=&quot;math-container&quot;&gt;$z_1 \ and z_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c - x_i \le My_{i}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_i - c \le M(1-y_{i})$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j \lt i} y_j \le i \quad \forall i \in\ N$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_{i+1}\le y_i \ \forall i \in\ N$&lt;/span&gt;: this ensures y turns 0 once c=x and remains 0 for rest of the array.&lt;/p&gt;&#xA;&lt;p&gt;First index will be &lt;span class=&quot;math-container&quot;&gt;$\sum_{j \lt i} y_j$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-03T16:46:04.907" LastActivityDate="2022-12-03T16:46:04.907" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9449" PostTypeId="2" ParentId="9438" CreationDate="2022-12-01T15:35:57.327" Score="3" Body="&lt;p&gt;&lt;strong&gt;Context Free Algebra.&lt;/strong&gt;&lt;br /&gt;&#xA;As pointed out by &lt;a href=&quot;https://or.stackexchange.com/users/4569/xd-y&quot;&gt;xd y&lt;/a&gt; in the &lt;a href=&quot;https://or.stackexchange.com/questions/9438/normal-approximation-of-poisson-distribution#comment19990_9438&quot;&gt;comments&lt;/a&gt;, one way to derive this without context (i.e., understanding the Gaussian approximation to the Poisson) is just to apply the &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_formula&quot; rel=&quot;nofollow noreferrer&quot;&gt;quadratic formula&lt;/a&gt; to the expression you provide.&lt;/p&gt;&#xA;&lt;p&gt;For notation simplicity, let &lt;span class=&quot;math-container&quot;&gt;$z_{1-\alpha} \equiv z$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Expanding and factoring permit immediately give the target form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\begin{align}&#xA;(c-\bar \mu)^2 &amp;amp;=\bar\mu z^2 \\&#xA;\bar\mu^2 -2c\bar\mu -\mu z^2 +c^2 &amp;amp;= 0 \\&#xA;\bar\mu^2 + \bar\mu(-2c-z^2) + c^2 &amp;amp;=0 \tag{Target Form} \\&#xA;\end{align}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;All that remains is to apply the &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_formula&quot; rel=&quot;nofollow noreferrer&quot;&gt;quadratic formula&lt;/a&gt; and simplify:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\bar \mu = \frac{-(-2c-z^2) \pm \sqrt{(-2c-z^2)^2-4c^2}}{2} \\&#xA;\bar \mu= \frac{2c+z^2 \pm \sqrt{4c^2+4cz^2+z^4-4c^2}}{2} \\&#xA;\bar \mu= \frac{2c+z^2 \pm \sqrt{z^4 +4cz^2}}{2} \quad \square\\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;With Context:  Normal (Gaussian) approximation to the Poisson distribution.&lt;/strong&gt;&lt;br /&gt;&#xA;The ideas behind the equations in your question come from this approximation.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$X \sim \text{Poisson}(\lambda)$&lt;/span&gt; then&#xA;&lt;span class=&quot;math-container&quot;&gt;$$X \approx \text{Normal}(\mu = \lambda,\; \sigma = \sqrt{\lambda}) \tag{1}$$&lt;/span&gt; for a sufficiently large &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; value. As &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; increases, the approximation gets better and better.&lt;/p&gt;&#xA;&lt;p&gt;One way to understand this is a &lt;span class=&quot;math-container&quot;&gt;$\text{Poisson}(20)$&lt;/span&gt; random variable is equivalent to adding up the results of 20 independent and identically distributed (i.i.d.) &lt;span class=&quot;math-container&quot;&gt;$\text{Poisson}(1)$&lt;/span&gt; random variables. This permits invoking the hallowed &lt;a href=&quot;https://en.wikipedia.org/wiki/Central_limit_theorem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Central Limit Theorem&lt;/a&gt; which immediately results in Equation &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt;Related:&lt;br /&gt;&#xA;On CrossValidated (Stats.SE): &lt;a href=&quot;https://stats.stackexchange.com/q/83283/177387&quot;&gt;Normal approximation to the Poisson distribution&lt;/a&gt;  &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="491" LastEditorUserId="491" LastEditDate="2022-12-01T17:24:41.490" LastActivityDate="2022-12-01T17:24:41.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9450" PostTypeId="1" AcceptedAnswerId="9456" CreationDate="2022-12-01T18:50:52.323" Score="2" ViewCount="168" Body="&lt;p&gt;I have a real world problem, which is analogous to the below toy problem, which I call 'The Movie Theater Problem' (TMTP.)&lt;/p&gt;&#xA;&lt;p&gt;In TMTP, movie viewers are assigned seats which principally balances two objectives, weighted equally: 1/ minimize distances to fire exists (F1 and F2) and 2/ maximize distance from other viewers, allocated to seats (S1...S9). For viewers, i (red) and j (blue) the proposed seats are S4 and S9, respectively, as depicted below.&lt;/p&gt;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Distance/Angle to theater screen is irrelevant as this is a toy problem analogous to one that is of interest to me.&lt;/li&gt;&#xA;&lt;li&gt;The sum of viewers could be any number, less than or equal to the total number of seats, not constrained to 2 viewers.&lt;/li&gt;&#xA;&lt;li&gt;In practice, this solution could be called several times iteratively as new viewers purchase tickets. As such, some seats may be allocated in previous iterations, which must be factored in as constraints in the current iteration, and are not eligible for the solver to reallocate.&lt;/li&gt;&#xA;&lt;li&gt;I typically use Google's OR-Tools, which interface with various MIP solvers, as well as CP-SAT, a constraint programming solver, which could potentially be more appropriate.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Data structures&lt;/p&gt;&#xA;&lt;p&gt;The primary data structure of interest is D, a distance matrix, where &lt;code&gt;D[i,j]&lt;/code&gt; represents the distance between locations &lt;code&gt;i-&amp;gt;j&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#     F1, S1, ..., S9, F2   &#xA;D = [[                   ], #F1&#xA;     [                   ], #S1&#xA;     ...&#xA;     [                   ], #S9&#xA;     [                   ]] #F2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Objective Function. I cannot directly minimize Eq1 and maximize E2 at the same time, however, scaling Eq1 by -1, should allow for a single objective function to be maximized where the dual of Eq1 is minimized.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/p3AWd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/p3AWd.png&quot; alt=&quot;Seat distance matrix&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Max( -1 * [  Si * D[i,F1]&#xA;           + Si * D[i,F2]&#xA;           + Sj * D[j,F1]&#xA;           + Sj * D[j,F2]  ] &#xA;     +1 * [  Si * Sj * D[i,j] ] )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Constraints&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Si in {1,0}&#xA;Sj in {1,0}&#xA;Si != Sj&#xA;SUM(Si: 1-&amp;gt;n) = num_viewers &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How can I best articulate this as a (mixed) integer programming problem?&lt;/li&gt;&#xA;&lt;li&gt;Is my objective function appropriate given the textual write-up above?&lt;/li&gt;&#xA;&lt;li&gt;Are my constraints (thus far) valid?&lt;/li&gt;&#xA;&lt;li&gt;How can I add constraints for seats that are already allocated from previous iterations, Sz?&lt;/li&gt;&#xA;&lt;li&gt;Is constraint programming more suitable than a MIP solution?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;A second version of this graphic is provided where S3 is allocated already, so distances from it must be maximized, but unlike Si and Sj, Sz cannot be allocated elsewhere and is a fixed constraint.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1oSuL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1oSuL.png&quot; alt=&quot;Seat distance matrix&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="981" LastEditDate="2023-12-22T15:13:31.657" LastActivityDate="2023-12-22T15:13:31.657" Title="Mixed Integer Programming: Iterative assignment problem" Tags="|mixed-integer-programming|python|or-tools|cp-sat|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9451" PostTypeId="2" ParentId="9420" CreationDate="2022-12-01T19:01:07.197" Score="3" Body="&lt;p&gt;Thanks to the Gurobi staff, this is how to formulate it using the norm constraint:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import gurobipy as gp&#xA;m=gp.Model()&#xA;m.addGenConstrNorm(aux, [x, y], 2, &amp;quot;normconstr&amp;quot;)&#xA;m.addConstr(aux&amp;lt;=z)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Ref: &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/10762215603345-SOCP&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://support.gurobi.com/hc/en-us/community/posts/10762215603345-SOCP&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10454" LastEditorUserId="8" LastEditDate="2022-12-01T21:06:34.260" LastActivityDate="2022-12-01T21:06:34.260" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9452" PostTypeId="2" ParentId="9450" CreationDate="2022-12-01T20:01:36.330" Score="2" Body="&lt;p&gt;The following is expressed in terms of the &amp;quot;toy&amp;quot; problem, and may or may not translate to your actual problem.&lt;/p&gt;&#xA;&lt;p&gt;If you are going to use a single objective function, there are some questions to answer. First, do you want to use the distance from each viewer to the nearest fire exit, or the sum/average distance to all fire exits? Another possibility (which would complicate the objective function) would be the distance to nearest weighted by the number of viewers for whom that is the nearest exit. (An exit being close is less helpful if everyone else is trying to get out that door.) Similarly, do you care about the distance from a given viewer to the closest other viewer, the total/average distance to all other viewers, or the number of viewers within a certain distance.&lt;/p&gt;&#xA;&lt;p&gt;Second, once all that is thrashed out, is how to weight the combination of the two distances in the objective function. Simply subtracting the exit distance expression from the viewer distance expression might not be adequate. Even though both may be expressed in the same units, a decrease of one foot distance to a neighboring viewer might not be as painful/annoying as an increase of one foot distance to the nearest fire exit.&lt;/p&gt;&#xA;&lt;p&gt;Third, you have to decide if all viewers are equivalent (meaning red in seat 4, blue in seat 9 is functionally the same as blue in seat 4, red in seat 9).&lt;/p&gt;&#xA;&lt;p&gt;Once you've worked through that, you will have a version of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;quadratic assignment problem&lt;/a&gt; if viewers have to be treated as individuals (meaning it matters which viewer is in seat 4, rather than just that seat 4 is filled). If all that matters is which seats are filled, it's a simpler model, but the objective is still quadratic because the distance measure depends on the occupancy of pairs of seats.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-12-01T20:01:36.330" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9453" PostTypeId="1" AcceptedAnswerId="9459" CreationDate="2022-12-01T20:35:11.783" Score="2" ViewCount="184" Body="&lt;p&gt;I am trying to solve a problem that requires I find the EOQ. This problem is from the book (translation from greek) Operational Research: Theory, Algorithms and Applications by authors Coletsos John &amp;amp; Stogiannis Dimitris.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A publishing house puts out a variety of books. One of the books with the most stable sales is the book “Master Chef”, which is on its 4th edition. The publishing house estimates that the next edition of the book will have circa 25,000 sales per year.&lt;/p&gt;&#xA;&lt;p&gt;The past years, the publishing house printed and bound the stock of a year of this book. However, recently, the big carrying cost is putting pressure on the managers who are reconsidering their policy. In particular, the publishing house is thinking about binding half the amount of copies that are printed and keeping the rest unbound. When needed, they’ll have the opportunity to bind the rest of the copies. The costs are presented in the following table (the transportation cost and the other costs that are not associated with this decision are omitted). The carrying cost is 25% of the value of the book per € per year.&lt;/p&gt;&#xA;&lt;p&gt;(a) What’s the EOQ if the printing and binding of the book happen at the same time? What’s the yearly total cost?&lt;/p&gt;&#xA;&lt;p&gt;(b) What’s the EOQ if only half the books are bound after printing? What’s the yearly TC?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The table that is provided is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;                Printing (in€)        Binding (in€)&#xA;Setup cost          7,500                  1,500&#xA;&#xA;Variable cost         6                      3&#xA;per unit&#xA;(I think they refer to carrying cost)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am unsure about some things and how to solve the problem. I started by writing down the given information and I for sure have the demand &lt;span class=&quot;math-container&quot;&gt;$D=25,000$&lt;/span&gt;. In order to calculate the EOQ and the TC I need the following: &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; (i’ve also seen it symbolized with &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;), which is the cost of the order, &lt;span class=&quot;math-container&quot;&gt;$K_c$&lt;/span&gt; which is the cost to store the books. Then, I can find the EOQ from its formula &lt;span class=&quot;math-container&quot;&gt;$\sqrt\frac{2\cdot K\cdot D}{K_c}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$TC = \frac{D}{EOQ}\cdot K+ \frac{EOQ}{2}\cdot K_c$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I think for (a) &lt;span class=&quot;math-container&quot;&gt;$K=7,500+1,500 =9,000$&lt;/span&gt;. Then, &lt;span class=&quot;math-container&quot;&gt;$K_c=25$&lt;/span&gt;%&lt;span class=&quot;math-container&quot;&gt;$\cdot Value$&lt;/span&gt;, but that’s where I get stuck. I don’t really understand how the second row of the table comes in hand in the carrying cost.&lt;/p&gt;&#xA;&lt;p&gt;Like, if I go to calculate in (a) with these I get:&#xA;&lt;span class=&quot;math-container&quot;&gt;$EOQ =\sqrt{\frac{2\cdot 9,000 \cdot 25,000}{0.25\cdot Value}}=14,142.14$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$TC=\frac{25,000}{14142.14}\cdot 9,000+\frac{14142.14}{2}\cdot 0.25\cdot 9=31,819.81$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can someone help me to understand how to utilise the information of the problem?&lt;/p&gt;&#xA;&lt;p&gt;Edit: I am going to accept @Steven01123581321 's answer as the correct one, because it's the closest to the correct one and the main reason I managed to get through this problem unscathed.&lt;/p&gt;&#xA;&lt;p&gt;For (a) Steven had it completely correct and nicely explained.&lt;/p&gt;&#xA;&lt;p&gt;As for (b), the thought process is this:&#xA;The publishing house is going to make &amp;quot;orders&amp;quot; in batches, printing all of the books in the batch and binding half of them. But before making another order, they'll obviously just bind the half that are left before printing more books. Therefore, the cost per order is going to be:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$7,500$&lt;/span&gt; for the printing of the batch&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$1,500$&lt;/span&gt; for the first half's binding and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$1,500$&lt;/span&gt; for the second half's binding later.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;That brings the setup cost per order to a sum of &lt;span class=&quot;math-container&quot;&gt;$K=10,500$&lt;/span&gt; euros. As for the rest, Steven got that covered, with the carrying cost being &lt;span class=&quot;math-container&quot;&gt;$K_c=7.5\cdot 0.25$&lt;/span&gt; euros per copy.&lt;/p&gt;&#xA;" OwnerUserId="10847" LastEditorUserId="10847" LastEditDate="2022-12-10T20:54:15.100" LastActivityDate="2022-12-15T16:57:12.680" Title="How to calculate EOQ in this problem?" Tags="|reduced-costs|economic-order-quantity|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9454" PostTypeId="2" ParentId="9453" CreationDate="2022-12-01T20:55:14.540" Score="2" Body="&lt;p&gt;You are correct about the demand and setup cost. The presence of &amp;quot;Value&amp;quot; in the numerator of the EOQ formula is an error. &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is the order setup cost (which is why you have seen it as &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;), which is independent of the value of the order. As for &amp;quot;Value&amp;quot; in the denominator, I would take it to mean the variable cost of one unit (which would depend on whether it was bound or not).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-12-01T20:55:14.540" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9455" PostTypeId="1" AcceptedAnswerId="9457" CreationDate="2022-12-01T22:51:14.360" Score="2" ViewCount="192" Body="&lt;p&gt;This question is a Google OR-Tools specific implementation of recommendation from a &lt;a href=&quot;https://or.stackexchange.com/questions/9450/mixed-integer-programming-iterative-assignment-problem?noredirect=1#comment20012_9450&quot;&gt;previous question&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In short, the movie theater problem encompasses assigning viewers to seats such that the distance between viewers is maximized, however, the distance between viewers and fire exits is minimized. I've attempted to solve using OR-Tools, specifically the SCIP solver: &lt;a href=&quot;https://colab.research.google.com/drive/1M7h5WWyt0d1B3E_fkavl50A1ycAhdCw8?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google Colab&lt;/a&gt; (reference for full code/details.)&lt;/p&gt;&#xA;&lt;p&gt;The expert of interest is below:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;objective_terms = []&#xA;&#xA;## Seat-seat distance penalty&#xA;for i in seat_matrix.keys():&#xA;  # only compute the penalty once per each {seat_i, seat_j} pair&#xA;  if i == max_seats:&#xA;    continue &#xA;  seat_i = seat_vars[i]&#xA;&#xA;  for j in range(i+1, max_seats+1):&#xA;    seat_j = seat_vars[j]&#xA;&#xA;    # only apply the distance penalty(i,j) if both seats i and j are assigned&#xA;    # unless both binary variables equal 1, penalty is not applied&#xA;    &#xA;    ## Attenpt 1: Triggers error&#xA;    dist = distance_matrix[(i,j)] * seat_i * seat_j &#xA;    objective_terms.append(dist) &#xA;&#xA;    ## Attempt 2: Doesn't apply penalty&#xA;    # if seat_i + seat_j == 2:&#xA;    #   objective_terms.append(distance_matrix[(i,j)])&#xA;&#xA;## Seat-exit distance penalty &#xA;for seat,var in seat_vars.items():&#xA;  dist = exit_distance_matrix[(seat, 1)] * var + exit_distance_matrix[(seat, 2)] * var&#xA;  objective_terms.append(-1*dist)&#xA;&#xA;solver.Maximize(solver.Sum(objective_terms))&#xA;&#xA;solution = {}&#xA;for seat, var in seat_vars.items():&#xA;  solution[seat] = var.solution_value()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Both attempt 1 and attempt 2 fail but for different reasons: Attempt multiplies two integer variables, which violates the assumption of linearity. Attempt 2 fails because the conditional logic is not accepted.&lt;/p&gt;&#xA;&lt;p&gt;How can these objective functions be restated such that seat-seat distance penalty is only applied if both seat_i and seat_j equal 1.&lt;/p&gt;&#xA;" OwnerUserId="10326" LastActivityDate="2022-12-01T23:43:36.773" Title="Google OR Tools: Iterative Assignment Problem" Tags="|mixed-integer-programming|linear-programming|or-tools|googlecolab|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9456" PostTypeId="2" ParentId="9450" CreationDate="2022-12-01T23:06:13.217" Score="2" Body="&lt;p&gt;With V = no. of viewers as variable, S =9 -&lt;span class=&quot;math-container&quot;&gt;$x_s$&lt;/span&gt; from previous iteration, as constant&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_s$&lt;/span&gt; is binary &lt;span class=&quot;math-container&quot;&gt;$\in\ {0,1}$&lt;/span&gt; flipping to 1 if seat, s is assigned&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z \in\ {0,1}$&lt;/span&gt; as well to make sure seats are enough for viewers. Otherwise solver will make everything 0.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;br /&gt;&#xA;C1 = &lt;span class=&quot;math-container&quot;&gt;$S - V \le Mz$&lt;/span&gt;&lt;br /&gt;&#xA;C1_1 = &lt;span class=&quot;math-container&quot;&gt;$V-S \le M(1-z)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;C2 = &lt;span class=&quot;math-container&quot;&gt;$Vz+S(1-z) = \sum_s x_s $&lt;/span&gt; : If V&amp;lt;S, allocate V seats, else allocate all S seats.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Average \ Exit$&lt;/span&gt; = &lt;span class=&quot;math-container&quot;&gt;${\sum_s \sum_{f=[1,2]} D_{f}x_s}\over S$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$Viewer \ Dist$&lt;/span&gt; = &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j \in\ S\times S} \ D_{i,j}x_ix_j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Obj = &lt;span class=&quot;math-container&quot;&gt;$min (scale(Average \ Exit) - Viewer \ Dist)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Linearize the obj&lt;/strong&gt;&lt;br /&gt;&#xA;Introduce &lt;span class=&quot;math-container&quot;&gt;$z_{i,j} \in\ {0,1} \ \forall i,j \in\  seats \ S$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Additional constraints&lt;/strong&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{i,j} \le x_i$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{i,j} \le x_j$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_i + x_j - 1 \le z_{i,j}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the objective part Viewer Dist, replace &lt;span class=&quot;math-container&quot;&gt;$x_ix_j$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$z_{i,j}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-03T19:41:05.317" LastActivityDate="2022-12-03T19:41:05.317" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9457" PostTypeId="2" ParentId="9455" CreationDate="2022-12-01T23:43:36.773" Score="3" Body="&lt;p&gt;Basically as earlier&lt;br /&gt;&#xA;&lt;strong&gt;Linearize the obj&lt;/strong&gt;&lt;br /&gt;&#xA;Introduce &lt;span class=&quot;math-container&quot;&gt;$z_{i,j} \in\ {0,1} \ \forall i,j \in\  seats \ S$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Additional constraints&lt;/strong&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{i,j} \le x_i$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{i,j} \le x_j$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_i + x_j - 1 \le z_{i,j}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the objective part Viewer Dist, replace &lt;span class=&quot;math-container&quot;&gt;$x_ix_j$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$z_{i,j}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-01T23:43:36.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9458" PostTypeId="1" AcceptedAnswerId="9467" CreationDate="2022-12-02T03:56:43.963" Score="1" ViewCount="210" Body="&lt;p&gt;In previous posts, &lt;a href=&quot;https://or.stackexchange.com/questions/9450/mixed-integer-programming-iterative-assignment-problem&quot;&gt;A&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://or.stackexchange.com/questions/9455/google-or-tools-iterative-assignment-problem&quot;&gt;B&lt;/a&gt;, I posed the Movie Theater Problem. In short, the movie theater problem encompasses assigning viewers to seats such that the distance between viewers is maximized, however, the distance between viewers and fire exits is minimized.&lt;/p&gt;&#xA;&lt;p&gt;In particular, the answer from @&lt;a href=&quot;https://or.stackexchange.com/users/10602/sutanu&quot;&gt;sutanu&lt;/a&gt; was helpful as they described a method for linearizing what appeared to be a quadratic problem. The solution has been implemented in &lt;a href=&quot;https://colab.research.google.com/drive/1M7h5WWyt0d1B3E_fkavl50A1ycAhdCw8?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google Colab&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'd like to extend the solution to a variation of the movie theater problem, namely, that viewers' priority scores, according to a loyalty program, influence the objective function:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Maximize distance between viewers, proportional to their priority scores&lt;/li&gt;&#xA;&lt;li&gt;Minimize distance between viewers and fire exits, F1 and F2, also proportional to priority scores.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In the previous iteration of the problem, solved in Google Colab, viewers implicitly shared the same priority score (all weights equaled 1.)&lt;/p&gt;&#xA;&lt;p&gt;My previous objective function, in pseudo-code utilized a binary matrix of shape [seats, seats] where &lt;code&gt;Z[i,j]=1&lt;/code&gt; represents an edge between seat i and seat j (both seats were occupied and thus the viewer distance penalty was applied, else 0 penalty.)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Max( -1 * [  S[i]   * D[i,F1]    # distance seat i from F1 &#xA;           + S[i]   * D[i,F2]]   # distance seat i from F2&#xA;     +1 * [  Z[i,j] * D[i,j] ] ) # distance viewer i from viewer j &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This was possible by asserting two constraints that &lt;code&gt;Z[i,j] &amp;lt;= S[i]&lt;/code&gt; and &lt;code&gt;Z[i,j] &amp;lt;= S[j]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I'm unsure how to incorporate priority scores when making allocation decisions. How is it recommended to most easily achieve this effect?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I've made an attempt to solve this problem.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;objective_terms = []&#xA;&#xA;## Seat-seat priority-distance  penalty&#xA;# only compute the penalty once per each {seat_i, seat_j} pair&#xA;for i in range(1,max_seats):&#xA;  for j in range(i+1, max_seats+1):&#xA;&#xA;    # only apply the distance penalty(i,j) if both seats i and j are assigned&#xA;    # unless both binary variables equal 1, penalty is not applied&#xA;&#xA;    viewer_pri_i = solver.Sum([V[i, v] * viewer_priorities[v] for v in range(1, num_viewers+1)])&#xA;    viewer_pri_j = solver.Sum([V[j, v] * viewer_priorities[v] for v in range(1, num_viewers+1)])&#xA;    weighted_distance = distance_matrix[(i,j)] * (viewer_pri_i + viewer_pri_j)&#xA;    objective_terms.append(weighted_distance)     &#xA;&#xA;## Seat-exit distance penalty &#xA;for seat,var in seat_vars.items():&#xA;  dist = exit_distance_matrix[(seat, 1)] * var + exit_distance_matrix[(seat, 2)] * var&#xA;  objective_terms.append(-0.5*dist) # average distance (seat, F1), (seat, F2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As you can see, the seat separation penalty must be proportional to the viewer priority (aka higher priority seaters get more space, are closer to exits, etc.)&lt;/p&gt;&#xA;&lt;p&gt;The line &lt;code&gt;weighted_distance = distance_matrix[(i,j)] * (viewer_pri_i + viewer_pri_j)&lt;/code&gt; captures an error that I noticed: The separation penalty for i-&amp;gt;j will be applied if either seat i &lt;em&gt;&lt;strong&gt;or&lt;/strong&gt;&lt;/em&gt; seat j has a viewer seated. &lt;strong&gt;It does not require both viewers to be seated.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;See full &lt;a href=&quot;https://colab.research.google.com/drive/17AoBhJUz-mwIB9BdreRL0if733QBvH9t?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;code&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="10326" LastEditDate="2022-12-02T22:06:21.077" LastActivityDate="2022-12-03T13:49:26.993" Title="Applying weights to assignment problems for linear MIP solvers" Tags="|mixed-integer-programming|linear-programming|python|or-tools|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9459" PostTypeId="2" ParentId="9453" CreationDate="2022-12-02T08:37:36.280" Score="1" Body="&lt;p&gt;I find the wordings pretty confusing, but the way I see it:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;for (a)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If binding &amp;amp; printing both happen, then for every ordered batch, you incur the costs &lt;span class=&quot;math-container&quot;&gt;$7500 + 1500 = 9000$&lt;/span&gt;. So ordering &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; times, would incur this costs &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; times. So when ordering a batch of &lt;span class=&quot;math-container&quot;&gt;$2000$&lt;/span&gt;, your total order costs would be &lt;span class=&quot;math-container&quot;&gt;$\frac{25000\times 9000}{2000} = 112500$&lt;/span&gt;. When ordering a batch of &lt;span class=&quot;math-container&quot;&gt;$2000$&lt;/span&gt; each time, we know from the underlying demand model that the average inventory will be &lt;span class=&quot;math-container&quot;&gt;$\frac{2000}{2} = 1000$&lt;/span&gt;. For each unit, when binding and printing happen both, to me it looks like the total cost per unit is &lt;span class=&quot;math-container&quot;&gt;$9$&lt;/span&gt; (and you pay &lt;span class=&quot;math-container&quot;&gt;$0.25$&lt;/span&gt; over this value as yearly inventory costs), which would lead to a yearly inventory cost of &lt;span class=&quot;math-container&quot;&gt;$\frac{2000}{2} \times 0.25 \times 9 = 2250$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Applying the EOQ formula with this knowledge, gives&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$EOQ = \sqrt{\frac{2\times 25000 \times 9000}{0.25\times 9}} \approx 14142$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with a total cost of:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{25000}{14142} \times 9000 + \frac{14142}{2} \times 0.25 \times 9 = 31819.81$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;for (b)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Because of the underlying model of the EOQ, I believe the authors are implying that there is a fixed order and unit cost as well, when half of the copies get printed but not bound.&lt;/p&gt;&#xA;&lt;p&gt;So when you order &lt;span class=&quot;math-container&quot;&gt;$2000$&lt;/span&gt; copies each batch and half of the copies are printed but not bounded, then the order cost is still &lt;span class=&quot;math-container&quot;&gt;$9000$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt;: the order cost is &lt;span class=&quot;math-container&quot;&gt;$10500$&lt;/span&gt; following the logic of @Tia in the answer. I'll adjust my answer this cost to be complete.&lt;/p&gt;&#xA;&lt;p&gt;When looking at yearly inventory costs: if you order &lt;span class=&quot;math-container&quot;&gt;$2000$&lt;/span&gt; pcs each times, your average inventory will be &lt;span class=&quot;math-container&quot;&gt;$1000$&lt;/span&gt; and the cost per unit will be &lt;span class=&quot;math-container&quot;&gt;$\frac{500 \times 6 + 500 \times 9}{1000} = 7.5$&lt;/span&gt;. This thus always leads to a unit cost of &lt;span class=&quot;math-container&quot;&gt;$\frac{6 + 9}{2} = 7.5$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Using this in the EOQ, I get&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$EOQ = \sqrt{\frac{2\times 25000 \times 10500}{0.25\times 7.5}} \approx 16733$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with a total cost of:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{25000}{16733} \times 10500+ \frac{16733}{2} \times 0.25 \times 7.5 = 31374.75$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We could also have calculated the change in the EOQ directly:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sqrt{\frac{9}{7.5}}\times \sqrt{\frac{10500}{9000}} = 1.1832$&lt;/span&gt; and multiplying &lt;span class=&quot;math-container&quot;&gt;$14142$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$1.1832$&lt;/span&gt; leads to &lt;span class=&quot;math-container&quot;&gt;$\approx 16733$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2022-12-15T16:57:12.680" LastActivityDate="2022-12-15T16:57:12.680" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="9460" PostTypeId="1" CreationDate="2022-12-02T08:38:15.147" Score="1" ViewCount="88" Body="&lt;p&gt;We know the fundamental theorem on the equivalence of separation and optimization: an optimization problem can be solved in a  polynomial time if and only if there is a polynomial time separation oracle.&lt;/p&gt;&#xA;&lt;p&gt;Let us consider a special case: We have an LP with exponential numbers of columns and rows.&#xA;If we have a polynomial time oracle to generate columns (vars) and rows (constraints), can we solve this LP in a polynomial time?&lt;/p&gt;&#xA;&lt;p&gt;I know that the fundamental theorem is proved using the ellipsoid algorithm. If the LP only has an exponential number of rows, we can apply the theorem for the primal problem; If the LP only has an exponential number of columns, we can apply the theorem for the dual problem.&#xA;Does the ellipsoid algorithm still work for primal and dual problems simultaneously? Perhaps, one needs to define the `polynomial time' to a proper problem data.&lt;/p&gt;&#xA;" OwnerUserId="10852" LastEditorUserId="2862" LastEditDate="2022-12-02T20:25:51.380" LastActivityDate="2022-12-02T20:25:51.380" Title="Polynomial time separation and optimization for an LP with exponential columns and rows?" Tags="|optimization|mixed-integer-programming|linear-programming|computational-complexity|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9461" PostTypeId="1" AcceptedAnswerId="9473" CreationDate="2022-12-02T11:06:54.853" Score="3" ViewCount="202" Body="&lt;p&gt;I've been looking everywhere, and I can't seem to find any information on whether GLPK can do &lt;strong&gt;successive optimizations&lt;/strong&gt; on the same model, on which we add a constraint at each iteration.&#xA;More concretely, I want to implement a Branch and Bound algorithm on a 01ILP, so at each iteration, I'll fix a variable either to 0 or 1 (depending on the branch) and solve the relaxed LP, but I don't want to reoptimize from scratch each time.&lt;/p&gt;&#xA;&lt;p&gt;Do you know if such a thing is possible using GLPK (and Julia/JuMP as modeling language)? And if not, do you see a solver that would do that?&lt;/p&gt;&#xA;" OwnerUserId="10854" LastEditorUserId="9115" LastEditDate="2022-12-04T01:51:30.660" LastActivityDate="2022-12-05T20:52:55.743" Title="Reoptimization with GLPK in Julia/JuMP" Tags="|branch-and-bound|julia|jump|glpk|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9462" PostTypeId="2" ParentId="9367" CreationDate="2022-12-02T13:05:53.317" Score="1" Body="&lt;p&gt;It is due to the interface on the NEOS server:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ampl: option solver kestrel;&#xA;ampl: option kestrel_options 'solver=gurobi';&#xA;ampl: option neos_server 'neos-server.org:3333';&#xA;ampl: option email 'USER@MAIL';&#xA;ampl: solve;&#xA;Connecting to: neos-server.org:3333&#xA;gurobi is not available on NEOS. Choose from:&#xA;    Bonmin&#xA;    Cbc&#xA;    CONOPT&#xA;    COUENNE&#xA;    CPLEX&#xA;    FilMINT&#xA;    filter &#xA;    Ipopt&#xA;    KNITRO&#xA;    L-BFGS-B&#xA;    LANCELOT&#xA;    LGO&#xA;    LOQO&#xA;    MINLP&#xA;    MINOS&#xA;    MINTO&#xA;    MOSEK&#xA;    OCTERACT&#xA;    OOQP&#xA;    PATH&#xA;    RAPOSa&#xA;    SNOPT&#xA;&#xA;To choose: option kestrel_options &amp;quot;solver=xxx&amp;quot;;&#xA;&#xA;&#xA;exit value 1&#xA;&amp;lt;BREAK&amp;gt;&#xA;ampl:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="814" LastActivityDate="2022-12-02T13:05:53.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9463" PostTypeId="1" AcceptedAnswerId="9510" CreationDate="2022-12-02T13:23:41.533" Score="2" ViewCount="47" Body="&lt;p&gt;Are there any tools to transform programs written in an algebraic modeling language like GAMS,AMPL,... into a different formulation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;E.g&lt;/strong&gt;. there is a quadratic constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_j b_i b_j = N, b \in \mathbb{B}$&lt;/span&gt; which can reformulated easily into several linear ones sacrificing readibility of the model. Most solvers automatically do such kind of reformulations.&lt;/p&gt;&#xA;&lt;p&gt;Are there tools to only perform those kind of reformulations and examine the results ?&lt;/p&gt;&#xA;" OwnerUserId="814" LastEditorUserId="814" LastEditDate="2022-12-02T15:29:55.673" LastActivityDate="2022-12-05T03:15:47.070" Title="Automatic Reformulation Tools For AML Programs" Tags="|linear-programming|modeling|nonlinear-programming|reformulation-linearization|modeling-languages|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9467" PostTypeId="2" ParentId="9458" CreationDate="2022-12-02T15:17:41.480" Score="2" Body="&lt;p&gt;Ok, since priority scores are associated with viewers need to create a set (tuple) of combinations SV with variables &lt;span class=&quot;math-container&quot;&gt;$x_{s,v} \ where \ v \in\ $&lt;/span&gt; viewer V and &lt;span class=&quot;math-container&quot;&gt;$x_{s,v} \in\ {0,1}  \ \forall s \in\ $&lt;/span&gt;Seats, S.&lt;br /&gt;&#xA;Any solver that can recall solved values of previous run can update S and python can dynamically make such combinations.&lt;br /&gt;&#xA;Constants/Parameters:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$p_v$&lt;/span&gt; as priority score for every v &lt;span class=&quot;math-container&quot;&gt;$\in\ $&lt;/span&gt;V&lt;/p&gt;&#xA;&lt;p&gt;Assuming previous constraints remain valid &amp;amp; relevant&lt;br /&gt;&#xA;Additional Constraints:&lt;/p&gt;&#xA;&lt;p&gt;C1 = &lt;span class=&quot;math-container&quot;&gt;$\sum_{s}^S x_{s,v} \le 1 \quad \forall v \in\ V$&lt;/span&gt;: Ensure all viewers are assigned atmost 1 seat, where S = no. of seats available in current iteration&lt;br /&gt;&#xA;C2 = &lt;span class=&quot;math-container&quot;&gt;$\sum_v x_{s,v} \le 1 \quad \forall s \in\ S$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objectives&lt;br /&gt;&#xA;Fire_Exit = Min&lt;span class=&quot;math-container&quot;&gt;$({\sum_{s,v \in\ SV} \sum_f D_fx_{s,v}\over S} - \sum_{s,v \in\ SV} p_vx_{s,v})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A kind of experimentation may be needed here. I'd suggest, break the objectives into two parts&lt;br /&gt;&#xA;First solve with above objective. Then use optimal solution of this part as a constraint &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; in the next part for max dist between viewers. In next part priority portion will be &lt;span class=&quot;math-container&quot;&gt;$+$&lt;/span&gt; to inter-viewer distance.&lt;br /&gt;&#xA;Need to check if this method gives better solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;2nd Edit&lt;/strong&gt;&lt;br /&gt;&#xA;Per the solution algorithm, for all &lt;span class=&quot;math-container&quot;&gt;$i,j \in\ $&lt;/span&gt;Seats,there are two variables:&lt;span class=&quot;math-container&quot;&gt;$viewerpr_{i,i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$viewerpr_{i,j}$&lt;/span&gt;&lt;br /&gt;&#xA;that are multiplied with sum if priority &lt;span class=&quot;math-container&quot;&gt;$p_v$&lt;/span&gt;.&#xA;So introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$z_{i,j}$&lt;/span&gt; where&#xA;Constraints:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$viewerpr_{i,i}+ viewerpr_{i,j} \le M\sum_v V_{i,v} \quad \forall i \in\ S$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$viewerpr_{i,i}+ viewerpr_{i,j} \le M\sum_v V_{j,v} \quad \forall j \in\ S$&lt;/span&gt;&lt;br /&gt;&#xA;M is sum(2 highest priorities)+1&lt;/p&gt;&#xA;&lt;p&gt;Objective = &lt;span class=&quot;math-container&quot;&gt;$\sum_j \sum_i D_{i,j}(viewerpr_{i,i}+ viewerpr_{i,j})$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-03T13:49:26.993" LastActivityDate="2022-12-03T13:49:26.993" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9468" PostTypeId="1" AcceptedAnswerId="9471" CreationDate="2022-12-02T15:48:54.400" Score="3" ViewCount="339" Body="&lt;p&gt;The following problem is defined with binary variables &lt;span class=&quot;math-container&quot;&gt;$a_{i1}, a_{i2}, a_{i3}, k_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k_2$&lt;/span&gt;.&#xA;Is it possible to avoid binary variables and to only work with continuous variables? How would we ought to adjust the constraints then?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{i1}, a_{i2}, a_{i3} \in \{0, 1\}$&lt;/span&gt; and initialized to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \le x_1, x_2, x_3 \lt 1$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b_1, b_2 \in [0, 1]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$k_{i1}, k_{i2} \in \{0, 1\}$&lt;/span&gt; and initialized to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constants&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M = 10$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x_1, x_2, x_3, b_1, b_2} f(D_i, P_i, z_i)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_i = a_{i1}x_1 + a_{i2}x_2 +a_{i3}x_3$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b_1-c_i \le a_{i1}M$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_i -b_2 \le a_{i3}M$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{i1}+a_{i2}+a_{i3} = 1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_i-b_1 \le Mk_{i1}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b_2 - c_i \le Mk_{i2}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$k_{i1}+ k_{i2} - 1 \le a_{i2}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n D_iz_i = \beta \sum_{i=1}^n D_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2022-12-02T19:15:41.517" LastActivityDate="2022-12-04T16:17:21.137" Title="Can we use continuous variables instead of binary variables in this NLP problem?" Tags="|nonlinear-programming|binary-variable|logical-constraints|minlp|continuous-optimization|" AnswerCount="2" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="9469" PostTypeId="2" ParentId="9410" CreationDate="2022-12-02T15:54:25.270" Score="3" Body="&lt;p&gt;Honestly, I do not know how to embed previous computations results in a new execution when considering a mathematical model. However, you can reuse previous computations in a new iteration, when considering an &amp;quot;analytical approach&amp;quot;, i.e. one not based on the use of solvers. The strategy relies, in principle, on any algorithm that makes use of &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;-&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;-paths in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; are the source and sink nodes, respectively. For didactical purposes, we will take the &lt;a href=&quot;https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ford-Fulkerson algorithm&lt;/a&gt;, where we will try to reuse the previous computations whenever calculating a new &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;-&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;-path in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;. For a better explanation, let's take the Ford-Fulkerson algorithm given &lt;a href=&quot;https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;below&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Inputs: Network &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; with flow capacity &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, a source node &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, and a sink node &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;Output: Compute a flow &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; of maximum value.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f(u,v)\leftarrow 0$&lt;/span&gt; for all edges &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$G_{f}(V,E_{f})$&lt;/span&gt; be the residual network with capacity &lt;span class=&quot;math-container&quot;&gt;$c_{f}(u,v) = c(u,v) - f(u,v)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;While there is a path &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$G_{f}$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$c_{f}(u,v)&amp;gt;0$&lt;/span&gt; for all edges &lt;span class=&quot;math-container&quot;&gt;$(u,v) \in p$&lt;/span&gt;:&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Find &lt;span class=&quot;math-container&quot;&gt;$c_{f}(p)=\min\{c_{f}(u,v):(u,v)\in p\}$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;For each edge &lt;span class=&quot;math-container&quot;&gt;$(u,v)\in p$&lt;/span&gt;:&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f(u,v)\leftarrow f(u,v)+c_{f}(p)$&lt;/span&gt; (Send flow along the path);&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f(v,u)\leftarrow f(v,u)-c_{f}(p)$&lt;/span&gt; (The flow might be &amp;quot;returned&amp;quot; later);&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Let's say that the algorithm above is executed &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; times, and each Max-Flow execution &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; caches the generated &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;-&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;-paths in a pool of paths, named as, &lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt;, i.e., the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th execution saves the paths generated at step 3 in the pool &lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In a given Max-Flow execution &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, we may reduce the number of iterations made at step 3, by making look-ups in the pools &lt;span class=&quot;math-container&quot;&gt;$\{P_i: i &amp;lt; j\}$&lt;/span&gt;, for any path in which all the nodes belong to the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;-th execution input graph, that is, &lt;span class=&quot;math-container&quot;&gt;$\{ p \in P_i: V(p) \subseteq V_j \wedge i &amp;lt; j\}$&lt;/span&gt;.&#xA;Of course, a smart strategy for reducing the look-up effort may be required, maybe a &lt;a href=&quot;https://en.wikipedia.org//wiki/Trie&quot; rel=&quot;nofollow noreferrer&quot;&gt;trie tree&lt;/a&gt; could suit this case.&lt;/p&gt;&#xA;&lt;p&gt;Not that, the described reusing strategy is not limited to the Ford-Fulkerson algorithm, but to algorithms that rely on the use of &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;-&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;-paths.&lt;/p&gt;&#xA;&lt;p&gt;Case any point is not clear, please, let me know. Regards.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastActivityDate="2022-12-02T15:54:25.270" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9470" PostTypeId="2" ParentId="9468" CreationDate="2022-12-02T17:08:35.083" Score="4" Body="&lt;p&gt;You can relax integrality of &lt;span class=&quot;math-container&quot;&gt;$a_{i2}.$&lt;/span&gt; Due to the &amp;quot;big M&amp;quot; constraints, I do not believe you can relax integrality of the other binary variables. It's a bit hard to be sure, since you did not indicate what the &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; are and whether &lt;span class=&quot;math-container&quot;&gt;$f()$&lt;/span&gt; is increasing, decreasing or not montonic in its arguments.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-12-02T17:08:35.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9471" PostTypeId="2" ParentId="9468" CreationDate="2022-12-02T17:43:31.387" Score="4" Body="&lt;p&gt;Yes, binaries can be replaced by NLP using continuous variables. But it's not necessarily a good idea, and is usually is a bad idea. If it were a good idea, there probably wouldn't be MINLP solvers.&lt;/p&gt;&#xA;&lt;p&gt;Binary variable &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; can be declared continuous by adding the constraint &lt;span class=&quot;math-container&quot;&gt;$b(b−1)=0$&lt;/span&gt;. Continuous yes. Well behaved, probably not. It's basically a non-nice way of writing a complementarity constraint, and inherits the challenges of such constraints.&lt;/p&gt;&#xA;&lt;p&gt;General integer variables, for example, integer x in range of 0 to 3 can be replaced by continuous x with constraint &lt;span class=&quot;math-container&quot;&gt;$x(x−1)(x−2)(x−3) = 0$&lt;/span&gt;. Again, not usually a good idea.&lt;/p&gt;&#xA;&lt;p&gt;The reformulation of binary or integer to continuous as above, results in a non-convex optimization problem. The original problem formulation having binary or integer variables, would not be convex, but its continuous relaxation might be. The reformulated problem is not convex.&lt;/p&gt;&#xA;&lt;p&gt;For binary or general integer variable, there might be at lease one local minimum associated with every integer value (which would be 2 in the case of binary). If there are multiple binary or integer variables, there may be at least one local minimum for every integer combination (if all binary, then &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; such combinations, where n is number of binaries).&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-12-04T16:17:21.137" LastActivityDate="2022-12-04T16:17:21.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9472" PostTypeId="1" CreationDate="2022-12-02T18:28:59.990" Score="4" ViewCount="57" Body="&lt;p&gt;&lt;strong&gt;TLDR&lt;/strong&gt;: If George Costanza was supposed to do Robust Optimization, he would instead do Best Case Optimization, which is (sort of) the opposite of Robust Optimization.&lt;/p&gt;&#xA;&lt;p&gt;Is there a literature or problem nomenclature associated with the concept of optimization with respect to the best case? That is sort of the opposite of Robust Optimization, which is optimizing with respect to the worst case.&lt;/p&gt;&#xA;&lt;p&gt;Robust optimization optimizes the worst case outcome with respect to some defined universe of possibilities. For instance, the increasingly popular &amp;quot;Wasserstein distributionally robust optimization&amp;quot;. It finds the optimum for the worst case within a specified Wasserstein distance.&lt;/p&gt;&#xA;&lt;p&gt;Optimizing for the best case would find the optimum for the best case, within a specified Wasserstein distance (or possibly otherwise).&lt;/p&gt;&#xA;&lt;p&gt;Roughly speaking, optimizing for the best case would let the optimizer choose the most favorable among a set of possible constraints, basically an &amp;quot;or&amp;quot;; whereas robust optimization essentially amounts to an &amp;quot;and&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Another analogy would be to Stochastic Programming. But in best optimization, the optimizer gets to choose the most favorable scenario to incorporate as a constraint.&lt;/p&gt;&#xA;&lt;p&gt;For example, let's say that (at least) one out of n of the matrix constraints, &lt;span class=&quot;math-container&quot;&gt;$A_ix = b_i$&lt;/span&gt; is satisfied, but we don't know which one.  Best case optimization would solve&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{min (w.r.t. to i,x)}: \text{f}(x), \text{s.t.} A_ix=b_i$$&lt;/span&gt;&#xA;So mini-min, not mini-max.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2022-12-02T18:28:59.990" Title="Best Case Optimization, which is sort of the opposite of Robust Optimization" Tags="|robust-optimization|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="9473" PostTypeId="2" ParentId="9461" CreationDate="2022-12-02T19:17:07.173" Score="3" Body="&lt;p&gt;Yes, you can do such a thing in JuMP.&#xA;If you use the so-called &lt;a href=&quot;https://jump.dev/JuMP.jl/stable/manual/models/#Direct-mode&quot; rel=&quot;nofollow noreferrer&quot;&gt;direct mode&lt;/a&gt;, then incremental changes to the model are passed directly to the solver.&#xA;If your solver supports incremental changes and re-solve, then it will do so.&#xA;For instance, if you are solving an LP, adding a constraint, and re-solving, then the second solve will (likely) be a lot faster than the first.&lt;/p&gt;&#xA;&lt;p&gt;All mainstream solvers I know of, e.g., CPLEX, Gurobi, GLPK, HiGHS, etc., support this.&#xA;BTW: nowadays, I would recommend using &lt;a href=&quot;https://highs.dev/&quot; rel=&quot;nofollow noreferrer&quot;&gt;HiGHS&lt;/a&gt; instead of GLPK. It's much much faster and more numerically robust.&lt;/p&gt;&#xA;&lt;p&gt;Here is a small example based on a knapsack problem&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using JuMP&#xA;using GLPK&#xA;&#xA;# Generate instance data&#xA;n = 8        # number of items&#xA;w = rand(n)  # item weights&#xA;c = rand(n)  # item values&#xA;W = sum(w) / 2  # total knapsack capacity&#xA;&#xA;# Build the optimization model&#xA;# (we only give the LP relaxation to GLPK)&#xA;model = JuMP.Model(GLPK.Optimizer)&#xA;&#xA;# Create x variables in [0, 1]&#xA;# they are not marked as binary to do branching manually later&#xA;@variable(model, x[1:n])&#xA;@constraint(model, bounds, 0 .&amp;lt;= x .&amp;lt;= 1)&#xA;&#xA;@constraint(model, capacity, w'x &amp;lt;= W)  # knapsack capacity&#xA;@objective(model, Max, c'x)  # maximize value of selected items&#xA;&#xA;# Main loop&#xA;optimize!(model)&#xA;z_root = objective_value(model)&#xA;x_ = value.(x)&#xA;&#xA;# branch on first fractional variable&#xA;# (here we assume that `x1` is fractional)&#xA;# Left (x1 = 0) node&#xA;JuMP.fix(x[1], 0.0)&#xA;optimize!(model)&#xA;z0 = objective_value(model)&#xA;# Right (x1 = 1) node&#xA;JuMP.unfix(x[1])&#xA;JuMP.fix(x[1], 1.0)&#xA;optimize!(model)&#xA;z1 = objective_value(model)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you have more technical questions, I encourage you to post them on the &lt;a href=&quot;https://discourse.julialang.org/c/domain/opt/13&quot; rel=&quot;nofollow noreferrer&quot;&gt;Julia discourse forum on mathematical optimization&lt;/a&gt;. You'll get more traction there.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastEditorUserId="3598" LastEditDate="2022-12-05T20:52:55.743" LastActivityDate="2022-12-05T20:52:55.743" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9474" PostTypeId="1" AcceptedAnswerId="9481" CreationDate="2022-12-03T06:07:13.397" Score="3" ViewCount="65" Body="&lt;p&gt;Is the substitution method expected to &lt;strong&gt;reduce&lt;/strong&gt; the computation cost? We know it will reduce the number of variables and constraints.&lt;/p&gt;&#xA;&lt;p&gt;I mean by substitution method is to eliminate the &lt;strong&gt;equality&lt;/strong&gt; constraints when possible.&lt;/p&gt;&#xA;&lt;p&gt;A simple illustrative example might be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;minimize z&#xA;Subject to:&#xA;z=x-2&#xA;0&amp;lt;x&amp;lt;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This can be reduced to:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;minimize x-2&#xA;Subject to:&#xA;0&amp;lt;x&amp;lt;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I use the substitution on a large problem, the computation time decreases if I use gurobipy but increases if I use CVXPY&lt;/p&gt;&#xA;" OwnerUserId="10454" LastEditorUserId="10454" LastEditDate="2022-12-03T06:16:56.373" LastActivityDate="2022-12-03T13:54:04.073" Title="Is not the substitution method supposed to reduce the computation cost?" Tags="|mixed-integer-programming|linear-programming|gurobi|convex-optimization|cvxpy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9475" PostTypeId="1" AcceptedAnswerId="9476" CreationDate="2022-12-03T07:23:36.743" Score="2" ViewCount="96" Body="&lt;p&gt;I have a &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; matrix &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; of binary variables in my MIP which represents a list of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; items each belonging to one of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; categories. &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is usually around &lt;span class=&quot;math-container&quot;&gt;$1,000$&lt;/span&gt; while &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is much lower at around &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$X_{i,j}=1$&lt;/span&gt;, then it means that item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; belongs to category &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (and 0 would mean that the item doesn't belong to that category).&lt;/p&gt;&#xA;&lt;p&gt;In addition to this, I have a list of costs &lt;span class=&quot;math-container&quot;&gt;$w_{i,j}$&lt;/span&gt; which contribute to a total cost &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; if and only if item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; belongs to the same category as item &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. For example, if &lt;span class=&quot;math-container&quot;&gt;$w_{300,400}=999$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; will be increased by 999 if items 300 and 400 belong to the same category (regardless of what category it is). Even though there are potentially up to a million possible pairs, the number of pairs in &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is usually at most around &lt;span class=&quot;math-container&quot;&gt;$10,000$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What's the best way to represent this total cost &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; in my MIP? My mathematical intuition would be to take the dot product of &lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_j$&lt;/span&gt; and multiply by &lt;span class=&quot;math-container&quot;&gt;$w_{i,j}$&lt;/span&gt; for all the pairs, but multiplying two variables is invalid in MIP.&lt;/p&gt;&#xA;" OwnerUserId="10857" LastEditorUserId="500" LastEditDate="2022-12-03T08:17:26.857" LastActivityDate="2022-12-03T08:27:20.197" Title="Expressing inner product of binary variables in MIP" Tags="|mixed-integer-programming|integer-programming|linearization|binary-variable|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9476" PostTypeId="2" ParentId="9475" CreationDate="2022-12-03T08:17:11.510" Score="5" Body="&lt;p&gt;The general approach for linearizing a product of binary variables is here: &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;How to linearize the product of two binary variables?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But you can exploit some special structure in your setting and avoid most products.  For each pair of items &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$i&amp;lt;j$&lt;/span&gt;) that have positive cost &lt;span class=&quot;math-container&quot;&gt;$w_{ij}$&lt;/span&gt;, introduce binary (or nonnegative) variable &lt;span class=&quot;math-container&quot;&gt;$Y_{ij}$&lt;/span&gt; to represent the inner product &lt;span class=&quot;math-container&quot;&gt;$\sum_k X_{ik}X_{jk}$&lt;/span&gt;. The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i&amp;lt;j} w_{ij} Y_{ij}$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_k X_{ik} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$}\\&#xA;X_{ik} + X_{jk} - 1 &amp;amp;\le Y_{ij} &amp;amp;&amp;amp;\text{for all $k$ and all $i&amp;lt;j$ with $w_{ij}&amp;gt;0$}&#xA;\end{align}&lt;/span&gt;&#xA;Contrast this with the usual linearization that would instead introduce four-indexed variables &lt;span class=&quot;math-container&quot;&gt;$Y_{ikj\ell}$&lt;/span&gt; to represent the product &lt;span class=&quot;math-container&quot;&gt;$X_{ik} X_{j\ell}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-12-03T08:27:20.197" LastActivityDate="2022-12-03T08:27:20.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9477" PostTypeId="1" AcceptedAnswerId="9483" CreationDate="2022-12-03T11:58:11.317" Score="6" ViewCount="227" Body="&lt;p&gt;&lt;strong&gt;Setup&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have a &lt;span class=&quot;math-container&quot;&gt;$N \times M$&lt;/span&gt; matrix with integer values and I need to group it into &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; groups (subject to constraints). Internally I work with a flattened 1D list as I don't see any benefits of using this two-dimensionality, but I can change this if needed.&lt;/p&gt;&#xA;&lt;p&gt;I have already a working solution to create these different groups and I would like to improve this model via symmetry breaking.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have a binary matrix &lt;span class=&quot;math-container&quot;&gt;$x_{i,j} \in \{0,1\}$&lt;/span&gt; that takes value 1 if the matrix value i is assigned to group j, as asked by @Kuifje.&#xA;An additional constraint I didn't mention is that the group have to be roughly in equal size.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have a &lt;span class=&quot;math-container&quot;&gt;$2 \times 4$&lt;/span&gt; matrix, thus &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; elements, and I want to group them into &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; groups named &lt;span class=&quot;math-container&quot;&gt;$A, B$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;One possible way to create these group is:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;matrix value&lt;/th&gt;&#xA;&lt;th&gt;-4&lt;/th&gt;&#xA;&lt;th&gt;1&lt;/th&gt;&#xA;&lt;th&gt;-4&lt;/th&gt;&#xA;&lt;th&gt;5&lt;/th&gt;&#xA;&lt;th&gt;1&lt;/th&gt;&#xA;&lt;th&gt;-1&lt;/th&gt;&#xA;&lt;th&gt;4&lt;/th&gt;&#xA;&lt;th&gt;3&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;group&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;A&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;A&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td&gt;C&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;B&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td&gt;C&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;B&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;B&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td&gt;C&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Which is the same as saying (group &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; flipped, marked in bold):&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;matrix value&lt;/th&gt;&#xA;&lt;th&gt;-4&lt;/th&gt;&#xA;&lt;th&gt;1&lt;/th&gt;&#xA;&lt;th&gt;-4&lt;/th&gt;&#xA;&lt;th&gt;5&lt;/th&gt;&#xA;&lt;th&gt;1&lt;/th&gt;&#xA;&lt;th&gt;-1&lt;/th&gt;&#xA;&lt;th&gt;4&lt;/th&gt;&#xA;&lt;th&gt;3&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;group&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;B&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;B&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td&gt;C&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;A&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td&gt;C&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;A&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;strong&gt;A&lt;/strong&gt;&lt;/td&gt;&#xA;&lt;td&gt;C&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;The only thing which matters is how these fields are grouped, not to which particular group they belong.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Ideas:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I already have a symmetry breaking constraint which fixes field &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to group &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, this removes already a few of the possible permutations. But I believe there is more performance gain possible.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I extend my idea above to create more symmetry breaking constraints? Alternatively: is there a better way to model this, so that no symmetry breaking is needed?&lt;/p&gt;&#xA;" OwnerUserId="10858" LastEditorUserId="10858" LastEditDate="2022-12-03T19:41:25.150" LastActivityDate="2022-12-03T20:10:36.000" Title="Breaking symmetry of permutations in LIP" Tags="|linear-programming|integer-programming|symmetry|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9478" PostTypeId="2" ParentId="9477" CreationDate="2022-12-03T12:19:16.667" Score="6" Body="&lt;p&gt;It would help a little if you detailed the formulation of the model you are using.&lt;/p&gt;&#xA;&lt;p&gt;Assuming you are using binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,j} \in \{0,1\}$&lt;/span&gt; that take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if matrix value &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to group &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, you could add the following ordering constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i}x_{i,j} \ge x_{k,j+1} \quad \forall k,\; \forall j \tag{1} \label{1}&#xA;$$&lt;/span&gt;&#xA;This ensures that group &lt;span class=&quot;math-container&quot;&gt;$j+1$&lt;/span&gt; is not used until group &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is. Then you can order the groups by non increasing size with:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i}x_{i,j} \ge \sum_{i}x_{i,j+1} \quad  \forall j \tag{2} \label{2}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As noted by @RobPratt in the comments below, constraints \eqref{1} are dominated by constraints \eqref{2}, and can therefore be eliminated.&lt;/p&gt;&#xA;&lt;p&gt;Depending on the nature of your problem (the other constraints), you could maybe adapt cover/clique/knapsack cuts.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, you could decompose the problem with a Dantzig-Wolfe formulation as follows. Let &lt;span class=&quot;math-container&quot;&gt;$\lambda_u \in \{0,1\}$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if predefined group &lt;span class=&quot;math-container&quot;&gt;$u \in \Omega$&lt;/span&gt; is selected. Let &lt;span class=&quot;math-container&quot;&gt;$c_u$&lt;/span&gt; be the cost of group &lt;span class=&quot;math-container&quot;&gt;$u \in \Omega$&lt;/span&gt;. You want to minimize the cost of your selection:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \; \sum_{u \in \Omega}c_u \lambda_u&#xA;$$&lt;/span&gt;&#xA;subject to set covering constraints (a matrix item is selected exactly once):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{u \in \Omega, j\in u} \lambda_u = 1 \quad \mbox{for each matrix value }j&#xA;$$&lt;/span&gt;&#xA;You can, depending on your initial problem, limit the number of groups with convexity constraints (or impose a number of groups):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{u \in \Omega} \lambda_u \le K&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is an upper bound on the number of groups.&lt;/p&gt;&#xA;&lt;p&gt;Of course, this is only part of the problem, as you need to either predefine all possible groups (this may be an option depending on your problem) or  define them dynamically with a column generation approach. Without more knowledge of your problem, it is not possible to detail any more.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-12-03T14:20:50.353" LastActivityDate="2022-12-03T14:20:50.353" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9479" PostTypeId="1" AcceptedAnswerId="9480" CreationDate="2022-12-03T13:06:23.760" Score="2" ViewCount="131" Body="&lt;p&gt;Could you please check where I might be wrong?&#xA;Task is:&#xA;If &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt;, then either &lt;span class=&quot;math-container&quot;&gt;$x=1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My approach:&#xA;If &lt;span class=&quot;math-container&quot;&gt;$z=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x+y=1$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\implies x+y\le1$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\implies x+y\ge1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$z=0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x+y\ge0 - M\cdot(1-z)$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\implies x+y\ge-1 + z$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10750" LastEditorUserId="491" LastEditDate="2023-03-29T02:40:40.617" LastActivityDate="2023-03-29T02:40:40.617" Title="Conditional constraint for binary" Tags="|modeling|integer-programming|constraint-programming|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9480" PostTypeId="2" ParentId="9479" CreationDate="2022-12-03T13:24:20.247" Score="6" Body="&lt;p&gt;If all of the variables are binary, then the logical expression is equivalent to the:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ z=1 \rightarrow (x=1 \lor y=1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (1-z) \lor (x \lor y)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (1-z) + x + y \geq 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x + y -z \geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-12-03T13:24:20.247" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9481" PostTypeId="2" ParentId="9474" CreationDate="2022-12-03T13:54:04.073" Score="4" Body="&lt;p&gt;If you have a long equality constraint &lt;span class=&quot;math-container&quot;&gt;$x=\sum_j a_j y_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; appears multiple times in your model, performing the substitution can greatly increase the number of nonzero coefficients in the constraint matrix, and that typically hurts the performance.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-12-03T13:54:04.073" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9482" PostTypeId="2" ParentId="9434" CreationDate="2022-12-03T14:23:49.570" Score="3" Body="&lt;p&gt;Another approach I was trying to do, also based on @RobPratt hints, would be by substituting &lt;span class=&quot;math-container&quot;&gt;$y \geq 2$&lt;/span&gt; as an indicator constraint and changing the original logical expression into:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \{x_1 = 1 \wedge y \geq 2 \implies x_2 = 1\}  \rightarrow \{x_1 = 1 \land  \lnot z\implies x_2 = 1\}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lnot x_1 \lor  z \lor x_2$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(1-x_1) +  z + x_2 \geq 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-x_1 + x_2 + z \geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the second part we need to add:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y + Mz \leq 3$$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$M=2$&lt;/span&gt; to enforce &lt;span class=&quot;math-container&quot;&gt;$y\ge 2\implies \lnot z$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-12-03T14:23:49.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9483" PostTypeId="2" ParentId="9477" CreationDate="2022-12-03T20:10:36.000" Score="5" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$V_i$&lt;/span&gt; be the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th matrix value. One way to break symmetry would be to require that the groups be labeled in ascending order of their sum. The constraints would be &lt;span class=&quot;math-container&quot;&gt;$$\sum_i V_i x_{i1} \le \sum_i V_i x_{i2} \le \dots \le \sum_i V_i x_{iG}$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; is the desired number of groups. This has a better chance of helping when there is substantial diversity in the matrix entries (and thus, hopefully, the group sums).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-12-03T20:10:36.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9484" PostTypeId="2" ParentId="9432" CreationDate="2022-12-03T20:34:51.933" Score="2" Body="&lt;p&gt;First, your &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; should actually be &lt;span class=&quot;math-container&quot;&gt;$Z(x),$&lt;/span&gt; since the feasible region of the dual of the inner problem depends on &lt;span class=&quot;math-container&quot;&gt;$x.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Second, &lt;span class=&quot;math-container&quot;&gt;$$\max_{x\in X, z\in Z(x)}(cx - mz) \neq \max_{x\in X}(cx - \max_{z\in Z(x)} mz)$$&lt;/span&gt; since, for any given value of &lt;span class=&quot;math-container&quot;&gt;$x,$&lt;/span&gt; the left side looks for the value of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; that makes &lt;span class=&quot;math-container&quot;&gt;$mz$&lt;/span&gt; as small as possible and the right side looks for the value of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; that makes &lt;span class=&quot;math-container&quot;&gt;$mz$&lt;/span&gt; as large as possible.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-12-03T20:34:51.933" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9485" PostTypeId="1" CreationDate="2022-12-03T22:35:27.280" Score="2" ViewCount="402" Body="&lt;p&gt;I have a quadratic integer programming assignment problem. The goal is to assign riders seats on a bus such that distance between any two riders is maximized; however, the importance of each objective term (rider-rider distances) will be be scaled by the product of their priority scores, for example, elderly, disability, pregnancy, etc.&lt;/p&gt;&#xA;&lt;p&gt;This problem is analogous to a real world problem, which I am solving. The bus-seat example is fictitious, however, it illustrates the nature of my constraints and objectives nicely.&lt;/p&gt;&#xA;&lt;p&gt;I have attempted to solve this problem using CVXPY, however, then I get the following error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;DCPError: Problem does not follow DCP rules. Specifically:&#xA;The objective is not DCP. Its following subexpressions are not: (var7596[0] @ 5.0 + var7596[1] @ 4.0 + var7596[2] @ 3.0 + var7596[3] @ 2.0 + var7596[4] @ 1.0) @ (var7597[0] @ 5.0 + var7597[1] @ 4.0 + var7597[2] @ 3.0 + var7597[3] @ 2.0 + var7597[4] @ 1.0)...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Data&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;# Data&#xA;rider_priorities = {1:5,2:4,3:3,4:2,5:1}&#xA;num_riders = len(rider_priorities)&#xA;&#xA;x_wide, y_tall = 5,5&#xA;max_seats = x_wide * y_tall&#xA;num_seats = 0&#xA;seat_matrix = {}&#xA;for i in range(1, x_wide+1):&#xA;  for j in range(1, y_tall+1):&#xA;    num_seats +=1     &#xA;    seat_matrix[num_seats] = (i,j) &#xA;&#xA;import math&#xA;distance_matrix = {}&#xA;for i in seat_matrix.keys():&#xA;  i_x, i_y = seat_matrix[i]&#xA;  for j in seat_matrix.keys():&#xA;    if i==j:&#xA;      continue&#xA;    j_x, j_y = seat_matrix[j]&#xA;    euc_dist = math.sqrt((i_x - j_x)**2 + (i_y - j_y)**2)&#xA;    distance_matrix[(i,j)] = euc_dist    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And the actual problem formulation.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;# Variables &#xA;seat_rider_map = {}&#xA;for s in range(1, num_seats+1):&#xA;  seat_rider_map[s] = cp.Variable(shape=num_riders, boolean=True)&#xA;&#xA;&#xA;# Constraints&#xA;constraints = []&#xA;for seat, rider_arr in seat_rider_map.items():&#xA;  # each seat assigned 0 or 1 riders&#xA;  c = sum(rider_arr) &amp;lt;= 1 &#xA;  constraints.append(c)&#xA;&#xA;# each rider assigned exactly one seat&#xA;for r in range(num_riders):&#xA;  seat_arr = [seat_rider_map[seat][r] for seat in seat_rider_map.keys()]&#xA;  c = sum(seat_arr) == 1&#xA;  constraints.append(c)&#xA;&#xA;# Objective&#xA;objective_terms = []&#xA;for s1 in range(1, max_seats):&#xA;  for s2 in range(s1+1, max_seats+1):&#xA;&#xA;    r1_pri = sum([seat_rider_map[s1][r1-1] * p1 for r1,p1 in rider_priorities.items()])&#xA;    r2_pri = sum([seat_rider_map[s2][r2-1] * p2 for r2,p2 in rider_priorities.items()])&#xA;    # old formulation  &#xA;    # separation_penalty = r1_pri * r2_pri * distance_matrix[(s1,s2)]&#xA;&#xA;    #new formulation&#xA;    separation_penalty = r1_pri @ r2_pri &#xA;    separation_penalty *= distance_matrix[(s1,s2)]&#xA;    objective_terms.append(separation_penalty)&#xA;&#xA;objective = cp.Maximize(sum(objective_terms))&#xA;prob = cp.Problem(objective, constraints)&#xA;prob.solve()&#xA;&#xA;solution = {}&#xA;for seat, rider_arr in seat_rider_map.items():&#xA;  solution[seat] = rider_arr.value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I've seen other questions related to this error and answers have been about the function not being quadratic. However, as you can see from the error above, the terms are in fact quadratic.&lt;/p&gt;&#xA;&lt;p&gt;In the objective function, r1_pri and r2_pri are both summations of variables scaled by constants. Then r1_pri and r2_pri multiplied (only quadratic operation) and scaled by a constant. The objective is to maximize the summation of these constants.&lt;/p&gt;&#xA;&lt;p&gt;Could this error be triggered by something unrelated to non-quadratic operations? What does a solution look like?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: With the new formulation, I get an error from  &lt;code&gt;separation_penalty = r1_pri @ r2_pri&lt;/code&gt; : &lt;code&gt;ValueError: Scalar operands are not allowed, use '*' instead&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This is highly unexpected because this statement is a multiplication of two different variables, not constants.&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="8" LastEditDate="2023-01-11T06:18:43.467" LastActivityDate="2023-10-08T07:04:25.583" Title="MIQP — CVXPY unable to treat summation of variables as a variable" Tags="|mixed-integer-programming|python|quadratic-programming|cvxpy|disciplined-convex-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9486" PostTypeId="2" ParentId="9485" CreationDate="2022-12-03T23:04:39.643" Score="-1" Body="&lt;p&gt;In math programming whenever two variables are summed up or any kind of operation is conducted (-,*) and the resultant is used again in another operation, then it should be declared a variable. So separation_penalty should be declared as a variable first.&lt;br /&gt;&#xA;So if &lt;span class=&quot;math-container&quot;&gt;$z=xy$&lt;/span&gt; and again penalty= &lt;span class=&quot;math-container&quot;&gt;$dist*z$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; should be declared a var.&lt;br /&gt;&#xA;Only if &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is going to be used as objective without any further operation then it need not be declared a variable. It will be akin to like obj = &lt;span class=&quot;math-container&quot;&gt;$xy$&lt;/span&gt; instead of obj = &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-03T23:25:03.660" LastActivityDate="2022-12-03T23:25:03.660" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9487" PostTypeId="1" CreationDate="2022-12-04T07:07:59.640" Score="5" ViewCount="411" Body="&lt;p&gt;Recently, I have been working on Dantzig-Wolfe(DW) decomposition technique. I found enough online resources that show worked-out examples of how to solve linear problems using the DW method. But I did not find any resource which explains solving MILP/IP with a numerical example of DW method. Can anyone provide me with any article/link of a clear numerical example of the DW method for MILP/IP?&lt;/p&gt;&#xA;" OwnerUserId="5891" LastEditorUserId="727" LastEditDate="2022-12-04T20:00:17.827" LastActivityDate="2024-02-25T04:22:06.213" Title="Dantzig-Wolfe decomposition for mixed-integer problem" Tags="|mixed-integer-programming|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9488" PostTypeId="1" AcceptedAnswerId="9491" CreationDate="2022-12-04T09:17:16.543" Score="3" ViewCount="982" Body="&lt;p&gt;I am using the cvxpy library in python to solve a quadratic programming problem and the solver used is scip. I found that when the amount of data becomes large, the solution process will be particularly slow. Therefore, I am thinking about whether C++ can speed up the solution, such as some numerical calculation libraries in C++,alglib,nplot and so on.&lt;/p&gt;&#xA;&lt;p&gt;But I'm really not sure whether C++ will be faster. Because most of the time is consumed in the solving process, rather than the speed of code execution, I think the solvers used are similar, such as SCIP, OSQP and so on.&lt;/p&gt;&#xA;&lt;p&gt;If I want to switch to C++ to implement, then I should need a lot of time to learn those libraries, but I am not sure whether they are really useful, because I am afraid that I have done useless work, so I raised this question and wanted to know their speed is there really a big difference.&lt;/p&gt;&#xA;" OwnerUserId="10825" LastActivityDate="2022-12-04T15:55:41.063" Title="Is solving a quadratic programming optimization problem using python slower than C++？" Tags="|optimization|python|quadratic-programming|c++|cvxpy|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9489" PostTypeId="1" CreationDate="2022-12-04T10:51:31.947" Score="1" ViewCount="129" Body="&lt;p&gt;I have tuned my model with &lt;code&gt;grbtune&lt;/code&gt; and depending on the seed used, the runtime changes a lot: For example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Testing candidate parameter set 11 ...&#xA;&#xA;    Method 0&#xA;    MIPFocus 1&#xA;    Cuts 2&#xA;&#xA;Solving with random seed #1 ... runtime 1.85s&#xA;Solving with random seed #2 ... runtime 10.77s&#xA;Solving with random seed #3 ... runtime 10.51s&#xA;&#xA;Improvement found:&#xA;  baseline: mean runtime 14.85s&#xA;  improved: mean runtime 7.71s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How can I retrieve random seed #1 in this example and how can I set this seed (as far as I know, this should be possible, but the gurobi docs do not mention setting the seed)?&lt;/p&gt;&#xA;" OwnerUserId="10858" LastActivityDate="2022-12-04T10:51:31.947" Title="How to get seed from grbtune and set it in Gurobi?" Tags="|gurobi|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9490" PostTypeId="2" ParentId="9487" CreationDate="2022-12-04T10:58:53.547" Score="4" Body="&lt;p&gt;A nice example (&amp;quot;SpongeRollProblem&amp;quot;) is provided in the &lt;a href=&quot;https://github.com/coin-or/pulp/tree/master/examples&quot; rel=&quot;nofollow noreferrer&quot;&gt;PuLP Github repo&lt;/a&gt;, which is just a classical cutting stock problem.&lt;/p&gt;&#xA;&lt;p&gt;Different variations are implemented, which helps understanding the mechanics:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/coin-or/pulp/blob/master/examples/SpongeRollProblem1.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;SpongeRollProblem1&lt;/a&gt; and &lt;a href=&quot;https://github.com/coin-or/pulp/blob/master/examples/SpongeRollProblem2.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;SpongeRollProblem2&lt;/a&gt; are a decomposed version, where patterns (columns) are &lt;em&gt;&lt;strong&gt;given&lt;/strong&gt;&lt;/em&gt; beforehand as part of the data.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/coin-or/pulp/blob/master/examples/SpongeRollProblem3.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;SpongeRollProblem3&lt;/a&gt; and &lt;a href=&quot;https://github.com/coin-or/pulp/blob/master/examples/SpongeRollProblem4.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;SpongeRollProblem4&lt;/a&gt; are a decomposed version, where patterns (columns) are &lt;em&gt;&lt;strong&gt;computed beforehand&lt;/strong&gt;&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/coin-or/pulp/blob/master/examples/SpongeRollProblem5.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;SpongeRollProblem5&lt;/a&gt; and &lt;a href=&quot;https://github.com/coin-or/pulp/blob/master/examples/SpongeRollProblem6.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;SpongeRollProblem6&lt;/a&gt; are a decomposed version, where patterns (columns) are &lt;em&gt;&lt;strong&gt;computed dynamically&lt;/strong&gt;&lt;/em&gt; with a column generation approach. I suggest starting with SpongeRollProblem5, SpongeRollProblem6 is a just a columnwise implementation for more efficiency, but it may be a little harder to grasp if column generation is new to you.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In these examples, you are dealing with a MIP, and the way the integral solution is obtained is simply by solving the restricted master problem with integer variables (&lt;em&gt;price-and-branch&lt;/em&gt;). This does not guarantee optimality (unless you have generated all possible columns). &lt;a href=&quot;https://pypi.org/project/coinor.dippy/1.5.3/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dippy&lt;/a&gt; is an extension of PuLP which can do the &lt;em&gt;branch-and-price&lt;/em&gt; (the column generation procedure for solving the linear relaxation, embedded in a branch-and-bound framework) for you, but it is kind of a black box for users (the code is open source, but hard to understand).&lt;/p&gt;&#xA;&lt;p&gt;Note that the DW method refers to the formulation. It is typically combined with column generation, but these are two different concepts. Column generation is the algorithm which dynamically generates the variables of the linear relaxation of the DW formulation.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-12-04T12:24:13.873" LastActivityDate="2022-12-04T12:24:13.873" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9491" PostTypeId="2" ParentId="9488" CreationDate="2022-12-04T11:45:23.383" Score="3" Body="&lt;p&gt;As far as I know, the core of almost all of the optimization solvers has been written in C/C++ and other their available APIs are playing as a thin layer to exchange information on the both sides, unless one would like to write some specific callbacks or routines to deal solver, usually on the fly, that may change this too much. Also, you would find the same useful topics by searching in the community. I hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-12-04T11:45:23.383" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9492" PostTypeId="1" AcceptedAnswerId="9495" CreationDate="2022-12-04T12:06:28.380" Score="3" ViewCount="51" Body="&lt;p&gt;Suppose we have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; tasks. These tasks &lt;strong&gt;can not&lt;/strong&gt; be executed at the same time i.e. every task should be finished before starting the next task. Every task (&lt;span class=&quot;math-container&quot;&gt;$i=0,\cdots,n$&lt;/span&gt;) has a day in which it starts &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt;, has execution time &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt; and a day in which the task &amp;quot;has&amp;quot; to be finished &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt;. A task can have a longer execution time which causes the task te be finished after the day it has to be finished. Our goal is to minimize the maximum of time the execution time exceeds &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I couldn't seem to figure out how to formulate the constraint that only &lt;strong&gt;one&lt;/strong&gt; task can be executed at once. This is what I came up with (which is only the objective function and one constraint);&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$(s_i+t_i)-f_i) &amp;gt; 0$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min\max&amp;amp;\quad(\sum_{i=0}^{n}((s_i+t_i)-f_i)y)\\\text{s.t.}&amp;amp;\quad(s_i+t_i) \leq s_{i+1}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where we have that (I thought this was most straightforward) all &lt;span class=&quot;math-container&quot;&gt;$s_i,t,i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; are integers and counted on the real line. So for example today is day 0 where as next week on monday we are day 7.&lt;/p&gt;&#xA;&lt;p&gt;Anyone have any idea how to formulate this LP problem?&lt;/p&gt;&#xA;" OwnerUserId="10863" LastEditorUserId="123" LastEditDate="2022-12-04T15:18:21.060" LastActivityDate="2022-12-04T20:37:40.003" Title="Formulating a non-multitask constraint" Tags="|linear-programming|job-shop-scheduling|" AnswerCount="1" CommentCount="6" ClosedDate="2022-12-04T15:14:35.203" ContentLicense="CC BY-SA 4.0" />
  <row Id="9494" PostTypeId="1" AcceptedAnswerId="9519" CreationDate="2022-12-04T14:49:45.477" Score="1" ViewCount="128" Body="&lt;p&gt;In the benders decomposition, is it possible to decompose the master problem as follows and let the subproblem become the subproblem of the new subproblem? Let's say that we have the following problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a binary variable, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; are continuous and take values between &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x∈X, y∈Y}(cx - \min_{z∈Z(y)}dxz)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to decompose it further, as follows?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{Master Problem:}&amp;amp;\quad\max_{y∈Y} θ\\\text{Subproblem 1}&amp;amp;\quad\max_{x∈X(y)} cx\\\text{Subproblem 2}&amp;amp;\quad\min_{z∈Z(y)} d\bar xz\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subproblem 1 contains constraints that include &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Subproblem 2 contains constraints that include &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If yes, is there any sources to look up while developing the algorithm and constraints correctly to solve this problem? If not, what are the best ways to solve a large-scale master problem?&lt;/p&gt;&#xA;&lt;p&gt;Edit: There was maximization in subproblem 2 by mistake, changed it to minimization. Edited the notation.&lt;/p&gt;&#xA;" OwnerDisplayName="user5245" LastEditorDisplayName="user5245" LastEditDate="2022-12-05T07:53:25.497" LastActivityDate="2022-12-06T18:32:45.960" Title="Further decomposing master problem in benders" Tags="|optimization|combinatorial-optimization|benders-decomposition|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9495" PostTypeId="2" ParentId="9492" CreationDate="2022-12-04T15:14:48.233" Score="2" Body="&lt;p&gt;First of all, I have to state that I do not know how to formulate your problem as an LP model. However, I do know how to make it through an IP model. Thus, I will proceed with this strategy.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem definition&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Firstly, we will define our Non-Multitask Problem (NMP). An NMP instance is defined below. Let&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; be the set of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; tasks;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s_i \in \mathbb{R}$&lt;/span&gt; be the task &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; starting time;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t_i \in \mathbb{R}$&lt;/span&gt; be the task &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; execution time; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f_i \in \mathbb{R}_{\geqslant s_i}$&lt;/span&gt; be the task &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; &amp;quot;desired&amp;quot; ending time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;An NMP solution is defined as a function &lt;span class=&quot;math-container&quot;&gt;$g: T \rightarrow \mathbb{R}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$g(i)$&lt;/span&gt; stands for the task &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; ending time. A feasible NMP solution must satisfy the following rules:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$g(i) \geqslant s_i + t_i$&lt;/span&gt;, i.e. task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; ending time must encompass its task starting and execution times, &lt;span class=&quot;math-container&quot;&gt;$\forall i \in T$&lt;/span&gt;; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$g(j) \geqslant g(i) + t_j \vee g(j) \leqslant g(i) - t_i$&lt;/span&gt;, i.e. two distinct tasks cannot share the same execution time, &lt;span class=&quot;math-container&quot;&gt;$\forall i, j \in T: i\neq j$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The cost of an NMP solution is given by the function &lt;span class=&quot;math-container&quot;&gt;$c(g) = \sum_{i \in T} \max \{0, g(i) - f_i\}$&lt;/span&gt;, i.e. the cost is the sum of all exceding times.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;IP model&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Before moving to the model, let's take a look at some properties of this problem. If we consider&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A dummy deposit task &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;An unweighted complete digraph &lt;span class=&quot;math-container&quot;&gt;$D(V = T \cup \{d\}, A = \{ (i, j) : i, j \in V \wedge i \neq j \})$&lt;/span&gt;, such that each task &lt;span class=&quot;math-container&quot;&gt;$i \in V$&lt;/span&gt; is a node;&lt;/li&gt;&#xA;&lt;li&gt;Parameter &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt; as the node &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; service time; And&lt;/li&gt;&#xA;&lt;li&gt;Parameters &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; as node &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; time windows &lt;span class=&quot;math-container&quot;&gt;$[s_i, f_i]$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;We have a &lt;a href=&quot;https://doi.org/10.1287/opre.40.2.342&quot; rel=&quot;nofollow noreferrer&quot;&gt;VRPTW&lt;/a&gt; variant, in which the goal is to find a hamiltonian tour in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; such that starting times &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; are respected, and whose sum of all exceding times is minimized.&lt;/p&gt;&#xA;&lt;p&gt;With this insight, we move to the modeling of the problem. Below follows the list of variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_i \in \mathbb{R}$&lt;/span&gt; be the task &lt;span class=&quot;math-container&quot;&gt;$i \in V$&lt;/span&gt; ending time;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_i \in \mathbb{R}^{+}$&lt;/span&gt; be the task &lt;span class=&quot;math-container&quot;&gt;$i \in V$&lt;/span&gt; exceeding time; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij} \in \mathbb{B}$&lt;/span&gt; be the variable stating whether task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; immediately precedes task &lt;span class=&quot;math-container&quot;&gt;$j: (i, j) \in A$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;We will have the following objective function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min \sum_{i \in T} z_i$&lt;/span&gt; (1)&lt;/p&gt;&#xA;&lt;p&gt;And the following constraints.&lt;/p&gt;&#xA;&lt;p&gt;Task &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; exceeding time formula. Note that, by the definition of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z_i \geqslant 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_i \geqslant y_i - f_i$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in T$&lt;/span&gt; (2)&lt;/p&gt;&#xA;&lt;p&gt;Task &lt;span class=&quot;math-container&quot;&gt;$i \in T$&lt;/span&gt; ending time lower bound.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_i \geqslant s_i + t_i$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in T$&lt;/span&gt; (3)&lt;/p&gt;&#xA;&lt;p&gt;Reset dummy task &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; ending time.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_d = 0$&lt;/span&gt; (4)&lt;/p&gt;&#xA;&lt;p&gt;Routing flow constraints, that force each task to precede another task.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{a \in \delta^+(i)} x_a = \sum_{a \in \delta^-(i)} x_a = 1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in V$&lt;/span&gt; (5)&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://doi.org/10.1016/0167-6377(91)90083-2&quot; rel=&quot;nofollow noreferrer&quot;&gt;MTZ&lt;/a&gt; connectivity constraints, guarantee that all feasible solutions will be hamiltonian paths in &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;. Such that the big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is equals to &lt;span class=&quot;math-container&quot;&gt;$\max_{i \in T} \{ s_i \} + \sum_{i \in T} t_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_j \geqslant y_i + t_j - (1 - x_{ij}) M$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall (i, j) \in A$&lt;/span&gt; (6)&lt;/p&gt;&#xA;&lt;p&gt;And finally the domain constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z \in \mathbb{R}^{+|V|}$&lt;/span&gt; (7)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{R}^{|V|}$&lt;/span&gt; (8)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{B}^{|A|}$&lt;/span&gt; (9)&lt;/p&gt;&#xA;&lt;p&gt;Case any point is not clear, please let me know.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="491" LastEditDate="2022-12-04T20:37:40.003" LastActivityDate="2022-12-04T20:37:40.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9496" PostTypeId="1" AcceptedAnswerId="9497" CreationDate="2022-12-04T15:32:50.093" Score="2" ViewCount="474" Body="&lt;p&gt;Let's assume we have event &lt;span class=&quot;math-container&quot;&gt;$i=1,2,\cdots,k$&lt;/span&gt;, denoted as &lt;span class=&quot;math-container&quot;&gt;$\text{event}_i$&lt;/span&gt;. We know for a fact that &lt;span class=&quot;math-container&quot;&gt;$\text{event}_i$&lt;/span&gt; is smaller then &lt;span class=&quot;math-container&quot;&gt;$\text{event}_{i+1}$&lt;/span&gt; i.e., &lt;span class=&quot;math-container&quot;&gt;$\text{event}_i \leq \text{event}_{i+1}$&lt;/span&gt;. Now we have given some events &lt;span class=&quot;math-container&quot;&gt;$a,b,c,d \leq k$&lt;/span&gt;. How do I formulate the constraint that: if &lt;span class=&quot;math-container&quot;&gt;$\text{event}_a \leq \text{event}_b$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\text{event}_c \leq \text{event}_d$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;My try was:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{event}_a + Mz &amp;amp;&amp;gt; \text{event}_b\\\text{event}_c + M(1-z) &amp;amp;\leq \text{event}_d\end{align}&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$z \in\{0,1\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; large.&lt;/p&gt;&#xA;" OwnerUserId="10863" LastEditorUserId="500" LastEditDate="2022-12-04T15:49:41.637" LastActivityDate="2022-12-04T16:27:07.950" Title="If/then constraint formulation" Tags="|linear-programming|modeling|constraint-programming|logical-constraints|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9497" PostTypeId="2" ParentId="9496" CreationDate="2022-12-04T15:48:57.337" Score="7" Body="&lt;p&gt;You want to enforce the logical implication&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{event}_a \leq \text{event}_b \implies \text{event}_c \leq \text{event}_d.$$&lt;/span&gt;&#xA;Introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{event}_a \leq \text{event}_b \implies z = 1 \tag1\label1\\&#xA;z = 1 \implies \text{event}_c \leq \text{event}_d \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Equivalently, by contraposition of \eqref{1},&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z = 0 \implies \text{event}_a &amp;gt; \text{event}_b  \tag3\label3\\&#xA;z = 1 \implies \text{event}_c \leq \text{event}_d  \tag4\label4&#xA;\end{align}&lt;/span&gt;&#xA;Now big-M modeling yields&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{event}_b - \text{event}_a &amp;amp;&amp;lt; M_1 z \tag5\label5\\&#xA;\text{event}_c - \text{event}_d &amp;amp;\le M_2(1-z) \tag6\label6&#xA;\end{align}&lt;/span&gt;&#xA;This is very similar to what you tried, except that your second &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; needs the opposite sign.&#xA;Because MILP disallows strict inequalities, you need to introduce a positive tolerance &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; and replace \eqref{5} with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{event}_b - \text{event}_a +\epsilon \le M_1 z.$$&lt;/span&gt;&#xA;The effect is that you are enforcing&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{event}_a - \epsilon &amp;lt; \text{event}_b \implies \text{event}_c \leq \text{event}_d.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-12-04T16:27:07.950" LastActivityDate="2022-12-04T16:27:07.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9498" PostTypeId="2" ParentId="9488" CreationDate="2022-12-04T15:55:41.063" Score="2" Body="&lt;p&gt;Agree with Omidi.&lt;br /&gt;&#xA;One need to timeit and test timing of model loading/updating using one or two constraints using loops. Like Numpy/pandas in python allows vars to be listed in array/dataframe. That may vectorize it and may be faster than using, say, the sum function call from the solver API.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-04T15:55:41.063" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9499" PostTypeId="2" ParentId="7334" CreationDate="2022-12-04T17:27:07.377" Score="1" Body="&lt;p&gt;Not sure what the operation &lt;span class=&quot;math-container&quot;&gt;$\lceil a \rceil_ℓ$&lt;/span&gt; stands for, thus I will take this as the number, multiple of &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;, and greater than or equal to &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;First, let's focus on the &lt;em&gt;rounding-up&lt;/em&gt; part of the &lt;span class=&quot;math-container&quot;&gt;$\lceil a \rceil_ℓ$&lt;/span&gt; operation. Let &lt;span class=&quot;math-container&quot;&gt;$y_{uv} \in \mathbb{Q}$&lt;/span&gt; be our &lt;span class=&quot;math-container&quot;&gt;$\lceil \sum_{k \in K} q_k x_{uv}^k \rceil_ℓ$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall (u, v) \in A$&lt;/span&gt;, we will have the following constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{uv} \geqslant \sum_{k \in K} q_k x_{uv}^k$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall (u, v) \in A$&lt;/span&gt; (1)&lt;/p&gt;&#xA;&lt;p&gt;And then, let's focus on the &amp;quot;multiple of &lt;span class=&quot;math-container&quot;&gt;$ℓ$&lt;/span&gt;&amp;quot; part.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{uv} = z_{uv} ℓ$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall (u, v) \in A$&lt;/span&gt; (2)&lt;/p&gt;&#xA;&lt;p&gt;Such that, &lt;span class=&quot;math-container&quot;&gt;$z_{uv} \in \mathbb{N}$&lt;/span&gt; represents the multiple of &lt;span class=&quot;math-container&quot;&gt;$ℓ$&lt;/span&gt; composing &lt;span class=&quot;math-container&quot;&gt;$y_{uv}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;With these two constraints sets, we then have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{v : (u, v) \in A} y_{uv} \leqslant Q_u$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall u \in U$&lt;/span&gt; (3)&lt;/p&gt;&#xA;&lt;p&gt;Case any point is not clear, please let me know.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="2862" LastEditDate="2022-12-06T10:41:36.657" LastActivityDate="2022-12-06T10:41:36.657" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9500" PostTypeId="2" ParentId="9410" CreationDate="2022-12-04T20:05:33.713" Score="1" Body="&lt;p&gt;Try using pyomo quicksum instead of sum for defining the additional_rule. Quicksum improves efficiency with scale. Also please check if you are using latest and compatible Python &amp;amp; Pyomo version.&lt;br /&gt;&#xA;Also check if in the additional_rule using &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; rather than &lt;span class=&quot;math-container&quot;&gt;$==$&lt;/span&gt; makes any difference, since objective is being maximized. Tight constraints sometimes take more time.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-04T20:18:29.377" LastActivityDate="2022-12-04T20:18:29.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9501" PostTypeId="2" ParentId="9423" CreationDate="2022-12-04T20:08:09.640" Score="3" Body="&lt;p&gt;In general, JuMP does not support querying the best fractional solution of a branch and bound tree.&lt;/p&gt;&#xA;&lt;p&gt;However, if you are using CPLEX or Gurobi, you can write a solver-specific callback to do what you want.&lt;/p&gt;&#xA;&lt;p&gt;Since you tagged &lt;code&gt;CPLEX&lt;/code&gt;, use something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using JuMP, CPLEX&#xA;model = direct_model(CPLEX.Optimizer())&#xA;# This is very, very important!!! Only use callbacks in single-threaded mode.&#xA;MOI.set(model, MOI.NumberOfThreads(), 1)&#xA;@variable(model, x[1:100], Bin)&#xA;@constraint(model, rand(100)' * x &amp;lt;= 10)&#xA;@objective(model, Max, rand(100)' * x)&#xA;best_value, best_solution = Inf, fill(NaN, num_variables(model))&#xA;function my_callback_function(cb_data, context_id)&#xA;    if callback_node_status(cb_data, model) == MOI.CALLBACK_NODE_STATUS_FRACTIONAL&#xA;        valueP = Ref{Cdouble}()&#xA;        CPXcallbackgetrelaxationpoint(cb_data, C_NULL, 0, -1, valueP)&#xA;        if valueP[] &amp;lt; best_value&#xA;            global best_value = valueP[]&#xA;            CPLEX.load_callback_variable_primal(cb_data, context_id)&#xA;            best_solution .= callback_value.(cb_data, all_variables(model))&#xA;            @info &amp;quot;New upper bound: $best_value&amp;quot;&#xA;        end    &#xA;    end&#xA;    return&#xA;end&#xA;MOI.set(model, CPLEX.CallbackFunction(), my_callback_function)&#xA;optimize!(model)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="804" LastActivityDate="2022-12-04T20:08:09.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9502" PostTypeId="1" AcceptedAnswerId="9505" CreationDate="2022-12-04T20:24:30.700" Score="1" ViewCount="163" Body="&lt;p&gt;&lt;strong&gt;Current status on the problem (what I've done)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm working on a NLP problem and I got a formulation of the problem, together with the necessary constraints, but I think it needs some adjustments to ensure feasibility and efficiency.&lt;/p&gt;&#xA;&lt;p&gt;I was using the NLP-solver 'Ipopt' but switched to 'SCIP' and 'Bonmin' because of the binary variables I'm using. SCIP seems to have a lot of trouble with finding a solution as it keeps on running. I can limit the time and then stop it: it gives me a more or less optimal solution but the result shows that my constraints are not enforcing what I want. The Bonmin-solver gives me an error ('solver didn't exit normally'), but on other problems I have, Bonmin works just fine. This makes me think that my constraints are overcomplicated or not stated correctly. Therefore this question.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The problem formulation (what I want)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;We have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; items (&lt;span class=&quot;math-container&quot;&gt;$i=1, 2, \dots, n$&lt;/span&gt;) and every item has (constant) parameters &lt;span class=&quot;math-container&quot;&gt;$D_i =$&lt;/span&gt; demand and &lt;span class=&quot;math-container&quot;&gt;$P_i =$&lt;/span&gt; price. We rank the items on the demand-parameter, so &lt;span class=&quot;math-container&quot;&gt;$D_i \ge D_{i+1}$&lt;/span&gt;. After this, we calculate a new parameter &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; per item as the cumulative demand, so &lt;span class=&quot;math-container&quot;&gt;$c_i= \sum_{j=1}^i D_i$&lt;/span&gt;  for &lt;span class=&quot;math-container&quot;&gt;$i = 1, 2, \dots, n$&lt;/span&gt;. And we know that &lt;span class=&quot;math-container&quot;&gt;$c_n = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ c_i \le c_{i+1}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now we want to assign a variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to ever item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; where we have the constraint that &lt;span class=&quot;math-container&quot;&gt;$x_i \ge x_{i+1}$&lt;/span&gt; Then a nonlinear function &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is applied with arguments &lt;span class=&quot;math-container&quot;&gt;$x_i, c_i, D_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt; and this function needs to be minimized with the constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n D_ix_i = \beta \sum_{i=1}^n D_i$$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$0 \le \beta \lt 1$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; is a fixed parameter.&lt;/p&gt;&#xA;&lt;p&gt;BUT.&lt;/p&gt;&#xA;&lt;p&gt;We want to split up the items in &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; classes based on the variable &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; (the cumulative demand). We want to do this by assigning two boundaries &lt;span class=&quot;math-container&quot;&gt;$b_1, b_2$&lt;/span&gt; that can split up the items with the simple logical expression: &lt;em&gt;&amp;quot;if &lt;span class=&quot;math-container&quot;&gt;$c_i \le b_1$&lt;/span&gt; then class 1, if &lt;span class=&quot;math-container&quot;&gt;$b_1 \lt c_i \le b_2$&lt;/span&gt; then class 2, else class 3&amp;quot;.&lt;/em&gt; Then every class gets one of the 3 &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;-variables : &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2, x_3$&lt;/span&gt;. So we don't have a &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;-variable but only &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; variables &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now we always want 3 classes and &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; is always assigned to class 1, &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; to class 2 and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; to class 3.&lt;/p&gt;&#xA;&lt;p&gt;Let&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \le x_3 \le x_2 \le x_1 \le 1-\delta$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; is small value like &lt;span class=&quot;math-container&quot;&gt;$0.0001$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 + \epsilon \le b_1 \le b_2 - \epsilon \le 1-\epsilon$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is high enough to make sure there are &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; classes.&lt;/p&gt;&#xA;&lt;p&gt;To formulate it mathematically, I'm using binary variables and create a new variable &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x_1, x_2, x_3, b_1, b_2} g(D_i, P_i, z_i)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n D_iz_i = \beta \sum_{i=1}^n D_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_i = a_{i1}x_1 + a_{i2}x_2 +a_{i3}x_3$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b_1-c_i \le a_{i1}M$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_i -b_2 \le a_{i3}M$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{i1}+a_{i2}+a_{i3} = 1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_i-b_1 \le Mk_{i1}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b_2 - c_i \le Mk_{i2}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$k_{i1}+ k_{i2} - 1 \le a_{i2}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b_1 \le b_2 - \epsilon$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_3 \le x_2 \le x_1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;, where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a large constant.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{i1}, a_{i2}, a_{i3} \in \{0, 1\}$&lt;/span&gt; and initialized to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \le x_1, x_2, x_3 \lt 1$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b_1, b_2 \in [0+\epsilon, 1-\epsilon]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$k_{i1}, k_{i2} \in \{0, 1\}$&lt;/span&gt; and initialized to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Which constraints need to be adjusted or added to ensure everything I want? It doesn’t enforces &lt;span class=&quot;math-container&quot;&gt;$z_i \ge z_{i+1}$&lt;/span&gt; which is something I want. But how can I write a constraint that enforces this? And how can I generally improve the mathematical formulation?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2022-12-04T22:41:07.070" LastActivityDate="2022-12-05T17:02:51.093" Title="How to formulate this NLP problem correctly?" Tags="|constraint|nonlinear-programming|minlp|nlp|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9503" PostTypeId="1" AcceptedAnswerId="9509" CreationDate="2022-12-04T21:24:11.330" Score="1" ViewCount="201" Body="&lt;p&gt;Does the cvxpy replace the max function, which is convex, by MIP formulation under the hood when shows up in the constraints (for example, &lt;span class=&quot;math-container&quot;&gt;$\max(x,y)\le z$&lt;/span&gt;) or in the objective function?  In gurobipy, we need to introduce a new variable and new constraint: &lt;span class=&quot;math-container&quot;&gt;$L=\max(x,y)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L\le z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then gurobipy converts it to MIP.&lt;/p&gt;&#xA;&lt;p&gt;for example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;m=gp.Model()&#xA;x=m.addvar(vtype='C')       &#xA;y=m.addvar(vtype='C')       &#xA;z=m.addvar(vtype='C')       &#xA;L=m.addvar(vtype='C')       # new variable &#xA;m.addConstr(L=gp.max_(x,y)) # new constraint&#xA;m.addaddConstr(L&amp;lt;=z)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;L=gp.max_(x,y)&lt;/code&gt; is nonconvex, and gurobipy converts it to MIP convex under the hood.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max(x,y)\le z$&lt;/span&gt;&#xA;can b formulated in cvxpy as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import cvxpy as cp&#xA;Cons=[cp.max(x,y)&amp;lt;=z]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Does cvxpy do something similar to gurobipy?&lt;/p&gt;&#xA;&lt;p&gt;Thanks, @xd y!&#xA;My problem was the following: &lt;span class=&quot;math-container&quot;&gt;$$g+z\ge\max(x,y)+L$$&lt;/span&gt; Does that mean it can be rewritten as &lt;span class=&quot;math-container&quot;&gt;$g+z\ge x+L$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$g+z\ge y+L$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10454" LastEditorUserId="123" LastEditDate="2022-12-05T18:09:37.937" LastActivityDate="2022-12-05T18:09:37.937" Title="Does the cvxpy replace the max function by MIP formulation under the hood?" Tags="|gurobi|convex-optimization|constraint-programming|nonconvex-programming|cvxpy|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9504" PostTypeId="2" ParentId="9502" CreationDate="2022-12-04T21:25:01.503" Score="-2" Body="&lt;p&gt;Using gurobi and python..Used an arbitrary objective g involving D,p &amp;amp; z. It gives a feasible model. Let me know if I should try with diff parameters.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;n=8&#xA;item=[*range(n)]&#xA;p = {0:3,1:2,2:4,3:5.5,4:2.5,5:6,6:4,7:3.2}&#xA;D = {0:10,1:12,2:14,3:15.5,4:12.5,5:16,6:14,7:13.2}&#xA;c = {i:D[i]+c[i-1] for i in item[1:]}&#xA;c.update({0:D[0]})&#xA;#print(c)&#xA;e,ep,M = 1e-1,1e-3,200&#xA;&#xA;model = Model('Test')&#xA;beta = model.addVar(ub=1-ep,name='beta')&#xA;z = model.addVars(item,name='z',ub=1)&#xA;b1 = model.addVar(name='b1',ub=1-e,lb=e)&#xA;b2 = model.addVar(name='b2',ub=1-e,lb=e)&#xA;a = model.addVars(item,[1,2,3],vtype='b',name='a')&#xA;x = model.addVars([1,2,3],ub=0.999,name='x')&#xA;k = model.addVars(item,[1,2],vtype='b',name='k')&#xA;#x = [1,2,3]# x3,x2,x1&#xA;&#xA;#Constraints&#xA;#Dz = betaD&#xA;C1 = model.addConstr(z.prod(D) == beta*c[n-1],'C1')&#xA;&#xA;C2 = model.addConstrs((b1 - c[i] &amp;lt;= a[i,1]*M for i in item),'C2')&#xA;C3 = model.addConstrs((c[i] - b2 &amp;lt;= a[i,3]*M for i in item),'C3')&#xA;&#xA;C4 = model.addConstrs((c[i] - b1 &amp;lt;= k[i,1]*M for i in item),'C4')&#xA;C5 = model.addConstrs((b2 - c[i] &amp;lt;= k[i,2]*M for i in item),'C5')&#xA;C6 = model.addConstrs((k[i,1] + k[i,2] - 1 &amp;lt;= a[i,2] for i in item),'C6')&#xA;&#xA;C7 = model.addConstrs((a.sum(i,'*') == 1 for i in item),'C7')&#xA;&#xA;C8 = model.addConstr(b1 &amp;lt;= b2 - e,'C8')&#xA;&#xA;C9_1 = model.addConstr(x[3] &amp;lt;= x[2],'C9_1')&#xA;C9_2 = model.addConstr(x[2] &amp;lt;= x[1],'C9_2')&#xA;&#xA;C10 = model.addConstrs((z[i] == a[i,1]*x[1]+a[i,2]*x[2]+a[i,3]*x[3] for i in item),'C9')&#xA;&#xA;#Objective&#xA;g = quicksum(D[i]*p[i] for i in item) + quicksum(z[i] for i in item)&#xA;model.update()&#xA;model.setObjective(g,GRB.MINIMIZE)&#xA;model.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-04T21:25:01.503" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9505" PostTypeId="2" ParentId="9502" CreationDate="2022-12-04T22:58:39.937" Score="2" Body="&lt;p&gt;Notation alert: I will use &lt;span class=&quot;math-container&quot;&gt;$g(i)\in \lbrace 1,2,3 \rbrace$&lt;/span&gt; to denote the group into which item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is placed. So your &lt;span class=&quot;math-container&quot;&gt;$D_i z_i$&lt;/span&gt; is my &lt;span class=&quot;math-container&quot;&gt;$D_i x_{g(i)}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Introduce new continuous variables &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$D_i x_{g(i)}.$&lt;/span&gt; We define them via the constraints &lt;span class=&quot;math-container&quot;&gt;$$D_i [x_j - (1-a_{i,j})] \le w_i \le D_i [x_j + (1-a_{i,j})] \quad \forall i=1,\dots,n; \forall j=1,2,3.$$&lt;/span&gt; If item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is in group &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$a_{i,j}=1$&lt;/span&gt;), then &lt;span class=&quot;math-container&quot;&gt;$w_i = D_i x_j.$&lt;/span&gt; Otherwise &lt;span class=&quot;math-container&quot;&gt;$a_{i,j}=0$&lt;/span&gt; and the constraint that &lt;span class=&quot;math-container&quot;&gt;$x_j &amp;lt; 1,$&lt;/span&gt; along with the presumption that &lt;span class=&quot;math-container&quot;&gt;$D_i &amp;gt; 0,$&lt;/span&gt; means &lt;span class=&quot;math-container&quot;&gt;$$D_i [x_j - (1-a_{i,j})] &amp;lt; 0 \le D_i x_{g(i)}$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$D_i [x_j + (1-a_{i,j})] &amp;gt; D_i \ge D_i x_{g(i)},$$&lt;/span&gt; making the constraints nonbinding.&lt;/p&gt;&#xA;&lt;p&gt;You already have the constraint &lt;span class=&quot;math-container&quot;&gt;$a_{i,1}+a_{i,2}+a_{i,3}=1,$&lt;/span&gt; ensuring each item is assigned to a unique group. What is left is to enforce monotonicity with respect to cumulative demand. We can do that with the constraint  &lt;span class=&quot;math-container&quot;&gt;$$a_{i,1} + 2a_{i,2} +3 a_{i,3} \le a_{i+1,1} + 2a_{i+1,2} +3 a_{i+1,3}\quad \forall i=1,\dots,n-1.$$&lt;/span&gt; That simply says that no item is assigned to a higher index group than the next item.&lt;/p&gt;&#xA;&lt;p&gt;Assuming the &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; variables were concocted only to achieve the monotonic group assignments, you can presumably drop them and &lt;span class=&quot;math-container&quot;&gt;$M.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Addendum: To ensure that all three classes are used, we can add the constraints &lt;span class=&quot;math-container&quot;&gt;$$\sum_i a_{i,j} \ge 1 \quad j=1,2,3.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-12-05T17:02:51.093" LastActivityDate="2022-12-05T17:02:51.093" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9506" PostTypeId="2" ParentId="9503" CreationDate="2022-12-04T23:39:58.567" Score="2" Body="&lt;p&gt;Natively I am not sure since solvers that come do not have MIP capability&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.cvxpy.org/tutorial/advanced/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Scroll down for list of solvers&lt;/a&gt;&#xA;And this &lt;a href=&quot;https://www.cvxpy.org/_modules/cvxpy/atoms/max.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;link to source code max&lt;/a&gt; seems to suggest it uses max function.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-04T23:39:58.567" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9507" PostTypeId="1" CreationDate="2022-12-05T00:50:41.833" Score="4" ViewCount="100" Body="&lt;p&gt;Here is the constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{Pa} + \text{Pb}=a + b \sqrt{\text{Ir}^2 +\text{Ii}^2} + c (\text{Ir}^2 +\text{Ii}^2)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$\text{Pa}, \text{Pb}, \text{Ir},$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\text{Ii}$&lt;/span&gt; are variables. &lt;span class=&quot;math-container&quot;&gt;$a, b, c$&lt;/span&gt; are given parameters.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{Pa} &amp;gt;0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\text{Pb}&amp;gt;0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$-\text{Imax} \leq \text{Ir} \leq \text{Imax}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$-\text{Imax} \leq \text{Ii} \leq \text{Imax}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10869" LastEditorUserId="123" LastEditDate="2022-12-05T18:07:58.227" LastActivityDate="2022-12-05T18:07:58.227" Title="How to linearize or convexify a constraint with a square root of sum of two variables?" Tags="|linear-programming|nonlinear-programming|convex-optimization|nonconvex-programming|ipopt|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9508" PostTypeId="2" ParentId="8809" CreationDate="2022-12-05T01:14:42.757" Score="1" Body="&lt;p&gt;Another option is to solve your problem with a hybrid approach, a math-heuristic. For example, you could use a metaheuristic to define some of the variables (maybe, the integer ones) and then solve the parametrized problem using MILP solver. For example, several ideas can be found &lt;a href=&quot;https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8802783/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;https://ieeexplore.ieee.org/abstract/document/9904763&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/B9780128185971500291&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S1568494613001282&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, and &lt;a href=&quot;https://www.semanticscholar.org/paper/Hybridizing-exact-methods-and-metaheuristics%3A-A-Vermeulen-Jourdan-Basseur/c31233681fe257a940292cd58ae8e7097695ca77&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2022-12-05T01:14:42.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9509" PostTypeId="2" ParentId="9503" CreationDate="2022-12-05T02:04:40.677" Score="2" Body="&lt;p&gt;No. Firstly you should use &lt;code&gt;cp.maximum&lt;/code&gt; instead of &lt;code&gt;cp.max&lt;/code&gt;. Secondly, it is converted to a convex programming problem (LP in this case, like &lt;span class=&quot;math-container&quot;&gt;$x \leq z, y \leq z$&lt;/span&gt;) since it follows &lt;a href=&quot;https://www.cvxpy.org/tutorial/dcp/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;DCP&lt;/a&gt; rules, rather than introducing binary variables. To see that, you can try &lt;code&gt;Cons=[cp.maximum(x, y) &amp;gt;= z]&lt;/code&gt; and solving the problem, you will see it fails to solve it.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2022-12-05T02:04:40.677" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9510" PostTypeId="2" ParentId="9463" CreationDate="2022-12-05T03:15:47.070" Score="2" Body="&lt;p&gt;With SAS, for both &lt;a href=&quot;https://go.documentation.sas.com/doc/en/pgmsascdc/v_033/casmopt/casmopt_optmodel_details57.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;automated linearization&lt;/a&gt; and &lt;a href=&quot;https://go.documentation.sas.com/doc/en/pgmsascdc/v_033/casmopt/casmopt_optmodel_details63.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;automated conic transformation&lt;/a&gt;, you can use the &lt;a href=&quot;https://go.documentation.sas.com/doc/en/pgmsascdc/v_033/casmopt/casmopt_optmodel_syntax11.htm#casmopt.optmodel.npxexpandstmt&quot; rel=&quot;nofollow noreferrer&quot;&gt;EXPAND statement in PROC OPTMODEL&lt;/a&gt; to see the transformed model.  The syntax is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;expand / linearize;&#xA;expand / conic;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For linearization, you can also save the linearized model to MPS format:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;save mps mymps linearize;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Disclaimer: I work at SAS.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-12-05T03:15:47.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9511" PostTypeId="1" AcceptedAnswerId="9521" CreationDate="2022-12-05T07:45:48.763" Score="3" ViewCount="715" Body="&lt;p&gt;I have a Mixed Complementarity Problem (MCP) that represents a market under perfect competition. The model is written in GAMS and works as expected. But when translating it to Python, using Pyomo, the model is infeasible. Both models use the Path solver.&lt;/p&gt;&#xA;&lt;p&gt;It appears to be the Pyomo c1_rule constraint that is causing infeasibility. If I change the Pyomo c1_rule relationship to be &amp;lt;= rather than == then the model solves to optimality, but the solution makes no sense.&lt;/p&gt;&#xA;&lt;p&gt;Any ideas about what I'm doing wrong?&lt;/p&gt;&#xA;&lt;p&gt;The variables and equations in GAMS are:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;positive variables&#xA;  Production(g),&#xA;  Demand;&#xA;&#xA;free variables&#xA;  Price;&#xA;&#xA;elasticity = -0.3;&#xA;p0   = 20;&#xA;g0   = 3000;&#xA;rho  = p0 / elasticity / g0;&#xA;&#xA;Production.up(g) = StatData(g, 'GenMax');&#xA;&#xA;equations&#xA;  SRMC(g),&#xA;  PriceCurve,&#xA;  Balance;&#xA;&#xA;  SRMC(g)..     MarginalCost(g) - Price =e= 0;&#xA;  PriceCurve..  Price - (p0 + rho * (Demand - g0)) =e= 0;&#xA;  Balance..     sum(g, Production(g)) - Demand =e= 0;&#xA;&#xA;model PerfectComp / SRMC.Production, Balance.Price, PriceCurve.Demand /;&#xA;&#xA;solve PerfectComp using MCP;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Equivalent code in Pyomo:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Model.Elasticity = pyo.Param(within = pyo.Reals, initialize = -0.3)&#xA;Model.pSet = pyo.Param(within = pyo.NonNegativeReals, initialize = 20)&#xA;Model.qSet = pyo.Param(within = pyo.NonNegativeReals, initialize = 3000)&#xA;&#xA;Rho = Model.pSet / Model.Elasticity / Model.qSet&#xA;&#xA;Model.Production = pyo.Var(Model.Generators, domain = pyo.NonNegativeReals)&#xA;Model.Demand = pyo.Var(domain = pyo.NonNegativeReals)&#xA;Model.Price = pyo.Var(domain = pyo.Reals)&#xA;&#xA;def rule_capacity(Model, S):&#xA;    return Model.Production[S] &amp;lt;= Model.GMax[S]&#xA;Model.MaxCapacity = pyo.Constraint(Model.Generators, rule = rule_capacity)&#xA;&#xA;def c1_rule(Model, S):&#xA;    return mpec.complements(Model.VarCost[S] - Model.Price == 0, Model.Production[S] &amp;gt;= 0)&#xA;&#xA;def c2_rule(Model):&#xA;    return mpec.complements(Model.Price - (Model.pSet + Rho * (Model.Demand - Model.qSet)) == 0, Model.Demand &amp;gt;= 0)&#xA;&#xA;def c3_rule(Model):&#xA;    return mpec.complements(sum(Model.Production[s] for s in Model.Generators) - Model.Demand == 0, Model.Price)&#xA;&#xA;Model.c1 = mpec.Complementarity(Model.Generators, rule = c1_rule)&#xA;Model.c2 = mpec.Complementarity(rule = c2_rule)&#xA;Model.c3 = mpec.Complementarity(rule = c3_rule)&#xA;&#xA;Solver = pyo.SolverFactory('path')&#xA;Results = Solver.solve(Model, load_solutions = False, tee = True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5128" LastActivityDate="2022-12-07T03:57:45.477" Title="Convert MCP model from GAMS to Pyomo" Tags="|pyomo|gams|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9512" PostTypeId="2" ParentId="4667" CreationDate="2022-12-05T08:58:30.803" Score="2" Body="&lt;p&gt;Just adding two more options. &lt;a href=&quot;https://pymoo.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pymoo&lt;/a&gt; is a good option, it has several algorithms and functionality for creating your own. And &lt;a href=&quot;https://anyoptimization.com/projects/pysamoo/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pysamoo&lt;/a&gt; is the version for surrogated (multiobjective) optimization.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2022-12-05T08:58:30.803" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9513" PostTypeId="2" ParentId="6211" CreationDate="2022-12-05T09:18:30.600" Score="4" Body="&lt;p&gt;From the official CPLEX documentation &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=SSSA5P_20.1.0/ilog.odms.cplex.help/refpythoncplex/html/cplex._internal._subinterfaces.SolutionInterface-class.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; (CPLEX 20.1): &lt;code&gt;SolutionInterface.get_dual_values()&lt;/code&gt; does indeed return the Lagrange/dual values.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-12-05T09:18:30.600" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9514" PostTypeId="2" ParentId="9511" CreationDate="2022-12-05T12:14:17.623" Score="4" Body="&lt;p&gt;I am not sure how an MCP solver/wrapper works, but it seems the solving process, somewhat, is similar to the Lagrangian relaxation method.&lt;/p&gt;&#xA;&lt;p&gt;In the following picture you can see a simple transportation problem and whose equivalent MCP that implemented in GAMS.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7baaE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7baaE.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, for more details took a look at these links:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.mpsge.org/shock/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;An Illustrative GAMS/MCP Model&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Richard W. Cottle, Jong-Shi Pang, Richard E. Stone, The Linear Complementarity Problem, Academic Press, 1992.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www-personal.umich.edu/%7Emurty/books/linear_complementarity_webbook/lcp-complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linear complementarity webbook&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://gist.github.com/anthonydouc/3d90c9e10674b6e05a9c998a8493d412&quot; rel=&quot;nofollow noreferrer&quot;&gt;Simple example for solving an mcp with Pyomo and PATH Solver&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/44199750/7414813&quot;&gt;Mixed Complementarity (MCP) Pyomo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-12-05T12:14:17.623" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9515" PostTypeId="2" ParentId="9511" CreationDate="2022-12-05T19:18:58.670" Score="3" Body="&lt;p&gt;In GAMS and Pyomo please check the order of the equations in the complementary constraints lest you are passing &lt;span class=&quot;math-container&quot;&gt;$-F$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; where F is the function expressing the constraints. Based on this &lt;a href=&quot;https://www.gams.com/latest/docs/S_PATH.html#PATH_COMPLEMNTARITY&quot; rel=&quot;nofollow noreferrer&quot;&gt;guide&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-05T19:18:58.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9517" PostTypeId="2" ParentId="9511" CreationDate="2022-12-06T01:56:35.303" Score="5" Body="&lt;p&gt;You need to get the inequalities correct for each complementarity constraint, and you need to use &lt;code&gt;pyo.inequality&lt;/code&gt; to pass a double-sided inequality around the production variables:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;from pyomo import mpec&#xA;&#xA;model = pyo.ConcreteModel()&#xA;GENERATORS = [0, 1]&#xA;var_cost = [1.0, 1.0]&#xA;elasticity, pSet, qSet = -0.3, 20, 3_000&#xA;Rho = pSet / elasticity / qSet&#xA;model.production = pyo.Var(GENERATORS)&#xA;model.demand = pyo.Var()&#xA;model.price = pyo.Var()&#xA;&#xA;def c1_rule(model, g):&#xA;    return mpec.complements(var_cost[g] - model.price, pyo.inequality(0, model.production[g], 1))&#xA;&#xA;def c2_rule(model):&#xA;    return mpec.complements(model.price - (pSet + Rho * (model.demand - qSet)) &amp;gt;= 0, model.demand &amp;gt;= 0)&#xA;&#xA;def c3_rule(model):&#xA;    return mpec.complements(sum(model.production[g] for g in GENERATORS) - model.demand == 0, model.price)&#xA;&#xA;model.c1 = mpec.Complementarity(GENERATORS, rule = c1_rule)&#xA;model.c2 = mpec.Complementarity(rule = c2_rule)&#xA;model.c3 = mpec.Complementarity(rule = c3_rule)&#xA;&#xA;opt = pyo.SolverFactory('pathampl')&#xA;results = opt.solve(model, tee = True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For what it's worth, here's what I get if I solve the problem using &lt;a href=&quot;https://jump.dev&quot; rel=&quot;nofollow noreferrer&quot;&gt;JuMP&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using JuMP, PATHSolver&#xA;# =====================&#xA;# This part is a guess&#xA;GENERATORS = 1:2&#xA;var_cost = [1.0, 1.0]&#xA;g_max = [1.0, 1.0]&#xA;# =====================&#xA;elasticity, pSet, qSet = -0.3, 20, 3000&#xA;ρ = pSet / elasticity / qSet&#xA;model = Model(PATHSolver.Optimizer)&#xA;@variables(model, begin&#xA;    0 &amp;lt;= production[g = GENERATORS] &amp;lt;= g_max[g]&#xA;    demand &amp;gt;= 0&#xA;    price&#xA;end)&#xA;@constraints(model, begin&#xA;    [g in GENERATORS], var_cost[g] - price ⟂ production[g]&#xA;    price - (pSet + ρ * (demand - qSet)) ⟂ demand&#xA;    sum(production) - demand ⟂ price&#xA;end)&#xA;optimize!(model)&#xA;&#xA;julia&amp;gt; solution_summary(model; verbose = true)&#xA;* Solver : Path 5.0.03&#xA;&#xA;* Status&#xA;  Termination status : LOCALLY_SOLVED&#xA;  Primal status      : FEASIBLE_POINT&#xA;  Dual status        : NO_SOLUTION&#xA;  Result count       : 1&#xA;  Has duals          : false&#xA;  Message from the solver:&#xA;  &amp;quot;The problem was solved&amp;quot;&#xA;&#xA;* Candidate solution&#xA;  Objective value      : 0.00000e+00&#xA;  Primal solution :&#xA;    demand : 2.00000e+00&#xA;    price : 8.66222e+01&#xA;    production[1] : 1.00000e+00&#xA;    production[2] : 1.00000e+00&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="804" LastEditorUserId="804" LastEditDate="2022-12-06T19:29:28.967" LastActivityDate="2022-12-06T19:29:28.967" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9519" PostTypeId="2" ParentId="9494" CreationDate="2022-12-06T18:32:45.960" Score="1" Body="&lt;p&gt;You have an undefined symbol &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; in subproblem 2. Assuming that is the &lt;span class=&quot;math-container&quot;&gt;$x\in X$&lt;/span&gt; from subproblem 1, I don't think you can apply Benders, because in subproblem 2 you have both the objective function and the right hand side depending on a candidate solution to the master problem (&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in the objective, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in the RHS). One or the other would be OK, but not (as far as I know) both.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-12-06T18:32:45.960" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9520" PostTypeId="2" ParentId="7334" CreationDate="2022-12-06T19:05:07.610" Score="1" Body="&lt;p&gt;While waiting for Joris to say if &lt;span class=&quot;math-container&quot;&gt;$Q_u$&lt;/span&gt; may be rounded up, I'll take the cue from Matheus Andrade and modify the problem constraints as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$q_{uv}^k$&lt;/span&gt; as the quantity. I'd avoid &lt;span class=&quot;math-container&quot;&gt;$x_{uv}$&lt;/span&gt; binary because &lt;span class=&quot;math-container&quot;&gt;$q_{uv}^k = 0$&lt;/span&gt; will mean commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; will not use arc &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ 0 \le z_{uv}^kl -q_{uv}^k$&lt;/span&gt; (1)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{uv}^kl -q_{uv}^k \le \epsilon \quad \forall (u,v) \in\ A,\ \forall k \in\ K$&lt;/span&gt; : (2) where  &lt;span class=&quot;math-container&quot;&gt;$z_{uv}^k \ge 0, z_{uv}^k \in\ Z, \ l = 0.5, \ \epsilon \ is \ a \ small \ number \ge 0, \ like \ {l\over 10}$&lt;/span&gt; Basically constraining to send volume of commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; in multiples of 5, if at all using that arc &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{v:(u,v) \in\ A} \sum_k q_{uv} \le Q_u$&lt;/span&gt; (3).&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-06T20:01:42.737" LastActivityDate="2022-12-06T20:01:42.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9521" PostTypeId="2" ParentId="9511" CreationDate="2022-12-07T03:38:48.900" Score="1" Body="&lt;p&gt;To answer my own question, the following model seems to work as intended.&lt;/p&gt;&#xA;&lt;p&gt;It seems that GAMS is more forgiving than Pyomo. For the bound on c1_rule's constraint, GAMS allows = or &amp;lt;=, while Pyomo requires &amp;lt;=. In effect, the complementarity relationship says that for a generator's quantity to be non-zero, the generator's cost must be &amp;lt;= the market price. Which is what is intended.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;from pyomo import mpec&#xA;import pandas as pd&#xA;&#xA;model = pyo.ConcreteModel()&#xA;GENERATORS = [0, 1, 2, 3]&#xA;var_cost = [10.0, 20.0, 30.0, 40.0]&#xA;GMax = [600.0, 400.0, 1000.0, 2000.0]&#xA;elasticity, pSet, qSet = -0.3, 20.0, 3000.0&#xA;Rho = pSet / elasticity / qSet&#xA;&#xA;model.production = pyo.Var(GENERATORS, within = pyo.NonNegativeReals, initialize = 0)&#xA;model.demand = pyo.Var(within = pyo.NonNegativeReals, initialize = 3000)&#xA;model.price = pyo.Var(initialize = 20)&#xA;&#xA;def c1_rule(model, g):&#xA;    return mpec.complements(var_cost[g] - model.price &amp;lt;= 0, model.production[g] &amp;lt;= GMax[g])&#xA;&#xA;def c2_rule(model):&#xA;    return mpec.complements(model.price - (pSet + Rho * (model.demand - qSet)) == 0, model.demand &amp;gt;= 0)&#xA;&#xA;def c3_rule(model):&#xA;    return mpec.complements(sum(model.production[g] for g in GENERATORS) - model.demand == 0, model.price &amp;gt;= 0)&#xA;&#xA;model.c1 = mpec.Complementarity(GENERATORS, rule = c1_rule)&#xA;model.c2 = mpec.Complementarity(rule = c2_rule)&#xA;model.c3 = mpec.Complementarity(rule = c3_rule)&#xA;&#xA;opt = pyo.SolverFactory('pathampl')&#xA;results = opt.solve(model, tee = True)&#xA;&#xA;pd.options.display.float_format = &amp;quot;{:,.2f}&amp;quot;.format&#xA;GenResults = pd.DataFrame()&#xA;for s in GENERATORS:&#xA;    GenResults.loc[s, 'Dispatch'] = pyo.value(model.production[s])&#xA;    GenResults.loc[s, 'UB'] = GMax[s]&#xA;    GenResults.loc[s, 'SRMC'] = var_cost[s]&#xA;display(GenResults)&#xA;&#xA;print('Rho:   ', round(Rho,4))&#xA;print('Price: ', round(pyo.value(model.price), 2))&#xA;print('Demand:', round(pyo.value(model.demand), 2))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5128" LastEditorUserId="5128" LastEditDate="2022-12-07T03:57:45.477" LastActivityDate="2022-12-07T03:57:45.477" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9522" PostTypeId="2" ParentId="9511" CreationDate="2022-12-07T03:50:28.590" Score="-1" Body="&lt;p&gt;In GAMS version I don't see production[g] forming part of the equation unless marginalCost covers it. But you are then setting mpec solver to set either production for g 0 or make marginalCost equal to price.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-07T03:50:28.590" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9524" PostTypeId="1" CreationDate="2022-12-08T14:59:22.970" Score="4" ViewCount="111" Body="&lt;p&gt;Let us consider the following optimization-problem: For a given set of tuples &lt;span class=&quot;math-container&quot;&gt;$T=(a_1,b_1),\dots,(a_n,b_n)$&lt;/span&gt; and integers &lt;span class=&quot;math-container&quot;&gt;$k,C$&lt;/span&gt;. The task is to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max \quad &amp;amp; \sum_{i=1}^n x_i \cdot a_i - C \cdot \prod_{i=1}^n (1 - x_i \cdot (1 - b_i)) \\&#xA;\text{subject to} \quad &amp;amp; \sum_{i=1}^n x_i \le k \\&#xA;\forall i=1,\dots,n \quad &amp;amp; x_i \text{ is binary}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note, when &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is not selected the factor &lt;span class=&quot;math-container&quot;&gt;$(1 - x_i \cdot (1 - b_i))$&lt;/span&gt; in the penalty is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, and when &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is selected, then the factor is &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would like to know the name of this problem in literature and I am interested, whether it is NP-hard.&#xA;As the problem seems to be quite fundamental, I am quite sure that I am not the first person to observe this problem. But I have not so many good ideas what that could be called like.&lt;/p&gt;&#xA;&lt;p&gt;There is a strong connection to Knapsack and Subset-Sum. Thus, I have found somewhat similar but not close enough problems:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Product Knapsack: &lt;a href=&quot;https://link.springer.com/content/pdf/10.1007/s11590-017-1227-5.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/content/pdf/10.1007/s11590-017-1227-5.pdf&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;The Penalized Knapsack: &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0167637705000751&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sciencedirect.com/science/article/pii/S0167637705000751&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;However all relations to Knapsack result in the issue that in the presented problem, there are no weights to the tuples/elements.&lt;/p&gt;&#xA;&lt;p&gt;The most desirable variant for me would be &lt;span class=&quot;math-container&quot;&gt;$a_i\in \mathbb Q_{\ge 0}, b_i\in \mathbb Q\cap[0,1)$&lt;/span&gt;, but I would also be happy with an idea for the case where  &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;s and &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;s are integers (or anything else.&lt;/p&gt;&#xA;&lt;p&gt;(Three months ago, I have asked this question in the StackExchange-Forum for CS-Theory. &lt;a href=&quot;https://cstheory.stackexchange.com/questions/51832/complexity-of-a-sum-with-a-product&quot;&gt;https://cstheory.stackexchange.com/questions/51832/complexity-of-a-sum-with-a-product&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="10891" LastEditorUserId="10891" LastEditDate="2022-12-12T07:33:55.483" LastActivityDate="2022-12-12T07:33:55.483" Title="A sum with a product-penalty" Tags="|knapsack|np-complete|problem-library|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9525" PostTypeId="1" CreationDate="2022-12-08T22:43:29.990" Score="1" ViewCount="152" Body="&lt;p&gt;Disclaimer: I am not sure if this is the right forum to ask this question.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for a postdoc position in operations research in the US. So far, I have found three ways:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;INFORMS community (or some other similar websites) includes some positions but it does not cover the majority of them.&lt;/li&gt;&#xA;&lt;li&gt;Some of the positions are advertised on the university's website, some positions are posted on the department's website, some are posted on LinkedIn, etc. It is confusing and difficult to find the postings.&lt;/li&gt;&#xA;&lt;li&gt;Send a direct email to professors with similar research interests. This method is extensively time-consuming and a bit unethical to reject a professor when they show interest.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I was wondering what would be the most efficient strategy that you recommend to an operations researcher to find a post-doc (or even a professorship) position in the US. Please note that my research interests include: (i) healthcare and supply chain management, and (ii) applications of operations research and machine learning methods. However willing to work in other related areas.&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="5598" LastEditDate="2022-12-08T22:48:59.047" LastActivityDate="2022-12-08T23:46:53.320" Title="An efficient way to find a postdoc for an operations researcher" Tags="|machine-learning|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9526" PostTypeId="2" ParentId="9525" CreationDate="2022-12-08T23:26:04.857" Score="1" Body="&lt;p&gt;Most postings will be public and will show up based on recency and click rate. You can start in google with an efficient search string like postdoc+PhD+operations research|data science or postdoctoral+PhD+operations research.&lt;br /&gt;&#xA;Also search Insidehighered careers page.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-08T23:46:53.320" LastActivityDate="2022-12-08T23:46:53.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9527" PostTypeId="1" AcceptedAnswerId="9531" CreationDate="2022-12-09T04:17:08.310" Score="3" ViewCount="75" Body="&lt;p&gt;Does anybody know why in the outer approximation approach for MINLP it is not necessarily/needed to solve MILP to optimality? What is the rationale or explanation behind it?&lt;/p&gt;&#xA;" OwnerUserId="9994" LastEditorUserId="491" LastEditDate="2022-12-09T12:55:37.420" LastActivityDate="2022-12-09T12:55:37.420" Title="Outer approximation approach for MINLP" Tags="|optimization|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9528" PostTypeId="2" ParentId="9524" CreationDate="2022-12-09T05:26:51.367" Score="2" Body="&lt;p&gt;One way is to replace the product part with its log. So if &lt;span class=&quot;math-container&quot;&gt;$z=\prod_i (1-x_i(1-b_i))$&lt;/span&gt;, this can be substituted with &lt;span class=&quot;math-container&quot;&gt;$\sum_i \log(1-x_i(1-b_i))$&lt;/span&gt; or simply &lt;span class=&quot;math-container&quot;&gt;$\sum_i x_i \cdot \log b_i$&lt;/span&gt;.&lt;br /&gt;&#xA;This 2nd objective can form the lower level in bilevel or can be optimized independently with &lt;span class=&quot;math-container&quot;&gt;$\sum_{i}^n x_i \le k$&lt;/span&gt; as constraint, then the optimal solution L used as constraint as below:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad\sum_i a_i \cdot x_i\\\text{s.t.}&amp;amp;\quad L \le \sum_i x_i \cdot \log b_i\\&amp;amp;\quad\sum_{i}^n x_i \le k\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="123" LastEditDate="2022-12-11T10:11:32.167" LastActivityDate="2022-12-11T10:11:32.167" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9529" PostTypeId="1" AcceptedAnswerId="9530" CreationDate="2022-12-09T08:12:24.213" Score="4" ViewCount="332" Body="&lt;p&gt;If the nonempty feasible set of a primal LP has extreme points does its dual also have extreme points? I know that a standard form LP (nonempty) always has extreme points. But I am not sure if we can say anything about dual having extreme points or not given the knowledge that primal LP (standard/general) has extreme points.&lt;/p&gt;&#xA;" OwnerUserId="10675" LastActivityDate="2022-12-09T18:34:49.407" Title="Existence of extreme points in primal and dual LP" Tags="|linear-programming|duality|primal-simplex|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9530" PostTypeId="2" ParentId="9529" CreationDate="2022-12-09T10:19:42.250" Score="5" Body="&lt;p&gt;If you by standard form mean the primal-dual pair&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{l}&#xA;\text{minimize} &amp;amp; c^T x,\\&#xA;\text{subject to}&amp;amp; Ax=b,\\&#xA;&amp;amp;x\geq 0,&#xA;\end{array}&#xA;\quad&#xA;\begin{array}{l}&#xA;\text{maximize} &amp;amp; b^T y,\\&#xA;\text{subject to}&amp;amp; A^T y + s = c,\\&#xA;&amp;amp;s\geq 0,&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;then&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;primal feasible set is nonempty &lt;span class=&quot;math-container&quot;&gt;$\Leftrightarrow$&lt;/span&gt; primal feasible set has an extreme point,&lt;/li&gt;&#xA;&lt;li&gt;dual feasible set is nonempty &lt;span class=&quot;math-container&quot;&gt;$\Leftrightarrow$&lt;/span&gt; dual feasible set has an extreme point,&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;and you can find these extreme points using primal simplex phase I (resp. dual simplex phase I).&lt;/p&gt;&#xA;&lt;p&gt;The stated assumption that &lt;em&gt;the primal LP is feasible and has extreme points&lt;/em&gt;, notably does not imply that the dual is feasible and so does not imply that the dual has extreme points. Any primal problem with unbounded optimal value (objective can be improved indefinitely) will show you this.&lt;/p&gt;&#xA;&lt;p&gt;Note further that standard forms allowing free variables in the primal and/or dual problem does not possess this property. Specifically, adding a free variable to any primal instance without any additional constraints will turn all of its feasible points non-extreme, while not affecting the extreme point property in the dual.&lt;/p&gt;&#xA;" OwnerUserId="198" LastActivityDate="2022-12-09T10:19:42.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9531" PostTypeId="2" ParentId="9527" CreationDate="2022-12-09T12:35:38.613" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://optimization.mccormick.northwestern.edu/index.php/Outer-approximation_(OA)&quot; rel=&quot;nofollow noreferrer&quot;&gt;I think this link has a reasonable description of Outer Approximation approach for MINLP&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The outer approximation MILP is  a relaxation of the MINLP. Any lower bound on the MILP outer approximation is also a lower bound on the MINLP. Therefore a lower bound on the outer approximation MILP can be used as a lower bound for the MINLP, without requiring  it be solved to optimality.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-12-09T12:40:46.267" LastActivityDate="2022-12-09T12:40:46.267" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9532" PostTypeId="2" ParentId="9529" CreationDate="2022-12-09T14:09:40.090" Score="8" Body="&lt;p&gt;Besides useful comment and answer, let's depict out the feasible space of the linear problem and its equivalent dual in some simple examples.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1)&lt;/strong&gt; When the primal problem has an optimal solution:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{l}&#xA;\text{Maximize} &amp;amp; Z =  3x_1 + 2x_2\\&#xA;\text{subject to:}&amp;amp; \\&#xA;&amp;amp;x_1  + x_2 \leq  9\\&#xA;&amp;amp;3x_1 + x_2 \leq 18\\&#xA;&amp;amp;x_1 \leq  7\\&#xA;&amp;amp;x_2 \leq  6\\&#xA;&amp;amp;x_1,x_2\geq 0,&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{l} &#xA;\text{Minimize} &amp;amp; W =  9y_1 + 18y_2 + 7y_3 + 6y_4\\&#xA;\text{subject to:}&amp;amp; \\&#xA;&amp;amp;y_1 + 3y_2 + y_3 \geq 3\\&#xA;&amp;amp;y_1 + y_2 + y_4 \geq 2\\&#xA;&amp;amp;y_1,y_2,y_3,y_4\geq 0,&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The primal and dual feasible spaces would be:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/SY8vT.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SY8vT.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;Based on the feasible spaces, the primal contains five extreme points and the dual consists of at least one vertex.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;2)&lt;/strong&gt; When the primal does have multiple optimal solutions:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{l}&#xA;\text{Maximize} &amp;amp; Z =  x_1 + x_2\\&#xA;\text{subject to:}&amp;amp; \\&#xA;&amp;amp;x_1  + x_2 \leq  6\\&#xA;&amp;amp;-x_1 + 2x_2 \leq 8\\&#xA;&amp;amp;x_1,x_2\geq 0,&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{l} &#xA;\text{Minimize} &amp;amp; W =  6y_1 + 8y_2\\&#xA;\text{subject to:}&amp;amp; \\&#xA;&amp;amp;y_1 - y_2  \geq 1\\&#xA;&amp;amp;y_1 + 2y_2 \geq 1\\&#xA;&amp;amp;y_1, y_2 \geq 0,&#xA;\end{array}&lt;/span&gt;&lt;br /&gt;&#xA;The primal and dual feasible spaces would be:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/26eZM.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/26eZM.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;The primal problem has four vertices, but the dual has one and obviously degenerated.&lt;/p&gt;&#xA;&lt;p&gt;I think, as other members pointed out too, one of the best way to find the vertices in the primal or dual would be by using Simplex algorithm and information in its tableaus.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-12-09T14:09:40.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9533" PostTypeId="1" CreationDate="2022-12-09T14:37:49.657" Score="1" ViewCount="113" Body="&lt;p&gt;My problem is described in this picture(It's like a Pyramid structure):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4QPPP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4QPPP.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective function is below: &lt;span class=&quot;math-container&quot;&gt;$$\min\sum_{k=1}^\ell\sum_{i=0}^{2^k-1}\sum_{j=0}^{2^k-1}\left(A_{i,j}^k-A_{i,j+1}^k\cdot\frac{D_{i,j}^k}{D_{i,j+1}^k}\right)^2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this problem, &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is known, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is the object that I want to get. It is a layered structure, each block in the upper layer is divided into four sub-blocks in the layer below. And the value of the upper layer node is equal to the sum of the four child nodes of the lower layer. In above example, I used only 2 layers.&lt;/p&gt;&#xA;&lt;p&gt;What I want to do is simulate the distribution of &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, so in the objective function is the ratio of two adjacent squares in each row in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; compared to the value in &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;. I do this comparison on each layer and sum them. Then it is all of my objective function. But in the finest layer, the value in &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; like the above picture, so this is also a 0-1 programming problem. I have tried to solve it using integer quadratic programming in python library CVXPY but adding the constraints of &lt;code&gt;A&amp;lt;=1&lt;/code&gt;. However, it seems the speed is slow.&lt;/p&gt;&#xA;&lt;p&gt;So I want to model this problem as a standard 0-1 programming problem, and then use some solutions of 0-1 programming to solve it, but I don't know how to model this problem as a standard 0-1 programming problem, and what methods I can use to solve it?&lt;/p&gt;&#xA;&lt;p&gt;In other way, if I use quadratic programming instead of Integer quadratic programming (from &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$0/1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a value between &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;). In this way whether I can solve it using the method of derivation, because this is a convex optimization problem, which can guarantee the global optimal solution. There are two unknown variables in each item, that is, the two items with &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; in the formula. Partial derivatives are obtained for them, and the restriction of &lt;code&gt;A&amp;lt;=1&lt;/code&gt; is added, then solve using (such as) gradient descent method. Is this mathematically feasible, because I don't know much about optimization, and if it is possible, how should I do it? If not possible, what other methods can I use?&lt;/p&gt;&#xA;" OwnerUserId="10825" LastEditorUserId="123" LastEditDate="2022-12-11T14:22:51.937" LastActivityDate="2022-12-11T14:22:51.937" Title="How to model and solve such a 0-1 programming problem" Tags="|optimization|integer-programming|convex-optimization|quadratic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9534" PostTypeId="1" CreationDate="2022-12-09T14:52:29.587" Score="2" ViewCount="169" Body="&lt;p&gt;I have implemented multitrip VRP in ortools (To be specific, solved CVRPTW with virtual depots). Maximum number of trips per vehicle is limited to 2. I want to put a hard constraint that load carried in 2nd trip is always greater than 1st trip of the vehicle. How can I implement this?&lt;/p&gt;&#xA;" OwnerUserId="9609" LastEditorUserId="981" LastEditDate="2023-03-04T00:13:46.113" LastActivityDate="2024-04-01T15:55:51.007" Title="Control load per trip in multi trip VRP in ORTools" Tags="|python|vehicle-routing|or-tools|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9535" PostTypeId="2" ParentId="9533" CreationDate="2022-12-09T16:59:35.657" Score="1" Body="&lt;p&gt;Say the finest layer, &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is 1, then declare &lt;span class=&quot;math-container&quot;&gt;$n \times m$&lt;/span&gt; variables &lt;span class=&quot;math-container&quot;&gt;$a_{n,m}^k \in\ \{0,1\}$&lt;/span&gt; as binary for the finest layer.&#xA;For other layers, &lt;span class=&quot;math-container&quot;&gt;$k=2...K$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$A_{i,j}^{k+1} = a_{i,j}^k+a_{i+1,j+1}^k+a_{i+1,j}^k+a_{i,j+1}^k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Except the finest layer &lt;span class=&quot;math-container&quot;&gt;$k=1$&lt;/span&gt;, rest of &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;'s are real numbers.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-09T16:59:35.657" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9536" PostTypeId="2" ParentId="9529" CreationDate="2022-12-09T18:34:49.407" Score="4" Body="&lt;p&gt;This turns out to be a bit tricky, in part because the geometry of a LP (feasible region, optimal points) can map to multiple algebraic formulations.&lt;/p&gt;&#xA;&lt;p&gt;Consider the following admittedly goofy-looking LP:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\min5x-2y\\&#xA;\textrm{s.t. }x-y &amp;amp; =1\\&#xA;x-y &amp;amp; =1\\&#xA;x,y &amp;amp; \ge0&#xA;\end{align*}&lt;/span&gt;&#xA;where the lone constraint is intentionally duplicated. It has one extreme point, namely &lt;span class=&quot;math-container&quot;&gt;$(1,0),$&lt;/span&gt; which is also the optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;The dual problem is&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\max\lambda+\mu\\&#xA;\textrm{s.t. }\lambda+\mu &amp;amp; \le5\\&#xA;-\lambda-\mu &amp;amp; \le-2\\&#xA;\lambda,\mu &amp;amp; \textrm{ free}.&#xA;\end{align*}&lt;/span&gt;&#xA;The feasible region of the dual is the infinite band &lt;span class=&quot;math-container&quot;&gt;$2 \le \lambda + \mu \le 5,$&lt;/span&gt; which contains no extreme points.&#xA;If we remove the redundant constraint in the primal, the dual has a single variable &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; with feasible region &lt;span class=&quot;math-container&quot;&gt;$2 \le \lambda \le 5,$&lt;/span&gt; which clearly has extreme points.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-12-09T18:34:49.407" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9537" PostTypeId="1" AcceptedAnswerId="9654" CreationDate="2022-12-09T20:01:04.110" Score="2" ViewCount="111" Body="&lt;p&gt;I'm implementing on Xpress a problem with different solution proposed on a paper. The idea is to decompose a matrix &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; into a convex sum &lt;span class=&quot;math-container&quot;&gt;$\sum_{t}\lambda_t M^{(t)}$&lt;/span&gt;, where each &lt;span class=&quot;math-container&quot;&gt;$M^{(t)}$&lt;/span&gt; has only either &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, better stated we have that &lt;span class=&quot;math-container&quot;&gt;$M^{(t)} = (m^{(t)}_{ij})_{ij}$&lt;/span&gt; and each &lt;span class=&quot;math-container&quot;&gt;$m_{ij}$&lt;/span&gt; is a binary variable. In order to find such decomposition, we consider another continuous variable &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; and resolve the problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;&amp;amp;\min\; \alpha \tag{1}\\ &#xA;&amp;amp;\text{s.t.}\\&#xA;&amp;amp;\sum_{t}\lambda_t = 1 \tag{2}\\&#xA;&amp;amp;\sum_{j} m^{(t)}_{ij}\leq 1 \quad \forall i\;\forall t \tag{3}\\&#xA;&amp;amp;\sum_{i}m^{(t)}_{ij}\leq q_{i} \quad \forall j\;\forall t \tag{4}\\&#xA;&amp;amp;\sum_{t}\lambda_t M^{(t)} - X \geq 0 \tag{5}\\&#xA;&amp;amp;\sum_{t}\lambda_t M^{(t)} - X \leq \alpha\tag{6}\\&#xA;&amp;amp;\lambda_t,\alpha\geq 0&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Equations &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt; are problematic because they are quadratic and would yield a non convex region. We can linearize it by introducing a variable &lt;span class=&quot;math-container&quot;&gt;$z^{(t)}_{ij}=\lambda_{t}m^{(t)}_{ij}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$Z^{(t)} = (z^{(t)}_{ij})_{ij}$&lt;/span&gt; which ultimately changes the equations to: &lt;span class=&quot;math-container&quot;&gt;$$\sum_t Z^{(t)} - X \geq 0\qquad\text{and}\qquad \sum_{t}Z^{(t)} - X \leq\alpha$$&lt;/span&gt;&#xA;which is now linear but requires the additional constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\forall i, j,t\hspace{2mm}: 0\leq z_{ij}^{(t)}\leq \lambda_t \qquad z_{ij}^{(t)}\geq \lambda_t + m_{ij}^{(t)}-1$$&lt;/span&gt;&lt;br /&gt;&#xA;The code runs perfectly with a non trivial output, meaning that the problem is feasible. Nontheless the new solution looses the meaning of the initial implementetion: the non linearized equation would have given as a result, &lt;span class=&quot;math-container&quot;&gt;$0-1$&lt;/span&gt; matrixes, which is my aim actually. By linearizing, the solution looses any interpretation (as the &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;'s need now to be continuous variables). What's the best idea to set back now? Is dividing each &lt;span class=&quot;math-container&quot;&gt;$Z^{(t)}$&lt;/span&gt; by its &lt;span class=&quot;math-container&quot;&gt;$\lambda_t$&lt;/span&gt; and rounding the numbers a meaningful step?&lt;/p&gt;&#xA;" OwnerUserId="10897" LastEditorUserId="10897" LastEditDate="2023-01-02T22:16:57.470" LastActivityDate="2023-01-02T22:16:57.470" Title="Correct way to set a quadratic constraint Xpress" Tags="|linear-programming|python|minimax|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9538" PostTypeId="2" ParentId="9524" CreationDate="2022-12-09T20:05:05.217" Score="2" Body="&lt;p&gt;You might consider using dynamic programming, as in the usual binary knapsack problem. Let &lt;span class=&quot;math-container&quot;&gt;$f(n,k,C)$&lt;/span&gt; be the optimal objective value for the original problem. Conditioning on the value of &lt;span class=&quot;math-container&quot;&gt;$x_n\in\{0,1\}$&lt;/span&gt; yields DP recursion&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(n,k,C)=\max\left(f(n-1,k,C), a_n+f(n-1,k-1,C b_n)\right).$$&lt;/span&gt;&#xA;In the worst case, you will have &lt;span class=&quot;math-container&quot;&gt;$O(n k 2^n)$&lt;/span&gt; states, but you could have fewer if the number of distinct values of &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; is small.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-12-09T20:05:05.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9540" PostTypeId="2" ParentId="9424" CreationDate="2022-12-10T20:14:50.493" Score="1" Body="&lt;p&gt;The problem is NP-hard in general. I suspect that your problems are rather small or have few terminals and are therefore easy to solve, even for an approximation algorithm.&lt;/p&gt;&#xA;" OwnerUserId="10905" LastActivityDate="2022-12-10T20:14:50.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9541" PostTypeId="1" CreationDate="2022-12-11T01:30:06.323" Score="4" ViewCount="983" Body="&lt;p&gt;I have implemented a Pyomo model for solving maximum flow problem as a subroutine of an algorithm. However, the approach does not scale very well because Pyomo does not provide a very good way to re-optimize the computation based on previous computations. (It provides a warm start but It does not seem to allow one to obtain the solution from the results and feed it in a following computation, therefore it is rather limited in this sense)&lt;/p&gt;&#xA;&lt;p&gt;Google-OR tools provides an surprisingly easy way to solve maximum flow problems and claim it is also very performant &lt;a href=&quot;https://developers.google.com/optimization/flow/maxflow&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization/flow/maxflow&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;How well does this solver perform compared to other tools such as CPLEX and Gurobi and will it be a better option to consider than Pyomo?&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="981" LastEditDate="2023-02-05T16:42:00.370" LastActivityDate="2023-02-05T16:42:00.370" Title="Google-OR tools vs Pyomo and other commercial Solvers for solving a simple maximum flow problem" Tags="|combinatorial-optimization|pyomo|or-tools|network-flow|cplex-python-api|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9542" PostTypeId="1" CreationDate="2022-12-11T04:21:40.607" Score="1" ViewCount="89" Body="&lt;p&gt;As a part of an problem where i deploy the EM-algorithm i got stuck with the m-step that can be summarized into the below problem:&lt;/p&gt;&#xA;&lt;p&gt;Consider the following function: &lt;span class=&quot;math-container&quot;&gt;$$f(\alpha_{k,l}, \theta_{n, m}) = \sum_{k}\sum_l\left[\sum_n\sum_m r_{k,n,m,l}\right]\ln(\alpha_{k,l}) + \sum_{n}\sum_m\left[\sum_k\sum_l r_{k,n,m,l}\right]\ln(\theta_{n,m})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where as &lt;span class=&quot;math-container&quot;&gt;$$r_{k,n,m,l}$$&lt;/span&gt; are our expectations that are already computed(can be though of as constant matrices), the solution should obviously be some expression of these expectations.&#xA;&lt;span class=&quot;math-container&quot;&gt;$\alpha_{k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\theta_n$&lt;/span&gt; are probabilities thus the following should hold:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_n \alpha_{k,n} = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_l \theta_{n,m} = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thus we have two constraints to adhere to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}1 - \sum_l \alpha_{k, l} &amp;amp;= 0\\ 1- \sum_r \theta_{n, m} &amp;amp;= 0\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and we aim to solve this with Lagrange multipliers.&lt;/p&gt;&#xA;&lt;p&gt;We construct two functions aiming to capture the constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$g(\alpha_{k, l}, \theta_{n,m}) = 1 - \sum_l \alpha_{k, l}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h(\alpha_{k, l}, \theta_{n,m}) = 1 - \sum_m \theta_{n, m}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Lets start calculating our gradients:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\nabla_f = &amp;lt;\sum_k\sum_l[\sum_n\sum_m r_{k,n,m,l}]\frac{1}{\alpha_{k,l}}, \sum_n\sum_m[\sum_k\sum_l r_{k,n,m,l}]\frac{1}{\theta_{n,m}}&amp;gt;$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\nabla_g = &amp;lt;1, 0&amp;gt;$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\nabla_h = &amp;lt;0, 1&amp;gt;$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;thus we are left with the following system of equations:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_k\sum_l[\sum_n\sum_m r_{k,n,m,l}]\frac{1}{\alpha_{k,l}} = \lambda_{\alpha}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_n\sum_m[\sum_k\sum_l r_{k,n,m,l}]\frac{1}{\theta_{n,m}} =\lambda_{\theta}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1 - \sum_l \alpha_{k, l} = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1 - \sum_n \theta_{n, m} = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and from here i am stuck..&lt;/p&gt;&#xA;&lt;p&gt;i have been told that the solution for &lt;span class=&quot;math-container&quot;&gt;$\alpha_{k, l}$&lt;/span&gt; should be: &lt;span class=&quot;math-container&quot;&gt;$\frac{\sum_n\sum_m r_{k,n,m,l}}{\sum_l\sum_n\sum_m r_{k,n,m,l}}$&lt;/span&gt; but i cant come up with this answer neither with the lagrange nor without the constraints.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone see how they came up with this solution?&lt;/p&gt;&#xA;" OwnerUserId="10899" LastEditorUserId="10899" LastEditDate="2022-12-12T21:13:39.380" LastActivityDate="2022-12-12T21:13:39.380" Title="Optimization with two constraints using Lagrange multipliers" Tags="|optimization|machine-learning|lagrange-multipliers|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9543" PostTypeId="1" AcceptedAnswerId="9544" CreationDate="2022-12-11T07:38:42.950" Score="1" ViewCount="639" Body="&lt;p&gt;I am trying to implement a constraint as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;routing.solver().Add(capacity_dimension.CumulVar(idx) * routing.ActiveVar(idx) &amp;gt;= capacity_dimension.CumulVar(routing.End(v)) * 0.5 )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It gives error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;TypeError: unsupported operand type(s) for *: 'IntVar' and 'float'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How can I resolve this?&lt;/p&gt;&#xA;&lt;p&gt;I tried &lt;code&gt;capacity_dimension.CumulVar(routing.End(v)).Value() * 0.5&lt;/code&gt; on RHS but this kills the kernel.&lt;/p&gt;&#xA;" OwnerUserId="9609" LastEditorUserId="9609" LastEditDate="2022-12-13T05:22:57.030" LastActivityDate="2022-12-13T05:22:57.030" Title="TypeError: unsupported operand type(s) for *: 'IntVar' and 'float' in ortools" Tags="|python|vehicle-routing|or-tools|" AnswerCount="1" CommentCount="1" ClosedDate="2022-12-12T10:12:49.963" ContentLicense="CC BY-SA 4.0" />
  <row Id="9544" PostTypeId="2" ParentId="9543" CreationDate="2022-12-11T07:40:12.770" Score="1" Body="&lt;p&gt;This is solved as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;2 * capacity_dimension.CumulVar(idx) * routing.ActiveVar(idx) &amp;gt;= capacity_dimension.CumulVar(routing.End(v))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9609" LastActivityDate="2022-12-11T07:40:12.770" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9545" PostTypeId="1" AcceptedAnswerId="9548" CreationDate="2022-12-11T13:03:55.873" Score="6" ViewCount="691" Body="&lt;p&gt;Background:  I have a group of 6 guys that get together and play pickleball every week.  We play 2v2 and 2 players sit each game.  We play 2 sets of 6 games each week (12 total games) - in each set, each player plays 4 games, and sits for 2 games.  At the end of each set, each player totals up the amount of points he scores, and we have a winner.&lt;/p&gt;&#xA;&lt;p&gt;Anyway, I worked out all the combinations of games for 6 people for playing doubles.  There are a total of 45 unique games that could be played, where every combination of partners would play every other combination of partners.  I would like to come up with a schedule to play all 45 of these games across 4 sessions of 2 sets each for a total of 8 sets (the final 3 games in the last set can be arbitrary since 6x8=48, and there are only 45 unique games).&lt;/p&gt;&#xA;&lt;p&gt;The problem comes in with determining the order of the games, such that following criteria is met, for each of the sets of 6 games:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Each player plays 4 games, and sits for 2 games.&lt;/li&gt;&#xA;&lt;li&gt;No player sits for 2 consecutive games.&lt;/li&gt;&#xA;&lt;li&gt;Each player partners with a different partner every game.  (i.e. no 2 players partner more than once per set).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Where I could use help is figuring out the algorithm to come up with the optimal order of games.  With 45 factorial possible orders ~1e56...it's too many to brute force.  Any advice would be appreciated.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;All the combinations for players A, B, C, D, E, and F:&#xA;T1  T2  Bye&#xA;AB  CD  EF&#xA;AB  CE  DF&#xA;AB  CF  DE&#xA;AB  DE  CF&#xA;AB  DF  CE&#xA;AB  EF  CD&#xA;AC  BD  EF&#xA;AC  BE  DF&#xA;AC  BF  DE&#xA;AC  DE  BF&#xA;AC  DF  BE&#xA;AC  EF  BD&#xA;AD  BC  EF&#xA;AD  BE  CF&#xA;AD  BF  CE&#xA;AD  CE  BF&#xA;AD  CF  BE&#xA;AD  EF  BC&#xA;AE  BC  DF&#xA;AE  BD  CF&#xA;AE  BF  CD&#xA;AE  CD  BF&#xA;AE  CF  BD&#xA;AE  DF  BC&#xA;AF  BC  DE&#xA;AF  BD  CE&#xA;AF  BE  CD&#xA;AF  CD  BE&#xA;AF  CE  BD&#xA;AF  DE  BC&#xA;BC  DE  AF&#xA;BC  DF  AE&#xA;BC  EF  AD&#xA;BD  CE  AF&#xA;BD  CF  AE&#xA;BD  EF  AC&#xA;BE  CD  AF&#xA;BE  CF  AD&#xA;BE  DF  AC&#xA;BF  CD  AE&#xA;BF  CE  AD&#xA;BF  DE  AC&#xA;CD  EF  AB&#xA;CE  DF  AB&#xA;CF  DE  AB&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Tried writing a brute force algorithm in Excel VBA...seems like it was going to take forever to run.&lt;/p&gt;&#xA;" OwnerUserId="10910" LastEditorUserId="10910" LastEditDate="2022-12-13T01:53:50.157" LastActivityDate="2022-12-16T03:41:33.967" Title="Doubles Round Robin Sorting Algorithm" Tags="|optimization|mixed-integer-programming|scheduling|constraint-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9546" PostTypeId="1" CreationDate="2022-12-11T15:15:26.377" Score="2" ViewCount="57" Body="&lt;p&gt;Consider an objective function in the form of minimization of maximization that is the sum of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; similar functions &lt;span class=&quot;math-container&quot;&gt;$f\left(x\right)\ge 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\ \forall x$&lt;/span&gt;. The summation of all variables is constant (e.g., 1), like a limited resource:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\mathrm{min}} \sum^N_{j=1}{f\left(x_j\right)}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\mathrm{max}} \sum^N_{j=1}{f\left(x_j\right)}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum^N_{j=1}{x_j}=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_j\ge 0,\ \forall j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The function &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is highly non-linear and non-convex. I examined the model computationally for a given function, and in the optimal solution, I can see that&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For the minimization case, there is the most unbalance: all terms in the objective function except one become zero;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For the maximization case, there is the highest balance: all terms in the objective function get a value close to each.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I cannot analytically prove these observations. Are there any theorems or properties about &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; to show this fact?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;This is the main problem with at least two terms in the objective function. Each term represents a facility. So, they can be more than two.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$min Z(x_1,y_1,x_2,y_2)=\frac{{\beta }_c{x_1}^2+{\beta }_mx_1y_1+{\beta }_n{y_1}^2}{(h_1-r_cx_1-r_ny_1)}+\frac{{\beta }_c{x_2}^2+{\beta }_mx_2y_2+{\beta }_n{y_2}^2}{(h_2-r_cx_2-r_ny_2)}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1+x_2=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_1+y_2=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0\le x_1,y_1,x_2,y_2\le 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;All parameters are non-negative. The denominators are also positive.&lt;/p&gt;&#xA;" OwnerUserId="10911" LastEditorUserId="36" LastEditDate="2022-12-12T21:13:25.997" LastActivityDate="2022-12-12T21:13:25.997" Title="Minimizing sum of similar functions with a dependence" Tags="|nonlinear-programming|nonconvex-programming|decomposition|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9547" PostTypeId="1" CreationDate="2022-12-11T16:20:47.273" Score="1" ViewCount="79" Body="&lt;p&gt;I have come across this problem while trying to understand game theory. The problem presents two players (hunters) that want to hunt in one of two regions available. Region &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; rabbits and region &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$18$&lt;/span&gt; rabbits. If the two hunters go to different regions they will acquire all the rabbits in their respective hunting ground, but if they go to the same region they'll acquire half the rabbits each, assuming they have the same skills. I have found the mixed strategy that they need to follow, which will be the same for both: they will go to region &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; with probability &lt;span class=&quot;math-container&quot;&gt;$p=\frac{3}{5}$&lt;/span&gt; or to region &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; with probability &lt;span class=&quot;math-container&quot;&gt;$1-p=\frac{2}{5}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The problem emerges when I try to further the problem by adding a third hunter in the game. I would assume that an obvious answer would come up, like one region would give the best result when chosen for all hunters. However, what I'm seeing by creating the payoff tables is that if the third hunter chooses region &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; then it's in everyone's benefit if the other two hunters choose region &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, thus having the result array be &lt;span class=&quot;math-container&quot;&gt;$(H_1,H_2,H_3)=(9,9,12)$&lt;/span&gt;. But if hunter 3 chooses region &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, the best outcome is when the other two hunters don't choose the same region between themselves.&lt;/p&gt;&#xA;&lt;p&gt;I am unsure as to how I can interpret this or if there's another way to find the answer to this more complicated question. Can I apply a method to this problem and find mixed strategies for the three hunters? I am not necessarily looking for the answer directly, but for someone to point out a method or way of thinking for me to find the answer alone.&lt;/p&gt;&#xA;" OwnerUserId="10847" LastEditorUserId="10847" LastEditDate="2022-12-12T14:11:33.740" LastActivityDate="2022-12-12T14:11:33.740" Title="How to find best strategy for 3 hunters hunting in 2 regions?" Tags="|optimization|nash-equilibrium|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="9548" PostTypeId="2" ParentId="9545" CreationDate="2022-12-11T20:04:39.453" Score="8" Body="&lt;p&gt;You can solve this with an integer programming model. I will omit the objective function, since any feasible solution produces a viable schedule. You might give some thought to whether there is a criterion that would let you choose among viable schedules.&lt;/p&gt;&#xA;&lt;p&gt;First, we define some sets:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P=$&lt;/span&gt; set of all players (&lt;span class=&quot;math-container&quot;&gt;$\vert P\vert=6$&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$G=$&lt;/span&gt; set of all games (&lt;span class=&quot;math-container&quot;&gt;$\vert G\vert=45$&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S=$&lt;/span&gt; set of slots for games (&lt;span class=&quot;math-container&quot;&gt;$\vert S\vert=48$&lt;/span&gt;), with 12 slots in&#xA;each week&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_{0}\subset S=$&lt;/span&gt; set of slots that start a set (so &lt;span class=&quot;math-container&quot;&gt;$S_{0}=\left\{ 1,7,\dots,43\right\} $&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_{1}\subset S=$&lt;/span&gt; set of slots followed by another slot in the same&#xA;set (so &lt;span class=&quot;math-container&quot;&gt;$S_{1}=\left\{ s\in S:6\not|\:s\right\} $&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$T=$&lt;/span&gt; set of teams (pairs of players) (&lt;span class=&quot;math-container&quot;&gt;$\vert T\vert=15$&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Next, we define a couple of parameters:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\pi_{p,g}=1$&lt;/span&gt; if player &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; plays in game &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, else 0&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\tau_{t,g}=1$&lt;/span&gt; if team &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is together in game &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;, else&#xA;0&lt;/p&gt;&#xA;&lt;p&gt;We have the following binary variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{g,s}=1$&lt;/span&gt; if game &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is scheduled into slot &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, 0 otherwise&lt;/p&gt;&#xA;&lt;p&gt;Now come the constraints.&lt;/p&gt;&#xA;&lt;p&gt;Each game is scheduled at least once and at most twice: &lt;span class=&quot;math-container&quot;&gt;$$1\le\sum_{s\in S}x_{g,s}\le2\quad\forall g\in G$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Each slot is filled once: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{g\in G}x_{g,s}=1\quad\forall s\in S$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Each player plays four of six games within a set: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{g\in G}\pi_{p,g}x_{g,s}+\sum_{g\in G}\pi_{p,g}x_{g,s+1}+\cdots+\sum_{g\in G}\pi_{p,g}x_{g,s+5}=4\quad\forall p\in P,\forall s\in S_{0}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;No player sits for two consecutive games:&lt;span class=&quot;math-container&quot;&gt;$$\sum_{g\in G}\pi_{p,g}x_{g,s}+\sum_{g\in G}\pi_{p,g}x_{g,s+1}\ge1\quad\forall p\in P,\forall s\in S_{1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;No team plays more than once in a set:&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{g\in G}\tau_{t,g}x_{g,s}+\sum_{g\in G}\tau_{t,g}x_{g,s+1}+\cdots+\sum_{g\in G}\tau_{t,g}x_{g,s+5}\le1\quad\forall t\in T,\forall s\in S_{0}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Addendum: I coded this in Java using CPLEX 22.1 to solve the MIP, and got what I assume is a valid schedule in about one second. Also, I believe you could just as well use a constraint programming model rather than an IP model.&lt;/p&gt;&#xA;&lt;p&gt;Addendum 2: Here is the solution my code obtained.&lt;/p&gt;&#xA;&lt;p&gt;Day 1, Set 1:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;AB vs. CD (bye: EF)&#xA;AE vs. CF (bye: BD)&#xA;BD vs. CE (bye: AF)&#xA;AD vs. EF (bye: BC)&#xA;BC vs. DF (bye: AE)&#xA;AF vs. BE (bye: CD)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Day 1, Set 2:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;AE vs. BF (bye: CD)&#xA;AC vs. DE (bye: BF)&#xA;AF vs. BD (bye: CE)&#xA;BE vs. CF (bye: AD)&#xA;AD vs. BC (bye: EF)&#xA;CD vs. EF (bye: AB)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Day 2, Set 1:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;AB vs. EF (bye: CD)&#xA;AC vs. DF (bye: BE)&#xA;BE vs. CD (bye: AF)&#xA;AD vs. CF (bye: BE)&#xA;BF vs. DE (bye: AC)&#xA;AE vs. BC (bye: DF)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Day 2, Set 2:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;CF vs. DE (bye: AB)&#xA;AC vs. BF (bye: DE)&#xA;CE vs. DF (bye: AB)&#xA;AE vs. BD (bye: CF)&#xA;AF vs. BC (bye: DE)&#xA;AD vs. BE (bye: CF)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Day 3, Set 1:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;AD vs. CE (bye: BF)&#xA;BF vs. CD (bye: AE)&#xA;AC vs. BE (bye: DF)&#xA;AF vs. DE (bye: BC)&#xA;AB vs. CF (bye: DE)&#xA;BD vs. EF (bye: AC)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Day 3, Set 2:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;AC vs. BD (bye: EF)&#xA;AE vs. DF (bye: BC)&#xA;BF vs. CE (bye: AD)&#xA;AF vs. CD (bye: BE)&#xA;AB vs. DE (bye: CF)&#xA;BC vs. EF (bye: AD)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Day 4, Set 1:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;AE vs. CD (bye: BF)&#xA;AD vs. BF (bye: CE)&#xA;AB vs. CE (bye: DF)&#xA;BE vs. DF (bye: AC)&#xA;AC vs. EF (bye: BD)&#xA;BD vs. CF (bye: AE)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Day 4, Set 2:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;AB vs. DF (bye: CE)&#xA;AF vs. CE (bye: BD)&#xA;BC vs. DE (bye: AF)&#xA;AE vs. CF (bye: BD)&#xA;AD vs. BE (bye: CF)&#xA;BF vs. CD (bye: AE)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Addendum 3: It belatedly occurred to me that we might want to add a constraint saying the 45 possible games must occur once each among the first 45 slots, meaning that any repeated games must occupy the last three slots (in case we want to cut the last day short and not play those three repeated games). In the IP model, this just adds the constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{s\in \hat{S}} x_{g,s} = 1 \quad\forall g\in G$$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$\hat{S}\subset S$&lt;/span&gt; consists of the first 45 slots.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2022-12-16T03:41:33.967" LastActivityDate="2022-12-16T03:41:33.967" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="9549" PostTypeId="1" AcceptedAnswerId="9554" CreationDate="2022-12-12T08:31:17.177" Score="5" ViewCount="290" Body="&lt;p&gt;I want to formulate a MIP constraint such that :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^nx_i = 2 \implies \delta = 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_i, \delta \in \{0, 1\}$&lt;/span&gt;.&lt;br /&gt;&#xA;My problem is that delta should be one when this sum is exactly 2 and not greater or less than.&lt;/p&gt;&#xA;" OwnerUserId="10716" LastEditorUserId="2556" LastEditDate="2022-12-12T09:18:18.703" LastActivityDate="2022-12-18T05:33:14.723" Title="MIP constraint with sum of decision variables having certain value : $\sum_{i=1}^nx_i = 2 \implies \delta = 1$" Tags="|mixed-integer-programming|modeling|linearization|logical-constraints|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9550" PostTypeId="2" ParentId="9549" CreationDate="2022-12-12T08:51:39.053" Score="10" Body="&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; variables are binary, the contraposition reads as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\delta = 0 \implies \left( \sum_{i=1}^n x_i \le 1 \right)\vee \left( \sum_{i=1}^n x_i \ge 3 \right)&#xA;$$&lt;/span&gt;&#xA;Define a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n x_i \le 1$&lt;/span&gt; and another one &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n x_i \ge 3$&lt;/span&gt;, such that in conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\neg \delta  \implies y_1 \vee y_2&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\delta \vee y_1 \vee y_2 &#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\delta +y_1 +y_2 \ge 1 &#xA;$$&lt;/span&gt;&#xA;So in summary:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA; \sum_{i=1}^n x_i \le 1+M_1(1-y_1) \\&#xA;\sum_{i=1}^n x_i \ge 3-M_2(1-y_2) \\&#xA;\delta +y_1 +y_2 \ge 1 \\&#xA;x_i,y_i,\delta \in \{0,1\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$0\le \sum_{i=1}^nx_i\le n$&lt;/span&gt;, you can use values &lt;span class=&quot;math-container&quot;&gt;$M_1=n-1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_2=3$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2022-12-12T15:25:33.220" LastActivityDate="2022-12-12T15:25:33.220" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9551" PostTypeId="1" CreationDate="2022-12-12T11:46:43.490" Score="1" ViewCount="219" Body="&lt;p&gt;I have formulated a MILP problem &amp;amp; solved it using Gurobi. Below is the link to the description of MILP problem (a brief document) clearly stating its variables, constraints, and objective function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://docs.google.com/document/d/1upkdHAkJ2UUIqz5GKvJWhXls-U9lA36f/edit?usp=sharing&amp;amp;ouid=104556000005791842995&amp;amp;rtpof=true&amp;amp;sd=true&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.google.com/document/d/1upkdHAkJ2UUIqz5GKvJWhXls-U9lA36f/edit?usp=sharing&amp;amp;ouid=104556000005791842995&amp;amp;rtpof=true&amp;amp;sd=true&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, I want to check if I can add heuristics or metaheuristics to my existing problem and remodify it.&lt;/p&gt;&#xA;" OwnerUserId="10916" LastEditorUserId="491" LastEditDate="2022-12-12T18:30:08.697" LastActivityDate="2022-12-12T18:30:08.697" Title="How do I convert existing MILP problem into heuristics? or Shall I add heuristics to my existing MILP problem?" Tags="|mixed-integer-programming|gurobi|heuristics|metaheuristics|robust-optimization|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9552" PostTypeId="2" ParentId="9549" CreationDate="2022-12-12T13:18:26.170" Score="2" Body="&lt;p&gt;As the expression is totally boolean form and based on the logic modeling, the mentioned if-then would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \text{exactly(2)}_i x_i \implies \delta = 1 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \text{atleast(2)}_i x_i \land \text{atmost(2)}_i x_i \implies \delta = 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \lnot (\text{atleast(2)}_i x_i \land \text{atmost(2)}_i x_i) \lor \delta$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (\text{atmost(2-1)}_i x_i \lor \text{atleast(2+1)}_i x_i) \lor \delta$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (\text{atmost(1)}_i x_i \lor \text{atleast(3)}_i x_i) \lor \delta$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (\sum_{i=1}^n x_{i} \leq 1) \lor ((\sum_{i=1}^n x_{i} \geq 3) \lor \delta$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;By introducing the auxiliary variables, the last line would be:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_{1} + z_{2} + \delta \geq 1 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, the linearization can be written as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_{1} + z_{2} + \delta \geq 1 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^n x_{i} - M_1.z_{1} \geq 0 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^n x_{i} + M_2.z_{2} \leq UB$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, if one would like to see how the original expression can be converted to a CNF which is finally translated to the math without auxiliary binary variables, please took a look at this &lt;a href=&quot;https://math.stackexchange.com/questions/4600813/cnf-form-of-the-logical-exactly2-x-i/4601023?noredirect=1#comment9692326_4601023&quot;&gt;link&lt;/a&gt; and useful answer by @RobPratt.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2022-12-18T05:33:14.723" LastActivityDate="2022-12-18T05:33:14.723" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9553" PostTypeId="2" ParentId="9551" CreationDate="2022-12-12T14:04:25.590" Score="3" Body="&lt;p&gt;There is a Gurobi video &lt;a href=&quot;https://www.gurobi.com/events/faster-mips-using-custom-heuristics/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Faster MIPs Using Custom Heuristics&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;MIPs often solve faster with good integer feasible solutions. Thus,&#xA;Gurobi contains a variety of MIP heuristics to create integer&#xA;solutions and improve them. However, sometimes you can improve upon&#xA;this with custom integer heuristics that exploit model structure.&lt;/p&gt;&#xA;&lt;p&gt;In this webinar, you will learn:&lt;/p&gt;&#xA;&lt;p&gt;What models may benefit from custom MIP heuristics, and how to build&#xA;your own custom MIP heuristics by using the traveling salesman problem&#xA;to illustrate different integer heuristics that take advantage of both&#xA;model structure and relaxed solution values in the MIP tree.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Without going custom, the amount of time the Gurobi solver devotes to feasibility heuristics can be controlled by the Heuristics parameter.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/heuristics.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.0/refman/heuristics.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Heuristics Time spent in feasibility heuristics   Type:   double&#xA;  Default value:  0.05    Minimum value:  0   Maximum value:  1&lt;/p&gt;&#xA;&lt;p&gt;Determines the amount of time spent in MIP heuristics. You can think&#xA;of the value as the desired fraction of total MIP runtime devoted to&#xA;heuristics (so by default, we aim to spend 5% of runtime on&#xA;heuristics). Larger values produce more and better feasible solutions,&#xA;at a cost of slower progress in the best bound.&lt;/p&gt;&#xA;&lt;p&gt;Note: Only affects mixed integer programming (MIP) models&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="68" LastActivityDate="2022-12-12T14:04:25.590" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9554" PostTypeId="2" ParentId="9549" CreationDate="2022-12-12T14:50:35.060" Score="6" Body="&lt;p&gt;Assuming you also want to enforce the converse, here’s another approach that uses the same additional binary variables &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2$&lt;/span&gt; as in @Kuifje’s answer.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_1+\delta+y_2=1\\&#xA;0y_1+2\delta+3y_2\le \sum_{i=1}^n x_i \le 1y_1+2\delta+ny_2&#xA;$$&lt;/span&gt;&#xA;If you prefer, you can think of &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt; as a slack variable and eliminate it, yielding&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\delta+y_2\le 1\\&#xA;2\delta+3y_2\le \sum_{i=1}^n x_i \le 1+\delta+(n-1)y_2&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-12-12T14:50:35.060" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9555" PostTypeId="1" AcceptedAnswerId="9563" CreationDate="2022-12-12T15:25:00.560" Score="3" ViewCount="253" Body="&lt;p&gt;I came across the following functionality that is offered by CPLEX for modifying and re-optimizing a model based on previous computations: &lt;a href=&quot;https://perso.ensta-paris.fr/%7Ediam/ro/online/cplex/cplex1271/CPLEX/GettingStarted/topics/tutorials/Python/modify_reopt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://perso.ensta-paris.fr/~diam/ro/online/cplex/cplex1271/CPLEX/GettingStarted/topics/tutorials/Python/modify_reopt.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I could not find any examples of how to use this functionality with the Python API. Does CPLEX support this &amp;quot;under the hood&amp;quot; or I need to do something more advanced to enable it? Can someone point me to a resource or give an example?&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="491" LastEditDate="2022-12-12T18:26:24.213" LastActivityDate="2022-12-21T10:16:30.140" Title="Modifying and re-optimizing a model using CPLEX Python API" Tags="|python|integer-programming|cplex|reference-request|cplex-python-api|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9556" PostTypeId="2" ParentId="9551" CreationDate="2022-12-12T16:01:34.547" Score="2" Body="&lt;p&gt;Please see if this &lt;a href=&quot;https://or.stackexchange.com/questions/2999/a-heuristic-approach-to-solve-a-milp-problem?rq=1&quot;&gt;answer&lt;/a&gt; helps you.&#xA;Heuristics will have perturbation (changing values, first randomly, then based on a pattern if direction of min/max is ascertained) of variables, checking the constraints (called fitness function) and repeat.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-12T16:01:34.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9557" PostTypeId="1" AcceptedAnswerId="9561" CreationDate="2022-12-12T16:14:46.543" Score="1" ViewCount="109" Body="&lt;p&gt;I'm a software dev that's pretty new to OR and want to solve a specific problem I came across at my job. From what I've researched it is a variation of resource-constrained assignment problem, but with variety of those problems it's quite hard for me to confirm.&lt;/p&gt;&#xA;&lt;p&gt;I have n jobs that need to be assigned to m production facilities:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;only some of those facilities are viable locations for producing&lt;/li&gt;&#xA;&lt;li&gt;some (but not all) products are stock constrained&lt;/li&gt;&#xA;&lt;li&gt;cost of producing those is variable and depends on number of jobs assigned to that location (edit: for 1-10 items unit cost would \$10, for 10-100 \$9 etc. and it would differ between production houses)&lt;/li&gt;&#xA;&lt;li&gt;number of jobs assigned should be between min-max for that location (but might be exceeded either way if no feasible solution found).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;There are multiple objectives depending on other factors, but I should be able to get it down to a single number by using weights.&lt;/p&gt;&#xA;&lt;p&gt;I've found different papers that deal with RCAP, but what I struggle to understand is how to incorporate constraint 3 into any LP model or any other of those solutions. Additionally in &amp;quot;Model Building in Mathematical Programming&amp;quot; I've read that LP is not that good for those kinds of problems as it multiplies variables very fast and specialized algorithms work better, but I struggle to find one that fits my needs.&lt;/p&gt;&#xA;&lt;p&gt;Is local search options a better solution for real-world application? I've looked into OptaPlanner, but it seems like a too-good-to-be-true solution and I'd rather explore all different options before committing to one. What approaches/problems/tools would you suggest I read up on?&lt;/p&gt;&#xA;&lt;p&gt;In my case, I'd need to deal with up to 100 production houses and up to 10000 orders.&lt;/p&gt;&#xA;" OwnerUserId="10917" LastEditorUserId="10917" LastEditDate="2022-12-12T17:34:35.783" LastActivityDate="2022-12-12T20:22:13.077" Title="How do I approach this optimization problem?" Tags="|combinatorial-optimization|assignment-problem|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9559" PostTypeId="2" ParentId="9557" CreationDate="2022-12-12T16:38:01.447" Score="1" Body="&lt;p&gt;For constraint #3, assuming cost of production should have some basis like unit cost per order/job/facility and if you want to use a constraint around it, then it's like&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$C = \sum_f \sum _{j} c_j \cdot O_{j,f}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c_{j,f}$&lt;/span&gt; is unit cost per job, j per facility, f and &lt;span class=&quot;math-container&quot;&gt;$O_{j,f}$&lt;/span&gt; is volume of orders.&lt;/p&gt;&#xA;&lt;p&gt;If multiple price points like p1=10 (1-10), p2=9 (11-100)..pN depending upon volume of orders and N is largest index of price points then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$9 - O_{j,f} \le U \cdot x_{0,f}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$O_{j,f} - 10 \le U \cdot x_{1,j} \quad \forall \ j \in\ $&lt;/span&gt;jobs and &lt;span class=&quot;math-container&quot;&gt;$\forall \ f \in\ $&lt;/span&gt;Facilities where  &lt;span class=&quot;math-container&quot;&gt;$x_1 \in\ \{0,1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U \gt O$&lt;/span&gt;: upper bound of order volume&lt;br /&gt;&#xA;Similarly, &lt;span class=&quot;math-container&quot;&gt;$O_{j,f} - 100 \le U \cdot x_{2,j}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, &lt;span class=&quot;math-container&quot;&gt;$\sum_i x_{i,j} = 1$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$0 \le i \le N \quad \forall  j \in\ $&lt;/span&gt;jobs.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{j,f} = \sum_i x_{i,j} \cdot p_i \quad \forall \ j,f \in\ $&lt;/span&gt;job, facilities&lt;/p&gt;&#xA;&lt;p&gt;Depending upon linearity of other constraints and objectives, LP or NLP solver will be able to solve it without worrying about algorithms but some solvers do provide option to choose algorithms like branch-cut/branch-bound-price or interior points etc. and parameters like tolerances/optimality gap etc.&lt;br /&gt;&#xA;Local search is advisable if global optimum is taking longer than allowed and is generally the case for multi-variate non-convex objectives.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-12T20:22:13.077" LastActivityDate="2022-12-12T20:22:13.077" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9561" PostTypeId="2" ParentId="9557" CreationDate="2022-12-12T17:45:16.027" Score="3" Body="&lt;p&gt;Your cost structure is known as an &amp;quot;economy of scale&amp;quot;, and would convert your linear program into an integer linear program as follows. Let's say your cost breakpoints are &lt;span class=&quot;math-container&quot;&gt;$a_1 &amp;lt; a_2 &amp;lt; \dots &amp;lt; a_n$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$a_{n+1}$&lt;/span&gt; the upper limit on production. For instance, in your example you would have &lt;span class=&quot;math-container&quot;&gt;$a_1=1,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$a_2=10,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$a_3=100$&lt;/span&gt; and so on. Let &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; be the unit cost if production volume &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is between &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_{i+1}.$&lt;/span&gt; You can introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$y_1,\dots,y_n$&lt;/span&gt; with the constraint &lt;span class=&quot;math-container&quot;&gt;$$y_1 + \dots + y_n=1,$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$y_i=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$a_i \le x \le a_{i+1}.$&lt;/span&gt; We enforce that definition with the constraints &lt;span class=&quot;math-container&quot;&gt;$$x\ge a_1 y_1 + \dots + a_n y_n$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$x \le a_2 y_1 + \dots + a_{n_1} y_n.$$&lt;/span&gt; Your total production cost &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is then defined by &lt;span class=&quot;math-container&quot;&gt;$$z \ge c_i x - M(1-y_i) \quad i=1,\dots,n$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M=c_1 a_{n+1}$&lt;/span&gt; is an upper bound on production cost. (We could tighten that a bit if solver performance was a problem.) Note that this relies on the assumption that lower cost is better (i.e., you do not work for the federal government).&lt;/p&gt;&#xA;&lt;p&gt;Quality IP solvers are routinely used with success for these types of problems. An alternative might be constraint programming (CP). Some CP solvers are designed specifically to handle machine scheduling (and perhaps lot-sizing) problems.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-12-12T17:45:16.027" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9562" PostTypeId="1" AcceptedAnswerId="9564" CreationDate="2022-12-12T18:38:36.553" Score="2" ViewCount="189" Body="&lt;p&gt;Apologies for the english question, but I believe this forum will be better suited for answering my question.&lt;/p&gt;&#xA;&lt;p&gt;I am trying to decide whether I should use A MILP or An MILP, as I have seen both cases in the literature, with &amp;quot;A MILP&amp;quot; being more prevalent. As I understood it, from the English stack exchange, if we pronnounce it letter by letter, M-I-L-P, then one should use An. But if one pronounces it as a single word, MILP, then A MILP should be used.&lt;/p&gt;&#xA;&lt;p&gt;I am not a native a native english user, and I don't know if there is a definite right answer.&lt;/p&gt;&#xA;" OwnerUserId="5352" LastActivityDate="2022-12-12T20:03:47.583" Title="How do you pronounce MILP?" Tags="|terminology|academia|" AnswerCount="2" CommentCount="4" ClosedDate="2022-12-14T22:21:35.767" ContentLicense="CC BY-SA 4.0" />
  <row Id="9563" PostTypeId="2" ParentId="9555" CreationDate="2022-12-12T19:31:37.877" Score="2" Body="&lt;p&gt;You can do incremental changes&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/AlexFleischerParis/zoodocplex/blob/master/zooincremental.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/AlexFleischerParis/zoodocplex/blob/master/zooincremental.py&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from docplex.mp.model import Model&#xA;&#xA;# original model&#xA;&#xA;mdl = Model(name='buses')&#xA;nbbus40 = mdl.integer_var(name='nbBus40')&#xA;nbbus30 = mdl.integer_var(name='nbBus30')&#xA;mdl.add_constraint(nbbus40*40 + nbbus30*30 &amp;gt;= 300, 'kids')&#xA;mdl.minimize(nbbus40*500 + nbbus30*400)&#xA;&#xA;mdl.solve()&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&#xA;#now 350 kids instead of 300&#xA;&#xA;print()&#xA;print(&amp;quot;now 350 kids instead of 300&amp;quot;)    &#xA;    &#xA;mdl.get_constraint_by_name(&amp;quot;kids&amp;quot;).rhs=350;&#xA;mdl.solve()&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&#xA;# no more than 4 buses 40 seats&#xA;&#xA;print()&#xA;print(&amp;quot;no more than 4 buses 40 seats&amp;quot;)&#xA;&#xA;&#xA;mdl.get_var_by_name(&amp;quot;nbBus40&amp;quot;).ub=4&#xA;mdl.solve()&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&#xA;#change the objective so that cost for 40 seats is 450&#xA;#and remove the limit on the number of buses 40 seats&#xA;&#xA;print()&#xA;print(&amp;quot;change the objective so that cost for 40 seats is 450&amp;quot;)&#xA;print(&amp;quot;and remove the limit on the number of buses 40 seats  &amp;quot;)  &#xA;    &#xA;mdl.get_var_by_name(&amp;quot;nbBus40&amp;quot;).ub=1000&#xA;mdl.set_objective(&amp;quot;min&amp;quot;,nbbus40*450 + nbbus30*400);&#xA;mdl.solve()&#xA;&#xA;for v in mdl.iter_integer_vars():&#xA;    print(v,&amp;quot; = &amp;quot;,v.solution_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;which gives&#xA;nbBus40  =  6.0&#xA;nbBus30  =  2.0&#xA;now 350 kids instead of 300&#xA;nbBus40  =  8.0&#xA;nbBus30  =  1.0&#xA;no more than 4 buses 40 seats&#xA;nbBus40  =  2.0&#xA;nbBus30  =  9.0&#xA;change the objective so that cost for 40 seats is 450&#xA;and remove the limit on the number of buses 40 seats  &#xA;nbBus40  =  8.0&#xA;nbBus30  =  1.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-12-12T19:31:37.877" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9564" PostTypeId="2" ParentId="9562" CreationDate="2022-12-12T19:46:08.017" Score="3" Body="&lt;p&gt;I suggest &amp;quot;A MILP&amp;quot;, in which MILP is pronounced as a word sounding like &amp;quot;milK', except with a &amp;quot;P&amp;quot; rather than &amp;quot;k' as the end.&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;An MILP&amp;quot; would be appropriate if each letter were being sounded out separately. I.e., An &amp;quot;M&amp;quot; &amp;quot;I&amp;quot; &amp;quot;L&amp;quot; &amp;quot;P&amp;quot;.  In this case, &amp;quot;An&amp;quot; is needed rather than &amp;quot;A&amp;quot; because the letter &amp;quot;M&amp;quot; is sounded out as &amp;quot;Emm&amp;quot;, which begins with a vowel sound, hence requiring &amp;quot;an&amp;quot; rather than &amp;quot;a&amp;quot; to proceed it.&lt;/p&gt;&#xA;&lt;p&gt;I don't believe &amp;quot;An MILP&amp;quot; is commonly used, at least in the United States, because the individual letters of MILP are not usually sounded out.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2022-12-12T19:46:08.017" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9565" PostTypeId="2" ParentId="9562" CreationDate="2022-12-12T20:03:47.583" Score="2" Body="&lt;p&gt;Generally people say Mixed Integer model. here LP is like obvious, unless they need to mention like Nonlinear model or Quadratically constrained model.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-12T20:03:47.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9566" PostTypeId="1" AcceptedAnswerId="9595" CreationDate="2022-12-13T04:51:02.690" Score="1" ViewCount="438" Body="&lt;p&gt;If I use IPOPT (cyipopt) to solve nonlinear problems of large scale. It is optional to provide or not provide the hessian matrix, hessian structure, and Jacobian structure.&lt;/p&gt;&#xA;&lt;p&gt;The question is which one is faster, to provide them or to let the solver calculate them numerically? and which of them is more accurate?&lt;/p&gt;&#xA;" OwnerUserId="10454" LastEditorUserId="10454" LastEditDate="2022-12-15T07:09:11.397" LastActivityDate="2022-12-16T23:23:52.250" Title="Should I provide the hessian matrix, hessian structure, and Jacobian structure if I use cyipopt (IPOPT) if I am concerned about computation time?" Tags="|nonlinear-programming|nonconvex-programming|ipopt|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9567" PostTypeId="1" AcceptedAnswerId="9570" CreationDate="2022-12-13T09:29:28.470" Score="7" ViewCount="540" Body="&lt;p&gt;I am trying to implement a heuristic callback to a MILP with &lt;strong&gt;BOTH&lt;/strong&gt; integer variables and continuous variables. After finding a feasible solution, I tried to use &lt;strong&gt;setSolution()&lt;/strong&gt; to send the solution to CPLEX. I don't want CPLEX to spend time evaluating the solution as the feasibility is guaranteed during its generation process. However, according to the online material of setSolution(), I don't know how to update my solution with both integer and continuous variables. I found the following API:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Ympxt.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ympxt.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NNXwj.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NNXwj.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Another question is also related to the API. Do I have to convert all of my variables to a one-dimensional array? If so, what should I do if I constructed my model by defining variable matrices?&lt;/p&gt;&#xA;" OwnerUserId="10922" LastActivityDate="2022-12-13T17:15:57.247" Title="Implementing Heuristic Callback in CPLEX C++ API for MILP" Tags="|mixed-integer-programming|cplex|c++|callback|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9568" PostTypeId="2" ParentId="9567" CreationDate="2022-12-13T10:40:12.740" Score="6" Body="&lt;p&gt;Disclaimer: It's been a while since I used Cplex' C++ API.&lt;/p&gt;&#xA;&lt;p&gt;According to your question, you probably rather want to use a &lt;a href=&quot;https://www.ibm.com/docs/en/icos/22.1.0?topic=techniques-generic-callbacks&quot; rel=&quot;noreferrer&quot;&gt;generic callback&lt;/a&gt; and inject a feasible (heuristic) solution through &lt;a href=&quot;https://www.ibm.com/docs/en/icos/22.1.0?topic=c-callbackcontext#method_postHeuristicSolution&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;Callback::Context::postHeuristicSolution&lt;/code&gt;&lt;/a&gt; instead of using the legacy callback's &lt;code&gt;setSolution&lt;/code&gt; method.&lt;/p&gt;&#xA;&lt;p&gt;This way you can control how Cplex should complete (partial) solutions by the last argument &lt;code&gt;strat&lt;/code&gt;, which is just an &lt;a href=&quot;https://www.ibm.com/docs/en/icos/22.1.0?topic=e-solutionstrategytypes&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;SolutionStrategy&lt;/code&gt;&lt;/a&gt; enum. Consequently, you can inject a feasible solution without any checks by passing &lt;code&gt;IloCplex::SolutionStrategy::Types::NoCheck&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It's worth mentioning that a generic callback can be invoked from different Contexts, i.e.: Branching, Candidate, GlobalProgress, LocalProgress, Relaxation, ThreadDown, ThreadUp. You can find a description of each Context &lt;a href=&quot;https://www.ibm.com/docs/en/icos/22.1.0?topic=callbacks-what-is-context-generic-callback&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. (IMHO, it's also worth mentioning that the docs are pretty messy because most of the C++ Docs just link to the C API.)&lt;/p&gt;&#xA;&lt;p&gt;Each of the contexts has a &lt;code&gt;inContextName()&lt;/code&gt; method which returns true if the callback is called in the specific context. For instance, Cplex invokes your callback in the globalProgress context once it has found a feasible solution in one of the local threads and stored it in the global solution structure.&lt;/p&gt;&#xA;&lt;p&gt;Here's a (untested) code snippet that illustrates this approach for the globalProgress context:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;ilcplex/ilocplex.h&amp;gt;&#xA;&#xA;&#xA;class YourCallback : public IloCplex::Callback::Function{&#xA;  private:&#xA;        // Your private member's here&#xA;  public:&#xA;        Yourcallback() = default; // Your other constructors here&#xA;&#xA;        void invoke(IloCplex::Callback::Context const&amp;amp; context) override{&#xA;            if(context.inGlobalProgress()){&#xA;                // inject your feasible (heuristic) solution and disable&#xA;                // any checks by Cplex &#xA;                context.postHeuristicSolution(vars, vals, obj, IloCplex::SolutionStrategy::Types::NoCheck);&#xA;            }&#xA;        }&#xA;};&#xA;&#xA;int main(){&#xA;    // Create Cplex model&#xA;    IloEnv env;&#xA;    IloModel model(env);&#xA;    IloNumVarArray x(env);&#xA;    IloObjective obj(env);&#xA;    IloRangeArray cons(env);&#xA;    IloCplex cplex(model);&#xA;&#xA;    // Call default-constructor of your callback&#xA;    YourCallback cb;&#xA;&#xA;    // Set the context where your callback gets invoked&#xA;    cplex.use(&amp;amp;cb, IloCplex::Callback::Context::Id::GlobalProgress);&#xA;&#xA;    // solve the model&#xA;    cplex.solve();&#xA;}&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="3696" LastEditDate="2022-12-13T10:45:27.017" LastActivityDate="2022-12-13T10:45:27.017" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9570" PostTypeId="2" ParentId="9567" CreationDate="2022-12-13T17:15:57.247" Score="5" Body="&lt;ol&gt;&#xA;&lt;li&gt;As @Joni notes, there is a parameter that controls how much (if any) effort CPLEX spends checking solutions you supply.&lt;/li&gt;&#xA;&lt;li&gt;You can freely mix integer and continuous variables in the call to setSolution, in a single IloNumVarArray argument. Integer variables are special cases of numeric variables. You can put the variables in any order you wish, as long as the second argument (values) has the same order.&lt;/li&gt;&#xA;&lt;li&gt;Yes, you have to collapse your matrices of variables into 1-D arrays, and then glue together the arrays corresponding to different variables. Just declare an IloNumVarArray and then fill up the slots (and the corresponding slots of the second argument) using loops.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-12-13T17:15:57.247" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9571" PostTypeId="2" ParentId="8710" CreationDate="2022-12-14T12:14:19.350" Score="1" Body="&lt;p&gt;The basic idea behind the result is that &lt;span class=&quot;math-container&quot;&gt;$\exp(x) = 1 + x + O(x^2)$&lt;/span&gt;, whereby &lt;span class=&quot;math-container&quot;&gt;$\exp(x) = \exp(2^{-k} x)^{2^k} = \lim_{k \rightarrow \infty} (1 + 2^{-k} x)^{2^k}$&lt;/span&gt; holds for all &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}$&lt;/span&gt; and provides an approximation for any finite &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To verify the strength of the approximation the authors wished to establish a sandwich of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (1 - \epsilon)\exp(x) \leq (1+ 2^{-k} x)^{2^k} \leq \exp(x).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The upper bound of this sandwich is implied by the valid inequality, &lt;span class=&quot;math-container&quot;&gt;$(1 + y) \leq \exp(y)$&lt;/span&gt;, as seen by setting &lt;span class=&quot;math-container&quot;&gt;$y = 2^{-k} x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To lower bound of the sandwich is less obvious and we need to find a multiplier such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$f(x) \exp(x) \leq (1+ 2^{-k} x)^{2^k}$&lt;/span&gt; on the range &lt;span class=&quot;math-container&quot;&gt;$|x| \leq R$&lt;/span&gt;. Letting &lt;span class=&quot;math-container&quot;&gt;$f(x) = g(x)^{2^k}$&lt;/span&gt;, this simplifies to &lt;span class=&quot;math-container&quot;&gt;$g(y) \exp(y) \leq (1+ y)$&lt;/span&gt; on the range &lt;span class=&quot;math-container&quot;&gt;$|y| \leq 2^{-k} R$&lt;/span&gt;. Obviously, &lt;span class=&quot;math-container&quot;&gt;$g(y) \leq 1$&lt;/span&gt; for this to be valid and for a tight sandwich we also impose &lt;span class=&quot;math-container&quot;&gt;$g(0) = 1$&lt;/span&gt;. Thus &lt;span class=&quot;math-container&quot;&gt;$g(y) = 1 + O(y^2)$&lt;/span&gt; and this yields two obvious candidates:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$g(y) = 1 - y^2\quad$&lt;/span&gt; &lt;em&gt;(the simplest polynomial)&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$g(y) = \exp(-y^2)\quad$&lt;/span&gt; &lt;em&gt;(the simplest Gaussian function / bell curve)&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Although both of these multipliers establish the sandwich inequality for finite values of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, the latter stays closer to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in the neighborhood of &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, thus reaching the max deviation of &lt;span class=&quot;math-container&quot;&gt;$1 - \epsilon$&lt;/span&gt; for smaller values of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, thus resulting in a smaller second-order cone approximation.&lt;/p&gt;&#xA;&lt;p&gt;Why the authors added a constant factor and used &lt;span class=&quot;math-container&quot;&gt;$g(y) = \exp(-4y^2)$&lt;/span&gt; is beyond me. Probably they had a smarter way of producing the multiplier that didn't involve guessing.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2022-12-15T09:03:29.703" LastActivityDate="2022-12-15T09:03:29.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9572" PostTypeId="1" CreationDate="2022-12-14T18:38:52.987" Score="1" ViewCount="178" Body="&lt;p&gt;I am working on the following assignment problem:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;You may produce seven products by consuming three materials. The unit sales price and material consumption of each product are listed in Table 1. For each day, the supply of these three materials are limited. The supply limits are listed in Table 2. For each day, you need to determine the production quantity for each product.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/5K9kx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5K9kx.png&quot; alt=&quot;production detail table&quot; /&gt;&lt;/a&gt;&#xA;Formulate a linear integer program that generates a feasible production plan to maximize the total profit (which is also the total revenue, as there is no cost in this problem).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;How I formulated the problem using Mathematica:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1yCi5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1yCi5.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;br/&gt;(The first line is the objective function, the following lines are the constraints, and the last line specifies the decision variables... Sorry if this is explanatory to the point of condescending... Just want to clarify if anyone's not familiar with Mathematica's syntax.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I am getting the following error message:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QClVP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QClVP.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I am guessing I am making a very elementary mistake in how I am formulating my constraints.&lt;/p&gt;&#xA;" OwnerUserId="10929" LastEditorUserId="500" LastEditDate="2022-12-14T21:43:55.397" LastActivityDate="2022-12-14T21:53:04.220" Title="Homework Problem – Help Formulating Constraints" Tags="|constraint|software|" AnswerCount="1" CommentCount="3" ClosedDate="2022-12-14T22:15:38.883" ContentLicense="CC BY-SA 4.0" />
  <row Id="9573" PostTypeId="2" ParentId="9572" CreationDate="2022-12-14T18:59:29.497" Score="1" Body="&lt;p&gt;Seven issues:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Product 3, material 2 coefficient should be 3 instead of 10.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Lower bound of m3 should be &lt;span class=&quot;math-container&quot;&gt;$0 \le$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use double equals == for equality constraints.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &amp;amp;&amp;amp; instead of commas to delimit constraints:&lt;/p&gt;&#xA;&lt;p&gt;Maximize[{f, con1 &amp;amp;&amp;amp; con2 &amp;amp;&amp;amp; ...}, {x1, x2, ...}]&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;List all variables (both x and m) in the second argument.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You have not specified that the variables must take integer values.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Your constraints should instead be of the form &lt;span class=&quot;math-container&quot;&gt;$m_i = \sum_j a_{i,j} x_j$&lt;/span&gt;.  If you prefer, omit the &lt;span class=&quot;math-container&quot;&gt;$m_i$&lt;/span&gt; variables and just impose &lt;span class=&quot;math-container&quot;&gt;$\sum_j a_{i,j} x_j \le b_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-12-14T21:53:04.220" LastActivityDate="2022-12-14T21:53:04.220" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9574" PostTypeId="1" AcceptedAnswerId="9577" CreationDate="2022-12-14T23:06:20.550" Score="5" ViewCount="1946" Body="&lt;p&gt;Is there any Python library as published on PyPi, with genetic algorithm (GA) or GA inspired solver that helps with constrained optimization?&lt;br /&gt;&#xA;I am aware of Matlab's GA solver and also aware that costs of constraint violations can form part of my objective to minimize. But wanted to check if there's a library that can run on Python where I can specify the objective and an array of constraints.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="2556" LastEditDate="2022-12-15T12:17:18.480" LastActivityDate="2022-12-15T12:17:18.480" Title="Genetic Algorithm" Tags="|python|constrained-optimization|evolutionary|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9575" PostTypeId="2" ParentId="9574" CreationDate="2022-12-15T10:13:50.653" Score="6" Body="&lt;p&gt;Not exactly what you are needing, but DEAP allows to pass constraints as a decorator: &lt;a href=&quot;https://deap.readthedocs.io/en/master/tutorials/advanced/constraints.html&quot; rel=&quot;noreferrer&quot;&gt;https://deap.readthedocs.io/en/master/tutorials/advanced/constraints.html&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2022-12-15T10:13:50.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9576" PostTypeId="2" ParentId="9574" CreationDate="2022-12-15T11:13:17.590" Score="5" Body="&lt;p&gt;Try optapy.&lt;/p&gt;&#xA;&lt;p&gt;No genetic algorithms, but several other, more advanced metaheuristics. See &lt;a href=&quot;https://www.optapy.org&quot; rel=&quot;noreferrer&quot;&gt;https://www.optapy.org&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2022-12-15T11:13:17.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9577" PostTypeId="2" ParentId="9574" CreationDate="2022-12-15T12:12:54.687" Score="6" Body="&lt;p&gt;&lt;a href=&quot;https://pygad.readthedocs.io/en/latest/&quot; rel=&quot;noreferrer&quot;&gt;PyGAD&lt;/a&gt; seems to be a decent library, although I have never tested it myself. The documentation looks very complete, with good &lt;a href=&quot;https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#examples-2&quot; rel=&quot;noreferrer&quot;&gt;examples&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2022-12-15T12:12:54.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9578" PostTypeId="1" AcceptedAnswerId="9579" CreationDate="2022-12-15T12:28:21.197" Score="0" ViewCount="102" Body="&lt;p&gt;Consider the following model:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;max \quad Z &amp;amp;= 19x_1 - 3x_1^2 + 5x_2^2 - x_2^4 + 4x_3 \\&#xA;&amp;amp; s.t. \quad x_1 + 3x_2 + 3x_3 \leq 7 \\&#xA;&amp;amp; \quad \quad \quad x_1,x_2,x_3 \geq 0 &#xA;\end{align*}&lt;/span&gt;&#xA;&lt;br /&gt;&#xA;&lt;br /&gt;&#xA;Also note that all &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are integers. How does one formulate a Bellman equation for each stage? Can someone maybe give me a hint so I learn from it.&lt;/p&gt;&#xA;" OwnerUserId="10863" LastEditorUserId="500" LastEditDate="2022-12-16T17:23:24.413" LastActivityDate="2022-12-16T23:06:41.630" Title="Bellman Equation for nonlinear model" Tags="|nonlinear-programming|knapsack|dynamic-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9579" PostTypeId="2" ParentId="9578" CreationDate="2022-12-15T13:05:04.740" Score="4" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$f(n,b)$&lt;/span&gt; be the maximum objective value for the problem with variables &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n$&lt;/span&gt; and constraint right-hand side &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. You want to compute &lt;span class=&quot;math-container&quot;&gt;$f(3,7)$&lt;/span&gt;.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; be the constraint coefficient of &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$z_i(x_i)$&lt;/span&gt; be the contribution to the objective value for variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&#xA;For example, &lt;span class=&quot;math-container&quot;&gt;$z_2(x_2) = 5x_2^2-x_2^4$&lt;/span&gt;.&#xA;The boundary condition is &lt;span class=&quot;math-container&quot;&gt;$f(0,b)=0$&lt;/span&gt;.&#xA;To derive the Bellman equation as a recurrence for &lt;span class=&quot;math-container&quot;&gt;$f(n,b)$&lt;/span&gt; in terms of &lt;span class=&quot;math-container&quot;&gt;$f(n-1,.)$&lt;/span&gt;, condition on the finite number of choices for the value of &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(n,b) = \max_{x_n \in \{0,\dots,\lfloor b/a_n \rfloor\}} (z_n(x_n) + f(n-1,b-a_n x_n))$$&lt;/span&gt;&#xA;The resulting values of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; are as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{matrix}&#xA;    n\backslash b &amp;amp;0 &amp;amp;1 &amp;amp;2 &amp;amp;3 &amp;amp;4 &amp;amp;5 &amp;amp;6 &amp;amp;7 \\ &#xA;\hline&#xA;    0 &amp;amp;0 &amp;amp;0 &amp;amp;0 &amp;amp;0 &amp;amp;0 &amp;amp;0 &amp;amp;0 &amp;amp;0 \\&#xA;    1 &amp;amp;0 &amp;amp;16 &amp;amp;26 &amp;amp;30 &amp;amp;30 &amp;amp;30 &amp;amp;30 &amp;amp;30 \\&#xA;    2 &amp;amp;0 &amp;amp;16 &amp;amp;26 &amp;amp;30 &amp;amp;30 &amp;amp;30 &amp;amp;34 &amp;amp;34 \\&#xA;    3 &amp;amp;0 &amp;amp;16 &amp;amp;26 &amp;amp;30 &amp;amp;30 &amp;amp;30 &amp;amp;34 &amp;amp;\color{red}{34} \\ &#xA;\end{matrix}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-12-16T17:19:06.213" LastActivityDate="2022-12-16T17:19:06.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9580" PostTypeId="2" ParentId="9578" CreationDate="2022-12-15T14:33:02.780" Score="2" Body="&lt;p&gt;Assuming there are n stages, S symbolized by say &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; define &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$x_{1,s},x_{2,s}, x_{3,s}$&lt;/span&gt;: decision vector &lt;span class=&quot;math-container&quot;&gt;$X_s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z(X_s)$&lt;/span&gt; as optimal value for every stage &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; subject to same constraint&lt;br /&gt;&#xA;Using Bellman equation its&lt;br /&gt;&#xA;Z = max[&lt;span class=&quot;math-container&quot;&gt;$Z(X_{s_O}) + \sum_{i=1}^n Z(X_{s+i}:b^{T} X_{s+i} \le 7)]$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall s \in\ $&lt;/span&gt;S&lt;br /&gt;&#xA;s.t.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$b^T X_{s_0} \le 7$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would however solve it like:&#xA;max &lt;span class=&quot;math-container&quot;&gt;$Z(X_{s}) \ \forall s \in\ $&lt;/span&gt; S&lt;br /&gt;&#xA;s.t.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$b^T X_{s} \le 7$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$L_{s+1} \le max(Z(X_{s+1}:b^{T} X_{s+1} \le 7)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since now &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is integer and vector of &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is stage [1,2,3] so we have finite set&lt;br /&gt;&#xA;For stage=3, &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; can have values of [0,1,2]&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\begin{array}{c|c|c|} &#xA; &amp;amp; \text{$x_3$} &amp;amp; \text{$Z=4x_3$} &amp;amp; \text{Max} \\ \hline&#xA;\text{State 1} &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 \\ \hline&#xA;\text{State 2} &amp;amp; 1 &amp;amp; 4 &amp;amp; 4 \\\hline&#xA;\text{State 3} &amp;amp; 2 &amp;amp; 8 &amp;amp; 8 \\ \hline&#xA;\end{array}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$Max(stage=3)=8$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$x_3=2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For stage 2, &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; can have values of [0,1,2] with rhs of constraint=7&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\begin{array}{c|c|c|} &#xA; &amp;amp; \text{$x_2$} &amp;amp; \text{$x_3$} &amp;amp; \text{rhs=7} &amp;amp; \text{$Z=5x_2^2 - x_2^4 +max(Stage 3 \ Z \ for \ x_3$} &amp;amp; \text{Max}\\ \hline&#xA;\text{Row 1} &amp;amp; 0 &amp;amp; 0 &amp;amp; 7 &amp;amp; 0 &amp;amp; \\ \hline&#xA;\text{Row 2} &amp;amp; 0 &amp;amp; 1 &amp;amp; 7-3(1)=4 &amp;amp; 4 &amp;amp;  \\ \hline&#xA;\text{Row 3} &amp;amp; 0 &amp;amp; 2 &amp;amp; 1 &amp;amp; 8 &amp;amp; 8 \\ \hline&#xA;\text{Row 4} &amp;amp; 1 &amp;amp; 0 &amp;amp; 4 &amp;amp; 4 &amp;amp; \\ \hline&#xA;\text{Row 5} &amp;amp; 1 &amp;amp; 1 &amp;amp; 1 &amp;amp; 8 &amp;amp; 8 \\ \hline&#xA;\text{Row 5} &amp;amp; 2 &amp;amp; 0 &amp;amp; 1 &amp;amp; 4 &amp;amp; 4 \\ \hline&#xA;\end{array}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$Max(stage=2)=8$&lt;/span&gt; at either &lt;span class=&quot;math-container&quot;&gt;$(0,2)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$(1,1)$&lt;/span&gt;. Cant consider (1,2) or (2,1) as this will violate constraint.\&lt;/p&gt;&#xA;&lt;p&gt;For stage 1, &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; can have values of [0,1,2]&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\begin{array}{c|c|c|} &#xA; &amp;amp; \text{$x_1$} &amp;amp; \text{$x_2$} &amp;amp; \text{rhs=7} &amp;amp; \text{$Z=19x_1 - 3x_1^2 + max (Stage2 \ Z \ for \ x_2)$} &amp;amp; \text{Max}\\ \hline&#xA;\text{Row 1} &amp;amp; 0 &amp;amp; 0 &amp;amp; 7 &amp;amp; 8  \\ \hline&#xA;\text{Row 2} &amp;amp; 0 &amp;amp; 1 &amp;amp; 7-3(1)=4 &amp;amp; 8 \\ \hline&#xA;\text{Row 3} &amp;amp; 0 &amp;amp; 2 &amp;amp; 1 &amp;amp; 4 &amp;amp; 8 \\ \hline&#xA;\text{Row 4} &amp;amp; 1 &amp;amp; 0 &amp;amp; 6 &amp;amp; 24 \\ \hline&#xA;\text{Row 5} &amp;amp; 1 &amp;amp; 1 &amp;amp; 3 &amp;amp; 24 \\ \hline&#xA;\text{Row 5} &amp;amp; 1 &amp;amp; 2 &amp;amp; 0 &amp;amp; 20 &amp;amp; 24 \\ \hline&#xA;\text{Row 5} &amp;amp; 2 &amp;amp; 0 &amp;amp; 5 &amp;amp; 34 \\ \hline&#xA;\text{Row 5} &amp;amp; 2 &amp;amp; 1 &amp;amp; 2 &amp;amp; 34 &amp;amp; 34 \\ \hline&#xA;\text{Row 6} &amp;amp; 3 &amp;amp; 1 &amp;amp; 1 &amp;amp; 34 &amp;amp; 34 \\ \hline&#xA;\end{array}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_1 \ge 4$&lt;/span&gt; onwards objective val will start declining&lt;/p&gt;&#xA;&lt;p&gt;So at Stage 1, Z = 34 for &lt;span class=&quot;math-container&quot;&gt;$X = [3,1,0], [2,1,2]$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-16T23:06:41.630" LastActivityDate="2022-12-16T23:06:41.630" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9581" PostTypeId="1" AcceptedAnswerId="9582" CreationDate="2022-12-15T14:46:31.983" Score="2" ViewCount="185" Body="&lt;p&gt;Assume that we have a LP with the constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j} \left(c_j x_j + |c_j x_j - \alpha_j + \beta_j|\right) \leq y  $$&lt;/span&gt;&#xA;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\alpha_j + \beta_j \leq \lambda_j  $$&lt;/span&gt;&#xA;for all &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, where the (positive) cost vector &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is known, &lt;span class=&quot;math-container&quot;&gt;$x_j, \alpha_j$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\beta_j \geq 0$&lt;/span&gt; are variables. How do i linearize the absolute values, the usual trick with &lt;span class=&quot;math-container&quot;&gt;$|f(x)| \leq y$&lt;/span&gt; would not work because we have multiple absolute values and multiple variables inside the absolute values.&lt;/p&gt;&#xA;" OwnerUserId="10764" LastEditorUserId="500" LastEditDate="2022-12-15T15:23:21.180" LastActivityDate="2022-12-15T15:26:27.850" Title="Multiple absolute values with multiple variables in an LP" Tags="|linear-programming|linearization|absolute-value|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9582" PostTypeId="2" ParentId="9581" CreationDate="2022-12-15T15:26:27.850" Score="6" Body="&lt;p&gt;Yes, the usual technique applies.  Introduce a variable &lt;span class=&quot;math-container&quot;&gt;$z_j$&lt;/span&gt; (together with linear constraints) to represent the absolute value, and replace the original constraint with &lt;span class=&quot;math-container&quot;&gt;$\sum_j (c_j x_j + z_j) \le y$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-12-15T15:26:27.850" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9583" PostTypeId="1" CreationDate="2022-12-15T16:48:56.023" Score="-2" ViewCount="69" Body="&lt;p&gt;There are two matrices:&lt;br /&gt;&#xA;Matrix &lt;span class=&quot;math-container&quot;&gt;$S^{v\times v} \in \{0,1\}$&lt;/span&gt; this is a know parameter.&lt;br /&gt;&#xA;Matrix &lt;span class=&quot;math-container&quot;&gt;$X^{v\times p} \in \mathbb{N}$&lt;/span&gt;. Elements of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; are the variables.&lt;/p&gt;&#xA;&lt;p&gt;I want to model:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\textrm{if  }s_{v v'} = 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\textrm{then  } x_{vp} + x_{v'p} \leq 1 $$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="8891" LastEditorUserId="500" LastEditDate="2022-12-15T17:03:20.247" LastActivityDate="2022-12-15T17:14:35.737" Title="How to model the following &quot;if, then&quot; constraint" Tags="|mixed-integer-programming|modeling|constraint|indicator-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9584" PostTypeId="2" ParentId="9583" CreationDate="2022-12-15T17:02:14.830" Score="4" Body="&lt;p&gt;Because &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is a known parameter and not a decision variable, you do not need indicator constraints or any fancy modeling.  Just check the condition on &lt;span class=&quot;math-container&quot;&gt;$s_{vv'}$&lt;/span&gt; when you declare the constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{vp} + x_{v'p} \leq 1 \quad \text{for all $v,v',p$ such that $s_{vv&quot;}=1$}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-12-15T17:02:14.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9585" PostTypeId="2" ParentId="9583" CreationDate="2022-12-15T17:05:43.157" Score="-1" Body="&lt;p&gt;What about:&#xA;&lt;span class=&quot;math-container&quot;&gt;$s_{vv'}(x_{vp} + x_{v'p}) \leq 1 $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-15T17:14:35.737" LastActivityDate="2022-12-15T17:14:35.737" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9586" PostTypeId="1" CreationDate="2022-12-15T21:59:34.480" Score="-2" ViewCount="101" Body="&lt;p&gt;The objective function is of the form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$max$&lt;/span&gt;  &lt;span class=&quot;math-container&quot;&gt;$x^2/2+y^2/2+z^2/2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would like to convert it to piecewise linear function. How do I achieve that?&lt;/p&gt;&#xA;" OwnerUserId="10938" LastActivityDate="2022-12-15T22:21:45.400" Title="Converting a quadratic objective function in piecewise linear function" Tags="|linear-programming|quadratic-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9587" PostTypeId="2" ParentId="9586" CreationDate="2022-12-15T22:21:45.400" Score="1" Body="&lt;p&gt;One easy way is to add constraints like&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$2\lambda_x = x^2$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$2\lambda_y = y^2$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$2\lambda_z = z^2$&lt;/span&gt;&lt;br /&gt;&#xA;Then obj =&lt;span class=&quot;math-container&quot;&gt;$\lambda_x+\lambda_y+\lambda_z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Another complicated way is to consider each of the terms &lt;span class=&quot;math-container&quot;&gt;$x^2, y^2, z^2$&lt;/span&gt; or may be sum of them &lt;span class=&quot;math-container&quot;&gt;$(x^2+y^2 + z^2) \over 2 $&lt;/span&gt; piecewise&lt;br /&gt;&#xA;Say for &lt;span class=&quot;math-container&quot;&gt;$x^2 \over 2$&lt;/span&gt; identify points &lt;span class=&quot;math-container&quot;&gt;$(x_i,f_i)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i=1...n$&lt;/span&gt;&lt;br /&gt;&#xA;Introduce constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_i \delta_i x_i = x$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_i \delta_i f_i = \lambda_x$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_i \delta_i = 1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\delta_i \ge 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\delta_i$&lt;/span&gt; is special order set type 2 (two adjacent) are &lt;span class=&quot;math-container&quot;&gt;$\gt 0$&lt;/span&gt;&lt;br /&gt;&#xA;Then objective same as before replacing &lt;span class=&quot;math-container&quot;&gt;$x,y,z$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\lambda_x,\lambda_y,\lambda_z$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-15T22:21:45.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9588" PostTypeId="1" AcceptedAnswerId="9589" CreationDate="2022-12-16T05:39:26.187" Score="2" ViewCount="362" Body="&lt;p&gt;This is not a technical question, but more curious if anyone has seen any software that converts english rules into linear constraints for MILP solvers?  The rules would be industry specific and not general, thus for example specifying pseudocode for a shift scheduling problem (ex: an employee cannot work 3 shift days in a row) for warehouses or in healthcare setting, so not industry generic.&lt;/p&gt;&#xA;" OwnerUserId="4581" LastActivityDate="2022-12-16T13:22:50.740" Title="pseudocode to convert english to constraint" Tags="|mixed-integer-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9589" PostTypeId="2" ParentId="9588" CreationDate="2022-12-16T11:47:22.367" Score="3" Body="&lt;p&gt;Statement rules like as in the example above are turned into propositional logic. In commercial software that have something called rules engine a truth table is used to convert such rules to logical flow.&lt;br /&gt;&#xA;Any automation/workflow based software with rules engine may have this capability, like Capterra, process marker, SAP may have that. If searching on Google suggested search string is 'sentence based rules to logic or constraints'&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-16T11:47:22.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9590" PostTypeId="1" AcceptedAnswerId="9594" CreationDate="2022-12-16T12:21:22.043" Score="4" ViewCount="371" Body="&lt;p&gt;Assuming I had solved the a problem to optimality, I want to remove a constraint.&lt;/p&gt;&#xA;&lt;p&gt;What happens to primal feasibility?&#xA;What happens to dual feasibility?&lt;/p&gt;&#xA;&lt;p&gt;How to solve this new problem efficiently?&lt;/p&gt;&#xA;&lt;p&gt;My understanding is that the primal feasibility is maintained and I can solve the new problem using primal simplex very fast.&lt;/p&gt;&#xA;&lt;p&gt;Assumption is that the original is solved to optimal it’s using dual simplex.&lt;/p&gt;&#xA;" OwnerUserId="3954" LastEditorUserId="491" LastEditDate="2022-12-16T15:47:39.430" LastActivityDate="2022-12-16T22:45:06.083" Title="What happens to the dual and primal feasibility when a constraint is removed after finding an optimal solution?" Tags="|linear-programming|duality|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9591" PostTypeId="2" ParentId="9588" CreationDate="2022-12-16T13:22:50.740" Score="6" Body="&lt;p&gt;I tried &lt;a href=&quot;https://www.linkedin.com/pulse/optimization-zoo-openai-chatgpt-alex-fleischer/&quot; rel=&quot;noreferrer&quot;&gt;chatGPT&lt;/a&gt; with my &lt;a href=&quot;https://medium.com/ibm-data-ai/optimization-simply-do-more-with-less-zoo-buses-and-kids-66940178db6&quot; rel=&quot;noreferrer&quot;&gt;Zoo, bus and optimization example&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GEm4C.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GEm4C.jpg&quot; alt=&quot;question&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and I got&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E9afg.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E9afg.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and then&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wt645.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wt645.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-12-16T13:22:50.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9593" PostTypeId="2" ParentId="9590" CreationDate="2022-12-16T18:17:18.313" Score="1" Body="&lt;p&gt;I assume that you meant by removed constraints is something like redundant constraints, otherwise, by that, the feasibility space of the primal is totally changing.&lt;/p&gt;&#xA;&lt;p&gt;Based on the duality theorem, the feasibility of the primal is the optimality of the dual, and the optimality of the primal is the feasibility of the dual. Also, the constraints in the primal are already converted to the corresponding dual variables. Now, let's show what's happened to the primal and dual with the redundant constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{l}&#xA;\text{Maximize} &amp;amp; Z =  3x_1 + 2x_2\\&#xA;\text{subject to:}&amp;amp; \\&#xA;&amp;amp;x_1  + x_2 \leq  9\\&#xA;&amp;amp;3x_1 + x_2 \leq 18\\&#xA;&amp;amp;x_1 \leq  7\\&#xA;&amp;amp;x_2 \leq  6\\&#xA;&amp;amp;x_1,x_2\geq 0,&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The feasible space of the problem is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2BPOk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2BPOk.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;as you can see the last two constraints are redundant and can be omitted without changing the problem's feasible space and the optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;Now, consider the dual form of the original primal:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{l} &#xA;\text{Minimize} &amp;amp; W =  9y_1 + 18y_2 + 7y_3 + 6y_4\\&#xA;\text{subject to:}&amp;amp; \\&#xA;&amp;amp;y_1 + 3y_2 + y_3 \geq 3\\&#xA;&amp;amp;y_1 + y_2 + y_4 \geq 2\\&#xA;&amp;amp;y_1,y_2,y_3,y_4\geq 0,&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;By omitting the primal last two constraints, one can see the variables &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_4$&lt;/span&gt; would be removed from the dual without changing the solution space and also optimal value.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nykDU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nykDU.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Actually, this is a tiny problem and I am really not sure if may it be a general rule or not.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-12-16T18:17:18.313" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9594" PostTypeId="2" ParentId="9590" CreationDate="2022-12-16T22:45:06.083" Score="4" Body="&lt;p&gt;Since the primal problem was feasible before you removed the constraint, it remains feasible. Any feasible solution to the original problem obviously satisfies all the remaining constraints.&lt;/p&gt;&#xA;&lt;p&gt;Dual feasibility is tied to primal boundedness. Since the original primal problem had an optimal solution, so did the original dual problem (strong duality). If removing one primal constraint makes the primal problem unbounded, the dual becomes infeasible (weak duality). If the primal remains bounded, and thus still has an optimal solution, the dual remains feasible (and has an optimal solution -- strong duality again).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-12-16T22:45:06.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9595" PostTypeId="2" ParentId="9566" CreationDate="2022-12-16T23:23:52.250" Score="1" Body="&lt;p&gt;To solve nonlinear optimization problems with IPOPT, it is &lt;strong&gt;most probably&lt;/strong&gt; better to provide the exact hessian matrix and its structure as well as Jacobian structure, especially for large problems. That would make the solver faster and coverage to a better candidate solution.&lt;/p&gt;&#xA;&lt;p&gt;However, it is not difficult to compare this solution with the solution you will get if you solve with not providing them; just comment the matrix and the structures out!&lt;/p&gt;&#xA;&lt;p&gt;Thanks to Mark L. Stone. As he mentioned Try the &lt;strong&gt;exact&lt;/strong&gt; hessian first.&lt;/p&gt;&#xA;" OwnerUserId="10454" LastActivityDate="2022-12-16T23:23:52.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9596" PostTypeId="1" CreationDate="2022-12-17T00:09:59.620" Score="0" ViewCount="292" Body="&lt;p&gt;When solve with ipopt, we can use Jax to calculate the hessian matrix and jacobian instead of providing it ourselves. However, ipopt with Jax is very slow for large problems.&lt;/p&gt;&#xA;&lt;p&gt;If we calculate the hessian matrix and jacobian ourselves and use the Problem interface, we can define their structures. Defining the hessian matrix and jacobian structures will make the solver faster, especially if sparse.&lt;/p&gt;&#xA;&lt;p&gt;Can we use the Jax library to calculate the hessian matrix and jacobian and still be able to define the structures? I want to take the power of both.&lt;/p&gt;&#xA;&lt;p&gt;Otherwise, using the problem interface and not Jax will be better.&lt;/p&gt;&#xA;&lt;p&gt;Problem interface: &lt;a href=&quot;https://cyipopt.readthedocs.io/en/stable/tutorial.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cyipopt.readthedocs.io/en/stable/tutorial.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10454" LastActivityDate="2022-12-17T00:09:59.620" Title="Can we use the Jax library with ipopt to calculate the hessian matrix and Jacobian and still be able to define the structures?" Tags="|optimization|nonconvex-programming|ipopt|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9597" PostTypeId="1" CreationDate="2022-12-17T14:27:26.667" Score="4" ViewCount="126" Body="&lt;p&gt;I have a Dantzig-Wolfe decomposition question with the following questions&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;Maximize: 2x_1 +3x_2+4x_3+2x_4 \\&#xA;s.t. \quad &amp;amp;  x_1 +x_2+2x_3+x_4 \le 15\\&#xA;      &amp;amp; x_1 +x_2+2x_3+x_4 \le 10\\&#xA;      &amp;amp;x_1 +2x_2 \le 8\\&#xA;      &amp;amp;x_1 \le 3\\&#xA;      &amp;amp;x_3+3x_4 \le 6\\&#xA;      &amp;amp;x_4 \le 4\\&#xA;&amp;amp;x_1,x_2,x_3,x_4 \ge 0\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;a) Find the extreme point of the diagonal blocks (e.g., using the graphical method) and&#xA;reformulate this optimization problem in terms of that extreme points using the representation&#xA;theorem.&lt;/p&gt;&#xA;&lt;p&gt;b) Assuming that the dual variable for the binding constraints (the one with ≤ 15 and&#xA;≤ 10) are equal to 1 and 2, respectively. Formulate the corresponding sub-problems and find&#xA;the vectors Vih to be added as the columns in the master problem&lt;/p&gt;&#xA;&lt;p&gt;I posted the solutions but am unsure how to solve part (b). Is the solution optimal since the z of both subproblems is zero?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YokE1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YokE1.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YDnWg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YDnWg.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10948" LastEditorUserId="500" LastEditDate="2022-12-18T18:41:19.853" LastActivityDate="2022-12-20T00:59:37.630" Title="How to find the vectors to be added as the columns in the master problem of Dantzig-Wolfe Decomposition?" Tags="|optimization|column-generation|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9598" PostTypeId="1" AcceptedAnswerId="9599" CreationDate="2022-12-18T05:37:32.500" Score="0" ViewCount="127" Body="&lt;p&gt;The &lt;strong&gt;max_wall_time&lt;/strong&gt; and &lt;strong&gt;max_cpu_time&lt;/strong&gt; are not working in ipopt (cyipopt).&lt;/p&gt;&#xA;&lt;p&gt;See example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nlp = cyipopt.Problem(n=len(x0), m=len(cl), problem_obj=HS071(),&#xA;                      lb=lb, ub=ub, cl=cl, cu=cu)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The following are not working:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nlp.add_option('max_wall_time', 20)&#xA;&#xA;nlp.add_option('max_cpu_time', 20)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;it says &lt;code&gt;TypeError: Error while assigning an option.&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Any idea about how to set these stopping criteria in ipopt (cyipopt)?&lt;/p&gt;&#xA;" OwnerUserId="10454" LastEditorUserId="10454" LastEditDate="2022-12-18T10:32:27.910" LastActivityDate="2022-12-18T10:32:27.910" Title="The max_wall_time and max_cpu_time in ipopt are not working?" Tags="|nonlinear-programming|nonconvex-programming|ipopt|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9599" PostTypeId="2" ParentId="9598" CreationDate="2022-12-18T05:47:34.543" Score="2" Body="&lt;p&gt;The solution is shown below. I just figured that out, so I thought it would be better to leave the question that might be helpful for others.&lt;/p&gt;&#xA;&lt;p&gt;It accepts float rather than integer!&lt;/p&gt;&#xA;&lt;p&gt;nlp.add_option('max_wall_time', &lt;strong&gt;20.0&lt;/strong&gt;)&lt;/p&gt;&#xA;&lt;p&gt;nlp.add_option('max_cpu_time', &lt;strong&gt;20.0&lt;/strong&gt;)&lt;/p&gt;&#xA;" OwnerUserId="10454" LastActivityDate="2022-12-18T05:47:34.543" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9600" PostTypeId="1" AcceptedAnswerId="9621" CreationDate="2022-12-18T11:32:21.877" Score="-1" ViewCount="140" Body="&lt;p&gt;I use Ipopt to solve a problem with sparse hessian and jacobian matrices.&lt;/p&gt;&#xA;&lt;p&gt;If I provide the hessian matrix: its structure, and the non zeros elements in the hessian matrix, it will be really fast.&lt;/p&gt;&#xA;&lt;p&gt;If I do not define the hessian structure but provide the whole hessian matrix, which is almost zeros, the solver will be slow but converges to a better solution!&lt;/p&gt;&#xA;&lt;p&gt;Does that mean the zeros help the solver find a better solution?&lt;/p&gt;&#xA;" OwnerUserId="10454" LastEditorUserId="10454" LastEditDate="2022-12-18T12:52:33.607" LastActivityDate="2022-12-21T11:56:47.377" Title="Ipopt finds a better solution if I do not eliminate the zeros in the hessian matrix ?(we eliminate the zeros by defining the structure)" Tags="|nonlinear-programming|nonconvex-programming|ipopt|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9601" PostTypeId="2" ParentId="7566" CreationDate="2022-12-18T20:46:03.357" Score="4" Body="&lt;p&gt;Here is a straightforward conversion of Python PuLP code from &lt;a href=&quot;https://machinelearninggeek.com/sensitivity-analysis-in-python/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://machinelearninggeek.com/sensitivity-analysis-in-python/&lt;/a&gt; into Google OR Tools:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pandas as pd&#xA;from ortools.linear_solver import pywraplp&#xA;from ortools.init import pywrapinit&#xA;&#xA;solver = pywraplp.Solver.CreateSolver('GLOP')&#xA;A = solver.NumVar(0.0, solver.infinity(), &amp;quot;A&amp;quot;)&#xA;B = solver.NumVar(0.0, solver.infinity(), &amp;quot;B&amp;quot;)&#xA;solver.Add(4 * A + 10 * B &amp;lt;= 100, &amp;quot;c0&amp;quot;)&#xA;solver.Add(2 * A + 1 * B &amp;lt;= 22, &amp;quot;c1&amp;quot;)&#xA;solver.Add(3 * A + 3 * B &amp;lt;= 39, &amp;quot;c2&amp;quot;)&#xA;&#xA;solver.Maximize(60 * A + 50 * B )&#xA;&#xA;status = solver.Solve()&#xA;if status == pywraplp.Solver.OPTIMAL:&#xA;    print('Solution:')&#xA;    print('Objective value =', solver.Objective().Value())&#xA;    print('A =', A.solution_value())&#xA;    print('B =', B.solution_value())&#xA;else:&#xA;    print('The problem does not have an optimal solution.')&#xA;    &#xA;activities = solver.ComputeConstraintActivities()&#xA;o = [{'Name':c.name(), 'shadow price':c.dual_value(), 'slack': c.ub() - activities[i]} for i, c in enumerate(solver.constraints())]&#xA;print(pd.DataFrame(o))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Output is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Solution:&#xA;Objective value = 740.0&#xA;A = 9.000000000000002&#xA;B = 3.9999999999999973&#xA;  Name  shadow price  slack&#xA;0   c0     -0.000000   24.0&#xA;1   c1     10.000000    0.0&#xA;2   c2     13.333333    0.0   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Shadow prices can be retrieved from constraint.dual_value() and slack by substracting the constraint activities from the upper bound of the constraint.&lt;/p&gt;&#xA;" OwnerUserId="10947" LastActivityDate="2022-12-18T20:46:03.357" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9602" PostTypeId="1" AcceptedAnswerId="9603" CreationDate="2022-12-19T03:41:14.797" Score="2" ViewCount="279" Body="&lt;p&gt;I was hoping to get some help in modelling the following logic, I know that it would use some kind of Big M formulation but I am not sure how. Thank you in advance!&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt; is a set whose values are all binary, &lt;span class=&quot;math-container&quot;&gt;$\Omega(n,k)$&lt;/span&gt; is one of the value.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\Omega(n,k)=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$p(k,n)\ge 0$&lt;/span&gt;, else &lt;span class=&quot;math-container&quot;&gt;$p(k,n)=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This question is similar to the following:&#xA;&lt;a href=&quot;https://or.stackexchange.com/questions/3426/modelling-an-if-then-else-logic-in-mip&quot;&gt;Modelling an if-then-else logic in MIP&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10951" LastEditorUserId="491" LastEditDate="2022-12-19T13:24:56.457" LastActivityDate="2022-12-19T14:34:37.487" Title="An if-then-else logic to construct constraint" Tags="|mixed-integer-programming|linear-programming|nonconvex-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9603" PostTypeId="2" ParentId="9602" CreationDate="2022-12-19T04:24:17.587" Score="2" Body="&lt;p&gt;Assuming that &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt; is a set of variables, as opposed to parameters, you can just write &lt;span class=&quot;math-container&quot;&gt;$0 \le p(k,n) \le M_{k,n} \cdot \Omega(n, k)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M_{k,n}$&lt;/span&gt; is a known upper bound for &lt;span class=&quot;math-container&quot;&gt;$p(k,n).$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="491" LastEditDate="2022-12-19T13:25:35.267" LastActivityDate="2022-12-19T13:25:35.267" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9604" PostTypeId="1" CreationDate="2022-12-19T11:45:26.957" Score="1" ViewCount="177" Body="&lt;p&gt;Let, &lt;span class=&quot;math-container&quot;&gt;$\mathcal{C}=\{1,2,\cdots,C\}$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{U}=\{1,2,\cdots,U\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}_u$&lt;/span&gt; is a subset of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{C}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$u\in \mathcal{U}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_{u,c}$&lt;/span&gt; is a binary variable with &lt;span class=&quot;math-container&quot;&gt;$u=1,2,\cdots,U$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c=1,2,\cdots,C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, with &lt;span class=&quot;math-container&quot;&gt;$u=1$&lt;/span&gt;, if &lt;span class=&quot;math-container&quot;&gt;$d_{1,2}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_{1,5}=1$&lt;/span&gt;, then we want to enforce that both &lt;span class=&quot;math-container&quot;&gt;$2\in\mathcal{S}_u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$5\in\mathcal{S}_1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Similarly,&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$u=3$&lt;/span&gt;, if &lt;span class=&quot;math-container&quot;&gt;$d_{3,2}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_{3,7}=1$&lt;/span&gt;, then we want to enforce that both &lt;span class=&quot;math-container&quot;&gt;$2\in\mathcal{S}_3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$7\in\mathcal{S}_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What is an efficient way of generalising this constraint for any &lt;span class=&quot;math-container&quot;&gt;$u\in \mathcal{U}$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="836" LastActivityDate="2022-12-19T13:51:06.717" Title="How to express this constraint efficiently?" Tags="|mixed-integer-programming|integer-programming|indicator-constraints|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9605" PostTypeId="2" ParentId="9604" CreationDate="2022-12-19T12:30:04.373" Score="1" Body="&lt;p&gt;So if &lt;span class=&quot;math-container&quot;&gt;$d_{u,c_1} \cdot d_{u,c_2} =1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\{c_1,c_2\}$&lt;/span&gt; part of &lt;span class=&quot;math-container&quot;&gt;$S_u$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_{u,c_1} + d_{u,c_2} -1 \le z_{u,c_1,c_2}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{u,c_1,c_2} \le d_{u,c_1}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{u,c_1,c_2} \le d_{u,c_2}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{u,c_1,c_2} \in\ \{0,1\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If using set,&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$S_u \cup z_{u,c_1,c_2}\cdot\{c_1,c_2\}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-19T12:30:04.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9606" PostTypeId="2" ParentId="9604" CreationDate="2022-12-19T13:51:06.717" Score="3" Body="&lt;p&gt;Just use a sparse index set of ordered pairs &lt;span class=&quot;math-container&quot;&gt;$(u,c)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$d_{u,c}$&lt;/span&gt;. Explicitly, the set is &lt;span class=&quot;math-container&quot;&gt;$\{(u,c):u\in\mathcal{U},c\in S_u\}$&lt;/span&gt;. This way, instead of defining variables that must take the value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, you just omit them from the problem.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-12-19T13:51:06.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9607" PostTypeId="2" ParentId="9602" CreationDate="2022-12-19T13:55:49.533" Score="2" Body="&lt;p&gt;I missed the part where &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is continuous and just have to be non-negative. Then same as above answer&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$p(n,k) \le M\Omega(k,n)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$p(n,k) \ge 0$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is upper bound of &lt;span class=&quot;math-container&quot;&gt;$p(n,k)$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-19T14:34:37.487" LastActivityDate="2022-12-19T14:34:37.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9608" PostTypeId="1" CreationDate="2022-12-19T17:05:10.167" Score="2" ViewCount="66" Body="&lt;p&gt;I have a C API program uploaded here in &lt;a href=&quot;https://www.dropbox.com/sh/qen96t54eon3x0h/AAA_Oco9TLVE4_EfErBrSfqta?dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dropbox&lt;/a&gt; that is an LP. Here is the problem: When I compile the C file it gives me &amp;quot;1017 Not available for mixed-integer problems&amp;quot; while the problem is apparently LP. At the same time, when it prints its solution, it is integer. However, when I write the lp in a .lp file and solve it with CPLEX terminal, it gives the right solution.&lt;/p&gt;&#xA;" OwnerUserId="10954" LastEditorUserId="36" LastEditDate="2022-12-19T17:38:39.917" LastActivityDate="2022-12-19T17:38:39.917" Title="Discrepancy between CPLEX interface solution and C API" Tags="|cplex|modeling-languages|api|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9609" PostTypeId="2" ParentId="9597" CreationDate="2022-12-19T17:47:47.757" Score="-1" Body="&lt;p&gt;Please read this book Bazaraa et al. Linear Programming and Network Flows, 3rd edition, page 345 the numerical&lt;a href=&quot;https://i.stack.imgur.com/yO1a4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yO1a4.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt; example 7.2.&lt;/p&gt;&#xA;" OwnerUserId="10954" LastEditorUserId="10954" LastEditDate="2022-12-20T00:59:37.630" LastActivityDate="2022-12-20T00:59:37.630" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9610" PostTypeId="1" CreationDate="2022-12-20T09:22:38.343" Score="2" ViewCount="229" Body="&lt;p&gt;I have a large nonlinear and nonconvex problem. It also has sin (theta) and cos(theta).&lt;/p&gt;&#xA;&lt;p&gt;While gurobipy accepts sin or cos using the general constraint. gurobipy uses piecewise linear approximation, which means gurobipy introduces binary variables.&lt;/p&gt;&#xA;&lt;p&gt;If theta dimension is 10,000; gurobipy introduces at least 10,000 binary variables to formulate the sin(theta) or cos(theta). Does that mean it would be better to solve the problem with ipopt, if the computation speed is important? As we want to avoid adding a huge number of binary variables.&lt;/p&gt;&#xA;&lt;p&gt;ipopt can solve the nonlinear problem without introducing binary variables.&lt;/p&gt;&#xA;&lt;p&gt;I guess ipopt will be faster, but gurobipy will converge to a better solution.&lt;/p&gt;&#xA;&lt;p&gt;Any thought?&lt;/p&gt;&#xA;" OwnerUserId="10454" LastActivityDate="2022-12-20T11:14:19.323" Title="Should I replace sin(theta) by piecewise linear and solve the linear problem using gurobipy or use ipopt to solve the nonlinear probelm?" Tags="|gurobi|ipopt|gurobipy|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9611" PostTypeId="2" ParentId="9610" CreationDate="2022-12-20T11:14:19.323" Score="3" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Gurobi can currently solve mixed-integer (non)convex problems with&#xA;(bi)linear terms, i.e., the only nonlinearities allowed are squares&#xA;and products of 2 variables. If your model is nonconvex, you have to&#xA;set the NonConvex parameter to 2.&lt;/p&gt;&#xA;&lt;p&gt;If your problem involves any other nonlinear functions, you can use&#xA;Gurobi's general functions feature. There, Gurobi approximates&#xA;nonlinear functions via piecewise-linear constraints.&lt;/p&gt;&#xA;&lt;p&gt;You don't have to change the &amp;quot;solver&amp;quot;, you just have to possibly set&#xA;the NonConvex parameter. Unless you mean whether you can change to a&#xA;different MINLP solver. Then yes, you could for example change to the&#xA;open-source MINLP solver SCIP.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Also, the following example can give some good starting points to you:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;import math&#xA;&#xA;def f(u):&#xA;  return math.atan(u)&#xA;&#xA;m = gp.Model()&#xA;&#xA;lbz = -2&#xA;ubz =  2&#xA;z = m.addVar(lb=lbz, ub=ubz, vtype=GRB.CONTINUOUS, name=&amp;quot;z&amp;quot;)&#xA;y = m.addVar(lb=-math.pi/2, ub=math.pi/2, vtype=GRB.CONTINUOUS, name=&amp;quot;y&amp;quot;)&#xA;&#xA;# Compute piecewise-linear arctan function for z&#xA;npts = 101&#xA;ptu = []&#xA;ptf = []&#xA;for i in range(npts):&#xA;    ptu.append(lbz + (ubz - lbz) * i / (npts - 1))&#xA;    ptf.append(f(ptu[i]))&#xA;&#xA;# Add constraint y = arctan(z) as piecewise-linear approximation&#xA;m.addGenConstrPWL(z,y,ptu,ptf,&amp;quot;PWLarctan&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For more details please, see these links:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/11466556605713-MINLP-solver?page=1#community_comment_11522661949713&quot; rel=&quot;nofollow noreferrer&quot;&gt;MINLP &amp;amp; solver&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/10776952609425-arctan-in-gUrobi-optimization-python-&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arctan in GurobiPy&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-12-20T11:14:19.323" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9612" PostTypeId="1" CreationDate="2022-12-20T12:20:05.817" Score="1" ViewCount="228" Body="&lt;p&gt;I'm trying to use Pulp to solve VRP problem. Here is the model:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for K in range(1,K+1):&#xA;  # set problem type&#xA;  problem = pulp.LpProblem('Etrash_Model', pulp.LpMinimize)&#xA;&#xA;  # set decision valiables&#xA;  #x = pulp.LpVariable.dicts('x', ((i, j, k) for k in range(1,K+1) for i in V for j in V if i!=j  ), lowBound=0, upBound=1, cat='Binary')&#xA;  #y = pulp.LpVariable.dicts('y',(i for i in range(1,K+1)), lowBound=0, upBound=1, cat='Binary')&#xA;  #x=pulp.LpVariable.dicts('x', ((i, j,k) for i in V for j in V for k in range(K) if i!=j ), lowBound=0, upBound=1, cat='Binary')&#xA;  #u = pulp.LpVariable.dicts('u',N, lowBound=0, cat='Continuous')&#xA;  #print(&amp;quot;Customer set &amp;quot;, V)&#xA;  x = [[[pulp.LpVariable(&amp;quot;x%s_%s,%s&amp;quot;%(i,j,k), cat=&amp;quot;Binary&amp;quot;) if i != j else None for k in range(K)] for j in range(n)] for i in range(n)]&#xA;  #print(&amp;quot;decision variables &amp;quot;, x)&#xA;&#xA;  #set objective function&#xA;  problem += pulp.lpSum([distances[i][j] * x[i][j][k]  if j!=i else None for i in range(n) for j in range(n) for k in range(K)])&#xA;&#xA;#set constraints&#xA;#cst 2&#xA;  for j in range(1,n) :&#xA;    problem+= pulp.lpSum(x[i][j][k] if j!=i else 0 &#xA;                       for i in range(n)&#xA;                       for k in range(K)) ==1&#xA;&#xA;#cst 3&#xA;  for k in range(K):&#xA;        problem += pulp.lpSum(x[0][j][k] for j in range(1,n)) == 1&#xA;        problem += pulp.lpSum(x[i][0][k] for i in range(1,n)) == 1&#xA;&#xA;#cst 4&#xA;  for k in range(K):&#xA;    for j in range(n):&#xA;      problem += pulp.lpSum(x[i][j][k] if i != j else 0 for i in range(n)) -  pulp.lpSum(x[j][i][k] for i in range(n)) == 0&#xA;&#xA;#cst 5&#xA;    for k in range(K):&#xA;        problem += pulp.lpSum(df.demand[j] * x[i][j][k] if i != j else 0 for i in range(n) for j in range(1,n)) &amp;lt;= vehicle_capacity &#xA;&#xA;# eliminate subtour (cst 6)&#xA;  subtours = []&#xA;  for i in range(2,n):&#xA;    subtours += itertools.combinations(range(1,n), i)&#xA;&#xA;  for s in subtours:&#xA;    problem += pulp.lpSum(x[i][j][k] if i !=j else 0 for i, j in itertools.permutations(s,2) for k in range(K)) &amp;lt;= len(s) - 1&#xA;    &#xA;# print vehicle_count which needed for solving problem&#xA;# print calculated minimum distance value&#xA;    status = problem.solve()&#xA;    &#xA;    if status == 1:&#xA;        print(&amp;quot;ok---------------------&amp;quot;)&#xA;        print('Vehicle Requirements:', K)&#xA;        print('Moving Distance:', pulp.value(problem.objective))&#xA;        status, pulp.LpStatus[status], pulp.value(problem.objective)&#xA;        break&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The problem that I get these solutions:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ok---------------------&#xA;Vehicle Requirements: 2&#xA;Moving Distance: 667.1482646478239&#xA;ok---------------------&#xA;Vehicle Requirements: 3&#xA;Moving Distance: 788.1102137014474&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And when asking the optimal:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;status, pulp.LpStatus[status], pulp.value(problem.objective)&#xA;&#xA;(1, 'Optimal', 788.1102137014474)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I don't understand why it is 788.11. It would be 667.14 since it is a minimization problem.&lt;/p&gt;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="10962" LastEditorUserId="491" LastEditDate="2022-12-20T12:55:48.527" LastActivityDate="2022-12-20T12:55:48.527" Title="Problem of optimal solution generated with Pulp" Tags="|linear-programming|vehicle-routing|pulp|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9613" PostTypeId="1" CreationDate="2022-12-20T15:01:07.703" Score="6" ViewCount="257" Body="&lt;p&gt;I have the following optimization problem:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min&amp;amp;\quad x\\&#xA;\text{s.t.}&amp;amp;\quad x=\max_{i} \{x_{i}\}\\&#xA;&amp;amp;\quad x_{i}y_{i}=z_{i}\\&#xA;&amp;amp;\quad x_{i}, y_{i}, z_{i}\geqslant0&#xA;\end{align}&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,\ldots,n\}, n \in \mathbb{N}$&lt;/span&gt; and some linear equality constraints involving &lt;span class=&quot;math-container&quot;&gt;$y_{i}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z_{i}$&lt;/span&gt; and other variables.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to reformulate this problem with usual conic constraints (linear constraints, quadratic cone, rotated quadratic cone, primal power cone or its dual, primal exponential or its dual, semidefinite) accepted in software like Mosek for example?&lt;/p&gt;&#xA;&lt;p&gt;If not possible, how do I demonstrate it?&lt;/p&gt;&#xA;" OwnerUserId="10964" LastEditorUserId="68" LastEditDate="2022-12-20T16:12:05.390" LastActivityDate="2022-12-20T16:12:05.390" Title="Is it possible to express these constraints with basic cones?" Tags="|convex-optimization|cone|mosek|generalized-linear-fractional|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9615" PostTypeId="2" ParentId="9613" CreationDate="2022-12-20T15:57:34.377" Score="5" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_i = \frac{z_i}{y_i}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then, presuming &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; does not appear in any of the other constraints, this appears to be a &lt;strong&gt;Generalized linear-fractional programming problem&lt;/strong&gt; per section 4.3.2 &amp;quot;Linear-fractional programming&amp;quot; of &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/bv_cvxbook.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Boyd and Vandenberghe, &amp;quot;Convex Optimization&amp;quot;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It can be solved by bisection as discussed in &lt;a href=&quot;http://www.seas.ucla.edu/%7Evandenbe/ee236a/lectures/lfp.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vandenberghe's notes for Lecture 8 of EE236A (Fall 2013-14) &amp;quot;Linear-fractional optimization&amp;quot;&lt;/a&gt;  As stated there on p. 8-7 (edited by me to add some details for clarity),&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In contrast to Linear Fractional Programming problem  of p. 8–2, generalized Linear Fractional Programming problem is not reducible to a Linear Programming problem. It can be solved efficiently as a sequence of Linear Programming feasibility problems using&#xA;the bisection algorithm on p. 8-9.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So, using the bisection algorithm, this could be solved by making a sequence of calls to Mosek, or any other LP solver.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2022-12-20T16:10:02.030" LastActivityDate="2022-12-20T16:10:02.030" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9616" PostTypeId="1" CreationDate="2022-12-20T16:04:29.693" Score="1" ViewCount="72" Body="&lt;p&gt;I was hoping to get some help in modelling the following logic. I tried to solve it by &amp;quot;Big-M method&amp;quot; but failed. Thank you in advance!&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a(k,n)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b(k,n)$&lt;/span&gt; are known constants, &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mu_k$&lt;/span&gt; are variables used for optimization, and such logic is used at a gp model.&lt;/p&gt;&#xA;&lt;p&gt;My original logic is as follows: if &lt;span class=&quot;math-container&quot;&gt;$a_{k,n}-b_{k,n}\ge\dfrac{\lambda}{\mu_k}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(To ensure that the following expression has a real number solution)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$p_{k,n} = \frac{1}{2}\left[\sqrt{\left(\frac1{a_{k,n}}-\frac1{b_{k,n}}\right)^2+\frac{4\mu_k}{\lambda}\left(\frac1{b_{k,n}}-\frac1{a_{k,n}}\right)}-\left(\frac1{a_{k,n}}+\frac1{b_{k,n}}\right)\right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;else &lt;span class=&quot;math-container&quot;&gt;$p_{k,n} = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I first tried to avoid the condition &lt;span class=&quot;math-container&quot;&gt;$a_{k,n}-b_{k,n} \ge \frac{\lambda}{\mu_k}$&lt;/span&gt; by changing to the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{tmp1} &amp;amp;= \left[\left(\frac1{a_{k,n}}-\frac1{b_{k,n}}\right)^2+\frac{4\mu_k}{\lambda}\left(\frac1{b_{k,n}}-\frac1{a_{k,n}}\right)\right]^+\\\text{tmp2}&amp;amp;=\sqrt{\text{tmp1}}-\left(\frac1{a_{k,n}}+\frac1{b_{k,n}}\right)\\p_{k,n}&amp;amp;=\frac{1}{2}[\text{tmp2}]^+\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$[x]^+=\max\{0,x\}$&lt;/span&gt;, but got the following error&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Disciplined convex programming error:&#xA;    Cannot perform the operation max({constant},{concave})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;due to &lt;span class=&quot;math-container&quot;&gt;\begin{align}\text{tmp1} &amp;amp;= \left[\left(\frac1{a_{k,n}}-\frac1{b_{k,n}}\right)^2+\frac{4\mu_k}{\lambda}\left(\frac1{b_{k,n}}-\frac1{a_{k,n}}\right)\right]^+\\&amp;amp;=\max\left\{0,\left(\frac1{a_{k,n}}-\frac1{b_{k,n}}\right)^2+\frac{4\mu_k}{\lambda}\left(\frac1{b_{k,n}}-\frac1{a_{k,n}}\right)\right\}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now I feel that the if-then-else constraint may be converted in a big-M way, but I don't know how to express it; but maybe this intuition is wrong.&lt;/p&gt;&#xA;" OwnerUserId="10951" LastEditorUserId="123" LastEditDate="2022-12-20T16:30:44.870" LastActivityDate="2022-12-20T17:37:30.860" Title="An if-then-else logic whose condition is an inequality" Tags="|linear-programming|nonlinear-programming|geometric-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9617" PostTypeId="2" ParentId="9616" CreationDate="2022-12-20T17:18:10.573" Score="2" Body="&lt;p&gt;As @J.Dionisio suggested, you can:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$a_{k,n}-b_{k,n} - {\lambda \over \mu_{k}} \le Mx_k$&lt;/span&gt; where&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_k \in\ \{0,1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is upper bound of any value possible in the model (constants or vars)&lt;br /&gt;&#xA;Also since dividing will be problem replace&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_k \cdot \mu_k = 1$&lt;/span&gt; and&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\lambda \cdot z = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So first constraint turns like&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$(a_{k,n}-b_{k,n}) - y_k \lambda \le Mx_k$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_k \lambda - (a_{k,n}-b_{k,n}) \le M(1-x_k)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$2p_{n,k} = x_k \cdot tmp1$&lt;/span&gt;&lt;br /&gt;&#xA;In tmp1, replace &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-20T17:37:30.860" LastActivityDate="2022-12-20T17:37:30.860" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9618" PostTypeId="1" AcceptedAnswerId="9619" CreationDate="2022-12-20T20:05:55.037" Score="4" ViewCount="445" Body="&lt;p&gt;From the &lt;em&gt;Integer Programming&lt;/em&gt; book by Conforti et al, I've sniped the image below. At the bottom of this image there is the remnants of a tableau, presumably from several iterations of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Simplex_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;simplex algorithm&lt;/a&gt;. I cannot reproduce their numbers. It may just be that my simplex algorithm skills are poor.&lt;/p&gt;&#xA;&lt;p&gt;However, I cannot reproduce the numbers using SCIP either. I get numbers that are close, but the signs and order don't quite match. Doing it by hand I cannot get fractional values on every slack since I don't go through that many iterations. Is there something wrong with my approach? What pivot rule are they using, or what elements did they pivot on to arrive those numbers?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CUz68.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CUz68.png&quot; alt=&quot;Enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7428" LastEditorUserId="1160" LastEditDate="2022-12-21T21:45:52.333" LastActivityDate="2022-12-21T21:45:52.333" Title="Help me reproduce this tableau from the 'Integer Programming' book" Tags="|linear-programming|simplex|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9619" PostTypeId="2" ParentId="9618" CreationDate="2022-12-21T02:50:32.460" Score="7" Body="&lt;p&gt;The dictionary is correct.  You can check your work by using Robert Vanderbei's &lt;a href=&quot;https://vanderbei.princeton.edu/JAVA/pivot/simple.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Simple Pivot Tool&lt;/a&gt;:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/uxOvu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uxOvu.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The following sequence of pivots yields the same optimal dictionary:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Enter Leave&#xA;x3    w3&#xA;x2    w2&#xA;x1    w5&#xA;w2    w4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2KvUP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2KvUP.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2022-12-21T17:37:34.367" LastActivityDate="2022-12-21T17:37:34.367" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9620" PostTypeId="2" ParentId="9555" CreationDate="2022-12-21T10:16:30.140" Score="1" Body="&lt;p&gt;Now with the CPLEX Matrix API you can do the same kind of changes of course.&lt;/p&gt;&#xA;&lt;p&gt;Let me start with the example from&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://medium.com/@alexfleischer_84755/optimization-simply-do-more-with-less-zoo-buses-and-kids-part2-python-java-c-cc04558e49b5&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://medium.com/@alexfleischer_84755/optimization-simply-do-more-with-less-zoo-buses-and-kids-part2-python-java-c-cc04558e49b5&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And suppose that in buses 40 seats, suddenly we allow 70 kids.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Import packages.&#xA;import cplex&#xA;my_prob = cplex.Cplex()&#xA;my_obj = [500, 400]&#xA;my_ub = [cplex.infinity, cplex.infinity]&#xA;my_lb = [0.0, 0.0]&#xA;my_ctype = &amp;quot;II&amp;quot;&#xA;my_colnames = [&amp;quot;nbBus40&amp;quot;, &amp;quot;nbBus30&amp;quot;]&#xA;my_rhs = [300]&#xA;my_rownames = [&amp;quot;nbKids&amp;quot;]&#xA;my_sense = &amp;quot;G&amp;quot;&#xA;my_prob.objective.set_sense(my_prob.objective.sense.minimize)&#xA;my_prob.variables.add(obj=my_obj, lb=my_lb, ub=my_ub, types=my_ctype,&#xA;names=my_colnames)&#xA;rows = [[[&amp;quot;nbBus40&amp;quot;, &amp;quot;nbBus30&amp;quot;], [40,30]]]&#xA;my_prob.linear_constraints.add(lin_expr=rows, senses=my_sense,&#xA;rhs=my_rhs, names=my_rownames)&#xA;my_prob.solve()&#xA;print(&amp;quot;cost  = &amp;quot;, my_prob.solution.get_objective_value())&#xA;numcols = my_prob.variables.get_num()&#xA;    &#xA;sol = my_prob.solution.get_values()&#xA;for j in range(numcols):&#xA;    print(my_colnames[j],&amp;quot;  = &amp;quot;, sol[j])&#xA;&#xA;#now let us do some change&#xA;&#xA;print(&amp;quot;now the 40 seats buses can bring 70 kids to the zoo&amp;quot;)&#xA;&#xA;my_prob.linear_constraints.set_coefficients(0,0,70)&#xA;&#xA;my_prob.solve()&#xA;print(&amp;quot;cost  = &amp;quot;, my_prob.solution.get_objective_value())&#xA;numcols = my_prob.variables.get_num()&#xA;    &#xA;sol = my_prob.solution.get_values()&#xA;for j in range(numcols):&#xA;    print(my_colnames[j],&amp;quot;  = &amp;quot;, sol[j])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;works fine and gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cost  =  3800.0&#xA;nbBus40   =  6.0&#xA;nbBus30   =  2.0&#xA;now the 40 seats buses can bring 70 kids to the zoo&#xA;&#xA;MIP start 'm1' defined initial solution with objective 3800.0000.&#xA;&#xA;cost  =  2400.0&#xA;nbBus40   =  4.0&#xA;nbBus30   =  1.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="627" LastActivityDate="2022-12-21T10:16:30.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9621" PostTypeId="2" ParentId="9600" CreationDate="2022-12-21T11:56:47.377" Score="4" Body="&lt;p&gt;No. Whether you use the sparse derivatives or the full ones, IPOPT will perform nearly the same calculations. The only differences are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;speed (the sparse one is much faster for sparse problems), and&lt;/li&gt;&#xA;&lt;li&gt;accumulation of numerical error.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;IPOPT is sensitive to small fluctuations in the numbers, so assuming all derivatives you provided are correct and equivalent, the latter is the most likely reason you got a different answer.&lt;/p&gt;&#xA;&lt;p&gt;Another possibility (depending on how you're running IPOPT) if you actually provided &lt;em&gt;nothing&lt;/em&gt; the second time around, is that it switched to finite differences and got a better result by luck. This would also explain the slowness.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2022-12-21T11:56:47.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9623" PostTypeId="1" AcceptedAnswerId="9624" CreationDate="2022-12-22T20:51:43.347" Score="5" ViewCount="275" Body="&lt;p&gt;I have a multiple assignment problem, with an added cost for &amp;quot;repeat assignments&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;For example, consider the cost matrix:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;        sing  guitar  bass  drums&#xA;ringo      8      10    10      2&#xA;paul       3       4     2      5&#xA;john       2       4     4      5&#xA;george     4       2     4      5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If The Beatles are recording a single song, we can optimize this with standard OR tools, such as linear programming.  We get the following assignment:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;        sing  guitar  bass  drums&#xA;ringo      0       0     0      1&#xA;paul       0       0     1      0&#xA;john       1       0     0      0&#xA;george     0       1     0      0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Suppose that we are recording two songs.  Being the polymaths that they are, The Beatles get bored playing the same roles in every single song, so they would really like to switch things up a bit.  In other words, Paul &lt;em&gt;could&lt;/em&gt; play bass on song 2, but he'd like to sing, maybe, so there is an added cost for him to play bass twice.&lt;/p&gt;&#xA;&lt;p&gt;One way to incorporate this is to add a power on the assignment term in the objective equation.  I.e. the &amp;quot;no multiple assignment penalty&amp;quot; objective equation for the regular assignment problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum c_{i,j} * x_{i,j} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Becomes, say:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum c_{i,j} * x_{i,j}^2 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So if Paul plays bass on song one and sings on song two, the overall cost due to Paul is &lt;span class=&quot;math-container&quot;&gt;$2*1 + 3*1 = 5$&lt;/span&gt;, but if Paul plays bass on &lt;em&gt;both&lt;/em&gt; songs, then the overall cost due to Paul is not &lt;span class=&quot;math-container&quot;&gt;$2*2 = 4$&lt;/span&gt;, but &lt;span class=&quot;math-container&quot;&gt;$2*2^2 = 8$&lt;/span&gt;.  We could adjust the &lt;span class=&quot;math-container&quot;&gt;$^2$&lt;/span&gt; to be an arbitrary &lt;span class=&quot;math-container&quot;&gt;$^k$&lt;/span&gt; for how much we want to penalize repeat assignments.&lt;/p&gt;&#xA;&lt;p&gt;The problem with this approach is that the objective function is no longer linear.  Is there a way to introduce penalties for multiple assignments, while keeping the problem linear?&lt;/p&gt;&#xA;" OwnerUserId="10974" LastEditorUserId="981" LastEditDate="2023-12-22T14:53:18.643" LastActivityDate="2023-12-22T14:53:18.643" Title="Adding linear penalties for multiple assignments" Tags="|mixed-integer-programming|or-tools|assignment-problem|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9624" PostTypeId="2" ParentId="9623" CreationDate="2022-12-22T21:27:44.530" Score="5" Body="&lt;p&gt;One possible approach is to define an increasing sequence of cost coefficients &lt;span class=&quot;math-container&quot;&gt;$c_{ij}^{(k)}$&lt;/span&gt; representing the costs of assigning &lt;span class=&quot;math-container&quot;&gt;$i\rightarrow j$&lt;/span&gt; a total of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; times. In the objective function, introduce a new variable &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; for the cost of any &lt;span class=&quot;math-container&quot;&gt;$i\rightarrow j$&lt;/span&gt; assignments, along with the constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_{ij} \ge c_{ij}^{(1)} x_{ij}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_{ij} \ge c_{ij}^{(2)} (x_{ij} - 1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\cdots$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_{ij} \ge c_{ij}^{(n)} (x_{ij} - n)$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the upper limit on how many times the &lt;span class=&quot;math-container&quot;&gt;$i\rightarrow j$&lt;/span&gt; assignment might be made. You will want the costs to satisfy &lt;span class=&quot;math-container&quot;&gt;$c_{ij}^{(2)} &amp;gt; 2 c_{ij}^{(1)},$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$c_{ij}^{(3)} &amp;gt; 2 c_{ij}^{(2)},$&lt;/span&gt; etc.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-12-22T21:27:44.530" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9625" PostTypeId="1" CreationDate="2022-12-22T23:18:45.327" Score="1" ViewCount="58" Body="&lt;p&gt;In my two-stage continuous NLP problem, I have a constraint in second stage:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{g,k}$&lt;/span&gt; = &lt;span class=&quot;math-container&quot;&gt;$X_{g,0} + a_{g} d_{g} $&lt;/span&gt;, if  &lt;span class=&quot;math-container&quot;&gt;$X_{g,k} \in [X_g^u,X_g^l]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{g,k} = X_g^u$&lt;/span&gt;, if   &lt;span class=&quot;math-container&quot;&gt;$X_{g,k} \geq X_g^u$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{g,k} = X_g^l$&lt;/span&gt;, if   &lt;span class=&quot;math-container&quot;&gt;$X_{g,k} \leq X_g^l$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$a_{g}$&lt;/span&gt; is a predefined factor between {0,1}, and &lt;span class=&quot;math-container&quot;&gt;$d_{g}$&lt;/span&gt; is an unbounded variable. &lt;span class=&quot;math-container&quot;&gt;$X_{g,0}$&lt;/span&gt; is a first-stage value of variable &lt;span class=&quot;math-container&quot;&gt;$X_{g,k}$&lt;/span&gt;. It can be implemented using two binary variables but I want to keep the problem continues for efficient computation. How can I handle such constraints?&lt;/p&gt;&#xA;" OwnerUserId="10869" LastActivityDate="2022-12-22T23:18:45.327" Title="How to avoid complementarity constraints in continuous nonlinear program?" Tags="|optimization|mixed-integer-programming|linear-programming|integer-programming|nonlinear-programming|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9626" PostTypeId="2" ParentId="9623" CreationDate="2022-12-22T23:36:50.847" Score="3" Body="&lt;p&gt;Prof @prubin's solution is apt but if d.v. are needed to be raised to power k then, taking cue from geometric optimization (&lt;a href=&quot;https://optimization.mccormick.northwestern.edu/index.php/Logarithmic_transformation&quot; rel=&quot;nofollow noreferrer&quot;&gt;reference&lt;/a&gt;):&lt;br /&gt;&#xA;Introduce vars &lt;span class=&quot;math-container&quot;&gt;$z_{i,j}$&lt;/span&gt;&lt;br /&gt;&#xA;Objective = &lt;span class=&quot;math-container&quot;&gt;$log(\sum c_{i,j}\cdot e^{z_{i,j}})$&lt;/span&gt;&lt;br /&gt;&#xA;s.t.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{i,j} \ge k\cdot log(x_{i,j})$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="491" LastEditDate="2023-01-06T02:26:54.570" LastActivityDate="2023-01-06T02:26:54.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9627" PostTypeId="1" CreationDate="2022-12-23T00:21:55.903" Score="3" ViewCount="206" Body="&lt;p&gt;I have a non-convex Quadratic Programming over unite simplex set. I have a valid lower bound on the objective function (goal is minimization problem).&#xA;If I add a constraint like&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(x)\geq lower~bound,$$&lt;/span&gt;&#xA;the solver time is increased, since I add a non-convex constraint!&#xA;is there any efficient way to use a lower bound in the input when we use Gurobi as a solver (in yalmip)?&lt;/p&gt;&#xA;" OwnerUserId="9818" LastActivityDate="2022-12-23T01:12:47.837" Title="How do I pass an objective bound to Gurobi?" Tags="|linear-programming|gurobi|nonlinear-programming|quadratic-programming|yalmip|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9628" PostTypeId="2" ParentId="9627" CreationDate="2022-12-23T01:12:47.837" Score="2" Body="&lt;p&gt;There's a &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/refman/cutoff.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;cutoff&lt;/a&gt; parameter that may help.&#xA;Another approach, though may or may not work is to try with &lt;span class=&quot;math-container&quot;&gt;$Z(x)$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; lower_bound&lt;span class=&quot;math-container&quot;&gt;$+f(x)$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-23T01:12:47.837" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9629" PostTypeId="1" AcceptedAnswerId="9630" CreationDate="2022-12-23T21:39:05.333" Score="3" ViewCount="129" Body="&lt;p&gt;I have a MILP (Xpress) constraint, which is doing what I want it to, but I'm struggling to translate it into a LaTeX friendly mathematical expression.&lt;/p&gt;&#xA;&lt;p&gt;The below code enforces that in the matrix &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;, the sum of the row indexed at seat, is less than or equal to the element in vector &lt;code&gt;seat_vars&lt;/code&gt;, indexed at &lt;code&gt;seat&lt;/code&gt;.  In plain English, one or zero viewers can be assigned to each seat; put another may, at most one person could be assigned to each seat.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;for seat in seat_vars.keys():&#xA;    constraint = [V[seat, v] for v in range(1, num_viewers+1)]&#xA;    sum_ = solver.Sum(constraint)&#xA;    solver.Add(sum_ &amp;lt;= seat_vars[seat])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What is the proper mathematical way to express this in LaTeX?&lt;/p&gt;&#xA;&lt;p&gt;The best I've got so far is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i=1}^{n} V_{\text{seat},i} \leq \text{seatvars}_{\text{seat}} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, I'm unsure how to &amp;quot;for loop&amp;quot; over every seat; eg this constraint holds for each seat.&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="8" LastEditDate="2022-12-26T15:26:44.543" LastActivityDate="2022-12-26T15:26:44.543" Title="Expressing $\{0,1\}$ assignment across a matrix in MILP?" Tags="|mixed-integer-programming|python|binary-variable|assignment-problem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9630" PostTypeId="2" ParentId="9629" CreationDate="2022-12-23T21:46:24.867" Score="5" Body="&lt;p&gt;Okay...&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n V_{seat,i} \le seatvars_{seat} \quad \forall seat \in\ $&lt;/span&gt;seatVars&lt;br /&gt;&#xA;Looping 'for' in done by &lt;span class=&quot;math-container&quot;&gt;$\forall$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-23T21:46:24.867" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9631" PostTypeId="2" ParentId="7933" CreationDate="2022-12-25T12:02:35.997" Score="1" Body="&lt;p&gt;In general, you cannot assume that setting N=5 will not cut off an optimal solution. Because you do not know the MIP objective value, but just that of the (LP?) relaxation. This objective value could be arbitrarily far away from the optimal objective value of the MIP.&lt;/p&gt;&#xA;" OwnerUserId="10905" LastActivityDate="2022-12-25T12:02:35.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9632" PostTypeId="1" AcceptedAnswerId="11133" CreationDate="2022-12-25T15:58:33.490" Score="2" ViewCount="138" Body="&lt;p&gt;I was wondering if there is any write up that shows how to perform dual simplex with boxed variables where &lt;code&gt;l &amp;lt;= x &amp;lt;= u&lt;/code&gt; and preferably with a small example (like 4-5 variable problem with a few iterations).&lt;/p&gt;&#xA;&lt;p&gt;I tried searching but I keep getting into some dissertations.&lt;/p&gt;&#xA;" OwnerUserId="3954" LastActivityDate="2023-10-20T21:00:53.793" Title="Any good write up for Dual simplex with boxed variables?" Tags="|simplex|dual-simplex|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9633" PostTypeId="2" ParentId="9632" CreationDate="2022-12-25T20:20:35.600" Score="2" Body="&lt;p&gt;Two good options:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4615-0257-9&quot; rel=&quot;nofollow noreferrer&quot;&gt;István Maros: Computational Techniques of the Simplex Method&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.researchgate.net/profile/Achim-Koberstein/publication/35632487_The_dual_simplex_method_techniques_for_a_fast_and_stable_implementation_Elektronische_Ressource/links/0a85e52ef5144e9031000000/The-dual-simplex-method-techniques-for-a-fast-and-stable-implementation-Elektronische-Ressource.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Achim Koberstein: The dual simplex method, techniques for a fast and stable implementation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The second one is a dissertation but I don't understand why this should be an issue.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2022-12-25T20:20:35.600" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9634" PostTypeId="2" ParentId="9632" CreationDate="2022-12-26T00:36:49.243" Score="2" Body="&lt;p&gt;A textbook that deals with this at the undergraduate level is Chvatal's &lt;em&gt;Linear Programming&lt;/em&gt;.   Sadly, it's out of print, but you might be able to find it in an academic library.&lt;/p&gt;&#xA;" OwnerUserId="103" LastActivityDate="2022-12-26T00:36:49.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9635" PostTypeId="2" ParentId="9632" CreationDate="2022-12-26T07:24:51.907" Score="3" Body="&lt;p&gt;For simplicity, you can write the bounded variable as two additional constraints. In the following example, there are four positive variables with a bounded variable &lt;span class=&quot;math-container&quot;&gt;$3 \leq x_1 \leq 5$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{l}&#xA;\text{Maximize} &amp;amp; Z =  -15x_1 - 10x_2 - 8x_3 - 4x_4\\&#xA;\text{subject to:}&amp;amp; \\&#xA;&amp;amp;-3x_1 - 5x_2 - 3x_3 \leq -5\\&#xA;&amp;amp;-5x_1 - 2x_2 - 6x_4 \leq -3\\&#xA;&amp;amp;x_1 \geq  3\\&#xA;&amp;amp;x_1 \leq  5\\&#xA;&amp;amp;x_1, x_2, x_3, x_4 \geq 0,&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, by performing the dual simplex algorithm the problem is solved in four iterations.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7LaAH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7LaAH.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;To try that yourself please, took a look at this &lt;a href=&quot;https://cbom.atozmath.com/CBOM/Simplex.aspx?q=ds&amp;amp;q1=4%604%60MAX%60Z%60x1%2cx2%2cx3%2cx4%60-15%2c-10%2c-8%2c-4%60-3%2c-5%2c-3%2c0%3b-5%2c-2%2c0%2c-6%3b1%2c0%2c0%2c0%3b1%2c0%2c0%2c0%60%3c%3d%2c%3c%3d%2c%3e%3d%2c%3c%3d%60-5%2c-3%2c3%2c5%60%60D%60false%60true%60false%60true%60false%60false%60true%601&amp;amp;dp=2&amp;amp;do=1#PrevPart&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2022-12-26T07:24:51.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9636" PostTypeId="1" CreationDate="2022-12-27T15:06:21.477" Score="0" ViewCount="44" Body="&lt;p&gt;I am studying &lt;a href=&quot;https://www.zib.de/groetschel/pubnew/paper/groetschelpadberg1985.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; chapter and I am stuck on page 262. In fact, I do not understand why the pair (E, &lt;span class=&quot;math-container&quot;&gt;$\tilde{\mathcal{S}}$&lt;/span&gt;) is a matroid where &lt;span class=&quot;math-container&quot;&gt;$\tilde{\mathcal{S}}$&lt;/span&gt; is the set of all the subsets of all 1-trees on the complete graph &lt;span class=&quot;math-container&quot;&gt;$K_n$&lt;/span&gt;. Following the definition in &lt;a href=&quot;https://en.wikipedia.org/wiki/Matroid&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;, I am supposed to prove three things:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The empty set is in &lt;span class=&quot;math-container&quot;&gt;$\tilde{\mathcal{S}}$&lt;/span&gt;: this is true, as it is a subset of every set, and thus a subset of every 1-tree.&lt;/li&gt;&#xA;&lt;li&gt;Every subset of &lt;span class=&quot;math-container&quot;&gt;$S\in \tilde{\mathcal{S}}$&lt;/span&gt; is in &lt;span class=&quot;math-container&quot;&gt;$\tilde{\mathcal{S}}$&lt;/span&gt; as well: this is trivially true, as every subset of a subset of a 1-tree is a subset of a 1-tree as well.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$I,J\in\tilde{\mathcal{S}}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\vert I \vert &amp;lt; \vert J \vert $&lt;/span&gt;, then there exists &lt;span class=&quot;math-container&quot;&gt;$e \in J \setminus I$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$I\cup{e}$&lt;/span&gt; is still in &lt;span class=&quot;math-container&quot;&gt;$\tilde{\mathcal{S}}$&lt;/span&gt;: This is where I am stuck. Consider the following examples: Let &lt;span class=&quot;math-container&quot;&gt;$K_5$&lt;/span&gt; be the complete graph on 5 nodes and consider the 1-tree &lt;span class=&quot;math-container&quot;&gt;${(1, 2), (1, 4), (2, 3), (4, 3), (4,5)}$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$I = {(1, 2)}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$J = {(1, 4), (2, 3)}$&lt;/span&gt;. The two sets are both subsets of the original 1-tree, but they are disjoint, so I cannot prove the existence of such &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5722" LastActivityDate="2022-12-27T15:21:09.657" Title="Prove that a structure related to 1-tree is a matroid?" Tags="|spanning-trees|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9637" PostTypeId="2" ParentId="9636" CreationDate="2022-12-27T15:21:09.657" Score="3" Body="&lt;p&gt;For property 3, &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$I \cup e$&lt;/span&gt; need not be subsets of the same &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;-tree. In your example, you can take either edge in &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-12-27T15:21:09.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9638" PostTypeId="2" ParentId="39" CreationDate="2022-12-27T21:22:03.780" Score="-1" Body="&lt;p&gt;The four required constraints are summarized below for &lt;strong&gt;non-negative&lt;/strong&gt; case:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z&amp;lt;=M.x$&lt;/span&gt;          (1)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z&amp;lt;=y$&lt;/span&gt;            (2)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z&amp;gt;=y-(1-x).M$&lt;/span&gt;    (3)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z&amp;gt;=0$&lt;/span&gt;            (4)&lt;/p&gt;&#xA;&lt;p&gt;For &lt;strong&gt;negative and nonnegative&lt;/strong&gt;, the general formula is give here: &lt;a href=&quot;https://www.fico.com/en/resource-access/download/3217&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.fico.com/en/resource-access/download/3217&lt;/a&gt;   (page 7, section 2.8)&lt;/p&gt;&#xA;" OwnerUserId="10454" LastEditorUserId="10454" LastEditDate="2022-12-28T13:03:56.290" LastActivityDate="2022-12-28T13:03:56.290" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9639" PostTypeId="1" CreationDate="2022-12-28T02:01:10.763" Score="2" ViewCount="114" Body="&lt;p&gt;I have a system of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; machines and &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; users.&#xA;Each machine has a capacity in terms of number of resources.&lt;/p&gt;&#xA;&lt;p&gt;Let, machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; has &lt;span class=&quot;math-container&quot;&gt;$\zeta_m$&lt;/span&gt; resources.&lt;/p&gt;&#xA;&lt;p&gt;Each user has a service demand &lt;span class=&quot;math-container&quot;&gt;$d_u$&lt;/span&gt; and there is a link between any user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and any machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; defined as &lt;span class=&quot;math-container&quot;&gt;$\theta_{u,m}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The link quality between the user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is defined as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$l_{u}=\log_2\left(1+\frac{\theta_{u,m}}{\sum_{m'=1,m'\neq m}^{M}\theta_{u,m'}}\right),$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; is constant value which is very small.&lt;/p&gt;&#xA;&lt;p&gt;The amount of resources needed by user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; from machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; depends on its link quality.&lt;/p&gt;&#xA;&lt;p&gt;For example, if user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; with demand &lt;span class=&quot;math-container&quot;&gt;$d_u$&lt;/span&gt; is connected to a single machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; with link quality &lt;span class=&quot;math-container&quot;&gt;$l_{u}$&lt;/span&gt;, then the number of resources it needs from machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$$\lambda_{u,m}=\frac{d_u}{l_{u}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I want to do optimal/ best possible load balancing so that the machines have proportional load depending on the capacity/the of resources they have. At the same time, the overall link quality of all the user should also be maximised. This is because the lower the amount of resources used from the machines, the faster the users get their services attended.&lt;/p&gt;&#xA;&lt;p&gt;Not that the each user has access to a given set of machines.&#xA;For example, the accessible set of machines for user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; is defined as &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}_u$&lt;/span&gt; (a non-empty set with at least one element) which is a subset of the set &lt;span class=&quot;math-container&quot;&gt;$\{1,2,\cdots,M\}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2023-01-03T00:52:44.267" LastActivityDate="2023-01-03T00:52:44.267" Title="How to mathematically model this multi-objective optimization problem?" Tags="|mixed-integer-programming|modeling|nonlinear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9640" PostTypeId="2" ParentId="9639" CreationDate="2022-12-28T05:24:34.740" Score="2" Body="&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$\theta_{u,m}$&lt;/span&gt; is given for each user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; and machine &lt;span class=&quot;math-container&quot;&gt;$m \in\ S_u$&lt;/span&gt;&lt;br /&gt;&#xA;One way is to proportionally distribute quality with load balancing for each user&lt;br /&gt;&#xA;Objective1= Max &lt;span class=&quot;math-container&quot;&gt;$\sum_{u}\sum_{m \in\ S_u}(l(u,\theta_{u,m}) + \sum_{m \in\ M}\sum_u \frac{l(u,\theta_{u,m})}{d_u \zeta_m}$&lt;/span&gt;. Basically taking inverse of (load*capacity), thus min turns into max.&lt;/p&gt;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&lt;p&gt;If your solver allows solving multiobj lexicographically then&lt;br /&gt;&#xA;You may set obj1= max &lt;span class=&quot;math-container&quot;&gt;$\sum_{u}\sum_{m \in\ S_u}l(u,\theta_{u,m})$&lt;/span&gt;with higher priority.&lt;br /&gt;&#xA;And obj2= max&lt;span class=&quot;math-container&quot;&gt;$\sum_{m \in\ M}\sum_u \frac{l(u,\theta_{u,m})}{d_u \zeta_m}$&lt;/span&gt; with lower priority.&lt;br /&gt;&#xA;Solver solves obj1 first then adds a constraint as obj1&lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt;solution and solves for obj2.&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_u x_{u,m}\frac{d_u}{l(u,\theta_{u,m})} \le \zeta_{m} \ \ \forall m \in\ $&lt;/span&gt;M&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$1 \le \sum_{m \in\ S_u} x_{u,m} \le \vert S_u\vert \ \ \forall u$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{m \in\ S_u} l(u,\theta_{u,m}) \ge d_u \ \ \forall u \in\ $&lt;/span&gt;users (Not required)&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$l(u,\theta_{u,m}) = \log_2(\sum_m \theta_{u,m}) - \log_2 (\sum_m (1-x_{u,m})\theta_{u,m}+\sigma) \ \ \forall u \in\ $&lt;/span&gt;users&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{u,m} \in\ \{0,1\}: m \in\ S_u$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As suggested by OP for load balancing&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\underset{x_{u,m}}{\min} \sum_u x_{u,m}z$&lt;/span&gt;&lt;br /&gt;&#xA;Add a constraint&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z \ge \delta_m \ \ \forall m$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-28T14:21:42.127" LastActivityDate="2022-12-28T14:21:42.127" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="9642" PostTypeId="1" AcceptedAnswerId="9663" CreationDate="2022-12-28T13:57:44.000" Score="5" ViewCount="443" Body="&lt;p&gt;I want to apply for a position after my PhD in an industrial laboratory that does research in OR.&#xA;They stipulate that they want either Python or Julia programming languages. Since my Bachelor's internship supervisor taught me Julia 5~6 years ago and I liked it, I did not really get a look into Python and kind of begin to become more and more used to Julia.&lt;/p&gt;&#xA;&lt;p&gt;However, as I do not know much about Python, I would like to know what are the pros and cons for such a position for either Julia or Python.&#xA;I believe that if a position wants Julia, you should not considered that much Python and vice-versa and my question should be answered only if both languages are suggested in the position.&#xA;As I would not prefer asymmetrical answers and would like objectivity, I suggest that all answers contains the two sections:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pros and Cons of Python over Julia in OR industry laboratory interviews&lt;/li&gt;&#xA;&lt;li&gt;Pros and Cons of Julia over Python in OR industry laboratory interviews&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Some of the pros and cons I have in mind is that Julia is relatively new and its community too. So, many questions about Python have been asked in StackOverflow. This is not really true for Julia.&#xA;Also, as mentioned in &lt;a href=&quot;https://or.stackexchange.com/a/3962/35&quot;&gt;this answer&lt;/a&gt;, there are many cutting-edges packages developed for JuliaOPT. Finally, Julia is known to be generally faster though Python can also be fast&#xA;if you correctly use the appropriate packages.&lt;/p&gt;&#xA;&lt;p&gt;What else you should mention in such an interview?&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="491" LastEditDate="2022-12-28T14:08:15.340" LastActivityDate="2022-12-30T22:06:26.307" Title="What are the key pros and cons to mention when asked why one prefer Julia over Python in OR-research-industry interviews and vice-versa?" Tags="|python|julia|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9643" PostTypeId="1" AcceptedAnswerId="9644" CreationDate="2022-12-28T14:30:13.717" Score="5" ViewCount="236" Body="&lt;p&gt;I'm modeling a problem where I have a set of binary decision variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; that has a value of 1 if the person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is allocated to day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; or 0 otherwise.&lt;/p&gt;&#xA;&lt;p&gt;I have another set of binary decision variables &lt;span class=&quot;math-container&quot;&gt;$n_{jk}$&lt;/span&gt; that has a value of 1 if the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;'s day has &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; persons assigned to it.&lt;/p&gt;&#xA;&lt;p&gt;I need a way to force the &lt;span class=&quot;math-container&quot;&gt;$n_{jk}$&lt;/span&gt; to 1 if the &lt;span class=&quot;math-container&quot;&gt;$\sum x_{ij} = k$&lt;/span&gt;, 0 otherwise.&lt;/p&gt;&#xA;" OwnerUserId="10481" LastEditorUserId="36" LastEditDate="2022-12-28T14:58:47.503" LastActivityDate="2022-12-28T15:15:13.077" Title="Summation of Binary Variables Pushing a Binary Variable" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9644" PostTypeId="2" ParentId="9643" CreationDate="2022-12-28T15:15:13.077" Score="7" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_k n_{jk} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $j$} \tag1\label1 \\&#xA;\sum_k k n_{jk} &amp;amp;= \sum_i x_{ij} &amp;amp;&amp;amp;\text{for all $j$} \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} selects one count for each day. Constraint \eqref{2} makes the selected count consistent with &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; for each day.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-12-28T15:15:13.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9645" PostTypeId="2" ParentId="9642" CreationDate="2022-12-28T15:28:15.633" Score="4" Body="&lt;p&gt;Answers will probably be very opinionated and it also depends on what kind of research (and possible adoption of that research) you are targeting.&lt;/p&gt;&#xA;&lt;h4&gt;Disclaimer&lt;/h4&gt;&#xA;&lt;p&gt;I did not use Julia for a long time (and it's obvious, that i prefer Python). This is probably no fair comparison and i don't want to talk down julia. Also consider that my background is CS, not Math and i never did academic research but only did work in the industrial context.&lt;/p&gt;&#xA;&lt;p&gt;So from the top of my head:&lt;/p&gt;&#xA;&lt;h4&gt;Pro Python&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It actually is a (well-)supported language in all commercial sovers while Julia might not be&#xA;&lt;ul&gt;&#xA;&lt;li&gt;See &lt;a href=&quot;https://www.gurobi.com/resources/starting-with-gurobi/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi&lt;/a&gt; and co.&lt;/li&gt;&#xA;&lt;li&gt;Yes... There are lots of good community-provided libs, but official support is (sometimes) hard to beat&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;The ecosystem is much bigger:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Lots of great software to make use of&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Even software not related to optimization but extremely helpful in research anyways like &lt;a href=&quot;https://matplotlib.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;matplotlib&lt;/a&gt; or &lt;a href=&quot;https://pandas.pydata.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;pandas&lt;/a&gt;; why use 2 languages at work if 1 can be enough&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;The community is much bigger&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This might also be the case in your local colleague-community&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(If there is a &lt;em&gt;lingua-franca in programming&lt;/em&gt;: it's probably &lt;em&gt;C&lt;/em&gt; for system-languages and &lt;em&gt;Python&lt;/em&gt; for interpreted-languages)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Better foreing-language tooling (i guess; see disclaimer)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;e.g. &lt;a href=&quot;https://github.com/pybind/pybind11&quot; rel=&quot;nofollow noreferrer&quot;&gt;pybind11&lt;/a&gt; / &lt;a href=&quot;https://cython.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;cython&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Python/C++-Hybrids are imho the perfect combination&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Performance can be optimized where it matters (e.g real computational work needed within some cutting-plane callback)&lt;/li&gt;&#xA;&lt;li&gt;State of the art libraries can be used when needed&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Example: I frequently make use of &lt;a href=&quot;https://eigen.tuxfamily.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;Eigen&lt;/a&gt; / &lt;a href=&quot;https://www.boost.org/doc/libs/1_81_0/libs/graph/doc/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;boost::graph&lt;/a&gt; which i consider both state of the art in their respective domains&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;There are no JIT(Julia!)-related performance surprises (which are hard to predict)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;e.g. multi-second pause in your program because that function hasn't be compiled/optimized yet&lt;/li&gt;&#xA;&lt;li&gt;no fun at all when doing benchmarking&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;0-indexing if you like it (and you will if you touch any other programming-language; i'm ignoring matlab)&lt;/li&gt;&#xA;&lt;li&gt;Python will definitely stay relevant for many years to come&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;Pro Julia&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Good (advanced) research community&#xA;&lt;ul&gt;&#xA;&lt;li&gt;From the top of my head: decomposition-methods; (specialized) interior-point solvers; first-order solvers (although at some point people consider porting them; e.g. Googles PDLP which was &lt;a href=&quot;https://github.com/google-research/FirstOrderLp.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;POCed in Julia&lt;/a&gt; and then &lt;a href=&quot;https://github.com/google/or-tools/tree/stable/ortools/pdlp&quot; rel=&quot;nofollow noreferrer&quot;&gt;ported to C++ based on Eigen&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Better performance on tight loops&lt;/li&gt;&#xA;&lt;li&gt;Multithreading-support&#xA;&lt;ul&gt;&#xA;&lt;li&gt;No personal experience with it; but Python's &lt;a href=&quot;https://en.wikipedia.org/wiki/Global_interpreter_lock&quot; rel=&quot;nofollow noreferrer&quot;&gt;GIL&lt;/a&gt; can really by annoying&#xA;&lt;ul&gt;&#xA;&lt;li&gt;At that point hybrids help again (as you can acquire/release the GIL in your native-code)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;(Better languaged-provided tooling for abstraction from what i heard)&lt;/li&gt;&#xA;&lt;li&gt;1-indexing if you like it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;No clue but maybe important&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Type-system (i believe in type-systems catching hard-to-debug bugs early)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Both seem to make use of optional type-hints but i don't know how powerful / accurate it's used&lt;/li&gt;&#xA;&lt;li&gt;This is relatively new in Python and there sure are limitations&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;Personal Opinion: Missing tooling&lt;/h4&gt;&#xA;&lt;p&gt;If they ask about Python/Julia without some C/C++ knowledge, it's probably very research- or modelling-focused as i don't see these two languages providing what's needed to really exploit all those available features of existing software has to offer. (All the commercial solvers are C/C++-based)&lt;/p&gt;&#xA;&lt;p&gt;So maybe all points related to performance or getting access to all the solver-features might be unimportant.&lt;/p&gt;&#xA;&lt;p&gt;Skimming over &lt;a href=&quot;https://or.stackexchange.com/q/3952/231&quot;&gt;your linked answer&lt;/a&gt;, it seems, that this low-level access is irrelevant for lots of people (which get the work done using Python alone for example). So maybe &lt;em&gt;i'm the outlier here&lt;/em&gt;. Although... &lt;a href=&quot;https://www.scipopt.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SCIP&lt;/a&gt; always seemed to be the dominating research-focused solver (when going into depth of such technology; so more low-lvl then modelling) and it's probably hard to make use of it without C/C++.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Additional remark:&lt;/strong&gt; I consider Python relatively easy to learn and i don't consider it a year-long task to get working. This might be nearly the same for Julia (but won't be for C++).&lt;/p&gt;&#xA;" OwnerUserId="231" LastEditorUserId="231" LastEditDate="2022-12-28T15:54:10.653" LastActivityDate="2022-12-28T15:54:10.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9646" PostTypeId="1" CreationDate="2022-12-28T18:37:57.117" Score="5" ViewCount="967" Body="&lt;p&gt;I originally asked a question &lt;a href=&quot;https://math.stackexchange.com/questions/4594095/how-many-variables-and-constraints-can-modern-mixed-integer-programming-solvers&quot;&gt;here&lt;/a&gt; and they suggested that I crosspost it to the OR stack exchange, so that is what I am doing (hopefully correctly?). Here is the question I asked there:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;I know it depends on the specific problem instance, but approximately how large of an MIP problem can we write and still be guaranteed that an optimization solver will find a solution? For instance, if we have a mixed integer program with 1,000 variables and 1,000 constraints, can we be guaranteed that no matter what the variables and constraints are, modern optimization software will be able to spit out a solution in a reasonable time frame (defined as 1 month or less on a standard computer)? What about 1 million variables and constraints, or a billion variables and a million constraints, etc.&amp;quot;&lt;/p&gt;&#xA;" OwnerUserId="11000" LastEditorUserId="491" LastEditDate="2022-12-29T18:17:37.973" LastActivityDate="2022-12-29T18:17:37.973" Title="How many variables and constraints can modern mixed integer programming solvers handle?" Tags="|optimization|mixed-integer-programming|linear-programming|integer-programming|computational-complexity|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9647" PostTypeId="2" ParentId="9646" CreationDate="2022-12-28T18:57:42.147" Score="2" Body="&lt;p&gt;Basically modern solvers like Gurobi have no limit in terms of capacity (talking of full license). While I wasn't able to find a specific reference in Gurobi Manual but found &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360071854832-Maximum-number-of-constraints-for-a-model&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; confirmation. CPLEX also has no meaningful limit. Solving time depends upon machine RAM, sparsity of constraint matrix, linearity of the objective, integer variables, Python API calls like access/manipulation on Pandas and specific class of problems that are NP-Hard like Travelling Salesman Problem with hundreds of nodes and edges.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-28T18:57:42.147" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9648" PostTypeId="2" ParentId="9642" CreationDate="2022-12-29T05:10:41.430" Score="2" Body="&lt;p&gt;If either-or choice is there simple answer would be that you are comfortable in Julia and have worked out functioning code.&lt;br /&gt;&#xA;Many interviewers appreciate the confidence that you display when you communicate your comfort level. But do display some scope to learn Python, Ruby etc if asked.&lt;br /&gt;&#xA;At the end in large corporates a PhD researcher would be expected at best to develop prototypes of the proposed models. For production there will be full stack python developers in their application development team. But you would need to communicate and express your model and it's characteristics via functional diagrams, specification notes and prototype code.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-29T05:10:41.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9649" PostTypeId="2" ParentId="9642" CreationDate="2022-12-29T11:36:21.330" Score="1" Body="&lt;p&gt;Very opinionated answer too. I think the big cons of Julia are that its ecosystem and community are currently smaller than Python. If this is important or not, it will depend on the kind of research to do. If, for example, you will have to prototype heuristics or model math programming problems, Julia looks better.&#xA;Anyway, I suggest spending some time learning Python. There is no silver-bullet language and, currently, both interop very well.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2022-12-29T11:36:21.330" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9650" PostTypeId="1" CreationDate="2022-12-29T12:27:30.493" Score="2" ViewCount="206" Body="&lt;p&gt;I am trying to include to my model a demand shift. That is, I am having a fixed demand for each period (t), but because of capacity constraints I am not able to serve the whole demand for each period. The demand must then be transferred to the upcoming period (t+1).&lt;/p&gt;&#xA;&lt;p&gt;Is there a name or a standard model for such a problem? I would like to research a suitable approach from literature.&lt;/p&gt;&#xA;" OwnerUserId="9883" LastActivityDate="2022-12-29T15:41:57.450" Title="How to model not-met demand to next period?" Tags="|mixed-integer-programming|modeling|inventory|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9651" PostTypeId="2" ParentId="9650" CreationDate="2022-12-29T13:09:43.913" Score="5" Body="&lt;p&gt;An easy approach is the following. Assuming &lt;span class=&quot;math-container&quot;&gt;$X_t$&lt;/span&gt; the production at period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_t$&lt;/span&gt; the demand at period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, create a new variable &lt;span class=&quot;math-container&quot;&gt;$F_t$&lt;/span&gt; to store how much demand cannot be satisfied. Then, modify the demand constraints in the following way:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$X_t = d_t + F_{t-1} - F_t$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So, basically, you need to produce the current demand plus all previous not satisfied demand and, in case it cannot be possible, it will be transferred to the next period.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2022-12-29T13:09:43.913" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9652" PostTypeId="2" ParentId="9650" CreationDate="2022-12-29T14:48:15.127" Score="2" Body="&lt;p&gt;The above answer is apt but if you want to try something fancy then:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$Cap_t \le D_t - F_t+ F_{t-1} \ \ \forall t$&lt;/span&gt;&lt;br /&gt;&#xA;You can make &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; tight by &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; if it doesn't make model infeasible&lt;br /&gt;&#xA;where&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$0 \le F_t \le D_t $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$Cap_t$&lt;/span&gt; is Capacity for period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-29T15:41:57.450" LastActivityDate="2022-12-29T15:41:57.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9654" PostTypeId="2" ParentId="9537" CreationDate="2022-12-29T15:57:13.590" Score="4" Body="&lt;p&gt;I can't help you with Xpress, but one approach is to linearize the problem by replacing the products &lt;span class=&quot;math-container&quot;&gt;$\lambda_t m_{ij}^{(t)}$&lt;/span&gt; with new nonnegative variables &lt;span class=&quot;math-container&quot;&gt;$z_{ijt}$&lt;/span&gt;, together with constraints that enforce the product.  See &lt;a href=&quot;https://or.stackexchange.com/questions/39/how-to-linearize-the-product-of-a-binary-and-a-non-negative-continuous-variable&quot;&gt;How to linearize the product of a binary and a non-negative continuous variable?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2022-12-29T15:57:13.590" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9655" PostTypeId="1" CreationDate="2022-12-29T20:30:54.483" Score="5" ViewCount="205" Body="&lt;p&gt;I am trying to solve some of the stochastic optimization proposed problems for an Optimization course I joined.&lt;/p&gt;&#xA;&lt;p&gt;One of the exercices asks to solve the Expected Value problem. I already made it.&lt;/p&gt;&#xA;&lt;p&gt;Next exercise asks to solve the expected result of using the EV solution (EEV). So I started solving the |Ω| = 2 linear problems, one for each scenario, setting the decision variables to the values ​​obtained in the optimal solution of EV.&lt;/p&gt;&#xA;&lt;p&gt;But it turned out that one of these two problems is infeasible. So, how can I calculate the EEV in this case?&lt;/p&gt;&#xA;" OwnerUserId="11006" LastActivityDate="2022-12-29T21:22:17.270" Title="Two-Stage Stochastic Optimization: How to deal with Infeasible scenario while calculating EEV (Expected result of using the EV solution)" Tags="|optimization|cplex|stochastic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9656" PostTypeId="2" ParentId="9655" CreationDate="2022-12-29T21:22:17.270" Score="3" Body="&lt;p&gt;A paper &lt;a href=&quot;https://addi.ehu.es/bitstream/handle/10810/18673/TFG_S.Laconcepcion.pdf?&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; speak of scenarios for EEV that are infeasible. Alternative is to use a complete recourse model, unfix stage 1 variables for the model to adapt. I guess you may experiment by making solution of the EV kind of upper/lower bounds for the stage 1 variables.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2022-12-29T21:22:17.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9657" PostTypeId="1" AcceptedAnswerId="9659" CreationDate="2022-12-30T06:07:52.017" Score="4" ViewCount="250" Body="&lt;p&gt;Can XPRESS variables not be used as indices to retrieve other XPRESS variables. In Python, for example, say that I have a list of XPRESS variables, each which can take on values (0-&amp;gt;24). I'd like to use these values as indices to retrieve other variables from another list. However, I'm encountering this error: &lt;code&gt;TypeError: list indices must be integers or slices, not xpress.var&lt;/code&gt;. Is there a way around this?&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="10326" LastEditDate="2022-12-30T16:10:27.200" LastActivityDate="2022-12-30T16:10:31.323" Title="XPRESS variables as indices for mixed integer linear programming" Tags="|mixed-integer-programming|python|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9658" PostTypeId="2" ParentId="9657" CreationDate="2022-12-30T13:22:15.033" Score="3" Body="&lt;p&gt;I think it's Python issue. Only integers can be used as indices, not linear expressions or dictionary items. Solver vars are somewhat like expressions or tuples. Rather you can use series of auxillary binary variables &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and use another expression, like&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n i\cdot z_i =$&lt;/span&gt; xp.var&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{i=1}^n z_i = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$n= U$&lt;/span&gt; with U as upper bound of xp.var&lt;/p&gt;&#xA;&lt;p&gt;The above two ensure &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; represents whatever non-negative integer value xp.var takes.&lt;/p&gt;&#xA;&lt;p&gt;Then from the list, L&lt;br /&gt;&#xA;Use expression &lt;span class=&quot;math-container&quot;&gt;$\sum_i L_iz_i$&lt;/span&gt; to retrieve value from list L&lt;/p&gt;&#xA;&lt;p&gt;Hat tip to Gurobi from &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360071776111-use-a-decision-variable-as-an-index-&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and Dr. Rob Pratt (saw a similar answer in another post)&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-30T14:29:21.807" LastActivityDate="2022-12-30T14:29:21.807" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9659" PostTypeId="2" ParentId="9657" CreationDate="2022-12-30T16:10:31.323" Score="4" Body="&lt;p&gt;In general, you cannot use a decision variable directly as an index to a vector of decision variables in a linear or integer/mixed-integer program. As far as I know, it is not supported by any solvers. It &lt;em&gt;is&lt;/em&gt; possible in &lt;em&gt;constraint programming&lt;/em&gt; models, at least with some (probably most) solvers.&lt;/p&gt;&#xA;&lt;p&gt;One way to get at &lt;span class=&quot;math-container&quot;&gt;$x_y$&lt;/span&gt; in a MIP model, where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a vector of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is an integer variable with domain &lt;span class=&quot;math-container&quot;&gt;$1,\dots,n$&lt;/span&gt; is as described in Sutanu's answer. You expand &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; as a sum of binary variables multiplied by constants (&lt;span class=&quot;math-container&quot;&gt;$y=\sum_i i\cdot z_i$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; binary and &lt;span class=&quot;math-container&quot;&gt;$\sum_i z_i =1$&lt;/span&gt;). You then write &lt;span class=&quot;math-container&quot;&gt;$x_y$&lt;/span&gt; as a similar sum (&lt;span class=&quot;math-container&quot;&gt;$\sum_i x_i \cdot z_i$&lt;/span&gt;), which is a quadratic expression that can be linearized.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2022-12-30T16:10:31.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9660" PostTypeId="1" AcceptedAnswerId="9661" CreationDate="2022-12-30T16:15:09.203" Score="2" ViewCount="492" Body="&lt;p&gt;I am trying to find a way to solve the following problem of mine by using Solver but I get stuck right at the end of it.&lt;/p&gt;&#xA;&lt;p&gt;I have a table of 14 companies each of which want to work on a project. I will be providing them with the workers that are required. In a table I have the workers that each company needs and the amount of time in weeks that their project will take. Once the workers are assigned they can't leave their post. Based on all this information (and the table) I have to calculate the least amount of workers that my company needs to hire for all projects to be completed within 6 months.&lt;/p&gt;&#xA;&lt;p&gt;Now, for the sake of space and time, I'll reduce this problem to 4 companies to give you my POV:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Company   Workers required   Weeks required&#xA;A                 3                3&#xA;B                 1                3&#xA;C                 5                2&#xA;D                 4                3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Suppose that there's no obvious answer to this and that we have 2 months in our disposal, or something like that. 2 months have approx 8 weeks and so the above projects need to be completed in 8 weeks.&lt;/p&gt;&#xA;&lt;p&gt;My mathematical modeling is as follows:&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$x_i $&lt;/span&gt; be the week that project &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; starts. Also, &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt; shall be the weeks required for project &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; will be the workers required.&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, I'll have &lt;span class=&quot;math-container&quot;&gt;$Y_{ij}$&lt;/span&gt; be a binary variable that is equal to 1 if project &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is taking place during week &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and 0 if not. Thus, &lt;span class=&quot;math-container&quot;&gt;$W_j=\sum_{i=1}^{4}Y_{ij}\cdot c_i$&lt;/span&gt; is the amount of workers that are working during week &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, we are looking to minimize &lt;span class=&quot;math-container&quot;&gt;$W=max_{1\leq j\leq 8}W_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The only constraint I believe there is the following: &lt;span class=&quot;math-container&quot;&gt;$1\leq x_i \leq 8-t_i+1$&lt;/span&gt; meaning that a project can start on the 1st week at least and be completed by the end of the 8th week at most.&lt;/p&gt;&#xA;&lt;p&gt;Now,I have taken this to Excel and have created 2 tables. One that has the companies column and the values &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i+t_i$&lt;/span&gt; for each one. On another column I have the restraint that &lt;span class=&quot;math-container&quot;&gt;$x_i\leq 8-t_i+1$&lt;/span&gt; that I would use for solver. On the second table I have the companies, &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;, and 8 columns one for each week.The variables on the inside represent &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; and at the end of each column I have calculated the sumproduct of &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; with column &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; meaning the &lt;span class=&quot;math-container&quot;&gt;$W_j$&lt;/span&gt;'s. Finally, my target cell is the maximum of the &lt;span class=&quot;math-container&quot;&gt;$W_j$&lt;/span&gt;'s.&lt;/p&gt;&#xA;&lt;p&gt;When I try to run Solver with the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;'s as the changing variable cells it returns an error that the problem is not linear (my &lt;span class=&quot;math-container&quot;&gt;$Y_{ij}$&lt;/span&gt;'s are set to either 1 or 0 with an IF function depending on &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;'s values), but when I go use &lt;span class=&quot;math-container&quot;&gt;$Y_j$&lt;/span&gt;'s as the changing variable cells, other than the fact that I don't know how to include the constraint, it just keeps every variable at 0 without giving me a solution. Mind you, my table has more companies and weeks (14com &lt;span class=&quot;math-container&quot;&gt;$\times$&lt;/span&gt; 24w) which exceeds the 200 variables that Solver can handle.&lt;/p&gt;&#xA;&lt;p&gt;How am I approaching this wrong? What steps should I take/change in my process to find the solution to my problem?&lt;/p&gt;&#xA;&lt;p&gt;Edit: I’ve decided to accept every answer as correct, because they were all so well presented and helped me learn something new and see the solution to this from different perspectives. Thank you all for your precious time and help!&lt;/p&gt;&#xA;" OwnerUserId="10847" LastEditorUserId="10847" LastEditDate="2023-01-02T23:29:43.387" LastActivityDate="2023-01-03T12:33:21.543" Title="How to approach this shifts problem with Excel Solver?" Tags="|optimization|linear-programming|integer-programming|solver|excel|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9661" PostTypeId="2" ParentId="9660" CreationDate="2022-12-30T16:47:00.563" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;I very much doubt that Solver knows how to convert an IF function into a linear constraint (although I suppose it is possible). So I think you need to rethink your MIP model.&lt;/li&gt;&#xA;&lt;li&gt;If the variable limit in Solver becomes an obstacle, you can install &lt;a href=&quot;https://opensolver.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OpenSolver&lt;/a&gt;, which is an open-source (hence free) Excel add-in that extends the capabilities of Solver.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Addendum: One way to avoid the &amp;quot;if&amp;quot; statement is to change &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; to binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij},$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 1$&lt;/span&gt; if and only if project &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; begins in week &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. You would add the constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=1}^{9-t_i} x_{ij} = 1 \quad\forall i$$&lt;/span&gt; to ensure that each project is assigned a single start time, and the constraints &lt;span class=&quot;math-container&quot;&gt;$$Y_{ij} = \sum_{k=\max(1,j-t_i + 1)}^j x_{ik} \quad \forall i,j$$&lt;/span&gt; to define &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; in terms of the start time variable.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-01-01T16:41:43.770" LastActivityDate="2023-01-01T16:41:43.770" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9662" PostTypeId="2" ParentId="9660" CreationDate="2022-12-30T17:43:38.773" Score="2" Body="&lt;p&gt;Well, to do min-max I think you need&lt;br /&gt;&#xA;Assuming project implies company&lt;/p&gt;&#xA;&lt;p&gt;Minimize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;&lt;br /&gt;&#xA;s.t.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z \ge  \sum_{i=1}^4 Y_{i,j}c_i \ \ \forall j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^W Y_{i,j} = t_i \ \ \forall i$&lt;/span&gt;: where W = 9 (assigned total time)&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$t_iY_{i,j-1} - \sum_{k=1}^{j-1} Y_{i,k} \le t_iY_{i,j}\ \ \forall j=2...W-1, \ \forall i$&lt;/span&gt;: Ensures Y's are consecutively assigned&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$Y \in\ \{0,1\}^{i\times j} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Images&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/VrQiV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VrQiV.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/7hB5M.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7hB5M.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-02T01:43:56.143" LastActivityDate="2023-01-02T01:43:56.143" CommentCount="17" ContentLicense="CC BY-SA 4.0" />
  <row Id="9663" PostTypeId="2" ParentId="9642" CreationDate="2022-12-30T22:06:26.307" Score="3" Body="&lt;p&gt;To the risk of stating the obvious: the person best-positioned to answer is the person who will interview you. Job postings will often list a few programming languages to encourage many candidates to apply; you may end up coding in Java and GAMS...&lt;/p&gt;&#xA;&lt;p&gt;As already noted, the Julia vs Python question has no universal answer other than &amp;quot;it depends.&amp;quot; The environment you work in, people you work with, legacy codebases... are as important (if not &lt;em&gt;more&lt;/em&gt; important sometimes) than a language's raw features. There is nothing you can do Python than you cannot in Julia, and vice-versa; in my experience it's often more about &amp;quot;how fast can you make it happen?&amp;quot; and &amp;quot;how easy is it to use?&amp;quot;, the answer to which depends heavily on your familiarity with each tool. There are some great answers about the pros and cons of each programming language on this forum:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/3952/are-python-and-julia-used-for-optimization-in-industry&quot;&gt;Are Python and Julia used for optimization in industry?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/4170/matlab-vs-python-in-industry&quot;&gt;Matlab vs Python in industtry&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/6907/softwares-for-operations-research-is-excel-outdated-or-useless-for-the-or-indus&quot;&gt;Software for OR&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/9174/ideal-programming-language-for-an-operations-researcher&quot;&gt;Ideal programming language for an operations researcher&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/1475/are-programming-languages-necessary-useful-for-operations-research-practitioner&quot;&gt;Are programming languages necessary/useful for operations research practitioner?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2022-12-30T22:06:26.307" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9664" PostTypeId="1" CreationDate="2022-12-31T10:14:33.617" Score="1" ViewCount="257" Body="&lt;p&gt;I'm trying to solve this problem:&lt;/p&gt;&#xA;&lt;p&gt;An investment agency holds the rights to six investment projects: I1, I2, ..., I6. Projects I1, I2 and I3 are research and&#xA;technological development projects and the remaining three, I4, I5 and I6, are sustainable agriculture projects. The&#xA;agency intends to form portfolios consisting of a research and technological development project and a sustainable&#xA;agriculture project. Due to the risk associated with the projects, only the following pairs of projects are feasible: (I1,&#xA;I4), (I1, I5), (I2, I4), (I2, I5), (I2, I6), (I3, I4) (I3, I5) e (I3, I6). The risk associated to each project, measured on a scale of&#xA;0 -10 (0 - no risk; 10 - maximum risk), and the number of portfolios in which each project may be included are shown&#xA;in the table below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4eI2v.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4eI2v.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;a) Represent the problem in a network and identify the network model that allows the agency to determine how&#xA;many portfolios of two projects it will be possible to define. Justify&lt;/p&gt;&#xA;&lt;p&gt;b) Suppose now that the agency wants to determine the three portfolios of two projects that minimise total risk.&#xA;Indicate all the necessary changes to be made to the network shown in a) and state the network model that allows&#xA;the optimal solution to be determined. Justify.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Point a) I considered that it was a problem of maximum flow and I solved it this way (but I don't know if it's right). M is considered to be a large number. Above the arcs are their capacities (in this case, it represents the number of portfolios).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3LSAL.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3LSAL.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I don't know how to solve part b) and turn the network in part a) into a minimum cost flow problem. I don't know where to put it on the network that I can only have 3 portfolios.&lt;/p&gt;&#xA;" OwnerUserId="11011" LastEditorUserId="11011" LastEditDate="2022-12-31T11:40:59.613" LastActivityDate="2022-12-31T18:27:42.347" Title="Graph models - Maximum flow problem and minimum cost flow problem" Tags="|graphs|network-flow|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9665" PostTypeId="2" ParentId="9664" CreationDate="2022-12-31T11:12:10.533" Score="2" Body="&lt;p&gt;Since this looks to be a homework, perhaps a few hints rather than the answer?&lt;/p&gt;&#xA;&lt;p&gt;a)  Check your network.  How many edges should go from (i1,i2,i3) to (i4,i5,i6)?  How many do you have?&lt;/p&gt;&#xA;&lt;p&gt;b) You know this is a minimum cost flow, so you know you can have a general network structure and costs on the edges.  So you have figured out that you somehow need to limit the flow in the network to at most three.  Can you figure out how to make sure no more than 3 leaves s?  In addition to costs on arcs, what in min-cost flow, what additional number is put on nodes?  Depending on how this is taught, the solution will either be through the supply/demand on nodes or, if your min-cost flows always have conservation of flow at nodes, through an edge with the appropriate capacity.&lt;/p&gt;&#xA;&lt;p&gt;Perhaps that will help?&lt;/p&gt;&#xA;" OwnerUserId="214" LastActivityDate="2022-12-31T11:12:10.533" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9666" PostTypeId="2" ParentId="9664" CreationDate="2022-12-31T15:15:28.947" Score="1" Body="&lt;p&gt;To convert to min-cost, you need to tweak this way:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;keep sink and nodes&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;put 1 as weight on the graph, so a flow(r, a) of f(r,a) is anyway binary, r is research project and a is agriculture. Ensure to put flow(r,a) = flow(a,r) which implies &lt;span class=&quot;math-container&quot;&gt;$f_{i,j} = f_{j,i} \ \ \forall (i,j)$&lt;/span&gt; pairs&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;on nodes, demand as part of flow conservation is the number of portfolio the node appears. &lt;br /&gt;&#xA;Like flow conservation will be&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in\ S_i} f_{i,j} \le N_i \ \ \forall i \in\ $&lt;/span&gt;projects,&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$f_{i,j}$&lt;/span&gt; is the binary flow, &lt;span class=&quot;math-container&quot;&gt;$N_i$&lt;/span&gt; is number of pairs &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; can appear, &lt;span class=&quot;math-container&quot;&gt;$S_i $&lt;/span&gt; is set of j nodes connected/adjacent to each i.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Put demand at sink, s = 3 with an edge from all projects&lt;br /&gt;&#xA;Then &lt;span class=&quot;math-container&quot;&gt;$\sum_{i} f_{i,s} = 3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f_{i,s} \le \sum_{j \in\ S_i} f_{i,j} \ \ \forall i$&lt;/span&gt;: ensures before it makes an edge from a node to sink 1, that node must be in a portfolio pair selected.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Objective is then &lt;span class=&quot;math-container&quot;&gt;$\sum_i (r_i \sum_{j \in\ {S_i} }f_{i,j})$&lt;/span&gt;. Ensure to exclude sink node here.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2022-12-31T18:27:42.347" LastActivityDate="2022-12-31T18:27:42.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9668" PostTypeId="2" ParentId="9660" CreationDate="2023-01-01T11:35:44.773" Score="2" Body="&lt;p&gt;First of all, you will have to ensure that the total number of weeks is enough to schedule, otherwise, it causes many overlaps in projects. The mentioned problem can be formulated either as a resource-constrained project schedule or a variant of aggregation planning or through Monte Carlo simulation to examine how many resources you actually need. The first and the second would be as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1-&lt;/strong&gt; &lt;em&gt;Resource-constrained project schedule:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;One of the best approaches to solving such an assignment problem, specifically when it comes along with a variation in the different resources, is project scheduling tools. In the following, two scenarios are depicted. First, by assuming to execute projects &lt;span class=&quot;math-container&quot;&gt;$1,2$&lt;/span&gt; simultaneously and &lt;span class=&quot;math-container&quot;&gt;$4, 5$&lt;/span&gt; sequentially, and second by overlapping the projects and allowing to extend the resource availability in the time horizon.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First&#xA;&lt;a href=&quot;https://i.stack.imgur.com/5Ah7K.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5Ah7K.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In this scenario, we have 9 identical resources. Each project can execute with whose resources except project&lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; that uses the shared resources.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Second&#xA;&lt;a href=&quot;https://i.stack.imgur.com/zYY6n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zYY6n.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In the second, I try with only &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; resources with overlapping tasks. You can obviously see changing in the finish time after leveling/dispatching resources. I think this is a simple way to examine many different scenarios.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;2-&lt;/strong&gt; &lt;em&gt;Aggregate planning:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Defining the sets &lt;span class=&quot;math-container&quot;&gt;$p \in Projects$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w \in Weeks$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ r \in Resources$&lt;/span&gt;, and parameters &lt;span class=&quot;math-container&quot;&gt;$Cost_{i,p}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Duration_{p}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$AvailableTime_{p}$&lt;/span&gt;, and declare decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{r,p,t}$&lt;/span&gt; to calculate the number of resources needed for each project at each week and the following model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{l}&#xA;\text{Minimize} &amp;amp; Z =  \sum_{r,p,w} Cost_{r,p}x_{r,p,w}\\&#xA;\text{subject to:}&amp;amp; \\&#xA;&amp;amp;\sum_{r} AvailableTime_{p} x_{r,p,w} = Duration_{p} &amp;amp; \forall p \in Projects, w \in Week\\&#xA;&amp;amp;x_{r,p,w} \geq 0,&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Based on the data table in the original question and some random data the result is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;        VARIABLE x[r,p,w] &#xA; &#xA;                     w1          w2          w3          w4&#xA;&#xA;worker_1.p1       3.000       3.000       3.000       3.000&#xA;worker_1.p4       3.000       3.000       3.000       3.000&#xA;worker_2.p2       1.000       1.000       1.000       1.000&#xA;worker_2.p3       3.000       3.000       3.000       3.000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am not an Excel_solver user, but &lt;a href=&quot;https://drive.google.com/file/d/1uBlyXvvICUBdZ6DWiJGqVDjbEyjtdXVW/view?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;this template&lt;/a&gt; would be helpful to run it.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-01-01T11:35:44.773" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9669" PostTypeId="2" ParentId="9660" CreationDate="2023-01-02T14:13:03.693" Score="2" Body="&lt;h2&gt;Introduction&lt;/h2&gt;&#xA;&lt;p&gt;The problem consists in determining the &lt;strong&gt;optimal project start-up sequence&lt;/strong&gt;, i.e. &lt;em&gt;the sequence such as to minimize the number of workers hired without violating the time constraint imposed by the assignment of a worker to a certain project for a given number of weeks&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Enumerating all possible sequences&lt;/h2&gt;&#xA;&lt;p&gt;The project sequencing decision problem can be solved by listing all possible sequences, calculating the respective number of workers needed and selecting the sequence with the minimum number of hired workers. Given a graph having &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;≥1 levels and &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; different projects, at each level &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; there will be &lt;span class=&quot;math-container&quot;&gt;$N-T$&lt;/span&gt; possible decisional alternatives.&#xA;The number of sequences of projects admissible a priori is therefore equal to&#xA;&lt;span class=&quot;math-container&quot;&gt;$N\cdot(N-1)\cdot(N-2)\cdot … \cdot (N-(T-1))$&lt;/span&gt;&#xA;For example, having assigned &lt;span class=&quot;math-container&quot;&gt;$N=14$&lt;/span&gt; different projects and setting a planning horizon of &lt;span class=&quot;math-container&quot;&gt;$T=8$&lt;/span&gt; weeks, the possible alternatives to be evaluated turn out to be &lt;span class=&quot;math-container&quot;&gt;$14\cdot13\cdot…\cdot7= 121,080,960$&lt;/span&gt;, a number certainly beyond a direct evaluation. Therefore, in practice visiting the decision tree is not feasible: the use of mathematical programming is fundamental.&lt;/p&gt;&#xA;&lt;h2&gt;The model&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;Unit of time&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The decision-making problem of sequencing projects is implicitly &lt;strong&gt;discrete-time&lt;/strong&gt; where the instants of occurrence of the events can be defined a priori. &lt;em&gt;Events&lt;/em&gt; are the start point of a project, while its duration is assigned a priori. The &lt;em&gt;events&lt;/em&gt; that occur in the mathematical model are variations in the value of some variable and these events can only occur at the extremes of one of the intervals with which the time horizon is divided. At the beginning or at the end of the interval itself. Since the activity planning calendar is weekly, the &lt;strong&gt;week&lt;/strong&gt; is adopted as the &lt;em&gt;unit of time&lt;/em&gt;. The &lt;em&gt;time horizon&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is therefore divided into a certain number of intervals each with a time duration of one week.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The following model gives the starting temporal sequence for &lt;span class=&quot;math-container&quot;&gt;$N=14$&lt;/span&gt; projects so that the number of hired workers is optimal within the planning horizon of &lt;span class=&quot;math-container&quot;&gt;$T=8$&lt;/span&gt; weeks. The model requires &lt;span class=&quot;math-container&quot;&gt;$112$&lt;/span&gt; Boolean variables (&lt;span class=&quot;math-container&quot;&gt;$112=14 \cdot 8$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; integers variables (1 integer variable for each week). Every week is designate by means of a pedice &lt;span class=&quot;math-container&quot;&gt;$i=1, 2, \ldots, T=8$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For each week, the possible choices are basically two:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;“start” or “not start” a project in the i-th week&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;We designate the projects by means of a pedice &lt;span class=&quot;math-container&quot;&gt;$j=1, 2,..., N$&lt;/span&gt;. As consequence, we need &lt;span class=&quot;math-container&quot;&gt;$T \cdot N = 8\cdot14 = 112$&lt;/span&gt; variables in order to define all possible decisions. Let introduce the Boolean variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=1$&lt;/span&gt; if in i-th week I decide to start the project j-th and to keep &lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt; workers as many weeks as required/specified for the j-th project&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=0$&lt;/span&gt; if in i-th week I decide to not start the j-th  project&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$w_j$&lt;/span&gt;: number of workers to be assigned to the j-th project&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_j$&lt;/span&gt;: number of weeks needed to complete the j-th project&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;We introduce &lt;span class=&quot;math-container&quot;&gt;$T=8$&lt;/span&gt; equations and variables &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; that track how long workers are kept for the future weeks.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ A_1 = \sum_{i=1}^{N} t_j \cdot x_{1,j} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ A_2 = A_1  - 1 + \sum_{j=1}^{N} t_j \cdot x_{2,j} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \vdots $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ A_T = A_{T-1}  - 1 + \sum_{j=1}^{N} t_j \cdot x_{T,j} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For example, in the first week if we decide to start the &lt;span class=&quot;math-container&quot;&gt;$j=2$&lt;/span&gt; project and to keep it for &lt;span class=&quot;math-container&quot;&gt;$t_2=3$&lt;/span&gt; weeks it results: &lt;span class=&quot;math-container&quot;&gt;$ A_1 = \sum_{j=1}^{N} x_{1,j}  \cdot t_k = 3$&lt;/span&gt; because &lt;span class=&quot;math-container&quot;&gt;$x_{1,2}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{1,1}=x_{1,3}= x_{1,4}=…= 0$&lt;/span&gt;.&#xA;In order to impose in every week there is a project in execution, we add further &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$ A_i \geq 1 \quad \forall i=1,\ldots,T $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In order to avoid the unacceptable situation of use a worker when the workers of the previous projects are not yet free and available, we introduce the following &lt;span class=&quot;math-container&quot;&gt;$T-1$&lt;/span&gt; additional constraints as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;\sum_{j=1}^{N} t_j \cdot x_{1,j} \leq (1 - \sum_{j=1}^{N} x_{2,j} ) \cdot M +1 \\&#xA;A_{1} -1 + \sum_{j=1}^{N} t_j \cdot x_{2,j} \leq (1 - \sum_{j=1}^{N} x_{3,j} ) \cdot M +1 \\&#xA;\vdots \\&#xA;A_{T-2} -1 + \sum_{j=1}^{N} t_j \cdot x_{T-1,j} \leq (1 - \sum_{j=1}^{N} x_{T,j} ) \cdot M +1  \\&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the parameter M can be choosen as &lt;span class=&quot;math-container&quot;&gt;$M &amp;gt; \max_j t_j $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^{N} x_{i,j}  \leq 1 \quad \forall i=1,\ldots,T $&lt;/span&gt;  makes sure that no any project is in execution in parallel with someone other. If &lt;em&gt;parallel execution&lt;/em&gt; is &lt;strong&gt;allowable&lt;/strong&gt;, this constraint can be removed.&lt;/p&gt;&#xA;&lt;p&gt;The constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{T} x_{i,j}  \leq 1 \quad \forall j=1,\ldots,N $&lt;/span&gt;  makes sure that every company executes no more than one project.&lt;/p&gt;&#xA;&lt;p&gt;Finally, the constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{T} \sum_{j=1}^{N} t_j \cdot x_{i,j}  \leq T$&lt;/span&gt;  makes sure that all selected projects are completed within the fixed planning horizon &lt;span class=&quot;math-container&quot;&gt;$T=8$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Formulation as Linear Programming Model&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ min \left \{ \sum_{i = 1}^T \sum_{j = 1}^N w_j \cdot x_{i,j} \right \} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subject to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\left\{ \begin{array}{l}&#xA;A_1 = \sum_{i=1}^{N} t_j \cdot x_{1,j} \\&#xA;A_2 = A_1  - 1 + \sum_{j=1}^{N} t_j \cdot x_{2,j} \\&#xA;\vdots \\&#xA;A_T = A_{T-1}  - 1 + \sum_{j=1}^{N} t_j \cdot x_{T,j} \\&#xA;\sum_{j=1}^{N} t_j \cdot x_{1,j} \leq (1 - \sum_{j=1}^{N} x_{2,j} ) \cdot M +1 \\&#xA;A_{1} -1 + \sum_{j=1}^{N} t_j \cdot x_{2,j} \leq (1 - \sum_{j=1}^{N} x_{3,j} ) \cdot M +1 \\&#xA;\vdots \\&#xA;A_{T-2} -1 + \sum_{j=1}^{N} t_j \cdot x_{T-1,j} \leq (1 - \sum_{j=1}^{N} x_{T,j} ) \cdot M +1  \\&#xA;\sum_{j=1}^{N} x_{i,j}  \leq 1 \quad \forall i=1,\ldots,T \\&#xA;\sum_{i=1}^{T} x_{i,j}  \leq 1 \quad \forall j=1,\ldots,N \\&#xA;\sum_{i=1}^{T} \sum_{j=1}^{N} t_j \cdot x_{i,j}  \leq T \\&#xA;A_i \ge 1 \quad \forall i=1,\ldots,T \\&#xA;x_{i,j} \in \left \{ 0 ; 1 \right \} \forall \ i, j&#xA;\end{array} \right. $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Remarks&lt;/em&gt;&#xA;The computational capacity of Solver is artificially limited to a certain number of variables (200 variable cells, 2018). There is an open source software, &lt;em&gt;OpenSolver&lt;/em&gt;, capable of solving optimization problems in the linear, integer and non-linear form in Excel that does not admit a maximum number of variables. OpenSolver uses COIN-OR CBC to generate the solution in Excel.&lt;/p&gt;&#xA;" OwnerUserId="4114" LastEditorUserId="4114" LastEditDate="2023-01-03T12:33:21.543" LastActivityDate="2023-01-03T12:33:21.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9670" PostTypeId="1" CreationDate="2023-01-02T17:28:33.473" Score="1" ViewCount="102" Body="&lt;p&gt;I was trying to use Gurobi for a minimization problem like so:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min\|M-TX\|_1&#xA;$$&lt;/span&gt;&#xA;where all three terms are matrices. &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is the nonnegative decision variable(s) of compatible size. &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; are nonnegative. I wanted &lt;span class=&quot;math-container&quot;&gt;$TX$&lt;/span&gt; to approximate &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; being as sparse as possible in an LP. I also have some other constraints on &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It seems that the MVar support in Gurobi v10 doesn't yet have a norm function, and that its general norm function only supports vectors, and that its reshape support only applies to variables, not to expressions. How can I achieve my objective?&lt;/p&gt;&#xA;" OwnerUserId="7428" LastEditorUserId="123" LastEditDate="2023-01-02T22:14:35.213" LastActivityDate="2023-01-02T22:14:35.213" Title="min matrix norm with gurobi v10+" Tags="|linear-programming|gurobi|gurobipy|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9671" PostTypeId="2" ParentId="7650" CreationDate="2023-01-02T22:56:32.073" Score="1" Body="&lt;p&gt;This is probably the post you were looking for: &lt;a href=&quot;https://matheducators.stackexchange.com/a/13519/8598&quot;&gt;What are easy examples from daily life of constrained optimization?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The story is true! In Section 6.4 (Arachim Vacharamim) of the Mishneh Torah, &lt;a href=&quot;https://www.chabad.org/library/article_cdo/aid/983603/jewish/Arachim-Vacharamim-Chapter-8.htm#v4&quot; rel=&quot;nofollow noreferrer&quot;&gt;verse 8:4 states&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When does the above apply? When they retracted one after the other. If, however, they all retracted at the same time, we divide the sum among them.&lt;/p&gt;&#xA;&lt;p&gt;What is implied? The first one says: &amp;quot;I will [redeem] it for ten selaim,&amp;quot; the second: &amp;quot;...for twenty,&amp;quot; and a third &amp;quot;...for 24,&amp;quot; and the second and third retract at the same time, we enable the first to redeem it for ten and we expropriate seven from the property of both the second and the third.10 Thus the Temple treasury collects 24. Similarly, if all three of them retract and the consecrated article is [ultimately] sold for three, we expropriate seven selaim from the property of all of them. These principles are followed in all instances.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is a &amp;quot;prelude&amp;quot; to the constrained equal losses problem. &lt;a href=&quot;https://www.cs.cmu.edu/%7Earielpro/15896s15/docs/paper8.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Aumann and Maschler (1985)&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; provides a much greater exposition including both Maimonides' stance and his intellectual adversary Rabad.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; Reference &lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] Aumann, R. J., Maschler, M. (1985). Game theoretic analysis of a bankruptcy problem from the Talmud. &lt;em&gt;Journal of Economic Theory.&lt;/em&gt; 36(2):195-213. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="123" LastActivityDate="2023-01-02T22:56:32.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9672" PostTypeId="1" CreationDate="2023-01-03T00:45:04.883" Score="1" ViewCount="188" Body="&lt;p&gt;I am trying to write the following expression in Gurobi+Java or Gurobi+python, if it is more practical It could be expressed as a big-M formulation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} \label{const4}&#xA;    \text{D}_{uv} =&#xA;  \begin{cases}&#xA;    \quad 0       &amp;amp; \quad \text{if } \quad Z_{uv}+Z_{vu} = 1\\&#xA;    \quad 0.3  &amp;amp; \quad \text{if } \quad Z_{uu}+Z_{vv} = 2 \\&#xA;    \quad 0.7  &amp;amp; \quad \text{if } \quad P_{u}= 1 \\&#xA;\end{cases}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;the variable &lt;span class=&quot;math-container&quot;&gt;$D_{uv}$&lt;/span&gt; is used in a minimization objective function, where &lt;span class=&quot;math-container&quot;&gt;$C_{uv}$&lt;/span&gt; is the parameter cost. I want to update the value for the variable &lt;span class=&quot;math-container&quot;&gt;$D_{uv}$&lt;/span&gt;, according to the behaviour of variable &lt;span class=&quot;math-container&quot;&gt;$Z_{uv}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_{u}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;f_{min}= \sum_{(u,v) \in P(i,j)} C_{uv} (\text{D}_{uv})&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I used the method GRBModel.AddGenConstrIndicator() (Gurobi+Java), but, when any of the conditions are fulfilled I do not see any changes in the value for variable &lt;span class=&quot;math-container&quot;&gt;$D_{uv}$&lt;/span&gt;, it does not change at all.&lt;/p&gt;&#xA;&lt;p&gt;I want to express these conditional statements using the indicator constraints by gurobi, if it is not possible, I would like to use a big-M formulation. I have tried to express the conditional statements as big-M formulations without success.&lt;/p&gt;&#xA;" OwnerUserId="11018" LastEditorUserId="11018" LastEditDate="2023-02-17T23:01:48.427" LastActivityDate="2023-02-17T23:01:48.427" Title="How to write this logical expression with Gurobi + Java, or express it as a big-m formulation" Tags="|modeling|integer-programming|gurobi|logical-constraints|indicator-constraints|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9674" PostTypeId="2" ParentId="7768" CreationDate="2023-01-03T08:42:21.367" Score="2" Body="&lt;p&gt;It is not true. You can refer to the following two papers, which provide a general method to analyze the departure process.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The Departure Process of the GI/G/1 Queue and Its MacLaurin Series.&lt;/li&gt;&#xA;&lt;li&gt;Correlated queues with service times depending on inter-arrival times.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Using the methods in the two papers, it is not difficult to obtain that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$E[D^k]=\rho E[S^k]+(1-\rho) E[(A+S)^k],$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is the generic inter-departure time, &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is the generic service time, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is inter-arrival times and &lt;span class=&quot;math-container&quot;&gt;$\rho=E[S]/E[A]$&lt;/span&gt; is the traffic intensity. From this formula, we can conclude that the departure process of M/G/1 queue is &lt;em&gt;not&lt;/em&gt; a Poisson process.&lt;/p&gt;&#xA;" OwnerUserId="11020" LastEditorUserId="11020" LastEditDate="2023-01-15T13:07:06.177" LastActivityDate="2023-01-15T13:07:06.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9675" PostTypeId="1" CreationDate="2023-01-03T16:05:31.790" Score="6" ViewCount="230" Body="&lt;p&gt;It is known for knapsack type constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in N} a_i x_i \leq b , x \in \{0,1\}$&lt;/span&gt;, we can generate the so called cover cuts that have the sum of coefficient in a set C greater than b. The cover cuts are &lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in C} x_j \leq |C| - 1, ~\forall~ C \subseteq N$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to generate the similar kind of cuts if x is integer, &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{Z}^{+}$&lt;/span&gt;.? Or there a way to generate other kind of valid inequalities from this constraint?&lt;/p&gt;&#xA;" OwnerUserId="11022" LastEditorUserId="491" LastEditDate="2023-01-06T02:27:38.883" LastActivityDate="2023-01-06T02:27:51.800" Title="Cover cuts for knapsack constraint with integer variables" Tags="|mixed-integer-programming|combinatorial-optimization|knapsack|branch-and-cut|valid-inequalities|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9677" PostTypeId="1" AcceptedAnswerId="9678" CreationDate="2023-01-03T19:40:40.060" Score="1" ViewCount="271" Body="&lt;p&gt;I am trying to solve a capacitated MCLP problem with two additional constraints.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Non-overlapping circles&lt;/li&gt;&#xA;&lt;li&gt;Minimum and Maximum value for the capacity for a circle.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;for 2nd constraint, I am able to add maximum limit but I am getting error when I try to add the minimum limit (as some locations are zeros and cannot be selected)&lt;/p&gt;&#xA;&lt;p&gt;All the details are same as this question. &lt;a href=&quot;https://or.stackexchange.com/questions/6459/capacitated-maximum-coverage-location-problem-python-and-gurobi/9676#9676&quot;&gt;Capacitated Maximum Coverage Location Problem, Python and Gurobi&lt;/a&gt; and I found it useful for adding a constraint.&lt;/p&gt;&#xA;&lt;p&gt;Pls suggest how can I add the second constraint?&lt;/p&gt;&#xA;&lt;p&gt;Note: Below image is added for the added query i.e not all demand points from a location, were included in the optimized solution. pls see the query in detail below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/O55EX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/O55EX.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OOYet.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OOYet.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11023" LastEditorUserId="11023" LastEditDate="2023-01-09T13:06:56.930" LastActivityDate="2023-01-09T20:01:42.360" Title="Capacitated Maximum Coverage Location Problem, Python and Gurobi" Tags="|optimization|python|integer-programming|gurobi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9678" PostTypeId="2" ParentId="9677" CreationDate="2023-01-03T20:35:16.157" Score="1" Body="&lt;p&gt;So, you are looking for something like&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$Minpoints\cdot x_j \le \sum_{i \in\ S_j} y_i \ \ \forall j \in\ J$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x_j =1$&lt;/span&gt; if Facility j is selected at all, &lt;span class=&quot;math-container&quot;&gt;$S_j =\{i \in\ I: d_{i,j} \le r\}$&lt;/span&gt; and Minpoints is a number you choose&lt;/p&gt;&#xA;&lt;p&gt;Using same code as before&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for j in J:&#xA; model.addConstr(minpoints*x[j] &amp;lt;= quicksum(y[i] for i in np.where(D[:,j]==1)[0]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-03T21:12:08.830" LastActivityDate="2023-01-03T21:12:08.830" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9679" PostTypeId="2" ParentId="9675" CreationDate="2023-01-04T14:00:19.853" Score="4" Body="&lt;p&gt;Consider the integer knapsack set as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ K_{I} = \{ x \in Z^{N}_{+} : ax \leq b, x \leq u\} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$C \subseteq N$&lt;/span&gt; be a cover if &lt;span class=&quot;math-container&quot;&gt;$\lambda = \sum_{i \in C} u_ia_i − b \gt 0$&lt;/span&gt; and consider the restriction &lt;span class=&quot;math-container&quot;&gt;$K_I (N \text{\\} C,  \varnothing)$&lt;/span&gt; obtained by fixing all &lt;span class=&quot;math-container&quot;&gt;$x_i, i \in N \text{\\} C$&lt;/span&gt; to zero. Extending the combinatorial argument on covers for the &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;-&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; knapsack set, since not all variables &lt;span class=&quot;math-container&quot;&gt;$x_i, i \in C$&lt;/span&gt; can be at their upper bound simultaneously, inequality:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i \in C} x_i \leq u(C)-1 \quad (1)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is valid for &lt;span class=&quot;math-container&quot;&gt;$K_I (N \text{\\} C,  \varnothing)$&lt;/span&gt;. Another way to write the above inequality is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i \in C} (u_{i} - x_{i}) \geq 1 \quad (2)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which states that at least one &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; must be less than its upper bound. However, observe that if &lt;span class=&quot;math-container&quot;&gt;$a_i \lt \lambda$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i \in C$&lt;/span&gt; the left-hand side of (2) is greater than &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; for all feasible solutions. This suggests the strengthening:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i \in C} (u_{i} - x_{i}) \geq \lceil \lambda/ \bar{a} \rceil $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\bar{a} = \text{max}_{i \in C} a_{i}$&lt;/span&gt;. Suppose the integer knapsack is given as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ K_{I}=\{ x \in \text{Z}^2: 5x_{1} + 9x_{2} \leq 45, x_{1} \leq 6, x_{2} \leq 4\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$C = \{1,2\}$&lt;/span&gt; be an integer cover with &lt;span class=&quot;math-container&quot;&gt;$\lambda = 30 + 36 − 45 = 21$&lt;/span&gt;. The following inequality:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ (6-x_{1}) + (4-x_{2}) \geq 1 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;does not support &lt;span class=&quot;math-container&quot;&gt;$K_{I}$&lt;/span&gt; . However, the strengthened inequality:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ (6-x_{1}) + (4-x_{2}) \geq \lceil 21/9 \rceil $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;defines a facet of &lt;span class=&quot;math-container&quot;&gt;$K_{I}$&lt;/span&gt; for this example. For more details please, see the following paper.&lt;/p&gt;&#xA;&lt;p&gt;Also, it seems the mentioned integer knapsack set can be supposed as a capacity constraint in the planning models that other valid inequalities like Gomory cuts, MIR cuts, etc. can be applied on.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;em&gt;Atamtürk, A. Cover and Pack Inequalities for (Mixed) Integer Programming. Ann Oper Res 139, 21–38 (2005). &lt;a href=&quot;https://doi.org/10.1007/s10479-005-3442-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1007/s10479-005-3442-1&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="123" LastEditDate="2023-01-04T19:30:59.413" LastActivityDate="2023-01-04T19:30:59.413" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9680" PostTypeId="2" ParentId="9675" CreationDate="2023-01-04T14:15:44.427" Score="2" Body="&lt;p&gt;Sure. Another way of doing this is by extending the number of items. Suffices to create &lt;span class=&quot;math-container&quot;&gt;$\lfloor \frac{b}{a_i} \rfloor$&lt;/span&gt; dummy items to each item &lt;span class=&quot;math-container&quot;&gt;$i \in N$&lt;/span&gt;. Thus, we would have the new items set &lt;span class=&quot;math-container&quot;&gt;$N^{'} = \bigcup_{i \in N} N_i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$N_i = \{ i_k : k \in \mathbb{N}^{*}_{\leqslant \lfloor \frac{b}{a_i} \rfloor} \}$&lt;/span&gt; is the set of dummies items of item &lt;span class=&quot;math-container&quot;&gt;$i \in N$&lt;/span&gt;. Resulting in the following formulation.&lt;/p&gt;&#xA;&lt;p&gt;Max &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in N^{'}} p_i x_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in N^{'}} a_i x_i \leqslant b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{B}^{|N^{'}|}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With the following cover cuts.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in C} x_i \leqslant |C| - 1 \quad\quad \forall C \subseteq N^{'} : \sum_{i \in C} a_i &amp;gt; b$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="491" LastEditDate="2023-01-06T02:27:51.800" LastActivityDate="2023-01-06T02:27:51.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9681" PostTypeId="1" AcceptedAnswerId="9683" CreationDate="2023-01-04T19:24:12.167" Score="2" ViewCount="76" Body="&lt;p&gt;I'm curious how is the best way to articulate a soft, categorical constraint for MILP solvers.&lt;/p&gt;&#xA;&lt;p&gt;In example, say that there are two sizes of t-shirts, small and large. Likewise, people have ideal t-shirt sizes, small and large. A hard constraint would enforce that everybody gets a t-shirt their size and if that's not possible, there is no solution.&lt;/p&gt;&#xA;&lt;p&gt;Conversely, a soft constraint would enforce that everybody received a t-shirt, but it might not be their ideal size. I believe that this could be done by an objective term, rather than a constraint, by maximizing the number of people who got their ideal t-shirt size (or minimizing those who didn't.)&lt;/p&gt;&#xA;&lt;p&gt;However, I'd like to some feedback on how I can express this categorical soft constraint in terms of variables, which a generic MILP solver would accept.&lt;/p&gt;&#xA;" OwnerUserId="10326" LastActivityDate="2023-01-04T20:05:12.223" Title="Articulating categorical soft constraints in MILP" Tags="|mixed-integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9682" PostTypeId="1" AcceptedAnswerId="9684" CreationDate="2023-01-04T19:50:48.257" Score="2" ViewCount="265" Body="&lt;p&gt;Typical Divide and Conquer algorithm solves a problem using following three steps:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Divide: This involves dividing the problem into smaller sub-problems.&lt;/li&gt;&#xA;&lt;li&gt;Conquer: Solve sub-problems by calling recursively until solved.&lt;/li&gt;&#xA;&lt;li&gt;Combine: Combine the sub-problems to get the final solution of the&#xA;whole&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://www.geeksforgeeks.org/divide-and-conquer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.geeksforgeeks.org/divide-and-conquer/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;By looking at that general definition, I wonder if it is not, in general, the same process used by Dantzig and Wolfe with their decomposition technique:&lt;br /&gt;&#xA;Divide: Accomplished by models with a special constraints structure&lt;br /&gt;&#xA;Conquer: Solve sub-problems&lt;br /&gt;&#xA;Combine: Combine the sub-problems solutions by convexity constraints.&lt;/p&gt;&#xA;&lt;p&gt;Does this make sense?&lt;/p&gt;&#xA;" OwnerUserId="3139" LastEditorUserId="491" LastEditDate="2023-01-06T02:25:36.610" LastActivityDate="2023-01-06T02:26:07.577" Title="Is Dantzig-Wolfe decomposition an example of a divide and conquer algorithm?" Tags="|linear-programming|algorithms|dantzig-wolfe-decomposition|approximation-algorithms|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9683" PostTypeId="2" ParentId="9681" CreationDate="2023-01-04T20:05:12.223" Score="2" Body="&lt;p&gt;One approach is to use penalty terms. So you would have variables for number of small/large shirts delivered to customers asking for small/large shirts (four variables, one for each combination), constraints that small shirts delivered to customers who wanted them plus small shirts delivered to customers who wanted large equals total small shirts produced (and similarly for large shirts), and penalty terms in the objective for each small (large) shirt delivered to a customer requesting a large (small) shirt. These penalties need not be equal. Sending a big person a small shirt may be worse than sending a small person a big shirt. Adding penalties is easy in formulation terms; the tricky part is picking the right values (objective coefficients) for the penalties.&lt;/p&gt;&#xA;&lt;p&gt;Another approach is to constrain the number of small (large) shirts used to satisfy demand for large (small) shirts, specifying upper limits. A third approach is to use both constraints and penalties (penalties to discourage mismatches and constraints to make sure that at most a certain number of angry customers of either type is created, even if it means eating larger penalties).&lt;/p&gt;&#xA;&lt;p&gt;With regard to penalties, sometimes it is useful to apply a sequence of progressively more stringent penalties for the same constraint violation. For instance, suppose I have a variable that assigns work hours to a worker who has a nominal 40 hour work week. I might write the constraint as &amp;quot;hours assigned - slack + OT1 + OT2 = 40,&amp;quot; where OT1 is &amp;quot;time-and-a-half overtime&amp;quot; (lower bound 0, upper bound 10, penalty coefficient = 1.5 times normal wage) and OT2 is &amp;quot;double-time overtime&amp;quot; (lower bound 0, no upper bound, penalty coefficient = 2 times normal wage).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-01-04T20:05:12.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9684" PostTypeId="2" ParentId="9682" CreationDate="2023-01-04T20:12:33.433" Score="7" Body="&lt;p&gt;I've never seen D-W referred to as &amp;quot;divide and conquer.&amp;quot; While I'm not sure there is a definitive answer one way or the other (meaning I don't know that anyone can say with authority that it is wrong to call it d-and-c), I personally would not consider it a d-and-c approach. My sense is that &amp;quot;divide and conquer&amp;quot; typically refers to a decomposition where each subproblem is solved once. In D-W, both subproblems and the master problem are solved repeatedly.&lt;/p&gt;&#xA;&lt;p&gt;That said, there is definitely dividing and hopefully conquering when using D-W decomposition.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="491" LastEditDate="2023-01-06T02:26:07.577" LastActivityDate="2023-01-06T02:26:07.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9685" PostTypeId="1" AcceptedAnswerId="9686" CreationDate="2023-01-05T09:58:22.467" Score="4" ViewCount="363" Body="&lt;p&gt;I want to know how to transform this logical if-then constraint? If &lt;span class=&quot;math-container&quot;&gt;$B=1$&lt;/span&gt;,then &lt;span class=&quot;math-container&quot;&gt;$A \ge C$&lt;/span&gt;, else &lt;span class=&quot;math-container&quot;&gt;$A=0$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; are decision variables and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; are constants. &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is binary variable and &lt;span class=&quot;math-container&quot;&gt;$A\ge 0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11031" LastEditorUserId="491" LastEditDate="2023-01-06T02:24:03.723" LastActivityDate="2023-01-06T02:24:03.723" Title="How can I transform this logical if-then constraint?" Tags="|modeling|logical-constraints|" AnswerCount="1" CommentCount="1" ClosedDate="2023-01-14T18:57:32.453" ContentLicense="CC BY-SA 4.0" />
  <row Id="9686" PostTypeId="2" ParentId="9685" CreationDate="2023-01-05T11:18:19.753" Score="7" Body="&lt;p&gt;For better readability, let &lt;span class=&quot;math-container&quot;&gt;$y_B \in \{0,1\}$&lt;/span&gt; be your &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; variable, and let &lt;span class=&quot;math-container&quot;&gt;$x_A \in \mathbb{R}^+$&lt;/span&gt; be your &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; variable. You can model your statement as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA; Cy_B \le x_A \le My_B&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is an upper bound for variable &lt;span class=&quot;math-container&quot;&gt;$x_A$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2023-01-05T11:18:19.753" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9687" PostTypeId="1" CreationDate="2023-01-05T12:41:14.520" Score="3" ViewCount="77" Body="&lt;p&gt;I want to solve a multi-objective problem with nsga2 or moead taking advantage of the parallelism available in pygmo library. I have seen a very nice example on &lt;a href=&quot;https://github.com/esa/pagmo2/issues/149&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;  posted below. However I am not sure I understand it correctly. Setting the number of generations to 10 in the nsga2 algorithm,  it then loops 10 iterations (the so-called number of evolutions) calling the function evolve on the archipelago. Why should we do this evolution specifically ? Could we not set the number of generations to 100 instead of 10 ? or use &lt;code&gt;archi.evolve(10)&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The goal here is to speed up the pareto frontier approximation, e.g. instead of using 200 gen and 200 pop size on one core , I would expect that parallelize 50 gen and 50 pop size on 8 cores would do the job. But I am not sure how to do it.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;&amp;quot;Example that illustrates multi-objective optimization using pygmo.&amp;quot;&amp;quot;&amp;quot;&#xA;&#xA;import pygmo as pg&#xA;import numpy as np&#xA;from multiprocessing import Process, freeze_support&#xA;&#xA;def optimize(popsize=100, generations=10, islands=3, evolutions=10,&#xA;             prob=pg.problem(FonsecaFleming(5))):&#xA;    &amp;quot;&amp;quot;&amp;quot;Start optimization process.&amp;quot;&amp;quot;&amp;quot;&#xA;    # set up algorithm and optimize&#xA;    algo = pg.algorithm(pg.nsga2(gen=generations))&#xA;    archi = pg.archipelago(islands, algo=algo, prob=prob, pop_size=popsize)&#xA;&#xA;    # evolution&#xA;    fits_log, vectors_log = [], []&#xA;    for e in range(0, evolutions):&#xA;        # evolve islands&#xA;        archi.evolve(e)&#xA;        archi.wait()&#xA;        # extract data&#xA;        vectors = [isl.get_population().get_x() for isl in archi]&#xA;        vectors_log.append(vectors)&#xA;        fits = [isl.get_population().get_f() for isl in archi]&#xA;        fits_log.append(fits)&#xA;&#xA;    return [fits_log, vectors_log]&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    freeze_support()&#xA;    Process(target=optimize).start()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Because nsga2 does not seem compatible with a topology in pygmo, I have decided to use moead instead (tell me if i am wrong).&lt;/p&gt;&#xA;&lt;p&gt;Using a priori-knowledge, i have created a population of 200 individuals , each a vector of 30 variables. I have set fully connected topology to allow communications between the islands of the archipelago. See below my code.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   algo.set_verbosity(10)&#xA;   archi = pg.archipelago(n=8, algo=algo, pop=pop)&#xA;   archi.set_topology(pg.fully_connected(len(archi)))&#xA;   archi.evolve()&#xA;  archi.wait_check()  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and output:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RRsvO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RRsvO.png&quot; alt=&quot;Output of pygmo archipelago&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The code runs but I would have expected different values in the log (ADF, ideal1, ideal2) displayed for each process. Indeed for each generation , all islands have the same output parameters. Is that normal ? Also it is not that much faster (464 seconds instead of 729s)...&lt;/p&gt;&#xA;" OwnerUserId="11033" LastActivityDate="2023-01-05T12:41:14.520" Title="Pygmo2: What is the point of evolving an archipelago in a loop if number of generations already set in algo" Tags="|optimization|python|multi-objective-optimization|genetic-algorithm|parallel-computing|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9690" PostTypeId="1" AcceptedAnswerId="9693" CreationDate="2023-01-07T11:57:46.037" Score="4" ViewCount="1066" Body="&lt;p&gt;I am not that experienced with Operations Research yet. I have become familiar with what Sensitivity Analysis and Limits Reports are in general and through the use of Excel.&lt;/p&gt;&#xA;&lt;p&gt;I know that they can only be performed by Excel on non integer variable problems, but I read somewhere online that you can also do it on Integer Linear Programming models.&lt;/p&gt;&#xA;&lt;p&gt;I'm curious to learn whether they can be done on an ILP problem with binary variables. From what I understand, sensitivity analysis the allowed reduction or augmentation of a variable's value, as well as does the same for the constraints, whereas limits report gives us the upper and lower limit of the objective function's values. But the first one seems to not be feasible since our variables will either be 1 or 0 and I'm unsure how the same can be done on the constraints and as far as the second one goes I'm clueless as well.&lt;/p&gt;&#xA;&lt;p&gt;So, can we apply those two on a BILP problem or is the nature of the problem not allowing us to?&lt;/p&gt;&#xA;" OwnerUserId="10847" LastActivityDate="2023-01-07T19:03:53.323" Title="Can sensitivity analysis and limits report be done on an BILP problem?" Tags="|linear-programming|integer-programming|binary-variable|excel|sensitivity-analysis|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9691" PostTypeId="1" CreationDate="2023-01-07T17:49:25.927" Score="3" ViewCount="315" Body="&lt;p&gt;Does Guroib take advantage of the problem structure?&lt;/p&gt;&#xA;&lt;p&gt;I am working on a large optimization problem with more than 40,000 binary variables and huge number of constraints. below is only one of the constraints:&lt;/p&gt;&#xA;&lt;p&gt;P_plus&amp;gt;=P&lt;/p&gt;&#xA;&lt;p&gt;P_plus&amp;gt;=-p&lt;/p&gt;&#xA;&lt;p&gt;That will be applied on every time step t and every node i.&lt;/p&gt;&#xA;&lt;p&gt;First formulation:      Gurobi consumes 1 minute to solve the model.&lt;/p&gt;&#xA;&lt;p&gt;Second formulation:   Gurobi consumes 9 minutes to solve the model.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# First formulation, efficient formulation:&#xA;for i in range(n_b):&#xA;    for t in range (n_t):&#xA;       m.addConstr(P_plus[i,t]&amp;gt;=P[i,t],name='c0')&#xA;       m.addConstr(P_plus[i,t]&amp;gt;=-P[i,t], name='c1')&#xA;       &#xA;# Second formulation, less efficient formulation:       &#xA;m.addConstrs((P_plus[i,t]&amp;gt;=P[i,t] for i in range(n_b) for t in range (n_t)) , name='c0')&#xA;m.addConstrs((P_plus[i,t]&amp;gt;=-P[i,t] for i in range(n_b) for t in range (n_t)), name='c1')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Does that mean I should try to aggregate the constraints applied on the same time step and node together?&lt;/p&gt;&#xA;" OwnerUserId="10454" LastEditorUserId="10454" LastEditDate="2023-01-07T21:29:54.687" LastActivityDate="2023-01-07T21:29:54.687" Title="Does solver take advantage of the problem structure?" Tags="|linear-programming|gurobi|convex-optimization|gurobipy|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9692" PostTypeId="2" ParentId="9691" CreationDate="2023-01-07T18:23:58.490" Score="3" Body="&lt;p&gt;Probably the content &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360013420111-How-do-I-improve-the-time-to-build-my-model-&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; will be helpful.&lt;br /&gt;&#xA;Using for-loop outside of the gurobi native construct is slightly faster.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-01-07T18:23:58.490" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9693" PostTypeId="2" ParentId="9690" CreationDate="2023-01-07T18:57:28.207" Score="3" Body="&lt;p&gt;Parametric/sensitivity analysis of a right hand side coefficient in an optimization problem with integer variables can be done, but it is messy. See:&#xA;Schrage, L, and L. Wolsey (1985), &amp;quot;Sensitivity Analysis for Branch and Bound Integer Programming,&amp;quot; Operations Research, 33, (5):1008-1023.&lt;/p&gt;&#xA;&lt;p&gt;Parametric analysis of an objective coefficient of a variable that appears linearly in the objective is a bit more straight forward. The major result is that the optimal objective value is a concave function (assuming you are minimizing the objective) of the changing objective coefficient. If the optimization problem is a linear integer program, then the optimal objective value is a piecewise linear concave function. Loosely speaking, the approach is: solve a modest number of problems for appropriately/wisely chosen values for the parameter and &amp;quot;connect the dots.&amp;quot; See:&lt;/p&gt;&#xA;&lt;p&gt;Jenkins, L. (1982) &amp;quot;Parametric Mixed Integer Programming: An Application to Solid Waste Management.&amp;quot; Management Science 28(11):1270-1284.&lt;/p&gt;&#xA;" OwnerUserId="9043" LastEditorUserId="9043" LastEditDate="2023-01-07T19:03:53.323" LastActivityDate="2023-01-07T19:03:53.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9694" PostTypeId="2" ParentId="9691" CreationDate="2023-01-07T20:17:14.133" Score="3" Body="&lt;p&gt;Assuming you're talking about the time required to build the model:&lt;/p&gt;&#xA;&lt;p&gt;Let's time your two approaches first inside an iPython shell via the &lt;a href=&quot;https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-timeit&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;%%timeit&lt;/code&gt;&lt;/a&gt; magic command. Here, I use n_b = 400 and n_t = 100:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;In [11]: %%timeit&#xA;    ...:&#xA;    ...: for i in range(n_b):&#xA;    ...:     for t in range (n_t):&#xA;    ...:        m.addConstr(P_plus[i,t]&amp;gt;=P[i,t],name='c0')&#xA;    ...:        m.addConstr(P_plus[i,t]&amp;gt;=-P[i,t], name='c1')&#xA;&#xA;854 ms ± 9.35 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;In [12]: %%timeit&#xA;    ...:&#xA;    ...: # Second formulation, less efficient formulation:&#xA;    ...: m.addConstrs((P_plus[i,t]&amp;gt;=P[i,t] for i in range(n_b) for t in range (n_t)) , name='c0')&#xA;    ...: m.addConstrs((P_plus[i,t]&amp;gt;=-P[i,t] for i in range(n_b) for t in range (n_t)), name='c1')&#xA;&#xA;1.11 s ± 34.5 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Depending on the other constraints in your model, &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_mvar.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;MVar&lt;/code&gt;&lt;/a&gt;s are probably the better choice if the model building performance matters:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;P_plus = m.addMVar((n_b, n_t), name=&amp;quot;P_plus&amp;quot;)&#xA;P = m.addMVar((n_b, n_t), name=&amp;quot;P&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then, you can easily add your constraints as follows:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;In [13]: %%timeit&#xA;    ...:&#xA;    ...: m.addConstr(P_plus &amp;gt;= P)&#xA;    ...: m.addConstr(P_plus &amp;gt;= -P)&#xA; &#xA;368 ms ± 9.03 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2023-01-07T20:17:14.133" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9695" PostTypeId="1" CreationDate="2023-01-07T20:40:54.630" Score="1" ViewCount="64" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Pop-Donuts located in Los Angeles of California makes two products, donuts and cakes. Pop-Donuts has bottlenecks in its capital used to purchase flour that is required in making both donuts and cakes, and also in labor hours used to make these two products. These two products are very popular in the local market and all products are sold quickly. The goal of Pop-Donuts is to make as much profits as possible within its capacities. Currently contribution margins for a dozen donuts and a cake are &lt;span class=&quot;math-container&quot;&gt;$\\\$ 3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\\\$ 9$&lt;/span&gt;, respectively. Pop-Donuts will adjust sales prices when variable costs change to keep the contribution margins constant. Required direct labor hours are &lt;span class=&quot;math-container&quot;&gt;$15 \mathrm{~min}(0.25$&lt;/span&gt; h) per dozen donuts and &lt;span class=&quot;math-container&quot;&gt;$1 \mathrm{~h}$&lt;/span&gt; per cake. Pop-Donuts is expecting uncertainties in its budgets for direct materials as well as usage of flour per unit. The budget to purchase flour has a distribution with &lt;span class=&quot;math-container&quot;&gt;$f(x)=\frac{60000}{x^2}, \quad 15000 \leq x \leq 20000$&lt;/span&gt;, the cost of flour for a dozen donuts has a distribution with &lt;span class=&quot;math-container&quot;&gt;$f(x)=-750 x^2+900 x-262.5, \quad x \in(0.5,0.7)$&lt;/span&gt; and the cost of flour for a cake has a fixed value of &lt;span class=&quot;math-container&quot;&gt;$\\\$ 1.3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; We now build a continuous SLP problem and convert it to a discrete model by dividing these ranges into sub-intervals. Let us assume the following intervals in this discrete model. We use the first interval to demonstrate calculations and other intervals follow.&#xA;Given the interval of &lt;span class=&quot;math-container&quot;&gt;$(15000,17500)$&lt;/span&gt; and pdf &lt;span class=&quot;math-container&quot;&gt;$f(x)=\frac{60000}{x^2}, 15000 \leq x \leq 20000$&lt;/span&gt;, then the cumulative distribution function value &lt;span class=&quot;math-container&quot;&gt;$(\mathrm{CDF})=\int_{15000}^{17500} \frac{60000}{x^2} d x=0.5714$&lt;/span&gt; and its mean value is &lt;span class=&quot;math-container&quot;&gt;$\int_{15000}^{17500} \frac{60000}{x} d x=16,186$&lt;/span&gt;&#xA;As these distributions are independent, hence this discrete model can have four combinations in this case. Note that given large computational complexities of the SAA method, &lt;strong&gt;we uses equal interval in sampling rather than equal probability in sampling.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zfoGl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zfoGl.png&quot; alt=&quot;image&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As indicated before, if more sub-intervals are selected and hence more combinations are used, the obtained optimal solution will get closer to the global optimal solution to the original continuous SLP problem.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;Q: I couldn't understand how they construct the four scenarios from the solution, especially the two constraints. Like I guess the 1st constraint is cost of flour but what is the 2nd constraint? And what they mean by, &lt;strong&gt;we uses equal interval in sampling rather than equal probability in sampling.&lt;/strong&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Q: In the 1st constraint &lt;span class=&quot;math-container&quot;&gt;$\bbox[4px, border: 2px solid red]{0.5625} x_1+1.3 x_2 \leq \bbox[4px, border: 2px solid red]{16186}$&lt;/span&gt;, is the coefficients come from &lt;span class=&quot;math-container&quot;&gt;$\int x\left(-750 x^2+900 x-262.5\right) d x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\int_{15000}^{17500} \frac{60000}{x} d x$&lt;/span&gt; ? because then for &lt;span class=&quot;math-container&quot;&gt;$(0.5,0.7)$&lt;/span&gt; interval isn't it should be &lt;span class=&quot;math-container&quot;&gt;$\int_{0.5}^{0.7} x\left(-750 x^2+900 x-262.5\right) d x=0.6$&lt;/span&gt; ? but it was given &lt;span class=&quot;math-container&quot;&gt;$0.5625$&lt;/span&gt; Another question is, they mention probability as &lt;span class=&quot;math-container&quot;&gt;$0.2857$&lt;/span&gt;, how?&lt;/p&gt;&#xA;" OwnerUserId="9806" LastEditorUserId="491" LastEditDate="2023-01-09T18:37:14.483" LastActivityDate="2023-01-09T18:37:14.483" Title="Problem to construct constaints in SAA method" Tags="|optimization|constraint|stochastic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9696" PostTypeId="2" ParentId="9695" CreationDate="2023-01-07T22:07:21.943" Score="1" Body="&lt;p&gt;2nd constraint is related to direct labor hours. It seems 15 min per dozen donuts, &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; could imply a dozen donuts. But I am not sure how 0.25 is turning into 2.5 while per cake labor remains at 1. It should be&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$0.25x1 + x2 \le L$&lt;/span&gt; where L is Labor hours available.&lt;br /&gt;&#xA;As for Sample Average Approximate, its a continuous distribution over given interval like (15000,20000) or (0.5,0.7). So if you are to take a random variable of x from these intervals, you can choose a random value with a uniform probability of 1/N where N=2000-15000 or as for the range, 0.7-0.5. This will have have its complexities of large number of values possible. So the paper is suggesting to consider equal intervals with may be of size=100 and then take the average which you have correctly calculated as &lt;span class=&quot;math-container&quot;&gt;$\int\  xf(x)$&lt;/span&gt; over the intervals.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-01-07T22:07:21.943" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9697" PostTypeId="1" CreationDate="2023-01-07T22:09:19.660" Score="1" ViewCount="137" Body="&lt;p&gt;A factory has a four workstations assembly line which produces a bluetooth speaker. This&#xA;production requires twelve assembly operations, respecting some precedence constraints. Table&#xA;4 indicates the duration of every task (in minutes) and the list of its immediate predecessors (the abbreviation PCB used in this table stands for ’printed circuit board’). The order of processing of the tasks should respect the precedences that are given in this table and illustrated on the graph of Figure 2.&#xA;The production manager would like to distribute the tasks among the four workstations, subject&#xA;to the precedence constraints, in order to balance the line to obtain the shortest possible cycle&#xA;time, that is, the total time required for assembling a bluetooth speaker. Every task needs to be&#xA;assigned to a single workstation that has to process it without interruption. Every workstation&#xA;deals with a single operation at a time. We talk about cycle time because the operations on&#xA;every workstation will be repeated for every speaker. When a product is finished, the bluetooth&#xA;speaker at stations 1 to 3 advance by one station, and the assembly of a new speaker is started&#xA;at the first workstation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wKBHm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wKBHm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/m639Y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/m639Y.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11048" LastActivityDate="2023-01-07T22:09:19.660" Title="Assembly Line Balancing---(Minimizing Cycle Time)" Tags="|optimization|integer-programming|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9698" PostTypeId="1" CreationDate="2023-01-07T23:16:24.560" Score="1" ViewCount="210" Body="&lt;p&gt;How do I model a precedence constraint of 12 tasks distributed among 4 work stations in order to balance the line to obtain the shortest possible cycle time?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Number of tasks&#xA;N = 12&#xA;#Number of workstations&#xA;W = 4&#xA;&#xA;#D[i] duration of task i&#xA;D = [3,6,7,6,4,8,9,11,2,13,4,3]&#xA;&#xA;# Precedence (arcs on the precedence graph)&#xA;A = [(1,2),(1,3),&#xA;    (2,4),(2,5),(2,6),&#xA;    (3,6),(3,7),&#xA;    (4,9),&#xA;    (5,9),&#xA;    (6,8),&#xA;    (7,11),&#xA;    (11,10), &#xA;    (8,9),(8,10),&#xA;    (9,12),&#xA;    (10,12)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Variables:&lt;br /&gt;&#xA;Xik ={1, if task i = 1,...,N is assigned to station k=1,...,W&lt;br /&gt;&#xA;0, otherwise&lt;br /&gt;&#xA;Yik = beginning of task i = 1,...,N on station k =1,...,W&lt;br /&gt;&#xA;Ej = time at which operations in station k = 1,...,W end&lt;/p&gt;&#xA;" OwnerUserId="11048" LastEditorUserId="491" LastEditDate="2023-01-11T18:17:32.077" LastActivityDate="2023-01-11T18:17:32.077" Title="How do I model a precedence constraint?" Tags="|optimization|integer-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9699" PostTypeId="2" ParentId="9698" CreationDate="2023-01-08T01:15:30.043" Score="1" Body="&lt;p&gt;Ok just in general:&lt;br /&gt;&#xA;Any preceding relation or constraint is modelled as:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{i,k} \le x_{j,k} \ \ \forall j \in\ S_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$S_i=$&lt;/span&gt; set of precedence tasks or whatever for &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;br /&gt;&#xA;Now you have to also ensure once all preceding jobs are assigned &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; for job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; should be assigned. You do that by:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in\ S_i} \sum_k x_{j,k} - \vert S_i \vert +1 \le \sum_k x_{i,k} \ \ \forall i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There's another constraint to ensure a task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to just 1 workstation.&lt;/p&gt;&#xA;&lt;p&gt;Also your starting time &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; is max of start+duration of other preceding jobs.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_i \ge (y_j+D_j) \ \ \forall j \in\ S_i \ \ \forall i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And then you have to link&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_k x_{i,k}\le y_i \le M \sum_k x_{i,k} \ \ \forall i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now think duration of which task or workstation will you minimize to optimize the cycle time? Or should you maximize the production rate?&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-08T02:15:57.087" LastActivityDate="2023-01-08T02:15:57.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9700" PostTypeId="1" AcceptedAnswerId="9708" CreationDate="2023-01-08T02:03:43.270" Score="1" ViewCount="80" Body="&lt;p&gt;Stochastic dual dynamic programming (SDDP) algorithm solves stage-wise optimization problem through sampling scenarios. In this regard, it is obvious to see that wait-and-see uncertainty can be easily handled by SDDP (first sample random noise at each decision node in a scenario and solve a deterministic problem). On the other hand, is it possible to solve a multi stage optimization problem with here-and-now uncertainty nodes (random noise at a particular node is realized after respective stage specific problem is solved)?&#xA;In this case, stage specific problems can not be made deterministic by simply sampling random noise at the respective stages.&lt;/p&gt;&#xA;" OwnerUserId="10727" LastActivityDate="2023-01-08T19:07:07.223" Title="Can stochastic dual dynamic programming algorithm (or any variant of it) handle multi-stage optimization problems with here-and-now uncertainty nodes?" Tags="|stochastic-programming|uncertainty|multi-stage|sddp|stochastic-dual-dynamic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9701" PostTypeId="1" CreationDate="2023-01-08T07:42:26.740" Score="2" ViewCount="191" Body="&lt;p&gt;What is the difference between Optimality cuts and Feasibility cuts for L shaped method in stochastic programming? Like for the following problem they used Optimality cuts,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;&amp;amp; z=\min 100 x_1+150 x_2+\mathrm{E}_{\boldsymbol{\xi}}\left(q_1 y_1+q_2 y_2\right) \\&#xA;&amp;amp; \text { s. t. } \quad x_1+x_2 \leq 120 \text {, } \\&#xA;&amp;amp; 6 y_1+10 y_2 \leq 60 x_1 \text {, } \\&#xA;&amp;amp; 8 y_1+5 y_2 \leq 80 x_2 \text {, } \\&#xA;&amp;amp; y_1 \leq d_1, \quad y_2 \leq d_2, \\&#xA;&amp;amp; x_1 \geq 40, \quad x_2 \geq 20, \quad y_1, y_2 \geq 0, \\&#xA;&amp;amp;&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{\xi}^T=\left(d_1, d_2, q_1, q_2\right)$&lt;/span&gt; takes on the values &lt;span class=&quot;math-container&quot;&gt;$(500,100,-24,-28)$&lt;/span&gt; with probability &lt;span class=&quot;math-container&quot;&gt;$0.4$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(300,300,-28,-32)$&lt;/span&gt; with probability &lt;span class=&quot;math-container&quot;&gt;$0.6$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And Feasibility cuts for the the following problem,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{gathered}&#xA;\min 3 x_1+2 x_2-\mathrm{E}_{\boldsymbol{\xi}}\left(15 \mathbf{y}_1+12 \mathbf{y}_2\right) \\&#xA;\text { s. t. } 3 \mathbf{y}_1+2 \mathbf{y}_2 \leq x_1, \\&#xA;2 \mathbf{y}_1+5 \mathbf{y}_2 \leq x_2, \\&#xA;.8 \boldsymbol{\xi}_1 \leq \mathbf{y}_1 \leq \boldsymbol{\xi}_1, \\&#xA;.8 \boldsymbol{\xi}_2 \leq \mathbf{y}_2 \leq \boldsymbol{\xi}_2, \\&#xA;x, \mathbf{y} \geq 0, \text { a.s., }&#xA;\end{gathered}&#xA;$$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$\xi_1=4$&lt;/span&gt; or 6 and &lt;span class=&quot;math-container&quot;&gt;$\xi_2=4$&lt;/span&gt; or 8 , independently, with probability &lt;span class=&quot;math-container&quot;&gt;$1 / 2$&lt;/span&gt; each and &lt;span class=&quot;math-container&quot;&gt;$\boldsymbol{\xi}=\left(\boldsymbol{\xi}_1, \boldsymbol{\xi}_2\right)^T$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Q: I have the solution. But what I am missing is the clear meaning of Optimality Cuts and Feasibility Cuts used in L shape method and Why? It will be a great help if anyone give some insight or resource for clear explanation of that.&lt;/p&gt;&#xA;" OwnerUserId="9806" LastEditorUserId="491" LastEditDate="2023-01-09T18:33:41.833" LastActivityDate="2023-01-09T18:33:41.833" Title="Difference between Optimality cuts and Feasibility cuts for L shaped method in stochastic programming?" Tags="|reference-request|stochastic-programming|benders-decomposition|optimality-conditions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9702" PostTypeId="1" CreationDate="2023-01-08T08:46:41.730" Score="2" ViewCount="42" Body="&lt;p&gt;Consider an assembly line where some parts are produced in a station following a Poisson process with a rate of &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;These parts are put directly in a bin (transfer time to the bin is negligible). We have &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; robot arms that take these parts from the bin and place them in the next station.&lt;/p&gt;&#xA;&lt;p&gt;Each robot arm is programmed to detect the number of parts in the bin, and it only collects and transfers them when there are precisely &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; units available.&lt;/p&gt;&#xA;&lt;p&gt;It takes &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; time units for an arm to go from the bin to the next station, and it takes &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; time units for it to return to the bin. The time for grabbing and dropping products is negligible.&lt;/p&gt;&#xA;&lt;p&gt;If we model the robot arms as &lt;span class=&quot;math-container&quot;&gt;$M/D^{(b,b)}/r$&lt;/span&gt;, is the service time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$2t$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;I thought since it takes &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; for a batch to be &amp;quot;served&amp;quot; which is it being taken from the bin and placed in the next station, the service time is &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, and the service rate is &lt;span class=&quot;math-container&quot;&gt;$1/t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Does this make sense?&lt;/p&gt;&#xA;" OwnerDisplayName="user10774" LastActivityDate="2023-01-09T07:26:47.090" Title="Modeling an assembly line as a batch processing $M/D^{(b,b)}/r$ queue" Tags="|queuing-theory|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9703" PostTypeId="2" ParentId="9698" CreationDate="2023-01-08T14:06:18.707" Score="1" Body="&lt;p&gt;Noted that separate from whether we can solve such a problem, some things should be considered. First, for an assembly line balancing two important factors are the line bottleneck and the required demand that comes from the customer side. The second would be how we can analyze the bottleneck station regarding being a tool/machine/etc. or a human-based station. I assume you analyzed that and now, the only thing is to solve the above problem.&lt;/p&gt;&#xA;&lt;p&gt;There are many ways to solve an assembly line problem and also its variants. Some cases are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A simple random assignment, that almost yields a sub-optimal solution.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.technicaljournalsonline.com/ijaers/VOL%20II/IJAERS%20VOL%20II%20ISSUE%20IV%20JULY%20SEPTEMBER%202013/321.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ranked Positional Weights&lt;/a&gt;, which is a well-known heuristic to solve SALBP. Also, a python implementation could be found &lt;a href=&quot;https://github.com/noobie1Kenobie/rpw/blob/main/RankedPositionalWeightMethod.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S036083520000053X&quot; rel=&quot;nofollow noreferrer&quot;&gt;COMSOAL&lt;/a&gt; algorithm is another very good heuristic to solve SALBPs.&lt;/li&gt;&#xA;&lt;li&gt;Mixed-integer linear programming.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The solution for the above problem by using &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;rd and the &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;th mentioned techniques are as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;The &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;rd&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CGfCp.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CGfCp.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As shown in the above results, the assembly line cycle time would be around &lt;span class=&quot;math-container&quot;&gt;$20$&lt;/span&gt; mins. Also, from a mathematical point of view, this problem can be formulated as a bin-packing problem by adding the precedence constraint:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;The &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;th&lt;/em&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{s \in Station} s x_{i,s} \leq  \sum_{s \in Station} s x_{j,s} \quad \forall (i,j) \in &#xA;PrecedenceTasks $$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also, The results of the MIP with the objective value equal to &lt;span class=&quot;math-container&quot;&gt;$20$&lt;/span&gt; mins would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;VARIABLE x[i,s]  assignment&#xA;&#xA;          station1    station2    station3    station4&#xA;&#xA;item1        1.000&#xA;item2        1.000&#xA;item3        1.000&#xA;item4                                1.000&#xA;item5        1.000&#xA;item6                    1.000&#xA;item7                                1.000&#xA;item8                    1.000&#xA;item9                                1.000&#xA;item10                                           1.000&#xA;item11                                           1.000&#xA;item12                                           1.000&#xA; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can see the result of both methods are very similar. For more details on SALBP please, see this &lt;a href=&quot;https://assembly-line-balancing.de/salbp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-01-08T14:06:18.707" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9704" PostTypeId="1" CreationDate="2023-01-08T14:38:11.293" Score="4" ViewCount="314" Body="&lt;p&gt;Maybe this is a weird question for Operations Research SE, but I seek to get paid for my operations research skills while working remotely. I already have accounts on freelancing websites. However, I exert a lot of effort in refusing to do students' homework. Would anyone please suggest another way?&lt;/p&gt;&#xA;" OwnerUserId="3480" LastEditorUserId="8" LastEditDate="2023-05-25T09:17:05.853" LastActivityDate="2023-05-25T09:17:05.853" Title="How to get paid for operations research skills?" Tags="|or-careers|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9705" PostTypeId="2" ParentId="9702" CreationDate="2023-01-08T15:15:39.320" Score="1" Body="&lt;p&gt;t= start of service to end of service. The t for return will be part of average wait time for the queue.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-01-08T15:15:39.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9706" PostTypeId="1" CreationDate="2023-01-08T17:33:58.850" Score="5" ViewCount="389" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; be a graph. I would like to identify an eulerian cycle in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; with minimum cost, &lt;strong&gt;with an integer programing approach&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; are integer variables that denote the number of times that edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is used.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \; \sum_{(i,j)\in E}c_{ij}x_{ij}&#xA;$$&lt;/span&gt;&#xA;subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i,(i,j)\in E}x_{ij}&amp;amp;=\sum_{i,(j,i)\in E}x_{ji} \quad \forall j \in V \tag{1}\\&#xA;x_{ij} &amp;amp;\ge 1 \quad \forall (i,j)\in E \tag{2}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is this a valid formulation? Can I relax the variables to be continuous?&lt;/p&gt;&#xA;" OwnerUserId="11050" LastEditorUserId="2556" LastEditDate="2023-01-08T21:24:08.883" LastActivityDate="2023-01-09T16:23:14.223" Title="Is this arc routing formulation correct?" Tags="|modeling|integer-programming|graphs|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9707" PostTypeId="1" AcceptedAnswerId="9718" CreationDate="2023-01-08T18:20:18.853" Score="4" ViewCount="179" Body="&lt;p&gt;Given a positive integer &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, a constant &lt;span class=&quot;math-container&quot;&gt;$k=2/3$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$7$&lt;/span&gt; variables &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2, x_3, x_{12}, x_{13}, x_{23}, x_{123}$&lt;/span&gt; (non-negative reals or integers) I would like to find:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \binom{x_1}2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\binom{x_1}2 \ge \binom{x_2}2 \ge \binom{x_3}2 \tag{1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\binom{n}2 \ge \binom{x_1}2+\binom{x_2}2+\binom{x_3}2-\binom{x_{12}}2-\binom{x_{23}}2-\binom{x_{13}}2 \ge k\binom{n-1}2 \tag{2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\binom{x_1}2 \ge \binom{x_{12}}2+\binom{x_{13}}2 \ge k\binom{x_1-1}2 \tag{3}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\binom{x_2}2 \ge \binom{x_{12}}2+\binom{x_{23}}2 \ge k\binom{x_2-1}2 \tag{4}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\binom{x_3}2 \ge \binom{x_{13}}2+\binom{x_{23}}2 \ge k\binom{x_3-1}2 \tag{5}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_1+x_2+x_3-x_{12}-x_{13}-x_{23}+x_{123} = n \tag{6}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is a starting example, because from this I would like to solve the natural extension of the problem with &lt;span class=&quot;math-container&quot;&gt;$2^q-1$&lt;/span&gt; variables, &lt;span class=&quot;math-container&quot;&gt;$q \gt 3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If we remove &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt; from the problem and we could replace &lt;span class=&quot;math-container&quot;&gt;$\binom{x_1-1}2, \binom{x_2-1}2, \binom{x_3-1}2$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\binom{x_1}2, \binom{x_2}2, \binom{x_3}2$&lt;/span&gt; on the RHS of &lt;span class=&quot;math-container&quot;&gt;$(3), (4), (5)$&lt;/span&gt; and then set &lt;span class=&quot;math-container&quot;&gt;$y_1=\binom{x_1}2, y_2=\binom{x_2}2, y_3=\binom{x_3}2, y_{12}=\binom{x_{12}}2, y_{13}=\binom{x_{13}}2, y_{23}=\binom{x_{23}}2, y_{123}=\binom{x_{123}}2$&lt;/span&gt; we would get a linear program. Unfortunately, we can't do that, that's why we have a &amp;quot;nearly&amp;quot; linear program.&lt;/p&gt;&#xA;&lt;p&gt;One idea that came to mind is that e.g.:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$k\binom{x_1-1}2 = k\frac{x_1-2}{x_1}\binom{x_1}2 \ge \frac{2}{3}k\binom{x_1}2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;when &lt;span class=&quot;math-container&quot;&gt;$x_1 \ge 6$&lt;/span&gt;, therefore we could replace the RHS for &lt;span class=&quot;math-container&quot;&gt;$x_1 \ge 6$&lt;/span&gt; and enumerate all the possible values of &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$x_1 \lt 6$&lt;/span&gt;, but we would have another &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; linear programs to solve. If we fix &lt;span class=&quot;math-container&quot;&gt;$\binom{x_2-1}2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\binom{x_3-1}2$&lt;/span&gt; in the same way, the additional programs to solve would be &lt;span class=&quot;math-container&quot;&gt;$6^3 = 216$&lt;/span&gt;. That will be much bigger for &lt;span class=&quot;math-container&quot;&gt;$q \gt 3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Another idea is keep &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt;, then use the identity:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\binom{x_1-1}2=\binom{x_1}2-x_1+1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;however, with this one we would need a way to enforce the relation between &lt;span class=&quot;math-container&quot;&gt;$y_1 = \binom{x_1}2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;, i.e. linearize:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y_1 = \frac{x_1(x_1-1)}2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Any idea or suggestion?&lt;/p&gt;&#xA;" OwnerUserId="9517" LastEditorUserId="9517" LastEditDate="2023-01-09T14:33:45.317" LastActivityDate="2023-01-10T22:03:59.773" Title="How to solve a &quot;nearly&quot; linear program" Tags="|linear-programming|linearization|nonlinear-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9708" PostTypeId="2" ParentId="9700" CreationDate="2023-01-08T19:07:07.223" Score="3" Body="&lt;p&gt;Here-and-now uncertainty problems, which are also known as &lt;strong&gt;Decision-Hazard&lt;/strong&gt; problems, are problems that decisions need to be made before the revelation of uncertain parameters on each node of a scenario tree. In multi-stage stochastic programming, &lt;em&gt;nonanticaptivity&lt;/em&gt; constraints are required. That is, no matter what the revealed uncertain data is in stage &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, decisions in stage &lt;span class=&quot;math-container&quot;&gt;$t-1$&lt;/span&gt; should be consistent. This is ensured by SDDP automatically, which implies the first method to handle Decision-Hazard problems:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Add auxiliary variables to the parent node (denote as &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;) of Decision-Hazard node (denote as &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;). Then add constraints to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; to make decisions of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; the same as that of &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;. In other words, all the Decision-Hazard types of decisions are made in the previous stage.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There is also another way:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Treat Decision-Hazard subproblems in SDDP as two-stage stochastic problems, in which the decisions that need to be made before the revelation of uncertain parameters are the first-stage decisions, while the other decisions are the second-stage decisions.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Some related papers that may be helpful:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Dowson, O. (2020). The policy graph decomposition of multistage stochastic programming problems. Networks, 76(1), 3–23.&#xA;&lt;a href=&quot;https://doi.org/10.1002/net.21932&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1002/net.21932&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Street, A., Valladão, D., Lawson, A., &amp;amp; Velloso, A. (2020). Assessing the cost of the Hazard-Decision simplification in multistage&#xA;stochastic hydrothermal scheduling. Applied Energy, 280, 115939.&#xA;&lt;a href=&quot;https://doi.org/10.1016/j.apenergy.2020.115939&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.apenergy.2020.115939&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2023-01-08T19:07:07.223" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9709" PostTypeId="2" ParentId="9706" CreationDate="2023-01-08T20:15:44.057" Score="3" Body="&lt;p&gt;An Eulerian cycle crosses every edge exactly once (&lt;a href=&quot;https://en.wikipedia.org/wiki/Eulerian_path&quot; rel=&quot;nofollow noreferrer&quot;&gt;see Wikipedia entry&lt;/a&gt;). So in your formulation, which appears to assume a directed graph, for any &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in E$&lt;/span&gt; you would need to allow &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; to be either 0 or 1, and add the constraint that &lt;span class=&quot;math-container&quot;&gt;$$x_{ij} + x_{ji} = 1 \quad \forall i\neq j.$$&lt;/span&gt; I am assuming that the graph is symmetric (&lt;span class=&quot;math-container&quot;&gt;$(i,j)\in E \implies (j,i) \in E$&lt;/span&gt;) and contains no self-loops (no &lt;span class=&quot;math-container&quot;&gt;$(i,i)\in E$&lt;/span&gt;). If the graph is asymmetric, you can set &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1$&lt;/span&gt; whenever &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in E$&lt;/span&gt; but &lt;span class=&quot;math-container&quot;&gt;$(j,i)\notin E$&lt;/span&gt;. If there are self-loops, &lt;span class=&quot;math-container&quot;&gt;$(i,i)\in E \implies x_{i,i} = 1.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Just to clarify, this is only a partial answer. You still have to add a sequencing component (in what order are the edges traversed) and rule out &amp;quot;subpaths&amp;quot; (compositions of disjoint paths, with cycles that do not include the starting/ending node).&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-01-09T16:23:14.223" LastActivityDate="2023-01-09T16:23:14.223" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9710" PostTypeId="2" ParentId="9706" CreationDate="2023-01-08T21:21:59.677" Score="4" Body="&lt;p&gt;If OP wants an Eulerian cycle, then refer to @prubin's answer. If the graph is not eulerian, then the problem will be infeasible. If the graph is eulerian, then the solution to the problem will give you the direction of each edge in the eulerian circuit. Note that you don't have to go through integer programming to know if the graph is eulerian or not, you can just check if vertices have even degree.&lt;/p&gt;&#xA;&lt;p&gt;Assuming OP accepts cycles with duplicated edges (in this case we are dealing with the &lt;em&gt;route inspection problem&lt;/em&gt;), then replace constraints (2) with:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{ij}+x_{ji}\ge 1 \quad \forall i\neq j&#xA;$$&lt;/span&gt;&#xA;which enforce that edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; must be used at least once, in any direction (possibly in both).&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2023-01-08T21:21:59.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9711" PostTypeId="2" ParentId="9706" CreationDate="2023-01-08T21:26:58.117" Score="1" Body="&lt;p&gt;In Eulerian circuit, you've to take in all edges, atleast and atmost once. Here cost may be associated with the vertex, as all edges will be included. So cost minimization will depend upon how many times the nodes/vertices are visited/not visited.&#xA;So for node &lt;span class=&quot;math-container&quot;&gt;$v \in\ V$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$S_v \in\ Z^+$&lt;/span&gt;&lt;br /&gt;&#xA;Test for Eulerian cycle first: degrees of all vertices should be even i.e. &lt;span class=&quot;math-container&quot;&gt;$\sum_{v \in\ V} E_{u,v} \mod 2 =0 \ \ \forall u \in\ V$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Parameters:&lt;br /&gt;&#xA;If directed,&#xA;&lt;span class=&quot;math-container&quot;&gt;$Deg_v = \sum_{(u,v)} (E_{u,v}+ E_{v,u})$&lt;/span&gt;:&lt;br /&gt;&#xA;Otherwise: &lt;span class=&quot;math-container&quot;&gt;$Deg_v = \sum_{(u,v)} E_{v,u}$&lt;/span&gt;:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$(u,v) \in\ $&lt;/span&gt; Edges&lt;/p&gt;&#xA;&lt;p&gt;Min &lt;span class=&quot;math-container&quot;&gt;$\sum_v Cost_v S_v $&lt;/span&gt;&lt;br /&gt;&#xA;s.t.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$1 \le S_v \le Deg_v$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$S_v + \sum_{u\in\ E} S_u \le Deg_v+\sum_{u\in\ E} Deg_u - \sum E_{u,v} \ \ \forall v \in\ $&lt;/span&gt;V and E&lt;span class=&quot;math-container&quot;&gt;$=E_{u,v}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-09T01:39:17.993" LastActivityDate="2023-01-09T01:39:17.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9712" PostTypeId="2" ParentId="9701" CreationDate="2023-01-09T06:47:05.217" Score="3" Body="&lt;p&gt;Given a certain master problem solution, when the subproblem is infeasible, a &lt;strong&gt;feasibility cut&lt;/strong&gt; is added to the master problem. On the other hand, an &lt;strong&gt;optimality cut&lt;/strong&gt; is added to the master problem when the subproblem is feasible, but its objective implies the trial master problem solution is not globally optimal. Both cuts remove the current master problem solution from being searched in future iterations.&lt;/p&gt;&#xA;&lt;p&gt;As demonstrated by [1]:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;(The L-shaped method) is essentially the same as the algorithm developed by Benders [2].&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Therefore, besides papers about the L-shaped method, papers about &lt;strong&gt;Benders Decomposition&lt;/strong&gt; also help with understanding these two types of cuts.&lt;/p&gt;&#xA;&lt;p&gt;Finally, I would like to recommend the literature review paper [3], which I feel is easier for understanding the Benders decomposition than [1] and [2].&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;[1] Van Slyke, R. M., &amp;amp; Wets, R. (1969). L-shaped linear programs with applications to optimal control and stochastic programming. SIAM&#xA;Journal on Applied Mathematics, 17(4), 638–663.&#xA;&lt;a href=&quot;https://doi.org/10.1137/0117061&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1137/0117061&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;[2] Benders, J. F. (1962). Partitioning procedures for solving mixed-variables programming problems. Numerische Mathematik, 4(1),&#xA;238–252. &lt;a href=&quot;https://doi.org/10.1007/BF01386316&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1007/BF01386316&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;[3] Rahmaniani, R., Crainic, T. G., Gendreau, M., &amp;amp; Rei, W. (2017). The Benders decomposition algorithm: A literature review. European&#xA;Journal of Operational Research, 259(3), 801–817.&#xA;&lt;a href=&quot;https://doi.org/10.1016/j.ejor.2016.12.005&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.ejor.2016.12.005&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2023-01-09T06:47:05.217" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9713" PostTypeId="2" ParentId="9702" CreationDate="2023-01-09T07:26:47.090" Score="1" Body="&lt;p&gt;I assume you want to analyze the service time w.r.t one robot grabs and drops the parts and moves between the stations. By knowing the service time for each part is &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and we need to box precisely &lt;span class=&quot;math-container&quot;&gt;$\text{b}$&lt;/span&gt; units, the average waiting time for the robot is &lt;span class=&quot;math-container&quot;&gt;$(\text{AWT}_r = \lambda*b)$&lt;/span&gt;. As long as this time has been greater than the transfer time between the stations, the service time of the robot is &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, and as @Sutanu pointed out &lt;em&gt;The t for return will be part of the average wait time for the queue&lt;/em&gt;. In the following, this is depicted as an example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OO1ZA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OO1ZA.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The service time for Assy_line was set around &lt;span class=&quot;math-container&quot;&gt;$20$&lt;/span&gt; parts per hour, while the transfer time between the stations was assumed to be &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; minute. The number of parts in the bin should be exactly &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; to move by a robot. The robot needs to wait to fill the box and its service time is &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. If robots work simultaneously to transfer the parts between the stations, the service time depends on the number of robots and the average number of parts waiting to box.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-01-09T07:26:47.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9714" PostTypeId="2" ParentId="9704" CreationDate="2023-01-09T13:53:07.863" Score="1" Body="&lt;p&gt;I had been doing some freelance jobs through platforms like &lt;a href=&quot;https://www.upwork.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Upwork&lt;/a&gt; and &lt;a href=&quot;https://www.guru.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Guru&lt;/a&gt;, but there are not so many job postings about OR (and, in several ones, hourly rates are not so high, too). Most of the jobs are disguised in machine learning or data science job postings. And also, they are usually not pure OR jobs, but small apps or libraries that solve an OR-related problem (ie, usually not AMPL-related jobs, for example).&lt;/p&gt;&#xA;&lt;p&gt;So, if you want to monetize OR as a freelance, learn how to code and develop small apps. And learn something about machine learning and data science too.&lt;/p&gt;&#xA;&lt;p&gt;Said that, I totally agree with @fontanf comment. You have to build a strong network, so use these sites in order to build that and get some experience. They could also be an entry point for bigger projects.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2023-01-09T13:53:07.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9715" PostTypeId="2" ParentId="9704" CreationDate="2023-01-09T14:27:36.643" Score="5" Body="&lt;p&gt;&lt;strong&gt;For me, the three necessary ingredients to get (O.R.) consulting work usually are&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The potential client has to&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Know me&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Like me (personally, as well as being confident I will do a good job)&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Have money (which they are authorized to spend on a consultant)&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;It's not so easy to find all three together.&lt;/p&gt;&#xA;&lt;p&gt;There are many people who know me. Of those who know me, a significant portion (but much less than 100%, ha ha) like me.&lt;/p&gt;&#xA;&lt;p&gt;At any given time, of those who know me and like me, only a very small portion have money (which they are authorized to spend on a consultant). However, &amp;quot;having money&amp;quot; is a stochastic process, so some who know me and like me, but don't have money now, may have money later.&lt;/p&gt;&#xA;&lt;p&gt;There are some who know me and have money, but don't like me. Usually, it's not easy to convert someone who dislikes you to like you. But it can happen, especially if the reason for their dislike was not based on first hand knowledge, so their dislike may not be very strong or immutable.&lt;/p&gt;&#xA;&lt;p&gt;Of course, when you do get work, you better deliver the goods, or the liking will very soon turn into strong disliking. I am not a practitioner of &amp;quot;fake it til you make it&amp;quot;. Some people are. I turn down potential gigs which I don't think will work out well, and which would leave the client dissatisfied. Better to disappoint them by not taking the gig, than to take the gig and disappoint them with unsatisfactory outcome.&lt;/p&gt;&#xA;&lt;p&gt;However, I am open to expanding my horizons. If I do some unpaid looking into/figuring out things before agreeing to a new gig for which I didn't have all the needed skills, and convince myself I can do it, I will take the gig. I do not consider that to be faking it til I make it, because I will have already made it before taking it, so there's no faking it.&lt;/p&gt;&#xA;&lt;p&gt;It is easy to start a business/become a consultant. Getting (profitable) revenue is the hard part. There are quite a few people on LinkedIn with impressive resumes, who after retiring or being downsized from a company, become consultants, sometimes with an impressive sounding company name. Their LinkedIn consulting entry has several lines of very impressive sounding capabilities and the kind of (often high level executive) clients they serve, often written in an active voice, as though they have actually done these things for these clients. In many cases, after one or two years, they have yet to get any paying clients.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-01-09T16:01:47.940" LastActivityDate="2023-01-09T16:01:47.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9716" PostTypeId="2" ParentId="9704" CreationDate="2023-01-09T14:34:51.017" Score="1" Body="&lt;p&gt;Concur with above replies and comments.&lt;br /&gt;&#xA;Also, in the industry OR apps are pretty complex. The number of constraints will be mind-boggling and often difficult to formulate if you don't have some domain knowledge. That's why in the industry OR is implemented by a team. That also explains why some ML/DS projects keep failing if domain experts are not working together.&lt;br /&gt;&#xA;Also freelancing sites like taproot may offer some interesting projects but there could be others who may seek help because they are stuck in a part of their project. Apart from communications, suddenly being pulled into middle of a project you may not get the head and tail of it. It happens on this stackexchange site sometimes. Users will post either from a book or paper or part of industry work with some unclear concept or error in print and then you have to wonder.&lt;/p&gt;&#xA;&lt;p&gt;Still regularly visit or.stackexchange or equivalent stats and math site. While stats and math sites will be purely PhD level stuff, OR subsite does have content that clarifies concepts. These may be handy in the industry or during interviews.&lt;/p&gt;&#xA;&lt;p&gt;Disclaimer: I do myself browse Taproot and Upwork myself and agree getting an OR project is difficult. Most are ML/DS ones with may be a new optimization trick.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-09T14:42:58.477" LastActivityDate="2023-01-09T14:42:58.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9717" PostTypeId="2" ParentId="9677" CreationDate="2023-01-09T16:48:07.417" Score="1" Body="&lt;p&gt;Code with Sample data:\&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;from gurobipy import *&#xA;import numpy as np&#xA;from scipy.spatial.distance import pdist&#xA;from collections import namedtuple&#xA;from scipy.spatial import distance_matrix as dm&#xA;&#xA;N =15 #Sites&amp;quot; Towers&#xA;R = 86&#xA;#Generate Data&#xA;Points = namedtuple('Points', 'x, y')&#xA;def gen_data(Points,N):&#xA;  locations = []&#xA;  for p in range(N):&#xA;    x,y = np.random.uniform(1,10,size = 2)&#xA;    points = Points(x,y)&#xA;    if points.x**2 + points.y**2 &amp;lt;= R**2:&#xA;      locations.append(points)&#xA;  return np.array([[p.x,p.y] for p in locations],dtype='float16')&#xA;  #return sites&#xA;#print(sites)&#xA;#Generate sites&#xA;sites = gen_data(Points,N)&#xA;&#xA;towers = gen_data(Points,7)&#xA;#print(towers)&#xA;&#xA;N,_ = sites.shape&#xA;I = [*range(N)]&#xA;T,_ = towers.shape&#xA;J = [*range(T)]&#xA;K = 5&#xA;maxpoints = 13 #per tower circle&#xA;minpoints = 2 #per tower circle&#xA;#Generate distance D(i,j)&#xA;D = dm(sites,towers).astype('float16')&#xA;print(D)&#xA;#Masking&#xA;mask = (D &amp;lt; 7)&#xA;D[mask] = 1; D[~mask]=0&#xA;&#xA;model = Model('fac')&#xA;&#xA;x = model.addVars(J,vtype='b',name='x')&#xA;y = model.addVars(I,vtype='b',name='y')&#xA;&#xA;C1 = model.addConstr(x.sum() == K,'C1')&#xA;C2 = model.addConstrs((minpoints*x[j] &amp;lt;= quicksum(y[i] for i in np.where(D[:,j]==1)[0])\&#xA;                      for j in J),'C2')&#xA;&#xA;#C3 = model.addConstrs((quicksum(x[j] for j in np.where(D[i,:]==1)[0])&amp;lt;= K*(1-y[i])+y[i]\&#xA; #                     for i in I),'NonOverlapping')&#xA;&#xA;                  for j in J),'C2')&#xA;C5 = model.addConstrs((maxpoints &amp;gt;= quicksum(y[i] for i in np.where(D[:,j]==1)[0])\&#xA;                      for j in J),'C2')    &#xA;C4 = model.addConstrs((y[i] == 1 for i in np.where(np.sum(D,axis=1)&amp;gt;=1)[0]),'C4')&#xA;obj = y.sum()&#xA;model.setObjective(obj,GRB.MAXIMIZE)&#xA;model.update()&#xA;model.optimize()&#xA;model.printAttr('x')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-09T20:01:42.360" LastActivityDate="2023-01-09T20:01:42.360" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9718" PostTypeId="2" ParentId="9707" CreationDate="2023-01-09T18:19:46.240" Score="5" Body="&lt;p&gt;Here's a linearization that you might find useful.  Suppose integer variable &lt;span class=&quot;math-container&quot;&gt;$x\in\{0,\dots,M\}$&lt;/span&gt;.  Then you can enforce &lt;span class=&quot;math-container&quot;&gt;$y = \binom{x}{2}$&lt;/span&gt; by introducing binary variables &lt;span class=&quot;math-container&quot;&gt;$z_j$&lt;/span&gt; and linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{j=0}^M z_j &amp;amp;= 1 \\&#xA;\sum_{j=0}^M j z_j &amp;amp;= x \\&#xA;\sum_{j=0}^M \binom{j}{2} z_j &amp;amp;= y \\&#xA;\end{align}&lt;/span&gt;&#xA;More generally, you can enforce any functional relationship &lt;span class=&quot;math-container&quot;&gt;$y=f(x)$&lt;/span&gt; by replacing &lt;span class=&quot;math-container&quot;&gt;$\binom{j}{2}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$f(j)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-01-10T22:03:59.773" LastActivityDate="2023-01-10T22:03:59.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9719" PostTypeId="1" CreationDate="2023-01-09T21:46:09.893" Score="0" ViewCount="75" Body="&lt;p&gt;I have programmed the primal-dual simplex method as explained &lt;a href=&quot;http://www.4er.org/CourseNotes/Book%20B/B-III.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The method requires the information to be passed in the standard form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;min:\quad c^\top \cdot x\\&#xA;s.t.:\\&#xA;A·x = b\\&#xA;x \geq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, most solvers offer an interface to pass the data in the following format, which is quite generic and convenient:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;min:\quad c^\top \cdot x\\&#xA;s.t.:\\&#xA;Ub \leq A·x \leq Ub\\&#xA;lb \leq x \leq ub&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;How can I convert this format to the standard form accepted by the interior point method?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="11056" LastEditorUserId="11056" LastEditDate="2023-01-10T07:34:55.820" LastActivityDate="2023-01-10T07:34:55.820" Title="Transform any linear program to its standard form used in interior point solvers" Tags="|linear-programming|interior-point-method|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9720" PostTypeId="1" CreationDate="2023-01-10T14:46:55.850" Score="3" ViewCount="162" Body="&lt;p&gt;We’re [1] in the thick of building out a testing suite for decision models, starting with a focus on route optimization. There are several angles we care about [2] and are considering: unit testing, scenario testing, historical testing, shadow testing, switchback testing, acceptance testing, and benchmarking.&lt;/p&gt;&#xA;&lt;p&gt;I’ve seen some discussions here about different aspects of testing [3, 4]. My general impression: cohesive testing still has a ways to go, but it adds value if you can find the time to set it up and maintain it (after all that other work you did you simply build and deploy your model — DoorDash has written about this well [5]).&lt;/p&gt;&#xA;&lt;p&gt;I’m curious to know: What do you like or dislike about the testing frameworks/tooling available today? What testing capabilities do you wish you could have?&lt;/p&gt;&#xA;&lt;p&gt;[1] We’re a decision optimization company called Nextmv (&lt;a href=&quot;https://www.nextmv.io&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.nextmv.io&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;[2] &lt;a href=&quot;https://www.nextmv.io/videos/tools-for-benchmarking-and-testing-in-the-optimization-space&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.nextmv.io/videos/tools-for-benchmarking-and-testing-in-the-optimization-space&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[3] &lt;a href=&quot;https://or.stackexchange.com/questions/5216/how-to-generate-data-for-test&quot;&gt;How to generate data for test?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[4] &lt;a href=&quot;https://or.stackexchange.com/questions/6600/what-are-technologies-or-libraries-which-greatly-improve-the-speed-or-ease-of-us&quot;&gt;What are technologies or libraries which greatly improve the speed or ease of use for delivering of OR software?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[5] &lt;a href=&quot;https://medium.com/@DoorDash/switchback-tests-and-randomized-experimentation-under-network-effects-at-doordash-f1d938ab7c2a&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://medium.com/@DoorDash/switchback-tests-and-randomized-experimentation-under-network-effects-at-doordash-f1d938ab7c2a&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10683" LastActivityDate="2023-01-10T23:14:49.713" Title="Optimization model testing tooling: likes, dislikes, and wishes" Tags="|optimization|modeling|benchmark|test-instances|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9721" PostTypeId="1" CreationDate="2023-01-10T17:07:34.417" Score="1" ViewCount="78" Body="&lt;p&gt;How does one linearize the following constaints:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_1 \geq 4$&lt;/span&gt; then &lt;strong&gt;one&lt;/strong&gt; out of the following three constraints must hold: &lt;span class=&quot;math-container&quot;&gt;$x_2 \leq 3, x_3 \leq 4, x_4=5$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_1 \leq 4 + Mz_1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_2 \leq 3 + M(1-z_2) + M(1-z_1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_3 \leq 4 + M(1-z_3) + M(1-z_1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_4 \leq 5 + M(1-z_4) + M(1-z_1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_4  + M(1-z_4) + M(1-z_1) \geq 5$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_2 + z_3 + z_4 = 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_i \text{ binary, }M\text{ large} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is this correct?&lt;/p&gt;&#xA;" OwnerUserId="11063" LastEditorUserId="67" LastEditDate="2023-01-10T17:22:26.923" LastActivityDate="2023-01-10T18:19:54.380" Title="If $x_1 \geq 4$ then **one** out of the following three constraints must hold: $x_2 \leq 3, x_3 \leq 4, x_4=5$" Tags="|linear-programming|constraint-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9722" PostTypeId="2" ParentId="9721" CreationDate="2023-01-10T17:21:20.317" Score="1" Body="&lt;p&gt;Assuming that (a) you are OK with some ambiguity when &lt;span class=&quot;math-container&quot;&gt;$x_1=4$&lt;/span&gt; (in which case &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; can be either 0 or 1) and (b) you want at least one rather than exactly one of the three constraints to hold (nothing in your formulation prevents all three from being satisfied), then this is correct. It would also be correct to change the last constraint to &lt;span class=&quot;math-container&quot;&gt;$$z_2+z_3+z_4=z_1.$$&lt;/span&gt; I don't know if that would help solver performance or not.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-01-10T17:21:20.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9723" PostTypeId="2" ParentId="9721" CreationDate="2023-01-10T18:19:54.380" Score="-1" Body="&lt;p&gt;Trying to be creative, what about:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_1 - 4 \le M(12- x_2-x_3-x_4)$&lt;/span&gt; and&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_2+x_3 \le 7 $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-01-10T18:19:54.380" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9724" PostTypeId="2" ParentId="9720" CreationDate="2023-01-10T22:48:05.680" Score="-2" Body="&lt;p&gt;By testing of decision models I am assuming you are testing if the model has high fidelity to the mathematical formulation, sense of constraints and other properties and attributes associated with the objective and candidate solutions at the nodes.&#xA;Mathematical formulation can be tested using MPS file, constraint sense and other attributes can be tested by querying different attributes and properties. These should be available on the reference manual just as &lt;a href=&quot;https://www.gurobi.com/documentation/10.0/refman/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;gurobi&lt;/a&gt;'s.&lt;br /&gt;&#xA;You can also perform benchmark tests on solver performance by comparing with other solvers.&#xA;Algorithm tests may be done with as a unit test by inputting data sets that give known optimal, feasible, sub-optimal, infeasible/unbounded results with set tolerance and optimality gaps.&lt;br /&gt;&#xA;An important part of testing for solver is if the solver is able to identify and set the appropriate code based on solution status like optimal, infeasible, unbounded etc.&lt;br /&gt;&#xA;Finally what I'd call stress tests- testing the model with both small scale and large scale datasets.&lt;/p&gt;&#xA;&lt;p&gt;Finally while not exactly on testing strategies Gurobi did organize a talk on &lt;a href=&quot;https://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;url=https://www.gurobi.com/events/webinar-holiday-tech-talk/&amp;amp;ved=2ahUKEwiS8uihkL78AhWpkIkEHZkGAJwQtwJ6BAgTEAE&amp;amp;usg=AOvVaw29qZxXai5lT1zGRsO2kE79&quot; rel=&quot;nofollow noreferrer&quot;&gt;grinch&lt;/a&gt; that can ruin your model. This may give you some insights on designing/sampling your test cases.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-10T23:14:49.713" LastActivityDate="2023-01-10T23:14:49.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9725" PostTypeId="1" CreationDate="2023-01-11T06:21:27.723" Score="2" ViewCount="315" Body="&lt;p&gt;&lt;a href=&quot;https://cw.fel.cvut.cz/b192/_media/courses/ko/ilp_rubik.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cw.fel.cvut.cz/b192/_media/courses/ko/ilp_rubik.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In pages 5-6 this example solves a cube with Gurobi. I don't have Gurobi but I'd like to get .lp or .mps version for my own testing?&lt;/p&gt;&#xA;" OwnerUserId="9050" LastActivityDate="2023-01-11T16:34:00.857" Title="How can I extract the .lp or .mps version of this (Rubik's cube example)" Tags="|mixed-integer-programming|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9726" PostTypeId="2" ParentId="9725" CreationDate="2023-01-11T08:14:54.430" Score="3" Body="&lt;p&gt;One possible way to use Gurobi is by invoking its library on &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/4409582394769-Google-Colab-Installation-and-Licensing&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google Colab&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Google Colab provides an easy way to use Gurobi with Python + Jupyter&#xA;notebooks, with no local software installation required. The Gurobi&#xA;solver can be used in Colab notebooks either with the free&#xA;size-limited trial license that is installed by default or with a Web&#xA;License Service (WLS) license which enables the full features of&#xA;Gurobi.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Also, as far as I know, Gurobi offers a &lt;a href=&quot;https://www.gurobi.com/academia/for-online-courses/&quot; rel=&quot;nofollow noreferrer&quot;&gt;community license&lt;/a&gt; to run the optimization problems, but with a limited size of the variables or constraints.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-01-11T08:14:54.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9728" PostTypeId="2" ParentId="9725" CreationDate="2023-01-11T12:17:03.087" Score="4" Body="&lt;p&gt;You can always use &lt;a href=&quot;https://colab.research.google.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google colab&lt;/a&gt; as Omidi has indicated that will have some limitation on capacity. Exporting to different format is through &lt;code&gt;model.write()&lt;/code&gt; function as explained &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360032742051-How-do-I-export-a-model-from-Gurobi-&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and refer &lt;a href=&quot;https://www.gurobi.com/documentation/10.0/refman/py_model_write.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-11T15:54:45.583" LastActivityDate="2023-01-11T15:54:45.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9729" PostTypeId="1" CreationDate="2023-01-11T12:30:04.700" Score="2" ViewCount="98" Body="&lt;p&gt;I am trying to maximize expected revenue over a horizon.&lt;/p&gt;&#xA;&lt;p&gt;Consider the following function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;sales(budget_1, budget_2) = \sum_te^{C_1t} * budget_1t^{saturation_1t} + e^{C_2t} * budget_2t^{saturation_2t} \\ &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; denotes the timestep and &lt;span class=&quot;math-container&quot;&gt;$0 \le (saturation_1t, saturation_2t) \le 1$&lt;/span&gt; thus exhibiting diminishing marginal returns and &lt;span class=&quot;math-container&quot;&gt;$C_1t, C_2t$&lt;/span&gt; acts as our exponents for the coefficients.&lt;/p&gt;&#xA;&lt;p&gt;Now consider a budget ceiling of &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My aim is to reach a target ROI (return on investment) while maximizing the budget, thus giving a target &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_{budget_1, budget_2} \sum_tbudget_1t + budget_2t&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to the constraints:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\frac{\sum_te^{C_1} * budget_1^{saturation_1} + e^{C_2} * budget_2^{saturation_2}}{\sum_tbudget_1t + budget_2t} &amp;amp; \ge T \\\\&#xA;\sum_tbudget_1t + budget_2t &amp;amp; \le B&#xA;\end{align}&lt;/span&gt;&#xA;Is this a bad way of formulating it and if so/not so what would be an appropriate solver for such a problem?&lt;/p&gt;&#xA;&lt;p&gt;I assume that the constraint may introduce some concavity.&lt;/p&gt;&#xA;" OwnerUserId="11067" LastEditorUserId="36" LastEditDate="2023-01-11T13:35:21.067" LastActivityDate="2023-01-11T19:51:17.983" Title="Formulate revenue maximization problem and find an appropriate solver" Tags="|optimization|constraint|nonlinear-programming|convex-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9730" PostTypeId="2" ParentId="9729" CreationDate="2023-01-11T13:50:59.637" Score="1" Body="&lt;p&gt;Assuming C1,C2 are constants, just rearrange your first constraint as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_t(e^{C_1} * budget_1^{saturation_1} + e^{C_2} * budget_2^{saturation_2}) \ge T\sum_t t(budget_1 + budget_2)$&lt;/span&gt;\&lt;/p&gt;&#xA;&lt;p&gt;Appropriate solver will be Gurobi, CPLEX to name a few. You can import them on Google Colab or use &lt;a href=&quot;https://neos-server.org/neos/&quot; rel=&quot;nofollow noreferrer&quot;&gt;NEOS&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-11T19:51:17.983" LastActivityDate="2023-01-11T19:51:17.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9732" PostTypeId="2" ParentId="9725" CreationDate="2023-01-11T16:34:00.857" Score="1" Body="&lt;p&gt;I answer this&lt;/p&gt;&#xA;&lt;p&gt;I Installed gurobipy and pycuber with pip.&#xA;I copied the python code to file.py&#xA;I replaced the last line&lt;/p&gt;&#xA;&lt;p&gt;m.optimize()&lt;/p&gt;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&lt;p&gt;m.write('model.lp')&lt;/p&gt;&#xA;&lt;p&gt;m.write('model.mps')&lt;/p&gt;&#xA;&lt;p&gt;Cbc cannot read those files but Scip can read .mps file.&lt;/p&gt;&#xA;&lt;p&gt;Scip can read the exported .lp file after I deleted all [ and ] characters from the .lp file.&lt;/p&gt;&#xA;&lt;p&gt;Done.&lt;/p&gt;&#xA;" OwnerUserId="9050" LastActivityDate="2023-01-11T16:34:00.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9734" PostTypeId="1" CreationDate="2023-01-12T14:12:52.447" Score="3" ViewCount="148" Body="&lt;p&gt;I'm coding in Julia, how can I do the same as &amp;quot;Remove(Cplex.Callback)&amp;quot; function does in C++ ?&lt;/p&gt;&#xA;" OwnerUserId="5681" LastActivityDate="2023-01-13T19:18:26.527" Title="How to remove a callback that was previously registered in Julia?" Tags="|mixed-integer-programming|cplex|julia|jump|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9735" PostTypeId="1" AcceptedAnswerId="9739" CreationDate="2023-01-12T18:50:43.610" Score="2" ViewCount="170" Body="&lt;p&gt;I have a piecewise constraint that I am having a hard time converting using big-M modelling. The context is a gym owner that is updating membership costs subject to churn restrictions. The owner can increase or decrease the prices which will have an effect on the churn probability of a customer, &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. However, if the change in price is small enough, there is no churn. The function looks like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ch_n$&lt;/span&gt; =&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases} &#xA;      0, &amp;amp; |p^*_n - p_n|\leq \epsilon \\&#xA;      m_n(p^*_n - p_n), &amp;amp;  p^*_n - p_n &amp;gt; \epsilon&#xA;   \end{cases}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$ch_n$&lt;/span&gt; is the churn probability of customer n. This is zero is the price increase is less than some threshold epsilon (&lt;span class=&quot;math-container&quot;&gt;$p^*_n$&lt;/span&gt; is the new price and the decision variable. &lt;span class=&quot;math-container&quot;&gt;$p_n$&lt;/span&gt; is the old price). If the change is greater than epsilon, the churn probability is a linear function of the price change (so &lt;span class=&quot;math-container&quot;&gt;$m_n$&lt;/span&gt; is known for each customer).&lt;/p&gt;&#xA;&lt;p&gt;The difficulty I am having the the presence of the absolute values in the constraint definition.&lt;/p&gt;&#xA;" OwnerUserId="11074" LastEditorUserId="491" LastEditDate="2023-01-19T12:52:19.743" LastActivityDate="2023-01-19T12:52:19.743" Title="Piecewise constraint using big-M notation" Tags="|linear-programming|constraint|logical-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9736" PostTypeId="2" ParentId="9734" CreationDate="2023-01-12T18:57:08.043" Score="3" Body="&lt;p&gt;Currently there is no support for removing a callback from a model in JuMP. Your options are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Rebuild the model&lt;/li&gt;&#xA;&lt;li&gt;Set a new callback that does nothing&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://discourse.julialang.org/c/domain/opt/13&quot; rel=&quot;nofollow noreferrer&quot;&gt;Julia discourse forum&lt;/a&gt; is another platform you can browse on questions related to JuMP.&lt;/p&gt;&#xA;" OwnerUserId="804" LastEditorUserId="123" LastEditDate="2023-01-13T19:18:26.527" LastActivityDate="2023-01-13T19:18:26.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9737" PostTypeId="1" AcceptedAnswerId="9738" CreationDate="2023-01-12T20:31:48.940" Score="1" ViewCount="143" Body="&lt;p&gt;I have a system with &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; machine and &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; users.&#xA;The decision variables are &lt;span class=&quot;math-container&quot;&gt;$d_{u,c}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;${\bf f}_{u,c}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$c=1,2,\cdots,C$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u=1,2,\cdots,U$&lt;/span&gt;, where&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$d_{u,c}\in\{0,1\}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$${\bf f}_{u,c}\in\mathbb{C}^{N\times 1}\hspace{3mm}\text{(a vector of }N\text{ complex elements)}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I want to put a constraint like this:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$d_{u,c}=0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$||{\bf f}_{u,c}||^2=0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$d_{u,c}=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;||{\bf f}_{u,c}||^2\le T$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$||\cdot||$&lt;/span&gt; is Euclidean norm and &lt;span class=&quot;math-container&quot;&gt;$T&amp;gt;0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How to model this constraints mathematically?&lt;/p&gt;&#xA;" OwnerUserId="836" LastActivityDate="2023-01-12T20:51:16.227" Title="How to model this constraint?" Tags="|mixed-integer-programming|modeling|combinatorial-optimization|" AnswerCount="1" CommentCount="0" ClosedDate="2023-01-13T15:34:56.253" ContentLicense="CC BY-SA 4.0" />
  <row Id="9738" PostTypeId="2" ParentId="9737" CreationDate="2023-01-12T20:39:40.367" Score="4" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_{u,c}\sigma  \le ||{\bf f}_{u,c}||^2\le Td_{u,c}$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; is a very small number based on scale of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-12T20:51:16.227" LastActivityDate="2023-01-12T20:51:16.227" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9739" PostTypeId="2" ParentId="9735" CreationDate="2023-01-12T20:46:32.307" Score="3" Body="&lt;p&gt;While the clarification sought by Prof Paul is relevant here generally how abs is handled:&lt;br /&gt;&#xA;Define &lt;span class=&quot;math-container&quot;&gt;$z \in R^n$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$p_n^* - p_n \le z_n $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$p_n - p_n* \le z_n $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_n-(ϵ+\sigma) \le Mx_n $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ϵ - z_n \le M(1-x_n)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$m_nz_n + M(x_n-1) \le ch_n \le m_nz_n + M(1-x_n) $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$0 \le ch_n \le x_n $&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\ \ \forall n $&lt;/span&gt;&lt;br /&gt;&#xA;In the above two constraints M can be replaced by 1.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x \in \{0,1\}^n $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; is a small number say like 0.001 depending upon scale of &lt;span class=&quot;math-container&quot;&gt;$ϵ $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-13T01:30:08.237" LastActivityDate="2023-01-13T01:30:08.237" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9740" PostTypeId="1" AcceptedAnswerId="9741" CreationDate="2023-01-13T16:22:31.743" Score="4" ViewCount="559" Body="&lt;p&gt;Suppose I have a set of employee &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; and set of jobs &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; in a given time horizon &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;. I would like to make sure that no employee works on multiple jobs where each job &lt;span class=&quot;math-container&quot;&gt;$e\in E$&lt;/span&gt; takes a certain amount of time presented as &lt;span class=&quot;math-container&quot;&gt;$\delta_e$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$X_{ejt}$&lt;/span&gt; be a binary variables stating if employee &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; starts working on job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Then, I can write;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ M(X_{ejt}-1) \geq \sum_{i \in J \setminus \{ j\}} \sum_{t^* : t \leq t^*  &amp;lt; t + \delta_j}  X_{eit^*}, \quad \forall e \in E, j \in J, t \in T$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the constraint ensures that employee &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; cannot work on another job until their current job is completed.&lt;/p&gt;&#xA;&lt;p&gt;My question is that if there is a better way to accomplish this with a more effective constraint without leaning on a big-M constraint. When I say efficient, I mean it should work better during the B&lt;span class=&quot;math-container&quot;&gt;$\&amp;amp;$&lt;/span&gt;B process.&lt;/p&gt;&#xA;" OwnerUserId="3567" LastEditorUserId="3567" LastEditDate="2023-01-13T16:56:51.740" LastActivityDate="2023-01-14T20:30:07.423" Title="Alternative way to restrict an employee to work on multiple jobs" Tags="|optimization|linear-programming|combinatorial-optimization|scheduling|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9741" PostTypeId="2" ParentId="9740" CreationDate="2023-01-13T17:05:51.707" Score="5" Body="&lt;p&gt;Works better is an empirical question. Only experimentation will tell.&lt;/p&gt;&#xA;&lt;p&gt;First, note that your &amp;quot;big M&amp;quot; may in fact not be all that big. &lt;span class=&quot;math-container&quot;&gt;$M=\vert J \vert-1$&lt;/span&gt; is sufficiently large to do the job.&lt;/p&gt;&#xA;&lt;p&gt;That said, one way to avoid &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; involves adding new variables &lt;span class=&quot;math-container&quot;&gt;$Y_{ejt}\ge 0$&lt;/span&gt; and more constraints. It makes the model larger (generally not desirable) but may or may not make the bounds tighter. The additional constraints are &lt;span class=&quot;math-container&quot;&gt;$$Y_{ejt} \ge \sum_{\tau=t-\delta_j + 1}^t X_{ej\tau}\quad \forall e,j,t$$&lt;/span&gt; (with suitable adjustments to the lower limit of summation to skip negative times) and &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j\in J}Y_{ejt} \le 1\quad \forall e,t.$$&lt;/span&gt; The first new constraint forces &lt;span class=&quot;math-container&quot;&gt;$Y_{ejt} \ge 1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; starts &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; before time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; but close enough that &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; would still be in progress at time &lt;span class=&quot;math-container&quot;&gt;$t.$&lt;/span&gt; In other words, you will get &lt;span class=&quot;math-container&quot;&gt;$Y_{ejt}=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; is doing &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at &lt;span class=&quot;math-container&quot;&gt;$t.$&lt;/span&gt; The second constraint says that any employee at any time can be doing at most one job.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-01-13T17:05:51.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9742" PostTypeId="2" ParentId="9740" CreationDate="2023-01-13T17:08:51.503" Score="0" Body="&lt;p&gt;Choose M as an upper bound, &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; of number jobs an employee &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; can be assigned over time horizon &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;, then&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in \{J-j\}}\sum_{t\le t^* \le t+\delta_j}x_{e,j,t^*} \le U(1-x_{e,j,t}) \ \ \forall e \in E \ \ \forall j \in J$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you want to avoid use of U or M then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_j x_{e,j,t} \le 1 \ \ \forall t \ \ \forall e $&lt;/span&gt; (1)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\delta_j x_{e,j,t} \le \sum_{\tau = t}^{t+\delta_j-1}(x_{e,j,\tau}) + C \le \delta_j \ \ \forall C \in \{0,1,...\delta_j-1 \} \ \ \forall t \ \ \forall e \ \ \forall j$&lt;/span&gt; (2)&lt;/p&gt;&#xA;&lt;p&gt;OR: Alternate to cons (2)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\delta_jx_{e,j,t-1} - \sum_{k=1}^{t-1} x_{e,j,k} \le \delta_j x_{e,j,t} $&lt;/span&gt; (3)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{k=1}^{t-1}x_{e,j,k} - \delta_jx_{e,j,t-1} \le \delta_j (1-x_{e,j,t}) $&lt;/span&gt; (4)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall t \in \{2,...T\} \ \ \forall j \ \ \forall e $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="67" LastEditDate="2023-01-14T20:30:07.423" LastActivityDate="2023-01-14T20:30:07.423" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9743" PostTypeId="1" CreationDate="2023-01-14T16:49:46.550" Score="1" ViewCount="78" Body="&lt;p&gt;I would like to linearize a product, for example &lt;span class=&quot;math-container&quot;&gt;$a*b$&lt;/span&gt;. if I solve my solution in log space, I can formulate it as &lt;span class=&quot;math-container&quot;&gt;$a+b$&lt;/span&gt; and when my final output is returned, remember to convert back to original space by finding &lt;span class=&quot;math-container&quot;&gt;$e^a, e^b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, further suppose that I have integer constraints for binary assignment, where &lt;span class=&quot;math-container&quot;&gt;$a,b$&lt;/span&gt; fall in the set {0,1}. By using &lt;span class=&quot;math-container&quot;&gt;$log_2{x}$&lt;/span&gt; I can use set{1,2} rather than set{0,1}. This is because &lt;span class=&quot;math-container&quot;&gt;$log_2{1}=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$log_2{2}=1$&lt;/span&gt;. So now, if I revisit the original problem of &lt;span class=&quot;math-container&quot;&gt;$a*b$&lt;/span&gt; and I want to find if both &lt;span class=&quot;math-container&quot;&gt;$a,b$&lt;/span&gt; are true, I can solve this in log space as &lt;span class=&quot;math-container&quot;&gt;$z= a+b$&lt;/span&gt; remembering to subtract one from each variable to convert back to binary variables in the original space, where &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; would indicate if both &lt;span class=&quot;math-container&quot;&gt;$a,b$&lt;/span&gt; were true else False.&lt;/p&gt;&#xA;&lt;p&gt;Often times, in MILP problems there will be multiple objective terms, which &lt;em&gt;I believe that&lt;/em&gt; the MILP solver anticipates adding together. Consider my objective terms, in original space as &lt;span class=&quot;math-container&quot;&gt;$a*b + x*y$&lt;/span&gt;. Taking the logarithm, &lt;span class=&quot;math-container&quot;&gt;$log_2{(a*b + x*y)}$&lt;/span&gt;. However, I do not believe that this can be simplified any further. Because the log cannot be removed from the equation, I cannot so eloquently expunge it from the solver's logic. And MILP solvers are not equipped to evaluate log expressions.&lt;/p&gt;&#xA;&lt;p&gt;The first workaround that comes to mind is using a geometric mean rather than an arithmetic mean.&lt;/p&gt;&#xA;&lt;p&gt;To give an example, say that I had &lt;strong&gt;two objective terms&lt;/strong&gt; in my original space, &lt;span class=&quot;math-container&quot;&gt;$a*b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x*y*$&lt;/span&gt;. The arithmetic mean of these objective terms is &lt;span class=&quot;math-container&quot;&gt;$(a*b + x*y)/2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, using a geometric mean, there are two formulations:&lt;/p&gt;&#xA;&lt;p&gt;First, &lt;span class=&quot;math-container&quot;&gt;$\sqrt[\leftroot{-2}\uproot{2}2]{a*b*x*y}$&lt;/span&gt;. And second, &lt;span class=&quot;math-container&quot;&gt;$(log_2{a} + log_2{b} + log_2{x} + log_2{y})/2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I believe that this second formulation would enable me to find the geometric mean of my objective terms by treating inputs as logarithms and remembering to convert back to the original space post solution using exponentiation.&lt;/p&gt;&#xA;&lt;p&gt;Any thoughts or experience here?&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="10326" LastEditDate="2023-01-14T17:00:25.373" LastActivityDate="2023-01-14T18:07:33.537" Title="MILP: Substituting products with additive logarithms" Tags="|mixed-integer-programming|linearization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9744" PostTypeId="2" ParentId="9743" CreationDate="2023-01-14T17:03:06.220" Score="1" Body="&lt;p&gt;If solver (and most solver can) handle log in constraints, I'd&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_1 = \log_2 a + \log_2 b $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ z_2 = \log_2 x + \log_2 y$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Obj = &lt;span class=&quot;math-container&quot;&gt;$z_1+z_2 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x= e^{u_x} ; y= e^{u_y}$&lt;/span&gt;&lt;br /&gt;&#xA;Obj = &lt;span class=&quot;math-container&quot;&gt;$e^{u_1+u_2} + e^{u_a+u_b} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Using geo mean, it may be vastly different from arithmetic mean. While log of a geometric mean is an addition and will be convex, also optimal point for log equivalent remains the same as original function but using geometric mean (nonconvex) as a function may give different optimal point than the original convex arithmetic mean.&lt;/p&gt;&#xA;&lt;p&gt;OK found a close approximation of what OP is seeking &lt;a href=&quot;https://or.stackexchange.com/questions/180/how-to-linearize-the-product-of-two-continuous-variables&quot;&gt;here&lt;/a&gt;. It uses separable programming.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-14T18:07:33.537" LastActivityDate="2023-01-14T18:07:33.537" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9745" PostTypeId="1" AcceptedAnswerId="9747" CreationDate="2023-01-15T11:14:37.883" Score="6" ViewCount="499" Body="&lt;p&gt;We have two variables &lt;span class=&quot;math-container&quot;&gt;$x\geq0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y\in\mathbb{Z}^{0+}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We have this constraint in our model&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x = \sum_{i = 0}c_i \mathbb{1}_{\{y=i\}}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; is a parameter and &lt;span class=&quot;math-container&quot;&gt;$\mathbb{1}_{A} = 1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is true and zero otherwise.&lt;/p&gt;&#xA;&lt;p&gt;Is this constraint linear?&lt;/p&gt;&#xA;" OwnerDisplayName="user10774" LastEditorUserId="500" LastEditDate="2023-01-15T14:02:28.287" LastActivityDate="2023-01-15T14:02:28.287" Title="Is this constraint with an indicator function nonlinear?" Tags="|mixed-integer-programming|linear-programming|modeling|indicator-constraints|linear|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9747" PostTypeId="2" ParentId="9745" CreationDate="2023-01-15T11:59:11.967" Score="5" Body="&lt;p&gt;Since the constraint includes binaries, it does not define a convex set, and is therefore not linear.&lt;/p&gt;&#xA;&lt;p&gt;For example, if &lt;span class=&quot;math-container&quot;&gt;$x=c_11_{A}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; can take values either &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$c_1$&lt;/span&gt;. But &lt;span class=&quot;math-container&quot;&gt;$\frac{0+c_1}{2} \notin \{0,c_1 \}$&lt;/span&gt;, so the constraint does not define a convex set.&lt;/p&gt;&#xA;&lt;p&gt;Note however that the convex hull of the constraint is linear, which is why such constraints are considered linear in the context of Mixed Linear Programming (MIP). So as Erwin points out in the comment section, a MIP is linear/convex if its relaxation is linear/convex.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-01-15T13:21:52.637" LastActivityDate="2023-01-15T13:21:52.637" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9748" PostTypeId="2" ParentId="9745" CreationDate="2023-01-15T14:01:36.913" Score="6" Body="&lt;p&gt;Indicator constraints are not linear constraints, but here’s a linearization with binary variables &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i z_i &amp;amp;= 1 \\&#xA;\sum_i i z_i &amp;amp;= y \\&#xA;\sum_i c_i z_i &amp;amp;= x&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-01-15T14:01:36.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9749" PostTypeId="1" CreationDate="2023-01-15T19:06:23.187" Score="3" ViewCount="131" Body="&lt;p&gt;How can I linearize this constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$d_{u,c}\sigma  \le \|{\bf f}_{u,c}\|^2\le Td_{u,c}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; is a very small number based on scale of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$T&amp;gt;0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;${\bf f}_{u,c}$&lt;/span&gt; is optimization variable, a complex vector.&#xA;&lt;span class=&quot;math-container&quot;&gt;$d_{u,c}$&lt;/span&gt; is also an optimization variable which in binary.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="123" LastEditDate="2023-01-18T21:55:53.873" LastActivityDate="2023-01-18T21:56:21.090" Title="How to linearize or fix this disciplined convex programming error?" Tags="|mixed-integer-programming|linearization|disciplined-convex-programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9750" PostTypeId="2" ParentId="9749" CreationDate="2023-01-15T19:43:39.060" Score="4" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_{u,c}\sigma  \le \|{\bf f}_{u,c}\|^2$&lt;/span&gt; is inherently non-convex, because &lt;code&gt;affine &amp;lt;= convex&lt;/code&gt; is non-convex, unless the LHS is zero, in which case this constraint can be eliminated as vacuous. Therefore, it can't be linearized into DCP compliance. I am interpreting the norm as being the two-norm. The one-norm or infinity-norm could be linearized into DCP compliance, as shown in &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/mio.html#integer-modeling&quot; rel=&quot;nofollow noreferrer&quot;&gt;Section 9,1 of Mosek Modeling Cookbook&lt;/a&gt;, suitably adjusted to handle complex variables, and for infinity norm as opposed to one-norm.&lt;/p&gt;&#xA;&lt;p&gt;If you really need this constraint, I recommend you abandon thoughts of using (MI)DCP for this problem. Rather, use a high quality off-the-shelf non-convex optimization solver. You could try some sort of Successive Convex Approximation or other dubious scheme, but I don't recommend it. Instead, let the non-convex solver handle any such things in the context of a high quality implementation, not a crude, unsafeguarded hack job, as seems to be de rigeur on some DCP forums.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="123" LastEditDate="2023-01-18T21:56:21.090" LastActivityDate="2023-01-18T21:56:21.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9752" PostTypeId="1" AcceptedAnswerId="9753" CreationDate="2023-01-16T13:48:52.007" Score="1" ViewCount="383" Body="&lt;p&gt;How to save log file from pulp , log including algorithms used by the solver  ?&lt;/p&gt;&#xA;&lt;p&gt;while this is printed in the python IDE console, looking to save it as a txt file .&lt;/p&gt;&#xA;" OwnerUserId="2958" LastActivityDate="2023-01-16T14:02:31.817" Title="How to save log file from pulp , log including algorithms used by the solver?" Tags="|pulp|cbc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9753" PostTypeId="2" ParentId="9752" CreationDate="2023-01-16T14:02:31.817" Score="3" Body="&lt;p&gt;You can use the logPath argument:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;prob.solve(pulp.PULP_CBC_CMD(msg=1,logPath=&amp;quot;info.log&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;More information can be found here:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://coin-or.github.io/pulp/technical/solvers.html#pulp.apis.COIN_CMD&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://coin-or.github.io/pulp/technical/solvers.html#pulp.apis.COIN_CMD&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2023-01-16T14:02:31.817" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9754" PostTypeId="1" AcceptedAnswerId="9755" CreationDate="2023-01-16T15:04:16.320" Score="2" ViewCount="124" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$g_1(x):=(x_1-1)^2+(x_2-1)^2-2\leq 0, g_2(x):=(x_1-1)^2+(x_2+1)^2-2\leq 0, g_3(x):=-x_1\leq 0$&lt;/span&gt; be given constraints. Show that the Mangasarian-Fromovitz Constraint Qualification (MFCQ) is satisfied in &lt;span class=&quot;math-container&quot;&gt;$\bar x=(0,0)$&lt;/span&gt; but the Linear Independence Constraint Qualification (LICQ) is not satisfied.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;All three constraints are active. I determined &lt;span class=&quot;math-container&quot;&gt;$$\nabla g_1(\bar x)=(-1,0)^T,\nabla g_2(\bar x)=(-2,-2)^T , \nabla g_3(\bar x)=(-2,2)^T.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Choose &lt;span class=&quot;math-container&quot;&gt;$d=(2,1)^T$&lt;/span&gt; to satisfy &lt;span class=&quot;math-container&quot;&gt;$\nabla g_i(x)^Td &amp;lt; 0\ \forall i=1,2,3$&lt;/span&gt;. So (MFCQ) is satisfied.&lt;/p&gt;&#xA;&lt;p&gt;BUT: &lt;span class=&quot;math-container&quot;&gt;$\nabla g_i(x)$&lt;/span&gt; are linear independent &lt;span class=&quot;math-container&quot;&gt;$\forall i=1,2,3$&lt;/span&gt;, so (LICQ) is also satisfied. Where is my mistake?&lt;/p&gt;&#xA;" OwnerUserId="11095" LastEditorUserId="491" LastEditDate="2023-01-17T01:28:10.737" LastActivityDate="2023-01-17T01:28:10.737" Title="Prove MF-Constraint Qualification but not LICQ is satisfied" Tags="|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9755" PostTypeId="2" ParentId="9754" CreationDate="2023-01-16T15:23:03.243" Score="2" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\nabla g_3(\bar x) = (1/4) \nabla g_1(\bar x) + (1/4) \nabla g_2(\bar x)$&lt;/span&gt;. So the active constraint gradients are not independent.&lt;/p&gt;&#xA;&lt;p&gt;Even without finding that relation, it must be the case that the active constraint gradients are not independent if the number of active constraints (3 in this case) is greater than the optimization problem dimension (2 in this case). That is because the rank of a matrix (active constraint gradients in this case) can't exceed the lesser of number of rows and columns.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-01-16T15:29:25.933" LastActivityDate="2023-01-16T15:29:25.933" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9757" PostTypeId="1" AcceptedAnswerId="9764" CreationDate="2023-01-16T15:44:09.657" Score="2" ViewCount="539" Body="&lt;p&gt;I have a research problem where my Mixed Integer Linear Program has data that follow probability distributions. I am approaching this by creating some m instances through realizations of these random variables (data).&lt;/p&gt;&#xA;&lt;p&gt;How do I approach this problem in Gurobi?&lt;/p&gt;&#xA;&lt;p&gt;For a better explanation, my data will be simple numerical data once the random variables are realized. But I will have created 1000 such instances and I want my model to perform optimally on say the 75th quantile case.&lt;/p&gt;&#xA;" OwnerUserId="10735" LastActivityDate="2023-01-20T12:45:12.570" Title="Robust Optimization in Gurobi" Tags="|optimization|gurobi|stochastic-programming|robust-optimization|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9759" PostTypeId="2" ParentId="9757" CreationDate="2023-01-16T16:02:30.057" Score="2" Body="&lt;p&gt;Robust optimization (&lt;span class=&quot;math-container&quot;&gt;$+/-$&lt;/span&gt;) is still a research area and I am not sure if Gurobi has an automated way unless you want to follow this example from &lt;a href=&quot;https://reference.wolfram.com/language/ref/RobustConvexOptimization.html#:%7E:text=Robust%20optimization%20is%20typically%20used,for%20all%20possible%20parameter%20values.&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wolfram&lt;/a&gt;. In case it's &lt;a href=&quot;https://en.wikipedia.org/wiki/Stochastic_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;stochastic programming&lt;/a&gt; one way is to apply sample approximation average (&lt;a href=&quot;https://en.wikipedia.org/wiki/Stochastic_programming#Monte_Carlo_sampling_and_Sample_Average_Approximation_(SAA)_Method&quot; rel=&quot;nofollow noreferrer&quot;&gt;SAA&lt;/a&gt;) if continuous distribution and parameters are known. You can generate sample data at cdf &lt;span class=&quot;math-container&quot;&gt;$\ge 75$&lt;/span&gt;% then take expected value of the sample. You can repeat this process itself. If you are using &lt;a href=&quot;https://optimization.cbe.cornell.edu/index.php?title=Chance-constraint_method#:%7E:text=The%20chance%2Dconstraint%20method%20of,determining%20the%20most%20likely%20result.&quot; rel=&quot;nofollow noreferrer&quot;&gt;chance constraints&lt;/a&gt; then you may need to determine the z-score at &lt;span class=&quot;math-container&quot;&gt;$75$&lt;/span&gt;% and then use appropriate relation.&lt;br /&gt;&#xA;You can check &lt;a href=&quot;http://www.lindo.com/cgi-bin/modelf.cgi?NewsVendScen01.txt;LINGO&quot; rel=&quot;nofollow noreferrer&quot;&gt;LINDO&lt;/a&gt; example and &lt;a href=&quot;https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_chance.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;GAMS&lt;/a&gt; example&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-16T16:51:04.263" LastActivityDate="2023-01-16T16:51:04.263" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9760" PostTypeId="1" CreationDate="2023-01-16T20:21:03.163" Score="2" ViewCount="40" Body="&lt;p&gt;This question is related to my previous question posted here: &lt;a href=&quot;https://or.stackexchange.com/questions/9735/piecewise-constraint-using-big-m-notation/9739#9739&quot;&gt;Piecewise constraint using big-M notation&lt;/a&gt; and this question posted on the math stackexchange: &lt;a href=&quot;https://math.stackexchange.com/questions/4065112/mip-modelling-of-piecewise-linear-function&quot;&gt;https://math.stackexchange.com/questions/4065112/mip-modelling-of-piecewise-linear-function&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Given the answers to the questions posted above, I am a little confused regarding the use of upper and lower bounds (see the variables &lt;span class=&quot;math-container&quot;&gt;$U_{1}, U_{2}, U_{3}, L_{1}, L_{2}, L_{3}$&lt;/span&gt; in the math stackexchange post for example).&lt;/p&gt;&#xA;&lt;p&gt;In that post, I tried setting each &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to 1 (one at a time), and sure enough I can see that we obtain the piecewise function the OP wanted. However, what is confusing me is that apparently the &lt;span class=&quot;math-container&quot;&gt;$L_{i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U_{i}$&lt;/span&gt; have to be calculated. It was my (naive) understanding that these could just be &amp;quot;absurdly&amp;quot; large and small numbers. So using the same post, U = 1000 and L = -1000 (&lt;span class=&quot;math-container&quot;&gt;$\forall i$&lt;/span&gt;) would be fine. But is this not the case? Is there a way to calculate these?&lt;/p&gt;&#xA;&lt;p&gt;If I can indeed just choose &amp;quot;absurdly&amp;quot; large and small numbers for these, is there any computational drawback? From my basic understanding, my guess would be that the search space would increase and as would the computational time.&lt;/p&gt;&#xA;" OwnerUserId="11074" LastActivityDate="2023-01-16T20:21:03.163" Title="Choosing upper and lower bound using big-M" Tags="|linearization|big-m|" AnswerCount="0" CommentCount="0" ClosedDate="2023-01-18T21:54:57.597" ContentLicense="CC BY-SA 4.0" />
  <row Id="9761" PostTypeId="1" CreationDate="2023-01-16T23:13:51.717" Score="1" ViewCount="98" Body="&lt;p&gt;I am reading the following paper on the pick-up delivery problem with LIFO but ultimately failing to understand the LIFO constraint that the authors used. Here is the paper:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Cherkesly, M., Desaulniers, G., &amp;amp; Laporte, G. (2015).&#xA;Branch-price-and-cut algorithms for the pickup and delivery problem&#xA;with time windows and last-in-first-out loading. Transportation&#xA;Science, 49(4), 752-766.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The authors define a subset &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of all node &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; and then defines a constraint (7) on this subset. If you are familiar with LIFO invoved VRP would you be able to explain how this subset be can be visulaized?  Is there a better way to construct the LIFO constraints?&lt;/p&gt;&#xA;&lt;p&gt;Below is the section where they proposed the model.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JRkYi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JRkYi.png&quot; alt=&quot;![enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WWNeN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WWNeN.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3288" LastActivityDate="2023-01-17T22:14:08.770" Title="How to construct LIFO constraints in Pickup and Delivery Problem" Tags="|vehicle-routing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9762" PostTypeId="2" ParentId="9761" CreationDate="2023-01-17T01:16:12.257" Score="3" Body="&lt;p&gt;Basically it says after the last pickup vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; doesn't visit any other node unless the node is a delivery point &lt;span class=&quot;math-container&quot;&gt;$\in D$&lt;/span&gt; for the last picked up request.&lt;/p&gt;&#xA;&lt;p&gt;Hierarchical Objective - minimize travel time and number of unserved customers. Other objectives could be minimize number of vehicles needed and transport cost.&lt;/p&gt;&#xA;&lt;p&gt;Sets&lt;br /&gt;&#xA;Nodes:&lt;span class=&quot;math-container&quot;&gt;$N_i$&lt;/span&gt;&lt;br /&gt;&#xA;N = &lt;span class=&quot;math-container&quot;&gt;$O \cup P \cup D$&lt;/span&gt; where O=&lt;span class=&quot;math-container&quot;&gt;$\{0,2n+1\}$&lt;/span&gt;:depot; P=&lt;span class=&quot;math-container&quot;&gt;$\{1,2,...n\}$&lt;/span&gt; Pickup points and &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$D=\{n+1,n+2,...2n\}$&lt;/span&gt; Delivery points: basically pickup and delivery points are paired\&lt;/p&gt;&#xA;&lt;p&gt;Arcs: &lt;span class=&quot;math-container&quot;&gt;$A_{ij}$&lt;/span&gt;&lt;br /&gt;&#xA;Open/Close time for each point &lt;span class=&quot;math-container&quot;&gt;$e_i, l_i $&lt;/span&gt;&lt;br /&gt;&#xA;Vehicles: &lt;span class=&quot;math-container&quot;&gt;$K = \{1,2,...v\}$&lt;/span&gt;: with capacity &lt;span class=&quot;math-container&quot;&gt;$Q_k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Parameters&#xA;Request: &lt;span class=&quot;math-container&quot;&gt;$q_i$&lt;/span&gt;: it's the load from pickup &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to delivery &lt;span class=&quot;math-container&quot;&gt;$n+i$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$q_{n+i}+q_i = 0$&lt;/span&gt;&lt;br /&gt;&#xA;Customers &lt;span class=&quot;math-container&quot;&gt;$≡ $&lt;/span&gt;Pickup point request, so number of customers = &lt;span class=&quot;math-container&quot;&gt;$ \vert P \vert = n$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Variables&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{ijk} \in \{0,1\}$&lt;/span&gt; indicates if vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is used on trip &lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$T_{ik}$&lt;/span&gt;: Total travel time for vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$L_{ik}$&lt;/span&gt;: total load for vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;obj = &lt;span class=&quot;math-container&quot;&gt;$\min w_1 (\sum_{k\in K}\sum_{i,j\in A}t_{ij}x_{ijk}) + w_2\frac{(n-\sum_k\sum_{i,j \in A}x_{ijk}-v)}2 $&lt;/span&gt;&lt;br /&gt;&#xA;s.t.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$T_{ik}+ t_{ij} - M(1-x_{ijk}) \le T_{jk} \ \ \forall i,j \in A \ \forall k \in K$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$L_{ik}+ q_{j} - M(1-x_{ijk}) \le L_{jk} \ \ \forall i,j \in A \ \forall k \in K$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$e_i \le T_{ik} \le l_i \ \ i \in O$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Pairing &amp;amp; Precedence&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in N}x_{ijk} = \sum_{j\in N}x_{j,n+i,k}  \ \ \forall i \in P \ \ \forall k$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$T_i + t_{i,n+i} \le T_{n+i} \ \ \forall i \in P \ \forall k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Enure each vehicle leaves &amp;amp; returns to depot: Subtour prevention&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_j x_{0,j,k}=\sum_i x_{i,2n+1,k}\ \ \forall k$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_j x_{0,j,k}=1 \ \ \forall k$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$1 \le \sum_k\sum_j x_{ijk} \ \ \forall i \in N$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$q_i \le L_{i,k} \ \ \forall k \ \forall i \in P$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;LIFO Policy-basically after a pickup vehicle cant travel to another unpaired delivery point&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$L_{n+i,k} = L_{i,k}-q_i \ \ \forall i \in P \ \forall k$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in D-\{n+i\}}x_{ijk} = 0 \ \ \forall i \in P \ \ \forall k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \le L_{i,k};  0\le T_{i,k} \ \forall i \in N $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$w_1,w_2$&lt;/span&gt; are objective weights for significance or priority.&lt;/p&gt;&#xA;&lt;p&gt;References that explain it better,&#xA;&lt;a href=&quot;https://www.matec-conferences.org/articles/matecconf/pdf/2018/63/matecconf_imiec2018_07003.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MATEC&lt;/a&gt;, &lt;a href=&quot;https://numerique.banq.qc.ca/patrimoine/details/52327/2494771&quot; rel=&quot;nofollow noreferrer&quot;&gt;U of Montreal&lt;/a&gt;, &lt;a href=&quot;https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=8910558&quot; rel=&quot;nofollow noreferrer&quot;&gt;IEEE&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="491" LastEditDate="2023-01-17T22:14:08.770" LastActivityDate="2023-01-17T22:14:08.770" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9763" PostTypeId="2" ParentId="9749" CreationDate="2023-01-17T03:55:03.197" Score="1" Body="&lt;p&gt;I guess by the constraint &lt;span class=&quot;math-container&quot;&gt;$\|\mathbf f_{u, c}\|^2 \geq \sigma d_{u,c}$&lt;/span&gt; with a very small &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt;, what you want is &lt;span class=&quot;math-container&quot;&gt;$d_{u,c} = 1 \Rightarrow \|\mathbf f_{u,c}\|^2_2 &amp;gt; 0$&lt;/span&gt;. In this case, since &lt;span class=&quot;math-container&quot;&gt;$\|\mathbf f_{u,c}\|_2 &amp;gt; 0 \Leftrightarrow \|\mathbf f_{u,c}\|_1&amp;gt;0$&lt;/span&gt;, you can replace the l2 norm with l1 norm, and l1 norm could be transformed to DCP, as mentioned. So the result is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;d_{u, c} \tilde{\sigma} \leq \|\mathbf f_{u,c}\|_1\\&#xA;\|\mathbf f_{u,c}\|_2^2 \leq Td_{u,c}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\tilde{\sigma}$&lt;/span&gt; is another small number.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2023-01-17T03:55:03.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9764" PostTypeId="2" ParentId="9757" CreationDate="2023-01-17T08:50:56.500" Score="7" Body="&lt;p&gt;One way to do this is to rewrite the objective somewhat.&lt;/p&gt;&#xA;&lt;p&gt;I'm going to start from an objective of the following form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \min_x c(\zeta)^\top x, $$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$c(\zeta)$&lt;/span&gt; a cost vector depending on a random vector &lt;span class=&quot;math-container&quot;&gt;$\zeta$&lt;/span&gt; with known probability distribution, and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; a decision vector, both of suitable dimension.&lt;/p&gt;&#xA;&lt;p&gt;Now, the problem using &lt;span class=&quot;math-container&quot;&gt;$\zeta$&lt;/span&gt; directly is that the support of its probability distribution could be very large. Instead, we can sample a representative set of &lt;span class=&quot;math-container&quot;&gt;$n \in \mathbb{N}$&lt;/span&gt; realisations &lt;span class=&quot;math-container&quot;&gt;$\zeta_1, \zeta_2, \ldots, \zeta_n$&lt;/span&gt; from the probability distribution of &lt;span class=&quot;math-container&quot;&gt;$\zeta$&lt;/span&gt;.&#xA;If these samples adequately capture the randomness in &lt;span class=&quot;math-container&quot;&gt;$\zeta$&lt;/span&gt;, the resulting sampling solution should also be close to the optimal solution had we used &lt;span class=&quot;math-container&quot;&gt;$\zeta$&lt;/span&gt; directly.&lt;/p&gt;&#xA;&lt;p&gt;We can restate the sampling objective using an epigraph formulation, as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \min_{x, t} t $$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$t \in \mathbb{R}$&lt;/span&gt;, subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ t \ge c(\zeta_i)^\top x, \qquad i = 1, 2, \ldots, n. $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Using binary variables &lt;span class=&quot;math-container&quot;&gt;$z_i \in \{0, 1\}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i = 1,\ldots, n$&lt;/span&gt;, we can rewrite this to add the condition that a fraction &lt;span class=&quot;math-container&quot;&gt;$\alpha \in [0,1]$&lt;/span&gt; of these constraints may be violated:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align} \textstyle&#xA;  \sum_{i = 1}^n z_i &amp;amp;\le \alpha n, \\&#xA;  t &amp;amp;\ge c(\zeta_i)^\top x - Mz_i \qquad i = 1, 2, \ldots, n,&#xA;\end{align}&lt;/span&gt;&#xA;for some &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; big enough. A concrete value for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; could be the objective value you get when optimising with &lt;span class=&quot;math-container&quot;&gt;$M = \alpha = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For the &lt;span class=&quot;math-container&quot;&gt;$0.75$&lt;/span&gt; quantile, set &lt;span class=&quot;math-container&quot;&gt;$\alpha = 0.25$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="992" LastEditorUserId="992" LastEditDate="2023-01-20T12:45:12.570" LastActivityDate="2023-01-20T12:45:12.570" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9765" PostTypeId="2" ParentId="9757" CreationDate="2023-01-17T12:24:20.307" Score="6" Body="&lt;p&gt;The following formulation is more or less the same as the formulation used in &lt;a href=&quot;https://or.stackexchange.com/questions/8633/how-to-represent-a-constraint-on-the-kth-smallest-function/8634#8634&quot;&gt;How to represent a constraint on the kth-smallest function?&lt;/a&gt;. So thanks to @RobPratt for providing a comment which improved that formulation, and hence this one.&lt;/p&gt;&#xA;&lt;p&gt;Le &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; be the number off scenarios. In your case, 1000.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; be the applicable quantile. In your case, 0.75&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$f(i)$&lt;/span&gt; be the non-robustified objective value for scenario &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Declare an optimization variable &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, which will be the objective function to be minimized in the robustified problem.&lt;/p&gt;&#xA;&lt;p&gt;Declare &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; as a vector of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; binary optimization variables.&lt;/p&gt;&#xA;&lt;p&gt;Add the indicator constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$b(i) = 1 \rightarrow f(i) \le t$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i=1,...,N$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(If maximizing instead of minimizing, instead use&#xA;&lt;span class=&quot;math-container&quot;&gt;$b(i) = 1 \rightarrow f(i) \ge t$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i=1,...,N$&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Add the constraint &lt;span class=&quot;math-container&quot;&gt;$\Sigma_{i=1}^N b(i) \ge q N$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If this were implemented in a modeling system (and solver other than Gurobi) which did not have indicator constraints, the Big M equivalent could be used instead.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2023-01-17T12:24:20.307" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9766" PostTypeId="1" CreationDate="2023-01-18T08:52:37.540" Score="2" ViewCount="83" Body="&lt;p&gt;I have a binary variable (X) multiplying a continuous variable (Y). I know I can linearize by adding an auxiliary variable (I have that model working), but I now want to do my own branching in the binary variable.&lt;/p&gt;&#xA;&lt;p&gt;For what I read on Gurobi's documentation, I guess that it should be done by tightening the domain of variable X until getting to the binary solution. But I have no idea how to implement this, or even if it makes sense.&lt;/p&gt;&#xA;&lt;p&gt;I saw this video of Gurobi, but I think is more complex that what I need for my binary variable. And I end up more confused than before.&lt;/p&gt;&#xA;&lt;p&gt;I hope someone could guide me in how to do a branching on a binary variable in Gurobi (I use python, but can extrapolate from the other languages).&lt;/p&gt;&#xA;" OwnerUserId="7200" LastActivityDate="2023-01-18T08:52:37.540" Title="Branching the product of binary and continuous variable in Gurobi" Tags="|mixed-integer-programming|gurobi|nonlinear-programming|binary-variable|branch-and-bound|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9767" PostTypeId="1" CreationDate="2023-01-18T15:10:40.330" Score="2" ViewCount="45" Body="&lt;p&gt;Do you know some &lt;strong&gt;European conferences&lt;/strong&gt; requiring to send &lt;strong&gt;sole abstract&lt;/strong&gt; which is then published in &lt;strong&gt;book of abstracts&lt;/strong&gt;? I am searching mostly for conferences in &lt;strong&gt;Operations Research with an economics section&lt;/strong&gt; (but other related sciences could also be ok if they meet the conditions).&lt;/p&gt;&#xA;&lt;p&gt;Do you know some of these conferences, for example like &lt;strong&gt;EURO conference&lt;/strong&gt; which suits it the best: &lt;a href=&quot;https://euro2022espoo.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://euro2022espoo.com/&lt;/a&gt;?&lt;/p&gt;&#xA;&lt;p&gt;I know there is a list on a site such as &lt;strong&gt;INOMICS&lt;/strong&gt;: &lt;a href=&quot;https://inomics.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://inomics.com/&lt;/a&gt;, but I haven't seen there any operations research conferences as EURO.&lt;/p&gt;&#xA;&lt;p&gt;Do you know some other lists/sites?&lt;/p&gt;&#xA;&lt;p&gt;Possibly, conferences requiring to send a paper but publishing only abstracts in book of abstracts would be ok as well, but they are not the prime focus of this question.&lt;/p&gt;&#xA;" OwnerUserId="11035" LastEditorUserId="491" LastEditDate="2023-01-19T12:50:13.297" LastActivityDate="2023-01-19T12:50:13.297" Title="Abstract-only European conferences in OR with economics sections" Tags="|academia|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9768" PostTypeId="1" CreationDate="2023-01-18T16:19:19.170" Score="2" ViewCount="75" Body="&lt;p&gt;I have a convex MINLP that after a Dantzig-Wolfe reformulation, passes most of the difficulty onto the pricing problem, which becomes a convex MINLP itself.&lt;/p&gt;&#xA;&lt;p&gt;The pricing problem should be solvable with a Benders-like algorithm since it has a set of variables &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; such that, when fixed, the problem is extremely easy to solve. However, these fixable variables are continuous, not discrete, and so the corresponding Benders-like subproblem has integer variables, which excludes traditional Generalized Benders.&lt;/p&gt;&#xA;&lt;p&gt;I know that I can solve the continuous relaxation and then branch, and I have also seen Logic-based Benders Decomposition, which requires branching as well. I am afraid that this will take too much time, especially given that I am not interested in an optimal solution, I just want to generate a new column for the Dantzig-Wolfe's master.&lt;/p&gt;&#xA;&lt;p&gt;So my question is, besides setting a high &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt; parameter for the Benders termination criteria, are there any other &lt;span class=&quot;math-container&quot;&gt;$\textit{fast}$&lt;/span&gt; alternatives? To summarize, the subproblem is a MINLP for which I can obtain solutions very very quickly, and I am not necessarily interested in provably optimal solutions (but still would like more than just feasibility).&lt;/p&gt;&#xA;&lt;p&gt;As additional information, all integer variables are binary. Furthermore, for fixed &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables, I can solve the subproblem directly without calling an outside solver, as everything else is fixed as well. Solving the continuous relaxation takes considerably more time, and that is why I am wary of branching approaches. Finally, the domain of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is such that I do not need to worry about its feasibility.&lt;/p&gt;&#xA;" OwnerUserId="5352" LastEditorUserId="491" LastEditDate="2023-01-19T12:51:26.067" LastActivityDate="2023-01-19T12:51:26.067" Title="Benders with MINLP subproblem as the pricing problem of Dantzig Wolfe" Tags="|reference-request|benders-decomposition|minlp|decomposition|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9769" PostTypeId="1" CreationDate="2023-01-18T20:04:54.810" Score="3" ViewCount="365" Body="&lt;p&gt;I have an optimization variable denoted as &lt;span class=&quot;math-container&quot;&gt;${\bf A\in\mathbb{C}^{100\times 5}}=[{\bf a}_1\hspace{1mm} {\bf a}_2 \hspace{1mm} {\bf a}_3 \hspace{1mm} {\bf a}_4 \hspace{1mm} {\bf a}_5];$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;${\bf a}_1$&lt;/span&gt; is the 1st column of matrix &lt;span class=&quot;math-container&quot;&gt;${\bf A}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;${\bf a}_2$&lt;/span&gt; is the 2nd column of matrix &lt;span class=&quot;math-container&quot;&gt;${\bf A}$&lt;/span&gt; and so on.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;${\bf b}=[||{\bf a}_1||_2 \hspace{1mm}||{\bf a}_2||_2 \hspace{1mm} ||{\bf a}_3||_2 \hspace{1mm} ||{\bf a}_4||_2 \hspace{1mm} ||{\bf a}_5||_2]$&lt;/span&gt; be the vector of norms of all the column vectors in matrix &lt;span class=&quot;math-container&quot;&gt;${\bf A}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In case it is beneficial we may also allow &lt;span class=&quot;math-container&quot;&gt;${\bf b}=[||{\bf a}_1||_1 \hspace{1mm}||{\bf a}_2||_1 \hspace{1mm} ||{\bf a}_3||_1 \hspace{1mm} ||{\bf a}_4||_1 \hspace{1mm} ||{\bf a}_5||_1]$&lt;/span&gt;, i.e, L1 norm instead of L2 norm.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textbf{I want to make the norms zero for as many columns as possible.}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My objective function is expressed as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min\hspace{3mm} ||{\bf b}||_0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$||\cdot||_2$&lt;/span&gt; is L2 norm operator and &lt;span class=&quot;math-container&quot;&gt;$||\cdot||_0$&lt;/span&gt; is L0 norm operator.&lt;/p&gt;&#xA;&lt;p&gt;Here, norm L0 is defined as the number of nonzero elements.&lt;/p&gt;&#xA;&lt;p&gt;We know that L0 norm is non convex. How to deal this objective? I mean linearization/convexification or approximation.&lt;/p&gt;&#xA;&lt;p&gt;Or any other means to achieve the same.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2023-01-18T21:20:44.100" LastActivityDate="2023-01-19T16:38:46.470" Title="How to deal this L0 norm of a vector of L2 or L1 norms in objective?" Tags="|linear-programming|linearization|convex-optimization|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9770" PostTypeId="2" ParentId="9769" CreationDate="2023-01-18T20:34:20.890" Score="3" Body="&lt;p&gt;You can introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$\mathbf{z}\in \lbrace 0, 1 \rbrace^n$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the dimension of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}$&lt;/span&gt;) together with the constraints &lt;span class=&quot;math-container&quot;&gt;$b_i \le M_i z_i,$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; is an upper bound for &lt;span class=&quot;math-container&quot;&gt;$\vert b_i \vert,$&lt;/span&gt; and then minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_i z_i.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-01-19T16:38:46.470" LastActivityDate="2023-01-19T16:38:46.470" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9771" PostTypeId="1" CreationDate="2023-01-18T21:46:35.887" Score="3" ViewCount="76" Body="&lt;p&gt;Recently I found a subproblem in a project I am working with. This problem is a sort of flow variant, as you will see. And I am looking for literature-related articles and also fast approaches for tackling the problem. In this variant we have a &lt;a href=&quot;https://en.wikipedia.org/wiki/Flow_network#Definition&quot; rel=&quot;nofollow noreferrer&quot;&gt;flow network&lt;/a&gt; &lt;span class=&quot;math-container&quot;&gt;$(D, c, s, t)$&lt;/span&gt;, where:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$D(V, A)$&lt;/span&gt; is a digraph, where:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$(s, i) \in A \quad \forall i \in V \backslash \{s, t\}$&lt;/span&gt;, i.e. there is an arc from the source node &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; to each node in the digraph, excepting the target node &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$(i, t) \in A \quad \forall i \in V \backslash \{s, t\}$&lt;/span&gt;, i.e. there is an arc from each node, excepting the source &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, to the target node &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c: A \rightarrow \mathbb{N}$&lt;/span&gt; is the arc capacity function;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s \in V$&lt;/span&gt; is the source node; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t \in V$&lt;/span&gt; is the target node.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;And we also have&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$d: V \rightarrow \mathbb{N}$&lt;/span&gt; a function stating the flow demand of each node; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$F \in \mathbb{N}$&lt;/span&gt; which represents the initial flow at the source node &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;A feasible solution for an instance &lt;span class=&quot;math-container&quot;&gt;$((D, c, s, t), d, F)$&lt;/span&gt; of this flow variant is given by &lt;span class=&quot;math-container&quot;&gt;$f: A \rightarrow \mathbb{N}$&lt;/span&gt;, such that:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{a \in \delta^{-}(i)} f_a = \sum_{a \in \delta^{+}(i)} f_a = d_i$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in V \backslash \{s, t\}$&lt;/span&gt;, i.e. the entering flow, the leaving flow, and the flow demand of a given node are the same, excepting for the &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; nodes;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{a \in \delta^{+}(s)} f_a \leqslant F$&lt;/span&gt;, i.e. the flow sent by the source &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is at most &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt;; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f_a \leqslant c_a$&lt;/span&gt;, i.e. the flow sent in a given arc is limited by the arc capacity.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;This flow variant is a decision problem that concerns finding a feasible &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; for a given instance &lt;span class=&quot;math-container&quot;&gt;$((D, c, s, t), d, F)$&lt;/span&gt;. As far as I concern, this problem is a sort of max-flow with integer and mandatory flows - flows that must assume integral measures and must satisfy the nodes' flow demands.&lt;/p&gt;&#xA;&lt;p&gt;Of course, we could design CP and IP models for solving the problem. However, for the purpose this problem is being used for, fast algorithms are required, once this problem is embedded as a subproblem of a global algorithm. Thus, I would like to know if someone has some related literature references, and also algorithms suggestions, even if relying on mathematical programming models.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="491" LastEditDate="2023-01-19T12:50:50.563" LastActivityDate="2023-01-19T12:50:50.563" Title="Flow problem with flow demands" Tags="|algorithms|graphs|network-flow|maxflow|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9772" PostTypeId="1" AcceptedAnswerId="9782" CreationDate="2023-01-19T11:27:47.003" Score="6" ViewCount="256" Body="&lt;p&gt;In vehicle routing problems, the &lt;em&gt;route first cluster second&lt;/em&gt; approach starts by computing a &amp;quot;giant&amp;quot; TSP tour (which typically does not satisfy all constraints of the problem), and then transforms this tour into smaller feasible ones (see for example &lt;a href=&quot;https://www.researchgate.net/profile/John_Beasley/publication/23793206_Route_first--Cluster_second_methods_for_vehicle_routing/links/0fcfd51013de989426000000.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;I am wondering if it is possible to apply the same strategy for arc routing problems. A trial and error approach is described &lt;a href=&quot;https://web.mit.edu/urban_or_book/www/book/chapter6/6.4.14.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for the &lt;a href=&quot;https://en.wikipedia.org/wiki/Chinese_postman_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPP&lt;/a&gt;, but it is not very satisfying.&lt;/p&gt;&#xA;&lt;p&gt;Could we formulate a MIP to partition a &amp;quot;giant&amp;quot; eulerian tour into &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; subtours (with, for example, a maximum length) ? Or is there another smart way of achieving this?&lt;/p&gt;&#xA;&lt;p&gt;An example is illustrated below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/k8uIO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/k8uIO.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-01-20T12:28:09.183" LastActivityDate="2023-01-24T11:11:54.270" Title="How to partition a giant tour into feasible routes?" Tags="|mixed-integer-programming|modeling|vehicle-routing|graphs|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9773" PostTypeId="1" CreationDate="2023-01-19T15:36:29.593" Score="1" ViewCount="116" Body="&lt;p&gt;This question is related to &lt;a href=&quot;https://or.stackexchange.com/questions/9769/how-to-deal-this-l0-norm-of-a-vector-of-l2-or-l1-norms-in-objective&quot;&gt;How to deal this L0 norm of a vector of L2 or L1 norms in objective?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have an optimization variable denoted as &lt;span class=&quot;math-container&quot;&gt;${\bf A\in\mathbb{C}^{100\times 5}}=\begin{bmatrix}{\bf a}_1&amp;amp;{\bf a}_2&amp;amp;{\bf a}_3&amp;amp;{\bf a}_4&amp;amp;{\bf a}_5\end{bmatrix}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;${\bf a}_1$&lt;/span&gt; is the 1st column of matrix &lt;span class=&quot;math-container&quot;&gt;${\bf A}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;${\bf a}_2$&lt;/span&gt; is the 2nd column of matrix &lt;span class=&quot;math-container&quot;&gt;${\bf A}$&lt;/span&gt; and so on.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;${\bf b}=\begin{bmatrix}\|{\bf a}_1\|_2&amp;amp;\|{\bf a}_2\|_2&amp;amp;\|{\bf a}_3\|_2&amp;amp;\|{\bf a}_4\|_2&amp;amp;\|{\bf a}_5\|_2\end{bmatrix}$&lt;/span&gt; be the vector of norms of all the column vectors in matrix &lt;span class=&quot;math-container&quot;&gt;${\bf A}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textbf{I want to make the norms zero for as many columns as possible.}$&lt;/span&gt;. Please see prof. Rubin's proposal.&lt;/p&gt;&#xA;&lt;p&gt;At the same time I also want to minimize the &lt;span class=&quot;math-container&quot;&gt;$\|A\|_F$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\|A\|_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How to model this objective?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2023-01-24T10:04:34.207" LastActivityDate="2023-01-24T10:04:34.207" Title="How to model this problem with multiple objectives?" Tags="|mixed-integer-programming|modeling|multi-objective-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9774" PostTypeId="2" ParentId="9773" CreationDate="2023-01-19T16:09:55.340" Score="1" Body="&lt;p&gt;Couple of ways:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Scale up the smaller objective value so choose &lt;span class=&quot;math-container&quot;&gt;$\alpha_1 obj1_1 + \alpha_2obj_2 $&lt;/span&gt; so that &lt;span class=&quot;math-container&quot;&gt;$\alpha_1 obj1 \ge \alpha_2obj_2 $&lt;/span&gt;. In your case try adding weight of 50 to the smaller objective.&lt;/li&gt;&#xA;&lt;li&gt;Solve the problem with bigger objective value first, then while solving the next objective add a constraint using the solved optimal value. Like if z is optimal solution for max&lt;span class=&quot;math-container&quot;&gt;$\Vert A \Vert_2 $&lt;/span&gt;, then while solving for min &lt;span class=&quot;math-container&quot;&gt;$\Vert b_i \Vert_0$&lt;/span&gt; (basically minimizing &lt;span class=&quot;math-container&quot;&gt;$\sum_i z_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\beta_i \le Mz_i$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$b_i \le \beta_i$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$-b_i \le \beta_i$&lt;/span&gt; as in the previous post) add constraint &lt;span class=&quot;math-container&quot;&gt;$z \le \Vert A \Vert_2$&lt;/span&gt; or whatever linear form you are using for &lt;span class=&quot;math-container&quot;&gt;$L_2$&lt;/span&gt; norm.&lt;/li&gt;&#xA;&lt;li&gt;Try with multiplicative relation like obj1*obj2. Then use log for the objective &lt;span class=&quot;math-container&quot;&gt;$\log Z = \log obj_1 + \log obj_2$&lt;/span&gt;. Then you have to transform back to actual optimal value using &lt;span class=&quot;math-container&quot;&gt;$\exp$&lt;/span&gt; of log base.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-19T17:01:34.437" LastActivityDate="2023-01-19T17:01:34.437" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9775" PostTypeId="1" AcceptedAnswerId="9777" CreationDate="2023-01-20T16:00:18.707" Score="2" ViewCount="115" Body="&lt;p&gt;I have an optimization problem as below&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_x&amp;amp;\quad x\sum_{k=1}^{K}\log\left(1+\frac{h_k}{x}\right)+{(1-x) \sum_{l=1}^L \log\left(1+\frac{g_l}{1-x}\right)}\\\text { subject to }&amp;amp;\quad0 &amp;lt; x &amp;lt; 1 \hspace{0.7cm}\\&amp;amp;\quad Q(x)\leq 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is it possible use slack variables to reform it (actually first constraint) in a standard format? (I'm aiming to rewrite it as a standard problem and then attempt to find a closed-form solution using the Lagrangian method.)&lt;/p&gt;&#xA;" OwnerUserId="11105" LastEditorUserId="123" LastEditDate="2023-01-20T22:23:17.200" LastActivityDate="2023-01-20T22:23:17.200" Title="How to rewrite this problem in a standard format?" Tags="|optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9777" PostTypeId="2" ParentId="9775" CreationDate="2023-01-20T18:41:34.547" Score="2" Body="&lt;p&gt;You should take a look at the &lt;a href=&quot;https://en.wikipedia.org/wiki/Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions&quot; rel=&quot;nofollow noreferrer&quot;&gt;Karush-Kuhn-Tucker conditions&lt;/a&gt; (aka KKT conditions) as an alternative to Lagrange multipliers. As noted in the comment by @joni, you can pick a small positive number &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; (this is a parameter, not a variable to be constrained) and rewrite your first constraint as &lt;span class=&quot;math-container&quot;&gt;$$\begin{align*}x &amp;amp; \le 1-\epsilon \\ -x &amp;amp; \le -\epsilon.\end{align*}$$&lt;/span&gt; How small &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; should be depends on how close to 0 or 1 you want to allow &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to get, with the qualification that too small a value can result in numerical issues.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-01-20T18:41:34.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9778" PostTypeId="1" CreationDate="2023-01-20T18:58:23.320" Score="2" ViewCount="129" Body="&lt;p&gt;I'm a beginner in C++ and want to implement Benders decomposition in C++ using CPLEX. I'm gonna use it for a special case study, so I need to customize the cuts to minimize the optimality gap. However, I don't know much about implementation. I was wondering if anyone can suggest a reference (books, papers, codes) begin with.&lt;/p&gt;&#xA;" OwnerUserId="11106" LastEditorUserId="491" LastEditDate="2023-03-24T12:20:50.183" LastActivityDate="2023-03-24T12:20:50.183" Title="How should I implement Benders Decomposition with annotations in C++ using CPLEX library" Tags="|cplex|reference-request|benders-decomposition|c++|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9779" PostTypeId="2" ParentId="9778" CreationDate="2023-01-21T01:10:15.637" Score="1" Body="&lt;p&gt;I think I just answered this on my blog, but for the record, CPLEX does not (as far as I know) provide access to Benders cuts when the problem is partitioned automatically using annotations. So to merge cuts from subproblems, you would need to employ callbacks.&lt;/p&gt;&#xA;&lt;p&gt;There are two things to note regarding the idea of taking a linear combination of cuts. First, the combined cut likely would be weaker than the individual cuts, so any reduction in computational time from keeping the number of cuts smaller might well be offset by requiring more iterations in the master problem (and possibly more calls to the callback). Second, CPLEX automatically does some cut management. The cuts are added to a cut pool, and the ones that are nonbinding (for some number of iterations) are held out of the &amp;quot;working set&amp;quot; and only checked when necessary. So adding &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; cuts does not necessarily mean that the master problem constraint matrix being used for pivoting has &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; rows more than it started with.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-01-21T01:10:15.637" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9780" PostTypeId="1" AcceptedAnswerId="9784" CreationDate="2023-01-21T12:04:19.750" Score="3" ViewCount="196" Body="&lt;p&gt;Suppose we have a directed tree as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rXiWu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rXiWu.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The information regarding the edges are also given to us as a list&#xA;like edge_info = [ (a,c) , (a,b) , (b,d) , (b,e) , (b,f) ]&lt;/p&gt;&#xA;&lt;p&gt;I am trying to find a way to assign a number to each node as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a --&amp;gt; 0&lt;/li&gt;&#xA;&lt;li&gt;b ---&amp;gt; 1&lt;/li&gt;&#xA;&lt;li&gt;d, e, f ---&amp;gt; 2&lt;/li&gt;&#xA;&lt;li&gt;c---&amp;gt; 1&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Like the distance from the original node a&#xA;I need to do it without solving any optimization model just by normal operations / algorithm (sorting, reordering)&lt;/p&gt;&#xA;&lt;p&gt;It should be done no matter the order of edge information is given to us in edge_info list&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2023-01-23T08:45:29.383" Title="Directed trees and the order/score of each node in the tree" Tags="|graphs|hamiltonian-path|spanning-trees|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9782" PostTypeId="2" ParentId="9772" CreationDate="2023-01-21T14:18:04.347" Score="6" Body="&lt;p&gt;Here’s a MILP formulation to partition an Eulerian graph into &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; Eulerian subgraphs, with an objective of minimizing the maximum cost.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}$&lt;/span&gt; indicate whether edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; appears in subgraph &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$y_{vk}$&lt;/span&gt; be a nonnegative integer decision variable for each node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; and subgraph &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, and let decision variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; represent &lt;span class=&quot;math-container&quot;&gt;$\max_k \sum_{i,j} c_{ij}x_{ijk}$&lt;/span&gt;.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to &lt;a href=&quot;https://or.stackexchange.com/questions/5442/contiguous-service-area-constraint&quot;&gt;contiguity constraints&lt;/a&gt; and&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_k x_{ijk} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $(i,j)$} \tag1\label1 \\&#xA;\sum_{(i,j):v \in \{i,j\}} x_{ijk} &amp;amp;= 2y_{vk} &amp;amp;&amp;amp;\text{for all $v$ and $k$} \tag2\label2 \\&#xA;\sum_{i,j} c_{ij}x_{ijk} &amp;amp;\le z &amp;amp;&amp;amp;\text{for all $k$} \tag3\label3&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} assigns each edge to exactly one subgraph. Constraint \eqref{2} forces every node to have even degree in subgraph &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. Constraint \eqref{3} enforces the minimax objective.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Here's a flow-based approach to enforce contiguity of subgraph &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$w_{ik}$&lt;/span&gt; indicate whether node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; appears in subgraph &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$s_{ik}$&lt;/span&gt; indicate whether node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the source node for subgraph &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.  Let nonnegative variable &lt;span class=&quot;math-container&quot;&gt;$f_{ijk}$&lt;/span&gt; be the flow of &amp;quot;commodity&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.  The following constraints select one source for each &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and send one unit of flow from that source to all other nodes in subgraph &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i s_{ik} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $k$} \\&#xA;s_{ik} &amp;amp;\le w_{ik} &amp;amp;&amp;amp;\text{for all $i$ and $k$} \\&#xA;w_{ik} \le y_{ik} &amp;amp;\le \frac{\text{degree}_i}{2} w_{ik} &amp;amp;&amp;amp;\text{for all $i$ and $k$} \\&#xA;f_{ijk} + f_{jik} &amp;amp;\le n x_{ijk} &amp;amp;&amp;amp;\text{for all $(i,j)$ and $k$} \\&#xA;\sum_j (f_{ijk} - f_{jik}) &amp;amp;\le n s_{ik} - w_{ik}  &#xA;&amp;amp;&amp;amp;\text{for all $i$ and $k$} \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Without the contiguity constraints, the optimal objective value for the example instance with &lt;span class=&quot;math-container&quot;&gt;$K=3$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$1290$&lt;/span&gt;, attained by the following subgraphs with weights &lt;span class=&quot;math-container&quot;&gt;$1290$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$1270$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$1240$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;C D 120 &#xA;C I 250 &#xA;D I 300 &#xA;E F  80 &#xA;E H 260 &#xA;F G 100 &#xA;G H 180 &#xA;&#xA;A B 120 &#xA;A C 150 &#xA;B D 150 &#xA;C D 120 &#xA;D E 150 &#xA;D J 250 &#xA;E K 250 &#xA;J K  80 &#xA;&#xA;I J 120 &#xA;I J 120 &#xA;K L 150 &#xA;K L 150 &#xA;F G 100 &#xA;F L 250 &#xA;G M 250 &#xA;L M 100 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With the contiguity constraints also imposed, the example solution in the question is optimal, with objective value &lt;span class=&quot;math-container&quot;&gt;$1320$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-01-23T01:53:07.037" LastActivityDate="2023-01-23T01:53:07.037" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9783" PostTypeId="2" ParentId="9780" CreationDate="2023-01-21T14:51:15.617" Score="3" Body="&lt;p&gt;You can follow either fdepth-first or breadth-first  traversal while using dynamic programming. You can define &lt;span class=&quot;math-container&quot;&gt;$d(s,v,z)=$&lt;/span&gt; &amp;quot;depth(s), vector(v), distance from root &amp;quot; where vector is direction of child nodes i, like maybe an order [1,2,3,..] as they (set of i) appear in edge list, L for a node j.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ s=0; v=0$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$f(s,a)= d(s,v,0)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$j= a$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall i \in  L(j)$&lt;/span&gt;: For-loop&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z[i]= edge(j,i)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$s[i]= 1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$f(s,i) = d(s[i]+s[j],v,z[i]+z[j])$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ v=v+1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ j= L(0)$&lt;/span&gt; : move to first child node of parent node, j and repeat.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$s=s+1$&lt;/span&gt;: update stage/depth\&lt;/p&gt;&#xA;&lt;p&gt;till &lt;span class=&quot;math-container&quot;&gt;$s \ \exists$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-21T19:54:38.560" LastActivityDate="2023-01-21T19:54:38.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9784" PostTypeId="2" ParentId="9780" CreationDate="2023-01-21T19:52:08.780" Score="2" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; be the set of nodes. The following procedure should require &lt;span class=&quot;math-container&quot;&gt;$O(\vert N \vert^3)$&lt;/span&gt; time (I think).&lt;/p&gt;&#xA;&lt;p&gt;Start by defining a set &lt;span class=&quot;math-container&quot;&gt;$P_n=\emptyset$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$n\in N.$&lt;/span&gt; Scan the list of arcs, and for each arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; add &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$P_j.$&lt;/span&gt; Once done, &lt;span class=&quot;math-container&quot;&gt;$P_j$&lt;/span&gt; contains the list of all immediate predecessors of node &lt;span class=&quot;math-container&quot;&gt;$j.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now set &lt;span class=&quot;math-container&quot;&gt;$d=0$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; will index the depth in the graph) and set &lt;span class=&quot;math-container&quot;&gt;$L_d=\emptyset$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$L_d$&lt;/span&gt; will be the set of nodes at depth &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;). For every &lt;span class=&quot;math-container&quot;&gt;$n\in N,$&lt;/span&gt; add &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$L_d$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$P_n=\emptyset.$&lt;/span&gt; Once that scan is done, replace &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$N\backslash L_d$&lt;/span&gt; and for each remaining &lt;span class=&quot;math-container&quot;&gt;$n\in N$&lt;/span&gt; replace &lt;span class=&quot;math-container&quot;&gt;$P_n$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$P_n \backslash L_d.$&lt;/span&gt; Increment &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; by one and repeat until &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is empty.&lt;/p&gt;&#xA;&lt;p&gt;Note: This should work for any layered digraph. For a directed tree, &lt;span class=&quot;math-container&quot;&gt;$\vert P_n \vert$&lt;/span&gt; will never exceed 1.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-01-21T20:19:24.863" LastActivityDate="2023-01-21T20:19:24.863" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9785" PostTypeId="2" ParentId="841" CreationDate="2023-01-22T09:06:37.477" Score="2" Body="&lt;p&gt;I just want to mention the solvers that have been produced in recent years in the remit of the PACE (Parameterized Algorithms and Computational Experiments) challenge, see &lt;a href=&quot;https://pacechallenge.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pacechallenge.org/&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This competition asks participants to produce fast exact and/or heuristic solvers for various NP-hard graph problems. Thus far the challenges have been on treewidth, (directed) feedback vertex set, vertex cover, steiner tree, cluster editing, treedepth, and hypertreewidth.&lt;/p&gt;&#xA;&lt;p&gt;These problems are not commonly encountered OR problems in the way that something like VRP is, but they may well occur as subroutines in a larger OR solution framework.&lt;/p&gt;&#xA;&lt;p&gt;The winning solvers produced each year tend to be extremely good, and a significant advance on what has come before, so they are definitely worth considering if such problems cross your path in OR.&lt;/p&gt;&#xA;" OwnerUserId="9673" LastActivityDate="2023-01-22T09:06:37.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9786" PostTypeId="1" CreationDate="2023-01-22T12:53:02.243" Score="5" ViewCount="144" Body="&lt;p&gt;I would like to know if there is an efficient way to formulate simple cycles on the Graph/Digraph. Let's say, there is a grid-form graph for which each vertex is only connected to a limited number of vertices as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/08QMb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/08QMb.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Some of the single cycles can be counted as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1: [1,2,5,6,1]&#xA;2: [6,5,8,9,6]&#xA;3: [2,3,4,5,2]&#xA;4: [5,6,9,8,5]&#xA;5: [3,4,7,8,5,2,3] &#xA;6: ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried some algorithms to find cycles on the graph to make what I want, and by applying some sort of filters, I can get the results, but it is a bit hard to represent that as a general approach. For example, finding the cycles only with &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; vertices. &lt;em&gt;&lt;strong&gt;My question: is there any way to represent such a problem as a MILP?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-01-26T17:47:08.560" LastActivityDate="2023-01-26T18:06:14.837" Title="Number of simple cycles on the graph" Tags="|mixed-integer-programming|graphs|hamiltonian-path|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9787" PostTypeId="1" CreationDate="2023-01-22T16:12:18.800" Score="1" ViewCount="274" Body="&lt;p&gt;I'm using pyomo to model a system consisting of subsystems which themselves consist of subsystems. Therefore, I use nested Blocks. Every block is described in a separate file. I want to be able to switch which models I use as subsystems.&#xA;I'm wondering whether it's possible to give the outermost model the inner models as arguments. While this is straight forward for one level of hierarchy (a block in the outermost model), I can't seem to find a way to make two levels of hierarchy work (pass the innermost model to the 1st level).&#xA;This would be very handy as I could change which inner models I load without changing the &lt;em&gt;import model from file&lt;/em&gt; in the model file's headers all the time.&lt;/p&gt;&#xA;&lt;p&gt;Here is an example code that shows my approach. For what I want to do I would need to be able to pass non-model related arguments to the pyo.Block function, which doesn't seem to work.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;## model file&#xA;import pyomo.environ as pyo&#xA;&#xA;def func_model(subblock,subsubblock):&#xA;    model = pyo.AbstractModel()&#xA;    model.idx = pyo.RangeSet()&#xA;    model.subblock = pyo.Block(model.idx, **subsubblock**, rule = subblock)&#xA;    return model&#xA;&#xA;### script&#xA;&#xA;def subblock(submodel,idx, **subsubblock**):&#xA;    submodel.jdx = pyo.RangeSet()&#xA;    submodel.subsubblock = pyo.Block(submodel.jdx, rule = subsubblock)&#xA;    return submodel&#xA;&#xA;def subsubblock(subsubmodel):&#xA;    subsubmodel.kdx = pyo.RangeSet()&#xA;    return subsubmodel&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now I pass the data from a dict&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;data = {&#xA;    None: {&#xA;        &amp;quot;idx&amp;quot; : {None: [1,2]},&#xA;        &amp;quot;subblock&amp;quot;: {&#xA;            &amp;quot;jdx&amp;quot;: {None: [1]},&#xA;            &amp;quot;subsubblock&amp;quot;: {&#xA;                &amp;quot;kdx&amp;quot;: {None: [1,2,3]}&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and create the instance&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = func_model(subblock, subsubblock)&#xA;&#xA;instance = model.create_instance(data)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now checking the model.pprint() results in&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;2 Set Declarations&#xA;    subblock_index : Size=1, Index=None, Ordered=True&#xA;        Key  : Dimen : Domain               : Size : Members&#xA;        None :     2 : idx*subblock_index_1 :    0 :      {}&#xA;    subblock_index_1 : Size=1, Index=None, Ordered=Insertion&#xA;        Key  : Dimen : Domain : Size : Members&#xA;        None :     1 :    Any :    1 : {None,}&#xA;&#xA;2 RangeSet Declarations&#xA;    idx : Dimen=1, Size=0, Bounds=(None, None)&#xA;        Key  : Finite : Members&#xA;        None :   True :      []&#xA;    kdx : Dimen=1, Size=0, Bounds=(None, None)&#xA;        Key  : Finite : Members&#xA;        None :   True :      []&#xA;&#xA;1 Block Declarations&#xA;    subblock : Size=0, Index=subblock_index, Active=True&#xA;&#xA;5 Declarations: idx subblock_index_1 subblock_index subblock kdx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So the nesting didn't work.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;As pointed out by jsiirola, nesting in combination with abstract models can get very cumbersome.&#xA;So I tried to model it using concrete models and nest the blocks &amp;quot;by hand&amp;quot;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;&#xA;def func_model():&#xA;    model = pyo.AbstractModel()&#xA;    model.idx_lb = pyo.Param()&#xA;    model.idx_ub = pyo.Param()&#xA;    model.idx = pyo.RangeSet(model.idx_lb, model.idx_ub)&#xA;    #model.subblock = pyo.Block(model.idx, rule = subblock)&#xA;    return model&#xA;&#xA;def subblock():&#xA;    submodel = pyo.AbstractModel()&#xA;    submodel.jdx_ub = pyo.Param()&#xA;    submodel.jdx = pyo.RangeSet(submodel.jdx_ub)&#xA;    #submodel.subsubblock = pyo.Block(submodel.jdx, rule = subsubblock)&#xA;    return submodel&#xA;&#xA;def subsubblock():&#xA;    subsubmodel = pyo.AbstractModel()&#xA;    subsubmodel.kdx_ub = pyo.Param()&#xA;    subsubmodel.kdx = pyo.RangeSet(subsubmodel.kdx_ub)&#xA;    return subsubmodel&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then, creating the subsubmodel&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ssb_data = {None: {&amp;quot;kdx_ub&amp;quot; : {None: 3}}}&#xA;ss_model = subsubblock()&#xA;ss_instance = ss_model.create_instance(ssb_data)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and adding this into the submodel&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import copy&#xA;sb_data = {None: {&amp;quot;jdx_ub&amp;quot;: {None: 2}}}&#xA;s_model = subblock()&#xA;s_instance = s_model.create_instance(sb_data)&#xA;&#xA;def copy_func(m,j):&#xA;    return copy.deepcopy(ss_instance)&#xA;&#xA;s_instance.subsubblock = pyo.Block(s_instance.jdx, rule = copy_func)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I would also do the same for nesting the subblock into the model.&lt;/p&gt;&#xA;&lt;p&gt;I think this is much better than the cumbersome abstract model instantiation I would normally do. However, in my real example I have a nested model that is interconnected. E.g., my (outermost) model puts constraints on the subblock's parameters. Is there any way to handle this with the upper approach?&lt;/p&gt;&#xA;" OwnerUserId="11114" LastEditorUserId="11114" LastEditDate="2023-01-23T10:11:33.657" LastActivityDate="2023-01-23T10:11:33.657" Title="variable use of nested blocks in pyomo" Tags="|modeling|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9788" PostTypeId="2" ParentId="9787" CreationDate="2023-01-22T21:43:56.357" Score="2" Body="&lt;p&gt;This question is a partial duplicate of &lt;a href=&quot;https://stackoverflow.com/questions/75136387/dependent-component-cant-be-instantiated-in-abstractmodel-with-pyomo-5-7-3&quot;&gt;https://stackoverflow.com/questions/75136387/dependent-component-cant-be-instantiated-in-abstractmodel-with-pyomo-5-7-3&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;First, I would generally recommend the use of &lt;code&gt;ConcreteModel&lt;/code&gt; and not &lt;code&gt;AbstractModel&lt;/code&gt; for structured (hierarchical) Pyomo models: As you will see, the data structure for the &lt;code&gt;AbstractModel&lt;/code&gt; can get rather cumbersome.  Further, it is frequently more natural (both for the modeler and for Pyomo) for these models to load / process the data first and then construct the (concrete) Pyomo model in a single pass.  For your use case, it might be more natural for each subsystem to be constructed by a function, and you can then pass the constructor for the sub-sub system as a functor argument to the subsystem's construction function that returns the fully-constructed subsystem.&lt;/p&gt;&#xA;&lt;p&gt;As for your example (based on abstract models) There are a couple issues here:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Current versions of Pyomo do not support initializing RangeSet objects from data.  Instead, the RangeSet bounds / step should be defined using Param components (and then the Param components can be initialized from data).&lt;/li&gt;&#xA;&lt;li&gt;The data structure for initializing abstract components is a dict that maps component indexed to the initialization data.  For scalar components, the data structure should have a key &amp;quot;&lt;code&gt;None&lt;/code&gt;&amp;quot; for the implicit index.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Putting that together, a working implementation of your model would be something like:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;## model file&#xA;import pyomo.environ as pyo&#xA;&#xA;def func_model(subblock, subsubblock):&#xA;    model = pyo.AbstractModel()&#xA;    model.idx_lb = pyo.Param()&#xA;    model.idx_ub = pyo.Param()&#xA;    model.idx = pyo.RangeSet(model.idx_lb, model.idx_ub)&#xA;    model.subblock = pyo.Block(model.idx, rule = subblock)&#xA;    return model&#xA;&#xA;### script&#xA;&#xA;def subblock(submodel, idx):&#xA;    submodel.jdx_ub = pyo.Param()&#xA;    submodel.jdx = pyo.RangeSet(submodel.jdx_ub)&#xA;    submodel.subsubblock = pyo.Block(submodel.jdx, rule = subsubblock)&#xA;    return submodel&#xA;&#xA;def subsubblock(subsubmodel):&#xA;    subsubmodel.kdx_ub = pyo.Param()&#xA;    subsubmodel.kdx = pyo.RangeSet(subsubmodel.kdx_ub)&#xA;    return subsubmodel&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;with data&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;data = {&#xA;    None: {&#xA;        &amp;quot;idx_lb&amp;quot; : {None: 1},&#xA;        &amp;quot;idx_ub&amp;quot; : {None: 2},&#xA;        &amp;quot;subblock&amp;quot;: {&#xA;            1: {&#xA;                &amp;quot;jdx_ub&amp;quot;: {None: 1},&#xA;                &amp;quot;subsubblock&amp;quot;: {&#xA;                    1: {&#xA;                        &amp;quot;kdx_ub&amp;quot;: {None: 3},&#xA;                    },&#xA;                },&#xA;            },&#xA;            2: {&#xA;                &amp;quot;jdx_ub&amp;quot;: {None: 1},&#xA;                &amp;quot;subsubblock&amp;quot;: {&#xA;                    1: {&#xA;                        &amp;quot;kdx_ub&amp;quot;: {None: 3},&#xA;                    },&#xA;                },&#xA;            },&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;that when run, would give:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; func_model(subblock, subsubblock).create_instance(data).pprint()&#xA;1 RangeSet Declarations&#xA;    idx : Dimen=1, Size=2, Bounds=(1, 2)&#xA;        Key  : Finite : Members&#xA;        None :   True :   [1:2]&#xA;&#xA;2 Param Declarations&#xA;    idx_lb : Size=1, Index=None, Domain=Any, Default=None, Mutable=False&#xA;        Key  : Value&#xA;        None :     1&#xA;    idx_ub : Size=1, Index=None, Domain=Any, Default=None, Mutable=False&#xA;        Key  : Value&#xA;        None :     2&#xA;&#xA;1 Block Declarations&#xA;    subblock : Size=2, Index=idx, Active=True&#xA;        subblock[1] : Active=True&#xA;            1 RangeSet Declarations&#xA;                jdx : Dimen=1, Size=1, Bounds=(1, 1)&#xA;                    Key  : Finite : Members&#xA;                    None :   True :     [1]&#xA;&#xA;            1 Param Declarations&#xA;                jdx_ub : Size=1, Index=None, Domain=Any, Default=None, Mutable=False&#xA;                    Key  : Value&#xA;                    None :     1&#xA;&#xA;            1 Block Declarations&#xA;                subsubblock : Size=1, Index=subblock[1].jdx, Active=True&#xA;                    subblock[1].subsubblock[1] : Active=True&#xA;                        1 RangeSet Declarations&#xA;                            kdx : Dimen=1, Size=3, Bounds=(1, 3)&#xA;                                Key  : Finite : Members&#xA;                                None :   True :   [1:3]&#xA;&#xA;                        1 Param Declarations&#xA;                            kdx_ub : Size=1, Index=None, Domain=Any, Default=None, Mutable=False&#xA;                                Key  : Value&#xA;                                None :     3&#xA;&#xA;                        2 Declarations: kdx_ub kdx&#xA;&#xA;            3 Declarations: jdx_ub jdx subsubblock&#xA;        subblock[2] : Active=True&#xA;            1 RangeSet Declarations&#xA;                jdx : Dimen=1, Size=1, Bounds=(1, 1)&#xA;                    Key  : Finite : Members&#xA;                    None :   True :     [1]&#xA;&#xA;            1 Param Declarations&#xA;                jdx_ub : Size=1, Index=None, Domain=Any, Default=None, Mutable=False&#xA;                    Key  : Value&#xA;                    None :     1&#xA;&#xA;            1 Block Declarations&#xA;                subsubblock : Size=1, Index=subblock[2].jdx, Active=True&#xA;                    subblock[2].subsubblock[1] : Active=True&#xA;                        1 RangeSet Declarations&#xA;                            kdx : Dimen=1, Size=3, Bounds=(1, 3)&#xA;                                Key  : Finite : Members&#xA;                                None :   True :   [1:3]&#xA;&#xA;                        1 Param Declarations&#xA;                            kdx_ub : Size=1, Index=None, Domain=Any, Default=None, Mutable=False&#xA;                                Key  : Value&#xA;                                None :     3&#xA;&#xA;                        2 Declarations: kdx_ub kdx&#xA;&#xA;            3 Declarations: jdx_ub jdx subsubblock&#xA;&#xA;4 Declarations: idx_lb idx_ub idx subblock&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10026" LastEditorUserId="10026" LastEditDate="2023-01-22T21:54:00.930" LastActivityDate="2023-01-22T21:54:00.930" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9789" PostTypeId="1" AcceptedAnswerId="9793" CreationDate="2023-01-23T03:27:10.840" Score="7" ViewCount="1284" Body="&lt;p&gt;My question is related to a previous one: &lt;a href=&quot;https://or.stackexchange.com/questions/2725/dedicated-solver-for-convex-problems&quot;&gt;Dedicated solver for convex problems&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;To minimize a convex function of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$~f(x_i) = \left[ C + mx_i + \frac{s}{x_i+t}  \right]^p $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with various parameters &lt;span class=&quot;math-container&quot;&gt;$~C$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t~$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$~p$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$~$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$~0 \le x_i \le 1~$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$~p \ge 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(By generating a graph of the function, I ensure that the function &lt;span class=&quot;math-container&quot;&gt;$f(x_i)$&lt;/span&gt; is convex.  &lt;span class=&quot;math-container&quot;&gt;$~$&lt;/span&gt;The constraints are all linear.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; (5:30am GMT January 25): Apologies for not bringing this up earlier, since I assumed that it wouldn't make a difference.  The variable actually is a vector &lt;span class=&quot;math-container&quot;&gt;$X =$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\cdots$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt;).. The objective function is:&lt;/p&gt;&#xA;&lt;p&gt;Minimise &lt;span class=&quot;math-container&quot;&gt;$~Z(X) = \sum_{i=1}^n Z_i = \sum_{i=1}^n f(x_i)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If each &lt;span class=&quot;math-container&quot;&gt;$f(x_i)$&lt;/span&gt; is convex, then their sum &lt;span class=&quot;math-container&quot;&gt;$Z(X)$&lt;/span&gt; is also convex.&lt;/p&gt;&#xA;&lt;p&gt;My question is, which solvers are well-suited to minimize such a convex function (subject to linear constraints)?&lt;/p&gt;&#xA;&lt;p&gt;Of all solvers at &lt;a href=&quot;https://neos-server.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;NEOS&lt;/a&gt;, only MINOS seems to come close, and even this is not perfect (sometimes returns errors for instances for which manually I'm able to obtain optimal feasible solutions).&lt;/p&gt;&#xA;" OwnerUserId="7218" LastEditorUserId="7218" LastEditDate="2023-01-25T05:30:38.137" LastActivityDate="2024-02-29T07:01:17.353" Title="Solver for convex optimization with exponent in the objective function" Tags="|solver|convex-optimization|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9790" PostTypeId="2" ParentId="9789" CreationDate="2023-01-23T03:47:06.827" Score="5" Body="&lt;p&gt;Best way is to apply log to the function as optimal solution to log of a function is the same for the function.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \log f = p[\log (C(x+t)+ mx(x+t)+s)-\log(x+t)]$&lt;/span&gt;&lt;br /&gt;&#xA;Then you have to get the actual solution by the exp of &lt;span class=&quot;math-container&quot;&gt;$\log$&lt;/span&gt; base used (e, 2 or 10).&lt;/p&gt;&#xA;&lt;p&gt;However log functions need to be transformed into auxillary variables. You can also use the exp with &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; but these also have to expressed as additional variables using addition constraints. Here is the link to suggested piecewise solution by &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/10481250723217-How-to-add-log-and-exponential-term-in-objective-function-&quot; rel=&quot;noreferrer&quot;&gt;Gurobi&lt;/a&gt;. Gurobi provides constraints as model methods like addGenConstrLog() and addGenConstrExp(). These are available at Gurobi's &lt;a href=&quot;https://www.gurobi.com/documentation/10.0/refman/py_model.html&quot; rel=&quot;noreferrer&quot;&gt;reference guide&lt;/a&gt;.&#xA;Solvers won't have a problem with 2nd degree &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-23T03:54:28.823" LastActivityDate="2023-01-23T03:54:28.823" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9791" PostTypeId="2" ParentId="9780" CreationDate="2023-01-23T08:45:29.383" Score="2" Body="&lt;p&gt;If you would like to use python to draw the decision tree as shown above, you can use &lt;em&gt;&lt;strong&gt;&lt;a href=&quot;https://networkx.org/documentation/stable/tutorial.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Networkx&lt;/a&gt;&lt;/strong&gt;&lt;/em&gt; package to labeling or scoring the tree by using the &lt;a href=&quot;https://networkx.org/documentation/stable/_modules/networkx/relabel.html#relabel_nodes&quot; rel=&quot;nofollow noreferrer&quot;&gt;relabel_nodes()&lt;/a&gt; method as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The original tree:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ikTXL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ikTXL.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The labeled tree:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lPG2u.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lPG2u.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;you can use any labale or score to draw the graph. I hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-01-23T08:45:29.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9792" PostTypeId="2" ParentId="9789" CreationDate="2023-01-23T09:11:14.817" Score="6" Body="&lt;p&gt;Use Ipopt and a modeling language. For example, JuMP: &lt;a href=&quot;https://jump.dev/JuMP.jl/stable/tutorials/nonlinear/introduction/&quot; rel=&quot;noreferrer&quot;&gt;https://jump.dev/JuMP.jl/stable/tutorials/nonlinear/introduction/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;julia&amp;gt; using JuMP, Ipopt&#xA;&#xA;julia&amp;gt; model = Model(Ipopt.Optimizer)&#xA;A JuMP Model&#xA;Feasibility problem with:&#xA;Variables: 0&#xA;Model mode: AUTOMATIC&#xA;CachingOptimizer state: EMPTY_OPTIMIZER&#xA;Solver name: Ipopt&#xA;&#xA;julia&amp;gt; set_silent(model)&#xA;&#xA;julia&amp;gt; @variable(model, 0 &amp;lt;= x &amp;lt;= 1)&#xA;x&#xA;&#xA;julia&amp;gt; C, m, s, t, p = 1, 1, 1, 0.1, 3&#xA;(1, 1, 1, 0.1, 3)&#xA;&#xA;julia&amp;gt; @NLobjective(model, Min, (C + m * x + s / (x + t))^p)&#xA;&#xA;julia&amp;gt; optimize!(model)&#xA;&#xA;julia&amp;gt; value(x)&#xA;0.8999994186940709&#xA;&#xA;julia&amp;gt; objective_value(model)&#xA;24.389000000008522&#xA;&#xA;julia&amp;gt; (C + m * value(x) + s / (value(x) + t))^p&#xA;24.389000000008522&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="804" LastActivityDate="2023-01-23T09:11:14.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9793" PostTypeId="2" ParentId="9789" CreationDate="2023-01-23T09:21:41.183" Score="12" Body="&lt;p&gt;You are missing some details for the claimed convexity of &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;. I will assume that you meant to say convex on the domain &lt;span class=&quot;math-container&quot;&gt;$C+mx+\frac{s}{x+t} \geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x+t \geq 0$&lt;/span&gt;. In this case the epigraph of &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; has conic normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;&amp;amp;f \geq \left(C+mx+\frac{s}{x+t}\right)^p\\\Leftrightarrow&#xA;&amp;amp;f \geq \left(C+mx+y\right)^p,\quad y \geq \frac{s}{x+t},\\\Leftrightarrow&#xA;&amp;amp;f \geq z^p,\quad z=C+mx+y,\quad y \geq \frac{s}{x+t},\\\Leftrightarrow&#xA;&amp;amp;f \geq |z|^p,\quad z=C+mx+y \geq 0,\quad y (x+t) \geq s.&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the last deduction adds in the missing convexity details. You can now input the representation in any Disciplined Convex Programming language using &lt;strong&gt;one power cone&lt;/strong&gt; for &lt;span class=&quot;math-container&quot;&gt;$f \geq |z|^p$&lt;/span&gt; (see, e.g, &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/powo.html#powers&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.mosek.com/modeling-cookbook/powo.html#powers&lt;/a&gt;), and &lt;strong&gt;one rotated quadratic cone&lt;/strong&gt; for &lt;span class=&quot;math-container&quot;&gt;$y (x+t) \geq s$&lt;/span&gt; (see, e.g., &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/cqo.html#rotated-quadratic-cones&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.mosek.com/modeling-cookbook/cqo.html#rotated-quadratic-cones&lt;/a&gt;). These two cones are so simple that their presence will hardly affect the interior-point algorithm from a complexity point of view.&lt;/p&gt;&#xA;&lt;p&gt;As a last remark, note that minimizing &lt;span class=&quot;math-container&quot;&gt;$\left(C+mx+\frac{s}{x+t}\right)^p$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$p\geq 1$&lt;/span&gt; is equivalent to just minimizing &lt;span class=&quot;math-container&quot;&gt;$C+mx+\frac{s}{x+t}$&lt;/span&gt;. Hence, if &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; really is all there is to your objective function, you will get the same optimal solution by just minimizing &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. This will allow you to get rid of the epigraph variable &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and the power cone that constrain it.&lt;/p&gt;&#xA;&lt;p&gt;As to the question of which solver to use with Disciplined Convex Programming, I refer to this answer to your previous question:&#xA;&lt;a href=&quot;https://or.stackexchange.com/a/2727&quot;&gt;https://or.stackexchange.com/a/2727&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2023-01-24T08:09:29.057" LastActivityDate="2023-01-24T08:09:29.057" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9794" PostTypeId="2" ParentId="9786" CreationDate="2023-01-23T20:17:44.613" Score="3" Body="&lt;p&gt;Using a reasonably straightforward looping approach, I found a total of 13 distinct simple cycles in your graph:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[1, 2, 5, 4, 7, 8, 9, 6, 1]&#xA;[1, 2, 3, 4, 7, 8, 9, 6, 1]&#xA;[1, 2, 3, 4, 5, 8, 9, 6, 1]&#xA;[1, 2, 5, 8, 9, 6, 1]&#xA;[1, 2, 3, 4, 5, 6, 1]&#xA;[1, 2, 3, 4, 7, 8, 5, 6, 1]&#xA;[1, 2, 5, 6, 1]&#xA;[2, 3, 4, 5, 2]&#xA;[2, 3, 4, 7, 8, 5, 2]&#xA;[2, 3, 4, 7, 8, 9, 6, 5, 2]&#xA;[4, 5, 8, 7, 4]&#xA;[4, 5, 6, 9, 8, 7, 4]&#xA;[5, 6, 9, 8, 5]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The logic is fairly straightforward. We assume that the start of any cycle is the lowest index node in it. So we find all cycles starting at 1, then all cycles starting at 2 noting that they cannot contain 1, then all cycles starting at 3 (and not containing 1 or 2), etc. The cycles are found the usual way: each edge incident at the start node forms a new partial path; each partial path spawns more partial paths by extending it with each edge incident at the last node; an extension is discarded if it leads to either a node less than the start node or a node already on the path (and not the start); and an extension that returns to the start node forms a complete cycle.&lt;/p&gt;&#xA;&lt;p&gt;This still results in duplication of paths (paths show up both &amp;quot;clockwise&amp;quot; and &amp;quot;counterclockwise&amp;quot;), so we check completed paths to see if they are duplicates.&lt;/p&gt;&#xA;&lt;p&gt;The Java code to do this took about 11 ms., including building the graph structure, processing and printing. I don't see any way to build and solve a MILP model that finds all simple cycles in that short a time.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-01-23T22:21:48.570" LastActivityDate="2023-01-23T22:21:48.570" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9795" PostTypeId="2" ParentId="9772" CreationDate="2023-01-24T10:29:32.857" Score="2" Body="&lt;p&gt;Here is an alternative to RobPratt's precise solution.&lt;/p&gt;&#xA;&lt;p&gt;First, compute all &lt;a href=&quot;https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.cycles.simple_cycles.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;simple cycles&lt;/a&gt; of the graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,A)$&lt;/span&gt; (the graph can be directed in an arbitrary direction). Then, compute &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;-cycles and &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;-cycles, by merging cycles together if they share at least one common vertex (hence guaranteeing contiguity constraints). Let &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt; be the set of all these cycles. The cost of cycle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is denoted by &lt;span class=&quot;math-container&quot;&gt;$C_k$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;These cycles are now the variables of the problem, let &lt;span class=&quot;math-container&quot;&gt;$x_k \in \{0,1\}$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if cycle &lt;span class=&quot;math-container&quot;&gt;$k \in \Omega$&lt;/span&gt; is used in the solution. Let decision variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; represent &lt;span class=&quot;math-container&quot;&gt;$\max_k \; C_k x_k$&lt;/span&gt;. The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each edge must be covered exactly once by a given cycle:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{k \in \Omega, (i,j)\in k}x_k =1\quad \forall (i,j) \in A&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is defined as the maximum length of the selected cycles:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;C_k x_k \le z \quad \forall k \in \Omega&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;In our case, we can only use &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; cycles:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{k\in \Omega}x_k = 3&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Some comments:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;With the above formulation, I am able to find the optimal solution of&#xA;the example in the question (in about 2 sec with CBC, and 0.1 sec with CPLEX). A simulation with some (non optimized) code can be found &lt;a href=&quot;https://github.com/Kuifje02/or.stackexchange-simulations/blob/main/kCPP.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The solution is not unique.&lt;/li&gt;&#xA;&lt;li&gt;This is nothing more than a Dantzig-Wolfe decomposition of RobPratt's formulation. The contiguity constraints (and &amp;quot;even degree&amp;quot; constraints) are handled in a pre-processing phase, which  makes the model a bit lighter.&lt;/li&gt;&#xA;&lt;li&gt;However, in the general case, computing cycles up to &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;-cycles is not sufficient to guarantee that the optimal solution is reached.&lt;/li&gt;&#xA;&lt;li&gt;One could compute the appropriate cycles dynamically with a column generation procedure (which would complicate the approach quite a bit) and either use branch-and-price (optimal), or solve the restricted master problem once all good columns have been found (heuristic).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-01-24T11:11:54.270" LastActivityDate="2023-01-24T11:11:54.270" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9796" PostTypeId="1" CreationDate="2023-01-24T11:33:06.923" Score="2" ViewCount="112" Body="&lt;p&gt;For a study, I need to make runs to evaluate and compare performance of various models. To evaluate them I need to obtain their running times. I wonder if there is a rule to when to start and end timing. For instance, for the problems I also generate data randomly. Should I start prior to that random data generation, should I start timing between the time after generating data and defining the model, or should I only time how fast is the &lt;code&gt;.solve()&lt;/code&gt; command? Or any other time?&lt;/p&gt;&#xA;&lt;p&gt;I am using CPLEX on Python 3.10. For timing, I use &lt;code&gt;time.time()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user5245" LastEditorUserId="491" LastEditDate="2023-01-24T15:31:19.303" LastActivityDate="2023-01-25T01:46:33.887" Title="Runtimes for benchmarking" Tags="|benchmark|runtime|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9797" PostTypeId="2" ParentId="9796" CreationDate="2023-01-24T15:43:29.143" Score="3" Body="&lt;p&gt;I agree with the comment by @Kuifje: record the solve time as this is what you are concerned with.&lt;/p&gt;&#xA;&lt;p&gt;However, if you are comparing to some other method (e.g. a smaller MIP with weaker bound or a tailored algorithm) then you might also want to record the “build time” as the total wait time for the user may depend on this as well (new big model solves fast but builds slow, and old small model solves slowly but builds fast, for instance).&lt;/p&gt;&#xA;&lt;p&gt;Generally, I try to time way too many things when testing, because it might turn out to reveal some insights I hadn’t thought about a priori. Recently we found a bottleneck in a project to be the communication with cplex in a callback: retrieving solution information for variables took up 80% of the time in the separation routine.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2023-01-24T15:43:29.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9798" PostTypeId="2" ParentId="9796" CreationDate="2023-01-25T01:41:26.783" Score="1" Body="&lt;p&gt;In addition to the above answers I'd also look at both solver performance and model performance. Is the model itself taking time to build across other solvers. Timeit() will help. &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360013420111-How-do-I-improve-the-time-to-build-my-model-&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here's&lt;/a&gt; some references on checking model performance. Model build time may depend upon both logic in constraints, model size, presolving if redundant variables present, data structures used etc &lt;br /&gt;&#xA;Then comes question of solver's performance. For that, solvers output log or runtime queries can provide useful info like optimality gap/MIP gap covered (difference between primal and dual values), nodes created, nodes and branches explored at different checkpoints. This page provides important&#xA;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/sections/360009927972-Performance&quot; rel=&quot;nofollow noreferrer&quot;&gt;references&lt;/a&gt; for Gurobi (the 3rd link) but you should get the idea.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-25T01:46:33.887" LastActivityDate="2023-01-25T01:46:33.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9799" PostTypeId="1" CreationDate="2023-01-25T12:19:15.440" Score="6" ViewCount="246" Body="&lt;p&gt;I am researching the robust version of a problem. I have managed to produce an Integer programming formulation which solves the problem with perfect knowledge. From my research on the topic one can define uncertainty of the parameters by defining the uncertainty to come from a well-known uncertainty set. (e.g. Box, Interval, Ellipsoid) I am very new to this topic and most of the resources that I found online are not very helpful.&lt;/p&gt;&#xA;&lt;p&gt;Can you recommend me a starting point (articles, papers, books repositories) that is more beginner level in this area?&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="491" LastEditDate="2023-01-25T15:20:15.767" LastActivityDate="2023-01-30T05:52:12.643" Title="Robust optimization for IP formulation" Tags="|mixed-integer-programming|reference-request|literature-research|robust-optimization|uncertainty|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9800" PostTypeId="2" ParentId="9799" CreationDate="2023-01-25T15:57:56.103" Score="5" Body="&lt;p&gt;I think this is a relatively easy but still general paper to start with: &lt;a href=&quot;https://arxiv.org/pdf/1501.02634.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://arxiv.org/pdf/1501.02634.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="601" LastActivityDate="2023-01-25T15:57:56.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9802" PostTypeId="2" ParentId="5068" CreationDate="2023-01-26T00:36:43.820" Score="5" Body="&lt;p&gt;With SCIP 8, you can either download the program from &lt;a href=&quot;https://scipopt.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://scipopt.org/&lt;/a&gt; and add it to your search path, or you can install using Anaconda via &lt;code&gt;conda install scip&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Once SCIP is installed, you should be able to run &lt;code&gt;pyomo --solver scip --solver-io nl model.py&lt;/code&gt; or use &lt;code&gt;SolverFactory('scip', solver_io='nl')&lt;/code&gt; in your Python code.&lt;/p&gt;&#xA;&lt;p&gt;If you leave off the solver-io option, Pyomo will try to use a SCIP-specific communication method, which didn't work for me. But specifying &lt;code&gt;--solver-io nl&lt;/code&gt; forces Pyomo to run SCIP in AMPL/ASL mode, which works fine.&lt;/p&gt;&#xA;&lt;p&gt;You may also be able to get this to run without putting &lt;code&gt;scip&lt;/code&gt; in your search path, by specifying the full path to the program instead of just &lt;code&gt;scip&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5262" LastEditorUserId="5262" LastEditDate="2023-01-27T22:22:05.980" LastActivityDate="2023-01-27T22:22:05.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9803" PostTypeId="1" AcceptedAnswerId="9805" CreationDate="2023-01-26T13:29:55.103" Score="3" ViewCount="457" Body="&lt;p&gt;I am trying to find a suitable paradigm under which my discrete optimisation problem falls into. This looks similar to integer programming, so the goal is to find a binary vector &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt;. However, there are two differences:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Costs vector &lt;span class=&quot;math-container&quot;&gt;$c^T$&lt;/span&gt; is dynamic and depends on &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt;, so the minimisation objective is &lt;span class=&quot;math-container&quot;&gt;$c^T(\bar{x})\bar{x}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Instead of a constraint per resource, there is a constraint on the total amount of resources, so &lt;span class=&quot;math-container&quot;&gt;$\sum_i^m\sum_j^na_{ij}\bar{x}_i&amp;lt;b$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Can this still be expressed as a binary integer programming problem? If so, how, and if not, would the common heuristic methods for the solution of IP still apply to this setting? Or is there another type of setting which this problem falls under, and I should research that direction more?&lt;/p&gt;&#xA;" OwnerUserId="11133" LastEditorUserId="123" LastEditDate="2023-01-26T14:26:12.120" LastActivityDate="2023-01-26T16:29:19.597" Title="Binary integer programming with dynamic costs and total resource constraint" Tags="|integer-programming|constraint|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9804" PostTypeId="2" ParentId="9803" CreationDate="2023-01-26T14:33:15.753" Score="4" Body="&lt;p&gt;As for &lt;span class=&quot;math-container&quot;&gt;$c^T$&lt;/span&gt; if the function &lt;span class=&quot;math-container&quot;&gt;$c(x_i)$&lt;/span&gt; is nonlinear you can always use something like &lt;span class=&quot;math-container&quot;&gt;$c_i(0)(1-x_i) + c_i(1)x_i$&lt;/span&gt;, so it takes either value depending upon &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-26T15:42:51.027" LastActivityDate="2023-01-26T15:42:51.027" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9805" PostTypeId="2" ParentId="9803" CreationDate="2023-01-26T16:29:19.597" Score="4" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; be the dimension of &lt;span class=&quot;math-container&quot;&gt;$\bar{x}.$&lt;/span&gt; There are &lt;span class=&quot;math-container&quot;&gt;$M=2^N$&lt;/span&gt; possible values for &lt;span class=&quot;math-container&quot;&gt;$\bar{x}.$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; turns out to be a manageable number, you can reformulate as follows.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Enumerate the possible values of &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$\bar{x}^{(1)},\dots,\bar{x}^{(M)}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Compute the cost &lt;span class=&quot;math-container&quot;&gt;$\gamma_i=c(\bar{x}^{(i))})$&lt;/span&gt; of each combination.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use binary variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$i=1,\dots,M$&lt;/span&gt;) to select which value of &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; to use, with the constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_i y_i = 1.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The objective becomes minimization of &lt;span class=&quot;math-container&quot;&gt;$\sum_i \gamma_i y_i.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$n=1,\dots,N,$&lt;/span&gt; add the constraint &lt;span class=&quot;math-container&quot;&gt;$x_n = \sum_{i\in S_n}y_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$S_n = \lbrace i \in \lbrace 1,\dots,M\rbrace : \bar{x}^{(i)}_n = 1 \rbrace.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Your resource constraint is unchanged, other than that it must be a weak inequality (&lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; rather than &lt;span class=&quot;math-container&quot;&gt;$&amp;lt;$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-01-26T16:29:19.597" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9806" PostTypeId="2" ParentId="9786" CreationDate="2023-01-26T18:06:14.837" Score="2" Body="&lt;p&gt;With &lt;a href=&quot;https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.cycles.simple_cycles.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Johnson's algorithm&lt;/a&gt; from the networkx library, all 13 cycles are found in 0.0005 seconds:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7yS0s.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7yS0s.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2023-01-26T18:06:14.837" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9807" PostTypeId="2" ParentId="9799" CreationDate="2023-01-26T18:20:13.087" Score="2" Body="&lt;p&gt;you may check this &lt;a href=&quot;https://pubs.acs.org/doi/full/10.1021/ie200150p&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pubs.acs.org/doi/full/10.1021/ie200150p&lt;/a&gt; ,there are two other papers related to that, II and III, I hope you will find it useful.&lt;/p&gt;&#xA;" OwnerUserId="11004" LastEditorUserId="11004" LastEditDate="2023-01-30T05:52:12.643" LastActivityDate="2023-01-30T05:52:12.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9809" PostTypeId="2" ParentId="6174" CreationDate="2023-01-26T18:37:20.480" Score="2" Body="&lt;p&gt;The examples on &lt;a href=&quot;https://developers.google.com/optimization/routing/tsp&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization/routing/tsp&lt;/a&gt; seem, I believe, to be based on &lt;strong&gt;SYMMETRIC TSP&lt;/strong&gt;s (i.e., distance between nodes are equal regardless of direction).&lt;/p&gt;&#xA;&lt;p&gt;If you want it to act like as @Sune points out, you'll need an &lt;strong&gt;ASYMMETRIC TSP SOLVER&lt;/strong&gt; which yet adds another higher level of complexity to the problem.&lt;/p&gt;&#xA;" OwnerUserId="11135" LastActivityDate="2023-01-26T18:37:20.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9810" PostTypeId="1" CreationDate="2023-01-26T23:17:17.637" Score="2" ViewCount="99" Body="&lt;p&gt;I'm trying to solve an optimization model using Automated Benders with annotations using CPLEX library in C++. I've defined a master problem and N (number of supply nodes in my model's network) subproblems by annotations as below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; nI; i++)&#xA;{&#xA;    for (int t = aan[i]; t &amp;lt; nT; t++)&#xA;    {&#xA;        for (int g = 0; g &amp;lt; nG; g++)&#xA;        {&#xA;            cplex.setAnnotation(benders, ztig[t][i][g], 0);&#xA;        }&#xA;    }&#xA;&#xA;}&#xA;&#xA;for (int o = 0; o &amp;lt; nO; o++)&#xA;{&#xA;    for (int g = 0; g &amp;lt; nG; g++)&#xA;    {&#xA;        for (int d = 0; d &amp;lt; nD; d++)&#xA;        {&#xA;            cplex.setAnnotation(benders, ygod[g][o][d], o + 1);&#xA;            for (int t = aan[o]; t &amp;lt; To; t++)&#xA;            {&#xA;                for (int i = 0; i &amp;lt; nI; i++)&#xA;                {&#xA;                    if (Aij[o][i] == 1)&#xA;                    {&#xA;                        cplex.setAnnotation(benders, xtodijg[t][o][d][o][i][g], o + 1);&#xA;                    }&#xA;                    if (t &amp;gt;= tij[i][o])&#xA;                    {&#xA;                        if (Aij[i][o] == 1)&#xA;                        {&#xA;                            cplex.setAnnotation(benders, xtodijg[t - tij[i][o]][o][d][i][o][g], o + 1);&#xA;                        }&#xA;                    }&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After setting benders strategy parameter two &amp;quot;worker&amp;quot; mode, I ran the code and got &amp;quot;Microsoft C++ exception: IloCplex::Exception at memory location&amp;quot; exception in solve command (following part)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cplex.setParam(IloCplex::Param::Benders::Strategy, 2);&#xA;//cplex.setOut(env.getNullStream());&#xA;if (!cplex.solve()) {&#xA;    env.error() &amp;lt;&amp;lt; &amp;quot;Failed to optimize the Master Problem!!!&amp;quot; &amp;lt;&amp;lt; endl;&#xA;    throw (-1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Please note that model has been successfully solved by both Full mode of automated benders and branch &amp;amp; cut. So, I guess my annotations are not creating disjoint subproblems. I've checked the algebraic model many times, and subproblems are disjoint there. On the other hand, I couldn't find any mistakes in implementation of annotations. So does anyone has similar experience or ideas why its not working?&lt;/p&gt;&#xA;" OwnerUserId="11106" LastActivityDate="2024-03-28T19:31:05.237" Title="Automated Benders Using Annotations" Tags="|cplex|benders-decomposition|c++|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9811" PostTypeId="1" AcceptedAnswerId="9812" CreationDate="2023-01-27T00:59:01.797" Score="-1" ViewCount="91" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P =$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x, if U \geq U^{max} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ y, if U^{up} &amp;lt; U &amp;lt; U^{max} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ z, if U^{down} &amp;lt; U &amp;lt; U^{up} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \alpha, if U^{min} &amp;lt; U &amp;lt; U^{down} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \beta, if U \leq U^{min} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; are variables with bounds expressed as &lt;span class=&quot;math-container&quot;&gt;$P^{min} \leq P \leq P^{max}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$U^{min} \leq U \leq U^{max}$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$x, y, z, \alpha$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; represent nonlinear expressions. &lt;span class=&quot;math-container&quot;&gt;$U^{down}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U^{up}$&lt;/span&gt; are parameters.&lt;/p&gt;&#xA;" OwnerUserId="10869" LastEditorUserId="10869" LastEditDate="2023-01-27T01:15:13.897" LastActivityDate="2023-01-27T17:34:02.237" Title="How to apply smooth approximation to non-linear complementarity constraints?" Tags="|mixed-integer-programming|linear-programming|nonlinear-programming|logical-constraints|approximation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9812" PostTypeId="2" ParentId="9811" CreationDate="2023-01-27T01:25:10.887" Score="2" Body="&lt;p&gt;Need to check boundaries for &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$U^{min} \le U\le U^{max}$&lt;/span&gt; and then the first and last if conditions. Still define binary variables &lt;span class=&quot;math-container&quot;&gt;$\delta_x, \delta_y$&lt;/span&gt; and so on for each of the expressions. Add constraints&lt;br /&gt;&#xA;(1) &lt;span class=&quot;math-container&quot;&gt;$U-U^{max} \le M\delta_x$&lt;/span&gt;&lt;br /&gt;&#xA;(2) &lt;span class=&quot;math-container&quot;&gt;$U^{max}-U \le M(1-\delta_x)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(3) &lt;span class=&quot;math-container&quot;&gt;$U^{up} + e + M(\delta_y-1)\le U \le U^{max}+ e + M(1-\delta_y)$&lt;/span&gt;&lt;br /&gt;&#xA;Similarly,&lt;br /&gt;&#xA;(4) &lt;span class=&quot;math-container&quot;&gt;$U^{down} + e + M(\delta_z-1)\le U \le U^{up}+ e + M(1-\delta_z)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(5) &lt;span class=&quot;math-container&quot;&gt;$U^{min} + e + M(\delta_a-1)\le U \le U^{down}+ e + M(1-\delta_a)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(6) &lt;span class=&quot;math-container&quot;&gt;$U^{min}-U \le M\delta_b $&lt;/span&gt;&lt;br /&gt;&#xA;(7) &lt;span class=&quot;math-container&quot;&gt;$U-U^{min}\le M(1-\delta_b)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(8) &lt;span class=&quot;math-container&quot;&gt;$\delta_x + \delta_y + \delta_z + \delta_a + \delta_b = 1 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P = x\delta_x + y\delta_y +z\delta_z + \alpha\delta_a + \beta\delta_b $&lt;/span&gt;&lt;br /&gt;&#xA;where M and e are big/small numbers based on scale of the model\&lt;/p&gt;&#xA;&lt;p&gt;As suggested by Dr. Rob replacing the constraints (1-7) with a single one&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$U^{max}\delta_x + (U^{up}+e)\delta_y + (U^{down}+e)\delta_z + (U^{min}+e)\delta_a \le U \le (U^{max}-e)\delta_y + (U^{up}-e)\delta_z + (U^{down}-e)\delta_a + U^{min}\delta_b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If using continuous then define &lt;span class=&quot;math-container&quot;&gt;$0\le \delta\le 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\delta \in R^+$&lt;/span&gt; as SOS Type 1. For reference from &lt;a href=&quot;https://www.gurobi.com/documentation/10.0/refman/cpp_sos.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-27T17:34:02.237" LastActivityDate="2023-01-27T17:34:02.237" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9813" PostTypeId="2" ParentId="9811" CreationDate="2023-01-27T02:15:47.917" Score="3" Body="&lt;p&gt;Read&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.researchgate.net/publication/263734490_Smooth_Approximations_to_Nonlinear_Complementarity_Problems&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bintong CHen and Patrick T. Harker, &lt;em&gt;Smooth Approximations to Nonlinear Complementarity Problems&lt;/em&gt;, SIAM Journal on Optimization, 7(2), 403-320, 1997&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2023-01-27T02:15:47.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9814" PostTypeId="1" AcceptedAnswerId="9815" CreationDate="2023-01-27T15:35:48.097" Score="2" ViewCount="73" Body="&lt;p&gt;My experience with OR is pretty limited, so I apologize if I'm using any sort of bespoke terminology.&lt;/p&gt;&#xA;&lt;p&gt;I have a set of subsets &lt;span class=&quot;math-container&quot;&gt;${ \{ S_1,\cdots,S_m\}}$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n$&lt;/span&gt;, and corresponding functions &lt;span class=&quot;math-container&quot;&gt;$\{f_1,\cdots,f_m\}$&lt;/span&gt;, where the domain of &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Every set &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; can be understood as a hypercube in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n$&lt;/span&gt;; no discontinuities or funkiness happening there.&lt;/p&gt;&#xA;&lt;p&gt;Assume that for every set &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt;, across every dimension of the vector space, your index variable &lt;span class=&quot;math-container&quot;&gt;$x_h$&lt;/span&gt; has some concrete constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$a_{x_h} \leq x_h \lt b_{x_h} \forall h \in\{1,\cdots,n\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Additionally, all of these sets are disjoint, eg &lt;span class=&quot;math-container&quot;&gt;$$S_i \cap S_j = \emptyset, i \neq j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The problem is that these sets don't necessarily cover &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n$&lt;/span&gt;, eg it's possible that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\bigcup_{i=1}^m S_i \neq\mathbb{R}^n$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What I want is to enumerate the minimum number of disjoint subsets &lt;span class=&quot;math-container&quot;&gt;$\{S_{m+1}..S_{m+k}\}$&lt;/span&gt; required to &amp;quot;cover&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n$&lt;/span&gt;, eg&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\bigcup_{i=1}^{m+k} S_i = \mathbb{R}^n$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As an example, let's take &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^2$&lt;/span&gt; as the space we want to cover.&lt;/p&gt;&#xA;&lt;p&gt;Our set of functions &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; might have the following domains:&lt;/p&gt;&#xA;&lt;p&gt;D1 : { (x, y) : x &amp;gt;= 2, y &amp;lt; -4 }&lt;/p&gt;&#xA;&lt;p&gt;D2 : { (x, y) : x &amp;lt; -1, y &amp;gt; 5 }&lt;/p&gt;&#xA;&lt;p&gt;D3 : { (x, y) : -1 &amp;lt;= x &amp;lt; 2 }&lt;/p&gt;&#xA;&lt;p&gt;From inspection, it's clear that there's at least 2 disjoint subsets of &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^2$&lt;/span&gt; that are not covered by these domains.&lt;/p&gt;&#xA;&lt;p&gt;They're depicted by the purple question marks in this image:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/s2sUk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/s2sUk.png&quot; alt=&quot;https://photos.app.goo.gl/ty6WLpaLgSo2VNWP8&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;What I want to know is, &lt;strong&gt;is there an algorithm which can take these domains as input, and output all existing disjoint, uncovered domains in the larger space?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="11139" LastEditorUserId="11139" LastEditDate="2023-01-27T15:48:31.160" LastActivityDate="2023-01-28T15:02:07.473" Title="How to enumerate disjoint sets which cover a vector space in $\mathbb{R}^n$?" Tags="|optimization|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9815" PostTypeId="2" ParentId="9814" CreationDate="2023-01-27T22:14:23.067" Score="3" Body="&lt;p&gt;This can be solved with an integer linear program (although I'm not sure that's the best approach). We first create a grid by running horizontal and vertical lines through all corners of your various domains. We don't need the grid to be evenly spaced. We also need to enclose the overall region in a box (hyperrectangle) big enough that all the vertices of the function domains are in the interior of the box. (We will relax the box later.) We need grid lines along the edges of the box.&lt;/p&gt;&#xA;&lt;p&gt;I'll refer to any hyperrectangle bounded by consecutive grid lines in all directions as a &amp;quot;cell&amp;quot;. We record the center points of each cell for future use, discarding any that are inside function domains.&lt;/p&gt;&#xA;&lt;p&gt;Next, we form all possible hyperrectangles whose vertices are grid points. Discard any hyperrectangle that overlaps one of the function domains. This is easy to determine. If, in any dimension, both limits of the hyperrectangle are on the same side of the domain (both less than or equal to the lower range limit for that variable, or both greater than or equal to the upper range limit), the domain and the hyperrectangle do not overlap. Otherwise, they do.&lt;/p&gt;&#xA;&lt;p&gt;Enumerate the surviving hyperrectangles as &lt;span class=&quot;math-container&quot;&gt;$R_1,\dots,R_N.$&lt;/span&gt; Compute the set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of pairs &lt;span class=&quot;math-container&quot;&gt;$(i,j),\, i&amp;lt;j$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$R_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R_j$&lt;/span&gt; overlap (using the same logic by which we decided if hyperrectangles and domains overlapped).&lt;/p&gt;&#xA;&lt;p&gt;Finally, for each center point &lt;span class=&quot;math-container&quot;&gt;$c_i,$&lt;/span&gt; compute the set &lt;span class=&quot;math-container&quot;&gt;$C_i = \lbrace j\in 1,\dots,N : c_i\in R_j\rbrace$&lt;/span&gt; of hyperrectangles containing that point.&lt;/p&gt;&#xA;&lt;p&gt;Now define binary variables &lt;span class=&quot;math-container&quot;&gt;$x_i,\,i=1,\dots,N$&lt;/span&gt; which will indicate whether or not hyperrectangle &lt;span class=&quot;math-container&quot;&gt;$R_i$&lt;/span&gt; is part of our cover. The objective is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_i x_i,$&lt;/span&gt; the number of rectangles used. To avoid hyperrectangles intersecting, for each &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in S$&lt;/span&gt; we add the constraint &lt;span class=&quot;math-container&quot;&gt;$x_i + x_j \le 1,$&lt;/span&gt; preventing us from using both. Finally, to ensure that everything outside the function domains is covered, for each center point &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; we add the constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in C_i} x_j = 1,$&lt;/span&gt; requiring that the center point belong to exactly one selected hyperrectangle. Since the hyperrectangle boundaries are grid lines, if the center point of a cell is in a hyperrectangle, the entire cell is in the hyperrectangle.&lt;/p&gt;&#xA;&lt;p&gt;Once we have a solution, we replace the lower (upper) limit of any variable in any selected hyperrectangle with &lt;span class=&quot;math-container&quot;&gt;$-\infty$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$+\infty$&lt;/span&gt;) if the edge of the hyperrectangle is on one of the boundaries of the box we imposed at the start.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-01-28T15:02:07.473" LastActivityDate="2023-01-28T15:02:07.473" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9816" PostTypeId="1" AcceptedAnswerId="9818" CreationDate="2023-01-28T14:54:19.550" Score="1" ViewCount="121" Body="&lt;p&gt;Based on the assumption that &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$g_1(x)$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$g_2(x)$&lt;/span&gt; are concave and positive, we get the following optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem A&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_x&amp;amp;\quad f(x) \\\text { subject to }&amp;amp;\quad g_1(x)-g_2(x)\leq0 &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But due to the constraint of this problem that is not concave, it rewrite as follow&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem B&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max_{x,\eta_1,\eta_2}&amp;amp;\quad f(x) \\\text { subject to }&amp;amp;\quad g_1(x)-\eta_1\leq0 \hspace{0.7cm}\\&amp;amp;\quad g_2(x)-\eta_2\leq0 \hspace{0.7cm}\\&amp;amp;\quad \eta_1-\eta_2\leq0 \hspace{0.7cm}\\&amp;amp;\quad -\eta_1\leq0 \hspace{0.7cm}\\&amp;amp;\quad -\eta_2\leq0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is it equivalent to problem A?&lt;/p&gt;&#xA;" OwnerUserId="11105" LastEditorUserId="11105" LastEditDate="2023-01-28T16:50:44.673" LastActivityDate="2023-01-28T17:11:30.233" Title="Is it possible to say that problem A and problem B are equivalent, and B is concave?" Tags="|optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9817" PostTypeId="2" ParentId="9816" CreationDate="2023-01-28T15:20:09.583" Score="1" Body="&lt;p&gt;If both &lt;span class=&quot;math-container&quot;&gt;$g_1(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_2(x) $&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; than corresponding &lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt;s, don't think original constraint will be satisfied. Rather replace 2nd constraint with &lt;span class=&quot;math-container&quot;&gt;$\eta_2 \le g_2(x)$&lt;/span&gt; and simply all &lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt; s &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; 0. You have indicated &lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt;s as non-negative but it's like holding one's nose by wrapping the arm around the head.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-01-28T15:20:09.583" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9818" PostTypeId="2" ParentId="9816" CreationDate="2023-01-28T17:11:30.233" Score="2" Body="&lt;p&gt;B is not equivalent to A. Suppose &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is infeasible in A because &lt;span class=&quot;math-container&quot;&gt;$g_1(x) - g_2(x) = P &amp;gt; 0.$&lt;/span&gt; In B, set &lt;span class=&quot;math-container&quot;&gt;$\eta_1 = g_1(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\eta_2 = g_2(x) + P &amp;gt; g_2(x).$&lt;/span&gt; Then &lt;span class=&quot;math-container&quot;&gt;$\eta_1 - \eta_2 = 0,$&lt;/span&gt;  so &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt; satisfy the constraints of B and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; has magically become &amp;quot;feasible&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Even if you fix this, I'm not sure what you accomplish, since B again does not have a convex feasible region.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-01-28T17:11:30.233" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9819" PostTypeId="1" AcceptedAnswerId="9821" CreationDate="2023-01-28T21:54:28.963" Score="3" ViewCount="309" Body="&lt;p&gt;I'm dealing with a problem I already modelled by using linear programming. The already existing constraints set at 1 groups of contiguous variables (for ex: &lt;code&gt;(0001111100000000000)&lt;/code&gt; ).&#xA;I'm now asked to add a constraint that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;set at 0 at least the next set of N variables&#xA;In the mentioned example, said N = 5 I won't be able to get &lt;code&gt;(00011111000011110000)&lt;/code&gt;, but I could get &lt;code&gt;(00011111000000011110)&lt;/code&gt;. What causes me a problem, is that I have groups of 1s and not single placed 1s. If I had just single placed 1s, the constraint would be something similar: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=0}^{N}x_i=0$$&lt;/span&gt;but I can't find a way to formulate the constraint in order to cover all the 1s of the set.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10956" LastEditorUserId="491" LastEditDate="2023-01-30T00:14:36.657" LastActivityDate="2023-01-30T00:14:36.657" Title="Set null the next set of N values" Tags="|linear-programming|modeling|constraint|binary-variable|logical-constraints|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9820" PostTypeId="2" ParentId="9819" CreationDate="2023-01-28T22:13:26.357" Score="3" Body="&lt;p&gt;To avoid &lt;span class=&quot;math-container&quot;&gt;$101$&lt;/span&gt;, the logical proposition is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lnot (x_i \land \lnot x_{i+1} \land x_{i+2}).$$&lt;/span&gt;&#xA;Rewriting in conjunctive normal form yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lnot x_i \lor x_{i+1} \lor \lnot x_{i+2},$$&lt;/span&gt;&#xA;which you can enforce via linear constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(1-x_i) + x_{i+1} +(1-x_{i+2}) \ge 1,$$&lt;/span&gt;&#xA;equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i - x_{i+1} + x_{i+2} \le 1.$$&lt;/span&gt;&#xA;More generally, to avoid &lt;span class=&quot;math-container&quot;&gt;$10\dots01$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; zeroes), impose&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i - \sum_{j=i+1}^{i+n} x_j + x_{i+n+1} \le 1.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Rather than impose separate constraints to avoid 101, 1001, 10001, and 100001, @prubin suggested instead enforcing&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(x_i \land \lnot x_{i+1}) \implies \bigwedge_{j=i+2}^{i+n} \lnot x_j.$$&lt;/span&gt;&#xA;Now rewrite in conjunctive normal form to somewhat automatically derive the desired linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\lnot (x_i \land \lnot x_{i+1}) \lor \bigwedge_{j=i+2}^{i+n} \lnot x_j \\&#xA;(\lnot x_i \lor x_{i+1}) \lor \bigwedge_{j=i+2}^{i+n} \lnot x_j \\&#xA;\bigwedge_{j=i+2}^{i+n} (\lnot x_i \lor x_{i+1} \lor \lnot x_j) \\&#xA;\bigwedge_{j=i+2}^{i+n} ((1 - x_i) + x_{i+1} + (1 - x_j) \ge 1) \\&#xA;\bigwedge_{j=i+2}^{i+n} (x_i - x_{i+1} + x_j \le 1),&#xA;$$&lt;/span&gt;&#xA;which is equivalent to what @prubin recommended.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-01-29T05:02:23.957" LastActivityDate="2023-01-29T05:02:23.957" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="9821" PostTypeId="2" ParentId="9819" CreationDate="2023-01-28T22:43:38.767" Score="5" Body="&lt;p&gt;If I understand this correctly, what you want to enforce is the following: if &lt;span class=&quot;math-container&quot;&gt;$x_i=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{i+1}=0$&lt;/span&gt; (so that variable &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the last in a string of one or more consecutive 1s) then &lt;span class=&quot;math-container&quot;&gt;$x_{i+2}=\dots=x_{i+N}=0$&lt;/span&gt; (position &lt;span class=&quot;math-container&quot;&gt;$i+1$&lt;/span&gt; is the start of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; consecutive 0s). You can do that with the following constraints for each index &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_j \le 1-x_{j-2} + x_{j-1}$$&lt;/span&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_j \le 1-x_{j-3}+x_{j-2}$$&lt;/span&gt;&lt;span class=&quot;math-container&quot;&gt;$$\vdots$$&lt;/span&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_j \le 1-x_{j-N}+x_{j-N+1}.$$&lt;/span&gt;Omit any constraints for which the variable being subtracted on the right does not exit. For instance, if &lt;span class=&quot;math-container&quot;&gt;$N=5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j=4$&lt;/span&gt; you would have the first two constraints, but the third constraint would subtract &lt;span class=&quot;math-container&quot;&gt;$x_0,$&lt;/span&gt; which doesn't exist, so you stop after two constraints.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-01-28T22:43:38.767" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9822" PostTypeId="2" ParentId="9819" CreationDate="2023-01-29T00:21:39.333" Score="2" Body="&lt;p&gt;As I understand you have a set of numbers 000011110 and you want to detect the index of the last 1 and then set next N numbers at 0. Obviously your set/list of cardinality 10 isn't like {0001110000} as in that case you already have 0s after the 1s. For the problem to make sense it would be like 0110001110 or 0011000111&lt;br /&gt;&#xA;If length of the set is known say m then&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=m+1}^N x_{i} \le 2 - (x_m+x_{m-1}) $&lt;/span&gt;&lt;br /&gt;&#xA;and to make it tighter&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=m+1}^N x_{i} \le x_m$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the length of the set is not known then its a different problem. In that case need to find at what maximum index the last 1 occurs.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-01-29T00:21:39.333" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9823" PostTypeId="1" AcceptedAnswerId="9827" CreationDate="2023-01-29T06:04:26.710" Score="4" ViewCount="163" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; is the uncertain vector of parameters and it varies within the interval &lt;span class=&quot;math-container&quot;&gt;$\Theta$&lt;/span&gt;. We have the following uncertain constraint.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i} f_i(x,\theta) \ge \sum_{j} g_j(x,\theta) \quad \theta \in \Theta&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To find the robust counterpart, we should consider the following constraint.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{\theta \in \Theta} \left( \sum_{i} f_i(x,\theta) \right) \ge \max_{\theta \in \Theta}  \left(   \sum_{j} g_j(x,\theta)   \right)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am wondering if it is possible to approximate the above constraint with the following constraint?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA; \sum_{i} \min_{\theta \in \Theta} \left( f_i(x,\theta) \right) \ge    \sum_{j} \max_{\theta \in \Theta}  \left( g_j(x,\theta)   \right)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I think the last constraint is tighter than the former constraint and if it is valid, the former constraint would be valid. I am wondering what this approach is called. Is it called &amp;quot;Safe conservative inner approximation&amp;quot;?&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="727" LastEditDate="2023-01-29T22:43:58.733" LastActivityDate="2023-01-29T22:43:58.733" Title="How to approximate an uncertain constraint?" Tags="|robust-optimization|uncertainty|unconstrained-optimization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9824" PostTypeId="2" ParentId="9823" CreationDate="2023-01-29T14:47:54.373" Score="2" Body="&lt;p&gt;My simple logic says your constraint states that the lowest of the lhs should always be greater than/equal to the highest values possible in the rhs within the given interval. If you take sum then you may have something like this:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$1+2+3 \ge 3+1+1$&lt;/span&gt;, one of the constraints being violated&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-29T14:53:18.290" LastActivityDate="2023-01-29T14:53:18.290" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9825" PostTypeId="1" CreationDate="2023-01-29T16:16:32.813" Score="3" ViewCount="103" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$W^C_t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$W_t$&lt;/span&gt; be binary variables and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; an integer variable with &lt;span class=&quot;math-container&quot;&gt;$1 \leq p \leq 3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The variables are related through the following equation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$W^C_t = \sum_{\theta=1}^{p} W_{t-\theta}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I can linearise this equation by introducing indicator variables &lt;span class=&quot;math-container&quot;&gt;$Y_1, Y_2, Y_3$&lt;/span&gt; and requiring:&lt;/p&gt;&#xA;&lt;p&gt;IF &lt;span class=&quot;math-container&quot;&gt;$Y_1=1$&lt;/span&gt; THEN &lt;span class=&quot;math-container&quot;&gt;$W^C_t = W_{t-1}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;IF &lt;span class=&quot;math-container&quot;&gt;$Y_2=1$&lt;/span&gt; THEN &lt;span class=&quot;math-container&quot;&gt;$W^C_t = W_{t-1} + W_{t-2} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;IF &lt;span class=&quot;math-container&quot;&gt;$Y_3=1$&lt;/span&gt; THEN &lt;span class=&quot;math-container&quot;&gt;$W^C_t = W_{t-1} + W_{t-2} + W_{t-3}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Y_1 + Y_2 + Y_3 = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This approach may, depending on the problem, to a large amount of constraints.&lt;/p&gt;&#xA;&lt;p&gt;The question is, is there a better way to model the equation?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2023-02-28T18:04:10.497" Title="Modelling Question" Tags="|mixed-integer-programming|modeling|binary-variable|indicator-constraints|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9826" PostTypeId="2" ParentId="9825" CreationDate="2023-01-29T17:11:49.557" Score="-1" Body="&lt;p&gt;Define set/list as &lt;span class=&quot;math-container&quot;&gt;$S=\{1,2,3\}$&lt;/span&gt;: basically indices of length N&lt;br /&gt;&#xA;Then add constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^3 jz_j = p $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_j z_j = 1$&lt;/span&gt;&lt;br /&gt;&#xA;Then use&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ z_j \le \sum_{k=1}^j W_{t-k} \ \forall j \in S$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{k: (k\gt j)} W_{t-k} \le z_{k} \ \forall j \in S$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ W_{t}^C = \sum_{\theta=1}^N W_{t-\theta}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-01-29T17:11:49.557" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9827" PostTypeId="2" ParentId="9823" CreationDate="2023-01-29T18:52:13.540" Score="3" Body="&lt;p&gt;Yes, it is always mathematically guaranteed that &lt;span class=&quot;math-container&quot;&gt;$$\sum_i \min_\theta a_{i, \theta} ≤ \min_\theta \sum_i a_{i, \theta} \tag{1}$$&lt;/span&gt; and that &lt;span class=&quot;math-container&quot;&gt;$$\sum_i \max_\theta a_{i, \theta} ≥ \max_\theta \sum_i a_{i, \theta} \tag{2}$$&lt;/span&gt; for any values &lt;span class=&quot;math-container&quot;&gt;$a_{i,\theta}$&lt;/span&gt; (including &lt;span class=&quot;math-container&quot;&gt;$a_{i, \theta} = f_i(x, \theta)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$a_{i, \theta} = g_i(x, \theta)$&lt;/span&gt;), least as long as the minima and maxima are all well defined.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Proof of &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;: Let &lt;span class=&quot;math-container&quot;&gt;$m_i = \min_\theta a_{i,\theta}$&lt;/span&gt;.  By definition, we have &lt;span class=&quot;math-container&quot;&gt;$m_i ≤ a_{i,\theta}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;.  Thus &lt;span class=&quot;math-container&quot;&gt;$\sum_i m_i ≤ \sum_i a_{i,\theta}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;, and thus &lt;span class=&quot;math-container&quot;&gt;$\sum_i \min_\theta a_{i, \theta} = \sum_i m_i ≤ \min_\theta \sum_i a_{i,\theta}$&lt;/span&gt;, QED.  (Inequality &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; can be proven the same way, just by swapping &lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\min$&lt;/span&gt; and changing the direction of the inequality signs.)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Of course, it could happen that this tighter constraint might not be satisfiable even if if the original robust constraint was (and of course the robust constraint itself might not be satisfiable even if there existed an &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; that satisfies the original uncertain constraint for all &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;) and optimizing with the tighter constraint might yield a less optimal result than using either of the looser constraints.  That's the price you pay for simplifying the constraints.&lt;/p&gt;&#xA;&lt;p&gt;(As for whether there's an established name for the tightened robust constraint, with the minimum / maximum taken componentwise inside the sum, I cannot say — I'm a mathematician, and mostly unfamiliar with OR specific terminology.  Sorry.)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Ps.&lt;/strong&gt; In fact, the inequalities &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; still hold, and can be proven the same way, even if we generalize them by replacing &lt;span class=&quot;math-container&quot;&gt;$\min$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\inf$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sup$&lt;/span&gt;.  While in this general case it's no longer guaranteed that the &lt;a href=&quot;https://en.wikipedia.org/wiki/Infimum_and_supremum&quot; rel=&quot;nofollow noreferrer&quot;&gt;infimum or supremum&lt;/a&gt; is actually attained for any &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;, and thus the inequality &lt;span class=&quot;math-container&quot;&gt;$m_i ≤ a_{i,\theta}$&lt;/span&gt; might always be strict, the proof still works.&lt;/p&gt;&#xA;" OwnerUserId="2510" LastEditorUserId="2510" LastEditDate="2023-01-29T19:07:34.527" LastActivityDate="2023-01-29T19:07:34.527" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9828" PostTypeId="1" AcceptedAnswerId="9829" CreationDate="2023-01-30T10:44:28.850" Score="5" ViewCount="261" Body="&lt;p&gt;I already asked this on stack overflow but just found this forum instead and figured it was more suited here. If this isn't allowed please feel free to tell me and I'll delete the post.&lt;/p&gt;&#xA;&lt;p&gt;I am doing some work for a local factory of where they cut out small metal sheets from larger metal sheets. All are rectangles.&lt;/p&gt;&#xA;&lt;p&gt;Today they try to fit many small sheets on one large. And only order and keep stock of one size of large sheets before cutting them into smaller. They try to minimize the metal waste by fitting as many small sheets on the large one, and because of this the order of the production of the small sheets can be quite hard to predict some days. To combat this, they instead want to start ordering large sheets of varying sizes, maybe 8-16 different sizes. And instead produce only ONE small sheet from each LARGE sheet. This might increase the waste, but also make it easier to plan ahead which small sheets to produce. But we now face another optimization problem: What 8(just an example number, could be 10 later, but quite small number) sizes of LARGE should we keep in stock?&lt;/p&gt;&#xA;&lt;p&gt;The SMALL sheets can be 50mm - 2000mm in width and 50mm - 1500mm in height. So one SMALL sheet could for example be 50mm wide and 1000mm high. Using a 1000x1000mm LARGE sheet would then create a lot of waste. They know what the sizes and the number of each of the SMALL sheets they are going to produce each month before, so that is part of the input. It could be many different sizes, maybe 100. And different number of each.&lt;/p&gt;&#xA;&lt;p&gt;So the question is essentially: If our input is some sizes and the number of each, maybe : (50mm,200mm,50pcs), (100mm,200mm,50pcs) .... and the number of different LARGE sheets to order (maybe 8). What 8 sizes of LARGE sheets should we order (and how many of each?).&lt;/p&gt;&#xA;&lt;p&gt;So far I have programmed a python script to calculate the waste for a specific set of LARGE sheets and for a data set of needed SMALL sheets, always using the best LARGE sheet for a specific SMALL sheet. But now I struggle to come up with a smart way to choose the large sheets. I am guessing the sizes can be discretized to steps of 25mm or 50mm to make it easier. I have only been thinking of randomly trying different sets of large sheets and choosing the best set found, but I guess some greedy heuristic could be developed?&lt;/p&gt;&#xA;&lt;p&gt;Would greatly appreciate some guidance on how to move forward with this.&lt;/p&gt;&#xA;" OwnerUserId="11150" LastEditorUserId="11150" LastEditDate="2023-01-30T11:56:45.477" LastActivityDate="2023-01-30T22:35:53.850" Title="Optimize selection of metal sheets to keep in stock" Tags="|integer-programming|combinatorial-optimization|nonlinear-programming|approximation-algorithms|industry|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9829" PostTypeId="2" ParentId="9828" CreationDate="2023-01-30T12:14:33.330" Score="4" Body="&lt;p&gt;If I understand well your problem, a good way to tackle it is to model it as an integer linear program and solve it with a mixed-integer linear programming solver, such as CBC, SCIP or Highs for the free ones.&lt;/p&gt;&#xA;&lt;p&gt;Data:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; small sheets with demand &lt;span class=&quot;math-container&quot;&gt;$d_j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j = 1, \dots, n$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; large sheets with cost &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i = 1, \dots, m$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;For all &lt;span class=&quot;math-container&quot;&gt;$j = 1, \dots, n$&lt;/span&gt;, for all &lt;span class=&quot;math-container&quot;&gt;$i = 1, \dots, m$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a_{i, j} = 1$&lt;/span&gt; iff small sheet &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; fits in large sheet &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt;: maximum number of types of large sheets to use&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_i \in \{ 0, \sum_j d_j \}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i = 1, \dots, m$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$y_i = k$&lt;/span&gt; iff &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; copies of large sheets &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; are used&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_i \in \{ 0, 1 \}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i = 1, \dots, m$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$z_i = 1$&lt;/span&gt; iff large sheets &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; are used&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i, j} \in \{ 0, d_j \}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j = 1, \dots, n$&lt;/span&gt;: number of small sheets &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; assigned to large sheets &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Objective: minimize the cost of the selected large sheets&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \min \sum_{i = 1}^m c_i y_i $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints 1: all small sheet is assigned to a large sheet&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \forall j = 1, \dots, n, \qquad  \sum_{i, a_{i, j} = 1} x_{i, j} = d_j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints 2: link between &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \forall i = 1, \dots, m, \qquad \sum_{j, a_{i, j} = 1} x_{i, j} = y_i $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints 3: link between &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \forall i = 1, \dots, m, \quad \forall j = 1, \dots, n, \quad a_{i, j} = 1, \qquad d_j z_i \ge x_{i, j} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints 4: maximum number of types of large sheets to order:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \forall i = 1, \dots, m, \qquad \sum_i z_i \le U $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that if you don't impose to use only one small sheet in a large sheet, then the problem is known as the Variable-sized Bin Packing Problem. It's the kind of problem that a &lt;a href=&quot;https://github.com/fontanf/packingsolver&quot; rel=&quot;nofollow noreferrer&quot;&gt;library&lt;/a&gt; I wrote can solve.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2023-01-30T22:35:53.850" LastActivityDate="2023-01-30T22:35:53.850" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9830" PostTypeId="1" CreationDate="2023-01-30T14:58:50.790" Score="2" ViewCount="101" Body="&lt;p&gt;I think I have some special kind of Job Shop Problem lying at hand which I'd like to solve, however I am unsure how to correctly define it and therefore cannot search for appropriate references in order to implement adequate algorithms.&lt;/p&gt;&#xA;&lt;p&gt;Assume two machines of type A and four machines of type B. Machines of type A can process all products, but only one product at a time. Machines of type B can process only a specific type of product but can therefore process two of the same kind at once (it is possible to process only one however as well). A product needs to be processed several times by machines of type A and B in a specific order, depending on its type. Assume I know the processing plan for each product, i.e. I know beforehand how many times and in which order a product will visit A and B.&lt;/p&gt;&#xA;&lt;p&gt;Include scheduled donwtimes / capacities of the machines.&#xA;Find an optimal schedule, where optimal may refer to either minimum total completion time or minimum completion time of some prioritized product.&lt;/p&gt;&#xA;&lt;p&gt;What kind of problem lies at hand? I have heard read about flexible job shop problems with recirculation, but I am not 100% sure this is what i should look further into.&lt;/p&gt;&#xA;&lt;p&gt;In addition, I am looking for references which give some examples of applied solutions to basic and advanced problems. The ones I have found so far are very theoreitcal and focused on algorithm complexity and less on application to real world problems.&lt;/p&gt;&#xA;" OwnerUserId="11152" LastEditorUserId="123" LastEditDate="2023-01-30T19:09:59.697" LastActivityDate="2023-01-31T09:44:19.193" Title="Problem similar to job shop" Tags="|job-shop-scheduling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9831" PostTypeId="2" ParentId="9830" CreationDate="2023-01-30T19:49:44.750" Score="2" Body="&lt;p&gt;Without knowing more details below is the outline what you can follow/develop further:\&lt;/p&gt;&#xA;&lt;p&gt;Products:  &lt;span class=&quot;math-container&quot;&gt;$P_p $&lt;/span&gt;: Priority &lt;span class=&quot;math-container&quot;&gt;$ Z_p$&lt;/span&gt;, Type&lt;span class=&quot;math-container&quot;&gt;$ C_c$&lt;/span&gt;, Processing time &lt;span class=&quot;math-container&quot;&gt;$ T_p$&lt;/span&gt;&lt;br /&gt;&#xA;Machines: Type: &lt;span class=&quot;math-container&quot;&gt;$ M_m$&lt;/span&gt;: Number &lt;span class=&quot;math-container&quot;&gt;$ N_m$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$ Cap_{m,c}$&lt;/span&gt;: units at a time; &lt;span class=&quot;math-container&quot;&gt;$ D_m$&lt;/span&gt;: downtime in hours for machine: Downtime Schedule: &lt;span class=&quot;math-container&quot;&gt;$ND_{m,t}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Time: &lt;span class=&quot;math-container&quot;&gt;$T_t$&lt;/span&gt;: could be in hours {1,2,3,..T} or minutes. Depends upon cycle time unit/&lt;/p&gt;&#xA;&lt;p&gt;Derived Sets:&lt;br /&gt;&#xA;Process time-(Machine,Product): &lt;span class=&quot;math-container&quot;&gt;$PT_{m,p}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Parameters/Constants&lt;br /&gt;&#xA;Available Time &lt;span class=&quot;math-container&quot;&gt;$T= $&lt;/span&gt;22x8 hours&lt;br /&gt;&#xA;Product-Priority-Type &lt;span class=&quot;math-container&quot;&gt;$ \tau_{p,c} =1 $&lt;/span&gt; if product is of type &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, else 0&lt;/p&gt;&#xA;&lt;p&gt;Machine-Product Type &lt;span class=&quot;math-container&quot;&gt;$ \tau_{m,c} = 1$&lt;/span&gt; if machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; handles this type &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, else 0&#xA;&lt;span class=&quot;math-container&quot;&gt;$T_{AB} = \{t\in T: t_A \le t_B\} $&lt;/span&gt;: Times when a product has to pass through machine type A before machine type B&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$T_{BA} = T\setminus T_AB $&lt;/span&gt;: Times when a product has to pass through machine type B before machine type A&lt;br /&gt;&#xA;Order of processing: &lt;span class=&quot;math-container&quot;&gt;$O_{p,m} $&lt;/span&gt;: {1,2,3..}&lt;/p&gt;&#xA;&lt;p&gt;Variables:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_{p,m,t}^o \in \{0,1\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Obj Min &lt;span class=&quot;math-container&quot;&gt;$\sum_p\sum_t\sum_mx_{m,p,t}^o $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;st&lt;br /&gt;&#xA;(1) &lt;span class=&quot;math-container&quot;&gt;$T_p \le \sum_t \sum_m \sum_o\tau_{p,c}\tau_{m,c}x_{p,m,t}^o \ \forall p \in P \ \forall c \in C $&lt;/span&gt;: Total processing time through machines for each product greater than total processing time needed for that product&lt;/p&gt;&#xA;&lt;p&gt;(2) &lt;span class=&quot;math-container&quot;&gt;$\sum_p \tau_{p,c}x_{p,m,t} \le Cap_{m,c}\tau_{m,c}(N_m - ND_{m,t}) \ \ \forall t \in T \ \forall m\in M \ \forall o \in O$&lt;/span&gt;:&lt;br /&gt;&#xA;Each product through a machine type at a time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is constrained by the capacity of the machine (2 vs 1 at a time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, number of machines available and if machine can handle that product type &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(3) &lt;span class=&quot;math-container&quot;&gt;$\sum_o\sum_t \sum_p \tau_{m,c}x_{m,p,t}^o \le T - \sum_t D_{m,t}  \ \ \forall m \in M$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(4) &lt;span class=&quot;math-container&quot;&gt;$\tau_{m,c}\tau_{p,c}PT_{p,m} \le \sum_t x_{m,p,t}^o \ \forall \ \in P \ \forall m \in M \ \forall o$&lt;/span&gt;: ensure every product is processed on machine as per processing time of that product and machine.&lt;/p&gt;&#xA;&lt;p&gt;(5) &lt;span class=&quot;math-container&quot;&gt;$\sum_{o* \gt o}\sum_t x_{m,p,t}^{o^*} \le \sum_t x_{m,p,t}^o \ \forall O \in O$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Further Readings&lt;br /&gt;&#xA;&lt;a href=&quot;https://support.sas.com/documentation/onlinedoc/or/151/ormpex.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;SAS OR&lt;/a&gt;L Ch 3 &amp;amp; 4: Example Models&lt;br /&gt;&#xA;&lt;a href=&quot;https://developers.google.com/optimization/scheduling/job_shop&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google OR&lt;/a&gt; Examples&lt;br /&gt;&#xA;IEEE &lt;a href=&quot;https://ieeexplore.ieee.org/document/8514241&quot; rel=&quot;nofollow noreferrer&quot;&gt;Paper&lt;/a&gt;: Discussion&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.gurobi.com/wp-content/uploads/2022/08/IndustrySolutionSheet-Manufacturing-MadeToOrder.pdf?x47079&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi&lt;/a&gt;: Presentation&lt;br /&gt;&#xA;&lt;a href=&quot;https://dr.lib.iastate.edu/server/api/core/bitstreams/cd6eb376-354c-413f-8df3-8ad7b503db14/content&quot; rel=&quot;nofollow noreferrer&quot;&gt;Academic Paper&lt;/a&gt;: Discussion&#xA;and numerous other ERP/Shopfloor scheduling tools.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-30T22:48:17.567" LastActivityDate="2023-01-30T22:48:17.567" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9832" PostTypeId="1" CreationDate="2023-01-30T21:22:10.770" Score="2" ViewCount="117" Body="&lt;p&gt;I have a set of tasks &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; with  processing times &lt;span class=&quot;math-container&quot;&gt;$p_i, \forall i \in I$&lt;/span&gt;. There exists a set of machines &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; and each machine has availability time ranges in a given time horizon.&lt;/p&gt;&#xA;&lt;p&gt;For instance, given a machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; and a time horizon &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt; hours, &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; might  be available between &lt;span class=&quot;math-container&quot;&gt;$a_{m1} =[0,10]$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a_{m2} =[20,40]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_{m3} =[75,95]$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$A_{m}$&lt;/span&gt; represents the set of time slots for machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;. I'll use &lt;span class=&quot;math-container&quot;&gt;$+$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$-$&lt;/span&gt; for the upper and lower limit for each range. Note that another machine could have a completely different time slot availability.&lt;/p&gt;&#xA;&lt;p&gt;The goal is to capture the precedence relationship for the tasks where no multiple task is processed on the same machine at the same time. Let us define three variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt; : the start time of processing part &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\delta_{ij}$&lt;/span&gt; : whether part &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; precedes part &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u_{ima}$&lt;/span&gt; : whether part &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is processed on machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; during shift &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here are the constraints that I come up with so far.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_i \geq t_j + p_j - M (2-u_{ima} -u_{jma} + \delta_{ij})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_j \geq t_i + p_i - M (2-u_{ima} -u_{jma} + 1- \delta_{ij})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;These constraints above state that if &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; precedes &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on the same machine, then the start time of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; must be greater than the completion time of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. The confusing part is the availability range here. I don't think that it captures what I'd like. I was wondering if there's an easy fix or if I'm on the right track. Should I sum over &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; each variable &lt;span class=&quot;math-container&quot;&gt;$u_{ima}$&lt;/span&gt;? Please note that I do not want to consider each time slot as an individual machine. Even though it would resolve the issue, I have other set of constraints that I do not share here.&lt;/p&gt;&#xA;&lt;p&gt;To make sure that lower and upper bound of each availability time range is met, I have the following constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_i + p_i \leq a^+ u_{ima} + M(1-u_{ima} ) \quad \forall i \in I, m \in M, a \in A_{m}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_i \geq a^- u_{ima} + M(1-u_{ima} ) \quad \forall i \in I, m \in M, a \in A_{m}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I can also add another constriant to ensure that each part is assigned to one machine.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{m \in M} \sum_{a \in A{m}}u_{ima}  =1, \quad  \forall i \in I$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3567" LastEditorUserId="3567" LastEditDate="2023-01-31T15:52:10.107" LastActivityDate="2023-02-01T09:52:48.750" Title="constraint set for a scheduling problem with machine availability" Tags="|mixed-integer-programming|modeling|scheduling|job-shop-scheduling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9833" PostTypeId="2" ParentId="9832" CreationDate="2023-01-30T22:18:30.163" Score="-1" Body="&lt;p&gt;It isn't abt not scheduling &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in the same slit. It's more about preserving the precedence even when assigned on different slots. So&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$u_{jma}\le \sum_m \sum_{a^{*+}\le a} u_{i,m,a^{*+}}+M(1-\delta_{i,j}) $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$u_{ima} \le \sum_m\sum_{a^{*+}\le a} u_{j,m,a^{*+}}+M\delta_{i,j} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You may remove the &lt;span class=&quot;math-container&quot;&gt;$u_{ima}$&lt;/span&gt; in the first 2 constraints.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-31T16:23:24.107" LastActivityDate="2023-01-31T16:23:24.107" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9834" PostTypeId="2" ParentId="9830" CreationDate="2023-01-31T09:44:19.193" Score="2" Body="&lt;p&gt;Based on What you mentioned, you could have a look at the &lt;a href=&quot;https://en.wikipedia.org/wiki/Parallel_task_scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;parallel machine scheduling problem&lt;/em&gt;&lt;/a&gt; with precedence, resource capacity, and batch processing constraints. (&lt;span class=&quot;math-container&quot;&gt;$ P_{m} \ | \ cap, prec, batch \ | \ \sum (Prio_{j}.C_{j}) \ \text{Or} \ C_{max}$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Also, the problem is fallen under the &lt;em&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Job-shop_scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;flexible job shop problem&lt;/a&gt;&lt;/em&gt; with the resource capacity and batch processing constraint if, &lt;em&gt;&lt;strong&gt;all of jobs/tasks&lt;/strong&gt;&lt;/em&gt; would be processed on &lt;em&gt;&lt;strong&gt;all of the types&lt;/strong&gt;&lt;/em&gt; of machines through the pre-defined routes.&#xA;(&lt;span class=&quot;math-container&quot;&gt;$ Fj \ | \ cap, batch \ | \ \sum (Prio_{j}.C_{j}) \ \text{Or} \ C_{max}$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Otherwise, you have faced an &lt;a href=&quot;https://en.wikipedia.org/wiki/Open-shop_scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;open-shop problem&lt;/em&gt;&lt;/a&gt;. (&lt;span class=&quot;math-container&quot;&gt;$ O_{m} \ | \ cap, batch \ | \ \sum (Prio_{j}.C_{j}) \ \text{Or} \ C_{max}$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;I strongly recommend you to read &lt;em&gt;&lt;a href=&quot;https://www.msi-jp.com/xpress/learning/square/(B)Modeling%20and%20problem_Summary.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Applications of optimization with Xpress-MP&lt;/a&gt;, (Chapter 7)&lt;/em&gt; if you would like to take some examples of applied solutions. Also, the following links would be useful:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/7039/how-to-include-material-flow-in-job-shop-scheduling-problem-as-constraint/7045#7045&quot;&gt;How to include material flow in job shop scheduling problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/6949/what-is-the-state-of-art-in-industry-and-academy-of-this-scheduling-routing/6954#6954&quot;&gt;What is the state-of-art (in industry and academy) of this scheduling + routing problem?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/5967/job-shop-scheduling-problem-jobs-are-scheduled-on-the-same-machine-at-the-same/6037#6037&quot;&gt;Job Shop Scheduling Problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-01-31T09:44:19.193" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9835" PostTypeId="1" CreationDate="2023-01-31T12:40:01.290" Score="2" ViewCount="49" Body="&lt;p&gt;I am trying to model a capacitated VRP model where the capacity is defined by the time the vehicle is available.&lt;/p&gt;&#xA;&lt;p&gt;What I have:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;List of vehicles available and the time for which they are available&lt;/li&gt;&#xA;&lt;li&gt;List of points that need to be served and each point with a specific serving time&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;My approach:&lt;/p&gt;&#xA;&lt;p&gt;I am trying to formulate a MIP assuming a centroid for each vehicle and then minimising the distance of these dropping points from that centroid. I have added the constraint that the total serving time shouldn't exceed the capacity of a vehicle. But here the problem is only serving time is being taken care of. I am unable to code the travel time which is kind of the TSP time for a vehicle.&lt;/p&gt;&#xA;&lt;p&gt;How can this problem be encoded?&lt;/p&gt;&#xA;" OwnerUserId="5532" LastEditorUserId="491" LastEditDate="2023-01-31T18:38:03.600" LastActivityDate="2023-01-31T18:38:03.600" Title="A 'capacitated' VRP model where the capacity constraint is the time" Tags="|mixed-integer-programming|combinatorial-optimization|vehicle-routing|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9836" PostTypeId="1" AcceptedAnswerId="9852" CreationDate="2023-01-31T12:40:16.147" Score="3" ViewCount="150" Body="&lt;h2&gt;Problem Summary&lt;/h2&gt;&#xA;&lt;p&gt;To match passengers (the number of passengers) to capacitated vehicles such that the profit is increased. All the vehicles have the same capacity &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;. It is not important to track which passenger is matched to which vehicle.&lt;/p&gt;&#xA;&lt;h2&gt;Problem Background&lt;/h2&gt;&#xA;&lt;p&gt;I'm trying to find a solution to the following passenger matching problem:&lt;/p&gt;&#xA;&lt;p&gt;The network is represented by graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is the set of nodes/stations. &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt; is the profit of traveling through an edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; be the number of vehicles, all the vehicles have the same capacity &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;At each (discreet) time step, the passengers arrive at their origin station and need to be transported to their destination station. &lt;span class=&quot;math-container&quot;&gt;$d^t_{ij}$&lt;/span&gt; is the demand. &lt;span class=&quot;math-container&quot;&gt;$f^t_{ij} \le d^t_{ij}$&lt;/span&gt; is the passenger flow, i.e., the number of passengers that are traveling from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and are successfully matched to a vehicle. The unmatched passers will leave the system. &lt;span class=&quot;math-container&quot;&gt;$X^t_i$&lt;/span&gt; is the total number of available vehicles at station &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Objective&lt;/h3&gt;&#xA;&lt;p&gt;The objective is to maximize profit.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem formulation for single occupancy vehicle&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I read a few resources and found the following formulation. However, this formulation assumes that the vehicles are single occupancy.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ max \sum_{i,j \in V} f^t_{ij}p^t_{ij} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ 0 \le f^t_{ij} \le d^t_{ij} \quad i,j \in V \quad (1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j\in V} f^t_{ij} \le X^t_i \quad i \in V \quad \quad (2)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; ensures that the passenger flow doesn't exceed the demand and is non-negative.&lt;/p&gt;&#xA;&lt;p&gt;The constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;  ensures that the number of vehicles doesn't exceed the number of available vehicles &lt;span class=&quot;math-container&quot;&gt;$X^t_i$&lt;/span&gt;  at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; at station &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As long as the demand is integral, this formulation results in integral passenger flow.&lt;/p&gt;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&lt;p&gt;I'd like to extend the above single occupancy formulation to multi-passenger vehicles. I explored some resources online but the methods focused on individual vehicles instead of stations and were using ILP.&lt;/p&gt;&#xA;&lt;h1&gt;Update&lt;/h1&gt;&#xA;&lt;p&gt;I modified the problem formulation to set an upper bound to the vehicle count.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ max \sum_{i,j \in V} f_{ij}p_{ij} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ 0 \le c.x_{i,j} \le d_{ij}+c \quad i,j \in V \quad (1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j \in V} x_{ij} \le X_i \quad \forall i \in V \quad \quad (2)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ f_{i,j} \le c.x_{ij} \quad \forall i,j \in V \quad \quad (3)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="11159" LastEditorUserId="11159" LastEditDate="2023-03-02T14:21:51.990" LastActivityDate="2023-03-02T14:21:51.990" Title="Vehicle passenger assignment with capacity constraint" Tags="|optimization|linear-programming|constraint-programming|graphs|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9837" PostTypeId="2" ParentId="9836" CreationDate="2023-01-31T14:43:48.923" Score="3" Body="&lt;p&gt;Say you have total &lt;span class=&quot;math-container&quot;&gt;$V=\sum_i X_{i}$&lt;/span&gt; vehicles so if &lt;span class=&quot;math-container&quot;&gt;$z_{v,i}^t $&lt;/span&gt; represents number of passengers vehicle &lt;span class=&quot;math-container&quot;&gt;$z_v$&lt;/span&gt; carries from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;br /&gt;&#xA;Define vars &lt;span class=&quot;math-container&quot;&gt;$z_{v,i }^t $&lt;/span&gt; over Set S = {1,2...V}, time &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; and nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;br /&gt;&#xA;Additional constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_j f_{i,j}^t \le c\sum_v z_{v,i}^t \le \sum_j d_{i,j}^t$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_j f_{i,j}^t \le cX_{i}^t$&lt;/span&gt;&lt;br /&gt;&#xA;Or&lt;br /&gt;&#xA;You can you replace &lt;span class=&quot;math-container&quot;&gt;$f_{i,j}^t$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$z_{v,i,j}^t$&lt;/span&gt; if you want&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-31T21:45:35.107" LastActivityDate="2023-01-31T21:45:35.107" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9838" PostTypeId="1" CreationDate="2023-01-31T15:04:41.147" Score="1" ViewCount="52" Body="&lt;p&gt;For the Leontief utility function &lt;span class=&quot;math-container&quot;&gt;$$u_L(\lambda,y)=\min\{\lambda_1(r_1-y_1),\ldots,\lambda_m(r_m-y_m)\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would like to graphically show that, for &lt;span class=&quot;math-container&quot;&gt;$m=2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda\in\Lambda$&lt;/span&gt; (for positive instances), not every global minimum point of L(λ) is an efficient point (Pareto optimal).&lt;/p&gt;&#xA;&lt;p&gt;I tried to make a graph with&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u_L((1/2,1/2),.)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$r=[(20,15)]^T$&lt;/span&gt; and got this graph&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0jZi0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0jZi0.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;but was stuck with the proof.&lt;/p&gt;&#xA;" OwnerUserId="11161" LastEditorUserId="123" LastEditDate="2023-01-31T15:15:08.740" LastActivityDate="2023-01-31T15:15:08.740" Title="Leontief utility function" Tags="|multi-objective-optimization|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9839" PostTypeId="1" CreationDate="2023-01-31T16:07:12.247" Score="1" ViewCount="136" Body="&lt;p&gt;Given the input data:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;Stock[pl,p][t]&lt;/code&gt; where &lt;code&gt;pl&lt;/code&gt; is plant, &lt;code&gt;p&lt;/code&gt; is product, &lt;code&gt;t&lt;/code&gt; is time horizon.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Cost[p,pl]['Cost']&lt;/code&gt; where &lt;code&gt;pl&lt;/code&gt; is plant, &lt;code&gt;p&lt;/code&gt; is product.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Price[c,p]['Price']&lt;/code&gt; where &lt;code&gt;c&lt;/code&gt; is cost, &lt;code&gt;p&lt;/code&gt; is product.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Order[o,p,t]['Quantity']&lt;/code&gt; where &lt;code&gt;o&lt;/code&gt; is Sales orders, &lt;code&gt;p&lt;/code&gt; is product, &lt;code&gt;t&lt;/code&gt; is time horizon. Here the &lt;code&gt;t&lt;/code&gt; is delivery dates.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerDisplayName="user11162" LastEditorDisplayName="user11162" LastEditDate="2023-02-07T19:04:24.353" LastActivityDate="2023-02-07T19:04:24.353" Title="Pulp: optimization" Tags="|supply-chain|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9840" PostTypeId="2" ParentId="9839" CreationDate="2023-01-31T18:50:49.207" Score="1" Body="&lt;p&gt;(As you have done)&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$Delv_{pl,p,t} \le Stck_{pl,p,t} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$O_{c,p,t}^k (\delta_{k,pl}-1) \le \sum_p \tau_{c,pl}Delv_{pl,p,t} \le \sum_p O_{c,p,t}^k \delta_{k,pl} \ \ \forall pl \in Pl \ \ \forall t \in T \ \ \forall c \in C \ \forall k \in$&lt;/span&gt; Orders&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{pl} \delta_{k,pl} \le 1 \ \ \forall k \in $&lt;/span&gt;Orders&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\delta_{k,pl} =1$&lt;/span&gt; if plant &lt;span class=&quot;math-container&quot;&gt;$pl$&lt;/span&gt; is selected for order# &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, else 0 and &lt;span class=&quot;math-container&quot;&gt;$ \tau_{c,pl}=1$&lt;/span&gt; if Pl is among those where customer &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; sources from.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; is a binary variable while &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; is given. You can use set membership logic as well like &lt;span class=&quot;math-container&quot;&gt;$ C_pl = \{pl: pl \in $&lt;/span&gt; Customer sources for C}&lt;/p&gt;&#xA;&lt;p&gt;In your case you are using length of set in Constraint (3)&lt;/p&gt;&#xA;&lt;p&gt;I don't think any of your constraints are addressing this in this way.&#xA;Constraint (2) is saying 'get product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; from one or all (that what sum does) plants'. Trying replacing &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; as there's a chance that a product in an order will not be delivered from the plant chosen. Constraint (3) is then attempting to restrict number of plants involved in every order to 1 but there in the constraint you are coding p_ == o.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-01-31T19:27:24.017" LastActivityDate="2023-01-31T19:27:24.017" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9841" PostTypeId="1" AcceptedAnswerId="9846" CreationDate="2023-01-31T19:28:34.187" Score="3" ViewCount="639" Body="&lt;p&gt;I have 4 variables. Xl6, Xs6, Pl6, Ps6. I have a constant C as well.&lt;/p&gt;&#xA;&lt;p&gt;Xl6 and Xs6 are binary whereas Pl6 and Ps6 are integers. Also, all variables can take only positive values.&lt;/p&gt;&#xA;&lt;p&gt;I have to implement following constraints in an MIP:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;If Xl6 == 0 then Pl6 == 0 else Pl6 &amp;gt; 0&#xA;If Xs6 == 0 then Ps6 == 0 else Ps6 &amp;gt; 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Another set of if-else constraints are:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if Xl6 == 1 and Xs6 == 1 then Pl6 + Ps6 &amp;gt;= C&#xA;elif Xl6 == 1 and Xs6 == 0 then Pl6 &amp;gt;= C&#xA;elif Xl6 == 0 and Xs6 == 1 then Ps6 &amp;gt;= C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also, we have another constraint that &lt;code&gt;Xl6 and Xs6 both can't be zero at the same time&lt;/code&gt;. This has been implemented as &lt;code&gt;Xl6 + Xs6 &amp;gt;= 1&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How can we formulate above set of conditions as linear constraints?&lt;/p&gt;&#xA;" OwnerUserId="9609" LastEditorUserId="500" LastEditDate="2023-01-31T22:33:09.153" LastActivityDate="2023-02-03T13:43:11.580" Title="Modelling if elif else conditions as MIP" Tags="|mixed-integer-programming|linear-programming|modeling|logical-constraints|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9842" PostTypeId="2" ParentId="9841" CreationDate="2023-01-31T19:39:29.183" Score="3" Body="&lt;p&gt;I am assuming that &lt;code&gt;pl6&lt;/code&gt; is a non-negative integer.  (tell me if it holds).&lt;br /&gt;&#xA;For &lt;code&gt;Xl==0 then Pl6 ==0&lt;/code&gt; you can have :&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Pl6&amp;lt;= Xl6&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;This tells you that if Xl6 = 0 : Pl6&amp;lt;= 0 and since it takes &amp;gt;=0 values , it has to be 0.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Pl6&amp;gt;= Xl6/M&lt;/code&gt; where M is a really big integer.&#xA;Now if Xl6==1  Pl6&amp;gt;1/M --&amp;gt; Pl6 &amp;gt;0&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For the second type of contraint:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Pl6 + Ps6 &amp;gt;= C(Xl6 + Xs6 - 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Notice that if and only if &lt;code&gt;Xl6 = Xs6 = 1&lt;/code&gt; the right-hand will be exactly C.&#xA;If both are 0 it will be negative (and therefore do nothing) , and if one of them is 1 if will be 0.&lt;/p&gt;&#xA;&lt;p&gt;(Everything I said holds if P's are non-negative)&lt;/p&gt;&#xA;" OwnerUserId="10716" LastActivityDate="2023-01-31T19:39:29.183" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9843" PostTypeId="1" AcceptedAnswerId="9845" CreationDate="2023-01-31T19:46:21.523" Score="1" ViewCount="41" Body="&lt;p&gt;I found the following problem in my book.&lt;br /&gt;&#xA;I know that I can compute the simplex tableau , let's call it S for a basis &lt;code&gt;X_b=(x_1, x2, x_5)^T&lt;/code&gt; as &lt;code&gt;S=B^{-1}A&lt;/code&gt;, if my initial problem is  :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; maximize f   &#xA;  s.t Ax = b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But &lt;strong&gt;here we have a minimization problem. Can I still apply the same formula?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eUCuz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eUCuz.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10716" LastActivityDate="2023-01-31T21:09:52.880" Title="Computing simplex tableu for a given basis" Tags="|linear-programming|simplex|linear-algebra|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9844" PostTypeId="2" ParentId="9841" CreationDate="2023-01-31T20:05:19.407" Score="4" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sigma Xl6 \le Pl6 \le UXl6 $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sigma Xs6 \le Ps6 \le UXs6 $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; is very small nonnegative number (even 1 as Prof Rubin suggested since PPl/Ps are integers) &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt;(&lt;span class=&quot;math-container&quot;&gt;$ \gt$&lt;/span&gt; C) is upper bound for Pl &amp;amp; Ps&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C(Xl6+Xs6 -1) + U(Xl6+Xs6-2) \le Pl6 + Ps6$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$CXl6 - U(Xl6+2Xls6-1)\le Pl6$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$CXs6 - U(2Xl6+Xls6-1)\le Ps6$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ 1 \le Xl6 + Xs6$&lt;/span&gt; as you've already&lt;/p&gt;&#xA;&lt;p&gt;If both integer vars can take positive values only then 2nd bunch of constraints can be replaced by&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$CXl6 \le Pl6$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$CXs6 \le Ps6$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-01T01:40:48.867" LastActivityDate="2023-02-01T01:40:48.867" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9845" PostTypeId="2" ParentId="9843" CreationDate="2023-01-31T21:09:52.880" Score="2" Body="&lt;p&gt;Yes, the formula is the same regardless of whether you are maximizing or minimizing. The difference is in how you interpret the reduced costs &lt;span class=&quot;math-container&quot;&gt;$c^\prime -c_B^\prime B^{-1} A.$&lt;/span&gt; When maximizing, you want to pivot on variables with positive reduced cost. When minimizing, you want to pivot on variables with negative reduced cost.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-01-31T21:09:52.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9846" PostTypeId="2" ParentId="9841" CreationDate="2023-01-31T22:19:34.277" Score="5" Body="&lt;p&gt;For the first part, let &lt;span class=&quot;math-container&quot;&gt;$Ul6$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Us6$&lt;/span&gt; be upper bounds on &lt;span class=&quot;math-container&quot;&gt;$Pl6$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Ps6$&lt;/span&gt;, respectively, and impose linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;Xl6 \le Pl6 &amp;amp;\le Ul6 Xl6 \\&#xA;Xs6 \le Ps6 &amp;amp;\le Us6 Xs6&#xA;\end{align}&lt;/span&gt;&#xA;For the second part:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;Pl6 + Ps6 &amp;amp;\ge C(Xl6 + Xs6 - 1) \\&#xA;Pl6 &amp;amp;\ge C(Xl6 - Xs6) \\&#xA;Ps6 &amp;amp;\ge C(Xs6 - Xl6)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-02-03T13:43:11.580" LastActivityDate="2023-02-03T13:43:11.580" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9847" PostTypeId="2" ParentId="9832" CreationDate="2023-02-01T09:52:48.750" Score="-1" Body="&lt;p&gt;One possible way to assign tasks to the machines w.r.t the time slots is to redefine the sets and some constraints in addition to other models' constraints as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{Set} \ Tasks = \{1 \cdots \text{I} \}.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{Set} \ Machines = \{1 \cdots \text{M} \}.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{Set} \ TimeSlots= \{1 \cdots \text{T} \}.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{Set} \ Map_{(Tasks , Machines)}= \{1.(1, \cdots, T), \cdots, \text{M}.(1, \cdots, T) \}.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{P}_{tasks} = \text{The processing time of tasks i}.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{TimeSlotDuration}_{TimeSlots} = \text{The available time in each timeslot t}.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$U_{tasks, machines, timeslots} = \text{whether part i is processed on machine m during timeslot t}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{m,t} u(i,m,t) = 1 \quad\forall i \in I \quad (1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i,t} u(i,m,t) \leq | \ I \ | \quad\forall m \in M \quad (2)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i} u(i,m,t)*P(i) \leq TimeSlotDuration(t) \quad\forall m \in M, t \in T : map(m,t) \quad (3)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first constraint implies that each task should be processed on one machine at one time slot. The second constraint ensures that each machine might process all of the tasks at one time slot. The third constraint implies that the processing time of the tasks at each time slot and in each machine would be less equal than the available time for each time slot. As the simple example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set tasks =  {task1*task5};&#xA;set machines {m1*m3};&#xA;set timeslot {tm1*tm3};&#xA;&#xA;parameter timeslotduration(t)&#xA;tm1 20&#xA;tm2 35&#xA;tm3 25&#xA;;&#xA;&#xA;parameter p(i)&#xA;task1 15&#xA;task2 25&#xA;task3 25&#xA;task4 5&#xA;task5 10 &#xA;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The results would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;VARIABLE u.L  &#xA;&#xA;                 tm1         tm2         tm3&#xA;&#xA;task1.m1       1.000&#xA;task2.m1                   1.000&#xA;task3.m3                               1.000&#xA;task4.m1       1.000&#xA;task5.m2                   1.000&#xA;&#xA; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-02-01T09:52:48.750" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9848" PostTypeId="1" CreationDate="2023-02-01T10:33:03.293" Score="1" ViewCount="47" Body="&lt;p&gt;I am looking for a smooth (continuous differentiable) approximation of the following five-phased linear function:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;P(U, R, P_r) = \begin{cases}&#xA;R(U_{max} - U) + R(U_{up} - U_{max}) + P_r; &amp;amp; U \geq U_{max}\\&#xA;R(U_{up} - U) + P_r; &amp;amp; U_{up} &amp;lt; U &amp;lt; U_{max}\\&#xA;P_r; &amp;amp; U_{low} \leq U \leq U_{up}\\&#xA;R(U_{low} - U) + P_r; &amp;amp; U_{min} &amp;lt; U &amp;lt; U_{low}\\&#xA;R(U_{min} - U) + R(U_{low} - U_{min}) + P_r; &amp;amp; U \leq U_{min}\\&#xA;\end{cases},&#xA;$$&lt;/span&gt;&#xA;Here &lt;span class=&quot;math-container&quot;&gt;$U_{max} \ge U_{up} \ge U_{low} \ge U_{min} $&lt;/span&gt; are the breakpoints and bounds of the variable &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$P_r$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; are a given setpoint value and slope of the line respectively. Also, &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; has bounds as &lt;span class=&quot;math-container&quot;&gt;$P_{min} \leq P \leq P_{max}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am trying to define these constraints as nested max functions and then apply the smooth approximation.&#xA;Such that: &lt;span class=&quot;math-container&quot;&gt;$$F(x) = \max\{0,x\}, \quad for \quad x \in \mathbb{R}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;By picking any positive number &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$F^\epsilon(x) = \epsilon \ln \left(1+ \exp(x/\epsilon)\right), \quad for \quad x \in \mathbb{R}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with bound verification:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$F^\epsilon(x) - \epsilon \ln2 \leq F(x) \leq F^\epsilon(x)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10869" LastEditorUserId="67" LastEditDate="2023-02-01T17:03:10.190" LastActivityDate="2023-02-01T17:03:10.190" Title="Smooth approximation of a five phase piecewise linear function" Tags="|linear-programming|approximation|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9850" PostTypeId="1" AcceptedAnswerId="9917" CreationDate="2023-02-01T15:25:48.880" Score="2" ViewCount="144" Body="&lt;p&gt;I am looking for the name of a scheduling problem in literature with some references. Here is the variant that I have in mind.&lt;/p&gt;&#xA;&lt;p&gt;Given a set of jobs, employees have certain shifts that they can work on these jobs. Suppose employee &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; starts processing job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, but before completing the job, his shift finishes. The rule is that no other job can replace &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; until its process is completed. That is why either the same employee or another employee should come and continue working on &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; based on their shift requirements.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering how this problem is defined / called and if there are efficient formulation proposed for it in the literature. I am aware of the preemptive scheduling, but my problem definition is a little bit different than it.&lt;/p&gt;&#xA;" OwnerUserId="4025" LastEditorUserId="4025" LastEditDate="2023-02-02T14:47:45.167" LastActivityDate="2023-02-10T10:12:07.840" Title="Definition of a modified scheduling problem where jobs are halted based on the shifts of employees" Tags="|optimization|reference-request|scheduling|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9851" PostTypeId="2" ParentId="9850" CreationDate="2023-02-01T15:56:34.400" Score="-4" Body="&lt;p&gt;It can be solved by mathematical optimization. I'd go by below:&lt;br /&gt;&#xA;Define variable &lt;span class=&quot;math-container&quot;&gt;$ x_{j,m}^t$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; represents the shift&lt;br /&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$D_j$&lt;/span&gt; is the processing time for job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$ S_t$&lt;/span&gt; is shift duration at &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; then you need a constraint like&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ D_j \le Ux_{j,m}^{t+1} + \sum_{k\le t}x_{j,m}^kS_k$&lt;/span&gt;&lt;br /&gt;&#xA;and&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{k\le t}x_{j,m}^kS_k - D_j \le U(1-x_{j,m}^{t+1})$&lt;/span&gt;&lt;br /&gt;&#xA;where binary variable &lt;span class=&quot;math-container&quot;&gt;$ x_{j,m}^t=1$&lt;/span&gt; if job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is assigned to machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, else 0 and&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; is a large number, not too large just based on the scle of the model, could be upper bound of something like sum of all shift durations.&#xA;Also&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_j x_{j,m}^t \le 1$&lt;/span&gt;: ensures one job per machine at a time&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-01T19:28:37.440" LastActivityDate="2023-02-01T19:28:37.440" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9852" PostTypeId="2" ParentId="9836" CreationDate="2023-02-01T16:54:55.653" Score="3" Body="&lt;p&gt;If, per a comment, we ignore questions of how time periods link together, whether vehicles return to their starting points etc., and if we assume that a vehicle makes at most one trip per time period (stopping at a single destination), then to allow up to &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; passengers per vehicle you can introduce nonnegative integer variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^t$&lt;/span&gt; representing the number of vehicle trips from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and replace (2) with &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j\in V} x_{ij}^t \le X_i^t\quad \forall i\in V,\,\forall t$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$f_{ij}^t \le c\cdot x_{ij}^t\quad \forall i,j\in V,\,\forall t.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-02-01T16:54:55.653" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9853" PostTypeId="1" CreationDate="2023-02-01T21:00:38.577" Score="3" ViewCount="114" Body="&lt;p&gt;In this problem, I need to pick the optimal charging and discharging times and durations of an electric car-sharing battery to maximize income - not just for a single (dis)charging cycle, but a whole bunch, with some car-sharing bookings that must work in between.&lt;/p&gt;&#xA;&lt;p&gt;The curve in the graph is the time series data of the energy price &lt;span class=&quot;math-container&quot;&gt;$P(t)$&lt;/span&gt;. The red box is a car-sharing booking, which pauses the (dis)charging. It discharges the battery by &lt;span class=&quot;math-container&quot;&gt;$\Delta \text{SoC}_{b_n}$&lt;/span&gt;. Left of the booking is a discharging period starting at &lt;span class=&quot;math-container&quot;&gt;$I_n$&lt;/span&gt;, lasting for &lt;span class=&quot;math-container&quot;&gt;$\Delta i_n$&lt;/span&gt;. On the right is a charging time at &lt;span class=&quot;math-container&quot;&gt;$S_n$&lt;/span&gt; for the duration of &lt;span class=&quot;math-container&quot;&gt;$\Delta s_n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The red line signifies the state of the battery charge (state of charge, SoC), which follows the charging and discharging cycle and the usage of the car.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HBJfI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HBJfI.png&quot; alt=&quot;sketch of the price data and the naming of my variables&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;My objective function is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f_{objective} = \sum_{n=0}^{m} \int\limits_{I_n}^{I_n + \Delta i_n} P(t) \,dt - \int\limits_{S_n}^{S_n + \Delta s_n} P(t) \,dt &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, I directly integrate the price data &lt;span class=&quot;math-container&quot;&gt;$P(t)$&lt;/span&gt; with my variables, setting the intervals and the times.&lt;/p&gt;&#xA;&lt;p&gt;The constraints are primarily for SoC: At no time can the battery be fuller than 100% and emptier than 0%. I try to express that with the upper bound of the sum of &lt;span class=&quot;math-container&quot;&gt;$1 .. m$&lt;/span&gt;.  (&lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is the charge/time factor)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;0  \leq \sum_{n=0}^{1..m} -\Delta i_n \cdot c - \Delta \text{SoC}_{b_n} + \Delta s_n \cdot c \leq 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and even the individual charges can never leave the SoC-interval of 0..1:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;0  \leq \Delta i_n \cdot c \leq 1, \quad&#xA;0  \leq \Delta \text{SoC}_{b_n}  \leq 1, \quad &#xA;0  \leq  \Delta s_n \cdot c \leq 1&#xA;$$&lt;/span&gt;&#xA;The (dis)charging and booking times can not overlap.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;I_n + \Delta i_n &amp;lt; B_n, \quad &#xA;B_n + \Delta b_n &amp;lt; S_n, \quad &#xA;S_n + \Delta s_n &amp;lt; I_{n+1}   &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I wrote some python code for this and ran into problems with the integration. I have difficulty understanding the pyomo &lt;code&gt;Integral&lt;/code&gt; function and how to use it, especially with my time series data. I tried to integrate with NumPy functionality, but that fails. Can you please help me make this work? I am a pyomo noob and still struggle with concepts and terminology.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;from pyomo.environ import *&#xA;from pyomo.opt import SolverFactory&#xA;&#xA;def make_demo_data():&#xA;    x = np.linspace(0, 2 * np.pi, 100)&#xA;    y = np.sin(x) + 1.5 -x*.025  # add offset to make sure all values are positive&#xA;    return np.array([x, y])&#xA;&#xA;def integrate(data_a, x, delta_x):&#xA;    x = x.values&#xA;    delta_x = delta_x.values&#xA;    scaling_factor = 100 / (4*np.pi)&#xA;    x_start = x&#xA;    x_end = x + delta_x&#xA;    x_data = np.linspace(x_start, x_end, 5)&#xA;    y_interp = np.interp(x_data, data_a[0], data_a[1])&#xA;    earning = np.trapz(y_interp, x_data * scaling_factor)&#xA;    return earning&#xA;&#xA;data = make_demo_data()&#xA;&#xA;model = ConcreteModel(name=&amp;quot;(DischargePlan)&amp;quot;)&#xA;&#xA;# define variables&#xA;model.i = Var(domain=NonNegativeReals, name=&amp;quot;i&amp;quot;)&#xA;model.delta_i = Var(domain=NonNegativeReals, name=&amp;quot;delta_i&amp;quot;)&#xA;model.s = Var(domain=NonNegativeReals, name=&amp;quot;s&amp;quot;)&#xA;model.delta_s = Var(domain=NonNegativeReals, name=&amp;quot;delta_s&amp;quot;)&#xA;&#xA;model.objectives = Objective(expr=integrate(data, model.i, model.delta_i) - integrate(data, model.s, model.delta_s), sense=maximize)&#xA;&#xA;model.constraints = ConstraintList()&#xA;model.constraints.add(model.i + model.delta_i &amp;lt;= np.pi)&#xA;model.constraints.add(model.s + model.delta_s &amp;lt;= 2*np.pi)&#xA;model.constraints.add(1 - model.delta_i + model.delta_s &amp;lt;= 1)&#xA;model.constraints.add(1 - model.delta_i  &amp;lt;= 1)&#xA;model.constraints.add(1 - model.delta_i + model.delta_s &amp;gt; 0)&#xA;model.constraints.add(1 - model.delta_i &amp;gt; 0)&#xA;&#xA;solver = SolverFactory('CPLEX')&#xA;solver.solve(model)&#xA;print(model.objectives())&#xA;print(f&amp;quot;i = {model.i.values}, delta_i = {model.delta_i.values}, s = {model.s.values}, delta_s = {model.delta_s.values}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11166" LastActivityDate="2023-02-13T08:27:56.797" Title="How to maximise a function with non-differentiable constraints while integrating over a time series data series with linear programming?" Tags="|linear-programming|python|pyomo|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="9854" PostTypeId="2" ParentId="9365" CreationDate="2023-02-02T01:22:36.423" Score="6" Body="&lt;p&gt;By request, here's an explicit derivation.  The desired logical implication is &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n x_i \ge k \implies y = 1.$$&lt;/span&gt;&#xA;Its contrapositive is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y \not= 1 \implies \sum_{i=1}^n x_i &amp;lt; k,$$&lt;/span&gt;&#xA;equivalently (because &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is binary and &lt;span class=&quot;math-container&quot;&gt;$\sum_i x_i$&lt;/span&gt; is an integer),&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y = 0 \implies \sum_{i=1}^n x_i \le k - 1.$$&lt;/span&gt;&#xA;This logical implication can be enforced via big-M constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n x_i - (k - 1) \le M y.$$&lt;/span&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n x_i - (k - 1) \le 0$&lt;/span&gt;, as desired.&#xA;If &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^n x_i - (k - 1) \le M$&lt;/span&gt;, and we want to choose the smallest &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; that makes the constraint redundant, so take &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to be an upper bound on the left-hand side:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$M = \sum_{i=1}^n 1 - (k - 1) = n - k + 1.$$&lt;/span&gt;&#xA;The desired constraint is thus&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n x_i - (k - 1) \le (n - k + 1) y,$$&lt;/span&gt;&#xA;equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n x_i \le k - 1 + (n - k + 1) y.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-02-02T01:22:36.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9855" PostTypeId="1" CreationDate="2023-02-02T06:19:50.043" Score="3" ViewCount="95" Body="&lt;p&gt;I would like to incorporate a constraint to my model, this constraint is related to supplier quality or/ reliability selection  with respect to efficiency, furthermore, I would like to make the parameter &lt;span class=&quot;math-container&quot;&gt;$ q_{s} $&lt;/span&gt; as an uncertain and deal with it using robust optimization where &lt;span class=&quot;math-container&quot;&gt;$ {1}\geq  q_{s}\geq {0} $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ \varepsilon _{s} $&lt;/span&gt; is a lower bound parameter, for instance 0.95.So I am wondering if the below constraint is correct? I would like also to know if considering the parameter &lt;span class=&quot;math-container&quot;&gt;$q_{s}$&lt;/span&gt; as an uncertain parameter in robust optimization is a valid assumption ?&#xA;&lt;br/&gt; S : Set of suppliers.&#xA;&lt;br/&gt;W : Set of warehouses&#xA;&lt;br/&gt;C : Set of customers.&#xA;&lt;br/&gt;&lt;span class=&quot;math-container&quot;&gt;$ Q{sw}$&lt;/span&gt; : decision variable: amount of product shipped from s to w.&#xA;&lt;br/&gt;&lt;span class=&quot;math-container&quot;&gt;$ Q{wc}$&lt;/span&gt; : decision variable: amount of product shipped from w to c.&#xA;&lt;br/&gt; &lt;span class=&quot;math-container&quot;&gt;$ q_{s}$&lt;/span&gt; : non-defective rate of ssuplier.&#xA;&lt;br/&gt; &lt;span class=&quot;math-container&quot;&gt;$ \varepsilon _{s} $&lt;/span&gt; : minimum acceptable non defective rate.&#xA;&lt;br/&gt; Constraint:&#xA;&lt;br/&gt;&lt;span class=&quot;math-container&quot;&gt;$ q_{s}* \sum_{s}\left(Q_{sw} \right) \geq \sum_{s}\left(Q_{wc} \right)* \varepsilon _{s} $&lt;/span&gt; for all s&#xA;&lt;br/&gt; The original constraint was nonlinear given as;&#xA;&lt;br/&gt;&lt;span class=&quot;math-container&quot;&gt;$ \frac{q_{s}* \sum_{s}\left(Q_{sw} \right)}{\sum_{s}\left(Q_{wc} \right)} \geq  \varepsilon _{s} $&lt;/span&gt; for all s&lt;/p&gt;&#xA;" OwnerUserId="11004" LastEditorUserId="11004" LastEditDate="2023-02-02T09:57:13.897" LastActivityDate="2023-02-02T15:31:42.417" Title="Robust Optimization and Supplier Selection" Tags="|robust-optimization|supply-chain|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9856" PostTypeId="1" AcceptedAnswerId="9857" CreationDate="2023-02-02T09:03:08.883" Score="4" ViewCount="226" Body="&lt;p&gt;I want to ensure, that a generator (in my case a heat generator, for example a boiler) first starts to output thermal energy, when a certain minimum output can be realized. Otherwise the output should be zero. For example, the boiler should not run if it can only output 1mW, first if it can output at least 1kW or so.&lt;/p&gt;&#xA;&lt;p&gt;So what I actually want to do, is make the the value of a variable dependent on its own value. Basically:&lt;/p&gt;&#xA;&lt;p&gt;IF &lt;span class=&quot;math-container&quot;&gt;$x\geq x_\text{min}$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$x=x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;ELSE: &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To show what I mean, here is a broken down version of my problem formulation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;sets:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{T}$&lt;/span&gt; for timesteps&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Parameters:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_t\quad\forall t\in\mathcal{T}$&lt;/span&gt; for thermal demand at timestep &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt; for boiler efficiency&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_\text{min}$&lt;/span&gt; for minimum possible boiler heat output&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Variables:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$g_t\quad\forall t\in\mathcal{T}$&lt;/span&gt; for gas fed to boiler at timestep &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_t\quad\forall t\in\mathcal{T}$&lt;/span&gt; for heat from boiler at timestep &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$r_t\quad\forall t\in\mathcal{T}$&lt;/span&gt; for deciding whether the boiler is running at timestep &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; (binary variable)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Minimize difference between thermal demand and supply by boiler (I think enforcing equality via constraint would lead to infeasibility, if the boiler can only run with a certain minimum output).&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{min.}\quad\sum_{t\in\mathcal{T}}d_t-h_t$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Balance input/output of boiler:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$h_t=\eta\cdot g_t\quad\forall t\in\mathcal{T}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And my approach to enforce minimum output (which does not work for &lt;span class=&quot;math-container&quot;&gt;$r_t=0$&lt;/span&gt;):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$h_t\geq r_t\cdot h_\text{min}\quad\forall t\in\mathcal{T}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have seen Solutions like &lt;a href=&quot;https://or.stackexchange.com/questions/6090/model-if-else-statement&quot;&gt;here&lt;/a&gt; or &lt;a href=&quot;https://math.stackexchange.com/questions/4086562/making-a-variable-in-a-linear-program-be-equal-to-a-ramp-function/4086955#4086955&quot;&gt;here&lt;/a&gt;.&#xA;However, I think these solutions are not applicable here, since there is one variable dependent on the value of another variable. But here I really want to say: &amp;quot;If the output &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is greater than for example 1 kW, say 2kW, than &lt;span class=&quot;math-container&quot;&gt;$x=2$&lt;/span&gt;kW, but otherwise &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt;kW&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Is there a possibility to achieve this if-else like behaviour?&lt;/p&gt;&#xA;" OwnerUserId="9052" LastActivityDate="2023-02-03T12:25:18.127" Title="how to ensure minimum output of a generator (else zero output) in linear programming?" Tags="|linear-programming|constraint|binary-variable|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9857" PostTypeId="2" ParentId="9856" CreationDate="2023-02-02T09:29:24.270" Score="7" Body="&lt;p&gt;What you describe is the disjunction&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(x \geq x_\min) \mbox{ or } (x=0),$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which can be input directly into any optimization software that supports disjunctive constraints. Alternatively, you need an upper bound on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, say &lt;span class=&quot;math-container&quot;&gt;$x_\max$&lt;/span&gt;, which leads to the Big-M formulation&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_\min z \leq  x \leq x_\max z,\; z \in \{0,1\}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In your application, I guess &lt;span class=&quot;math-container&quot;&gt;$x_\max$&lt;/span&gt; would be interpreted as the maximum possible thermal output from the boiler, and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is whether thermal energy is being output from the boiler or not.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2023-02-02T09:37:11.350" LastActivityDate="2023-02-02T09:37:11.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9858" PostTypeId="2" ParentId="9855" CreationDate="2023-02-02T13:17:48.710" Score="2" Body="&lt;p&gt;RO is still in academic research area and several methods have been proposed. What I would do is this( not using any math programming model as you have already formulated already)&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Solve for q=0&lt;/li&gt;&#xA;&lt;li&gt;Solve for q=1: in other words best and worst case scenario.&lt;/li&gt;&#xA;&lt;li&gt;Use max (or min) of the two optimal values&lt;br /&gt;&#xA;Or&lt;/li&gt;&#xA;&lt;li&gt;Then use the values of the decision variables as bounds and re-solve without q.&lt;br /&gt;&#xA;Or&lt;/li&gt;&#xA;&lt;li&gt;Goal programming: use the optimal values of the above two cases as constraint ( upper and lower bound), on the objective function with slack variables (&lt;span class=&quot;math-container&quot;&gt;$s^+$&lt;/span&gt;,&lt;span class=&quot;math-container&quot;&gt;$s^-$&lt;/span&gt;): max and min deviation and solve with objective as min (&lt;span class=&quot;math-container&quot;&gt;$s^++s^-$&lt;/span&gt;).&lt;br /&gt;&#xA;You can use both 4&amp;amp;5.&lt;br /&gt;&#xA;Below are couple of materials. I'd add one more that I found in this forum couple of days back.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://cdnsciencepub.com/doi/10.1139/L08-131&quot; rel=&quot;nofollow noreferrer&quot;&gt;Reading 1&lt;/a&gt;&lt;br /&gt;&#xA;&lt;a href=&quot;https://arxiv.org/pdf/1501.02634.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Reading 2&lt;/a&gt; as mentioned &lt;a href=&quot;https://or.stackexchange.com/questions/9799/robust-optimization-for-ip-formulation&quot;&gt;here&lt;/a&gt;&lt;br /&gt;&#xA;&lt;a href=&quot;https://math.stackexchange.com/questions/4245983/defeinition-of-robust-counterpart-in-robust-optimization&quot;&gt;Reading 3&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-02T15:31:42.417" LastActivityDate="2023-02-02T15:31:42.417" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9859" PostTypeId="1" AcceptedAnswerId="9860" CreationDate="2023-02-02T18:00:11.930" Score="-1" ViewCount="124" Body="&lt;p&gt;What is the best way to start modelling with &lt;code&gt;GurobiPy&lt;/code&gt;, in order to utilize it, for research purpose (&lt;strong&gt;i.e.&lt;/strong&gt; more complicated problems)?&lt;/p&gt;&#xA;" OwnerUserId="11004" LastEditorUserId="11200" LastEditDate="2023-02-11T00:32:26.927" LastActivityDate="2023-02-11T00:32:26.927" Title="GurobiPy Tutorials and hands on from beginner to advanced" Tags="|optimization|python|gurobi|gurobipy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9860" PostTypeId="2" ParentId="9859" CreationDate="2023-02-02T18:33:23.953" Score="2" Body="&lt;p&gt;Useful links:&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.gurobi.com/documentation/9.5/quickstart_mac/cs_python.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Intro&lt;/a&gt;&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_python_api_overview.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python API&lt;/a&gt;- queries, attributes etc.&lt;br /&gt;&#xA;Some &lt;a href=&quot;https://www.gurobi.com/documentation/10.0/examples/python_examples.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;basic examples&lt;/a&gt; in Python demonstrating how to use callback, lazy constraints (delayed row generation) etc.&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.gurobi.com/jupyter_models/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python API Examples&lt;/a&gt;-Beginner to Advanced&lt;br /&gt;&#xA;Also check the &lt;a href=&quot;https://gurobi-machinelearning.readthedocs.io/en/stable/firststeps-introduction.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi-ML&lt;/a&gt; integration&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-02T19:44:11.620" LastActivityDate="2023-02-02T19:44:11.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9861" PostTypeId="1" CreationDate="2023-02-02T19:32:59.153" Score="2" ViewCount="425" Body="&lt;p&gt;How does the &amp;quot;re-optimize&amp;quot; feature work in commercial optimization solvers such as IBM CPLEX and Gurobi? I recently experienced a considerable performance boost by re-solving a model with incremental changes to the model. I was interested to learn how those solvers improve subsequent computations.&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="500" LastEditDate="2023-12-13T18:05:27.463" LastActivityDate="2023-12-13T18:05:27.463" Title="&quot;Re-optimize&quot; feature in Commercial Optimization" Tags="|optimization|cplex|gurobi|combinatorial-optimization|warm-start|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9862" PostTypeId="2" ParentId="9861" CreationDate="2023-02-02T19:43:49.073" Score="1" Body="&lt;p&gt;Probably this &lt;a href=&quot;https://www.gurobi.com/documentation/9.0/examples/modify_a_model.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt; from Gurobi will help. You have to call the optimize() function in gurobi after you change parameters like the rhs of a constraint, add/remove constraints, change bounds of variables, change objective coefficients or hyperparameters like optimal gap, integrality gap (for MIP), turning certain constraints into lazy constraints (kind of delayed row generation), changing warm start etc.&lt;br /&gt;&#xA;Basically the solver re-solves the model and there's option to consider the last feasible candidate set.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-02-02T19:43:49.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9863" PostTypeId="2" ParentId="9861" CreationDate="2023-02-02T20:19:40.190" Score="6" Body="&lt;p&gt;CPLEX has an advanced start parameter which dictates how it acts when solve is called on a previously solved/partially solved model.&lt;/p&gt;&#xA;&lt;p&gt;For MIP models with the default setting of the parameter, if you partially solve a model (stopping short of proven optimality) and then tweak solver parameters (without altering the model) and solve again, CPLEX will pick up where it left off, starting from the search tree left at the end of the first run. If you change the model, I don't think the old search tree can be used, but CPLEX can try to use the previous solution as a starting solution (using heuristics to try to &amp;quot;repair&amp;quot; it if changes to the model made it infeasible). A different setting of the parameter tells CPLEX to restart from the root but try to retain the current incumbent solution if there is one. (I'm not sure if CPLEX tries to repair the solution should it no longer be feasible, or just discards it.)&lt;/p&gt;&#xA;&lt;p&gt;For LP models with advanced start turned on, CPLEX will attempt to start from the final basis of the previous run or, if the barrier method is being used, try to restart from the last &amp;quot;barrier iterate&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;So, assuming the model has changed, a &amp;quot;hot start&amp;quot; for an LP might allow the solver to get to a feasible basis faster (perhaps by taking the last basis of the previous run and using dual simplex to restore feasibility) or might provide a feasible incumbent / primal bound sooner (by repairing a feasible solution to the previous model). Note the use of the word &amp;quot;might&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-02-02T20:19:40.190" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9865" PostTypeId="2" ParentId="9856" CreationDate="2023-02-03T12:25:18.127" Score="3" Body="&lt;p&gt;This is called a &lt;strong&gt;semi-continuous variable&lt;/strong&gt;. Most MIP solvers support such a variable type directly.&lt;/p&gt;&#xA;" OwnerUserId="907" LastActivityDate="2023-02-03T12:25:18.127" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9866" PostTypeId="1" AcceptedAnswerId="9867" CreationDate="2023-02-03T13:50:11.230" Score="1" ViewCount="73" Body="&lt;p&gt;&lt;strong&gt;I have this problem right here&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are &lt;strong&gt;N&lt;/strong&gt; passengers whose are at places &lt;strong&gt;1,2,...,N&lt;/strong&gt; respectively. The &lt;strong&gt;i-th&lt;/strong&gt; passenger, who is currently at place &lt;strong&gt;i&lt;/strong&gt;, wants to go to place &lt;strong&gt;i+N&lt;/strong&gt;. There are &lt;strong&gt;K&lt;/strong&gt; buses are currently at place &lt;strong&gt;0&lt;/strong&gt;. Bus &lt;strong&gt;k&lt;/strong&gt; can only contains &lt;strong&gt;q(k)&lt;/strong&gt; number of passengers at the same time. Given the 2-dimensional array distance matrix &lt;strong&gt;d&lt;/strong&gt;, where &lt;strong&gt;d[i][j]&lt;/strong&gt;  is the distance of place &lt;strong&gt;i&lt;/strong&gt; to place &lt;strong&gt;j&lt;/strong&gt;. Make an optimal route plan so that the total distance traveled by all buses is the shortest.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Input data:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;number of passengers: &lt;strong&gt;N&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;number of buses: &lt;strong&gt;K&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;distance matrix: 2D matrix &lt;strong&gt;d&lt;/strong&gt;, &lt;strong&gt;d[i][j]&lt;/strong&gt; is the distance from &lt;strong&gt;i&lt;/strong&gt; to &lt;strong&gt;j&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;List of buses' capacity: 1D matrix &lt;strong&gt;q&lt;/strong&gt;, where &lt;strong&gt;q[k]&lt;/strong&gt; is the capacity of bus &lt;strong&gt;k&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Output data:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Route plan for &lt;strong&gt;K&lt;/strong&gt; buses&lt;/li&gt;&#xA;&lt;li&gt;Total distances traveled&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;The progress is:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;place &lt;strong&gt;0&lt;/strong&gt;: depot&lt;/li&gt;&#xA;&lt;li&gt;place &lt;strong&gt;1 -&amp;gt; N&lt;/strong&gt;: pickup places&lt;/li&gt;&#xA;&lt;li&gt;place &lt;strong&gt;N+1 -&amp;gt; 2N&lt;/strong&gt;: drop places&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;I came up with some constraints also, but I think these are not enough:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The number of passengers &amp;lt;= the capacity of the bus&lt;/li&gt;&#xA;&lt;li&gt;Buses start with 0 passengers and end with 0 passengers&lt;/li&gt;&#xA;&lt;li&gt;Each bus go through a place &lt;strong&gt;ONCE&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;... And some more, for instance: constraint for avoiding subtours&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Can anybody help me out with this problem?&lt;/p&gt;&#xA;" OwnerUserId="11180" LastEditorUserId="491" LastEditDate="2023-02-03T20:03:26.230" LastActivityDate="2023-02-03T20:03:26.230" Title="How to mathematically model this vehicle routing with pickup and deliveries problem?" Tags="|optimization|mixed-integer-programming|vehicle-routing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9867" PostTypeId="2" ParentId="9866" CreationDate="2023-02-03T14:20:25.087" Score="1" Body="&lt;p&gt;The below is what I put in in another answer. It has additional LiFO constreaint- last load pickup, first to be dropped.&lt;/p&gt;&#xA;&lt;p&gt;Basically it says after the last pickup vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; doesn't visit any other node unless the node is a delivery point &lt;span class=&quot;math-container&quot;&gt;$\in D$&lt;/span&gt; for the last picked up request.&lt;/p&gt;&#xA;&lt;p&gt;Hierarchical Objective - minimize travel time and number of unserved customers. Other objectives could be minimize number of vehicles needed and transport cost.&lt;/p&gt;&#xA;&lt;p&gt;Sets&lt;br /&gt;&#xA;Nodes:&lt;span class=&quot;math-container&quot;&gt;$N_i$&lt;/span&gt;&lt;br /&gt;&#xA;N = &lt;span class=&quot;math-container&quot;&gt;$O \cup P \cup D$&lt;/span&gt; where O=&lt;span class=&quot;math-container&quot;&gt;$\{0,2n+1\}$&lt;/span&gt;:depot; P=&lt;span class=&quot;math-container&quot;&gt;$\{1,2,...n\}$&lt;/span&gt; Pickup points and &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$D=\{n+1,n+2,...2n\}$&lt;/span&gt; Delivery points: basically pickup and delivery points are paired\&lt;/p&gt;&#xA;&lt;p&gt;Arcs: &lt;span class=&quot;math-container&quot;&gt;$A_{ij}$&lt;/span&gt;&lt;br /&gt;&#xA;Open/Close time for each point &lt;span class=&quot;math-container&quot;&gt;$e_i, l_i $&lt;/span&gt;&lt;br /&gt;&#xA;Vehicles: &lt;span class=&quot;math-container&quot;&gt;$K = \{1,2,...v\}$&lt;/span&gt;: with capacity &lt;span class=&quot;math-container&quot;&gt;$Q_k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Parameters&#xA;Request: &lt;span class=&quot;math-container&quot;&gt;$q_i$&lt;/span&gt;: it's the load from pickup &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to delivery &lt;span class=&quot;math-container&quot;&gt;$n+i$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$q_{n+i}+q_i = 0$&lt;/span&gt;&lt;br /&gt;&#xA;Customers &lt;span class=&quot;math-container&quot;&gt;$≡ $&lt;/span&gt;Pickup point request, so number of customers = &lt;span class=&quot;math-container&quot;&gt;$ \vert P \vert = n$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Variables&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{ijk} \in \{0,1\}$&lt;/span&gt; indicates if vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is used on trip &lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$T_{ik}$&lt;/span&gt;: Total travel time for vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$L_{ik}$&lt;/span&gt;: total load for vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;obj = &lt;span class=&quot;math-container&quot;&gt;$\min w_1 (\sum_{k\in K}\sum_{i,j\in A}t_{ij}x_{ijk}) + w_2\frac{(n-\sum_k\sum_{i,j \in A}x_{ijk}-v)}2 $&lt;/span&gt;&lt;br /&gt;&#xA;s.t.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$T_{ik}+ t_{ij} - M(1-x_{ijk}) \le T_{jk} \ \ \forall i,j \in A \ \forall k \in K$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$L_{ik}+ q_{j} - M(1-x_{ijk}) \le L_{jk} \ \ \forall i,j \in A \ \forall k \in K$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$e_i \le T_{ik} \le l_i \ \ i \in O$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Pairing &amp;amp; Precedence&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in N}x_{ijk} = \sum_{j\in N}x_{j,n+i,k}  \ \ \forall i \in P \ \ \forall k$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$T_i + t_{i,n+i} \le T_{n+i} \ \ \forall i \in P \ \forall k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Enure each vehicle leaves &amp;amp; returns to depot: Subtour prevention&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_j x_{0,j,k}=\sum_i x_{i,2n+1,k}\ \ \forall k$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_j x_{0,j,k}=1 \ \ \forall k$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$1 \le \sum_k\sum_j x_{ijk} \ \ \forall i \in N$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$q_i \le L_{i,k} \ \ \forall k \ \forall i \in P$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;LIFO Policy-basically after a pickup vehicle cant travel to another unpaired delivery point&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$L_{n+i,k} = L_{i,k}-q_i \ \ \forall i \in P \ \forall k$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in D-\{n+i\}}x_{ijk} = 0 \ \ \forall i \in P \ \ \forall k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \le L_{i,k};  0\le T_{i,k} \ \forall i \in N $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$w_1,w_2$&lt;/span&gt; are objective weights for significance or priority.&lt;/p&gt;&#xA;&lt;p&gt;References that explain it better&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.matec-conferences.org/articles/matecconf/pdf/2018/63/matecconf_imiec2018_07003.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MATEC&lt;/a&gt;,&lt;br /&gt;&#xA;&lt;a href=&quot;https://numerique.banq.qc.ca/patrimoine/details/52327/2494771&quot; rel=&quot;nofollow noreferrer&quot;&gt;U of Montreal&lt;/a&gt;,&lt;br /&gt;&#xA;&lt;a href=&quot;https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=8910558&quot; rel=&quot;nofollow noreferrer&quot;&gt;IEEE&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-02-03T14:20:25.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9869" PostTypeId="1" CreationDate="2023-02-04T02:01:32.717" Score="3" ViewCount="62" Body="&lt;p&gt;I have a MILP formulation where one of the parameters in the constraints is unknown but comes from a know uncertainty set (Robust Optimization approach). As far as I researched the first step for formulating the robust counterpart is to identify the worst case of the realized uncertainty and either max/or min it.&lt;/p&gt;&#xA;&lt;p&gt;What are the best ways to identifying the worst case that comes from the uncertainty set?&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="491" LastEditDate="2023-02-06T12:56:19.993" LastActivityDate="2023-02-06T12:56:19.993" Title="Identifying worst case of realized uncertainty" Tags="|mixed-integer-programming|linear-programming|robust-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9870" PostTypeId="2" ParentId="9869" CreationDate="2023-02-04T04:05:32.097" Score="1" Body="&lt;p&gt;Worst case implies either lower (max)/upper bound (min). I'd try using duality principle as feasible solution to the dual will give me a bound to the primal objective. So you can use the bounds of the random variable as a constraint, solve the dual, then use the value found for the random and the dual bound as constraints on the objective, re-solve.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-02-04T04:05:32.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9872" PostTypeId="1" AcceptedAnswerId="9873" CreationDate="2023-02-04T23:05:41.783" Score="4" ViewCount="575" Body="&lt;p&gt;I have a convex optimization problem:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Maximize    obj1&#xA;Minimize    obj2&#xA;Some constraint&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now to solve this problem, I used lambda to make it one problem:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Maximize    lambda * obj1 - (1-lambda) * obj2 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For my problem, I considered lambda to be 0.8, which is an excellent answer when I simulate my problem using the &amp;quot;cvxpy&amp;quot; in python. However, if I submit a paper including this problem, I will be questioned about the reason for setting the lambda as 0.8. I know that &amp;quot;It just worked&amp;quot; is not a good answer, and I want a scientific approach to finding the optimal value for lambda. The first idea that came to my mind was making lambda an optimization variable. But, very soon, I realized that by taking lambda as a variable, the problem would no longer count as a linear programming problem. So, I wonder if there is a good way to find lambda in a convex optimization problem that can be justified in a scientific paper.&lt;/p&gt;&#xA;" OwnerUserId="11188" LastActivityDate="2023-02-05T02:24:10.887" Title="Determining the optimize lambda in Multi-Objective Optimization" Tags="|linear-programming|convex-optimization|multi-objective-optimization|cvxpy|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9873" PostTypeId="2" ParentId="9872" CreationDate="2023-02-04T23:31:22.380" Score="9" Body="&lt;p&gt;There is no mathematical way to derive (or justify) a value for &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;. The justification has to be made in the context of a specific problem and a specific (reasonably credible) decision maker. Basically, the choice of &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; says that the decision maker would be indifferent between an increase (decrease) of one unit of obj1 and an increase (decrease) of &lt;span class=&quot;math-container&quot;&gt;$\frac{\lambda}{1-\lambda}$&lt;/span&gt; units of obj2. So, for example, if obj1 measures number of traffic accidents avoided and obj2 is thousands of dollars spent on safety measures, choosing &lt;span class=&quot;math-container&quot;&gt;$\lambda=0.6$&lt;/span&gt; says that the decision maker would be indifferent (neither particularly in favor nor particularly against) spending 1,500 per accident avoided.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-02-04T23:31:22.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9874" PostTypeId="2" ParentId="9872" CreationDate="2023-02-05T00:03:29.970" Score="8" Body="&lt;p&gt;Another approach could be generating the &lt;a href=&quot;https://en.wikipedia.org/wiki/Pareto_front&quot; rel=&quot;noreferrer&quot;&gt;Pareto Frontier&lt;/a&gt;, solving the problem several times for different values of lambda, using a Weighted sum algorithm (see &lt;a href=&quot;https://www.tandfonline.com/doi/abs/10.1080/02331934.2010.511674&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; or &lt;a href=&quot;https://arxiv.org/pdf/1903.07041.pdf&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2023-02-05T00:03:29.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9875" PostTypeId="2" ParentId="9872" CreationDate="2023-02-05T02:24:10.887" Score="7" Body="&lt;p&gt;In addition to the above answers, there's good deal of discussion &lt;a href=&quot;https://or.stackexchange.com/questions/8182/weight-choice-in-multi-objective-weighted-sum&quot;&gt;here&lt;/a&gt;. One of the experts logically breaks down some key questions like avoiding dominating solution by sticking to single combination of weights. Rather you should experiment with different combinations to ensure you get Pareto optimal candidate set.&lt;br /&gt;&#xA;In addition I'd say you can also try with a common method like defining a variable &lt;span class=&quot;math-container&quot;&gt;$z \le$&lt;/span&gt; obj2. Then maximize obj1 + &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. Or you can try with priority based optimization and goal programming.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-02-05T02:24:10.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9876" PostTypeId="2" ParentId="9850" CreationDate="2023-02-05T11:12:33.923" Score="-1" Body="&lt;p&gt;As you pointed out this is not a case that preemption would help. The preemptive constraint is often used where we are still allowed to split a job/task if another job/task with higher priority needs to be processed on the same machine/resource. In this case, the on-hand processed task would be stopped or moved to another machine/resource (splitting the processing task) to process the new one with higher priority.&lt;/p&gt;&#xA;&lt;p&gt;Now, I assume there are no other constraints on the problem you mentioned. The scheduling model you are having is a variant of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Parallel_task_scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;Parallel machine scheduling problem&lt;/a&gt; with the resourced constraints. &lt;span class=&quot;math-container&quot;&gt;$ \text{P}_{m} ||  \sum w_{j}c_{j} \ Or \ C_{max}$&lt;/span&gt;. Also, As far as I know, the problem is classified as NP-Hard in the Ordinary Sense&lt;span class=&quot;math-container&quot;&gt;$^1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$ \text{P}_{m} || C_{max}$&lt;/span&gt; can already be solved efficiently by applying &lt;em&gt;&lt;strong&gt;LPT&lt;/strong&gt;&lt;/em&gt; (The Longest Processing Time first) rule. Also, one of its practical forms in presence of the machine eligibility constraint would be &lt;em&gt;&lt;strong&gt;LFJ/LFM&lt;/strong&gt;&lt;/em&gt; (the Least Flexible Job/Machine first). Besides the mentioned algorithms it would be worth taking a look at MILP, CP, etc. to solve such a problem in an optimal sense.&lt;/p&gt;&#xA;&lt;p&gt;To assign employees to the machines in each shift, either &lt;a href=&quot;https://docs.oracle.com/cd/A60725_05/html/comnls/us/crp/rccp.htm#:%7E:text=RCCP%20verifies%20that%20you%20have,schedule%20and%2For%20available%20capacity.&quot; rel=&quot;nofollow noreferrer&quot;&gt;rough cut capacity planning&lt;/a&gt; (RCCP) or the simulation method would be useful. Please, be aware that it is still usual that at the end of each shift, some WIPs/jobs would be remaining or being under process till another operator comes to complete that. Such times are often called the chang-over time and can be assumed as planned stop time.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$^1$&lt;/span&gt; - &lt;a href=&quot;https://link.springer.com/book/10.1007/978-3-540-69516-5&quot; rel=&quot;nofollow noreferrer&quot;&gt;Scheduling Algorithms&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-02-05T11:12:33.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9877" PostTypeId="2" ParentId="9861" CreationDate="2023-02-05T12:49:26.037" Score="1" Body="&lt;p&gt;Here are two threads published by @Erwin Kalvelagen on his blog that would be useful:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://yetanothermathprogrammingconsultant.blogspot.com/2017/01/mip-starts-sometimes-disappoint.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIP Starts sometimes disappoint&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Modern MIP solvers allow to use a good integer solution to “warm&#xA;start” the branch and bound process. This looks like a very good&#xA;approach to cut down on total solution times, and it sometimes is. But&#xA;in many cases it turns out, finding good solutions and passing them on&#xA;to the MIP solver is not worth the while.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://yetanothermathprogrammingconsultant.blogspot.com/2015/03/reliability-of-nlp-solvers.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Reliability of NLP solvers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;NLP solvers can fail for a number of reasons. One way to increase the&#xA;reliability of a production run is to use a back-up solver in case the&#xA;main solver fails. In GAMS primal and dual information is passed&#xA;between SOLVE statements even if different solvers are used. This is&#xA;actually very useful in a case I just observed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I was really enjoying both.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-02-05T12:49:26.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9879" PostTypeId="1" CreationDate="2023-02-05T14:33:09.427" Score="2" ViewCount="82" Body="&lt;p&gt;for example, I got a list of tokens and each token's number of characters(length) is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;length = [2, 1, 1, 2, 2, 3, 2, 1, 1, 2, 2, 2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and here is the list of each token's probability of [not insert a linefeed, insert a linefeed] after the token&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;prob =  [[9.9978e-01, 2.2339e-04],  [9.9995e-01, 4.9344e-05],  [0.9469, 0.0531],  &#xA;         [9.9994e-01, 5.8422e-05],  [0.9964, 0.0036],  [9.9991e-01, 9.4295e-05],  &#xA;         [9.9980e-01, 1.9620e-04],  [1.0000e+00, 5.2492e-08],  [9.9998e-01, 1.8293e-05],  &#xA;         [9.9999e-01, 5.1220e-06],  [1.0000e+00, 3.9795e-06],  [0.0142, 0.9858]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and the result for the probabilies is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which means inserting a linefeed after the last token.&#xA;The whole length of this line is 21, and I would like to have a maximum of 20 characters per line.&#xA;In that case, I have to insert one (in this example, maybe more in other situations) more linefeed to make sure every line has 20 characters at most.&#xA;In this example, the best answer is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;since the 3rd token gets the highest probability of inserting a linefeed.&lt;/p&gt;&#xA;&lt;p&gt;My thought is to make all combinations of these probabilities.(Multiply them instead of adding) I got 12 tokens in this example, each token gets its 0-1 Classification Probability, so there are 2^12 kinds of combination. And I use the binary sequence to record every situation (since it's a 0-1 Classification Problem)and store them in a dictionary in format of [binary sequence, the combination of probabilities].&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    for i in range(nums):&#xA;        num *= 2&#xA;    numx = bin(num)&#xA;    for i in range(num):&#xA;        numx = bin(numx - 1)&#xA;        str1 = numx.encode('ascii').decode('ascii')&#xA;        str1 = str1.lstrip('0b')&#xA;        probb = 1&#xA;        for k in range(len(str1)):&#xA;            x = str1[k]&#xA;            if int(x) == 0:          # [0, 1]&#xA;                probb *= prob_task2[k][0]&#xA;            else:&#xA;                probb *= prob_task2[k][1]&#xA;        dic[str1] = probb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then I want to sort all kinds of combination, and search the possible result from high to low.&#xA;I make two loops for making all combinations. And another two loops for searching the combinations from top to low in order to meet the restriction of characters. But I got some troubles with the efficiency, since once there are 40 tokens, I have to count 2^40 kinds of combinations.&lt;/p&gt;&#xA;&lt;p&gt;I am not good at algorithms, so I do want to ask is there an efficient way to solve the problem.&lt;/p&gt;&#xA;" OwnerUserId="11193" LastActivityDate="2023-02-06T11:41:52.360" Title="How to find the maximum probability of satisfying the conditions in all combinations of arrays" Tags="|python|algorithms|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9880" PostTypeId="1" CreationDate="2023-02-05T14:34:37.933" Score="2" ViewCount="64" Body="&lt;p&gt;Consider a convex polyhedron &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;. Assume we have subsets &lt;span class=&quot;math-container&quot;&gt;$A_1,\ldots,A_n$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; that are themselves covex polyhedra and are mutually disjoint except maybe sharing an edge, and that their union gives &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;.&#xA;A simple example would be &lt;span class=&quot;math-container&quot;&gt;$A=[0,10]$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$A_1=[0,3]$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$A_2=[3,6]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_3=[6,10]$&lt;/span&gt; (observe &lt;span class=&quot;math-container&quot;&gt;$A_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_2$&lt;/span&gt; are disjoint except for a common extreme point, and so are &lt;span class=&quot;math-container&quot;&gt;$A_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_3$&lt;/span&gt;, and their union gives &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;What do we call this sort of partition-like subdivision of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; (in addition to a &amp;quot;cover&amp;quot;)?&lt;/p&gt;&#xA;" OwnerUserId="9880" LastEditorUserId="9880" LastEditDate="2023-02-05T16:50:17.343" LastActivityDate="2023-02-05T16:50:17.343" Title="Does this kind of &quot;partition&quot; have a name?" Tags="|convex-optimization|convexity|terminology|polyhedra|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9881" PostTypeId="2" ParentId="9880" CreationDate="2023-02-05T16:34:09.420" Score="1" Body="&lt;p&gt;What you are describing is often referred to as a &amp;quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Tessellation&quot; rel=&quot;nofollow noreferrer&quot;&gt;tesselation&lt;/a&gt;&amp;quot; or &amp;quot;tiling&amp;quot;. I believe they are studied a fair bit by people working on computer graphics.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-02-05T16:34:09.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9882" PostTypeId="1" CreationDate="2023-02-05T17:10:39.013" Score="3" ViewCount="133" Body="&lt;p&gt;I am new to the concept of robust optimization. I am currently trying to use a gamma uncertainty set (Bertsimas and Sim, 2002) for the following scenario. Suppose we have a constraint of the form &lt;span class=&quot;math-container&quot;&gt;$\sum{a_{i,j}} \geq b_j$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$I \in I, j \in &#xA;J$&lt;/span&gt; with uncertainty in the rhs. I was interested in finding an answer to the following questions about the gamma uncertainty set:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;As far as I understood, in the gamma uncertainty set we essentially introduce a set &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; which keeps track of the constraint coefficients that are subject to parameter uncertainty. Do we need to reformulate the constraint, so &lt;span class=&quot;math-container&quot;&gt;$b_j$&lt;/span&gt; is part of the lhs and introduce a variable which corresponds to its coefficient (e.g. &lt;span class=&quot;math-container&quot;&gt;$b_{j,u}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$u \in U$&lt;/span&gt;)?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Given that we want to simulate this, we can have gamma as a parameter and we select up to Gamma constraints to be changed. Assuming this is true, how do we decide the actual change to the nominal value so it fits the gamma uncertainty framework?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10707" LastActivityDate="2023-02-05T17:30:18.150" Title="Gamma uncertainty set" Tags="|optimization|mixed-integer-programming|linear-programming|robust-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9883" PostTypeId="2" ParentId="9882" CreationDate="2023-02-05T17:24:21.103" Score="3" Body="&lt;p&gt;I think you meant &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in I} a_{i,j} x_i \ge b_j$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt;.  In section 14.1 of Bertsimas/Weismantel, &lt;em&gt;Optimization over Integers&lt;/em&gt; (2005), your first question is addressed by introducing a new (fixed) variable &lt;span class=&quot;math-container&quot;&gt;$x_{n+1}=1$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$n=|I|$&lt;/span&gt;, and rewriting the constraint as &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in I} a_{i,j} x_i - b_j x_{n+1} \ge 0$&lt;/span&gt; so that all the uncertain coefficients appear on the LHS.&lt;/p&gt;&#xA;&lt;p&gt;For your second question, the uncertainty interval for each coefficient is part of the input.  It should be wide enough to capture the worst case in which Nature works against you but not so wide that it includes values that will never occur.  If you have historical data, you could apply statistical techniques for estimating the range of a random variable.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-02-05T17:30:18.150" LastActivityDate="2023-02-05T17:30:18.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9884" PostTypeId="1" CreationDate="2023-02-05T23:55:08.860" Score="2" ViewCount="188" Body="&lt;p&gt;I am trying to update the rhs of a constraint iteratively under a while loop in docplex, however, it does not work properly. As I analyze the output text file, while some constraints are updated as I want, others are not.&lt;/p&gt;&#xA;&lt;p&gt;z_bar is a list consists of y+1 elements and is updated at each iteration. Constraint set I want to change the RHS of consists of (x+1)*(y+1) constraints. z_bar is related to the j indice, however since each constraint involves i and j indices, I have to update all. What do you think I am doing wrong?&lt;/p&gt;&#xA;&lt;p&gt;Original constraint set:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Define sets&#xA;X_cbd = [(i, j) for i in range(1, x + 1) for j in range(1, y + 1)]&#xA;&#xA;# Define variables&#xA;x_cbd = sub_cbd.binary_var_dict(X_cbd, name=&amp;quot;x&amp;quot;, lb=0)&#xA;&#xA;for i in range(1, x + 1):&#xA;for j in range(1, y + 1):&#xA;sub_cbd.add_constraint(x_cbd[i, j] &amp;lt;= z_bar[j], ctname='constraint_name{0}{1}'.format(i, j))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Updating constraint set rhs attempt:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;z_bar=[]&#xA;&#xA;for i in range(1, x + 1):&#xA;    for j in range(1, y + 1):&#xA;        sub_cbd.get_constraint_by_name('constraint_name{0}{1}'.format(i, j)).rhs = z_bar[j]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user5245" LastEditorDisplayName="user5245" LastEditDate="2023-03-31T05:06:52.403" LastActivityDate="2023-03-31T05:06:52.403" Title="Updating constraint set rhs in docplex" Tags="|optimization|python|cplex|docplex|cplex-python-api|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9885" PostTypeId="2" ParentId="9884" CreationDate="2023-02-06T08:57:30.663" Score="1" Body="&lt;p&gt;I think the method you pointed out would be as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# model&#xA;&#xA;mdl = Model(name='...')&#xA;&#xA;variables part&#xA;&#xA;constraints like&#xA;mdl.add_constraint(LHD &amp;lt;=&amp;gt; rhs, 'name')&#xA;mdl.minimize(...)&#xA;&#xA;RHS = []&#xA;for i in range(0,N):  &#xA;   mdl.get_constraint_by_name(&amp;quot;name&amp;quot;).rhs=RHS[i]&#xA;   mdl.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also, you can use &lt;code&gt;'name'.rhs.add(value)&lt;/code&gt; to change the RHS coefficient in the model or any desired loop.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-02-06T08:57:30.663" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9886" PostTypeId="2" ParentId="9879" CreationDate="2023-02-06T10:28:49.297" Score="5" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$z_i \in \{0,1\}$&lt;/span&gt; be the binary decision of whether to predict a linefeed or not. Given the probability of a linefeed &lt;span class=&quot;math-container&quot;&gt;$p^1$&lt;/span&gt;, and the probability of no linefeed &lt;span class=&quot;math-container&quot;&gt;$p^0$&lt;/span&gt;, you seem to describe a maximum likelihood objective function of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \log \prod_i \left( p^1 z_i + p^0 (1 - z_i) \right),&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where your example has &lt;span class=&quot;math-container&quot;&gt;$p^1$&lt;/span&gt; = &lt;code&gt;[0.00022339, 4.9344e-5, 0.0531, 5.8422e-5, 0.0036, 9.4295e-5, 0.0001962, 5.2492e-8, 1.8293e-5, 5.122e-6, 3.9795e-6, 0.9858]&lt;/code&gt;, and&#xA;&lt;span class=&quot;math-container&quot;&gt;$p^0$&lt;/span&gt; = &lt;code&gt;[0.99978, 0.99995, 0.9469, 0.99994, 0.9964, 0.99991, 0.9998, 1.0, 0.99998, 0.99999, 1.0, 0.0142]&lt;/code&gt;. Note that I added the logarithmic transformation for concavity; it doesn't change the optimal solution set, but allows you to deploy disciplined convex optimization software [1].&lt;/p&gt;&#xA;&lt;p&gt;The &lt;em&gt;maximum characters per line&lt;/em&gt; constraint can be represented as a set of cover inequalities of the form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in C} z_i \geq 1,\quad \forall C,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where a cover, &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, is defined as an index range where the total length exceeds the limit, i.e., for which&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in C} \mbox{length[i]} &amp;gt; L.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The cover inequality hence state that there must be at least one linefeed in each cover. In your example you had &lt;code&gt;L=20&lt;/code&gt; and &lt;code&gt;length = [2, 1, 1, 2, 2, 3, 2, 1, 1, 2, 2, 2]&lt;/code&gt;, and there would thus only be one cover; namely the full index range from start to end. Hence, the corresponding formulation for this particular example would only have one cover inequality simply summing over all &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; variables. In the general case, you would have to generate all covers by looping over every possible start index and find the corresponding end index at which the line length exceeded the limit.&lt;/p&gt;&#xA;&lt;p&gt;[1] If you wanted to use conic optimization software such as MOSEK, for example, you would rewrite it as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;\max &amp;amp;\log \prod_i u_i,&amp;amp;\mbox{where }u_i = p^1 z_i + p^0 (1 - z_i)\\&#xA;&amp;amp;= \sum_i \log u_i,\\&#xA;&amp;amp;= \sum_i v_i,&amp;amp;\mbox{where }u_i \geq \exp(v_i).\\&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;and thus get a linear objective function and one &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/expo.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;exponential cone&lt;/a&gt; per index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2023-02-06T11:41:52.360" LastActivityDate="2023-02-06T11:41:52.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9887" PostTypeId="2" ParentId="9672" CreationDate="2023-02-06T18:16:15.610" Score="1" Body="&lt;p&gt;What about:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \delta_1,\delta_2$&lt;/span&gt; binary&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_{uv} = 0.3\delta_1 + 0.7\delta_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1-z_{min}(1 - \delta_3) \le z_{uv}+z_{vu}\le 1+z_{max}(1-\delta_3)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ 2 - z_{min}(1-\delta_2) \le z_{uu}+z_{vv}\le 2 + z_{max}(1-\delta_2) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1-z_{min}(1-\delta_1) \le z_{uu} \le 1 + z_{max}(1-\delta_1) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \delta_1+\delta_2 +\delta_3 = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If using indicator variable for &lt;a href=&quot;https://www.gurobi.com/documentation/current/refman/py_model_agc_indicator.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi&lt;/a&gt;,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.addGenConstrIndicator(delta[1],1,z[u,u]==1)&#xA;   &#xA;model.addGenConstrIndicator(delta[2],1,z[u,u]+z[vv]==2)&#xA;            &#xA;model.addGenConstrIndicator(delta[3],1,z[u,v]+z[v,u]==1)&#xA;        &#xA;model.addConstr(delta.sum()==1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-06T20:04:49.690" LastActivityDate="2023-02-06T20:04:49.690" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9888" PostTypeId="1" CreationDate="2023-02-07T04:49:15.443" Score="3" ViewCount="1095" Body="&lt;p&gt;I converted an &lt;a href=&quot;https://www.dropbox.com/s/22b4tu5mtimzaxq/example.xlsx?dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;excel solver problem&lt;/a&gt; to Pulp. However, while the pulp program calculates the objective function value correctly, it doesn't arrive at the right answer. I can't figure out what is wrong in the code. Can anyone identify what I may be doing wrong here?&lt;/p&gt;&#xA;&lt;p&gt;*edit: &lt;a href=&quot;https://www.dropbox.com/s/22b4tu5mtimzaxq/example.xlsx?dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Have a look at the problem in excel here. Solver finds a much better solution.&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I know the objective functions in pulp and excel are both the same, since if I plug in the pulp solution in the excel model, excel gives me the same objective function value as pulp. But for some reason, pulp cannot find the low cost that excel does.&lt;/p&gt;&#xA;&lt;p&gt;Thank you again for your help!&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import *&#xA;import pandas as pd&#xA;&#xA;init_inventory = 500&#xA;init_workers = 100&#xA;&#xA;reg_work_hours = 160&#xA;max_ot_hours = 20&#xA;&#xA;cost_hiring = 1600&#xA;cost_firing = 2000&#xA;&#xA;monthly_wage = 1500&#xA;ot_wage_rate = 13&#xA;&#xA;labor_hours_per_shoe = 4&#xA;mat_cost_per_shoe = 15&#xA;hold_cost_per_month = 3&#xA;&#xA;Months = [&amp;quot;Month 1&amp;quot;, &amp;quot;Month 2&amp;quot;, &amp;quot;Month 3&amp;quot;, &amp;quot;Month 4&amp;quot;]&#xA;&#xA;ShoesNeeded = dict(zip(Months, [3000, 5000, 2000, 1000]))&#xA;&#xA;&#xA;prob = LpProblem(&amp;quot;ProductionPlanning&amp;quot;, LpMinimize)&#xA;&#xA;hire = LpVariable.dicts(&amp;quot;hire&amp;quot;, Months, 0, None, LpInteger)&#xA;fire = LpVariable.dicts(&amp;quot;fire&amp;quot;, Months, 0, None, LpInteger)&#xA;&#xA;avail_workers = {Months[0] : init_workers + hire[Months[0]] - fire[Months[0]]}&#xA;&#xA;for m in range(1,4):&#xA;  avail_workers[Months[m]] = avail_workers[Months[m-1]] + hire[Months[m]] - fire[Months[m]]&#xA;&#xA;reg_hours = {m: avail_workers[m] * reg_work_hours for m in Months}&#xA;max_ot_avail = {m: avail_workers[m] * max_ot_hours for m in Months}&#xA;&#xA;ot_used = LpVariable.dicts(&amp;quot;ot_used&amp;quot;, Months, 0, None, LpInteger)&#xA;&#xA;total_labor_hours = {m: reg_hours[m] + ot_used[m] for m in Months}&#xA;&#xA;prod_capacity = {m: total_labor_hours[m] / labor_hours_per_shoe for m in Months}&#xA;&#xA;shoes_produced = LpVariable.dicts(&amp;quot;Shoes_produced&amp;quot;, Months, 0, None, LpInteger)&#xA;&#xA;invent_ending = {Months[0] : init_inventory + shoes_produced[Months[0]] - ShoesNeeded[Months[0]]}&#xA;&#xA;for m in range(1,4):&#xA;  invent_ending[Months[m]] = invent_ending[Months[m-1]] + shoes_produced[Months[m]] - ShoesNeeded[Months[m]]&#xA;&#xA;prob += lpSum(hire[m] * cost_hiring +&#xA;              fire[m] * cost_firing + &#xA;              avail_workers[m] * monthly_wage +&#xA;              ot_used[m] * ot_wage_rate + &#xA;              shoes_produced[m] * mat_cost_per_shoe +&#xA;              invent_ending[m] * hold_cost_per_month for m in Months), &amp;quot;Total Cost&amp;quot;&#xA;&#xA;for m in Months:&#xA;  prob += ot_used[m] &amp;lt;= max_ot_avail[m], f&amp;quot;Max OT for {m}&amp;quot;&#xA;  prob += shoes_produced[m] &amp;lt;= prod_capacity[m], f&amp;quot;Production capacity for {m}&amp;quot;&#xA;  prob += invent_ending[m] &amp;gt;= ShoesNeeded[m], f&amp;quot;Minimum quantity needed for {m}&amp;quot;&#xA;&#xA;prob.solve()&#xA;&#xA;for v in prob.variables():&#xA;    print(v.name, &amp;quot;=&amp;quot;, v.varValue)&#xA;&#xA;print(&amp;quot;Total Cost = &amp;quot;, value(prob.objective))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11203" LastEditorUserId="11203" LastEditDate="2023-02-08T15:05:19.270" LastActivityDate="2023-02-08T15:05:19.270" Title="Pulp problem gets the right objective value but fails to find the minimal solution" Tags="|optimization|python|pulp|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9889" PostTypeId="2" ParentId="9888" CreationDate="2023-02-07T08:25:09.843" Score="6" Body="&lt;p&gt;How do you define the &amp;quot;right&amp;quot; answer?&lt;/p&gt;&#xA;&lt;p&gt;If the objective function value is computed correctly and reaches minimum value, then it is possible that the optimal solution is not unique, and that the solver you have used with pulp (CBC) simply found another optimal solution. There is no reason to say it is not &amp;quot;the right answer&amp;quot;, as long as the minimal value is reached and that all constraints are satisfied.&lt;/p&gt;&#xA;&lt;p&gt;If you wish to have a different optimal value, you can add &lt;a href=&quot;https://or.stackexchange.com/questions/6157/no-good-cuts-for-general-integer-variables&quot;&gt;no good cuts&lt;/a&gt; for integer variables to exclude the current solution.&lt;/p&gt;&#xA;&lt;p&gt;You could also add some additional constraints to enforce part of the solution you found in Excel, and check if that guides the solver in pulp (CBC) to the same solution.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2023-02-07T08:25:09.843" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9890" PostTypeId="1" CreationDate="2023-02-07T15:29:08.907" Score="2" ViewCount="63" Body="&lt;p&gt;My question is what the conventions are to show scalar, vectors, matrices, random variables, vector, and matrix of random variables? I think some of them are defined as follows:&lt;/p&gt;&#xA;&lt;p&gt;scalar: Lower-case letters&lt;/p&gt;&#xA;&lt;p&gt;Random variable: Upper-case letters&lt;/p&gt;&#xA;&lt;p&gt;Vector: Bold and lower-case letters. The realization of a random variable is denoted by lower-case letters.&lt;/p&gt;&#xA;&lt;p&gt;Matrix: Bold and upper-case letters&lt;/p&gt;&#xA;&lt;p&gt;However, I don't know how to show a vector and a matrix of random variables. I am wondering what form of notations is more common in OR/MS? Is there any other case that I have missed? This question might be a matter of personal preference, but I would be thankful to know the most commonly used forms.&lt;/p&gt;&#xA;" OwnerUserId="139" LastEditorUserId="36" LastEditDate="2023-03-10T02:18:46.387" LastActivityDate="2023-03-10T02:18:46.387" Title="Good (standard) way to define and use notations for vectors, r.v., vector of r.v.s etc?" Tags="|research|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9891" PostTypeId="2" ParentId="9888" CreationDate="2023-02-07T15:36:08.720" Score="1" Body="&lt;p&gt;Avail_workers seems to be an array of  variable, indexed by month. It's like a derived decision variable as it depends upon two other decision variables- hire and fire&lt;br /&gt;&#xA;Add a constraint with &lt;span class=&quot;math-container&quot;&gt;$ availworker_m$&lt;/span&gt; being a variable (no need to declare it integer)&lt;br /&gt;&#xA;Add this constraint&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ availWorker_m = availWorker_{m-1}+hire_m-fire_m \ \ \forall m \in$&lt;/span&gt; Months[1:]&lt;br /&gt;&#xA;Also, as already there the initial month[0]:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ availworker_0 = initWorker+hire_0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Modify the below constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$shoesproduced_m\times labourHoursPerShoe \le availWorker_m\times regWorkHours +otUsed_m$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-07T15:43:00.380" LastActivityDate="2023-02-07T15:43:00.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9892" PostTypeId="1" AcceptedAnswerId="9898" CreationDate="2023-02-07T15:52:54.097" Score="4" ViewCount="329" Body="&lt;p&gt;I have a headache regarding calculating the reduced costs of a linear program. I am using Pulp for modelling and CBC for solving.&lt;/p&gt;&#xA;&lt;p&gt;What I do is, I model a linear programming problem based on a rhs vector &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, a constraint matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and a cost vector &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;. When I have solved the model, I want to print the duals, reduced costs and the solution itself. I do this in Python using Pulp as follows&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Print variable values and reduced costs&#xA;for v in model.variables():&#xA;    print(v.name, &amp;quot;=&amp;quot;, v.varValue, &amp;quot;\tReduced Cost =&amp;quot;, v.dj)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Print duals and slacks&#xA;for name, c in list(model.constraints.items()):&#xA;    print(&amp;quot;Duals=&amp;quot;, c.pi, &amp;quot;\tSlack=&amp;quot;, c.slack)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This seems to work fine. Then, for the fun of it, I wanted to calculate the reduced costs &amp;quot;by hand&amp;quot;. I do this using the formula &lt;span class=&quot;math-container&quot;&gt;$\bar{c}_j=c_j-\mu^TA_j$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; is the objective function coefficient of the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;'th variable, &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; is the duals, and &lt;span class=&quot;math-container&quot;&gt;$A_j$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;'th column of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;. I do this as follows&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for it, col in enumerate(A):&#xA;    # Reduced costs&#xA;    print(c[it]-sum(duals[i]*col[i] for i in range(len(duals)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;(Note that &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is transposed for practical purposes in my implementation)&lt;/p&gt;&#xA;&lt;p&gt;The problem is, these &amp;quot;by hand calculated reduced costs&amp;quot; do not have the same values as the ones provided by the solver. I have observed that the dual values printed are very small positive numbers, and consequently, the reduced costs I calculate are rather large compared to those provided by the solver. What am I doing wrong here? Is there something obvious that I am missing?&lt;/p&gt;&#xA;" OwnerUserId="609" LastActivityDate="2023-02-08T12:04:25.737" Title="Understanding reduced costs and dual values" Tags="|linear-programming|pulp|dual|reduced-costs|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9893" PostTypeId="1" AcceptedAnswerId="9899" CreationDate="2023-02-07T15:55:42.387" Score="1" ViewCount="131" Body="&lt;p&gt;In this minimization problem we have &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; items, &lt;span class=&quot;math-container&quot;&gt;$j= 1, 2, \dots, N$&lt;/span&gt; and a decision variable &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; which are continuous values.&#xA;For every item, we have a nonlinear objective function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; in function of the decision variables &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; that we want to minimize. We also have a variable &lt;span class=&quot;math-container&quot;&gt;$d_j$&lt;/span&gt; that is different for every item and a variable &lt;span class=&quot;math-container&quot;&gt;$a_j$&lt;/span&gt; that contains values from the set &lt;span class=&quot;math-container&quot;&gt;$\lbrace 0, 1, 2\rbrace$&lt;/span&gt;. Look at this &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;-variable as a classification that puts all items in one of three classes. I want to formulate the problem where we minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^Nf(x_{j})$&lt;/span&gt; but &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; must be fixed for each class, so there are at most &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; different values for &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt;. Apart from that, we have the constraints &lt;span class=&quot;math-container&quot;&gt;$0.00 \le x_j &amp;lt; 1.00$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$\frac{\sum_{j=1}^N d_jx_{j}}{\sum_{j=1}^N d_j} = \beta,$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$0.00 \le \beta &amp;lt; 1.00$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To make it a bit more clear, you can imagine the following table as an example of a valid (but not necessarily optimal) solution:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;item    a    x     d     f(x)&#xA;&#xA;1       0   0.98  198    212.5 &#xA;2       1   0.95  50     1245.2  &#xA;3       0   0.98  110    100.2     &#xA;4       2   0.92  20     120.8&#xA;5       1   0.95  80     521.2&#xA;6       1   0.95  36     8232.1&#xA;7       0   0.98  109    3245.7&#xA;8       2   0.92  15     58.2&#xA;9       0   0.98  140    5123.2&#xA;10      2   0.92  10     4128&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In this valid solution, &lt;span class=&quot;math-container&quot;&gt;$\beta = 0.97$&lt;/span&gt; and the result of the objective function is &lt;span class=&quot;math-container&quot;&gt;$22987.1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;How can I formulate this NLP problem by enforcing the constraints mentioned?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2023-02-08T09:10:40.903" LastActivityDate="2023-02-08T14:35:35.167" Title="Formulating a continuous NLP problem with a class variable" Tags="|nonlinear-programming|constrained-optimization|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9894" PostTypeId="1" AcceptedAnswerId="9895" CreationDate="2023-02-07T18:51:58.957" Score="3" ViewCount="566" Body="&lt;p&gt;So I am solving a purely integer linear optimization problem with Pyomo on a single computer (core i-5, 12 GB RAM). The problem has around 10000 variables and 300 constraints. For doing this, I am calling the solver GLPK. However, I find that the problem cannot be solved in a timely manner. Yesterday I let it run for 14 hours straight and, during that time, only a feasible solution was found (failed to certify optimality). Is this expected for problems of this size given my hardware? What problem size should I expect to be able to manage within  1-5 hours? I have no experience with this practical side and thus my intuition of what is a big problem could be flawed.&lt;/p&gt;&#xA;&lt;p&gt;Curiously enough, the relaxation of the same problem is solved within a second. I know that I cannot expect the solution time to be roughly the same on both cases but the difference is so much that it feels like I am doing something wrong.&lt;/p&gt;&#xA;" OwnerUserId="11164" LastEditorUserId="11164" LastEditDate="2023-02-07T19:05:19.610" LastActivityDate="2023-02-07T19:35:49.577" Title="Of what size should I expect to be able to solve an integer linear program with Pyomo?" Tags="|mixed-integer-programming|linear-programming|integer-programming|pyomo|constraint-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9895" PostTypeId="2" ParentId="9894" CreationDate="2023-02-07T19:31:05.530" Score="6" Body="&lt;p&gt;This very much depends on the solver (glpk) and not so much on the modelling language (Pyomo). In my experience, glpk is not among the best free ILP solvers. You may try cbc, which I think is somewhat better than glpk.&lt;/p&gt;&#xA;&lt;p&gt;Next step is a licensed solver like cplex, gurobi, or something in that calibre.&lt;/p&gt;&#xA;&lt;p&gt;Regarding expected problem sizes solvable in reasonable, it is quite difficult to predict solution time from size alone. It also depends on the strength of the LP relaxation, density of the constraint matrix, how “heuristic-friendly” the model is, and many other things.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2023-02-07T19:35:49.577" LastActivityDate="2023-02-07T19:35:49.577" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9896" PostTypeId="1" CreationDate="2023-02-07T21:19:55.637" Score="2" ViewCount="156" Body="&lt;p&gt;My objective function is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f_{objective} = \sum_{n=0}^{m} \int\limits_{I_n}^{I_n + \Delta i_n} P_{normal}(t) \,dt - \int\limits_{S_n}^{S_n + \Delta s_n} P_{CO_2}(t) \,dt &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(&lt;span class=&quot;math-container&quot;&gt;$P(t)$&lt;/span&gt; is the price,) and it boils down to this in python:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;        ...&#xA;&#xA;        obj_func += self.price(soc[i - 1] - soc[i], i)&#xA;&#xA;        ...&#xA;&#xA;def price(self, delta_soc, index):&#xA;    if delta_soc &amp;gt;= 0:&#xA;        return delta_soc * self.data[&amp;quot;price_co2&amp;quot;][index]&#xA;    else:&#xA;        return delta_soc * self.data[&amp;quot;price&amp;quot;][index]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;except it does not work like that. I get the error message.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;z3.z3types.Z3Exception: Symbolic expressions cannot be cast to concrete Boolean values.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and I understand why that is. But how can I work around that? Is there a trick so I can sell at another price than when I buy?&lt;/p&gt;&#xA;" OwnerUserId="11166" LastEditorUserId="907" LastEditDate="2023-02-08T04:20:39.517" LastActivityDate="2023-02-08T10:59:10.510" Title="How to change the price in the objective function, depending on its sign, in python, with Z3?" Tags="|python|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9897" PostTypeId="2" ParentId="9896" CreationDate="2023-02-08T10:59:10.510" Score="3" Body="&lt;p&gt;It took me a while to get the syntax right, so I share it for later generations. This seems to work as intended:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;        obj_func += (soc[i - 1] - soc[i]) * \&#xA;                    z3.If(soc[i - 1] &amp;gt;= soc[i],&#xA;                          self.data[&amp;quot;price&amp;quot;][i],&#xA;                          self.data[&amp;quot;price_co2&amp;quot;][i])  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11166" LastActivityDate="2023-02-08T10:59:10.510" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9898" PostTypeId="2" ParentId="9892" CreationDate="2023-02-08T12:04:25.737" Score="1" Body="&lt;p&gt;One of the best possible ways for the models with some difficulties to understand how the model can be treating in the solving process, specifically in the situations like infeasibility, comparing some solver outputs by handy calculations, etc. would be by writing the model in an LP file and investigating which one of the typos cause the issue.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-02-08T12:04:25.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9899" PostTypeId="2" ParentId="9893" CreationDate="2023-02-08T13:38:06.990" Score="4" Body="&lt;p&gt;Given, &lt;span class=&quot;math-container&quot;&gt;$a_j\in\{0,1,2\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_j$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;, your problem is to find &lt;span class=&quot;math-container&quot;&gt;$x_0,x_1,x_2\in [0,1]$&lt;/span&gt; to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^N f(x_{a_j})$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{\sum_{j=1}^N d_j x_{a_j}}{\sum_{j=1}^N d_j} = \beta.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For example, here's what it would look like in SAS, where I have used &lt;span class=&quot;math-container&quot;&gt;$f(x)=(x-1/2)^4$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;data indata;&#xA;   input item a d;&#xA;   datalines;&#xA; 1 0 198&#xA; 2 1  50&#xA; 3 0 110&#xA; 4 2  20&#xA; 5 1  80&#xA; 6 1  36&#xA; 7 0 109&#xA; 8 2  15&#xA; 9 0 140&#xA;10 2  10&#xA;;&#xA;&#xA;proc optmodel;&#xA;   set ITEMS;&#xA;   num a {ITEMS};&#xA;   num d {ITEMS};&#xA;   num beta = 0.97;&#xA;   set LABELS = setof {j in ITEMS} a[j];&#xA;&#xA;   read data indata into ITEMS=[item] a d;&#xA;&#xA;   var X {LABELS} &amp;gt;= 0 &amp;lt;= 1;&#xA;   min Z = sum {j in ITEMS} (X[a[j]] - 1/2)^4;&#xA;   con Ratio:&#xA;      (sum {j in ITEMS} d[j] * X[a[j]]) / (sum {j in ITEMS} d[j]) = beta;&#xA;&#xA;   solve;&#xA;   print a d {j in ITEMS} X[a[j]];&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-02-08T14:35:35.167" LastActivityDate="2023-02-08T14:35:35.167" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9900" PostTypeId="1" AcceptedAnswerId="9902" CreationDate="2023-02-08T13:41:31.483" Score="5" ViewCount="573" Body="&lt;p&gt;I have a problem, which is similar to Assignment Problem, described as follows:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The problem instance has a number of workers and a number of tasks. Any task can only be assigned to a subset of the workers. A task should be assigned to exactly one worker. Each task has a different difficulty, therefore, workers will spend different time to finish each task. It is required to assign tasks as uniformly as possible: all of the workers spent almost the same time to finish assigned tasks.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Translating this problem to an Integer Linear Programming problem and solving it by CoinCbc solver is all I learned from Assignment Problem: the cost function is to minimize the variance of each worker. I searched a lot, assignment problem, balanced assignment problem, constrained assignment problem, quadratic assignment problem, etc. All I found are different from this problem. Although, I can solve the problem now. I want to solve it more efficiently.&lt;/p&gt;&#xA;&lt;p&gt;Is the problem well studied? Are there any algorithms to solve it more efficiently? (Approximation is acceptable)&lt;/p&gt;&#xA;" OwnerUserId="11215" LastEditorUserId="36" LastEditDate="2023-02-08T13:49:17.207" LastActivityDate="2023-02-08T19:09:05.880" Title="Minimize worker variance assignment problem" Tags="|optimization|integer-programming|assignment-problem|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9901" PostTypeId="2" ParentId="9321" CreationDate="2023-02-08T15:48:43.103" Score="2" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; be the universe (e.g. total set of elements). Then, if I understand your post correctly, you are looking for a function which given two elements &lt;span class=&quot;math-container&quot;&gt;$e_1,e_2\in U, e_1\neq e_2$&lt;/span&gt;, tells you if they should be chosen together (I will call this a SAME constraint), chosen different (DIFFER constraint) or are unrestricted.&lt;/p&gt;&#xA;&lt;p&gt;First, consider only SAME constraints. As this is a transitive operation (e.g. if &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; are chosen together and &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; are chosen together, then also &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; are chosen together), we can partition &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; into sets of items &lt;span class=&quot;math-container&quot;&gt;$S_1,\dots S_k$&lt;/span&gt; where all elements in each set should be chosen together. For your example you would get that &lt;span class=&quot;math-container&quot;&gt;$S_1=\{1,2\}, S_2=\{3\}$&lt;/span&gt;. At the initialization of the branch-and-price algorithm, you would then have a partition with only single element sets &lt;span class=&quot;math-container&quot;&gt;$S_i=\{e_i\}$&lt;/span&gt; for all elements &lt;span class=&quot;math-container&quot;&gt;$e_i\in U$&lt;/span&gt;. If you then require that two elements &lt;span class=&quot;math-container&quot;&gt;$e_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e_2$&lt;/span&gt; are chosen together, you can keep track of this in the partition by taking the two sets in which they belong &lt;span class=&quot;math-container&quot;&gt;$S_1,S_2$&lt;/span&gt;, and replacing them by &lt;span class=&quot;math-container&quot;&gt;$S_1\cup S_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In order to keep track of the DIFFER constraints, let &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; be an undirected graph which has the sets &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; as nodes. Then, a DIFFER constraint for &lt;span class=&quot;math-container&quot;&gt;$e_1\in S_1, e_2\in S_2$&lt;/span&gt; is applied by adding an edge between &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S_2$&lt;/span&gt;. When you apply a SAME constraint to two nodes &lt;span class=&quot;math-container&quot;&gt;$e_1\in S_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e_2\in S_2$&lt;/span&gt;, then contract &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S_2$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; to become a single node, merging their neighbourhoods. Then, infeasibility can be observed if we either try to apply SAME to contract two nodes &lt;span class=&quot;math-container&quot;&gt;$S_1,S_2$&lt;/span&gt; which are already connected by an edge in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; or if the two nodes from a DIFFER constraint are in the same set S.&lt;/p&gt;&#xA;&lt;p&gt;In order to find the 'extra edges' for a SAME constraint on &lt;span class=&quot;math-container&quot;&gt;$e_1\in S_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e_2\in S_2$&lt;/span&gt;, iterate over all pairs &lt;span class=&quot;math-container&quot;&gt;$(S_1\setminus \{e_1\}) \times (S_2\setminus\{e_2\})$&lt;/span&gt;. Similarly, for a DIFFER constraint with &lt;span class=&quot;math-container&quot;&gt;$e_1\in S_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e_2\in S_2$&lt;/span&gt;, you can find the extra edges by iterating over &lt;span class=&quot;math-container&quot;&gt;$(S_1\setminus \{e_1\}) \times (S_2\setminus\{e_2\})$&lt;/span&gt; and requiring that they are different.&lt;/p&gt;&#xA;&lt;p&gt;The above is basically a &lt;a href=&quot;https://en.wikipedia.org/wiki/Disjoint-set_data_structure&quot; rel=&quot;nofollow noreferrer&quot;&gt;Disjoint-Set or (Union-Find) datastructure&lt;/a&gt;, where you can efficiently implement the partitioning of sets by ensuring each set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; has a 'representative element', and by storing the representative element for each element in the set, which can be queried by a function &lt;span class=&quot;math-container&quot;&gt;$\mathrm{FIND}(e_i)$&lt;/span&gt;. Initially, each element is its own representative. Then, we have that &lt;span class=&quot;math-container&quot;&gt;$\mathrm{FIND}(e_1)= \mathrm{FIND}(e_2)$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$e_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e_2$&lt;/span&gt; are to be chosen together. You can efficiently store all edges in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; by only storing them for the representatives. In order to check if two element &lt;span class=&quot;math-container&quot;&gt;$e_1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$e_2$&lt;/span&gt; are different, you can then check if the sets of &lt;span class=&quot;math-container&quot;&gt;$\mathrm{FIND}(e_1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathrm{FIND}(e_2)$&lt;/span&gt; share an edge. If not, then the pair is unrestricted.&lt;/p&gt;&#xA;" OwnerUserId="11216" LastActivityDate="2023-02-08T15:48:43.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9902" PostTypeId="2" ParentId="9900" CreationDate="2023-02-08T16:36:08.900" Score="5" Body="&lt;p&gt;First, you might consider a different objective function. Rather than variance, you might minimize the maximum time spent by any worker, or minimize the range in worker times (the difference between the longest and shortest times that any worker is occupied). That might speed up solution time.&lt;/p&gt;&#xA;&lt;p&gt;If you want to settle for a good but not provably optimal solution, there are a number of possibilities. First, you can continue with your current model but set a time limit, and accept the incumbent solution when the time limit is reached. With some solvers, you may also find a parameter setting telling the solver to emphasize finding good incumbents (as opposed to improving the best bound), which in conjunction with a time limit might produce a sufficiently good solution.&lt;/p&gt;&#xA;&lt;p&gt;Beyond that, there are numerous metaheuristics that can be applied to the problem. Some of them use a version of &amp;quot;neighborhood&amp;quot; search, in which you take a proposed set of assignments and see if you can improve it by, for example, swapping a pair jobs between two workers or just moving a job from one worker to another. Metaheuristics typically do not provide proof of optimality and frequently do not attain optimality. Whether they reach a good enough answer faster than your current approach can only be answered by experimentation.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-02-08T16:36:08.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9903" PostTypeId="2" ParentId="9900" CreationDate="2023-02-08T19:09:05.880" Score="4" Body="&lt;p&gt;It depends what you mean by variance. Assuming it's how uniformly tasks are assigned and objective to have almost uniform total time per worker you either do what the above answer suggests or define two variables, say &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$z_2$&lt;/span&gt; that takes in the min and max values of total time taken per worker. Like &lt;span class=&quot;math-container&quot;&gt;$z_1 \le \sum_{jobs}$&lt;/span&gt;TotalTime&lt;span class=&quot;math-container&quot;&gt;$\ \forall$&lt;/span&gt; workers.&lt;br /&gt;&#xA;Same for &lt;span class=&quot;math-container&quot;&gt;$z_2$&lt;/span&gt; with relation as &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt;.&lt;br /&gt;&#xA;Then minimize &lt;span class=&quot;math-container&quot;&gt;$z_2-z_1$&lt;/span&gt;. Most solvers will assign tasks as uniformly as possible.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-02-08T19:09:05.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9904" PostTypeId="2" ParentId="9890" CreationDate="2023-02-08T23:27:24.847" Score="1" Body="&lt;p&gt;For vector/matrix of r.v. I have seen notations like &lt;span class=&quot;math-container&quot;&gt;$\omega $&lt;/span&gt; for matrix and &lt;span class=&quot;math-container&quot;&gt;$ \Omega$&lt;/span&gt; indicating vectors. Other than that this guide from &lt;a href=&quot;https://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;url=https://www.cs.cmu.edu/%7E10601-f20/10601_Notation_Guide.pdf&amp;amp;ved=2ahUKEwiY7ai5iIf9AhV6lYkEHauqBAcQFnoECCUQAQ&amp;amp;usg=AOvVaw3OkrQGZ4cOHpcCiM6RDFEk&quot; rel=&quot;nofollow noreferrer&quot;&gt;Carnegie Mellon&lt;/a&gt; may be helpful.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-02-08T23:27:24.847" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9905" PostTypeId="1" AcceptedAnswerId="9914" CreationDate="2023-02-09T06:19:02.953" Score="4" ViewCount="524" Body="&lt;p&gt;While well-known IP/LP solvers such as CPLEX and Gurobi have capabilities to run their solver on multiple threads, is there any tool that helps exploit the availability of not only multiple threads on a single CPU, but also increasingly, the availability of multiple processing units themselves? For instance, my laptop has one CPU with 8 threads and two other GPUs.&lt;/p&gt;&#xA;&lt;p&gt;(a) Are there solvers that exploit the presence of multiple processing units -- CPU + additional GPUs on a machine?&lt;/p&gt;&#xA;&lt;p&gt;(b) Is there any benefit to learning DC++ and SYCL (and other options such as Open CL / CUDA) programming for operations research computations?&lt;/p&gt;&#xA;&lt;p&gt;(c) Are there any open source template code bases in C/C++ that someone can use to build their own OR models?&lt;/p&gt;&#xA;" OwnerUserId="11221" LastEditorUserId="491" LastEditDate="2023-02-09T14:38:49.057" LastActivityDate="2023-02-10T06:00:31.670" Title="Multithreading vs DPCC SYCL Programming for OR computational implementations" Tags="|solver|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9906" PostTypeId="2" ParentId="9905" CreationDate="2023-02-09T06:46:55.117" Score="8" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;(a) Are there solvers that exploit the presence of multiple processing&#xA;units -- CPU + additional GPUs on a machine?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Many solvers can work with multiple CPUs. Fewer can do distributed optimization. GPUs have been used in some academic studies, but in general, GPUs don't work very well when dealing with large sparse LP/MIP models. So there is, as of yet, not much commercial interest. Of course, GPUs are much more popular in dense linear algebra and machine learning.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;(b) Is there any benefit to learning DC++ and SYCL (and other options&#xA;such as Open CL / CUDA) programming for operations research&#xA;computations?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If you want to develop your own high-performance algorithms, this may be of some interest. For modeling, not so much (often better to just use readily available tools -- writing your own tools is often not a good investment: buying good tools is much cheaper than developing them).&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;(c) Are there any open source template code bases in C/C++ that&#xA;someone can use to build their own OR models?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Most model development is not done in C++ but in higher-level languages such as Python or using modeling languages such as AMPL and GAMS. C++ is more for developing high-performance algorithms than for model building. Modelers like to be efficient (they often work under time pressure), and using more low-level languages does not help there. Also, model maintenance may be more difficult when using low-level languages. Performance is usually less of an issue when doing modeling (opposed to when running solvers to solve these models: solvers are often written in C or C++).&lt;/p&gt;&#xA;&lt;p&gt;It seems you are mixing model development and solver development. These are two very different crafts. At least for traditional mathematical programming (e.g. LP/MIP) and for constraint programming (CP). When writing your own tailored heuristic algorithms, the difference may be a bit more blurred.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2023-02-09T06:53:54.323" LastActivityDate="2023-02-09T06:53:54.323" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9907" PostTypeId="1" AcceptedAnswerId="9910" CreationDate="2023-02-09T08:58:09.337" Score="1" ViewCount="360" Body="&lt;p&gt;I am trying to optimally schedule a series of tasks with fixed durations between 9am and 5pm in the day (I guess kind of like a constrained knapsack problem, or job scheduling problem). I have broken the day into 15 minutes increments, and assumed my working window is 8 hours (32 x 15 minutes increments). Across the columns of the output matrix are the tasks in order from Task 1 to Task4. If a cell is 1, this means the task was scheduled for that particular interval.&lt;/p&gt;&#xA;&lt;p&gt;My code kind of solves the problem, however it doesn't treat a task as having a fixed duration. So, in my example, Task 4 is running for 3 hours, when in reality it shouldn't run at all as there isn't enough time to fit the full 4 hours in.&lt;/p&gt;&#xA;&lt;p&gt;I have a whole range of extra constraints I would like to introduce (e.g. tasks priorities, fixing some tasks at specific times, etc), but for now I wanted to keep it simple. I'd also love for any suggestions, or sample code for even better ways I could approach this problem (other options apart from linear programming are also welcome).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.environ import *&#xA;&#xA;# Inputs&#xA;task_list      = ['Task 1', 'Task 2', 'Task 3', 'Task 4']&#xA;task_durations = [2,1,2,4]&#xA;&#xA;Intervals = 32&#xA;Tasks = len(durations)&#xA;&#xA;# Construct model variables&#xA;model = ConcreteModel()&#xA;model.Intervals = range(Intervals)&#xA;model.Tasks = range(Tasks)&#xA;model.flag = Var( model.Intervals, model.Tasks, within=Integers)&#xA;model.x = Var( model.Intervals, model.Tasks, within=Binary )&#xA;&#xA;# Set objective&#xA;model.obj = Objective(expr = sum(model.x[n,m] * 0.25 for n in model.Intervals for m in model.Tasks ), sense = maximize )&#xA;&#xA;# Set constraints&#xA;model.row_constraint = ConstraintList()&#xA;for n in model.Intervals:&#xA;    model.row_constraint.add(sum( model.x[n,m] * 0.25 for m in model.Tasks) &amp;lt;= 0.25)&#xA;&#xA;model.column_constraint = ConstraintList()&#xA;for m in model.Tasks:&#xA;    model.column_constraint.add(sum( model.x[n,m] * 0.25 for n in model.Intervals ) &amp;lt;= durations[m])&#xA;&#xA;model.flag_making = ConstraintList()&#xA;for m in model.Tasks:&#xA;    for n in model.Intervals:&#xA;        if n == 0:&#xA;           model.flag_making.add(model.x[n,m] - 0 == model.flag[n,m]) &#xA;        elif n == Intervals-1:&#xA;            model.flag_making.add(0 - model.x[n,m] == model.flag[n,m])&#xA;        else:&#xA;            model.flag_making.add(model.x[n,m] - model.x[n-1,m] == model.flag[n,m])&#xA;&#xA;# Solve the model&#xA;solver = SolverFactory('glpk')&#xA;results = solver.solve(model)&#xA;&#xA;# Post processing&#xA;outputMatrix = [[value(model.x[Intervals,Tasks]) for Tasks in model.Tasks] for Intervals in model.Intervals]&#xA;df = pd.DataFrame(outputMatrix, columns = task_list)&#xA;&#xA;print(&amp;quot;\nObjective Value:&amp;quot;)&#xA;print(model.obj())&#xA;&#xA;df&#xA;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4256" LastActivityDate="2023-02-09T15:05:42.800" Title="Optimal to-do list scheduling in Python using Pyomo" Tags="|linear-programming|pyomo|knapsack|job-shop-scheduling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9908" PostTypeId="1" AcceptedAnswerId="9913" CreationDate="2023-02-09T09:18:27.543" Score="5" ViewCount="1539" Body="&lt;p&gt;I am trying to solve this task:&lt;/p&gt;&#xA;&lt;p&gt;There are three datasets: first data on offices in cities: each city has a certain number of offices and each office has its own capacity of employees. Second, data on teams and open positions in these teams. Third, data on candidates for positions, showing their id, city and position.&lt;/p&gt;&#xA;&lt;p&gt;We have to allocate applicants across teams and offices in such a way as to maximize the number of employees of one team located in one office together. At the same time, we have to minimize number of cases when there are less than two employees of a certain team in a certain office.&lt;/p&gt;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&lt;p&gt;Input:&lt;/p&gt;&#xA;&lt;p&gt;city_data:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    city          office_id           capacity&#xA; New York           A                     3&#xA; New York           B                     2&#xA; New York           C                     6&#xA; Boston             D                     2&#xA; Boston             E                     5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;team_data:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;team_id         position&#xA;alpha            Manager&#xA;alpha            Manager&#xA;alpha            Engineer&#xA;alpha            Engineer&#xA;alpha            Engineer&#xA;alpha            Engineer&#xA;alpha            Designer&#xA;beta             Engineer&#xA;beta             Engineer&#xA;beta             Engineer&#xA;gamma            Designer&#xA;gamma            Engineer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;employees_data:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;employee_id               city                  position&#xA;1                        New York              Manager&#xA;2                        New York              Manager&#xA;3                        New York              Engineer&#xA;4                        New York              Engineer&#xA;5                        New York              Engineer&#xA;6                        New York              Engineer&#xA;7                        New York              Engineer&#xA;8                        New York              Designer&#xA;9                        New York              Designer&#xA;10                       Boston                Engineer&#xA;11                       Boston                Engineer&#xA;12                       Boston                Engineer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Possible output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;team_id      employee_id          position           city            office_id&#xA;alpha            1                Manager         New York              C&#xA;alpha            2                Manager         New York              C&#xA;alpha            3                Engineer         New York             C&#xA;alpha            4                Engineer         New York             C&#xA;alpha            5                Engineer         New York             C&#xA;alpha            6                Engineer         New York             B&#xA;alpha            8                Designer         New York             B&#xA;beta             10               Engineer         Boston               E&#xA;beta             11               Engineer         Boston               E&#xA;beta             12               Engineer         Boston               E&#xA;gamma            9                 Designer        New York             A&#xA;gamma            7                 Engineer        New York             A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried to solve this way:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Sort the employee_data in decreasing order of the count of employees for each position and city.&lt;/li&gt;&#xA;&lt;li&gt;For each city and position, assign the employee_id to the team_id and office_id with the maximum capacity until it reaches the capacity limit.&lt;/li&gt;&#xA;&lt;li&gt;Repeat the step 2 until all employees are assigned to the team_id and office_id.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;And wrote this code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from collections import defaultdict&#xA;&#xA;def allocate_employees(city_data, team_data, employee_data):&#xA;    city_office_capacity = defaultdict(dict)&#xA;    for city, office, capacity in city_data:&#xA;        city_office_capacity[city][office] = capacity&#xA;&#xA;    team_positions = defaultdict(list)&#xA;    for team, position in team_data:&#xA;        team_positions[team].append(position)&#xA;&#xA;    employee_allocations = []&#xA;    for employee, city, position in employee_data:&#xA;        max_capacity = 0&#xA;        max_office = None&#xA;        for office, capacity in city_office_capacity[city].items():&#xA;            if capacity &amp;gt; max_capacity:&#xA;                max_capacity = capacity&#xA;                max_office = office&#xA;        city_office_capacity[city][max_office] -= 1&#xA;        for team, positions in team_positions.items():&#xA;            if position in positions:&#xA;                employee_allocations.append((team, employee, position, city, max_office))&#xA;                break&#xA;    return employee_allocations&#xA;&#xA;city_data = [(&amp;quot;New York&amp;quot;, &amp;quot;A&amp;quot;, 3),&#xA;             (&amp;quot;New York&amp;quot;, &amp;quot;B&amp;quot;, 2),&#xA;             (&amp;quot;New York&amp;quot;, &amp;quot;C&amp;quot;, 6),&#xA;             (&amp;quot;Boston&amp;quot;, &amp;quot;D&amp;quot;, 2),&#xA;             (&amp;quot;Boston&amp;quot;, &amp;quot;E&amp;quot;, 5)]&#xA;&#xA;team_data = [(&amp;quot;alpha&amp;quot;, &amp;quot;Manager&amp;quot;),&#xA;             (&amp;quot;alpha&amp;quot;, &amp;quot;Manager&amp;quot;),&#xA;             (&amp;quot;alpha&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;             (&amp;quot;alpha&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;             (&amp;quot;alpha&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;             (&amp;quot;alpha&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;             (&amp;quot;alpha&amp;quot;, &amp;quot;Designer&amp;quot;),&#xA;             (&amp;quot;beta&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;             (&amp;quot;beta&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;             (&amp;quot;beta&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;             (&amp;quot;gamma&amp;quot;, &amp;quot;Designer&amp;quot;),&#xA;             (&amp;quot;gamma&amp;quot;, &amp;quot;Engineer&amp;quot;)]&#xA;&#xA;employee_data = [(1, &amp;quot;New York&amp;quot;, &amp;quot;Manager&amp;quot;),&#xA;                 (2, &amp;quot;New York&amp;quot;, &amp;quot;Manager&amp;quot;),&#xA;                 (3, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;                 (4, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;                 (5, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;                 (6, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;                 (7, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;                 (8, &amp;quot;New York&amp;quot;, &amp;quot;Designer&amp;quot;),&#xA;                 (9, &amp;quot;New York&amp;quot;, &amp;quot;Designer&amp;quot;),&#xA;                 (10, &amp;quot;Boston&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;                 (11, &amp;quot;Boston&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;                 (12, &amp;quot;Boston&amp;quot;, &amp;quot;Engineer&amp;quot;)]&#xA;&#xA;allocate_employees(city_data, team_data, employee_data)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I get the wrong output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[('alpha', 1, 'Manager', 'New York', 'C'),&#xA; ('alpha', 2, 'Manager', 'New York', 'C'),&#xA; ('alpha', 3, 'Engineer', 'New York', 'C'),&#xA; ('alpha', 4, 'Engineer', 'New York', 'A'),&#xA; ('alpha', 5, 'Engineer', 'New York', 'C'),&#xA; ('alpha', 6, 'Engineer', 'New York', 'A'),&#xA; ('alpha', 7, 'Engineer', 'New York', 'B'),&#xA; ('alpha', 8, 'Designer', 'New York', 'C'),&#xA; ('alpha', 9, 'Designer', 'New York', 'A'),&#xA; ('alpha', 10, 'Engineer', 'Boston', 'E'),&#xA; ('alpha', 11, 'Engineer', 'Boston', 'E'),&#xA; ('alpha', 12, 'Engineer', 'Boston', 'E')]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried a greedy algorithm here, but maybe integer programming will do better, for example?&lt;/p&gt;&#xA;" OwnerUserId="11225" LastEditorUserId="1160" LastEditDate="2023-02-09T23:40:16.853" LastActivityDate="2023-02-14T22:36:23.800" Title="How can I solve this algorithmic task in Python?" Tags="|optimization|python|integer-programming|combinatorial-optimization|algorithms|" AnswerCount="6" CommentCount="34" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9909" PostTypeId="1" CreationDate="2023-02-09T12:27:27.557" Score="5" ViewCount="213" Body="&lt;p&gt;I haven't really kept myself up to date with research on the simplex algorithm for several years. I have taught linear programming, but it has not focused on the cutting edge of things.&lt;/p&gt;&#xA;&lt;p&gt;I remember many years ago I went to a course on linear programming, where the teacher said something along the lines of &amp;quot;When applying the simplex algorithm, its frustrating that we can &amp;quot;see&amp;quot; the optimal vertex all the time (convex feasible set) but we have to travel all the way around the edge of the polyhedron to get there&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;My question is &amp;quot;what ideas have been proposed to make &amp;quot;short cuts&amp;quot; through the polyhedron &lt;em&gt;when using the simplex algorithm&lt;/em&gt;&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;I know this is what interior point algorithms do, but this is in the context of the simplex algorithm.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2023-02-09T21:00:10.480" LastActivityDate="2023-02-09T21:00:10.480" Title="Short cuts when using the simplex algorithm" Tags="|linear-programming|simplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9910" PostTypeId="2" ParentId="9907" CreationDate="2023-02-09T12:47:24.940" Score="2" Body="&lt;p&gt;In addition to the below code&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for m in model.Tasks:&#xA;    model.column_constraint.add(sum( model.x[n,m] * 0.25 for n in model.Intervals ) &amp;lt;= durations[m])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you want to squeeze all your tasks within 8 hours then it should be like&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ 0.25\sum_n\sum_m x_{m,n}d_m \le D$&lt;/span&gt; where D=8 or whatever in interval of 15 mins. Your task duration &lt;span class=&quot;math-container&quot;&gt;$d_m$&lt;/span&gt; is in hours also.&lt;/p&gt;&#xA;&lt;p&gt;If you don't want tasks to be scheduled in fractions in other words no scheduling if the whole task doesn't fit then either add the below constraint:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$d_mx_{m,n-1}-\sum_{k \lt n-1} x_{m,k} \le d_mx_{m,n}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or for tighter bounds&lt;br /&gt;&#xA;Have new binary variable &lt;span class=&quot;math-container&quot;&gt;$y_m =1$&lt;/span&gt; if task &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is scheduled, else 0.&#xA;Then your constraints in addition to what you've in your code will be&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_m y_m d_m \le D$&lt;/span&gt;&#xA;and two more constraints below&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$d_my_m \le \sum_nx_{m,n} \le y_m d_m$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-09T15:05:42.800" LastActivityDate="2023-02-09T15:05:42.800" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9911" PostTypeId="2" ParentId="9909" CreationDate="2023-02-09T15:53:03.610" Score="5" Body="&lt;p&gt;The only methods I can think of that could be interpreted as &amp;quot;taking a shortcut through the polyhedron&amp;quot; are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Criss-cross_algorithm&quot; rel=&quot;noreferrer&quot;&gt;Cross-cross methods&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.1100.0425?journalCode=ijoc&quot; rel=&quot;noreferrer&quot;&gt;The Improved Primal Simplex Method for Degenerate LPs&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In both cases the interpretation is a bit of a stretch.&lt;/p&gt;&#xA;&lt;p&gt;This does not mean that simplex algorithms have not been improved in the recent years. On the implementation side, a lot of improvements went into presolve (one of those is &lt;a href=&quot;https://community.fico.com/s/blog-post/a5Q80000000Drp2EAC/fico1299&quot; rel=&quot;noreferrer&quot;&gt;folding&lt;/a&gt;), improved implementation details in all aspects of the algorithms, improved accuracy of the solves. My impression is that especially crossover has improved a lot recently (as can be seen in the Mittelmann benchmarks). Sadly, most of these improvements are done at solver companies and solver developers usually don't have much time to also publish their work in scientific journals.&lt;/p&gt;&#xA;" OwnerUserId="302" LastActivityDate="2023-02-09T15:53:03.610" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9912" PostTypeId="2" ParentId="9908" CreationDate="2023-02-09T16:09:53.297" Score="3" Body="&lt;p&gt;you can try with integer programming but we can see if this combinatorics works&lt;br /&gt;&#xA;In the code put\&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from collections import defaultdict&#xA;&#xA;def allocate_employees(city_data, team_data, employee_data):&#xA;    city_office_capacity = defaultdict(dict)&#xA;    for city, office, capacity in city_data:&#xA;        city_office_capacity[city][office] = capacity&#xA;&#xA;    team_positions = defaultdict(list)&#xA;    for team, position in team_data:&#xA;        team_positions[team].append(position)&#xA;&#xA;    employee_allocations = []    &#xA;    for employee, city, position in employee_data:&#xA;                max_capacity =0;&#xA;                max_office = None              &#xA;                for office, capacity in city_office_capacity[city].items():&#xA;                    if capacity &amp;gt; max_capacity:&#xA;                        max_capacity = capacity&#xA;                        max_office = office&#xA;                        &#xA;                        for team, positions in team_positions.items():    &#xA;                           if position in positions:&#xA;                               employee_allocations.append((team, employee, position, city, max_office))&#xA;                               #team_positions[team].pop(position)&#xA;                               team_positions[team].remove(position)&#xA;                               city_office_capacity[city][max_office] -= 1&#xA;                               break&#xA;                        break       &#xA;    return employee_allocations&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you choose to go for MIP, here is suggested solution:&#xA;Sets:&lt;br /&gt;&#xA;Roles: &lt;span class=&quot;math-container&quot;&gt;$ R_r$&lt;/span&gt;&#xA;Teams: &lt;span class=&quot;math-container&quot;&gt;$ T_t$&lt;/span&gt;: Role &lt;span class=&quot;math-container&quot;&gt;$ R_{rt}$&lt;/span&gt;&lt;br /&gt;&#xA;Office &lt;span class=&quot;math-container&quot;&gt;$ O_o$&lt;/span&gt;: Capacity &lt;span class=&quot;math-container&quot;&gt;$ Cap_o$&lt;/span&gt;, City &lt;span class=&quot;math-container&quot;&gt;$ Ct_o$&lt;/span&gt;&lt;br /&gt;&#xA;City: &lt;span class=&quot;math-container&quot;&gt;$Ct_c$&lt;/span&gt;&lt;br /&gt;&#xA;Employees: &lt;span class=&quot;math-container&quot;&gt;$ E_e$&lt;/span&gt;: City &lt;span class=&quot;math-container&quot;&gt;$Ct_e$&lt;/span&gt;: Role &lt;span class=&quot;math-container&quot;&gt;$ \tau_{r,e} =1$&lt;/span&gt; if employee has that role r, else 0\&lt;/p&gt;&#xA;&lt;p&gt;Derived sets:&lt;br /&gt;&#xA;ET: &lt;span class=&quot;math-container&quot;&gt;$ \{(e,t): R_e \in R_t \}$&lt;/span&gt;&lt;br /&gt;&#xA;EO:  &lt;span class=&quot;math-container&quot;&gt;$\{(e,o): Ct_e \in Ct_o \}$&lt;/span&gt; &lt;br /&gt;&#xA;ETOC = ET&lt;span class=&quot;math-container&quot;&gt;$\times$&lt;/span&gt;EO&#xA;Vars:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_{e,t,o} = 1$&lt;/span&gt; if assigned, else 0. No need for city as office-id itself will determine the city&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ z_{to}$&lt;/span&gt; binary: to track of cases where less than 2 employees are assigned per team per ofice&lt;/p&gt;&#xA;&lt;p&gt;Max &lt;span class=&quot;math-container&quot;&gt;$\sum_{eto} x_{eto}  - \sum_o\sum_tz_{to}$&lt;/span&gt;&lt;br /&gt;&#xA;s.t.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_t \sum_{e\in EO} x_{e,t,o} \le Cap_o \ \ \forall o \in O$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$R_{r,t} \le \sum_o\sum_{e\in ET} \tau_{r,e}x_{e,t,o} \ \ \forall r \in R \ \forall  t \in T$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; just represents set membership (if employee E if of the role ,R) Can be replaced with set membership logic like EO &amp;amp; ET.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(2+e) - \sum_e x_{eto} \le 3z_{t,o} $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_e x_{eto}-(2+e) \le 3(z_{t,o}-1) \ \ \forall t \in T \ \ \forall o \in O$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Using Gurobipy&lt;/strong&gt;, solves in 0.02 secs, 1 node&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Combos&#xA;ETOClist = []&#xA;for employee in employee_data:&#xA;  for team in team_data:&#xA;    if employee[2] == team[1]:&#xA;      #tp = employee[0],team[0], employee[2]&#xA;      #ETlist.append(tp)&#xA;      for office in city_data:&#xA;        if employee[1] == office[0]:&#xA;          ta = office[1], employee[0],team[0], employee[2]&#xA;          ETOClist.append(ta)&#xA;&#xA;&#xA;ETOCSet = set(ETOClist)&#xA;ETOC = tuplelist(ETOCSet)&#xA;#EO = tuplelist(ETlist)&#xA;&#xA;TOlist = []&#xA;for team in team_data:&#xA;  for office in city_data:&#xA;    tp = team[0],office[1]&#xA;    TOlist.append(tp)&#xA;&#xA;TOSet = set(TOlist)&#xA;TO = tuplelist(TOSet)&#xA;&#xA;#Dict from citydata&#xA;office,city,cap = multidict({office:[city,capa] for city,office,capa in city_data})&#xA;req = {('Manager','alpha'):2,('Engineer','alpha'):4,('Designer','alpha'):1,&#xA;       ('Engineer', 'beta'): 3, ('Designer', 'gamma'): 1, ('Engineer', 'gamma'): 1 }&#xA;model = Model('Assign')&#xA;x = model.addVars(ETOC,vtype='b',name='x')&#xA;z = model.addVars(TO,vtype='b',name='z')&#xA;&#xA;M = 100&#xA;#Constraints&#xA;C1 = model.addConstrs((x.sum(o,'*','*','*') &amp;lt;= cap[o] for o in office),'Capacity')&#xA;C2= model.addConstrs((req[r,t] &amp;lt;= x.sum('*','*',t,r) for r,t in req),'Req')&#xA;&#xA;#Ensure no employee is assigned to a team unless role is there. redundant&#xA;#C3= model.addConstrs((x.sum('*','*',t,r) &amp;lt;= Mreq[r,t] for r,t in req),'Optional')&#xA;&#xA;C4 = model.addConstrs(2.01 - x.sum(o,'*',t,'*') &amp;lt;= 3*z[t,o] for t,o in TO)&#xA;C5 = model.addConstrs(x.sum(o,'*',t,'*') - 2.01 &amp;lt;= 3*(z[t,o]-1) for t,o in TO)&#xA;&#xA;#Prioritizing objectives: P1, P2&#xA;P1, P2 = 3,1&#xA;obj = P1*x.sum() - P2*z.sum()&#xA;&#xA;model.setObjective(obj, GRB.MAXIMIZE)&#xA;model.optimize()&#xA;model.printAttr('x')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-14T22:36:23.800" LastActivityDate="2023-02-14T22:36:23.800" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9913" PostTypeId="2" ParentId="9908" CreationDate="2023-02-09T17:07:03.020" Score="7" Body="&lt;p&gt;Here is solution with a MIP, based on a multicommodity flow formulation. A commodity is a &amp;quot;city-position&amp;quot; couple. Consider the following multipartite network with 5 layers:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the candidate layer with nodes &lt;span class=&quot;math-container&quot;&gt;$V_1=\{\text{NewYork-Manager}, \text{NewYork-Engineer}, \text{NewYork-Designer}, \text{Boston-Engineer}\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;the position layer with nodes &lt;span class=&quot;math-container&quot;&gt;$V_2=\{\text{Manager}, \text{Engineer}, \text{Designer}\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;the team layer with nodes &lt;span class=&quot;math-container&quot;&gt;$V_3=\{\alpha, \beta, \gamma\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;the office layer with nodes &lt;span class=&quot;math-container&quot;&gt;$V_4=\{\text{A},\text{B},\text{C},\text{D},\text{E}\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;the city layer with nodes &lt;span class=&quot;math-container&quot;&gt;$V_5=\{\text{NewYork},\text{Boston}\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Each from one layer to another are add to the graph based on the data. The network is illustrated below (with obvious abreviations or labels):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/0Kj7I.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0Kj7I.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;What does not appear in the graph is the fact that some edges are not allowed for some commodities. For example, between nodes &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; (or &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; in the illustration) and &lt;span class=&quot;math-container&quot;&gt;$\textit{A}$&lt;/span&gt;, there is no existing edge for commodity &lt;span class=&quot;math-container&quot;&gt;$\text{BO-Eng}$&lt;/span&gt;, because such a commodity can only cross node &lt;span class=&quot;math-container&quot;&gt;$\text{BO}$&lt;/span&gt; in the cities layer. Below is the network induced by the arcs of commodity &lt;span class=&quot;math-container&quot;&gt;$\text{BO-Eng}$&lt;/span&gt; (green) and &lt;span class=&quot;math-container&quot;&gt;$\text{NY-Man}$&lt;/span&gt; (red):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/a7wZY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/a7wZY.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Once the network is setup, the model is straightforward: define integer variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^c \in \mathbb{N}^+$&lt;/span&gt; which denote the number of commodities of type &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; on arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;. The following constraints must hold:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Flow conservation:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i} x_{ij}^c = \sum_{i} x_{ij}^c \quad \forall c, \forall j\neq s,t \tag{1}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Office capacities:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{c} x_{ij}^c \le Q_{ij}\quad \forall (i,j)\in V_4 \times V_5 \tag{2}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Teams requirements:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{c} x_{ij}^c = R_{ij}\quad \forall (i,j)\in V_2 \times V_3 \tag{3}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Given amount of candidates/commodities:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{sc}^c = N_c \quad \forall c \tag{4}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The above is the core model. Now to maximize members of a given team in a given office, introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in V_4\times V_5$&lt;/span&gt; is used. The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{(i,j)} y_{ij}$&lt;/span&gt; subject to constraints &lt;span class=&quot;math-container&quot;&gt;$(1)-(4)$&lt;/span&gt;, with the additional constraint &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^c\le M y_{ij}$&lt;/span&gt; to link &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables. And to ensure no member of a team is by himself in an office, add&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_c x_{ij}^c \ge 2 y_{ij} \quad \forall (i,j) \in V_3 \times V_4&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;When I &lt;a href=&quot;https://github.com/Kuifje02/or.stackexchange-simulations/blob/main/MulticommodityFlow_AssignmentProblem.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;run&lt;/a&gt; the model, I get the following solution:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;NY,Eng&#xA;=======&#xA;Eng a 4.0&#xA;Eng g 1.0&#xA;a C 4.0&#xA;g B 1.0&#xA;B NY 1.0&#xA;C NY 4.0&#xA;&#xA;NY,Man&#xA;=======&#xA;Man a 2.0&#xA;a A 2.0&#xA;A NY 2.0&#xA;&#xA;NY,Des&#xA;=======&#xA;Des a 1.0&#xA;Des g 1.0&#xA;a C 1.0&#xA;g B 1.0&#xA;B NY 1.0&#xA;C NY 1.0&#xA;&#xA;BO,Eng&#xA;=======&#xA;Eng b 3.0&#xA;b E 3.0&#xA;E BO 3.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or in terms of teams:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Team  a&#xA;======&#xA;office A -&amp;gt; 2.0 employees&#xA;office C -&amp;gt; 5.0 employees&#xA;&#xA;Team  b&#xA;======&#xA;office E -&amp;gt; 3.0 employees&#xA;&#xA;Team  g&#xA;======&#xA;office B -&amp;gt; 2.0 employees&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-02-10T12:59:12.233" LastActivityDate="2023-02-10T12:59:12.233" CommentCount="17" ContentLicense="CC BY-SA 4.0" />
  <row Id="9914" PostTypeId="2" ParentId="9905" CreationDate="2023-02-09T18:00:34.633" Score="3" Body="&lt;p&gt;There at least 4 to 5 companies building and selling software for solution of (mixed) linear optimization problems. All these companies has many very clever employees that have put many man years into the software.&lt;/p&gt;&#xA;&lt;p&gt;I am pretty sure if any of those companies thought they could make their software be much better than the competitors by using GPUs then they would do it. Simply because they could make of lot of money that way.&lt;/p&gt;&#xA;&lt;p&gt;I have been working on &lt;a href=&quot;https://www.mosek.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek&lt;/a&gt; for almost 25 years and based on that experience then there is no simple trick like using a GPU that will make the software much better. Rather if all optimization software vendors is not doing something then it is most likely impossible or not worthwhile.&lt;/p&gt;&#xA;&lt;p&gt;Regarding multithreading as asked in the comments after the initial post. I only have experience with parallelizing interior-point methods. My conclusion is that parallelizing something like an inner product provides little benefit, because the computation is memory bound.&#xA;Parallelizing something like big dense matrix multiplication is fairly easy because you parallelize O(n^3) computations but only read O(n^2) data.&#xA;Therefore, the benefit from solving an LP parallel will highly depend on what type computations are dominating and that is problem dependent.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2023-02-10T06:00:31.670" LastActivityDate="2023-02-10T06:00:31.670" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9915" PostTypeId="1" CreationDate="2023-02-09T20:20:36.343" Score="3" ViewCount="107" Body="&lt;p&gt;Suppose we wanted to solve the following optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\inf_{x \geq 0}\sup_{y \in [0, 1];\ z &amp;gt; 0} f(x, y, z),$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f(x, y, z)$&lt;/span&gt; is some objective function with a closed form that can be specified in terms of parameters &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. How would we implement this optimization, say using the Python programming language?&lt;/p&gt;&#xA;&lt;p&gt;I am only vaguely familiar with implementing optimization in the Bayesian setting (eg using variational inference) or by a grid search. But I do not think Bayesian optimization works here as there are any priors here (I could be wrong though) and I'm not quite sure how to discretize these parameters in a reasonable way.&lt;/p&gt;&#xA;&lt;p&gt;(The motivation for the optimization problem above comes from my personal study of robust optimization models from the paper &lt;a href=&quot;https://arxiv.org/pdf/1908.05659.pdf.&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/1908.05659.pdf.&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="11234" LastEditorUserId="491" LastEditDate="2023-02-09T20:35:34.820" LastActivityDate="2023-02-10T12:49:27.933" Title="Question about implementation method for optimization problem" Tags="|python|multi-objective-optimization|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9916" PostTypeId="2" ParentId="9915" CreationDate="2023-02-10T08:16:28.460" Score="3" Body="&lt;p&gt;The first thing to do is not to write your own solver, but to use an existing one. In Python, you can use the modeler &lt;a href=&quot;http://www.pyomo.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo&lt;/a&gt; to model the problem and then select which solver to use to solve it.&lt;/p&gt;&#xA;&lt;p&gt;If you have the closed-form of the function to optimize and the problem is non-convex, you can first try a global optimization solver. If the problem is easy enough, it may find a provably globally optimal solution within reasonable time.&lt;/p&gt;&#xA;&lt;p&gt;If it is not the case, i.e. the problem is convex, or the resolution takes too much time and the current solution is not feasible or not good enough, then you can try a local optimization solver. If the problem is non-convex, these solvers do not guarantee finding the optimal solution. But they may find a good one quickly.&lt;/p&gt;&#xA;&lt;p&gt;You can find a list of solvers &lt;a href=&quot;https://neos-server.org/neos/solvers/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; In particular, you can look at the &amp;quot;Global Optimization&amp;quot; and &amp;quot;Nonlinearly Constrained Optimization&amp;quot; sections.&lt;/p&gt;&#xA;&lt;p&gt;Only, if none of these solutions are satisfying, you can consider implementing another algorithm yourself.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="491" LastEditDate="2023-02-10T12:49:27.933" LastActivityDate="2023-02-10T12:49:27.933" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9917" PostTypeId="2" ParentId="9850" CreationDate="2023-02-10T10:12:07.840" Score="1" Body="&lt;p&gt;The closest topic of what you described that I am aware of is the field of &amp;quot;Scheduling with machine availability constraints&amp;quot;. In particular, the semiresumable case:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Under the semiresumable assumption, the disrupted operation will have to partially restart after the machine becomes available again&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Here is a not so recent survey of these problems:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;quot;A survey of scheduling with deterministic machine availability constraints&amp;quot; (Ma et al, 2010) &lt;a href=&quot;https://doi.org/10.1016/j.cie.2009.04.014&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-02-10T10:12:07.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9918" PostTypeId="1" AcceptedAnswerId="9919" CreationDate="2023-02-10T14:20:20.513" Score="1" ViewCount="635" Body="&lt;br /&gt;&#xA;I am currently working on a cost minimisation model for multi-product, multi-period supplier selection with Pyomo. It is a linear model described below.&lt;br /&gt;&#xA;**Problem statement**&lt;br /&gt;&#xA;I have no idea how to formulate a restriction that defines the binary decision variables with the values 0 and 1 respectively. Currently, only the calculation of unit level costs works. The binary variables always remain at 0, so no order level costs or supplier level costs are included.&lt;br /&gt;&#xA;I would be very grateful if someone had an idea to formulate the restrictions for the binary variables.&#xA;&lt;p&gt;&lt;strong&gt;Sets&lt;/strong&gt;&lt;br /&gt;&#xA;The model consists of three sets:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;products: P&lt;/li&gt;&#xA;&lt;li&gt;time periods: T&lt;/li&gt;&#xA;&lt;li&gt;suppliers: S&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;&lt;br /&gt;&#xA;For simplicity, the model has five parameters:&lt;br /&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Supplier level costs: slc[s]&lt;/li&gt;&#xA;&lt;li&gt;Order level costs: olc[s,t]&lt;/li&gt;&#xA;&lt;li&gt;Unit level costs: ulc[p,s,t]&lt;/li&gt;&#xA;&lt;li&gt;Production capacity: c[p,s,t]&lt;/li&gt;&#xA;&lt;li&gt;Demand: d[p,t]&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Decision Variables&lt;/strong&gt;&lt;br /&gt;&#xA;There are three decision variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Delivery quantity: x[p,s,t]: units of product &lt;em&gt;p&lt;/em&gt; ordered in period &lt;em&gt;t&lt;/em&gt; from supplier &lt;em&gt;s&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;Binary assignment variable: y_1[s] value: &amp;quot;1&amp;quot; if supplier &lt;em&gt;s&lt;/em&gt; delivers (independent of product and period), else &amp;quot;0&amp;quot;&lt;/li&gt;&#xA;&lt;li&gt;Binary assignment variable: y_2[s,t] value: &amp;quot;1&amp;quot; if supplier &lt;em&gt;s&lt;/em&gt; delivers in period &lt;em&gt;t&lt;/em&gt; (independent of product), else &amp;quot;0&amp;quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective Function&lt;/strong&gt;&lt;br /&gt;&#xA;minimize Total Costs = Sum_slc + Sum_olc + sum_ulc &lt;br /&gt;&#xA;with...&lt;br /&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Sum_slc=sum((model.y_1[s]) * model.slc[s] for s in model.S)&lt;br /&gt;&lt;/li&gt;&#xA;&lt;li&gt;Sum_olc=sum(model.y_2[s,t] * model.olc[s,t] for s in model.S for t in model.T)&lt;br /&gt;&lt;/li&gt;&#xA;&lt;li&gt;Sum_ulc=sum(model.x[p,s,t] * model.ulc[p,s,t]  for p in model.P for s in model.S for t in model.T)&lt;br /&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt; &lt;br /&gt;&#xA;Demand constraint: sum(model.x[p,s,t] for s in model.S) == model.d[p,t]&#xA;Capacity constraint: model.xME[p,s,t] &amp;lt;= model.c[p,s,t]&lt;/p&gt;&#xA;" OwnerUserId="11238" LastEditorUserId="11238" LastEditDate="2023-02-10T14:22:08.273" LastActivityDate="2023-02-13T16:09:43.630" Title="Pyomo: Value assignment for binary variables through constraints" Tags="|pyomo|binary-variable|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9919" PostTypeId="2" ParentId="9918" CreationDate="2023-02-10T14:32:53.487" Score="1" Body="&lt;p&gt;So problem is to make sure &lt;span class=&quot;math-container&quot;&gt;$y1_{s}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y2_{s,t}$&lt;/span&gt; take values of 1 when supplier &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; delivers &lt;span class=&quot;math-container&quot;&gt;$x_{p,s}^t \gt 0$&lt;/span&gt;&lt;br /&gt;&#xA;Add constraints:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y2_{s,t}\le \sum_p x_{p,s}^t \le My2_{s,t} \ \ \forall t\in T \ \ \forall s$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y1_s\le \sum_t\sum_p x_{s,p}^t \le My1_s$&lt;/span&gt; where M is a number like &lt;span class=&quot;math-container&quot;&gt;$\sum_p c_{p,s}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-10T20:11:20.850" LastActivityDate="2023-02-10T20:11:20.850" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9920" PostTypeId="1" CreationDate="2023-02-10T19:37:53.723" Score="3" ViewCount="70" Body="&lt;p&gt;I have a multi-pickup dropoff problem where orders from pickup locations need to be dropped off at delivery locations. I converted the problem into a three-index pickup drop-off problem with time windows (PDPTW). A standard formulation of PDPTW can be found here &lt;a href=&quot;https://www.dep.ufscar.br/munari/pdptw/supplementary_material.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.dep.ufscar.br/munari/pdptw/supplementary_material.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, since my delivery location is fixed for all orders that are coming from multiple pickup locations, I had to create &lt;span class=&quot;math-container&quot;&gt;$(n-1)$&lt;/span&gt; instances of the single delivery location, where n is the total number of orders or pickup locations. The distance and travel time between these dummy delivery locations are &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and hence do not hold the triangular inequality condition &lt;span class=&quot;math-container&quot;&gt;$t[i,k]&amp;gt;t[i,j]+t[j,k]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I was able to solve a PDPTW problem where all pickups and dropoffs were located at different locations using a solver. However, when I try to solve this multi-PDPTW, where I create these dummy locations, the solver shows its feasible problem, but the feasible solution does not improve even after a long time. I am trying to understand whether this is happening because of the creation of the dummy variables. I know that sub-tour is eliminated because there are time windows and capacity constraints. But I was wondering if this was happening because the triangular inequality among those delivery locations is not met.&lt;/p&gt;&#xA;&lt;p&gt;Edit:  In a PDPTW each order has a unique origin and destination pair associated with it. For multi-PDPTW, some delivery locations are the same for some orders.  The following figure is from a paper. They are creating one  copy of &lt;span class=&quot;math-container&quot;&gt;$d_1$&lt;/span&gt; to create &lt;span class=&quot;math-container&quot;&gt;$d_1'$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_1''$&lt;/span&gt; to convert the multi-PDPTW into a PDPTW formulation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0IgTs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0IgTs.png&quot; alt=&quot;cloing delivery location&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3288" LastEditorUserId="3288" LastEditDate="2023-02-12T18:52:28.840" LastActivityDate="2023-02-12T18:52:28.840" Title="Triangular inequality in Routing or Pickup/Drop off problem" Tags="|vehicle-routing|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9922" PostTypeId="1" CreationDate="2023-02-11T21:51:39.627" Score="2" ViewCount="97" Body="&lt;p&gt;Suppose you wanted to solve the following optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\inf_{a \geq 0}\sup_{b \geq 0}\dfrac{(a^2 + 1)(a + b)}{2a + b} + \dfrac{b}{a + b} - ab,$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$a, b$&lt;/span&gt; are scalars. How would you use a Python program to perform grid search for this optimization problem? I'm having quite a bit of trouble with it because I am not quite sure how to discretize and upper-bound my search space. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="11234" LastEditorUserId="11234" LastEditDate="2023-02-11T23:24:30.660" LastActivityDate="2023-02-12T19:14:40.980" Title="Grid search for optimization problem" Tags="|optimization|python|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9923" PostTypeId="1" CreationDate="2023-02-11T22:49:22.313" Score="3" ViewCount="238" Body="&lt;p&gt;I have a problem in the following type:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i∈I}{\max_{j∈J}c_{ij}\cdot x_{j}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For each objective, in a set of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables, the goal is to select the one with the highest cost coefficient. After obtaining their objective values, we sum them up. Is there any simple way to write this in CPLEX? In minimax or maximax adding a dummy variable would be the way but it does not work in this case as we sum the objectives of multiple problems. However, defining &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; many problems, solving them seperately and summing their values would be too time consuming. Is there any fast way to do this?&lt;/p&gt;&#xA;" OwnerDisplayName="user5245" LastEditorUserId="123" LastEditDate="2023-02-11T22:55:11.693" LastActivityDate="2023-02-12T20:32:33.520" Title="Summation of maximization terms in CPLEX" Tags="|optimization|cplex|docplex|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9924" PostTypeId="2" ParentId="9923" CreationDate="2023-02-11T23:37:19.003" Score="1" Body="&lt;p&gt;Wouldn't know exactly in CPLEX but referring to this &lt;a href=&quot;https://or.stackexchange.com/questions/860/sum-of-max-terms-maximization&quot;&gt;answer&lt;/a&gt; one way is to define &lt;span class=&quot;math-container&quot;&gt;$\theta_i$&lt;/span&gt; and binary variables &lt;span class=&quot;math-container&quot;&gt;$z \in \{0,1\}^{I\times J}$&lt;/span&gt;as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ c_{ij}x_j \le \theta_i \le c_{ij}x_ j + M(1-z_{ij}) \ \ \forall j \ \ \forall i$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_j z_{ij} = 1 \ \ \forall i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then sum up &lt;span class=&quot;math-container&quot;&gt;$\sum_i \theta_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; is already binary and to be used to indicate the max coefficient then referring to 2nd answer &lt;a href=&quot;https://math.stackexchange.com/questions/2446606/linear-programming-set-a-variable-the-max-between-two-another-variables&quot;&gt;here&lt;/a&gt;&lt;br /&gt;&#xA;Define &lt;span class=&quot;math-container&quot;&gt;$\theta_i$&lt;/span&gt; as&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$c_{ij}\le \theta_i \le c_{ij} + M(1-x_{ij})\ \ \forall j$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_j x_{ij}=1 \ \ \forall i $&lt;/span&gt;&lt;br /&gt;&#xA;Then sum up &lt;span class=&quot;math-container&quot;&gt;$\sum_i \theta_i$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-12T15:59:17.413" LastActivityDate="2023-02-12T15:59:17.413" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9925" PostTypeId="1" CreationDate="2023-02-12T00:23:59.780" Score="2" ViewCount="117" Body="&lt;p&gt;Suppose I want to minimize a linear function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; over a convex set &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; and I have only access to a separation oracle, that is, given a point, the oracle returns yes if the point is in &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; and otherwise returns a hyperplane separating the point from the set. How can I use this to minimize &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; in polynomial time?&lt;/p&gt;&#xA;&lt;p&gt;I have read about cutting plane methods that return a point in the set unless the volume if the set is very small. But I don't see how it will help to get the minimizer of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11245" LastActivityDate="2023-02-12T11:54:41.227" Title="Separation oracle gives optimisation" Tags="|optimization|linear-programming|convex-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9926" PostTypeId="2" ParentId="9925" CreationDate="2023-02-12T11:54:41.227" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Cutting-plane_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;cutting plane algorithm&lt;/a&gt; is often used when one would like to derive the integer solution from the linear relaxation of the original space. (I assumed the original problem is an LP). The cutting plane method for solving MIPs can be viewed&#xA;as an extension of the dual simplex method in which the separation procedure (for&#xA;searching violated inequalities) is not limited to verifying the constraints of the current formulation, but can also generate new cuts.&lt;/p&gt;&#xA;&lt;p&gt;Now, suppose there is a linear minimization (or maximization) problem that the solution space &lt;span class=&quot;math-container&quot;&gt;$\in \mathbb{R}^+$&lt;/span&gt;. By using the cutting plan algorithm one can invoke the integer solution set from the original solution space that &lt;span class=&quot;math-container&quot;&gt;$\in \mathbb{Z}^+$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Some of its variants are, for example, &lt;a href=&quot;https://wwwhome.ewi.utwente.nl/%7Euetzm/do/DO_Lecture7.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chvatal-Gomory&lt;/a&gt; or &lt;a href=&quot;https://optimization.cbe.cornell.edu/index.php?title=Mixed-integer_cuts#:%7E:text=Mixed%2DInteger%20Rounding%20(MIR),%2Dinteger%20programs%20(8).&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mixed-integer rounding cut&lt;/a&gt;. It is known that this separation problem is NP-hard. But, on the other hand, there are a number of important special cases when it is solved efficiently. For more details please, check the separation procedure for C-G cuts.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-02-12T11:54:41.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9927" PostTypeId="2" ParentId="9923" CreationDate="2023-02-12T16:02:23.500" Score="3" Body="&lt;p&gt;It sounds like you want to maximize &lt;span class=&quot;math-container&quot;&gt;$$\sum_i \sum_j c_{ij} x_{ij}$$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j x_{ij} &amp;amp;=1 &amp;amp;&amp;amp;\text{for all $i$} \\&#xA;x_{ij} &amp;amp;\in\{0,1\} &amp;amp;&amp;amp;\text{for all $i$ and $j$} \end{align}&lt;/span&gt;&#xA;The optimal objective value is clearly &lt;span class=&quot;math-container&quot;&gt;$\sum_i \max_j c_{ij}$&lt;/span&gt;, so you don’t really need to call a solver. If you need to set &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1$&lt;/span&gt; for exactly one largest &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, you can do that with a simple loop over &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, again without calling a solver. If you insist on calling a solver and don’t want to decompose by &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, just solve the one big problem directly. There is no need to introduce auxiliary variables or big-M constraints.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-02-12T16:02:23.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9928" PostTypeId="2" ParentId="9922" CreationDate="2023-02-12T17:37:36.387" Score="2" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\DeclareMathOperator*{\argmax}{arg\,max}&#xA;\DeclareMathOperator*{\argmin}{arg\,min}$&lt;/span&gt;&#xA;Define &lt;span class=&quot;math-container&quot;&gt;$$f(b\vert a)=\dfrac{(a^2 + 1)(a + b)}{2a + b} + \dfrac{b}{a + b} - ab$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$g(a) = \argmax_{b \ge 0} f(b\vert a).$$&lt;/span&gt; For any given value of &lt;span class=&quot;math-container&quot;&gt;$a,$&lt;/span&gt; we will evaluate &lt;span class=&quot;math-container&quot;&gt;$g(a)$&lt;/span&gt; numerically by doing a line search for the max of &lt;span class=&quot;math-container&quot;&gt;$f(b\vert a)$&lt;/span&gt; in the &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; direction. To get the optimal value of &lt;span class=&quot;math-container&quot;&gt;$a,$&lt;/span&gt; we do a line search for the min of &lt;span class=&quot;math-container&quot;&gt;$g(a).$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How you do the line searches is up to you. Since &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is differentiable, you could use bisection search when evaluating &lt;span class=&quot;math-container&quot;&gt;$g(a)$&lt;/span&gt; and, say, &lt;a href=&quot;https://en.wikipedia.org/wiki/Golden-section_search&quot; rel=&quot;nofollow noreferrer&quot;&gt;golden section search&lt;/a&gt; when minimizing &lt;span class=&quot;math-container&quot;&gt;$g().$&lt;/span&gt; It might be easier from a coding standpoint to do golden section search along both axes. There are other line search algorithms, but I'm pretty comfortable with golden section.&lt;/p&gt;&#xA;&lt;p&gt;To do a search for the maximum of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; given a value of &lt;span class=&quot;math-container&quot;&gt;$a,$&lt;/span&gt; I would start with &lt;span class=&quot;math-container&quot;&gt;$b = 0$&lt;/span&gt; and evaluate &lt;span class=&quot;math-container&quot;&gt;$f(1, a), f(2, a), f(4,a), f(8,a) \dots$&lt;/span&gt; until I had a big enough value &lt;span class=&quot;math-container&quot;&gt;$b_0$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; such that one of the points in the interval &lt;span class=&quot;math-container&quot;&gt;$[0, b_0]$&lt;/span&gt; had a bigger value of &lt;span class=&quot;math-container&quot;&gt;$f()$&lt;/span&gt; than either 0 or &lt;span class=&quot;math-container&quot;&gt;$b_0$&lt;/span&gt; had, telling me there was a maximizer (or at least a local maximizer) somewhere in the interval &lt;span class=&quot;math-container&quot;&gt;$[0, b_0].$&lt;/span&gt; That would be my starting interval for GS search.&lt;/p&gt;&#xA;&lt;p&gt;Similarly, when search for the minimizer of &lt;span class=&quot;math-container&quot;&gt;$g,$&lt;/span&gt; I would look at &lt;span class=&quot;math-container&quot;&gt;$g(0), g(1), g(2), g(4), g(8)\dots$&lt;/span&gt; until I saw the value of &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; turn back upwards, giving me the starting interval for GS search on the &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; dimension.&lt;/p&gt;&#xA;&lt;p&gt;I'll add two disclaimers. First, GS search finds a global optimizer when the function in question is unimodal (only turns from decreasing to increasing or increasing to decreasing, whichever is relevant, once). Otherwise you are only guaranteed to find a local optimizer. Second, the business of finding the initial search interval by taking longer and longer steps until you see the function values change direction won't work as described if the function is increasing/decreasing toward an asymptotic value. If I saw a bunch of function values that pretty much stopped changing (changes smaller than numerical tolerance, or smaller than the number of decimal places I was using), I would just stop there and define the first instance of the asymptotic value as the upper endpoint of my search interval.&lt;/p&gt;&#xA;&lt;p&gt;Edit: I'm not a Python user, but R has multiple library routines for optimizing functions of a single variable. My guess is that Python does as well.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-02-12T19:14:40.980" LastActivityDate="2023-02-12T19:14:40.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9929" PostTypeId="2" ParentId="9923" CreationDate="2023-02-12T20:32:33.520" Score="0" Body="&lt;p&gt;We can use the following identity:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i \in I}{\max_{j \in J}c_{ij}\cdot x_{j}}&#xA;= \max_{j_1,\dots,j_{|I|} \in J} \sum_{i \in I} c_{i j_i} \cdot x_{j_i} = \max_{j_1,\dots,j_{|I|} \in J} c_{1 j_1} x_{j_1} + \dots + c_{k j_{|I|}} x_{j_{|I|}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;One way to encode this as integer linear programming is to express each &lt;span class=&quot;math-container&quot;&gt;$j_i$&lt;/span&gt; as a one-hot vector, e.g., &lt;span class=&quot;math-container&quot;&gt;$j_i=1$&lt;/span&gt; corresponds to &lt;span class=&quot;math-container&quot;&gt;$(1,0,0,\dots,0)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j_i=2$&lt;/span&gt; corresponds to &lt;span class=&quot;math-container&quot;&gt;$(0,1,0,\dots,0)$&lt;/span&gt;, etc.  If we expand that out, we build a matrix &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$|I|$&lt;/span&gt; columns and &lt;span class=&quot;math-container&quot;&gt;$|J|$&lt;/span&gt; rows, where &lt;span class=&quot;math-container&quot;&gt;$M_{uv}=1$&lt;/span&gt; iff &lt;span class=&quot;math-container&quot;&gt;$j_u=v$&lt;/span&gt;.  Then the objective function becomes&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_M \sum_{u,v} M_{uv} c_{uv} x_v,$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the maximization is taken over all zero-or-one matrices &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\sum_v M_{uv}=1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2415" LastActivityDate="2023-02-12T20:32:33.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9930" PostTypeId="2" ParentId="9853" CreationDate="2023-02-13T08:12:54.107" Score="1" Body="&lt;p&gt;This is an attempt at a solution. It has several shortcomings.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it is a discrete solution&lt;/li&gt;&#xA;&lt;li&gt;it does not have bookings yet&lt;/li&gt;&#xA;&lt;li&gt;it should handle different buying and selling prices, but it does not.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;On the upside&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it does buy and sell&lt;/li&gt;&#xA;&lt;li&gt;it handles a few thousand variables nicely&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Some of this is most likely a z3 limitation. I will try with another optimizer next.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;from z3 import *&#xA;&#xA;CHARGING_CONST = 1/3&#xA;START_VAL = 1.0&#xA;NUM = 20&#xA;&#xA;def make_demo_data():&#xA;    x = np.linspace(0, (4 * np.pi), NUM)&#xA;    y = np.sin(x) +1.5 -.025 * x&#xA;    z = np.sin(x) * 3 -.027 * x&#xA;    data = np.zeros(NUM, dtype=([(&amp;quot;time&amp;quot;, float), (&amp;quot;price&amp;quot;, float), (&amp;quot;price_co2&amp;quot;, float)]))&#xA;    data[&amp;quot;time&amp;quot;] = x&#xA;    data[&amp;quot;price&amp;quot;] = y&#xA;    data[&amp;quot;price_co2&amp;quot;] = z&#xA;    return data&#xA;&#xA;data = make_demo_data()&#xA;soc = []&#xA;&#xA;o = z3.Optimize()&#xA;soc.append(z3.Real(&amp;quot;soc_0&amp;quot;))&#xA;o.add(soc[0] &amp;lt;= START_VAL + CHARGING_CONST)&#xA;o.add(soc[0] &amp;gt;= START_VAL - CHARGING_CONST)&#xA;o.add(soc[0] &amp;gt;= 0)&#xA;o.add(soc[0] &amp;lt;= 1)&#xA;f_obj = 0&#xA;f_obj += data[&amp;quot;price&amp;quot;][0] * (START_VAL - soc[0])&#xA;&#xA;for cnt in range(1, NUM):&#xA;    soc.append(z3.Real(f&amp;quot;soc_{cnt}&amp;quot;))&#xA;    o.add(soc[cnt] &amp;lt;= soc[cnt - 1] + CHARGING_CONST)&#xA;    o.add(soc[cnt] &amp;gt;= soc[cnt - 1] - CHARGING_CONST)&#xA;    o.add(soc[cnt] &amp;gt;= 0)&#xA;    o.add(soc[cnt] &amp;lt;= 1)&#xA;    f_obj += (soc[cnt - 1] - soc[cnt]) *\&#xA;        z3.If(soc[cnt - 1] &amp;gt;= soc[cnt],&#xA;           data[&amp;quot;price&amp;quot;][cnt],&#xA;           data[&amp;quot;price_co2&amp;quot;][cnt])&#xA;# data[&amp;quot;price&amp;quot;][cnt]&#xA;&#xA;o.add(soc[-1] == START_VAL)&#xA;o.maximize(f_obj)&#xA;print(o.check())&#xA;m=o.model()&#xA;&#xA;for cnt in range(NUM):&#xA;    print(f&amp;quot;&amp;quot;&amp;quot;{cnt}: {m.evaluate(soc[cnt]).as_decimal(2)}&amp;quot;&amp;quot;&amp;quot;)&#xA;&#xA;print(f&amp;quot;Result: {m.evaluate(f_obj).as_decimal(2).strip('?')}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11166" LastEditorUserId="11166" LastEditDate="2023-02-13T08:27:56.797" LastActivityDate="2023-02-13T08:27:56.797" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9931" PostTypeId="1" CreationDate="2023-02-13T10:39:34.453" Score="0" ViewCount="68" Body="&lt;p&gt;I am currently learning Python and doing object-oriented programming. I am trying to create a simulation for MDP.&lt;/p&gt;&#xA;&lt;p&gt;My problem statement is: &amp;quot;I have four stages of process. Each stage has two equipment items. Each equipment item is associated with doing a certain task&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;I am trying to formulate Class in Python for stage, equipment item, production task and so on.&lt;/p&gt;&#xA;&lt;p&gt;Ex:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;class Stage:&#xA;def __init__(self, equipment: EquipmentItem):&#xA;&#xA;    self.equipment = equipment &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;    class EquipmentItem:&#xA;    def __init__(self, tasks: List[ProductionTask] ):&#xA;&#xA;        self.tasks = tasks&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Each stage has two equipment items.&lt;/p&gt;&#xA;" OwnerUserId="10916" LastEditorUserId="491" LastEditDate="2023-02-13T14:44:59.677" LastActivityDate="2023-02-13T14:44:59.677" Title="Creating a simple class in python for doing simulation of MDP" Tags="|mixed-integer-programming|python|scheduling|markov-decision-process|reinforcement-learning|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9932" PostTypeId="1" CreationDate="2023-02-13T14:51:54.770" Score="1" ViewCount="702" Body="&lt;p&gt;I have inherited a reasonably simple ortools-based optimizer (Python) with linear relationships that I need to non-linear-ize, and I have no idea how to do that.&lt;/p&gt;&#xA;&lt;p&gt;The relevant part of my problem looks like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solver = pywraplp.Solver(&amp;quot;B&amp;quot;, pywraplp.Solver.GLOP_LINEAR_PROGRAMMING)&#xA;...&#xA;# charging a battery&#xA;## cap_prev: capacity before the current timeslot&#xA;## cap: ditto afterwards&#xA;## b_chg: charging power&#xA;## all are NumVar(0,some_hardware_limit)&#xA;&#xA;solver.Add(cap_prev + 0.9 * b_chg - b_dis == cap)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The problem is that I need to replace the &lt;code&gt;0.9&lt;/code&gt; with something that depends on the value of &lt;code&gt;b_chg&lt;/code&gt;. The Naïve solution looks like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solver.Add(cap_prev + b_chg_eff - b_dis == cap)&#xA;&#xA;solver.Add(b_chg_eff == b_chg * (0.1+b_chg*0.8)).OnlyEnforceIf(b_chg&amp;lt;100)&#xA;solver.Add(b_chg_eff == b_chg * (0.9).OnlyEnforceIf(100&amp;lt;=b_chg&amp;lt;200)&#xA;solver.Add(b_chg_eff == b_chg * (0.9-(b_chg-200)*0.01).OnlyEnforceIf(200&amp;lt;=b_chg)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;except that this is no longer linear, which kindof points to the assumption that I need a different solver.&lt;/p&gt;&#xA;" OwnerUserId="11253" LastEditorUserId="491" LastEditDate="2023-11-10T22:29:09.273" LastActivityDate="2023-12-10T23:04:00.407" Title="OR-Tools: Nonlinear constraints?" Tags="|nonlinear-programming|or-tools|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9933" PostTypeId="2" ParentId="9918" CreationDate="2023-02-13T16:09:43.630" Score="2" Body="&lt;p&gt;Sutanu's contribution helped me a lot. In addition, I am posting the source code for modelling the constraints for &lt;span class=&quot;math-container&quot;&gt;$y_{st}$&lt;/span&gt; to help people with a similar problem.&lt;/p&gt;&#xA;&lt;p&gt;I used the demand as Big M in order not to choose the value larger than necessary: &lt;span class=&quot;math-container&quot;&gt;$Big\ M=\sum_{p}\sum_{t}d_{p,t}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(1) &lt;span class=&quot;math-container&quot;&gt;$y_{st}\le\sum_{p}x_{p,s,t},\forall t\in T,\forall s\in S$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(2) &lt;span class=&quot;math-container&quot;&gt;$\sum_{p}\ x_{p,s,t}\le M{*y}_{s,t},\ \forall\ t\in\ T,\forall\ s\in\ S$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The following code creates the corresponding constraints in Pyomo:&lt;/p&gt;&#xA;&lt;p&gt;(1)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.constraint_1 = pyo.ConstraintList()&#xA;for s in model.S:&#xA;    for t in model.T:&#xA;        lhs_1 = model.y_2[s,t]&#xA;        rhs_1 = sum(model.x[p,s,t] for p in model.P for t in model.T)&#xA;        model.constraint_1.add(lhs_1&amp;lt;=rhs_1)&#xA;model.constraint_1.pprint() #Output command for constraints&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;(2)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.constraint_2 = pyo.ConstraintList()&#xA;for s in model.S:&#xA;    for t in model.T:&#xA;        lhs_2 = sum(model.x[p,s,t] for p in model.P)&#xA;        rhs_2 = model.y_2[s,t]*sum(model.d[p,t] for p in model.P for t in model.T)&#xA;        model.constraint_2.add(lhs_2&amp;lt;=rhs_2)&#xA;model.constraint_2.pprint() #Output command for constraints&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11238" LastActivityDate="2023-02-13T16:09:43.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9934" PostTypeId="2" ParentId="9932" CreationDate="2023-02-13T17:04:59.743" Score="0" Body="&lt;p&gt;If you are looking to linearize the 3 conditional relations/constraints below is what you may do&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ 200\delta_3+ 100\delta_2 \le$&lt;/span&gt; b_chng &lt;span class=&quot;math-container&quot;&gt;$\le (200+e)\delta_2 +(100+e)\delta_1 $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{i=1}^3\delta_i = 1$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; are binary and e is a very small number (like &lt;span class=&quot;math-container&quot;&gt;$1e-3$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Then&lt;br /&gt;&#xA;b_chng_eff= 1st Constr1&lt;span class=&quot;math-container&quot;&gt;$\delta_1$&lt;/span&gt;+2nd_Constr&lt;span class=&quot;math-container&quot;&gt;$\delta_2$&lt;/span&gt;+3rd_Constr&lt;span class=&quot;math-container&quot;&gt;$\delta_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As for the 2nd degree quads for 2 of the above relations, most solvers will be able to accept these constraints. Else you may choose piecewise linearization as suggested &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/constraints.html#subsubsection:GeneralConstraints&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, scroll down to piecewise linear constraints.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-02-13T17:04:59.743" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9935" PostTypeId="1" CreationDate="2023-02-13T19:28:37.337" Score="4" ViewCount="86" Body="&lt;p&gt;Has there been any research  on the topic of directional derivatives of functions that are minimums of convex functions?&lt;/p&gt;&#xA;" OwnerUserId="5217" LastEditorUserId="491" LastEditDate="2023-02-15T13:08:49.707" LastActivityDate="2023-02-15T13:08:49.707" Title="The study of directional derivatives for functions that are minimums of convex functions" Tags="|reference-request|convex-optimization|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9936" PostTypeId="2" ParentId="9908" CreationDate="2023-02-14T18:08:53.320" Score="1" Body="&lt;p&gt;Here's my modified code:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from collections import defaultdict, Counter&#xA;&#xA;def allocate_employees(city_data, team_data, employee_data):&#xA;    city_office_capacity = defaultdict(dict)&#xA;    for city, office, capacity in city_data:&#xA;        city_office_capacity[city][office] = capacity&#xA;&#xA;    team_position_count = defaultdict(Counter)&#xA;    for team, position in team_data:&#xA;        team_position_count[team][position] += 1&#xA;&#xA;    employee_allocations = []&#xA;    for employee, city, position in employee_data:&#xA;        max_capacity = 0&#xA;        max_office = None&#xA;        for office, capacity in city_office_capacity[city].items():&#xA;            if capacity &amp;gt; max_capacity:&#xA;                max_capacity = capacity&#xA;                max_office = office&#xA;        city_office_capacity[city][max_office] -= 1&#xA;        for team, position_count in team_position_count.items():&#xA;            if position_count[position] &amp;gt; 0:&#xA;                employee_allocations.append((team, employee, position, city, max_office))&#xA;                team_position_count[team][position] -= 1&#xA;                break&#xA;    return employee_allocations&#xA;&#xA;city_data = [&#xA;    (&amp;quot;New York&amp;quot;, &amp;quot;A&amp;quot;, 3),&#xA;    (&amp;quot;New York&amp;quot;, &amp;quot;B&amp;quot;, 2),&#xA;    (&amp;quot;New York&amp;quot;, &amp;quot;C&amp;quot;, 6),&#xA;    (&amp;quot;Boston&amp;quot;, &amp;quot;D&amp;quot;, 2),&#xA;    (&amp;quot;Boston&amp;quot;, &amp;quot;E&amp;quot;, 5),&#xA;]&#xA;&#xA;team_data = [&#xA;    (&amp;quot;alpha&amp;quot;, &amp;quot;Manager&amp;quot;),&#xA;    (&amp;quot;alpha&amp;quot;, &amp;quot;Manager&amp;quot;),&#xA;    (&amp;quot;alpha&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (&amp;quot;alpha&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (&amp;quot;alpha&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (&amp;quot;alpha&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (&amp;quot;alpha&amp;quot;, &amp;quot;Designer&amp;quot;),&#xA;    (&amp;quot;beta&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (&amp;quot;beta&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (&amp;quot;beta&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (&amp;quot;gamma&amp;quot;, &amp;quot;Designer&amp;quot;),&#xA;    (&amp;quot;gamma&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;]&#xA;&#xA;employee_data = [&#xA;    (1, &amp;quot;New York&amp;quot;, &amp;quot;Manager&amp;quot;),&#xA;    (2, &amp;quot;New York&amp;quot;, &amp;quot;Manager&amp;quot;),&#xA;    (3, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (4, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (5, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (6, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (7, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (8, &amp;quot;New York&amp;quot;, &amp;quot;Designer&amp;quot;),&#xA;    (9, &amp;quot;New York&amp;quot;, &amp;quot;Designer&amp;quot;),&#xA;    (10, &amp;quot;Boston&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (11, &amp;quot;Boston&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;    (12, &amp;quot;Boston&amp;quot;, &amp;quot;Engineer&amp;quot;),&#xA;]&#xA;&#xA;allocations = allocate_employees(city_data, team_data, employee_data)&#xA;for r in allocations:&#xA;    print(r)&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1016" LastActivityDate="2023-02-14T18:08:53.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9937" PostTypeId="1" CreationDate="2023-02-15T06:16:10.560" Score="3" ViewCount="47" Body="&lt;p&gt;I am trying to come with a optimization framework &amp;amp; cost function for the following problem:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I have a stream of tasks coming in (volume of tasks upfront is unknown). Each task has a priority between 0 and 1 (1 being highest) and an Expiry Time (after which the Task is considered to be cancelled) - which is usually 1 or 2 days. Doing each task can take a few minutes.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I have two sets of workers:&lt;/p&gt;&#xA;&lt;p&gt;1st Set Are Highly Skilled (have accuracy of High_X%) and have a fixed capacity of High_Y tasks/day and fixed cost $High_Z/day. The number of people might vary throughout the day as they login or out.&lt;/p&gt;&#xA;&lt;p&gt;2nd Set are low skilled (have accuracy of Low_X%), have a fixed capacity of Low_Y Tasks/day. However, their cost is different. They have a variable cost of $Low_Z_Per_Ad which is lower than High_Z/High_Y. The number of people might vary throughout the day as they login or out.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;We need to try and maximize the sum(priority) of tasks done &lt;em&gt;accurately&lt;/em&gt; before their Expiry Time, while minimizing the cost.&lt;/p&gt;&#xA;&lt;p&gt;Note the number of tasks is greater than High_Y + Low_Y so we can't follow a simple strategy of assigning of highest priority to High Skill and lowest priority to low skill.&lt;/p&gt;&#xA;&lt;p&gt;Since this is a stream of tasks, and the number of tasks + number of workers vary throughout the day, I am thinking the best way is to run an optimization every X minutes by forming a graph between the Tasks and Workers where the edges have a cost function. And then try to pick the edges with least cost while ensuring each task is only assigned to one worker.&lt;/p&gt;&#xA;&lt;p&gt;However, what should the cost function look like for this kind of problem.&lt;/p&gt;&#xA;" OwnerUserId="1020" LastActivityDate="2023-02-15T17:07:28.610" Title="Cost function for Routing Tasks between differently skilled workers" Tags="|optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9938" PostTypeId="1" AcceptedAnswerId="9941" CreationDate="2023-02-15T16:20:54.230" Score="6" ViewCount="468" Body="&lt;p&gt;I want to maximize the sum of a nonlinear function &lt;span class=&quot;math-container&quot;&gt;$f(.)$&lt;/span&gt; w.r.t. &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; that is convex in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max \sum_{i=1}^N f(x_i), $$&lt;/span&gt;where &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is a continuous variable and &lt;span class=&quot;math-container&quot;&gt;$0 \le x_i &amp;lt; 1$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i = 1, 2, \dots , N$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But in this problem, &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is restricted to be an element of the set &lt;span class=&quot;math-container&quot;&gt;$a = \lbrace a_1, a_2, a_3 \rbrace$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$a_j$&lt;/span&gt; is also a continuous variable and &lt;span class=&quot;math-container&quot;&gt;$0 \le a_j &amp;lt; 1$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$j = 1, 2, 3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The problem is thus to maximize the objective function in w.r.t. of &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i= 1, 2, \dots , N$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; has to belong to the set &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_j$&lt;/span&gt; also is unknown and thus a decision variable.&lt;/p&gt;&#xA;&lt;p&gt;There is one more constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\beta = \frac{\sum_{i=1}^N D_i x_i }{\sum_{i=1}^N D_i},$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$D_i$&lt;/span&gt; is a known constant for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; is again a constant with &lt;span class=&quot;math-container&quot;&gt;$0 \le \beta &amp;lt; 1$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$D_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; are thus outside of the model.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to formulate this as an NLP problem?&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2023-02-16T08:14:16.867" LastActivityDate="2023-02-21T16:10:44.677" Title="How do we formulate a problem where the decision variable has an index that is also a decision variable?" Tags="|modeling|nonlinear-programming|constrained-optimization|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9939" PostTypeId="2" ParentId="9938" CreationDate="2023-02-15T16:59:06.837" Score="1" Body="&lt;p&gt;Assuming set &lt;span class=&quot;math-container&quot;&gt;$a=\{a_1,a_2,a_3\}$&lt;/span&gt; is filled with variable &lt;span class=&quot;math-container&quot;&gt;$a_k$&lt;/span&gt; and also where &lt;span class=&quot;math-container&quot;&gt;$a_j$&lt;/span&gt; can take any value from set &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, lets try:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{j=1}^3 a_j\cdot z_{j,i} = a_i \ \ \forall i$&lt;/span&gt; &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_j z_{j,i} = 1 \ \ \forall i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The above 2 will turn &lt;span class=&quot;math-container&quot;&gt;$ z_j = 1$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$a_j = a_i$&lt;/span&gt; for an index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then &lt;span class=&quot;math-container&quot;&gt;$\sum_j z_{j,i}\cdot x_{j} \ \ \forall i$&lt;/span&gt; which can be linearized by&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \epsilon z_{j,i} \le x_{j} \le Mz_{j,i} \ \ \forall j \ \ \forall i$&lt;/span&gt; where M and &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; can be the upper &amp;amp; lower bound for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-15T18:56:34.320" LastActivityDate="2023-02-15T18:56:34.320" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9940" PostTypeId="2" ParentId="9937" CreationDate="2023-02-15T17:07:28.610" Score="3" Body="&lt;p&gt;Since you have two distinct objectives (maximizing priority-weighted accurate task completions and minimizing cost), one approach is to form a weighted combination of the two objective functions and optimize that.&lt;/p&gt;&#xA;&lt;p&gt;The first question is whether objective one (completions) can be expressed as a linear function. Are you comfortable with giving each task a &amp;quot;value&amp;quot; formed by the product of the probability it is completed accurately and the priority? This implicitly assumes that a task with priority 0.6 is twice as important/valuable as a task with priority 0.3.&lt;/p&gt;&#xA;&lt;p&gt;Assuming the answer is yes, then the next question is whether you can quantify the tradeoff between task value and cost. Can you find a value &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; such that you would be indifferent between increasing (decreasing) a task value by 1 and increasing (decreasing) cost by &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;? Note that this implies that the monetary value of a one unit change in task value (product of priority and completion probability) is constant regardless whether it would be adding to a low value or a high value.&lt;/p&gt;&#xA;&lt;p&gt;It the answer is again yes, then you can look at maximizing (task value - &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; * cost) as your objective function.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-02-15T17:07:28.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9941" PostTypeId="2" ParentId="9938" CreationDate="2023-02-15T18:53:45.160" Score="9" Body="&lt;p&gt;Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$x_i = a_j$&lt;/span&gt;, and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j y_{ij} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \tag1\label1 \\&#xA;-(1 - y_{ij}) \le x_i - a_j &amp;amp;\le 1 - y_{ij} &amp;amp;&amp;amp;\text{for all $i$ and $j$} \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} selects exactly one &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and (big-M) constraint \eqref{2} enforces the logical implication &lt;span class=&quot;math-container&quot;&gt;$y_{ij} = 1 \implies x_i = a_j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-02-15T20:05:04.667" LastActivityDate="2023-02-15T20:05:04.667" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9942" PostTypeId="1" CreationDate="2023-02-16T04:52:01.777" Score="5" ViewCount="468" Body="&lt;p&gt;Essentially, I am trying to solve a simple orthogonal least-squares (OLS) problem with some constraints — the coefficients must sum to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, no coefficient can be less than &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, and no coefficient can be greater than &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. I am using CVXPY for this and I get solutions for only the SCS solver.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;def get_w(A, b):&#xA;    # Define the decision variables&#xA;    x = cp.Variable(&#xA;        A.shape[1], &#xA;        nonneg=True&#xA;    )&#xA;&#xA;    # Define the objective function and the constraints&#xA;    objective = cp.Minimize(cp.sum_squares(A @ x - b))&#xA;    # Define the constraints&#xA;    constraints = [cp.sum(x) == 1]  # weights must sum to 1&#xA;    other_constraints = [x &amp;lt;= 1, x&amp;gt;= 0]  # weights must not be greater than 1 and should not be nonnegative&#xA;&#xA;    # Define the problem instance and solve it&#xA;    problem = cp.Problem(&#xA;        objective, &#xA;        constraints + other_constraints&#xA;    )&#xA;    problem.solve(solver=cp.SCS, verbose=True) # using SCS solver&#xA;    # problem.solve(solver=cp.MOSEK, verbose=True) # using SCS solver&#xA;    # problem.solve(solver=cp.CVXOPT, verbose=True) # using CVXOPT solver&#xA;    # problem.solve(solver=cp.ECOS, verbose=True) # using ECOS solver&#xA;    # problem.solve(solver=cp.OSQP, verbose=True) # using OSQP solver&#xA;    print(&amp;quot;Optimal value: &amp;quot;, problem.value)&#xA;    print(&amp;quot;Optimal x: &amp;quot;, x.value)&#xA;    return x.value&#xA;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Using SCS:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;status:  solved&#xA;timings: total: 7.71e-01s = setup: 5.46e-04s + solve: 7.71e-01s&#xA;     lin-sys: 3.94e-01s, cones: 7.45e-02s, accel: 6.40e-02s&#xA;------------------------------------------------------------------&#xA;objective = 2990249263.651514&#xA;------------------------------------------------------------------&#xA;-------------------------------------------------------------------------------&#xA;                                    Summary                                    &#xA;-------------------------------------------------------------------------------&#xA;(CVXPY) Feb 16 11:49:08 AM: Problem status: optimal&#xA;(CVXPY) Feb 16 11:49:08 AM: Optimal value: 2.983e+09&#xA;(CVXPY) Feb 16 11:49:08 AM: Compilation took 1.653e-02 seconds&#xA;(CVXPY) Feb 16 11:49:08 AM: Solver (including time spent in interface) took 7.721e-01 seconds&#xA;Optimal value:  2982885159.9210763&#xA;Optimal x:  [0.01442644 0.80144737 0.00357662 0.         0.19490373 0.&#xA; 0.00103442 0.         0.0013799  0.00129703]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, using MOSEK:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;===============================================================================&#xA;                                     CVXPY                                     &#xA;                                     v1.3.0                                    &#xA;===============================================================================&#xA;(CVXPY) Feb 16 11:50:00 AM: Your problem has 10 variables, 3 constraints, and 0 parameters.&#xA;(CVXPY) Feb 16 11:50:00 AM: It is compliant with the following grammars: DCP, DQCP&#xA;(CVXPY) Feb 16 11:50:00 AM: (If you need to solve this problem multiple times, but with different data, consider using parameters.)&#xA;(CVXPY) Feb 16 11:50:00 AM: CVXPY will first compile your problem; then, it will invoke a numerical solver to obtain a solution.&#xA;-------------------------------------------------------------------------------&#xA;                                  Compilation                                  &#xA;-------------------------------------------------------------------------------&#xA;(CVXPY) Feb 16 11:50:00 AM: Compiling problem (target solver=MOSEK).&#xA;(CVXPY) Feb 16 11:50:00 AM: Reduction chain: Dcp2Cone -&amp;gt; CvxAttr2Constr -&amp;gt; ConeMatrixStuffing -&amp;gt; MOSEK&#xA;(CVXPY) Feb 16 11:50:00 AM: Applying reduction Dcp2Cone&#xA;(CVXPY) Feb 16 11:50:00 AM: Applying reduction CvxAttr2Constr&#xA;(CVXPY) Feb 16 11:50:00 AM: Applying reduction ConeMatrixStuffing&#xA;(CVXPY) Feb 16 11:50:00 AM: Applying reduction MOSEK&#xA;(CVXPY) Feb 16 11:50:00 AM: Finished problem compilation (took 1.420e-02 seconds).&#xA;-------------------------------------------------------------------------------&#xA;                                Numerical solver                               &#xA;-------------------------------------------------------------------------------&#xA;(CVXPY) Feb 16 11:50:00 AM: Invoking solver MOSEK  to obtain a solution.&#xA;&#xA;&#xA;(CVXPY) Feb 16 11:50:00 AM: Problem&#xA;(CVXPY) Feb 16 11:50:00 AM:   Name                   :                 &#xA;(CVXPY) Feb 16 11:50:00 AM:   Objective sense        : maximize        &#xA;(CVXPY) Feb 16 11:50:00 AM:   Type                   : CONIC (conic optimization problem)&#xA;(CVXPY) Feb 16 11:50:00 AM:   Constraints            : 11              &#xA;(CVXPY) Feb 16 11:50:00 AM:   Affine conic cons.     : 0               &#xA;(CVXPY) Feb 16 11:50:00 AM:   Disjunctive cons.      : 0               &#xA;(CVXPY) Feb 16 11:50:00 AM:   Cones                  : 1               &#xA;(CVXPY) Feb 16 11:50:00 AM:   Scalar variables       : 83              &#xA;(CVXPY) Feb 16 11:50:00 AM:   Matrix variables       : 0               &#xA;(CVXPY) Feb 16 11:50:00 AM:   Integer variables      : 0               &#xA;(CVXPY) Feb 16 11:50:00 AM: &#xA;(CVXPY) Feb 16 11:50:00 AM: Optimizer started.&#xA;(CVXPY) Feb 16 11:50:00 AM: Presolve started.&#xA;(CVXPY) Feb 16 11:50:00 AM: Linear dependency checker started.&#xA;(CVXPY) Feb 16 11:50:00 AM: Linear dependency checker terminated.&#xA;(CVXPY) Feb 16 11:50:00 AM: Eliminator started.&#xA;(CVXPY) Feb 16 11:50:00 AM: Freed constraints in eliminator : 0&#xA;(CVXPY) Feb 16 11:50:00 AM: Eliminator terminated.&#xA;(CVXPY) Feb 16 11:50:00 AM: Eliminator started.&#xA;(CVXPY) Feb 16 11:50:00 AM: Freed constraints in eliminator : 0&#xA;(CVXPY) Feb 16 11:50:00 AM: Eliminator terminated.&#xA;(CVXPY) Feb 16 11:50:00 AM: Eliminator - tries                  : 2                 time                   : 0.00            &#xA;(CVXPY) Feb 16 11:50:00 AM: Lin. dep.  - tries                  : 1                 time                   : 0.00            &#xA;(CVXPY) Feb 16 11:50:00 AM: Lin. dep.  - number                 : 0               &#xA;(CVXPY) Feb 16 11:50:00 AM: Presolve terminated. Time: 0.01    &#xA;(CVXPY) Feb 16 11:50:00 AM: Problem&#xA;(CVXPY) Feb 16 11:50:00 AM:   Name                   :                 &#xA;(CVXPY) Feb 16 11:50:00 AM:   Objective sense        : maximize        &#xA;(CVXPY) Feb 16 11:50:00 AM:   Type                   : CONIC (conic optimization problem)&#xA;(CVXPY) Feb 16 11:50:00 AM:   Constraints            : 11              &#xA;(CVXPY) Feb 16 11:50:00 AM:   Affine conic cons.     : 0               &#xA;(CVXPY) Feb 16 11:50:00 AM:   Disjunctive cons.      : 0               &#xA;(CVXPY) Feb 16 11:50:00 AM:   Cones                  : 1               &#xA;(CVXPY) Feb 16 11:50:00 AM:   Scalar variables       : 83              &#xA;(CVXPY) Feb 16 11:50:00 AM:   Matrix variables       : 0               &#xA;(CVXPY) Feb 16 11:50:00 AM:   Integer variables      : 0               &#xA;(CVXPY) Feb 16 11:50:00 AM: &#xA;(CVXPY) Feb 16 11:50:00 AM: Optimizer  - threads                : 1               &#xA;(CVXPY) Feb 16 11:50:00 AM: Optimizer  - solved problem         : the primal      &#xA;(CVXPY) Feb 16 11:50:00 AM: Optimizer  - Constraints            : 11&#xA;(CVXPY) Feb 16 11:50:00 AM: Optimizer  - Cones                  : 2&#xA;(CVXPY) Feb 16 11:50:00 AM: Optimizer  - Scalar variables       : 74                conic                  : 54              &#xA;(CVXPY) Feb 16 11:50:00 AM: Optimizer  - Semi-definite variables: 0                 scalarized             : 0               &#xA;(CVXPY) Feb 16 11:50:00 AM: Factor     - setup time             : 0.00              dense det. time        : 0.00            &#xA;(CVXPY) Feb 16 11:50:00 AM: Factor     - ML order time          : 0.00              GP order time          : 0.00            &#xA;(CVXPY) Feb 16 11:50:00 AM: Factor     - nonzeros before factor : 66                after factor           : 66              &#xA;(CVXPY) Feb 16 11:50:00 AM: Factor     - dense dim.             : 0                 flops                  : 6.40e+03        &#xA;(CVXPY) Feb 16 11:50:00 AM: ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  &#xA;(CVXPY) Feb 16 11:50:00 AM: 0   1.0e+00  5.2e+05  2.0e+00  0.00e+00   -1.000000000e+00  0.000000000e+00   1.0e+00  0.01  &#xA;(CVXPY) Feb 16 11:50:00 AM: 1   2.4e-01  1.3e+05  9.9e-01  -1.00e+00  4.629821529e+00   2.539548706e+00   2.4e-01  0.02  &#xA;(CVXPY) Feb 16 11:50:00 AM: 2   1.1e-01  5.9e+04  6.7e-01  -1.00e+00  2.306848035e+01   1.611939361e+01   1.1e-01  0.02  &#xA;(CVXPY) Feb 16 11:50:00 AM: 3   3.9e-02  2.1e+04  4.0e-01  -1.00e+00  1.253251144e+02   1.019919163e+02   3.9e-02  0.02  &#xA;(CVXPY) Feb 16 11:50:00 AM: 4   1.2e-02  6.5e+03  2.2e-01  -1.00e+00  5.898058156e+02   5.109155876e+02   1.2e-02  0.02  &#xA;(CVXPY) Feb 16 11:50:00 AM: 5   4.0e-03  2.1e+03  1.3e-01  -1.00e+00  2.173195893e+03   1.923642037e+03   4.0e-03  0.02  &#xA;(CVXPY) Feb 16 11:50:00 AM: 6   1.7e-03  8.8e+02  8.2e-02  -9.99e-01  7.054617802e+03   6.460043795e+03   1.7e-03  0.02  &#xA;(CVXPY) Feb 16 11:50:00 AM: 7   6.3e-04  3.3e+02  5.0e-02  -9.99e-01  9.455825778e+03   7.884169511e+03   6.3e-04  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 8   1.7e-04  9.0e+01  2.6e-02  -9.99e-01  9.155019130e+04   8.576035475e+04   1.7e-04  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 9   1.0e-05  5.4e+00  6.4e-03  -9.97e-01  1.068711546e+06   9.733775073e+05   1.0e-05  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 10  5.0e-06  2.6e+00  4.4e-03  -9.95e-01  1.449409320e+06   1.252647855e+06   5.0e-06  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 11  1.7e-06  9.1e-01  2.6e-03  -9.85e-01  1.001732425e+07   9.472633405e+06   1.7e-06  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 12  4.2e-07  2.2e-01  1.3e-03  -9.71e-01  1.708644327e+07   1.478156036e+07   4.2e-07  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 13  4.4e-08  2.3e-02  4.0e-04  -9.91e-01  1.898620289e+08   1.692426877e+08   4.4e-08  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 14  9.7e-09  5.1e-03  1.7e-04  -9.24e-01  1.029521407e+09   9.549496746e+08   9.7e-09  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 15  3.9e-09  2.0e-03  6.0e-05  -4.64e-01  1.686150459e+09   1.625936468e+09   3.9e-09  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 16  2.3e-09  1.2e-03  3.4e-05  3.33e-02   2.003056288e+09   1.952261974e+09   2.3e-09  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 17  5.2e-10  2.7e-04  5.4e-06  3.26e-01   2.685683118e+09   2.664326403e+09   5.2e-10  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 18  2.6e-10  4.2e-05  3.7e-07  7.74e-01   2.931858881e+09   2.927835254e+09   8.0e-11  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 19  2.5e-10  4.0e-05  3.2e-07  9.45e-01   2.935162425e+09   2.931366043e+09   7.5e-11  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 20  1.5e-11  2.4e-06  1.8e-08  9.48e-01   2.986698162e+09   2.986446910e+09   4.5e-12  0.03  &#xA;(CVXPY) Feb 16 11:50:00 AM: 21  1.5e-11  2.4e-06  1.8e-08  9.48e-01   2.986698162e+09   2.986446910e+09   4.5e-12  0.04  &#xA;(CVXPY) Feb 16 11:50:00 AM: 22  1.5e-11  2.4e-06  1.8e-08  9.48e-01   2.986698162e+09   2.986446910e+09   4.5e-12  0.04  &#xA;(CVXPY) Feb 16 11:50:00 AM: Optimizer terminated. Time: 0.04    &#xA;(CVXPY) Feb 16 11:50:00 AM: &#xA;(CVXPY) Feb 16 11:50:00 AM: &#xA;(CVXPY) Feb 16 11:50:00 AM: Interior-point solution summary&#xA;(CVXPY) Feb 16 11:50:00 AM:   Problem status  : DUAL_INFEASIBLE&#xA;(CVXPY) Feb 16 11:50:00 AM:   Solution status : DUAL_INFEASIBLE_CER&#xA;(CVXPY) Feb 16 11:50:00 AM:   Primal.  obj: 1.2725221277e+01    nrm: 6e+00    Viol.  con: 9e-07    var: 0e+00    cones: 0e+00  &#xA;-------------------------------------------------------------------------------&#xA;                                    Summary                                    &#xA;-------------------------------------------------------------------------------&#xA;(CVXPY) Feb 16 11:50:00 AM: Problem status: infeasible&#xA;(CVXPY) Feb 16 11:50:00 AM: Optimal value: inf&#xA;(CVXPY) Feb 16 11:50:00 AM: Compilation took 1.420e-02 seconds&#xA;(CVXPY) Feb 16 11:50:00 AM: Solver (including time spent in interface) took 5.786e-02 seconds&#xA;Optimal value:  inf&#xA;Optimal x:  None&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What does it mean for the dual to be infeasible, and why can it be solved in SCS where MOSEK fails?&lt;/p&gt;&#xA;" OwnerUserId="11265" LastEditorUserId="8" LastEditDate="2023-02-17T13:31:40.457" LastActivityDate="2023-02-17T13:31:40.457" Title="Simple OLS problem can only be solved in SCS. Is the dual infeasible?" Tags="|solver|quadratic-programming|duality|cvxpy|mosek|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9943" PostTypeId="1" CreationDate="2023-02-16T06:29:26.113" Score="2" ViewCount="88" Body="&lt;p&gt;There is a field of modelling called &amp;quot;Survival Analysis&amp;quot; (&lt;a href=&quot;https://en.wikipedia.org/wiki/Survival_analysis&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Survival_analysis&lt;/a&gt;), in which the objective is to model the effect of different &amp;quot;characteristics&amp;quot; (e.g. medical measurements of patients such as height, age, weight, etc.) on the &amp;quot;time of some event&amp;quot; (e.g. death). Many models used in Survival Analysis are essentially a form of &amp;quot;Regression Models&amp;quot; (&lt;a href=&quot;https://en.wikipedia.org/wiki/Regression_analysis&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Regression_analysis&lt;/a&gt;)  - and of course, these models are built, train and fine tuned using some Optimization Algorithm (e.g. Newton-Raphson).&lt;/p&gt;&#xA;&lt;p&gt;One of the most popular types of models used in Survival Analysis is called the &amp;quot;Cox Proportional-Hazards&amp;quot; Model (&lt;a href=&quot;https://en.wikipedia.org/wiki/Proportional_hazards_model&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Proportional_hazards_model&lt;/a&gt;). As an example, here I have fit a Cox-PH Model to some dataset using the R programming language:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Call:&#xA;coxph(formula = Surv(time, status) ~ age + sex + ph.ecog, data = lung)&#xA;&#xA;             coef exp(coef)  se(coef)      z        p&#xA;age      0.011067  1.011128  0.009267  1.194 0.232416&#xA;sex     -0.552612  0.575445  0.167739 -3.294 0.000986&#xA;ph.ecog  0.463728  1.589991  0.113577  4.083 4.45e-05&#xA;&#xA;Likelihood ratio test=30.5  on 3 df, p=1.083e-06&#xA;n= 227, number of events= 164 &#xA;   (1 observation deleted due to missingness)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Based on these results, I can infer information such as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The number of observations&lt;/li&gt;&#xA;&lt;li&gt;The number of events&lt;/li&gt;&#xA;&lt;li&gt;The number of variables&lt;/li&gt;&#xA;&lt;li&gt;The estimate for the effect of each variable&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt; Given this information, is it possible to simulate the covariate and response information for n = 227 such observations - such that if a similar Cox-PH model was fit to these newly simulated 227 observations, the resulting regression coefficients would approximately be equal to the original regression coefficients? &lt;strong&gt;Can I try to &amp;quot;guess&amp;quot; (and recreate) a plausible set of observations might have been observed based on the regression model coefficients?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is where I thought that an Optimization Algorithm such as the Genetic Algorithm might be suitable. For example, below I tried to outline the pseudocode needed for such a problem:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use an algorithm like the Genetic Algorithm (&lt;a href=&quot;https://cran.r-project.org/web/packages/GA/vignettes/GA.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cran.r-project.org/web/packages/GA/vignettes/GA.html&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Step 0 : Set some plausible ranges for the covariates (e.g. age between 20 - 80, sex either male or female, ph.ecog between 0 and 5 &lt;a href=&quot;https://ecog-acrin.org/resources/ecog-performance-status/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ecog-acrin.org/resources/ecog-performance-status/&lt;/a&gt;) . Specify distributions for each of these variables (e.g. age ~ lognormal, sex ~ binom, ph.ecog ~ multinomial) and specify parameters for each of these distributions (e.g. lognormal(mu1, sigma1), binom(p1), etc)&lt;/li&gt;&#xA;&lt;li&gt;Step 1: Set some plausible range and distribution for the Survival Times (e.g. Exponential Distribution with Lambda = 5)&lt;/li&gt;&#xA;&lt;li&gt;Step 2: Simulate 227 random observations and randomly censor 164 of these observations&lt;/li&gt;&#xA;&lt;li&gt;Step 3: Fit a Cox PH model to this simulated data and record performance measurements such as the coefficients, standard errors, p-values, likelihood ratio test, etc&lt;/li&gt;&#xA;&lt;li&gt;Step 4: Calculate the squared difference between these performance measurements from the model with the simulated dataset vs the performance measurements from the model with the actual dataset - and then sum all these squared differences.&lt;/li&gt;&#xA;&lt;li&gt;Step 5: Repeat Step 1 - Step 4 many times (e.g. 1000 times)&lt;/li&gt;&#xA;&lt;li&gt;Step 6: Repeat Step 0 - 5 many times&lt;/li&gt;&#xA;&lt;li&gt;Step 7: Use the Genetic Algorithm to find out which covariate ranges and covariate distributions bring you closest to the performance measurements of the original model. In other words, the &amp;quot;summed squared difference&amp;quot; is the Objective Function you will be attempting to optimize using the Genetic Algorithm.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I know this is a very abstract and roundabout way that might not have any mathematical validity - &lt;strong&gt;but I was curious to know if such an application of the Genetic Algorithm might be logical?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Notes:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I realize there are probably an infinite number of n = 227 samples that can be randomly simulated such that a Cox-PH Model produces the same regression coefficient estimates as above.&lt;/li&gt;&#xA;&lt;li&gt;I realize that its entirely possible that I happen to simulate a dataset in which all the ages are concentrated around 20-25 years old when in fact the real age of the participants in this dataset were senior citizens - but based on the results of the other simulated variables, the resulting Cox-PH model produced using this simulated data might coincidentally have the same performance results as the original model - thus rendering this approach useless.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5971" LastEditorUserId="491" LastEditDate="2023-03-24T12:20:22.433" LastActivityDate="2023-03-24T12:20:22.433" Title="Using Optimization Algorithms to &quot;Guess&quot; the Dataset used to Train a Model?" Tags="|optimization|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9944" PostTypeId="2" ParentId="9942" CreationDate="2023-02-16T08:49:43.213" Score="6" Body="&lt;p&gt;Mosek does not fail. Mosek says the problem is dual infeasible which means if the problem has solution, then it is unbounded. In fact Mosek has a quite good certificate for that.&lt;/p&gt;&#xA;&lt;p&gt;Since your problem should not be dual infeasible my guess is your problem is ill conditioned. It seems the optimal objective value is very large.&lt;/p&gt;&#xA;&lt;p&gt;One way to get a better conditioned problem is to minimize the norm of&lt;/p&gt;&#xA;&lt;p&gt;A @ x - b&lt;/p&gt;&#xA;&lt;p&gt;instead of&lt;/p&gt;&#xA;&lt;p&gt;cp.sum_squares(A @ x - b)&lt;/p&gt;&#xA;&lt;p&gt;There is no benefit of the squaring unless your solver only can solve QPs.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2023-02-16T08:49:43.213" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9945" PostTypeId="1" CreationDate="2023-02-16T15:31:54.973" Score="0" ViewCount="60" Body="&lt;p&gt;I am new to the concept of robust optimization.I am trying to formulate the robust variation of a Binary Integer Program. Suppose we have a constraint of the form &lt;span class=&quot;math-container&quot;&gt;$\sum{x_{i,j}} \geq b_j$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$ i \in I, j \in J$&lt;/span&gt; with uncertainty in the rhs. We know that each value &lt;span class=&quot;math-container&quot;&gt;$b_j$&lt;/span&gt; is going to deviate in a known interval and we known that a specific number of rhs's will deviate (e.g. &lt;span class=&quot;math-container&quot;&gt;$\Gamma$&lt;/span&gt; uncertainty).&lt;/p&gt;&#xA;&lt;p&gt;According to what I researched about the work of Bertsimas and Sim, they consider uncertainty only in the lhs or in the objective and they propose a method to reformulate the uncertainty from the rhs in the lhs by introducing a new variable. Is someone away how to do that or whether is any useful research papers that would help me reformulate the problem and come up with the Robust formulation?&lt;/p&gt;&#xA;&#xA;" OwnerUserId="10707" LastEditorUserId="727" LastEditDate="2023-02-19T22:01:56.707" LastActivityDate="2023-02-19T22:01:56.707" Title="Gamma uncertainty in the RHS of a constraint" Tags="|linear-programming|integer-programming|reference-request|robust-optimization|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9946" PostTypeId="2" ParentId="9942" CreationDate="2023-02-16T22:36:16.437" Score="1" Body="&lt;p&gt;Also don't think the other_constraint is required. If first constraint &amp;amp; variable declaration constrain the following&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is non negative and &lt;span class=&quot;math-container&quot;&gt;$ \sum_i x_i = 1$&lt;/span&gt;. So all &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;s will be &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt;1 anyway.&lt;br /&gt;&#xA;Also have a look &lt;a href=&quot;https://stackoverflow.com/questions/46246349/infeasible-solution-for-an-lp-even-though-there-exists-feasible-solutionusing-c&quot;&gt;here&lt;/a&gt;. Seems scaling could be an issue.&lt;br /&gt;&#xA;Also even by SCS the minimization opt values seems pretty high. Hope you are minimizing norm of  &lt;span class=&quot;math-container&quot;&gt;$ A@x - y$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$A@x+b -y $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-16T22:48:58.723" LastActivityDate="2023-02-16T22:48:58.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9947" PostTypeId="1" AcceptedAnswerId="9949" CreationDate="2023-02-17T13:52:17.417" Score="2" ViewCount="325" Body="&lt;p&gt;I'm trying to implement a MINLP problem which is described in a previous post here: &lt;a href=&quot;https://or.stackexchange.com/questions/9938/how-do-we-formulate-a-problem-where-the-decision-variable-has-an-index-that-is-a/9941?noredirect=1#comment21139_9941&quot;&gt;How do we formulate a problem where the decision variable has an index that is also a decision variable?&lt;/a&gt;&#xA;The only change is that the objective function is different and is to be minimized instead of to be maximized (the function has changed but is given below for completeness).&lt;/p&gt;&#xA;&lt;p&gt;The problem is about minimizing a (nonlinear) objective function w.r.t. &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i=1}^N f(x_i, s_i, p_i),$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; are constants for each &lt;span class=&quot;math-container&quot;&gt;$i=1, 2, \dots, N$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is a decision variable, where &lt;span class=&quot;math-container&quot;&gt;$0 \le x_i &amp;lt; 1$&lt;/span&gt;. The function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$f(x_i, s_i, p_i) = p_is_i\frac{x_i^{0.135}-(1-x_i)^{0.135}}{0.1975}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We also have a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; and a continuous variable &lt;span class=&quot;math-container&quot;&gt;$a_j$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$0 \le a_j &amp;lt; 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j = 1, 2, 3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The constraints are the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} &#xA;\beta= \frac{\sum_{i=1}^N x_id_i}{\sum_{i=1}^N d_i},\tag1\label1 \\&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; is again a constant for each &lt;span class=&quot;math-container&quot;&gt;$i=1, 2, \dots, N$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; is a constant where &lt;span class=&quot;math-container&quot;&gt;$0 \le \beta &amp;lt; 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j y_{ij} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$}, \tag2\label2 \\&#xA;-(1 - y_{ij}) \le x_i - a_j &amp;amp;\le 1 - y_{ij} &amp;amp;&amp;amp;\text{for all $i$ and $j$}. \tag3\label3&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm implementing it in Pyomo as interface and I use mindtpy as a solver.&#xA;Here is the code I have implemented (note that I split up constraint &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;f = lambda x, s, p: ((x**0.135-(1-x)**0.135)/0.1975)*p*s&#xA;Beta = 0.96&#xA;model = ConcreteModel(name=&amp;quot;ORExchangeExample&amp;quot;)&#xA;&#xA;model.x = Var(N, bounds=(0.00, 0.9999), initialize = 0.50)&#xA;model.a = Var(J, bounds=(0.00, 0.9999), initialize = 0.50)&#xA;model.y = Var(N, J, domain=Binary, initialize=0)&#xA;&#xA;def obj_rule(model):&#xA;    return sum(f(model.x[n], s[n], p[n]) for n in N)&#xA;model.obj = Objective(rule=obj_rule, sense=minimize)&#xA;&#xA;def constraint_1(model):&#xA;    return sum(d[n]*model.x[n] for n in N) == Beta*(sum(d[n] for n in N))&#xA;model.constraint_1= Constraint(rule=constraint_1)&#xA;&#xA;def constraint_2(model, i):&#xA;    return sum(model.y[i, j] for j in J) == 1&#xA;model.constraint_2= Constraint(N, rule=constraint_2)&#xA;&#xA;def constraint_3(model, i, j):&#xA;    return -(1-model.y[i, j]) &amp;lt;= model.x[i]-model.a[j]&#xA;model.constraint_3= Constraint(N, J, rule=constraint_3)&#xA;&#xA;def constraint_4(model, i, j):&#xA;    return model.x[i]-model.a[j] &amp;lt;= 1-model.y[i, j]&#xA;model.constraint_4= Constraint(N, J, rule=constraint_4)&#xA;&#xA;solver.solve(model, tee=True, &#xA;                  mip_solver='glpk',&#xA;                  nlp_solver='ipopt',)&#xA;solver.solve(model)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The variable &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is a list containing &lt;span class=&quot;math-container&quot;&gt;$1, 2 , \dots, N$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; is also a list &lt;span class=&quot;math-container&quot;&gt;$ = [1, 2, 3]$&lt;/span&gt;.&#xA;The constant variables &lt;span class=&quot;math-container&quot;&gt;$p, s$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; are dictionaries with the elements of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; as keys and the actual values as values, for example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;p = {1: 19.06, 2: 4.0607, 3: 9.75, 4: 0.2716, ...}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I run this, it runs without errors but gives me back as a solution the initialized values for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;. So it doesn't solve it, because constraint (1) isn't met and the objective function is definitely not minimized. The result (in this code set up) will give [0.5, 0.5, ...] for all values of &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Am I missing something?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: I used the Ipopt as the nonlinear solver but still the same result. However, if I do it for a small sample (&lt;span class=&quot;math-container&quot;&gt;$N = 10$&lt;/span&gt;), then it all works fine...&lt;/p&gt;&#xA;&lt;p&gt;This is what the solver has to say, but I don't really know how to interpret this. In my data, &lt;span class=&quot;math-container&quot;&gt;$N = 4831$&lt;/span&gt;.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/8iFGY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8iFGY.png&quot; alt=&quot;Output Solver&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="500" LastEditDate="2023-02-17T16:43:00.800" LastActivityDate="2023-02-17T16:43:00.800" Title="Implementing a MINLP problem in Pyomo: giving an infeasible solution" Tags="|mixed-integer-programming|python|nonlinear-programming|pyomo|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="9948" PostTypeId="1" AcceptedAnswerId="9950" CreationDate="2023-02-17T14:59:10.957" Score="4" ViewCount="196" Body="&lt;p&gt;I want to solve the following optimization problem&lt;/p&gt;&#xA;&lt;p&gt;min &lt;span class=&quot;math-container&quot;&gt;$\|x\|_{\infty}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$Ax \ge b, x \ge 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a matrix with integer coefficients and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is a vector with integer coefficients.&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$\|x\|_{\infty} = \max\{|x_1|,\ldots,|x_n|\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What kind of software could I use for that.&lt;/p&gt;&#xA;" OwnerUserId="9655" LastActivityDate="2023-02-17T16:18:29.027" Title="Software for optimization problem" Tags="|optimization|software|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9949" PostTypeId="2" ParentId="9947" CreationDate="2023-02-17T15:11:21.627" Score="2" Body="&lt;p&gt;Try ipopt as the nonlinear solver. With ipopt I got the following solution from your code (with the following assumptions):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;12 Set Declarations&#xA;a_index : Size=1, Index=None, Ordered=Insertion&#xA;    Key  : Dimen : Domain : Size : Members&#xA;    None :     1 :    Any :    3 : {1, 2, 3}&#xA;constraint_2_index : Size=1, Index=None, Ordered=Insertion&#xA;    Key  : Dimen : Domain : Size : Members&#xA;    None :     1 :    Any :    2 : {1, 2}&#xA;constraint_3_index : Size=1, Index=None, Ordered=True&#xA;    Key  : Dimen : Domain                                    : Size : &#xA;Members&#xA;    None :     2 : constraint_3_index_0*constraint_3_index_1 :    6 : {(1, &#xA;1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3)}&#xA;constraint_3_index_0 : Size=1, Index=None, Ordered=Insertion&#xA;    Key  : Dimen : Domain : Size : Members&#xA;    None :     1 :    Any :    2 : {1, 2}&#xA;constraint_3_index_1 : Size=1, Index=None, Ordered=Insertion&#xA;    Key  : Dimen : Domain : Size : Members&#xA;    None :     1 :    Any :    3 : {1, 2, 3}&#xA;constraint_4_index : Size=1, Index=None, Ordered=True&#xA;    Key  : Dimen : Domain                                    : Size : &#xA;Members&#xA;    None :     2 : constraint_4_index_0*constraint_4_index_1 :    6 : {(1, &#xA;1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3)}&#xA;constraint_4_index_0 : Size=1, Index=None, Ordered=Insertion&#xA;    Key  : Dimen : Domain : Size : Members&#xA;    None :     1 :    Any :    2 : {1, 2}&#xA;constraint_4_index_1 : Size=1, Index=None, Ordered=Insertion&#xA;    Key  : Dimen : Domain : Size : Members&#xA;    None :     1 :    Any :    3 : {1, 2, 3}&#xA;x_index : Size=1, Index=None, Ordered=Insertion&#xA;    Key  : Dimen : Domain : Size : Members&#xA;    None :     1 :    Any :    2 : {1, 2}&#xA;y_index : Size=1, Index=None, Ordered=True&#xA;    Key  : Dimen : Domain              : Size : Members&#xA;    None :     2 : y_index_0*y_index_1 :    6 : {(1, 1), (1, 2), (1, 3), &#xA;(2, 1), (2, 2), (2, 3)}&#xA;y_index_0 : Size=1, Index=None, Ordered=Insertion&#xA;    Key  : Dimen : Domain : Size : Members&#xA;    None :     1 :    Any :    2 : {1, 2}&#xA;y_index_1 : Size=1, Index=None, Ordered=Insertion&#xA;    Key  : Dimen : Domain : Size : Members&#xA;    None :     1 :    Any :    3 : {1, 2, 3}&#xA;&#xA;3 Var Declarations&#xA;a : Size=3, Index=a_index&#xA;    Key : Lower : Value              : Upper  : Fixed : Stale : Domain&#xA;      1 :   0.0 : 0.7327896229031757 : 0.9999 : False : False :  Reals&#xA;      2 :   0.0 : 0.7327896229031757 : 0.9999 : False : False :  Reals&#xA;      3 :   0.0 : 0.7327896229031757 : 0.9999 : False : False :  Reals&#xA;x : Size=2, Index=x_index&#xA;    Key : Lower : Value              : Upper  : Fixed : Stale : Domain&#xA;      1 :   0.0 : 0.9788067730557521 : 0.9999 : False : False :  Reals&#xA;      2 :   0.0 :  0.950596613472124 : 0.9999 : False : False :  Reals&#xA;y : Size=6, Index=y_index&#xA;    Key    : Lower : Value               : Upper : Fixed : Stale : Domain&#xA;    (1, 1) :     0 : 0.33333333333333337 :     1 : False : False : Binary&#xA;    (1, 2) :     0 : 0.33333333333333337 :     1 : False : False : Binary&#xA;    (1, 3) :     0 : 0.33333333333333337 :     1 : False : False : Binary&#xA;    (2, 1) :     0 :  0.3333333333333333 :     1 : False : False : Binary&#xA;    (2, 2) :     0 :  0.3333333333333333 :     1 : False : False : Binary&#xA;    (2, 3) :     0 :  0.3333333333333333 :     1 : False : False : Binary&#xA;&#xA;1 Objective Declarations&#xA;obj : Size=1, Index=None, Active=True&#xA;    Key  : Active : Sense    : Expression&#xA;    None :   True : minimize : (x[1]**0.135 - (1 - x[1])**0.135)/0.1975 + &#xA;(x[2]**0.135 - (1 - x[2])**0.135)/0.1975*2*2&#xA;&#xA;4 Constraint Declarations&#xA;constraint_1 : Size=1, Index=None, Active=True&#xA;    Key  : Lower : Body          : Upper : Active&#xA;    None :  2.88 : x[1] + 2*x[2] :  2.88 :   True&#xA;constraint_2 : Size=2, Index=constraint_2_index, Active=True&#xA;    Key : Lower : Body                     : Upper : Active&#xA;      1 :   1.0 : y[1,1] + y[1,2] + y[1,3] :   1.0 :   True&#xA;      2 :   1.0 : y[2,1] + y[2,2] + y[2,3] :   1.0 :   True&#xA;constraint_3 : Size=6, Index=constraint_3_index, Active=True&#xA;    Key    : Lower : Body                           : Upper : Active&#xA;    (1, 1) :  -Inf : - (1 - y[1,1]) - (x[1] - a[1]) :   0.0 :   True&#xA;    (1, 2) :  -Inf : - (1 - y[1,2]) - (x[1] - a[2]) :   0.0 :   True&#xA;    (1, 3) :  -Inf : - (1 - y[1,3]) - (x[1] - a[3]) :   0.0 :   True&#xA;    (2, 1) :  -Inf : - (1 - y[2,1]) - (x[2] - a[1]) :   0.0 :   True&#xA;    (2, 2) :  -Inf : - (1 - y[2,2]) - (x[2] - a[2]) :   0.0 :   True&#xA;    (2, 3) :  -Inf : - (1 - y[2,3]) - (x[2] - a[3]) :   0.0 :   True&#xA;constraint_4 : Size=6, Index=constraint_4_index, Active=True&#xA;    Key    : Lower : Body                       : Upper : Active&#xA;    (1, 1) :  -Inf : x[1] - a[1] - (1 - y[1,1]) :   0.0 :   True&#xA;    (1, 2) :  -Inf : x[1] - a[2] - (1 - y[1,2]) :   0.0 :   True&#xA;    (1, 3) :  -Inf : x[1] - a[3] - (1 - y[1,3]) :   0.0 :   True&#xA;    (2, 1) :  -Inf : x[2] - a[1] - (1 - y[2,1]) :   0.0 :   True&#xA;    (2, 2) :  -Inf : x[2] - a[2] - (1 - y[2,2]) :   0.0 :   True&#xA;    (2, 3) :  -Inf : x[2] - a[3] - (1 - y[2,3]) :   0.0 :   True&#xA;&#xA;20 Declarations: x_index x a_index a y_index_0 y_index_1 y_index y obj             &#xA;constraint_1 constraint_2_index constraint_2 constraint_3_index_0 &#xA;constraint_3_index_1 constraint_3_index constraint_3 constraint_4_index_0 &#xA;constraint_4_index_1 constraint_4_index constraint_4&#xA;Objective value:  8.660160748261013&#xA;x[1] value is 0.978807&#xA;x[2] value is 0.950597&#xA;&#xA;Process finished with exit code 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Assumptions:&#xA;n_ = 3&#xA;N = list(range(1, n_))&#xA;J = [1, 2, 3]&#xA;s = {1:1, 2:2, 3:3}&#xA;p = {1:1, 2:2, 3:3}&#xA;d = {1:1, 2:2, 3:3}&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2023-02-17T15:11:21.627" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9950" PostTypeId="2" ParentId="9948" CreationDate="2023-02-17T15:20:19.910" Score="4" Body="&lt;p&gt;Ok any solver that supports LP can solve it like IPOPT, Gurobi, Cplex, SAS-OR (I think academic or free editions available on google colab). As for give problem its called minmax (minimize the maximum). Generally its like introduce a variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and add constraints to the existing ones with &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_i \le z$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$-x_i \le z \ \forall i$&lt;/span&gt;&lt;br /&gt;&#xA;Then min &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;BTW: &lt;a href=&quot;https://www.gurobi.com/documentation/current/refman/py_model_agc_abs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi&lt;/a&gt; and &lt;a href=&quot;https://go.documentation.sas.com/doc/en/pgmsascdc/v_036/casmopt/casmopt_optmodel_details57.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;SAS-OR&lt;/a&gt; has an in-built constraint to deal with abs. you wont need 2 constraints per &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. CPLEX will also have one.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-17T16:18:29.027" LastActivityDate="2023-02-17T16:18:29.027" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="9951" PostTypeId="1" AcceptedAnswerId="9952" CreationDate="2023-02-18T02:28:11.817" Score="2" ViewCount="149" Body="&lt;p&gt;I am working on a flexible job-shop scheduling problem, where indices are as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;: Index of operations&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;: Index of jobs&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;: Index of machines&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;: Index of operation sequences on a machine&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The decision variables of this model are defined as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ijmp} \in \{0, 1\}$&lt;/span&gt;: If operation &lt;span class=&quot;math-container&quot;&gt;$O_{ij}$&lt;/span&gt; is allocated to machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; with sequence &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, 1; otherwise, 0&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t_{ij} \geq 0$&lt;/span&gt;: Start time of operation &lt;span class=&quot;math-container&quot;&gt;$O_{ij}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t'_{pm} \geq 0$&lt;/span&gt;: Start time of machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; in sequence &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$S_{ij}$&lt;/span&gt; is the processing time of operation &lt;span class=&quot;math-container&quot;&gt;$O_{ij}$&lt;/span&gt; (a preset parameter). If &lt;span class=&quot;math-container&quot;&gt;$a_{lm} \geq 0$&lt;/span&gt;, I need constraint sets that specify:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{lm} = S_{ij}$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$\sum_{p} x_{ijmp} = 1$&lt;/span&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$l = t_{ij}$&lt;/span&gt; (or &lt;span class=&quot;math-container&quot;&gt;$a_{lm} = S_{ij}$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_{ijmp} = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$l = t'_{mp}$&lt;/span&gt;) &lt;span class=&quot;math-container&quot;&gt;$\forall l, m$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{lm} = 0$&lt;/span&gt; if (&lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j,p} x_{ijmp} = 0$&lt;/span&gt;) &lt;strong&gt;or&lt;/strong&gt; (&lt;span class=&quot;math-container&quot;&gt;$\sum_{p} x_{ijmp} = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$l \neq t_{ij}$&lt;/span&gt; for all operations) &lt;span class=&quot;math-container&quot;&gt;$\forall l, m$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Since the time set is large in my application (300+ time slots for real-sized instances), I think it might be better not to use a time-indexed formulation (i.e., &lt;span class=&quot;math-container&quot;&gt;$x_{ijmt}$&lt;/span&gt;). How do you efficiently formulate such a constraint set?&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="491" LastEditDate="2023-03-24T12:20:05.250" LastActivityDate="2023-04-05T07:31:00.310" Title="Efficient formulation of flexible job-shop scheduling constraints" Tags="|modeling|constraint|job-shop-scheduling|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9952" PostTypeId="2" ParentId="9951" CreationDate="2023-02-18T04:21:31.150" Score="2" Body="&lt;p&gt;Whether you need to index on time depends on what you are trying to achieve, what's your objective. If you are trying to work on constraints involving &lt;span class=&quot;math-container&quot;&gt;$a_{lm} $&lt;/span&gt; then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_l l\delta_{lij} =t_{ij}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_l \delta_{lij} =1 \ \ \forall i,j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; is time index.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_{ij}(\sum_p x_{ijmp}+\delta_{lij} -1) \le a_{lm} \le S_{ij}(\sum_p x_{ijmp}+\delta_{lij}-1) + TS_{ij}(1-\delta_{lij}) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a_{lm} \le S_{ij}\sum_{ijp}x_{ijmp}$&lt;/span&gt;&lt;br /&gt;&#xA;where T could be 300.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-18T04:37:07.960" LastActivityDate="2023-02-18T04:37:07.960" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9953" PostTypeId="1" CreationDate="2023-02-18T10:18:15.573" Score="2" ViewCount="57" Body="&lt;p&gt;I want to optimize the power flow in a low voltage grid, with respect to customer requests for electric vehicle (EV) charging, but also avoid grid overload (basically, the formulation can be seen in an &lt;a href=&quot;https://or.stackexchange.com/questions/8254/how-to-calm-down-optimizer&quot;&gt;older question from me&lt;/a&gt;). But now, I also want to include controllable electrical loads in the households (for example heat pump) in the optimization (where electric and thermal demand of the household always needs to be covered).&lt;/p&gt;&#xA;&lt;p&gt;As result I imagine things like: &amp;quot;the EV cannot charge right now, because the heat pump is running&amp;quot; or &amp;quot;there is enough energy in the thermal storage, so the heat pump does not have to run, the EV can be charged instead&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;These heatpumps can only run if a certain minimum electrical input can be realized (similar to &lt;a href=&quot;https://or.stackexchange.com/questions/9856/how-to-ensure-minimum-output-of-a-generator-else-zero-output-in-linear-program&quot;&gt;another question from me&lt;/a&gt;). This leads to binary variables in my problem formulation. And I have many households with a heat pump in the grid. And I consider many time steps. So I have many variables (and some of them binary).&lt;/p&gt;&#xA;&lt;p&gt;Now I have already seen that binary variables (only considering one household) drastically increase the time for solving the optimization model. However, I need to run the optimization in regular intervals (e.g. each minute would be super). This is impossible with all these binary variables.&lt;/p&gt;&#xA;&lt;p&gt;Now I have heard about metaheuristics (like particle swarm optimization, ant colony optimization, artificial bee colony and may more...). For example, I read &lt;a href=&quot;https://or.stackexchange.com/questions/709/are-metaheuristics-ever-practical-for-continuous-optimization?rq=1&quot;&gt;this question&lt;/a&gt;, but there aren't binary variables mentioned. It is always about continuous optimization (which sounds to me like binary variables are not allowed).&lt;/p&gt;&#xA;&lt;p&gt;So after a lot of background, finally &lt;strong&gt;my question:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Would it make sense, to consider using metaheuristics to solve my optimization problem? Or can you directly say: no, forget about it? Maybe there are other methods I haven heard of yet?&lt;/p&gt;&#xA;" OwnerUserId="9052" LastEditorUserId="2671" LastEditDate="2023-03-06T13:44:49.393" LastActivityDate="2023-03-06T13:44:49.393" Title="Is it useful to consider metaheuristics for power flow optimization involving binary variables?" Tags="|optimization|binary-variable|metaheuristics|runtime|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9954" PostTypeId="1" CreationDate="2023-02-18T15:35:07.930" Score="1" ViewCount="244" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;A theater center needs to select which shows to broadcast in one of its rooms for a given day. There are three options available: short films that last about 1 hour, movies that last about 2 hours, and operas that last about 4 hours.&lt;/p&gt;&#xA;&lt;p&gt;The room needs to be open from 8 a.m. to 6 p.m. and has a fixed cost of \$1,000. However, customers want it to stay open until 10 p.m. If the center closes at 6 p.m., it will cost \$700. If it closes at 7 p.m., the amount drops to $500. If it closes at 8 p.m., the cost will be \$400. If it closes at 9 p.m., the cost will be \$125 and \$100 if it closes at 10 p.m. These costs are in addition to the fixed cost.&lt;/p&gt;&#xA;&lt;p&gt;The cost of running each show depends on when it starts, with shows only able to start at the beginning of each hour (following table). The theater may choose to leave the room empty at a cost of \$100 per hour.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;&lt;/th&gt;&#xA;&lt;th&gt;Short films&lt;/th&gt;&#xA;&lt;th&gt;Movies&lt;/th&gt;&#xA;&lt;th&gt;Operas&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;8 a.m.&lt;/td&gt;&#xA;&lt;td&gt;50&lt;/td&gt;&#xA;&lt;td&gt;90&lt;/td&gt;&#xA;&lt;td&gt;150&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;9 a.m.&lt;/td&gt;&#xA;&lt;td&gt;50&lt;/td&gt;&#xA;&lt;td&gt;90&lt;/td&gt;&#xA;&lt;td&gt;190&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;10 a.m.&lt;/td&gt;&#xA;&lt;td&gt;50&lt;/td&gt;&#xA;&lt;td&gt;90&lt;/td&gt;&#xA;&lt;td&gt;175&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;11 a.m.&lt;/td&gt;&#xA;&lt;td&gt;50&lt;/td&gt;&#xA;&lt;td&gt;90&lt;/td&gt;&#xA;&lt;td&gt;200&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Noon&lt;/td&gt;&#xA;&lt;td&gt;110&lt;/td&gt;&#xA;&lt;td&gt;215&lt;/td&gt;&#xA;&lt;td&gt;380&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;1 p.m.&lt;/td&gt;&#xA;&lt;td&gt;110&lt;/td&gt;&#xA;&lt;td&gt;215&lt;/td&gt;&#xA;&lt;td&gt;380&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2 p.m.&lt;/td&gt;&#xA;&lt;td&gt;30&lt;/td&gt;&#xA;&lt;td&gt;120&lt;/td&gt;&#xA;&lt;td&gt;145&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3 p.m.&lt;/td&gt;&#xA;&lt;td&gt;30&lt;/td&gt;&#xA;&lt;td&gt;120&lt;/td&gt;&#xA;&lt;td&gt;125&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;4 p.m.&lt;/td&gt;&#xA;&lt;td&gt;30&lt;/td&gt;&#xA;&lt;td&gt;80&lt;/td&gt;&#xA;&lt;td&gt;160&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5 p.m.&lt;/td&gt;&#xA;&lt;td&gt;60&lt;/td&gt;&#xA;&lt;td&gt;80&lt;/td&gt;&#xA;&lt;td&gt;190&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;6 p.m.&lt;/td&gt;&#xA;&lt;td&gt;60&lt;/td&gt;&#xA;&lt;td&gt;80&lt;/td&gt;&#xA;&lt;td&gt;300&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;7 p.m.&lt;/td&gt;&#xA;&lt;td&gt;70&lt;/td&gt;&#xA;&lt;td&gt;90&lt;/td&gt;&#xA;&lt;td&gt;200&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;8 p.m.&lt;/td&gt;&#xA;&lt;td&gt;75&lt;/td&gt;&#xA;&lt;td&gt;95&lt;/td&gt;&#xA;&lt;td&gt;250&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;9 p.m.&lt;/td&gt;&#xA;&lt;td&gt;80&lt;/td&gt;&#xA;&lt;td&gt;100&lt;/td&gt;&#xA;&lt;td&gt;300&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;The center needs to determine its broadcast schedule so as to minimize its total cost.&lt;/p&gt;&#xA;&lt;p&gt;Possible answer:&lt;/p&gt;&#xA;&lt;p&gt;Indices:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s ∈ S = {f, m, o, n}$&lt;/span&gt;  Types of shows that can be shown: short film (f), movie (m), opera (o), and no shows(n)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t ∈ T = \{08:00, 09:00, …, 22:00\}$&lt;/span&gt;    Time of day the show can start or end&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(t, u) ∈ A$&lt;/span&gt;    Shows starting at time t and ending at time u&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$e ∈ E = \{19:00, …, 22:00\}$&lt;/span&gt;   Time of day the room can close&lt;/p&gt;&#xA;&lt;p&gt;Parameters:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$op_{st}$&lt;/span&gt;   Operating cost of broadcasting the type of show s at time of day t [$ per show]&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_e$&lt;/span&gt;   Closing costs at closing time e [$ per day]&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$fix$&lt;/span&gt;   Fixed costs of operating the room during one day [$ per day]&lt;/p&gt;&#xA;&lt;p&gt;Variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{stu}$&lt;/span&gt;   Indicator variable if type of show s started at time t and ended at time u&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Y_e$&lt;/span&gt;   Indicator variable if the room closes at time e&lt;/p&gt;&#xA;&lt;p&gt;Objective Function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min fix + ∑_{s∈S}∑_{(t,u)∈A} o_{st} X_{stu} + ∑_{e∈E} c_e Y_e$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints:&lt;/p&gt;&#xA;&lt;p&gt;Flow constraint – the room must have a continuous assignment of shows until closing time&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{s∈S}∑_{u:(t,u)∈A} X_{stu} - ∑_{s∈S}∑_{u:(u,t)∈A} X_{sut} = 0,  ∀ t ∈ T = {09:00, …, 18:00}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$∑_{s∈S}∑_{u:(8,u)∈A} X_{s8u} - ∑_{s∈S}∑_{u:(u,8)∈A} X_{su8} = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$∑_{s∈S}∑_{u:(e,u)∈A} X_{seu} - ∑_{s∈S}∑_{u:(u,e)∈A} X_{sue} + Y_e = 0,  ∀ e ∈ E$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Both variables are binary&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_stu ∈ \{0,1\},  ∀ (t,u)∈A, s∈S$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Y_e ∈ \{0,1\},  ∀ e ∈ E$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is it true? or it should be treated as integer programming problem with closing costs as fixed costs? If so, how we should write the link constraints for fixed costs associated with closing costs?&lt;/p&gt;&#xA;" OwnerUserId="10596" LastEditorUserId="123" LastEditDate="2023-02-18T16:00:18.303" LastActivityDate="2023-03-06T13:05:31.397" Title="multi-commodity flow vs integer programming" Tags="|modeling|integer-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9955" PostTypeId="1" CreationDate="2023-02-18T15:42:39.690" Score="1" ViewCount="95" Body="&lt;p&gt;I currently have a scheduling algorithm which computes an approximate solution, say S, for the nominal scenario of a given problem instance, say N. Given that N changes in a way and becomes infeasible, I want to reuse S and complement it in a way so that:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The method is able to compute a solution (by relaxing some of the constraints)&lt;/li&gt;&#xA;&lt;li&gt;The new solution violates a minimum amount of constraints.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The new problem essentially becomes the following: We have a set of tasks, each task with release time, deadline, duration, and a set of time slots. We can assign tasks to run in parallel and they are pre-emptible. Objective is to assign the tasks in a way that minimizes the total number of cores used.&lt;/p&gt;&#xA;&lt;p&gt;Is someone aware of such scheduling problem in the literature or any suggestions how to address it?&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="491" LastEditDate="2023-02-18T21:23:25.553" LastActivityDate="2023-02-18T21:23:25.553" Title="Scheduling tasks to minimize the total number of utilized cores" Tags="|linear-programming|reference-request|scheduling|robust-optimization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9956" PostTypeId="2" ParentId="9954" CreationDate="2023-02-18T16:53:28.227" Score="2" Body="&lt;p&gt;I am a bit confused about the 2nd constraint.&#xA;Nevertheless in the derived STU (combination of show type, start time, end time), exclude combinations like (o,16,19), (o,17,20)..(m,18,19) etc because these won' t fit.&#xA;Am not sure how you have chosen your (u,t) combinations, are these simply like (9,10) or (opera,9,13) depending upon show type?&#xA;If chosen by show type then &lt;span class=&quot;math-container&quot;&gt;$\{s,t,u=(t+1,t+2,t+4) \}$&lt;/span&gt; slots should depend upon the durations, otherwise if you schedule like &lt;span class=&quot;math-container&quot;&gt;$ (s,t,u=t+1)$&lt;/span&gt; you'd need another constraint with duration &lt;span class=&quot;math-container&quot;&gt;$d_s$&lt;/span&gt;. Like this you can avoid unnecessarily creating redundant vars &amp;amp; constraints (maybe your constraint 3 is trying to do that), good for model sizing. But choice is yours, whatever appears easy to work with.&lt;/p&gt;&#xA;&lt;p&gt;Assuming based on your first constraint &lt;span class=&quot;math-container&quot;&gt;$ u=t+1$&lt;/span&gt;&#xA;As for linking closing costs/fixed cost your objective is on track.&#xA;As for linking &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; &amp;amp; some additional constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_s x_{stu} = 1 \ \ \forall (t,u) \in A$&lt;/span&gt;: ensure only one show (movie,opera, short or no show at a particular time slot, t-u): to be used if your slots are like &lt;span class=&quot;math-container&quot;&gt;$(t, t+1)$&lt;/span&gt;  (1)&lt;/p&gt;&#xA;&lt;p&gt;Or the below 2 constraints ensures for each block based on show type there is no overlap and at least one show/no show is scheduled:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_s \sum_{u: (t,u)\in A}x_{stu} = 1 \ \forall t \in T$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_s \sum_{t: (t,u)\in A}x_{stu} = 1 \ \forall u \in T$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_e y_e = 1$&lt;/span&gt;: Select one closing time&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_s x_{s,t-1,u}+\sum_{k\lt t-1}x_{s,k,u} \le d_s x_{s,t,u} \ \ \forall (t,u) \in A \ \ \forall s \in S$&lt;/span&gt;&amp;quot; This ensures based on duration, time slots, if incrementing by 1 hour, are continuously assigned. Can be skipped if using blocks that are already dependent on show type.&lt;/p&gt;&#xA;&lt;p&gt;Not sure what you are trying with your last constraint. The below pair should be better&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{(t,u) \in A}\sum_s d_s x_{stu} -e \le My_e$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$e-\sum_{(t,u) \in A}\sum_s d_s x_{stu} \le M(1-y_e) \ \forall e \in E$&lt;/span&gt;&lt;br /&gt;&#xA;Ensure total of all shows across time slots end on the selected closing time, d_{s} is the duration for that show type (1-2-4), M could be simply 24&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="2671" LastEditDate="2023-03-06T13:05:31.397" LastActivityDate="2023-03-06T13:05:31.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9957" PostTypeId="2" ParentId="9955" CreationDate="2023-02-18T17:10:16.437" Score="1" Body="&lt;p&gt;It sounds like a job scheduling problem. So say set of Tasks, &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;, Time slots/cores &lt;span class=&quot;math-container&quot;&gt;$ T$&lt;/span&gt;. Define a continuous variable &lt;span class=&quot;math-container&quot;&gt;$ 0 \le x_{zt} \le 1$&lt;/span&gt; that tracks units of task &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; assigned to time slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Assuming each task can be broken down into smaller units and they must sum up to 1. &lt;br /&gt;&#xA;You may need a binary variable &lt;span class=&quot;math-container&quot;&gt;$ y_{z,t}$&lt;/span&gt; to track time slots alloted to task for the duration. And a continuous var &lt;span class=&quot;math-container&quot;&gt;$ \delta$&lt;/span&gt; to track maximum number of task units per time slot.&lt;/p&gt;&#xA;&lt;p&gt;Then constraints like&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_t x_{z,t} = 1 $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ y_{z,t} \le x_{z,t} \le My_{z,t}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_t y_{z,t} = D_z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&amp;lt;you can have additional constraints for release here. am putting whatever you've posted&amp;gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_z x_{z,t} \le \delta \ \ \forall t$&lt;/span&gt;: getting maximum of units in a time slot&lt;/p&gt;&#xA;&lt;p&gt;Then min &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-18T20:59:37.957" LastActivityDate="2023-02-18T20:59:37.957" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9958" PostTypeId="1" AcceptedAnswerId="9960" CreationDate="2023-02-19T10:39:28.010" Score="1" ViewCount="153" Body="&lt;p&gt;I am modelling an optimization problem that is described as follows:&lt;/p&gt;&#xA;&lt;p&gt;I would like to maximize audience for scheduling matches. There are &lt;em&gt;n&lt;/em&gt; eligible teams and &lt;em&gt;n/2&lt;/em&gt; different slots.&#xA;Teams will only play once.&#xA;The audience of each possible match is known.&#xA;Each slot has also a known audience reduction coefficient. To penalize audience for not being close to prime time.&lt;/p&gt;&#xA;&lt;p&gt;Finally, in each slot you can schedule all the matches that you want knowing that the more matches scheduled in the same slot the more the audience is reduced. For example, 1 game in one slot the audience reduction is 0, for 2 games in one slot the reduction is 30%, an for 3 games in one slot the reduct is 50%...etc. This reduction applies to each match scheduled in the slot.&lt;/p&gt;&#xA;&lt;p&gt;I am able to set-up objective function and all restrictions except for the last part of simulteaneity. I feel like it is needed to know in advance how much games are scheduled in each specific slot.&lt;/p&gt;&#xA;" OwnerUserId="11294" LastEditorUserId="491" LastEditDate="2023-02-21T15:01:45.627" LastActivityDate="2023-02-21T15:01:45.627" Title="Mixed Integer Programming - How to model objective function with variables that depends on the solution?" Tags="|optimization|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="0" ClosedDate="2023-03-05T22:34:06.420" ContentLicense="CC BY-SA 4.0" />
  <row Id="9959" PostTypeId="1" CreationDate="2023-02-19T12:03:36.857" Score="5" ViewCount="604" Body="&lt;p&gt;I'm new to the branch and price algorithm. Though I have some knowledge about how branch &amp;amp; bound and column generation work, there're still some details making me confused.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;In short, my problem is:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;After branching, where do the columns of child node come from before new column being added by sub-problem?&lt;/li&gt;&#xA;&lt;li&gt;Are they obtained by inheritance of the columns in restricted master problem of parent node which is solved to optimality?&lt;/li&gt;&#xA;&lt;li&gt;If so, there must be some inherited columns violating the branching rule, what should we do with these columns in conflict? Are they directly removed?&lt;/li&gt;&#xA;&lt;li&gt;What if the model becomes infeasible after the removal of these conflicting columns?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Take bin packing problem as an example:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Suppose we have &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; items need to be packed. And the formulation based on Dantzig-Wolfe decomposition should be a set covering model:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_j x_j$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$s.t.\, \sum_j a_{ij}x_j \geq 1, \,\,\,\,i=1,2,3,4$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt; is a binary indicator specifying whether item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is packed in bin &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; is the decision variable to indicate whether bin &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; appears in the solution.&lt;/p&gt;&#xA;&lt;p&gt;Let's say we are in a situation where the RMP(restricted master problem) of &lt;strong&gt;Node 0&lt;/strong&gt; is solved to optimality by column generation. At this time, say the RMP is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{pmatrix}1\\0\\1\\1\end{pmatrix}x_1+\begin{pmatrix}1\\1\\0\\0\end{pmatrix}x_2+\begin{pmatrix}0\\0\\0\\1\end{pmatrix}x_3 \geq \begin{pmatrix}1\\1\\1\\1\end{pmatrix}$$&lt;/span&gt;&#xA;Then &lt;strong&gt;Node 0&lt;/strong&gt; is branching to two nodes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Node 1&lt;/strong&gt; with constraint: let's say item &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and item &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; cannot be in the same bin.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Node 2&lt;/strong&gt; with constraint: let's say item &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and item &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; should be in the same bin.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Then, in &lt;strong&gt;Node 1&lt;/strong&gt;, if the answers to my problem 2,3 are &lt;strong&gt;yes&lt;/strong&gt;, the RMP of &lt;strong&gt;Node 1&lt;/strong&gt; should be &lt;span class=&quot;math-container&quot;&gt;$$\begin{pmatrix}1\\0\\1\\1\end{pmatrix}x_1+\begin{pmatrix}0\\0\\0\\1\end{pmatrix}x_3 \geq \begin{pmatrix}1\\1\\1\\1\end{pmatrix}$$&lt;/span&gt;&#xA;since the coefficients of &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; put item &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and item &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; together, thus should be removed.&lt;/p&gt;&#xA;&lt;p&gt;However, the RMP of &lt;strong&gt;Node 1&lt;/strong&gt; is infeasible now, which means it cannot be iterated by column generation.&lt;/p&gt;&#xA;&lt;p&gt;And I'm at a loss what to do at this stage.&lt;/p&gt;&#xA;" OwnerUserId="11293" LastActivityDate="2023-02-20T10:13:53.430" Title="Puzzles of branch and price algorithm" Tags="|branch-and-price|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9960" PostTypeId="2" ParentId="9958" CreationDate="2023-02-19T12:57:30.067" Score="1" Body="&lt;p&gt;Ok not sure how you are taking your decision variables like is a game represented by variable &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; or team set like &lt;span class=&quot;math-container&quot;&gt;$(t_i,t_j)$&lt;/span&gt;. Since main problem is to model the audience reduction, you may either model a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{g,s} =1$&lt;/span&gt;  if game &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is assigned to slot &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; or an integer &lt;span class=&quot;math-container&quot;&gt;$x_{s}$&lt;/span&gt;&lt;br /&gt;&#xA;You may have a list or dictionary like &lt;span class=&quot;math-container&quot;&gt;$P=\{p_2,p_2,p_3,...\}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$p_k$&lt;/span&gt; is the reduction penalty for assigning 1,2,3,... games in a slot.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{k=1}^P kz_{k,s} = \sum_g x_{g,s} \ \ \forall s\in$&lt;/span&gt; slots  (1)&lt;br /&gt;&#xA;or&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{k=1}^P kz_{k,s} = x_{s}$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x_{s}$&lt;/span&gt; is an integer variable.  (2)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_k z_{k,s} =1 \ \ \forall s$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$z_{k,s}$&lt;/span&gt; is a binary.  (3)&lt;/p&gt;&#xA;&lt;p&gt;Then in the objective (if it's part of) use&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_s\sum_kz_{k,s}p_k$&lt;/span&gt; or for some other constraint use &lt;span class=&quot;math-container&quot;&gt;$\sum_kz_{k,s}p_k \ \ \forall s$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-19T13:48:51.770" LastActivityDate="2023-02-19T13:48:51.770" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9961" PostTypeId="1" CreationDate="2023-02-19T13:09:59.887" Score="2" ViewCount="36" Body="&lt;p&gt;I am relatively new to the concept of recoverable robustness. I am researching the robust version of an optimization problem. I currently have methods to address the problem with perfect knowledge. However, at the point of uncertainty realisation, there are a couple of scenarios that might affect the true solution:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The objective value can become worse&lt;/li&gt;&#xA;&lt;li&gt;The objective value can become better&lt;/li&gt;&#xA;&lt;li&gt;The algorithm might not be able to find a feasible solution.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;From my understanding, I should be able to re-use my algorithms with perfect knowledge and &amp;quot;fix&amp;quot; the produced solution so it produces the minimum amount of constraint violations and an objective value that is close to the optimal. How should one approach analysing the results produced from the uncertainty sets? Is that conceptually correct? Is someone aware of common recovery methods/strategies that can be used? (I presume one should not only rely on integer/linear programs to compute those.) I would appreciate if someone points me to some good literature on the topic.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;A side note:&lt;/strong&gt; Two other approaches I am considering:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Modify the algorithms by relaxing constraints to produce a solution that can be used as a starting basis for a recovery.&lt;/li&gt;&#xA;&lt;li&gt;Use a more involved single algorithm. (I was unsure about this one as the literature suggests the algorithms with perfect knowledge should be able to produce a good enough solution that can be &amp;quot;fixed&amp;quot;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10707" LastActivityDate="2023-02-19T13:09:59.887" Title="Recoverable Robustness for an optimization problem" Tags="|optimization|linear-programming|integer-programming|reference-request|robust-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9962" PostTypeId="2" ParentId="9959" CreationDate="2023-02-19T14:45:44.157" Score="4" Body="&lt;p&gt;The columns of the child can be initialized by the subset of columns of the parent that also satisfy the branching conditions. For each child node, you would perform column generation to solve the node to optimality. If the inherited columns already yield a feasible solution to the restricted master for that node, you can skip phase 1. Otherwise, you need to do both phases.  In short, each node has its own column generation problem, and you can initialize with any set of columns that are feasible to that node.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-02-19T14:45:44.157" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9963" PostTypeId="2" ParentId="9959" CreationDate="2023-02-19T14:49:04.193" Score="5" Body="&lt;p&gt;At each node, you need to ensure that the initial LP is feasible. For example, for the Bin Packing problem, you can add a column for each item or group of items that must be in the same bin corresponding to packing these items alone in a bin.&lt;/p&gt;&#xA;&lt;p&gt;It is possible to speed up the column generation at the non-root nodes by adding previously computed columns &lt;strong&gt;which are still feasible&lt;/strong&gt; for the node subproblem.&lt;/p&gt;&#xA;&lt;p&gt;In general, the bottleneck of a branch-and-price is the pricing problem, and not the LP solves. But for the Bin Packing problem, it might not be the case, since the subproblem is quite easy. If the bottleneck is the LP solves, it might not be worth adding all the previously computed columns which are feasible, but only a subset of those. For example, only those found at the root node, or only the last ones found at the root node, or only the ones which are active in the root node solution.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-02-19T14:49:04.193" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9964" PostTypeId="1" AcceptedAnswerId="9980" CreationDate="2023-02-19T17:13:14.467" Score="2" ViewCount="1676" Body="&lt;p&gt;I am relatively new to the topic of optimization. I am currently trying to address the following problem:&lt;/p&gt;&#xA;&lt;p&gt;We are given a set of jobs, say &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; with release times, deadlines and duration. Jobs can be pre-empted and also can be scheduled to run in parallel on different machines with the only constraint that a unit of a given job (from its duration) cannot be proccessed at the same time on 2 different machines. Objective is to find the minimum amount of machines required for a feasible schedule to be possible (not the schedule itself).&lt;/p&gt;&#xA;&lt;p&gt;I am seeking a polynomial time solution. Is someone aware of such problem in the literature?&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="10707" LastEditDate="2023-02-19T17:46:48.283" LastActivityDate="2023-02-21T18:56:19.187" Title="Identifying the minimum number of required machines to schedule jobs" Tags="|optimization|linear-programming|reference-request|scheduling|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9965" PostTypeId="1" AcceptedAnswerId="9968" CreationDate="2023-02-19T17:58:48.200" Score="-2" ViewCount="75" Body="&lt;p&gt;I am trying to model and solve a problem for maximize audience of matches that must be scheduled in different slots (I am using python PulP library). Below I explain the problem and the model process I followed:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Maximize audience of 20 teams in 10 slots. Those teams belongs to 3 different categories. Matrix is given for the audience where rows and columns are the categories and contains the audience value. My model is based on binary decision variable as follows:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;match_slot = [(team1, team2, slot) for team1 in range(20) for team2 in range(20) for slot in range(10)]&#xA;&#xA;var_match_slot = pulp.LpVariable.dicts(&amp;quot;var_partido_horario&amp;quot;, match_slot, 0, 1, cat=pulp.LpBinary)&#xA;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each slot has a reduction of audience given by:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;penalty_slot = [0.4,0.55,0.7,0.8,1,0.45,0.75,0.85,1,0.4]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Restrictions were added for :Teams only play once, they cannot play against themselves and they have to play in first and last slot minimum one match&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;for team in range(20):&#xA;&#xA;    model += pulp.lpSum([var_match_slot[team,team2,slot] + var_match_slot[team2,team,slot] for team2 in range(20) for slot in range(10)]) == 1&#xA;&#xA;&#xA;for team in range(20):&#xA;&#xA;    model += pulp.lpSum([var_match_slot[team,team,slot]  for slot in range(10)]) == 0&#xA;&#xA;model += pulp.lpSum([var_match_slot[team1, team2, 0] for team1 in range (20) for team2 in range (20)]) &amp;gt;=1&#xA;model += pulp.lpSum([var_match_slot[team1, team2, 9] for team1 in range (20) for team2 in range (20)]) &amp;gt;=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After my objective function to maximize audience looks like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model += pulp.lpSum([var_match_slot[(team1, team2, slot)] *audience[category[team1]][category[team2]]*penalty_slot[slot] for team1 in range(20) for team2 in range(20) for slot in range(10)])&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This implementation works but &lt;strong&gt;I need to add a reduction of audience due to how many games are scheduled  in same slot following the dictionary:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;penalty_coincidence = {0:1, 1:1, 2:0.75,3:0.55,4:0.4,5:0.30,6:0.25,7:0.23,8:0.02,9:0.02}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried to add a new integer decision variable to count number of matches and then use the value to index this dictionary which will be added as factor in objective function. That does not work or I have a problem in my implementation.&lt;/p&gt;&#xA;" OwnerUserId="11294" LastEditorUserId="491" LastEditDate="2023-02-21T15:01:26.087" LastActivityDate="2023-03-06T12:19:58.583" Title="Mixed Integer programming - Problem modelling coincidence restriction in scheduling match problem" Tags="|mixed-integer-programming|linear-programming|pulp|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9966" PostTypeId="2" ParentId="8635" CreationDate="2023-02-19T18:15:48.493" Score="1" Body="&lt;p&gt;Not sure why this question was abandoned but I'll give it a try:&lt;br /&gt;&#xA;Two vars: binary &lt;span class=&quot;math-container&quot;&gt;$x_{e,s,d}=1$&lt;/span&gt; if employee &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; alloted to shift &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; &amp;amp; another binary &lt;span class=&quot;math-container&quot;&gt;$o_{e,d} = 1$&lt;/span&gt; if off for day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; per week, else 0&lt;br /&gt;&#xA;Constraints:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_e x_{e,s,d} = 1 \ \ \forall s, d$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_s x_{e,s,d} + o_{e,d} \le 1 \ \ \forall e, d$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ 3 \le \sum_{k=d}^{d+6\mod 7} o_{e,k} \le 7 \ \forall d \ \forall e$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$  \sum_{k=d}^{d+6\mod 7} x_{e,s,k}\le 4 \ \ \forall d\ \forall s \ \forall e$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-20T03:59:53.767" LastActivityDate="2023-02-20T03:59:53.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9967" PostTypeId="2" ParentId="9964" CreationDate="2023-02-19T18:18:34.943" Score="2" Body="&lt;p&gt;If the number of machines is fixed, determining if there is a feasible schedule under the conditions you described is NP-hard. Therefore, it's unlikely that there exists a polynomial exact algorithm.&lt;/p&gt;&#xA;&lt;p&gt;I'm not aware of many polynomial algorithms for scheduling problems with preemption in general in the literature.&lt;/p&gt;&#xA;&lt;p&gt;At first glance, I would try a binary search on the number of machines, and use a greedy algorithm to search for a feasible schedule with a fixed number of machines.&lt;/p&gt;&#xA;&lt;p&gt;The greedy algorithm could look like:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For each job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For each machine &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Schedule as much as possible of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-02-19T18:18:34.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9968" PostTypeId="2" ParentId="9965" CreationDate="2023-02-19T18:51:22.100" Score="1" Body="&lt;p&gt;Try this: (I don't know PuLP very well).&#xA;I am assuming you have already built possible combinations like (team_1,Team_2, 0), (team_1,team_3,0),(team_1,team_3,1)... This is generally useful so that you can eliminate creating redundant variables like (Team1, Team1,0)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;slot =[*range(10)]&#xA;idx = [*range(10)] #Assuming max 9 games can be scheduled in one slot&#xA;z = pulp.LpVariable.dicts(&amp;quot;z&amp;quot;, idx,slot, 0, 1, cat=pulp.LpBinary)&#xA;for s in slot:&#xA;    model += pulp.lpsum(k*z[k,s] for k in idx) = lpsum(var_match_slot[(team, team, s)] for team in teams) # &lt;span class=&quot;math-container&quot;&gt;$ \sum_k kz_{k,s} = \sum_{(t1,t2)\in teams}x_{t1,t2,s}$&lt;/span&gt;&#xA;    model += pulp.lpsum(z[k,s] for k in idx) = 1# &lt;span class=&quot;math-container&quot;&gt;$\sum_k z_{k,s} = 1$&lt;/span&gt;&#xA;    &#xA;# Objective #&lt;span class=&quot;math-container&quot;&gt;$ \sum_k z_{k,s}penalty_slot[k]$&lt;/span&gt;&#xA;model += pulp.lpSum(z[k,s]*penalty_slot[k] for k in penalty_slot for slot in range(10)])&#xA;# or&#xA;model += pulp.lpSum(z[k,s]*penalty_slot[k] for k in idx for slot in range(10)])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="2671" LastEditDate="2023-03-06T12:19:58.583" LastActivityDate="2023-03-06T12:19:58.583" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9969" PostTypeId="2" ParentId="9959" CreationDate="2023-02-20T10:13:53.430" Score="3" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;After branching, where do the columns of child node come from before new column being added by sub-problem?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It is very common to use previously generated columns because they could both be of high quality and not in violation of any branching rule at the child node.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Are they obtained by inheritance of the columns in restricted master problem of parent node which is solved to optimality?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is one possibility, but not the only one.&#xA;Indeed, columns generated in a completely different part of the branch-and-bound tree could still prove useful in your child node, and you don't want to generate them again.&#xA;A common approach is to keep a global column pool.&#xA;All explored nodes add new columns to this column pool.&#xA;Each node keeps a list of column indices which are &lt;strong&gt;not&lt;/strong&gt; compatible with it because they violate some branching constraint.&#xA;A new child node would inherit this list from its parent node, and add new indices which are not compatible with the new branching rule which generated the child node.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If so, there must be some inherited columns violating the branching rule, what should we do with these columns in conflict? Are they directly removed?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In the approach I propose above, the columns are not removed but rather &amp;quot;blacklisted&amp;quot; from that particular child node because they violate the branching rule.&#xA;Depending on many considerations (how fast it is to solve the pricing problem vs. the master problem, how many columns you are generating, etc.) you might decide that your column pool is growing too big.&#xA;A big column pool means that the LP solved at each node might be slow to solve.&#xA;In that case, you can establish rules for columns to &lt;strong&gt;exit&lt;/strong&gt; the column pool.&#xA;For example, for each column, you could store the sequential B&amp;amp;B node id of the last node in which the column was active.&#xA;If the column has been inactive for too long, then you might want to remove it from the column pool.&#xA;However, I would only implement such an exit criterion if I had proof or a strong suspicion that the column pool size is becoming a hindrance to the performance of the algorithm.&#xA;I would start without such a mechanism.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;What if the model becomes infeasible after the removal of these conflicting columns?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This could happen.&#xA;Even at the root node, how do you initialise the restricted set of columns to ensure feasibility?&#xA;There is no universal answer to this because finding a feasible set of columns could be trivial for some problems and extremely hard for others.&#xA;A possible approach is to initialise the column pool with a single &amp;quot;dummy&amp;quot; column.&#xA;Such a column should have a huge penalty in the objective function, but its coefficients in the constraints matrix should be such that this single column makes all constraints satisfied.&#xA;For example, in your bin packing problem, you could add an initial column with index &lt;span class=&quot;math-container&quot;&gt;$j=0$&lt;/span&gt;.&#xA;You would give this column a large cost in the objective function (something like &lt;span class=&quot;math-container&quot;&gt;$\min \; 10^9 x_0 + \sum_{j &amp;gt; 0} x_j$&lt;/span&gt;).&#xA;You would also set the coefficients &lt;span class=&quot;math-container&quot;&gt;$a_{i0} = 1 \; \forall i$&lt;/span&gt;.&#xA;If &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; was a &amp;quot;real&amp;quot; column, it would correspond to a single knapsack in which you pack all objects.&#xA;(Unless your problem is trivial, this solution will violate the knapsack capacity constraint.)&#xA;Adding &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; to the column pool ensures that the problem is always feasible.&lt;/p&gt;&#xA;&lt;p&gt;However, there are a few things you should keep in mind.&#xA;First, column &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; shall never be removed from the column pool and shall never be blacklisted by any branching rule.&#xA;Second, any optimal solution to the continuous relaxation of your problem which selects column &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x_0 &amp;gt; 0$&lt;/span&gt; is, in reality, an infeasible solution.&#xA;Therefore, if a child node has &lt;span class=&quot;math-container&quot;&gt;$x_0 &amp;gt; 0$&lt;/span&gt; in its optimal solution, then that child node is infeasible.&#xA;If &lt;span class=&quot;math-container&quot;&gt;$x_0 &amp;gt; 0$&lt;/span&gt; at the root node, then the entire problem is infeasible.&lt;/p&gt;&#xA;&lt;p&gt;Even when you use a dummy column because you cannot ensure that you will have a feasible set of columns, you should strive to add as many good columns as possible to your initial column pool.&#xA;If you don't, it is likely that the dual of the continuous relaxation of your problem will be degenerate.&#xA;In such a case, LP solvers will most likely return dual values corresponding to an optimal vertex of the dual polytope.&#xA;In this case, you have all the duals &amp;quot;accumulate&amp;quot; in one of the dual variables and be 0 in all others.&#xA;This leads to pricing subproblems which will yield new columns of &amp;quot;low quality&amp;quot;, in the sense that they are unlikely to be selected in the optimal integer solution of the master problem.&#xA;In your bin packing example, if you call &lt;span class=&quot;math-container&quot;&gt;$\lambda_i$&lt;/span&gt; your dual variables, you might have &lt;span class=&quot;math-container&quot;&gt;$\lambda_1 = M$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a large number) and &lt;span class=&quot;math-container&quot;&gt;$\lambda_i = 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i &amp;gt; 1$&lt;/span&gt;.&#xA;Such dual values are quite uninformative when it comes to generating good columns in the subproblem.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2023-02-20T10:13:53.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9970" PostTypeId="1" AcceptedAnswerId="9971" CreationDate="2023-02-20T11:37:27.663" Score="3" ViewCount="187" Body="&lt;p&gt;I'm trying to model the following MINLP problem in Pyomo.&lt;/p&gt;&#xA;&lt;p&gt;We are trying to minimize a nonlinear objective function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$x_i \in \lbrace{0, 1, 2\rbrace}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i= 1, 2, \dots, N$&lt;/span&gt; and subject to a constraint involving &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;. Then, &lt;span class=&quot;math-container&quot;&gt;$a_j \in \lbrace{a_0, a_1, a_2\rbrace}$&lt;/span&gt; is a fixed set where &lt;span class=&quot;math-container&quot;&gt;$0 \le a_0, a_1, a_2 &amp;lt; 1$&lt;/span&gt; and the problem can be described as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min f(a_{x_i}, s_i, p_i),$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\beta = \frac{\sum_{i=1}^N d_ia_{x_i}}{\sum_{i=1}^N d_i},$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$d_i, p_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; are constants for each &lt;span class=&quot;math-container&quot;&gt;$i=1, 2, \dots, N$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; is a fixed number where &lt;span class=&quot;math-container&quot;&gt;$0 \le \beta &amp;lt; 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The function &lt;span class=&quot;math-container&quot;&gt;$f(a_{x_i}, s_i, p_i)$&lt;/span&gt; is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$p_is_i\frac{a_{x_i}^{0.135}-(1-a_{x_i})^{0.135}}{0.1975}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is an example of the code I had at first:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;f = lambda x, s, p: ((x**0.135-(1-x)**0.135)/0.1975)*p*s&#xA;Beta = 0.96&#xA;N = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]&#xA;a = [0.98, 0.95, 0.90]&#xA;p = {1: 2.1, 2: 3.4, 3: 1.7, 4: 2.4, 5: 5.3, 6: 0.8, 7: 8.8, 8: 4.9, 9: 10.6, 10: 3.2}&#xA;d = {1: 1000, 2: 870, 3: 500, 4: 480, 5: 370, 6: 325, 7: 280, 8: 190, 9: 145, 10: 115}&#xA;s = {1: 25, 2: 36, 3: 17, 4: 14, 5: 46, 6: 14, 7: 56, 8: 11, 9: 8, 10: 13}&#xA;model = ConcreteModel(name=&amp;quot;SLDIFF&amp;quot;)&#xA;model.x = Var(N, bounds=(0, 2), domain=NonNegativeIntegers, initialize=0)&#xA;def obj_rule(model):&#xA;    return sum(f(a[model.x[n]], s[n], p[n]) for n in N)&#xA;model.obj = Objective(rule=obj_rule, sense=minimize)&#xA;def constraint(model):&#xA;    return sum(d[n]*a[model.x[n]] for n in N) == Beta*(sum(d[n] for n in N))&#xA;model.constraint = Constraint(rule=constraint)&#xA;solver = SolverFactory('mindtpy')&#xA;solver.solve(model, mip_solver = 'glpk', nlp_solver='ipopt')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, Pyomo doesn't allow this. It gives the TypeError: list indices must be integers or slices, not _GeneralVarData.&lt;/p&gt;&#xA;&lt;p&gt;My first thought was to adjust 'model.x[n]' to 'value(model.x[n])':&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;f = lambda x, s, p: ((x**0.135-(1-x)**0.135)/0.1975)*p*s&#xA;Beta = 0.96&#xA;N = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]&#xA;a = [0.98, 0.95, 0.90]&#xA;p = {1: 2.1, 2: 3.4, 3: 1.7, 4: 2.4, 5: 5.3, 6: 0.8, 7: 8.8, 8: 4.9, 9: 10.6, 10: 3.2}&#xA;d = {1: 1000, 2: 870, 3: 500, 4: 480, 5: 370, 6: 325, 7: 280, 8: 190, 9: 145, 10: 115}&#xA;s = {1: 25, 2: 36, 3: 17, 4: 14, 5: 46, 6: 14, 7: 56, 8: 11, 9: 8, 10: 13}&#xA;model = ConcreteModel(name=&amp;quot;SLDIFF&amp;quot;)&#xA;model.x = Var(N, bounds=(0, 2), domain=NonNegativeIntegers, initialize=0)&#xA;def obj_rule(model):&#xA;    return sum(f(a[value(model.x[n])], s[n], p[n]) for n in N)&#xA;model.obj = Objective(rule=obj_rule, sense=minimize)&#xA;def constraint(model):&#xA;    return sum(d[n]*a[value(model.x[n])] for n in N) == Beta*(sum(d[n] for n in N))&#xA;model.constraint = Constraint(rule=constraint)&#xA;solver = SolverFactory('mindtpy')&#xA;solver.solve(model, mip_solver = 'glpk', nlp_solver='ipopt')&#xA;print([value(model.x[key]) for key in model.x])&#xA;print(value(model.obj))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But then it gives an error when trying to build the constraint:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ValueError: Invalid constraint expression. The constraint expression resolved to a trivial &#xA;Boolean (False) instead of a Pyomo object. Please modify your rule to return &#xA;Constraint.Infeasible instead of False.&#xA;&#xA;Error thrown for Constraint 'constraint'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I don't see how this expression is invalid? Anyone experience with this error and how to solve it?&lt;/p&gt;&#xA;" OwnerUserId="329" LastActivityDate="2023-02-20T13:04:52.610" Title="Modelling a decision variable as an index of a (fixed) set" Tags="|mixed-integer-programming|nonlinear-programming|pyomo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9971" PostTypeId="2" ParentId="9970" CreationDate="2023-02-20T12:04:57.107" Score="3" Body="&lt;p&gt;You can't use a decision variable &lt;code&gt;x[n]&lt;/code&gt; as an index in &lt;code&gt;a[x[n]]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Say you want&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;y = a[x] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Instead of that, introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$\delta_i$&lt;/span&gt; and do:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;&amp;amp;y = \sum_i a_i \cdot\delta_i \\ &#xA;&amp;amp;x = \sum_i i\cdot \delta_i \\&#xA;&amp;amp;\sum_i  \delta_i = 1 \\&#xA;&amp;amp;\delta_i \in  \{0,1\}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;This is now completely linear.&lt;/p&gt;&#xA;&lt;p&gt;Or use a solver or tool that can handle the so-called &lt;strong&gt;element constraint&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2023-02-20T13:04:52.610" LastActivityDate="2023-02-20T13:04:52.610" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="9972" PostTypeId="1" AcceptedAnswerId="9975" CreationDate="2023-02-20T15:26:59.977" Score="2" ViewCount="128" Body="&lt;p&gt;Consider the notation and objective below for this sequential resource allocation problem:&lt;/p&gt;&#xA;&lt;p&gt;Allocation channels &lt;span class=&quot;math-container&quot;&gt;$i \in (1, 2)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Spend/Cost timestep i channel j: &lt;span class=&quot;math-container&quot;&gt;$C_{i, j}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Total resource: &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Horizon: &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Max allocation jump between time-steps: &lt;span class=&quot;math-container&quot;&gt;$1.5$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Minimum allocation: &lt;span class=&quot;math-container&quot;&gt;$min\_total\_channel_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;target ROI: &lt;span class=&quot;math-container&quot;&gt;$targetvalue$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;planned spend over horizon: &lt;span class=&quot;math-container&quot;&gt;$P = (C_{1, 1}, C_{1, 2}.....C_{H, 1}, C_{H, 2})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We have a time-variant predictor for the amount of sales on a specific day. For a certain timestep it takes the following form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$sales_{i, j} = coeff_{i, j} * spend_{i, j}^{saturation_{{i, j}}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where as &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; denotes the timestep and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; denotes the channel.&lt;/p&gt;&#xA;&lt;p&gt;The following holds: &lt;span class=&quot;math-container&quot;&gt;$0 \le saturation_{i ,j} \le 1$&lt;/span&gt; , notice that this curve exhibits diminishing marginal returns and is concave when minimizing thus convex when maximizing.&lt;/p&gt;&#xA;&lt;p&gt;The total sales over the horizon can then be expressed as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$totalsales(P) = \sum_{i}\sum_{j} coeff_{i, j} * spend_{i, j}^{saturation_{{i, j}}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The aim of this optimization task is to maximize the spend whilst maintaining a target ROI (return on investment). We also have some constraints we want our solution to adhere to such as minimum spend per channel, total budget constraint, max jump between the budgeting between one day and another.&lt;/p&gt;&#xA;&lt;p&gt;We construct the following optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    \max_{C_{i, j}}\sum_{i}\sum_{j}C_{i, j} \\&#xA;    s.t \sum_{i}\sum_{j} C_{i, j} &amp;amp;\le B \quad (Total-budget) \\&#xA;    C_{i, j} &amp;amp; \ge 0.4 * C_{i - 1, j} \quad (Max-increment) \\&#xA;    C_{i, j} &amp;amp; \ge 0.4 * C_{i + 1, j} \quad (Max-decrement) \\&#xA;    \sum_{i}C_{i, j} &amp;amp; \ge min\_total\_spend\_channel_j \quad (Channel-budget) \\&#xA;    \frac{totalsales(P)}{\sum_{i}\sum_{j}C_{i, j}} &amp;amp; \ge targetvalue \quad (ROI)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is a toy example and not the real-life example I am working on.&#xA;In the real example, the sales predictor has a more complex functional shape looking like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$sales_{i} = \sum_{j}coeff_{i, j}*hill\_saturation (adstock(C_{i, j}))$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where as &lt;span class=&quot;math-container&quot;&gt;$adstock(C_{i, j}) = C_{i, j} + \lambda C_{i - 1, j}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt;= \lambda &amp;lt;= 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$hill\_saturation(C_{i, j}) = \frac{C_{i, j}^{\alpha}}{C_{i, j}^{\alpha} + \gamma^{\alpha}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thus it exhibits a hill-type of function introducing all sorts of possible local minima. However, in the general case for my datasets, this function will be convex considering a maximization problem.&lt;/p&gt;&#xA;&lt;p&gt;What I am wondering is if this is a good way of formulating this type of problem, particularly the formulation of the objective being maximizing the cost and putting the ROI objective as a constraint. I assume this could lead to some issues when picking up a solver. Maybe maximizing sales as an objective and keeping the constraint would be better.&lt;/p&gt;&#xA;&lt;p&gt;I have been playing around with some python solvers without a good deal of luck(CPLEX doesn't work(DCP-violated), SLSQP and trust-constr gets stuck in local minima, and the random search takes ages. what would be a good solver for this type of problem - plus point for one with implementations that are free in python/API?&lt;/p&gt;&#xA;" OwnerUserId="11197" LastEditorUserId="1228" LastEditDate="2023-02-21T07:04:16.973" LastActivityDate="2023-02-21T10:28:06.313" Title="Formulation of nonlinear nonconvex optimization problem and finding appropiate solver" Tags="|optimization|nonlinear-programming|nonconvex-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9973" PostTypeId="1" AcceptedAnswerId="9974" CreationDate="2023-02-20T16:57:46.603" Score="3" ViewCount="233" Body="&lt;p&gt;I am solving a problem using linear relaxation at the initial phase. Hence, I need continuous variables at the beginning. Then I need to convert some continuous variables to binary and solve the same problem in that way. If I need to redefine the model, it can be very inefficient as I have many constraints.&lt;/p&gt;&#xA;&lt;p&gt;I have defined a continuous variable as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Define sets&#xA;X = [(i, j) for i in range(1, a + 1) for j in range(1, b + 1)]&#xA;&#xA;# Define variables&#xA;x = m.continuous_var_dict(X, name=&amp;quot;x&amp;quot;, lb=0, ub=1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is it possible to convert it to binary variable, possible in the most efficient way computationally?&lt;/p&gt;&#xA;" OwnerDisplayName="user5245" LastActivityDate="2023-02-22T09:44:21.267" Title="Converting continuous variable dict to binary variables in python docplex" Tags="|optimization|python|cplex|docplex|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9974" PostTypeId="2" ParentId="9973" CreationDate="2023-02-20T19:44:28.637" Score="2" Body="&lt;p&gt;If you would like to convert a variable into another type, this can be possible by using ilo.conversation method. This can be invoked on DoCplex by;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;The_defined_variable.set_vartype('C')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where the character &amp;quot;C&amp;quot; would be as well as either &amp;quot;B&amp;quot;, &amp;quot;I&amp;quot; or &amp;quot;N&amp;quot; to convert continues, binary, integer or semi-defined variables respectively. Also, if you are willing to solve the relaxed version of the problem the simple below template would be helpful:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;!pip install cplex&#xA;!pip install docplex&#xA;from docplex.mp.model import Model&#xA;from docplex.mp.relax_linear import LinearRelaxer&#xA;&#xA;m = Model(&amp;quot;model&amp;quot;)&#xA;'''&#xA;optimization model    &#xA;'''&#xA;&#xA;lp = LinearRelaxer.make_relaxed_model(m)&#xA;lp.print_information()&#xA;s_lp = lp.solve(log_output=True)&#xA;s_lp.display()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As an example of how these two method work please, see this &lt;a href=&quot;https://colab.research.google.com/drive/1RemT_UUaE4kkvIZ85M1BeHfSTRaAJybW?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-02-22T09:44:21.267" LastActivityDate="2023-02-22T09:44:21.267" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9975" PostTypeId="2" ParentId="9972" CreationDate="2023-02-21T09:50:00.403" Score="2" Body="&lt;p&gt;Yes, there are quite a few good global NLP solvers. That would be my first thing to try out. (Always start experiments with the easiest/cheapest thing to do; do more complex things only when not happy yet).&lt;/p&gt;&#xA;&lt;p&gt;Gurobi has a global quadratic solver. It is not too difficult to reformulate into a non-convex quadratic model. That would be another quick thing to try. (Note: something like &lt;span class=&quot;math-container&quot;&gt;$y=x^{2/3}$&lt;/span&gt; can be written as &lt;span class=&quot;math-container&quot;&gt;$y\cdot y^2=x^2$&lt;/span&gt;.)&lt;/p&gt;&#xA;&lt;p&gt;The nonlinearities are somewhat mild, so an alternative is to use a piecewise linear approximation. The resulting model is linear, I believe (after rearranging the last constraint in the model). That would also give global solutions.&lt;/p&gt;&#xA;&lt;p&gt;Finally, we can discretize the &lt;span class=&quot;math-container&quot;&gt;$C_{i,j}$&lt;/span&gt;. That would give you additional solvers, such as Cplex CP solver, or OR-Tools CP-SAT tools. (Note: HillSaturation can be precomputed then, so the nonlinearity and con-convexity is gone. That would make things even linear.).&lt;/p&gt;&#xA;&lt;p&gt;I can't imagine that all these approaches would fail terribly.&lt;/p&gt;&#xA;&lt;p&gt;Note that math is confusing. E.g. &lt;span class=&quot;math-container&quot;&gt;$totalSales(P)$&lt;/span&gt; does not depend on &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; (or on &lt;span class=&quot;math-container&quot;&gt;$C_{i,j}$&lt;/span&gt;). Writing down a clean optimization model (in math) is also a good first step. A clean model allows better reasoning about it, so that is always a good idea.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2023-02-21T10:28:06.313" LastActivityDate="2023-02-21T10:28:06.313" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9976" PostTypeId="1" AcceptedAnswerId="9977" CreationDate="2023-02-21T13:22:08.610" Score="2" ViewCount="242" Body="&lt;p&gt;I want to linearize the following disjunctive form.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\left[\begin{gathered}w_{1}\\x \geq a\end{gathered}\right] \vee \left[\begin{gathered}w_{2}\\x \geq b\end{gathered}\right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$w_1$&lt;/span&gt; and  &lt;span class=&quot;math-container&quot;&gt;$w_2$&lt;/span&gt; are binary and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a free variable &lt;span class=&quot;math-container&quot;&gt;$\in \{ -2, \cdots, 10\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\{ -2 \lt a \lt b \lt 10 \}$&lt;/span&gt;. I think one possible way is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\left[\begin{gathered}(w_{1}=1) \land (x \geq a) \end{gathered}\right] \vee \left[\begin{gathered}(w_{2}=1) \land (x \geq b)\end{gathered}\right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$(w_{1} \lor w_{2}) \bigwedge (w_{1} \implies x \geq a) \bigwedge (w_{2} \implies x \geq b)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would like to know if, is there a way to linearize such a disjunctive form by introducing the new auxiliary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; for each disjunct? (Also, the answer by Rob is a perfect one).&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-03-04T12:17:05.490" LastActivityDate="2023-03-06T04:40:13.907" Title="Linearizing a disjunctive expression into MILP" Tags="|mixed-integer-programming|linearization|logical-constraints|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9977" PostTypeId="2" ParentId="9976" CreationDate="2023-02-21T13:47:40.517" Score="5" Body="&lt;p&gt;Because &lt;span class=&quot;math-container&quot;&gt;$a&amp;lt;b$&lt;/span&gt;, the lower bound &lt;span class=&quot;math-container&quot;&gt;$x \ge a$&lt;/span&gt; is valid for both parts.  So linearize the following:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;a\le x \le 10\\&#xA;z_1 \lor z_2 \\&#xA;z_1 \implies w_1 \\&#xA;z_2 \implies w_2 \\&#xA;z_2 \implies x\ge b&#xA;$$&lt;/span&gt;&#xA;The resulting linear constraints are:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z_1 + z_2 &amp;amp;\ge 1 \\&#xA;z_1 &amp;amp;\le w_1 \\&#xA;z_2 &amp;amp;\le w_2 \\&#xA;a + (b-a)z_2 \le x &amp;amp;\le 10&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If the disjunction is instead intended to be exclusive, you can omit the &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; variables and impose:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;w_1 + w_2 &amp;amp;= 1 \\&#xA;a + (b-a)w_2 \le x &amp;amp;\le 10&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-04T20:39:00.280" LastActivityDate="2023-03-04T20:39:00.280" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9978" PostTypeId="2" ParentId="9938" CreationDate="2023-02-21T16:10:44.677" Score="0" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_i \ge x_{i+1}$&lt;/span&gt; (which was the case in my situation), I found the following that works as well. Create two continuous variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0 \le x_i, a_i &amp;lt; 1$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i= 1, 2, \dots, N$&lt;/span&gt; and one binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta_i$&lt;/span&gt;. Then impose the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_i = x_{i-1} - (\delta_ia_i)\tag{1},$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\delta_1 = 0\tag{2},$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i \delta_i = 2\tag{3},$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\beta = \frac{\sum_i d_ix_i}{\sum_i d_i}\tag{4}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="329" LastActivityDate="2023-02-21T16:10:44.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9979" PostTypeId="1" CreationDate="2023-02-21T16:20:13.327" Score="1" ViewCount="37" Body="&lt;p&gt;Suppose we consider budgeted uncertainty (Bertsimas and Sim, 2002) for the following scenario. We have a binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt; (two sets). We then have the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_i x_{i,j} \geq b_j$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The value &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; comes from a separate set, say &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, where each element is associated with an element from &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now we assume, up to &lt;span class=&quot;math-container&quot;&gt;$\Gamma$&lt;/span&gt; elements from &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; are uncertain. How can we derive the robust counterpart or move the uncertainty to left-hand side? Alternatively, can someone point me to relevant literature.&lt;/p&gt;&#xA;&lt;p&gt;Note: There is similarity to question: &lt;a href=&quot;https://or.stackexchange.com/questions/9882/gamma-uncertainty-set&quot;&gt;Gamma uncertainty set&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, the information provided here is more specific. Alternatively, I seek better explanation or other relevant literature, since the linked paper is not easily accessible.&lt;/p&gt;&#xA;" OwnerUserId="10707" LastEditorUserId="500" LastEditDate="2023-02-22T00:02:56.427" LastActivityDate="2023-02-22T00:02:56.427" Title="Budgeted uncertainty on the RHS" Tags="|optimization|mixed-integer-programming|linear-programming|reference-request|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9980" PostTypeId="2" ParentId="9964" CreationDate="2023-02-21T16:35:43.663" Score="0" Body="&lt;p&gt;Assuming that there is no time cost for moving a job onto or off of a machine, you could try the following MIP model. The parameters (all assumed integer) are the set of jobs (indexed &lt;span class=&quot;math-container&quot;&gt;$j=1,\dots,J$&lt;/span&gt;), the time horizon (indexed &lt;span class=&quot;math-container&quot;&gt;$t=1,\dots,T$&lt;/span&gt;), and for each job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; the release time &lt;span class=&quot;math-container&quot;&gt;$r_j,$&lt;/span&gt; the deadline &lt;span class=&quot;math-container&quot;&gt;$d_j$&lt;/span&gt; and the duration &lt;span class=&quot;math-container&quot;&gt;$\delta_j.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{j,t}$&lt;/span&gt; signalling whether job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is running at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$x_{j,t} = 0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$t &amp;lt; r_j$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$t &amp;gt; d_j$&lt;/span&gt;) and a continuous variable &lt;span class=&quot;math-container&quot;&gt;$y\ge 0$&lt;/span&gt; measuring the number of machines needed.&lt;/p&gt;&#xA;&lt;p&gt;The objective is to minimize &lt;span class=&quot;math-container&quot;&gt;$y.$&lt;/span&gt; Constraints are as follows.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{t=1}^T x_{j,t} = \delta_j \quad \forall j=1,\dots,J$$&lt;/span&gt; (each job must receive the necessary processing between its release and deadline dates) and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y\ge \sum_{j=1}^J x_{j,t}\quad \forall t=1,\dots,T$$&lt;/span&gt; (in each period there must be at least as many machines available as there are jobs being processed).&lt;/p&gt;&#xA;&lt;p&gt;I would not be surprised if this model solved fairly quickly.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-02-21T16:35:43.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9981" PostTypeId="2" ParentId="9964" CreationDate="2023-02-21T18:56:19.187" Score="1" Body="&lt;p&gt;I solved a problem with objective to minimize resources. I have to agree that this problem is not addressed in literature.&lt;/p&gt;&#xA;&lt;p&gt;This problem is generally more complicated than minimization of makespan for example since a solution with less resources can be very different compared to a solution with more resources.&lt;/p&gt;&#xA;&lt;p&gt;In your case I would recommend to use constraint programming and use capacity of cumulative constraint (if possible) to express needed resources. Classical constraint solver can be trapped in local optimum, better is to use cp-sat solver from ortools.&lt;/p&gt;&#xA;" OwnerUserId="4412" LastActivityDate="2023-02-21T18:56:19.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9982" PostTypeId="1" CreationDate="2023-02-21T20:02:06.973" Score="1" ViewCount="61" Body="&lt;p&gt;Can anyone advise how this nonlinear equation with a single variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; can be solved as a closed form?&#xA;&lt;span class=&quot;math-container&quot;&gt;${\left(\frac{x}{1-x}\right)}^2.{\left(\frac{x-C}{\left(1-x\right)-N}\right)}^2=H.\frac{2x-C}{2\left(1-x\right)-N}$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; are real and positive values. I only know that &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;x&amp;lt;1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Please also guide me on what the best way to solve it computationally is.&lt;/p&gt;&#xA;" OwnerUserId="10911" LastActivityDate="2023-02-22T14:39:28.527" Title="Solving single-variable fractional equation" Tags="|nonlinear-programming|generalized-linear-fractional|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9983" PostTypeId="1" CreationDate="2023-02-21T20:10:53.313" Score="0" ViewCount="64" Body="&lt;p&gt;I want to solve large instances of asymmetrical capacitated vehicle problem with thousands of nodes. So far I tried lkh-3 solver but so far I cannot reach noticably better results compared to naive solution used as initial solution for the solver&lt;/p&gt;&#xA;&lt;p&gt;Even good/optimal solution for a problem calculated in days is good for me for comparison with worse and faster solutions.&lt;/p&gt;&#xA;" OwnerUserId="4412" LastActivityDate="2023-02-21T20:10:53.313" Title="a solver for large instances of ACVRP" Tags="|vehicle-routing|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9984" PostTypeId="1" CreationDate="2023-02-21T20:36:40.477" Score="-1" ViewCount="301" Body="&lt;p&gt;I am really new at pyomo and I have been trying to model a simple problem (I reduced the problem to the maximum so that I can see the error). Now the error is at the beginning when I declare the parameters as you will see below. I also use this matrix in my constraint with indexes &lt;code&gt;[i,j]&lt;/code&gt;, and also an index error as in the figure below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7GGjL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7GGjL.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BZ2Ph.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BZ2Ph.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZAjrK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZAjrK.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11313" LastEditorUserId="11313" LastEditDate="2023-02-21T22:47:34.753" LastActivityDate="2023-02-23T17:47:51.343" Title="An error in Pyomo with a parameter represented as a matrix" Tags="|pyomo|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9985" PostTypeId="2" ParentId="9984" CreationDate="2023-02-21T21:08:03.197" Score="0" Body="&lt;p&gt;Your matrix as defined isn't a matrix (2-D); its just 1-D with value of &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;. To make 2-D you'll need np.ones(shape=(3,3)) or np.zeros((3,3)) to make a default matrix.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-21T21:47:59.580" LastActivityDate="2023-02-21T21:47:59.580" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9986" PostTypeId="2" ParentId="9982" CreationDate="2023-02-21T22:26:21.893" Score="1" Body="&lt;p&gt;I cannot speak to a closed form solution, but I can address the possibility of a numeric approach. To solve the equation, we will look for a root in &lt;span class=&quot;math-container&quot;&gt;$(0, 1)$&lt;/span&gt; of the function &lt;span class=&quot;math-container&quot;&gt;$$f(x) = {\left(\frac{x}{1-x}\right)}^2 \cdot {\left(\frac{x-C}{\left(1-x\right)-N}\right)}^2 - H\cdot \frac{2x-C}{2\left(1-x\right)-N}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;First note that &lt;span class=&quot;math-container&quot;&gt;$f(x)\rightarrow \infty$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$x\rightarrow 1,$&lt;/span&gt; so you will need to bound the upper limit of the search interval for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; strictly below 1. Second, there may be more than one root of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; in the unit interval.&lt;/p&gt;&#xA;&lt;p&gt;I did some quick numerical experiments, and it appears that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; can a bit volatile (very steep in places), making numeric methods a bit tricky. You could, for instance, try &lt;a href=&quot;https://en.wikipedia.org/wiki/Newton%27s_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Newton's method&lt;/a&gt;, starting from some value inside the unit interval (maybe 0.5, maybe a different value), either using an explicit formula for the derivative &lt;span class=&quot;math-container&quot;&gt;$f^\prime(x)$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is not too hard to differentiate) or using numerical approximations for the derivative. If Newton's method fails to converge to a root, you can retry with a different starting point. Depending on what your preferred programming language is, you may be able to find third party libraries that support Newton (also known as Newton-Raphson) or other root finding methods.&lt;/p&gt;&#xA;&lt;p&gt;A lower tech, fairly easy approach to program is &lt;a href=&quot;https://en.wikipedia.org/wiki/Bisection_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;bisection search&lt;/a&gt;. Start by defining a sequence of grid points &lt;span class=&quot;math-container&quot;&gt;$x_0 = 0 &amp;lt; x_1 &amp;lt; x_2 &amp;lt; \dots &amp;lt; x_n &amp;lt; 1$&lt;/span&gt; and evaluate &lt;span class=&quot;math-container&quot;&gt;$f(x_i)$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Find an index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; changes sign between &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{i+1}.$&lt;/span&gt; Evaluate &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; at the midpoint of the interval &lt;span class=&quot;math-container&quot;&gt;$[x_i, x_{i + 1}],$&lt;/span&gt; replace the endpoint having the same sign for &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; as the midpoint with the midpoint, and repeat until the width of the interval is small enough that you will accept the last midpoint as your estimate of the root of &lt;span class=&quot;math-container&quot;&gt;$f.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-02-21T22:26:21.893" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9987" PostTypeId="1" CreationDate="2023-02-21T23:21:22.173" Score="1" ViewCount="212" Body="&lt;p&gt;Could you please teach me when an optimization model with fractional terms in the objective function can be linearized or solved optimally?&lt;/p&gt;&#xA;&lt;p&gt;I only know that if the objective function has a single fractional term with a linear numerator and denominators can be linearized. But I wonder if (i) there is a summation of fractional terms or (ii) with a quadratic numerator and/ or denominator are quadratic can be linearized or de-fractioned.&lt;/p&gt;&#xA;" OwnerUserId="10911" LastEditorUserId="500" LastEditDate="2023-02-22T00:08:29.993" LastActivityDate="2024-01-03T07:12:37.950" Title="Nonlinear fractional objective function" Tags="|optimization|nonlinear-programming|linearization|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9988" PostTypeId="1" CreationDate="2023-02-22T01:42:48.187" Score="0" ViewCount="122" Body="&lt;p&gt;A telecommunication company (CALLME TEL Co., Ltd) receives and processes customers’ orders.&lt;/p&gt;&#xA;&lt;p&gt;Orange Co., Ltd is an important customer, who mostly places orders every 2 months. Medium quantity of successful order in the “shall-placing-order-month” total is 500 units. (occasionally it also places small number of orders every month)&lt;/p&gt;&#xA;&lt;p&gt;(the Orders came in different days in the “shall-placing-order-month”, for various phone models of different quantities. The total successful quantity of all models sums to about 500 units in the month)&lt;/p&gt;&#xA;&lt;p&gt;Because of different reasons (delivery, stock, pricing, etc.), the order success rate remains on 30%.&lt;/p&gt;&#xA;&lt;p&gt;From an order received from Orange, to the order is confirmed as successful, it takes 5 to 60 days (depends on processing time of individual orders).&lt;/p&gt;&#xA;&lt;p&gt;As the customer Orange may place orders to CALLME’s competitors too. CALLME’s manager wants to detect if the orders came from Orange is declining early.&lt;/p&gt;&#xA;&lt;p&gt;CALLME’s manager thinks, CALLME shall maintain a safe order level from Orange (orders being progressed).&lt;/p&gt;&#xA;&lt;p&gt;How to calculate the safe order level? (any other information required for the calculation)&lt;/p&gt;&#xA;" OwnerUserId="2440" LastEditorUserId="491" LastEditDate="2023-02-25T03:03:42.573" LastActivityDate="2024-03-21T05:08:26.033" Title="To maintain safe order level from a customer" Tags="|modeling|inventory|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9989" PostTypeId="2" ParentId="9987" CreationDate="2023-02-22T09:56:17.230" Score="0" Body="&lt;p&gt;There are various ways to formulate this depending on context. For example, in the general case any program of type &lt;span class=&quot;math-container&quot;&gt;$\min \frac{f(x)}{g(x)}$&lt;/span&gt; can be reformulated to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min w\\\text{s.t.}\\w=\frac{f(x)}{g(x)}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This can then be written as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min w \\\text{s.t.}\\g(x)w=f(x)\\|g(x)|\geq \epsilon$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This can then be relaxed and solved with branch and bound. If we have more fractional terms, we simply add more auxiliary &lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; variables and constraints to match. In this example, if the range of &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; initially includes 0 we have to give something up by adding a finite tolerance, so this can not be an exact reformulation.&lt;/p&gt;&#xA;&lt;p&gt;This is typically good enough because it's bad modelling to allow a model to acquire meaningful values close to singularities in the first place.&lt;/p&gt;&#xA;&lt;p&gt;Global optimization solvers will do all of this automatically.&lt;/p&gt;&#xA;&lt;p&gt;If one is feeling cheeky they might even decide the bilinear syntax is fine and not to add the absolute value constraint, if that happens to work out in hindsight, even though that's not mathematically correct. For instance, we can solve without the &lt;span class=&quot;math-container&quot;&gt;$\neq 0$&lt;/span&gt; constraint and check whether the result actually evaluates to &lt;span class=&quot;math-container&quot;&gt;$g(x)=0$&lt;/span&gt;. If it doesn't, sweet, we're done.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="491" LastEditDate="2023-04-06T12:15:08.210" LastActivityDate="2023-04-06T12:15:08.210" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9990" PostTypeId="2" ParentId="9982" CreationDate="2023-02-22T14:22:54.113" Score="1" Body="&lt;p&gt;Using Mathematica or Wolfram Engine, you could do something like this. Hope this helps.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;In[11]:= NSolve[{((C - x)^2*x^2)/((-1 + x)^2*(-1 + N + x)^2) == (H*(C - 2*x))/(-2 + N + 2*x), x &amp;gt; 0, x &amp;lt; 1, N == 123, H&#xA;== 12, C == 321}]&#xA;&#xA;Out[11]= {{C -&amp;gt; 321., H -&amp;gt; 12., N -&amp;gt; 123., x -&amp;gt; 0.681967}}&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9050" LastEditorUserId="9050" LastEditDate="2023-02-22T14:39:28.527" LastActivityDate="2023-02-22T14:39:28.527" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9991" PostTypeId="2" ParentId="7145" CreationDate="2023-02-22T15:45:57.943" Score="0" Body="&lt;p&gt;I found a link that works for installing the solver on windows, i dont know if that will help, but here it is :&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=EB_qVoM74Fg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=EB_qVoM74Fg&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11313" LastActivityDate="2023-02-22T15:45:57.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9992" PostTypeId="2" ParentId="9988" CreationDate="2023-02-22T23:44:05.290" Score="1" Body="&lt;p&gt;It's part of inventory control, subject of research &amp;amp; practice within large supply chain domain. Though in grad school, inventory management is a topic as part of operations research. Inventory management is therefore an intersection between optimization, statistics (probability distribution of orders and lead time), processes (fulfillment) and maybe Machine learning (to predict seasonal/cyclical likelihood of incoming orders).&lt;br /&gt;&#xA;Though literature on this subject is vast and easily available (just google inventory+safety stock+service level) for dive-down, I usually find links that aggregate content and present as quick guide quite useful like &lt;a href=&quot;https://www.supplychain247.com/article/inventory_management_four_common_pitfalls_of_safety_stock&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;.&#xA;While scenarios will impact calculation but &lt;em&gt;generally&lt;/em&gt; what you are asking can be interpreted in a similar way to safety stock metric used in inventory management. General formulation is&lt;br /&gt;&#xA;&lt;em&gt;Safety stock&lt;/em&gt; =&lt;span class=&quot;math-container&quot;&gt;$z\sqrt{L_{\mu}^2D_{\sigma}^2+ L_{\sigma}^2D_{\mu}^2 }$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is z-score for service level (your case is 70%) and L is lead time, D is demand indexed by &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;: average lead time/average demand and &lt;span class=&quot;math-container&quot;&gt;$\sigma^2 $&lt;/span&gt; is their corresponding variance.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-23T01:43:02.953" LastActivityDate="2023-02-23T01:43:02.953" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9993" PostTypeId="1" CreationDate="2023-02-23T03:12:20.743" Score="2" ViewCount="488" Body="&lt;p&gt;I want to solve an optimization problem where the objective function is the summation of nonlinear, piecewise functions in the decision variables q_i's such that when a decision variable q_i &amp;lt; 1, the function associated with it is quadratic; otherwise it is a log function. In Pyomo with &amp;quot;ipopt&amp;quot; solver, I tried to define the objective function (as suggested by the answer &lt;a href=&quot;https://stackoverflow.com/questions/67437603/is-it-possible-to-write-a-nonlinear-piecewise-function-inside-the-objective-func&quot;&gt;here&lt;/a&gt;) using the &amp;quot;Expr_If&amp;quot; expression. However, when I run the code (see below), the solver indicates that an optimal solution is reached (Message: Ipopt 3.14.9\x3a Optimal Solution Found, Termination condition: optimal). I can print the value of optimal decision variables by running:&#xA;&lt;code&gt;for x in model.q: print(model.q[x].value)&lt;/code&gt;&#xA;but I can not print the optimal value of the objective function when I run:&#xA;&lt;code&gt;model.payoff()&lt;/code&gt; such that I get this error &amp;quot;math domain error&amp;quot;. This error might suggest that a log function is being evaluated at a negative value, but based on the objective function that I defined this should not happen. Also, I can calculate the value of the objective function by evaluating it (after obtaining the optimal solution) directly using the values of optimal solution q_i's by running the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;payoff_ = 0&#xA;for i in model.P:&#xA;    if model.q[i].value&amp;gt;=1:&#xA;        payoff_ +=  model.Beta[i] * log(model.q[i])&#xA;    else:&#xA;        payoff_ += (-0.5)*model.Alpha[i] * (model.q[i]-1)**2&#xA;print(payoff_())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Do you know why I am getting the &amp;quot;math domain error&amp;quot; when I run &lt;code&gt;model.payoff()&lt;/code&gt; ?&lt;/p&gt;&#xA;&lt;p&gt;Also, is there any other solver I can use to solve this problem? (not necessarily with python)&lt;/p&gt;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = ConcreteModel()&#xA;&#xA;#Define the set&#xA;model.P = Set(initialize=['P1','P2','P3','P4'])&#xA;&#xA;#Parameters&#xA;model.Beta = Param(model.P, initialize = {'P1':1,'P2':1.2,'P3':1.4,'P4':1.6})&#xA;model.Alpha = Param(model.P, initialize = {'P1':0.1,'P2':0.2,'P3':0.3,'P4':0.4})&#xA;&#xA;#Variables&#xA;model.q = Var(model.P)&#xA;&#xA;#Objective&#xA;def Payoff(model):&#xA;    return sum(Expr_if(IF=model.q[i]&amp;gt;=1, THEN=model.Beta[i] * log(model.q[i]),&#xA;              ELSE=(-0.5)*model.Alpha[i] * (model.q[i]-1)**2) for i in model.P)&#xA;model.payoff = Objective(expr = Payoff, sense = maximize)&#xA;&#xA;#Constraints&#xA;def limit(model, i):&#xA;    return -1.1&amp;lt;= model.q[i]&#xA;model.limit = Constraint(model.P, rule = limit)&#xA;&#xA;def balance(model):&#xA;    return summation(model.q) == 0&#xA;model.balance = Constraint(rule = balance)&#xA;&#xA;solver = SolverFactory('ipopt')&#xA;solver.solve(model)&#xA;#model.pprint()&#xA;&#xA;#model.payoff()             &amp;lt;--- printing value of objective function gives an error&#xA;#value(model.payoff)        &amp;lt;--- printing value of objective function gives an error&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11301" LastEditorUserId="11301" LastEditDate="2023-02-23T03:18:38.823" LastActivityDate="2023-02-23T10:02:43.787" Title="I want to solve an optimization problem with nonlinear piecewise objective function (I tried Pyomo with &quot;ipopt&quot; solver but I had an error)" Tags="|python|nonlinear-programming|pyomo|ipopt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9994" PostTypeId="2" ParentId="9993" CreationDate="2023-02-23T03:51:23.140" Score="1" Body="&lt;p&gt;IPOPT only supports continuous variables, not binary or integer.&lt;/p&gt;&#xA;&lt;p&gt;Look for an MINLP solver which suits your needs and budget.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2023-02-23T03:51:23.140" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="9996" PostTypeId="2" ParentId="9993" CreationDate="2023-02-23T10:02:43.787" Score="0" Body="&lt;p&gt;The error &lt;em&gt;math domain error&lt;/em&gt; implies you are evaluating a function outside their allowed domain: if you adjust your limit-constraint from &lt;span class=&quot;math-container&quot;&gt;$-1.1$&lt;/span&gt; to a value &lt;span class=&quot;math-container&quot;&gt;$&amp;gt; 0$&lt;/span&gt;, it should not give the error anymore.&lt;/p&gt;&#xA;&lt;p&gt;Besides that and like Mark already mentioned is that Ipopt only supports continuous variables. A MINLP solver you can use is &amp;quot;mindtpy&amp;quot;. You can also define the underlying mip solver and nlp solver like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solver.solve(model, mip_solver=&amp;quot;glpk&amp;quot;, nlp_solver=&amp;quot;ipopt&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="329" LastActivityDate="2023-02-23T10:02:43.787" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9998" PostTypeId="2" ParentId="9984" CreationDate="2023-02-23T17:47:51.343" Score="1" Body="&lt;p&gt;The problem was in the initialization of the parameters.&#xA;so for every parameter that should iterate, we use a function that returns each element of this parameter (with the correct index), as shown in the below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def W_init(model, i, j):&#xA;    return matrix [i,j]&#xA;&#xA;model.rout = Param(model.i, model.j,  initialize=W_init,mutable=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11313" LastActivityDate="2023-02-23T17:47:51.343" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9999" PostTypeId="1" CreationDate="2023-02-24T06:18:05.367" Score="0" ViewCount="115" Body="&lt;p&gt;I'm asking you a question because I was confused about MIP while reading the paper.&#xA;This paper is about dual crane optimization.&#xA;In the MIP model of the paper, equations (7) and (8) are used to model similar situations, but (7) has &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I} y^2_{ist}$&lt;/span&gt;, and (8) has no &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I} y^2_{ist}$&lt;/span&gt;. I don't know why there's this difference.&lt;br&gt;&lt;br&gt;&#xA;I think that &lt;span class=&quot;math-container&quot;&gt;$y^2_{ist}$&lt;/span&gt; is 1 when &lt;span class=&quot;math-container&quot;&gt;$(i, s, t)$&lt;/span&gt; set should be only one case about &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;br&gt;&#xA;when &lt;span class=&quot;math-container&quot;&gt;$(i, s, t)$&lt;/span&gt; is (1, 4, 5), &lt;span class=&quot;math-container&quot;&gt;$y^2_{ist}$&lt;/span&gt; is 1 then &lt;span class=&quot;math-container&quot;&gt;$(1, s', t')$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; not 4, &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; not 5. so, I can't understand above (7), (8) what is difference &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I} y^2_{ist}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(7) means that if the landside crane starts to pick up container i in slot s at time t (&lt;span class=&quot;math-container&quot;&gt;$y^2_{ist} = 1$&lt;/span&gt;), then it is actually located in slot s throughout the time interval [t, t + p] (loading time). &lt;br&gt;&#xA;(8) means that if the landside crane starts to pick up container i in slot s at time t (&lt;span class=&quot;math-container&quot;&gt;$y^2_{ist} = 1$&lt;/span&gt;), then it is actually located in slot s throughout the unlodaing time.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QttZ9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QttZ9.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8Ha1n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8Ha1n.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0166218X16301652&quot; rel=&quot;nofollow noreferrer&quot;&gt;article site&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11326" LastActivityDate="2024-03-20T18:07:55.907" Title="Meaning difference between SUMMATION and not in the MIP model" Tags="|optimization|mixed-integer-programming|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10000" PostTypeId="1" AcceptedAnswerId="10017" CreationDate="2023-02-24T11:02:03.423" Score="2" ViewCount="163" Body="&lt;p&gt;Consider the binary program&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \min_{ x \in \{0,1\}^N } \left\{ c^T x \mid Ax \leq b \right\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; are real matrices with appropriate dimensions. I am interested in solving large binary MIP problems of this type. In many cases, a large number of my variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are zero. According to &lt;a href=&quot;https://or.stackexchange.com/a/2736/11216&quot;&gt;this answer&lt;/a&gt; by Rolf van Lieshout, one could do this using reduced cost fixing. However, I've tried looking further into the topic but resources are quite limited, as &lt;a href=&quot;https://or.stackexchange.com/q/9125&quot;&gt;others also have noted&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;From what I understand, reduced cost fixing works by considering the reduced cost vector  &lt;span class=&quot;math-container&quot;&gt;$d=c-A^T y^\star$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$y^\star$&lt;/span&gt; is the optimal dual solution. Then, given some lower bound &lt;span class=&quot;math-container&quot;&gt;$z_{LB}$&lt;/span&gt; and upper bound &lt;span class=&quot;math-container&quot;&gt;$z_{UB}$&lt;/span&gt;, we can fix the nonbasic variable &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if  &lt;span class=&quot;math-container&quot;&gt;$d_j \geq z_{UB} - z_{LB}$&lt;/span&gt;, or fix &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; to one when &lt;span class=&quot;math-container&quot;&gt;$- d_j \geq z_{UB}-z_{LB}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, one can also write &lt;span class=&quot;math-container&quot;&gt;$d_j = c_j - c_{\mathcal{B}}^T B^{-1} a_j$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$c_{\mathcal{B}}$&lt;/span&gt; is the cost coefficient vector of the basic variables, &lt;span class=&quot;math-container&quot;&gt;$B^{-1}$&lt;/span&gt; is the basis inverse and &lt;span class=&quot;math-container&quot;&gt;$a_j$&lt;/span&gt; is the j'th column of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have a question regarding this topic:&lt;/p&gt;&#xA;&lt;p&gt;Is there a mathematical derivation which proofs that the entries of the reduced cost vector indeed show that the objective would have to increase by the given amount before they could enter the basis in the simplex algorithm? All sources I could find unfortunately simply claim this fact, but neglect to show it. I would really like to understand and proof &lt;em&gt;why&lt;/em&gt; we can claim that the objective has to change by the given value before the variable can enter the basis again. I've tried proving it, but could not manage.&lt;/p&gt;&#xA;" OwnerUserId="11216" LastEditorUserId="11216" LastEditDate="2023-02-27T12:23:45.677" LastActivityDate="2023-02-28T08:31:49.023" Title="Reduced cost fixing for binary programs" Tags="|linear-programming|integer-programming|binary-variable|bounds|reduced-costs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10001" PostTypeId="1" CreationDate="2023-02-24T11:04:37.477" Score="3" ViewCount="168" Body="&lt;p&gt;I am a Bitcoin / Lightning Network open source developer and researcher and  new here but &lt;a href=&quot;https://bitcoin.stackexchange.com/users/81940/rene-pickhardt&quot;&gt;very active on the sister site&lt;/a&gt;. In the context of my research I discovered the field of operations research and I have a problem that I am sure has been solved before but I fail to find the solution or the problem in the literature.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In my context I have a transportation network where the convex (in practice I linearize it but I thought I describe the problem in the original form) cost function for each arc with capacity &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; encodes the uncertainty weather &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; units can be forwarded. This is expressed as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;cost(a) = -\log(P(X&amp;gt;=a)) = -\log\left(\frac{c+1-a}{c+1}\right)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$mcf(a)$&lt;/span&gt; be the solution of the corresponding Minimum Cost Flow Problem as described in &lt;a href=&quot;https://arxiv.org/abs/2107.05322&quot; rel=&quot;nofollow noreferrer&quot;&gt;this research article&lt;/a&gt;. Then &lt;span class=&quot;math-container&quot;&gt;$P(mcf(a)) = 2^{-cost(mcf(a))}$&lt;/span&gt; can be seen as the probability for &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; units to successfully flow through the network.&lt;/p&gt;&#xA;&lt;p&gt;for a fixed source and sink node pair on a small example network I have computed the probabilities for various amounts of goods for the resulting flows as can be seen in this diagram:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xntou.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xntou.png&quot; alt=&quot;Distribution of success Probabilities for various units (called sats) to flow through the network&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The probability of success drops stronger than exponentially with more units to be sent. Which makes sense from a probabilistic perspective.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Actual Question / Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;One can multiply for each amount &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; the amount with the resulting probability &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; of the corresponding minimum cost flow and receive the expected amount that will be delivered through the network. For the small sample network I have done this in the following diagram for every possible amount &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; that produced a feasible flow.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qj8Bs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qj8Bs.png&quot; alt=&quot;Expected amount that can flow through a network with probabilistic forwarding on arcs depending on the attempted sent out amount&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So my goal is to find the maximum of this function without having to solve the min cost flow problem several times. So I seek the expectation value or the solution of&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;EV = argmax_{a}\{a\cdot P(mcf(a))\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Of course I can do this as done here in a small network by computing the result of the minimum cost flow problem for every amount but I wish to find a more straight forward approach for this second stage optimization problem.&lt;/p&gt;&#xA;&lt;p&gt;While searching the literature I found &lt;a href=&quot;http://stoprog.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;stochastic programming&lt;/a&gt; but I feel a bit uncertain if I have to learn the techniques in that field to solve my problem. However the problem seems to me to be common enough in the sense that it should be known.  Of course the most desirable goal would be if an open source software solver for the problem already existed.&lt;/p&gt;&#xA;" OwnerUserId="11328" LastEditorUserId="491" LastEditDate="2023-02-25T03:01:15.117" LastActivityDate="2023-03-01T19:40:04.257" Title="How to find the maximizing number of expected delivered units of a probabilistic minimum cost flow problem?" Tags="|optimization|linear-programming|modeling|stochastic-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10002" PostTypeId="2" ParentId="10001" CreationDate="2023-02-24T12:43:27.243" Score="1" Body="&lt;p&gt;Since you seem to have figured out a distribution for minimum cost flow (appears like Log-normal) you can try 2- stage stochastic programming using  &lt;a href=&quot;https://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;url=https://www.researchgate.net/publication/286488982_A_Guide_to_Sample_Average_Approximation&amp;amp;ved=2ahUKEwjZs_KZla79AhWVE0QIHdp4C68QFnoECA8QAQ&amp;amp;usg=AOvVaw2sxoPkFRXJp_ndJNIEFPwd&quot; rel=&quot;nofollow noreferrer&quot;&gt;SAA&lt;/a&gt; techniques. &lt;a href=&quot;https://www.lindo.com/doc/online_help/lingo20_0/index.html?stock_option_example.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;LINDO Systems&lt;/a&gt; or &lt;a href=&quot;https://www.lindo.com/index.php/application-models-library&quot; rel=&quot;nofollow noreferrer&quot;&gt;model&lt;/a&gt; offers a very helpful tutorial on that.&lt;br /&gt;&#xA;You will need expected value as the objective (that's always part of objective formulation) but need to pick up a sample size for constraints.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-02-24T12:56:45.037" LastActivityDate="2023-02-24T12:56:45.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10003" PostTypeId="2" ParentId="9999" CreationDate="2023-02-24T15:54:23.380" Score="0" Body="&lt;p&gt;Constr(7) is saying from every slot &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; if any container (that's why you have summation, whenever you want to work on conditions like &lt;em&gt;any/atleast&lt;/em&gt;) is picked up, the seaside crane's position &lt;span class=&quot;math-container&quot;&gt;$ x_{2t}$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; should be at slot &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; where atleast 1 container is picked up. Otheriwse &lt;span class=&quot;math-container&quot;&gt;$x_{2t}$&lt;/span&gt; is free.&lt;br /&gt;&#xA;Constr(8) is saying for a container &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; picked up from a slot &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; (that's why you need to iterate over all slots &amp;amp; container, meaning of for-loop), travel the distance &lt;span class=&quot;math-container&quot;&gt;$s_i-s$&lt;/span&gt; in same time &lt;span class=&quot;math-container&quot;&gt;$ s_i-s$&lt;/span&gt; excluding pick-up/drop-off (&lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;) for the crane's position to be at &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt;-destination slot for container &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is picked-up (&lt;span class=&quot;math-container&quot;&gt;$y_{ist}^2=1$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-02-24T15:54:23.380" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10006" PostTypeId="1" CreationDate="2023-02-25T12:31:03.600" Score="2" ViewCount="188" Body="&lt;p&gt;Consider the optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{array}{l}&#xA;\min_{(x,y)\in \mathbb{R}^2_{+}} \quad x_{1}a_{1} + x_2a_{2}&#xA;\\ \text {subject to } \quad\; &#xA;y_{2} \ge \frac{1}{{x}_2}, &#xA;\\ \quad \quad \quad\quad \quad y_{1} \ge y_{2} + \frac{1}{{x}_1}, &#xA;\\ \quad \quad \quad\quad \quad y_0 \ge y_{1},  &#xA;\\ \quad \quad \quad\quad \quad a_0 \ge y_0,&#xA;\end{array}&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x,y$&lt;/span&gt; are positive variables and &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; are non-negative constants.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is it possible to solve the problem in a distributed manner through e.g., the ADMM algorithm?&lt;/strong&gt; (note a distributed solution is useful since the original problem is high dimensional, has many more inequality constraints with the same structure, and includes additional &lt;em&gt;separable&lt;/em&gt; equality constraints).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What I have tried:&lt;/strong&gt; We can reformulate the problem with auxiliary variables &lt;span class=&quot;math-container&quot;&gt;$z_1 = y_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_2 = y_2$&lt;/span&gt;, so that:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{array}{l}&#xA;\min_{x,y} \quad \quad \;\;x_{1}a_{1} + x_2a_{2}&#xA;\\ \text {subject to } \quad\; &#xA;y_{2} \ge \frac{1}{{x}_2}, &#xA;\\ \quad \quad \quad\quad \quad y_{1} \ge z_{2} + \frac{1}{{x}_1}, &#xA;\\ \quad \quad \quad\quad \quad y_0 \ge z_{1},  &#xA;\\ \quad \quad \quad\quad \quad a_0 \ge y_0,&#xA;\\ \quad \quad \quad\quad \quad y_2 = z_2,&#xA;\\ \quad \quad \quad\quad \quad y_1 = z_1,&#xA;\end{array}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now the constraints are &amp;quot;separated&amp;quot; and we can have three sets of variables &lt;span class=&quot;math-container&quot;&gt;$(x_2,y_2)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(x_1,y_1,z_2)$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$(y_0,z_1)$&lt;/span&gt;, with three corresponding sub-problems. Does it make sense to proceed this way?&lt;/p&gt;&#xA;&lt;p&gt;I don't really know how to handle inequality constraints since it seems that ADMM is mainly tailored to affine equality constraints. Adding slack variables for any constraint doesn't really work since the inequality constraints are non-affine. &lt;a href=&quot;https://arxiv.org/pdf/1610.02967.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;This paper&lt;/a&gt; generalizes ADMM to non-linear inequality-constrained problems but it seems to complicate the derivation and potentially the solution to the local sub-problems.&lt;/p&gt;&#xA;&lt;p&gt;Maybe ADMM is not really suited to solve this kind of problem. Any idea on better &lt;em&gt;distributed&lt;/em&gt; methods better suited to solve it? I thought of Generalized Benders decomposition but I am not sure how to formulate the problem.&lt;/p&gt;&#xA;" OwnerUserId="5005" LastEditorUserId="500" LastEditDate="2023-04-02T19:53:45.357" LastActivityDate="2023-04-02T19:53:45.357" Title="Distributed optimization with coupled inequality constraints" Tags="|optimization|convex-optimization|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="10007" PostTypeId="1" CreationDate="2023-02-25T13:46:38.917" Score="1" ViewCount="177" Body="&lt;p&gt;We are looking for a tool that can be used by business users where they can do the followings:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;use a simple data modeler to create the classes of data and populate the data instances&lt;/li&gt;&#xA;&lt;li&gt;simple option to tag data elements to be the decision variables / input or output&lt;/li&gt;&#xA;&lt;li&gt;GUI to create the constraints , turn them on/off&lt;/li&gt;&#xA;&lt;li&gt;Configure the solver options&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;We are not into using Excel as a candidate tool, and we are looking for a complete GUI based where the whole activity requires no code at all.&lt;/p&gt;&#xA;" OwnerUserId="11340" LastActivityDate="2023-08-26T13:21:02.050" Title="GUI Optimization tool for business users" Tags="|optimization|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10008" PostTypeId="1" CreationDate="2023-02-26T18:57:24.470" Score="1" ViewCount="170" Body="&lt;p&gt;Sorry if this is off-topic, but can anyone recommend some resources to find trivia facts about operations research? Like the fact that Abraham Lincoln had to solve a 14-city TSP as a lawyer, or that Roger Corman studied industrial engineering at Stanford, or the story about George Dantzig solving the two open problems on the blackboard as a grad student?&lt;/p&gt;&#xA;" OwnerUserId="11042" LastActivityDate="2023-02-28T13:29:12.207" Title="Operations research trivia facts" Tags="|history|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10009" PostTypeId="2" ParentId="10008" CreationDate="2023-02-26T19:59:33.067" Score="1" Body="&lt;p&gt;Not sure if this is a trivia fact or a fact about trivia, but Sam Buttrey, associate professor of OR at the Naval Postgraduate School, &lt;a href=&quot;https://pubsonline.informs.org/do/10.1287/LYTX.2021.06.18n/full/&quot; rel=&quot;nofollow noreferrer&quot;&gt;won big&lt;/a&gt; on the trivia quiz show &lt;em&gt;Jeopardy&lt;/em&gt;. (Hopefully my use of the term &amp;quot;trivia&amp;quot; won't result in &lt;em&gt;Jeopardy&lt;/em&gt; fans besieging my house.)&lt;/p&gt;&#xA;&lt;p&gt;It may be stretching the definition of operations research a little, but there's an interesting story about &lt;a href=&quot;https://en.wikipedia.org/wiki/Abraham_Wald&quot; rel=&quot;nofollow noreferrer&quot;&gt;Abraham Wald's work&lt;/a&gt; with the US Army Air Force in WW II.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="7666" LastEditDate="2023-02-28T13:29:12.207" LastActivityDate="2023-02-28T13:29:12.207" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10010" PostTypeId="1" CreationDate="2023-02-26T22:30:31.560" Score="1" ViewCount="140" Body="&lt;p&gt;I’m curious if MILP can be used to optimize portfolio allocations and what inputs, outputs, variables, constraints and objectives are relevant.&lt;/p&gt;&#xA;&lt;p&gt;For example, is a stock’s average price and variance of central interest? Or is a linear trend and variance there more useful?&lt;/p&gt;&#xA;&lt;p&gt;I could see maximizing the expectation and minimizing the variance to be desirable. (Not sure how to express this as a linear constraint) but even so if I stock was bought and didn’t grow, was that useful?&lt;/p&gt;&#xA;&lt;p&gt;Would such a model indicate when to buy and sell and more of just “buy and hold” strategy.&lt;/p&gt;&#xA;&lt;p&gt;I’m very much a novice in this domain!&lt;/p&gt;&#xA;" OwnerUserId="10326" LastActivityDate="2023-02-26T22:30:31.560" Title="How can mixed integer linear programming be used to optimize portfolio allocations?" Tags="|mixed-integer-programming|finance|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="10011" PostTypeId="2" ParentId="10007" CreationDate="2023-02-27T06:20:11.103" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://www.aimms.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AIMMS&lt;/a&gt; could be a viable solution (depending on the number of users and budget) for building interactive GUI for optimization problems.&lt;/p&gt;&#xA;" OwnerUserId="11346" LastActivityDate="2023-02-27T06:20:11.103" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10016" PostTypeId="1" CreationDate="2023-02-28T06:59:26.960" Score="1" ViewCount="99" Body="&lt;p&gt;Variation of the traditional lot-sizing problem - with some additional complexities:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;multiple suppliers (S1, S2, S3), with different procurement lead-time&lt;/li&gt;&#xA;&lt;li&gt;Suppliers have to be allocated based on a fixed proportion (e.g. 30%, 30%, 40%)&lt;/li&gt;&#xA;&lt;li&gt;Each supplier has a minimum order quantity (MOQ) (e.g. 12, 15, 15)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Rest of the problem is similar to traditional lot-sizing models.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Planning horizon of T days&lt;/li&gt;&#xA;&lt;li&gt;No capacity constraints&lt;/li&gt;&#xA;&lt;li&gt;Demand for all T days are known, demand cannot be delayed.&lt;/li&gt;&#xA;&lt;li&gt;Holding (h) and ordering costs(o) are constant over T and also for all suppliers.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I want to check if there are any well known heuristics that allow for fast and close to optimal solutions.&lt;/p&gt;&#xA;&lt;p&gt;I can use a MILP formulation+solver, but would like to avoid that if possible.&lt;/p&gt;&#xA;" OwnerUserId="7686" LastActivityDate="2024-04-02T23:07:05.840" Title="Single item unconstrained lot-sizing with multiple suppliers and minimum order quantities" Tags="|linear-programming|dynamic-programming|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10017" PostTypeId="2" ParentId="10000" CreationDate="2023-02-28T07:04:07.107" Score="2" Body="&lt;p&gt;Assume you want to solve&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;min &amp;amp; c^T x \\&#xA;st  &amp;amp; A  x = b \\&#xA;    &amp;amp; x \geq 0&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For any dual feasible solution &lt;span class=&quot;math-container&quot;&gt;$(\hat y,\hat s)$&lt;/span&gt; it holds&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\hat s = c - A^T \hat y \geq 0.&#xA;$$&lt;/span&gt;&#xA;Next assume &lt;span class=&quot;math-container&quot;&gt;$c^Tx \leq \hat z$&lt;/span&gt;  for all feasible x, then clearly&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c^T x - \hat y^T \hat A x = c^T x - b^T \hat y \leq \hat z - b^T\hat y&#xA;$$&lt;/span&gt;&#xA;holds for all feasible &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. This implies&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c^T x - \hat y^T \hat A x = (c - A^T \hat y)^T x = \hat s^T x \leq  \hat z - b^T \hat y.&#xA;$$&lt;/span&gt;&#xA;Given &lt;span class=&quot;math-container&quot;&gt;$x \geq 0$&lt;/span&gt; we conclude&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\hat s_j^T x_j \leq  \hat z - b^T \hat y.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is how I explain how to obtain bounds on primal variables from a dual feasible solution and an upper bound on the objective value.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2023-02-28T08:31:49.023" LastActivityDate="2023-02-28T08:31:49.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10018" PostTypeId="1" CreationDate="2023-02-28T23:35:18.537" Score="4" ViewCount="245" Body="&lt;p&gt;I have an optimization problem with vectors &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is an integer vector. My objective function is linear (i.e. &lt;span class=&quot;math-container&quot;&gt;$\|y\|_1$&lt;/span&gt;), but one of my constraints is quadratic (&lt;span class=&quot;math-container&quot;&gt;$x^Ty \leq z$&lt;/span&gt;). The other constraints are all linear. In addition, I have equality and inequality constraints. What methods are there to optimize this?&lt;/p&gt;&#xA;&lt;p&gt;I see two options:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Convex optimization methods (but they might be inefficient, given that my loss is linear.&lt;/li&gt;&#xA;&lt;li&gt;Use methods for quadratic objectives and just use them with linear objective functions.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Google mostly lists proprietary software instead of papers to read.&lt;/p&gt;&#xA;&lt;p&gt;Any better suggestions that are explicitly made for QCMILP (quadratically constrained mixed integer linear programs?&lt;/p&gt;&#xA;" OwnerUserId="10594" LastEditorUserId="491" LastEditDate="2023-03-02T12:36:02.983" LastActivityDate="2023-07-30T13:06:50.807" Title="Solver for quadratically constrained mixed-integer linear programs" Tags="|mixed-integer-programming|linear-programming|convex-optimization|quadratic-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10019" PostTypeId="2" ParentId="10018" CreationDate="2023-03-01T00:01:51.797" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360013156432-What-types-of-models-can-Gurobi-solve-&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi&lt;/a&gt; can solve mixed integer quadratically constrained problems provided that your known values in the quadratic constraint form positive semidefinite matrix. You'd need to use &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/cs_model_addqconstr.html#:%7E:text=Important%20note%3A%20Gurobi%20can%20handle,and%20non%2Dconvex%20quadratic%20constraints.&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quadratic Constraint&lt;/a&gt; to model the constraints. Gurobi will &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/10535497087633-help-with-the-log-of-a-mixed-integer-quadratically-contrained-problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;linearly relax&lt;/a&gt; using either interior points or outer approximation.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-01T00:14:27.150" LastActivityDate="2023-03-01T00:14:27.150" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10020" PostTypeId="1" CreationDate="2023-03-01T07:31:52.243" Score="1" ViewCount="582" Body="&lt;p&gt;I want to solve a large scale non linear optimization problem and there are two methods interior point method and sequential quadric programing usually used to solve non linear optimization problem. I need suggestions regarding these methods which to use in term of implementation.&lt;/p&gt;&#xA;" OwnerUserId="11366" LastActivityDate="2023-03-01T10:38:38.297" Title="Non linear programming" Tags="|nonlinear-programming|nonconvex-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10021" PostTypeId="1" AcceptedAnswerId="10027" CreationDate="2023-03-01T09:42:17.440" Score="1" ViewCount="83" Body="&lt;p&gt;I need to solve a CSP with a constraint imposing upper bounds on the multiplicity of variables in a list.&#xA;More precisely, I need a constraint of the form&#xA;&lt;code&gt;multiplicity(VARIABLES,UPPER_BOUNDS)&lt;/code&gt;, where &lt;code&gt;VARIABLES&lt;/code&gt; is a list of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables and &lt;code&gt;UPPER_BOUNDS&lt;/code&gt; is a list of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; (constant) integers, so that the constraint is satisfied if at most &lt;code&gt;UPPER_BOUNDS[i]&lt;/code&gt; variables take the same value as &lt;code&gt;VARIABLES[i]&lt;/code&gt;, for &lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For example, &lt;code&gt;multiplicity([1,2,2,3,2,1],[2,3,4,1,3,3])&lt;/code&gt; is satisfied but &lt;code&gt;multiplicity([1,2,2,3,2,1],[2,2,4,1,3,3])&lt;/code&gt; fails because the second variable (equal to 2) appears 3 times in the list but has a multiplicity bounded by 2.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I wonder if there is an out-of-the box constraint available in any CP solver to do that?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I am aware of the constraint &lt;code&gt;(,,)&lt;/code&gt; (cf. &lt;a href=&quot;https://sofdem.github.io/gccat/gccat/Catmost.html#uid14762&quot; rel=&quot;nofollow noreferrer&quot;&gt;this ref&lt;/a&gt;), which demands that at most &lt;code&gt;N&lt;/code&gt; variables in the list &lt;code&gt;VARIABLES&lt;/code&gt; take the value &lt;code&gt;VALUE&lt;/code&gt;. What I need is thus a generalization of &lt;code&gt;atmost&lt;/code&gt; allowing the &lt;code&gt;VALUE&lt;/code&gt; to be a variable. Then, the multiplicity constraint could be written as &lt;code&gt;atmost(UPPER_BOUND[i],VARIABLES,VARIABLES[i])&lt;/code&gt;, for &lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,n$&lt;/span&gt;. Is there a CP solver supporting a variant of &lt;code&gt;atmost&lt;/code&gt; allowing a variable in the field &lt;code&gt;VALUE&lt;/code&gt; ?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;At the moment, my best guess was to rewrite the multiplicity constraint as a list of  implications&#xA;&lt;code&gt;VARIABLES[i]=j   implies    atmost(UPPER_BOUND[i],VARIABLES,j)&lt;/code&gt;&#xA;, for all &lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,n$&lt;/span&gt; and all values &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; that the variables can take. In practice the pruning does not seem to be very efficient with this approach. Is there another get-around that would be more efficient?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11368" LastEditorUserId="491" LastEditDate="2023-03-02T12:35:09.747" LastActivityDate="2023-03-02T12:35:09.747" Title="Multiplicity-Constraint in Constraint Programming Solvers" Tags="|constraint|constraint-programming|or-tools|minizinc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10022" PostTypeId="2" ParentId="10020" CreationDate="2023-03-01T10:22:10.563" Score="3" Body="&lt;p&gt;Sequential quadratic programming methods are mainly useful for problems with expensive evaluations. They can also be relevant in some cases if a good initial point is available.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, interior point methods are suited for large-scale problems with cheaper evaluations.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, you can try an interior point method first. But do not hesitate to compare both on your problem. And unless you really want to implement them yourself, you should rather just write models for solvers that already implement them. Then, you can easily switch between different algorithms.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-03-01T10:22:10.563" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10023" PostTypeId="2" ParentId="10020" CreationDate="2023-03-01T10:38:38.297" Score="1" Body="&lt;p&gt;As @fontanf said, you're better off writing a mathematical model (AMPL, GAMS, JuMP, Pyomo, etc) and call an existing solver. There are extremely robust solvers out there (e.g. filterSQP and IPOPT), it would be a shame to reinvent the wheel.&lt;br /&gt;&#xA;Should you decide to implement your own solver anyway, you can check out the code of my modern C++ solver &lt;a href=&quot;https://github.com/cvanaret/Uno&quot; rel=&quot;nofollow noreferrer&quot;&gt;Uno&lt;/a&gt; (Unifying Nonlinear Optimization).&lt;/p&gt;&#xA;" OwnerUserId="10561" LastActivityDate="2023-03-01T10:38:38.297" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10024" PostTypeId="1" CreationDate="2023-03-01T13:11:47.730" Score="2" ViewCount="76" Body="&lt;p&gt;suppose that decision variable is &lt;code&gt;X&lt;/code&gt; with &lt;code&gt;N&lt;/code&gt; dimensions, and one type of the constraint is &lt;code&gt;y = y0-sum(max(0,x)*b)-sum(min(0,x)*a)&lt;/code&gt;, where the dimension of &lt;code&gt;x&lt;/code&gt; is from 1 to &lt;code&gt;N&lt;/code&gt; which means that there are &lt;code&gt;N&lt;/code&gt; constraints, and the &lt;code&gt;y&lt;/code&gt; should be less than &lt;code&gt;y_min&lt;/code&gt; and be greater than &lt;code&gt;y_max&lt;/code&gt;, i.e. &lt;code&gt;y_min &amp;lt;= y0-sum(max(0,x)*b)-sum(min(0,x)*a) &amp;lt;= y_max&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In &lt;code&gt;cvxpy&lt;/code&gt;, it could be write as &lt;code&gt;y0 - cp.sum(cp.pos(x[:i])*b) + cp.sum(cp.neg(x[:i])*a)&lt;/code&gt;,&lt;/p&gt;&#xA;&lt;p&gt;however, &lt;code&gt;-cp.sum(cp.pos(x[:i])*b)&lt;/code&gt; is a &lt;code&gt;concave&lt;/code&gt; expression, &lt;code&gt;cp.sum(cp.neg(x[:i])*a)&lt;/code&gt; is a &lt;code&gt;convex&lt;/code&gt; expression, and the sum of them would not satisfy the DCP rule.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to rewrite this type of constraint to follow the DCP rule?&lt;/p&gt;&#xA;&lt;p&gt;(although we could use &lt;code&gt;dccp&lt;/code&gt; to solve it.)&lt;/p&gt;&#xA;" OwnerUserId="11370" LastActivityDate="2023-03-01T13:11:47.730" Title="How to rewrite a constraint with sum of convex and concave components to satisfy DCP rule?" Tags="|mixed-integer-programming|cvxpy|disciplined-convex-programming|cbc|scip|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10025" PostTypeId="1" CreationDate="2023-03-01T15:14:39.020" Score="0" ViewCount="115" Body="&lt;p&gt;I have an lp and am trying to solve multiple scenarios at once. One of my scenarios is infeasible though this is not the issue.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/C1Sv3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/C1Sv3.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;For some reason, when I print m.status, both solutions have a status of 2 (Optimal) and the lp files are identical, despite me having changed the rhs in scenario 1. It looks like the changes I made in scenario 1 follow through to the solver but I cannot physically see them in the lp file and the model status seems to be incorrect. If I run scenario 1 by itself, the status prints out correctly as 4 (Infeasible) but the lp file still doesn't reflect the changes I made.&lt;/p&gt;&#xA;&lt;p&gt;Has anyone experienced this before and is there anything I can do to correct this issue?&lt;/p&gt;&#xA;" OwnerUserId="10747" LastEditorUserId="491" LastEditDate="2023-03-02T12:34:45.307" LastActivityDate="2023-03-02T12:34:45.307" Title="Multi-Scenario Gurobi Python Output" Tags="|optimization|linear-programming|python|gurobi|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10027" PostTypeId="2" ParentId="10021" CreationDate="2023-03-01T17:07:12.747" Score="3" Body="&lt;p&gt;What &amp;quot;special&amp;quot; constraints a CP solver provides tends to vary by solver. I think it is fairly common, though, for CP solvers to treat logical expressions as equivalent to binary variables. So if &lt;span class=&quot;math-container&quot;&gt;$x[]$&lt;/span&gt; is your vector of variables and &lt;span class=&quot;math-container&quot;&gt;$b[]$&lt;/span&gt; your vector of upper bounds, you could write something like &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\neq i}(x[i] == x[j]) \le b[i].$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-01T17:07:12.747" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10029" PostTypeId="2" ParentId="10001" CreationDate="2023-03-01T19:40:04.257" Score="0" Body="&lt;p&gt;This open-source software solver can handle stochastic programming problems, including the scenario approach. PySP is a python based modeling framework for stochastic programming that allows us to easily implement and solve stochastic optimization problems using a variety of solvers. Another popular solver for stochastic programming problems includes AMPL &amp;amp; GAMS. As stated above if you are having access to a suitable solver then using SAA methods we can efficiently solve this problem without having to solve the minimum cost flow problem multiple times.&lt;/p&gt;&#xA;" OwnerUserId="11375" LastActivityDate="2023-03-01T19:40:04.257" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10030" PostTypeId="1" CreationDate="2023-03-01T21:08:08.650" Score="1" ViewCount="59" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; be two variables, and &lt;span class=&quot;math-container&quot;&gt;$Q_\min$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q_\max$&lt;/span&gt; be two parameters. I need a series of linear constraints to define &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; vis-a-vis the value of &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; based on the following rules:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$K \le Q_\min$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$Q = Q_\min$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$K \ge Q_\max$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$Q = Q_\max$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$Q_\min \le K \le Q_\max$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$Q = K$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11376" LastEditorUserId="11376" LastEditDate="2023-03-02T04:38:36.407" LastActivityDate="2023-03-02T04:38:36.407" Title="Linearize constraints on a truncated variable" Tags="|linear-programming|linearization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10031" PostTypeId="2" ParentId="10030" CreationDate="2023-03-01T21:31:09.787" Score="2" Body="&lt;p&gt;Assume &lt;span class=&quot;math-container&quot;&gt;$K_\min \le K \le K_\max$&lt;/span&gt;, and introduce binary decision variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; for the three cases (reordered as 1, 3, 2), together with linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i=1}^3 x_i &amp;amp;= 1 \tag1\label1 \\&#xA;K_\min x_1 + Q_\min x_2 + Q_\max x_3 \le K &amp;amp;\le Q_\min x_1 + Q_\max x_2 + K_\max x_3 \tag2\label2 \\ &#xA;Q_\min \le Q &amp;amp;\le Q_\min x_1 + Q_\max(1-x_1) \tag3\label3 \\&#xA;(Q_\min-K_\max)(1-x_2) \le Q - K &amp;amp;\le (Q_\max-K_\min)(1-x_2) \tag4\label4 \\&#xA;Q_\max x_3 + Q_\min(1-x_3) \le Q &amp;amp;\le Q_\max \tag5\label5&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} selects exactly one case.&#xA;Constraint \eqref{2} enforces the bounds on &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; for each case.&#xA;Constraints \eqref{3} through \eqref{5} enforce the value of &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; for each case.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;You could alternatively replace \eqref{3} through \eqref{5} with indicator constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_1 = 1 &amp;amp;\implies Q = Q_\min \\&#xA;x_2 = 1 &amp;amp;\implies Q = K \\&#xA;x_3 = 1 &amp;amp;\implies Q = Q_\max&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Yet another approach is to recognize that &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is a nonconvex and nonconcave continuous piecewise linear function of &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; and use any formulation for that, such as the ones recommended in the answers to &lt;a href=&quot;https://or.stackexchange.com/questions/6674/how-to-linearize-specific-range-constraints&quot;&gt;How to linearize specific range constraints?&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-02T01:12:14.297" LastActivityDate="2023-03-02T01:12:14.297" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10032" PostTypeId="1" CreationDate="2023-03-02T22:21:18.653" Score="0" ViewCount="68" Body="&lt;p&gt;Consider the following trivial, theoretical model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max x+2y+3z \qquad s.t.&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x \leq b_x&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y \leq b_y&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z \leq b_z&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x+y+z = 1&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x,y,z \in \{0, 1\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and &lt;span class=&quot;math-container&quot;&gt;$b_x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_z$&lt;/span&gt; integer, non-negative parameters. Whenever the parameter &lt;span class=&quot;math-container&quot;&gt;$b_z \geq 1$&lt;/span&gt; the trivial solution would be &lt;span class=&quot;math-container&quot;&gt;$z=1, x=y=0$&lt;/span&gt;. Let us assume I have hypotethical reasons to &amp;quot;prefer&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;; say, when &lt;span class=&quot;math-container&quot;&gt;$b_x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_z$&lt;/span&gt; are greater/equal 1, return &lt;span class=&quot;math-container&quot;&gt;$x=1, y=z=0$&lt;/span&gt; as solution. In other words, &lt;strong&gt;I would maximize the objective function under a &amp;quot;preference constraint&amp;quot; on variables. Is it possible to express such a constraint as a MIP/MILP?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For example, imposing &lt;span class=&quot;math-container&quot;&gt;$z \leq x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y \leq z$&lt;/span&gt; would do the trick when both &lt;span class=&quot;math-container&quot;&gt;$b_x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_z$&lt;/span&gt; are greater/equal 1, but when &lt;span class=&quot;math-container&quot;&gt;$b_x = 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_z \geq 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_y \geq 1$&lt;/span&gt; it would return &lt;span class=&quot;math-container&quot;&gt;$x=y=z=0$&lt;/span&gt;, whereas the optimal solution for me according to my preference would be &lt;span class=&quot;math-container&quot;&gt;$z=1, x=y=0$&lt;/span&gt;. Similarly, with &lt;span class=&quot;math-container&quot;&gt;$b_x = b_z = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_y\geq 1$&lt;/span&gt; the optimal solution from solving the problem would be again &lt;span class=&quot;math-container&quot;&gt;$x=y=z=0$&lt;/span&gt; whereas what I want according to my preference would be &lt;span class=&quot;math-container&quot;&gt;$y=1, x=z=0$&lt;/span&gt;. So my attempt &lt;span class=&quot;math-container&quot;&gt;$z \leq x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y \leq z$&lt;/span&gt;  clearly does not work.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for a generalizable solution for any number of variables and any preference, not just for a solution to this specific case.&lt;/p&gt;&#xA;" OwnerUserId="459" LastEditorUserId="459" LastEditDate="2023-03-02T22:49:25.313" LastActivityDate="2023-03-02T23:06:50.147" Title="Maximization problem with preferences on variables" Tags="|mixed-integer-programming|modeling|integer-programming|constraint|logical-constraints|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10033" PostTypeId="2" ParentId="10032" CreationDate="2023-03-02T22:36:36.590" Score="1" Body="&lt;p&gt;How is this following constraint&lt;br /&gt;&#xA;Either&#xA;&lt;span class=&quot;math-container&quot;&gt;$b_z + y \le b_x+z +b_y\le x + b_z +yb_y$&lt;/span&gt;&#xA;Or let's break it&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$b_x+z \le x + b_z$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$b_z + y \le z +b_y $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-02T23:06:50.147" LastActivityDate="2023-03-02T23:06:50.147" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10034" PostTypeId="1" AcceptedAnswerId="10035" CreationDate="2023-03-03T01:13:12.490" Score="0" ViewCount="173" Body="&lt;p&gt;I want to model a problem that one of my variables needs to be used as an index of a dictionary in my constraints. Here is a minimal code that shows an example situation:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;&#xA;# Create a new Gurobi model&#xA;m = gp.Model()&#xA;&#xA;my_dict = {1: 2, 3: 4, 5: 6}&#xA;# Create decision variables&#xA;x = m.addVar(name=&amp;quot;x&amp;quot;)&#xA;m.update()&#xA;# Set objective function&#xA;m.setObjective(x, gp.GRB.MINIMIZE)&#xA;&#xA;# Add constraints&#xA;m.addConstr(my_dict[x] &amp;gt;= 1, name=&amp;quot;c1&amp;quot;)&#xA;&#xA;# Optimize the model&#xA;m.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;in this example variable x in the constraint is used as the index of my_dict dictionary. However, the above code will result in the following error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;KeyError: &amp;lt;gurobi.Var x&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there a workaround to solve this and be able to use variables as indexes?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Another thing I also need for the above formulation is to be able to bound value of varialbe dicts to keys in the my_dict, e.g. if there were some options like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.addVar(name='x', vtype=GRB.INTEGER, set=list(my_dict.keys()))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Is there a solution to this for bounding values to a specific set?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11380" LastEditorUserId="11380" LastEditDate="2023-03-03T11:28:01.210" LastActivityDate="2023-03-06T05:28:09.570" Title="How to use Gurobi variables as a dictionary index in Gurobipy" Tags="|gurobi|gurobipy|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10035" PostTypeId="2" ParentId="10034" CreationDate="2023-03-03T01:39:17.013" Score="-1" Body="&lt;p&gt;First bounding of your vector variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; over dict key set &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{i\in I} iz_i = x$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_i z_i = 1$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is binary.&lt;/p&gt;&#xA;&lt;p&gt;The above 2 bounds &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to choose from &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; and to use:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in I} z_iD_i$&lt;/span&gt; where D is your dict.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Sample code&lt;/strong&gt; below&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;D ={1:3, 2:5, 6:3.5, 8:4.2, 6:5.2}&#xA;model = Model('Index')&#xA;x = model.addVar(name='x')&#xA;z = model.addVars(D,vtype='b',name='z')&#xA;&#xA;# constraints&#xA;C1 = model.addConstr(quicksum(d*z[d] for d in D) == x,name='C1')&#xA;C2 = model.addConstr(z.sum()==1, name='C2')&#xA;C3 = model.addConstr(quicksum(z[d]*D[d] for d in D) &amp;gt;= 2,name='C3')&#xA;&#xA;obj = x&#xA;#obj = quicksum(z[d]*D[d] for d in D)&#xA;model.setObjective(obj,GRB.MAXIMIZE)&#xA;model.update()&#xA;model.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-05T21:48:35.963" LastActivityDate="2023-03-05T21:48:35.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10036" PostTypeId="1" CreationDate="2023-03-03T11:02:40.503" Score="1" ViewCount="117" Body="&lt;p&gt;I am working on implementing the interior point method, and the barrier function always gives me a complex number.  B(x) = f(x) - t * sum(ln(hi(x))). I have changed the value of 't' to see the B(x) behavior, but it's not responding. My hi(x) has small values of {10^-14}. Is there any way to deal with the issue?&lt;/p&gt;&#xA;" OwnerUserId="11366" LastActivityDate="2023-03-17T15:32:51.417" Title="My barrier function is always giving a complex number" Tags="|nonlinear-programming|nonconvex-programming|interior-point-method|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10038" PostTypeId="1" AcceptedAnswerId="10039" CreationDate="2023-03-04T02:24:11.590" Score="2" ViewCount="499" Body="&lt;p&gt;I want to use the sum of two binary decision variables (when their sum equals to one) as the condition of Model.AddGenConstrIndicator &lt;a href=&quot;https://www.gurobi.com/documentation/current/refman/py_model_agc_indicator.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/current/refman/py_model_agc_indicator.html&lt;/a&gt;, however, it seems to be impossible, e.g. for the minimal code below which reflects the relevant part of my real problem trying the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;&#xA;model = gp.Model()&#xA;&#xA;x = model.addVar(vtype=gp.GRB.BINARY, name=&amp;quot;x&amp;quot;)&#xA;y = model.addVar(vtype=gp.GRB.BINARY, name=&amp;quot;y&amp;quot;)&#xA;&#xA;z = model.addVar(vtype=gp.GRB.CONTINUOUS, name=&amp;quot;z&amp;quot;)&#xA;&#xA;model.update()&#xA;constr = model.addConstr((x + y == 1) &amp;gt;&amp;gt; (z &amp;lt;= 20))&#xA;&#xA;model.setObjective(z, gp.GRB.MAXIMIZE)&#xA;&#xA;# Solve the model&#xA;model.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Will result in the following error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    constr = model.addConstr((x + y == 1) &amp;gt;&amp;gt; (z &amp;lt;= 20))&#xA;  File &amp;quot;src/gurobipy/model.pxi&amp;quot;, line 3632, in gurobipy.Model.addConstr&#xA;gurobipy.GurobiError: Indicator constraints can only be triggered by a single binary variable at a given value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is there a workaround for this?&lt;/p&gt;&#xA;" OwnerUserId="11380" LastEditorUserId="500" LastEditDate="2023-03-04T02:55:58.620" LastActivityDate="2023-03-07T12:38:33.990" Title="Using indicator constraint with two variables" Tags="|gurobi|indicator-constraints|gurobipy|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10039" PostTypeId="2" ParentId="10038" CreationDate="2023-03-04T02:55:26.713" Score="5" Body="&lt;p&gt;You want to enforce &lt;span class=&quot;math-container&quot;&gt;$x+y=1 \implies z \le 20$&lt;/span&gt;.  Introduce a new binary variable &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x+y = 1 &amp;amp;\implies w = 1 \tag1\label1\\&#xA;w = 1 &amp;amp;\implies z \le 20 \tag2\label2\\&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{2} is already an indicator constraint.&#xA;The contrapositive of \eqref{1} is &lt;span class=&quot;math-container&quot;&gt;$w \not= 1 \implies x+y \not= 1$&lt;/span&gt;,&#xA;which you can rewrite as an indicator constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w = 0 \implies x+y = 2v \tag3\label3,$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is a binary variable.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, you can rewrite \eqref{1} in conjunctive normal form to somewhat automatically derive linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;((x \land \lnot y) \lor (\lnot x \land y)) \implies w \\&#xA;\lnot ((x \land \lnot y) \lor (\lnot x \land y)) \lor w \\&#xA;(\lnot (x \land \lnot y) \land \lnot (\lnot x \land y)) \lor w \\&#xA;((\lnot x \lor y) \land (x \lor \lnot y)) \lor w \\&#xA;(\lnot x \lor y \lor w) \land (x \lor \lnot y \lor w) \\&#xA;(1 - x + y + w \ge 1) \land (x + 1 - y + w \ge 1) \\&#xA;(w \ge x - y) \land (w \ge y - x)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-04T03:42:06.347" LastActivityDate="2023-03-04T03:42:06.347" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10040" PostTypeId="2" ParentId="9976" CreationDate="2023-03-04T12:23:39.450" Score="0" Body="&lt;p&gt;From the modeling language point of view, the above disjunctive form can be written by CPLEX in the following form:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  c1: (y1==1 &amp;amp;&amp;amp; x&amp;gt;=2) || (y2==1 &amp;amp;&amp;amp; x&amp;gt;=3);&#xA;  c2: (y3==1 &amp;amp;&amp;amp; x&amp;lt;=8) || (y4==1 &amp;amp;&amp;amp; x==2.5);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  c1: (y1==1 || y2==1);&#xA;  c2: (y3==1 || y4==1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and adding appropriate linearization constraints.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-03-04T12:23:39.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10041" PostTypeId="1" CreationDate="2023-03-04T17:40:44.117" Score="0" ViewCount="184" Body="&lt;p&gt;I would like to write the following simple model in GurobiPy, which is part of many terms that's belongs to the objective function, I assumed that I have three suppliers are selected and three warehouses are opened, where &lt;span class=&quot;math-container&quot;&gt;$QS_{swpt}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Q_{whpt}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$QU_{whpt}$&lt;/span&gt;.are CONTINUOUS decicison variables. &lt;span class=&quot;math-container&quot;&gt;$S_{st}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$W_{wt}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$G_{gt}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$O_{ot}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L_{lt}$&lt;/span&gt; are BINARY decision variables, I have tried a toy instance by hand and on GurobiPy but, the results from the latter was wrong, I would like to know a rule of thumb to model such problems, or any resource that explain how to model similar and advanced problems.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is the time.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; are the suppliers.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; are the warehouses.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; are the products.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$COF= \sum_ {t}\sum_{s}FS_{st}*S_st+\sum_ {t}\sum_{w}FW_{wt}*W_{wt}+\sum_ {t}\sum_{g}FG_{gt}*G_{gt}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$+\sum_ {t}\sum_{o}FO_{ot}*O_{ot}+\sum_ {t}\sum_{l}FL_{lt}*L_{lt}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ OCS= \sum_{t}\sum_{s}\sum_{w}\sum_{p}QS_{swpt}(MC_{spt}+TS_{swpt}) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$PCS=\sum_{t}\sum_{s}\sum_{w}\sum_{p}KW_{wpt}*Y_{wt}+QS_{swpt}*c_{spt}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$CIW=\sum_{t}\sum_{s}\sum_{w}\sum_{p}QW_{whpt}*[I_{wt}+HCW_{wt}+TW_{wpht}*(\boldsymbol{1-\bar{p}})]$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$SCH=\sum_{t}\sum_{w}\sum_{h}\sum_{p}QU_{whpt}*p_{ht}$$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$Minimize\; Z = COF+OCS+PCS+CIW+SCH$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Contiuous Decision Variables&#xA;    QS_swpt= m.addVar(vtype=GRB.CONTINUOUS, name=&amp;quot;QS_swpt&amp;quot;, lb=0)&#xA;    QW_whpt= m.addVar(vtype=GRB.CONTINUOUS, name=&amp;quot;QW_whpt&amp;quot;, lb=0 )&#xA;    QW_gpt= m.addVar(vtype=GRB.CONTINUOUS, name= &amp;quot;QW_gpt&amp;quot;, lb=0)&#xA;    QU_whpt=m.addVar(vtype=GRB.CONTINUOUS, name= &amp;quot;QU_whpt&amp;quot;, lb=0)&#xA;#Binary Decision Variables&#xA;    Y_wt= m.addVar(vtype=GRB.BINARY, name=&amp;quot;Y_wt&amp;quot;)&#xA;    S_st=m.addVar(vtype=GRB.BINARY, name=&amp;quot;S_st&amp;quot;)&#xA;    W_wt= m.addVar(vtype=GRB.BINARY, name=&amp;quot;W_wt&amp;quot;)&#xA;    G_gt=m.addVar(vtype=GRB.BINARY, name=&amp;quot;G_gt&amp;quot;)&#xA;    O_ot=m.addVar(vtype=GRB.BINARY, name=&amp;quot;O_ot&amp;quot;)&#xA;    L_lt=m.addVar(vtype=GRB.BINARY, name=&amp;quot;L_lt&amp;quot;)&#xA;#Modelling the objective Function.&#xA;    COF=  quicksum(FS_st[s]*S_st for s in FS_st for sp in S for t in Time)\&#xA;            + quicksum(FW_wt[w]*W_wt for w in FW_wt for wr in W for t in Time)\&#xA;            + quicksum(FG_gt[g]*G_gt for g in FG_gt for gs in G  for t in Time)\&#xA;            + quicksum(FO_ot[o]*O_ot for o in FO_ot for om in O for t in Time)\&#xA;            + quicksum(FL_lt[l]*L_lt for l in FL_lt for lf in L for t in Time)&#xA;    OCS= quicksum(QS_swpt*(MC_spt[p]) for p in MC_spt for w in W for t in Time )\&#xA;            + quicksum(QS_swpt*(TS_swt[s]) for s in TS_swt for w in W for t in Time )&#xA;    PCS = quicksum(KW_wpt[k]* Y_wt for k in KW_wpt for w in W for t in Time)\&#xA;              + quicksum(c_st[c] for c in c_st for w in W for t in Time)&#xA;    CIW =  quicksum(QW_swpt[qs]*(I_wt[i]) for i in I_wt for s in S for qs in QW_swpt for t in Time)\&#xA;              + quicksum((QW_whpt[qs]*HCW_wt[hc]) for hc in HCW_wt for s in S for qs in QW_whpt for t in Time )\&#xA;              + quicksum(QW_whpt[qw]*(TW_whpt[ts]*(p_bc)) for ts in TW_whpt for w in W for qw in QW_whpt for t in Time)&#xA;    SCH= quicksum(QU_whpt[qu]*p_ht[ph] for ph in p_ht for u in W for qu in QU_whpt for t in Time)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11004" LastEditorUserId="11004" LastEditDate="2023-03-05T14:24:23.323" LastActivityDate="2023-03-05T14:24:23.323" Title="Modelling with Gurobi-Python a Supply Chain Problem" Tags="|optimization|mixed-integer-programming|python|gurobi|supply-chain|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10042" PostTypeId="2" ParentId="10038" CreationDate="2023-03-05T09:52:36.233" Score="0" Body="&lt;p&gt;I think what you need in a code is actually something like:&#xA;(The first constraint actually comes from my last comment)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = gp.Model()&#xA;&#xA;x = model.addVar(vtype=gp.GRB.BINARY, name=&amp;quot;x&amp;quot;)&#xA;y = model.addVar(vtype=gp.GRB.BINARY, name=&amp;quot;y&amp;quot;)&#xA;w = model.addVar(vtype=gp.GRB.INTEGER, name=&amp;quot;w&amp;quot;)&#xA;&#xA;z = model.addVar(lb=0, ub=20, vtype=gp.GRB.CONTINUOUS, name=&amp;quot;z&amp;quot;)&#xA;&#xA;constr = model.addConstr(x + y &amp;gt;= 1 - w)&#xA;constr = model.addConstr((w == 1) &amp;gt;&amp;gt; (z &amp;lt;= 20))&#xA;model.setObjective(z, gp.GRB.MAXIMIZE)&#xA;&#xA;&#xA;# Solve the model&#xA;model.update()&#xA;model.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;pre&gt;&lt;code&gt;Optimize a model with 1 rows, 4 columns and 3 nonzeros&#xA;Model fingerprint: 0xcf4a20b1&#xA;Model has 1 general constraint&#xA;Variable types: 1 continuous, 3 integer (2 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [1e+00, 1e+00]&#xA;  Objective range  [1e+00, 1e+00]&#xA;  Bounds range     [1e+00, 2e+01]&#xA;  RHS range        [1e+00, 1e+00]&#xA;  GenCon rhs range [2e+01, 2e+01]&#xA;  GenCon coe range [1e+00, 1e+00]&#xA;Found heuristic solution: objective 20.0000000&#xA;&#xA;Explored 0 nodes (0 simplex iterations) in 0.01 seconds (0.00 work units)&#xA;Thread count was 1 (of 2 available processors)&#xA;&#xA;Solution count 1: 20 &#xA;&#xA;Optimal solution found (tolerance 1.00e-04)&#xA;Best objective 2.000000000000e+01, best bound 2.000000000000e+01, gap 0.0000%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also, as the second attempt I try to use two indicator variables as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ w_{1}=1 \quad \Longleftrightarrow \quad x+y=1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ w_{2}=1 \quad \Longleftrightarrow \quad z\leq 20$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ w_{1}=1 \implies w_{2}=1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The linearization of the constraints would be:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ w_{1}=1 \implies (x+y=1) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \lnot(w_{1}) \lor ((x \land \lnot y) \lor (\lnot x \land y)) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ ((1-w_{1}) \lor x \lor \lnot y)) \land ((1-w) \lor \lnot x \lor y)) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ ((1-w_{1}) + x + (1-y) \land ((1-w) + (1-x) + y)) \quad (1) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (x+y=1) \implies w_{1}=1 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (1 - x + y + w \ge 1) \land (x + 1 - y + w \ge 1) \quad \text{from Rob's answer} \quad (2) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ w_{2}=1 \Longleftrightarrow z\leq 20$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z + (UB+\epsilon)w_{2} \geq (UB+\epsilon) \quad (3)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ w_{1} \leq w_{2} \quad (4)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-03-07T12:38:33.990" LastActivityDate="2023-03-07T12:38:33.990" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="10043" PostTypeId="2" ParentId="10041" CreationDate="2023-03-05T12:31:03.173" Score="1" Body="&lt;p&gt;One possible way is by defining each part of the objective function separately and finally collecting them in an objective method. For example, suppose there are two different terms in the object as &lt;span class=&quot;math-container&quot;&gt;$\sum_{i} P_{i}x_{i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_{i} \sum_{j} C_{i,j}y_{i,j}$&lt;/span&gt; , then a simple template would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;I = 10&#xA;J = 10&#xA;P = np.random.rand(I)&#xA;C = np.random.rand(I,J)&#xA;&#xA;m = gp.Model()&#xA;&#xA;x = m.addVars(I)&#xA;y = m.addVars(I,J)&#xA;&#xA;part_1= gp.quicksum(P[i] * x[i] for i in range(I))   &#xA;part_2= gp.quicksum(C[i, j] * y[i, j] for i in range(I) for j in range(J))&#xA;objective= part_1 - part_2&#xA;m.setObjective(objective, GRB.MINIMIZE)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-03-05T12:31:03.173" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10044" PostTypeId="2" ParentId="10041" CreationDate="2023-03-05T14:00:50.560" Score="0" Body="&lt;p&gt;Sample variable declaration and use in expressions or constraints\&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    QS_swpt =model addVars((S,W,P,T))# lb=o, vtype='c' is by default&#xA;    #similary for binary&#xA;    Y_wt= model.addVars((W,T),vtype='b') # S is set/list of suppliers,\&#xA;# T is list of time periods, W is list of warehouses. You can also make combinations like SWPT a list/set of tuples or tuplelist like [(s,w,p,t) for s in S for p in P for w in W]. In that case your variable declaration will be like mode.addVars(SWPT)&#xA;    &#xA;    # then expressions like OCS&#xA;    OCS= gp.quicksum(QS_swpt[s,w,p,t](MC_[s,p,t]+TS_swpt[s,w,p,t]) for p in products for w in warehouses for s in supplier for t in time)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-03-05T14:00:50.560" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10045" PostTypeId="1" AcceptedAnswerId="10046" CreationDate="2023-03-05T20:29:14.890" Score="0" ViewCount="66" Body="&lt;p&gt;I want to know how I can check constraints like &lt;a href=&quot;https://www.gurobi.com/documentation/current/refman/py_model_agc_indicator.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/current/refman/py_model_agc_indicator.html&lt;/a&gt; in my model using something like &lt;code&gt;model.disply()&lt;/code&gt; function. E.g. for the following dummy example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;&#xA;model = gp.Model()&#xA;&#xA;x = model.addVar(vtype=gp.GRB.BINARY, name=&amp;quot;x&amp;quot;)&#xA;y = model.addVar(vtype=gp.GRB.BINARY, name=&amp;quot;y&amp;quot;)&#xA;a = model.addVar(vtype=gp.GRB.BINARY, name=&amp;quot;a&amp;quot;)&#xA;&#xA;&#xA;z = model.addVar(vtype=gp.GRB.CONTINUOUS, name=&amp;quot;z&amp;quot;, ub=30)&#xA;model.addGenConstrAnd(a, [x, y], &amp;quot;andconstr&amp;quot;)&#xA;&#xA;model.update()&#xA;&#xA;# constr1 = model.addConstr(z &amp;lt;= 20)&#xA;constr2 = model.addConstr((a == 0) &amp;gt;&amp;gt; (z &amp;lt;= 5))&#xA;&#xA;model.setObjective(z+x+y+a, gp.GRB.MAXIMIZE)&#xA;&#xA;model.update()&#xA;# Solve the model&#xA;model.optimize()&#xA;model.display()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;calling &lt;code&gt;model.display()&lt;/code&gt; will only show me the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Maximize&#xA;  x + y + a + z&#xA;Subject To&#xA;Bounds&#xA;  0 &amp;lt;= z &amp;lt;= 30&#xA;Binaries&#xA;  ['x', 'y', 'a']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and it dos not show anything regarding:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.addGenConstrAnd(a, [x, y], &amp;quot;andconstr&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;constr2 = model.addConstr((a == 0) &amp;gt;&amp;gt; (z &amp;lt;= 5))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is there a way to see such information in Gurobi &lt;code&gt;model.display()&lt;/code&gt; or some similar function?&lt;/p&gt;&#xA;" OwnerUserId="11380" LastEditorUserId="491" LastEditDate="2023-03-06T12:23:56.937" LastActivityDate="2023-03-06T12:23:56.937" Title="How to check conditional constraints added to the model?" Tags="|gurobi|gurobipy|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10046" PostTypeId="2" ParentId="10045" CreationDate="2023-03-05T21:08:42.580" Score="0" Body="&lt;p&gt;Use model.write('filename.lp') or model.write('filename.mps'). AND constraint will appear in the section General constraints(lp) or GENCONS(mps).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Subject To&#xA; GC1: a = 0 -&amp;gt; z &amp;lt;= 5&#xA;Bounds&#xA; z &amp;lt;= 30&#xA;Binaries&#xA; x y a&#xA;General Constraints&#xA; andconstr: a = AND ( x , y )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-03-05T21:08:42.580" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10048" PostTypeId="2" ParentId="10036" CreationDate="2023-03-06T04:41:52.837" Score="0" Body="&lt;p&gt;It sounds like you're running into numerical issues due to very small or very large values. A few things to try:&lt;/p&gt;&#xA;&lt;p&gt;Use logged variables instead of raw values in the barrier term. So instead of ln(hi(x)), use ln(max(hi(x), ε)), where ε is a small positive constant (like 10^-14). This avoids taking the log of a very small number.&lt;/p&gt;&#xA;&lt;p&gt;Scale your problem to avoid very large/small raw values. If hi(x) is on the order of 10^-14, scale x and hi(x) by a large constant to bring the values into a more reasonable range.&#xA;Use higher precision floating point, like quad precision if available. This can help with stability for problems with a wide range of scales.&lt;/p&gt;&#xA;&lt;p&gt;Check for other potential numerical issues - are there divisions by very small numbers, exponential growth/decay, etc.&lt;/p&gt;&#xA;&lt;p&gt;In general, interior point methods can be numerically sensitive, so it's important to be careful with scaling, avoiding extremes, and using stable algorithms/precision.&lt;/p&gt;&#xA;" OwnerUserId="901" LastActivityDate="2023-03-06T04:41:52.837" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10049" PostTypeId="2" ParentId="9534" CreationDate="2023-03-06T04:43:19.717" Score="0" Body="&lt;p&gt;You can add this constraint directly in your routing model with a CumulVar expression. It would look something like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for vehicle in vehicles:&#xA;    model.Add(&#xA;        cumul_vars[vehicle][1] &amp;gt; cumul_vars[vehicle][0]&#xA;    )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;cumul_vars&lt;/code&gt; here being the list of cumul variables per vehicle, indexing trip 0 and trip 1 to get the loads of the two trips and imposing the constraint that trip 1 load is greater than trip 0 load.&lt;/p&gt;&#xA;&lt;p&gt;This uses the fact that cumul variables represent accumulated quantities over trips, so &lt;code&gt;cumul_vars[vehicle][1]&lt;/code&gt; is the total load over trips 0 and 1, allowing this comparison.&#xA;So in full this would be added as an additional constraint on top of your existing routing model formulation.&lt;/p&gt;&#xA;" OwnerUserId="901" LastEditorUserId="123" LastEditDate="2024-04-01T15:55:51.007" LastActivityDate="2024-04-01T15:55:51.007" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10052" PostTypeId="1" AcceptedAnswerId="10055" CreationDate="2023-03-06T06:06:16.460" Score="4" ViewCount="350" Body="&lt;p&gt;&lt;strong&gt;Question 1:&lt;/strong&gt; Is ortool's CP-SAT sensitive to the order in which a model is constructed?&lt;/p&gt;&#xA;&lt;p&gt;In other words, does it matter which variables and constraints come first?&lt;/p&gt;&#xA;&lt;p&gt;I am seeing a high performance variance for some models which, unless I messed up, should be &amp;quot;the same&amp;quot; (isomorphic), and wonder if this should all be attributed to the non-determinism and heuristics in CP-SAT, or whether I could improve things by &amp;quot;normalizing&amp;quot; my model construction somehow.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question 2:&lt;/strong&gt; If so, are there best practices on which variables/constraints to list first?&lt;/p&gt;&#xA;" OwnerUserId="11390" LastActivityDate="2023-03-06T21:30:58.467" Title="Relevance of order of model construction in CP-SAT" Tags="|or-tools|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10054" PostTypeId="1" CreationDate="2023-03-06T10:48:16.383" Score="0" ViewCount="207" Body="&lt;p&gt;The value of one of the variable of my model (alpha_1) is given by a piecewise function. Each element of the piecewise depends on the value of some other binary decision variables (X1, x2, x3).&lt;/p&gt;&#xA;&lt;p&gt;I'd like to know how I can express this piecewise function as some linear equations within the constraints to make sure that the right value has been chosen. Please below find the piecewise function.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/g0HbH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/g0HbH.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5008" LastEditorUserId="5008" LastEditDate="2023-03-06T13:43:00.870" LastActivityDate="2023-03-06T14:03:10.383" Title="Converting a piecewise function to a linear equation as a constraint" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|linearization|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10055" PostTypeId="2" ParentId="10052" CreationDate="2023-03-06T11:28:05.850" Score="7" Body="&lt;p&gt;This is a well know behavior of all MIP/CP solvers. Presolve and search are heavily heuristics based (to limit the complexity of the underlying algorithms), and thus are dependent on variables and constraints orders&lt;/p&gt;&#xA;&lt;p&gt;The impact is known to be very large. And there is no way to define a canonical order.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://pubsonline.informs.org/doi/pdf/10.1287/educ.2013.0112&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pubsonline.informs.org/doi/pdf/10.1287/educ.2013.0112&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2023-03-06T21:30:58.467" LastActivityDate="2023-03-06T21:30:58.467" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10056" PostTypeId="1" CreationDate="2023-03-06T12:03:22.920" Score="0" ViewCount="67" Body="&lt;p&gt;I would like to capture the unmet demand by modeling the following constraint with two decision variables. where &lt;span class=&quot;math-container&quot;&gt;$QU_{wc}$&lt;/span&gt; is the unmet demand and &lt;span class=&quot;math-container&quot;&gt;$QW_{wc}$&lt;/span&gt; the shipped amount of products. I model the constraint correctly but its not giving me the value of &lt;span class=&quot;math-container&quot;&gt;$QU_{c} \;\forall \; customers$&lt;/span&gt; which is a decision variable of the shortage.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$QU_{c}$&lt;/span&gt; is the shortage quantity for all customers, which is a decision variable&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$QW_{wc}$&lt;/span&gt; is the amount shipped from &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$D_{c}$&lt;/span&gt; demand at the customers for all customers.&lt;/p&gt;&#xA;&lt;p&gt;Shortages are allowed.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{w} QW_{wc} + QU_{c} \geq D_{c} \ ; \forall{c}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Demand constraints&lt;/p&gt;&#xA;&lt;p&gt;m.addConstrs((&lt;span class=&quot;math-container&quot;&gt;$QW_{wh}$&lt;/span&gt;.sum('*',c)+ &lt;span class=&quot;math-container&quot;&gt;$QU_{c}$&lt;/span&gt;[c] &amp;gt;= demand[c] for c in range (customers)),&amp;quot;Demand&amp;quot;)$&lt;/p&gt;&#xA;" OwnerUserId="11004" LastEditorUserId="11004" LastEditDate="2023-03-13T18:34:43.233" LastActivityDate="2023-03-13T18:34:43.233" Title="Gurobi-Python, unmet demand of customers" Tags="|optimization|mixed-integer-programming|python|gurobi|supply-chain|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="10057" PostTypeId="2" ParentId="10054" CreationDate="2023-03-06T13:14:09.613" Score="1" Body="&lt;p&gt;For the if statements try this&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_1-(x_2+x_3) \le w_1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_2-x_3 \le w_2 $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_3 \le w_3 $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ w_1 +w_2+w_3 =1$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; are binary.&#xA;&lt;span class=&quot;math-container&quot;&gt;$\alpha = 100w_1 +200w_2 + 300w_3 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As question now stands I d modify answer as&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_1 +x_2+x_3 = w_1+2w_2+3w_3$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_i w_i =1$&lt;/span&gt;&lt;br /&gt;&#xA;You may also need &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=k+1}^n x_i \le Mx_k$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$k=\{1,2,...n-1\}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-06T14:03:10.383" LastActivityDate="2023-03-06T14:03:10.383" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10058" PostTypeId="1" AcceptedAnswerId="10102" CreationDate="2023-03-06T13:50:24.107" Score="1" ViewCount="132" Body="&lt;p&gt;Is there a solver that can handle an AMPL model of this sort:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;param max_amt=1;&#xA;param min_amt=.05;&#xA;set VALUE={min_amt..max_amt by .01}union{0}; # Exact dollar value&#xA;var purchase {CUSTOMER} in VALUE; # set membership as opposed to inequality/equality&#xA;# Maximize or minimize some utility non-linear function...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In other words, a non-linear solver that can satisfy a set membership constrain in continuous domain.&lt;/p&gt;&#xA;" OwnerUserId="11394" LastEditorUserId="11394" LastEditDate="2023-03-11T20:48:18.777" LastActivityDate="2023-03-11T20:48:18.777" Title="Optimization solver that satisfies variable values within set membership" Tags="|optimization|modeling|solver|ampl|modeling-languages|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10059" PostTypeId="1" CreationDate="2023-03-06T14:36:28.060" Score="1" ViewCount="146" Body="&lt;p&gt;I have a clustering problem with around 400-500 nodes. The edge between any two nodes has a weight (between 0 and 1, 0: can be considered as there is no edge/connection between these two nodes) as shown in the figure. I haven’t drawn all the edges so as not to make the figure messy. Generally, the edge between the nodes that are far away from each other has low weight.&lt;/p&gt;&#xA;&lt;p&gt;I need to perform clustering of these nodes. Lets say we want to put the nodes in 7-8 clusters/groups.&lt;/p&gt;&#xA;&lt;p&gt;The objective is that the sum-weight in each cluster should be maximized. This may also generate clusters where the number of edges connecting two clusters is low.&lt;a href=&quot;https://i.stack.imgur.com/Vmu9z.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Vmu9z.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Problem Statement:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$N=500$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$G=8$&lt;/span&gt; and maximum cluster/group size is 70.&lt;/p&gt;&#xA;&lt;p&gt;Let&lt;/p&gt;&#xA;&lt;p&gt;binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,g}$&lt;/span&gt; indicate whether node &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,\dots,N\}$&lt;/span&gt; appears in group &lt;span class=&quot;math-container&quot;&gt;$g\in\{1,\dots,G\}$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j,g}$&lt;/span&gt; indicate whether edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; appears in group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We want to maximize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i&amp;lt;j}\sum_g w_{i,j} y_{i,j,g}$$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_g x_{i,g} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \tag1 \\&#xA;\sum_i x_{i,g} &amp;amp;\le 70 &amp;amp;&amp;amp;\text{for all $g$} \\&#xA;y_{i,j,g} &amp;amp;\le x_{i,g} &amp;amp;&amp;amp;\text{for all $i&amp;lt;j$ and all $g$} \\&#xA;y_{i,j,g} &amp;amp;\le x_{j,g} &amp;amp;&amp;amp;\text{for all $i&amp;lt;j$ and all $g$} \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As we can see this a binary integer programming problem and has large number of optimization variable. Difficult to solve. Also I cannot afford a solver.&lt;/p&gt;&#xA;&lt;p&gt;I prefer a less-complex solution.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="500" LastEditDate="2023-03-08T17:40:08.157" LastActivityDate="2023-03-08T20:43:07.950" Title="How to perform clustering of a large number of nodes?" Tags="|optimization|linear-programming|nonlinear-programming|graphs|clustering|" AnswerCount="4" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10061" PostTypeId="2" ParentId="10058" CreationDate="2023-03-06T15:53:11.173" Score="0" Body="&lt;p&gt;Define a set like &lt;span class=&quot;math-container&quot;&gt;$I= \{0,5,6,...100\}$&lt;/span&gt; and a binary &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;.&lt;br /&gt;&#xA;Add constraints:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{i\in I} iz_{i,k} = 100p_k$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is purchase variable for k customers&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{i\in I} z_{i,k} = 1$&lt;/span&gt;&lt;br /&gt;&#xA;Above 2 will enforce purchase variable &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; to choose from the set I&lt;/p&gt;&#xA;&lt;p&gt;Or&lt;br /&gt;&#xA;Depending upon objective (if it's linear) you may choose purchase variable &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; as belonging to domain non-negative integer &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; and with a binary &lt;span class=&quot;math-container&quot;&gt;$z_{k}$&lt;/span&gt; you can have pair of constraints for all &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; customers&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$100*0.05z_{k} \le p_k \le 100z_k$&lt;/span&gt;.&lt;br /&gt;&#xA;This bounds in non-continuous 0 or &lt;span class=&quot;math-container&quot;&gt;$[5,...100] $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-07T14:10:56.560" LastActivityDate="2023-03-07T14:10:56.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10062" PostTypeId="2" ParentId="10058" CreationDate="2023-03-06T17:36:43.750" Score="1" Body="&lt;p&gt;AMPL automatically linearizes &lt;code&gt;var purchase {CUSTOMER} in VALUE;&lt;/code&gt; where &lt;code&gt;VALUE&lt;/code&gt; is a set of numbers. The linearization creates some binary (zero-one) variables, so you need a solver that can handle such variables.&lt;/p&gt;&#xA;&lt;p&gt;However, due to the limited precision of floating-point arithmetic in the computer, sets of fractional values like &lt;code&gt;{min_amt..max_amt by .01}&lt;/code&gt; are problematical. Here's a simplified example of one kind of unexpected result: If you define&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;param min_amt := 0.05;&#xA;ampl: param max_amt := 0.22;&#xA;ampl: set VALUE = {0} union {min_amt..max_amt by .01};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then using AMPL's &lt;code&gt;display&lt;/code&gt; command, you can look at the members of the set &lt;code&gt;VALUE&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ampl: display VALUE;&#xA;set VALUE :=&#xA;0                      0.1                    0.16&#xA;0.05                   0.11                   0.16999999999999998&#xA;0.060000000000000005   0.12000000000000001    0.18&#xA;0.07                   0.13                   0.19&#xA;0.08                   0.14                   0.2&#xA;0.09                   0.15000000000000002    0.21000000000000002;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The number 0.22 is not in the set! This problem is really due to the use of &lt;code&gt;by .01&lt;/code&gt;. The number .01 cannot be represented exactly in the computer, so when .01 is repeatedly added to &lt;code&gt;min_amt&lt;/code&gt;, there is some imprecision in the results. In this example, when .01 is added to the previous value 0.21000000000000002, the result is 0.22000000000000003, which not included in the set because it is greater than &lt;code&gt;max_amt&lt;/code&gt;. To be sure that you do not run into this and similar problems, you can instead define &lt;code&gt;VALUE&lt;/code&gt; by a series of integers that are each divided by 100:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;param min_amt := 5;&#xA;param max_amt := 22;&#xA;set VALUE = {0} union setof {i in min_amt..max_amt} i/100;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then the members of &lt;code&gt;VALUE&lt;/code&gt; are as expected:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ampl: display VALUE;&#xA;set VALUE :=&#xA;0      0.06   0.08   0.1    0.12   0.14   0.16   0.18   0.2    0.22&#xA;0.05   0.07   0.09   0.11   0.13   0.15   0.17   0.19   0.21;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When &lt;code&gt;VALUE&lt;/code&gt; is defined in this way, the linearization of &lt;code&gt;var purchase {CUSTOMER} in VALUE;&lt;/code&gt; will add some binary variables to your problem, but it will not change the members of &lt;code&gt;VALUE&lt;/code&gt; -- they will still be fractional, and the values of the variable &lt;code&gt;purchase&lt;/code&gt; will be fractional.&lt;/p&gt;&#xA;&lt;p&gt;If you use this approach and still get crashes, you may want to report an example to the &lt;a href=&quot;https://discuss.ampl.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AMPL forum&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="52" LastEditorUserId="52" LastEditDate="2023-03-07T16:35:30.353" LastActivityDate="2023-03-07T16:35:30.353" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10063" PostTypeId="2" ParentId="10059" CreationDate="2023-03-06T21:36:33.843" Score="1" Body="&lt;p&gt;Here's a simple hill-climbing approximate solver in Python which seems to work quite well:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import numpy as np&#xA;&#xA;def cluster(weights, n_groups, max_size):&#xA;    n = weights.shape[0]&#xA;    assert n_groups * max_size &amp;gt;= n&#xA;    group_weights = np.zeros((n, n_groups))&#xA;    groups = np.empty(n, dtype=int)&#xA;    group_sizes = np.zeros(n_groups, dtype=int)&#xA;    idxs = np.arange(n)&#xA;    np.random.shuffle(idxs)&#xA;    score = 0&#xA;    for i in idxs:&#xA;        g = i % n_groups&#xA;        groups[i] = g&#xA;        group_sizes[g] += 1&#xA;        score += group_weights[i,g]&#xA;        group_weights[:,g] += weights[i]&#xA;    while True:&#xA;        #Reassignment phase&#xA;        changed = False&#xA;        for i in idxs:&#xA;            g = groups[i]&#xA;            w = np.copy(group_weights[i])&#xA;            w[group_sizes == max_size] = -1&#xA;            h = np.argmax(w)&#xA;            ds = group_weights[i,h] - group_weights[i,g]&#xA;            if ds &amp;lt;= 1e-16:&#xA;                continue&#xA;            changed = True&#xA;            groups[i] = h&#xA;            group_sizes[g] -= 1&#xA;            group_sizes[h] += 1&#xA;            score += ds&#xA;            group_weights[:,g] -= weights[i]&#xA;            group_weights[:,h] += weights[i]&#xA;        #Swapping phase&#xA;        for i in range(n):&#xA;            for j in range(n):&#xA;                if j == i:&#xA;                    continue&#xA;                g = groups[i]&#xA;                h = groups[j]&#xA;                ds = (group_weights[i,h] - group_weights[i,g]) + (group_weights[j,g] - group_weights[j,h]) - 2 * weights[i,j]&#xA;                if ds &amp;lt;= 1e-16:&#xA;                    continue&#xA;                changed = True&#xA;                groups[i] = h&#xA;                groups[j] = g&#xA;                score += ds&#xA;                dw = weights[j] - weights[i]&#xA;                group_weights[:,g] += dw&#xA;                group_weights[:,h] -= dw&#xA;        if not changed:&#xA;            break&#xA;    return groups, score&#xA;&#xA;if __name__ == &amp;quot;__main__&amp;quot;:&#xA;    np.random.seed(0)&#xA;&#xA;    N = 500&#xA;    max_size = 70&#xA;    n_groups = 8&#xA;    weights = np.random.uniform(0., 1., (N, N))&#xA;    weights = np.tril(weights, -1) + np.triu(weights.T, 1)&#xA;&#xA;    groups, score = cluster(weights, n_groups, max_size)&#xA;&#xA;    print(groups)&#xA;    print(score)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7666" LastEditorUserId="7666" LastEditDate="2023-03-06T21:50:25.677" LastActivityDate="2023-03-06T21:50:25.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10068" PostTypeId="1" CreationDate="2023-03-07T16:35:26.853" Score="-1" ViewCount="151" Body="&lt;p&gt;I have a constraint optimization problem as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I need to assign &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; tasks to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; days, with &lt;span class=&quot;math-container&quot;&gt;$n \geq m$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Each day can host 0 to &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; tasks.&lt;/li&gt;&#xA;&lt;li&gt;Each task either belongs to type &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;I want to assign the tasks to the days such that tasks of the same type are grouped as much as possible on the same days (minimize mixing tasks of different types on the same day)&lt;/li&gt;&#xA;&lt;li&gt;I have a set of constraints indicating the days on which each task can occur.&lt;/li&gt;&#xA;&lt;li&gt;Moreover, the number of days that is used to host all the tasks should also be minimized. For instance: If the constraints allow hosting 2 tasks of the same type either on 2 different days or otherwise on the same day, hosting the 2 tasks on the same day should have preference.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I'm having issues finding a formulation of this problem that can be solved. My first thought is to use an &lt;span class=&quot;math-container&quot;&gt;$m\times n$&lt;/span&gt; matrix &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; where if &lt;span class=&quot;math-container&quot;&gt;$M(i,j) \neq 0$&lt;/span&gt; it means that task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; occurs on day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$M(i,j) = 1$&lt;/span&gt; if the task is of type &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M(i,j) = -1$&lt;/span&gt; if the task is of type &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I think part of my optimization objective should express that I want to minimize Shannon entropy: &lt;span class=&quot;math-container&quot;&gt;$-\sum p \dot \log(p)$&lt;/span&gt;. The zeros in my matrix are not relevant for the entropy calculation so when I compute &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; I need to divide 2 variables: The number of tasks of group &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; divided by the total number of tasks on that day. I don't know the number of tasks on a given day beforehand since this is part of the optimization so I get a division of 2 variables.&lt;/p&gt;&#xA;&lt;p&gt;I also tried an alternative for entropy in the objective function: I sum all the 1's and -1's on each day and then take the absolute value: The larger this sum, the higher the orderliness of that day. But again, when wanting to compare the 'orderliness' of 2 days with a different number of activities on them, I have to divide by the number of activities on that day, which is again division of 2 variables.&lt;/p&gt;&#xA;&lt;p&gt;I've tried solving this problem with OR-tools and CVXPY but I get error messages like: The problem does not adhere to &amp;quot;disciplined convex programming&amp;quot;. As I understand it, the division of 2 variables is a problem. Even worse, it is possible that a day has 0 activities and then I get a division by zero.&lt;/p&gt;&#xA;&lt;p&gt;Is there any other formulation of this optimization problem that would not cause these problems?&lt;/p&gt;&#xA;" OwnerUserId="11401" LastEditorUserId="981" LastEditDate="2023-12-31T11:09:14.260" LastActivityDate="2023-12-31T11:09:14.260" Title="Reformulate this constraint optimization problem such that I do not have to divide 2 variables?" Tags="|optimization|mixed-integer-programming|convex-optimization|or-tools|assignment-problem|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10069" PostTypeId="2" ParentId="10068" CreationDate="2023-03-07T17:15:01.100" Score="0" Body="&lt;p&gt;You could try implementing the condition &lt;span class=&quot;math-container&quot;&gt;$x * y = z$&lt;/span&gt; by expanding &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; as binary vectors &lt;span class=&quot;math-container&quot;&gt;$x^b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y^b$&lt;/span&gt;,&lt;span class=&quot;math-container&quot;&gt;$z^b$&lt;/span&gt;. I.e. &lt;span class=&quot;math-container&quot;&gt;$\Sigma x^b = \Sigma y^b = \Sigma z^b = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z^b_{i \cdot j} &amp;gt;= x^b_i + y^b_j - 1$&lt;/span&gt;. Then you can recover &lt;span class=&quot;math-container&quot;&gt;$z = \Sigma_i i \cdot z^b_i$&lt;/span&gt;. But this will probably be slow. Maybe try big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; reformulation (or enforcement variables) to assign a score for each day to each combination of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; task counts.&lt;/p&gt;&#xA;" OwnerUserId="7666" LastActivityDate="2023-03-07T17:15:01.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10071" PostTypeId="2" ParentId="9908" CreationDate="2023-02-10T02:13:34.790" Score="1" Body="&lt;p&gt;I second the integer programming suggestion.  But greedy is worth a shot.&lt;/p&gt;&#xA;&lt;p&gt;I don't have time to give a full implementation, but here is the basic idea.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for all teams from biggest to smallest&#xA;    if you can put them entirely colocated in one city&#xA;        can you do it without leaving just one employee out?&#xA;            put them in the smallest such available city.&#xA;    &#xA;&#xA;for all cities from least open spaces to most:&#xA;    how many is the most that can be assigned from one team?&#xA;        can you do it without leaving only one out (city or team)?&#xA;            do that from the smallest team you can.&#xA;        if that is more than 2:&#xA;            assign one less than that from the smallest team you can&#xA;               (leave one out from the most commonly needed role)&#xA;        else:&#xA;            assign as many as you can anyways&#xA;    repeat until the city is assigned&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="btilly" LastActivityDate="2023-02-10T02:13:34.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10072" PostTypeId="2" ParentId="9908" CreationDate="2023-02-18T09:04:33.310" Score="1" Body="&lt;p&gt;I put together a solution for the provided data, not sure if my stuff is very scalable, with large datasets. My line of thinking with the data you provided was:&lt;/p&gt;&#xA;&lt;p&gt;1.) add all employees to a dataframe&#xA;2.) assign largest teams to largest cities containing employees&#xA;3.) assign city teams to city rooms based on the size of team/room with the condition a room must always have 2 members from a team.&lt;/p&gt;&#xA;&lt;p&gt;my assign employees to rooms was definitely a hack and slash, conditionals could be reworked or improved on. Regardless the code below will give you the desired output for the datasets you provided.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pandas as pd&#xA;import math&#xA;&#xA;city_data = [(&amp;quot;New York&amp;quot;, &amp;quot;A&amp;quot;, 3), &#xA;             (&amp;quot;New York&amp;quot;, &amp;quot;B&amp;quot;, 2), &#xA;             (&amp;quot;New York&amp;quot;, &amp;quot;C&amp;quot;, 6), &#xA;             (&amp;quot;Boston&amp;quot;, &amp;quot;D&amp;quot;, 2), &#xA;             (&amp;quot;Boston&amp;quot;, &amp;quot;E&amp;quot;, 5)]&#xA;&#xA;team_data = [(&amp;quot;alpha&amp;quot;, &amp;quot;Manager&amp;quot;), &#xA;             (&amp;quot;alpha&amp;quot;, &amp;quot;Manager&amp;quot;), &#xA;             (&amp;quot;alpha&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;             (&amp;quot;alpha&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;             (&amp;quot;alpha&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;             (&amp;quot;alpha&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;             (&amp;quot;alpha&amp;quot;, &amp;quot;Designer&amp;quot;), &#xA;             (&amp;quot;beta&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;             (&amp;quot;beta&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;             (&amp;quot;beta&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;             (&amp;quot;gamma&amp;quot;, &amp;quot;Designer&amp;quot;), &#xA;             (&amp;quot;gamma&amp;quot;, &amp;quot;Engineer&amp;quot;)]&#xA;&#xA;employee_data = [(1, &amp;quot;New York&amp;quot;, &amp;quot;Manager&amp;quot;), &#xA;                 (2, &amp;quot;New York&amp;quot;, &amp;quot;Manager&amp;quot;), &#xA;                 (3, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;                 (4, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;                 (5, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;                 (6, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;                 (7, &amp;quot;New York&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;                 (8, &amp;quot;New York&amp;quot;, &amp;quot;Designer&amp;quot;), &#xA;                 (9, &amp;quot;New York&amp;quot;, &amp;quot;Designer&amp;quot;), &#xA;                 (10, &amp;quot;Boston&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;                 (11, &amp;quot;Boston&amp;quot;, &amp;quot;Engineer&amp;quot;), &#xA;                 (12, &amp;quot;Boston&amp;quot;, &amp;quot;Engineer&amp;quot;)]&#xA;&#xA;df = pd.DataFrame({&#xA;    &amp;quot;team_id&amp;quot; : [],&#xA;    &amp;quot;employee_id&amp;quot; : [],&#xA;    &amp;quot;position&amp;quot; : [],&#xA;    &amp;quot;city&amp;quot; : [],&#xA;    &amp;quot;office_id&amp;quot;: []&#xA;})&#xA;&#xA;def add_employee(employee, df):&#xA;    new_employee = pd.DataFrame({&#xA;        &amp;quot;team_id&amp;quot; : [''],&#xA;        &amp;quot;employee_id&amp;quot; : [employee[0]],&#xA;        &amp;quot;position&amp;quot; : [employee[2]],&#xA;        &amp;quot;city&amp;quot; : [employee[1]],&#xA;        &amp;quot;office_id&amp;quot;: [''],&#xA;    })&#xA;    return pd.concat([df, new_employee], ignore_index=True)&#xA;    &#xA;def add_team(team_id, employee_id, df):&#xA;    df.loc[df['employee_id'] == employee_id, 'team_id'] = team_id&#xA;&#xA;def assign_employee_to_team(team_data, df):&#xA;    current_team= &amp;quot;&amp;quot;&#xA;    &#xA;    for item in team_data:      &#xA;        team = item[0]&#xA;        position = item[1]      &#xA;        &#xA;        if team != current_team:&#xA;            current_team = team&#xA;            location = list(get_largest_available_employees_location(team_data, df).keys())[0]&#xA;            &#xA;        if location is None:&#xA;            employee = df.loc[(df['team_id'] == '') &amp;amp; (df['position'] == position), 'employee_id'].iloc[0]&#xA;        else:   &#xA;            employee = df.loc[(df['team_id'] == '') &amp;amp; (df['position'] == position) &amp;amp; (df['city'] == location), 'employee_id'].iloc[0]&#xA;&#xA;        add_team(team, employee, df)&#xA;&#xA;def get_largest_available_employees_location(team_data, df):&#xA;        return df.loc[df['team_id'] == '', 'city'].value_counts().to_dict()&#xA;    &#xA;def add_all_employees(df):&#xA;    for employee in employee_data:&#xA;        df = add_employee(employee, df)&#xA;    return df&#xA;    &#xA;def assign_room(employee, room, df):&#xA;    df.loc[(df['office_id'] == '') &amp;amp; (df['employee_id'] == employee), 'office_id'] = room&#xA;&#xA;def update_employee_rooms(people_to_add, team_name, city, room_id, df):&#xA;    for person in range(people_to_add):&#xA;        employee = df.loc[(df['office_id'] == '') &amp;amp; (df['team_id'] == team_name) &amp;amp; (df['city'] == city), 'employee_id'].iloc[0]&#xA;        assign_room(employee,room_id,df)&#xA;                        &#xA;def get_total_team_count_per_city(df):&#xA;    return df.value_counts(['team_id', 'city'])&#xA;&#xA;def assign_employee_to_room(city_data, df):&#xA;    rooms = sorted(city_data, key=lambda tup: (tup[0], tup[2]), reverse=True)&#xA;    teams = get_total_team_count_per_city(df)&#xA;    carry_over = 0&#xA;    &#xA;    for team_info in teams.items():&#xA;        team_name = team_info[0][0]&#xA;        team_city = team_info[0][1]&#xA;        num_of_people = team_info[1]&#xA;&#xA;        for index, item in enumerate(rooms):&#xA;            if num_of_people == 0:&#xA;                break&#xA;        &#xA;            city = item[0]&#xA;            room_id = item[1]&#xA;            max_size = item[2]&#xA;            &#xA;            if max_size == 'FULL':&#xA;                continue&#xA;                &#xA;            if team_city == city:&#xA;                if (math.floor(num_of_people/max_size)) &amp;gt;= 2:&#xA;                    people_to_add = num_of_people - max_size&#xA;                    update_employee_rooms(people_to_add, team_name, city, room_id, df)&#xA;                    num_of_people = num_of_people - people_to_add&#xA;                else:&#xA;                    if (num_of_people - (max_size-1)) &amp;lt; 0:&#xA;                        people_to_add = num_of_people&#xA;                    elif (num_of_people - max_size) == 0:&#xA;                        people_to_add = num_of_people&#xA;                    else:&#xA;                        people_to_add = (max_size-1)&#xA;                    &#xA;                    num_of_people = (num_of_people - people_to_add)&#xA;                    update_employee_rooms(people_to_add, team_name, city, room_id, df)&#xA;                    rooms[index] = (city, room_id, 'FULL')&#xA;&#xA;df = add_all_employees(df)&#xA;assign_employee_to_team(team_data, df)&#xA;assign_employee_to_room(city_data, df)&#xA;&#xA;print(df)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Nolan Walker" LastActivityDate="2023-02-18T09:04:33.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10073" PostTypeId="2" ParentId="9908" CreationDate="2023-02-21T22:08:17.723" Score="1" Body="&lt;p&gt;I used the library &lt;a href=&quot;https://pypi.org/project/PuLP/&quot; rel=&quot;nofollow noreferrer&quot;&gt;pulp&lt;/a&gt; (&lt;a href=&quot;https://github.com/coin-or/pulp&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;) which is nice for linear programming and optimization. It allows to add additional constraints later on (see the # comments), the code is a bit longer and clunky (because I just noticed your question today) but it should do the job:&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;The data:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pandas as pd&#xA;from pulp import *&#xA;&#xA;# Load the data&#xA;city_data = pd.DataFrame({&#xA;    'city': ['New York', 'New York', 'New York', 'Boston', 'Boston'],&#xA;    'office_id': ['A', 'B', 'C', 'D', 'E'],&#xA;    'capacity': [3, 2, 6, 2, 5]&#xA;})&#xA;team_data = pd.DataFrame({&#xA;    'team_id': ['alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'beta', 'beta', 'beta', 'gamma', 'gamma'],&#xA;    'position': ['Manager', 'Manager', 'Engineer', 'Engineer', 'Engineer', 'Engineer', 'Designer', 'Engineer', 'Engineer', 'Engineer', 'Designer', 'Engineer']&#xA;})&#xA;employees_data = pd.DataFrame({&#xA;    'employee_id': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],&#xA;    'city': ['New York', 'New York', 'New York', 'New York', 'New York', 'New York', 'New York', 'New York', 'New York', 'Boston', 'Boston', 'Boston'],&#xA;    'position': ['Manager', 'Manager', 'Engineer', 'Engineer', 'Engineer', 'Engineer', 'Engineer', 'Designer', 'Designer', 'Engineer', 'Engineer', 'Engineer']&#xA;})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;The Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Create a list of cities, offices and teams&#xA;cities = city_data['city'].unique()&#xA;offices = city_data['office_id'].unique()&#xA;teams = team_data['team_id'].unique()&#xA;&#xA;# Create a dictionary of office capacities&#xA;capacities = dict(zip(city_data['office_id'], city_data['capacity']))&#xA;&#xA;# Create a dictionary of employees by city and position&#xA;employees = {}&#xA;for city in cities:&#xA;    for position in team_data['position'].unique():&#xA;        employees[(city, position)] = employees_data[(employees_data['city'] == city) &amp;amp; (employees_data['position'] == position)]['employee_id'].tolist()&#xA;&#xA;# Create the LP problem&#xA;prob = LpProblem(&amp;quot;Employee Allocation Problem&amp;quot;, LpMaximize)&#xA;&#xA;# Create a binary variable for each employee, indicating whether they are assigned to a team&#xA;employee_vars = LpVariable.dicts(&amp;quot;Employee&amp;quot;, [(employee_id, team_id, office_id) for employee_id in employees_data['employee_id']&#xA;                                              for team_id in teams for office_id in offices],&#xA;                                 cat='Binary')&#xA;&#xA;# Create Auxiliary table&#xA;df_employee_vars = pd.DataFrame.from_dict(employee_vars, orient='index', columns=['Employee']).reset_index().rename(columns={'index': 'assignment'})  # , index=range(len(employee_vars))&#xA;df_employee_vars['employee_id'] = df_employee_vars['assignment'].str[0]&#xA;df_employee_vars['team'] = df_employee_vars['assignment'].str[1]&#xA;df_employee_vars['office'] = df_employee_vars['assignment'].str[2]&#xA;&#xA;# Objective 1: minimize number of offices&#xA;employees_in_office = (df_employee_vars['Employee']*df_employee_vars['office']).values&#xA;prob += lpSum(-len({y for x in employees_in_office for y in x.values()}))&#xA;&#xA;# Objective 2: maximize number of employees of same team in same office&#xA;vals = df_employee_vars.groupby(['team', 'office'])['Employee'].sum().values&#xA;prob += lpSum(np.mean(vals))&#xA;&#xA;# Constraint: each employee can only be assigned to one team and one office&#xA;for employee_id in employees_data['employee_id']:&#xA;    prob += lpSum([employee_vars[(employee_id, team_id, office_id)] for team_id in teams for office_id in offices]) == 1&#xA;&#xA;# Constraint: Each office has a capacity constraint&#xA;for office_id in offices:&#xA;    for team_id in teams:&#xA;        prob += lpSum([employee_vars[(employee_id, team_id, office_id)] for employee_id in employees_data['employee_id']]) &amp;lt;= capacities[office_id]&#xA;&#xA;# Constraint: Each office has a capacity constraint&#xA;for office_id in offices:&#xA;    employees_in_office = df_employee_vars[df_employee_vars['office'].eq(office_id)]['Employee'].values&#xA;    prob += lpSum(employees_in_office) &amp;lt;= capacities[office_id]&#xA;&#xA;# Constraint: Each team has a capacity constraint&#xA;team_capacities = team_data.groupby(['team_id'])['team_id'].count().to_dict()&#xA;for team_id, capacity in team_capacities.items():&#xA;    employees_in_team = df_employee_vars[df_employee_vars['team'].eq(team_id)]['Employee'].values&#xA;    prob += lpSum(employees_in_team) &amp;lt;= capacity&#xA;&#xA;# Solve&#xA;prob.solve()&#xA;&#xA;# Print the status of the solution&#xA;print(&amp;quot;Status:&amp;quot;, LpStatus[prob.status])&#xA;&#xA;# Print the optimal objective value&#xA;print(&amp;quot;Objective value:&amp;quot;, value(prob.objective))&#xA;&#xA;# Print the optimal variable values&#xA;for v in prob.variables():&#xA;    if v.varValue == 1:&#xA;        print(v.name, &amp;quot;=&amp;quot;, v.varValue)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;The Output:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;INTEGER OPTIMAL SOLUTION FOUND&#xA;Time used:   0.0 secs&#xA;Memory used: 0.3 Mb (266494 bytes)&#xA;Writing MIP solution to 'C:\Users\...\AppData\Local\Temp\...-pulp.sol'...&#xA;Status: Optimal&#xA;Objective value: 5&#xA;Employee_(1,_'alpha',_'A') = 1&#xA;Employee_(10,_'alpha',_'A') = 1&#xA;Employee_(11,_'alpha',_'A') = 1&#xA;Employee_(12,_'gamma',_'E') = 1&#xA;Employee_(2,_'gamma',_'E') = 1&#xA;Employee_(3,_'alpha',_'B') = 1&#xA;Employee_(4,_'alpha',_'B') = 1&#xA;Employee_(5,_'alpha',_'C') = 1&#xA;Employee_(6,_'alpha',_'C') = 1&#xA;Employee_(7,_'beta',_'E') = 1&#xA;Employee_(8,_'beta',_'E') = 1&#xA;Employee_(9,_'beta',_'E') = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Andreas" LastActivityDate="2023-02-22T14:43:52.197" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10074" PostTypeId="2" ParentId="10068" CreationDate="2023-03-07T17:51:24.440" Score="0" Body="&lt;p&gt;You can define a parameter &lt;span class=&quot;math-container&quot;&gt;$\tau_t= 1$&lt;/span&gt; if tasks &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is from set A, -1 otherwise. In that case your &lt;span class=&quot;math-container&quot;&gt;$ m_{t,d}=1$&lt;/span&gt; if task &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is assigned on day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;, becomes a binary. you can use &lt;span class=&quot;math-container&quot;&gt;$ \sum_t \tau_t m_{t,d}$&lt;/span&gt; to sum up for the day.&lt;/p&gt;&#xA;&lt;p&gt;As for division of two variable like &lt;span class=&quot;math-container&quot;&gt;$ x\over y$&lt;/span&gt; always define another variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; with a bilinear constraint &lt;span class=&quot;math-container&quot;&gt;$ y*z = 1$&lt;/span&gt;. Then it comes expression involving division as quadratic &lt;span class=&quot;math-container&quot;&gt;$ xz$&lt;/span&gt;.&#xA;As for &lt;span class=&quot;math-container&quot;&gt;${x\over y}log {x\over y}$&lt;/span&gt;, it will be turned into &lt;span class=&quot;math-container&quot;&gt;$ xz(logx+logz)$&lt;/span&gt;.&lt;br /&gt;&#xA;Depending upon solver you need to smoothen log.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-07T21:56:19.083" LastActivityDate="2023-03-07T21:56:19.083" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10078" PostTypeId="2" ParentId="10059" CreationDate="2023-03-07T21:12:55.583" Score="1" Body="&lt;p&gt;You can apply a genetic algorithm to the problem, although (a) I'm not sure it would be considered &amp;quot;less-complex&amp;quot; and (b) it definitely would have a random component, with different runs likely producing different clusters. You would want to use a GA library, but fortunately there are high-quality open-source libraries for most languages. I have a &lt;a href=&quot;https://rubin.msu.domains/blog/ga_clustering.nb.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;demo&lt;/a&gt; coded as an R notebook (using the &amp;quot;GA&amp;quot; R library).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-07T21:12:55.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10079" PostTypeId="2" ParentId="10059" CreationDate="2023-03-08T16:07:13.760" Score="0" Body="&lt;p&gt;If you would like to maximize intra-cluster weight, firstly, subtract each edge weight from 1. On the resulting graph, solve a Minimum Spanning Tree (MST). If you would like 2 clusters, remove the costliest edge in the MST solution. If you would like 3 clusters, remove the costliest and next costliest edge in the MST solution...If you would like m clusters, remove the m-1 costliest edges in the MST solution. This is a heuristic and relatively easy to implement solution to your problem.&lt;/p&gt;&#xA;" OwnerUserId="11221" LastActivityDate="2023-03-08T16:07:13.760" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10080" PostTypeId="2" ParentId="10059" CreationDate="2023-03-08T20:43:07.950" Score="1" Body="&lt;p&gt;This is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Graph_partition&quot; rel=&quot;nofollow noreferrer&quot;&gt;graph partitioning problem&lt;/a&gt;. In your formulation, you are trying to maximize the weight of edges that are inside a cluster, instead of minimizing the weight of edges between clusters, but both are equivalent.&lt;/p&gt;&#xA;&lt;p&gt;There are very good heuristics, some of which are explained on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Graph_partition&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia page&lt;/a&gt;. And very good solvers based on these heuristics.&lt;/p&gt;&#xA;&lt;p&gt;I suggest either &lt;a href=&quot;https://github.com/KarypisLab/METIS&quot; rel=&quot;nofollow noreferrer&quot;&gt;Metis&lt;/a&gt; or &lt;a href=&quot;https://github.com/kahypar/kahypar&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kahypar&lt;/a&gt;. Both are free software and have bindings for multiple languages.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2023-03-08T20:43:07.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10081" PostTypeId="1" AcceptedAnswerId="10087" CreationDate="2023-03-08T20:53:28.670" Score="1" ViewCount="109" Body="&lt;p&gt;I have a real world use case where I aim to optimize the assignment of trucks to orders of different sizes over a time window by minimizing some cost function (e.g. total distance traveled).&lt;/p&gt;&#xA;&lt;p&gt;The below model (coded in Python with Google OR-Tools) illustrates my problem, and solves quickly on my toy dataset. My issue is that the real problem will contain approximately 1000 locations and 1000+ trucks, which causes the number of path variables (denoted r[i,t,k,k'] in the sample code) to explode to 1000 trucks * 15 time periods * choose(1000,2) distance matrix entries. Setting up this many variables and associated constraints in the MIP solver will be time prohibitive, and I have my doubts as to whether the solver (or a commercial solver) will be able to give a solution in a reasonable amount of time.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pandas as pd&#xA;import numpy as np&#xA;from ortools.linear_solver import pywraplp&#xA;&#xA;#CREATE DATA&#xA;distance_matrix = pd.DataFrame([(str(x),str(y)) for x in range(1,6) for y in range(1,6)], columns=['ORIGIN','DESTINATION'])&#xA;distance_matrix['DISTANCE'] = abs(distance_matrix.ORIGIN.astype(int)-distance_matrix.DESTINATION.astype(int))&#xA;&#xA;orders = pd.DataFrame(&#xA;         {'ORDER': ['A', 'B', 'C'],&#xA;          'PICKUP_LOCATION': ['1', '4', '5'],&#xA;          'DELIVER_LOCATION': ['5', '1', '2'],&#xA;          'SIZE': [1, 2, 3],&#xA;          'PICKUP_EARLIEST': [0, 0, 0],&#xA;          'PICKUP_LATEST': [3, 3, 3],&#xA;          'DELIVER_EARLIEST': [4, 4, 4],&#xA;          'DELIVER_LATEST': [9, 9, 9]}&#xA;          )&#xA;&#xA;trucks = pd.DataFrame(&#xA;         {'TRUCK': ['A', 'B', 'C'],&#xA;         'CAPACITY': [1, 2, 3],&#xA;         'CURRENT_LOCATION': ['4', '2', '3']}&#xA;         )&#xA;&#xA;&#xA;#DEFINE MODEL PARAMETERS&#xA;max_distance_per_time = 1 #MAX NUMBER OF UNITS A TRUCK CAN MOVE IN ONE TIME PERIOD&#xA;max_time = 9 #NUMBER OF TIME PERIODS TO OPTIMIZE OVER&#xA;&#xA;&#xA;#PRE-FILTER DISTANCE MATRIX TO ONLY ALLOWABLE DISTANCES OVER A TIME PERIOD&#xA;distance_matrix = distance_matrix.loc[distance_matrix.DISTANCE&amp;lt;=max_distance_per_time].reset_index(inplace=False, drop=True)&#xA;&#xA;#DEFINE VECTOR OF POSSIBLE LOCATIONS FOR LOOPING THROUGH&#xA;all_locations = np.unique(np.append(distance_matrix.ORIGIN.unique(), distance_matrix.DESTINATION.unique()))&#xA;&#xA;&#xA;###BUILD MODEL&#xA;solver = pywraplp.Solver.CreateSolver('SCIP')&#xA;&#xA;&#xA;##CREATE DECISION VARIABLES&#xA;x={} #x[i,j,t]=1 if truck i picks up order j at time t, 0 otherwise&#xA;for truck_index, truck in trucks.iterrows():&#xA;    for order_index, order in orders.iterrows():&#xA;        for t in range(max_time+1):&#xA;            if t&amp;gt;=order.PICKUP_EARLIEST and t&amp;lt;=order.PICKUP_LATEST:&#xA;                x[truck_index, order_index, t] = solver.BoolVar(f'x[{truck_index},{order_index},{t}]')&#xA;&#xA;y={} #y[i,j,t]=1 if truck i delivers order j at time t, 0 otherwise&#xA;for truck_index, truck in trucks.iterrows():&#xA;    for order_index, order in orders.iterrows():&#xA;        for t in range(max_time+1):&#xA;            if t&amp;gt;=order.DELIVER_EARLIEST and t&amp;lt;=order.DELIVER_LATEST:&#xA;                y[truck_index, order_index, t] = solver.BoolVar(f'y[{truck_index},{order_index},{t}]')&#xA;&#xA;z={} #z[i,t,k]=1 if truck i is positioned at location k at time t, 0 otherwise&#xA;for truck_index, truck in trucks.iterrows():&#xA;    for t in range(max_time+1):&#xA;        for location_index, location in enumerate(all_locations):&#xA;            z[truck_index, t, location] = solver.BoolVar(f'z[{truck_index},{t},{location}]')&#xA;&#xA;r = {} #r[i,t,k,k']=1 if z[i,t,k]*z[i,t-1,k']=1, 0 otherwise. REPRESENTS POINTS TRAVERSED BETWEEN t-1 AND t.&#xA;for truck_index, truck in trucks.iterrows():&#xA;    for t in range(1, max_time+1):&#xA;        for location_index, location in enumerate(all_locations):&#xA;            for od_index, od in distance_matrix[distance_matrix.DESTINATION==location].iterrows():&#xA;                r[truck_index, t, location, od.ORIGIN] = solver.BoolVar(f'r[{truck_index},{t},{location},{od.ORIGIN}]')&#xA;                solver.Add(r[truck_index, t, location, od.ORIGIN]-z[truck_index, t, location]&amp;lt;=0)&#xA;                solver.Add(r[truck_index, t, location, od.ORIGIN]-z[truck_index, t-1, od.ORIGIN]&amp;lt;=0)&#xA;                solver.Add(r[truck_index, t, location, od.ORIGIN] - z[truck_index, t, location] - z[truck_index, t-1, od.ORIGIN] &amp;gt;= -1)&#xA;                &#xA;                #CANNOT TRAVEL MORE THAN max_distance_per_time BETWEEN TIME STEPS (ADDING CONSTRAINT HERE TO AVOID LOOPING THROUGH AGAIN)&#xA;                solver.Add(r[truck_index, t, location, od.ORIGIN]*od.DISTANCE&amp;lt;=max_distance_per_time)&#xA;        &#xA;        #TRUCK MUST MAKE 1 MOVE EACH TIME PERIOD ALONG VALID PATH (INCLUDING MOVES TO SAME LOCATION)&#xA;        solver.Add(solver.Sum(r[truck_index, t, od.DESTINATION, od.ORIGIN] for od_index, od in distance_matrix.iterrows())==1)&#xA;&#xA;&#xA;&#xA;##CREATE CONSTRAINTS&#xA;for truck_index, truck in trucks.iterrows():&#xA;    #TRUCK AT CURRENT_LOCATION AT TIME 0&#xA;    solver.Add(z[truck_index, 0, truck.CURRENT_LOCATION]==1)&#xA;    &#xA;    for t in range(max_time+1):&#xA;        #TOTAL SIZE LOADED ON TRUCK i AT TIME t &amp;lt;= CAPACITY[i]&#xA;        solver.Add(solver.Sum(order.SIZE*x[truck_index, order_index, time_index] for order_index, order in orders.iterrows() for time_index in range(order.PICKUP_EARLIEST, min(order.PICKUP_LATEST, t)+1) if t&amp;gt;=order.PICKUP_EARLIEST and t&amp;lt;=order.DELIVER_LATEST) -&#xA;                   solver.Sum(order.SIZE*y[truck_index, order_index, time_index] for order_index, order in orders.iterrows() for time_index in range(order.DELIVER_EARLIEST, min(order.DELIVER_LATEST, t)+1) if t&amp;gt;=order.DELIVER_EARLIEST and t&amp;lt;=order.DELIVER_LATEST)&#xA;                   &amp;lt;=truck.CAPACITY)&#xA;        &#xA;        #TRUCK MUST BE AT 1 AND ONLY 1 LOCATION AT EACH TIME&#xA;        solver.Add(solver.Sum(z[truck_index, t, location] for location in all_locations)==1)&#xA;&#xA;&#xA;for order_index, order in orders.iterrows():&#xA;    #ALL ORDERS MUST BE PICKED UP (EXACTLY ONCE)&#xA;    solver.Add(solver.Sum(x[truck_index, order_index, t] for truck_index in range(trucks.shape[0]) for t in range(order.PICKUP_EARLIEST, order.PICKUP_LATEST+1))==1)&#xA;    &#xA;    for truck_index, truck in trucks.iterrows():&#xA;        #ALL ORDERS PICKED UP ARE DELIVERED&#xA;        solver.Add(solver.Sum(x[truck_index, order_index, t] for t in range(order.PICKUP_EARLIEST, order.PICKUP_LATEST+1)) -&#xA;                   solver.Sum(y[truck_index, order_index, t] for t in range(order.DELIVER_EARLIEST, order.DELIVER_LATEST+1))&#xA;                   ==0)&#xA;        &#xA;        #TRUCK MUST BE AT ORIGIN AT TIME OF PICKUP&#xA;        for t in range(order.PICKUP_EARLIEST, order.PICKUP_LATEST+1):&#xA;            solver.Add(x[truck_index, order_index, t]-z[truck_index, t, order.PICKUP_LOCATION]&amp;lt;=0)&#xA;        &#xA;        #TRUCK MUST BE AT DESTINATION AT TIME OF DELIVERY&#xA;        for t in range(order.DELIVER_EARLIEST, order.DELIVER_LATEST+1):&#xA;            solver.Add(y[truck_index, order_index, t]-z[truck_index, t, order.DELIVER_LOCATION]&amp;lt;=0)&#xA;&#xA;&#xA;&#xA;&#xA;##DEFINE OBJECTIVE&#xA;objective_terms = []&#xA;for truck_index, truck in trucks.iterrows():&#xA;    for t in range(1,max_time+1):&#xA;        for od_index, od in distance_matrix.iterrows():&#xA;            objective_terms.append(r[truck_index, t, od.DESTINATION, od.ORIGIN]*od.DISTANCE)&#xA;&#xA;&#xA;&#xA;#SOLVE THE MODEL&#xA;solver.Minimize(sum(objective_terms))&#xA;status = solver.Solve()&#xA;&#xA;&#xA;#PRINT THE SOLUTION&#xA;if status == pywraplp.Solver.OPTIMAL or status == pywraplp.Solver.FEASIBLE:&#xA;    for truck_index, truck in trucks.iterrows():&#xA;        for t in range(1, max_time+1):&#xA;            for location_index, location in enumerate(all_locations):&#xA;                print_ind=0&#xA;                for prev_location in distance_matrix[distance_matrix.DESTINATION==location].ORIGIN:&#xA;                    if r[truck_index, t, location, prev_location].solution_value()&amp;gt;0.5:&#xA;                        print(f'Truck {truck.TRUCK} moved from {prev_location} to {location} at time {t}')&#xA;                &#xA;                for order_index, order in orders.iterrows():&#xA;                    if t&amp;gt;=order.PICKUP_EARLIEST and t&amp;lt;=order.PICKUP_LATEST and x[truck_index, order_index, t].solution_value() &amp;gt; 0.5 and order.PICKUP_LOCATION==location:&#xA;                        print(f'Truck {truck.TRUCK} picked up order {order.ORDER} at time {t} from location {order.PICKUP_LOCATION}')&#xA;                        print_ind+=1&#xA;                    if t&amp;gt;=order.DELIVER_EARLIEST and t&amp;lt;=order.DELIVER_LATEST and y[truck_index, order_index, t].solution_value() &amp;gt; 0.5 and order.DELIVER_LOCATION==location:&#xA;                         print(f'Truck {truck.TRUCK} delivered order {order.ORDER} at time {t} at location {order.DELIVER_LOCATION}')&#xA;                         print_ind+=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11412" LastEditorUserId="491" LastEditDate="2023-03-08T22:02:34.630" LastActivityDate="2023-03-09T16:44:10.377" Title="Alternative Approaches to Assignment Problem" Tags="|vehicle-routing|or-tools|assignment-problem|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10082" PostTypeId="2" ParentId="10081" CreationDate="2023-03-08T21:08:38.403" Score="1" Body="&lt;p&gt;It seems that you are trying to solve a pickup and delivery problem. MIP solvers are often not the best tool for that, and getting good results with them requires special models and tricks.&lt;/p&gt;&#xA;&lt;p&gt;There are many heuristics that do the job. Since you are using OR-tools already, you may want to look at their &lt;a href=&quot;https://developers.google.com/optimization/routing/pickup_delivery&quot; rel=&quot;nofollow noreferrer&quot;&gt;pickup and delivery example&lt;/a&gt;.&#xA;Other solvers provide direct support for this kind of problems too (&lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/pdptw.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;LocalSolver&lt;/a&gt; and &lt;a href=&quot;https://www.optaplanner.org/docs/optaplanner/latest/use-cases-and-examples/use-cases-and-examples.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;OptaPlanner&lt;/a&gt; do at least).&lt;/p&gt;&#xA;&lt;p&gt;You can roll your own heuristic too, or look for better MIP models (column generation...), but that is no easy task.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2023-03-08T21:08:38.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10083" PostTypeId="1" CreationDate="2023-03-08T23:56:01.457" Score="1" ViewCount="195" Body="&lt;p&gt;Do you have to normalize objectives when using the weighted sum approch when having multiple objectives?&lt;/p&gt;&#xA;&lt;p&gt;Actually I thought that I should do it. But now I have run several experiments with different optimization models and the results reveal that there is no benefit when scaling the different objectives (by using the optimal value obtained from solving the single-objective problem). In contrary, I would even say that in my experiments, scaling the objective functions when using a weighted sum approach makes the results even worse, even when having objectives with different magnitudes.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2023-03-09T01:23:43.263" LastActivityDate="2023-08-07T08:05:55.327" Title="Do you have to normalize objectives when using the weighted sum approch?" Tags="|multi-objective-optimization|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="10084" PostTypeId="2" ParentId="10083" CreationDate="2023-03-09T02:09:52.383" Score="0" Body="&lt;p&gt;Yes, you need to normalize. It is not about weighting. If you don't, one of them dominates the others. The reason that you got worse result may be because you use weight coefficients improperly or the problem arises from something else. Generally, when I use weight coefficients, their sum is equal to 1.&lt;/p&gt;&#xA;" OwnerUserId="11414" LastActivityDate="2023-03-09T02:09:52.383" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10085" PostTypeId="1" CreationDate="2023-03-09T06:13:37.840" Score="2" ViewCount="256" Body="&lt;p&gt;I am trying to use &lt;a href=&quot;https://www.cvxpy.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;CVXPY&lt;/a&gt; to analyse a problem and the objective function for this problem involves calculating a product and a sum as per the problem description below (taken from a draft paper I am writing):&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hZ3og.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hZ3og.png&quot; alt=&quot;printscreen from paper that the author is writing&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;However, I cannot figure out how to specify such an objective function in CVXPY given that it uses a product to combine all of the probability values for a particular target. In order to replicate the objective function, I need to multiply all of the elements of each row in a matrix together (i.e. multiplication along an axis). I am hoping to achieve something like the function shown below, which doesn't work because of the use of the numpy function.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;objective = cp.Maximize(cp.sum(np.prod(1-cp.exp(cp.multiply(x, cp.log(q))), axis=1)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is there any way that I can perform multiplication along an axis in CVXPY? Or, is there an alternative way to represent my objective function?&lt;/p&gt;&#xA;" OwnerUserId="11413" LastEditorUserId="11413" LastEditDate="2023-03-09T23:39:10.443" LastActivityDate="2023-11-09T05:56:06.610" Title="How to represent the objective function of the Weapon Target Assignment problem in CVXPY?" Tags="|python|assignment-problem|cvxpy|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10086" PostTypeId="2" ParentId="10085" CreationDate="2023-03-09T15:28:04.103" Score="3" Body="&lt;p&gt;&lt;strong&gt;TLDR&lt;/strong&gt;: This can be formulated and solved in CXVPY with Mosek as solver, as a Mixed-Integer (generalized) Geometric Programming problem, using CVXPY's Disciplined Geometric Programming (DGP) capability. It can also be formulated and solved in &lt;a href=&quot;http://web.cvxr.com/cvx/doc/gp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;CVX using its gp mode&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Details&lt;/strong&gt;: This satisfies all of CVXPY's Disciplined Geometric Programming (DGP) rules. The objective function is a sum of monomials, which is a posynomial, and is log-log convex. So this can be formulated as a (generalized) Mixed-Integer Geometric Programming problem. Mosek is the best (only?) solver to use, because it has native exponential cone capability, which is invoked by CVXPY to solve the generalized Geometric Programming problem, and can solve such problems subject to integer constraints on some or all of the variables.&lt;/p&gt;&#xA;&lt;p&gt;See the &lt;a href=&quot;https://www.cvxpy.org/examples/dgp/dgp_fundamentals.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;CVXPY web page for Disciplined Geometric Programming (DGP)&lt;/a&gt;,&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-03-09T15:33:10.480" LastActivityDate="2023-03-09T15:33:10.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10087" PostTypeId="2" ParentId="10081" CreationDate="2023-03-09T16:44:10.377" Score="1" Body="&lt;p&gt;If you are open to heuristic (approximate) solutions, one possibility is to generate a set of routes and then rewrite the problem to assign trucks and customers/orders to routes. In problems of this sort, a common tactic is to start with an initial set of routes created manually with an eye toward ensuring you have enough routes to make the problem feasible. The master problem is then relaxed from an IP to an LP and solved, and the dual variables are used to create objective functions in a subproblem that generates additional routes that could be used to improve the LP solution. At some point, you stop generating new routes (either because you cannot find any that look attractive, or because you hit a time limit, or because the master problem is getting too big), restore the integrality restrictions in the master problem and solve it.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-09T16:44:10.377" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10088" PostTypeId="1" CreationDate="2023-03-09T17:03:50.430" Score="0" ViewCount="122" Body="&lt;p&gt;I want to implement some conditions in my objective function. I know adding conditions to constraints is possible through addGenConstrIndicator() but I don't know how I can add conditions in the objective function. Here is a minimal example snippet for my problem. I have variable v with size = 3, prev_values are the previous values for this variable (consider a temporal scenario with the next variable values is dependent on the previous variable values). Now, I want to check if the current value is either equal to 0 or equal to its previous values, and use it in my objective function. How can I implement this in Gurobi (below is a sketch of what I intend to implement)?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = gp.Model()&#xA;E = [2, 4, 7]&#xA;prev_values = [4, 5, 1]&#xA;v = model.addVar(3, lb=0, vtype=gp.GRB.INTEGER, )&#xA;&#xA;def check(vn, vp):&#xA;    if vn == 0 or vn == vp:&#xA;        return 0&#xA;    return 1&#xA;&#xA;model.setObjective(max([check(v[i], prev_values[i]) * E[i] for i in range(3)]) , gp.GRB.MINIMIZE)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11380" LastActivityDate="2023-03-09T17:31:35.037" Title="How to add conditions in objective functions?" Tags="|gurobi|gurobipy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10089" PostTypeId="2" ParentId="10088" CreationDate="2023-03-09T17:31:35.037" Score="1" Body="&lt;p&gt;If you are trying to maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_i E_i f(v_i, p_i)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; are nonnegative integer variables and &lt;span class=&quot;math-container&quot;&gt;$f(v_i, p_i)$&lt;/span&gt; is zero if either argument is zero and 1 if both arguments are strictly positive, you can do it by introduce a new binary variable &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; to represent the value of &lt;span class=&quot;math-container&quot;&gt;$f(v_i, p_i).$&lt;/span&gt; (I'm assuming here that &lt;span class=&quot;math-container&quot;&gt;$E_i$&lt;/span&gt; is a nonnegative parameter.) Your object becomes &lt;span class=&quot;math-container&quot;&gt;$\max \sum_i E_i z_i,$&lt;/span&gt; and you add the constraints &lt;span class=&quot;math-container&quot;&gt;$z_i \le v_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_i \le p_i$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-09T17:31:35.037" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10090" PostTypeId="2" ParentId="10085" CreationDate="2023-03-09T18:34:57.073" Score="3" Body="&lt;p&gt;Now&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rcl}&#xA;t_j &amp;amp; \geq &amp;amp; \prod_{i=1}^m (1-p_{ij})^{x_{ij}} \\&#xA;    &amp;amp; =    &amp;amp; exp(\ln(\prod_{i=1}^m (1-p_{ij})^{x_{ij}})) \\&#xA;    &amp;amp; =    &amp;amp; exp(\sum_{i=1}^m x_{ij} \ln(1-p_{ij})) \\&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;This is the same as saying&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(t_j;1;\sum_{i=1}^m x_{ij} \ln(1-p_{ij})) &#xA;$$&lt;/span&gt;&#xA;has to belong to the primal exponential cone.&lt;/p&gt;&#xA;&lt;p&gt;So you can easily rewrite your problem as a &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/expo.html#exponential-cone-optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;conic optimization problem&lt;/a&gt; involving the exponential cone.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://mosek.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek&lt;/a&gt; for sure can solve those problems even if some variables are constrained to be integers. I guess Cvxpy+Mosek should be handle that formulation. Not sure how hard the problem will be given the integer constraints.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2023-03-09T18:34:57.073" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10091" PostTypeId="2" ParentId="10016" CreationDate="2023-03-09T20:25:19.213" Score="0" Body="&lt;p&gt;You can get an approximate answer using a genetic algorithm. I tested one (coded in R) using a 30 day horizon, three suppliers with minimum order sizes and shares of the overall orders as above, and with randomly generated demand and cost coefficients and an arbitrary initial inventory. On a small number of test runs, it tended to get within 4% to 6% of the optimal cost (as determined by a MIP model).&lt;/p&gt;&#xA;&lt;p&gt;I made a few tweaks to your problem. First, I required that every order get split among the three suppliers (so if any supplier receives an order in period &lt;span class=&quot;math-container&quot;&gt;$t,$&lt;/span&gt; they all do). Second, to deal with rounding, I allowed the chunk of any order going to a supplier to be at most one unit less than what their percentage of the total order would be. Third, I added a constraint that at the end of the horizon the remaining on-hand inventory plus any inventory in the pipeline (ordered during the planning horizon but not yet delivered) should at least equal the initial inventory. The choice of that limit was arbitrary on my part, but it would be a good idea to set some ending inventory requirement. Otherwise the solution might leave you starting the next planning period with empty shelves.&lt;/p&gt;&#xA;&lt;p&gt;The GA uses a binary chromosome with one bit for each period, where a 1 signals that an order will be placed and a 0 signals no order. Prior to running the GA, we compute the last possible time &lt;span class=&quot;math-container&quot;&gt;$\bar{t}$&lt;/span&gt; for the first order placed (the last time such that the fastest supplier could make a delivery before any demand was lost). Given a chromosome, we repair it if necessary by setting the bit at position &lt;span class=&quot;math-container&quot;&gt;$\bar{t}$&lt;/span&gt; to 1 if no prior bit is 1. Now that we know the order dates (and the total ordering cost), we compute order quantities using a &amp;quot;Just In Time&amp;quot; approach to minimize holding costs. For each order date except the last, we compute the smallest combined order quantity such that, after allocating to suppliers and if necessary boosting it so that all suppliers have their minimum order limit met, no demand is lost prior to the earliest delivery date of the next order. For the final order, we tweak the quantity to also ensure that ending inventory plus orders in the pipeline meet the terminal criterion.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-09T20:25:19.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10092" PostTypeId="1" CreationDate="2023-03-09T20:46:31.707" Score="2" ViewCount="67" Body="&lt;p&gt;I'm working on a scheduling/rostering problem. In this scenario the shifts are predefined with a starting and ending date and time.&lt;br /&gt;&#xA;The problem basically assigns people to shifts with a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 1$&lt;/span&gt; if person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to shift &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;br /&gt;&#xA;In this problem there are especial shifts that represent the rest time. This shifts also have a start and end date and time.&lt;br /&gt;&#xA;The problem already takes care of simultaneous shifts and rest time between shifts, so those constraints are already working.&lt;br /&gt;&#xA;However, I want to restrict the amount of &amp;quot;working&amp;quot; shifts before a &amp;quot;rest&amp;quot; shift.&lt;br /&gt;&#xA;It should be something like: at most 4 working shifts before a rest shift.&#xA;How would I model those constraints?&lt;/p&gt;&#xA;" OwnerUserId="8891" LastActivityDate="2023-03-17T15:01:57.900" Title="How to restrict the amount of consecutive assignments" Tags="|mixed-integer-programming|constraint|binary-variable|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10093" PostTypeId="2" ParentId="10092" CreationDate="2023-03-09T22:58:08.000" Score="0" Body="&lt;p&gt;If aim is to restrict non consecutive shifts then&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{j\lt k}x_{ij} \le 3+y_{i,k} \\\forall k\in S_i$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; is set of designated shift time for worker &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and shift indicator is the binary &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If consecutive shift then&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j\lt k}^{j-3} x_{i,k} \le 3 +y_{i,k} $&lt;/span&gt;&lt;br /&gt;&#xA;You may also have &lt;span class=&quot;math-container&quot;&gt;$x_{ik}+y_{ik} \le 1$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-09T23:20:50.890" LastActivityDate="2023-03-09T23:20:50.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10094" PostTypeId="1" CreationDate="2023-03-10T09:43:03.303" Score="3" ViewCount="280" Body="&lt;p&gt;I'm a solving a model that has the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c_{p,n} = \sum_{s\in S}\sum_{i \in \{1,2,3\} } x_{p,s,i-1} x_{n,s,i}, \forall (p,n) \in C&#xA;$$&lt;/span&gt;&#xA;where both the &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables are binary, &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is a set of indices. The indices &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; stand for &amp;quot;previous&amp;quot; and &amp;quot;next&amp;quot; and represent the same entity, i.e. they both belong to a set &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p \in T$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$n \in T$&lt;/span&gt;. Their combinations are listed in &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;. The constraint above is used to know whether any combination of &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is chosen. The variables &lt;span class=&quot;math-container&quot;&gt;$c_{p,n}$&lt;/span&gt; appear in the cost function weighted by a cost &lt;span class=&quot;math-container&quot;&gt;$w_{p,n}\in \mathbb{R}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Other relevant constraints in the problem are:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\sum_{s\in S}\sum_{i \in I} x_{p,s,i} &amp;amp;\leq 1, \forall p \in T \\&#xA;\sum_{p\in T} x_{p,s,i} &amp;amp;\leq 1, \forall s \in S, \forall i \in I \\&#xA;\sum_{p\in T} x_{p,s,i} &amp;amp;\leq \sum_{p\in T} x_{p,s,i-1}, \forall s \in S, \forall i \in \{1,2,3\}, \\&#xA;\end{align}$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$I=\{0,1,2,3\}$&lt;/span&gt;. Note that in the last constraint, both the left-hand-size and the right-hand-size can sum up to 1 at most (due to the second constraint).&lt;/p&gt;&#xA;&lt;p&gt;The bilinear constraints above make my problem slow to solve in certain (large) instances. I tried to reformulate them using a linear reformulation. I created binary variables &lt;span class=&quot;math-container&quot;&gt;$y_{p,n,s,i}$&lt;/span&gt; to replace the above variables &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and added the three following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;y_{p,n,s,i} &amp;amp;\leq x_{p,s,i-1}, \forall (p, n) \in C, \forall s \in S, \forall i\in \{1,2,3\} \\&#xA;y_{p,n,s,i} &amp;amp;\leq x_{n,s,i}, \forall (p, n) \in C, \forall s \in S, \forall i\in \{1,2,3\} \\&#xA;y_{p,n,s,i} &amp;amp;\geq x_{p,s,i-1} + x_{n,s,i} - 1, \forall (p, n) \in C, \forall s \in S, \forall i\in \{1,2,3\} \\&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, after doing so, the problem is even slower to solve on the same large instances mentioned before. The issue is that there are many more variables now (one order of magnitude more) and many more constraints. Gurobi, which is the solver I'm using, needs to spend a lot of time in the presolve phase making the problem smaller. Then, when solving the problem, it also spends a large amount of time in the root node and after that starts exploring the tree, where there are now many more nodes to explore, and thus it takes more time to reach the optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;I tried using a lot of different parameters of Gurobi to no avail. I also added my own cuts with information on the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables and on the model to help Gurobi but again I didn't succeed in speeding up the optimization.&lt;/p&gt;&#xA;&lt;p&gt;Is there any other reformulation I could use to remove the bilinear constraint?&lt;/p&gt;&#xA;" OwnerUserId="10208" LastEditorUserId="10208" LastEditDate="2023-03-11T09:06:50.870" LastActivityDate="2023-03-12T13:43:51.213" Title="Reformulate bilinear binary constraint" Tags="|mixed-integer-programming|gurobi|linearization|binary-variable|runtime|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10095" PostTypeId="1" CreationDate="2023-03-10T10:01:44.790" Score="1" ViewCount="61" Body="&lt;p&gt;I have a bi-objective mixed integer linear programming (MILP) problem, which contains two specially sub-objective functions. The first linear objective function, only contains integer variables, while the second one only has continuous variables. In general, such a MILP problem could be solved directly by the solver.&#xA;However, recently, I discovered that my MILP problem can be solved in two steps. Firstly, the optimal integer variables can be solved directly by solving a sub-problem that contains the first sub-objective function and constraints related to integer variables. Then, with the obtained integer variables, the MILP problem could be transformed into a linear program problem and find the optimal continuous variables. In this way, the obtained optimal solutions (integer variables and continuous variables) are the same as the way to solve the MILP problem directly.&#xA;Is there some feasible way for me to prove that this phenomenon is true?&lt;/p&gt;&#xA;" OwnerUserId="11422" LastEditorUserId="491" LastEditDate="2023-03-11T04:01:12.270" LastActivityDate="2023-03-11T04:01:12.270" Title="bi-objective mixed integer linear programming (MILP) problem" Tags="|mixed-integer-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10096" PostTypeId="1" CreationDate="2023-03-10T12:37:24.080" Score="2" ViewCount="189" Body="&lt;p&gt;I am struggling to correctly interpret the meaning of a dual ray for an infeasible primal lp.&#xA;Consider the following example.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min z = y_1 + y_2 -2y_3 &#xA;$$&lt;/span&gt;&#xA;s.t&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_1 -2y_1 -y_3 \ge 3 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-2y_1 - y_2  &amp;gt;=2 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_1, y_2, y_3 \ge 0$$&lt;/span&gt;&#xA;which has a dual&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max w = 3u_1 + 2u_2$$&lt;/span&gt;&#xA;s.t.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$u_1 - 2u_2 \le 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-2u_1 - u_2 \le 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-u_2 \le -2$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$u_1, u_2 \ge 0.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this case, the primal is clearly infeasible and the dual is unbounded (as expected).&#xA;Now if I want to extract the extreme ray for this problem what should I do? If I solve the problem using docplex, turning off presolve and choosing the dual simplex with the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;prob = Model('infeasible')&#xA;y = prob.continuous_var_list(range(3), name = 'y', lb = 0)&#xA;c1 = prob.add_constraint(y[0] -2*y[1] - y[2]&amp;gt;= 3)&#xA;c2 = prob.add_constraint(-2*y[0] - y[1]&amp;gt;= 2)&#xA;obj = y[0] + y[1] -2*y[2]&#xA;prob.set_objective(&amp;quot;min&amp;quot;, obj)&#xA;prob.parameters.lpmethod = 2&#xA;prob.parameters.preprocessing.presolve = 0&#xA;sol=prob.solve(log_output = True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The solver returns infeasible. Now I want to get the extreme ray for this problem. At this &lt;a href=&quot;https://www.ibm.com/support/pages/how-obtain-extreme-ray-when-lp-unbounded&quot; rel=&quot;nofollow noreferrer&quot;&gt;post&lt;/a&gt; they say that we should use the dualfarkas member function. If I do this as follows&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;farkasConstraints, farkasValues = prob.get_engine().get_cplex().solution.advanced.dual_farkas() &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I get that &lt;code&gt;farkasConstraints = [1.0, 0.5]&lt;/code&gt; and &lt;code&gt;farkasValues = 4&lt;/code&gt;, how should I interpret this? What is confusing me is that if I use&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ray = prob.get_engine().get_cplex().solution.get_dual_values()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I get that &lt;code&gt;ray = [2.0,0.5]&lt;/code&gt;. What is the difference between the two? To make things more confusing, if I solve the problem in Xpress and obtain the dual ray using the &lt;code&gt;ray = prob.getdyalray()&lt;/code&gt; I get &lt;code&gt;ray = [0.5, 0.25]&lt;/code&gt; which is exactly half what cplex returns. Does this mean that the dual ray is not unique? I summarize my questions as follows.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How should I interpret the dual ray?&lt;/li&gt;&#xA;&lt;li&gt;Which cplex method is correct?&lt;/li&gt;&#xA;&lt;li&gt;What element of the extreme ray corresponds to which constraint?&lt;/li&gt;&#xA;&lt;li&gt;Why is the dual ray found using cplex different from the one returned by Xpress?&lt;/li&gt;&#xA;&lt;li&gt;If I solved the dual problem directly, how could I get the extreme ray?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11181" LastEditorUserId="11181" LastEditDate="2023-03-13T14:11:54.007" LastActivityDate="2023-03-13T14:11:54.007" Title="Obtaining the dual ray of an infeasible lp to generate a benders feasibility cut" Tags="|linear-programming|docplex|benders-decomposition|extreme-rays|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10097" PostTypeId="2" ParentId="10094" CreationDate="2023-03-10T13:17:39.277" Score="0" Body="&lt;p&gt;If sum &lt;span class=&quot;math-container&quot;&gt;$\sum_{s\in S}\sum_{i \in \{1,2,3\} } x_{p,s,i-1} x_{n,s,i}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$\le 1$&lt;/span&gt; then you can modify as&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ y_{s}\le \sum_i x_{p,s,i-1} $&lt;/span&gt;.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ y_s\le \sum_i x_{n,s,i}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_i x_{p,s,i-1}+\sum_s x_{n,s,i}\le y_{s}+1 \ \ \forall (p,n) \in C \ \ \forall s$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Elsif &lt;span class=&quot;math-container&quot;&gt;$\sum_s x_{n,s,i}\ge 1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{n,s,i}\le M\sum_i x_{p,s,i-1}$&lt;/span&gt;&lt;br /&gt;&#xA;Then for &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; use only &lt;span class=&quot;math-container&quot;&gt;$x_{n,s,i}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The above will reduce your constraints and thus size of the model.&lt;/p&gt;&#xA;&lt;p&gt;In addition the following links from Gurobi may be helpful.&lt;br /&gt;&#xA;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/6177882007441-Slow-MIP-performance&quot; rel=&quot;nofollow noreferrer&quot;&gt;Link1&lt;/a&gt;,&lt;br /&gt;&#xA;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/4419521725329-Conditional-parameter-slow-MIP-solving&quot; rel=&quot;nofollow noreferrer&quot;&gt;Link2&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-12T13:43:51.213" LastActivityDate="2023-03-12T13:43:51.213" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10098" PostTypeId="2" ParentId="10094" CreationDate="2023-03-10T13:24:10.120" Score="3" Body="&lt;p&gt;If the cost &lt;span class=&quot;math-container&quot;&gt;$w_{p,n}$&lt;/span&gt; is nonnegative, you should be able to get by with no additional variables and the following linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c_{p,n} \ge x_{p,s,i-1} + x_{n,s,i} - 1&#xA;$$&lt;/span&gt;&#xA;These arise from the following logical proposition:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\bigvee_{s,i} (x_{p,s,i-1} \land x_{n,s,i}) \implies c_{p,n}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-10T13:34:43.800" LastActivityDate="2023-03-10T13:34:43.800" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10099" PostTypeId="2" ParentId="10096" CreationDate="2023-03-10T16:56:52.550" Score="1" Body="&lt;p&gt;Technically, a &lt;em&gt;recession direction&lt;/em&gt; is a vector &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; such that if &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is feasible then so is &lt;span class=&quot;math-container&quot;&gt;$w+\lambda v$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$\lambda &amp;gt; 0,$&lt;/span&gt; while a &lt;em&gt;ray&lt;/em&gt; is a recession direction anchored at a specific point. Most people in optimization use the terms interchangeably (I think).&lt;/p&gt;&#xA;&lt;p&gt;So to answer (some of) your questions ...&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;As I explained in the definition of recession direction, the dual ray is a vector of &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; values that, if multiplied by a positive amount and added to any &lt;span class=&quot;math-container&quot;&gt;$\hat{w}$&lt;/span&gt; feasible in the dual, produces another solution feasible in the dual. For instance, &lt;span class=&quot;math-container&quot;&gt;$(0,0)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2, 0.5)$&lt;/span&gt; are feasible solutions to your dual and &lt;span class=&quot;math-container&quot;&gt;$(1, 0.5)$&lt;/span&gt; is a recession direction. For any &lt;span class=&quot;math-container&quot;&gt;$\lambda &amp;gt; 0,$&lt;/span&gt; both &lt;span class=&quot;math-container&quot;&gt;$(\lambda, 0.5\lambda)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2 + \lambda, 0.5 + 0.5\lambda)$&lt;/span&gt; are feasible in the dual.&lt;/li&gt;&#xA;&lt;li&gt;You are misinterpreting the vector &lt;span class=&quot;math-container&quot;&gt;$(2, 0.5).$&lt;/span&gt; It is &lt;em&gt;not&lt;/em&gt; a ray; it is a feasible solution to the dual. When solving the dual, CPLEX got to that corner of the dual feasible region and then discovered a direction along which the objective function improved forever, at which point it stopped and declared the problem unbounded.&lt;/li&gt;&#xA;&lt;li&gt;I do not understand what you are asking here.&lt;/li&gt;&#xA;&lt;li&gt;They are the same ray. One is just twice the other. The key is that they are pointing in exactly the same direction.&lt;/li&gt;&#xA;&lt;li&gt;If you mean solving it by hand, using the simplex method, at some point you would obtain a tableau where the reduced costs pointed to a variable that wanted to enter the basis but the row selection criterion would fail to find a row in which to pivot. The pivot column would be a recession direction.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-10T16:56:52.550" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10100" PostTypeId="1" AcceptedAnswerId="10101" CreationDate="2023-03-10T17:54:20.047" Score="1" ViewCount="60" Body="&lt;p&gt;Given the following model, what's the suitable optimization model for it?&lt;br /&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/PCWSs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PCWSs.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{i,j}^N$&lt;/span&gt; is a Matrix. (is known, and &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; stands for Normalized. It means, &lt;span class=&quot;math-container&quot;&gt;$X_{i,j}^N$&lt;/span&gt; is normalized version of &lt;span class=&quot;math-container&quot;&gt;$X_{i,j}$&lt;/span&gt;; so, &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is not an operator.)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is a vector (we are looking for &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; in this case) (unknown)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sigma^N$&lt;/span&gt; is a vector (is known, and &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; stands for normalized)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\pi_j^N$&lt;/span&gt; is a vector (is known, and &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; stands for normalized)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\epsilon=10^{-3}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; is a floating point scaler (is known)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6022" LastEditorUserId="6022" LastEditDate="2023-03-10T18:44:19.430" LastActivityDate="2023-03-10T23:12:58.933" Title="What's the suitable optimization model for solving the given model?" Tags="|optimization|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10101" PostTypeId="2" ParentId="10100" CreationDate="2023-03-10T23:12:58.933" Score="2" Body="&lt;p&gt;We can eliminate a few variables and rewrite the problem as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\max\lambda_{a}-\beta\left[\sum_{j}\left(w_{j}-\sigma_{j}^{N}\right)^{2}+\sum_{j}\left(w_{j}-\pi_{j}^{N}\right)^{2}\right]\\&#xA;\textrm{s.t. }\sum_{j}w_{j}x_{ij}^{N} - \lambda_{a}&amp;amp; \ge 0\\&#xA;\sum_{j}w_{j} &amp;amp; =1\\&#xA;w_{j} &amp;amp; \le1\quad\forall j\\&#xA;w_{j} &amp;amp; \ge\epsilon\quad\forall j&#xA;\end{align*}&lt;/span&gt;&#xA;noting that the constraint &lt;span class=&quot;math-container&quot;&gt;$w_j \le 1$&lt;/span&gt; is actually redundant give the constraints above and below it. Since the quantity inside the square brackets is convex in &lt;span class=&quot;math-container&quot;&gt;$w,$&lt;/span&gt; the objective is concave and quadratic, and the constraints are linear. So you have an ordinary quadratic programming problem, which can be solved by quite a few solvers, both commercial (CPLEX, Gurobi, Xpress) and open-source.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-10T23:12:58.933" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10102" PostTypeId="2" ParentId="10058" CreationDate="2023-03-11T00:56:31.337" Score="0" Body="&lt;p&gt;MINLP (Mixed-Integer Non-Linear Problem) solvers can process the optimization predicate of the question I asked of which Bonmin and Couenne are two &lt;a href=&quot;https://en.wikipedia.org/wiki/Free_and_open-source_software&quot; rel=&quot;nofollow noreferrer&quot;&gt;FOSS&lt;/a&gt; examples, both natively supported in AMPL.&lt;/p&gt;&#xA;&lt;p&gt;For such a solver the example stated can more suitably be expressed as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;param max_amt=1;&#xA;param min_amt=.05;&#xA;var purchase {CUSTOMER} in interval [min_amount,max_amt] union {0};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;rounding &lt;code&gt;purchase[]&lt;/code&gt; as &lt;code&gt;round(purchase[],2)&lt;/code&gt; wherever it is inputted.&lt;/p&gt;&#xA;&lt;p&gt;This so far has been the most efficient, least computationally intensive, remedy among the answers I've come across and won't lead to software crash as easily when the range between &lt;code&gt;min_amt&lt;/code&gt; and &lt;code&gt;max_amt&lt;/code&gt; enlarges.&lt;/p&gt;&#xA;" OwnerUserId="11394" LastActivityDate="2023-03-11T00:56:31.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10103" PostTypeId="1" CreationDate="2023-03-11T02:04:21.760" Score="0" ViewCount="128" Body="&lt;p&gt;Here is the Saudi-Israel game framework as a Stack Exchange question with MathJax:&lt;/p&gt;&#xA;&lt;p&gt;game-theory markov-processes&lt;/p&gt;&#xA;&lt;p&gt;How can I model the dynamics of Saudi-Israel relations using a stochastic game with Markov states?&lt;/p&gt;&#xA;&lt;p&gt;I'm trying to analyze the fluctuations in Saudi-Israel relations over time using a game-theoretic model. Here is a basic framework I've devised:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{Players}: &amp;amp;&amp;amp; S = \text{Saudi Arabia}, I = \text{Israel} \\&#xA;\text{States}: &amp;amp;&amp;amp; H = \text{Hostile}, C = \text{Cooperative} \\&#xA;\text{Payoffs per period}: &amp;amp;&amp;amp;&#xA;H &amp;amp;= (U(SD), U(ID)) \\&#xA;C &amp;amp;= (U(SC), U(IC)) \\&#xA;\text{State transitions}: &amp;amp;&amp;amp;&#xA;H \to C &amp;amp;= P(\text{Bincrease}) \text{ for } S, P(\text{Bdecrease}) \text{ for } I \\&#xA;C \to H &amp;amp;= P((\text{Z,Rincrease})) \text{ for } S, P((\text{Z,Rdecrease})) \text{ for } I&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I implement and analyze this type of model? Some questions I have:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How should I define the payoff functions &lt;span class=&quot;math-container&quot;&gt;$U(.\cdot)$&lt;/span&gt; and transition probabilities &lt;span class=&quot;math-container&quot;&gt;$P(.\cdot)$&lt;/span&gt; based on factors like cooperation benefits/costs and conflict risks?&lt;/li&gt;&#xA;&lt;li&gt;How can I simulate the model to explore how different parameters/assumptions impact the time spent in hostile vs. cooperative states?&lt;/li&gt;&#xA;&lt;li&gt;What kinds of insights might be gained from such a model? What are its limitations in analyzing real-world relationships like this?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;How do I model such stochastic dynamic games?&lt;/p&gt;&#xA;" OwnerUserId="11425" LastEditorUserId="491" LastEditDate="2023-03-11T04:00:17.070" LastActivityDate="2024-04-04T18:05:45.727" Title="Analytic international relations" Tags="|markov-decision-process|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10104" PostTypeId="1" AcceptedAnswerId="10105" CreationDate="2023-03-11T08:30:14.733" Score="4" ViewCount="307" Body="&lt;p&gt;I am trying to linearize the following expression without using the Big-M formulation, but I cannot convert it. I am willing to know if there exists an efficient way to do that?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ Iff \quad (w=1) \Longleftrightarrow (x \Longleftrightarrow y)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; are binary variables?&lt;/p&gt;&#xA;" OwnerUserId="11407" LastActivityDate="2023-03-11T20:14:35.933" Title="The linearization of the (Iff-and-only-Iff) expression" Tags="|modeling|linearization|logical-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10105" PostTypeId="2" ParentId="10104" CreationDate="2023-03-11T08:53:34.337" Score="5" Body="&lt;p&gt;One possible way to linearize such a constraint would be by dividing this expression into four parts and then linearizing each of which separately.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ Iff \quad (w=1) \rightarrow (x \rightarrow y) \quad (\text{Part-1})$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ Iff \quad (w=1) \rightarrow (y \rightarrow x) \quad (\text{Part-2})$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ Iff \quad (x \rightarrow y) \rightarrow (w=1) \quad (\text{Part-3})$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ Iff \quad (y \rightarrow x) \rightarrow (w=1) \quad (\text{Part-4})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, the first one can be translated as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (w) \rightarrow (\lnot x \lor y)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \lnot(w) \lor (\lnot x \lor y)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \lnot w \lor \lnot x \lor y$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (1-w) + (1-x) + y \geq 1 \quad (\text{Part-1})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The second part would be the same as the one and the result is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (1-w) + (1-y) + x \geq 1 \quad (\text{Part-2})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The third part can be linearized as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (\lnot x \lor y) \rightarrow (w)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \lnot (\lnot x \lor y) \lor(w)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (x \land \lnot y) \lor (w)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (x \lor w) \bigwedge (\lnot y \lor w)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (x + w \geq 1) \bigwedge ((1-y) + w \geq 1) \quad (\text{Part-3})$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (y + w \geq 1) \bigwedge ((1-x) + w \geq 1) \quad (\text{Part-4})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, the third and fourth parts can already be written as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \lnot ((\lnot x \lor y) \land (\lnot y \lor x)) \lor w$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (x + y + w \geq 1) \bigwedge (w \geq x + y - 1) \quad (\text{Part-(3,4)})$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-03-11T08:53:34.337" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10106" PostTypeId="2" ParentId="10104" CreationDate="2023-03-11T12:38:32.423" Score="4" Body="&lt;p&gt;@A.Omidi gave a nice derivation using conjunctive normal form.  In this case, the big-M approach with &lt;span class=&quot;math-container&quot;&gt;$M=1$&lt;/span&gt; yields the same formulation:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w = 1 \implies x=y$$&lt;/span&gt;&#xA;can be enforced via&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-(1-w) \le x-y \le 1-w,$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w = 0 \implies x+y=1$$&lt;/span&gt;&#xA;can be enforced via&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-w \le x+y-1 \le w.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;An alternative approach is to introduce a binary decision variable &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; and impose a single equality constraint &lt;span class=&quot;math-container&quot;&gt;$$x+y=2v+1-w.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-11T20:14:35.933" LastActivityDate="2023-03-11T20:14:35.933" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10107" PostTypeId="2" ParentId="10103" CreationDate="2023-03-11T12:58:15.933" Score="0" Body="&lt;p&gt;Here's an attempt of an analytic, SDE, to frame an insight.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$dX_t = [A\_1(X_t)*(U(SC) - U(SD)) + A\_2(t)*[P(Z,R\_{increase}) - P(Z,R\_{decrease})]] dt&#xA;        + [B\_1*dv(oil\_price) + B\_2*dv(petrodollar\_status)] dW_t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;X&lt;span class=&quot;math-container&quot;&gt;$_t$&lt;/span&gt; is the state variable representing relations&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$A\_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A\_2$&lt;/span&gt; are functions for drift towards cooperation vs. conflict, dependent on current state and time-varying conditions&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$B\_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B\_2$&lt;/span&gt; are parameters determining diffusion magnitude from oil price and petrodollar volatility&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$dv(.)$&lt;/span&gt; represents volatility of the economic variables&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$dW_t$&lt;/span&gt; is a Wiener process representing random shocks&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The specific forms of the &lt;span class=&quot;math-container&quot;&gt;$A_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$A_2$&lt;/span&gt; and volatility functions, and values of the parameters, would be estimated based on data/modeling assumptions about the relationships between the variables.&lt;/p&gt;&#xA;&lt;p&gt;Simulating and analyzing the SDE could reveal how relations might fluctuate around trends, and be impacted by economic factors.&lt;/p&gt;&#xA;&lt;p&gt;Of course, this is a simplified model and would face the usual challenges in capturing such a complex real-world system.&lt;/p&gt;&#xA;" OwnerUserId="11425" LastEditorUserId="51" LastEditDate="2023-03-11T16:42:43.417" LastActivityDate="2023-03-11T16:42:43.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10109" PostTypeId="1" CreationDate="2023-03-12T05:38:04.347" Score="2" ViewCount="1173" Body="&lt;p&gt;When I solve the following code, the binaries for the &lt;code&gt;lines_selection&lt;/code&gt; variable is not respected by PuLP. Can anyone please point me out to the reason why this could occur?&lt;/p&gt;&#xA;&lt;p&gt;I've also attached the output LP file for reference.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pandas as pd&#xA;plants = {1:('Plant 1'), 2: ('Plant 2')}&#xA;customers = {1: ('Customer 1'), 2: ('Customer 2'), 3: ('Customer 3')}&#xA;demands = {1: 50, 2: 50, 3: 25}&#xA;line_options = [1, 2]#{1:('Base'), 2: ('Double Base')}&#xA;line_options_cost = {1: 0, 2: 10}&#xA;line_options_capacity = {1: 50, 2: 100}&#xA;costs = {(1, 1): 1, (1, 2): 1.5, (1,3): 1.5, (2,1): 1, (2,2): 1, (2,3): 1}&#xA;&#xA;#Declare the problem&#xA;Investment_Decisions_Problem = LpProblem(&amp;quot;Investment_Decisions&amp;quot;, LpMinimize)&#xA;&#xA;#Variable - Config of plant lines&#xA;lines_selection = LpVariable.dicts(&amp;quot;Line Selection&amp;quot;, [(i, j) for i in line_options for j in plants], cat='binary')&#xA;#lines_selection = LpVariable.dicts(&amp;quot;Line Selection&amp;quot;, [(i, j) for i in line_options for j in plants], lowBound = 0, upBound = 1, cat='interger')&#xA;&#xA;#Variable - Flow of product from plant to customer&#xA;flow_vars = LpVariable.dicts(&amp;quot;Flow&amp;quot;, [(j, k) for j in plants for k in customers], lowBound = 0, cat = 'continuous')&#xA;&#xA;#Adding an internal flow variable&#xA;internal_flow = LpVariable.dicts(&amp;quot;Flow_Internal&amp;quot;, [(j) for j in plants], lowBound = 0, cat = 'continuous')&#xA;#Setting objective&#xA;total_cost = lpSum(flow_vars[j,k] * costs[j,k] for j in plants for k in customers) + lpSum(lpSum(lines_selection[i,j] * line_options_cost[i] for i in line_options) for j in plants)&#xA;&#xA;# Constraints&#xA;# C1 - All customer demand must be satisfied&#xA;for k in customers:                      &#xA;    Investment_Decisions_Problem += LpConstraint(e = lpSum([flow_vars[j,k] for j in plants]),&#xA;                                        sense = LpConstraintEQ,&#xA;                                        name = 'Demand_Satisfied_'+str(k),&#xA;                                        rhs = demands[k])&#xA;&#xA;# C2 - Flow must be less than capacity&#xA;for j in plants:&#xA;    Investment_Decisions_Problem += LpConstraint(e = lpSum([flow_vars[j,k] for k in customers]) - internal_flow[j],&#xA;                                                 sense = LpConstraintEQ,&#xA;                                                 name = 'Equalizing_multi_echlon_flow_'+str(j),&#xA;                                                 rhs = 0)&#xA;&#xA;# C3 - Balancing internal flow&#xA;for j in plants:&#xA;    Investment_Decisions_Problem += LpConstraint(e = lpSum([lines_selection[i,j] * line_options_capacity[i] for i in line_options]) - internal_flow[j],&#xA;                                                 sense = LpConstraintEQ,&#xA;                                                 name = 'Multi_Echelon_Flow_vs_capacity'+str(j),&#xA;                                                 rhs = 0)&#xA;&#xA;# C4 - Only one line options is possible&#xA;for j in plants:&#xA;    Investment_Decisions_Problem += LpConstraint(e = lpSum([lines_selection[i,j] for i in line_options]),&#xA;                                                 sense = LpConstraintEQ,&#xA;                                                 name = 'Only one option'+str(j),&#xA;                                                 rhs = 1)&#xA;# Setting problem objective&#xA;Investment_Decisions_Problem.setObjective(total_cost)&#xA;&#xA;# The problem data is written to an .lp file&#xA;Investment_Decisions_Problem.writeLP(&amp;quot;Investment_Decisions_Flow.lp&amp;quot;)&#xA;    &#xA;# The problem is solved using PuLP's choice of Solver&#xA;Investment_Decisions_Problem.solve()&#xA;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Output LP file:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;* Investment_Decisions *&lt;br /&gt;&#xA;Minimize&#xA;OBJ: Flow_(1,&lt;em&gt;1) + 1.5 Flow&lt;/em&gt;(1,&lt;em&gt;2) + 1.5 Flow&lt;/em&gt;(1,&lt;em&gt;3) + Flow&lt;/em&gt;(2,_1)&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Flow_(2,&lt;em&gt;2) + Flow&lt;/em&gt;(2,&lt;em&gt;3) + 10 Line_Selection&lt;/em&gt;(2,_1)&lt;/li&gt;&#xA;&lt;li&gt;10 Line_Selection_(2,&lt;em&gt;2)&#xA;Subject To&#xA;Demand_Satisfied_1: Flow&lt;/em&gt;(1,&lt;em&gt;1) + Flow&lt;/em&gt;(2,&lt;em&gt;1) = 50&#xA;Demand_Satisfied_2: Flow&lt;/em&gt;(1,&lt;em&gt;2) + Flow&lt;/em&gt;(2,&lt;em&gt;2) = 50&#xA;Demand_Satisfied_3: Flow&lt;/em&gt;(1,&lt;em&gt;3) + Flow&lt;/em&gt;(2,&lt;em&gt;3) = 25&#xA;Equalizing_multi_echlon_flow_1: Flow&lt;/em&gt;(1,&lt;em&gt;1) + Flow&lt;/em&gt;(1,&lt;em&gt;2) + Flow&lt;/em&gt;(1,_3)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Flow_Internal_1 = 0&#xA;Equalizing_multi_echlon_flow_2: Flow_(2,&lt;em&gt;1) + Flow&lt;/em&gt;(2,&lt;em&gt;2) + Flow&lt;/em&gt;(2,_3)&lt;/li&gt;&#xA;&lt;li&gt;Flow_Internal_2 = 0&#xA;Multi_Echelon_Flow_vs_capacity1: - Flow_Internal_1 + 50 Line_Selection_(1,_1)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;100 Line_Selection_(2,&lt;em&gt;1) = 0&#xA;Multi_Echelon_Flow_vs_capacity2: - Flow_Internal_2 + 50 Line_Selection&lt;/em&gt;(1,_2)&lt;/li&gt;&#xA;&lt;li&gt;100 Line_Selection_(2,&lt;em&gt;2) = 0&#xA;Only_one_option1: Line_Selection&lt;/em&gt;(1,&lt;em&gt;1) + Line_Selection&lt;/em&gt;(2,&lt;em&gt;1) = 1&#xA;Only_one_option2: Line_Selection&lt;/em&gt;(1,&lt;em&gt;2) + Line_Selection&lt;/em&gt;(2,&lt;em&gt;2) = 1&#xA;Bounds&#xA;0 &amp;lt;= Flow&lt;/em&gt;(1,&lt;em&gt;1)&#xA;0 &amp;lt;= Flow&lt;/em&gt;(1,&lt;em&gt;2)&#xA;0 &amp;lt;= Flow&lt;/em&gt;(1,&lt;em&gt;3)&#xA;0 &amp;lt;= Flow&lt;/em&gt;(2,&lt;em&gt;1)&#xA;0 &amp;lt;= Flow&lt;/em&gt;(2,&lt;em&gt;2)&#xA;0 &amp;lt;= Flow&lt;/em&gt;(2,&lt;em&gt;3)&#xA;0 &amp;lt;= Flow_Internal_1&#xA;0 &amp;lt;= Flow_Internal_2&#xA;Line_Selection&lt;/em&gt;(1,&lt;em&gt;1) free&#xA;Line_Selection&lt;/em&gt;(1,&lt;em&gt;2) free&#xA;Line_Selection&lt;/em&gt;(2,&lt;em&gt;1) free&#xA;Line_Selection&lt;/em&gt;(2,_2) free&#xA;End&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Clearly mentions that&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Line_Selection_(1,&lt;em&gt;1) free&#xA;Line_Selection&lt;/em&gt;(1,&lt;em&gt;2) free&#xA;Line_Selection&lt;/em&gt;(2,&lt;em&gt;1) free&#xA;Line_Selection&lt;/em&gt;(2,_2) free&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;are all free or unrestricted variables. Any idea what I am doing wrong?&#xA;TIA&lt;/p&gt;&#xA;" OwnerUserId="11431" LastEditorUserId="11431" LastEditDate="2023-03-12T05:39:06.470" LastActivityDate="2023-03-12T16:22:13.400" Title="Any Idea why PuLP is ignoring binary variables?" Tags="|mixed-integer-programming|pulp|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10110" PostTypeId="1" CreationDate="2023-03-12T06:28:12.977" Score="3" ViewCount="155" Body="&lt;p&gt;The solver API for CP-SAT offers the attribute &lt;code&gt;NumBooleans&lt;/code&gt;, which is documented as &amp;quot;Returns the number of boolean variables managed by the SAT solver&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Excuse my ignorance, but why is this a property of the &lt;em&gt;solution&lt;/em&gt; rather than the model itself? Should I think about the solver as applying some simplifying preprocessing steps to the model, and the number indicating the complexity of the model after that, or what is the right mental model here?&lt;/p&gt;&#xA;" OwnerUserId="11390" LastEditorUserId="981" LastEditDate="2023-03-13T10:30:09.420" LastActivityDate="2023-03-13T10:30:09.420" Title="CP-SAT's `NumBooleans()` parameter" Tags="|or-tools|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10111" PostTypeId="2" ParentId="10109" CreationDate="2023-03-12T06:36:07.980" Score="4" Body="&lt;p&gt;You need to capitalize the first letter in the cat option:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Variable - Config of plant lines&#xA;lines_selection = LpVariable.dicts(&amp;quot;Line Selection&amp;quot;, [(i, j) for i in line_options for j in plants], cat='Binary')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2023-03-12T06:36:07.980" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10112" PostTypeId="2" ParentId="10110" CreationDate="2023-03-12T06:44:23.293" Score="5" Body="&lt;p&gt;This does not count Boolean variables in the model. It counts Boolean variables in the SAT solver. This is vastly different. Presolve is happening, some constraints are expanded, search and conflicts create Boolean variables. It differs even among workers solving the same model.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-03-12T06:44:23.293" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10113" PostTypeId="2" ParentId="10109" CreationDate="2023-03-12T07:02:16.530" Score="3" Body="&lt;p&gt;Some points should be considered.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First, you defined the variable &lt;span class=&quot;math-container&quot;&gt;$FlowInternal_{j}$&lt;/span&gt; as the slack variables on the constraints &lt;span class=&quot;math-container&quot;&gt;$C_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_3$&lt;/span&gt; but, forgot to limit it on the objective function. (For example, by a &lt;em&gt;&lt;strong&gt;Big_M&lt;/strong&gt;&lt;/em&gt; cost).&lt;/li&gt;&#xA;&lt;li&gt;Second, as this slack variable appears on the two different constraints, its values might be different which causes infeasibility.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;One possible way would be by relaxing those constraints &lt;strong&gt;from &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt;&lt;/strong&gt; to achieve what you want. Also, by solving the above problem based on the mentioned points, the solution and its corresponding LP file would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;---- VAR objective      -INF  10125.000     +INF       .         &#xA;&#xA;---- VAR x  &#xA;&#xA;                       LOWER     LEVEL     UPPER   &#xA;&#xA;Base       .plant_1      .        1.000     1.000       &#xA;Base       .plant_2      .        1.000     1.000       &#xA;double_Base.plant_1      .         .        1.000      &#xA;double_Base.plant_2      .         .        1.000      &#xA;&#xA;---- VAR flow  &#xA;&#xA;                      LOWER     LEVEL     UPPER    &#xA;&#xA;plant_1.customer_1      .       50.000     +INF               &#xA;plant_1.customer_2      .         .        +INF           &#xA;plant_1.customer_3      .         .        +INF           &#xA;plant_2.customer_1      .         .        +INF           &#xA;plant_2.customer_2      .       50.000     +INF               &#xA;plant_2.customer_3      .       25.000     +INF              &#xA;&#xA;---- VAR flow_internal  &#xA;&#xA;           LOWER     LEVEL     UPPER    &#xA;&#xA;plant_1      .       25.000     +INF                &#xA;plant_2      .       25.000     +INF         &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;LP File:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;objf..  objective - 10*x(double_Base,plant_1) - 10*x(double_Base,plant_2)&#xA;     &#xA;      - flow(plant_1,customer_1) - 1.5*flow(plant_1,customer_2)&#xA;     &#xA;      - 1.5*flow(plant_1,customer_3) - flow(plant_2,customer_1)&#xA;     &#xA;      - flow(plant_2,customer_2) - flow(plant_2,customer_3)&#xA;     &#xA;      - 200*flow_internal(plant_1) - 200*flow_internal(plant_2) =E= 0 ;&#xA;&#xA;---- e1&#xA;&#xA;e1(plant_1)..  x(Base,plant_1) + x(double_Base,plant_1) =E= 1 ;&#xA;e1(plant_2)..  x(Base,plant_2) + x(double_Base,plant_2) =E= 1 ;&#xA;&#xA;&#xA;---- e2 &#xA;&#xA;e2(customer_1)..  flow(plant_1,customer_1) + flow(plant_2,customer_1) =E= 50 ;     &#xA;e2(customer_2)..  flow(plant_1,customer_2) + flow(plant_2,customer_2) =E= 50 ; &#xA;e2(customer_3)..  flow(plant_1,customer_3) + flow(plant_2,customer_3) =E= 25 ;     &#xA;&#xA;&#xA;---- e3 &#xA;&#xA;e3(plant_1)..  flow(plant_1,customer_1) + flow(plant_1,customer_2)&#xA;     &#xA;      + flow(plant_1,customer_3) - 3*flow_internal(plant_1) =L= 0 ; &#xA;     &#xA;e3(plant_2)..  flow(plant_2,customer_1) + flow(plant_2,customer_2)&#xA;     &#xA;      + flow(plant_2,customer_3) - 3*flow_internal(plant_2) =L= 0 ; &#xA;     &#xA;&#xA;---- e4  =L=  &#xA;&#xA;e4(plant_1)..  50*x(Base,plant_1) + 100*x(double_Base,plant_1)&#xA;     &#xA;      - 2*flow_internal(plant_1) =L= 0 ; &#xA;     &#xA;e4(plant_2)..  50*x(Base,plant_2) + 100*x(double_Base,plant_2)&#xA;     &#xA;      - 2*flow_internal(plant_2) =L= 0 ;&#xA;&#xA;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-03-12T07:02:16.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10114" PostTypeId="1" CreationDate="2023-03-12T13:02:11.630" Score="2" ViewCount="98" Body="&lt;p&gt;I know the logical constraints can be linearized by either the logical representation of whose relation, (for pure binary variables e.g. CNF/DNF) or for general form by using Big-M formulation. As I have recently seen there are other methods like &lt;em&gt;&lt;strong&gt;convex-hull or cutting-plan transformation&lt;/strong&gt;&lt;/em&gt; to do that in which one can use those and often perform faster than Big-M formulation. I would like to know, is there any simple example of how these methods work and do they implement in the modern solvers?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-03-12T13:02:11.630" Title="The linearization of the logical constraints" Tags="|mixed-integer-programming|linearization|solver|logical-constraints|algorithms|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10115" PostTypeId="2" ParentId="10109" CreationDate="2023-03-12T16:22:13.400" Score="1" Body="&lt;p&gt;Changing 'binary' to 'Binary' in the lines_selection definition gave me this in the LP file&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\* Investment_Decisions *\&#xA;Minimize&#xA;OBJ: Flow_(1,_1) + 1.5 Flow_(1,_2) + 1.5 Flow_(1,_3) + Flow_(2,_1)&#xA; + Flow_(2,_2) + Flow_(2,_3) + 10 Line_Selection_(2,_1)&#xA; + 10 Line_Selection_(2,_2)&#xA;Subject To&#xA;Demand_Satisfied_1: Flow_(1,_1) + Flow_(2,_1) = 50&#xA;Demand_Satisfied_2: Flow_(1,_2) + Flow_(2,_2) = 50&#xA;Demand_Satisfied_3: Flow_(1,_3) + Flow_(2,_3) = 25&#xA;Equalizing_multi_echlon_flow_1: Flow_(1,_1) + Flow_(1,_2) + Flow_(1,_3)&#xA; - Flow_Internal_1 = 0&#xA;Equalizing_multi_echlon_flow_2: Flow_(2,_1) + Flow_(2,_2) + Flow_(2,_3)&#xA; - Flow_Internal_2 = 0&#xA;Multi_Echelon_Flow_vs_capacity1: - Flow_Internal_1 + 50 Line_Selection_(1,_1)&#xA; + 100 Line_Selection_(2,_1) = 0&#xA;Multi_Echelon_Flow_vs_capacity2: - Flow_Internal_2 + 50 Line_Selection_(1,_2)&#xA; + 100 Line_Selection_(2,_2) = 0&#xA;Only_one_option1: Line_Selection_(1,_1) + Line_Selection_(2,_1) = 1&#xA;Only_one_option2: Line_Selection_(1,_2) + Line_Selection_(2,_2) = 1&#xA;Bounds&#xA; 0 &amp;lt;= Flow_(1,_1)&#xA; 0 &amp;lt;= Flow_(1,_2)&#xA; 0 &amp;lt;= Flow_(1,_3)&#xA; 0 &amp;lt;= Flow_(2,_1)&#xA; 0 &amp;lt;= Flow_(2,_2)&#xA; 0 &amp;lt;= Flow_(2,_3)&#xA; 0 &amp;lt;= Flow_Internal_1&#xA; 0 &amp;lt;= Flow_Internal_2&#xA;Binaries&#xA;Line_Selection_(1,_1)&#xA;Line_Selection_(1,_2)&#xA;Line_Selection_(2,_1)&#xA;Line_Selection_(2,_2)&#xA;End&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-03-12T16:22:13.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10116" PostTypeId="1" CreationDate="2023-03-12T17:06:59.067" Score="0" ViewCount="94" Body="&lt;p&gt;I'm trying to recall a theorem that I was taught in grad school, but can't remember the name of the theorem. We were learning about different methods to solve unit committment and economic dispatch models for electric power grids. The TA showed us a theorem that proved that stochastic methods that incorporate the uncertainty inherent in variable renewable power generation will produce better results than purely deterministic models. Anyone have any idea what that theorem is called?&lt;/p&gt;&#xA;" OwnerUserId="11436" LastActivityDate="2024-04-06T09:02:35.327" Title="Theorem proving Stochastic Optimization for Unit Commitment always better than deterministic solution" Tags="|stochastic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10117" PostTypeId="2" ParentId="10116" CreationDate="2023-03-13T05:26:30.780" Score="0" Body="&lt;p&gt;*In the following, we assume minimization.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$VSS = EEV - SP \geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;holds, where SP is the objective of stochastic problem and the EEV is &amp;quot;expected value of the expected value solution&amp;quot;. The former is the value of objective function by solving the stochastic programming problem. The latter fixes the first-stage variables to that yield by &amp;quot;expected value problem （EV)&amp;quot;, i.e., stochastic parameters in the stochastic programming problem are replaced with their expected value. VSS - value of stochastic solution, represents the value of solving the stochastic problem rather than a deterministic counterpart.&lt;/p&gt;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;[1] Birge, J. R. (1982). The value of the stochastic solution in&#xA;stochastic linear programs with fixed recourse. Mathematical&#xA;Programming, 24(1), 314–325. &lt;a href=&quot;https://doi.org/10.1007/BF01585113&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1007/BF01585113&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[2] Madansky, A. (1960). Inequalities for stochastic linear&#xA;programming problems. Management Science, 6(2), 197–204.&#xA;&lt;a href=&quot;https://doi.org/10.1287/mnsc.6.2.197&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/mnsc.6.2.197&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2023-03-13T05:26:30.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10118" PostTypeId="1" AcceptedAnswerId="10119" CreationDate="2023-03-13T15:19:17.200" Score="1" ViewCount="185" Body="&lt;p&gt;I have a FJSSP that I would like to solve. However, the jobs in this problem have deadlines and in addition there are setup times between two jobs. Because of this, my objective function is not just the makespan but rather a more complex (nonlinear)combination between makespan and tardiness (with respect to given deadlines) of the execution of the jobs.&lt;/p&gt;&#xA;&lt;p&gt;I was thus wondering which solvers are available right now which offer flexibility to modify my objective functions. Or, in general, how are practitioners tackling these problems in industry currently?&lt;/p&gt;&#xA;" OwnerUserId="11164" LastEditorUserId="491" LastEditDate="2024-03-18T12:39:32.503" LastActivityDate="2024-03-18T12:39:32.503" Title="Solver for Flexible Job Shop Scheduling Problem" Tags="|mixed-integer-programming|linear-programming|integer-programming|scheduling|job-shop-scheduling|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10119" PostTypeId="2" ParentId="10118" CreationDate="2023-03-13T15:57:01.667" Score="1" Body="&lt;p&gt;There are constraint programming solvers that support global constraints specific to job scheduling (setup times, resource sharing etc.). CPOptimizer is the one with which I am most familiar, but I am certain there are others. So a CP model is one possibility. As far as I know, CP models for scheduling can handle nonlinear objective functions.&lt;/p&gt;&#xA;&lt;p&gt;A MIP model &lt;em&gt;might&lt;/em&gt; also be a possibility, depending on what your nonlinear combination of makespan and tardiness looks like.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-13T15:57:01.667" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10120" PostTypeId="1" CreationDate="2023-03-13T23:02:44.093" Score="1" ViewCount="85" Body="&lt;p&gt;I have a Binary Integer Program with two binary decision variables and additionally have an expected solution. At the time of execution of this program I expect the parameters to change slightly. I am using the expected solution to fix the values of the decision variables according to it and utilize the model to compute the rest of the decisions at time of execution. I was curious whether this approach benefits the program in some way assuming most of the variables are fixed from the expected solution. Is there an alternative approach that is better?&lt;/p&gt;&#xA;" OwnerUserId="10707" LastActivityDate="2023-03-14T09:54:05.283" Title="Fixing binary variables in an Binary Integer Program" Tags="|optimization|mixed-integer-programming|integer-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10121" PostTypeId="2" ParentId="10120" CreationDate="2023-03-14T00:38:18.083" Score="0" Body="&lt;p&gt;There are approaches like this, kind of heuristic you may say, where you can fix values of some variables like a warm start and allow the solver to start search from the given feasible candidate solution.&lt;br /&gt;&#xA;Other than that there's pre-solving and introduction of cuts/constraints like knapsack cover. Such techniques are followed for solving MILP models.&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.fico.com/fico-xpress-optimization/docs/latest/getting_started/dhtml/chap8_sec_c8s1.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;FICO&lt;/a&gt; has described one such heuristic where you start by solving LP relaxation, then fixing values of some of the binaries and then iteratively solvng the MILP using the best candidate solution as the bounds.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-03-14T00:38:18.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10122" PostTypeId="2" ParentId="10120" CreationDate="2023-03-14T09:54:05.283" Score="1" Body="&lt;p&gt;Actually, it effectively depends on the problem you have at hand. Modern solvers have often been armed with dozen of (SOTA) heuristics, cutting plane approaches, powerful pre-solving phases, etc. Also, to inject a heuristic solution usually, there are two ways. First, by something like a MIP-Start, and the second by using the heuristic callback if the solver supports that. In many cases, there might be a situation in which the founded heuristic solution would be rejected by the solver process. By Googling or searching the community you definitely could find many useful notes. (e.g. &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360077367271-Injecting-Heuristic-Solution-with-Callback-is-Very-Slow&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;As a simple example, you can check the behavior of the solver again with a founded heuristic solution. Suppose, there is a bin-packing problem only with two items and one bin. (this is a tiny example that can be illustrated). The feasible solution of the problem is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1bF4C.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1bF4C.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and the optimal solution, objective function, would be equal to one. (it is obviously!). Now, I am trying to inject a heuristic solution &lt;span class=&quot;math-container&quot;&gt;$\{1,1,0\}$&lt;/span&gt;. The solver's log shows that:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Processing 1 MIP starts.&#xA;MIP start 'm1' defined no solution.&#xA;Warning:  No solution found from 1 MIP starts.&#xA;Retaining values of one MIP start for possible repair.&#xA;Found incumbent of value 1.000000 after 0.00 sec.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and as the second try inject the solution &lt;span class=&quot;math-container&quot;&gt;$\{0,1,1\}$&lt;/span&gt;. Then the log file again shows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Processing 1 MIP starts.&#xA;MIP start 'm1' defined solution with objective 1.0000.&#xA;1 of 1 MIP starts provided solutions.&#xA;MIP start 'm1' defined initial solution with objective 1.0000.&#xA;MIP emphasis: optimality.&#xA;MIP search method: dynamic search.&#xA;Parallel mode: none, using 1 thread.&#xA;Root relaxation solution time = 0.00 sec.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Once a wise man said to check a heuristic solution that obtained from an external program/function, it would be worth fixing the problem variables at this solution and investigating if it can provide at least a feasible solution. I hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-03-14T09:54:05.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10124" PostTypeId="1" CreationDate="2023-03-14T18:08:51.180" Score="0" ViewCount="38" Body="&lt;p&gt;If I have a Lp problem should I make it to standard form and then calculate number of 0s in the proposed solution and compare it to :&lt;/p&gt;&#xA;&lt;p&gt;number of equation - number of variables;&lt;/p&gt;&#xA;&lt;p&gt;And that's for checking wether the solution is a basis(BFS) or not.&lt;/p&gt;&#xA;&lt;p&gt;What I know is if I have a proposed solution (expressing the original variables) I can directly check weather it is a bfs or not without the need to convert it to standard form.&lt;/p&gt;&#xA;&lt;p&gt;P.s: this step is just the 2nd step of checking&lt;/p&gt;&#xA;" OwnerUserId="11444" LastActivityDate="2023-03-14T18:08:51.180" Title="Is Converting to Standard Form Necessary to Check if a Proposed Solution is a Basis in Linear Programming?" Tags="|linear-programming|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10126" PostTypeId="1" AcceptedAnswerId="10127" CreationDate="2023-03-14T20:00:53.480" Score="1" ViewCount="84" Body="&lt;p&gt;In scheduling problems, one usually has different options as objective functions (makespan, tardiness, etc). However, for any such type of scheduling problem one can consider an online version of it on which new jobs are arriving to be processed at random times. This seems more natural in practice. I was thus wondering how are practitioners modeling this in industry and what strategies are they following to solve it.&lt;/p&gt;&#xA;&lt;p&gt;My first thought was to follow the workflow:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get data on jobs today and solve the associated (offline)problem to this data&lt;/li&gt;&#xA;&lt;li&gt;Start processing jobs according to the computed schedule&lt;/li&gt;&#xA;&lt;li&gt;While jobs are being processed, record the incoming jobs, but keep them hidden from the solver&lt;/li&gt;&#xA;&lt;li&gt;After a fixed short period of time (usually before the makespan of the precomputed schedule) show these additional jobs to the solver and ask it to solve a new problem with these jobs plus the jobs that are still not processed from the previous schedule at that point in time.&lt;/li&gt;&#xA;&lt;li&gt;Go to step 2.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;However, this procedure seems very naive because in theory old orders can be always pushed to the end and never be processed (for example, if we are minimizing the total number of delayed orders and you have a big order that will take a lot of time and delay many orders if processed). So, what objective should we aim to minimize in this case? Can you please provide a reference I could checkout on this topic?&lt;/p&gt;&#xA;" OwnerUserId="11164" LastActivityDate="2023-03-15T06:37:46.633" Title="How to tackle online scheduling problems?" Tags="|mixed-integer-programming|linear-programming|integer-programming|scheduling|job-shop-scheduling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10127" PostTypeId="2" ParentId="10126" CreationDate="2023-03-14T21:06:19.817" Score="1" Body="&lt;p&gt;Disclaimer: I'm not a practitioner, so I don't know if any of the relevant academic literature is actually, well, relevant. That said, I think you might want to look at work on &amp;quot;rolling horizon&amp;quot; scheduling. In particular, &lt;a href=&quot;https://or.stackexchange.com/questions/9362/rolling-horizon-approach-for-solving-a-job-scheduling-problem&quot;&gt;this question&lt;/a&gt; on OR SE and its answers are pertinent.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-14T21:06:19.817" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10128" PostTypeId="1" AcceptedAnswerId="10136" CreationDate="2023-03-15T01:00:09.407" Score="2" ViewCount="178" Body="&lt;p&gt;As title, recently I got a minimax problem, after formalizing, the model is like this.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{minimise } \max_{k \in K} \sum_{i \in I} b_{i,k} \cdot f_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;such that: &lt;span class=&quot;math-container&quot;&gt;$$ \forall i \in I,\, \sum_{k \in K} a_{i,k}b_{i,k} = 1.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here we know &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$a_{i,k}$&lt;/span&gt;. All of &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; is integer, &lt;span class=&quot;math-container&quot;&gt;$a_{i,k}, b_{i,k} \in \{0,1\}$&lt;/span&gt;, the decision variable is &lt;span class=&quot;math-container&quot;&gt;$b_{i,k}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Are there any useful method to resolve this problem? Actually, I have found the paper &lt;a href=&quot;https://people.csail.mit.edu/rrw/presentations/Lenstra81.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;INTEGER PROGRAMMING WITH A FIXED NUMBER OF VARIABLE&amp;quot;&lt;/a&gt;, &lt;a href=&quot;https://www.researchgate.net/publication/242932580_Implicit_Enumeration_for_the_Pure_Integer_01_Minimax_Programming_Problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Implicit Enumeration For The Pure Integer 0/1 Minimax Programming Problem&amp;quot;&lt;/a&gt;, while the problem definition is a little different from ours.&lt;/p&gt;&#xA;&lt;p&gt;The paper in &lt;a href=&quot;https://people.csail.mit.edu/rrw/presentations/Lenstra81.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt; said&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;If in the original problem each coordinate of χ is required to be in {0,1}, no transformation of the problem is needed to achieve the condition just stated. This suggests that in this case our algorithm is equivalent to complete enumeration. We remark that the {0,1} linear programming problem is NP-complete.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Does the author means that the algorithm he proposed can only solve 0/1 integer programming by complete enumeration?&lt;/p&gt;&#xA;&lt;p&gt;I have read &lt;a href=&quot;https://or.stackexchange.com/questions/143/why-are-integer-minimax-problems-hard&quot;&gt;Why are integer minimax problems hard?&lt;/a&gt;, but is there any directly related papers that can solve this problem within the tolerable time complexity? or Is there any related papers that can just remind me designing a not bad heuristic algorithm?&lt;/p&gt;&#xA;" OwnerUserId="11445" LastEditorUserId="6111" LastEditDate="2023-03-16T13:05:49.983" LastActivityDate="2023-03-16T20:34:30.467" Title="Is there any &quot;not bad&quot; algorithm that can solve the minimax problem in 0/1 integer programming?" Tags="|mixed-integer-programming|integer-programming|heuristics|minimax|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10129" PostTypeId="2" ParentId="10126" CreationDate="2023-03-15T06:37:46.633" Score="1" Body="&lt;p&gt;Take a look into &lt;strong&gt;Real-time planning&lt;/strong&gt; and &lt;strong&gt;Non-disruptive replanning&lt;/strong&gt;. See &lt;a href=&quot;https://youtu.be/Ew6pq9nJKog&quot; rel=&quot;nofollow noreferrer&quot;&gt;my video&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2023-03-15T06:37:46.633" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10131" PostTypeId="2" ParentId="3396" CreationDate="2023-03-15T13:39:31.417" Score="2" Body="&lt;p&gt;In addition to the above answer, the following might be worthwhile too.&lt;/p&gt;&#xA;&lt;p&gt;Often, an algorithm for one scheduling problem can be applied to another scheduling problem as well. For example, &lt;span class=&quot;math-container&quot;&gt;$ 1|| \sum c_{j} $&lt;/span&gt; is a special case of &lt;span class=&quot;math-container&quot;&gt;$ 1|| \sum w_{j}c_{j} $&lt;/span&gt; and a procedure for this can also be used for the first one. In complexity terms, it is said that &lt;span class=&quot;math-container&quot;&gt;$ 1|| \sum c_{j} $&lt;/span&gt; reduces to &lt;span class=&quot;math-container&quot;&gt;$ 1|| \sum w_{j}c_{j} $&lt;/span&gt;. Based on this concept a chain of reductions can be established. For example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ (1|| \sum c_{j}) \rightarrow (1|| \sum w_{j}c_{j}) \rightarrow (P_{m} || \sum w_{j}c_{j}) \rightarrow (Q_{m} |prec| \sum w_{j}c_{j}))$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As an example of hard and easy problem, &lt;span class=&quot;math-container&quot;&gt;$ 1 || C_{max} $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ P_{2} || C_{max} $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ F_{2} || C_{max} $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ J_{m} || C_{max} $&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$ FF_{c} || C_{max} $&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tVThw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tVThw.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Of course, there are also many problems that are not comparable with one&#xA;another. For example, &lt;span class=&quot;math-container&quot;&gt;$ P_{m} || \sum w_{j}T_{j}$&lt;/span&gt; is not comparable to &lt;span class=&quot;math-container&quot;&gt;$ J_{m}|| C_{max} $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A considerable effort has been made to establish a problem hierarchy describing&#xA;the relationships between the hundreds of scheduling problems. In the&#xA;comparisons between the complexities of the different scheduling problems, it&#xA;is of interest to know how a change in a single element in the classification of&#xA;a problem affects its complexity. The following graph helps determine the complexity hierarchy of deterministic scheduling problems based on the different objective functions.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/crlqn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/crlqn.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-03-15T13:39:31.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10132" PostTypeId="1" CreationDate="2023-03-15T15:20:17.470" Score="1" ViewCount="83" Body="&lt;p&gt;I have cars and persons and I want each persons to be in a car.&#xA;Moreover, each person has a number of persons they can share a car with.&lt;/p&gt;&#xA;&lt;p&gt;I have implemented a model (with binary variables and constant objective) which works well for small instances. However for larger ones the solver takes ages and I have to interupt it.&lt;/p&gt;&#xA;&lt;p&gt;What would be a good approach to takle this issue (I'm thinking branch-and-bound, metaheuristics, etc. But I don't really have a clear idea).&lt;/p&gt;&#xA;" OwnerUserId="8723" LastEditorUserId="8723" LastEditDate="2023-03-17T14:21:47.410" LastActivityDate="2023-03-17T14:21:47.410" Title="Solver is not convering" Tags="|linear-programming|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10133" PostTypeId="2" ParentId="10132" CreationDate="2023-03-15T18:50:21.313" Score="2" Body="&lt;p&gt;The following solves quickly with at least one commercial solver.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; indicate whether person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; rides in car &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.  The constraints are:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j x_{ij} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \tag1\label1 \\&#xA;\sum_{k\not= i} x_{kj} + (m - 1 - M_i) x_{ij} &amp;amp;\le m - 1 &amp;amp;&amp;amp;\text{for all $i$ and $j$} \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} assigns each person to exactly one car.&#xA;Constraint \eqref{2} enforces the logical implication &lt;span class=&quot;math-container&quot;&gt;$$x_{ij} = 1 \implies \sum_{k\not= i} x_{kj} \le M_i,$$&lt;/span&gt;&#xA;which you could instead enforce via an indicator constraint.&lt;/p&gt;&#xA;&lt;p&gt;An interesting variant would be to minimize the number of cars used.  In that case, introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; to indicate whether car &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is used,  change the RHS of \eqref{2} to &lt;span class=&quot;math-container&quot;&gt;$(m-1)y_j$&lt;/span&gt;, and minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_j y_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This formulation lends itself to column generation with a set partitioning master problem, and Ryan-Foster branching can perform well.  That approach is automated in SAS if you specify to use the Dantzig-Wolfe decomposition algorithm with METHOD=SET or explicitly identify the block structure via the .BLOCK constraint suffix.  If you are using a different solver, you can try implementing column generation yourself.  The corresponding formulation has a binary decision variable &lt;span class=&quot;math-container&quot;&gt;$z_S$&lt;/span&gt; for each feasible subset &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of (at most &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;) people.  The constraints are then:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{S: i \in S} z_S &amp;amp;= 1 &amp;amp;&amp;amp; \text{for all $i$} \tag3\label3 \\&#xA;\sum_{S} z_S &amp;amp;\le n \tag4\label4&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{3} assigns each person to exactly one car.&#xA;Constraint \eqref{4} enforces using at most &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; cars.&#xA;For static column generation, you would generate all feasible &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; a priori and solve one MILP.  For dynamic column generation, you would need to iterate between a master LP problem and a MILP subproblem.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-15T19:56:55.703" LastActivityDate="2023-03-15T19:56:55.703" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10134" PostTypeId="2" ParentId="10132" CreationDate="2023-03-15T19:46:13.843" Score="1" Body="&lt;p&gt;You can try the following algorithm:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Sort passengers in descending order of number of co-passengers, &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt;.Output sets &lt;span class=&quot;math-container&quot;&gt;$S_4 = \{i\in P: M_i \gt 3\}$&lt;/span&gt;. Similarly sets &lt;span class=&quot;math-container&quot;&gt;$ S_3, S_2, S_1, S_0$&lt;/span&gt;. P is set of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; passengers\&lt;/li&gt;&#xA;&lt;li&gt;Loop through each of the sets in the cardinal number &lt;span class=&quot;math-container&quot;&gt;$ 4,3,2,1$&lt;/span&gt; like&lt;br /&gt;&#xA;initialize &lt;span class=&quot;math-container&quot;&gt;$ C_1 = 0$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ C_{n} = C_{n} + i: i \in S_{k+1|k\lt 4} \land m_i \lt C_{j} $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$C_{n} = k \quad \forall n \le {\vert S_k\vert\over k}$&lt;/span&gt;&lt;br /&gt;&#xA;You can allocate/track individual allocation as well&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ C_{n}= \{i: i \in S_k\}: C_n \lt k \quad \forall n \le {\vert S_k\vert\over k}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ C_{n+1} = {\vert S_{k} \vert \mod k} $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\forall n \in$&lt;/span&gt; cars:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \forall k \in \{4,3,2,1,0\}$&lt;/span&gt; (Nested loop, &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the inner loop)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ C_j =$&lt;/span&gt; number of passengers in car &lt;span class=&quot;math-container&quot;&gt;$ j$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-15T21:29:34.890" LastActivityDate="2023-03-15T21:29:34.890" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10135" PostTypeId="2" ParentId="10128" CreationDate="2023-03-16T00:33:56.007" Score="0" Body="&lt;p&gt;If I understand your question, something like this should work:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import random&#xA;from ortools.sat.python import cp_model&#xA;&#xA;model = cp_model.CpModel()&#xA;#Generate a random instance&#xA;f = [random.randrange(-256, 257) for _ in range(100)]&#xA;a = [[random.randrange(2) for _ in range(100)] for _ in range(100)]&#xA;b = [[model.NewIntVar(0, 1, f'b_{(i, k)}') for k in range(100)] for i in range(100)]&#xA;for a_i, b_i in zip(a, b):&#xA;    model.Add(sum(a_ik * b_ik for a_ik, b_ik in zip(a_i, b_i)) == 1)&#xA;bound_max = sum(f_i for f_i in f if f_i &amp;gt; 0)&#xA;bound_min = sum(f_i for f_i in f if f_i &amp;lt; 0)&#xA;bound = model.NewIntVar(bound_min, bound_max, 'bound')&#xA;for bt_k in zip(*b):&#xA;    model.Add(bound &amp;gt;= sum(b_ik * f_i for b_ik, f_i in zip(bt_k, f)))&#xA;model.Minimize(bound)&#xA;solver = cp_model.CpSolver()&#xA;solver.parameters.log_search_progress = True&#xA;solver.Solve(model)&#xA;for b_i in b:&#xA;    print(''.join(str(solver.Value(b_ik)) for b_ik in b_i))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7666" LastActivityDate="2023-03-16T00:33:56.007" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10136" PostTypeId="2" ParentId="10128" CreationDate="2023-03-16T01:14:03.140" Score="3" Body="&lt;p&gt;A greedy construction heuristic might not perform horribly here.  For each &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt;, select the &lt;span class=&quot;math-container&quot;&gt;$b_{ik}$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$a_{ik}=1$&lt;/span&gt;) that increases the minimax value the least.  You could process &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; in different random orders and take the best.  Given a feasible solution, you could also perform a local search improvement heuristic with two moves:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Move &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; from current group &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt; to new group &lt;span class=&quot;math-container&quot;&gt;$\ell\in K$&lt;/span&gt; if doing so improves the minimax value.&lt;/li&gt;&#xA;&lt;li&gt;Swap a current pair &lt;span class=&quot;math-container&quot;&gt;$(i,k_i)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(j,k_j)$&lt;/span&gt; to yield new pair &lt;span class=&quot;math-container&quot;&gt;$(i,k_j)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(j,k_i)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-16T15:58:59.497" LastActivityDate="2023-03-16T15:58:59.497" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10137" PostTypeId="1" CreationDate="2023-03-16T03:25:26.943" Score="1" ViewCount="60" Body="&lt;p&gt;I would like to know if there is a way to migrate the model from A to another solver.&#xA;For example, lets say i have done built my model in gurobipy and would like to migrates into pyomo. Is there a way?&lt;/p&gt;&#xA;" OwnerUserId="10000" LastActivityDate="2023-03-16T03:25:26.943" Title="Migrates between solvers" Tags="|pyomo|gurobipy|mps|lp|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10138" PostTypeId="1" CreationDate="2023-03-16T08:49:01.537" Score="1" ViewCount="93" Body="&lt;p&gt;&lt;strong&gt;Context:&lt;/strong&gt; I am working on a small electricity market model in Pyomo. It optimizes the capacity of different technologies and generation in at least 43800 hours. One of the technologies is a battery. Among several constraints for this technology, one specifies the state of charge across hours. Here's what it looks like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def socstatetrans(model,s,h):&#xA;  if model.Hour[h] == 1: &#xA;    return model.soc0 + sqrt(model.beff)*model.ch[s,h] - model.disch[s,h]/sqrt(model.beff) == model.soc[s,h]&#xA;  else: &#xA;    return model.soc[s,h-1] + sqrt(model.beff)*model.ch[s,h] - model.disch[s,h]/sqrt(model.beff) == model.soc[s,h]&#xA;&#xA;model.sochourly = Constraint(model.Stor, model.Hour, rule = socstatetrans)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Adding the constraint to the model takes about three minutes in Google Colab. As I have to run the model many times, this is too long. I suspect that my code is somehow inefficient and would appreciate any tips on how to rewrite the constraint to speed this up.&lt;/p&gt;&#xA;" OwnerUserId="11452" LastActivityDate="2023-03-16T08:49:01.537" Title="How to speed up state of charge constraint in Pyomo model" Tags="|linear-programming|constraint|pyomo|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10141" PostTypeId="2" ParentId="10128" CreationDate="2023-03-16T15:30:54.433" Score="1" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; be the index sets and for &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; let &lt;span class=&quot;math-container&quot;&gt;$K_i = \lbrace k\in K : a_{i,k}=1\rbrace.$&lt;/span&gt; Hopefully &lt;span class=&quot;math-container&quot;&gt;$K_i \neq \emptyset\, \forall i\in I,$&lt;/span&gt; else the problem is infeasible.&lt;/p&gt;&#xA;&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; is binary, the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th constraint reduces to &lt;span class=&quot;math-container&quot;&gt;$\sum_{k\in K_i} b_{i,k} = 1.$&lt;/span&gt; So we have to set exactly one &lt;span class=&quot;math-container&quot;&gt;$b_{i,k}$&lt;/span&gt; equal to 1. Let &lt;span class=&quot;math-container&quot;&gt;$k_i \in K_i$&lt;/span&gt; be the index of the selected variable.&lt;/p&gt;&#xA;&lt;p&gt;A primitive random heuristic would be to randomly select &lt;span class=&quot;math-container&quot;&gt;$k_i \in K_i$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i,$&lt;/span&gt; evaluate the objective function, record the solution as a new incumbent if it improves on any previous solutions, and then repeat.&lt;/p&gt;&#xA;&lt;p&gt;A more sophisticated approach would be to use a random key genetic algorithm. Let &lt;span class=&quot;math-container&quot;&gt;$\hat{b}$&lt;/span&gt; be a vector containing every &lt;span class=&quot;math-container&quot;&gt;$b_{i,k}$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$k\in K_i.$&lt;/span&gt; The chromosome for the GA would be a permutation of the indices &lt;span class=&quot;math-container&quot;&gt;$1,\dots,N$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is the dimension of &lt;span class=&quot;math-container&quot;&gt;$\hat{b}.$&lt;/span&gt; The fitness function would decode a permutation by using it to permute &lt;span class=&quot;math-container&quot;&gt;$\hat{b},$&lt;/span&gt; selecting for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; the first variable &lt;span class=&quot;math-container&quot;&gt;$b_{i,k}$&lt;/span&gt; in the permuted vector, and evaluating the objective function.&lt;/p&gt;&#xA;&lt;p&gt;Addendum: I tested the GA in R on some 20x30 test cases, and the solution (which came in seconds) consistently matched what a MIP model (which also solved in seconds) produced. Of course, that's no guarantee that the GA reaches optimality every time.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-03-16T20:34:30.467" LastActivityDate="2023-03-16T20:34:30.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10142" PostTypeId="1" CreationDate="2023-03-16T16:59:08.033" Score="0" ViewCount="80" Body="&lt;p&gt;how to make 2d array of strings in Cplex&lt;/p&gt;&#xA;&lt;p&gt;//indics&lt;/p&gt;&#xA;&lt;p&gt;{string} cluster=...;&lt;/p&gt;&#xA;&lt;p&gt;setof(string) darkstore =...;&lt;/p&gt;&#xA;&lt;p&gt;setof(string)demandpoint =...;&lt;/p&gt;&#xA;&lt;p&gt;//data&lt;/p&gt;&#xA;&lt;p&gt;cluster={chav,sree};&lt;/p&gt;&#xA;&lt;p&gt;demandpoint=[{tsnami,adholokam,neelambari,ashrayam},{tg,pd,cp,dt}];&lt;/p&gt;&#xA;&lt;p&gt;darkstore=[{dilucia,quickstart,babystores,yonnesbakery},{a,b,c,d}];&lt;/p&gt;&#xA;" OwnerUserId="11357" LastEditorUserId="11357" LastEditDate="2023-03-16T17:00:02.907" LastActivityDate="2023-03-16T18:39:42.423" Title="Array of string in OPL" Tags="|optimization|linear-programming|modeling|cplex|opl|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10143" PostTypeId="2" ParentId="10142" CreationDate="2023-03-16T18:39:42.423" Score="1" Body="&lt;p&gt;.mod&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{string} cluster=...;&#xA;&#xA;string darkstore [cluster][1..4]=...;&#xA;&#xA;string demandpoint  [cluster][1..4]=...;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;.dat&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cluster={chav,sree};&#xA;&#xA;demandpoint=[[tsnami,adholokam,neelambari,ashrayam],[tg,pd,cp,dt]];&#xA;&#xA;darkstore=[[dilucia,quickstart,babystores,yonnesbakery],[a,b,c,d]];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;work fine&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2023-03-16T18:39:42.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10147" PostTypeId="1" CreationDate="2023-03-17T07:40:55.273" Score="2" ViewCount="357" Body="&lt;p&gt;In simplex algorithm, in order to handle inequation constraints, we need to convert them into equations by introducing so-called 'slack variables', like&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathbf{a}^T\mathbf{x} + b \leq 0\quad\rightarrow\quad \mathbf{a}^T\mathbf{x} + b + s = 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, if some constraints could be violated, we can introduce 'slack variables' to make them 'soft constraints', like&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathbf{a}^T\mathbf{x} + b \leq 0\quad\rightarrow\quad \mathbf{a}^T\mathbf{x} + b - s \leq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;These two scenarios are different. In the simplex scenario, it is the equation constraint that is slacked to be an inequation, and in the second scenario, it is the inequation that is slacked. But in both scenarios, we say &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is the slack variable of constraint &lt;span class=&quot;math-container&quot;&gt;$\mathbf{a}^T\mathbf{x} + b \leq 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It seems a little bit strange to me , so I wonder if I am wrong somewhere.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastEditorUserId="4569" LastEditDate="2023-03-17T07:46:00.317" LastActivityDate="2023-03-17T14:57:26.863" Title="Are there two types of 'slack variables'?" Tags="|simplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10148" PostTypeId="1" AcceptedAnswerId="10186" CreationDate="2023-03-17T10:10:12.683" Score="0" ViewCount="70" Body="&lt;p&gt;Thanks to &lt;a href=&quot;https://or.stackexchange.com/questions/9137&quot;&gt;a previous question&lt;/a&gt;, I know about &lt;a href=&quot;https://cscmp.org/CSCMP/Educate/SCM_Definitions_and_Glossary_of_Terms.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;this PDF file, containing a lot of terms concerning supply chain management&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This list is quite elaborated, but I'm now more specifically looking for different terms of racks. The list contains &amp;quot;Flow rack&amp;quot;, &amp;quot;Cantilever rack&amp;quot; and the extremely general term &amp;quot;Pallet rack&amp;quot;, but I'm interested in different types of racks, e.g. based on the amount of entries and exits for entering and getting items to and from the rack, or even more terms.&lt;/p&gt;&#xA;&lt;p&gt;Is there a list of supply chain terms around storage locations, like racks?&lt;/p&gt;&#xA;" OwnerUserId="10563" LastActivityDate="2023-03-26T18:04:23.177" Title="What is the official terminology concerning different types of racks?" Tags="|terminology|supply-chain|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10149" PostTypeId="1" AcceptedAnswerId="10151" CreationDate="2023-03-17T12:11:07.787" Score="1" ViewCount="187" Body="&lt;p&gt;Consider a variable c from the domain {-1,0,1}. I have the following constraint:&lt;br /&gt;&#xA;IF &lt;span class=&quot;math-container&quot;&gt;$c = 1 \Rightarrow x = 1 $&lt;/span&gt; ELSE &lt;span class=&quot;math-container&quot;&gt;$x = 0$&lt;/span&gt;&#xA;How do I linearize this constraint?&lt;/p&gt;&#xA;" OwnerUserId="11401" LastEditorUserId="500" LastEditDate="2023-03-17T13:00:00.837" LastActivityDate="2023-03-17T13:12:10.867" Title="Linearize conditional constraint" Tags="|mixed-integer-programming|linear-programming|constraint|linearization|constraint-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10150" PostTypeId="1" CreationDate="2023-03-17T12:20:43.353" Score="2" ViewCount="75" Body="&lt;p&gt;I was trying to find a literature review on Dantzig-Wolfe decomposition but was unable to do so. I found one on Benders, and another on Column-generation.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: If there is none, is there a paper that tends to be used as a representative of the algorithm? The more recent, the better, I would like to avoid using the original 1960 paper.&lt;/p&gt;&#xA;" OwnerUserId="5352" LastActivityDate="2023-03-17T14:54:16.543" Title="Dantzig-Wolfe decomposition survey/literature review" Tags="|reference-request|literature-research|dantzig-wolfe-decomposition|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10151" PostTypeId="2" ParentId="10149" CreationDate="2023-03-17T13:12:10.867" Score="6" Body="&lt;p&gt;It might help to consider the contrapositives:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x=0 &amp;amp;\implies c\le 0 \\&#xA;x=1 &amp;amp;\implies c\ge 1&#xA;\end{align}&lt;/span&gt;&#xA;Both of these are indicator constraints, which you can linearize via big-M:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;c &amp;amp;\le 1x \\&#xA;-c+1 &amp;amp;\le 2(1-x)&#xA;\end{align}&lt;/span&gt;&#xA;Simplifying yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$2x-1 \le c \le x,$$&lt;/span&gt;&#xA;which you could have also derived via&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-1(1-x)+1x \le c \le 0(1-x)+1x.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-03-17T13:12:10.867" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10153" PostTypeId="2" ParentId="10147" CreationDate="2023-03-17T14:57:26.863" Score="4" Body="&lt;p&gt;You are correct that there are two different scenarios where slack variables are introduced in linear programming: one for converting inequality constraints to equality constraints, and another for introducing soft constraints.&lt;/p&gt;&#xA;&lt;p&gt;In the first scenario, where inequality constraints are converted to equality constraints, slack variables are introduced to represent the amount by which the left-hand side of the constraint falls short of the right-hand side. In this case, the slack variable represents the &amp;quot;slack&amp;quot; or surplus in the constraint, and we add it to the left-hand side of the constraint to convert it to an equality.&lt;/p&gt;&#xA;&lt;p&gt;In the second scenario, where we introduce soft constraints, slack variables are also introduced, but in this case they represent the amount by which the left-hand side of the constraint can be violated. In other words, the slack variable represents the &amp;quot;slack&amp;quot; or flexibility in the constraint, and we subtract it from the left-hand side of the constraint to allow for some degree of violation.&lt;/p&gt;&#xA;&lt;p&gt;Despite the different interpretations of the slack variable in each scenario, it is still called a slack variable in both cases because it represents some degree of slack or flexibility in the constraint.&lt;/p&gt;&#xA;" OwnerUserId="10056" LastActivityDate="2023-03-17T14:57:26.863" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10154" PostTypeId="2" ParentId="10092" CreationDate="2023-03-17T15:01:57.900" Score="2" Body="&lt;p&gt;To model the constraint that limits the number of working shifts before a rest shift, you can introduce an additional binary variable to represent whether a person is on rest or not, and then use this variable to enforce the constraint.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; be a binary variable that is equal to 1 if person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is on rest and 0 otherwise. Then, for each person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and each shift &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, we can introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$w_{ij}$&lt;/span&gt; that is equal to 1 if person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is working on shift &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and 0 otherwise.&lt;/p&gt;&#xA;&lt;p&gt;To enforce the constraint that limits the number of working shifts before a rest shift, we can use a set of constraints that ensure that if person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is working on shift &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, then they must also have worked on at most 3 other shifts in the previous 4 shifts. This can be modeled as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{k=j-3}^{j-1} w_{ik} + w_{ij} \leq 4 - 4 y_i \quad \forall i,j&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This constraint ensures that if person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is on rest (i.e., &lt;span class=&quot;math-container&quot;&gt;$y_i = 1$&lt;/span&gt;), then they can work on up to 4 consecutive shifts before their rest shift. If person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is not on rest (i.e., &lt;span class=&quot;math-container&quot;&gt;$y_i = 0$&lt;/span&gt;), then they must have worked on at most 3 other shifts in the past 4 shifts before working on shift &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, in order to satisfy the constraint.&lt;/p&gt;&#xA;&lt;p&gt;Note that this constraint assumes that there are no gaps between shifts. If there are gaps between shifts, then you may need to modify the constraint to take this into account. Additionally, you may need to modify the constraint to handle cases where the rest shift occurs at the beginning or end of the scheduling period.&lt;/p&gt;&#xA;" OwnerUserId="10056" LastActivityDate="2023-03-17T15:01:57.900" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10155" PostTypeId="2" ParentId="4603" CreationDate="2023-03-17T15:10:16.627" Score="1" Body="&lt;p&gt;When Boyd refers to &amp;quot;regularizing the subproblems,&amp;quot; he is likely referring to techniques that improve the numerical stability and convergence properties of the subproblem solvers in the context of dual decomposition. Dual decomposition involves solving a series of subproblems, each of which involves optimizing a subset of the variables in the original problem while holding the others fixed. These subproblems can sometimes be ill-conditioned, which can lead to numerical instability and slow convergence.&lt;/p&gt;&#xA;&lt;p&gt;One common technique for regularizing subproblems is to add a regularization term to the objective function that penalizes large values of the variables. This can help to improve the conditioning of the problem and prevent numerical issues such as overflow or underflow. The choice of regularization term depends on the specific problem and the structure of the subproblem.&lt;/p&gt;&#xA;&lt;p&gt;Another technique is to use preconditioning to improve the conditioning of the subproblem. Preconditioning involves transforming the subproblem into an equivalent form that has better conditioning properties, such as by scaling the variables or adding a diagonal matrix to the constraints. Again, the choice of preconditioning technique depends on the specific problem and the structure of the subproblem.&lt;/p&gt;&#xA;&lt;p&gt;Finally, it is also possible to choose the decomposition variables in such a way as to improve the conditioning of the subproblems. For example, if the original problem has a block diagonal structure, it may be beneficial to choose the decomposition variables to correspond to the blocks in the matrix.&lt;/p&gt;&#xA;&lt;p&gt;Overall, the choice of regularization technique depends on the specific problem and the structure of the subproblem. It is often a matter of trial and error to find the technique that works best for a given problem.&lt;/p&gt;&#xA;" OwnerUserId="10056" LastActivityDate="2023-03-17T15:10:16.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10156" PostTypeId="2" ParentId="3133" CreationDate="2023-03-17T15:12:42.720" Score="2" Body="&lt;p&gt;You are correct that the optimal choice of parameters for the Armijo line search can vary depending on the problem and the optimization algorithm being used. In practice, there are several common strategies for choosing these parameters:&lt;/p&gt;&#xA;&lt;p&gt;Fixed values: One approach is to use fixed values for the parameters &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt;. For example, &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; could be set to a small value such as 0.01, &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; could be set to 0.5 or 0.9, and &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; could be set to 0.1 or 0.5. These values are often used as a starting point and can be adjusted manually based on the performance of the algorithm on the specific problem.&lt;/p&gt;&#xA;&lt;p&gt;Backtracking line search: Another approach is to use a backtracking line search to automatically adjust the parameters at each iteration. In this approach, the initial value of &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is set to a large value, and then decreased until the Armijo condition is satisfied. The parameter &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; is typically set to a small value such as 0.1 or 0.01, and the parameter &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; is usually set to a small value such as 0.1 or 0.01. Backtracking line search can be computationally expensive, but it can lead to better convergence properties and can adapt to the specific problem.&lt;/p&gt;&#xA;&lt;p&gt;Adaptive strategies: A third approach is to use adaptive strategies to adjust the parameters dynamically during the optimization process. For example, the parameters could be adjusted based on the progress of the optimization, the magnitude of the gradient, or some other criterion. Adaptive strategies can be more complex to implement, but they can lead to better convergence properties and can adapt to the specific problem.&lt;/p&gt;&#xA;&lt;p&gt;Overall, the choice of parameter selection strategy depends on the specific problem and the optimization algorithm being used. Fixed values can be a good starting point, but may need to be adjusted manually. Backtracking line search can be more computationally expensive, but can lead to better convergence properties. Adaptive strategies can be more complex to implement, but can adapt to the specific problem and lead to better convergence properties.&lt;/p&gt;&#xA;" OwnerUserId="10056" LastActivityDate="2023-03-17T15:12:42.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10157" PostTypeId="2" ParentId="2961" CreationDate="2023-03-17T15:15:43.603" Score="3" Body="&lt;p&gt;You can check the following weblink:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.minlp.com/nlp-and-minlp-test-problems&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.minlp.com/nlp-and-minlp-test-problems&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10056" LastActivityDate="2023-03-17T15:15:43.603" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10158" PostTypeId="2" ParentId="3176" CreationDate="2023-03-17T15:18:03.047" Score="3" Body="&lt;p&gt;There has been some research on algorithmically detecting SOS structure in optimization models. One approach is to use a graph-based algorithm to identify the structure of the model and detect the presence of SOS constraints.&lt;/p&gt;&#xA;&lt;p&gt;The basic idea is to construct a graph representation of the optimization model, where the nodes represent the variables and the edges represent the constraints. Then, the graph is partitioned into strongly connected components, which represent groups of variables that are related to each other through the constraints. If a strongly connected component has a specific structure, such as a quadratic form, then it can be identified as an SOS constraint.&lt;/p&gt;&#xA;" OwnerUserId="10056" LastEditorUserId="10056" LastEditDate="2023-03-17T15:47:57.383" LastActivityDate="2023-03-17T15:47:57.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10159" PostTypeId="2" ParentId="10036" CreationDate="2023-03-17T15:32:51.417" Score="2" Body="&lt;p&gt;The issue of obtaining complex values when evaluating the barrier function in an interior point method can be caused by taking the natural logarithm of a negative number. This can happen when the values of the inequality constraints &lt;span class=&quot;math-container&quot;&gt;$h_i(x)$&lt;/span&gt; are very small, as you have observed. In this case, the logarithm of &lt;span class=&quot;math-container&quot;&gt;$h_i(x)$&lt;/span&gt; may be negative, resulting in a complex value when multiplied by &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;One way to address this issue is to add a small positive constant to the values of &lt;span class=&quot;math-container&quot;&gt;$h_i(x)$&lt;/span&gt; before taking the natural logarithm. This is known as a &amp;quot;logarithmic barrier with a small constant&amp;quot; and is a common technique used in interior point methods to avoid taking the logarithm of a negative number.&lt;/p&gt;&#xA;&lt;p&gt;For example, you can modify the barrier function as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$B(x) = f(x) - t \sum_{i=1}^m \ln(h_i(x) + \epsilon)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is a small positive constant, such as &lt;span class=&quot;math-container&quot;&gt;$10^{-8}$&lt;/span&gt;. By adding this constant, you ensure that the logarithm is always taken of a positive number, avoiding the issue of obtaining complex values.&lt;/p&gt;&#xA;&lt;p&gt;However, keep in mind that adding a small constant can also affect the convergence properties of the interior point method. It can make the barrier function less steep, which can slow down the convergence of the method. Therefore, it is important to choose a value of &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; that is small enough to avoid the issue of complex values, but not so large that it significantly affects the convergence of the method.&lt;/p&gt;&#xA;&lt;p&gt;Another approach is to use a truncated logarithmic barrier, which involves setting a lower bound on the value of &lt;span class=&quot;math-container&quot;&gt;$h_i(x)$&lt;/span&gt; before taking the logarithm. This can also avoid the issue of obtaining complex values, but may require more careful tuning of the parameter values.&lt;/p&gt;&#xA;&lt;p&gt;Overall, adding a small positive constant to the values of &lt;span class=&quot;math-container&quot;&gt;$h_i(x)$&lt;/span&gt; before taking the logarithm is a common technique used to avoid the issue of complex values in the barrier function. However, it is important to choose an appropriate value of the constant to balance convergence and numerical stability.&lt;/p&gt;&#xA;" OwnerUserId="10056" LastActivityDate="2023-03-17T15:32:51.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10160" PostTypeId="1" CreationDate="2023-03-17T18:21:29.217" Score="1" ViewCount="127" Body="&lt;p&gt;When devising heuristics for the TSP I often see edge exchange algorithms suggested. But I also find them a bit hard to understand and somewhat cumbersome to implement.&lt;/p&gt;&#xA;&lt;p&gt;When I think about a TSP, I imagine a permutation of the nodes of the problem, and hence I always default to swapping nodes in the permutation.&lt;/p&gt;&#xA;&lt;p&gt;Is there any literature on the relative performance of edge exchange heuristics and node swap heuristics?&lt;/p&gt;&#xA;&lt;p&gt;Also, is a node swap heuristic a special case of an edge exchange?&lt;/p&gt;&#xA;" OwnerUserId="609" LastActivityDate="2023-03-17T18:21:29.217" Title="Node swap and edge swap for TSP" Tags="|traveling-salesman|heuristics|local-search|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10161" PostTypeId="1" AcceptedAnswerId="10162" CreationDate="2023-03-19T18:05:36.497" Score="1" ViewCount="68" Body="&lt;p&gt;Suppose we have a transportation problem similar to pickup and delivery problems. So, we have a set of drivers and a set of passengers. each passenger has predefined origins and destinations.  I'd like to know if we could compute the distance between a passenger's destinations and the drop-off nodes without having access to the solver's output.&lt;/p&gt;&#xA;&lt;p&gt;Every riders could be picked-up and drooped-off by multiple drivers. And there's no particular order on nodes of the graph which is denoted by &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We have a binary variables of &lt;span class=&quot;math-container&quot;&gt;$ x_{i,j}^{d,r}$&lt;/span&gt; if driver &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; drives &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; on edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;&#xA;and we already know for each &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; their start's &lt;span class=&quot;math-container&quot;&gt;$s_r$&lt;/span&gt; and their destination's &lt;span class=&quot;math-container&quot;&gt;$d_r$&lt;/span&gt; points (&lt;span class=&quot;math-container&quot;&gt;$s_r \in N$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_r in N$&lt;/span&gt;). I'm wondering without knowing the path and values of variables from the solver how to minimize the objective as a distance between the last drop-off point and the destinations of each rider. Is this possible to compute this value implicitly and have it as an objective function or do we simply need more information?&lt;/p&gt;&#xA;" OwnerUserId="11474" LastEditorUserId="11474" LastEditDate="2023-03-19T22:07:35.613" LastActivityDate="2023-03-19T22:07:35.613" Title="how to minimize the distance to the final points with incomplete information?" Tags="|mixed-integer-programming|modeling|integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10162" PostTypeId="2" ParentId="10161" CreationDate="2023-03-19T18:49:29.750" Score="0" Body="&lt;p&gt;Define binary &lt;span class=&quot;math-container&quot;&gt;$e_{i}^r,s_{i}^r$&lt;/span&gt; as drop-off &amp;amp; pickup nodes for rider &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;. &lt;br /&gt;&#xA;Then assuming a rider &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; is picked/dropped by same driver&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_d(\sum_j x_{j,i}^{d,r} -\sum_jx_{i,j}^{d,r}) = e_{i}^r - s_{i}^r$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ s_{i}^r+ e_{i}^r \le 1  \quad \forall i \ \forall r$&lt;/span&gt;: A node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; can either be origin/destination.&lt;/p&gt;&#xA;&lt;p&gt;If you don't want to use &lt;span class=&quot;math-container&quot;&gt;$ s_i$&lt;/span&gt; then (as used in another &lt;a href=&quot;https://or.stackexchange.com/questions/10149/linearize-conditional-constraint&quot;&gt;response&lt;/a&gt; by Dr. Rob)&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ 2e_{i}^r - 1 \le \sum_d(\sum_j x_{j,i}^{d,r} -\sum_jx_{i,j}^{d,r}) \le e_{i}^r$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then distance is:&lt;br /&gt;&#xA;if &lt;span class=&quot;math-container&quot;&gt;$ d_r$&lt;/span&gt; may either be a node or 2-D location coordinates, then every node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; will also have location coordinates. So predefine distance matrix to compute&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_r \sum_i dist_{d_r,i}e_{i}^r $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-19T22:02:24.010" LastActivityDate="2023-03-19T22:02:24.010" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="10163" PostTypeId="1" CreationDate="2023-03-19T18:55:06.517" Score="1" ViewCount="125" Body="&lt;p&gt;I have been working in the data science and operations research industry for a while now. Since about 2.5 years, I work in the IT department of a startup and my role is fully focussed on putting operations research in practice. Over the course of these years, my business title has changed from &amp;quot;Operations Researcher&amp;quot; to &amp;quot;Operations Research Scientist&amp;quot; to &amp;quot;Operations Research Engineer&amp;quot;. In the end, your work is of course not about the title, but about the content. In our company, the OR profile is considered as a mix of software engineer and data scientist.&lt;/p&gt;&#xA;&lt;p&gt;I recently reflected on this, and was wondering how one would distinguish between operations research engineer / scientist / analyst / ... outside of my bubble. Hence the question: how would you see the differences between these roles, and are there even any?&lt;/p&gt;&#xA;" OwnerUserId="954" LastActivityDate="2023-03-21T11:08:14.640" Title="How to distinguish between the different roles / titles in industry?" Tags="|industry|or-careers|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10164" PostTypeId="1" AcceptedAnswerId="10272" CreationDate="2023-03-19T22:48:59.250" Score="-1" ViewCount="119" Body="&lt;p&gt;I am working on an optimization project here and my objective is to come out with the optimal amount of each item to buy at certain vendors that can minimize the cost while meeting the demand(already figured out the demand constraints).&lt;/p&gt;&#xA;&lt;p&gt;Here is a little background for the case below, there are 2 Vendors, 2 distribution centers(DC), 2 items(UPC), and 2 Microfulfillment centers (MFC) and the chart below also contains the price, weight, and cube of each item.&lt;/p&gt;&#xA;&lt;p&gt;In my model, there are two types of variables:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;first type is a continuous variable where it has a form of v_dc_u_m(ex: v1_dc1_u1_m1 = 5 means 5 unit of items 1 purchased from vendor 1, shipping from dc1 to mfc1), it will be like&lt;/li&gt;&#xA;&lt;li&gt;second type of variable is a binary variable that has a form of v_dc_m which is used for calculating freight fee(ex: v1_dc1_m1 = 1 means a shipment is processed from v1, dc1 to m1, then it will be charged the corresponding freight fee)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The freight cost of each vendor(v1, v2) is also below where v1 charges a freight fee based on the total weight and cube of all ordered items from one DC to one MFC; v2 charges a freight fee based on the total order amount(in $) from one DC to one MFC.&lt;/p&gt;&#xA;&lt;p&gt;Everything else for this model is done except for this complicated freight cost in the objective function. I am stuck on this part and would really appreciate some help on how to implement this freight fee idea.&lt;/p&gt;&#xA;&lt;p&gt;I do have an idea, in the objective part, loop through all the unique v_mfc combinations and then sum up the total weight and cube of all ordered items from one DC to one MFC(using gp.quicksum()), then use multiple if-else statements to compare with the cube and weight range and use the corresponding freight fee. The same idea applies to v2 where it is based on the total order amount in dollars.&lt;/p&gt;&#xA;&lt;p&gt;Would really want some advice on whether my idea will work OR if anyone can share an easier way to implement this idea would be greatly appreciated!&#xA;&lt;a href=&quot;https://i.stack.imgur.com/S8jL7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S8jL7.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ll5eC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ll5eC.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TLTjR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TLTjR.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2023-04-06T06:20:43.833" Title="How to implement tiered pricing based on weight or cube volume or order amount total into objective function with Guro i py" Tags="|optimization|gurobi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10165" PostTypeId="2" ParentId="10164" CreationDate="2023-03-19T23:22:53.680" Score="1" Body="&lt;p&gt;Yes, if-then-else with indicator constraints will work.&lt;br /&gt;&#xA;If you may linearize, here's the suggestion&lt;br /&gt;&#xA;Suppose &lt;span class=&quot;math-container&quot;&gt;$0 \le x_{v,d,m,u,w,c} \in Z$&lt;/span&gt; is integer number of items &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; ordered from vendor &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; DC, of weight &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; &amp;amp; volume &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;&lt;br /&gt;&#xA;Also define some binary cost variables &lt;span class=&quot;math-container&quot;&gt;$v1_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$i= {1,2,...6}$&lt;/span&gt; scenarios. Also depending upon the problem it seems vendor &lt;span class=&quot;math-container&quot;&gt;$v1$&lt;/span&gt; has created a tiered pricing based on either weight or cube volume. Every item &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; will have a weight/cube. Weight/cube is given in the table &lt;span class=&quot;math-container&quot;&gt;${0.7,1.13}$&lt;/span&gt; &amp;amp; weight &lt;span class=&quot;math-container&quot;&gt;${5.5,9.4}$&lt;/span&gt;. So you can derive the minimum numbers of items that is causing this tier system, like from freight chart for vendor &lt;span class=&quot;math-container&quot;&gt;$v1$&lt;/span&gt;, total weight=500, each weight &lt;span class=&quot;math-container&quot;&gt;$=5.5$&lt;/span&gt;, so minimum order &lt;span class=&quot;math-container&quot;&gt;$500/5.5$&lt;/span&gt;. Same for cube &lt;span class=&quot;math-container&quot;&gt;$999/0.7$&lt;/span&gt;.&lt;br /&gt;&#xA;Then perhaps vendor is looking at minimum of min&lt;span class=&quot;math-container&quot;&gt;$\{500/5.5,999/0.7,500/9.4,999/1.13\}$&lt;/span&gt;. Suppose this number is VQ[1]. Likewise you may need to recreate a table of minimum quantity of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; for each threshold. It will be 6 scenarios with 6 freight cost &lt;span class=&quot;math-container&quot;&gt;$VC_i=Cost_i*VQ_i$&lt;/span&gt;. Also &lt;span class=&quot;math-container&quot;&gt;$200$&lt;/span&gt; at 0 weight, 0 cube, looks like setup cost which needs to be added. &lt;br /&gt;&#xA;Same for vendor 2, define binary variable &lt;span class=&quot;math-container&quot;&gt;$v2_j$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$j={1,2,..5}$&lt;/span&gt; scenarios. Its more straight forward, depending upon value of items ordered from DC to MFC.&lt;/p&gt;&#xA;&lt;p&gt;Constraints:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\forall i$&lt;/span&gt;:&lt;br /&gt;&#xA;(1)  &lt;span class=&quot;math-container&quot;&gt;$\sum_{d,m,w,c,u}(x_{v1,d,m,u,w,c} &#xA; \le VQ_i+Mv1_i$&lt;/span&gt;&lt;br /&gt;&#xA;(2)  &lt;span class=&quot;math-container&quot;&gt;$VQ_i \le \sum_{d,m,w,c,u}x_{v1,d,m,u,w,c}+M(1-v1_i)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Combining constr (1)&amp;amp;(2) into single pair of constraints&lt;br /&gt;&#xA;(3) &lt;span class=&quot;math-container&quot;&gt;$ \sum_iVQ_iv1_i \le \sum_{d,m,w,c,u}x_{v1,d,m,w,c,u} \le \sum_i VQ_{i+1}v1_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(4) &lt;span class=&quot;math-container&quot;&gt;$\sum_i v1_i = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Gurobi expression&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$VC1 = 200 + \sum_i V1C_iv1_i$&lt;/span&gt;: It will select one of the freight costs depending upon the volume.&lt;/p&gt;&#xA;&lt;p&gt;For vendor 2:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\forall j$&lt;/span&gt;:&lt;br /&gt;&#xA;(5)  &lt;span class=&quot;math-container&quot;&gt;$\sum_{d,m,w,c,u}p_{v2,d,m,u, w,c}x_{v2,d,m,w,c,u}  \le V2C_j+Mv2_j$&lt;/span&gt; &lt;br /&gt;&#xA;(6) &lt;span class=&quot;math-container&quot;&gt;$VC_j \le \sum_{d,m,w,c,u}p_{v2,d,m,u,w,c}x_{v2,d,m,w,c,u} + M(1-v2_j)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Combining constrs (5)&amp;amp;(6) into a pair of constraints as above&lt;br /&gt;&#xA;(7) &lt;span class=&quot;math-container&quot;&gt;$\sum_j V2C_jv2_j \sum_{dmwcu}p_{v2,d,m,u,w,c}x_{v2,d,m,w,c,u} \le \sum_j V2C_{j+1}v2_j$&lt;/span&gt;&lt;br /&gt;&#xA;(8) &lt;span class=&quot;math-container&quot;&gt;$\sum_jv2_j = 1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; can be big enough number, like upper bound of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Gurobi expression&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$VC2 = \sum_jV2C_jv2_j$&lt;/span&gt;: It will select one of the freight costs depending upon the order price.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-20T16:33:12.923" LastActivityDate="2023-03-20T16:33:12.923" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10166" PostTypeId="2" ParentId="10163" CreationDate="2023-03-20T06:34:11.223" Score="2" Body="&lt;p&gt;I see no difference between these titles and it's becoming increasingly risky to assume anything based on someone's job title.  I've met plenty of &amp;quot;managers&amp;quot; where the only thing they manage is their inbox.&lt;/p&gt;&#xA;" OwnerUserId="10108" LastActivityDate="2023-03-20T06:34:11.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10167" PostTypeId="2" ParentId="10163" CreationDate="2023-03-20T09:11:30.413" Score="1" Body="&lt;p&gt;As Riley said, the job title is not a good indicator, you will need to check the job description. But, as a rule of thumb, an analyst is someone expected to do models and analysis of results, but not to manage people, implement solutions in software, etc. A scientist is more related to modeling and an engineer with the software implementation of the model.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2023-03-20T09:11:30.413" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10168" PostTypeId="1" AcceptedAnswerId="10169" CreationDate="2023-03-20T10:25:10.373" Score="3" ViewCount="260" Body="&lt;p&gt;Let's have binary variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. I'd like to define a helping binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z = 1 \; \;\; \mathrm{iff} \; \; \; x + y = 2.$$&lt;/span&gt;&#xA;If I wanted to express the equivalence between binary variables &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, I would simply convert them into a conjunctive normal form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ a \Leftrightarrow b \equiv (a \Rightarrow b) \land (b \Rightarrow a) \equiv &#xA;(\lnot a \lor b) \land (\lnot b \lor a)$$&lt;/span&gt;&#xA;and do a standard SAT &lt;span class=&quot;math-container&quot;&gt;$\to$&lt;/span&gt; ILP conversion:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (1 -a) + b \geq 1, $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (1 - b) + a \geq 1. $$&lt;/span&gt;&#xA;Now let's try to substitute &lt;span class=&quot;math-container&quot;&gt;$a \to (z = 1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b \to (x + y = 2)$&lt;/span&gt; into the CNF:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (\lnot (z = 1) \lor (x + y = 2)) \land (\lnot (x + y = 2) \lor (z = 1)). $$&lt;/span&gt;&#xA;Since we can't use inequalities, we can rewrite the equalities as follows&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (\lnot (z \geq 1) \lor (x + y \geq 2)) \land (\lnot (x + y \geq 2) \lor (z \geq 1)) $$&lt;/span&gt;&#xA;and then we can simply negate the inequalities&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ ((z \leq 0) \lor (x + y \geq 2)) \land ((x + y \leq 1) \lor (z \geq 1)). $$&lt;/span&gt;&#xA;Now, my idea was to use the fact that the logical AND is implicit within the constraints and that we can emulate logical OR between the inequalities using big &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. Let's define helping variables &lt;span class=&quot;math-container&quot;&gt;$a_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_2$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z \leq  \mathrm{M}a_1, $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x + y + \mathrm{M}(1 - a_1) \geq 2, $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x + y \leq 1 + Ma_2, $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z + M(1 - a_2) \geq 1. $$&lt;/span&gt;&#xA;Now this won't work since we could just use &lt;span class=&quot;math-container&quot;&gt;$a_1 = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_2 = 0$&lt;/span&gt; and there would be no constraint on &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My idea is that we would somehow need to connect the lefthand side of the logical AND with the righthand side.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Was my approach correct up until the point right before the last conversion?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;How would one go about expressing the logical rules between entire equalities and inequalities in general?&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11480" LastEditorUserId="500" LastEditDate="2023-03-20T12:46:21.720" LastActivityDate="2023-03-21T01:57:27.683" Title="Equivalence between constraints in ILP" Tags="|integer-programming|constraint|combinatorial-optimization|linearization|logical-constraints|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10169" PostTypeId="2" ParentId="10168" CreationDate="2023-03-20T12:29:03.557" Score="3" Body="&lt;p&gt;Not sure if you need all this machinery. I would write:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{aligned} &amp;amp; z=0 \iff 0 \le x+ y \le 1 \\&#xA;                   &amp;amp;  z=1 \iff 2 \le x+ y \le 2 \end{aligned} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;or &lt;span class=&quot;math-container&quot;&gt;$$ 2z \le x+y \le 1 + z $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(Actually Rob's answer is better than this: use &lt;span class=&quot;math-container&quot;&gt;$z=xy$&lt;/span&gt; and linearize that using &lt;span class=&quot;math-container&quot;&gt;$z\le x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z \le y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z\ge x+y-1$&lt;/span&gt;. That is tighter. In fact it is so tight that we can relax &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to be continuous between 0 and 1).&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2023-03-20T14:15:10.387" LastActivityDate="2023-03-20T14:15:10.387" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10170" PostTypeId="2" ParentId="10168" CreationDate="2023-03-20T12:44:32.313" Score="4" Body="&lt;p&gt;For binary variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, notice that &lt;span class=&quot;math-container&quot;&gt;$x+y=2$&lt;/span&gt; is equivalent to &lt;span class=&quot;math-container&quot;&gt;$xy=1$&lt;/span&gt;, so you want to linearize &lt;span class=&quot;math-container&quot;&gt;$z=xy$&lt;/span&gt;.  I gave a derivation via conjunctive normal form in my answer here: &lt;a href=&quot;https://or.stackexchange.com/a/473/500&quot;&gt;https://or.stackexchange.com/a/473/500&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-03-20T12:44:32.313" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10171" PostTypeId="2" ParentId="10163" CreationDate="2023-03-20T13:24:35.690" Score="0" Body="&lt;p&gt;Broadly OR:&lt;br /&gt;&#xA;Analyst - generally quant analyst building models and conducting data collection, cleaning,  exploratory analysis &amp;amp; building dashboards.&lt;/p&gt;&#xA;&lt;p&gt;Scientist - building new algorithms and writing model prototypes. Generally PhD is needed. Expectation may include to build propriety solvers.&lt;/p&gt;&#xA;&lt;p&gt;Engineer - Industrial Engineer role designing models with known algorithms/solvers &amp;amp; implementing on shop floor. Sometimes could be same as OR Analyst.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-03-20T13:24:35.690" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10172" PostTypeId="1" AcceptedAnswerId="10173" CreationDate="2023-03-20T14:07:19.527" Score="3" ViewCount="124" Body="&lt;p&gt;Some modeling languages and solvers support indicator constraints of the form &lt;span class=&quot;math-container&quot;&gt;$$y=\hat{y} \implies \sum_j a_j x_j \le b,$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a binary decision variable and &lt;span class=&quot;math-container&quot;&gt;$\hat{y}\in\{0,1\}$&lt;/span&gt; is a constant.  How do I enforce a more general logical implication&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_j a_j x_j \le b \implies \sum_j c_j x_j \le d?$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-20T14:13:25.153" LastActivityDate="2023-03-20T14:13:25.153" Title="How to enforce logical implication $\sum_j a_j x_j \le b \implies \sum_j c_j x_j \le d$" Tags="|linearization|logical-constraints|indicator-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10173" PostTypeId="2" ParentId="10172" CreationDate="2023-03-20T14:07:19.527" Score="7" Body="&lt;p&gt;You can accomplish this by introducing a binary decision variable and splitting into two implications:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j a_j x_j \le b &amp;amp;\implies y = 1 \tag1\label1 \\&#xA;y = 1 &amp;amp;\implies \sum_j c_j x_j \le d \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{2} is already an indicator constraint.&#xA;To rewrite \eqref{1} as an indicator constraint, use its contrapositive&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y = 0 \implies \sum_j a_j x_j &amp;gt; b,$$&lt;/span&gt;&#xA;which you can model as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y = 0 \implies \sum_j a_j x_j \ge b + \epsilon$$&lt;/span&gt;&#xA;for some small constant tolerance &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt;.  If &lt;span class=&quot;math-container&quot;&gt;$\sum_j a_j x_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; are integer-valued, you can take &lt;span class=&quot;math-container&quot;&gt;$\epsilon=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now either use the indicator constraints directly or linearize via big-M:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;b + \epsilon - \sum_j a_j x_j &amp;amp;\le M_1 y \\&#xA;\sum_j c_j x_j - d &amp;amp;\le M_2 (1-y)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-03-20T14:07:19.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10174" PostTypeId="2" ParentId="10168" CreationDate="2023-03-21T01:57:27.683" Score="1" Body="&lt;p&gt;You can't let &lt;span class=&quot;math-container&quot;&gt;$a_1=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_2=0$&lt;/span&gt;, because it will enforce &lt;span class=&quot;math-container&quot;&gt;$x+y \geq 2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x+y \leq 1$&lt;/span&gt;, which is infeasible. That is the connection between the two new variables. So your model is totally correct but maybe not efficient.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2023-03-21T01:57:27.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10175" PostTypeId="1" AcceptedAnswerId="10180" CreationDate="2023-03-21T07:46:54.063" Score="2" ViewCount="202" Body="&lt;p&gt;Consider the following binary variable &lt;span class=&quot;math-container&quot;&gt;$x \in \{0,1\}$&lt;/span&gt;  and two continuous real variables &lt;span class=&quot;math-container&quot;&gt;$y,p \in \mathbb{R}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am trying to model the following conditional equations as constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases}&#xA;    -y \le p \le y ,&amp;amp; \text{if } y \ge 0 \\&#xA;     y \le p \le -y ,&amp;amp; \text{if } y \le 0 \\&#xA;     p = 0 ,&amp;amp; \text{if } x = 0 \\&#xA;\end{cases}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Whats the best way to do so while maintaining a MILP formulation?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The above is a restatement of the problem I attempted to explain below:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If the following two binary variables &lt;span class=&quot;math-container&quot;&gt;$x,z \in \{0,1\}$&lt;/span&gt;  and&#xA;continuous real variable &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{R}$&lt;/span&gt;. Whats the best way to&#xA;linearize the product of the three (i.e. &lt;span class=&quot;math-container&quot;&gt;$xyz$&lt;/span&gt;) if I am using them in&#xA;a constraint?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ xyz \le p \le xyz$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$p \in \mathbb{R} $&lt;/span&gt; is another continuous variable. The actual&#xA;constraint in mind is supposed to maintain the variable &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; within the&#xA;same range when the continuous variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; switches signs. For more&#xA;details, here is the actual expression:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x((1-z)y + 2yz)) \le p \le x(2(1-z)y + yz)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(1-z)y \le zy$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So the idea is that &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is 0 when &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is positive, and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is 1 when&#xA;&lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is negative. &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a switching binary that is turned to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to&#xA;limit the value of &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; to 0. Is there a way to linearize this&#xA;expression?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="9695" LastEditorUserId="9695" LastEditDate="2023-03-21T23:43:46.583" LastActivityDate="2023-03-22T13:42:01.033" Title="Linearization the product of three variables (two binary &amp; one continuous)" Tags="|mixed-integer-programming|linearization|nonlinear-programming|binary-variable|big-m|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10176" PostTypeId="2" ParentId="10175" CreationDate="2023-03-21T10:25:42.493" Score="1" Body="&lt;p&gt;By updating the question, the mentioned conditional inequalities can be linearized by introducing new indicator variables, &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;, for each part and coupling those to make linearization. For example the first part, &lt;span class=&quot;math-container&quot;&gt;$\{-y \leq p \leq y , \ \text{if } y \ge 0\}$&lt;/span&gt;, would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ z_1 = 1 \iff (y \geq 0) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_2 = 1 \iff (- y - p \leq 0)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_3 = 1 \iff (p - y \leq 0)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_4 = 1 \iff (z_2 + z_3 = 2)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_1 = 1 \implies z_4  = 1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and the same should be held for the rest inequalities.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-03-22T13:42:01.033" LastActivityDate="2023-03-22T13:42:01.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10177" PostTypeId="2" ParentId="10163" CreationDate="2023-03-21T11:08:14.640" Score="1" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;... how one would distinguish between operations research engineer / scientist / analyst / ... outside of my bubble. Hence the question: how would you see the differences between these roles, and are there even any?&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Two ways to distinguish between the naming of the position is by the name of the course in a post-secondary institutions and at an employer.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Employers who ask for qualifications that are not taught in school are also seldom willing to pay for them.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Positions not correctly named are usually open to great variance as to what is entailed, and resulting pay.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It's best to either establish in writing what is required or avoid employers who don't know what they want and the usual amount to be paid.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The name of the position, pay, responsibilities and years in school required are one set of distinguishing requirements, another way to look at it is from the viewpoint of supply and demand.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You wouldn't want to spend many years in school studying extremely technical material to do a job that has many responsibilities, paid little, and was difficult to find.&lt;/li&gt;&#xA;&lt;li&gt;I guess it's ideal if the study isn't too lengthy or mindbending, few people take the course, the jobs are plentiful, and the responsibilities are enough to provide some challenges, but it pays well.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;One source of job descriptions and average pay is online job sites, for example: &lt;a href=&quot;https://www.glassdoor.ca/Salaries/operations-research-scientist-salary-SRCH_KO0,29.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;GlassDoor&lt;/a&gt; and &lt;a href=&quot;https://www.betterteam.com/operations-research-analyst-job-description&quot; rel=&quot;nofollow noreferrer&quot;&gt;BetterTeam - Operations Research Analyst Job Description Template&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Operations Research Scientist Salaries in Canada: \$79,471/yr (Average Base Pay, out of 1,414 salaries)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Operations Research Engineer Canada \$71,590&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Operations Research Analyst Canada \$58,001&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When you look up the average pay in the USA it's much higher, worth moving. Source: &lt;a href=&quot;https://www.ziprecruiter.com/Jobs/Operations-Research-Engineer&quot; rel=&quot;nofollow noreferrer&quot;&gt;ZipRecruiter&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Operations Research Analyst USA &lt;a href=&quot;https://www.ziprecruiter.com/Salaries/Operations-Research-Analyst-Salary-in-Kansas-City,KS&quot; rel=&quot;nofollow noreferrer&quot;&gt;\$88,674/yr&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Operations Research Engineer USA \$162,999/yr&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;A less biased source of information is probably the &lt;a href=&quot;https://www.bls.gov/ooh/math/operations-research-analysts.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;US Bureau of Labor Statistics&lt;/a&gt;. Clicking on related jobs (with lesser requirements and greater pay) we find: &lt;a href=&quot;https://www.bls.gov/ooh/computer-and-information-technology/computer-and-information-research-scientists.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Computer and Information Research Scientists - Masters, \$131,490/yr&lt;/a&gt; or &lt;a href=&quot;https://www.bls.gov/ooh/math/data-scientists.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Data Scientist - Bachelor, \$100,910/yr&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Future outlook is another consideration, while not related to your question it's useful to consider the future before undertaking the course or planning an employment career.&lt;/p&gt;&#xA;&lt;p&gt;Some careers are quite safe as far as longevity is concerned, others are either being phased out or have such rapidly changing requirements that your paper is outdated before the ink can dry.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2023-03-21T11:08:14.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10178" PostTypeId="2" ParentId="10175" CreationDate="2023-03-21T14:34:10.327" Score="0" Body="&lt;p&gt;Basically you are trying the following:&#xA;&lt;span class=&quot;math-container&quot;&gt;$ p \le xp_{max}$&lt;/span&gt;: ensures &lt;span class=&quot;math-container&quot;&gt;$p=0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt;, else &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is free,&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ p_{max}$&lt;/span&gt; is upper bound of &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;&lt;br /&gt;&#xA;And&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ y(2z-1) \le p \le y(1-2z) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$ y, z$&lt;/span&gt; switching I think you already have&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ y \le y_{max}(1-z)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$-y \le y_{max}z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To linearize &lt;span class=&quot;math-container&quot;&gt;$ yz$&lt;/span&gt; you can try with a new continuous variable &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; in same domain as &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; with following standard constraints (&lt;a href=&quot;https://or.stackexchange.com/questions/6071/how-to-linearize-the-product-of-a-binary-and-a-continuous-variable&quot;&gt;link&lt;/a&gt;)&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ w \le M(1-z)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ -w \le M(1-z)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ y-Mz \le w$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ w \le y + Mz$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The above 4 constraints forces &lt;span class=&quot;math-container&quot;&gt;$w=y$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$z=0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$0 \le y$&lt;/span&gt;, else 0&lt;/p&gt;&#xA;&lt;p&gt;So &lt;span class=&quot;math-container&quot;&gt;$ 2w-y \le p \le y-2w$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-21T22:17:59.863" LastActivityDate="2023-03-21T22:17:59.863" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10179" PostTypeId="1" CreationDate="2023-03-21T16:05:45.287" Score="3" ViewCount="81" Body="&lt;p&gt;While working on optimization issues I encountered the following problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left\{\begin{array}{ll}&#xA;    {\displaystyle \sup_{z\in\mathbb{R}^{m}}} &amp;amp;\frac{ \langle c,z \rangle + \rho}{ \left\|B z\right\|}  \\&#xA;     \mbox{s. t} &amp;amp; Az\leq b\\&#xA;     &amp;amp; \langle f,z\rangle =1.&#xA;\end{array} \right.$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\left\|\cdot\right\|$&lt;/span&gt; is the Euclidean norm. I know that this is a fractional problem, and I know that the easiest fractional problems to solve are those that are a quotient of two affine functions. However, this problem is not of that type. I have tried to solve it in Matlab with fmincon, but it takes too long to find a solution. My intention is to know if there is a more efficient way to solve this problem. The reason for this posting is to ask you for suggestions on how to deal with this problem.&lt;/p&gt;&#xA;" OwnerUserId="11486" LastActivityDate="2023-03-21T16:05:45.287" Title="Looking for an efficient way to solve a fractional problem (affine function over euclidean norm )" Tags="|optimization|nonlinear-programming|generalized-linear-fractional|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10180" PostTypeId="2" ParentId="10175" CreationDate="2023-03-21T23:51:10.337" Score="5" Body="&lt;p&gt;More compactly, you want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-x|y| \le p \le x|y|$$&lt;/span&gt;&#xA;Assume &lt;span class=&quot;math-container&quot;&gt;$L \le y \le U$&lt;/span&gt; for some constants &lt;span class=&quot;math-container&quot;&gt;$L\le 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U\ge 0$&lt;/span&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$M=\max(-L,U)$&lt;/span&gt;.  Introduce continuous decision variable &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; (to represent &lt;span class=&quot;math-container&quot;&gt;$|y|$&lt;/span&gt;) and binary decision variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;-Mx \le p &amp;amp;\le Mx \tag1\label1 \\&#xA;-w \le p &amp;amp;\le w \tag2\label2 \\&#xA;-w \le y &amp;amp;\le w \tag3\label3 \\&#xA;w - y &amp;amp;\le (M-L) z \tag4\label4 \\&#xA;w + y &amp;amp;\le (M+U)(1-z) \tag5\label5                      &#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} enforces &lt;span class=&quot;math-container&quot;&gt;$x=0 \implies p=0$&lt;/span&gt;.&#xA;Constraint \eqref{4} enforces &lt;span class=&quot;math-container&quot;&gt;$z=0 \implies w\le y$&lt;/span&gt; (hence &lt;span class=&quot;math-container&quot;&gt;$w=y$&lt;/span&gt;).&#xA;Constraint \eqref{5} enforces &lt;span class=&quot;math-container&quot;&gt;$z=1 \implies w\le -y$&lt;/span&gt; (hence &lt;span class=&quot;math-container&quot;&gt;$w=-y$&lt;/span&gt;).&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-03-21T23:51:10.337" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10181" PostTypeId="1" CreationDate="2023-03-22T02:16:02.760" Score="3" ViewCount="51" Body="&lt;p&gt;Is there a nice formula for the finite time variance of the m/m/1/k=1 queue in steady state? (Exponential arrivals &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;, exponential service time &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt;, 1 server and no queue, so if a job arrives while one is in service it is lost.)  In particular I'm interested in k=1 where this is a simply continuous time markov chain with 2 states, busy and idle.&lt;/p&gt;&#xA;&lt;p&gt;Formally, let f be the fraction of time there is a job in service, ie how busy is the server. (I don't care about the lost jobs.) Then for any length of time &lt;span class=&quot;math-container&quot;&gt;$E[f]=\mu/(\lambda+\mu)$&lt;/span&gt; in steady state, but what is the variance of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; over a period of time &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For the special case where &lt;span class=&quot;math-container&quot;&gt;$\lambda=\mu$&lt;/span&gt; then over an interval of length &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; the number of jobs serviced is Poisson and conditional on this number, the times at which the jobs begin and end are uniformly distributed over the interval, so you can compute all the probabilities as (ugly) sums. Is there a similar result when &lt;span class=&quot;math-container&quot;&gt;$\lambda\not=\mu$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8941" LastActivityDate="2023-03-22T02:16:02.760" Title="m/m/1/k=1 variance" Tags="|queuing-theory|stochastic-process|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10182" PostTypeId="1" CreationDate="2023-03-22T20:18:08.447" Score="1" ViewCount="79" Body="&lt;p&gt;I would like to know how can I obtain the exact number of simplex and barrier iterations used by CPLEX in OPL. The solution reports the total number of iterations but I want them to be separated (Barrier and Simplex).&lt;/p&gt;&#xA;" OwnerUserId="11499" LastEditorUserId="36" LastEditDate="2023-03-23T12:57:06.753" LastActivityDate="2023-03-23T12:57:06.753" Title="Information about number of simplex and barrier iterations in OPL CPLEX" Tags="|cplex|opl|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10183" PostTypeId="1" CreationDate="2023-03-23T12:05:06.473" Score="2" ViewCount="97" Body="&lt;p&gt;I have a demand forecast that gives me a distribution for future demand, for each time period in percentiles (e.g. demand for period 1 will be between 6 and 25 (zero and 100th percentiles, and i know all other percentiles in between, and this is given for each time period). I don't know which distribution each product follows.&lt;/p&gt;&#xA;&lt;p&gt;The inventory optimization I feed this to currently only uses a point from the forecast, thus I am missing a lot of information I could use to create a better optimization.&lt;/p&gt;&#xA;&lt;p&gt;I'm currently considering (1) determining a critical factor for each product as the ration of underage and overage cost, or (2) running the optimization across e.g. the 10th, 20th, 30th etc percentile of the forecast of each product, weighing these &amp;quot;scenarios&amp;quot; with their likelihood and choosing the optimal outcome.&lt;/p&gt;&#xA;&lt;p&gt;I'm missing the vocabulary to be able to research these options. Can you help me with what terms should I search for to find relevant research for this? any other ideas I should look at to solve this?&lt;/p&gt;&#xA;" OwnerUserId="7430" LastEditorUserId="491" LastEditDate="2023-03-24T12:18:48.847" LastActivityDate="2023-04-01T06:44:54.640" Title="use Forecast distribution width in inventory optimization" Tags="|optimization|inventory|demand-distribution|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10184" PostTypeId="2" ParentId="10183" CreationDate="2023-03-23T15:33:45.160" Score="4" Body="&lt;p&gt;Here are three distinct fields of research, any of which might (or might not) be useful to you.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Robust_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Robust optimization&lt;/a&gt; deals with uncertainty in the parameters of an optimization model by focusing on worst cases.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://neos-guide.org/guide/types/stochastic/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Stochastic programming with recourse&lt;/a&gt; deals with randomness in parameters by incorporating in the optimization model elements related to how the system adapts to the effects of randomness (for instance, expediting orders, outsourcing or suffering stock-out penalties if demand exceeds the inventory levels generated by the model decisions).&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://optimization.cbe.cornell.edu/index.php?title=Chance-constraint_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chance constrained programming&lt;/a&gt; incorporates randomness into the optimization model by constraining solutions to be feasible/optimal with a certain probability (meaning the user accepts a certain risk that the solution will not work when the random variables are observed).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-23T15:33:45.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10185" PostTypeId="1" AcceptedAnswerId="10204" CreationDate="2023-03-24T10:09:00.997" Score="1" ViewCount="192" Body="&lt;p&gt;I would like to get the inventory balance in the oponed facility &lt;span class=&quot;math-container&quot;&gt;$\text{C}$&lt;/span&gt; such that, the Inventory at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is equal to the previous one, plus the inflow minus the outflow. I have tried to create a list with zeroes, but I could not make it automated. The other issue is with indexing in python. For instance, if &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; which is time in months, and it's &lt;code&gt;range(0,3)&lt;/code&gt; then, &lt;span class=&quot;math-container&quot;&gt;$t-1$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$(-1)$&lt;/span&gt; which gives an error.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$INV_{c,t}$&lt;/span&gt;: is the inventory at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$INV_{c,t-1}$&lt;/span&gt;: is the inventory at time &lt;span class=&quot;math-container&quot;&gt;$t-1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The equations:&#xA;&lt;span class=&quot;math-container&quot;&gt;$INV_{c,t}=INV_{c,t-1}+\sum{QS}_{c,t}+\sum{QM}_{c,t}-\sum{QG}_{c,t}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Inventory level decision variable&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;INV_c= m.addVars(storages,months, name=&amp;quot;INV_ct&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Inventory Balance Constraints&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;m.addConstrs(INV_c[c,t] == INV_c[c,t-1] + sum(QD_wc[w,c,t,p] for w in range(warehouses) for p in range(products)) + sum(QH_hc[h,c,t]\&#xA;               for h in range(customers)) - sum(QG_co[c,o,t] for o in range(centers)) for c in range(storages) for t in range(months))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have defined &lt;span class=&quot;math-container&quot;&gt;$INV0_{c,t}$&lt;/span&gt; as parameter (an array of 3 by 2 dimension), in which &lt;span class=&quot;math-container&quot;&gt;$INV0_{c,t}$&lt;/span&gt; could replace &lt;code&gt;INV_c[c,t-1] &lt;/code&gt; in the above constraint.&lt;/p&gt;&#xA;&lt;p&gt;I have tried to write a for loop to capture the cumulative inventory at each period, by defining the following code;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;INV0_[c,t]=0&#xA;for t in range(months):&#xA; for c in range(storages):&#xA;  INV0_[c,t]=INV0_[c,t]+INV_c[c,t]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11004" LastEditorUserId="500" LastEditDate="2023-03-25T19:03:30.963" LastActivityDate="2023-03-28T10:20:06.923" Title="Multi-period Inventory Balance in Gurobipy" Tags="|mixed-integer-programming|python|gurobi|inventory|" AnswerCount="4" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="10186" PostTypeId="2" ParentId="10148" CreationDate="2023-03-24T12:04:39.293" Score="2" Body="&lt;p&gt;What you are looking for is categorized under &lt;em&gt;&lt;strong&gt;warehouse space and its related handling system optimization&lt;/strong&gt;&lt;/em&gt;. For example, the first term &lt;code&gt;Flow rack&lt;/code&gt; referred to the storage location near to production line(s) to feed the row/WIP materials into the line(s) based on the FIFO strategy and also with the aid of gravity to move the small pallets on the rack. Usually feeding from the back and consuming in front.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1V6iz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1V6iz.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are already many useful resources to study around this topic. One of the best is &lt;em&gt;&lt;a href=&quot;https://www.warehouse-science.com/book/editions/wh-sci-0.98.1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;WAREHOUSE &amp;amp; DISTRIBUTION SCIENCE&lt;/a&gt;&lt;/em&gt; by Georgia Institute of Technology. Also, others would be &lt;a href=&quot;https://rackingandshelving.files.wordpress.com/2018/04/warehouseoperationshandout2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;https://docs.oracle.com/en/applications/jd-edwards/supply-chain-manufacturing/9.2/eoawm/defining-warehouse-specifications.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; links. Indeed, You could still find many related topics in the supply chain handbooks as well as warehouse service companies' technical materials.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-03-24T12:04:39.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10187" PostTypeId="2" ParentId="10185" CreationDate="2023-03-24T12:38:26.127" Score="2" Body="&lt;p&gt;The standard inventory balance equation would be something like &lt;span class=&quot;math-container&quot;&gt;$I_{t-1} + x_{t} = d_{t} + I_{t}$&lt;/span&gt; , where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; are production quantity and demand respectively. Now, it seems you need to push the flow materials on both sides. Also, besides the inventory term, you have three additional terms in the RHS that needs more clarification. For the second error, I am not sure how it can be implemented in python, but for fixing the indexing error you have to define the inventory variable domain &lt;span class=&quot;math-container&quot;&gt;$\in \{0, \cdots, T \}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-03-24T12:38:26.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10188" PostTypeId="2" ParentId="9951" CreationDate="2023-03-24T13:20:38.377" Score="1" Body="&lt;p&gt;Job shop scheduling problem is NP-hard in its essence and finding or developing a straightforward formulation to solve the large instance is really challenging work. If you would like to develop a math model I recommend having a look at the following papers to see how different formulations can solve the problem. Also, one of the best approaches to solving this kind of problem is by using either CP/SAT solver or some state-of-the-art heuristic algorithms like the &lt;a href=&quot;https://en.wikipedia.org/wiki/Shifting_bottleneck_heuristic&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;&lt;strong&gt;shifting-bottleneck heuristic&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://tidel.mie.utoronto.ca/pubs/JSP_CandOR_2016.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mixed Integer Programming Models for Job Shop Scheduling: A Computational Analysis&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/opre.8.2.219&quot; rel=&quot;nofollow noreferrer&quot;&gt;Alan Manne, &amp;quot;On the job-shop scheduling problem&amp;quot;, Operations Research vol 8, no 2 March-April 1960.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-03-24T13:20:38.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10189" PostTypeId="2" ParentId="10185" CreationDate="2023-03-24T14:37:11.913" Score="2" Body="&lt;p&gt;You can start your index from &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n+1$&lt;/span&gt; if you have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; months for which you need to write the balance equations. Then you can define &lt;span class=&quot;math-container&quot;&gt;$I_{-1}=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$I_{n+1}=0$&lt;/span&gt; if you don't want to keep inventory at the end of planning period. While you still need to define &lt;span class=&quot;math-container&quot;&gt;$I_{-1}$&lt;/span&gt; as a variable but you can fix this variable to have the value of &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; by:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$I_{-1}.lb = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$I_{-1}.ub = 0$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2023-03-24T14:37:11.913" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10190" PostTypeId="1" AcceptedAnswerId="10191" CreationDate="2023-03-24T16:03:15.657" Score="3" ViewCount="260" Body="&lt;p&gt;I am trying to set up a MILP for production scheduling. The specific details I'm not sure are important but in general a plant has M machines running N parts, each part requiring W workers. The model runs over S shifts (usually over 5 day or 10 day modelling periods).&lt;/p&gt;&#xA;&lt;p&gt;One key feature is it's preferable for the amount of workers to stay relatively constant. One way we have thought to do this is to just put constraints on the minimum and maximum number of workers and adjusting those as tight as we can. The downside to that is that we would need to re-run the model and adjust the parameters.&lt;/p&gt;&#xA;&lt;p&gt;However, I was wondering if there is a way to somehow quantify either the standard deviation (preferable) or the range (less preferable but still appreciated) of the number of workers per shift such that the model remains a MILP?&lt;/p&gt;&#xA;" OwnerUserId="11510" LastEditorUserId="491" LastEditDate="2023-03-24T16:32:29.987" LastActivityDate="2023-03-24T18:54:45.653" Title="Quantifying a measure of standard deviation in MILP" Tags="|optimization|mixed-integer-programming|modeling|linearization|scheduling|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10191" PostTypeId="2" ParentId="10190" CreationDate="2023-03-24T16:14:47.090" Score="6" Body="&lt;p&gt;A couple of options come to mind. Let &lt;span class=&quot;math-container&quot;&gt;$w_s$&lt;/span&gt; be a variable representing the number of workers during shift &lt;span class=&quot;math-container&quot;&gt;$s.$&lt;/span&gt; You can introduce nonnegative variables &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to represent the minimum and maximum of &lt;span class=&quot;math-container&quot;&gt;$w_s,$&lt;/span&gt; along with the constraints &lt;span class=&quot;math-container&quot;&gt;$y \le w_s \le z$&lt;/span&gt; for all shifts &lt;span class=&quot;math-container&quot;&gt;$s \in S.$&lt;/span&gt; Now add a penalty term &lt;span class=&quot;math-container&quot;&gt;$\lambda(z-y)$&lt;/span&gt; to your objective (&lt;span class=&quot;math-container&quot;&gt;$\lambda &amp;gt; 0$&lt;/span&gt; if your objective is minimization, &lt;span class=&quot;math-container&quot;&gt;$\lambda &amp;lt; 0$&lt;/span&gt; if maximization). Because you are penalizing the size of the range, the optimal solution will automatically set &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; respectively &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to the smallest respectively largest values of &lt;span class=&quot;math-container&quot;&gt;$w_s.$&lt;/span&gt; The virtue of this approach is that it keeps your model linear (assuming it was linear before).&lt;/p&gt;&#xA;&lt;p&gt;Using the standard deviation would be problematic, but if you are willing to &amp;quot;trade-up&amp;quot; to a quadratic integer program you can penalize the variance of the shift sizes. Introduce a nonnegative variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to represent the mean shift size, together with the constraint &lt;span class=&quot;math-container&quot;&gt;$$\frac{1}{\vert S \vert}\sum_{s\in S}w_s = z.$$&lt;/span&gt; Add the penalty term &lt;span class=&quot;math-container&quot;&gt;$\lambda \sum_s \left(w_s - z\right)^2$&lt;/span&gt; to the objective function. Assuming the constraints were linear before the change, they still are, and many (most?) modern IP solvers can handle minimizing a convex quadratic objective function.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-24T16:14:47.090" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10192" PostTypeId="2" ParentId="10190" CreationDate="2023-03-24T16:48:06.563" Score="3" Body="&lt;p&gt;Similar to above answer, you can avoid quadratic objective by summing up absolute deviation from the mean with:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \vert S \vert w_s - \sum_s w_s \le \vert S \vert z$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_s w_s - \vert S \vert w_s \le \vert S \vert z$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ 0 \le z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;There's may not be any need to use &lt;span class=&quot;math-container&quot;&gt;$ \vert S \vert $&lt;/span&gt; on RHS&lt;/p&gt;&#xA;&lt;p&gt;Then minimize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You may choose to have variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; for each shift &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, then minimize the sum.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-24T17:17:01.263" LastActivityDate="2023-03-24T17:17:01.263" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10193" PostTypeId="2" ParentId="10190" CreationDate="2023-03-24T18:54:45.653" Score="2" Body="&lt;p&gt;Why not try to calculate the overall required operators at each shift or any specific period of time, weekly/monthly, as a predefined parameter, in the best case, for each of &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; parts, and incorporating this in the model directly?&lt;/p&gt;&#xA;&lt;p&gt;This is a very common in many of the practical scheduling software. Suppose for each part you know how long it takes to complete in each machin. By summing up the required time to complete all of parts on the specific machine and also defining your appreciate shift, the number of required operators can be calculated as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$P_{p,m}$&lt;/span&gt;: processing time of part &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; on machin &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$D_{p,m}$&lt;/span&gt;: the number of parts should be processed on machin &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Opr_{p}$&lt;/span&gt;: the number of required operators for each part.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ Opr_{p} = Ceil((\sum P_{p,m}D_{p,m}) / |S|)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, if you would like to incorporate the required operators as a decision variable, what proposed by Prof. Rubin, you can use this number as an upper bound on this variable to improve the solving process.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-03-24T18:54:45.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10194" PostTypeId="1" AcceptedAnswerId="10195" CreationDate="2023-03-25T00:29:56.980" Score="2" ViewCount="373" Body="&lt;p&gt;How do I represent the following constraints in terms of equations?&lt;/p&gt;&#xA;&lt;p&gt;For each &lt;em&gt;i&lt;/em&gt;, either (1) holds or (2) holds-&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{1}^i \geq x_{2}^i \quad and \quad x_{3}^i \geq x_{4}^i \quad   {(1)}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{1}^i \leq x_{2}^i \quad and \quad x_{3}^i \leq x_{4}^i  \quad   {(2)}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10675" LastEditorUserId="10675" LastEditDate="2023-03-25T00:53:32.340" LastActivityDate="2023-03-25T01:12:25.407" Title="Representing &quot;and&quot;/&quot;or&quot; relationships into constraints" Tags="|modeling|constraint|logical-constraints|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10195" PostTypeId="2" ParentId="10194" CreationDate="2023-03-25T00:59:35.107" Score="7" Body="&lt;p&gt;Introduce binary decision variable &lt;span class=&quot;math-container&quot;&gt;$z^i$&lt;/span&gt;. You can model your logical conditions via indicator constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z^i=0 &amp;amp;\implies x_1^i \ge x_2^i \\&#xA;z^i=0 &amp;amp;\implies x_3^i \ge x_4^i \\&#xA;z^i=1 &amp;amp;\implies x_1^i \le x_2^i \\&#xA;z^i=1 &amp;amp;\implies x_3^i \le x_4^i&#xA;\end{align}&lt;/span&gt;&#xA;These indicator constraints can alternatively be enforced via linear big-M constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_2^i - x_1^i &amp;amp;\le M_1 z^i\\&#xA;x_4^i - x_3^i &amp;amp;\le M_2 z^i\\&#xA;x_1^i - x_2^i &amp;amp;\le M_3 (1-z^i) \\&#xA;x_3^i - x_4^i &amp;amp;\le M_4 (1-z^i)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-25T01:12:25.407" LastActivityDate="2023-03-25T01:12:25.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10196" PostTypeId="2" ParentId="10194" CreationDate="2023-03-25T01:01:42.510" Score="2" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x_1^{i}-x_2^{i} \le \epsilon + Mz_1^i$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_2^{i}-x_1^{i}\le \epsilon + M(1-z_1^i) $&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_3^{i}- x_4^{i} \le \epsilon + Mz_2^i$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_4^{i}- x_3^{i} \le \epsilon + M(1-z_2^i)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ z_1^i+z_2^i \le 1+\delta_1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\delta_1 \le z_1^i $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\delta_1 \le z_2^i $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ 1\le \delta_1+\delta_2$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$1-z_1^i-z_2^i \le \delta_2$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; are binary, M is upper bound of your &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0\le \epsilon$&lt;/span&gt; is a very small number.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-03-25T01:01:42.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10197" PostTypeId="1" CreationDate="2023-03-25T11:53:30.443" Score="3" ViewCount="389" Body="&lt;p&gt;I have an optimization problem that has a variable in the matrix form. The variable is a binary matrix. It has size &lt;span class=&quot;math-container&quot;&gt;$M \times N = 10 \times 50$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is the number of machines and &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is the number of resources. The resources are indexed as &lt;span class=&quot;math-container&quot;&gt;$\{1, 2, 3, \dots, 50 \}$&lt;/span&gt;. Also, one resource can be shared by multiple machines and each row corresponds to a machine.&lt;/p&gt;&#xA;&lt;p&gt;The condition is as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;One user can have maximum of 20 resources.&lt;/li&gt;&#xA;&lt;li&gt;The resources assigned to any user must be contiguous.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For example, let us consider user &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;. It got &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; resources. If the first resource is being assigned to the index &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt;, the other &lt;span class=&quot;math-container&quot;&gt;$9$&lt;/span&gt; resources must be indexed as &lt;span class=&quot;math-container&quot;&gt;$11$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$19$&lt;/span&gt; so that all the resources assigned to user 5 are contiguous. &lt;em&gt;&lt;strong&gt;How can I model this constraint?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11515" LastEditorUserId="6111" LastEditDate="2023-03-26T18:57:12.400" LastActivityDate="2023-03-26T18:57:12.400" Title="How to model this binary constraint?" Tags="|modeling|integer-programming|constraint|binary-variable|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10198" PostTypeId="2" ParentId="10197" CreationDate="2023-03-25T13:42:30.063" Score="9" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; be your binary decision variable. The “at most 20 resources” constraint is &lt;span class=&quot;math-container&quot;&gt;$\sum_j x_{i,j} \le 20$&lt;/span&gt; for each row &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. One way to enforce contiguity is to introduce another binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; to indicate whether &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; is the “start” (the first &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;) in row &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.  You would then impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j y_{i,j} &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for all $i$} \tag1\label1 \\&#xA;x_{i,j} &amp;amp;\le y_{i,j} &amp;amp;&amp;amp;\text{for all $i$ and $j=1$}\tag2\label2 \\&#xA;x_{i,j} - x_{i,j-1} &amp;amp;\le y_{i,j} &amp;amp;&amp;amp;\text{for all $i$ and $j&amp;gt;1$}\tag3\label3&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} enforces at most &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; start per row. Constraint \eqref{2} enforces &lt;span class=&quot;math-container&quot;&gt;$x_{i,1} \implies y_{i,1}$&lt;/span&gt;. Constraint \eqref{3} enforces &lt;span class=&quot;math-container&quot;&gt;$(x_{i,j} \land \lnot x_{i,j-1}) \implies y_{i,j}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If you want to avoid introducing new variables, you can instead replace \eqref{1} through \eqref{3} with &lt;span class=&quot;math-container&quot;&gt;$\binom{N}{3}$&lt;/span&gt; constraints per row:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{i,j} + x_{i,\ell} - 1 &amp;amp;\le x_{i,k} &amp;amp;&amp;amp;\text{for all $i$ and $1\le j &amp;lt; k &amp;lt; \ell \le N$}\tag4\label4&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{4} enforces &lt;span class=&quot;math-container&quot;&gt;$(x_{i,j} \land x_{i,\ell}) \implies x_{i,k}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-26T14:39:29.130" LastActivityDate="2023-03-26T14:39:29.130" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10199" PostTypeId="2" ParentId="10197" CreationDate="2023-03-25T13:49:32.047" Score="0" Body="&lt;p&gt;Assuming user is your machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; over resource &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is your binary matrix&lt;br /&gt;&#xA;Try&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$N_mx_{m,r-1}-\sum_{k=1}^{r-2} x_{m,k} \le N_mx_{m,r} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you number of resources assigned to a machine is itself a variable then you can try&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{k=1}^{j-1}x_{ij} \le Mz1_{ij}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M=min(20,j-1)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{k=j+1}^{N}x_{ij} \le Mz2_{ij} $&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M=min(20,N-j)$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ z1_{ij}+z2_{ij} -1 \le x_{ij} \quad \forall j$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-26T17:12:12.883" LastActivityDate="2023-03-26T17:12:12.883" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10202" PostTypeId="2" ParentId="10185" CreationDate="2023-03-25T20:34:30.507" Score="1" Body="&lt;p&gt;Ok I see you have updated your code because in the previous version I thought I saw cumulative inventory being used in the constraints. If not used in constraint then yes you can simply use it as expression as you have used in the code INV0_[c,t]=INV0_[c,t]+INV_c[c,t]. But need to change it a bit.&lt;br /&gt;&#xA;Declare INV0_[c,t] as a python matrix like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;INV0_ = [[0,0,0,0],&#xA;          [0,0,0,]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Possible if you define it as numpy matrix gurobi throws an error but native python matrix doesn't have a problem.&lt;br /&gt;&#xA;Then in code&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for t in range(months):&#xA;   for c in range(storages):&#xA;     INV0_[c][t]=INV0_[c][t-1]+INV_c[c,t]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then to get the values of INV0 use&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for t in range(months):&#xA;       for c in range(storages):&#xA;         print(INV0_[c][t].getValue())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-25T21:20:21.360" LastActivityDate="2023-03-25T21:20:21.360" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10204" PostTypeId="2" ParentId="10185" CreationDate="2023-03-26T16:00:03.773" Score="2" Body="&lt;p&gt;A simple approach that does not require much thought would be to split this into two parts:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# the general case for t&amp;gt;0&#xA;m.addConstrs(INV_c[c,t] == INV_c[c,t-1] + sum(QD_wc[w,c,t,p] for w in range(warehouses) for p in range(products)) + sum(QH_hc[h,c,t]\&#xA;               for h in range(customers)) - sum(QG_co[c,o,t] for o in range(centers)) for c in range(storages) for t in range(1,months))&#xA;&#xA;# special case for t=0&#xA;m.addConstrs(INV_c[c,0] == INV0[c] + sum(QD_wc[w,c,0,p] for w in range(warehouses) for p in range(products)) + sum(QH_hc[h,c,0]\&#xA;               for h in range(customers)) - sum(QG_co[c,o,0] for o in range(centers)) for c in range(storages))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where &lt;code&gt;INV0[c]&lt;/code&gt; are exogenous values: inventory at &lt;code&gt;t=-1&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;IMHO, this is a little bit more straightforward than some of the other suggestions.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2023-03-28T10:20:06.923" LastActivityDate="2023-03-28T10:20:06.923" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10205" PostTypeId="2" ParentId="10148" CreationDate="2023-03-26T18:04:23.177" Score="1" Body="&lt;p&gt;For general Supply Chain terms you can refer to manual from &lt;a href=&quot;http://www.apics.org/docs/default-source/certification/cpim-ecm-5-0-final-with-covers.pdf?sfvrsn=4&quot; rel=&quot;nofollow noreferrer&quot;&gt;APICS&lt;/a&gt; (they also provide a dictionary &amp;amp; an updated manual at a price).&lt;br /&gt;&#xA;For general racking systems &lt;a href=&quot;https://www.ar-racking.com/en/news-and-blog/storage-solutions/storage-racking-solutions/types-of-industrial-racking-for-the-warehouse-classification-and-characteristics&quot; rel=&quot;nofollow noreferrer&quot;&gt;AR- Racking&lt;/a&gt; storage solutions kind of most comprehensive list of different racks, their classifications and use.&lt;br /&gt;&#xA;For general warehouse related terms and operations, this &lt;a href=&quot;https://www.apexwarehousesystems.com/coming-to-terms-with-the-material-handling-word-soup/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt; provides a glossary.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-03-26T18:04:23.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10207" PostTypeId="1" AcceptedAnswerId="10211" CreationDate="2023-03-27T02:58:46.277" Score="1" ViewCount="84" Body="&lt;p&gt;I'd like some help in understanding and setting up (what may be) an optimization problem that has some similarities to the 0/1 knapsack problem. In this problem the items are a given number of words (analogous to knapsack items) that can go into the given fields of a crossword puzzle (analogous to a knapsack). A word can fit into a field if their lengths match. The constraints are, as usual, that the letters where any two fields intersect must be the same letter. The goal is to fill the fields with as many words as possible from the given set of words. In general, some fields may ultimately be left unfilled--eg, if there are no words remaining that meet all intersecting field constraints.&lt;/p&gt;&#xA;&lt;p&gt;At first I thought this could be approached as an optimization problem like the 0/1 knapsack. The initial fields might be filled longest first (analogous to an efficient knapsack solution). But the progressive selection of words is not filling an undifferentiated space like a knapsack. Rather each next selected word must exactly fit into one of the remaining fields. I can't tell if this lends itself to an optimization algorithm, or requires falling back to brute search through all possibilities. What could be a good objective function to maximize? Maximizing the number of filled fields or the number of selected words is a possibility, but can this kind of optimization be used to kill a lot of nodes in the search tree like it does for the knapsack problem?&lt;/p&gt;&#xA;&lt;p&gt;I can solve the standard knapsack problem with a branch &amp;amp; bound algorithm that relaxes the item weights when progressively filling, but not sure if something like this would work for this crossword problem.&lt;/p&gt;&#xA;&lt;p&gt;PS: For those who haven't studied the 0/1 knapsack, here is a short video that (purports) to explain some of the key considerations&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=yV1d-b_NeK8&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=yV1d-b_NeK8&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Here's an example problem, with the best solution (as suggested by A.Omidi):&lt;/p&gt;&#xA;&lt;p&gt;Wordset = (squid sound swiss pique roses best suns weds psst nod ssw)&lt;/p&gt;&#xA;&lt;p&gt;Fieldset = (1across 5across 6across 7across 8across&#xA;1down 2down 3down 4down 6down)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@PSST&#xA;@IOW&#xA;SQUID&#xA;SUNS@&#xA;WEDS@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Best solution found by brute force search through all possibe field/word pairs:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;FILL (6DOWN SSW) NIL 6.0 8 0.0&#xA;  ((FILLED 1ACROSS) (FILLED 1DOWN) (FILLED 2DOWN) (FILLED 3DOWN) (FILLED 6ACROSS) (FILLED 6DOWN) (FILLED 7ACROSS) (FILLED 8ACROSS)&#xA;   (REMAINING-FIELDS&amp;amp;WORDS-HT #&amp;lt;HASH-TABLE :TEST EQUAL :COUNT 2 {258ED8D1}&amp;gt;) (TEXT 1ACROSS &amp;quot;PSST&amp;quot;) (TEXT 1DOWN &amp;quot;PIQUE&amp;quot;)&#xA;   (TEXT 2DOWN &amp;quot;SOUND&amp;quot;) (TEXT 3DOWN &amp;quot;SWISS&amp;quot;) (TEXT 4DOWN &amp;quot;T?D&amp;quot;) (TEXT 5ACROSS &amp;quot;IOW?&amp;quot;) (TEXT 6ACROSS &amp;quot;SQUID&amp;quot;) (TEXT 6DOWN &amp;quot;SSW&amp;quot;)&#xA;   (TEXT 7ACROSS &amp;quot;SUNS&amp;quot;) (TEXT 8ACROSS &amp;quot;WEDS&amp;quot;) (USED-FIELD-IDS-HT #&amp;lt;HASH-TABLE :TEST EQ :COUNT 8 {258ED3E9}&amp;gt;))&#xA;  NIL&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My main question is whether choosing an appropriate objective function (eg, maximizing the number of words filled in) will actually prune the search tree. My intuition is that, contrary to knapsack pruning, it will not significantly prune the tree. (But I haven't programmed it; fair amount of work just to test.)&lt;/p&gt;&#xA;" OwnerUserId="11527" LastEditorUserId="11527" LastEditDate="2023-03-28T04:35:55.000" LastActivityDate="2023-03-28T04:35:55.000" Title="How to Set Up an Optimization Problem Like the 0/1 Knapsack" Tags="|optimization|branch-and-bound|knapsack|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10210" PostTypeId="1" AcceptedAnswerId="10215" CreationDate="2023-03-27T13:59:49.200" Score="0" ViewCount="46" Body="&lt;p&gt;I am trying to model a job-shop scenario where - given a certain number of workers (W) and parts (P) such that P&amp;gt;W  - each worker spends each shift (k) working on a specific part. Due to reasons of maintaining efficient workflows, it is preferred that a worker keeps working on that same part for the entire week (i.e. all 5 shifts in a week). At the outset, it doesn't matter which part they start on, but once they are scheduled for a part it is preferred they stick to it. I have thought to model it in the following way.&lt;/p&gt;&#xA;&lt;p&gt;My question is: does this makes sense or if there are any negative consequences to this method of modelling? One thing I do not like is there ends up being many &lt;span class=&quot;math-container&quot;&gt;$\delta_{w,p}$&lt;/span&gt; constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Z_{w,p,k} \in \lbrace 0,1 \rbrace$&lt;/span&gt; = Worker W making part P on shift K&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\delta_{w,p} \in \lbrace 0,1 \rbrace \ge Z_{w,p,k}$&lt;/span&gt; for  each k (to check if a worker is working on that part that modelling period or not)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\delta_{w} = \sum \delta_{w,p} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And then either minimizing the sum of all &lt;span class=&quot;math-container&quot;&gt;$\delta_{w}$&lt;/span&gt; or constraining their maximum.&lt;/p&gt;&#xA;" OwnerUserId="10872" LastEditorUserId="67" LastEditDate="2023-03-27T15:25:51.267" LastActivityDate="2023-03-27T23:18:22.873" Title="Maintaining Pair Preference that is neutral at outset" Tags="|mixed-integer-programming|integer-programming|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10211" PostTypeId="2" ParentId="10207" CreationDate="2023-03-27T15:19:50.093" Score="1" Body="&lt;p&gt;You can certainly model this as a binary integer program. The constraints are very straightforward, and either filling the maximum number of fields or (equivalently) maximizing the number of words used makes sense to me. Whether it would solve efficiently is an empirical question.&lt;/p&gt;&#xA;&lt;p&gt;It could also be modeled as a constraint programming problem. The number of variables would be smaller. Where an IP model would use a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; to indicate whether word &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; gets stuffed into field &lt;span class=&quot;math-container&quot;&gt;$j,$&lt;/span&gt; a CP model might use an integer variable &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; with domain &lt;span class=&quot;math-container&quot;&gt;$0,\dots,W$&lt;/span&gt; (where &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is the number of words) to select the word that goes into field &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$y_j=0$&lt;/span&gt; indicating the field is left empty). Alternatively, you might use a variable &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; with domain &lt;span class=&quot;math-container&quot;&gt;$0,\dots,F$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; the number of fields) to indicate the field into which word &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; gets stuffed (again using &lt;span class=&quot;math-container&quot;&gt;$z_i=0$&lt;/span&gt; to indicate the word is unused). In fact, you might very well include both sets of variables, together with compatibility constraints (word &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; going into field &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; implies word &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; cannot go into field &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; because the fields intersect in what would be different letters for the two words). A CP approach avoids a bunch of matrix arithmetic and does domain reductions more directly (if I put word &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in field &lt;span class=&quot;math-container&quot;&gt;$j,$&lt;/span&gt; then it cannot be used anywhere else and these other words no longer can be used in these intersecting fields).&lt;/p&gt;&#xA;&lt;p&gt;In my very limited experience with CP, one drawback relative to IP models tends to be weaker objective bounding with CP. I'm not sure that would be a big issue with this particular problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-27T15:19:50.093" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10213" PostTypeId="2" ParentId="10210" CreationDate="2023-03-27T16:13:00.500" Score="0" Body="&lt;p&gt;I'd model it as &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ K_p z_{w,p}^k - \sum_{t=1}^{k-1} z_{w,p}^t \le \sum_{t=k+1}^{K_p} z_{w,p}^t \ \quad \forall w,p \quad \forall k$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$ K_p$&lt;/span&gt; is total number of shifts generally required to complete part &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, should be a parameter.&lt;/p&gt;&#xA;&lt;p&gt;Edit:&#xA;Your constraint &lt;span class=&quot;math-container&quot;&gt;$z_{w,p}^k \le \delta_{w,p}$&lt;/span&gt; is equivalent to &lt;span class=&quot;math-container&quot;&gt;$ \sum_k z_{w,p}^k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So you either minimize&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_w \sum_p \sum_k z_{w,p}^k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_w \sum_k z_{w,p}^k \le \delta_p$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then &lt;span class=&quot;math-container&quot;&gt;$min \sum_p \delta_p$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-27T23:18:22.873" LastActivityDate="2023-03-27T23:18:22.873" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10214" PostTypeId="1" AcceptedAnswerId="10221" CreationDate="2023-03-27T18:34:05.370" Score="1" ViewCount="638" Body="&lt;p&gt;I am trying to implement a scheduling problem to solve with CP-SAT from OR-tools. There, in particular, for every machine I want to add a time transition constraint from every task that  is performed on that machine to whatever its successor task is on the machine. For that, I found out I need to use a circuit constraint. This of course makes sense: we can construct a graph whose nodes are the tasks that can be performed on that machine (together with an additional dummy node to separate the start from end) and, once we have a Hamiltonian circuit there, the transition constraints can be defined since we know the successor of every task.&lt;/p&gt;&#xA;&lt;p&gt;My problem lies on the fact that some of the tasks can be active on that machine or not. In my context, the task is identified by an OptionalInterval object, and thus I want to find the Hamiltonian circuit only over the complete subgraph whose nodes are those associated to tasks with active OptionalInterval. &lt;strong&gt;How can I accomplish this?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I checked the example provided &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/contrib/scheduling_with_transitions_sat.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and I even closely followed the implementation but there only one task per job is considered and as soon as I add a task to a job the code breaks. Moreover, I know that I should use the AddCircuit method from cp-sat (python), but is unclear to me exactly what this constraint does. &lt;strong&gt;Could you please clarify?&lt;/strong&gt; In the Python documentation of the function AddCircuit it is mentioned that&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Adds Circuit(arcs).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Adds a circuit constraint from a sparse list of arcs that encode the graph.&#xA;&#xA;A circuit is a unique Hamiltonian path in a subgraph of the total&#xA;graph. In case a node 'i' is not in the path, then there must be a&#xA;loop arc 'i -&amp;gt; i' associated with a true literal. Otherwise&#xA;this constraint will fail.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;However, with that info it is unclear to me over which subgraph precisely is the circuit being considered. &lt;strong&gt;How is this subgraph defined?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I managed to get a minimal working example that turns out to be infeasible but should be feasible according to my understanding of the topic. There, I define a complete graph of 3 nodes, but one of the nodes (node 2) will not be active. I thus want to find a Hamiltonian circuit over the nodes 0 and 1, but apparently it doesn't exist.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = cp_model.CpModel()&#xA;&#xA;bool_node_active = {&#xA;    0: model.NewBoolVar(&amp;quot;Is node 0 active&amp;quot;),&#xA;    1: model.NewBoolVar(&amp;quot;Is node 1 active&amp;quot;),&#xA;    2: model.NewBoolVar(&amp;quot;Is node 2 active&amp;quot;)&#xA;}&#xA;&#xA;model.Add(bool_node_active[2] == 0)&#xA;&#xA;bool_arcs = {(i, j): model.NewBoolVar(&amp;quot;&amp;quot;) for i in range(3) for j in range(3)}&#xA;&#xA;arcs = [&#xA;    [i, j, bool_arcs[i, j]] for i in range(3) for j in range(3)&#xA;]&#xA;for i in range(3):&#xA;    for j in range(3):&#xA;        model.AddImplication(bool_arcs[i, j], bool_node_active[i])&#xA;        model.AddImplication(bool_arcs[i, j], bool_node_active[j])&#xA;        &#xA;&#xA;model.AddCircuit(arcs)&#xA;&#xA;# Solve model.&#xA;solver = cp_model.CpSolver()&#xA;&#xA;solution_printer = SolutionPrinter()&#xA;status = solver.Solve(model, solution_printer)&#xA;&#xA;# Print Solution               &#xA;print('Solve status: %s' % solver.StatusName(status))    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Could you please fix the example above?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="11164" LastActivityDate="2023-03-29T06:31:31.320" Title="About circuit constraints in OR - tools" Tags="|scheduling|constraint-programming|or-tools|cp-sat|hamiltonian-path|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10215" PostTypeId="2" ParentId="10210" CreationDate="2023-03-27T21:01:54.147" Score="1" Body="&lt;p&gt;Your approach seems appropriate to me, although I would change the &lt;span class=&quot;math-container&quot;&gt;$\delta_w$&lt;/span&gt; variables to &lt;span class=&quot;math-container&quot;&gt;$\delta_p = \sum_w \delta_{w,p}$&lt;/span&gt; and then minimize the largest value by minimizing a new variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$z\ge \delta_p$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$p.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-27T21:01:54.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10216" PostTypeId="2" ParentId="10210" CreationDate="2023-03-27T22:03:02.680" Score="1" Body="&lt;p&gt;More than it has been a job shop problem, it sounds like an assembly/fabrication sequencing problem. You can formulate this as of a variant of the bin packing problem with additional constraints to capture what you want. The objective is to minimize the number of workers that are being assigned to perform parts. Also, you can already define a specific order of jobs in which can be performed simultaneously by a specific worker to balance the workload of each worker. As an attempt, I tried with the following assumption and the results would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;parts= {(part1-1, part1-2, part1-3), (part2-1, part2-2, part2-3), (part3-1, part3-2, part3-3)};&#xA;workers = {worker1, ..., worker9};&#xA;processing time= {&#xA;part1-1 03&#xA;part1-2 02&#xA;part1-3 02&#xA;part2-1 05&#xA;part2-2 01&#xA;part2-3 02&#xA;part3-1 02&#xA;part3-2 2.5&#xA;part3-3 3.5&#xA;};&#xA;shift = {8}; # a normal 8hrs shift&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Result with determining an order of parts to perform simultaneously:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;            worker1     worker2     worker3&#xA;&#xA;part1-1                   1.000&#xA;part1-2                   1.000&#xA;part1-3                   1.000&#xA;part2-1                               1.000&#xA;part2-2                               1.000&#xA;part2-3                               1.000&#xA;part3-1       1.000&#xA;part3-2       1.000&#xA;part3-3       1.000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Result with an arbitrary performing order of jobs:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;            worker1     worker2     worker3&#xA;&#xA;part1-1                               1.000&#xA;part1-2       1.000&#xA;part1-3       1.000&#xA;part2-1                               1.000&#xA;part2-2       1.000&#xA;part2-3       1.000&#xA;part3-1                   1.000&#xA;part3-2                   1.000&#xA;part3-3                   1.000&#xA;&#xA;&#xA; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-03-27T22:03:02.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10217" PostTypeId="1" AcceptedAnswerId="10222" CreationDate="2023-03-28T00:20:56.547" Score="5" ViewCount="390" Body="&lt;p&gt;I am looking for a list of solution methodologies that solves a discrete optimization problem, except that the objective function evaluated at any feasible point can only be obtained by performing a simulation. In other words, for any &lt;span class=&quot;math-container&quot;&gt;$(\bar{x}, \bar{y})$&lt;/span&gt; that satisfies constraints \eqref{1}-\eqref{3}, we can only obtain &lt;span class=&quot;math-container&quot;&gt;$F(\bar{x}, \bar{y})$&lt;/span&gt; by performing a simulation.  We may assume that &lt;span class=&quot;math-container&quot;&gt;$F(\cdot)$&lt;/span&gt; is a deterministic function bounded over the feasible region, &lt;span class=&quot;math-container&quot;&gt;$X, Y$&lt;/span&gt; are convex sets.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\underset{x \in \lbrace{0,1 \rbrace}^n, y \in \mathbb{R}^m }{\mathrm{min}}&amp;amp; \quad F(x, y)\\&#xA;\text{s.t.}&amp;amp; \quad Ax + By \leq c \tag1\label1\\ &#xA;&amp;amp; \quad x \in X \tag2\label2\\&#xA;&amp;amp; \quad y \in Y \tag3\label3\\  &#xA;\end{align}&lt;/span&gt;&#xA;I am looking to get an awareness to the different solution methodologies designed for such problems. Some papers that I thought could be useful to this problem are:&lt;/p&gt;&#xA;&lt;p&gt;[1] &amp;quot;Combining Optimization and Simulation Using Logic Based Benders&#xA;Decomposition&amp;quot;,  Forbes et al.&lt;/p&gt;&#xA;&lt;p&gt;[2] &amp;quot;Optimizing over an Ensemble of Trained Neural Networks&amp;quot;, Wang et al.&lt;/p&gt;&#xA;&lt;p&gt;It would be great if people will be kind enough to comment with a brief description of why the paper may be useful. For example, I think [2] can be relevant, if we are somehow able to build a surrogate function for the optimization objective in terms of a Neural network (NN) with ReLu activations.&lt;/p&gt;&#xA;" OwnerUserId="972" LastEditorUserId="972" LastEditDate="2023-03-28T00:34:07.257" LastActivityDate="2023-03-28T11:30:24.330" Title="Discrete optimization for a simulation objective" Tags="|untagged|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10218" PostTypeId="1" AcceptedAnswerId="10219" CreationDate="2023-03-28T00:26:54.197" Score="2" ViewCount="197" Body="&lt;p&gt;I am trying to design an algorithm to label a graph’s nodes with as few colors as possible&#xA;such that all pairs of nodes joined by an edge do not have the same color.&lt;/p&gt;&#xA;&lt;p&gt;This is the code I have written so far. I have added the variables x[0] to x[n-1] for the graph's nodes. I do not understand how to add the constraint that for each set of connected nodes (0 and 1; 1 and 2; and 1 and 3) the colors may not be equal. Subject to these constraints the goal is to find the minimize the maximum c_i (the color of a node) where all colors are nonnegative integers. You cannot directly add an inequality constraint in Gurobi or a Boolean constraint that if nodes i and j are connected then c_i &amp;lt;= c_j - 1 or c_i &amp;gt;= c_j + 1. Can anyone suggest an approach to do this?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from gurobipy import Model, GRB, quicksum&#xA;&#xA;n = 4 &#xA;N = [i for i in range(n)]&#xA;&#xA;edges = [[1], [2, 3], [], []] #node 0 is connected to node 1; and 1 is connected to 2 and 3 &#xA;&#xA;mdl = Model('CVRP') &#xA;&#xA;x = mdl.addVars(N, vtype=GRB.INTEGER) #x (node color) is a nonnegative integer &#xA;&#xA;mdl.modelSense = GRB.MINIMIZE &#xA; &#xA;mdl.addConstrs(x[i] &amp;gt;= 0 for i in range(n))  &#xA; &#xA;mdl.optimize()&#xA;mdl.display()  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11516" LastEditorUserId="500" LastEditDate="2023-03-28T02:29:13.167" LastActivityDate="2023-03-28T02:31:12.627" Title="Smallest graph coloring in Gurobi" Tags="|optimization|gurobi|graphs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10219" PostTypeId="2" ParentId="10218" CreationDate="2023-03-28T01:43:53.207" Score="3" Body="&lt;p&gt;With that choice of variables, you can use a constraint programming solver, together with, for each edge, either a &lt;em&gt;disequality&lt;/em&gt; or an &lt;em&gt;alldiff&lt;/em&gt; constraint to enforce a proper coloring.&lt;/p&gt;&#xA;&lt;p&gt;The usual integer linear programming approach for graph coloring is to instead use binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{ic}$&lt;/span&gt; to indicate whether node &lt;span class=&quot;math-container&quot;&gt;$i\in N$&lt;/span&gt; is assigned color &lt;span class=&quot;math-container&quot;&gt;$c\in C$&lt;/span&gt; and binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_c$&lt;/span&gt; to indicate whether color &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is ever used.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{c\in C} y_c$&lt;/span&gt; subject to linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{c\in C} x_{ic} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for $i\in N$} \tag1\label1 \\&#xA;x_{ic} + x_{jc} &amp;amp;\le y_c &amp;amp;&amp;amp;\text{for $(i,j)\in E$ and $c\in C$} \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} assigns exactly one color to each node.&#xA;Constraint \eqref{2} prevents assigning &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; the same color &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; is an edge, and it also enforces the logical implication &lt;span class=&quot;math-container&quot;&gt;$(x_{ic} \lor x_{jc}) \implies y_c$&lt;/span&gt; to properly record that color &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is used.  You could also impose &lt;span class=&quot;math-container&quot;&gt;$x_{ic} \le y_c$&lt;/span&gt; to handle any isolated nodes, but you might as well just preprocess any such nodes away by fixing &lt;span class=&quot;math-container&quot;&gt;$x_{i1}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can take &lt;span class=&quot;math-container&quot;&gt;$C=\{1,\dots,|N|\}$&lt;/span&gt; or, more generally, &lt;span class=&quot;math-container&quot;&gt;$C=\{1,\dots,u\}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$u\le |N|$&lt;/span&gt; is an upper bound on the number of colors needed.  Such an upper bound can be obtained by any proper (perhaps greedy) coloring.&lt;/p&gt;&#xA;&lt;p&gt;The problem is symmetric with respect to &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, and an application of Dantzig-Wolfe decomposition with one block per &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; leads to a set partitioning master problem with identical blocks, which can be solved via column generation with Ryan-Foster branching.  This approach is &lt;a href=&quot;https://go.documentation.sas.com/doc/en/pgmsascdc/v_037/casmopt/casmopt_decomp_details06.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;automated in SAS&lt;/a&gt;, or you can implement a specialized algorithm as in &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoc.8.4.344&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mehrotra and Trick (1996)&lt;/a&gt;.  Relaxing \eqref{1} to &lt;span class=&quot;math-container&quot;&gt;$\ge 1$&lt;/span&gt; can sometimes improve the performance of this approach.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-28T02:31:12.627" LastActivityDate="2023-03-28T02:31:12.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10220" PostTypeId="2" ParentId="10217" CreationDate="2023-03-28T02:56:52.503" Score="4" Body="&lt;p&gt;A &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S1569190X07001256&quot; rel=&quot;nofollow noreferrer&quot;&gt;2008 paper&lt;/a&gt; by Jack Kleijnen discusses a version of response surface methodology for optimization of one (response) variable in a simulation given constraints on other variables in the simulation. Response surface methodology involves estimating (via interpolation, regression estimation or something similar) the functional relationship between the response variable and the controllable variables (i.e., estimating your &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt;). I don't recall what sorts of constraints Kleijnen discussed, but he does say in the introduction that his focus is on simulation models that are expensive to run.&lt;/p&gt;&#xA;&lt;p&gt;Full reference: Jack P.C. Kleijnen, &amp;quot;Response surface methodology for constrained simulation optimization: An overview&amp;quot;, &lt;em&gt;Simulation Modelling Practice and Theory&lt;/em&gt;, Volume 16, Issue 1, 2008, pp. 50-64. ISSN 1569-190X,&#xA;&lt;a href=&quot;https://doi.org/10.1016/j.simpat.2007.10.001&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.simpat.2007.10.001&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-28T02:56:52.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10221" PostTypeId="2" ParentId="10214" CreationDate="2023-03-28T08:02:51.547" Score="4" Body="&lt;p&gt;The graph is defined by the arcs you pass.&#xA;An arc is &lt;code&gt;(start node, end node, literal)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the &lt;code&gt;literal&lt;/code&gt; is true, the arc is selected.&lt;/p&gt;&#xA;&lt;p&gt;The constraint enforces that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;there is only one circuit of size &amp;gt; 1&lt;/li&gt;&#xA;&lt;li&gt;every node has 1 incoming arc and 1 outgoing arc&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In other words, the constraint is circuit or sub-circuit in the CP literature.&lt;/p&gt;&#xA;&lt;p&gt;To deal with optional nodes, one must add a self loop on the node.&#xA;For instance, if node &lt;code&gt;k&lt;/code&gt; is optional, and active only if literal &lt;code&gt;lit&lt;/code&gt; is true, then the arc &lt;code&gt;(k, k, lit.Not())&lt;/code&gt; must be added to the constraint&lt;/p&gt;&#xA;&lt;p&gt;Finally, in the scheduling example, one must deal with the case where the resource is empty (no tasks). So the case of the dummy node &lt;code&gt;0&lt;/code&gt; must me treaded.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a literal 'empty' must be created: &lt;code&gt;empty = model.NewBoolVar('empty')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;a self loop on 0 must created: &lt;code&gt;arc.append(0, 0, empty)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;if empty is true, all nodes are unperformed: &lt;code&gt;for all node n, model.AddImplication(empty, performed(n).Not())&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2023-03-29T06:31:31.320" LastActivityDate="2023-03-29T06:31:31.320" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10222" PostTypeId="2" ParentId="10217" CreationDate="2023-03-28T08:48:43.477" Score="4" Body="&lt;p&gt;&lt;em&gt;Optimization via Simulation&lt;/em&gt; (or &lt;em&gt;Surrogated Optimization&lt;/em&gt; or &lt;em&gt;Simulation-based optimization&lt;/em&gt;) is an umbrella term for all optimization algorithms that rely on a simulation to evaluate objective functions and/or constraints. It includes direct usage of simulation (like the &lt;a href=&quot;https://doi.org/10.1016/j.simpat.2007.10.001&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kleinen's paper suggested by Prubin&lt;/a&gt;), indirect use of simulation (like it is explained in &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S1569190X21001040&quot; rel=&quot;nofollow noreferrer&quot;&gt;this review&lt;/a&gt;) and hybrid schemas (like &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S221471601830068X&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;A good approach to solve those kinds of problems is to use metaheuristics in an &lt;em&gt;Optimization via Simulation&lt;/em&gt; scheme (as an example, see &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0167923618301015&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Regarding discrete optimization problem, here is a &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S036083521830682X&quot; rel=&quot;nofollow noreferrer&quot;&gt;good review&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastEditorUserId="10165" LastEditDate="2023-03-28T11:30:24.330" LastActivityDate="2023-03-28T11:30:24.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10223" PostTypeId="2" ParentId="10007" CreationDate="2023-03-29T09:00:26.247" Score="1" Body="&lt;p&gt;If you know some Python and web languages, check this &lt;a href=&quot;https://www.danielpradilla.info/blog/linear-optimization-with-or-tools-building-a-web-front-end-with-falcon-and-gunicorn/&quot; rel=&quot;nofollow noreferrer&quot;&gt;post&lt;/a&gt;. It is not exactly what you want but, with some effort, it could be adapted to your requirements.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2023-03-29T09:00:26.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10225" PostTypeId="1" AcceptedAnswerId="10226" CreationDate="2023-03-29T21:28:46.897" Score="3" ViewCount="157" Body="&lt;p&gt;I am dealing with the following problem as follows.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i,j}( x_{i}+y_{j}+q_{ij}+w_{i})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{s.t.} x_{i}+y_{j}+q_{ij}+w_{i} \geq b_{ij}, \forall i,j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to handle this problem more efficiently??&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; All variables are continuous.&lt;/p&gt;&#xA;" OwnerDisplayName="user5245" LastEditorDisplayName="user5245" LastEditDate="2023-03-31T05:29:52.850" LastActivityDate="2023-03-31T05:29:52.850" Title="About Mathematical Programs" Tags="|optimization|benders-decomposition|decomposition|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10226" PostTypeId="2" ParentId="10225" CreationDate="2023-03-29T22:14:13.987" Score="2" Body="&lt;p&gt;Your first subproblem is not separable, but your second subproblem is. You can split the second subproblem into one LP for each value of &lt;span class=&quot;math-container&quot;&gt;$i,$&lt;/span&gt; since there are no variables with subscript &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; that do not also have subscript &lt;span class=&quot;math-container&quot;&gt;$i.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;On the subject of stronger cuts, you may already be aware of it, but there is a stream of research, starting with a paper by Magnanti and Wong in 1981, on generating stronger Benders cuts. You might find a paper by Sherali and Lunday [1] interesting.&lt;/p&gt;&#xA;&lt;p&gt;[1] Sherali, H.D., Lunday, B.J. On generating maximal nondominated Benders cuts. Ann Oper Res 210, 57–72 (2013). &lt;a href=&quot;https://doi.org/10.1007/s10479-011-0883-6&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1007/s10479-011-0883-6&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-03-29T22:14:13.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10227" PostTypeId="1" AcceptedAnswerId="10230" CreationDate="2023-03-30T01:06:16.417" Score="0" ViewCount="122" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;A restaurant has a total of 16 tables, each of which can seat a maximum of 4 people. If 50 people were sitting at the tables in the restaurant, with no tables empty, what is the greatest possible number of tables that could be occupied by just 1 person?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I believe the integer programming conditions are the following, but I don't know a solver to execute this. How to solve by hand or via a computer?&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Maximize: x*z1&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Subject to:&#xA;z1 + z2 = 1 (either x or y must be included in the solution)&#xA;x + y = 16&#xA;x + 4y = 50&#xA;&lt;span class=&quot;math-container&quot;&gt;$x,y \in \mathbb{N}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11548" LastActivityDate="2023-03-30T13:08:11.450" Title="What is the greatest possible number of tables that could be occupied by just 1 person?" Tags="|integer-programming|solver|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10228" PostTypeId="2" ParentId="10227" CreationDate="2023-03-30T01:40:37.110" Score="0" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{i, j}\in\{0, 1\}$&lt;/span&gt; represent whether there are &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; people at table &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$i=1, \dots, 16$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j=1, \dots, 4$&lt;/span&gt;. The model is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{split}&#xA;\max &amp;amp;\sum_i x_{i, 1}\\&#xA;\mathrm{s.t.} &amp;amp;\sum_{i, j} j x_{i, j} = 50&#xA;\end{split}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The optimal value I believe is 4.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2023-03-30T01:40:37.110" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10229" PostTypeId="2" ParentId="10227" CreationDate="2023-03-30T01:49:00.547" Score="3" Body="&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,2,3,4\}$&lt;/span&gt;, let nonnegative integer decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; be the number of tables occupied by exactly &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; people.  The problem is to maximize &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; subject to linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_1 + x_2 + x_3 + x_4 &amp;amp;= 16 \tag1\label1 \\&#xA;1 x_1 + 2 x_2 + 3 x_3 + 4 x_4 &amp;amp;= 50  \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;The linear programming relaxation yields optimal solution &lt;span class=&quot;math-container&quot;&gt;$x^*=(14/3,0,0,34/3)$&lt;/span&gt;, and the LP dual solution &lt;span class=&quot;math-container&quot;&gt;$(4/3,-1/3)$&lt;/span&gt; certifies optimality:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_1 &amp;amp;\le x_1 + \frac{2}{3}x_2 + \frac{1}{3}x_3 \\&#xA;&amp;amp;= \frac{4}{3}(x_1 + x_2 + x_3 + x_4)&#xA;-\frac{1}{3}(1 x_1 + 2 x_2 + 3 x_3 + 4 x_4) \\&#xA;&amp;amp;= \frac{4}{3}\cdot16-\frac{1}{3}\cdot50 \\&#xA;&amp;amp;= \frac{14}{3}&#xA;\end{align}&lt;/span&gt;&#xA;So the ILP has optimal objective value at most &lt;span class=&quot;math-container&quot;&gt;$\lfloor 14/3 \rfloor = 4$&lt;/span&gt;.  Now find such a solution &lt;span class=&quot;math-container&quot;&gt;$x=(4,\underline{},\underline{},\underline{})$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Note that the optimal LP solution can reasonably be obtained by inspection by arguing that &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; will be maximized when &lt;span class=&quot;math-container&quot;&gt;$x_2=x_3=0$&lt;/span&gt;, which reduces \eqref{1} and \eqref{2} to two equations and two unknowns.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;An alternative approach skips the LP solve and instead uses “probing” to deduce the upper bound of &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;. Suppose there are at least five tables with exactly one person (&lt;span class=&quot;math-container&quot;&gt;$x_1\ge5$&lt;/span&gt;). Then we must distribute the remaining &lt;span class=&quot;math-container&quot;&gt;$50-5=45$&lt;/span&gt; people among the remaining &lt;span class=&quot;math-container&quot;&gt;$16-5=11$&lt;/span&gt; tables that together have capacity &lt;span class=&quot;math-container&quot;&gt;$44&amp;lt;45$&lt;/span&gt;, but that is impossible.  So &lt;span class=&quot;math-container&quot;&gt;$x_1 \le 4$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-30T13:08:11.450" LastActivityDate="2023-03-30T13:08:11.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10230" PostTypeId="2" ParentId="10227" CreationDate="2023-03-30T03:58:23.720" Score="-1" Body="&lt;p&gt;What about LCM? &lt;span class=&quot;math-container&quot;&gt;$2,3,4$&lt;/span&gt; has lowest common multiple of &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt;. So max &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; tables can fit &lt;span class=&quot;math-container&quot;&gt;$2,3,4$&lt;/span&gt; people. Remaining is &lt;span class=&quot;math-container&quot;&gt;$16-12=4$&lt;/span&gt; tables for &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; person&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-03-30T04:03:25.933" LastActivityDate="2023-03-30T04:03:25.933" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10231" PostTypeId="2" ParentId="10227" CreationDate="2023-03-30T12:40:09.560" Score="0" Body="&lt;p&gt;No tables are empty, meaning all 16 tables must have at least one person sitting at them.&#xA;Minimize the number of tables with more than one person by distributing the remaining 34 people (50 - 16 = 34) among the tables that already have 1 person.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We can put 3 people at each table to reach its maximum capacity of 4. Doing this for 11 tables will accommodate 11 * 3 = 33 people.&lt;/li&gt;&#xA;&lt;li&gt;We still have 1 person left, so we can add them to the 12th table, which now has 2 people.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Now, we have:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;11 tables with 4 people each (44 people)&lt;/li&gt;&#xA;&lt;li&gt;1 table with 2 people (2 people)&lt;/li&gt;&#xA;&lt;li&gt;4 tables with 1 person each (4 people)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Thus, the greatest possible number of tables that could be occupied by just 1 person is 4.&lt;/p&gt;&#xA;" OwnerUserId="10056" LastActivityDate="2023-03-30T12:40:09.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10232" PostTypeId="1" CreationDate="2023-03-30T14:33:49.403" Score="0" ViewCount="71" Body="&lt;p&gt;I have an optimisation problem to solve but I can't model it correctly. Any insight is welcome :)&lt;/p&gt;&#xA;&lt;p&gt;It has been a few years since my optimisation classes in university, and while I have forgotten a lot of tricks, I remember some others.&lt;/p&gt;&#xA;&lt;h2&gt;The Problem:&lt;/h2&gt;&#xA;&lt;p&gt;I have a set of resources and each resource has a set of associated &lt;em&gt;availabilities&lt;/em&gt; (times during which they are available).&lt;/p&gt;&#xA;&lt;p&gt;Domain constraints:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The value of a resource may vary over time (values are non-negative and constant over a certain time interval).&lt;/li&gt;&#xA;&lt;li&gt;Bookings may not overlap except for start/end time-point (in case a booking &lt;span class=&quot;math-container&quot;&gt;$p_1=[p^s_1,p^e_1]$&lt;/span&gt; and a booking &lt;span class=&quot;math-container&quot;&gt;$p_2=[p^s_2,p^e_2]$&lt;/span&gt; are on the same resource and &lt;span class=&quot;math-container&quot;&gt;$e_1=b_2$&lt;/span&gt;, they will be combined&#xA;into a single booking &lt;span class=&quot;math-container&quot;&gt;$p'_1=[p^s_1,p^e_2]$&lt;/span&gt; in a post-processing step, but there can never be 2 bookings &lt;span class=&quot;math-container&quot;&gt;$p_1, p_2$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$p^s_1 &amp;lt; p^s_2 &amp;lt; p^e_1$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;li&gt;A booking may not be shorter than a fixed threshold.&lt;/li&gt;&#xA;&lt;li&gt;I have a maximum time budget to use over all bookings.&lt;/li&gt;&#xA;&lt;li&gt;A booking can only cover a single resource.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I want to book time on the resources in a way as to optimise the total value.&#xA;I am aware that this has to be transformed into an equivalent minimisation function for most solvers, but that is easy.&lt;/p&gt;&#xA;&lt;p&gt;We can assume that the time interval we optimise over always starts with an availability.&lt;/p&gt;&#xA;&lt;h2&gt;Example:&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/g9LVT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/g9LVT.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The following chart shows the value per hour of each segment in brackets (e.g. for segment v2,1, the value of selecting the complete segment would be 5, since the segment is only 30 minutes long, but we are not interested in selecting segments but time intervals, so showing the value per hour seems to make more sense).&lt;/p&gt;&#xA;&lt;p&gt;Let the &amp;quot;minimum time per booking&amp;quot; (3) be 1h, the &amp;quot;maximum total booking time&amp;quot;(4) be 4h and the availability values as displayed below,&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0Erq9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0Erq9.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;then the section values above lead to the optimum selection (in red) below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tgWl4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tgWl4.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In addition to the 3 red bookings above which are clearly optimal (selecting v2,1 and a portion of v2,2 instead of book2 would only), result in a total value of 10/2 + 5/2 = 7.5 instead of 9 for selecting v3,2; also note the &amp;quot;no overlap&amp;quot; constraint (2) which prevents us from selecting both v2,1 and v3,2), and we are free to choose a forth booking of 1h length in either section v1,2 or v2,2 or to extend book1 by 1 hour to obtain an optimal solution.&lt;/p&gt;&#xA;&lt;h2&gt;My attempts so far:&lt;/h2&gt;&#xA;&lt;p&gt;I do not know in advance how many bookings are required for an optimal solution, but we can easily determine an upper limit by dividing the maximum booking time (4) by the minimum booking duration (3): &lt;span class=&quot;math-container&quot;&gt;$n^b$&lt;/span&gt; = floor(max_booking_time / min time per booking); so in our example &lt;span class=&quot;math-container&quot;&gt;$n_b = 4$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I chose to model a booking &amp;quot;i&amp;quot; through 2 variables &lt;span class=&quot;math-container&quot;&gt;$p^s_i$&lt;/span&gt; (booking i start) and &lt;span class=&quot;math-container&quot;&gt;$p^s_i$&lt;/span&gt; (booking i end) which are bounded by &lt;span class=&quot;math-container&quot;&gt;$[0, \max_{j=1..n_a}{v^e_j}]$&lt;/span&gt; which would be &lt;span class=&quot;math-container&quot;&gt;$0 \leq p^s_i, p^e_i \leq 12$&lt;/span&gt; in our example.&#xA;This leads to the following set of model constraints:&lt;/p&gt;&#xA;&lt;p&gt;(A1) &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{nb} p^e_i - p^s_i \leq \text{max_booking_time}$&lt;/span&gt; &amp;quot;maximum budget constraint (4)&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;(A2) &lt;span class=&quot;math-container&quot;&gt;$\forall i \in \{1..n^b\}: p^s_i \leq p^s_i$&lt;/span&gt; &amp;quot;start before end constraint&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;(A3) &lt;span class=&quot;math-container&quot;&gt;$\forall i \in \{1..n^b - 1\}: p^e_i \leq p^s_{i+1}$&lt;/span&gt; &amp;quot;no overlap constraint (2)&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;(A4) &lt;span class=&quot;math-container&quot;&gt;$\forall i \in \{1..n^b\}: p^e_i &amp;gt; 0 \Rightarrow p^e_i - p^s_i &amp;gt; 1$&lt;/span&gt; &amp;quot;minimum duration constraint (3)&amp;quot; enabled by (a2) and (A3).&lt;/p&gt;&#xA;&lt;p&gt;In addition, I introduce a set of decision variables &lt;span class=&quot;math-container&quot;&gt;$x^j_i \in \{0, 1\}$&lt;/span&gt; defining which availability &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; a booking &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; belongs to; let &lt;span class=&quot;math-container&quot;&gt;$n_a$&lt;/span&gt; denote the number of availabilities:&lt;/p&gt;&#xA;&lt;p&gt;(E1) &lt;span class=&quot;math-container&quot;&gt;$\forall i \in \{1..n^b\}: \sum_{j=1}^{n_a} x^j_i = 1$&lt;/span&gt; &amp;quot;bookings cannot overlap resources constraint (5)&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;(A5) &lt;span class=&quot;math-container&quot;&gt;$\forall i \in \{1..n^b\} \forall j \in \{1..n^a\}: x_i^j = 1 \Rightarrow p^e_i \leq v^e_j$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$v^e_j$&lt;/span&gt; denotes the end of visibility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(A6)  &lt;span class=&quot;math-container&quot;&gt;$\forall i \in \{1..n^b\} \forall j \in \{1..n^a\}: x_i^j = 1 \Rightarrow v^s_j \leq p^s_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$v^s_j$&lt;/span&gt; denotes the start of visibility &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I believe that the constraints actually reflect my use-case's constraints and as far as I remember, implications can be&#xA;expressed using decision variables.&lt;/p&gt;&#xA;&lt;p&gt;The above said, I have difficulties defining the objective function.&lt;/p&gt;&#xA;&lt;p&gt;One attempt is to use&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max \sum_{i=1}^{n_b} \sum_{j=1}^{n_a} x_i^j (f_j(p^e_i) - f_j(p^s_i))$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f_j(t)$&lt;/span&gt; is a monotonous, continuous function describing the accumulated value of availability &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; up to time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;;&#xA;the multiplication with &lt;span class=&quot;math-container&quot;&gt;$x_i^j$&lt;/span&gt; is necessary to avoid double-scoring for overlapping availabilities&#xA;(e.g. v2,1 and v3,2 in our example).&#xA;In our example, we would define&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;f_2(t) = \begin{cases}&#xA;0 &amp;amp;\text{ for } t \leq 5 \\&#xA;10 (t-5) &amp;amp;\text{ for } 5 \leq t \leq 5.5 \\&#xA;5 + 5 (t-5.5) &amp;amp;\text{ for } 5.5 \leq t \leq 10 \\&#xA;27.5 &amp;amp;\text{ for } 10 \leq t&#xA;\end{cases}&#xA;\end{equation}&lt;/span&gt;&#xA;However, the objective function is definitely not linear and I am not sure how to define &lt;span class=&quot;math-container&quot;&gt;$f_j$&lt;/span&gt; to a (Python) solver.&lt;/p&gt;&#xA;&lt;h2&gt;Question:&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can the objective function above be expressed as a linear function or an equivalent linear objective function be defined ?&lt;/li&gt;&#xA;&lt;li&gt;If not, is there a more elegant way to model the problem, e.g. by modifying/adding constraints but simplifying the objective function ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I thank you all in advance for your insights and help :)&#xA;Edit 1: Corrected (E1) missing &lt;span class=&quot;math-container&quot;&gt;$x^j_i$&lt;/span&gt; variables in sum.&lt;/p&gt;&#xA;" OwnerUserId="11551" LastEditorUserId="11551" LastEditDate="2023-04-04T12:58:33.607" LastActivityDate="2023-04-04T12:58:33.607" Title="Resource selection problem with non-linear objective function" Tags="|mixed-integer-programming|nonlinear-programming|linearization|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10233" PostTypeId="1" CreationDate="2023-03-30T21:55:31.430" Score="1" ViewCount="29" Body="&lt;p&gt;I am trying to understand some journal articles on the vehicle routing problem, specifically &lt;a href=&quot;https://www.researchgate.net/publication/220288626_Vehicle_routing_with_dynamic_travel_times_A_queueing_approach&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vehicle routing with dynamic travel times: A queueing approach&lt;/a&gt; and &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0305054821002550&quot; rel=&quot;nofollow noreferrer&quot;&gt;An M/M/c queue model for vehicle routing problem in multi-door cross-docking environments&lt;/a&gt;, but have a limited background in queueing theory especially when it comes it applications of queueing theory to the vehicle routing problem. Can anyone provide any resources that explain how queueing theory is used to model the vehicle routing problem or give any advice on how to understand the mathematics used in these articles?&lt;/p&gt;&#xA;" OwnerUserId="11516" LastEditorUserId="500" LastEditDate="2023-03-30T22:05:46.300" LastActivityDate="2023-03-30T22:05:46.300" Title="Understanding queueing theory used to model the vehicle routing problem" Tags="|reference-request|vehicle-routing|queuing-theory|stochastic-process|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10234" PostTypeId="1" CreationDate="2023-03-30T22:34:33.527" Score="0" ViewCount="43" Body="&lt;p&gt;I am trying to solve the following problem. The optimization variables are &lt;span class=&quot;math-container&quot;&gt;$x \in R^{+,I}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y \in {R}^{+,I x S}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z \in {R}^{+,J x S}$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$a_{i}, b_{j}, c_{i}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; are parameters and all of them are positive. The constraint of the problem is a power cone with &lt;span class=&quot;math-container&quot;&gt;$\delta&amp;gt;1$&lt;/span&gt;, which can be easily handled with Mosek.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_{x_{i} \geq 0, y_{i,s} \geq 0, z_{j,s} \geq 0} &amp;amp;\sum_{i=1}^{I}\sum_{s=1}^{S} \left(y_{i,s}-a_{i}\right)x_{i} + \sum_{j=1}^{J}\sum_{s=1}^{S}b_{j}z_{j,s} \\&#xA;&amp;amp;\text{s.t} \hspace{5pt} d_{ij}(c_{i}+y_{i,s}) \leq z_{j,s}^{1-\delta} \hspace{5pt} \forall \hspace{5pt}i,j,s&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The problematic terms are the &lt;span class=&quot;math-container&quot;&gt;$y_{i,s}x_{i}$&lt;/span&gt; which are bilinear functions. Are there any ways to either convexify this problem or provide a convex relaxation of this inner product?&lt;/p&gt;&#xA;" OwnerUserId="10612" LastEditorUserId="491" LastEditDate="2023-04-02T14:03:23.473" LastActivityDate="2023-04-02T14:03:23.473" Title="Convex relaxation of an inner product for optimization" Tags="|convex-optimization|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10235" PostTypeId="1" CreationDate="2023-03-30T23:59:45.553" Score="-1" ViewCount="271" Body="&lt;p&gt;Good morning ! I would like to implement this constraint using CP-SAT (see image below).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AHyIg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AHyIg.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;x_i,j is a boolean variable, a and b are given. The problem is that I don't know how to implement the indicator function in a constraint. I tried with int() function but it cannot be applied with a BoundedLinearExpression. Here is my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(20):&#xA;  for j in range(30):&#xA;    x[(i,j)] = model.NewBoolVar('variable%ii%ij' % (i,j))&#xA;model.Add(a &amp;lt;= sum( int( sum(x[(i,j)] for j in range(30)) &amp;gt;= 5 ) for i in range(20) ) &amp;lt;= b)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Any idea on how to solve it ?&lt;/p&gt;&#xA;" OwnerUserId="11556" LastEditorUserId="500" LastEditDate="2023-03-31T00:02:31.843" LastActivityDate="2023-03-31T13:15:48.600" Title="[OR-Tools][CP-SAT] Implement an indicator function in a constraint" Tags="|constraint-programming|or-tools|indicator-constraints|cp-sat|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10236" PostTypeId="1" CreationDate="2023-03-31T00:02:33.717" Score="1" ViewCount="19" Body="&lt;p&gt;When I submit a GAMS file along with a GDX file to the Neos Server upon clicking the submit button I don't get any error but the following webpage which is not loading and nothing is displayed. I checked the queue but my submission is not there either although no error message is displayed. I did not receive an email either. Can someone explain what to do about this?&lt;br /&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/p7G1w.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/p7G1w.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11516" LastEditorUserId="11516" LastEditDate="2023-03-31T00:04:56.847" LastActivityDate="2023-03-31T00:04:56.847" Title="Using Neos Server to submit GAMS file" Tags="|gams|neos|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10237" PostTypeId="1" AcceptedAnswerId="10238" CreationDate="2023-03-31T03:00:18.390" Score="3" ViewCount="722" Body="&lt;p&gt;Let's assume a warehouse with multiple areas, each including either ground or shelf bins. I want to zone bins in this warehouse such that all bins in a zone are as close as possible. Considering that I need to use a preset value for the number of zones in each area, I have explored two options so far:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Mathematical programming: For each area, suppose &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; refer to the indices of zones and bins, respectively. If binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; determines the allocation of bins to zones, and integer variable &lt;span class=&quot;math-container&quot;&gt;$z_j$&lt;/span&gt; specifies the distance of other bines from bin &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, I can formulate a model as follows.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;min \sum_{j} z_j&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subjected to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{i} x_{ij} = 1 \hspace{1cm} \forall j&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;z_j \geq \sum_{j'} x_{ij'} \times D_{jj'} - (1-x_{ij}) \times \Omega \hspace{1cm} \forall i,j&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$D_{jj'}$&lt;/span&gt; specifies the distance between bins &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j'$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt; is a sufficiently large number. Based on my experimental observations, this model is not computationally efficient (no feasible solution was found after a couple of hours).&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Data mining: I have tried different data mining methods, out of which k-means works the best. The following figure illustrates the zoning of bins for a warehouse with 3,000 bins and 50 zones in each area.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7zLAi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7zLAi.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Please let me know your opinion on whether you suggest other methods worth exploring for this question.&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="5598" LastEditDate="2023-03-31T03:24:20.170" LastActivityDate="2024-04-04T03:54:57.860" Title="An efficient method for zoning bins in a warehouse" Tags="|machine-learning|supply-chain|clustering|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="10238" PostTypeId="2" ParentId="10237" CreationDate="2023-03-31T03:29:36.023" Score="6" Body="&lt;p&gt;Here is a reformulation as MIQP.  Minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j,j'} D_{jj'} x_{ij} x_{ij'}$$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i x_{ij} = 1 \quad \text{for all $j$} \tag1\label1$$&lt;/span&gt;&#xA;If both &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j'$&lt;/span&gt; are assigned to the same bin &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=x_{ij'}=1$&lt;/span&gt;, so the objective penalty &lt;span class=&quot;math-container&quot;&gt;$D_{jj'}$&lt;/span&gt; is accrued.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Here is an alternative linearization that does not use big-M constraints. Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{jj’}$&lt;/span&gt; indicate whether &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j’$&lt;/span&gt; are assigned to the same bin. Define linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{ij} + x_{ij’} - 1 \le y_{jj’} \quad \text{for all $i,j,j’$} \tag2\label2$$&lt;/span&gt;&#xA;Now minimize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j,j’} D_{jj’} y_{jj’}$$&lt;/span&gt; subject to \eqref{1} and \eqref{2}. Note that this linearization differs from the usual one that would instead use triply-indexed variables &lt;span class=&quot;math-container&quot;&gt;$y_{ijj’}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-03-31T12:51:22.237" LastActivityDate="2023-03-31T12:51:22.237" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10240" PostTypeId="2" ParentId="10235" CreationDate="2023-03-31T13:15:48.600" Score="0" Body="&lt;p&gt;If I understand you are trying this.&lt;br /&gt;&#xA;For each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, sum across &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. Then if all the sums across &lt;span class=&quot;math-container&quot;&gt;$j \ge 5$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (basically the &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt;, the AND logic), then whole sum will be between constants &lt;span class=&quot;math-container&quot;&gt;$a,b$&lt;/span&gt;.&lt;br /&gt;&#xA;I can linearize it as below (OR-Tools will do the same thing)&lt;br /&gt;&#xA;Introduce set of new binary variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;. Add linear constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_j x_{i,j} \le 5+My_i$&lt;/span&gt; &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ 5- \sum_j x_{i,j} \le M(1-y_i)$&lt;/span&gt;&lt;br /&gt;&#xA;where could be appropriate big number, like upper bound of sum of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; values possible.&lt;/p&gt;&#xA;&lt;p&gt;Then you'd need another binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; and below constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\delta \le y_i  \quad \forall i$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_iy_i -I+1 \le \delta$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is total number of your &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;s&lt;/p&gt;&#xA;&lt;p&gt;Then the below constraint&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ a-M(1-\delta) \le \sum_i \sum_j x_{i,j} \le b + M(1- \delta)$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-03-31T13:15:48.600" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10241" PostTypeId="2" ParentId="10237" CreationDate="2023-03-31T18:13:54.623" Score="1" Body="&lt;p&gt;Rather than summing all the distances, another possible objective function is to minimize the sum of the &amp;quot;diameters&amp;quot; of the zones, where the diameter is the maximum distance between any two bins assigned to the zone. Using your variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; and letting &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; now represent the diameter of zone &lt;span class=&quot;math-container&quot;&gt;$i,$&lt;/span&gt; your second constraint is replaced by &lt;span class=&quot;math-container&quot;&gt;$$z_i \ge D_{j,j'} (x_{i,j} + x_{i,j'} - 1)\quad \forall i,j,j' &amp;gt; j.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Addendum: Another common choice for this type of problem is to minimize the largest zone diameter, rather than the sum of the diameters. To do this, minimize a new variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; subject to the constraints &lt;span class=&quot;math-container&quot;&gt;$y\ge z_i \, \forall i.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-03-31T19:32:11.490" LastActivityDate="2023-03-31T19:32:11.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10242" PostTypeId="2" ParentId="10183" CreationDate="2023-03-31T18:47:14.630" Score="1" Body="&lt;p&gt;One addition to the optimization methods/concepts that Prubin proposed is simulation-optimization: &lt;a href=&quot;https://www.informs-sim.org/wsc97papers/0118.PDF&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.informs-sim.org/wsc97papers/0118.PDF&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="329" LastEditorUserId="329" LastEditDate="2023-04-01T06:44:54.640" LastActivityDate="2023-04-01T06:44:54.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10243" PostTypeId="2" ParentId="10237" CreationDate="2023-03-31T23:23:43.650" Score="1" Body="&lt;p&gt;As you understood, your zoning problem can be modeled as a clustering problem: discrete decision variables related to assigning items to sets, possible additional constraints on how the items can or cannot be assigned to the sets, and an objective function related to a distance to minimize. The distance is generally of a quadratic nature. Paul, above, suggests different distance functions to reach the most appropriate business solutions.&lt;/p&gt;&#xA;&lt;p&gt;Due to the quadratic nature of the problem, traditional solvers like Gurobi and Cplex cannot scale. Given the number of items you mentioned (3,000 bins), MILP or MIQP solvers don't deliver meaningful solutions, even after hours of running times.&lt;/p&gt;&#xA;&lt;p&gt;Thanks to its higher-lever modeling APIs involving set variables and nonlinear mathematical operators, coupled with exact and heuristic methods under the hood, Hexaly can provide high-quality solutions to such problems in minutes. You can find ready-to-use templates for this problem &lt;a href=&quot;https://www.hexaly.com/docs/last/exampletour/index.html#supply-chain-network-design&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. Benchmarks related to these problems, like Quadratic Assignment Problem (QAP) or K-Means Clustering Problem (MSSC), are also available &lt;a href=&quot;https://www.hexaly.com/benchmark/localsolver-vs-gurobi-k-means-clustering-mssc&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Disclaimer: Hexaly is commercial software. Nevertheless, it is free for faculty and students.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2024-04-04T03:54:57.860" LastActivityDate="2024-04-04T03:54:57.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10244" PostTypeId="1" CreationDate="2023-04-01T16:14:18.877" Score="0" ViewCount="136" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CNZ9a.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CNZ9a.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;price=np.array([70,60,50]) ## [Super, Regular, Dissel]&#xA;cost=np.array([45,35])&#xA;x = cp.Variable((2,3)) ## Let x[i,j] denote the barrel of crude oil i-1 to use to produce product j&#xA;c=np.array([5000,5000])&#xA;&#xA;profit= cp.Maximize( cp.sum(price*cp.sum(x,axis = 0))- cp.sum(cost*cp.sum(x,axis&#xA;= 1)))&#xA;&#xA;const=[]&#xA;const.append(x&amp;gt;=0)&#xA;const.append(12*x[0,0]+ 6*x[1,0]&amp;gt;=10*(x[0,0]+x[1,0]))&#xA;const.append(12*x[0,1]+ 6*x[1,1]&amp;gt;=8*(x[0,1]+x[1,1]))&#xA;const.append(12*x[0,2]+ 6*x[1,2]&amp;gt;=6*(x[0,2]+x[1,2]))&#xA;const.append(0.5*x[0,0]+ 2*x[1,0]&amp;lt;=1*(x[0,0]+x[1,0]))&#xA;const.append(0.5*x[0,1]+ 2*x[1,1]&amp;lt;=2*(x[0,1]+x[1,1]))&#xA;const.append(0.5*x[0,2]+ 2*x[1,2]&amp;lt;=1*(x[0,2]+x[1,2]))&#xA;const.append(cp.sum(x,axis = 1) &amp;lt;= c)&#xA;const.append(cp.sum(cp.sum(x)) &amp;lt;= 9000)&#xA;&#xA;problem = cp.Problem(profit,const)&#xA;problem.solve()&#xA;print(&amp;quot;Status: &amp;quot;, problem.status)&#xA;print(&amp;quot;The optimal value is&amp;quot;, problem.value)&#xA;print(&amp;quot;A solution x is&amp;quot;)&#xA;print(x.value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am very confused with the code why is the revenue portion the number of crude oil used to produce product j. I understand that for the cost, it should use the number of crude oil used for production, but for revenue it is weird to be using it as a way to calculate revenue.&lt;/p&gt;&#xA;" OwnerUserId="11561" LastEditorUserId="8" LastEditDate="2023-04-06T10:29:38.313" LastActivityDate="2023-04-06T10:29:38.313" Title="Optimal blending of gasoline via LP" Tags="|optimization|linear-programming|python|cvxpy|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10246" PostTypeId="2" ParentId="10244" CreationDate="2023-04-01T17:22:38.597" Score="2" Body="&lt;p&gt;The key is in the last sentence: nothing is lost in blending. So the combined amount of crude 1 and crude 2 used to make super equals the amount of super produced, and so on.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-01T17:22:38.597" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10247" PostTypeId="1" AcceptedAnswerId="10248" CreationDate="2023-04-01T22:20:26.620" Score="4" ViewCount="379" Body="&lt;p&gt;Suppose  &lt;span class=&quot;math-container&quot;&gt;$C_1 \ge 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$C_2 \ge 0$&lt;/span&gt; are continuous variables and &lt;span class=&quot;math-container&quot;&gt;$b_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b_2$&lt;/span&gt; are binary variables.&lt;/p&gt;&#xA;&lt;p&gt;How could I model the following?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C_1 = C_2 \implies b_1 = b_2$&lt;/span&gt;, the opposite does not hold.&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="123" LastEditDate="2023-08-09T08:02:31.230" LastActivityDate="2023-08-09T08:02:31.230" Title="How to model $C_1=C_2$ implies $b_1 = b_2$" Tags="|mixed-integer-programming|modeling|linearization|logical-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10248" PostTypeId="2" ParentId="10247" CreationDate="2023-04-01T22:47:39.363" Score="7" Body="&lt;p&gt;Equivalently, you want to enforce the contrapositive&#xA;&lt;span class=&quot;math-container&quot;&gt;$$b_1 \not= b_2 \implies C_1 \not= C_2$$&lt;/span&gt;&#xA;Because the &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; are binary, this is the same as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$b_1 + b_2 = 1 \implies C_1 \not= C_2$$&lt;/span&gt;&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt; be a small constant tolerance, and suppose that &lt;span class=&quot;math-container&quot;&gt;$C_i \le M_i$&lt;/span&gt;.&#xA;Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;, and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;b_1 + b_2 &amp;amp;= 2y_1 + y_2 \tag1\label1 \\&#xA;y_2 &amp;amp;\le z_1 + z_2 \tag2\label2 \\&#xA;C_1 - C_2 + \epsilon &amp;amp;\le (M_1 + \epsilon) (1-z_1) \tag3\label3 \\&#xA;C_2 - C_1 + \epsilon &amp;amp;\le (M_2 + \epsilon) (1-z_2) \tag4\label4 &#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} enforces &lt;span class=&quot;math-container&quot;&gt;$b_1 + b_2 = 1 \implies y_2$&lt;/span&gt;.&#xA;Constraint \eqref{2} enforces &lt;span class=&quot;math-container&quot;&gt;$y_2 \implies (z_1 \lor z_2)$&lt;/span&gt;.&#xA;Constraint \eqref{3} enforces &lt;span class=&quot;math-container&quot;&gt;$z_1 \implies C_1 + \epsilon \le C_2$&lt;/span&gt;.&#xA;Constraint \eqref{4} enforces &lt;span class=&quot;math-container&quot;&gt;$z_2 \implies C_2 + \epsilon \le C_1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-04-01T22:47:39.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10249" PostTypeId="2" ParentId="10247" CreationDate="2023-04-01T23:23:18.677" Score="2" Body="&lt;p&gt;You can try the following&lt;br /&gt;&#xA;Lets define 3 binary variables &lt;span class=&quot;math-container&quot;&gt;$y_1,y_2,z$&lt;/span&gt;&lt;br /&gt;&#xA;Additional constraints with &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; as small positive number&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$c_1-c_2 + \delta \le My_1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$c_2-c_1-\delta \le M(1-y_1)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$c_2-c_1+\delta \le My_2$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$c_1-c_2-\delta \le M(1-y_2)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_1+y_2 \le 1+z$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z\le y_1,y_2$&lt;/span&gt;&lt;br /&gt;&#xA;Then&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ b_2+z-1 \le b_1 \le b_2 + 1-z$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-04-01T23:23:18.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10250" PostTypeId="1" CreationDate="2023-04-02T10:08:59.840" Score="2" ViewCount="22" Body="&lt;p&gt;There is an M/M/1 (getting a result for M/M/c is ideal) queue with arrival rate  and service rate  and participants can renege.&lt;/p&gt;&#xA;&lt;p&gt;However, the difference between normal reneging settings (constant time &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt;) and this setting is that the participants know its service time ahead of time and the time to renege is a function of its service time (sampling from exponential). Let's say the function is a linear function of its service time &lt;span class=&quot;math-container&quot;&gt;$ w(\cdot) = a \cdot s$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$ s \sim Exp(\mu)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ a $&lt;/span&gt; is a constant.&lt;/p&gt;&#xA;&lt;p&gt;There is no balking.&lt;/p&gt;&#xA;&lt;p&gt;What would be the expression for the steady-state probability that a participant receives service?&lt;/p&gt;&#xA;" OwnerUserId="11563" LastActivityDate="2023-04-02T10:08:59.840" Title="Service probability for M/M/c queue for reneging where reneging time is a function of service time" Tags="|queuing-theory|probability-theory|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10251" PostTypeId="1" CreationDate="2023-04-02T15:56:27.380" Score="2" ViewCount="105" Body="&lt;p&gt;Folks, I am working on a project in which I have to code some C++ algorithms for smooth MINLPs.&#xA;Such algorithms are Extended Cutting Plane, Extended Supporting Hyperplane, and Outer Approximation. I am planning to use some MILP solver (for solving the master problem) along with its callback functionality (for adding cuts from the slave problems).&lt;/p&gt;&#xA;&lt;p&gt;Therefore, I am trying to choose the most suitable option for my situation.&#xA;Below I listed such options in a table.&#xA;So far I have listed some requirements the MILP solver must have (1st column), and the corresponding functions (remaining columns) in two solvers, the Coin-OR B&amp;amp;C, and the CPLEX.&lt;/p&gt;&#xA;&lt;p&gt;I placed the &amp;quot;?&amp;quot; character in the cells I do not know the proper information.&#xA;I am looking for the remaining information necessary to fill this table.&#xA;I would like to know if someone has worked with MINLP before, and&#xA;if has some answers for filling this table.&#xA;Also, any recommendations of others solvers are very welcome.&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Requirements&lt;/th&gt;&#xA;&lt;th&gt;CBC-COIN-OR&lt;/th&gt;&#xA;&lt;th&gt;&lt;/th&gt;&#xA;&lt;th&gt;CPLEX Concert&lt;/th&gt;&#xA;&lt;th&gt;&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;/td&gt;&#xA;&lt;td&gt;Functions&lt;/td&gt;&#xA;&lt;td&gt;References&lt;/td&gt;&#xA;&lt;td&gt;Functions&lt;/td&gt;&#xA;&lt;td&gt;References&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Get inequalities&lt;/td&gt;&#xA;&lt;td&gt;getNumRows()&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#40e058a76208364a573dc109586bd208&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#40e058a76208364a573dc109586bd208&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;IloConstraintArray&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-iloconstraintarray-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-iloconstraintarray-1&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Get inequality sense&lt;/td&gt;&#xA;&lt;td&gt;getRowSense()&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#9cf311df9ca4dd9165a925a780f73d59&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#9cf311df9ca4dd9165a925a780f73d59&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;IloConstraintArray.getImpl()&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilonumexprarg-1#method_getImpl&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilonumexprarg-1#method_getImpl&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Get inequality LHS&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;td&gt;IloConstraintArray.getImpl()&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilonumexprarg-1#method_getImpl&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilonumexprarg-1#method_getImpl&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Get inequality RHS&lt;/td&gt;&#xA;&lt;td&gt;getRightHandSide()&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#10f1678372ac83e3c84ec0173382c49a&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#10f1678372ac83e3c84ec0173382c49a&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;IloConstraintArray.getImpl()&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilonumexprarg-1#method_getImpl&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilonumexprarg-1#method_getImpl&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Get non-linear inequalities&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Get convex inequalities&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Get variables&lt;/td&gt;&#xA;&lt;td&gt;getNumCols()&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#5d010c66439040cc41f325e403ac455d&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#5d010c66439040cc41f325e403ac455d&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;IloNumVarArray&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilonumvararray-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilonumvararray-1&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Get integer variables&lt;/td&gt;&#xA;&lt;td&gt;numberIntegers() integerType(int I) isContinuous(int colIndex) isBinary(int colIndex) isInteger(int colIndex) IsIntegerNonBinary(int colIndex)&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#46b35008e5dde744de7861a456597888&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#46b35008e5dde744de7861a456597888&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Get non-integer variables&lt;/td&gt;&#xA;&lt;td&gt;numberIntegers() integerType(int I) isContinuous(int colIndex) isBinary(int colIndex) isInteger(int colIndex) IsIntegerNonBinary(int colIndex)&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#46b35008e5dde744de7861a456597888&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#46b35008e5dde744de7861a456597888&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;td&gt;?&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Get variables UB&lt;/td&gt;&#xA;&lt;td&gt;getColUpper() GetCbcColUpper ()&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#e029873f5a7b4aef3df4ad30be929e1f&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#e029873f5a7b4aef3df4ad30be929e1f&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;IloRangeArray&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilorangearray-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilorangearray-1&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Get variables LB&lt;/td&gt;&#xA;&lt;td&gt;GetColLower () GetCbcColLower ()&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#cfa9192b32bde2d710e85deb71bce52b&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.coin-or.org/Doxygen/CoinAll/class_cbc_model.html#cfa9192b32bde2d710e85deb71bce52b&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;IloRangeArray&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilorangearray-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilorangearray-1&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Read LP file&lt;/td&gt;&#xA;&lt;td&gt;readLp&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.coin-or.org/Doxygen/CoinAll/class_osi_clp_solver_interface.html#d13f9e98ebaec68ce028d5aec95e6c38&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.coin-or.org/Doxygen/CoinAll/class_osi_clp_solver_interface.html#d13f9e98ebaec68ce028d5aec95e6c38&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;importModel(IloModel &amp;amp; m, const char * filename)&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilocplex-3#method_importModel&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilocplex-3#method_importModel&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Read MPS file&lt;/td&gt;&#xA;&lt;td&gt;readMps&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.coin-or.org/Doxygen/CoinAll/class_osi_clp_solver_interface.html#edd68d7b3e54507a1afa0df0712f76d1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.coin-or.org/Doxygen/CoinAll/class_osi_clp_solver_interface.html#edd68d7b3e54507a1afa0df0712f76d1&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;importModel(IloModel &amp;amp; m, const char * filename)&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilocplex-3#method_importModel&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/12.9.0?topic=c-ilocplex-3#method_importModel&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Thank you very much for the attention, best regards.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastActivityDate="2023-04-02T16:17:30.397" Title="Structuring an MINLP solver" Tags="|mixed-integer-programming|minlp|coin-or|concert|nlp|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10252" PostTypeId="2" ParentId="10251" CreationDate="2023-04-02T16:17:30.397" Score="1" Body="&lt;p&gt;First of all, I'd not use terms like slave in the 21st century. For me it's the main problem &amp;amp; sub-problems.&lt;br /&gt;&#xA;Most modern solvers like Gurobi can approach MINLP using decomposition methods. The following links may be of some help.&lt;br /&gt;&#xA;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/11466556605713-MINLP-solver&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi&lt;/a&gt;,&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.gurobi.com/documentation/10.0/refman/cpp_api_details.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;API Details&lt;/a&gt;,&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.gurobi.com/documentation/10.0/refman/cpp_api_overview.html#sec:C++&quot; rel=&quot;nofollow noreferrer&quot;&gt;C++&lt;/a&gt;,&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.gurobi.com/documentation/10.0/refman/attributes.html#sec:Attributes&quot; rel=&quot;nofollow noreferrer&quot;&gt;Attributes&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-04-02T16:17:30.397" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10254" PostTypeId="1" AcceptedAnswerId="10255" CreationDate="2023-04-03T01:09:31.743" Score="3" ViewCount="701" Body="&lt;p&gt;I modeled an optimization problem in an integer programming format. The main constraint I came up with is now nonconvex. I would like to see if there is another equivalent formulation in which the constraints are convex or simple enough to be solved.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \begin{aligned}&#xA;        \min_{x,t} \quad &amp;amp;  \sum_{i=1}^{n}{c_i x_i}\\&#xA;        \textrm{s.t.} \quad &amp;amp; \sum_{j=1}^{n}{t_j  \big( \text{dist} (v_i  , v_j)  - T x_j  \big)}  \leq 0 ,~ i=1,\dots,n \\&#xA;        &amp;amp;  t_1 +  t_2 +\dots + t_n = 1\\&#xA;        &amp;amp; t_i  , x_i  \in  \{  0 , 1 \}    \\&#xA;    \end{aligned}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$\text{dist} (v_i , v_j) $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; are positive constants. &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt; if the node &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; is selected, &lt;span class=&quot;math-container&quot;&gt;$x_i = 0$&lt;/span&gt; otherwise. &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt;s are auxiliary variables. The constraints have been written in a way that for each node &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt;, there exists a selected node &lt;span class=&quot;math-container&quot;&gt;$v_j$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\text{dist} (v_i , v_j) \leq T.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="11566" LastEditorUserId="11566" LastEditDate="2023-04-03T04:12:48.570" LastActivityDate="2023-04-03T04:24:27.963" Title="Writing a constraint of an integer programming in a linear form" Tags="|mixed-integer-programming|linear-programming|modeling|linearization|facility-location|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10255" PostTypeId="2" ParentId="10254" CreationDate="2023-04-03T01:22:25.757" Score="7" Body="&lt;p&gt;Introduce a binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; to represent the product &lt;span class=&quot;math-container&quot;&gt;$t_j x_j$&lt;/span&gt;. The &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;usual linearization&lt;/a&gt; would use three linear constraints to enforce this relationship. But here, because &lt;span class=&quot;math-container&quot;&gt;$T\ge 0$&lt;/span&gt;, we need only enforce &lt;span class=&quot;math-container&quot;&gt;$y_j \le t_j x_j$&lt;/span&gt;, so two constraints suffice: &lt;span class=&quot;math-container&quot;&gt;$y_j \le t_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_j \le x_j$&lt;/span&gt;. Finally, replace your first constraint with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=1}^n \left(t_j \text{dist}(v_i,v_j)−T y_j\right)\le0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;A simpler way to enforce your desired restriction is to let &lt;span class=&quot;math-container&quot;&gt;$$J_i=\{j\in\{1,\dots,n\}: \text{dist}(v_i,v_j)\le T\}$$&lt;/span&gt; and impose set covering constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j\in J_i} x_j \ge 1 \quad \text{for all $i$}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-04-03T04:24:27.963" LastActivityDate="2023-04-03T04:24:27.963" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10256" PostTypeId="2" ParentId="10254" CreationDate="2023-04-03T02:08:56.607" Score="2" Body="&lt;p&gt;You can implement - for each node &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt;, there exists a node &lt;span class=&quot;math-container&quot;&gt;$v_j$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\text{dist} (v_i , v_j) \leq T.$&lt;/span&gt; like below&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_i \le \sum_{j \neq i} x_j \le x_i + M(1-x_i)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j \neq i}x_j dist(v_i,v_j) \le T +M(1-x_i)$&lt;/span&gt;&lt;br /&gt;&#xA;Or&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j \neq i}x_j dist(v_i,v_j) \le T(2-x_i)$&lt;/span&gt;: simply replaced &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-04-03T02:08:56.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10258" PostTypeId="1" CreationDate="2023-04-04T15:52:02.693" Score="3" ViewCount="762" Body="&lt;p&gt;As the title says, I was wondering if there are applications of optimization in art.&#xA;I am mainly thinking about visual arts e.g., painting, drawing, sculpture, but any other form of art would be interesting, e.g., music.&lt;/p&gt;&#xA;" OwnerUserId="766" LastActivityDate="2023-04-04T16:40:41.443" Title="Are there applications of OR in art?" Tags="|applications|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10259" PostTypeId="2" ParentId="10258" CreationDate="2023-04-04T16:40:05.023" Score="6" Body="&lt;p&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/0691164061&quot; rel=&quot;noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Opt Art&lt;/a&gt; takes you into some of the applications esp. in visualizing patterns\tiles\covers. Also entire computer vision &amp;amp; ML into correctly identifying images is based on optimizing a loss function.&lt;br /&gt;&#xA;Sill I guess applying optimization techniques to art does require some serious investment of time &amp;amp; effort. Like what factors (variables) do the average human eye and senses find most appealing? What are the recipes (variables) that make a movie a hit?&lt;br /&gt;&#xA;Though running ML algorithms like random forests often give out a probability of profiles of movies or art that are most likely to capture human emotions or senses, I dont think there's a serious thinking into identifying the impact (reduced cost/price) of different variables that go into that.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-04-04T16:40:05.023" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10261" PostTypeId="1" AcceptedAnswerId="10271" CreationDate="2023-04-04T19:09:43.200" Score="1" ViewCount="113" Body="&lt;p&gt;Can we perform sensitivity analysis on the decision variables for the perturbed right-hand side of the constraints in a convex/nonlinear program? I know a basic result regarding the sensitivity of the optimal solution but are there any techniques/references to do the same for the decision variables?&lt;/p&gt;&#xA;" OwnerUserId="10675" LastActivityDate="2023-04-06T00:30:03.680" Title="Sensitivity analysis for decision vectors in convex programming" Tags="|nonlinear-programming|convex-optimization|sensitivity-analysis|perturbation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10262" PostTypeId="2" ParentId="9951" CreationDate="2023-04-05T07:31:00.310" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/cpp/jobshop_sat.cc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/examples/cpp/jobshop_sat.cc&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It can parse most of standard jssp/fjssp problems. It has very good results.&#xA;Make sure you have a beefy machine (8, and better 16 cores), and use the corresponding number of workers.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-04-05T07:31:00.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10263" PostTypeId="1" CreationDate="2023-04-05T10:49:27.083" Score="2" ViewCount="170" Body="&lt;p&gt;I am working on the directed graph by using the Networkx package and what I need is to use its predecessors' method on an optimization model. Let's say, there exists a directed graph with just &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; nodes which is defined as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;G = nx.DiGraph(&#xA;    [(1, 2), (1, 3), &#xA;     (2, 4), (2, 5), (2, 6), &#xA;     (3, 6), (3, 7), &#xA;     (4, 9), &#xA;     (5, 9), &#xA;     (6, 8),&#xA;     (7, 11),&#xA;     (8, 9), (8, 10),&#xA;     (9, 12),&#xA;     (10, 12),&#xA;     (11, 12),&#xA;     ])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now, I would like to use its predecessors in the constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{m} m.x_{i,m} \leq \sum_{m} m.x_{j,m} \quad \forall (i,j) \in \text{Predecessors}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What I try is something like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;predecessors = numpy.array(G.predecessors)&#xA;m.pred= Set(initialize = m.I * m.I, dimen=2, filter=lambda m, i, j: (i,j) in predecessors)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;By that, the model does not produce any throw, but the results are incorrect. I guess it came from the definition of the above set (!) and am wondering if, someone can guide me to fix that.&lt;/p&gt;&#xA;&lt;p&gt;As an attempt, I tried to run the problem in DoCplex, but the issue on the &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;th constraint is the same. I think(?) this should be more of a Python issue than a solver issue.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;number_of_nodes = 12&#xA;S = [[1, 2], [1, 3], &#xA;     [2, 4], [2, 5], [2, 6], &#xA;     [3, 6], [3, 7], &#xA;     [4, 9], &#xA;     [5, 9], &#xA;     [6, 8],&#xA;     [7, 11],&#xA;     [8, 9], [8, 10],&#xA;     [9, 12],&#xA;     [10, 12],&#xA;     [11, 10],&#xA;]&#xA;&#xA;I = range(number_of_nodes)&#xA;B = range(number_of_station)&#xA;&#xA;x = {}&#xA;for i in I:&#xA;  for b in B:&#xA;    x[(i,b)] = mdl.binary_var()&#xA;&#xA;the first form:&#xA;for i in S:&#xA;  for j in S:&#xA;    if (i,j) in enumerate(S):&#xA;      mdl.add_constraint( mdl.sum(x[(i,b)]*b for b in B) &amp;lt;= mdl.sum(x[(j,b)]*b for b in B ) ) &#xA;&#xA;the second form:&#xA;for i in S:&#xA;  for j in i:&#xA;    if (i,j) in enumerate(S):&#xA;      mdl.add_constraint( mdl.sum(x[(i,b)]*b for b in B) &amp;lt;= mdl.sum(x[(j,b)]*b for b in B ) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Unfortunately, in both form the solution is incorrect.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;The correct solution:&#xA;Objective = 20&#xA;&#xA;----------------------&#xA;                 1           2           3           4&#xA;&#xA;    1        1.000&#xA;    2        1.000&#xA;    3                    1.000&#xA;    4        1.000&#xA;    5        1.000&#xA;    6                                1.000&#xA;    7                    1.000&#xA;    8                                1.000&#xA;    9                                            1.000&#xA;    10                                           1.000&#xA;    11                   1.000&#xA;    12                                           1.000&#xA;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-04-07T14:46:10.053" LastActivityDate="2024-01-02T16:09:11.110" Title="Using networkx predecessors in Pyomo initialize method" Tags="|mixed-integer-programming|python|pyomo|modeling-languages|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10264" PostTypeId="1" AcceptedAnswerId="10268" CreationDate="2023-04-05T12:45:46.563" Score="1" ViewCount="59" Body="&lt;p&gt;I have a routing problem and am wondering if it is even possible to only use the &lt;span class=&quot;math-container&quot;&gt;$k^{th}$&lt;/span&gt; shortest path?&#xA;There are a set of people with cars and a set of other people with no cars, each has its own itinerary. We call them drivers (although they're not taxis), and riders. For all these people we know the k first shortest path (as if they have a car). I wanted to define a variable like &lt;span class=&quot;math-container&quot;&gt;$ x^{d,r}=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is matched with &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; and two other variables &lt;span class=&quot;math-container&quot;&gt;$y_k^r$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_k^d$&lt;/span&gt; take one if, respectively, &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; take their &lt;span class=&quot;math-container&quot;&gt;$k^{th}$&lt;/span&gt; shortest path.&lt;/p&gt;&#xA;&lt;p&gt;But this obviously won't work when there are no overlap between the &lt;span class=&quot;math-container&quot;&gt;$k^{th}$&lt;/span&gt; shortest path of each people. Even if there was,  how to cover cases when one rider wants to switch from one person to another?&lt;/p&gt;&#xA;&lt;p&gt;In other words, how to merge the two shortest paths with each other? Is it possible? For example, following the 1st shortest path until point &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and then diverging to other possible shortest paths from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; onward.&lt;/p&gt;&#xA;&lt;p&gt;I have searched and did not find a good formulation that only uses the shortest path. Is this because of inefficiency?&lt;/p&gt;&#xA;" OwnerUserId="11476" LastEditorUserId="11476" LastEditDate="2023-04-05T13:38:26.403" LastActivityDate="2023-04-05T22:40:19.860" Title="Is it possible to route based only upon shortest path?" Tags="|mixed-integer-programming|modeling|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10265" PostTypeId="1" CreationDate="2023-04-05T12:55:09.783" Score="3" ViewCount="117" Body="&lt;p&gt;In the DFJ formulation of the symmetric TSP, the subtour elimination constraints are typically written as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{\{i,j\} \in E: \ i \in S, j \notin S} x_{ij} \geq 2, \qquad \forall S \subset V, \; 3 \leq |S| \leq |V|-1$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is the set of vertices.&lt;/p&gt;&#xA;&lt;p&gt;It is sometimes pointed out that the number of these constraints can be reduced by observing that the constraints for &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; and its complement &lt;span class=&quot;math-container&quot;&gt;$\bar{S}$&lt;/span&gt; are the same. Therefore, one can write them as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{\{i,j\} \in E: \ i \in S, j \notin S} x_{ij} \geq 2, \qquad \forall S \subset V, \; 3 \leq |S| \leq \bigg \lfloor \frac{|V|}{2} \bigg \rfloor.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Although I've seen this kind of reduction in the number in a number of sources, I don't recall ever finding a similar observation (reduced formulation) for the ATSP -- at least not one that uses subsets with sizes not exceeding &lt;span class=&quot;math-container&quot;&gt;$\lfloor \frac{|V|}{2} \rfloor$&lt;/span&gt;. In my mind, unless I'm missing something, I'm thinking similar reasoning applies in the ATSP case. Namely, if we include constraints for all subsets of size &lt;span class=&quot;math-container&quot;&gt;$\leq \lfloor \frac{|V|}{2} \rfloor$&lt;/span&gt;, a subtour of size &lt;span class=&quot;math-container&quot;&gt;$&amp;gt; \lfloor \frac{|V|}{2} \rfloor$&lt;/span&gt; will never occur since that implies that there exist other subtours whose size &lt;span class=&quot;math-container&quot;&gt;$\leq \lfloor \frac{|V|}{2} \rfloor$&lt;/span&gt;. In that case, can we write:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{(i,j) \in A: \ i \in S, j \notin S} x_{ij} \geq 1, \qquad \forall S \subset V, \; 2 \leq |S| \leq \bigg \lfloor \frac{|V|}{2} \bigg \rfloor?$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If so, is there a reason why the ATSP DFJ formulation is always presented in its more general form with almost all possible subsets? Of course, the number is still exponential (maybe it doesn't matter in a sense), but still surprised me that I could not find a reference that supported this.&lt;/p&gt;&#xA;&lt;p&gt;Thanks for your help!&lt;/p&gt;&#xA;" OwnerUserId="11589" LastEditorUserId="500" LastEditDate="2023-04-05T13:24:20.550" LastActivityDate="2023-04-05T13:24:20.550" Title="Number of Subtour Elimination Constraints for ATSP (DFJ Formulation)" Tags="|integer-programming|traveling-salesman|subtour-elimination|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10266" PostTypeId="2" ParentId="10264" CreationDate="2023-04-05T21:09:30.553" Score="0" Body="&lt;p&gt;You can try dynamic programming like&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ P(i,r) = min\{\sum_j d_{i,j}(y_{k}^r+z_{k}^d)+ P_{k+1}(j,r) \ \ \forall j \in (i,j)\}$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is distance matrix from nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ y_{k}^r+z_{k}^d \le 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is the efficient merged path.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-04-05T22:40:19.860" LastActivityDate="2023-04-05T22:40:19.860" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10267" PostTypeId="1" CreationDate="2023-04-05T21:15:50.047" Score="1" ViewCount="59" Body="&lt;p&gt;I would like to know how to use pyhon or Cplex or both for finding the whole optimal pareto front for a biobjective mixed integer linear programming problem?&lt;/p&gt;&#xA;" OwnerUserId="3925" LastEditorUserId="491" LastEditDate="2023-11-09T21:07:15.697" LastActivityDate="2023-11-09T21:07:15.697" Title="Which Python package is suitable for finding the optimal non dominated set in multiobjective optimization?" Tags="|mixed-integer-programming|python|multi-objective-optimization|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10268" PostTypeId="2" ParentId="10264" CreationDate="2023-04-05T22:04:41.973" Score="0" Body="&lt;p&gt;I'll define a possible model other than the objective function (which should not be hard to add). A key to the model is that we focus on paths rather than drivers. If the same physical path is one of the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; shortest paths for two different drivers, it is considered two different paths in the model.&lt;/p&gt;&#xA;&lt;h2&gt;Assumptions&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;We have a directed graph.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each driver has a fixed origin and destination and will select one of the k shortest paths between their origin and destination (and not deviate from that path).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each path visits every node at most once (paths do not contain loops).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Riders have fixed origins and destinations but are not limited to a fixed set of paths.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Drivers can carry multiple riders.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Driving times for all paths are known with reasonable accuracy.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The time to pick up or drop off a rider is negligible.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2&gt;Sets&lt;/h2&gt;&#xA;&lt;p&gt;• &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is the set of vertices&lt;/p&gt;&#xA;&lt;p&gt;• &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is the set of (directed) edges&lt;/p&gt;&#xA;&lt;p&gt;• &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is the set of drivers&lt;/p&gt;&#xA;&lt;p&gt;• &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; is the set of riders&lt;/p&gt;&#xA;&lt;p&gt;• &lt;span class=&quot;math-container&quot;&gt;$P_{d}$&lt;/span&gt; is the set of the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; shortest paths for driver &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;• &lt;span class=&quot;math-container&quot;&gt;$P=\cup_{d\in D}P_{d}$&lt;/span&gt; is the set of all paths&lt;/p&gt;&#xA;&lt;h2&gt;Parameters&lt;/h2&gt;&#xA;&lt;p&gt;• &lt;span class=&quot;math-container&quot;&gt;$o(r)\in V$&lt;/span&gt; is the origin node for rider &lt;span class=&quot;math-container&quot;&gt;$r\in R$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;• &lt;span class=&quot;math-container&quot;&gt;$\delta(r)\in V$&lt;/span&gt; is the destination node for rider &lt;span class=&quot;math-container&quot;&gt;$r\in R$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;• &lt;span class=&quot;math-container&quot;&gt;$\alpha_{p,p',i}=1$&lt;/span&gt; if path &lt;span class=&quot;math-container&quot;&gt;$p\in P$&lt;/span&gt; enters node &lt;span class=&quot;math-container&quot;&gt;$i\in V$&lt;/span&gt; no later than path &lt;span class=&quot;math-container&quot;&gt;$p'\in P$&lt;/span&gt; leaves &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (0 if &lt;span class=&quot;math-container&quot;&gt;$p'$&lt;/span&gt; leaves &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; first or if either &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$p'$&lt;/span&gt; does not visit &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at all)&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\alpha_{p,p,i}=1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;• &lt;span class=&quot;math-container&quot;&gt;$C_{p}$&lt;/span&gt; is the maximum number of simultaneous riders allowed on path &lt;span class=&quot;math-container&quot;&gt;$p\in P$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h2&gt;Variables&lt;/h2&gt;&#xA;&lt;p&gt;• &lt;span class=&quot;math-container&quot;&gt;$x_{p}\in\left\{ 0,1\right\}$&lt;/span&gt; is 1 if path &lt;span class=&quot;math-container&quot;&gt;$p\in P$&lt;/span&gt; is used, 0 if not&lt;/p&gt;&#xA;&lt;p&gt;• &lt;span class=&quot;math-container&quot;&gt;$y_{r,e,p}\in\left\{ 0,1\right\}$&lt;/span&gt; is 1 if rider &lt;span class=&quot;math-container&quot;&gt;$r\in R$&lt;/span&gt; crosses edge &lt;span class=&quot;math-container&quot;&gt;$e\in E$&lt;/span&gt; on path &lt;span class=&quot;math-container&quot;&gt;$p\in P,$&lt;/span&gt; 0 if not&lt;/p&gt;&#xA;&lt;h2&gt;Constraints&lt;/h2&gt;&#xA;&lt;p&gt;• Each driver selects exactly one of their k shortest paths:&lt;span class=&quot;math-container&quot;&gt;$$\sum_{p\in P_{d}}x_{p}=1\quad\forall d\in D$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;• No driver can carry more than the allowed number of riders on any portion of any path:&lt;span class=&quot;math-container&quot;&gt;$$\sum_{r\in R}y_{r,e,p}\le C_{p}\quad\forall p\in P,\forall e\in p$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;• A rider cannot cross an edge on a path that does not contain the edge:&lt;span class=&quot;math-container&quot;&gt;$$y_{r,e,p}=0\quad\forall r\in R,\forall p\in P,\forall e\in E\backslash p$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;• A rider cannot cross an edge via an unused path:&lt;span class=&quot;math-container&quot;&gt;$$y_{r,e,p}\le x_{p}\quad\forall r\in R,\forall p\in P,\forall e\in p$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;• Each rider leaves their origin exactly once:&lt;span class=&quot;math-container&quot;&gt;$$\sum_{e=(o(r),j)\in E}\ \sum_{p\in P:e\in p}y_{r,e,p}=1\quad\forall r\in R$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;• Each rider enters their destination exactly once:&lt;span class=&quot;math-container&quot;&gt;$$\sum_{e=(j,\delta(r))\in E}\ \sum_{p\in P:e\in p}y_{r,e,p}=1\quad\forall r\in R$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;• For any node other than their origin and destination, a rider exits the node the same number of times they enter it:&lt;span class=&quot;math-container&quot;&gt;$$\sum_{e=(i,j)\in E}\ \sum_{p\in P:e\in p}y_{r,e,p}=\sum_{e=(j,k)\in E}\ \sum_{p\in P:e\in p}y_{r,e,p}\quad\forall r\in R,\forall j\in V\backslash\left\{ o(r),\delta(r)\right\} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;• A rider can transfer between paths only if the paths intersect at the transfer point and the path the rider is leaving gets to the transfer point before the path the rider is joining leaves the transfer point:&lt;span class=&quot;math-container&quot;&gt;$$y_{r,e,p}+y_{r,e',p'}\le1+\alpha_{p,p',i}$$&lt;/span&gt; where the constraint is enforced &lt;span class=&quot;math-container&quot;&gt;$\forall r\in R,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i\in V,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall e=(h,i)\in E,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall e'=(i,j)\in E,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall p\in P:e\in p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\forall p'\in P:e'\in p'.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-05T22:04:41.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10269" PostTypeId="1" CreationDate="2023-04-05T22:25:41.220" Score="1" ViewCount="39" Body="&lt;p&gt;I am investigating an optimization problem under uncertainty and am using scenario-based robust optimization to deal with uncertainties. I have developed a heuristic approach in which I can set the number of scenarios to large values. For example, I am currently using 1,000 randomly generated scenarios, and the algorithm seems efficient for large-scale instances in terms of CPU time. Commercial solvers might not be computationally efficient when the number of scenarios is large.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering what scientific and systematic approaches would be recommended for determining the number of scenarios in a scenario-based optimization algorithm.&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="5598" LastEditDate="2023-04-05T23:04:14.923" LastActivityDate="2023-04-06T00:02:51.740" Title="Number of scenarios in non-deterministic optimization methods" Tags="|optimization|robust-optimization|uncertainty|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10270" PostTypeId="2" ParentId="10269" CreationDate="2023-04-06T00:02:51.740" Score="1" Body="&lt;p&gt;Generally if aiming for robust I'd try to get scenarios that would fall within 95% (95th percentile if distribution is discrete) of cases or choose the worst-case scenarios. Depending upon distribution you can constrain your relations to satisfy cases in that chosen range (chance constrained).&lt;br /&gt;&#xA;Other than that, sample average approximation is used where may be N samples are generated &amp;amp; average of those samples is taken as the parameter.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-04-06T00:02:51.740" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10271" PostTypeId="2" ParentId="10261" CreationDate="2023-04-06T00:18:51.383" Score="3" Body="&lt;p&gt;Suppose that &lt;span class=&quot;math-container&quot;&gt;$F: R^{n} \rightarrow R^{n}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$F(x)=b$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is differentiable at &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; with non-singular Jacobian &lt;span class=&quot;math-container&quot;&gt;$J(x)$&lt;/span&gt;.  Then to first order, we can use the Jacobian to find a change &lt;span class=&quot;math-container&quot;&gt;$\Delta x$&lt;/span&gt; due to a small change &lt;span class=&quot;math-container&quot;&gt;$\Delta b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$F(x+\Delta x)=b+\Delta b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$F(x)+J(x)\Delta x=b+\Delta b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\Delta x=J(x)^{-1} \Delta b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This is exact only in the limit as &lt;span class=&quot;math-container&quot;&gt;$\Delta b$&lt;/span&gt; goes to 0, but it tells you  that the partial derivatives of &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; with respect to &lt;span class=&quot;math-container&quot;&gt;$b_{j}$&lt;/span&gt; are given by&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\frac{\partial x_{i} }{\partial b_{j}}=(J(x)^{-1})_{i,j}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now suppose that you've got a smooth optimization problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min f(x)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_{i}(x)=b_{i}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i=1, 2, \ldots, m$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and that you have found an optimal solution &lt;span class=&quot;math-container&quot;&gt;$x^{*}$&lt;/span&gt; and also solved the KKT conditions.  The KKT conditions are of the form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$K(x^{*},\lambda^{*})=0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;including the specific constraint equations&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_{i}(x^{*})-b_{i}=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i=1, 2, \ldots, m$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and the Lagrange multiplier constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\nabla f(x^{*}) + \sum_{i=1}^{m} \lambda_{i}^{*} \nabla h_{i}(x^{*})=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can now find the Jacobian of &lt;span class=&quot;math-container&quot;&gt;$K(x^{*},\lambda^{*})$&lt;/span&gt; and invert it to get the sensitivity of &lt;span class=&quot;math-container&quot;&gt;$x^{*}$&lt;/span&gt; with respect to changes in &lt;span class=&quot;math-container&quot;&gt;$b_{i}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that in order to do this you'll have to look at the &lt;em&gt;second derivatives&lt;/em&gt; of &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; and the &lt;span class=&quot;math-container&quot;&gt;$h_{i}(x)$&lt;/span&gt; since &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; already involves the first derivatives.&lt;/p&gt;&#xA;&lt;p&gt;You can easily extend this to problems with inequality constraints.&lt;/p&gt;&#xA;&lt;p&gt;A good book that discusses this is:&lt;/p&gt;&#xA;&lt;p&gt;Bonnans, J. Frédéric, and Alexander Shapiro. &lt;em&gt;Perturbation Analysis of Optimization Problems&lt;/em&gt;. Springer, 2013.&lt;/p&gt;&#xA;" OwnerUserId="103" LastEditorUserId="103" LastEditDate="2023-04-06T00:30:03.680" LastActivityDate="2023-04-06T00:30:03.680" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10272" PostTypeId="2" ParentId="10164" CreationDate="2023-04-06T06:20:43.833" Score="0" Body="&lt;p&gt;After a decent research, I found that the tiered order amount can be implemented easily by using &amp;quot;Model.addGenConstrPWL()&amp;quot; from gurobi which is a general constraints for Piecewise function.&lt;/p&gt;&#xA;&lt;p&gt;Below is a link for anyone that wants to take a look!&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/9.1/refman/py_model_agc_pwl.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/9.1/refman/py_model_agc_pwl.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, another useful link is below if your piecewise function input is the sum of other variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360077610571-A-weird-output-is-it-a-bug-of-Gurobi-8-1-1-&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://support.gurobi.com/hc/en-us/community/posts/360077610571-A-weird-output-is-it-a-bug-of-Gurobi-8-1-1-&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2023-04-06T06:20:43.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10273" PostTypeId="1" CreationDate="2023-04-06T16:11:41.870" Score="2" ViewCount="131" Body="&lt;p&gt;I have a multivariable function (9 variables), and I want to find where the function records a minimum value. The function is as follows:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ygj4p.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ygj4p.png&quot; alt=&quot;https://i.stack.imgur.com/ygj4p.png&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It also has a few constraints:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/1FgPv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1FgPv.png&quot; alt=&quot;https://i.stack.imgur.com/1FgPv.png&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/TIH4K.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TIH4K.png&quot; alt=&quot;https://i.stack.imgur.com/TIH4K.png&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/enyj4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/enyj4.png&quot; alt=&quot;https://i.stack.imgur.com/enyj4.png&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I tried a brute force algorithm, but because of 9 variables, it has a really high time complexity, and will take a long time to run. Is there a much better way to do this?&lt;/p&gt;&#xA;" OwnerUserId="11598" LastActivityDate="2023-04-06T19:20:42.293" Title="Finding the minima of a multivariable function with constraints" Tags="|optimization|algorithms|constrained-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10274" PostTypeId="1" CreationDate="2023-04-06T16:38:42.077" Score="2" ViewCount="46" Body="&lt;p&gt;I am seeking help on how to perform Monte Carlo simulations on (potentially) correlated time series.  I have a single product (e.g., men's wallets) that are sold out of seven stores in the same city. I have last year's daily sales of wallets for each store.  Most days, a store sold zero, some days they sold one, fewer days they sold two... the histogram resembles an exponential distribution.&lt;/p&gt;&#xA;&lt;p&gt;I want to be able to use last year's sales, to simulate the potential combined sales of the seven stores.  (Assume no sales growth year on year). I am wary of just sampling each store's daily sales independently and combining them into a new RV, as there may be some correlation, and some seasonality, of the sales.  Ideally I'd be able to simulate a range of the combined sales for January 1, a range of the combined sales for January 2, .... a range of the combined sales for December 31; that takes into account potential correlation and seasonality of the sales.  Bonus points if you can point me to some R functions that do this.&lt;/p&gt;&#xA;&lt;p&gt;It's important to note that I'm not looking to forecast a time series, but rather understand potential range of the 7 stores' sales in sum, based upon variability in the existing 7 stores' time series of sales.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastActivityDate="2023-04-06T16:38:42.077" Title="Monte Carlo simulation of (potentially) correlated multiple time series" Tags="|simulation|supply-chain|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10275" PostTypeId="2" ParentId="10273" CreationDate="2023-04-06T19:20:42.293" Score="1" Body="&lt;p&gt;I'm not sure there is a way to guarantee a global optimum. If you are willing to settle for a local optimum, you could try a &lt;a href=&quot;https://en.wikipedia.org/wiki/Penalty_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;penalty method&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For instance, you could square the difference between left and right side of each constraint, sum the squared differences, multiply by a positive parameter value (which I will call the penalty weight) and add that to the original objective function. That gives you an unconstrained problem, on which you could try something like gradient descent. If the solution to which it converged violated any constraints by more than an acceptable amount of rounding error, you would increase the penalty weight and try again, until you got a solution that was close enough to satisfying all constraints.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-06T19:20:42.293" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10277" PostTypeId="2" ParentId="10263" CreationDate="2023-04-07T15:37:21.630" Score="0" Body="&lt;p&gt;As you already guessed, these are rather coding issues than solver issues.&lt;/p&gt;&#xA;&lt;p&gt;Regarding the pyomo model: Both &lt;code&gt;m.pred&lt;/code&gt; and &lt;code&gt;m.PAIRS&lt;/code&gt; in your linked MWE are empty. DiGraph's &lt;a href=&quot;https://networkx.org/documentation/stable/reference/classes/generated/networkx.DiGraph.predecessors.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;predecessor method&lt;/a&gt; returns an iterator and expects the node &lt;code&gt;n&lt;/code&gt; as argument whose predecessors you'd like to iterate over. That's why&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;predecessors = numpy.array(G.predecessors)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;is just a numpy array of a method and not an iterator. So it doesn't make sense in your case. Since you can initialize Pyomo Sets from any &lt;em&gt;Iterable&lt;/em&gt;, you can use a simple list instead of an iterator:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;predecessors = list(list(G.predecessors(node)) for node in G.nodes())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then, &lt;code&gt;predecessors[i-1]&lt;/code&gt; gives you all the direct predecessor nodes of the node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; as Python uses zero-based indexing and your graph nodes start with 1. Alternatively, you can easily create a dict such that &lt;code&gt;predecessors[i, j]&lt;/code&gt; gives you the direct predecessor nodes of the nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, i.e. the edge &lt;span class=&quot;math-container&quot;&gt;$(i, j)$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;predecessors = {(i,j): list(G.predecessors(i)) + list(G.predecessors(j)) for (i,j) in S}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Regarding the DocPlex model it's not really clear what &lt;code&gt;if (i, j) in enumerate(S)&lt;/code&gt; is expected to do. &lt;code&gt;enumerate&lt;/code&gt; is just an iterator (not a list!) that gives you the index of each edge in S and the edge stored in a python list.&lt;/p&gt;&#xA;&lt;p&gt;Depending on what &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$\forall(i, j) \in \text{Precedessors}$&lt;/span&gt;&amp;quot; means (it's a bit vague, IMO), the above tips may be helpful in getting you back on track.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2023-04-07T15:37:21.630" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10278" PostTypeId="1" AcceptedAnswerId="10281" CreationDate="2023-04-07T15:40:40.490" Score="2" ViewCount="135" Body="&lt;p&gt;TLDR: Why does ADMM diverge when solving &lt;span class=&quot;math-container&quot;&gt;$\ell_1$&lt;/span&gt; regression?&lt;/p&gt;&#xA;&lt;h2&gt;Introduction&lt;/h2&gt;&#xA;&lt;p&gt;I am learning about convex optimisation and wanted to solve a simple exercise that I am having issues with. I want to solve a &lt;span class=&quot;math-container&quot;&gt;$\ell_1$&lt;/span&gt; regression using ADMM (Alternating Direction Method of Multiplies, &lt;a href=&quot;https://stanford.edu/%7Eboyd/admm.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://stanford.edu/~boyd/admm.html&lt;/a&gt;). Not because I have to, but because I want to try it and have a little fun.&lt;/p&gt;&#xA;&lt;h2&gt;Problem set up&lt;/h2&gt;&#xA;&lt;p&gt;The problem is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_\beta \|X\beta -y \|_1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; has dimensions &lt;span class=&quot;math-container&quot;&gt;$N \times D$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;-dimensional vector and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; has length &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What I wanted to try is using an augmented variable &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; to make the problem linear. That is, I want to solve&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{\alpha, \beta} \alpha^\top 1_N \quad \text{s.t.} \quad X\beta-y \leq \alpha \quad \text{and} \quad -X\beta + y \leq \alpha $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;these constraints are quivalent to &lt;span class=&quot;math-container&quot;&gt;$|X\beta-y| \leq \alpha$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I now write down the Augmented Lagrangian:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\mathcal{L}=\alpha^\top 1_N + \lambda_1 (\alpha-X\beta+y) + \lambda_2 (\alpha+X\beta-y) + \rho_1/2 \|\alpha-X\beta+y\|_2^2 + \rho_2/2 \|\alpha+X\beta-y\|_2^2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$\lambda_1 \leq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda_2 \leq 0$&lt;/span&gt; (Constraint should be positive, so during minimisation the &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;s should be negative. See Bishop, Pattern Recognition Appendix).&lt;/p&gt;&#xA;&lt;p&gt;I initialise:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\rho_1 \leftarrow 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\rho_2 \leftarrow 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lambda_1 \leftarrow 1_N$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lambda_2 \leftarrow 1_N$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\alpha \leftarrow |X\beta-y|$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now I update in the following order:&lt;/p&gt;&#xA;&lt;p&gt;We solve &lt;span class=&quot;math-container&quot;&gt;$\nabla_\beta \mathcal{L}=0$&lt;/span&gt; and use the pseudo inverse (same as OLS estimator) to get&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\beta \leftarrow \frac{1}{\lambda_1-\lambda_2 + \rho_1 - \rho_2} (X^\top X)^{-1}X^\top \left[\lambda_1 (\alpha + y) + \lambda_2 (\alpha - y) + \rho_1 (\alpha + y) + \rho_2 (\alpha - y) \right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We solve &lt;span class=&quot;math-container&quot;&gt;$\nabla_\alpha \mathcal{L}=0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\alpha \leftarrow - \frac{1}{\rho_1 + \rho_2} \left[1_N + \lambda_1 + \lambda_2 +(\rho_2-\rho_1) (X \beta - y) \right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Next the dual ascent on &lt;span class=&quot;math-container&quot;&gt;$\lambda_1$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\lambda_1 \leftarrow \max \{\lambda_1 + \rho_1 (\alpha-X\beta+y), 0\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and &lt;span class=&quot;math-container&quot;&gt;$\lambda_2$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\lambda_2 \leftarrow \max \{ \lambda_2 + \rho_2 (\alpha+X\beta-y), 0 \}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h2&gt;The Issue&lt;/h2&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; grows to &lt;span class=&quot;math-container&quot;&gt;$-\infty$&lt;/span&gt; quite quickly and the loss goes to &lt;span class=&quot;math-container&quot;&gt;$\infty$&lt;/span&gt;. I can't seem to make it stop. What am I doing wrong? I tried playing with hyperparameters.&lt;/p&gt;&#xA;&lt;p&gt;Edit: &lt;a href=&quot;https://colab.research.google.com/drive/1dXOHCGGTZ9dlhuwBMp9rbJZ6BTat7ObN?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google Colab Notebook&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10594" LastEditorUserId="10594" LastEditDate="2023-04-07T15:46:41.953" LastActivityDate="2023-04-11T00:22:49.947" Title="ADMM diverges on L1 regression" Tags="|convex-optimization|lagrange-multipliers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10279" PostTypeId="1" CreationDate="2023-04-07T17:46:37.070" Score="5" ViewCount="429" Body="&lt;p&gt;So a while back I had asked this question: &lt;a href=&quot;https://or.stackexchange.com/questions/5167/is-there-a-linear-programming-library-that-natively-supports-fractions-instead-o&quot;&gt;Is there a Linear Programming Library that natively supports fractions instead of floating point arithmetic?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And basically the overwhelming consensus was that the best libraries for exact linear programming were:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;QSOPT-Exact&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;GLPK&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;and there were a few others. So I wanted libraries that are nicely compatible with python3 on a mac os.&lt;/p&gt;&#xA;&lt;p&gt;I started with QSOPT-Exact, which I installed via the two links below&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/jonls/qsopt-ex&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/jonls/qsopt-ex&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/jonls/python-qsoptex&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/jonls/python-qsoptex&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This library has worked well for me in the past but today it seems like it has a segfault (this might be due to Mac OS) which I raised as an issue here: &lt;a href=&quot;https://github.com/jonls/python-qsoptex/issues/8&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/jonls/python-qsoptex/issues/8&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now the next option was GLPK and I was able get GLPK working with python3 by installing&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;brew install glpk&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;python3 -m pip install PuLP&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;But while GLPK can be called via the exact flag it does not output rationals but rather a floating point representation of the exact result. See here:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DA9Wr.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DA9Wr.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And heres the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from fractions import Fraction&#xA;&#xA;prob = pulp.LpProblem(&amp;quot;sidsproblem&amp;quot;, pulp.LpMaximize)&#xA;&#xA;x1 = pulp.LpVariable(&amp;quot;x_1&amp;quot;,0,1)&#xA;x2 = pulp.LpVariable(&amp;quot;x_2&amp;quot;,0,1)&#xA;&#xA;prob += x1 + x2&#xA;prob += (5*x1 + 4*x2 &amp;lt;= 1)&#xA;prob += (4*x1 - 11*x2 &amp;lt;= -1)&#xA;prob += (x1 &amp;lt;= 0.23)&#xA;prob += (x2 &amp;lt;= Fraction(2,9))&#xA;prob.writeLP(&amp;quot;sidsproblem2.lp&amp;quot;)&#xA;&#xA;prob.solve(pulp.GLPK(options=['--exact']))&#xA;&#xA;for v in prob.variables():&#xA;    print(v.name, &amp;quot;=&amp;quot;, v.varValue)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So clearly GLPK is doing exact arithmetic but the interface which talks to python3 hands python3 a float as opposed to a rational. Which defeats the point on my end.&lt;/p&gt;&#xA;&lt;p&gt;Which now makes me wonder, what high quality WORKING implementations of exact linear programming libraries exist for python3? It seems like the options are few and limited now and I wanted to know what any of you have successfully used in the past year.&lt;/p&gt;&#xA;" OwnerUserId="1239" LastActivityDate="2023-07-02T04:23:14.860" Title="What are my options for exact linear programming solvers in python3 that work as of April 2023?" Tags="|linear-programming|python|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10280" PostTypeId="1" CreationDate="2023-04-08T16:18:49.247" Score="1" ViewCount="36" Body="&lt;p&gt;I have the following constraint for robust counterpart formulation, where two uncertain parameters appear at the same time;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum{QG_{ij}}$&lt;/span&gt;*&lt;span class=&quot;math-container&quot;&gt;${\theta}$&lt;/span&gt;+&lt;span class=&quot;math-container&quot;&gt;$\sum_{}\sum{QD_{ij}}*p $&lt;/span&gt; * &lt;span class=&quot;math-container&quot;&gt;${\theta}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where;&#xA;&lt;span class=&quot;math-container&quot;&gt;${QG}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;${QD}$&lt;/span&gt; are decision variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${p}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;${\theta}$&lt;/span&gt; are uncertain parameters.&lt;/p&gt;&#xA;&lt;p&gt;In order to overcome the issue of the two parameters in the second term, I defined an auxiliary parameter, let it be;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\beta}$&lt;/span&gt;= &lt;span class=&quot;math-container&quot;&gt;${p}$&lt;/span&gt; * &lt;span class=&quot;math-container&quot;&gt;${\theta}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then the constraint becomes;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum{QG_{ij}}$&lt;/span&gt;*&lt;span class=&quot;math-container&quot;&gt;${\theta}$&lt;/span&gt;+&lt;span class=&quot;math-container&quot;&gt;$\sum_{}\sum{QD_{ij}}$&lt;/span&gt; * &lt;span class=&quot;math-container&quot;&gt;${\beta}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am wondering if this simplification is valid or not.&lt;/p&gt;&#xA;" OwnerUserId="11004" LastEditorUserId="11004" LastEditDate="2023-04-12T20:22:11.933" LastActivityDate="2023-04-12T20:22:11.933" Title="Auxiliary parameters for two uncertain parameters Robust Optimization" Tags="|optimization|mixed-integer-programming|modeling|robust-optimization|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10281" PostTypeId="2" ParentId="10278" CreationDate="2023-04-08T17:35:52.390" Score="2" Body="&lt;p&gt;ADMM assumes that the constraints being added as penalties are equality constraints. In your reformulation of the l1 objective into inequality constraints i.e., &lt;span class=&quot;math-container&quot;&gt;$X\beta - y \leq \alpha$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$-X \beta + y \leq \alpha $&lt;/span&gt;, you first have to convert those inequality constraints into equality constraints using slack variables and then dualize those equalities.&lt;/p&gt;&#xA;" OwnerUserId="972" LastActivityDate="2023-04-08T17:35:52.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10282" PostTypeId="1" AcceptedAnswerId="10284" CreationDate="2023-04-08T21:25:52.610" Score="1" ViewCount="65" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A} \in \mathbb{R}^{n \times n}$&lt;/span&gt;. I'm working in a problem where I have a black-box algorithmic solution to compute the products &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}\mathbf{x}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}^T \mathbf{x}$&lt;/span&gt; given an input &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x} \in \mathbb{R}^n$&lt;/span&gt;. Given that I can't access the value of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}$&lt;/span&gt; directly, what are some examples of algorithms for solving the regularized linear least square problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA; \min_{\mathbf{x}} \frac{1}{2} \| \mathbf{y} - \mathbf{A} \mathbf{x}\|^2 + \lambda \phi(\mathbf{x})&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;that only rely in the computation of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}\mathbf{x}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}^T\mathbf{x}$&lt;/span&gt;? Here, &lt;span class=&quot;math-container&quot;&gt;$\lambda &amp;gt;0$&lt;/span&gt; is a given regularization parameter. I'm more interested in the likelihood &lt;span class=&quot;math-container&quot;&gt;$ \frac12 \|\mathbf{y} -  \mathbf{A} \mathbf{x}\|^2$&lt;/span&gt; updates so we can assume pretty much anything we want for &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; for the sake of this question. If it makes the problem more concrete, you can assume that &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; is convex lower semicontinuous, so that &lt;span class=&quot;math-container&quot;&gt;$\text{prox}_{\lambda\phi}$&lt;/span&gt; exists and is single valued.&lt;/p&gt;&#xA;&lt;p&gt;For instance, if &lt;span class=&quot;math-container&quot;&gt;$\phi$&lt;/span&gt; is differentiable, given a stepsize &lt;span class=&quot;math-container&quot;&gt;$\mu&amp;gt;0$&lt;/span&gt;, the gradient descent update&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\mathbf{x}^{i+1} &amp;amp;= \mathbf{x^i} - \mu \mathbf{A}^T(\mathbf{A}\mathbf{x^i} - \mathbf{y}) - \mu \lambda \nabla \phi(\mathbf{x^i})&#xA;\end{align}&lt;/span&gt;&#xA;can be implemented in my system. What are some other examples?&lt;/p&gt;&#xA;" OwnerUserId="11607" LastActivityDate="2023-04-09T07:52:36.070" Title="Solving regularized least squares problem using black-box computation of $\mathbf{A}\mathbf{x}$ and $\mathbf{A}^T\mathbf{x}$" Tags="|optimization|convex-optimization|linear-algebra|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10283" PostTypeId="2" ParentId="10282" CreationDate="2023-04-08T23:35:45.763" Score="0" Body="&lt;p&gt;If, say, &lt;span class=&quot;math-container&quot;&gt;$\phi()$&lt;/span&gt; is convex (so that a global min for the objective exists) but is not smooth, you could use the &lt;a href=&quot;https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nelder-Mead algorithm&lt;/a&gt; or one of the variations of it. It requires objective function evaluations only (no gradients). There are some other gradient-free optimization methods as well.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-08T23:35:45.763" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10284" PostTypeId="2" ParentId="10282" CreationDate="2023-04-09T07:52:36.070" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Conjugate_gradient_method#Conjugate_gradient_on_the_normal_equations&quot; rel=&quot;nofollow noreferrer&quot;&gt;conjugate gradient method&lt;/a&gt; works quite well on least square problems and is easy to implement. With a simple line search, it should be much better than a simple gradient descent.&lt;/p&gt;&#xA;&lt;p&gt;There are many other iterative methods to solve linear least-square problems (&lt;a href=&quot;https://web.stanford.edu/group/SOL/software/lsmr/&quot; rel=&quot;nofollow noreferrer&quot;&gt;a starting point&lt;/a&gt;). They usually consider &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; a blackbox, but they assume a quadratic regularization. You may be able to apply the same tricks to your problem (presolving mostly), but those are a bit more involved.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2023-04-09T07:52:36.070" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10285" PostTypeId="2" ParentId="10278" CreationDate="2023-04-09T11:15:35.353" Score="2" Body="&lt;p&gt;I implemented @batwing's suggestion and it works. Let &lt;span class=&quot;math-container&quot;&gt;$\phi_1 \geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\phi_2 \geq 0$&lt;/span&gt; be slack variables (which we initialise to &lt;span class=&quot;math-container&quot;&gt;$0_N$&lt;/span&gt;), the Lagrangian becomes:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\mathcal{L}=\alpha^\top 1_N + \lambda_1^\top (\alpha-X\beta+y-\phi_1) + \lambda_2^\top(\alpha+X\beta-y-\phi_2) + \rho_1/2 \|\alpha-X\beta+y-\phi_1\|_2^2 + \rho_2/2 \|\alpha+X\beta-y-\phi_2\|_2^2$$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$\phi_1 \geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\phi_2 \geq 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The update for &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; becomes:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\beta \leftarrow - \frac{1}{\rho_1 + \rho_2} (X^\top X)^{-1}X^\top \left[ (\lambda_2 - \lambda_2) - \rho_1(\alpha + y - \phi_1) + \rho_2 (\alpha-y-\phi_2) \right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The update for &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; becomes:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\alpha \leftarrow - \frac{1}{\rho_1 + \rho_2} \left[1_N + \lambda_1 + \lambda_2 +(\rho_2-\rho_1) (X \beta - y) - \rho_1 \phi_1 - \rho_2 \phi_2 \right]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Solve for &lt;span class=&quot;math-container&quot;&gt;$\phi_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\phi_2$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\phi_1 \leftarrow \max\left(0, \frac{1}{\rho_1}\lambda_1 + \alpha - X\beta + y \right)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\phi_2 \leftarrow \max\left(0, \frac{1}{\rho_1}\lambda_1 + \alpha + X\beta - y \right)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And then we perform dual ascent on dual and slack variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\lambda_1 \leftarrow \lambda_1 + \rho_1 (\alpha-X\beta+y-\phi_1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lambda_2 \leftarrow \lambda_2 + \rho_2 (\alpha+X\beta-y-\phi_2)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And now it works :)&lt;/p&gt;&#xA;" OwnerUserId="10594" LastEditorUserId="10594" LastEditDate="2023-04-11T00:22:49.947" LastActivityDate="2023-04-11T00:22:49.947" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="10286" PostTypeId="2" ParentId="10279" CreationDate="2023-04-10T04:09:46.840" Score="4" Body="&lt;p&gt;SCIP has an exact linear solver; it's still in development, but it should be more or less easy to use.&lt;/p&gt;&#xA;&lt;p&gt;First, install SCIP with the exact solver: &lt;a href=&quot;https://github.com/leoneifler/exact-SCIP&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/leoneifler/exact-SCIP&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, in PuLP (because you are using it), give the path to this installation of SCIP, plus an option for using the exact solver (&lt;code&gt;exact/exact_enabled&lt;/code&gt;): &lt;a href=&quot;https://coin-or.github.io/pulp/technical/solvers.html#pulp.apis.SCIP&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://coin-or.github.io/pulp/technical/solvers.html#pulp.apis.SCIP&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="156" LastActivityDate="2023-04-10T04:09:46.840" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10287" PostTypeId="2" ParentId="10279" CreationDate="2023-04-10T09:54:31.640" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://developers.google.com/optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google OR tools&lt;/a&gt; is the other option if you have not explored it. You can model IP or MIP using google or tools, it has very good python interface with good documentation. you can use open source solver like scip, clp, cbc, glop to solve LP - &lt;a href=&quot;https://ttps://developers.google.com/optimization/lp/lp_example&quot; rel=&quot;nofollow noreferrer&quot;&gt;example link&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;OR tools also gives flexibility to integrate your choice of solver - &lt;a href=&quot;https://developers.google.com/optimization/lp/lp_advanced&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://developers.google.com/optimization/lp/lp_advanced&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="208" LastActivityDate="2023-04-10T09:54:31.640" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10288" PostTypeId="1" CreationDate="2023-04-10T18:36:18.123" Score="3" ViewCount="296" Body="&lt;p&gt;I am working on a scheduling problem that is already coded in Pyomo. To solve the problem, I have used the NEOS solver, CPLEX. Now, to test and run some of the instances, I need to call some CPLEX internal options like, mipgap, branching priority, warm-start, solver log, etc. I also tried some functions to do this, but a few of them can work fine in a robust way, specifically, when needs to invoke the solution after the optimization terminates. The method I am currently using is something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;results = solver_manager.solve(m, solver = &amp;quot;cplex&amp;quot;, tee= True, keepfiles=True, logfile = &amp;quot;log.txt&amp;quot;, options_string=&amp;quot;mipgap=0.1&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;At the moment, this method can only handle &lt;code&gt;solver = &amp;quot;cplex&amp;quot;&lt;/code&gt; and &lt;code&gt;options_string=&amp;quot;mipgap=0.1&amp;quot;&lt;/code&gt;. Also, Pyomo documents contain cplex options, but it has not been mentioned (at least I can't find) how those can be applied when one would like to use NEOS. My question is, &lt;em&gt;&lt;strong&gt;is there any robust way to use CPLEX internal options when it is called by NEOS?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-09-08T23:02:15.307" Title="Solver options in Pyomo as long as using the NEOS solvers" Tags="|python|solver|pyomo|modeling-languages|neos|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10289" PostTypeId="1" CreationDate="2023-04-11T08:52:35.170" Score="2" ViewCount="149" Body="&lt;p&gt;When I used Column Generation, I found a column with reduced cost &amp;lt; 0, and added it to the Restricted Master Problem.&lt;/p&gt;&#xA;&lt;p&gt;Must the newly added column be used in the solution of RMP at once?  If not, then why this reduced cost does not work to the objective of RMP?&lt;/p&gt;&#xA;&lt;p&gt;e.g.&#xA;Suppose &lt;span class=&quot;math-container&quot;&gt;$z_1, z_2, z_3 $&lt;/span&gt; are initial columns, we have a RMP below,&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$P_1:\min {3 z_1 + 4 z_2 + 9 z_3} $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;strong&gt;s.t.&lt;/strong&gt;&lt;br /&gt;&#xA;Constraint a: &lt;span class=&quot;math-container&quot;&gt;$z_1 + z_2 + z_3 = 2$&lt;/span&gt;&lt;br /&gt;&#xA;Constraint b:   &lt;span class=&quot;math-container&quot;&gt;$z_1 + 2 z_3 = 1$&lt;/span&gt;&lt;br /&gt;&#xA;Constraint c:   &lt;span class=&quot;math-container&quot;&gt;$z_2 + 0.5 z_3 = 1$&lt;/span&gt;&lt;br /&gt;&#xA;If we solve this model directly, the objective value should be 7, and the dual values should be &lt;span class=&quot;math-container&quot;&gt;$\pi_a = -2/3, \pi_b = 11/3, \pi_c = 14/3$&lt;/span&gt;.&lt;br /&gt;&#xA;Then if we find a new column &lt;span class=&quot;math-container&quot;&gt;$z_4$&lt;/span&gt;, with the cost equals to 3.5&lt;br /&gt;&#xA;As the reduced cost should be 3.5 - 11/3 - 14/3 + 2/3 &amp;lt; 0, so it will be added to RMP.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$P_2:\min {3 z_1 + 4 z_2 + 9 z_3 + 3.5 z_4} $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;strong&gt;s.t.&lt;/strong&gt;&lt;br /&gt;&#xA;Constraint a: &lt;span class=&quot;math-container&quot;&gt;$z_1 + z_2 + z_3 + z_4 = 2$&lt;/span&gt;&lt;br /&gt;&#xA;Constraint b:   &lt;span class=&quot;math-container&quot;&gt;$z_1 + 2 z_3 + z_4 = 1$&lt;/span&gt;&lt;br /&gt;&#xA;Constraint c:   &lt;span class=&quot;math-container&quot;&gt;$z_2 + 0.5 z_3 + z_4 = 1$&lt;/span&gt;&lt;br /&gt;&#xA;when &lt;span class=&quot;math-container&quot;&gt;$z_4$&lt;/span&gt; is added, it cannot be used instantly.&#xA;The newly solution will be &lt;span class=&quot;math-container&quot;&gt;$z_1 = 1, z_2 = 1$&lt;/span&gt;, the Obj value of RMP not changed and the newly column &lt;span class=&quot;math-container&quot;&gt;$z_4$&lt;/span&gt; not used.&lt;br /&gt;&#xA;&lt;strong&gt;While&lt;/strong&gt; if we changed the equal signs in the constraint to Greater than or equal signs.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$P_3:\min {3 z_1 + 4 z_2 + 9 z_3} $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;strong&gt;s.t.&lt;/strong&gt;&lt;br /&gt;&#xA;Constraint a: &lt;span class=&quot;math-container&quot;&gt;$z_1 + z_2 + z_3 &amp;gt;= 2$&lt;/span&gt;&lt;br /&gt;&#xA;Constraint b:   &lt;span class=&quot;math-container&quot;&gt;$z_1 + 2 z_3 &amp;gt;= 1$&lt;/span&gt;&lt;br /&gt;&#xA;Constraint c:   &lt;span class=&quot;math-container&quot;&gt;$z_2 + 0.5 z_3 &amp;gt;= 1$&lt;/span&gt;&lt;br /&gt;&#xA;and &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$P_4:\min {3 z_1 + 4 z_2 + 9 z_3 + 3.5 z_4} $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;strong&gt;s.t.&lt;/strong&gt;&lt;br /&gt;&#xA;Constraint a: &lt;span class=&quot;math-container&quot;&gt;$z_1 + z_2 + z_3 + z_4 &amp;gt;= 2$&lt;/span&gt;&lt;br /&gt;&#xA;Constraint b:   &lt;span class=&quot;math-container&quot;&gt;$z_1 + 2 z_3 + z_4 &amp;gt;= 1$&lt;/span&gt;&lt;br /&gt;&#xA;Constraint c:   &lt;span class=&quot;math-container&quot;&gt;$z_2 + 0.5 z_3 + z_4 &amp;gt;= 1$&lt;/span&gt; &lt;br /&gt;&#xA;Now the newly column &lt;span class=&quot;math-container&quot;&gt;$z_4$&lt;/span&gt; will be used and make the new obj becomes 6.5.&lt;/p&gt;&#xA;&lt;p&gt;My question becomes, In &lt;span class=&quot;math-container&quot;&gt;$P_1 \&amp;amp; P_2$&lt;/span&gt;, do the newly column &lt;span class=&quot;math-container&quot;&gt;$z_4$&lt;/span&gt; enter the basis? If do, why the value of &lt;span class=&quot;math-container&quot;&gt;$z_4$&lt;/span&gt; if 0, is this situation right?&lt;/p&gt;&#xA;" OwnerUserId="11622" LastEditorUserId="11622" LastEditDate="2023-04-13T06:38:53.110" LastActivityDate="2023-04-13T06:38:53.110" Title="Must the Newly Generated Column be used in RMP in the Column Generation Method?" Tags="|linear-programming|column-generation|reduced-costs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10290" PostTypeId="2" ParentId="10289" CreationDate="2023-04-11T15:11:52.220" Score="5" Body="&lt;p&gt;I assume that you are minimizing. If you only add one column at a time, the new column should immediately enter the basis. If you add multiple columns with negative reduced costs before doing more pivots in the RMP, it is possible that one of the new columns might not make it into the basis due to some of the other new columns.&lt;/p&gt;&#xA;&lt;p&gt;One caveat has to do with what you mean by &amp;quot;used in the solution&amp;quot;. If you add a single new column, update and get a degenerate solution, it is possible that the new column might be in the basis but with value 0 (so not obviously basic if you just look at the variable values in the new solution).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-11T15:11:52.220" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10291" PostTypeId="1" AcceptedAnswerId="10294" CreationDate="2023-04-11T17:32:01.187" Score="2" ViewCount="108" Body="&lt;p&gt;I have a multi-period model in gurobipy with 7 types continuous decision variables and 1 type of binary (Thousands indexed total). The model solves properly and the solution has passed many validation tests so far. However, I noticed that some variables come back with a very small negative value (subscript 1x10-10). I could just round these up to 0 in the post processing but am concerned that this implies that there is an issue in my model. I do have large and small coefficients in my model currently.&lt;/p&gt;&#xA;&lt;p&gt;Is this something to be concerned about? If so, how can I resolve it?&lt;/p&gt;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="10747" LastActivityDate="2023-04-17T15:48:07.677" Title="Small negative decision variable returned in Gurobipy model" Tags="|mixed-integer-programming|linear-programming|python|gurobi|gurobipy|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10292" PostTypeId="1" CreationDate="2023-04-11T17:54:27.120" Score="1" ViewCount="52" Body="&lt;p&gt;I am trying to understand whether this intuition is true or false.&lt;/p&gt;&#xA;&lt;p&gt;Given a minimum spanning tree (MST) of an undirected positive graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Consider a MST &lt;span class=&quot;math-container&quot;&gt;$T\subseteq G$&lt;/span&gt;. Removing any single edge from &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; would generate two separate Steiner trees with nodes partitioned in &lt;span class=&quot;math-container&quot;&gt;$V_1,V_2$&lt;/span&gt;. Are these minimal Steiner trees for the subsets of terminals &lt;span class=&quot;math-container&quot;&gt;$V_1,V_2$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5523" LastEditorUserId="5523" LastEditDate="2023-04-11T22:56:07.550" LastActivityDate="2023-04-11T22:56:07.550" Title="Does cutting a minimum spanning tree generate two minimum Steiner tree?" Tags="|reference-request|graphs|spanning-trees|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10293" PostTypeId="2" ParentId="10291" CreationDate="2023-04-11T18:15:33.967" Score="0" Body="&lt;p&gt;You can refer to this &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/6099091201041-Variable-value-is-zero-but-Solver-reports-1e-17-for-it-&quot; rel=&quot;nofollow noreferrer&quot;&gt;answer&lt;/a&gt; from Gurobi support. Small differences depend upon numerical tolerances that can be finetuned using attributes as  FeasibilityTol, IntFeasTol, OptimalityTol that control numerical offsets for feasible, integer and optimal values.&lt;br /&gt;&#xA;more information available from Gurobi's &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/guidelines_for_numerical_i.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;manual&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-04-11T18:15:33.967" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10294" PostTypeId="2" ParentId="10291" CreationDate="2023-04-11T18:17:25.857" Score="5" Body="&lt;p&gt;A nonnegative decision variable having an &amp;quot;optimal&amp;quot; value of -1e-10 is not unusual, and should not be a problem, whether the variable is continuous, general integer, or binary (yes, binary variables are not necessarily exactly zero or one). So your procedure to adjust the returned value to exactly zero should be fine.&lt;/p&gt;&#xA;&lt;p&gt;However, having non-zero input data spanning a wade range of magnitudes, or not being within a small number of orders of magnitude of one, does have the potential to cause numerical difficulties in the solver, or to make the solver's assessment of the problem being (primal) infeasible or unbounded, be unreliable.  When using Gurobi, the solver can be instructed to be more numerically robust, at the expense of computation speed, by setting the &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/numericfocus.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;NumericFocus parameter&lt;/a&gt; to a value such as 2, or for the most extreme emphasis on numerical robustness, 3.&lt;/p&gt;&#xA;&lt;p&gt;When there is very large or small magnitude input data, it is better to try to re-scale the problem (by changing units) if possible, or chopping off &amp;quot;nuisance&amp;quot; coefficients which should be exactly zero, but are not due to the procedure used to generate the input data. But if this is not possible, consider setting the NumericFocus parameter to a high value if your non-zero input data does span a wide range of orders of magnitude.&lt;/p&gt;&#xA;&lt;p&gt;Gurobi staff member Silke Horn wrote in &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360056371732-What-does-Gurobi-do-for-different-values-of-the-NumericFocus-parameter-&quot; rel=&quot;nofollow noreferrer&quot;&gt;answer to a support question&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In general, we can say that the higher you set NumericFocus the more&#xA;careful Gurobi tries to be with numerics in the simplex algorithms,&#xA;presolve, barrier and crossover. We cannot give you all the details,&#xA;but here are some of the things that the NumericFocus parameter does:&#xA;It tightens tolerances such as the Markowitz tolerance, bounds on&#xA;redundant constraint detection or the step length for barrier. It also&#xA;makes Gurobi use less aggressive cuts. The higher the setting, the&#xA;tighter the tolerances. With NumericFocus=3, it also switches to quad&#xA;precision (Quad=1).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Here is a &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360074634731-Providing-integer-start-solution-drastically-increases-root-relaxation-computation-time?page=1#community_comment_360013490411&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi forum answer by a Gurobi staff member to a related question.&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The NumericFocus parameter automatically controls the quad precision&#xA;computation, the Markowitz Tolerance, and a few others. Since&#xA;NumericFocus automatically decides whether to use quad precision, it&#xA;is possible that setting the value to 2 or 1 will also enable it,&#xA;where a higher value favors the enabling more. If you want to&#xA;explicitly enable Quad Precision, you can set the Quad parameter.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-04-17T15:48:07.677" LastActivityDate="2023-04-17T15:48:07.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10295" PostTypeId="2" ParentId="10288" CreationDate="2023-04-11T21:23:06.460" Score="1" Body="&lt;p&gt;Have you tried passing options using a dictionary like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;SolverManagerFactory('neos').solve(m, solver='cplex', options={'mipgap':0.1, 'other_option':'other_option_value'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tested this locally with Ipopt options that I'm more familiar with and it seemed to work. I don't use NEOS regularly so I'm not sure if there is a way to get the full solver log back from NEOS to confirm that specific options were set but I compared the solution and termination condition when running Ipopt locally and through NEOS.&lt;/p&gt;&#xA;" OwnerUserId="583" LastActivityDate="2023-04-11T21:23:06.460" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10296" PostTypeId="2" ParentId="10292" CreationDate="2023-04-11T21:56:24.243" Score="1" Body="&lt;p&gt;I think the answer is yes, but I recommend triple-checking my logic. I assume by &amp;quot;positive graph&amp;quot; you mean positive edge weights.&lt;/p&gt;&#xA;&lt;p&gt;I'll equate a tree with a set of edges from &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; and use the notation &lt;span class=&quot;math-container&quot;&gt;$\ell(\hat{E})$&lt;/span&gt; to be the sum of the edge weights for any subset &lt;span class=&quot;math-container&quot;&gt;$\hat{E} \subseteq E$&lt;/span&gt; of edges. A key observation is that in an undirected graph with positive edge weights, any minimum weight subgraph covering all vertices must be acyclic (else you could reduce weight by removing a cycle), so a MST is a minimum weight connected cover of the vertices.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$T\subseteq E$&lt;/span&gt; be your MST, let &lt;span class=&quot;math-container&quot;&gt;$\bar{e}$&lt;/span&gt; be the edge you delete, and let &lt;span class=&quot;math-container&quot;&gt;$T_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T_2$&lt;/span&gt; be the resulting subtrees (so that &lt;span class=&quot;math-container&quot;&gt;$T=T_{1}\dot{\cup}\left\{ \bar{e}\right\} \dot{\cup}T_{2}$&lt;/span&gt;). Now suppose &lt;span class=&quot;math-container&quot;&gt;$T_1$&lt;/span&gt; is &lt;em&gt;not&lt;/em&gt; a Steiner tree for the terminals &lt;span class=&quot;math-container&quot;&gt;$V_1.$&lt;/span&gt; That means there is a set of nodes &lt;span class=&quot;math-container&quot;&gt;$\hat{V}\subseteq V_2$&lt;/span&gt; from the other subtree that you can &amp;quot;borrow&amp;quot; to produce a tree &lt;span class=&quot;math-container&quot;&gt;$\hat{T}$&lt;/span&gt; connecting all the nodes in &lt;span class=&quot;math-container&quot;&gt;$V_1\dot{\cup}\hat{V}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\ell(\hat{T}) &amp;lt; \ell(T_1).$&lt;/span&gt; In that case, the set of edges &lt;span class=&quot;math-container&quot;&gt;$E^* = \hat{T} \cup T_2$&lt;/span&gt; produces a connected graph (not necessarily a tree) covering all of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; (because all nodes in &lt;span class=&quot;math-container&quot;&gt;$V_1$&lt;/span&gt; are connected by &lt;span class=&quot;math-container&quot;&gt;$\hat{T},$&lt;/span&gt; all nodes in &lt;span class=&quot;math-container&quot;&gt;$V_2$&lt;/span&gt; are connected by &lt;span class=&quot;math-container&quot;&gt;$T_2,$&lt;/span&gt; and at least one node in &lt;span class=&quot;math-container&quot;&gt;$V_1$&lt;/span&gt; is connected to at least one node in &lt;span class=&quot;math-container&quot;&gt;$\hat{V} \subseteq V_2$&lt;/span&gt; via &lt;span class=&quot;math-container&quot;&gt;$\hat{T}$&lt;/span&gt;). The sum of the edge weights in &lt;span class=&quot;math-container&quot;&gt;$E^*$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$$\ell(E^*) = \ell(\hat{T}) + \ell(\hat{T_2}) &amp;lt; \ell(T_1) + \ell(T_2) = \ell(T),$$&lt;/span&gt;&#xA;contradicting &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; being a MST.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-11T21:56:24.243" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10297" PostTypeId="1" AcceptedAnswerId="10298" CreationDate="2023-04-11T22:43:18.430" Score="0" ViewCount="374" Body="&lt;p&gt;I have a binary indicator variable &lt;span class=&quot;math-container&quot;&gt;$i \in \{ 0, 1 \}$&lt;/span&gt; and an integer variable &lt;span class=&quot;math-container&quot;&gt;$c \in \mathbb{Z}$&lt;/span&gt;.&#xA;I am trying to come up with a formulation in which &lt;span class=&quot;math-container&quot;&gt;$i = 0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$c = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i = 1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$c \neq 0$&lt;/span&gt;.&#xA;However, I am having trouble accomplishing this.&#xA;I tried formulating it as the minimum of two functions but that was not successful.&#xA;I tried creating two different copies of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (one for if &lt;span class=&quot;math-container&quot;&gt;$c &amp;lt; 0$&lt;/span&gt; and one for if &lt;span class=&quot;math-container&quot;&gt;$c &amp;gt; 0$&lt;/span&gt;). However that did not prove fruitful either.&#xA;I also tried formulating it using step functions combined with minimizing two functions.&#xA;However that also failed.&#xA;Is there a trick to deal with such programs?&lt;/p&gt;&#xA;" OwnerUserId="11000" LastActivityDate="2023-04-12T00:42:31.203" Title="How to formulate an MIP so that a binary variable is 0 or 1 depending on whether another variable is nonzero?" Tags="|mixed-integer-programming|linear-programming|integer-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10298" PostTypeId="2" ParentId="10297" CreationDate="2023-04-11T23:04:42.317" Score="3" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$L \le c\le U$&lt;/span&gt; for some constants &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt;.  Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;L x + 0(1-i) + 1y \le c &amp;amp;\le -1 x + 0(1-i) + U y\\&#xA;x + (1-i) + y &amp;amp;= 1 \\&#xA;x, i, y &amp;amp;\in \{0,1\}&#xA;\end{align}&lt;/span&gt;&#xA;The three cases correspond to&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$(x,i,y)=(1,1,0)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c\in[L,-1]$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$(x,i,y)=(0,0,0)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c = 0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$(x,i,y)=(0,1,1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c\in[1,U]$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-04-12T00:42:31.203" LastActivityDate="2023-04-12T00:42:31.203" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10299" PostTypeId="1" AcceptedAnswerId="10301" CreationDate="2023-04-12T13:49:11.863" Score="7" ViewCount="319" Body="&lt;p&gt;I am interested in the following problem dealing with the optimization of traffic lights on the intersection illustrated below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zX8Hu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zX8Hu.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The goal is maximize the duration during which each movement &lt;span class=&quot;math-container&quot;&gt;$m\in M=\{a,...,j\}$&lt;/span&gt; has a green light, subject to the following constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;incompatible movements cannot be done simultaneously&lt;/li&gt;&#xA;&lt;li&gt;each movement has to have a green light for at least &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; seconds&lt;/li&gt;&#xA;&lt;li&gt;the duration of a complete cycle must equal &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; seconds&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;One strategy is to:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Consider the compatibility graph &lt;span class=&quot;math-container&quot;&gt;$G=(V,E)$&lt;/span&gt; (an edge exists between two movements if they can be done simultaneously):&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Q9kOt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Q9kOt.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Find a vertex cover of cliques (sets of pairwise compatible movements) ordered in a circular fashion:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/s6Zip.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/s6Zip.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Solve the following linear program: let &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt; be a continuous variable representing duration of green light for clique &lt;span class=&quot;math-container&quot;&gt;$K_i$&lt;/span&gt;, and maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_{m\in M}\sum_{i|m\in K_i} t_i$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\left\{\sum_i t_i=C,\sum_{i|m\in K_i} t_i \ge s \; \forall m\in M \right\}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I find Step 2 (order the maximal cliques in a circular fasion) to be a bit tedious and am trying to figure out a (mixed integer) linear formulation for this problem. Any suggestions are welcome.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-04-23T16:17:54.213" LastActivityDate="2023-04-23T16:17:54.213" Title="Traffic lights optimization" Tags="|mixed-integer-programming|modeling|graphs|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10300" PostTypeId="2" ParentId="10299" CreationDate="2023-04-12T15:27:02.307" Score="-1" Body="&lt;p&gt;I'd try by defining binary variables &lt;span class=&quot;math-container&quot;&gt;$ x$&lt;/span&gt; indexed on set of compatible edges &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; &amp;amp; time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; over set &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;. Also define a set of edges, F where simultaneous movement is possible. Then add constraints like:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ sx_{\epsilon,t-1} - \sum_{k=1}^{t-2}x_{\epsilon,k} \le sx_{\epsilon,t} \quad \forall \epsilon \in E \ \ \forall t$&lt;/span&gt;: ensures contiguous allocation of &lt;span class=&quot;math-container&quot;&gt;$\ge s$&lt;/span&gt; secs&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{\epsilon} x_{\epsilon,t} \le 1 \ \forall t \quad \forall \epsilon \in E\setminus F$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-04-12T15:27:02.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10301" PostTypeId="2" ParentId="10299" CreationDate="2023-04-12T15:54:47.707" Score="3" Body="&lt;p&gt;If a movement belongs to &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; cliques, then you want &lt;span class=&quot;math-container&quot;&gt;$c-1$&lt;/span&gt; of those cliques to be followed by another clique from the same set.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; be the number of cliques and let &lt;span class=&quot;math-container&quot;&gt;$H_m=\lbrace i : m\in K_i\rbrace$&lt;/span&gt; for all movements &lt;span class=&quot;math-container&quot;&gt;$m\in M.$&lt;/span&gt; Define binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; for all pairs of clique indices &lt;span class=&quot;math-container&quot;&gt;$i\neq j,$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$z_{ij}=1$&lt;/span&gt; will signal that clique &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; follows clique &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in a clockwise traversal of your circle. Fix &lt;span class=&quot;math-container&quot;&gt;$z_{ii}=0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (to simplify the indexing in what follows) and dd the constraints &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^k z_{ij} = 1\quad \forall j\in \lbrace 1,\dots, k\rbrace$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=1}^k z_{ij} = 1\quad \forall i\in \lbrace 1,\dots, k\rbrace$$&lt;/span&gt; to ensure that every clique is preceded/followed by exactly one clique.&lt;/p&gt;&#xA;&lt;p&gt;Now for each movement &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; add the constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j\in H_m : i &amp;lt; j} ( z_{ij} + z_{ji}) \ge \vert H_m \vert - 1.$$&lt;/span&gt; This says that the total number of transitions between cliques containing &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; has to be at least the number of such cliques minus 1, or equivalently that the number of times in a cycle you transition from a clique containing &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; to a clique not containing &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is at most 1. (I used &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; rather than &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; in case you might have a movement permissible throughout the entire cycle of the light.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-12T15:54:47.707" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10302" PostTypeId="1" AcceptedAnswerId="10304" CreationDate="2023-04-12T20:06:46.020" Score="1" ViewCount="58" Body="&lt;p&gt;I have a series of functions (very similar to convex quadratic equations, see the first comment below) &lt;span class=&quot;math-container&quot;&gt;$f_1(x), f_2(x), \dots, f_n(x)$&lt;/span&gt;. Each of these functions touches the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;-axis at &lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt;, which can be different for each function. The functions &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; are such that the derivative on the left of its point &lt;span class=&quot;math-container&quot;&gt;$(a_i, 0)$&lt;/span&gt; is different from the derivative on the right of that point. This is because all &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; represent penalty functions which are asymmetric: deviating from the optimum &lt;span class=&quot;math-container&quot;&gt;$x = a_i$&lt;/span&gt; results in a different penalty if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is, say, &lt;span class=&quot;math-container&quot;&gt;$a_i - 1$&lt;/span&gt; compared to &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; being &lt;span class=&quot;math-container&quot;&gt;$a_i + 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a scalar. We have &lt;span class=&quot;math-container&quot;&gt;$x \ge 0$&lt;/span&gt;, and it is known that &lt;span class=&quot;math-container&quot;&gt;$a_i \ge 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The penalties of all functions for a certain &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are combined: &lt;span class=&quot;math-container&quot;&gt;$F(x) = f_1(x) + f_2(x) + \dots + f_n(x)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We are interested in finding the &lt;span class=&quot;math-container&quot;&gt;$x_\text{opt}$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$F(x)$&lt;/span&gt; is minimal.&lt;/p&gt;&#xA;&lt;p&gt;If the derivatives would be the same on the left and the right (and hence the coefficients would be constant), I think we can find the optimal solution analytically: for a convex &lt;span class=&quot;math-container&quot;&gt;$f_i(x) = \alpha_ix^2 + \beta_ix +\gamma_iz$&lt;/span&gt;, the optimum is &lt;span class=&quot;math-container&quot;&gt;$-\beta_i / (2\alpha_i)$&lt;/span&gt;, and we can take the average of all these values.&lt;/p&gt;&#xA;&lt;p&gt;And is this approach still valid for the above described situation? And if so, what is an approach to finding this value analytically / programmatically (in python)?&lt;/p&gt;&#xA;" OwnerUserId="11633" LastEditorUserId="491" LastEditDate="2023-04-14T11:29:58.200" LastActivityDate="2023-04-14T11:29:58.200" Title="Quadratic optimization with non-constant coefficients" Tags="|optimization|convex-optimization|quadratic-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10304" PostTypeId="2" ParentId="10302" CreationDate="2023-04-12T20:31:47.157" Score="0" Body="&lt;p&gt;The problem can be solved either analytically or numerically.&lt;/p&gt;&#xA;&lt;p&gt;Let's assume without loss of generality that the breakpoints are numbered in increasing order: &lt;span class=&quot;math-container&quot;&gt;$0 \le a_1 \le \dots \le a_n &amp;lt; \infty.$&lt;/span&gt; The first step is to evaluate &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; at all the breakpoints &lt;span class=&quot;math-container&quot;&gt;$0, a_1, \dots, a_n.$&lt;/span&gt; Next, find the minimum value (either analytically or via numerical method such as gradient search) in each &lt;em&gt;open&lt;/em&gt; interval &lt;span class=&quot;math-container&quot;&gt;$(0, a_1),$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$(a_1, a_2),$&lt;/span&gt; ..., &lt;span class=&quot;math-container&quot;&gt;$(a_n, \infty).$&lt;/span&gt; Since each of the component functions is quadratic in the interior of every interval, this should be straightforward. Now compare the values at the breakpoints and the interior minimizers and pick a winner.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-12T20:31:47.157" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10305" PostTypeId="1" AcceptedAnswerId="10309" CreationDate="2023-04-13T08:23:44.207" Score="1" ViewCount="84" Body="&lt;p&gt;I have an assignment problem where I have &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; locations and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; dates for each location, and the goal is to choose &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; location-date pairs that maximize revenue. There are a number of constraints, for example a location can only be chosen once, a date can only be chosen once, etc.&lt;/p&gt;&#xA;&lt;p&gt;Here is a dummy example of how I'm setting up the problem in PuLP:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import random&#xA;import pulp as pl&#xA;&#xA;&#xA;# Dummy revenue calculation&#xA;def get_revenue(location, date):&#xA;    return random.randint(100, 1000)&#xA;&#xA;&#xA;def optimize(max_choices=4):&#xA;    # Dummy data&#xA;    locations = ['a', 'b', 'c', 'd']&#xA;    dates = ['2023-01-01', '2023-02-01', '2023-03-01', '2024-04-01']&#xA;&#xA;    prob = pl.LpProblem('RevenueMaximization', pl.LpMaximize)&#xA;&#xA;    # Variable setup&#xA;    pairs = [(location, date) for location in locations for date in dates]&#xA;    choices = pl.LpVariable.dicts('LocationDates', pairs, cat=pl.LpBinary)&#xA;&#xA;    # Objective function&#xA;    prob += pl.lpSum([choices[pair]*get_revenue(pair[0], pair[1]) for pair in pairs])&#xA;&#xA;    # Desired choices constraint&#xA;    prob += pl.lpSum([choices[pair] for pair in pairs]) == max_choices, 'MaxChoices'&#xA;&#xA;    # One date per location constraint&#xA;    for location in locations:&#xA;        prob += pl.lpSum([&#xA;            choices[(location, date)]&#xA;            for date in dates&#xA;        ]) &amp;lt;= 1, f'OneDatePerLocation_{location}'&#xA;&#xA;    # One location per date constraint&#xA;    for date in dates:&#xA;        prob += pl.lpSum([&#xA;            choices[(location, date)]&#xA;            for location in locations&#xA;        ]) &amp;lt;= 1, f'OneLocationPerDate_{date}'&#xA;        &#xA;    # Other constraints...&#xA;&#xA;    # Solve and print results&#xA;    prob.solve()&#xA;    if pl.LpStatus[prob.status] == 'Optimal':&#xA;        for v in prob.variables():&#xA;            if v.value() &amp;gt; 0:&#xA;                print(v.name, '=', v.dj)&#xA;    else:&#xA;        print('Problem is infeasible')&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This works fine, but there are two constraints that I have left out that are stumping me. I want to allow a user to specify a first and/or last location, meaning if a user selects &lt;code&gt;a&lt;/code&gt; as the first location, then no other location can have a date earlier than the date chosen for &lt;code&gt;a&lt;/code&gt;. Similarly, if a user selects &lt;code&gt;d&lt;/code&gt; as the last location, then no locations can have a date after the date chosen for &lt;code&gt;d&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the real world, I have a few thousand locations and a dynamic range of dates that spans ~1.5 years, so I think brute forcing is out of the equation. I'd like to solve these constraints directly with PuLP, but I am having trouble wrapping my head around how to formulate, let alone implement them.&lt;/p&gt;&#xA;&lt;p&gt;I am fairly new to linear programming and using PuLP, so I'm not sure if there is some trick I'm missing, or if this is complicated and requires additional indicator variables. Any help would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="11634" LastEditorUserId="2556" LastEditDate="2023-04-13T08:27:27.183" LastActivityDate="2023-04-14T03:43:47.447" Title="PuLP ensure first and last choice" Tags="|optimization|linear-programming|modeling|assignment-problem|pulp|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10306" PostTypeId="1" AcceptedAnswerId="10308" CreationDate="2023-04-13T10:55:19.503" Score="2" ViewCount="49" Body="&lt;p&gt;What is the requirements on &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; in order for &lt;span class=&quot;math-container&quot;&gt;$\max_x\{f(g(x))\} = f(\max_x\{g(x)\})$&lt;/span&gt; to be correct?&lt;/p&gt;&#xA;&lt;p&gt;Equivalently, when is &lt;span class=&quot;math-container&quot;&gt;$\min_x\{f(g(x))\} = f(\min_x\{g(x)\})$&lt;/span&gt; ?&lt;/p&gt;&#xA;&lt;p&gt;Any reference for describing this is welcome.&lt;/p&gt;&#xA;" OwnerUserId="9151" LastActivityDate="2023-04-13T11:55:07.873" Title="When is $\max_x\{f(g(x))\} = f(\max_x\{g(x)\})$?" Tags="|reference-request|convex-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10307" PostTypeId="1" AcceptedAnswerId="10313" CreationDate="2023-04-13T11:35:10.753" Score="0" ViewCount="89" Body="&lt;p&gt;I have weighted graph for sensor networks with aggregation nodes and sensors. There is a edge between two nodes associated with a weight.&#xA;Higher the weight, stronger the interference between the aggregation nodes if they have same color.&lt;/p&gt;&#xA;&lt;p&gt;I need to perform graph coloring of these nodes with just K colors. The nodes with higher edge weight should/must have different colors.&lt;/p&gt;&#xA;&lt;p&gt;What is an efficient way to do the optimal coloring?&lt;/p&gt;&#xA;&lt;p&gt;Ideas:&lt;/p&gt;&#xA;&lt;p&gt;May be the coloring of such a big network is too difficult. Instead we can have clusters of nodes and then do the intra-cluster coloring. But then we need to take care of inter-cluster interference.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2023-04-14T08:01:39.757" LastActivityDate="2023-04-14T08:01:39.757" Title="Coloring of nodes in a sensor networks" Tags="|mixed-integer-programming|graphs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10308" PostTypeId="2" ParentId="10306" CreationDate="2023-04-13T11:36:37.470" Score="5" Body="&lt;p&gt;A sufficient condition for &lt;span class=&quot;math-container&quot;&gt;$\max_x\{f(g(x))\} = f(\max_x\{g(x)\})$&lt;/span&gt; is that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a monotone increasing function on the range of &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;. This is also sufficient condition for &lt;span class=&quot;math-container&quot;&gt;$\min_x\{f(g(x))\} = f(\min_x\{g(x)\})$&lt;/span&gt; and the reason is that monotone increasing functions are order preserving.&lt;/p&gt;&#xA;&lt;p&gt;To clarify, a function is monotone increasing if &lt;span class=&quot;math-container&quot;&gt;$x \leq y$&lt;/span&gt; implies &lt;span class=&quot;math-container&quot;&gt;$f(x) \leq f(y)$&lt;/span&gt;. Thus also &lt;span class=&quot;math-container&quot;&gt;$g(x) \leq g(y)$&lt;/span&gt; implies &lt;span class=&quot;math-container&quot;&gt;$f(g(x)) \leq f(g(y))$&lt;/span&gt;. Consequently, each minimizer (resp. maximizer) of &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; is also a minimizer (resp. maximizer) of &lt;span class=&quot;math-container&quot;&gt;$f(g(x))$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In contrast, monotone decreasing functions are order reversing, and you would obtain relations such as &lt;span class=&quot;math-container&quot;&gt;$\max_x\{f(g(x))\} = f(\min_x\{g(x)\})$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2023-04-13T11:55:07.873" LastActivityDate="2023-04-13T11:55:07.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10309" PostTypeId="2" ParentId="10305" CreationDate="2023-04-13T12:02:55.913" Score="2" Body="&lt;p&gt;Additional constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{k=1}^{t-1} x_{l,k} \le 1-x_{a,t} \quad \forall l \neq a$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{k=t+1}^{T} x_{l,k} \le 1-x_{d,t} \quad \forall l \neq d$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the binary location pair variable as you defined &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is the index over chronologically sorted list of dates with &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; as the last index.&lt;/p&gt;&#xA;&lt;p&gt;Corrected..&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-04-13T13:21:03.080" LastActivityDate="2023-04-13T13:21:03.080" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10310" PostTypeId="1" AcceptedAnswerId="10311" CreationDate="2023-04-13T12:03:45.517" Score="2" ViewCount="48" Body="&lt;p&gt;Suppose the following logical form there exists.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Iff: (x_{j,m} \land x_{k,m}) \implies ((C_{j} \leq S_{k}) \lor (C_{k} \leq S_{j}))$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is well-known as a &lt;em&gt;&lt;strong&gt;no_overlap_constraint&lt;/strong&gt;&lt;/em&gt; in the parallel machine scheduling problem. One of the linearization forms that is frequently used in literature is as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$C_{j} \leq S_{k} + M*(1-x_{j,m}) + M*(1-x_{k,m}) + M*(\alpha_{j,k}) \quad \forall k,j,m: j&amp;lt;k \tag1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$C_{k} \leq S_{j} + M*(1-x_{j,m}) + M*(1-x_{k,m}) + M*(1-\alpha_{j,k}) \quad \forall k,j,m: j&amp;lt;k \tag2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This linearization still leads to a weak linear relaxation that already causes a long time to solve the problem. Hence, I tried to derive another linearization form based on the following CNF transformation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ Iff: (x_{j,m} \land x_{k,m}) \implies ((w_{j,k}^1 \iff C_{j} \leq S_{k}) \lor (w_{j,k}^2 \iff C_{k} \leq S_{j}))$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ Iff: (x_{j,m} \land x_{k,m}) \implies (w_{j,k}^1 \lor w_{j,k}^2) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (1-x_{j,m}) + (1-x_{k,m}) + w_{j,k}^1 + w_{j,k}^2 \geq 1 \tag3 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ C_{j} \leq S_{k} + M*(1-w_{j,k}^1) \tag4 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ C_{j} \geq S_{k} + \epsilon - (M-\epsilon)*w_{j,k}^1 \tag5 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ C_{k} \leq S_{j} + M*(1-w_{j,k}^2) \tag6 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ C_{k} \geq S_{j} + \epsilon - (M-\epsilon)*w_{j,k}^2 \tag7 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;After solving the model with both formulations, I found that the second one, &lt;span class=&quot;math-container&quot;&gt;$\{(3), (4), (5), (6), (7) \}$&lt;/span&gt;, can be solved so faster than the first one. The first transformation takes around 28 sec, while the second just takes around 2 sec. (for the same data and environment). In both cases, the optimal solution is the same and the results are reasonable.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;I would like to know if the second form is a correct derivation of the logical constraint(?) and if I am not lucky to get the optimal solution.&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Is there any tighter formulation to speed up the solving process?&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="199" LastEditorUserId="500" LastEditDate="2023-04-13T13:47:15.103" LastActivityDate="2023-04-13T13:47:15.103" Title="A tighter relaxation of the mix logical constraints" Tags="|mixed-integer-programming|modeling|logical-constraints|convex-hull|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10311" PostTypeId="2" ParentId="10310" CreationDate="2023-04-13T12:44:02.743" Score="1" Body="&lt;p&gt;Yes, (3) through (7) yield a correct linearization of the original implication. But you don’t need to enforce &lt;span class=&quot;math-container&quot;&gt;$\iff$&lt;/span&gt; for the &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; variables, and so you can omit (5) and (7).&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-04-13T12:44:02.743" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10313" PostTypeId="2" ParentId="10307" CreationDate="2023-04-13T12:54:37.660" Score="3" Body="&lt;p&gt;I recommend first trying to solve the problem directly. For each edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; be the edge weight. Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{ik}$&lt;/span&gt; indicate whether node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned color &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j} c_{ij} \sum_k x_{ik} x_{jk}$$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\sum_k x_{ik} = 1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. You can call an MIQP solver or linearize the quadratic objective. To linearize, for each edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$c_{ij}&amp;gt;0$&lt;/span&gt;, introduce binary (or just nonnegative) decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$\sum_k x_{ik} x_{jk}$&lt;/span&gt;, impose additional constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_{ij} \ge x_{ik} + x_{jk} - 1$&lt;/span&gt;, and minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j} c_{ij} y_{ij}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-04-13T13:55:58.513" LastActivityDate="2023-04-13T13:55:58.513" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="10316" PostTypeId="2" ParentId="10305" CreationDate="2023-04-14T02:38:53.737" Score="1" Body="&lt;p&gt;For anyone who comes across this in the future and is looking to translate the solution @Sutanu posted to PuLP, here is how I implemented it.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import random&#xA;import pulp as pl&#xA;&#xA;&#xA;# Dummy revenue calculation&#xA;def get_revenue(location, date):&#xA;    return random.randint(100, 1000)&#xA;&#xA;&#xA;def optimize(first_location, last_location, max_choices=4):&#xA;    # Dummy data&#xA;    locations = ['a', 'b', 'c', 'd']&#xA;    dates = ['2022-12-01', '2023-01-01', '2023-02-01', '2023-03-01', '2023-04-01', '2023-05-01', '2023-06-01']&#xA;&#xA;    prob = pl.LpProblem('RevenueMaximization', pl.LpMaximize)&#xA;&#xA;    # Variable setup&#xA;    pairs = [(location, date) for location in locations for date in dates]&#xA;    choices = pl.LpVariable.dicts('LocationDates', pairs, cat=pl.LpBinary)&#xA;&#xA;    # Objective function&#xA;    prob += pl.lpSum([choices[pair] * get_revenue(pair[0], pair[1]) for pair in pairs])&#xA;&#xA;    # Desired choices constraint&#xA;    prob += pl.lpSum([choices[pair] for pair in pairs]) == max_choices, 'MaxChoices'&#xA;&#xA;    # One date per location constraint&#xA;    for location in locations:&#xA;        prob += pl.lpSum([&#xA;            choices[(location, date)]&#xA;            for date in dates&#xA;        ]) &amp;lt;= 1, f'OneDatePerLocation_{location}'&#xA;&#xA;    # One location per date constraint&#xA;    for date in dates:&#xA;        prob += pl.lpSum([&#xA;            choices[(location, date)]&#xA;            for location in locations&#xA;        ]) &amp;lt;= 1, f'OneLocationPerDate_{date}'&#xA;&#xA;    # First location constraint&#xA;    for location in filter(lambda x: x != first_location, locations):&#xA;        for idx, date in enumerate(dates):&#xA;            prob += pl.lpSum([&#xA;                choices[(location, d)]&#xA;                for d in dates[:idx]&#xA;            ]) &amp;lt;= 1 - choices[(first_location, date)], f'FirstLocationExclude_{location}_{date}'&#xA;&#xA;    # Last location constraint&#xA;    for location in filter(lambda x: x != last_location, locations):&#xA;        for idx, date in enumerate(dates):&#xA;            prob += pl.lpSum([&#xA;                choices[(location, d)]&#xA;                for d in dates[idx:]&#xA;            ]) &amp;lt;= 1 - choices[(last_location, date)], f'LastLocationExclude_{location}_{date}'&#xA;&#xA;    # Solve and print results&#xA;    prob.solve()&#xA;    if pl.LpStatus[prob.status] == 'Optimal':&#xA;        for v in prob.variables():&#xA;            if v.value() &amp;gt; 0:&#xA;                print(v.name, '=', v.dj)&#xA;    else:&#xA;        print('Problem is infeasible')&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    optimize(first_location='a', last_location='d')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that the range of dates is expanded from the original question to show that the constraints work for larger solution spaces. It also assumes that &lt;code&gt;dates&lt;/code&gt; is in chronological order, which helps avoid any &lt;code&gt;datetime&lt;/code&gt; conversions or comparisons.&lt;/p&gt;&#xA;&lt;p&gt;It's definitely a toy example, but it should illustrate the core concepts.&lt;/p&gt;&#xA;" OwnerUserId="11634" LastActivityDate="2023-04-14T02:38:53.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10317" PostTypeId="2" ParentId="10305" CreationDate="2023-04-14T03:43:47.447" Score="1" Body="&lt;p&gt;Here’s a somewhat automated way to obtain the formulation proposed by @Sutanu. You want to enforce the logical implication &lt;span class=&quot;math-container&quot;&gt;$$\bigwedge_t \left(x_{at} \implies \bigwedge_{l\not= a}\bigwedge_{k&amp;lt;t}\lnot x_{lk}\right).$$&lt;/span&gt; Rewriting in conjunctive normal form yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\bigwedge_t \left(\lnot x_{at} \lor \bigwedge_{l\not= a}\bigwedge_{k&amp;lt;t}\lnot x_{lk}\right) \\&#xA;\bigwedge_t \bigwedge_{l\not= a}\bigwedge_{k&amp;lt;t}\left(&#xA;\lnot x_{at} \lor \lnot x_{lk}\right)\\&#xA;\bigwedge_t \bigwedge_{l\not= a}\bigwedge_{k&amp;lt;t}\left(&#xA;(1-x_{at}) + (1-x_{lk})\ge 1 \right)\\ &#xA;\bigwedge_t \bigwedge_{l\not= a}\bigwedge_{k&amp;lt;t}\left(x_{at} + x_{lk}\le 1 \right)&#xA;$$&lt;/span&gt;&#xA;This is correct but can be strengthened by using the fact that &lt;span class=&quot;math-container&quot;&gt;$\sum_k x_{lk}\le 1$&lt;/span&gt;, as shown &lt;a href=&quot;https://or.stackexchange.com/questions/6187/how-can-i-strengthen-a-family-of-constraints-in-the-presence-of-a-clique-constra&quot;&gt;here&lt;/a&gt;. The strengthened constraints are&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\bigwedge_t \bigwedge_{l\not= a}\left(x_{at} + \sum_{k&amp;lt;t} x_{lk}\le 1 \right).&#xA;$$&lt;/span&gt;&#xA;The constraints for &lt;span class=&quot;math-container&quot;&gt;$x_{dt}$&lt;/span&gt; have a similar derivation.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-04-14T03:43:47.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10318" PostTypeId="1" CreationDate="2023-04-14T05:27:01.630" Score="2" ViewCount="132" Body="&lt;p&gt;I am seeking some career advice regarding my current position as an Operations Research Analyst. I have been working in this role for three years, but I lack a formal academic background in Operations Research and Numerical Optimization. I got this job by demonstrating other related skills such as numerical computation, evolutionary optimization, computer programming, statistics and basic ML/Deep Learning.&lt;/p&gt;&#xA;&lt;p&gt;Although I am confident in my basic knowledge of Operations Research and can implement optimization problems in AML's (Pyomo mainly) using solvers, I often feel that my lack of theoretical understanding limits my ability to go deeper into the concepts. I struggle when discussing topics like algorithmic implementation details of solvers, branch and bound, optimality, KKT conditions, or gap in MIP's, big-M method, among others. I hope that provides an idea regarding where I struggle.&lt;/p&gt;&#xA;&lt;p&gt;As I want to remain in the field of OR, I am willing to put in efforts to improve my knowledge. However, I struggle to find relevant resources that can help me fill the gaps in my OR knowledge. While there are plenty of resources available for topics in ML/Data Science, I cannot find many resources in OR that can help me improve.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, I would like to ask for your advice on how I can develop my OR knowledge. Should I consider reading a book, taking formal training, or is there any other resource that you can recommend?&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="491" LastEditDate="2024-02-21T23:04:58.513" LastActivityDate="2024-02-21T23:04:58.513" Title="Seeking Career Advice for Developing Operations Research Knowledge Without Formal Academic Background" Tags="|books|or-careers|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10319" PostTypeId="1" CreationDate="2023-04-14T06:05:23.577" Score="2" ViewCount="183" Body="&lt;p&gt;I need to determine the global optimum results of this objective function. I define the problem by minimizing the squared difference as represented in function &lt;span class=&quot;math-container&quot;&gt;$f(q_1,q_2,\alpha_1,\alpha_2)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective function:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(q_1,q_2,\alpha_1,\alpha_2)= \frac{1}{5}\sum\limits_{i = 1}^{5} (b_{i} - b_{mod_{i}})^2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With bounds:&lt;/p&gt;&#xA;&lt;p&gt;lower = c(1000, 1000, 0.8, 1.4)&#xA;upper = c(1e10, 1e35, 1.5, 15.0)&lt;/p&gt;&#xA;&lt;p&gt;where,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$b_{mod,i} = q_{1} \lambda_i^{-\alpha_1} + q_{2} \lambda_i^{-\alpha_2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and &lt;span class=&quot;math-container&quot;&gt;$\lambda_i = c(375, 470, 528, 625, 880)$&lt;/span&gt; are the wavelengths of 5 channels and&#xA;&lt;span class=&quot;math-container&quot;&gt;$b_i = c(228,124,98,67,44)$&lt;/span&gt; represents the light absorption measurement corresponding to each wavelength.&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; is a measured value from a device and &lt;span class=&quot;math-container&quot;&gt;$b_{mod,i}$&lt;/span&gt; is the modelled value achieved by the optimization process.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Approach 1: Excel Solver&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the Excel solver, I used the non-linear solver function with the inbuilt &amp;quot;Evolutionary&amp;quot; algorithm. The optimized values &lt;span class=&quot;math-container&quot;&gt;$q_1,\alpha_1,q_2,\alpha_2$&lt;/span&gt; seems reasonable.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Approach 2: in R using &lt;code&gt;DEoptim&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I found that the Evolutionary algorithm in Excel is based on the Differential Evolutionary algorithm and in R there is a package called &lt;code&gt;DEoptim&lt;/code&gt; (&lt;a href=&quot;https://cran.r-project.org/web/packages/DEoptim/DEoptim.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Link&lt;/a&gt;). Also, I need to run the optimization process for a large data set where each timestamp of data represents &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. However, &lt;code&gt;DEoptim&lt;/code&gt; results were found to be very close to the upper bound and often are very sensitive to the bounds provided.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Queries&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am trying to use this technique in R to solve a physical problem.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is &lt;code&gt;DEoptim&lt;/code&gt; a good choice for the defined problem?&lt;/li&gt;&#xA;&lt;li&gt;Are there any other optimization techniques to solve the present problem?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11637" LastEditorUserId="491" LastEditDate="2023-04-14T11:50:47.953" LastActivityDate="2023-04-17T04:43:05.150" Title="Solving a Global Optimization problem using Differential Evolutionary Algorithm using R" Tags="|optimization|multi-objective-optimization|r|global-optimization|evolutionary|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10320" PostTypeId="2" ParentId="10318" CreationDate="2023-04-14T09:35:55.967" Score="2" Body="&lt;p&gt;There are several good courses in Coursera: &lt;a href=&quot;https://www.coursera.org/courses?query=operations%20research&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.coursera.org/courses?query=operations%20research&lt;/a&gt;. MIT OCW is another very good option: &lt;a href=&quot;https://ocw.mit.edu/search/?d=Mathematics&amp;amp;d=Sloan%20School%20of%20Management&amp;amp;q=%22operations%20research%22&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ocw.mit.edu/search/?d=Mathematics&amp;amp;d=Sloan%20School%20of%20Management&amp;amp;q=%22operations%20research%22&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;_____ Edited _____ (2023-04-15)&lt;/p&gt;&#xA;&lt;p&gt;Following Prubin's suggestion, you can check EDX too (&lt;a href=&quot;https://www.edx.org/search?q=operatins+research&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.edx.org/search?q=operatins+research&lt;/a&gt;), very good courses.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastEditorUserId="10165" LastEditDate="2023-04-15T13:33:37.053" LastActivityDate="2023-04-15T13:33:37.053" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10321" PostTypeId="1" AcceptedAnswerId="10335" CreationDate="2023-04-14T11:07:42.547" Score="1" ViewCount="132" Body="&lt;p&gt;It is the same problem as posted at &lt;a href=&quot;https://or.stackexchange.com/questions/10307/coloring-of-nodes-in-a-sensor-networks&quot;&gt;Coloring of nodes in a sensor networks&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Its about coloring a weighted graph.&lt;/p&gt;&#xA;&lt;p&gt;@RobPratt suggested a very good solution that solves the problem directly.&lt;/p&gt;&#xA;&lt;p&gt;However, we need to employ MIQP or MILP solver to solve this problem.&lt;/p&gt;&#xA;&lt;p&gt;I am also looking for a greedy heuristic solution that would perform very close to what @RobPratt has suggested.&lt;/p&gt;&#xA;&lt;p&gt;Or Any distributed (coloring) solution?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2023-04-14T11:13:22.503" LastActivityDate="2023-08-09T15:38:16.083" Title="Coloring of nodes of a sensor network" Tags="|mixed-integer-programming|graphs|heuristics|metaheuristics|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10322" PostTypeId="1" CreationDate="2023-04-14T11:44:07.410" Score="0" ViewCount="59" Body="&lt;p&gt;I have an optimisation problem that is essentially a knapsack problem with a non-linear objective.&lt;/p&gt;&#xA;&lt;p&gt;I have an input dataframe that contains a row for each item, each item has columns defining its mean value and weight. I also have a covariance matrix that contains the variances and covariances between each item.&lt;/p&gt;&#xA;&lt;p&gt;I take this information and simulate the values for each item a number of times, and store that data.&lt;/p&gt;&#xA;&lt;p&gt;Then i define my optimisation problem, where i want to select 20 groups of 6 items, so that i maximise the probability of any one of these groups reaching a target value.&lt;/p&gt;&#xA;&lt;p&gt;Essentially, I am trying to maximise:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$P(max(x) &amp;gt; T)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where x is the values of the groups of lineups, and T is the target score.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My current method:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am using pyomo in python to solve this problem. First I define a binary decision variable and some constraints, such as making sure no groups are identical and that they are under the weight limit, then i define the objective rule.&lt;/p&gt;&#xA;&lt;p&gt;I try and do this by summing the simulated scores for each group of items, doing this for each simulation, and keeping track of the number of times the value reaches the target value.&lt;/p&gt;&#xA;&lt;p&gt;I then try to solve the problem using the solver.&lt;/p&gt;&#xA;&lt;p&gt;However, when i run it, the model does not initialise values for the binary decision variable, i assume because it cannot find a solution. When i initialise the values myself with groups that make sense, it runs through and calculates the probability, but does not change any of the groups at all.&lt;/p&gt;&#xA;&lt;p&gt;Here is my current attempt:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Define input data&#xA;n_items = 120&#xA;m_groups = 20&#xA;target_value = 400&#xA;n_simulations = 10000&#xA;&#xA;# Generate simulated scores for all players in the tournament&#xA;simulated_scores = multivariate_normal.rvs(mean=df['value'], cov=cov_mat, size=n_simulations)&#xA;&#xA;# Define model&#xA;model = ConcreteModel()&#xA;&#xA;# Define decision variables with initial values&#xA;model.x = Var(range(n_items), range(m_groups), within=Binary, initialize=0)&#xA;&#xA;def objective_rule(model):&#xA;    prob = 0&#xA;    for j in range(m_groups):&#xA;        # Get indices of selected players in lineup j&#xA;        for s in range(n_simulations):&#xA;            sim_scores = sum(model.x[i,j] * simulated_scores[s, i] for i in range(n_items))&#xA;            if value(sim_scores) &amp;gt; target_value:&#xA;                prob += 1&#xA;    total_prob = prob / (n_simulations*20)   &#xA;    return total_prob&#xA;&#xA;model.objective = Objective(rule=objective_rule, sense=maximize)&#xA;&#xA;# Define constraints&#xA;model.players_per_lineup = ConstraintList()&#xA;for j in range(m_groups):&#xA;    model.players_per_lineup.add(sum(model.x[i,j] for i in range(n_items)) == 6)&#xA;&#xA;model.group_per_item = ConstraintList()&#xA;for i in range(n_items):&#xA;    model.group_per_item.add(sum(model.x[i,j] for j in range(m_groups)) &amp;lt;= 3)&#xA;&#xA;model.weight_limit = ConstraintList()&#xA;for j in range(m_groups):&#xA;    model.weight_limit.add(sum(model.x[i,j] * df.iloc[i]['weights'] for i in range(n_items)) &amp;lt;= 300)&#xA;&#xA;# Solve model&#xA;solver = SolverFactory('glpk')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I assume this is not working as I am not fully understanding the extent of this optimisation problem, and taking a simplistic approach that cannot be solved using this method.&lt;/p&gt;&#xA;&lt;p&gt;I'm looking for a simple way to produce a solution for this non-linear problem that produces the optimal groups of items. Ideally something that works with simulations that are not always normally distributed.&lt;/p&gt;&#xA;" OwnerUserId="10047" LastActivityDate="2023-04-14T11:44:07.410" Title="How do I solve this non-linear optimisation problem based on simulations?" Tags="|integer-programming|nonlinear-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10323" PostTypeId="1" CreationDate="2023-04-14T12:01:58.227" Score="0" ViewCount="41" Body="&lt;p&gt;I arrive at an objective function value that I know to be optimal. However, dual prices remain negative (which leads me to believe another pattern can be added, but when I do, the dual prices don't change). How to interpret this? Working in LINGO.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;MIN = X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10 + X11 + X12 + X13;&#xA;10*X1 + 8*X2 + 8*X3 + 7*X4 + 7*X5 + X6 + X11 + 2*X13 &amp;gt;= 25;&#xA;X2 + 2*X4 + X5 + X7 + X8 + X9 + 2*X10 + X11 + 7*X12 + 6*X13 &amp;gt;= 40;&#xA;X3 + X5 + X7 + 3*X8 + 2*X9 + X11 &amp;gt;= 20;&#xA;X6 + 3*X7 + X9 + X11 &amp;gt;= 30;&#xA;X6 + X9 + X10 &amp;gt;= 15;&#xA;X6 + X8 + X10 + X11 &amp;gt;= 20;&#xA;X1 &amp;gt;= 0;&#xA;X2 &amp;gt;= 0;&#xA;X3 &amp;gt;= 0;&#xA;X4 &amp;gt;= 0;&#xA;X5 &amp;gt;= 0;&#xA;X6 &amp;gt;= 0;&#xA;X7 &amp;gt;= 0;&#xA;X8 &amp;gt;= 0;&#xA;X9 &amp;gt;= 0;&#xA;X10 &amp;gt;= 0;&#xA;X11 &amp;gt;= 0; &#xA;X12 &amp;gt;= 0;&#xA;X13 &amp;gt;= 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Variable           Value        Reduced Cost&#xA;                              X1        0.000000           0.2857143&#xA;                              X2        0.000000           0.2857143&#xA;                              X3        0.000000           0.2755102&#xA;                              X4        0.000000           0.2142857&#xA;                              X5        0.000000           0.2040816&#xA;                              X6        15.00000            0.000000&#xA;                              X7        5.000000            0.000000&#xA;                              X8        5.000000            0.000000&#xA;                              X9        0.000000           0.2040816E-01&#xA;                             X10        0.000000           0.2040816E-01&#xA;                             X11        0.000000            0.000000&#xA;                             X12        0.000000            0.000000&#xA;                             X13        5.000000            0.000000&#xA;&#xA;                             Row    Slack or Surplus      Dual Price&#xA;                               1        30.00000           -1.000000&#xA;                               2        0.000000          -0.7142857E-01&#xA;                               3        0.000000          -0.1428571&#xA;                               4        0.000000          -0.1530612&#xA;                               5        0.000000          -0.2346939&#xA;                               6        0.000000          -0.2959184&#xA;                               7        0.000000          -0.3979592&#xA;                               8        0.000000            0.000000&#xA;                               9        0.000000            0.000000&#xA;                              10        0.000000            0.000000&#xA;                              11        0.000000            0.000000&#xA;                              12        0.000000            0.000000&#xA;                              13        15.00000            0.000000&#xA;                              14        5.000000            0.000000&#xA;                              15        5.000000            0.000000&#xA;                              16        0.000000            0.000000&#xA;                              17        0.000000            0.000000&#xA;                              18        0.000000            0.000000&#xA;                              19        0.000000            0.000000&#xA;                              20        5.000000            0.000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11638" LastActivityDate="2023-04-14T12:01:58.227" Title="Dual prices remain stable but negative in column generation" Tags="|linear-programming|duality|column-generation|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10324" PostTypeId="1" AcceptedAnswerId="10325" CreationDate="2023-04-14T12:21:33.463" Score="0" ViewCount="84" Body="&lt;p&gt;I'm trying to understand the following expression (which can be called an objective function as well):&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;${b_t}\left( {\omega ,\rho } \right) = \arg \mathop {\max }\limits_{b \in {\Delta _m}} \quad\prod\limits_{i \in {C_t}\left( {\omega ,\rho } \right)} {\left( {b\cdot{x_i}} \right)} \qquad \qquad \qquad (Eq. 7)$&lt;/span&gt;&lt;br /&gt;&#xA;which is provided in &lt;a href=&quot;https://paperswithcode.com/paper/corn-correlation-driven-non-parametric&quot; rel=&quot;nofollow noreferrer&quot;&gt;this scientific article&lt;/a&gt; (page 11). Suppose &lt;span class=&quot;math-container&quot;&gt;${C_t}\left( {\omega ,\rho } \right)$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$\{ 1,2, \ldots ,n\}$&lt;/span&gt;. The components are defined as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\omega$&lt;/span&gt;: length of time window (Integer and is known)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt;: correlation coefficient threshold (a real value &lt;span class=&quot;math-container&quot;&gt;$-1\le\rho\le1$&lt;/span&gt; and is known)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b_t$&lt;/span&gt;: vector of weights for the &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;'th day&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\Delta _m$&lt;/span&gt;: a simplex with &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; components (actually, it demonstrates two constraints:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{j = 1}^m {{b_{ij}}}  = 1$&lt;/span&gt;,&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$0 \le {b_{ij}} \le 1$&lt;/span&gt;,&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$i\in\{1,2,...,n\}{\rm{   }}$&lt;/span&gt;,&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$j \in\{ 1,2, \ldots ,m\}$&lt;/span&gt;&lt;br /&gt;&#xA;In the above, &lt;span class=&quot;math-container&quot;&gt;$b_{ij}$&lt;/span&gt; refers to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;'th element of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;'th set of weights.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;: vector of weights with length &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;: vector of real values with length &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; (is known)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;My question is where we have &lt;span class=&quot;math-container&quot;&gt;$\arg \max \prod {} $&lt;/span&gt;! The output of &lt;span class=&quot;math-container&quot;&gt;$b\cdot{x_i}$&lt;/span&gt; is supposed to be a scalar, consequently, the output of &lt;span class=&quot;math-container&quot;&gt;$\prod\limits_{i \in {C_t}\left( {\omega ,\rho } \right)} {\left( {b \cdot {x_i}} \right)} $&lt;/span&gt; is supposed to be a scalar. So, how can we look for &lt;span class=&quot;math-container&quot;&gt;$\arg \max$&lt;/span&gt; of a scalar? Furthermore, &lt;span class=&quot;math-container&quot;&gt;${b_t}\left( {\omega ,\rho } \right)$&lt;/span&gt; is supposed to be the vector of weights for &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;'th day, but &lt;span class=&quot;math-container&quot;&gt;$\arg \max$&lt;/span&gt; returns an integer index. So, &lt;span class=&quot;math-container&quot;&gt;${b_t}\left( {\omega ,\rho } \right)=index$&lt;/span&gt; expression doesn't make sense.&lt;/p&gt;&#xA;" OwnerUserId="6022" LastEditorUserId="6022" LastEditDate="2023-04-14T16:59:36.613" LastActivityDate="2023-04-14T19:47:39.473" Title="Understanding mathematical concept behind an objective function" Tags="|optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10325" PostTypeId="2" ParentId="10324" CreationDate="2023-04-14T12:54:46.060" Score="3" Body="&lt;p&gt;The optimization variable, a.k.a., decision variable, in this problem is the length m vector &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The objective function of a &amp;quot;standard&amp;quot; (single objective) optimization problem must evaluate to a real scalar, and depending on the problem is maximized or minimized, in this case, maximized. We can conclude that 4 &amp;gt; 3. But is (2,4) &amp;gt; (1,5)?  That doesn't make sense. So that is why the objective function must evaluate to s real scalar.&lt;/p&gt;&#xA;&lt;p&gt;argmax (argmin in the case of minimization) is the optimal value (i.e., argument value) of the optimization variable, which in this case is a length m vector. argmax is short for the argument value at which the maximum of the objective function occurs, subject to (i.e. given) the constraints. So it is the value of the length m vector &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; at which the objective function is maximized, given that &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; satisfies all the constraints.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2023-04-14T12:54:46.060" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="10326" PostTypeId="1" CreationDate="2023-04-14T16:44:36.250" Score="2" ViewCount="58" Body="&lt;p&gt;It is advised that in a big M constraint, M should be chosen as small as possible.&lt;/p&gt;&#xA;&lt;p&gt;Is this recommendation a hard fact or heuristics?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2023-04-14T16:44:36.250" Title="Big M Modelling" Tags="|mixed-integer-programming|big-m|" AnswerCount="0" CommentCount="1" ClosedDate="2023-04-18T06:13:34.680" ContentLicense="CC BY-SA 4.0" />
  <row Id="10327" PostTypeId="1" AcceptedAnswerId="10329" CreationDate="2023-04-14T17:05:23.910" Score="1" ViewCount="165" Body="&lt;p&gt;Many modern SAT and SMT solvers offer a feature where they can report why a problem is unsatisfiable, something called an &amp;quot;unsat core.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Are there any optimization solvers (in my case, specifically MILP and LP) that can report the minimal infeasible constraint set?  What is the name of this, equivalent to &amp;quot;unsat core?&amp;quot;&lt;/p&gt;&#xA;" OwnerUserId="11641" LastEditorUserId="500" LastEditDate="2023-04-14T17:44:21.327" LastActivityDate="2023-04-15T18:00:44.547" Title="Minimal infeasible constraint set" Tags="|mixed-integer-programming|linear-programming|solver|terminology|irreducible-infeasible-subset|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10328" PostTypeId="2" ParentId="10321" CreationDate="2023-04-14T17:37:14.180" Score="2" Body="&lt;p&gt;Here are two heuristic approaches:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A greedy construction heuristic could be to loop through the nodes and assign each node the color that increases the objective function the least.  You could optionally process the nodes in some specified order, perhaps decreasing order of total sum of incident edge weights.  Or run several times with random node ordering and keep the best.&lt;/li&gt;&#xA;&lt;li&gt;A local search improvement heuristic could be to try to improve a given coloring by two moves: change the color of a single node, or swap the colors of two (differently colored) nodes.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-04-14T17:37:14.180" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10329" PostTypeId="2" ParentId="10327" CreationDate="2023-04-14T17:42:57.323" Score="4" Body="&lt;p&gt;In the optimization community, this is called an &lt;em&gt;irreducible infeasible set&lt;/em&gt; (IIS), and many solvers support this functionality.  The &amp;quot;irreducible&amp;quot; part means that the set is minimal in the sense that removing any constraint yields a feasible set.  Such a set is typically not unique, and removing one member does not necessarily make the original problem feasible, so you might need to find and repair an IIS multiple times.  The problem of finding a minimum-cardinality infeasible set is much more difficult.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-04-14T17:42:57.323" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10330" PostTypeId="2" ParentId="10321" CreationDate="2023-04-14T18:07:17.170" Score="2" Body="&lt;p&gt;You may try this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Sort out the edge weights in descending order. Initialize a counter for each of the colors.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Repeat until all nodes are exhausted&lt;br /&gt;&#xA;Repeat until colors are exhausted&lt;br /&gt;&#xA;2. Assign two separate colors with least counter to the nodes of first edge. Update the counter.&#xA;3. Move to the next edge.&lt;br /&gt;&#xA;If either of the nodes are same as any of the previous, choose color with least counter for the connected node.&lt;br /&gt;&#xA;Else you can choose the previous two colors.&lt;br /&gt;&#xA;4. Update counter of colors.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-04-14T18:07:17.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10332" PostTypeId="1" AcceptedAnswerId="10336" CreationDate="2023-04-14T20:01:05.773" Score="0" ViewCount="76" Body="&lt;p&gt;I'm having trouble with the formulation of a linear program constraint, for an aggregate planning problem for 30 months.&lt;/p&gt;&#xA;&lt;p&gt;Company XYZ wants to maximize profit, and wants to know how many workers the company must have each month, how many workers should the company hire and how many should be laid-off?&lt;/p&gt;&#xA;&lt;p&gt;The constraint is as follows &amp;quot;Each hired worker must receive a training course, that will last 3 months, and can't be laid-off before the training ends&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Decision Variables are:&lt;/p&gt;&#xA;&lt;p&gt;a(t)= Number of workers in each day .&lt;/p&gt;&#xA;&lt;p&gt;b(t) = Number of manufactured units in each day .&lt;/p&gt;&#xA;&lt;p&gt;c(t)= Number of hired workers in each day.&lt;/p&gt;&#xA;&lt;p&gt;d(t)= Number of laid-off workers in each day.&lt;/p&gt;&#xA;&lt;p&gt;The balance constraint is : a(t)=a(t-1)+c(t)-d(t)&lt;/p&gt;&#xA;&lt;p&gt;I think the constraint would be:&lt;/p&gt;&#xA;&lt;p&gt;d(t)=0, t=1,2,3,&lt;/p&gt;&#xA;&lt;p&gt;d(t)&amp;lt;=c(t-3), t=4,5,6....30&lt;/p&gt;&#xA;&lt;p&gt;But I'm not sure.&lt;/p&gt;&#xA;" OwnerUserId="11643" LastActivityDate="2023-04-15T01:42:35.783" Title="Linear Programming aggregate planning" Tags="|optimization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10333" PostTypeId="2" ParentId="10332" CreationDate="2023-04-14T22:24:56.563" Score="0" Body="&lt;p&gt;Hint: The people you lay off must have been hired &lt;em&gt;at least&lt;/em&gt; three months (not days) earlier and must not have been laid off previously.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-14T22:24:56.563" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10334" PostTypeId="1" AcceptedAnswerId="10337" CreationDate="2023-04-14T23:36:25.273" Score="5" ViewCount="283" Body="&lt;p&gt;Consider a knapsack problem with binary variables and a standard knapsack constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in N}a_jx_j\leq b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A set &lt;span class=&quot;math-container&quot;&gt;$C\subseteq N$&lt;/span&gt; is a cover if &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in C}a_j &amp;gt;b$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$C\subseteq N$&lt;/span&gt; is a cover, then we can state a cover inequality (CI): &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in C}x_j \leq |C|-1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is a cover, and &lt;span class=&quot;math-container&quot;&gt;$S\subset C$&lt;/span&gt; is also a cover, then the CI &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in S}x_j \leq |S|-1$&lt;/span&gt; is stronger than the CI associated with &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;A cover &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is a minimal cover if &lt;span class=&quot;math-container&quot;&gt;$C\setminus \{j\}$&lt;/span&gt; is not a cover for all &lt;span class=&quot;math-container&quot;&gt;$j\in C$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; be a cover and &lt;span class=&quot;math-container&quot;&gt;$E=\{j:a_j\ge\max_{i\in C}a_i\}$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in C\cup E}x_j\leq |C|-1$&lt;/span&gt; is the extended CI.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\hat{x}$&lt;/span&gt; be the optimal solution to the LP relaxation of our knapsack problem. To find a violated CI, we can solve the following separation problem: &lt;span class=&quot;math-container&quot;&gt;$\exists C\subseteq N$&lt;/span&gt;, s.t. &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in C} a_j &amp;gt;b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in C}(1-\hat{x}_j)&amp;lt;1$&lt;/span&gt;?&#xA;This we can do by solving: &lt;span class=&quot;math-container&quot;&gt;$\min\{\sum_{j\in N}(1-\hat{x}_j)z_j | \sum_{j\in N}a_jz_j &amp;gt; b,z\textrm{ binary}\}$&lt;/span&gt;. If the objective is less than 1, the &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; variables define the violated cover.&lt;/p&gt;&#xA;&lt;p&gt;(i) While this separation problem finds a violated cover, this cover doesn't necessary have to be minimal? How to find a minimal violated cover inequality?&lt;/p&gt;&#xA;&lt;p&gt;(ii) Once we find a violated cover &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, we can strengthen the associated inequality, e.g. by writing an extended CI or by lifting. The relation between a lifted CI and an extended CI isn't quite obvious to me: is a lifted CI always at least as strong as an extended CI? What procedure would you use to strengthen &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;(iii) A sequential lifting procedure such as the one below depends on the order of the variables. Is there a suggested variable ordering that's best to use?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VfoFR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VfoFR.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;(iv) Are there other procedures than the above lifting procedure that you would consider that leads to potentially stronger inequalities?&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="500" LastEditDate="2023-04-15T04:36:01.420" LastActivityDate="2023-06-09T19:28:37.817" Title="Separating violated cover inequalities" Tags="|linear-programming|knapsack|cutting-planes|valid-inequalities|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10335" PostTypeId="2" ParentId="10321" CreationDate="2023-04-15T00:02:15.390" Score="2" Body="&lt;p&gt;This is a variant of Rob's improvement heuristic. Assume the nodes are indexed &lt;span class=&quot;math-container&quot;&gt;$1,\dots,N.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Assign a color to each node randomly.&lt;/li&gt;&#xA;&lt;li&gt;Shuffle the list &lt;span class=&quot;math-container&quot;&gt;$1,\dots,N$&lt;/span&gt; of node indices randomly.&lt;/li&gt;&#xA;&lt;li&gt;For each node in the shuffled list, compute the sum of edge weights to nodes in every color group and reassign the node to the &amp;quot;cheapest&amp;quot; color (which might be the current color of the node).&lt;/li&gt;&#xA;&lt;li&gt;After checking every node, repeat steps 2 and 3 until you make one full pass through the shuffled list without any nodes changing color.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Since this should be pretty fast computationally, you might want to do it multiple times and take the best solution.&lt;/p&gt;&#xA;&lt;p&gt;For something more sophisticated, there are ways to attack the problem using genetic algorithms.&lt;/p&gt;&#xA;&lt;p&gt;Addendum: I tried both the heuristic (with random restarts) and a GA on a 20 x 10 grid graph. Given equal run times, the heuristic seemed to outperform the GA. (I also tried solving the MIP model, with CPLEX, but gave up because the lower bound is too loose to reach proven optimality in the time I was willing to allocate.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-08-09T15:38:16.083" LastActivityDate="2023-08-09T15:38:16.083" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="10336" PostTypeId="2" ParentId="10332" CreationDate="2023-04-15T01:42:35.783" Score="0" Body="&lt;p&gt;It depends upon your objective function. As I mentioned in math.exchange site one constraint to add is the flow balance as &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ a_{t} = a_{t-1}+c_t - d_t $&lt;/span&gt;&lt;br /&gt;&#xA;where may be &lt;span class=&quot;math-container&quot;&gt;$ a_1  =0$&lt;/span&gt; if month index starts from &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You may expand your last constraint as such&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ d_1,d_2,d_3=0$&lt;/span&gt;: or no need to create them&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ d_{t+3} \le \sum_{k=1}^{t} c_t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here you are dealing with total numbers and continuous/integer variables. Depending upon your objective if you want to identify workers who are to be fired/retained then you need to define an indicator variable per worker indexed over time, like &lt;span class=&quot;math-container&quot;&gt;$ x_{w,t}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; can be an index for set of workers to hire from, like a pool, &lt;span class=&quot;math-container&quot;&gt;$ \{1,2,...W\}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; could be some higher bound like capacity. &lt;br /&gt;&#xA;You may need another indicator variable to define if a worker is hired from the pool in the first place.&lt;br /&gt;&#xA;If minimization then, depending upon the objective formula the solver will turn a subset of &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; as workers to be hired/retained.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-04-15T01:42:35.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10337" PostTypeId="2" ParentId="10334" CreationDate="2023-04-15T07:30:09.747" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;As a heuristic for finding a minimal violated cover inequality, you can solve your min-knapsack problem to find a cover &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;. Then, you may note that all objective function coefficients of the separation problem are non-negative, so it is only non-minimal if you have some &lt;span class=&quot;math-container&quot;&gt;$z_i=1$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\hat{x}_i=1$&lt;/span&gt;. Also note, that these variables does not contribute to the violation. Hence, you may simply look for items, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$z_i=\hat{x}_i=1$&lt;/span&gt; which can be removed without breaking the cover property. This way you maintain the violation.&#xA;Another approach is to consider the separation problem as a lexicographic optimisation problem where the high priority objective is to minimise your violation-objective, and the low priority goal is to minimise the cardinality of the cover. A lex-opt solution can be found by adding a small constant &lt;span class=&quot;math-container&quot;&gt;$\varepsilon&amp;gt;0$&lt;/span&gt; to all objective function coefficients, so the function to minimise becomes &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in N}(1-\hat{x}_j+\varepsilon)z_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I'm am not quite sure here, because the lifted cover inequality depends on your lifting sequence. Hence, it might be possible to come up with a lifting sequence that leads to a weaker inequality. What is true, however, is that there exist at least one lifted cover inequality, that defines a facet for the knapsack polytope. The extended cover inequality is not guaranteed to be facet defining. Hence, there exist cases where a lifted cover inequality strictly dominates the corresponding extended cover inequality. Note that an extended cover inequality is just a special case of a lifted cover inequality, so the best lifted cover inequality is as good or better than the extended cover inequality.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There are several suggestions for generating an ordering of the variables. For example &lt;a href=&quot;https://doi.org/10.1287/ijoc.10.4.427&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gu et al.&lt;/a&gt; propose a specific lifting sequence.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I would generally recommend the paper &amp;quot;&lt;a href=&quot;https://doi.org/10.1007/s10107-010-0359-5&quot; rel=&quot;nofollow noreferrer&quot;&gt;Separation algorithms for 0-1 knapsack polytopes&lt;/a&gt;&amp;quot; by K. Kaparis and A.N. Letchford in case you are interested in separation for the knapsack polytope.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="500" LastEditDate="2023-04-18T15:55:23.403" LastActivityDate="2023-04-18T15:55:23.403" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10338" PostTypeId="1" AcceptedAnswerId="10340" CreationDate="2023-04-15T11:47:33.107" Score="4" ViewCount="502" Body="&lt;p&gt;I have five integer variables, and I need to write some constraints on them:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; , &lt;span class=&quot;math-container&quot;&gt;$[x_1, x_2, x_3, x_4 ]$&lt;/span&gt;.  &lt;span class=&quot;math-container&quot;&gt;$1 \leq x_i \leq 3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$x_0 =1$&lt;/span&gt;  then no constraint on  &lt;span class=&quot;math-container&quot;&gt;$[x_1, x_2, x_3, x_4 ]$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$x_0 =2$&lt;/span&gt;  then  1 &lt;span class=&quot;math-container&quot;&gt;$\in$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$[x_1, x_2, x_3, x_4 ]$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$x_0 =3$&lt;/span&gt;  then  1,2 &lt;span class=&quot;math-container&quot;&gt;$\in$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$[x_1, x_2, x_3, x_4 ]$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;What is the most efficient way of doing it?&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="1160" LastEditDate="2023-04-16T16:21:55.797" LastActivityDate="2023-04-17T03:09:06.847" Title="How can I formulate this 'if-then' constraint problem?" Tags="|mixed-integer-programming|modeling|constraint-programming|logical-constraints|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10339" PostTypeId="2" ParentId="10321" CreationDate="2023-04-15T11:47:45.440" Score="2" Body="&lt;p&gt;The problem you are describing is strongly related to the Partial Directed Weighted Improper Coloring Problem which was studied for example in &lt;a href=&quot;https://espace2.etsmtl.ca/id/eprint/12488/2/Gagnon%20F.%202016%2012488%20Constructive%20algorithms%20for%20the%20partial%20directed.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;, where the authors show how such a coloring problem can model channel assignment in a network, in order to maximize network use, while respecting interference constraints.&lt;/p&gt;&#xA;&lt;p&gt;The authors have adapted the well known coloring algorithms (&lt;a href=&quot;https://www.geeksforgeeks.org/welsh-powell-graph-colouring-algorithm/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Welsh-Powell&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/DSatur&quot; rel=&quot;nofollow noreferrer&quot;&gt;DSATUR&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Recursive_largest_first_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;RLF&lt;/a&gt;) to this problem with a limited number of colors, and weights. The heuristics are similar to what @prubin and @RobPratt have proposed, but with some theoretical results (mainly time complexity), some improvements, and some numerical results. You can also find a MIP for the problem.&lt;/p&gt;&#xA;&lt;h3&gt;References&lt;/h3&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://espace2.etsmtl.ca/id/eprint/12488/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Constructive algorithms for the partial directed weighted improper coloring problem&lt;/a&gt; A Hertz, R Montagné, F Gagnon - Journal of Graph Algorithms and Applications, 2016&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0166218X18304657&quot; rel=&quot;nofollow noreferrer&quot;&gt;A comparison of integer programming models for the partial directed weighted improper coloring problem&lt;/a&gt; A Hertz, R Montagné, F Gagnon - Discrete Applied Mathematics, 2019&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2023-04-15T11:47:45.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10340" PostTypeId="2" ParentId="10338" CreationDate="2023-04-15T12:08:43.370" Score="6" Body="&lt;p&gt;Here is one option: first define &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; with binaries:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_i&amp;amp;=y_i^1+2y_i^2+3y_i^3 \\&#xA;1&amp;amp;=y_i^1+y_i^2+y_i^3 \\&#xA;y_i^j &amp;amp;\in \{0,1\}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can enforce &lt;span class=&quot;math-container&quot;&gt;$x_0=2 \implies 1 \in [x_1,x_2,x_3,x_4]$&lt;/span&gt; with:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_0^2 \implies \bigvee_{i=1}^4 y_i^1 \quad  \equiv \quad  y_0^2 \le \sum_{i=1}^4 y_i^1 &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And &lt;span class=&quot;math-container&quot;&gt;$x_0=3 \implies 1,2 \in [x_1,x_2,x_3,x_4] $&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$&#xA;y_0^3 \implies (\bigvee_{i=1}^4 y_i^1) \wedge (\bigvee_{i=1}^4 y_i^2)$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ y_0^3 \le \sum_{i=1}^4 y_i^1  \\&#xA;y_0^3 \le \sum_{i=1}^4 y_i^2 &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-04-15T16:56:45.793" LastActivityDate="2023-04-15T16:56:45.793" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10341" PostTypeId="2" ParentId="10318" CreationDate="2023-04-15T14:03:26.657" Score="0" Body="&lt;p&gt;If you have the funds &amp;amp; time you can try the online MS in OR from Florida Tech. There are other online Masters in OR like Georgia Tech or Industrial Engineering courses from a number of other universities but the one at Florida Tech should be the most cost effective.&lt;br /&gt;&#xA;Or if not full Masters, check if you can do individual courses on optimization. &lt;br /&gt;&#xA;Also check Udemy as well.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-04-15T14:03:26.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10342" PostTypeId="2" ParentId="10338" CreationDate="2023-04-15T14:21:38.207" Score="-1" Body="&lt;p&gt;As @RobPratt implies an integer can be expressed as &lt;span class=&quot;math-container&quot;&gt;$2^{n}y^{n}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$ n =\{0,1,2,...\}$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; as binary.&lt;br /&gt;&#xA;So integers &lt;span class=&quot;math-container&quot;&gt;$[x_i] $&lt;/span&gt; can be expressed as &lt;span class=&quot;math-container&quot;&gt;$2^ny_i^{n} $&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$n =\{0,1\}$&lt;/span&gt;&lt;br /&gt;&#xA;Constraints can be&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_0 - 1 \le 2\sum_{i=1}^4 y_{i}^0$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_0-2 \le \sum_i y_{i}^1 \le 5-x_0$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-04-15T22:12:01.977" LastActivityDate="2023-04-15T22:12:01.977" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10343" PostTypeId="2" ParentId="10327" CreationDate="2023-04-15T18:00:44.547" Score="0" Body="&lt;p&gt;FindMUS in MiniZinc might be of interest:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.minizinc.org/doc-2.5.3/en/find_mus.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.minizinc.org/doc-2.5.3/en/find_mus.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3236" LastActivityDate="2023-04-15T18:00:44.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10344" PostTypeId="2" ParentId="10338" CreationDate="2023-04-15T21:42:30.000" Score="3" Body="&lt;p&gt;Here’s a binary-expansion-based modification of @Kuifje’s formulation, and it uses fewer variables and constraints, but the last two are quadratic:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_i&amp;amp;=y_i^1+2y_i^2 &amp;amp;&amp;amp;\text{for $i\in\{0,\dots,4\}$}\\&#xA;1&amp;amp;\le y_i^1+y_i^2 &amp;amp;&amp;amp;\text{for $i\in\{0,\dots,4\}$}\\&#xA;y_i^j &amp;amp;\in \{0,1\} &amp;amp;&amp;amp;\text{for $i\in\{0,\dots,4\}$ and $j\in\{1,2\}$}\\&#xA;y_0^2 &amp;amp;\le \sum_{i=1}^4 y_i^1 (1-y_i^2) \\&#xA;y_0^1 + y_0^2 -1&amp;amp;\le \sum_{i=1}^4 y_i^2 (1-y_i^1)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are &lt;span class=&quot;math-container&quot;&gt;$196$&lt;/span&gt; feasible solutions.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://porta.zib.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PORTA&lt;/a&gt; yields the following (linear) formulation with &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$21$&lt;/span&gt; constraints for the &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; space:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_i^1 + y_i^2 &amp;amp;\ge 1 &amp;amp;&amp;amp;\text{for $i\in\{0,\dots,4\}$} \\&#xA;y_i^j &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for $i\in\{0,\dots,4\}$ and $j\in\{1,2\}$} \\&#xA;\sum_{i=0}^4 y_i^2 &amp;amp;\le 4 \\&#xA;y_0^1 + y_0^2 + \sum_{i=1}^4 y_i^1 &amp;amp;\le 5 \\&#xA;\sum_{i=0}^4 \sum_{j=1}^2 y_i^j &amp;amp;\le 7 + y_k^1 + y_k^2 &amp;amp;&amp;amp; \text{for $k\in\{1,2,3,4\}$} \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For comparison, note that PORTA yields the following formulation with &lt;span class=&quot;math-container&quot;&gt;$15$&lt;/span&gt; variables and &lt;span class=&quot;math-container&quot;&gt;$26$&lt;/span&gt; constraints for @Kuifje's &lt;span class=&quot;math-container&quot;&gt;$y_i^j$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{j=1}^3 y_i^j &amp;amp;= 1 &amp;amp;&amp;amp;\text{for $i\in\{0,\dots,4\}$}\\&#xA;y_i^j &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for $i\in\{0,\dots,4\}$ and $j\in\{1,2,3\}$} \\&#xA;y_0^3 &amp;amp;\le \sum_{i=1}^4 y_i^2 \\&#xA;\sum_{i=0}^4 y_i^3 &amp;amp;\le 3 + y_k^3 &amp;amp;&amp;amp;\text{for $k\in\{1,2,3,4\}$}\\&#xA;\sum_{i=0}^4 (y_i^2+y_i^3) &amp;amp;\le 4&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-04-17T03:09:06.847" LastActivityDate="2023-04-17T03:09:06.847" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10345" PostTypeId="1" CreationDate="2023-04-16T12:38:46.227" Score="1" ViewCount="69" Body="&lt;p&gt;When we use branch, price and cut method to solve VRPTW problems, the objectives is always:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;minimize the total distance, or&lt;/li&gt;&#xA;&lt;li&gt;minimize the sum of distance-related variable cost and truck-related fixed cost&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;But in reality, it's common that we want consider the working time related cost, which includes driving and waiting.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, except heuristics, &lt;em&gt;do we have any good ways to consider time cost in BPC or other exact methods&lt;/em&gt;?&lt;/p&gt;&#xA;&lt;p&gt;My understanding is that it should be very difficult since we can not deduce strong dominance rules to eliminate labels safely.&lt;/p&gt;&#xA;" OwnerUserId="11652" LastEditorUserId="36" LastEditDate="2023-04-16T13:33:15.350" LastActivityDate="2023-04-16T13:33:15.350" Title="How to consider time cost in VRP with BPC method" Tags="|vehicle-routing|branch-and-price|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10346" PostTypeId="2" ParentId="10319" CreationDate="2023-04-17T04:43:05.150" Score="1" Body="&lt;p&gt;(This is too long for a comment.)&lt;/p&gt;&#xA;&lt;p&gt;What I meant with my comment is this: given two candidate solutions to an optimization model, it is easy to figure out which is better. Insert each solution into the objective function; the solution with the lower objective function value is better (as you minimize).&lt;/p&gt;&#xA;&lt;p&gt;As pointed out by Enrique Gabriel Baquela in the comments, DE and similar methods require certain parameters to be set. Default parameters are rarely good choices, though in the case of DE, they often work remarkably robustly. But anyway, that leaves the number of iterations to be set. (See &lt;a href=&quot;http://enricoschumann.net/R/remarks.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://enricoschumann.net/R/remarks.htm&lt;/a&gt; for a discussion.)&lt;/p&gt;&#xA;&lt;p&gt;In your model, the two terms can be very similar. If the alphas are around 1.4, they can be identical. That means there is an identification problem; the objective function will be flat. DE can handle such cases, but typically requires a large population to do so efficiently (much larger than the 5-10 times the number of parameters, as is often a default choice).&lt;/p&gt;&#xA;&lt;p&gt;What is more, the parameter values can be quite extreme. For instance, if &lt;span class=&quot;math-container&quot;&gt;$q_2$&lt;/span&gt; is at &lt;span class=&quot;math-container&quot;&gt;$10^{30}$&lt;/span&gt;, say, the first term will vanish under standard computer arithmetic, because of rounding error.&lt;/p&gt;&#xA;&lt;p&gt;If you fixed the alpha parameters, then the model could be solved with Least Squares (if I understand it correctly). That suggests an alternative solution strategy: run a grid search over &lt;span class=&quot;math-container&quot;&gt;$\alpha_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha_2$&lt;/span&gt;, and for each vector of values compute the &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; parameters.  Here is a sketch in R; for the grid search, I use the implementation in package &lt;a href=&quot;https://cran.r-project.org/package=NMOF&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;NMOF&lt;/code&gt;&lt;/a&gt; (which I maintain):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;lambda &amp;lt;- c(375, 470, 528, 625, 880)&#xA;b &amp;lt;- c(228, 124, 98, 67, 44)&#xA;&#xA;par &amp;lt;- lower &amp;lt;- c(1000, 1000, 0.8, 1.4)&#xA;par &amp;lt;- upper &amp;lt;- c(1e10, 1e35, 1.5, 15.0)&#xA;&#xA;## original objective function&#xA;fun &amp;lt;- function(par, b, lambda) {&#xA;    res &amp;lt;- par[1]*lambda^(-par[3]) + par[2]*lambda^(-par[4])  - b&#xA;    sum(res*res)&#xA;}&#xA;&#xA;## LS objective function&#xA;fun.ls &amp;lt;- function(par, b, lambda) {&#xA;    QR &amp;lt;- qr(cbind(lambda^(-par[1]), lambda^(-par[2])))&#xA;    coef &amp;lt;- qr.solve(QR, b)&#xA;&#xA;    if (any(coef &amp;lt; lower[1:2] |  coef &amp;gt; upper[1:2]))&#xA;        ans &amp;lt;- 1e6  ## mark infeasible solutions with a large value&#xA;    else {&#xA;        ans &amp;lt;- qr.resid(QR, b)&#xA;        ans &amp;lt;- sum(ans*ans)&#xA;    }&#xA;    attr(ans, &amp;quot;coefficients&amp;quot;) &amp;lt;- coef&#xA;    ans&#xA;}&#xA;&#xA;## run a grid search&#xA;par &amp;lt;- c(0.8, 4.010101)&#xA;library(&amp;quot;NMOF&amp;quot;)&#xA;gs &amp;lt;- gridSearch(fun.ls,&#xA;                 lambda = lambda,&#xA;                 b = b,&#xA;                 lower = c(0.8, 1.4),&#xA;                 upper = c(1.5, 15),&#xA;                 n = 100)&#xA;## &lt;span class=&quot;math-container&quot;&gt;$minfun&#xA;## [1] 12.68621&#xA;## &#xA;## $&lt;/span&gt;minlevels&#xA;## [1] 0.800000 4.010101&#xA;&#xA;fun.ls(gs$minlevels, b, lambda)&#xA;## [1] 12.68621&#xA;## attr(,&amp;quot;coefficients&amp;quot;)&#xA;## [1] 8.598193e+03 3.212813e+12&#xA;&#xA;par &amp;lt;- c(8598.19, 3212813450654, 0.8, 4.010101)&#xA;fun(par, b, lambda)&#xA;## [1] 12.68621&#xA;&#xA;data.frame(b,&#xA;           fit = par[1]*lambda^(-par[3]) + par[2]*lambda^(-par[4]))&#xA;##     b       fit&#xA;## 1 228 228.04507&#xA;## 2 124 124.49555&#xA;## 3  98  95.85731&#xA;## 4  67  69.58422&#xA;## 5  44  42.91865&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11640" LastActivityDate="2023-04-17T04:43:05.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10347" PostTypeId="1" CreationDate="2023-04-17T08:39:12.580" Score="0" ViewCount="34" Body="&lt;p&gt;How to embed an arbitrary graph into (k,d)-kautz space (like multidimensional scaling of non-normed space)? See details in the following.&lt;/p&gt;&#xA;&lt;p&gt;Given a graph &lt;span class=&quot;math-container&quot;&gt;$G = \{V,E\}$&lt;/span&gt;,&#xA;we have a distance matrix (the shortest path matrix of &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\mathbf{D}_t=\{\theta_{u,v}|\forall v,u\in V\},&#xA;\end{equation}&lt;/span&gt;&#xA;how to embed the graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; into the &lt;span class=&quot;math-container&quot;&gt;$(k,d)$&lt;/span&gt;-kautz metric space, that is, optimize the coordinate &lt;span class=&quot;math-container&quot;&gt;$x_v$&lt;/span&gt; of each node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; in the &lt;span class=&quot;math-container&quot;&gt;$(k,d)$&lt;/span&gt;-kautz metric space to minimize the difference between &lt;span class=&quot;math-container&quot;&gt;$\rho(x_v,x_u)$&lt;/span&gt; and the distance matrix &lt;span class=&quot;math-container&quot;&gt;$\mathbf{D}_t$&lt;/span&gt;, as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} \label{eq:kautz_mds}&#xA;    \min_{\{x_v|\forall v \in V\}} \sum_{\forall v,u\in V} |\rho(x_v,x_u) - \theta_{u,v}| \ \  (1)&#xA;\end{equation}&lt;/span&gt;&#xA;where the coordinate &lt;span class=&quot;math-container&quot;&gt;$x_v$&lt;/span&gt; is a string of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; characters and &lt;span class=&quot;math-container&quot;&gt;$\rho(x_v,x_u)$&lt;/span&gt; represents the distance between &lt;span class=&quot;math-container&quot;&gt;$x_v$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_u$&lt;/span&gt;.&#xA;In the coordinate string &lt;span class=&quot;math-container&quot;&gt;$x_v$&lt;/span&gt;, each character has &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; choices, and the adjacent characters are different, which is formulated as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation*}&#xA;    \begin{split}&#xA;        &amp;amp;x_v = a_{1,v} a_{2,v} ...a_{2,v}...a_{k,v},\\&#xA;        % \textrm{s.t.\ }&#xA;        &amp;amp;\textrm{where}\ \ \forall i\in[1,k-1], a_{i,v} \in [1,d], \ a_{i,v}\neq a_{i+1,v}.&#xA;    \end{split}&#xA;\end{equation*}&lt;/span&gt;&#xA;The distance &lt;span class=&quot;math-container&quot;&gt;$\rho(x_v,x_u)$&lt;/span&gt; is  the length of the longest common prefix and suffix between &lt;span class=&quot;math-container&quot;&gt;$x_v$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_u$&lt;/span&gt;, which is formulated as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \rho(x_v,x_u)= k-\max(lcp(x_v,x_u), lcp(x_u,x_v))&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    lcp(x_v,x_u) = \max\ i,\ \ \textrm{s.t.}\ a_{1,v}... a_{i,v} = a_{k-i+1,u}... a_{k,u}&#xA;\end{equation}&lt;/span&gt;&#xA;The optimization problem in Eq. (1) is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} \label{eq:kautz_mds_transform}&#xA;    \min_{\hat V_s} \|\mathbf{D}_t-S(\mathbf{D}_s,\hat V_s)\|,\ \textrm{s.t.}\ \hat V_s \subset V_s, |\hat V_s| = |V| \ll |V_s|, (2)&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{D}_s$&lt;/span&gt; is the distance matrix of all feasible coordinates in the &lt;span class=&quot;math-container&quot;&gt;$(k,d)$&lt;/span&gt;-kautz metric space,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} &#xA;\mathbf{D}_s=\{\rho(x_v,x_u)|\forall v,u\in V_s\},\&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$V_s$&lt;/span&gt; is the set of all feasible coordinates in the &lt;span class=&quot;math-container&quot;&gt;$(k,d)$&lt;/span&gt;-kautz metric space, and&#xA;&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is to select a sub-matrix &lt;span class=&quot;math-container&quot;&gt;$S(\mathbf{D}_s,\hat V_s)$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$\mathbf{D}_s$&lt;/span&gt;, \ie the distance matrix of &lt;span class=&quot;math-container&quot;&gt;$\hat V_s$&lt;/span&gt;.&#xA;The problem in Eq. (2) is to select some coordinates &lt;span class=&quot;math-container&quot;&gt;$\hat V_s\subset V_s$&lt;/span&gt; as the coordinates of&#xA;all nodes in the graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; to minimize the difference between the target distance matrix &lt;span class=&quot;math-container&quot;&gt;$\mathbf{D}_t$&lt;/span&gt; and the distance matrix &lt;span class=&quot;math-container&quot;&gt;$S(\mathbf{D}_s,\hat V_s)$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$\hat V_s$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11657" LastEditorUserId="11657" LastEditDate="2023-04-17T12:26:58.277" LastActivityDate="2023-04-17T12:26:58.277" Title="How to embed an arbitrary graph into (k,d)-kautz space (like multidimensional scaling of non-normed space)" Tags="|optimization|combinatorial-optimization|graphs|machine-learning|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10348" PostTypeId="1" CreationDate="2023-04-18T09:01:18.470" Score="3" ViewCount="192" Body="&lt;p&gt;I am looking for an optimization challenge for an intern (such as ROADEF Challenge, Gecco competitions, or CEC competitions) active during summer 2023 (ideally July - September). Longer competitions or &amp;quot;small&amp;quot; competitions within conferences are ok.&lt;/p&gt;&#xA;&lt;p&gt;I'll be thankful for any tips!&lt;/p&gt;&#xA;" OwnerUserId="11660" LastActivityDate="2023-04-25T20:45:37.323" Title="Optimization challenges (currently active or soon to begin)" Tags="|combinatorial-optimization|heuristics|metaheuristics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10349" PostTypeId="1" CreationDate="2023-04-18T10:40:50.537" Score="1" ViewCount="36" Body="&lt;p&gt;I am trying to solve a non convex optimization problem with the help of sequential quadric programing. My optimization variables are complex and I have expressions for gradients, hessian etc but all these are in complex form. Let's say I am solving this problem using quadprog toolbox and inputs to this toolbox takes only real values. So what should I do about this&lt;/p&gt;&#xA;" OwnerUserId="11366" LastActivityDate="2023-04-18T12:31:50.163" Title="Non convex quadratic problem with complex variables" Tags="|quadratic-programming|nonconvex-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10350" PostTypeId="1" CreationDate="2023-04-18T10:55:22.860" Score="2" ViewCount="106" Body="&lt;p&gt;I am trying to solve a non-convex optimization problem with the help of sequential quadratic programming.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Sn9Fu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Sn9Fu.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I need to develop an algorithm inside SQP to solve this subproblem. What potential methods (conjugate gradient, etc) can be used to solve this, keeping in mind the Hessian &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; is not positive semidefinite?&lt;/p&gt;&#xA;" OwnerUserId="11366" LastEditorUserId="8" LastEditDate="2023-04-18T12:27:02.493" LastActivityDate="2023-04-19T06:50:52.297" Title="Potential methods for solving quadratic optmization problem" Tags="|optimization|nonlinear-programming|quadratic-programming|nonconvex-programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10351" PostTypeId="2" ParentId="10350" CreationDate="2023-04-18T12:07:43.277" Score="1" Body="&lt;p&gt;Use an off-the-shelf non-convex QP solver.  There is a choice  of solving to local optimality or to global optimality. Solving to local optimality is generally much faster, and may (but not necessarily) provide better overall algorithm progress (with starting point for the QP solve being the current iterate (incumbent)). That is because a local minimum is more likely to be close to the starting point, and therefore be in a region where the QP objective function is likely to  be a better model of the objective of the original problem. If the QP solves for the step to the new iterate (which your formulation apparently does based on &lt;span class=&quot;math-container&quot;&gt;$\Delta x$&lt;/span&gt; ), then a starting point of the vector of zeros can be used for the QP solve.&lt;/p&gt;&#xA;&lt;p&gt;Or use a damped BFGS update for the Hessian (which maintains positive semidefiniteness), combined with a convex QP solver.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2023-04-18T12:07:43.277" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10352" PostTypeId="2" ParentId="10349" CreationDate="2023-04-18T12:31:50.163" Score="1" Body="&lt;p&gt;If &lt;code&gt;x&lt;/code&gt; is the optimization complex vector variable, instead make the real variables, &lt;code&gt;x_real&lt;/code&gt; and &lt;code&gt;x_imaginary&lt;/code&gt;, the variables. Form the original complex variable problem in terms of those. This formulation only involves real variables.&lt;/p&gt;&#xA;&lt;p&gt;If you directly use &lt;code&gt;quadproog&lt;/code&gt;, rather than a more flexible front end such as YALMIP, you will have to &amp;quot;stack&amp;quot; &lt;code&gt;x_real&lt;/code&gt; and &lt;code&gt;x_imaginary&lt;/code&gt; into one vector variable. if you use YALMIP, you can specify the problem directly in terms of the complex variables, and YALMIP will do this transformation for you under the hood, saving you rime and reducing error propensity.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2023-04-18T12:31:50.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10353" PostTypeId="2" ParentId="10348" CreationDate="2023-04-18T12:39:06.920" Score="3" Body="&lt;p&gt;Lehigh University Modeling and Optimization: Theory and Applications (MOPTA) program.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://coral.ise.lehigh.edu/%7Emopta/competition&quot; rel=&quot;nofollow noreferrer&quot;&gt;15th AIMMS-MOPTA Optimization Modeling Competition&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Teams must consist of at most 3 students. An individual student working by themself might be at a disadvantage.&lt;/p&gt;&#xA;&lt;p&gt;Details are at&#xA;&lt;a href=&quot;https://coral.ise.lehigh.edu/%7Emopta/mopta2023/MOPTA2023_Competition.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;15th AIMMS-MOPTA Optimization Modeling Competition:&#xA;Planning Electric Vehicle Charging Stations&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-04-25T20:45:37.323" LastActivityDate="2023-04-25T20:45:37.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10354" PostTypeId="2" ParentId="10350" CreationDate="2023-04-19T06:50:52.297" Score="0" Body="&lt;p&gt;Why not try out an existing SQP method that solves indefinite QPs, such as filterSQP? It is extremely robust and efficient. As globalization strategies, it uses a filter strategy to accept/reject iterates and a trust region to restrict the length of the step.&#xA;It can even be tested online: &lt;a href=&quot;https://neos-server.org/neos/solvers/nco:filter/AMPL.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://neos-server.org/neos/solvers/nco:filter/AMPL.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10561" LastActivityDate="2023-04-19T06:50:52.297" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10355" PostTypeId="1" AcceptedAnswerId="10359" CreationDate="2023-04-19T10:11:09.783" Score="0" ViewCount="90" Body="&lt;p&gt;I have a linear programming problem. There are two questions:&lt;/p&gt;&#xA;&lt;p&gt;Consider 2 centers (1,2) that should serve clients [s,b,c,t], What it the minimum distance cost. The formulation is straight forward.&#xA;The LP problem is solved and then the indicated red and blue paths will be found (let's assume it is optimal). Solution A or B might be found.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{alignat}{2} &#xA;\min_{flow_{ij}} &amp;amp; \sum_{ij \in \Omega} D_{ij}flow_{ij} \\&#xA;&amp;amp; Source_i - Sink_i = \sum_{ij \in \Omega} flow_{ij}-flow_{ji} \\&#xA;&amp;amp; 0 \leq flow_{i,j} \leq f_{max} \\&#xA;&amp;amp; 0\leq Source_i \leq S_{max} \\&#xA;&amp;amp; Sink_i \textrm{ is a binary parameter , 1 for all non-source} \\&#xA;&amp;amp; \Omega \ \textrm{is the set of arcs} \\ &#xA;\end{alignat}$$&lt;/span&gt;&#xA;&lt;strong&gt;The second question is how to know which center is serving who by just looking at the network flow variables?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The ideal answer should be like:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 ---&amp;gt; [b,s]&lt;/li&gt;&#xA;&lt;li&gt;2 ---&amp;gt; [t,c]&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;ّI need to find the connected components (hopefully without solving extra optimization )&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ojp18.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ojp18.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2023-04-20T07:35:02.993" LastActivityDate="2023-04-20T13:04:33.707" Title="How to identify which node is serving each customer?" Tags="|optimization|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10356" PostTypeId="1" CreationDate="2023-04-19T13:45:23.697" Score="1" ViewCount="332" Body="&lt;p&gt;I have a non-linear program, minimizing sum of concave functions subject to linear constraints. Hence I'm using a different solver(in Julia). However, that solver assumes we have constraints in &lt;span class=&quot;math-container&quot;&gt;$Ax \le b$&lt;/span&gt; form and requires me to pass &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; as input parameters. This is very inconvenient as I explicitly do not have these matrices.&#xA;Since the constraints are linear, I plan to build them in cplex or gurobi and export the coefficient matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and right hand side &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; in some file and then import and read them in my NLP solver.&lt;/p&gt;&#xA;&lt;p&gt;So, is there a way to extract &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; from the cplex model?&#xA;I'm using docplex and guribipy.&lt;/p&gt;&#xA;&lt;p&gt;Also if there is a better way to resolve this, I'm all ears.&lt;/p&gt;&#xA;" OwnerUserId="10062" LastEditorUserId="491" LastEditDate="2023-04-24T15:36:47.950" LastActivityDate="2023-04-24T15:36:47.950" Title="Is there a way to obtain coefficient matrix A and RHS b of constraints equation from cplex or guribi in python?" Tags="|modeling|gurobi|nonconvex-programming|docplex|julia|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10357" PostTypeId="2" ParentId="10356" CreationDate="2023-04-19T15:39:56.390" Score="0" Body="&lt;p&gt;Let's assume that, when you build the model, you assign names to all constraints and variables and to the objective function. CPLEX (and I'm pretty sure Gurobi) can export the model to a text file in &lt;a href=&quot;https://en.wikipedia.org/wiki/MPS_(format)&quot; rel=&quot;nofollow noreferrer&quot;&gt;MPS format&lt;/a&gt;. You can write code (in Python or Julia) to create the required matrices, initially filled with zeros, and then read in the MPS file, parse it, and plug the entries in it into the correct slots in the matrices.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-19T15:39:56.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10358" PostTypeId="2" ParentId="10356" CreationDate="2023-04-19T17:25:09.217" Score="1" Body="&lt;p&gt;In gurobi, you can use &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_model_geta.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;model.getA()&lt;/code&gt;&lt;/a&gt; query to get the linear coeff matrix in sparse format.&lt;br /&gt;&#xA;You can get list of linear constraints using &lt;code&gt;model.getConstrs()&lt;/code&gt; &amp;amp; also get attributes like &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/rhs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;rhs&lt;/a&gt;, &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_model_getrow.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;lhs&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/sense.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;sense&lt;/a&gt;.&lt;br /&gt;&#xA;You can output the model in python through &lt;code&gt;model.write('filename.mps')&lt;/code&gt;. You can read in a model through &lt;code&gt;model.read()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="491" LastEditDate="2023-04-24T15:35:49.047" LastActivityDate="2023-04-24T15:35:49.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10359" PostTypeId="2" ParentId="10355" CreationDate="2023-04-20T13:04:33.707" Score="1" Body="&lt;p&gt;Like you mentioned, you want to find the connected components of the support graph of the flow variables.  Explicitly, let &lt;span class=&quot;math-container&quot;&gt;$$S=\{(i,j)\in\Omega: \text{flow}_{ij}&amp;gt;0 \lor \text{flow}_{ji}&amp;gt;0\},$$&lt;/span&gt;&#xA;initialize each node to be in its own component, and loop over &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; once, where in each iteration &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; of the loop you merge the two components for node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. At the end, the nodes served by a center are the ones that appear in the same component as that center.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-04-20T13:04:33.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10360" PostTypeId="1" CreationDate="2023-04-20T19:38:19.507" Score="6" ViewCount="1617" Body="&lt;p&gt;In a game I am trying to optimize for, the goal of the game is to get each of your 23 &amp;quot;skills&amp;quot; to exceed a certain amount of &amp;quot;experience&amp;quot; in the shortest time possible. There are various &amp;quot;training methods&amp;quot; you can use to gain experience in possibly multiple skills at once, and each of these methods has a set amount of experience per unit-time you gain for using that training method.&lt;/p&gt;&#xA;&lt;p&gt;For example, the goal might be to get skill A to at least 10,000 experience, and skill B to at least 5,000 experience, and there are 3 methods:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Method 1 gives 10 experience in skill A and 5 experience in skill B per hour&lt;/li&gt;&#xA;&lt;li&gt;Method 2 gives 20 experience in skill A and 0 experience in skill B per hour&lt;/li&gt;&#xA;&lt;li&gt;Method 3 gives 0 experience in skill A and 7 experience in skill B per hour&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;We want to reach the experience goals while spending the minimal number of hours. So far this seems like a classic LP, where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}$&lt;/span&gt; contains each method's hourly rates for each skill, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is the experience goal, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the number of hours spent on each method, and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is just the ones-vector... and we want to minimize &lt;span class=&quot;math-container&quot;&gt;$b\cdot x$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}x \ge c$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However...what happens if each &amp;quot;training method&amp;quot; itself has a &amp;quot;feasible region&amp;quot; in which it can be trained? For example, say Method 1 can't be used until you have at least 2,000 experience in skill A. Can this still be formulated as something resembling a LP, or does it suddenly become a much harder problem because the order of events starts to matter? Do you know of any research on this sort of problem, where it's a dual LP except each &amp;quot;thing you can spend time on&amp;quot; has its own resource requirements?&lt;/p&gt;&#xA;" OwnerUserId="11672" LastEditorUserId="11672" LastEditDate="2023-04-20T19:38:52.743" LastActivityDate="2023-04-21T14:18:00.610" Title="Linear programming, except each &quot;thing you can spend time on&quot; has its own feasible region/requirements" Tags="|linear-programming|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10361" PostTypeId="2" ParentId="10360" CreationDate="2023-04-20T21:35:06.323" Score="4" Body="&lt;p&gt;The first part of your problem is identical to the well known &lt;a href=&quot;https://en.wikipedia.org/wiki/Stigler_diet&quot; rel=&quot;nofollow noreferrer&quot;&gt;Diet problem&lt;/a&gt;. See e.g. this &lt;a href=&quot;https://neos-guide.org/case-studies/om/the-diet-problem/#:%7E:text=The%20problem%20is%20formulated%20as,and%20cholesterol%20in%20the%20diet.&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the 2nd part of your question, ordering becomes important, i.e. the order in which you acquire skills. There's various ways you could model this. One way would be a dynamic program, where a state represents (i) experience level for each skill and (ii) total hours of accumulated training. A state transition is performed by taking 1 hour of a particular method. A state &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt; dominates a state &lt;span class=&quot;math-container&quot;&gt;$S_2$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$S_1$&lt;/span&gt; spent fewer hours to accumulate the same or higher experience levels than &lt;span class=&quot;math-container&quot;&gt;$S_2$&lt;/span&gt;. A terminal state is a state where the experience levels for each skill meet or exceed the target experience levels. You could implement this as a labeling algorithm.&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2023-04-20T21:35:06.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10362" PostTypeId="2" ParentId="10360" CreationDate="2023-04-20T21:52:43.763" Score="7" Body="&lt;p&gt;Without knowing the full problem, it is difficult to be definitive. That said, I suspect you can model this as a mixed integer linear program (MILP), assuming that you are only training one person and that person can only perform a single training task at any time. You would use binary variables, one for each combination of time period (hour) and method, to indicate if you were using that training method in that hour. You would use a nonnegative continuous variable for each combination of skill and hour to indicate your &amp;quot;inventory&amp;quot; (level) of that skill at the end of that hour. Constraints would limit you to at most a single method in each hour, update skill inventory based based on training method, and impose any restrictions on particular methods that could be expressed in terms of skill inventory (such as needing 2,000 experience in skill A to employ method 1). To minimize total training time, you could minimize the sum of the binary variables.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-20T21:52:43.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10363" PostTypeId="2" ParentId="10360" CreationDate="2023-04-20T22:09:05.650" Score="2" Body="&lt;p&gt;I cant comment on specific method but I'd go with MILP, say by the given example, training method &lt;span class=&quot;math-container&quot;&gt;$ \alpha$&lt;/span&gt; from among all other methods &lt;span class=&quot;math-container&quot;&gt;${t}$&lt;/span&gt; cant be used until training of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; hrs completed for skill s. So&lt;br /&gt;&#xA;Using a binary variable &lt;span class=&quot;math-container&quot;&gt;$ \delta_s = 1$&lt;/span&gt; if accumulated training hours for skill &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$H_s$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise, you'd need couple of constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ T_{min}(\delta_s - 1) \le \sum_{t \neq \alpha} A_t x_t - H_s \le T_{max}\delta_s$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$T_{min} \delta_s \le x_{\alpha}A_{\alpha} \le T_{max}\delta_s$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$ 0 \le T_{max}$&lt;/span&gt; can be large number, may be capacity in terms of hours possible &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$ 0\le T_{min}$&lt;/span&gt; is a small number, like minimum training hours needed.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-04-21T00:45:44.393" LastActivityDate="2023-04-21T00:45:44.393" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10364" PostTypeId="2" ParentId="10360" CreationDate="2023-04-21T14:18:00.610" Score="0" Body="&lt;p&gt;For clarity of discussion, I've written down a mathematisation/formalisation of your problem. I think I've got all the aspects you mention, but comment if I missed anything you want.&lt;/p&gt;&#xA;&lt;p&gt;Given&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; of size &lt;span class=&quot;math-container&quot;&gt;$m \times n$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;an 'enabling matrix' &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; of size &lt;span class=&quot;math-container&quot;&gt;$m \times n$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;a boolean 'enabled vector' &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; of length &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;an input vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; of length &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;an output bound vector &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; of length &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, and&lt;/li&gt;&#xA;&lt;li&gt;a weights vector &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; of length &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;We want to solve the optimisation problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;&amp;amp;\mathbf{minimise}\ c \cdot x\\&#xA;&amp;amp;\mathbf{subject\ to}\\&#xA;&amp;amp;\quad A (x \circ \alpha) \geq b \\&#xA;&amp;amp;\quad x \geq 0 \\&#xA;&amp;amp;\quad \alpha_j = [K e_j \leq A(x \circ \alpha)]&#xA;    \qquad(\text{for}\ 1 \leq j \leq n)&#xA;\end{align}$$&lt;/span&gt;&#xA;and where &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Hadamard_product_(matrices)&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hadamard product&lt;/a&gt; and &lt;span class=&quot;math-container&quot;&gt;$[P] = \begin{cases} 1 \quad\text{if}\ P \\ 0 \quad\text{if}\ \neg P  \end{cases}\ $&lt;/span&gt; the &lt;a href=&quot;https://en.wikipedia.org/wiki/Iverson_bracket&quot; rel=&quot;nofollow noreferrer&quot;&gt;Iverson bracket&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, the difficult thing about this is &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;, the definition of which is dependent on the output of the multiplication of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$x \cdot \alpha$&lt;/span&gt;, which includes &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; again! I feel like this is going to make the problem very hard, unless I've missed some clever encoding.&lt;/p&gt;&#xA;" OwnerUserId="11675" LastActivityDate="2023-04-21T14:18:00.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10365" PostTypeId="1" AcceptedAnswerId="10376" CreationDate="2023-04-21T23:30:30.257" Score="2" ViewCount="127" Body="&lt;p&gt;I have probability values &lt;span class=&quot;math-container&quot;&gt;$p \in \mathbb{R}^n$&lt;/span&gt;. Given &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{m\times n}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b \in \mathbb{R}^m$&lt;/span&gt;, I want to minimize the following objective function. &lt;span class=&quot;math-container&quot;&gt;$||Ap - b||_2^2 + \sum_{i=1}^{n-2} (\log(p_i) - 2\log(p_{i + 1}) + \log(p_{i+2}))^2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to &lt;span class=&quot;math-container&quot;&gt;$\sum p_i = 1$&lt;/span&gt;.&#xA;Unfortunately, the second term is non-convex. I have tried to do change of variables &lt;span class=&quot;math-container&quot;&gt;$y_i = \exp(x_i)$&lt;/span&gt; to make the second term convex, but then the first term is non-convex.&lt;/p&gt;&#xA;&lt;p&gt;I have two questions.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is a good way to optimize this problem?&lt;/li&gt;&#xA;&lt;li&gt;I believe that this objective function doesn't have any local minimums besides the global minimum (perhaps with some weak assumptions). Is this true? If so, how could I solve this?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10044" LastActivityDate="2023-04-24T12:38:48.930" Title="Optimize least squares penalized by curvature of log pdf" Tags="|optimization|nonlinear-programming|global-optimization|local-minimum|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="10366" PostTypeId="1" AcceptedAnswerId="10369" CreationDate="2023-04-22T20:38:37.820" Score="3" ViewCount="99" Body="&lt;p&gt;Is the following expression a knapsack constraint?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_i a(i) y(i) \ge W$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$y(i)$&lt;/span&gt; binaries, &lt;span class=&quot;math-container&quot;&gt;$a(i),W$&lt;/span&gt; reals.&lt;/p&gt;&#xA;&lt;p&gt;What confuses me is the &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; sign.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, do solvers generate cuts out of this expression?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2023-04-23T16:05:09.743" Title="Knapsack Constraint" Tags="|mixed-integer-programming|knapsack|cuts|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10367" PostTypeId="2" ParentId="10366" CreationDate="2023-04-22T21:18:20.583" Score="0" Body="&lt;p&gt;Either you are looking at &lt;a href=&quot;http://archive.dimacs.rutgers.edu/reconnect/Lafayette/lectures/knaplecture.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;knapsack&lt;/a&gt; cover (&lt;span class=&quot;math-container&quot;&gt;$a_i(1-y)_i$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$y_i=0$&lt;/span&gt;) inequality or its part of minimizing &lt;a href=&quot;https://www.cs.jhu.edu/%7Emdinitz/classes/ApproxAlgorithms/Spring2019/Lectures/lecture24.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;knapsack&lt;/a&gt; problem. Modern solvers will relax the MIP and then may apply cuts like Gomory cuts.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-04-22T21:46:08.750" LastActivityDate="2023-04-22T21:46:08.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10368" PostTypeId="2" ParentId="10365" CreationDate="2023-04-23T15:43:26.173" Score="1" Body="&lt;p&gt;The following is a heuristic, meaning I cannot prove it converges to an optimum. It generates a sequence of solutions with monotonically decreasing objective values, so it will at least converge to a local minimum.&lt;/p&gt;&#xA;&lt;p&gt;In addition to the original constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_i p_i = 1,$&lt;/span&gt; we also require that &lt;span class=&quot;math-container&quot;&gt;$p_i \ge \epsilon\, \forall i$&lt;/span&gt; for some positive constant &lt;span class=&quot;math-container&quot;&gt;$\epsilon,$&lt;/span&gt; to avoid have the logs blow up. Let &lt;span class=&quot;math-container&quot;&gt;$f(p)$&lt;/span&gt; denote the original objective function. We will use a change of variables. The new variables &lt;span class=&quot;math-container&quot;&gt;$x_0,\dots,x_n$&lt;/span&gt; are defined by &lt;span class=&quot;math-container&quot;&gt;$x_0=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_j = \sum_{i=1}^j p_i$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$j=1,\dots,n$&lt;/span&gt; (implying &lt;span class=&quot;math-container&quot;&gt;$x_n = 1$&lt;/span&gt;). The reverse transformation is &lt;span class=&quot;math-container&quot;&gt;$p_i = x_i - x_{i-1},$&lt;/span&gt; which we denote by &lt;span class=&quot;math-container&quot;&gt;$p = \pi(x).$&lt;/span&gt; To ensure &lt;span class=&quot;math-container&quot;&gt;$p_i \ge \epsilon,$&lt;/span&gt; we require &lt;span class=&quot;math-container&quot;&gt;$x_{i-1} + \epsilon \le x_i \le x_{i+1} - \epsilon.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now let &lt;span class=&quot;math-container&quot;&gt;$g(x)=f(\pi(x)).$&lt;/span&gt; We want to minimize &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$x_0=1 &amp;lt; x_1 &amp;lt; \dots &amp;lt; x_n = 1$&lt;/span&gt; with the &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; difference requirements described above. The heuristic proceeds as follows.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Generate an initial feasible solution and record it as an incumbent. This could be done randomly, or you could start with &lt;span class=&quot;math-container&quot;&gt;$p=(1/n,1/n,\dots,1/n)$&lt;/span&gt; (and convert it to the equivalent &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Repeat the following loop until a full pass through the loop produces no change in the incumbent solution.&lt;/p&gt;&#xA;&lt;p&gt;a. Shuffle the indices &lt;span class=&quot;math-container&quot;&gt;$1,\dots,n-1,$&lt;/span&gt; calling the resulting list &lt;span class=&quot;math-container&quot;&gt;$L.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;b. For each &lt;span class=&quot;math-container&quot;&gt;$i\in L,$&lt;/span&gt; search for the value &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; in the interval &lt;span class=&quot;math-container&quot;&gt;$[x_{i-1} + \epsilon, x_{i+1} - \epsilon]$&lt;/span&gt; that minimizes &lt;span class=&quot;math-container&quot;&gt;$g(x_0,\dots, x_{i-1}, \xi, x_{i+1},\dots, x_n).$&lt;/span&gt; If the new objective value is less than that of the incumbent, make the new &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; vector the new incumbent.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Step 2b requires an algorithm to optimize a function of one variable over a closed interval. Depending on what language you are using, there may well be library routines for this available. (I did some tests in R, using the &lt;code&gt;optimize&lt;/code&gt; method from the standard &lt;code&gt;stats&lt;/code&gt; package.) Worst case, you can code something like golden section search very easily.&lt;/p&gt;&#xA;&lt;p&gt;The virtue of using a random starting solution is that, in the event that the global minimum is not the only local minimum, you can run the heuristic multiple times with different starts and hope to get lucky.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I also tried gradient projection in R, using the &lt;code&gt;BB&lt;/code&gt; library. It generated a better solution to my test problem, in considerably less time. The time difference is in part due to &lt;code&gt;BB&lt;/code&gt; being coded in a compiled language by better coders than I, but the improved solution is attributable to the method.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-04-23T22:23:55.037" LastActivityDate="2023-04-23T22:23:55.037" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10369" PostTypeId="2" ParentId="10366" CreationDate="2023-04-23T16:01:21.670" Score="2" Body="&lt;p&gt;If you complement the variables &lt;span class=&quot;math-container&quot;&gt;$y_i=1−z_i$&lt;/span&gt;, substitute, and rearrange terms, you get a classic knapsack constraint. And yes, solvers generally separate cuts from all available structures.&lt;/p&gt;&#xA;&lt;p&gt;A simple set of valid inequalities (which could be used as cuts) for your “inverted knapsack constraint” are the so-called &lt;em&gt;knapsack cover inequalities&lt;/em&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i\in N\setminus S}\min \left\{ a_i, W-\sum_{i\in S}a_i\right\}y_i\geq W-\sum_{i\in S}a_i&#xA;$$&lt;/span&gt;&#xA;Here &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is the index set for the variables, and &lt;span class=&quot;math-container&quot;&gt;$S\subseteq N$&lt;/span&gt; is such that &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in S}a_i&amp;lt;W$&lt;/span&gt;. In “&lt;a href=&quot;https://www.lancaster.ac.uk/staff/letchfoa/articles/knapsack-cover.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lifting the Knapsack Cover Inequalities for the Knapsack Polytope&lt;/a&gt;” Letchford and Souli show how to strengthen these inequalities through lifting.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="500" LastEditDate="2023-04-23T16:05:09.743" LastActivityDate="2023-04-23T16:05:09.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10370" PostTypeId="1" AcceptedAnswerId="10371" CreationDate="2023-04-23T16:16:28.943" Score="1" ViewCount="82" Body="&lt;p&gt;This is a follow up question of &lt;a href=&quot;https://or.stackexchange.com/questions/10299/traffic-lights-optimization&quot;&gt;this thread&lt;/a&gt;, in which it is asked how to model a circular layout of a given set of cliques of a graph, which represent simultaneous movements at an intersection.&lt;/p&gt;&#xA;&lt;p&gt;@prubin proposed a model, which is satisfactory and elegant, but which relies on the fact that the right set of cliques are part of the given inputs:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; be the number of cliques and let &lt;span class=&quot;math-container&quot;&gt;$H_m=\lbrace i : m\in&#xA;K_i\rbrace$&lt;/span&gt; for all movements &lt;span class=&quot;math-container&quot;&gt;$m\in M.$&lt;/span&gt; Define binary variables&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; for all pairs of clique indices &lt;span class=&quot;math-container&quot;&gt;$i\neq j,$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$z_{ij}=1$&lt;/span&gt;&#xA;will signal that clique &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; follows clique &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in a clockwise&#xA;traversal of your circle. Fix &lt;span class=&quot;math-container&quot;&gt;$z_{ii}=0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (to simplify the&#xA;indexing in what follows) and add the constraints &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^k z_{ij}&#xA;= 1\quad \forall j\in \lbrace 1,\dots, k\rbrace \tag{1}$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=1}^k z_{ij} = 1\quad \forall i\in \lbrace 1,\dots, k\rbrace \tag{2}$$&lt;/span&gt; to ensure&#xA;that every clique is preceded/followed by exactly one clique.&lt;/p&gt;&#xA;&lt;p&gt;Now for each movement &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; add the constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j\in H_m : i &amp;lt;&#xA; j} ( z_{ij} + z_{ji}) \ge \vert H_m \vert - 1 \tag{3}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I would now like to know how to proceed if the cliques are not given as an input. That is, I  would like to simultaneously define the cliques, and the circular layout. Note that considering all maximal cliques of the graph is not necessarily a good idea, as no circular layout may exist which such sets.&lt;/p&gt;&#xA;&lt;p&gt;Adapting @prubin's model sounds possible with additional binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{mi}$&lt;/span&gt; that take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if node/movement &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is part of clique &lt;span class=&quot;math-container&quot;&gt;$K_i$&lt;/span&gt;, and binary variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; that take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if clique &lt;span class=&quot;math-container&quot;&gt;$K_i$&lt;/span&gt; is selected.&lt;/p&gt;&#xA;&lt;p&gt;Every node/movement &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; should be part of at least one clique:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i x_{mi}\ge 1 \quad \forall v$$&lt;/span&gt;&#xA;Cliques should be well defined:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{mi}+x_{ni}\le y_i \quad \forall (m,n)\notin E, \;\forall K_i&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints &lt;strong&gt;(1)&lt;/strong&gt; and &lt;strong&gt;(2)&lt;/strong&gt; could be modified as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^k z_{ij}&#xA;= y_j\quad \forall j\in \lbrace 1,\dots, k\rbrace \tag{1}$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=1}^k z_{ij} = y_i\quad \forall i\in \lbrace 1,\dots, k\rbrace \tag{2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However I am unsure how to adapt constraint &lt;strong&gt;(3)&lt;/strong&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Also, variables should be defined differently, as &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is undefined.&lt;/p&gt;&#xA;&lt;p&gt;Is there a better approach than this?&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-04-23T16:33:52.807" LastActivityDate="2023-04-23T19:37:22.320" Title="Traffic lights optimization (part 2)" Tags="|mixed-integer-programming|modeling|graphs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10371" PostTypeId="2" ParentId="10370" CreationDate="2023-04-23T19:37:22.320" Score="1" Body="&lt;p&gt;Given your definition of &lt;span class=&quot;math-container&quot;&gt;$x_{mi},$&lt;/span&gt; we should have &lt;span class=&quot;math-container&quot;&gt;$m\in K_i \iff x_{mi}=1,$&lt;/span&gt; and thus &lt;span class=&quot;math-container&quot;&gt;$H_m = \lbrace i: x_{mi}=1 \rbrace.$&lt;/span&gt; So &lt;span class=&quot;math-container&quot;&gt;$\vert H_m \vert = \sum_i x_{mi}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As for &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; being undefined, one possibility is to solve the model for a fairly large value of &lt;span class=&quot;math-container&quot;&gt;$k.$&lt;/span&gt; If not all &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; cliques are used, you can either accept the solution or, if it has too many cliques (meaning the combination of traffic light states would cause the drivers to freak out) try with a smaller &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and see if the problem remains feasible and the objective value is acceptable. If all cliques are used, trying increasing &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and see if the objective improves and the complexity remains acceptable. If the problem is infeasible, definitely increase &lt;span class=&quot;math-container&quot;&gt;$k.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-23T19:37:22.320" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10372" PostTypeId="1" CreationDate="2023-04-23T23:22:23.873" Score="0" ViewCount="115" Body="&lt;p&gt;I have to find the dual of following LP:&lt;/p&gt;&#xA;&lt;p&gt;Minimize    &lt;span class=&quot;math-container&quot;&gt;$ x_1 + x_2 + x_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$4x_1 + 8x_2 \geq3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$7x_2 + 4x_3 \leq 6$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$3x_1 - 2x_2 + 5x_3 = 7$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1 \leq 0, x_2 \geq 0, x_3$&lt;/span&gt; is unrestricted&lt;/p&gt;&#xA;&lt;p&gt;I changed it into a canonical form,changed the maximum to minimum, coefficients of objective function into the value of the  constraints and took the transpose of the coefficient matrix,for the &lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt;, I let &lt;span class=&quot;math-container&quot;&gt;$x_3 =x_3^{'} - x_3^{''}$&lt;/span&gt; where both &lt;span class=&quot;math-container&quot;&gt;$x_3^{'}$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$x_3^{''}$&lt;/span&gt; are positive. For equality in the constraints, I split it into &lt;span class=&quot;math-container&quot;&gt;$\geq$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I also managed to satisfy the number of constraints and variables in the prime and dual. I noticed after all this steps that, &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; was restricted to be negative.&lt;/p&gt;&#xA;&lt;p&gt;So should I introduce a new variable &lt;span class=&quot;math-container&quot;&gt;$x_1^{'} =-x_1$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;If not, how do I address it?&lt;/p&gt;&#xA;" OwnerUserId="11683" LastEditorUserId="491" LastEditDate="2023-04-24T15:41:40.120" LastActivityDate="2023-04-24T15:41:40.120" Title="Dual of a LP with a variable restricted to be negative" Tags="|linear-programming|dual|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10376" PostTypeId="2" ParentId="10365" CreationDate="2023-04-24T12:01:48.900" Score="2" Body="&lt;p&gt;You could just throw this at a global NLP solver. For &amp;quot;small&amp;quot; instances they can prove global optimality. I tried the following using GAMS/Baron:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Set&#xA;  i /i1*i25/&#xA;  j /j1*j25/&#xA;;&#xA;&#xA;parameter A(i,j), b(i);&#xA;A(i,j) = uniform(0,1);&#xA;b(i) = uniform(0,1);&#xA;&#xA;variable p(j),z;&#xA;p.lo(j) = 0.001;&#xA;p.up(j) = 1;&#xA;&#xA;equations obj,e;&#xA;&#xA;obj.. z =e= sum(i,sqr(sum(j,A(i,j)*p(j))-b(i))) +&#xA;            sum(j$(ord(j)&amp;lt;=card(j)-2), sqr(log(p(j))-2*log(p(j+1))+log(p(j+2))));&#xA;            &#xA;e.. sum(j,p(j)) =e= 1;&#xA;&#xA;model m /all/;&#xA;option nlp=baron, threads=0;&#xA;solve m minimizing z using nlp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This gives:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;===========================================================================&#xA; BARON version 23.3.11. Built: WIN-64 Sat Mar 11 18:01:20 EST 2023&#xA;&#xA; BARON is a product of The Optimization Firm.&#xA; For information on BARON, see https://minlp.com/about-baron&#xA;&#xA; If you use this software, please cite publications from&#xA; https://minlp.com/baron-publications, such as: &#xA;&#xA; Khajavirad, A. and N. V. Sahinidis,&#xA; A hybrid LP/NLP paradigm for global optimization relaxations,&#xA; Mathematical Programming Computation, 10, 383-421, 2018.&#xA;===========================================================================&#xA; This BARON run may utilize the following subsolver(s)&#xA; For LP/MIP/QP: CLP/CBC, ILOG CPLEX                             &#xA; For NLP: MINOS, SNOPT, External NLP, IPOPT, FILTERSQP&#xA;===========================================================================&#xA; Doing local search&#xA; Preprocessing found feasible solution with value 2.10908&#xA; Solving bounding LP&#xA; Starting multi-start local search&#xA; Done with local search&#xA;===========================================================================&#xA;  Iteration    Open nodes         Time (s)    Lower bound      Upper bound&#xA;          1             1             0.59      1.72152          2.10908&#xA;       1526            83            29.75      2.00708          2.10908&#xA;       4691            73            59.41      2.00708          2.10908&#xA;       7903            74            89.16      2.00708          2.10908&#xA;      10797            62           118.78      2.00708          2.10908&#xA;      13761            51           148.61      2.00820          2.10908&#xA;      16724            49           178.17      2.00820          2.10908&#xA;      19677            41           207.70      2.00820          2.10908&#xA;      22105            36           237.20      2.00820          2.10908&#xA;      24746            26           267.09      2.00820          2.10908&#xA;      27238            18           296.91      2.00820          2.10908&#xA;      29698            17           326.59      2.04487          2.10908&#xA;      31844            10           356.42      2.04487          2.10908&#xA;      34535            14           386.00      2.05357          2.10908&#xA;      37169            10           415.53      2.06959          2.10908&#xA;      39835             5           445.19      2.07546          2.10908&#xA;      42543             7           474.88      2.08354          2.10908&#xA;      43439             0           484.69      2.10886          2.10908&#xA;&#xA; Calculating duals&#xA;&#xA;                         *** Normal completion ***            &#xA;&#xA; Wall clock time:                   490.83&#xA; Total CPU time used:               484.69&#xA;&#xA; Total no. of BaR iterations:   43439&#xA; Best solution found at node:      -1&#xA; Max. no. of nodes in memory:      88&#xA; &#xA; All done&#xA;===========================================================================&#xA;&#xA;Solution      = 2.10907512234556  best solution found during preprocessing&#xA;Best possible = 2.10886421617&#xA;Absolute gap  = 0.00021090617555819  optca = 1E-9&#xA;Relative gap  = 9.99993662262895E-5  optcr = 0.0001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Baron finds the global optimum during preprocessing but proving global optimality takes a bit of time. This could be a confirmation that the local optimum is indeed globally optimal. The penalty term seems rather small (for my random data) compared to the LS term.&lt;/p&gt;&#xA;&lt;p&gt;Note: you can use &lt;a href=&quot;https://neos-server.org/neos/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://neos-server.org/neos/&lt;/a&gt; to solve this. This can also be useful to verify results found by your own algorithms. NEOS gives you access to different global NLP solvers (both under AMPL and GAMS).&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2023-04-24T12:38:48.930" LastActivityDate="2023-04-24T12:38:48.930" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10377" PostTypeId="1" AcceptedAnswerId="10410" CreationDate="2023-04-24T12:03:52.010" Score="1" ViewCount="121" Body="&lt;p&gt;I plan to use sigmoidal programming from the git repo &lt;a href=&quot;https://github.com/madeleineudell/SigmoidalProgramming.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/madeleineudell/SigmoidalProgramming.jl&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are some issues with the implementation of this repo. It requires me to pass &lt;span class=&quot;math-container&quot;&gt;$A, b, C, d$&lt;/span&gt; from the equation set (&lt;span class=&quot;math-container&quot;&gt;$Ax\le b$&lt;/span&gt;) and (&lt;span class=&quot;math-container&quot;&gt;$Cx=d$&lt;/span&gt;). It is really difficult to construct these matrices because docplex or gurobipy output matrix in sparse format. Moreover they have equality and inequality embedded in the same matrix with slacks I think. So to decouple them into &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; and correspondingly &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; vectors. The initial plan was to use gurobi or cplex to construct the equations and export the matrices and right hand sides but it's getting more difficult.&lt;/p&gt;&#xA;&lt;p&gt;Can anyone suggest a workaround for this?&lt;/p&gt;&#xA;" OwnerUserId="10062" LastEditorUserId="491" LastEditDate="2023-04-24T15:31:52.977" LastActivityDate="2023-05-05T10:57:09.777" Title="Sigmoidal programming" Tags="|constraint|docplex|gurobipy|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10378" PostTypeId="1" CreationDate="2023-04-25T20:23:20.610" Score="1" ViewCount="40" Body="&lt;p&gt;For a long-done project presentation, I implemented the &lt;a href=&quot;https://www.math.wsu.edu/math/faculty/lih/MDKP.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Primal Effective Capacity (PECH) Heuristic&lt;/a&gt; to look for initial greedy solutions for the Multidimensional Knapsack (MDK) problem in Python. I looked into this specific heuristic because the class I was presenting to wanted a simple initial algorithm that was easy to understand, but also because my main PC only has 3GB of RAM and I needed in-place solving heuristic due to this limitation - loading large MDK problems into DoCplex always crashed my PC due to Mem Errors. Regardless, the definition of the MDK problem I was using is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max z = \sum_{i\in N}c_ix_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{Subject to: }\qquad\qquad\qquad\qquad\qquad\qquad$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in N}w_{ji}x_i\le b_j,\quad\forall j\in m$$&lt;/span&gt;&#xA;Where &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; denotes the total number of items &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; denotes the total number of bags &lt;span class=&quot;math-container&quot;&gt;$b_j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; denotes the cost of using item &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$_{ji}$&lt;/span&gt; denotes the weight of using item &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; in bag &lt;span class=&quot;math-container&quot;&gt;$b_j$&lt;/span&gt;. There are two formulations for &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; that I am solving for each problem in which &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; can either be binary or an integer.&lt;/p&gt;&#xA;&lt;p&gt;The original steps of the PECH algorithm is as follows:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Select a &lt;span class=&quot;math-container&quot;&gt;$\alpha \in [0,1]$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Initialize all decision variables, &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt;, for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Initialize all the Effective Capacity, &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;, to be the set of all indices of &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Then do the following while True:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Compute the effective capacity for all items &lt;span class=&quot;math-container&quot;&gt;$\bar y_i = \min_j \left(\lfloor \frac{\bar b_j}{w_{ji}}\rfloor : w_{ji} &amp;gt; 0 \right)\forall i\in E$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$\bar y_i = 0\quad\forall i \in E$&lt;/span&gt;, then end the loop.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Compute the improvement for all items: &lt;span class=&quot;math-container&quot;&gt;$c_i\cdot \bar y_i,\quad\forall i\in E$&lt;/span&gt;, then select the best improvement &lt;span class=&quot;math-container&quot;&gt;$i^* = \arg\max_{i\in E}(c_i\cdot \bar y_i)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Compute the improvement of the best element &lt;span class=&quot;math-container&quot;&gt;$i^*$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$y_{i^*}=\min(\bar u_{i^*}, \max(1, \lfloor \alpha\cdot\bar y_{i^*}\rfloor))$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Update the improving decision variable: &lt;span class=&quot;math-container&quot;&gt;$x_{i^*} = x_{i^*} + y_{i^*}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Update the remaining capacities of each bag: &lt;span class=&quot;math-container&quot;&gt;$b_j = b_j - w_{ji^*}\cdot y_{i^*},\quad\forall j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Update upper bounds: &lt;span class=&quot;math-container&quot;&gt;$u_{i^*} = u_{i^*}-y_{i^*}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$u_{i^*} = 0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\alpha = 1$&lt;/span&gt;, then remove &lt;span class=&quot;math-container&quot;&gt;$i^*$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;, and if &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is empty, then end the loop.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Report the final solution obtained.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Because I did not know at the time how to safely hot-remove indices &lt;span class=&quot;math-container&quot;&gt;$i^*$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; while not ruining the step involving &lt;span class=&quot;math-container&quot;&gt;$i^*$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$y_{i^*}=\min(\bar u_{i^*}, \max(1, \lfloor \alpha\cdot\bar y_{i^*}\rfloor))$&lt;/span&gt;, I changed the algorithm to become the following:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Select a &lt;span class=&quot;math-container&quot;&gt;$\alpha \in [0,1]$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Initialize all decision variables, &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt;, for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Initialize all the Effective Capacity, &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;, to be the set of all indices of &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Initialize a integer counter &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$t=0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Initialize a largest number &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Then do the following while True:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;(all of these steps are the same)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$u_{i^*} = 0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\alpha = 1$&lt;/span&gt;, then set &lt;span class=&quot;math-container&quot;&gt;$c_{i^*} = -M$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t=t+1$&lt;/span&gt;, and if &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; equals the amount of elements in &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;, then end the&#xA;loop.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Report the final solution obtained.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I ended up figuring out later how to delete indexes from arrays, but one thing I noticed is that if I followed their original algorithm, I got a substantially much worse solution than the one I modified (both solutions are feasible). For example, for a binary 100 items and 5 bags knapsack problem, DoCplex reports an objective of &lt;span class=&quot;math-container&quot;&gt;$59822$&lt;/span&gt;, my modified PECH reports an objective of &lt;span class=&quot;math-container&quot;&gt;$58386$&lt;/span&gt;, and their original reports &lt;span class=&quot;math-container&quot;&gt;$37896$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My question is this: Why did this simple change derive a better solution? Effectively, they both should be doing the same thing. I've been &lt;em&gt;strongly&lt;/em&gt; thinking it was my code/implementation, but even when I had my professor and colleagues look at it and they said they didn't know and didn't see anything wrong or wierd (aside from the objective values).&lt;/p&gt;&#xA;" OwnerUserId="10807" LastEditorUserId="10807" LastEditDate="2023-04-25T22:46:22.177" LastActivityDate="2023-04-25T22:46:22.177" Title="Why does changing this one thing in the Primal Effective Capacity Heuristic improve the solutions it generates for the MDK problem?" Tags="|python|heuristics|knapsack|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10379" PostTypeId="1" CreationDate="2023-04-26T00:27:27.190" Score="1" ViewCount="74" Body="&lt;p&gt;I have a maximization problem as shown in the picture below. The output has a common shock z that follows a two-state Markov chain with a transition matrix Π. Does anyone know how I would go about solving this by discrete-state-space dynamic programming?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dW7zY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dW7zY.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BMUzz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BMUzz.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11701" LastActivityDate="2023-04-26T04:45:44.403" Title="Solving stochastic dynamic problem by space state MATLAB program" Tags="|dynamic-programming|matlab|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10380" PostTypeId="2" ParentId="10379" CreationDate="2023-04-26T04:45:44.403" Score="1" Body="&lt;p&gt;Best I know as I used in my own paper is MDP toolbox which proposes functions related to the resolution of discrete-time Markov Decision Processes: backwards induction, value iteration, policy iteration, linear programming algorithms with some variants.&lt;/p&gt;&#xA;&lt;p&gt;Can be downloaded from Toolbox page: &lt;a href=&quot;http://www.inra.fr/mia/T/MDPtoolbox&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.inra.fr/mia/T/MDPtoolbox&lt;/a&gt; or the following address:(Marie-Josee Cros (2023). Markov Decision Processes (MDP) Toolbox)&#xA;&lt;a href=&quot;https://www.mathworks.com/matlabcentral/fileexchange/25786-markov-decision-processes-mdp-toolbox&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.mathworks.com/matlabcentral/fileexchange/25786-markov-decision-processes-mdp-toolbox&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2023-04-26T04:45:44.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10381" PostTypeId="1" AcceptedAnswerId="10382" CreationDate="2023-04-26T17:35:15.190" Score="1" ViewCount="173" Body="&lt;p&gt;I'm using Python and the GLPK Solver to find recommendations for an infeasible problem.&lt;/p&gt;&#xA;&lt;p&gt;I'm optimizing for price, and this is the problem data:&lt;/p&gt;&#xA;&lt;h1&gt;Define problem data&lt;/h1&gt;&#xA;&lt;p&gt;foods = ['Food 0', 'Food 1', 'Food 2', 'Food 3',&#xA;'Food 4', 'Food 5', 'Food 6', 'Food 7']&#xA;nutrients = ['Nutrient 0', 'Nutrient 1', 'Nutrient 2', 'Nutrient 3',&#xA;'Nutrient 4', 'Nutrient 5', 'Nutrient 6', 'Nutrient 7']&#xA;food_costs = [2.10, 3.00, 1.50, 4.26, 0.50, 0.84, 2.40, 0.75]&lt;/p&gt;&#xA;&lt;p&gt;nutrient_matrix = [&#xA;[0.10, 0.20, 0.15, 0.05, 0.05, 0.10, 0.15, 0.10],&#xA;[0.05, 0.10, 0.20, 0.10, 0.15, 0.15, 0.15, 0.15],&#xA;[0.15, 0.05, 0.10, 0.20, 0.25, 0.10, 0.10, 0.20],&#xA;[0.05, 0.20, 0.05, 0.15, 0.25, 0.25, 0.20, 0.10],&#xA;[0.10, 0.15, 0.25, 0.15, 0.05, 0.10, 0.05, 0.20],&#xA;[0.30, 0.05, 0.15, 0.25, 0.10, 0.15, 0.05, 0.10],&#xA;[0.20, 0.10, 0.10, 0.05, 0.20, 0.20, 0.15, 0.10],&#xA;[0.15, 0.25, 0.15, 0.10, 0.15, 0.10, 0.10, 0.15],&#xA;]&#xA;nutrient_bounds = [(0.1, 0.2), (0.05, 0.1), (0.1, 0.2),&#xA;(0.1, 0.15), (0.1, 0.2), (0.1, 0.2), (0.1, 0.2), (0.1, 0.2)]&#xA;food_bounds = [(0.1, 0.3), (0.1, 0.3), (0.1, 0.3), (0.1, 0.3),&#xA;(0.1, 0.3), (0.1, 0.3), (0.1, 0.3), (0.1, 0.3)]&#xA;It's a nutrition problem where I have foods and nutrients, both having constraints.&lt;/p&gt;&#xA;&lt;p&gt;Since the problem is infeasible, I have to make changes to the food constraints to make it feasible.&lt;/p&gt;&#xA;&lt;p&gt;The feasible solution is found when Food 0 has its upper bound set to 0.4 and Food 2 has it's lower bound set to 0.&lt;/p&gt;&#xA;&lt;p&gt;I'm trying to develop a code that gives recommendations to what Foods need their bounds changed and to what direction (lower / upper) when a problem is infeasible.&lt;/p&gt;&#xA;&lt;p&gt;The result of the problem should be:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Make changes to the upper bound of Food 0 ; Make changes to the lower bound of food 2.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;I have tried everything from Farkas and Dual variables but I can't find the solution. Can anyone help?&lt;/p&gt;&#xA;&lt;p&gt;Here is where I stopped on my code:&lt;/p&gt;&#xA;&lt;p&gt;import cvxpy as cp&#xA;import numpy as np&lt;/p&gt;&#xA;&lt;h1&gt;Define problem data&lt;/h1&gt;&#xA;&lt;p&gt;foods = ['Food 0', 'Food 1', 'Food 2', 'Food 3',&#xA;'Food 4', 'Food 5', 'Food 6', 'Food 7']&#xA;nutrients = ['Nutrient 0', 'Nutrient 1', 'Nutrient 2', 'Nutrient 3',&#xA;'Nutrient 4', 'Nutrient 5', 'Nutrient 6', 'Nutrient 7']&#xA;food_costs = [2.10, 3.00, 1.50, 4.26, 0.50, 0.84, 2.40, 0.75]&lt;/p&gt;&#xA;&lt;p&gt;nutrient_matrix = [&#xA;[0.10, 0.20, 0.15, 0.05, 0.05, 0.10, 0.15, 0.10],&#xA;[0.05, 0.10, 0.20, 0.10, 0.15, 0.15, 0.15, 0.15],&#xA;[0.15, 0.05, 0.10, 0.20, 0.25, 0.10, 0.10, 0.20],&#xA;[0.05, 0.20, 0.05, 0.15, 0.25, 0.25, 0.20, 0.10],&#xA;[0.10, 0.15, 0.25, 0.15, 0.05, 0.10, 0.05, 0.20],&#xA;[0.30, 0.05, 0.15, 0.25, 0.10, 0.15, 0.05, 0.10],&#xA;[0.20, 0.10, 0.10, 0.05, 0.20, 0.20, 0.15, 0.10],&#xA;[0.15, 0.25, 0.15, 0.10, 0.15, 0.10, 0.10, 0.15],&#xA;]&#xA;nutrient_bounds = [(0.1, 0.2), (0.05, 0.1), (0.1, 0.2),&#xA;(0.1, 0.15), (0.1, 0.2), (0.1, 0.2), (0.1, 0.2), (0.1, 0.2)]&#xA;food_bounds = [(0.1, 0.3), (0.1, 0.3), (0.1, 0.3), (0.1, 0.3),&#xA;(0.1, 0.3), (0.1, 0.3), (0.1, 0.3), (0.1, 0.3)]&lt;/p&gt;&#xA;&lt;h1&gt;Define the function to solve the problem&lt;/h1&gt;&#xA;&lt;p&gt;def solve_problem(food_bounds, nutrient_bounds, nutrient_matrix, food_costs):&#xA;# Create the variables&#xA;food_vars = cp.Variable(len(foods), nonneg=True)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Objective function: Minimize cost&#xA;objective = cp.Minimize(cp.sum(food_costs @ food_vars))&#xA;&#xA;# Nutrient constraints&#xA;nutrient_constraints = [&#xA;    cp.sum(np.array(nutrient_matrix)[i] @&#xA;           food_vars) &amp;gt;= nutrient_bounds[i][0]&#xA;    for i in range(len(nutrients))&#xA;] + [&#xA;    cp.sum(np.array(nutrient_matrix)[i] @&#xA;           food_vars) &amp;lt;= nutrient_bounds[i][1]&#xA;    for i in range(len(nutrients))&#xA;]&#xA;&#xA;# Food constraints&#xA;food_constraints = [&#xA;    food_vars[i] &amp;gt;= food_bounds[i][0] for i in range(len(foods))&#xA;] + [&#xA;    food_vars[i] &amp;lt;= food_bounds[i][1] for i in range(len(foods))&#xA;]&#xA;&#xA;# Sum of food percentages constraint&#xA;total_percentage_constraint = [cp.sum(food_vars) == 1]&#xA;&#xA;# Combine all constraints&#xA;constraints = nutrient_constraints + \&#xA;    food_constraints + total_percentage_constraint&#xA;&#xA;# Create the problem&#xA;prob = cp.Problem(objective, constraints)&#xA;&#xA;# Solve the problem&#xA;prob.solve(solver=cp.GLPK)&#xA;&#xA;return prob, constraints, food_vars&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;def compute_dual_values(original_prob, constraints):&#xA;dual_vars = [cp.Variable(nonneg=True) for _ in constraints]&#xA;slack_vars = [cp.Variable() for _ in constraints]&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dual_constraints = []&#xA;for dual_var, constraint, slack_var in zip(dual_vars, constraints, slack_vars):&#xA;    A = constraint.args[0].T  # Transpose of the constraint matrix&#xA;    x = constraint.args[1]&#xA;    dual_constraints.append(slack_var == A @ x - dual_var)&#xA;&#xA;dual_prob = cp.Problem(cp.Minimize(cp.sum(slack_vars)), dual_constraints)&#xA;dual_prob.solve(solver=cp.GLPK)&#xA;&#xA;return [dual_var.value for dual_var in dual_vars]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;def analyze_food_constraints(constraints, dual_vars):&#xA;food_constraint_indices = list(&#xA;range(len(constraints) - len(foods) * 2, len(constraints)))&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;largest_duals = sorted(food_constraint_indices,&#xA;                       key=lambda i: abs(dual_vars[i]), reverse=True)&#xA;&#xA;recommendations = []&#xA;for i in largest_duals:&#xA;    if abs(dual_vars[i]) &amp;gt; 1e-6:&#xA;        food_index = i - len(constraints) + len(foods)&#xA;        if food_index &amp;lt; len(foods):&#xA;            bound_type = &amp;quot;lower&amp;quot;&#xA;        else:&#xA;            food_index -= len(foods)&#xA;            bound_type = &amp;quot;upper&amp;quot;&#xA;&#xA;        recommendations.append(&#xA;            f&amp;quot;Recommend changing the {bound_type} bound of Food {food_index}.&amp;quot;)&#xA;&#xA;return recommendations&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Call the function to solve the original problem&lt;/h1&gt;&#xA;&lt;p&gt;original_prob, constraints, food_vars = solve_problem(&#xA;food_bounds, nutrient_bounds, nutrient_matrix, food_costs)&lt;/p&gt;&#xA;&lt;h1&gt;Check if the original problem is infeasible&lt;/h1&gt;&#xA;&lt;p&gt;if original_prob.status == cp.INFEASIBLE:&#xA;print(&amp;quot;The original problem is infeasible. Analyzing constraints...&amp;quot;)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Obtain the dual variables (shadow prices)&#xA;dual_vars = compute_dual_values(original_prob, constraints)&#xA;&#xA;# Analyze food constraints&#xA;recommendations = analyze_food_constraints(constraints, dual_vars)&#xA;&#xA;# Print recommendations&#xA;for recommendation in recommendations:&#xA;    print(recommendation)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;else:&#xA;print(&amp;quot;Status:&amp;quot;, original_prob.status)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Print the optimal food quantities and cost if the problem is feasible&#xA;print(&amp;quot;Optimal food quantities (percentage of meal):&amp;quot;)&#xA;for i, food in enumerate(foods):&#xA;    print(f&amp;quot;{food}: {food_vars.value[i] * 100:.2f}%&amp;quot;)&#xA;&#xA;print(&amp;quot;Optimal meal cost per kilogram: ${:.2f}&amp;quot;.format(&#xA;    original_prob.value))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11708" LastActivityDate="2023-04-26T17:59:17.193" Title="Python and GLPK to solve Linear programming problem (infeasible solution)" Tags="|linear-programming|python|glpk|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10382" PostTypeId="2" ParentId="10381" CreationDate="2023-04-26T17:59:17.193" Score="2" Body="&lt;p&gt;The first step is deciding what constraints you are willing to relax. It appears that you have chosen to relax the bounds on food quantities (as opposed to nutrient requirements).&lt;/p&gt;&#xA;&lt;p&gt;The next step is to decide how to &amp;quot;price&amp;quot; the relaxations. Is relaxing the upper bound on food #1 by 1 kg. better than, the same as or worse than relaxing the lower bound on food #2 by 1 kg.? This is a question that probably needs to be answered by whoever instituted those bounds in the first place.&lt;/p&gt;&#xA;&lt;p&gt;A possible third step is to decide how much you are willing to relax each bound. That might be an individual decision or a &amp;quot;group&amp;quot; decision. For instance, if there are three foods that are considered &amp;quot;pasta&amp;quot;, you might say that you are willing to increase total pasta by 10 kg. and leave it to the solver to decide how to split the increase among the three foods.&lt;/p&gt;&#xA;&lt;p&gt;Once you know all this, you can add variables to the model representing the increase or decrease in each relevant bound, change the objective function to minimizing the total cost/penalty for those changes, and solve the modified problem. The solution will tell you how to adjust the bounds to make the problem feasible, after which you can solve the original model with the modified bounds.&lt;/p&gt;&#xA;&lt;p&gt;Besides the somewhat subjective aspects of the questions above, there is one other caveat. If you make the minimum changes necessary to achieve feasibility, you might wind up with a model with a very small feasible region (perhaps a single point), which might produce a very unsatisfying solution to the original problem. An alternative approach is to insert the new variables (sometimes described as &amp;quot;artificial&amp;quot; variables) and optimize a weighted combination of the original objective and a cost/penalty for the bounds changes. The tricky part of this approach is assigning a cost for the changes (e.g., increasing the bound on food 1 by 1 kg. &amp;quot;costs&amp;quot; the same as buying 3 kg. of food 2).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-26T17:59:17.193" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10383" PostTypeId="1" AcceptedAnswerId="10384" CreationDate="2023-04-27T02:19:24.167" Score="1" ViewCount="564" Body="&lt;p&gt;I'm new to operation research. I'm confusing about the sign of reduced cost and I have a few questions that I'd like to ask. Suppose that I solve a maximization problem, considering a variable x with positive coefficient, then&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the sign of the reduced cost of this variable if in the solution x &amp;gt; 0 ?&lt;/li&gt;&#xA;&lt;li&gt;If x &amp;gt; 0 in the solution, then is x a basic variable ?&lt;/li&gt;&#xA;&lt;li&gt;How do you interpret the sign of reduced cost in a maximization problem ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Thank you for your time&lt;/p&gt;&#xA;" OwnerUserId="11713" LastActivityDate="2023-04-27T02:36:54.110" Title="Sign of the reduced cost in LP" Tags="|optimization|linear-programming|reduced-costs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10384" PostTypeId="2" ParentId="10383" CreationDate="2023-04-27T02:36:54.110" Score="1" Body="&lt;p&gt;The reduced cost of a nonbasic variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the net rate of change to the objective if you increase the value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; by a small amount and optimally adjust the other variables to preserve feasibility. Regardless of whether you are maximizing or minimizing, a positive reduced cost means increasing &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; will increase the objective value and a negative reduced cost means increasing &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; will decrease the objective value. The reduced cost of a basic variable is always 0.&lt;/p&gt;&#xA;&lt;p&gt;Assuming that the problem has been solved to optimality, and assuming that the domain of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$[0, \infty)$&lt;/span&gt; (typical for most LP formulations), then if &lt;span class=&quot;math-container&quot;&gt;$x&amp;gt;0$&lt;/span&gt; in the optimal solution it will be a basic variable, and if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is basic the reduced cost will be 0.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; has a nonzero lower bound &lt;span class=&quot;math-container&quot;&gt;$\ell &amp;gt; 0$&lt;/span&gt; that is expressed as a bound on the variable rather than as a constraint (meaning that the constraint matrix does not include &lt;span class=&quot;math-container&quot;&gt;$x\ge \ell$&lt;/span&gt;), and if &lt;span class=&quot;math-container&quot;&gt;$x=\ell$&lt;/span&gt; in the solution, then it may be nonbasic even though it is positive. The same is true if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; has a finite upper bound &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; expressed as a bound rather than a constraint and &lt;span class=&quot;math-container&quot;&gt;$x=u$&lt;/span&gt; in the optimal solution. This is because there are versions of the simplex algorithm that handle a lower bound &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; by substituting &lt;span class=&quot;math-container&quot;&gt;$\hat{x}=x - \ell$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in the model, and handle an upper bound &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; by substituting &lt;span class=&quot;math-container&quot;&gt;$\hat{x} = u - x$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; hits its upper bound.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-04-27T02:36:54.110" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10386" PostTypeId="1" CreationDate="2023-04-27T19:55:36.560" Score="1" ViewCount="55" Body="&lt;p&gt;I am looking for some help in Plant Network Optimization- as an example scenario would be to optimize the Plant network based on the below inputs and figure out best possible plants to use to service the given demand. Model should also provide some fictitious locations where we should have a plant setup and be able to turn off/on current plants based on the below inputs and constraints.&lt;/p&gt;&#xA;&lt;p&gt;As this is an experimental study, I would like to use open solver here and wanted to see if any scholar or an academic person would like to help me out as a freelancer&lt;/p&gt;&#xA;&lt;p&gt;Modelling Inputs&#xA;Plants  - 5 in the network across USA with a specified location&#xA;Products - 1000&#xA;Customers - 5&lt;/p&gt;&#xA;&lt;p&gt;Attributes - Inputs:&#xA;Demand - ( Product/Plant/Customer/Month/Zip Code)&#xA;Fixed Cost( Plant)&#xA;Variable Cost( Plant/Product)&#xA;Logistics Cost( Product/Customer/Zip)&#xA;Capacity available( Plant/Month)&#xA;Capacity needed( Plant/Product/Month)&lt;/p&gt;&#xA;&lt;p&gt;Constraints:&#xA;Capacity Needed &amp;lt;= Capacity available&#xA;Supply &amp;lt;= demand&lt;/p&gt;&#xA;&lt;p&gt;Outputs:&#xA;Cost to serve&#xA;Logistics cost&#xA;Fixed Cost&#xA;Variable costs&lt;/p&gt;&#xA;" OwnerUserId="11720" LastActivityDate="2023-04-27T19:55:36.560" Title="Plant Network model" Tags="|optimization|mixed-integer-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10387" PostTypeId="1" CreationDate="2023-04-28T12:04:32.267" Score="2" ViewCount="220" Body="&lt;p&gt;I have written a huge optimization code in pyomo. The code serves for any planning horizon. The variables are indexed in time (&lt;em&gt;t&lt;/em&gt;). When I set &lt;em&gt;t&lt;/em&gt; to have 365 days, the termination condition is feasible/optimal. It solves the planning for a year, but when I set &lt;em&gt;t&lt;/em&gt; having a cardinality equal to 500, the problem gives a termination condition different of infeasible. It makes no sense, since the problem is controlled, stable and linear, the solution should be feasible (termination condition = feasible/optimal). Conversely, it gives the terminal condition &amp;quot;other&amp;quot;. What does it mean? Does it have any reference to provide information about &amp;quot;other&amp;quot;? Does Pyomo or GLPK solver is limited?&lt;/p&gt;&#xA;&lt;p&gt;The status of the solver is:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;# ==========================================================&#xA;# = Solver Results                                         =&#xA;# ==========================================================&#xA;# ----------------------------------------------------------&#xA;#   Problem Information&#xA;# ----------------------------------------------------------&#xA;Problem: &#xA;- Name: unknown&#xA;  Lower bound: -inf&#xA;  Upper bound: inf&#xA;  Number of objectives: 1&#xA;  Number of constraints: 71102&#xA;  Number of variables: 42302&#xA;  Number of nonzeros: 1161420&#xA;  Sense: maximize&#xA;# ----------------------------------------------------------&#xA;#   Solver Information&#xA;# ----------------------------------------------------------&#xA;Solver: &#xA;- Status: ok&#xA;  Termination condition: other&#xA;  Statistics: &#xA;    Branch and bound: &#xA;      Number of bounded subproblems: 0&#xA;      Number of created subproblems: 0&#xA;  Error rc: 0&#xA;  Time: 202.43064308166504&#xA;&#xA;Funcobj =  4500&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11726" LastEditorUserId="11726" LastEditDate="2023-04-29T12:57:21.290" LastActivityDate="2023-04-29T12:57:21.290" Title="Pyomo Terminal Condition: other" Tags="|python|solver|pyomo|glpk|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10388" PostTypeId="1" AcceptedAnswerId="10389" CreationDate="2023-04-29T10:22:59.723" Score="1" ViewCount="55" Body="&lt;p&gt;I would like to seek some advice on modeling the following logical implications, where &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; is a binary variable, &lt;span class=&quot;math-container&quot;&gt;$D_{j}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_{j}$&lt;/span&gt; are nonnegative discrete variables, and &lt;span class=&quot;math-container&quot;&gt;$p_{j}$&lt;/span&gt; are nonnegative discrete parameter values.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\delta = 1 \implies D_{j}+p_{j}\gt A_{j} \lor D_{j}+p_{j}\lt A_{j} \tag1\label1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$D_{j}+p_{j}\gt A_{j} \lor D_{j}+p_{j}\lt A_{j} \implies \delta = 1 \tag2\label2$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3682" LastEditorUserId="500" LastEditDate="2023-04-29T16:58:41.253" LastActivityDate="2023-04-29T17:12:02.663" Title="Assistance in formulating implication constraints for inequalities" Tags="|mixed-integer-programming|modeling|binary-variable|logical-constraints|indicator-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10389" PostTypeId="2" ParentId="10388" CreationDate="2023-04-29T10:44:32.773" Score="2" Body="&lt;p&gt;Apply the formulation given in &lt;a href=&quot;https://or.stackexchange.com/a/2632/500&quot;&gt;https://or.stackexchange.com/a/2632/500&lt;/a&gt; with &lt;span class=&quot;math-container&quot;&gt;$y=1-\delta$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x=D_j-A_j$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$b=-p_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Assuming by “discrete” you mean that &lt;span class=&quot;math-container&quot;&gt;$D_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A_j$&lt;/span&gt; are integer-valued, you can use a tolerance of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; (the &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; in the linked answer).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If you want to enforce only &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$\delta_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\delta_2$&lt;/span&gt;, and impose linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\delta &amp;amp;\le \delta_1 + \delta_2 \\&#xA;-D_j - p_j + A_j + 1 &amp;amp;\le M_1 (1-\delta_1) \\&#xA;D_j + p_j - A_j + 1 &amp;amp;\le M_2 (1-\delta_2)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you want to enforce only &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;,&#xA;consider its contrapositive&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\delta = 0 \implies D_{j}+p_{j}\le A_{j} \land D_{j}+p_{j}\ge A_{j},$$&lt;/span&gt;&#xA;which you can enforce via&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;D_j + p_j - A_j &amp;amp;\le M_3 \delta \\&#xA;-D_j - p_j + A_j &amp;amp;\le M_4 \delta&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-04-29T17:12:02.663" LastActivityDate="2023-04-29T17:12:02.663" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10390" PostTypeId="1" AcceptedAnswerId="10392" CreationDate="2023-04-29T16:16:48.417" Score="5" ViewCount="293" Body="&lt;p&gt;Read this &lt;a href=&quot;https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4296668/&quot; rel=&quot;noreferrer&quot;&gt;article&lt;/a&gt; on potential application of Markov Decision Process in decision making process of patient evaluation schedule.&lt;br /&gt;&#xA;Does anyone know or have experience in application of such OR techniques in medicine? &lt;br /&gt;&#xA;I am aware of application of optimization in logistics, scheduling. Looking for applications directly in medical decisions.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-04-29T19:47:57.067" Title="OR applications in medicine" Tags="|optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10391" PostTypeId="1" AcceptedAnswerId="10393" CreationDate="2023-04-29T17:03:53.430" Score="0" ViewCount="153" Body="&lt;p&gt;In Store &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, shelf 1 accounted for &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{4}$&lt;/span&gt; of Bakery &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; 's average weekly sales and shelf 2 accounted for &lt;span class=&quot;math-container&quot;&gt;$\frac{2}{3}$&lt;/span&gt; as much as shelf 1 . If shelves 3 and 4 each accounted for less than shelf 2 but together accounted for more than shelf 1, what's the maximum and minimum range of possible average weekly sales in shelf five?&lt;/p&gt;&#xA;&lt;p&gt;How to formulate this problem as a linear programming problem?&lt;/p&gt;&#xA;" OwnerUserId="11548" LastEditorUserId="67" LastEditDate="2023-04-30T20:18:49.773" LastActivityDate="2023-04-30T20:18:49.773" Title="How to formulate the minimum and maximum range of possible values?" Tags="|optimization|linear-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10392" PostTypeId="2" ParentId="10390" CreationDate="2023-04-29T17:57:46.290" Score="3" Body="&lt;p&gt;Two colleagues and I published a paper[1] on an optimization model for creating patient panels for primary care providers. A patient panel is the set of patients seeing a particular provider at a particular location. The model takes into account doctor availability, how much time each doctor allocates to each type of appointment, the needs of the patients, patient preferences (for instance, a patient might want a female doctor) and location, and includes options for hiring new staff.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: There is also a substantial body of work on the use of integer programming models to design radiotherapy treatments in oncology. It's been a while since I saw any of it, but I believe decision variables included positioning of emitters and power/duration of radiation bursts. Eva K. Lee[2], formerly of Georgia Institute of Technology, was (I believe) a pioneer in that area.&lt;/p&gt;&#xA;&lt;p&gt;[1] Harrington, William, Paul A. Rubin and Lihui Bai. “An optimization approach to panel size management”. In: &lt;em&gt;Operations Research for Health Care&lt;/em&gt; &lt;strong&gt;31&lt;/strong&gt;, article 100313. ISSN: 2211-6923. DOI: &lt;a href=&quot;https://doi.org/10.1016/j.orhc.2021.100313&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.orhc.2021.100313&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;[2] &lt;a href=&quot;https://en.wikipedia.org/wiki/Eva_K._Lee&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Eva_K._Lee&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-04-29T19:18:21.457" LastActivityDate="2023-04-29T19:18:21.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10393" PostTypeId="2" ParentId="10391" CreationDate="2023-04-29T18:26:56.430" Score="3" Body="&lt;p&gt;Make some sweeping assumptions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As @RobPratt says, assume that all open inequalities are actually closed inequalities&lt;/li&gt;&#xA;&lt;li&gt;Assume that total sales are fixed at 1.0, meaning that the shelf quantities are represented as fractions of the actual total sales&lt;/li&gt;&#xA;&lt;li&gt;Assume that there are no other shelves, which was not explicit in the question&lt;/li&gt;&#xA;&lt;li&gt;Assume that amortized sales averages are not e.g. per unit of bread, but in cash; in other words, all variables continuous instead of integral&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Run the same problem twice: once for each of 'minimize' and 'maximize'. Most software can do this conversion for you, but if not, then just negate the objective the second time through.&lt;/p&gt;&#xA;&lt;p&gt;An example implementation in PuLP shows that the fifth shelf varies between 25% and 33.33% of total weekly sales.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from typing import Literal&#xA;import pulp&#xA;&#xA;&#xA;'''&#xA;In Store X, shelf 1 accounted for 1/4 of Bakery C's average weekly sales and shelf 2 accounted for&#xA;2/3 as much as shelf 1. If shelves 3 and 4 each accounted for less than shelf 2, but together &#xA;accounted for more than shelf 1, what's the maximum and minimum, range of possible average weekly &#xA;sales in shelf five?&#xA;'''&#xA;&#xA;&#xA;def run_with_sense(sense: Literal['Minimize', 'Maximize']) -&amp;gt; list[float]:&#xA;    total = pulp.LpVariable(&#xA;        name='total',&#xA;        # In the absense of any other information, fix the total at 1 so that the solution is&#xA;        # fractional&#xA;        lowBound=1, upBound=1)&#xA;&#xA;    shelves = [&#xA;        pulp.LpVariable(name=f'shelf_{i}', lowBound=0)&#xA;        for i in range(1, 6)&#xA;    ]&#xA;&#xA;    prob = pulp.LpProblem(name='bakery', sense=getattr(pulp, 'Lp' + sense))&#xA;    prob.objective = shelves[4] + 0&#xA;&#xA;    # Assume that the sum of five shelves account for total sales&#xA;    # (this is left ambiguous in the question)&#xA;    prob.addConstraint(name='sales_total', constraint=total == pulp.lpSum(shelves))&#xA;&#xA;    # shelf 1 accounted for 1/4 of Bakery C's average weekly sales&#xA;    prob.addConstraint(name='sales_1', constraint=4*shelves[0] == total)&#xA;&#xA;    # shelf 2 accounted for 2/3 as much as shelf 1&#xA;    prob.addConstraint(name='sales_1_2', constraint=2*shelves[0] == 3*shelves[1])&#xA;&#xA;    # shelves 3 and 4 each accounted for less than shelf 2&#xA;    # (&amp;quot;less&amp;quot; is only approximated here as &amp;quot;at most&amp;quot;)&#xA;    prob.addConstraint(name='sales_3_2', constraint=shelves[2] &amp;lt;= shelves[1])&#xA;    prob.addConstraint(name='sales_4_2', constraint=shelves[3] &amp;lt;= shelves[1])&#xA;&#xA;    # together accounted for more than shelf 1&#xA;    # (&amp;quot;more&amp;quot; is only approximated here as &amp;quot;at least&amp;quot;)&#xA;    prob.addConstraint(name='sales_3_4_1', constraint=shelves[2] + shelves[3] &amp;gt;= shelves[0])&#xA;&#xA;    print(prob)&#xA;    prob.solve()&#xA;    assert prob.status == pulp.LpStatusOptimal&#xA;    return [v.value() for v in shelves]&#xA;&#xA;&#xA;def main() -&amp;gt; None:&#xA;    for sense in ('Minimize', 'Maximize'):&#xA;        shelf_fractions = run_with_sense(sense)&#xA;        print('Shelf fractions of total sales:')&#xA;        print(', '.join(f'{s:.4f}' for s in shelf_fractions))&#xA;        print()&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;bakery:&#xA;MINIMIZE&#xA;1*shelf_5 + 0&#xA;SUBJECT TO&#xA;sales_total: - shelf_1 - shelf_2 - shelf_3 - shelf_4 - shelf_5 + total = 0&#xA;&#xA;sales_1: 4 shelf_1 - total = 0&#xA;&#xA;sales_1_2: 2 shelf_1 - 3 shelf_2 = 0&#xA;&#xA;sales_3_2: - shelf_2 + shelf_3 &amp;lt;= 0&#xA;&#xA;sales_4_2: - shelf_2 + shelf_4 &amp;lt;= 0&#xA;&#xA;sales_3_4_1: - shelf_1 + shelf_3 + shelf_4 &amp;gt;= 0&#xA;&#xA;VARIABLES&#xA;shelf_1 Continuous&#xA;shelf_2 Continuous&#xA;shelf_3 Continuous&#xA;shelf_4 Continuous&#xA;shelf_5 Continuous&#xA;total = 1 Continuous&#xA;&#xA;Welcome to the CBC MILP Solver &#xA;Version: 2.10.3 &#xA;Build Date: Dec 15 2019 &#xA;&#xA;command line - pulp.sol (default strategy 1)&#xA;At line 2 NAME          MODEL&#xA;At line 3 ROWS&#xA;At line 11 COLUMNS&#xA;At line 30 RHS&#xA;At line 37 BOUNDS&#xA;At line 39 ENDATA&#xA;Problem MODEL has 6 rows, 6 columns and 17 elements&#xA;Coin0008I MODEL read with 0 errors&#xA;Option for timeMode changed from cpu to elapsed&#xA;Presolve 0 (-6) rows, 0 (-6) columns and 0 (-17) elements&#xA;Empty problem - 0 rows, 0 columns and 0 elements&#xA;Optimal - objective value 0.25&#xA;After Postsolve, objective 0.25, infeasibilities - dual 0 (0), primal 0 (0)&#xA;Optimal objective 0.25 - 0 iterations time 0.002, Presolve 0.00&#xA;Option for printingOptions changed from normal to all&#xA;Total time (CPU seconds):       0.00   (Wallclock seconds):       0.00&#xA;&#xA;Shelf fractions of total sales:&#xA;0.2500, 0.1667, 0.1667, 0.1667, 0.2500&#xA;&#xA;bakery:&#xA;MAXIMIZE&#xA;1*shelf_5 + 0&#xA;SUBJECT TO&#xA;sales_total: - shelf_1 - shelf_2 - shelf_3 - shelf_4 - shelf_5 + total = 0&#xA;&#xA;sales_1: 4 shelf_1 - total = 0&#xA;&#xA;sales_1_2: 2 shelf_1 - 3 shelf_2 = 0&#xA;&#xA;sales_3_2: - shelf_2 + shelf_3 &amp;lt;= 0&#xA;&#xA;sales_4_2: - shelf_2 + shelf_4 &amp;lt;= 0&#xA;&#xA;sales_3_4_1: - shelf_1 + shelf_3 + shelf_4 &amp;gt;= 0&#xA;&#xA;VARIABLES&#xA;shelf_1 Continuous&#xA;shelf_2 Continuous&#xA;shelf_3 Continuous&#xA;shelf_4 Continuous&#xA;shelf_5 Continuous&#xA;total = 1 Continuous&#xA;&#xA;Welcome to the CBC MILP Solver &#xA;Version: 2.10.3 &#xA;Build Date: Dec 15 2019 &#xA;&#xA;command line - pulp.sol (default strategy 1)&#xA;At line 2 NAME          MODEL&#xA;At line 3 ROWS&#xA;At line 11 COLUMNS&#xA;At line 30 RHS&#xA;At line 37 BOUNDS&#xA;At line 39 ENDATA&#xA;Problem MODEL has 6 rows, 6 columns and 17 elements&#xA;Coin0008I MODEL read with 0 errors&#xA;Option for timeMode changed from cpu to elapsed&#xA;Presolve 0 (-6) rows, 0 (-6) columns and 0 (-17) elements&#xA;Empty problem - 0 rows, 0 columns and 0 elements&#xA;Optimal - objective value 0.33333333&#xA;After Postsolve, objective 0.33333333, infeasibilities - dual 0 (0), primal 0 (0)&#xA;Optimal objective 0.3333333333 - 0 iterations time 0.002, Presolve 0.00&#xA;Option for printingOptions changed from normal to all&#xA;Total time (CPU seconds):       0.00   (Wallclock seconds):       0.00&#xA;&#xA;Shelf fractions of total sales:&#xA;0.2500, 0.1667, 0.0833, 0.1667, 0.3333&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But note the output describing that the problem is trivial:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Presolve 0 (-6) rows, 0 (-6) columns and 0 (-17) elements&#xA;Empty problem - 0 rows, 0 columns and 0 elements&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It's just as easy to solve this problem by hand:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$s_1 = \frac 1 4$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$s_2 = \frac 2 3 s_1 = \frac 1 6$$&lt;/span&gt;&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$s_3 = s_4 = s_{34}$&lt;/span&gt;, then&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \frac 1 2 \cdot \frac 1 4 \le s_{34} \le \frac 1 6 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \frac 1 8 \le \frac 1 2 \left( 1 - \frac 1 4 - \frac 1 6 - s_5 \right) \le \frac 1 6 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \frac 1 8 \le \frac 7 {24} - \frac {s_5} 2 \le \frac 1 6 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \frac 1 4 \le s_5 \le \frac 1 3 $$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="11118" LastEditorUserId="11118" LastEditDate="2023-04-29T21:32:43.417" LastActivityDate="2023-04-29T21:32:43.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10394" PostTypeId="1" AcceptedAnswerId="10395" CreationDate="2023-04-29T18:34:59.080" Score="2" ViewCount="246" Body="&lt;p&gt;I had formulated an optimization model, and along the way I had to change a variable into a parameter. In doing so, one of my constraints that contained the variable I changed no longer contained a decision variable; however, the model solved alright. I want to know if it is possible to have a constraint that does not contain any decision variables.&lt;/p&gt;&#xA;" OwnerUserId="11734" LastEditorUserId="491" LastEditDate="2023-04-30T19:22:31.470" LastActivityDate="2023-04-30T19:22:31.470" Title="it is possible to have a constraint that does not contain any decision variables" Tags="|optimization|constraint|ampl|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10395" PostTypeId="2" ParentId="10394" CreationDate="2023-04-29T18:50:05.217" Score="4" Body="&lt;p&gt;Constraints define your feasibility region; bounds your search space. A constraint with no dv (decision or optimization variable) simply becomes a testing condition. If parameter value satisfies the constraint, it evaluates the objective value, if not it throws a infeasible/out of bounds error.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-04-29T18:50:05.217" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10396" PostTypeId="2" ParentId="10390" CreationDate="2023-04-29T19:47:57.067" Score="3" Body="&lt;p&gt;You can checkout work from &lt;a href=&quot;https://scholar.google.com/citations?hl=fr&amp;amp;user=msbeB7oAAAAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nadia Lahrichi&lt;/a&gt;, she is an OR expert and has written many papers with healthcare applications such as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://scholar.google.com/citations?view_op=view_citation&amp;amp;hl=fr&amp;amp;user=msbeB7oAAAAJ&amp;amp;citation_for_view=msbeB7oAAAAJ:roLk4NBRz8UC&quot; rel=&quot;nofollow noreferrer&quot;&gt;A patient assignment algorithm for home care services&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://scholar.google.com/citations?view_op=view_citation&amp;amp;hl=fr&amp;amp;user=msbeB7oAAAAJ&amp;amp;citation_for_view=msbeB7oAAAAJ:hqOjcs7Dif8C&quot; rel=&quot;nofollow noreferrer&quot;&gt;The nurse scheduling problem in real-life&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://scholar.google.com/citations?view_op=view_citation&amp;amp;hl=fr&amp;amp;user=msbeB7oAAAAJ&amp;amp;citation_for_view=msbeB7oAAAAJ:_kc_bZDykSQC&quot; rel=&quot;nofollow noreferrer&quot;&gt;Online stochastic optimization of radiotherapy patient scheduling&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2023-04-29T19:47:57.067" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10398" PostTypeId="1" CreationDate="2023-05-01T06:35:02.987" Score="4" ViewCount="262" Body="&lt;p&gt;I am currently working on my undergrad thesis which is a mathematical optimization problem of the territory design family of problems. I am using the mathematical formulation of the problem to solve it using commercial software and comparing the time and gap to optimum to my metaheuristics.&lt;/p&gt;&#xA;&lt;p&gt;One step of my heuristics involves solving a relaxed version of the problem. I have two decision variables: &lt;span class=&quot;math-container&quot;&gt;$Y_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_{ij}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$Y_i =1$&lt;/span&gt; if the territory center &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is selected for use, 0 if not, where I must select &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; centers to be used. On the other hand, &lt;span class=&quot;math-container&quot;&gt;$X_{ij}=1$&lt;/span&gt; if the client &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is served by the center &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, 0 if not. In the relaxed version of the problem, I tell the solver to work with &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; as a continuous variable bounded from 0.0 to 1.0, but the &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is left alone as an integer.&lt;/p&gt;&#xA;&lt;p&gt;In theory, this should make the model easier to solve, leaving me with infactible solutions for my original model as &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; should be an integer, but I really don't care much as I use this relaxation to initialize my &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;, working with my &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; later on the heuristic.&lt;/p&gt;&#xA;&lt;p&gt;With some sizes of the instances that I generate, this appears to hold. My heuristic containing the relaxed version of the model and my algorithm to construct the &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; runs in less time than the normal version of the model for the same instance. However, working with larger instances shows me that the relaxed version is harder to solve than the non-relaxed version.&lt;/p&gt;&#xA;&lt;p&gt;What I mean by this is that an instance with 2650 clients, 500 centers and &lt;span class=&quot;math-container&quot;&gt;$P = 220$&lt;/span&gt; takes the following time to be solved and a cutoff time of 1800 seconds:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Gurobi&lt;/th&gt;&#xA;&lt;th&gt;CPLEX&lt;/th&gt;&#xA;&lt;th&gt;HiGHS&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Relaxed: 1490 seconds&lt;/td&gt;&#xA;&lt;td&gt;Relaxed: 1800 seconds&lt;/td&gt;&#xA;&lt;td&gt;Relaxed: 1800 seconds&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Non-Relaxed: 925 seconds&lt;/td&gt;&#xA;&lt;td&gt;Non-Relaxed: 1800 seconds&lt;/td&gt;&#xA;&lt;td&gt;Non-Relaxed: Unfeasible&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;In this specific case, only Gurobi finds an optimal solution to the model, with CPLEX and HiGHS failing to achieve so, even HiGHS failing to find a feasible solution for the problem. I don't want this question to be a technical implementation or solvers comparison question. The same model is built for the three solvers, using the JuMP.jl package in the Julia language.&lt;/p&gt;&#xA;&lt;p&gt;It really puzzles me how the only solver that found the optimum takes longer to solve the relaxed version, and I would like to know if there is a solver agnostic explanation for this or if my idea of relaxing the integer constraints is flawed. I would be more than happy to provide the code and logs of the solvers if required but I don't want to make this question any longer than it should be.&lt;/p&gt;&#xA;" OwnerUserId="11743" LastActivityDate="2023-05-01T11:55:51.993" Title="MIP Model with relaxed integer constraints takes longer to solve than normal model, why?" Tags="|mixed-integer-programming|modeling|cplex|gurobi|solver|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10399" PostTypeId="1" CreationDate="2023-05-01T07:42:22.830" Score="7" ViewCount="102" Body="&lt;p&gt;In &lt;a href=&quot;https://cstheory.stackexchange.com/questions/48099/integer-linear-program-formulation-of-planarity&quot;&gt;this question&lt;/a&gt;, it was asked wether a MIP formulation exists to test for a graph's planarity. The inputs are the graph's nodes and edges, and the output would be a certificate which guarantees that the graph is, or is not, planar.&lt;/p&gt;&#xA;&lt;p&gt;The python package NetworkX provides a &lt;a href=&quot;https://networkx.org/documentation/stable/_modules/networkx/algorithms/planarity.html#is_planar&quot; rel=&quot;noreferrer&quot;&gt;method&lt;/a&gt; which does exactly this, but it is not based on linear programming. The source code provides the following references:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ulrik Brandes: &lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.217.9208&quot; rel=&quot;noreferrer&quot;&gt;The Left-Right Planarity Test&lt;/a&gt; (2009)&lt;/li&gt;&#xA;&lt;li&gt;Takao Nishizeki, Md Saidur Rahman: Planar graph drawing, Lecture Notes Series on Computing: Volume 12 (2004)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Some ideas:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Euler_characteristic#Plane_graphs&quot; rel=&quot;noreferrer&quot;&gt;Euler's theorem&lt;/a&gt; (&lt;span class=&quot;math-container&quot;&gt;$n-m+f=2$&lt;/span&gt;); but this depends on how the nodes (and edges) are organized in space, which is not part of the input data.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; planar &lt;span class=&quot;math-container&quot;&gt;$\implies m\le 3n-6$&lt;/span&gt;; but this does not cover all cases, it can be a tool to prove that a graph is not planar, but is useless the otherway around.&lt;/li&gt;&#xA;&lt;li&gt;There is a relationship between planar graphs and &lt;a href=&quot;https://en.wikipedia.org/wiki/Book_embedding&quot; rel=&quot;noreferrer&quot;&gt;book embeddings&lt;/a&gt; (see this great &lt;a href=&quot;https://www.youtube.com/watch?v=qw2Pl_Nk3CA&quot; rel=&quot;noreferrer&quot;&gt;video&lt;/a&gt; from Numberphile for a recent breakthrough in graph theory on the subject), but not sure it helps.&lt;/li&gt;&#xA;&lt;li&gt;Other characterizations of planar graphs are mentioned on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Planar_graph#Planarity_criteria&quot; rel=&quot;noreferrer&quot;&gt;Wikipedia page&lt;/a&gt;, such as &lt;a href=&quot;https://en.wikipedia.org/wiki/Whitney%27s_planarity_criterion&quot; rel=&quot;noreferrer&quot;&gt;Whitney's planarity criterion&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/Mac_Lane%27s_planarity_criterion&quot; rel=&quot;noreferrer&quot;&gt;Mac Lane's planarity criterion&lt;/a&gt;. These might be interesting.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To this day, the question has not been answered. I find the question interesting from a modeling point of view and am curious wheter it can be answered &lt;strong&gt;with a MIP&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-05-01T11:07:36.743" LastActivityDate="2023-05-01T11:07:36.743" Title="MIP formulation for graph planarity test" Tags="|mixed-integer-programming|modeling|graphs|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10400" PostTypeId="2" ParentId="10398" CreationDate="2023-05-01T11:55:51.993" Score="5" Body="&lt;p&gt;First, it is risky to draw conclusions with so few data. It could just be luck.&lt;/p&gt;&#xA;&lt;p&gt;Still, there are some possible reasons why setting some variables as integer might be beneficial:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It can trigger more deductions in the presolve step&lt;/li&gt;&#xA;&lt;li&gt;It can lead to new cuts being generated&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-05-01T11:55:51.993" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10401" PostTypeId="1" CreationDate="2023-05-01T13:53:25.937" Score="2" ViewCount="116" Body="&lt;p&gt;&lt;em&gt;All the input variables are positive float (x &amp;gt; 0).&lt;/em&gt; We have &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; agents with limited amount of time &lt;span class=&quot;math-container&quot;&gt;$t_1,\dots,t_M$&lt;/span&gt;,  &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; tasks &lt;span class=&quot;math-container&quot;&gt;$task_1,\dots,task_N$&lt;/span&gt; associated with duration &lt;span class=&quot;math-container&quot;&gt;$d_1,\dots, d_N$&lt;/span&gt;. Cost for assigning agent  &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt;. Time assigning agent &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We define task as satisfied if the sum of of time  allocated to it, by the agents, equals to its duration (binary value):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$SAT(task_j) = 1 \iff d_j=\sum_{i=1}^Mx_{ij}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We want to find the  &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; that get the maximum number of satisfied tasks while minimizing the cost:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$MIN\sum_{j=1}^N \sum_{i=1}^Mc_{ij}x_{ij}$$&lt;/span&gt;&#xA;While&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j=1}^N \left(SAT(task_j)\right) = MAX-SATISFIED$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The main idea is to find the solution with lowest cost in the set of solutions with maximal number of satisfied tasks (The satisfied tasks is the most important objective).&lt;/p&gt;&#xA;&lt;p&gt;Is there a name for this variation of the assignment problem? Also is there an known efficient algorithm?&lt;/p&gt;&#xA;" OwnerUserId="11748" LastEditorUserId="67" LastEditDate="2023-05-01T15:11:55.853" LastActivityDate="2023-05-02T12:27:15.880" Title="Is there a name for this variation of the generalized assignment problem?" Tags="|optimization|mixed-integer-programming|assignment-problem|multi-objective-optimization|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10402" PostTypeId="2" ParentId="10401" CreationDate="2023-05-01T14:48:12.987" Score="1" Body="&lt;p&gt;It's similar to knapsack problem. I am referring to wiki links &lt;a href=&quot;https://en.wikipedia.org/wiki/Generalized_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; from here you can refer to other additional academic papers. Also check this general &lt;a href=&quot;https://en.wikipedia.org/wiki/Assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;wiki&lt;/a&gt; as well on general assignment problem.&lt;br /&gt;&#xA;Algorithms will be what most solvers will use for MIP (branch-bound or branch-cut, dynamic column generation). You can also use dynamic programming but search space may be pretty large.&lt;/p&gt;&#xA;&lt;p&gt;Modern solvers (like Gurobi) will have &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_model_agc_indicator.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;conditional/indicator&lt;/a&gt; constraints and under-the-hood will linearize these.&lt;/p&gt;&#xA;&lt;p&gt;As for SAT&lt;span class=&quot;math-container&quot;&gt;$(t_j$&lt;/span&gt;) you can use @RobPratt's formulation from &lt;a href=&quot;https://or.stackexchange.com/questions/33/in-an-integer-program-how-i-can-force-a-binary-variable-to-equal-1-if-some-cond&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Define 3 binary variables &lt;span class=&quot;math-container&quot;&gt;$ y_j^+,y_j,y_j^-$&lt;/span&gt; for each of the tasks.&lt;br /&gt;&#xA;Then apply constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ Ly_j^- + (d_j+\epsilon)y_j^+ + d_j y_j \le \sum_i x_{ij} \le (d_j - \epsilon)y_j^- + d_jy_j + Yy_j^+$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ y_j^- + y_j + y_j^+ = 1 \quad \forall j$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$ U,L$&lt;/span&gt; could be max &amp;amp; min for &lt;span class=&quot;math-container&quot;&gt;$ d_j$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$0 \le \epsilon$&lt;/span&gt; is very small number&lt;/p&gt;&#xA;&lt;p&gt;Then in the objective use &lt;span class=&quot;math-container&quot;&gt;$ \sum_jy_j$&lt;/span&gt; instead of SAT.&lt;br /&gt;&#xA;You can also assign priority values to the separate objectives. Solvers like Gurobi provide multiple ways to &lt;a href=&quot;https://www.gurobi.com/documentation/current/refman/multiple_objectives.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;prioritize&lt;/a&gt; objectives.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-05-01T14:54:55.690" LastActivityDate="2023-05-01T14:54:55.690" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10403" PostTypeId="2" ParentId="10401" CreationDate="2023-05-01T19:28:24.427" Score="1" Body="&lt;p&gt;The problem sounds like a parallel resource scheduling problem with preemption. One of the efficient way to solve the problem (as an LP) is to define that as a bipartite graph in which the first group is related to the agents with the limited capacity and the second group is referred to the tasks with their associated duration. Now, each task can be connected to each agents to ensure allowing preemption and already satisfying the duration of each task. In this way the decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{n,m}$&lt;/span&gt; is a fractional duration of the processing tasks on the agents. Also, another constraint would be something like a knapsack one to capture each agent capacity. The first objective function is to minimize the assignment costs. Again, by this way, you can achieve the optimal allocation of the tasks on the agents with the minimum cost. You can already define other objective functions to capture what you want. E.g. minimizing the total duration of the tasks processing on the agents. B.T.W this problem has a limitation when the total duration of the tasks being greater than the agents capacity. In this situation you will need to define an auxiliary  variable with an appropriate penalties in the objective function to capture the capacity violations.&lt;/p&gt;&#xA;&lt;p&gt;I tried solving the problem by the following data:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;agents = [m1, ..., m4];&#xA;tasks  = [n1, ..., n6];&#xA;&#xA;taskduration(n) = [&#xA;n1 10,&#xA;n2 15,&#xA;n3 08,&#xA;n4 12,&#xA;n5 10,&#xA;n6 05&#xA;];&#xA;&#xA;agentcapacity = [&#xA;m1 20,&#xA;m2 30,&#xA;m3 10,&#xA;m4 20&#xA;];&#xA;&#xA;cost:&#xA;        m1          m2          m3          m4&#xA;&#xA;n1      25.000      46.000      37.000      29.000&#xA;n2      29.000      26.000      30.000      46.000&#xA;n3      22.000      35.000      50.000      37.000&#xA;n4      50.000      43.000      24.000      39.000&#xA;n5      24.000      27.000      40.000      33.000&#xA;n6      31.000      30.000      24.000      24.000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and the solution would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;The first objective: totalprocessing 23.000&#xA;The second objective: costs: 1541.00  &#xA;&#xA;VARIABLE x.L  &#xA;            m1          m2          m3          m4&#xA;&#xA;n1      10.000&#xA;n2                  15.000&#xA;n3       8.000&#xA;n4                              10.000       2.000&#xA;n5       2.000       8.000&#xA;n6                                           5.000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-05-01T19:42:37.107" LastActivityDate="2023-05-01T19:42:37.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10404" PostTypeId="2" ParentId="10401" CreationDate="2023-05-02T12:27:15.880" Score="0" Body="&lt;p&gt;This sounds like a lexicographic optimization problem with two objectives: &amp;quot;maximize the number of tasks satisfied&amp;quot; is the high-priority objective while &amp;quot;minimize the cost&amp;quot; is the low priority objective. You may formulate the problem as a maximum-covering-like problem: Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; for each task taking the value 1 iff task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is satisfied. Also, rename the variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; to be the proportion of task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; assigned to agent &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. The the problem becomes&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{lex}\max\ &amp;amp;\{\sum_{j=1}^Ny_j,-\sum_{i=1}^M\sum_{j=1}^Nd_jc_{ij}x_{ij}\}\\&#xA;\text{s.t.:}\ &amp;amp; \sum_{i=1}^Mx_{ij}\geq y_j,&amp;amp;&amp;amp;\forall j=1,...,N\\&#xA;\ &amp;amp; \sum_{j=1}^Nd_jx_{ij}\leq T_i,&amp;amp;&amp;amp;\forall i=1,...,M\\&#xA;\ &amp;amp; y_j\in\{0,1\},&amp;amp;&amp;amp;\forall j=1,...,m&#xA;\end{align}&lt;/span&gt;&#xA;You can solve this by &lt;em&gt;scalarizing&lt;/em&gt; the objectives into &lt;span class=&quot;math-container&quot;&gt;$\max \mu\sum_{j=1}^Ny_j-\sum_{i=1}^M\sum_{j=1}^Nd_jc_{ij}x_{ij}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; is a large constant. This will often lead to numerical problems, however, to include such a large constant in the objective. A more practical approach is to first maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^Ny_j$&lt;/span&gt;. Then add a constraint of the form &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^Ny_j\geq z^*$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt; is the number of satisfied tasks found while maximising. Next, you change the objective function to &lt;span class=&quot;math-container&quot;&gt;$\min\sum_{i=1}^M\sum_{j=1}^Nd_jc_{ij}x_{ij}$&lt;/span&gt; and solve this new ILP with the added constraint.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2023-05-02T12:27:15.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10405" PostTypeId="1" CreationDate="2023-05-02T17:21:52.227" Score="3" ViewCount="71" Body="&lt;p&gt;consider a constrained optimization problem (typically c=0), with f highly nonlinear:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\text{minimize}_x f(x) \\\\ s.t \ \ \ \ g(x) \leq c&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I experimented a bit and found empirically that (at least for my problem) constraint optimization methods lead to an much better (constrained satisfying) optimimum, when the constraint threshold c is not directly set to zero, but chosen higher in the beginning and then lowered gradually to approach zero. The higher threshold probably allows to explore more freely and then when a good region is found, one can lower the threshold.&lt;/p&gt;&#xA;&lt;p&gt;Are there any constrained optimization methods (I am f.ex thinking of exterior penalty methods), that use a decreasing constraint threshold? Or penalty methods with an increasing penalty term (which should behave similarly). If yes, are there some good papers on theoretic guarantees of these methods or papers that compare them to traditional methods?&lt;/p&gt;&#xA;" OwnerUserId="11762" LastEditorUserId="491" LastEditDate="2023-06-14T18:59:06.713" LastActivityDate="2023-06-14T18:59:06.713" Title="constrained optimization with decreasing constraint thresholds -Literature tips" Tags="|optimization|constraint|lagrange-multipliers|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10406" PostTypeId="1" AcceptedAnswerId="10414" CreationDate="2023-05-02T20:52:06.320" Score="2" ViewCount="1340" Body="&lt;p&gt;I have an optimization problem that I am solving with CP-SAT and I am using the Python interface. Moreover, I know a good feasible solution coming from a heuristic and I want the solver to start its search from this solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;How can I achieve this? Ideally, I would like to specify the initial value right after defining the variable, and not after the model is constructed. Is there a way to do it like this?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I tried with the AddHint() method but it is not clear to me what it does exactly: the solver just ignores the hint and finds another initial solution. I also found the thread &lt;a href=&quot;https://github.com/google/or-tools/discussions/3277&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; but it remains unanswered.&lt;/p&gt;&#xA;&lt;p&gt;As a minimal working example, consider the optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \max\limits_{(x, y) \in \Bbb Z^2 \cap [0, 10]^2 } \{x \: | \: x + y = 10  \}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The code implementation is the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from ortools.sat.python import cp_model&#xA;&#xA;class SolutionPrinter(cp_model.CpSolverSolutionCallback):&#xA;    &amp;quot;&amp;quot;&amp;quot;Print intermediate solutions.&amp;quot;&amp;quot;&amp;quot;&#xA;&#xA;    def __init__(self, x):&#xA;        cp_model.CpSolverSolutionCallback.__init__(self)&#xA;        self._solution_count = 1     &#xA;        self.x = x   &#xA;&#xA;    def on_solution_callback(self):&#xA;        &amp;quot;&amp;quot;&amp;quot;Called at each new solution.&amp;quot;&amp;quot;&amp;quot;&#xA; &#xA;        print(&amp;quot;Solution &amp;quot; + str(self._solution_count) + &amp;quot; ---&amp;gt; &amp;quot; + str(self.Value(self.x))    )&#xA;       &#xA;        print(&amp;quot;&amp;quot;)&#xA;        self._solution_count += 1&#xA;        &#xA;    &#xA;model = cp_model.CpModel()&#xA;&#xA;x = model.NewIntVar(0, 10, &amp;quot;x&amp;quot;)&#xA;y = model.NewIntVar(0, 10, &amp;quot;y&amp;quot;)&#xA;&#xA;# Maximize x&#xA;model.Maximize(x)&#xA;&#xA;# Hint &#xA;model.AddHint(x, 1)&#xA;&#xA;solver = cp_model.CpSolver()&#xA;printer = SolutionPrinter(x)&#xA;&#xA;solver.Solve(model, printer)&#xA;print(f&amp;quot;x = {solver.Value(x)} and y = {solver.Value(y)}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The output here is&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Solution 1 ---&amp;gt; 10&lt;/p&gt;&#xA;&lt;p&gt;x = 10 and y = 0&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Instead, it should find that &lt;span class=&quot;math-container&quot;&gt;$y = 9$&lt;/span&gt; makes &lt;span class=&quot;math-container&quot;&gt;$(x, y)$&lt;/span&gt; feasible and print that&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Solution 1 ---&amp;gt; 1&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;and only then keep looking.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Based on the suggestion of @LaurentPerron, I added the options&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solver.parameters.log_search_progress = True&#xA;solver.parameters.num_search_workers = 1&#xA;solver.log_callback = print &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but this returns&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Starting CP-SAT solver v9.6.2534&lt;/p&gt;&#xA;&lt;p&gt;Parameters: log_search_progress: true num_search_workers: 1&lt;/p&gt;&#xA;&lt;p&gt;Initial optimization model '': (model_fingerprint: 0x871bcff12da75473)&lt;/p&gt;&#xA;&lt;p&gt;#Variables: 2 (#ints:1 in objective)&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;2 in [0,10]&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Starting presolve at 0.00s&lt;/p&gt;&#xA;&lt;p&gt;The solution hint is complete and is feasible.&lt;/p&gt;&#xA;&lt;p&gt;[ExtractEncodingFromLinear] #potential_supersets=0&#xA;#potential_subsets=0&lt;/p&gt;&#xA;&lt;p&gt;#at_most_one_encodings=0 #exactly_one_encodings=0 #unique_terms=0 #multiple_terms=0 #literals=0 time=1e-06s&lt;/p&gt;&#xA;&lt;p&gt;[Symmetry] Graph for symmetry has 2 nodes and 0 arcs.&lt;/p&gt;&#xA;&lt;p&gt;[Symmetry] Symmetry computation done. time: 4.9e-06 dtime: 1.2e-07&lt;/p&gt;&#xA;&lt;p&gt;[Probing] deterministic_time: 0 (limit: 1) wall_time: 1.1e-06 (0/0)&lt;/p&gt;&#xA;&lt;p&gt;[DetectDuplicateConstraints] #duplicates=0 #without_enforcements=0&#xA;time=6e-06s&lt;/p&gt;&#xA;&lt;p&gt;[DetectDominatedLinearConstraints] #relevant_constraints=0&#xA;#work_done=0 #num_inclusions=0 #num_redundant=0 time=3.7e-06s&lt;/p&gt;&#xA;&lt;p&gt;[ProcessSetPPC] #relevant_constraints=0 #num_inclusions=0 work=0&#xA;time=7e-07s&lt;/p&gt;&#xA;&lt;p&gt;[FindBigLinearOverlap] #blocks=0 #saved_nz=0 #linears=0&#xA;#work_done=0/1e+09 time=6e-07s&lt;/p&gt;&#xA;&lt;p&gt;[MergeClauses] #num_collisions=0 #num_merges=0 #num_saved_literals=0&#xA;work=0/100000000 time=4e-07s&lt;/p&gt;&#xA;&lt;p&gt;[ExpandObjective] #propagations=0 #entries=0 #tight_variables=0&#xA;#tight_constraints=0 #expands=0 #issues=0 time=5.4e-06s&lt;/p&gt;&#xA;&lt;p&gt;Presolve summary:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;0 affine relations were detected.&lt;/li&gt;&#xA;&lt;li&gt;rule 'objective: variable not used elsewhere' was applied 1 time.&lt;/li&gt;&#xA;&lt;li&gt;rule 'presolve: 2 unused variables removed.' was applied 1 time.&lt;/li&gt;&#xA;&lt;li&gt;rule 'presolve: iteration' was applied 1 time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Presolved optimization model '': (model_fingerprint:&#xA;0xfc4715b25d7c8ae9)&lt;/p&gt;&#xA;&lt;p&gt;#Variables: 0 ( in objective)&lt;/p&gt;&#xA;&lt;p&gt;Preloading model.&lt;/p&gt;&#xA;&lt;p&gt;#Bound   0.00s best:-inf  next:[10,10]    initial_domain&lt;/p&gt;&#xA;&lt;p&gt;[Symmetry] Graph for symmetry has 0 nodes and 0 arcs.&lt;/p&gt;&#xA;&lt;p&gt;Starting to load the model at 0.00s&lt;/p&gt;&#xA;&lt;p&gt;Starting sequential search at 0.00s&lt;/p&gt;&#xA;&lt;p&gt;#1       0.00s best:10    next:[]          fixed_bools:0/0&lt;/p&gt;&#xA;&lt;p&gt;Solution 1 ---&amp;gt; 10&lt;/p&gt;&#xA;&lt;p&gt;#Done    0.00s&lt;/p&gt;&#xA;&lt;p&gt;CpSolverResponse summary:&lt;/p&gt;&#xA;&lt;p&gt;status: OPTIMAL&lt;/p&gt;&#xA;&lt;p&gt;objective: 10&lt;/p&gt;&#xA;&lt;p&gt;best_bound: 10&lt;/p&gt;&#xA;&lt;p&gt;integers: 1&lt;/p&gt;&#xA;&lt;p&gt;booleans: 0&lt;/p&gt;&#xA;&lt;p&gt;conflicts: 0&lt;/p&gt;&#xA;&lt;p&gt;branches: 0&lt;/p&gt;&#xA;&lt;p&gt;propagations: 0&lt;/p&gt;&#xA;&lt;p&gt;integer_propagations: 1&lt;/p&gt;&#xA;&lt;p&gt;restarts: 0&lt;/p&gt;&#xA;&lt;p&gt;lp_iterations: 0&lt;/p&gt;&#xA;&lt;p&gt;walltime: 0.0025853&lt;/p&gt;&#xA;&lt;p&gt;usertime: 0.0025854&lt;/p&gt;&#xA;&lt;p&gt;deterministic_time: 0&lt;/p&gt;&#xA;&lt;p&gt;gap_integral: 0&lt;/p&gt;&#xA;&lt;p&gt;solution_fingerprint: 0x2a5128eb91a71559&lt;/p&gt;&#xA;&lt;p&gt;x = 10 and y = 0&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Thus, the problem still remains.&lt;/p&gt;&#xA;" OwnerUserId="11164" LastEditorUserId="11164" LastEditDate="2023-05-03T19:00:10.967" LastActivityDate="2023-05-05T18:18:40.590" Title="What exactly does the AddHint() method in Google OR-Tools' CP-SAT solver do?" Tags="|constraint-programming|or-tools|cp-sat|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="10407" PostTypeId="1" CreationDate="2023-05-03T06:13:59.290" Score="0" ViewCount="69" Body="&lt;p&gt;In the search of some of the important cutting edge many objective optimization problems to be solved using non-dominated sorting genetic algorithm (NSGA) and its variants.&lt;/p&gt;&#xA;" OwnerUserId="11069" LastEditorUserId="500" LastEditDate="2023-05-03T11:16:50.023" LastActivityDate="2023-05-03T11:16:50.023" Title="What are some important real life examples of multi objective optimization problem with box constraints to work on?" Tags="|optimization|multi-objective-optimization|test-instances|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10408" PostTypeId="1" AcceptedAnswerId="10413" CreationDate="2023-05-04T22:15:05.977" Score="4" ViewCount="584" Body="&lt;p&gt;I have drawn X-many samples from a population. I want to use this data to drive inputs for a Monte Carlo simulation (or similar). The population may be a real world measurement, or it could be the output of another computer model.&lt;/p&gt;&#xA;&lt;p&gt;There are two ways I could go about this:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I could use the samples to estimate a population distribution and sample from the estimated distribution within the Monte Carlo simulation.&lt;/li&gt;&#xA;&lt;li&gt;I could randomly draw from the samples that I have already collected from the population.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Both of these approaches have strengths and weaknesses and are appropriate in some situations and less useful in others.&lt;/p&gt;&#xA;&lt;p&gt;Is there better terminology that I can use if/when I want to discuss the distinction?&lt;/p&gt;&#xA;" OwnerUserId="10114" LastEditorUserId="500" LastEditDate="2023-05-04T22:31:20.747" LastActivityDate="2023-05-06T03:07:33.830" Title="Using the &quot;true&quot; sample rather than sampling from a distribution - is there a name for this?" Tags="|terminology|simulation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10409" PostTypeId="2" ParentId="10408" CreationDate="2023-05-05T08:21:27.287" Score="6" Body="&lt;p&gt;This is called an &lt;em&gt;Empirical distribution function&lt;/em&gt;. You can check out &lt;a href=&quot;https://en.wikipedia.org/wiki/Empirical_distribution_function&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2023-05-05T08:21:27.287" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10410" PostTypeId="2" ParentId="10377" CreationDate="2023-05-05T10:57:09.777" Score="0" Body="&lt;p&gt;For the sake of completion, I got a workaround it.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I exported my model from python doplex in .mps format. The equation&#xA;name should not have any spaces because that later creates issues for&#xA;reading mps files.&lt;/li&gt;&#xA;&lt;li&gt;The using JuMP package in Julia, I read the mps file.&lt;/li&gt;&#xA;&lt;li&gt;The default syntax for constraints in JuMP is LB &amp;lt;= Ax &amp;lt;= UB and there are functions to get A in sparse form, LB and UB.  Using collect() I convert sparse to dense matrix.&lt;/li&gt;&#xA;&lt;li&gt;Then I do something&#xA;stupid and smart,  I vertically stack(using vcat()) constraint matrix&#xA;as a = [A, -A] and rhs = [LB,-UB] and then pass it as aX&amp;lt;=rhs  The&#xA;equality is implicitly captured where LB and UB are same.&#xA;Inequalities have one of the bounds as Inf or -Inf&lt;/li&gt;&#xA;&lt;li&gt;Basically what I do is, LB &amp;lt;= Ax &amp;lt;= UB ===&amp;gt; -Ax &amp;lt;= -LB and Ax &amp;lt;= UB which is equivalent to a = [A, -A] and rhs = [LB,-UB] in equation ax &amp;lt;= rhs&lt;/li&gt;&#xA;&lt;li&gt;This is simple to&#xA;do but doubles the number of constraints so might be a stupid thing&#xA;to do for large problems unless there is some pre-processing also&#xA;being done.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10062" LastActivityDate="2023-05-05T10:57:09.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10412" PostTypeId="1" CreationDate="2023-05-05T14:26:00.460" Score="0" ViewCount="102" Body="&lt;p&gt;Using an optimality gap formula that calculates an average over large sets of instances is a common practice to assess the efficiency of an algorithm. The widely-used formula employed by CPLEX is: |bestbound - bestinteger| / (epsilon + |bestinteger|). However, a problem arises when the denominator approaches zero while the difference between the upper and lower bounds is small, causing the optimality gap to approach infinity. To address this issue and gain a better interpretation of results with an average across all instances, I propose setting epsilon to one. This adjustment would not significantly alter the optimality gap for instances where the best integer is greater than one, as its effect would be negligible. However, it would eliminate instances with an optimality gap percentage of 4000% or higher, replacing them with a value of at least 400. Considering the scale of large instances, this approach would mitigate the impact of such extreme values.&lt;/p&gt;&#xA;&lt;p&gt;I'm not aware of any specific instances in the literature where epsilon with a value of &amp;quot;1&amp;quot; has been used extensively.&lt;/p&gt;&#xA;&lt;p&gt;Could you please suggest any references or alternative solutions to my problem?&lt;/p&gt;&#xA;" OwnerUserId="11780" LastActivityDate="2023-05-05T14:26:00.460" Title="Calculating optimality gap when denominator goes to zero" Tags="|optimality-gap|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10413" PostTypeId="2" ParentId="10408" CreationDate="2023-05-05T14:44:37.687" Score="4" Body="&lt;p&gt;Both these approaches are considered two different versions of the &lt;a href=&quot;https://online.stat.psu.edu/stat555/node/119/#:%7E:text=Parametric%20bootstrap,or%20normal%20for%20continuous%20distribution.&quot; rel=&quot;nofollow noreferrer&quot;&gt;bootstrap&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the case that we are fitting the distribution to a parametric model and then sampling from the model, this is called the parametric bootstrap. If we simply resample the raw data directly, this is referred to the non-parametric bootstrap.&lt;/p&gt;&#xA;&lt;p&gt;In practice, the non-parametric bootstrap is used much more often, due to being simpler and having less assumptions attached. As such, when people refer to simply &amp;quot;bootstrap&amp;quot;, they usually mean the non-parametric approach.&lt;/p&gt;&#xA;" OwnerUserId="11781" LastEditorUserId="11781" LastEditDate="2023-05-06T03:07:33.830" LastActivityDate="2023-05-06T03:07:33.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10414" PostTypeId="2" ParentId="10406" CreationDate="2023-05-05T16:31:03.960" Score="2" Body="&lt;p&gt;The hints are actually wrong and infeasible. A good way to check it is to add the parameter &lt;code&gt;fix_variables_to_their_hinted_value:true&lt;/code&gt; to the solver before solving.&lt;/p&gt;&#xA;&lt;p&gt;In your case, it returns INFEASIBLE, thus showing the problem.&lt;/p&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2023-05-05T18:18:40.590" LastActivityDate="2023-05-05T18:18:40.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10415" PostTypeId="1" CreationDate="2023-05-05T18:21:26.017" Score="1" ViewCount="122" Body="&lt;p&gt;Suppose we have an LP with rational coefficients.&lt;/p&gt;&#xA;&lt;p&gt;To my knowledge, this implies that the optimal solution to that LP is also rational. In other words, every variable may be written as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{i}^{\star} = M_{i}/N_{i}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Moreover, I can scale numerator/denumerator such that all variables share the same denumerator:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{i}^{\star} = \frac{M_{i}^{\prime}} {N_{common}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to find a common denumerator &lt;span class=&quot;math-container&quot;&gt;$N_{common}$&lt;/span&gt; before solving the LP? This would convert the optimization problem to a problem which must have an integer solution (optimizing over variables &lt;span class=&quot;math-container&quot;&gt;$M_{i}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Another interpretation of my question: Is it possible to solve any LP by having each variable take values which are multiples of &lt;span class=&quot;math-container&quot;&gt;$1/N_{common}$&lt;/span&gt;, with the latter having the notion of the required &amp;quot;precision&amp;quot; to avoid losses?&lt;/p&gt;&#xA;" OwnerUserId="10811" LastActivityDate="2023-05-08T08:49:37.380" Title="Rational LP, its Rational solution and a minimum precision" Tags="|mixed-integer-programming|linear-programming|integer-programming|convex-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10416" PostTypeId="1" CreationDate="2023-05-06T19:22:08.270" Score="2" ViewCount="310" Body="&lt;p&gt;I have a few questions about mathematical modeling (MILPs mainly). My understanding is that the complexity of a model is primarily determined by the number of decision variables, rather than the number of constraints. Am I right about that?if so, would it be beneficial to include constraints that seems to be naturally hold true, or to include constraints that should not naturally hold due to the nature of the objective function and the types of variables? These acting as cut constraint or can make the problem runs worse?&lt;/p&gt;&#xA;" OwnerUserId="11476" LastActivityDate="2023-05-06T22:43:36.507" Title="Model Complexity and Constraints in Mathematical Modeling" Tags="|mixed-integer-programming|modeling|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10417" PostTypeId="2" ParentId="10416" CreationDate="2023-05-06T21:23:42.253" Score="4" Body="&lt;p&gt;First, please note that the only valid generalization regarding MILP models is that there are no other valid generalizations besides this one.&lt;/p&gt;&#xA;&lt;p&gt;That said, it is often (usually?) the case that increasing the number of variables does more to increase solution time than does increasing the number of constraints. There are at least two contributing factors. One factor is that most solvers use a &amp;quot;presolve&amp;quot; stage to simplify the model, which includes fixing models that can be fixed and eliminating redundant constraints. I suspect that it is somewhat easier to detect a redundant constraint than it is to fix a variable. The other factor is that modern solvers may use &lt;a href=&quot;https://en.wikipedia.org/wiki/Active-set_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;active set methods&lt;/a&gt; or may set aside constraints that have not been binding for a while and revisit them (possibly reactivating them and possibly setting aside other constraints) on the fly. Thus the solver may be working with the full set of variables but with only a subset of constraints.&lt;/p&gt;&#xA;&lt;p&gt;As far as adding constraints, with integer programs the addition of a seemingly redundant constraint sometimes helps the solver fix integer variables earlier ... sometimes. It very much depends on the specific model and the specific constraint.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-05-06T21:23:42.253" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10418" PostTypeId="2" ParentId="10416" CreationDate="2023-05-06T22:43:36.507" Score="2" Body="&lt;p&gt;Constraints are like if-then-else type logic. These can be helpful as cuts (as you've mentioned), reducing the feasible region, setting bounds which may lead to faster solution time and smaller difference between the solution &amp;amp; true optimal.&lt;br /&gt;&#xA;Conversely large number of constraints (too many dual variables) can make finding a solution impossible in polynomial time (infeasible). The later happens when constraints are contradictory or quadratic with polynomial degree.&lt;br /&gt;&#xA;If you are introducing constraints that naturally do not hold you may constraint certain variables while leaving other variables uncovered. This may lead the solver to converge to a feasible solution by maximizing/minimizing variables that are not covered by constraints. Such solutions may not be optimal.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-05-06T22:43:36.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10419" PostTypeId="1" CreationDate="2023-05-07T21:50:26.430" Score="1" ViewCount="199" Body="&lt;p&gt;I'm having trouble in solving this problem dealing with the Wagner's-Whitin Algorithm, because the holding and ordering costs are not given, we only have the optimal costs from the beginning to each node, and the shortest path.&#xA;&lt;strong&gt;(The answer is $2050)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/x6vbA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/x6vbA.png&quot; alt=&quot;Wagner's Whitin&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11643" LastActivityDate="2023-05-07T21:50:26.430" Title="Wagner's-Whitin Algorithm" Tags="|dynamic-programming|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10420" PostTypeId="1" CreationDate="2023-05-08T06:51:19.900" Score="1" ViewCount="81" Body="&lt;p&gt;Given a cover inequality of the form:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{j\in C}x_j \leq |C|-1&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A lifted version of this inequality takes the following form:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{j\in C}x_j+\sum_{j\in N\setminus C}\alpha_jx_j \leq |C|-1&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As long as &lt;span class=&quot;math-container&quot;&gt;$\alpha_j\geq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall j\in N\setminus C$&lt;/span&gt;, it follows that the lifted version of this inequality is stronger than the original cover inequality, because we add more arguments to the LHS without changing the RHS. The &lt;span class=&quot;math-container&quot;&gt;$\alpha_j$&lt;/span&gt; coefficients can be obtained through a sequantial procedure.&lt;/p&gt;&#xA;&lt;p&gt;This particular form of lifting is in some papers referred to as 'uplifting'. Equivalently, there exists another form of lifting known as 'down lifting'. For a given &lt;span class=&quot;math-container&quot;&gt;$D\subset N$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$N\cap C = \emptyset$&lt;/span&gt;, a downlifted version of the cover inequality:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{j\in C\setminus D}x_j+\sum_{j\in D}\beta_jx_j \leq |C|+\sum_{j\in D}\beta_j-1&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In contrast to the uplifted version, in the downlifted version we modify the RHS. As such, it is not obvious to me:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;why/when is this down lifted inequality stronger than the original cover inequality?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For a given &lt;span class=&quot;math-container&quot;&gt;$j\in D$&lt;/span&gt;, when &lt;span class=&quot;math-container&quot;&gt;$x_j=1$&lt;/span&gt; the &lt;span class=&quot;math-container&quot;&gt;$\beta_j$&lt;/span&gt; terms of the LHS and RHS cancel each other out and we obtain the orignal cover inequality. However, when &lt;span class=&quot;math-container&quot;&gt;$x_j=0$&lt;/span&gt;, the RHS remains larger and we obtain an inequality that seems weaker?&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;when would you apply down lifting?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="49" LastActivityDate="2023-05-10T08:35:35.080" Title="down lifting of variable coefficients for cover inequalities" Tags="|valid-inequalities|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10421" PostTypeId="2" ParentId="10415" CreationDate="2023-05-08T08:49:37.380" Score="3" Body="&lt;p&gt;Finding &lt;span class=&quot;math-container&quot;&gt;$N_{common}$&lt;/span&gt; seems equivalent to finding a column scaling such that the optimal solution is integer-valued. Surely, if you want to do this without knowledge of the optimal solution, you are looking for a column scaling to that turns your &lt;em&gt;rational polyhedron&lt;/em&gt; into an &lt;em&gt;integer polyhedron&lt;/em&gt; where all vertices are integer-valued. The direct approach, visiting all vertices of the polyhedron, has exponential complexity. Moreover, the encoding length of a column scaling turning all vertices integer-valued, might also be exponential in the enconding length of input data.&lt;/p&gt;&#xA;&lt;p&gt;From a practical standpoint, you are much better of with exact rational arithmetic. See, e.g., &lt;a href=&quot;https://www.dii.uchile.cl/%7Edaespino/PApers/exact_simplex.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Exact solutions to linear programming problems&lt;/a&gt; from 2007 by Applegate, Cook, Dash and Espinoza.&lt;/p&gt;&#xA;" OwnerUserId="198" LastActivityDate="2023-05-08T08:49:37.380" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10422" PostTypeId="1" AcceptedAnswerId="10423" CreationDate="2023-05-08T16:52:14.687" Score="0" ViewCount="122" Body="&lt;p&gt;The problem:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The mechanical workshop can produce &lt;span class=&quot;math-container&quot;&gt;$600$&lt;/span&gt; units of part #1 or &lt;span class=&quot;math-container&quot;&gt;$1200$&lt;/span&gt; units of part #2 per shift. The production capacity of the thermal workshop, where these parts are sent for heat treatment on the same day, allows for processing &lt;span class=&quot;math-container&quot;&gt;$1200$&lt;/span&gt; units of part #1 or &lt;span class=&quot;math-container&quot;&gt;$800$&lt;/span&gt; units of part #2 per shift. The prices of both parts are the same. It is necessary to determine the daily production program of parts that maximizes the company's output, given the additional condition that both workshops work one shift.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;So, in the end we obtain a mathematical model of the given problem in the form of a linear programming problem, both the objective function and the constraint functions should be linear. Which can be solved using simplex method.&lt;/p&gt;&#xA;&lt;p&gt;Simply speaking, I need the problem above to be described in linear equation with constraints.&lt;/p&gt;&#xA;&lt;p&gt;Example (not related to the problem above):&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/yGROW.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;" OwnerUserId="11796" LastEditorUserId="198" LastEditDate="2023-05-12T12:52:22.487" LastActivityDate="2023-05-12T12:52:22.487" Title="Determine the daily production program that maximizes the company's output" Tags="|linear-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10423" PostTypeId="2" ParentId="10422" CreationDate="2023-05-09T12:23:00.420" Score="2" Body="&lt;p&gt;I assume that both workshops can produce both products in a shift and the working rate is constant. That is, e.g., the mechanical workshop could produce 300 of product 1 and 600 of product 2 in a single shift. A linear program could then look as follows:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_{i}$&lt;/span&gt; be the units produced of product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; the profit earned when producing (and selling) product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Linear Program&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\&#xA;&amp;amp; \max z = p_1 \cdot x_{1} + p_2 \cdot x_{2} \; \\&#xA;\\\textit{S.t.}\\&#xA;\\&#xA;&amp;amp; \frac{x_1}{600} + \frac{x_2}{1200} \leq 1 &amp;amp; \tag1 \\ &#xA;\\&#xA;&amp;amp; \frac{x_1}{1200} + \frac{x_2}{800} \leq 1 &amp;amp; \tag2 \\ \\&#xA;&amp;amp;   x_{1}, x_{2} \in \mathbb{N} \tag3 &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective is to maximize profit. Constraints (1) and (2) ensure that the capacities of workshops are not exceeded. Constraint (3) states that the units produced must be natural numbers.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2023-05-09T12:23:00.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10424" PostTypeId="2" ParentId="10420" CreationDate="2023-05-10T08:35:35.080" Score="1" Body="&lt;p&gt;Generally, the purpose of lifting is to obtain a strong inequality in a higher dimensional space than the original inequality. A cover inequality is only in very rare cases a facet defining inequality for the knapsack polytope. Even the extended cover inequalities define facets in only rare cases (see Proposition 2.3, section II.2 of &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/book/10.1002/9781118627372&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nemhauser and Wolsey&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;The general theory is as follows: Suppose that &lt;span class=&quot;math-container&quot;&gt;$S\subseteq \{0,1\}^n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S^\delta=S\cap\{x\in\{0,1\}^n:x_1=\delta\}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\delta\in\{0,1\}$&lt;/span&gt;. Furthermore, assume that &lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{j=2}^n\pi_jx_j\leq \pi_0&#xA;\end{equation}&lt;/span&gt;&#xA;is a facet defining inequality for &lt;span class=&quot;math-container&quot;&gt;$\text{conv}(S^0)$&lt;/span&gt;, then if &lt;span class=&quot;math-container&quot;&gt;$S^1\neq \emptyset$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha_1=\pi_0-\max\{\sum_{j=2}^n\pi_jx_j:x\in S^1\}$&lt;/span&gt; it can be shown that &lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\alpha_1x_1+\sum_{j=2}^n\pi_jx_j\leq \pi_0&#xA;\end{equation}&lt;/span&gt;&#xA;is facet defining for &lt;span class=&quot;math-container&quot;&gt;$\text{conv}(S)$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=2}^n\pi_jx_j\leq \pi_0$&lt;/span&gt; on the other hand is a facet defining for &lt;span class=&quot;math-container&quot;&gt;$\text{conv}(S^1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S^0\neq\emptyset$&lt;/span&gt; then&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\gamma_1x_1+\sum_{j=2}^n\pi_jx_j\leq \pi_0+\gamma_1&#xA;\end{equation}&lt;/span&gt;&#xA;is a facet defining inequality for &lt;span class=&quot;math-container&quot;&gt;$\text{conv}(S)$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$\gamma_1=\pi_0-\max\{ \sum_{j=2}^n\pi_jx_j:x\in S^0\}$&lt;/span&gt; (these claims are proven in Proposition 1.1. and 1.2. in section II.2 of Nemhauser and Wolsey). Due to these results, if we can prove a given inequality is facet defining for a restricted version of the original polytope (&amp;quot;restricted polytope&amp;quot; here means the polytope in a lower dimensional space obtained by fixing some variables to either zero or one), then up- and down-lifting can be used sequentially to generate a facet defining inequality for the original high-dimensional polytope.&lt;/p&gt;&#xA;&lt;p&gt;The last result needed is stated in Corollary 2.4 in section II.2. of Nemhauser and Wolsey: If &lt;span class=&quot;math-container&quot;&gt;$C\subseteq\{1,...,n\}$&lt;/span&gt; is a minimal cover for the knapsack &lt;span class=&quot;math-container&quot;&gt;$S=\{x\in\{0,1\}:\sum_{j=1}^n a_jx_j\leq b\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(C_1,C_2)$&lt;/span&gt; is a partition of &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$C_1\neq \emptyset$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\sum_{j\in C_1}x_1\leq \vert C_1\vert-1$&lt;/span&gt; is a facet defining inequality for &lt;span class=&quot;math-container&quot;&gt;$\text{conv}(S(C_1,C_2))$&lt;/span&gt;, where&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA; S(C_1,C_2)=\{  x\in\{0,1\}^{\vert C_1\vert}: \sum_{j\in C_1}a_jx_j\leq b-\sum_{j\in C_2}a_j  \}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With this result, we can sequentially apply down-lifting of the variables in &lt;span class=&quot;math-container&quot;&gt;$C_2$&lt;/span&gt; and up-lifting of the variables in &lt;span class=&quot;math-container&quot;&gt;$\{1,...,n\}\setminus C$&lt;/span&gt; in order to get a facet defining inequality for &lt;span class=&quot;math-container&quot;&gt;$\text{conv}(\{x\in\{0,1\}:\sum_{j=1}^n a_jx_j\leq b\})$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2023-05-10T08:35:35.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10425" PostTypeId="1" CreationDate="2023-05-10T09:09:48.053" Score="1" ViewCount="166" Body="&lt;p&gt;I have a specific pickup and delivery problem to work on and am thinking how to incorporate time windows effectively. The problem has some driver with some time window [&lt;span class=&quot;math-container&quot;&gt;$a_d, b_d$&lt;/span&gt;] which is the start time and end time. They also have a start and end locations &lt;span class=&quot;math-container&quot;&gt;$[s_d,e_d]$&lt;/span&gt; roaming around the city to along the way (as much as time allows) to pickup and drop off some people to earn some extra money. However, people (as riders) also have time window [&lt;span class=&quot;math-container&quot;&gt;$a_r, b_r$&lt;/span&gt;] and locations &lt;span class=&quot;math-container&quot;&gt;$[s_r,e_r]$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$a_r$&lt;/span&gt; is the desired start time of rider and &lt;span class=&quot;math-container&quot;&gt;$b_r$&lt;/span&gt; is the desired end time. I know how to model the routing parts as an IP to allow for multiple pickup for drivers and also a possibility of switching between cars for passengers. but because of the same reason I don't know how to include time constraints to ensure that all individuals are within with their time limits and when meeting at locations the time is correct. Is there any trick to apply?&#xA;My try so far:&#xA;decision variable are &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,d}$&lt;/span&gt; if a driver travel and edge. &lt;span class=&quot;math-container&quot;&gt;$y_{i,j,r,d}$&lt;/span&gt; if a rider travel one edge with &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;. And finally &lt;span class=&quot;math-container&quot;&gt;$z_r$&lt;/span&gt; if riders were driven (not important how many times or by whom) then satisfying routing constraint like; every rider/drivers leave s and reach e and meet flow of path.&lt;/p&gt;&#xA;" OwnerUserId="11802" LastEditorUserId="11802" LastEditDate="2023-05-15T07:06:07.057" LastActivityDate="2023-05-15T07:06:07.057" Title="how to satisfy time constraints with meeting points?" Tags="|mixed-integer-programming|modeling|constraint|vehicle-routing|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10426" PostTypeId="2" ParentId="10425" CreationDate="2023-05-10T14:05:28.083" Score="2" Body="&lt;p&gt;You can refer to Google OR &lt;a href=&quot;https://developers.google.com/optimization/routing/vrptw&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt; for more information but it seems you'd need a time matrix &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; between locations &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;&lt;br /&gt;&#xA;Then for  each driver it will be set of constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ a_d+\sum_{i,j}x_{i,j}^d T_{i,j} \le b_d$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$ a_d,b_d$&lt;/span&gt; is the time window for driver &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;.&lt;br /&gt;&#xA;Also you can avoid creating more variables &amp;amp; constraints by creating pre-defined combinations of riders &amp;amp; drivers with compatible time windows, like &lt;span class=&quot;math-container&quot;&gt;$ (d,r): a_d \le a_r \land b_r \le b_d$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for the meeting point time there can be another variable &lt;span class=&quot;math-container&quot;&gt;$t_{rd}^{s_r}$&lt;/span&gt; with bounds as &lt;span class=&quot;math-container&quot;&gt;$ a_r \le t_{r,d}^{s_r} \le b_r$&lt;/span&gt; or&lt;br /&gt;&#xA;Using time matrix:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ a_r \le a_d+\sum_{i,j}y_{i,j}^{r,d}T_{i,j} \le b_r$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$ t_d$&lt;/span&gt; is start time of the day for the driver.&lt;/p&gt;&#xA;&lt;p&gt;And other constraints will be needed like&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_r y_{ij}^{rd} \le Mx_{ij}^d \quad \forall d \ \forall i,j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&lt;br /&gt;&#xA;Referring to slightly older but probably pretty fundamental &amp;amp; relevant &lt;a href=&quot;http://alvarestech.com/temp/vrptw/Vehicle%20Routing%20Problem%20with%20Time%20Windows.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;article&lt;/a&gt;. So the constraints will be&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ z_ra_r \le t_{i}^{rd} \le z_rb_r \quad \forall r,d \ \forall i$&lt;/span&gt;&lt;br /&gt;&#xA;and&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ t_{i}^{rd} + T_{i,j} - t_{j}^{rd} \le (a_r+b_r)(1-y_{i,j}^{r,d}) \quad \forall i,j \ \forall r,d$&lt;/span&gt;&lt;br /&gt;&#xA;The above constraint can be reduced as only one driver is riding with &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; along an edge &lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_d t_{i}^{rd} + T_{i,j} - \sum_d t_{j}^{rd} \le (a_r+b_r)(1-\sum_d y_{i,j}^{r,d}) \quad \forall i,j \ \forall r$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_d y_{ij}^{rd} \le 1 \quad \forall i,j \ \forall r $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-05-11T13:03:49.500" LastActivityDate="2023-05-11T13:03:49.500" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10427" PostTypeId="1" CreationDate="2023-05-11T09:32:50.110" Score="0" ViewCount="199" Body="&lt;p&gt;Complete revision:&lt;/p&gt;&#xA;&lt;p&gt;I have all 4 machines that can run in positive and negative directions which results in 2 outputs:&#xA;&lt;span class=&quot;math-container&quot;&gt;$ P_1 = \begin{cases}&#xA;  -390 \le P_1 \le -300 &amp;amp; \text{for neg mode}\\    &#xA;  0 &amp;amp; \text{for off mode}\\&#xA;  190 \le P_1 \le 380  &amp;amp; \text{for pos mode}&#xA;\end{cases}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;These must match exactly the &amp;quot;Setpoint&amp;quot; while minimizing the efficiency. The efficiency for each machine is given by the equation: &lt;span class=&quot;math-container&quot;&gt;$ \frac{0.03}{190}x+0.937-0.2 \cdot i\\  \text{for i in the range number of machine} $&lt;/span&gt;&#xA;So far I tried formulating like this using 3 variables for each mode, but I still can't reformulate to constraint the output.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Define the problem as a minimization problem, for each setpoint&#xA;for P_co in P_cos:&#xA;prob = LpProblem(&amp;quot;HydroOptimization&amp;quot;, LpMaximize)&#xA;&#xA;# Define decision variables&#xA;P = [LpVariable(f&amp;quot;P{i}&amp;quot;, P_min_p, P_max_t, cat=&amp;quot;Continuous&amp;quot;) for i in range(N)]&#xA;X = [LpVariable(f&amp;quot;X{i}{j}&amp;quot;, cat =&amp;quot;Binary&amp;quot;) for i in range(N) for j in [&amp;quot;p&amp;quot;,&amp;quot;t&amp;quot;,&amp;quot;z&amp;quot;]]&#xA;print(X)&#xA;&#xA;Eff = LpVariable(f&amp;quot;Eff&amp;quot;, lowBound=0, upBound= 1, cat='Continuous')&#xA;&#xA;&#xA;&#xA;for i in range(N):&#xA;    prob += X[3*i] + X[3*i+1] + X[3*i+2] == 1, f&amp;quot;Pump Turbine Zero condition{i}&amp;quot;&#xA;&#xA;    Less_eq = LpConstraint(e = P[i],&#xA;                            sense=LpConstraintLE,&#xA;                            rhs = P_max_p if X[3*i] == 1 else 0) &#xA;    &#xA;    Great_eq = LpConstraint(e =P[i],&#xA;                            sense=LpConstraintGE,&#xA;                            rhs = P_min_t if X[3*i+1] == 1 else 0)&#xA;    &#xA;    Great_eq = LpConstraint(e =P[i],&#xA;                            sense=LpConstraintEQ,&#xA;                            rhs = 0 if X[3*i+2] == 1 else 0)&#xA;    &#xA;    prob.addConstraint(name = f&amp;quot;less_eq{i}&amp;quot;, constraint=X[3*i]&amp;lt;=P[i]&amp;lt;=) &#xA;    prob.addConstraint(name = f&amp;quot;Great_eq{i}&amp;quot;, constraint=Great_eq) &#xA;&#xA;    prob.addConstraint(name = f&amp;quot;Prod{i}&amp;quot;, constraint=  LpAffineExpression(P[i], X[3*i]) + LpAffineExpression(P[i], X[3*i+1]) + X[3*i+2]*0 == P[i])&#xA;&#xA;print(prob)&#xA;&#xA;&#xA;prob += lpSum(P) == P_co, &amp;quot;Setpoint&amp;quot;&#xA;&#xA;# Define objective function&#xA;for i in range(N):&#xA;    Eff += (-0.0000012*(P[i]-390)**2+1)*(P[i])&#xA;Eff = Eff/4*P_co&#xA;prob += Eff&#xA;print(prob)&#xA;# Solve the problem&#xA;status = prob.solve()&#xA;&#xA;# Print the solution status&#xA;print(&amp;quot;Solution status:&amp;quot;, LpStatus[status])&#xA;&#xA;# Print the decision variable values&#xA;&#xA;print(&amp;quot;P values:&amp;quot;, [P[i].value() for i in range(N)])&#xA;print(&amp;quot;Efficiency:&amp;quot;,Eff.value())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also later I would like to implement the start up and shutdown cost of each machine&lt;/p&gt;&#xA;" OwnerUserId="11807" LastEditorUserId="11807" LastEditDate="2023-05-15T09:32:15.637" LastActivityDate="2023-05-17T13:57:07.840" Title="Using PULP to model machines in a factory" Tags="|optimization|mixed-integer-programming|python|nonlinear-programming|pulp|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10428" PostTypeId="1" CreationDate="2023-05-11T10:32:31.907" Score="3" ViewCount="209" Body="&lt;p&gt;Im solving n-dimensional Knapsack problem as LP problem.&lt;/p&gt;&#xA;&lt;p&gt;I noticed that sometimes dual LP problem may be solved much faster than primal.&lt;/p&gt;&#xA;&lt;p&gt;My test problem contains 500k variables and 50k constraints, integers only.&lt;/p&gt;&#xA;&lt;p&gt;When I force 'presolve dual setting' I see much better results in some cases comparing to 'presolve dual setting' set to auto, but sometimes primal is faster.&#xA;&lt;a href=&quot;https://www.ibm.com/docs/en/cofz/12.10.0?topic=parameters-presolve-dual-setting&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/cofz/12.10.0?topic=parameters-presolve-dual-setting&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there any way to understand that primal problem will take a lot of time and try dual instead?&lt;/p&gt;&#xA;&lt;p&gt;btw. When problem is slow I see a lot of iterations like, maybe a lot of iterations with same gap may be an indicator&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0z0nk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0z0nk.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11809" LastActivityDate="2023-05-11T15:26:25.140" Title="Dual problem in IBM CPLEX" Tags="|cplex|cplex-python-api|dual-simplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10429" PostTypeId="2" ParentId="10428" CreationDate="2023-05-11T15:26:25.140" Score="3" Body="&lt;p&gt;If the primal LP problem suffers from degeneracy, I believe dual simplex may be faster. You might try using the barrier method to solve the (primal) LP. In cases where the LP has degeneracy issues, I think barrier has been known to speed things up.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-05-11T15:26:25.140" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10430" PostTypeId="2" ParentId="10427" CreationDate="2023-05-12T00:05:31.303" Score="0" Body="&lt;p&gt;Each machine needs at least two integral variables. I demonstrate here with one 'negative' variable and one 'positive' variable. I assume that in your description &amp;quot;minimize efficiency&amp;quot; is incorrect and you mean &amp;quot;maximize efficiency&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;I also assume that the &amp;quot;set point&amp;quot; is the sum of the machine outputs, regardless of whether they're negative or positive. Your description left this ambiguous.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import pandas as pd&#xA;import pulp&#xA;&#xA;&#xA;def make_vars(index: int) -&amp;gt; pd.Series:&#xA;    output = pulp.LpVariable(&#xA;        name=f'P{index}', cat=pulp.LpContinuous)&#xA;    neg = pulp.LpVariable(name=f'neg{index}', cat=pulp.LpBinary)&#xA;    pos = pulp.LpVariable(name=f'pos{index}', cat=pulp.LpBinary)&#xA;    eff = 0.03/190*output + 0.937 - 0.2*index&#xA;&#xA;    prob.addConstraint(name=f'excl{index}', constraint=neg + pos &amp;lt;= 1)&#xA;&#xA;    '''&#xA;    sign  lo   hi&#xA;    -1  -390 -300&#xA;     0     0    0&#xA;    +1   190  380&#xA;    '''&#xA;    prob.addConstraint(name=f'lo{index}', constraint=output &amp;gt;= neg*-390 + pos*190)&#xA;    prob.addConstraint(name=f'hi{index}', constraint=output &amp;lt;= neg*-300 + pos*380)&#xA;&#xA;    return pd.Series([output, neg, pos, eff], index=['output', 'neg', 'pos', 'eff'])&#xA;&#xA;&#xA;prob = pulp.LpProblem(name='HydroOptimization', sense=pulp.LpMaximize)&#xA;machines = pd.Series(&#xA;    pd.RangeIndex(start=0, stop=4), name='index'&#xA;).apply(make_vars)&#xA;&#xA;set_point = 120&#xA;prob.addConstraint(&#xA;    name='set_point',&#xA;    constraint=pulp.lpSum(machines.output) == set_point)&#xA;prob.objective = pulp.lpSum(machines.eff)&#xA;&#xA;print(machines)&#xA;print(prob)&#xA;prob.solve()&#xA;assert prob.status == pulp.LpStatusOptimal&#xA;&#xA;machines[['output', 'neg', 'pos']] = machines[[&#xA;    'output', 'neg', 'pos'&#xA;]].applymap(pulp.LpVariable.value)&#xA;machines['eff'] = machines['eff'].apply(pulp.LpAffineExpression.value)&#xA;print(machines)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;  output   neg   pos                           eff&#xA;0     P0  neg0  pos0  {P0: 0.00015789473684210527}&#xA;1     P1  neg1  pos1  {P1: 0.00015789473684210527}&#xA;2     P2  neg2  pos2  {P2: 0.00015789473684210527}&#xA;3     P3  neg3  pos3  {P3: 0.00015789473684210527}&#xA;HydroOptimization:&#xA;MAXIMIZE&#xA;0.00015789473684210527*P0 + 0.00015789473684210527*P1 + 0.00015789473684210527*P2 + 0.00015789473684210527*P3 + 2.548&#xA;SUBJECT TO&#xA;excl0: neg0 + pos0 &amp;lt;= 1&#xA;&#xA;lo0: P0 + 390 neg0 - 190 pos0 &amp;gt;= 0&#xA;&#xA;hi0: P0 + 300 neg0 - 380 pos0 &amp;lt;= 0&#xA;&#xA;excl1: neg1 + pos1 &amp;lt;= 1&#xA;&#xA;lo1: P1 + 390 neg1 - 190 pos1 &amp;gt;= 0&#xA;&#xA;hi1: P1 + 300 neg1 - 380 pos1 &amp;lt;= 0&#xA;&#xA;excl2: neg2 + pos2 &amp;lt;= 1&#xA;&#xA;lo2: P2 + 390 neg2 - 190 pos2 &amp;gt;= 0&#xA;&#xA;hi2: P2 + 300 neg2 - 380 pos2 &amp;lt;= 0&#xA;&#xA;excl3: neg3 + pos3 &amp;lt;= 1&#xA;&#xA;lo3: P3 + 390 neg3 - 190 pos3 &amp;gt;= 0&#xA;&#xA;hi3: P3 + 300 neg3 - 380 pos3 &amp;lt;= 0&#xA;&#xA;set_point: P0 + P1 + P2 + P3 = 120&#xA;&#xA;VARIABLES&#xA;P0 free Continuous&#xA;P1 free Continuous&#xA;P2 free Continuous&#xA;P3 free Continuous&#xA;0 &amp;lt;= neg0 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= neg1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= neg2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= neg3 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= pos0 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= pos1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= pos2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= pos3 &amp;lt;= 1 Integer&#xA;&#xA;Welcome to the CBC MILP Solver &#xA;Version: 2.10.3 &#xA;Build Date: Dec 15 2019 &#xA;&#xA;At line 2 NAME          MODEL&#xA;At line 3 ROWS&#xA;At line 18 COLUMNS&#xA;At line 75 RHS&#xA;At line 89 BOUNDS&#xA;At line 102 ENDATA&#xA;Problem MODEL has 13 rows, 12 columns and 36 elements&#xA;Coin0008I MODEL read with 0 errors&#xA;Option for timeMode changed from cpu to elapsed&#xA;Continuous objective value is 0.0189474 - 0.00 seconds&#xA;Cgl0004I processed model has 12 rows, 11 columns (8 integer (8 of which binary)) and 36 elements&#xA;Cbc0038I Initial state - 1 integers unsatisfied sum - 0.315789&#xA;Cbc0038I Pass   1: suminf.    0.31579 (1) obj. -0.0189474 iterations 1&#xA;Cbc0038I Pass   2: suminf.    0.17949 (1) obj. -0.0189474 iterations 5&#xA;Cbc0038I Pass   3: suminf.    0.10526 (1) obj. -0.0189474 iterations 6&#xA;Cbc0038I Pass   4: suminf.    0.00000 (0) obj. -0.0189474 iterations 4&#xA;Cbc0038I Solution found of -0.0189474&#xA;Cbc0038I Relaxing continuous gives -0.0189474&#xA;Cbc0038I Before mini branch and bound, 4 integers at bound fixed and 0 continuous&#xA;Cbc0038I Mini branch and bound did not improve solution (0.00 seconds)&#xA;Cbc0038I After 0.00 seconds - Feasibility pump exiting with objective of -0.0189474 - took 0.00 seconds&#xA;Cbc0012I Integer solution of -0.018947368 found by feasibility pump after 0 iterations and 0 nodes (0.00 seconds)&#xA;Cbc0001I Search completed - best objective -0.018947368421052, took 0 iterations and 0 nodes (0.00 seconds)&#xA;Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost&#xA;Cuts at root node changed objective from -0.0189474 to -0.0189474&#xA;Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;&#xA;Result - Optimal solution found&#xA;&#xA;Objective value:                0.01894737&#xA;Enumerated nodes:               0&#xA;Total iterations:               0&#xA;Time (CPU seconds):             0.00&#xA;Time (Wallclock seconds):       0.00&#xA;&#xA;Option for printingOptions changed from normal to all&#xA;Total time (CPU seconds):       0.00   (Wallclock seconds):       0.01&#xA;&#xA;   output  neg  pos       eff&#xA;0  -300.0  1.0  0.0  0.889632&#xA;1   190.0  0.0  1.0  0.767000&#xA;2     0.0  0.0  0.0  0.537000&#xA;3   230.0  0.0  1.0  0.373316&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11118" LastEditorUserId="11118" LastEditDate="2023-05-17T13:57:07.840" LastActivityDate="2023-05-17T13:57:07.840" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10431" PostTypeId="2" ParentId="10427" CreationDate="2023-05-12T02:33:36.913" Score="0" Body="&lt;p&gt;For the first 2 machines &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; define a set of binary vars &lt;span class=&quot;math-container&quot;&gt;$p_{m,0}, p_{m,50},p_{m,100}$&lt;/span&gt;. Now for production variable &lt;span class=&quot;math-container&quot;&gt;$x \in R$&lt;/span&gt; introduce constraints&lt;br /&gt;&#xA;(1) &lt;span class=&quot;math-container&quot;&gt;$ x_m = 50p_{m,50} + 100p_{m,100}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ (2) p_{m,0}+p_{m,50}+p_{m,100}=1 \quad \forall m =\{1,2\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For efficiency &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$e_m = p_{m,50}-p_{m,100} $&lt;/span&gt;:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$e_m$&lt;/span&gt; need not be an optimization variable. It could an expression to be used in the objective.&lt;/p&gt;&#xA;&lt;p&gt;In fact if you want to reduce number of variables/constraints then for the 2 fixed machines &lt;span class=&quot;math-container&quot;&gt;$50p_{m,50}+100p_{m,100} $&lt;/span&gt; can be used as production variable, instead of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; along with constraint (2) for each of fixed machines.&lt;/p&gt;&#xA;&lt;p&gt;For the other two machines&lt;br /&gt;&#xA;(3) &lt;span class=&quot;math-container&quot;&gt;$b_m \le x_m \le 200b_m $&lt;/span&gt;&lt;br /&gt;&#xA;Here &lt;span class=&quot;math-container&quot;&gt;$b_m$&lt;/span&gt; is a binary variable &amp;amp; can act as efficiency variable.&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&lt;br /&gt;&#xA;Based on new piecewise production function, you'd need the following constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ -390\delta_1+190\delta_2  \le x \le -300\delta_1+380\delta_2$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \delta_1 + \delta_2 + \delta_3 = 1$&lt;/span&gt;: ensures at least one of the binaries is 1&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$ \delta \in \{0,1 \}^{3}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-05-15T16:38:16.407" LastActivityDate="2023-05-15T16:38:16.407" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10432" PostTypeId="1" AcceptedAnswerId="10435" CreationDate="2023-05-12T14:47:51.703" Score="3" ViewCount="414" Body="&lt;p&gt;Consider the linear program:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{maximize} ~~ c\cdot x \\ \text{subject to} ~~ A\cdot x\leq b, ~~x\geq 0.$$&lt;/span&gt;&#xA;Suppose &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$m\times n$&lt;/span&gt; matrix, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; an &lt;span class=&quot;math-container&quot;&gt;$m\times 1$&lt;/span&gt; vector and &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; an &lt;span class=&quot;math-container&quot;&gt;$n\times 1$&lt;/span&gt; vector, and all their elements are integers with at most &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; bits.&lt;/p&gt;&#xA;&lt;p&gt;Suppose the program is feasible and bounded. What is an upper bound on the number of bits in the binary representation of the optimal solution value, as a function of &lt;span class=&quot;math-container&quot;&gt;$m, n, k$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Since linear programming can be solved in polynomial time, I would guess that there is some upper bound that is polynomial in &lt;span class=&quot;math-container&quot;&gt;$m, n, k$&lt;/span&gt;. But what polynomial exactly?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: as there are many ways to represent numbers, I have to clarify that I mean: a representation of the solution as (numerator)/(denominator), where the numerator and the denominator are integers that are represented in binary. Note that a linear program always has a rational solution.&lt;/p&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="2576" LastEditDate="2023-05-13T19:39:04.717" LastActivityDate="2024-04-03T15:36:15.310" Title="Upper bound on length of solution of linear program" Tags="|linear-programming|bounds|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10433" PostTypeId="2" ParentId="10432" CreationDate="2023-05-12T16:36:57.893" Score="3" Body="&lt;p&gt;Consider the linear program &lt;span class=&quot;math-container&quot;&gt;$maximize\ x\ s.t. 3x = 1$&lt;/span&gt;. It can be easily transformed into the standard form in your question. The optimal solution to this lp is &lt;span class=&quot;math-container&quot;&gt;$x = \frac{1}{3}$&lt;/span&gt; with an objective value of &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{3}$&lt;/span&gt;. The binary representation is &lt;span class=&quot;math-container&quot;&gt;$0.010101010101...$&lt;/span&gt;, repeating infinitely. Thus there is no upper bound on the length of the binary representation of the optimal value of an LP in general.&lt;/p&gt;&#xA;" OwnerUserId="47" LastActivityDate="2023-05-12T16:36:57.893" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10434" PostTypeId="2" ParentId="10432" CreationDate="2023-05-12T21:21:46.130" Score="0" Body="&lt;p&gt;Let's consider&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x\in \mathbb{R}} x $$&lt;/span&gt;&#xA;subject to &lt;span class=&quot;math-container&quot;&gt;$x*3=1$&lt;/span&gt;. We know optimal value will be &lt;span class=&quot;math-container&quot;&gt;$\in \mathbb{R}^1$&lt;/span&gt; and further based on properties of the polytope formed by the constraints, without being aware of the objective we can find that the polytope is &lt;span class=&quot;math-container&quot;&gt;$\{1/3\}$&lt;/span&gt; so given the constraints we actually need 0 bits to represent the solution which is a far cry from &lt;span class=&quot;math-container&quot;&gt;$\infty$&lt;/span&gt; bits. Let's consider &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;=x*3&amp;lt;=1$&lt;/span&gt; similarily unaware of the objective. There are 3 possible solutions depending on the objectives. &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x=1/3$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x\in [0,1/3]$&lt;/span&gt; the third case reflects that the objective is orthogonal to the facet of the symplex holding the optimal solution or the objective weighted by &lt;span class=&quot;math-container&quot;&gt;$\vec 0$&lt;/span&gt; face. Luckily you didn't ask for an encoding to all the solutions but of the encoding of one solution which we can do with just one bit.&lt;/p&gt;&#xA;&lt;p&gt;This is not a pathology of one dimensional case. If there is a feasible and optimal point there has to be one on the vertices of the polytope. Also for any vertex of a polytope there exists an objective for which that corner is uniquely among the optimal point. So we need atleast &lt;span class=&quot;math-container&quot;&gt;$\log_2(\#\text{vertices count})$&lt;/span&gt; bits. &lt;a href=&quot;https://mathoverflow.net/a/127426&quot;&gt;Formula for maximum vertex count&lt;/a&gt;. For fixed dimension this grows &lt;span class=&quot;math-container&quot;&gt;$\log_2(\text{polynomial}(k))$&lt;/span&gt; where the order of the polynomial depends &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. This encoding is not very useful though. One property would want from an encoding is to read of the solution from the encoding.&lt;/p&gt;&#xA;&lt;h3&gt;A finite information componentwise interpretable encoding&lt;/h3&gt;&#xA;&lt;p&gt;The next construction rests on two claims:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Given a bounded &lt;span class=&quot;math-container&quot;&gt;$G \subset \mathbb{Z}$&lt;/span&gt; any polytope &lt;span class=&quot;math-container&quot;&gt;$Ax&amp;lt;=b$&lt;/span&gt; with&#xA;&lt;span class=&quot;math-container&quot;&gt;$A\in G^{m\times n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b \in G^n$&lt;/span&gt; which is bounded all its&#xA;vertices are rational. There is a finite number of distinct rational numbers which appear in those vertices. There exist a largest &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; rational number whose integers multiples can represent any of rational numbers appearing in the vertices.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Given a bounded &lt;span class=&quot;math-container&quot;&gt;$G \subset \mathbb{Z}$&lt;/span&gt; any polytope &lt;span class=&quot;math-container&quot;&gt;$Ax&amp;lt;=b$&lt;/span&gt; with&#xA;&lt;span class=&quot;math-container&quot;&gt;$A\in G^{m\times n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b \in G^n$&lt;/span&gt; projected&#xA;on any axis results is an interval. These intervals have a bounded length &lt;span class=&quot;math-container&quot;&gt;$d \in \mathbb{Q}^+$&lt;/span&gt; depending on &lt;span class=&quot;math-container&quot;&gt;$(m,n,G)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${d\over s} \in \mathbb{Z}$&lt;/span&gt; by construction. Any vertex of &lt;span class=&quot;math-container&quot;&gt;$Ax&amp;lt;=b$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$ \in ([-|{d\over s}|, |{d\over s}|] \cap \mathbb{Z} )^n * s $&lt;/span&gt; which we can represent with &lt;span class=&quot;math-container&quot;&gt;$n \lceil \log_2 ({2*d\over s}) \rceil$&lt;/span&gt; bits.&lt;/p&gt;&#xA;&lt;h3&gt;How large are &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;?&lt;/h3&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(\prod_{g \in G} |g|)^{(m+1) n}$&lt;/span&gt; is a valid &lt;span class=&quot;math-container&quot;&gt;$1 \over s$&lt;/span&gt;. There are way tighter bounds though.&lt;/p&gt;&#xA;&lt;p&gt;For bounding &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; i don't have a formula, however we can calculate &lt;span class=&quot;math-container&quot;&gt;$d \over 2$&lt;/span&gt; using a MINLP program.&lt;/p&gt;&#xA;&lt;p&gt;It involves insections of the most slightly non parallel hyper planes being as far away from each other as possible using integers available as coefficients from &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;.&#xA;The maximum objective of this program in the JuMP modeling language calculates  &lt;span class=&quot;math-container&quot;&gt;$d\over 2 $&lt;/span&gt; in for &lt;span class=&quot;math-container&quot;&gt;$n=2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$m=2$&lt;/span&gt; by finding a pairs of equality constraints in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^2$&lt;/span&gt; such that the point defined by the pairs intersection has a maximal squared first component.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using JuMP, Gurobi&#xA;&#xA;l =-2&#xA;u = 1&#xA;M = max(l^2, u^2)&#xA;&#xA;m = Model(Gurobi.Optimizer)&#xA;set_attribute(m, &amp;quot;Presolve&amp;quot;, 2)&#xA;set_attribute(m, &amp;quot;NonConvex&amp;quot;, 2)&#xA;&#xA;set_attribute(m, &amp;quot;FeasibilityTol&amp;quot;, 1.1e-9)&#xA;&#xA;@variable(m, -1.0e11 &amp;lt;= x[1:2] &amp;lt;= 1.0e11) &#xA;#mess with this bound and Gurobi cries. It obviously limits the validity of the program, but those errors are dominated by Gurobis minimal &amp;quot;FeasibilityTol&amp;quot; of 1.0e-9. Don't trust it to be correct for large numbers.&#xA;&#xA;@variable(m, l&amp;lt;= b[1:2] &amp;lt;= u,Int)&#xA;@variable(m, l&amp;lt;= a[1:2,1:2] &amp;lt;= u,Int)&#xA;&#xA;@constraint(m, a[:,:]*x[:] == b[:])  # Two linear inequalities&#xA;&#xA;@objective(m, Max, (x[1])^2)&#xA;&#xA;@variable(m, 0 &amp;lt;= s[1:2] &amp;lt;= M *2, Int)&#xA;for j in 1:2 @constraint(m, s[j] == sum( a[j,:].* a[j,:])) end&#xA;&#xA;@variable(m, M *-2 &amp;lt;= c &amp;lt;= M *2, Int)&#xA;@constraint(m, c == sum( a[1,:].* a[2,:])) # scalar product between the equations&#xA;@constraint(m, c*c + 1 &amp;lt;= s[1]*s[2])&#xA;# We want them not being colinear, so we impose &amp;lt;a[1,:], a[2,:]&amp;gt;^2 &amp;lt; ||a[1,:]||^2*||a[2,:]||^2, since all coefficients are integer +1 is actually a safe epsilon to impose this.&#xA;&#xA;optimize!(m)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$G = \mathbb{Z} \cap [-1,0] $&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$d=2$&lt;/span&gt; holds. For &lt;span class=&quot;math-container&quot;&gt;$G = \mathbb{Z} \cap [-1,1] $&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$d=8$&lt;/span&gt; holds. For &lt;span class=&quot;math-container&quot;&gt;$G = \mathbb{Z} \cap [-2,1] $&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$d=8$&lt;/span&gt; holds. For &lt;span class=&quot;math-container&quot;&gt;$G = \mathbb{Z} \cap [-8,7] $&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$d=28800$&lt;/span&gt; holds. Beyond this (and maybe also earlier) you will need a rational solver to get accurate results. I am not aware of such a solver. I hope you can discover a structure which let's you build an upper bound for &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; with this. Representing the &lt;span class=&quot;math-container&quot;&gt;$\{0, 1, 2, 5\}$&lt;/span&gt; requires additional binary variables.&lt;/p&gt;&#xA;&lt;h3&gt;An idea for a &lt;span class=&quot;math-container&quot;&gt;$d(m,m,G)$&lt;/span&gt;&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CayfE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CayfE.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt; This might be the most amplying square matrix. It assumes without loss of much generality that &lt;span class=&quot;math-container&quot;&gt;$|\min G| \leq \max G$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4777" LastEditorUserId="4777" LastEditDate="2023-05-13T20:01:54.327" LastActivityDate="2023-05-13T20:01:54.327" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10435" PostTypeId="2" ParentId="10432" CreationDate="2023-05-13T20:23:11.670" Score="5" Body="&lt;p&gt;Based on the clarification that we are assuming exact arithmetic, and assuming &lt;span class=&quot;math-container&quot;&gt;$m&amp;gt;1,$&lt;/span&gt; I think the bound is likely to be &lt;span class=&quot;math-container&quot;&gt;$m\cdot (k + \log_2(m))$&lt;/span&gt; bits ... but the following bears careful checking.&lt;/p&gt;&#xA;&lt;p&gt;Let's make a minor change (inserting slack variables) and write the constraint matrix as &lt;span class=&quot;math-container&quot;&gt;$Ax = b,$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is now &lt;span class=&quot;math-container&quot;&gt;$m\times (m+n)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is still &lt;span class=&quot;math-container&quot;&gt;$m\times 1.$&lt;/span&gt; The optimal solution is &lt;span class=&quot;math-container&quot;&gt;$x=B^{-1} \cdot b$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$m\times m$&lt;/span&gt; basis matrix.&lt;/p&gt;&#xA;&lt;p&gt;Now use &lt;a href=&quot;https://en.wikipedia.org/wiki/Cramer%27s_rule&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cramer's rule&lt;/a&gt; to solve &lt;span class=&quot;math-container&quot;&gt;$B\cdot x = b.$&lt;/span&gt; According to Cramer's rule, each element of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the ratio of two determinants, both coming from &lt;span class=&quot;math-container&quot;&gt;$m \times m$&lt;/span&gt; matrices. Each determinant is the sum of &lt;span class=&quot;math-container&quot;&gt;$m!$&lt;/span&gt; terms, with each term being the product of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; matrix elements. If each element is bounded in magnitude by &lt;span class=&quot;math-container&quot;&gt;$2^k,$&lt;/span&gt; then each product is bounded by &lt;span class=&quot;math-container&quot;&gt;$2^{mk}$&lt;/span&gt; and the determinant is bounded by &lt;span class=&quot;math-container&quot;&gt;$m! \cdot 2^{mk}.$&lt;/span&gt; So the number of bits to express either numerator or denominator of any element of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is bounded by &lt;span class=&quot;math-container&quot;&gt;$k\cdot m + \log_2(m!).$&lt;/span&gt; Since &lt;span class=&quot;math-container&quot;&gt;$\log_2(m!)$&lt;/span&gt; is bounded by &lt;span class=&quot;math-container&quot;&gt;$m\log_2(m),$&lt;/span&gt; the overall bound on the number of bits is &lt;span class=&quot;math-container&quot;&gt;$m\cdot (k + \log_2(m)).$&lt;/span&gt; (The bound can perhaps be tightened a bit using &lt;a href=&quot;https://en.wikipedia.org/wiki/Stirling%27s_approximation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Stirling's approximation&lt;/a&gt; for the log of the factorial.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2024-04-03T15:36:15.310" LastActivityDate="2024-04-03T15:36:15.310" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10436" PostTypeId="2" ParentId="10427" CreationDate="2023-05-14T08:41:06.380" Score="1" Body="&lt;p&gt;I assumed that the mode indicator is a variable otherwise, what you are looking for can be applied by a simple if-then loop on the constraints. To define the first row of your logical expression, it is equivalent to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ Iff \quad (mod=-1) \implies (-390 \leq P_{1} \leq -300) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To linearize this constraint you need to define the binary auxiliary variables &lt;span class=&quot;math-container&quot;&gt;$z_{1}, \cdots, z_{3}$&lt;/span&gt;, and derive the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ (mod = -1) \implies (z_{1} = 1) \iff (z_{1} = 0) \implies (mod \neq -1) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\cdots $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ ((z_{2} = 1) \implies (-390 \leq P_{1})) \land ((z_{3} = 1) \implies (P_{1} \leq -300)) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\cdots $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_{1} \implies (z_{2} \land z_{3}) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \lnot z_{1} \lor (z_{2} \land z_{3}) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (\lnot z_{1} \lor z_{2}) \land (\lnot z_{1} \lor z_{3}) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\cdots $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (1-z_{1}) + z_{2} \geq 1 \quad (1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ (1-z_{1}) + z_{3} \geq 1 \quad (2)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ mod \geq 0 - M_1(z_{1}) \quad (3) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ mod \leq -2 + M_2(z_{1}) \quad (4) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ P_{1} \geq -390 - M_3(1-z_{2}) \quad (5) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ P_{1} \leq -300 + M_4(1-z_{3}) \quad (6) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, the rest parts can already be linearized in the above form.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-05-14T08:41:06.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10437" PostTypeId="1" AcceptedAnswerId="10438" CreationDate="2023-05-14T09:16:58.947" Score="5" ViewCount="877" Body="&lt;p&gt;Suppose both &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}^{ab}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}^a$&lt;/span&gt; are binaries. Then how can I rewrite the following if-then in linear form?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_b x_{i,j}^{ab} \ge 1 \implies \sum_{i,j} y_{i,j}^a = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I was thinking of considering an indicator. But is there a better way to not have any additional variables (indicators) and still linearize?&lt;/p&gt;&#xA;&lt;p&gt;My thought was to have, &lt;span class=&quot;math-container&quot;&gt;$\alpha^a$&lt;/span&gt;, a binary indicator. Then&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_b x_{i,j}^{ab} \ge 1 \implies \alpha^a \quad \&amp;amp;\&amp;amp; \quad  \alpha^a \implies\sum_{i,j} y_{i,j}^a \le 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then the first one becomes &lt;span class=&quot;math-container&quot;&gt;$1- \alpha^a \le \sum_b x_{i,j}^{ab} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And the next one becomes &lt;span class=&quot;math-container&quot;&gt;$\alpha^a \le \sum_{i,j} y_{i,j}^{a} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is this a correct way to rewrite it?&lt;/p&gt;&#xA;" OwnerUserId="11474" LastEditorUserId="1160" LastEditDate="2023-05-16T13:39:45.200" LastActivityDate="2023-05-16T13:39:45.200" Title="Rewriting if-then constraints of binary summations" Tags="|mixed-integer-programming|modeling|linearization|logical-constraints|indicator-constraints|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10438" PostTypeId="2" ParentId="10437" CreationDate="2023-05-14T09:26:47.350" Score="13" Body="&lt;p&gt;In conjunctive normal form, you want to enforce:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\quad \quad \quad\bigvee_b x_{i,j}^{a,b} \implies \bigwedge_{u,v}\neg y_{u,v}^{a} \quad&amp;amp;\forall a,i,j\\&#xA;&amp;amp;\equiv \quad\neg \left( \bigvee_b  x_{i,j}^{a,b} \right) \vee \left(\bigwedge_{u,v}\neg y_{u,v}^{a} \right) \quad&amp;amp;\forall a,i,j\\&#xA;&amp;amp;\equiv \quad \left( \bigwedge_b  \neg x_{i,j}^{a,b} \right) \vee  \left(\bigwedge_{u,v}\neg y_{u,v}^{a} \right) \quad&amp;amp;\forall a,i,j\\&#xA;&amp;amp;\equiv \quad 1- x_{i,j}^{a,b} + 1-y_{u,v}^{a} \ge 1\quad&amp;amp;\forall a,b,i,j,u,v\\&#xA;&amp;amp;\equiv \quad x_{i,j}^{a,b} + y_{u,v}^{a}\le 1 \quad&amp;amp;\forall a,b,i,j,u,v\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can verify that this is correct: if any &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variable takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, then all other &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables must equal &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, which will force the sum to also be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;As noted by @RobPratt in the comments below, a more compact (although weaker) formulation can be obtained by aggregating the conflict constraint by summing both sides over &lt;span class=&quot;math-container&quot;&gt;$b,i,j$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{b,i,j}(x_{i,j}^{a,b} + y_{u,v}^{a})\le \sum_{b,i,j} 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-05-14T12:57:46.997" LastActivityDate="2023-05-14T12:57:46.997" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10439" PostTypeId="2" ParentId="10437" CreationDate="2023-05-14T11:38:19.430" Score="4" Body="&lt;p&gt;Another way would be by introducing the new binary auxiliary variables &lt;span class=&quot;math-container&quot;&gt;$z_{i, j, a}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_a$&lt;/span&gt; and imply the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ z_{i,j,a} = 1 \iff\left(\sum_{b} x_{i,j,a,b} \geq 1\right) \quad \forall i,j,a \tag1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ w_a = 1 \iff\left(\sum_{u,v} y_{u,v,a} = 0\right) \quad \forall a \tag2$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_{i,j,a} = 1 \implies w_a = 1 \quad \forall i,j,a \tag3$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As far as I know, Pyomo has an internal facility to do these kinds of transformations somewhat automatically under a hood. The following snippet code can do this transformation:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = pyo.ConcreteModel()&#xA;model.I = pyo.Set(initialize= range(2))&#xA;model.J = pyo.Set(initialize= range(2))&#xA;model.A = pyo.Set(initialize= range(2))&#xA;model.B = pyo.Set(initialize= range(2))&#xA;model.U = pyo.Set(initialize= range(2))&#xA;model.V = pyo.Set(initialize= range(2))&#xA;&#xA;model.x = pyo.Var(model.I, model.J, model.A, model.B, domain= Binary, name= &amp;quot;x&amp;quot;, bounds=(0, 1))&#xA;model.y = pyo.Var(model.I, model.J, model.A, domain= Binary, name= &amp;quot;y&amp;quot;, bounds=(0, 1))&#xA;&#xA;@model.Disjunction(model.I, model.J, model.A)&#xA;def rule(model, i, j ,a):&#xA;    disjunct_A = [&#xA;        sum(model.x[i,j,a,b] for b in model.B) == 1, &#xA;        sum(model.y[u,v,a] for u in model.U for v in model.V) == 0&#xA;    ]&#xA;    disjunct_B = [sum(model.x[i,j,a,b] for b in model.B) == 0,&#xA;                  sum(model.y[u,v,a] for u in model.U for v in model.V) &amp;gt;= 1&#xA;    ]&#xA;    return [disjunct_A, disjunct_B]&#xA;&#xA;@model.Objective(sense=pyo.maximize)&#xA;def obj(model):&#xA;    return 0&#xA;&#xA;pyo.TransformationFactory('gdp.bigm').apply_to(model)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-05-15T06:45:16.380" LastActivityDate="2023-05-15T06:45:16.380" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10440" PostTypeId="2" ParentId="10437" CreationDate="2023-05-14T13:26:46.873" Score="7" Body="&lt;p&gt;@Kuifje gave a correct formulation without introducing additional variables. To answer your question about the indicator variable approach, what you proposed is not correct.&lt;/p&gt;&#xA;&lt;p&gt;To enforce &lt;span class=&quot;math-container&quot;&gt;$$\sum_b x_{i,j}^{ab} \ge 1 \implies \alpha^a,$$&lt;/span&gt;&#xA;equivalently consider its contrapositive&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lnot \alpha^a \implies \sum_b x_{i,j}^{ab} \le 0,$$&lt;/span&gt;&#xA;which you can enforce via big-M constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_b x_{i,j}^{ab} \le M_1\alpha^a.$$&lt;/span&gt;&#xA;To enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\alpha^a \implies\sum_{i,j} y_{i,j}^a \le 0,$$&lt;/span&gt;&#xA;impose big-M constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j} y_{i,j}^a \le M_2(1-\alpha^a).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can view both of these big-M constraints as aggregations of the following stronger constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{i,j}^{ab} &amp;amp;\le \alpha^a &amp;amp;&amp;amp;\text{for all $a,b,i,j$}\\&#xA;y_{u,v}^a &amp;amp;\le 1-\alpha^a &amp;amp;&amp;amp;\text{for all $a,u,v$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-05-15T12:51:54.607" LastActivityDate="2023-05-15T12:51:54.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10441" PostTypeId="2" ParentId="10437" CreationDate="2023-05-14T16:22:40.993" Score="1" Body="&lt;p&gt;Try if you want to avoid additional indicator binaries&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{ij} y_{ij}^a \le M(1-x_{ij}^{ab}) \quad \forall b,i,j,a$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$M = \vert i\times j \vert$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-05-14T16:22:40.993" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10442" PostTypeId="2" ParentId="10425" CreationDate="2023-05-14T20:45:37.420" Score="1" Body="&lt;p&gt;I'm going to make the following assumptions.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;No driver and no rider ever visits the same node twice. (It is possible to work around this assumption by adding arcs to the graph, but that makes the already large model even larger.)&lt;/li&gt;&#xA;&lt;li&gt;The &lt;span class=&quot;math-container&quot;&gt;$[a, b]$&lt;/span&gt; time windows are interpreted as &amp;quot;leave no earlier than &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, arrive no later than &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;&amp;quot;.&lt;/li&gt;&#xA;&lt;li&gt;The time for a rider to enter/exit a vehicle is negligible. (Again, this can be worked around at the cost of expanding the size of the model.)&lt;/li&gt;&#xA;&lt;li&gt;Vehicles have no capacity limits.&lt;/li&gt;&#xA;&lt;li&gt;Drivers cannot go faster than the specified time for crossing an arc (denoted &lt;span class=&quot;math-container&quot;&gt;$t_{i,j,d}$&lt;/span&gt; for the time required by driver &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; to cross arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;) but can go slower or can loiter at a node as needed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In addition to the binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,d},$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$y_{i,j,r,d}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_r,$&lt;/span&gt; let &lt;span class=&quot;math-container&quot;&gt;$A_{i,p}\ge 0$&lt;/span&gt; denote the time that a person (driver or rider) arrives at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D_{i,p}\ge 0$&lt;/span&gt; denote the time a person leaves node &lt;span class=&quot;math-container&quot;&gt;$i.$&lt;/span&gt; If the person does not arrive at or depart from node &lt;span class=&quot;math-container&quot;&gt;$i,$&lt;/span&gt; we let the solver fill in whatever value it likes (probably 0) and ignore it. Note that, in a feasible solution, &lt;span class=&quot;math-container&quot;&gt;$A_{i,p} \le b_p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D_{i,p} \le b_p.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'll skip the objective function. The constraints are as follows. (To save typing, I will assume that all summations and constraints are over those combinations of subscripts that make sense, in particular those pairs of nodes that actually are connected by arcs. Any place I use &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; means it applies to both drivers and riders.)&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Flow balance for drivers: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j}x_{i,j,d}-\sum_{j}x_{j,i,d}=\begin{cases}&#xA;1 &amp;amp; i=s_{d}\\&#xA;-1 &amp;amp; i=e_{d}\\&#xA;0 &amp;amp; \textrm{otherwise}&#xA;\end{cases}\quad\forall d, \forall i$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Flow balance for riders: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{d}\sum_{j}y_{i,j,r,d}-\sum_{d}\sum_{j}y_{j,i,r,d}=\begin{cases}&#xA;1 &amp;amp; i=s_{r}\\&#xA;-1 &amp;amp; i=e_{r}\\&#xA;0 &amp;amp; \textrm{otherwise}&#xA;\end{cases} \quad \forall r, \forall i$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Riders go where their drivers go: &lt;span class=&quot;math-container&quot;&gt;$$y_{i,j,r,d} \le x_{i,j,d} \quad \forall i,j,r,d$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;A rider is considered driven if and only if they reach their destination: &lt;span class=&quot;math-container&quot;&gt;$$z_r = \sum_d \sum_{i} y_{i,e_r,d,r} \quad \forall r$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Time windows must be respected: &lt;span class=&quot;math-container&quot;&gt;$$A_{e_p,p} \le b_p \quad \forall p$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$D_{s_p, p} \ge a_p \quad \forall p$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;You cannot leave before you arrive: &lt;span class=&quot;math-container&quot;&gt;$$D_{i,p} \ge A_{i,p} \quad \forall p, \forall i\neq s_p$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Drivers obey speed limits: &lt;span class=&quot;math-container&quot;&gt;$$A_{j,d} \ge D_{i,d} + t_{i,j,d} - (b_d + t_{i,j,d})(1-x_{i,j,d}) \quad \forall i,j,d$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Riders arrive/depart when their drivers do: &lt;span class=&quot;math-container&quot;&gt;$$A_{i,r} \ge A_{i,d} - b_d(1 - y_{j,i,r,d}) \quad \forall i,j,r,d$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$A_{i,r} \le A_{i,d} + b_r(1 - y_{j,i,r,d}) \quad \forall i,j,r,d$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$D_{i,r} \ge D_{i,d} - b_d(1 - y_{i,j,r,d}) \quad \forall i,j,r,d$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$D_{i,r} \le D_{i,d} + b_r(1 - y_{i,j,r,d}) \quad \forall i,j,r,d$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As a side note, the incorporation of arrival and departure times at nodes takes care of subtour elimination.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-05-14T20:45:37.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10443" PostTypeId="2" ParentId="7831" CreationDate="2023-05-15T07:55:58.643" Score="3" Body="&lt;p&gt;Your explanation is acceptable.&lt;/p&gt;&#xA;&lt;p&gt;I am giving this from LINEAR PROGRAMMING, 5th Ed. By Saul I Gass. Page 37.&lt;/p&gt;&#xA;&lt;p&gt;A simplex is an n-dimensional convex polyhedron having exactly n-1 vertices. The boundary of the simplex contains simplices of lower dimension which are called simplicial faces.&#xA;A simplex in zero dimension is a point; in one dimension it is  a line; in two dimensions it is a triangle; and in three dimensions it is a tetrahedron.&lt;/p&gt;&#xA;&lt;p&gt;also please check the foot note on page 76 of the same book.&lt;/p&gt;&#xA;" OwnerUserId="11825" LastActivityDate="2023-05-15T07:55:58.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10445" PostTypeId="1" CreationDate="2023-05-17T21:31:07.827" Score="4" ViewCount="164" Body="&lt;p&gt;For teaching purposes, I am looking for some nice examples of revenue management problems which are tackled with optimization techniques, ideally linear programming (including MIPs).&lt;/p&gt;&#xA;&lt;p&gt;For example, &lt;a href=&quot;https://towardsdatascience.com/optimizing-vacation-cabin-rental-revenues-730d2847a2ed&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt; on Medium is very good in my opinion : it is concise but with enough details, numerical simulations are reproducible, and the problem is solved with linear programming. Even better, the author has showed the impact of using an optimization model vs a first-come-first-served policy.  It is (partially?) based on the following reference:&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Cross, R.B. (1997). Revenue management: hard-core tactics for market domination. New York: Broadway Books, p. 276.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2024-02-14T04:13:06.603" Title="What are some good references of OR techniques applied to revenue management?" Tags="|optimization|linear-programming|reference-request|revenue|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10446" PostTypeId="1" CreationDate="2023-05-18T09:58:45.870" Score="2" ViewCount="256" Body="&lt;p&gt;In the convex optimization community, there has been a growing concern regarding the search for a reliable open-source solver (especially a quadratic programming solver) that can effectively deliver accurate results in reasonable times. This search has become quite challenging, requiring a substantial investment of time and effort.&lt;/p&gt;&#xA;&lt;p&gt;What is a reliable open-source quadratic solver?&lt;/p&gt;&#xA;" OwnerUserId="10" LastEditorUserId="491" LastEditDate="2023-05-18T12:30:23.620" LastActivityDate="2023-05-22T16:35:18.040" Title="Looking for a reliable and scalable open source quadratic solver" Tags="|solver|quadratic-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10447" PostTypeId="1" CreationDate="2023-05-18T17:50:32.677" Score="1" ViewCount="91" Body="&lt;p&gt;I am working on a large scale workforce scheduling problem with a large number of hard and soft constraints. The soft constraints are modeled as objectives with penalties for violating them. So my question is regarding choosing the penalty weights. Is there a way we can come up with an optimal set of weights for those objectives (solving it as a multiobjective problem is not an option yet). Right now, the weights are chosen randomly and they range between 0.01 to 1000 and it feels like they are too random.&lt;/p&gt;&#xA;" OwnerUserId="11848" LastEditorUserId="500" LastEditDate="2023-05-18T17:56:37.987" LastActivityDate="2023-05-18T17:59:33.523" Title="Workforce scheduling MIP formulation" Tags="|mixed-integer-programming|modeling|combinatorial-optimization|scheduling|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10448" PostTypeId="2" ParentId="10447" CreationDate="2023-05-18T17:59:33.523" Score="1" Body="&lt;p&gt;There is no &amp;quot;optimal&amp;quot; way to weight competing objectives. In some cases, you can ask the decision maker for tradeoffs -- &amp;quot;How much delay would you be willing to incur on this in order to save \$100 on that?&amp;quot; -- and use it to infer weights. That can get difficult when the things being traded are not directly comparable (say, cost v. &amp;quot;fairness&amp;quot;), and it also presumes that tradeoffs are constant regardless of magnitude (if it's worth \$100 to cut my work day from 15 hours to 14 hours then it's worth \$100 to cut it from 6 hours to 5 hours).&lt;/p&gt;&#xA;&lt;p&gt;If you are willing to solve the problem multiple times, you can pick some weights, solve, show the solution to the decision maker, ask them if they are happy and, if not, what they would be willing to sacrifice to improve something bugging them (in non-numerical terms, just &amp;quot;more of this for less of that&amp;quot;), tweak the weights accordingly, and repeat ad nauseum.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-05-18T17:59:33.523" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="10450" PostTypeId="2" ParentId="10445" CreationDate="2023-05-18T21:45:08.180" Score="1" Body="&lt;p&gt;For RM using optimization you'd find academic references on:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Newsvendor model - optimizing purchase often with stochastic 2 stage demand and may include penalty for underselling &amp;amp; storage costs.\&lt;/li&gt;&#xA;&lt;li&gt;Optimal bidding strategy - determining the best price with winning probability P% against a competitor with uniform pricing distribution between &lt;span class=&quot;math-container&quot;&gt;$[l,u]$&lt;/span&gt; where the bid will go to the lower bidder\&lt;/li&gt;&#xA;&lt;li&gt;Airlines revenue models - optimize oversale of tickets per segment in a market with binomial distribution of no-shows so that penalty for overbooking is kept at minimum. Gurobi has a solved example in their Examples site.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;References:&lt;br /&gt;&#xA;Below are some from Gurobi &amp;amp; Lindo/Lingo Tutorials (never understood why Lingo not that used in the industry, may be benchmarked performance of the solver LindoGlobal isn't great even though GAMS uses it or it's Python support that isn't easy to use. Also google search will lead to more academic papers &amp;amp; examples. But above the examples from Gurobi/Lindo may cover most of the examples&lt;br /&gt;&#xA;For the pricing/bidding one I had found this example in a Duke university graduate class long time back &amp;amp; had downloaded the free example. But not finding it now. So found a homework example, very similar. It's example of unconstrained optimization but also belongs to bidding/auction/Nash equilibrium domain.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/jupyter_models/yield-management/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Airlines yield management&lt;/a&gt;/ &lt;a href=&quot;https://www.lindo.com/cgi-bin/libraryf.cgi?name;OVERBOOK.lng&quot; rel=&quot;nofollow noreferrer&quot;&gt;Overbooking&lt;/a&gt; / &lt;a href=&quot;https://www.gurobi.com/jupyter_models/airline-planning-after-flight-disruption/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Revenue Management&lt;/a&gt;&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.lindo.com/lsmodels/Controller/doSelect.php?action=4&amp;amp;kwid=234&quot; rel=&quot;nofollow noreferrer&quot;&gt;Newsvendor&lt;/a&gt;/&lt;a href=&quot;https://www.lindo.com/lsmodels/Controller/doSelect.php?action=4&amp;amp;kwid=234&quot; rel=&quot;nofollow noreferrer&quot;&gt;Newsboy&lt;/a&gt; model&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.gurobi.com/jupyter_models/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi&lt;/a&gt; Additional models (capacity allocation, demand forecast)&lt;br /&gt;&#xA;&lt;a href=&quot;https://homework.study.com/explanation/suppose-we-are-interested-in-bidding-on-a-piece-of-land-and-we-know-one-other-bidder-is-interested-the-seller-announced-that-the-highest-bid-in-excess-of-10-000-will-be-accepted-assume-that-the-competitor-s-bid-x-is-a-random-variable-that-is-uniformly.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pricing&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-05-20T02:01:36.883" LastActivityDate="2023-05-20T02:01:36.883" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10451" PostTypeId="1" CreationDate="2023-05-18T23:34:34.853" Score="1" ViewCount="84" Body="&lt;p&gt;Assume we have 50 variables that we want to split into 3 groups and each group should have at least 5 variables. How to formulate that all variables in the same group take the same values? I used the binary variable y to assign the variable to each group.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max \sum_i Q_i C_i $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Q_i \in \lbrace 0, 1, ... 20 \rbrace&#xA;\quad \forall i = 1, ... 50 $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i y_{i1} \ge 5$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i y_{i2} \ge 5$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i y_{i3} \ge 5$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{i1}, y_{i2}, y_{i3} \in \lbrace 0, 1 \rbrace&#xA;\quad \forall i=1, ..., 50$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{i1} + y_{i2} + y_{i3} = 1&#xA;\quad \forall i=1, ..., 50$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;" OwnerUserId="11850" LastEditorUserId="11118" LastEditDate="2023-05-20T23:33:20.153" LastActivityDate="2023-05-22T14:03:05.323" Title="Grouping variables to take same value" Tags="|constraint|binary-variable|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10452" PostTypeId="1" CreationDate="2023-05-19T09:00:04.143" Score="0" ViewCount="96" Body="&lt;p&gt;I am solving an optimization problem, where I want to minimize the objective function&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Z = \sum_q \left(D_q \text{fare}_q - \sum_{p \ne q} \Delta D^p_q \text{fare}_q \right) (1-Z_q)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Each &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; is an optional flight which the solver should decide whether to operate or not depending on some constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Z_q$&lt;/span&gt; is a Boolean decision variable which has the following constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Z_q = 0$&lt;/span&gt; if flight &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; is cancelled.&#xA;&lt;span class=&quot;math-container&quot;&gt;$Z_q = 1$&lt;/span&gt; if flight &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; is operated.&#xA;The expression &lt;span class=&quot;math-container&quot;&gt;$$D_q \text{fare}_q - \sum_{p \ne q} \Delta D^p_q \text{fare}_q$$&lt;/span&gt;&#xA;represents a revenue loss, which should only occur when the flight &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; is cancelled (&lt;span class=&quot;math-container&quot;&gt;$Z_q = 0$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;I am solving the problem using Matlab, and the question is how to practically implement this part in the objective function.&lt;/p&gt;&#xA;&lt;p&gt;My first idea is to neglect the 1 in &lt;span class=&quot;math-container&quot;&gt;$(1-Z_q)$&lt;/span&gt;, and then my objective function becomes the following:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-\sum_q \left(D_q \text{fare}_q - \sum_{p \ne q} \Delta D^p_q \text{fare}_q \right)(Z_q)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;then re-add the neglected on the result of the objective function, or this solution will mess up the concept of the revenue loss&lt;/p&gt;&#xA;&lt;p&gt;My 2nd idea is to add another decision variable and add constraints to ensure it to be equal 1&#xA;for example my objective function will be the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_q\left(D_q \text{fare}_q - \sum_{p \ne q} \Delta D^p_q \text{fare}_q \right)(V_q-Z_q)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then I should add the following constraint &lt;span class=&quot;math-container&quot;&gt;$V_q = 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that this solution will have a great effect on the solving time&lt;/p&gt;&#xA;" OwnerUserId="11854" LastEditorUserId="500" LastEditDate="2023-05-20T12:42:23.477" LastActivityDate="2023-05-20T12:42:23.477" Title="Mixed Integer Programming - How to model a term in objective function with a constant multiplied by (1-Decision Variable)" Tags="|optimization|mixed-integer-programming|linear-programming|modeling|matlab|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10453" PostTypeId="2" ParentId="10452" CreationDate="2023-05-19T12:58:32.223" Score="1" Body="&lt;p&gt;You want to optimize an (affine) objective function of the form &lt;span class=&quot;math-container&quot;&gt;$\sum_j c_j x_j + k$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; are constants and &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; is a decision variable.&lt;/p&gt;&#xA;&lt;p&gt;If your solver requires that the “objective constant” or “offset” &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, a simple workaround is to omit &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and add it back in after the solver call, as you described in your first idea. This transformation preserves the set of optimal solutions.&lt;/p&gt;&#xA;&lt;p&gt;Your second idea is also valid but makes the problem artificially larger. I would not expect much performance difference between the two approaches because a presolver would immediately eliminate the “fixed” variable &lt;span class=&quot;math-container&quot;&gt;$V_q$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-05-19T13:07:03.140" LastActivityDate="2023-05-19T13:07:03.140" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10454" PostTypeId="1" CreationDate="2023-05-20T12:47:48.750" Score="0" ViewCount="114" Body="&lt;p&gt;I was trying to search for different types of problems in OR and couldn't find a exhaustive list of problems.  So far I have,&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Travelling salesman problem&lt;/li&gt;&#xA;&lt;li&gt;Cutting Stock problem&lt;/li&gt;&#xA;&lt;li&gt;Shortest path problem&lt;/li&gt;&#xA;&lt;li&gt;Knapsack problem&lt;/li&gt;&#xA;&lt;li&gt;Coloring problem&lt;/li&gt;&#xA;&lt;li&gt;News vendor problem&lt;/li&gt;&#xA;&lt;li&gt;Assignment problem&lt;/li&gt;&#xA;&lt;li&gt;Scheduling problem&lt;/li&gt;&#xA;&lt;li&gt;Facility location problem&lt;/li&gt;&#xA;&lt;li&gt;Demand supply / Production planning problem&lt;/li&gt;&#xA;&lt;li&gt;Diet problem&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I am obviously forgetting a lot of them. Can you add and extend the list?&lt;/p&gt;&#xA;" OwnerUserId="10062" LastActivityDate="2023-05-22T08:10:35.137" Title="Is there a comprehensive list of problems in OR?" Tags="|optimization|modeling|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10455" PostTypeId="2" ParentId="10454" CreationDate="2023-05-20T14:51:47.713" Score="1" Body="&lt;ol start=&quot;12&quot;&gt;&#xA;&lt;li&gt;Loss function optimization (basis of ML)&lt;/li&gt;&#xA;&lt;li&gt;Reinforcement learning / Dynamic programming&lt;/li&gt;&#xA;&lt;li&gt;Policy/Value optimization&lt;/li&gt;&#xA;&lt;li&gt;Vehicle routing problem &amp;amp; it's variants (Chinese postman etc.)&lt;/li&gt;&#xA;&lt;li&gt;Stochastic &amp;amp; Robust optimization&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-05-20T15:44:15.530" LastActivityDate="2023-05-20T15:44:15.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10456" PostTypeId="2" ParentId="10451" CreationDate="2023-05-20T23:47:10.693" Score="1" Body="&lt;p&gt;You want to enforce &lt;span class=&quot;math-container&quot;&gt;$y_{ik}=y_{jk}\implies Q_i=Q_j$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i\neq j$&lt;/span&gt; and all &lt;span class=&quot;math-container&quot;&gt;$k=1,2,3.$&lt;/span&gt; Given the domain of &lt;span class=&quot;math-container&quot;&gt;$Q,$&lt;/span&gt; the most any two &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; variables can differ by is 20, so you can do this with the following two constraints for all &lt;span class=&quot;math-container&quot;&gt;$i,j,k$&lt;/span&gt; combinations: &lt;span class=&quot;math-container&quot;&gt;$$Q_i - Q_j \le 20(2 - y_{ik} - y_{jk})$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$Q_j - Q_i \le 20(2 - y_{ik} - y_{jk}).$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-05-20T23:47:10.693" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10457" PostTypeId="1" AcceptedAnswerId="10484" CreationDate="2023-05-21T07:23:16.133" Score="1" ViewCount="207" Body="&lt;p&gt;In the context of column generation, specifically, price and branch or delayed column generation like Gilmore-Gomory (GG-CG) procedure, it needs to define an initial feasible solution as a trigger of the optimization process on the master problem. It seems the solving process procedure highly depended on the quality of the provided initial solution. As an example, suppose in a scheduling problem that was solved by (GG-CG) when the initial solution sets as a worse case, the number of iterations of the algorithm increases very much, and also the quality of the final solution may not be good enough. While if we set an optimal or near-optimal solution, to test the algorithm execution, it was solved with a few number of iterations in contrast to the previous one and already proved the optimal solution. My main questions are:&lt;/p&gt;&#xA;&lt;p&gt;• &lt;strong&gt;Has the provided initial solution had an impact on the solving process?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;• &lt;strong&gt;May it be possible that the algorithm destroys a good initial solution?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-05-27T18:21:33.890" Title="Quality of the defined initial solution in column generation" Tags="|mixed-integer-programming|column-generation|feasible-points|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10458" PostTypeId="1" CreationDate="2023-05-21T19:26:41.330" Score="4" ViewCount="277" Body="&lt;p&gt;A while back, I &lt;a href=&quot;https://or.stackexchange.com/q/5489&quot;&gt;read on this forum&lt;/a&gt; that Octeract is free for academic use and that for commercial use it is also free but users are restricted to 1 core. I cannot find anything on the &lt;a href=&quot;https://octeract.gg&quot; rel=&quot;nofollow noreferrer&quot;&gt;website&lt;/a&gt; to download or install this solver. Is this solver still available for free?&lt;/p&gt;&#xA;" OwnerUserId="9989" LastEditorUserId="8" LastEditDate="2023-05-21T21:12:12.563" LastActivityDate="2023-05-22T13:26:25.597" Title="On the global optimization solver Octeract" Tags="|solver|global-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10460" PostTypeId="2" ParentId="10454" CreationDate="2023-05-22T08:10:35.137" Score="0" Body="&lt;ol start=&quot;17&quot;&gt;&#xA;&lt;li&gt;Timetabling optimization problem&lt;/li&gt;&#xA;&lt;li&gt;Transportation/Transbording problem&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2023-05-22T08:10:35.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10461" PostTypeId="2" ParentId="10458" CreationDate="2023-05-22T13:26:25.597" Score="5" Body="&lt;p&gt;Thanks for your interest. We discontinued the free version in 2022 due to various reasons, and the solver has been a paid product for all audiences ever since.&lt;/p&gt;&#xA;&lt;p&gt;Our Neural service is free, but it's limited to 1MB/file for non-enterprise users due to compute costs. Note that, for the same reason, the free Neural model is our Neural Feasibility model. This means that it will instantly produce a feasible point, but does not do global (or local) optimisation.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2023-05-22T13:26:25.597" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10462" PostTypeId="1" CreationDate="2023-05-22T13:40:45.037" Score="1" ViewCount="152" Body="&lt;p&gt;I am currently working on a large workforce/manpower planning model for an aviation company. This model should decide whether to hire a new pilot or to let pilots fly overtime.&#xA;It has two skillsets. Copilots and Captains. Captains can only be hired from the copilots.&lt;/p&gt;&#xA;&lt;p&gt;Each Skillset contains 24 salary steps. Each step will earn more money than the previous step. Each Pilot will jump one step after one year so the pilots in the highest steps will be there the longest and will hence upgrade first from copilot to captain. If the model decides I will need a captain this month.&lt;/p&gt;&#xA;&lt;p&gt;All the copilots from step 17 onward will be upgraded to the captains side but will be integrated in step 7 of the captains side. Step 16 will be integrated into step 6 and so forth until step 11 to 1 which will be upgraded to step 1 on the captains side. Also, the model should be forced to take the copilot of the highest step first.&#xA;There are following sets in the model&#xA;s E Skills {&amp;quot;co&amp;quot;,&amp;quot;cpt&amp;quot;}&#xA;t E Month {Ranging from 1 to 12}&#xA;i E Salary Steps{Ranging from 1 to 24}&lt;/p&gt;&#xA;&lt;p&gt;I use following decision variables for the Balance constraint&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$W_{s,t,i}  = Workforce$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_{s,t,i} =$&lt;/span&gt; hiring of a copilot or captain&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u_{t,i} = $&lt;/span&gt; upgraded Pilots at month t from step i&lt;/p&gt;&#xA;&lt;p&gt;I have following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_{cpt,t,7} = u_{t,18} + u_{t,17} $&lt;/span&gt; this has to hold for all t&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_{cpt,t,6} = u_{t,16} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_{cpt,t,5} = u_{t,15} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_{cpt,t,4} = u_{t,14} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_{cpt,t,3} = u_{t,13} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_{cpt,t,2} = u_{t,12} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_{cpt,t,1} = u_{t,i} $&lt;/span&gt; this has to hold for i &amp;lt;= 11&lt;/p&gt;&#xA;&lt;p&gt;Furthermore the balance constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$w_{co,t,i} = w_{co,t-1,i} - u_{t,i} + h_{co,t,i}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$w_{cpt,t,i} = w_{cpt,t-1,i} + h_{cpt,t,i}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_{co,t,i} = 0 $&lt;/span&gt; for all i &amp;gt; 1&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_{cpt,t,i} = 0 $&lt;/span&gt; for all i &amp;gt; 7&lt;/p&gt;&#xA;&lt;p&gt;Right now my model will take the pilots out of step 11 of the copilot skill and put it in the correct step of the captains side. Then it will use the copilots out of step 12 and put them in the right step of the captain salary scale. I want it that it should use first the copilots from step 18 and work the other way around. Disregard step 18 to 24 of the copilot salary scale the workforce will always be 0 in these steps. They are included because the captains salary scale has more steps.&lt;/p&gt;&#xA;" OwnerUserId="11866" LastEditorUserId="11866" LastEditDate="2023-05-22T16:34:42.503" LastActivityDate="2024-02-19T22:05:40.707" Title="Conditional Statements in an LP model" Tags="|linear-programming|gurobi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10463" PostTypeId="2" ParentId="10446" CreationDate="2023-05-22T13:42:16.270" Score="5" Body="&lt;p&gt;I'll take the bullet and give you the honest answer, there aren't any.&lt;/p&gt;&#xA;&lt;p&gt;That's not to say that we don't have perfectly fine free solvers, it's just that if our frame of reference about &amp;quot;reliable&amp;quot;, &amp;quot;scalable&amp;quot;, or performant, is the very best stuff out there, the best stuff is always commercial and it is many times better than any free alternative, especially on non-library problems.&lt;/p&gt;&#xA;&lt;p&gt;This often comes as a surprise for people unfamiliar with the field, but it takes hundreds of thousands of hours of development to write a solver that performs well, which is time open-source developers don't really have (since they can't get funding for it).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastEditorUserId="1228" LastEditDate="2023-05-22T16:35:18.040" LastActivityDate="2023-05-22T16:35:18.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10464" PostTypeId="2" ParentId="10451" CreationDate="2023-05-22T14:03:05.323" Score="1" Body="&lt;p&gt;This problem is trivial and &lt;span class=&quot;math-container&quot;&gt;$Q_i = 20 \, \forall i$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$C_i \ge 0 \, \forall i$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; may be negative, then keep your &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; binary assignment variables, add three group value variables &lt;span class=&quot;math-container&quot;&gt;$G_j$&lt;/span&gt;, and only enforce that the group value variables are constrained to integers - the original &lt;span class=&quot;math-container&quot;&gt;$Q_{i}$&lt;/span&gt; are easier solved as bounded continuous. Then add constraints like the following:&lt;/p&gt;&#xA;&lt;p&gt;Error: &lt;span class=&quot;math-container&quot;&gt;$$\epsilon_{ij} := Q_i - G_j $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Tolerance: &lt;span class=&quot;math-container&quot;&gt;$$\tau_{ij} := 20 \left( 1 - y_{ij} \right) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\epsilon_{ij} \le \tau_{ij}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-\epsilon_{ij} \le \tau_{ij}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import pulp&#xA;from numpy.random import default_rng&#xA;&#xA;&#xA;n = 50&#xA;m = 3&#xA;group_bound = 5&#xA;Qbound = 20&#xA;rand = default_rng(seed=399)&#xA;C = rand.uniform(low=-1, high=1, size=n)&#xA;&#xA;Q = pulp.LpVariable.matrix(&#xA;    name='Q', indices=range(n), cat=pulp.LpContinuous, lowBound=0, upBound=Qbound)&#xA;Qgroup = pulp.LpVariable.matrix(&#xA;    name='Qgroup', indices=range(m), cat=pulp.LpInteger, lowBound=0, upBound=Qbound)&#xA;y = pulp.LpVariable.matrix(&#xA;    name='y', indices=(range(n), range(m)), cat=pulp.LpBinary)&#xA;&#xA;prob = pulp.LpProblem(name='var_grouping', sense=pulp.LpMaximize)&#xA;prob.objective = pulp.lpDot(Q, C)&#xA;&#xA;for i in range(n):&#xA;    prob.addConstraint(&#xA;        name=f'groupexcl{i}',&#xA;        constraint=pulp.lpSum(y[i]) == 1)&#xA;for j in range(m):&#xA;    prob.addConstraint(&#xA;        name=f'groupmin{j}',&#xA;        constraint=pulp.lpSum([&#xA;            y[i][j] for i in range(n)&#xA;        ]) &amp;gt;= group_bound)&#xA;&#xA;for i in range(n):&#xA;    for j in range(m):&#xA;        # if y == 0, Q == 0&#xA;        # if y == 1, Q == Qgroup&#xA;&#xA;        error = Q[i] - Qgroup[j]&#xA;        tol = Qbound*(1 - y[i][j])&#xA;        prob.addConstraint(name=f'assign_{i}_{j}_hi', constraint=error &amp;lt;= tol)&#xA;        # Only needed if C may be negative&#xA;        prob.addConstraint(name=f'assign_{i}_{j}_lo', constraint=-error &amp;lt;= tol)&#xA;&#xA;print(prob)&#xA;prob.solve()&#xA;assert prob.status == pulp.LpStatusOptimal&#xA;&#xA;print('Qgroup =')&#xA;print([int(Qgroup[j].value()) for j in range(m)])&#xA;&#xA;print('y =')&#xA;for j in range(m):&#xA;    print([int(y[i][j].value()) for i in range(n)])&#xA;print()&#xA;&#xA;print('Q =')&#xA;print([int(Q[i].value()) for i in range(n)])&#xA;print()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;var_grouping:&#xA;MAXIMIZE&#xA;0.3626220607951214*Q_0 + 0.42196536951115493*Q_1 + ...&#xA;SUBJECT TO&#xA;groupexcl0: y_0_0 + y_0_1 + y_0_2 = 1&#xA;&#xA;groupexcl1: y_1_0 + y_1_1 + y_1_2 = 1&#xA;&#xA;groupexcl2: y_2_0 + y_2_1 + y_2_2 = 1&#xA;&#xA;groupexcl3: y_3_0 + y_3_1 + y_3_2 = 1&#xA;...&#xA;&#xA;groupmin0: y_0_0 + y_10_0 + y_11_0 + y_12_0 + y_13_0 + y_14_0 + y_15_0&#xA; + y_16_0 + y_17_0 + y_18_0 + y_19_0 + y_1_0 + y_20_0 + y_21_0 + y_22_0&#xA; + y_23_0 + y_24_0 + y_25_0 + y_26_0 + y_27_0 + y_28_0 + y_29_0 + y_2_0&#xA; + y_30_0 + y_31_0 + y_32_0 + y_33_0 + y_34_0 + y_35_0 + y_36_0 + y_37_0&#xA; + y_38_0 + y_39_0 + y_3_0 + y_40_0 + y_41_0 + y_42_0 + y_43_0 + y_44_0&#xA; + y_45_0 + y_46_0 + y_47_0 + y_48_0 + y_49_0 + y_4_0 + y_5_0 + y_6_0 + y_7_0&#xA; + y_8_0 + y_9_0 &amp;gt;= 5&#xA;&#xA;groupmin1: y_0_1 + y_10_1 + y_11_1 + y_12_1 + y_13_1 + y_14_1 + y_15_1&#xA; + y_16_1 + y_17_1 + y_18_1 + y_19_1 + y_1_1 + y_20_1 + y_21_1 + y_22_1&#xA; + y_23_1 + y_24_1 + y_25_1 + y_26_1 + y_27_1 + y_28_1 + y_29_1 + y_2_1&#xA; + y_30_1 + y_31_1 + y_32_1 + y_33_1 + y_34_1 + y_35_1 + y_36_1 + y_37_1&#xA; + y_38_1 + y_39_1 + y_3_1 + y_40_1 + y_41_1 + y_42_1 + y_43_1 + y_44_1&#xA; + y_45_1 + y_46_1 + y_47_1 + y_48_1 + y_49_1 + y_4_1 + y_5_1 + y_6_1 + y_7_1&#xA; + y_8_1 + y_9_1 &amp;gt;= 5&#xA;&#xA;groupmin2: y_0_2 + y_10_2 + y_11_2 + y_12_2 + y_13_2 + y_14_2 + y_15_2&#xA; + y_16_2 + y_17_2 + y_18_2 + y_19_2 + y_1_2 + y_20_2 + y_21_2 + y_22_2&#xA; + y_23_2 + y_24_2 + y_25_2 + y_26_2 + y_27_2 + y_28_2 + y_29_2 + y_2_2&#xA; + y_30_2 + y_31_2 + y_32_2 + y_33_2 + y_34_2 + y_35_2 + y_36_2 + y_37_2&#xA; + y_38_2 + y_39_2 + y_3_2 + y_40_2 + y_41_2 + y_42_2 + y_43_2 + y_44_2&#xA; + y_45_2 + y_46_2 + y_47_2 + y_48_2 + y_49_2 + y_4_2 + y_5_2 + y_6_2 + y_7_2&#xA; + y_8_2 + y_9_2 &amp;gt;= 5&#xA;&#xA;assign_0_0_hi: Q_0 - Qgroup_0 + 20 y_0_0 &amp;lt;= 20&#xA;&#xA;assign_0_0_lo: - Q_0 + Qgroup_0 + 20 y_0_0 &amp;lt;= 20&#xA;&#xA;assign_0_1_hi: Q_0 - Qgroup_1 + 20 y_0_1 &amp;lt;= 20&#xA;&#xA;assign_0_1_lo: - Q_0 + Qgroup_1 + 20 y_0_1 &amp;lt;= 20&#xA;&#xA;assign_0_2_hi: Q_0 - Qgroup_2 + 20 y_0_2 &amp;lt;= 20&#xA;&#xA;assign_0_2_lo: - Q_0 + Qgroup_2 + 20 y_0_2 &amp;lt;= 20&#xA;&#xA;...&#xA;&#xA;VARIABLES&#xA;Q_0 &amp;lt;= 20 Continuous&#xA;Q_1 &amp;lt;= 20 Continuous&#xA;Q_10 &amp;lt;= 20 Continuous&#xA;Q_11 &amp;lt;= 20 Continuous&#xA;...&#xA;0 &amp;lt;= Qgroup_0 &amp;lt;= 20 Integer&#xA;0 &amp;lt;= Qgroup_1 &amp;lt;= 20 Integer&#xA;0 &amp;lt;= Qgroup_2 &amp;lt;= 20 Integer&#xA;0 &amp;lt;= y_0_0 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= y_0_1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= y_0_2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= y_10_0 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= y_10_1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= y_10_2 &amp;lt;= 1 Integer&#xA;...&#xA;At line 2 NAME          MODEL&#xA;At line 3 ROWS&#xA;At line 358 COLUMNS&#xA;At line 1915 RHS&#xA;At line 2269 BOUNDS&#xA;At line 2473 ENDATA&#xA;Problem MODEL has 353 rows, 203 columns and 1200 elements&#xA;Coin0008I MODEL read with 0 errors&#xA;Option for timeMode changed from cpu to elapsed&#xA;Continuous objective value is 207.128 - 0.01 seconds&#xA;Cgl0004I processed model has 353 rows, 203 columns (153 integer (150 of which binary)) and 1200 elements&#xA;Cbc0038I Initial state - 100 integers unsatisfied sum - 4.63636&#xA;Cbc0038I Pass   1: suminf.    0.00000 (0) obj. -207.128 iterations 129&#xA;Cbc0038I Solution found of -207.128&#xA;Cbc0038I Relaxing continuous gives -207.128&#xA;Cbc0038I Cleaned solution of -207.128&#xA;Cbc0038I Before mini branch and bound, 52 integers at bound fixed and 50 continuous&#xA;Cbc0038I Mini branch and bound did not improve solution (0.04 seconds)&#xA;Cbc0038I After 0.04 seconds - Feasibility pump exiting with objective of -207.128 - took 0.01 seconds&#xA;Cbc0012I Integer solution of -207.12836 found by feasibility pump after 0 iterations and 0 nodes (0.04 seconds)&#xA;Cbc0001I Search completed - best objective -207.1283647272854, took 0 iterations and 0 nodes (0.04 seconds)&#xA;Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost&#xA;Cuts at root node changed objective from -207.128 to -207.128&#xA;Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)&#xA;&#xA;Result - Optimal solution found&#xA;&#xA;Objective value:                207.12836473&#xA;Enumerated nodes:               0&#xA;Total iterations:               0&#xA;Time (CPU seconds):             0.05&#xA;Time (Wallclock seconds):       0.04&#xA;&#xA;Option for printingOptions changed from normal to all&#xA;Total time (CPU seconds):       0.06   (Wallclock seconds):       0.06&#xA;&#xA;Qgroup =&#xA;[0, 20, 20]&#xA;y =&#xA;[0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1]&#xA;[1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0]&#xA;[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]&#xA;&#xA;Q =&#xA;[20, 20, 20, 0, 20, 20, 0, 20, 20, 0, 0, 0, 20, 20, 0, 20, 20, 0, 0, 20, 0, 0, 20, 0, 20, 20, 20, 0, 20, 0, 0, 0, 0, 20, 20, 20, 0, 20, 0, 0, 0, 0, 0, 0, 20, 20, 20, 0, 0, 0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11118" LastActivityDate="2023-05-22T14:03:05.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10465" PostTypeId="1" AcceptedAnswerId="10470" CreationDate="2023-05-23T04:35:37.783" Score="2" ViewCount="175" Body="&lt;p&gt;I'm starting to learn operations research and trying to get my head around this problem that I have.&lt;/p&gt;&#xA;&lt;p&gt;Problem statement: Find the minimum number of equipment needed to run a service schedule.&lt;/p&gt;&#xA;&lt;p&gt;There are a set of machine types that need service during different times of the day for a period of 14 months (datetime data for each day of this period). Each machine requires a certain amount of different types of equipment for a set amount of time for the service.&lt;/p&gt;&#xA;&lt;p&gt;Here's an example of what I mean:&#xA;Machine MC001 requires 2 multimeters for a time period of 5 minutes from 18:35 pm to 18:55 pm on 30/09/2023 and it takes 2 minutes to move it from one service station to the next so ideally we would need a total of 2 Multimeters: From 18:35 to 18:40 for MC001 then we can add two minutes (18:42) for the equipment to move to MC002 Machine and then it can be used at MC002 from anywhere between 18:42 to 19:00&lt;/p&gt;&#xA;&lt;p&gt;I want to formulate the problem in terms of decision variables, objective function, and constraints to get the minimum number of equipment that would be required for the whole service schedule period.&lt;a href=&quot;https://i.stack.imgur.com/S3sjb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S3sjb.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11856" LastEditorUserId="11856" LastEditDate="2023-05-23T23:57:23.923" LastActivityDate="2023-05-30T12:17:21.380" Title="Find the minimum number of equipment required for a service period" Tags="|optimization|mixed-integer-programming|linear-programming|modeling|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="10467" PostTypeId="2" ParentId="10462" CreationDate="2023-05-25T05:14:58.410" Score="0" Body="&lt;p&gt;If you want to sequence upgrading copilots into captain starting from level 18, followed by 17,...12 define binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{t,i} \ \forall i \in \{12,13,...18 \}$&lt;/span&gt;&lt;br /&gt;&#xA;Then following constraints&lt;/p&gt;&#xA;&lt;p&gt;(1) &lt;span class=&quot;math-container&quot;&gt;$ z_{t,i} \le u_{t,i}\le W_{max}z_{t,i} \quad \forall t \ \ \forall i \in \{12,13,...18 \}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(2) &lt;span class=&quot;math-container&quot;&gt;$1-W_{s,t,i+1} \le z_{t,i}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(3) &lt;span class=&quot;math-container&quot;&gt;$W_{s,t,i+1} \le W_{max}(1-z_{ti})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(4) &lt;span class=&quot;math-container&quot;&gt;$ z_{t,i} \le z_{t,i+1} \quad \forall t \ \ \forall i \in \{12,13,...17 \}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$W_{max}$&lt;/span&gt; is a big-M, a big number based on the model, could be max of copilot headcount.&lt;/p&gt;&#xA;&lt;p&gt;Also, you may not need &lt;span class=&quot;math-container&quot;&gt;$z_{18}$&lt;/span&gt; if you choose to initiate/warm start &lt;span class=&quot;math-container&quot;&gt;$u_{1,18} = 1$&lt;/span&gt; and other balance constraints may take care to set &lt;span class=&quot;math-container&quot;&gt;$ u_{t,18} \ge 1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$ W_{s,t,18} \gt 0$&lt;/span&gt; since &lt;span class=&quot;math-container&quot;&gt;$ u_{t,18}$&lt;/span&gt; will remain unconstrained.&lt;br /&gt;&#xA;In that case you may need to adjust the boundary of first constraint &lt;span class=&quot;math-container&quot;&gt;$ \forall i \in \{12,...17 \}$&lt;/span&gt;.&lt;br /&gt;&#xA;It will save a variable &amp;amp; a constraint.&lt;/p&gt;&#xA;&lt;p&gt;And..&#xA;if you modify constraints (2) &amp;amp; (3) as&lt;br /&gt;&#xA;(5) &lt;span class=&quot;math-container&quot;&gt;$1-\sum_{i+1}^{18} W_{s,t,i+1} \le z_{t,i}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(6) &lt;span class=&quot;math-container&quot;&gt;$\sum_{i+1}^{18} W_{s,t,i+1} \le W_{max}(1-z_{ti}) \quad \forall i \in \{12,...17 \}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then you may skip constraint (4)&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-05-25T19:54:10.830" LastActivityDate="2023-05-25T19:54:10.830" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10468" PostTypeId="5" CreationDate="2023-05-25T12:43:24.390" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2023-05-25T12:43:24.390" LastActivityDate="2023-05-25T12:43:24.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10469" PostTypeId="4" CreationDate="2023-05-25T12:43:24.390" Score="0" Body="Questions pertaining to career paths in operations research." OwnerUserId="8" LastEditorUserId="8" LastEditDate="2023-05-25T21:54:18.927" LastActivityDate="2023-05-25T21:54:18.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10470" PostTypeId="2" ParentId="10465" CreationDate="2023-05-25T13:47:14.483" Score="1" Body="&lt;p&gt;Add decision variables for:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The actual start time of machine service within each window, continuous&lt;/li&gt;&#xA;&lt;li&gt;The actual start time of machine service for a given piece of equipment, continuous&lt;/li&gt;&#xA;&lt;li&gt;The actual duration of machine service for a given piece of equipment, continuous&lt;/li&gt;&#xA;&lt;li&gt;Binary assignment variables: for each piece of equipment, is it assigned to a given machine service window?&lt;/li&gt;&#xA;&lt;li&gt;The maximum value of the assignment variable per piece of equipment group, i.e. &amp;quot;is this piece of equipment used&amp;quot;; continuous&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If assigned, the start time and duration of the equipment service must be equal to the start time and duration of the machine&lt;/li&gt;&#xA;&lt;li&gt;The 'used' variable must be at least the value of each 'assigned' variable&lt;/li&gt;&#xA;&lt;li&gt;Each machine must have a fixed value for the amount of assigned equipment&lt;/li&gt;&#xA;&lt;li&gt;The difference between the stop time of the equipment service and the start time of the next equipment service must be at least 0, or at least the travel time if assigned&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from datetime import datetime, timedelta&#xA;&#xA;import pandas as pd&#xA;import pulp&#xA;&#xA;df = pd.DataFrame(&#xA;    index=pd.Index(name='MachineName', data=('MC001', 'MC002')),&#xA;    data={&#xA;        'ServiceTimeStart': [datetime(2023, 9, 30, 18, 35), datetime(2023, 9, 30, 18, 37)],&#xA;        # 'ServiceTimeEnd':   [datetime(2023, 9, 30, 18, 40), datetime(2023, 9, 30, 18, 45)],  # would require all 4&#xA;        'ServiceTimeEnd':   [datetime(2023, 9, 30, 18, 55), datetime(2023, 9, 30, 19,  0)],&#xA;        'EquipName':        ['Multimeter', 'Multimeter'],&#xA;        'EquipServiceTime': [timedelta(minutes=5), timedelta(minutes=7)],&#xA;        'EquipRequired':    [2, 2],&#xA;        'EquipMoveTime':    [timedelta(minutes=2), timedelta(minutes=2)],&#xA;    },&#xA;)&#xA;&#xA;first_time = df.ServiceTimeStart.min()&#xA;last_time = df.ServiceTimeEnd.max()&#xA;one_minute = timedelta(minutes=1)&#xA;max_time = (last_time - first_time)/one_minute&#xA;max_dur = df.EquipServiceTime.max()/one_minute&#xA;&#xA;'''&#xA;one piece of equipment moves from machine to machine, with a fixed move time between them.&#xA;machines have fixed windows of time in which they can receive maintenance.&#xA;equipment maintenance time is given to be smaller than or equal to machine maintenance window time.&#xA;&#xA;we assume that EquipServiceTime indicates the time for one equipment type and simultaneous use of&#xA;all instances of that piece of equipment at the same time.&#xA;'''&#xA;&#xA;prob = pulp.LpProblem(name='machine_maintenance', sense=pulp.LpMinimize)&#xA;&#xA;# in the worst case, every machine needs a dedicated equipment set;&#xA;# i.e. the amount of equipment is at most the sum of all EquipRequired&#xA;max_equip_required = df.groupby('EquipName').EquipRequired.sum()&#xA;equip_idx = max_equip_required.apply(range).explode()&#xA;equipment = pd.DataFrame({&#xA;    'EquipIdx': equip_idx,&#xA;    'EquipID': equip_idx.index + '_' + equip_idx.astype(str),&#xA;})&#xA;&#xA;&#xA;def make_machine_vars(row: pd.Series) -&amp;gt; pd.Series:&#xA;    # per machine and equipment type, we need to decide when - within&#xA;    # the maintenance window - the maintenance actually happens&#xA;    startoff = pulp.LpVariable(&#xA;        name=f'startoff_{row.name}_{row.EquipName}',&#xA;        cat=pulp.LpContinuous,&#xA;        lowBound=(&#xA;            row.ServiceTimeStart - first_time&#xA;        )/one_minute,&#xA;        upBound=(&#xA;            row.ServiceTimeEnd - first_time - row.EquipServiceTime&#xA;        )/one_minute,&#xA;    )&#xA;    return pd.Series(index=['StartOff'], data=[startoff])&#xA;&#xA;&#xA;df = pd.concat((df, df.apply(make_machine_vars, axis=1)), axis=1)&#xA;&#xA;&#xA;def make_combos(row: pd.Series):&#xA;    suffix = f'_{row.MachineName}_{row.EquipID}'&#xA;&#xA;    # is this equipment assigned to this machine service?&#xA;    assign = pulp.LpVariable(name='assign' + suffix, cat=pulp.LpBinary)&#xA;&#xA;    # the start and duration time for this equipment to service this machine&#xA;    startoff = pulp.LpVariable(&#xA;        name='startoff' + suffix, cat=pulp.LpContinuous,&#xA;        lowBound=0,&#xA;        upBound=max_time)&#xA;    duration = pulp.LpVariable(&#xA;        name='duration' + suffix, cat=pulp.LpContinuous,&#xA;        lowBound=0,&#xA;        upBound=max_dur)&#xA;&#xA;    # if assigned, then the equipment start offset and duration must equal that of the machine&#xA;    start_error = startoff - row.StartOff&#xA;    dur_error = duration - row.EquipServiceTime/one_minute&#xA;    start_tol = 2*max_time*(1 - assign)&#xA;    dur_tol = 2*max_dur*(1 - assign)&#xA;&#xA;    prob.addConstraint(name='startlo' + suffix, constraint=start_error &amp;lt;= start_tol)&#xA;    prob.addConstraint(name='starthi' + suffix, constraint=-start_error &amp;lt;= start_tol)&#xA;    prob.addConstraint(name='durlo' + suffix, constraint=dur_error &amp;lt;= dur_tol)&#xA;    prob.addConstraint(name='durhi' + suffix, constraint=-dur_error &amp;lt;= dur_tol)&#xA;&#xA;    return pd.Series(&#xA;        index=['Assign', 'EquipStartOff', 'EquipDur'],&#xA;        data=[assign, startoff, duration])&#xA;&#xA;&#xA;# per machine and equipment instance&#xA;combos = pd.merge(&#xA;    left=df.reset_index(), right=equipment,&#xA;    left_on='EquipName', right_on='EquipName')&#xA;combos = pd.concat(&#xA;    (combos, combos.apply(make_combos, axis=1)),&#xA;    axis=1,&#xA;).set_index(['MachineName', 'EquipName', 'EquipIdx'])&#xA;&#xA;&#xA;def make_used(group: pd.DataFrame) -&amp;gt; pd.Series:&#xA;    # for each equipment instance: is it used at least once?&#xA;    used = pulp.LpVariable(&#xA;        name=f'used_{group.name}',&#xA;        cat=pulp.LpContinuous,&#xA;        lowBound=0,&#xA;    )&#xA;&#xA;    # if any assign = 1, then used = 1&#xA;    for (machine_name, equip_name, equip_idx), row in group.iterrows():&#xA;        prob.addConstraint(&#xA;            name=f'usedmax_{machine_name}_{equip_name}_{equip_idx}',&#xA;            constraint=used &amp;gt;= row.Assign,&#xA;        )&#xA;&#xA;    return pd.Series(index=['Used'], data=[used])&#xA;&#xA;&#xA;# the objective is to minimize the amount of used equipment&#xA;equipment['Used'] = (&#xA;    combos.groupby('EquipID')&#xA;    .apply(make_used)&#xA;    .set_index(equipment.index)&#xA;    .Used&#xA;)&#xA;prob.objective = equipment.Used.sum()&#xA;&#xA;# for each machine service period, it has an enforced amount of equipment used&#xA;for (machine_name, equip_name), group in combos.groupby(level=['MachineName', 'EquipName']):&#xA;    prob.addConstraint(&#xA;        name=f'nequip_{machine_name}_{equip_name}',&#xA;        constraint=group.Assign.sum() == group.iloc[0,:].EquipRequired,&#xA;    )&#xA;&#xA;# For every equipment instance,&#xA;for equip_id, equip_group in combos.groupby('EquipID'):&#xA;    # For every pair of chronologically consecutive machine service periods,&#xA;    machine_groups = tuple(equip_group.groupby(level='MachineName'))&#xA;    for (machine0_name, machine0), (machine1_name, machine1) in zip(&#xA;        machine_groups[:-1],&#xA;        machine_groups[1:],&#xA;    ):&#xA;        machine0 = machine0.iloc[0, :]&#xA;        machine1 = machine1.iloc[0, :]&#xA;        suffix = f'_{machine0_name}_{machine1_name}_{equip_id}'&#xA;&#xA;        # the new start must be after the old stop, plus the move time if assigned&#xA;        slack = machine1.EquipStartOff - (machine0.EquipStartOff + machine0.EquipDur)&#xA;        min_pause = machine0.EquipMoveTime/one_minute * machine0.Assign&#xA;        prob.addConstraint(name='chrono' + suffix, constraint=slack &amp;gt;= min_pause)&#xA;&#xA;print(prob)&#xA;prob.solve()&#xA;&#xA;assert prob.status == pulp.LpStatusOptimal&#xA;&#xA;pd.set_option('display.max_columns', 500)&#xA;pd.set_option('display.width', 1000)&#xA;print(f'{prob.objective.value()} pieces of equipment used')&#xA;print()&#xA;&#xA;equipment['Used'] = equipment.Used.apply(pulp.LpVariable.value)&#xA;print(equipment)&#xA;print()&#xA;&#xA;df['StartOff'] = first_time + df.StartOff.apply(pulp.LpVariable.value)*one_minute&#xA;print(df)&#xA;print()&#xA;&#xA;combos[['StartOff', 'Assign', 'EquipStartOff', 'EquipDur']] = combos[[&#xA;    'StartOff', 'Assign', 'EquipStartOff', 'EquipDur',&#xA;]].applymap(pulp.LpVariable.value)&#xA;combos.EquipStartOff = first_time + combos.EquipStartOff*one_minute&#xA;combos.EquipDur *= one_minute&#xA;print(combos[['Assign', 'EquipStartOff', 'EquipDur']])&#xA;print()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This run is shown for the more difficult version where all four multimeters needs to be used:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;machine_maintenance:&#xA;MINIMIZE&#xA;1*used_Multimeter_0 + 1*used_Multimeter_1 + 1*used_Multimeter_2 + 1*used_Multimeter_3 + 0&#xA;SUBJECT TO&#xA;startlo_MC001_Multimeter_0: 20 assign_MC001_Multimeter_0&#xA; - startoff_MC001_Multimeter + startoff_MC001_Multimeter_0 &amp;lt;= 20&#xA;&#xA;starthi_MC001_Multimeter_0: 20 assign_MC001_Multimeter_0&#xA; + startoff_MC001_Multimeter - startoff_MC001_Multimeter_0 &amp;lt;= 20&#xA;&#xA;durlo_MC001_Multimeter_0: 14 assign_MC001_Multimeter_0&#xA; + duration_MC001_Multimeter_0 &amp;lt;= 19&#xA;&#xA;durhi_MC001_Multimeter_0: 14 assign_MC001_Multimeter_0&#xA; - duration_MC001_Multimeter_0 &amp;lt;= 9&#xA;&#xA;...&#xA;&#xA;usedmax_MC001_Multimeter_0: - assign_MC001_Multimeter_0 + used_Multimeter_0&#xA; &amp;gt;= 0&#xA;&#xA;usedmax_MC002_Multimeter_0: - assign_MC002_Multimeter_0 + used_Multimeter_0&#xA; &amp;gt;= 0&#xA;&#xA;...&#xA;&#xA;nequip_MC001_Multimeter: assign_MC001_Multimeter_0 + assign_MC001_Multimeter_1&#xA; + assign_MC001_Multimeter_2 + assign_MC001_Multimeter_3 = 2&#xA;&#xA;nequip_MC002_Multimeter: assign_MC002_Multimeter_0 + assign_MC002_Multimeter_1&#xA; + assign_MC002_Multimeter_2 + assign_MC002_Multimeter_3 = 2&#xA;&#xA;chrono_MC001_MC002_Multimeter_0: - 2 assign_MC001_Multimeter_0&#xA; - duration_MC001_Multimeter_0 - startoff_MC001_Multimeter_0&#xA; + startoff_MC002_Multimeter_0 &amp;gt;= 0&#xA;&#xA;chrono_MC001_MC002_Multimeter_1: - 2 assign_MC001_Multimeter_1&#xA; - duration_MC001_Multimeter_1 - startoff_MC001_Multimeter_1&#xA; + startoff_MC002_Multimeter_1 &amp;gt;= 0&#xA;&#xA;...&#xA;&#xA;VARIABLES&#xA;0 &amp;lt;= assign_MC001_Multimeter_0 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= assign_MC001_Multimeter_1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= assign_MC001_Multimeter_2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= assign_MC001_Multimeter_3 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= assign_MC002_Multimeter_0 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= assign_MC002_Multimeter_1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= assign_MC002_Multimeter_2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= assign_MC002_Multimeter_3 &amp;lt;= 1 Integer&#xA;duration_MC001_Multimeter_0 &amp;lt;= 7 Continuous&#xA;duration_MC001_Multimeter_1 &amp;lt;= 7 Continuous&#xA;duration_MC001_Multimeter_2 &amp;lt;= 7 Continuous&#xA;duration_MC001_Multimeter_3 &amp;lt;= 7 Continuous&#xA;duration_MC002_Multimeter_0 &amp;lt;= 7 Continuous&#xA;duration_MC002_Multimeter_1 &amp;lt;= 7 Continuous&#xA;duration_MC002_Multimeter_2 &amp;lt;= 7 Continuous&#xA;duration_MC002_Multimeter_3 &amp;lt;= 7 Continuous&#xA;startoff_MC001_Multimeter = 0 Continuous&#xA;startoff_MC001_Multimeter_0 &amp;lt;= 10 Continuous&#xA;startoff_MC001_Multimeter_1 &amp;lt;= 10 Continuous&#xA;startoff_MC001_Multimeter_2 &amp;lt;= 10 Continuous&#xA;startoff_MC001_Multimeter_3 &amp;lt;= 10 Continuous&#xA;2 &amp;lt;= startoff_MC002_Multimeter &amp;lt;= 3 Continuous&#xA;startoff_MC002_Multimeter_0 &amp;lt;= 10 Continuous&#xA;startoff_MC002_Multimeter_1 &amp;lt;= 10 Continuous&#xA;startoff_MC002_Multimeter_2 &amp;lt;= 10 Continuous&#xA;startoff_MC002_Multimeter_3 &amp;lt;= 10 Continuous&#xA;used_Multimeter_0 Continuous&#xA;used_Multimeter_1 Continuous&#xA;used_Multimeter_2 Continuous&#xA;used_Multimeter_3 Continuous&#xA;&#xA;Welcome to the CBC MILP Solver &#xA;Version: 2.10.3 &#xA;Build Date: Dec 15 2019 &#xA;&#xA;At line 2 NAME          MODEL&#xA;At line 3 ROWS&#xA;At line 51 COLUMNS&#xA;At line 192 RHS&#xA;At line 239 BOUNDS&#xA;At line 267 ENDATA&#xA;Problem MODEL has 46 rows, 30 columns and 120 elements&#xA;Coin0008I MODEL read with 0 errors&#xA;Option for timeMode changed from cpu to elapsed&#xA;Continuous objective value is 2 - 0.00 seconds&#xA;Cgl0003I 0 fixed, 0 tightened bounds, 8 strengthened rows, 0 substitutions&#xA;Cgl0003I 0 fixed, 0 tightened bounds, 8 strengthened rows, 0 substitutions&#xA;Cgl0004I processed model has 30 rows, 21 columns (8 integer (8 of which binary)) and 91 elements&#xA;Cutoff increment increased from 1e-05 to 0.9999&#xA;Cbc0038I Initial state - 8 integers unsatisfied sum - 3.60216&#xA;Cbc0038I Pass   1: suminf.    2.49432 (7) obj. 2.75284 iterations 5&#xA;Cbc0038I Pass   2: suminf.    1.61364 (4) obj. 3.19318 iterations 8&#xA;Cbc0038I Pass   3: suminf.    0.00000 (0) obj. 4 iterations 2&#xA;Cbc0038I Solution found of 4&#xA;Cbc0038I Relaxing continuous gives 4&#xA;Cbc0038I Before mini branch and bound, 0 integers at bound fixed and 1 continuous&#xA;Cbc0038I Full problem 30 rows 21 columns, reduced to 30 rows 20 columns&#xA;Cbc0038I Mini branch and bound did not improve solution (0.03 seconds)&#xA;Cbc0038I Round again with cutoff of 2.90009&#xA;Cbc0038I Pass   4: suminf.    2.49432 (7) obj. 2.75284 iterations 0&#xA;...&#xA;&#xA;Result - Optimal solution found&#xA;&#xA;Objective value:                4.00000000&#xA;Enumerated nodes:               0&#xA;Total iterations:               0&#xA;Time (CPU seconds):             0.05&#xA;Time (Wallclock seconds):       0.05&#xA;&#xA;Option for printingOptions changed from normal to all&#xA;Total time (CPU seconds):       0.06   (Wallclock seconds):       0.06&#xA;&#xA;4.0 pieces of equipment used&#xA;&#xA;           EquipIdx       EquipID  Used&#xA;EquipName                              &#xA;Multimeter        0  Multimeter_0   1.0&#xA;Multimeter        1  Multimeter_1   1.0&#xA;Multimeter        2  Multimeter_2   1.0&#xA;Multimeter        3  Multimeter_3   1.0&#xA;&#xA;               ServiceTimeStart      ServiceTimeEnd   EquipName EquipServiceTime  EquipRequired   EquipMoveTime            StartOff&#xA;MachineName                                                                                                                        &#xA;MC001       2023-09-30 18:35:00 2023-09-30 18:40:00  Multimeter  0 days 00:05:00              2 0 days 00:02:00 2023-09-30 18:35:00&#xA;MC002       2023-09-30 18:37:00 2023-09-30 18:45:00  Multimeter  0 days 00:07:00              2 0 days 00:02:00 2023-09-30 18:37:00&#xA;&#xA;                                 Assign       EquipStartOff        EquipDur&#xA;MachineName EquipName  EquipIdx                                            &#xA;MC001       Multimeter 0            1.0 2023-09-30 18:35:00 0 days 00:05:00&#xA;                       1            0.0 2023-09-30 18:35:00 0 days 00:00:00&#xA;                       2            0.0 2023-09-30 18:35:00 0 days 00:00:00&#xA;                       3            1.0 2023-09-30 18:35:00 0 days 00:05:00&#xA;MC002       Multimeter 0            0.0 2023-09-30 18:45:00 0 days 00:00:00&#xA;                       1            1.0 2023-09-30 18:37:00 0 days 00:07:00&#xA;                       2            1.0 2023-09-30 18:37:00 0 days 00:07:00&#xA;                       3            0.0 2023-09-30 18:45:00 0 days 00:00:00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You ask:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;explain the code underneath the comment &lt;code&gt;# if assigned, then the equipment start offset and duration must equal that of the machine&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This model has an offset and duration within the service window of the machine, and then a model and offset for every single equipment instance that might be assigned to that machine. If it is assigned, then the machine variables need to equal the equipment variables. This equality is enforced conditionally using a &lt;a href=&quot;https://en.wikipedia.org/wiki/Big_M_method&quot; rel=&quot;nofollow noreferrer&quot;&gt;big M constraint&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I can't make out why we need to double the max_time: 2&lt;em&gt;max_time&lt;/em&gt;(1 - assign) if there is no offset?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It's not if there's no offset; it's if there's no &lt;em&gt;assignment&lt;/em&gt;. We double the maximum time to calculate a &amp;quot;big M&amp;quot;: a coefficient sufficiently large enough that it can be guaranteed never smaller than the times with which it's compared.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;how the logic for start_error = startoff - row.StartOff works?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In this context, &lt;code&gt;startoff&lt;/code&gt; is the equipment-specific start time variable and &lt;code&gt;row.StartOff&lt;/code&gt; is the machine start time variable. This defines the difference between the two. If the equipment is assigned, that difference is forced to 0; otherwise it's left unconstrained.&lt;/p&gt;&#xA;" OwnerUserId="11118" LastEditorUserId="11118" LastEditDate="2023-05-30T12:17:21.380" LastActivityDate="2023-05-30T12:17:21.380" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="10471" PostTypeId="1" AcceptedAnswerId="10472" CreationDate="2023-05-25T14:59:03.747" Score="2" ViewCount="244" Body="&lt;p&gt;TLDR: When doing sensitivity analysis (specifically the objective coefficients), there maximum allowable increase and decrease before the solution changes is only valid when a single coefficient changes. Is there a way to generalize when multiple values change?&lt;/p&gt;&#xA;&lt;p&gt;Context:&#xA;My model (see below) is a simple minimize cost of a weighted sum subject to 2 constraints. The coefficients in my objective are not known well and vary based on some distribution. So I approximate by using the sample mean. So i sample multiple times to get the coefficients subject to some confidence interval. The more I sample, the tighter the interval but each sample is VERY VERY computationally expensive. The cardinality of i and j is at most 6, giving us a maximum of 36 variables. So, I wanted to see if there is stage where given the confidence intervals, I know that the LP solution is unlikely change with additional samples?&lt;/p&gt;&#xA;&lt;p&gt;My mind first went to sensitivity analysis but the results are only valid when a single parameter changes. But since this is a small problem, is there a way to generalize this further?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KSYGP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KSYGP.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5973" LastEditorUserId="500" LastEditDate="2023-05-25T15:29:56.500" LastActivityDate="2023-05-25T15:29:56.500" Title="LP Sensitivity Analysis with multiple simultaneous changes" Tags="|linear-programming|sensitivity-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10472" PostTypeId="2" ParentId="10471" CreationDate="2023-05-25T15:26:13.700" Score="1" Body="&lt;p&gt;For either changes to the objective or changes to the right hand side values, the sensitivity results hold for multiple changes as long as the sum of the fraction of the allowed change used by each parameter does not exceed 1. Say the maximum increase for &lt;span class=&quot;math-container&quot;&gt;$\overline{d^{(1)}}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$D_1$&lt;/span&gt; and you increase it by &lt;span class=&quot;math-container&quot;&gt;$d_1 \in [0,D_1],$&lt;/span&gt; and the maximum decrease for &lt;span class=&quot;math-container&quot;&gt;$\overline{d^{(2)}}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$D_2 &amp;gt; 0$&lt;/span&gt; and you decrease it by &lt;span class=&quot;math-container&quot;&gt;$d_2\in[0, D_2].$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$$\frac{d_1}{D_1} + \frac{d_2}{D_2} \le 1,$$&lt;/span&gt; the shadow prices/dual values remain the same. This is conservative, in the sense that if you make bigger changes the shadow prices &lt;em&gt;might&lt;/em&gt; stay the same (but very well might change). You can apply the same logic to changes to objective coefficients.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-05-25T15:26:13.700" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10473" PostTypeId="1" CreationDate="2023-05-25T17:02:52.873" Score="3" ViewCount="390" Body="&lt;p&gt;I am trying to find a constraint for the following relationship, but am failing a bit at it right now. I want to find a linear constraint that does the following. The binary variable &lt;span class=&quot;math-container&quot;&gt;$switch_{ot}$&lt;/span&gt; is to be introduced. It should always take the value 1, if the variable &lt;span class=&quot;math-container&quot;&gt;$lamp_{ot}$&lt;/span&gt; was &lt;span class=&quot;math-container&quot;&gt;$=0$&lt;/span&gt; in every of the periods &lt;span class=&quot;math-container&quot;&gt;$t-\tau$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t-1$&lt;/span&gt;. Otherwise &lt;span class=&quot;math-container&quot;&gt;$switch_{ot}=0$&lt;/span&gt; shall be valid. How do I model something like this?&lt;/p&gt;&#xA;" OwnerUserId="11887" LastEditorUserId="8" LastEditDate="2023-05-26T11:45:52.317" LastActivityDate="2023-05-26T11:45:52.317" Title="How to model a binary variable?" Tags="|modeling|integer-programming|linearization|binary-variable|logical-constraints|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10474" PostTypeId="2" ParentId="10473" CreationDate="2023-05-25T18:52:51.677" Score="3" Body="&lt;p&gt;In other words, you want to linearize this relationship:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{switch}_{ot} \iff \bigwedge_{u=t-\tau}^{t-1} \lnot \text{lamp}_{ou}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or as a product:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{switch}_{ot} = \prod_{u=t-\tau}^{t-1} (1 - \text{lamp}_{ou})$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Because &lt;span class=&quot;math-container&quot;&gt;$\text{lamp}_{ou}$&lt;/span&gt; is binary, so is its &amp;quot;complement&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$1 - \text{lamp}_{ou}$&lt;/span&gt;, and the &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;usual linearization of a product of binary variables&lt;/a&gt; yields:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{switch}_{ot} &amp;amp;\le 1 - \text{lamp}_{ou} &amp;amp;&amp;amp;\text{for $u \in \{t-\tau, \dots, t-1\}$} \tag1\label1\\&#xA;\text{switch}_{ot} &amp;amp;\ge \sum_{u=t-\tau}^{t-1} (1 - \text{lamp}_{ou}) - \tau + 1 \tag2\label2&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Of course, \eqref{2} can be simplified as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{switch}_{ot} \ge 1 - \sum_{u=t-\tau}^{t-1} \text{lamp}_{ou}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-05-25T18:52:51.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10475" PostTypeId="2" ParentId="10473" CreationDate="2023-05-25T19:12:23.300" Score="0" Body="&lt;p&gt;The answer of Rob is great. Another way to model this with fewer constraints needed is the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}1&#xA;(1- \text{switch}_{ot}) &amp;amp;\le \sum_{u=t-\tau}^{t-1} \text{lamp}_{ou} &#xA;\tag{1}\label{1A}\\&#xA;M \cdot (1- \text{switch}_{ot}) &amp;amp;\ge \sum_{u=t-\tau}^{t-1} \text{lamp}_{ou}  \tag{2} \label{2A}&#xA;\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a large enough number. In your case this might be &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt;.&#xA;If all &lt;span class=&quot;math-container&quot;&gt;$\text{lamp}_{ou}$&lt;/span&gt; variables are &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, equation \eqref{1A} makes sure that the switch variable is 1. If any &lt;span class=&quot;math-container&quot;&gt;$\text{lamp}_{ou}$&lt;/span&gt; is greater &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, \eqref{2A} states that the switch variable must be 0.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="123" LastEditDate="2023-05-25T21:48:31.530" LastActivityDate="2023-05-25T21:48:31.530" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10477" PostTypeId="2" ParentId="10457" CreationDate="2023-05-25T22:03:36.363" Score="1" Body="&lt;p&gt;The question is not clear to me, but I'll try to give an answer anyway.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Solving the linear relaxation of the Dantzig-Wolfe formulation&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;First, let's talk about the resolution of the linear relaxation of the Dantzig-Wolfe formulation using a column generation approach. The resolution provides a dual bound for the original problem.&lt;/p&gt;&#xA;&lt;p&gt;The column generation procedure requires an initial set of columns that ensures that the LP is feasible; because if the LP is infeasible, no dual values are available.&lt;/p&gt;&#xA;&lt;p&gt;The quality of the initial columns is likely to impact the number of iterations to converge. The extreme case being that an optimal solution of the linear relaxation is already in the initial set of columns and therefore, the solution of the first iteration is already optimal. In general, it is reasonable to expect less iterations if the initial columns are better.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Solving the restricted master&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;You mention &amp;quot;price-and-branch&amp;quot;. I assume that you talk about the strategy to get an integer feasible solution by solving a MILP containing only the columns which have been generated during the column generation procedure that solved the linear relaxation. This is also called &amp;quot;solving the restricted master&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;An important drawback of this approach is that no new column is generated during the process. If you consider the extreme case mentioned above where the initial columns of the column generation procedure already provide the optimal solution, then no additional column is available for the MILP, and it is likely to not find any integer solution at all. The better the initial columns are, the lesser iterations there will be, and therefore the lesser diversity there will be in the columns for the MILP. Thus, the MILP might struggle to find columns that fit well together.&lt;/p&gt;&#xA;&lt;p&gt;There exists other approaches that allow generating new columns and usually work better than solving the restricted master. See&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Sadykov R, Vanderbeck F, Pessoa A, et al (2019) Primal Heuristics for Branch and Price: The Assets of Diving Methods. INFORMS Journal on Computing 31:251–267. &lt;a href=&quot;https://doi.org/10.1287/ijoc.2018.0822&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/ijoc.2018.0822&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-05-25T22:03:36.363" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10478" PostTypeId="1" CreationDate="2023-05-26T13:49:22.067" Score="2" ViewCount="65" Body="&lt;p&gt;I am searching for a keyword that describes a machine scheduling problem in which machines are allowed to process multiple jobs at a time. Each job requires a given capacity on the machine. At any point in time, the sum of the capacity required by the jobs processed at that time must not exceed a given limit.&lt;/p&gt;&#xA;&lt;p&gt;Particularly, I am searching for MILP formulations for problems with this property. However, I only find parallel machine scheduling problems in which the processing of only one job at a time is allowed.&lt;/p&gt;&#xA;" OwnerUserId="11889" LastEditorUserId="491" LastEditDate="2023-05-26T14:01:07.980" LastActivityDate="2023-05-26T14:07:37.310" Title="Machine Scheduling with simultaneous processing of jobs" Tags="|scheduling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10479" PostTypeId="2" ParentId="10478" CreationDate="2023-05-26T14:07:37.310" Score="2" Body="&lt;p&gt;The keyword is &amp;quot;resource constrained scheduling problem&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Here is a book chapter about the classical mixed-integer programming models for the standard version of the problem:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Artigues, Christian, Oumar Koné, Pierre Lopez, et Marcel Mongeau. 2015. « Mixed-Integer Linear Programming Formulations ». In Handbook on Project Management and Scheduling Vol.1, édité par Christoph Schwindt et Jürgen Zimmermann, 17‑41. International Handbooks on Information Systems. Cham: Springer International Publishing. &lt;a href=&quot;https://doi.org/10.1007/978-3-319-05443-8_2&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1007/978-3-319-05443-8_2&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-05-26T14:07:37.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10480" PostTypeId="1" CreationDate="2023-05-26T17:35:23.007" Score="1" ViewCount="48" Body="&lt;p&gt;I have an optimization problem which goes:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;    \text{Minimize:}&#xA;    \\&#xA;    &amp;amp; \sqrt{x} + \sqrt{y} \tag{NL-objective}&#xA;    \\&#xA;    \text{Subject to:}&#xA;    \\&#xA;    &amp;amp;3x + 2y \geq 2 &amp;amp; \tag{C1}&#xA;    \\&#xA;    &amp;amp;2x + 3y \geq 2 &amp;amp; \tag{C2}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am attempting to piecewise linearize it. The idea is to approximate the non-linear function with a bunch of linear functions and solve the MILP problem. I break the function in 2 lines each, equidistant in x. For reference, the image is attached below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/S4G71.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S4G71.png&quot; alt=&quot;PWL objective&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you can see, &lt;span class=&quot;math-container&quot;&gt;$\sqrt x$&lt;/span&gt; can be written as &lt;span class=&quot;math-container&quot;&gt;$\min\{0.7071 x,0.5858 x+0.4142\}$&lt;/span&gt; in its piecewise linear form, where minimum is over the lines. Similarly we can write a minimum of linear functions for &lt;span class=&quot;math-container&quot;&gt;$\sqrt y$&lt;/span&gt;.&#xA;Generally, we write min of linear functions as MILP as given in image below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JXoiq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JXoiq.png&quot; alt=&quot;Generalization of &lt;span class=&quot;math-container&quot;&gt;$min\{f_i(x); i=1..n\}$&lt;/span&gt;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So, I get&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;    \text{Minimize:}\\&#xA;    &amp;amp;d_{1} + d_{2} \tag{Objective-PWL}\\&#xA;    \text{Subject to:}\\&#xA;    &amp;amp;3x+2y \geq 2 &amp;amp;\tag{C1} \\&#xA;    &amp;amp;2x+3y \geq 2 &amp;amp;\tag{C2} \\&#xA;    &amp;amp;y_{11} = \sqrt 2 x_{11} &amp;amp;\tag{first line, x} \\&#xA;    &amp;amp;y_{12} = 0.5858 x_{12}+0.4142 &amp;amp;\tag{second line, x} \\&#xA;    &amp;amp;y_{21} = \sqrt 2 x_{21} &amp;amp;\tag{first line, y} \\&#xA;    &amp;amp;y_{22} = 0.5858 x_{22}+0.4142 &amp;amp;\tag{second line, y} \\&#xA;    &amp;amp;0 \leq y_{11}, y_{21} \leq 0.7071 &amp;amp;\tag{1.i} \\&#xA;    &amp;amp;0.7071 \leq y_{21}, y_{22} \leq 1 &amp;amp;\tag{1.i} \\&#xA;    &amp;amp;d_{1} \leq y_{11}, y_{12} &amp;amp;\tag{2.i} \\&#xA;    &amp;amp;d_{2} \leq y_{21}, y_{22} &amp;amp;\tag{2.i} \\&#xA;    &amp;amp;d_{1} \geq y_{11} - 0.7071(1 - z_{11}) &amp;amp;\tag{3.i} \\&#xA;    &amp;amp;d_{1} \geq y_{12} - (1 - z_{12}) &amp;amp;\tag{3.i} \\&#xA;    &amp;amp;d_{2} \geq y_{21} - 0.7071(1 - z_{21}) &amp;amp;\tag{3.i} \\&#xA;    &amp;amp;d_{2} \geq y_{22} - (1 - z_{22}) &amp;amp;\tag{3.i} \\&#xA;    &amp;amp;z_{11}+z_{21}=1 &amp;amp;\tag{4.i} \\&#xA;    &amp;amp;z_{21}+z_{22}=1 &amp;amp;\tag{4.i} \\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, there seems to be an issue with this formulation because there is no co-relation between &lt;span class=&quot;math-container&quot;&gt;$x, x_{11}, x_{12}$&lt;/span&gt;&#xA;What I think I have done is basically replaced the &lt;span class=&quot;math-container&quot;&gt;$\sqrt x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sqrt y$&lt;/span&gt; with a bunch of lines, and converted the linear functions as &lt;span class=&quot;math-container&quot;&gt;$\min (f_1(x), f_2(x))$&lt;/span&gt; and reformulated the min part as MILP. I do not know how to incorporate other constraints. Can someone help me figure out the correct formulation?&lt;/p&gt;&#xA;" OwnerUserId="11867" LastEditorUserId="491" LastEditDate="2023-05-26T19:15:07.253" LastActivityDate="2023-05-26T19:15:07.253" Title="$\min\{f(x_1),\dots,f(x_n)\}$ with other constraints" Tags="|optimization|mixed-integer-programming|nonlinear-programming|linearization|nonconvex-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10481" PostTypeId="2" ParentId="10480" CreationDate="2023-05-26T18:05:15.890" Score="2" Body="&lt;p&gt;Your model contains a lot more items than are needed. Assume that &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a sufficiently large positive parameter. I'll add two binary variables &lt;span class=&quot;math-container&quot;&gt;$z_x$&lt;/span&gt; (used to linearize &lt;span class=&quot;math-container&quot;&gt;$\sqrt{x}$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$z_y$&lt;/span&gt; (used to linearize &lt;span class=&quot;math-container&quot;&gt;$\sqrt{y}$&lt;/span&gt;), and change your &lt;span class=&quot;math-container&quot;&gt;$d_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_2$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$d_x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_y$&lt;/span&gt; just for clarity, resulting in the following model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;    \text{Minimize:}\\&#xA;    &amp;amp;d_{x} + d_{y} \\&#xA;    \text{Subject to:}\\&#xA;    &amp;amp;3x+2y \ge 2 &amp;amp; \\&#xA;    &amp;amp;2x+3y \ge 2 &amp;amp; \\&#xA;    &amp;amp;d_x \ge \sqrt 2 \cdot x - M(1 - z_x)&amp;amp; \\&#xA;    &amp;amp;d_x \ge 0.5858 x + 0.4142 -M z_x &amp;amp; \\&#xA;    &amp;amp;d_y \ge \sqrt 2 \cdot y - M(1 - z_y)&amp;amp; \\&#xA;    &amp;amp;d_y \ge 0.5858 y + 0.4142 -M z_y &amp;amp; \\&#xA;    &amp;amp;z_x, z_y \in \lbrace 0, 1 \rbrace &amp;amp;\\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;A key here is that you are minimizing the sum of the surrogate (&lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;) variables, meaning you don't have to worry about their being too large. You just have to make sure they are not too small.&lt;/p&gt;&#xA;&lt;p&gt;If you use more than two linear segments in approximating the square root function, you need additional binary variables and an SOS1 constraint for each set of binaries.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-05-26T18:05:15.890" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10482" PostTypeId="1" CreationDate="2023-05-26T19:50:31.973" Score="3" ViewCount="148" Body="&lt;p&gt;I am trying to solve the following problem. Suppose &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$m \times n$&lt;/span&gt; matrix of integers with entries in &lt;span class=&quot;math-container&quot;&gt;$\{1, \dots, k\}$&lt;/span&gt;. There are two kinds of constraints on the entries of this matrix:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For each integer, there are constraints on the number of times that integer can appear in each row and column. The integer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; must appear in each column no fewer than &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; and no more than &lt;span class=&quot;math-container&quot;&gt;$C_i$&lt;/span&gt; times, and in each row no fewer than &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; and no more than &lt;span class=&quot;math-container&quot;&gt;$R_i$&lt;/span&gt; times.&lt;/li&gt;&#xA;&lt;li&gt;For each integer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, it must appear in each row as part of a &lt;em&gt;span&lt;/em&gt; - where that integer repeats for some length &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;. The length of the span must be between &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In my application, I have &lt;span class=&quot;math-container&quot;&gt;$m \approx 30$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$n \approx 50$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$k \approx 10$&lt;/span&gt;. I tried modeling this using Google's ortools, and can generate a matrix that satisfies the constraints on the rows and columns (first bullet point), but am having trouble with the constraints on the span lengths. I came up with a solution but it runs for hours and does not find a feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;Is there a kind of problem in the literature which is similar to this? Could anyone give some pointers about how I can try to solve this?&lt;/p&gt;&#xA;" OwnerUserId="11890" LastEditorUserId="500" LastEditDate="2023-05-27T19:31:55.107" LastActivityDate="2023-05-28T19:33:23.093" Title="Constraint programming problem with matrix of integers" Tags="|constraint-programming|or-tools|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10483" PostTypeId="2" ParentId="4605" CreationDate="2023-05-27T10:33:53.007" Score="0" Body="&lt;p&gt;I guess you are reading the example on page 185 of &lt;em&gt;Introdution of stochastic programming&lt;/em&gt; by John R. Birge. After reading the explanation above by Oguz Toragay, I would like to represent my opinion on the so-called &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In fact, &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; is generated in this way. Let&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A = \left(&#xA;\begin{array}{c}&#xA;6 &amp;amp; 10 &amp;amp; 1 &amp;amp; 0 \\&#xA;8 &amp;amp; 5  &amp;amp; 0 &amp;amp; 0 \\&#xA;1 &amp;amp; 0  &amp;amp; 0 &amp;amp; 1 \\&#xA;0 &amp;amp; 1  &amp;amp; 0 &amp;amp; 0 &#xA;\end{array}&#xA;\right)&#xA;\quad&#xA;c =\left(&#xA;\begin{array}{c}&#xA;-24 \\&#xA;-28 \\&#xA;0 \\&#xA;0 &#xA;\end{array}&#xA;\right),$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then we got &lt;span class=&quot;math-container&quot;&gt;$\pi = c^T \times A^{-1} = \left[ 0,-3,0,-13\right]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that there are four constraints in the origin problem, and with the optimal solution of the LP, constraints &lt;span class=&quot;math-container&quot;&gt;$8y_1+5y_2 \leq 1600$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2\leq100$&lt;/span&gt; are tight, and the other two constraints have redundance, which leaves space to  descend. The corresponding slack variables, namely &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_5$&lt;/span&gt;, are checked in the last step of simplex algorithm. That's why we put these two columns into matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt;, rather than the others. You can also observe that all items in &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt; are no bigger than &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; because it is the termination condition of the simplex algorithm, and also represents the (negative) shadow price. Consequently, only &lt;span class=&quot;math-container&quot;&gt;$\pi_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\pi_4$&lt;/span&gt; are negative because only the second and the fourth constraints are tight.&lt;/p&gt;&#xA;" OwnerUserId="11892" LastEditorUserId="11892" LastEditDate="2023-05-27T10:41:46.623" LastActivityDate="2023-05-27T10:41:46.623" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10484" PostTypeId="2" ParentId="10457" CreationDate="2023-05-27T18:21:33.890" Score="2" Body="&lt;p&gt;If you are asking whether columns can be added to the LP relaxation of the master that will move the LP solution away from the initial incumbent, I assume that is possible. As long as the columns for the initial incumbent remain in the relaxed master, though, when you eventually restore the integrality requirements and do a final solve of the master you should get a solution as good as if not better than the initial incumbent, because the initial incumbent remains feasible in the expanded master problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-05-27T18:21:33.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10485" PostTypeId="2" ParentId="10482" CreationDate="2023-05-27T19:04:02.360" Score="0" Body="&lt;p&gt;There is a bit of tangential similarity to cutting stock problems. One possible approach would be to define, for each integer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, the set of legal spans. So if &lt;span class=&quot;math-container&quot;&gt;$s_2=2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S_2=3,$&lt;/span&gt; the legal spans for 2 are &lt;span class=&quot;math-container&quot;&gt;$22$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$222.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Next, build the set of legal patterns for each row, where a pattern is a combination of spans that contains &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; integers and contains &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; between &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R_i$&lt;/span&gt; times for each &lt;span class=&quot;math-container&quot;&gt;$i.$&lt;/span&gt; You can start by finding all span combinations for each integer that meet the &lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$R_i$&lt;/span&gt; constraints, then find all combinations of those combinations that get all the integers and fit in a row, then look at all arrangements (permutations) of those spans.&lt;/p&gt;&#xA;&lt;p&gt;Once you have enumerated all possible row patterns, the remaining problem is to select one pattern for each row such that every column contains between &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_i$&lt;/span&gt; instances of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i.$&lt;/span&gt; Since any permutation of the rows of a feasible answer remains feasible, you might want to specify some sort of antisymmetry constraint, such as row 1, column 1 containing the integer 1.&lt;/p&gt;&#xA;&lt;p&gt;This can become computationally infeasible pretty quickly, as the number of patterns can be enormous.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-05-27T19:04:02.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10486" PostTypeId="2" ParentId="10482" CreationDate="2023-05-27T23:05:38.693" Score="2" Body="&lt;p&gt;You might try integer programming instead of constraint programming.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{uvi}$&lt;/span&gt; indicate whether entry &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt; takes value &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{uvi}$&lt;/span&gt; indicate whether entry &lt;span class=&quot;math-container&quot;&gt;$(u,v)$&lt;/span&gt; starts a span with value &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.  The constraints are&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i x_{uvi} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $u,v$} \tag1\label1\\&#xA;r_i \le \sum_v x_{uvi} &amp;amp;\le R_i &amp;amp;&amp;amp;\text{for all $u,i$} \tag2\label2\\&#xA;c_i \le \sum_u x_{uvi} &amp;amp;\le C_i &amp;amp;&amp;amp;\text{for all $v,i$} \tag3\label3\\&#xA;x_{uvi} - x_{u,v-1,i} &amp;amp;\le y_{uvi} &amp;amp;&amp;amp;\text{for all $u,v,i$} \tag4\label4\\&#xA;y_{uvi} &amp;amp;\le x_{uwi} &amp;amp;&amp;amp;\text{for all $u,v,i$ and all $w\in\{v,\dots,v+s_i-1\}$} \tag5\label5\\&#xA;\sum_{w=v}^{v+S_i} x_{uwi} &amp;amp;\le S_i &amp;amp;&amp;amp;\text{for all $u,v,i$} \tag6\label6&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} assigns exactly one value to each entry.&#xA;Constraints \eqref{2} and \eqref{3} enforce the counts of value &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in the rows and columns, respectively.&#xA;Constraint \eqref{4} enforces &lt;span class=&quot;math-container&quot;&gt;$(x_{uvi} \land \lnot x_{u,v-1,i}) \implies y_{uvi}$&lt;/span&gt;.&#xA;Constraint \eqref{5} enforces &lt;span class=&quot;math-container&quot;&gt;$y_{uvi} \implies \bigwedge_{w=v}^{v+s_i-1} x_{uwi}$&lt;/span&gt; so that each span has length at least &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt;.&#xA;Constraint \eqref{6} prevents spans of length &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;S_i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-05-27T23:05:38.693" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10487" PostTypeId="1" CreationDate="2023-05-28T06:06:30.020" Score="0" ViewCount="107" Body="&lt;p&gt;My question is this:&lt;/p&gt;&#xA;&lt;p&gt;I want to express the time it takes for multiple servers to complete tasks for multiple users. I divide the time into &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; time slots, and each task may occupy multiple time slots. Assuming that a user's task is uploaded in &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; time slot, how can I express the time slot service after &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; time slot to allocate corresponding resources for it?&#xA;How can I express the total time it takes for all users to complete their tasks?&lt;/p&gt;&#xA;" OwnerUserId="11898" LastEditorUserId="36" LastEditDate="2023-05-28T13:14:43.687" LastActivityDate="2024-02-22T19:06:45.823" Title="How to linearize the waiting time" Tags="|mixed-integer-programming|scheduling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10488" PostTypeId="1" CreationDate="2023-05-28T08:39:23.957" Score="0" ViewCount="45" Body="&lt;p&gt;My original content was like this:&lt;/p&gt;&#xA;&lt;p&gt;Assuming that server &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; can only allocate corresponding computing functions to MU &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; after receiving their tasks. Let&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ y_{i,k,t} = \begin{cases} 1 &amp;amp; \text{if MU $i$ has sent a task to server $k$ at time slot $t$} \\ 0 &amp;amp;\text{otherwise} \end{cases} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Therefore, we have&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;   y_{i,k,t} \leq s_{i, k,t},  \quad \forall i,k,t. &#xA;\end{eqnarray}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;    y_{i,k,t} \geq x_{i,k,t}, \quad \forall i,k,t.&#xA;\end{eqnarray}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;x_{i,k,t} \geq y_{i,k,t} + s_{i,k,t} - 1. \quad \forall i,k,t. \label{3_start}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{i, k, t}$&lt;/span&gt; denotes whether the user &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is transferring tasks to the server &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; at time slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i, k, t}$&lt;/span&gt; denotes whether the server &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is allocating resources to the user &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; at time slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I want to constrain the server to only start allocating resources to users after receiving their task requests. However, now I want to change this constraint to that users may need more than one time slot to send tasks. How should I change this constraint?&lt;/p&gt;&#xA;" OwnerUserId="11898" LastEditorUserId="8" LastEditDate="2023-05-28T13:11:15.310" LastActivityDate="2023-05-28T13:11:15.310" Title="How to linearize such a constraint?" Tags="|mixed-integer-programming|linearization|binary-variable|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10489" PostTypeId="1" AcceptedAnswerId="10490" CreationDate="2023-05-28T15:00:54.497" Score="0" ViewCount="98" Body="&lt;p&gt;I am trying to simulate the following quadratic integer program using &lt;span class=&quot;math-container&quot;&gt;$\textsf{cvxpy}$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \begin{array}{ll} \underset {x_1, \dots, x_K} {\text{minimize}} &amp;amp; \displaystyle\sum\limits_{i=1}^{K}\frac{y_{i}}{Y}\left(\frac{x_{i}}{y_{i}}-\frac{X}{Y}\right)^{2} \\[0.2cm] \text{subject to} &amp;amp; x_{i} \leqslant y_{i}, \quad i=1, 2, \dots, K \\ &amp;amp; \sum_{i}x_{i}=X \\ &amp;amp; x_{i}, y_{i} \in \mathbb{Z}^{+}, \quad i=1,2,\ldots,K\end{array} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{K} y_{i} = Y$&lt;/span&gt;. There is a paper by &lt;a href=&quot;https://doi.org/10.1287/ijoc.7.1.109&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bretthauer et al. (1995)&lt;/a&gt; where they address this type of problem and proposed a good algorithm to solve this. However, I chose to use &lt;span class=&quot;math-container&quot;&gt;$\textsf{cvxpy}$&lt;/span&gt; for simplified and optimized simulation.&lt;/p&gt;&#xA;&lt;p&gt;Accordingly, I wrote the following piece of code:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import numpy as np&#xA;import cvxpy as cp&#xA;&#xA;def solve_quad_int_knapsack(y, X):&#xA;&#xA;    Y = np.sum(y)&#xA;    m = X/Y&#xA;&#xA;    x = cp.Variable(len(y), integer=True)  # Integer variables x_i&#xA;&#xA;    objective =  cp.sum((y/Y) * cp.square(x/y - m))  # Objective function&#xA;    constraints = [0 &amp;lt;= x, x &amp;lt;= y, sum(x) == X]&#xA;&#xA;    problem = cp.Problem(cp.Minimize(objective), constraints)&#xA;    res = problem.solve()&#xA;&#xA;    obj = objective.value&#xA;    x_optimal = x.value&#xA;&#xA;    return obj, x_optimal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In simulating the code for &lt;span class=&quot;math-container&quot;&gt;$y=\begin{bmatrix}10&amp;amp;18&amp;amp;41 \end{bmatrix}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X=12$&lt;/span&gt;, I received the following error:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;SolverError: Either candidate conic solvers (['GLPK_MI', 'SCIPY']) do not support the cones output by the problem (SOC, NonNeg, Zero), or there are not enough constraints in the problem.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Can someone please help me understand the error that seems to be with the linear constraints?&lt;/p&gt;&#xA;" OwnerUserId="11900" LastEditorUserId="491" LastEditDate="2023-05-28T19:31:05.733" LastActivityDate="2023-05-28T19:31:05.733" Title="Simulating an integer quadratic knapsack problem" Tags="|integer-programming|quadratic-programming|cvxpy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10490" PostTypeId="2" ParentId="10489" CreationDate="2023-05-28T15:26:35.820" Score="2" Body="&lt;p&gt;The constraints are fine.&lt;/p&gt;&#xA;&lt;p&gt;Per the &lt;a href=&quot;https://www.cvxpy.org/tutorial/advanced/index.html#choosing-a-solver&quot; rel=&quot;nofollow noreferrer&quot;&gt;CVXPY &amp;quot;Choosing a solver&amp;quot;&lt;/a&gt; table, neither GLPK_MI nor SCPY support QP. You need a solver in that table having an X in both the QP and MIP columns.&lt;/p&gt;&#xA;&lt;p&gt;The error message seems unnecessarily non-specific and therefore confusing as to the actual error. But don't blame me, I am not a CVXPY developer.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-05-28T18:48:50.400" LastActivityDate="2023-05-28T18:48:50.400" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10491" PostTypeId="2" ParentId="10487" CreationDate="2023-05-28T17:29:13.913" Score="0" Body="&lt;p&gt;I am not sure how you are allocating decision variables but standard MIP will have a binary set of variables &lt;span class=&quot;math-container&quot;&gt;$ x_{j,t,s} = 1$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$ j,t,s$&lt;/span&gt; represent Task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; in process/start/occupying time slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; by a server &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;,&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_{jts}=0$&lt;/span&gt; if no tasks is assigned/in-process at time slot on the server\&lt;/p&gt;&#xA;&lt;p&gt;You may add a user &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; depending upon the model.&lt;br /&gt;&#xA;Also each of the tasks, &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; will have predefined service/processing time &lt;span class=&quot;math-container&quot;&gt;$T_j$&lt;/span&gt; which can be defined in terms of time slots&lt;br /&gt;&#xA;Then add set of constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{j,t,s} \le \sum_{k=t+1}^{T_j-1}x_{j,k,s} + Tx_{j,t-1,s}$&lt;/span&gt;: where &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is arbitrary big number like total timespan.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_t T_tx_{j,t,s} \le T_j$&lt;/span&gt;: where &lt;span class=&quot;math-container&quot;&gt;$ T_t$&lt;/span&gt; is span of time slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Total time for all users&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_j\sum_s\sum_t T_tx_{j,t,s}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If using user as well then&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_u \sum_j \sum_s \sum_t T_tx_{j,t,s,u}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-05-28T17:29:13.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10492" PostTypeId="2" ParentId="10482" CreationDate="2023-05-28T19:33:23.093" Score="0" Body="&lt;p&gt;You can reuse RobPratt@ ideas with CP-SAT.&lt;/p&gt;&#xA;&lt;p&gt;First, for each cell, you have a Boolean var array, 1 for each integer.&#xA;You then use and &lt;code&gt;AddExactlyOne(bool_variables_for_each_color)&lt;/code&gt; to constrain it.&lt;/p&gt;&#xA;&lt;p&gt;For the number of occurrence of a given color, just use &lt;code&gt;sum(bool_variables_for_one_color) == target&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now the complex constraint is a min/max sequence of one color.&#xA;Luckily, it is already implemented in the &lt;a href=&quot;https://github.com/google/or-tools/blob/5425dedcfbb22cb74c636c1374a9b5ad684b1eb5/examples/python/shift_scheduling_sat.py#L57&quot; rel=&quot;nofollow noreferrer&quot;&gt;shift_scheduling_sat.py&lt;/a&gt; example to limit the sequence of one type of shift.&lt;/p&gt;&#xA;&lt;p&gt;The code for &lt;code&gt;add_soft_sequence_constraint&lt;/code&gt; is a bit more general as it also accept soft lower and upper bounds for sequences.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-05-28T19:33:23.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10493" PostTypeId="1" CreationDate="2023-05-28T22:40:19.017" Score="0" ViewCount="136" Body="&lt;p&gt;I am reading up a bit on Linear Programming and have taken a lot from &lt;a href=&quot;https://link.springer.com/article/10.1023/A:1019009928005&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Scheduling Emergency Room Physicians&amp;quot;&lt;/a&gt; (by Michael W. Carter &amp;amp; Sophie D. LaPierre, Health Care Management Science 4, 347–360 (2001)) for this.&lt;/p&gt;&#xA;&lt;p&gt;I have a question regarding constraint (3.2.2) from page 350. This constraint prevents understaffing and overstaffing. It goes as following:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{k=1}^{K}x_{ijk}=c_{ij}~\forall I,J$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It indicates wether worker &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; works shift &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Introducing overstaffing could easily be done by changing the equality to &lt;span class=&quot;math-container&quot;&gt;$\ge c_{ij}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My question is, how do I change the constraint so that I can still allow for understaffing? Of course, the constraint should prevent that every shift is understaffed (&lt;span class=&quot;math-container&quot;&gt;$\sum_{k\in K}^{}x_{ijk}=0$&lt;/span&gt;), because this would logically minimize the costs.&lt;/p&gt;&#xA;&lt;p&gt;I'm interested in how to introduce some understaffing, for example, that a physician can be admitted less than necessary, sort of as a lower minimum?&lt;/p&gt;&#xA;" OwnerUserId="11887" LastEditorUserId="11887" LastEditDate="2023-05-29T04:50:52.280" LastActivityDate="2024-01-25T19:04:30.513" Title="Linear Programming - Model understaffing" Tags="|linear-programming|scheduling|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10494" PostTypeId="2" ParentId="10493" CreationDate="2023-05-29T05:05:43.837" Score="0" Body="&lt;p&gt;You can choose multiple varied ways but I'd go with something like the min of daily requirement (across all shifts) as the floor for total manpower needed for the day&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \min \{c_{i,j}: \ \forall i \} \le \sum_k \sum_i x_{ijk} \quad \forall j$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-05-29T05:05:43.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10495" PostTypeId="2" ParentId="10493" CreationDate="2023-05-29T06:45:36.267" Score="0" Body="&lt;p&gt;You could add (positive) slack variables &lt;span class=&quot;math-container&quot;&gt;$o_{ij}$&lt;/span&gt; for overstaffing and &lt;span class=&quot;math-container&quot;&gt;$u_{ij}$&lt;/span&gt; for understaffing:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_k x_{ijk}+ u_{ij}=c_{ij}+o_{ij} \quad \forall i,j&#xA;$$&lt;/span&gt;&#xA;And add the cost of overstaffing/understaffing by weighting these variables in the objective function.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2023-05-29T06:45:36.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10496" PostTypeId="1" AcceptedAnswerId="10497" CreationDate="2023-05-29T08:18:31.197" Score="4" ViewCount="402" Body="&lt;p&gt;How to solve problems like &lt;span class=&quot;math-container&quot;&gt;$\min_x f(x) \\ g(x) &amp;lt; 0 \ or \ h(x)&amp;lt;0$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;I think we can solve &lt;span class=&quot;math-container&quot;&gt;$\min_x f(x) \\ g(x) &amp;lt; 0 $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\min_x f(x) \\ h(x) &amp;lt; 0 $&lt;/span&gt;, then we compare the solutions from these problems. Is there any other way to solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="11901" LastActivityDate="2023-05-30T18:33:49.440" Title="union of constraints" Tags="|optimization|constraint|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10497" PostTypeId="2" ParentId="10496" CreationDate="2023-05-29T09:00:11.270" Score="5" Body="&lt;p&gt;The problem seems can be formulated as a &lt;a href=&quot;http://egon.cheme.cmu.edu/Papers/IMAGrossmannRuiz.pdf&quot; rel=&quot;noreferrer&quot;&gt;Generalized Disjunctive Programming&lt;/a&gt; as follows where each function you mentioned can be assumed as a disjunct of the whole set.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{split}&#xA;\min\ Z = &amp;amp;\ f(x) \\&#xA;\text{s.t.} \\&#xA;&amp;amp;\ \bigvee_{i\in D_k} \left[&#xA;    \begin{gathered}&#xA;    Y_{ik} \\&#xA;    g(x) \leq 0 \\&#xA;    h(x) \leq 0 \\&#xA;    \end{gathered}&#xA;\right] \quad k \in K\\&#xA;&amp;amp;\ \Omega(Y) = True \\&#xA;&amp;amp;\ Y \in \{True, False\}^{p}\\&#xA;\end{split}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;further you can solve the problem by introducing the axillary binary indicator variables, &lt;span class=&quot;math-container&quot;&gt;$Y_{ik}$&lt;/span&gt; to transform each disjunct to whose linear or non-linear (in)equality constraints.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-05-29T09:10:10.490" LastActivityDate="2023-05-29T09:10:10.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10498" PostTypeId="2" ParentId="10496" CreationDate="2023-05-29T20:31:14.690" Score="4" Body="&lt;p&gt;You could introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and a large enough constant &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;. You can then modify your constraints in the following linear way:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min_x f(x) \\ &#xA;g(x) &amp;lt; M \cdot y \\&#xA;h(x) &amp;lt; M \cdot (1-y)\\&#xA;y  \in \{0,1\}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; must be &lt;span class=&quot;math-container&quot;&gt;$&amp;lt;0$&lt;/span&gt; and if &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$h(x)$&lt;/span&gt; must be &lt;span class=&quot;math-container&quot;&gt;$&amp;lt;0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2023-05-29T20:31:14.690" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10500" PostTypeId="1" AcceptedAnswerId="10972" CreationDate="2023-05-30T13:31:09.040" Score="2" ViewCount="435" Body="&lt;p&gt;I want to solve a Mixed Integer problem with several constraints. Gurobi or Google OR tools solve such problems. Though I am not sure, I think they use an exact method such as branch and bound or plane cut. Whereas, OptaPlanner is a metaheuristic solver. Does it give equally good results in terms of optimality?&lt;/p&gt;&#xA;" OwnerUserId="11909" LastEditorUserId="981" LastEditDate="2023-12-22T14:43:12.680" LastActivityDate="2023-12-22T14:43:12.680" Title="Does OptaPlanner give equally good results when comparing with commercially available MIP solvers?" Tags="|optimization|mixed-integer-programming|solver|or-tools|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10501" PostTypeId="2" ParentId="10500" CreationDate="2023-05-30T14:05:18.010" Score="3" Body="&lt;p&gt;First, @&lt;a href=&quot;https://or.stackexchange.com/users/350/geoffrey-de-smet&quot;&gt;Geoffrey De Smet&lt;/a&gt;, is the creator of Optaplanner and might answer your question with more details about his tool. But, as you want to compare the exact solution, please be aware, Gurobi and OR-tools MIP solver use, in general, the branch and cut algorithm to solve a MIP problem based on the linear relaxation of the original model that can be solved optimality by Simplex or other efficient exact algorithms. However, the best way to compare is to test a provided solution by Optaplanner as a warm-start on its equivalent MIP model to examine the quality of the solution you have.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-05-30T14:05:18.010" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10502" PostTypeId="1" AcceptedAnswerId="10556" CreationDate="2023-05-30T15:53:03.910" Score="0" ViewCount="281" Body="&lt;p&gt;I am using Pyomo and I have the following lines&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;outputVariables_list = [model.param1, model.variable1]&#xA;optimal_values_list = [[pyo.value(model_item[key]) for key in model_item] for model_item in outputVariables_list] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I run it I get a warning that I don't understand:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;WARNING: DEPRECATED: Using __getitem__ to return a set value from its&#xA;    (ordered) position is deprecated.  Please use at()  (deprecated in 6.1,&#xA;    will be removed in 7.0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried the following line but this led to an error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;optimal_values_list = [[pyo.at(model_item[key]) for key in model_item] for model_item in outputVariables_list]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Further, I tried to use &lt;code&gt;pyo.value(model_item.at[key])&lt;/code&gt; and &lt;code&gt;pyo.value(model_item.at(key)&lt;/code&gt; and both lead to AttributeError: 'IndexedParam' object has no attribute 'at'.&lt;/p&gt;&#xA;&lt;p&gt;How can I use the &lt;code&gt;at()&lt;/code&gt; method recommended by Pyomo? What I don't understand is that Pyomo tells me to use &amp;quot;at&amp;quot; instead, but this not work as I get errors when using at. This is a quite confusing recommendation. Any idea how can I can integrate the at() method in my code?&lt;/p&gt;&#xA;&lt;p&gt;Here is the full list of pyomo components that I use can be seen in the following line (the name indicates if it is a parameter, variable or set): &lt;code&gt;outputVariables_list_BT2 = [model.param_helpTimeSlots_BT2, model.variable_heatGenerationCoefficient_SpaceHeating_BT2, model.variable_heatGenerationCoefficient_DHW_BT2, model.variable_help_OnlyOneStorage_BT2, model.variable_temperatureBufferStorage_BT2, model.variable_usableVolumeDHWTank_BT2,  model.variable_electricalPowerTotal_BT2, model.variable_pvGeneration_BT2, model.variable_windPowerAssigned_BT2,  model.param_heatDemand_In_W_BT2, model.param_DHWDemand_In_W_BT2, model.param_electricalDemand_In_W_BT2, model.param_pvGenerationNominal_BT2, model.param_outSideTemperature_In_C, model.param_windAssignedNominal_BT2,  model.param_COPHeatPump_SpaceHeating_BT2, model.param_COPHeatPump_DHW_BT2, model.param_electricityPrice_In_Cents, model.set_timeslots]&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: What I actually want is to store the output in a pandas dataframe by using the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    #Create pandas dataframe for displaying the results of BT2&#xA;    outputVariables_list_BT2 = [model.param_helpTimeSlots_BT2, model.variable_heatGenerationCoefficient_SpaceHeating_BT2, model.variable_heatGenerationCoefficient_DHW_BT2, model.variable_help_OnlyOneStorage_BT2, model.variable_temperatureBufferStorage_BT2, model.variable_usableVolumeDHWTank_BT2,  model.variable_electricalPowerTotal_BT2, model.variable_pvGeneration_BT2, model.variable_windPowerAssigned_BT2,  model.param_heatDemand_In_W_BT2, model.param_DHWDemand_In_W_BT2, model.param_electricalDemand_In_W_BT2, model.param_pvGenerationNominal_BT2, model.param_outSideTemperature_In_C, model.param_windAssignedNominal_BT2,  model.param_COPHeatPump_SpaceHeating_BT2, model.param_COPHeatPump_DHW_BT2, model.param_electricityPrice_In_Cents, model.set_timeslots]&#xA;    optimal_values_list_BT2 = [[pyo.value(model_item[key]) for key in model_item] for model_item in outputVariables_list_BT2]&#xA;&#xA;    results_BT2 = pd.DataFrame(optimal_values_list_BT2)&#xA;    results_BT2= results_BT2.T&#xA;    results_BT2 = results_BT2.rename(columns = {0:'timeslot', 1:'variable_heatGenerationCoefficient_SpaceHeating', 2:'variable_heatGenerationCoefficient_DHW', 3:'variable_help_OnlyOneStorage', 4:'variable_temperatureBufferStorage', 5:'variable_usableVolumeDHWTank',    6:'variable_electricalPowerTotal',  7:'variable_pvGeneration', 8:'variable_windPowerAssigned', 9:'param_heatDemand_In_W', 10:'param_DHWDemand_In_W', 11:'param_electricalDemand_In_W', 12:'param_pvGenerationNominal', 13:'param_outSideTemperature_In_C', 14:'param_windAssignedNominal', 15:'param_COPHeatPump_SpaceHeating', 16:'param_COPHeatPump_DHW',  17:'param_PriceElectricity [Cents]', 18:'set_timeslots'})&#xA;    cols = ['set_timeslots']&#xA;    results_BT2.set_index('set_timeslots', inplace=True)&#xA;    results_BT2['variable_temperatureBufferStorage'] = results_BT2['variable_temperatureBufferStorage'].round(2)&#xA;    results_BT2['variable_usableVolumeDHWTank'] = results_BT2['variable_usableVolumeDHWTank'].round(1)&#xA;    results_BT2['param_COPHeatPump_SpaceHeating'] = results_BT2['param_COPHeatPump_SpaceHeating'].round(3)&#xA;    results_BT2['param_COPHeatPump_DHW'] = results_BT2['param_COPHeatPump_DHW'].round(3)&#xA;    results_BT2['variable_heatGenerationCoefficient_SpaceHeating'] = results_BT2['variable_heatGenerationCoefficient_SpaceHeating'].round(4)&#xA;    results_BT2['variable_heatGenerationCoefficient_DHW'] = results_BT2['variable_heatGenerationCoefficient_DHW'].round(4)&#xA;    filePath_BT2 = folderPath + &amp;quot;\Combined_BT2.csv&amp;quot;&#xA;    results_BT2.to_csv(filePath_BT2, index=False,  sep =&amp;quot;;&amp;quot;) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Actually it works fine but I get this warning that however does not seem to have any effect. Still I am curious why it is popping up.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Reminder&lt;/strong&gt;: My bounty is about to expire and so far I still have not received any answer that solves the problem. Thus, I'll highly appreciate any further suggestions.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2023-06-12T09:42:35.500" LastActivityDate="2023-06-12T09:42:35.500" Title="How to use the at() method in Pyomo" Tags="|python|pyomo|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10508" PostTypeId="1" CreationDate="2023-05-31T07:27:16.200" Score="4" ViewCount="92" Body="&lt;p&gt;I am fairly new to linear programming since I came across this topic at university this semester. We mainly focus on nurse rostering. In the lecture, we created a very basic rostering model with an objective function and two constraints. Nr. 1 is the demand constraint and nr.2 is the individual working constraint. I now want to build upon this model and add a few constraints.&lt;/p&gt;&#xA;&lt;p&gt;In our model, we have two binary variables: &lt;span class=&quot;math-container&quot;&gt;$a_{its}$&lt;/span&gt; indicates if nurse &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; works the shift &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$b_{it}$&lt;/span&gt; indicates if nurse &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; works on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. The index goes from &lt;span class=&quot;math-container&quot;&gt;$i;t;s \in \{1,\dots,I;T;S\}$&lt;/span&gt;.&#xA;I now want to model the following:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A nurse must work at least &lt;span class=&quot;math-container&quot;&gt;$E_\min$&lt;/span&gt; days at a stretch. To avoid off-on-off patterns so to speak.&lt;/li&gt;&#xA;&lt;li&gt;A nurse may work a maximum of &lt;span class=&quot;math-container&quot;&gt;$E_\max$&lt;/span&gt; days at a stretch. My suggestion would be: &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=t}^{j+E_\max}b_{ij}\le E_\max~\forall i\in I, t\in \{1,\dots,|T| -E_\max\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;A break between work sequences must always be exactly 2 days.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;How do I model those linear constraints?&lt;/p&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="500" LastEditDate="2023-05-31T13:25:56.137" LastActivityDate="2023-05-31T19:01:48.560" Title="Nurse Rostering constraints - LP" Tags="|linear-programming|modeling|scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10509" PostTypeId="1" AcceptedAnswerId="10527" CreationDate="2023-05-31T07:45:22.590" Score="1" ViewCount="122" Body="&lt;p&gt;How can I express the process of converting a series of if-then constraints into a linear form?&lt;/p&gt;&#xA;&lt;p&gt;Let's assume that we have integer variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, non-negative variables &lt;span class=&quot;math-container&quot;&gt;$y_i^d$&lt;/span&gt;, and binary variables &lt;span class=&quot;math-container&quot;&gt;$\delta_{i,j}^d$&lt;/span&gt;. Additionally, we assume that N and S are natural numbers, and A and B are subsets of all links &lt;span class=&quot;math-container&quot;&gt;$(i,j) \in E$&lt;/span&gt;, where A and B represent links that do not intersect.&lt;/p&gt;&#xA;&lt;p&gt;The conditional statements:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x_i \geq N  $&lt;/span&gt; then The &lt;span class=&quot;math-container&quot;&gt;$\delta_{i,j}^d = 1  $&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$ \delta_{i,j}^d = 0$&lt;/span&gt;. but if &lt;span class=&quot;math-container&quot;&gt;$\delta_{i,j}^d = 1$&lt;/span&gt; I want to ensure that  &lt;span class=&quot;math-container&quot;&gt;$ y_i^d \leq y_j^d - S  \quad \forall (i,j) \in A$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But If &lt;span class=&quot;math-container&quot;&gt;$x_i &amp;lt; N  $&lt;/span&gt; I want to ensure that &lt;span class=&quot;math-container&quot;&gt;$\delta_{i,j}^d=0 \quad  \forall (i,j) \in A$&lt;/span&gt; but they could take value fron set&lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;. in other words,   &lt;span class=&quot;math-container&quot;&gt;$\delta_{i,j}^d =0 $&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$ \delta_{i,j}^d =1 \quad \forall (i,j)\in B $&lt;/span&gt;&#xA;And if this latter happen &lt;span class=&quot;math-container&quot;&gt;$  y_i^d \leq y_j^d - N \cdot S \quad \forall (i,j)\in B $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="11474" LastEditorUserId="11474" LastEditDate="2023-06-04T22:03:38.057" LastActivityDate="2023-06-04T22:54:18.150" Title="How to linearize a chain of if-then constraints?" Tags="|constraint|linearization|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10510" PostTypeId="2" ParentId="10509" CreationDate="2023-05-31T08:12:00.673" Score="1" Body="&lt;p&gt;If the binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta_{i,j}^d$&lt;/span&gt; is defined to linearize, Your first clause can be converted as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Iff \quad ((x_i \geq N) \implies \delta_{i,j}^d = 1)) \quad \implies ((\delta_{i,j}^d = 1) \implies y_i^d \leq y_j^d - S) $$&lt;/span&gt; is equal to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Iff \quad ((\delta_{i,j}^d = 0) \implies x_i \leq N) \quad \implies ((\delta_{i,j}^d = 1) \implies y_i^d \leq y_j^d - S) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It yields the following linear constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_{i} \leq N + M_{1}\delta_{i,j}^d \quad (1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ y_{i} - y_{j} + S\leq M_{2}(1-\delta_{i,j}^d) \quad (2)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the second clause, the procedure is the same.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-05-31T08:35:18.277" LastActivityDate="2023-05-31T08:35:18.277" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10511" PostTypeId="2" ParentId="10508" CreationDate="2023-05-31T19:01:48.560" Score="-1" Body="&lt;p&gt;Try&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ E_{min}b_{i,t-1} - \sum_{k=1}^{t-1}b_{i,k} \le E_{max}b_{i,t}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_t b_{i,t} \le E_{max}b_{i,t-1} - \sum_{k=1}^{t-1}b_{i,k}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ b_{i,t} \le 1 + b_{i,t-1} - b_{i,t-2}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and ofcourse&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ b_{i,t} \le \sum_s a_{i,s,t} \le Tb_{i,t}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-05-31T19:01:48.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10512" PostTypeId="1" CreationDate="2023-05-31T21:25:08.287" Score="5" ViewCount="552" Body="&lt;p&gt;How to translate a non-monetary objectives like satisfaction maximization, co2- reduction, puncuality, on time delivery, .... to € to compare solutions?&lt;/p&gt;&#xA;&lt;p&gt;Example:&#xA;Lets consider for example a production planning problem, where we produce end products from different quality raw materials, with different objective functions&lt;/p&gt;&#xA;&lt;p&gt;A) Maximize number of orders delivered (unit #)&lt;/p&gt;&#xA;&lt;p&gt;B) Optimize usage of low quality material (unit kg)&lt;/p&gt;&#xA;&lt;p&gt;C) Optimize CO2-Usage (unit kg)&lt;/p&gt;&#xA;&lt;p&gt;Now you want to optimize a weighted sum of these objectives. For this to make sense these need to be in the same order of range.&#xA;I would like to translate them all to €.&#xA;But this is not so straightforward.&lt;/p&gt;&#xA;&lt;p&gt;How do you come up with a logic to calculate a price per low quality material used? Or CO2 reduction?&lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="491" LastEditDate="2023-05-31T23:13:59.373" LastActivityDate="2023-06-01T14:02:39.573" Title="What are best practices for translating of non-monetary goals to € in the objective function?" Tags="|mixed-integer-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10513" PostTypeId="2" ParentId="10512" CreationDate="2023-05-31T23:56:49.407" Score="5" Body="&lt;p&gt;This is actually a complex question to answer. In practice, we encounter a lot of problems where different components are hard to quantify in terms of costs. As per example, in many vehicle routing applications, you want to: (i) minimize total driving cost, (ii) maximize on-time arrival or delivery speed, (iii) minimize carbon emissions, (iv) maximize niceness of a route. A route could be considered 'nice' if drivers have pleasant working hours, sufficient breaks, and can be home by the end of the day.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Issue 1&lt;/strong&gt;: many of these requirements are incomparable because they are expressed in different quantities&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Issue 2&lt;/strong&gt;: many of these requirements conflict. Maximizing delivery speed often drives up delivery cost and carbon (e.g. you would use an airplane to get somewhere fast but that takes more carbon than a slow freight train).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Solution 1:&lt;/strong&gt; accept that the quantities are incomparable, create a Pareto curve and let the user/customer choose his/her preferred solution. Do you prefer solution A that costs \$100 and produces 5kg of carbon, or do you prefer solution B that costs \$120 but only produces 3.5kg of carbon? One difficulty here is that the Pareto curve often contains a lot of points, so you need to preselect a subset of points to limit the choice set presented to a human.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Solution 2&lt;/strong&gt;: capture some objectives as a constraint instead of as an objective value. E.g. minimize the routing cost, subject to the constraint that no customer is visited more than X minutes late. Or express it as a chance constraint: Minimize cost, subject to the requirement that we have an on-time arrival rate of X%. The choice of X can be something sensible, or something that's market driven (e.g. if a competitor has a consistent 96% of-the-time on-time delivery, then you might want to meet or exceed this performance).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Solution 3&lt;/strong&gt;: convert objectives into dollars. This is challenging and often subjective.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For carbon, you could look at &lt;a href=&quot;https://carbonpricingdashboard.worldbank.org/what-carbon-pricing&quot; rel=&quot;noreferrer&quot;&gt;carbon pricing&lt;/a&gt; and use the cost of a carbon credit.&lt;/li&gt;&#xA;&lt;li&gt;You could use a survey/market experiment to figure out what value to attach. E.g. what it it worth to you if your parcel is delivered in 2 days instead of 5, or delivered to a nearby location instead of your home?&lt;/li&gt;&#xA;&lt;li&gt;You could use pricing mechanisms such as auctions to determine the value of a service, or the customer's willingness to pay.&lt;/li&gt;&#xA;&lt;li&gt;Use the cost-of-alternatives. A set of vehicle routes could cost \$2MM in driver fees and emit 1MMkg in carbon. An alternative set of vehicle routes could cost us  \$2.5MM but only emit 0.75MMkg carbon. In essence, to reduce the amount of carbon by 0.25MMkg you would pay $0.5MM. As an alternative, you could take the same \$0.5MM and buy electrical vehicles, thereby saving 0.3MMkg of carbon. This fictional comparison allows you to evaluate your choices without knowing the true value of carbon.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;From my experience, this is a tough subject though, in particular for many companies. Many managers have a hard time justifying more expensive solutions even though such a solution is more environmentally sustainable. As a manager, would you buy solution A that produces 2kg of carbon for 100$, or would you rather buy solution B for \$120 that produces 1.5kg carbon? How do you make this trade-off, especially if you need to justify this to shareholders... In practice the best solution is to associate a carbon price and show that solution A is actually more expensive than B if you factor in the cost of carbon...&lt;/p&gt;&#xA;" OwnerUserId="49" LastActivityDate="2023-05-31T23:56:49.407" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10514" PostTypeId="2" ParentId="10509" CreationDate="2023-06-01T03:22:38.497" Score="1" Body="&lt;p&gt;Going by @Omidi answer, constr (1) solves your problem for &lt;span class=&quot;math-container&quot;&gt;$N \lt x$&lt;/span&gt; but to achieve &lt;span class=&quot;math-container&quot;&gt;$\delta =1 $&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$ x=N$&lt;/span&gt; you can try\&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$N - M\alpha - M\delta \le x \le N + M\delta - \epsilon\alpha$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\delta + \alpha \le 1 $&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$0 \le \epsilon \lt \min (\vert x-N \vert)$&lt;/span&gt;&lt;br /&gt;&#xA;This makes &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; free for &lt;span class=&quot;math-container&quot;&gt;$x\lt N$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So &lt;span class=&quot;math-container&quot;&gt;$ x\lt N$&lt;/span&gt; define another binary &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; as&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ N \le x + M\beta$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \epsilon\beta -M(1-\beta) \le N-x$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-06-03T01:01:05.547" LastActivityDate="2023-06-03T01:01:05.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10515" PostTypeId="2" ParentId="10512" CreationDate="2023-06-01T14:02:39.573" Score="2" Body="&lt;p&gt;To convert non-monetary items/objectives to euro/dollar values you can choose&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Opportunity cost - cost of lost opportunity, for example what is the cost of lost orders?&lt;/li&gt;&#xA;&lt;li&gt;Risk - what are the risks in dollar amount (compliance/lost sales) for low quality&lt;/li&gt;&#xA;&lt;li&gt;Benefits of usage - low carbon usage &amp;amp; associated carbon credits&lt;/li&gt;&#xA;&lt;li&gt;Investment - what is the cost involved to achieve customer satisfaction rate &amp;gt;99%.&lt;br /&gt;&#xA;Quality also comes with a cost.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-06-01T14:02:39.573" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10516" PostTypeId="1" CreationDate="2023-06-01T16:16:47.523" Score="3" ViewCount="204" Body="&lt;p&gt;I am using OR-Tools for an employees scheduling problem. I have a dictionary that is defined as an IntVar, where such dictionary contains the number of hours that will be assigned to each employee, ranging from zero to availability_for_day:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;intvars[ID_VAR] = model.NewIntVar(0, availability_for_day, ID_VAR)&#xA;model.Add(sum[intvars[intv] for intv in intvars.keys()]&amp;lt;= availability_for_day&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The ID_VAR keys for &lt;strong&gt;intvars&lt;/strong&gt; are an f-string combination between dates &lt;em&gt;(yyyy-mm-dd)&lt;/em&gt; and employee_id. I want to add a constraint that allows me to set a minimum number of employees that are assigned for a task for each day.&#xA;Therefore, my question is: how do I count how many intvars[intv] values are greater than zero? Then, how do I set the number of intvars[intv] that are greater than zero to be equal or greater than a minimum number of employees that I want to allocate?&lt;/p&gt;&#xA;&lt;p&gt;So far, I have tried using another IntVar as a counter, but I could not make it work.&lt;/p&gt;&#xA;" OwnerUserId="11921" LastEditorUserId="491" LastEditDate="2023-06-02T18:37:49.777" LastActivityDate="2023-06-02T18:37:49.777" Title="how to count the number of values that are greater than zero in OR-Tools" Tags="|constraint-programming|or-tools|cp-sat|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10517" PostTypeId="2" ParentId="10516" CreationDate="2023-06-01T17:41:11.280" Score="4" Body="&lt;p&gt;You can a look at this &lt;a href=&quot;https://github.com/google/or-tools/blob/main/ortools/sat/docs/channeling.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;doc&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You will create one Boolean variable per integer variable, and sum them.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-06-01T17:41:11.280" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10518" PostTypeId="2" ParentId="10516" CreationDate="2023-06-01T18:02:09.673" Score="0" Body="&lt;p&gt;It's like bin packing problem. Just define set of binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{d,s}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$d,s$&lt;/span&gt; is same index as your intvar keys -(date d, staff s). Then add constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_{d,s} \le H_{d,s} \le A_{d,s}x_{d,s} \\ \forall d,s $&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$H_{d,s} $&lt;/span&gt; is your intvar and &lt;span class=&quot;math-container&quot;&gt;$A_{d,s}$&lt;/span&gt; is available hours per &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ L_d\le \sum_s x_{d,s} \ \forall d$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is min staff required for date &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-06-01T18:02:09.673" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10519" PostTypeId="1" CreationDate="2023-06-01T23:32:09.207" Score="2" ViewCount="108" Body="&lt;p&gt;I recently came across a book on Abstract Algebra by Charles Pinter. I am surprised by its simplicity to explain the concepts.&lt;/p&gt;&#xA;&lt;p&gt;I am very interested in OR problems in supply chain management. I can imagine that there are a lot of OR problems at every stage of the supply chain, e.g., inventory management, order fulfilment, pricing, matching, etc. I am wondering if there are books that can help me learn supply chain management and mathematical formulation of these problems.&lt;/p&gt;&#xA;" OwnerUserId="5564" LastEditorUserId="500" LastEditDate="2023-06-02T02:39:43.743" LastActivityDate="2023-06-07T04:42:59.100" Title="An easy-to-read and engaging book to learn supply chain modelling problems" Tags="|supply-chain|books|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10520" PostTypeId="2" ParentId="10519" CreationDate="2023-06-02T08:21:38.907" Score="1" Body="&lt;p&gt;A really good choice could be &lt;a href=&quot;https://books.google.com.ar/books?id=5WrSBQAAQBAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Supply Chain Engineering: Models and Applications&amp;quot; by Ravindran and  Warsing&lt;/a&gt;. It covers most of the Supply Chain related problems and, having some knowledge of Operations Research, it is easy to read.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2023-06-02T08:21:38.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10521" PostTypeId="2" ParentId="10519" CreationDate="2023-06-02T11:07:11.130" Score="1" Body="&lt;p&gt;You can easily find out many useful materials just by searching the community (OR.SE) and some of them would be:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/117/recommended-books-materials-for-practical-applications-of-operations-research-in/196#196&quot;&gt;Recommended books/materials for practical applications of Operations Research in industry&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/529/supply-chain-public-data-repository&quot;&gt;Supply Chain Public Data Repository&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/430/real-world-examples-of-supply-chain-contracts&quot;&gt;Real-world examples of supply chain contracts?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/5885/recommendations-for-om-blogs&quot;&gt;Recommendations for OM blogs&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/1442/case-studies-and-real-problems-for-teaching-optimization-and-modelling/1454#1454&quot;&gt;Case Studies and Real Problems for Teaching Optimization and Modelling&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-06-02T11:07:11.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10523" PostTypeId="1" CreationDate="2023-06-02T20:28:42.847" Score="1" ViewCount="78" Body="&lt;p&gt;Given a binary optimization problem of the following form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;min\; &amp;amp;cx&amp;amp;\\&#xA;&amp;amp;Dx \leq e&amp;amp;\\&#xA;&amp;amp;\sum_{i\in S} x_i \leq r(S) &amp;amp;\forall S\in \mathbb{S}\\&#xA;&amp;amp;x_i binary &amp;amp;\forall i\in N&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The set &lt;span class=&quot;math-container&quot;&gt;$\mathbb{S}$&lt;/span&gt; is the family of all infeasible subsets, i.e. all infeasible combinations of items &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. For every &lt;span class=&quot;math-container&quot;&gt;$S\in \mathbb{S}$&lt;/span&gt; we have &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in S} x_i \leq r(S)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$r(S)$&lt;/span&gt; is the maximum number of items that can be selected from &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; in any feasible solution. Note that because &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is an infeasible subset, it must hold that &lt;span class=&quot;math-container&quot;&gt;$r(S) \leq |S|-1$&lt;/span&gt;. For a given &lt;span class=&quot;math-container&quot;&gt;$S\in \mathbb{S}$&lt;/span&gt;, it's possible to compute &lt;span class=&quot;math-container&quot;&gt;$r(S)$&lt;/span&gt; via a simple MIP. The family &lt;span class=&quot;math-container&quot;&gt;$\mathbb{S}$&lt;/span&gt; is however exponentially large so it's not possible to precompute the entire set, so the intend is to add these constraints through a cutting plane procedure.&lt;/p&gt;&#xA;&lt;p&gt;For a given LP solution &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt;, I would like to verify whether there exists a set &lt;span class=&quot;math-container&quot;&gt;$S\in \mathbb{S}$&lt;/span&gt; for which the constraint is violated. More precisely, I'd like to find the set &lt;span class=&quot;math-container&quot;&gt;$S'$&lt;/span&gt; that maximizes the violation: &lt;span class=&quot;math-container&quot;&gt;$argmax_{S'\in \mathbb{S}}\sum_{i\in S'}\bar{x}_i-r(S')$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To have a concrete example, let's assume that &lt;span class=&quot;math-container&quot;&gt;$\mathbb{S}=\{S\subset N|\sum_{i\in S}a_i&amp;gt;b\}$&lt;/span&gt; is the family of subsets that exceed a knapsack constraint*. Let &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; be a binary variable indicating whether item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is a member of set &lt;span class=&quot;math-container&quot;&gt;$S'$&lt;/span&gt;. To find the most violated set &lt;span class=&quot;math-container&quot;&gt;$S'$&lt;/span&gt;, we would have to solve:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max \sum_{i\in N}\bar{x}_iz_i-r(z)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;r(z)=&amp;amp;\max \sum_{i\in N}y_i&amp;amp;\\&#xA;&amp;amp;\sum_{i\in N}a_iy_i\leq b&amp;amp;\\&#xA;&amp;amp;y_i\leq z_i &amp;amp; \forall i\in N\\&#xA;&amp;amp;y_i binary &amp;amp;\forall i\in N&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the resulting objective is strictly positive, a violated set has been found. My question: is there a way to reformulate this separation problem into single model (e.g. &lt;span class=&quot;math-container&quot;&gt;$\max \sum_{i\in N}\bar{x}_iz_i-r$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$r\geq \dots$&lt;/span&gt;)? If not, how would one solve this formulation?&lt;/p&gt;&#xA;&lt;p&gt;*: &lt;sub&gt;in my problem, the infeasible sets are more complex than knapsack constraints, but I use it here for illustrative purposes.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2023-06-02T21:15:37.370" LastActivityDate="2023-06-02T21:53:11.367" Title="Finding a maximum violated infeasible subset" Tags="|mixed-integer-programming|valid-inequalities|bilevel-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10524" PostTypeId="2" ParentId="10523" CreationDate="2023-06-02T21:14:43.147" Score="2" Body="&lt;p&gt;Here's where I think you are heading:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\max_{z\in\{0,1\}^N} \left[\sum_{i\in N} \bar{x}_i z_i - \max_{y\in\{0,1\}^N} \left(\sum_{i\in N} y_i: \sum_{i\in N} a_i y_i \le b \land \bigwedge_{i\in N} (y_i \le z_i) \right) \right] \\&#xA;&amp;amp;= \max_z \left[\bar{x}^T z - \max_y \left(e^T y: a^T y \le b \land y \le z \right) \right] \\&#xA;&amp;amp;= \max_z \left[\bar{x}^T z + \min_y \left(-e^T y: a^T y \le b \land y \le z \right) \right] \\&#xA;&amp;amp;\stackrel{*}{=} \max_{z, \eta, y} \left[\bar{x}^T z + \eta: \eta \le -e^T y \land a^T y \le b \land y \le z \right] \\&#xA;&amp;amp;= \max_{z, r, y} \left[\bar{x}^T z - r: r \ge e^T y \land a^T y \le b \land y \le z \right]&#xA;\end{align}&lt;/span&gt;&#xA;But the &lt;span class=&quot;math-container&quot;&gt;$\stackrel{*}{=}$&lt;/span&gt; step is suspect.  In particular, it leads to the false conclusion that it is always optimal to take &lt;span class=&quot;math-container&quot;&gt;$r=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_i=0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.  If your actual subproblem (not knapsack) is totally unimodular, you can relax &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, dualize the subproblem, and maximize over &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and the dual variables.  Otherwise, relaxing &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; yields only a bound.&lt;/p&gt;&#xA;&lt;p&gt;A generic approach is to use combinatorial Benders decomposition, with the master problem over &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and the subproblem over &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; for fixed &lt;span class=&quot;math-container&quot;&gt;$z=\hat{z}$&lt;/span&gt;.  If the subproblem is infeasible, the Benders feasibility cuts prohibit that &lt;span class=&quot;math-container&quot;&gt;$\hat{z}$&lt;/span&gt;.  If the subproblem is optimal but the objective value disagrees with &lt;span class=&quot;math-container&quot;&gt;$\hat{\eta}$&lt;/span&gt;, the Benders optimality cuts prohibit that &lt;span class=&quot;math-container&quot;&gt;$(\hat{z},\hat{\eta})$&lt;/span&gt;.  But then you would be using a cutting-plane algorithm to find cuts for a cutting-plane algorithm...&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-06-02T21:53:11.367" LastActivityDate="2023-06-02T21:53:11.367" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10525" PostTypeId="1" CreationDate="2023-06-03T07:27:48.290" Score="0" ViewCount="59" Body="&lt;p&gt;I have the following question. I have two variables &lt;span class=&quot;math-container&quot;&gt;$w_{nds}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m_{nd}$&lt;/span&gt;. The first variable indicates whether a nurse &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; works shift &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;. The second one indicates the motivation of nurse &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;. How can I link both and create a new variable &lt;span class=&quot;math-container&quot;&gt;$moti_{nds}$&lt;/span&gt; that combines both information. So the new variable should capture the motivation for each nurse for each shift each day. The value of &lt;span class=&quot;math-container&quot;&gt;$moti$&lt;/span&gt; for a given shift should be &lt;span class=&quot;math-container&quot;&gt;$\ge 0$&lt;/span&gt; only if the nurse works this shift. For example, if she works all shifts in a day then &lt;span class=&quot;math-container&quot;&gt;$moti_{1ds}=1 ~\forall s\in S$&lt;/span&gt; should hold. My suggestion would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{align}&#xA;&amp;amp;moti_{nds}=w_{nds}\cdot m_{nd}~~~~\forall n\in N, d\in D, s\in S&#xA;\end{align}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Would this be a linear formulation? I would be because, yes, you multiply a variable with two indices by one over three. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="8" LastEditDate="2023-06-03T18:39:45.687" LastActivityDate="2023-06-03T19:41:38.283" Title="Help finding linear constraint - LP" Tags="|linear-programming|constraint|scheduling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10526" PostTypeId="2" ParentId="10525" CreationDate="2023-06-03T13:57:12.980" Score="1" Body="&lt;p&gt;To linearize product of two variables with &lt;span class=&quot;math-container&quot;&gt;$moti_{nds}$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$ m_{nd}$&lt;/span&gt; are binary&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ w_{nds}+ m_{nd} \le moti_{nds}+1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$moti_{nds}\le m_{nd}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$moti_{nds}\le w_{nds} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can sum &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and moti over shift &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; for last 2 constraints for nurse &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; works  on a given day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_s moti_{nds}\le m_{nd}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_s moti_{nds}\le  \sum_s w_{nds} \le S\sum_s moti_{nds}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In case &lt;span class=&quot;math-container&quot;&gt;$m_{n,d}$&lt;/span&gt; is continuous variable in domain &lt;span class=&quot;math-container&quot;&gt;$[L,U]$&lt;/span&gt; then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L w_{nds} \le \sum_s moti_{nds} \le Uw_{nds}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$m_{nd}+L(1-w_{nds}) \le \sum_s moti_{nds} \le m_{nd}+U(1-w_{nds})$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-06-03T19:41:38.283" LastActivityDate="2023-06-03T19:41:38.283" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10527" PostTypeId="2" ParentId="10509" CreationDate="2023-06-04T22:54:18.150" Score="2" Body="&lt;p&gt;For &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in A$&lt;/span&gt;, you want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\delta_{i,j}^d = 1 \implies y_i^d \le y_j^d - S \tag1\label1$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i &amp;lt; N  \implies \delta_{i,j}^d=0 \tag2\label2$$&lt;/span&gt;&#xA;For &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in B$&lt;/span&gt;, you want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\delta_{i,j}^d =1 \implies y_i^d \le y_j^d - N \cdot S \tag3\label3$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To enforce \eqref{1}, use big-M:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_i^d - y_j^d + S \le M(1-\delta_{i,j}^d) \quad \text{for $(i,j)\in A$}$$&lt;/span&gt;&#xA;To enforce \eqref{2}, first rewrite as its contrapositive:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\delta_{i,j}^d=1 \implies x_i \ge N$$&lt;/span&gt;&#xA;and then use big-M:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$N - x_i \le M(1-\delta_{i,j}^d) \quad \text{for $(i,j)\in A$}$$&lt;/span&gt;&#xA;To enforce \eqref{3}, use big-M:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_i^d - y_j^d + N\cdot S \le M(1-\delta_{i,j}^d) \quad \text{for $(i,j)\in B$}$$&lt;/span&gt;&#xA;Note that the values of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; are different in these three cases.  In each case, &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; should be a (small) constant upper bound on the LHS when &lt;span class=&quot;math-container&quot;&gt;$\delta_{ij}^d=0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-06-04T22:54:18.150" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10529" PostTypeId="1" CreationDate="2023-06-05T08:38:58.247" Score="0" ViewCount="137" Body="&lt;p&gt;I occasionally see this slightly strange thing happen with cplex where it jumps from a MIP gap of, say 5%, to then reporting the status as optimal. This happens when it starts solution polishing after hitting the &lt;code&gt;PolishAfterTime&lt;/code&gt; condition.&lt;/p&gt;&#xA;&lt;p&gt;From inspection of the solutions, I do not believe they are actually optimal and I suspect something could be going wrong in solution polishing, but I'm unsure what. Has anyone seen anything similar or have an idea what could be happening? I have attached an example image of cplex logs. Also, it's worth noting that it never gets past the root node and cplex reports &lt;code&gt;nodes=0&lt;/code&gt;.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/HYVNy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HYVNy.png&quot; alt=&quot;cplex logs&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11933" LastEditorUserId="36" LastEditDate="2023-06-05T16:08:03.807" LastActivityDate="2023-09-05T08:42:24.450" Title="Cplex seems to terminate early as optimal when starting solution polishing" Tags="|mixed-integer-programming|cplex|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10530" PostTypeId="1" AcceptedAnswerId="10539" CreationDate="2023-06-05T23:52:05.770" Score="3" ViewCount="185" Body="&lt;p&gt;Can anyone recommend a straightforward quadratic programming (QP) algorithm suitable for an undergraduate engineering class? I'm interested in finding an algorithm that they can easily grasp and implement, say in Python, through a hands-on learning approach.&lt;/p&gt;&#xA;&lt;p&gt;Best,&#xA;Walton.&lt;/p&gt;&#xA;" OwnerUserId="11938" LastEditorUserId="500" LastEditDate="2023-06-06T00:19:53.757" LastActivityDate="2023-06-07T14:41:27.987" Title="Simplest Quadratic Programming algorithm for teaching" Tags="|python|convex-optimization|quadratic-programming|algorithms|teaching|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10531" PostTypeId="1" AcceptedAnswerId="10532" CreationDate="2023-06-06T06:41:07.517" Score="3" ViewCount="301" Body="&lt;p&gt;Consider two binary variables &lt;span class=&quot;math-container&quot;&gt;$p_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_2$&lt;/span&gt;. Suppose, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a continuous variable that should not take values between &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here is my try:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p_1 =1 \mbox{ if } x \le a \\&#xA;p_1 =0 \mbox{ if } x &amp;gt;a  \\&#xA;p_2 =1 \mbox{ if } x \ge b  \\&#xA;p_2 =0 \mbox{ if } x &amp;lt; b &#xA;$$&lt;/span&gt;&#xA;Now what will be the final equations??&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;p_1+p_2=1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="11940" LastEditorUserId="2556" LastEditDate="2023-06-06T07:49:23.603" LastActivityDate="2023-06-06T21:28:05.957" Title="Modeling a continuous variable which can't take values between a and b" Tags="|modeling|logical-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10532" PostTypeId="2" ParentId="10531" CreationDate="2023-06-06T07:49:04.910" Score="7" Body="&lt;p&gt;You want to model&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x \le a \mbox{ or } x \ge b&#xA;$$&lt;/span&gt;&#xA;which you can enforce with a binary variable &lt;span class=&quot;math-container&quot;&gt;$p\in \{0,1\}$&lt;/span&gt; and big M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;b - M_1p \le x&amp;amp;\le a +M_2(1-p) \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The LHS enforces &lt;span class=&quot;math-container&quot;&gt;$p=0 \implies x\ge b$&lt;/span&gt;, while the RHS enforces &lt;span class=&quot;math-container&quot;&gt;$p=1 \implies x \le a$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$p=0$&lt;/span&gt;, the constraint becomes &lt;span class=&quot;math-container&quot;&gt;$$ b  \le x\le a +M_2 $$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$p=1$&lt;/span&gt;, the constraint becomes &lt;span class=&quot;math-container&quot;&gt;$$ b - M_1 \le x \le a $$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x \ge 0$&lt;/span&gt;, you could set &lt;span class=&quot;math-container&quot;&gt;$M_1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$M_2$&lt;/span&gt; is either an upper bound on &lt;span class=&quot;math-container&quot;&gt;$x-a$&lt;/span&gt; (if available), or a large constant.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="500" LastEditDate="2023-06-06T21:28:05.957" LastActivityDate="2023-06-06T21:28:05.957" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10533" PostTypeId="1" CreationDate="2023-06-06T12:33:49.533" Score="1" ViewCount="48" Body="&lt;p&gt;I am trying to set up a constraint that does the following. I a binary variable &lt;span class=&quot;math-container&quot;&gt;$p_{it}$&lt;/span&gt; that indicates whether a student &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; passed the test in &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. 1 if yes and 0 if no. Now I want to set up a constraint that fills another variable, so to speak. &lt;span class=&quot;math-container&quot;&gt;$n_{it}$&lt;/span&gt; should indicate how many tests a student &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; has passed at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. If for example &lt;span class=&quot;math-container&quot;&gt;$p_{i2}=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p_{i3}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_{i4}=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$n_{i4}=3$&lt;/span&gt; shall be valid. Thereby &lt;span class=&quot;math-container&quot;&gt;$p_{it}$&lt;/span&gt; exists only from &lt;span class=&quot;math-container&quot;&gt;$t=2$&lt;/span&gt;.&#xA;My suggestion is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;n_{i t}=\sum_{j=t}^{t} p_{i (j)} \quad \forall i \in I, t \in \{2,\ldots,T\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is that correct?&lt;/p&gt;&#xA;" OwnerUserId="11914" LastActivityDate="2023-06-06T13:21:36.917" Title="How to sum over periods till Period t?" Tags="|linear-programming|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10534" PostTypeId="2" ParentId="10533" CreationDate="2023-06-06T13:12:35.207" Score="1" Body="&lt;p&gt;That is almost correct, but what you proposed is a one-term sum.  The summation index &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; should instead start at your first period: &lt;span class=&quot;math-container&quot;&gt;$$n_{it}=\sum_{j=2}^t p_{ij}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Alternative shorthand:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$n_{it}=\sum_{j\le t} p_{ij}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, &lt;span class=&quot;math-container&quot;&gt;$p_{i(j)}$&lt;/span&gt; looks like &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is a function of &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt; is better.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-06-06T13:21:36.917" LastActivityDate="2023-06-06T13:21:36.917" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10535" PostTypeId="1" CreationDate="2023-06-06T15:38:42.497" Score="1" ViewCount="215" Body="&lt;p&gt;I have a general question: Is random search a heuristic or a metaheuristic. Actually, as far as I understand, metaheuristics define a general principle to approximately solving an optimization problem that is applicable to a big variety of problems. Thus, I would infer, that random search is also a metaheuristic, as it can be applied to (almost?) every optimization problem. I would argue that in a nuthshell, it is not really different from evolutionary algorithms or particle swarm optimization. All of the don't make use of problem-specific characteristics as a heuristic usually does.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: By random search I am refering to a method that just randomly samples a fixed number of points in the solution space and at the end uses the best solution after evaluating all those solutions.&lt;/p&gt;&#xA;&lt;p&gt;What is your take on this?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2023-06-06T15:48:20.430" LastActivityDate="2023-06-07T06:30:07.550" Title="Is random search a heuristic or a metaheuristic" Tags="|heuristics|metaheuristics|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10536" PostTypeId="2" ParentId="10531" CreationDate="2023-06-06T19:14:01.357" Score="-1" Body="&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$ b \lt a$&lt;/span&gt; you can try&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x + \epsilon \le b + Mp$&lt;/span&gt;&lt;br /&gt;&#xA;if &lt;span class=&quot;math-container&quot;&gt;$ p=0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$ x \lt b$&lt;/span&gt;, the 2nd constr becomes meaningless.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ a+\epsilon \le x + M(1-p)$&lt;/span&gt;&lt;br /&gt;&#xA;if &lt;span class=&quot;math-container&quot;&gt;$p=1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$x \gt a$&lt;/span&gt;, 1st constr turns meaningless &amp;amp; since &lt;span class=&quot;math-container&quot;&gt;$ b \lt a$&lt;/span&gt; so &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; cant be &lt;span class=&quot;math-container&quot;&gt;$[b,a]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a reasonably big number, maybe upper bound of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is a very small number to take care &lt;span class=&quot;math-container&quot;&gt;$\lt$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-06-06T19:14:01.357" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10537" PostTypeId="2" ParentId="10519" CreationDate="2023-06-07T04:42:59.100" Score="0" Body="&lt;p&gt;Try this: &lt;a href=&quot;https://coral.ise.lehigh.edu/sctheory/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fundamentals of Supply Chain Theory&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11947" LastActivityDate="2023-06-07T04:42:59.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10538" PostTypeId="2" ParentId="10535" CreationDate="2023-06-07T06:21:01.613" Score="3" Body="&lt;p&gt;I think the answer depends on what school you belong to. I've heard many define metaheuritics as &lt;em&gt;generic&lt;/em&gt; heuristics in the sense that they can be applied to a broad range of optimization problems. In the way I was taught, however, metaheuritic are algorithms built on top of heuristics. These heuristics can be generic or problem specific, typically parameterized and often randomized, but all have in common that they take some input and produce a single solution. The job of the metaheuristic is then to iteratively select which heuristic to run (e.g., one that constructs a new solution, or one that combine/improve old) and which data to input (e.g., updating pseudo-costs, tabu lists or probability distributions) to strike a balance between climbing local peaks (local optimization) and not being caught in the neighborhood of one forever (diversification).&lt;/p&gt;&#xA;&lt;p&gt;In this perspective, your description of random search is perhaps the simplest possible metaheuristic in existence as it only uses one heuristic (constructive random selection) and reruns it repeatedly where only the internal state of the random number generator changes from run to run. In some sense it represent an extreme in the metaheuristic space of algorithms with 100% diversification and 0% local optimization. Simplistic as it is, however, it is guaranteed to find the optimal solution in finite time if the solution space is finite, which is a theoretical property often sought in metaheuristics.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2023-06-07T06:30:07.550" LastActivityDate="2023-06-07T06:30:07.550" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="10539" PostTypeId="2" ParentId="10530" CreationDate="2023-06-07T07:32:41.670" Score="5" Body="&lt;p&gt;You can optimize convex equality-constrained QP by solving a linear equation system (the KKT conditions). This is good knowledge to disseminate and easy for undergrads to grasp in a lecture. Moreover, there are many tools out there for solving equation systems so the only challenge for your undergrads is setting up the equation system and calling a function.&lt;/p&gt;&#xA;&lt;p&gt;Once that is cleared, you can challenge them to write an active set method to solve convex inequality-constrained QP. This is a natural generalization of the simplex method which many undergrads will most likely encounter in their studies anyway, and combinatorial in nature meaning that (at the cost of performance) your undergrads can focus on the logic of decisions derived from mathematical expressions, rather than the numerical challenges of floating-point precision.&lt;/p&gt;&#xA;&lt;p&gt;Whether this approach is suitable all depends on your learning goals.&lt;/p&gt;&#xA;" OwnerUserId="198" LastActivityDate="2023-06-07T07:32:41.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10540" PostTypeId="2" ParentId="10530" CreationDate="2023-06-07T12:12:01.943" Score="4" Body="&lt;p&gt;Some really simple but higher-level approaches (no low-level pivoting required) could be:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A simple Sequential Linear Programming algorithm (useful approach for other nonlinear problems and a nice application of a Taylor series)&lt;/li&gt;&#xA;&lt;li&gt;Form LCP from KKT conditions, and solve as a MIP (makes you understand complementarity)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;These methods can help students look at QP problems in a different way (as NLP or as complementarity problem). Not a real programming challenge however (I have taught these things using remarkably few lines of GAMS code).&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2023-06-07T14:41:27.987" LastActivityDate="2023-06-07T14:41:27.987" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10541" PostTypeId="1" CreationDate="2023-06-08T07:36:38.897" Score="1" ViewCount="110" Body="&lt;p&gt;There exists a scheduling problem in which some tasks should be processed on some resources. Additionally, each task needs to be assigned to a specific position on each resource. Let the decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{j,p,m}$&lt;/span&gt; take the value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is being assigned to position &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; on the resource &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. Also, one of the limitations on the model is a precedence constraint that defines as a precedence graph &lt;span class=&quot;math-container&quot;&gt;$G(V, E)$&lt;/span&gt; in which tasks are nodes and relations are edges. (&lt;span class=&quot;math-container&quot;&gt;$(i \rightarrow j)$&lt;/span&gt; means task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; should be processed before task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;). As the problem is large-scale it is separated into two models. The following constraints are some of the parts of the first model.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{p,m} x_{j,p,m} = 1 &amp;amp;&amp;amp; \forall j \in J &amp;amp;&amp;amp; (1)\\&#xA;\sum_{j} x_{j,p,m} \leq 1 &amp;amp;&amp;amp; \forall p \in P, m \in M &amp;amp;&amp;amp; (2)\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first ensures assigning each task to each position, and the second for occupying positions. The above constraints have &lt;em&gt;&lt;strong&gt;integrality property&lt;/strong&gt;&lt;/em&gt; and we are willing to keep that.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering if, is there any precedence constraint that follows this integrality property? If NO, is there any form that being as tight as possible?&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2024-04-03T18:01:25.163" Title="Modeling of a special form of the precedence constraint" Tags="|mixed-integer-programming|modeling|scheduling|lp-relaxation|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10542" PostTypeId="1" AcceptedAnswerId="10543" CreationDate="2023-06-08T08:45:01.687" Score="0" ViewCount="65" Body="&lt;p&gt;I have a constraint that is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$  &#xA; Ax - f(x) \leq 0  &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$f(x)=min_y(g(x,y))$&lt;/span&gt;. Which is convex. I can even get the gradient in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. How can I reformulate my constraint? or what approach should/could I follow to solve a problem like this?&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; was binary (and that is added to the minimization function &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;. Could I still solve this? Do you have any tips or reading that I could do about this?&lt;/p&gt;&#xA;&lt;p&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are vectors of variables.&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="7200" LastEditDate="2023-06-08T11:04:26.897" LastActivityDate="2023-06-08T11:49:00.300" Title="Min-convex function as constraint" Tags="|mixed-integer-programming|nonlinear-programming|convex-optimization|reformulation-linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10543" PostTypeId="2" ParentId="10542" CreationDate="2023-06-08T09:26:03.937" Score="3" Body="&lt;p&gt;In case &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; belongs to a finite domain (e.g., if binary), you can split your difficult constraint into multiple simpler (one for each element of the domain) using:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Ax \leq \min_y g(x,y) \quad\Longleftrightarrow\quad Ax \leq g(x,y) \;\; \forall y.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In case &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; belongs to an infinite domain (e.g., continuous) you can reformulate if you are able to derive a strong dual problem, satisfying &lt;span class=&quot;math-container&quot;&gt;$\min_y g(x,y) = \max_\lambda h(x,\lambda)$&lt;/span&gt;, in which case you end up with a single constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Ax \leq \min_y g(x,y) = \max_\lambda h(x,\lambda) \quad\Longleftrightarrow\quad Ax \leq h(x,\lambda).&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; One way to derive a strong dual is by first reformulating to some well-known standard form. As example, if &lt;span class=&quot;math-container&quot;&gt;$\min_y g(x,y)$&lt;/span&gt; could be reformulated as a linear optimization problem with &lt;span class=&quot;math-container&quot;&gt;$$&lt;/span&gt; as the cost coefficient, then&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rcl}&#xA;\min_y g(x,y) &amp;amp;=&amp;amp; \min\{ x^T y \;:\; By = b,\; y \geq 0 \},\\&#xA;&amp;amp;=&amp;amp; \max\{ b^T \lambda \;:\; B^T\lambda \leq x \},&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;holds by linear duality theory, and tells you that it is possible rewrite&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Ax \leq \min_y g(x,y) \quad\Longleftrightarrow\quad Ax \leq b^T \lambda,\;\; B^T\lambda \leq x.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For nonlinear functions I recommend going through the conic standard form which has well-studied duality properties. If there exists a conic reformulation, there also exists a conic reformulation that satisfies strong duality to make the trick above work. The &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;MOSEK cookbook&lt;/a&gt; is a good source on how to formulate conic optimization problems.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2023-06-08T11:49:00.300" LastActivityDate="2023-06-08T11:49:00.300" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10544" PostTypeId="1" AcceptedAnswerId="10548" CreationDate="2023-06-08T10:58:55.580" Score="-1" ViewCount="192" Body="&lt;p&gt;I am trying to solve a multi objective optimization problem. I have a set of nodes belonging to different counties and each node is associated with some cost and some priority. I want to select the nodes such that cost of selected nodes is minimized and nodes with higher priority are selected. At each county, a minimum number of nodes should be selected.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{ll}&#xA;\text{minimize}  &amp;amp; c^T x \\&#xA;\text{maximize}  &amp;amp; p^T x \\&#xA;\text{subject to}&amp;amp;  \sum_i x_{i} &amp;gt;=  \alpha_k, \quad \forall x_i \in C_k, \quad \forall k \in \{C_1,C_2,C_3,....,C_k\} \\&#xA;\ &amp;amp;0 \le x \le 1.&#xA;\end{array}&lt;/span&gt;&#xA;&lt;code&gt;c&lt;/code&gt; is the cost array, &lt;code&gt;p&lt;/code&gt; is the priority array, &lt;code&gt;x&lt;/code&gt; is binary design variable and &lt;code&gt;C&lt;/code&gt; is a county. The constraint means that in a given county C, the count of nodes selected should be atleast &lt;code&gt;alpha&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have taken the approach of binary integer programming. Each node is encoded as a binary variable where 0 means node is not selected and 1 means node is selected.&lt;/p&gt;&#xA;&lt;p&gt;I am using &lt;a href=&quot;https://pymoo.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;pymoo&lt;/a&gt; to model this problem and the problem is formulated as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;class NodeProblem(Problem):&#xA;    def __init__(self, nodes:List[int], node_priorities:Dict[int,int], county_node_bounds:Dict[int,List[int]], county_nodes:Dict[int,List[int]], node_cost:Dict[int, float], **kwargs):&#xA;        self.nodes = np.array(nodes)&#xA;        self.node_priorities = node_priorities&#xA;        self.county_node_bounds = county_node_bounds&#xA;        self.county_nodes = county_nodes&#xA;        self.priorities = np.array(list(node_priorities.values()))&#xA;        self.cost = np.array(list(node_cost.values()))&#xA;        super().__init__(n_var=len(nodes), n_obj=2, n_ieq_constr=len(county_node_bounds), xl=0, xu=1, vtype=bool,  **kwargs)&#xA;    &#xA;    @staticmethod&#xA;    def get_index(arr1, arr2):&#xA;        &amp;quot;&amp;quot;&amp;quot;&#xA;        Return the index of elements present in arr2 ndarray as per arr1 ndarray.&#xA;        &amp;quot;&amp;quot;&amp;quot;&#xA;        sort = np.argsort(arr1)&#xA;        rank = np.searchsorted(arr1, arr2, sorter=sort)&#xA;        return sort[rank]&#xA;&#xA;    def _evaluate(self, X, out, *args, **kwargs):&#xA;        # Shape of X is (pop_size, n_var)&#xA;        # objective value for each member of population&#xA;&#xA;        cost_obj = np.dot(X, self.cost) # Shape after calculation is (pop_size,)&#xA;&#xA;        priority_obj = np.dot(X, self.priorities)&#xA;        out[&amp;quot;F&amp;quot;] = np.column_stack([cost_obj, -priority_obj])&#xA;        # Shape of constrs should be (pop_size, self.n_constr)&#xA;        constrs = []&#xA;        for c,target in self.county_node_bounds.items():&#xA;            node_cds = [ndc for ndc in self.county_nodes[c]]&#xA;            node_idxs = self.get_index(self.nodes, np.array(node_cds))&#xA;            a = target - np.sum(X[:, node_idxs], axis=1)&#xA;            constrs.append(a)&#xA;        out[&amp;quot;G&amp;quot;] = np.column_stack(constrs)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My pareto front comes out as follows where first column is cost and second column is priority:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[[2365.51796736, -346.]&#xA; [3004.5990833,  -383.]&#xA; [3826.76396175, -414.]&#xA; [3383.5413055,  -398.]&#xA; [3447.82173955, -399.]&#xA; [5397.57485522, -437.]&#xA; [4400.71535067, -426.]&#xA; [2648.00046736, -366.]&#xA; [2366.60434547, -347.]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The resulting pareto front is not meeting the standards. The priority values are coming out as negative. Is this because I have changed the sign of priority objective &lt;code&gt;priority_obj&lt;/code&gt; to maximize it as &lt;code&gt;Pymoo&lt;/code&gt; gives only &lt;code&gt;minimize&lt;/code&gt; function? If negative sign just represents &lt;code&gt;maximize&lt;/code&gt;, then also the result is not correct. For example, the highest cost value of 5397.57485522 has the highest priority 437. Similarly, the lowest cost value of 2365.51796736 has the lowest priority 346. But it should be the other way around.&lt;/p&gt;&#xA;&lt;p&gt;Is my formulation wrong or I am not understanding something about optimization?&lt;/p&gt;&#xA;" OwnerUserId="11800" LastEditorUserId="11800" LastEditDate="2023-06-09T11:55:56.733" LastActivityDate="2023-06-09T11:55:56.733" Title="Multi objective optimization is giving wrong results" Tags="|linear-programming|binary-variable|multi-objective-optimization|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10545" PostTypeId="2" ParentId="10541" CreationDate="2023-06-08T13:00:21.550" Score="0" Body="&lt;p&gt;One option is to enforce the precedence via constraints on the start and completion times. Let &lt;span class=&quot;math-container&quot;&gt;$s_{j,m}$&lt;/span&gt; be the start of job &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; on machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; with delay &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; that finishes at time &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$x_{j,m} \geq x_{j,*,m}$&lt;/span&gt;. We have constraints like:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c_{j,m} \geq s_{j,m} + d_{j,m}x_{j,m}&#xA;$$&lt;/span&gt;&#xA;We can group (e.g. max) those into per-job start times:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c_{j} \geq c_{j,*}&#xA;$$&lt;/span&gt;&#xA;Then we can enforce precedence like so:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;s_{k} \geq c_{j}&#xA;$$&lt;/span&gt;&#xA;It's also common to define a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{j,j',m}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; happens before &lt;span class=&quot;math-container&quot;&gt;$j'$&lt;/span&gt;. If you utilize this approach you can simply constrain certain of those values to be 1. If you have travel/setup times, meaning that &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; must immediately precede &lt;span class=&quot;math-container&quot;&gt;$j'$&lt;/span&gt;, then this won't work for precedence, and you'll be back to constraining completion times.&lt;/p&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2023-06-08T13:00:21.550" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10546" PostTypeId="1" CreationDate="2023-06-08T13:23:41.550" Score="0" ViewCount="60" Body="&lt;p&gt;The optimal strategy for the well known &lt;a href=&quot;https://en.wikipedia.org/wiki/Secretary_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;secretary problem&lt;/a&gt; with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; candidates is to reject the first &lt;span class=&quot;math-container&quot;&gt;$\lceil \frac{n}{e} \rceil-1$&lt;/span&gt; candidates, and then select the first subsequent applicant that is better than all previous ones.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$n=3$&lt;/span&gt;, this optimal &amp;quot;threshold based&amp;quot; strategy selects the best applicant &lt;span class=&quot;math-container&quot;&gt;$50\%$&lt;/span&gt; of the time.&lt;/p&gt;&#xA;&lt;p&gt;However, in &lt;a href=&quot;https://studentnet.cs.manchester.ac.uk/pgt/2014/COMP60342/COMP60342-2013-DynamProg2-Secretary.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this document&lt;/a&gt; from Manchester University (pages 5-10), another strategy based on dynamic programming is described, which yields an optimal choice approximately &lt;span class=&quot;math-container&quot;&gt;$70\%$&lt;/span&gt; of the time (based on my simulations which match the paper's results). Note that in this version of the problem, the distribution of the &amp;quot;value&amp;quot; of the candidates is known, and used in the strategy.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My question&lt;/strong&gt;: is the strategy based on the threshold optimal only when the distribution is not known? Or is there a contradiction somewhere?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: A relevant tag for this question would be &amp;quot;online optimization,&amp;quot; but it does not exist.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-06-08T13:30:16.937" LastActivityDate="2023-06-08T13:30:16.937" Title="Best strategy for the secretary problem with known distribution" Tags="|optimization|stochastic-programming|dynamic-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10547" PostTypeId="1" CreationDate="2023-06-08T15:35:39.700" Score="0" ViewCount="82" Body="&lt;p&gt;I am currently working on a resource allocation problem and I am uncertain about which field of stochastic optimization and reinforcement learning encompasses this particular problem.&lt;/p&gt;&#xA;&lt;p&gt;The objective is to allocate a limited resource (budget) among different investment options in a way that maximizes the accumulated revenue over the optimization horizon. Each day, a decision is made regarding the allocation of resources to an investment channel (which remains constant throughout the horizon), and prior to making the decision for the next day, the reward (sales) obtained from the previous day is revealed.&lt;/p&gt;&#xA;&lt;p&gt;To assist in this process, we have a Bayesian parametric model that approximates the rewards received on specific dates throughout the horizon. The model is nonlinear and time-dependent, although it may not represent the true underlying model, serving as an approximation based on domain expertise. The environment being modeled exhibits a low signal-to-noise ratio.&lt;/p&gt;&#xA;&lt;p&gt;Formally, the problem can be described as follows:&lt;/p&gt;&#xA;&lt;p&gt;Investment channels: &lt;span class=&quot;math-container&quot;&gt;$I = (i, j)$&lt;/span&gt;&lt;br /&gt;&#xA;Horizon: &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;&lt;br /&gt;&#xA;Total resource: &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;&lt;br /&gt;&#xA;Decision variables: &lt;span class=&quot;math-container&quot;&gt;$x_{i, t}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; represents the investment channel and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; represents the timestep&lt;br /&gt;&#xA;Bayesian parametric model (reward approximator): &lt;span class=&quot;math-container&quot;&gt;$F(x_{x_{i, 1}, x_{j, 1}, x_{i, 2}, x_{j, 2}....x_{i, H}, x_{j, H}})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The optimization objective can be stated as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x_{i, 1}, x_{j, 1}, x_{i, 2}, x_{j, 2}....x_{i, H}, x_{j, H}}\sum_{t \in H} F(x_{x_{i, 1}, x_{j, 1}, x_{i, 2}, x_{j, 2}....x_{i, H}, x_{j, H}}) \tag{1}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subject to: &lt;span class=&quot;math-container&quot;&gt;$$\sum_{t \in H}\sum_{k \in (i, j)} x_{k, t} \leq B \tag{2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, let's consider two different schemes to approach this problem:&lt;/p&gt;&#xA;&lt;p&gt;Scheme 1:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1. Collect daily data on historic investments and their corresponding rewards.&#xA;2. Obtain posterior estimates of the model using MCMC sampling with the collected data.&#xA;3. Sample a single trajectory from the posterior, projecting the parameter estimates over the horizon&#xA;4. Utilize this single trajectory as the true parameter values over the horizon and optimize the allocation strategy.&#xA;5. Execute the investment.&#xA;6. Receive the reward for the current day.&#xA;7. Repeat from step 1 the next day.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Scheme 2:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1. Same as scheme 1.&#xA;2. Same as scheme 1.&#xA;3. Sample multiple (possibly a large number of) trajectories from the posterior, projecting the parameter estimates over the horizon.&#xA;4. Use these samples as potential trajectories over the horizon and optimize the allocation strategy by considering the mean of the different reward trajectories.&#xA;5. Same as scheme 1.&#xA;6. Same as scheme 1.&#xA;7. Same as scheme 1.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am interested in understanding if scheme 1 is an example of Thompson sampling, as it appears quite similar. Additionally, does scheme 2 fall under the category of stochastic optimization, as it seems quite comparable? I am seeking literature that addresses this type of problem, which seems to be encountered in various scenarios, but I am struggling to find relevant literature. Most of the problems I come across are substantially different. Utilizing a Bayesian model to model uncertainty and sampling trajectories seems like a straightforward approach for approximating an environment in these optimization problems while accounting for uncertainty. However, I need to find relevant literature to gain a deeper understanding. I also have issues understanding what would be the policy in this case.&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, I would like to explore how these two approaches differ in terms of exploitation versus exploration. Intuitively, sampling a single trajectory as in scheme 1 suggests a greater emphasis on exploration compared to scheme 2, although one could argue the opposite as well. I am interested in reading more about this topic and exploring alternative approaches to address this challenge.&lt;/p&gt;&#xA;" OwnerUserId="11952" LastEditorUserId="491" LastEditDate="2023-06-09T11:58:26.817" LastActivityDate="2023-06-09T11:58:26.817" Title="Resource allocation problem - RL or stochastic optimization?" Tags="|stochastic-programming|stochastic-process|reinforcement-learning|optimal-control|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10548" PostTypeId="2" ParentId="10544" CreationDate="2023-06-08T18:17:57.447" Score="1" Body="&lt;p&gt;It seems right to me. If you want to maximise priority, you would have to sacrifice cost-wise. Hence, the costs goes up. If you want to minimise costs, you cannot select all the high-priority nodes, hence the total priority goes down. All the other solutions are non-dominated compromises between costs and priority.&lt;/p&gt;&#xA;&lt;p&gt;I haven’t used pymoo before, but it seems you are right that it converts &lt;span class=&quot;math-container&quot;&gt;$\max f(x)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$-\min -f(x)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2023-06-08T18:17:57.447" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10549" PostTypeId="2" ParentId="10544" CreationDate="2023-06-08T23:17:16.110" Score="1" Body="&lt;p&gt;I don't know how pymoo works under the hood but the moment you are minimizing something like &lt;span class=&quot;math-container&quot;&gt;$g(x) = c^Tx - p^Tx $&lt;/span&gt; without any scaling or hierarchial factor, it would minimize the whole func.&lt;br /&gt;&#xA;Rather you choose to &lt;span class=&quot;math-container&quot;&gt;$z= \min -p^Tx$&lt;/span&gt; separately along with the constraint &amp;amp; then minimize the cost with &lt;span class=&quot;math-container&quot;&gt;$z \ge -p^Tx$&lt;/span&gt; as additional constraint with the country selection one.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-06-08T23:17:16.110" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10550" PostTypeId="1" CreationDate="2023-06-09T02:16:04.297" Score="2" ViewCount="77" Body="&lt;p&gt;I have a constraint of the following form&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;x^{\top}x + y^{\top}y \leq t&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where x, y are vector variables and t is a scalar variable. I can augment the variables x and y, create a variable z and write it as a rotated second order cone constraint: &lt;span class=&quot;math-container&quot;&gt;$(1/2, t, z) \in \mathcal{Q}_r$&lt;/span&gt;. However, that is not the motivation, and I want to understand when it is alright to use an epigraph formulation with quadratic constraints, and so I will instead rewrite the constraint as follows&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{aligned}&#xA;\theta_1 + \theta_2 &amp;amp;= t \newline&#xA;x^{\top}x &amp;amp;\leq \theta_1 \newline&#xA;y^{\top}y &amp;amp;\leq \theta_2 \newline&#xA;\end{aligned}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If there exists a solution to the second system of equations, then the first inequality must hold. However, the second formulation is a relaxation of the first, where I have replaced equalities with inequalities. It is not clear if such &lt;span class=&quot;math-container&quot;&gt;$\theta_1, \theta_2$&lt;/span&gt; where the quadratic inequalities bind, exist.&lt;/p&gt;&#xA;&lt;p&gt;On a similar note I have a slightly different convex quadratic inequality with &lt;span class=&quot;math-container&quot;&gt;$t \neq 0$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;x^{\top}x + a^{\top}x + b \leq t&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; are constants. I can write it as a rotated second order cone constraint: &lt;span class=&quot;math-container&quot;&gt;$(1/2, t -b - a^{\top} x, x) \in \mathcal{Q}_r$&lt;/span&gt;.  However, once again that is not the motivation, and I want to understand when it is valid to use an epigraph formulation with simple and complex quadratic constraints,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{aligned}&#xA;\theta_3 + a^{\top}x + b &amp;amp;= t \newline&#xA;x^{\top}x &amp;amp;\leq \theta_3&#xA;\end{aligned}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3496" LastEditorUserId="491" LastEditDate="2023-06-09T03:11:35.603" LastActivityDate="2023-06-09T11:49:50.183" Title="epigraphs for quadratic constraints" Tags="|constraint|convex-optimization|quadratic-programming|socp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10551" PostTypeId="2" ParentId="10544" CreationDate="2023-06-09T08:28:01.553" Score="1" Body="&lt;p&gt;Pymoo always &lt;a href=&quot;https://pymoo.org/interface/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;minimize&lt;/a&gt; so, as you did, it is needed to convert &lt;em&gt;max priority&lt;/em&gt; to &lt;em&gt;min -priority&lt;/em&gt;. If your results are expressed in terms of &lt;em&gt;priority&lt;/em&gt; instead of &lt;em&gt;-priority&lt;/em&gt;, and sorted in base of the first column, you have:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Cost&lt;/th&gt;&#xA;&lt;th&gt;Priority&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2365.51796736&lt;/td&gt;&#xA;&lt;td&gt;346&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;2366.60434547&lt;/td&gt;&#xA;&lt;td&gt;347&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3004.5990833&lt;/td&gt;&#xA;&lt;td&gt;383&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3004.5990833&lt;/td&gt;&#xA;&lt;td&gt;383&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3383.5413055&lt;/td&gt;&#xA;&lt;td&gt;398&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3447.82173955&lt;/td&gt;&#xA;&lt;td&gt;399&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;3826.76396175&lt;/td&gt;&#xA;&lt;td&gt;414&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;4400.71535067&lt;/td&gt;&#xA;&lt;td&gt;426&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;5397.57485522&lt;/td&gt;&#xA;&lt;td&gt;437&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Which looks like the right result. Better cost results (ie, lesser costs) imply worse priority results (ie, lesser priority) and viceversa.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2023-06-09T08:28:01.553" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10552" PostTypeId="2" ParentId="10550" CreationDate="2023-06-09T11:49:50.183" Score="1" Body="&lt;p&gt;You can establish equivalence between two sets of constraints by showing that any solution to one set of constraints can be mapped to a solution of the other set of constraints. For instance, if I were to show equivalence of&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(1)\quad t \geq \theta_1 + \theta_2,\;\; \theta_1 \geq x^T x,\;\; \theta_2 \geq y^T y&#xA;$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(2)\quad t = \theta_1 + \theta_2,\;\; \theta_1 \geq x^T x,\;\; \theta_2 \geq y^T y&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would argue that a solution to (2) is always valid in (1), and that a solution to (1) can be mapped to a solution to (2) by following the search direction &lt;span class=&quot;math-container&quot;&gt;$\Delta \theta_1 = 1$&lt;/span&gt; (this relies on &lt;span class=&quot;math-container&quot;&gt;$\theta_1$&lt;/span&gt; not appearing anywhere else in the model and hence not affecting the objective function either).&lt;/p&gt;&#xA;&lt;p&gt;The other ingredient you need to reformulate a constraint such as &lt;span class=&quot;math-container&quot;&gt;$t \geq x^T x + y^T y$&lt;/span&gt; is that of &lt;em&gt;function composition&lt;/em&gt;. First note that the following reformulation holds in general,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;t \geq f(g(x)) \quad \Longleftrightarrow \quad t \geq f(\theta_1),\;\; \theta_1 = g(x),&#xA;$$&lt;/span&gt;&#xA;and can be used on your example with &lt;span class=&quot;math-container&quot;&gt;$g(x) = x^T x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f(g) = g + y^T y$&lt;/span&gt;. The issue with this reformulation is that it does not preserve convexity and hence is undesirable in practice. Fortunately, research has gone into characterizing convex relaxations of the decomposed nonconvex form. If, for example, you apply the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/practical.html#composite-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;MOSEK cookbook on function composition&lt;/a&gt; on your example, you find that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$t \geq f(\theta_1),\;\; \theta_1 \geq g(x)$$&lt;/span&gt;&#xA;is a convex relaxation because &lt;span class=&quot;math-container&quot;&gt;$f(\theta_1) = \theta_1 + y^T y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g(x) = x^T x$&lt;/span&gt; are convex functions, and that this relaxation is actually an exact representation because &lt;span class=&quot;math-container&quot;&gt;$f(\theta_1)$&lt;/span&gt; is nondecreasing on the range of &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="198" LastActivityDate="2023-06-09T11:49:50.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10553" PostTypeId="1" CreationDate="2023-06-09T12:06:22.627" Score="0" ViewCount="550" Body="&lt;p&gt;Here's my attempt to implement the clarke and wright algorithm with the following constraints: maximum truck capacity, maximum distance traveled by a truck.&lt;/p&gt;&#xA;&lt;p&gt;The algorithm takes a distance matrix to calculate the distance between two nodes, and a weights array, in which each element is the demand -weight- of a specific node.&lt;/p&gt;&#xA;&lt;p&gt;The code seems to work fine with the predefined variables,- max_distance, max_capacity..&#xA;but once I want to try with other values it either prints the same routes, or false ones.&lt;/p&gt;&#xA;&lt;p&gt;You can check and test the live code here: &lt;a href=&quot;https://onlinegdb.com/tEG0oyBr-&quot; rel=&quot;nofollow noreferrer&quot;&gt;LINK TO LIVE CODE&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&lt;p&gt;Here's the complete code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;&#xA;# Maximum capacity of the vehicle&#xA;max_capacity = 100&#xA;&#xA;# Maximum travel distance of the vehicle&#xA;max_distance = 500&#xA;&#xA;# Index of the depot node&#xA;depot = 0&#xA;&#xA;# Weight of each node&#xA;weights = [42, 16, 32, 1, 21, 29, 27, 50, 46]&#xA;&#xA;# Distance matrix representing the distances between nodes&#xA;distance_matrix = np.array([[0, 50, 50, 80, 60, 45, 80, 35, 105],&#xA;                           [50, 0, 30, 45, 65, 80, 120, 55, 110],&#xA;                           [50, 30, 0, 80, 90, 90, 105, 35, 75],&#xA;                           [80, 45, 80, 0, 45, 85, 155, 95, 150],&#xA;                           [60, 65, 90, 45, 0, 45, 130, 95, 150],&#xA;                           [45, 80, 90, 85, 45, 0, 95, 75, 140],&#xA;                           [80, 120, 105, 155, 130, 95, 0, 75, 100],&#xA;                           [35, 55, 35, 95, 95, 75, 75, 0, 70],&#xA;                           [105, 110, 75, 150, 150, 140, 100, 70, 0]])&#xA;&#xA;# Savings dictionary to store the savings for each pair of nodes&#xA;savings = dict()&#xA;&#xA;# Number of nodes&#xA;n = distance_matrix.shape[0]&#xA;&#xA;# List to store the routes&#xA;routes = []&#xA;&#xA;# List to keep track of assigned nodes&#xA;&#xA;assigned_nodes = []&#xA;&#xA;# List to keep track of assigned pairs of nodes&#xA;assigned_pairs = []&#xA;&#xA;# Calculate savings&#xA;for i in range(1, n):&#xA;        for j in range(1, n):&#xA;            if i != j:&#xA;                key = (i, j)&#xA;                savings[key] = distance_matrix[0][i] + distance_matrix[0][j] - distance_matrix[i][j]&#xA;                &#xA;# Sort savings&#xA;sorted_savings = sorted(savings.items(), key=lambda x: x[1], reverse=True)&#xA;&#xA;&#xA;# Create the first route with the first node in the sorted savings array&#xA;key, value = sorted_savings[0]&#xA;node1, node2 = key&#xA;first_route = [0, 0]&#xA;&#xA;if distance_matrix[depot][node1] &amp;lt; max_distance and weights[node1] &amp;lt; max_capacity:&#xA;    assigned_nodes.append(node1)&#xA;    first_route.insert(1, node1)&#xA;    routes.append(first_route)&#xA;    &#xA;    &#xA;# Loop through the sorted savings&#xA;for key, value in sorted_savings:&#xA;    node1, node2 = key&#xA;    &#xA;    # Check if either node of the pair is already assigned to a route&#xA;    for route in routes:&#xA;        if node1 in route or node2 in route:&#xA;            if (node1 in route and not node2 in assigned_nodes) and not ([node1, node2] in assigned_pairs or [node2, node1] in assigned_pairs):&#xA;                if node1 == route[1] or node1 == route[len(route)-2]:&#xA;                    # Check if the node can be inserted at the beginning or end of the route&#xA;                    if node1 == route[1]:&#xA;                        if sum(distance_matrix[depot][node] for node in route )+ distance_matrix[node1][node2] + distance_matrix[node2][depot] &amp;lt; max_distance\&#xA;                            and sum(weights[node] for node in route) + weights[node2]:&#xA;                                node1_index = route.index(node1)&#xA;                                route.insert(node1_index, node2)&#xA;                                assigned_nodes.append(node2)&#xA;                                assigned_pairs.append([node1, node2])&#xA;                    elif node1 == route[len(route)-2]:&#xA;                            if sum(distance_matrix[depot][node] for node in route )+ distance_matrix[node1][node2] + distance_matrix[node2][depot] &amp;lt; max_distance\&#xA;                            and sum(weights[node] for node in route) + weights[node2]:&#xA;                                node1_index = route.index(node1) + 1&#xA;                                route.insert(node1_index, node2)&#xA;                                assigned_nodes.append(node2)&#xA;                                assigned_pairs.append([node1, node2])&#xA;                                &#xA;                else: &#xA;                    new_route = [0, node2, 0]&#xA;                    routes.append(new_route)&#xA;                    &#xA;            # Create a new route with the node if it cannot be added to an existing route&#xA;            elif (node2 in route and not node1 in assigned_nodes) and not ([node1, node2] in assigned_pairs or [node2, node1] in assigned_pairs):&#xA;                # Check if the other node of the pair can be inserted into the route&#xA;                if node2 == route[1] or node2 == route[len(route)-2]:&#xA;                    if node2 == route[1]:&#xA;                        if sum(distance_matrix[depot][node] for node in route )+ distance_matrix[node2][node1] + distance_matrix[node1][depot] &amp;lt; max_distance\&#xA;                            and sum(weights[node] for node in route) + weights[node1]:&#xA;                            node2_index = route.index(node2)&#xA;                            route.insert(node2_index, node1)&#xA;                            assigned_nodes.append(node1)&#xA;                            assigned_pairs.append([node2, node1])&#xA;                            &#xA;                    elif node2 == route[len(route)-2]:&#xA;                            if sum(distance_matrix[depot][node] for node in route )+ distance_matrix[node2][node1] + distance_matrix[node1][depot] &amp;lt; max_distance\&#xA;                            and sum(weights[node] for node in route) + weights[node1]:&#xA;                                node2_index = route.index(node2) + 1&#xA;                                route.insert(node2_index, node1)&#xA;                                assigned_nodes.append(node1)&#xA;                                assigned_pairs.append([node2, node1])&#xA;                else: &#xA;                    # Create a new route with the node if it cannot be added to an existing route&#xA;                    new_route = [0, node1, 0]&#xA;                    routes.append(new_route)&#xA;                    assigned_nodes.append(node1)&#xA;                    &#xA;    # Check if both nodes of the pair are unassigned and can be inserted into a new route&#xA;    if (not node1 in route and not node2 in route ) and (not node1 in assigned_nodes and not node2 in assigned_nodes) \&#xA;        and not ([node1, node2] in assigned_pairs or [node2, node1] in assigned_pairs):&#xA;        if distance_matrix[depot][node1] + distance_matrix[node1][node2] + distance_matrix[node2][depot] &amp;lt; max_distance\&#xA;            and weights[node1] + weights[node2] &amp;lt; max_capacity:&#xA;            new_route = [0, node1, node2, 0]&#xA;            routes.append(new_route)&#xA;            assigned_nodes.append(node1)&#xA;            assigned_nodes.append(node2)&#xA;            assigned_pairs.append([node1, node2])&#xA;            &#xA;# Print the routes&#xA;for route in routes:&#xA;    i = routes.index(route)&#xA;    result = &amp;quot; -&amp;gt; &amp;quot;.join(str(x) for x in route)&#xA;    print(f&amp;quot;Route {i + 1}: {result}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3806" LastEditorUserId="491" LastEditDate="2023-06-09T13:59:14.270" LastActivityDate="2023-06-09T13:59:14.270" Title="VRP - Clarke and Wright implementation in python unable to find routes" Tags="|python|vehicle-routing|heuristics|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10555" PostTypeId="2" ParentId="10334" CreationDate="2023-06-09T19:28:37.817" Score="3" Body="&lt;p&gt;A partial answer to part (ii) of your question (this was too long for a comment so I'm including it as an answer). Note that the following assumes a &lt;em&gt;minimal&lt;/em&gt; cover.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;em&gt;sequence independent&lt;/em&gt; lifting procedure due to Gu, Nemhauser, Savelsbergh (&amp;quot;Sequence Independent Lifting in Mixed Integer Programming&amp;quot;, Journal of Combinatorial Optimization, 2000) produces a cut that is at least as strong as the corresponding extended cover inequality. Indeed, all variables with weight at least &lt;span class=&quot;math-container&quot;&gt;$a_1 - \lambda + \rho_1$&lt;/span&gt; have a lifting coefficient of at least &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. Here, &lt;span class=&quot;math-container&quot;&gt;$a_1$&lt;/span&gt; is the weight of the heaviest item in the minimal cover, &lt;span class=&quot;math-container&quot;&gt;$\lambda = \sum_{j\in C}a_j - b$&lt;/span&gt; is the excess of the cover, and &lt;span class=&quot;math-container&quot;&gt;$\rho_1 = \max\{0, a_2 - (a_1 -\lambda)\}$&lt;/span&gt; is the excess of the cover if the heaviest item was replaced by a copy of the 2nd heaviest item. By definition &lt;span class=&quot;math-container&quot;&gt;$\rho_1\le\lambda$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$a_1 - \lambda+\rho_1\le a_1$&lt;/span&gt;, so all variables with weight at least &lt;span class=&quot;math-container&quot;&gt;$a_1$&lt;/span&gt; have a lifting coefficient of at least &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, so this (weakly) dominates the extended cover cut.&lt;/p&gt;&#xA;" OwnerUserId="11959" LastActivityDate="2023-06-09T19:28:37.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10556" PostTypeId="2" ParentId="10502" CreationDate="2023-06-10T11:50:18.557" Score="2" Body="&lt;p&gt;The issue you have is that your output variables list has objects of different types that have different interfaces to access their data. The objects that are a kind of &lt;code&gt;Set&lt;/code&gt; are the ones that give the warning about index access, and in fact shouldn't be accessed in this way.&lt;/p&gt;&#xA;&lt;p&gt;When you iterate over the &lt;code&gt;Set&lt;/code&gt; objects, you get the items in the set. When you iterate over &lt;code&gt;Var&lt;/code&gt; or &lt;code&gt;Param&lt;/code&gt; objects, you get their index values.&lt;/p&gt;&#xA;&lt;p&gt;To correct the part of your code that you are struggling with, I suggest the following to build &lt;code&gt;optimal_values_list&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;optimal_values_list = []&#xA;for model_item in outputVariables_list:&#xA;    if isinstance(model_item, Union[pyo.Set, pyo.RangeSet]) :&#xA;        optimal_values_list.append(list(model_item))&#xA;    else:&#xA;        optimal_values_list.append([pyo.value(model_item[k]) for k in model_item.index_set()])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Another approach to getting Pyomo variable and parameter values into a pandas &lt;code&gt;DataFrame&lt;/code&gt; can be found in &lt;a href=&quot;https://stackoverflow.com/a/67494352&quot;&gt;https://stackoverflow.com/a/67494352&lt;/a&gt;. Without much work, you can extend the idea to also get parameters, expressions, sets, etc.&lt;/p&gt;&#xA;" OwnerUserId="11962" LastActivityDate="2023-06-10T11:50:18.557" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10557" PostTypeId="2" ParentId="323" CreationDate="2023-06-10T15:49:17.790" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://www.or.uni-bonn.de/%7Ehougardy/HardTSPInstances.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hard to Solve Instances of the Euclidean Traveling Salesman Problem&lt;/a&gt; provides awhole class of hard to solve small instances for the planar Euclidean TSP; the are also downloadable instances.&lt;/p&gt;&#xA;" OwnerUserId="11963" LastActivityDate="2023-06-10T15:49:17.790" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10558" PostTypeId="1" AcceptedAnswerId="10578" CreationDate="2023-06-11T08:14:48.153" Score="1" ViewCount="120" Body="&lt;p&gt;One approach to solving NP-hard problems is to use an &lt;a href=&quot;https://en.wikipedia.org/wiki/Anytime_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;anytime algorithm&lt;/a&gt;: an algorithnm that starts with a heuristic solution and keeps improving it towards the optimum, and when it is stopped, it returns the best solution found so far. For example, the &lt;a href=&quot;https://en.wikipedia.org/wiki/Greedy_number_partitioning#Complete_greedy_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;complete greedy algorithm&lt;/a&gt; is an anytime algorithm for number partitioning.&lt;/p&gt;&#xA;&lt;p&gt;My question is: is there a generic integer linear programming solver, that works in this &amp;quot;anytime&amp;quot; manner?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2023-06-14T09:17:15.240" Title="Anytime solver for integer linear program" Tags="|integer-programming|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10561" PostTypeId="1" CreationDate="2023-06-11T14:14:38.730" Score="-1" ViewCount="158" Body="&lt;p&gt;I am new to pyomo and I do have some smaller (or bigger) problems and hope someone can help me.  How can you create this variable in pyomo? I wanted to create it with pyo.Varlist() in which I pass every other variable with index, but that did not work.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_j \in \{0,1\}^{\vert D_j \vert}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;model.J = pyo.Set(&lt;span class=&quot;math-container&quot;&gt;$[1, ..., n]$&lt;/span&gt;), &lt;span class=&quot;math-container&quot;&gt;$j \in [1, ... ,n]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\vert D_j\vert \in [1, ...,m]$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="11965" LastEditorUserId="3883" LastEditDate="2023-06-11T20:34:28.683" LastActivityDate="2023-11-08T21:06:55.883" Title="creating individual Variables in pyomo with different length" Tags="|pyomo|binary-variable|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10562" PostTypeId="1" AcceptedAnswerId="10569" CreationDate="2023-06-11T17:39:03.553" Score="0" ViewCount="236" Body="&lt;p&gt;I have the following question / concern. I have a modeling problem with the decision variable &lt;span class=&quot;math-container&quot;&gt;$d_{ptm}$&lt;/span&gt; which indicates whether product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; was serviced by machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; in period &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. It takes the value 1 if so, and 0 otherwise. A product can be serviced by different machine in different periods. In addition, a product may not be serviced for two days and then again, possibly by a different machine.  I now want to introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt; that indicates such a switch in machines a product was serviced by. It should take the value = 1 if there was a machine switch from the last time a product was serviced till the current period. How can I model this? The constraints should not only create a lower bound, but also an upper bound. It should not be compared to the previous period, but to the time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; when the last time a product was serviced by a machine. In another &lt;a href=&quot;https://math.stackexchange.com/questions/4705317/modelling-a-shift-change&quot;&gt;thread&lt;/a&gt; I already found the solution for a switch compared to previous day, but I would like to have it compared to the last day with a machining. My idea would be to somehow remember the status, but I have no idea how to do it.&lt;/p&gt;&#xA;&lt;p&gt;My constraints so far (adopted from post mentioned above):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$d_{ptm}-d_{p(t+1)m}\le\rho_{p(t+1)} \\&#xA;d_{ptm}+d_{p(t+1)m}+\rho_{p(t+1)}\le 2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&#xA;Model shift change using &lt;span class=&quot;math-container&quot;&gt;$w_{ptm}$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;d_{ptm}+\sum_{j \neq m} w_{ptj}\le \rho_{pt}+1~&amp;amp;\forall p \in P, m\in M, t\in\{2,\ldots,T\}\\&#xA;&amp;amp;w_{ptm}+d_{ptm}+\rho_{pt}\le 2~&amp;amp;\forall p \in P, m\in M, t\in\{2,\ldots,T\}&#xA;\end{align}&lt;/span&gt;&#xA;Definition of &lt;span class=&quot;math-container&quot;&gt;$w_{ptm}$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;w_{ptm}\ge d_{p(t-1)m}~&amp;amp;\forall p\in P, m\in M, t\in\{2,\ldots,T\} \\&#xA;&amp;amp;w_{ptm}\ge w_{p(t-1)m}-\sum_{j \in M\setminus\left\{ m \right\}} d_{p(t-1)j} ~&amp;amp;\forall p\in P,m\in M, t\in\{2,\ldots,T\}\\&#xA;&amp;amp;\sum_m w_{ptm} = 1 ~&amp;amp;\forall p\in P, t\in \{2,\ldots,T\}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="11967" LastEditorUserId="11967" LastEditDate="2023-06-13T19:46:37.417" LastActivityDate="2023-06-14T14:57:00.597" Title="LP - How to model binary variable that indicates a switch" Tags="|linear-programming|modeling|constraint|binary-variable|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="10563" PostTypeId="1" CreationDate="2023-06-11T19:00:29.370" Score="1" ViewCount="64" Body="&lt;p&gt;This is probably one of those &amp;quot;just google it&amp;quot; kinds of questions, but is there a commonly-accepted &amp;quot;definitive&amp;quot; model in the literature for capturing the kind of matching problem that Uber faces, in (say) a Euclidean sense?  It seems that the significant problem attributes are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Customers arrive in the service region according to a (let's say uniform) spatiotemporal Poisson process.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Drivers have a fixed radius of customers that they can visit (ditto for customers).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There is a period of time between a customer requesting a ride and getting assigned to a driver, and there is a trade-off:&lt;/p&gt;&#xA;&lt;p&gt;a) If the assignment is instantaneous, then you have a greedy assignment policy which could be far from system-optimal.&lt;/p&gt;&#xA;&lt;p&gt;b) If the assignment takes a long time, then the assignment is probably quite good, but customers might leave the system due to impatience.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Can anyone suggest some &amp;quot;seminal&amp;quot; papers in this area?  I know it is subjective but am new to the field and trying to &amp;quot;see the forest for the trees&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="11969" LastEditorUserId="36" LastEditDate="2023-06-11T20:38:00.283" LastActivityDate="2023-06-12T09:18:50.707" Title="What are the most popular papers on Uber-type spatial matching?" Tags="|reference-request|vehicle-routing|matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10564" PostTypeId="2" ParentId="10561" CreationDate="2023-06-11T19:20:41.570" Score="0" Body="&lt;p&gt;This is the approach that I would take.  Having both an indexed set &lt;code&gt;m.J_K&lt;/code&gt; and its companion flat set will likely prove valuable in construction of constraints.&lt;/p&gt;&#xA;&lt;p&gt;Here is another &lt;a href=&quot;https://stackoverflow.com/questions/73996930/using-discontinuous-indices-for-pyomo-optimization/73997720#73997720&quot;&gt;example&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h4&gt;Code:&lt;/h4&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;&#xA;Dj_len = {1: 3,&#xA;          2: 2,&#xA;          3: 5,&#xA;          4: 1}&#xA;&#xA;m = pyo.ConcreteModel('example')&#xA;&#xA;m.J = pyo.Set(initialize=Dj_len.keys())&#xA;m.K = pyo.Set(initialize=range(1, max(Dj_len.values()) + 1))&#xA;&#xA;def J_K_init(m, j):&#xA;    return range(1, Dj_len[j]+1)&#xA;m.J_K = pyo.Set(m.J, initialize=J_K_init)&#xA;m.J_K_flat = pyo.Set(within = m.J * m.K, initialize=[(j, k) for j in m.J for k in m.J_K[j]])&#xA;&#xA;m.x = pyo.Var(m.J_K_flat, domain=pyo.Binary)&#xA;&#xA;m.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h4&gt;Output:&lt;/h4&gt;&#xA;&lt;pre&gt;&lt;code&gt;5 Set Declarations&#xA;    J : Size=1, Index=None, Ordered=Insertion&#xA;        Key  : Dimen : Domain : Size : Members&#xA;        None :     1 :    Any :    4 : {1, 2, 3, 4}&#xA;    J_K : Size=4, Index=J, Ordered=Insertion&#xA;        Key : Dimen : Domain : Size : Members&#xA;          1 :     1 :    Any :    3 : {1, 2, 3}&#xA;          2 :     1 :    Any :    2 : {1, 2}&#xA;          3 :     1 :    Any :    5 : {1, 2, 3, 4, 5}&#xA;          4 :     1 :    Any :    1 : {1,}&#xA;    J_K_flat : Size=1, Index=None, Ordered=Insertion&#xA;        Key  : Dimen : Domain          : Size : Members&#xA;        None :     2 : J_K_flat_domain :   11 : {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 1)}&#xA;    J_K_flat_domain : Size=1, Index=None, Ordered=True&#xA;        Key  : Dimen : Domain : Size : Members&#xA;        None :     2 :    J*K :   20 : {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5)}&#xA;    K : Size=1, Index=None, Ordered=Insertion&#xA;        Key  : Dimen : Domain : Size : Members&#xA;        None :     1 :    Any :    5 : {1, 2, 3, 4, 5}&#xA;&#xA;1 Var Declarations&#xA;    x : Size=11, Index=J_K_flat&#xA;        Key    : Lower : Value : Upper : Fixed : Stale : Domain&#xA;        (1, 1) :     0 :  None :     1 : False :  True : Binary&#xA;        (1, 2) :     0 :  None :     1 : False :  True : Binary&#xA;        (1, 3) :     0 :  None :     1 : False :  True : Binary&#xA;        (2, 1) :     0 :  None :     1 : False :  True : Binary&#xA;        (2, 2) :     0 :  None :     1 : False :  True : Binary&#xA;        (3, 1) :     0 :  None :     1 : False :  True : Binary&#xA;        (3, 2) :     0 :  None :     1 : False :  True : Binary&#xA;        (3, 3) :     0 :  None :     1 : False :  True : Binary&#xA;        (3, 4) :     0 :  None :     1 : False :  True : Binary&#xA;        (3, 5) :     0 :  None :     1 : False :  True : Binary&#xA;        (4, 1) :     0 :  None :     1 : False :  True : Binary&#xA;&#xA;6 Declarations: J K J_K J_K_flat_domain J_K_flat x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3883" LastActivityDate="2023-06-11T19:20:41.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10565" PostTypeId="1" AcceptedAnswerId="10570" CreationDate="2023-06-12T09:01:15.783" Score="3" ViewCount="128" Body="&lt;p&gt;I am currently working with inventory fluctuation data for a company and facing some issues. The raw data is stored in an xls file, recorded on a monthly basis. According to the logic, the sum of the beginning balance and the increase minus the consumption should be equal to the ending balance for each month.&lt;/p&gt;&#xA;&lt;p&gt;However, due to poor management, there are discrepancies between the data, causing the above equation to not hold true. My goal is to find a corrective value for each row of data through optimization, ensuring that the adjusted inventory fluctuation table satisfies the mentioned equation.&lt;/p&gt;&#xA;&lt;p&gt;I have an Excel file containing the original data with the following structure:&lt;/p&gt;&#xA;&lt;p&gt;Column 1: Item code&#xA;Column 2: Item name&#xA;Column 3: Initial balance&#xA;Starting from Column 4, every three columns represent the increase, decrease, and ending balance for each month. The ending balance of each month becomes the beginning balance for the next month.&#xA;The xls file includes hundreds of rows of inventory item data and records for nearly 50 months.&#xA;I need to find corrective values that meet the following objectives:&lt;/p&gt;&#xA;&lt;p&gt;1、Some corrective values must be integers, as certain inventory items cannot exist in decimal form, such as televisions.&#xA;2、Other corrective values can be decimals, for example, a cable length of 20.5 meters.&lt;/p&gt;&#xA;&lt;p&gt;Additionally, I could annotate the unit of measurement for each project's corrective value, such as precision to 0.1 or precision to 1.&lt;/p&gt;&#xA;&lt;p&gt;While satisfying the above objectives, I aim to minimize the absolute value of each corrective value to minimize adjustments to the original data.&lt;/p&gt;&#xA;&lt;p&gt;My current challenge is determining which algorithm to use to solve the mentioned problem.&lt;/p&gt;&#xA;" OwnerUserId="11971" LastEditorUserId="491" LastEditDate="2023-06-12T19:22:06.883" LastActivityDate="2023-06-12T19:22:06.883" Title="Seeking Help: Algorithm Recommendations for Inventory Data Adjustment" Tags="|inventory|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10566" PostTypeId="2" ParentId="10563" CreationDate="2023-06-12T09:18:50.707" Score="1" Body="&lt;p&gt;I advise you to look at the following paper. The authors look at pure online strategies where a decision is made instantly but also look at re-optimization strategies.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Bertsimas, D., Jaillet, P., &amp;amp; Martin, S. (2019). Online Vehicle&#xA;Routing: The Edge of Optimization in Large-Scale Applications.&#xA;Operations Research, 67(1), 143–162. doi:10.1287/opre.2018.1763&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2023-06-12T09:18:50.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10567" PostTypeId="1" CreationDate="2023-06-12T11:18:06.713" Score="0" ViewCount="64" Body="&lt;p&gt;I have a primal problem that is a network-flow:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;min_x \sum_{a \in A} c_a x_a \\&#xA;\text{s.t.} \sum_{a \in A:n = v} X_{a}-\sum_{a \in A:n' = v} X_{a} = \begin{cases} \;\;\;1, \; v=n^{in} \\ -1, \; v=n^{out} \\ \;\;\;0, \; v \in V \setminus \{n_u^{in},n_u^{en}\} \end{cases}  \\&#xA;X_{0}+ \sum_{a\in A \setminus \{0\}} X_{a} = 1  \\&#xA;X_{a} \leq X_{e} \;\;\;\;\;\;\forall a\in A^{special}, e \in A^{special}_a \\&#xA;X_{a}\in \{0,1\} \;\;\;\;\forall a\in A \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first constraint is the continuity conservation, the second is that if it takes arc &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; it cannot take nothing else and constraint 3 means that if it takes an special arc &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, then all the arcs in &lt;span class=&quot;math-container&quot;&gt;$A_a$&lt;/span&gt; have to activate. And constraint 4 is the binary nature of the variable (which I can relax to be &lt;span class=&quot;math-container&quot;&gt;$\in [0,1]$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;The dual of this problem is (or I think it is):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max_{\pi} \pi_{n^{in}}^1 - \pi_{n^{out}}^1 + \pi^2 \\&#xA;\textbf{s.t.} \;\; \pi_{n^{in}}^1 - \pi_{n^{out}}^1 + \pi^2 + \pi^4_{0} \leq c_0 \\&#xA;\pi_{n^{in}}^1 - \pi_{n^{out}}^1 + \pi^2 + \pi^4_{0} \leq c_0 \\&#xA;\pi_{n^{in}}^1 - \pi_{n^{out}}^1 + \pi^2 - \sum_{e \in A^a} \pi^3_e  + \pi^4_{a} \leq c_a \;\; \forall a \in A^{special} \\&#xA;\pi_{n^{in}}^1 - \pi_{n^{out}}^1 + \pi^2 + \sum_{e \in A^{special}} \pi^3_e  + \pi^4_{a} \leq c_a \;\; \forall a \in A^{a} \\&#xA;\pi_{n^{in}}^1 - \pi_{n^{out}}^1 + \pi^2 + \sum_{e \in A^{special}} \pi^3_e  + \pi^4_{a} \leq c_a \;\; \forall a \in A \setminus A^{a} \setminus A^{special} \setminus \{0\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How do I interpret the dual constraints?&lt;/p&gt;&#xA;" OwnerUserId="7200" LastActivityDate="2023-06-12T11:18:06.713" Title="What the dual constraints mean?" Tags="|convex-optimization|network-flow|duality|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10569" PostTypeId="2" ParentId="10562" CreationDate="2023-06-12T14:52:10.667" Score="2" Body="&lt;p&gt;Following my hint, introduce a binary decision variable &lt;span class=&quot;math-container&quot;&gt;$s_{ptm}$&lt;/span&gt; that indicates whether the last servicing of product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; in periods prior to &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; was on machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.  You want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\rho_{ptm} \iff \lnot s_{ptm} \land d_{ptm},$$&lt;/span&gt;&#xA;equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\rho_{ptm} = (1-s_{ptm}) d_{ptm},$$&lt;/span&gt;&#xA;which can be linearized in &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;the usual way&lt;/a&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\rho_{ptm} &amp;amp;\le 1-s_{ptm} &amp;amp;&amp;amp;\text{for all $p,t,m$} \\&#xA;\rho_{ptm} &amp;amp;\le d_{ptm} &amp;amp;&amp;amp;\text{for all $p,t,m$} \\&#xA;\rho_{ptm} &amp;amp;\ge (1-s_{ptm}) + d_{ptm} - 1 &amp;amp;&amp;amp;\text{for all $p,t,m$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It remains to enforce the definition of &lt;span class=&quot;math-container&quot;&gt;$s_{ptm}$&lt;/span&gt;.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{pt}$&lt;/span&gt; indicate whether no service is performed for product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_m d_{ptm} + x_{pt} = 1 \quad \text{for all $p,t$} $$&lt;/span&gt;&#xA;You want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$s_{p,t+1,m} \iff d_{ptm} \lor (s_{ptm} \land x_{pt}),$$&lt;/span&gt;&#xA;equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$s_{p,t+1,m} = d_{ptm} + s_{ptm} x_{pt},$$&lt;/span&gt;&#xA;which can be linearized as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;s_{p,t+1,m} &amp;amp;= d_{ptm} + y_{ptm} &amp;amp;&amp;amp;\text{for all $p,t\not=T,m$} \\&#xA;y_{ptm} &amp;amp;\le s_{ptm} &amp;amp;&amp;amp;\text{for all $p,t,m$} \\&#xA;y_{ptm} &amp;amp;\le x_{pt} &amp;amp;&amp;amp;\text{for all $p,t,m$} \\&#xA;y_{ptm} &amp;amp;\ge s_{ptm} + x_{pt} - 1 &amp;amp;&amp;amp;\text{for all $p,t,m$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;It is worth noting that network modeling provides a powerful framework for multiperiod situations like this where you want to capture pairwise interactions between decisions.  Let node &lt;span class=&quot;math-container&quot;&gt;$(p,t,m)$&lt;/span&gt; represent servicing of product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; on machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, and let a directed arc from &lt;span class=&quot;math-container&quot;&gt;$(p,t,m)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$(p,t',m')$&lt;/span&gt; represent that product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; was serviced at times &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t'$&lt;/span&gt; and no other times between &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t'$&lt;/span&gt;.  Now a servicing schedule for product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; corresponds to a path in the network. Your &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt; variable is then a sum of arc variables for which &lt;span class=&quot;math-container&quot;&gt;$m\not= m'$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-06-14T14:57:00.597" LastActivityDate="2023-06-14T14:57:00.597" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="10570" PostTypeId="2" ParentId="10565" CreationDate="2023-06-12T15:08:49.570" Score="3" Body="&lt;p&gt;You can solve an integer programming model for each item. Using the subscript &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; for month (with the initial inventory occurring in &amp;quot;month 0&amp;quot;) and letting &lt;span class=&quot;math-container&quot;&gt;$S_m,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$D_m$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$I_m$&lt;/span&gt; be respectively the supply, demand (consumption) and closing inventory in month &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; (all parameters), your inventory balance constraints for items that come in integer quantities (such as televisions) become &lt;span class=&quot;math-container&quot;&gt;$$I_{m-1} + x_{m-1} + S_m - D_m = I_m + x_m$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_m$&lt;/span&gt; is a free integer variable. &amp;quot;Free&amp;quot; means unrestricted in sign (can be positive or negative). For an item like cable, decide on the precision &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; with which it is measured and multiple &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; by &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; on both sides of the constraint. For instance, if cable is sold in multiples of six inches and the data is recorded in feet, &lt;span class=&quot;math-container&quot;&gt;$p=0.5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the number of half-foot adjustments.&lt;/p&gt;&#xA;&lt;p&gt;In the objective function, you want to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_m \vert x_m \vert.$&lt;/span&gt; Since we cannot use absolute value directly, we introduce a second (continuous, nonnegative) variable &lt;span class=&quot;math-container&quot;&gt;$y_m$&lt;/span&gt; for each month and minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_m y_m.$&lt;/span&gt; We add the constraints &lt;span class=&quot;math-container&quot;&gt;$x_m \le y_m$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$-x_m \le y_m$&lt;/span&gt; for each month, which makes &lt;span class=&quot;math-container&quot;&gt;$y_m = \vert x_m \vert$&lt;/span&gt; in the solution.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-06-12T15:08:49.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10571" PostTypeId="1" CreationDate="2023-06-12T23:04:28.213" Score="-1" ViewCount="64" Body="&lt;p&gt;I am trying to write a model where I have to distribute fractions of rent from properties to loans. The objective is to distribute the rents as equally as possible given the loan balance.&lt;/p&gt;&#xA;&lt;p&gt;Say there are 5 properties and 8 loans, I have 40 variables X11, X12, X13....X18; X21, X22, X23...X28;......; X51, X52,..X58&lt;/p&gt;&#xA;&lt;p&gt;Loan Balances are L1, L2, L3, L4 ...L8&#xA;Rents from properties are R1,R2, R3, R4 and R5&lt;/p&gt;&#xA;&lt;p&gt;So Minimize (&#xA;Absolute Value (R1 &lt;em&gt;X11/L1 + R2&lt;/em&gt;X21/L1 + R3&lt;em&gt;X31/L1 +R4&lt;/em&gt;X41/L1 +R5&lt;em&gt;X51/L1 - AverageRentLoanRatio) + Abolute Value (R1 &lt;em&gt;X12/L2 + R2&lt;/em&gt;X22/L2 + R3&lt;/em&gt;X32/L2 +R4&lt;em&gt;X42/L2 +R5&lt;/em&gt;X52/L2 - AverageRentLoanRatio)+ Abolute Value (R1 &lt;em&gt;X13/L3 + R2&lt;/em&gt;X23/L3 + R3&lt;em&gt;X33/L3 +R4&lt;/em&gt;X43/L3 +R5&lt;em&gt;X53/L3 - AverageRentLoanRatio)+ Abolute Value (R1 &lt;em&gt;X14/L4 + R2&lt;/em&gt;X24/L4 + R3&lt;/em&gt;X34/L4 +R4&lt;em&gt;X44/L4 +R5&lt;/em&gt;X54/L4 - AverageRentLoanRatio) + Abolute Value (R1 &lt;em&gt;X15/L5 + R2&lt;/em&gt;X25/L5 + R3&lt;em&gt;X35/L5 +R4&lt;/em&gt;X45/L5 +R5*X55/L5 - AverageRentLoanRatio))&lt;/p&gt;&#xA;&lt;p&gt;With Constraints such as a property cannot be allocated to a specific property and total rent is 100%&lt;/p&gt;&#xA;&lt;p&gt;I am able to define the constraints but struggling how to write the objective.&lt;/p&gt;&#xA;&lt;p&gt;Here is the model I have written so far&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using CSV&#xA;using DataFrames&#xA;C= CSV.read(&amp;quot;Property.csv&amp;quot;, DataFrame)&#xA;L = CSV.read(&amp;quot;LoanFile.csv&amp;quot;, DataFrame)&#xA;&#xA;&#xA;&#xA;using JuMP, GLPK&#xA;&#xA;# Preparing an optimization model&#xA;m = Model(GLPK.Optimizer)&#xA;&#xA;&#xA;#getting the number of properties and loans&#xA;index_i = 1:nrow(C)&#xA;index_j = 1:ncol(C)-2&#xA;&#xA;#setting the number of constraints&#xA;#index_constraints = 1:nrow(C)* (ncol(C)-2)&#xA;&#xA;# Declaring variables&#xA;@variable(m, x[index_i, index_j] &amp;gt;= 0)&#xA;&#xA;# Declaring bound Constraints&#xA;@constraint(m, conb[i=index_i, j=index_j],x[i, j] &amp;lt;= C[i,j+2])&#xA;&#xA;#Declaring total 100 % constraints&#xA;@constraint(m,cont[i=index_i],sum(x[i, j] * C[i,2] for j in index_j) &amp;lt;= C[i,2])&#xA;&#xA;# Setting the objective&#xA;Average_KDF  = sum(C[i,2] for i in 1:nrow(C))/sum(L[i,2] for i in 1:nrow(L))&#xA;&#xA;KDFratio = Array{Float64}(undef,nrow(C),ncol(C)-2)&#xA;KDFsumRatio = Array{Float64}(undef,nrow(L))&#xA;&#xA;&#xA;#@objective(m, Min,sum(abs((x[i, j] * C[i,2]/L[j,2]- Average_KDF) for j in index_j) for i in index_i)&#xA;# the above setting of objective is not working and I am struggling to formulate this.&#xA;  &#xA;&#xA;&#xA;# Printing the prepared optimization model&#xA;&#xA;print(m)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here are the files I am using for loans and properties&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|﻿LoanID  | Balance |&#xA;|L 1     |  100.00  |&#xA;|L 2     |  100.00  |&#xA;|L 3     |  300.00  |&#xA;|L 4     |  100.00  |&#xA;|L 5     |  50.00   |&#xA;|L 6     |  50.00   |&#xA;|L 7     |  50.00   |&#xA;|L 8     |  50.00   |&#xA;&#xA;&#xA;|﻿PropertyID  | Rent(R)  |L1|L2|L3|L4|L5|L6|L7|L8|&#xA;|P 1         |  5.00    | 1| 0| 0| 0| 0| 0| 0| 0|&#xA;|P 2         |  10.00   | 0| 1| 1| 0| 0| 0| 0| 0|&#xA;|P 3         |  1.5     | 1| 1| 0| 0| 0| 0| 0| 0|&#xA;|P 4         |  10.50   | 1| 1| 1| 1| 0| 0| 0| 0|&#xA;|P 5         |  20.00   | 0| 1| 0| 1| 0| 1| 0| 1|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11977" LastActivityDate="2023-06-13T02:00:42.240" Title="How to set an objective to minimize the variance in ratio of allocation" Tags="|optimization|linear-programming|constraint-programming|multi-objective-optimization|julia|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10572" PostTypeId="2" ParentId="10571" CreationDate="2023-06-13T01:42:49.967" Score="2" Body="&lt;p&gt;In case your solver doesn't provide a constraint to use absolute value like gurobi.absconstraint &amp;amp; since you have minimize as objective any &lt;span class=&quot;math-container&quot;&gt;$\vert x-c \vert $&lt;/span&gt; can be written with constraints as&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x-c \le y$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ c-x \le y$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ 0 \le y $&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x,y$&lt;/span&gt; are your variables with &lt;span class=&quot;math-container&quot;&gt;$y \in$&lt;/span&gt; same domain as &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then use &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in the objective.&lt;/p&gt;&#xA;&lt;p&gt;You can consult Cornell optimization &lt;a href=&quot;https://optimization.cbe.cornell.edu/index.php?title=Optimization_with_absolute_values&quot; rel=&quot;nofollow noreferrer&quot;&gt;helpsite&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Another way I saw somewhere, if linear expressions, with constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x-c = \mu^+ - \mu^-$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$0 \le \mu^+ , \mu^- $&lt;/span&gt;&lt;br /&gt;&#xA;Then use &lt;span class=&quot;math-container&quot;&gt;$ \mu^+ + \mu^-$&lt;/span&gt; in the objective.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-06-13T02:00:42.240" LastActivityDate="2023-06-13T02:00:42.240" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10573" PostTypeId="1" AcceptedAnswerId="10575" CreationDate="2023-06-13T13:43:50.790" Score="0" ViewCount="111" Body="&lt;h2&gt;Objective and short problem description&lt;/h2&gt;&#xA;&lt;p&gt;The objective is to load as many passenger vehicles as possible on an auto-train. The train consists of multiple wagons with two levels each. The wagons are connected to each other. Every vehicle has to enter the train from the rear on the upper or the lower level and drive all the way to its assigned position. Once it entered a level it can not be moved to the other level and once it is positioned the following vehicles cant be in front of the vehicle.&lt;/p&gt;&#xA;&lt;p&gt;The vehicles are parked very close to each other in one (first problem instance) or multiple (second instance) rows. We have to load the first vehicle before we load the second vehicle before we load the third vehicle and so on. If there are multiple rows we can always choose the currently first vehicle of each row.&lt;/p&gt;&#xA;&lt;p&gt;Multiple constraints limit the capacity of the train. Each wagon is constrained in terms of length. Both levels of a wagon are constrained in terms of weight and height. On the bottom level the entry and exit of the wagons are sloped. Because of that on the first and last position of each wagon the height is more limited than the height on the positions in between.&lt;/p&gt;&#xA;&lt;h2&gt;Modeling approach&lt;/h2&gt;&#xA;&lt;p&gt;I currently model the problem as an assignment problem due to the complex precedence constraints. The train has a number of Wagons and a number of positions &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; both levels (&lt;span class=&quot;math-container&quot;&gt;$W_l$&lt;/span&gt; are sub-sets of platforms that are on the lower (0) and upper level (1)). Each wagon has a maximum of 6 positions on both levels which I model by building multiple subsets &lt;span class=&quot;math-container&quot;&gt;$W \in P$&lt;/span&gt;. Any of the positions can remain empty.&lt;/p&gt;&#xA;&lt;p&gt;Weight and length constraints are very easy to implement by summing up lengths &amp;amp; weights of the vehicles &lt;span class=&quot;math-container&quot;&gt;$v \in V$&lt;/span&gt; on the positions &lt;span class=&quot;math-container&quot;&gt;$p \in W$&lt;/span&gt; over all the wagons. I model the height constraints with the help of auxiliary variables. In case the sum of the lengths of the vehicles on the lower level of a wagon is above a certain threshold, we have to account for the extra height of vehicle on the first position on the lower level of this wagon (which is now standing on a slope). If the sum is above a second threshhold we also have to consider the extra height due to the slope of the last position on the lower level of this wagon.&lt;/p&gt;&#xA;&lt;h2&gt;Question / Problem&lt;/h2&gt;&#xA;&lt;p&gt;I have implemented all of these constraints and they are working fine.&#xA;I have also successfully implemented the precedence constraints in case there is only a single row of vehicles:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For a single row for every vehicle &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; we build a set of pairs that models the precedence requirements for every vehicle according to the order in the row: v &amp;lt; u: &lt;span class=&quot;math-container&quot;&gt;$(v, u) \in A$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{pv}$&lt;/span&gt; is equal to 1, if vehicle &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is on position &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and 0, otherwise&lt;/p&gt;&#xA;&lt;p&gt;The two constraints I use that work are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{p\in W_l}px_{pv} \leq \sum\limits_{p\in W_l}px_{pu} + (1-\sum\limits_{p\in W_l}x_{pu})*M\quad \forall (v,u) \in A:W_{l\in 0/1}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{p\in P}x_{pv} \geq \sum\limits_{p\in P}x_{p(v+1)} \quad\forall v \in {0, ..., |V|-1}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The precedence constraints I want to model are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The train has to be loaded from the back to the front on both levels&lt;/li&gt;&#xA;&lt;li&gt;The vehicles are now parked in multiple rows and I can always only access the currently first vehicle in each row.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For example there are three rows with vehicles:&#xA;[0, 1, 2]&#xA;[3, 4, 5]&#xA;[6, 7, 8]&#xA;. 0 has to be loaded before 1, 1 before 2, 3 before 4, ...&lt;/p&gt;&#xA;&lt;p&gt;If I use the above constraints (1) and (2) I can only model the precedences within each single row. However, there is also a precedence that connects the different rows which is that I can always only load the currently first vehicle of each row.&lt;/p&gt;&#xA;&lt;p&gt;This problem becomes more clear if I show the result for the small example above:&lt;/p&gt;&#xA;&lt;p&gt;Top level Wagon 1: [0, &lt;strong&gt;4, 6&lt;/strong&gt;, 5], Wagon 2: [...], ...&lt;/p&gt;&#xA;&lt;p&gt;Bot level Wagon 1: [1, 2, &lt;strong&gt;7, 3&lt;/strong&gt;, 8], Wagon 2: [...], ...&lt;/p&gt;&#xA;&lt;p&gt;Vehicle 4 and 7 can not be loaded because neither 6 nor 3 are loaded. A correct result would be:&lt;/p&gt;&#xA;&lt;p&gt;Top level: [0, &lt;strong&gt;3, 6&lt;/strong&gt;, 5], Wagon 2: [...], ...&lt;/p&gt;&#xA;&lt;p&gt;Bot level: [1, 2, &lt;strong&gt;7, 4&lt;/strong&gt;, 8], Wagon 2: [...], ...&lt;/p&gt;&#xA;&lt;p&gt;I am searching for multiple days straight but can not figure out the right way to do it. My guess is that I somehow have to relate the predecessors of the vehicles between the rows.&lt;/p&gt;&#xA;" OwnerUserId="11981" LastEditorUserId="11981" LastEditDate="2023-06-15T11:44:08.503" LastActivityDate="2023-06-15T11:44:08.503" Title="Assignment problem with multiple precedence constraints" Tags="|mixed-integer-programming|integer-programming|scheduling|assignment-problem|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10575" PostTypeId="2" ParentId="10573" CreationDate="2023-06-13T22:03:43.087" Score="1" Body="&lt;p&gt;The following assumes that the &lt;span class=&quot;math-container&quot;&gt;$(v,u)\in A$&lt;/span&gt; precedence requirements have to do with the order cars are in a row and not something else (such as cars before trucks, heavy vehicles before light vehicles or whatever).&lt;/p&gt;&#xA;&lt;p&gt;I suggest using three sets of binary variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{w,v} \in \lbrace 0, 1 \rbrace$&lt;/span&gt; (1 if vehicle &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is loaded onto wagon &lt;span class=&quot;math-container&quot;&gt;$w\in \lbrace 1, \dots, W \rbrace$&lt;/span&gt;);&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{\ell,v}$&lt;/span&gt; (1 if vehicle &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is put on level &lt;span class=&quot;math-container&quot;&gt;$\ell \in \lbrace 0, 1 \rbrace$&lt;/span&gt;, 0 if not); and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{n,v}$&lt;/span&gt; (1 if vehicle &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-th vehicle taken, 0 if not).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$(v,u)\in A$&lt;/span&gt; signifies that &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is parked immediately behind &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; in the same row (whatever row that may be) and that all cars that are moved are taken (so if 4 is taken then 0 must be taken, not just moved off to the side), you can use the following constraints.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each vehicle is assigned at most one position: &lt;span class=&quot;math-container&quot;&gt;$\sum_n z_{n,v} \le 1.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Each position is assigned at most once: &lt;span class=&quot;math-container&quot;&gt;$\sum_v z_{n,v}\le 1.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Each vehicle is assigned to exactly one level if taken (and to neither level if not taken): &lt;span class=&quot;math-container&quot;&gt;$y_{0,v}+y_{1,v} = \sum_n z_{n,v}.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The position in which a vehicle is taken is greater than the position in which the vehicle in front of it is taken: &lt;span class=&quot;math-container&quot;&gt;$\sum_n (N - n)\cdot z_{n,v} \le \sum_n (N - n) \cdot z_{n,u}\ \ \forall (v,u)\in A.$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is the total number of vehicles. The somewhat indirect formulation is to allow for the possibility that &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt; is taken but &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is not.)&lt;/li&gt;&#xA;&lt;li&gt;If two vehicles &lt;span class=&quot;math-container&quot;&gt;$v \neq v'$&lt;/span&gt; are both loaded on the same level &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; in wagons &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w'$&lt;/span&gt; respectively, with &lt;span class=&quot;math-container&quot;&gt;$w &amp;lt; w'$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; must be taken before &lt;span class=&quot;math-container&quot;&gt;$v'$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;$\sum_n n\cdot z_{n,v} - \sum_n n \cdot z_{n,v'} \le N(4 - y_{\ell,v} - y_{\ell,v'} - x_{w,v} - x_{w',v'}).$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-06-14T21:56:36.967" LastActivityDate="2023-06-14T21:56:36.967" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10576" PostTypeId="2" ParentId="10573" CreationDate="2023-06-14T00:17:13.533" Score="0" Body="&lt;p&gt;Suppose vehicles &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; are currently parked in known matrix parameter &lt;span class=&quot;math-container&quot;&gt;$ S_{r,c}$&lt;/span&gt;&lt;br /&gt;&#xA;You can try along with your constrs (1) &amp;amp; (2):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{p \in W_l} x_{p,S_{r+1,c}} \le \sum_{p \in W_l}x_{p,S_{r,c}} \quad \forall r \in \{0,1,...r-1 \} \ \ \forall c $&lt;/span&gt;: Row &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; is inner loop&lt;/p&gt;&#xA;&lt;p&gt;If you define &lt;span class=&quot;math-container&quot;&gt;$ x_{p,v}$&lt;/span&gt; over vehicle set &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; and same are pre-defined for &lt;span class=&quot;math-container&quot;&gt;$ S_{r,c}$&lt;/span&gt; there's wont be any issues.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-06-14T00:17:13.533" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10577" PostTypeId="1" CreationDate="2023-06-14T06:02:41.057" Score="1" ViewCount="86" Body="&lt;p&gt;In this post there are already good answers:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/4347/how-to-convince-people-that-or-can-help-them&quot;&gt;How to convince people that OR can help them?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But I would like to expand a little bit on this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there any literature/blog posts/expert discussions on how to sell OR (or maybe in the broader context Data Science)? Especially&#xA;as a consultancy?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a structured approach to this? What works, what doesn't work? Are there any pitfalls?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What are tools that help to convince the client to make a project with you?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How to find a good trade-off between investment in new showcases vs figuring out if it actually sells?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;My thoughts regarding 2. and 3.:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For a similar project you have already done:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;a) Ask for a open reference (&amp;quot;So you can say we have done it a XXX&#xA;Company&amp;quot;). If not you need to tell is anonymously&lt;/p&gt;&#xA;&lt;p&gt;b) Try to access the monetary benefit in the old project (&amp;quot;We saved %&#xA;of money/time&amp;quot;)&lt;/p&gt;&#xA;&lt;p&gt;c) Try to build a anonymous showcase from the project&lt;/p&gt;&#xA;&lt;p&gt;d) For each potential new client, tweak the showcase that it could&#xA;fit for the client&lt;/p&gt;&#xA;&lt;p&gt;e) Try first companies in the same branch as the one in the initial&#xA;project, since they are most likely to have the same problem and there&#xA;the transfer is the easiest.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;For project you don't have done:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;a) Read about a common problem/Talk to domain experts&lt;/p&gt;&#xA;&lt;p&gt;b) Build a mockup (For example in powerpoint) to showcases the&#xA;frontend, such that the user can envision what the tool in the end&#xA;provides&lt;/p&gt;&#xA;&lt;p&gt;c) Build a showcase (As extension to the mockup, but this is&#xA;expensive)&lt;/p&gt;&#xA;&lt;p&gt;d) Calculate a business cases (But this is difficult to do without&#xA;data credibly)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Especially for projects you have not done. This is difficult and time intensive to build a material/showcases to convince the client.&lt;/p&gt;&#xA;" OwnerUserId="3305" LastActivityDate="2023-06-14T06:02:41.057" Title="How to sell OR (especially as a consultant company)?" Tags="|software|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10578" PostTypeId="2" ParentId="10558" CreationDate="2023-06-14T09:17:15.240" Score="1" Body="&lt;p&gt;All commercial software capable of finding multiple solutions in one run will return the &amp;quot;best found so far&amp;quot; if an early exit condition is met (e.g. interrupt).&lt;/p&gt;&#xA;&lt;p&gt;My solver for instance will even do that on CTRL+C.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2023-06-14T09:17:15.240" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10579" PostTypeId="1" AcceptedAnswerId="10602" CreationDate="2023-06-15T02:19:34.383" Score="5" ViewCount="215" Body="&lt;p&gt;In a project, I am working with constraints of the following type&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \frac{1}{2}{x}^\top Q x  + q^\top x + q_0 \leq 0 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where I randomly generate the data by (&lt;code&gt;randn&lt;/code&gt; stands for random standard normal sampling)&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-matlab prettyprint-override&quot;&gt;&lt;code&gt;q = randn(n)&#xA;Q = randn(n,n); Q = Q'*Q;&#xA;q0 = - 1.0 * n + randn();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, most of the time&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \left\{x \in \mathbb{R}^n \ : \ \frac{1}{2}{x}^\top Q x  + q^\top x + q_0 \leq 0  \right\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is not bounded. Hence, my optimization problems under this constraint are producing errors. Is there a way of randomly generating such data while ensuring that this feasible set stays bounded?&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="8" LastEditDate="2023-06-15T14:02:13.547" LastActivityDate="2023-06-21T08:10:26.617" Title="Randomly constructing a bounded ellipsoid" Tags="|quadratic-programming|feasible-points|julia|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10581" PostTypeId="1" CreationDate="2023-06-15T04:14:15.950" Score="1" ViewCount="241" Body="&lt;p&gt;I posted the same question on &lt;a href=&quot;https://stackoverflow.com/questions/76478872/best-algorithm-for-scheduling-interviews?noredirect=1#comment134849808_76478872&quot;&gt;stackoverflow&lt;/a&gt; and immediately referred to post it here.&lt;/p&gt;&#xA;&lt;p&gt;I want to think about the best algorithm which let the interviewer meet maximum number of candidates.&#xA;Suppose that there are n candidates and one interviewer. Each of interview will be held for a fixed time, so we can consider that each interview to be given a time slot. Number of time slots are given as m. All candidates are asked to submit whether they are available for each time slots.&#xA;If I put it in table format, it looks like this.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1: available&#xA;0: not available&#xA;&#xA;         Aoi   Banri  ...   Nami&#xA;slot 1    1      1    ...    0&#xA;slot 2    0      1    ...    1&#xA; .        .      .    .      .&#xA; .        .      .     .     .&#xA; .        .      .      .    .&#xA;slot m    0      1    ...    0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Possible approaches 1: solve as a matrix problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If I interpret this as a matrix problem, it would be reduced to find the Matrix X, expressed as a product of matrices with only one-to-one column exchange, that maximizes trace(AX). A is the schedule table.&lt;/p&gt;&#xA;&lt;p&gt;Is there any good way to do that?&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Possible approaches 2: solve as a algorithm problem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If one can think about the best algorithm which always produces best result, it does not necessarily be a matrix problem&#xA;One that comes to my mind will be something like that:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Find the candidate A which has minimum number of available time slots.&lt;/li&gt;&#xA;&lt;li&gt;Among the time slots when A is available, find the slot a which has minimum number of candidates who are possible to attend.&lt;/li&gt;&#xA;&lt;li&gt;Place A on slot a. Remove both from the table.&lt;/li&gt;&#xA;&lt;li&gt;Repeat above procedure for each candidates.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In the Python code format, it may look like this.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;d=[[Aoi, 1, 0, ..., 0&#xA;Banri, 1, 1, ..., 1&#xA;.&#xA;.&#xA;.&#xA;Nami,  0, 1, ..., 0&#xA;]]&#xA;&#xA;d_reserved=[]&#xA;&#xA;d_return=reserve_each(d, d_reserved)&#xA;&#xA;&#xA;def reserve_each(d, _reserved):&#xA;  d_summed = cal_sums(d) # add summ on rows and columns as the outermost row/column.&#xA;  d=d[np.argsort(d_summed[-1, :])]&#xA;&#xA;  for i in range(n):&#xA;    di=d[i,1:]&#xA;    if np.max(di) &amp;lt; 0.1:&#xA;      if i &amp;gt; 1:&#xA;        researve_each(d[i-1:, :], d[:i-1,:])&#xA;      else:&#xA;        # alert!!! perhaps goes random?&#xA;&#xA;    di=di[np.argmax(d[-1,1:]*d[i,1:])]&#xA;&#xA;    first = 1&#xA;    for dij in di:&#xA;      if dij == 1:&#xA;        dij = dij*first&#xA;        first = 0        &#xA;&#xA;    d[i,1:]=di&#xA;&#xA;  return np.concatenate(d_reserved, d, axis=1))    &#xA;&#xA;&#xA;def cal_sums(d):&#xA;  d=np.concatenate(d, np.sum(d[:, 1:], axis=1))&#xA;  d_summed=np.concatenate(d_sorted, [0, np.sum(d[1, 1:], axis=0)])&#xA;  return d_summed&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, I can think many ways this algorithm would fail or may not be provide the best answers.&#xA;I would be happy if anyone facing similar problem knows better ways to do that.&lt;/p&gt;&#xA;" OwnerUserId="11989" LastEditorUserId="491" LastEditDate="2023-06-23T12:37:58.097" LastActivityDate="2023-06-23T12:37:58.097" Title="Best algorithm for scheduling interviews" Tags="|optimization|scheduling|algorithms|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10582" PostTypeId="1" AcceptedAnswerId="10583" CreationDate="2023-06-15T08:20:44.833" Score="2" ViewCount="135" Body="&lt;p&gt;I want to create a transportation model. I have identified importing and exporting countries with their estimated demand and supply. The cost of transportation per one uni is already calculated for each ex- and importer. Some exporters transport the hydrogen by ship and others by pipeline.&lt;/p&gt;&#xA;&lt;p&gt;The problem I have is that I need to introduce losses when it is transported by ship. About 20% is lost and won't reach the importer. For pipeline transport there is no losses. I am having trouble to implement this into the objective function or the constraints. Is there a way to integrate this into the model?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yEnFM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yEnFM.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user11991" LastEditorDisplayName="user11991" LastEditDate="2023-08-17T12:58:50.887" LastActivityDate="2023-08-17T12:58:50.887" Title="Transportation Problem" Tags="|optimization|linear-programming|modeling|network-flow|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10583" PostTypeId="2" ParentId="10582" CreationDate="2023-06-15T09:11:09.793" Score="2" Body="&lt;p&gt;You can add an index to the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables to indicate whether transport is via pipeline or by ship: &lt;span class=&quot;math-container&quot;&gt;$x_{ij}^k$&lt;/span&gt; denotes the quantity shipped on link &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; via transport mode &lt;span class=&quot;math-container&quot;&gt;$k\in\{\mbox{pipeline, ship}\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The problem becomes:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \sum_k\sum_i\sum_jc_{ij}^kx_{ij}^k &#xA;$$&lt;/span&gt;&#xA;subject to&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;supply constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_k\sum_jx_{ij}^k \le a_i \quad \forall i \tag{1}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;demand constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_k\sum_ix_{ij}^k \ge b_j \quad \forall j \tag{2}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To take into account &lt;span class=&quot;math-container&quot;&gt;$20\%$&lt;/span&gt; loss when transported by ship, you can consider that a dummy copy of node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; absorbs the &lt;span class=&quot;math-container&quot;&gt;$20\%$&lt;/span&gt; loss. Constraints &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; should be modified as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_k\sum_ix_{ij}^k \ge b_j + 0.2\sum_ix_{ij}^{\mbox{ship}}\quad \forall j \tag{3}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, as proposed by @Sune, you could simply say that only &lt;span class=&quot;math-container&quot;&gt;$80\%$&lt;/span&gt; of the shipped quantity reaches the destination:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_ix_{ij}^{\mbox{pipeline}} + 0.8\sum_ix_{ij}^{\mbox{ship}} \ge b_j \quad \forall j \tag{4}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Both constraints are of course equivalent, as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_k\sum_ix_{ij}^k = \sum_ix_{ij}^{\mbox{pipeline}} +0.8\sum_ix_{ij}^{\mbox{ship}} +0.2\sum_ix_{ij}^{\mbox{ship}} \tag{5}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-06-15T13:17:03.230" LastActivityDate="2023-06-15T13:17:03.230" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10584" PostTypeId="2" ParentId="10581" CreationDate="2023-06-15T10:48:41.727" Score="2" Body="&lt;p&gt;You can model your problem as ILP and implement it e.g., in Pythons PuLP library and solve it with commercial solvers (e.g., GUROBI or CPLEX) or non-commercial solvers such as COIN-OR. However, you would need to see how this approach would scale.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt; be the set of interviewers, &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt; the set of interviewees and &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt; the set of slots. We now define variable &lt;span class=&quot;math-container&quot;&gt;$x_{ijt}$&lt;/span&gt; to be a binary variable that is 1 if interviewer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; interviews interviewee &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Further, let &lt;span class=&quot;math-container&quot;&gt;$y_{jt}$&lt;/span&gt; be the parameter that shows if interviewee &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is available in slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Linear Program&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\&#xA;&amp;amp; \max z = \sum_{i\in I}\sum_{j\in J}\sum_{t\in T} x_{ijt} \\&#xA;\\\textit{S.t.}\\&#xA;\\&#xA;&amp;amp;  \sum_{i\in I} \sum_{t\in T} x_{ijt} \leq 1 \quad \forall j \in J &amp;amp; \tag1 \\&#xA;&amp;amp;  \sum_{i\in I} x_{ijt} \leq y_{jt} \quad \forall j \in J; t \in T &amp;amp; \tag2 \\  &#xA;&amp;amp;  \sum_{j\in J} x_{ijt} \leq 1 \quad \forall i \in I; t \in T &amp;amp; \tag3 \\ &#xA;&amp;amp;   x_{ijt} \in \{0,1\} \quad \forall i \in I; j \in J; t \in T\tag4 &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective is to maximize the number of interviews held. Equation (1) makes sure that an interviewee is only interviewed at most once. Equation (2) makes sure that an interviewee is interviewed in a slot he is available in. Equation (3) makes sure that an interviewer interviews at most one interviewee in a slot.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2023-06-15T10:48:41.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10585" PostTypeId="2" ParentId="10581" CreationDate="2023-06-15T11:11:49.977" Score="0" Body="&lt;p&gt;Someone with a handlename &lt;a href=&quot;https://stackoverflow.com/users/844416/mbo&quot;&gt;MBo&lt;/a&gt; told me this problem is called Maximum Bipartite Matching problem and there is an algorithm to solve it on my stackoverflow post.&lt;/p&gt;&#xA;&lt;p&gt;Khun's Algorithm:&#xA;&lt;a href=&quot;https://cp-algorithms.com/graph/kuhn_maximum_bipartite_matching.html#proof&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cp-algorithms.com/graph/kuhn_maximum_bipartite_matching.html#proof&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I may try implementing one of the variation.&lt;/p&gt;&#xA;&lt;p&gt;As I commented, I think I can expand this problem for more than one interviewer.&#xA;In that case, just set the number of total time slots to be equal to the sum of time slots each of iterviewers is available. So that the variables can be represented in 2D array and can be solved in the same manner.&lt;/p&gt;&#xA;" OwnerUserId="11989" LastActivityDate="2023-06-15T11:11:49.977" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10586" PostTypeId="1" CreationDate="2023-06-15T17:32:27.973" Score="-1" ViewCount="75" Body="&lt;p&gt;I've come across the possibility of introducing binary variables in linear programming with the Big-M method here several times now. Here is an example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;(1-x_{i})\le \sum_i y_i\\&#xA;&amp;amp;M\cdot (1-x_{i})\ge \sum_i y_i&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, when I look up Big-M, I only find literature and works on the Big-M method for solving LPs. Is there also literature on the Big-M method for constraints?&lt;/p&gt;&#xA;" OwnerUserId="11967" LastEditorUserId="51" LastEditDate="2023-06-15T18:34:48.857" LastActivityDate="2023-06-15T21:10:12.917" Title="Literature for the Big-M constraint method" Tags="|linear-programming|constraint|big-m|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10587" PostTypeId="2" ParentId="10582" CreationDate="2023-06-15T18:02:57.750" Score="0" Body="&lt;p&gt;You can try as below as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i}(x_{i,j}P_i + 0.8x_{i,j}(1-P_i)) \ge b_j \quad \forall j$&lt;/span&gt;&lt;br /&gt;&#xA;where known parameter&#xA;&lt;span class=&quot;math-container&quot;&gt;$P_i = \begin{cases}&#xA;1, \text{if transport by pipe from i}  \\&#xA;0, \text{by ship}&#xA;\end{cases}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Edit:&#xA;correction made as suggested below.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-06-15T21:56:39.900" LastActivityDate="2023-06-15T21:56:39.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10588" PostTypeId="2" ParentId="10586" CreationDate="2023-06-15T21:10:12.917" Score="1" Body="&lt;p&gt;It's covered in a lot of textbooks. For instance, chapter 9 (&amp;quot;Building Integer Programming Models I&amp;quot;) in the fourth edition of the excellent book &amp;quot;Model Building in Mathematical Programming&amp;quot; by H. Paul Williams has a big-M constraint containing an indicator variable in the very first formula.&lt;/p&gt;&#xA;&lt;p&gt;Rather than searching &amp;quot;big M&amp;quot;, you might want to search &amp;quot;indicator variable&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-06-15T21:10:12.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10589" PostTypeId="1" CreationDate="2023-06-16T09:21:42.990" Score="-1" ViewCount="85" Body="&lt;p&gt;I successfully worked on the problem with following model in Excel, but I have a problem translating it into Python.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YPvQz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YPvQz.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is the proposed way to code the problem form the book:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model &amp;quot;E-6 van rental&amp;quot;&#xA; uses &amp;quot;mmxprs&amp;quot;&#xA; declarations&#xA;  NM = 6&#xA;  MONTHS = 1..NM&#xA;  CONTR = 3..5&#xA;  REQ: array(MONTHS) of integer&#xA;  COST: array(CONTR) of integer&#xA;  NINIT: integer&#xA;! Months&#xA;! Contract types&#xA;! Monthly requirements&#xA;! Cost of contract types&#xA;! Vans rented at beginning of plan&#xA;           rent: array(CONTR,MONTHS) of mpvar  ! New rentals every month&#xA;          end-declarations&#xA;          initializations from ’e6vanrent.dat’&#xA;           REQ COST NINIT&#xA;          end-initializations&#xA;         ! Objective: total cost&#xA;          Cost:= sum(c in CONTR, m in MONTHS) COST(c)*rent(c,m)&#xA;         ! Fulfill the monthly requirements&#xA;          forall(m in MONTHS)&#xA;           if(m&amp;lt;=2, NINIT, 0) +&#xA;            sum(c in CONTR, n in maxlist(1,m-c+1)..minlist(m,NM-c+1)) rent(c,n) &amp;gt;=&#xA;REQ(m)&#xA;         ! Solve the problem&#xA;          minimize(Cost)&#xA;end-model&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;And so far this is what I came up with:&#xA;I am especially confused about the constraint.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Model&#xA;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;&#xA;# Data (Set and Parameter)&#xA;NM = 6  # Number of months&#xA;Months = range(NM)&#xA;Contr = [3,4,5]  # Contract Types&#xA;REQ = [430, 410, 440, 390, 425, 450]  # Monthly requirement for vans&#xA;Cost = [1700,2200,2600] # Cost of contract types&#xA;NINIT = 200 # Vans rented at the beginning of plan&#xA;&#xA;# Create a new model&#xA;model = gp.Model(&amp;quot;Fleet Vans&amp;quot;)&#xA;&#xA;# Create decision variables&#xA;rent = model.addVars(Contr, Months, vtype=GRB.INTEGER,name=&amp;quot;rent&amp;quot;)&#xA;&#xA;# Set objective function: Minimize rent cost&#xA;Cost = start.sum()&#xA;model.setObjective(Cost, GRB.MINIMIZE)&#xA;&#xA;# Constraints&#xA;# Constraint 1: Fulfill the monthly requirements&#xA;for m in Months:&#xA;    model.addConstr(if(m&amp;lt;=2, NINIT, 0) + sum(rent[c,n] for c in [3, 4, 5]) &amp;gt;= REQ[m])&#xA;    &#xA;# Optimize the model&#xA;model.optimize()&#xA;&#xA;# Print the solution&#xA;if model.status == GRB.OPTIMAL:&#xA;    print(&amp;quot;Optimal cost:&amp;quot;)&#xA;    &#xA;    print(&amp;quot;Total cost:&amp;quot;, Total.getValue())&#xA;else:&#xA;    print(&amp;quot;No solution found.&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is the problem by the way:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/kZmKj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kZmKj.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11996" LastEditorUserId="491" LastEditDate="2023-06-16T12:22:28.627" LastActivityDate="2023-07-16T18:08:10.940" Title="How do I translate the following constraint for gurobi py?" Tags="|optimization|modeling|python|gurobi|gurobipy|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10590" PostTypeId="1" CreationDate="2023-06-16T09:31:41.493" Score="1" ViewCount="133" Body="&lt;p&gt;We have the following two conditions:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C1.$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$l(x) \geq 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$x\in \mathbb{R}^n$&lt;/span&gt;,&lt;br/&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$C2.$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$l(x) \geq 1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$x\in \mathbb{R}^n$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$a+b^Tx \leq 0.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$l(x) = \begin{bmatrix} x^T 1 \end{bmatrix} M \begin{bmatrix} x \\ 1 \end{bmatrix}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We have to show that &lt;span class=&quot;math-container&quot;&gt;$C2.$&lt;/span&gt; is equivalent to&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$C3.$&lt;/span&gt;: there exists &lt;span class=&quot;math-container&quot;&gt;$\tau \geq 0$&lt;/span&gt; such that for every &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;,  &lt;span class=&quot;math-container&quot;&gt;$l(x) \geq 1-2\tau (a+b^Tx). $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here is what I have tried:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C1.$&lt;/span&gt; is equivalent to the fact that &lt;span class=&quot;math-container&quot;&gt;$M \succcurlyeq 0$&lt;/span&gt;. &lt;br/&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$C3.$&lt;/span&gt; holds then,  under &lt;span class=&quot;math-container&quot;&gt;$a+b^Tx \leq 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$l(x) \geq 1-2\tau (a+b^Tx) \geq 1.$&lt;/span&gt; Hence, &lt;span class=&quot;math-container&quot;&gt;$C2.$&lt;/span&gt; holds.&lt;/p&gt;&#xA;&lt;p&gt;The following exact statement from &lt;a href=&quot;http://people.eecs.berkeley.edu/%7Eelghaoui/Pubs/wcVaR_OR2003.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt;&#xA;concludes that &lt;span class=&quot;math-container&quot;&gt;$C2.$&lt;/span&gt; gives &lt;span class=&quot;math-container&quot;&gt;$C3.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With &lt;span class=&quot;math-container&quot;&gt;$C1.$&lt;/span&gt; in force, an application of the classical strong&#xA;duality result for convex programs under the Slater assumption&#xA;shows that the&#xA;above condition is sufficient, provided there exists an &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; such&#xA;that  &lt;span class=&quot;math-container&quot;&gt;$a+b^Tx_0 &amp;lt;0.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am having trouble here. I tried writing a convex problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{x} l(x)-1 &#xA;\\&#xA;\text{s.t.} a+b^Tx \leq 0.  &#xA;$$&lt;/span&gt;&#xA;So we get its Lagrange function as &lt;span class=&quot;math-container&quot;&gt;$L(x,\tau) = l(x)-1 + \tau (a+b^Tx) $&lt;/span&gt;. A KKT point will satisfy &lt;span class=&quot;math-container&quot;&gt;$C3.$&lt;/span&gt;, but I am unable to show it for every &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Moreover I am not using &lt;span class=&quot;math-container&quot;&gt;$C1. $&lt;/span&gt; but the statement takes it into account.&lt;/p&gt;&#xA;&lt;p&gt;This question is asked &lt;a href=&quot;https://math.stackexchange.com/questions/4719806/equivalent-condition-for-indicator-function&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11997" LastEditorUserId="491" LastEditDate="2023-06-16T12:21:18.040" LastActivityDate="2024-03-15T10:02:25.350" Title="Equivalent condition for indicator function" Tags="|optimization|convex-optimization|duality|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10591" PostTypeId="1" CreationDate="2023-06-16T12:59:36.770" Score="1" ViewCount="97" Body="&lt;p&gt;I am trying to find sorting networks having the optimal depth or optimal number of comparators by generating &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; binary sequences where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is the channel size.&lt;/p&gt;&#xA;&lt;p&gt;The main variables in my model are as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L_{ijd} = 1$&lt;/span&gt; if a comparator exists between indices &lt;span class=&quot;math-container&quot;&gt;$(i, j)$&lt;/span&gt; at depth &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$V_{idj}$&lt;/span&gt; is the input value (&lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;)  at index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, depth &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; for the &lt;span class=&quot;math-container&quot;&gt;$j^{th}$&lt;/span&gt; binary_sequence.&lt;/p&gt;&#xA;&lt;p&gt;My model is based on section 2 of this &lt;a href=&quot;https://arxiv.org/abs/1310.6271&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt;. The issue I am finding with my model is that I've to input the value of depth &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; that allows me to find the optimal depth. But that doesn't help in finding the optimal number of comparators.&lt;/p&gt;&#xA;&lt;p&gt;Now I can just create depth as a variable but then it is used as an index. That's causing the issue. How can I change the model so that it allows the solver to find the depth?&lt;/p&gt;&#xA;" OwnerUserId="9481" LastActivityDate="2023-06-16T19:22:01.163" Title="Modelling Optimal Sorting Networks" Tags="|combinatorial-optimization|constraint-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10592" PostTypeId="1" CreationDate="2023-06-16T16:47:18.700" Score="0" ViewCount="111" Body="&lt;p&gt;I need your help.&#xA;I'm setting up an LP and I'm trying to find constraints to introduce the binary varibale &lt;span class=&quot;math-container&quot;&gt;$b_{ij}$&lt;/span&gt;. So it should take the value 0 if the sum of all &lt;span class=&quot;math-container&quot;&gt;$a_{ij}$&lt;/span&gt; values to the period t are &lt;span class=&quot;math-container&quot;&gt;$\le n~ \forall i \in I \text{ and } j \in J$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; being a not yet defined whole number. Otherwise, it is supposed to take the value 1. I think one models the whole thing with Big-M, but how exactly I do not know unfortunately.&lt;/p&gt;&#xA;" OwnerUserId="11999" LastEditorUserId="8" LastEditDate="2023-06-17T14:06:46.310" LastActivityDate="2023-06-17T14:06:46.310" Title="Modelling a binary variable in LPs" Tags="|linear-programming|binary-variable|big-m|indicator-constraints|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10593" PostTypeId="2" ParentId="10592" CreationDate="2023-06-16T17:11:52.793" Score="-1" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{j\le t} a_{i,j} \le n + Mb_{i,j}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ n+\epsilon \le \sum_{j \le t} a_{i,j} + M(1-b_{i,j})$&lt;/span&gt;&lt;br /&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$ \epsilon$&lt;/span&gt; as a small number, depending upon expected values of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-06-16T19:24:25.480" LastActivityDate="2023-06-16T19:24:25.480" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10594" PostTypeId="2" ParentId="10589" CreationDate="2023-06-16T17:18:44.893" Score="0" Body="&lt;pre&gt;&lt;code&gt;!Define dict NIN&#xA;NIN = {1:NINT, 2:NINT, 3:0,4:0,5:0}&#xA;for m in Months:&#xA;       model.addConstr(NIN[m] + sum(rent[c,n] for c in [3, 4, 5]) &amp;gt;= REQ[m])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-06-16T17:18:44.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10595" PostTypeId="2" ParentId="10592" CreationDate="2023-06-16T17:48:33.290" Score="3" Body="&lt;p&gt;You want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$b_{it} = 0 \iff \sum_{j \le t} a_{ij} \le n.$$&lt;/span&gt;&#xA;You can enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$b_{it} = 0 \implies \sum_{j \le t} a_{ij} \le n$$&lt;/span&gt;&#xA;with big-M constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j \le t} a_{ij} - n \le M_1 b_{it},$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$M_1 = |\{j\in J: j \le t\}| - n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j \le t} a_{ij} \le n \implies b_{it} = 0,$$&lt;/span&gt;&#xA;equivalently its contrapositive&#xA;&lt;span class=&quot;math-container&quot;&gt;$$b_{it} = 1 \implies \sum_{j \le t} a_{ij} \ge n + 1,$$&lt;/span&gt;&#xA;with big-M constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$n + 1 - \sum_{j \le t} a_{ij} \le M_2 (1 - b_{it}),$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$M_2 = n + 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Another way to think of this is that you want &lt;span class=&quot;math-container&quot;&gt;$\sum_{j \le t} a_{ij}$&lt;/span&gt; to be between &lt;span class=&quot;math-container&quot;&gt;$\color{red}{0}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\color{red}{n}$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$b_{it}=0$&lt;/span&gt; and between &lt;span class=&quot;math-container&quot;&gt;$\color{blue}{n+1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\color{blue}{U_t}=|\{j\in J: j \le t\}|$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$b_{it}=1$&lt;/span&gt;, yielding&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\color{red}{0}(1-b_{it}) + (\color{blue}{n+1})b_{it} \le \sum_{j \le t} a_{ij} \le \color{red}{n}(1-b_{it}) + \color{blue}{U_t} b_{it}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-06-16T17:56:24.033" LastActivityDate="2023-06-16T17:56:24.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10596" PostTypeId="2" ParentId="10591" CreationDate="2023-06-16T19:22:01.163" Score="1" Body="&lt;p&gt;Say &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is a set/list/dictionary/dataframe of all possible &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; values, defined parameter. Define binary set &lt;span class=&quot;math-container&quot;&gt;$z_d'$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$d'$&lt;/span&gt; is indexed over &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt;. Then using constraint&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{d' \in D} z_{d'} = d$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then use &lt;span class=&quot;math-container&quot;&gt;$ \sum_{d'} z_{d'}D_{d'} V_{ij}^{d'}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-06-16T19:22:01.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10597" PostTypeId="1" AcceptedAnswerId="10598" CreationDate="2023-06-17T09:01:27.033" Score="1" ViewCount="156" Body="&lt;p&gt;TL;DR: How can I specify to &lt;strong&gt;ortools&lt;/strong&gt; to use only the Clarke and Wright algorithm.&lt;/p&gt;&#xA;&lt;p&gt;Hello,&#xA;I'm trying to solve a CVRP. When exploring the my options, I stumble by the ortools library, it gets the job done by using different algorithms, but I want to use only the Clarke and Wright algorithm to solve my problem.&lt;/p&gt;&#xA;&lt;p&gt;How can I achieve that?&lt;/p&gt;&#xA;&lt;p&gt;Here's my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from ortools.constraint_solver import routing_enums_pb2&#xA;from ortools.constraint_solver import pywrapcp&#xA;&#xA;&#xA;def create_data_model():&#xA;    &amp;quot;&amp;quot;&amp;quot;Stores the data for the problem.&amp;quot;&amp;quot;&amp;quot;&#xA;    data = {}&#xA;    data['distance_matrix'] = [&#xA;        [&#xA;            0, 548, 776, 696, 582, 274, 502, 194, 308, 194, 536, 502, 388, 354,&#xA;            468, 776, 662&#xA;        ],&#xA;        [&#xA;            548, 0, 684, 308, 194, 502, 730, 354, 696, 742, 1084, 594, 480, 674,&#xA;            1016, 868, 1210&#xA;        ],&#xA;        [&#xA;            776, 684, 0, 992, 878, 502, 274, 810, 468, 742, 400, 1278, 1164,&#xA;            1130, 788, 1552, 754&#xA;        ],&#xA;        [&#xA;            696, 308, 992, 0, 114, 650, 878, 502, 844, 890, 1232, 514, 628, 822,&#xA;            1164, 560, 1358&#xA;        ],&#xA;        [&#xA;            582, 194, 878, 114, 0, 536, 764, 388, 730, 776, 1118, 400, 514, 708,&#xA;            1050, 674, 1244&#xA;        ],&#xA;        [&#xA;            274, 502, 502, 650, 536, 0, 228, 308, 194, 240, 582, 776, 662, 628,&#xA;            514, 1050, 708&#xA;        ],&#xA;        [&#xA;            502, 730, 274, 878, 764, 228, 0, 536, 194, 468, 354, 1004, 890, 856,&#xA;            514, 1278, 480&#xA;        ],&#xA;        [&#xA;            194, 354, 810, 502, 388, 308, 536, 0, 342, 388, 730, 468, 354, 320,&#xA;            662, 742, 856&#xA;        ],&#xA;        [&#xA;            308, 696, 468, 844, 730, 194, 194, 342, 0, 274, 388, 810, 696, 662,&#xA;            320, 1084, 514&#xA;        ],&#xA;        [&#xA;            194, 742, 742, 890, 776, 240, 468, 388, 274, 0, 342, 536, 422, 388,&#xA;            274, 810, 468&#xA;        ],&#xA;        [&#xA;            536, 1084, 400, 1232, 1118, 582, 354, 730, 388, 342, 0, 878, 764,&#xA;            730, 388, 1152, 354&#xA;        ],&#xA;        [&#xA;            502, 594, 1278, 514, 400, 776, 1004, 468, 810, 536, 878, 0, 114,&#xA;            308, 650, 274, 844&#xA;        ],&#xA;        [&#xA;            388, 480, 1164, 628, 514, 662, 890, 354, 696, 422, 764, 114, 0, 194,&#xA;            536, 388, 730&#xA;        ],&#xA;        [&#xA;            354, 674, 1130, 822, 708, 628, 856, 320, 662, 388, 730, 308, 194, 0,&#xA;            342, 422, 536&#xA;        ],&#xA;        [&#xA;            468, 1016, 788, 1164, 1050, 514, 514, 662, 320, 274, 388, 650, 536,&#xA;            342, 0, 764, 194&#xA;        ],&#xA;        [&#xA;            776, 868, 1552, 560, 674, 1050, 1278, 742, 1084, 810, 1152, 274,&#xA;            388, 422, 764, 0, 798&#xA;        ],&#xA;        [&#xA;            662, 1210, 754, 1358, 1244, 708, 480, 856, 514, 468, 354, 844, 730,&#xA;            536, 194, 798, 0&#xA;        ],&#xA;    ]&#xA;    data['demands'] = [0, 1, 1, 2, 4, 2, 4, 8, 8, 1, 2, 1, 2, 4, 4, 8, 8]&#xA;    data['vehicle_capacities'] = [40, 100, 30, 10]&#xA;    data['num_vehicles'] = 4&#xA;    data['depot'] = 0&#xA;    return data&#xA;&#xA;&#xA;def print_solution(data, manager, routing, solution):&#xA;    &amp;quot;&amp;quot;&amp;quot;Prints solution on console.&amp;quot;&amp;quot;&amp;quot;&#xA;    total_distance = 0&#xA;    total_load = 0&#xA;    for vehicle_id in range(data['num_vehicles']):&#xA;        index = routing.Start(vehicle_id)&#xA;        plan_output = 'Route for vehicle {}:\n'.format(vehicle_id)&#xA;        route_distance = 0&#xA;        route_load = 0&#xA;        while not routing.IsEnd(index):&#xA;            node_index = manager.IndexToNode(index)&#xA;            route_load += data['demands'][node_index]&#xA;            plan_output += ' {0} -&amp;gt; '.format(node_index, route_load)&#xA;            previous_index = index&#xA;            index = solution.Value(routing.NextVar(index))&#xA;            route_distance += routing.GetArcCostForVehicle(&#xA;                previous_index, index, vehicle_id)&#xA;        plan_output += ' {0}\n'.format(manager.IndexToNode(index),&#xA;                                                 route_load)&#xA;        plan_output += 'Distance of the route: {}m\n'.format(route_distance)&#xA;        plan_output += 'Load of the route: {}\n'.format(route_load)&#xA;        print(plan_output)&#xA;        total_distance += route_distance&#xA;        total_load += route_load&#xA;    print('Total distance of all routes: {}m'.format(total_distance))&#xA;    print('Total load of all routes: {}'.format(total_load))&#xA;&#xA;&#xA;def main():&#xA;    &amp;quot;&amp;quot;&amp;quot;Solve the CVRP problem.&amp;quot;&amp;quot;&amp;quot;&#xA;    # Instantiate the data problem.&#xA;    data = create_data_model()&#xA;&#xA;    # Create the routing index manager.&#xA;    manager = pywrapcp.RoutingIndexManager(len(data['distance_matrix']),&#xA;                                           data['num_vehicles'], data['depot'])&#xA;&#xA;    # Create Routing Model.&#xA;    routing = pywrapcp.RoutingModel(manager)&#xA;&#xA;    # Create and register a transit callback.&#xA;    def distance_callback(from_index, to_index):&#xA;        &amp;quot;&amp;quot;&amp;quot;Returns the distance between the two nodes.&amp;quot;&amp;quot;&amp;quot;&#xA;        # Convert from routing variable Index to distance matrix NodeIndex.&#xA;        from_node = manager.IndexToNode(from_index)&#xA;        to_node = manager.IndexToNode(to_index)&#xA;        return data['distance_matrix'][from_node][to_node]&#xA;&#xA;    transit_callback_index = routing.RegisterTransitCallback(distance_callback)&#xA;&#xA;    # Define cost of each arc.&#xA;    routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)&#xA;&#xA;    # Add capacity constraint.&#xA;    def demand_callback(from_index):&#xA;        &amp;quot;&amp;quot;&amp;quot;Returns the demand of the node.&amp;quot;&amp;quot;&amp;quot;&#xA;        # Convert from routing variable Index to demands NodeIndex.&#xA;        from_node = manager.IndexToNode(from_index)&#xA;        return data['demands'][from_node]&#xA;&#xA;    demand_callback_index = routing.RegisterUnaryTransitCallback(demand_callback)&#xA;    routing.AddDimensionWithVehicleCapacity(&#xA;        demand_callback_index,&#xA;        0,  # null capacity slack&#xA;        data['vehicle_capacities'],  # vehicle maximum capacities&#xA;        True,  # start cumul to zero&#xA;        'Capacity')&#xA;&#xA;    # Add maximum distance constraint.&#xA;    max_distance = 2000  # Maximum traveled distance for each vehicle&#xA;    routing.AddDimension(&#xA;        transit_callback_index,&#xA;        0,  # no slack&#xA;        max_distance,  # maximum distance&#xA;        True,  # start cumul to zero&#xA;        'Distance')&#xA;&#xA;    # Set first solution heuristic.&#xA;    search_parameters = pywrapcp.DefaultRoutingSearchParameters()&#xA;    search_parameters.first_solution_strategy = (&#xA;        routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)&#xA;&#xA;    # Solve the problem.&#xA;    solution = routing.SolveWithParameters(search_parameters)&#xA;&#xA;    # Print solution on console.&#xA;    if solution:&#xA;        print_solution(data, manager, routing, solution)&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    main()&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3806" LastActivityDate="2023-06-17T10:18:44.840" Title="Routing problem - How can I make use of the Clarke and Wright algorithm for a CVRP, when using the ortools library?" Tags="|vehicle-routing|or-tools|heuristics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10598" PostTypeId="2" ParentId="10597" CreationDate="2023-06-17T10:18:44.840" Score="4" Body="&lt;p&gt;You need to replace &lt;code&gt;PATH_CHEAPEST_ARC&lt;/code&gt; by &lt;code&gt;SAVINGS&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/constraint_solver/routing_enums.proto#L48&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/ortools/constraint_solver/routing_enums.proto#L48&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-06-17T10:18:44.840" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10601" PostTypeId="2" ParentId="10590" CreationDate="2023-06-19T07:28:19.347" Score="0" Body="&lt;p&gt;Let&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{lrl}&#xA;p^\star = &amp;amp;\min&amp;amp; l(x)-1 \\&#xA;&amp;amp;\text{s.t.}&amp;amp; a+b^Tx \leq 0.&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;Assumption C1 tells us that this is a convex optimization problem, and existence of a Slater point, &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt;, satisfying &lt;span class=&quot;math-container&quot;&gt;$a + b^T x_0 &amp;lt; 0$&lt;/span&gt;, tells that this convex optimization problem satisfies strong duality. That is,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max_{\tau \geq 0} \min_x L(x,\tau) = p^\star.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$L(x,\tau) = l(x)-1 + \tau (a+b^Tx)$&lt;/span&gt; is the Lagrange function. By assumption C2, telling us that &lt;span class=&quot;math-container&quot;&gt;$p^\star \geq 0$&lt;/span&gt;, we thus have that the optimal dual multiplier, &lt;span class=&quot;math-container&quot;&gt;$\tau^\star \geq 0$&lt;/span&gt;, satisfies&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_x L(x,\tau^\star) \geq 0&#xA;$$&lt;/span&gt;&#xA;and thus we conclude &lt;span class=&quot;math-container&quot;&gt;$L(x,\tau^\star) \geq 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{R}^n$&lt;/span&gt;, which is equivalent to C3.&lt;/p&gt;&#xA;" OwnerUserId="198" LastActivityDate="2023-06-19T07:28:19.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10602" PostTypeId="2" ParentId="10579" CreationDate="2023-06-19T14:50:34.273" Score="7" Body="&lt;p&gt;As noted in a comment to the original question, I have (I believe) a proof that the ellipsoid is bounded with probability 1 (assuming the pseudorandom number generator is, well, random). I've also tested a few different optimization models, attempting to maximize either the &lt;span class=&quot;math-container&quot;&gt;$L_1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$L_\infty$&lt;/span&gt; norm of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; over the ellipsoid, with mixed results. I published the proof (maybe a bit too long to include here) in &lt;a href=&quot;https://orinanobworld.blogspot.com/2023/06/an-unbounded-bounded-feasible-region-i.html&quot; rel=&quot;noreferrer&quot;&gt;one blog post&lt;/a&gt; and some computational results in &lt;a href=&quot;https://orinanobworld.blogspot.com/2023/06/an-unbounded-bounded-feasible-region-ii.html&quot; rel=&quot;noreferrer&quot;&gt;another post&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-06-19T14:50:34.273" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10603" PostTypeId="2" ParentId="10579" CreationDate="2023-06-19T17:30:38.257" Score="5" Body="&lt;h1&gt;Mathematical boundedness&lt;/h1&gt;&#xA;&lt;p&gt;The model is bounded if all eigenvalues of &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; are positive. As @prubin already answered this is the case with high probability.&lt;/p&gt;&#xA;&lt;p&gt;Mathematically, the distribution of eigenvalues for this matrix has been analyzed already (the &lt;a href=&quot;https://en.wikipedia.org/wiki/Wishart_distribution&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wishart&lt;/a&gt; distribution). This distribution is continuous, so the probability of an eigenvalue being exactly &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; is nil.&lt;/p&gt;&#xA;&lt;h1&gt;Solver troubles&lt;/h1&gt;&#xA;&lt;p&gt;The solver may have trouble with it because the generated matrix has really bad conditioning. The ratio between larger and smaller eigenvalues is typically around &lt;span class=&quot;math-container&quot;&gt;$10^5$&lt;/span&gt; for a &lt;span class=&quot;math-container&quot;&gt;$100 \times 100$&lt;/span&gt; matrix, and &lt;span class=&quot;math-container&quot;&gt;$10^6$&lt;/span&gt; for a &lt;span class=&quot;math-container&quot;&gt;$1000 \times 1000$&lt;/span&gt; matrix, but is often as high as &lt;span class=&quot;math-container&quot;&gt;$10^8$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$10^{10}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In Python:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;H = np.random.randn(100, 100)&#xA;Q = H @ H.transpose()&#xA;eig = np.sort(np.linalg.eigvalsh(Q))&#xA;print(f&amp;quot;{eig[-1] / eig[0]}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is called the &lt;a href=&quot;https://en.wikipedia.org/wiki/Condition_number#Matrices&quot; rel=&quot;nofollow noreferrer&quot;&gt;condition number&lt;/a&gt;. A high condition number means that the smallest eigenvalue is very close to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; compared to the largest.&#xA;Depending on the solver, this can cause numerical issues, and this is probably why the model is declared unbounded.&lt;/p&gt;&#xA;&lt;p&gt;A plot of the condition number across matrices:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Gcabm.png&quot; alt=&quot;Plot of the condition number for 5x5 matrix&quot; /&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Avoiding the issue&lt;/h1&gt;&#xA;&lt;p&gt;If this is indeed the issue for your solver, you could generate matrices with better eigenvalue distributions.&#xA;A very simple way to improve the conditioning (flatten the eigenvalue distribution) is to make your initial matrix &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; non-square (&lt;span class=&quot;math-container&quot;&gt;$n \times m$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$m &amp;gt; n$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;I plotted the condition number for varying &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, averaged over 100 matrices. We see that it improves the condition number very quickly (note the log scale!).&lt;/p&gt;&#xA;&lt;p&gt;Please tell me if it helps with your solver.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wCBGW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wCBGW.png&quot; alt=&quot;A graphic showing improved conditioning with larger m&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2023-06-20T08:15:51.010" LastActivityDate="2023-06-20T08:15:51.010" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10604" PostTypeId="1" CreationDate="2023-06-20T08:45:30.050" Score="7" ViewCount="3106" Body="&lt;p&gt;The Rust programming language is gaining popularity. As the title says, I wonder if state-of-the-art, say MILP, solvers will eventually release APIs for the Rust programming language. Solvers such as Cplex and Gurobi have APIs for some of the most used programming languages, including, C++, Java, Python, R, Matlab. As far as I know, these do not have Rust APIs.&lt;/p&gt;&#xA;&lt;p&gt;Should we expect any Rust API in the near future? And what are the reasons in favor or against that?&lt;/p&gt;&#xA;&lt;p&gt;(To keep the question more specific, I would limit the scope to Cplex and Gurobi).&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="491" LastEditDate="2023-06-21T01:05:03.090" LastActivityDate="2023-06-21T01:05:03.090" Title="Will there be Rust APIs for state-of-the-art solvers?" Tags="|solver|api|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10607" PostTypeId="2" ParentId="10604" CreationDate="2023-06-20T10:47:07.947" Score="8" Body="&lt;p&gt;This is what @mattmilten mentioned in the Gurobi &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/360057920492-Rust-API&quot; rel=&quot;noreferrer&quot;&gt;forum&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;There is no official native Rust API for Gurobi, yet. There are tool&#xA;to generate C bindings for Rust that you may be able to use to call&#xA;the Gurobi C API: &lt;a href=&quot;https://github.com/rust-lang/rust-bindgen&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/rust-lang/rust-bindgen&lt;/a&gt;. This is&#xA;similar to what the official APIs do:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UkXTe.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UkXTe.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-06-20T10:47:07.947" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10608" PostTypeId="2" ParentId="10604" CreationDate="2023-06-20T15:49:05.433" Score="12" Body="&lt;p&gt;The upcoming 10.1 version of Mosek includes a fully documented &lt;a href=&quot;https://docs.mosek.com/10.1/rustapi/index.html&quot; rel=&quot;noreferrer&quot;&gt;Rust API&lt;/a&gt;. It is currently in beta mode.&#xA;At our GitHub page you find more info about &lt;a href=&quot;https://github.com/MOSEK/mosek.rust&quot; rel=&quot;noreferrer&quot;&gt;Rust and Mosek&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2023-06-20T15:49:05.433" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10610" PostTypeId="2" ParentId="10579" CreationDate="2023-06-21T08:03:39.263" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://www.mosek.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;MOSEK&lt;/a&gt; offers a &lt;a href=&quot;https://docs.mosek.com/whitepapers/qmodel.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;whitepaper on quadratic constraints&lt;/a&gt; in which it is concluded that if &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; has a suitable factor model, then it is often beneficial to represent your model in a way that exploits this factor model. In your case you have &lt;span class=&quot;math-container&quot;&gt;$Q=H^T H$&lt;/span&gt; and although &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt; has no particular properties of interest (besides full rank with high probability), I suggest you try to reformulate&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\frac{1}{2} x^T Q x + q^T x + q_0 \leq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\frac{1}{2} y^T y + q^T x + q_0 \leq 0,\quad y = Hx,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;or perhaps even better as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\frac{1}{2} y^T y + p^T y + q_0 \leq 0,\quad y = Hx,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is the solution to &lt;span class=&quot;math-container&quot;&gt;$H^T p = q$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$p^T y = p^T H x = q^T x$&lt;/span&gt; by definition. In your case, the potential benefit comes from having the quadratic coefficient matrix (the only nonlinear part) becoming an identity matrix which is numerically stable. There is no eigenvalue distribution to worry about.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2023-06-21T08:10:26.617" LastActivityDate="2023-06-21T08:10:26.617" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10614" PostTypeId="1" CreationDate="2023-06-22T00:30:23.050" Score="0" ViewCount="85" Body="&lt;h2&gt;Problem Description&lt;/h2&gt;&#xA;&lt;p&gt;I have many examples (say &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;) to choose from to train my machine learning model. However, I could only select &lt;span class=&quot;math-container&quot;&gt;$n \ll N$&lt;/span&gt; based on a set of &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; attributes &lt;span class=&quot;math-container&quot;&gt;$\{a_1, a_2, \cdots, a_k\}$&lt;/span&gt; already measured for the dataset.&lt;/p&gt;&#xA;&lt;p&gt;Now I would like to find these &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; samples so that some measure (for example, sum) of the &lt;strong&gt;each&lt;/strong&gt; of the &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; columns are maximized.&lt;/p&gt;&#xA;&lt;h2&gt;What I Tried&lt;/h2&gt;&#xA;&lt;p&gt;This looks like a knapsack problem but with multiple attributes. However, direct Google search does not seem to give me a lot of relevant results as I am looking for an existing software package that could solve this problem (or perhaps its relaxed version).&lt;/p&gt;&#xA;&lt;h2&gt;Note&lt;/h2&gt;&#xA;&lt;p&gt;Cross-posted at &lt;a href=&quot;https://math.stackexchange.com/q/4721933/488804&quot;&gt;Math.SE&lt;/a&gt; with 200 bounty points.&lt;/p&gt;&#xA;" OwnerUserId="4684" LastEditorUserId="491" LastEditDate="2023-06-23T12:31:56.117" LastActivityDate="2023-06-23T12:31:56.117" Title="Knapsack Problem with Multiple Properties" Tags="|combinatorial-optimization|knapsack|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10615" PostTypeId="2" ParentId="10614" CreationDate="2023-06-22T02:04:12.960" Score="1" Body="&lt;p&gt;First, let &lt;span class=&quot;math-container&quot;&gt;$x_i=1$&lt;/span&gt; if the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;th example is picked, where &lt;span class=&quot;math-container&quot;&gt;$i \in \{1, 2, …, N\}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt; otherwise.&lt;/p&gt;&#xA;&lt;p&gt;If you want to maximize the sum of ALL the elements, simply a knapsack problem with non-varying weights suffices.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$max \sum_i (\sum_k a_{ki}) x_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subject to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i x_i \leq n$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This can trivially solved by picking the first &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; elements ranked by the sum of its attributes.&lt;/p&gt;&#xA;&lt;p&gt;If instead you want to maximize the minimum of the sum of each attribute, you can introduce integer variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to solve&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$max \; z$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subject to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i x_i \leq n$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i a_{ki} x_i \geq z, \; \forall k $$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3255" LastEditorUserId="3255" LastEditDate="2023-06-22T03:00:13.913" LastActivityDate="2023-06-22T03:00:13.913" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10616" PostTypeId="1" AcceptedAnswerId="10621" CreationDate="2023-06-22T13:49:31.347" Score="1" ViewCount="133" Body="&lt;p&gt;I am currently working on a paper in which I am statistically comparing dynamic optimization algorithms like SDDP, Actor-Critics etc.&#xA;In this regard, should I be running SDDP algorithm for my deterministic multi-stage optimization problem once (if it is a deterministic solver) or should I be running it multiple times (like 50 times in case it has a stochastic component to it)?&lt;/p&gt;&#xA;&lt;p&gt;It is very important to note that my problem is a deterministic (not stochastic) multi stage optimization problem, meaning it has only one scenario.&lt;/p&gt;&#xA;" OwnerUserId="10727" LastEditorUserId="491" LastEditDate="2023-06-23T12:33:55.583" LastActivityDate="2023-08-30T22:15:31.840" Title="Is stochastic dual dynamic programming (SDDP) a deterministic solution algorithm or does it have a stochastic component to it?" Tags="|optimization|dynamic-programming|multi-stage|stochastic-dual-dynamic-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10619" PostTypeId="1" AcceptedAnswerId="10620" CreationDate="2023-06-25T13:02:22.473" Score="3" ViewCount="142" Body="&lt;p&gt;In the literature, domain propagation defines the process of inferring sequences of local domain reductions at the current node of the branch-and-bound tree. The goal is to shrink the size of the current sub-problem as much as possible at an affordable computational cost. (references mentioned at the end). Also, it is often more known in constraint programming than MILPs.&lt;/p&gt;&#xA;&lt;p&gt;However, this approach has often been used in the context of integer programming (IP) where the domain of the variables is limited and also can be estimated in prior. Now suppose we have a mixed-integer program, specifically a scheduling problem, with a mix of the binary (assigning) and positive (intervals) variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;My questions are:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it possible to apply domain propagation to the positive variables of the MIP? (If so):&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If one can make a good domain for the interval variables (also known as the start and end time of each task) by using some heuristic approaches, then fixing these time intervals in the domain window of the interval variables, can this be a domain reduction/propagation? Or just is a domain prediction?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://webdoc.sub.gwdg.de/ebook/serien/ah/ZIB/ZR-13-03.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Shift-And-Propagate by T BERTHOLD&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.zib.de/hendel/publication/rounding-and-propagation-heuristics-for-mip/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Rounding and Propagation Heuristics for Mixed Integer Programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-06-25T16:04:14.440" Title="Meaning of the domain propagation in the context of mixed-integer programming" Tags="|mixed-integer-programming|solver|scheduling|heuristics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10620" PostTypeId="2" ParentId="10619" CreationDate="2023-06-25T15:58:04.523" Score="2" Body="&lt;h3&gt;Overview&lt;/h3&gt;&#xA;&lt;p&gt;I think the canonical resource to this topic is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Achterberg, Tobias. Constraint integer programming. Diss. 2007.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h3&gt;Example Code&lt;/h3&gt;&#xA;&lt;p&gt;As this basiclly describes the theory behind the open-source MILP solver:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.scipopt.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SCIP&lt;/a&gt; (nowadays more than MILP)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;it's not surprising, that there are some rather complex applications of constraint-propagation, even related to scheduling, where things get complex very fast because CP community introduced lots of very powerful propagation-mechanisms.&lt;/p&gt;&#xA;&lt;p&gt;See for example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/scipopt/scip/blob/master/src/scip/cons_cumulative.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;/src/scip/cons_cumulative.h&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Heinz, Stefan, Wen-Yang Ku, and J. Christopher Beck. &amp;quot;Recent improvements using constraint integer programming for resource allocation and scheduling.&amp;quot; Integration of AI and OR Techniques in Constraint Programming for Combinatorial Optimization Problems: 10th International Conference, CPAIOR 2013, Yorktown Heights, NY, USA, May 18-22, 2013. Proceedings 10. Springer Berlin Heidelberg, 2013.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;(it's more than &amp;quot;just&amp;quot; propagation however: e.g. conflict-analysis)&lt;/p&gt;&#xA;&lt;h3&gt;Further applications&lt;/h3&gt;&#xA;&lt;p&gt;So yes... You can add domain-propagation to MILP (if the solver is extensible enough).&lt;/p&gt;&#xA;&lt;p&gt;One direction, related to scheduling and probably to your example domain, which i never saw in code, but which seems like a good idea to me (depending on the problem to solve of course) would be introducing the domain-propagation of &lt;a href=&quot;http://profs.sci.univr.it/%7Eposenato/courses/temporalConstraints/slides/temporalNetworks01STN.pdf&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Presentation PDF&quot;&gt;Simple Temporal Networks&lt;/a&gt;, for which bounded incremental algorithms are available (as propagation from scratch is equivalent to the all-pairs shortest-paths problem: rather expensive).&lt;/p&gt;&#xA;&lt;p&gt;I'm pretty sure, &lt;em&gt;&amp;quot;IBM ILOG CP optimizer for scheduling&amp;quot;&lt;/em&gt; does exactly this and more, which is indicated in:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Laborie, Philippe, et al. &amp;quot;IBM ILOG CP optimizer for scheduling: 20+ years of scheduling with constraints at IBM/ILOG.&amp;quot; Constraints 23 (2018): 210-250.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Keep in mind, that this software seems to be a hybrid of CP and MILP (although the how / tightness of this integration is hard to estimate as it's commercial software).&lt;/p&gt;&#xA;&lt;h3&gt;Remarks about heuristics&lt;/h3&gt;&#xA;&lt;p&gt;If heuristics are compatible with domain-propagation surely depends on details.&lt;/p&gt;&#xA;&lt;p&gt;In CP and CIP (Constraint Integer-Programming) community, i'm pretty sure the following (in absense of a better-suited resource) holds:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Lagerkvist, Mikael Zayenz, and Magnus Rattfeldt. &amp;quot;Half-checking propagators.&amp;quot; arXiv preprint arXiv:2007.05423 (2020).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;&amp;quot;Propagators are required to be correct; they must&#xA;never remove a value from a variable that may still be a solution to the constraint.&#xA;This means that propagation is not actually concerned with finding a solution&#xA;but about proving that no solution exists for a certain variable-value pair, which&#xA;is a subjectively harder problem.&amp;quot;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;So everything happening during domain-propagation basically &lt;strong&gt;assume a closed-world model&lt;/strong&gt; (current domain state, current constraint-state) and one has to be careful about the implications.&lt;/p&gt;&#xA;&lt;h4&gt;Heuristic shrinking&lt;/h4&gt;&#xA;&lt;p&gt;If you shrink domains by heuristics and continue, the solver surely can exploit follow-up domain-propagation much more heavily and speed up reasoning / local optimization. But you lost global-optimality of course (as you assumed something without knowing if you are right). This sounds like something focused on the generation of &amp;quot;fast good solutions&amp;quot;. In some sense, one might see this as primal-heuristic (which afaik in SCIP can be interleaved with constraint-propagation).&lt;/p&gt;&#xA;&lt;p&gt;There is probably a lot possible in this direction although semantics might deviate a lot!&lt;/p&gt;&#xA;&lt;p&gt;If you are able to do state-restoration / backtracking, you can embed this in some outer tree such that you don't lose global-optimality.&lt;/p&gt;&#xA;&lt;h4&gt;Something similar and yet very different&lt;/h4&gt;&#xA;&lt;p&gt;There might be a connection to the concepts of: probing (in MP / CIP community) or singleton arc-consistency / shaving (CP community) although i fail to &amp;quot;build a bridge&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Shaving is actually something very popular in scheduling applications, &lt;strong&gt;but&lt;/strong&gt; shaving (as i understood it) is solely used to &lt;strong&gt;refute&lt;/strong&gt; parts of the search-space which is pretty much the oppositve of our above &amp;quot;fast good solution&amp;quot; approach.&lt;/p&gt;&#xA;" OwnerUserId="231" LastEditorUserId="231" LastEditDate="2023-06-25T16:04:14.440" LastActivityDate="2023-06-25T16:04:14.440" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10621" PostTypeId="2" ParentId="10616" CreationDate="2023-06-26T05:28:34.197" Score="2" Body="&lt;p&gt;It depends on the implementation.&lt;/p&gt;&#xA;&lt;p&gt;Irrespective of whether the model has one scenario or many, it's possible to code an implementation of SDDP that is deterministic in the sense that it will return the same optimal policy if run multiple times with the same random seed.&lt;/p&gt;&#xA;&lt;p&gt;It's also possible to code an implementation that is stochastic and potentially returns different optimal policies each time.&lt;/p&gt;&#xA;&lt;p&gt;Even if your SDDP code is deterministic, it also depends on whether the underlying optimization solver is reproducible. For example, in Gurobi's default configuration it may choose a non-deterministic concurrent algorithm when solving an LP:&#xA;&lt;a href=&quot;https://www.gurobi.com/documentation/10.0/refman/method.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/10.0/refman/method.html&lt;/a&gt;&#xA;This can cause you to visit a different sequence of states in the forward pass and add a different sequence of cuts.&lt;/p&gt;&#xA;" OwnerUserId="804" LastEditorUserId="804" LastEditDate="2023-08-30T22:15:31.840" LastActivityDate="2023-08-30T22:15:31.840" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10623" PostTypeId="1" CreationDate="2023-06-26T10:50:46.300" Score="0" ViewCount="62" Body="&lt;p&gt;I am looking to implement the following optimization problem in CVXPY.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \max _{x_t} x_t' \mu - \frac{\gamma}{2} x'_t \Sigma x_t - x'_t\Lambda \Delta x_t $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\Delta x_t := x_t - x_{t-1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\Sigma$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\Lambda$&lt;/span&gt; are positive definite symmetric matrices.&lt;/p&gt;&#xA;&lt;p&gt;Here is my attempt:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import cvxpy as cp&#xA;import numpy as np&#xA;&#xA;N = 2&#xA;gamma = 0.01&#xA;xprev = [0.5, 0.5]&#xA;mu = [0.01, 0.01]&#xA;Sigma = np.diag([0.1 ** 2] * 2)&#xA;Lambda = Sigma * 0.01&#xA;x = cp.Variable(N)&#xA;obj_terms = []&#xA;constraints = []&#xA;xdiff = x - xprev&#xA;&#xA;term1 = cp.sum(cp.multiply(mu, x))&#xA;term2 = gamma * 0.5 * cp.quad_form(x, Sigma)&#xA;term3 = x.T @ Lambda @ xdiff&#xA;&#xA;term = (term1 - term2 - term3)&#xA;obj_terms.append(term)&#xA;objective = cp.Maximize(cp.sum(obj_terms))  &#xA;problem = cp.Problem(objective)&#xA;problem.solve()&#xA;x_value = x.value  &#xA;print(x_value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, this implementation always results in a DCP error. I believe this problem is a convex one. The problem child is the implementation &lt;code&gt;x.T @ Lambda @ xtdiff&lt;/code&gt;. Can someone please help me figure out how to implement the term &lt;span class=&quot;math-container&quot;&gt;$x'_t\Lambda \Delta x_t$&lt;/span&gt; in CVXPY?&lt;/p&gt;&#xA;" OwnerUserId="12041" LastEditorUserId="12041" LastEditDate="2023-06-26T15:30:35.120" LastActivityDate="2023-06-26T15:30:35.120" Title="How do I implement this convex problem in CVXPY?" Tags="|python|convex-optimization|quadratic-programming|cvxpy|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="10624" PostTypeId="1" CreationDate="2023-06-27T06:45:14.843" Score="0" ViewCount="67" Body="&lt;p&gt;I am trying to solve a VRP variant where I have a list of vehicles. If a vehicle is used/rented, a cost will be incurred. If not, there will be no cost.&lt;/p&gt;&#xA;&lt;p&gt;And even if a vehicle is rented, it can only be used for a certain given time.&lt;/p&gt;&#xA;&lt;p&gt;I am trying to formulate the problem like this.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\text{Minimize:} \quad &amp;amp; \sum_{j=1}^{m} \text{vehicle_rent_cost}[j] * y[j] \\&#xA;\text{Subject to:} \quad &amp;amp; \\&#xA;&amp;amp; \sum_{i=1}^{n} x[i, j] = 1 \quad \forall j = 1 \text{ to } m \\&#xA;&amp;amp; x[i, j] \leq y[j] \quad \forall i = 1 \text{ to } n, \quad \forall j = 1 \text{ to } m \\&#xA;&amp;amp; \sum_{a=1}^{n} \sum_{b=1}^{n} \text{total_time_matrix}[a, b] * v[a, b] \leq \text{vehicle_rent_time} \quad \forall j = 1 \text{ to } n \\&#xA;&amp;amp; \sum_{i=1}^{n} \text{cell_demand_kg}[i] * x[i, j] \leq \text{vehicle_capacity_kg}[j] * y[j] \quad \forall i = 1 \text{ to } n, \quad \forall j = 1 \text{ to } m \\&#xA;&amp;amp; \sum_{i=1}^{n} \text{cell_demand_cft}[i] * x[i, j] \leq \text{vehicle_capacity_cft}[j] * y[j] \quad \forall i = 1 \text{ to } n, \quad \forall j = 1 \text{ to } m \\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;n be the number of cells.&#xA;&#xA;m be the number of vehicles.&#xA;&#xA;x[i, j] be a binary variable indicating whether cell i is assigned to vehicle j.&#xA;&#xA;y[j] be a binary variable indicating whether vehicle j is used.&#xA;&#xA;v[a, b] be a binary variable indicating whether cell b is served after cell a.&#xA;&#xA;vehicle_rent_cost[j] be the cost of renting vehicle j.&#xA;&#xA;total_time_matrix[a, b] be the time to travel from cell a to cell b, after serving cell a.&#xA;&#xA;vehicle_rent_time be the total available time for a vehicle.&#xA;&#xA;cell_demand_kg[i] be the demand in kilograms for cell i.&#xA;&#xA;vehicle_capacity_kg[j] be the capacity in kilograms of vehicle j.&#xA;&#xA;cell_demand_cft[i] be the demand in cubic feet for cell i.&#xA;&#xA;vehicle_capacity_cft[j] be the capacity in cubic feet of vehicle j.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But this is clearly wrong. &lt;code&gt;v[a,b]&lt;/code&gt; will always be 0.&lt;/p&gt;&#xA;&lt;p&gt;How can I formulate the problem in a better way?&lt;/p&gt;&#xA;" OwnerUserId="5532" LastActivityDate="2023-06-27T23:16:03.487" Title="Solving a VRP variant with time constraints" Tags="|optimization|mixed-integer-programming|vehicle-routing|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10626" PostTypeId="2" ParentId="10624" CreationDate="2023-06-27T12:02:42.777" Score="0" Body="&lt;p&gt;You'd need precedence constraints like&lt;/p&gt;&#xA;&lt;p&gt;(1) &lt;span class=&quot;math-container&quot;&gt;$ x_{a,j} \le x_{b,j} \ &#xA;\forall j \ \  \forall (a,b) \in$&lt;/span&gt; Time matrix&lt;br /&gt;&#xA;Precedence constraint if travelling from &lt;span class=&quot;math-container&quot;&gt;$ b -&amp;gt; a$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(2) &lt;span class=&quot;math-container&quot;&gt;$\sum_b v_{a,b}^j \le x_{a,j} \ \ \forall a,j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(3) &lt;span class=&quot;math-container&quot;&gt;$\sum_av_{a,b}^j \le x_{b,j} \ \ \forall j, b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(4) &lt;span class=&quot;math-container&quot;&gt;$x_{a,j} + x_{b,j} \le v_{a,b}^j + 1 \ \ \forall a,b,j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then in the constraint for total vehicle rent time you may need to sum &lt;span class=&quot;math-container&quot;&gt;$v_{a,b}^j$&lt;/span&gt; for vehicles &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; if it's total rent time of all vehicles.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively instead of &lt;span class=&quot;math-container&quot;&gt;$v_{a,b}$&lt;/span&gt; being binary you can make it nonnegative continuous if it's only to be used in constraint to compute time of travel for vehicle &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and update constraints (2)-(4) as&#xA;&lt;span class=&quot;math-container&quot;&gt;$t_{a,b}(x_{a,j}+x_{b,j}-1) \le v_{a,b}^j \le t_{a,b}x_{b,j}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \le v_{a,b}^j $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then in the total rent time constraint just use &lt;span class=&quot;math-container&quot;&gt;$ \sum_j v_{a,b}^j$&lt;/span&gt; instead of time parameter&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-06-27T23:16:03.487" LastActivityDate="2023-06-27T23:16:03.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10627" PostTypeId="2" ParentId="10624" CreationDate="2023-06-27T15:46:58.493" Score="2" Body="&lt;p&gt;What is the incentive for using the vehicles? Nothing in your model requires that any demand be satisfied, so the cheapest solution clearly is to do nothing. If you are required to meet cell demands, you need a constraint to enforce that.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-06-27T15:46:58.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10629" PostTypeId="1" AcceptedAnswerId="10641" CreationDate="2023-06-28T15:12:04.530" Score="-1" ViewCount="62" Body="&lt;p&gt;&lt;strong&gt;Context:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I was working on some VRP solvers and realized that tractability deproved when I added Fixed Cost for each vehicle (in an attempt to reduce number of vehicles used).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;1-&#xA;Due to the traingle inequality, it is always shorter(or equal to) to remove an intermediate node. Adding more vehicles would mean more visits to the central depot/start.  Thus, using additional vehicles to fulfill a set of nodes would always result in a longer tour. If this were true,that would imply that mTSPs will naturally try to minimize number of vehicles used? If so, it feels like mTSP would always result in the same solution as TSP which does not seem to make sense.&lt;/p&gt;&#xA;&lt;p&gt;2-&#xA;What about in the case if there are capacity limits to the vehicle? I have been trying to generate examples to disprove this but have not been able to.&lt;/p&gt;&#xA;&lt;p&gt;Is my reasoning flawed? An example or simple logical proof would be greatly appreciated&lt;/p&gt;&#xA;" OwnerUserId="5973" LastEditorUserId="500" LastEditDate="2023-06-28T15:52:49.037" LastActivityDate="2023-06-30T16:25:20.270" Title="does mTSP/CVRP always minimize number of vehicles used?" Tags="|integer-programming|vehicle-routing|traveling-salesman|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10630" PostTypeId="2" ParentId="9174" CreationDate="2023-06-28T18:30:55.380" Score="3" Body="&lt;p&gt;Today I'm responsible for the tool chains for 461 engineers, hereof 88 with main focus on OR-like tasks. They cover anything from HPC (20,000 cores) to racks of Nvidia-A100 GPUs to swarms of micro-services.&lt;/p&gt;&#xA;&lt;p&gt;The glue that makes everything work is &lt;code&gt;python3.10&lt;/code&gt; running on Linux Ubuntu LTS.&#xA;After that comes specialized packages written in &lt;code&gt;C&lt;/code&gt; or &lt;code&gt;nim&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Speed is the key so we use lots of OR to tune our algorithms - from memory management(1) to multiprocessing(2) to calibration of block sizes(3) so we get the optimal balance between the number of IOPS and block size on SSDs during read and write.&lt;/p&gt;&#xA;&lt;p&gt;With this context there is one central lesson:&lt;/p&gt;&#xA;&lt;p&gt;All software goes through 4 stages of development and I illustrate the share of lines of code by programming language involved:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Make it work (100% python)&lt;/li&gt;&#xA;&lt;li&gt;Make it right (100% python, markdown and jupyter notebook)&lt;/li&gt;&#xA;&lt;li&gt;Make it fast (98% python, 2% &lt;code&gt;C&lt;/code&gt; or &lt;code&gt;nim&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Make it cheap (97% python, 3% &lt;code&gt;C&lt;/code&gt; or &lt;code&gt;nim&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;This progression becomes easy to understand once you see how easy it is to link &lt;code&gt;python&lt;/code&gt; with &lt;code&gt;nim&lt;/code&gt; have a look &lt;a href=&quot;https://nbviewer.org/github/root-11/root-11.github.io/blob/master/content/calling_nim_from_python.ipynb&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4852" LastEditorUserId="4852" LastEditDate="2023-08-10T12:41:26.610" LastActivityDate="2023-08-10T12:41:26.610" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10632" PostTypeId="2" ParentId="9174" CreationDate="2023-06-29T01:03:57.240" Score="0" Body="&lt;p&gt;FWIW, my experience in the corporate world OR is that most of your time will be in data cleaning, prep, and visualization.  And for that R is extremely effective and easy to use. That's the primary reason it's my language of choice.  You can also do optimization, simulation, predictive modeling, etc.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastActivityDate="2023-06-29T01:03:57.240" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10633" PostTypeId="1" AcceptedAnswerId="10634" CreationDate="2023-06-29T05:58:22.670" Score="0" ViewCount="56" Body="&lt;p&gt;In most VRPs, we start from a set of fleets (homogeneous or heterogeneous) and a set of points to be served. Then there are other constraints that need to be taken care of.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for a heuristic that will generate this set of fleets given different serving points.&lt;/p&gt;&#xA;&lt;p&gt;I have two major constraints:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Tour length: It has to be less than a given time (typically 12-14 hrs)&lt;/li&gt;&#xA;&lt;li&gt;Demand&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The tricky thing here is the tour length. So say, if my demand is 1000 kgs, and I have some fleets with a capacity of 1200 kgs, that doesn't mean those fleets will be able to serve the load. Because there may be one or more fleets that will have the tour length condition violated.&lt;/p&gt;&#xA;&lt;p&gt;Is there any heuristic that helps to generate a set of feasible set of fleets?&lt;/p&gt;&#xA;&lt;p&gt;Currently, I am doing this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Randomly select a set of fleets that has the capacity to serve the loads&lt;/li&gt;&#xA;&lt;li&gt;Do the VRP and calculate the tour length&lt;/li&gt;&#xA;&lt;li&gt;Replace the vehicle(s) for which the tour length exceeds the given limit with an equivalent set of smaller-sized vehicles&lt;/li&gt;&#xA;&lt;li&gt;Repeat 2&amp;amp;3 until the selected combination has all the feasible trips&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Is there any other intelligent way?&lt;/p&gt;&#xA;" OwnerUserId="5532" LastActivityDate="2023-06-29T07:55:05.337" Title="Heuristics for selecting the right fleet combinations for a VRP" Tags="|optimization|combinatorial-optimization|vehicle-routing|heuristics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10634" PostTypeId="2" ParentId="10633" CreationDate="2023-06-29T07:55:05.337" Score="2" Body="&lt;p&gt;You could for example adapt the well known Clarke &amp;amp; Wright algorithm and only generate routes that meet all of the required constraints.&lt;/p&gt;&#xA;&lt;p&gt;This is precisely what is done in the &lt;a href=&quot;https://vrpy.readthedocs.io/en/latest/&quot; rel=&quot;nofollow noreferrer&quot;&gt;VRPy&lt;/a&gt; library. You can find the Clarke &amp;amp; Wright adaptation &lt;a href=&quot;https://github.com/Kuifje02/vrpy/blob/master/vrpy/clarke_wright.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, where optional constraints can be activated:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;capacity constraints&lt;/li&gt;&#xA;&lt;li&gt;maximum number of stops&lt;/li&gt;&#xA;&lt;li&gt;maximum duration of tour&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2023-06-29T07:55:05.337" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10635" PostTypeId="1" CreationDate="2023-06-29T09:09:00.227" Score="2" ViewCount="136" Body="&lt;p&gt;I want to understand how to represent iff constraints in MILPs. For example, I want to represent the following as the constraints of a MILP&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ c = \begin{cases} 1 &amp;amp;\text{if } d \geq e \\ 0 &amp;amp; \text{if } d &amp;lt; e \end{cases} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$c \in \{0,1\}$&lt;/span&gt; is a binary variable, &lt;span class=&quot;math-container&quot;&gt;$d \in [0,1]$&lt;/span&gt; is a continuous variable, and &lt;span class=&quot;math-container&quot;&gt;$e \in [0, 1]$&lt;/span&gt; is given. How should I do this? In the constraints, I want only &lt;span class=&quot;math-container&quot;&gt;$\geq$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$&amp;lt;$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have tried consulting various resources, but they generally only talked about if-then scenarios and not this one.&lt;/p&gt;&#xA;" OwnerUserId="12051" LastEditorUserId="8" LastEditDate="2023-06-29T09:42:30.910" LastActivityDate="2023-06-29T10:21:29.893" Title="Conditional constraints in MILPs" Tags="|mixed-integer-programming|linear-programming|modeling|integer-programming|binary-variable|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10636" PostTypeId="2" ParentId="10635" CreationDate="2023-06-29T09:24:44.257" Score="3" Body="&lt;p&gt;For more clarity, I have slightly changed the notations: &lt;span class=&quot;math-container&quot;&gt;$y_c \in \{0,1\}$&lt;/span&gt; is the binary variable &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_d \in [0,1]$&lt;/span&gt; is the continuous variable &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;. I will also assume that &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;e\le 1$&lt;/span&gt; to avoid ambiguity at the breakpoint &lt;span class=&quot;math-container&quot;&gt;$e=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(x_d \ge e \implies y_c=1) \wedge (x_d &amp;lt; e \implies y_c=0)&#xA;$$&lt;/span&gt;&#xA;which is equivalent (via contraposition) to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(y_c=0 \implies x_d &amp;lt; e) \wedge (y_c=1 \implies e\le x_d)&#xA;$$&lt;/span&gt;&#xA;You can enforce &lt;span class=&quot;math-container&quot;&gt;$y_c=1 \implies e\le x_d$&lt;/span&gt; with:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;e \le x_d + (1-y_c)&#xA;$$&lt;/span&gt;&#xA;And &lt;span class=&quot;math-container&quot;&gt;$y_c=0 \implies x_d &amp;lt; e$&lt;/span&gt; with:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_d -y_c &amp;lt; e &#xA;$$&lt;/span&gt;&#xA;Finally, the resulting constraint is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_d+\epsilon -y_c\le e \le x_d + (1-y_c)&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is your tolerance.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-06-29T10:21:29.893" LastActivityDate="2023-06-29T10:21:29.893" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10637" PostTypeId="1" AcceptedAnswerId="10642" CreationDate="2023-06-29T23:54:59.007" Score="0" ViewCount="60" Body="&lt;p&gt;Ipopt/Knitro are local optimization solvers, so for nonconvex problems convergence doesn't guarantee optimality. However, Knitro has a multi-start &lt;a href=&quot;https://www.artelys.com/docs/knitro/3_referenceManual/userOptions.html#ms_maxsolves&quot; rel=&quot;nofollow noreferrer&quot;&gt;method&lt;/a&gt; where one can start with more random initial solutions with the hope of terminating at a better solution than a single run. I am wondering, is there an equivalent &lt;code&gt;ms_maxsolves&lt;/code&gt; option in Ipopt? I failed finding a suitable option in Ipopt in my research.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2023-07-01T05:12:08.377" Title="Knitro`ms_maxsolves` equivalent in Ipopt" Tags="|nonlinear-programming|solver|ipopt|interior-point-method|knitro|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10638" PostTypeId="1" CreationDate="2023-06-30T03:37:19.573" Score="2" ViewCount="75" Body="&lt;p&gt;This question is cross-posted from &lt;a href=&quot;https://math.stackexchange.com/questions/4724197/when-do-two-integer-linear-programs-yield-the-same-solution&quot;&gt;math stack exchange&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;An illustrative example&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Consider an integer linear program &lt;span class=&quot;math-container&quot;&gt;$\min -2x_1 + x_2$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$x_1 - x_2 \leq 3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_1 + x_2 \leq 10$&lt;/span&gt; and integer &lt;span class=&quot;math-container&quot;&gt;$x_1, x_2 \geq 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The solution is &lt;span class=&quot;math-container&quot;&gt;$x_1=10, x_2=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I can change the objective's coefficient from &lt;span class=&quot;math-container&quot;&gt;$-2x_1 + x_2$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$-5x_1 +2x_2$&lt;/span&gt; and the solution would be the same. The first constraint be similarly perturbed with no change in the solution.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Notation&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let an integer linear program be defined by a three-tuple &lt;span class=&quot;math-container&quot;&gt;$P_i = (c_i, A_i, b_i)$&lt;/span&gt;, i.e., &lt;span class=&quot;math-container&quot;&gt;$\min c'x$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$Ax\leq b$&lt;/span&gt;. A solution of &lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt; is denoted &lt;span class=&quot;math-container&quot;&gt;$S_i = \{x: x = \text{argmin } c_i'x, A_ix \leq b_i\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Questions&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the following questions, assume the solutions are unknown.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Generally, when and how do I determine whether two integer linear programs &lt;span class=&quot;math-container&quot;&gt;$P_1, P_2$&lt;/span&gt; yield the same solution?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How do I know what to what degree I can perturb the coefficients in &lt;span class=&quot;math-container&quot;&gt;$c, A, b$&lt;/span&gt; without changing the solution?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In the above, by &amp;quot;the same solution&amp;quot; or &amp;quot;without changing the solution&amp;quot;, I mean two scenarios: 1. the scenario where the solutions are identical, i.e., &lt;span class=&quot;math-container&quot;&gt;$S_1 = S_2$&lt;/span&gt;, and 2. the scenario where the solutions overlap &lt;span class=&quot;math-container&quot;&gt;$|S_1 \cap S_2| \geq 1$&lt;/span&gt; but are not necessarily equal,&lt;/p&gt;&#xA;" OwnerUserId="9336" LastEditorUserId="9336" LastEditDate="2023-06-30T16:29:14.470" LastActivityDate="2023-06-30T16:29:14.470" Title="When do two integer linear programs yield the same solution?" Tags="|linear-programming|integer-programming|sensitivity-analysis|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10640" PostTypeId="1" CreationDate="2023-06-30T12:50:18.950" Score="2" ViewCount="83" Body="&lt;h4&gt;Problem&lt;/h4&gt;&#xA;&lt;p&gt;Say I have a data set of &lt;span class=&quot;math-container&quot;&gt;$n \in \mathbb N$&lt;/span&gt; survey responses to &lt;span class=&quot;math-container&quot;&gt;$N \in \mathbb N$&lt;/span&gt; categorically-valued multiple-choice questions, which we denote as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathbf X = \{ \mathbf x_j \}_{j = 1}^n \subset \mathcal X := \mathcal X_1 \times \dots \times \mathcal X_N \quad \text{with} \quad \mathbf x_j = \{ x_{j \ell } \}_{\ell = 1}^N.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have an idea to perform a clustering analysis as follows:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$k \in \mathbb N$&lt;/span&gt; be the pre-selected number of clusters and define the optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;P: \quad \min_{\mathcal S = \{S_1, \dots, S_k \} } \quad \sum_{i = 1}^k \sum_{\mathbf x \in S_i} \sum_{\ell = 1}^N - \log\left( \frac{1}{|S_i|} \sum_{ \tilde{\mathbf x} \in S_i} \mathbf 1\{ \tilde x_\ell = x_\ell \} \right) \quad \text{s.t.} \quad \bigsqcup \mathcal S = \mathbf X,&#xA;$$&lt;/span&gt;&#xA;i.e. &lt;span class=&quot;math-container&quot;&gt;$\mathcal S$&lt;/span&gt; is a partition of &lt;span class=&quot;math-container&quot;&gt;$\mathbf X$&lt;/span&gt; into &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; disjoint sets (clusters).&lt;/p&gt;&#xA;&lt;p&gt;How could we go about solving this? (Or finding an approximate or local minimum?)&lt;/p&gt;&#xA;&lt;p&gt;I'd be especially happy to hear about open source solvers that could help with this problem.&lt;/p&gt;&#xA;&lt;h4&gt;Motivation and thoughts&lt;/h4&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\delta_{x}$&lt;/span&gt; be the Dirac measure in the point &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Let &lt;span class=&quot;math-container&quot;&gt;$\hat Q_\ell(\bullet|S_i) = \frac{1}{|S_i|} \sum_{ \tilde{\mathbf x} \in S_i} \mathbf 1\{ \tilde x_\ell = \bullet \}$&lt;/span&gt;, i.e. the conditional empircal probability measure given the subset &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt;. Then for &lt;span class=&quot;math-container&quot;&gt;$\mathbf x \in S_i$&lt;/span&gt;, we have the Kullback-Leibler divergence:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;D_{\text{KL}}\left( \delta_{x_\ell} \, \middle\| \, \hat Q_\ell(\bullet|S_i) \right) = \sum_{y \in \mathcal X_\ell} \delta_{x_\ell}(y) \cdot \log \left( \frac{\delta_{x_\ell}(y)}{ \hat Q_\ell(y|S_i) } \right) &amp;amp;= - \log\left( \frac{1}{|S_i|} \sum_{ \tilde{\mathbf x} \in S_i} \mathbf 1\{ \tilde x_\ell = x_\ell \} \right) \\&#xA;&amp;amp;= \log|S_i| - \log \left|\{ \tilde{ \mathbf x } \in S_i : \tilde{x}_\ell = x_\ell  \} \right|.&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;So we're summing over the Kullback-Leibler divergences between the individual responses to question &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; in cluster &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; and conditional empirical distribution for question &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; given &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I'm not sure how to reformulate this into an analysis or solver-amenable problem. It seems like a pretty beastly combinatorial problem.&lt;/p&gt;&#xA;" OwnerUserId="2868" LastEditorUserId="2868" LastEditDate="2023-06-30T13:17:51.513" LastActivityDate="2023-07-04T21:47:58.433" Title="Clustering optimization problem for categorical data: How to solve?" Tags="|optimization|combinatorial-optimization|clustering|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10641" PostTypeId="2" ParentId="10629" CreationDate="2023-06-30T16:25:20.270" Score="1" Body="&lt;p&gt;I found one such instance(from the &amp;quot;P&amp;quot; datasets) and i distilled it to just the customers who will result in this 'phenomenon'.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;NAME : P-n22-k8&#xA;COMMENT : (Augerat et al, No of trucks: 8, Optimal value: 603)&#xA;TYPE : CVRP&#xA;DIMENSION : 9&#xA;EDGE_WEIGHT_TYPE : EUC_2D&#xA;VEHICLES : 3&#xA;CAPACITY : 3000&#xA;&#xA;NODE_COORD_SECTION&#xA;D1 145 215&#xA;C13 156 217&#xA;C15 146 208&#xA;C16 164 208&#xA;C17 141 206&#xA;C18 147 193&#xA;C19 164 193&#xA;C21 155 185&#xA;C22 139 182&#xA;-1&#xA;&#xA;DEMAND_SECTION&#xA;D1 0&#xA;C13 1300&#xA;C15 300&#xA;C16 900&#xA;C17 2100&#xA;C18 1000&#xA;C19 900&#xA;C21 1800&#xA;C22 700&#xA;-1&#xA;&#xA;DEPOT_SECTION&#xA; D1&#xA; -1&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you run this with 3 vs 4 vehicles, you will see a savings of 13. The total demand of this instance is 90 and with only 3 vehicles you have to make sure each route has total demand of 30. This together with C17, who has high demand,  has to be paired with someone with demand = 9 which results in a 'sub-optimal' solution which can be avoided with more vehicles.&lt;/p&gt;&#xA;&lt;p&gt;Generating such instances is not as trivial as i had anticipated. Thanks to Sune for the idea to look at the &amp;quot;P&amp;quot; datasets.&lt;/p&gt;&#xA;" OwnerUserId="5973" LastActivityDate="2023-06-30T16:25:20.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10642" PostTypeId="2" ParentId="10637" CreationDate="2023-07-01T05:12:08.377" Score="1" Body="&lt;p&gt;As @mark-l-stone says, Ipopt does not have a multi-start option. Just solve your model with different starting points manually.&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2023-07-01T05:12:08.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10643" PostTypeId="1" CreationDate="2023-07-01T21:26:56.017" Score="0" ViewCount="84" Body="&lt;p&gt;My scheduling problem has a specific pattern of 2 days of work followed by 2 days off. Additionally, there is a week off after every 4 weeks of work. The scheduling matrix (P) has five different schedules, where 0 represents not working, and 1 represents working. The constraints of my problem include pattern assignment constraints and worker efficiency constraints.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;P = [[0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],&#xA;     [1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1],&#xA;     [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],&#xA;     [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0],&#xA;     [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My objective function aims to maximize the days spent together by married couples while minimizing the days they both work, to make it easier to take care of the children. I am trying to find a compromise between the needs of the employees and the company by assuring at least a certain percentage of the workforce (e.g., 40%) is present every day throughout the year while providing generous rest days for the employees.&#xA;The goal of my project is to increase the workforce proportion to its highest while satisfying the objective functions for 100 employees. However, my current algorithm works well only for up to 30 people. I have noticed that for some reason, certain values of N (such as 14 and 19) result in the highest availability (K can increase up to 4), but I am not sure why. Currently I believe it might be related to how I distribute the worker’s efficiency.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;NOTATION:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;*_:  ℎ     ℎ   &lt;/p&gt;&#xA;&lt;p&gt;_:  ℎ     ℎ   &lt;/p&gt;&#xA;&lt;p&gt;_:   ℎℎ ℎ ℎℎ       (Assumed half of the workforce was married)&lt;/p&gt;&#xA;&lt;p&gt;_:    (    )&lt;/p&gt;&#xA;&lt;p&gt;_:    ℎℎ      &lt;/p&gt;&#xA;&lt;p&gt;_: ℎℎ      &lt;/p&gt;&#xA;&lt;p&gt;_: Binary parameter whether pattern m works on day d&lt;/p&gt;&#xA;&lt;p&gt;N: number of employees&#xA;*&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;MODEL&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Max Σ_ Σ_ Σ_ Σ_ ((_ _ _ _)-(1−)(_ _ _ _ ))&lt;/p&gt;&#xA;&lt;p&gt;s.t.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;sum(_)==1≫Person can only have one schedule&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;_  == (_ _ )≫        &lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;sum(_ _) ≥×&#xA;ℎ   ℎ     ℎ     &#xA;k initially set as 0.3 and improved&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;_≤_ Linearise&#xA;_≤_&#xA;_≥_+ _−1&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt; is currently set as 0.7&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;My questions are&lt;/strong&gt;&lt;/em&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;1.  Is there a better way to model the distribution of worker efficiency? Currently, I am using a normal distribution&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;a = [0] * N&#xA;smart = round(N * 0.021)&#xA;ok = round(smart + N * 0.136)&#xA;notbad = round(ok + N * 0.682)&#xA;bad = round(notbad + N * 0.136)&#xA;dumb = round(bad + N * 0.021)&#xA;for j in range(N):&#xA;    if j &amp;lt;= smart:&#xA;        a[j] = 5&#xA;    elif smart &amp;lt; j &amp;lt;= ok:&#xA;        a[j] = 4&#xA;    elif ok &amp;lt; j &amp;lt;= notbad:&#xA;        a[j] = 3&#xA;    elif notbad &amp;lt; j &amp;lt;= bad:&#xA;        a[j] = 2&#xA;    elif bad &amp;lt; j &amp;lt;= dumb:&#xA;        a[j] = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;2.   Why do certain values of N, such as 14 and 19, result in better outcomes in terms of availability (K)? &amp;gt;&amp;gt; the maximum for 14 and 19 was 0.4 while it was only 0.34 for 11 employees&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here is a full version of the code.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from ortools.linear_solver import pywraplp&#xA;import numpy as np&#xA;import time&#xA;import random&#xA;import signal&#xA;import multiprocessing as mp&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;class Me:&#xA;&#xA;    def __init__(self, kkk, N):&#xA;&#xA;        self.hihi(kkk, N)&#xA;&#xA;    def hihi(self, kkk, N):&#xA;&#xA;        startTime = time.time()&#xA;&#xA;        print(&amp;quot;When N is &amp;quot;, N)&#xA;        # D = 35 # five weeks&#xA;&#xA;        # while()&#xA;        D = 35&#xA;        &#xA;        I = [i for i in range(N)]  # set of workers : 0~39, 40명&#xA;        # k = 0.3&#xA;        k = kkk&#xA;        print(&amp;quot;k is &amp;quot;, k)&#xA;        # Patterns&#xA;        P = []&#xA;&#xA;        #5 DIFFERENT PATTERNS EMPLOYEES CAN BE ASSIGNED TO&#xA;        P = [[0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],&#xA;             [1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1],&#xA;             [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],&#xA;             [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0],&#xA;             [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]&#xA;&#xA;        z = P.copy()&#xA;&#xA;        # pattern-pattern (c, w)&#xA;        c = [[0] * len(P)] * len(P)  # When both patterns are off work&#xA;        w = [[0] * len(P)] * len(P)  # When both patterns are on work&#xA;&#xA;        for m in range(len(P)):  # mth pattern&#xA;            c[m] = [sum([(1 - a) * (1 - b) for a, b in zip(P[m], P[n])]) for n in range(len(P))]&#xA;            w[m] = [sum([a * b for a, b in zip(P[m], P[n])]) for n in range(len(P))]&#xA;&#xA;        #OMIT C MATRIX LESS THAN 9 AND W MATRIX BIGGER THAN 5;&#xA;        #AS EVEN WITH A CONVENTIONAL 5 DAY WEEK, THERE WOULD BE 10 DAYS WHEN THEY ARE BOTH OFF WORK&#xA;        for m in range(len(P)):&#xA;            for n in range(len(c[m])):&#xA;                if c[m][n] &amp;lt; 9 or w[m][n] &amp;gt; 5:&#xA;&#xA;                    c[m][n] = 0&#xA;                    w[m][n] = 0&#xA;&#xA;        print(&amp;quot;C matrix&amp;quot;, c)&#xA;        print(&amp;quot;W matrix&amp;quot;, w)&#xA;&#xA;        #EFFICIENCY OF WORKERS OF NORMAL DIST&#xA;        a = [0] * N&#xA;        smart = round(N * 0.021)&#xA;        ok = round(smart + N * 0.136)&#xA;        notbad = round(ok + N * 0.682)&#xA;        bad = round(notbad + N * 0.136)&#xA;        dumb = round(bad + N * 0.021)&#xA;        for j in range(N):&#xA;            if j &amp;lt;= smart:&#xA;                a[j] = 5&#xA;            elif smart &amp;lt; j &amp;lt;= ok:&#xA;                a[j] = 4&#xA;            elif ok &amp;lt; j &amp;lt;= notbad:&#xA;                a[j] = 3&#xA;            elif notbad &amp;lt; j &amp;lt;= bad:&#xA;                a[j] = 2&#xA;            elif bad &amp;lt; j &amp;lt;= dumb:&#xA;                a[j] = 1&#xA;        print(&amp;quot;original a&amp;quot;, a)&#xA;        for kk in range(N):&#xA;            b = random.randint(0, N - 1)&#xA;            tmp = a[kk]&#xA;            a[kk] = a[b]&#xA;            a[b] = tmp&#xA;        print(&amp;quot;a&amp;quot;, a)&#xA;        sumsum = 0&#xA;        for aa in a:&#xA;            sumsum = sumsum + aa&#xA;        print(sumsum)&#xA;&#xA;        # ASSUMED HALF OF THE WORKFORCE IS MARRIED&#xA;        pa = [[0] * len(I)] * len(I)&#xA;        for i in [2 * j for j in range(int(len(I) / 4))]:&#xA;            pa[i] = [0] * len(I)&#xA;            pa[i + 1] = [0] * len(I)&#xA;            pa[i][i + 1] = 1&#xA;            pa[i + 1][i] = 1&#xA;            # p[2*i+1][2*i] = 1&#xA;        print(&amp;quot;pa&amp;quot;, pa)&#xA;&#xA;        # Solver&#xA;        # Create the mip solver with the CBC backend.&#xA;        solver = pywraplp.Solver.CreateSolver('CBC')&#xA;&#xA;        x = []&#xA;        y = []&#xA;        u = []&#xA;&#xA;        for i in I:&#xA;            t1 = []&#xA;            t2 = []&#xA;            for m in range(len(P)):&#xA;                # for m in range(20):&#xA;                t1.append(solver.IntVar(0, 1, ''))&#xA;            for d in range(len(P[0])):&#xA;                # for d in range(35):&#xA;                t2.append(solver.IntVar(0, 1, ''))&#xA;            x.append(t1)&#xA;            y.append(t2)&#xA;&#xA;        for i in I:&#xA;            t1 = []&#xA;            for j in I:&#xA;                t2 = []&#xA;                for m in range(len(P)):&#xA;                    # for m in range(20):&#xA;                    t3 = []&#xA;                    for n in range(len(P)):&#xA;                        # for n in range(20):&#xA;                        t3.append(solver.IntVar(0, 1, ''))&#xA;                    t2.append(t3)&#xA;                t1.append(t2)&#xA;            u.append(t1)&#xA;&#xA;        #print('Number of variables =', model.NumVari)&#xA;&#xA;        # CONSTRAINTS&#xA;        # pattern assignment constraint&#xA;        for i in I:&#xA;            solver.Add(sum(x[i]) == 1)&#xA;&#xA;        # worker efficiency&#xA;        for d in range(len(P[0])):&#xA;&#xA;            solver.Add(sum(y[i][d] * a[i] for i in I) &amp;gt;= k * sumsum)&#xA;&#xA;&#xA;        # defining y&#xA;        for i in I:&#xA;            for d in range(len(P[0])):&#xA;&#xA;                solver.Add(y[i][d] == sum(z[m][d] * x[i][m] for m in range(len(P))))&#xA;                #THIS SHOULD BE A SOFT CONSTRAINT INSTEAD OF A HARD CONSTRAINT BUT NEED MULTIPLE FEASIBLE SOLUTIONS&#xA;&#xA;        # defining u : linearize!&#xA;        for i in I:&#xA;            for j in I:&#xA;                for m in range(len(P)):&#xA;                    # for m in range(20):&#xA;                    for n in range(len(P)):&#xA;                        # for n in range(20):&#xA;                        solver.Add(u[i][j][m][n] &amp;lt;= x[i][m])&#xA;                        solver.Add(u[i][j][m][n] &amp;lt;= x[j][n])&#xA;                        solver.Add(u[i][j][m][n] &amp;gt;= x[i][m] + x[j][n] - 1)&#xA;&#xA;        # OBJECTIVE FUNCTION&#xA;        objective_terms = []&#xA;        alpha = 0.7&#xA;        for i in I:&#xA;            for j in I:&#xA;                for m in range(len(P)):&#xA;                    # for m in range(20):&#xA;                    for n in range(len(P)):&#xA;                        # for n in range(20):&#xA;                        # objective_terms.append(0)&#xA;                        objective_terms.append(alpha * pa[i][j] * c[m][n] * u[i][j][m][n])&#xA;                        objective_terms.append(- (1 - alpha) * pa[i][j] * w[m][n] * u[i][j][m][n])&#xA;&#xA;        solver.Maximize(solver.Sum(objective_terms))  # MAXIMISING THE OBJECTIVE FUNCTION&#xA;&#xA;        # Solve&#xA;        solver.SetTimeLimit(100000)#SETTING A TIME LIMIT OF 100 SECONDS&#xA;        status = solver.Solve()&#xA;&#xA;        print(&amp;quot;hae&amp;quot;)&#xA;&#xA;        # Print solution.&#xA;        if status == pywraplp.Solver.OPTIMAL or status == pywraplp.Solver.FEASIBLE:&#xA;&#xA;            print('Optimal objective function = ', solver.Objective().Value(), '\n')&#xA;            print('Optimal assignment\n')&#xA;            for i in I:&#xA;                print('Schedule to worker ', i, ': ', int(sum(m * x[i][m].solution_value() for m in range(len(P)))))&#xA;                for m in range(len(P)):&#xA;                    if x[i][m].solution_value() == 1:&#xA;                        print(P[m])&#xA;                        runTime = time.time() - startTime&#xA;                        print(&amp;quot;--- %s seconds ---&amp;quot; % (runTime))&#xA;            print(&amp;quot;finding better solution&amp;quot;)&#xA;            # if N&amp;lt;11 or k&amp;lt;0.33:&#xA;            # if N!=11 and N!=12:&#xA;            if N != 0:&#xA;                kiki = k + 0.01&#xA;                kfork = round(kiki, 3)&#xA;                self.hihi(kfork, N)&#xA;&#xA;&#xA;        else:&#xA;            print(&amp;quot;Sorry we couldn't find any feasible or optimal solution.&amp;quot;)&#xA;&#xA;&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;&#xA;    for i in range(10):&#xA;        for N in range(5, 45):&#xA;            a = Me(0.3, N)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12060" LastEditorUserId="981" LastEditDate="2023-08-02T18:25:17.137" LastActivityDate="2023-08-02T18:25:17.137" Title="how the number of employees affects the married employee scheduling problem" Tags="|python|or-tools|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10645" PostTypeId="2" ParentId="10279" CreationDate="2023-07-02T04:23:14.860" Score="1" Body="&lt;p&gt;Not sure about high-quality, but here's one I wrote: &lt;a href=&quot;https://pypi.org/project/flexible-lp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;flexible_lp&lt;/a&gt;. It uses two-phase simplex.&lt;/p&gt;&#xA;&lt;p&gt;It should work well for small/medium problems but isn't optimized for speed. Just published, so happy for any feedback!&lt;/p&gt;&#xA;" OwnerUserId="12061" LastActivityDate="2023-07-02T04:23:14.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10646" PostTypeId="1" CreationDate="2023-07-02T15:05:35.793" Score="2" ViewCount="58" Body="&lt;p&gt;I'm trying to optimize a noisy loss function (experimental) where the absolute value of the gradient changes significantly depending on the direction taken. In other words, some parameters have a larger influence than others, but all are important. What variant of gradient descent is recommended to use in this case?&lt;/p&gt;&#xA;&lt;p&gt;To provide a little more context. My objective is to define a loss function that would measure, so to speak, the convergence of the model towards a uniform data distribution.&lt;/p&gt;&#xA;&lt;p&gt;I generate K random fictitious observations and compare how many of them are smaller than the true data in the training set. In other words, the model generates K simulations, and we determine the number of simulations where the generated data is smaller than the actual data. If the model is well trained, this distribution should converge to a uniform distribution.&lt;/p&gt;&#xA;&lt;p&gt;However, since the resulting histogram is not differentiable, I needed to approximate this idea using compositions of continuous differentiable functions. The code (in Julia) would be something like this.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;η = 0.1; num_epochs = 100; n_samples = 1000&#xA;optim = Flux.setup(Flux.Adam(η), model)&#xA;losses = []&#xA;l = CustomLoss(2)&#xA;for epoch in 1:num_epochs&#xA;    loss, grads = Flux.withgradient(model) do m&#xA;        aₖ = zeros(l.K+1)&#xA;        for _ in 1:n_samples&#xA;            x = rand(Normal(μ, stddev), l.K)&#xA;            yₖ = m(x')&#xA;            y = target(rand(Normal(μ, stddev)))&#xA;           aₖ += generate_aₖ(l, yₖ, y)&#xA;        end&#xA;        scalar_diff(l, aₖ ./ sum(aₖ))&#xA;    end&#xA;    Flux.update!(optim, model, grads[1])&#xA;    push!(losses, loss)&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So, &lt;code&gt;generate_aₖ(l, yₖ, y)&lt;/code&gt; would return a vector of size &lt;code&gt;K+1&lt;/code&gt;, where the element at index &lt;code&gt;k&lt;/code&gt; is close to 1 if y is greater than k elements of the vector &lt;code&gt;yₖ&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Finally, &lt;code&gt;scalar_diff&lt;/code&gt; calculates the squared difference between the calculated &lt;code&gt;aₖ&lt;/code&gt; and the uniform distribution.&lt;/p&gt;&#xA;&lt;p&gt;After studying the cost function for the simplest case I could think of (learning the parameters of a line &lt;code&gt;m*x + b&lt;/code&gt;), I see that indeed, the minimum is where it should be. However, the function is relatively noisy, and furthermore (as is evident on the other hand) it decreases very rapidly along the parameter &lt;code&gt;m&lt;/code&gt; axis compared to the parameter &lt;code&gt;b&lt;/code&gt; axis.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7vvrv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7vvrv.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12064" LastActivityDate="2023-07-02T15:05:35.793" Title="Optimization of a noisy loss function" Tags="|optimization|machine-learning|loss-functions|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10648" PostTypeId="2" ParentId="10643" CreationDate="2023-07-03T00:01:45.667" Score="1" Body="&lt;p&gt;I don't see anything wrong following normal dist for distributing efficiency level. As for the outcomes, more employees with higher efficiency means more choices with more slack on constraints.&#xA;As for half of them being married it should mean married pairs, otherwise all would be married- fewer choices.&lt;/p&gt;&#xA;&lt;p&gt;Just confirming if you are using a binary variable &lt;span class=&quot;math-container&quot;&gt;$u_{ij}^d$&lt;/span&gt; to count married couple assignment with constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ p_dx_{i,p}+p'_{d}x_{j,p'} \le u_{ij}^d + 1 \ \ \forall p,p' \in P$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ u_{ij}^d \le p_dx_{i,p}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ u_{ij}^d \le p_dx_{j,p} \ \ \forall p \ \ \forall d \ \ \forall (i,j) \in $&lt;/span&gt; Couples&lt;/p&gt;&#xA;&lt;p&gt;And then minimizing &lt;span class=&quot;math-container&quot;&gt;$\sum_d \sum_{(ij)}u_{ij}^d$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-07-03T00:01:45.667" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10649" PostTypeId="1" AcceptedAnswerId="10657" CreationDate="2023-07-03T07:59:53.203" Score="2" ViewCount="68" Body="&lt;p&gt;I'm dealing with a NLP-problem that can be formulated as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{\overrightarrow{x}} f(A\cdot\overrightarrow{x})$$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\overrightarrow{x}$&lt;/span&gt; is a vector of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; design points where every element sits on the interval &lt;span class=&quot;math-container&quot;&gt;$[0, 1]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is a fixed binary matrix of shape &lt;span class=&quot;math-container&quot;&gt;$(j, n)$&lt;/span&gt;. The input of the function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is thus a variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; of size &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, but the decision variable is the vector of size &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f(.)$&lt;/span&gt; is a non-linear function of the form &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^j a-\left(bx_i\right)^c*d+\left(ex_i\right)^{f}g+h$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$a, b, c, d, e, f, g, h$&lt;/span&gt; are alle positive and non-integers constants.&lt;/p&gt;&#xA;&lt;p&gt;The constraint that we are dealing with is linear:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac{\sum_{i=1}^j d_ix_i}{\sum_{i=1}^jd_i} = \beta$$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; is a constant variable and &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; is a constant on the interval &lt;span class=&quot;math-container&quot;&gt;$[0, 1]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I'm looking for a derivative-free based optimization algorithm that can optimize the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-design points but considering the linear constraint.&lt;/p&gt;&#xA;&lt;p&gt;Are there any derivative-free based optimization methods that can handle constraints?&lt;/p&gt;&#xA;" OwnerUserId="329" LastActivityDate="2023-07-03T23:59:09.120" Title="Derivative-free based optimization subject to a linear constraint" Tags="|optimization|nonlinear-programming|nlp|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10650" PostTypeId="2" ParentId="231" CreationDate="2023-07-03T10:36:09.860" Score="2" Body="&lt;p&gt;I'm currently working on the optimal transmission problem (OTS), that is a particular optimization problem that is originally formulated as a mixed-integer non-linear problem and usually reformulated as a mixed-integer linear optimization problem that requires bigMs. I show below a summary of the results for 100 random instances of this problem. This plot compares three methods:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Gurobi: just solving the OTS problem as a mixed-integer non-linear problem that includes the product of binary and continuous variables. This method does not require bigMs.&lt;/li&gt;&#xA;&lt;li&gt;Fattahi: Formulate the OTS as a mixed-integer linear problem with bigM that are tuned as proposed in &lt;a href=&quot;https://ieeexplore.ieee.org/document/8451930&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ieeexplore.ieee.org/document/8451930&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Proposed: The method we propose to find better bigMs in this preprint (&lt;a href=&quot;https://arxiv.org/abs/2306.02784&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/2306.02784&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/S1Kfq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S1Kfq.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you can see, methods 1) and 2) are unable to solve the 100 instances to optimality within a maximum time of 1 hour, while our method can solve all problems in a maximum time of 800 seconds.&lt;/p&gt;&#xA;&lt;p&gt;I also implemented the indicator function in Gurobi, although I did not include it in the figure because the results are worse than the mixed-integer non-linear solutions provided by Gurobi. In fact, this approach does not solve any of the 100 instances in 1 hour. The average gap is 6.91% and the maximum gap amounts to 12.51%. Then, even though I am not sure what Gurobi is doing &amp;quot;behind the scenes&amp;quot; with this indicator constraints, its computational performance is questionable.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt; I agree with other opinions here and, in my experience, using information about the problem to properly tune bigMs normally provides better computational results than using general purpose methods implemented in commercial optimization solvers such as CPLEX or Gurobi.&lt;/p&gt;&#xA;" OwnerUserId="3637" LastActivityDate="2023-07-03T10:36:09.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10652" PostTypeId="1" CreationDate="2023-07-03T14:48:16.540" Score="2" ViewCount="172" Body="&lt;p&gt;There is an equation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;280a + 80b + 75c + 50d + 25e - 30f - 42g = R&lt;/code&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;a, b, c, d, e, f, g&lt;/code&gt; - those are &lt;em&gt;modifiers&lt;/em&gt;. They're strictly positive integer values.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;R&lt;/code&gt; - this is a &lt;em&gt;solution range&lt;/em&gt;, the equation is valid as long as the result of its left side falls into that range.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The goal is:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For each possible &lt;em&gt;&lt;strong&gt;subset of the variable set&lt;/strong&gt;&lt;/em&gt; find the smallest sum of &lt;em&gt;&lt;strong&gt;modifiers&lt;/strong&gt;&lt;/em&gt; values such that the result of the left side of the equation is within given &lt;em&gt;&lt;strong&gt;solution range&lt;/strong&gt;&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Subsets are defined by inclusion of &lt;em&gt;modifiers&lt;/em&gt;. I.e., &lt;em&gt;modifier&lt;/em&gt; can either &lt;code&gt;== 0&lt;/code&gt; or &lt;code&gt;&amp;gt; 0&lt;/code&gt;.&lt;br /&gt;&#xA;For example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;b, c, d, e, f, g == 0&lt;/code&gt; and &lt;code&gt;a &amp;gt; 0&lt;/code&gt; is 1st subset&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;a, c, d, e, f, g == 0&lt;/code&gt; and &lt;code&gt;b &amp;gt; 0&lt;/code&gt; is 2nd subset&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;c, d, e, f, g == 0&lt;/code&gt; and &lt;code&gt;a, b &amp;gt; 0&lt;/code&gt; is 3rd subset&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;etc...&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Basically it's like counting in binary. Ergo there's a total of 128 subsets (technically 127 since a subset where all modifiers &lt;code&gt;== 0&lt;/code&gt; isn't needed as a solution).&lt;/p&gt;&#xA;&lt;p&gt;Note: I know that &lt;code&gt;e&lt;/code&gt; can replace &lt;code&gt;c, d&lt;/code&gt; modifiers as both of these are divisible by it, but I still need those as separate modifiers for the sake of unique permutations.&lt;/p&gt;&#xA;&lt;p&gt;Basically, the &lt;em&gt;&lt;strong&gt;solution range&lt;/strong&gt;&lt;/em&gt; is the input and the result should be a &lt;em&gt;&lt;strong&gt;list of all valid subsets with the smallest sum of modifiers&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here's an example of a valid result:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Let the range we input be from -2 to -2&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here's a list of smallest solutions for a couple different subsets (not all possible) with just &lt;code&gt;b, c, d, e, f, g&lt;/code&gt; modifiers: &lt;a href=&quot;https://imgur.com/a/ZlWeAlq&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://imgur.com/a/ZlWeAlq&lt;/a&gt; (permutation == subset, I didn't use the correct terminology at the time).&lt;/p&gt;&#xA;&lt;p&gt;Plugging these values in the equation will result in &lt;code&gt;-2&lt;/code&gt; on every subset (assume &lt;code&gt;a&lt;/code&gt; modifier is 0, I didn't include it in my first solver).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I made a quick bruteforce solution in C# with a parallel loop just going over all possible values (within boundaries) until it finds all solutions, but it's painfully slow.&lt;/p&gt;&#xA;&lt;p&gt;A couple algorithms I have considered:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Breadth-first search:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Add 1 of each &lt;em&gt;modifier&lt;/em&gt; and check if any individual &amp;quot;node&amp;quot; is a solution. Then add 1 of each &lt;em&gt;modifier&lt;/em&gt; to each previous node and see if any of the new nodes are solutions.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I'll have to somehow optimize it to not check the same path multiple times since adding 2 &lt;em&gt;modifiers&lt;/em&gt; in different order will lead to the same node&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This grows really fast in terms of memory, so I'll have to limit it to some range of values within which I allow this &amp;quot;branching&amp;quot;, and then I'll only allow addition of identical &lt;em&gt;modifiers&lt;/em&gt; until that &amp;quot;branching range&amp;quot; is close enough to the &lt;em&gt;solution range&lt;/em&gt;. Something like:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if a &lt;em&gt;solution range&lt;/em&gt; is smth like 500-550, I'll only allow &lt;em&gt;modifiers&lt;/em&gt; with positive coefficients to be added to itself until the value on each node is within 100 of the &lt;em&gt;solution range&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Simplify an arbitrary working answer:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Calculate the minimum difference you can create given the selected modifier set&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Calculate how many minimum differences added together it takes to get into a &lt;em&gt;solution range&lt;/em&gt; which can give a large number of modifiers being used but its a working answer&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a table to quickly simplify/neutralize the modifiers with each other until you get the minimum possible&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Bruteforce, but with even more optimization:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I could add the same range check to a bruteforce algorithm so that it only tries every combination within a given range, as well as remove some unnecessary repetitions (my current solution sucks quite hard)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Another hopefully decent optimization I can think of right off the bat is to remove impossible subsets for a given range at the very start.&lt;/p&gt;&#xA;&lt;p&gt;For example, if a range is positive, then subsets where only &lt;code&gt;f&lt;/code&gt;, only &lt;code&gt;g&lt;/code&gt; or only &lt;code&gt;f, g&lt;/code&gt; &lt;em&gt;modifiers&lt;/em&gt; are &lt;code&gt;&amp;gt; 0&lt;/code&gt; will never be a valid answer since both of these have negative coefficients (can't ever reach a positive range by adding negative values).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;So my question is, which algorithm, either from the ones that I thought of or from other existing algorithms that I didn't think of, would be able to quickly and efficiently solve this problem?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have yet to try to implement any of these since I'm not sure whether they will be good at all and if there are any existing algorithms that would be much better than any of the things I could think of. My bruteforce solution still exists and, if needed, I can link it. It is terribly slow tho and definitely not worth comparison in its current form.&lt;/p&gt;&#xA;" OwnerUserId="12071" LastEditorUserId="727" LastEditDate="2023-12-05T23:53:27.677" LastActivityDate="2024-01-05T00:01:00.147" Title="Find an algorithm for quickly computing results to a given equation" Tags="|optimization|algorithms|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10653" PostTypeId="1" CreationDate="2023-07-03T15:54:55.033" Score="0" ViewCount="268" Body="&lt;p&gt;This is the Travelling Salesperson Problem code from Google's OR tools. I used a simple instance that is defined in the data dictionary and has optimal value (sum of Euclidean distances) of 36.26 for the path [0, 2, 4, 1, 3,0]. However, the solution outputs 34, an integer value that is not correct and it makes me doubt whether if it doesn't know the actual objective value it is doing the optimization correctly. It is using the rounded integer distances rather than the actual floating point values even though I set the distance matrix to contain floating point values. How do I get the correct floating point output?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;&amp;quot;&amp;quot;Simple Travelling Salesperson Problem (TSP) on a circuit board.&amp;quot;&amp;quot;&amp;quot;&#xA;&#xA;import math&#xA;from ortools.constraint_solver import routing_enums_pb2&#xA;from ortools.constraint_solver import pywrapcp&#xA;&#xA;def compute_euclidean_distance_matrix(locations):&#xA;    &amp;quot;&amp;quot;&amp;quot;Creates callback to return distance between points.&amp;quot;&amp;quot;&amp;quot;&#xA;    distances = {}&#xA;    for from_counter, from_node in enumerate(locations):&#xA;        distances[from_counter] = {}&#xA;        for to_counter, to_node in enumerate(locations):&#xA;            if from_counter == to_counter:&#xA;                distances[from_counter][to_counter] = 0&#xA;            else:&#xA;                # Euclidean distance&#xA;                distances[from_counter][to_counter] = ((&#xA;                    math.hypot((from_node[0] - to_node[0]),&#xA;                               (from_node[1] - to_node[1]))))&#xA;                &#xA;#                 distances[from_counter][to_counter] = ((from_node[0] - to_node[0])**2 + &#xA;#                                (from_node[1] - to_node[1])**2)**0.5 &#xA;                &#xA;    return distances &#xA;&#xA;def print_solution(manager, routing, solution):&#xA;    &amp;quot;&amp;quot;&amp;quot;Prints solution on console.&amp;quot;&amp;quot;&amp;quot;&#xA;    print('Objective: {}'.format(solution.ObjectiveValue()))&#xA;    index = routing.Start(0)&#xA;    plan_output = 'Route:\n'&#xA;    route_distance = 0&#xA;    while not routing.IsEnd(index):&#xA;        plan_output += ' {} -&amp;gt;'.format(manager.IndexToNode(index))&#xA;        previous_index = index&#xA;        index = solution.Value(routing.NextVar(index))&#xA;        route_distance += routing.GetArcCostForVehicle(previous_index, index, 0)&#xA;    plan_output += ' {}\n'.format(manager.IndexToNode(index))&#xA;    print(plan_output)&#xA;    plan_output += 'Objective: {}m\n'.format(route_distance)&#xA;&#xA;&#xA;def main():&#xA;    &amp;quot;&amp;quot;&amp;quot;Entry point of the program.&amp;quot;&amp;quot;&amp;quot;&#xA;    # Instantiate the data problem. &#xA;    data = {'locations': [(1,2), (12,3), (4.5,5), (4,1), (18,6)], 'num_vehicles': 1, 'depot': 0}&#xA;    &#xA;    print('data: ', data)&#xA;    &#xA;    # Create the routing index manager.&#xA;    manager = pywrapcp.RoutingIndexManager(len(data['locations']),&#xA;                                           data['num_vehicles'], data['depot'])&#xA;&#xA;    # Create Routing Model.&#xA;    routing = pywrapcp.RoutingModel(manager)&#xA;&#xA;    distance_matrix = compute_euclidean_distance_matrix(data['locations'])&#xA;    &#xA;    print('distance_matrix: ', distance_matrix)&#xA;    &#xA;    def distance_callback(from_index, to_index):&#xA;        &amp;quot;&amp;quot;&amp;quot;Returns the distance between the two nodes.&amp;quot;&amp;quot;&amp;quot;&#xA;        # Convert from routing variable Index to distance matrix NodeIndex.&#xA;        from_node = manager.IndexToNode(from_index)&#xA;        to_node = manager.IndexToNode(to_index)&#xA;        return distance_matrix[from_node][to_node]&#xA;&#xA;    transit_callback_index = routing.RegisterTransitCallback(distance_callback)&#xA;&#xA;    # Define cost of each arc.&#xA;    routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)&#xA;&#xA;    # Setting first solution heuristic.&#xA;    search_parameters = pywrapcp.DefaultRoutingSearchParameters()&#xA;    search_parameters.first_solution_strategy = (&#xA;        routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)&#xA;&#xA;    # Solve the problem.&#xA;    solution = routing.SolveWithParameters(search_parameters)&#xA;&#xA;    # Print solution on console.&#xA;    if solution:&#xA;        print_solution(manager, routing, solution)&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11516" LastEditorUserId="11516" LastEditDate="2023-07-03T16:02:02.960" LastActivityDate="2023-07-03T16:13:50.977" Title="TSP problem using Google's OR tools" Tags="|optimization|or-tools|traveling-salesman|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10654" PostTypeId="2" ParentId="10653" CreationDate="2023-07-03T16:13:16.560" Score="2" Body="&lt;p&gt;The solver is integral, and python silently rounds all distances to the nearest integer.&lt;/p&gt;&#xA;&lt;p&gt;see &lt;a href=&quot;https://developers.google.com/optimization/routing/tsp#create_the_data&quot; rel=&quot;nofollow noreferrer&quot;&gt;The note in the guide&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-07-03T16:13:16.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10655" PostTypeId="2" ParentId="10653" CreationDate="2023-07-03T16:13:50.977" Score="2" Body="&lt;p&gt;Indeed, OrTools does not take into account floating point values for the distance matrix, and automatically performs rounding, as you suspected.&lt;/p&gt;&#xA;&lt;p&gt;One way around this is to artificially multiply all distances by &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt; (considering your precision is &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; decimals), and then divide your objective function value by &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt; at the end.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2023-07-03T16:13:50.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10656" PostTypeId="1" AcceptedAnswerId="10658" CreationDate="2023-07-03T17:05:33.563" Score="2" ViewCount="386" Body="&lt;p&gt;I have a scheduling problem I am trying to work through. As I was outlining the problem, I realized it is probably of a known problem type, but I am unsure of what keywords to search for or what software to use.&lt;/p&gt;&#xA;&lt;p&gt;I have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; tasks and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; workers. For each task, I must determine when the task is completed, and by which worker. Each worker can only work on one task at a time, and each task must be completed. Each worker is only qualified to perform a specific set of tasks, so each task can only be completed by a specific set of workers.&lt;/p&gt;&#xA;&lt;p&gt;Each task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; has a scheduled start time &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; and scheduled duration &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt;. Tasks may start later than their scheduled start time, but may not start earlier. Some tasks must start exactly on time. Tasks will always take exactly &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; time to complete. There is no deadline to complete any task, and tasks can be completed in any order (as long as they do not start before their start date).&lt;/p&gt;&#xA;&lt;p&gt;Define the actual start time for each task as &lt;span class=&quot;math-container&quot;&gt;$t_i$&lt;/span&gt;, and the &amp;quot;wait to start time&amp;quot; for task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$t_i - s_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The goal is to schedule the tasks by assigning them to workers and determining their start times such that the total &amp;quot;wait to start&amp;quot; time for each task is minimized. That is, my objective is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_i \left(t_i - s_i \right)$&lt;/span&gt;, subject to the above constraints.&lt;/p&gt;&#xA;&lt;p&gt;I can easily frame this as a integer linear program by creating &lt;span class=&quot;math-container&quot;&gt;$n \cdot p \cdot k$&lt;/span&gt; binary decision variables, where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is the maximum number of &amp;quot;wait to start&amp;quot; days that I allow. The problem here is that this can be a very large number of decision variables for integer programming, as &lt;span class=&quot;math-container&quot;&gt;$n \approx 200$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p \approx 20$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is on the order of hundreds. Additionally, I would not like to set a global maximum on &amp;quot;wait to start&amp;quot; days.&lt;/p&gt;&#xA;&lt;p&gt;An alternative formulation requires only &lt;span class=&quot;math-container&quot;&gt;$n \cdot p$&lt;/span&gt; decision variables for the assignments, plus &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; decision variables for the start times, but in this case, the constraint that each worker can only work on one task at once becomes very non-linear.&lt;/p&gt;&#xA;&lt;p&gt;What type(s) of problem is this and what software exists to solve it? I am open to both exact solvers and heuristics. Our current workflow to solve this problem is a homemade greedy algorithm that assigns workers to tasks via iterating over time, so I imagine an integer/constraint programming approach will lead to a much better solution.&lt;/p&gt;&#xA;" OwnerUserId="9724" LastEditorUserId="9724" LastEditDate="2023-07-03T21:43:34.317" LastActivityDate="2023-07-04T07:38:23.393" Title="Scheduling to minimize total &quot;wait to start&quot; time" Tags="|mixed-integer-programming|scheduling|constraint-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10657" PostTypeId="2" ParentId="10649" CreationDate="2023-07-03T18:02:04.547" Score="2" Body="&lt;p&gt;Why do you want derivative-free (see below)? A good derivative-based local optimization solver should be more robust and likely faster executing than a derivative-free solver.&lt;/p&gt;&#xA;&lt;p&gt;If you insist on using a derivative-free optimizer for some reason, you can use &lt;a href=&quot;https://www.pdfo.net/docs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;LINCOA&lt;/a&gt;, which is a highly regarded derivative-free solver for linearly-constrained optimization problems. It was written by the late &lt;a href=&quot;https://en.wikipedia.org/wiki/Michael_J._D._Powell&quot; rel=&quot;nofollow noreferrer&quot;&gt;Michael J.D. Powell&lt;/a&gt;. LINCOA builds up a quadratic model of the objective, and solves a series of trust-region subproblems to arrive at the solution to the original problem. It is a local optimizer, meaning, that if the optimization problem (in your case, specifically, the objective function) is not convex, the solution found by the solver might not be a global minimum.&lt;/p&gt;&#xA;&lt;p&gt;It is not difficult to calculate (first) derivatives of this objective function with hand-coding, Alternatively, derivatives can easily be calculated by automatic differentiation. Optimization systems such as AMPL can handle that automatically for you. The global optimizer BARON computes whatever derivatives are needed. If  &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;c,f \le 1$&lt;/span&gt;, the optimization problem is convex, and even a local optimization solver should find the global minimum; if the optimization problem is not convex, you may need a global optimization solver to find the global minimum.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="500" LastEditDate="2023-07-03T23:59:09.120" LastActivityDate="2023-07-03T23:59:09.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10658" PostTypeId="2" ParentId="10656" CreationDate="2023-07-03T18:10:14.680" Score="4" Body="&lt;p&gt;I recommend using your second formulation with &lt;span class=&quot;math-container&quot;&gt;$np$&lt;/span&gt; binary assignment variables and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; continuous start variables.  To prevent overlapping tasks for the same worker, impose a linear disjunction for each pair of tasks that can be assigned to the same worker, as in this question:&#xA;&lt;a href=&quot;https://or.stackexchange.com/questions/6078/modelling-precedence-relations&quot;&gt;Modelling precedence relations&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Explicitly, let &lt;span class=&quot;math-container&quot;&gt;$x_{iw}$&lt;/span&gt; indicate whether task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to worker &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; indicate whether task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; precedes task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_w x_{iw} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \tag1\label1\\&#xA;x_{iw} + x_{jw} - 1 &amp;amp;\le y_{ij} + y_{ji} &amp;amp;&amp;amp;\text{for all $i,j,w$} \tag2\label2\\&#xA;t_i + d_i - t_j &amp;amp;\le M_{ij}(1-y_{ij}) &amp;amp;&amp;amp;\text{for all $i,j$} \tag3\label3&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} assigns each task to exactly one worker.&#xA;Constraint \eqref{2} enforces &lt;span class=&quot;math-container&quot;&gt;$(x_{iw} \land x_{jw}) \implies (y_{ij} \lor y_{ji})$&lt;/span&gt;.&#xA;Constraint \eqref{3} enforces &lt;span class=&quot;math-container&quot;&gt;$y_{ij} = 1 \implies t_i + d_i \le t_j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-07-03T19:44:03.683" LastActivityDate="2023-07-03T19:44:03.683" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="10659" PostTypeId="2" ParentId="10652" CreationDate="2023-07-03T22:02:57.480" Score="0" Body="&lt;p&gt;Formulate this as one (highly-separable, but) large linear program. This reduces the amount of setup overhead at the expense of modest memory consumption, so long as you use sparse matrices correctly for your constraints.&lt;/p&gt;&#xA;&lt;p&gt;The biggest drawback of this approach is that if &lt;em&gt;any&lt;/em&gt; one permutation is infeasible, the entire problem is infeasible.&lt;/p&gt;&#xA;&lt;p&gt;Set your optimization coefficients (&lt;code&gt;c&lt;/code&gt;) to all 1. There will be 448 decision variables, one for each non-zero position in your permutation matrix (do not include zero-positions in the problem). All decision variables are integral and have a lower bound of 1. Each permutation has two constraint rows: one for the lower bound and one for the upper bound. Depending on which solver you use, you either need to (as below) represent everything in one inequality matrix, or separate into lower and upper constraint matrices. When implemented correctly this should execute in less than a second.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import numpy as np&#xA;import scipy.sparse&#xA;from scipy.optimize import linprog&#xA;&#xA;coef = np.array((280, 80, 75, 50, 25, 30, 42))&#xA;n = len(coef)&#xA;m = 2**n - 1&#xA;&#xA;perm_index = np.arange(m, dtype=np.uint8)&#xA;perm_bits = np.unpackbits(&#xA;    1 + perm_index[:, np.newaxis],&#xA;    axis=1, count=n, bitorder='little',&#xA;)  # 127x7&#xA;perm_mask = perm_bits.astype(bool).ravel()    # 889&#xA;perm_index = perm_index.repeat(n)[perm_mask]  # 448&#xA;&#xA;low = 500&#xA;high = 600&#xA;c = np.ones_like(perm_index)  # 448&#xA;&#xA;'''&#xA;280  .    .   . . . . (448)&#xA;.    80   .   . . . .&#xA;.    .    280 80 &#xA;.    .    .   . 75 . .&#xA;(127)&#xA;'''&#xA;sparse_coef = scipy.sparse.coo_array((&#xA;    # overload 4: data, (i, j)&#xA;    np.tile(coef, m)[perm_mask],  # data&#xA;    (&#xA;        perm_index,         # row indices&#xA;        np.arange(len(c)),  # column indices&#xA;    ),&#xA;)).tocsr()  # 127x448&#xA;A_ub = scipy.sparse.vstack((-sparse_coef, sparse_coef))  # 254x448&#xA;b_ub = np.concatenate((&#xA;    np.full(shape=m, fill_value=-low),&#xA;    np.full(shape=m, fill_value=high),&#xA;))  # 254&#xA;&#xA;res = linprog(c=c, integrality=c, bounds=(1, None), A_ub=A_ub, b_ub=b_ub)&#xA;assert res.success, res.message&#xA;&#xA;x_full = np.zeros(m*n, dtype=int)  # 889&#xA;x_full[perm_mask] = res.x&#xA;x_full = x_full.reshape((m, n))  # 127x7&#xA;print(x_full)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;[[ 2  0  0  0  0  0  0]&#xA; [ 0  7  0  0  0  0  0]&#xA; [ 1  3  0  0  0  0  0]&#xA; [ 0  0  7  0  0  0  0]&#xA; [ 2  0  1  0  0  0  0]&#xA; [ 0  6  1  0  0  0  0]&#xA; [ 1  1  2  0  0  0  0]&#xA; [ 0  0  0 10  0  0  0]&#xA;...&#xA; [ 0  4  1  1  1  1  1]&#xA; [ 1  1  1  1  1  1  1]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11118" LastEditorUserId="11118" LastEditDate="2023-07-04T13:11:43.547" LastActivityDate="2023-07-04T13:11:43.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10660" PostTypeId="1" CreationDate="2023-07-04T02:01:44.807" Score="2" ViewCount="106" Body="&lt;p&gt;I have an optimisation problem that I believe is a variant of the 'bin packing problem with precedence', but I'm unsure of if that is the correct paradigm to work with and I'm not having a huge amount of success searching for how to implement this problem and my desired constraints.&lt;/p&gt;&#xA;&lt;p&gt;What I am trying to implement is this:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have 'x' input stacks of items which have two key parameters - colour and length (see figure)&lt;/li&gt;&#xA;&lt;li&gt;I want to rearrange these input stacks of items into eight possible output locations - this number of locations/bins is fixed. I don't necessarily need to use all eight, but there is no possibility of more.&lt;/li&gt;&#xA;&lt;li&gt;My preference for placing items in locations/bins are:&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Colours grouped together&lt;/li&gt;&#xA;&lt;li&gt;Longer items cannot be stacked on top of shorter items&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In addition:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I can only access the top item of each input stack at any time&lt;/li&gt;&#xA;&lt;li&gt;I can only handle each item once&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1WTFc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1WTFc.png&quot; alt=&quot;Input stacks of items&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As noted, my first issue is understanding what type of problem this is so I can implement the appropriate framework.&lt;/p&gt;&#xA;&lt;p&gt;From what I understand I have hard constraints (eight final locations, only access top item from each input stack) and soft constraints (group colours, no longer items on top of shorter items). Eventually I would like to add further soft constraints (e.g. preference taking items from input stack 1 first).&lt;/p&gt;&#xA;&lt;p&gt;I have tried to repurpose an OR-Tools example to formulate my problem, but the output is not as expected and I'm not sure if it's because I'm going about this incorrectly, or I've just not formulated the problem/constraints properly.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from ortools.linear_solver import pywraplp&#xA;&#xA;# Sample data representing the objects in the initial stacks&#xA;initial_stacks = [&#xA;    [{'colour': 'red', 'length': '3'}, {'colour': 'blue', 'length': '4'}, {'colour': 'red', 'length': '3'}],&#xA;    [{'colour': 'blue', 'length': '2'}, {'colour': 'green', 'length': '4'}, {'colour': 'red', 'length': '4'}],&#xA;    [{'colour': 'green', 'length': '2'}, {'colour': 'red', 'length': '3'}, {'colour': 'blue', 'length': '3'}],&#xA;    [{'colour': 'red', 'length': '4'}, {'colour': 'red', 'length': '3'}, {'colour': 'blue', 'length': '3'}]&#xA;]&#xA;num_initial_stacks = len(initial_stacks)&#xA;&#xA;# Create the solver&#xA;solver = pywraplp.Solver.CreateSolver('SCIP')&#xA;&#xA;# Create decision variables&#xA;num_new_stacks = 8&#xA;num_objects = sum(len(stack) for stack in initial_stacks)&#xA;num_colors = len(set(obj['colour'] for stack in initial_stacks for obj in stack))&#xA;x = {}&#xA;for i in range(num_objects):&#xA;    for j in range(num_new_stacks):&#xA;        for c in range(num_colors):&#xA;            x[i, j, c] = solver.BoolVar(f'x[{i},{j},{c}]')&#xA;&#xA;# Set constraints&#xA;# Each object is placed in only one stack and one length within each stack&#xA;for i in range(num_objects):&#xA;    solver.Add(solver.Sum(x[i, j, c] for j in range(num_new_stacks) for c in range(num_colors)) == 1)&#xA;&#xA;# Grouping constraints: Objects with the same colour are grouped together&#xA;for c in range(num_colors):&#xA;    for j in range(num_new_stacks):&#xA;        solver.Add(solver.Sum(x[i, j, c] for i in range(num_objects)) &amp;lt;= 1)&#xA;&#xA;# Objective function: Maximize the number of grouped objects&#xA;objective = solver.Objective()&#xA;for i in range(num_objects):&#xA;    for j in range(num_new_stacks):&#xA;        for c in range(num_colors):&#xA;            objective.SetCoefficient(x[i, j, c], 1)&#xA;objective.SetMaximization()&#xA;&#xA;# Solve the problem&#xA;status = solver.Solve()&#xA;&#xA;# Print the solution&#xA;if status == pywraplp.Solver.OPTIMAL:&#xA;    print('Objective value:', objective.Value())&#xA;    for j in range(num_new_stacks):&#xA;        stack = []&#xA;        for i in range(num_objects):&#xA;            for c in range(num_colors):&#xA;                if x[i, j, c].solution_value() == 1:&#xA;                    stack.append((f'Object {i}', f'Color {c}'))&#xA;        print(f'New Stack {j+1}:', stack)&#xA;else:&#xA;    print('The problem does not have an optimal solution.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which produces the output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Objective value: 12.0&#xA;New Stack 1: [('Object 0', 'Color 0'), ('Object 1', 'Color 1'), ('Object 2', 'Color 2')]&#xA;New Stack 2: [('Object 3', 'Color 0'), ('Object 4', 'Color 1'), ('Object 5', 'Color 2')]&#xA;New Stack 3: [('Object 6', 'Color 0'), ('Object 7', 'Color 1'), ('Object 8', 'Color 2')]&#xA;New Stack 4: [('Object 9', 'Color 0'), ('Object 10', 'Color 1'), ('Object 11', 'Color 2')]&#xA;New Stack 5: []&#xA;New Stack 6: []&#xA;New Stack 7: []&#xA;New Stack 8: []&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12074" LastEditorUserId="981" LastEditDate="2023-12-31T11:09:51.427" LastActivityDate="2024-01-30T12:01:15.153" Title="Rearrange 'x' piles of items into eight possible locations/bins based on item colour and length" Tags="|integer-programming|or-tools|scip|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10661" PostTypeId="2" ParentId="10656" CreationDate="2023-07-04T07:38:23.393" Score="2" Body="&lt;p&gt;Based on what you mentioned, something should be considered. First, your problem falls in the class of parallel machine scheduling problems. There are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; tasks that should be processed by &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; resources. Second, you already have released time, &lt;span class=&quot;math-container&quot;&gt;$r_{j}$&lt;/span&gt;, and resource eligibility, &lt;span class=&quot;math-container&quot;&gt;$M_{j}$&lt;/span&gt;, constraints. I am not sure if you have a precedence relation that is very common in such kinds of problems. If there exists, the problem can be solved very effectively, say optimal, by the &lt;span class=&quot;math-container&quot;&gt;$\text{CPM}$&lt;/span&gt; algorithm.&lt;/p&gt;&#xA;&lt;p&gt;B.T.W, the problem can be represented as &lt;span class=&quot;math-container&quot;&gt;$ P_{k} | r_{j}, M_{j} | C_{max}/\sum C_{j}$&lt;/span&gt;. Where &lt;span class=&quot;math-container&quot;&gt;$\sum C_{j}$&lt;/span&gt; would be the total flow of tasks. Also, you can use other uncommon objective functions like what you proposed as &lt;span class=&quot;math-container&quot;&gt;$\sum_i \left(t_i - s_i \right)&#xA;$&lt;/span&gt;, but in many cases, you might lose an active schedule. One of the best algorithms to tackle such a problem would be the &lt;span class=&quot;math-container&quot;&gt;$\text{LSF}$&lt;/span&gt;, the least flexible job first, algorithm. Also in the case that all of the tasks have a duration equal to one and also without given released time, this achieves an optimal schedule.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$\text{LSF}$&lt;/span&gt; rule selects, every time a machine is freed, among&#xA;the available jobs the job that can be processed on the smallest&#xA;number of machines, i.e., the least flexible job. Ties may be broken&#xA;arbitrarily.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Please be aware that, as many of the problems in this class of scheduling are strongly NP-hard, developing an appropriate mathematical model without having a solution procedure, like decomposition methods, etc, would be challenging work. I recommend you to look at &lt;a href=&quot;https://web-static.stern.nyu.edu/om/software/lekin/&quot; rel=&quot;nofollow noreferrer&quot;&gt;LEKIN software&lt;/a&gt; which is one of the excellent to test and benchmark such problems.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-07-04T07:38:23.393" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10662" PostTypeId="1" CreationDate="2023-07-04T09:39:18.477" Score="7" ViewCount="626" Body="&lt;p&gt;I am looking for the formulation of a constraint that does the following. I want to introduce a new binary variable &lt;span class=&quot;math-container&quot;&gt;$\kappa_{it}$&lt;/span&gt; that takes the value 1 if the sum of the other binary variable &lt;span class=&quot;math-container&quot;&gt;$\omega_{it}$&lt;/span&gt; is greater than or equal to the number &lt;span class=&quot;math-container&quot;&gt;$N_{\max}$&lt;/span&gt; by time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Otherwise, it is to become zero. My suggestion would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{k=1}^{t}\omega_{ik}\le N_{\max} + M \cdot \kappa_{it}\\&#xA;N_{\max}+\mu\le\sum_{k=1}^{t}\omega_{ik}+\left( 1-\kappa_{it} \right) \cdot M $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; is a small value. Is that correct?&lt;/p&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="8" LastEditDate="2023-10-07T21:38:27.730" LastActivityDate="2023-10-07T21:38:27.730" Title="How can one model a binary variable?" Tags="|linear-programming|modeling|constraint|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10663" PostTypeId="2" ParentId="10662" CreationDate="2023-07-04T10:09:00.587" Score="7" Body="&lt;p&gt;You want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{k=1}^t \omega_{ik} \ge N_{max} \iff \kappa_{it}=1&#xA;$$&lt;/span&gt;&#xA;Or equivalently&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\left( \kappa_{it}=1 \implies \sum_{k=1}^t \omega_{ik} \ge N_{max}  \right) &#xA;\wedge&#xA;\left( \kappa_{it}=0 \implies \sum_{k=1}^t \omega_{ik} \le N_{max}-1\right)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can enforce this with big-M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;N_{max}\kappa_{it} \le \sum_{k=1}^t \omega_{ik} \le N_{max}-1+(t+1-N_{max})\kappa_{it}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-07-04T12:33:03.580" LastActivityDate="2023-07-04T12:33:03.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10665" PostTypeId="2" ParentId="10660" CreationDate="2023-07-04T19:39:06.367" Score="0" Body="&lt;p&gt;You can consult the &lt;a href=&quot;https://www.geeksforgeeks.org/c-program-for-tower-of-hanoi/amp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Towers of Hanoi&lt;/a&gt; algorithm&#xA;Still you want to use optimization then define binary decision variables &lt;span class=&quot;math-container&quot;&gt;$ x_{i,b}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$ i$&lt;/span&gt; is index for your objects &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$ b$&lt;/span&gt; represents your bin.&lt;br /&gt;&#xA;Create two types of sets/dictionaries:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$C_i = \{i \}$&lt;/span&gt; where object &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; has color &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;&lt;br /&gt;&#xA;Another set: ordered pairs of objects according to their lenghts &lt;span class=&quot;math-container&quot;&gt;$ L=\{ (i,j) : L_i \le L_j \}$&lt;/span&gt;\&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Optional&lt;/em&gt; varibles depending upon your objective&lt;br /&gt;&#xA;binary variable &lt;span class=&quot;math-container&quot;&gt;$ z_{c,b}$&lt;/span&gt; indicating if a color &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is assigned to a bin &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;&lt;br /&gt;&#xA;binary &lt;span class=&quot;math-container&quot;&gt;$ \delta_b$&lt;/span&gt; indicating if a bin &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is used at all. useful if you want to use an objective.&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;br /&gt;&#xA;To capture ordering of objects according to their lengths you can use precedence constraints either as&lt;/p&gt;&#xA;&lt;p&gt;(1) &lt;span class=&quot;math-container&quot;&gt;$ x_{j,b} \le x_{i,b} \ \ \forall b \ \ \forall (i,j) \in L $&lt;/span&gt;&lt;br /&gt;&#xA;or&lt;br /&gt;&#xA;(1) &lt;span class=&quot;math-container&quot;&gt;$x_{i,b}+x_{j,b} - 1 \le My_{i,j} \ \ \forall b \ \ \forall (i,j) \in L$&lt;/span&gt;&#xA;with additional binaries &lt;span class=&quot;math-container&quot;&gt;$ y_{i,j} \ \forall (i,j) \in L$&lt;/span&gt; similar to &lt;a href=&quot;https://or.stackexchange.com/questions/10656/scheduling-to-minimize-total-wait-to-start-time&quot;&gt;precedence constraints&lt;/a&gt; if you want to track it.&lt;/p&gt;&#xA;&lt;p&gt;(2) &lt;span class=&quot;math-container&quot;&gt;$z_{c,b} \le \sum_{i \in c} x_{i,b} \le \vert c \vert z_{c,b} \quad \forall b \ \ \forall c \in $&lt;/span&gt; Colors&lt;/p&gt;&#xA;&lt;p&gt;(3) &lt;span class=&quot;math-container&quot;&gt;$ 1 \le \sum_b z_{c,b} \le U \ \ \forall c$&lt;/span&gt;&lt;br /&gt;&#xA;here you can choose a value of &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; to restrict how many bins objects of a color &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; will be distributed to or choose &lt;span class=&quot;math-container&quot;&gt;$ \sum_b \delta_b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(4) &lt;span class=&quot;math-container&quot;&gt;$ \delta_b \le \sum_i x_{i,b} \le B\delta_b \ \ \forall b$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$ B$&lt;/span&gt; is number of bins&lt;/p&gt;&#xA;&lt;p&gt;(5) &lt;span class=&quot;math-container&quot;&gt;$\sum_b x_{i,b} = 1 \ \ \forall i $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objective (&lt;em&gt;optional&lt;/em&gt;) &lt;span class=&quot;math-container&quot;&gt;$ \min \sum_b \delta_{b} $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-07-04T20:43:30.083" LastActivityDate="2023-07-04T20:43:30.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10666" PostTypeId="2" ParentId="10640" CreationDate="2023-07-04T21:47:58.433" Score="3" Body="&lt;p&gt;I tried a random key genetic algorithm (in R, using four parallel threads), both as a &amp;quot;standard GA&amp;quot; (single population) and as an &amp;quot;island&amp;quot; model (multiple populations, four in my tests, evolving separately and periodically using &amp;quot;migration&amp;quot; to pass &amp;quot;genetic material&amp;quot; to other populations). I used 100 responses to 30 questions with five clusters. Both methods hit a predefined limit of 500 generations in around three minutes on my PC (decent but no workstation), and appeared to still be improving when they hit that limit. I did not do many runs, nor did I experiment with the various parameters (mutation rates, elitism, migration rates) available.&lt;/p&gt;&#xA;&lt;p&gt;The island model did a bit better than the standard model (which has me wondering if the standard model would benefit from a higher mutation rate or &amp;quot;immigration&amp;quot; of a few random solutions in each generation). Improvement over the initial random solution after three minutes was only about 2%, and I have no idea whether that is good or bad in this context.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-07-04T21:47:58.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10667" PostTypeId="1" CreationDate="2023-07-05T09:36:52.040" Score="0" ViewCount="103" Body="&lt;p&gt;I'm trying to solve a linear program with 869532 variables and 8869 constraints in CVXPY. The CVXPY gets stuck in the Compilation session right before passing the problem to the solver. Here's the verbose log:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;-------------------------------------------------------------------------------&#xA;                                  Compilation                                  &#xA;-------------------------------------------------------------------------------&#xA;(CVXPY) Jul 05 11:23:23 AM: Compiling problem (target solver=ECOS).&#xA;(CVXPY) Jul 05 11:23:23 AM: Reduction chain: Dcp2Cone -&amp;gt; CvxAttr2Constr -&amp;gt; ConeMatrixStuffing -&amp;gt; ECOS&#xA;(CVXPY) Jul 05 11:23:23 AM: Applying reduction Dcp2Cone&#xA;(CVXPY) Jul 05 11:23:25 AM: Applying reduction CvxAttr2Constr&#xA;(CVXPY) Jul 05 11:23:26 AM: Applying reduction ConeMatrixStuffing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After, say half an hour, nothing happens.&#xA;So, my question is whether there is an option to possibly bypass the reduction or facilitate this process.&lt;/p&gt;&#xA;&lt;p&gt;PS. I have tried different solvers resulting in no effect.&lt;/p&gt;&#xA;" OwnerUserId="10" LastActivityDate="2023-07-05T09:36:52.040" Title="CVXPY stuck in Compilation step during solving linear program" Tags="|linear-programming|solver|cvxpy|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10668" PostTypeId="1" CreationDate="2023-07-05T15:56:49.373" Score="1" ViewCount="45" Body="&lt;p&gt;I have two specific types of bilinear terms in the problem. The first type involves the multiplication of an integer variable and a continuous variable, while the second type involves the multiplication of two continuous variables.&#xA;I'm currently exploring the possibility of linearizing this problem using the Benders technique. However, I'm unsure if it is feasible in my particular case, which is why I have posed this question.&#xA;I'm aware that numerous papers have been published on this topic, but I may have overlooked some of them. Therefore, I believe it would be beneficial to seek input from this community, particularly from individuals well-versed in Benders. Would you kindly provide me with any relevant papers in the field of Benders that pertain to my query?&lt;/p&gt;&#xA;&lt;p&gt;Best,&lt;/p&gt;&#xA;&lt;p&gt;Samira&lt;/p&gt;&#xA;" OwnerUserId="12083" LastEditorUserId="500" LastEditDate="2023-07-05T16:21:44.900" LastActivityDate="2023-07-05T16:21:44.900" Title="Seeking Assistance with Applying Benders Technique for Bilinear Problem Solving" Tags="|reference-request|benders-decomposition|minlp|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10669" PostTypeId="1" AcceptedAnswerId="10670" CreationDate="2023-07-05T17:41:15.807" Score="1" ViewCount="170" Body="&lt;p&gt;or-tools-discuss cross post &lt;a href=&quot;https://groups.google.com/g/or-tools-discuss/c/xu8YAbfLJ8w&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;As a disclaimer&lt;/strong&gt;&lt;/em&gt; -- I am very aware that OR-Tools' Python code are just wrappers around their C++ source code. I'm just getting an odd discrepancy between a model setup in Python and one setup in C++ and am wracking my brain to figure out what I've messed up (because its most likely me not implementing something correctly or missing a &amp;quot;hidden-to-me&amp;quot; difference between the two).&lt;/p&gt;&#xA;&lt;h2&gt;Setup Context&lt;/h2&gt;&#xA;&lt;p&gt;OS&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pop!OS 22.04 (basically Ubuntu)&lt;/li&gt;&#xA;&lt;li&gt;x86_64&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Python Environment&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Python 3.10.5&lt;/li&gt;&#xA;&lt;li&gt;ortools 9.6.2534&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;C++ Environment&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CMake 3.26.4&lt;/li&gt;&#xA;&lt;li&gt;gcc 11.3.0&lt;/li&gt;&#xA;&lt;li&gt;or-tools &lt;code&gt;FetchContent&lt;/code&gt;'d from &lt;code&gt;stable&lt;/code&gt; Git branch&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Problem Context&lt;/h2&gt;&#xA;&lt;p&gt;I've got two scripts, one in Python and the other in C++, that are setup to do (what I believe) is the same thing: read in an MPS file and solve the contained MIP using the SCIP solver.&lt;/p&gt;&#xA;&lt;p&gt;The MPS file being fed into both scripts is the same, so I would have expected them to produce similar results. I might have even expected the C++ program to run faster than its Python counterpart. But what I'm seeing is that the Python script finished in ~20 seconds or so, while the C++ script errors out during the solve process after 5+ minutes.&lt;/p&gt;&#xA;&lt;p&gt;The C++ error produced was (effectively): &lt;code&gt;ERROR: (node 1) unresolved numerical troubles in LP 2 cannot be dealt with&lt;/code&gt;, which is mentioned in &lt;a href=&quot;https://stackoverflow.com/questions/73195778/numerical-troubles-in-lp&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Upon inspecting the logs from both solvers, I see they are both coming to the same primal / dual bounds. But whereas the Python script reaches those bounds and exits with an &lt;code&gt;Optimal&lt;/code&gt; solution, the C++ script continues to iterate until error-ing out with the above issue.&lt;/p&gt;&#xA;&lt;p&gt;I'm wondering if it could be related to the way I've read in the MPS file and loaded it into a model? The process for each is laid out below:&lt;/p&gt;&#xA;&lt;p&gt;Python&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use &lt;code&gt;ortools.linear_solver.python.model_builder.ModelBuilder&lt;/code&gt;and &lt;code&gt;ModelSolver&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;instantiate objects &lt;code&gt;model = ModelBuilder()&lt;/code&gt; and &lt;code&gt;solver = ModelSolver(&amp;quot;SCIP&amp;quot;)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;model.import_from_mps_file&lt;/code&gt; to read MPS&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;solver.solve(model)&lt;/code&gt; to optimize MIP&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;C++&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;#include &amp;lt;ortools/lp_data/mps_reader.h&amp;gt;&lt;/code&gt; and &lt;code&gt;#include &amp;lt;ortools/linear_solver/linear_solver.h&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;instantiate solver `solver = MPSolver::CreateSolver(&amp;quot;SCIP&amp;quot;)&lt;/li&gt;&#xA;&lt;li&gt;read MPS file to proto &lt;code&gt;model_proto = glop::MpsFileToMPModelProto(mps_file)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;load model from proto &lt;code&gt;solver-&amp;gt;LoadModelFromProto(*model_proto, ...)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;solver-&amp;gt;Solve()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So, in Python, I'm using the ModelHelpers and in C++ I'm interfacing directly with the &lt;code&gt;MPSolver&lt;/code&gt; class. Perhaps this is where the difference lies?&lt;/p&gt;&#xA;&lt;p&gt;Any thoughts / suggestions as to why I'm seeing this difference would be much appreciated!&lt;/p&gt;&#xA;" OwnerUserId="7672" LastActivityDate="2023-07-05T18:01:18.207" Title="Are there any hidden differences in OR-Tools' default parameters for a MIP model in Python vs C++?" Tags="|python|or-tools|c++|scip|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10670" PostTypeId="2" ParentId="10669" CreationDate="2023-07-05T18:01:18.207" Score="1" Body="&lt;p&gt;As explained on or-tools-discuss, model_builer and MPSolver use 2 different sets of parameter s. In particular the tolerances ans the gaps.&lt;/p&gt;&#xA;&lt;p&gt;I recommend using settings the same solver specific parameters as strings on both front ends.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-07-05T18:01:18.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10671" PostTypeId="1" CreationDate="2023-07-05T19:10:58.887" Score="3" ViewCount="102" Body="&lt;p&gt;I have the following question. I have a LP with the objective function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max\sum_{i\in I}^{}\sum_{p\in P}^{}sales_{ip}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, the number of sales over all individuals &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is to be maximized for all periods &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;. So far so good. The model works and maximizes the sales. But it happens from time to time that e.g. individual 1 has 10 sales and the others 0, while it also happens that all have 2. In the sum, however, always ten. How can we force that it is as balanced as possible over all individuals? So that there is not the extreme with &amp;quot;one has everything&amp;quot;, but that it is more or less equally distributed?&lt;/p&gt;&#xA;" OwnerUserId="12086" LastEditorUserId="500" LastEditDate="2023-07-05T19:23:57.143" LastActivityDate="2023-07-05T19:23:57.143" Title="Modify objective function for equal solution distribution" Tags="|linear-programming|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10672" PostTypeId="2" ParentId="10671" CreationDate="2023-07-05T19:23:17.520" Score="4" Body="&lt;p&gt;Two approaches:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use an interior point algorithm (without crossover) to naturally encourage balanced solutions.&lt;/li&gt;&#xA;&lt;li&gt;Use multiple objectives.  The primary objective is to maximize sales.  After optimizing the primary objective, impose an additional constraint (&amp;quot;objective cut&amp;quot;) that forces the sales to be at least the maximum just found.  The secondary objective can be to minimize the maximum (alternatively, maximize the minimum).  Now optimize the secondary objective subject to the original constraints and the objective cut.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-07-05T19:23:17.520" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10673" PostTypeId="1" AcceptedAnswerId="10674" CreationDate="2023-07-05T21:03:48.740" Score="2" ViewCount="368" Body="&lt;p&gt;I'm a researcher and I have a problem with CPLEX. The .lp file containing the model includes the following constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1000000000 x(1,12,0) + T(1,0) - T(12,0) &amp;lt;= 999999992&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;where x and T are decision variables. The solution returned is &lt;strong&gt;x(1,12,0) = 1, T(1,0) = 8, T(12,0) = 8&lt;/strong&gt;, which violates the constraint. Can someone help?  I appreciate it in advance.&lt;/p&gt;&#xA;" OwnerUserId="12089" LastActivityDate="2023-07-05T21:46:12.810" Title="CPLEX violating constraints (CPLEX - version 12.10 - C++)" Tags="|optimization|modeling|cplex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10674" PostTypeId="2" ParentId="10673" CreationDate="2023-07-05T21:46:12.810" Score="8" Body="&lt;p&gt;Your problem is that double precision arithmetic is not perfectly accurate. Consequently, CPLEX (and pretty much every other solver) has various tolerance settings for when a double precision value is &amp;quot;close enough&amp;quot; to the target to let the solution be accepted. If you divide your constraint by 1e9 you get x(1,12,0) + ... &amp;lt;= 0.999999992. Substitute the alleged solution and the violation is 8e-09, which is well below the default tolerance of 1e-6 used by CPLEX.&lt;/p&gt;&#xA;&lt;p&gt;You can reduce the feasibility tolerance parameter, but I don't advise it. Crank it too low and feasible solutions will suddenly become &amp;quot;infeasible&amp;quot; due to rounding error. The fundamental problem is that your model is poorly scaled. The constraint looks like a &amp;quot;big M&amp;quot; constraint, and &amp;quot;big M&amp;quot; constraints are notorious for causing numerical problems. If it is a &amp;quot;big M&amp;quot; constraint, your options include the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;find a smaller value for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; that gets the job done;&lt;/li&gt;&#xA;&lt;li&gt;find an alternate formulation that does not require &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; (you could perhaps try indicator constraints, although CPLEX may internally reformulate them as &amp;quot;big M&amp;quot; constraints); or&lt;/li&gt;&#xA;&lt;li&gt;find an alternative way to solve the model (combinatorial Benders decomposition might be an option).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-07-05T21:46:12.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10675" PostTypeId="1" CreationDate="2023-07-06T09:31:58.077" Score="-1" ViewCount="53" Body="&lt;p&gt;To solve a minimization problem using the primal simplex firstly we need a basis. If I am not wrong, a variable is basic if it enters into this equation with a coefficient of one. So I have seen solutions where artificial variables are added in order to find a basis and then proceed with the table to find the solution. The problem is that I don't understand where to put the artificial variable and in general how to find the basis.&lt;/p&gt;&#xA;&lt;p&gt;Here's an example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$min z= -2x_1 +2x_2 + 2x_3$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$s.t  \; x_1+x_2-2x_3 \geq 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_1+x_2-x_3 \leq 3$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-x_1-x_2+3x_3 \geq -2$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_1,x_2,x_3 \geq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="12092" LastEditorUserId="12092" LastEditDate="2023-07-06T15:54:22.660" LastActivityDate="2023-07-06T15:54:22.660" Title="Find a basis with the primal simplex method" Tags="|primal-simplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10676" PostTypeId="1" CreationDate="2023-07-06T12:14:12.103" Score="0" ViewCount="18" Body="&lt;p&gt;I have two allocations &lt;span class=&quot;math-container&quot;&gt;$\omega_1, \omega_2$&lt;/span&gt; with the following values for the decision variables:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\omega_1$&lt;/span&gt;: demand side: &lt;span class=&quot;math-container&quot;&gt;$x_1=1$&lt;/span&gt;; supply side: &lt;span class=&quot;math-container&quot;&gt;$y_1=5, y_2=3$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\omega_2$&lt;/span&gt;: demand side: &lt;span class=&quot;math-container&quot;&gt;$x_1=1$&lt;/span&gt;; supply side: &lt;span class=&quot;math-container&quot;&gt;$y_1=4, y_2=4$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I want to calculate the distance between &lt;span class=&quot;math-container&quot;&gt;$\omega_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\omega_2$&lt;/span&gt;. Is the difference 0, since the total supply and demand quantities are identical in both allocations, or &lt;span class=&quot;math-container&quot;&gt;$\sqrt{(5−4)^2+(3−4)^2} = \sqrt{2}$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;I want to apply the Shapley-Folkman lemma (&lt;a href=&quot;https://econweb.ucsd.edu/%7Erstarr/SFarticle.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://econweb.ucsd.edu/~rstarr/SFarticle.pdf&lt;/a&gt;) and check if the distance between these two allocation is smaller than a specific constant.&lt;/p&gt;&#xA;&lt;p&gt;Could anyone help me, please?&lt;/p&gt;&#xA;" OwnerUserId="6063" LastActivityDate="2023-07-06T12:14:12.103" Title="Distance between two allocations and the Shapley-Folkman lemma" Tags="|optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10677" PostTypeId="1" CreationDate="2023-07-06T12:47:05.677" Score="0" ViewCount="43" Body="&lt;p&gt;I would like to ask if there are some specific conditions under which the Weighted Sum method yields a unique solution for MOLP or more general for convex problems. Let us assume that the number of objectives-criteria are more than two.&lt;/p&gt;&#xA;&lt;p&gt;Thank you in advance!&lt;/p&gt;&#xA;" OwnerUserId="12095" LastActivityDate="2023-07-06T12:47:05.677" Title="When the Weighted Sum method yields a unique solution in MOLP?" Tags="|convex-optimization|multi-objective-optimization|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10678" PostTypeId="2" ParentId="10675" CreationDate="2023-07-06T14:52:27.403" Score="2" Body="&lt;p&gt;I'm assuming that your variables are nonnegative. (The question does not specify this.) Your first step is to add slack variables to &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; constraints and subtract surplus variables in &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; constraints. Any slack variables added will be part of the initial basis. To use what is known as the &amp;quot;two phase simplex&amp;quot; method, you add an artificial variable to each &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt; constraint, form an initial basis from the artificials and any slacks (but not surpluses), and then change the objective to minimize the sum of the artificial variables.&lt;/p&gt;&#xA;&lt;p&gt;If the original problem is feasible, the simplex method will pivot all the artificial variables out of the basis, driving the phase 1 objective to zero. At that point, you have a basis feasible in the original problem. Change back to the original objective, remove any artificials from the problem, and resume pivoting (in what is now called phase 2).&lt;/p&gt;&#xA;&lt;p&gt;There is one edge case to note. If the final phase 1 solution is degenerate, you might still have one or more artificials in the basis (with value 0). You can pivot them out and then get to phase 2.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-07-06T14:52:27.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10679" PostTypeId="1" CreationDate="2023-07-07T10:34:16.720" Score="3" ViewCount="104" Body="&lt;p&gt;I have to minimize &lt;span class=&quot;math-container&quot;&gt;$c^Tx$&lt;/span&gt;&#xA;subject to  &lt;span class=&quot;math-container&quot;&gt;$Ax = b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_iw_i = 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; non negative continuous and &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; binary.&#xA;What model should I use to solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="12105" LastEditorUserId="2556" LastEditDate="2023-07-07T14:17:37.790" LastActivityDate="2023-07-07T14:17:37.790" Title="using milp for a linear complementarity problem" Tags="|optimization|modeling|linearization|nonconvex-programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10680" PostTypeId="2" ParentId="10679" CreationDate="2023-07-07T12:12:44.990" Score="4" Body="&lt;p&gt;Equivalently, you want to enforce &lt;span class=&quot;math-container&quot;&gt;$$w_i=1\implies x_i\le 0.$$&lt;/span&gt; You can either use an indicator constraint to express this directly or use the following big-M constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i \le M_i(1-w_i),$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; is a (small) constant upper bound on &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-07-07T12:12:44.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10681" PostTypeId="1" AcceptedAnswerId="10696" CreationDate="2023-07-08T14:05:08.800" Score="1" ViewCount="275" Body="&lt;p&gt;I would like to know if there are methods that can gurantee to find all pareto-optimal solutions of a multi-objective optimization problem.&lt;/p&gt;&#xA;&lt;p&gt;I found some possible approaches but I don't know if they can in fact find all Pareto-optimal solutions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Dichotomic approach by Cohon et al, 1979 (&lt;a href=&quot;https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/WR015i005p01001&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/WR015i005p01001&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;ε-constraint by Chankong and Haimes, 1983 (&lt;a href=&quot;https://www.econbiz.de/Record/multiobjective-decision-making-theory-and-methodology-vira-chankong/10004024477&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.econbiz.de/Record/multiobjective-decision-making-theory-and-methodology-vira-chankong/10004024477&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Box-method by Hamacher et al., 2007 (&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0167637706000745&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sciencedirect.com/science/article/pii/S0167637706000745&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Do you know these methods and can you tell me if they can find all Pareto-optimal solutions? If not, do you know any method that is capable to do so? I am asking for exact methods (so no heuristic or local optimization approach).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I am asking for methods for any multiobjective optimization problem (n goals, continious or mixed-integer problems, convex or non-convex).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Reminder&lt;/strong&gt;: Can nobody tell me a little bit more about multiobjective optimization problems? Do you know any methods for solving them exactly?&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2023-07-12T07:10:19.763" LastActivityDate="2023-07-13T14:07:29.107" Title="Which exact method can find all pareto-optimal solutions of a multi-objective optimization problem" Tags="|multi-objective-optimization|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10682" PostTypeId="2" ParentId="10541" CreationDate="2023-07-08T16:52:57.587" Score="0" Body="&lt;p&gt;I can think of something similar to @Robpratt suggestion in another problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s_i+d_ix_{i,p,m} \le s_j + M(2-x_{i,p,m}-x_{j,p',m}) \ \ \forall p,p': p \le p'$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$s,d $&lt;/span&gt; are start times and duration(this is given) for tasks &lt;span class=&quot;math-container&quot;&gt;$i,j$&lt;/span&gt; on resource &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-07-08T16:52:57.587" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10683" PostTypeId="1" AcceptedAnswerId="10685" CreationDate="2023-07-08T20:23:40.567" Score="3" ViewCount="132" Body="&lt;p&gt;I have some basic knowledge about deep learning methods (fully connected and convolutional NNs). I would like to expand my knowledge of deep learning which could be beneficial for an operations researcher. What resource/book would you suggest for reading?&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="491" LastEditDate="2023-07-09T00:57:58.610" LastActivityDate="2023-07-24T22:21:02.320" Title="deep learning for operations researchers" Tags="|deep-learning|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10684" PostTypeId="1" CreationDate="2023-07-09T12:37:53.647" Score="0" ViewCount="49" Body="&lt;p&gt;I am reading the article &amp;quot;Some remarks on the Value at Risk and the Conditional Value at Risk&amp;quot; by G. Pflug. The author claims that CVaR is positively homogeneous. That is,&#xA;Given a loss function &lt;span class=&quot;math-container&quot;&gt;$X(x,\omega)$&lt;/span&gt; of the decision variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and the uncertainty &lt;span class=&quot;math-container&quot;&gt;$\omega$&lt;/span&gt;, we have that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$CVaR_\alpha(kX)=kCVaR_\alpha(x)$$&lt;/span&gt;&#xA;I am starting from the definition of CVaR but I do not seem to be heading anywhere.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;CVaR_\alpha(kX)=\min_{\beta\in\mathbb{R}}(\beta+\frac{1}{1-\alpha}\int_{\omega\in\mathbb{R}}\max(0,kX(x,\omega)-\beta)p(\omega)d\omega)&#xA;$$&lt;/span&gt;&#xA;This is equal to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;CVaR_\alpha(kX)=\min_{\beta\in\mathbb{R}}(\beta+\frac{1}{1-\alpha}\int_{\omega:kX(x,\omega)\geq \beta}(kX(x,\omega)-\beta)p(\omega)d\omega)&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;CVaR_\alpha(kX)=\min_{\beta\in\mathbb{R}}(\beta+\frac{1}{1-\alpha}\int_{\omega:kX(x,\omega)\geq \beta}kX(x,\omega)p(\omega)d\omega-\frac{\beta}{1-\alpha}\int_{\omega:kX(x,\omega)\geq \beta}p(\omega)d\omega)&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;CVaR_\alpha(kX)=\min_{\beta\in\mathbb{R}}(\beta+\frac{1}{1-\alpha}\int_{\omega:kX(x,\omega)\geq \beta}kX(x,\omega)p(\omega)d\omega-\frac{\beta}{1-\alpha}(1-\alpha))&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;CVaR_\alpha(kX)=\min_{\beta\in\mathbb{R}}(\frac{1}{1-\alpha}\int_{\omega:kX(x,\omega)\geq \beta}kX(x,\omega)p(\omega)d\omega)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Any advise on how to continue?&lt;/p&gt;&#xA;" OwnerUserId="9880" LastActivityDate="2023-07-09T12:37:53.647" Title="Why is CVaR positively homogeneous?" Tags="|convex-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10685" PostTypeId="2" ParentId="10683" CreationDate="2023-07-10T18:57:48.973" Score="3" Body="&lt;p&gt;This is the book that I used for my class at VT:&#xA;&lt;a href=&quot;https://www.deeplearningbook.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.deeplearningbook.org/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is another book that was recommended there:&#xA;&lt;a href=&quot;https://d2l.ai/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://d2l.ai/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This book on online learning is also useful:&#xA;&lt;a href=&quot;https://www.cs.huji.ac.il/%7Eshais/papers/OLsurvey.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.cs.huji.ac.il/~shais/papers/OLsurvey.pdf&lt;/a&gt;&#xA;&amp;quot;Online Learning and Online Convex Optimization&amp;quot; by Shai Shalev-Shwartz.&lt;/p&gt;&#xA;&lt;p&gt;Some papers I found helpful from Van Hentenryck:&#xA;&amp;quot;Fast Approximations for Job Shop Scheduling: A Lagrangian Dual Deep Learning Method&amp;quot;,&#xA;&amp;quot;Predicting AC Optimal Power Flows: Combining Deep Learning and Lagrangian Dual Methods&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Also, this paper is helpful: &lt;a href=&quot;https://arxiv.org/pdf/1705.03341.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/pdf/1705.03341.pdf&lt;/a&gt; &amp;quot;Stable Architectures for Deep Neural Networks&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;If you have a graph background: &lt;a href=&quot;https://web.njit.edu/%7Eym329/dlg_book/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://web.njit.edu/~ym329/dlg_book/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7428" LastEditorUserId="7428" LastEditDate="2023-07-24T22:21:02.320" LastActivityDate="2023-07-24T22:21:02.320" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10686" PostTypeId="2" ParentId="10681" CreationDate="2023-07-11T10:35:35.947" Score="1" Body="&lt;p&gt;I would like to add the following resources that were mentioned by Gurobi experts and would be useful:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;These extreme points are non-dominated points on the Pareto front. It&#xA;is possible to compute all of these points and reconstruct the whole&#xA;Pareto front from them. This idea is presented in the paper by&#xA;Özpeynirci &amp;amp; Koksalan.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;O. Ozpeynirci and M. Koksalan. “An Exact Algorithm for Finding Extreme Sup- ported Nondominated Points of Multiobjective Mixed Integer Programs”. In: Management Science 56.12 (2010), pages 2302–2315.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;M. Ehrgott. Multicriteria optimization. Volume 491. Lecture notes in economics and mathematical systems. Springer Science &amp;amp; Business Media, 2005.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-07-11T10:35:35.947" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10687" PostTypeId="1" AcceptedAnswerId="10694" CreationDate="2023-07-11T15:13:31.260" Score="2" ViewCount="103" Body="&lt;p&gt;This question is about an optimization problem that arises in &lt;a href=&quot;https://scikit-learn.org/stable/auto_examples/svm/plot_svm_regression.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;support vector regression (SVR)&lt;/a&gt;. Suppose you have &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; pairs &lt;span class=&quot;math-container&quot;&gt;$(\vec{x}_n, y_n)$&lt;/span&gt; as data and would like to find a vector of weights &lt;span class=&quot;math-container&quot;&gt;$\vec w \in\mathbb R^k$&lt;/span&gt; and a bias &lt;span class=&quot;math-container&quot;&gt;$b \in \mathbb R$&lt;/span&gt; such that function &lt;span class=&quot;math-container&quot;&gt;$\vec{w}^T \vec{x}_n + b \approx y_n \,\forall n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(Vapnik, 1995, sec. 5.9.2) introduces SVR as an empirical risk minimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\min_{\mathbf w, b}&#xA;\quad\frac12 w^T w + C&#xA; \sum_{n=1}^N l(x_n,y_n; \mathbf w,b)\\&#xA;l(x_n,y_n; \mathbf w,b) = \max\left( 0, |y_n - (w^T x_n + b)| - \varepsilon \right)&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$l(x_n,y_n; \mathbf w,b)$&lt;/span&gt; function is known as the &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-insensitive loss function.&lt;/p&gt;&#xA;&lt;p&gt;He then claims that this problem &amp;quot;is equivalent to the problem of finding the pair &lt;span class=&quot;math-container&quot;&gt;$\mathbf w, b$&lt;/span&gt; that minimizes the quantity defined by slack variables &lt;span class=&quot;math-container&quot;&gt;$(\xi_n,\xi_n^*)_{n=1}^N$&lt;/span&gt;&amp;quot;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\min_{\mathbf w, \mathbf\xi, \mathbf\xi^*}&#xA;&amp;amp;\quad\frac12 w^T w + C&#xA; \sum_{n=1}^N (\xi_n + \xi_n^*)\\&#xA;\text{s.t.} &amp;amp;\quad&#xA;\begin{cases}&#xA;y_n - (w^T x_n + b) &amp;amp;\le \varepsilon + \xi_n^*\\&#xA;-(y_n - (w^T x_n + b)) &amp;amp;\le \varepsilon + \xi_n\\&#xA;\xi_n, \xi_n^* &amp;amp;\ge 0&#xA;\end{cases}&#xA;\forall n\in \{1,\dots,N\}&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My &lt;strong&gt;question&lt;/strong&gt; is: &lt;strong&gt;how&lt;/strong&gt; to get from the &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-insensitive loss to the quadratic optimization problem above? Where do the slack variables &lt;span class=&quot;math-container&quot;&gt;$\xi_n,\xi_n^*$&lt;/span&gt; come from?&lt;/p&gt;&#xA;&lt;p&gt;Here's what I found:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;(Smola, 2004) cites (Vapnik, 1995) and says that the above optimization problem &amp;quot;corresponds to dealing with a so called &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-insensitive loss function&amp;quot;, but doesn't explain how to get from the &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-insensitive loss to the QP.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Slides from &lt;a href=&quot;https://stats.stackexchange.com/a/287855/328515&quot;&gt;this CrossValidated answer&lt;/a&gt; go from the &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-insensitive loss to the QP with no explanation as well.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.csie.ntu.edu.tw/%7Ehtlin/mooc/doc/206_present.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;These slides&lt;/a&gt; (slide 11) derive the QP from the &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-insensitive loss step-by-step, but they don't explicitly explain why I can just introduce these random &lt;span class=&quot;math-container&quot;&gt;$\xi_n$&lt;/span&gt; slack variables.&lt;/p&gt;&#xA;&lt;p&gt;In particular, why is the minimization problem with the &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-insensitive loss equivalent to this?&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\min_{b,w,\xi}&amp;amp;\quad \frac12 w^T w + C\sum_{n=1}^N \xi_n\\&#xA;\text{s.t.}&amp;amp;\quad&#xA;\begin{aligned}&#xA;&amp;amp;\left| y_n - (w^T x_n + b) \right| - \varepsilon \le \xi_n\\&#xA;&amp;amp;\xi_n \ge 0&#xA;\end{aligned}\quad\forall n&#xA;\end{aligned}&#xA;   $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Looks like they're trying to find the smallest &lt;span class=&quot;math-container&quot;&gt;$\xi_n$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\max\left( 0, \left| y_n - (w^T x_n + b) \right| - \varepsilon \right) \le\xi_n$&lt;/span&gt;, but why is this equivalent to the original problem? How did they think of such a transformation? In what cases can it be applied?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;References&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vapnik, V.N. (1995) ‘Chapter 5. Constructing learning algorithms’, in The Nature of Statistical Learning Theory. New York, NY: Springer New York, pp. 119–156. Available at: &lt;a href=&quot;https://doi.org/10.1007/978-1-4757-3264-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1007/978-1-4757-3264-1&lt;/a&gt;. &lt;a href=&quot;https://github.com/muditbac/Reading/blob/master/programming/A.I/(%20)%20Vladimir%20N.%20Vapnik%20%20(auth.)-The%20Nature%20of%20Statistical%20Learning%20Theory-Springer%20New%20York%20(1995).pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;PDF from someone's GitHub&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Smola, A.J. and Schölkopf, B. (2004) ‘A tutorial on support vector regression’, Statistics and Computing, 14(3), pp. 199–222. Available at: &lt;a href=&quot;https://doi.org/10.1023/B:STCO.0000035301.49549.88&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1023/B:STCO.0000035301.49549.88&lt;/a&gt;. &lt;a href=&quot;https://alex.smola.org/papers/2004/SmoSch04.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;PDF from author&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10396" LastEditorUserId="500" LastEditDate="2023-07-11T17:25:05.847" LastActivityDate="2023-07-12T20:46:47.580" Title="How to show that minimizing the epsilon-insensitive loss is equivalent to a quadratic program with inequality constraints?" Tags="|optimization|linearization|quadratic-programming|machine-learning|regression|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10688" PostTypeId="1" AcceptedAnswerId="10689" CreationDate="2023-07-11T15:33:56.953" Score="1" ViewCount="113" Body="&lt;p&gt;FICO XPRESS recently released a feature that supports &lt;a href=&quot;https://www.fico.com/fico-xpress-optimization/docs/latest/solver/optimizer/HTML/chapter5.html?scroll=multiobj&quot; rel=&quot;nofollow noreferrer&quot;&gt;multi-objective optimization&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;While it allows you to define a tolerance per objective (aka how much you can relax the previous objective), I am not sure how to enforce a different optimization gap for each of the objectives. Maybe for the first objective I want to solve it to 1% optimality gap the second objective to 2% and the third one to 0%.&lt;/p&gt;&#xA;&lt;p&gt;Any idea whether this is possible in the python api?&lt;/p&gt;&#xA;" OwnerUserId="590" LastActivityDate="2023-07-11T16:46:31.760" Title="Set optimality gap for each goal objective in FICO XPRESS" Tags="|python|multi-objective-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10689" PostTypeId="2" ParentId="10688" CreationDate="2023-07-11T16:46:31.760" Score="0" Body="&lt;p&gt;There are two callback functions offered before and after each optimization.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    p = xp.problem&#xA;    def beforeobjective(prob, object):&#xA;        if prob.attributes.solvedobjs == 0:&#xA;            print(&amp;quot;will enforce gap to first objective&amp;quot;)&#xA;            prob.controls.miprelstop = 2e-2&#xA;        if prob.attributes.solvedobjs == 1:&#xA;            print(&amp;quot;will enforce gap to second objective&amp;quot;)&#xA;            prob.controls.miprelstop = 1e-2&#xA;            # From now on (solves 3,4) the gap will be 1e-2&#xA;        &#xA;    def afterobjective(prob, object):&#xA;        print(&amp;quot;Completed solve {}&amp;quot;.format(prob.attributes.solvedobjs))&#xA;    p.addcbbeforeobjective(beforeobjective, None, 0)&#xA;    p.addcbafterobjective(afterobjective, None, 0)&#xA;    p.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="590" LastActivityDate="2023-07-11T16:46:31.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10690" PostTypeId="1" CreationDate="2023-07-11T20:57:26.987" Score="2" ViewCount="516" Body="&lt;p&gt;I was wondering how the run time of an LP and an MILP model compare to each other.&#xA;I found out that MIPs are NP-hard, where as LPs aren't, but it don't really understand what it means.&lt;/p&gt;&#xA;&lt;p&gt;Does that mean that LPs can be solved faster than MIPs? And how does the runtime of MIPs increase with size? Exponentially?&lt;/p&gt;&#xA;" OwnerUserId="12086" LastEditorUserId="491" LastEditDate="2023-07-13T21:21:53.150" LastActivityDate="2023-07-13T21:21:53.150" Title="Runtime of LP vs MILP" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10691" PostTypeId="2" ParentId="10690" CreationDate="2023-07-11T21:21:38.633" Score="8" Body="&lt;p&gt;At the risk of offending someone by oversimplifying, NP-hard basically means that the amount of time to solve a model instance can grow faster than any polynomial function of the model size (number of variables, number of constraints, magnitude of coefficients etc.). In and of itself, it's not particularly germane to your question.&lt;/p&gt;&#xA;&lt;p&gt;The simple answer is that an LP is usually going to be faster than the same model with some or all variables restricted to integers because the solver will typically first solve the LP relaxation (the model without integrality, i.e., the LP to which we are comparing it) and then do a bunch of additional work. In some cases you get lucky and the LP solution satisfies the integrality conditions, in which case they take the same amount of time. The MIP version is very unlikely to be faster to solve than the LP, the rare exception being when the integrality conditions let the presolver solve the model before any pivoting takes place.&lt;/p&gt;&#xA;&lt;p&gt;Note that I'm comparing the same model with and without integrality. You can certain find a trivial MIP that solves faster than a ginormous LP.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-07-11T21:21:38.633" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10693" PostTypeId="1" CreationDate="2023-07-12T15:09:17.377" Score="0" ViewCount="71" Body="&lt;p&gt;I am trying to optimize a charging station for EVs in matlab with intlinprog, which is connected to a PV-Modul, to an system storage systeme and to the network grid. I am using different Storage technologies (Lithium, Lead acid and flywheel). I have issues to simulate for some charging scenarios with time resolution of 15 minutes (PV and load data). The charging scenarios are 350kW with 3 Charging points (total energy demand for a year 665 MWh); 150 kW with 12 Charging points (allover 253.58 MWh)and 11kW with 25 Charging points (for a whole year 83.8 MWh). When the demanded energy is lower, the model runs slower, and when there is higher self-discharge, the model also slows down. The simulation varies 3h30 for Li and first scenario (so lowest self discharge and highest Demand) to nearly a day for Flywheel and 11 kW. Can someone help me, explain to me why?&lt;/p&gt;&#xA;" OwnerUserId="12124" LastEditorUserId="12124" LastEditDate="2023-07-12T16:31:17.030" LastActivityDate="2023-07-12T16:31:17.030" Title="is it possible to improve the solution process of an MILP?" Tags="|optimization|mixed-integer-programming|matlab|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10694" PostTypeId="2" ParentId="10687" CreationDate="2023-07-12T20:46:47.580" Score="4" Body="&lt;p&gt;Consider a simpler problem where you are given a constant &lt;span class=&quot;math-container&quot;&gt;$k\ge 0$&lt;/span&gt; and want to find &lt;span class=&quot;math-container&quot;&gt;$x\in \mathbb{R}$&lt;/span&gt; to minimize the (convex piecewise-linear) loss function &lt;span class=&quot;math-container&quot;&gt;$$\max(x-k,-k-x,0)=\begin{cases} x-k &amp;amp;\text{if $x&amp;gt; k$} \\ -k-x &amp;amp;\text{if $x&amp;lt; -k$} \\ 0 &amp;amp;\text{if $-k \le x\le k$}\end{cases}$$&lt;/span&gt;&#xA;(Note that the special case &lt;span class=&quot;math-container&quot;&gt;$k=0$&lt;/span&gt; corresponds to &lt;span class=&quot;math-container&quot;&gt;$|x|$&lt;/span&gt;.)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Z3u9s.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Z3u9s.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;One way to linearize this minimax objective is to introduce a decision variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and minimize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z &amp;amp;\ge x - k \\&#xA;z &amp;amp;\ge -k - x \\&#xA;z &amp;amp;\ge 0&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Another way to linearize this minimax objective is to introduce two decision variables &lt;span class=&quot;math-container&quot;&gt;$z^+$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z^-$&lt;/span&gt; and minimize &lt;span class=&quot;math-container&quot;&gt;$z^++z^-$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;-k \le x - z^+ + z^- &amp;amp;\le k \\&#xA;z^+ &amp;amp;\ge 0 \\&#xA;z^- &amp;amp;\ge 0&#xA;\end{align}&lt;/span&gt;&#xA;At optimality, &lt;span class=&quot;math-container&quot;&gt;$z^+ = \max(x-k,0)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z^- = \max(-k-x,0)$&lt;/span&gt;, and at most one of these can be positive, so the objective value is &lt;span class=&quot;math-container&quot;&gt;$z^+ + z^- = \max(x-k,-k-x,0)$&lt;/span&gt;, as desired.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-07-12T20:46:47.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10695" PostTypeId="1" AcceptedAnswerId="10697" CreationDate="2023-07-13T12:56:49.007" Score="4" ViewCount="383" Body="&lt;p&gt;I've been studying the Benders decomposition method to solve stochastic integer problems.&lt;/p&gt;&#xA;&lt;p&gt;I've also stumbled across papers using a so called L-shaped-algorithm which also divides into master problem and sub problem.&lt;/p&gt;&#xA;&lt;p&gt;Are these the same techniques? If not, what are the differences?&lt;/p&gt;&#xA;" OwnerUserId="12130" LastEditorUserId="8718" LastEditDate="2023-07-22T03:24:08.700" LastActivityDate="2023-07-22T03:24:08.700" Title="Is Benders decomposition and the L-shaped method the same algorithm?" Tags="|mixed-integer-programming|linear-programming|stochastic-programming|benders-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10696" PostTypeId="2" ParentId="10681" CreationDate="2023-07-13T14:07:29.107" Score="2" Body="&lt;p&gt;Whether a particular method is capable of generating all efficient solutions is often a question of what structure the MOOP (multi objective optimisation problem) has.&lt;/p&gt;&#xA;&lt;p&gt;In addition, you ask for methods that can generate all Pareto optimal solutions. In the single objective case, this is equivalent to asking for all alternative optimal solutions. Often what algorithms generate is a so-called minimal complete set of Pareto optimal solutions, which is a subset of Pareto optimal solutions such that there is exactly one solution for each non-dominated outcome vector. In linear and mixed integer linear MOOPs you also need to figure out how you want to represent the set of non-dominated outcomes and their corresponding pre-images: using extreme points, faces/facets, or both.&lt;/p&gt;&#xA;&lt;p&gt;If the problem is a convex MOOP (convex objectives and convex feasible set) then for every Pareto optimal solution, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, there exists a weight vector for which &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is optimal to the weighted sum problem. And furthermore, if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is optimal to the weighted sum problem for some weight vector, then it is Pareto optimal. Hence algorithms based on weighted sum scalarizations are in principle capable of generating all Pareto optimal solutions. However, there might very well exist multiple optimal solutions to a weighted sum problem, so you might need to tickle your single objective solver in order to get all the alternatives (they are all Pareto optimal). For the bi objective case the algorithm by Cohon usually works well. Especially if the problem is also linear. If you have a higher dimensional &lt;em&gt;linear&lt;/em&gt; problem I usually resort to versions of Bensons algorithm. Bensons algorithm provides both a face and an extreme point representation.&lt;/p&gt;&#xA;&lt;p&gt;For combinatorial MOOPs, usually ranking based methods are used when all Pareto optimal solutions must be generated. These methods often rely on solving weighted sums and then ranking solutions for a given weight. Standard references include the “two-phase papers” by Ulungu and Teghem. From a practical perspective, some type of &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;-constraint based method is usually difficult to beat (for two objectives) both with respect to computation time and implementation time.&lt;/p&gt;&#xA;&lt;p&gt;Through the last couple of years branch and bound methods for combinatorial MOOPs (with more than two objectives) have shown some potential. You can look at papers by N. Forget, S. Paragh, or K. Klamroth (among others).&lt;/p&gt;&#xA;&lt;p&gt;For non-convex continuous MOOPs I do not know much. I would look for papers from e.g. G. Eichfelder.&lt;/p&gt;&#xA;&lt;p&gt;Concluding I would like to stress that asking for an algorithm that is good for any type of problem, is like asking for the perfect tool for building a house. The tool depends on the task at hand!&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2023-07-13T14:07:29.107" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10697" PostTypeId="2" ParentId="10695" CreationDate="2023-07-13T14:14:24.933" Score="7" Body="&lt;p&gt;In the paper that proposed &lt;em&gt;L-shaped method&lt;/em&gt;, you can find&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In section 2, an algorithm which is essentially the same as the&#xA;algorithm developed by Benders[3] is described and a geometric&#xA;interpretation is given.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pbBfo.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pbBfo.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;-- Van Slyke, R. M., &amp;amp; Wets, R. (1969). L-shaped linear programs with applications to optimal control and stochastic programming. SIAM Journal on Applied Mathematics, 17(4), 638–663. &lt;a href=&quot;https://doi.org/10.1137/0117061&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1137/0117061&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So &amp;quot;Benders decomposition&amp;quot; and &amp;quot;L-shaped method&amp;quot; can be interchangeable.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;However, when &amp;quot;L-shaped&amp;quot; is used, one implies the problem is stochastic, as you can find &amp;quot;stochastic programming&amp;quot; in the above title. While Benders decomposition is intended for a more general class of problems.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2023-07-13T14:14:24.933" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10698" PostTypeId="1" AcceptedAnswerId="10699" CreationDate="2023-07-13T15:19:05.750" Score="1" ViewCount="92" Body="&lt;p&gt;We have a set of constraints in an ILP of the following form :&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \gamma (X_{11} + X_{12} + X_{13}) \leq C_1$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$X_{ij} \in \{0,1\}$&lt;/span&gt; and the value of &lt;span class=&quot;math-container&quot;&gt;$\gamma$&lt;/span&gt; is going to depend on the actual value of &lt;span class=&quot;math-container&quot;&gt;$X_{ij}$&lt;/span&gt; variable being set. For example, if &lt;span class=&quot;math-container&quot;&gt;$X_{11} = 1, X_{12} = 1, X_{13} = 1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\gamma = 0.45$&lt;/span&gt;, while on the other hand, &lt;span class=&quot;math-container&quot;&gt;$X_{11} = 0, X_{12} = 0, X_{13} = 1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$\gamma = 0.76$&lt;/span&gt; and so forth. How can such constraints be encoded in an ILP where the constant factor actually depends on the value of the variable&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="500" LastEditDate="2023-07-13T15:44:25.490" LastActivityDate="2023-07-13T16:33:56.743" Title="Setting constant values in constraints depending on actual values of variables" Tags="|mixed-integer-programming|integer-programming|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10699" PostTypeId="2" ParentId="10698" CreationDate="2023-07-13T15:43:18.253" Score="3" Body="&lt;p&gt;Given constant &lt;span class=&quot;math-container&quot;&gt;$C_1$&lt;/span&gt;, you want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left(X_{11} \land X_{12} \land X_{13}\right) \implies 0.45(1+1+1) \le C_1.$$&lt;/span&gt;&#xA;Equivalently, you want to enforce the contrapositive&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0.45(1+1+1) &amp;gt; C_1 \implies \lnot \left(X_{11} \land X_{12} \land X_{13}\right),$$&lt;/span&gt;&#xA;equivalently,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lnot \left(X_{11} \land X_{12} \land X_{13}\right) \quad \text{if $0.45(1+1+1) &amp;gt; C_1$},$$&lt;/span&gt;&#xA;which you can enforce with linear constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(1-X_{11}) + (1-X_{12}) + (1-X_{13}) \ge 1 \quad \text{if $0.45(1+1+1) &amp;gt; C_1$},$$&lt;/span&gt;&#xA;which simplifies to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$X_{11} + X_{12} + X_{13} \le 2 \quad \text{if $0.45(1+1+1) &amp;gt; C_1$}. \tag1$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Similarly,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left(\lnot X_{11} \land \lnot X_{12} \land X_{13}\right) \implies 0.76(0+0+1) \le C_1$$&lt;/span&gt;&#xA;yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$X_{11} + X_{12} + (1-X_{13}) \ge 1 \quad \text{if $0.76(0+0+1) &amp;gt; C_1$}.\tag2$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-07-13T16:33:56.743" LastActivityDate="2023-07-13T16:33:56.743" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10700" PostTypeId="1" CreationDate="2023-07-14T06:56:24.773" Score="1" ViewCount="195" Body="&lt;p&gt;I'm trying to formulate an LP that is in essence a variant of the sudoku problem, and I've repurposed the code from &lt;a href=&quot;https://coin-or.github.io/pulp/CaseStudies/a_sudoku_problem.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://coin-or.github.io/pulp/CaseStudies/a_sudoku_problem.html&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The differences are now that instead of a Boxes constraint in the original sudoku formulation, I now want each possible pair-wise sequences across a row to appear at least once (ie, the sequence 1-2 should appear once, 2-1 should appear once, etc).&lt;/p&gt;&#xA;&lt;p&gt;In this specific scenario it is equivalent to having no duplicated pairwise sequences, but I intend to generalize this code for values/rows/columns that aren't equal.&lt;/p&gt;&#xA;&lt;p&gt;To that end I've attempted two ways of formulating it:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Making a new binary variable for the link between two cells, denoted [v1][v2][r][l], where l can take values from 1-8 (8 links in total between 9 cells).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;# All rows, columns and values within a Sudoku take values from 1 to 9&#xA;VALS = ROWS = COLS = range(1, 10)&#xA;LINKS = range(1, 9) #8 links between cells in a given row&#xA;links = LpVariable.dicts(&amp;quot;Links&amp;quot;, (VALS, VALS, ROWS, LINKS), cat = &amp;quot;Binary&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Just like choices[v][r][c] is denoted as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 if the cell at (r,c) has value v&lt;/li&gt;&#xA;&lt;li&gt;0 otherwise&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;links[v1][v2][r][l] is denoted as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 if cell at [r][l] has value v1 and cell at [r][l + 1] has value v2&lt;/li&gt;&#xA;&lt;li&gt;0 otherwise&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;After setting the typical constraints on links (each individual link sums to 1 across all [v1][v2]), I then set the constraint as such:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for v1 in VALS:&#xA;    for v2 in VALS:&#xA;        if v1 != v2:&#xA;            prob += lpSum([links[v1][v2][r][l] for r in ROWS for l in LINKS]) &amp;gt;= 1 &#xA;            #Each link of v1 - v2 should appear at least once across all rows/links&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The problem is now that I'm dealing with significantly more binary variables with this formulation - the original sudoku LP deals with 729 binary variables and here I deal with 5000-ish at the minimum and I'm not sure if this is efficient (or even feasible if I expand the range of rows/columns/values).&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Having a multiplicative boolean variable&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Since each individual link is a binary variable that's 1 if both cell choices are 1, link[v1][v2][r][c] can be expressed as choices[v1][r][c] * choices[v2][r][c+1], and as such it should be possible to formulate a constraint as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for v1 in VALS:&#xA;    for v2 in VALS:&#xA;        if v1 != v2:&#xA;            prob += lpSum(choices[v1][r][l] * choices[v2][r][l+1] for r in ROWS for c in LINKS) &amp;gt;= 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but from what I understand of PuLP, constraints cannot involve multiplication since that makes them not linear. Linearizing it like in 1) would resolve it but run into the issues of way too many variables and constraints for a feasible run time if the problem is expanded in any way.&lt;/p&gt;&#xA;&lt;p&gt;Are there better ways to formulate this constraint such that it doesn't require the creation of a 4d array to specify/solve for each individual link, and doesn't require multiplication in its constraints?&lt;/p&gt;&#xA;" OwnerUserId="12136" LastEditorUserId="12136" LastEditDate="2023-07-14T07:03:32.843" LastActivityDate="2023-07-17T04:05:57.407" Title="Efficient ways to do pairwise/multiplicative variables in integer linear programming on PuLP / Python" Tags="|python|integer-programming|binary-variable|pulp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10701" PostTypeId="2" ParentId="10700" CreationDate="2023-07-14T10:04:34.143" Score="0" Body="&lt;p&gt;I would try having a 'link' variable for each row and ordered pair of values. Then force if to 0 if the reverse order appears anywhere in the row. If this is not general enough for you, I think your first option might be fast enough depending on your choice of solver.&lt;/p&gt;&#xA;" OwnerUserId="7666" LastActivityDate="2023-07-14T10:04:34.143" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10702" PostTypeId="1" AcceptedAnswerId="10703" CreationDate="2023-07-14T13:37:36.587" Score="0" ViewCount="69" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$X_{ijklm}$&lt;/span&gt; are Boolean Variables, where &lt;span class=&quot;math-container&quot;&gt;$i,j,k,l,m$&lt;/span&gt; range from &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, then write an ILP constraint to ensure that for each value of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, either all the &lt;span class=&quot;math-container&quot;&gt;$jth$&lt;/span&gt; variables are set to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or all the &lt;span class=&quot;math-container&quot;&gt;$jth$&lt;/span&gt; variables are set to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; irrespective of the values of &lt;span class=&quot;math-container&quot;&gt;$i,l$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; and there exists at least one value of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; for which all the variables are set to 1.&lt;/p&gt;&#xA;&lt;p&gt;For example, when &lt;span class=&quot;math-container&quot;&gt;$k=1$&lt;/span&gt;, ensure all variables where &lt;span class=&quot;math-container&quot;&gt;$j=1,2,3 \ldots n$&lt;/span&gt;  are set to either &lt;em&gt;all&lt;/em&gt; 0 or &lt;em&gt;all&lt;/em&gt; 1 irrespective of the values of &lt;span class=&quot;math-container&quot;&gt;$i, l$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;. Similarly, when &lt;span class=&quot;math-container&quot;&gt;$k=2$&lt;/span&gt;, ensure all variables where &lt;span class=&quot;math-container&quot;&gt;$j=1,2,3 \ldots n$&lt;/span&gt;  are set to either  &lt;em&gt;all&lt;/em&gt; 0 or &lt;em&gt;all&lt;/em&gt; 1 irrespective of the values of &lt;span class=&quot;math-container&quot;&gt;$i, l$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;. Additionally, ensure that there exists at least one &lt;span class=&quot;math-container&quot;&gt;$kth$&lt;/span&gt; index for which all variables are set to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As a concrete enumerated case, consider &lt;span class=&quot;math-container&quot;&gt;$X_{ij1lm}$&lt;/span&gt;, in which case &lt;span class=&quot;math-container&quot;&gt;$k = 1$&lt;/span&gt;, in such a scenario, the set of variables for different values of j are &lt;span class=&quot;math-container&quot;&gt;$X_{i11lm}, X_{i21lm}, X_{i31lm}, \ldots, X_{in1lm}$&lt;/span&gt;. Similarly for &lt;span class=&quot;math-container&quot;&gt;$k = 2$&lt;/span&gt;, the set of variables for different values of j are &lt;span class=&quot;math-container&quot;&gt;$X_{i12lm}, X_{i22lm}, X_{i32lm}, \ldots, X_{in2lm}$&lt;/span&gt;. The ILP constraint should ensure either all these variables are set to 0 or set to 1 and there exists at least one value of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; for which all the variables are set to 1.&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="584" LastEditDate="2023-07-14T15:57:51.743" LastActivityDate="2023-07-14T23:11:59.990" Title="ILP constraint conditional on a value of a variable" Tags="|mixed-integer-programming|integer-programming|logical-constraints|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10703" PostTypeId="2" ParentId="10702" CreationDate="2023-07-14T16:34:35.203" Score="2" Body="&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$i,k,l,m$&lt;/span&gt;, you want all &lt;span class=&quot;math-container&quot;&gt;$X_{ijklm}$&lt;/span&gt; to take the same value for all &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.  Here are three alternative ways, in increasing order of efficiency:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$X_{ijklm} = X_{ij'klm} \quad \text{for all $i,k,l,m,j &amp;lt; j'$}$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Introduce a new variable &lt;span class=&quot;math-container&quot;&gt;$Y_{iklm}$&lt;/span&gt; to represent the common value and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$X_{ijklm} = Y_{iklm} \quad \text{for all $i,j,k,l,m$}$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Omit the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; index and replace &lt;span class=&quot;math-container&quot;&gt;$X_{ijklm}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$X_{iklm}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;For the &amp;quot;there exists at least one value of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; for which all the variables are set to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;&amp;quot; requirement, here are the corresponding constraints for the three alternative ways:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_k X_{i1klm} \ge 1 \quad \text{for all $i,l,m$}$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_k Y_{iklm} \ge 1 \quad \text{for all $i,l,m$}$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_k X_{iklm} \ge 1 \quad \text{for all $i,l,m$}$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-07-14T16:41:11.497" LastActivityDate="2023-07-14T16:41:11.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10704" PostTypeId="2" ParentId="10702" CreationDate="2023-07-14T23:11:59.990" Score="0" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j} x_{iklm}^j =ny_{iklm} \ \ \forall i,l,m,k $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1 \le \sum_k y_{iklm} \ \ \forall i,l,m$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$y_{iklm}$&lt;/span&gt; is also binary&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-07-14T23:11:59.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10705" PostTypeId="2" ParentId="10700" CreationDate="2023-07-14T23:30:16.070" Score="1" Body="&lt;p&gt;You can define a binary link &lt;span class=&quot;math-container&quot;&gt;$z_{v,v'}$&lt;/span&gt; and use the following linear constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ z_{v,v'} \le \sum_{r,l}x_{r,l}^v$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ z_{v,v'} \le \sum_{r,l}x_{r,l+1}^{v'}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{r,l}(x_{r,l+1}^v+x_{r,l}^{v'}) \le z_{v,v'}+1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{v,v'} \ge 1 \quad \forall v, v'$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x_{r,l}^{v}$&lt;/span&gt; is your choice binary variable.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-07-17T04:05:57.407" LastActivityDate="2023-07-17T04:05:57.407" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10706" PostTypeId="1" AcceptedAnswerId="10707" CreationDate="2023-07-15T00:02:30.423" Score="1" ViewCount="224" Body="&lt;p&gt;I am using a MIP formulation to decide which dates and locations (i.e. stops) should be chosen for a route that maximizes the total revenue over all chosen stops. My decision variable &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is the permutation of all possible locations &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and all possible dates &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$X[l,t]$&lt;/span&gt; represents the binary choice of a location &lt;span class=&quot;math-container&quot;&gt;$l \in L$&lt;/span&gt; and date &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have a revenue matrix &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$R[l,t]$&lt;/span&gt; represents the revenue estimate for a given location-date pair. I also have a distance matrix &lt;span class=&quot;math-container&quot;&gt;$D_l$&lt;/span&gt; which gives the distance between any two locations, as well as a time distance matrix &lt;span class=&quot;math-container&quot;&gt;$D_t$&lt;/span&gt; which gives the number of days between any two dates. I am also operating with the constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The route has at most &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; stops: &lt;span class=&quot;math-container&quot;&gt;$\sum X[l, t] \leq N$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Each date may be chosen at most once: &lt;span class=&quot;math-container&quot;&gt;$\sum_{l \in L} X[l, t] \leq 1 \space \forall \space t \in T$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Each location may be chosen once: &lt;span class=&quot;math-container&quot;&gt;$\sum_{t \in T} X[l, t] \leq 1 \space \forall \space l \in L$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;A requirement of the problem is that each stop on the route has to be within &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; miles of the previous stop, and between &lt;span class=&quot;math-container&quot;&gt;$t_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_2$&lt;/span&gt; days of the previous stop. For example, this could mean that any two stops on the route must be within 250 miles of each other and between 5 and 7 days apart from each other.&lt;/p&gt;&#xA;&lt;p&gt;My first attempt was to find the set of &amp;quot;invalid&amp;quot; choices for each choice in my decision variable. This means for each choice &lt;span class=&quot;math-container&quot;&gt;$X[l,t]$&lt;/span&gt;, I found the set of other choices &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; that satisfy the conditions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$D_l[l, l'] &amp;gt; d \space \forall \space l' \in L$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$D_t[t, t'] &amp;lt; t_1 \space \forall \space t' \in T$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$D_t[t, t'] &amp;gt; t_2 \space \forall \space t' \in T$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Then, when building the constraints, requiring &lt;span class=&quot;math-container&quot;&gt;$\sum Y \le 1 - X[l, t]$&lt;/span&gt; for each location date pair in my decision variable. Efficiency of this approach aside, it doesn't work as it is naive to any ordering of stops on the route and ultimately restricts my solution space down to a single valid location date pair.&lt;/p&gt;&#xA;&lt;p&gt;I also attempted the &amp;quot;inverse&amp;quot; formulation, where for each choice I found all &amp;quot;valid&amp;quot; choices (essentially flipping the equalities of the previous conditions), &lt;span class=&quot;math-container&quot;&gt;$Y'$&lt;/span&gt;, and building the constraints &lt;span class=&quot;math-container&quot;&gt;$\sum Y \ge X[l,t]$&lt;/span&gt;. This also doesn't work as it is just not restrictive enough to prevent invalid routes.&lt;/p&gt;&#xA;&lt;p&gt;I'm at an impasse at this point and could use help from the community on my formulation of these constraints. I believe that if I could encode the ordering of stops into the constraints, i.e. that the distance and time conditions only apply to the next stop on my route and not all stops, I would have a working solution.&lt;/p&gt;&#xA;&lt;p&gt;Any and all help is much appreciated!&lt;/p&gt;&#xA;" OwnerUserId="11634" LastEditorUserId="11634" LastEditDate="2023-07-15T00:48:11.027" LastActivityDate="2023-07-21T17:00:28.620" Title="MIP constraints with chronological ordering" Tags="|mixed-integer-programming|linear-programming|modeling|constraint|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10707" PostTypeId="2" ParentId="10706" CreationDate="2023-07-15T01:34:15.930" Score="3" Body="&lt;p&gt;I recommend a network-based formulation in a directed acyclic network with a node for each location-date pair &lt;span class=&quot;math-container&quot;&gt;$(l,t)$&lt;/span&gt; and an arc from &lt;span class=&quot;math-container&quot;&gt;$(l,t)$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$(l',t')$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$t &amp;lt; t'$&lt;/span&gt; and the time and distance restrictions are satisfied.  Also introduce a source node &lt;span class=&quot;math-container&quot;&gt;$(l_S,t_S)$&lt;/span&gt; and a sink node &lt;span class=&quot;math-container&quot;&gt;$(l_T,t_T)$&lt;/span&gt; to represent the start and end of the route, respectively.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{l,t,l',t'}$&lt;/span&gt; indicate whether arc &lt;span class=&quot;math-container&quot;&gt;$(l,t,l',t')\in A$&lt;/span&gt; is traversed.  The problem is to maximize the total revenue &lt;span class=&quot;math-container&quot;&gt;$$\sum_{(l,t,l',t')\in A} R[l',t'] x_{l,t,l',t'}$$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align} &#xA;\sum_{(l,t,l',t')\in A} x_{l,t,l',t'} - \sum_{(l',t',l,t)\in A} x_{l',t',l,t} &amp;amp;=&#xA;\begin{cases} 1 &amp;amp; \text{if $(l,t)=(l_S,t_S)$} \\ -1 &amp;amp; \text{if $(l,t)=(l_T,t_T)$} \\ 0 &amp;amp; \text{otherwise} \end{cases} &#xA;&amp;amp;\text{for all nodes $(l,t)$} \tag1\label1\\&#xA;\sum_{(l,t,l',t')\in A} x_{l,t,l',t'} &amp;amp;\le N+1 \tag2\label2\\&#xA;\sum_{(l,t,l',t')\in A} x_{l,t,l',t'} &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for all $t'$} \tag3\label3\\&#xA;\sum_{(l,t,l',t')\in A} x_{l,t,l',t'} &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for all $l'$} \tag4\label4\\&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} yields a path from source to sink.&#xA;Constraint \eqref{2} enforces at most &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; stops.&#xA;Constraint \eqref{3} chooses each date at most once.&#xA;Constraint \eqref{4} chooses each location at most once.&lt;/p&gt;&#xA;&lt;p&gt;See the following blog post of mine for a very similar problem and the resulting network-based formulation:&#xA;&lt;a href=&quot;https://blogs.sas.com/content/operations/2015/04/03/the-traveling-baseball-fan-problem/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://blogs.sas.com/content/operations/2015/04/03/the-traveling-baseball-fan-problem/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-07-15T16:22:48.927" LastActivityDate="2023-07-15T16:22:48.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10708" PostTypeId="2" ParentId="10706" CreationDate="2023-07-15T05:37:42.547" Score="0" Body="&lt;p&gt;You may need to define a set of binary variables &lt;span class=&quot;math-container&quot;&gt;$y_{l,l'}$&lt;/span&gt; for arcs/routes from &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$l'$&lt;/span&gt; in a set &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; and say &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is set of dates in chronological order.&lt;br /&gt;&#xA;Also define a constant &lt;span class=&quot;math-container&quot;&gt;$\tau_{t,t'} : t'= T_t +1$&lt;/span&gt; where&#xA;&lt;span class=&quot;math-container&quot;&gt;$\tau_{t,t'} = 1: t+5 \le t' \le t+7 $&lt;/span&gt;, else &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; with additional constraints like&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ y_{l,l'}=0 \quad \forall (l,l'): D_{l,l'} \gt 250$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x_{l,t}+ x_{l',t'} \le \tau_{t,t'}y_{l,l'}+1 : \ \ t' = T_t +1 \ \ \forall t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The edge/arc variable &lt;span class=&quot;math-container&quot;&gt;$y_{l,l'} $&lt;/span&gt; will provide the constraint on visiting 2 stops within the given time frame.&lt;/p&gt;&#xA;&lt;p&gt;If there are dates when there's possibility no location is visited then define &lt;span class=&quot;math-container&quot;&gt;$ \tau_{t,t'}= 1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$ (t,t')$&lt;/span&gt; pairs of &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; as a parameter in &lt;span class=&quot;math-container&quot;&gt;$ t\times t$&lt;/span&gt; matrix&#xA;Then the 2nd set of constraints can be modified as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{l,t}+ x_{l',t'} \le \tau_{t,t'}y_{l,l'}+1 + \sum_{m \in V - \{l,l' \}}x_{m,t''} \ \ \forall (l,l') \in V \ \ \forall t \lt t'' \lt t'$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-07-16T21:36:42.217" LastActivityDate="2023-07-16T21:36:42.217" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10711" PostTypeId="1" AcceptedAnswerId="10714" CreationDate="2023-07-17T13:20:33.127" Score="0" ViewCount="119" Body="&lt;p&gt;I am developing a TOPTW where there are a set of N nodes. Each node i is associated with a visit time, which is also the score Si. The starting point and the end point of each tour is fixed, which is node 0. Travel time matrix is given. Not all nodes can be visited because of time budget max_time.&lt;/p&gt;&#xA;&lt;p&gt;I worked on the following but it gave me &lt;em&gt;infeasible&lt;/em&gt; after adjusting various parameters such as num_paths. I wonder if any of my codes go wrong?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;num_vertices = 15 # num of visits&#xA;num_paths = 1 # num of walk paths&#xA;startshift = 420&#xA;endshift = 840&#xA;max_time = endshift - startshift # max shift time&#xA;scores = [0, 60, 30, 45, 45, 45, 30, 45, 45, 60, 60, 30, 30, 45, 45] # visit duration&#xA;travel_times = [&#xA;    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],&#xA;    [0, 5, 12, 17, 25, 13, 37, 10, 12, 13, 13, 12, 27, 19, 26],&#xA;    [0, 12, 5, 8, 21, 7, 32, 12, 7, 19, 7, 5, 21, 12, 23],&#xA;    [0, 17, 9, 5, 17, 8, 28, 16, 11, 25, 8, 9, 18, 7, 20],&#xA;    [0, 25, 19, 17, 5, 17, 18, 24, 24, 34, 17, 19, 6, 13, 8],&#xA;    [0, 14, 5, 8, 17, 5, 28, 12, 11, 22, 5, 5, 18, 9, 20],&#xA;    [0, 37, 30, 28, 18, 28, 5, 35, 33, 43, 28, 30, 14, 23, 20],&#xA;    [0, 10, 11, 16, 23, 12, 35, 5, 14, 18, 12, 11, 25, 17, 24],&#xA;    [0, 12, 7, 12, 25, 11, 33, 14, 5, 18, 11, 7, 25, 15, 27],&#xA;    [0, 13, 19, 25, 34, 22, 43, 18, 18, 5, 22, 19, 35, 27, 35],&#xA;    [0, 14, 5, 8, 17, 5, 28, 12, 11, 22, 5, 5, 18, 9, 20],&#xA;    [0, 12, 5, 8, 21, 7, 32, 12, 7, 19, 7, 5, 21, 12, 23],&#xA;    [0, 27, 20, 18, 6, 18, 14, 25, 25, 35, 18, 20, 5, 13, 8],&#xA;    [0, 19, 11, 7, 13, 9, 23, 18, 15, 28, 9, 11, 13, 5, 16],&#xA;    [0, 27, 22, 20, 8, 20, 20, 25, 27, 35, 20, 22, 8, 16, 5]&#xA; ]&#xA;time_windows = [(420, 840), (405, 435), (405, 435), (465, 495), (480, 510), (495, 525), (495, 525), (525, 555), (525, 555), (555, 585), (555, 585), (555, 585), (585, 615), (585, 615), (585, 615)]&#xA;&#xA;&#xA;# Model&#xA;model = cp_model.CpModel()&#xA;&#xA;# Variables &#xA;x = {}&#xA;for i in range(num_vertices):&#xA;  for j in range(num_vertices):&#xA;    for p in range(num_paths):&#xA;      x[i,j,p] = model.NewBoolVar(f'x_{i}_{j}_{p}')&#xA;      &#xA;y = {}&#xA;for i in range(num_vertices):&#xA;  for p in range(num_paths):  &#xA;    y[i,p] = model.NewBoolVar(f'y_{i}_{p}')&#xA;    &#xA;start_time = {}  &#xA;for i in range(num_vertices):&#xA;  for p in range(num_paths):&#xA;    start_time[i,p] = model.NewIntVar(startshift, endshift, f'start_{i}_{p}')&#xA;    &#xA;wait_time = {}&#xA;for i in range(num_vertices): # wait after node i&#xA;    for p in range(num_paths):&#xA;        wait_time[i,p] = model.NewIntVar(0, max_time, f'wait_{i}_{p}')&#xA;&#xA;# Constraints&#xA;# Start and end vertex (C1)&#xA;for p in range(num_paths):&#xA;  model.Add(sum(x[0,j,p] for j in range(1, num_vertices)) == 1) # start from 0&#xA;  model.Add(sum(x[i,0,p] for i in range(1, num_vertices)) == 1) # end at 0&#xA;  # model.Add(y[0,p] == 1) &#xA;&#xA;# Connectivity of paths (C2)&#xA;for p in range(num_paths):&#xA;    for k in range(num_vertices):&#xA;        model.Add(sum(x[i,k,p] for i in range(num_vertices) if i != k) == y[k,p])&#xA;        model.Add(sum(x[k,j,p] for j in range(num_vertices) if k != j) == y[k,p])&#xA;&#xA;# Time between visits (C3) to account for service, travel and wait time&#xA;for i in range(num_vertices):&#xA;    for j in range(num_vertices):&#xA;        if i != j:  # exclude loops&#xA;            for p in range(num_paths):&#xA;                model.Add(start_time[j,p] == start_time[i,p] + int(travel_times[i][j]) + scores[i] + wait_time[i,p]).OnlyEnforceIf(x[i,j,p])&#xA;                &#xA;# Each vertex visited at most once (C4)&#xA;for i in range(1, num_vertices):&#xA;    model.Add(sum(y[i,p] for p in range(num_paths)) &amp;lt;= 1)&#xA;                &#xA;# Restrict path duration (C5)&#xA;for p in range(num_paths):&#xA;    model.Add(sum(int(travel_times[i][j])*x[i,j,p] for i in range(num_vertices) for j in range(num_vertices)) + &#xA;               sum(scores[i]*y[i,p] for i in range(num_vertices)) + &#xA;               sum(wait_time[i,p] for i in range(num_vertices)) &amp;lt;= max_time)&#xA;&#xA;# Restrict the start of the service within time windows (C6 C7)&#xA;for i in range(num_vertices):&#xA;  for p in range(num_paths):&#xA;    lb, ub = time_windows[i]&#xA;    model.Add(start_time[i,p] &amp;gt;= lb).OnlyEnforceIf(y[i,p])&#xA;    model.Add(start_time[i,p] &amp;lt;= ub)&#xA;&#xA;# Objective to maximise the total collected score&#xA;objective = []&#xA;for i in range(1, num_vertices):&#xA;  for p in range(num_paths):&#xA;    objective.append(scores[i] * y[i,p])&#xA;model.Maximize(sum(objective))&#xA;&#xA;# Solution&#xA;solver = cp_model.CpSolver()&#xA;status = solver.Solve(model)&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12146" LastEditorUserId="491" LastEditDate="2023-07-17T16:01:44.997" LastActivityDate="2023-07-17T17:52:04.197" Title="Team Orienteering Problem with Time Windows infeasible using CP-SAT solver in Google OR-Tool" Tags="|optimization|mixed-integer-programming|or-tools|cp-sat|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10714" PostTypeId="2" ParentId="10711" CreationDate="2023-07-17T17:45:01.730" Score="2" Body="&lt;p&gt;I enabled logging:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;solver.parameters.log_search_progress = True&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Unfortunately, nothing jumps out. The model is proven infeasible during presolve.&lt;/p&gt;&#xA;&lt;p&gt;You should look at the prized collecting vrp problem written with CP-SAT.&#xA;I believe this is the same problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/python/prize_collecting_vrp_sat.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/examples/python/prize_collecting_vrp_sat.py&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And its tsp variation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/examples/python/prize_collecting_tsp_sat.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/examples/python/prize_collecting_tsp_sat.py&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2023-07-17T17:52:04.197" LastActivityDate="2023-07-17T17:52:04.197" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10715" PostTypeId="1" CreationDate="2023-07-18T12:58:02.310" Score="1" ViewCount="95" Body="&lt;p&gt;Ucame across a paper today and this &lt;a href=&quot;https://doi.org/10.1287/serv.2017.0192&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt; mentioned that the model size is &lt;span class=&quot;math-container&quot;&gt;$O(\mid I\mid\cdot\mid T \mid)$&lt;/span&gt;. I am also sitting on a MILP problem right now. Does my model size also amount to this size or is it different? If so, how do I find out what my model size is?&lt;/p&gt;&#xA;" OwnerUserId="11999" LastEditorUserId="491" LastEditDate="2023-07-18T15:22:28.913" LastActivityDate="2023-07-18T15:59:13.307" Title="MILP - Find out model size" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10716" PostTypeId="2" ParentId="10715" CreationDate="2023-07-18T15:59:13.307" Score="3" Body="&lt;p&gt;First, the notation &lt;span class=&quot;math-container&quot;&gt;$O(\mid I\mid\cdot\mid T \mid)$&lt;/span&gt; means that the model size grows in proportion to the product of the cardinalities of &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T.$&lt;/span&gt; Whether this is relevant to you depends on whether you envision applying your model to progressively large problem instances. If you have one specific problem in mind, &amp;quot;big O&amp;quot; notation is not meaningful for your case.&lt;/p&gt;&#xA;&lt;p&gt;For a given instance of your model, there are several size measures that are relevant, the primary ones being total number of constraints, total number of variables, number of integer/binary variables and number of nonzero coefficients. Many solvers will output this information for you. What to make of it is hard to say. Typically &amp;quot;more&amp;quot; implies &amp;quot;slower to solve&amp;quot;, but it's not quite that simple. For instance, a reformulation of the original model that increases either the constraint or variable count (or both) but reduces the density of the coefficient matrix (basically, number of nonzero coefficients divided by product of constraint and variable counts) might be faster to solve than the original model ... or it might be slower.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-07-18T15:59:13.307" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10718" PostTypeId="1" CreationDate="2023-07-19T18:53:51.407" Score="1" ViewCount="119" Body="&lt;p&gt;Given an directed graph &lt;span class=&quot;math-container&quot;&gt;$G= (N,E)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; is the set of nodes and &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is the set of all edges, each associated with a direction. &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; is a connected graph but not necessarily a complete graph.&lt;/p&gt;&#xA;&lt;p&gt;A path can start at any of the blue nodes, can contain one or more blue node depending on the graph connectivity and the edges direction, but must end at the destination in red. My graphs are relatively small, thus it is possible to enumerate all possible paths. Let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be the set of all paths with no cycles. In the graph below 7 paths are possible: &lt;span class=&quot;math-container&quot;&gt;$P = \{p_{(n_1dst)},p_{(n_2dst)},p_{(n_3dst)},p_{(n_1n_2dst)}, p_{(n_1n_3dst)}, p_{(n_2n_3dst)}, p_{(n_1n_2n_3dst)}\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I want to write a set of constraints that makes sure that in the final solution we obtain a path or a subset of paths such that there's at least one blue node in common with all other blue nodes in the selected paths or all blue nodes are in the same path.&lt;/p&gt;&#xA;&lt;p&gt;For example, for the graph below a solution that contains &lt;span class=&quot;math-container&quot;&gt;$p_{(n_1dst)}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_{(n_2n_3dst)}$&lt;/span&gt; is not feasible. The possible feasible solutions are if we use at least:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{(n_1n_2n_3dst)}$&lt;/span&gt; + additional paths&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{(n_1n_2dst)}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_{(n_1n_3dst)}$&lt;/span&gt; + additional paths&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{(n_1n_2dst)}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_{(n_2n_3dst)}$&lt;/span&gt; + additional paths&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p_{(n_1n_3dst)}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_{(n_2n_3dst)}$&lt;/span&gt; + additional paths&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;If we define &lt;span class=&quot;math-container&quot;&gt;$x_{p} \in \{0,1\}^{|P|}$&lt;/span&gt; as a binary variable that equals 1 if path &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is used, and 0 otherwise. The following constraints can be added:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_1:$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$p_{(n_1n_2dst)} + p_{(n_1n_3dst)} + p_{(n_1n_2n_3dst)}  \geq 1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$c_2:$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$p_{(n_1n_2dst)} + p_{(n_2n_3dst)} + p_{(n_1n_2n_3dst)} \geq 1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$c_3:$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$p_{(n_1n_3dst)} + p_{(n_2n_3dst)} + p_{(n_1n_2n_3dst)} \geq 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;if for example &lt;span class=&quot;math-container&quot;&gt;$p_{(n_1n_2dst)} = 1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$c_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_2$&lt;/span&gt; are respected, thus in  &lt;span class=&quot;math-container&quot;&gt;$c_3$&lt;/span&gt;, either &lt;span class=&quot;math-container&quot;&gt;$p_{(n_1n_3dst)}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$p_{(n_2n_3dst)}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$p_{(n_1n_2n_3dst)}$&lt;/span&gt; has to be selected.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZBsB1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZBsB1.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;While this work for graphs of size 3, I tried to generalize it in this way for larger graphs (size 4 and more): &lt;span class=&quot;math-container&quot;&gt;$\sum_{r~\in~\Theta_{n}} x_{p} \geq 1, \forall~ n \in N$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\Theta_{n} = n \cup \Bigl\{ \bigcup_{k=1}^{k=|c^{'}|}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$c^{'} \choose k$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\Bigr\}, \forall n \in N$&lt;/span&gt;, and where &lt;span class=&quot;math-container&quot;&gt;$c^{'} = c \setminus \{n\} $&lt;/span&gt;. I find for each node &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; the combination of size 1 to &lt;span class=&quot;math-container&quot;&gt;$|N|-1$&lt;/span&gt; of n with the remaining nodes without n. But this didn't work.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone has an idea on how to make this work, and if this problem has a name in the OR literature?&lt;/p&gt;&#xA;" OwnerUserId="11022" LastEditorUserId="491" LastEditDate="2023-07-20T00:49:55.697" LastActivityDate="2023-12-17T01:02:35.403" Title="Constraints to avoid disjointed solutions in a MIP" Tags="|mixed-integer-programming|linear-programming|integer-programming|constraint|combinatorial-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10719" PostTypeId="2" ParentId="10718" CreationDate="2023-07-19T20:29:20.870" Score="0" Body="&lt;p&gt;It sounds like you want to enforce connectivity of an induced subhypergraph of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Hypergraph&quot; rel=&quot;nofollow noreferrer&quot;&gt;hypergraph&lt;/a&gt; with the blue nodes as the node set and a hyperedge for each path.  You can do this by enforcing connectivity of an induced subgraph in the associated bipartite &amp;quot;incidence&amp;quot; graph with the blue nodes on the left, a node for each hyperedge on the right, and an edge if the blue node appears in the hyperedge.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-07-19T20:37:19.600" LastActivityDate="2023-07-19T20:37:19.600" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10720" PostTypeId="1" CreationDate="2023-07-20T15:16:35.387" Score="0" ViewCount="108" Body="&lt;p&gt;I am trying to run the pricing model from the paper &amp;quot;Designing pricing and compensation schemes by integrating matching and routing models for crowd-shipping systems&amp;quot; on python with Gurobi, but the constraints given in this model do not preserve the network flow as expected. Maybe there should be more constraints to secure the networkflow from the origin nodes to the pick up nodes. I would like to get some feedback about the model and my 'translation' to python, as I don't get why it does not work as expected.&#xA;First the scenario: We have m drivers h in H, H=[1,..,m], each having an origin node tau[h] and a destination node tau_[h]. We have also n requests i in A, A=[1,..,n] (pickup nodes), which have to be delivered in the delivery nodes A_=[n+1,...,2n]. Resulting from this we have a Graph G(V,E) with V=A+A_+tau+tau_ nodes and E=V*V lines. A driver should drive from his origin passing a pickup and the appropriate delivery to his destination.(or directly from his origin to his destination).&lt;br /&gt;&#xA;This is the model from the paper:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fzV3w.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fzV3w.png&quot; alt=&quot;Sets and Variables 1&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Srq0S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Srq0S.png&quot; alt=&quot;Sets and Variables 2&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/6kE8l.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6kE8l.png&quot; alt=&quot;model part 1&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/c3QSr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/c3QSr.png&quot; alt=&quot;model part 2&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The package size is not relevant and is neglected in the paper. That's why K is also not considered in the programm.&lt;/p&gt;&#xA;&lt;p&gt;And here is my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;from gurobipy import GRB, quicksum&#xA;def pricing(n, m, A, A_, H, WTP, ETP, R, d2, V, V1, E2, d, t, s, l, a, b, M):&#xA;&#xA;    global mod&#xA;    mod = gp.Model(&amp;quot;Pricing&amp;quot;)&#xA;&#xA;    # Decision variables&#xA;    x = mod.addVars(E, H, vtype=GRB.BINARY, name=&amp;quot;x&amp;quot;)&#xA;    S = mod.addVars(V, H, vtype=GRB.CONTINUOUS,lb=0, name=&amp;quot;S&amp;quot;)&#xA;    L = mod.addVars(V, H, vtype=GRB.CONTINUOUS,lb=0, name=&amp;quot;L&amp;quot;)&#xA;    z = mod.addVars(A, vtype=GRB.BINARY, name=&amp;quot;z&amp;quot;)&#xA;    p = mod.addVars(E, H, vtype=GRB.CONTINUOUS, lb=0, name=&amp;quot;p&amp;quot;)&#xA;    c = mod.addVars(E, H, vtype=GRB.CONTINUOUS, lb=0, name=&amp;quot;c&amp;quot;)&#xA;    mod.setObjective(quicksum(p[i,j,h]*d2[i]-c[i, j, h]*d[i, j] for i in A for j in A_ &#xA;    for h in H if j!=i ), gp.GRB.MAXIMIZE) # (40)&#xA;    mod.addConstrs((p[i, j, h] &amp;lt;= WTP[i]/d2[i] + (1-x[i, j, h])*M for i in A for j in A_ &#xA;    for h in H if i!=j), name='Price_not_greater_than_WTP (02)/(28)')&#xA;    mod.addConstrs((c[i, j, h] &amp;gt;= ETP[h]*x[i, j, h] for j in A_ for h in H for i in A if &#xA;    i!=j), name='Compensation_not_less_than_ETP (03)/(29)')&#xA;    mod.addConstrs((p[i, j, h] &amp;gt;= c[i, j, h] for i in A for j in A_ for h in H), &#xA;    name=&amp;quot;constraint4&amp;quot;)&#xA;    mod.addConstrs((quicksum(x[i, j, h] for j in A_ for h in H) + z[i] == 1 for i in A), &#xA;    name=&amp;quot;constraint5&amp;quot;)&#xA;    mod.addConstrs((quicksum(x[i, j, h] for j in V if i!=j ) - quicksum(x[j, n + i, h] &#xA;    for j in V if j!=n+i) == 0 for i in A for h in H), name=&amp;quot;constraint6&amp;quot;)&#xA;    mod.addConstrs((quicksum(x[tau[h], j, h] for j in pickup_destination[h] ) == 1 for h &#xA;    in H), name=&amp;quot;constraint7&amp;quot;)&#xA;    mod.addConstrs((quicksum(x[i, tau_[h], h] for i in delivery_origin[h] ) == 1 for h &#xA;    in H), name=&amp;quot;constraint8&amp;quot;)&#xA;    mod.addConstrs((quicksum(x[i, j, h] for i in V if i!=j) - quicksum(x[j, i, h] for i &#xA;    in V if i!=j) == 0 for j in A_ for h in H), name=&amp;quot;constraint9&amp;quot;)&#xA;    mod.addConstrs((S[i, h] + s[i] + t[i, j] &amp;lt;= S[j, h] + (1-x[i, j, h])*M for (i, j) in &#xA;    E for h in H), name='courier_follows_matched_paths (10)/(34)')&#xA;    mod.addConstrs(( S[i, h] == [a[i], b[i]] for i in V for h in H),name=&amp;quot;constraint11&amp;quot;)&#xA;    mod.addConstrs((S[i, h] &amp;lt;= S[n + i, h] for i in V[0:-n] for h in H), &#xA;    name=&amp;quot;constraint12&amp;quot;)&#xA;    mod.addConstrs((L[i, h] + l[j] &amp;lt;= L[j, h]+ (1-x[i , j, h])*M for (i,j) in E for h in &#xA;    H), name='capacity_for_next_loading (13)/(35)')&#xA;    mod.addConstrs((L[i, h] &amp;lt;= R[h] for i in V for h in H ), name=&amp;quot;constraint14&amp;quot;)&#xA;    mod.addConstrs((L[tau[h], h] == 0 for h in H), name=&amp;quot;constraint15.1&amp;quot;)&#xA;    mod.addConstrs((L[tau_[h], h] == 0 for h in H), name=&amp;quot;constraint15.2&amp;quot;)&#xA;    mod.addConstrs((p[i, j, h] &amp;lt;= M*x[i, j, h] for i, j in E for h in H if i!=j), &#xA;    name=&amp;quot;constraint23&amp;quot;)&#xA;    mod.addConstrs((c[i, j, h] &amp;lt;= M*x[i, j, h] for i, j in E for h in H), &#xA;    name=&amp;quot;constraint24&amp;quot;)&#xA;    mod.addConstrs((p[i, j, h]*x[i, j, h]==p[i, j, h] for i, j in E for h in H if i!=j), &#xA;    name='constraint25')&#xA;    mod.addConstrs((c[i, j, h]*x[i, j, h]==c[i, j, h] for i, j in E for h in H &#xA;    ),name='constraint26')&#xA;    mod.optimize()&#xA;&#xA;    active_arcs=[(i, j, h) for i, j in E for h in H if x[i, j, h].x&amp;gt;0.99] &#xA;    active_prices=[(i, j, h) for i, j in E for h in H if p[i, j, h].x&amp;gt;0.99]&#xA;    active_costs=[(i, j, h) for i, j in E for h in H if c[i, j, h].x&amp;gt;0.99]   &#xA;    active_load=[(i, h) for i in V for h in H  if L[i, h].x&amp;gt;0.99] &#xA;    active_z=[i for i in A if z[i].x&amp;gt;0.99] &#xA;    active_Start=[(i, h) for i in V for h in H if S[i, h].x&amp;gt;0.99]&#xA;&#xA;    if mod.status == GRB.OPTIMAL:&#xA;          &#xA;        optimal_x = mod.getAttr(&amp;quot;x&amp;quot;, x)&#xA;        optimal_S = mod.getAttr(&amp;quot;x&amp;quot;, S)&#xA;        optimal_L = mod.getAttr(&amp;quot;x&amp;quot;, L)&#xA;        optimal_z = mod.getAttr(&amp;quot;x&amp;quot;, z)&#xA;        optimal_p = mod.getAttr(&amp;quot;x&amp;quot;, p)&#xA;        optimal_c = mod.getAttr(&amp;quot;x&amp;quot;, c)&#xA;&#xA;         &#xA;        return active_arcs, active_prices, active_costs, active_load, &#xA;        active_Start, active_z, optimal_L, optimal_S, optimal_c, optimal_p, optimal_x, &#xA;        optimal_z&#xA;    else:&#xA;        return None&#xA;n = 2  # Number of packages&#xA;m = 2  # Number of couriers&#xA;# Sets/nodes&#xA;A = list(range(m+1, n+m + 1))  # Set of package pickup nodes&#xA;A_ = list(range(n+m + 1, 2 * n +m+ 1))  # Set of package delivery nodes&#xA;H = list(range(1, m + 1))  # Set of couriers&#xA;tau=[h for h in H]&#xA;tau.insert(0,0)&#xA;tau_=[2*n + m +h for h in H]&#xA;tau_.insert(0,0)&#xA;V= tau[1:] + A + A_ + tau_[1:]&#xA;destination={(h): tau_[h] for h in H}&#xA;pickup_destination= {h: A+[destination[h]] for h in H}&#xA;origin={(h): tau[h] for h in H}&#xA;delivery_origin={h: A_+[origin[h]] for h in H}&#xA;Vh={(h): [origin[h]]+A+A_+[destination[h]] for h in H }&#xA;# Edges&#xA;E=[(i, j) for i in V for j in V if i!=j ]&#xA;M = 10000  # Large positive number&#xA;# Other parameters&#xA;WTP = {i: 10 for i in A}  # Maximum price that a Sender is willing to pay&#xA;ETP = {h: 2 for h in H}  # Minimum compensation that courier h expects&#xA;R = {(h): 5 for h in H }  # Capacity of courier h for package size k&#xA;d = {(i, j): 1 for i, j in E}  # Travel distance for link (i, j)&#xA;for key,value in d.items():  &#xA;    if key[0]==key[1]:&#xA;        value= 0     &#xA;    d[key]=value&#xA;d1= {i:1 for i in V} #Travel distance for price relevant arcs &#xA;d2= d1.copy()&#xA;for i in d2:&#xA;    if i not in A:&#xA;        d2[i]=0&#xA;t = {(i, j): 1 for i, j in E}  # Travel time for link (i, j)&#xA;s = {i: 1 for i in V}  # Service time at node i&#xA;for i in s:&#xA;    if i in tau:&#xA;        s[i]=0&#xA;    if i in tau_:&#xA;        s[i]=0&#xA;l = {i: 1 for i in V}  # Amount of packages that need to be loaded at node i&#xA;for key, value in l.items():&#xA;    global newvalue&#xA;    newvalue=value&#xA;    if key in A_:&#xA;        newvalue=value*(-1)&#xA;    if key in tau :&#xA;        newvalue=0&#xA;    if key in tau_:&#xA;        newvalue=0&#xA;    l[key]=newvalue #positive load in pickup and negative load at dropoff&#xA;a = {i:0 for i in V}  # Time window lower bound&#xA;b = {i: 10 for i in V}  # Time window upper bound&#xA;&#xA;&#xA;result = pricing(n, m, A, A_, H, WTP, ETP, R, d2, V, V1, E2, d, t, s, l, a, b, M)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I run it like this, the plotted result looks like this: &lt;a href=&quot;https://i.stack.imgur.com/jT5nR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jT5nR.png&quot; alt=&quot;result&quot; /&gt;&lt;/a&gt;&#xA;So there is no constraint (in my programm) forcing the driver actually to begin at his origin. It would be very helpful to get some feedback where the mistake could be.&lt;/p&gt;&#xA;" OwnerUserId="12156" LastEditorUserId="12156" LastEditDate="2023-07-20T16:22:26.630" LastActivityDate="2023-12-18T03:09:16.077" Title="Interpret the formulation of a pricing model in crowdshipping" Tags="|python|linearization|network-flow|gurobipy|pricing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10721" PostTypeId="1" CreationDate="2023-07-20T15:47:40.050" Score="1" ViewCount="82" Body="&lt;p&gt;The multi-objective optimization problem settings are as defined below:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Objective 1: Minimize &lt;span class=&quot;math-container&quot;&gt;$f_1(X_1,X_2)=C_0+C_1(1/X_1)+C_2(X_2/X_1)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Objective 2: Minimize &lt;span class=&quot;math-container&quot;&gt;$f_2(X_1,X_2)=D_0+D_1X_1+D_2X_2+D_3(X_2/X_1)+D_4(X_2^2/X_1)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Objective 3: Minimize &lt;span class=&quot;math-container&quot;&gt;$f_3(X_1, X_2)=E_1(X_2/X_1)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 1: &lt;span class=&quot;math-container&quot;&gt;$ 0 \le X_1 \le A_1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 2: &lt;span class=&quot;math-container&quot;&gt;$ 0 \le X_2 \le A_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 3: &lt;span class=&quot;math-container&quot;&gt;$ k_1X_1 + k_2X_2 \le A_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constraint 4: &lt;span class=&quot;math-container&quot;&gt;$ k_3X_1 \le k_4X_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$C_0, C_1,C_2,D_0,D_1,D_2,D_3,D_4,E_1,A_1,A_2, A_3, k_1,k_2,k_3,k_4$&lt;/span&gt; are positive constant numbers. &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_2$&lt;/span&gt; are decision variables that can be real/integer.&lt;/p&gt;&#xA;&lt;p&gt;Evolutionary algorithms like NSGA-II are considered mainstream algorithms to solve a non-linear multi-objective optimization algorithm (Pareto optimization).&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Other than metaheuristics like NSGA-II, PSO, and SMPSO, are there other exact methods that can be applied to solve Pareto optimization problems (i.e., identifying Pareto optimal solutions)?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Which is better to solve the problem illustrated above NSGA-II or exact methods? Does the non-linearity of the problem play a significant role in the selection of solution algorithms?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5794" LastEditorUserId="67" LastEditDate="2023-07-20T19:10:46.473" LastActivityDate="2023-08-19T20:08:06.027" Title="Metaheuristics or Exact algorithms to solve a non-linear multi-objective optimization problem?" Tags="|optimization|linear-programming|multi-objective-optimization|metaheuristics|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10722" PostTypeId="2" ParentId="10721" CreationDate="2023-07-20T20:06:17.843" Score="1" Body="&lt;p&gt;Observe that all three objective functions are increasing functions of &lt;span class=&quot;math-container&quot;&gt;$X_2.$&lt;/span&gt; For fixed &lt;span class=&quot;math-container&quot;&gt;$X_1,$&lt;/span&gt; you want the smallest feasible value of &lt;span class=&quot;math-container&quot;&gt;$X_2.$&lt;/span&gt; Constraint 4 is the only one that puts upward pressure on &lt;span class=&quot;math-container&quot;&gt;$X_2.$&lt;/span&gt; So for fixed &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; you want &lt;span class=&quot;math-container&quot;&gt;$X_2 = \frac{k_3}{k_4} X_1.$&lt;/span&gt; Substitute that into constraint 3 to get &lt;span class=&quot;math-container&quot;&gt;$$X_1 \le \frac{k_4}{k_1 k_4 + k_2 k_3} A_3.$$&lt;/span&gt; Combining constraints 2 and 4, we also have &lt;span class=&quot;math-container&quot;&gt;$X_1 \le \frac{k_4}{k_3} A_2.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Rewrite your objective functions, substituting out &lt;span class=&quot;math-container&quot;&gt;$X_2.$&lt;/span&gt; The first is now linear in &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{X_1},$&lt;/span&gt; the second is linear in &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; and the third is a constant. The domain of &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; is from 0 to &lt;span class=&quot;math-container&quot;&gt;$$\min(A_1, \frac{k_4}{k_3} A_2,\frac{k_4}{k_1 k_4 + k_2 k_3} A_3).$$&lt;/span&gt; Since &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; is strictly decreasing and &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt; is strictly increasing in &lt;span class=&quot;math-container&quot;&gt;$X_1,$&lt;/span&gt; every point in the revised domain of &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; is Pareto efficient.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-07-20T20:06:17.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10723" PostTypeId="1" AcceptedAnswerId="11465" CreationDate="2023-07-21T00:11:24.760" Score="0" ViewCount="69" Body="&lt;p&gt;Assume an inventory stochastic optimization problem in the following form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min\limits_{x\in X} c^\top x +  \mathbb{E}_{\mathbb{\xi}}[\mathcal{Q}(x, \xi)]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Demand is the uncertain parameter, and is realised throughout the horizon. Historical demand data is used as scenarios for a sample average approximation in the second stage. I am solving the problem using a rolling horizon approach. My question is:&lt;/p&gt;&#xA;&lt;p&gt;Can I derive a lower bound for the stochastic two-stage problem by solving the problem with one scenario only, where that scenario is the future realized demand?&lt;/p&gt;&#xA;" OwnerUserId="660" LastActivityDate="2024-01-03T04:41:23.640" Title="Deriving a lower bound for a two-stage stochastic problem" Tags="|stochastic-programming|bounds|approximation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10724" PostTypeId="2" ParentId="10720" CreationDate="2023-07-21T02:56:04.827" Score="0" Body="&lt;p&gt;For source/dest node you may add constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_j x_{\tau_h,j}^{h}- \sum_i x_{i,\tau_h}^h = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_j x_{\tau'_h,j}^{h}- \sum_i x_{i,\tau'_h}^h = -1 \ \ \forall h$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-07-21T02:56:04.827" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10725" PostTypeId="1" AcceptedAnswerId="10727" CreationDate="2023-07-21T12:14:48.467" Score="1" ViewCount="79" Body="&lt;p&gt;I wonder if there is a way to retrieve the global objective upper bound in a callback in Cplex (in cpp)? I tried several context/IloCplex/IloModel... methods but nothing worked.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UMDrL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UMDrL.png&quot; alt=&quot;Bound&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12159" LastEditorUserId="12159" LastEditDate="2023-07-21T12:15:45.410" LastActivityDate="2023-07-21T16:57:28.667" Title="Get objective upper bound in a callback (cplex)" Tags="|cplex|bounds|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10726" PostTypeId="2" ParentId="10723" CreationDate="2023-07-21T14:36:08.800" Score="2" Body="&lt;p&gt;The following is a valid lower bound for the stochastic programming problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\mathbb{E}_{\mathbb{\xi} \in \varOmega} \min \limits_{x\in X} \left( c^\top x + \mathcal{Q}(x, \xi) \right) \leq &#xA;\min\limits_{x\in X} c^\top x +  \mathbb{E}_{\mathbb{\xi} \in \varOmega}[\mathcal{Q}(x, \xi)]&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To derive this lower bound, you need to &lt;strong&gt;solve &lt;span class=&quot;math-container&quot;&gt;$|\varOmega|$&lt;/span&gt; wait-and-see (perfect-information) problems&lt;/strong&gt; (&lt;span class=&quot;math-container&quot;&gt;$\varOmega$&lt;/span&gt; is the set of all the scenarios). The difference between the left-hand side and the right-hand side is: in the left-hand side, the first-stage decision &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; varies with &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt;; while in the right-hand side, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is constant for all the &lt;span class=&quot;math-container&quot;&gt;$\xi \in \varOmega$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This can be used to determine appropriate scenario size [1][2][3], and tighten the lower bound for a solution algorithm [1].&lt;/p&gt;&#xA;&lt;p&gt;Since the relationship between the objective of the stochastic problem and an arbitrary wait-and-see problem is unclear, it is generally impossible to generate a lower bound with a single run of a wait-and-see problem. However, as @Sutanu mentioned, when you know which scenario can yield the wait-and-see problem with the lowest objective in advance, it can be used to derive a valid lower bound, which is weaker than the above inequality.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;[1] Guo, P., &amp;amp; Zhu, J. (2023). Capacity reservation for humanitarian&#xA;relief: A logic-based Benders decomposition method with subgradient&#xA;cut. European Journal of Operational Research.&#xA;&lt;a href=&quot;https://doi.org/10.1016/j.ejor.2023.06.006&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/j.ejor.2023.06.006&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[2] Guo, C., Bodur, M., Aleman, D. M., &amp;amp; Urbach, D. R. (2021). Logic-based Benders decomposition and binary decision diagram based&#xA;approaches for stochastic distributed operating room scheduling.&#xA;INFORMS Journal on Computing, 33(4), 1551–1569.&#xA;&lt;a href=&quot;https://doi.org/10.1287/ijoc.2020.1036&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/ijoc.2020.1036&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[3] Mak, W.-K., Morton, D. P., &amp;amp; Wood, R. K. (1999). Monte Carlo bounding techniques for determining solution quality in stochastic&#xA;programs. Operations Research Letters, 24(1), 47–56.&#xA;&lt;a href=&quot;https://doi.org/10.1016/S0167-6377(98)00054-6&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/S0167-6377(98)00054-6&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2023-07-21T14:36:08.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10727" PostTypeId="2" ParentId="10725" CreationDate="2023-07-21T16:57:28.667" Score="1" Body="&lt;p&gt;I'll use Java notation, but C++ should be very similar if not the same. There is a method IloCplex.Callback.Context.getDoubleInfo() that takes an enumeration value as argument and returns a double precision value. The enumeration value IloCplex.Callback.Context.Info.BestBound is what you want.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-07-21T16:57:28.667" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10728" PostTypeId="2" ParentId="10706" CreationDate="2023-07-21T17:00:28.620" Score="0" Body="&lt;p&gt;As is often the case, @RobPratt's answer is probably the best way to approach this, but if you don't like the edge-based formulation and insist on the same &lt;span class=&quot;math-container&quot;&gt;$x_{\ell t}$&lt;/span&gt; variables you started with, I think the following formulation will work:&lt;/p&gt;&#xA;&lt;p&gt;In addition to the &lt;span class=&quot;math-container&quot;&gt;$x_{\ell t}\in\{0,1\}$&lt;/span&gt; variables, you also introduce &lt;span class=&quot;math-container&quot;&gt;$y_{\ell t}\in\{0,1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_{\ell t}\in\{0,1\}$&lt;/span&gt;, which are variables that indicate if &lt;span class=&quot;math-container&quot;&gt;$(\ell,t)$&lt;/span&gt; is the start or end of your schedule respectively.  Naturally you'll have &lt;span class=&quot;math-container&quot;&gt;$$\sum_{\ell,t}y_{\ell t}=\sum_{\ell,t}z_{\ell t}=1~.$$&lt;/span&gt;Next, the role that &lt;span class=&quot;math-container&quot;&gt;$D_\ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D_t$&lt;/span&gt; serve is that for each &lt;span class=&quot;math-container&quot;&gt;$(\ell,t)$&lt;/span&gt;, you have a set of &amp;quot;successors&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$S(\ell,t)$&lt;/span&gt; and &amp;quot;predecessors&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$P(\ell,t)$&lt;/span&gt;.  A successor of &lt;span class=&quot;math-container&quot;&gt;$\ell,t$&lt;/span&gt; is an assignment &lt;span class=&quot;math-container&quot;&gt;$(\ell',t')$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$(\ell,t)\to(\ell',t')$&lt;/span&gt; is a valid consecutive pair, and a predecessor has &lt;span class=&quot;math-container&quot;&gt;$(\ell',t')\to(\ell,t)$&lt;/span&gt; as a valid consecutive pair.  You have a constraint that says that if you're using &lt;span class=&quot;math-container&quot;&gt;$(\ell,t)$&lt;/span&gt;, then either you're using a successor of &lt;span class=&quot;math-container&quot;&gt;$(\ell,t)$&lt;/span&gt;, or that's the end of your schedule, which you can do with these constraints: &lt;span class=&quot;math-container&quot;&gt;$$x_{\ell t} \leq z_{\ell,t} + \sum_{(\ell',t')\in S(\ell,t)}x_{\ell't'}~\forall(\ell,t)$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$z_{\ell,t}+x_{\ell't'}\leq 1~\forall(\ell,t),\forall(\ell',t')\in S(\ell,t)$$&lt;/span&gt; The second of those two constraints says that you can't use any successors of &lt;span class=&quot;math-container&quot;&gt;$(\ell,t)$&lt;/span&gt; if it's designated as the end of the schedule.  You do the same thing for predecessors:&lt;span class=&quot;math-container&quot;&gt;$$x_{\ell t} \leq y_{\ell,t} + \sum_{(\ell',t')\in P(\ell,t)}x_{\ell't'}~\forall(\ell,t)$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$y_{\ell,t}+x_{\ell't'}\leq 1~\forall(\ell,t),\forall(\ell',t')\in P(\ell,t)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The other role that &lt;span class=&quot;math-container&quot;&gt;$D_\ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$D_t$&lt;/span&gt; serve is that they give &amp;quot;forbidden pairs&amp;quot;, i.e. there exist pairs of assignments &lt;span class=&quot;math-container&quot;&gt;$(\ell,t)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(\ell',t')$&lt;/span&gt; that are mutually incompatible and cannot possibly coexist on the schedule together (e.g. &lt;span class=&quot;math-container&quot;&gt;$|t-t'|\leq t_{min}$&lt;/span&gt;, which you called &lt;span class=&quot;math-container&quot;&gt;$t_1$&lt;/span&gt; in your post).  Let &lt;span class=&quot;math-container&quot;&gt;$F(\ell,t)$&lt;/span&gt; be the set of all assignments &lt;span class=&quot;math-container&quot;&gt;$(\ell',t')$&lt;/span&gt; that are forbidden as a result of using &lt;span class=&quot;math-container&quot;&gt;$(\ell,t)$&lt;/span&gt;, so you'd write a constraint that &lt;span class=&quot;math-container&quot;&gt;$$x_{\ell t} + x_{\ell' t'} \leq 1~\forall (\ell,t),\forall(\ell',t')\in F(\ell,t)~.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I think that covers it, in addition to the constraints you already have that &lt;span class=&quot;math-container&quot;&gt;$$\sum_{\ell,t} x_{\ell t} \leq N$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$\sum_\ell x_{\ell t} \leq 1 ~\forall t$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$\sum_t x_{\ell t} \leq 1 ~\forall \ell~.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="12162" LastActivityDate="2023-07-21T17:00:28.620" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10729" PostTypeId="1" CreationDate="2023-07-22T05:24:47.460" Score="0" ViewCount="11" Body="&lt;p&gt;If I have MCDM problems with performance values as &amp;quot;random variables&amp;quot;, for instance, one value for object &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; follows &lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}(60,100)$&lt;/span&gt; and the same criterion value for object &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; follows &lt;span class=&quot;math-container&quot;&gt;$\mathcal{N}(40,200)$&lt;/span&gt;. Is there any vigorous way to investigate the difference between those two values? Or is this simply a statistics problem while in a MCDM setting? Like in TOPSIS, how can I construct a reasonable &amp;quot;distance&amp;quot; to calculate the final closeness coefficient?&lt;/p&gt;&#xA;&lt;p&gt;For uncertainty in MCDM, I suppose related topics include fuzzy MCDM and grey MCDM, but herein I'm faced with a probability setting.&lt;/p&gt;&#xA;" OwnerUserId="4417" LastActivityDate="2023-07-22T05:24:47.460" Title="Evaluate performance values following probability distributions in MCDM" Tags="|probability-distributions|multicriteria-decision-analysis|uncertainty|statistics|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10730" PostTypeId="1" CreationDate="2023-07-22T07:29:25.837" Score="1" ViewCount="41" Body="&lt;p&gt;I am working on the problem that I am willing to use SCIP's &lt;code&gt;conshdlr&lt;/code&gt; callback to check how the constraints might be added to the model. I am using the following manner:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;    class MyConshdlr(Conshdlr):&#xA;    &#xA;        ## fundamental callbacks ##&#xA;        def consenfolp(self, constraints, nusefulconss, solinfeasible):&#xA;        calls.add(&amp;quot;consenfolp&amp;quot;)&#xA;        for constraint in constraints:&#xA;          assert id(constraint) in ids&#xA;        return {&amp;quot;result&amp;quot;: SCIP_RESULT.FEASIBLE}&#xA;    &#xA;        def consenfops(self, constraints, nusefulconss, solinfeasible, objinfeasible):&#xA;        calls.add(&amp;quot;consenfolp&amp;quot;)&#xA;        for constraint in constraints:&#xA;          assert id(constraint) in ids&#xA;        return {&amp;quot;result&amp;quot;: SCIP_RESULT.FEASIBLE}&#xA;    &#xA;    &#xA;        def conscheck(self, constraints, solution, checkintegrality, checklprows, printreason, completely):&#xA;        calls.add(&amp;quot;conscheck&amp;quot;)&#xA;        for constraint in constraints:&#xA;          assert id(constraint) in ids&#xA;        return {&amp;quot;result&amp;quot;: SCIP_RESULT.FEASIBLE}&#xA;    &#xA;        def conslock(self, constraint, locktype, nlockspos, nlocksneg):&#xA;        calls.add(&amp;quot;conslock&amp;quot;)&#xA;        assert id(constraint) in ids&#xA;    &#xA;        ## Optinal callbacks ##&#xA;        def consactive(self, constraint):&#xA;        calls.add(&amp;quot;consactive&amp;quot;)&#xA;        assert id(constraint) in ids&#xA;    &#xA;        def consgetnvars(self, constraint):&#xA;        calls.add(&amp;quot;consgetnvars&amp;quot;)&#xA;        assert id(constraint) in ids&#xA;        return {&amp;quot;nvars&amp;quot;: 1, &amp;quot;success&amp;quot;: True}&#xA;        &#xA;        def test_conshdlr():&#xA;    &#xA;            def create_model():&#xA;                # create solver instance&#xA;                s = Model()&#xA;    &#xA;    &#xA;                # Optimization model&#xA;                ...&#xA;    &#xA;                # create conshdlr and include it to SCIP&#xA;                conshdlr = MyConshdlr()&#xA;                s.includeConshdlr()&#xA;                &#xA;                # creating constraint&#xA;                cons1 = s.createCons()&#xA;                ...&#xA;    &#xA;                # add these constraints&#xA;                s.addPyCons()&#xA;                ...&#xA;                &#xA;                return s&#xA;    &#xA;            s = create_model()&#xA;            # solve problem&#xA;            s.optimize()&#xA;    &#xA;            del s&#xA;            assert &amp;quot;consenfolp&amp;quot; in calls&#xA;            assert &amp;quot;consenfops&amp;quot; in calls&#xA;            assert &amp;quot;conscheck&amp;quot; in calls&#xA;            assert &amp;quot;conslock&amp;quot; in calls&#xA;            assert &amp;quot;consactive&amp;quot; in calls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As long as the problem is solved by the usual paradigm, the solver returns the optimal solution, but when I add the constraints by callbacks, it throws an issue as follows:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;    AssertionError                            Traceback (most recent call last)&#xA;    &amp;lt;ipython-input-7-9a59f5f7b72a&amp;gt; in &amp;lt;cell line: 154&amp;gt;()&#xA;        153 &#xA;        154 if __name__ == &amp;quot;__main__&amp;quot;:&#xA;    --&amp;gt; 155   test_conshdlr()&#xA;    &#xA;    &amp;lt;ipython-input-7-9a59f5f7b72a&amp;gt; in test_conshdlr()&#xA;        137   del s&#xA;        138 &#xA;    --&amp;gt; 139   assert &amp;quot;consenfolp&amp;quot; in calls&#xA;    &#xA;    AssertionError: &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also, I have a look at SCIP's documents where &lt;code&gt;CONSENFOLP&lt;/code&gt; is defined as:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The CONSENFOLP method is called after the price-and-cut loop was&#xA;finished and an LP solution is available. Like the CHECK call, the&#xA;ENFOLP method should return a result SCIP_FEASIBLE, if the solution&#xA;satisfies all the constraints. However, the behavior should be&#xA;different, if the solution violates some of the associated&#xA;constraints. The constraint handler may return a result&#xA;SCIP_INFEASIBLE in this situation, but this is not the best what one&#xA;can do.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Now, my questions are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What does exactly &lt;code&gt;CONSENFOLP&lt;/code&gt; mean? and how does it work?&lt;/li&gt;&#xA;&lt;li&gt;As the other callbacks seem to work fine, how is it possible to reject the solution by &lt;code&gt;CONSENFOLP&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-07-24T07:05:58.110" LastActivityDate="2023-07-24T07:05:58.110" Title="Why did the CONSENFOLP callback assertion fail when the problem has a primal feasible solution?" Tags="|mixed-integer-programming|callback|scip|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10731" PostTypeId="1" AcceptedAnswerId="10732" CreationDate="2023-07-23T01:31:29.847" Score="4" ViewCount="331" Body="&lt;p&gt;On this site, one can usually finds questions like “How to transform my expression into linear form?” The expressions usually contain &lt;code&gt;and&lt;/code&gt;, &lt;code&gt;or&lt;/code&gt;, &lt;code&gt;iff&lt;/code&gt;, and combines of them. But the answers are usually problem specific, making it hard to generalize them to other cases.&lt;/p&gt;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there any systematic material on linearization for conditional / logical expressions?&lt;/li&gt;&#xA;&lt;li&gt;It seems that Constraint Programming (CP), which I am not quite familiar with, handles conditional / logical expressions more intuitively. Is there any reference on the link between CP and Mathematical Programming.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2023-07-23T21:05:37.483" Title="Systematic references on linearizing conditional / logical expressions" Tags="|linearization|reference-request|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10732" PostTypeId="2" ParentId="10731" CreationDate="2023-07-23T01:40:01.693" Score="6" Body="&lt;p&gt;A systematic approach is to rewrite the logical proposition in &lt;a href=&quot;https://en.wikipedia.org/wiki/Conjunctive_normal_form&quot; rel=&quot;noreferrer&quot;&gt;conjunctive normal form&lt;/a&gt;, which somewhat automatically yields linear constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\bigwedge_{i \in I} \bigvee_{j \in J_i} z_{ij} \iff \left(\sum_{j \in J_i} z_{ij} \ge 1 \text{ for all $i \in I$}\right)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Several examples are &lt;a href=&quot;https://or.stackexchange.com/search?q=%22conjunctive%20normal%20form%22&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A good reference is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Raman, R. and I.E. Grossmann, &lt;em&gt;Relation Between MILP Modelling and&#xA;Logical Inference for Chemical Process Synthesis&lt;/em&gt;, &lt;strong&gt;Computers Chem.&#xA;Engng.&lt;/strong&gt; 15 (1991).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-07-23T01:40:01.693" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10733" PostTypeId="2" ParentId="10731" CreationDate="2023-07-23T12:53:22.733" Score="2" Body="&lt;p&gt;I was also interested in this.&lt;/p&gt;&#xA;&lt;p&gt;I found these &lt;a href=&quot;https://laurentlessard.com/teaching/cs524/slides/20%20-%20logic%20constraints%20and%20integer%20variables.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;lecture notes&lt;/a&gt; online by Laurent Lessard which covers many cases. RobPratt's answer is very useful. The reason for adding these lecture notes as well is because they cover some cases where I would not be confident converting to CNF (e.g. implications).&lt;/p&gt;&#xA;" OwnerUserId="11353" LastActivityDate="2023-07-23T12:53:22.733" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10737" PostTypeId="2" ParentId="10731" CreationDate="2023-07-23T21:05:37.483" Score="2" Body="&lt;p&gt;I've found the following documentation from YALMIP often useful:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://yalmip.github.io/tutorial/logicprogramming&quot; rel=&quot;nofollow noreferrer&quot;&gt;YALMIP -  Logics and integer-programming representations&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1230" LastActivityDate="2023-07-23T21:05:37.483" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10739" PostTypeId="1" AcceptedAnswerId="10810" CreationDate="2023-07-24T03:56:02.680" Score="-1" ViewCount="130" Body="&lt;p&gt;I want to maximize this function&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\left(\sum_{k=1}^{N}\cos(2\pi f_1t_k+\phi_k+\alpha\pi(k-1))\right)^2+\left(\sum_{k=1}^{N}\sin(2\pi f_1t_k+\phi_k+\alpha\pi(k-1))\right)^2,$$&lt;/span&gt; where the variables are &lt;span class=&quot;math-container&quot;&gt;$t_k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\phi_k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; is given by &lt;span class=&quot;math-container&quot;&gt;$f_1=28$&lt;/span&gt; GHz &lt;span class=&quot;math-container&quot;&gt;$=28000000000$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N=16$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I don't know what solver to use. Is this function non-convex? Is it hard to find the optimal values?&lt;/p&gt;&#xA;&lt;p&gt;I tried to use Juniper and Ipopt in the Julia language but I always got NaN solutions.&lt;/p&gt;&#xA;" OwnerUserId="3075" LastEditorUserId="3075" LastEditDate="2023-07-24T23:18:22.107" LastActivityDate="2023-12-05T02:50:49.997" Title="How to maximize sum of cosine squared plus sum of sine squarred?" Tags="|nonlinear-programming|solver|nonconvex-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10740" PostTypeId="1" AcceptedAnswerId="10746" CreationDate="2023-07-24T10:37:48.247" Score="3" ViewCount="175" Body="&lt;p&gt;I ran across this problem at work and I'm sure that we can optimize it with OR.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I have &lt;span class=&quot;math-container&quot;&gt;$n(T) = 4$&lt;/span&gt; teachers and &lt;span class=&quot;math-container&quot;&gt;$n(S) = 7$&lt;/span&gt; students that should have a weekly individual class.&lt;/p&gt;&#xA;&lt;p&gt;If a student &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; has a class with teacher &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, ideally &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; only will have a class with &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; after he had classes with all other teachers.&lt;/p&gt;&#xA;&lt;p&gt;Our &lt;strong&gt;constraint&lt;/strong&gt; is that a student cannot have classes with a teacher before he has &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; classes with other teachers. We do that so the student's schedule is not too repetitive.&lt;/p&gt;&#xA;&lt;p&gt;We know each student's schedule history:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;# Constants&#xA;teachers = [&amp;quot;t1&amp;quot;, &amp;quot;t2&amp;quot;, &amp;quot;t3&amp;quot;, &amp;quot;t4&amp;quot;]&#xA;students = [&amp;quot;s1&amp;quot;, &amp;quot;s2&amp;quot;, &amp;quot;s3&amp;quot;, &amp;quot;s4&amp;quot;, &amp;quot;s5&amp;quot;, &amp;quot;s6&amp;quot;, &amp;quot;s7&amp;quot;]&#xA;&#xA;# Past sessions&#xA;classes_data = {&#xA;    &amp;quot;s1&amp;quot;: [&amp;quot;t1&amp;quot;, &amp;quot;t4&amp;quot;, &amp;quot;t3&amp;quot;, &amp;quot;t1&amp;quot;],&#xA;    &amp;quot;s2&amp;quot;: [&amp;quot;t3&amp;quot;, &amp;quot;t2&amp;quot;, &amp;quot;t4&amp;quot;],&#xA;    &amp;quot;s4&amp;quot;: [&amp;quot;t1&amp;quot;, &amp;quot;t4&amp;quot;, &amp;quot;t3&amp;quot;, &amp;quot;t2&amp;quot;, &amp;quot;t4&amp;quot;],&#xA;    &amp;quot;s6&amp;quot;: [&amp;quot;t3&amp;quot;, &amp;quot;t4&amp;quot;, &amp;quot;t1&amp;quot;, &amp;quot;t2&amp;quot;],&#xA;    &amp;quot;s7&amp;quot;: [&amp;quot;t2&amp;quot;, &amp;quot;t1&amp;quot;, &amp;quot;t3&amp;quot;],&#xA;    &amp;quot;s5&amp;quot;: [&amp;quot;t1&amp;quot;, &amp;quot;t3&amp;quot;],&#xA;    &amp;quot;s3&amp;quot;: [&amp;quot;t4&amp;quot;],&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Our &lt;strong&gt;objective&lt;/strong&gt; is to arrange the schedule for the next week minimizing the concentration of the classes on the hands of one teacher each week.&lt;/p&gt;&#xA;&lt;p&gt;In other words, we want an even distribution of students by teachers.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I figured that it is an &lt;strong&gt;assignment problem&lt;/strong&gt; where we should &lt;strong&gt;minimize the variance&lt;/strong&gt; of the distribution of classes by teachers each week.&lt;/p&gt;&#xA;&lt;p&gt;I am new to OR and I'm using the PuLP library. Can you guys give me advice to solve that problem?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://pastebin.com/BgAcvHJ8&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is my current attempt.&lt;/p&gt;&#xA;" OwnerUserId="12177" LastActivityDate="2023-08-10T00:15:00.433" Title="Assignment Problem - Students and teachers" Tags="|optimization|binary-variable|assignment-problem|pulp|penalty-based-optimization|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10741" PostTypeId="1" AcceptedAnswerId="10742" CreationDate="2023-07-24T20:39:29.430" Score="4" ViewCount="180" Body="&lt;p&gt;I have the following objective function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{n}(1-prob_{n})(1+x_n)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is my decision variable. &lt;span class=&quot;math-container&quot;&gt;$prob_{n}$&lt;/span&gt; is a piecewise function that can look like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$prob_{n} = $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases} &#xA;      0.5, &amp;amp; x_n \leq 4 \\&#xA;      0.05, &amp;amp; x_n &amp;gt; 4&#xA;\end{cases}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The other constraints are:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{n}(1-prob_{n}) &amp;gt; k, k \in R^{+}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Seeing as &lt;span class=&quot;math-container&quot;&gt;$prob_n$&lt;/span&gt; depends on the decision variable, does this mean that the objective function is no longer linear? I 'linearized' it using Big-M notation but when I try to solve it using glpk, I get an error saying that the objective is non-linear. The only reason I can think of is the one stated above or I have misspecified something in my code.&lt;/p&gt;&#xA;&lt;p&gt;I am a little confused because I am not multiplying the decision variable (i.e. there is no &lt;span class=&quot;math-container&quot;&gt;$x^2$&lt;/span&gt; term). So I don't see what type of non-linear problem this is.&lt;/p&gt;&#xA;" OwnerUserId="11074" LastEditorUserId="11074" LastEditDate="2023-07-25T06:06:23.077" LastActivityDate="2023-07-25T06:06:23.077" Title="Non-Linear objective function due to piecewise component" Tags="|mixed-integer-programming|linear-programming|linearization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10742" PostTypeId="2" ParentId="10741" CreationDate="2023-07-24T22:37:38.717" Score="4" Body="&lt;p&gt;This can be MILP using the escape-hatch that binary constraints can capture what would otherwise be a non-linear expression:&lt;/p&gt;&#xA;&lt;p&gt;With &lt;span class=&quot;math-container&quot;&gt;$d_n \in \lbrace 0, 1 \rbrace $&lt;/span&gt; as an auxiliary binary decision variable saying whether &lt;span class=&quot;math-container&quot;&gt;$prob_n$&lt;/span&gt; is &amp;quot;low or high&amp;quot;,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{n}(1-prob_{n})(1+x_n)&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;decomposes to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_n (1 - 0.05 - (0.5 - 0.05) d_{n})(1+x_n) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ = \sum_n (0.95 - 0.45 d_{n})(1+x_n) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ = 0.95 n + \sum_n \left( 0.95 x_n - 0.45 d_n ( 1 + x_n ) \right) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ = 0.95 n + \sum_n \left( 0.95 x_n - 0.45 d_n -0.45 x'_n \right) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x'_n$&lt;/span&gt;, an auxiliary continuous (or semicontinuous) variable, is constrained to be either 0 or &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; based on the value of &lt;span class=&quot;math-container&quot;&gt;$d_n$&lt;/span&gt; with a big-&lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; constraint. In many problem constructions you can drop the first &lt;span class=&quot;math-container&quot;&gt;$0.95n$&lt;/span&gt; term as it is not a function of your variables. You will need constraints smelling roughly like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_n \le 4 + M_0 (1-d_n) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_n &amp;gt; 4 - M_1 d_n $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x'_n \le M_2 d_n $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x'_n \le x_n $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x'_n \ge x_n - M_3 (1-dn) $$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="11118" LastEditorUserId="11118" LastEditDate="2023-07-24T23:08:25.777" LastActivityDate="2023-07-24T23:08:25.777" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10743" PostTypeId="2" ParentId="10739" CreationDate="2023-07-25T02:17:05.033" Score="6" Body="&lt;p&gt;Allowing &lt;span class=&quot;math-container&quot;&gt;$\phi_k\in[-2\pi,2\pi]$&lt;/span&gt; gives you enough freedom to achieve any angle &lt;span class=&quot;math-container&quot;&gt;$\theta_k$&lt;/span&gt; as the common argument of &lt;span class=&quot;math-container&quot;&gt;$\cos$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sin$&lt;/span&gt;.  A geometric interpretation of your problem is to find a sequence of &lt;span class=&quot;math-container&quot;&gt;$16$&lt;/span&gt; unit vectors &lt;span class=&quot;math-container&quot;&gt;$(\cos(\theta_k),\sin(\theta_k))$&lt;/span&gt; whose sum is farthest from the origin.  Just take &lt;span class=&quot;math-container&quot;&gt;$\theta_k$&lt;/span&gt; constant so the steps are in the same direction, yielding objective value &lt;span class=&quot;math-container&quot;&gt;$16^2=256$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-07-25T02:17:05.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10745" PostTypeId="1" CreationDate="2023-07-25T13:11:23.790" Score="3" ViewCount="43" Body="&lt;p&gt;I am solving a Prize Collecting VRPTW. In my problem, each node represents a visit that needs to be made within a certain time window, and the &amp;quot;prize&amp;quot; for each node is the time spent at the visit. Some visits require more than one vehicle. Therefore, I have pairs of nodes that represent the same visit. I want to add a synchronization constraint such that if one node in a pair is visited, then the other node must also be visited (not the same vehicle). Currently, my model includes time windows for each visit, and I am using the AddDisjunction function to allow nodes to be dropped, with the &amp;quot;prize&amp;quot; for each node as the penalty.&lt;/p&gt;&#xA;&lt;p&gt;I tried using the following code, but this does not result in a feasible solution.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for visit in data['visit_pairs']:&#xA;if len(visit) == 2:&#xA;index1 = manager.NodeToIndex(visit[0])&#xA;index2 = manager.NodeToIndex(visit[1])&#xA;routing.solver().Add(routing.ActiveVar(index1) == routing.ActiveVar(index2))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I also tried below which gives me a feasible solution that often violates the constraint.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;routing.solver().Add(time_dimension.CumulVar(index1) == time_dimension.CumulVar(index2))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How can I modify my model to implement service synchronization, given that I also need to allow nodes to be dropped?&lt;/p&gt;&#xA;&lt;p&gt;(Also in Google or-tools-discuss)&lt;/p&gt;&#xA;" OwnerUserId="12146" LastActivityDate="2023-07-25T13:11:23.790" Title="Adding synchronisation constraint in Prize-collecting VRPTW" Tags="|optimization|solver|vehicle-routing|or-tools|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10746" PostTypeId="2" ParentId="10740" CreationDate="2023-07-25T15:34:36.660" Score="3" Body="&lt;p&gt;As in the comments: as it stands, the problem is infeasible. For student 3, they could never be given a class with any teacher, because they have never had at least two classes with any teacher. You need an escape hatch for students that have a small class history.&lt;/p&gt;&#xA;&lt;p&gt;A crude approximation to &amp;quot;variance&amp;quot; that I demonstrate below is: teachers with low load are not themselves a problem, but teachers with high above-mean load variance should have their load minimized in aggregate (this accomplishes, very roughly, the same thing).&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import numpy as np&#xA;import pandas as pd&#xA;import pulp&#xA;&#xA;teachers = [&amp;quot;t1&amp;quot;, &amp;quot;t2&amp;quot;, &amp;quot;t3&amp;quot;, &amp;quot;t4&amp;quot;]&#xA;students = [&amp;quot;s1&amp;quot;, &amp;quot;s2&amp;quot;, &amp;quot;s3&amp;quot;, &amp;quot;s4&amp;quot;, &amp;quot;s5&amp;quot;, &amp;quot;s6&amp;quot;, &amp;quot;s7&amp;quot;]&#xA;&#xA;class_history_data = {&#xA;    &amp;quot;s1&amp;quot;: [&amp;quot;t1&amp;quot;, &amp;quot;t4&amp;quot;, &amp;quot;t3&amp;quot;, &amp;quot;t1&amp;quot;],&#xA;    &amp;quot;s2&amp;quot;: [&amp;quot;t3&amp;quot;, &amp;quot;t2&amp;quot;, &amp;quot;t4&amp;quot;],&#xA;    &amp;quot;s4&amp;quot;: [&amp;quot;t1&amp;quot;, &amp;quot;t4&amp;quot;, &amp;quot;t3&amp;quot;, &amp;quot;t2&amp;quot;, &amp;quot;t4&amp;quot;],&#xA;    &amp;quot;s6&amp;quot;: [&amp;quot;t3&amp;quot;, &amp;quot;t4&amp;quot;, &amp;quot;t1&amp;quot;, &amp;quot;t2&amp;quot;],&#xA;    &amp;quot;s7&amp;quot;: [&amp;quot;t2&amp;quot;, &amp;quot;t1&amp;quot;, &amp;quot;t3&amp;quot;],&#xA;    &amp;quot;s5&amp;quot;: [&amp;quot;t1&amp;quot;, &amp;quot;t3&amp;quot;],&#xA;    &amp;quot;s3&amp;quot;: [&amp;quot;t4&amp;quot;],&#xA;}&#xA;&#xA;# 22 long, for every teacher-student history pair&#xA;class_history = pd.DataFrame(&#xA;    [&#xA;        [student, teacher]&#xA;        for student, teachers in class_history_data.items()&#xA;        for teacher in teachers&#xA;    ],&#xA;    columns=['student', 'teacher'],&#xA;)&#xA;&#xA;# 20-long, teacher-student history pair counts, multi-indexed&#xA;class_history['n'] = 1&#xA;class_history = (&#xA;    class_history.set_index(['student', 'teacher'])&#xA;    .groupby(level=['student', 'teacher'])&#xA;    .sum()&#xA;)&#xA;&#xA;# 28-long: for every possible teacher-student pair&#xA;combos = pd.DataFrame(&#xA;    index=pd.MultiIndex.from_product((students, teachers), names=('student', 'teacher'))&#xA;)&#xA;&#xA;# 28-long names by student and teacher, e.g. s1_t2&#xA;var_names = (&#xA;    combos.index.get_level_values('student')&#xA;    + '_'&#xA;    + combos.index.get_level_values('teacher')&#xA;).to_series(index=combos.index)&#xA;&#xA;combos['asn'] = var_names.apply(pulp.LpVariable, cat=pulp.LpBinary)&#xA;combos['history'] = class_history.n&#xA;combos['history'] = combos.history.fillna(value=0).astype(int)&#xA;&#xA;# for a student, concerning their current potential teacher, and all other teachers&#xA;history_pairs = np.count_nonzero(&#xA;    np.broadcast_to(&#xA;        # 7x4x1&#xA;        combos.history.unstack(level='teacher').values[..., np.newaxis],&#xA;        # to 7x4x4 repeated&#xA;        (len(students), len(teachers), len(teachers)),&#xA;    )&#xA;    # with self references (teacher to same teacher) removed&#xA;    *(1 - np.eye(len(teachers))),&#xA;    axis=1,&#xA;)&#xA;# for this student-teacher pair, the number of other teachers taught at least once&#xA;combos['history_other'] = history_pairs.ravel()&#xA;&#xA;# for each student, total number of classes so far&#xA;combos['history_total'] = combos.history.groupby(level='student').transform('sum')&#xA;&#xA;# A student cannot have classes with a teacher before they have at least 2 classes with other teachers&#xA;# OR IF they have not yet taken classes with at least two teachers&#xA;# Express this by row elimination and not an LP constraint&#xA;# Reduces this from 28 to 26 rows.&#xA;combos = combos[&#xA;    (combos.history_other &amp;gt;= 2) |&#xA;    (combos.history_total &amp;lt; 2)&#xA;]&#xA;&#xA;# 4x7, with zeros where there can never be a teacher-student assignment&#xA;assignments_by_teacher = combos.asn.unstack(level='student').fillna(0)&#xA;&#xA;# 4-long: deviation above mean load per teacher (deviation below mean load is ignored).&#xA;mean_load = len(students) / len(teachers)&#xA;load_dev = (&#xA;    (&#xA;        'load_dev_' +&#xA;        assignments_by_teacher.index&#xA;        .to_series(index=assignments_by_teacher.index)&#xA;    )&#xA;    .apply(pulp.LpVariable, cat=pulp.LpContinuous, lowBound=0)&#xA;)&#xA;&#xA;# minimize total deviation above mean load&#xA;prob = pulp.LpProblem(name='class_distribution', sense=pulp.LpMinimize)&#xA;prob.objective = load_dev.sum()&#xA;&#xA;# Every student must have one class&#xA;for student, group in combos.asn.groupby(level='student'):&#xA;    prob.addConstraint(name=student + '_class_count', constraint=group.sum() == 1)&#xA;&#xA;# The deviation above mean load has a lower bound of sum(load) - mean(load)&#xA;for teacher, load in assignments_by_teacher.sum(axis=1).items():&#xA;    prob.addConstraint(&#xA;        name='dev_' + teacher,&#xA;        constraint=load_dev[teacher] &amp;gt;= load - mean_load,&#xA;    )&#xA;&#xA;print(prob)&#xA;prob.solve()&#xA;assert prob.status == pulp.LpStatusOptimal&#xA;&#xA;print('Student-teacher assignments for this week:')&#xA;combos['asn'] = combos.asn.apply(pulp.LpVariable.value).astype(int)&#xA;print(combos.asn.unstack(level='teacher', fill_value=0), end='\n\n')&#xA;&#xA;print('Teacher loads:')&#xA;loads = pd.DataFrame({&#xA;    'load': assignments_by_teacher.sum(axis=1).apply(pulp.LpAffineExpression.value),&#xA;    'deviation above mean': load_dev.apply(pulp.LpVariable.value),&#xA;})&#xA;print(loads)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;class_distribution:&#xA;MINIMIZE&#xA;1*load_dev_t1 + 1*load_dev_t2 + 1*load_dev_t3 + 1*load_dev_t4 + 0&#xA;SUBJECT TO&#xA;s1_class_count: s1_t1 + s1_t2 + s1_t3 + s1_t4 = 1&#xA;&#xA;s2_class_count: s2_t1 + s2_t2 + s2_t3 + s2_t4 = 1&#xA;&#xA;s3_class_count: s3_t1 + s3_t2 + s3_t3 + s3_t4 = 1&#xA;&#xA;s4_class_count: s4_t1 + s4_t2 + s4_t3 + s4_t4 = 1&#xA;&#xA;s5_class_count: s5_t2 + s5_t4 = 1&#xA;&#xA;s6_class_count: s6_t1 + s6_t2 + s6_t3 + s6_t4 = 1&#xA;&#xA;s7_class_count: s7_t1 + s7_t2 + s7_t3 + s7_t4 = 1&#xA;&#xA;dev_t1: load_dev_t1 - s1_t1 - s2_t1 - s3_t1 - s4_t1 - s6_t1 - s7_t1 &amp;gt;= -1.75&#xA;&#xA;dev_t2: load_dev_t2 - s1_t2 - s2_t2 - s3_t2 - s4_t2 - s5_t2 - s6_t2 - s7_t2&#xA; &amp;gt;= -1.75&#xA;&#xA;dev_t3: load_dev_t3 - s1_t3 - s2_t3 - s3_t3 - s4_t3 - s6_t3 - s7_t3 &amp;gt;= -1.75&#xA;&#xA;dev_t4: load_dev_t4 - s1_t4 - s2_t4 - s3_t4 - s4_t4 - s5_t4 - s6_t4 - s7_t4&#xA; &amp;gt;= -1.75&#xA;&#xA;VARIABLES&#xA;load_dev_t1 Continuous&#xA;load_dev_t2 Continuous&#xA;load_dev_t3 Continuous&#xA;load_dev_t4 Continuous&#xA;0 &amp;lt;= s1_t1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s1_t2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s1_t3 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s1_t4 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s2_t1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s2_t2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s2_t3 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s2_t4 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s3_t1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s3_t2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s3_t3 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s3_t4 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s4_t1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s4_t2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s4_t3 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s4_t4 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s5_t2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s5_t4 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s6_t1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s6_t2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s6_t3 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s6_t4 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s7_t1 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s7_t2 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s7_t3 &amp;lt;= 1 Integer&#xA;0 &amp;lt;= s7_t4 &amp;lt;= 1 Integer&#xA;&#xA;Welcome to the CBC MILP Solver &#xA;Version: 2.10.3 &#xA;Build Date: Dec 15 2019 &#xA;&#xA;At line 2 NAME          MODEL&#xA;At line 3 ROWS&#xA;At line 16 COLUMNS&#xA;At line 129 RHS&#xA;At line 141 BOUNDS&#xA;At line 168 ENDATA&#xA;Problem MODEL has 11 rows, 30 columns and 56 elements&#xA;&#xA;...&#xA;&#xA;Result - Optimal solution found&#xA;&#xA;Objective value:                0.75000000&#xA;Enumerated nodes:               0&#xA;Total iterations:               0&#xA;Time (CPU seconds):             0.02&#xA;Time (Wallclock seconds):       0.02&#xA;&#xA;Option for printingOptions changed from normal to all&#xA;Total time (CPU seconds):       0.02   (Wallclock seconds):       0.02&#xA;&#xA;Student-teacher assignments for this week:&#xA;teacher  t1  t2  t3  t4&#xA;student                &#xA;s1        1   0   0   0&#xA;s2        0   1   0   0&#xA;s3        1   0   0   0&#xA;s4        0   0   1   0&#xA;s5        0   1   0   0&#xA;s6        0   0   1   0&#xA;s7        0   0   0   1&#xA;&#xA;Teacher loads:&#xA;         load  deviation above mean&#xA;teacher                            &#xA;t1        2.0                  0.25&#xA;t2        2.0                  0.25&#xA;t3        2.0                  0.25&#xA;t4        1.0                  0.00&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;History penalty instead of history constraint&lt;/h2&gt;&#xA;&lt;p&gt;This does better, and is also simpler:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import pandas as pd&#xA;import pulp&#xA;&#xA;teachers = pd.Index(name='teacher', data=(&amp;quot;t1&amp;quot;, &amp;quot;t2&amp;quot;, &amp;quot;t3&amp;quot;, &amp;quot;t4&amp;quot;))&#xA;students = pd.Index(name='student', data=(&amp;quot;s1&amp;quot;, &amp;quot;s2&amp;quot;, &amp;quot;s3&amp;quot;, &amp;quot;s4&amp;quot;, &amp;quot;s5&amp;quot;, &amp;quot;s6&amp;quot;, &amp;quot;s7&amp;quot;))&#xA;&#xA;class_history_data = {&#xA;    &amp;quot;s1&amp;quot;: [&amp;quot;t1&amp;quot;, &amp;quot;t4&amp;quot;, &amp;quot;t3&amp;quot;, &amp;quot;t1&amp;quot;],&#xA;    &amp;quot;s2&amp;quot;: [&amp;quot;t3&amp;quot;, &amp;quot;t2&amp;quot;, &amp;quot;t4&amp;quot;],&#xA;    &amp;quot;s3&amp;quot;: [&amp;quot;t4&amp;quot;],&#xA;    &amp;quot;s4&amp;quot;: [&amp;quot;t1&amp;quot;, &amp;quot;t4&amp;quot;, &amp;quot;t3&amp;quot;, &amp;quot;t2&amp;quot;, &amp;quot;t4&amp;quot;],&#xA;    &amp;quot;s5&amp;quot;: [&amp;quot;t1&amp;quot;, &amp;quot;t3&amp;quot;],&#xA;    &amp;quot;s6&amp;quot;: [&amp;quot;t3&amp;quot;, &amp;quot;t4&amp;quot;, &amp;quot;t1&amp;quot;, &amp;quot;t2&amp;quot;],&#xA;    &amp;quot;s7&amp;quot;: [&amp;quot;t2&amp;quot;, &amp;quot;t1&amp;quot;, &amp;quot;t3&amp;quot;],&#xA;}&#xA;&#xA;# 22 long, for every teacher-student history pair&#xA;class_history = pd.DataFrame(&#xA;    [&#xA;        [student, teacher]&#xA;        for student, teachers in class_history_data.items()&#xA;        for teacher in teachers&#xA;    ],&#xA;    columns=['student', 'teacher'],&#xA;)&#xA;&#xA;# 20-long, teacher-student history pair counts, multi-indexed&#xA;class_history['n'] = 1&#xA;class_history = (&#xA;    class_history.set_index(['student', 'teacher'])&#xA;    .groupby(level=['student', 'teacher'])&#xA;    .sum()&#xA;)&#xA;&#xA;# 28-long: for every possible teacher-student pair&#xA;combos = pd.DataFrame(&#xA;    index=pd.MultiIndex.from_product((students, teachers))&#xA;)&#xA;&#xA;# 28-long names by student and teacher, e.g. s1_t2&#xA;var_names = (&#xA;    combos.index.get_level_values('student')&#xA;    + '_'&#xA;    + combos.index.get_level_values('teacher')&#xA;).to_series(index=combos.index)&#xA;&#xA;combos['asn'] = var_names.apply(pulp.LpVariable, cat=pulp.LpBinary)&#xA;combos['history'] = class_history.n&#xA;combos['history'] = combos.history.fillna(value=0).astype(int)&#xA;&#xA;# 4-long: deviation above mean load per teacher (deviation below mean load is ignored).&#xA;mean_load = len(students) / len(teachers)&#xA;load_dev = (&#xA;    (&#xA;        'load_dev_' +&#xA;        teachers.astype(str)&#xA;        .to_series(index=teachers)&#xA;    )&#xA;    .apply(pulp.LpVariable, cat=pulp.LpContinuous, lowBound=0)&#xA;)&#xA;&#xA;# minimize total deviation above mean load, and minimize prior history&#xA;load_weight = 0.75&#xA;hist_weight = 1.00&#xA;prob = pulp.LpProblem(name='class_distribution', sense=pulp.LpMinimize)&#xA;prob.objective = load_weight*load_dev.sum() + hist_weight*combos.asn.dot(combos.history)&#xA;&#xA;# Every student must have one class&#xA;for student, group in combos.asn.groupby(level='student'):&#xA;    prob.addConstraint(name=student + '_class_count', constraint=group.sum() == 1)&#xA;&#xA;# The deviation above mean load has a lower bound of sum(load) - mean(load)&#xA;for teacher, load in combos.asn.groupby('teacher').sum().items():&#xA;    prob.addConstraint(&#xA;        name='dev_' + teacher,&#xA;        constraint=load_dev.loc[teacher] &amp;gt;= load - mean_load,&#xA;    )&#xA;&#xA;print(prob)&#xA;prob.solve()&#xA;assert prob.status == pulp.LpStatusOptimal&#xA;&#xA;print('Student-teacher assignments for this week:')&#xA;combos['asn'] = combos.asn.apply(pulp.LpVariable.value).astype(int)&#xA;print(combos.asn.unstack(level='teacher', fill_value=0), end='\n\n')&#xA;&#xA;print('Teacher loads:')&#xA;loads = pd.DataFrame({&#xA;    'load': combos.asn.groupby('teacher').sum(),&#xA;    'deviation above mean': load_dev.apply(pulp.LpVariable.value),&#xA;})&#xA;print(loads)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Student-teacher assignments for this week:&#xA;teacher  t1  t2  t3  t4&#xA;student                &#xA;s1        0   1   0   0&#xA;s2        1   0   0   0&#xA;s3        0   0   1   0&#xA;s4        1   0   0   0&#xA;s5        0   0   0   1&#xA;s6        0   1   0   0&#xA;s7        0   0   0   1&#xA;&#xA;Teacher loads:&#xA;         load  deviation above mean&#xA;teacher                            &#xA;t1          2                  0.25&#xA;t2          2                  0.25&#xA;t3          1                  0.00&#xA;t4          2                  0.25&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11118" LastEditorUserId="11118" LastEditDate="2023-08-10T00:15:00.433" LastActivityDate="2023-08-10T00:15:00.433" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10747" PostTypeId="1" CreationDate="2023-07-25T18:37:29.447" Score="3" ViewCount="127" Body="&lt;p&gt;I have a coefficient matrix for an MIP with a less than ideal range of magnitudes. For example, consider this constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{ij} {\rm cost}_{ij} \cdot x_{ij} \leq \rm Budget$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{ij} \in \{0, 1\} \; \forall i,j$$&lt;/span&gt;&#xA;where the cost of a specific &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; pair may be &lt;span class=&quot;math-container&quot;&gt;$10^{-2}$&lt;/span&gt; and the RHS might be &lt;span class=&quot;math-container&quot;&gt;$10^{10}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I remember either hearing or reading that masking this scaling through another variable(s) doesn't actually help. Is that correct? For example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$10^{-3} \cdot \sum_{i} x_{ij} = {\rm scaledcount}_{j} \; \forall j $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j} {\rm cost}_{j} \cdot {\rm scaledcount}_{j} \leq {\rm Budget}^*$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{ij} \in \{0, 1\} \; \forall i,j$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$${\rm count}_{j} \in \mathbb{R} \; \forall j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where Budget can now be scaled back by &lt;span class=&quot;math-container&quot;&gt;$10^{-3}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is the assumption that this approach doesn't strengthen the model scaling correct?&lt;/p&gt;&#xA;" OwnerUserId="815" LastEditorUserId="123" LastEditDate="2023-08-09T08:05:09.967" LastActivityDate="2023-09-05T22:59:56.623" Title="Coefficient Scaling for MIP" Tags="|mixed-integer-programming|modeling|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10748" PostTypeId="1" CreationDate="2023-07-25T19:02:52.610" Score="2" ViewCount="81" Body="&lt;p&gt;I am interested in the value function of a quadratic program of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;v(y)=\min_x \frac{1}{2} x^\top Q(y) x,&#xA;$$&lt;/span&gt;&#xA;subject to a linear equality constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;E(y)x=d(y),&#xA;$$&lt;/span&gt;&#xA;and a linear inequality constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;A x \preceq b,&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\preceq$&lt;/span&gt; denotes component-wise inequalities.&lt;/p&gt;&#xA;&lt;p&gt;Notice that &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; all depend on a parameter &lt;span class=&quot;math-container&quot;&gt;$y\in{\Bbb R}^m_{\geq 0}$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$Q(y)$&lt;/span&gt; is positive definite for all &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. Importantly, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; do not depend on &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For the particular problem I am interested in, I know &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; but they are a bit complicated and I'm hoping that their specific structure is not important here.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I would like to show that &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is convex.&lt;/strong&gt; Given my specific problem, I know that &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is convex if we remove the inequality constraint &lt;span class=&quot;math-container&quot;&gt;$A x \preceq b$&lt;/span&gt;. In that case the problem is simple and I can solve for &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My question is: if &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is convex without the inequality constraint, does &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; remain convex when we add the inequality constraint? Recall that this inequality constraint does not depend on &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If that helps, in my specific problem &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; are homogenous in the sense that &lt;span class=&quot;math-container&quot;&gt;$Q(\lambda y)=\lambda Q(y)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$E(\lambda y)=\lambda E(y)$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$\lambda\in{\Bbb R}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$d(y)=y-c$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c\in{\Bbb R}^m_{\geq 0}$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is also linear in &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;I tried to compute &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; using the dual approach but this seems intractable.&lt;/li&gt;&#xA;&lt;li&gt;I have looked at a few special cases and cannot find a counterexample.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Value function without inequality constraints&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Without the inequality constraint, the &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;solution to this problem&lt;/a&gt; is given by&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left[\begin{array}{cc}&#xA;Q &amp;amp; E'\\&#xA;E &amp;amp; 0&#xA;\end{array}\right]\left[\begin{array}{c}&#xA;x\\&#xA;\lambda&#xA;\end{array}\right]=\left[\begin{array}{c}&#xA;0\\&#xA;d&#xA;\end{array}\right]&#xA;$$&lt;/span&gt;&#xA;which can be &lt;a href=&quot;https://en.wikipedia.org/wiki/Block_matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;inverted&lt;/a&gt; as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left[\begin{array}{cc}&#xA;Q &amp;amp; E'\\&#xA;E &amp;amp; 0&#xA;\end{array}\right]^{-1}=\left[\begin{array}{cc}&#xA;Q^{-1}-Q^{-1}E'\left(EQ^{-1}E'\right)^{-1}EQ^{-1} &amp;amp; Q^{-1}E'\left(EQ^{-1}E'\right)^{-1}\\&#xA;\left(EQ^{-1}E'\right)^{-1}EQ^{-1} &amp;amp; -\left(EQ^{-1}E'\right)^{-1}&#xA;\end{array}\right]&#xA;$$&lt;/span&gt;&#xA;Since &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is positive definite it is invertible. Suppose that &lt;span class=&quot;math-container&quot;&gt;$EQ^{-1}E'$&lt;/span&gt; is also invertible. Then&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x=Q^{-1}E'\left(EQ^{-1}E'\right)^{-1}d&#xA;$$&lt;/span&gt;&#xA;and the objective function at the optimum is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;v(y)=d'\left(\left(EQ^{-1}E'\right)^{-1}\right)d&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My particular problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In my particular problem &lt;span class=&quot;math-container&quot;&gt;$x\in{\Bbb R}_{\geq 0}^{n^2}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y\in{\Bbb R}_{\geq 0}^{n}$&lt;/span&gt;. The function &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; are&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;E(y)=y'\otimes I_n,&#xA;$$&lt;/span&gt;&#xA;and,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;d(y)=y-c,&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$n\times 1$&lt;/span&gt; column vector such that &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;c_i&amp;lt;1$&lt;/span&gt;. The matrix &lt;span class=&quot;math-container&quot;&gt;$Q(y)$&lt;/span&gt; is given by&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;Q=\left[\begin{array}{ccc}&#xA;y_{1}F_{1} &amp;amp;  &amp;amp; 0\\&#xA; &amp;amp; \ddots\\&#xA;0 &amp;amp;  &amp;amp; y_{n}F_{n}&#xA;\end{array}\right]&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$F_i$&lt;/span&gt; is an &lt;span class=&quot;math-container&quot;&gt;$n\times n$&lt;/span&gt; positive definite matrix.&lt;/p&gt;&#xA;&lt;p&gt;Doing the matrix algebra, and using the expression for &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; above, we find&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;v(y)=\left(y-c\right)'\left(\sum_{i}y_{i}F_{i}^{-1}\right)^{-1}\left(y-c\right)&#xA;$$&lt;/span&gt;&#xA;A proof of convexity for this function can be found &lt;a href=&quot;https://math.stackexchange.com/questions/4739698/convexity-of-bf-x-mapsto-bf-x-bf-a-top-left-sum-i-x-i-bf-a&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12190" LastEditorUserId="12190" LastEditDate="2023-07-26T15:37:42.843" LastActivityDate="2023-07-26T15:37:42.843" Title="Does the value function of a quadratic program stay convex when adding constraints?" Tags="|optimization|convex-optimization|quadratic-programming|sensitivity-analysis|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="10749" PostTypeId="1" AcceptedAnswerId="10750" CreationDate="2023-07-26T10:09:58.957" Score="2" ViewCount="99" Body="&lt;p&gt;I am currently optimizing a hydrogen production chain.&#xA;I am optimizing the production regime, and the size of the required wind, solar and the electrolyser.&lt;/p&gt;&#xA;&lt;p&gt;For every hour of the year, the production level of the electrolyser should be lower than the sum of the production of wind and solar and higher than 10% of the electrolyser capacity, if the sum of wind and solar is below 10% of the electrolyser capacity, I want the production level to be 0. I have the production pattern for a 1 MW unit for both wind and solar, noted by &lt;span class=&quot;math-container&quot;&gt;$W_t, S_t$&lt;/span&gt; for every timestep t. The sizes of the electrolyser, solar and wind are noted as &lt;span class=&quot;math-container&quot;&gt;$X_e, X_s, X_w$&lt;/span&gt;. The total energy required in a year is &lt;span class=&quot;math-container&quot;&gt;$E_r$&lt;/span&gt;. The production level for every hour is &lt;span class=&quot;math-container&quot;&gt;$p_t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now I know that in non-linear programming, using a variable &lt;span class=&quot;math-container&quot;&gt;$u_t$&lt;/span&gt; can be used to 'turn off' the electrolyser, but you would have to multiply it by the size of the electrolyser &lt;span class=&quot;math-container&quot;&gt;$X_e$&lt;/span&gt;, making the constraint non-linear. I have read somethings about the big-M method, but I have difficulties formulating this exact problem into that method. Could somebody please help me?&lt;/p&gt;&#xA;&lt;p&gt;Below, I have tried to express in symbols what I mean.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum p_t = E_r$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$W_t X_w+S_t X_s - p_t \ge 0$&lt;/span&gt; for all t&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_t -X_e \le 0$&lt;/span&gt; for all t&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;if&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$W_t X_w+S_t X_s \ge 0.1 X_e$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_t -0.1 X_e \ge 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;elseif&lt;/strong&gt; &lt;span class=&quot;math-container&quot;&gt;$W_t X_w+S_t X_s &amp;lt; 0.1 X_e$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$p_t = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am working with the PuLP package in Python.&lt;/p&gt;&#xA;" OwnerUserId="12187" LastEditorUserId="491" LastEditDate="2023-08-03T03:03:09.987" LastActivityDate="2023-08-03T03:03:09.987" Title="How to linearize the multiplication by a binary decision variable?" Tags="|optimization|linear-programming|python|linearization|pulp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10750" PostTypeId="2" ParentId="10749" CreationDate="2023-07-26T12:02:40.017" Score="2" Body="&lt;p&gt;I assumed that your variables are &lt;span class=&quot;math-container&quot;&gt;$X_{w}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$X_{s}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$X_{e}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$p_{t}$&lt;/span&gt;. Then as @RobPratt suggested, we can use two separate disjuncts.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ W_t X_w+S_t X_s - 0.1 X_e \geq m(1-z_t) \quad (1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ p_t -0.1 X_e \geq m(1-z_t) \quad (2)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;......&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ W_t X_w+S_t X_s - 0.1 X_e \leq M z_t \quad (3)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ p_t \leq M z_t \quad (4)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ p_t \geq m z_t \quad (5)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the auxiliary binary variable &lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt; is equal to one, the first two constraints, (1,2), are activated, and if &lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt; is equal to zero, the second third constraints, (3,4,5), would be activated.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-07-26T12:57:50.757" LastActivityDate="2023-07-26T12:57:50.757" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="10751" PostTypeId="1" CreationDate="2023-07-26T20:59:56.353" Score="1" ViewCount="51" Body="&lt;p&gt;I'm attempting to implement the dual face algorithm from Pan's book chapter 22 (&lt;a href=&quot;https://link.springer.com/book/10.1007/978-981-19-0147-8&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/book/10.1007/978-981-19-0147-8&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;The part in question is pasted here:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/0k9m7l.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0k9m7l.png&quot; alt=&quot;Alg 22.5.1&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can you please explain what these rotations are supposed to accomplish? I recognize that it's trying to update L after deleting a column from &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, but I don't understand what is necessary to keep &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; bound to &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; in that scenario. Why are there two commas after the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;? I have &lt;span class=&quot;math-container&quot;&gt;$L, k, p$&lt;/span&gt;; I need &lt;span class=&quot;math-container&quot;&gt;$\hat{L}$&lt;/span&gt;. How do I determine &lt;span class=&quot;math-container&quot;&gt;$\hat{L}$&lt;/span&gt; using Numpy/Scipy?&lt;/p&gt;&#xA;" OwnerUserId="7428" LastEditorUserId="7428" LastEditDate="2023-07-26T21:59:49.067" LastActivityDate="2023-07-26T21:59:49.067" Title="explain Givens rotation chain for maintaining Cholesky factorization" Tags="|python|simplex|linear-algebra|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10752" PostTypeId="1" AcceptedAnswerId="10753" CreationDate="2023-07-27T03:33:06.703" Score="3" ViewCount="223" Body="&lt;p&gt;Say the edges of a 4 nodes graph are &lt;code&gt;0 1&lt;/code&gt;, &lt;code&gt;1 2&lt;/code&gt; and &lt;code&gt;1 3&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The solution to the colouring problem can be &lt;code&gt;1,0,1,1&lt;/code&gt; or &lt;code&gt;0,1,0,0&lt;/code&gt;, both are essentially the same. How I can model redundant constraints for this?&lt;/p&gt;&#xA;" OwnerUserId="10566" LastEditorUserId="10566" LastEditDate="2023-07-27T03:47:56.427" LastActivityDate="2023-07-27T06:19:51.077" Title="Graph coloring problem redundant constraints" Tags="|mixed-integer-programming|linear-programming|integer-programming|graphs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10753" PostTypeId="2" ParentId="10752" CreationDate="2023-07-27T06:19:51.077" Score="6" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Search for symmetry breaking constraints. Here's a small but common example: &lt;a href=&quot;https://math.stackexchange.com/questions/4415333/assymetric-graph-coloring-formulation&quot;&gt;https://math.stackexchange.com/questions/4415333/assymetric-graph-coloring-formulation&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fix some variables. E.g. Greedily find the largest clique in your graph, and hard code the colors of the vertices in this clique.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="49" LastActivityDate="2023-07-27T06:19:51.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10754" PostTypeId="1" CreationDate="2023-07-27T14:59:35.213" Score="1" ViewCount="25" Body="&lt;p&gt;I have a cost function of the form &lt;span class=&quot;math-container&quot;&gt;$f(x) - \log(x)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is some smooth function mapping &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n_+\to\mathbb{R}$&lt;/span&gt;and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is restricted to be nonnegative by the problem constraints (and for course the logarithm term means it has to be strictly positive). I'm currently minimizing this function using Proximal gradient descent, treating &lt;span class=&quot;math-container&quot;&gt;$-\log(x)$&lt;/span&gt; as the nonsmooth term with known proximal operator.&lt;/p&gt;&#xA;&lt;p&gt;I wanted to try Nesterov acceleration to see if it could help out. Just to develop notation, I'll write down the basic iteration I'm using, which is modeled on the FISTA method (which has an unrestricted variable and uses the prox associated with the aboslute value function instead):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y^t = \textrm{prox}^{-\log}_{\eta}(x^{t-1}-\eta\nabla f(x^{t-1})) \\&#xA;x^t = (1-\gamma^t)y^t + \gamma y^{t-1}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\eta$&lt;/span&gt; is a step size and &lt;span class=&quot;math-container&quot;&gt;$\gamma^t$&lt;/span&gt; is the Nesterov combination coefficient computed in the usual manner.&lt;/p&gt;&#xA;&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$y^t$&lt;/span&gt; is coming out of a proximal operator which &amp;quot;knows&amp;quot; about the &lt;span class=&quot;math-container&quot;&gt;$\log$&lt;/span&gt; term, it is always strictly positive. However, I've found that the variable &lt;span class=&quot;math-container&quot;&gt;$x^t$&lt;/span&gt; can be negative despite this (if &lt;span class=&quot;math-container&quot;&gt;$y^{t-1}$&lt;/span&gt; is much smaller than &lt;span class=&quot;math-container&quot;&gt;$y^t$&lt;/span&gt;). It is not possible to subsequently compute &lt;span class=&quot;math-container&quot;&gt;$\nabla f(x^t)$&lt;/span&gt;, since &lt;span class=&quot;math-container&quot;&gt;$x^t$&lt;/span&gt; is outside of the domain of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Are there modified procedures that can allow Nesterov acceleration to work in my case?&lt;/p&gt;&#xA;" OwnerUserId="7713" LastEditorUserId="7713" LastEditDate="2023-07-27T15:16:31.713" LastActivityDate="2023-07-27T15:16:31.713" Title="Nesterov Acceleration in Proximal Iteration with Strictly Positive Variable?" Tags="|constraint|convex-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10755" PostTypeId="1" CreationDate="2023-07-27T17:00:44.723" Score="3" ViewCount="93" Body="&lt;p&gt;For some &lt;span class=&quot;math-container&quot;&gt;$c &amp;gt;0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z \in \mathbb{R}^n$&lt;/span&gt;, the optimal value of&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\begin{array}{cl}&#xA;\sup_{x \in \mathbb{R}^n}&amp;amp; z^\top x&#xA;\\\text{s.t.}&amp;amp; \lVert x \rVert \leq c&#xA;\end{array}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is equal to the dual norm &lt;span class=&quot;math-container&quot;&gt;$c \cdot \lVert z \rVert_{*}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have a modification to this problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\begin{array}{cl}&#xA;\sup_{x \in \mathbb{R}^n}&amp;amp; z^\top x&#xA;\\\text{s.t.}&amp;amp; \lVert x \rVert \leq c \\&#xA;&amp;amp; \lVert x - t \rVert \leq c'&#xA;\end{array}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for some constant vector &lt;span class=&quot;math-container&quot;&gt;$t \in \mathbb{R}^n$&lt;/span&gt; and a scalar &lt;span class=&quot;math-container&quot;&gt;$c' &amp;gt; 0$&lt;/span&gt;. I was wondering if this can be represented via dual norms as well. Is there a way I can get rid of the &lt;span class=&quot;math-container&quot;&gt;$\sup$&lt;/span&gt;, or does this problem not have a closed-form representation?&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2023-08-09T16:25:30.413" Title="Dual norm definition: adding new constraints" Tags="|convex-optimization|duality|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10756" PostTypeId="1" CreationDate="2023-07-27T17:34:30.907" Score="4" ViewCount="70" Body="&lt;p&gt;I'm currently struggling with a MIP. Have to model a truck delivering packages for customers in the set &lt;span class=&quot;math-container&quot;&gt;$C = \{1,2,3,4,5\}$&lt;/span&gt;. The travel time from location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; I've defined as &lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt;. The truck must start from location 0 and can travel to any customer in any order, provided all customers are visited. I've set the variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; to be 1 if the truck travel from location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and 0 otherwise.&lt;/p&gt;&#xA;&lt;p&gt;I'm struggling with this part of the problem. Each customer has a time &lt;span class=&quot;math-container&quot;&gt;$E_i$&lt;/span&gt; as the earliest allowed time of arrival for customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L_i$&lt;/span&gt; as the latest possible time of arrival. If the truck arrives early it's charged 3 dollars /min early and 2 dollars/min late.&lt;/p&gt;&#xA;&lt;p&gt;I've had trouble adding that into my objective function and as a constraint. So far I've attempted to use the variable &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; to represent time of arrival to location &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Unfortunately the issue here is I am unable to find a way to determine the order of the deliveries to sum the time.&lt;/p&gt;&#xA;&lt;p&gt;Any insight would be much appreciated, thank you!&lt;/p&gt;&#xA;" OwnerUserId="12201" LastEditorUserId="136" LastEditDate="2023-07-27T21:02:29.993" LastActivityDate="2023-07-27T22:41:47.630" Title="Late and Early Costs per minute for a delivery problem" Tags="|mixed-integer-programming|vehicle-routing|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10757" PostTypeId="2" ParentId="10756" CreationDate="2023-07-27T17:57:31.580" Score="1" Body="&lt;p&gt;The problem you are describing is a version of what is known as a Vehicle Routing Problem with Time Windows (VRPTW). If you enter VRPTW in the search box for this site, you'll find a gaggle of problems about them, and of course you could google the phrase (or acronym). Among the hits you are likely to find some model formulations.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-07-27T17:57:31.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10759" PostTypeId="2" ParentId="10756" CreationDate="2023-07-27T22:41:47.630" Score="3" Body="&lt;p&gt;The constraints you need to set the value of variables &lt;span class=&quot;math-container&quot;&gt;$A_i$&lt;/span&gt; correctly are a generalisation of the famous &lt;a href=&quot;https://how-to.aimms.com/Articles/332/332-Miller-Tucker-Zemlin-formulation.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Miller-Tucker-Zemlin&lt;/a&gt; (MTZ) constraints.&lt;/p&gt;&#xA;&lt;p&gt;For example, you can use &lt;span class=&quot;math-container&quot;&gt;$A_j \geq A_i + t_{ij} - M(1 - x_{ij})$&lt;/span&gt;, for a sufficiently large constant &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;.&#xA;You have one constraint for each arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j \neq 0$&lt;/span&gt;.&#xA;Now you must compute eventual early and late arrivals.&lt;/p&gt;&#xA;&lt;p&gt;Introduce two variables for each customer. Variable &lt;span class=&quot;math-container&quot;&gt;$\epsilon_i \geq 0$&lt;/span&gt; will tell you how early you arrived at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; if you arrived early; otherwise, it will be 0. Variable &lt;span class=&quot;math-container&quot;&gt;$\lambda_i \geq 0$&lt;/span&gt; will tell you how late you arrived at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; if you arrived late; otherwise, it will be 0.&lt;/p&gt;&#xA;&lt;p&gt;In other words, you would like these variables to hold values&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\epsilon_i = \max \{ E_i - A_i, 0 \}\mathrm{,}\quad \lambda_i = \max \{ A_i - L_i, 0 \}\mathrm{.}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The problem is that the &lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; function is not linear, so you must devise a linear constraint to set the values of &lt;span class=&quot;math-container&quot;&gt;$\epsilon_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda_i$&lt;/span&gt;.&#xA;Because both &lt;span class=&quot;math-container&quot;&gt;$\epsilon_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda_i$&lt;/span&gt; are non-negative by definition and because they are penalised in the objective function, you can use&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\epsilon_i \geq E_i - A_i\mathrm{,}\quad \lambda_i \geq A_i - L_i\mathrm{.}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The following figures show the difference that adding the penalties makes. The first figure shows the optimal solution without early/late penalties; the second figure is with the penalties. The blue point is the depot, and the orange points are the customers. Values above the customers are the &lt;span class=&quot;math-container&quot;&gt;$[E_i, L_i]$&lt;/span&gt; time windows; values below the customers are arrival times (in red if early or late). Values on the edges are traversing times.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lttkg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lttkg.png&quot; alt=&quot;Solution without penalties.&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/hpLVd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hpLVd.png&quot; alt=&quot;Solution with penalties.&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2023-07-27T22:41:47.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10762" PostTypeId="1" AcceptedAnswerId="10764" CreationDate="2023-07-28T07:56:04.513" Score="6" ViewCount="880" Body="&lt;p&gt;I am looking for an idea on how to formulate the following problem as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Integer_programming#Variants&quot; rel=&quot;nofollow noreferrer&quot;&gt;MILP&lt;/a&gt;.&#xA;Given a connected graph, find the shortest path route starting from a node (not given) and visit all other nodes. All nodes should be visited at least once.&lt;/p&gt;&#xA;&lt;h3&gt;Some example&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/by7kE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/by7kE.jpg&quot; alt=&quot;Enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Travelling_salesman_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;TSP&lt;/a&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Travelling_salesman_problem#Integer_linear_programming_formulations&quot; rel=&quot;nofollow noreferrer&quot;&gt;MTZ&lt;/a&gt; formulation can not be used since we might need to revisit a node.&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="36" LastEditDate="2023-07-30T00:07:49.053" LastActivityDate="2023-07-30T00:07:49.053" Title="How can I find the shortest path visiting all nodes in a connected graph as MILP?" Tags="|optimization|mixed-integer-programming|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10763" PostTypeId="2" ParentId="10762" CreationDate="2023-07-28T12:52:24.787" Score="8" Body="&lt;p&gt;You can solve this problem by transforming to a TSP in a complete graph where the edge weights are the shortest-path distances in the original graph.  So it is three steps:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Compute all-pairs shortest paths in the original graph.&lt;/li&gt;&#xA;&lt;li&gt;Solve a TSP in the complete graph with these shortest-path distances as the new edge weights.&lt;/li&gt;&#xA;&lt;li&gt;Expand the TSP solution back to the original graph by replacing each edge in the TSP tour with its corresponding shortest path.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;This same approach generalizes to visiting a specified subset &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of nodes, but the shortest paths are computed only for all pairs of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, and the complete graph is over &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;.  See&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/6193/how-to-visit-a-subset-of-network-nodes-in-a-single-trip&quot;&gt;How to visit a subset of network nodes in a single trip?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://math.stackexchange.com/questions/4466582/find-the-shortest-path-in-a-graph-which-must-pass-certain-nodes&quot;&gt;https://math.stackexchange.com/questions/4466582/find-the-shortest-path-in-a-graph-which-must-pass-certain-nodes&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-07-28T15:49:39.403" LastActivityDate="2023-07-28T15:49:39.403" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10764" PostTypeId="2" ParentId="10762" CreationDate="2023-07-28T19:54:54.607" Score="6" Body="&lt;p&gt;My first thought was Rob's model, but for what it's worth here is an alternative formulation that does not require solving a bunch of shortest path problems at the outset. Whether it is faster or not I don't know.&lt;/p&gt;&#xA;&lt;p&gt;I'm going to write &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; for the set of nodes and &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; for the set of directed arcs in the graph (so each line in the examples corresponds to two arcs). I assume that any node can be the start node (which means the path shown for the star graph is actually not optimal -- you can reduce it by one arc if you start anywhere except 1). I'm also going to guess an a priori upper limit &lt;span class=&quot;math-container&quot;&gt;$k^*$&lt;/span&gt; on the number of arcs needed to visit every node, and let &lt;span class=&quot;math-container&quot;&gt;$K=\lbrace 1,\dots,k^* \rbrace.$&lt;/span&gt; If the guess is too low, the model will be infeasible, requiring another run with a larger guess. Guessing too high does not hurt the model's accuracy but might slow it down.&lt;/p&gt;&#xA;&lt;p&gt;Variables are as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s_i\in \lbrace 0, 1 \rbrace$&lt;/span&gt; is 1 if node &lt;span class=&quot;math-container&quot;&gt;$i\in N$&lt;/span&gt; is the starting node for the path;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j,k}\in \lbrace 0, 1 \rbrace$&lt;/span&gt; is 1 if the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-th move is from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,k}$&lt;/span&gt; fixed at 0 whenever &lt;span class=&quot;math-container&quot;&gt;$(i,j)\notin A$&lt;/span&gt;);&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{i,k}\ge 0$&lt;/span&gt; will be 1 if the path exits node &lt;span class=&quot;math-container&quot;&gt;$i\in N$&lt;/span&gt; at step &lt;span class=&quot;math-container&quot;&gt;$k\in K;$&lt;/span&gt; and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{i,k}\ge 0$&lt;/span&gt; will be 1 if the path enters node &lt;span class=&quot;math-container&quot;&gt;$i\in N$&lt;/span&gt; at step &lt;span class=&quot;math-container&quot;&gt;$k\in K.$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The objective is to minimize the number &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j,k} x_{i,j,k}$&lt;/span&gt; of arcs crossed (or some appropriate distance measure).&lt;/p&gt;&#xA;&lt;p&gt;Constraints are as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{i,k} = \sum_{(j,i)\in A} x_{j,i,k}\quad \forall i, k$&lt;/span&gt; (defining the exit variables);&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{i,k} = \sum_{(i,j)\in A} x_{i,j,k}\quad \forall i, k$&lt;/span&gt; (defining the entry variables);&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{(i,j)\in A} x_{i,j,k} \le 1\quad \forall k\in K$&lt;/span&gt; (at most one arc can occupy each slot in the trip);&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in N} s_i = 1$&lt;/span&gt; (there must be exactly one origin);&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{i,1} = s_i \quad \forall i\in N$&lt;/span&gt; (the first step must exit the origin);&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{i,k} \le z_{i, k-1} \quad \forall i\in N, k &amp;gt; 1$&lt;/span&gt; (other than the first step, exiting a node requires entering it at the previous step); and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s_i + \sum_{k\in K} z_{i,k} \ge 1 \quad \forall i\in N$&lt;/span&gt; (every node other than the origin must be entered at least once).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-07-28T19:54:54.607" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10767" PostTypeId="1" CreationDate="2023-07-30T22:51:55.603" Score="1" ViewCount="88" Body="&lt;p&gt;I don't know how to write this as Latex formulas, but here are anyways two examples, the divisors of &lt;span class=&quot;math-container&quot;&gt;$9$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; as the solutions to knapsack problems.&lt;/p&gt;&#xA;&lt;p&gt;Beware that there is some &lt;code&gt;DeleteDuplicates[]&lt;/code&gt; sequence manipulation in Mathematica. I have tested this knapsack method for numbers &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$13$&lt;/span&gt; and it gives the divisors greater than 1 for those numbers.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(*start*)&amp;quot;knapsack problem&amp;quot;&#xA;nn = 9;&#xA;TableForm[solve = Solve[&#xA;    x1 == 1 &amp;amp;&amp;amp;&#xA;     x1 == x8 &amp;amp;&amp;amp;&#xA;     x2 == x7 &amp;amp;&amp;amp;&#xA;     x3 == x6 &amp;amp;&amp;amp;&#xA;     x4 == x5 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x2] &amp;lt; 2 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x3] &amp;lt; 3 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x4] &amp;lt; 4 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x5] &amp;lt; 5 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x6] &amp;lt; 6 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x7] &amp;lt; 7 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x8] &amp;lt; 8 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x9] &amp;lt; 9 &amp;amp;&amp;amp;&#xA;     x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 == 0,&#xA;    {x1, x2, x3, x4, x5, x6, x7, x8, x9}, Integers]];&#xA;TableForm[&#xA;  solutions = &#xA;   Transpose[&#xA;    Table[ReleaseHold[&#xA;       MakeExpression[RowBox[{StringJoin[&amp;quot;x&amp;quot;, ToString[n]]}], &#xA;        StandardForm]] /. solve, {n, 1, nn}]]];&#xA;&amp;quot;Number of solutions&amp;quot;&#xA;Length[solutions]&#xA;abs = Abs[1 - solutions];&#xA;table = Table[DeleteDuplicates[abs[[k]]], {k, 1, Length[abs]}];&#xA;minLength = Min[Table[Length[table[[k]]], {k, 1, Length[table]}]];&#xA;select = Select[table, Length[#] == minLength &amp;amp;];&#xA;deleteDuplicates = DeleteDuplicates[select];&#xA;&amp;quot;Divisors excluding 1&amp;quot;&#xA;DeleteCases[Flatten[deleteDuplicates], 0]&#xA;(*end*)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where the essential part is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    x1 == 1 &amp;amp;&amp;amp;&#xA;     x1 == x8 &amp;amp;&amp;amp;&#xA;     x2 == x7 &amp;amp;&amp;amp;&#xA;     x3 == x6 &amp;amp;&amp;amp;&#xA;     x4 == x5 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x2] &amp;lt; 2 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x3] &amp;lt; 3 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x4] &amp;lt; 4 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x5] &amp;lt; 5 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x6] &amp;lt; 6 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x7] &amp;lt; 7 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x8] &amp;lt; 8 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x9] &amp;lt; 9 &amp;amp;&amp;amp;&#xA;     x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 == 0,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;pre&gt;&lt;code&gt;(*start*)&#xA;&amp;quot;knapsack problem&amp;quot;&#xA;nn = 12;&#xA;TableForm[solve = Solve[&#xA;    x1 == 1 &amp;amp;&amp;amp;&#xA;     x1 == x11 &amp;amp;&amp;amp;&#xA;     x2 == x10 &amp;amp;&amp;amp;&#xA;     x3 == x9 &amp;amp;&amp;amp;&#xA;     x4 == x8 &amp;amp;&amp;amp;&#xA;     x5 == x7 &amp;amp;&amp;amp;&#xA;     x6 == x6 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x2] &amp;lt; 2 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x3] &amp;lt; 3 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x4] &amp;lt; 4 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x5] &amp;lt; 5 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x6] &amp;lt; 6 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x7] &amp;lt; 7 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x8] &amp;lt; 8 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x9] &amp;lt; 9 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x10] &amp;lt; 10 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x11] &amp;lt; 11 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x12] &amp;lt; 12 &amp;amp;&amp;amp;&#xA;     x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 == &#xA;      0, {x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12}, &#xA;    Integers]];&#xA;TableForm[&#xA;  solutions = &#xA;   Transpose[&#xA;    Table[ReleaseHold[&#xA;       MakeExpression[RowBox[{StringJoin[&amp;quot;x&amp;quot;, ToString[n]]}], &#xA;        StandardForm]] /. solve, {n, 1, nn}]]];&#xA;&amp;quot;Number of solutions&amp;quot;&#xA;Length[solutions]&#xA;abs = Abs[1 - solutions];&#xA;table = Table[DeleteDuplicates[abs[[k]]], {k, 1, Length[abs]}];&#xA;minLength = Min[Table[Length[table[[k]]], {k, 1, Length[table]}]];&#xA;select = Select[table, Length[#] == minLength &amp;amp;];&#xA;deleteDuplicates = DeleteDuplicates[select];&#xA;&amp;quot;Divisors excluding 1&amp;quot;&#xA;DeleteCases[Flatten[deleteDuplicates], 0]&#xA;(*end*)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where the essential part is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    x1 == 1 &amp;amp;&amp;amp;&#xA;     x1 == x11 &amp;amp;&amp;amp;&#xA;     x2 == x10 &amp;amp;&amp;amp;&#xA;     x3 == x9 &amp;amp;&amp;amp;&#xA;     x4 == x8 &amp;amp;&amp;amp;&#xA;     x5 == x7 &amp;amp;&amp;amp;&#xA;     x6 == x6 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x2] &amp;lt; 2 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x3] &amp;lt; 3 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x4] &amp;lt; 4 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x5] &amp;lt; 5 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x6] &amp;lt; 6 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x7] &amp;lt; 7 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x8] &amp;lt; 8 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x9] &amp;lt; 9 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x10] &amp;lt; 10 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x11] &amp;lt; 11 &amp;amp;&amp;amp;&#xA;     0 &amp;lt; Abs[x12] &amp;lt; 12 &amp;amp;&amp;amp;&#xA;     x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 == 0,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Output for &lt;code&gt;nn=9&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;{3, 9}&lt;/p&gt;&#xA;&lt;p&gt;Output for &lt;code&gt;nn=12&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;{2, 3, 4, 6, 12}&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Can you explain/prove this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="671" LastActivityDate="2023-07-30T22:51:55.603" Title="Finding the divisors of the numbers 2 to 13 as a knapsack problem" Tags="|knapsack|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10768" PostTypeId="1" AcceptedAnswerId="10782" CreationDate="2023-07-30T23:35:14.963" Score="2" ViewCount="84" Body="&lt;p&gt;I cannot find a link for the instances of Kim et al.'s (2006) waste collection VRP-IF. &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0305054805001322&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sciencedirect.com/science/article/pii/S0305054805001322&lt;/a&gt;. The link mentioned in the paper and the citing papers is broken!&lt;/p&gt;&#xA;" OwnerUserId="3480" LastEditorUserId="123" LastEditDate="2023-08-09T08:05:52.227" LastActivityDate="2023-08-09T08:05:52.227" Title="Kim et al.'s (2006) waste collection VRP-IF" Tags="|reference-request|vehicle-routing|test-instances|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10770" PostTypeId="1" CreationDate="2023-07-31T16:47:56.367" Score="2" ViewCount="34" Body="&lt;p&gt;Consider the following three problems. The first is intended to be a simplification of the second that might be amenable to solution methods the second is not amenable to.&lt;/p&gt;&#xA;&lt;p&gt;First problem: Assume we have an undirected graph, each vertex of which has a payout associated with visiting it (e.g. five dollars). Each edge has an associated travel duration (e.g. fifteen minutes). Given a time limit (e.g. eight hours), find the route that takes less than this time limit to traverse that maximizes the payout.&lt;/p&gt;&#xA;&lt;p&gt;Second problem: In this variant, the payout is not a scalar in dollars, but a vector of apples, oranges, and plums. Instead of a single payout value associated with each vertex, there are multiple payouts (e.g. visiting a certain vertex comes with a payout of one apple, two oranges, and a plum). Which route, under the time limit, maximizes the number of fruit paid out in the smallest component (e.g. {two apples, two oranges, one plum} is preferable to {one apple, two oranges, zero plums}) (EDITED to correct earlier mistake pointed out by prubin).&lt;/p&gt;&#xA;&lt;p&gt;Third problem: The same as the second problem, but instead of looking for a single optimal solution, we are looking for a description of the non-dominated set. So if one path gets {one apple, two oranges, one plum} and another gets {two apples, one orange, one plum}, both are returned because neither is better in all dimensions.&lt;/p&gt;&#xA;&lt;p&gt;Can all three problems be formulated as mixed integer linear programs? Are any in a named class of optimization problems? Are there known optimal algorithms for these problems?&lt;/p&gt;&#xA;" OwnerUserId="12213" LastEditorUserId="12213" LastEditDate="2023-07-31T18:38:37.000" LastActivityDate="2023-07-31T18:38:37.000" Title="Maximizing value of nodes visited in fixed time" Tags="|linear-programming|integer-programming|multi-objective-optimization|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10771" PostTypeId="1" CreationDate="2023-07-31T21:02:32.990" Score="4" ViewCount="76" Body="&lt;p&gt;When using smoothing for dual values stabilization in column generation, the duals used in the subproblem lie on the segment joining the stability center (inside the dual feasible region) and the current dual values yielded by the last master problem solution (outside the dual feasible region unless the problem is solved to optimality).&lt;/p&gt;&#xA;&lt;p&gt;Does this imply that it is possible to generate a column which is already in the column pool? I am thinking that, with respect to the duals used in the subproblem, an existing column can still have strictly negative reduced cost. Therefore, the subproblem could generate it again. Is this correct?&lt;/p&gt;&#xA;&lt;p&gt;I am referring to the smoothing method proposed, e.g., in this paper:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A. Pessoa, R. Sadykov, E. Uchoa, F. Vanderbeck (2018) Automation and Combination of Linear-Programming Based Stabilization&#xA;Techniques in Column Generation. INFORMS Journal on Computing 30(2):339-360. &lt;a href=&quot;https://doi.org/10.1287/ijoc.2017.0784&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/ijoc.2017.0784&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="12215" LastActivityDate="2023-08-10T09:40:50.743" Title="Can dual values smoothing lead to generating duplicate columns?" Tags="|mixed-integer-programming|linear-programming|duality|column-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10772" PostTypeId="1" CreationDate="2023-08-01T07:04:09.167" Score="-1" ViewCount="185" Body="&lt;p&gt;Problem Definition:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Pa = Constant&#xA;Pb = Constant&#xA;Vmax_a = Constant&#xA;Vmax_b = constant&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Objective Function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;maximize: PaVa + PbVb - PoVo&#xA;Where: Vo = f(Po) ~ C  + e*Po&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Constraints:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;0 &amp;lt;= Va &amp;lt;= Vmax_a&#xA;0 &amp;lt;= Vb &amp;lt;= Vmax_b&#xA;Va + Vb = Vo&#xA;P_min &amp;lt; Po &amp;lt; P_max&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Variables to Optimize:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Va, Vb, Po&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12217" LastEditorUserId="491" LastEditDate="2023-08-02T17:21:43.900" LastActivityDate="2023-08-09T08:10:53.503" Title="How do I optimize this problem where the constraints and objective are variable?" Tags="|optimization|integer-programming|nonlinear-programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10773" PostTypeId="1" AcceptedAnswerId="10776" CreationDate="2023-08-01T11:25:11.800" Score="7" ViewCount="738" Body="&lt;p&gt;I don't know if I can ask this here, but I've been pulling my hair out trying to think of how to represent this in constraints.&lt;/p&gt;&#xA;&lt;p&gt;I have two sets of binary variables: &lt;span class=&quot;math-container&quot;&gt;$X_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y_{it}$&lt;/span&gt;. So, I want to represent that,&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if &lt;span class=&quot;math-container&quot;&gt;$X_t=X_{t-1}$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$Y_{it}=Y_{it-1}$&lt;/span&gt;&#xA;I can't seem to find a way that works without enforcing other behaviors.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Maybe this is basic and I am just blocked.&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="123" LastEditDate="2023-08-09T08:06:30.263" LastActivityDate="2023-08-09T08:06:30.263" Title="Binary logical constraint dependent on indices" Tags="|mixed-integer-programming|modeling|integer-programming|binary-variable|logical-constraints|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10775" PostTypeId="2" ParentId="10773" CreationDate="2023-08-01T11:48:38.747" Score="10" Body="&lt;p&gt;You could convert to CNF.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$(a = b) \implies (c = d)$$&lt;/span&gt; can be expressed by:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$0 \le a + b + c - d \le 2$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0 \le a + b + d - c \le 2$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="7666" LastActivityDate="2023-08-01T11:48:38.747" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10776" PostTypeId="2" ParentId="10773" CreationDate="2023-08-01T12:47:24.293" Score="9" Body="&lt;p&gt;You can enforce &lt;span class=&quot;math-container&quot;&gt;$X_t=X_{t-1}\implies Y_{it}=Y_{it-1}$&lt;/span&gt; with additional binary variables &lt;span class=&quot;math-container&quot;&gt;$\omega_{0t},\omega_{1t},\omega_{2t}$&lt;/span&gt; as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;X_t+X_{t-1}&amp;amp;=0\omega_{0t}+1\omega_{1t}+2\omega_{2t} \tag{1} \\&#xA;\omega_{0t}+\omega_{1t}+\omega_{2t} &amp;amp;= 1 \tag{2}\\&#xA;\omega_{0t} &amp;amp;\le 1-Y_{it}+Y_{it-1} \tag{3}\\&#xA;\omega_{0t} &amp;amp;\le 1-Y_{it-1}+Y_{it} \tag{4}\\&#xA;\omega_{2t} &amp;amp;\le 1-Y_{it}+Y_{it-1} \tag{5}\\&#xA;\omega_{2t} &amp;amp;\le  1-Y_{it-1}+Y_{it} \tag{6}\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; encapsulate the different possible values of the sum &lt;span class=&quot;math-container&quot;&gt;$X_t+X_{t-1}$&lt;/span&gt;. Constraints &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; make sure that exactly one these options is active. Constraints &lt;span class=&quot;math-container&quot;&gt;$(3)-(6)$&lt;/span&gt; enforce &lt;span class=&quot;math-container&quot;&gt;$\omega_{0t} \vee \omega_{2t} \implies Y_{it}=Y_{it-1}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that you could use constraint &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; to get rid of one of the &lt;span class=&quot;math-container&quot;&gt;$\omega$&lt;/span&gt; variables, but I think the model is more readable as it is.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Alternatively, you want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(X_t \wedge X_{t-1})\implies (Y_{it}\wedge Y_{it-1})\vee (\neg Y_{it}\wedge \neg Y_{it-1}) \tag{7}&#xA;$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(\neg X_t \wedge \neg X_{t-1})\implies (Y_{it}\wedge Y_{it-1})\vee (\neg Y_{it}\wedge \neg Y_{it-1}) \tag{8}&#xA;$$&lt;/span&gt;&#xA;Constraint &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt; is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\quad\;  \neg (X_t \wedge X_{t-1})\vee (Y_{it}\wedge Y_{it-1})\vee (\neg Y_{it}\wedge \neg Y_{it-1}) \\&#xA;&amp;amp;\equiv  (\neg X_t \vee \neg X_{t-1})\vee (Y_{it}\wedge Y_{it-1})\vee (\neg Y_{it}\wedge \neg Y_{it-1}) \\&#xA;&amp;amp;\equiv  (1- X_t + 1- X_{t-1} + Y_{it}+ 1-Y_{it-1} \ge 1) \wedge (1- X_t + 1- X_{t-1} + 1-Y_{it}+ Y_{it-1} \ge 1)\\&#xA;&amp;amp;\equiv  (X_t + X_{t-1} - Y_{it} +Y_{it-1}\le 2) \wedge (X_t + X_{t-1} +Y_{it}- Y_{it-1} \le 2) \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Similarly, constraint &lt;span class=&quot;math-container&quot;&gt;$(8)$&lt;/span&gt; is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(X_t + X_{t-1} - Y_{it} +Y_{it-1}\ge 0) \wedge (X_t + X_{t-1} +Y_{it}- Y_{it-1} \ge 0)&#xA;$$&lt;/span&gt;&#xA;The resulting model is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;0 \le X_t + X_{t-1} - Y_{it} +Y_{it-1}\le 2 \\&#xA;0 \le X_t + X_{t-1} + Y_{it} -Y_{it-1}\le 2&#xA;$$&lt;/span&gt;&#xA;as proposed by @user1502040.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-08-01T16:25:42.553" LastActivityDate="2023-08-01T16:25:42.553" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10777" PostTypeId="1" CreationDate="2023-08-01T13:12:01.463" Score="0" ViewCount="36" Body="&lt;p&gt;Desrochers, Desrosiers and Solomon (1992) presents a method for reducing the size of the time windows for the VRPTW.&lt;/p&gt;&#xA;&lt;p&gt;Given other versions of the VRPTW, what are the requirements on the problem for it to be suitable for this time window reduction method?&lt;/p&gt;&#xA;&lt;p&gt;Martin Desrochers, Jacques Desrosiers, Marius Solomon, (1992) A New Optimization Algorithm for the Vehicle Routing Problem with Time Windows. Operations Research 40(2):342-354.&#xA;&lt;a href=&quot;https://doi.org/10.1287/opre.40.2.342&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/opre.40.2.342&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9151" LastActivityDate="2023-08-01T13:12:01.463" Title="When is time window reduction applicable?" Tags="|vehicle-routing|dynamic-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10778" PostTypeId="2" ParentId="10772" CreationDate="2023-08-01T20:35:17.380" Score="1" Body="&lt;p&gt;I am not 100% sure, but I am thinking like this: I suppose you can rewrite the objective to: &lt;span class=&quot;math-container&quot;&gt;$$\max V_a(P_a-P_o)+V_b(P_b-P_o)$$&lt;/span&gt; since &lt;span class=&quot;math-container&quot;&gt;$V_a + V_b = V_o$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And since that sum is also equal to whatever is the RHS of that strange equation @prubin asked about and since either &lt;span class=&quot;math-container&quot;&gt;$P_a-P_o$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$P_b-P_o$&lt;/span&gt; will always be bigger depends only on &lt;span class=&quot;math-container&quot;&gt;$P_a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_b$&lt;/span&gt; and not on &lt;span class=&quot;math-container&quot;&gt;$P_o$&lt;/span&gt;, you can assign both &lt;span class=&quot;math-container&quot;&gt;$V_a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V_b$&lt;/span&gt; from the RHS. If &lt;span class=&quot;math-container&quot;&gt;$P_a &amp;gt; P_b$&lt;/span&gt; you will max out &lt;span class=&quot;math-container&quot;&gt;$V_a$&lt;/span&gt; before assigning the remaining to &lt;span class=&quot;math-container&quot;&gt;$V_b$&lt;/span&gt;, otherwise it's just the opposite. So you can essentially search only for &lt;span class=&quot;math-container&quot;&gt;$P_o$&lt;/span&gt; in the range &lt;span class=&quot;math-container&quot;&gt;$P_\min$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\min(P_\max, \max(P_a, P_b))$&lt;/span&gt;. Especially because the RHS has to be non-negative due to being equal to the sum of two non-negative numbers -&amp;gt; if &lt;span class=&quot;math-container&quot;&gt;$P_o$&lt;/span&gt; would surpass &lt;span class=&quot;math-container&quot;&gt;$P_a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_b$&lt;/span&gt; will make the objective negative, while it may be non-negative if &lt;span class=&quot;math-container&quot;&gt;$P_o$&lt;/span&gt; is smaller than the larger one.&lt;/p&gt;&#xA;&lt;p&gt;The problem becomes (assuming &lt;span class=&quot;math-container&quot;&gt;$P_a &amp;gt; P_b$&lt;/span&gt;):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\max&amp;amp;\quad {\rm RHS} \cdot (P_a - P_o)\\&#xA;\text{s.t.}&amp;amp;\quad 0 \le{\rm RHS}\le {V_a}_\max + {V_b}_\max\\&#xA;&amp;amp;\quad P_\min \le P_o \le \min(P_\max, P_a)\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And RHS being the function of &lt;span class=&quot;math-container&quot;&gt;$P_o$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Not sure how to solve that optimally though. Maybe use heuristics?&lt;/p&gt;&#xA;" OwnerUserId="242" LastEditorUserId="123" LastEditDate="2023-08-09T08:10:53.503" LastActivityDate="2023-08-09T08:10:53.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10779" PostTypeId="2" ParentId="10772" CreationDate="2023-08-01T22:32:07.930" Score="1" Body="&lt;p&gt;Your merit function is nonlinear, continuous and differentiable.&lt;/p&gt;&#xA;&lt;p&gt;So long as &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is unknown, variable and unbounded, the fact that &lt;span class=&quot;math-container&quot;&gt;$V_o$&lt;/span&gt; may be expressed as a function of &lt;span class=&quot;math-container&quot;&gt;$P_o$&lt;/span&gt; is immaterial. If &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is bounded or fixed then constraints need to be added to the demonstration below, but I assume that that is not the case.&lt;/p&gt;&#xA;&lt;p&gt;When optimizing, &lt;span class=&quot;math-container&quot;&gt;$V_a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V_b$&lt;/span&gt; being bounded implies that &lt;span class=&quot;math-container&quot;&gt;$V_o$&lt;/span&gt; is also bounded, but this bound can stay implicit; and the simpler form for the merit function is one where &lt;span class=&quot;math-container&quot;&gt;$V_o$&lt;/span&gt; is substituted with &lt;span class=&quot;math-container&quot;&gt;$V_a + V_b$&lt;/span&gt;. As a cost (negative merit),&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;c = P_o (V_a + V_b) - P_a V_a - P_b V_b&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The gradient of the cost function is easy and can help many optimizers, so include it in your problem construction:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\nabla c = \begin{bmatrix}&#xA;P_o - P_a \\&#xA;P_o - P_b \\&#xA;V_a + V_b&#xA;\end{bmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;All together, an implementation could look like&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import numpy as np&#xA;import pandas as pd&#xA;from scipy.optimize import check_grad, minimize&#xA;&#xA;Pa = 0.3&#xA;Pb = 0.6&#xA;Pmin = 0.2&#xA;Pmax = 0.7&#xA;Vmax_a = 12&#xA;Vmax_b = 9&#xA;&#xA;&#xA;def cost(params: np.ndarray) -&amp;gt; float:&#xA;    Va, Vb, Po = params&#xA;    return Po*(Va + Vb) - Pa*Va - Pb*Vb&#xA;&#xA;&#xA;def cost_jacobian(params: np.ndarray) -&amp;gt; tuple[float, float, float]:&#xA;    Va, Vb, Po = params&#xA;    return (&#xA;        Po - Pa,&#xA;        Po - Pb,&#xA;        Va + Vb,&#xA;    )&#xA;&#xA;&#xA;error = check_grad(func=cost, grad=cost_jacobian, x0=(0.9, 1.1, 1.4))&#xA;assert error &amp;lt; 1e-6&#xA;&#xA;result = minimize(&#xA;    fun=cost, jac=cost_jacobian,&#xA;    x0=(1, 1, 1),&#xA;    bounds=(&#xA;        (0, Vmax_a),&#xA;        (0, Vmax_b),&#xA;        (Pmin, Pmax),&#xA;    ),&#xA;)&#xA;assert result.success, result.message&#xA;&#xA;Va, Vb, Po = result.x&#xA;Vo = Va + Vb&#xA;C = Vo - np.e*Po&#xA;df = pd.DataFrame(&#xA;    {&#xA;        'V': (Va, Vb, Vo),&#xA;        'P': (Pa, Pb, Po),&#xA;    },&#xA;    index=pd.Index(['a', 'b', 'o']),&#xA;)&#xA;print(df)&#xA;&#xA;print(f'\nC = {C:.3f}')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;      V    P&#xA;a  12.0  0.3&#xA;b   9.0  0.6&#xA;o  21.0  0.2&#xA;&#xA;C = 20.456&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11118" LastActivityDate="2023-08-01T22:32:07.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10780" PostTypeId="2" ParentId="10747" CreationDate="2023-08-02T04:55:02.017" Score="-2" Body="&lt;p&gt;&lt;strong&gt;Scaling will directly impact the Objective function of an optimization problem.&lt;/strong&gt;&#xA;say we have&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Max obj1 = c1&lt;em&gt;x1 + c2&lt;/em&gt;x2&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Now if your c1 = [0-10] &amp;amp; c2 = [200-1000], x2 variable will dictate much of the objective function.&#xA;But, you are talking about Constraints. For Constraints, aren't we just check if this constraint is satisfied or not (in such case, scaling seems not a matter). May I missing something?&lt;/p&gt;&#xA;" OwnerUserId="11346" LastActivityDate="2023-08-02T04:55:02.017" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10781" PostTypeId="2" ParentId="10773" CreationDate="2023-08-02T13:34:08.440" Score="3" Body="&lt;p&gt;With the common &lt;span class=&quot;math-container&quot;&gt;$\text{BigM}$&lt;/span&gt; approach, we can linearize the logical expression as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ if: \quad (x_{t}-x_{t-1} = 0) \implies (y_{i,t} - y_{i,t-1} = 0) \quad \equiv$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ if: \quad (x_{t}-x_{t-1} = 0) \implies (z_{i,t} = 1) \implies(y_{i,t} - y_{i,t-1} = 0) \quad \equiv$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first part would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ if: \quad (z_{i,t} = 0) \implies ((x_{t}-x_{t-1} \geq 1) \lor (x_{t}-x_{t-1} \leq -1)) \quad \equiv$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ if: \quad (z_{i,t} = 0) \implies (((w_{t} = 1) \implies (x_{t}-x_{t-1} \geq 1)) \lor ((o_{t} = 1) \implies (x_{t}-x_{t-1} \leq -1))) \quad \equiv$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;That yields the following three linear expressions:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ z_{i,t} + w_{t} + o_{t} \geq 1 \quad (1) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x_{t} - x_{t-1} \geq 1 - m(1-w_{t}) \quad (2) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x_{t} - x_{t-1} \leq -1 + M(1-o_{t}) \quad (3) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The second part also would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ (z_{i,t} = 1) \implies(y_{i,t} - y_{i,t-1} = 0) \quad $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;That translating into the following expressions:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ y_{i,t} - y_{i,t-1} \geq 0 - m(1-z_{i,t}) \quad (4) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ y_{i,t} - y_{i,t-1} \leq 0 + M(1-z_{i,t}) \quad (5) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where the value of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; should be &lt;span class=&quot;math-container&quot;&gt;$\leq 2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Also, based on the indicator variables the corresponding CNF is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ (z_{i,t}) \bigvee ((x_{t} \land \lnot x_{t-1}) \lor (\lnot x_{t} \land x_{t-1})) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thant yields following inequalities:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ z_{i,t} + x_{t} + x_{t-1} \geq 1 \quad (1) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ z_{i,t} - x_{t} - x_{t-1} \geq -1 \quad (2) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And the second part would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ (\lnot z_{i,t}) \bigvee ((y_{i,t} \land y_{i,t-1}) \lor (\lnot y_{i,t} \land \lnot y_{i,t-1})) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thant yields following inequalities:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ -z_{i,t} + y_{i,t} - y_{i,t-1} \geq -1 \quad (1) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ -z_{i,t} - y_{i,t} + y_{i,t-1} \geq -1 \quad (2) $$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-08-02T14:28:12.073" LastActivityDate="2023-08-02T14:28:12.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10782" PostTypeId="2" ParentId="10768" CreationDate="2023-08-02T14:14:04.380" Score="2" Body="&lt;p&gt;Here I found the correct link: &lt;a href=&quot;http://logistics.postech.ac.kr/benchmark.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://logistics.postech.ac.kr/benchmark.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2023-08-02T14:14:04.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10783" PostTypeId="1" CreationDate="2023-08-04T11:47:52.837" Score="0" ViewCount="89" Body="&lt;p&gt;In general the relationship between safety stock and service level is non-convex. As it contains often a Normal distribution or simulation.&#xA;If one considers now optimization the supply chain by finding the optimal safety stock over the multiple warehouse system (central/regional distribution chains) one can apply a metaheuristic. Are solvers like Gurobi also possible? But how is the Normal distribution in the classical safety stock service level handled in such cases?&lt;/p&gt;&#xA;&lt;p&gt;For example we have the classical formula:&lt;/p&gt;&#xA;&lt;p&gt;Safetystock level &lt;span class=&quot;math-container&quot;&gt;$= Z_a \times sigma_d \times \sqrt L$&lt;/span&gt;, where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Z_a$&lt;/span&gt; is the inverse cumulative distribution function,&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sigma_d$&lt;/span&gt; is the standard deviation of demand&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is the lead time.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now suppose I want to optimize over a to find the cost minimum (together with other constraints). This is what multi echelon inventory optimization is about. Now this is a non-convex constraint because of the distribution function. But are there models which can optimize something similar to this with Gurobi?&lt;/p&gt;&#xA;" OwnerUserId="12147" LastEditorUserId="123" LastEditDate="2023-08-09T07:58:58.360" LastActivityDate="2023-08-09T07:58:58.360" Title="Optimizing Safety Stock in a Multi Echelon Optimization" Tags="|optimization|inventory|probability-distributions|multi-echelon|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10784" PostTypeId="1" CreationDate="2023-08-04T13:52:47.307" Score="-1" ViewCount="71" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$C=10$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$U=50$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$P_c,c=1,\cdots,C$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha_{u,c},u=1,\cdots,U,c=1,\cdots,C$&lt;/span&gt; are optimization variables&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\alpha_{u,c}$&lt;/span&gt; is binary&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sigma_{u,c}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_{u,c}$&lt;/span&gt; are known parameters&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min \sum_{c=1}^CP_c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\gamma_u=\frac{\sum_{c=1}^C\alpha_{u,c}P_cd_{u,c}^{-3.76}}{\sum_{c=1}^C(1-\alpha_{u,c})P_cd_{u,c}^{-3.76}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\gamma_u \ge \gamma_{th},\forall u$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0\le P_c\le 100$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We have multiplication of vatiables, i.e., &lt;span class=&quot;math-container&quot;&gt;$\alpha_{u,c}P_c$&lt;/span&gt; (in numerator) and &lt;span class=&quot;math-container&quot;&gt;$(1-\alpha_{u,c})P_c$&lt;/span&gt; (in denominator)&lt;/p&gt;&#xA;&lt;p&gt;How can I make this problem MILP?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2023-08-08T21:59:01.173" LastActivityDate="2023-08-08T21:59:01.173" Title="How to linearize the multiplication of variables and transform this into an MILP?" Tags="|mixed-integer-programming|linear-programming|linearization|convex-optimization|nonconvex-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10785" PostTypeId="2" ParentId="10784" CreationDate="2023-08-04T15:35:20.030" Score="1" Body="&lt;p&gt;Numerator and denominator you'd rearrange as &lt;span class=&quot;math-container&quot;&gt;$ A \times d = n$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$n,d$&lt;/span&gt; are expressions of numerator &amp;amp; denominator.&lt;br /&gt;&#xA;As for multiplication of a binary variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; with a continuous variable &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; you can use the following constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ xp_l \le \delta \le xp_u$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ p - p_l(1-x) \le \delta \le p + p_u(1-x)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$ \delta$&lt;/span&gt; is variable of same type as &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p_l,p_u$&lt;/span&gt; are lower/upper bounds for &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-08-04T15:35:20.030" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10786" PostTypeId="1" CreationDate="2023-08-04T19:03:09.940" Score="1" ViewCount="96" Body="&lt;p&gt;Suppose resources r1 and r2 are both able to perform jobs j1 and j2. The duration of the jobs being done is d.&lt;/p&gt;&#xA;&lt;p&gt;I would like to model the following rule:&lt;/p&gt;&#xA;&lt;p&gt;Within a time horizon H,&#xA;perform j1 on r2 only if it isn't optimal to perform it on r1 and perform j2 on r1 only if it isn't optimal to perform it on r2.&lt;/p&gt;&#xA;&lt;p&gt;In other words I would like to see an optimal solution&lt;/p&gt;&#xA;&lt;p&gt;Resource r1 performs within H:  j1, j1, j1, j1&lt;/p&gt;&#xA;&lt;p&gt;Resource r2 performs within H:  j2, j2, j2&lt;/p&gt;&#xA;&lt;p&gt;rather than an optimal solution&lt;/p&gt;&#xA;&lt;p&gt;Resource r1 performs within H:  j1, j2, j2, j1&lt;/p&gt;&#xA;&lt;p&gt;Resource r2 performs within H:  j2, j1, j1&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="500" LastEditDate="2023-08-04T19:32:08.667" LastActivityDate="2023-08-06T10:43:41.813" Title="Breaking symmetry" Tags="|mixed-integer-programming|modeling|multi-objective-optimization|symmetry|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10787" PostTypeId="1" AcceptedAnswerId="10789" CreationDate="2023-08-04T19:13:07.320" Score="2" ViewCount="287" Body="&lt;p&gt;Here are all the 369 octominoes: &lt;a href=&quot;https://en.wikipedia.org/wiki/Octomino&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Octomino&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If I have an 8x8 area, how to create one octomino, any of those 369 and any rotation and mirroring is allowed?&lt;/p&gt;&#xA;&lt;p&gt;I have tried several linearized and/or tricks but those produced sometimes correct sometimes wrong solutions. How to make constraints so the eight binary ones are always connected?&lt;/p&gt;&#xA;" OwnerUserId="9050" LastEditorUserId="500" LastEditDate="2023-08-04T20:21:33.777" LastActivityDate="2023-08-05T14:39:54.780" Title="How to do one octomino?" Tags="|binary-variable|graphs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10788" PostTypeId="2" ParentId="10786" CreationDate="2023-08-04T19:26:03.270" Score="1" Body="&lt;p&gt;Suppose you define a small penalty for each time a job is performed on the &amp;quot;wrong&amp;quot; resource. You now have a bicriterion optimization problem, one criterion being the original objective and the other being minimization of this penalty. There are at least three possible solution approaches.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Solve using the original objective only, constrain the original objective function to be no worse than the optimal value, and solve again with the objective being minimization of the penalty.&lt;/li&gt;&#xA;&lt;li&gt;Add the penalty component to the original objective and solve one model. The catch with this approach is that you need to be able to scale the penalty component so that it cannot exceed in magnitude the difference between the (original) objective value of the optimal solution and the objective value of the best suboptimal solution.&lt;/li&gt;&#xA;&lt;li&gt;Use a solver that is capable of handling lexicographic ordering of objective functions. (Recent versions of CPLEX, for instance, can do that.) The inherent idea is that nodes are pruned only if they are known to have a worse value of the original objective than does the incumbent or if they are known to tie the incumbent on the original objective but have a worse penalty value. So the problem is solved in a single branch-and-cut run, but with perhaps slower pruning of the search tree.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-08-04T19:26:03.270" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10789" PostTypeId="2" ParentId="10787" CreationDate="2023-08-04T20:21:08.063" Score="6" Body="&lt;p&gt;You want to model a connected subgraph, with &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; nodes, of an &lt;span class=&quot;math-container&quot;&gt;$8 \times 8$&lt;/span&gt; grid graph.&#xA;Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; indicate whether undirected edge &lt;span class=&quot;math-container&quot;&gt;$\{i,j\}\in E$&lt;/span&gt; is selected.&#xA;Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; indicate whether node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is selected.&#xA;Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; indicate whether node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is selected as the source node.  Let nonnegative decision variable &lt;span class=&quot;math-container&quot;&gt;$f_{ij}$&lt;/span&gt; be the flow across directed arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in A$&lt;/span&gt;.  The idea is to enforce connectivity by sending one unit of flow from the source to each other selected node.  The constraints are:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i y_i &amp;amp;= 8 \tag1\label1 \\&#xA;x_{ij} &amp;amp;\le y_i &amp;amp;&amp;amp;\text{for all $\{i,j\}\in E$} \tag2\label2 \\&#xA;x_{ij} &amp;amp;\le y_j &amp;amp;&amp;amp;\text{for all $\{i,j\}\in E$} \tag3\label3 \\&#xA;x_{ij} &amp;amp;\ge y_i + y_j - 1 &amp;amp;&amp;amp;\text{for all $\{i,j\}\in E$} \tag4\label4 \\&#xA;\sum_i s_i &amp;amp;= 1 \tag5\label5 \\&#xA;s_i &amp;amp;\le y_i &amp;amp;&amp;amp; \text{for all $i$} \tag6\label6 \\&#xA;f_{ij} + f_{ji} &amp;amp;\le 7 x_{ij} &amp;amp;&amp;amp; \text{for all $\{i,j\}\in E$} \tag7\label7 \\&#xA;\sum_{(i,j) \in A} f_{ij} - \sum_{(j,i)\in A} f_{ji}&#xA;   &amp;amp;= 8 s_i - y_i &amp;amp;&amp;amp;\text{for all $i$} \tag8\label8&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} selects &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; nodes.&#xA;Constraints \eqref{2} through \eqref{4} link the node variables to the edge variables.&#xA;Constraint \eqref{5} selects one source node.&#xA;Constraint \eqref{6} forces the source node to be a selected node.&#xA;Constraint \eqref{7} allows flow only on selected edges.&#xA;Constraint \eqref{8} enforces flow balance.&lt;/p&gt;&#xA;&lt;p&gt;Because a connected graph must have at most one more node than the number of edges, an optional constraint is &lt;span class=&quot;math-container&quot;&gt;$$\sum_{\{i,j\}\in E} x_{ij} \ge 7.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that you can relax &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to be nonnegative because it will automatically take values in &lt;span class=&quot;math-container&quot;&gt;$\{0,1\}$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; does.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-08-05T14:39:54.780" LastActivityDate="2023-08-05T14:39:54.780" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10790" PostTypeId="2" ParentId="10786" CreationDate="2023-08-05T03:00:23.490" Score="0" Body="&lt;p&gt;In addition to below constraints with binary assignment vars &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_j x_{j,r,t} \le 1 \ \ \forall t,r$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_r x_{j,r,t} \le 1 \ \ \forall t,j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Define binary vars &lt;span class=&quot;math-container&quot;&gt;$z_{j,r}$&lt;/span&gt; subject to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x_{j,r,t} - x_{j,r,t-1} \le z_{j,r}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_{j,r,t-1} - x_{j,r,t} \le z_{j,r}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{j,r,t-1} + x_{j,r,t} + z_{j,r} \le 2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Define objective&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\min \sum_{j,r}z_{j,r}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-08-05T03:17:17.700" LastActivityDate="2023-08-05T03:17:17.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10791" PostTypeId="2" ParentId="10783" CreationDate="2023-08-05T12:54:53.790" Score="1" Body="&lt;p&gt;If you would like to take into account the inventory model directly in an optimization model, your problem is more likely classified in the following areas:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Multi-Depot Location Routing Problem taking inventory control decisions into consideration&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Location-inventory problem with risk consideration&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For the first and second you can take a look at the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s00170-003-1639-5&quot; rel=&quot;nofollow noreferrer&quot;&gt;A two-phase heuristic method for the multi-depot location routing problem taking inventory control decisions into consideration&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://onlinelibrary.wiley.com/doi/epdf/10.1002/nav.20376&quot; rel=&quot;nofollow noreferrer&quot;&gt;A two-echelon inventory-location problem with service considerations&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also, I have seen some models that take inventory as a part of the objective function to minimize the related cost. E.g. something like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \text{Min} \biggl\{ (\text{deploy cost}) + \cdots + (\text{inventory cost}*z_{\alpha/2}*\sqrt{}\sum\sigma^2*\text{some decision variables}) \biggl\} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Please be aware that, solving such a model in an actual situation is challenging work, and also with an appropriate solver that handles the non-convex problems may take a while to solve optimality.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-08-05T12:54:53.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10792" PostTypeId="1" AcceptedAnswerId="10793" CreationDate="2023-08-05T13:48:39.583" Score="2" ViewCount="93" Body="&lt;p&gt;I'm working on an optimization problem using Docplex and wonder if it's possible to incorporate a logical expression into the objective function of my model.&lt;/p&gt;&#xA;&lt;p&gt;Specifically, I have three variables x, y, and z.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{ijk} \quad : \quad binary \quad variable$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{ik} \quad and \quad z_{ik} \quad : \quad are \quad continuous \quad variables $$&lt;/span&gt;&#xA;And I want to model this objective function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA; \min w_{1} \sum_{k \in K} \sum_{(i, j) \in V} c_{ijk}*x_{ijk} + w_{2}\sum_{k \in K} \sum_{(i, j) \in V} [(y_{jk} - y_{ik})*x_{ijk} \quad if \quad z_{ik} == 0]&#xA;\end{aligned}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is it feasible to include such a logical expression directly within the objective function in CPLEX? If so, how can I go about implementing it effectively?&lt;/p&gt;&#xA;" OwnerUserId="5537" LastEditorUserId="5537" LastEditDate="2023-08-05T16:03:40.843" LastActivityDate="2023-08-07T15:24:01.487" Title="Can a logical expression be added to the objective function of a model in docplex?" Tags="|optimization|mixed-integer-programming|cplex|docplex|cplex-python-api|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10793" PostTypeId="2" ParentId="10792" CreationDate="2023-08-05T20:10:56.857" Score="3" Body="&lt;p&gt;We can use a &amp;quot;big M&amp;quot; approach, assuming that you can find a positive constant &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\vert y_{jk}-y_{ik} \vert \le M$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(i,j)\in V.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Introduce new binary variables &lt;span class=&quot;math-container&quot;&gt;$u_{ik}$&lt;/span&gt; and continuous variables &lt;span class=&quot;math-container&quot;&gt;$v_{ijk}.$&lt;/span&gt; The second objective summand (the mess in brackets) becomes &lt;span class=&quot;math-container&quot;&gt;$v_{ijk}.$&lt;/span&gt; Now add the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$3u_{ik} + z_{ik} \le 3\, (1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$u_{ik} + z_{ik} \ge 1 \, (2)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$v_{ijk} \le M u_{ik}\, (3)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$v_{ijk} \ge -M u_{ik}\, (3')$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$v_{ijk} \le M x_{ijk}\, (4)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$v_{ijk} \ge -M x_{ijk}\, (4')$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$v_{ijk} \le y_{jk} - y_{ik} + M(2 - u_{ik} - x_{ijk}) \, (5)$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$v_{ijk} \ge y_{jk} - y_{ik} - M(2 - u_{ik} - x_{ijk}) \, (5')$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints (1) and (2) combine to set &lt;span class=&quot;math-container&quot;&gt;$u_{ik} =1$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$z_{ik} = 0.$&lt;/span&gt; Constraints (3) and (3') say that the &lt;span class=&quot;math-container&quot;&gt;$(i,j,k)$&lt;/span&gt; objective term is 0 if &lt;span class=&quot;math-container&quot;&gt;$u_{ik}=0$&lt;/span&gt; (meaning &lt;span class=&quot;math-container&quot;&gt;$z_{ik} \in \lbrace 1,2,3 \rbrace$&lt;/span&gt;). Constraints (4) and (4') say that the objective term is 0 if &lt;span class=&quot;math-container&quot;&gt;$x_{ijk} =0.$&lt;/span&gt; Finally, constraints (5) and (5') say that if &lt;span class=&quot;math-container&quot;&gt;$u_{ik}=1$&lt;/span&gt; (meaning &lt;span class=&quot;math-container&quot;&gt;$z_{ik}=0$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$x_{ijk}=1,$&lt;/span&gt; then the objective term equals &lt;span class=&quot;math-container&quot;&gt;$y_{jk}-y_{ik}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: If the solver supports &amp;quot;if-then&amp;quot; (implication) constraints (CPLEX does), then the &amp;quot;big M&amp;quot; constraints can be replaced with implications, as follows.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$u_{ik}=0 \implies v_{ijk}=0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{ijk}=0 \implies v_{ijk}=0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$u_{ik} + x_{ijk} = 2  \implies v_{ijk} = y_{jk}-y_{ik}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As a general rule, you are probably better off with the &amp;quot;big M&amp;quot; constraints if you can find a reasonably tight value of &lt;span class=&quot;math-container&quot;&gt;$M.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-08-07T15:24:01.487" LastActivityDate="2023-08-07T15:24:01.487" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10794" PostTypeId="2" ParentId="10786" CreationDate="2023-08-06T10:43:41.813" Score="1" Body="&lt;p&gt;The problem you have sounds like a parallel resource scheduling model that may have some additional limitations. &lt;span class=&quot;math-container&quot;&gt;$(\text{R}_{2} \ | Cap | \sum_{j}w_{j})$&lt;/span&gt;. In the simplest form, it is still NP-hard, I supposed there are two tasks and also two resources. I tried using a &lt;a href=&quot;https://en.wikipedia.org/wiki/Generalized_assignment_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Generalized assignment problem&lt;/a&gt;, so already you can adapt it based on your formulation.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using appropriate costs/weights to assign tasks&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; \text{Min} z = \sum_{i,j} x_{i,j}w_{i,j} \\&#xA;&amp;amp; \text{S.t:} \\&#xA;&amp;amp; \sum_{j} x_{ij}  =  1 \quad \forall i \in \text{Task} \tag1 \\&#xA;&amp;amp; \sum_{i} x_{ij} \text{duration}_{i,j} \le Cap_j \quad \forall j \in \text{Resources} \tag2 \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using an arbitrary binary assignment parameter/set&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j} x_{ij} \gamma_{i,j}  =  1 \quad \forall i \in \text{Task} \tag1 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, for two tasks with the following durations:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;duration (i,j) 'resource usage'&#xA;           R1    R2&#xA;task1      6     8&#xA;task2      7     5&#xA;&#xA;alpha(i,j) 'resource assign'&#xA;           R1  R2&#xA;task1      0   1&#xA;task2      0   1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;the results of the two ways would be the same:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eqpAU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eqpAU.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-08-06T10:43:41.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10795" PostTypeId="1" CreationDate="2023-08-06T20:17:45.257" Score="6" ViewCount="237" Body="&lt;p&gt;I'm currently working on a paper that investigates the capabilities of Large Language Models (like OpenAI's GPT variants) to understand and write mathematical models based solely on natural language descriptions of optimization problems.&lt;/p&gt;&#xA;&lt;p&gt;Given the multidisciplinary nature of this research at the intersection of OR and NLP, I'm seeking suggestions for a suitable venue/journal/conference to present this work. I believe many in the OR community would find the results intriguing, especially with the potential to reshape how we formulate and communicate optimization problems.&lt;/p&gt;&#xA;&lt;p&gt;Has anyone seen similar works or know of venues where such research is particularly welcomed? Your insights and suggestions would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="172" LastActivityDate="2023-08-07T02:18:34.880" Title="Large Language Models for Translating Natural Language to Mathematical Models - Suitable Venues?" Tags="|modeling|journals|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10796" PostTypeId="1" AcceptedAnswerId="10797" CreationDate="2023-08-06T20:33:47.173" Score="3" ViewCount="574" Body="&lt;p&gt;Given the dimension of a rectangle and the radii of n unequal circles, how can I decide if these circles can fit in the rectangle?&lt;/p&gt;&#xA;&lt;p&gt;I don't know if there is a formula to compute such a thing!&lt;/p&gt;&#xA;&lt;p&gt;The formula is straightforward if they are only two circles, not n circles. Also, it can be deducted if they are rectangles, not circles. But I can't figure it out for that case.&lt;/p&gt;&#xA;" OwnerUserId="3480" LastActivityDate="2023-08-06T20:48:02.520" Title="Packing a number of unequal circles in a rectangle" Tags="|combinatorial-optimization|set-covering|packing|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10797" PostTypeId="2" ParentId="10796" CreationDate="2023-08-06T20:48:02.520" Score="6" Body="&lt;p&gt;You can determine whether such a packing is possible by solving a nonconvex quadratically constrained feasibility problem where the decision variables are the coordinates of the circle centers.  See &lt;a href=&quot;http://yetanothermathprogrammingconsultant.blogspot.com/2018/05/knapsack-packing-difficult-miqcp.html&quot; rel=&quot;noreferrer&quot;&gt;http://yetanothermathprogrammingconsultant.blogspot.com/2018/05/knapsack-packing-difficult-miqcp.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-08-06T20:48:02.520" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10798" PostTypeId="1" CreationDate="2023-08-06T21:04:18.397" Score="1" ViewCount="104" Body="&lt;p&gt;I am solving an integrated scheduling problem and have dealt with coupling constraints using Lagrangian relaxation to decompose the problem into two separate problems. However, it is still difficult to solve the two decomposed problems directly using the solver. Based on the structure and nature of the problems, the column generation algorithm can be used to solve them separatly, but I have not found in the relevant literature that the column generation algorithm can be used to solve Lagrangian subproblem for example, I would like to ask if this combination of Lagrangian relaxation and column generation algorithm can be used?&lt;/p&gt;&#xA;" OwnerUserId="12244" LastEditorUserId="500" LastEditDate="2023-08-06T21:06:13.367" LastActivityDate="2023-08-07T06:07:33.030" Title="Combination of lagrangian relaxation and column generation" Tags="|column-generation|lagrangian-relaxation|lp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10799" PostTypeId="2" ParentId="10798" CreationDate="2023-08-06T22:03:04.820" Score="0" Body="&lt;p&gt;It is hard to say anything specific without knowing more about the problem, and if you are looking for practical solutions or theoretical ones. However, your description reminds me of packing/resource sharing problems. These have been studied quite a bit, often in the context of multi-commodity flow problems, but the results can be applied to a wide collection of problems. You might want to look into the 1994 and 1996 papers of Grigoriadis and Khachiyan. (&lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1002/net.3230260202&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://onlinelibrary.wiley.com/doi/abs/10.1002/net.3230260202&lt;/a&gt;) (&lt;a href=&quot;https://www.jstor.org/stable/3690236&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.jstor.org/stable/3690236&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="5812" LastActivityDate="2023-08-06T22:03:04.820" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10800" PostTypeId="2" ParentId="10795" CreationDate="2023-08-07T02:18:34.880" Score="2" Body="&lt;p&gt;A good start to reaching the OR community would be publishing in an INFORMS journal. Among those, I suspect the &lt;a href=&quot;https://pubsonline.informs.org/journal/ijoc&quot; rel=&quot;nofollow noreferrer&quot;&gt;INFORMS Journal on Computing&lt;/a&gt; might be the best fit.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-08-07T02:18:34.880" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10801" PostTypeId="2" ParentId="10798" CreationDate="2023-08-07T06:07:33.030" Score="1" Body="&lt;p&gt;In theory, nothing forbids it.&lt;/p&gt;&#xA;&lt;p&gt;I don't remember seeing any such example in the scientific literature. But here is an example of an algorithm using nested column generation, i.e. the pricing subproblem is solved by column generation as well:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Vanderbeck F (2001) A Nested Decomposition Approach to a Three-Stage, Two-Dimensional Cutting-Stock Problem. Management Science 47:864–879. &lt;a href=&quot;https://doi.org/10.1287/mnsc.47.6.864.9809&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/mnsc.47.6.864.9809&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Just be careful that usually, column generation based algorithms are not the fastest ones, while many Lagrangian subproblems need to be solved.&lt;/p&gt;&#xA;&lt;p&gt;There should also be a couple of possible optimizations such as keeping a common column pool for all subproblems.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-08-07T06:07:33.030" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10802" PostTypeId="2" ParentId="10083" CreationDate="2023-08-07T08:05:55.327" Score="1" Body="&lt;p&gt;It depends on what you want to achieve, but I would like to argue, contrary to the answer by @Merve Özer, that you &lt;em&gt;do not&lt;/em&gt; need to (explicitly) normalize the objectives.&lt;/p&gt;&#xA;&lt;p&gt;If you have, two objective functions &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt; and you want to bring &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt; into the same magnitude as &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt;, you would find a constant, say &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;, and multiply &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt; by this constant and obtain a new normalized objective &lt;span class=&quot;math-container&quot;&gt;$\tilde{f}_2(x)=\alpha f_2(x)$&lt;/span&gt;. Next you would create a weighted sum of &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\tilde{f}_2$&lt;/span&gt;, with weights &lt;span class=&quot;math-container&quot;&gt;$\tilde{w}_1,\tilde{w}_2&amp;gt;0$&lt;/span&gt;, and optimize this:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\min \tilde{w}_1f_1(x)+\tilde{w}_2\tilde{f}_2(x)&#xA;\end{equation}&lt;/span&gt;&#xA;This is simply the same as optimizing the weighted sum of the original objective functions with weights &lt;span class=&quot;math-container&quot;&gt;$w_1=\tilde{w}_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_2=\alpha \tilde{w}_2$&lt;/span&gt;. Hence, you should &amp;quot;just&amp;quot; find good weights for the original objectives.&lt;/p&gt;&#xA;&lt;p&gt;A further thing to observe is that some times it is advised to scale both objectives such that the set of non-dominated outcome vectors are contained in a (unit) hypercube. This will in many cases lead to numerical problems if larger values are &amp;quot;squeezed&amp;quot; into a small box.&lt;/p&gt;&#xA;&lt;p&gt;This answer relies on two assumptions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You want &lt;em&gt;a&lt;/em&gt; Pareto optimal solution to your multi objective optimisation problem, which is (only) guaranteed to be a supported efficient solution.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It is often very difficult, even after normalizing the objectives, to predict the characteristics of the resulting solution obtained after optimising the weighted sum scalarisation. For some problems, even small changes to the weights will lead to very different solutions. For others, large changes does not change the solution much.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="278" LastActivityDate="2023-08-07T08:05:55.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10804" PostTypeId="1" AcceptedAnswerId="10805" CreationDate="2023-08-07T13:23:06.667" Score="2" ViewCount="79" Body="&lt;p&gt;starting off with a MIP that I want to solve using Benders.&lt;/p&gt;&#xA;&lt;p&gt;so in Benders Decomposition, you add feasibility cuts in the following form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$v^j (b - Ax) \geq 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt; being the set of extreme rays of the dual solution space.&lt;/p&gt;&#xA;&lt;p&gt;While trying to understand the theory behind Benders, I am struggling to understand where the &lt;span class=&quot;math-container&quot;&gt;$\geq 0$&lt;/span&gt; comes from.&lt;/p&gt;&#xA;&lt;p&gt;Why do I to add these constraints to the reformulated master problem?&lt;/p&gt;&#xA;" OwnerUserId="12130" LastActivityDate="2023-08-07T15:33:28.437" Title="How do you derive the Benders feasibility cuts?" Tags="|mixed-integer-programming|duality|benders-decomposition|decomposition|extreme-rays|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10805" PostTypeId="2" ParentId="10804" CreationDate="2023-08-07T15:33:28.437" Score="3" Body="&lt;p&gt;In Benders, you pass a candidate solution to the master problem into an LP subproblem, where it affects the RHS of the LP constraints. That modified RHS is also the objective coefficient vector of the dual LP. Now suppose the master solution you passed in makes the primal subproblem infeasible. That will make the dual problem unbounded. (There are some edge cases where both primal and dual are infeasible, but I don't think they come up in Benders.) If your primal is maximizing (minimizing), your dual is minimizing (maximizing), and the dual being unbounded says there is an extreme dual ray along which the objective decreases (increases) forever.&lt;/p&gt;&#xA;&lt;p&gt;For a master solution to be feasible, the primal LP must be feasible and the dual LP must be bounded. So you create a constraint that says the rate of change along that ray of the dual objective value computed from any valid master solution has to be nonnegative (nonpositive), and add that constraint to the master problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-08-07T15:33:28.437" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10806" PostTypeId="1" AcceptedAnswerId="10807" CreationDate="2023-08-07T17:50:52.900" Score="2" ViewCount="101" Body="&lt;p&gt;I'm working with a statistical linear model where I have a variable, ( N ), representing the percentage of charging of a battery. Based on ( N ), I derive another variable, &lt;code&gt;Charging_level&lt;/code&gt;, with the following conditions:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;- If \( N = 0 \), `Charging_level = 0`.&#xA;- If \( 0 &amp;lt; N \leq 20 \), `Charging_level = 1`.&#xA;- If \( 20 &amp;lt; N \leq 40 \), `Charging_level = 2`.&#xA;- If \( 40 &amp;lt; N \leq 80 \), `Charging_level = 3`.&#xA;- If \( 80 &amp;lt; N \leq 100 \), `Charging_level = 4`.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have 4 distinct levels of charging: 1, 2, 3, and 4. The statiscal model use indicator variables (coefficients per level), where one level is set to 1 and the others are set to 0, and hence can provide prediction.&lt;/p&gt;&#xA;&lt;p&gt;I should note that I am optimizing over N (tradeoff between charging to full and other budget constraints), I'm seeking an efficient way to represent the &lt;code&gt;Charging_level&lt;/code&gt; variable. I've come across the Big-M method, which I know is used for basic if-else conditions, but I'm unsure how to apply it to my scenario with multiple levels.&lt;/p&gt;&#xA;&lt;p&gt;Is there a straightforward method for representing this multi-level categorical variable using the Big-M method? Or are there alternative approaches that might be more suitable?&lt;/p&gt;&#xA;" OwnerUserId="6016" LastEditorUserId="491" LastEditDate="2023-08-08T12:27:20.250" LastActivityDate="2023-08-08T12:27:20.250" Title="Representing a Multi-Level Categorical Variable using Big-M Method in Linear programming" Tags="|mixed-integer-programming|modeling|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10807" PostTypeId="2" ParentId="10806" CreationDate="2023-08-07T18:07:41.640" Score="3" Body="&lt;p&gt;Introduce a small constant tolerance &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt; and five binary decision variables &lt;span class=&quot;math-container&quot;&gt;$z_0,\dots,z_4$&lt;/span&gt;, and impose linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i=0}^4 z_i &amp;amp;=1 \\&#xA;0z_0+\epsilon z_1+(20+\epsilon)z_2+(40+\epsilon)z_3+&#xA;(80+\epsilon)z_4&#xA;\le N&#xA;&amp;amp;\le&#xA;0z_0+20z_1+40z_2+80z_3+&#xA;100z_4 \\&#xA;\sum_{i=0}^4 i z_i &amp;amp;=\text{Charging_level}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-08-07T18:07:41.640" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10808" PostTypeId="1" AcceptedAnswerId="10809" CreationDate="2023-08-08T10:08:23.803" Score="2" ViewCount="145" Body="&lt;p&gt;Consider a Linear Programme (LP)&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min &amp;amp;&amp;amp; \sum_{i \in I} c_i x_i \\&#xA;\text{s.t.} &amp;amp;&amp;amp; \sum_{i \in I} a_{ij} x_i &amp;amp;\geq b_j &amp;amp; \quad &amp;amp; \forall j \in J \\&#xA;&amp;amp;&amp;amp; x_i &amp;amp;\geq 0 &amp;amp; \quad &amp;amp; \forall i \in I&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assume you are solving this problem via column generation.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; be the value of the optimal solution of the &lt;strong&gt;reduced&lt;/strong&gt; problem (RLP), i.e., the problem obtained when only considering a subset of the variables, &lt;span class=&quot;math-container&quot;&gt;$I' \subsetneq I$&lt;/span&gt;.&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$\bar{c}$&lt;/span&gt; be the lowest reduced cost of a variable of &lt;span class=&quot;math-container&quot;&gt;$I' \setminus I$&lt;/span&gt; (i.e., which is not yet in RLP).&#xA;Note that &lt;span class=&quot;math-container&quot;&gt;$\bar{c} &amp;lt; 0$&lt;/span&gt; unless we are at the optimum.&#xA;Finally, assume that a convexity constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I} x_i \leq U$&lt;/span&gt; holds.&lt;/p&gt;&#xA;&lt;p&gt;The Lagrangian bound is a dual bound on the value of the optimum &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt; of LP and states that it cannot be improved by more than &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; times &lt;span class=&quot;math-container&quot;&gt;$\bar{c}$&lt;/span&gt;, i.e.,&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;z + U \cdot \bar{c} \leq z^* \leq z&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now assume that the set of variables can be partitioned as &lt;span class=&quot;math-container&quot;&gt;$I = I_1 \cup \ldots \cup I_k$&lt;/span&gt; and that new variables can be priced solving &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; independent subproblems.&#xA;Further assume that we have &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; convexity constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{i \in I_\ell} x_i \leq U_\ell \quad \forall \ell \in \{1, \ldots, k\}&#xA;\end{equation}&lt;/span&gt;&#xA;Denote with &lt;span class=&quot;math-container&quot;&gt;$\bar{c}_\ell$&lt;/span&gt; the lowest reduced cost given by pricing subproblem &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt;, i.e., the lowest reduced cost of a variable in &lt;span class=&quot;math-container&quot;&gt;$I_\ell \setminus I'$&lt;/span&gt;. Is it true that the following is a valid bound?&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;z + \sum_{\ell = 1}^k U_\ell \cdot \bar{c}_\ell \leq z^* \leq z&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="12215" LastEditorUserId="500" LastEditDate="2023-08-08T11:05:39.643" LastActivityDate="2023-08-08T12:02:29.270" Title="Can one strengthen the Lagrangian dual bound in column generation when there are multiple subproblems?" Tags="|linear-programming|column-generation|reduced-costs|pricing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10809" PostTypeId="2" ParentId="10808" CreationDate="2023-08-08T11:03:19.633" Score="4" Body="&lt;p&gt;Yes, that bound is valid, and you can prove it by exhibiting a dual feasible solution with that objective value. I don’t have my copy handy, but Wolsey’s &lt;em&gt;Integer Programming&lt;/em&gt; shows this. In fact, the bound is still valid even if &lt;span class=&quot;math-container&quot;&gt;$\bar{c}_\ell$&lt;/span&gt; is only a lower bound on the objective value of subproblem &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt;. That is, you can obtain a valid bound even if you stop solving a subproblem early, as is common when the subproblem is MILP instead of LP.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-08-08T12:02:29.270" LastActivityDate="2023-08-08T12:02:29.270" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10810" PostTypeId="2" ParentId="10739" CreationDate="2023-08-08T16:35:13.553" Score="3" Body="&lt;p&gt;Using Hexaly Optimizer, we can confirm the elegant interpretation and solution given by Rob:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function model() {&#xA;&#xA;  PI = 3.141592; &#xA;  N = 16;&#xA;  F1 = 28;&#xA;&#xA;  t[k in 1..N] &amp;lt;- float(-1,1);&#xA;  phi[k in 1..N] &amp;lt;- float(-2*PI,2*PI); &#xA;&#xA;  obj &amp;lt;- pow(sum[k in 1..N]( cos(2*PI*F1*t[k] + phi[k] + PI*(k-1) )),2) &#xA;    + pow(sum[k in 1..N]( sin(2*PI*F1*t[k] + phi[k] + PI*(k-1) )),2); &#xA;&#xA;  maximize obj;&#xA;}&#xA;&#xA;function output() {&#xA;  for[k in 1..N]&#xA;    println(&amp;quot;t[&amp;quot; + k + &amp;quot;] = &amp;quot; + t[k].value + &amp;quot; phi[&amp;quot; + k + &amp;quot;] = &amp;quot; + phi[k].value);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here is the Hexaly resolution log with a time limit of 10 seconds:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; hexaly .\orse.lsp lsTimeLimit=10&#xA;Hexaly 12.0.20230721-Win64. All rights reserved.&#xA;&#xA;Model:  expressions = 153, decisions = 32, constraints = 0, objectives = 1&#xA;Param:  time limit = 10 sec, no iteration limit&#xA;&#xA;[objective direction ]:     maximize&#xA;&#xA;[  0 sec,       0 itr]:  2.73395e-11&#xA;[ optimality gap     ]:      100.00%&#xA;[  1 sec,  161011 itr]:          256&#xA;[  2 sec,  408305 itr]:          256&#xA;[  3 sec,  640000 itr]:          256&#xA;[  4 sec,  880000 itr]:          256&#xA;[  5 sec, 1126904 itr]:          256&#xA;[  6 sec, 1372096 itr]:          256&#xA;[  7 sec, 1614615 itr]:          256&#xA;[  8 sec, 1849999 itr]:          256&#xA;[  9 sec, 2092157 itr]:          256&#xA;[ 10 sec, 2092157 itr]:          256&#xA;[ optimality gap     ]:       50.00%&#xA;[ 10 sec, 2332052 itr]:          256&#xA;[ optimality gap     ]:       50.00%&#xA;&#xA;2332052 iterations performed in 10 seconds&#xA;&#xA;Feasible solution:&#xA;  obj    =          256&#xA;  gap    =       50.00%&#xA;  bounds =          512&#xA;&#xA;Run output...&#xA;t[1] = 0.21471180063292 phi[1] = 0.0832646843060022&#xA;t[2] = 0.156390289371164 phi[2] = 0.918941396765761&#xA;t[3] = 0.610083475245977 phi[3] = -0.359099069033989&#xA;t[4] = -0.443873802890364 phi[4] = -0.29125479048723&#xA;t[5] = 0.99999998607111 phi[5] = 0.158259516856785&#xA;t[6] = -0.621006854721066 phi[6] = -0.544312419458254&#xA;t[7] = 0.323496907222156 phi[7] = -0.205647025090234&#xA;t[8] = 0.485645652482093 phi[8] = -0.458003740637076&#xA;t[9] = 0.78707054858743 phi[9] = -0.0803543395208796&#xA;t[10] = -0.477971981549317 phi[10] = -0.575572519914052&#xA;t[11] = -0.316888915678176 phi[11] = -0.640445164286173&#xA;t[12] = 0.411307335221625 phi[12] = 0.0539053761039563&#xA;t[13] = 0.542077136903721 phi[13] = -0.961165712317072&#xA;t[14] = -0.517353397473377 phi[14] = 0.0695838953447903&#xA;t[15] = 0.465791702245212 phi[15] = -0.106703190073651&#xA;t[16] = 0.548882822090854 phi[16] = 0.983110478290966&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Disclaimer: Hexaly is a commercial mathematical optimization solver.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="3391" LastEditorUserId="3391" LastEditDate="2023-12-05T02:50:49.997" LastActivityDate="2023-12-05T02:50:49.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10811" PostTypeId="1" AcceptedAnswerId="10819" CreationDate="2023-08-08T18:21:56.390" Score="1" ViewCount="119" Body="&lt;p&gt;I'm currently working on an optimization problem where I'm using Benders decomposition to solve a complex problem involving the installation of charging stations. The master problem determines the placement of charging stations, while the subproblem involves optimal power flow. I've encountered an issue with subproblem infeasibility despite using feasibility cuts.&lt;/p&gt;&#xA;&lt;p&gt;Here's an overview of my approach and the formulation of my feasibility cut:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I've fixed decision variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,t}$&lt;/span&gt; in the master problem, which determine the number of charging stations to be installed at location bus &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; of type &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The primal subproblem is presented in its canonical form, and I've provided the associated dual variables next to each constraint. I transformed each equality constrained to two inequality constraints.&lt;/li&gt;&#xA;&lt;li&gt;I've formulated a feasibility cut. This cut is derived from the extreme ray values of the subproblem's dual variables.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This is the linear subproblem where &lt;span class=&quot;math-container&quot;&gt;$P_k^g,Q_k^g,P_{ij},Q_{ij},V_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\delta_i$&lt;/span&gt; are continuous decision variables:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$min \sum_{k\in G}\left( C_{1,k} P_{k}^{g} +C_{0,k}\right)$$&lt;/span&gt;&#xA;S.t.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$P_{k}^{g} \geq P_{k}^{gl} \quad \forall k\in G \qquad _{k} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-P_{k}^{g} \geq -P_{k}^{gu} \quad \forall k\in G \qquad _{k}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Q_{k}^{g} \geq Q_{k}^{gl} \quad \forall k\in G \qquad \epsilon_{k}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-Q_{k}^{g} \geq -Q_{k}^{gu} \quad \forall k\in G \qquad \zeta_{k}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V_{i} \geq  v_{i}^{l} \quad \forall i\in N \qquad \eta_{i}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-V_{i} \geq - v_{i}^{u} \quad \forall i\in N \qquad \tau_{i}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-\delta_{i} +\delta_{j} \geq -\theta_{ij}^{\Delta u} \quad \forall ( i,j) \in E \qquad \xi_{ij}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\delta_{i} -\delta_{j} \geq \theta_{ij}^{\Delta l} \quad \forall ( i,j) \in E \qquad \omicron_{ij}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k\in G_{i}} P_{k}^{g} -\sum_{( i,j) \in E_i} P_{ij} \geq \sum_{k\in L_{i}} P_{k}^{d} +\sum_{t\in T} P_{t}^{cs}\overline{x_{i,t}} \quad \forall i\in N \qquad \iota_{i}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-\sum_{k\in G_{i}} P_{k}^{g} +\sum_{( i,j) \in E_i} P_{ij} \geq -\sum_{k\in L_{i}} P_{k}^{d} -\sum_{t\in T} P_{t}^{cs}\overline{x_{i,t}} \quad \forall i\in N \qquad \kappa_{i}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k\in G_{i}} Q_{k}^{g} -\sum_{( i,j) \in E_{i}} Q_{ij} \geq \sum_{k\in L_{i}} Q_{k}^{d} \quad \forall i\in N \qquad \lambda_{i}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-\sum_{k\in G_{i}} Q_{k}^{g} +\sum_{( i,j) \in E_{i}} Q_{ij} \geq -\sum_{k\in L_{i}} Q_{k}^{d} \quad \forall i\in N \qquad \mu_{i}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$P_{ij} -( V_{i} -V_{j})  G_{ij} +B_{ij}  ( \delta_{i} -\delta_{j}) \geq 0 \quad \forall ( i,j) \in E \qquad \rho_{ij}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-P_{ij} +( V_{i} -V_{j})  G_{ij} -B_{ij}  ( \delta_{i} -\delta_{j}) \geq 0 \quad \forall ( i,j) \in E \qquad \sigma_{ij}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Q_{ij} -( V_{j} -V_{i})  B_{ij} +G_{ij}  ( \delta_{i} -\delta_{j}) \geq 0 \qquad \forall ( i,j) \in E \qquad \upsilon_{ij}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-Q_{ij} +( V_{j} -V_{i})  B_{ij} -G_{ij}  ( \delta_{i} -\delta_{j}) \geq 0 \quad \forall ( i,j) \in E \qquad \omega_{ij}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Multiplying the RHS of each constraint with its dual variable, should give the objective function of the dual of the subproblem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ max \sum_{k\in G} ( P_{k}^{gl}  \gamma_{k} -P_{k}^{gu}  \psi_{k} +Q_{k}^{gl}  \epsilon_{k} -Q_{k}^{gu}  \zeta_{k}) +\sum_{i\in N}( v_{i}^{l} \eta_{i} - v_{i}^{u}  \tau_{i}) +\sum_{i\in N} ((\sum_{k\in L_{i}} P_{k}^{d} +\sum_{t\in T} P_{t}^{cs}\overline{x_{i,t}})  \iota_{i} -(\sum_{k\in L_{i}} P_{k}^{d} +\sum_{t\in T} P_{t}^{cs}\overline{x_{i,t}})  \kappa_{i}) +\sum_{i\in N}(\sum_{k\in L_{i}} Q_{k}^{d}  \lambda_{i}  -\sum_{k\in L_{i}} Q_{k}^{d}  \mu_{i}) +\sum_{( i,j) \in E}( \theta_{ij}^{\Delta l} \omicron_{ij} -\theta_{ij}^{\Delta u} \xi_{ij})&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I've implemented this approach using JuMP with Julia and Gurobi as the solver. I retrieve the dual extreme ray values using &lt;code&gt;JuMP.shadow_price(ConstraintRef)&lt;/code&gt;. As for now, I follow the classical approach without lazy constraints to test the implementation.&#xA;My understanding is that I should directly incorporate the extreme ray values obtained from the unbounded dual of the subproblem into the objective function of the dual of the subproblem. This results in the following feasibility cut:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{k\in G}\left( P_{k}^{gl}  \overline{\gamma_{k}} -P_{k}^{gu}  \overline{\psi_{k}} +Q_{k}^{gl}  \overline{\epsilon_{k}} -Q_{k}^{gu}  \overline{\zeta_{k}}\right) +\sum_{i\in N}\left( v_{i}^{l}  \overline{ \eta_{i}} - v_{i}^{u}  \overline{\tau_{i}}\right) +\sum_{i\in N}\left(\left(\sum_{k\in L_{i}} P_{k}^{d} +\sum_{t\in T} P_{t}^{cs} x_{i,t}  \right)\overline{ \iota_{i}} -\left(\sum_{k\in L_{i}} P_{k}^{d} +\sum_{t\in T} P_{t}^{cs} x_{i,t}\right)  \overline{\kappa_{i}}\right) +\sum_{i\in N}\left(\sum_{k\in L_{i}} Q_{k}^{d}  \overline{\lambda_{i}}  -\sum_{k\in L_{i}} Q_{k}^{d}  \overline{\mu_{i}}\right) +\sum_{( i,j) \in E}\left( \theta_{ij}^{\Delta l}  \overline{\omicron_{ij}} -\theta_{ij}^{\Delta u} \overline{\xi_{ij}}\right) \leq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, the master problem still propagates the same infeasible solution to the subproblem in subsequent iterations.&lt;/p&gt;&#xA;&lt;p&gt;I'm looking for insights into why this feasibility cut is not effectively cutting away the infeasible solution from the master problem. Are there any potential mistakes in the formulation or any suggestions on how to improve the feasibility cut?&lt;/p&gt;&#xA;" OwnerUserId="12253" LastEditorUserId="500" LastEditDate="2023-08-11T13:19:09.830" LastActivityDate="2023-08-11T13:19:09.830" Title="Persisting Subproblem Infeasibility Benders Decomposition" Tags="|mixed-integer-programming|combinatorial-optimization|duality|benders-decomposition|jump|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10812" PostTypeId="1" CreationDate="2023-08-09T09:14:21.517" Score="0" ViewCount="76" Body="&lt;p&gt;I am working on an optimization problem where I aim to maximize revenue. My current model has the following objective function:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ Sales(P_i) * log(P_i - const_i))$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$P_i$&lt;/span&gt; represents the price of product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&#xA;The Sales function is a mixed integer linear function due to the inclusion of some categorical variables. I should note also that Sales function, which is linear, is modeled to predict the log of sales (a common practice in econometrics) hence the need to log the unit margin part in order to obtain the true optimum.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to transform this objective function into a quadratic form so I can use quadratic solvers? If not, is there any approximation that I can do?&lt;/p&gt;&#xA;" OwnerUserId="6016" LastEditorUserId="491" LastEditDate="2023-08-09T12:44:30.833" LastActivityDate="2023-08-10T12:18:50.970" Title="Optimize revenue function with log part" Tags="|mixed-integer-programming|modeling|linearization|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10813" PostTypeId="2" ParentId="10755" CreationDate="2023-08-09T16:25:30.413" Score="1" Body="&lt;p&gt;In case someone has a similar problem, I wanted to add an answer.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}_1 := \{x : \lVert x \rVert \leq c \}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}_2 : = \{x : \lVert x -t \rVert \leq c' \} $&lt;/span&gt;. So our problem is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sup_{x \in \mathcal{S}_1 \cap \mathcal{S}_2} z^\top x.$$&lt;/span&gt;&#xA;Any book covering Robust Optimization shows that such a problem is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \inf_{z^1, z^2} \{\delta^{*} (z^1 \mid \mathcal{S}_1) + \delta^{*} (z^2 \mid \mathcal{S}_2) \ : \ z^1 + z^2 = z\},$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\delta^{*}(\cdot | \mathcal{S})$&lt;/span&gt; denotes the support function of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}$&lt;/span&gt;, which is the convex conjugate of the indicator function taking value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; only for elements of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}$&lt;/span&gt;. We can write &lt;span class=&quot;math-container&quot;&gt;$\delta^{*}(z \mid \mathcal{S}) = \sup_{x \in \mathcal{S}} z^\top x$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}$&lt;/span&gt; of suitable dimensions.&lt;/p&gt;&#xA;&lt;p&gt;Now, notice that&#xA;&lt;span class=&quot;math-container&quot;&gt;$\delta^{*} (z^1 \mid \mathcal{S}_1) = \sup_{x:  \lVert x\rVert\leq c} x^\top z^1 = c\cdot\lVert z^1 \Vert_{*} $&lt;/span&gt; by the definition of the dual norm &lt;span class=&quot;math-container&quot;&gt;$\lVert \cdot \rVert_{*}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, &lt;span class=&quot;math-container&quot;&gt;$\delta^{*} (z^2 \mid \mathcal{S}_2) =  \sup_{x:  \lVert x-t \rVert\leq c'} x^\top z^2  = t^\top z^2 + \sup_{x:  \lVert x \rVert\leq c'} x^\top z^2 = t^\top z^2 + c' \cdot \lVert z^2\rVert_{*}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The problem is thus equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \inf_{z^1, z^2} \{t^\top z^2 + c\cdot\lVert z^1 \Vert_{*} + c' \cdot \lVert z^2\rVert_{*} \ : \ z^1 + z^2 = z\} $$&lt;/span&gt;&#xA;and substituting variables gives&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \inf_{z^2} \{t^\top z' + c\cdot\lVert z - z' \Vert_{*} + c' \cdot \lVert z'\rVert_{*}\}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2023-08-09T16:25:30.413" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10814" PostTypeId="2" ParentId="10771" CreationDate="2023-08-10T09:40:50.743" Score="2" Body="&lt;p&gt;You solve the pricing problem using the smoothed dual values, but then you analyse the reduced cost of obtained columns using original dual values (i.e., those coming from the master LP). If the column is already in the pool, it means that the original reduced cost is non-negative, and one does not usually add this column to the master LP. If all obtained columns have non-negative original reduced cost, then the so-called &lt;em&gt;misprice&lt;/em&gt; happens, and one should solve the pricing problem again with different dual values (either original dual values or dual values smoothed with a different coefficient).&lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2023-08-10T09:40:50.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10816" PostTypeId="1" CreationDate="2023-08-10T13:58:42.637" Score="0" ViewCount="33" Body="&lt;p&gt;I reformulated the logical constraint &lt;span class=&quot;math-container&quot;&gt;$x =   \min\{y,z\}$&lt;/span&gt; as this MILP problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;x &amp;amp;\leq y \\&#xA;x &amp;amp;\leq z \\&#xA;x &amp;amp;\geq y-M(1-w) \\&#xA;x &amp;amp;\geq z-Mw&#xA;\end{array}&#xA;$$&lt;/span&gt;&#xA;in which &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a large positive constant and &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is a binary variable. Let &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; be a continuous variable and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; be the uncertain parameter.&#xA;Now, if I want to write the main constraint as a probabilistic constraint, I will have &lt;span class=&quot;math-container&quot;&gt;$\mathbb{P}(\text{set of four constraints})\geq 1-\epsilon$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;strong&gt;first question&lt;/strong&gt; is whether this chance constraint is joint and not single, and the &lt;strong&gt;second question&lt;/strong&gt; is since the main variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; has both lower and upper bounds (but with different values and not with the same value with the opposite sign), is it two-sided and not one-sided?&lt;/p&gt;&#xA;" OwnerUserId="12264" LastEditorUserId="12264" LastEditDate="2023-08-10T15:33:42.287" LastActivityDate="2023-08-10T15:33:42.287" Title="Joint, two-sided chance constraint of MILP reformulation of a logical constrain" Tags="|mixed-integer-programming|logical-constraints|chance-constraints|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10817" PostTypeId="2" ParentId="10811" CreationDate="2023-08-10T16:09:50.770" Score="0" Body="&lt;p&gt;Disclaimer #1: I did not check your formulation of the dual problem and the Benders cut carefully. It looks plausible, but the density of the notation made my eyes water.&lt;/p&gt;&#xA;&lt;p&gt;Disclaimer #2: I'm not a JuMP user. You'll need to check what I'm about to say with someone who is.&lt;/p&gt;&#xA;&lt;p&gt;I suspect you may be calling the wrong function. When a solver detects an unbounded LP, it typically is sitting at an extreme point of the feasible region looking at an edge in a desirable direction that extends forever. The dual &lt;em&gt;solution&lt;/em&gt; (which is what I suspect the shadow_price() function returns, based on its name) is distinct form the dual &lt;em&gt;ray&lt;/em&gt; (the direction of that edge). If I'm right, you need to find a function that returns the ray.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-08-10T16:09:50.770" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10818" PostTypeId="2" ParentId="9295" CreationDate="2023-08-10T16:59:25.590" Score="1" Body="&lt;p&gt;To run CPLEX on MacOS use the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    solver = SolverFactory('cplex', executable = '/Applications/CPLEX_Studio2211/cplex/bin/x86-64_osx/cplex')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12267" LastActivityDate="2023-08-10T16:59:25.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10819" PostTypeId="2" ParentId="10811" CreationDate="2023-08-11T13:10:29.307" Score="1" Body="&lt;p&gt;After some trial and error, I fixed the following two problems:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem 1&lt;/strong&gt;: the formulation provided here is indeed correct as mentioned above, but I forgot to add bounds on the variables &lt;span class=&quot;math-container&quot;&gt;$P_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q_{ij}$&lt;/span&gt;. This results in additional dual variables that should be added to the feasibility cut.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem 2&lt;/strong&gt;: the function &lt;code&gt;JuMP.shadow_price()&lt;/code&gt; returns the wrong values (see &lt;a href=&quot;https://discourse.julialang.org/t/benders-subproblem-infeasibility/102622&quot; rel=&quot;nofollow noreferrer&quot;&gt;Benders Subproblem Infeasibility&lt;/a&gt;). Use &lt;code&gt;JuMP.dual()&lt;/code&gt; to get the correct dual extreme ray values.&lt;/p&gt;&#xA;" OwnerUserId="12253" LastActivityDate="2023-08-11T13:10:29.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10820" PostTypeId="1" CreationDate="2023-08-11T13:25:43.400" Score="2" ViewCount="153" Body="&lt;p&gt;I am playing around with the game called &lt;a href=&quot;https://en.wikipedia.org/wiki/Set_%28card_game%29#:%7E:text=Basic%20combinatorics%20of%20Set&quot; rel=&quot;nofollow noreferrer&quot;&gt;Set&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In the game, certain combinations of three cards are said to make up a&#xA;&amp;quot;set&amp;quot;. For each one of the four categories of features — color,&#xA;number, shape, and shading — the three cards must display that feature&#xA;as either a) all the same, or b) all different. Put another way: For&#xA;each feature the three cards must avoid having two cards showing one&#xA;version of the feature and the remaining card showing a different&#xA;version.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Given the &lt;span class=&quot;math-container&quot;&gt;$81$&lt;/span&gt; cards of the game, is it possible to generate the&#xA;possible different sets of the game with a MIP (or a sequence of&#xA;MIPs)?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Follow up question is posted &lt;a href=&quot;https://or.stackexchange.com/questions/10827/set-game-how-to-generate-decks-of-12-cards-with-6-hidden-sets/10828#10828&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12269" LastEditorUserId="2556" LastEditDate="2023-08-12T08:36:01.420" LastActivityDate="2023-08-12T08:36:01.420" Title="SET game: how to generate all sets with a MIP?" Tags="|mixed-integer-programming|modeling|constraint|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10821" PostTypeId="1" AcceptedAnswerId="10822" CreationDate="2023-08-11T16:03:01.267" Score="2" ViewCount="132" Body="&lt;p&gt;I have a scheduling problem.&#xA;20 hours of work load should be assigned to different days (max 4 days are available and the capacity of ech day is 8 hours max)&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_i h_i = 20$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \leq h_i \leq 8$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Gh77R.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Gh77R.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The following picture shows the desirable and undesirable ways of assignment.&#xA;How can I mathematically formulate it as MILP to use minimum number of days and fill them from left to right (using all capacity) ?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LSgrV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LSgrV.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="500" LastEditDate="2023-08-11T16:15:46.490" LastActivityDate="2023-09-15T17:26:31.477" Title="How to fill the days in sequence?" Tags="|optimization|mixed-integer-programming|modeling|scheduling|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10822" PostTypeId="2" ParentId="10821" CreationDate="2023-08-11T16:15:23.380" Score="3" Body="&lt;p&gt;You want to enforce &lt;span class=&quot;math-container&quot;&gt;$h_i &amp;gt; 0 \implies h_{i-1} = 8$&lt;/span&gt;.  You can do so by introducing binary variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;h_i &amp;gt; 0 &amp;amp;\implies x_i = 1 \\&#xA;x_i = 1 &amp;amp;\implies h_{i-1} = 8&#xA;\end{align}&lt;/span&gt;&#xA;which you can linearize as:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;h_i &amp;amp;\le 8 x_i \\&#xA;8 - h_{i-1} &amp;amp;\le 8(1-x_i)&#xA;\end{align}&lt;/span&gt;&#xA;More compactly:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$8 x_{i+1} \le h_i \le 8 x_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The exact total workload should be distributed in different days :&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i h_i =20$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="4775" LastEditDate="2023-08-12T03:24:19.050" LastActivityDate="2023-08-12T03:24:19.050" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10823" PostTypeId="2" ParentId="10821" CreationDate="2023-08-11T17:13:14.267" Score="1" Body="&lt;p&gt;If the work load can be discretized, you could model this like a bin &lt;a href=&quot;https://en.wikipedia.org/wiki/Bin_packing_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;packing problem&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If the time granularity is for example the hour, let &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if hour &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. And let &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is &amp;quot;used&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;You want to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_j y_j$&lt;/span&gt; subject to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each hour must be assigned to a day:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j} x_{ij}=1 \quad \forall i&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Each day has a maximum of &lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt; hours available:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i} x_{ij}\le 8y_j \quad \forall j&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; cannot be used if day &lt;span class=&quot;math-container&quot;&gt;$j-1$&lt;/span&gt; is not:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_j \le y_{j-1} \quad \forall j&amp;gt;1&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Capacity must be saturated before using a new day:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_i x_{ij}\ge 8y_{j+1} \quad \forall j\neq 4&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-08-11T17:39:21.813" LastActivityDate="2023-08-11T17:39:21.813" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10824" PostTypeId="2" ParentId="10821" CreationDate="2023-08-11T17:29:34.997" Score="1" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ -20x_i \le 20-\sum_{d}^{i-1} h_d - 8 \le 20(1-x_i)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ 8(1-x_i) \le h_i \le 20-\sum_{d}^{i-1} h_d $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is a binary&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-08-11T17:29:34.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10825" PostTypeId="1" CreationDate="2023-08-11T18:02:59.870" Score="1" ViewCount="45" Body="&lt;p&gt;I am trying to solve a multi objective optimization problem. It has 5 objectives. I am able to do optimization using NSGA2 algorithm of &lt;code&gt;pymoo&lt;/code&gt; library in python. After that I want to fetch top N individuals from the optimal offspring/ individual population.&lt;/p&gt;&#xA;&lt;p&gt;NSGA2 provides pareto optimal solutions. These are trade off solutions where none of the individual solution dominates any other solution. Finally we need to find a decision point. In my case I want to find N decision points.&lt;/p&gt;&#xA;&lt;p&gt;For now I have thought of using Topsis algorithm in &lt;code&gt;pymcdm&lt;/code&gt; to rank the individual solutions and then take the top N individuals. Is this approach correct ?&lt;/p&gt;&#xA;" OwnerUserId="11800" LastEditorUserId="11800" LastEditDate="2023-08-13T18:17:03.960" LastActivityDate="2023-08-13T18:17:03.960" Title="Rank individuals of population after multi objective optimization using MCDM algorithm" Tags="|multi-objective-optimization|multicriteria-decision-analysis|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10826" PostTypeId="2" ParentId="10820" CreationDate="2023-08-11T18:09:14.853" Score="4" Body="&lt;p&gt;Let me start with the advisory that &amp;quot;can do&amp;quot; and &amp;quot;should do&amp;quot; are distinct concepts. We can find all 1,080 sets in a full deck using an integer programming model ... or a constraint programming model ... or brute force. I think that list is in ascending order of speed.&lt;/p&gt;&#xA;&lt;p&gt;For the IP approach, define the following variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_c=1$&lt;/span&gt; if card &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is included in the set, 0 if not;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{f,v}=1$&lt;/span&gt; if value &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; of feature &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; appears in the set; and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_f=1$&lt;/span&gt; if feature &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is all different in the set and 0 if all the same.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The objective function is irrelevant, so we can minimize 0.&lt;/p&gt;&#xA;&lt;p&gt;Constraints are as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Exactly three cards must be in the set: &lt;span class=&quot;math-container&quot;&gt;$$\sum_c x_c = 3.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;For each feature, either one or three values must be present: &lt;span class=&quot;math-container&quot;&gt;$$\sum_v y_{f,v} = 1 + 2z_f\quad \forall f.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;A value of a feature appears in the set if and only if a card with that value is included in the set: &lt;span class=&quot;math-container&quot;&gt;$$y_{f,v} \ge x_c\quad \forall c\in C_{f,v}$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$y_{f,v} \le \sum_{c\in C_{f,v}} x_c.$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$C_{f,v}$&lt;/span&gt; denotes the set of cards with value &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; of feature &lt;span class=&quot;math-container&quot;&gt;$f.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Solving the model finds a single valid set. To avoid repeating the set, after getting a solution &lt;span class=&quot;math-container&quot;&gt;$(\bar{x}, \bar{y}, \bar{z})$&lt;/span&gt; we add a &amp;quot;no good&amp;quot; constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{c : \bar{x}_c =1} x_c \le 2$$&lt;/span&gt; and then solve again. After finding 1,080 solutions, the model becomes infeasible.&lt;/p&gt;&#xA;&lt;p&gt;If your IP solver supports callbacks, rather than solving 1,081 models you can solve one model, adding the no good constraints via callback (and in the process rejecting the solutions that generated the constraints), again until the problem becomes infeasible.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum:&lt;/strong&gt; I tried this in Java using CPLEX 22.1.1. Brute force enumeration (done recursively) required about 0.1 seconds. Using a single IP model with a generic callback (and limiting CPLEX to one thread so that I didn't have to deal with thread-safety problems) took about 1.4 seconds (so roughly an order of magnitude slower). Solving an IP model over and over while adding constraints took about 56 seconds.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Addendum 2:&lt;/strong&gt; I tried CP Optimizer 22.1.1 (constraint programming solver), and it found all 1,080 solutions in about 0.1 seconds, roughly tying it with brute force.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2023-08-11T22:27:33.250" LastActivityDate="2023-08-11T22:27:33.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10827" PostTypeId="1" CreationDate="2023-08-12T08:31:31.280" Score="1" ViewCount="40" Body="&lt;p&gt;This question was initially the second part of &lt;a href=&quot;https://or.stackexchange.com/questions/10820/how-to-generate-feasible-sets-with-a-mip&quot;&gt;another question&lt;/a&gt; and justifies a new post.&lt;/p&gt;&#xA;&lt;p&gt;The context is a game called &lt;a href=&quot;https://en.wikipedia.org/wiki/Set_%28card_game%29#:%7E:text=Basic%20combinatorics%20of%20Set&quot; rel=&quot;nofollow noreferrer&quot;&gt;Set&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In the game, certain combinations of three cards are said to make up a&#xA;&amp;quot;set&amp;quot;. For each one of the four categories of features — color,&#xA;number, shape, and shading — the three cards must display that feature&#xA;as either a) all the same, or b) all different. Put another way: For&#xA;each feature the three cards must avoid having two cards showing one&#xA;version of the feature and the remaining card showing a different&#xA;version.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Apps online generate decks of &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; cards with exactly &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; hidden sets. The goal is to find the &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; hidden sets, and once all &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; are found, a new deck of 12 cards is generated, with &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; hidden sets. And so forth.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to generate such decks with a MIP?&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-08-12T14:12:46.073" LastActivityDate="2023-08-12T20:42:45.957" Title="SET game: how to generate decks of 12 cards with 6 hidden sets?" Tags="|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10828" PostTypeId="2" ParentId="10827" CreationDate="2023-08-12T08:34:28.160" Score="1" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt; be the set of all the &lt;em&gt;sets&lt;/em&gt;, and let &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; the complete deck of cards. Let &lt;span class=&quot;math-container&quot;&gt;$y_s$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if set &lt;span class=&quot;math-container&quot;&gt;$s \in \Omega$&lt;/span&gt; is used. And let &lt;span class=&quot;math-container&quot;&gt;$x_c$&lt;/span&gt; be a binary variable that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if and only if card &lt;span class=&quot;math-container&quot;&gt;$c\in C$&lt;/span&gt; is used.&lt;/p&gt;&#xA;&lt;p&gt;To generate a deck of &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; cards with &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; sets, minimize a dummy objective function subject to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The deck must have &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; cards:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{c\in C} x_c = 12 &#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;The deck must have &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; sets:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{s\in \Omega} y_s= 6 &#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If set &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is selected, then cards from this set are selected:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_s\le x_c \quad \forall s\in \Omega, \quad\forall c \in s &#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If a set &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is not selected, then its &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; cards can not be selected (courtesy of @prubin):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{c\in s}x_c \le 2+y_s \quad \forall s \in \Omega&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To generate a new deck given a solution &lt;span class=&quot;math-container&quot;&gt;$\hat{y}$&lt;/span&gt;, you can add a no good cut:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{s\in \Omega|\hat{y_s}=1}y_s \le 5&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that brute force would require generating decks from the &lt;span class=&quot;math-container&quot;&gt;$\binom{81}{12}=7.07243201847 × 10^{13}$&lt;/span&gt; possible decks of &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; cards, and checking if they contain &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; of the &lt;span class=&quot;math-container&quot;&gt;$1 080$&lt;/span&gt; sets.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-08-12T20:42:45.957" LastActivityDate="2023-08-12T20:42:45.957" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10829" PostTypeId="1" CreationDate="2023-08-12T12:03:18.210" Score="5" ViewCount="130" Body="&lt;p&gt;I am solving a mixed-integer program whose decision variables are &lt;span class=&quot;math-container&quot;&gt;$x \in \{0, 1\}^n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{R}^m$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$0 \leq y_j \leq u_j$&lt;/span&gt; for constant upper bounds.&lt;/p&gt;&#xA;&lt;p&gt;My primary objective function is of the form&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\text{minimize } \sum_{i=1}^n c_i x_i&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where each &lt;span class=&quot;math-container&quot;&gt;$c_i &amp;gt; 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, under the constraints for this problem, it turns out that there are many equivalent optimal solutions for this objective, and the solver typically finds an optimum quickly and then spends a long time iterating on dual bounds to prove its optimality.&lt;/p&gt;&#xA;&lt;p&gt;To compensate for this, I want to to use an objective of the following form as a &amp;quot;tiebreaker&amp;quot;—that is, of the set of solutions that minimize &lt;span class=&quot;math-container&quot;&gt;$c^T x$&lt;/span&gt;, I want to select the one that minimizes&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j=1}^m d_j y_j&#xA;$$&lt;/span&gt;&#xA;where each &lt;span class=&quot;math-container&quot;&gt;$d_j &amp;gt; 0$&lt;/span&gt;. (Actually, all I really care about is the 1-norm sparsity of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, so you  can assume &lt;span class=&quot;math-container&quot;&gt;$d_j = 1$&lt;/span&gt; if that helps at all.)&lt;/p&gt;&#xA;&lt;p&gt;At a first glance, one way to accomplish this optimization objective would be as follows:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get the solution that minimizes &lt;span class=&quot;math-container&quot;&gt;$c^T x$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; denote the associated objective value.&lt;/li&gt;&#xA;&lt;li&gt;Solve the MILP again, but change the objective function to &lt;span class=&quot;math-container&quot;&gt;$d^T y$&lt;/span&gt; and impose the constraint &lt;span class=&quot;math-container&quot;&gt;$c^T x \leq z$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I have two problems with this approach:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;In step 1, we know from experience that it takes the solver a long time to prove optimality with respect to &lt;span class=&quot;math-container&quot;&gt;$c^T x$&lt;/span&gt;, and we are not exploiting our secondary preference to accelerate this process.&lt;/li&gt;&#xA;&lt;li&gt;In step 2, it would be ideal to reuse the optimal solution from the previous step as a warm start, but I am required to use Google's OR-Tools (which doesn't provide a warm start API), so this step will take a long time.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;So, I am considering adopting the following approach instead:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\bar c = \min \{c_i - c_j : c_i - c_j &amp;gt; 0\}$&lt;/span&gt; equal the smallest positive difference among the &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;. This represents a lower bound on the difference between &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and the objective value of any feasible solution that is &lt;em&gt;not&lt;/em&gt; optimal.&lt;/li&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\hat d = \sum d_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\hat u = \sum u_j$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Solve the whole thing in one shot by minimizing &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n c_i x_i + \frac{\bar c}{\hat d \hat u}\sum_{j=1}^n d_j y_j .$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The constants in the the second term confine its value to the range &lt;span class=&quot;math-container&quot;&gt;$[0, \bar c]$&lt;/span&gt;, meaning that the first term must be optimized before the second has any effect.&lt;/p&gt;&#xA;&lt;p&gt;The risk of this approach is that for large &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, the coefficients on the &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; will be very small relative to the &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;, and the problem may be poorly conditioned.&lt;/p&gt;&#xA;&lt;p&gt;My question is, &lt;strong&gt;is this approach valid, and is it possible to mitigate the risk of numerical instability for large &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Edit: I don't think the approach is valid to begin with: If &lt;span class=&quot;math-container&quot;&gt;$c_1 = 2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_2 = 0.99$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$c_3 = 0.99$&lt;/span&gt;, then we get &lt;span class=&quot;math-container&quot;&gt;$\bar c = 1.01$&lt;/span&gt;, but the solutions &lt;span class=&quot;math-container&quot;&gt;$x = (1, 0, 0)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x = (0, 1, 1)$&lt;/span&gt; differ in objective value by only &lt;span class=&quot;math-container&quot;&gt;$0.02 &amp;lt; \bar c$&lt;/span&gt; (assuming they are feasible).&lt;/p&gt;&#xA;&lt;p&gt;The question of how to do this lexicographic optimization in a way that avoids the problems with the &lt;span class=&quot;math-container&quot;&gt;$c^T x \leq z$&lt;/span&gt; approach stands.&lt;/p&gt;&#xA;" OwnerUserId="4463" LastEditorUserId="981" LastEditDate="2023-12-22T14:47:20.400" LastActivityDate="2024-01-21T15:02:00.233" Title="Numerically stable way to optimize a lexicographical preference between two objective functions?" Tags="|mixed-integer-programming|or-tools|multi-objective-optimization|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10830" PostTypeId="2" ParentId="10829" CreationDate="2023-08-13T00:11:09.753" Score="0" Body="&lt;p&gt;If we assume that the &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; are integers, and the &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are binary, then the primary objective function is integer-valued, which means the minimum difference in objective value between an optimal solution and a suboptimal solution is 1. So we just have to scale the secondary objective in such a way that its range (the difference between the largest and smallest it can be) is strictly less than 1. That ensures that no amount of improvement in the secondary objective would lead to a suboptimal value in the primary objective. If the unscaled secondary objective is &lt;span class=&quot;math-container&quot;&gt;$\sum_j y_j,$&lt;/span&gt; we can multiply that by &lt;span class=&quot;math-container&quot;&gt;$\lambda=\frac{0.5}{\sum_j u_j}$&lt;/span&gt; to achieve that.&lt;/p&gt;&#xA;&lt;p&gt;If the &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; are &lt;em&gt;much&lt;/em&gt; larger in magnitude than &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; (10 or so orders of magnitude), it's possible it could cause the solver issues, although in my experience poor scaling of constraint coefficients is a bigger problem than poor scaling of objective coefficients. If that becomes an issue, you can try replacing &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$v_j = \alpha y_j$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt; \alpha &amp;lt; 1.$&lt;/span&gt; The secondary objective becomes &lt;span class=&quot;math-container&quot;&gt;$\frac{\lambda}{\alpha}\sum_j v_j,$&lt;/span&gt; making the coefficients closer in magnitude to the &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;. It also means constraint coefficients of &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; get multiplied by &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; (shrinking them), so it remains to be seen whether that damages numerical stability by screwing up the constraint scaling.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-08-13T00:11:09.753" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10831" PostTypeId="1" CreationDate="2023-08-14T13:12:29.953" Score="0" ViewCount="68" Body="&lt;p&gt;I have tried to implement a toy problem (MIP) from the literature using Lagrangian Relaxation with the subgradient method, I implemented it correctly and I got the upper bound which is updated at each iteration, however, for the lower bound (original problem), I optimized it to using a solver inside the algorithm, but in the literature, it has been mentioned that we can make use of relaxed problem solution to find a lower bound (maximization problem), most of them they refer to a heuristic to find such lower bound because in most cases the solution of relaxed problem will be infeasible to the original one, but I did not figure it out, do I have to optimize the lower bound using the solution from LR and solver or just plug the solution of the relaxed problem into the original problem ( in this case it will not work, as I have tried it before).&lt;/p&gt;&#xA;" OwnerUserId="12255" LastEditorUserId="12255" LastEditDate="2023-08-14T13:19:22.817" LastActivityDate="2023-08-14T16:00:50.290" Title="Finding lower bound (maximization problem) in Lagrangian Relaxation with subgradient method" Tags="|mixed-integer-programming|algorithms|lagrangian-relaxation|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10832" PostTypeId="1" CreationDate="2023-08-14T13:13:10.313" Score="2" ViewCount="106" Body="&lt;p&gt;I'd like to optimize the loading problem in first-mile delivery that maximize the occupancy of the truck. The main question to be answered is this: with the given truck, would this list of items fit or not fit? If fit, can we know the visualization of the items in the trucks? If not, can we know the items that are not carried?&lt;/p&gt;&#xA;&lt;p&gt;My early research is that this problem is like the container loading problem (clp). The items are in cartoon, and I just want to know for each truck. The items are weakly heterogeneous but they tend to have a lot in number of quantity (since it is first mile delivery).&#xA;Any advice about how to solve this? I would want to stay as close as possible with Excel and Python.&lt;/p&gt;&#xA;" OwnerUserId="10000" LastActivityDate="2023-08-15T19:05:31.340" Title="Container Loading Problem" Tags="|optimization|mixed-integer-programming|heuristics|metaheuristics|excel|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10833" PostTypeId="1" CreationDate="2023-08-14T13:26:13.033" Score="6" ViewCount="140" Body="&lt;p&gt;There are tons of Masters programs across North America and Europe focused on OR/Industrial Engineering.&lt;/p&gt;&#xA;&lt;p&gt;I am interested especially in solver technology and would be very grateful if someone could help me in choosing a MS program that offers a curriculum and faculty specifically geared towards my goal.&lt;/p&gt;&#xA;&lt;p&gt;I have looked at a few programs in Germany as it seems almost everyone working on MIP solvers is based there but I am not too sure if they are offered in English and that kind of limits my options.&lt;/p&gt;&#xA;&lt;p&gt;Apologies, if this is off-topic, but since OR folks hang out here, I figured this would be the best place to ask.&lt;/p&gt;&#xA;" OwnerUserId="12279" LastActivityDate="2023-08-14T13:26:13.033" Title="What are some recommended Master's degree programs for individuals interested in specializing in the development of MI(L)P solvers?" Tags="|reference-request|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10834" PostTypeId="1" CreationDate="2023-08-14T15:25:18.780" Score="3" ViewCount="181" Body="&lt;p&gt;Is a Biconvex function f(x,y):=yg(x), (where g is a convex function, y&amp;gt;=0), Pseudoconvex function?&lt;/p&gt;&#xA;" OwnerUserId="9818" LastEditorUserId="9818" LastEditDate="2023-08-22T22:12:17.923" LastActivityDate="2023-08-22T22:12:17.923" Title="When Biconvex function is Pseudoconvex function?" Tags="|convex-optimization|nonconvex-programming|convexity|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10835" PostTypeId="2" ParentId="10831" CreationDate="2023-08-14T16:00:50.290" Score="1" Body="&lt;p&gt;The relaxed constraints will typically be violated, but the rest of the constraints will be satisfied.  To get a feasible solution to the original problem, you need to modify the relaxed solution somehow to satisfy all the constraints.  Such a &amp;quot;repair&amp;quot; heuristic is usually problem-specific.  For example, Section 10.4 of Wolsey's &lt;em&gt;Integer Programming&lt;/em&gt; describes a greedy heuristic when the original problem is set covering and all covering constraints are relaxed: ignore the rows that are already covered by the relaxed solution, and greedily change some variables from &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to cover the rest.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-08-14T16:00:50.290" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10836" PostTypeId="2" ParentId="10834" CreationDate="2023-08-14T16:45:58.640" Score="5" Body="&lt;p&gt;I am a bit confused by the wording. The title says when biconvex is pseudoconvex, but in the description asks whether a biconvex function is pseudoconvex. I am answering assuming you are asking the latter, i.e, whether biconvex functions are pseudoconvex.&lt;/p&gt;&#xA;&lt;p&gt;I guess, the answer is not always. Consider the function &lt;span class=&quot;math-container&quot;&gt;$f(x,y) = y x^2$&lt;/span&gt;. Firstly, recall that every pseudoconvex function is a quasiconvex function (definition: all sub-level sets are convex sets). So if we show that &lt;span class=&quot;math-container&quot;&gt;$f(x,y)$&lt;/span&gt; is not quasiconvex, then &lt;span class=&quot;math-container&quot;&gt;$f(x,y)$&lt;/span&gt; is not pseudoconvex.&#xA;Consider the points:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; = -0.5, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; = -1, so &lt;span class=&quot;math-container&quot;&gt;$f(x_1, y)$&lt;/span&gt; = -0.25.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; = 0.5, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; = -1, so &lt;span class=&quot;math-container&quot;&gt;$f(x_2, y)$&lt;/span&gt; = -0.25.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_3$&lt;/span&gt; = 0, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; = -1, so &lt;span class=&quot;math-container&quot;&gt;$f(x_3, y)$&lt;/span&gt; = 0.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Consider the sub-level set &lt;span class=&quot;math-container&quot;&gt;$C = \lbrace{(x,y) | f(x, y) &amp;lt;= -0.2 \rbrace}$&lt;/span&gt;. Clearly &lt;span class=&quot;math-container&quot;&gt;$(x_1, y), (x_2, y)$&lt;/span&gt; lie in &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, whereas their convex combination &lt;span class=&quot;math-container&quot;&gt;$(x_3, y) = \dfrac{1}{2}(x_1, y) + \dfrac{1}{2}(x_2, y)$&lt;/span&gt; does not belong to &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, so &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is not a convex set.&lt;/p&gt;&#xA;" OwnerUserId="972" LastActivityDate="2023-08-14T16:45:58.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10837" PostTypeId="1" AcceptedAnswerId="10838" CreationDate="2023-08-15T07:40:03.527" Score="2" ViewCount="213" Body="&lt;p&gt;I am trying to solve an optimization problem in which there is a set of tasks, &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e_i$&lt;/span&gt; are the starting and ending time of task &lt;span class=&quot;math-container&quot;&gt;$i \in S$&lt;/span&gt;. Each task &lt;span class=&quot;math-container&quot;&gt;$i $&lt;/span&gt; must be done within its time own window &lt;span class=&quot;math-container&quot;&gt;$[a_i, b_i]$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;a_i \le s_i, \forall i \in S&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;e_i \le b_i, \forall i \in S&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Due to the presence of time windows, tasks could overlap. I have defined continuous variable &lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt; to quantify the overlapping time of tasks &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The objective is to minimize the overlapping time:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;min \sum_{i,j \in S} t_{ij}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I define constraints to compute &lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="12282" LastEditorUserId="500" LastEditDate="2023-08-15T13:01:13.113" LastActivityDate="2023-08-15T20:34:12.133" Title="Compute overlapping time" Tags="|mixed-integer-programming|modeling|constraint|scheduling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10838" PostTypeId="2" ParentId="10837" CreationDate="2023-08-15T13:01:03.283" Score="3" Body="&lt;p&gt;First note that you can omit &lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt; for any pair &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; for which the time windows do not overlap because &lt;span class=&quot;math-container&quot;&gt;$t_{ij}=0$&lt;/span&gt; in that case.&lt;/p&gt;&#xA;&lt;p&gt;Tasks &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; overlap if and only if the later starting time &lt;span class=&quot;math-container&quot;&gt;$\max(s_i,s_j)$&lt;/span&gt; precedes the earlier ending time &lt;span class=&quot;math-container&quot;&gt;$\min(e_i,e_j)$&lt;/span&gt;, so you want to enforce &lt;span class=&quot;math-container&quot;&gt;$$t_{ij} \ge \max(\min(e_i,e_j) - \max(s_i,s_j), 0),$$&lt;/span&gt; which can be linearized by introducing&#xA;&lt;span class=&quot;math-container&quot;&gt;$u_{ij}$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$\max(s_i,s_j)$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$v_{ij}$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$\min(e_i,e_j)$&lt;/span&gt;,&#xA;binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt;, and linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0 \le u_{ij} - s_i &amp;amp;\le (b_j-a_i) y_{ij} \tag1\label1\\ &#xA;0 \le u_{ij} - s_j &amp;amp;\le (b_i-a_j) (1-y_{ij}) \tag2\label2\\ &#xA;(a_j-b_i) x_{ij} \le v_{ij} - e_i &amp;amp;\le 0 \tag3\label3\\ &#xA;(a_i-b_j) (1-x_{ij}) \le v_{ij} - e_j &amp;amp;\le 0 \tag4\label4\\ &#xA;t_{ij} &amp;amp;\ge v_{ij} - u_{ij} \tag5\label5 \\ &#xA;t_{ij} &amp;amp;\ge 0 \tag6\label6&#xA;\end{align}&lt;/span&gt;&#xA;Constraints \eqref{1} and \eqref{2} enforce &lt;span class=&quot;math-container&quot;&gt;$u_{ij}=\max(s_i,s_j)$&lt;/span&gt;.&#xA;Constraints \eqref{3} and \eqref{4} enforce &lt;span class=&quot;math-container&quot;&gt;$v_{ij}=\min(e_i,e_j)$&lt;/span&gt;.&#xA;Constraints \eqref{5} and \eqref{6} enforce &lt;span class=&quot;math-container&quot;&gt;$t_{ij}\ge\max(v_{ij}-u_{ij},0)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-08-15T20:34:12.133" LastActivityDate="2023-08-15T20:34:12.133" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10839" PostTypeId="1" CreationDate="2023-08-15T15:28:49.970" Score="1" ViewCount="37" Body="&lt;p&gt;Suppose we are maximizing &lt;span class=&quot;math-container&quot;&gt;$f(x^1,\ldots,x^t)= \begin{bmatrix}{x^1}^\top &amp;amp; \ldots &amp;amp; {x^t}^\top  \end{bmatrix}^\top Q \begin{bmatrix}{x^1}^\top &amp;amp; \ldots &amp;amp; {x^t}^\top  \end{bmatrix}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$Q \succ 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let our constraints be &lt;span class=&quot;math-container&quot;&gt;$x^1, \ldots, x^t \in \mathcal{S}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}\subseteq \mathbb{R}^n$&lt;/span&gt; is a probability simplex.&lt;/p&gt;&#xA;&lt;p&gt;Is there any rule-of-thumb for this problem? If we had only one simplex (&lt;span class=&quot;math-container&quot;&gt;$t = 1$&lt;/span&gt;) then we could enumerate the extreme points which is easy, but for the general case we have &lt;span class=&quot;math-container&quot;&gt;$n^t$&lt;/span&gt; extreme points. I thought about the reformulation-linearization technique, but that would also result in a lot of constraints. Hence I was wondering if there is something easier.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2023-08-15T15:35:30.303" LastActivityDate="2023-08-15T15:35:30.303" Title="Convex quadratic maximization over cartesian product of simplices" Tags="|quadratic-programming|nonconvex-programming|reformulation-linearization|relaxation|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10840" PostTypeId="1" AcceptedAnswerId="10841" CreationDate="2023-08-15T16:34:31.033" Score="2" ViewCount="829" Body="&lt;p&gt;Let set &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; denote the facility location set, &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; denote the customer set,&#xA;and &lt;span class=&quot;math-container&quot;&gt;$d_{ni}, \forall n\in N, i \in I $&lt;/span&gt; is the distance between customer &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and facility &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&#xA;The problem is to locate facilities in &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; with binary decision variable &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt;, and assign customer &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; to the opened &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; with binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{ni}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that there are many other constraints that I had omitted, and the problem is much difficult than the classic facility location problem.&#xA;The most tricky part is how to build an equation which forces customer to visit their nearest and opened facility.&#xA;Without this constraint, customer may visit farther facility, which is not what I want.&lt;/p&gt;&#xA;&lt;p&gt;Now, I provide a equation as follows, which is nonlinear but can be linearized.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i\in I} d_{ni} y_{ni} = \min \{ M(1-v_i) + d_{ni}v_i,\forall i \in I\} \quad \forall n \in N&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a sufficient large constant.&lt;/p&gt;&#xA;&lt;p&gt;My problem is: Could anyone suggest a better way to force customers visit their nearest opened facility? I think the above relationship is complex. How to simplify this or provide another method?&lt;/p&gt;&#xA;" OwnerUserId="12286" LastEditorUserId="500" LastEditDate="2023-08-15T16:53:27.733" LastActivityDate="2023-08-18T18:28:55.940" Title="Modeling: How to force customers visit their NEAREST facility" Tags="|mixed-integer-programming|modeling|assignment-problem|facility-location|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10841" PostTypeId="2" ParentId="10840" CreationDate="2023-08-15T16:58:32.527" Score="3" Body="&lt;p&gt;If the objective is to minimize total distance, this will happen naturally.  But if you want to explicitly enforce it, you can impose a rule like&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lnot(y_{ni} \land v_j) \quad \text{for all $n,i,j$ such that $d_{ni} &amp;gt; d_{nj}$}.$$&lt;/span&gt;&#xA;Rewriting in conjunctive normal form yields a conflict constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\lnot y_{ni} \lor \lnot v_j &amp;amp; &amp;amp;&amp;amp;\text{for all $n,i,j$ such that $d_{ni} &amp;gt; d_{nj}$}\\&#xA;(1-y_{ni})+(1-v_j) &amp;amp;\ge 1 &amp;amp;&amp;amp;\text{for all $n,i,j$ such that $d_{ni} &amp;gt; d_{nj}$}\\&#xA;y_{ni} + v_j &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for all $n,i,j$ such that $d_{ni} &amp;gt; d_{nj}$}\tag1\label1&#xA;\end{align}&lt;/span&gt;&#xA;Because &lt;span class=&quot;math-container&quot;&gt;$\sum_i y_{ni}\le 1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, you can then strengthen \eqref{1} by using the idea described in &lt;a href=&quot;https://or.stackexchange.com/questions/6187/how-can-i-strengthen-a-family-of-constraints-in-the-presence-of-a-clique-constra&quot;&gt;How can I strengthen a family of constraints in the presence of a clique constraint?&lt;/a&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i: d_{ni} &amp;gt; d_{nj}} y_{ni} + v_j \le 1&#xA;\quad \text{for all $n$ and $j$}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-08-15T22:34:50.090" LastActivityDate="2023-08-15T22:34:50.090" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10842" PostTypeId="2" ParentId="10832" CreationDate="2023-08-15T18:54:51.133" Score="3" Body="&lt;p&gt;As a free Excel plugin to solve a 3D packing problem and already with the visualization, the Vehicle Routing and Logistics Optimization within EURO, &lt;a href=&quot;https://www.euro-online.org/websites/verolog/clp-spreadsheet-solver-2/&quot; rel=&quot;nofollow noreferrer&quot;&gt;VeRoLog&lt;/a&gt;, has a material that may help to solve such a problem.&lt;/p&gt;&#xA;&lt;p&gt;Another solver may be &lt;a href=&quot;https://github.com/fontanf/packingsolver&quot; rel=&quot;nofollow noreferrer&quot;&gt;PackingSolver&lt;/a&gt; which was developed by &lt;em&gt;Dr. Florian Fontan&lt;/em&gt; (in the community @fontanf). It would be interesting to solve 2D and also 3D packing problems.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-08-15T19:05:31.340" LastActivityDate="2023-08-15T19:05:31.340" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10843" PostTypeId="2" ParentId="10840" CreationDate="2023-08-15T19:45:11.510" Score="2" Body="&lt;p&gt;If you would like to assign the customers to the nearest facility, one way would be by adding a set-covering constraint to ensure the customers with the minimum distance from a facility are assigned to that.&lt;/p&gt;&#xA;&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is either the maximal acceptable service distance or time or covering radius, and the set &lt;span class=&quot;math-container&quot;&gt;$N_n \small =  \{i | d_{ij} &amp;lt; S\}$&lt;/span&gt; is to control the distance in contrast to the &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. The following constraint should impose what you want:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{i \in N_n} v_{i} \geq 1 \quad \forall \ n \in N$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-08-15T19:45:11.510" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10844" PostTypeId="1" AcceptedAnswerId="10848" CreationDate="2023-08-16T03:30:21.677" Score="0" ViewCount="145" Body="&lt;p&gt;I am trying to solve an assignment problem by Constraint Programming (CP). Let us consider a task assignment problem that have &lt;span class=&quot;math-container&quot;&gt;$|M|$&lt;/span&gt; tasks and &lt;span class=&quot;math-container&quot;&gt;$|N|$&lt;/span&gt; machines, each task has different processing time required on each machine, and each machine has a maximum capacity (number of tasks can be processed). The objective is to assign each task to a single machine with respect to the precedence requirements, such that the overall processing time can be minimized.&lt;/p&gt;&#xA;&lt;p&gt;To model the assignment decisions, we can use &lt;span class=&quot;math-container&quot;&gt;$|M||N|$&lt;/span&gt; binary variables (represent whether a task is assigned to a machine) or &lt;span class=&quot;math-container&quot;&gt;$|M|$&lt;/span&gt; integer variables (each has a domain of &lt;span class=&quot;math-container&quot;&gt;$[1, |N|]$&lt;/span&gt;, represent the machine that each task is assigned to). I am little experienced with CP, but I have read material that says less variable, and more constraints can be beneficial for solving CP. So, I suspect that using integer variables is better.&lt;/p&gt;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;- How the choice of variable type (binary / integer) impacts the algorithm efficiency?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;- Will CP solvers (e.g. OR-Tools) convert integer variables into binary ones automatically, such that there is no difference between binary variables and integer variables?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;This question is related to &lt;a href=&quot;https://or.stackexchange.com/q/3209/8718&quot;&gt;How to choose between high number of binary variables or fewer number of integer (not only 0 and 1) variables in a IP formulation?&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/q/6555/8718&quot;&gt;Does exchanging integer variables by binary variables strengthen a MIP?&lt;/a&gt;, which are in the context of Mathematical Programming, rather than CP.&lt;/p&gt;&#xA;" OwnerUserId="8718" LastEditorUserId="981" LastEditDate="2023-08-17T14:07:16.470" LastActivityDate="2023-08-17T14:12:24.687" Title="Using binary variable or integer variable in Constraint Programming (CP)?" Tags="|constraint-programming|binary-variable|or-tools|cp-sat|integer-variable|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10845" PostTypeId="1" CreationDate="2023-08-16T06:31:41.457" Score="1" ViewCount="43" Body="&lt;p&gt;In some cases I have seen, the indicator constraint can be written as &lt;code&gt;indcons(expression, binary_var)&lt;/code&gt;. Then it is interpreted as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$LHS - slack (\leq = \geq) RHS$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ if: \quad (binary = 1) \implies (slack = 0)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As far as I know, CPLEX and maybe Gurobi have used binary variables and whose linking to linearize the constraint. I am actually not aware of their internal mechanism. Now, I would like to know the rule of the slack variable in this form and if is it necessary to use that instead of using e.g. &lt;span class=&quot;math-container&quot;&gt;$BigM$&lt;/span&gt; approach.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="500" LastEditDate="2023-08-16T12:24:30.190" LastActivityDate="2023-08-16T12:24:30.190" Title="The rule of the slack variable in an indicator constraint" Tags="|mixed-integer-programming|solver|indicator-constraints|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10846" PostTypeId="2" ParentId="10834" CreationDate="2023-08-16T12:57:15.470" Score="0" Body="&lt;p&gt;The example in the other answer (by batwing) is not a counterexample to the question as it currently stands because it does not satisfy the conditions that &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is non-decreasing and &lt;span class=&quot;math-container&quot;&gt;$y\geq 0$&lt;/span&gt;. (These conditions were added after the answer was posted.) To satisfy these two conditions, we need to restrict the domain to &lt;span class=&quot;math-container&quot;&gt;$x\geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y\geq 0$&lt;/span&gt;, which rules out the three points considered in the answer.&lt;/p&gt;&#xA;&lt;p&gt;An easy counterexamples is as follows. Take &lt;span class=&quot;math-container&quot;&gt;$g(x)=x$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$f(x,y)=xy$&lt;/span&gt;. There is a stationary point at &lt;span class=&quot;math-container&quot;&gt;$(0,0)$&lt;/span&gt;, but it is not a global minimizer as &lt;span class=&quot;math-container&quot;&gt;$f(x,y)&amp;lt;0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$x&amp;lt;0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y&amp;gt;0$&lt;/span&gt;. This tells us that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is not pseudoconvex, because for pseudoconvex functions stationary points are global minimizers.&lt;/p&gt;&#xA;" OwnerUserId="12292" LastActivityDate="2023-08-16T12:57:15.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10847" PostTypeId="1" CreationDate="2023-08-16T15:51:25.507" Score="0" ViewCount="38" Body="&lt;p&gt;It seems that Newton-Raphson is said to have quadratic convergence, and that Fisher Scoring has linear convergence.  By Fisher Scoring, I mean Newton-Raphson, but replace the Hessian with its expectation. That is,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\theta_{m+1} = \theta_m + I^{-1}(\theta_m)*V(\theta_m)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$I(\theta) = \mathbb{E}[J(\theta)]$&lt;/span&gt; is the Fisher Information (the expected Hessian), and &lt;span class=&quot;math-container&quot;&gt;$V(\theta)$&lt;/span&gt; is the score.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What is the proof that Fisher Scoring has linear convergence?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is result is claimed in &amp;quot;A generic algorithm for reducing bias in parametric estimation&amp;quot; by Kosmidis and Firth in (2010), and in &amp;quot;Partitioned algorithms for maximum likelihood and other non-linear estimation&amp;quot; by Smyth in (1995). But I don't see reference/theory about this.&lt;/p&gt;&#xA;" OwnerUserId="12295" LastEditorUserId="12295" LastEditDate="2023-08-17T17:09:04.713" LastActivityDate="2023-08-17T17:09:04.713" Title="Why does Fisher Scoring have linear convergence?" Tags="|optimization|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10848" PostTypeId="2" ParentId="10844" CreationDate="2023-08-17T14:12:24.687" Score="3" Body="&lt;p&gt;For the CP-SAT solver, the rule of thumb is the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if you need to check if a variable ==/!= value, then you should use an array of Boolean variables instead&lt;/li&gt;&#xA;&lt;li&gt;the start, end, size of interval variables must be integer variables&lt;/li&gt;&#xA;&lt;li&gt;index of element constraint, variables in a constraint like all_different, table, automaton: they will all be expanded to Boolean variables as the constraints will also be expanded to Boolean and enforced linear constraints.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So for quantities, sums, time: use IntVar&#xA;For assignment: use BoolVars.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-08-17T14:12:24.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10849" PostTypeId="1" CreationDate="2023-08-17T14:46:41.303" Score="3" ViewCount="64" Body="&lt;p&gt;What investigation has there been of Block Simplex Algorithms, i.e., block active set for Linear Programming, i.e., block pivoting? This is a follow-up to &lt;a href=&quot;https://scicomp.stackexchange.com/questions/27987/why-do-active-set-methods-or-the-simplex-method-pivot-only-one-variable-at-a-tim&quot;&gt;Why do active set methods or the simplex method pivot only one variable at a time?&lt;/a&gt;. This board was not yet in existence when that question was asked; and the question now seems better suited here.&lt;/p&gt;&#xA;&lt;p&gt;It seems that (primal or dual) block active set has the potential to be much faster on some problems than (Primal or Dual) Simplex. As I and others suggested on the previous question, there may be a potential for cycling if block pivoting is performed.&lt;/p&gt;&#xA;&lt;p&gt;Has anyone systematically investigated cycling in block active set, specialized in particular to Linear Programming? Are there certain rules (criteria) which would prevent cycling, but allow more than one variable to be cycled in or out of the basis at one time? Perhaps something in between always pivoting one variable at a time (Simplex), to always pivoting all variables having the requisite value of reduced cost (maximal block pivot)?&lt;/p&gt;&#xA;&lt;p&gt;What could be said about use of Block Dual Simplex to solve node LP problems in MILP, which perhaps is the most important use case for LP Simplex (family) algorithms?&lt;/p&gt;&#xA;&lt;p&gt;Even if there are no known criteria which provably prevent cycling in Block Simplex, might it still be better in practice than Simplex on some (many?) LPs?&lt;/p&gt;&#xA;&lt;p&gt;Please post substantive answers, even if only addressing some of the questions.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2023-08-17T14:46:41.303" Title="Block Simplex Algorithm, i.e., Block Active Set for Linear Programming" Tags="|linear-programming|simplex|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10851" PostTypeId="2" ParentId="10840" CreationDate="2023-08-18T00:34:03.930" Score="1" Body="&lt;p&gt;Another way is for all customers &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; sort the distance in ascending order into a set &lt;span class=&quot;math-container&quot;&gt;$S_n =\{d_{ni}: d_{n,i}  \le d_{n,i+1}\}$&lt;/span&gt; basically indexed by the facility.&lt;br /&gt;&#xA;Then for each customer loop the below constraints through the set&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$v_i \le \sum_{j \in S_n}^{i}y_{n,j} \ \ \forall i \in S_n \ \ \forall n$&lt;/span&gt;&lt;br /&gt;&#xA;with another constraint which may be there already&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_n y_{n,i} \le Mv_i \quad \forall i $&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is big number like capacity of the facility and&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_i y_{n,i} = 1 \ \ \forall n$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-08-18T18:28:55.940" LastActivityDate="2023-08-18T18:28:55.940" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10852" PostTypeId="1" CreationDate="2023-08-18T05:00:25.637" Score="3" ViewCount="174" Body="&lt;p&gt;What are the some of prominent technical features (which may or may not be part of commercial Algebraic Modeling Languages (AMLs) such as GAMS or AMPL) which are currently lacking in open-source AMLs like Pyomo, JuMP etc.?&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="113" LastEditDate="2023-09-07T05:34:26.873" LastActivityDate="2023-09-07T05:34:26.873" Title="What are some of the key features that are currently absent in open-source AMLs like Pyomo, JuMP, Gurobipy" Tags="|pyomo|gurobipy|jump|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10853" PostTypeId="1" AcceptedAnswerId="10854" CreationDate="2023-08-18T07:54:22.640" Score="2" ViewCount="82" Body="&lt;p&gt;in the process of implementing my first BD algorithm, I am unsure how to proceed in the case that the subproblem is unbounded.&lt;/p&gt;&#xA;&lt;p&gt;Obviously, it means you get an extreme ray that you can add to the RMP as a feasibility cut.&lt;/p&gt;&#xA;&lt;p&gt;But do you also add an optimality cut in the same iteration, with the extreme point that the extreme ray is based on?&lt;/p&gt;&#xA;" OwnerUserId="12130" LastActivityDate="2023-08-18T18:46:48.767" Title="In Benders Decomposition, do you add an optimality cut together with a feasibility cut?" Tags="|mixed-integer-programming|benders-decomposition|cuts|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10854" PostTypeId="2" ParentId="10853" CreationDate="2023-08-18T09:02:55.530" Score="2" Body="&lt;p&gt;In each iteration of BD, you either add a feasibility cut or an optimality cut. That is due to the fact that the subproblem cannot be simultaneously feasible (and optimal) and infeasible (speaking in terms of the primal form of the subproblem).&lt;/p&gt;&#xA;" OwnerUserId="119" LastActivityDate="2023-08-18T09:02:55.530" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10855" PostTypeId="1" AcceptedAnswerId="10856" CreationDate="2023-08-18T14:07:58.517" Score="3" ViewCount="245" Body="&lt;p&gt;I'm working on a binary integer programming problem using pulp. I have a vector &lt;code&gt;X = [x_1, x_2, x_3, . . . , x_n]&lt;/code&gt;. I have enforced a number of simple constraints. I have a bunch of groups in the data say &lt;code&gt;group0 = [x_1, x_2], group1 = [x_3, x_4] . . .&lt;/code&gt;. My goal is to maximize the number of groups where all the variables in the group are zero. So effectively the objective function would be&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def objective(group):&#xA;    if sum(group) == 0:&#xA;        return 1&#xA;    else&#xA;        return 0&#xA;maximize sum(objective(group_i) for group_i in groups)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But Im not sure if there is a way to do this with a linear solver.&lt;/p&gt;&#xA;&lt;p&gt;Also, to make things concrete this is essentially a scheduling problem. Each X_i represents a shift where x_i == 1 mean the worker is scheduled and x_i == 0 means they are not scheduled. Each group represents requests for time off, and we want to maximize the number of these requests that we can grant while ensuring staffing is sufficient/a number of other constraints are met.&lt;/p&gt;&#xA;&lt;p&gt;A simple example with no objective function would be&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pulp&#xA;&#xA;# Initialize problem and variables&#xA;num_variables = 10&#xA;prob = pulp.LpProblem(&amp;quot;Shift_Scheduling&amp;quot;, pulp.LpMinimize)&#xA;x = pulp.LpVariable.dicts(&amp;quot;shift&amp;quot;, range(num_variables), cat='Binary')&#xA;&#xA;# Add simple constraint&#xA;prob += pulp.lpSum(x[i] for i in range(num_variables)) == int(num_variables * 0.8)&#xA;&#xA;# Solve the problem&#xA;solver = pulp.PULP_CBC_CMD(timeLimit=30, threads=4, gapRel=0.5)&#xA;prob.solve(solver)&#xA;&#xA;# View results&#xA;for i in range(num_variables):&#xA;    print(f&amp;quot;var {i} ==&amp;quot;, pulp.value(x[i]))&#xA;&#xA;Output: &#xA;var 0 == 1.0&#xA;var 1 == 1.0&#xA;var 2 == 1.0&#xA;var 3 == 1.0&#xA;var 4 == 1.0&#xA;var 5 == 1.0&#xA;var 6 == 1.0&#xA;var 7 == 1.0&#xA;var 8 == 0.0&#xA;var 9 == 0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have tried giving each group a weight so group0 would have weight == 1, group1 would have weight == 2 . . . This way, we incentivize the solver to zero out groups with lower weight. For example . . .&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Initialize problem and variables&#xA;num_variables = 10&#xA;prob = pulp.LpProblem(&amp;quot;Shift_Scheduling&amp;quot;, pulp.LpMaximize)&#xA;x = pulp.LpVariable.dicts(&amp;quot;shift&amp;quot;, range(num_variables), cat='Binary')&#xA;&#xA;# Create groups [(0, 1), (2, 3), . . . ]&#xA;groups = [(i, i + 1) for i in range(0, num_variables, 2)]&#xA;# Get weights for each group - group_0 has weight 1, group_1 has wieght 2 . . .&#xA;group_weights = {}&#xA;for weight, group in enumerate(groups):&#xA;    for index in group:&#xA;        group_weights[index] = weight + 1&#xA;&#xA;# Add objective function&#xA;prob += pulp.lpSum(group_weights[i] * x[i] for i in range(num_variables))&#xA;&#xA;# Add simple constraint&#xA;prob += pulp.lpSum(x[i] for i in range(num_variables)) == int(num_variables * 0.8)&#xA;&#xA;# Solve the problem&#xA;solver = pulp.PULP_CBC_CMD(timeLimit=60, threads=4, gapRel=0.5)&#xA;prob.solve(solver)&#xA;&#xA;# View results&#xA;for i in range(num_variables):&#xA;    print(f&amp;quot;var {i} ==&amp;quot;, pulp.value(x[i]))&#xA;&#xA;output:&#xA;var 0 == 0.0&#xA;var 1 == 0.0&#xA;var 2 == 1.0&#xA;var 3 == 1.0&#xA;var 4 == 1.0&#xA;var 5 == 1.0&#xA;var 6 == 1.0&#xA;var 7 == 1.0&#xA;var 8 == 1.0&#xA;var 9 == 1.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However I don't like this solution because we are giving priority to certain groups, it feels a bit hacky. It seems like as the constraints becomes more complex, this could lead to cases where the solver zeros out lots of low weight groups but solutions could exist where greater numbers of groups could be zeroed out if each group was prioritized equally. Of course, we want to maximize the number of time off requests that are granted and we don't want to arbitrarily prioritize one request over another.&lt;/p&gt;&#xA;&lt;p&gt;Also if this is not possible with pulp I would be open to using other solvers, its just a significant amount of work has already been done by my team using pulp and I would rather not have to redo the work if its at all possible.&lt;/p&gt;&#xA;" OwnerUserId="12305" LastEditorUserId="491" LastEditDate="2023-08-18T17:10:06.697" LastActivityDate="2023-08-18T18:49:33.657" Title="Binary Integer Programming Problem - Enforce Zeros on Certain Groups" Tags="|integer-programming|binary-variable|pulp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10856" PostTypeId="2" ParentId="10855" CreationDate="2023-08-18T16:13:43.470" Score="5" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; be the set of groups.  For group &lt;span class=&quot;math-container&quot;&gt;$g\in G$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$I_g$&lt;/span&gt; be the set of indices &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in that group.  Introduce binary decision variable &lt;span class=&quot;math-container&quot;&gt;$y_g$&lt;/span&gt; to indicate whether &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i\in I_g$&lt;/span&gt;.  To maximize the number of groups that have all &lt;span class=&quot;math-container&quot;&gt;$x_i=0$&lt;/span&gt;, maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_g y_g$&lt;/span&gt; subject to linear constraints &lt;span class=&quot;math-container&quot;&gt;$$x_i \le 1-y_g \quad \text{for all $g\in G$ and $i\in I_g$} \tag1\label1$$&lt;/span&gt;&#xA;that enforce the logical implication &lt;span class=&quot;math-container&quot;&gt;$y_g \implies \lnot x_i$&lt;/span&gt;.&#xA;Alternatively, you can aggregate \eqref{1} and instead enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in I_g} x_i \le |I_g|(1-y_g) \quad \text{for all $g\in G$} \tag2\label2$$&lt;/span&gt;&#xA;As usual, the aggregated version \eqref{2} is weaker but yields a smaller LP so might perform better.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-08-18T16:13:43.470" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10857" PostTypeId="2" ParentId="10853" CreationDate="2023-08-18T18:46:48.767" Score="1" Body="&lt;p&gt;The &amp;quot;anchor point&amp;quot; of the unbounded dual ray is a feasible solution to the &lt;em&gt;dual&lt;/em&gt; subproblem. Optimality cuts are based on feasible solutions to the &lt;em&gt;primal&lt;/em&gt; subproblem. If the dual is unbounded, then as Ehsan points out the primal is infeasible, meaning there is nothing on which to base the optimality cut.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-08-18T18:46:48.767" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10858" PostTypeId="2" ParentId="10855" CreationDate="2023-08-18T18:49:33.657" Score="3" Body="&lt;p&gt;This is just a complement to the answer given by &lt;a href=&quot;https://or.stackexchange.com/users/500/robpratt&quot;&gt;@RobPratt&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let an instance for our scheduling problem be given by:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; the set of workers;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; the set of groups, such that &lt;span class=&quot;math-container&quot;&gt;$g \in G$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$g \subseteq W$&lt;/span&gt;; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$D \in \mathbb{N}$&lt;/span&gt; be the minimum number of workers required for the scheduling.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;We, then, can proceed with our BIP modeling with the following variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_w \in \mathbb{B}$&lt;/span&gt; is equals to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, if worker &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is allocated for the scheduling, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise, &lt;span class=&quot;math-container&quot;&gt;$\forall w \in W$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_g \in \mathbb{B}$&lt;/span&gt; is equals to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, if some &lt;span class=&quot;math-container&quot;&gt;$w \in g$&lt;/span&gt; is allocated for the scheduling, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise, &lt;span class=&quot;math-container&quot;&gt;$\forall  g \in G$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;With the following objective function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min \sum_{g \in G} y_g$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And with the following constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{w \in W} x_w = D$&lt;/span&gt;, stating the mandatory number of workers;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_w \leqslant y_g$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall g \in G, w \in g$&lt;/span&gt;, stating that, when a worker &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is allocated, then &lt;strong&gt;all the groups&lt;/strong&gt; containing this worker must be taken as allocated as well.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;An improvement, could be:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_g \leqslant \sum_{w \in g} x_w$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall g \in G$&lt;/span&gt;, stating that, when a group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is taken as allocated, then &lt;strong&gt;at least one&lt;/strong&gt; worker belonging to this group must be allocated as well.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Below follows an implementation:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;    import pulp&#xA;&#xA;    # Initialize problem&#xA;    W = list(range(10))&#xA;    n = len(W)&#xA;    &#xA;    G = list(map(lambda w: (w, w+ 1), range(0, n, 2)))&#xA;    &#xA;    D = 0.8 * n&#xA;    &#xA;    # Initialize model&#xA;    prob = pulp.LpProblem(&amp;quot;Shift_Scheduling&amp;quot;, pulp.LpMinimize)&#xA;    &#xA;    # Initialize variables&#xA;    x = pulp.LpVariable.dicts(&amp;quot;worker_allocated&amp;quot;, W, cat='Binary')&#xA;    y = dict({g: pulp.LpVariable(&amp;quot;group_allocated &amp;quot; + str(g), cat='Binary') for g in G})&#xA;    &#xA;    # Add obj. func.&#xA;    prob += pulp.lpSum(map(lambda g: y[g], G))&#xA;    &#xA;    # Add min demand constraint&#xA;    prob += pulp.lpSum(map(lambda w: x[w], W)) == D&#xA;    &#xA;    # Add group flag lifting constraint&#xA;    for g in G:&#xA;        for w in g:&#xA;            prob += x[w] &amp;lt;= y[g]&#xA;    &#xA;    # Add improvement&#xA;    for g in G:&#xA;        prob += y[g] &amp;lt;= pulp.lpSum(map(lambda w: x[w], g))&#xA;    &#xA;    # Solve the problem&#xA;    solver = pulp.PULP_CBC_CMD(timeLimit=30, threads=4, gapRel=0.5)&#xA;    prob.solve(solver)&#xA;    &#xA;    # View results&#xA;    for w in W:&#xA;        print(f&amp;quot;x {w} ==&amp;quot;, pulp.value(x[w]))&#xA;    &#xA;    for g in G:&#xA;        print(&amp;quot;y %s == %.1f&amp;quot; % (str(g), pulp.value(y[g])))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For more related problems, you may consider the &lt;a href=&quot;https://en.wikipedia.org/wiki/Set_cover_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;set covering&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Set_packing&quot; rel=&quot;nofollow noreferrer&quot;&gt;set packing&lt;/a&gt; problems.&lt;/p&gt;&#xA;&lt;p&gt;Regards.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastActivityDate="2023-08-18T18:49:33.657" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10859" PostTypeId="1" CreationDate="2023-08-19T07:01:16.197" Score="1" ViewCount="156" Body="&lt;p&gt;I am currently working on a Vehicle Routing Problem (VRP) with a set of specific constraints. I have a total of 19 nodes, each representing a customer location, and a depot. There are also 7 pickers available to fulfill the pick up requirements. The problem has the following characteristics:&lt;/p&gt;&#xA;&lt;p&gt;I have a distance matrix between all 19 nodes and the depot.&#xA;Each node has an associated demand representing the amount to be picked up.&#xA;The pickers have a limited capacity of 25 units each.&#xA;&lt;strong&gt;The capacity of each picker is less than the demand at every node&lt;/strong&gt;, necessitating &lt;strong&gt;multiple trips&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am seeking assistance in formulating this problem mathematically. Specifically, I need help defining the constraints to ensure that the pickers efficiently complete their tasks &lt;strong&gt;while considering capacity limitations and multiple trips necessity&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Data:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Distance matrix: A 20x20 matrix representing distances between nodes and the depot.&lt;/li&gt;&#xA;&lt;li&gt;Demand: A list of 19 demand values, one for each node.&lt;/li&gt;&#xA;&lt;li&gt;Picker capacity: 25 units for each picker.&lt;/li&gt;&#xA;&lt;li&gt;Number of pickers: 7.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt;&lt;br /&gt;&#xA;Minimize the total distance traveled by the pickers while satisfying the pick up demands and capacity constraints.&lt;/p&gt;&#xA;" OwnerUserId="12309" LastEditorUserId="491" LastEditDate="2023-08-19T13:49:56.927" LastActivityDate="2024-01-21T12:01:10.267" Title="Help with Mathematical Formulation for VRP with Specific Constraints" Tags="|optimization|mixed-integer-programming|vehicle-routing|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10860" PostTypeId="1" CreationDate="2023-08-20T05:53:36.117" Score="1" ViewCount="84" Body="&lt;p&gt;I'm currently working on a mixed-integer programming (MIP) problem and I'm trying to implement a set of conditional constraints in CPlex. These constraints involve decision variables that are indexed by the value of other variables. Specifically, I have the following types of constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{ct} = X_{ci} \ \ \ \ \ \forall c \in Crane, \ \ i \in Job, t \in [S_{ci}, ..., S_{ci}+p_{ci}[&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This constraint holds when Crane &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; starts job &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; during time &lt;span class=&quot;math-container&quot;&gt;$S_{ci},...,S_{ci}+p_{ci}$&lt;/span&gt;. I understand that this constraint involves conditional indexing and need to be linearized for Cplex. Could you please provide guidance on how I can linearize these constraints in CPlex?&lt;/p&gt;&#xA;&lt;p&gt;Additionally, if you're looking for relevant literature on this topic, I found the paper by Dorndorf and Schneider (2010) titled &amp;quot;Scheduling automated triple cross-over stacking cranes in a container yard&amp;quot; to be insightful.&lt;/p&gt;&#xA;" OwnerUserId="12313" LastEditorUserId="491" LastEditDate="2023-08-20T16:53:11.547" LastActivityDate="2023-08-20T16:53:11.547" Title="Linearization of Conditional Constraints for MIP using Cplex" Tags="|cplex|linearization|scheduling|logical-constraints|indicator-constraints|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10862" PostTypeId="2" ParentId="10859" CreationDate="2023-08-21T01:45:08.370" Score="0" Body="&lt;p&gt;This is possible with LP but it isn't entirely straightforward.&lt;/p&gt;&#xA;&lt;p&gt;Right out the gate, ignore &lt;code&gt;n_pickers = 7&lt;/code&gt;. Your objective is only on total distance and not total time, which is a very different creature; so we can imagine that an optimal system smells the same regardless of whether you have one picker or 700.&lt;/p&gt;&#xA;&lt;p&gt;With&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;picker capacity &lt;span class=&quot;math-container&quot;&gt;$c = 25$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;node count &lt;span class=&quot;math-container&quot;&gt;$n = 19$&lt;/span&gt;, and&lt;/li&gt;&#xA;&lt;li&gt;node demand &lt;span class=&quot;math-container&quot;&gt;$d_i &amp;gt; c \; \forall i$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There is an important pre-solve step - run a fixed number of visits to each node at full capacity equal to &lt;span class=&quot;math-container&quot;&gt;$$ \lfloor\frac {d_i} c \rfloor $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;After these fixed visits, we can guarantee that the remaining &lt;span class=&quot;math-container&quot;&gt;$0 \le d_i &amp;lt; c \; \forall i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then you'll need distinct circuits. It's easy to prove that the maximum number of non-degenerate circuits is &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;With&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;graph edges &lt;span class=&quot;math-container&quot;&gt;$e_{ijk}$&lt;/span&gt; (source &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, dest &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and circuit &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;),&lt;/li&gt;&#xA;&lt;li&gt;graph node visit assignments &lt;span class=&quot;math-container&quot;&gt;$a_{ik}$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;units picked up per node visit &lt;span class=&quot;math-container&quot;&gt;$u_{ik}$&lt;/span&gt;, and&lt;/li&gt;&#xA;&lt;li&gt;distances &lt;span class=&quot;math-container&quot;&gt;$\delta_{ij}$&lt;/span&gt;:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Care must be taken when defining &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;. No &lt;span class=&quot;math-container&quot;&gt;$(i, i)$&lt;/span&gt; is allowed, but &lt;em&gt;some&lt;/em&gt; matrix transposition must be allowed. The only situation where we permit an edge to be traversed twice is if it's from the depot to a node and directly back again; so a sample solution could end up looking like&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;node_b   0    1    2    3    4    5    6    7    8    9    10&#xA;node_a                                                       &#xA;0       NaN  0.0  1.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0&#xA;1       0.0  NaN  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0&#xA;2       1.0  NaN  NaN  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0&#xA;3       0.0  NaN  NaN  NaN  1.0  1.0  0.0  0.0  0.0  0.0  0.0&#xA;4       0.0  NaN  NaN  NaN  NaN  0.0  0.0  0.0  1.0  0.0  0.0&#xA;5       0.0  NaN  NaN  NaN  NaN  NaN  0.0  0.0  0.0  0.0  1.0&#xA;6       0.0  NaN  NaN  NaN  NaN  NaN  NaN  0.0  0.0  0.0  0.0&#xA;7       0.0  NaN  NaN  NaN  NaN  NaN  NaN  NaN  0.0  0.0  0.0&#xA;8       0.0  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  0.0  1.0&#xA;9       0.0  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  0.0&#xA;10      0.0  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;with &lt;code&gt;NaN&lt;/code&gt; where there is no edge assignment defined. (Notice the subtrip in the above - more on that in a minute.)&lt;/p&gt;&#xA;&lt;p&gt;Minimize the distance objective:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{ijk} e_{ijk} \delta_{ij}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subject to the following.&lt;/p&gt;&#xA;&lt;p&gt;The sum of visit units for each circuit must not exceed capacity:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i u_{ik} \le c \; \forall k$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The sum of visit units over all circuits for each node must equal the node's demand left over from after the unconditional trips:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_k u_{ik} = d_i \; \forall i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the visit is assigned, at least one unit must be picked up, and vice versa; here a suitable &lt;span class=&quot;math-container&quot;&gt;$M &amp;gt; d_i$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$a_{ik} \le u_{ik} \le M a_{ik}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Within each circuit, for each node, the number of associated edges must either be 2 if the visit is assigned (one ingress edge, one egress edge), or 0 otherwise (notably this is conditional whereas traditional TSP is unconditional):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j} e_{ijk} = 2 a_{ik} \; \forall i,k $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Specific to the depot, for each circuit, the number of egress (and, separately, ingress) edges must be 1 if there is any visit assigned in the circuit, or 0 otherwise:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\frac 1 n \sum_i a_{ik} \le \sum_i e_{i0k} \le \sum_i a_{ik} \; \forall k$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac 1 n \sum_j a_{jk} \le \sum_j e_{0jk} \le \sum_j a_{jk} \; \forall k$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;All of this will not be enough; you need subtrip elimination.  Read e.g. &lt;a href=&quot;https://www.math.uwaterloo.ca/tsp/methods/dfj/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dantzig cutting-plane&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11118" LastEditorUserId="11118" LastEditDate="2023-08-21T01:50:34.603" LastActivityDate="2023-08-21T01:50:34.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10863" PostTypeId="2" ParentId="10852" CreationDate="2023-08-21T15:47:13.587" Score="6" Body="&lt;p&gt;Pulp is missing the Python Cplex Piecewize feature, and IF/ELSE features.&#xA;Caylie Cincera has a nice video about this, she does a Piecewize included constraints optimization using Pulp:&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=0zP74EdmN0w&quot; rel=&quot;noreferrer&quot;&gt;https://www.youtube.com/watch?v=0zP74EdmN0w&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12321" LastEditorUserId="12321" LastEditDate="2023-08-21T15:59:13.857" LastActivityDate="2023-08-21T15:59:13.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10864" PostTypeId="1" CreationDate="2023-08-23T04:31:51.183" Score="1" ViewCount="118" Body="&lt;p&gt;There is an order batching problem.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Given a set of orders, they need to be split into several batches, with a maximum order number of M per batch.&lt;/li&gt;&#xA;&lt;li&gt;Each order needs to be picked from multiple storage areas. The set of storage areas is A.&lt;/li&gt;&#xA;&lt;li&gt;The goal is to find an optimal batching scheme, where the number of distinct storage areas (covered) is minimized for each batch.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To give an example, order o1 = {a, b, c} means that this order should be picked from storage areas a, b and c. order o2 = {b, c, d}, o3 = {e, f}, o4 = {e, h}, o5 = {j, k}. If M = 2, then the optimal solution is batch1 = {o1, o2} with cover storage areas {a, b, c, d}, batch2 = {o3, o4}, which cover areas {e, f, h}, and batch3 = {o5}.&lt;/p&gt;&#xA;&lt;p&gt;I have tried some heuristics. Can anyone give some exact algorithms that use dynamic programming or graph matching? Since an MIP solver is not available in my project, so I want to find some domain specific algorithms.&lt;/p&gt;&#xA;" OwnerUserId="12326" LastEditorUserId="12326" LastEditDate="2023-08-26T13:26:25.377" LastActivityDate="2023-08-26T19:19:07.230" Title="Matching algorithm in an order batching problem" Tags="|dynamic-programming|matching|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10865" PostTypeId="1" AcceptedAnswerId="10868" CreationDate="2023-08-23T12:35:05.293" Score="0" ViewCount="200" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is a given binary matrix of &lt;span class=&quot;math-container&quot;&gt;$M \times N$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; both are vectors of size &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; correspondingly, with non-negative elements.&lt;/p&gt;&#xA;&lt;p&gt;For given &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; we need to find any matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; of &lt;span class=&quot;math-container&quot;&gt;$M \times N$&lt;/span&gt; such that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max_{A_{i,j}} [(A \odot C) l]_k,&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;A_{i,j} &amp;gt; 0, \sum_{j} A_{i,j} = 1,\,  &#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(A \odot C) l - b \geq 0,&#xA;$$&lt;/span&gt;&#xA;where last inequality considered element-wise and &lt;span class=&quot;math-container&quot;&gt;$\odot$&lt;/span&gt; is element-wise product.&lt;/p&gt;&#xA;&lt;p&gt;If we can solve the optimization problem without finding matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; or have a good lower bound for it, it will be great, too.&lt;/p&gt;&#xA;" OwnerUserId="12333" LastEditorUserId="12333" LastEditDate="2023-08-23T15:21:58.667" LastActivityDate="2023-08-23T21:18:50.843" Title="How to reduce this problem to linear programming one?" Tags="|linear-programming|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10866" PostTypeId="1" CreationDate="2023-08-23T13:53:34.323" Score="0" ViewCount="214" Body="&lt;p&gt;I'm currently solving a MIP model with pyomo using gurobi and I am facing strange results.&lt;/p&gt;&#xA;&lt;p&gt;I have one constraint that looks like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def satisfacer_servicios_r1(modelo, s):&#xA;    return (sum(modelo.x[bv, s] for bv in modelo.BV) == 1)&#xA;modelo.satisfacer_servicios_r1 = pyo.Constraint(modelo.S, rule=satisfacer_servicios_r1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And x is defined as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;modelo.x = pyo.Var(modelo.BV, modelo.S, domain=pyo.Binary) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In the solution found by gurobi all x are equal to -1 nonetheless it says that constraint &amp;quot;satisfacer_servicios_r1&amp;quot; is active.&lt;/p&gt;&#xA;&lt;p&gt;Code to check x values:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;modelo.x.pprint()&#xA;x : Size=4250, Index=x_index&#xA;    Key       : Lower : Value : Upper : Fixed : Stale : Domain&#xA;       (1, 1) :     0 :  -0.0 :     1 : False : False : Binary&#xA;       (1, 5) :     0 :  -0.0 :     1 : False : False : Binary&#xA;      (1, 11) :     0 :  -0.0 :     1 : False : False : Binary&#xA;      (1, 15) :     0 :  -0.0 :     1 : False : False : Binary&#xA;      (1, 18) :     0 :  -0.0 :     1 : False : False : Binary&#xA;      (1, 31) :     0 :  -0.0 :     1 : False : False : Binary&#xA;      (1, 34) :     0 :  -0.0 :     1 : False : False : Binary&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Code to check constraint status:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;modelo.satisfacer_servicios_r1.pprint()&#xA;satisfacer_servicios_r1 : Size=85, Index=S, Active=True&#xA;    Key : Lower : Body                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         : Upper : Active&#xA;      1 :   1.0 :x[1,1] + x[2,1] + x[3,1] + x[4,1] + x[5,1] + x[6,1] + x[7,1] + x[8,1] + x[9,1] + x[10,1] + x[11,1] + x[12,1] + x[13,1] + x[14,1] + x[15,1] + x[16,1] + x[17,1] + x[18,1] + x[19,1] + x[20,1] + x[21,1] + x[22,1] + x[23,1] + x[24,1] + x[25,1] + x[26,1] + x[27,1] + x[28,1] + x[29,1] + x[30,1] + x[31,1] + x[32,1] + x[33,1] + x[34,1] + x[35,1] + x[36,1] + x[37,1] + x[38,1] + x[39,1] + x[40,1] + x[41,1] + x[42,1] + x[43,1] + x[44,1] + x[45,1] + x[46,1] + x[47,1] + x[48,1] + x[49,1] + x[50,1] :   1.0 :   True&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Gurobi log:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x22053: 587140 rows, 21953 columns, 2317504 nonzeros&#xA;Set parameter MIPGap to value 0.15&#xA;Gurobi Optimizer version 10.0.1 build v10.0.1rc0 (win64)&#xA;CPU model: AMD Ryzen 7 5800H with Radeon Graphics, instruction set [SSE2|AVX|AVX2]&#xA;Thread count: 8 physical cores, 16 logical processors, using up to 16 threads&#xA;Optimize a model with 587140 rows, 21953 columns and 2317504 nonzeros&#xA;Model fingerprint: 0x7427a6f5&#xA;Variable types: 8653 continuous, 13300 integer (13300 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [8e-02, 5e+02]&#xA;  Objective range  [1e+00, 1e+00]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [1e+00, 1e+03]&#xA;Presolve removed 196104 rows and 8802 columns (presolve time = 5s) ...&#xA;Presolve removed 200354 rows and 8802 columns (presolve time = 10s) ...&#xA;Presolve removed 200354 rows and 8802 columns&#xA;Presolve time: 13.18s&#xA;Presolved: 386786 rows, 13151 columns, 1221701 nonzeros&#xA;Variable types: 151 continuous, 13000 integer (13000 binary)&#xA;Found heuristic solution: objective 118.1166667&#xA;Root simplex log...&#xA;Iteration    Objective       Primal Inf.    Dual Inf.      Time&#xA;       0    1.0250000e+02   0.000000e+00   8.600000e+00     25s&#xA;     107    1.0250000e+02   0.000000e+00   0.000000e+00     25s&#xA;     107    1.0250000e+02   0.000000e+00   0.000000e+00     25s&#xA;     107    1.0250000e+02   0.000000e+00   0.000000e+00     25s&#xA;Use crossover to convert LP symmetric solution to basic solution...&#xA;Root crossover log...&#xA;    8514 PPushes remaining with PInf 0.0000000e+00                25s&#xA;    1154 PPushes remaining with PInf 0.0000000e+00                30s&#xA;       0 PPushes remaining with PInf 0.0000000e+00                35s&#xA;  Push phase complete: Pinf 0.0000000e+00, Dinf 2.3045463e-11     35s&#xA;Root simplex log...&#xA;Iteration    Objective       Primal Inf.    Dual Inf.      Time&#xA;    8624    1.0250000e+02   0.000000e+00   0.000000e+00     35s&#xA;Root relaxation: objective 1.025000e+02, 8624 iterations, 12.16 seconds (10.88 work units)&#xA;Total elapsed time = 60.91s&#xA;Total elapsed time = 67.15s&#xA;Total elapsed time = 73.27s&#xA;Total elapsed time = 75.11s&#xA;    Nodes    |    Current Node    |     Objective Bounds      |     Work&#xA; Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time&#xA;     0     0  102.50000    0   76  118.11667  102.50000  13.2%     -   76s&#xA;Explored 1 nodes (45160 simplex iterations) in 76.75 seconds (82.07 work units)&#xA;Thread count was 16 (of 16 available processors)&#xA;Solution count 1: 118.117 &#xA;Optimal solution found (tolerance 1.50e-01)&#xA;Best objective 1.181166666666e+02, best bound 1.025000000000e+02, gap 13.2214%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Edit: I have fixed the value of one x to 1 and then check the behaviour after this. The fix works and the value is 1 on the solution, but now I have noticed that some of the x values are not 0, but -0. I do not know what this means.&lt;/p&gt;&#xA;" OwnerUserId="12334" LastEditorUserId="12334" LastEditDate="2023-08-25T13:11:31.107" LastActivityDate="2024-01-22T14:04:55.657" Title="Gurobi founds optimal solution but it is not feasible" Tags="|gurobi|pyomo|binary-variable|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10867" PostTypeId="2" ParentId="10865" CreationDate="2023-08-23T16:17:04.510" Score="4" Body="&lt;p&gt;If you change the lower bound &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;0$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\ge 0$&lt;/span&gt; (alternatively, &lt;span class=&quot;math-container&quot;&gt;$\ge \epsilon$&lt;/span&gt; for some fixed positive &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;), this is already a linear programming problem.  Explicitly, the problem is to maximize &lt;span class=&quot;math-container&quot;&gt;$$\sum_j A_{kj} C_{kj} \ell_j$$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;A_{ij} &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $i$ and $j$} \\&#xA;\sum_j A_{ij} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \\&#xA;\sum_j A_{ij} C_{ij} \ell_j &amp;amp;\ge b_i &amp;amp;&amp;amp;\text{for all $i$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Assuming the problem is feasible, the optimal objective value should be&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\max_j C_{kj} \ell_j,$$&lt;/span&gt;&#xA;attained by taking &lt;span class=&quot;math-container&quot;&gt;$A_{kj}=1$&lt;/span&gt; for the largest &lt;span class=&quot;math-container&quot;&gt;$C_{kj} \ell_j$&lt;/span&gt; among all &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-08-23T18:57:20.753" LastActivityDate="2023-08-23T18:57:20.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10868" PostTypeId="2" ParentId="10865" CreationDate="2023-08-23T16:39:06.163" Score="1" Body="&lt;p&gt;Here's my best guess:&lt;/p&gt;&#xA;&lt;p&gt;With&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Index &lt;span class=&quot;math-container&quot;&gt;$0 \le i &amp;lt; M$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Index &lt;span class=&quot;math-container&quot;&gt;$0 \le j &amp;lt; N$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Known &lt;span class=&quot;math-container&quot;&gt;$C_{ij} \in \lbrace 0, 1 \rbrace \; \forall i,j $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Known &lt;span class=&quot;math-container&quot;&gt;$b_i \ge 0 \; \forall i $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Known &lt;span class=&quot;math-container&quot;&gt;$l_j \ge 0 \; \forall j $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Known &lt;span class=&quot;math-container&quot;&gt;$0 \le k &amp;lt; N $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Unknown &lt;span class=&quot;math-container&quot;&gt;$A_{ij} \ge 0 \; \forall i,j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Minimize&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{A_{ij}} \left( -\sum_i \sum_j A_{ij} C_{ij} l_j \right)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;but &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is fixed at &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and all other &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; are ignored, so&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{A_{kj}} \left( - \sum_j l_j A_{kj} C_{kj} \right)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In practical terms, you simply drop all rows of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; except those at &lt;span class=&quot;math-container&quot;&gt;$i=k$&lt;/span&gt;; and would also want to drop all &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is zero during your implementation; so&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{A_{kj}} \left( - \sum_{j| C_{kj}=1} l_j A_{kj} \right) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;LP solvers will accept&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$c_j = -l_j \; \forall j| C_{kj}=1 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;as the optimization coefficient vector.&lt;/p&gt;&#xA;&lt;p&gt;Importantly, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; only has one subset of one row with any meaningfully optimized values. Your constraints will be similarly reduced. You need to decide what to fill &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; with in the off-elements - zero? After optimization there's still an infinite number of states for the full version of &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; that would satisfy your constraints. To demonstrate one simple option,&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import numpy as np&#xA;from numpy.random import default_rng&#xA;from scipy.optimize import milp, Bounds, LinearConstraint&#xA;&#xA;rand = default_rng(seed=0)&#xA;&#xA;M = 9&#xA;N = 5&#xA;k = 1&#xA;b = rand.uniform(low=0, high=1, size=M)&#xA;l = rand.uniform(low=0, high=10, size=N)&#xA;C = rand.integers(low=0, high=1, endpoint=True, size=(M, N))&#xA;b *= C.any(axis=1)  # enforce feasibility for zero rows&#xA;i = k&#xA;j, = C[i, :].nonzero()&#xA;&#xA;Arow_eq_1 = LinearConstraint(A=np.ones(len(j)), lb=1, ub=1)&#xA;ACl_ge_b = LinearConstraint(A=l[j], lb=b[i])&#xA;&#xA;result = milp(&#xA;    c=-l[j],              # maximize ACl&#xA;    bounds=Bounds(lb=0),  # Ai,j &amp;gt;= 0&#xA;    constraints=(Arow_eq_1, ACl_ge_b),&#xA;)&#xA;assert result.success, result.message&#xA;&#xA;is_nonzero = C.any(axis=1)&#xA;A = np.zeros((M, N))&#xA;Cl = C[is_nonzero, :] * l&#xA;A[is_nonzero, :] = Cl / Cl.sum(axis=1, keepdims=True)&#xA;A[~is_nonzero, 0] = 1&#xA;A[i, j] = result.x&#xA;&#xA;print('A =')&#xA;print(A)&#xA;print('Evaluated constraint 1: 1 =', A.sum(axis=1))&#xA;print('Evaluated constraint 2: 0 &amp;lt;=', (A*C)@l - b)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;A =&#xA;[[0.53321056 0.46522785 0.00156159 0.         0.        ]&#xA; [1.         0.         0.         0.         0.        ]&#xA; [1.         0.         0.         0.         0.        ]&#xA; [0.         0.         0.00306413 0.95935669 0.03757918]&#xA; [0.         0.99665462 0.00334538 0.         0.        ]&#xA; [0.5231906  0.4564854  0.00153224 0.         0.01879176]&#xA; [0.35357075 0.30849157 0.00103549 0.32420278 0.01269942]&#xA; [0.         0.47798969 0.         0.5023333  0.01967701]&#xA; [0.53404452 0.46595548 0.         0.         0.        ]]&#xA;Evaluated constraint 1: 1 = [1. 1. 1. 1. 1. 1. 1. 1. 1.]&#xA;Evaluated constraint 2: 0 &amp;lt;= [8.14456396 9.08093752 0.         8.22174277 7.31806353 7.71006106&#xA; 8.00036824 7.48383514 8.25159239]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11118" LastEditorUserId="11118" LastEditDate="2023-08-23T21:18:50.843" LastActivityDate="2023-08-23T21:18:50.843" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10869" PostTypeId="2" ParentId="10859" CreationDate="2023-08-24T10:34:42.170" Score="0" Body="&lt;p&gt;In Timefold (open source, java), start from the capacitated VRP quickstarts (&lt;a href=&quot;https://www.youtube.com/watch?v=JaP6rgvElhc&quot; rel=&quot;nofollow noreferrer&quot;&gt;see this video&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;One not-very-sophisticated way to solve it:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If a visit has 40 units, split it up into 40 visits at the same location.&lt;/li&gt;&#xA;&lt;li&gt;Create a src/main/resources/solverConfig.xml (see vaccination quickstart how) and configure ListChangeMoveSelector and ListSwapMoveSelector together with the normal change, swap and tailSwap moves. &lt;a href=&quot;https://timefold.ai/docs/timefold-solver/latest/move-and-neighborhood-selection/move-and-neighborhood-selection.html#listMoveSelectors&quot; rel=&quot;nofollow noreferrer&quot;&gt;See docs.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;A much more sophisticated way would be to not split up the demands, to drop capacity as a constraint and instead introduce a shadow variable &amp;quot;Visit.unitsCollectedThisFar&amp;quot; (and Visit.arrivalTime like in VRPTW) to force the pickers to go back-and-forth to the depot in the middle of a picking. This would scale much better in case you want to handle thousands of pickers.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2023-08-24T10:34:42.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10870" PostTypeId="1" CreationDate="2023-08-24T11:43:56.197" Score="1" ViewCount="123" Body="&lt;p&gt;I was trying to solve a MILP by a column generation algorithm, and I noticed that the algorithm was stuck at the same solution, I tried to diversify the pool of initial columns, but the problem I faced was that even if the MP solved by CPLEX gave the optimal solution, the algorithm cannot prove it and keep returning it.&lt;/p&gt;&#xA;" OwnerUserId="5537" LastActivityDate="2023-08-24T11:43:56.197" Title="Why the column generation algorithm remains stuck at the same solution?" Tags="|optimization|mixed-integer-programming|cplex|column-generation|" AnswerCount="0" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="10871" PostTypeId="1" CreationDate="2023-08-24T12:57:24.387" Score="0" ViewCount="32" Body="&lt;p&gt;I am trying to implemet the subgradient method in Lagragian relaxation to update the multiplier lamda which has three dimension, I have ecountered an Except error, it looks the is bugs in the code. it shows the following error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;---&amp;gt; 39          lamda[i,k] = max(0,lamda[i,k] + b_Ax[i,k])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;TypeError: list indices must be integers or slices, not tuple&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;J=2&#xA;I=3&#xA;K=3&#xA;b = np.ones((I,K))&#xA;#Initial data&#xA;m=0 #number of iterations to start with in the algorithm&#xA;n=0 #iteration count that is incremented when LBb is not imprtoved&#xA;N= 3 # Maximum number of iterations count (max iter with improvement)&#xA;M= 1 #Maximum number of itereations allowed in the heuristic i.e LR heuristic&#xA;LB_b= -math.inf #best lower bound&#xA;UB_b= math.inf #best upper bound&#xA;pi_m= 1   # step size&#xA;epsilon= 0.001 # gap limit&#xA;tao= 0.001 #limit for tild_m where tildm goes to zero after some iterations.&#xA;beta= 0.5# scalar multiplied by tildm&#xA;tild_m= 1  # scalar oaly a role in reducing the step size after some iterations.&#xA;lamda = np.zeros((I,K))&#xA;# Decision varaibles&#xA;x_m = model.addVars(I,J,K,vtype=GRB.BINARY, name ='x_m')&#xA;#Lagrange relaxation&#xA;for m in range(M):&#xA;    #Relaxed porblem_in this case the Lower bound&#xA;    z1 =(9*x_m[0,0,0]+ 2*x_m[0,1,0]+ x_m[1,0,1] + 2*x_m[1,1,1] + 3*x_m[2,0,2] + &#xA;    8*x_m[2,1,2] + sum(lamda[i,k]*b[i,k]- lamda[i,k]*sum(x_m[i, j,k] for j in range(J)) &#xA;    for i in range(I) for k in range(K)))&#xA;    model.setObjective(z1,GRB.MINIMIZE)&#xA;    model.addConstr(6*x_m[0,0,0] +7*x_m[1,0,1] + 9*x_m[2,0,2] &amp;lt;= 13, &amp;quot;const1&amp;quot;)&#xA;    model.addConstr(8*x_m[0,1,0]+5*x_m[1,1,1]+6*x_m[2,1,2] &amp;lt;= 11, &amp;quot;const2&amp;quot;)&#xA;    model.optimize()&#xA;    LB_m = model.objVal&#xA;    if LB_m &amp;gt; LB_b:&#xA;       LB_b=LB_m&#xA;       n=0&#xA;    else:&#xA;       n+=1&#xA;       if n == N:&#xA;          tild_m=beta*tild_m&#xA;          n=0&#xA;    b_Ax1 = [b[i,k] - sum(x_m[i,j,k].x  for j in range(J))  for i in range(I) for k in &#xA;    range(K)]&#xA;    b_Ax = [pi_m*num for num in b_Ax1]&#xA;    b_Axr = sum(b[i,k]- sum(x_m[i, j, k].x for j in range(J)) for i in range(I) for k in &#xA;    range(K))&#xA;    # the solution of relaxed problem will be feasible to original problem,&#xA;    UB_b=18 &#xA;    gap = abs(UB_b-LB_b)/ (UB_b)&#xA;    if (UB_b-LB_b)/ UB_b &amp;lt;= epsilon:&#xA;        break&#xA;    else:&#xA;        for i in range(I):&#xA;            for k in range(K):&#xA;                lamda[i,k] = max(0,lamda[i,k] + b_Ax[i,k])&#xA;    pi_m = pi_m = tild_m*((UB_b-LB_b)/(LA.norm(b_Axr)**2))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12255" LastActivityDate="2023-08-24T12:57:24.387" Title="Error while using subgradient method to update lagrange multipliers" Tags="|python|algorithms|lagrange-multipliers|gurobipy|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10872" PostTypeId="2" ParentId="10866" CreationDate="2023-08-24T14:22:03.517" Score="0" Body="&lt;p&gt;This problem usually occurs when you have issues with numerical precision, stemming from parameters that are much larger than they should be. Things you should ask yourself:&lt;/p&gt;&#xA;&lt;p&gt;Am I using big M? If yes, is it properly scaled?&#xA;Are the parameters I'm using on very different scales? Do I have any parameters in the billions and others in other ranges? If so, it might be reasonable to consider rounding.&lt;/p&gt;&#xA;" OwnerUserId="5355" LastActivityDate="2023-08-24T14:22:03.517" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10873" PostTypeId="1" CreationDate="2023-08-24T14:31:45.270" Score="0" ViewCount="46" Body="&lt;p&gt;I have about 300 orders, where each order consists of different products that comes from a city (in total I have about 30 cities and around 100 products from all orders).&lt;/p&gt;&#xA;&lt;p&gt;My job is to allocate the orders to specific factories that can produce those products. There are 10 factories, each with varying distance to the demand locations. Now obviously I want to allocate the orders to the closest factory to minimize the transportation cost.&lt;/p&gt;&#xA;&lt;p&gt;However the production capacity for each product at different factory is limited, for example, say factory 1 is the closest to city 1, but can only produce 100 product 1, whereas city 1 ordered 200 product 1, so in this case I have to look for other factories that has a higher production power because I don't want to split the orders.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, factory will accept orders that the total volume of products from those orders can fit into a full load of a truck (or integer multiples of a truckload), a factory can accept multiple orders, I am also allowed to make extra orders (with the products I choose) to make sure the volume satisfies the truckload requirement.&lt;/p&gt;&#xA;&lt;p&gt;My goals are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;meet the demands from customer without splitting the order.&lt;/li&gt;&#xA;&lt;li&gt;minimize the transportation fee while making sure the factories have enough labors to produce.&lt;/li&gt;&#xA;&lt;li&gt;making fewest extra orders to fulfill the truckload requirement&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;How should I start formulating this problem? I feel like this has the flavour of a bin packing problem, but it seems I have two &amp;quot;layers&amp;quot; of bins, where I want to package items into a single order and then put the orders into different trucks, how would I formulate the &amp;quot;no splitting&amp;quot; requirement for an order? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="4743" LastActivityDate="2023-08-24T20:03:25.387" Title="Order fulfilment with constraints on factory production capacity and truckload" Tags="|mixed-integer-programming|packing|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10874" PostTypeId="2" ParentId="10873" CreationDate="2023-08-24T15:51:19.373" Score="1" Body="&lt;p&gt;Try with a binary variable &lt;span class=&quot;math-container&quot;&gt;$ x_{c,o,p}^{f}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is index for set of cities &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$o$&lt;/span&gt; is index for set of orders &lt;span class=&quot;math-container&quot;&gt;$\{O \}$&lt;/span&gt; within a city &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is the product type/category from product set &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is the factory. &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_{cop}^f = 1$&lt;/span&gt; if full volume of product in an order &lt;span class=&quot;math-container&quot;&gt;$o$&lt;/span&gt; is assigned to factory &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; from set &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise&lt;/p&gt;&#xA;&lt;p&gt;Parameters:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$v_{c,o,p} =$&lt;/span&gt; volume (integer) of product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; in an order &lt;span class=&quot;math-container&quot;&gt;$o$&lt;/span&gt; from a city &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.&lt;br /&gt;&#xA;You can drop &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; if order has unique identifier &amp;amp; use &lt;span class=&quot;math-container&quot;&gt;$ v_{o,p}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ L_f =$&lt;/span&gt; truckload for factory &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ C_{p,f} =$&lt;/span&gt; production capacity for product &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; at factory &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ D_{c,f}, T_{c,f} = $&lt;/span&gt;Distance &amp;amp; transport cost matrix&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ D_c = \{f \in F | f_i \le f_j \ \forall i,j \in F \}$&lt;/span&gt;: basically fo each city &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; a set of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; in ascending order of distance&lt;br /&gt;&#xA;Derived Set &lt;span class=&quot;math-container&quot;&gt;$ COP = \{(c,o,p) \} =$&lt;/span&gt; combination of (city,order,product)&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_f x_{c,o,p}^f = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_c \sum_o v_{c,o,p}x_{c,o,p}^f  \le C_{p,f} \quad \forall f \ \ \forall p$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{k \in D_c}^{f} x_{c,o,p}^k \le 1 \quad \forall f \in D_c \ \ \forall c,o,p \in COP $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{c,o,p} v_{c,o,p}x_{c,o,p}^f \le I \times L_f \quad \forall f$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is the integer of truck load &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objective:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\min (\sum_f (L_f - \sum_{cop}v_{c,o,p}x_{c,o,p}^f) + \sum_{f}\sum_{c,o,p}T_{c,f}x_{c,o,p}^f )$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-08-24T20:03:25.387" LastActivityDate="2023-08-24T20:03:25.387" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10875" PostTypeId="1" CreationDate="2023-08-24T20:34:38.823" Score="3" ViewCount="129" Body="&lt;p&gt;I have a problem in the following form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\begin{array}{cll}&#xA;\sup_{\theta \in \mathrm{dom}(f)} &amp;amp;  \inf_{z \in \mathbb{R}^n} &amp;amp; \underbrace{f(\theta)}_{\text{concave in $\theta$}} + \underbrace{\theta \cdot z^{\top} c}_{\text{linear in $\theta$ and $z$}} \\&#xA;&amp;amp; \mathrm{subject\;to} &amp;amp; \underbrace{g(\theta, z)}_{\text{convex in $\theta$ and $z$}} \leq 0.&#xA;\end{array}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;What conditions do we need so to be able to change the order of &lt;span class=&quot;math-container&quot;&gt;$\sup$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\inf$&lt;/span&gt;? Notice that when the outer problem fixes &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; the inner problem behaves well, as the objective is linear in &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and the constraints are convex. On the other hand, if we fix some &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; value, then the objective is convex in &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt; (as it becomes concave maximization) and again the constraints are convex in &lt;span class=&quot;math-container&quot;&gt;$\theta$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Proposition 5.5.4 of Convex Optimization Theory by Bertsekas gives conditions to change the order of &lt;span class=&quot;math-container&quot;&gt;$\sup$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\inf$&lt;/span&gt;, but there the constraints are separable in the sense that there is no constraint like &lt;span class=&quot;math-container&quot;&gt;$g(\theta, z) \leq 0$&lt;/span&gt;; rather, &lt;span class=&quot;math-container&quot;&gt;$\theta \in \Theta$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z \in Z$&lt;/span&gt;, separately.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2023-08-24T20:34:38.823" Title="Changing the order of $\sup$ and $\inf$" Tags="|convexity|minimax|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10876" PostTypeId="1" AcceptedAnswerId="10886" CreationDate="2023-08-25T01:45:22.553" Score="1" ViewCount="150" Body="&lt;p&gt;There is a one-dimensional bin-packing problem.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There is a collection of items that need to be divided into several groups, with a maximum of M items per group.&lt;/li&gt;&#xA;&lt;li&gt;Each item includes several characters, for example item1 = ABC and item2 = CDF. If item1 and item2 are assigned to the same group, then the distinct characters covered by this group is ABCDF.&lt;/li&gt;&#xA;&lt;li&gt;Let A be the set of all character sets. The objective is to find an optimal grouping scheme that minimizes the number of characters covered by each group.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I have tried some heuristics. Can anyone give some exact algorithms that use dynamic programming or graph matching?&lt;/p&gt;&#xA;" OwnerUserId="12326" LastActivityDate="2023-08-27T15:36:00.803" Title="Exact algorithms for a bin packing problem" Tags="|matching|packing|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="10877" PostTypeId="1" AcceptedAnswerId="10884" CreationDate="2023-08-25T07:44:38.707" Score="2" ViewCount="120" Body="&lt;p&gt;Switching over from CPLEX Optimization Studio, now I want to solve problems in C++ using the CPLEX API.&lt;/p&gt;&#xA;&lt;p&gt;Being used to the CPLEX data types, I was wondering how they best translate to C++.&lt;/p&gt;&#xA;&lt;p&gt;For example, using string arrays in CPLEX, what's the best way to represent them in C++?&#xA;A vector? pointer?&lt;/p&gt;&#xA;&lt;p&gt;Maybe there exists some kind of guide for this?&lt;/p&gt;&#xA;" OwnerUserId="12130" LastActivityDate="2023-08-26T16:24:15.630" Title="Which data type is best used when programming an optimization problem in C++?" Tags="|optimization|cplex|c++|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10880" PostTypeId="2" ParentId="10877" CreationDate="2023-08-25T15:43:52.590" Score="1" Body="&lt;p&gt;I would suggest taking a look at the C++ source code examples that ship with CPLEX Optimization Studio. Then have a look at the documentation for the C++ API, specifically for the optim.concert group. You'll find built in support for a lot of array types.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-08-25T15:43:52.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10881" PostTypeId="2" ParentId="10864" CreationDate="2023-08-25T18:16:05.833" Score="1" Body="&lt;p&gt;It seems to be a maximal &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Clique_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;clique&lt;/a&gt; problem. The larger the clique (subset of vertices- orders with a common storage area as edge) smaller will be number of storage areas covered.&lt;br /&gt;&#xA;Seems there's no straight forward algorithm possible in polynomial time but a Bron–Kerbosch algorithm has been referred.&#xA;Other than that using my simple OR skills I can try an MIP &amp;amp; set covering technique.&#xA;Define set of batches &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; of same cardinality as number of orders &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt; because that's the maximum batch possible&lt;br /&gt;&#xA;Define multiple sets &lt;span class=&quot;math-container&quot;&gt;$S_o$&lt;/span&gt; as the set of storage areas &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; from where order &lt;span class=&quot;math-container&quot;&gt;$o$&lt;/span&gt; can be picked. It can be a matrix also as &lt;span class=&quot;math-container&quot;&gt;$M_{s,o}=1$&lt;/span&gt; if order can be picked from a storage area, else &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Optimization variable:&lt;br /&gt;&#xA;Binary &lt;span class=&quot;math-container&quot;&gt;$x_{o,b}=1$&lt;/span&gt; if order &lt;span class=&quot;math-container&quot;&gt;$o$&lt;/span&gt; is assigned to batch &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise.&lt;/p&gt;&#xA;&lt;p&gt;Binary &lt;span class=&quot;math-container&quot;&gt;$y_{s,b} = 1$&lt;/span&gt; if storage &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; is covered by a batch &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;,&lt;/p&gt;&#xA;&lt;p&gt;Binary &lt;span class=&quot;math-container&quot;&gt;$z_b = 1$&lt;/span&gt; if batch &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is chosen&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_b x_{o,b} = 1 \quad \forall o$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ z_b \le \sum_o x_{o,b} + \sum_s y_{s,b}\le C_bz_b \quad \forall b$&lt;/span&gt;: where &lt;span class=&quot;math-container&quot;&gt;$C_b$&lt;/span&gt; may be a batch capacity in terms of orders or storage. You can split it also into one for constraining number of orders per batch &amp;amp; another with &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; ensuring no storage is included in a batch unless batch is chosen&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ y_{s,b} \le \sum_o M_{s,o}x_{o,b} \le Ty_{s,b}$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is a big number like &lt;span class=&quot;math-container&quot;&gt;$O \times S \times B$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ x_{o,b} \le \sum_{o' \in O \setminus o}\sum_{s} M_{s,o}M_{s,o'}x_{o',b} \quad \forall o, b$&lt;/span&gt;&lt;br /&gt;&#xA;Or&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_{o,b} \le \sum_s M_{s,o}y_{s,b} \quad \forall o,b$&lt;/span&gt;&lt;br /&gt;&#xA;Basically trying to constraint any order from being assigned to a batch if it doesn't share any storage area with any of the other orders&lt;/p&gt;&#xA;&lt;p&gt;Objective&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\min \sum_{s,b}y_{s,b} $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Another way - TSP:&lt;br /&gt;&#xA;@Ying multiple shared storage areas imply multiple edges (multi-graph). There will be algorithms for clique creation for multi-graphs. Otherwise you can define your own heuristic.&lt;br /&gt;&#xA;You can also try with &lt;a href=&quot;https://www.gurobi.com/jupyter_models/traveling-salesman/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Travelling Salesman problem&lt;/a&gt; (TSP): visiting all nodes covering minimum number of edges (storage). Typically in TSP sub-tours (batches of nodes) are eliminated. Here you may preserve subtours.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-08-26T19:19:07.230" LastActivityDate="2023-08-26T19:19:07.230" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10882" PostTypeId="2" ParentId="10864" CreationDate="2023-08-26T13:10:07.310" Score="1" Body="&lt;p&gt;It seems the problem you are facing is very similar to the storage location optimization and is categorized into the &lt;a href=&quot;https://or.stackexchange.com/a/10186/199&quot;&gt;warehouse optimization&lt;/a&gt; field and the following heuristic approach is highly effective for solving that.&lt;/p&gt;&#xA;&lt;p&gt;Suppose there is an order &lt;span class=&quot;math-container&quot;&gt;$O_1$&lt;/span&gt; with an order quantity equal to &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt;. Now, based on the working procedure, it needs to be split into two batches with a maximum order number of &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt; per batch. I assumed this limitation would get back to the batch’s storage area. Also, there exist four different SKUs in the &lt;span class=&quot;math-container&quot;&gt;$O_1$&lt;/span&gt; that need to be distinguished in the two batches by &lt;span class=&quot;math-container&quot;&gt;$2-2$&lt;/span&gt;. The first two SKUs should be picked in batch one, and the second two should be in the second batch. However, I still assumed the required quantity of each SKU in each order was equal to one.&lt;/p&gt;&#xA;&lt;p&gt;By the above assumptions, the quantity of each required SKU is equal to &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt;. Then without losing generality, and still by knowing each SKU needs a standard pallet, carton, or any packing list, we actually need &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt; packing boxes for each SKU. Now, if each of the batch storage areas can store only &lt;span class=&quot;math-container&quot;&gt;$50$&lt;/span&gt; boxes, the distinct storage areas would be at least &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; units of storage area. (E.g. number of racks, &lt;span class=&quot;math-container&quot;&gt;$M^2$&lt;/span&gt;, etc.). This actually comes from a concept so-called &lt;a href=&quot;https://www.routledge.com/Turbo-Flow-Using-Plan-for-Every-Part-PFEP-to-Turbo-Charge-Your-Supply/Conrad-Rooks/p/book/9781439820674&quot; rel=&quot;nofollow noreferrer&quot;&gt;PFEP&lt;/a&gt; or plan for every part.&lt;/p&gt;&#xA;&lt;p&gt;This situation is similar to when one would like to calculate the picking/packing area in the warehouse or determine the minimum number of WIP storage areas in the production line.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-08-26T13:10:07.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10883" PostTypeId="2" ParentId="10007" CreationDate="2023-08-26T13:21:02.050" Score="1" Body="&lt;p&gt;Another interesting tool would be &lt;a href=&quot;https://www.solvgraph.com/#/optimization/KNAPSACK/646c9419d3fc73b010e8b403&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;&lt;strong&gt;solvgraph&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt; which was developed by &lt;em&gt;&lt;strong&gt;@estelle derrien&lt;/strong&gt;&lt;/em&gt;. It actually tried to show the concept of an optimization model like the objective, constraints, etc. by a drag-and-drop scheme.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MeFRP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MeFRP.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-08-26T13:21:02.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10884" PostTypeId="2" ParentId="10877" CreationDate="2023-08-26T13:50:23.283" Score="2" Body="&lt;p&gt;There is no definitive answer and it depends on:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;your background&lt;/li&gt;&#xA;&lt;li&gt;the nature / characteristic of your problem&lt;/li&gt;&#xA;&lt;li&gt;the nature / characteristic of your implementation (proof of concept; deployed software)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As CPLEX' types basically behave like &lt;em&gt;smart pointers&lt;/em&gt; you are very flexible as this works well with most well-designed libraries.&lt;/p&gt;&#xA;&lt;p&gt;I'm one of those people dropping all those CPLEX provided containers (don't like them) and the following 3 categories of types / containers dominate all my c++-based modelling-code:&lt;/p&gt;&#xA;&lt;h3&gt;My go-to categories of types&lt;/h3&gt;&#xA;&lt;h4&gt;STL Containers / Algorithms&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Already mentioned in comments&lt;/li&gt;&#xA;&lt;li&gt;Typically:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vector, set/map, ...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Also compatible ones: boost containers, google's abseil, ...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;Eigen (&lt;a href=&quot;https://eigen.tuxfamily.org/index.php?title=Main_Page&quot; rel=&quot;nofollow noreferrer&quot;&gt;Link&lt;/a&gt;)&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;quot;Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.&amp;quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;boost::graph (&lt;a href=&quot;https://www.boost.org/doc/libs/1_83_0/libs/graph/doc/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Link&lt;/a&gt;)&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;quot;A generic interface for traversing graphs, using C++ templates.&amp;quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;Detail: STL&lt;/h4&gt;&#xA;&lt;p&gt;Most C++ programmers are very familiar with STL containers and it's a good idea to use them.&lt;/p&gt;&#xA;&lt;p&gt;At some point, those might not be enough howewer and some alternatives might become interesting:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;e.g. matrices (vector of vector is ugly, inefficient and usage is sub-optimal) or graphs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;Disclaimer: Eigen + boost::graph&lt;/h4&gt;&#xA;&lt;p&gt;Eigen as well as boost::graph are state of the art battle-tested libraries i highly recommend.&lt;/p&gt;&#xA;&lt;p&gt;Both howewer have some learning-curve.&lt;/p&gt;&#xA;&lt;p&gt;Both are header-only libs which make integration / building much easier.&lt;/p&gt;&#xA;&lt;h3&gt;Detail: Eigen&lt;/h3&gt;&#xA;&lt;p&gt;&lt;strong&gt;If my model has (dense) vectors, matrices or tensors, it's likely that i'm using Eigen&lt;/strong&gt; (limited to it's containers and related functionality; it offers much more we don't need).&lt;/p&gt;&#xA;&lt;p&gt;It basically allows everything what people also do in &lt;a href=&quot;https://numpy.org/doc/stable/user/basics.indexing.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;numpy&lt;/a&gt; (python):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;row/col-indexing&lt;/li&gt;&#xA;&lt;li&gt;fancy-indexing by vectors&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The docs for the parts most interesting for us: &lt;a href=&quot;https://eigen.tuxfamily.org/dox/group__TutorialSlicingIndexing.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Eigen: Slicing and Indexing&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Some example of row/col-based indexing typically happening in assignment-like subproblems.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;using MatrixVar = Eigen::Array&amp;lt;IloNumVar, Eigen::Dynamic, Eigen::Dynamic&amp;gt;;&#xA;using MatrixSol = Eigen::Array&amp;lt;double, Eigen::Dynamic, Eigen::Dynamic&amp;gt;;&#xA;&#xA;MatrixVar pos_class_mat(n_sequence, n_classes);&#xA;&#xA;// create variables&#xA;for(uint64_t s=0; s&amp;lt;n_sequence; ++s) {&#xA;  for(uint64_t c=0; c&amp;lt;n_classes; ++c) {&#xA;    pos_class_mat(s, c) = IloNumVar(env, 0, 1, ILOBOOL);&#xA;  }&#xA;} &#xA;&#xA;// exactly one classes chosen at each sequence-pos&#xA;for(uint64_t s=0; s&amp;lt;n_sequence; ++s) {&#xA;  IloExpr expr(env);&#xA;  for(auto&amp;amp; var : pos_class_mat(s, Eigen::all))&#xA;    expr += var;&#xA;  this-&amp;gt;model.add(expr == 1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In modern C++ we could also do nice things like:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;static auto get_sol(const MatrixVar&amp;amp; matrix, IloCplex&amp;amp; cplex) {&#xA;  auto extract = [&amp;amp;matrix, &amp;amp;cplex] (Eigen::Index i) { return cplex.getValue(matrix(i)); };&#xA;  return MatrixSol::NullaryExpr(matrix.rows(), matrix.cols(), extract);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This allows us to easily print it:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;std::cout &amp;lt;&amp;lt; get_sol(pos_class_mat, cplex) &amp;lt;&amp;lt; std::endl;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Detail: boost::graph&lt;/h3&gt;&#xA;&lt;p&gt;&lt;strong&gt;If my model has a graph-based structure i always use boost::graph which allows some powerful stuff.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I'm then able to structure the variable- and constraint objects.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;A somewhat &lt;strong&gt;convoluted example&lt;/strong&gt; trying to hint why this might be a good idea&#xA;-&amp;gt; handle complexity!.&lt;/p&gt;&#xA;&lt;p&gt;Here the code does not use CPLEX, but SCIP, but it does not matter. The concept is the same. Only the &lt;em&gt;handles&lt;/em&gt; for variables and constraints would be different (and i'm lazy).&lt;/p&gt;&#xA;&lt;h4&gt;Graphs-setup&lt;/h4&gt;&#xA;&lt;p&gt;We have a global-graph and many local-graphs with some implicit linking.&lt;/p&gt;&#xA;&lt;p&gt;Think &amp;quot;decomposition&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;The goal is to have &lt;strong&gt;a single model&lt;/strong&gt; allowing to be reused for:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;greedy-algorithms&#xA;&lt;ul&gt;&#xA;&lt;li&gt;solve first n parts only&lt;/li&gt;&#xA;&lt;li&gt;solve first n+1 parts only but fix decision of first n parts&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;large-neighborhood search&#xA;&lt;ul&gt;&#xA;&lt;li&gt;free some small ratio of decisions of some solution and resolve&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;just by using this structure (fixed or non-fixed variables).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// either a variable yet to be optimized or fixed (e.g. partially-fixed problem or full-fixed solution)&#xA;using MaybeContVar = std::variant&amp;lt;std::monostate, SCIP_VAR*, double&amp;gt;;&#xA;using MaybeUintVar = std::variant&amp;lt;std::monostate, SCIP_VAR*, uint64_t&amp;gt;;&#xA;using MaybeBoolVar = std::variant&amp;lt;std::monostate, SCIP_VAR*, bool&amp;gt;;&#xA;&#xA;struct GlobalGraphNodeParameters {&#xA;  std::optional&amp;lt;uint64_t&amp;gt; capacity;&#xA;};&#xA;&#xA;struct GlobalGraphNodeVariables {&#xA;  &#xA;};&#xA;&#xA;struct GlobalGraphNodeConstraints {&#xA;  SCIP_CONS* capacity_bound_in;&#xA;  SCIP_CONS* capacity_bound_out;&#xA;};&#xA;&#xA;struct GlobalGraphNode {&#xA;  GlobalGraphNodeParameters parameters;&#xA;  GlobalGraphNodeVariables variables;&#xA;  GlobalGraphNodeConstraints constraints;&#xA;};&#xA;&#xA;// -----&#xA;&#xA;struct GlobalGraphArcParameters {&#xA;  bool is_integral;&#xA;  boost::dynamic_bitset&amp;lt;&amp;gt; colors;&#xA;  std::optional&amp;lt;uint64_t&amp;gt; capacity;&#xA;  double cost_fixed;&#xA;  double cost_dynamic;&#xA;};&#xA;&#xA;struct GlobalGraphArcVariables {&#xA;  MaybeBoolVar is_open_negated;&#xA;  MaybeContVar is_open;&#xA;};&#xA;&#xA;struct GlobalGraphArcConstraints {&#xA;  SCIP_CONS* var_bool_open_neg_link;&#xA;  SCIP_CONS* capacity_bound_shared;&#xA;};&#xA;&#xA;struct GlobalGraphArc {&#xA;  uint64_t id;&#xA;&#xA;  GlobalGraphArcParameters parameters;&#xA;  GlobalGraphArcVariables variables;&#xA;  GlobalGraphArcConstraints constraints;&#xA;};&#xA;&#xA;using GlobalGraph = boost::adjacency_list&amp;lt;&#xA;  boost::vecS, boost::vecS, boost::bidirectionalS,&#xA;  GlobalGraphNode,&#xA;  GlobalGraphArc&amp;gt;;&#xA;&#xA;// --------------------&#xA;&#xA;struct LocalGraphNodeParameters {&#xA;  // positive -&amp;gt; can send at most&#xA;  // negative -&amp;gt; must receive at least&#xA;  int64_t flow_imbalance_capacity;&#xA;};&#xA;&#xA;struct LocalGraphNodeVariables {&#xA;};&#xA;&#xA;struct LocalGraphNodeConstraints {&#xA;  SCIP_CONS* flow_conservation_generalized;&#xA;};&#xA;&#xA;struct LocalGraphNode {&#xA;  bool is_valid;&#xA;&#xA;  LocalGraphNodeParameters parameters;&#xA;  LocalGraphNodeVariables variables;&#xA;  LocalGraphNodeConstraints constraints;&#xA;};&#xA;&#xA;// -----&#xA;&#xA;struct LocalGraphArcParameters {&#xA;  double cost_dynamic;&#xA;  std::optional&amp;lt;uint64_t&amp;gt; capacity;&#xA;};&#xA;&#xA;struct LocalGraphArcVariables {&#xA;  MaybeContVar flow;&#xA;};&#xA;&#xA;struct LocalGraphArcConstraints {&#xA;  SCIP_CONS* openess_indicator;&#xA;};&#xA;&#xA;struct LocalGraphArc {&#xA;  uint64_t id;&#xA;&#xA;  LocalGraphArcParameters parameters;&#xA;  LocalGraphArcVariables variables;&#xA;  LocalGraphArcConstraints constraints;&#xA;};&#xA;&#xA;// -----&#xA;&#xA;struct LocalGraphAuxParameters {&#xA;  std::optional&amp;lt;double&amp;gt; penalized_unperformed_allowed;&#xA;};&#xA;&#xA;struct LocalGraphAuxVariables {&#xA;  MaybeBoolVar is_unperformed;&#xA;};&#xA;&#xA;struct LocalGraphAuxConstraints {&#xA;};&#xA;&#xA;struct LocalGraphAux {&#xA;  LocalGraphAuxParameters parameters;&#xA;  LocalGraphAuxVariables variables;&#xA;  LocalGraphAuxConstraints constraints;&#xA;};&#xA;&#xA;using LocalGraph = boost::adjacency_list&amp;lt;&#xA;  boost::vecS, boost::vecS, boost::bidirectionalS,&#xA;  LocalGraphNode,&#xA;  LocalGraphArc,&#xA;  LocalGraphAux&amp;gt;;&#xA;&#xA;// Link global and local graph (decomposed parts) together&#xA;&#xA;struct Model {&#xA;  GlobalGraph global_graph;&#xA;  std::vector&amp;lt;std::optional&amp;lt;LocalGraph&amp;gt;&amp;gt; local_graphs;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h4&gt;Example usage&lt;/h4&gt;&#xA;&lt;p&gt;Then we could do cool things like:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;  auto es = boost::edges(lgraph);&#xA;  for(auto eit = es.first; eit != es.second; ++eit) {&#xA;    auto l_source_vertex = boost::source(*eit, lgraph); &#xA;    &#xA;    auto edge_in_global_graph_opt = get_specific_arc_incident(problem.global_graph, l_source_vertex, lgraph[*eit].id);&#xA;    assert(edge_in_global_graph_opt.has_value());&#xA;&#xA;    auto&amp;amp; props = lgraph[*eit];&#xA;    auto&amp;amp; props_in_global = problem.global_graph[edge_in_global_graph_opt.value()];&#xA;&#xA;    double flow_var_capacity = props.parameters.capacity.value_or(SCIPinfinity(scip));&#xA;    double cost_dynamic = props.parameters.cost_dynamic;&#xA;&#xA;    // flow&#xA;    if(std::holds_alternative&amp;lt;SCIP_VAR*&amp;gt;(props.variables.flow)) {&#xA;      // unfixed&#xA;      if(props_in_global.parameters.is_integral)&#xA;        SCIPcreateVar(scip, &amp;amp;std::get&amp;lt;SCIP_VAR*&amp;gt;(props.variables.flow), &amp;quot;flow&amp;quot;, 0.0, flow_var_capacity, cost_dynamic, SCIP_VARTYPE_INTEGER, TRUE, FALSE, NULL, NULL, NULL, NULL, NULL);&#xA;      else&#xA;        SCIPcreateVar(scip, &amp;amp;std::get&amp;lt;SCIP_VAR*&amp;gt;(props.variables.flow), &amp;quot;flow&amp;quot;, 0.0, flow_var_capacity, cost_dynamic, SCIP_VARTYPE_CONTINUOUS, TRUE, FALSE, NULL, NULL, NULL, NULL, NULL);&#xA;      SCIPaddVar(scip, std::get&amp;lt;SCIP_VAR*&amp;gt;(props.variables.flow));  &#xA;    }&#xA;    else if(std::holds_alternative&amp;lt;double&amp;gt;(props.variables.flow)) {&#xA;      // fixed&#xA;      double fixed_value = std::get&amp;lt;double&amp;gt;(props.variables.flow);&#xA;      props.variables.flow = MaybeContVar(std::in_place_type&amp;lt;SCIP_VAR*&amp;gt;);&#xA;&#xA;      if(props_in_global.parameters.is_integral)&#xA;        SCIPcreateVar(scip, &amp;amp;std::get&amp;lt;SCIP_VAR*&amp;gt;(props.variables.flow), &amp;quot;flow&amp;quot;, 0.0, flow_var_capacity, cost_dynamic, SCIP_VARTYPE_INTEGER, TRUE, FALSE, NULL, NULL, NULL, NULL, NULL);&#xA;      else&#xA;        SCIPcreateVar(scip, &amp;amp;std::get&amp;lt;SCIP_VAR*&amp;gt;(props.variables.flow), &amp;quot;flow&amp;quot;, 0.0, flow_var_capacity, cost_dynamic, SCIP_VARTYPE_CONTINUOUS, TRUE, FALSE, NULL, NULL, NULL, NULL, NULL);&#xA;      SCIPaddVar(scip, std::get&amp;lt;SCIP_VAR*&amp;gt;(props.variables.flow));&#xA;      SCIP_Bool infeasible;&#xA;      SCIP_Bool fixed;&#xA;      SCIPfixVar(scip, std::get&amp;lt;SCIP_VAR*&amp;gt;(props.variables.flow), fixed_value, &amp;amp;infeasible, &amp;amp;fixed);     &#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and also a minimal large-neighborhood search (changing fixed/sol -&amp;gt; unfixed/var for some parts):&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void Lns::parameterize_unstructured() {&#xA;  // Lets keep it sample -&amp;gt; randomize each decision&#xA;  std::bernoulli_distribution p_unfix(options.lns_unfix_probability);&#xA;&#xA;  // global&#xA;  {&#xA;    // GlobalGraphArcVariables&#xA;    auto es = boost::edges(working_model.global_graph);&#xA;    for (auto eit = es.first; eit != es.second; ++eit) {&#xA;      if(p_unfix(prng))&#xA;        working_model.global_graph[*eit].variables = GlobalGraphArcVariables {&#xA;          .is_open_negated = MaybeBoolVar(std::in_place_type&amp;lt;SCIP_VAR*&amp;gt;),&#xA;          .is_open = MaybeContVar(std::in_place_type&amp;lt;SCIP_VAR*&amp;gt;)&#xA;        };&#xA;    }&#xA;  }&#xA;&#xA;  // local&#xA;  for(auto&amp;amp; lgraph_opt : working_model.local_graphs) {&#xA;    assert(lgraph_opt.has_value());&#xA;&#xA;    // LocalGraphAuxVariables&#xA;    if(p_unfix(prng))&#xA;      lgraph_opt.value()[boost::graph_bundle].variables = LocalGraphAuxVariables {&#xA;        .is_unperformed = MaybeBoolVar(std::in_place_type&amp;lt;SCIP_VAR*&amp;gt;)&#xA;      };&#xA;&#xA;    // LocalGraphArcVariables&#xA;    auto es = boost::edges(lgraph_opt.value());&#xA;    for (auto eit = es.first; eit != es.second; ++eit) {&#xA;      if(p_unfix(prng))&#xA;        lgraph_opt.value()[*eit].variables = LocalGraphArcVariables {&#xA;          .flow = MaybeContVar(std::in_place_type&amp;lt;SCIP_VAR*&amp;gt;)&#xA;        };&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Summary / Recommendations&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Don't be scared not to use the provided types (&lt;code&gt;IloNumArray&lt;/code&gt; and co.)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If: stick to well-established alternatives (STL; maybe Eigen, boost::graph and co.)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Much larger community to help you out (usage is orthogonal to optimization and even non-optimization people can help)&lt;/li&gt;&#xA;&lt;li&gt;You can reuse concepts easily when changing the solver&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CPLEX, Gurobi, SCIP, CoinOR Cbc, ... It's just a different &lt;em&gt;handle-type&lt;/em&gt; within your containers&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Fun fact: Using python, i'm also using &lt;code&gt;numpy&lt;/code&gt; / &lt;code&gt;networkx&lt;/code&gt; quite frequently, despite the availability of high-lvl Python-based modelling-APIs (e.g. docplex)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Pick what's working for you&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you cannot invest the time to get ready for Eigen/boost::graph (both metaprogramming-heavy), it's probably not worth it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Ask yourself why you are using C++ and how you should make the best out of it&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Some do it because of performance (e.g. compared to python; only matters for model-setup)&lt;/li&gt;&#xA;&lt;li&gt;I mostly do it because of all those C++ capabilities&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Strong type-system, metaprogramming&lt;/li&gt;&#xA;&lt;li&gt;Also:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Availability of high-quality libraries&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Meaning: Small POCs won't always be C++-based and for sure won't look like above graph example&#xA;&lt;ul&gt;&#xA;&lt;li&gt;But at some point investing into the core-design helps to limit error-finding later!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="231" LastEditorUserId="231" LastEditDate="2023-08-26T16:24:15.630" LastActivityDate="2023-08-26T16:24:15.630" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10885" PostTypeId="1" AcceptedAnswerId="10887" CreationDate="2023-08-26T21:55:06.857" Score="1" ViewCount="55" Body="&lt;p&gt;I am looking at literature considering constrained optimization problems of the form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min_{x\in X\subseteq R^n} f(x), \text{ subject to } g_{oracle}(x) \leq 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The optimization algorithm doesn't know &lt;span class=&quot;math-container&quot;&gt;$g_{oracle}(\, .\,)$&lt;/span&gt; in closed form, but rather has to query the value of &lt;span class=&quot;math-container&quot;&gt;$g_{oracle}(x)$&lt;/span&gt; from an oracle for a given value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. Further, &lt;span class=&quot;math-container&quot;&gt;$g_{oracle}$&lt;/span&gt; may or may be able to return gradients with respect to &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This is motivated by the &lt;a href=&quot;https://en.wikipedia.org/wiki/Power_system_simulation#Optimal_power_flow&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimal Power Flow&lt;/a&gt; problem in electricity grids, which aims to optimize electricity costs subject to the physics of transferring electricity across the grid. Currently, OPF is solved by representing physics as linear or convex constraints, which are often low-fidelity. On the other hand, there do exist high-fidelity &lt;a href=&quot;https://en.wikipedia.org/wiki/Power-flow_study&quot; rel=&quot;nofollow noreferrer&quot;&gt;power flow&lt;/a&gt; simulators which do a better job of representing the physics. They correspond to the &lt;span class=&quot;math-container&quot;&gt;$g_{oracle}$&lt;/span&gt; in the above formulation.&lt;/p&gt;&#xA;&lt;p&gt;There are some papers in the power systems domain which use the above formulation in a Reinforcement Learning framework. However, I'm curious if there exists literature which considers general optimization problems of the above form?&lt;/p&gt;&#xA;" OwnerUserId="12346" LastActivityDate="2023-08-27T04:23:49.143" Title="Is there any literature on constrained nonlinear optimization where constraint returns have to be queried from an oracle?" Tags="|optimization|constraint|combinatorial-optimization|nonlinear-programming|global-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10886" PostTypeId="2" ParentId="10876" CreationDate="2023-08-27T02:11:18.143" Score="1" Body="&lt;p&gt;MIP is already exact. Let there be&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$l = 26$&lt;/span&gt; letters;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$m = 5$&lt;/span&gt; maximum group items;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$n = 7$&lt;/span&gt; as an example item count, also equal to the maximum number of groups;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$G_{i,j} \in \lbrace 0,1 \rbrace$&lt;/span&gt; binary group-item assignments, &lt;span class=&quot;math-container&quot;&gt;$0 \le i &amp;lt; n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0 \le j &amp;lt; n$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$I_{j,k} \in \lbrace 0,1 \rbrace$&lt;/span&gt; binary item-letter assignments, &lt;span class=&quot;math-container&quot;&gt;$0 \le j &amp;lt; n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0 \le k &amp;lt; l$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$L_{i,k}\in \lbrace 0,1 \rbrace$&lt;/span&gt; binary group-letter assignments, &lt;span class=&quot;math-container&quot;&gt;$0 \le i &amp;lt; n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0 \le k &amp;lt; l$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i \sum_k L_{i,k}$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$1=\sum_i G_{i,j} \;\forall j$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$m \ge \sum_j G_{i,j} \;\forall i$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$n L_{i,k} \ge \sum_j I_{j,k} G_{i,j} \;\forall i,k$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Works fine:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from string import ascii_uppercase&#xA;import scipy.sparse as sp&#xA;import numpy as np&#xA;from scipy.optimize import milp, Bounds, LinearConstraint&#xA;&#xA;&#xA;items = (&#xA;    'ABC', 'CDF', 'EHI', 'AHP', 'EPZ', 'CIZ', 'ITW',&#xA;)&#xA;&#xA;L = len(ascii_uppercase)&#xA;M = 5  # max items per group&#xA;N = len(items)&#xA;&#xA;&#xA;# Variables: NN item-group assignments; NL letter-group assignments&#xA;cost = np.concatenate((&#xA;    np.zeros(N*N),  # group-item assignments non-optimized&#xA;    np.ones(N*L),   # group-letter assignments minimized&#xA;))&#xA;&#xA;# Every item must be assigned to exactly one group&#xA;item_excl = LinearConstraint(&#xA;    A=sp.hstack(&#xA;        (sp.eye(N),)*N + (sp.csc_matrix((N, N*L)),),&#xA;        format='csc',&#xA;    ),&#xA;    lb=np.ones(N), ub=np.ones(N),&#xA;)&#xA;&#xA;# Every group can have at most M items (Kronecker)&#xA;group_capacity = LinearConstraint(&#xA;    A=sp.hstack((&#xA;        sp.kron(sp.eye(N), np.ones(N)),&#xA;        sp.csc_matrix((N, N*L)),&#xA;    ), format='csc'),&#xA;    ub=np.full(shape=N, fill_value=M),&#xA;)&#xA;&#xA;# For each letter of each item, that item must have at least one group assignment that in turn has&#xA;# a compatible letter assignment&#xA;item_block = sp.dok_array((L, N))&#xA;letter_block = sp.dok_array((L, L))&#xA;n_letters = 0&#xA;for letter in ascii_uppercase:&#xA;    items_with_letter = [i for i, word in enumerate(items) if letter in word]&#xA;    if len(items_with_letter) &amp;gt; 0:&#xA;        item_block[n_letters, items_with_letter] = -1&#xA;        letter_block[n_letters, ord(letter) - ord('A')] = N&#xA;        n_letters += 1&#xA;item_block = sp.block_diag((item_block[:n_letters, :],)*N, format='csc')&#xA;letter_block = sp.block_diag((letter_block[:n_letters, :],)*N, format='csc')&#xA;&#xA;letter_assigns = LinearConstraint(&#xA;    A=sp.hstack((item_block, letter_block), format='csc'),&#xA;    lb=np.zeros(n_letters*N),&#xA;)&#xA;&#xA;result = milp(&#xA;    c=cost,&#xA;    integrality=np.ones(N*N + N*L),  # all variables integral&#xA;    bounds=Bounds(lb=0, ub=1),       # all variables binary&#xA;    constraints=(item_excl, group_capacity, letter_assigns),&#xA;)&#xA;assert result.success, result.message&#xA;&#xA;item_assign, letter_assign = np.split(result.x, (N*N,))&#xA;item_assign = item_assign.reshape((N, N)).round().astype(int)&#xA;letter_assign = letter_assign.reshape((N, L)).round().astype(int)&#xA;&#xA;print('Item assignments:')&#xA;print(item_assign, end='\n\n')&#xA;&#xA;print('Letter assignments:')&#xA;print(letter_assign, end='\n\n')&#xA;&#xA;for i_group in range(N):&#xA;    group_assigns = item_assign[i_group]&#xA;    if group_assigns.any():&#xA;        group_letters = ''.join(ascii_uppercase[i] for i in letter_assign[i_group].nonzero()[0])&#xA;        print(f'Group {i_group} has letters {group_letters}, items',&#xA;              ', '.join(items[i] for i in group_assigns.nonzero()[0]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Item assignments:&#xA;[[1 0 1 1 1 1 0]&#xA; [0 0 0 0 0 0 1]&#xA; [0 0 0 0 0 0 0]&#xA; [0 0 0 0 0 0 0]&#xA; [0 0 0 0 0 0 0]&#xA; [0 0 0 0 0 0 0]&#xA; [0 1 0 0 0 0 0]]&#xA;&#xA;Letter assignments:&#xA;[[1 1 1 0 1 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1]&#xA; [0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0]&#xA; [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]&#xA; [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]&#xA; [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]&#xA; [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]&#xA; [0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]&#xA;&#xA;Group 0 has letters ABCEHIPZ, items ABC, EHI, AHP, EPZ, CIZ&#xA;Group 1 has letters ITW, items ITW&#xA;Group 6 has letters CDF, items CDF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11118" LastEditorUserId="11118" LastEditDate="2023-08-27T15:36:00.803" LastActivityDate="2023-08-27T15:36:00.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10887" PostTypeId="2" ParentId="10885" CreationDate="2023-08-27T04:23:49.143" Score="2" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$g_{oracle}(x)$&lt;/span&gt; can return gradients, then this is a standard nonlinear optimization problem which can be passed directly to an oracle-based solver like Ipopt (&lt;a href=&quot;https://github.com/coin-or/Ipopt&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/coin-or/Ipopt&lt;/a&gt;). Ipopt does not need to know the nonlinear expressions in closed form.&lt;/p&gt;&#xA;&lt;p&gt;In fact, if you write an optimal power flow formulation in an algebraic modeling language like AMPL, JuMP, or Pyomo, the first thing they do is convert the algebraic representation into an oracle that can be queried by the solver (as well as compute oracles for the relevant derivatives).&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$g_{oracle}(x)$&lt;/span&gt; cannot return gradients, then you would need to use a derivative-free solver. There are a variety of solvers, including algorithms implemented in &lt;a href=&quot;https://nlopt.readthedocs.io/en/latest/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://nlopt.readthedocs.io/en/latest/&lt;/a&gt; or &lt;a href=&quot;https://github.com/coin-or/rbfopt&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/coin-or/rbfopt&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2023-08-27T04:23:49.143" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10888" PostTypeId="1" AcceptedAnswerId="10889" CreationDate="2023-08-27T09:11:14.170" Score="3" ViewCount="452" Body="&lt;p&gt;Suppose we have a feasible LP problem in its standard form. From Ax=b we can directly determine some of its variables and thus we can reduce the problem.&lt;/p&gt;&#xA;&lt;p&gt;For example, from two constraints: x+y+z=2 and x+y=1, we can determine z=1. Then we can replace 'z' with '1' and move it to the RHS, and delete variable 'z' as well as one of the constraints above.&lt;/p&gt;&#xA;&lt;p&gt;Are there any tools which can do this kind of reduction?&lt;/p&gt;&#xA;" OwnerUserId="12349" LastEditorUserId="12349" LastEditDate="2023-08-27T09:17:24.960" LastActivityDate="2023-08-27T12:39:40.283" Title="How to reduce an LP problem already in its standard form?" Tags="|optimization|mixed-integer-programming|linear-programming|linear-algebra|api|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10889" PostTypeId="2" ParentId="10888" CreationDate="2023-08-27T12:10:03.403" Score="9" Body="&lt;h3&gt;Concept&lt;/h3&gt;&#xA;&lt;p&gt;The tools you are referring to are commonly called &lt;strong&gt;presolvers&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Resources (Implementation) / Availability&lt;/h3&gt;&#xA;&lt;p&gt;Every optimization software makes use of those (to improve performance, but also numerical-stability). This includes commercial solvers, as well as non-commercial ones.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Most implementations&lt;/strong&gt;, if not all are &lt;strong&gt;embedded into the solver framework&lt;/strong&gt;. The sole exception known to me would be:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/scipopt/papilo/&quot; rel=&quot;noreferrer&quot;&gt;papilo&lt;/a&gt;: Parallel Presolve for Integer and Linear Optimization (LP + MILP)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Embedded candidates to look at:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://scipopt.org/doc/html/group__PRESOLVERS.php&quot; rel=&quot;noreferrer&quot;&gt;SCIP&lt;/a&gt; (LP + MILP + ?MINLP?)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ERGO-Code/HiGHS/tree/master/src/presolve&quot; rel=&quot;noreferrer&quot;&gt;HiGHS&lt;/a&gt; (LP + MILP)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/coin-or/Clp/blob/master/src/ClpPresolve.hpp&quot; rel=&quot;noreferrer&quot;&gt;CoinOR Clp&lt;/a&gt; (LP)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(somewhere in CoinOR Cbc or related libs would be MILP presolving too)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Even if embedded, most most solvers allow to do the presolving step in an isolated step without automatically triggering follow-up solving (if the user wants it).&lt;/p&gt;&#xA;&lt;h3&gt;Resources (Theory)&lt;/h3&gt;&#xA;&lt;p&gt;There are high-quality resources on this topic.&lt;/p&gt;&#xA;&lt;h4&gt;Linear-Programming&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Andersen, Erling D., and Knud D. Andersen. &amp;quot;Presolving in linear programming.&amp;quot; Mathematical Programming 71 (1995): 221-245.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;Mixed-Integer-Programming Extensions&lt;/h4&gt;&#xA;&lt;p&gt;In this context, presolving is usually much more important and much more powerful (imho).&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Achterberg, Tobias, et al. &amp;quot;Presolve reductions in mixed integer programming.&amp;quot; INFORMS Journal on Computing 32.2 (2020): 473-506.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Gamrath, Gerald, et al. &amp;quot;Progress in presolving for mixed integer programming.&amp;quot; Mathematical Programming Computation 7 (2015): 367-398.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="231" LastEditorUserId="231" LastEditDate="2023-08-27T12:39:40.283" LastActivityDate="2023-08-27T12:39:40.283" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10890" PostTypeId="1" CreationDate="2023-08-27T23:17:27.133" Score="2" ViewCount="92" Body="&lt;p&gt;Consider a graph &lt;span class=&quot;math-container&quot;&gt;$G = (V,E)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is the set of vertices and &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is the set of weighted edges. We want to create &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; disjoint subsets of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; such that the sum of weights inside each subset is maximised whereas the sum of weights that are connecting two different subsets is minimised. The &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; needs to be determined and it's not given upfront. It's part of the solution.&lt;/p&gt;&#xA;&lt;p&gt;For example, given a graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; with 5 vertices. I decide to split into two parts the first one contains vertices 1,2 and 3 and the second one contains 4 and 5. My split maximises the sum of weights on green edges and minimises the sum of weights on red edges &lt;a href=&quot;https://i.stack.imgur.com/QH6fX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QH6fX.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Notice that the number &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; of subsets is part of the decision.&lt;/p&gt;&#xA;&lt;p&gt;Is this a well-defined optimization problem? It's some variation of a graph partitioning problem, but Is there a more precise name that commonly used name for it? Is there some papers about solving it?&lt;/p&gt;&#xA;" OwnerUserId="7222" LastEditorUserId="500" LastEditDate="2023-08-28T01:26:47.447" LastActivityDate="2023-08-28T06:33:27.537" Title="Is there a name for this problem?" Tags="|optimization|graphs|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10891" PostTypeId="1" AcceptedAnswerId="10898" CreationDate="2023-08-28T01:07:21.873" Score="2" ViewCount="75" Body="&lt;h2&gt;&lt;em&gt;&lt;strong&gt;Background Information&lt;/strong&gt;&lt;/em&gt;&lt;/h2&gt;&#xA;&lt;p&gt;I am studying constraint qualifications. Here are two theorems leading to my question:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Theorem 1&lt;/strong&gt;&lt;span class=&quot;math-container&quot;&gt;$\space\space\space\space$&lt;/span&gt; [Fritz John Theorem] Suppose that &lt;span class=&quot;math-container&quot;&gt;$f, g_1, \dots, g_k$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$C^1$&lt;/span&gt; functions of &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables. Suppose that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is a local maximizer of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; on the constraint set defined by the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; inequalities&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;g_1(x_1, \dots, x_n) \leq b_1, \dots, g_k(x_1, \dots, x_n) \leq b_k.&#xA;\end{equation}&lt;/span&gt;&#xA;Form the Lagrangian&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;L(x_1, \dots, x_n, \lambda_0, \lambda_1, \dots, \lambda_k) \equiv \lambda_0f(\mathbf{x}) - \lambda_1[g_1{\mathbf{x}} - b_1] - \dots - \lambda_k[g_k{\mathbf{x}} - b_k],&#xA;\end{equation}&lt;/span&gt;&#xA;with a multiplier &lt;span class=&quot;math-container&quot;&gt;$\lambda_0$&lt;/span&gt; for the objective function. Then, there exist multipliers &lt;span class=&quot;math-container&quot;&gt;$\lambda^* = (\lambda_0^*, \lambda_1^*, \dots, \lambda_k)$&lt;/span&gt; such that:&lt;/p&gt;&#xA;&lt;p&gt;(a) &lt;span class=&quot;math-container&quot;&gt;$\frac{\partial L}{\partial x_1}(\mathbf{x}^*, \lambda^*) = 0, \dots, \frac{\partial L}{\partial x_n}(\mathbf{x}^*, \lambda^*) = 0$&lt;/span&gt;,&lt;br /&gt;&#xA;(b) &lt;span class=&quot;math-container&quot;&gt;$\lambda_1^*[g_1(\mathbf{x}^*) - b_1] = 0, \dots, \lambda_k^*[g_k(\mathbf{x}^*) - b_k] = 0$&lt;/span&gt;,&lt;br /&gt;&#xA;(c) &lt;span class=&quot;math-container&quot;&gt;$\lambda_1^* \geq 0, \dots, \lambda_k^* \geq 0$&lt;/span&gt;,&lt;br /&gt;&#xA;(d) &lt;span class=&quot;math-container&quot;&gt;$g_1(\mathbf{x}^*) \leq b_1, \dots, g_k(\mathbf{x}^*) \leq b_k$&lt;/span&gt;,&lt;br /&gt;&#xA;(e) &lt;span class=&quot;math-container&quot;&gt;$\lambda_0^* = 0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, and&lt;br /&gt;&#xA;(f) &lt;span class=&quot;math-container&quot;&gt;$(\lambda_0^*, \lambda_1^*, \dots, \lambda_k^*) \neq (0, 0, \dots, 0)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Theorem 2&lt;/strong&gt;&lt;span class=&quot;math-container&quot;&gt;$\space\space\space\space$&lt;/span&gt; Let &lt;span class=&quot;math-container&quot;&gt;$f, g_1, \dots, g_k$&lt;/span&gt; be as in Theorem 1, and suppose that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^* \in \mathbb{R}^n$&lt;/span&gt; is a local maximizer of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; on the constraint set defined by&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;g_1(\mathbf{x}) \leq b_1, \dots, g_k(\mathbf{x}) \leq b_k.&#xA;\end{equation}&lt;/span&gt;&#xA;For ease of notation, suppose that &lt;span class=&quot;math-container&quot;&gt;$g_1, \dots, g_h$&lt;/span&gt; yield binding constraints at &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^*$&lt;/span&gt; and that &lt;span class=&quot;math-container&quot;&gt;$g_{h+1}, \dots, g_k$&lt;/span&gt; are not binding at &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^*$&lt;/span&gt;. Suppose that the &lt;em&gt;binding&lt;/em&gt; constraint functions satisfy one of the following properties:&lt;/p&gt;&#xA;&lt;p&gt;(a) (&lt;strong&gt;Slater Constraint Qualification&lt;/strong&gt;) There is a ball &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; about &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^*$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$g_1, \dots, g_h$&lt;/span&gt; are convex functions on &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; and there exists &lt;span class=&quot;math-container&quot;&gt;$\mathbf{z} \in U$&lt;/span&gt; so that each &lt;span class=&quot;math-container&quot;&gt;$g_i(\mathbf{z} &amp;lt; b_i)$&lt;/span&gt;.&lt;br /&gt;&#xA;(b) &lt;span class=&quot;math-container&quot;&gt;$g_1, \dots, g_h$&lt;/span&gt; are concave functions.&lt;br /&gt;&#xA;(c) &lt;span class=&quot;math-container&quot;&gt;$g_1, \dots, g_h$&lt;/span&gt; are linear functions.&lt;/p&gt;&#xA;&lt;p&gt;Then we can take &lt;span class=&quot;math-container&quot;&gt;$\lambda_0^* = 1$&lt;/span&gt; in the conclusion of Theorem 1.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h2&gt;&lt;em&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/em&gt;&lt;/h2&gt;&#xA;&lt;p&gt;I was asked to determine which of the three constraint qualifications in Theorem 2 hold for the constraint functions in the following maximization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;Max\space\space\space\space f(x, y) = 2y^2 - x\\&#xA;\space\space\space\space\space\space\space\space\space\space\space\space s.t.\space\space\space\space g_1(x, y) \equiv x^2 + y^2 \leq 1\\&#xA;\space\space\space\space\space\space\space\space\space\space\space\space\space\space g_2(x, y) \equiv -x \leq 0\\&#xA;\space\space\space\space\space\space\space\space\space\space\space\space\space\space g_3(x, y) \equiv -y \leq 0&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h2&gt;&lt;em&gt;&lt;strong&gt;My Question&lt;/strong&gt;&lt;/em&gt;&lt;/h2&gt;&#xA;&lt;p&gt;The answer to this problem is (a). I was very confused about it. One can check that the local maximizer of the &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; on the constraint set is &lt;span class=&quot;math-container&quot;&gt;$x = 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y = 1$&lt;/span&gt;. In that case, the binding constraint functions would be &lt;span class=&quot;math-container&quot;&gt;$g_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_2$&lt;/span&gt;. However, how is &lt;span class=&quot;math-container&quot;&gt;$g_1$&lt;/span&gt; a convex function on a ball &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; about &lt;span class=&quot;math-container&quot;&gt;$(0, 1)$&lt;/span&gt;? Wouldn't it be concave? What am I missing, or is my understanding of the theorem is wrong? I really appreciate any help!&lt;/p&gt;&#xA;" OwnerUserId="11987" LastActivityDate="2023-10-13T07:19:37.763" Title="Question About Fritz John Theorem and Slater Constraint Qualification" Tags="|optimization|constraint|nonlinear-programming|convex-optimization|convexity|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10892" PostTypeId="2" ParentId="10890" CreationDate="2023-08-28T06:33:27.537" Score="1" Body="&lt;p&gt;What you are looking for sounds like a variant of the HUB-location allocation problem, specifically, &lt;a href=&quot;https://www.jbs.cam.ac.uk/wp-content/uploads/2020/08/wp0810.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Uncapacitated Multiple Allocation Hub Location Problem&lt;/a&gt;. This problem contains a graph &lt;span class=&quot;math-container&quot;&gt;$G = (V, E)$&lt;/span&gt; where there are some disjoint subsets or HUBs that need to be located and some demand points that should be allocated to each hub. The number of hubs/disjoint subsets may be either predetermined or a decision variable. Also, the objective function can be a single form or also multi-objective. In your case, as the objectives have different directions it seems to be the second form.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sHunZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sHunZ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-08-28T06:33:27.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10893" PostTypeId="1" AcceptedAnswerId="10902" CreationDate="2023-08-28T07:46:35.897" Score="3" ViewCount="105" Body="&lt;p&gt;AI algorithms, specifically in industries, can be used to work and manipulate the data to estimate or learn this data to achive a solution or prepare trained data to feed that into an optimization model.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, the simulation techniques, especially discrete-event and Mont-Carlo, use almost the same data, e.g. number of failures in a specific station in the production line, to either estimate a function to robust some parameters as a final solution or feed these parameters into an optimization model. And already investigate the behavior of the complex system in a dynamic scheme with an appropriate feedback.&lt;/p&gt;&#xA;&lt;p&gt;Now my question is, &lt;em&gt;&lt;strong&gt;what exactly is the main difference between an AI method and a simulation technique for example to estimate the failures or production utilization?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-08-29T10:45:34.963" Title="Can simulation be known as a practical AI?" Tags="|optimization|simulation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10894" PostTypeId="1" AcceptedAnswerId="10897" CreationDate="2023-08-28T09:26:24.070" Score="0" ViewCount="82" Body="&lt;p&gt;I'm trying to do an assignment problem with the following characteristics:&lt;/p&gt;&#xA;&lt;p&gt;I have two sets that need to be matched with each other, set A (Students) and set B (Class combinations). Set A and B have the same number of rows (there's 100% matching and no leftovers in either set)&lt;/p&gt;&#xA;&lt;p&gt;Each row in Set A is a student with multiple categorical attributes (Gender, Age Group, Country of Residence etc). There can be &lt;strong&gt;any amount of attributes&lt;/strong&gt; and each attribute can have any number of options (Age Group can be in bins of 5 or 10 etc).&lt;/p&gt;&#xA;&lt;p&gt;Each row in Set B is a set of classes that each student in Set A can attend, such as (Physics, Chemistry, Linguistics). Each row has the same amount of classes (3 classes per row for example), and Y amount of classes to choose from. There are &lt;strong&gt;no repeating classes&lt;/strong&gt; within a row, and the &lt;strong&gt;positional sequence of each class doesn't matter&lt;/strong&gt; ([Physics, Chemistry] is the same as [Chemistry, Physics])&lt;/p&gt;&#xA;&lt;p&gt;What I'm trying to do is match each student in set A to a class combination in set B such that each class in set B is taken by students of equal proportions across all student attribute.&#xA;For example, if Country of Residence was 70:30 in set A between USA and Canada, the proportions of students taking each class should also be 70:30. This should apply to all student attributes in set A and classes in set B.&lt;/p&gt;&#xA;&lt;p&gt;I understand that because it's not possible to match everything perfectly it would end up being a minimization problem where you minimize an error term that determines how far the class proportion is from the actual student proportion. However I've never dealt with assignment problems where both sides have attributes that need matching (worker and job), nor have I found any resources online about such problems and frankly don't know where to begin formulating this as an LP. If there's anyone who can provide advice about how to begin formulating such a problem that can be translated to a solver like or-tools (everything linearized as much as possible) would be extremely helpful.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 1:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Based on Sutanu's answer I've gotten some headway but I'm still slightly confused on the matching part.&lt;/p&gt;&#xA;&lt;p&gt;I have 1 optimization variable:&#xA;&lt;br&gt; Binary &lt;span class=&quot;math-container&quot;&gt;$x_{s,r}$&lt;/span&gt; = Student s is taking row r&lt;/p&gt;&#xA;&lt;p&gt;1 intermediary variable dependent on the optimization variable:&#xA;&lt;br&gt; Binary &lt;span class=&quot;math-container&quot;&gt;$y_{s,c}$&lt;/span&gt; = Student s is taking class c (Dependent on &lt;span class=&quot;math-container&quot;&gt;$x_{s,r}$&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;1 preset binary variable for rows to class:&#xA;&lt;br&gt; Binary &lt;span class=&quot;math-container&quot;&gt;$z_{r,c}$&lt;/span&gt; = Row r contains class c&#xA;&lt;br&gt;Functionally equivalent to &lt;span class=&quot;math-container&quot;&gt;$c_r$&lt;/span&gt; in Sutanu's response&lt;/p&gt;&#xA;&lt;p&gt;Preset binary variables for each categorical attribute and student&#xA;&lt;br&gt; Binary &lt;span class=&quot;math-container&quot;&gt;$att_{s,a,b}$&lt;/span&gt; = Student s is attribute a for given categorical attribute b (a = US/Canada for b = Country, or a = Fresh/Soph/Jr/Sr for b = Year etc)&#xA;&lt;br&gt;(Intended to be functionally equivalent to &lt;span class=&quot;math-container&quot;&gt;$d_s$&lt;/span&gt; in Sutanu's response)&lt;/p&gt;&#xA;&lt;p&gt;Overall Constriants:&#xA;&lt;br&gt; &lt;span class=&quot;math-container&quot;&gt;$\sum_{s}^{}x_{s,r} = 1$&lt;/span&gt; forcing 1 row to be taken by 1 student&#xA;&lt;br&gt; &lt;span class=&quot;math-container&quot;&gt;$\sum_{r}^{}x_{s,r} = 1$&lt;/span&gt; forcing 1 student to take only 1 row&lt;/p&gt;&#xA;&lt;p&gt;Linearization of &lt;span class=&quot;math-container&quot;&gt;$x_{s,r}$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$z_{r,c}$&lt;/span&gt; =&amp;gt; &lt;span class=&quot;math-container&quot;&gt;$y_{s,c}$&lt;/span&gt; :&#xA;&lt;br&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{s,c} \leqslant x_{s,r}$&lt;/span&gt;&#xA;&lt;br&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{s,c} \leqslant z_{r,c}$&lt;/span&gt;&#xA;&lt;br&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{s,c} \geqslant x_{s,r} + z_{r,c} - 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My question at the moment is:&#xA;How exactly do I link &lt;span class=&quot;math-container&quot;&gt;$att_{s,a,b}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{s,c}$&lt;/span&gt; to make a variable that determines the number of students for a given attribute (US/Canada) are in a given class? Is the only way to make another binary variable &lt;span class=&quot;math-container&quot;&gt;$yatt_{s,a,b,c}$&lt;/span&gt; if student s of attribute a in categorical attribute b is taking class c and linearize that for &lt;span class=&quot;math-container&quot;&gt;$att_{s,a,b}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{s,c}$&lt;/span&gt; =&amp;gt; &lt;span class=&quot;math-container&quot;&gt;$yatt_{s,a,b,c}$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;I understand that this variable is what I should constrain to keep within the desired proportions (30% Canada / 70% USA etc), but I don't really know if there is a better way to create this variable than making &lt;span class=&quot;math-container&quot;&gt;$yatt_{s,a,b,c}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12136" LastEditorUserId="12136" LastEditDate="2023-08-29T03:54:37.080" LastActivityDate="2023-08-29T05:01:37.410" Title="Formulating assignment problem with people attributes that need to be balanced per assignment attribute in or-tools, CP-sat" Tags="|linear-programming|or-tools|assignment-problem|cp-sat|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10895" PostTypeId="2" ParentId="10894" CreationDate="2023-08-28T09:40:13.610" Score="0" Body="&lt;p&gt;create 1 Boolean var per pair of (student, course)&lt;/p&gt;&#xA;&lt;p&gt;Write the linear equations that constrain the model&lt;/p&gt;&#xA;&lt;p&gt;Decide on the objective&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-08-28T09:40:13.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10896" PostTypeId="1" AcceptedAnswerId="10899" CreationDate="2023-08-28T17:01:06.640" Score="0" ViewCount="39" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/odow/SDDP.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;SDDP.jl&lt;/a&gt; for my research project in which I am developing a state-of-the-art actor critic algorithm which I am going to benchmark with SDDP but for it I need to plot graphs which require data to be in excel or csv form.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to transfer the output stream into excel file?&lt;/p&gt;&#xA;&lt;p&gt;I have searched the whole internet but found nothing.&lt;/p&gt;&#xA;" OwnerUserId="10727" LastEditorUserId="804" LastEditDate="2023-08-30T22:20:06.517" LastActivityDate="2023-08-30T22:20:06.517" Title="How can I write the output stream of SDDP.jl into an excel file?" Tags="|dynamic-programming|julia|multi-stage|stochastic-dual-dynamic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10897" PostTypeId="2" ParentId="10894" CreationDate="2023-08-28T19:14:30.567" Score="1" Body="&lt;p&gt;You'd need two optimization variables&lt;br /&gt;&#xA;Binary &lt;span class=&quot;math-container&quot;&gt;$ x_{s,r} = 1$&lt;/span&gt; if student &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; from set A is matched with row &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; from set B&lt;br /&gt;&#xA;Binary &lt;span class=&quot;math-container&quot;&gt;$ y_{s,c} = 1$&lt;/span&gt; of student is matched to a class &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Derived sets/matrix where each row &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$c_r = \{r \in B \ | \ c \in r \} \ \ \forall$&lt;/span&gt; classes &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ d_s = \{s \in A | \ s \in d \} \ \forall $&lt;/span&gt; attributes. Basically a set of attribute matrices where in each row constaints the students sharing that attribute. For example, a matrix called Country will have a row indexed as US containing students who are from US. Similarly for Canada.&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ y_{s,c} \le \sum_{r \in c_r}x_{s,r} \le My_{s,c}$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; can be total number of classes any student is allowed to take&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_s x_{s,r} \ge 1 \quad \forall r$&lt;/span&gt;: match all rows to atleast 1 student&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_r x_{s,r} = 1 \quad \forall s$&lt;/span&gt;: match all students to 1 row&lt;/p&gt;&#xA;&lt;p&gt;Proportion (expression not a constraints)&lt;br /&gt;&#xA;US_{class} = &lt;span class=&quot;math-container&quot;&gt;$ \sum_s U_sy_{s,c}$&lt;/span&gt;&lt;br /&gt;&#xA;Can_{class} = &lt;span class=&quot;math-container&quot;&gt;$ \sum_s C_s y_{s,c}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So one of your objectives for the country will be like &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \sum_s (3U_s y_{s,c} - 7C_sy_{y,c})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Edit&lt;br /&gt;&#xA;You may use preset variables (basically constants) where &lt;span class=&quot;math-container&quot;&gt;$att_{a,b,s} = 1$&lt;/span&gt; if student &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; has value &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; for attribute &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;.&lt;br /&gt;&#xA;So for a proportion constraint on an attribute&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_s att_{a,b,s}y_{s,c} = p_{a,b} \sum_s y_{s,c} \quad \forall (a,b) \ \ \forall c$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is the proportion for the value &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; for the attribute &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If using set &lt;span class=&quot;math-container&quot;&gt;$A_b$&lt;/span&gt; that contains list of students &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; with value &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; for attribute &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; then&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{s \in A_b} y_{s,c} = p_{a,b}\sum_s y_{s,c} \ \ \forall c$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-08-29T05:01:37.410" LastActivityDate="2023-08-29T05:01:37.410" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10898" PostTypeId="2" ParentId="10891" CreationDate="2023-08-28T19:32:38.890" Score="5" Body="&lt;p&gt;Lets break down the statement:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;There is a ball &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; about &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^*$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n$&lt;/span&gt;&lt;/strong&gt;.&#xA;That is, let &lt;span class=&quot;math-container&quot;&gt;$U = \{ x \in \mathbb{R}^n : \| x - \mathbf{x}^* \| \leq \rho \}$&lt;/span&gt; be a norm-ball with some unspecified radius &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt;, having &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}^*$&lt;/span&gt; at its center.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;such that &lt;span class=&quot;math-container&quot;&gt;$g_1, \dots, g_h$&lt;/span&gt; are convex functions on &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt;&lt;/strong&gt;. That is, if you restricted the domain of these functions from &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^n$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; (or more generally, if &lt;span class=&quot;math-container&quot;&gt;$g_i : D_i \rightarrow \mathbb{R}$&lt;/span&gt;, from &lt;span class=&quot;math-container&quot;&gt;$D_i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$D_i \cap U$&lt;/span&gt;) then these domain-restricted functions would satisfy the definition of a convex function. Assuming &lt;span class=&quot;math-container&quot;&gt;$g_1, \dots, g_h$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$C^2$&lt;/span&gt; functions, this is equivalent to their Hessian matrices &lt;span class=&quot;math-container&quot;&gt;$H_{g_1}(x), \ldots, H_{g_h}(x)$&lt;/span&gt; being positive semidefinite for all &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in this restricted domain.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;and there exists &lt;span class=&quot;math-container&quot;&gt;$\mathbf{z} \in U$&lt;/span&gt; so that each &lt;span class=&quot;math-container&quot;&gt;$g_i(\mathbf{z}) &amp;lt; b_i$&lt;/span&gt;&lt;/strong&gt;. All functions, &lt;span class=&quot;math-container&quot;&gt;$g_1, \dots, g_h$&lt;/span&gt; as well as &lt;span class=&quot;math-container&quot;&gt;$g_{h+1}, \dots, g_k$&lt;/span&gt;, must be nonbinding at the so-called Slater point &lt;span class=&quot;math-container&quot;&gt;$\mathbf{z} \in U$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In your example, &lt;span class=&quot;math-container&quot;&gt;$g_1(x, y) = x^2 + y^2$&lt;/span&gt; is a convex function on all of &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_2(x,y) = -x$&lt;/span&gt; is linear (thus also convex) on all of &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^2$&lt;/span&gt;. This means that there is no limit to the radius &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt; of the norm-ball &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt;. We can thus choose &lt;span class=&quot;math-container&quot;&gt;$(x,y)=(0.5, 0.5)$&lt;/span&gt; as our Slater point.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2023-10-13T07:19:37.763" LastActivityDate="2023-10-13T07:19:37.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10899" PostTypeId="2" ParentId="10896" CreationDate="2023-08-28T20:40:02.177" Score="2" Body="&lt;p&gt;Use the &lt;code&gt;log_file&lt;/code&gt; keyword argument to &lt;code&gt;train&lt;/code&gt;: &lt;a href=&quot;https://odow.github.io/SDDP.jl/stable/apireference/#SDDP.train&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://odow.github.io/SDDP.jl/stable/apireference/#SDDP.train&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or, after training, use the &lt;code&gt;write_log_to_csv&lt;/code&gt; function: &lt;a href=&quot;https://odow.github.io/SDDP.jl/stable/apireference/#SDDP.write_log_to_csv&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://odow.github.io/SDDP.jl/stable/apireference/#SDDP.write_log_to_csv&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;p.s., in future, feel free to ask SDDP.jl-related questions by opening an issue: &lt;a href=&quot;https://github.com/odow/SDDP.jl/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/odow/SDDP.jl/issues&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2023-08-28T20:40:02.177" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10900" PostTypeId="1" CreationDate="2023-08-28T22:51:50.607" Score="1" ViewCount="48" Body="&lt;p&gt;I coded my mathematical program in CPLEX Studio IDE 22.1.1 However due to the difficulty of the problem the run takes days and then shows an out of memory error. I read that I can try to use &amp;quot;node storage file&amp;quot; to ask CPLEX to store the nodes in files. However, I am not sure how to do it in CPLEX Studio IDE 22.1.1&lt;/p&gt;&#xA;" OwnerUserId="12360" LastActivityDate="2023-08-29T10:34:54.843" Title="How to change CPLEX parameters from within CPLEX Studio IDE 22.1.1" Tags="|cplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10901" PostTypeId="1" CreationDate="2023-08-29T10:12:10.937" Score="1" ViewCount="90" Body="&lt;p&gt;I'm working on a routing and scheduling problem in the home care services context. I consider a break as a dummy patient, so routing and scheduling are also implemented for the break node (with some conditions). For some reason, I need to determine whether a visit occurs before or after a break. I defined two binary variables: &lt;span class=&quot;math-container&quot;&gt;$Z(i,k,t)$&lt;/span&gt; which means if patient i is visited by doctor k on shift t &lt;strong&gt;before&lt;/strong&gt; the break, and &lt;span class=&quot;math-container&quot;&gt;$Z'(i,k,t)$&lt;/span&gt; for &lt;strong&gt;after&lt;/strong&gt; the break. I added 2 new constraints as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S(b,k,t)-S(i,k,t) =l= M* Z(i,k,t)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Z(i,k,t) + Z'(i,k,t) =l= \sum_j X(i,j,k,t)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S(b,k,t)$&lt;/span&gt; is the starting time of break by doctor k on shift t&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S(i,k,t)$&lt;/span&gt; is the starting time of visiting patient i by doctor k on shift t&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X(i,j,k,t)$&lt;/span&gt; is if doctor k on shift t goes from node i to node j (binary variable)&lt;/p&gt;&#xA;&lt;p&gt;In the first constraint, if the left-hand side becomes positive, &lt;span class=&quot;math-container&quot;&gt;$Z(i,k,t)$&lt;/span&gt; will be 1.&#xA;The second one is guaranteeing that Z and Z' could get value if patient i was visited by doctor k on shift t.&#xA;By adding these 2 constraints to my model, the result of my S variables (starting time) get wrong.&#xA;I think it's better to rewrite the first constraint so that it becomes related somehow to &lt;span class=&quot;math-container&quot;&gt;$X(i,j,k,t)$&lt;/span&gt;, but I can not figure out how to do it.&lt;/p&gt;&#xA;" OwnerUserId="12362" LastEditorUserId="36" LastEditDate="2023-08-29T13:03:47.633" LastActivityDate="2024-01-26T18:07:41.037" Title="In a routing and scheduling problem with break consideration, How can I determine whether a node is met before a break or after it?" Tags="|optimization|mixed-integer-programming|modeling|scheduling|vehicle-routing|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10902" PostTypeId="2" ParentId="10893" CreationDate="2023-08-29T10:31:58.703" Score="5" Body="&lt;p&gt;The main difference is hype.&lt;/p&gt;&#xA;&lt;p&gt;Here is a quote &lt;a href=&quot;https://twitter.com/daniela_witten/status/1177294449702928384&quot; rel=&quot;nofollow noreferrer&quot;&gt;tweeted by University of Washington Statistics Professor Daniela Witten in 2019&lt;/a&gt;, attributed to source unknown, which captures the spirit:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When we raise money it’s AI, when we hire it's machine learning, and&#xA;when we do the work it's logistic regression.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Basically, most of O.R. could be considered to be AI.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-08-29T10:45:34.963" LastActivityDate="2023-08-29T10:45:34.963" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10903" PostTypeId="2" ParentId="10900" CreationDate="2023-08-29T10:34:54.843" Score="1" Body="&lt;p&gt;I tried using this option in the CPLEX studio &lt;code&gt;OPL-CPLEX 20.1.0&lt;/code&gt;. I am not aware of if, it changes in the latest version. To that you need to change &lt;code&gt;directory for working files&lt;/code&gt; to an appropriate location on your machine. (e.g. &lt;code&gt;C:\Users\omidi.a\opl_studio\...&lt;/code&gt;). Then limit the &lt;code&gt;memory available for working storage&lt;/code&gt; to your desired amount. Then in the MIP -&amp;gt; strategy -&amp;gt; &lt;code&gt;node storage file switch&lt;/code&gt; change the option to either &lt;code&gt;3&lt;/code&gt; or &lt;code&gt;4&lt;/code&gt;. By that, a temporary file is written in your disc to store the &lt;span class=&quot;math-container&quot;&gt;$\text{B&amp;amp;B}$&lt;/span&gt; tree on the disc and also the log file is something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;MIP Presolve modified 6 coefficients.&#xA;Reduced MIP has 54 rows, 520 columns, and 1032 nonzeros.&#xA;Reduced MIP has 520 binaries, 0 generals, 0 SOSs, and 0 indicators.&#xA;Presolve time = 0.02 sec. (1.84 ticks)&#xA;Represolve time = 0.38 sec. (6.42 ticks)&#xA;Began writing nodes to disk (directory C:\Users\omidi.a\opl_studio\BPP/cpxa08056 created)&#xA;  18129  6664       17.0000    27       18.0000       16.9000    55547    6.11%&#xA;  38032 18068       16.9500    23       18.0000       16.9000   130120    6.11%&#xA;  56190 30507       17.0000    28       18.0000       16.9000   222665    6.11%&#xA;* 59945 32517      integral     0       17.0000       16.9000   240820    0.59%&#xA;&#xA;Root node processing (before b&amp;amp;c):&#xA;  Real time             =    0.03 sec. (23.70 ticks)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-08-29T10:34:54.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10904" PostTypeId="2" ParentId="10901" CreationDate="2023-08-29T14:30:28.327" Score="0" Body="&lt;p&gt;I'd use binary &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}^{k,t}=1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; visits any node (patient or break node) basically the connecting edge (between patient -break and break-patient) and just one set of binary &lt;span class=&quot;math-container&quot;&gt;$z_{i}^{k,t}$&lt;/span&gt; to indicate if doctor has visited patient &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; or break &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;&lt;br /&gt;&#xA;Let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is set of patients &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is set of break nodes with &lt;span class=&quot;math-container&quot;&gt;$I = P \cup B$&lt;/span&gt; set of all nodes&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ s_{i}^{k,t} \le Mz_i^{k,t}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ z_i^{k,t} \le \sum_jx_{i,j}^{k,t}+\sum_i x_{j,i}^{k,t} - 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_i x_{i,j}^{k,t} \le Mz_i^{k,t}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_jx_{i,j}^{k,t} - \sum_i x_{i,j}^{k,t} = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ M(x_{i,j}^{k,t}-1) \le s_{j}^{k,t} - s_{i}^{k,t} \le Mx_{i,j}^{k,t}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-08-29T14:42:00.727" LastActivityDate="2023-08-29T14:42:00.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10905" PostTypeId="2" ParentId="10901" CreationDate="2023-08-29T17:22:17.770" Score="0" Body="&lt;p&gt;Is there a reason why you want to adjust your model? I would try to not add complexity to your mathematical model, as the solution to your initial problem should already include all the information you need, so I would rather see it as an information extraction issue. For example, if you use the Miller-Tucker-Zemlin formulation for subtour elimination purposes, you could use it to determine if a patient is visited before a break or afterward. I.e., you could simply look at the auxiliary variables (often referred to as &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt;). If &lt;span class=&quot;math-container&quot;&gt;$u_i &amp;lt; u_j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is visited before &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2023-08-29T17:22:17.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10906" PostTypeId="1" CreationDate="2023-08-30T04:02:52.897" Score="0" ViewCount="131" Body="&lt;p&gt;The problem I'm trying to solve is the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Given &lt;span class=&quot;math-container&quot;&gt;$t\in \{1,2,3....T\}$&lt;/span&gt; tasks, integer.&lt;/li&gt;&#xA;&lt;li&gt;Tasks have release times &lt;span class=&quot;math-container&quot;&gt;$r_t$&lt;/span&gt; and deadlines &lt;span class=&quot;math-container&quot;&gt;$d_t$&lt;/span&gt;, and processing times &lt;span class=&quot;math-container&quot;&gt;$p_t$&lt;/span&gt;, all continuous, real-valued.&lt;/li&gt;&#xA;&lt;li&gt;Minimize the number of machines required to process the tasks, assuming all machines are identical, and pre-emption is not allowed, and machines can only process one job at a time.&lt;/li&gt;&#xA;&lt;li&gt;Also, the schedule itself should be returned - not just the minimum number of machines.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;What would be an equivalent MIP or MILP for this problem?&lt;/p&gt;&#xA;&lt;p&gt;I've seen a &lt;a href=&quot;https://or.stackexchange.com/questions/9964/&quot;&gt;similar question&lt;/a&gt; however, their problem is much more simple for two reasons:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The schedule need not be returned&lt;/li&gt;&#xA;&lt;li&gt;Time is discrete.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;em&gt;EDIT&lt;/em&gt;:  If it makes the problem easier, I'm okay with a solution that has discrete time intervals, but it's not clear to me whether that makes the MILP formulation easier or more difficult.&lt;/p&gt;&#xA;" OwnerUserId="12368" LastEditorUserId="12368" LastEditDate="2023-08-31T07:55:31.473" LastActivityDate="2023-09-30T08:04:00.507" Title="How to minimize number of machines required to serve tasks, and return the schedules for each machine?" Tags="|mixed-integer-programming|combinatorial-optimization|job-shop-scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10908" PostTypeId="1" CreationDate="2023-08-30T08:11:11.007" Score="2" ViewCount="54" Body="&lt;p&gt;This is my problem:&#xA;I am planning camping trips for multiple people. Each person will be given a route. The routes may intersect at some points. They all start their trip simultaneously. Whenever two routes intersect, the person arriving the intersection point first must wait for the other person to arrive, after which both are allowed to continue their respective trips. The goal is to minimize the time it takes for the last person to finish his/her trip.&lt;/p&gt;&#xA;&lt;p&gt;If the weather is to bad the travelers have to stop, but each traveler might have a different weather threshold before having to stop. I have historic weather data available for the last x years.&lt;/p&gt;&#xA;&lt;p&gt;What is currently done is that a complete plan, namely a route for every traveler, is simulated by playing out what would happen each of the x years, then an average completion time over the x years is calculated. Hence, during the simulation no random numbers are generated as weather changes are given by the weather data.&lt;/p&gt;&#xA;&lt;p&gt;Questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is this a sensible way of doing it, given that it is very difficult&#xA;to generate random but at the same time realistic weather scenarios?&lt;/li&gt;&#xA;&lt;li&gt;Would this be considered a discrete event simulation based approach?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="9151" LastActivityDate="2023-08-30T08:11:11.007" Title="Optimization-simulation: is this sensible?" Tags="|simulation|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10909" PostTypeId="2" ParentId="10906" CreationDate="2023-08-30T09:22:19.877" Score="1" Body="&lt;p&gt;The problem you are facing is a variant of parallel machine scheduling problems with some limitations like release time, due date, and also unknown identical machines. This problem can be modeled as a mixed integer program as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\ min\ Z = &amp;amp;\ Cmax + \sum_{m} Nbmachines_{m} \\&#xA;&amp;amp;\text{s.t.} \\&#xA;&amp;amp;\ \sum_{m} x_{j,m} = 1 \quad \forall j \in T \quad (1)\\&#xA;&amp;amp;\ \sum_{j} x_{j,m} p_{j} \leq AvailableDuration*Nbmachines_{m} \quad \forall m \in M \quad (2)\\&#xA;&amp;amp;\ start_{j} \geq r_{j} \quad \forall j \in T \quad (3)\\&#xA;&amp;amp;\ start_{j} + p_{j} \leq Cmax \quad \forall j \in T \quad (4)\\&#xA;&amp;amp;\ start_{j} + p_{j} = finish_{j}\quad \forall j \in T \quad (5)\\&#xA;&amp;amp;\ finish_{j} \leq d_{j} \quad \forall j \in T \quad (6)\\&#xA;&amp;amp;\ (x_{i,m} \land x_{j,m}) \implies ((start_{i} + p_{i} \leq start_{j}) \lor (start_{j} + p_{j} \leq start_{i})) \quad \forall i, j \in T, m \in M: i \lt j \quad (7)\\&#xA;&amp;amp;\ x_{j,m} \in \mathbb{B}, Nbmachines_{m} \in \mathbb{B}, start_{j}, finish_{j} \in \mathbb{R}^+\\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I tried the following example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;jobs = {&amp;quot;j01&amp;quot;, &amp;quot;j02&amp;quot;, &amp;quot;j03&amp;quot;, &amp;quot;j04&amp;quot;, &amp;quot;j05&amp;quot;, &amp;quot;j06&amp;quot;};&#xA;machines = {&amp;quot;machine_1&amp;quot;, &amp;quot;machine_2&amp;quot;, &amp;quot;machine_3&amp;quot;, &amp;quot;machine_4&amp;quot;};&#xA;p[jobs] = [4, 9, 7, 5, 5, 4];&#xA;r[jobs] = [61, 59, 0, 21, 6, 0];&#xA;d[jobs] = [65, 80, 20, 40, 15, 10];&#xA;available_duration = 100;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and the results would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/voVu7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/voVu7.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Some points:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The lower bound on the &lt;em&gt;available_duration&lt;/em&gt; without having the precedence constraint should be &lt;span class=&quot;math-container&quot;&gt;$Max(p_{j}+r_{j}) \quad \forall j \in T$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The due date is already calculated in the simplest form while in the real situation almost comes with an appropriate penalty in the objective function.&lt;/li&gt;&#xA;&lt;li&gt;There is no need to predetermine the overlap between the tasks.&lt;/li&gt;&#xA;&lt;li&gt;Time index formulation usually provides a tighter lower bound, while adding a huge number of binary variables when the scale of the problem increases. In this case, usually, it needs to have a solving paradigm like the decomposition method.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-08-30T09:22:19.877" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10910" PostTypeId="1" CreationDate="2023-08-30T11:28:34.650" Score="1" ViewCount="100" Body="&lt;p&gt;Several tasks need to run repeatedly in a channel, one at a time, over a repeating time frame of length &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;. Associated to each task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the duration &lt;span class=&quot;math-container&quot;&gt;$L_i$&lt;/span&gt; the task will take to run, and a maximum time &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; between successive runs of the task. Note that task instances need not be evenly spaced; the time between any pair of instances of the same task &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is independent, but in each case not more than &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt;. Since this is a rolling timeframe, the first instance of the task succeeds the last. Assume the pattern repeats every cycle of the frame.&lt;/p&gt;&#xA;&lt;p&gt;For example suppose we have three tasks:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Red with &lt;span class=&quot;math-container&quot;&gt;$L_r = 2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M_r = 6$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Blue with &lt;span class=&quot;math-container&quot;&gt;$L_b = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M_b = 3$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Green with &lt;span class=&quot;math-container&quot;&gt;$L_g = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M_g = 4$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;An acceptable solution is shown below, having a total frame length of 14. I would like to maximize the time between tasks ideally (or the amount of unallocated (white) time per frame length). Although I've used simple numbers here, Im really wanting task lengths and spaces that might be thousands of time units, hence hoping to use intervals.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/q9aBc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/q9aBc.png&quot; alt=&quot;An acceptable schedule&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there a common CP paradigm that is well suited to this problem? Does Google ortools support it?&lt;/p&gt;&#xA;&lt;p&gt;When thinking about this problem using intervals I'm immediately confronted with a problem; I don't know how many intervals to assign to each task in any frame, since collisions would cause remaining intervals to be dragged forward, leaving more time at the end of the frame. So I'm thinking about some variable length list of intervals. Is there such a thing in ortools or another library?&lt;/p&gt;&#xA;" OwnerUserId="12369" LastEditorUserId="12369" LastEditDate="2023-08-31T01:32:43.567" LastActivityDate="2023-12-29T11:29:51.707" Title="Scheduling repeated tasks with minimum duty cycles" Tags="|scheduling|or-tools|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10911" PostTypeId="2" ParentId="10910" CreationDate="2023-08-30T13:36:32.707" Score="1" Body="&lt;p&gt;The repeating time frame is called cyclic scheduling.&lt;/p&gt;&#xA;&lt;p&gt;The max distance between tasks is called max delay.&lt;/p&gt;&#xA;&lt;p&gt;CP-SAT is a good tool to model it. You will need to use interval variables, the no_overlap constraint.&lt;/p&gt;&#xA;&lt;p&gt;The trick is to model 2 consecutive time frames, with strictly parallel interval (the first at time t, the second at time t + cycle time) to handle boundary conditions.&lt;/p&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2023-12-29T11:29:51.707" LastActivityDate="2023-12-29T11:29:51.707" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10912" PostTypeId="1" CreationDate="2023-08-30T14:41:14.000" Score="0" ViewCount="93" Body="&lt;p&gt;I have a problem with a quadratic constraint and I want to transform it into a linear constraint. This would help to reduce the computational time of my problem.&#xA;Following constraint should be linearized.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(w_{s,t,i} * o_{s,t,j}) - (w_{s,t,j} * o_{s,t,i} )&amp;lt;= 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The variable &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; in this constraint stands for the workforce of skill &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; in month &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; in salary step &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. The variable o stands for the overtime worked of skill s in month &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; in salary step &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&#xA;This constraint should compare the overtime worked of the workforce in the specific salary step and compare it to the overtime worked of the other salary steps in &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&#xA;This constraint should limit the overtime hour worked per worker to smaller than &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; between each salary step.&lt;/p&gt;&#xA;" OwnerUserId="11866" LastEditorUserId="11866" LastEditDate="2023-08-31T15:11:08.837" LastActivityDate="2023-08-31T15:11:08.837" Title="Transforming a quadratic constraint into a linear constraint" Tags="|linear-programming|python|linearization|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="10913" PostTypeId="1" CreationDate="2023-08-30T16:02:19.267" Score="0" ViewCount="16" Body="&lt;p&gt;I'm reading a paper about iterative Linear-Quadratic Regulator (iLQR) and there are a lot of points that I don't understand.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://homes.cs.washington.edu/%7Etodorov/papers/TassaICRA14.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://homes.cs.washington.edu/~todorov/papers/TassaICRA14.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RTCLI.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RTCLI.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I think equation (5b) is deduced by&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mcTfq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mcTfq.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But after getting equation (5b), I still have zero idea how equations (6a), (6b), and (6c) are deduced.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4rbvU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4rbvU.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12371" LastEditorUserId="36" LastEditDate="2023-08-30T22:18:59.023" LastActivityDate="2023-08-30T22:18:59.023" Title="Problem in understanding an equation from a paper about iterative Linear-Quadratic Regulator" Tags="|linear-programming|nonlinear-programming|quadratic-programming|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10914" PostTypeId="1" CreationDate="2023-08-30T16:24:25.153" Score="0" ViewCount="54" Body="&lt;p&gt;My question- What is the standard practice to linearize / approximate computations of mean and variance using MILP solvers?&lt;/p&gt;&#xA;&lt;p&gt;Edit: referencing comments, an idea was proposed to set an upper limit and lower limit, then minimize the range. In context of portfolio optimization, &lt;em&gt;if I specify a minimum desired return&lt;/em&gt;, I can minimize the variance around returns.&lt;/p&gt;&#xA;&lt;p&gt;Suppose here are stock price returns at each timestep indexed by (t, s):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;R = np.array(&#xA;      [[106.68504489,  96.18759117,  82.97144786],&#xA;       [104.4655367 ,  86.73121512,  80.24690676],&#xA;       [ 88.90226758,  88.61186455,  72.55923083],&#xA;       [116.87150529,  89.8232715 ,  83.98530315],&#xA;       [106.55712934,  98.7856774 ,  88.56319976],&#xA;       [102.31215119,  96.55448414,  84.04272026],&#xA;       [ 96.47732234,  88.84869302,  78.85341107],&#xA;       [107.0409267 ,  88.83174151,  85.33453174],&#xA;       [ 99.17865699,  87.98629567,  76.36985641],&#xA;       [ 93.27413486,  86.42718274,  70.47009819]])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I can formulate the problem as follows, using Xpress solver:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;problem = xp.problem()&#xA;&#xA;W = {}&#xA;# Weights for portfolio allocations&#xA;for s in range(3):&#xA;    W[f's{s}'] = xp.var(name=f's{s}',  vartype = xp.continuous)&#xA;problem.addVariable(W)&#xA;&#xA;# Lower limit and upper limit variables representing the max and min &#xA;#   returns across all timesteps. (Objective shrinks range to &#xA;#   shrink standard deviation of returns) &#xA;L = [xp.var(name=f'lower limit',  vartype = xp.continuous),&#xA;     xp.var(name=f'upper limit',  vartype = xp.continuous)]&#xA;problem.addVariable(L)&#xA;&#xA;C = []&#xA;# 1/ For each timestep, the sum of weighted allocations is greater than lower &#xA;#    limit and less than upper limit &#xA;for t in range(10):&#xA;    t_sum = xp.Sum([R[t,s] * W[f's{s}'] for s in range(3)])&#xA;    c1 = L[0] &amp;lt;= t_sum&#xA;    c2 = L[1] &amp;gt;= t_sum&#xA;    C.extend([ c1, c2 ])&#xA;    &#xA;# 2/ Each stock weight between [0,1]    &#xA;for s in range(3):&#xA;    c1 = 0.0 &amp;lt;= W[f&amp;quot;s{s}&amp;quot;]&#xA;    c2 = W[f&amp;quot;s{s}&amp;quot;] &amp;lt;= 1.0&#xA;    C.extend([c1, c2])&#xA;&#xA;# 3/ Weights sum to 100% portfolio allocation&#xA;c = xp.Sum([ W[f&amp;quot;s{s}&amp;quot;] for s in range(3) ]) == 1.0&#xA;C.append(c)&#xA;&#xA;# 4/ summed allocations over each stock and each timestep &#xA;#    greater than some threshold&#xA;T = xp.Sum([ xp.Sum([R[t,s] * W[f's{s}'] for s in range(3)])&#xA;     for t in range(10) ])&#xA;c = T &amp;gt;= 1000.0 &#xA;C.append(c)&#xA;&#xA;problem.addConstraint(C)&#xA;&#xA;O = L[1] - L[0]&#xA;problem.setObjective(xp.Sum(O), sense = xp.minimize)&#xA;problem.solve()  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Ultimately, the portfolio returns 1000, summing the weighted contributions over each timestep. But the true objective is to minimize the variance of these weighted contributions (an array of length 10, one weighted aggregation per timestep.) The standard deviation is 6.49 where the returns are as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;104.66273621418969,&#xA; 101.04906320581212,&#xA; 88.84632214954465,&#xA; 111.66072948494481,&#xA; 105.05997821163048,&#xA; 101.20295077452609,&#xA; 95.00768563857933,&#xA; 103.53297189768307,&#xA; 97.02247607184876,&#xA; 91.9550863512409&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, some issues with this approach:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Covariance is completely overlooked here, which could be relevant.&lt;/li&gt;&#xA;&lt;li&gt;Need to specify a desired overall return as a constraint and choosing a reasonably high yet still feasible value takes some consideration.&lt;/li&gt;&#xA;&lt;li&gt;In theory, I could swap variance minimization for mean maximization by using a desired variance as a constraint and maximizing the mean return. But this also requires the nontrivial specification of allowable risk.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to both maximize the mean and minimize the variance?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="10326" LastEditDate="2023-08-30T20:36:32.383" LastActivityDate="2023-08-30T20:36:32.383" Title="MILP: Linearization / approximation of mean and variance" Tags="|mixed-integer-programming|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10915" PostTypeId="1" AcceptedAnswerId="10916" CreationDate="2023-08-30T17:02:41.703" Score="2" ViewCount="48" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/odow/SDDP.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;SDDP.jl&lt;/a&gt; for my research project and want to use continuous distribution, can I do so?&lt;/p&gt;&#xA;" OwnerUserId="10727" LastEditorUserId="804" LastEditDate="2023-08-30T22:19:48.890" LastActivityDate="2023-08-30T22:19:48.890" Title="Can I use continuous probability distributions when creating an SDDP.jl model?" Tags="|dynamic-programming|julia|stochastic-dual-dynamic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10916" PostTypeId="2" ParentId="10915" CreationDate="2023-08-30T17:51:31.567" Score="3" Body="&lt;p&gt;Per the SDDP.jl documentation, the answer is no. But see below for a workaround.&lt;/p&gt;&#xA;&lt;p&gt;Per &lt;a href=&quot;https://odow.github.io/SDDP.jl/stable/tutorial/first_steps/#States,-controls,-and-random-variables&quot; rel=&quot;nofollow noreferrer&quot;&gt;States, controls, and random variables 3.&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Random variables are finite, discrete, exogenous random variables that&#xA;the agent observes at the start of a node, before the control&#xA;variables are decided.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Per &lt;a href=&quot;https://odow.github.io/SDDP.jl/stable/tutorial/first_steps/#Assumptions&quot; rel=&quot;nofollow noreferrer&quot;&gt;Assumptions&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Assumption 2: finite random variables&lt;/p&gt;&#xA;&lt;p&gt;The sample space &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt; is finite and discrete for each node &lt;span class=&quot;math-container&quot;&gt;$i\in N$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Per &lt;a href=&quot;https://odow.github.io/SDDP.jl/stable/tutorial/first_steps/#Random-variables&quot; rel=&quot;nofollow noreferrer&quot;&gt;Random variables&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;To add an uncertain variable to the model, we create a new JuMP&#xA;variable inflow, and then call the function SDDP.parameterize. The&#xA;SDDP.parameterize function takes three arguments: the subproblem, a&#xA;vector of realizations, and a corresponding vector of probabilities.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The remainder of this post is my commentary.&lt;/p&gt;&#xA;&lt;p&gt;So if you have a continuous distribution (random variable), you would have to discretize it, and input the vector of discrete values and corresponding vector of probabilities.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2023-08-30T17:51:31.567" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10917" PostTypeId="1" AcceptedAnswerId="10918" CreationDate="2023-08-30T19:04:34.093" Score="0" ViewCount="35" Body="&lt;p&gt;I am trying to model a routing instance in AMPL C++ API. The AMPL Book presents a strategy for modeling routing instances via AMPL (Figures 6-2a and 6-2b, Page 95, &lt;a href=&quot;https://ampl.com/wp-content/uploads/Chapter-6-Compound-Sets-and-Indexing-AMPL-Book.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chapter 6&lt;/a&gt;), as it is presented below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set V; # nodes&#xA;set A within {V,V}; # arcs&#xA;param cost{A}; # costs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, I am having a hard time to find resources showing of how to achieve this by means of the AMPL C++ API. Below follows a C++ code with the parts in which I am lost.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;&#xA;#include &amp;lt;string&amp;gt; &#xA;&#xA;#include &amp;quot;ampl/ampl.h&amp;quot;&#xA;&#xA;using namespace std;&#xA;using namespace ampl;&#xA;&#xA;int main(int argc, char **argv) {&#xA;    try {&#xA;        /* INPUT */&#xA;&#xA;        // Nodes ids&#xA;        size_t n = 10;&#xA;&#xA;        char ** V = (char **) malloc(n * sizeof(char*));&#xA;        for (int i = 0; i &amp;lt; n; i++) {&#xA;            // up to 10 characters of id&#xA;            V[i] = (char *) malloc(10 * sizeof(char));&#xA;            sprintf(V[i], &amp;quot;%d&amp;quot;, i);&#xA;        }&#xA;&#xA;        // Arcs&#xA;        vector&amp;lt;pair&amp;lt;int, int&amp;gt;&amp;gt; A = {make_pair(1, 0), make_pair(2, 5)};&#xA;&#xA;        /* AMPL process */&#xA;        AMPL ampl;&#xA;&#xA;        // Sets&#xA;        // Nodes&#xA;        ampl.eval(&amp;quot;set V;&amp;quot;);&#xA;        ampl.getSet(&amp;quot;V&amp;quot;).setValues(V, n);&#xA;&#xA;        // Arcs&#xA;        ampl.eval(&amp;quot;set A within {V,V};&amp;quot;);&#xA;        ampl.getSet(&amp;quot;A&amp;quot;);&#xA;        // how to set A???&#xA;&#xA;        // cost&#xA;        ampl.eval(&amp;quot;param cost{A};&amp;quot;);&#xA;        ampl.getParameter(&amp;quot;cost&amp;quot;);&#xA;        // how to set populate cost???&#xA;&#xA;        // Closing&#xA;        ampl.close();&#xA;&#xA;        // Cleaning&#xA;        for (int i = 0; i &amp;lt; n; i++) &#xA;            free(V[i]);&#xA;        free(V);&#xA;&#xA;        return 0;&#xA;    } catch (const std::exception &amp;amp;e) {&#xA;        std::cout &amp;lt;&amp;lt; e.what() &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&#xA;        return 1;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For those who want to replicate the experiments locally, just follow the steps of this &lt;a href=&quot;https://github.com/matheusdiogenesandrade/AMPL_cmake.git&quot; rel=&quot;nofollow noreferrer&quot;&gt;repo&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I took the time to read the API documentation, specifically wrt to the classes &lt;a href=&quot;https://portal.ampl.com/docs/api/latest/cpp/classes/set.html#_CPPv4N4ampl3SetE&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Set&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://portal.ampl.com/docs/api/latest/cpp/classes/parameter.html#_CPPv4N4ampl9ParameterE&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Parameter&lt;/code&gt;&lt;/a&gt;, but I still couldn't find a way of using the functions &lt;code&gt;setValues&lt;/code&gt;. I would like to know if anyone ever passed by such a situation before.&lt;/p&gt;&#xA;&lt;p&gt;Thanks and regards.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastActivityDate="2023-09-10T12:35:35.957" Title="Graphs arcs on AMPL C++ API" Tags="|graphs|c++|ampl|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10918" PostTypeId="2" ParentId="10917" CreationDate="2023-08-30T21:43:07.907" Score="1" Body="&lt;p&gt;In the API examples there is one with nodes, links and costs (&lt;a href=&quot;https://ampl.com/api/latest/cpp/examples.html#example-4-operate-with-multidimensional-data&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ampl.com/api/latest/cpp/examples.html#example-4-operate-with-multidimensional-data&lt;/a&gt;) that is very similar to what you are trying to do. The following snippet uses &lt;code&gt;AMPL::setData&lt;/code&gt; like in the multidimensional data example to pass a DataFrame with the elements of set &lt;code&gt;A&lt;/code&gt; and the values for the parameter &lt;code&gt;cost&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;ampl::AMPL ampl;&#xA;&#xA;std::vector&amp;lt;double&amp;gt; V = {0, 1, 2, 5};&#xA;ampl.eval(&amp;quot;set V;&amp;quot;);&#xA;ampl.getSet(&amp;quot;V&amp;quot;).setValues(V.data(), V.size());&#xA;&#xA;std::vector&amp;lt;std::pair&amp;lt;double, double&amp;gt;&amp;gt; A = {std::make_pair(1, 0), std::make_pair(2, 5)};&#xA;ampl.eval(&amp;quot;set A within {V,V};&amp;quot;);&#xA;ampl.eval(&amp;quot;param cost{A};&amp;quot;);&#xA;ampl.getParameter(&amp;quot;cost&amp;quot;);&#xA;&#xA;ampl::DataFrame df(2, ampl::StringArgs(&amp;quot;i&amp;quot;, &amp;quot;j&amp;quot;, &amp;quot;cost&amp;quot;));&#xA;std::vector&amp;lt;double&amp;gt; v1;&#xA;std::vector&amp;lt;double&amp;gt; v2;&#xA;std::vector&amp;lt;double&amp;gt; cost;&#xA;for (auto p : A)&#xA;{&#xA;  v1.push_back(p.first);&#xA;  v2.push_back(p.second);&#xA;  cost.push_back(3.14);&#xA;}&#xA;df.setColumn(&amp;quot;i&amp;quot;, v1.data(), v1.size());&#xA;df.setColumn(&amp;quot;j&amp;quot;, v2.data(), v2.size());&#xA;df.setColumn(&amp;quot;cost&amp;quot;, cost.data(), cost.size());&#xA;ampl.setData(df, &amp;quot;A&amp;quot;);&#xA;&#xA;ampl.eval(&amp;quot;display cost;&amp;quot;);&#xA;ampl.close();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9912" LastEditorUserId="9912" LastEditDate="2023-09-10T12:35:35.957" LastActivityDate="2023-09-10T12:35:35.957" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10919" PostTypeId="1" CreationDate="2023-08-31T13:18:20.417" Score="1" ViewCount="122" Body="&lt;p&gt;It seems that or-tools' CP-SAT solvers allows for non-integer coefficients in a linear objective expression. Am I correct, or is it just that the solver doesn't check for integrity and rounds the coefficients ?&lt;/p&gt;&#xA;" OwnerUserId="12375" LastActivityDate="2023-08-31T15:32:41.563" Title="Non integer linear objective in or-tools CP-SAT" Tags="|python|or-tools|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10920" PostTypeId="2" ParentId="10919" CreationDate="2023-08-31T13:55:32.733" Score="3" Body="&lt;p&gt;CP-SAT accepts floating point coefficients in the objective. It applies the necessary scaling to do all computation with integers, and report the unscaled objective.&lt;/p&gt;&#xA;&lt;p&gt;It also displays in the log some statistics about the quality and precision of the scaling.&lt;/p&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2023-08-31T15:32:41.563" LastActivityDate="2023-08-31T15:32:41.563" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10922" PostTypeId="1" AcceptedAnswerId="10923" CreationDate="2023-09-01T09:20:47.397" Score="0" ViewCount="27" Body="&lt;p&gt;I want to collect evaluation data and for it I need to collect data in numbers not SDDP.state objects, so how can I do that in &lt;a href=&quot;https://github.com/odow/SDDP.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;SDDP.jl&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10727" LastEditorUserId="804" LastEditDate="2023-09-01T12:46:23.293" LastActivityDate="2023-09-01T12:46:23.293" Title="How do I convert an SDDP.State object into a number or tuple in SDDP.jl?" Tags="|julia|stochastic-dual-dynamic-programming|sddp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10923" PostTypeId="2" ParentId="10922" CreationDate="2023-09-01T09:38:04.050" Score="1" Body="&lt;p&gt;The &lt;code&gt;x::SDDP.State&lt;/code&gt; objects have a &lt;code&gt;.in&lt;/code&gt; field and a &lt;code&gt;.out&lt;/code&gt; field, corresponding to the value of the incoming and outgoing state variables at a node. Pick which one makes sense to use for your application.&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2023-09-01T09:38:04.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10924" PostTypeId="1" CreationDate="2023-09-01T18:43:42.357" Score="0" ViewCount="68" Body="&lt;p&gt;The &lt;a href=&quot;http://people.brunel.ac.uk/%7Emastjjb/jeb/or/sp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR-Notes by J E Beasley&lt;/a&gt; states:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Hence the problem:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;minimise     5x+6y&#xA;subject to:&#xA;             Prob(a1x + a2y &amp;gt;= 3) &amp;gt;= 1-alpha&#xA;             x,y &amp;gt;= 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;is a well-defined problem.&lt;/p&gt;&#xA;&lt;p&gt;This particular problem (because it contains just two variables) can be easily solved by a simple numeric search procedure. For example for alpha=0.01 the solution is x=3, y=0 and for alpha=0.05 the solution is x=1, y=1.&lt;/p&gt;&#xA;&lt;p&gt;The feasible region for alpha=0.05 is shown below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GjRtY.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GjRtY.gif&quot; alt=&quot;Feasible region for alpha=0.05&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Here it is claimed that the example can be easily solved by a simple numeric search procedure. Does this mean that simplex solvers would be able to accept constraints such as the below&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \operatorname{Prob}(a_1x + a_2y &amp;gt;=3) \geq 0.95 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;either directly or with some reformulation?&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="198" LastEditDate="2023-09-05T07:58:05.673" LastActivityDate="2023-09-05T07:58:05.673" Title="Simplex algorithm for stochastic constraints?" Tags="|stochastic-programming|simplex|probability-distributions|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10925" PostTypeId="1" CreationDate="2023-09-02T18:41:55.360" Score="1" ViewCount="63" Body="&lt;p&gt;Suppose we are trying to optimize a uniformly continuous function with multiple critical points.&lt;/p&gt;&#xA;&lt;p&gt;If the value of global minimum is already known before optimization, can we find arg(min) within polynomial time?&lt;/p&gt;&#xA;&lt;p&gt;Numerical methods (i.e. gradient descents) typically only consider about first derivative, thus feel difficult to tell differences between local/ global min). However, I think at least in this special problem, “knowing value of global min” is helpful for finding arg(min).&lt;/p&gt;&#xA;" OwnerUserId="12382" LastActivityDate="2023-09-02T18:41:55.360" Title="Find arg(min) when global min is known" Tags="|nonconvex-programming|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="10928" PostTypeId="1" AcceptedAnswerId="10930" CreationDate="2023-09-04T08:22:47.030" Score="0" ViewCount="135" Body="&lt;p&gt;currently I am working on implementing Benders Decomposition for a large-scale stochastic MIP in C++ using the CPLEX Solver. I've been spending the last couple of months learning the programming language, understanding the method and now I feel ready to tackle this problem.&lt;/p&gt;&#xA;&lt;p&gt;Nevertheless, I feel a bit overwhelmed and I am worried I'm moving in a wrong direction with how I structure my code. For that reason, I wanted to ask if some of you have some tips on the best way to implement Benders?&lt;/p&gt;&#xA;&lt;p&gt;Maybe there even exists some kind of guide to help me along the way?&lt;/p&gt;&#xA;" OwnerUserId="12130" LastActivityDate="2023-09-04T15:11:03.017" Title="Tips for implementing Benders Decomposition in C++?" Tags="|cplex|stochastic-programming|benders-decomposition|c++|implementation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10929" PostTypeId="2" ParentId="10928" CreationDate="2023-09-04T11:48:06.647" Score="1" Body="&lt;p&gt;For example, If your problem is two-stages stochastic programming, then you can separate your problem into master problem and sub-problem by your hands.&#xA;Then you can use CPLEX to model both stages in different files, then go back to your main function to call them respectively.&#xA;In addition, based on different situation to generate feasibility cuts or optimality cuts until your gap within the tolerance you setting.&lt;/p&gt;&#xA;" OwnerUserId="12370" LastActivityDate="2023-09-04T11:48:06.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10930" PostTypeId="2" ParentId="10928" CreationDate="2023-09-04T15:11:03.017" Score="3" Body="&lt;p&gt;Recent versions of CPLEX (12.7 or later) have built in support for Benders. You can let CPLEX decide what to put in the master problem and what goes in the subproblems, or you can use annotations to specify what goes where. I did a &lt;a href=&quot;https://orinanobworld.blogspot.com/2016/12/support-for-benders-decomposition-in.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;blog post&lt;/a&gt; about it quite a while back.&lt;/p&gt;&#xA;&lt;p&gt;If you want to code your own, you might wish to look at some examples that ship with CPLEX Studio. If X is the installation directory for CPLEX Studio, look in X/cplex/examples/src/cpp. Examples you might find interesting are facility.cpp, ilobendersatsp2.cpp, ilobendersatsp.cpp and ilobenders.cpp.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-09-04T15:11:03.017" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10931" PostTypeId="2" ParentId="10529" CreationDate="2023-09-05T08:42:24.450" Score="1" Body="&lt;p&gt;First of all, I think you have to display the final MIP gap in your terminal, maybe that actually MIP gap is zero.&lt;/p&gt;&#xA;&lt;p&gt;If not, in my opinion, you have to check several experiments. Using MIP solver solve the problem until obtaining the optimal solution which is different with your &amp;quot;SolutionPolish&amp;quot; solution then that might be the case &amp;quot;SolutionPolish&amp;quot; cannot find more integer solution, or you have to check your setting for &amp;quot;SolutionPolish&amp;quot; would not make the algorithm terminate early. For example, integral tolerance, MIP gap or RunTime for &amp;quot;SolutionPolish&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;The reason for &amp;quot;SolutionPolish&amp;quot; cannot find more integer solution is that the concept of algorithm is actually a evaluation algorithm.&lt;/p&gt;&#xA;" OwnerUserId="12370" LastActivityDate="2023-09-05T08:42:24.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10932" PostTypeId="1" AcceptedAnswerId="10934" CreationDate="2023-09-05T13:58:23.020" Score="1" ViewCount="41" Body="&lt;p&gt;Suppose we have an array of binary variables &lt;span class=&quot;math-container&quot;&gt;$\{x_{i,t,n}, \ \forall i \in I, t \in T, n \in N \}$&lt;/span&gt;. If we want to define a condition as, if any of &lt;span class=&quot;math-container&quot;&gt;$x_{i,t,n} = 1$&lt;/span&gt; in an arbitrary index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, then the rest of the bigger index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; should be one. (E.g. if the card of index I would be six, then one of the possible solutions would be &lt;span class=&quot;math-container&quot;&gt;$\{0,0,1,1,1,1\}$&lt;/span&gt;. (For simplicity, I omitted the sets &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt;). I know there is a constraint as &lt;span class=&quot;math-container&quot;&gt;$x_{i,t,n} \leq x_{i+1,t,n}$&lt;/span&gt;, but as far as I test in some problems, it sorts the variables from the first position. For example in the scheduling problem when we want to deploy the resources respectively. Actually, I am not sure it can be used in general at all. I tried to write that in the following form, and I would like to know other insights regarding that.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ ((x_{i} \implies(x_{j} \land x_{k})) \bigvee  (x_{j} \implies(\lnot x_{i} \land x_{k})) \bigvee (x_{k} \implies(\lnot x_{i} \land \lnot x_{j}))) \quad \forall i,j,k \in I: (i\lt j \lt k) $$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-09-05T16:55:54.787" Title="Activating a sequence of the binary variables in a multi-dimensional array" Tags="|optimization|mixed-integer-programming|logical-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10933" PostTypeId="2" ParentId="10821" CreationDate="2023-09-05T14:14:25.277" Score="0" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{ll}&#xA;\text{minimize}  &amp;amp; \sum_{i} y_i \\&#xA;\text{subject to} \\&#xA;&amp;amp; \sum_{i} h_i = 20 \\&#xA;&amp;amp; h_i \ge h_{i+1}, \forall i \in \{1,2,3\} \\&#xA;&amp;amp; 8y_i \ge h_i, \forall i \\&#xA;&amp;amp; h_i \le 8, \forall i \\&#xA;&amp;amp; y_i \in \{0,1\} ,  \forall i\\&#xA;&amp;amp; h_i \ge 0, \forall i&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;That should be worked!&lt;/p&gt;&#xA;&lt;p&gt;The following picture is the result from SCIP.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/yNCpf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yNCpf.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12370" LastEditorUserId="12370" LastEditDate="2023-09-15T17:26:31.477" LastActivityDate="2023-09-15T17:26:31.477" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10934" PostTypeId="2" ParentId="10932" CreationDate="2023-09-05T16:55:54.787" Score="2" Body="&lt;p&gt;Introduce an ordering &lt;span class=&quot;math-container&quot;&gt;$\text{ord}: I \to \{1,\dots,|I|\}$&lt;/span&gt; and impose&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i \le x_j$$&lt;/span&gt;&#xA;for all &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j\in I$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\text{ord}_i + 1 = \text{ord}_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An alternative, less efficient, approach with &lt;span class=&quot;math-container&quot;&gt;$O(|I|^2)$&lt;/span&gt; constraints is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i \le x_j$$&lt;/span&gt;&#xA;for all &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j\in I$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\text{ord}_i &amp;lt; \text{ord}_j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-09-05T16:55:54.787" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="10935" PostTypeId="2" ParentId="10747" CreationDate="2023-09-05T22:59:56.623" Score="1" Body="&lt;p&gt;In my opinion, these two formulations are exactly the same.&#xA;However, coefficience scalling would lead the float number coefficience in the first constraints, and then that would not be the benefit for your solver to solve the problem. The reason is numerical issue can be lead other issues for simplex method such as: select entering/leaving variables, that might make cyclic or degenerate issues happened.&lt;/p&gt;&#xA;&lt;p&gt;So, in my past experience, I would try to deal with integral coefficience in the MIP model to reduce the burden for the solver.&lt;/p&gt;&#xA;" OwnerUserId="12370" LastActivityDate="2023-09-05T22:59:56.623" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10936" PostTypeId="1" CreationDate="2023-09-06T07:24:40.897" Score="2" ViewCount="521" Body="&lt;p&gt;Perhaps two trivial questions: What kind of problem is the following (please note the strict inequality)? How do we solve it?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x\geq 0}\{c^\top x: Ax &amp;lt; b\}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="8718" LastEditDate="2023-09-08T03:13:09.363" LastActivityDate="2023-09-08T03:13:09.363" Title="How to handle strict inequalities?" Tags="|linear-programming|simplex|linear|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10937" PostTypeId="2" ParentId="10936" CreationDate="2023-09-06T07:37:07.970" Score="2" Body="&lt;p&gt;I'm not aware of a special name for those kind of problems. In order to solve it in practice, you might add a small constant numerical tolerance &lt;span class=&quot;math-container&quot;&gt;$\varepsilon &amp;gt; 0$&lt;/span&gt;, e.g. &lt;span class=&quot;math-container&quot;&gt;$\varepsilon = 10^{-8}$&lt;/span&gt;, and solve&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{x \geq 0} c^\top x \quad \text{s.t} \quad Ax \leq b - \varepsilon&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;instead.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2023-09-06T07:37:07.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10938" PostTypeId="2" ParentId="10936" CreationDate="2023-09-06T08:11:11.727" Score="4" Body="&lt;p&gt;In practice, most solvers are implemented to use fast but inexact floating-point arithmetic and thus can only ever guarantee to satisfying the optimality conditions of your problem to within some nonzero tolerances. Due to the presence of these nonzero tolerances, strict and nonstrict inequality hence carry the exact same meaning. What you can do, however, is to rewrite &lt;span class=&quot;math-container&quot;&gt;$Ax &amp;lt; b$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$Ax \leq b - \epsilon$&lt;/span&gt;, for some small constant &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt; 0$&lt;/span&gt; significant enough to make up for tolerances as well as the inexact floating-point arithmetic used to verify those tolerances.&lt;/p&gt;&#xA;&lt;p&gt;In theory, with infinite precision or symbolic computations, you would need some kind of nonlinearity to represent a strict inequality in terms of standard inequalities. As example, your problem could be reformulated as a second-order cone problem as explained in a previous answer (&lt;a href=&quot;https://or.stackexchange.com/a/7357/198&quot;&gt;https://or.stackexchange.com/a/7357/198&lt;/a&gt;):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Strict positivity, &lt;span class=&quot;math-container&quot;&gt;$x &amp;gt; 0$&lt;/span&gt;, is equivalent to the existence of&#xA;nonnegative variable, &lt;span class=&quot;math-container&quot;&gt;$r \geq 0$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$xr \geq 1$&lt;/span&gt;. This means&#xA;that it can be represented in second-order cone programming by the&#xA;conic quadratic constraint  &lt;span class=&quot;math-container&quot;&gt;$$x+r \geq \sqrt{ (x-r)^2 + 1^2 }.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="198" LastActivityDate="2023-09-06T08:11:11.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10939" PostTypeId="2" ParentId="9064" CreationDate="2023-09-06T11:49:17.333" Score="1" Body="&lt;p&gt;For the implementation issue in UserCutCallback &amp;amp; LazyConstraintCallback, you might refer this github&#xA;&lt;a href=&quot;https://github.com/cswaroop/cplex-samples/blob/master/admipex5.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python Example&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;For technique detail between both Callback functions, you also can refer &lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=techniques-user-cut-lazy-constraint-pools&quot; rel=&quot;nofollow noreferrer&quot;&gt;CPLEX Official website&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Hope those information is useful for you.&lt;/p&gt;&#xA;" OwnerUserId="12370" LastActivityDate="2023-09-06T11:49:17.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10940" PostTypeId="1" CreationDate="2023-09-06T12:18:24.737" Score="2" ViewCount="71" Body="&lt;p&gt;&lt;strong&gt;Problem settings:&lt;/strong&gt;&#xA;we have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; agents and a set &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}$&lt;/span&gt; of possible world-states, where the size of &lt;span class=&quot;math-container&quot;&gt;$\mathcal{S}$&lt;/span&gt; is exponential with respect to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;.&#xA;Each agent &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; has a utility function &lt;span class=&quot;math-container&quot;&gt;$u_j\colon \mathcal{S}\to\mathbb{R}_{\geq 0}$&lt;/span&gt; that describes its satisfaction level from a given state. The functions are not explicitly given, but can be accessed through the following two oracles:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A value oracle: given &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; returns &lt;span class=&quot;math-container&quot;&gt;$u_j(S)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;An &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;-SUM oracle (for some given &lt;span class=&quot;math-container&quot;&gt;$\alpha\in(0,1)$&lt;/span&gt;): for any set of non-negative constants &lt;span class=&quot;math-container&quot;&gt;$a_1,\ldots, a_n$&lt;/span&gt;, it finds a state that approximately maximizes the following expression:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\sum_{j=1}^n a_j \cdot u_j(S)&#xA;\end{align*}&lt;/span&gt;&#xA;That is, it returns a state &lt;span class=&quot;math-container&quot;&gt;$S'$&lt;/span&gt; such that:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\sum_{j=1}^n a_j \cdot u_j(S') \geq (1-\alpha)\cdot \max_{S\in\mathcal{S}} \sum_{j=1}^n a_j \cdot u_j(S)&#xA;\end{align*}&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt;&#xA;our goal is to find a probability distribution over the set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; (i.e., some function &lt;span class=&quot;math-container&quot;&gt;$p\colon \mathcal{S}\to[0,1]$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\sum_{S\in \mathcal{S}}p(S) =1$&lt;/span&gt;), that would satisfy some desired properties (described below) regarding the expected utilities of the agents (i.e., &lt;span class=&quot;math-container&quot;&gt;$E_j(p) = \sum_{S\in \mathcal{S}}p(S) \cdot u_j(S)$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$1\leq j \leq n$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Specificaly, in the first step, we want to maximize the minimum value; however, we know that it is NP-hard and so we aim to approximate it.&#xA;The problem can be modeled as the following LP that has an exponential number of variables (&lt;span class=&quot;math-container&quot;&gt;$p(S)$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$S \in \mathcal{S}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; \max\quad  z \quad s.t. \tag{P1}\\&#xA;&amp;amp; (1) \quad \sum_{S \in \mathcal{S}}p(S)=1 \nonumber  \\&#xA;&amp;amp; (2) \quad \sum_{S \in\mathcal{S}}p(S)\cdot u_j(S)  \geq z &amp;amp;&amp;amp; j = 1,\ldots, n \nonumber\\&#xA;&amp;amp; (6) \quad p(S)\geq 0  &amp;amp;&amp;amp; \forall S \in \mathcal{S}\nonumber&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Its dual has a specific structure that allows us to use the ellipsoid method in order to find a feaible solution to the primal with objective value that &lt;span class=&quot;math-container&quot;&gt;$(1-\alpha)$&lt;/span&gt;-approximates the optimal value (e.g., as described &lt;a href=&quot;https://en.wikipedia.org/wiki/Ellipsoid_method#Approximating_LPs_with_an_exponential_number_of_variables&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; or in Section &amp;quot;Dual-based algorithm&amp;quot; of &lt;a href=&quot;https://cdn.aaai.org/ojs/5580/5580-13-8805-1-10-20200512.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt;).&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    &amp;amp; \min \quad q_0\quad s.t.\tag{D1}\\&#xA;        &amp;amp; (1) \quad q_0 -\sum_{j=1}^n u_j(S) v_{j} \geq 0  &amp;amp;&amp;amp; \forall S \in \mathcal{S} \nonumber\\&#xA;                    &amp;amp; (2) \quad \sum_{j=1}^n v_{j} = 1 &amp;amp;&amp;amp; j = 1,\ldots, n \nonumber \\&#xA;                    &amp;amp; (3) \quad v_{j} \geq 0  &amp;amp;&amp;amp; j = 1,\ldots, n \nonumber&#xA;\end{align}&lt;/span&gt;&#xA;The variables are &lt;span class=&quot;math-container&quot;&gt;$q_0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v_{j}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$1\leq j\leq n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The hard part:&lt;/strong&gt;&#xA;Denote the approximation we found for the primal P1 as &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt;.&#xA;Our second goal is to find (or to approximate) the maximum value, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, that can be added to &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; such that the sum of any two expected utilities will be at least &lt;span class=&quot;math-container&quot;&gt;$z_1 + z$&lt;/span&gt; (while each expected utility will be at least &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt;). This can be modelled as the following LP (the variables are &lt;span class=&quot;math-container&quot;&gt;$p(S)$&lt;/span&gt; for any &lt;span class=&quot;math-container&quot;&gt;$S \in \mathcal{S}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_1$&lt;/span&gt; is &lt;em&gt;constant&lt;/em&gt;):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; \max\quad  z \quad s.t. \tag{P2}\\&#xA;&amp;amp; (1) \quad \sum_{S \in \mathcal{S}}p(S)=1 \nonumber  \\&#xA;&amp;amp; (2) \quad y_{1} - \sum_{j=1}^n m_{1,j}\geq  z_1 &amp;amp;&amp;amp;  \nonumber \\&#xA;&amp;amp; (3) \quad 2 y_2 - \sum_{j=1}^{n} m_{2,j} \geq z_1 + z \nonumber \\&#xA;&amp;amp; (4) \quad m_{\ell,j} \geq y_{\ell} - \sum_{S \in\mathcal{S}}p(S)\cdot u_j(S)  &amp;amp;&amp;amp; \ell = 1,2 \quad j = 1,\ldots, n \nonumber \\&#xA;&amp;amp; (5) \quad m_{\ell,j} \geq 0  &amp;amp;&amp;amp; \ell = 1,2\quad j = 1,\ldots, n \nonumber\\&#xA;&amp;amp; (6) \quad p(S)\geq 0  &amp;amp;&amp;amp; \forall S \in \mathcal{S}\nonumber&#xA;\end{align}&lt;/span&gt;&#xA;The reason we use &lt;a href=&quot;https://or.stackexchange.com/questions/8980/how-to-solve-this-linear-program-with-an-exponential-number-of-constraints&quot;&gt;these constraints&lt;/a&gt; (instead of a constraint for each pair of agents) is that we aim to extend this process up to &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; (that is, given an approximation &lt;span class=&quot;math-container&quot;&gt;$z_2$&lt;/span&gt; to this program, we then want to find the maximum value, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, the can be added to &lt;span class=&quot;math-container&quot;&gt;$z_1+z_2$&lt;/span&gt; such that the sum of any three expected utilities will be at least &lt;span class=&quot;math-container&quot;&gt;$z_1+z_2+z$&lt;/span&gt; -while keeping the previous constraints-; and so on), so a direct approach will eventually result in a program that have an exponential number of variables and constraints.&lt;/p&gt;&#xA;&lt;p&gt;The dual of this program can be modeled as follows (the variables are &lt;span class=&quot;math-container&quot;&gt;$q_0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$v_{\ell,j}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q_{\ell}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\ell=1,2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1\leq j\leq n$&lt;/span&gt;):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    &amp;amp; \min \quad q_0- z_1\cdot q_{1} - z_1\cdot q_2 \quad s.t.\tag{D2}\\&#xA;        &amp;amp; (1) \quad q_0 -\sum_{j=1}^n u_j(S) \sum_{\ell=1}^2 v_{\ell,j} \geq 0  &amp;amp;&amp;amp; \forall S \in \mathcal{S} \nonumber\\&#xA;                    &amp;amp; (2) \quad q_2=1 \nonumber \\&#xA;                    &amp;amp; (3) \quad -\ell q_{\ell} + \sum_{j=1}^n v_{\ell,j} = 0 &amp;amp;&amp;amp; \ell = 1,2 \nonumber \\&#xA;                    &amp;amp; (4) \quad q_{\ell} - v_{\ell,j} \geq 0  &amp;amp;&amp;amp; \ell = 1,2 \quad j = 1,\ldots, n \nonumber \\&#xA;                    &amp;amp; (5) \quad v_{\ell,j} \geq 0  &amp;amp;&amp;amp; \ell = 1,2 \quad j = 1,\ldots, n \nonumber \\&#xA;                    &amp;amp; (6) \quad q_{\ell} \geq 0  &amp;amp;&amp;amp; \ell = 1,2  \nonumber&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, this dual has a different structure and so we cannot use the same technique. All our attempts to approximate P2 have failed.&#xA;Notice that the solution that we find for P1 (and D1) gives us a lower bound on the optimal value (maybe it can help..)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My question is: is there any way to approximate P2 in polynomial time, such that the approximation error is polynomial in &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;-- Recall that &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is the error in the given &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;-SUM oracle (described above).&lt;/p&gt;&#xA;&lt;p&gt;-- Note that a feasible primal solution has an exponential size (as we need to describe the value of each variable), but since the primal has only polynomially many constraints, it has a solution in which only a polynomial number of variables are nonzer, so we can consider its &lt;em&gt;sparse form&lt;/em&gt; (i.e., a list of the variables with positive values, along with their values).&lt;/p&gt;&#xA;" OwnerUserId="9927" LastEditorUserId="2576" LastEditDate="2023-09-06T20:08:17.503" LastActivityDate="2023-09-06T20:08:17.503" Title="Approximating an LP with an exponential number of variables and an almost-separation-oracle to its dual" Tags="|optimization|linear-programming|convex-optimization|duality|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10941" PostTypeId="1" AcceptedAnswerId="10943" CreationDate="2023-09-06T19:36:48.343" Score="3" ViewCount="103" Body="&lt;p&gt;Consider the function &lt;span class=&quot;math-container&quot;&gt;$f : [0,1]^n \to [0,\infty)$&lt;/span&gt; defined as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f(x_1,\dots,x_n) = \sum_{(z_1,\dots,z_n) \in \{0,1\}^n} g(z_1,\dots,z_n) \cdot \left[\prod_{i=1}^n x_i^{z_i} \cdot (1-x_i)^{1-z_i}\right]&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$g(z_1,\dots,z_n) \geq 0$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$(z_1,\dots,z_n) \in \{0,1\}^n$&lt;/span&gt;. Note that the summation consists of &lt;span class=&quot;math-container&quot;&gt;$2^n$&lt;/span&gt; terms. My objective is to solve the following problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \begin{aligned}&#xA;    \min_{x_1,\dots,x_n}&#xA;    \quad &amp;amp; f(x_1,\dots,x_n), \\&#xA;    \textrm{s.t.} \quad &amp;amp; (x_1,\dots,x_n) \in \{y \in \mathbb R^n \mid y_1 \in [a_{1},1],\dots,y_n \in [a_{n},1]\}&#xA;    \end{aligned} \tag{1} \label{prob}&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$0 \leq a_i &amp;lt; 1$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. In other words, the decision variables &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n$&lt;/span&gt; are constrained to be within an &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-dimensional hyperrectangle that is a subset of an &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-dimensional hypercube. To solve the problem in \eqref{prob}, my strategy was to convert it into the standard form for a geometric program and then pass it to a solver. However, the main difficulty in doing so is that the literature that I have found on geometric programming constrain &lt;span class=&quot;math-container&quot;&gt;$g(z_1,\dots,z_n)$&lt;/span&gt; to be strictly positive for every &lt;span class=&quot;math-container&quot;&gt;$(z_1,\dots,z_n) \in \{0,1\}^n$&lt;/span&gt;, while in my case, it can be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; for some &lt;span class=&quot;math-container&quot;&gt;$(z_1,\dots,z_n) \in \{0,1\}^n$&lt;/span&gt;. Therefore, &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is not strictly a posynomial. Any suggestions on how to proceed?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Based on the definitions given &lt;a href=&quot;https://inst.eecs.berkeley.edu/%7Eee127/sp21/livebook/l_gp_posy.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, it seems that this isn't really a problem, as the summation in &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; can be split as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;f(x_1,\dots,x_n) &amp;amp;= \sum_{\substack{(z_1,\dots,z_n) \in \{0,1\}^n \\ g(z_1,\dots,z_n) \neq 0}} g(z_1,\dots,z_n) \cdot \left[\prod_{i=1}^n x_i^{z_i} \cdot (1-x_i)^{1-z_i}\right] \\&#xA;&amp;amp;+ \sum_{\substack{(z_1,\dots,z_n) \in \{0,1\}^n \\ g(z_1,\dots,z_n) = 0}} g(z_1,\dots,z_n) \cdot \left[\prod_{i=1}^n x_i^{z_i} \cdot (1-x_i)^{1-z_i}\right] \\&#xA;&amp;amp;= \sum_{\substack{(z_1,\dots,z_n) \in \{0,1\}^n \\ g(z_1,\dots,z_n) \neq 0}} g(z_1,\dots,z_n) \cdot \left[\prod_{i=1}^n x_i^{z_i} \cdot (1-x_i)^{1-z_i}\right]&#xA;\end{align}&lt;/span&gt;&#xA;However, I wonder if there is a better way to approach this problem in the first place, so I'm keeping this question open.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2023-09-06T22:04:35.230" LastActivityDate="2023-09-20T22:13:55.620" Title="Can the following problem be cast as a geometric program?" Tags="|geometric-programming|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10942" PostTypeId="1" CreationDate="2023-09-06T21:15:51.413" Score="2" ViewCount="137" Body="&lt;p&gt;I was trying to generate random connected planar graph for dome numerical experiment of some transportation problem. I have three types of nodes: supply, transshipment and demand. I have the number of nodes and edges; also, i have following rules:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There is no arc from supply nodes driectly to demand nodes. The connection between these two must be through transshipment nodes.&lt;/li&gt;&#xA;&lt;li&gt;It must be a connected graph.&lt;/li&gt;&#xA;&lt;li&gt;The grapgh can be either directed or undirected.&lt;/li&gt;&#xA;&lt;li&gt;Total number of edges is given, but there is no specific rule about exact number of edges between different types of nodes.&lt;/li&gt;&#xA;&lt;li&gt;There are no edges between supply nodes; however, it is not the case for transshipment and demand nodes.&#xA;Any ideas how to code it? (no matter in what language, i just want to have an understanding of the process)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="11106" LastActivityDate="2024-02-04T18:08:36.093" Title="How to generate random connected planar graph?" Tags="|graphs|test-instances|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10943" PostTypeId="2" ParentId="10941" CreationDate="2023-09-07T10:07:46.523" Score="3" Body="&lt;p&gt;There's no problem if some &lt;span class=&quot;math-container&quot;&gt;$g(z_1,...,z_n) = 0$&lt;/span&gt;, because that's the same as the terms which have a zero &lt;span class=&quot;math-container&quot;&gt;$g(z_1,...,z_n)$&lt;/span&gt; not being in the sum (objective function). So the objective is a posynomial, and the optimization problem is a geometric program.&lt;/p&gt;&#xA;&lt;p&gt;The objective function is a posynomial because it is the sum of monomials. Each term in the sum is a monomial because a variable raised to a power is a monomial, and a product of monomials is a monomial.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-09-07T11:51:44.213" LastActivityDate="2023-09-07T11:51:44.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10944" PostTypeId="1" AcceptedAnswerId="10945" CreationDate="2023-09-07T13:16:13.010" Score="4" ViewCount="1161" Body="&lt;p&gt;I would like to solve the following type of LP problems:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CpXdB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CpXdB.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;em&gt;M&lt;/em&gt; and &lt;em&gt;N&lt;/em&gt; are very large numbers, they are on the order of a few hundreds of thousands and tens of thousands, respectively.&lt;/p&gt;&#xA;&lt;p&gt;As is clear from the above formulation, each constraint links only a few variables, leading to an extremely sparse coefficient matrix.&lt;/p&gt;&#xA;&lt;p&gt;Which methods and (free) libraries do you suggest for solving this issue very effectively (within a few minutes)? Is there one which can start from a known feasible solution provided by the user?&lt;/p&gt;&#xA;" OwnerUserId="12405" LastEditorUserId="-1" LastEditDate="2023-09-08T20:16:37.660" LastActivityDate="2023-09-08T20:16:37.660" Title="Which solvers should I use to solve large, but extremely sparse LP problems with 100-500 thousand variables?" Tags="|linear-programming|constraint|cbc|glpk|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10945" PostTypeId="2" ParentId="10944" CreationDate="2023-09-07T14:26:44.317" Score="7" Body="&lt;p&gt;One of the best-performing free LP solvers exploiting sparsity is HiGHS (&lt;a href=&quot;https://github.com/ERGO-Code/HiGHS&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/ERGO-Code/HiGHS&lt;/a&gt;). It allows passing a starting point.&lt;/p&gt;&#xA;&lt;p&gt;For comparing relative performance of a number of LP solvers on a standardized test set, take a look at the Mittelmann benchmarks (&lt;a href=&quot;https://plato.asu.edu/ftp/lpopt.html&quot; rel=&quot;noreferrer&quot;&gt;https://plato.asu.edu/ftp/lpopt.html&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="47" LastActivityDate="2023-09-07T14:26:44.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10946" PostTypeId="2" ParentId="10944" CreationDate="2023-09-07T15:45:42.100" Score="5" Body="&lt;p&gt;Based on the Mittelmann benchmarks, I would agree that HiGHS is a contender, as is &lt;a href=&quot;https://github.com/coin-or/Clp&quot; rel=&quot;noreferrer&quot;&gt;Clp&lt;/a&gt; (which is faster than HiGHS on some test problems, slower on others). You might also want to look at &lt;a href=&quot;https://www.scipopt.org/&quot; rel=&quot;noreferrer&quot;&gt;SCIP&lt;/a&gt;, which is highly regarded as a mixed integer program solver but will certainly solve LPs.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-09-07T15:45:42.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10947" PostTypeId="2" ParentId="10942" CreationDate="2023-09-07T17:49:11.833" Score="1" Body="&lt;p&gt;Here are two approaches, both for an undirected graph (but easily modified to handle a digraph).&lt;/p&gt;&#xA;&lt;p&gt;Method 1: Start with a complete graph (in the sense that all legal edges exist). Compile a list of all edges and shuffle it randomly. While the number of edges exceeds your quota, pop the next edge and remove it. If the graph remains connected, continue; if not, replace the edge and continue. If you use up all the edges before reaching the target number of edges, start over with a new random seed.&lt;/p&gt;&#xA;&lt;p&gt;Checking whether the graph remains connected after removing edge (i, j) is not as bad as it sounds. You just need to do a depth-first search for a surviving path from i to j.&lt;/p&gt;&#xA;&lt;p&gt;Method 2: Write an integer linear program to selected a subset of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; edges such that the graph is connected (&lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; being your required edge count). The model will contain a binary variable for each edge. Assign each of those variables a randomly generated positive cost and set minimization of the total cost as the objective. Method 2 does not require restarts (unlike method 1), but does require an integer programming solver and is likely to be slower (possibly a lot slower).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-09-07T17:49:11.833" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10949" PostTypeId="1" AcceptedAnswerId="10950" CreationDate="2023-09-08T04:04:13.343" Score="1" ViewCount="73" Body="&lt;p&gt;I'm trying to supply &lt;code&gt;knitro&lt;/code&gt; with a Hessian but struggle to understand the dimension of the Lagrangian multiplier &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;. From my general education and &lt;a href=&quot;https://www.artelys.com/docs/knitro/2_userGuide/derivatives.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;knitro's documentation&lt;/a&gt; which gives the Lagrangian as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathcal{L}(x,\lambda,\sigma) := \sigma f(x) +\sum\limits_{i=0}^{m-1} \lambda_i c_i(x),&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is the objective and &lt;span class=&quot;math-container&quot;&gt;$c_i(x)$&lt;/span&gt; are the constraints, I would think that &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is the number of constraints. When I implemented my Hessian (as function of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;, I noticed that the Hessian is evaluated in an unexpected way because the dimension of &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; seemed to equal that of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; although I have much more constraints than variables. That is why the Hessian returns &lt;code&gt;nan&lt;/code&gt; when calling knitro although the Hessian evaluates normally when I supply &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sigma$&lt;/span&gt; with the expected dimensions.&lt;/p&gt;&#xA;&lt;p&gt;This is also the case in the examples provided by &lt;code&gt;knitro&lt;/code&gt;. For example, in the example HS71 in &lt;code&gt;HS71.R&lt;/code&gt;, they show how to solve the problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min\limits_{x1,x2,x3,x4}    x_1 x_4 (x_1 + x_2 + x_3) + x_3&#xA;\quad&#xA;\text{ s.t. }   &#xA;\begin{cases}&#xA;x_1 x_2 x_3 x_4 \ge 25,\\&#xA;        x_1^2 + x_2^2 + x_3^2 + x_4^2 = 40,\\&#xA;        1 \le x_1, x_2, x_3, x_4 \le 5.&#xA;\end{cases}&#xA;$$&lt;/span&gt;&#xA;In the supplied code for the Hessian in this case, &lt;code&gt;eval_h(x, lambda, sig)&lt;/code&gt;, Artelys uses &lt;code&gt;lambda[1]&lt;/code&gt; and &lt;code&gt;lambda[2]&lt;/code&gt;, i.e. &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is &lt;strong&gt;two-dimensional&lt;/strong&gt;, as I would expect. However, when &lt;code&gt;knitro&lt;/code&gt; is called, i.e. &lt;code&gt;res &amp;lt;- knitro(...)&lt;/code&gt;, then&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;res$lambda = c(-1.087872e+00,  2.742766e-08, -9.083440e-09, -1.797043e-07)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which is suddenly &lt;strong&gt;four-dimensional&lt;/strong&gt;. I could imagine that the nonlinear constraints (of which there are 2) count double internally because they come with an upper and lower bound (although the upper bound for the first one if &lt;code&gt;Inf&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;In &lt;code&gt;HS40.R&lt;/code&gt;, there are 3 constraints (suggesting that lambda would be six-dimensional). But lambda is only four-dimensional as per the output of &lt;code&gt;knitro&lt;/code&gt;. I could imagine that the third inequality does not count as it is quadratic and &lt;code&gt;knitro&lt;/code&gt; handles the constraints internally.&lt;/p&gt;&#xA;&lt;p&gt;But in all these supplied examples, the number of constraints is lower than the number of variables and the dimension of &lt;code&gt;lambda&lt;/code&gt; is equal to the dimension of &lt;code&gt;x&lt;/code&gt;. In my application, there are more constraints than variables, but the dimension of &lt;code&gt;lambda&lt;/code&gt; that knitro calls my Hessian with is also exactly the dimension of &lt;code&gt;x&lt;/code&gt;. This leads to problems because I am referencing lambdas with &amp;quot;higher&amp;quot; indices.&lt;/p&gt;&#xA;&lt;p&gt;To summarize, my questions are&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What exactly is &lt;code&gt;m&lt;/code&gt; in the Lagrangian of knitro?&lt;/li&gt;&#xA;&lt;li&gt;Does a constraint like &lt;span class=&quot;math-container&quot;&gt;$l \le c_1 \le u$&lt;/span&gt; count twice for the dimension of &lt;code&gt;lambda&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Does a linear or quadratic constraint count into &lt;code&gt;m&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Is the lambda in the documentation of the Hessian and the lambda in the output of knitro perhaps something else? (The documentation says that the output &lt;code&gt;lambda&lt;/code&gt; is a &amp;quot;Vector containing the variable dual values.&amp;quot; I thought of these as dual values of constraints, but knitro says specifically &lt;em&gt;variable&lt;/em&gt; dual values).&lt;/li&gt;&#xA;&lt;li&gt;Is there a way to enforce the dimension of &lt;code&gt;lambda&lt;/code&gt; for &lt;code&gt;knitro&lt;/code&gt;'s calls to the Hessian (I do supply &lt;code&gt;ncon&lt;/code&gt; in my code and knitro correctly recognizes the number of constraints (not double-counting upper and lower bounds), but still supplies &lt;code&gt;lambda&lt;/code&gt;s of a lower dimension than what I expect.).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Edit: If that is relevant, I am using knitro version 13.0.1.&lt;/p&gt;&#xA;" OwnerUserId="12409" LastEditorUserId="36" LastEditDate="2023-09-08T12:36:25.147" LastActivityDate="2023-09-08T16:36:35.830" Title="Knitro dimension of lambda for Hessian" Tags="|nonlinear-programming|solver|software|lagrange-multipliers|knitro|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10950" PostTypeId="2" ParentId="10949" CreationDate="2023-09-08T16:36:35.830" Score="1" Body="&lt;p&gt;Indeed, there is a bug in the Knitro R interface. The size of the &lt;code&gt;lambda&lt;/code&gt; array in the callback input is wrong, and the &lt;code&gt;lambda&lt;/code&gt; array returned at the end only contains the dual variable values.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://nextcloud.artelys.com/nextcloud/s/4AbNzsmJCLTFcyz&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is a fixed version of the interface&lt;/p&gt;&#xA;&lt;p&gt;Now, in the output, there is one &lt;code&gt;lambda&lt;/code&gt; array for the constraint dual values and another &lt;code&gt;lambdaVar&lt;/code&gt; array for the variable dual values.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ Rscript HS40.R&#xA;&#xA;=======================================&#xA;          Commercial License&#xA;         Artelys Knitro 13.2.0&#xA;=======================================&#xA;&#xA;Knitro presolve eliminated 0 variables and 0 constraints.&#xA;&#xA;concurrent_evals:        0&#xA;&#xA;Problem Characteristics                                 (   Presolved)&#xA;-----------------------&#xA;Objective goal:  Maximize&#xA;Objective type:  general&#xA;Number of variables:                                  4 (           4)&#xA;    bounded below only:                               0 (           0)&#xA;    bounded above only:                               0 (           0)&#xA;    bounded below and above:                          0 (           0)&#xA;    fixed:                                            0 (           0)&#xA;    free:                                             4 (           4)&#xA;Number of constraints:                                3 (           3)&#xA;    linear equalities:                                0 (           0)&#xA;    quadratic equalities:                             0 (           0)&#xA;    gen. nonlinear equalities:                        3 (           3)&#xA;    linear one-sided inequalities:                    0 (           0)&#xA;    quadratic one-sided inequalities:                 0 (           0)&#xA;    gen. nonlinear one-sided inequalities:            0 (           0)&#xA;    linear two-sided inequalities:                    0 (           0)&#xA;    quadratic two-sided inequalities:                 0 (           0)&#xA;    gen. nonlinear two-sided inequalities:            0 (           0)&#xA;Number of nonzeros in Jacobian:                       7 (           7)&#xA;Number of nonzeros in Hessian:                        9 (           9)&#xA;&#xA;Knitro using the Interior-Point/Barrier Direct algorithm.&#xA;&#xA;  Iter      Objective      FeasError   OptError    ||Step||    CGits&#xA;--------  --------------  ----------  ----------  ----------  -------&#xA;       0    4.096000e-01   2.880e-01&#xA;       3    2.500000e-01   1.863e-10   2.661e-09   1.834e-05        0&#xA;&#xA;EXIT: Locally optimal solution found.&#xA;&#xA;Final Statistics&#xA;----------------&#xA;Final objective value               =   2.50000000082290e-01&#xA;Final feasibility error (abs / rel) =   1.86e-10 / 1.86e-10&#xA;Final optimality error  (abs / rel) =   2.66e-09 / 2.66e-09&#xA;# of iterations                     =          3&#xA;# of CG iterations                  =          0&#xA;# of function evaluations           =          4&#xA;# of gradient evaluations           =          4&#xA;# of Hessian evaluations            =          3&#xA;Total program time (secs)           =       0.16799 (     0.062 CPU time)&#xA;Time spent in evaluations (secs)    =       0.06291&#xA;&#xA;===============================================================================&#xA;&#xA;Final results:&#xA;$status&#xA;[1] 0&#xA;&#xA;$obj&#xA;[1] 0.25&#xA;&#xA;$x&#xA;[1] 0.7937005 0.7071068 0.5297315 0.8408964&#xA;&#xA;$lambda&#xA;[1] -0.5000000  0.4719372 -0.3535534&#xA;&#xA;$lambdaVar&#xA;[1] 0 0 0 0&#xA;&#xA;$objGrad&#xA;[1] 0.3149803 0.3535534 0.4719372 0.2973018&#xA;&#xA;$objGradIndexVars&#xA;[1] 0 1 2 3&#xA;&#xA;$c&#xA;[1] 1.000000e+00 9.385481e-11 1.863212e-10&#xA;&#xA;$r&#xA;NULL&#xA;&#xA;$jac&#xA;[1]  1.8898816  1.4142136  1.3348399 -1.0000000  0.6299605 -1.0000000  1.6817928&#xA;&#xA;$jacIndexCons&#xA;[1] 0 0 1 1 1 2 2&#xA;&#xA;$jacIndexVars&#xA;[1] 0 1 0 2 3 1 3&#xA;&#xA;$rsdJac&#xA;NULL&#xA;&#xA;$rsdJacIndexRsds&#xA;NULL&#xA;&#xA;$rsdJacIndexVars&#xA;NULL&#xA;&#xA;$numFCevals&#xA;[1] 4&#xA;&#xA;$numGAevals&#xA;[1] 4&#xA;&#xA;$numHevals&#xA;[1] 3&#xA;&#xA;$numHVevals&#xA;[1] 0&#xA;&#xA;$numIters&#xA;[1] 3&#xA;&#xA;$numCGiters&#xA;[1] 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-09-08T16:36:35.830" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10951" PostTypeId="1" AcceptedAnswerId="10966" CreationDate="2023-09-08T17:14:49.703" Score="1" ViewCount="63" Body="&lt;p&gt;For a &lt;code&gt;CpModel&lt;/code&gt; using docplex, is there any function to evaluate a linear expression based on the variables values in the final solution?&lt;/p&gt;&#xA;&lt;p&gt;For example, for &lt;code&gt;expression = (x + 2y + z)&lt;/code&gt;, with Gurobi this expression has type &lt;code&gt;gurobipy.LinExpr&lt;/code&gt; and I can do &lt;code&gt;expression.getValue()&lt;/code&gt;. For CP-SAT of OrTools I can do &lt;code&gt;solver.Value(expression)&lt;/code&gt; where solver has type &lt;code&gt;CpSolver&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12416" LastEditorUserId="981" LastEditDate="2023-12-22T15:09:24.003" LastActivityDate="2023-12-22T15:09:24.003" Title="Evaluation of linear expression with docplex based on a solution" Tags="|constraint-programming|or-tools|docplex|cp-sat|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10953" PostTypeId="2" ParentId="10951" CreationDate="2023-09-08T21:26:02.260" Score="-1" Body="&lt;p&gt;Assuming your model object is &lt;code&gt;mdl&lt;/code&gt;, when you create the constraints in docplex with &lt;code&gt;add_constraint&lt;/code&gt; (or &lt;code&gt;add_constraints&lt;/code&gt;), the generated constraint is returned and you can save that, similar to what you showed in your example.&lt;/p&gt;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;ctr = mdl.add_constraint(x+y&amp;lt;=5, 'c1')&lt;/code&gt;&#xA;If your constraint is not saved, you can access it after the solve by &lt;code&gt;ctr = mdl.get_constraint_by_name('c1')&lt;/code&gt; as well.&lt;/p&gt;&#xA;&lt;p&gt;Now, what's the value that you're after? If it's &lt;code&gt;x+y&lt;/code&gt;, then you're after the &lt;code&gt;lhs&lt;/code&gt;. So, to get that expression, you can say &lt;code&gt;ctr.lhs&lt;/code&gt; (Similarly, you can access &lt;code&gt;rhs&lt;/code&gt; using &lt;code&gt;ctr.rhs&lt;/code&gt;). If you want to get the value, it's like getting any other value in docplex, by accessing &lt;code&gt;solution_value&lt;/code&gt;. So, the value of &lt;code&gt;x+y&lt;/code&gt; becomes &lt;code&gt;ctr.lhs.solution_value&lt;/code&gt;. There might be other ways, but this is the one that I'm aware of.&lt;/p&gt;&#xA;" OwnerUserId="36" LastActivityDate="2023-09-08T21:26:02.260" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10954" PostTypeId="1" CreationDate="2023-09-09T06:17:18.717" Score="0" ViewCount="77" Body="&lt;p&gt;If an Integer Linear Programming (ILP) problem is relaxed to a Linear Programming (LP) problem, is the objective value of the LP always less than the same ILP problem? Why?&lt;/p&gt;&#xA;" OwnerUserId="584" LastActivityDate="2023-09-09T07:22:24.897" Title="For an ILP relaxed to LP is the LP solution objective always less than the ILP solution?" Tags="|optimization|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10955" PostTypeId="2" ParentId="10954" CreationDate="2023-09-09T07:17:06.250" Score="5" Body="&lt;p&gt;If the integer linear programming is a minimization problem then whose linear relaxation is a lower bound for the original MILP model, and for the maximization problem it is an upper bound. In the context of branch and bound and for the minimization model, linear relaxation is known as the best bound (lower bound), and every feasible solution would be an incumbent or best feasible solution. In the maximization, the situation is vice versa.&lt;/p&gt;&#xA;&lt;p&gt;When you enforce integrality constraint, the objective function of MILP is worse than whose linear relaxation. Also, there is an exception when the original problem has an integrality property which is known as the total unimodularity condition.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-09-09T07:22:24.897" LastActivityDate="2023-09-09T07:22:24.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10956" PostTypeId="1" AcceptedAnswerId="10957" CreationDate="2023-09-09T23:57:05.940" Score="2" ViewCount="100" Body="&lt;p&gt;I am working on a scheduler for a manufacturing plant. I have currently set it up so the decision variables are set up as binary variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{m,p,s}$&lt;/span&gt; = 1 if machine &lt;strong&gt;m&lt;/strong&gt; is running part &lt;strong&gt;p&lt;/strong&gt; on shift &lt;strong&gt;s&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, that is binary and so either the machine produces its maximum parts per shift that shift or none at all. It would be ideal for the scheduler to be able to produce a value in-between 0 and the maximum (for reasons of minimizing unnecessary inventory). I figure there are two ways to do it, and just am not sure which is better without trying both and would like to know if there is a standard way to formulate this.&lt;/p&gt;&#xA;&lt;p&gt;Let&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_{m,p,s}$&lt;/span&gt; - Number of parts to be made on machine &lt;strong&gt;m&lt;/strong&gt; for part &lt;strong&gt;p&lt;/strong&gt; at shift &lt;strong&gt;s&lt;/strong&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$0 \le y_{m,p,s} \le \text{PartsPerShift}_p$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;OPTION 1:&lt;/strong&gt;&lt;br /&gt;&#xA;Set &lt;span class=&quot;math-container&quot;&gt;$y_{m,p,s}$&lt;/span&gt; as a continuous (or integer) variable with constraints based on &lt;span class=&quot;math-container&quot;&gt;$x_{m,p,s}$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_{m,p,s} &amp;amp;\ge 0  \\&#xA;y_{m,p,s} &amp;amp;\le \text{PartsPerShift}_p x_{m,p,s}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;OPTION 2:&lt;/strong&gt;&lt;br /&gt;&#xA;Set &lt;span class=&quot;math-container&quot;&gt;$x_{m,p,s}$&lt;/span&gt; constraints based on &lt;span class=&quot;math-container&quot;&gt;$y_{m,p,s}$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{m,p,s} = 0 &amp;amp;\quad \text{if $y_{m,p,s} = 0$} \\&#xA;x_{m,p,s} = 1 &amp;amp;\quad \text{if $y_{m,p,s} &amp;gt; 0$}    &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As far as I can tell, the benefit of having &lt;span class=&quot;math-container&quot;&gt;$x_{m,p,s}$&lt;/span&gt; as a constraint based on &lt;span class=&quot;math-container&quot;&gt;$y_{m,p,s}$&lt;/span&gt; is that there are fewer decision variables overall (half as many), however this would involve a large rework of the model as it stands.&lt;/p&gt;&#xA;" OwnerUserId="11510" LastEditorUserId="500" LastEditDate="2023-09-10T21:22:10.450" LastActivityDate="2023-09-10T21:22:10.450" Title="Formulation for choosing how many items to manufacture" Tags="|optimization|mixed-integer-programming|modeling|scheduling|indicator-constraints|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10957" PostTypeId="2" ParentId="10956" CreationDate="2023-09-10T00:50:24.793" Score="3" Body="&lt;p&gt;If you need both &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in the model, a third option is to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_{m,p,s} &amp;amp;\ge x_{m,p,s} \\&#xA;y_{m,p,s} &amp;amp;\le \text{PartsPerShift}_p x_{m,p,s}&#xA;\end{align}&lt;/span&gt;&#xA;This modification to option 1 yields the same behavior you described in option 2.  Without this change, option 1 allows &lt;span class=&quot;math-container&quot;&gt;$x_{m,p,s}=1$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$y_{m,p,s}=0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-09-10T00:50:24.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10958" PostTypeId="1" CreationDate="2023-09-10T08:57:45.470" Score="0" ViewCount="110" Body="&lt;p&gt;Which one is the best solver for solving large-sized problems in Linear Programming, CPLEX or Gurobi?&#xA;Which one is faster?&lt;/p&gt;&#xA;" OwnerUserId="9818" LastActivityDate="2023-09-10T14:26:57.747" Title="Linear Programming faster solver: CPLEX or Gurobi?" Tags="|optimization|cplex|gurobi|convex-optimization|global-optimization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10959" PostTypeId="1" AcceptedAnswerId="10960" CreationDate="2023-09-10T11:08:31.727" Score="1" ViewCount="197" Body="&lt;p&gt;We are given three binary indicator variables &lt;span class=&quot;math-container&quot;&gt;$X_{ij}, Y_{jk}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z_{jl}$&lt;/span&gt;. Write linear constraints such that,&lt;/p&gt;&#xA;&lt;p&gt;a) if &lt;span class=&quot;math-container&quot;&gt;$X_{ij}$&lt;/span&gt; is equal to 1, then for that &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$X_{ij} = 1$&lt;/span&gt;, exactly one &lt;span class=&quot;math-container&quot;&gt;$Y_{jk} = 1$&lt;/span&gt;, while if &lt;span class=&quot;math-container&quot;&gt;$X_{ij}$&lt;/span&gt; is equal to 0, then for that &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; all &lt;span class=&quot;math-container&quot;&gt;$\sum_{k} Y_{jk}$&lt;/span&gt; should be 0&lt;/p&gt;&#xA;&lt;p&gt;b) if &lt;span class=&quot;math-container&quot;&gt;$X_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y_{jk}$&lt;/span&gt; is equal to 1, exactly one &lt;span class=&quot;math-container&quot;&gt;$Z_{jl} = 1$&lt;/span&gt;, while &lt;span class=&quot;math-container&quot;&gt;$X_{ij} = 0$&lt;/span&gt; implies &lt;span class=&quot;math-container&quot;&gt;$Y_{jk} = 0$&lt;/span&gt; from the first constraint and also ensure &lt;span class=&quot;math-container&quot;&gt;$\sum_{l} Z_{jl} = 0$&lt;/span&gt; for that &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first constraint can be expressed as &lt;span class=&quot;math-container&quot;&gt;$(1 - X_{ij}) + \sum_{k}{Y_{jk} = 1}, \forall i, j$&lt;/span&gt; derived from the boolean CNF expression&lt;/p&gt;&#xA;&lt;p&gt;The second constraint can be expressed as &lt;span class=&quot;math-container&quot;&gt;$(1 - X_{ij}) (1 - Y_{jk}) + \sum_{l}{Z_{jl} = 1} , \forall i, j, k$&lt;/span&gt;, but is quadratic. How can this be expressed linearly?&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="584" LastEditDate="2023-09-10T12:44:36.837" LastActivityDate="2023-09-10T14:38:21.887" Title="Linearizing if else conditions in ILP" Tags="|linear-programming|integer-programming|constraint|linearization|logical-constraints|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10960" PostTypeId="2" ParentId="10959" CreationDate="2023-09-10T11:28:43.513" Score="2" Body="&lt;p&gt;Your first constraint enforces more than was asked.  When &lt;span class=&quot;math-container&quot;&gt;$X_{ij}=0$&lt;/span&gt;, it forces &lt;span class=&quot;math-container&quot;&gt;$\sum_k Y_{jk}=0$&lt;/span&gt;, hence &lt;span class=&quot;math-container&quot;&gt;$Y_{jk}=0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. To enforce only &lt;span class=&quot;math-container&quot;&gt;$$X_{ij}=1 \implies \sum_k Y_{jk}=1,$$&lt;/span&gt; you can instead impose&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-(1-X_{ij})\le \sum_k Y_{jk} -1 \le M_j(1-X_{ij}).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the second constraint, you can apply the same big-M approach by first introducing &lt;span class=&quot;math-container&quot;&gt;$W_{ijk}$&lt;/span&gt; to represent the product &lt;span class=&quot;math-container&quot;&gt;$X_{ij}Y_{jk}$&lt;/span&gt; and additionally imposing&#xA;&lt;span class=&quot;math-container&quot;&gt;$W_{ijk}\ge X_{ij}+Y_{jk}-1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Now that you have modified the question, it suffices to linearize the product of two binary variables, as shown in &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;How to linearize the product of two binary variables?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-09-10T13:51:09.253" LastActivityDate="2023-09-10T13:51:09.253" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10961" PostTypeId="2" ParentId="10958" CreationDate="2023-09-10T14:26:57.747" Score="1" Body="&lt;p&gt;I think the performance for different solvers depends on your problems structure. Maybe some of specific problems will lead better performance for that solver.&lt;/p&gt;&#xA;&lt;p&gt;In general, in my opinion, both of them not far away.&lt;/p&gt;&#xA;&lt;p&gt;So, if you would like to choose one of them be your solver to solve problem, you can depends on your modelling skills. For example, if you are good at python, I would recommend you choose gurobi, since that have big community discuss some technical issues.&lt;/p&gt;&#xA;" OwnerUserId="12370" LastActivityDate="2023-09-10T14:26:57.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10962" PostTypeId="2" ParentId="10959" CreationDate="2023-09-10T14:38:21.887" Score="2" Body="&lt;p&gt;Besides @RobPratt's answer, the first condition would be (for simplicity I omitted indices &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and continued with only two &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x \implies (y_1 \oplus y_2) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \lnot x \lor (y_1 \oplus y_2) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ y_1 + y_2 + (1-x) \geq 1 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ - y_1 - y_2 - x \geq -2 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ y_1 + y_2 -x \geq 0 \quad (1) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ y_1 + y_2 + x \leq 2 \quad (2) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, by adding indices the constraints would be of the form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{k} y_{jk} - x_{ij} \geq 0 \quad \forall i \in I, j \in J \quad (1) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{k} y_{jk} + x_{ij} \leq 2 \quad \forall i \in I, j \in J \quad (2) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the second, the procedure almost is the same.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-09-10T14:38:21.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10963" PostTypeId="1" CreationDate="2023-09-10T19:15:32.533" Score="0" ViewCount="108" Body="&lt;p&gt;The background is I'm building a toy rent vs. buy mortgage calculator. I am an experienced software engineer but my math skills are 20 years behind me and I admit to being very lost.&lt;/p&gt;&#xA;&lt;p&gt;I've been using pulp, however perhaps I should have used z3 given that it may have a friendlier interface for newbies like me. Any advice welcome.&lt;/p&gt;&#xA;&lt;p&gt;This is a reduced example&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import *&#xA;&#xA;# assumptions, obviously absurd&#xA;thirty_year_fixed_rate = 6.78&#xA;property_price = 1_000_000&#xA;cash_on_hand = 50_000&#xA;monthly_expenses = 5000&#xA;monthly_income = 30_000&#xA;monthly_interest_rate = thirty_year_fixed_rate / (12.0 * 100)&#xA;&#xA;mortgage_payment = LpVariable(&amp;quot;mortgage_payment&amp;quot;, 0, None, LpContinuous)&#xA;pmi_payment = LpVariable(&amp;quot;pmi_payment&amp;quot;, 0, None, LpContinuous)&#xA;mortgaged_amount = LpVariable(&amp;quot;mortgaged_amount&amp;quot;, 0, None, LpContinuous)&#xA;down_payment_amount = LpVariable(&amp;quot;down_payment_amount&amp;quot;, 0, None, LpContinuous)&#xA;debt_to_income = LpVariable(&amp;quot;debt_to_income&amp;quot;, 0, None, LpContinuous)&#xA;loan_to_value = mortgaged_amount * (1.0 / property_price)&#xA;&#xA;prob = LpProblem(name=&amp;quot;minimize_monthlies&amp;quot;, sense=LpMinimize)&#xA;closing_costs = 0.04 * mortgaged_amount&#xA;&#xA;prob += mortgaged_amount == property_price - (down_payment_amount + closing_costs)&#xA;prob += down_payment_amount == cash_on_hand&#xA;mortgage_payment = (&#xA;    mortgaged_amount * monthly_interest_rate * (1 + monthly_interest_rate) ** 360&#xA;) / ((1 + monthly_interest_rate) ** 360 - 1)&#xA;# housing expenses must be kept under 43% DTI to be conforming&#xA;prob += debt_to_income == ((mortgage_payment + monthly_expenses) / monthly_income)&#xA;prob += debt_to_income &amp;lt;= 0.43&#xA;&#xA;&#xA;# these are thresholds for the loan_to_value ratio, below .80&#xA;# there is no payment required, but between each other range the &#xA;# payment percent scales up&#xA;t1, t2, t3, t4, M = 0.8, 0.85, 0.9, 0.95, 1&#xA;&#xA;Z1 = pulp.LpVariable(&amp;quot;Z1&amp;quot;, cat=&amp;quot;Binary&amp;quot;)&#xA;Z2 = pulp.LpVariable(&amp;quot;Z2&amp;quot;, cat=&amp;quot;Binary&amp;quot;)&#xA;Z3 = pulp.LpVariable(&amp;quot;Z3&amp;quot;, cat=&amp;quot;Binary&amp;quot;)&#xA;Z4 = pulp.LpVariable(&amp;quot;Z4&amp;quot;, cat=&amp;quot;Binary&amp;quot;)&#xA;Z5 = pulp.LpVariable(&amp;quot;Z5&amp;quot;, cat=&amp;quot;Binary&amp;quot;)&#xA;&#xA;prob.addConstraint(pulp.lpSum([Z1, Z2, Z3, Z4, Z5]) == 1)&#xA;prob.addConstraint(&#xA;    loan_to_value &amp;lt;= t1 * Z1 + t2 * Z2 + t3 * Z3 + t4 * Z4 + M * Z5 - 1e-6&#xA;)&#xA;prob.addConstraint(t1 * Z2 + t2 * Z3 + t3 * Z4 + t4 * Z5 &amp;lt;= loan_to_value)&#xA;&#xA;# HERE IS THE ISSUE: this is not correct&#xA;# this is just calculating the rate, NOT the payment&#xA;# I need to multiply this times the mortgaged_amount to get the actual payment&#xA;prob.addConstraint(&#xA;    (t1 * Z1 * 0)&#xA;    + (t2 * Z2 * (0.002 / 12))&#xA;    + (t3 * Z3 * (0.003 / 12))&#xA;    + (t4 * Z4 * (0.004 / 12))&#xA;    + (M * Z5 * (0.005 / 12))&#xA;    == pmi_payment&#xA;)&#xA;&#xA;monthly_payment = mortgage_payment + pmi_payment&#xA;&#xA;prob.setObjective(monthly_payment)&#xA;prob.solve()&#xA;for name, var in prob.variablesDict().items():&#xA;    print(name, var.varValue)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note my comment, if I modify this to read:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;prob.addConstraint(&#xA;    mortgaged_amount&#xA;    * (&#xA;        (t1 * Z1 * 0)&#xA;        + (t2 * Z2 * (0.002 / 12))&#xA;        + (t3 * Z3 * (0.003 / 12))&#xA;        + (t4 * Z4 * (0.004 / 12))&#xA;        + (M * Z5 * (0.005 / 12))&#xA;    )&#xA;    == pmi_payment&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'll receive: &lt;code&gt;TypeError: Non-constant expressions cannot be multiplied&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;I believe (again I'm ignorant here) that this would make the expression quadratic in nature since I'd be asking the solver to explore the product of two independent variables (?) and so pulp blows up.&lt;/p&gt;&#xA;&lt;p&gt;How do I go about calculating that amount properly?&lt;/p&gt;&#xA;&lt;p&gt;Note again that this a reduced example of a more complicated problem with lots of interdependencies - many payments change, like interest rate, as a result of loan to value, debt to income, etc. The goal will be to optimize monthly payments by distributing assets which isn't shown here quite yet as it isn't relevant.&lt;/p&gt;&#xA;" OwnerUserId="12425" LastActivityDate="2023-09-11T04:17:49.103" Title="applying a piecewise linearized equation in pulp" Tags="|optimization|linearization|pulp|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10964" PostTypeId="1" CreationDate="2023-09-10T23:27:20.787" Score="0" ViewCount="42" Body="&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In case anyone is interested, this question has been answered &lt;a href=&quot;https://math.stackexchange.com/a/4766980/652310&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Consider the following posynomial with respect to the variables &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;f(x_1,\dots,x_n) &amp;amp;= \sum_{k=1}^K c_k x_1^{a_{1k}} x_2^{a_{2k}} \cdots x_n^{a_{nk}} \\&#xA;&amp;amp;= \sum_{k=1}^K c_k \cdot \prod_{i=1}^n x_i^{a_{ik}}&#xA;\end{align}&lt;/span&gt;&#xA;According to &lt;a href=&quot;https://math.stackexchange.com/a/897393/652310&quot;&gt;this answer&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;if all of the exponents are nonnegative, and &lt;span class=&quot;math-container&quot;&gt;$\sum_i a_{ik}\leq 1$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$k=1,2,\dots,K$&lt;/span&gt;, then this expression is &lt;em&gt;concave&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Translating this statement, if &lt;span class=&quot;math-container&quot;&gt;$a_{ik} \geq 0$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, and if &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{n} a_{ik} \leq 1$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$f(x_1,\dots,x_n)$&lt;/span&gt; is concave with respect to &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n$&lt;/span&gt;. I'm trying to formally prove this statement, but I'm not sure how to complete the proof, so I would appreciate any suggestions on this.&lt;/p&gt;&#xA;&lt;p&gt;We first rewrite &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;f(x_1,\dots,x_n) &amp;amp;= \sum_{k=1}^K c_k \cdot \prod_{i=1}^n x_i^{a_{ik}} \\&#xA;&amp;amp;= \sum_{k=1}^K c_k \cdot \prod_{i=1}^n \exp\left(\log\left(x_i^{a_{ik}}\right)\right) \\&#xA;&amp;amp;= \sum_{k=1}^K c_k \cdot \prod_{i=1}^n \exp\left(a_{ik}\log\left(x_i\right)\right) \\&#xA;&amp;amp;= \sum_{k=1}^K c_k \cdot \exp\left[\sum_{i=1}^n a_{ik}\log\left(x_i\right)\right] \\&#xA;&amp;amp;= \sum_{k=1}^K \exp(\log(c_k)) \cdot \exp\left[\sum_{i=1}^n a_{ik}\log\left(x_i\right)\right] \\&#xA;&amp;amp;= \sum_{k=1}^K \exp\left[\sum_{i=1}^n a_{ik}\log\left(x_i\right) + \log(c_k)\right] \\&#xA;&amp;amp;= \sum_{k=1}^K \exp\left[g_k(x_1,\dots,x_n)\right] \\&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$g_k : \mathbb R^n \to \mathbb R$&lt;/span&gt; is defined as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;g_k(x_1,\dots,x_n) = \sum_{i=1}^n a_{ik}\log\left(x_i\right) + \log(c_k)&#xA;$$&lt;/span&gt;&#xA;To show that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is concave with respect to &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n$&lt;/span&gt;, we proceed as follows. Given that &lt;span class=&quot;math-container&quot;&gt;$a_{ik} \geq 0$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{n} a_{ik} \leq 1$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, we want to show that, for each &lt;span class=&quot;math-container&quot;&gt;$k = 1,\dots,K$&lt;/span&gt; and for every &lt;span class=&quot;math-container&quot;&gt;$t \in [0,1]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n,y_1,\dots,y_n \in \mathbb R$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\exp[g_k(tx_1 + (1-t)y_1,\dots,tx_n + (1-t)y_n)] \geq t\exp[g_k(x_1,\dots,x_n)] + (1-t)\exp[g_k(y_1,\dots,y_n)]&#xA;$$&lt;/span&gt;&#xA;We attempt to do this as follows. Because each &lt;span class=&quot;math-container&quot;&gt;$\log\left(x_i\right)$&lt;/span&gt; term is concave and monotone increasing in &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;, and because &lt;span class=&quot;math-container&quot;&gt;$a_{ik} \geq 0$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, then we can conclude that &lt;span class=&quot;math-container&quot;&gt;$g_k(x_1,\dots,x_n)$&lt;/span&gt; is a concave and monotone increasing function of &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n$&lt;/span&gt;. This means that, for every &lt;span class=&quot;math-container&quot;&gt;$t \in [0,1]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n,y_1,\dots,y_n \in \mathbb R$&lt;/span&gt;,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;g_k(tx_1 + (1-t)y_1,\dots,tx_n + (1-t)y_n) \geq tg_k(x_1,\dots,x_n) + (1-t)g_k(y_1,\dots,y_n)&#xA;$$&lt;/span&gt;&#xA;Because the &lt;span class=&quot;math-container&quot;&gt;$\exp$&lt;/span&gt; function is increasing, then&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\exp[g_k(tx_1 + (1-t)y_1,\dots,tx_n + (1-t)y_n)] \geq \exp[tg_k(x_1,\dots,x_n) + (1-t)g_k(y_1,\dots,y_n)]&#xA;$$&lt;/span&gt;&#xA;I'm not sure how to proceed beyond this point. Using the fact that the &lt;span class=&quot;math-container&quot;&gt;$\exp$&lt;/span&gt; function is convex does not seem to be helpful here, as this only shows that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\exp[tg_k(x_1,\dots,x_n) + (1-t)g_k(y_1,\dots,y_n)] \leq t\exp[g_k(x_1,\dots,x_n)] + (1-t)\exp[g_k(y_1,\dots,y_n)]&#xA;$$&lt;/span&gt;&#xA;I've not made use of the assumption that &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{n} a_{ik} \leq 1$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, so I think this should be used somehow.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2023-09-12T15:38:27.940" LastActivityDate="2023-09-12T15:38:27.940" Title="Is a posynomial concave under the following conditions?" Tags="|convex-optimization|convexity|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10965" PostTypeId="2" ParentId="10963" CreationDate="2023-09-11T04:17:49.103" Score="2" Body="&lt;p&gt;Since it's a product of a continuous (mortgaged amt), say &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and binary &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; you can linearize each of the product terms as below&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ 0 \le x \le Az$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$a + A(z-1) \le x \le a + A(1-z) $&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is continuous var &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is some big number like max mortgaged amt possible.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-09-11T04:17:49.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10966" PostTypeId="2" ParentId="10951" CreationDate="2023-09-11T17:13:14.307" Score="0" Body="&lt;p&gt;After some more research, it seems that as of today there is no way to get the value of a general linear expression that was not previously defined in the model before solving it. I found the same question here &lt;a href=&quot;https://community.ibm.com/community/user/ai-datascience/discussion/extract-the-solution-value-for-expression-in-cp&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://community.ibm.com/community/user/ai-datascience/discussion/extract-the-solution-value-for-expression-in-cp&lt;/a&gt; and apparently the best solution is to add the expression as a pre-defined KPI to the model.&lt;/p&gt;&#xA;" OwnerUserId="12416" LastActivityDate="2023-09-11T17:13:14.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10967" PostTypeId="1" CreationDate="2023-09-11T21:25:29.593" Score="0" ViewCount="67" Body="&lt;p&gt;I have created a data set to understand better an equation and apply it to predict behavior.&lt;/p&gt;&#xA;&lt;p&gt;The equation is y = 10/(1+k*⌊((x/t)^s)⌋).&lt;/p&gt;&#xA;&lt;p&gt;To create the data set and see if it is working properly, I did the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# creating the floor function f(x)&#xA;f = function(x) {&#xA;  10/(1+1.5*(floor((x/2.5)^0.7)))&#xA;}&#xA;&#xA;# specifying the domain of f(x)&#xA;x = seq(0, 100, length.out = 50) # x contains 50 points between 0 and 100&#xA;&#xA;library(ggplot2)&#xA;# creating a data frame that contains x and f(x)&#xA;dat = data.frame(x = x, y = f(x))&#xA;p = ggplot(dat, aes(x = x, y = y)) + &#xA;  geom_step() # geom_step creates a stairs plot&#xA;p&#xA;&#xA;# adding points to the plot&#xA;p + geom_point()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Pxp32.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Pxp32.png&quot; alt=&quot;I got this result, which is what I expect from it&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, I wanted to check a regression analysis over this data set using the following function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#See the regression&#xA;&#xA;# imports library&#xA;library(minpack.lm)&#xA;&#xA;start_values &amp;lt;- c(k=1, s=0.3, t=2)&#xA;fit &amp;lt;- nls(dat&lt;span class=&quot;math-container&quot;&gt;$y ~ 10/(1+k*(floor((dat$&lt;/span&gt;x/t)^s))),&#xA;           data = dat,&#xA;           algorithm = &amp;quot;port&amp;quot;,&#xA;        start = start_values,&#xA;        control = nls.control(maxiter = 1000))&#xA;summary(fit)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I get the following error:&lt;/p&gt;&#xA;&lt;p&gt;Error in nlsModel(formula, mf, start, wts, upper, scaleOffset = scOff,  :&#xA;singular gradient matrix at initial parameter estimates&lt;/p&gt;&#xA;&lt;p&gt;What should I do to avoid it? or which analysis should I perform then? I'm not an expert on stats.&lt;/p&gt;&#xA;&lt;p&gt;Thanks for your help!&lt;/p&gt;&#xA;" OwnerUserId="12431" LastActivityDate="2024-03-06T22:03:40.577" Title="non-linear regression analysis using a floor function over the independent variable?" Tags="|regression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10969" PostTypeId="1" CreationDate="2023-09-12T03:55:59.180" Score="2" ViewCount="130" Body="&lt;p&gt;I have a network where nodes are connected as shown in the Figure &lt;a href=&quot;https://i.stack.imgur.com/aXLe5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aXLe5.png&quot; alt=&quot;Network&quot; /&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Nodes 2 and 4 have a connection to the cloud node. I am writing constraints where at least one node with a connection to the cloud must be selected. Furthermore, a node &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; must also be selected. The objective is to select a minimal number of nodes while addressing the previous two constraints. However, the selected nodes must have a path directly or indirectly. If the node &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is node 2 or node 4, then the solution will be only node 2 or node 4. However, for other nodes, there should be a communication path to nodes 2 or 4. For example, if node &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; represents node 5, then the solution will be nodes 2, 3, and 5.&lt;/p&gt;&#xA;&lt;p&gt;I have written the following constraints. However, I am not able to select the intermediate node(s) which constitute a path. Any help in this regard is appreciated.&lt;/p&gt;&#xA;&lt;p&gt;The objective function is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{i\in N} x_{i}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraints are as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$x_{P} = 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in N} CloudConnection_{i} * x_{i} \ge 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in N, i \ne j} NodeCommunication_{i, j} * x_{i} \ge x_{j} \quad \forall j \in N$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="5419" LastEditorUserId="2556" LastEditDate="2023-09-12T08:25:31.283" LastActivityDate="2023-09-15T15:21:44.567" Title="How to select intermediate nodes in a network?" Tags="|optimization|mixed-integer-programming|linear-programming|modeling|constraint|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10971" PostTypeId="1" CreationDate="2023-09-12T14:48:40.300" Score="2" ViewCount="83" Body="&lt;p&gt;I think this is a problem a lot of people have in minimization but I couldn't find algorithmic approaches to it.&lt;/p&gt;&#xA;&lt;p&gt;Given a closed domain &lt;span class=&quot;math-container&quot;&gt;$D\subset R^n$&lt;/span&gt; over which a function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is supposed to be minimized and a point &lt;span class=&quot;math-container&quot;&gt;$x_0\in R^n$&lt;/span&gt;, how can I find &lt;span class=&quot;math-container&quot;&gt;$x \in D$&lt;/span&gt; which minimizes &lt;span class=&quot;math-container&quot;&gt;$||x - x_0||_2$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;The problem is, &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is given rather implicitly through boundary conditions of an optimization problem (linear and nonlinear). I'm trying to find a heuristic in which if I did a &amp;quot;jump outside of my feasible domain&amp;quot;, I'd be able to get right back in. I can try to jump somewhere else of course but I've seen often that empirically my violation is rather small and a &amp;quot;small bump&amp;quot; would bring me a lot closer to my local minimum, so I'd rather do that instead of invalidating the step alltogether.&lt;/p&gt;&#xA;&lt;p&gt;Are there some algorithms that handle this?&lt;/p&gt;&#xA;" OwnerUserId="12436" LastEditorUserId="500" LastEditDate="2023-09-12T17:39:21.510" LastActivityDate="2024-02-10T14:05:25.913" Title="Find projection onto implicitly defined set" Tags="|bounds|local-minimum|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10972" PostTypeId="2" ParentId="10500" CreationDate="2023-09-13T12:57:19.033" Score="1" Body="&lt;p&gt;It depends on the use case. The right tool for the job.&lt;/p&gt;&#xA;&lt;p&gt;Generally speaking, in my experience, for Vehicle Routing Problems and many other use cases, when scaling out, a good metaheuristics solver (such as OptaPlanner/Timefold, but there are others) will always outperform a good MIP solver. Typically MIP solvers go out of memory around 2000 VRP locations in single dataset. Your mileage may vary.&lt;/p&gt;&#xA;&lt;p&gt;If I recall correctly, Google OR Tools wrote a CVRP-specific (non-MIP) solver - with separate API, mostly unrelated to their MIP solver - to deal with this reality.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/TimefoldAI/timefold-quickstarts/tree/stable/use-cases&quot; rel=&quot;nofollow noreferrer&quot;&gt;These OptaPlanner/Timefold use cases&lt;/a&gt; work well with a metaheuristic solver. That's non-complete list, but similarly there is a long list of ideal for MIP solver use cases.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2023-09-13T14:44:53.430" LastActivityDate="2023-09-13T14:44:53.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10973" PostTypeId="2" ParentId="10971" CreationDate="2023-09-13T13:25:19.777" Score="0" Body="&lt;p&gt;I think the problem you are describing is known as constrained optimization or constrained minimization, where you want to minimize a function within a certain domain defined by constraints. In your case, the constraints are given implicitly.&lt;/p&gt;&#xA;&lt;p&gt;There are several approaches to handle constrained optimization problems, and the choice of method depends on the nature of your problem. Here are a few common methods that might be relevant to your situation:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Penalty Function Method&lt;/strong&gt;: You can convert the constrained optimization problem into an unconstrained problem by adding a penalty term to your objective function. This penalty term penalizes violations of the constraints, and you can adjust the penalty parameter to balance between staying within the feasible domain and minimizing the objective function.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Barrier Function Method&lt;/strong&gt;: Similar to the penalty method, you can use barrier functions to transform the constrained problem into an unconstrained one. Barrier functions become very large as you approach the boundary of the feasible region, discouraging the optimization algorithm from moving outside of it.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interior Point Methods&lt;/strong&gt;: These methods work directly within the feasible region by iteratively moving towards the optimum while respecting the constraints. They are particularly useful for problems with both equality and inequality constraints.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Augmented Lagrangian Method&lt;/strong&gt;: This approach combines the ideas of penalty functions and Lagrange multipliers to solve constrained optimization problems. It involves iteratively updating Lagrange multipliers and penalty parameters.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sequential Quadratic Programming (SQP)&lt;/strong&gt;: SQP is an iterative method that approximates the constrained problem by solving a sequence of unconstrained quadratic subproblems, taking into account the constraints at each step.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;And finally, the one I think you have in mind...&lt;/p&gt;&#xA;&lt;ol start=&quot;6&quot;&gt;&#xA;&lt;li&gt;&lt;strong&gt;Genetic Algorithms or Simulated Annealing&lt;/strong&gt;: These are heuristic methods that can explore the feasible region, making occasional &amp;quot;jumps&amp;quot; outside and returning while maintaining a balance between exploration and exploitation.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The choice of method depends on the specific characteristics of your problem and the computational resources available. Some problems may benefit from hybrid approaches that combine multiple techniques. You may need to experiment with different methods to find the one that works best for your particular situation.&lt;/p&gt;&#xA;" OwnerUserId="434" LastActivityDate="2023-09-13T13:25:19.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10974" PostTypeId="1" AcceptedAnswerId="10975" CreationDate="2023-09-13T13:33:17.727" Score="2" ViewCount="81" Body="&lt;p&gt;I am working on an investment optimization problem where I'm trying to maximize returns over a 20-year period with a given total budget. The investment involves an initial capital and annual contributions. While the main goal is to maximize the net profit, I also want to disincentivize investing an overly high initial capital in order to preserve liquidity.&lt;/p&gt;&#xA;&lt;p&gt;Here's the basic setup:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have a total budget of &lt;span class=&quot;math-container&quot;&gt;$B=€50000$&lt;/span&gt; to be allocated over &lt;span class=&quot;math-container&quot;&gt;$T=20$&lt;/span&gt; years.&lt;/li&gt;&#xA;&lt;li&gt;The annual net return rate is fixed at &lt;span class=&quot;math-container&quot;&gt;$R=0,026 \equiv 2,6\%$&lt;/span&gt; (compounded annually).&lt;/li&gt;&#xA;&lt;li&gt;The decision variables are the initial capital (&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;) and the annual contribution (&lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I'm considering introducing a penalty for the initial capital using a penalty factor &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; in the objective function.&lt;/p&gt;&#xA;&lt;p&gt;My initial thought is to use:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$max(A-\lambda P)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; represents the total accumulated amount after 20 years exploiting compound interest, and it is given by the following formula:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A=P(1+R)^{T}+C[\frac{(1+R)^{T} - 1}{R}]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraints of my optimization problem are:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA;P+T\cdot C=B =50000 \\&#xA;P \leq B=50000\\&#xA;C \leq \frac{B}{T} = \frac{50000}{20} = 2500\\&#xA;P\geq0\\&#xA;C\geq0&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is this an effective way to introduce such a penalty?&lt;/li&gt;&#xA;&lt;li&gt;How can I determine the best value for &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; to make this disincentive meaningful without overshadowing the primary objective of maximizing returns?&lt;/li&gt;&#xA;&lt;li&gt;Are there any other common or more effective methods to introduce this kind of disincentive in optimization problems?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="12439" LastEditorUserId="12439" LastEditDate="2023-09-13T13:44:44.233" LastActivityDate="2023-09-13T15:16:54.160" Title="Optimization Problem with a Penalty Factor" Tags="|optimization|linear-programming|penalty-based-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10975" PostTypeId="2" ParentId="10974" CreationDate="2023-09-13T15:16:54.160" Score="3" Body="&lt;p&gt;You have two separate objectives: maximizing terminal value &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and minimizing (or at least reducing) initial investment &lt;span class=&quot;math-container&quot;&gt;$P.$&lt;/span&gt; You might want to search the web using the phrases &amp;quot;bicriterion optimization&amp;quot; or &amp;quot;multiobjective optimization&amp;quot; to find a variety of approaches people use, none of which are definitively the &amp;quot;best&amp;quot; or &amp;quot;most correct&amp;quot; choice.&lt;/p&gt;&#xA;&lt;p&gt;Using a penalty term is definitely one option. As for choosing &lt;span class=&quot;math-container&quot;&gt;$\lambda,$&lt;/span&gt; there is no &amp;quot;best value&amp;quot;. You can try solving the model over a range of values of &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and see what tradeoff most appeals to the decision maker (you or whoever has the final say).&lt;/p&gt;&#xA;&lt;p&gt;Another possibility is to use lexicographic ordering of the objectives, which is a fancy way of saying that you first solve the model to get the maximal &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; with no penalty on &lt;span class=&quot;math-container&quot;&gt;$P,$&lt;/span&gt; then solve a modified version of the model in which you constrain &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; to be at least the optimal value (which of course means equal to it) and minimize &lt;span class=&quot;math-container&quot;&gt;$P,$&lt;/span&gt; looking for the smallest initial investment that yields the optimal return.&lt;/p&gt;&#xA;&lt;p&gt;Yet another possibility is to maximize &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; (again without penalty on &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;), find out what the optimal value of &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is, then add an upper bound less than that on &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and solve again. Repeat this for a variety of progressively lower bounds on &lt;span class=&quot;math-container&quot;&gt;$P,$&lt;/span&gt; then plot the results to get a sense of the relationship between &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and let the decision maker choose their preferred tradeoff.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-09-13T15:16:54.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10977" PostTypeId="1" AcceptedAnswerId="10978" CreationDate="2023-09-13T18:56:05.957" Score="0" ViewCount="36" Body="&lt;p&gt;Hey i have this constraint that i am trying to code in python: &amp;quot;scheduling next shift such its not within X hours of previous shift&amp;quot;&#xA;Given that i have start, end time of each shift and the user and shift dataframes.&lt;/p&gt;&#xA;" OwnerUserId="12443" LastActivityDate="2023-09-14T13:51:49.553" Title="Scheduling next shift such its not within X hours of previous shift" Tags="|constraint|constraint-programming|job-shop-scheduling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10978" PostTypeId="2" ParentId="10977" CreationDate="2023-09-13T20:18:29.167" Score="1" Body="&lt;p&gt;Suppose binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; indicates whether shift &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is scheduled. If shifts &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; conflict, then impose a constraint &lt;span class=&quot;math-container&quot;&gt;$x_i+x_j\le 1$&lt;/span&gt; to prevent scheduling both.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-09-13T20:18:29.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10980" PostTypeId="1" CreationDate="2023-09-14T13:24:32.460" Score="2" ViewCount="53" Body="&lt;p&gt;I'm trying to solve the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;-reliable shortest path problem with correlated time variables (travel time per arc), i.e. the shortest path subject to the constraint that the probability of arriving before a maximum time &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is greater than &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;. I was thinking of modeling all the arc times as a multivariate normal distribution; however I would like to know what are the best practices to do this or literature regarding this subject.&lt;/p&gt;&#xA;" OwnerUserId="12451" LastEditorUserId="500" LastEditDate="2023-09-17T20:05:39.167" LastActivityDate="2023-09-17T20:05:39.167" Title="Shortest path problem with time as a random variable with correlation" Tags="|network-flow|uncertainty|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10981" PostTypeId="1" AcceptedAnswerId="10982" CreationDate="2023-09-14T13:28:07.137" Score="1" ViewCount="82" Body="&lt;p&gt;I am solving a job scheduling problem with three shifts,&lt;br /&gt;&#xA;the duration of all shifts are assumed to be known (and might be equal):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2wUAk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2wUAk.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The tasks can start from any shift&lt;/li&gt;&#xA;&lt;li&gt;We know the duration of each task in minutes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Some examples:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/l02TW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/l02TW.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if it starts from minute &lt;span class=&quot;math-container&quot;&gt;$1\leq start \leq 480$&lt;/span&gt; then it is in shift1&lt;/li&gt;&#xA;&lt;li&gt;if it starts from minute &lt;span class=&quot;math-container&quot;&gt;$481\leq start \leq 960$&lt;/span&gt; then it is in shift2&lt;/li&gt;&#xA;&lt;li&gt;if it starts from minute &lt;span class=&quot;math-container&quot;&gt;$961\leq start \leq 1440$&lt;/span&gt; then it is in shift3&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now the question is how to calculate the duration that falls into each shift depending on the starting minute (variable) and duration (parameter) ?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Input:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Duration of each shift&lt;/li&gt;&#xA;&lt;li&gt;Duration of task&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am looking for the values of &lt;span class=&quot;math-container&quot;&gt;$h_1,h_2,h_3$&lt;/span&gt; in each case&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="500" LastEditDate="2023-09-14T14:16:11.773" LastActivityDate="2023-09-16T07:37:14.143" Title="How to calculate the duration of a task in each shift?" Tags="|optimization|mixed-integer-programming|constraint|constraint-programming|job-shop-scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10982" PostTypeId="2" ParentId="10981" CreationDate="2023-09-14T13:50:51.617" Score="2" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_1, h_2, h_3$&lt;/span&gt; mean the duration time in each period, respectively?&#xA;Output also including the start time variables?&lt;/p&gt;&#xA;&lt;p&gt;Ans:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_1 = (480 - start) * b_1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_2 = duration - h_1 - h_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$h_3 = (finish - 960) * b_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;,where &lt;span class=&quot;math-container&quot;&gt;$b_1 = 1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$start &amp;lt; 480$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$b_3 = 1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$finish &amp;gt; 960$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;PS in your case &lt;span class=&quot;math-container&quot;&gt;$b_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_3$&lt;/span&gt; can be parameter if start time is given, otherwise should be variables. Furthermore, if you would like to apply to more general setting such as: more than 3 periods that would be very complicated to define.&lt;/p&gt;&#xA;" OwnerUserId="12370" LastEditorUserId="12370" LastEditDate="2023-09-16T07:37:14.143" LastActivityDate="2023-09-16T07:37:14.143" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="10983" PostTypeId="2" ParentId="10977" CreationDate="2023-09-14T13:51:49.553" Score="0" Body="&lt;p&gt;if you know if task 2 should be after the task 1 then it is easy&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Start_2 \geq X + End_1$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2023-09-14T13:51:49.553" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10984" PostTypeId="2" ParentId="10969" CreationDate="2023-09-14T14:07:29.720" Score="1" Body="&lt;p&gt;Option 1: Run Dijkstra's algorithm first. Then you will have a grid of positive numbers that you can use for additional constraints. E.g. require a positive number to know that a path is available from not &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. Maybe try to minimize that distance number too.&lt;/p&gt;&#xA;&lt;p&gt;Option 2: Change your model to select all the nodes in the path. Add additional variables representing the selected edges. You can add constraints to those to ensure that any selected node has an input edge selected and an output edge selected. E.g.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;~\sum_i X_{ij}=m_j ~~~~~ j \in 2...n-1 ~~~~\text{(require input if output)}&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;~\sum_j X_{ij}=m_i ~~~~~ i \in 2...n-1 ~~~~\text{(require output if input)}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="7428" LastEditorUserId="7428" LastEditDate="2023-09-15T15:21:44.567" LastActivityDate="2023-09-15T15:21:44.567" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10985" PostTypeId="1" AcceptedAnswerId="10986" CreationDate="2023-09-15T07:19:39.247" Score="1" ViewCount="41" Body="&lt;p&gt;I have problem like below&#xA;Decision variable x1 &amp;gt;= 0&#xA;But it depends on selection variable s1 as binary variable&lt;/p&gt;&#xA;&lt;p&gt;If s1 = 0 then x1= 0 and&#xA;if s1 = 1 then x1&amp;gt;0&lt;/p&gt;&#xA;&lt;p&gt;how I can write this as constraint for mixed integer programming&lt;/p&gt;&#xA;" OwnerUserId="12455" LastEditorUserId="500" LastEditDate="2023-09-15T07:27:51.453" LastActivityDate="2023-09-15T07:27:51.453" Title="if else condition with multiple criteria in MIP" Tags="|optimization|mixed-integer-programming|indicator-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10986" PostTypeId="2" ParentId="10985" CreationDate="2023-09-15T07:27:22.147" Score="5" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; be a small constant positive tolerance, and let &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; be a constant upper bound on &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt;.  Now impose linear constraints &lt;span class=&quot;math-container&quot;&gt;$$\epsilon s_1 \le x_1 \le M s_1.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-09-15T07:27:22.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10987" PostTypeId="1" AcceptedAnswerId="10990" CreationDate="2023-09-15T09:55:06.980" Score="0" ViewCount="99" Body="&lt;p&gt;I am in the process of trying to solve a VRP with synchronization constraints with Benders Decomposition. I am programming in C++ and my approach seems to be really slow for the following reason:&lt;/p&gt;&#xA;&lt;p&gt;My VRP is a MIP with a minimization objective function.&#xA;Thus, my SP is a maximization problem and my MP is a minimization problem.&lt;/p&gt;&#xA;&lt;p&gt;I start the algorithm by initializing the integer variables with 0 as is usual practice, I solve the subproblem, which is optimal in that case but with quite a high obj. value giving me a first upper bound.&lt;/p&gt;&#xA;&lt;p&gt;My program generates an optimality cut and passes on to the MP.&#xA;The MP finds a solution, which is set as the lower bound. It passes on the integer variable values to the SP to go into the second interation.&lt;/p&gt;&#xA;&lt;p&gt;Now this process is obviously repeated until LB = UB.&lt;/p&gt;&#xA;&lt;p&gt;But: Starting from iteration 2, each time the subproblem is unbounded and it stays like this really long. Meaning we never see a feasible MP solution until the optimum is found.&lt;/p&gt;&#xA;&lt;p&gt;The problem is:&lt;/p&gt;&#xA;&lt;p&gt;Right now, I'm just testing with two simple instances. For the first one, it needs 366 iterations to find the optimum. Meaning we generated 1 optimality cut in iteration 1 and then 365 feasibility cuts until we got a feasible MP solution again.&lt;/p&gt;&#xA;&lt;p&gt;In the second example instance, it doesn't even find the optimal solutions. After over 2000 iterations, where apart from iteration 1, it only ever generated feasibility cuts, the programs stops without a solution.&lt;/p&gt;&#xA;&lt;p&gt;Now, these two are instances that are solved within milliseconds in CPLEX standard solver. Even when I set Benders strategy to FULL in CPLEX, they are solved quickly with much less cuts that have to be generated.&lt;/p&gt;&#xA;&lt;p&gt;Do you know why my program could behave like this?&#xA;Is it something that could be wrong in my programming or is this something that happens in Benders normally?&lt;/p&gt;&#xA;" OwnerUserId="12130" LastActivityDate="2023-09-16T13:52:06.430" Title="Is an insanely high number of feasibility cuts normal while solving a VRP with Benders?" Tags="|mixed-integer-programming|vehicle-routing|benders-decomposition|c++|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10988" PostTypeId="1" AcceptedAnswerId="10989" CreationDate="2023-09-15T15:29:24.943" Score="1" ViewCount="70" Body="&lt;p&gt;What is the dual of this primal LP?&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;max~c^Tx&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;s.t.~Ax=0&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;0 \leq x \leq d,~d \in \mathbb{R}_+^n&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2023-09-15T19:47:24.613" Title="how do I find the dual when a variable has an upper bound?" Tags="|linear-programming|duality|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10989" PostTypeId="2" ParentId="10988" CreationDate="2023-09-15T16:03:57.870" Score="1" Body="&lt;p&gt;You can imagine the upper bound for the variable is another constraint.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max: c^Tx$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{s.t.}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Ax = 0$&lt;/span&gt; --&amp;gt; &lt;span class=&quot;math-container&quot;&gt;$π_1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x ≤ d$&lt;/span&gt; --&amp;gt; &lt;span class=&quot;math-container&quot;&gt;$π_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 ≤ x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Therefore, you will obtain the following dual form.&#xA;(Assume &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$m \times n$&lt;/span&gt; matrix)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min: d^Tπ_2 $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\text{s.t.}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$π_1A + π_2 ≥ c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$π_1 \in \mathbb{R}^m$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 ≤ π_2$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="12370" LastEditorUserId="500" LastEditDate="2023-09-15T19:47:24.613" LastActivityDate="2023-09-15T19:47:24.613" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10990" PostTypeId="2" ParentId="10987" CreationDate="2023-09-16T13:52:06.430" Score="3" Body="&lt;p&gt;You usually use Benders decomposition when a large number of variables and linking constraints can somehow be removed without significantly affecting the structure of your problem.&lt;/p&gt;&#xA;&lt;p&gt;In your case, you have a VRP with sync constraints. You remove the sync from the MP (variables and associated constraints), and find yourself solving a regular VRP with no synchronization.&lt;/p&gt;&#xA;&lt;p&gt;Your solver, say at iteration 2, is finding a VRP solution that does not take into account synchronization. Then you find a feasibility cut to cut that solution. The result: you will find another solution that also does not care about synchronization. If the MP includes many solutions that do not respect the synchronization constraints, you may be adding Benders cuts forever. Each time you will be adding a feasibility cut only to find that the solver in the next iteration finds another bad solution.&lt;/p&gt;&#xA;&lt;p&gt;If the cost of synchronization is high, things are even worse. Your solver will be enumerating the cheapest solutions possible. This means that you will potentially enumerate a large number of solutions without synchronization being respected. This is most likely what you are observing.&lt;/p&gt;&#xA;&lt;p&gt;What can you do to mitigate this behavior? There are several techniques available:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use dual stabilization techniques to separate deep cuts, this is cuts that not only cut the current solution but potentially my neighboring solutions as well. Matteo Fischetti has for many years studied ways to achieve this. You could start by looking at this short article &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-010-0365-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/article/10.1007/s10107-010-0365-7&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Integrate in your MP some notions of syncronization. This is, does not remove sychnronization entirely, but add some variables and constraints to make sure that synchronization is &lt;em&gt;roughly&lt;/em&gt; enforced at the MP level. Think of leaving in the MP all the same synchronization constraints but &lt;em&gt;aggregated&lt;/em&gt; in groups. There are several implementations of this idea in the literature but I do not remember any of them by heart at this time (sorry).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Good luck with your research!&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2023-09-16T13:52:06.430" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10991" PostTypeId="1" CreationDate="2023-09-16T16:04:44.330" Score="0" ViewCount="57" Body="&lt;p&gt;I am implementing a Lagarange relaxation with subgradient method to find a lower bound for a minization problem, I tried to find the complicating constraints. I found an upper bound with relatively small amount of time(2-4 minutes) with a gap=0.65%. Howerver, when I tried to increase the size of the problem the algorithm did not perform the same, and I had to tune again the initial parameters, most of the time, the upper bound is worse that the first one or even did not report any improvement. Is this issue usual or something is wrong with the implementation ( I should mention that I relaxed three constraint, two of them constains binary variables, and both did not report lamda i.e lamda=0).&#xA;The problem is formulated in budget uncertainty set, and I am relaxing the robust problem with gamma(set size)=1, is this implementation valid or I have to relax the problem as determinic ie gamma =0.&#xA;The other thing is that I have found on the literature that they compete with solvers in terms of solving large scale problem, in this case do I have to do the to say the algorithm is valid.&lt;/p&gt;&#xA;" OwnerUserId="12255" LastEditorUserId="12255" LastEditDate="2023-09-16T16:17:07.927" LastActivityDate="2023-09-16T16:17:07.927" Title="Lagrange relaxation / subgaradient algorithm Sensivity to input data" Tags="|gurobi|robust-optimization|lagrange-multipliers|lagrangian-relaxation|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10992" PostTypeId="1" AcceptedAnswerId="10993" CreationDate="2023-09-16T16:45:15.600" Score="1" ViewCount="119" Body="&lt;p&gt;I am using Java to call the API of or-tools in IntelliJ IDEA to solve a mixed-integer programming problem. There are some modeling statements such as &lt;code&gt;ModelSolver solver = new ModelSolver(&amp;quot;SCIP&amp;quot;);&lt;/code&gt; and &lt;code&gt;ModelBuilder model = new ModelBuilder();&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Prior to solving, I want to output a readable model file with suffix lp or mps. I tried &lt;code&gt;model.exportToFile(&amp;quot;mip.lp&amp;quot;)&lt;/code&gt; and &lt;code&gt;model.exportToFile(&amp;quot;mip.mps&amp;quot;)&lt;/code&gt;, which can output files normally but in binary form. If I output the file with the suffix txt, it can be opened normally on a mac but with poor readability.&lt;/p&gt;&#xA;&lt;p&gt;In addition, I also tried &lt;code&gt;model.exportToLpString(true);&lt;/code&gt; and &lt;code&gt;model.exportToMpsString(true);&lt;/code&gt; methods, but I could not find the output file in the project path. Is there any way to output a more readable model file to speed up debugging?&lt;/p&gt;&#xA;&lt;p&gt;Additionally, I want to set parameters during the solving process, such as &lt;code&gt;solver.setSolverSpecificParameters(&amp;quot;limits/gap=0.01&amp;quot;);&lt;/code&gt;. Are there any other optional parameters for this input? I could not find the official manual for it.&lt;/p&gt;&#xA;" OwnerUserId="12326" LastActivityDate="2023-09-16T17:02:05.340" Title="Output a readable model file and control the solver parameters in Or-Tools" Tags="|or-tools|parameter|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10993" PostTypeId="2" ParentId="10992" CreationDate="2023-09-16T17:02:05.340" Score="1" Body="&lt;p&gt;&lt;code&gt;ModelBuilder.exportToMpsString()&lt;/code&gt; returns a string as the name suggests.&lt;/p&gt;&#xA;&lt;p&gt;See the &lt;a href=&quot;https://or-tools.github.io/docs/javadoc/com/google/ortools/modelbuilder/ModelBuilder.html#exportToMpsString-boolean-&quot; rel=&quot;nofollow noreferrer&quot;&gt;doc&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Parameters must be parsable by the solver. In your example, refer to the scip manual.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-09-16T17:02:05.340" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10994" PostTypeId="1" CreationDate="2023-09-16T18:34:52.303" Score="1" ViewCount="42" Body="&lt;p&gt;I am doing my thesis and I encounter the following issue last weeks, without solving it yet: I am trying to formulate a Markov Decision Process as an LP formulation, considering 2 items. (In the picture you can see the general formulation for one item). If we consider p1 the probability of item1 to stay in state i and 1-p1 to degrade to state i+1 (the same for p2 which is the probability of item2), how should I formulate the common transition matrix ? (both items degrade)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/z9m8v.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/z9m8v.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12459" LastActivityDate="2023-09-16T18:34:52.303" Title="LP programming of a Markov Decision Model" Tags="|markov-decision-process|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10996" PostTypeId="1" CreationDate="2023-09-16T22:33:56.857" Score="3" ViewCount="53" Body="&lt;p&gt;Consider the problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \begin{aligned}&#xA;    \min_{x}&#xA;    \quad &amp;amp; f(x) + g(x), \\&#xA;    \textrm{s.t.} \quad &amp;amp; x \in  X&#xA;    \end{aligned} \tag{1}&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$X \subset \mathbb R^n$&lt;/span&gt; is a convex set, &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is convex and twice-differentiable over &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is neither convex nor concave, but also twice-differentiable, over &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;. Is there a class of algorithms that aim to efficiently solve this kind of problem?&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2023-09-17T00:21:15.797" LastActivityDate="2023-09-17T00:21:15.797" Title="Are there algorithms for minimizing a sum of convex and non-convex/non-concave functions?" Tags="|convex-optimization|nonconvex-programming|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10997" PostTypeId="1" CreationDate="2023-09-17T13:09:17.230" Score="0" ViewCount="91" Body="&lt;p&gt;I’m working on an optimization problem that arises from maximizing the return obtained from investing in different marketing levers. The return from each lever exhibits diminishing returns, and is modeled using a power function to represent the saturation of investment. The problem can be mathematically described as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \begin{aligned}&#xA;    \max_{x}&#xA;    \quad &amp;amp; \sum_{i=1}^n x_i^p \\&#xA;    \textrm{s.t.} \quad &amp;amp; Ax = b&#xA;    \end{aligned}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a vector with dimension &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is a constant between 0 and 1, representing the power to which each lever's investment is raised.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Ax = b$&lt;/span&gt; are the linear constraints associated with the problem.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Is there a class of algorithms that aim to efficiently solve this kind of problem?&lt;/p&gt;&#xA;" OwnerUserId="12461" LastEditorUserId="500" LastEditDate="2023-09-17T17:30:26.847" LastActivityDate="2023-10-18T00:06:20.923" Title="Algorithms for maximizing the sum of power functions with linear constraints?" Tags="|nonlinear-programming|convex-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10998" PostTypeId="2" ParentId="10980" CreationDate="2023-09-17T19:18:42.610" Score="1" Body="&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: My response is not meant to be an exhaustive list of relevant directions \ publications for the &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;-reliable shortest path problem, but here are a few papers on related problems that can be suggestive of best practices.&lt;/p&gt;&#xA;&lt;p&gt;I believe your constraint on the arrival time is reminiscent of a chance constraint, dealing with correlated random arc duration variables is however challenging. Under such a setting, the most common approach I have seen is to frame the problem as a Sample Approximation problem with Chance constraints, take a look at [&lt;a href=&quot;https://optimization-online.org/wp-content/uploads/2007/09/1779.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;] for reference. Here, random i.i.d samples from the joint distribution of the arc variables are drawn and then the chance constraint is reformulated using the i.i.d samples. This approach gives rise to some nice probabilistic guarantees on the solution quality. You can also perhaps frame your problem through the lens of Distributionally robust optimization as well which similar to Stochastic Approximation draws samples and provides many useful probabilistic guarantees. Unfortunately, I was unable to locate the most relevant publication for you at this time.&lt;/p&gt;&#xA;&lt;p&gt;Apart from work in the OR community, there is some work in the AI scheduling community which may be relevant, see [&lt;a href=&quot;https://www.jair.org/index.php/jair/article/view/10487/25130&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;], [&lt;a href=&quot;https://arxiv.org/pdf/1401.4595.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;3&lt;/a&gt;]. Although the objective in scheduling problems is generally the longest path problem (credits Makespan objective), nevertheless if you are interested in heuristic approaches then the approaches in those papers may give you some ideas. [&lt;a href=&quot;https://www.jair.org/index.php/jair/article/view/10487/25130&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;] &amp;amp; [&lt;a href=&quot;https://arxiv.org/pdf/1401.4595.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;3&lt;/a&gt;] assume that the arc durations are i.i.d random durations. [&lt;a href=&quot;https://www.jair.org/index.php/jair/article/view/10487/25130&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;] assumes those r.v.s are Normally distributed while [&lt;a href=&quot;https://arxiv.org/pdf/1401.4595.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;3&lt;/a&gt;] makes fewer assumptions on each r.v. (just assumes the mean and variance and nothing about the distribution).&lt;/p&gt;&#xA;&lt;p&gt;References&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;James Luedtke and Shabbir Ahmed, &lt;a href=&quot;https://optimization-online.org/wp-content/uploads/2007/09/1779.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;A Sample Approximation Approach for Optimization with Probabilistic Constraints&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Beck and Wilson, &lt;a href=&quot;https://www.jair.org/index.php/jair/article/view/10487/25130&quot; rel=&quot;nofollow noreferrer&quot;&gt;Proactive Algorithms for Job Shop Scheduling with Probabilistic Durations&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Fu, N., Lau, H. C., Varakantham, P., &amp;amp; Xiao, F. (2012). &lt;a href=&quot;https://arxiv.org/pdf/1401.4595.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Robust local search for solving rcpsp/max with durational uncertainty.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="972" LastActivityDate="2023-09-17T19:18:42.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10999" PostTypeId="2" ParentId="10997" CreationDate="2023-09-17T23:06:35.980" Score="1" Body="&lt;p&gt;Sequential least-squares from Scipy is able to &lt;a href=&quot;https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html#scipy.optimize.minimize&quot; rel=&quot;nofollow noreferrer&quot;&gt;express this directly&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Method SLSQP uses Sequential Least SQuares Programming to minimize a function of several variables with any combination of bounds, equality and inequality constraints. The method wraps the SLSQP Optimization subroutine originally implemented by &lt;a href=&quot;https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html#rdd2e1855725e-12&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dieter Kraft&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It will behave the best if you give it the Jacobian analytically, and give it good bounds (unspecified on your question) and a good starting vector. You haven't offered dimensions for &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; so it's unclear whether this is under-, over- or exactly-determined, but in every case a least-squares pre-solve will do its best to find an initial solution:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import numpy as np&#xA;from scipy.optimize import Bounds, LinearConstraint, minimize, check_grad&#xA;&#xA;&#xA;def cost(x: np.ndarray, p: np.ndarray) -&amp;gt; float:&#xA;    return -(x**p).sum()&#xA;&#xA;&#xA;def jacobian(x: np.ndarray, p: np.ndarray) -&amp;gt; np.ndarray:&#xA;    return -p*x**(p - 1)&#xA;&#xA;&#xA;m = 3&#xA;n = 7&#xA;rand = np.random.default_rng(seed=0)&#xA;p = rand.uniform(low=0, high=1, size=n)&#xA;A = rand.uniform(low=0, high=1, size=(m, n))&#xA;b = rand.uniform(low=0, high=1, size=m)&#xA;&#xA;# Set x0 such that it initially satisfies the constraint&#xA;x0, *_ = np.linalg.lstsq(a=A, b=b, rcond=None)&#xA;&#xA;error = check_grad(cost, jacobian, x0, p)&#xA;assert error &amp;lt; 1e-5&#xA;&#xA;result = minimize(&#xA;    fun=cost, jac=jacobian, args=(p,),&#xA;    x0=x0, method='slsqp',&#xA;    bounds=Bounds(lb=0),&#xA;    constraints=LinearConstraint(A=A, lb=b, ub=b),&#xA;)&#xA;assert result.success, result.message&#xA;print(result.x)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11118" LastActivityDate="2023-09-17T23:06:35.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11000" PostTypeId="1" CreationDate="2023-09-18T04:18:52.097" Score="2" ViewCount="63" Body="&lt;p&gt;I am currently working on a storage location assignment problem (SLAP), which involves optimizing the allocation of various items with different dimensions to different storage areas. My model comprises two phases: warehousing, where there is one storage area with a specific number of racks, and manufacturing, which has its storage area and a specific number of racks as well.&lt;/p&gt;&#xA;&lt;p&gt;In this problem, I aim to determine both the number of supplies for each SKU item and the allocation of storage spaces for each item. These allocations need to adhere to the capacity constraints of each storage area while maximizing the production of final products. Each final product or order is a combination of several items.&lt;/p&gt;&#xA;&lt;p&gt;While addressing this problem, I've noticed that there are processes in manufacturing and final products that have sequence and timing considerations (there is a timing/sequence of operations to produce one product). This makes the problem somewhat resemble a flexible flow shop scheduling problem. However, unlike traditional flow shop scheduling, I am not looking to minimize makespan. Instead, I want to focus on the allocation of items to space and the supply of each SKU item based on the entire process of warehousing and manufacturing.&lt;/p&gt;&#xA;&lt;p&gt;Could you please help me identify the specific type of problem or hybrid problem that my model falls under? Additionally, any insights or guidance on how to approach this complex optimization challenge would be very helpful.&lt;/p&gt;&#xA;" OwnerUserId="12424" LastActivityDate="2023-09-18T09:33:09.417" Title="Optimizing Storage Allocation and Supply for Manufacturing with Time Constraints" Tags="|assignment-problem|job-shop-scheduling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11001" PostTypeId="1" AcceptedAnswerId="11002" CreationDate="2023-09-18T04:44:57.350" Score="2" ViewCount="134" Body="&lt;p&gt;When I read a model from a &amp;quot;.mps&amp;quot; file using &amp;quot;read_from_file&amp;quot; in JuMP and print it, I find that many bounds are written in the interval format like &amp;quot;x \in [0, 1]&amp;quot;. I want to change an interval to a lower bound and an upper bound like &amp;quot;x &amp;gt;= 0, x &amp;lt;= 1&amp;quot; but when I use the function &amp;quot;lower_bound&amp;quot;, it tells me &amp;quot;x does not have a lower bound&amp;quot;. Why would this happen? How can I do the transformation?&lt;/p&gt;&#xA;" OwnerUserId="12349" LastEditorUserId="279" LastEditDate="2023-09-18T15:39:11.210" LastActivityDate="2023-09-18T15:39:11.210" Title="How to change the variable bound from an interval to its lower and upper bound in JuMP?" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|jump|lp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11002" PostTypeId="2" ParentId="11001" CreationDate="2023-09-18T06:43:36.460" Score="2" Body="&lt;p&gt;You can use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;julia&amp;gt; using JuMP&#xA;&#xA;julia&amp;gt; function change_interval_to_bounds(model::JuMP.Model)&#xA;           for c_index in all_constraints(model, VariableRef, MOI.Interval{Float64})&#xA;               constraint = constraint_object(c_index)&#xA;               delete(model, c_index)&#xA;               set_lower_bound(constraint.func, constraint.set.lower)&#xA;               set_upper_bound(constraint.func, constraint.set.upper)&#xA;           end&#xA;           return&#xA;       end&#xA;change_interval_to_bounds (generic function with 1 method)&#xA;&#xA;julia&amp;gt; model = Model();&#xA;&#xA;julia&amp;gt; @variable(model, x in MOI.Interval(0.0, 1.0));&#xA;&#xA;julia&amp;gt; print(model)&#xA;Feasibility&#xA;Subject to&#xA; x ∈ [0, 1]&#xA;&#xA;julia&amp;gt; change_interval_to_bounds(model)&#xA;&#xA;julia&amp;gt; print(model)&#xA;Feasibility&#xA;Subject to&#xA; x ≥ 0&#xA; x ≤ 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;We don't have built-in support for this because we assume that models read from file should stay as they are. (And it's only a few lines to implement manually.)&lt;/p&gt;&#xA;&lt;p&gt;When you create a model using &lt;code&gt;@variable(model, l &amp;lt;= x &amp;lt;= u)&lt;/code&gt; we add two separate constraints instead of a single &lt;code&gt;Interval&lt;/code&gt; constraint because people want to change bounds, etc.&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2023-09-18T06:43:36.460" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11003" PostTypeId="1" AcceptedAnswerId="11004" CreationDate="2023-09-18T08:09:51.480" Score="3" ViewCount="230" Body="&lt;p&gt;I am currently working on a formulation for a linear program of a complex problem. At the moment I am facing to formulate the following logical condition:&lt;/p&gt;&#xA;&lt;p&gt;There are two binary variables. Let's name them &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt;, there are existing for &lt;span class=&quot;math-container&quot;&gt;$ \forall t \in T$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; should take the value 1 only if &lt;span class=&quot;math-container&quot;&gt;$\delta^{t-1} = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\delta^t = 0$&lt;/span&gt;. For all other cases, it should be zero.&lt;/p&gt;&#xA;&lt;p&gt;My first approach was the following inequality: &lt;span class=&quot;math-container&quot;&gt;$\delta^t - \delta^{t-1} + \beta^t = 0 \quad \forall t \in T$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;It's working for the described case, but it forbids also the feasible solutions of &lt;span class=&quot;math-container&quot;&gt;$\delta^{t-1} = 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\delta^{t} = 1$&lt;/span&gt;. Also &lt;span class=&quot;math-container&quot;&gt;$\delta^{t-1}=1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\delta^{t}=1$&lt;/span&gt; is feasible. Is there any way of formulating additional or other (inequality) equations to model this?&lt;/p&gt;&#xA;&lt;p&gt;I guess with an additional binary variable I can formulate this but of course, i would like to prevent this.&lt;/p&gt;&#xA;&lt;p&gt;Thanks for your help!&lt;/p&gt;&#xA;" OwnerUserId="12471" LastEditorUserId="500" LastEditDate="2023-09-18T12:19:49.197" LastActivityDate="2023-09-18T12:52:26.360" Title="Formulation of binary constraint with the least binary variables for linear programming" Tags="|mixed-integer-programming|linear-programming|gurobi|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11004" PostTypeId="2" ParentId="11003" CreationDate="2023-09-18T09:18:59.603" Score="3" Body="&lt;p&gt;You want to impose the following two logical constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\delta_{t-1} = 1 \wedge \delta_t = 0 &amp;amp;\implies \beta_t = 1 \tag{1} \\&#xA;\neg (\delta_{t-1} = 1 \wedge \delta_t = 0) &amp;amp;\implies \beta_t = 0 \tag{2}&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the first one, the conjunctive normal form reads&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\delta_{t-1} \wedge \neg \delta_t \implies \beta_t \\&#xA;\neg (\delta_{t-1} \wedge \neg \delta_t ) \vee \beta_t \\&#xA;\neg \delta_{t-1} \vee \delta_t \vee \beta_t&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and thus (1) can be modelled by &lt;span class=&quot;math-container&quot;&gt;$1 - \delta_{t-1} + \delta_t + \beta_t \geq 1$&lt;/span&gt; which is equivalent to &lt;span class=&quot;math-container&quot;&gt;$\delta_t - \delta_{t-1} + \beta_t \geq 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For the second one, the conjunctive normal form reads&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\neg(\delta_{t-1} \wedge \neg \delta_t) \implies \neg \beta_t \\ &#xA;(\delta_{t-1} \wedge \neg \delta_t) \vee \neg \beta_t \\&#xA;(\delta_{t-1} \vee \neg \beta_t ) \wedge (\neg \delta_t \vee \neg \beta_t)&#xA;%&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Hence, you can model (2) by imposing the linear constraints &lt;span class=&quot;math-container&quot;&gt;$\delta_{t-1} + 1 - \beta_t \geq 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1 - \delta_t + 1 - \beta_t \geq 1$&lt;/span&gt; which are equivalent to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\delta_{t-1} - \beta_t &amp;amp;\geq 0, \\&#xA;\beta_t + \delta_t &amp;amp;\leq 1.&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;As @RobPratt mentioned in the comments, we can also derive these constraints by &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;linearizing the product &lt;span class=&quot;math-container&quot;&gt;$\beta_t = \delta_{t-1} \cdot (1- \delta_{t})$&lt;/span&gt;&lt;/a&gt;. To see why, note that (2) is equivalent to the contraposition &lt;span class=&quot;math-container&quot;&gt;$\beta_t = 1 \implies \delta_{t-1} = 1 \wedge \delta_t = 0$&lt;/span&gt; and thus we have&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\delta_{t-1} = 1 \wedge \delta_t = 0 \iff \beta_t = 1.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Obviously, this is equivalent to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\delta_{t-1} = 1 \wedge 1 - \delta_t = 1 \iff \beta_t = 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which yields &lt;span class=&quot;math-container&quot;&gt;$\beta_t = \delta_{t-1} \cdot (1- \delta_{t})$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="3696" LastEditDate="2023-09-18T12:52:26.360" LastActivityDate="2023-09-18T12:52:26.360" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11005" PostTypeId="2" ParentId="11000" CreationDate="2023-09-18T09:33:09.417" Score="3" Body="&lt;p&gt;I guess, as you correctly mentioned, this problem is too complex as actually many of the SCM problems are complex and I doubt one math formulation can handle all of its aspects. Instead, the problem can be decomposed into at least three separated models with some interchanges between them. (please, be aware it is an initial thought and may extend to more than these three models).&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First, a lot-sizing or MRP model to capture the optimum number of orders based on the production needs and supplier capacity.&lt;/li&gt;&#xA;&lt;li&gt;Second, a packing and storing model to determine the best package form and the amount of racks needed to store these packages. In both warehouses and also production lines.&lt;/li&gt;&#xA;&lt;li&gt;Third, a sequencing model to represent how the products should be allocated to resources based on the production routes. (specifically, in the mentioned hybrid flow shop).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Based on the above three mentioned models, you will then decide how to develop either a math model, or heuristics, or hybrid solutions.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-09-18T09:33:09.417" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11006" PostTypeId="1" AcceptedAnswerId="11009" CreationDate="2023-09-18T13:56:45.180" Score="3" ViewCount="83" Body="&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: this question was already posted &lt;a href=&quot;https://math.stackexchange.com/q/4770765/652310&quot;&gt;on Math.SE&lt;/a&gt; but received no answers, so I'm re-posting it here for better reach.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Consider the following posynomial with respect to the variables &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;f(x_1,\dots,x_n) &amp;amp;= \sum_{k=1}^K c_k x_1^{a_{1k}} x_2^{a_{2k}} \cdots x_n^{a_{nk}} \\&#xA;&amp;amp;= \sum_{k=1}^K c_k \cdot \prod_{i=1}^n x_i^{a_{ik}}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Using the change of variables &lt;span class=&quot;math-container&quot;&gt;$\tilde x_i = \log x_i$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$x_i = e^{\tilde x_i}$&lt;/span&gt;, we get the following expression&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;f(\tilde x_1,\dots,\tilde x_n) &amp;amp;= \sum_{k=1}^K c_k \cdot \prod_{i=1}^n e^{\tilde x_i a_{ik}} \\&#xA;&amp;amp;= \sum_{k=1}^K c_k \cdot \exp\left[\sum_{i=1}^n \tilde x_i a_{ik}\right] \\&#xA;&amp;amp;= \sum_{k=1}^K \exp(\log(c_k)) \cdot \exp\left[\sum_{i=1}^n \tilde x_i a_{ik}\right] \\&#xA;&amp;amp;= \sum_{k=1}^K \exp\left[\sum_{i=1}^n \tilde x_i a_{ik} + \log(c_k)\right]&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;This expression is convex with respect to &lt;span class=&quot;math-container&quot;&gt;$\tilde x_1,\dots,\tilde x_n$&lt;/span&gt; (see &lt;a href=&quot;https://inst.eecs.berkeley.edu/%7Eee127/sp21/livebook/def_lse_fcn.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for a proof). &lt;strong&gt;My question is&lt;/strong&gt;: does there exist a similar change of variables such that the resulting expression is &lt;em&gt;concave&lt;/em&gt; (not convex) with respect to &lt;span class=&quot;math-container&quot;&gt;$\tilde x_1,\dots,\tilde x_n$&lt;/span&gt;? That is, does there exist functions &lt;span class=&quot;math-container&quot;&gt;$g_1,\dots,g_n$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$f(\tilde x_1,\dots,\tilde x_n)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\tilde x_i = g_i(x_i)$&lt;/span&gt;, is concave with respect to &lt;span class=&quot;math-container&quot;&gt;$\tilde x_1,\dots,\tilde x_n$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2023-09-18T14:45:41.007" LastActivityDate="2023-09-19T07:48:54.357" Title="Is it possible to make a posynomial concave using a change of variables?" Tags="|convex-optimization|convexity|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11007" PostTypeId="1" AcceptedAnswerId="11010" CreationDate="2023-09-18T21:42:20.833" Score="3" ViewCount="66" Body="&lt;p&gt;Suppose we have a convex optimizatiom program:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min &amp;amp;\quad f_0(x)\\&#xA;s.t. &amp;amp;\quad h_i(x) = 0 &amp;amp;&amp;amp; i=1,\ldots, p\\&#xA;&amp;amp;\quad g_i(x) \leq 0 &amp;amp;&amp;amp; i=1,\ldots, m\\&#xA;&amp;amp;\quad x \in \mathbb{R}^n&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where the objective function &lt;span class=&quot;math-container&quot;&gt;$f_0$&lt;/span&gt; is convex, the functions &lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt; are affine and the functions &lt;span class=&quot;math-container&quot;&gt;$g_i$&lt;/span&gt; are convex.&lt;/p&gt;&#xA;&lt;p&gt;To my understanding, in order to use the ellipsoid method to approximate such program we need (among other things) a starting ellipsoid &lt;span class=&quot;math-container&quot;&gt;$E_0$&lt;/span&gt; that contains the entire feasible region and a constant &lt;span class=&quot;math-container&quot;&gt;$\upsilon &amp;gt;0$&lt;/span&gt; that serves as a lower bound on the volume of the feasible region.&lt;/p&gt;&#xA;&lt;p&gt;I read &lt;a href=&quot;https://file:///C:/Users/user/Desktop/doctorate/leximin%20(06-23)/related%20work/ellipsoid%20and%20linear%20program%20-%20general/The%20Ellipsoid%20Method-%20A%20Survey.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; (&lt;em&gt;The Ellipsoid Method: A Survey&lt;/em&gt; by Bland, Goldfarb and Todd, page 10) that when the program is linear we can simply take &lt;span class=&quot;math-container&quot;&gt;$S(0,2^L)$&lt;/span&gt; as the starting ellipsoid where &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is the ball centered at the origin with radius &lt;span class=&quot;math-container&quot;&gt;$2^L$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; represents the length of the input.&lt;/p&gt;&#xA;&lt;p&gt;Do other cases exist for which it is known how to construct a starting ellipsoid and an appropriate constant &lt;span class=&quot;math-container&quot;&gt;$\upsilon$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Specifically, what are the most general assumptions (rather than linearity) we need to make over the convex functions (&lt;span class=&quot;math-container&quot;&gt;$f_0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_i$&lt;/span&gt;) that will allow us to construct these requirements?&lt;/p&gt;&#xA;" OwnerUserId="9927" LastActivityDate="2023-09-19T09:59:17.097" Title="Finding a starting ellipsoid and a minimum volume to approximate a convex optimization problem" Tags="|optimization|nonlinear-programming|convex-optimization|constraint-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11008" PostTypeId="1" CreationDate="2023-09-19T07:06:26.200" Score="3" ViewCount="189" Body="&lt;p&gt;I am well aware that &lt;em&gt;commercial&lt;/em&gt; solvers CPLEX and GUROBI provide an IIS (irreducible infeasible set) feature. @batwing mentions FICO Xpress in the comment section as well, and @RobPratt mentions SAS.&lt;/p&gt;&#xA;&lt;p&gt;On the side of &lt;em&gt;open source&lt;/em&gt; solvers, I believe CBC does not.&lt;/p&gt;&#xA;&lt;p&gt;Do &lt;strong&gt;SCIP&lt;/strong&gt; and/or &lt;strong&gt;HiGHS&lt;/strong&gt; have the IIS feature ?&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-09-20T07:00:42.940" LastActivityDate="2023-09-20T07:00:42.940" Title="Which solvers provide an IIS feature?" Tags="|constraint|solver|irreducible-infeasible-subset|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11009" PostTypeId="2" ParentId="11006" CreationDate="2023-09-19T07:43:52.247" Score="3" Body="&lt;p&gt;You implicitly assume &lt;span class=&quot;math-container&quot;&gt;$c_k &amp;gt; 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$x_i &amp;gt; 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and I will do the same. Using the change of variables &lt;span class=&quot;math-container&quot;&gt;$\tilde x_i = x_i^M$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$x_i = \tilde x_i^{1/M}$&lt;/span&gt;, for a big constant &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; at least the size of the largest monomial degree, &lt;span class=&quot;math-container&quot;&gt;$\max_k \left(\sum_{i=1}^n \alpha_{ik}\right)$&lt;/span&gt;, we get the following expression&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;f(\tilde x_1,\dots,\tilde x_n) &amp;amp;= \sum_{k=1}^K c_k \cdot \prod_{i=1}^n {\tilde x_i^{a_{ik}/M}}, \\&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;which is a sum of monomials of degree &lt;span class=&quot;math-container&quot;&gt;$p_k = \sum_i \frac{a_{ik}}{M} \leq 1$&lt;/span&gt; known to be concave and representable by a power cone in conic optimization; see &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/powo.html#the-most-general-power-cone&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for homogenous case &lt;span class=&quot;math-container&quot;&gt;$p_k=1$&lt;/span&gt;, and &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/powo.html#non-homogenous-constraints&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for the nonhomogenous case &lt;span class=&quot;math-container&quot;&gt;$p_k&amp;lt;1$&lt;/span&gt;. The expression above is thus concave with respect to &lt;span class=&quot;math-container&quot;&gt;$\tilde x_1,\dots,\tilde x_n$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="198" LastEditDate="2023-09-19T07:48:54.357" LastActivityDate="2023-09-19T07:48:54.357" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11010" PostTypeId="2" ParentId="11007" CreationDate="2023-09-19T09:59:17.097" Score="2" Body="&lt;p&gt;Not all convex optimization problems can be solved  in polynomial time unless P = NP.&lt;/p&gt;&#xA;&lt;p&gt;Copositve Programs are convex optimization problems. Per this &lt;a href=&quot;https://sburer.github.io/papers/033-cpchap.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Copositive Programming chapter by Samuel Burer&lt;/a&gt;, many NP-Complete problems can be formulated as copositive programs. Therefore, unless P = NP, not all convex optimization problems can be solved in polynomial time.&lt;/p&gt;&#xA;&lt;p&gt;Many conic optimization problems can be solved in polynomial time. But there are not known polynomial time algorithms to solve even all conic optimization problems, themselves being a subset of all convex optimization problems - see for instance this &lt;a href=&quot;https://math.stackexchange.com/questions/4400613/is-conic-programs-with-exponential-cone-solvable-in-polynomial-time/4400752#4400752&quot;&gt;Mathematics Stack Exchange answer by Michal Adamaszek&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2023-09-19T09:59:17.097" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11011" PostTypeId="1" CreationDate="2023-09-19T12:03:19.883" Score="2" ViewCount="60" Body="&lt;p&gt;I am working with a system having a massless 2D plane and on that plane there is a rigid object with some mass placed on it. I want to support the plane with wooden sticks such that the system is stable.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GYLop.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GYLop.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can see that the dotted line is the support polygon (convex hull) made by the support ticks.&lt;/p&gt;&#xA;&lt;p&gt;Stability for the system can be defined as the Center of mass (CoM) of the object inside the polygon assuming the object is rigid and there is no inclination on the surface.&lt;/p&gt;&#xA;&lt;p&gt;I want to formulate this problem in a constraint program only using integer values. I am already working on a model and this part is one of the other parts of my model. Hence all my decision variables are integers and as far as I have read, we can formulate polyhedral analysis problems in linear programming.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem to tackle:&lt;/strong&gt;&#xA;&lt;em&gt;Find the position of 2D n-points such that the system remains stable.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;All points are &lt;em&gt;decision variables&lt;/em&gt; of the program and are not passed externally&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Does anyone here happen to know the formulation in constraint program using only integer variables? Any reading materials you would suggest?&lt;/p&gt;&#xA;" OwnerUserId="11243" LastEditorUserId="36" LastEditDate="2023-09-19T13:14:35.957" LastActivityDate="2023-09-19T13:14:35.957" Title="System Stability constraints formulation" Tags="|modeling|constraint-programming|polyhedra|convex-hull|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="11012" PostTypeId="1" AcceptedAnswerId="11013" CreationDate="2023-09-20T09:40:57.390" Score="2" ViewCount="152" Body="&lt;p&gt;I'm working on a nonlinear optimization problem where I have a decision variable representing my product's price (P_m) and a constant representing my competitor's price (P_c). I want to introduce a penalty into my objective function when my price exceeds the competitor's price.&lt;/p&gt;&#xA;&lt;p&gt;My goal is to penalize based on the percentage (I optimize a log(profit) function, hence removing a percentage is intuitive from a decision maker point of view) by which my price exceeds the competitor's, but have no penalty if my price is equal to or less than the competitor's.&#xA;I don't want to solve it via a piecewise linear function as I want to use IPOPT solver. The idea is to similate this behavior&#xA;if &lt;span class=&quot;math-container&quot;&gt;$$Penalty= \lambda* (P_m - P_c)/P_c  \:if \: P_m &amp;gt; P_c \: else \: 0 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to model this penalty in a continuous and differentiable manner suitable for IPOPT?&lt;/p&gt;&#xA;" OwnerUserId="6016" LastActivityDate="2023-09-20T12:26:47.427" Title="How to model a penalty for exceeding a threshold in a nonlinear optimization problem using IPOPT?" Tags="|modeling|nonlinear-programming|ipopt|penalty-based-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11013" PostTypeId="2" ParentId="11012" CreationDate="2023-09-20T10:18:43.830" Score="4" Body="&lt;p&gt;What you want can be expressed mathematically as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{Penalty} = \lambda * \text{max(}(P_m - P_c)/P_c,0)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this problem, &lt;strong&gt;max&lt;/strong&gt; is being used in a convex manner, so can be handled without introducing binary variables. That is fortunate, because IPOPT doesn't support them.&lt;/p&gt;&#xA;&lt;p&gt;So use the epigraph form of &lt;strong&gt;max&lt;/strong&gt;, which can be accomplished by introducing a new variable, &lt;span class=&quot;math-container&quot;&gt;$P_{exceed}$&lt;/span&gt;, and use&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{Penalty} = \lambda * P_{exceed}/P_c$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and add the constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ 0 \le P_{exceed}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$P_m -P_c \le P_{exceed}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This problem will be as smooth (continuously differentiable) as if there were no Penalty term.&lt;/p&gt;&#xA;&lt;p&gt;Some optimization modeling front ends which call IPOPT can do the epigraph formulation for you under the hood, and allow you to specify the model directly using &lt;strong&gt;max&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="500" LastEditDate="2023-09-20T12:26:47.427" LastActivityDate="2023-09-20T12:26:47.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11014" PostTypeId="1" CreationDate="2023-09-20T12:42:31.813" Score="0" ViewCount="98" Body="&lt;p&gt;I try to solve a MILP with Column generation. The Master Problem is a minimization problem with &amp;quot; &lt;span class=&quot;math-container&quot;&gt;$\le$&lt;/span&gt; &amp;quot; constraint which lead to non-positive dual values. The problem is that the subproblem returns just columns with positive reduced cost which seems logical because &lt;span class=&quot;math-container&quot;&gt;$\overline{c_{i j}}=c_{i j}-\pi_{i j}\geq 0$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$c_{i j}=d_{i j} \text{(distance to travel from $i$ to $j$)} \geq 0 \forall(i, j)$&lt;/span&gt;. The question is how could make progress in Column Generation algorithm in this situation.&#xA;(N.B: The objective of the Master Problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{r \in \bar{\omega}} c_r y_r$&lt;/span&gt;, and the objective  of the Subproblem is to minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{(i, j) \in r} \overline{c_{i j}} x_{i j}$&lt;/span&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="5537" LastEditorUserId="500" LastEditDate="2023-09-22T12:49:24.183" LastActivityDate="2023-09-22T12:49:24.183" Title="How should one proceed with column generation when the subproblem generates only columns with positive reduced costs?" Tags="|optimization|mixed-integer-programming|column-generation|local-minimum|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11015" PostTypeId="2" ParentId="10941" CreationDate="2023-09-20T22:13:55.620" Score="2" Body="&lt;p&gt;Just want to add some clarifications to @MarkL.Stone's answer. The function &lt;span class=&quot;math-container&quot;&gt;$$g(x) = \prod_{i=1}^n x_i^{z_i} \cdot (1-x_i)^{1-z_i} \tag{1}$$&lt;/span&gt; is &lt;strong&gt;not&lt;/strong&gt; a monomial in &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n$&lt;/span&gt;. The reason is that, according to section 1.2 in the paper &lt;em&gt;&lt;a href=&quot;https://web.stanford.edu/%7Eboyd/papers/dgp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Disciplined Geometric Programming&lt;/a&gt;&lt;/em&gt; (2019) by A. Agrawal, S. Diamond, and S. Boyd,&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A function is log-log affine if and only if it is a monomial&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;That is (see section 2.1 in the same paper), a function &lt;span class=&quot;math-container&quot;&gt;$f : D \to \mathbb R_+$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathbb R_+$&lt;/span&gt; is the set of positive reals and &lt;span class=&quot;math-container&quot;&gt;$D \subseteq \mathbb R^n_+$&lt;/span&gt;, is a monomial if&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\forall x_1,x_2 \in D, \forall t \in [0,1], f\left(x_1^t \circ x_2^{1-t}\right) = f(x_1)^t \cdot f(x_2)^{1-t}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\circ$&lt;/span&gt; denotes elementwise product and &lt;span class=&quot;math-container&quot;&gt;$x^t = (x_1^t,\dots,x_n^t)$&lt;/span&gt; denotes elementwise exponentiation. In the case of &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, we have&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;g(x_1)^t &amp;amp;= \prod_{i=1}^n x_{1i}^{tz_i} \cdot (1-x_{1i})^{t(1-z_i)} \\&#xA;g(x_2)^{1-t} &amp;amp;= \prod_{i=1}^n x_{2i}^{(1-t)z_i} \cdot (1-x_{2i})^{(1-t)(1-z_i)} \\&#xA;g(x_1)^t \cdot g(x_2)^{1-t} &amp;amp;= \prod_{i=1}^n x_{1i}^{tz_i} \cdot x_{2i}^{(1-t)z_i} \cdot (1-x_{1i})^{t(1-z_i)} \cdot (1-x_{2i})^{(1-t)(1-z_i)} &#xA;\end{align}&lt;/span&gt;&#xA;but&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;g\left(x_1^t \circ x_2^{1-t}\right) &amp;amp;= \prod_{i=1}^n (x_{1i}^t \cdot x_{2i}^{1-t})^{z_i} \cdot (1-(x_{1i}^t \cdot x_{2i}^{1-t}))^{1-z_i} \\&#xA;&amp;amp;= \prod_{i=1}^n x_{1i}^{tz_i} \cdot x_{2i}^{(1-t)z_i} \cdot (1-(x_{1i}^t \cdot x_{2i}^{1-t}))^{1-z_i} \\&#xA;&amp;amp;\neq g(x_1)^t \cdot g(x_2)^{1-t}&#xA;\end{align}&lt;/span&gt;&#xA;&lt;strong&gt;However&lt;/strong&gt;, if we introduce the variable &lt;span class=&quot;math-container&quot;&gt;$y_i = 1 - x_i$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i = 1,\dots,n$&lt;/span&gt; with the equality constraint &lt;span class=&quot;math-container&quot;&gt;$x_i + y_i = 1$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, then the following function is a monomial in &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;h(x,y) = \prod_{i=1}^n x_i^{z_i} \cdot y_i^{1-z_i} \tag{2}&#xA;$$&lt;/span&gt;&#xA;We can check if &lt;span class=&quot;math-container&quot;&gt;$h(x,y)$&lt;/span&gt; is a monomial in &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt; using the same definition above:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;h(x_1,y_1)^t &amp;amp;= \prod_{i=1}^n x_{1i}^{tz_i} \cdot y_{1i}^{t(1-z_i)} \\&#xA;h(x_2,y_2)^{1-t} &amp;amp;= \prod_{i=1}^n x_{2i}^{(1-t)z_i} \cdot y_{2i}^{(1-t)(1-z_i)} \\&#xA;h(x_1,y_1)^t \cdot h(x_2,y_2)^{1-t} &amp;amp;= \prod_{i=1}^n x_{1i}^{tz_i} \cdot x_{2i}^{(1-t)z_i} \cdot y_{1i}^{t(1-z_i)} \cdot y_{2i}^{(1-t)(1-z_i)} &#xA;\end{align}&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;h\left(x_1^t \circ x_2^{1-t},y_1^t \circ y_2^{1-t}\right) &amp;amp;= \prod_{i=1}^n x_{1i}^{tz_i} \cdot x_{2i}^{(1-t)z_i} \cdot y_{1i}^{(1-z_i)t} \cdot y_{2i}^{(1-t)(1-z_i)} \\&#xA;&amp;amp;= h(x_1,y_1)^t \cdot h(x_2,y_2)^{1-t}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="7263" LastActivityDate="2023-09-20T22:13:55.620" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11016" PostTypeId="1" AcceptedAnswerId="11017" CreationDate="2023-09-21T16:43:01.770" Score="1" ViewCount="432" Body="&lt;p&gt;I have three binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}^{m,r}$&lt;/span&gt; , &lt;span class=&quot;math-container&quot;&gt;$y_i^{m,r}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z_i^{m,r}$&lt;/span&gt;. There is another integer variable &lt;span class=&quot;math-container&quot;&gt;$w_i^r$&lt;/span&gt;. And I want to linearize the following logic:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{m} x_{i,j}^{m,r} \ge 1 \implies w_j^r = w_i^r + \sum_{m} y_j^{m,r} - \sum_{m} z_j^{m,r}  &#xA; \qquad \forall r, i, j $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I think to linearize the above I need to introduce another binary. But could we do it without any new variables?&lt;/p&gt;&#xA;" OwnerUserId="11476" LastEditorUserId="11476" LastEditDate="2023-09-21T19:07:08.763" LastActivityDate="2023-09-21T19:12:34.597" Title="Is it possible to do a linearization without introducing new variables?" Tags="|linearization|logical-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11017" PostTypeId="2" ParentId="11016" CreationDate="2023-09-21T17:05:49.440" Score="6" Body="&lt;p&gt;You want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\bigvee_m x_{i,j}^{m,r} \implies w_j^r = w_i^r + \sum_{m} y_j^{m,r} - \sum_{m} z_j^{m,r} \quad \text{for all $r,i,j$}$$&lt;/span&gt;&#xA;Rewriting in conjunctive normal form leads to linear big-M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\left(\lnot \bigvee_m x_{i,j}^{m,r}\right) \lor \left(w_j^r = w_i^r + \sum_{m} y_j^{m,r} - \sum_{m} z_j^{m,r}\right) &amp;amp;&amp;amp;\text{for all $r,i,j$} \\&#xA;\left(\bigwedge_m \lnot x_{i,j}^{m,r}\right) \lor \left(w_j^r = w_i^r + \sum_{m} y_j^{m,r} - \sum_{m} z_j^{m,r}\right) &amp;amp;&amp;amp;\text{for all $r,i,j$} \\&#xA;\bigwedge_{m'} \left(\lnot x_{i,j}^{m',r} \lor w_j^r = w_i^r + \sum_{m} y_j^{m,r} - \sum_{m} z_j^{m,r}\right) &amp;amp;&amp;amp;\text{for all $r,i,j$} \\&#xA;\bigwedge_{m'} \left(x_{i,j}^{m',r} \implies w_j^r = w_i^r + \sum_{m} y_j^{m,r} - \sum_{m} z_j^{m,r}\right) &amp;amp;&amp;amp;\text{for all $r,i,j$} \\&#xA;x_{i,j}^{m',r} \implies w_j^r = w_i^r + \sum_{m} y_j^{m,r} - \sum_{m} z_j^{m,r} &amp;amp;&amp;amp;\text{for all $m',r,i,j$} \\&#xA;-M(1-x_{i,j}^{m',r}) \le w_j^r - w_i^r - \sum_{m} y_j^{m,r} + \sum_{m} z_j^{m,r} \le M(1-x_{i,j}^{m',r}) &amp;amp;&amp;amp;\text{for all $m',r,i,j$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-09-21T19:12:34.597" LastActivityDate="2023-09-21T19:12:34.597" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11018" PostTypeId="1" CreationDate="2023-09-22T09:05:28.527" Score="1" ViewCount="52" Body="&lt;p&gt;Common methods for solving convex programs return solutions that are only approximately-feasible solutions. Here is an example (from lecture notes by Nemirovski on interior-point methods for convex programming). Consider the following convex program:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nKdLC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nKdLC.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Interior point methods return solutions satisfying the following, for any given &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7S2Pl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7S2Pl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;that is: the constraints represented by the functions &lt;span class=&quot;math-container&quot;&gt;$g_j$&lt;/span&gt; are not satisfied exactly - they are satisfied only approximately (up to &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;In some cases, approxiamtely-feasible solutions may be possible. For example, if the constraints represent budget, we may be able to get a slightly larger budget than planned. But sometimes it is impossible. For exmaple, if we look for a probability distribution, then the sum of probabilities must be 1 - we cannot have a distribution with sum of probabilities larger than 1.&lt;/p&gt;&#xA;&lt;p&gt;In all papers that use convex programming, I have never seen any mention of this &amp;quot;approximately-feasible&amp;quot; issue. This is quite puzzling: how can we be sure that a solution, that is only approximately-feasible, is useful in practice?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2023-09-22T09:05:28.527" Title="What is the use of solvers that return approximately-feasible solutions?" Tags="|convex-optimization|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11019" PostTypeId="1" CreationDate="2023-09-22T18:45:33.013" Score="1" ViewCount="61" Body="&lt;p&gt;I'm trying to solve a Multi-Objective Optimization Problem to find the set of Pareto Optimal Solutions. I have a list of decision variables (x1, x2, x3) and a list of objectives (o1, o2, x3). As you can see, one of the variables is both a decision variable and an objective. Is this a good way to formulate this problem or are there more efficient ways to do it? Also, are you aware of any research that look into problems that have a variable as both a decision variable and objective?&lt;/p&gt;&#xA;" OwnerUserId="12504" LastEditorUserId="491" LastEditDate="2023-09-22T18:50:45.537" LastActivityDate="2023-09-22T18:50:45.537" Title="MOO: Variable is both a decision variable and an objective" Tags="|optimization|multi-objective-optimization|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11020" PostTypeId="1" CreationDate="2023-09-23T11:15:22.633" Score="1" ViewCount="88" Body="&lt;p&gt;I'm trying to solve a MIP using Google Or-Tools, but it's showing that the model is &lt;em&gt;&lt;strong&gt;infeasible&lt;/strong&gt;&lt;/em&gt;. I'd like to know if there is a convenient way to analyze which constraint or variable bounds are causing the infeasibility of the model. I want to use the built-in methods of Or-Tools only, without using any third-party packages.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;presolving:&lt;/p&gt;&#xA;&lt;p&gt;presolving (1 rounds: 1 fast, 0 medium, 0 exhaustive):&lt;/p&gt;&#xA;&lt;p&gt;11 deleted vars, 8 deleted constraints, 0 added constraints, 6&#xA;tightened bounds, 0 added holes, 1 changed sides, 0 changed&#xA;coefficients&lt;/p&gt;&#xA;&lt;p&gt;0 implications, 0 cliques&lt;/p&gt;&#xA;&lt;p&gt;presolving detected infeasibility&lt;/p&gt;&#xA;&lt;p&gt;Presolving Time: 0.00&lt;/p&gt;&#xA;&lt;p&gt;SCIP Status        : problem is solved [infeasible]&lt;/p&gt;&#xA;&lt;p&gt;Solving Time (sec) : 0.00&lt;/p&gt;&#xA;&lt;p&gt;Solving Nodes      : 0&lt;/p&gt;&#xA;&lt;p&gt;Primal Bound       : +1.00000000000000e+20 (0 solutions)&lt;/p&gt;&#xA;&lt;p&gt;Dual Bound         : +1.00000000000000e+20&lt;/p&gt;&#xA;&lt;p&gt;Gap                : 0.00 %&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="12326" LastEditorUserId="2556" LastEditDate="2023-09-23T11:37:12.377" LastActivityDate="2023-09-23T11:37:12.377" Title="How to cmpute IIS using the Or-Tools solver?" Tags="|or-tools|irreducible-infeasible-subset|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11021" PostTypeId="1" CreationDate="2023-09-23T15:37:07.430" Score="1" ViewCount="51" Body="&lt;p&gt;There is an allocation problem, while we have to assign logistics routes to multiple candidate carriers.&lt;/p&gt;&#xA;&lt;p&gt;For simplicity, let's assume there are only two routes, &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, with two candidate carriers, &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;. The total number of orders for route &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$N_a$&lt;/span&gt; and for route &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$N_b$&lt;/span&gt;. Carrier &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; provides unit prices &lt;span class=&quot;math-container&quot;&gt;$P_a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_b$&lt;/span&gt; for routes &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; respectively, while carrier &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; provides unit prices &lt;span class=&quot;math-container&quot;&gt;$Q_a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q_b$&lt;/span&gt; for routes &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; respectively. Both carrier &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; also provide stepped pricing types based on the number of orders they undertake (i.e., order quantity step), with two steps assumed for simplicity.&lt;/p&gt;&#xA;&lt;p&gt;For carrier &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;, the discount coefficient for the total freight cost is &lt;span class=&quot;math-container&quot;&gt;$c_1$&lt;/span&gt; when the number of orders is between &lt;span class=&quot;math-container&quot;&gt;$[0, M_1)$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$c_2$&lt;/span&gt; when the number of orders is &lt;span class=&quot;math-container&quot;&gt;$[M_1, inf)$&lt;/span&gt;. The problem is how to allocate the orders for these two routes to the two carriers, &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;, in such a way as to minimize the total cost of the freight.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For example, let's say the total order volumes for routes &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$N_a = 100$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N_b = 200$&lt;/span&gt;, respectively, with unit prices of &lt;span class=&quot;math-container&quot;&gt;$P_a = 2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$P_b = 3$&lt;/span&gt;, and unit prices of &lt;span class=&quot;math-container&quot;&gt;$Q_a = 3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q_b = 2$&lt;/span&gt;. The step details are &lt;span class=&quot;math-container&quot;&gt;$M_1 = 120$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_1 = 0.8$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$c_2 = 0.6$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Assuming that carrier &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is assigned 60 orders for route &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and 80 orders for route &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, while carrier &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is assigned the remaining orders, i.e., 40 orders for &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and 120 orders for &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;, the total cost (without discount) for carrier &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; is calculated as 60 * 2 + 80 * 3 = 360. The total shipment volume is 60 + 80 = 140, which falls in the second step, with a discount factor of 0.6. Therefore, the total freight charge payable to carrier P is 360 * 0.6.&lt;/p&gt;&#xA;&lt;p&gt;Similar calculations can be made for carrier &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;To formulate this problem, let &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; be the set of routes and &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; be the set of carriers. The decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; represents the quantity of orders assigned from route &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to carrier &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The first constraints is &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{j}{x_{ij}} = N_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then we introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$\mu_{kj}$&lt;/span&gt; to indicates whether the total number of orders assigned to carrier &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; follows into the &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;th interval, thus we have &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{k}{\mu_{kj}} = 1,\forall j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then the continuous variable &lt;span class=&quot;math-container&quot;&gt;$\pi_{kj}$&lt;/span&gt; to indicate the actual number of orders in interval &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, thus we have &lt;span class=&quot;math-container&quot;&gt;$M_{k-1,j}\mu_{kj} \leq \pi_{kj} \leq M_{kj} \mu_{kj}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The second constraint is &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i}{x_{ij}} = \sum\limits_{k}{\pi_{kj}},\forall j$&lt;/span&gt;, which represent the number of orders undertake by each carrier &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The total freights of carrier &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i}{p_i x_{ij}}$&lt;/span&gt; multiplied by &lt;span class=&quot;math-container&quot;&gt;$c_{kj}$&lt;/span&gt;, which indicated by &lt;span class=&quot;math-container&quot;&gt;$\mu_{kj}$&lt;/span&gt;, will introduce the nonlinearity.&lt;/p&gt;&#xA;" OwnerUserId="12326" LastEditorUserId="12326" LastEditDate="2023-09-24T03:24:29.190" LastActivityDate="2023-09-24T03:24:29.190" Title="How to linearize stepped pricing in a route assignment problem" Tags="|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11023" PostTypeId="2" ParentId="11021" CreationDate="2023-09-23T16:58:09.997" Score="1" Body="&lt;p&gt;your &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; is continuous and &lt;span class=&quot;math-container&quot;&gt;$u_{k,j}$&lt;/span&gt; is binary in the expression &lt;span class=&quot;math-container&quot;&gt;$ \sum_j p_jx_{i,j}\sum_k c_{j,k}u_{j,k}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$ \sum_j \sum_k p_jc_{j,k}x_{i,j}u_{k,j} $&lt;/span&gt;. So basically if you wish to linearize &lt;span class=&quot;math-container&quot;&gt;$xu$&lt;/span&gt; you can&lt;br /&gt;&#xA;Introduce a continuous variable (of same domain as &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;), say &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and couple of constraint sets&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ 0 \le z_{i,j} \le N_ju_{jk}$&lt;/span&gt;: where &lt;span class=&quot;math-container&quot;&gt;$N_j$&lt;/span&gt; is total order possible for carrier &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; or any other bigger constant &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_{i,j} + N_j(u_{j,k}-1) \le z_{i,j} \le x_{i,j} + N_j(1-u_{j,k})$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-09-23T16:58:09.997" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11024" PostTypeId="1" CreationDate="2023-09-23T18:11:31.363" Score="1" ViewCount="87" Body="&lt;p&gt;I am trying to optimize a cherry picking procedure on 96-well &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Microplate&quot; rel=&quot;nofollow noreferrer&quot;&gt;microplates&lt;/a&gt;. The plates are 12X8 (12 columns, 8 rows). We pass a command file that has many lines like this to a robot:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;source_plate, source_well, destination_plate, destination_well&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The robot has an arm that can cherry pick 8 positions at a time. The 8 source positions can be anywhere on any source plate, but the 8 corresponding destination positions should always be a complete or mostly complete column. This way the robot can dispense material to the destination plates in one action rather than 8 separate actions.&lt;/p&gt;&#xA;&lt;p&gt;For a given run, the robot can hold a maximum of 30 96-well microplates and the loaded command file should contain only source and destination plates that are actually on the robot's deck. Let's assume the following constraints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1500 total raw command lines (i.e. I want to cherry pick 1500 positions)&lt;/li&gt;&#xA;&lt;li&gt;130 source plates&lt;/li&gt;&#xA;&lt;li&gt;30 destination plates&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Given the 30-plate-maximum-per-run constraint, I'm trying to a find way to break those 1500 raw command lines into runs (i.e. command files) such that the number of times plates have to swapped on/off the deck is minimized. The difference between an optimized vs a naive approach could be one day or more of work in this case.&lt;/p&gt;&#xA;&lt;p&gt;I'm struggling to formulate the above scenario in terms of an objective function in which plate swapping events are minimized between runs. Also I'm unsure of the most appropriate method to use (e.g. linear programming, etc.) Any help would be appreciated&lt;/p&gt;&#xA;" OwnerUserId="12513" LastActivityDate="2023-09-23T18:11:31.363" Title="Optimize cherry picking runs" Tags="|optimization|linear-programming|modeling|integer-programming|scheduling|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11025" PostTypeId="1" CreationDate="2023-09-23T19:08:04.560" Score="0" ViewCount="120" Body="&lt;p&gt;In many routing problems, it is fairly common to include a constraint that ensures all vehicles follow an &lt;em&gt;elementary&lt;/em&gt; path, meaning that no vertices are repeated.&lt;/p&gt;&#xA;&lt;p&gt;However, when an elementary path is NOT required, then it is fairly common to include a constraint that ensures there are no &lt;em&gt;subtours&lt;/em&gt; meaning that there are no isolated tours that do not start at, and return to, the specified depot.&lt;/p&gt;&#xA;&lt;p&gt;From my understanding, it would never be necessary to include both of these constraints.  However, in some cases I have seen both of these constraints, for example here: &lt;a href=&quot;https://par.nsf.gov/servlets/purl/10074741&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://par.nsf.gov/servlets/purl/10074741&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8Aqca.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8Aqca.png&quot; alt=&quot;Problem Description&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4J2Zs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4J2Zs.png&quot; alt=&quot;MILP&quot; /&gt;&lt;/a&gt;&#xA;In routing problems, when is it ever necessary to include both 1) subtour elimination constraints, AND 2) elementary paths constraint?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;I've found another resource which highlights my intuition:  In &lt;a href=&quot;https://backend.orbit.dtu.dk/ws/portalfiles/portal/5065984/BK_PhD_thesis_final_060110.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this book&lt;/a&gt; it describes a similar problem, the vehicle routing problem with time windows.  And, in its MILP formulation (shown below), it does not have subtour elimination constraints, and explicitly mentions &lt;em&gt;the classical VRP subtour elimination constraints become redundant&lt;/em&gt;.  Now, I would have expected this to be the same reason why the image &lt;a href=&quot;https://i.stack.imgur.com/4J2Zs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt; would not need the subtour elimination constraints, since in both cases, the direction of traversal is indicated by denoting &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6zDE1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6zDE1.png&quot; alt=&quot;MILP_VRPTW&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/GVb4D.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GVb4D.png&quot; alt=&quot;subtour_redundant&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The difference between these two MILP formulations and problem statements might help me understand what you guys are getting at.  Is the only difference that one of them imposes a unique direction?&lt;/p&gt;&#xA;" OwnerUserId="12208" LastEditorUserId="12208" LastEditDate="2023-09-26T06:58:46.453" LastActivityDate="2023-09-26T06:58:46.453" Title="In routing problems, when is it ever necessary to include both 1) subtour elimination constraints, AND 2) elementary paths constraint?" Tags="|mixed-integer-programming|vehicle-routing|graphs|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="11026" PostTypeId="1" CreationDate="2023-09-24T07:23:30.513" Score="1" ViewCount="55" Body="&lt;p&gt;I am working with a dataset that contains multiple entries for different IDs across various years. Some IDs might have a gap of years between entries. My goal is to solve an optimization problem using CVXPY, where I impose constraints based on the annualized rate of change of a variable associated with each ID across years. When there are gaps between years for a given ID, I aim to consider the rate of change as evenly distributed across the gap years. For instance, if an ID has a 20% increase from the year 2010 to 2012, I calculate the annualized rate of change as &lt;span class=&quot;math-container&quot;&gt;$\sqrt[2012-2010]{\frac{{\text{value2012}}}{\text{value2010}}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, when incorporating this logic into my CVXPY problem, I am encountering a &lt;code&gt;DCPError: &amp;quot;Problem does not follow DCP rules&amp;quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Below is a simplified version of my code that illustrates the issue:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import cvxpy as cp&#xA;&#xA;# Define CVXPY variables&#xA;vars = {&#xA;    &amp;quot;value2010&amp;quot;: cp.Variable(name=&amp;quot;value2010&amp;quot;),&#xA;    &amp;quot;value2012&amp;quot;: cp.Variable(name=&amp;quot;value2012&amp;quot;),&#xA;}&#xA;&#xA;# Initialize constraints list&#xA;constraints = []&#xA;gap_years = 2012 - 2010&#xA;c = cp.Variable(nonneg=True)&#xA;&#xA;# Calculate the annualized deviation and add the constraint&#xA;annualized_deviation = cp.power(vars[&amp;quot;value2012&amp;quot;] / vars[&amp;quot;value2010&amp;quot;], 1/gap_years)&#xA;constraints.append(cp.square(annualized_deviation - 1) &amp;lt;= c)&#xA;&#xA;# Additional constraints/data for value2010/value2012 would be added here&#xA;&#xA;# Define the objective function and solve the problem&#xA;objective = cp.Minimize(c)&#xA;problem = cp.Problem(objective, constraints)&#xA;problem.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I understand that the error arises due to the division of one CVXPY variable by another, as discussed in several posts (&lt;a href=&quot;https://or.stackexchange.com/questions/8455&quot;&gt;1&lt;/a&gt;, &lt;a href=&quot;https://stackoverflow.com/questions/74491368&quot;&gt;2&lt;/a&gt;, &lt;a href=&quot;https://stackoverflow.com/questions/69973713&quot;&gt;3&lt;/a&gt;, &lt;a href=&quot;https://stackoverflow.com/questions/69973713&quot;&gt;4&lt;/a&gt;, &lt;a href=&quot;https://stackoverflow.com/questions/56589885&quot;&gt;5&lt;/a&gt;). I have also read &lt;a href=&quot;https://or.stackexchange.com/a/5041/12516&quot;&gt;this answer&lt;/a&gt; that raises the possibility of variable division under certain conditions by converting the problem to QCP, but I am not entirely sure how to apply this to my specific case.&lt;/p&gt;&#xA;&lt;p&gt;I would appreciate any guidance on how to address this issue, whether through an alternative formulation, clarification of the concepts involved, or any other means to incorporate the annualized rate of change in a optimization problem while handling year gaps.&lt;/p&gt;&#xA;" OwnerUserId="12516" LastActivityDate="2023-09-24T07:23:30.513" Title="Handling Variable Division in CVXPY for Calculating Annualized Rate of Change" Tags="|python|linearization|cvxpy|disciplined-convex-programming|disciplined-quasiconvex-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11028" PostTypeId="1" CreationDate="2023-09-25T06:52:58.670" Score="2" ViewCount="97" Body="&lt;p&gt;For context, I am using the Simio modeling software for an OR class, and for fun I am making a simulation model of the traffic outside my dorm. I have recreated the layout and distance of the streets, and I plan on taking the stats for an hour a day for two weeks on how many cars arrive at what time, how long they wait, etc. Simply put, I'm curious about playing around and seeing various traffic behaviors that arise while modeling.&lt;/p&gt;&#xA;&lt;p&gt;However, it rains often where I am at, say for any given day there's a 10% it will rain (for 12 hours a day) with the following occurrences (given the speed limit for these roads is 20mph):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;50% chance a car will slow down from 1~5mph (randomly) to caution the wet roads&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;50% chance will not slow down and will go the full 20mph&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Ultimately, I want to model the weather and have it change how vehicles operate within the model. I am however quite newbish with Simio and am going above my own scope of what is required for this class, and every resource I try to find online about this doesn't have anything that can answer or assist with this&lt;/p&gt;&#xA;&lt;p&gt;The first thing I investigated was some sort of trigger that would have a 10% chance to activate per day, and have that trigger alter the vehicle's desired speeds, but then I'm unsure how this would handle the case of cars that will go the 20mph regardless, or the cars that have speeds anywhere between 15~20mph (in other words, handle when vehicles are spawned whether or not they will have varying altered speeds and how this would be timed for when it will stop raining in the 12hr mark)&lt;/p&gt;&#xA;" OwnerUserId="10807" LastActivityDate="2024-03-24T04:58:50.380" Title="How does one model weather in Simio and have it change how vehicles operate within the model?" Tags="|software|queuing-theory|simulation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11029" PostTypeId="1" CreationDate="2023-09-25T09:45:29.757" Score="0" ViewCount="80" Body="&lt;p&gt;I'm using the IpSolve package to solve a problem to optimize the assignment (minimum distance) between sellers (rows)and customers (columns) using Rstudio.&lt;/p&gt;&#xA;&lt;p&gt;The problem I faced when using lp/lp.transport  is that I don't know how to introduce different constraints for each row. For example I want to establish that the sellers have between a minimum and a maximum number of customers, but as far as I know, I only can establish one constraint for each row.&lt;/p&gt;&#xA;&lt;p&gt;Do you know how I can solve this ??&lt;/p&gt;&#xA;&lt;p&gt;Do you know another more efficient way of solving this kind of problems when huge data is analyzed?&lt;/p&gt;&#xA;" OwnerUserId="12522" LastEditorUserId="198" LastEditDate="2023-09-27T09:01:57.747" LastActivityDate="2023-09-27T09:01:57.747" Title="different constraints for each row" Tags="|modeling|r|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11030" PostTypeId="1" AcceptedAnswerId="11040" CreationDate="2023-09-25T10:07:40.213" Score="0" ViewCount="34" Body="&lt;p&gt;I am using SDDP.jl for my research and want to know that at the very start of the execution, when there is no value function initialization and terminal state (for backward recursion), how cost-to-go function is initialized?&lt;/p&gt;&#xA;&lt;p&gt;In other words, what cost-to-go function is optimized at the very first forward pass in SDDP.jl implementation.&lt;/p&gt;&#xA;" OwnerUserId="10727" LastEditorUserId="10727" LastEditDate="2023-09-25T13:05:54.103" LastActivityDate="2023-09-25T19:06:19.630" Title="At the start of the execution of SDDP.jl, when there is no value approximation &amp; terminal states available, what cost-to-go estimation is used?" Tags="|julia|stochastic-dual-dynamic-programming|sddp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11031" PostTypeId="1" CreationDate="2023-09-25T15:01:29.413" Score="1" ViewCount="242" Body="&lt;p&gt;I'm currently working on a model that has a large number of variables (around 200k), and I don't know what the proper way to handle such a big problem is.&lt;/p&gt;&#xA;&lt;p&gt;One suggestion I got is to use lazy constraints in order to limit the number of constraints, so that the model can be lighter, but I'm not sure I understand how they should be used.&lt;/p&gt;&#xA;&lt;p&gt;Lazy constraints are constraints that get checked against a solution that satisfies all normal constraints, and in case they get violated, they get added as new constraints.&lt;/p&gt;&#xA;&lt;p&gt;The problem with my model is that it can generate many solutions that have the same score, so I fear that a very large number of solutions would have to be tested against these lazy constraints, which they'd violate, resulting in many iterations of this process, and in each of these iterations many violations would be found (meaning that a very large number of constraints would be added anyway).&lt;/p&gt;&#xA;&lt;p&gt;So, how do I use lazy constraints? Do I set as lazy only the constraints that rarely get violated, while keeping the others as normal? Or should I make a weak model, strenghtening it with lazy constraints?&lt;/p&gt;&#xA;" OwnerUserId="12523" LastActivityDate="2023-09-25T21:52:57.397" Title="How to properly tackle a big model using weak constraints" Tags="|optimization|mixed-integer-programming|modeling|constraint|constraint-programming|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11032" PostTypeId="1" AcceptedAnswerId="11033" CreationDate="2023-09-25T15:21:27.777" Score="-1" ViewCount="103" Body="&lt;p&gt;I want to create mip model which assign workers to entities. In case neighbour entities use same worker, objective should be increased by 1. A goal is to maximize total number of same workers for neighbour entities.&lt;/p&gt;&#xA;&lt;p&gt;Since number of combinations can be large, I prefer integer variable to hold index of assigned worker (allowed only one worker per entity) to an entity. It works for me with usage of big M, boolean variable (assignment of concrete worker) is mapped to an index.&lt;/p&gt;&#xA;&lt;p&gt;I don't how to map equality of indexes for two entities to boolean variable.&lt;/p&gt;&#xA;&lt;p&gt;For example&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;e1.w = 1, e2.w = 1 imply 1&lt;/li&gt;&#xA;&lt;li&gt;e1.w = 2, e2.w = 1 imply 0&lt;/li&gt;&#xA;&lt;li&gt;e1.w = 2, e2.w = 2 imply 1&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Is it possible to model it in mip ? Otherwise I have to for every possible combination of indexes create less or equal equation to trigger equality of workers.&lt;/p&gt;&#xA;" OwnerUserId="4412" LastEditorUserId="4412" LastEditDate="2023-09-25T16:29:14.923" LastActivityDate="2023-09-25T17:58:51.113" Title="mip - mapping of equality to boolean variable" Tags="|mixed-integer-programming|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11033" PostTypeId="2" ParentId="11032" CreationDate="2023-09-25T16:19:11.097" Score="0" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_1 = e1.w$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_2 = e2.w$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a big value, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is binary variable which represent whether is the same worker be assigned into neighbor entities (0 means the same, 1 means different)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$|x_1-x_2| ≤ My$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Above inequality can transfer into the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1 - x_2 ≤ My$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_2 - x_1 ≤ My$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objective function: &lt;span class=&quot;math-container&quot;&gt;$min: y$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In general, the number of binary variables is (the number of entities - 1)&lt;/p&gt;&#xA;" OwnerUserId="12370" LastActivityDate="2023-09-25T16:19:11.097" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11034" PostTypeId="2" ParentId="11032" CreationDate="2023-09-25T16:25:11.380" Score="0" Body="&lt;p&gt;Define a binary variable (like an edge of a graph where &lt;span class=&quot;math-container&quot;&gt;$V=$&lt;/span&gt; set of entities &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;) &lt;span class=&quot;math-container&quot;&gt;$y_{u,v}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$y=1$&lt;/span&gt; if entities &lt;span class=&quot;math-container&quot;&gt;$u,v \in V$&lt;/span&gt; share the same worker from set of workers &lt;span class=&quot;math-container&quot;&gt;$ \{1,2,3....W\}$&lt;/span&gt;, else &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. You can model workers assigned to an entity &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; as integer variable &lt;span class=&quot;math-container&quot;&gt;$w_u$&lt;/span&gt;.&lt;br /&gt;&#xA;Two more additional binary variables are needed &lt;span class=&quot;math-container&quot;&gt;$ y^+, y^-$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;2 set of constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$M(y_{u,v} - 1) - My_{u,v}^- + w_v \le w_u \le w_v + M (1-y_{u,v}) - M y_{u,v}^+$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ y_{u,v} + y_{u,v}^+ + y_{u,v}^- = 1 \ \ \forall u,v \in E$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Obj = &lt;span class=&quot;math-container&quot;&gt;$ \sum_{u,v}y_{u,v}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-09-25T16:25:11.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11035" PostTypeId="1" AcceptedAnswerId="11037" CreationDate="2023-09-25T17:25:50.697" Score="3" ViewCount="311" Body="&lt;p&gt;I try to implement cp model with OR-tools CP-SAT solver. Please, is it possible to name constraints for being able to manage conflict later like for variables:&#xA;&lt;code&gt;t_var[i] = model.NewBoolVar(f&amp;quot;affect_{i}&amp;quot;)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9755" LastActivityDate="2023-09-25T18:36:38.987" Title="OR-Tools CP-SAT solver: is it possible to name a constraint like in GUROBI" Tags="|constraint-programming|or-tools|cp-sat|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11036" PostTypeId="2" ParentId="11032" CreationDate="2023-09-25T17:58:51.113" Score="1" Body="&lt;p&gt;If I understood correctly, you want to enforce&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;e_{1,w} = e_{2,w} \implies b_{w} = 1 \quad \text{for all } w, \tag{1} \\&#xA;e_{1,w} \neq e_{2,w} \implies b_{w} = 0 \quad \text{for all } w. \tag{2}&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that (2) is equivalent to &lt;span class=&quot;math-container&quot;&gt;$b_w = 1 \implies e_{1,w} = e_{2,w}$&lt;/span&gt; and thus you'd like to enforce&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;e_{1,w} = e_{2,w} \iff b_{w} = 1 \quad \text{for all } w. \tag{*}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$0 \leq e_{1,w},e_{2,w} \leq U$&lt;/span&gt;, you can model (*) by introducing two binary variables &lt;span class=&quot;math-container&quot;&gt;$h_{1,w}, h_{2,w}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and imposing the constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;-U \cdot h_{w,1} + h_{w,2} &amp;amp;\leq e_{1,w} - e_{2,w} \leq - h_{w,1} + U \cdot h_{w,2} \qquad &amp;amp;\text{for all } w \\&#xA;h_{w,1} + h_{w,2} + b_w &amp;amp;= 1 &amp;amp;\qquad \text{for all } w.&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2023-09-25T17:58:51.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11037" PostTypeId="2" ParentId="11035" CreationDate="2023-09-25T18:11:22.530" Score="6" Body="&lt;p&gt;Setter:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ct = model.Add(x == 2).WithName(&amp;quot;my_ct&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Getter:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ct_name = ct.Name()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-09-25T18:11:22.530" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11038" PostTypeId="2" ParentId="11035" CreationDate="2023-09-25T18:36:38.987" Score="-1" Body="&lt;pre&gt;&lt;code&gt;C1 = model.addConstrs(&amp;lt;&amp;lt;expr&amp;gt;&amp;gt;, name = 'C1'+str(i))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-09-25T18:36:38.987" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11039" PostTypeId="2" ParentId="11031" CreationDate="2023-09-25T18:54:06.813" Score="0" Body="&lt;p&gt;Please see this link, it is for GUROBI &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360013197972-How-do-I-implement-lazy-constraints-in-Gurobi-&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://support.gurobi.com/hc/en-us/articles/360013197972-How-do-I-implement-lazy-constraints-in-Gurobi-&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9755" LastActivityDate="2023-09-25T18:54:06.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11040" PostTypeId="2" ParentId="11030" CreationDate="2023-09-25T19:06:19.630" Score="2" Body="&lt;p&gt;It is initialized with &lt;code&gt;theta &amp;gt;= lower_bound&lt;/code&gt; or &lt;code&gt;theta &amp;lt;= upper_bound&lt;/code&gt;, where &lt;code&gt;lower_bound&lt;/code&gt; or &lt;code&gt;upper_bound&lt;/code&gt; is passed as the argument to &lt;code&gt;SDDP.PolicyGraph(; lower_bound = 0) do sp, t ... end&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This tutorial explains the algorithm: &lt;a href=&quot;https://sddp.dev/stable/explanation/theory_intro&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://sddp.dev/stable/explanation/theory_intro&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2023-09-25T19:06:19.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11041" PostTypeId="2" ParentId="11031" CreationDate="2023-09-25T21:52:57.397" Score="3" Body="&lt;p&gt;How lazy constraints are handled may depend on the solver, but CPLEX turns off dual reductions in the presence of lazy constraints, which could negatively impact performance. So I would probably limit my lazy constraint pool to constraints I believe are unlikely to be binding in the optimal solution, and then only if it made a meaningful reduction in the total number of constraints.&lt;/p&gt;&#xA;&lt;p&gt;You mentioned your model having many solutions with the same score. If any of that is due to inherent symmetry in the model (basically, permutations of a feasible solution vector also being feasible with the same objective value), you might want to look at adding antisymmetry constraints (or invoking symmetry-breaking by the solver, if the solver provides it) to reduce the likelihood that the same objective value persists after activating bunches of lazy constraints. (It would also help with branch-and-bound performance in general, if you are solving a MIP.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-09-25T21:52:57.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11042" PostTypeId="1" AcceptedAnswerId="11043" CreationDate="2023-09-27T00:54:19.230" Score="0" ViewCount="238" Body="&lt;p&gt;I am reading &lt;a href=&quot;https://arxiv.org/pdf/1910.13045.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;, available for free viewing, which contains an example of job shop scheduling, shown below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nEdf1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nEdf1.png&quot; alt=&quot;part_1&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/dROqr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dROqr.png&quot; alt=&quot;part_2&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The details of the variable definitions, etc., can be found in the paper, but it's a pretty typical job scheduling problem.  The paper solves it by decomposing it into an MILP and a Constraint Programming sub-problem.  The MILP part is supposed to be &amp;quot;easy to solve&amp;quot; in some sense (i.e. polynomial time).&lt;/p&gt;&#xA;&lt;p&gt;What I don't understand is: why is the MILP they have identified is any easier to solve than the original problem?  Is it because constraints (13) and (16) involve more than one binary variable?  To me, constraint (12) seems very difficult to satisfy, but for some reason that is included in the MILP.  Faced with a general MILP, how to identify constraints which are more difficult to satisfy?&lt;/p&gt;&#xA;" OwnerUserId="12372" LastEditorUserId="500" LastEditDate="2023-09-27T02:00:23.127" LastActivityDate="2023-09-27T03:56:17.857" Title="How to identify constraints that make problem not solvable in polynomial time?" Tags="|mixed-integer-programming|integer-programming|benders-decomposition|job-shop-scheduling|integer-variable|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11043" PostTypeId="2" ParentId="11042" CreationDate="2023-09-27T01:31:53.357" Score="3" Body="&lt;p&gt;The motivation is the same as in the Jain and Grossmann reference [59]. After assigning jobs to machines, the problem decomposes into a separate feasibility subproblem for each machine. Jain and Grossmann solve these subproblems by using the CUMULATIVE constraint from CP. The paper you linked instead uses QC for the subproblems.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-09-27T01:31:53.357" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11044" PostTypeId="2" ParentId="11042" CreationDate="2023-09-27T02:03:51.470" Score="3" Body="&lt;p&gt;You can also see that the second part, constraints 13 to 16, contains more variables (IxI), more constraints (IxIxMxM) and a big M formulation (which is not good for MIP resolution). The first part (constraints 10 to 12) is more tractable and seems to be close to a bin-packing problem.&lt;/p&gt;&#xA;" OwnerUserId="9755" LastEditorUserId="500" LastEditDate="2023-09-27T03:56:17.857" LastActivityDate="2023-09-27T03:56:17.857" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11045" PostTypeId="1" AcceptedAnswerId="11047" CreationDate="2023-09-27T07:22:10.780" Score="1" ViewCount="155" Body="&lt;p&gt;As part of a bigger model I have a matrix of variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \geq 0$&lt;/span&gt; and a &amp;quot;selector&amp;quot; set of variables &lt;span class=&quot;math-container&quot;&gt;$y_j \in \{0,1\}, \sum_j y_j = 1$&lt;/span&gt;.&#xA;From &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; I'd like to get the variables of column &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$y_j = 1$&lt;/span&gt;, so it's kind of a matrix lookup: &lt;span class=&quot;math-container&quot;&gt;$x_{.j}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$j = \sum_k k \space y_k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm interested in efficient modelling variants to achieve this. Probably there is not &lt;em&gt;the&lt;/em&gt; best variant, as it largely depends on the other parts of the model, so proposals are welcomed.&lt;/p&gt;&#xA;&lt;p&gt;My approach:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;: columns of &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$y_j = 1$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;  \forall i: c_i = \sum_j x_{ij} \space y_j&#xA;$$&lt;/span&gt;&#xA;As &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \space y_j$&lt;/span&gt; is not linear, I introduce substitute &lt;span class=&quot;math-container&quot;&gt;$z_{ij} \geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; as upper bound on &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; with&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;  0 \leq z_{ij} \leq x_{ij} \\&#xA;  x_{ij} - M (1 - y_j) \leq z_{ij} \leq M \space y_j \\&#xA;$$&lt;/span&gt;&#xA;So &lt;span class=&quot;math-container&quot;&gt;$c_i = \sum_j z_{ij}$&lt;/span&gt; with the constraints from above. It works, but I wonder if it can be improved. What I don't like (beside Big-M) is that I have to introduce additional variables in the size of &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; plus 3 additional constraints per variable - and in the end I only need &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;. The &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; are just &amp;quot;intermediates&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="9644" LastEditorUserId="500" LastEditDate="2023-09-27T15:57:04.617" LastActivityDate="2023-09-27T15:57:04.617" Title="Matrix lookup modelling variants" Tags="|mixed-integer-programming|modeling|linearization|indicator-constraints|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11046" PostTypeId="1" AcceptedAnswerId="11049" CreationDate="2023-09-27T12:36:55.763" Score="2" ViewCount="79" Body="&lt;p&gt;I am working on a scheduling problem in which I have used two different MIP formulations and also based on the time index variable. My problem is in the class &lt;span class=&quot;math-container&quot;&gt;$ P_{j} | \ r_{j}, SDST \ | C_{Max} $&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Without having &lt;span class=&quot;math-container&quot;&gt;$SDST$&lt;/span&gt;, both formulations work well, but it makes an issue when I want to add the related constraints. Actually, the problem is solved, but the resulting schedule does not make sense against the &lt;span class=&quot;math-container&quot;&gt;$SDST$&lt;/span&gt; limitation. The constraint I have used is in the following form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i_{i\neq j}} \sum_{tt=t+p_{j}}^{t+p_{j}-s_{j,i}-1} x_{i,m,tt} \leq M.(1-x_{j,m,t}) \quad \forall j \in J, m \in M, t \in T$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{j,m,t}$&lt;/span&gt; is equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is being assigned on machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; at time slot &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, otherwise &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. I was wondering if, how can I fix my issue w.r.t the mentioned constraint and if there is another efficient way to do that.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-09-28T13:15:46.240" Title="How to define the sequence depending setup time based on a time index formulation" Tags="|mixed-integer-programming|modeling|scheduling|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11047" PostTypeId="2" ParentId="11045" CreationDate="2023-09-27T15:27:35.380" Score="3" Body="&lt;p&gt;You do not really need the &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; variables. You can just add the constraints &lt;span class=&quot;math-container&quot;&gt;$$x_{ij} - M(1-y_j) \le c_i \le x_{ij} + M(1-y_j)\quad \forall j.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-09-27T15:27:35.380" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11048" PostTypeId="2" ParentId="11045" CreationDate="2023-09-27T15:56:41.490" Score="3" Body="&lt;p&gt;If your modeling API supports indicator constraints, you can impose &lt;span class=&quot;math-container&quot;&gt;$$y_j =1 \implies c_i=x_{ij}.$$&lt;/span&gt;&#xA;@prubin’s answer provides the corresponding big-M formulation of this constraint.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-09-27T15:56:41.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11049" PostTypeId="2" ParentId="11046" CreationDate="2023-09-28T12:37:10.130" Score="1" Body="&lt;p&gt;Here is a way to model sequence-dependent setup times for a time-indexed formulation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\forall j, j' \in J, j \neq j' \quad&#xA;\forall m \in M, \quad&#xA;\forall t \in T, \qquad&#xA;x_{j, m, t} + \sum_{t' = t + p_j}^{t + p_j + s_{j, j'} - 1} x_{j', m, t'} \le 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This formulation assumes that the the setup times satisfy the triangular inequality (&lt;span class=&quot;math-container&quot;&gt;$s_{j_1, j_2} + s_{j_2, j_3} \ge s_{j_1, j_3}$&lt;/span&gt;)&lt;/p&gt;&#xA;&lt;p&gt;This formulation has no big-M constraint but may contain a large number of constraints.&lt;/p&gt;&#xA;&lt;p&gt;I'm not fully familiar with MILP formulations for scheduling problems, so I don't know if it's the standard and best way to model this.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2023-09-28T13:15:46.240" LastActivityDate="2023-09-28T13:15:46.240" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11051" PostTypeId="1" CreationDate="2023-09-29T10:48:35.950" Score="1" ViewCount="154" Body="&lt;p&gt;I'm looking at a problem that seems quite like flexible jobshop, but as I understand it jobshop is basically all about finding the order/sequence of tasks (across multiple machines potentially), however as far as I can tell it doesn't consider times. The problem I'm looking at has some jobs that will only be available to start at a specific time (earliest start time) and also may have their own deadlines for completion.&lt;/p&gt;&#xA;&lt;p&gt;I could approach this just by setting constraints on those tasks not starting until t&amp;gt;earliest start time, but it seems like that would be potentially limiting?&lt;/p&gt;&#xA;&lt;p&gt;Can anyone point me to what this may be called if its not a version of jobshop, or if it is jobshop how to best approach the differences?&lt;/p&gt;&#xA;" OwnerUserId="12550" LastEditorUserId="500" LastEditDate="2023-09-29T20:40:33.600" LastActivityDate="2023-09-29T20:40:33.600" Title="Is this classed as a version of jobshop? How should it be approached?" Tags="|scheduling|job-shop-scheduling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11052" PostTypeId="2" ParentId="11051" CreationDate="2023-09-29T11:13:48.280" Score="2" Body="&lt;p&gt;It's definitely a job-shop variant. Usually we use the terms &amp;quot;release time&amp;quot; and &amp;quot;deadline&amp;quot;. See the job characteristics list here: &lt;a href=&quot;https://en.wikipedia.org/wiki/Optimal_job_scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Optimal_job_scheduling&lt;/a&gt; . The triplet notation there will help you search for papers that have similar job shop formulations. Adding the additional constraints is what you need to do; it will further reduce the feasible solution count but that shouldn't slow the (already slow) computation. Be sure to use the indicator constraint functions for the disjunctive constraints.&lt;/p&gt;&#xA;" OwnerUserId="7428" LastEditorUserId="7428" LastEditDate="2023-09-29T11:20:01.667" LastActivityDate="2023-09-29T11:20:01.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11053" PostTypeId="1" AcceptedAnswerId="11055" CreationDate="2023-09-30T01:51:57.370" Score="1" ViewCount="97" Body="&lt;p&gt;Where can I find the fundamentals and the must read articles on metaheuristics? Additionally, what are the current research focal points and areas of interest in this field?&lt;/p&gt;&#xA;&lt;p&gt;I'm dedicated to gaining a comprehensive understanding of the subject and have been exploring resources such as Wikipedia (&lt;a href=&quot;https://en.wikipedia.org/wiki/Metaheuristic#Contributions&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Metaheuristic#Contributions&lt;/a&gt;) and scholarly papers authored by renowned researchers on Google Scholar (&lt;a href=&quot;https://scholar.google.com/citations?hl=en&amp;amp;view_op=search_authors&amp;amp;mauthors=label%3Ametaheuristics&amp;amp;btnG=&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://scholar.google.com/citations?hl=en&amp;amp;view_op=search_authors&amp;amp;mauthors=label%3Ametaheuristics&amp;amp;btnG=&lt;/a&gt;). But I would also like to know from researchers from here.&lt;/p&gt;&#xA;" OwnerUserId="2900" LastActivityDate="2023-09-30T15:45:10.903" Title="Metaheuristics must read articles and new research fields" Tags="|metaheuristics|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11054" PostTypeId="2" ParentId="11053" CreationDate="2023-09-30T05:15:13.527" Score="1" Body="&lt;p&gt;Not research papers, but I think a good place to start is the “Handbook of metaheuristics”: &lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4419-1665-5&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/book/10.1007/978-1-4419-1665-5&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It contains a number of contributed chapters on different metaheuristics.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2023-09-30T05:15:13.527" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11055" PostTypeId="2" ParentId="11053" CreationDate="2023-09-30T15:45:10.903" Score="2" Body="&lt;p&gt;A significant amount of research (maybe too much?) these days goes into &amp;quot;evolutionary&amp;quot; metaheuristics, an area that I think traces back to the creation of genetic algorithms. You can find a list of some of the many, many evolutionary algorithms at the &lt;a href=&quot;https://github.com/fcampelo/EC-Bestiary&quot; rel=&quot;nofollow noreferrer&quot;&gt;Evolutionary Computation Bestiary&lt;/a&gt;. I frequently wonder how many of these algorithms are basically the same thing with different names and differently phrase biological analogs.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-09-30T15:45:10.903" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11056" PostTypeId="1" AcceptedAnswerId="11057" CreationDate="2023-09-30T15:56:22.677" Score="0" ViewCount="44" Body="&lt;p&gt;I want to solve a multi-stage optimization problem using SDDP.jl in which I am having hard time using constraints on state variables at the termination.&lt;/p&gt;&#xA;" OwnerUserId="10727" LastActivityDate="2023-10-01T00:13:52.973" Title="How can I handle a constraint on a terminal state variable while avoiding infeasibility during SDDP.jl training process?" Tags="|julia|stochastic-dual-dynamic-programming|sddp|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11057" PostTypeId="2" ParentId="11056" CreationDate="2023-09-30T21:05:57.237" Score="1" Body="&lt;p&gt;You cannot add a hard constraint to the terminal state variable. The model must have relatively complete recourse, so there must be a feasible solution for any incoming value of the state variable in the last stage.&lt;/p&gt;&#xA;&lt;p&gt;You can instead add a soft constraint that penalizes the violation in the objective.&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2023-09-30T21:05:57.237" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11059" PostTypeId="1" AcceptedAnswerId="11060" CreationDate="2023-10-01T20:40:56.453" Score="1" ViewCount="79" Body="&lt;p&gt;Consider the convex function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;. In section 4.2.1 in &lt;a href=&quot;https://www.stat.cmu.edu/%7Eryantibs/convexopt-F18/scribes/Lecture_4.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;these lecture notes&lt;/a&gt;, the author writes:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;h3&gt;4.2.1 Relaxing non-affine equality constraints&lt;/h3&gt;&#xA;&lt;p&gt;For functions &lt;span class=&quot;math-container&quot;&gt;$g_i(x)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i \in \{1,\dots,d\}$&lt;/span&gt; that are convex but not affine, we relax&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \begin{aligned}&#xA;    \min&#xA;    \quad &amp;amp; f(x), \\&#xA;    \textrm{s.t.} \quad &amp;amp; {\color{blue}{g_i(x) = 0, \ i \in \{1,\dots,d\}}} \\&#xA;                  \quad &amp;amp; Ax = b \\&#xA;                  \quad &amp;amp; h_i(x) \leq 0&#xA;    \end{aligned} \implies_{\!\!\!\text{relax}}&#xA;    \begin{aligned}&#xA;    \min&#xA;    \quad &amp;amp; f(x), \\&#xA;    \textrm{s.t.} \quad &amp;amp; {\color{blue}{g_i(x) \leq 0, \ i \in \{1,\dots,d\}}} \\&#xA;                  \quad &amp;amp; Ax = b \\&#xA;                  \quad &amp;amp; h_i(x) \leq 0&#xA;    \end{aligned}&#xA;\end{equation}&lt;/span&gt;&#xA;as the original formulation is a non-convex problem (non-affine equalities are not convex). The relaxed formulation turns affine equalities into affine &lt;em&gt;inequalities&lt;/em&gt;, so thus has more feasible points and is now convex.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I'm not sure why the author converted the constraint &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$g_i(x) = 0, \ i \in \{1,\dots,d\}$&lt;/span&gt;&amp;quot; to &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$g_i(x) \leq 0, \ i \in \{1,\dots,d\}$&lt;/span&gt;&amp;quot; rather than &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$g_i(x) \geq 0, \ i \in \{1,\dots,d\}$&lt;/span&gt;&amp;quot;, since both kinds of relaxations have the original constraint &lt;span class=&quot;math-container&quot;&gt;$g_i(x) = 0$&lt;/span&gt; as a subset. One reason would be that the constraint &lt;span class=&quot;math-container&quot;&gt;$g_i(x) \leq 0$&lt;/span&gt; is a convex subset of the epigraph of the convex functions &lt;span class=&quot;math-container&quot;&gt;$g_i(x)$&lt;/span&gt;. Therefore, &lt;span class=&quot;math-container&quot;&gt;$g_i(x) \leq 0$&lt;/span&gt; defines a convex set, while &lt;span class=&quot;math-container&quot;&gt;$g_i(x) \geq 0$&lt;/span&gt; may not. However, I'm not sure if this reasoning is correct.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastActivityDate="2023-10-01T23:43:33.457" Title="Relaxing non-affine equality constraints in convex optimization" Tags="|convex-optimization|convexity|relaxation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11060" PostTypeId="2" ParentId="11059" CreationDate="2023-10-01T21:30:13.137" Score="2" Body="&lt;p&gt;Your reasoning is correct.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; is a jointly convex function of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$g(x) \le 0$&lt;/span&gt; is a convex constraint.  However, if, as stated, &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; is not affine, then except for some trivial cases, &lt;span class=&quot;math-container&quot;&gt;$g(x) \ge 0$&lt;/span&gt; is a non-convex constraint.&lt;/p&gt;&#xA;&lt;p&gt;That said, in general there is no particular reason why the relaxation of &lt;span class=&quot;math-container&quot;&gt;$g(x) = 0$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$g(x) \le 0$&lt;/span&gt;  should be any good.  If the solution to the relaxed problem does not satisfy the original constraint, &lt;span class=&quot;math-container&quot;&gt;$g(x) = 0$&lt;/span&gt;, all that will have been accomplished is gaining the knowledge that the optimal objective value of the relaxed problem constitutes a lower bound for the optimal objective value of the original problem.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-10-01T22:40:33.420" LastActivityDate="2023-10-01T22:40:33.420" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11061" PostTypeId="2" ParentId="11059" CreationDate="2023-10-01T21:51:04.447" Score="0" Body="&lt;p&gt;Just want to refine my reasoning: Given a convex function &lt;span class=&quot;math-container&quot;&gt;$f : X \to \mathbb R$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$X \subseteq \mathbb R^n$&lt;/span&gt; is a convex set, all of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;'s sublevel sets, including the set &lt;span class=&quot;math-container&quot;&gt;$\{x \in X \mid f(x) \leq 0\}$&lt;/span&gt;, are convex. This is straightforward to prove: for &lt;span class=&quot;math-container&quot;&gt;$\alpha \in \mathbb R$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$C_\alpha = \{x \in X \mid f(x) \leq \alpha\}$&lt;/span&gt; and fix any &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2 \in C_\alpha$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$f(x_1) \leq \alpha$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f(x_2) \leq \alpha$&lt;/span&gt;, and fix any &lt;span class=&quot;math-container&quot;&gt;$t \in [0,1]$&lt;/span&gt;. Then, because &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is convex, we have&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;f(tx_1 + (1-t)x_2) &amp;amp;\leq tf(x_1) + (1-t)f(x_2) \\&#xA;&amp;amp;\leq t\alpha + (1-t)f(x_2) \\&#xA;&amp;amp;\leq t\alpha + (1-t)\alpha \\&#xA;&amp;amp;= \alpha&#xA;\end{align}&lt;/span&gt;&#xA;and so &lt;span class=&quot;math-container&quot;&gt;$tx_1 + (1-t)x_2 \in C_\alpha$&lt;/span&gt;. See section 3.1.6 in the book &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Convex Optimization&lt;/em&gt;&lt;/a&gt; by Boyd and Vandenberghe for more information.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, if &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a convex but not affine function, and if the sublevel set &lt;span class=&quot;math-container&quot;&gt;$\{x \in X \mid f(x) \leq 0\}$&lt;/span&gt; is not empty, then its complement in &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, which is &lt;span class=&quot;math-container&quot;&gt;$\{x \in X \mid f(x) &amp;gt; 0\}$&lt;/span&gt;, is a non-convex subset of &lt;span class=&quot;math-container&quot;&gt;$\mathbb R^n$&lt;/span&gt; (see &lt;a href=&quot;https://math.stackexchange.com/q/3481411/652310&quot;&gt;here&lt;/a&gt; for a sketch of a proof of this).&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2023-10-01T23:43:33.457" LastActivityDate="2023-10-01T23:43:33.457" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11062" PostTypeId="1" AcceptedAnswerId="11063" CreationDate="2023-10-01T22:10:02.837" Score="2" ViewCount="63" Body="&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,p,s}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{i,j,p,s}$&lt;/span&gt; are binary and &lt;span class=&quot;math-container&quot;&gt;$z_i^s$&lt;/span&gt; is integer; how to enforce:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;((x_{i,j,p,s}=1) \land (z_i^s \ge 5 )) \implies  y_{i,j,p,s}=1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The value of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; in my problem could be 1 to maximum of 10.&lt;/p&gt;&#xA;" OwnerUserId="11802" LastEditorUserId="500" LastEditDate="2023-10-01T22:27:13.377" LastActivityDate="2023-10-02T17:35:05.760" Title="how to linearize if-then when having an operand?" Tags="|linearization|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11063" PostTypeId="2" ParentId="11062" CreationDate="2023-10-01T22:27:01.373" Score="4" Body="&lt;p&gt;First rewrite:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(x_{i,j,p,s}=1 \land z_i^s \ge 5) \implies y_{i,j,p,s}=1 \\&#xA;\lnot (x_{i,j,p,s}=1 \land z_i^s \ge 5) \lor y_{i,j,p,s}=1 \\&#xA;\lnot (x_{i,j,p,s}=1) \lor \lnot (z_i^s \ge 5) \lor y_{i,j,p,s}=1 \\&#xA;x_{i,j,p,s}=0 \lor z_i^s \le 4 \lor y_{i,j,p,s}=1 \\&#xA;x_{i,j,p,s}=0 \lor y_{i,j,p,s}=1 \lor z_i^s \le 4 \\&#xA;(x_{i,j,p,s}=1 \land y_{i,j,p,s}=0) \implies z_i^s \le 4&#xA;$$&lt;/span&gt;&#xA;Now introduce binary (or just nonnegative) variable &lt;span class=&quot;math-container&quot;&gt;$w_{i,j,p,s}$&lt;/span&gt; to represent the product &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,p,s} (1-y_{i,j,p,s})$&lt;/span&gt; and impose&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{i,j,p,s} + (1 - y_{i,j,p,s}) - 1 &amp;amp;\le w_{i,j,p,s} \tag1\label1 \\&#xA;z_i^s - 4 &amp;amp;\le (10-4)(1 - w_{i,j,p,s}) \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(x_{i,j,p,s}=1 \land y_{i,j,p,s}=0) \implies w_{i,j,p,s} = 1,$$&lt;/span&gt;&#xA;and big-M constraint \eqref{2} enforces&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w_{i,j,p,s} = 1 \implies z_i^s \le 4.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Alternatively, you can avoid introducing a new variable.  The convex hull turns out to be&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0 \le x &amp;amp;\le 1 \\&#xA;0 \le y &amp;amp;\le 1 \\&#xA;z &amp;amp;\ge 1 \\&#xA;6x - 6y + z &amp;amp;\le 10&#xA;\end{align}&lt;/span&gt;&#xA;The final constraint arises by replacing &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x-y$&lt;/span&gt; in \eqref{2}.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-10-02T17:35:05.760" LastActivityDate="2023-10-02T17:35:05.760" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11064" PostTypeId="1" CreationDate="2023-10-02T07:06:11.400" Score="1" ViewCount="96" Body="&lt;p&gt;I solving a MILP problem as given below using Python 3.8 and CPLEX 12.20. I want to obtain the number of nodes and nodes left. The details of the codes are as follows:&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;n_xvars=2&#xA;n_yvars=2&lt;/p&gt;&#xA;&lt;p&gt;#Create model:&#xA;my_MILP=Model(name='MILP example')&lt;/p&gt;&#xA;&lt;h1&gt;Defining variables:&lt;/h1&gt;&#xA;&lt;p&gt;x_vars={i+1:my_MILP.continuous_var(name='x_{}'.format(i+1),lb=-20,ub=20) for i in range(n_xvars)}&lt;/p&gt;&#xA;&lt;p&gt;y_vars={i+1:my_MILP.integer_var(name='y_{}'.format(i+1),lb=-20,ub=20) for i in range(n_yvars)}&lt;/p&gt;&#xA;&lt;h1&gt;Adding constraints:&lt;/h1&gt;&#xA;&lt;p&gt;my_MILP.add_constraint(x_vars[1]+4&lt;em&gt;x_vars[2]&amp;gt;=-5)&#xA;my_MILP.add_constraint(x_vars[1]-y_vars[2]&amp;lt;=5)&#xA;my_MILP.add_constraint(x_vars[1]+3&lt;/em&gt;y_vars[1]-10&lt;em&gt;y_vars[2]&amp;lt;=10)&#xA;my_MILP.add_constraint(x_vars[1]+2&lt;/em&gt;x_vars[2]-3&lt;em&gt;y_vars[1]+4&lt;/em&gt;y_vars[2]&amp;lt;=2)&lt;/p&gt;&#xA;&lt;h1&gt;Defining objective function:&lt;/h1&gt;&#xA;&lt;p&gt;obj=x_vars[1]+5&lt;em&gt;x_vars[2]+6&lt;/em&gt;y_vars[1]-2*y_vars[2]&#xA;my_MILP.minimize(obj)&lt;/p&gt;&#xA;&lt;h1&gt;Model information&lt;/h1&gt;&#xA;&lt;p&gt;my_MILP.print_information()&#xA;print(my_MILP.export_as_lp_string())&lt;/p&gt;&#xA;&lt;h1&gt;Solving and solution&lt;/h1&gt;&#xA;&lt;p&gt;my_MILP.solve()&#xA;my_MILP.print_solution()&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I have used a few codes such as&lt;/p&gt;&#xA;&lt;p&gt;nd_count=my_MILP.get_solve_details().nodes_processed&#xA;nd_left=my_MILP.get_solve_details().nodes_left&lt;/p&gt;&#xA;&lt;p&gt;but I am getting errors like&lt;/p&gt;&#xA;&lt;p&gt;AttributeError: 'SolveDetails' object has no attribute 'nodes_left'&#xA;AttributeError: 'SolveDetails' object has no attribute 'nodes_processed'&lt;/p&gt;&#xA;&lt;p&gt;I request the community to please help me obtain the node count and nodes left for MILP, IP, etc.&lt;/p&gt;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="10434" LastActivityDate="2023-10-02T08:03:31.427" Title="How to obtain nodes count and nodes left in docplex (using CPLEX 12.20 and Python 3.8)" Tags="|python|cplex|docplex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11065" PostTypeId="2" ParentId="11064" CreationDate="2023-10-02T08:03:31.427" Score="2" Body="&lt;p&gt;I think what you want can be seen in the CPLEX log as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Tried aggregator 1 time. &#xA;Presolve time =    0.00 sec. (0.00 ticks)&#xA;MIP emphasis: balance optimality and feasibility.&#xA;MIP search method: dynamic search.&#xA;Parallel mode: none, using 1 thread.&#xA;Root relaxation solution time = 0.00 sec (0.00 ticks)&#xA;&#xA;         Nodes                                 Cuts/   &#xA;   Node  Left     Objective  IInf  Best Integer     Best Bound    ItCnt    Gap&#xA;*     0+    0                            0.0000     3261.8212        8     ---&#xA;*     0+    0                         3148.0000     3261.8212        8    3.62%&#xA;      0     0     3254.5370     7     3148.0000       Cuts: 5       14    3.38%&#xA;      0     0     3246.0185     7     3148.0000       Cuts: 3       24    3.11%&#xA;*     0+    0                         3158.0000     3246.0185       24    2.79%&#xA;      0     0     3245.3465     9     3158.0000       Cuts: 5       27    2.77%&#xA;      0     0     3243.4477     9     3158.0000       Cuts: 5       32    2.71%&#xA;      0     0     3242.9809    10     3158.0000     Covers: 3       36    2.69%&#xA;      0     0     3242.8397    11     3158.0000     Covers: 1       37    2.69%&#xA;      0     0     3242.7428    11     3158.0000       Cuts: 3       39    2.68%&#xA;      0     2     3242.7428    11     3158.0000     3242.7428       39    2.68%&#xA;     10    11     3199.1875     2     3158.0000     3215.1261       73    1.81%&#xA;*    20+   11                         3168.0000     3215.1261       89    1.49%&#xA;     20    13     3179.0028     5     3168.0000     3215.1261       89    1.49%&#xA;     30    15     3179.9091     3     3168.0000     3197.5227      113    0.93%&#xA;*    39     3      integral     0     3186.0000     3197.3990      126    0.36%&#xA;     40     3     3193.7500     1     3186.0000     3197.3990      128    0.36% &#xA;&#xA;Cover cuts applied:  9&#xA;Zero-half cuts applied:  2&#xA;Gomory fractional cuts applied:  1&#xA;&#xA;Solution pool: 5 solutions saved. &#xA;MIP-Integer optimal solution:  Objective =   3.1860000000e+03&#xA;Solution time =    0.01 sec.  (0.00 ticks)  Iterations = 131   Nodes = 44&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The first and the second columns most likely are what you are looking for. In the above example, CPLEX found the optimal objective function value of 3.1860000000e+03 after exploring 44 nodes and performing 131 (dual simplex) iterations. Also, as far as I know, the log information can still be invoked through the optimization process via its appropriate callbacks.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-10-02T08:03:31.427" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11066" PostTypeId="1" CreationDate="2023-10-02T09:26:55.870" Score="0" ViewCount="48" Body="&lt;p&gt;I have the same graph coloring problem as in&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/10321/coloring-of-nodes-of-a-sensor-network&quot;&gt;Coloring of nodes of a sensor network&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;@RobPratt and @prubin have proposed some very good solutions.&lt;/p&gt;&#xA;&lt;p&gt;This time I am or interested in distributed coloring schemes considering the large size of the graph. I have around 3000-4000 nodes.&lt;/p&gt;&#xA;&lt;p&gt;The problem remains the same....[copied from @RobPratt's answer]&lt;/p&gt;&#xA;&lt;p&gt;For each edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; be the edge weight. Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{ik}$&lt;/span&gt; indicate whether node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned color &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j} c_{ij} \sum_k x_{ik} x_{jk}$$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$\sum_k x_{ik} = 1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To linearize, for each edge &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$c_{ij}&amp;gt;0$&lt;/span&gt;, introduce binary (or just nonnegative) decision variable &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; to represent &lt;span class=&quot;math-container&quot;&gt;$\sum_k x_{ik} x_{jk}$&lt;/span&gt;, impose additional constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_{ij} \ge x_{ik} + x_{jk} - 1$&lt;/span&gt;, and minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j} c_{ij} y_{ij}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for a fully distributed solution. at any epoch, one node can talk or share info with only its neighbors.&lt;/p&gt;&#xA;&lt;p&gt;The node can take color randomly in the very beginning. Ho do we proceed from there?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2023-10-02T10:15:44.417" LastActivityDate="2023-10-05T12:23:23.170" Title="Distributed coloring of nodes of sensor ntwork" Tags="|mixed-integer-programming|linear-programming|graphs|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="11067" PostTypeId="1" AcceptedAnswerId="11069" CreationDate="2023-10-02T10:06:01.237" Score="1" ViewCount="364" Body="&lt;p&gt;I am working on a problem where I have a &lt;code&gt;set of 2D vertices&lt;/code&gt; and a &lt;code&gt;test point&lt;/code&gt;. I want to chek whether the test point lies inside the polygon formed by the set of given vertices. I am trying to model this problem using &lt;strong&gt;discrete optimization&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Naturally, this lies under &lt;a href=&quot;https://en.wikipedia.org/wiki/Point_in_polygon#:%7E:text=One%20simple%20way%20of%20finding,an%20even%20number%20of%20times.&quot; rel=&quot;nofollow noreferrer&quot;&gt;point-in-polygon&lt;/a&gt; problem and I tried to implement a model for the Ray casting algorithm for my discrete problem. It seems a bit difficult to model and program it as I ran into some division issues.(You can look at &lt;a href=&quot;https://stackoverflow.com/questions/77194708/or-tools-sat-ray-tracing-algorithm-and-toggle-a-boolean&quot;&gt;this post&lt;/a&gt; for the model and the issue). There is a big discussion about the method in &lt;a href=&quot;https://stackoverflow.com/a/2922778/13720573&quot;&gt;this stack-post&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;1. Is there any other way in discrete optimization modeling to check if a test point lies inside the set of vertices?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;2. Does the Ray-casting algorithm fit best when we model it in Integer programming format?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;This problem is kinda of stressing me out. Can anyone suggest me some other method that we can model as a constraint model I am using a constrained programming method &lt;strong&gt;hence strictly integers only&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Any help will be really appreciated :)&lt;/p&gt;&#xA;" OwnerUserId="11243" LastActivityDate="2023-10-02T17:16:19.837" Title="Discrete point inside a polygon formed by set of vertices" Tags="|optimization|modeling|constraint|constraint-programming|polyhedra|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11068" PostTypeId="1" CreationDate="2023-10-02T10:49:10.693" Score="3" ViewCount="119" Body="&lt;p&gt;I am playing around with some Quadratic Programs (QPs), and I want to check if my reasoning is right concerning a re-modeling from QP to MILP. So, let's consider the below QP:&lt;/p&gt;&#xA;&lt;p&gt;(QP) &lt;span class=&quot;math-container&quot;&gt;$\min c^T x + x^T Q x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t. &lt;span class=&quot;math-container&quot;&gt;$Ax = b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$l \leqslant x \leqslant u$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Which lagrangean function would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{L}(x, \pi, \lambda, \beta) = c^T x + x^T Q x + \pi^T (Ax - b) + \lambda^T (l - x) + \beta^T (x - u)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Resulting in the following optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max_{\pi, \lambda \geqslant 0, \beta \geqslant 0} \min_{x} \mathcal{L}(x, \pi, \lambda, \beta)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With the following optimality conditions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\nabla_x \mathcal{L} = c + 2 Q x + A^T \pi - \lambda + \beta = 0$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\nabla_{\pi} \mathcal{L} = Ax - b = 0$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\nabla_{\lambda} \mathcal{L} = l - x \leqslant 0$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\nabla_{\beta} \mathcal{L} = x - u \leqslant 0$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x^T \nabla_{x} \mathcal{L} = 0$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\pi^T \nabla_{\pi} \mathcal{L} = 0$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\lambda^T \nabla_{\lambda} \mathcal{L} = 0$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta^T \nabla_{\beta} \mathcal{L} = 0$&lt;/span&gt;; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\lambda \geqslant 0, \beta \geqslant 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Taking the first optimality condition, we have that:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Q x= - \frac{1}{2} (c + A^T \pi - \lambda + \beta)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And thus, the QP objective function can be translated into:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c^T x + x^T Q x = $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c^T x - \frac{1}{2} x^T (c + A^T \pi - \lambda + \beta) = $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2} x^T (c - A^T \pi + \lambda - \beta) = $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2} (x^T c - x^T (A^T \pi) + x^T \lambda - x^T \beta) = $&lt;/span&gt; (by means of the complementarity/orthogonality conditions 6, 7, and 8)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2} (x^T c - \pi^T b + \lambda^T l - \beta^T u)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Allowing us to propose the following MILP:&lt;/p&gt;&#xA;&lt;p&gt;(MILP) &lt;span class=&quot;math-container&quot;&gt;$\min \frac{1}{2} (x^T c - \pi^T b + \lambda^T l - \beta^T u)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$A x = b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;SOS1&lt;span class=&quot;math-container&quot;&gt;$(l_i - x_i, \lambda_i)$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in {1, \dots, n}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;SOS1&lt;span class=&quot;math-container&quot;&gt;$(x_i - u_i, \beta_i)$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in {1, \dots, n}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$l \leqslant x \leqslant u$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\lambda \geqslant 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\beta \geqslant 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where the SOS1 stands for the operator Special Ordered Set Type 1, which imposes new integer variables, making the problem a MILP. The SOS1 is used for forcing the complementarity conditions by stating that&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$l_i - x_i = 0 \vee \beta_i = 0$&lt;/span&gt;; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i - u_i = 0 \vee \lambda_i = 0$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\forall i \in {1, \dots, n}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My question is, can we say that the optimal solution for the given MILP is equals to the optimal solution for the initial QP?&lt;/p&gt;&#xA;&lt;p&gt;Thanks for the attention, case there is any missing point, please, let me know.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="500" LastEditDate="2023-10-02T18:47:44.540" LastActivityDate="2023-10-02T18:47:44.540" Title="From Quadratic to MILP?" Tags="|mixed-integer-programming|linearization|quadratic-programming|lagrange-multipliers|kkt-conditions|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11069" PostTypeId="2" ParentId="11067" CreationDate="2023-10-02T14:43:04.987" Score="5" Body="&lt;p&gt;You can test whether a point &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt; appears inside a convex polygon with vertices &lt;span class=&quot;math-container&quot;&gt;$(x_i,y_i)$&lt;/span&gt; by solving a linear programming problem (with no objective):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i \lambda_i &amp;amp;= 1 \\&#xA;\sum_i x_i \lambda_i &amp;amp;= x \\&#xA;\sum_i y_i \lambda_i &amp;amp;= y \\&#xA;\lambda_i &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $i$}&#xA;\end{align}&lt;/span&gt;&#xA;The idea is to express &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt; as a convex combination of the vertices.&#xA;If the problem is feasible, the point appears inside the polygon.  If infeasible, it doesn't.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Note that the &lt;span class=&quot;math-container&quot;&gt;$\lambda_i$&lt;/span&gt; are continuous variables. If your solver requires integer variables, you can approximate &lt;span class=&quot;math-container&quot;&gt;$\lambda_i$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$p_i/q$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; are integer variables, and clear the denominators:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i p_i &amp;amp;= q \\&#xA;\sum_i x_i p_i &amp;amp;= x q \\&#xA;\sum_i y_i p_i &amp;amp;= y q \\&#xA;p_i &amp;amp;\ge 0 &amp;amp;&amp;amp;\text{for all $i$} \\&#xA;q &amp;amp;\ge 1 &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-10-02T17:16:19.837" LastActivityDate="2023-10-02T17:16:19.837" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="11070" PostTypeId="1" AcceptedAnswerId="11071" CreationDate="2023-10-03T12:17:09.797" Score="0" ViewCount="46" Body="&lt;p&gt;I'm trying to understand an Online Portfolio Selection Algorithm (AKA OPS, which are algorithms that update the portfolio when new data arrives), named local adaptive learning system (LOAD), that has been introduced by &lt;a href=&quot;https://doi.org/10.1016/j.knosys.2019.104958&quot; rel=&quot;nofollow noreferrer&quot;&gt;Guna and An (2019)&lt;/a&gt;.&#xA;The image of the algorithm is provided below.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/eDmU2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eDmU2.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I do not understand the &lt;strong&gt;14th line&lt;/strong&gt; of the algorithm. I do not know how to achieve the &lt;span class=&quot;math-container&quot;&gt;$\textbf{b}$&lt;/span&gt; vector (if it is a vector (?)) and what's the meaning of &lt;span class=&quot;math-container&quot;&gt;$\arg \mathop {\min }\limits_{\textbf{b} \in {\Delta _m}} {\left\| {\textbf{b} - {\textbf{b}_{t + 1}}} \right\|^2}$&lt;/span&gt;. I'm not sure if they mean &lt;span class=&quot;math-container&quot;&gt;$\textbf{b}$&lt;/span&gt; is a collection of portfolios and they want to find the one that has the lowest Euclidean distance from &lt;span class=&quot;math-container&quot;&gt;$\textbf{b}_{t + 1}$&lt;/span&gt;. Also, I don't know what they mean by projection.&lt;/p&gt;&#xA;&lt;p&gt;P.S.: The meaning of &lt;span class=&quot;math-container&quot;&gt;$\Delta _m$&lt;/span&gt; is:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$1^T\textbf{b}_{t + 1} = 1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$${\textbf{b}_{t + 1}} \ge 0$$&lt;/span&gt;&#xA;This means, the weight of each asset in the portfolio should be between 0 and 1, and sum of the weights should be equal to 1.&lt;/p&gt;&#xA;" OwnerUserId="6022" LastEditorUserId="6022" LastEditDate="2023-10-03T12:24:05.450" LastActivityDate="2023-10-03T13:01:05.587" Title="Portfolio Projection" Tags="|optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11071" PostTypeId="2" ParentId="11070" CreationDate="2023-10-03T13:01:05.587" Score="1" Body="&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$\hat{\mathbf b}_{t+1}$&lt;/span&gt; on line 13 might not satisfy the constraints that define &lt;span class=&quot;math-container&quot;&gt;$\Delta_m$&lt;/span&gt;.  Line 14 is intended to find the closest &lt;span class=&quot;math-container&quot;&gt;$\mathbf b$&lt;/span&gt; that does, that is, find the projection of &lt;span class=&quot;math-container&quot;&gt;$\hat{\mathbf b}_{t+1}$&lt;/span&gt; onto &lt;span class=&quot;math-container&quot;&gt;$\Delta_m$&lt;/span&gt;. But there are two typos in line 14: the &lt;span class=&quot;math-container&quot;&gt;$\hat{\mathbf b}_{t+1}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b}_{t+1}$&lt;/span&gt; are reversed.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-10-03T13:01:05.587" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11072" PostTypeId="1" CreationDate="2023-10-03T19:31:57.720" Score="1" ViewCount="28" Body="&lt;p&gt;I'm looking at this article:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;quot;Packing unequal circles into a strip of minimal length with a jump algorithm&amp;quot; (Stoyan et Yaskov, 2014) &lt;a href=&quot;https://doi.org/10.1007/s11590-013-0646-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In section 5, a nonlinear &lt;strong&gt;constrained&lt;/strong&gt; model is stated:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/H1m8xm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/H1m8xm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then the authors write:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lAYUSm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lAYUSm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;How does one compute this steepest ascent vector &lt;span class=&quot;math-container&quot;&gt;$Y^0$&lt;/span&gt;? If the problem were unconstrained, I would have thought of the gradient of the objective, but here I don't see&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-10-03T19:31:57.720" Title="Steepest ascent vector at a point of a constrained nonlinear problem" Tags="|nonlinear-programming|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11073" PostTypeId="1" AcceptedAnswerId="11074" CreationDate="2023-10-03T19:58:21.740" Score="0" ViewCount="95" Body="&lt;p&gt;I am learning linear programming through the book Introduction to Linear Optimization by Dimitris Bertsimas.&lt;/p&gt;&#xA;&lt;p&gt;Many of the exercises can be implemented in code. This is an example of such an exercise: (&lt;a href=&quot;https://i.stack.imgur.com/WzloF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/WzloF.png&lt;/a&gt;). Are there any courses or other sources that explain how to implement these algorithms in, for example, Gurobi, or other algorithms such as interior point methods or the ellipsoid algorithm? I want to also gain a more practical understanding of linear programming in addition to a theoretical understanding by reading the textbook.&lt;/p&gt;&#xA;" OwnerUserId="12580" LastEditorUserId="12580" LastEditDate="2023-10-03T19:58:55.550" LastActivityDate="2023-10-03T22:38:18.267" Title="Implementing linear programming algorithms" Tags="|linear-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11074" PostTypeId="2" ParentId="11073" CreationDate="2023-10-03T22:23:34.657" Score="2" Body="&lt;p&gt;Disclaimers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I interpret your question as asking about how to implement LP solving algorithms (the core) and not about how to apply LP technology having access to some LP solver / oracle&lt;/li&gt;&#xA;&lt;li&gt;I'm not a solver developer!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Textbook vs. Real-world&lt;/h2&gt;&#xA;&lt;p&gt;Imho LP (and MIP) technology is heavily lacking textbooks covering state-of-the-art real-world implementations. There is a large difference between theory and practice!&lt;/p&gt;&#xA;&lt;p&gt;Skimming over the employee lists of the well-known commercial vendors of this kind of software one can see a huge pool of people with a background at the Zuse Institut Berlin (ZIB) which might somewhat indicate how expertise builds up and is transferred. But that's just probably only part of the story.&lt;/p&gt;&#xA;&lt;h3&gt;IPMs&lt;/h3&gt;&#xA;&lt;p&gt;Interior-point solvers are probably much more easy to implement (for real-world purposes) as (at least when not competing with the state of the art like Mosek and co.) the sparse-algebra needed is rather generic-purpose and these routines dominate time-consumption and complexity in implementations: sometimes third-party software is available, e.g. MUMPS, SuperLU; sometimes not (there are more IPM-suited ones depending on the algorithmic core), but literature seems more complete here). There are still other parts less well-covered like matrix-scaling and co.&lt;/p&gt;&#xA;&lt;h3&gt;Simplex&lt;/h3&gt;&#xA;&lt;p&gt;Simplex-style solvers howewer seem way more specialized and factorization-routines don't seem to reappear in other applications (unlike MUMPS and SuperLU).&lt;/p&gt;&#xA;&lt;p&gt;This doesn't mean that there aren't great resources. But those are scattered.&#xA;Papers on presolving (also relevant for IPMs) seem rather complete to me. Simplex factorization, pivoting and co. can also be found. Things related to numerical-stability howewer: less transparent.&lt;/p&gt;&#xA;&lt;h3&gt;Source code&lt;/h3&gt;&#xA;&lt;p&gt;At some point, one probably has to read (open-source) code. Good picks are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CoinOR &lt;a href=&quot;https://github.com/coin-or/Clp&quot; rel=&quot;nofollow noreferrer&quot;&gt;Clp&lt;/a&gt; (&lt;a href=&quot;https://github.com/coin-or/Cbc&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cbc&lt;/a&gt;) (arguably hardest codebase to read; C++)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Contains IPM (2nd class citizen)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/scipopt/soplex&quot; rel=&quot;nofollow noreferrer&quot;&gt;Soplex&lt;/a&gt; (&lt;a href=&quot;https://github.com/scipopt/scip&quot; rel=&quot;nofollow noreferrer&quot;&gt;SCIP&lt;/a&gt;) (best documentation; ZIB in-house codebase; C)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ERGO-Code/HiGHS&quot; rel=&quot;nofollow noreferrer&quot;&gt;Highs&lt;/a&gt; (more modern/smaller codebase; more modern algorithmics; C++)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Contains IPM&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;ortools &lt;a href=&quot;https://github.com/google/or-tools/tree/stable/ortools/glop&quot; rel=&quot;nofollow noreferrer&quot;&gt;Glop&lt;/a&gt; (more modern/smaller codebase; more modern algorithmics: C++)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;More modern algorithmics related to (seems to be the core of modern impls dropping original algos of Clp/Soplex; buttake it with a grain of salt):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Huangfu, Qi, and JA Julian Hall. &amp;quot;Parallelizing the dual revised simplex method.&amp;quot; Mathematical Programming Computation 10.1 (2018): 119-142.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;All of those solvers (ortools being a bit different) extend to MILPs with branch-and-bound-and-price and such.&lt;/p&gt;&#xA;&lt;p&gt;A more minimal but interesting POC (also giving pointers on whats lacking):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/mlubin/jlSimplex&quot; rel=&quot;nofollow noreferrer&quot;&gt;jlsimplex&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;This is not a textbook implementation and contains some advanced features that are important for practical implementations...&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h3&gt;Textbook recommendations (personal)&lt;/h3&gt;&#xA;&lt;h4&gt;IPMs&lt;/h4&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Wright, Stephen J. Primal-dual interior-point methods. Society for Industrial and Applied Mathematics, 1997.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I wrote a Convex QP solver once surviving well known testsets and this book served as core reference.&lt;/p&gt;&#xA;&lt;h4&gt;Simplex&lt;/h4&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Maros, István. Computational techniques of the simplex method. Vol. 61. Springer Science &amp;amp; Business Media, 2012.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Only book imho really targeting real-world implementations (but a bit dated). A quote supporting my points in the intro:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;Over the years I was approached by several people asking for advice&#xA;regarding the implementation of the simplex method. They were complaining that information was scarce and scattered in the literature.&#xA;Additionally, they were not aware of all the aspects to be considered.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h3&gt;Resources recommended by vendors&lt;/h3&gt;&#xA;&lt;h4&gt;IBM/Cplex&lt;/h4&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/support/pages/information-describing-algorithms-cplex-uses&quot; rel=&quot;nofollow noreferrer&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h4&gt;Gurobi&lt;/h4&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.gurobi.com/resources/books-blog/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="231" LastEditorUserId="231" LastEditDate="2023-10-03T22:38:18.267" LastActivityDate="2023-10-03T22:38:18.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11075" PostTypeId="1" CreationDate="2023-10-04T01:33:06.263" Score="1" ViewCount="130" Body="&lt;p&gt;I have an optimization problem for deliveries between production lines and a warehouse in a small facility. I need to know how many vehicles and utilities to buy, such that cost and downtime are minimized (downtime can be considered as a cost as well). The horizon is 8 hours.&lt;/p&gt;&#xA;&lt;p&gt;It is some kind of scheduling/allocation problem, and I would like to formulate it as a mixed-integer programming problem. But I can't &amp;quot;visualize&amp;quot; this like other typical scheduling problems (e.g. job-shop or staff scheduling), so I don't know how to go about formulating the model. The kinds of scheduling problems I've seen all know their resources and jobs at the very start and just &amp;quot;arrange blocks&amp;quot; on a fixed timeline in the &amp;quot;best&amp;quot; way.&lt;/p&gt;&#xA;&lt;p&gt;The &amp;quot;resources&amp;quot; in my case would be: vehicles, utilities, and workers. The &amp;quot;jobs&amp;quot; would be: warehouse workers loading boxes onto utilities, empty-handed vehicles traveling between lines and warehouse, vehicles transporting loaded utilities from the warehouse to a line, line workers unloading boxes from utilities, and vehicles transporting emptied utilities back to the warehouse.&lt;/p&gt;&#xA;&lt;p&gt;Even if the number of resources were known, the jobs are still dynamic/unknown at the start. A chain of events would look like:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A line initiates an order for replenishment.&lt;/li&gt;&#xA;&lt;li&gt;A worker in the warehouse (when available) would load a utility (when empty and present in warehouse) with the boxes ordered.&lt;/li&gt;&#xA;&lt;li&gt;A vehicle (when available) would travel to the loaded utility in the warehouse, pick it up, travel to its destination line, and drop off the utility.&lt;/li&gt;&#xA;&lt;li&gt;A worker at the line (when available) would unload all the boxes from the utility.&lt;/li&gt;&#xA;&lt;li&gt;A vehicle (when available) would travel to the empty utility at the line, pick it up, travel to the warehouse, and drop off the empty utility.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;While a worker is loading/unloading (fixed processing time), the worker is unavailable for other jobs. As soon as a utility has started to be loaded, the utility becomes unavailable. When a worker has finished loading/unloading, the worker becomes available and the loaded/empty utility waits for a vehicle. When a vehicle is traveling to pickup/dropoff a utility (fixed travelling time between warehouse and a line), the vehicle is unavailable for other jobs. When an empty utility is dropped off back at the warehouse, the utility becomes available.&lt;/p&gt;&#xA;&lt;p&gt;So these chains of events all start from an order. But when the orders happen is not known at the very start. The example below shows that order points can vary based on when a line is running, when it goes down, and when it gets deliveries. Not stochastic, but depends on other time-related factors.&lt;/p&gt;&#xA;&lt;h6&gt;Definitions&lt;/h6&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t \in T = \{0, 1, 2, ..., 1440\}$&lt;/span&gt;, set of time indices (minutes)&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$m \in M = \{1, 2, ...\}$&lt;/span&gt;, set of components&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$n \in N = \{1, 2, ...\}$&lt;/span&gt;, set of production lines&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$j_{mn} = 1$&lt;/span&gt; if component &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is used by line &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise (this is a fixed parameter table)&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$q_m$&lt;/span&gt;, number of pieces of component &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; in &lt;strong&gt;one&lt;/strong&gt; box of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$p_n$&lt;/span&gt;, production rate (seconds between when one piece of all components at line &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; are simultaneously used)&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$r_{mnt}$&lt;/span&gt;, number of pieces of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; remaining at line &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$b_{mnt}$&lt;/span&gt;, number of boxes of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; ordered by line &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$f_m$&lt;/span&gt;, maximum number of boxes of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; which can fit on a utility. Multiple boxes can be loaded onto a utility, but all boxes loaded on a utility can only be for a single &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h6&gt;Example&lt;/h6&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$j_{11} = 1, j_{21} = 1, q_1 = 1000, q_2 = 40, p_1 = 15, f_1 = 1, f_2 = 3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Say the line has no parts at all at &lt;span class=&quot;math-container&quot;&gt;$t = 0$&lt;/span&gt;, and makes its first order: &lt;span class=&quot;math-container&quot;&gt;$b_{1,1,0} = f_1 = 0, b_{2,1,0} = f_2 = 3$&lt;/span&gt; (to ensure it can run for 30 minutes). Say at &lt;span class=&quot;math-container&quot;&gt;$t = 10, b_{1,1,0}$&lt;/span&gt; arrives. Say at &lt;span class=&quot;math-container&quot;&gt;$t = 20, b_{2,1,0}$&lt;/span&gt; arrives. At &lt;span class=&quot;math-container&quot;&gt;$t = 20$&lt;/span&gt;, the line starts. It knows it can run until it goes down at &lt;span class=&quot;math-container&quot;&gt;$t = 50$&lt;/span&gt;. With fixed lead time of &lt;span class=&quot;math-container&quot;&gt;$L = 10$&lt;/span&gt;, it will order &amp;quot;what it needs&amp;quot; at &lt;span class=&quot;math-container&quot;&gt;$t = 40$&lt;/span&gt; i.e. only &lt;span class=&quot;math-container&quot;&gt;$b_{2,1,40} = 3$&lt;/span&gt;, as it does not need any boxes for &lt;span class=&quot;math-container&quot;&gt;$m = 1$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$t \in [50, 80]$&lt;/span&gt;. Say the delivery arrives at &lt;span class=&quot;math-container&quot;&gt;$t = 60$&lt;/span&gt;. The line was down from &lt;span class=&quot;math-container&quot;&gt;$t \in [50, 60]$&lt;/span&gt;. At &lt;span class=&quot;math-container&quot;&gt;$t = 60$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$r_{1,1,60} = 880$&lt;/span&gt; (remaining since &lt;span class=&quot;math-container&quot;&gt;$t = 50$&lt;/span&gt;), and &lt;span class=&quot;math-container&quot;&gt;$r_{2,1,60} = 120$&lt;/span&gt; (replenished at &lt;span class=&quot;math-container&quot;&gt;$t = 60$&lt;/span&gt;). So from &lt;span class=&quot;math-container&quot;&gt;$t = 60$&lt;/span&gt;, the line knows it can run until it goes down at &lt;span class=&quot;math-container&quot;&gt;$t = 100$&lt;/span&gt;, and will order more &lt;span class=&quot;math-container&quot;&gt;$m = 2$&lt;/span&gt; boxes at &lt;span class=&quot;math-container&quot;&gt;$t = 90$&lt;/span&gt;. The order points here are: &lt;span class=&quot;math-container&quot;&gt;$t = 0, 40, 90$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;So... because I can't visualize &amp;quot;all of the blocks&amp;quot; at the very start, I cannot really visualize &amp;quot;arranging blocks&amp;quot; in the first place... So I am stuck on trying to formulate an MIP model for this. I only have somewhat of an objective function below.&lt;/p&gt;&#xA;&lt;h6&gt;Objective Function&lt;/h6&gt;&#xA;&lt;p&gt;minimize cost: &lt;span class=&quot;math-container&quot;&gt;$C_V \sum_v x_v + C_U \sum_u y_u + C_W \sum_w z_w + \sum_n \sum_t c_n d_{nt}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$C_V$&lt;/span&gt;, one-time cost for a single vehicle&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$C_U$&lt;/span&gt;, one-time cost for a single utility&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$C_W$&lt;/span&gt;, one-time cost for a single warehouse worker. All lines will have one worker, so not considering them as part of the cost function.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$c_n$&lt;/span&gt;, constant cost-per-minute for line &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; being down.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$d_{nt} = 1$&lt;/span&gt; if line &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is down during time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_v = 1$&lt;/span&gt; if vehicle &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is used at all in the horizon, and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise. Similar for &lt;span class=&quot;math-container&quot;&gt;$y_u$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_w$&lt;/span&gt;.&#xA;Here, I pick some reasonable/realistic upper bound for &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, intending to &amp;quot;zero out&amp;quot; the unused &lt;span class=&quot;math-container&quot;&gt;$x_v$&lt;/span&gt;'s, &lt;span class=&quot;math-container&quot;&gt;$y_u$&lt;/span&gt;'s, and &lt;span class=&quot;math-container&quot;&gt;$z_w$&lt;/span&gt;'s... Not sure what other way there would be to find the optimal number of vehicles/utilities/workers as part of this scheduling problem.&lt;/p&gt;&#xA;" OwnerUserId="12581" LastActivityDate="2023-10-05T13:37:39.800" Title="Mixed-Integer Programming Model for Scheduling with Dynamic Jobs" Tags="|optimization|mixed-integer-programming|modeling|scheduling|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11076" PostTypeId="1" CreationDate="2023-10-04T07:31:07.897" Score="2" ViewCount="233" Body="&lt;p&gt;&lt;sub&gt;&lt;a href=&quot;https://math.stackexchange.com/q/4780307&quot;&gt;Crossposted&lt;/a&gt; on Mathematics SE&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I seek to minimize a convex quadratic objective subject to linear and &lt;span class=&quot;math-container&quot;&gt;$\ell_1$&lt;/span&gt;-based equality constraints. When I turn to CVXPY, an error is raised indicating that it does &lt;strong&gt;not&lt;/strong&gt; follow DCP rules. In what ways would it violate DCP? Naively, I thought this would be a common problem so would be handled by CVXPY out of the box.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import cvxpy as cp&#xA;import numpy as np&#xA;&#xA;n = 5&#xA;A = np.random.randn(n, n)&#xA;E = np.eye(n)&#xA;w = cp.Variable(n)&#xA;problem = np.Problem(&#xA;   cp.Minimize(cp.quad_form(w, E)),&#xA;   [&#xA;      A.T @ w == 0,&#xA;      cp.norm(w, 1) == 1&#xA;   ]&#xA;prob.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12584" LastEditorUserId="8" LastEditDate="2023-10-05T13:14:58.943" LastActivityDate="2023-10-05T13:14:58.943" Title="Quadratic optimisation with $\ell_1$ constraints with CVXPY" Tags="|optimization|python|convex-optimization|cvxpy|disciplined-convex-programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11077" PostTypeId="1" CreationDate="2023-10-04T07:44:14.420" Score="0" ViewCount="171" Body="&lt;p&gt;I'm formulating a scheduling problem with the following decision variables:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$X_t \space \text{is power sold to market in time period t} \\&#xA;Y_t \space \text{is power used for production in time period t} \\&#xA;z_t \space \text{is binary variable for full load production or idle mode}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have to model three constraints:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Total power available in time period t.&lt;/li&gt;&#xA;&lt;li&gt;Plant can remain in idle state(10MW) for exactly 4 hours at a time and immediately after that it should be in full load production(100MW) for at least 2 hours.&lt;/li&gt;&#xA;&lt;li&gt;Idle mode uses power but does not produce material, thus incurring cost.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I have available the cost of power, market price of power (for selling power to the market), material price of the market and a conversion efficiency of power to material.&lt;/p&gt;&#xA;&lt;p&gt;My formulation is currently incomplete because I have to use a linear objective but currently I can manage only a bilinear one:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;max \sum_{t}^{T} R_t^m + R_t^p \cdot z_t - C_t \\&#xA;s.t. R_t^m = X_t \cdot \Delta{t} \cdot \pi_t^m \\&#xA;R_t^p = \frac{Y_t \cdot \Delta{t} \cdot \pi_t^p}{\eta} \\&#xA;X_t + Y_t \leq P_t \\&#xA;C_t = (X_t + Y_t) \cdot \Delta{t} \cdot \pi_t^c \\&#xA;Y_t = 100 \cdot z_t + 10 \cdot (1-z_t) \\&#xA;X_t, Y_t \geq 0 ; z_t \in (0,1) &#xA;$$&lt;/span&gt;&#xA;where :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ R_t^m \text{ is the revenue earned by selling power on market with power price } \pi_t^m \\&#xA;R_t^p \text{ is the revenue earned by selling produced material with market price } \pi_t^p \\&#xA;P_t \text{ is the total power available for that period and is a parameter}\\&#xA;\eta \text{ is the power to material conversion efficiency of the plant} \\&#xA;C_t \text{ is the cost of power in time period t with unit cost } \pi_t^c \\&#xA;\Delta{t} \text{ is unit time period} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How can I formulate a constraint for the idling requirements in constraint 2, preferable without adding another binary variable?&lt;/li&gt;&#xA;&lt;li&gt;Currently I multiply revenue earned by material production by the state of the plant to make sure revenue is calculated only when full load production takes place. However, that makes the term bilinear. How can I reformulate to have a linear objective?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I did think of using indicator constraints but I'd rather first ask whether there is a simpler way to reformulate. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="12133" LastEditorUserId="12133" LastEditDate="2023-10-12T11:33:18.587" LastActivityDate="2024-03-10T12:04:30.463" Title="Production scheduling" Tags="|mixed-integer-programming|constraint|linearization|binary-variable|production-planning|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11078" PostTypeId="2" ParentId="11076" CreationDate="2023-10-04T14:28:47.033" Score="5" Body="&lt;p&gt;&lt;code&gt;cp.norm(w, 1) == 1&lt;/code&gt; is a nonlinear equality constraint, hence violates DCP rules. It is a non-convex constraint.&lt;/p&gt;&#xA;&lt;p&gt;Unless there is some special CVXPY mode or add-on to handle this, i believe you would need to introduce binary variables to handle this constraint, as shown in &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/mio.html#integer-modeling&quot; rel=&quot;nofollow noreferrer&quot;&gt;section 9.1.7 &amp;quot;Exact 1-norm&amp;quot; of the &amp;quot;Mosek Modeling Cookbook&amp;quot;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that &lt;code&gt;cp.norm(w, 1) &amp;lt;= 1&lt;/code&gt; is a DCP-compliant convex constraint. But &lt;code&gt;cp.norm(w, 1) &amp;gt;= 1&lt;/code&gt; is non-convex, and is non-DCP-compliant.&lt;/p&gt;&#xA;&lt;p&gt;The formulation in the Mosek Modeling Cookbook gets around this by shifting the non-convexity into the binary variables. I.e., the declaration of a variable as binary or integer is in and of itself a non-convex constraint, but one which CVXPY and similar convex optimization modeling tools allow, presuming the continuous relaxation is DCP-compliant.&lt;/p&gt;&#xA;&lt;p&gt;P.S. In the future, please follow the advice in @Henrik Alsing Friberg 's comment to show all the modeling tool and solver log output.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-10-04T14:50:15.493" LastActivityDate="2023-10-04T14:50:15.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11079" PostTypeId="1" CreationDate="2023-10-04T12:58:03.587" Score="0" ViewCount="47" Body="&lt;p&gt;I have the following problem in my business class. I have done an error in my solutions but I don't know where it is. Can Someone help me?&lt;/p&gt;&#xA;&lt;p&gt;It's October, and the new management of Elektronik AG is determined to achieve its climate goals by the end of the year in line with the Paris Climate Agreement. To achieve this, they have enlisted the expertise of a specialist to estimate the levels of greenhouse gas emissions and water consumption resulting from the production of their electronic products. The individual values can be found in the table below. In order to meet the year-end goals, the company must limit its greenhouse gas emissions to only 1500 metric tons and its water consumption to 60 million liters. Therefore, the management is requesting that you propose an optimized production program that takes into account the climate goals while maximizing the highest possible contribution margin.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zAaKh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zAaKh.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;a) Which products should be considered for the optimization of the production program using the Simplex algorithm? Justify your selection based on relative contribution margins.&lt;/p&gt;&#xA;&lt;p&gt;b) Now, taking into consideration the results from a), formally articulate the optimization problem. (6 points)&lt;/p&gt;&#xA;&lt;p&gt;c) In preparation for determining the optimal production program using the Simplex algorithm, set up the initial tableau. Also, identify the pivot column and row, and the pivot element. Justify your selection.&lt;/p&gt;&#xA;&lt;p&gt;Now, for part a), I have calculated the relative contribution margins, and they should be as follows:&amp;quot;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/8aD1M.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8aD1M.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;While for part b), I have formulated the following optimization problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max CB(x_l,x_t,x_s)=1000x_l+300x_t+210x_s \\ 0 \leq x_l\leq 2000 \\ 0 \leq x_t\leq 5000 \\ 0 \leq x_s\leq 10000 \\ 4x_l+2.5x_t+3x_s \leq 1500000 \\ 0.05x_l+0.1x_t+0.21 x_s\leq 60000000$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now I believe there may be an issue with my formulation, as in part c) (which I've verified using an online calculator), it seems that all three products can be produced without any constraints, which doesn't make sense.&lt;/p&gt;&#xA;&lt;p&gt;Can you tell me where I'm going wrong?&lt;/p&gt;&#xA;" OwnerDisplayName="Marco Di Giacomo" LastActivityDate="2023-10-04T20:06:41.640" Title="Problem with the simplex method in a cost accounting problem" Tags="|optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11080" PostTypeId="2" ParentId="11079" CreationDate="2023-10-04T20:06:41.640" Score="2" Body="&lt;p&gt;There is a problem with your fourth and fifth constraint. I think you used the wrong coefficients. It should be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\max  z =  1,000x_l+300x_t+210x_s\\ &#xA;0 \leq x_l \leq 2000 \\&#xA;0 \leq x_t \leq 5000 \\&#xA;0 \leq x_s \leq 10,000 \\&#xA;250 x_s + 120x_t + 70x_s \leq 1,500,000 \\&#xA;20,000 x_s + 3,000x_t + 1,000x_s \leq 60,000,000 \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2023-10-04T20:06:41.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11081" PostTypeId="1" AcceptedAnswerId="11085" CreationDate="2023-10-05T08:55:29.650" Score="1" ViewCount="83" Body="&lt;p&gt;I successfully understood and implemented a Benders algorithm for the deterministic version of the problem I am studying.&lt;/p&gt;&#xA;&lt;p&gt;However, I have some issues now diving into the stochastic model. I have the mathematical foundations ready for two-stage stochastic programming but I don't know how to combine it with Benders now.&lt;/p&gt;&#xA;&lt;p&gt;Do you know good resources where I can learn about this? Maybe even an example implementation in C++?&lt;/p&gt;&#xA;" OwnerUserId="12130" LastActivityDate="2023-10-05T14:40:39.353" Title="Recommendations to understand stochastic version of Benders?" Tags="|mixed-integer-programming|stochastic-programming|benders-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11082" PostTypeId="1" CreationDate="2023-10-05T11:59:10.343" Score="1" ViewCount="63" Body="&lt;p&gt;The graph in the image represents the production sequencing on a machine with production capacity C in volume.  Each node N represents a different product with a profit L per volume produced.  Every time we pass through node N, a minimum volume of product must be produced.  The objective is to maximize profit.  Note, this is a generalization of the problem, what I'm interested in is a constraint that guarantees that an edge can be passed at most once.  Also, does anyone know if there is a classic problem in the literature that covers the problem?  The closest thing I came to was the vehicle and traveling salesman routing problem, but it's not quite the formulation I need, since nodes can be visited more than once.  I know there is a way to turn the problem into a routing problem, but I wanted an efficient formulation specific to my problem.&lt;a href=&quot;https://i.stack.imgur.com/yGcZV.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yGcZV.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12591" LastEditorUserId="9755" LastEditDate="2023-10-07T18:34:20.270" LastActivityDate="2023-10-07T18:34:20.270" Title="Need help with a model to optimize a trail in directed graph" Tags="|optimization|mixed-integer-programming|graphs|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11084" PostTypeId="2" ParentId="11075" CreationDate="2023-10-05T13:37:39.800" Score="1" Body="&lt;p&gt;To determine the number of AGVs in your production system, their working procedure should be exploded first based on the following states:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \{ \text{Idle time, empty travel time, loading time, loaded travel time, unloading time, blocked time, and charging time} \}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first three states usually can be predetermined, but the rest almost need to be estimated. Also, you still need to calculate two matrices. The first &lt;code&gt;From-To matrix&lt;/code&gt; (&lt;span class=&quot;math-container&quot;&gt;$f_{i,j}$&lt;/span&gt;), and the second &lt;code&gt;Distance matrix&lt;/code&gt; (&lt;span class=&quot;math-container&quot;&gt;$d_{i,j}$&lt;/span&gt;). (From pickup station &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to delivery station &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;). The required parameters to calculate the number of AGVs needed are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$L_{t}$&lt;/span&gt;: loading operation time&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$U_{t}$&lt;/span&gt;: unloading operation time&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;: vehicle speed&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;: planning horizon&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt;: vehicle’s efficiency estimation&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;: percentage of the time the vehicle is blocked&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;: percentage of time the vehicle is idle&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t_{b}$&lt;/span&gt;: time estimation the vehicle spends charging&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f(T_{lt})$&lt;/span&gt;: empty travel time estimation as a function of the loaded travel time&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \text{number of vehicles (N)} = (required transfer capacity)/(planning horizon) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ N = ((\sum_{i} \sum_{j} f_{i,j} d_{i,j}/V) +  f(T_{lt}) + (\sum_{i} \sum_{j} f_{i,j}(L_{t} + U_{t}))) / ( e(T - t_{b}) / 1 + b + c ) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The above function can either be applied directly or as a transfer function through the Monte-Carlo simulation to robust the represented parameters.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;As a PIP the above problem can be written as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$f_{i,j,k}$&lt;/span&gt;: number of transfers required from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; of flow type &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$NF_{i,k}$&lt;/span&gt;: net flow at node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; of flow type &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; per hour&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$CP_{i,j}$&lt;/span&gt;: number of transfers allowed on a path from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; per hour&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$W_{i,j}$&lt;/span&gt;: maximum number of flow path lanes allowed between nodes &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$L_{i,j}$&lt;/span&gt;: lane installation cost from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;: cost per vehicle including software and hardware&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\ Min\ z = &amp;amp;\ \sum_i \sum_j \sum_k C(x_{i,j,k} f_{i,j,k})/V  + \sum_i \sum_j L_{i,j} n_{i,j} \\&#xA;&amp;amp;\ \text{S.t:} \\&#xA;&amp;amp;\ \sum_j x_{i,j,k} - \sum_r x_{r,i,k} = NF_{i,k} \quad \forall i, \forall k \quad(1)\\&#xA;&amp;amp;\ n_{i,j} - \sum_k x_{i,j,k}/CP_{i,j} \geq 0 \quad \forall i,j \quad(2)\\&#xA;&amp;amp;\ n_{i,j} + n_{j,i} \leq W_{i,j} \quad \forall i,j \quad(3)\\&#xA;&amp;amp;\ x_{i,j,k} \ge 0 \in \mathbb{Z}^+, n_{i,j} \in \mathbb{B}\\&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective function minimizes the cost related to the number of vehicles needed and also the flow path network cost. The first constraint implies maintaining the flow in the system, the second constraint represents determining the number of flow path lanes required, and the third constraint controls the number of flow path lanes.&lt;/p&gt;&#xA;&lt;p&gt;Also, for determining the optimal number of required workers, either simulation or mathematical modeling of rough cut capacity planning (RCCP) can be used.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-10-05T13:37:39.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11085" PostTypeId="2" ParentId="11081" CreationDate="2023-10-05T14:40:39.353" Score="1" Body="&lt;p&gt;Not in C++, but SDDP.jl implements Benders for two-stage stochastic programming (as well as SDDP for multi-stage).&lt;/p&gt;&#xA;&lt;p&gt;There are a few tutorials which work though the algorithm:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://sddp.dev/stable/tutorial/example_newsvendor/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://sddp.dev/stable/tutorial/example_newsvendor/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://sddp.dev/stable/explanation/theory_intro/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://sddp.dev/stable/explanation/theory_intro/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;But both these tutorials are pedagogical. They do not include the tricks that a high quality implementation needs. (I'm obviously biased, but instead of implementing your own algorithm, you could just use SDDP.jl.)&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2023-10-05T14:40:39.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11086" PostTypeId="1" AcceptedAnswerId="11087" CreationDate="2023-10-05T22:22:11.123" Score="0" ViewCount="42" Body="&lt;p&gt;I have a program with quadratic objective and constraints, and wanna utilize sddp.jl package in julia for solution.&lt;/p&gt;&#xA;" OwnerUserId="10727" LastActivityDate="2023-10-06T07:11:14.200" Title="Are quadratic multi-stage optimization problems with quadratic constraints solvable by stochastic dual dynamic programming and SDDP.jl?" Tags="|julia|stochastic-dual-dynamic-programming|sddp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11087" PostTypeId="2" ParentId="11086" CreationDate="2023-10-06T07:11:14.200" Score="0" Body="&lt;p&gt;Yes, if you use a solver that supports quadratic objectives and constraints, and the problem is convex.&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2023-10-06T07:11:14.200" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11088" PostTypeId="1" CreationDate="2023-10-06T12:57:25.687" Score="2" ViewCount="96" Body="&lt;p&gt;Consider the model &lt;span class=&quot;math-container&quot;&gt;$\hat{y}_t = e^{\text{trend} + \text{seasonality}} \prod_k^K x_{k, t}^{b_k}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; denotes different investment alternatives. You can think that trend and seasonality are modelled a linear trend and dummies.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt; b_k &amp;lt; 1$&lt;/span&gt; (to capture diminishing marginal returns)&lt;/p&gt;&#xA;&lt;p&gt;We can linearize the multiplicative model to &lt;span class=&quot;math-container&quot;&gt;$$\ln(y) = \text{trend} + \text{seasonality} + \sum_{k \in \text{channels}} b_k \ln(x_k)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t &lt;span class=&quot;math-container&quot;&gt;$0 &amp;lt; b_k &amp;lt; 1 $&lt;/span&gt;...&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Now comes what bugs me out;&lt;/p&gt;&#xA;&lt;p&gt;Imagine that we estimated the linearized version with OLS and retrieved estimates for our &lt;span class=&quot;math-container&quot;&gt;$\text{trend}, \text{seasonality}, b_k$&lt;/span&gt; parameters.&lt;/p&gt;&#xA;&lt;p&gt;Imagine that we want to optimally plan a given budget &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; over our investments &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; such that we maximize &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; over a horizon &lt;span class=&quot;math-container&quot;&gt;$H$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There must be some issue with &lt;span class=&quot;math-container&quot;&gt;$log$&lt;/span&gt; not commuting with &lt;span class=&quot;math-container&quot;&gt;$\sum$&lt;/span&gt; since the two following reward functions are vastly different and will yield different solutions.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x_k}\sum_t^H e^{\hat{\text{trend}} + \hat{\text{seasonality}}} \prod_k^K x_{k, t}^{\hat{b}_k}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{x_k} \sum_t^H \hat{\text{trend}} + \hat{\text{seasonality}} + \sum_k^K x_{k, t}^{\hat{b}_k}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;....s.t &lt;span class=&quot;math-container&quot;&gt;$\sum_k^K \sum_t^T x_{k, t} \le B$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Notice how the seasonality and trend interact with our spend variables in the multiplicative model and do so in the linearized model. This means that we may ease in on spending when the season is bad and spend more when the season is good in the first model. This is not accounted for in the second model.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;How would one deal with this scenario, is it up to interpretation and are there any guidelines?&lt;/p&gt;&#xA;" OwnerUserId="12607" LastEditorUserId="12607" LastEditDate="2023-10-30T07:54:54.907" LastActivityDate="2023-10-30T07:54:54.907" Title="log-log regression as reward function in optimization problem" Tags="|optimization|linear-programming|nonlinear-programming|convex-optimization|constraint-programming|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11089" PostTypeId="1" CreationDate="2023-10-06T19:07:39.423" Score="0" ViewCount="86" Body="&lt;p&gt;When I look at the tableau generated by Gurobi for a simple 3D problem with five constraints, I get this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/9JDDZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9JDDZ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I expected to not have a -1 in basis columns 4, 5, 6 (referring to slack variables 1, 2, 3 if you 0-index). I intend to use this for some intersection cut experiments. I'm obviously going to need to account for the -1 with those. How should I use that information (for intersection cuts)? Should I negate those rows? Should I negate my constraints that go with those slack variables when I use them to represent a slack variable in the cut? Or just the RHS or LHS of those constraints?&lt;/p&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2023-10-06T19:07:39.423" Title="why the -1 in basis column for simplex tableau?" Tags="|gurobi|simplex|cuts|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="11090" PostTypeId="1" AcceptedAnswerId="11094" CreationDate="2023-10-08T15:37:46.233" Score="1" ViewCount="90" Body="&lt;p&gt;Here is part of a &amp;quot;.bas&amp;quot; file given by HiGHS using serial dual simplex method to solve an LP problem:&lt;/p&gt;&#xA;&lt;p&gt;HiGHS v1&lt;br /&gt;&#xA;Valid&lt;br /&gt;&#xA;# Columns 57471&lt;br /&gt;&#xA;3 1 1 3 3 1 1 3 3 1 1 3 1 3 3 1 ...&lt;/p&gt;&#xA;&lt;p&gt;What does the number &amp;quot;3&amp;quot; mean? I know that &amp;quot;1&amp;quot; indicates the basic variables, &amp;quot;0&amp;quot; indicates the non-basic variables at their lower bounds and &amp;quot;2&amp;quot; indicates the non-basic variables at their upper bounds.&lt;/p&gt;&#xA;" OwnerUserId="12349" LastActivityDate="2023-10-09T12:47:59.210" Title="How to understand the basis of LP problems given by HiGHS solver?" Tags="|mixed-integer-programming|linear-programming|api|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11091" PostTypeId="2" ParentId="10967" CreationDate="2023-10-08T20:15:39.390" Score="1" Body="&lt;p&gt;The problem is that the package you are using (minpack.lm) implements a version of the Levenberg-Marquardt algorithm, which requires gradients. Your function f is nondifferentiable at the values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; where the vertical steps occur.&lt;/p&gt;&#xA;&lt;p&gt;Possible workarounds include looking for a least-squares algorithm that works with nondifferentiable / nonconvex objective functions, or perhaps settling for a heuristic that produces a &amp;quot;reasonable&amp;quot; but not optimal fit.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-10-08T20:15:39.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11092" PostTypeId="2" ParentId="11077" CreationDate="2023-10-08T20:36:48.753" Score="0" Body="&lt;p&gt;There are some sources of confusion in your model. &lt;span class=&quot;math-container&quot;&gt;$P_t$&lt;/span&gt; is never defined; I'm going to assume it is a constant. It's not clear what &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$\Delta t$&lt;/span&gt; is unit time period&amp;quot; means; I'm going to assume it represents an hour and that &lt;span class=&quot;math-container&quot;&gt;$\Delta t = 1$&lt;/span&gt; (and can thus be ignored).&lt;/p&gt;&#xA;&lt;p&gt;It's also unclear whether you mean that the plant can idle for &lt;em&gt;up to&lt;/em&gt; four hours at a time or &lt;em&gt;exactly&lt;/em&gt; four hours at a time. Assuming the former, you can enforce it with a set of constraints &lt;span class=&quot;math-container&quot;&gt;$$z_t + z_{t+1} + \dots + z_{t+4} \ge 1$$&lt;/span&gt; for all relevant &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, which says that the plant cannot be idling (&lt;span class=&quot;math-container&quot;&gt;$z_t=0$&lt;/span&gt;) in any block of five consecutive hours.&lt;/p&gt;&#xA;&lt;p&gt;To ensure that revenue from production is zero when the plant is idling, you can remove &lt;span class=&quot;math-container&quot;&gt;$z_t$&lt;/span&gt; from the objective and instead change the second constraint from &lt;span class=&quot;math-container&quot;&gt;$R^p_t = \dots$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$R^p_t \le \dots$&lt;/span&gt; and add a constraint &lt;span class=&quot;math-container&quot;&gt;$R^p_t \le Mz_t$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is sum a priori upper bound on production revenue in any hour. If the plant is idle (&lt;span class=&quot;math-container&quot;&gt;$z_t = 0$&lt;/span&gt;), this will force &lt;span class=&quot;math-container&quot;&gt;$R^p_t = 0.$&lt;/span&gt; If the plant is at full load (&lt;span class=&quot;math-container&quot;&gt;$z_t = 1$&lt;/span&gt;), the big-M constraint will be nonbinding and, because you are maximizing revenue, the second constraint will be maxed out (effectively an equality).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-10-08T20:36:48.753" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11093" PostTypeId="1" CreationDate="2023-10-09T09:51:37.707" Score="1" ViewCount="263" Body="&lt;p&gt;Given a set of facilities &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; and days &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;, each facility &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt; has a capacity of &lt;span class=&quot;math-container&quot;&gt;$C_i$&lt;/span&gt;, and a set of days &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; where in each day &lt;span class=&quot;math-container&quot;&gt;$j \in J$&lt;/span&gt; there's a total demand of &lt;span class=&quot;math-container&quot;&gt;$q_j$&lt;/span&gt; that can be satisfied by one or more facilities.&lt;/p&gt;&#xA;&lt;p&gt;To satisfy the daily demand facilities are opened. The number of opened facilities of type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; should be equivalent on all days, hence the global cost of opening one facility of type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$h_{i}^{g} = |J|h_{i} $&lt;/span&gt;.  In addition, among the opened facilities, in each day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; a number of them can be canceled recovering the cost of opening one facility (&lt;span class=&quot;math-container&quot;&gt;$h_i$&lt;/span&gt;) and subject to a penalty (&lt;span class=&quot;math-container&quot;&gt;$h^{'}_i$&lt;/span&gt;) if the total number of canceled ones exceeds a certain threshold &lt;span class=&quot;math-container&quot;&gt;$0 \leq \alpha \leq 1.0$&lt;/span&gt; (e.g percentage) of the total number of opened facilities of type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. Thus we have &lt;span class=&quot;math-container&quot;&gt;$h^{'}_i &amp;lt;  h_i &amp;lt; h_{i}^{g}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The problem is to find the number of facilities of type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to be opened in all days and the one to be canceled in each day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; while minimizing the total cost of opened, cancelled and penalized facilities.&lt;/p&gt;&#xA;&lt;p&gt;Let the following integer variables be:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; = Total number of opened facilities&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; = number of canceled facilities of type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$w_i$&lt;/span&gt; = number of penalized facilities among the canceled ones&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt; = actual number of facilities of type &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; used in day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$z_{ij} = y_i - x_{ij}, \forall i,j)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; = amount sent from facility &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to satisfy the demand in day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The objective function minimizes: &lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in I} h_{i}^{g} y_i + \sum_{i\in I} h^{'}_i w_i - \sum_{i\in I,j\in J} h_i x_{ij}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In addition we have the following constraints:&lt;br /&gt;&#xA;(1) &lt;span class=&quot;math-container&quot;&gt;$\sum_{i} d_{ij} = q_{j}, \forall j$&lt;/span&gt; : demand satisfaction&lt;br /&gt;&#xA;(2) &lt;span class=&quot;math-container&quot;&gt;$d_{ij} \leq C_i z_{ij}, \forall i,j$&lt;/span&gt;: capacity constraints&lt;br /&gt;&#xA;(3) &lt;span class=&quot;math-container&quot;&gt;$z_{ij} = y_i - x_{ij}, \forall i,j$&lt;/span&gt;: actual number of used facilities &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in day &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;&lt;br /&gt;&#xA;(4) &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \leq y_i,\forall i,j$&lt;/span&gt;: no cancellation if facility is not opened&lt;br /&gt;&#xA;(5) &lt;span class=&quot;math-container&quot;&gt;$\sum_{j~\in{J}} x_{ij} - \beta y_{i} \leq w_{i} , \forall i$&lt;/span&gt;: penalize only if total cancellation exceeds &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; percentage of total number of y_{i}. Concretely &lt;span class=&quot;math-container&quot;&gt;$\beta = \alpha \times |{J}|$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0 \leq \alpha \leq 1.0$&lt;/span&gt;. For example &lt;span class=&quot;math-container&quot;&gt;$\beta = 0.2$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$\alpha = 10\%$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$|{J}| =2$&lt;/span&gt;. This constraint states that if:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j~\in~{J}} x_{ij} - \beta y_{i} \leq 0 \rightarrow w_{i} =0, \forall i~\in~{I} $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j~\in~{J}} x_{ij} - \beta y_{i} &amp;gt; 0 \rightarrow w_{i} \geq \sum_{j~\in~{J}} x_{ij} - \beta y_{i}, \forall i~\in~{I} $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Now imagine &lt;span class=&quot;math-container&quot;&gt;$|I| = 2$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$C_0 = 50$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C_1 = 60$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$h_0 = 500$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$h_1 = 550$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$h^{'}_{0} =400 $&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$h^{'}_{1} =440$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$|J| = 2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$q_0 = 75$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$q_1 = 110$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta = 0.2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Given these parameters, the optimal solution of the LP relaxation is &lt;span class=&quot;math-container&quot;&gt;$y_1 = 1.833333$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{10} = 0.5833333$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$w_1 = 0.216667$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_{10} = 75$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$d_{11} = 110$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It's not difficult to find this given that if  &lt;span class=&quot;math-container&quot;&gt;$y_1 = 1.833333$&lt;/span&gt; then:&lt;br /&gt;&#xA;in day 0: &lt;span class=&quot;math-container&quot;&gt;$C_1 \times y_1 = 60 \times 1.83333 = 110 - 75 = 35 =&amp;gt; 35/60 =0.583333$&lt;/span&gt; which equals the cancellation&lt;br /&gt;&#xA;in day 1: &lt;span class=&quot;math-container&quot;&gt;$C_1 \times y_1 = 60 \times 1.83333 = 110 - 110 = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;then for constraint (5) : &lt;span class=&quot;math-container&quot;&gt;$0.58333 - 0.366666 \leq 0.2166667$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am looking for a way to derive valid inequalities to cutoff this fractional solution (variables are integer) or to strengthen the formulation given the LP relaxation? or what is the right literature to look at to derive such cuts ? I am looking for network design problems with capacity expansion or elimination.&#xA;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="11022" LastEditorUserId="11022" LastEditDate="2023-10-17T10:08:31.870" LastActivityDate="2023-10-17T10:08:31.870" Title="Deriving a valid inequality" Tags="|optimization|linear-programming|integer-programming|valid-inequalities|cuts|" AnswerCount="0" CommentCount="20" ContentLicense="CC BY-SA 4.0" />
  <row Id="11094" PostTypeId="2" ParentId="11090" CreationDate="2023-10-09T12:47:59.210" Score="2" Body="&lt;p&gt;Here is the enum documentation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://ergo-code.github.io/HiGHS/stable/structures/enums/#HighsBasisStatus&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ergo-code.github.io/HiGHS/stable/structures/enums/#HighsBasisStatus&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But you have to infer that &lt;code&gt;kLower&lt;/code&gt; is &lt;code&gt;0&lt;/code&gt; and so on.&lt;/p&gt;&#xA;&lt;p&gt;The status 3 is &lt;code&gt;kZero&lt;/code&gt;: A free variable is nonbasic and set to zero&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2023-10-09T12:47:59.210" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11095" PostTypeId="2" ParentId="3072" CreationDate="2023-10-09T18:35:43.323" Score="3" Body="&lt;p&gt;Pyomo can do a lot. CVXPY is good for convex problems which can be modeled using DCP (Disciplined Convex Programming), including Linear SDPs, and does have certain extensions for certain non-convex problems.&lt;/p&gt;&#xA;&lt;p&gt;But there is no modeling environment I know of in Python which captures all of YALMIP's capabilities. For instance, I am not aware of any BMI (Blinear Matrix Inequality) capability in Pyomo or any other modeling environment in Python, let alone the capability to solve BMIs and Nonlinear SDPs to global optimality (given enough time).&lt;/p&gt;&#xA;&lt;p&gt;SO it really depends on the type and variety of problems you wish to solve.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-10-09T18:43:04.897" LastActivityDate="2023-10-09T18:43:04.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11096" PostTypeId="1" AcceptedAnswerId="11099" CreationDate="2023-10-09T22:52:12.333" Score="1" ViewCount="337" Body="&lt;p&gt;I am trying to solve a portfolio optimization problem using PuLP where given a dictionary of stock tickers and their returns for the day, returns a set of weights for each stock such that portfolio return is maximized. Both long and short positions are allowed. The weights must satisfy the following requirements&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Full investment (the absolute value of the weights sum to 1)&lt;/li&gt;&#xA;&lt;li&gt;Equity Market Neutral portfolio (long positions = short positions --&amp;gt; positive     weights sum to 0.5 and negative weights sum to -0.5)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Here is an example list of assets (labeled assets in the code):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;['META', 'GOOG', 'AAPL', 'BA', 'APO', 'FDX']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And a dictionary containing their returns (labeled returns_dict):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{'META': 0.005803442055417999, 'GOOG': -0.016066450130370023, 'AAPL': 0.0030249344157745966, &#xA;'BA': -0.05464299504580779, 'APO': -0.02150687085217356, 'FDX': -0.01989503040490268}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'm trying to solve this problem using the following code:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;        lp_problem = pulp.LpProblem(&amp;quot;Portfolio_Optimization&amp;quot;, pulp.LpMaximize)&#xA;        weights = pulp.LpVariable.dicts(&amp;quot;Weight&amp;quot;, assets, lowBound=-1, upBound=1, cat='Continuous')&#xA;&#xA;        lp_problem += pulp.lpSum([returns_dict[asset] * weights[asset] for asset in assets])&#xA;        &#xA;        # full investment constraint&#xA;        lp_problem += pulp.lpSum([(-1 if weights[asset] &amp;lt;= 0 else 1) * weights[asset] for asset in assets]) == 1&#xA;        #positive weights equal 0.5&#xA;        lp_problem  += pulp.lpSum([weights[asset] for asset in assets if weights[asset] &amp;gt;= 0]) - 0.5 &amp;lt;= 0.000001&#xA;        #negative weights equal - 0.5&#xA;        lp_problem  += pulp.lpSum([weights[asset] for asset in assets if weights[asset] &amp;lt;= 0]) + 0.5 &amp;lt;= 0.000001&#xA;        &#xA;        lp_problem.solve()&#xA;&#xA;        # Check the status of the solution&#xA;        if pulp.LpStatus[lp_problem.status] == &amp;quot;Optimal&amp;quot;:&#xA;            # Get and print the optimal portfolio weights&#xA;            optimal_weights = {asset: weights[asset].varValue for asset in assets}&#xA;            print(&amp;quot;Optimal Portfolio Weights:&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, PuLp is returning the following weights:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{'META': 1.0, 'GOOG': 0.0, 'AAPL': 1.0, 'BA': -1.0, 'APO': -1.0, 'FDX': -1.0}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which completely violate all of the constraints that I gave it. The absolute value of the weights don't equal 1, they equal 5. The sum of the positive weights equal 2 instead of 0.5 and the sum of the negative weights equal -3 instead of -0.5. Is there any changes that I can make to the constraints to prevent this from happening?&lt;/p&gt;&#xA;&lt;p&gt;The reason that I'm not simply setting the stock with the max positive return to 0.5 and the stock with the max negative return to -0.5 is to stay within a 25% interday turnover constraint, which I have not yet implemented.&lt;/p&gt;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;&lt;p&gt;Following sascha's advice, I attempted to preform comparisons on the returns instead&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;        #full investment&#xA;        lp_problem += pulp.lpSum([(-1 if returns_dict[asset] &amp;lt;= 0 else 1) * weights[asset] for asset in assets]) == 1&#xA;        #positive weights equal 0.5&#xA;        lp_problem  += pulp.lpSum([weights[asset] for asset in assets if returns_dict[asset] &amp;gt;= 0]) - 0.5 &amp;lt;= 0.000001&#xA;        #negative weights equal - 0.5&#xA;        lp_problem  += pulp.lpSum([weights[asset] for asset in assets if returns_dict[asset] &amp;lt;= 0]) + 0.5 &amp;lt;= 0.000001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but that didn't appear to fix my problem and I'm still getting bogus weight values:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{'GOOG': 0.0, 'META': -1.0, 'AAPL': -1.0, 'BA': -1.0, 'APO': -1.0, 'FDX': -1.0}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am aware that this is a suboptimal solution and fails in certain scenarios where all the returns are negative/positive, but was hoping it would work as a proof of concept.&lt;/p&gt;&#xA;" OwnerUserId="12630" LastEditorUserId="12630" LastEditDate="2023-10-09T23:46:39.110" LastActivityDate="2023-10-10T22:32:44.373" Title="PuLp is ignoring all of the constraints given to it" Tags="|optimization|linear-programming|solver|pulp|finance|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11097" PostTypeId="2" ParentId="11096" CreationDate="2023-10-10T00:25:09.160" Score="0" Body="&lt;p&gt;In case it helps, here's what it would look like in SAS:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;data indata;&#xA;   input stock $ return;&#xA;   datalines;&#xA;META  0.005803442055417999&#xA;GOOG -0.016066450130370023&#xA;AAPL  0.0030249344157745966 &#xA;BA   -0.05464299504580779&#xA;APO  -0.02150687085217356&#xA;FDX  -0.01989503040490268&#xA;;&#xA;&#xA;proc optmodel;&#xA;   set &amp;lt;str&amp;gt; STOCKS;&#xA;   num return {STOCKS};&#xA;   read data indata into STOCKS=[stock] return;&#xA;&#xA;   var Weight {STOCKS} &amp;gt;= -1 &amp;lt;= 1;&#xA;   max TotalReturn = sum {i in STOCKS} return[i] * Weight[i];&#xA;   con SumPositive:&#xA;      sum {i in STOCKS} max(Weight[i],0) = 0.5;&#xA;   con SumNegative:&#xA;      sum {i in STOCKS} min(Weight[i],0) = -0.5;&#xA;&#xA;   solve linearize;&#xA;   print Weight;&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The resulting optimal solution is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;stock Weight &#xA;AAPL   0.0 &#xA;APO    0.0 &#xA;BA    -0.5 &#xA;FDX    0.0 &#xA;GOOG   0.0 &#xA;META   0.5 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You could also impose a constraint as follows, but it is implied by the other two constraints:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   con SumAbs:&#xA;      sum {i in STOCKS} abs(Weight[i]) = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-10-10T00:25:09.160" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11099" PostTypeId="2" ParentId="11096" CreationDate="2023-10-10T20:31:24.213" Score="2" Body="&lt;p&gt;We can do this with fewer binary variables (and fewer constraints) than in the proposed PuLP model.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\max &amp;amp; \sum_{i} \color{darkblue}r_i (\color{darkred}w_{i,long}-\color{darkred}w_{i,short}) \\&#xA;     &amp;amp; \color{darkred}w_{i,long} \le \color{darkred}\delta_i \\&#xA;     &amp;amp;\color{darkred}w_{i,short} \le 1-\color{darkred}\delta_i \\&#xA;     &amp;amp;\sum_i \color{darkred}w_{i,p} = 0.5 &amp;amp;&amp;amp; \forall p \in \{long,short\}\\&#xA;     &amp;amp; \color{darkred}w_{i,p} \in [0,1] \\&#xA;     &amp;amp; \color{darkred}\delta_{i} \in \{0,1\} \\&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The solution would look like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;----     79 VARIABLE w.L  &#xA;&#xA;            long       short&#xA;&#xA;META       0.500&#xA;BA                     0.500&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Not sure if it makes much of a difference in performance. The model is a bit more compact, and the difference between long and short is more explicit.&lt;/p&gt;&#xA;&lt;p&gt;In general, I don't like to translate models line-by-line from one modeling tool to the next. I rather take a step back and translate concepts. This often leads to cleaner models.&lt;/p&gt;&#xA;&lt;p&gt;Update: the linearized turnover constraint can look like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned}&#xA;&amp;amp; \color{darkred}t_i \ge \color{darkred}w_{i,long}-\color{darkred}w_{i,short} - \color{darkblue}w^0_i \\&#xA;&amp;amp; \color{darkred}t_i \ge -(\color{darkred}w_{i,long}-\color{darkred}w_{i,short} - \color{darkblue}w^0_i) \\&#xA;&amp;amp; \sum_i \color{darkred}t_i \le 0.25 \\&#xA;&amp;amp; \color{darkred}t_i \ge 0&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The variable &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}t_i$&lt;/span&gt; needs to be interpreted with care. It is a bound on the turnover of asset &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2023-10-10T22:32:44.373" LastActivityDate="2023-10-10T22:32:44.373" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11100" PostTypeId="1" AcceptedAnswerId="11101" CreationDate="2023-10-11T11:59:47.947" Score="1" ViewCount="115" Body="&lt;p&gt;I want to know if dynamic programming can generally find globaly optimal solutions for scheduling problems? I think this might be difficult as dynamic makes one at a time decisions without calculating a schedule for the whole timespan. For that you need something like a linear/non-linear program as far as I see it.&lt;/p&gt;&#xA;&lt;p&gt;Let's look at one example from the field of energy. Suppose we have an electric vehicle and a time-variable electricity tarif. Now the goal is to charge the electric vehicle such that the overall charging costs for the next day are minimized while having the battery state of charge at a certain minimum value. Tranditionally, this is optimally solved by defining a MILP problem and solving using a solver (with some MIP gap). The output is a schedule which specifies for each hour of the day the charging power (of course we'd need some information about the availability of the electric vehicle)&lt;/p&gt;&#xA;&lt;p&gt;Now if you apply dynamic programming to this problem, you make sequential decisions at every hour as far as I understand. This can't normally be globally optimal as you don't consider all timeslots and future values (e.g. availability) together to make your decisions.&lt;/p&gt;&#xA;&lt;p&gt;So can dynamic programming still in fact find the globally optimal solution for such a time constrained scheduling problem.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastActivityDate="2023-10-11T15:37:22.920" Title="Can dynamic programming find globally optimal solutions for scheduling problems" Tags="|scheduling|dynamic-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11101" PostTypeId="2" ParentId="11100" CreationDate="2023-10-11T15:37:22.920" Score="4" Body="&lt;p&gt;Assuming your state space is discrete (for instance, there are finitely many possible charge levels for the vehicle), and assuming that how much you pay for charging depends on the amount of charging you do but not your past history (for instance, you are not accruing credits toward some sort of discount), then yes, you can solve your problem using DP ... in theory. Since you need to break the problem into stages (every hour, every day, ...) and define a state space for each stage, the primary practical question is how large the overall number of states gets.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-10-11T15:37:22.920" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11102" PostTypeId="1" AcceptedAnswerId="11103" CreationDate="2023-10-12T12:31:50.303" Score="1" ViewCount="94" Body="&lt;p&gt;So in the deterministic version of Benders, the main process works like this:&lt;/p&gt;&#xA;&lt;p&gt;I initialize my x-vector (Integer variables from the master problem) and solve the dual subproblem (SP).&lt;/p&gt;&#xA;&lt;p&gt;I add an optimality cut/feasibility cut to the master problem (MP), depending on if the SP was unbounded or optimal.&lt;/p&gt;&#xA;&lt;p&gt;Then I resolve the MP, pass that solution again to the SP and repeat this until the objective value of the MP = objective of the SP.&lt;/p&gt;&#xA;&lt;p&gt;Now, I want to tackle the stochastic version of Benders.&lt;/p&gt;&#xA;&lt;p&gt;For this, I now have different scenarios and the process looks like this:&lt;/p&gt;&#xA;&lt;p&gt;I initialize the algorithm with a MP solution.&#xA;I pass that on to the SPs, one per scenario.&lt;/p&gt;&#xA;&lt;p&gt;I solve the SP for each scenario.&#xA;I add cuts to the MP the same as before:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;feasibility cut if the SP is unbounded&lt;/li&gt;&#xA;&lt;li&gt;optimality cut if the SP is optimal but not globally optimal&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now, I struggle with my implementation because I don't understand how the stopping criteria of the algorithm works. How do I check global optimality when I don't have &amp;quot;one&amp;quot; solution value anymore for the SP? (Since I can't check MP = SP)&lt;/p&gt;&#xA;&lt;p&gt;And if for one scenario, the SP is globally optimal, what do I do? Do I just skip it and go to the next scenario? Or do I skip the whole iteration?&lt;/p&gt;&#xA;&lt;p&gt;Overall, what is the stopping criteria for the stochastic version of Benders?&lt;/p&gt;&#xA;" OwnerUserId="12130" LastActivityDate="2024-03-10T20:07:35.960" Title="How do I check convergence in stochastic Benders?" Tags="|mixed-integer-programming|algorithms|stochastic-programming|benders-decomposition|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11103" PostTypeId="2" ParentId="11102" CreationDate="2023-10-12T18:55:54.620" Score="1" Body="&lt;p&gt;Let the objective of the &lt;strong&gt;master problem&lt;/strong&gt; (the first-stage problem of stochastic programming) be&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{Minimize}~ cx + \frac{1}{|S|} \sum_{s \in S} \theta_s&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\theta_s$&lt;/span&gt; approximates the second-stage objective by Benders optimality cuts gradually.&lt;/p&gt;&#xA;&lt;p&gt;Then let the objective of the &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;th &lt;strong&gt;sub problem&lt;/strong&gt; (the second-stage problem of stochastic programming) be&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{Minimize}~ d_s y_s&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which are solved by fixing the fist-stage decisions to &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The Benders algorithm terminates when&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;c \bar{x} + \frac{1}{|S|} \sum_{s \in S} \bar{\theta_s} = c \bar{x} + \frac{1}{|S|} \sum_{s \in S} d_s y_s&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The global optimum is reached when (i) the first-stage solution is feasible for all the scenarios; (ii) the objective of the master problem and the subproblems meet the requirement specified by the above equation.&lt;/p&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2023-10-12T18:55:54.620" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11104" PostTypeId="1" AcceptedAnswerId="11112" CreationDate="2023-10-12T20:34:29.917" Score="4" ViewCount="147" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\DeclareMathOperator*{\argmin}{\arg\!\min}$&lt;/span&gt;Consider the convex function &lt;span class=&quot;math-container&quot;&gt;$f : X \to \mathbb R$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$X \subseteq \mathbb R^n$&lt;/span&gt; is a convex set. Define the functions &lt;span class=&quot;math-container&quot;&gt;$g_\ell : X^m \times \Delta \to \mathbb R$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_u : X^m \times \Delta \to \mathbb R$&lt;/span&gt; as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;g_\ell(x_1,\dots,x_m,\alpha_1,\dots,\alpha_m) &amp;amp;= f\left(\sum_{i=1}^m \alpha_i \cdot x_i\right) \\&#xA;g_u(x_1,\dots,x_m,\alpha_1,\dots,\alpha_m) &amp;amp;= \sum_{i=1}^m \alpha_i \cdot f\left(x_i\right)&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\Delta$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;-dimensional standard simplex &lt;span class=&quot;math-container&quot;&gt;$\{x \in \mathbb R^m \mid \sum_{i=1}^m x_i = 1\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(\alpha_1,\dots,\alpha_m) \in \Delta$&lt;/span&gt;. For brevity, we let &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m) = x_{1:m}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(\alpha_1,\dots,\alpha_m) = \alpha_{1:m}$&lt;/span&gt; such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;g_\ell(x_{1:m},\alpha_{1:m}) &amp;amp;= g_\ell(x_1,\dots,x_m,\alpha_1,\dots,\alpha_m) \\&#xA;g_u(x_{1:m},\alpha_{1:m}) &amp;amp;= g_u(x_1,\dots,x_m,\alpha_1,\dots,\alpha_m)&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Because &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is convex, then by Jensen's inequality,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;g_\ell(x_{1:m},\alpha_{1:m}) \leq g_u(x_{1:m},\alpha_{1:m})&#xA;$$&lt;/span&gt;&#xA;for every &lt;span class=&quot;math-container&quot;&gt;$x_{1:m} \in X^m$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m} \in \Delta$&lt;/span&gt;. For an arbitrary choice of &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m}$&lt;/span&gt;, I'm interested in conditions on &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; such that the values of &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m) \in X^m$&lt;/span&gt; that minimize &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt; for this choice of &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m}$&lt;/span&gt; are the same values that minimize &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; for the same choice of &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m}$&lt;/span&gt;. That is,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\argmin_{x_{1:m}} \ g_\ell(x_{1:m},\alpha_{1:m}) = \argmin_{x_{1:m}} \ g_u(x_{1:m},\alpha_{1:m})&#xA;$$&lt;/span&gt;Or, if this is not possible,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left\|\argmin_{x_{1:m}} \ g_\ell(x_{1:m},\alpha_{1:m}) - \argmin_{x_{1:m}} \ g_u(x_{1:m},\alpha_{1:m})\right\|_2 &amp;lt; \varepsilon&#xA;$$&lt;/span&gt;for some &lt;span class=&quot;math-container&quot;&gt;$\varepsilon &amp;gt; 0$&lt;/span&gt;. The trivial case is when &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is affine on &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;, but I'm looking for less strict conditions (such as &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; being strictly monotone increasing).&lt;/p&gt;&#xA;&lt;p&gt;More precisely, if we let &lt;span class=&quot;math-container&quot;&gt;$y_{1:m}^* = \argmin_{x_{1:m}} g_\ell(x_{1:m},\alpha_{1:m})$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$g_\ell(y_{1:m}^*,\alpha_{1:m}) \leq g_\ell(x_{1:m},\alpha_{1:m})$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$x_{1:m} \in X^m$&lt;/span&gt;, then, with additional conditions on &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, we want to show that  &lt;span class=&quot;math-container&quot;&gt;$g_u(y_{1:m}^*,\alpha_{1:m}) \leq g_u(x_{1:m},\alpha_{1:m})$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$x_{1:m} \in X^m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the figure below, I plotted &lt;span class=&quot;math-container&quot;&gt;$g_\ell(x,y) = f(\alpha x + (1-\alpha)y)$&lt;/span&gt; (red surface) and &lt;span class=&quot;math-container&quot;&gt;$g_u(x,y) = \alpha f(x) + (1-\alpha)f(y)$&lt;/span&gt; (blue surface) with &lt;span class=&quot;math-container&quot;&gt;$f(x) = x^2$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$(x,y) \in [0,1]^2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha = 0.5$&lt;/span&gt;. We can see that the minimum occurs at the same location for both &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt;. I want to know if this holds more generally under certain conditions.&lt;/p&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/2Q05U.png&quot; width=&quot;600&quot;&gt;&#xA;&lt;p&gt;Using only the assumption that &lt;span class=&quot;math-container&quot;&gt;$g_\ell(y_{1:m}^*,\alpha_{1:m}) \leq g_\ell(x_{1:m},\alpha_{1:m})$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$x_{1:m} \in X^m$&lt;/span&gt; and the fact that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is convex, we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;g_\ell(y_{1:m}^*,\alpha_{1:m}) &amp;amp;\leq g_\ell(x_{1:m},\alpha_{1:m}) \\&#xA;f\left(\sum_{i=1}^m \alpha_i \cdot y_i^*\right) &amp;amp;\leq f\left(\sum_{i=1}^m \alpha_i \cdot x_i\right) \\&#xA;&amp;amp;\leq \sum_{i=1}^m \alpha_i \cdot f\left(x_i\right) \\&#xA;&amp;amp;= g_u(x_{1:m},\alpha_{1:m})&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;for every &lt;span class=&quot;math-container&quot;&gt;$x_{1:m} \in X^m$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$g_\ell(y_{1:m}^*,\alpha_{1:m}) \leq g_u(x_{1:m},\alpha_{1:m})$&lt;/span&gt;. Using a similar argument, we can also conclude that &lt;span class=&quot;math-container&quot;&gt;$g_\ell(y_{1:m}^*,\alpha_{1:m}) \leq g_u(y_{1:m}^*,\alpha_{1:m})$&lt;/span&gt;, but I'm unable to relate these two inequalities together to conclude that &lt;span class=&quot;math-container&quot;&gt;$g_u(y_{1:m}^*,\alpha_{1:m}) \leq g_u(x_{1:m},\alpha_{1:m})$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2023-10-23T19:26:53.663" LastActivityDate="2023-10-23T19:33:04.617" Title="Does minimizing the upper bound due to Jensen's inequality yield an equivalent solution?" Tags="|convexity|relaxation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11105" PostTypeId="1" CreationDate="2023-10-13T15:02:01.477" Score="1" ViewCount="90" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HLMAZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HLMAZ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the constraints below, why have they used the big M? What do we look for in order to identify the big M in other questions?&lt;/p&gt;&#xA;" OwnerUserId="12648" LastEditorUserId="500" LastEditDate="2023-10-13T15:32:22.973" LastActivityDate="2023-10-13T15:32:22.973" Title="Mixed Integer programming, the big M" Tags="|mixed-integer-programming|indicator-constraints|big-m|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11106" PostTypeId="2" ParentId="11105" CreationDate="2023-10-13T15:16:26.277" Score="1" Body="&lt;p&gt;This is a common modeling techniques in operations research.&lt;/p&gt;&#xA;&lt;p&gt;Another interpretation is &lt;strong&gt;if-then relationship&lt;/strong&gt; or &lt;strong&gt;indicator&lt;/strong&gt;. When you have to count how many days you have to setup to produce then you can introduce this big-M formulation.&lt;/p&gt;&#xA;&lt;p&gt;In this case, you can imagine that the big-M value is your &lt;strong&gt;maximum production capacity&lt;/strong&gt;, since you never hope the value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; would exceed your production capacity.&lt;/p&gt;&#xA;&lt;p&gt;Of course this big-M value should be always valid for your entire problem, otherwise you would obtain wrong counting number on setup variables.&lt;/p&gt;&#xA;" OwnerUserId="12370" LastActivityDate="2023-10-13T15:16:26.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11107" PostTypeId="1" CreationDate="2023-10-13T20:57:36.393" Score="0" ViewCount="67" Body="&lt;p&gt;I am seeking guidance for a study in which I have the coordinates of 3 wastewater treatment plants (WTPs) shown in blue, and 54 farms shown in red (see the figure below). My goal is to calculate potential locations for the installation of waste treatment centers, taking into consideration the distances between the WTPs and farms. The main idea is to send sludge to these centers and, subsequently, produce fertilizer in these locations and deliver it to the farms. Therefore, these locations need to be strategically positioned to meet the needs of both the WTPs and the farms.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Os7j7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Os7j7.png&quot; alt=&quot;Map 1&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have calculated the average distances between the WTPs and the farms and obtained the following result:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; distance_mean&#xA;[1] 19.18519 20.96296 20.12963&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The mean of the average distances is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; mean(distance_mean)&#xA;[1] 20.09259&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My initial approach was to create random points on the map, taking into account the average distance between the WTPs and farms, which in this case is 20 km. This led to the identification of 5 potential installation sites, indicated in green on the figure.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3Z2oU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3Z2oU.png&quot; alt=&quot;Map 2&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am looking for additional suggestions or alternatives to determine these locations based on distance. Any ideas?&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; To calculate the distances, I have the geographical coordinates of each location, and I used the &lt;code&gt;distm&lt;/code&gt; function in R. To generate maps and random points, I used &lt;code&gt;QGIS&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12649" LastEditorUserId="12649" LastEditDate="2023-10-14T13:28:01.710" LastActivityDate="2023-10-14T13:28:01.710" Title="Guidance on selecting locals for waste treatment installation" Tags="|facility-location|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="11108" PostTypeId="1" AcceptedAnswerId="11123" CreationDate="2023-10-14T02:27:22.690" Score="1" ViewCount="383" Body="&lt;p&gt;I hope that this Stack Exchange channel is the right place for this.&lt;/p&gt;&#xA;&lt;p&gt;I'm trying to analyze a multiobjective optimization problem. I'm wanting to use the &lt;a href=&quot;https://www.researchgate.net/figure/Hypervolume-indicator-in-two-dimensions-for-a-set-A-a-1-a-4-R-2_fig1_235709701&quot; rel=&quot;nofollow noreferrer&quot;&gt;hypervolume calculation&lt;/a&gt; to benchmark the quality of my results. I'm working in Python, and can't seem to figure out a package that I can install that will do this. I'm wanting to find a package with a function &lt;code&gt;hypervolume&lt;/code&gt; that does the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;hv = hypervolume(pointset, reference_point)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;I've looked briefly online and tried to install &lt;a href=&quot;https://esa.github.io/pygmo2/install.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;PyGMO&lt;/a&gt; but I can't get this to install. It keeps raising the error: 'the following packages are causing the inconsistency'. I've also tried using the &lt;a href=&quot;https://deap.readthedocs.io/en/master/_modules/deap/benchmarks/tools.html?highlight=hypervolume#&quot; rel=&quot;nofollow noreferrer&quot;&gt;DEAP&lt;/a&gt; package, but can't get it to work properly. Has anyone had experience calculating hypervolume in Python before? Any advice would be welcome.&lt;/p&gt;&#xA;" OwnerUserId="4229" LastActivityDate="2023-10-17T06:05:29.127" Title="How to get hypervolume calculation for Pareto Front in python?" Tags="|python|multi-objective-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11109" PostTypeId="1" CreationDate="2023-10-14T05:24:04.997" Score="2" ViewCount="127" Body="&lt;p&gt;I have been struggling with the formulation of logic constraints. Is there any source you would recommend to understand the topic better or trick of formulation of the constraints?&lt;/p&gt;&#xA;" OwnerUserId="12648" LastEditorUserId="491" LastEditDate="2023-12-01T17:09:15.953" LastActivityDate="2023-12-01T17:09:15.953" Title="logic constraints for IP model" Tags="|mixed-integer-programming|linear-programming|reference-request|logical-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11110" PostTypeId="2" ParentId="11109" CreationDate="2023-10-14T07:00:15.220" Score="2" Body="&lt;p&gt;Besides the very useful reference mentioned by @RobPratt, the following might have also been good starting points:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://yalmip.github.io/tutorial/logicprogramming&quot; rel=&quot;nofollow noreferrer&quot;&gt;Logics and integer-programming representations by YALMIP&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/4414392016529-How-do-I-model-conditional-statements-in-Gurobi-&quot; rel=&quot;nofollow noreferrer&quot;&gt;How do I model conditional statements in Gurobi?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/10731/systematic-references-on-linearizing-conditional-logical-expressions&quot;&gt;Systematic references on linearizing conditional/logical expressions&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/231/when-to-use-indicator-constraints-versus-big-m-approaches-in-solving-mixed-int/259#259&quot;&gt;When to use indicator constraints versus big-M approaches&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;It already would be worth to search the community by the same topics to find lots of case studies.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-10-14T07:00:15.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11111" PostTypeId="1" CreationDate="2023-10-14T09:14:48.437" Score="2" ViewCount="31" Body="&lt;p&gt;Suppose, there exists a scheduling problem &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, in this case a single resource, with the following descriptions:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \text{conv(S)} = \{x \in \mathbb{R}^n \ | \ \forall \lambda_{i} \in \mathbb{R}^{n+}, \ x = \sum_{i=1}^{|s|} \lambda_{i} S_{i}, \ \sum_{i=1}^{|s|} \lambda_{i} = 1 \} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is the convex hull of &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;. Now, the set of feasible schedules for a set of jobs &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; with release dates would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ S^{SRR} = \{S \in \mathbb{R}^J \ | \ S_{j} \geq r_{j}, \ (S_{i} \geq S_{j} + l_{i,j}) \lor (S_{j} \geq S_{i} + l_{j,i}), \ \forall i,j \in J: i \not = j \} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In such a case, &lt;em&gt;Prof. Balas&lt;/em&gt; derived facet-defining inequalities for a subset of jobs &lt;span class=&quot;math-container&quot;&gt;$K \subseteq J$&lt;/span&gt; induces also a facet for &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt;. Now, the following inequality is a nontrivial facet inducing inequality for &lt;span class=&quot;math-container&quot;&gt;$P( \{ i,j\} )$&lt;/span&gt;, if and only if &lt;span class=&quot;math-container&quot;&gt;$(-d_{j,i} \lt L_{j} - L_{i} \lt d_{i,j})$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ (d_{i,j} + L_i − L_j )S_i + (d_{j,i} + L_j − L_i )S_j \geq d_{i,j} d_{j,i} + L_i d_{j,i} + L_j d_{i,j} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where, &lt;span class=&quot;math-container&quot;&gt;$d_{i,j}$&lt;/span&gt; is a processing time, and &lt;span class=&quot;math-container&quot;&gt;$L_{j}$&lt;/span&gt; is a release date. In some cases, I have seen the above inequality has been written as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ (l_{i,j} + r_i − r_j )S_i + (l_{j,i} + r_j − r_i )S_j \geq d_{i,j} d_{j,i} + L_i d_{j,i} + L_j d_{i,j} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Now, my questions are:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If this is a valid inequality for such a problem, is it possible to use that directly in the above-mentioned set of feasible schedules? If so, is there any paper or other references to illustrate this?&lt;/li&gt;&#xA;&lt;li&gt;Why, in some cases, the parameters are different in the LHS and RHS?&lt;/li&gt;&#xA;&lt;li&gt;Is it possible to apply this inequality in the general form? I mean e.g. in the parallel resource schedule?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://link.springer.com/chapter/10.1007/BFb0121051&quot; rel=&quot;nofollow noreferrer&quot;&gt;ON THE FACIAL STRUCTURE OF SCHEDULING POLYHEDRA - Egon BALAS&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-10-14T09:14:48.437" Title="The facet-defining inequalities for a single resource scheduling problem" Tags="|mixed-integer-programming|scheduling|polyhedra|valid-inequalities|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11112" PostTypeId="2" ParentId="11104" CreationDate="2023-10-14T18:11:29.823" Score="1" Body="&lt;h2&gt;Summary&lt;/h2&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\DeclareMathOperator*{\argmin}{\arg\!\min}$&lt;/span&gt;It turns out that, for any &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m} \in \Delta$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt; is minimized with respect to &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m)$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$f(x_i) = F^*$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i = 1,\dots,m$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$F^* = \min_x f(x)$&lt;/span&gt;. Moreover, &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is not required to be convex, but is instead required to have at least one global minimum such that &lt;span class=&quot;math-container&quot;&gt;$F^*$&lt;/span&gt; exists (for example, &lt;span class=&quot;math-container&quot;&gt;$f(x) = -\exp(-x^2)$&lt;/span&gt; has one global minimum at &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt;, but it is neither convex nor concave on &lt;span class=&quot;math-container&quot;&gt;$X = \mathbb R$&lt;/span&gt;). This includes the cases when &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; has a countable and uncountable number of global minima. Therefore, for the same choice of &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m} \in \Delta$&lt;/span&gt;, the optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{x_{1:m}} \quad &amp;amp; g_u(x_{1:m},\alpha_{1:m})&#xA;\end{aligned}&#xA;\end{equation}&#xA;$$&lt;/span&gt;&#xA;is equivalent to the optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{x_{1:m}} \quad &amp;amp; g_\ell(x_{1:m},\alpha_{1:m}), \\&#xA;\textrm{s.t.} \quad &amp;amp; \forall i \in \{1,\dots,m\}, f(x_i) = F^*&#xA;\end{aligned}&#xA;\end{equation}&#xA;$$&lt;/span&gt;&#xA;We now discuss the details of this for the case when &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; has a single global minimum, a countable number of global minima, and an uncountable number of global minima.&lt;/p&gt;&#xA;&lt;h2&gt;Single global minimum&lt;/h2&gt;&#xA;&lt;p&gt;First, suppose that &lt;span class=&quot;math-container&quot;&gt;$f : X \to \mathbb R$&lt;/span&gt; has exactly one global minimizer &lt;span class=&quot;math-container&quot;&gt;$z^* \in X$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$f(z^*) \leq f(x)$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$x \in X$&lt;/span&gt;. Second, fix any &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m} \in \Delta$&lt;/span&gt;. Then, note that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\min_{x_{1:m}} g_u(x_{1:m},\alpha_{1:m}) &amp;amp;= \min_{x_{1:m}} \sum_{i=1}^m \alpha_i \cdot f\left(x_i\right) \\&#xA;&amp;amp;= \sum_{i=1}^m \alpha_i \cdot \min_{x_i} f\left(x_i\right) \\&#xA;&amp;amp;= \sum_{i=1}^m \alpha_i \cdot f(z^*) \\&#xA;&amp;amp;= f(z^*) \sum_{i=1}^m \alpha_i \\&#xA;&amp;amp;= f(z^*)&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;and so, for any &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m} \in \Delta$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\argmin_{x_{1:m}} g_u(x_{1:m},\alpha_{1:m}) = (z^*,\dots,z^*)$&lt;/span&gt;. Then, for the same choice of &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m} \in \Delta$&lt;/span&gt;, note that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;g_\ell(x_{1:m},\alpha_{1:m}) = f\left(\sum_{i=1}^m \alpha_i \cdot x_i\right)&#xA;$$&lt;/span&gt;&#xA;is minimized when&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i=1}^m \alpha_i \cdot x_i = z^*&#xA;$$&lt;/span&gt;&#xA;For this choice of &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m}$&lt;/span&gt;, there are infinitely many values of &lt;span class=&quot;math-container&quot;&gt;$x_{1:m} \in X^m$&lt;/span&gt; for which this equation is satisfied. However, we are looking for the unique &lt;span class=&quot;math-container&quot;&gt;$x_{1:m}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$g_u(x_{1:m},\alpha_{1:m})$&lt;/span&gt; is also minimized. We have already established above that this occurs when &lt;span class=&quot;math-container&quot;&gt;$x_{1:m} = (x_1,\dots,x_m) = (z^*,\dots,z^*)$&lt;/span&gt;. By plugging this into the equation above, we get&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\sum_{i=1}^m \alpha_i \cdot z^* &amp;amp;= z^* \\&#xA;z^* \cdot \sum_{i=1}^m \alpha_i &amp;amp;= z^* \\&#xA;z^* &amp;amp;= z^*&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;and so &lt;span class=&quot;math-container&quot;&gt;$x_{1:m} = (z^*,\dots,z^*)$&lt;/span&gt; is the unique minimizer of both &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt;. That is, the solution to the optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{x_{1:m}} \quad &amp;amp; g_\ell(x_{1:m},\alpha_{1:m}), \\&#xA;\textrm{s.t.} \quad &amp;amp; \forall i \in \{1,\dots,m\}, x_i = z^*&#xA;\end{aligned}&#xA;\end{equation}&#xA;$$&lt;/span&gt;&#xA;is equivalent to the solution to the optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{x_{1:m}} \quad &amp;amp; g_u(x_{1:m},\alpha_{1:m})&#xA;\end{aligned}&#xA;\end{equation}&#xA;$$&lt;/span&gt;&#xA;for every &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m} \in \Delta$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt; is the global minimizer of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, in the case when determining &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt; directly is difficult, we could also solve the following equivalent optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{x_{1:m}} \quad &amp;amp; g_\ell(x_{1:m},\alpha_{1:m}), \\&#xA;\textrm{s.t.} \quad &amp;amp; Ax = 0&#xA;\end{aligned}&#xA;\end{equation}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb R^{nm}$&lt;/span&gt; is the block vector&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x = \begin{bmatrix}x_1 \\ x_2 \\ \vdots \\ x_m\end{bmatrix} \tag{1}&#xA;$$&lt;/span&gt;&#xA;and &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb R^{n(m-1) \times nm}$&lt;/span&gt; is a block matrix such that its &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; element is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;A_{ij} = \begin{cases}I, &amp;amp; i = j \\ -I, &amp;amp; i = j - 1 \\ 0, &amp;amp; \text{otherwise}\end{cases} \tag{2}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt; identity matrix and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt; zero matrix. The &lt;span class=&quot;math-container&quot;&gt;$Ax = 0$&lt;/span&gt; constraint is equivalent to the following set of constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\{x_i = x_j \mid \forall (i,j) \in \{1,\dots,m\}^2,i = j-1\}&#xA;$$&lt;/span&gt;&#xA;The reason that this optimization problem is equivalent to the previous one is that the constraint &lt;span class=&quot;math-container&quot;&gt;$\forall i \in \{1,\dots,m\}, x_i = z^*$&lt;/span&gt; in the previous problem is an element of the feasible set induced by the constraint &lt;span class=&quot;math-container&quot;&gt;$Ax = 0$&lt;/span&gt;, and that this element is a global minimizer of &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&lt;p&gt;To verify the preceding arguments, consider the example where &lt;span class=&quot;math-container&quot;&gt;$X = [-1,1]$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f(x) = x^2$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$g_\ell : [-1,1]^2 \to \mathbb R$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_u : [-1,1]^2 \to \mathbb R$&lt;/span&gt; are defined as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;g_\ell(x_1,x_2) &amp;amp;= \left(\alpha \cdot x_1 + (1-\alpha) \cdot x_2\right)^2 \\&#xA;g_u(x_1,x_2) &amp;amp;= \alpha \cdot x_1^2 + (1-\alpha) \cdot x_2^2&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\alpha \in [0,1]$&lt;/span&gt;. The global minimum of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; occurs at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. We plot &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; (red) and &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt; (blue) in the figure below for &lt;span class=&quot;math-container&quot;&gt;$\alpha = 0.5$&lt;/span&gt;, where we also show the line &lt;span class=&quot;math-container&quot;&gt;$\alpha \cdot x_1 + (1-\alpha) \cdot x_2 = 0$&lt;/span&gt; in green. We see that both &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt; are minimized when &lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2) = (0,0)$&lt;/span&gt; as expected.&lt;/p&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/KE24Y.png&quot; width=&quot;500&quot;&gt;&#xA;&lt;h2&gt;Countable number of global minima&lt;/h2&gt;&#xA;&lt;p&gt;We now consider the case when &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; has a countable number of global minima. Let the unique global minimizers of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; be &lt;span class=&quot;math-container&quot;&gt;$z_1^*,\dots,z_K^*$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$K &amp;gt; 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$K \in \mathbb N$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$f(z_1^*) = \cdots = f(z_K^*) = F^* \in \mathbb R$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f(z_i^*) \leq f(x)$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb R^n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i = 1,\dots,K$&lt;/span&gt;. As before, we want to determine the cases when the minimizers of &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt; are equivalent for any &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m}$&lt;/span&gt;. We proceed as follows. First, fix any &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m} \in \Delta$&lt;/span&gt;. Then,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\min_{x_{1:m}} g_u(x_{1:m},\alpha_{1:m}) &amp;amp;= \min_{x_{1:m}} \sum_{i=1}^m \alpha_i \cdot f\left(x_i\right) \\&#xA;&amp;amp;= \sum_{i=1}^m \alpha_i \cdot \min_{x_i} f\left(x_i\right) \tag{3} \\&#xA;&amp;amp;= \sum_{i=1}^m \alpha_i \cdot F^* \\&#xA;&amp;amp;= F^* \sum_{i=1}^m \alpha_i \\&#xA;&amp;amp;= F^*&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Unfortunately, because &lt;span class=&quot;math-container&quot;&gt;$K &amp;gt; 1$&lt;/span&gt;, we can no longer conclude that &lt;span class=&quot;math-container&quot;&gt;$\argmin_{x_{1:m}} g_u(x_{1:m},\alpha_{1:m}) = (z^*,\dots,z^*)$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m} \in \Delta$&lt;/span&gt; as before. The reason is that &lt;span class=&quot;math-container&quot;&gt;$F^*$&lt;/span&gt; is achieved by &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; different minimizers of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;. Moreover, because &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; above consists of a convex combination of &lt;span class=&quot;math-container&quot;&gt;$\min_{x_i} f(x_i)$&lt;/span&gt;, then we can choose one of &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; minimizers for each of the &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; elements in this combination. So, there exist a total of &lt;span class=&quot;math-container&quot;&gt;$K^m$&lt;/span&gt; global minimizers for &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt;, each achieving the minimum &lt;span class=&quot;math-container&quot;&gt;$F^*$&lt;/span&gt;. The set of all of these global minimizers is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\{z_1^*,\dots,z_K^*\}^m = \underbrace{\{z_1^*,\dots,z_K^*\} \times \cdots \times \{z_1^*,\dots,z_K^*\}}_{\text{$m$ times}}&#xA;$$&lt;/span&gt;&#xA;Then, for the same choice of &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m} \in \Delta$&lt;/span&gt;, note that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;g_\ell(x_{1:m},\alpha_{1:m}) = f\left(\sum_{i=1}^m \alpha_i \cdot x_i\right)&#xA;$$&lt;/span&gt;&#xA;is minimized when any one of the following &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; equations is satisfied:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\sum_{i=1}^m \alpha_i \cdot x_i &amp;amp;= z_1^* \\&#xA;&amp;amp;\vdots \\&#xA;\sum_{i=1}^m \alpha_i \cdot x_i &amp;amp;= z_K^*&#xA;\end{align} \tag{4}&#xA;$$&lt;/span&gt;&#xA;As before, there are infinitely many values of &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m)$&lt;/span&gt; for which one of the &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; equations in &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; is satisfied. That is, for this choice of &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m} \in \Delta$&lt;/span&gt;, the values of &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m)$&lt;/span&gt; that minimize &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; all lie on the &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-dimensional lines defined by the &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; equations in &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, we are looking for the values of &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m)$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$g_u(x_{1:m},\alpha_{1:m})$&lt;/span&gt; is also minimized. We have already established above that this occurs when &lt;span class=&quot;math-container&quot;&gt;$x_{1:m} \in \{z_1^*,\dots,z_K^*\}^m$&lt;/span&gt;. Therefore, we search for &lt;span class=&quot;math-container&quot;&gt;$x_{1:m} \in \{z_1^*,\dots,z_K^*\}^m$&lt;/span&gt; such that one of the &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; equations in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; is satisfied. In the set &lt;span class=&quot;math-container&quot;&gt;$\{z_1^*,\dots,z_K^*\}^m$&lt;/span&gt;, there are two kinds of points &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m)$&lt;/span&gt; that satisfy one of the equations in &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If for each &lt;span class=&quot;math-container&quot;&gt;$z_j^* \in \{z_1^*,\dots,z_K^*\}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z_j^*$&lt;/span&gt; is &lt;strong&gt;not&lt;/strong&gt; in the convex hull of &lt;span class=&quot;math-container&quot;&gt;$z_1^*,\dots,z_{j-1}^*,z_{j+1}^*,\dots,z_K^*$&lt;/span&gt; (i.e. &lt;span class=&quot;math-container&quot;&gt;$z_j^*$&lt;/span&gt; cannot be expressed as a convex combination of &lt;span class=&quot;math-container&quot;&gt;$z_1^*,\dots,z_{j-1}^*,z_{j+1}^*,\dots,z_K^*$&lt;/span&gt;), then there are only &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; points defined as &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m) = (z_i^*,\dots,z_i^*)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i = 1,\dots,K$&lt;/span&gt; that satisfy one of the equations in &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;However, if there exist &lt;span class=&quot;math-container&quot;&gt;$z_j^*$&lt;/span&gt; that are in the convex hull of &lt;span class=&quot;math-container&quot;&gt;$z_1^*,\dots,z_{j-1}^*,z_{j+1}^*,\dots,z_K^*$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$$\alpha_1 z_1^* + \dots + \alpha_{j-1}z_{j-1}^*,\alpha_{j+1}z_{j+1}^*,\dots,\alpha_{K}z_K^* = z_j^*$$&lt;/span&gt; then, in addition to the &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; points defined as &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m) = (z_i^*,\dots,z_i^*)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i = 1,\dots,K$&lt;/span&gt;, there are other points in &lt;span class=&quot;math-container&quot;&gt;$\{z_1^*,\dots,z_K^*\}$&lt;/span&gt; that satisfy one of the equations in &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt;. These are the points that, when combined as a convex combination, yields &lt;span class=&quot;math-container&quot;&gt;$z_j^*$&lt;/span&gt;.&#xA;In both cases, the &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; points defined as &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m) = (z_i^*,\dots,z_i^*)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i = 1,\dots,K$&lt;/span&gt; will minimize both &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Therefore, we can proceed in one of two ways.&lt;/p&gt;&#xA;&lt;h3&gt;Solution method 1&lt;/h3&gt;&#xA;&lt;p&gt;We solve the following &lt;a href=&quot;https://or.stackexchange.com/q/6545/7263&quot;&gt;integer program&lt;/a&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{x_{1:m}} \quad &amp;amp; g_\ell(x_{1:m},\alpha_{1:m}), \\&#xA;\textrm{s.t.} \quad &amp;amp; (x_1,\dots,x_m) \in \{z_1^*,\dots,z_K^*\}^m&#xA;\end{aligned}&#xA;\end{equation} \tag{5}&#xA;$$&lt;/span&gt;&#xA;which is equivalent to solving&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{x_{1:m}} \quad &amp;amp; g_u(x_{1:m},\alpha_{1:m}), \\&#xA;\textrm{s.t.} \quad &amp;amp; (x_1,\dots,x_m) \in \bigoplus_{i=1}^K \left\{(x_1,\dots,x_m) \in \mathbb R^{n \times m} \Bigg| \sum_{j=1}^m \alpha_j \cdot x_j = z_i^*\right\}&#xA;\end{aligned}&#xA;\end{equation} \tag{6}&#xA;$$&lt;/span&gt;&#xA;where the &lt;span class=&quot;math-container&quot;&gt;$\oplus$&lt;/span&gt; symbol represents the exclusive OR operation on the &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; sets. We can re-write &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt; as an integer program as follows. Define the binary variables &lt;span class=&quot;math-container&quot;&gt;$y_1,\dots,y_K$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$y_i \in \{0,1\}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i = 1,\dots,K$&lt;/span&gt;. Then, &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt; can be re-written as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{x_{1:m}} \quad &amp;amp; g_u(x_{1:m},\alpha_{1:m}), \\&#xA;\textrm{s.t.} \quad &amp;amp; \forall i \in \{1,\dots,K\}, y_i \in \{0,1\} \\&#xA;\quad &amp;amp; \sum_{i=1}^K y_i = 1 \\&#xA;\quad &amp;amp; \sum_{i=1}^m \alpha_i \cdot x_i = \sum_{j=1}^K y_j \cdot z_j^*&#xA;\end{aligned}&#xA;\end{equation} \tag{7}&#xA;$$&lt;/span&gt;&#xA;There are two disadvantages of this solution method. The first one is that the constraints imposed in &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt; will result in the need to solve integer programs, which are difficult in general. This may or may not be important in practice. We relax this difficulty in solution method 2 below.&lt;/p&gt;&#xA;&lt;p&gt;The second disadvantage is that the solution &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m)$&lt;/span&gt; that we obtain from &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; will not necessarily be equal to the solution obtained from &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt;. The reason is that any one of the &lt;span class=&quot;math-container&quot;&gt;$K^m$&lt;/span&gt; solutions that solve &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; will also solve &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt;. Therefore, we can pick one of these solutions to solve &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; and a different one to solve &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt;. Although the solutions &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m)$&lt;/span&gt; obtained from &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt; will necessarily minimize both &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt;, they will not necessarily be the same.&lt;/p&gt;&#xA;&lt;h3&gt;Solution method 2&lt;/h3&gt;&#xA;&lt;p&gt;Because the &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; points defined as &lt;span class=&quot;math-container&quot;&gt;$(x_1,\dots,x_m) = (z_i^*,\dots,z_i^*)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i = 1,\dots,K$&lt;/span&gt; will necessarily minimize both &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt;, then instead of solving &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt;, we solve&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{x_{1:m}} \quad &amp;amp; g_\ell(x_{1:m},\alpha_{1:m}), \\&#xA;\textrm{s.t.} \quad &amp;amp; (x_1,\dots,x_m) \in \{(z_1^*,\dots,z_1^*),\dots,(z_K^*,\dots,z_K^*)\}&#xA;\end{aligned}&#xA;\end{equation}&#xA;$$&lt;/span&gt;&#xA;or equivalently&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{x_{1:m}} \quad &amp;amp; g_\ell(x_{1:m},\alpha_{1:m}), \\&#xA;\textrm{s.t.} \quad &amp;amp; Ax = 0&#xA;\end{aligned}&#xA;\end{equation} \tag{8}&#xA;$$&lt;/span&gt;&#xA;where the block matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and the block vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are defined as in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; above. Solving &lt;span class=&quot;math-container&quot;&gt;$(8)$&lt;/span&gt; is equivalent to solving&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{x_{1:m}} \quad &amp;amp; g_u(x_{1:m},\alpha_{1:m}), \\&#xA;\textrm{s.t.} \quad &amp;amp; (x_1,\dots,x_m) \in \{(z_1^*,\dots,z_1^*),\dots,(z_K^*,\dots,z_K^*)\}&#xA;\end{aligned}&#xA;\end{equation}&#xA;$$&lt;/span&gt;&#xA;or equivalently&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{x_{1:m}} \quad &amp;amp; g_u(x_{1:m},\alpha_{1:m}), \\&#xA;\textrm{s.t.} \quad &amp;amp; Ax = 0&#xA;\end{aligned}&#xA;\end{equation} \tag{9}&#xA;$$&lt;/span&gt;&#xA;where the block matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and the block vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; are defined as in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; above. Compared to solution method 1, the advantage of solution method 2 is that we are no longer solving integer programs, as the constraints in &lt;span class=&quot;math-container&quot;&gt;$(8)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(9)$&lt;/span&gt; are linear. However, the disadvantage of solution method 2 compared to solution method 1 is that not all the valid solutions can be obtained by solving &lt;span class=&quot;math-container&quot;&gt;$(8)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(9)$&lt;/span&gt;. This is because the feasible sets in &lt;span class=&quot;math-container&quot;&gt;$(8)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(9)$&lt;/span&gt; are restricted to &lt;span class=&quot;math-container&quot;&gt;$\{(z_1^*,\dots,z_1^*),\dots,(z_K^*,\dots,z_K^*)\}$&lt;/span&gt;, which is a subset of the larger solution set &lt;span class=&quot;math-container&quot;&gt;$\{z_1^*,\dots,z_K^*\}^m$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&lt;p&gt;To verify the preceding arguments, consider the example where &lt;span class=&quot;math-container&quot;&gt;$X = [-2,2]$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f(x) = (x-1)^2(x+1)^2$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\alpha = 0.5$&lt;/span&gt;. The global minima of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; occur at &lt;span class=&quot;math-container&quot;&gt;$x = -1,1$&lt;/span&gt;, which implies that the global minima of &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt; occur at &lt;span class=&quot;math-container&quot;&gt;$(-1,-1),(1,-1),(-1,1),(1,1)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We plot &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; (red) and &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt; (blue) in the figure below. We see that, as expected, &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt; has four global minima: &lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2) = (1,1),(-1,1),(1,-1),(-1,-1)$&lt;/span&gt;. Both &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt; are minimized when &lt;span class=&quot;math-container&quot;&gt;$(x_1,x_2) = (-1,-1),(1,1)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/mTCR3.png&quot; width=&quot;500&quot;&gt;&#xA;&lt;h2&gt;Uncountable number of global minima&lt;/h2&gt;&#xA;&lt;p&gt;Finally, we consider the case when &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; has an uncountable number of global minima. Let the unique global minimizers of &lt;span class=&quot;math-container&quot;&gt;$f : X \to \mathbb R$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$X \subseteq \mathbb R^n$&lt;/span&gt;, be parameterized by the curve &lt;span class=&quot;math-container&quot;&gt;$z^* : [0,1] \to X$&lt;/span&gt; (note that &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbb R$&lt;/span&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Cardinality_of_the_continuum&quot; rel=&quot;nofollow noreferrer&quot;&gt;have the same cardinality&lt;/a&gt;), such that &lt;span class=&quot;math-container&quot;&gt;$f(z^*(t)) = F^* \in \mathbb R$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$t \in [0,1]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$F^* \leq f(x)$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$x \in X$&lt;/span&gt;. As before, we want to determine the cases when the minimizers of &lt;span class=&quot;math-container&quot;&gt;$g_\ell$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt; are equivalent for any &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m}$&lt;/span&gt;. We proceed as follows. First, fix any &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1:m} \in \Delta$&lt;/span&gt;. Then,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\min_{x_{1:m}} g_u(x_{1:m},\alpha_{1:m}) &amp;amp;= \min_{x_{1:m}} \sum_{i=1}^m \alpha_i \cdot f\left(x_i\right) \\&#xA;&amp;amp;= \sum_{i=1}^m \alpha_i \cdot \min_{x_i} f\left(x_i\right) \\&#xA;&amp;amp;= \sum_{i=1}^m \alpha_i \cdot F^* \\&#xA;&amp;amp;= F^* \sum_{i=1}^m \alpha_i \\&#xA;&amp;amp;= F^*&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;In this case, because &lt;span class=&quot;math-container&quot;&gt;$F^*$&lt;/span&gt; is achieved by an uncountable number of different minimizers of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; that are parameterized by &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt; also has an uncountable number of global minimizers. If we denote &lt;span class=&quot;math-container&quot;&gt;$A \subseteq X$&lt;/span&gt; as the range of &lt;span class=&quot;math-container&quot;&gt;$z^*$&lt;/span&gt; (i.e. &lt;span class=&quot;math-container&quot;&gt;$A = \{z^*(t) \mid t \in [0,1]\}$&lt;/span&gt;), then the set of all global minimizers of &lt;span class=&quot;math-container&quot;&gt;$g_u$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$A^m$&lt;/span&gt;. It turns out that the rest of the derivation for the uncountable case is similar to the countable case, so we leave it to the reader to fill in the blanks.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2023-10-23T19:33:04.617" LastActivityDate="2023-10-23T19:33:04.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11113" PostTypeId="1" CreationDate="2023-10-14T22:28:16.553" Score="2" ViewCount="35" Body="&lt;p&gt;I have a black box function to optimize with respect to 1-D input,&lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;, and I also have other inputs, which I don't need to optimize, say (x,y). So, I need to optimize f(&lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;, x,y) over &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt;. Now, I have a bunch of data points {&lt;span class=&quot;math-container&quot;&gt;$(x_n,y_n)$&lt;/span&gt;}, n = 1,2,...,N. So, if I use sklearn for example, I have to iterate over each &lt;span class=&quot;math-container&quot;&gt;$(x_n,y_n)$&lt;/span&gt; to get &lt;span class=&quot;math-container&quot;&gt;$b_n^*$&lt;/span&gt;. It gets very computationally slow. I am wondering if there is any library or tutorial to get {&lt;span class=&quot;math-container&quot;&gt;$b_n^*$&lt;/span&gt;}, at once, given all {&lt;span class=&quot;math-container&quot;&gt;$(x_n,y_n)$&lt;/span&gt;} so I can avoid iterations.&lt;/p&gt;&#xA;" OwnerUserId="12654" LastActivityDate="2023-10-14T22:28:16.553" Title="I need help with finding a library or tutorial to parallel optimize given a black box function, assuming it's convex" Tags="|python|convex-optimization|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11114" PostTypeId="1" AcceptedAnswerId="11117" CreationDate="2023-10-14T22:56:11.253" Score="3" ViewCount="211" Body="&lt;p&gt;I am brain storming the best way to approach the following problem.&lt;/p&gt;&#xA;&lt;p&gt;Problem: Load 100 given boxes of different types into the fewest number of trucks as possible, with the following details.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;10 types of boxes (types A-J). Boxes have same length and width (2x2) but height can be 2, 4 or 6. Boxes cannot be rotated or tilted.&lt;/li&gt;&#xA;&lt;li&gt;All trucks are 100x20x20 (lwh)&lt;/li&gt;&#xA;&lt;li&gt;There’s a list of rules on how to stack boxes (i.e - type H cannot have any box on top of it, type J can only be stacked on top of types A-E, etc)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The best idea that comes to mind is using a form of the assignment problem in LP. Start with the min n number of trucks (total volume of boxes assuming no wasted space). If infeasible with n trucks, then try n+1 until feasible. I am wondering if this is the best approach. It feels a bit off to me since there isn’t really a meaningful objective function. Makes it seem like LP is wasted, but I cannot think of a better solution.&lt;/p&gt;&#xA;&lt;p&gt;Someone mentioned the bin packing problem, but is there a way to track the location of each box in the bin? I am thinking of treating each bin as a 100x10x10 coordinate grid and then creating a &amp;quot;bin&amp;quot; for each coordinate block, but I feel like this is extremely overcomplicated.&lt;/p&gt;&#xA;" OwnerUserId="12655" LastEditorUserId="500" LastEditDate="2023-10-15T02:22:26.757" LastActivityDate="2023-10-15T08:23:17.373" Title="Best way to approach box stacking problem" Tags="|optimization|packing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11115" PostTypeId="1" AcceptedAnswerId="11136" CreationDate="2023-10-15T02:21:06.983" Score="1" ViewCount="513" Body="&lt;p&gt;I'm rusty on constraint optimization and am looking for help in this particular use case. There are individuals who are each member to several teams. This is a fixed many-to-many relationship and is determined a-priori. There are 3 time slots where the teams can be scheduled to conduct a business meeting, but if an individual is a member of more than one team which are both meeting at a given time slot, they'll only be able to attend one. The objective is to schedule the teams into the time slots, minimizing the number of overlaps of individuals.&lt;/p&gt;&#xA;&lt;p&gt;I've started with a simple Boolean array for the model:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    var model = new CpModel();&#xA;&#xA;    var x = new BoolVar[_timeSlots.Length, _teams.Length];&#xA;    foreach (var s in _timeSlots)&#xA;    {&#xA;        foreach (var t in _teams)&#xA;        {&#xA;&#xA;            x[s, t] = model.NewBoolVar($&amp;quot;teamMeets[{s},{t}]&amp;quot;);&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Teams may only meet once:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    foreach (var t in _teams)&#xA;    {&#xA;        var teamMeet = new List&amp;lt;ILiteral&amp;gt;();&#xA;        foreach (var s in _timeSlots)&#xA;        {&#xA;            teamMeet.Add(x[s, t]);&#xA;        }&#xA;        model.AddExactlyOne(teamMeet);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'm hazy on how to proceed to minimize the overlap - I'm thinking it should be an &lt;code&gt;IntVar&lt;/code&gt; containing the number of individuals overlapping between the teams, and then add a &lt;code&gt;model.Minimize&lt;/code&gt; objective. But I could use a hint on how I might correlate the time slots, teams, and individuals in this.&lt;/p&gt;&#xA;" OwnerUserId="12657" LastEditorUserId="12657" LastEditDate="2023-10-15T15:13:57.137" LastActivityDate="2024-01-30T16:00:45.790" Title="Google-OR Tools: Assignment minimizing overlapping members" Tags="|or-tools|assignment-problem|cp-sat|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11117" PostTypeId="2" ParentId="11114" CreationDate="2023-10-15T08:23:17.373" Score="3" Body="&lt;p&gt;This is a variant of a three-dimensional bin packing problem.&lt;/p&gt;&#xA;&lt;p&gt;If all boxes are identical squares, then packing stacks in trucks is trivial. What you just need is to build the least number of stacks. This is a variant of a one-dimensional bin packing problem, where the size of an item is its height and the size of a bin is the truck height.&lt;/p&gt;&#xA;&lt;p&gt;To solve this one-dimensional bin packing variant, you can try:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A mixed-integer linear programming model&lt;/li&gt;&#xA;&lt;li&gt;A column generation based algorithm. The subproblem will be a one-dimensional knapsack variant that should be solvable with dynamic programming or tree search&lt;/li&gt;&#xA;&lt;li&gt;A sequential decomposition: while there remain unpacked items, build a new stack as full as possible. The subproblem is the same one-dimensional knapsack variant as for the column generation based approach.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-10-15T08:23:17.373" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11118" PostTypeId="1" CreationDate="2023-10-15T14:55:05.953" Score="1" ViewCount="137" Body="&lt;p&gt;This is a follow up to this question: &lt;a href=&quot;https://or.stackexchange.com/questions/10741/non-linear-objective-function-due-to-piecewise-component/10742?noredirect=1#comment22914_10742&quot;&gt;Non-Linear objective function due to piecewise component&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Consider a piecewise function but now with three segments but the objective remains the same as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{n}(1-prob_{n})(1+x_n)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; is the  decision variable. However, &lt;span class=&quot;math-container&quot;&gt;$prob_n$&lt;/span&gt; is now defined as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$prob_{n} = $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases} &#xA;      0.25, &amp;amp; x_n \geq 2 \\&#xA;      0, &amp;amp; 0 &amp;lt; x_n &amp;lt; 2 \\&#xA;    0.05, &amp;amp; x \leq 0 \\&#xA;\end{cases}&lt;/span&gt;&#xA;I tried modifying the approach outlined by @Reinderien but I am unsure if I am on the right path.&lt;/p&gt;&#xA;&lt;p&gt;First I re-write the objective as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{n}(1-0.05 - (0.20 d_{1,n} - 0.05 d_{2,n}))(1+x_n)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$d_{1,n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d_{2,n}$&lt;/span&gt; are binary variables.&lt;/p&gt;&#xA;&lt;p&gt;Expanding this further I re-write it as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{n}(0.95 + 0.95x_{n} - 0.2d_{1,n} - 0.2x_{n}d_{1,n} + 0.05d_{2,n} + 0.05x_{n}d_{2,n})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now we have two non-linear terms so my guess is that I need two auxiliary variables, &lt;span class=&quot;math-container&quot;&gt;$x_{n}^{'}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{n}^{''}$&lt;/span&gt;. But before introducing the auxiliary variables, my problem is that I am unsure how to re-write this using big-M. This is my initial attempt:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_n \geq M_1d_{1,n}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_n \geq 2 - M_2(1-d_{1,n})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{n} \leq 2 - M_{3}d_{2}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{n} \leq M_{4} (1 - d_{1,n} - d_{2,n})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But after this I am not sure how to continue. I was able to verify the constraints suggested by @Reinderien but I cannot extend it to the three segment case.&lt;/p&gt;&#xA;" OwnerUserId="11074" LastActivityDate="2023-10-22T19:08:29.993" Title="Non-Linear objective function due to piecewise component (part 2)" Tags="|mixed-integer-programming|linear-programming|big-m|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11119" PostTypeId="1" AcceptedAnswerId="11169" CreationDate="2023-10-16T09:15:24.713" Score="0" ViewCount="157" Body="&lt;p&gt;Consider the following inequality:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\left(\frac{p}{1-q}\right)^p \geq \left(\frac{q}{1-p}\right)^{1-p}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;p, q&amp;lt; 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$p+q&amp;lt;1$&lt;/span&gt;. I am trying to show that the following inequality holds true for all values of &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; that meet the conditions.&lt;/p&gt;&#xA;" OwnerUserId="10701" LastEditorUserId="491" LastEditDate="2023-11-05T18:58:09.593" LastActivityDate="2023-11-05T18:58:09.593" Title="Proving the Validity of a Given Inequality Involving Ratios of $p$ and $q$" Tags="|valid-inequalities|proofs|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11121" PostTypeId="1" AcceptedAnswerId="11122" CreationDate="2023-10-16T11:37:01.347" Score="3" ViewCount="289" Body="&lt;p&gt;I'm wondering if evolution-like (or genetic) algorithms are competitive for combinatorial optimization (CO) problems, such as knapsack, maximum independent set, travelling salesman etc. problems in comparison? I mean, as I know evolution algorithms are used when we know little about the structure of the optimizing function (for example for Black Box Optimization), so it means that Evolution should not be particularly strong for CO. Does anybody know any practical evidence/benefits of Evolution for CO?&lt;/p&gt;&#xA;" OwnerUserId="12663" LastEditorUserId="12663" LastEditDate="2023-10-16T12:27:42.817" LastActivityDate="2023-10-16T12:27:42.817" Title="Is evolution algorithm suitable for combinatorial optimization problem" Tags="|combinatorial-optimization|genetic-algorithm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11122" PostTypeId="2" ParentId="11121" CreationDate="2023-10-16T12:00:36.907" Score="5" Body="&lt;p&gt;While pure Evolutionary algorithms might have some drawbacks, when combined with local search methods, which can make further use of the problem structure, Genetic algorithms can perform very well. The combination of an evolution strategy, with a local solver is also called &lt;em&gt;memetic&lt;/em&gt; or &lt;em&gt;hybrid&lt;/em&gt;. Examples for this are the HGS-CVRP solver which is currently State-of-the-art for CVRP problems:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Vidal, T., Crainic, T. G., Gendreau, M., Lahrichi, N., Rei, W. (2012). A hybrid genetic algorithm for multidepot and periodic vehicle routing problems. Operations Research, 60(3), 611-624. &lt;a href=&quot;https://doi.org/10.1287/opre.1120.1048&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1287/opre.1120.1048&lt;/a&gt; (Available HERE in technical report form).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Another example is the HG-means solver for minimum sum-of-squares clustering:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;HG-means: A scalable hybrid genetic algorithm for minimum sum-of-squares clustering. D. Gribel and T. Vidal, 2019. Pattern Recognition, &lt;a href=&quot;https://doi.org/10.1016/j.patcog.2018.12.022&quot; rel=&quot;noreferrer&quot;&gt;https://doi.org/10.1016/j.patcog.2018.12.022&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2023-10-16T12:00:36.907" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11123" PostTypeId="2" ParentId="11108" CreationDate="2023-10-17T06:05:29.127" Score="1" Body="&lt;p&gt;It seems the Pymoo package has the machinery to compute the hypervolume. From the documentation, in the &amp;quot;Performance indicator&amp;quot; section, they describe several performance indicators (generational distance, generational distance plus, inverted generational distance, inverted generational distance plus, and  the hypervolume).&lt;/p&gt;&#xA;&lt;p&gt;They provide the following example&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pymoo.indicators.hv import HV&#xA;from pymoo.problems import get_problem&#xA;import numpy as np&#xA;&#xA;# The pareto front of a scaled zdt1 problem&#xA;pf = get_problem(&amp;quot;zdt1&amp;quot;).pareto_front()&#xA;&#xA;# The result found by an algorithm&#xA;A = pf[::10] * 1.1&#xA;&#xA;ref_point = np.array([1.2, 1.2])&#xA;&#xA;ind = HV(ref_point=ref_point)&#xA;print(&amp;quot;HV&amp;quot;, ind(A))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="278" LastActivityDate="2023-10-17T06:05:29.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11124" PostTypeId="1" CreationDate="2023-10-17T10:36:49.363" Score="0" ViewCount="69" Body="&lt;p&gt;A constant in a linear optimization problem does not influence the decision variables and thus may be discarded (as in this example: &lt;code&gt;max z = x_1 + 2x_2 + 3x_3 + 37&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;In my example, I want to recommended users to other users in order to maximize the matches. A match is created when two users interact positively with one another. For this, I determined the match probabilities for every user with every other user. The maximization works perfectly fine.&lt;/p&gt;&#xA;&lt;p&gt;However, every match obtained by a user in a period reduces the match probability of this user with every other user by &lt;code&gt;0.05&lt;/code&gt; in the next period.&#xA;Given a user's match probability with another user is &lt;code&gt;70%&lt;/code&gt; and the user obtained 4 matches in the period prior to the recommendation, the match probability would be only &lt;code&gt;50%&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I want to consider this in the optimization. The approach is to extend the optimization with a penalty function and for this, calculate the expected number of matches every user may achieve in a period (this includes decision variables) and subtract the number of matches achieved in the last period (this is a fixed number and does not include decision variables). Given the number of expected matches is superior than the number of matches achieved last period, a penalty should be added (&lt;code&gt;-0.05&lt;/code&gt; for every extra match).&lt;/p&gt;&#xA;&lt;p&gt;The second term does only consist of a fixed number (&lt;code&gt;3&lt;/code&gt; if a user obtained &lt;code&gt;3&lt;/code&gt; matches in the prior period). However, the penalty does not improve my results. May this implementation even work or make sense?&lt;/p&gt;&#xA;" OwnerUserId="12673" LastEditorUserId="491" LastEditDate="2023-10-20T16:27:18.493" LastActivityDate="2023-10-20T16:27:18.493" Title="Constants in Penalty Function in Linear Optimization" Tags="|optimization|linear-programming|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11125" PostTypeId="1" AcceptedAnswerId="11260" CreationDate="2023-10-17T19:01:18.953" Score="0" ViewCount="323" Body="&lt;p&gt;I have been messing about with HiGHS and trying to get a hang of its capability.&lt;/p&gt;&#xA;&lt;p&gt;Here is an example of a simple model from their github repo&#xA;&lt;a href=&quot;https://github.com/ERGO-Code/HiGHS/blob/master/examples/call_highs_from_python.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ERGO-Code/HiGHS/blob/master/examples/call_highs_from_python.py&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this example, adding variables and constraints is done through lp.col and lp.row respectively.&lt;/p&gt;&#xA;&lt;p&gt;I'm getting a handle on how to do that, but here is another example from the repo&#xA;&lt;a href=&quot;https://github.com/ERGO-Code/HiGHS/blob/master/examples/minimal.py#L8&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ERGO-Code/HiGHS/blob/master/examples/minimal.py#L8&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;where they use addVar and addConstr instead. This of course simpler and more straightforward. Anyway, when I try to replicate that addVar works and all the variables are added. On the other hand, addConstr results in an attribute error&#xA;&lt;em&gt;&lt;strong&gt;AttributeError: 'Highs' object has no attribute 'addConstr'&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have been looking at the documentation with no luck to fix this issue. I have the latest version of the library. I'm wondering if this is something they haven't released yet maybe? I tried also to find the source code to see what function and attribute the model object has but couldn't find that either.&lt;/p&gt;&#xA;" OwnerUserId="12674" LastEditorUserId="36" LastEditDate="2023-10-18T12:54:46.210" LastActivityDate="2023-11-18T18:26:26.473" Title="Starting with HiGHS" Tags="|python|constraint|solver|highs|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11126" PostTypeId="2" ParentId="11125" CreationDate="2023-10-17T23:47:25.913" Score="0" Body="&lt;p&gt;The latest release @ github is &lt;a href=&quot;https://github.com/ERGO-Code/HiGHS/releases/tag/v1.6.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;1.6.0&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The latest release available @ pypi is &lt;a href=&quot;https://pypi.org/project/highspy/&quot; rel=&quot;nofollow noreferrer&quot;&gt;1.5.3&lt;/a&gt;.&#xA;This is the one you obtain when installing through &lt;code&gt;pip install highspy&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;While the feature you are trying to use was added (to some branch; see &lt;a href=&quot;https://github.com/ERGO-Code/HiGHS/pull/1263&quot; rel=&quot;nofollow noreferrer&quot;&gt;MR&lt;/a&gt;) in April 2023 and 1.5.3 was released in May 2023, &lt;strong&gt;it seems it's NOT part of 1.5.3&lt;/strong&gt; as indicated in this &lt;a href=&quot;https://github.com/ERGO-Code/HiGHS/compare/v1.5.3...v1.6.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;git-compare of the two releases&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Well... at least it looks like it. Imho the git-history/branching looks kind of &amp;quot;wild&amp;quot;. Your observation of having access to one function but not the other is strange but i think it's a result of &lt;a href=&quot;https://github.com/ERGO-Code/HiGHS/pull/1263#pullrequestreview-1391794732&quot; rel=&quot;nofollow noreferrer&quot;&gt;some overload&lt;/a&gt; (which looks a bit scary).&lt;/p&gt;&#xA;" OwnerUserId="231" LastEditorUserId="231" LastEditDate="2023-10-17T23:52:42.443" LastActivityDate="2023-10-17T23:52:42.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11127" PostTypeId="1" AcceptedAnswerId="11130" CreationDate="2023-10-18T13:37:24.127" Score="-2" ViewCount="111" Body="&lt;p&gt;I have the follwoing set in GAMS&#xA;set i /10,13,15/;&lt;/p&gt;&#xA;&lt;p&gt;how can I display the second element of this set ?&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2023-10-18T13:57:59.743" LastActivityDate="2023-10-19T09:05:01.373" Title="How to print/display a specific element of a set in GAMS?" Tags="|software|gams|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11128" PostTypeId="5" CreationDate="2023-10-18T15:00:53.370" Score="0" Body="&lt;p&gt;Resources:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://highs.dev/&quot; rel=&quot;nofollow noreferrer&quot;&gt;highs.dev&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ERGO-Code/HiGHS&quot; rel=&quot;nofollow noreferrer&quot;&gt;github.com/ERGO-Code/HiGHS&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="231" LastEditorUserId="231" LastEditDate="2023-10-18T18:00:53.530" LastActivityDate="2023-10-18T18:00:53.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11129" PostTypeId="4" CreationDate="2023-10-18T15:00:53.370" Score="0" Body="HiGHS is a free and open-source solver for linear programming (LP), convex quadratic programming (CQP) and mixed integer programming (MILP). Ask questions about usage, bugs, interfaces, behavior." OwnerUserId="231" LastEditorUserId="231" LastEditDate="2023-10-18T18:01:01.473" LastActivityDate="2023-10-18T18:01:01.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11130" PostTypeId="2" ParentId="11127" CreationDate="2023-10-18T18:10:42.510" Score="2" Body="&lt;p&gt;I would use a subset:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set &#xA;   i /10,13,15/&#xA;   isub(i)&#xA;;&#xA;isub(i) = ord(i)=2;&#xA;display isub; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This gives:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;----      6 SET isub  &#xA;&#xA;13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This only works for ordered sets.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2023-10-19T09:05:01.373" LastActivityDate="2023-10-19T09:05:01.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11132" PostTypeId="1" CreationDate="2023-10-20T16:38:33.763" Score="0" ViewCount="56" Body="&lt;p&gt;I have a csv file with a table with 5 columns: dueDateTime, cover, phone, simcard, tablet.&lt;/p&gt;&#xA;&lt;p&gt;This file has the amount of items for cover, phone, simcard, tablet.&lt;/p&gt;&#xA;&lt;p&gt;I have the size of the items:&lt;/p&gt;&#xA;&lt;p&gt;we have cover :   20cm x 10cm x 3cm&#xA;we have phone  :  15cm x 9cm x 8cm&#xA;we have simcard :  9cm x 6cm x 1cm&#xA;we have tablet :  26cm x 20cm x 6cm&lt;/p&gt;&#xA;&lt;p&gt;I have the capacity of each ship: 40cm x 40cm x 60cm&lt;/p&gt;&#xA;&lt;p&gt;Now I want to minimize the amounts of ships I need to use. Each Item can go into any ship.&lt;/p&gt;&#xA;&lt;p&gt;The problem is that we cannot cut the items in half. So its hard to use the volume in the calculation.&lt;/p&gt;&#xA;" OwnerUserId="12691" LastEditorUserId="500" LastEditDate="2023-10-20T16:39:50.917" LastActivityDate="2023-10-20T16:39:50.917" Title="Optimization for a capacity problem" Tags="|python|gurobi|packing|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11133" PostTypeId="2" ParentId="9632" CreationDate="2023-10-20T21:00:53.793" Score="2" Body="&lt;p&gt;Pan's book chapter 8: &lt;a href=&quot;https://link.springer.com/book/10.1007/978-981-19-0147-8&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/book/10.1007/978-981-19-0147-8&lt;/a&gt; . It has examples.&lt;/p&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2023-10-20T21:00:53.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11134" PostTypeId="1" CreationDate="2023-10-20T23:48:15.827" Score="2" ViewCount="100" Body="&lt;p&gt;Data:&#xA;I have the following items I need to ship, with the input data as below. Each item needs to be shipped by shipDate at the latest, but can be shipped as early as availDate. Each truck has a min/max load, so if there is not enough load for 1 truck, the shipment is postpone to next day.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;shipDate     item  weight availDate&#xA;10/20/23     1     10kg   10/20/23&#xA;10/20/23     2     20kg   10/19/23&#xA;10/21/23     3     30kg   10/19/23&#xA;10/22/23     4     40kg   10/21/23&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Currently, I am running a bin packing problem for each ship date, and for any leftover space for each day, I will take&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for date in shipDate&#xA;    filter items for date, and run bin packing problem with those items&#xA;&#xA;    if infeasible&#xA;        take all items in current date and update to next date&#xA;    else&#xA;        get total empty remaining weight for all trucks (i.e if truck 1 is 90/100kg, and trucks 2 is 95/100kg, then total remaining weight is 15kg)&#xA;        make list of all items that are available today but have ship date in future&#xA;        with that list, make combination of all items that total up to remaining weight (15kg in example). then sort the list by weight desc&#xA;        for item in list:&#xA;            rerun bin packing problem with added items til feasible is found&#xA;        if no feasible found, then original solution with no items  from future dates is optimal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This heuristic seems to work, but then I realize a problem. If I take items from a future date, then there is a chance that all shipments for that future date may be infeasible if there is not enough items to meet the minimum load.&lt;/p&gt;&#xA;&lt;p&gt;One approach I am thinking of is to treat this as one whole bin packing problem. If i create assignment variables with dates A(item)(truck)(date) and have each item have multiple dates between availDate and shipDate (i.e - for item 3 above, there would be assignment variables for 10/19, 10/20, and 10/21), then update the each item assigned to one truck/date constraint. Then I can add a weight to the objective function to prioritize an item to ship earlier if possible. sum( A(item,truck,date) * n) ), where n = 1 for first date etc.&lt;/p&gt;&#xA;&lt;p&gt;It is very hacky but I think it should work. Is there any holes in this logic that will cause issues or prevent scalability? I want to make sure I am not missing anything. Thanks&lt;/p&gt;&#xA;" OwnerUserId="12655" LastEditorUserId="2556" LastEditDate="2023-10-21T10:28:07.613" LastActivityDate="2023-10-22T09:40:08.643" Title="Bin packing problem with multiple dates" Tags="|optimization|mixed-integer-programming|modeling|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11135" PostTypeId="2" ParentId="11134" CreationDate="2023-10-21T10:00:06.283" Score="1" Body="&lt;p&gt;You can use the follow model:&lt;/p&gt;&#xA;&lt;h4&gt;Assumptions&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;No split delivery&lt;/li&gt;&#xA;&lt;li&gt;Each shipment can be done in at most one day&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;Parameters&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$q_k$&lt;/span&gt; minimum capacity for vehicle &lt;span class=&quot;math-container&quot;&gt;$k \in K$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$Q_k$&lt;/span&gt; maximum capacity for vehicle &lt;span class=&quot;math-container&quot;&gt;$k \in K$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_k$&lt;/span&gt; cost of using vehicle &lt;span class=&quot;math-container&quot;&gt;$k \in K$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; volume of item &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T_i \subseteq T$&lt;/span&gt; set of feasible shipment dates for item &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$I_t \subseteq I$&lt;/span&gt; set of feasible shipments (items) on day &lt;span class=&quot;math-container&quot;&gt;$t \in T$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;Variables&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ik}^t \in\{0,1\}$&lt;/span&gt; takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\Leftrightarrow$&lt;/span&gt; item &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; is shipped in vehicle &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$t\in T$&lt;/span&gt; (note: this is the assignment variable proposed by OP)&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{k}^t \in\{0,1\}$&lt;/span&gt; takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\Leftrightarrow$&lt;/span&gt; vehicle &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt; is used on day &lt;span class=&quot;math-container&quot;&gt;$t\in T$&lt;/span&gt; for a shipment&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;Objective function&lt;/h4&gt;&#xA;&lt;p&gt;You want to minimize total shipment costs:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \sum_{t\in T}\sum_{k\in K}c_ky_k^t&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h4&gt;Constraints&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each item must be shipped in one vehicle, on a feasible date:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{k \in K}\sum_{t \in T_i} x_{ik}^t = 1 \quad \forall i\in I&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Capacity constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA; q_k y_{k}^t \le \sum_{i \in I_t} v_i x_{ik}^t \le Q_k y_{k}^t  \quad \forall k\in K, \; \forall t \in T&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;If a vehicle cannot be used more than once:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{t\in T}y_{k}^t \le 1 \quad \forall k\in K&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Addendum&lt;/h3&gt;&#xA;&lt;p&gt;To prioritize early shipments, the following term can be included (minimized) in the objective function:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i,k,t}C_{i}^tx_{ik}^t&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$C_i^t$&lt;/span&gt; is a &amp;quot;penalty&amp;quot; for shipping item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. This penalty can be zero for the first shipment date possible, and then increase with time.&lt;/p&gt;&#xA;&lt;p&gt;Note that adding this term to the objective function creates a trade-off between minimizing vehicle costs and prioritizing shipments. It may not be easy to fix the right value for penalty &lt;span class=&quot;math-container&quot;&gt;$C_i^t$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-10-22T09:40:08.643" LastActivityDate="2023-10-22T09:40:08.643" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11136" PostTypeId="2" ParentId="11115" CreationDate="2023-10-21T12:08:50.800" Score="3" Body="&lt;p&gt;It is often a good idea to split this task into two parts:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Developing a mathematical model&lt;/li&gt;&#xA;&lt;li&gt;Implement the model (coding)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Often, if you do a good job on (1), (2) becomes a breeze.&lt;/p&gt;&#xA;&lt;p&gt;Here is my attempt.&lt;/p&gt;&#xA;&lt;p&gt;Indices: &lt;span class=&quot;math-container&quot;&gt;$$\begin{aligned}&amp;amp; i &amp;amp;&amp;amp; \text{individuals}\\&amp;amp; t &amp;amp;&amp;amp;\text{teams} \\ &amp;amp; s &amp;amp;&amp;amp; \text{time slots} \end{aligned}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Data: &lt;span class=&quot;math-container&quot;&gt;$$\color{darkblue}m_{i,t}=\begin{cases}1 &amp;amp; \text{if individual $i$ is member of team $t$} \\ 0 &amp;amp; \text{otherwise}\end{cases}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Binary variables: &lt;span class=&quot;math-container&quot;&gt;$$\color{darkred}x_{t,s} = \begin{cases}1 &amp;amp; \text{if meeting of team $t$ takes place at time slot $s$} \\ 0 &amp;amp; \text{otherwise}\end{cases}$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$\color{darkred}y_{i,s} = \begin{cases}1 &amp;amp; \text{if individual $i$ has meetings at timeslot $t$} \\ 0 &amp;amp; \text{otherwise}\end{cases}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My idea is to use as objective: maximize the number of meetings each individual can attend. This is the same as minimizing the number of overlaps, except that it is easier to model. The complete MIP model can look like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}\max &amp;amp;\sum_{i,s}\color{darkred}y_{i,s} \\ &amp;amp; \sum_s \color{darkred}x_{t,s}=1&amp;amp;&amp;amp;\forall t \\ &amp;amp; \color{darkred}y_{i,s}\le \sum_t \color{darkblue}m_{i,t}\cdot \color{darkred}x_{t,s}&amp;amp;&amp;amp;\forall i,s \\ &amp;amp; \color{darkred}x_{t,s} \in \{0,1\} \\ &amp;amp;\color{darkred}y_{i,s} \in \{0,1\} \end{aligned}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first constraint says: a team meeting has to occur exactly once. The second constraint says: if not a member of any teams that meet during time slot &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;, then individual &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is not attending that time slot.&lt;/p&gt;&#xA;&lt;p&gt;Using some random data:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;----     23 SET member  team membership&#xA;&#xA;                   team1       team2       team3       team4       team5       team6&#xA;&#xA;individual1          YES                                                         YES&#xA;individual2                                  YES&#xA;individual3                                  YES                     YES&#xA;individual4                                                          YES         YES&#xA;individual5                                  YES&#xA;individual6          YES                     YES&#xA;individual7                                                                      YES&#xA;individual8                      YES                     YES&#xA;individual10         YES         YES                                 YES&#xA;individual11         YES         YES                                 YES         YES&#xA;individual12                                                         YES         YES&#xA;individual13         YES                                                         YES&#xA;individual14                     YES         YES         YES&#xA;individual15         YES         YES&#xA;individual17         YES                     YES                     YES         YES&#xA;individual18                                             YES&#xA;individual19         YES                                 YES&#xA;individual20                                 YES                     YES&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I get the following solution:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;----     46 VARIABLE x.L  schedule team meetings at time slot&#xA;&#xA;        timeslot1   timeslot2   timeslot3&#xA;&#xA;team1           1&#xA;team2                       1&#xA;team3           1&#xA;team4                                   1&#xA;team5                                   1&#xA;team6                       1&#xA;&#xA;----     46 VARIABLE y.L  individual is in meeting at time slot&#xA;&#xA;               timeslot1   timeslot2   timeslot3&#xA;&#xA;individual1            1           1&#xA;individual2            1&#xA;individual3            1                       1&#xA;individual4                        1           1&#xA;individual5            1&#xA;individual6            1&#xA;individual7                        1&#xA;individual8                        1           1&#xA;individual10           1           1           1&#xA;individual11           1           1           1&#xA;individual12                       1           1&#xA;individual13           1           1&#xA;individual14           1           1           1&#xA;individual15           1           1&#xA;individual17           1           1           1&#xA;individual18                                   1&#xA;individual19           1                       1&#xA;individual20           1                       1&#xA;&#xA;&#xA;----     51 PARAMETER meetingcount  number of meetings&#xA;&#xA;               timeslot1   timeslot2   timeslot3&#xA;&#xA;individual1            1           1&#xA;individual2            1&#xA;individual3            1                       1&#xA;individual4                        1           1&#xA;individual5            1&#xA;individual6            2&#xA;individual7                        1&#xA;individual8                        1           1&#xA;individual10           1           1           1&#xA;individual11           1           2           1&#xA;individual12                       1           1&#xA;individual13           1           1&#xA;individual14           1           1           1&#xA;individual15           1           1&#xA;individual17           2           1           1&#xA;individual18                                   1&#xA;individual19           1                       1&#xA;individual20           1                       1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There are just a few double bookings. The &lt;code&gt;meetingcount&lt;/code&gt; is &lt;span class=&quot;math-container&quot;&gt;$\sum_t \color{darkblue}m_{i,t}\cdot \color{darkred}x^*_{t,s}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There is nothing particularly complex in the model, so it should be very easy to implement in code. Of course, this problem is small enough to do a complete enumeration.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;A MIP model to minimize the &amp;quot;overlaps&amp;quot; can be developed as follows.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\color{darkred}c^{\ge 2}_{i,s}$&lt;/span&gt; be the number meetings at time slot &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; individual &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; would like to attend &lt;strong&gt;exceeding 1&lt;/strong&gt; (i.e. 2 or more; this is in other words the number of overlaps). Then we can write:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}\min &amp;amp;\sum_{i,s}\color{darkred}c^{\ge 2}_{i,s} \\ &amp;amp; \sum_s \color{darkred}x_{t,s}=1&amp;amp;&amp;amp;\forall t \\ &amp;amp; 1+\color{darkred}c^{\ge 2}_{i,s}\ge \sum_t \color{darkblue}m_{i,t}\cdot \color{darkred}x_{t,s}&amp;amp;&amp;amp;\forall i,s \\ &amp;amp; \color{darkred}x_{t,s} \in \{0,1\} \\ &amp;amp;\color{darkred}c^{\ge 2}_{i,s} \ge 0 \end{aligned}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In other words, &lt;span class=&quot;math-container&quot;&gt;$$&#xA;\color{darkred}c^{\ge 2}_{i,s} = \max\{0,\sum_t \color{darkblue}m_{i,t}\cdot \color{darkred}x_{t,s}-1\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;In the Minizinc answer a MIP model is created from a high-level CP model. The statistics with the &lt;code&gt;HiGHS&lt;/code&gt; solver are also given. When I ran my MIP model and the MiniZinc model, I see some differences:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;                              MIP   MiniZinc&#xA;   rows before presolve        67      174 &#xA;   columns before presolve     79      141&#xA;   nz before presolve         253       na&#xA;   rows after presolve         57       87 &#xA;   columns after presolve      69       69   (minizinc generates some general integer variables)&#xA;   nz after presolve          195      261&#xA;   Timing                     0.02     0.1&#xA;   Nodes                        1        9&#xA;   LP iterations              103     1200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So, it looks like my MIP model is a little bit more efficient than the generated Minizinc model. Of course, in this case, this is totally inconsequential. But I suspect this can also be true for large, difficult models.&lt;/p&gt;&#xA;&lt;p&gt;There is no way of knowing the Minizinc CP-&amp;gt;MIP models are poorly performing, except by developing and comparing against a properly formulated MIP model.&lt;/p&gt;&#xA;" OwnerUserId="907" LastEditorUserId="907" LastEditDate="2023-10-30T13:20:08.083" LastActivityDate="2023-10-30T13:20:08.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11137" PostTypeId="1" CreationDate="2023-10-21T23:00:49.683" Score="1" ViewCount="122" Body="&lt;p&gt;Given the following two expressions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$ x - \frac{1}{T}\sum_{i} y_{i}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$ x - \frac{1}{Q}\sum_{i} \beta_{i} y_{i}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{Z}_{+}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{R}_{+}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta_{i}$&lt;/span&gt; are given constants.&lt;/p&gt;&#xA;&lt;p&gt;I need to find the following:&lt;br /&gt;&#xA;a) The min between these two expressions &lt;span class=&quot;math-container&quot;&gt;$F = \min (x - \frac{1}{T}\sum_{i} y_{i}, x - \frac{1}{Q}\sum_{i} \beta_{i} y_{i})$&lt;/span&gt;&lt;br /&gt;&#xA;b) if &lt;span class=&quot;math-container&quot;&gt;$F &amp;gt; 0 $&lt;/span&gt; I want to enforce on variable &lt;span class=&quot;math-container&quot;&gt;$w \in \mathbb{Z}_{+}$&lt;/span&gt; the floor of the min, &lt;span class=&quot;math-container&quot;&gt;$i.e.$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$w \leq \lfloor{F}\rfloor$&lt;/span&gt;&lt;br /&gt;&#xA;c) if &lt;span class=&quot;math-container&quot;&gt;$F &amp;lt; 0 $&lt;/span&gt; I want to enforce on another variable &lt;span class=&quot;math-container&quot;&gt;$v \in \mathbb{Z}_{+}$&lt;/span&gt; the ceil of the absolute value of &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; (since the minimum could be negative) &lt;span class=&quot;math-container&quot;&gt;$i.e. v \geq \lceil {|F|}\rceil$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What I have done so far is the following:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;To find the min function, I did the same as in here &lt;a href=&quot;https://or.stackexchange.com/questions/1160/how-to-linearize-min-function-as-a-constraint&quot;&gt;How to linearize min function as a constraint?&lt;/a&gt;. I define two aux variables equals each expression.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$r^{1} =  x - \frac{1}{T}\sum_{i} y_{i}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$r^{2} =  x - \frac{1}{Q}\sum_{i} \beta_{i} y_{i}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;a binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and the following constraints are introduced to find the min:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$r^{2} - r^{1} \leq Mz$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$r^{1} - r^{2} \leq M(1-z)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$F \leq r^{2}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$F \leq r^{1}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$F \geq r^{1} - M(1 - z)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$F \geq r^{2} - M(z)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;To find the absolute value &lt;span class=&quot;math-container&quot;&gt;$abs = |F|$&lt;/span&gt;. As proposed by here &lt;a href=&quot;https://groups.google.com/g/gurobi/c/YUWqUfk3PSc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://groups.google.com/g/gurobi/c/YUWqUfk3PSc&lt;/a&gt; I introduce two continuous variables &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and a binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta$&lt;/span&gt; used as an indicator and the following constraints:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$F = p -n $&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$p \leq M \delta$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$n \leq M (1 - \delta)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$abs = p + n $&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Now my question is I have difficulties to formulate the third constraints. I introduced a binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta^{'}$&lt;/span&gt; that equals 1 when &lt;span class=&quot;math-container&quot;&gt;$F &amp;gt; 0 $&lt;/span&gt; and 0 otherwise. Then this can be formulate as following:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$F \leq M\delta^{'}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$F \geq M(1 - \delta^{'})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now I want to say:&lt;br /&gt;&#xA;if &lt;span class=&quot;math-container&quot;&gt;$\delta^{'} = 1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$w \leq \lfloor{F}\rfloor$&lt;/span&gt;  (&lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is already enforced to be 0 so we don't have to worry about it in this case)&lt;br /&gt;&#xA;if &lt;span class=&quot;math-container&quot;&gt;$\delta^{'} = 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$v \geq \lceil{abs}\rceil$&lt;/span&gt;  (similarly &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is already enforced to be 0)&lt;/p&gt;&#xA;" OwnerUserId="11022" LastEditorUserId="491" LastEditDate="2023-10-27T13:29:18.143" LastActivityDate="2023-10-27T13:29:18.143" Title="How to linearize the following constraints" Tags="|integer-programming|constraint|linearization|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11138" PostTypeId="1" AcceptedAnswerId="11140" CreationDate="2023-10-21T23:27:45.750" Score="1" ViewCount="154" Body="&lt;p&gt;Are there any recommended textbooks or notes to learn the details about the primal-dual simplex algorithm?&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="36" LastEditDate="2023-10-22T13:11:25.240" LastActivityDate="2023-10-22T13:11:25.240" Title="Primal-Dual Simplex Algorithm" Tags="|linear-programming|reference-request|duality|books|primal-simplex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11139" PostTypeId="1" CreationDate="2023-10-22T06:22:04.663" Score="2" ViewCount="91" Body="&lt;p&gt;Following is the section 7.3 of &lt;strong&gt;Operation Research An Introduction by Hamdy A. Taha&lt;/strong&gt;,&lt;/p&gt;&#xA;&lt;p&gt;Define the upper-bounded LP model as, &lt;span class=&quot;math-container&quot;&gt;$$\max z=\{CX|(A,I)X=b,0\leq X\leq U\}$$&lt;/span&gt;&#xA;The bounded algorithm uses only the main constraints &lt;span class=&quot;math-container&quot;&gt;$(A,I)X=b,X\geq0$&lt;/span&gt;. It accounts for the upper bounds, &lt;span class=&quot;math-container&quot;&gt;$X\leq U$&lt;/span&gt;, implicitly by modifying the feasibility condition.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}_B=\mathbf{B}^{-1} \mathbf{b}$&lt;/span&gt; be a current basic feasible solution of &lt;span class=&quot;math-container&quot;&gt;$(\mathbf{A}, \mathbf{I}) \mathbf{X}=\mathbf{b}, \mathbf{X} \geq \mathbf{0}$&lt;/span&gt;, and assume that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{P}_j$&lt;/span&gt; is the entering vector (as determined by the regular optimality condition). Then, given that all the nonbasic variables are zero, the constraint equation of the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; th basic variable is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left(\mathbf{X}_B\right)_i=\left(\mathbf{B}^{-1} \mathbf{b}\right)_i-\left(\mathbf{B}^{-1} \mathbf{P}_j\right)_i x_j&#xA;$$&lt;/span&gt;&#xA;When the entering variable &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; increases above zero level, &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{X}_{\boldsymbol{B}}\right)_i$&lt;/span&gt; will increase or decrease depending on whether &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{B}^{-1} \mathbf{P}_j\right)_i$&lt;/span&gt; is negative or positive, respectively. Thus, in determining the value of the entering vector &lt;span class=&quot;math-container&quot;&gt;$\mathbf{P}_j$&lt;/span&gt;, three conditions must be satisfied:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The basic variable remains nonnegative - that is, &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{X}_{\boldsymbol{B}}\right)_i \geq 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The basic variable &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{X}_B\right)_i$&lt;/span&gt; does not exceed its upper bound-that is, &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{X}_B\right)_i \leq\left(\mathbf{U}_B\right)_i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{U}_B$&lt;/span&gt; comprises the elements of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{U}$&lt;/span&gt; corresponding to &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}_B$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The entering variable &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; cannot assume a value larger than its upper bound-that is, &lt;span class=&quot;math-container&quot;&gt;$x_j \leq \mathrm{u}_j$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$u_j$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; th element of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{U}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The first condition &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{X}_{\boldsymbol{B}}\right)_i \geq 0$&lt;/span&gt; is the same as in the regular simplex method. It yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_j \leq \theta_1=\min _i\left\{\frac{\left(\mathbf{B}^{-1} \mathbf{b}\right)_i}{\left(\mathbf{B}^{-1} \mathbf{P}_j\right)_i} \mid\left(\mathbf{B}^{-1} \mathbf{P}_j\right)_i&amp;gt;0\right\}&#xA;$$&lt;/span&gt;&#xA;The second condition &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{X}_{\boldsymbol{B}}\right)_i \leq\left(\mathbf{U}_{\boldsymbol{B}}\right)_i$&lt;/span&gt; specifies that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left(\mathbf{B}^{-1} \mathbf{b}\right)_i-\left(\mathbf{B}^{-1} \mathbf{P}_j\right)_i x_j \leq\left(\mathbf{U}_B\right)_i&#xA;$$&lt;/span&gt;&#xA;It is satisfied if&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_j \leq \theta_2=\min _i\left\{\frac{\left(\mathbf{B}^{-1} \mathbf{b}\right)_i-\left(\mathbf{U}_B\right)_i}{\left(\mathbf{B}^{-1} \mathbf{P}_j\right)_i} \mid\left(\mathbf{B}^{-1} \mathbf{P}_j\right)_i&amp;lt;0\right\}&#xA;$$&lt;/span&gt;&#xA;Combining the three restrictions, &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; enters the solution at the level that satisfies all three conditions-that is,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_j=\min \left\{\theta_1, \theta_2, u_j\right\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; I couldn't understand why we need to include &lt;span class=&quot;math-container&quot;&gt;$u_j$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$x_j=\min \left\{\theta_1, \theta_2, u_j\right\}$&lt;/span&gt; as we already consider the &lt;span class=&quot;math-container&quot;&gt;$\mathbf{U}_B$&lt;/span&gt; in case 2? Maybe I am not clear how they are using upper bound &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; in these two cases.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The change of basis for the next iteration depends on whether &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; enters the solution at level &lt;span class=&quot;math-container&quot;&gt;$\theta_1, \theta_2$&lt;/span&gt;, or &lt;span class=&quot;math-container&quot;&gt;$u_j$&lt;/span&gt;. Assuming that &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{X}_B\right)_r$&lt;/span&gt; is the leaving variable, then we have the following rules:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_j=\theta_1:\left(\mathbf{X}_B\right)_r$&lt;/span&gt; leaves the basic solution (becomes nonbasic) at level zero. The new iteration is generated using the regular simplex method with &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{X}_B\right)_r$&lt;/span&gt; as the entering and the leaving variables, respectively.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_j=\theta_2:\left(\mathbf{X}_B\right)_r$&lt;/span&gt; becomes nonbasic at its upper bound. The new iteration is generated as in the case of &lt;span class=&quot;math-container&quot;&gt;$x_j=\theta_1$&lt;/span&gt;, with one modification that accounts for the fact that &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{X}_B\right)_r$&lt;/span&gt; will be nonbasic at upper bound. Because the values of &lt;span class=&quot;math-container&quot;&gt;$\theta_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\theta_2$&lt;/span&gt; require all nonbasic variables to be at zero level (convince yourself that this is the case!), the new nonbasic &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{X}_B\right)_r$&lt;/span&gt; at upper bound is converted to a nonbasic variable at zero level. This is achieved by using the substitution &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{X}_B\right)_r=\left(\mathbf{U}_B\right)_r-\left(\mathbf{X}_B^{\prime}\right)_r$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\left(\mathbf{X}_B^{\prime}\right)_r \geq 0$&lt;/span&gt;. It is immaterial whether the substitution is made before or after the new basis is computed.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_j=u_j$&lt;/span&gt; : The basic vector &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}_B$&lt;/span&gt; remains unchanged because &lt;span class=&quot;math-container&quot;&gt;$x_j=u_j$&lt;/span&gt; stops short of forcing any of the current basic variables to reach its lower &lt;span class=&quot;math-container&quot;&gt;$(=0)$&lt;/span&gt; or upper bound. This means that &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; will remain nonbasic but at upper bound. The only change needed in the tableau is to use the substitution &lt;span class=&quot;math-container&quot;&gt;$x_j=u_j-x_j^{\prime}$&lt;/span&gt; to ensure that all nonbasic variables are at zero level.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; I manage to understand the three conditions above, but couldn't directly see how the procedure mentioned for &lt;span class=&quot;math-container&quot;&gt;$x_j=\theta_1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\theta_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_j=u_j$&lt;/span&gt; resolving the issue (force &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; to satisfy the condition).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It will be a great help if anyone enlighten me the intuition or redirect me to any great resources. Do I need to split this question into several thread as it seems big enough? Any suggestions will be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="12694" LastEditorUserId="12694" LastEditDate="2023-10-24T16:31:47.507" LastActivityDate="2023-10-24T16:31:47.507" Title="Understanding the condition of the bounded variable algorithm in the linear programming" Tags="|optimization|linear-programming|bounds|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11140" PostTypeId="2" ParentId="11138" CreationDate="2023-10-22T07:15:36.973" Score="3" Body="&lt;p&gt;To learn primal-dual simplex method, I have a recommend tutorial video and textbook as following:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=Txqky3l2cwc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=Txqky3l2cwc&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=f4p7JZPg89Q&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=f4p7JZPg89Q&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Bazaraa, M. S., Jarvis, J. J., &amp;amp; Sherali, H. D. (2011). Linear programming and network flows. John Wiley &amp;amp; Sons.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The knowledge for basic simplex method, there are two well-known operations research / linear programming books:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Hillier, F. S. (2001). Introduction to operations research. McGrawHill.&lt;/li&gt;&#xA;&lt;li&gt;Vanderbei, R. J. (2020). Linear programming. Springer International Publishing.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="12370" LastEditorUserId="12370" LastEditDate="2023-10-22T07:24:33.910" LastActivityDate="2023-10-22T07:24:33.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11141" PostTypeId="1" AcceptedAnswerId="11143" CreationDate="2023-10-22T18:52:19.203" Score="1" ViewCount="72" Body="&lt;p&gt;In column generation, we need to solve the following pricing problem :&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min c_j-\bf{c}^T_B\bf{B}^{-1}\bf{N}_j$$&lt;/span&gt;&#xA;In the book, I saw authors say that according to duality theory, &lt;span class=&quot;math-container&quot;&gt;$\bf{y}^T = \bf{c}^T_B\bf{B}^{-1}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\bf{y}$&lt;/span&gt; is the dual solution, the above pricing problem is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min c_j-\bf{y}^T\bf{N}_j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My question is: how to derive &lt;span class=&quot;math-container&quot;&gt;$\bf{y}^T = \bf{c}^T_B\bf{B}^{-1}$&lt;/span&gt;? Does this equation hold in every iteration of the Simplex iteration? Or it is true only at the optimal solution when Simplex finishes?&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2023-10-22T19:13:19.673" LastActivityDate="2023-10-22T21:06:26.830" Title="Question about Pricing Problem in Column Generation" Tags="|duality|column-generation|pricing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11142" PostTypeId="2" ParentId="11137" CreationDate="2023-10-22T19:10:26.577" Score="1" Body="&lt;p&gt;Given the variable &lt;span class=&quot;math-container&quot;&gt;$\delta \in \{0,1\}$&lt;/span&gt; that decides if the minimum function &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; is positive (&lt;span class=&quot;math-container&quot;&gt;$\delta = 1$&lt;/span&gt;) or negative (&lt;span class=&quot;math-container&quot;&gt;$\delta = 0$&lt;/span&gt;) The formulation is rather straightforward.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Floor function:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$w \geq F - \epsilon - M(1 - \delta)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$w \leq F + M(1 - \delta)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Ceil function:&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$v \geq |F| - M\delta$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$v \leq F + \epsilon + M\delta$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is a small tolerance, and &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; a big valid constant.&lt;/p&gt;&#xA;" OwnerUserId="11022" LastEditorUserId="11022" LastEditDate="2023-10-23T09:27:46.017" LastActivityDate="2023-10-23T09:27:46.017" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11143" PostTypeId="2" ParentId="11141" CreationDate="2023-10-22T21:06:26.830" Score="1" Body="&lt;p&gt;You don't really derive &lt;span class=&quot;math-container&quot;&gt;$y^\prime = c_B^\prime B^{-1}$&lt;/span&gt;, you just set &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; to that expression. At every iteration but the last of the simplex method on the primal problem, &lt;span class=&quot;math-container&quot;&gt;$x_B = B^{-1}b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_N = 0$&lt;/span&gt; gives a feasible but suboptimal solution to the primal problem and &lt;span class=&quot;math-container&quot;&gt;$y^\prime = c_B^\prime B^{-1}$&lt;/span&gt; gives a superoptimal but infeasible solution to the dual problem. At the final step, the primal solution goes from suboptimal to optimal and the dual solution goes from infeasible to feasible.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-10-22T21:06:26.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11144" PostTypeId="1" AcceptedAnswerId="11150" CreationDate="2023-10-23T01:53:04.440" Score="0" ViewCount="67" Body="&lt;p&gt;These days I try to build a Gurobipy optimization model by Pyomo and I met a problem about outputing IIS file.&#xA;I use&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;opt = SolverFactory(&amp;quot;gurobi&amp;quot;, solver_io=&amp;quot;python&amp;quot;)&#xA;option = {&amp;quot;MIPGAP&amp;quot;:0.001, &amp;quot;TimeLimit&amp;quot;:300}&#xA;obj = ...&#xA;for k, v in option.items():&#xA;  opt.options[k] = v&#xA;result = opt.solve(model, warmstart=True, tee=True, options_string=&amp;quot;ResultFile=iis_{}.ilp&amp;quot;.format(&amp;quot;model&amp;quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When model comes IIS, I find that the variables in IIS's constrains have no variable name or index I coded but some numeric serial number only like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x95729: -x36195 - 1.71 x40465 = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I can't figure out which constraint it is. Then I try to use&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;log_infeasiable_constraints(model, log_expression=True, log_variables=True)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to find out which constraints and variables issue the IIS, and I get a lot of constraints, the number of them far exceeds the number of constraints I got through the last approach (maybe I would have gotten a few with the last approach, whereas with log_infeasiable I would have gotten dozens) And I find that some variables' value in constraints is &amp;quot;None&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Are there some solutions that could calculate the minimum IIS constraints with variables' names and indexes? And where do these variables that turn into None values come from?&lt;/p&gt;&#xA;" OwnerUserId="12686" LastEditorUserId="500" LastEditDate="2023-10-23T14:12:19.757" LastActivityDate="2023-10-23T15:40:20.797" Title="Question about IIS output in Pyomo, Gurobipy" Tags="|optimization|python|gurobi|pyomo|irreducible-infeasible-subset|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11145" PostTypeId="1" AcceptedAnswerId="11157" CreationDate="2023-10-23T01:56:30.157" Score="0" ViewCount="56" Body="&lt;p&gt;I am studying Stochastic Dynamic Programming using Sheldon Ross's book, &amp;quot;Introduction to Stochastic Dynamic Programming.&amp;quot; In the book, Ross defines a dynamic programming algorithm to minimize cost for unbounded costs per stage problems, and it's represented as follows:&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$V_0(i) = 0$&lt;/span&gt;, and for &lt;span class=&quot;math-container&quot;&gt;$n &amp;gt; 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$$V_n(i) = min_a(C(i,a) + Σ_j P_{i,j}(a)V_{n-1}(j)),$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$C(i,a) \geq 0$&lt;/span&gt; for every &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The book claims that &lt;span class=&quot;math-container&quot;&gt;$V_n(i) \leq V_{n+1}(i)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$V_{n}(i)$&lt;/span&gt; represents the minimal expected cost for an n-stage problem starting in &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. The key observation here is that all costs are nonnegative, implying that &lt;span class=&quot;math-container&quot;&gt;$V_n(i)$&lt;/span&gt; must be less than &lt;span class=&quot;math-container&quot;&gt;$V_{n+1}(i)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I've been trying to prove this inequality using mathematical induction, but I've hit a roadblock in my efforts.&lt;/p&gt;&#xA;&lt;p&gt;Base Case (&lt;span class=&quot;math-container&quot;&gt;$n = 0$&lt;/span&gt;):&#xA;For &lt;span class=&quot;math-container&quot;&gt;$n = 0$&lt;/span&gt;, we have:&#xA;&lt;span class=&quot;math-container&quot;&gt;$V_0(i) = 0$&lt;/span&gt; (given).&#xA;Now, we need to prove that &lt;span class=&quot;math-container&quot;&gt;$V_0(i) \leq V_1(i)$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$V_1(i) = min_a(C(i,a) + ∑_j P_{i,j}(a) V_0(j))$&lt;/span&gt;&#xA;Since &lt;span class=&quot;math-container&quot;&gt;$V_0(j) = 0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, we can simplify this to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$V_1(i) = min_a(C(i,a))$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This is a minimum value over a set of non-negative values. Since &lt;span class=&quot;math-container&quot;&gt;$C(i,a)$&lt;/span&gt; is non-negative for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, the minimum value can only be zero or a positive value. Therefore, &lt;span class=&quot;math-container&quot;&gt;$V_1(i)$&lt;/span&gt; is either 0 or a positive value.&#xA;So, in the base case, &lt;span class=&quot;math-container&quot;&gt;$V_0(i) \leq V_1(i)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Inductive Hypothesis:&#xA;Assume that for some arbitrary &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$V_n(i) \leq V_{n+1}(i)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Inductive Step:&#xA;We want to show that &lt;span class=&quot;math-container&quot;&gt;$V_{n+1}(i) \leq V_{n+2}(i)$&lt;/span&gt;. We can use the formula for &lt;span class=&quot;math-container&quot;&gt;$V_{n+1}(i)$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$V_{n+1}(i) = min_a(C(i,a) + ∑_j P_{i,j}(a)V_n(j))$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm looking for assistance in completing the proof by induction.&lt;/p&gt;&#xA;" OwnerUserId="12698" LastEditorUserId="491" LastEditDate="2023-10-24T12:49:51.443" LastActivityDate="2023-10-24T12:50:04.627" Title="Successive approximation in negative dynamic programming" Tags="|dynamic-programming|proofs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11146" PostTypeId="1" AcceptedAnswerId="11147" CreationDate="2023-10-23T11:20:21.917" Score="2" ViewCount="276" Body="&lt;p&gt;I have implemented a pure binary integer combinatorial optimization routine within a Python module (importing &lt;code&gt;gurobipy&lt;/code&gt;), and experimented with relaxing a few constraints so some variables may assume values 0, 1 or 2, until I ran first into time-to-result latency problems then into memory problems. That initial effort was based on Gurobi, which I discovered on that occasion... and liked, because it has provisions to build &lt;a href=&quot;https://www.gurobi.com/documentation/9.5/refman/py_env2.html#pythonmethod:Env&quot; rel=&quot;nofollow noreferrer&quot;&gt;thread-safe compute environments&lt;/a&gt; when multi-threading, and it offers a model namespace in which the analyst may write out constraints and the objective function and embed them in code.&lt;/p&gt;&#xA;&lt;p&gt;I now need to replace the Gurobi solver because my earlier installation is reaching its free one-year term limit. I would like to be able to call a FOSS ILP/MIP solver into my python module. Although I saw a couple of references to &lt;code&gt;lpsolve()&lt;/code&gt; (e.g. &lt;a href=&quot;https://or.stackexchange.com/q/9334&quot;&gt;here&lt;/a&gt;), my issue is that I really don't know what is and what isn't available out there for Python v3.9+ environments.&lt;/p&gt;&#xA;&lt;p&gt;I am looking for a stable solver (no beta implementation) with a Python API.&lt;/p&gt;&#xA;" OwnerUserId="12701" LastEditorUserId="491" LastEditDate="2023-10-23T20:48:06.827" LastActivityDate="2023-10-23T20:48:06.827" Title="Non-proprietary (Python friendly) alternatives to Cplex and Gurobi" Tags="|mixed-integer-programming|python|cplex|gurobi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11147" PostTypeId="2" ParentId="11146" CreationDate="2023-10-23T12:41:45.400" Score="4" Body="&lt;p&gt;You can use &lt;a href=&quot;https://github.com/ERGO-Code/HiGHS&quot; rel=&quot;nofollow noreferrer&quot;&gt;HiGHS&lt;/a&gt;, &lt;a href=&quot;https://www.scipopt.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SCIP&lt;/a&gt; and &lt;a href=&quot;https://github.com/coin-or/Cbc&quot; rel=&quot;nofollow noreferrer&quot;&gt;CBC&lt;/a&gt; solvers with using PYOMO or other Pyomo supported solvers. Also you can use &lt;a href=&quot;https://github.com/google/or-tools&quot; rel=&quot;nofollow noreferrer&quot;&gt;google or-tools&lt;/a&gt; CP solver if you write CP model, google CP solver is &lt;a href=&quot;https://www.minizinc.org/challenge.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;very powerfull&lt;/a&gt;. PYOMO and GurobiPY have similar modelling structure. For example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Model defining:&#xA;Gurobi: &lt;code&gt;model = gurobipy.Model(&amp;quot;LP Example&amp;quot;)&lt;/code&gt; Pyomo: &lt;code&gt;model = pyomo.ConcreteModel()&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Variable adding: Gurobi: &lt;code&gt;x = model.addVar(name=&amp;quot;x&amp;quot;)&lt;/code&gt; Pyomo: &lt;code&gt;model.x = pyomo.Var(within=NonNegativeReals)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you compare gurobipy and pyomo models side-by-side, you can see similarities and convert easily.&lt;/p&gt;&#xA;&lt;p&gt;Before deciding solver, you can find performance benchmark of free and commercial solvers on &lt;a href=&quot;https://mattmilten.github.io/mittelmann-plots/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="432" LastEditorUserId="432" LastEditDate="2023-10-23T13:07:41.377" LastActivityDate="2023-10-23T13:07:41.377" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11148" PostTypeId="2" ParentId="11115" CreationDate="2023-10-23T15:20:24.760" Score="4" Body="&lt;p&gt;The MIP model by Erwin Kalvelagen is a good way to solve the problem, and is probably quite efficient.&lt;/p&gt;&#xA;&lt;p&gt;As an alternative, the following &lt;a href=&quot;https://www.minizinc.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MiniZinc&lt;/a&gt; model is a fairly straight-forward model based on the problem description. Additionaly, it can be used with different types of solvers.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;% The data-set of a problem&#xA;enum Teams;&#xA;enum Individuals;&#xA;enum Timeslots;&#xA;array[Teams] of set of Individuals: team_members;&#xA;&#xA;% The meeting time for each team&#xA;array[Teams] of var Timeslots: meeting_time;&#xA;&#xA;% The count of overlaps&#xA;var int: overlaps = sum(t1, t2 in Teams where t1 &amp;lt; t2) (&#xA;    if meeting_time[t1] = meeting_time[t2] then&#xA;        card(team_members[t1] intersect team_members[t2])&#xA;    else&#xA;        0&#xA;    endif&#xA;);&#xA;&#xA;% Solve minimizing the number of overlaps using the solvers default strategy&#xA;solve minimize overlaps;&#xA;&#xA;% Variables for counting the conflicts for each individual, used only for output&#xA;array[Individuals, Timeslots] of var int: conflicts = array2d(Individuals, Timeslots, [&#xA;    let {&#xA;      var int: meetings = count(t in Teams where i in team_members[t]) (&#xA;          meeting_time[t] = m&#xA;      )&#xA;    } in&#xA;    meetings&#xA;  | i in Individuals, m in Timeslots&#xA;]);&#xA;&#xA;output [&#xA;    &amp;quot;Times: \(meeting_time)\n&amp;quot;,&#xA;    &amp;quot;Total overlaps: \(overlaps)\n&amp;quot;,&#xA;    &amp;quot;Conflicts: \n&amp;quot;, show2d(conflicts),&amp;quot;\n&amp;quot;,&#xA;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The data can be supplied in a &lt;code&gt;dzn&lt;/code&gt;-file. Here is a file corresponding to the instance in Kalvelagens reply&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Timeslots = {M1, M2, M3};&#xA;Individuals = {I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16, I17, I18, I19, I20};&#xA;Teams = {T1, T2, T3, T4, T5, T6};&#xA;&#xA;team_members = [&#xA;    {I1, I6, I10, I11, I13, I15, I17, I19},&#xA;    {I8, I10, I11, I14, I15},&#xA;    {I2, I3, I5, I6, I14, I17, I20},&#xA;    {I8, I14, I18, I19},&#xA;    {I3, I4, I10, I11, I12, I17, I20},&#xA;    {I1, I4, I7, I11, I12, I13, I17},&#xA;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In MiniZinc version 2.7.6 with the default solver (Gecode 6.3.0, with statistics), the output is as follows&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[...]&#xA;----------&#xA;Times: [M2, M1, M1, M3, M3, M1]&#xA;Total overlaps: 3&#xA;Conflicts: &#xA;[|      M1: M2: M3: &#xA; |  I1:  1,  1,  0&#xA; |  I2:  1,  0,  0&#xA; |  I3:  1,  0,  1&#xA; |  I4:  1,  0,  1&#xA; |  I5:  1,  0,  0&#xA; |  I6:  1,  1,  0&#xA; |  I7:  1,  0,  0&#xA; |  I8:  1,  0,  1&#xA; |  I9:  0,  0,  0&#xA; | I10:  1,  1,  1&#xA; | I11:  2,  1,  1&#xA; | I12:  1,  0,  1&#xA; | I13:  1,  1,  0&#xA; | I14:  2,  0,  1&#xA; | I15:  1,  1,  0&#xA; | I16:  0,  0,  0&#xA; | I17:  2,  1,  1&#xA; | I18:  0,  0,  1&#xA; | I19:  0,  1,  1&#xA; | I20:  1,  0,  1&#xA; |]&#xA;----------&#xA;==========&#xA;%%%mzn-stat: failures=23&#xA;%%%mzn-stat: initTime=0.000784&#xA;%%%mzn-stat: nodes=61&#xA;%%%mzn-stat: peakDepth=7&#xA;%%%mzn-stat: propagations=3096&#xA;%%%mzn-stat: propagators=122&#xA;%%%mzn-stat: restarts=0&#xA;%%%mzn-stat: solutions=8&#xA;%%%mzn-stat: solveTime=0.000591&#xA;%%%mzn-stat: variables=121&#xA;%%%mzn-stat-end&#xA;%%%mzn-stat: nSolutions=8&#xA;%%%mzn-stat-end&#xA;Finished in 68msec.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Using OR-Tools 9.7 as the solver, gives the following statistics&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[...]&#xA;Times: [M1, M2, M1, M3, M3, M2]&#xA;Total overlaps: 3&#xA;Conflicts: &#xA;[|      M1: M2: M3: &#xA; |  I1:  1,  1,  0&#xA; |  I2:  1,  0,  0&#xA; |  I3:  1,  0,  1&#xA; |  I4:  0,  1,  1&#xA; |  I5:  1,  0,  0&#xA; |  I6:  2,  0,  0&#xA; |  I7:  0,  1,  0&#xA; |  I8:  0,  1,  1&#xA; |  I9:  0,  0,  0&#xA; | I10:  1,  1,  1&#xA; | I11:  1,  2,  1&#xA; | I12:  0,  1,  1&#xA; | I13:  1,  1,  0&#xA; | I14:  1,  1,  1&#xA; | I15:  1,  1,  0&#xA; | I16:  0,  0,  0&#xA; | I17:  2,  1,  1&#xA; | I18:  0,  0,  1&#xA; | I19:  1,  0,  1&#xA; | I20:  1,  0,  1&#xA; |]&#xA;----------&#xA;==========&#xA;%%%mzn-stat: nSolutions=9&#xA;%%%mzn-stat-end&#xA;%%%mzn-stat: boolVariables=63&#xA;%%%mzn-stat: failures=26&#xA;%%%mzn-stat: objective=3&#xA;%%%mzn-stat: objectiveBound=3&#xA;%%%mzn-stat: propagations=5882&#xA;%%%mzn-stat: solveTime=0.009147&#xA;%%%mzn-stat-end&#xA;Finished in 98msec.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Using the included HiGHS MIP solver gives the following statistics&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;%%%mzn-stat: nodes=7&#xA;%%%mzn-stat: objective=3&#xA;%%%mzn-stat: objectiveBound=3&#xA;%%%mzn-stat: solveTime=0.2083&#xA;%%%mzn-stat-end&#xA;Times: [M3, M2, M3, M1, M1, M2]&#xA;Total overlaps: 3&#xA;Conflicts: &#xA;[|      M1: M2: M3: &#xA; |  I1:  0,  1,  1&#xA; |  I2:  0,  0,  1&#xA; |  I3:  1,  0,  1&#xA; |  I4:  1,  1,  0&#xA; |  I5:  0,  0,  1&#xA; |  I6:  0,  0,  2&#xA; |  I7:  0,  1,  0&#xA; |  I8:  1,  1,  0&#xA; |  I9:  0,  0,  0&#xA; | I10:  1,  1,  1&#xA; | I11:  1,  2,  1&#xA; | I12:  1,  1,  0&#xA; | I13:  0,  1,  1&#xA; | I14:  1,  1,  1&#xA; | I15:  0,  1,  1&#xA; | I16:  0,  0,  0&#xA; | I17:  1,  1,  2&#xA; | I18:  1,  0,  0&#xA; | I19:  1,  0,  1&#xA; | I20:  1,  0,  1&#xA; |]&#xA;----------&#xA;==========&#xA;%%%mzn-stat: nodes=7&#xA;%%%mzn-stat: objective=3&#xA;%%%mzn-stat: objectiveBound=3&#xA;%%%mzn-stat: solveTime=0.2083&#xA;%%%mzn-stat-end&#xA;%%%mzn-stat: nSolutions=1&#xA;%%%mzn-stat-end&#xA;Finished in 291msec.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Since this is a fairly simple instance, there is no real insight in testing the different solvers. With larger instances, there is probably a lot more to be gained from choosing the right solver and adding parallel search.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;In addition, the &lt;code&gt;conflicts&lt;/code&gt; array of variables in the model is just added to get some pretty output, it is not useful for solving the problem. To get the best speed, the variables (and the output statement that uses them) should probably be removed.&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="301" LastEditDate="2023-10-25T05:10:10.310" LastActivityDate="2023-10-25T05:10:10.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11149" PostTypeId="1" AcceptedAnswerId="11151" CreationDate="2023-10-23T15:30:01.330" Score="2" ViewCount="172" Body="&lt;p&gt;I have two sets of binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{i,k}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$i, j, k$&lt;/span&gt; ranges over some index set &lt;span class=&quot;math-container&quot;&gt;$I,J,K$&lt;/span&gt;, which satisfies the constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_j x_{i,j} = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\sum_{k} y_{i, k} = 1$&lt;/span&gt;. How do I express the cardinality of the set &lt;span class=&quot;math-container&quot;&gt;$S_k := \{j: x_{i, j} =1 \text{ and } y_{i, k} = 1 \text{ for some } i\}$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;? I am trying to minimize an expression which is a linear combination of the cardinalities &lt;span class=&quot;math-container&quot;&gt;$|S_k|$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4743" LastActivityDate="2023-10-23T21:50:19.370" Title="Express cardinality of index set satisfying conditions" Tags="|mixed-integer-programming|logical-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11150" PostTypeId="2" ParentId="11144" CreationDate="2023-10-23T15:40:20.797" Score="0" Body="&lt;p&gt;Try adding the &lt;code&gt;symbolic_solver_labels=True&lt;/code&gt; option to your call to &lt;code&gt;solve&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;result = opt.solve(model, warmstart=True, tee=True, symbolic_solver_labels=True, options_string=&amp;quot;ResultFile=iis_{}.ilp&amp;quot;.format(&amp;quot;model&amp;quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This option should preserve the variable names that you set when the model gets passed to the solver.&lt;/p&gt;&#xA;" OwnerUserId="583" LastActivityDate="2023-10-23T15:40:20.797" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11151" PostTypeId="2" ParentId="11149" CreationDate="2023-10-23T15:52:02.120" Score="3" Body="&lt;p&gt;Let&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{ijk} = 1$&lt;/span&gt; iff. &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 1 \wedge y_{ik} = 1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in I, j \in J, k \in K$&lt;/span&gt;; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{kj} = 1$&lt;/span&gt; iff. &lt;span class=&quot;math-container&quot;&gt;$\exists_{i \in I} (z_{ijk} = 1)$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall j \in J, k \in K$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Then:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{ijk} \geqslant x_{ij} + y_{ik} - 1$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in I, j \in J, k \in K$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij} \geqslant z_{ijk}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in I, j \in J, k \in K$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{ik} \geqslant z_{ijk}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in I, j \in J, k \in K$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s_{kj} \geqslant z_{ijk}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in I, j \in J, k \in K$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I} z_{ijk} \geqslant s_{kj}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall j \in J, k \in K$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$S_k = \sum_{j \in J} s_{kj}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall k \in K$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let me know case you see any mistake.&lt;/p&gt;&#xA;&lt;p&gt;UPDATE: Thanks to @RobPratt.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="2862" LastEditDate="2023-10-23T16:52:37.547" LastActivityDate="2023-10-23T16:52:37.547" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11152" PostTypeId="1" CreationDate="2023-10-23T17:21:42.820" Score="0" ViewCount="34" Body="&lt;p&gt;Let's consider the following (MQ)IP:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min x^T Q x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t. &lt;span class=&quot;math-container&quot;&gt;$g(x) \geqslant 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i \in \mathbb{Z}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;By ignoring the integrality constraints we end up with the QP:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min x^T Q x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t. &lt;span class=&quot;math-container&quot;&gt;$g(x) \geqslant 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Whose lagrangian function would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\mathcal{L}(x, \lambda) = x^T Q x - \lambda^T g(x)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And whose stationarity condition would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\nabla_x \mathcal{L} = 2 Q x - \lambda^T \nabla_x g = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Which allows us to build the following problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min \frac{1}{2} x^T (\lambda^T \nabla_x g)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t. &lt;span class=&quot;math-container&quot;&gt;$2 Q x - \lambda^T \nabla_x g = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$g(x) \geqslant 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \leqslant g(x) \perp \lambda \geqslant 0$&lt;/span&gt; (Orthogonality condition)&lt;/p&gt;&#xA;&lt;p&gt;If, we try to place back the integrality constraint, the stationarity condition not necessarily will be maintained, thence, on this reasoning, I though in adding slacks to the stationarity condition, and penalize them in the objective function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min \frac{1}{2} x^T (\lambda^T \nabla_x g) + \sum_{i = 1}^n \epsilon_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t. &lt;span class=&quot;math-container&quot;&gt;$\epsilon \geqslant 2 Q x - \lambda^T \nabla_x g \geqslant - \epsilon$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$g(x) \geqslant 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_i \in \mathbb{Z}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$i \in I$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \leqslant g(x) \perp \lambda \geqslant 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I conducted some few experiments over a quadratic problem, and I could manage to make the new objective solution (&lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2} x^T (\lambda^T \nabla_x g) + \sum_{i = 1}^n \epsilon_i$&lt;/span&gt;) match the original objective function (&lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;) for integer assignments.&lt;/p&gt;&#xA;&lt;p&gt;I would like to know if someone ever tried to adapt stationarity conditions for IPs.&#xA;Of course, one may argue about binary transformation + &lt;span class=&quot;math-container&quot;&gt;$x_i (1 - x_i) = 0$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\forall i \in I$&lt;/span&gt;, but I am looking for a strategy that does not rely on adding more non linearities.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastActivityDate="2023-10-23T17:21:42.820" Title="Stationarity conditions for IPs" Tags="|integer-programming|kkt-conditions|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11154" PostTypeId="2" ParentId="11149" CreationDate="2023-10-23T21:50:19.370" Score="3" Body="&lt;p&gt;You can strengthen the formulation given by @Matheus Diógenes Andrade by replacing the &lt;span class=&quot;math-container&quot;&gt;$x_{ij} \ge z_{ijk}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{ik} \ge z_{ijk}$&lt;/span&gt; constraints.  We are given&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j x_{ij} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \tag1\label1 \\&#xA;\sum_k y_{ik} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Now multiply \eqref{1} by &lt;span class=&quot;math-container&quot;&gt;$y_{ik}$&lt;/span&gt; and \eqref{2} by &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; to obtain&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j x_{ij}y_{ik} &amp;amp;= y_{ik} &amp;amp;&amp;amp;\text{for all $i$ and $k$} \tag3\label3 \\&#xA;\sum_k y_{ik}x_{ij} &amp;amp;= x_{ij} &amp;amp;&amp;amp;\text{for all $i$ and $j$} \tag4\label4&#xA;\end{align}&lt;/span&gt;&#xA;Now replace the product &lt;span class=&quot;math-container&quot;&gt;$x_{ij} y_{ik}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$z_{ijk}$&lt;/span&gt; to obtain&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j z_{ijk} &amp;amp;= y_{ik} &amp;amp;&amp;amp;\text{for all $i$ and $k$} \tag5\label5 \\&#xA;\sum_k z_{ijk} &amp;amp;= x_{ij} &amp;amp;&amp;amp;\text{for all $i$ and $j$} \tag6\label6&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This change yields a formulation that is both tighter and smaller.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-10-23T21:50:19.370" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11156" PostTypeId="1" CreationDate="2023-10-24T02:15:49.990" Score="0" ViewCount="108" Body="&lt;p&gt;I am trying to use Gurobi optimization software in a Jupyter notebook on a Compute Canada HPC server, but I am running into issues importing the gurobipy module in Python.&lt;/p&gt;&#xA;&lt;p&gt;I have loaded the Gurobi module successfully using 'module load gurobipy' in Mobaxterm, and I can see the license is correctly set up. However, when I try to import gurobipy in a Jupyter notebook, I get an error saying &amp;quot;No module named gurobipy&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Additionally, when I try to install gurobipy using 'pip install gurobipy', I get error messages saying the package cannot be found.&lt;/p&gt;&#xA;&lt;p&gt;I have reviewed the Gurobi documentation on the Compute Canada wiki (&lt;a href=&quot;https://docs.alliancecan.ca/wiki/Gurobi&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.alliancecan.ca/wiki/Gurobi&lt;/a&gt;), including the Jupyter notebook instructions and video tutorial, but I am still unsure how to resolve this import issue within my Jupyter environment.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;How do I install and configure Gurobi and the gurobipy module so it can be imported correctly in a Jupyter notebook on Compute Canada?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="11516" LastEditorUserId="727" LastEditDate="2023-11-02T00:18:32.820" LastActivityDate="2023-11-02T00:18:32.820" Title="Troubleshooting Gurobi Import Errors in Jupyter Notebook on Compute Canada HPC server" Tags="|gurobi|gurobipy|high-performance-computing|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11157" PostTypeId="2" ParentId="11145" CreationDate="2023-10-24T11:42:58.370" Score="2" Body="&lt;p&gt;How about something like this?&lt;/p&gt;&#xA;&lt;p&gt;Assume that the statement is true for all values of &lt;span class=&quot;math-container&quot;&gt;$n \le K$&lt;/span&gt;, and that &lt;span class=&quot;math-container&quot;&gt;$C_i(a)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$P_{i,j}(a)$&lt;/span&gt; are positive functions of &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;.  Then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray*}&#xA;V_{K+1}(i) &amp;amp; = &amp;amp; \min_a \left\{C_i(a) + \sum_j P_{i,j}(a) V_{K}(j)\right\} \\&#xA;        &amp;amp; \ge &amp;amp; \min_a \left\{C_i(a) + \sum_j P_{i,j}(a) V_{K-1} (j)&#xA;\right\} \\&#xA;        &amp;amp; = &amp;amp; V_K (i)&#xA;\end{eqnarray*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The second line follows from the induction hypothesis, and the third from the definition.&lt;/p&gt;&#xA;" OwnerUserId="12706" LastEditorUserId="491" LastEditDate="2023-10-24T12:50:04.627" LastActivityDate="2023-10-24T12:50:04.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11158" PostTypeId="2" ParentId="5331" CreationDate="2023-10-25T14:17:56.143" Score="0" Body="&lt;p&gt;Well, once upon a time, CPLEX didn't use cutting planes on the obj, but if you define&lt;/p&gt;&#xA;&lt;p&gt;dvar int z&#xA;minimize z&#xA;s.t.&#xA;z = obj (....)&lt;/p&gt;&#xA;&lt;p&gt;then you shhould have CPLEX cutting the tree at 61.0&lt;/p&gt;&#xA;&lt;p&gt;At least this was happening some CPLEX releases ago.&lt;/p&gt;&#xA;" OwnerUserId="12700" LastActivityDate="2023-10-25T14:17:56.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11159" PostTypeId="1" AcceptedAnswerId="11164" CreationDate="2023-10-26T13:50:35.923" Score="1" ViewCount="295" Body="&lt;p&gt;I am currently trying to understand the integer L-shaped-method/stochastic version of Benders Decomposition because I have practical problem MIP that is stochastic and thus has very good decomposition structure for Benders.&lt;/p&gt;&#xA;&lt;p&gt;To get familiar with Benders Decomposition, I started off with implementing the deterministic version of my problem with Benders. That worked successfully and I'd like to think I understood the Benders algorithm in the deterministic case with integer variables in the master problem and continuous variables in the subproblem.&lt;/p&gt;&#xA;&lt;p&gt;Now though, I kind of struggle to transform my problem into a stochastic enviroment. The main issue is that I can't seem to find good material/literature that explain this step going from deterministic Benders to the stochastic version.&lt;/p&gt;&#xA;&lt;p&gt;Most literature explains the L-shaped-method in a very theoretical manner (i.e. Van Slyke and Wets 1969, Kall and Wallace 1994, Birge and Louveaux (2011). I struggle to follow the explanations given in those works. Mainly because it seems so far away from the original Benders without explaining in detail where the differences come from. Also, I think for the most part these works concentrate on LPs and not on MIPs.&lt;/p&gt;&#xA;&lt;p&gt;With this post, I wanted to ask if anyone knows good material that is more &amp;quot;hands-on&amp;quot; and delivers a more practical approach (maybe even an example) for the integer L-shaped-method/stochastic integer Benders?&lt;/p&gt;&#xA;&lt;p&gt;Maybe, if one is familiar with the method, he could even explain it himself.&lt;/p&gt;&#xA;" OwnerUserId="12130" LastEditorUserId="491" LastEditDate="2023-10-26T14:08:58.040" LastActivityDate="2023-11-25T22:04:20.617" Title="Understanding the L-shaped-method and the different variants of it" Tags="|mixed-integer-programming|algorithms|stochastic-programming|benders-decomposition|literature-research|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11160" PostTypeId="2" ParentId="11159" CreationDate="2023-10-26T14:43:37.360" Score="0" Body="&lt;p&gt;My personal experience to learn L-shaped method, I used &amp;quot;Introduction to Stochastic Programming&amp;quot; by John R. Birge&lt;/p&gt;&#xA;&lt;p&gt;Also, I tried to implement Integer L-shaped method in C# and Cplex by referencing &amp;quot;Laporte, G., &amp;amp; Louveaux, F. V. (1993). The integer L-shaped method for stochastic integer programs with complete recourse. Operations research letters, 13(3), 133-142.&amp;quot;&#xA;You can refer my github, I have uploaded my source code&#xA;&lt;a href=&quot;https://github.com/ytsao/Integer-L-shaped-method/blob/main/IntegerLShapedMethod-Final/IntegerLShapedMethod/ILShaped.cs&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ytsao/Integer-L-shaped-method/blob/main/IntegerLShapedMethod-Final/IntegerLShapedMethod/ILShaped.cs&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In addition, my friend's research is related Integer L-shaped method as well.&#xA;&amp;quot;Lin, D. Y., &amp;amp; Kuo, J. K. (2021). The vehicle deployment and relocation problem for electric vehicle sharing systems considering demand and parking space stochasticity. Transportation Research Part E: Logistics and Transportation Review, 156, 102514.&amp;quot;&lt;/p&gt;&#xA;" OwnerUserId="12370" LastActivityDate="2023-10-26T14:43:37.360" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11161" PostTypeId="1" AcceptedAnswerId="11162" CreationDate="2023-10-26T18:36:47.033" Score="0" ViewCount="90" Body="&lt;p&gt;I have a problem with implementing the Dantzig–Fulkerson–Johnson formulation to solve the following Travelling Salesman Problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{bmatrix}&#xA;M &amp;amp; 21 &amp;amp; 17 &amp;amp; 19 &amp;amp; 21 &amp;amp; 22\\&#xA;26 &amp;amp; M &amp;amp; 18 &amp;amp; 27 &amp;amp; 27 &amp;amp; 26\\&#xA;20 &amp;amp; 25 &amp;amp; M &amp;amp; 27 &amp;amp; 26 &amp;amp; 24\\&#xA;18 &amp;amp; 20 &amp;amp; 15 &amp;amp; M &amp;amp; 17 &amp;amp; 19\\&#xA;24 &amp;amp; 25 &amp;amp; 15 &amp;amp; 26 &amp;amp; M &amp;amp; 25\\&#xA;18 &amp;amp; 18 &amp;amp; 27 &amp;amp; 21 &amp;amp; 25 &amp;amp; M&#xA;\end{bmatrix}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I managed to create the following code (sorry for not optimizing it, I'm a total newbie):&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-ruby prettyprint-override&quot;&gt;&lt;code&gt;var x12 &amp;gt;= 0 binary;&#xA;var x13 &amp;gt;= 0 binary;&#xA;var x14 &amp;gt;= 0 binary;&#xA;var x15 &amp;gt;= 0 binary;&#xA;var x16 &amp;gt;= 0 binary;&#xA;&#xA;var x21 &amp;gt;= 0 binary;&#xA;var x23 &amp;gt;= 0 binary;&#xA;var x24 &amp;gt;= 0 binary;&#xA;var x25 &amp;gt;= 0 binary;&#xA;var x26 &amp;gt;= 0 binary;&#xA;&#xA;var x31 &amp;gt;= 0 binary;&#xA;var x32 &amp;gt;= 0 binary;&#xA;var x34 &amp;gt;= 0 binary;&#xA;var x35 &amp;gt;= 0 binary;&#xA;var x36 &amp;gt;= 0 binary;&#xA;&#xA;var x41 &amp;gt;= 0 binary;&#xA;var x42 &amp;gt;= 0 binary;&#xA;var x43 &amp;gt;= 0 binary;&#xA;var x45 &amp;gt;= 0 binary;&#xA;var x46 &amp;gt;= 0 binary;&#xA;&#xA;var x51 &amp;gt;= 0 binary;&#xA;var x52 &amp;gt;= 0 binary;&#xA;var x53 &amp;gt;= 0 binary;&#xA;var x54 &amp;gt;= 0 binary;&#xA;var x56 &amp;gt;= 0 binary;&#xA;&#xA;var x61 &amp;gt;= 0 binary;&#xA;var x62 &amp;gt;= 0 binary;&#xA;var x63 &amp;gt;= 0 binary;&#xA;var x64 &amp;gt;= 0 binary;&#xA;var x65 &amp;gt;= 0 binary;&#xA;&#xA;minimize z: 21*x12 + 17*x13 + 19*x14 + 21*x15 + 22*x16 + 26*x21 +18*x23 + 27*x24+ 27*x25&#xA; + 26*x26+ 20*x31 + 25*x32 + 27*x34 + 26*x35 + 24*x36 + 18*x41 + 20*x42 + 15*x43 + 17*x45 + 19*x46&#xA; + 24*x51 + 25*x52 + 15*x53 + 26*x54 + 25*x56 + 18*x61 + 18*x62 + 27*x63 + 21*x64 + 25*x65;&#xA;&#xA;&#xA;subject to WY1:   x12+x13+x14+x15+x16=1;&#xA;subject to WY2:   x21+x23+x24+x25+x26=1;&#xA;subject to WY3:   x31+x32+x34+x35+x36=1;&#xA;subject to WY4:   x41+x42+x43+x45+x46=1;&#xA;subject to WY5:   x51+x52+x53+x54+x56=1;&#xA;subject to WY6:   x61+x62+x63+x64+x65=1;&#xA;&#xA;subject to WE1:   x21+x31+x41+x51+x61=1;&#xA;subject to WE2:   x12+x32+x42+x52+x62=1;&#xA;subject to WE3:   x13+x23+x43+x53+x63=1;&#xA;subject to WE4:   x14+x24+x34+x54+x64=1;&#xA;subject to WE5:   x15+x25+x35+x45+x65=1;&#xA;subject to WE6:   x16+x26+x36+x46+x56=1;&#xA;&#xA;# subtour for each subset of vertices of length &amp;gt;= 2:&#xA;subject to subtour1: x12 + x21 &amp;lt;= 1;&#xA;subject to subtour2: x13 + x31 &amp;lt;= 1;&#xA;subject to subtour3: x14 + x41 &amp;lt;= 1;&#xA;subject to subtour4: x15 + x51 &amp;lt;= 1;&#xA;subject to subtour5: x16 + x61 &amp;lt;= 1;&#xA;subject to subtour6: x23 + x32 &amp;lt;= 1;&#xA;subject to subtour7: x24 + x42 &amp;lt;= 1;&#xA;subject to subtour8: x25 + x52 &amp;lt;= 1;&#xA;subject to subtour9: x26 + x62 &amp;lt;= 1;&#xA;subject to subtour10: x34 + x43 &amp;lt;= 1;&#xA;subject to subtour11: x35 + x53 &amp;lt;= 1;&#xA;subject to subtour12: x36 + x63 &amp;lt;= 1;&#xA;subject to subtour13: x45 + x54 &amp;lt;= 1;&#xA;subject to subtour14: x46 + x64 &amp;lt;= 1;&#xA;subject to subtour15: x56 + x65 &amp;lt;= 1;&#xA;subject to subtour16: x12 + x13 + x21 + x23 + x31 + x32 &amp;lt;= 2;&#xA;subject to subtour17: x12 + x14 + x21 + x24 + x41 + x42 &amp;lt;= 2;&#xA;subject to subtour18: x12 + x15 + x21 + x25 + x51 + x52 &amp;lt;= 2;&#xA;subject to subtour19: x12 + x16 + x21 + x26 + x61 + x62 &amp;lt;= 2;&#xA;subject to subtour20: x13 + x14 + x31 + x34 + x41 + x43 &amp;lt;= 2;&#xA;subject to subtour21: x13 + x15 + x31 + x35 + x51 + x53 &amp;lt;= 2;&#xA;subject to subtour22: x13 + x16 + x31 + x36 + x61 + x63 &amp;lt;= 2;&#xA;subject to subtour23: x14 + x15 + x41 + x45 + x51 + x54 &amp;lt;= 2;&#xA;subject to subtour24: x14 + x16 + x41 + x46 + x61 + x64 &amp;lt;= 2;&#xA;subject to subtour25: x15 + x16 + x51 + x56 + x61 + x65 &amp;lt;= 2;&#xA;subject to subtour26: x23 + x24 + x32 + x34 + x42 + x43 &amp;lt;= 2;&#xA;subject to subtour27: x23 + x25 + x32 + x35 + x52 + x53 &amp;lt;= 2;&#xA;subject to subtour28: x23 + x26 + x32 + x36 + x62 + x63 &amp;lt;= 2;&#xA;subject to subtour29: x24 + x25 + x42 + x45 + x52 + x54 &amp;lt;= 2;&#xA;subject to subtour30: x24 + x26 + x42 + x46 + x62 + x64 &amp;lt;= 2;&#xA;subject to subtour31: x25 + x26 + x52 + x56 + x62 + x65 &amp;lt;= 2;&#xA;subject to subtour32: x34 + x35 + x43 + x45 + x53 + x54 &amp;lt;= 2;&#xA;subject to subtour33: x34 + x36 + x43 + x46 + x63 + x64 &amp;lt;= 2;&#xA;subject to subtour34: x35 + x36 + x53 + x56 + x63 + x65 &amp;lt;= 2;&#xA;subject to subtour35: x45 + x46 + x54 + x56 + x64 + x65 &amp;lt;= 2;&#xA;subject to subtour36: x12 + x13 + x14 + x21 + x23 + x24 + x31 + x32 + x34 + x41 + x42 + x43 &amp;lt;= 3;&#xA;subject to subtour37: x12 + x13 + x15 + x21 + x23 + x25 + x31 + x32 + x35 + x51 + x52 + x53 &amp;lt;= 3;&#xA;subject to subtour38: x12 + x13 + x16 + x21 + x23 + x26 + x31 + x32 + x36 + x61 + x62 + x63 &amp;lt;= 3;&#xA;subject to subtour39: x12 + x14 + x15 + x21 + x24 + x25 + x41 + x42 + x45 + x51 + x52 + x54 &amp;lt;= 3;&#xA;subject to subtour40: x12 + x14 + x16 + x21 + x24 + x26 + x41 + x42 + x46 + x61 + x62 + x64 &amp;lt;= 3;&#xA;subject to subtour41: x12 + x15 + x16 + x21 + x25 + x26 + x51 + x52 + x56 + x61 + x62 + x65 &amp;lt;= 3;&#xA;subject to subtour42: x13 + x14 + x15 + x31 + x34 + x35 + x41 + x43 + x45 + x51 + x53 + x54 &amp;lt;= 3;&#xA;subject to subtour43: x13 + x14 + x16 + x31 + x34 + x36 + x41 + x43 + x46 + x61 + x63 + x64 &amp;lt;= 3;&#xA;subject to subtour44: x13 + x15 + x16 + x31 + x35 + x36 + x51 + x53 + x56 + x61 + x63 + x65 &amp;lt;= 3;&#xA;subject to subtour45: x14 + x15 + x16 + x41 + x45 + x46 + x51 + x54 + x56 + x61 + x64 + x65 &amp;lt;= 3;&#xA;subject to subtour46: x23 + x24 + x25 + x32 + x34 + x35 + x42 + x43 + x45 + x52 + x53 + x54 &amp;lt;= 3;&#xA;subject to subtour47: x23 + x24 + x26 + x32 + x34 + x36 + x42 + x43 + x46 + x62 + x63 + x64 &amp;lt;= 3;&#xA;subject to subtour48: x23 + x25 + x26 + x32 + x35 + x36 + x52 + x53 + x56 + x62 + x63 + x65 &amp;lt;= 3;&#xA;subject to subtour49: x24 + x25 + x26 + x42 + x45 + x46 + x52 + x54 + x56 + x62 + x64 + x65 &amp;lt;= 3;&#xA;subject to subtour50: x34 + x35 + x36 + x43 + x45 + x46 + x53 + x54 + x56 + x63 + x64 + x65 &amp;lt;= 3;&#xA;subject to subtour51: x12 + x13 + x14 + x15 + x21 + x23 + x24 + x25 + x31 + x32 + x34 + x35 + x41 + x42 + x43 + x45 + x51 + x52 + x53 + x54 &amp;lt;= 4;&#xA;subject to subtour52: x12 + x13 + x14 + x16 + x21 + x23 + x24 + x26 + x31 + x32 + x34 + x36 + x41 + x42 + x43 + x46 + x61 + x62 + x63 + x64 &amp;lt;= 4;&#xA;subject to subtour53: x12 + x13 + x15 + x16 + x21 + x23 + x25 + x26 + x31 + x32 + x35 + x36 + x51 + x52 + x53 + x56 + x61 + x62 + x63 + x65 &amp;lt;= 4;&#xA;subject to subtour54: x12 + x14 + x15 + x16 + x21 + x24 + x25 + x26 + x41 + x42 + x45 + x46 + x51 + x52 + x54 + x56 + x61 + x62 + x64 + x65 &amp;lt;= 4;&#xA;subject to subtour55: x13 + x14 + x15 + x16 + x31 + x34 + x35 + x36 + x41 + x43 + x45 + x46 + x51 + x53 + x54 + x56 + x61 + x63 + x64 + x65 &amp;lt;= 4;&#xA;subject to subtour56: x23 + x24 + x25 + x26 + x32 + x34 + x35 + x36 + x42 + x43 + x45 + x46 + x52 + x53 + x54 + x56 + x62 + x63 + x64 + x65 &amp;lt;= 4;&#xA;subject to subtour57: x12 + x13 + x14 + x15 + x16 + x21 + x23 + x24 + x25 + x26 + x31 + x32 + x34 + x35 + x36 + x41 + x42 + x43 + x45 + x46 + x51 + x52 + x53 + x54 + x56 + x61 + x62 + x63 + x64 + x65 &amp;lt;= 5;&#xA;&#xA;end;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I managed to generate all the constraints in Python as I don't know how to implement it in the model language.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, the code is not working:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;glpsol --model code.mod&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;Model has been successfully generated&#xA;GLPK Integer Optimizer 5.0&#xA;70 rows, 30 columns, 570 non-zeros&#xA;30 integer variables, all of which are binary&#xA;Preprocessing...&#xA;69 rows, 30 columns, 540 non-zeros&#xA;30 integer variables, all of which are binary&#xA;Scaling...&#xA; A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00&#xA;Problem data seem to be well scaled&#xA;Constructing initial basis...&#xA;Size of triangular part is 68&#xA;Solving LP relaxation...&#xA;GLPK Simplex Optimizer 5.0&#xA;69 rows, 30 columns, 540 non-zeros&#xA;      0: obj =   1.450000000e+02 inf =   3.400e+01 (18)&#xA;      7: obj =   1.280000000e+02 inf =   1.000e+00 (1)&#xA;LP HAS NO PRIMAL FEASIBLE SOLUTION&#xA;Time used:   0.0 secs&#xA;Memory used: 0.4 Mb (433124 bytes)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I know it is possible to limit the constraints thanks to the lazy constraint but a teacher wants us to write all the constraints.&lt;/p&gt;&#xA;&lt;p&gt;Would be great if anyone could help me solve this issue or even simplify my code.&lt;/p&gt;&#xA;&lt;h3&gt;EDIT -&amp;gt; SOLUTION:&lt;/h3&gt;&#xA;&lt;p&gt;First of all, big thanks to &lt;a href=&quot;https://or.stackexchange.com/users/500/robpratt&quot;&gt;@RobPratt&lt;/a&gt; and &lt;a href=&quot;https://or.stackexchange.com/users/12370/ytsao&quot;&gt;@ytsao&lt;/a&gt; for the answers!&lt;/p&gt;&#xA;&lt;p&gt;Turns out that, @RobPratt's answer was the solution.&lt;/p&gt;&#xA;&lt;p&gt;Expanding on his solution, I forgot about the fact that &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; must be a &lt;em&gt;&lt;strong&gt;proper subset&lt;/strong&gt;&lt;/em&gt; of vertices set:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Q\subset \{1, 2, 3, 4, 5, 6\} \implies Q \ne \{1, 2, 3, 4, 5, 6\}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;, that means it &lt;em&gt;&lt;strong&gt;cannot be equal&lt;/strong&gt;&lt;/em&gt; to vertices set.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, the error is the &lt;code&gt;subtour57&lt;/code&gt; constraint that comes from the &lt;span class=&quot;math-container&quot;&gt;$\{1, 2, 3, 4, 5, 6\}$&lt;/span&gt; subset, deleting it solved the problem.&lt;/p&gt;&#xA;" OwnerUserId="12722" LastEditorUserId="491" LastEditDate="2023-10-27T13:28:36.257" LastActivityDate="2023-10-27T13:28:36.257" Title="&quot;GLPK: No Primal Feasible Solution&quot; for Travelling Salesman Problem (Dantzig–Fulkerson–Johnson formulation)" Tags="|optimization|linear-programming|traveling-salesman|subtour-elimination|glpk|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11162" PostTypeId="2" ParentId="11161" CreationDate="2023-10-26T18:57:15.910" Score="6" Body="&lt;p&gt;The problem is indeed infeasible but becomes feasible if you omit the subtour57 constraint.  For a tour on &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; nodes, you need to use &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt; arcs, but that constraint allows only &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-10-26T18:57:15.910" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11163" PostTypeId="2" ParentId="11161" CreationDate="2023-10-26T19:15:17.050" Score="1" Body="&lt;p&gt;For python implementation using pyscipopt, you can refer as following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def Combination(n:int):&#xA;Q = []&#xA;&#xA;for i in range(2, n):&#xA;    Q.append(list(itertools.combinations(cities, i)))&#xA;&#xA;result = []&#xA;for i in Q:&#xA;    for j in i:&#xA;        result.append(list(j))&#xA;&#xA;return result&#xA;&#xA;&#xA;n = 6&#xA;cities = list(range(n))&#xA;&#xA;distance_matrix = [&#xA;    [9999, 21, 17, 19, 21, 22],&#xA;    [26, 9999, 18, 27, 27, 26],&#xA;    [20, 25, 9999, 27, 26, 24],&#xA;    [18, 20, 15, 9999, 17, 19],&#xA;    [24, 25, 15, 26, 9999, 25],&#xA;    [18, 18, 27, 21, 25, 9999]&#xA;]&#xA;&#xA;model = pyscipopt.Model(&amp;quot;TSP&amp;quot;)&#xA;&#xA;# Create variables&#xA;x = {}&#xA;for i in range(n):&#xA;    for j in range(n):&#xA;        if i == j:&#xA;            x[i,j] = model.addVar(lb=0, ub=0, vtype=&amp;quot;B&amp;quot;, name=&amp;quot;x(%s,%s)&amp;quot;%(i,j))&#xA;        else:&#xA;            x[i,j] = model.addVar(lb=0, ub=1, vtype=&amp;quot;B&amp;quot;, name=&amp;quot;x(%s,%s)&amp;quot;%(i,j))&#xA;&#xA;# Create objective function&#xA;model.setObjective(pyscipopt.quicksum(distance_matrix[i][j]*x[i,j] for i in range(n) for j in range(n)), sense=&amp;quot;minimize&amp;quot;)&#xA;&#xA;&#xA;# Create constraints&#xA;# Constraints 1&#xA;for i in range(n):&#xA;    model.addCons(pyscipopt.quicksum(x[i,j] for j in range(n)) == 1)&#xA;&#xA;# Constraints 2&#xA;for j in range(n):&#xA;    model.addCons(pyscipopt.quicksum(x[i,j] for i in range(n)) == 1)&#xA;&#xA;# Subtour-Elimination constraints (DFJ formulation)&#xA;Q = Combination(n)&#xA;&#xA;for each_q in Q:&#xA;    model.addCons(pyscipopt.quicksum(x[i,j]for i in each_q for j in each_q if i != j) &amp;lt;= len(each_q)-1)&#xA;&#xA;&#xA;model.writeProblem(&amp;quot;TSP.lp&amp;quot;)&#xA;model.optimize()&#xA;status = model.getStatus()&#xA;print(f&amp;quot;Solution status: {status}&amp;quot;)&#xA;if status == &amp;quot;optimal&amp;quot;:&#xA;    print(f&amp;quot;Objective value = {model.getObjVal()}&amp;quot;)&#xA;    for i in range(n):&#xA;        for j in range(n):&#xA;            print(f&amp;quot;{x[i,j]} = {model.getVal(x[i,j])}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12370" LastActivityDate="2023-10-26T19:15:17.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11164" PostTypeId="2" ParentId="11159" CreationDate="2023-10-26T22:01:44.297" Score="0" Body="&lt;p&gt;The &amp;quot;integer L-shaped method&amp;quot; and the &amp;quot;stochastic version of Benders Decomposition&amp;quot; are not the same thing. To understand the &amp;quot;integer L-shaped method&amp;quot; you need to first understand the relationship between the &amp;quot;Benders Decomposition&amp;quot; and the &amp;quot;L-shaped method / stochastic version of Benders Decomposition&amp;quot;; then the relationship between the &amp;quot;L-shaped method&amp;quot; and the &amp;quot;integer L-shaped method&amp;quot;, as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Benders -&amp;gt;&lt;/strong&gt; (uncartainty) &lt;strong&gt;-&amp;gt; L-shaped -&amp;gt;&lt;/strong&gt; (integer sub problem) &lt;strong&gt;-&amp;gt; integer L-shaped&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The Benders Decomposition tackles one sub problem in each iteration, while the sub problem of the L-shaped method is a set of sub problems, one for each &lt;em&gt;scenario&lt;/em&gt;. For understanding &lt;strong&gt;&amp;quot;Benders -&amp;gt; L-shaped&amp;quot;&lt;/strong&gt;, I recommend:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;[slides &amp;amp; video]&lt;/strong&gt; Luedtke, J. (2016, August 9). Benders Decomposition for Solving Two-stage Stochastic Optimization Models. IMA New Directions Short Course on Mathematical Optimization, Department of Industrial and Systems Engineering University of Wisconsin-Madison. &lt;a href=&quot;https://web.archive.org/web/20220730224934/https://www.ima.umn.edu/2015-2016/ND8.1-12.16/25378&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://web.archive.org/web/20220730224934/https://www.ima.umn.edu/2015-2016/ND8.1-12.16/25378&lt;/a&gt; (video: &lt;a href=&quot;https://cdnapisec.kaltura.com/index.php/extwidget/preview/partner_id/1369852/uiconf_id/42156071/entry_id/0_vbur76bm/embed/dynamic&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cdnapisec.kaltura.com/index.php/extwidget/preview/partner_id/1369852/uiconf_id/42156071/entry_id/0_vbur76bm/embed/dynamic&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;An answer for &amp;quot;&lt;a href=&quot;https://or.stackexchange.com/a/11103/8718&quot;&gt;How do I check convergence in stochastic Benders?&#xA;&lt;/a&gt;&amp;quot; on this site&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Benders Decomposition and the L-shaped method relies on the &lt;em&gt;dual&lt;/em&gt; of the sub problem(s) to generate Benders cuts. Thus, the sub problem(s) must be pure linear programming without integer variables. The integer L-shaped method differs from the previous two because it allows &lt;em&gt;binary&lt;/em&gt; (0-1) varialbes in the subproblems. The main difference between the L-shaped and integer L-shaped is the form of the Benders cut. For understanding &lt;strong&gt;&amp;quot;L-shaped -&amp;gt; integer L-shaped&amp;quot;&lt;/strong&gt;, I recommend:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;[the original work]&lt;/strong&gt; Laporte, G., &amp;amp; Louveaux, F. V. (1993). The integer L-shaped method for stochastic integer programs with complete recourse. Operations Research Letters, 13(3), 133–142. &lt;a href=&quot;https://doi.org/10.1016/0167-6377(93)90002-X&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1016/0167-6377(93)90002-X&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;[a more recnet enhancement]&lt;/strong&gt; Angulo, G., Ahmed, S., &amp;amp; Dey, S. S. (2016). Improving the integer L-shaped method. INFORMS Journal on Computing, 28(3), 483–499. &lt;a href=&quot;https://doi.org/10.1287/ijoc.2016.0695&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/ijoc.2016.0695&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2023-10-26T22:01:44.297" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11165" PostTypeId="2" ParentId="11115" CreationDate="2023-10-27T09:47:45.130" Score="1" Body="&lt;p&gt;The original data mises the team 9,16 (these two do not belong to any team)&#xA;The code in OR-TOOLS&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Data&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from ortools.sat.python import cp_model&#xA;Timeslots = [1,2,3]&#xA;Individuals = [i+1 for i in range(20)]&#xA;Teams = [team+1 for team in range(6)]&#xA;&#xA;    team_members = {&#xA;        1:[1, 6, 10, 11, 13, 15, 17, 19],&#xA;        2:[8, 10, 11, 14, 15],&#xA;        3:[2, 3, 5, 6, 14, 17, 20],&#xA;        4:[8, 14, 18, 19],&#xA;        5:[3, 4, 10, 11, 12, 17, 20],&#xA;        6:[1, 4, 7, 11, 12, 13, 17],&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;The code&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;class VarArraySolutionPrinter(cp_model.CpSolverSolutionCallback):&#xA;    &amp;quot;&amp;quot;&amp;quot;Print intermediate solutions.&amp;quot;&amp;quot;&amp;quot;&#xA;&#xA;    def __init__(self, variables):&#xA;        cp_model.CpSolverSolutionCallback.__init__(self)&#xA;        self.__variables = variables&#xA;        self.__solution_count = 0&#xA;&#xA;&#xA;    def on_solution_callback(self):&#xA;        self.__solution_count += 1&#xA;&#xA;    def solution_count(self):&#xA;        return self.__solution_count&#xA;&#xA;&#xA;def SearchForAllSolutionsSampleSat():&#xA;    &amp;quot;&amp;quot;&amp;quot;Showcases calling the solver to search for all solutions.&amp;quot;&amp;quot;&amp;quot;&#xA;    # Creates the model.&#xA;    model = cp_model.CpModel()&#xA;    &#xA;    x = {(team,t):model.NewBoolVar(f&amp;quot;x_{team}_{t}&amp;quot;) for team in Teams for t in Timeslots}&#xA;    over_pt = {(p,t):model.NewIntVar(0,len(Teams)-1, f&amp;quot;over_{p}_{t}&amp;quot;) for p in Individuals for t in Timeslots}&#xA;    &#xA;    # Create the constraints.&#xA;    for team in Teams:&#xA;        model.AddExactlyOne([x[team,t] for t in Timeslots])&#xA;&#xA;    for t in Timeslots:&#xA;        for p in Individuals:&#xA;            expressions = [x[team,t] for team in Teams if p in team_members[team] ]&#xA;            model.Add(sum(expressions)-1&amp;lt;= over_pt[p,t])            &#xA;&#xA;    of_expr = sum([over_pt[p,t] for p in Individuals for t in Timeslots])&#xA;    model.Minimize(of_expr)&#xA;    # Create a solver and solve.&#xA;    solver = cp_model.CpSolver()&#xA;    solution_printer = VarArraySolutionPrinter([x,over_pt])&#xA;    # Enumerate all solutions.&#xA;    solver.parameters.enumerate_all_solutions = False&#xA;    # Solve.&#xA;    status = solver.Solve(model, solution_printer)&#xA;    print(f&amp;quot;Status = {solver.StatusName(status)}&amp;quot;)&#xA;    &#xA;    print('Overassigned' , [i[0] for i in over_pt if solver.Value(over_pt[i]) ])&#xA;&#xA;&#xA;    team_assignment = {}    &#xA;    for (team,t),v in x.items():&#xA;        if solver.Value(v)&amp;gt;0:&#xA;            team_assignment[team,t] =1 &#xA;            print(f&amp;quot;Team {team} ------&amp;gt;  time {t}&amp;quot;)&#xA;    print(f&amp;quot;Team member   {1} {2} {3} &amp;quot;)    &#xA;&#xA;    for p in Individuals:&#xA;        time_assign = []&#xA;        for t in Timeslots:&#xA;            a = [team for team in Teams if p in team_members[team] and (team,t) in team_assignment]&#xA;            if len(a)&amp;gt;0:&#xA;                time_assign.append(len(a))&#xA;            else:&#xA;                time_assign.append(0)&#xA;        print(f&amp;quot;{p}             {time_assign[0]} {time_assign[1]} {time_assign[2]} &amp;quot;)    &#xA;&#xA;SearchForAllSolutionsSampleSat()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Results&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Status = OPTIMAL&#xA;Overassigned [11, 14, 17]&#xA;Team 1 ------&amp;gt;  time 3&#xA;Team 2 ------&amp;gt;  time 1&#xA;Team 3 ------&amp;gt;  time 1&#xA;Team 4 ------&amp;gt;  time 2&#xA;Team 5 ------&amp;gt;  time 2&#xA;Team 6 ------&amp;gt;  time 1&#xA;Team member   1 2 3 &#xA;1             1 0 1 &#xA;2             1 0 0 &#xA;3             1 1 0 &#xA;4             1 1 0 &#xA;5             1 0 0 &#xA;6             1 0 1 &#xA;7             1 0 0 &#xA;8             1 1 0 &#xA;9             0 0 0 &#xA;10             1 1 1 &#xA;11             2 1 1 &#xA;12             1 1 0 &#xA;13             1 0 1 &#xA;14             2 1 0 &#xA;15             1 0 1 &#xA;16             0 0 0 &#xA;17             2 1 1 &#xA;18             0 1 0 &#xA;19             0 1 1 &#xA;20             1 1 0 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2023-10-30T14:10:24.363" LastActivityDate="2023-10-30T14:10:24.363" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11166" PostTypeId="1" CreationDate="2023-10-27T11:17:53.770" Score="1" ViewCount="82" Body="&lt;p&gt;I've encountered some weird behavior when using the Automatic Benders Decomposition in CPLEX.&lt;/p&gt;&#xA;&lt;p&gt;I initially solved the MIP without BD and then I compared the results against the Full, Workers and User strategies using the CPLEX Java API.&lt;/p&gt;&#xA;&lt;p&gt;While the User strategy yielded the same solution (optimal) found by the Single MIP, both the Full and Workers strategies are off by 0.5% from the optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;Now when I turned off the preprocessing presovle, all strategies were able to find the optimal solution, but of course this resulted in increased computational time.&lt;/p&gt;&#xA;&lt;p&gt;Next, I solved the same problem in CPLEX Interactive Optimizer using the generated LP file. Surprisingly, without turning off the preprocessing  presolve, the Full strategy found the optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;I noticed the same behavior when using CPLEX 20.10 and 22.11.&lt;/p&gt;&#xA;&lt;p&gt;So I am wondering why is this happening ? and How it can be avoided ?&lt;/p&gt;&#xA;&lt;p&gt;Since the log file is long to be posted here, I will attach it as a separate file for your reference.&#xA;&lt;a href=&quot;https://www.dropbox.com/scl/fi/ls11k2ib39j538ir3tiir/Automatic-Benders-CPLEX.txt?rlkey=fmuekrqgrobew9wgvxjckq35x&amp;amp;dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;log file&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11022" LastEditorUserId="491" LastEditDate="2023-10-27T13:29:01.617" LastActivityDate="2023-10-27T13:29:01.617" Title="Weird behavior when using Automatic Benders Decomposition in CPLEX" Tags="|mixed-integer-programming|cplex|benders-decomposition|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11168" PostTypeId="1" CreationDate="2023-10-28T20:20:51.570" Score="5" ViewCount="533" Body="&lt;p&gt;I have the following objective that I want to maximize:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\max_{U_T\in \mathbb{R}, x\in\mathbb{R}^T} J_\alpha(U_T) = \frac{\alpha}{\alpha-1}\log\left(\frac{\cosh(U_T)}{\cosh(\alpha U_T)^\frac{1}{\alpha}}\right) \,,\qquad \text{s.t:} \qquad U_T= Ax+b.&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb{R}^{1\times T}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b\in\mathbb{R}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\alpha&amp;gt;1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It is easy to show that this is, in fact, a pseudo-concave function by checking that:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\eta'_\alpha(u)(v-u)\leq0 \implies \eta_\alpha(v)\leq \eta_\alpha(u),&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\eta_\alpha(u) = \frac{\cosh(u)}{\cosh(\alpha u)^\frac{1}{\alpha}}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This, of course, implies the quasiconcavity of &lt;span class=&quot;math-container&quot;&gt;$J_\alpha(U_T)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here's a plot of the function that I made with Wolfram Mathematica:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/hZX40.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hZX40.png&quot; alt=&quot;Plot of &lt;span class=&quot;math-container&quot;&gt;$J_\alpha(x)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\alpha=2$&lt;/span&gt;.&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;-My &lt;strong&gt;questions&lt;/strong&gt; are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there a way to write this objective function as a DQCP compliant program in CVXPY?&lt;/li&gt;&#xA;&lt;li&gt;When &lt;span class=&quot;math-container&quot;&gt;$\alpha \to 1^+$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$J_1(u) := -\log[\frac{e^{u\tanh(u)}}{\cosh(u)} ]$&lt;/span&gt; pointwise. Is there a way to write that as a DQCP compliant program in CVXPY as well?&lt;/li&gt;&#xA;&lt;li&gt;If it can't be put into a DCP compliant formulation, what would you recommend that I do to solve this problem numerically (especially question 2)?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I'm using CVXPY since I'll add more complicated constraints later, but maybe the problem has a simple analytical solution as well.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;-&lt;strong&gt;What I have so far:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am especially interested in question 2, so I'm trying to solve that first.&lt;/p&gt;&#xA;&lt;p&gt;Using the definitions of &lt;span class=&quot;math-container&quot;&gt;$\cosh$&lt;/span&gt;, write:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;J_1(u) &amp;amp;:= \lim_{\alpha\to 1^+}J_\alpha(u)\\ &#xA;&amp;amp;= \log(\cosh(u)) -u \tanh(u)\\&#xA;&amp;amp;= \log\left(e^u + e^{-u}\right)-u \tanh(u) + K\\&#xA;&amp;amp;= -u\left(\log\left(\frac{1}{1 + e^{-2u}}\right)+ \tanh(u)\right) + K\\&#xA;&amp;amp;= -\frac{1}{2}f^{-1}(f(2u))(\log(f(2u))- \tanh(u)) + K,&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is a constant and &lt;span class=&quot;math-container&quot;&gt;$f(y) := 1/(1+e^{-y})$&lt;/span&gt; is the logistic function, with inverse given by &lt;span class=&quot;math-container&quot;&gt;$f^{-1}(y) = \log(\frac{y}{1-y})$&lt;/span&gt;. By the well-known relation &lt;a href=&quot;https://en.wikipedia.org/wiki/Logistic_function#Mathematical_properties&quot; rel=&quot;nofollow noreferrer&quot;&gt;(Wiki)&lt;/a&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\tanh(y) = 2f(2y) - 1,\end{equation}&lt;/span&gt;&#xA;and we can conclude that:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation} J_1(u) = T(f(2u)) + K, \end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$T:[0,1]\to\mathbb{R}$&lt;/span&gt; is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}T(z) = -\frac{1}{2}\log\left(\frac{z}{1-z}\right)\left(\log(z) - 2z-1\right).\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;T is in fact concave, as we can see from the graph of its second derivative in Mathematica:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n4YgH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n4YgH.png&quot; alt=&quot;Plot of &lt;span class=&quot;math-container&quot;&gt;$T(z)$&lt;/span&gt;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;By further manipulation of &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;, we get the expression:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;-2T(z) &amp;amp;= \log\left(\frac{z}{1-z}\right)(z + z - 1 + \log(z))\\&#xA; &amp;amp;= z\log\left(\frac{z}{1-z}\right) + (1-z)\log\left(\frac{1-z}{z}\right) + \log\left(\frac{z}{1-z}\right)\log(z)\\&#xA;&amp;amp;= 2\text{JS}(t \vert\vert 1-t) + \log^2(z) - \log(z)\log(1-z),&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\text{JS}$&lt;/span&gt; is the Jensen-Shannon entropy (simmetrized KL divergence).&lt;/p&gt;&#xA;&lt;p&gt;Note the right-hand side is a sum of convex functions, as &lt;span class=&quot;math-container&quot;&gt;$\log^2(z)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$-\log(z)\log(1-z)$&lt;/span&gt; are convex in &lt;span class=&quot;math-container&quot;&gt;$(0,1)$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Therefore, I think I would be able to write the original program by optimizing &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; and adding a (quasilinear) constraint to account for the change of variable. Question 2 finally reduces to finding a DCP compliant representation of &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Progress on trying to find a DCP representation of &lt;span class=&quot;math-container&quot;&gt;$\log^2(t)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$-\log(t)\log(1-t)$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;I found some interesting things:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;a. &lt;span class=&quot;math-container&quot;&gt;$\log^2(t)$&lt;/span&gt;:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;We can write this as:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\min_{z} z \qquad\text{s.t.: } w\geq -\log(t),\,w\geq 0,\,z\geq w^2,&#xA;\end{equation}&lt;/span&gt;&#xA;for fixed &lt;span class=&quot;math-container&quot;&gt;$t \in (0,1)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;b. &lt;span class=&quot;math-container&quot;&gt;$-\log(t)\log(1-t)$&lt;/span&gt;:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is the tricky one. I had given up already, when I found this &lt;a href=&quot;https://en.wikipedia.org/wiki/Polylogarithm#Dilogarithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;wikipedia page&lt;/a&gt; on the Dilogarithm function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\text{Li}_2(z) = -\int_{0}^{z}\frac{\log(1-t)}{t}dt = -\int_{0}^{1}\frac{\log(1-z t)}{t}dt,&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\text{Li}_2(z) + \text{Li}_2(1-z) = \frac{1}{6}\pi^2 - \log(z)\log(1-z)&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now we can approximate the integral with numerical integration (trapezoidal rule):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;-\int_{0}^{z}\frac{\log(1-t)}{t}dt \approx -\frac{1}{N_t}\sum_{k=1}^{N_t}\frac{1}{2}\left(\frac{\log(1-z t_k)}{t_k} + \frac{\log(1-z t_{k-1})}{t_{k-1}}\right),&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$t_k$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$k\in\{0,N_t\}$&lt;/span&gt; discretizes the interval &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now this approximation is a convex DCP expression.&lt;/p&gt;&#xA;&lt;p&gt;I guess the only thing missing now is to write the remaining constraint for the change of variable.&lt;/p&gt;&#xA;" OwnerUserId="12739" LastEditorUserId="12739" LastEditDate="2023-11-14T20:59:24.153" LastActivityDate="2023-11-14T20:59:24.153" Title="How to write this objective in CVXPY for quasiconvex programming?" Tags="|nonlinear-programming|convex-optimization|cvxpy|disciplined-quasiconvex-programming|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="11169" PostTypeId="2" ParentId="11119" CreationDate="2023-10-29T03:31:29.817" Score="2" Body="&lt;p&gt;Maybe the definition of KL divergence is enough?&lt;/p&gt;&#xA;&lt;p&gt;If we eliminate the constraint that &lt;span class=&quot;math-container&quot;&gt;$q + p &amp;lt; 1$&lt;/span&gt;, notice that nothing changes in your inequality if I exchange &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1-q$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\left(\frac{p}{q}\right)^p &amp;amp;\geq \left(\frac{1-q}{1-p}\right)^{(1-p)}\iff\\&#xA;\iff p\log\left(\frac{p}{q}\right) &amp;amp;\geq (1-p)\log\left(\frac{1-q}{1-p}\right)\\&#xA;\iff p\log\left(\frac{p}{q}\right) &amp;amp;\geq -(1-p)\log\left(\frac{1-p}{1-q}\right)\\&#xA;\iff p\log\left(\frac{p}{q}\right) &amp;amp;+(1-p)\log\left(\frac{1-p}{1-q}\right) \geq 0\\&#xA;\iff D_{\text{KL}}(P\|Q) &amp;amp;\geq 0,&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$P,Q$&lt;/span&gt; are the random variables over &lt;span class=&quot;math-container&quot;&gt;$\{0,1\}$&lt;/span&gt; with probabilities &lt;span class=&quot;math-container&quot;&gt;$p,q$&lt;/span&gt; of observing ones, respectively, and &lt;span class=&quot;math-container&quot;&gt;$D_{\text{KL}}(P\|Q)$&lt;/span&gt; is the KL Divergence between &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Since the KL divergence is always positive, the first line is always true, for any &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$q$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;\min\{p,q\}\leq\max\{p,q\},&amp;lt;1$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="12739" LastEditorUserId="12739" LastEditDate="2023-11-03T23:52:44.300" LastActivityDate="2023-11-03T23:52:44.300" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11170" PostTypeId="1" CreationDate="2023-10-29T05:11:36.280" Score="0" ViewCount="169" Body="&lt;p&gt;Now I am using Or-Tools via the Java interface to solve a LP.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ModelBuilder model = new ModelBuilder();&#xA;ModelSolver solver = new ModelSolver(&amp;quot;SCIP&amp;quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;During the presolve process, the JVM exits with an error message: *&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Process finished with exit code 132 (interrupted by signal 4: SIGILL)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;*, see the first picture.&lt;/p&gt;&#xA;&lt;p&gt;When I add the VM options -Xss8m, the LP is solved to optimality. However, the presolve process is still very long, see the second picture. When the problem instance changes, the VM options may become invalid. It should be changed to -Xss16m, or higher.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone has any suggestions to avoid the program break-out, when using this Or-Tools? Should I use a LP solver instead of the SCIP? What's more, the log output &amp;quot;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Deactivated symmetry handling methods, since SCIP was built without&#xA;symmetry detector (SYM=none).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&amp;quot;, can we improve the solving efficiency by addressing this issue?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6UMYz.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6UMYz.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0Wfzb.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0Wfzb.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12326" LastActivityDate="2023-10-29T07:33:46.140" Title="Or-Tools: Process finished with exit code 132 (interrupted by signal 4: SIGILL)" Tags="|or-tools|scip|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11171" PostTypeId="2" ParentId="11170" CreationDate="2023-10-29T07:33:46.140" Score="1" Body="&lt;p&gt;I guess the signal is sent when memory is exhausted.&#xA;Now your problem only uses continuous variables. You do not need a MIP solver.&#xA;You can use 'glop'.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-10-29T07:33:46.140" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11172" PostTypeId="1" CreationDate="2023-10-29T08:44:17.143" Score="0" ViewCount="58" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\triangle_3 \in \mathbb{R}^3$&lt;/span&gt; be the &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;-simplex. I am solving a series of multilinear programming problems that looks like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{Maximize}\sum_{0\leq i, j, k \leq 3} A_{i,j,k} x_i x_j x_k$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subject to &lt;span class=&quot;math-container&quot;&gt;$(x_1, x_2, x_3)\in \triangle_3$&lt;/span&gt;,  &lt;span class=&quot;math-container&quot;&gt;$x_i \in [a_i, b_i]$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_0=1$&lt;/span&gt;, and there is no quadratic terms or cubed terms (i.e the objective is linear when you fix the other variables).&lt;/p&gt;&#xA;&lt;p&gt;I am noticing that all the optimal solutions are vertices of &lt;span class=&quot;math-container&quot;&gt;$\cap_i [a_i, b_i] \cap \triangle_3$&lt;/span&gt;. This suggests the function is convex, but it seems unlikely since multilinear optimisation is usually not convex/concave. And even then, I don't see how to verify that: The Hessian would be a function of at least one of the variables, so it is not straightforward to verify that the Hessian is positive semidefinite.&lt;/p&gt;&#xA;&lt;p&gt;Any idea how I might be able to prove this property here? This would be extremely helpful and would speed up the optimisation process tremendously.&lt;/p&gt;&#xA;" OwnerUserId="9623" LastActivityDate="2023-10-29T08:44:17.143" Title="Multilinear programming over the simplex" Tags="|nonlinear-programming|constraint-programming|nonconvex-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11173" PostTypeId="1" CreationDate="2023-10-29T08:46:16.457" Score="0" ViewCount="177" Body="&lt;p&gt;I have a linear programming problem where I use Or-Tools interface in Java for modeling. When using SCIP, I sometimes encounter memory errors and the solving time is relatively long. Later, I changed the solverType to GLOP and the solving time was about 5s. However, when I changed it to CLP, an error is reported that it cannot find a feasible solution, with a log &amp;quot;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;status = UNKNOWN_STATUS&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;To determine the root cause of the issue, I constructed a small linear programming problem, and found that while GLOP provided the optimal solution quickly, CLP still failed to solve it. Can anyone know what might be causing this ?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ModelBuilder model = new ModelBuilder();&#xA;    double infinity = java.lang.Double.POSITIVE_INFINITY;&#xA;    Variable x = model.newNumVar(0.0, infinity, &amp;quot;x&amp;quot;);&#xA;    Variable y = model.newNumVar(0.0, infinity, &amp;quot;y&amp;quot;);&#xA;&#xA;    System.out.println(&amp;quot;Number of variables = &amp;quot; + model.numVariables());&#xA;    // x + 7 * y &amp;lt;= 17.5.&#xA;    model.addLessOrEqual(LinearExpr.newBuilder().add(x).addTerm(y, 7), 17.5).withName(&amp;quot;c0&amp;quot;);&#xA;&#xA;    // x &amp;lt;= 3.5.&#xA;    model.addLessOrEqual(x, 3.5).withName(&amp;quot;c1&amp;quot;);&#xA;&#xA;    System.out.println(&amp;quot;Number of constraints = &amp;quot; + model.numConstraints());&#xA;    // Maximize x + 10 * y.&#xA;    model.maximize(LinearExpr.newBuilder().add(x).addTerm(y, 10.0));&#xA;    // Solve with the LP solver.&#xA;    ModelSolver solver = new ModelSolver(&amp;quot;glop&amp;quot;);&#xA;    final SolveStatus status = solver.solve(model);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;GLOP&#xA;&lt;a href=&quot;https://i.stack.imgur.com/eQMF8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eQMF8.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;CLP&#xA;&lt;a href=&quot;https://i.stack.imgur.com/6ZvDJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6ZvDJ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12326" LastActivityDate="2024-03-27T15:00:40.077" Title="Or-Tools：glop or clp to solve a LP" Tags="|or-tools|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11174" PostTypeId="2" ParentId="11173" CreationDate="2023-10-29T13:28:29.230" Score="0" Body="&lt;p&gt;My bad. model_builder is a minimal module. Currently, it supports GLOP, CP-SAT, PDLP, and SCIP.&lt;/p&gt;&#xA;&lt;p&gt;If you print the status, it will be MPSolverResponseStatus::MPSOLVER_SOLVER_TYPE_UNAVAILABLE.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-10-29T13:28:29.230" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11175" PostTypeId="1" CreationDate="2023-10-29T16:09:18.863" Score="2" ViewCount="92" Body="&lt;p&gt;Suppose we have a binary variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and a negative continuous variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;. How can we linearize the product &lt;span class=&quot;math-container&quot;&gt;$u=xy$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="12745" LastEditorUserId="2556" LastEditDate="2023-10-29T16:32:02.140" LastActivityDate="2023-10-30T15:23:37.187" Title="How to linearize the product of a binary and a negative continuous variable?" Tags="|linearization|binary-variable|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11176" PostTypeId="1" CreationDate="2023-10-29T16:28:50.333" Score="4" ViewCount="265" Body="&lt;p&gt;I am working with a column generation algorithm and have noticed that convergence is much faster when my master is a set covering problem (&lt;span class=&quot;math-container&quot;&gt;$Ax\ge 1$&lt;/span&gt;) compared to when it is a set partitioning problem (&lt;span class=&quot;math-container&quot;&gt;$Ax= 1$&lt;/span&gt;). Since it is a minimization problem, both formulations are equivalent and yield the same solution, only the convergence rate differs.&lt;/p&gt;&#xA;&lt;p&gt;Is there a reason for that (the dual space is reduced ?), and is this a general observation (the fact that using a covering formulation is more efficient), or does it depend on the nature of the subproblem (or anything else)?&lt;/p&gt;&#xA;&lt;h4&gt;EDIT&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I agree that covering and partitioning problems are not equivalent in general. However in this context, if minimizing, both formulations do work so I do believe this is quite a general case.&lt;/li&gt;&#xA;&lt;li&gt;When I say that convergence is faster, I mean that less iterations are required to reach optimality. The time taken PER iteration is more or less the same.&lt;/li&gt;&#xA;&lt;li&gt;I understand using a set covering formulation reduces the dual space. But how exactly does this impact the quality of the columns?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="12746" LastEditorUserId="12746" LastEditDate="2023-10-30T08:43:06.943" LastActivityDate="2023-10-31T14:17:27.717" Title="Column generation: set partitioning vs set covering" Tags="|mixed-integer-programming|linear-programming|column-generation|dantzig-wolfe-decomposition|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11177" PostTypeId="2" ParentId="11175" CreationDate="2023-10-29T17:21:59.990" Score="1" Body="&lt;p&gt;replace the constraint with the followings where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a large number:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u \le(1-x)M +y$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u \ge(1-x)M +y$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u \le xM$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$u \ge -xM$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastEditorUserId="39" LastEditDate="2023-10-30T15:23:37.187" LastActivityDate="2023-10-30T15:23:37.187" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11179" PostTypeId="2" ParentId="11175" CreationDate="2023-10-30T07:19:44.873" Score="1" Body="&lt;p&gt;base on use the usual technique described &lt;a href=&quot;https://or.stackexchange.com/questions/39/how-to-linearize-the-product-of-a-binary-and-a-non-negative-continuous-variable?rq=1&quot;&gt;here&lt;/a&gt; and general formula is give &lt;a href=&quot;https://www.fico.com/en/resource-access/download/3217&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;(page 7, section 2.8) we get to this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{ll}&#xA;\ u = x.y \\&#xA;u\le 0\\&#xA;u\ge -Mx\\&#xA;u\ge y\\&#xA;u\le y+M(1-x)&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="12745" LastActivityDate="2023-10-30T07:19:44.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11180" PostTypeId="2" ParentId="11176" CreationDate="2023-10-30T08:33:22.810" Score="1" Body="&lt;p&gt;First of all, you need to note @BrianBorchers' comment: the set partitioning problem and the set covering problem are not equivalent in general when you are minimizing.&lt;/p&gt;&#xA;&lt;p&gt;If I assume that you can verify that your models are equivalent in your case, then one reason for faster convergence for the set covering model may be due to the fact that you have a much smaller dual space. By going from equality constraints to inequality constraints, you add sign restrictions to your dual variables.&lt;/p&gt;&#xA;&lt;p&gt;However, in practice, you need to specify what you mean by &amp;quot;faster convergence&amp;quot;. Is it faster in terms of &lt;em&gt;seconds&lt;/em&gt;, or faster in terms of &lt;em&gt;iterations&lt;/em&gt;. If it is faster in terms of time, then the effect may come from solving the LP relaxations of a covering problem faster than solving the LP relaxation of the set partitioning problem. If you converge faster in terms of iterations, you should look into what columns you are generating in the pricing problems.&lt;/p&gt;&#xA;" OwnerUserId="609" LastActivityDate="2023-10-30T08:33:22.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11181" PostTypeId="1" CreationDate="2023-10-30T17:03:11.670" Score="2" ViewCount="71" Body="&lt;p&gt;This is a special case of a &lt;span class=&quot;math-container&quot;&gt;$M/M/c$&lt;/span&gt; queuing system with &lt;span class=&quot;math-container&quot;&gt;$c=2$&lt;/span&gt;. Here, there is a single customer queue that feeds into two servers, one of which has a higher rate of service than the other. Call them Able and Baker respectively. If a customer arrives and both Able and Baker are free, he preferentially chooses Able, otherwise he chooses Baker. The customer enqueues if both the servers are busy. My question is are there closed form expressions for various performance metrics for this system? For example, mean sojourn time in system, probability of customer being busy etc.&lt;/p&gt;&#xA;" OwnerUserId="12759" LastEditorUserId="67" LastEditDate="2023-10-31T15:56:25.287" LastActivityDate="2024-03-20T08:40:17.107" Title="Queueing system with 2 heterogeneous servers with prioritizing customers" Tags="|queuing-theory|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11182" PostTypeId="1" CreationDate="2023-10-31T13:37:01.527" Score="1" ViewCount="41" Body="&lt;p&gt;Since the benders algorithm is finite, there a maximum number of cuts that could theoretically be added. The worst case is that I add cuts for all extreme points and all extreme rays that are part of the full benders reformulation.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering, is there a method to calculate this number of maximum cuts?&lt;/p&gt;&#xA;&lt;p&gt;The reason being: my implementation right now is painfully slow, and for a certain problem size I get a stack overflow after about 2500 iterations.&lt;/p&gt;&#xA;&lt;p&gt;that means obviously, 2500 have been added already. since my problem size is still rather small, I was wondering if that would even be possible or if there is a mistake in my code.&#xA;So i thought that if I knew the maximum number of cuts that could be in the worst case be added, I would know if adding 2500 cuts even makes sense.&lt;/p&gt;&#xA;" OwnerUserId="12130" LastActivityDate="2023-10-31T13:37:01.527" Title="Is there a way to calcuate the maximum number of cuts in a Benders decomposition?" Tags="|mixed-integer-programming|benders-decomposition|decomposition|runtime|cuts|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11183" PostTypeId="2" ParentId="11176" CreationDate="2023-10-31T14:10:52.283" Score="1" Body="&lt;p&gt;Relaxing the equality constraint to an inequality constraint (when the problem allows!) should generally speed up convergence, and I have seen this many times in practice.&lt;/p&gt;&#xA;&lt;p&gt;You can understand this as follows: column generation in the primal is equivalent to adding cuts in the dual. Bad duals (very suboptimal for the full problem) lead to dual cuts (primal columns) that cut off points in the dual space that we do not really care about in the first place.&lt;/p&gt;&#xA;&lt;p&gt;For your specific problem, you have information that the solver does not have: you actually do not require an equality constraint! This translates to: the dual multipliers are non-negative/non-positive instead of unbounded. Adding this information (relaxing the constraint in the primal) then leads to an easier problem in the dual, and faster convergence.&lt;/p&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2023-10-31T14:17:27.717" LastActivityDate="2023-10-31T14:17:27.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11184" PostTypeId="1" CreationDate="2023-11-01T01:45:03.657" Score="1" ViewCount="71" Body="&lt;p&gt;I have two variables in an LP problem, a and b, both bound in range &lt;span class=&quot;math-container&quot;&gt;$(0,1)$&lt;/span&gt; and constrained such that &lt;span class=&quot;math-container&quot;&gt;$a+b=1$&lt;/span&gt;. So if a=0.25 then b=0.75.&lt;/p&gt;&#xA;&lt;p&gt;I have added a variable t constrained such that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t \ge a-b$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t \ge b-a$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t \ge 0.6$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My goal was to ensure that &lt;span class=&quot;math-container&quot;&gt;$max(a, b) \ge 0.8$&lt;/span&gt;. It does in fact work! But I'm a littler confused as to why...&lt;/p&gt;&#xA;&lt;p&gt;What's stopping the solver from assigning &lt;span class=&quot;math-container&quot;&gt;$a=0.5, b=0.5, t=0.6$&lt;/span&gt;? All three constraints would be satisfied.&lt;/p&gt;&#xA;" OwnerUserId="10326" LastActivityDate="2023-11-01T02:25:30.770" Title="LP: Constraining the maximum of two variables" Tags="|optimization|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11185" PostTypeId="2" ParentId="11184" CreationDate="2023-11-01T02:25:30.770" Score="3" Body="&lt;p&gt;The feasible region determined by &lt;span class=&quot;math-container&quot;&gt;$\max(a,b)\ge 0.8$&lt;/span&gt; is not convex, even if you further restrict by imposing &lt;span class=&quot;math-container&quot;&gt;$a \ge 0, b \ge 0, a+b=1$&lt;/span&gt;.  So you cannot express the constraint linearly without introducing at least one binary variable.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-11-01T02:25:30.770" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11186" PostTypeId="1" AcceptedAnswerId="11189" CreationDate="2023-11-01T06:01:46.497" Score="3" ViewCount="142" Body="&lt;p&gt;There are &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; items to be allocated into &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; bins. The profit generated by placing the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th item into the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;-th bin is &lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt;, and the service level is &lt;span class=&quot;math-container&quot;&gt;$s_{ij}$&lt;/span&gt;. A allocation scheme is required to maximize the total profit while satisfying a certain service level &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To represent the mathematical model of this problem, a variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; is introduced to represent the bin number where the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th item is placed. However, it is not possible to obtain the corresponding profit and service level based on the index.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, another approach is used, where 0-1 variables &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; are introduced to represent whether the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th item is placed in the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;-th bin. The corresponding mathematical model can be expressed as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max \sum\limits_{ij}{c_{ij}x_{ij}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{j}{x_{ij}}=1 \;\;\;\; \forall i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{ij}{s_{ij}x_{ij}} \geq M$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;SCIP can be used to find the optimal solution for small-scale problems. Howerver, for this problem with a large scale of hundreds of millions of items, it need a long time. Therefore, I would like to know if there are any effective heuristic methods that can guarantee near-optimal solutions, or whether the problem can be transformed into an assignment or graph matching problem, and then solved using specific graph theory methods to find the optimal solution?&lt;/p&gt;&#xA;" OwnerUserId="12326" LastActivityDate="2023-11-07T09:34:32.653" Title="Effective methods for solving the assignment and packing problem" Tags="|assignment-problem|matching|packing|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="11189" PostTypeId="2" ParentId="11186" CreationDate="2023-11-01T20:21:14.717" Score="2" Body="&lt;p&gt;I don't think the following heuristic can be said to &amp;quot;guarantee near-optimal solutions&amp;quot;, but it is quite straightforward to code and can make efficient use of parallel threading/multiple cores.&lt;/p&gt;&#xA;&lt;p&gt;If we do a partial Lagrangean relaxation of the original problem, relaxing only the service level constraint, we end up maximizing &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i,j} (c_{i,j}+\lambda s_{i,j})x_{i,j} - \lambda M$$&lt;/span&gt; subject to the single assignment constraint and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; being binary, with &lt;span class=&quot;math-container&quot;&gt;$\lambda \ge 0$&lt;/span&gt; the Lagrangean multiplier value. The constant term is irrelevant.&lt;/p&gt;&#xA;&lt;p&gt;So the heuristic proceeds as follows. Pick a positive value for &lt;span class=&quot;math-container&quot;&gt;$\lambda.$&lt;/span&gt; For each item &lt;span class=&quot;math-container&quot;&gt;$i,$&lt;/span&gt; evaluate &lt;span class=&quot;math-container&quot;&gt;$c_{i,j} + \lambda s_{i,j}$&lt;/span&gt; for all bins &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; and assign &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to the bin &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; for which that expression is maximal, breaking ties in favor of higher service levels. Compute the service total &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j} s_{i,j}x_{i,j}$&lt;/span&gt; and see if it meets or exceeds &lt;span class=&quot;math-container&quot;&gt;$M.$&lt;/span&gt; If yes, try lowering &lt;span class=&quot;math-container&quot;&gt;$\lambda.$&lt;/span&gt; If no, try raising &lt;span class=&quot;math-container&quot;&gt;$\lambda.$&lt;/span&gt; Keep track of the &lt;em&gt;feasible&lt;/em&gt; solution with best objective value. Stop when you run out of time or enthusiasm. Since this is basically a line search on the one-dimensional parameter &lt;span class=&quot;math-container&quot;&gt;$\lambda,$&lt;/span&gt; you could use bisection search.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-11-01T20:21:14.717" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11190" PostTypeId="5" CreationDate="2023-11-02T00:18:56.433" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/High-performance_computing&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/High-performance_computing&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="727" LastEditorUserId="727" LastEditDate="2023-11-02T02:57:35.410" LastActivityDate="2023-11-02T02:57:35.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11191" PostTypeId="4" CreationDate="2023-11-02T00:18:56.433" Score="0" Body="Questions about or related to HPC." OwnerUserId="727" LastEditorUserId="727" LastEditDate="2023-11-02T02:57:43.190" LastActivityDate="2023-11-02T02:57:43.190" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11192" PostTypeId="1" AcceptedAnswerId="11193" CreationDate="2023-11-02T08:03:07.957" Score="2" ViewCount="269" Body="&lt;p&gt;I build a MILP model by Pyomo and use Gurobi 9.0.3 as solver.&#xA;When the model comes infeasible, I try to use &lt;code&gt;pyomo.contrib.iis.iis.write_iis &lt;/code&gt;&#xA;to compute infeasible constraints yet failed. The program says&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;gurobipy.GurobiError: Cannot compute IIS on a feasible model&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Could somebody give suggestions about fixing it? Thx for any help!&lt;/p&gt;&#xA;" OwnerUserId="12686" LastEditorUserId="500" LastEditDate="2023-11-02T12:36:18.683" LastActivityDate="2023-11-02T14:14:47.760" Title="Gurobipy MILP model comes infeasible yet can't compute IIS because &quot;the model is feasible&quot;" Tags="|optimization|python|gurobi|pyomo|irreducible-infeasible-subset|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11193" PostTypeId="2" ParentId="11192" CreationDate="2023-11-02T11:21:05.167" Score="6" Body="&lt;p&gt;This model is likely on the borderline between feasibility and infeasibility. The algorithm used to determine feasibility in the solver is different than the algorithm used in IIS, and may reach a different conclusion on feasibility.&lt;/p&gt;&#xA;&lt;p&gt;The most likely reason is poor numerics in the model. You should try to change the scaling (units) on the problem so that all non-zero coefficients (input data) are within a small number of orders of magnitude of one. The Gurobi solver output shows the coefficient ranges.&lt;/p&gt;&#xA;&lt;p&gt;In addition to improving scaling, if needed, you can also set &lt;code&gt;NumericFocus&lt;/code&gt; to a higher than default value (for instance, its maximum value of 3).  You can also adjust &lt;code&gt;FeasibilityTol&lt;/code&gt; and other parameters listed at &lt;a href=&quot;https://www.gurobi.com/documentation/current/refman/making_the_algorithm_less_.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.gurobi.com/documentation/current/refman/making_the_algorithm_less_.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Gurobi developer Tobias Achterberg wrote the following in a support forum post in reply to a similar question to yours:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://groups.google.com/g/gurobi/c/fCcIITgdZRs&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi asserts that the model is infeasible but when coputing the IIS it says &amp;quot;Cannot compute IIS on a feasible model&amp;quot;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Your coefficient statistics shows a very big range in the matrix&#xA;coefficients. Coefficients in the order of 1e-10 can lead to numerical&#xA;issues in the linear system solves, which are caused by the finite&#xA;precision floating point arithmetics of the CPU. This could cause the&#xA;simplex algorithm to declare the model infeasible, while the IIS&#xA;algorithm thinks that it is feasible.&lt;/p&gt;&#xA;&lt;p&gt;You should try to reformulate your model so that those tiny&#xA;coefficients in the constraint matrix are avoided. Maybe rescaling&#xA;your columns may already suffice.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-11-02T14:14:47.760" LastActivityDate="2023-11-02T14:14:47.760" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11194" PostTypeId="1" AcceptedAnswerId="11293" CreationDate="2023-11-03T21:36:36.657" Score="0" ViewCount="73" Body="&lt;p&gt;I have found two formulas for Expected Queue Length &lt;span class=&quot;math-container&quot;&gt;$L_q$&lt;/span&gt; for the M/M/s model regarding Queuing Theory, namely:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Found inside the &amp;quot;Introduction to the Operations Research&amp;quot; book made by Hillier Lieberman:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;L_q = \frac{P_0(\lambda/\mu)^{s}\rho}{s!(1-\rho)^2}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Found on a &lt;a href=&quot;https://people.revoledu.com/kardi/tutorial/Queuing/MMs-Queuing-System.html#MMsQueuingSystem&quot; rel=&quot;nofollow noreferrer&quot;&gt;people.revoledu.com website&lt;/a&gt; and on a &lt;a href=&quot;https://mathcracker.com/multiple-server-model-calculator&quot; rel=&quot;nofollow noreferrer&quot;&gt;mathcracker.com website&lt;/a&gt; (in similar form):&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;L_q = \frac{P_0(\rho)^{s+1}}{(s-1)!(s-\rho)^2}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Are both of the equations the same? How can one prove it?&lt;/p&gt;&#xA;&lt;p&gt;I don't have the slightest idea what to do with the &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; in the denominator.&lt;/p&gt;&#xA;" OwnerUserId="12722" LastEditorUserId="491" LastEditDate="2024-03-18T12:11:44.700" LastActivityDate="2024-03-18T12:11:44.700" Title="Confusion with Expected Queue Length (Lq) Formulas for M/M/s Model in Queuing theory" Tags="|queuing-theory|proofs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11195" PostTypeId="1" CreationDate="2023-11-04T08:28:08.870" Score="0" ViewCount="142" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lrtaE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lrtaE.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LHpUh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LHpUh.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6TrXF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6TrXF.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So this is the maximum flow problem and I have two questions here:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why do we write maximize X_jt and why not X_st, since we want to maximize the flow from the source node to the end node? And why do we write X_jt if we do&lt;/li&gt;&#xA;&lt;li&gt;For the constraints what does X_jl mean? Why l there?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="12648" LastEditorUserId="500" LastEditDate="2023-11-04T12:58:08.990" LastActivityDate="2023-11-04T12:58:08.990" Title="Maximum Flow Linear Programming" Tags="|linear-programming|maxflow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11196" PostTypeId="2" ParentId="11195" CreationDate="2023-11-04T09:40:48.377" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;In the graph, we didn't have the direct connection between source and sink. However, we can reach sink from source by pass intermediate nodes. Therefore, we maximum all of arc's flow. Or you can just maximize the out-going flow from the source. Because the flow conservation constraints would ensure the all flow from source would going to sink finally.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In this problem, we have flow conservation constraints, which means the flow between nodes would be the same (except source and sink). To formulate this, you can imagine each index as following i : in-coming nodes, j : current node, l : out-going nodes.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="12370" LastEditorUserId="12370" LastEditDate="2023-11-04T09:46:18.830" LastActivityDate="2023-11-04T09:46:18.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11197" PostTypeId="1" CreationDate="2023-11-06T17:04:44.610" Score="2" ViewCount="36" Body="&lt;p&gt;I am reaching out to this knowledgeable community for assistance with a complex optimization problem that I have been investigating. Here is the formulation of the problem I'm addressing:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\tag{1}&#xA; \left\{ \begin{array}{cll}&#xA;      {\displaystyle \max_{\xi, \mathbf{p}, \mathbf{y} } }&amp;amp;  \left\|\mathbf{A}^{\intercal}\mathbf{p}\right\|_{\infty} \\&#xA;       \mbox{s.t.} &amp;amp; \mathbf{q}^{\intercal}\mathbf{y}\leq \left( \mathbf{A}\xi+\mathbf{b} \right)^{\intercal} \mathbf{p}, &amp;amp; \\&#xA;       &amp;amp; \mathbf{W}\mathbf{y}=\mathbf{A}\xi+\mathbf{b}, &amp;amp;\\&#xA;       &amp;amp; \mathbf{W}^{\intercal}\mathbf{p}\leq \mathbf{q}, &amp;amp; \\&#xA;       &amp;amp; \xi\in\Xi,\mathbf{p}\in\mathbb{R}^{m},\mathbf{y}\in\mathbb{R}^{\ell}_{+}.&amp;amp;&#xA;   \end{array} \right.&#xA;$$&lt;/span&gt;&#xA;In this problem, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A} \in \mathbb{R}^{m\times d}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{b} \in \mathbb{R}^{m}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\mathbf{q} \in \mathbb{R}^{\ell}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{W} \in \mathbb{R}^{m\times \ell}$&lt;/span&gt;. In addition, we assume that &lt;span class=&quot;math-container&quot;&gt;$\Xi$&lt;/span&gt; is a hypercube &lt;span class=&quot;math-container&quot;&gt;$\Xi=\times_{i=1}^{d_{\xi}} [a_{i},b_{i}]$&lt;/span&gt;. This problem has unique characteristics that set it apart.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Assumption:&lt;/strong&gt; Considering the optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\tag{2}&#xA;Q(\xi)=\left\{\begin{array}{ll} {\displaystyle \min_{\mathbf{y}\geq 0}} &amp;amp; \mathbf{q}^{\intercal}\mathbf{y}  \\ \mbox{s.t.} &amp;amp; \mathbf{W} \mathbf{y}= \mathbf{A}\xi +\mathbf{b}. \end{array} \right.&#xA;$$&lt;/span&gt;&#xA;We assume that for all &lt;span class=&quot;math-container&quot;&gt;$\xi\in\Xi$&lt;/span&gt;, we have &lt;span class=&quot;math-container&quot;&gt;$Q(\xi)&amp;lt;\infty$&lt;/span&gt;. This condition ensures that strong duality holds for problem (2), and the solutions to the dual problem are at the vertices of the dual polyhedron &lt;span class=&quot;math-container&quot;&gt;$\{\mathbf{p}:\mathbf{W}^{\intercal}\mathbf{p} \leq \mathbf{q} \}$&lt;/span&gt;. This is crucial because the first constraint in problem (1) relates directly to the dual variables of problem (2).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The drawback:&lt;/strong&gt; The main challenge with the problem (1) stems from the product of variables &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{p}$&lt;/span&gt; in the first constraint. It is worth noting that the maximization of an infinity norm is not an issue, as it can be recast as the maximization over a set of linear functions. Specifically, problem (1) can be reformulated as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \tag{3}&#xA;\max_{\mathbf{e}\in\mathcal{C}}\left\{ \begin{array}{cll}&#xA;      {\displaystyle \max_{\xi, \mathbf{p}, \mathbf{y} } }&amp;amp;  \mathbf{e}^{\intercal}\mathbf{A}^{\intercal}\mathbf{p} \\&#xA;       \mbox{s.t.} &amp;amp; \mathbf{q}^{\intercal}\mathbf{y}\leq \left( \mathbf{A}\xi+\mathbf{b} \right)^{\intercal} \mathbf{p}, &amp;amp; \\&#xA;       &amp;amp; \mathbf{W}\mathbf{y}=\mathbf{A}\xi+\mathbf{b}, &amp;amp;\\&#xA;       &amp;amp; \mathbf{W}^{\intercal}\mathbf{p}\leq \mathbf{q}, &amp;amp; \\&#xA;       &amp;amp; \xi\in\Xi,\mathbf{p}\in\mathbb{R}^{m},\mathbf{y}\in\mathbb{R}^{\ell}_{+}.&amp;amp;&#xA;   \end{array} \right.&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathcal{C}:=\left\{\mathbf{e}_{1},\mathbf{e}_{2},\ldots,\mathbf{e}_{d},-\mathbf{e}_{1},-\mathbf{e}_{2},\ldots,-\mathbf{e}_{d} \right\}$&lt;/span&gt; where  &lt;span class=&quot;math-container&quot;&gt;$\mathbf{e}_{i}$&lt;/span&gt;  is a canonical vector in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^{d}$&lt;/span&gt;, i.e., the vector whose &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th component is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and all other components are zero.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;I seek your guidance on approaches to tackle the problem (1), be it through innovative reformulations or through algorithms and numerical methods that can pave the way to a solution.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here are some insights that might influence your suggestions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The nature of &lt;span class=&quot;math-container&quot;&gt;$\Xi$&lt;/span&gt; as a hypercube seems advantageous. Empirical evidence suggests that optimal values of &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; frequently reside on the hypercube's boundary. However, this is based on experimental findings and lacks theoretical validation.&lt;/li&gt;&#xA;&lt;li&gt;The observation above might imply that problem (1) could be restricted to the vertices of the hypercube, potentially reducing it to a series of &lt;span class=&quot;math-container&quot;&gt;$2^d$&lt;/span&gt; linear programs. Unfortunately, this is not universally applicable as I've encountered scenarios where the optimal &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; values are not at the vertices.&lt;/li&gt;&#xA;&lt;li&gt;I have attempted several reformulations:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;&lt;strong&gt;Reformulation 1:&lt;/strong&gt;&lt;/em&gt; The first reformulation of (1) is as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left\{ \begin{array}{cll}&#xA;  {\displaystyle \max_{\xi, \mathbf{p}, \mathbf{y} } }&amp;amp;  \left\|\mathbf{A}^{\intercal}\mathbf{p}\right\|_{\infty} \\&#xA;   \mbox{s.t.} &amp;amp; \mathbf{q}^{\intercal}\mathbf{y}\leq  \mathbf{p}^{\intercal}\mathbf{W}\mathbf{y}, &amp;amp; \\&#xA;   &amp;amp; \mathbf{W}\mathbf{y}=\mathbf{A}\xi+\mathbf{b}, &amp;amp;\\&#xA;   &amp;amp; \mathbf{W}^{\intercal}\mathbf{p}\leq \mathbf{q}, &amp;amp; \\&#xA;   &amp;amp; \xi\in\Xi,\mathbf{p}\in\mathbb{R}^{m},\mathbf{y}\in\mathbb{R}^{\ell}_{+}.&amp;amp;&#xA;   \end{array} \right.$$&lt;/span&gt;&#xA;This approach does not eliminate the variable multiplication issue.&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;&lt;strong&gt;Reformulation 2:&lt;/strong&gt;&lt;/em&gt; Another reformulation of (1) is as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left\{ \begin{array}{cl}&#xA;  {\displaystyle \max_{\xi\in\Xi, \mathbf{p} } }&amp;amp;  \left\|\mathbf{A}^{\intercal}\mathbf{p}\right\|_{\infty} \\&#xA;   \mbox{s.t.} &amp;amp; {\displaystyle\sup_{\tilde{\mathbf{p}}\: :\: \mathbf{W}^{\intercal}\tilde{\mathbf{p}}\leq \mathbf{q} }}\left( \mathbf{A}\xi +\mathbf{b} \right)^{\intercal} \tilde{\mathbf{p}}\leq \left( \mathbf{A}\xi +\mathbf{b} \right)^{\intercal} \mathbf{p}, \\&#xA;   &amp;amp; \mathbf{W}^{\intercal}\mathbf{p}\leq \mathbf{q}.&#xA;   \end{array} \right.&#xA;$$&lt;/span&gt;&#xA;This might hint at addressing the problem with semi-infinite programming techniques, such as the decomposition method outlined at [see this &lt;a href=&quot;https://neos-guide.org/guide/algorithms/discretization/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link]&lt;/a&gt;. Yet, this approach is problematic due to the persistent variable multiplication and the challenges in initializing the method. Specifically, the master program and the Oracle program will continue to have multiplication of variables. In addition, another inconvenience lies in starting the method, this is because this type of method begins in its first iteration with a master program that removes the semi-infinite constraint, that is a drawback because if the dual polyhedron is unbounded, then that master program gives infinity and the algorithm will not be able to start.&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;&lt;strong&gt;Reformulation 3:&lt;/strong&gt;&lt;/em&gt; The Assumption introduced earlier in this discourse proves pivotal at this juncture. It facilitates the recasting of problem (1) into the following form:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left\{ \begin{array}{cl}&#xA;  {\displaystyle \max_{\xi\in\Xi, \mathbf{p}\in\{\pi_{1},\ldots,\pi_{M}\} } }&amp;amp;  \left\|\mathbf{A}^{\intercal}\mathbf{p}\right\|_{\overline{q}} \\&#xA;   \mbox{s.t.} &amp;amp; \left( \mathbf{A}\xi +\mathbf{b} \right)^{\intercal} \pi_{i}\leq \left( \mathbf{A}\xi +\mathbf{b} \right)^{\intercal} \mathbf{p} \qquad \forall i\in[M]  &#xA;   \end{array} \right.$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\pi_{1},\pi_{2},\dots,\pi_{M}$&lt;/span&gt; represent the extreme points of the dual polyhedron &lt;span class=&quot;math-container&quot;&gt;$\{\mathbf{p}:\mathbf{W}^{\intercal}\mathbf{p} \leq \mathbf{q} \}$&lt;/span&gt;. The practicality of this reformulation, however, remains elusive to me. Ideally, I would prefer to devise a method that circumvents the necessity of computing the extreme points of the dual polyhedron.&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;&lt;strong&gt;Reformulation 4:&lt;/strong&gt;&lt;/em&gt; The last reformulation I obtained is the following:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max_{\mathbf{e}\in\mathcal{C}}\max_{\xi\in\Xi}\left\{\begin{array}{ll}&#xA;{\displaystyle \min_{\gamma,\varphi,\phi} } &amp;amp; \mathbf{q}^{\intercal}\gamma + (\mathbf{A}\xi+\mathbf{b})^{\intercal}\phi \\&#xA;\mathrm{s.t}&amp;amp; \mathbf{W}\gamma-(\mathbf{A}\xi+\mathbf{b})\varphi=\mathbf{A}\mathbf{e}\\&#xA;&amp;amp; \mathbf{q}\varphi+\mathbf{W}^{\intercal}\phi\geq \mathbf{0}\\&#xA;&amp;amp; \gamma\in\mathbb{R}^{\ell}_{+},\varphi\in\mathbb{R},\phi\in\mathbb{R}^{m}.    &#xA;\end{array}\right.&#xA;$$&lt;/span&gt;&#xA;It leverages a duality argument based on reformulation (3), though its practicality is uncertain.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11486" LastEditorUserId="491" LastEditDate="2023-11-06T18:08:37.763" LastActivityDate="2023-11-06T18:08:37.763" Title="Addressing Variable Multiplication in Constrained Infinity-Norm Maximization with Hypercube &amp; Polyhedron Constraints" Tags="|optimization|linear-programming|global-optimization|reformulation-linearization|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11198" PostTypeId="1" AcceptedAnswerId="11199" CreationDate="2023-11-06T18:26:03.013" Score="1" ViewCount="42" Body="&lt;p&gt;I would like to assign items to a box over a time horizon where each box has an associated deadline. I was wondering if my formulation and / or variable definition can be improved. In other words, what other alternative way can I use to formulate my problem?&lt;/p&gt;&#xA;&lt;p&gt;One important detail is that if not all required item arrive at the box, then I do not want to assign any item.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Variables:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X_{ijt}$&lt;/span&gt; = amount of items &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; assigned to box &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Y_{ijt}$&lt;/span&gt; = binary variable indicating if any item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to box &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Z_{ij}$&lt;/span&gt; = binary variable indicating if total demand of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is met for box &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L_{j}$&lt;/span&gt; = binary variable indicating if total demand is met for box &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Inputs:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$d_j$&lt;/span&gt; = given deadline for box j.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c_{ij}$&lt;/span&gt; = total demand of item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; for box &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My constraints are defined as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t Y_{ijt} \leq d_j$&lt;/span&gt;. This guarantees that each item arrive by the deadline per box.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$  X_{ijt} \leq c_{ij} Y_{ijt}$&lt;/span&gt;. This is a big M constraint deciding if any amount of item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to box &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{t \in T} X_{ijt} \geq c_{ij} Z_{ij}$&lt;/span&gt;. This is constraint ensuring that the total demand is covered if any amount of item &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is assigned to box &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{i \in I}  Z_{ij} \geq |J| L_{j}$&lt;/span&gt;. Here, we decide if a box gets all the required parts. Then, I maximize the sum of &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; to make sure the model aims for meeting all the demands for each box.&lt;/p&gt;&#xA;&lt;p&gt;Overall, the goal is to make sure that the partial coverage is not allowed. Can there any improvements to avoid big M constraints?&lt;/p&gt;&#xA;" OwnerUserId="4025" LastEditorUserId="4025" LastEditDate="2023-11-06T18:50:46.873" LastActivityDate="2023-11-06T18:50:46.873" Title="Formulation to avoid partial coverage for demand points" Tags="|mixed-integer-programming|combinatorial-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11199" PostTypeId="2" ParentId="11198" CreationDate="2023-11-06T18:36:49.733" Score="1" Body="&lt;p&gt;Rather than impose your first constraint explicitly, it is better to define a sparse set &lt;span class=&quot;math-container&quot;&gt;$(j,t)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$t \le d_j$&lt;/span&gt;, to be used for both &lt;span class=&quot;math-container&quot;&gt;$Y_{ijt}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_{ijt}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Your last constraint goes in the wrong direction, so maximizing &lt;span class=&quot;math-container&quot;&gt;$\sum_j L_j$&lt;/span&gt; will just yield &lt;span class=&quot;math-container&quot;&gt;$L_j=1$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-11-06T18:36:49.733" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11200" PostTypeId="2" ParentId="11186" CreationDate="2023-11-07T09:34:32.653" Score="-1" Body="&lt;p&gt;The assignment and packing problem (APP) is a combinatorial optimization problem that involves assigning a set of items to a set of bins, such that each item is assigned to exactly one bin and the total profit or service level is maximized. The problem has a wide range of applications in logistics, manufacturing, and other fields.&lt;/p&gt;&#xA;&lt;p&gt;There are a number of effective methods for solving the APP, including:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Branch-and-bound:&lt;/strong&gt; This is a general-purpose algorithm for solving combinatorial optimization problems. It works by recursively exploring the solution space, pruning branches that cannot lead to optimal solutions.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Hungarian method:&lt;/strong&gt; This is a specific algorithm for solving the assignment problem. It works by finding a minimum-cost matching between the items and the bins.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Genetic algorithms:&lt;/strong&gt; This is a population-based algorithm that mimics the process of natural selection to find optimal solutions to problems. It works by creating a population of solutions and then iteratively evolving the population by combining and mutating solutions.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Particle swarm optimization:&lt;/strong&gt; This is another population-based algorithm that mimics the behavior of a swarm of particles to find optimal solutions to problems. It works by creating a swarm of particles and then iteratively updating the position of each particle based on the positions of the other particles in the swarm.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The best method for solving the APP depends on a number of factors, including the size of the problem, the desired accuracy, and the available computational resources. For small problems, it is often possible to find optimal solutions using branch-and-bound or the Hungarian method. For larger problems, it may be necessary to use a heuristic method, such as a genetic algorithm or particle swarm optimization.&lt;/p&gt;&#xA;&lt;p&gt;Here are some additional details about the methods mentioned above:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Branch-and-bound:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Branch-and-bound works by recursively exploring the solution space, pruning branches that cannot lead to optimal solutions. At each node of the search tree, a lower bound on the cost of the optimal solution is calculated. If the lower bound is greater than the cost of the best solution found so far, then the branch is pruned. Otherwise, the branch is split into two new branches, corresponding to the two possible assignments of the next item.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Hungarian method:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The Hungarian method works by finding a minimum-cost matching between the items and the bins. A matching is a set of pairs of items and bins, such that each item is assigned to exactly one bin and each bin is assigned to exactly one item. The cost of a matching is the sum of the costs of assigning each item to its bin.&lt;/p&gt;&#xA;&lt;p&gt;The Hungarian method works by iteratively reducing the cost of the current matching. In each iteration, the algorithm identifies a set of unassigned items and bins, and then finds a minimum-cost assignment of the items and bins in the set. The algorithm terminates when no further improvement can be made to the matching.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Genetic algorithms:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Genetic algorithms are population-based algorithms that mimic the process of natural selection to find optimal solutions to problems. They work by creating a population of solutions and then iteratively evolving the population by combining and mutating solutions.&lt;/p&gt;&#xA;&lt;p&gt;In the context of the APP, a solution can be represented by a vector, where each element of the vector represents the bin to which an item is assigned. The genetic algorithm works by creating a population of such vectors. The algorithm then iteratively evolves the population by selecting two solutions from the population at random and creating a new solution by combining the two solutions. The new solution is then mutated by randomly changing the assignment of one or more items.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Particle swarm optimization:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Particle swarm optimization is another population-based algorithm that mimics the behavior of a swarm of particles to find optimal solutions to problems. It works by creating a swarm of particles and then iteratively updating the position of each particle based on the positions of the other particles in the swarm.&lt;/p&gt;&#xA;&lt;p&gt;In the context of the APP, a particle can be represented by a vector, where each element of the vector represents the bin to which an item is assigned. The particle swarm optimization algorithm works by creating a swarm of such vectors. The algorithm then iteratively updates the position of each particle by moving it towards the position of the best particle in the swarm. The algorithm also allows the particles to move randomly to explore the solution space.&lt;/p&gt;&#xA;" OwnerUserId="12793" LastActivityDate="2023-11-07T09:34:32.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11202" PostTypeId="1" CreationDate="2023-11-07T14:07:21.980" Score="1" ViewCount="54" Body="&lt;p&gt;I've been working through &lt;a href=&quot;https://link.springer.com/book/10.1007/978-3-030-85128-6&quot; rel=&quot;nofollow noreferrer&quot;&gt;this book&lt;/a&gt; on robust optimization of electric energy systems, and in particular chapter 4 on distributionally robust optimization. In following the derivation of section 4.2.1.3, I cannot understand the last step. Here is the derivation I'm following and my understanding of each step, up until the point at which I get lost.&lt;/p&gt;&#xA;&lt;p&gt;First, let &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; be a decision vector and &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; be a vector of random variables. A static distributionally robust stochastic optimization problem (DRSO) is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\underset{x\in X}{\text{min}} \hspace{0.2cm} \underset{\xi \in \mathbb{U}}{\text{max}} &#xA;\hspace{0.05cm}\mathbb{E}_{\mathbb{P}}[f(x, \xi)]&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\mathbb{U}$&lt;/span&gt; is a support set defined as all &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$(\xi - \xi_{0})\Lambda(\xi - \xi_{0}) \leq 1$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$\Lambda$&lt;/span&gt; positive semi-definite. This uncertainty set defines an ellipsoid centered at nominal values of &lt;span class=&quot;math-container&quot;&gt;$\xi_{0}$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$\mathbb{P}$&lt;/span&gt; is a probability distribution that lives in an ambiguity set &lt;span class=&quot;math-container&quot;&gt;$\mathbf{P}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The inner maximization is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\underset{\mu}{\text{max}} \int_{\mathbb{U}} f(x, \xi) d\mu(\xi) \\&#xA;\text{subject to} \\&#xA;\int_\mathbb{U}\xi d\mu(\xi) = \xi_{0} \\&#xA;\int_\mathbb{U}(\xi - \xi_{0})(\xi - \xi_{0}) d\mu(\xi) \preceq \gamma \Sigma_{0}\\&#xA;\int_\mathbb{U}d\mu(\xi)=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which requires the covariance to lie in the cone &lt;span class=&quot;math-container&quot;&gt;$\gamma \Sigma_{0}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\Sigma_{0}$&lt;/span&gt; is the covariance matrix. Also, &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; must integrate to 1 and the mean of &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; must equal the notional mean &lt;span class=&quot;math-container&quot;&gt;$\xi_{0}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then, if you form the Lagrangian and group terms, you get the following Langrangian dual problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$L(\mu, \lambda, \mathbf{\beta}, Q) = \lambda + \xi_{0}\beta + \gamma \Sigma_{0} \bullet Q + \int_\mathbb{U}(f(x, \xi) - \lambda - \xi \beta - (\xi - \xi_{0})Q(\xi - \xi_{0}))d\mu(\xi) \\&#xA;\\&#xA;= \underset{\lambda, \beta, Q \succeq 0}{\text{min}} \hspace{0.05cm} \underset{\mu}{\text{max}} \hspace{0.05cm}\lambda + \xi_{0}\beta + \gamma \Sigma_{0} \bullet Q + \int_\mathbb{U}(f(x, \xi) - \lambda - \xi \beta - (\xi - \xi_{0})Q(\xi - \xi_{0}))d\mu(\xi)&#xA;\\&#xA;=\underset{\lambda, \beta, Q \succeq0}{\text{min}} \lambda + \xi_{0} \beta +\gamma \Sigma_{0} \bullet Q \\\&#xA;\text{subject to} \\&#xA;f(x, \xi) - \lambda - \xi \beta - (\xi - \xi_{0})Q(\xi - \xi_{0}) \leq 0, \hspace{0.25cm} \forall \xi \in \mathbb{U}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\bullet$&lt;/span&gt; is the Frobenius norm of two matrices, ie the component-wise sum.&lt;/p&gt;&#xA;&lt;p&gt;The last step comes from the fact that the maximization over &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; may be unbounded since the constraint that &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; integrate to 1 has been relaxed in the Lagrangian, so requiring that the term in the integral be negative ensures the integral will converge and the maximization over &lt;span class=&quot;math-container&quot;&gt;$\mu$&lt;/span&gt; will remain finite.&lt;/p&gt;&#xA;&lt;p&gt;Now, let &lt;span class=&quot;math-container&quot;&gt;$f(x,\xi)$&lt;/span&gt; = &lt;span class=&quot;math-container&quot;&gt;$\underset{1 \leq k \leq K}{\text{max}} y_{k} \xi + l_{k}(x)$&lt;/span&gt;. Substituting in for &lt;span class=&quot;math-container&quot;&gt;$f(x, \xi)$&lt;/span&gt;, we get&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\underset{\lambda, \beta, Q \succeq0}{\text{min}} \lambda + \xi_{0} \beta +\gamma \Sigma_{0} \bullet Q \\\&#xA;\text{subject to} \\&#xA;\underset{1 \leq k \leq K}{\text{max}} y_{k} \xi + l_{k}(x) - \lambda - \xi \beta - (\xi - \xi_{0})Q(\xi - \xi_{0}) \leq 0, \hspace{0.25cm} \forall \xi \in \mathbb{U}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;IF the above is true for the maximum over &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, then it must be true for all &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\underset{\lambda, \beta, Q \succeq0}{\text{min}} \lambda + \xi_{0} \beta +\gamma \Sigma_{0} \bullet Q \\\&#xA;\text{subject to} \\&#xA;y_{k} \xi + l_{k}(x) - \lambda - \xi \beta - (\xi - \xi_{0})Q(\xi - \xi_{0}) \leq 0, \hspace{0.25cm} \forall \xi \in \mathbb{U}, \hspace{0.25cm} \forall k \in K$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now putting a terms with &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt; on one side,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\underset{\lambda, \beta, Q \succeq0}{\text{min}} \lambda + \xi_{0} \beta +\gamma \Sigma_{0} \bullet Q \\\&#xA;\text{subject to} \\&#xA;y_{k} \xi - \xi \beta - (\xi - \xi_{0})Q(\xi - \xi_{0}) \leq \lambda - l_{k}(x), \hspace{0.25cm} \forall \xi \in \mathbb{U}, \hspace{0.25cm} \forall k \in K$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, if we multiply the constraint by -1, we can eliminate the &lt;span class=&quot;math-container&quot;&gt;$\forall \xi \in \mathbb{U}$&lt;/span&gt; by minimizing over &lt;span class=&quot;math-container&quot;&gt;$\xi$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\underset{\lambda, \beta, Q \succeq0}{\text{min}} \lambda + \xi_{0} \beta +\gamma \Sigma_{0} \bullet Q \\\&#xA;\text{subject to} \\&#xA;\underset{\xi : (\xi - \xi_{0})\Lambda(\xi - \xi_{0}) \leq 1}{\text{min}}(\xi - \xi_{0})Q(\xi - \xi_{0}) + (\beta - y_{k}) \xi \geq l_{k}(x) -\lambda, \hspace{0.25cm} \forall k \in K$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Everything up to here I understand- it is the next step the authors derive (without explanation) that I don't follow. Somehow, the above problem can be converted into this form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/I0rfm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/I0rfm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, there is no information in the book regarding how this last step is completed.&lt;/p&gt;&#xA;" OwnerUserId="12792" LastEditorUserId="36" LastEditDate="2023-11-07T14:10:32.353" LastActivityDate="2023-11-07T14:10:32.353" Title="Distributionally Robust Stochastic Programming - Help with derivation" Tags="|convex-optimization|duality|stochastic-programming|robust-optimization|semidefinite-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11204" PostTypeId="1" CreationDate="2023-11-07T17:54:58.440" Score="0" ViewCount="117" Body="&lt;p&gt;I am running a model using pulp CBC and have few constraints in the model that may make the model infeasible if wrong input is given to the model.&lt;/p&gt;&#xA;&lt;p&gt;I can see while my model runs that in case of infeasible model, I can see an output in terminal that says &lt;code&gt;presolve detects 1 infeasibility&lt;/code&gt;. After this line my model starts solving and no surprise gives me an output that my solution is infeasible.&lt;/p&gt;&#xA;&lt;p&gt;My question is, how can I stop my program if presolve is saying my model is infeasible? Is there any way to detect that as I don't want to spend time solving a model which presolve says is infeasible.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Problem Background:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have a hard constraint in my model, which can make my model infeasible in some cases, I want my &lt;strong&gt;program&lt;/strong&gt; (and not OR model) to detect this infeasibility and make that constraint soft.&lt;/p&gt;&#xA;&lt;p&gt;One way to achieve this is let my complete program run and then detect &lt;code&gt;result_status&lt;/code&gt; but as model can take quite some time to run and I don't want to spend time considering I have to take another run with &lt;em&gt;Soft Constraint&lt;/em&gt;. I am thinking is there any way I can detect and stop my model if presolve say model is infeasible.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;LP File with some rows removed:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Welcome to the CBC MILP Solver &#xA;Version: 2.10.3 &#xA;Build Date: Dec 15 2019 &#xA;&#xA;command line - &amp;quot;PATH&amp;quot; max sec 3000 ratio 1e-05 timeMode elapsed branch printingOptions all solution &amp;quot;PATH&amp;quot;\f5c13890167e459ea27741f1c5d52d5c-pulp.sol (default strategy 1)&#xA;At line 2 NAME          MODEL&#xA;At line 3 ROWS&#xA;At line 95389 COLUMNS&#xA;At line 611896 RHS&#xA;At line 707281 BOUNDS&#xA;At line 707282 ENDATA&#xA;Problem MODEL has 95384 rows, 175589 columns and 341444 elements&#xA;Coin0008I MODEL read with 0 errors&#xA;seconds was changed from 1e+100 to 3000&#xA;ratioGap was changed from 0 to 1e-05&#xA;Option for timeMode changed from cpu to elapsed&#xA;Presolve determined that the problem was infeasible with tolerance of 1e-08&#xA;Analysis indicates model infeasible or unbounded&#xA;1 infeasibilities&#xA;Analysis indicates model infeasible or unbounded&#xA;Perturbing problem by 0.001% of 5262.5816 - largest nonzero change 0.0052725434 ( 9.7117787%) - largest zero change 0.0026361607&#xA;0  Obj -0 Primal inf 7.4173266e+08 (10627) Dual inf 1.383116e+10 (56881)&#xA;0  Obj -0 Primal inf 7.4173266e+08 (10627) Dual inf 6.2882648e+14 (66006)&#xA;&#xA;Primal infeasible - objective value -6.0887206e+12&#xA;PrimalInfeasible objective -6.088720618e+12 - 108021 iterations time 88.622&#xA;&#xA;Result - Linear relaxation infeasible&#xA;&#xA;Enumerated nodes:           0&#xA;Total iterations:           0&#xA;Time (CPU seconds):         89.03&#xA;Time (Wallclock Seconds):   89.03&#xA;&#xA;Option for printingOptions changed from normal to all&#xA;Total time (CPU seconds):       89.91   (Wallclock seconds):       89.91&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12795" LastEditorUserId="491" LastEditDate="2024-03-15T14:38:43.223" LastActivityDate="2024-03-15T14:38:43.223" Title="Detect presolve status in pulp model" Tags="|linear-programming|python|pulp|cbc|coin-or|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11205" PostTypeId="1" CreationDate="2023-11-07T19:16:37.127" Score="0" ViewCount="105" Body="&lt;p&gt;I initially posted this on stackoverflow and got redirected here. You can view the old post  with formatted tables here: &lt;a href=&quot;https://stackoverflow.com/questions/77439941/pyomo-gurobi-scheduling-tasks-within-working-hours?noredirect=1#comment136523339_77439941&quot;&gt;StackOverflow Post&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have a python schedule optimization script using pyomo and the limited license version of gurobi. The script reads a csv list of Tasks and Artists. Each task has a task name, a duration in hours, dependencies, a link (an overarching group of tasks, in which the dependencies work within), pre-assigned artists (if any), and a buffer in hours before a dependent task can start after its completion. Each artist has an artist name and a list of task names they are capable of doing. The script returns assignments with start and end dates with a minimal makespan. Up to this point, the script works as intended.&lt;/p&gt;&#xA;&lt;p&gt;As an example of the input data, here is the example case list of tasks:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/J9i9a.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/J9i9a.png&quot; alt=&quot;Example Task List&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And the example artist list:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DUbs7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DUbs7.png&quot; alt=&quot;Example Artist List&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Although, in order to make it fully useful, I need the tasks to be only assigned from 09:00 to 17:00 every day. Tasks can and will span over multiple days. If the assignment overlaps multiple calendar days, the task should 'pause' from 17:00 to the next day at 09:00. This is where I'm struggling- I've made several attempts, but I can only go as far as restricting the schedule from 09:00-17:00 if the task duration stays below 8 hours (able to be assigned in a single day). My goal is to work off of this and eventually also add the functionality of assigning 'unavailable hours' for individual artists to accommodate booked vacation time, days/half-days off.&lt;/p&gt;&#xA;&lt;p&gt;I'd dearly appreciate any guidance on how to tackle this obstacle- even if it means restructuring from square one!&lt;/p&gt;&#xA;&lt;p&gt;Below is my entire script in it's current working state, without any consideration for working hours:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pandas as pd&#xA;from pyomo.environ import *&#xA;from pyomo.util.infeasible import log_infeasible_constraints&#xA;from datetime import datetime, timedelta&#xA;&#xA;# Load data from Excel&#xA;tasks_df = pd.read_excel('ProjectData.xlsx', sheet_name='Tasks')&#xA;artists_df = pd.read_excel('ProjectData.xlsx', sheet_name='Artists')&#xA;&#xA;# Preprocess data&#xA;tasks = {}&#xA;assigned_tasks = {}&#xA;for _, row in tasks_df.iterrows():&#xA;    unique_task_name = f&amp;quot;{row['Task Name']}-{row['Link']}&amp;quot;&#xA;    tasks[unique_task_name] = {'duration': row['Duration'],&#xA;                               'dependencies': [] if pd.isna(row['Dependencies']) else [f&amp;quot;{dep.strip()}-{row['Link']}&amp;quot; for dep in row['Dependencies'].split(',')],&#xA;                               'buffer': row['Buffer']}&#xA;&#xA;    if pd.notna(row['Assigned To']):&#xA;        assigned_tasks[unique_task_name] = row['Assigned To']&#xA;&#xA;print(tasks)&#xA;&#xA;# Ensuring task dependencies stay within their respective shot.&#xA;# Quick sanity check to ensure dependencies are correctly assigned.&#xA;for task, data in tasks.items():&#xA;    shot_id = task.split('-')[-1]&#xA;    for dep in data['dependencies']:&#xA;        dep_shot_id = dep.split('-')[-1]&#xA;        if shot_id != dep_shot_id:&#xA;            raise ValueError(f&amp;quot;Task {task} has a dependency {dep} from a different shot!&amp;quot;)&#xA;&#xA;&#xA;for _, row in tasks_df.iterrows():&#xA;    unique_task_name = f&amp;quot;{row['Task Name']}-{row['Link']}&amp;quot;&#xA;    tasks[unique_task_name] = {'duration': row['Duration'],&#xA;                               'dependencies': [] if pd.isna(row['Dependencies']) else [f&amp;quot;{dep.strip()}-{row['Link']}&amp;quot; for dep in row['Dependencies'].split(',')],&#xA;                               'buffer': row['Buffer']}&#xA;    &#xA;    # Check for Dependency Existence:&#xA;    for dep in tasks[unique_task_name]['dependencies']:&#xA;        if dep not in tasks:&#xA;            raise KeyError(f&amp;quot;Dependency '{dep}' for task '{unique_task_name}' not found in tasks.&amp;quot;)&#xA;&#xA;&#xA;&#xA;artists = {row['Name']: {'tasks': row['tasks'].split(',')} for _, row in artists_df.iterrows()}&#xA;&#xA;# Create a model&#xA;model = ConcreteModel()&#xA;model.TASKS = Set(initialize=tasks.keys())&#xA;model.ARTISTS = Set(initialize=artists.keys())&#xA;&#xA;# Variables&#xA;model.start_time = Var(model.TASKS, within=NonNegativeReals)&#xA;model.z = Var(model.TASKS, model.ARTISTS, within=Binary)&#xA;model.makespan = Var(within=NonNegativeReals)&#xA;&#xA;# Objective: Minimize makespan&#xA;model.obj = Objective(expr=model.makespan, sense=1)&#xA;&#xA;&#xA;# Additional Variable to manage overlapping tasks for artists&#xA;model.end_time = Var(model.TASKS, within=NonNegativeReals)&#xA;&#xA;&#xA;# Constraints&#xA;&#xA;'''&#xA;This constraint enforces that a task is preassigned to an artist if it has been explicitly assigned in the input data.&#xA;It sets the binary variable model.z[task, artist] to 1 if the task is preassigned to the artist; otherwise, &#xA;it allows model.z[task, artist] to be greater than or equal to 0.&#xA;'''&#xA;def preassigned_task_rule(model, task, artist):&#xA;    return model.z[task, artist] == 1 if task in assigned_tasks and assigned_tasks[task] == artist else model.z[task, artist] &amp;gt;= 0&#xA;&#xA;model.preassigned_task_constr = Constraint(model.TASKS, model.ARTISTS, rule=preassigned_task_rule)&#xA;&#xA;&#xA;&#xA;# Constraint to enforce task dependencies&#xA;def dependency_rule(model):&#xA;    for task in model.TASKS:&#xA;        if not tasks[task]['dependencies']: &#xA;            continue  # Skip if the task has no dependencies&#xA;        &#xA;        for dep in tasks[task]['dependencies']:&#xA;            latest_dep_end_time = model.end_time[dep] + tasks[dep]['buffer']&#xA;            yield model.start_time[task] &amp;gt;= latest_dep_end_time&#xA;&#xA;model.dependency_constr = ConstraintList(rule=lambda model=model: dependency_rule(model))&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;'''&#xA;This constraint calculates the end time of each task based on its start time and duration.&#xA;It enforces that the end time is equal to the start time plus the task's duration.&#xA;'''&#xA;def end_time_rule(model, task):&#xA;    return model.end_time[task] == model.start_time[task] + tasks[task]['duration']&#xA;&#xA;model.end_time_constr = Constraint(model.TASKS, rule=end_time_rule)&#xA;&#xA;'''&#xA;This constraint ensures that the makespan (the maximum end time) of the project is greater than or equal to the end time of each task.&#xA;It helps in minimizing the overall project duration.&#xA;'''&#xA;def makespan_rule(model, task):&#xA;    return model.makespan &amp;gt;= model.end_time[task]&#xA;&#xA;model.makespan_constr = Constraint(model.TASKS, rule=makespan_rule)&#xA;&#xA;&#xA;M = max(task_data['duration'] for task_data in tasks.values()) * len(tasks)&#xA;&#xA;&#xA;# Defining a set of (task, prerequisite) pairs&#xA;model.PREREQUISITES = Set(within=model.TASKS*model.TASKS, initialize=[(task, prerequisite) for task in model.TASKS for prerequisite in tasks[task]['dependencies']])&#xA;&#xA;'''&#xA;This constraint specifies that for each task with dependencies, the task's start time should &#xA;be greater than or equal to the average end time of its dependencies.&#xA;This rule promotes task parallelization when dependencies are satisfied.&#xA;'''&#xA;def immediate_start_rule(model, task):&#xA;    prerequisites = tasks[task]['dependencies']&#xA;    if prerequisites:&#xA;        return model.start_time[task] &amp;gt;= sum(model.end_time[prerequisite] for prerequisite in prerequisites) / len(prerequisites)&#xA;    else:&#xA;        return Constraint.Skip  # Skip if there are no prerequisites&#xA;&#xA;model.immediate_start_constr = Constraint(model.TASKS, rule=immediate_start_rule)&#xA;&#xA;&#xA;'''&#xA;This constraint encourages parallel execution of tasks of the same type (e.g., tasks with the same name) by different artists.&#xA;It ensures that if multiple artists are capable of performing the same task type, &#xA;at most one artist is assigned to execute that task at the same time.&#xA;'''&#xA;&#xA;def parallel_execution_rule(model, artist, task_i, task_j):&#xA;    if task_i &amp;gt;= task_j:  # skip duplicate pairs&#xA;        return Constraint.Skip&#xA;    &#xA;    task_name_i = task_i.split('-')[0]&#xA;    task_name_j = task_j.split('-')[0]&#xA;    &#xA;    # Check if the tasks are of the same type and if the artist can perform the task&#xA;    if task_name_i == task_name_j and artist in artists and task_name_i in artists[artist]['tasks']:&#xA;        other_artists = [a for a in artists if a != artist and task_name_i in artists[a]['tasks']]&#xA;        if other_artists:  # If there are other artists available&#xA;            return sum(model.z[task_i, artist] + model.z[task_j, artist] for artist in other_artists) &amp;lt;= 1&#xA;        else:&#xA;            return Constraint.Skip  # If no other artists are available, skip the constraint&#xA;    else:&#xA;        return Constraint.Skip  # Skip if tasks are not of the same type or artist can't perform them&#xA;&#xA;model.parallel_execution_constr = Constraint(model.ARTISTS, model.TASKS, model.TASKS, rule=parallel_execution_rule)&#xA;&#xA;'''&#xA;This constraint enforces that each task is assigned to exactly one artist.&#xA;It ensures that a task is not left unassigned and that it is assigned to a valid artist capable of performing that task.&#xA;'''&#xA;def assignment_rule(model, task):&#xA;    task_name = task.split('-')[0]&#xA;    possible_artists = [artist for artist, details in artists.items() if task_name in details['tasks']]&#xA;    return sum(model.z[task, artist] for artist in possible_artists) == 1&#xA;&#xA;model.assignment_constr = Constraint(model.TASKS, rule=assignment_rule)&#xA;&#xA;model.artist_assigned = Var(model.ARTISTS, model.TASKS, within=Binary)&#xA;&#xA;&#xA;'''&#xA;This constraint links the model.artist_assigned variable with the model.z variable to ensure consistency in assignment.&#xA;'''&#xA;def link_artist_assigned_rule(model, artist, task):&#xA;    return model.artist_assigned[artist, task] == model.z[task, artist]&#xA;&#xA;model.link_artist_assigned = Constraint(model.ARTISTS, model.TASKS, rule=link_artist_assigned_rule)&#xA;&#xA;&#xA;# Big M constant&#xA;M = 10000  # A large number&#xA;&#xA;# Create a binary variable to indicate whether tasks with the same name should overlap&#xA;model.overlap_allowed = Var(model.TASKS, model.TASKS, within=Binary)&#xA;&#xA;&#xA;# Constraint to prevent overlapping assignments for the same artist without a delay&#xA;def overlapping_tasks_rule(model, a, t1, t2):&#xA;    if t1 &amp;lt; t2:&#xA;        # Check if tasks t1 and t2 have the same name and artist can perform them&#xA;        task_name_t1, link_t1 = t1.split('-')[0], t1.split('-')[1]&#xA;        task_name_t2, link_t2 = t2.split('-')[0], t2.split('-')[1]&#xA;&#xA;        if task_name_t1 == task_name_t2 and a in artists and task_name_t1 in artists[a]['tasks']:&#xA;            start_time_t1 = model.start_time[t1]&#xA;            end_time_t1 = start_time_t1 + tasks[t1]['duration']&#xA;            start_time_t2 = model.start_time[t2]&#xA;            end_time_t2 = start_time_t2 + tasks[t2]['duration']&#xA;&#xA;            # Ensure that task t2 starts as soon as or just after task t1 ends (no delay)&#xA;            return (start_time_t2 &amp;gt;= end_time_t1 - 0.01) if task_name_t1 == 'Compositing' else Constraint.Skip&#xA;&#xA;    return Constraint.Skip  # Skip if conditions are not met&#xA;&#xA;model.overlapping_tasks_constr = Constraint(model.ARTISTS, model.TASKS, model.TASKS, rule=overlapping_tasks_rule)&#xA;&#xA;&#xA;# Solve&#xA;solver = SolverFactory('gurobi')&#xA;results = solver.solve(model, tee=True)&#xA;&#xA;for task in model.TASKS:&#xA;    print(f&amp;quot;Task {task} has start time {model.start_time[task].value} and end time {model.end_time[task].value}&amp;quot;)&#xA;&#xA;&#xA;if (results.solver.status == SolverStatus.warning and&#xA;        results.solver.termination_condition == TerminationCondition.infeasible):&#xA;    print(&amp;quot;Model is infeasible.&amp;quot;)&#xA;    log_infeasible_constraints(model)&#xA;    &#xA;    # Debugging step: manually check some constraints or variable values&#xA;    for task in model.TASKS:&#xA;        print(f&amp;quot;Task {task} has start time {model.start_time[task].value} and end time {model.end_time[task].value}&amp;quot;)&#xA;        &#xA;else:&#xA;    # Process results...&#xA;    pass&#xA;&#xA;&#xA;# Extract and write results to Excel&#xA;output_data = []&#xA;for task in model.TASKS:&#xA;    start = model.start_time[task].value&#xA;    end = start + tasks[task]['duration']&#xA;    &#xA;    # Define assigned_artist with a default value&#xA;    assigned_artist = None  &#xA;    &#xA;    for artist in model.ARTISTS:&#xA;        if model.z[task, artist].value == 1:&#xA;            assigned_artist = artist&#xA;            break&#xA;    &#xA;    # Ensure that a valid assigned_artist is found&#xA;    if assigned_artist is None:&#xA;        raise ValueError(f&amp;quot;No artist was assigned to task {task}. Check your optimization model.&amp;quot;)&#xA;    &#xA;    output_data.append([task.split('-')[0], task.split('-')[1], tasks[task]['duration'], assigned_artist,&#xA;                        (datetime.now() + timedelta(hours=start)).strftime('%Y-%m-%d %H:%M'),&#xA;                        (datetime.now() + timedelta(hours=end)).strftime('%Y-%m-%d %H:%M')])&#xA;&#xA;&#xA;output_df = pd.DataFrame(output_data, columns=['Task Name', 'Link', 'Duration', 'Assigned Artist', 'Start Time', 'End Time'])&#xA;output_df.to_excel('OptimizedSchedule.xlsx', index=False)&#xA;&#xA;print(&amp;quot;Optimization completed and results written to 'OptimizedSchedule.xlsx'&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12796" LastActivityDate="2023-11-07T19:16:37.127" Title="Pyomo + Gurobi Scheduling Tasks within Working Hours" Tags="|optimization|gurobi|scheduling|pyomo|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11206" PostTypeId="1" CreationDate="2023-11-07T20:00:41.230" Score="0" ViewCount="266" Body="&lt;p&gt;I am trying to transform an expression given by&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \operatorname{trace} \left( {\bf{X} } \right) +  \left( \sum_{n=1}^N \mathcal{R}(x_n) \right) $$&lt;/span&gt; into convex from where &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}$&lt;/span&gt; is complex in nature, size (1,N).&lt;/p&gt;&#xA;" OwnerUserId="11366" LastEditorUserId="11366" LastEditDate="2023-12-04T19:18:40.227" LastActivityDate="2023-12-04T19:18:40.227" Title="Convex approximation of an expression" Tags="|optimization|convex-optimization|cvxpy|approximation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11208" PostTypeId="1" CreationDate="2023-11-07T23:24:44.753" Score="1" ViewCount="190" Body="&lt;p&gt;In Python, I would like to solve a collection of problems, that are all solvable via MOSEK's conic optimization solvers (ExpCone, SOCP, &lt;em&gt;etc.&lt;/em&gt;)&lt;/p&gt;&#xA;&lt;p&gt;I have tried CVXPY. I get very robust and reliable results, however, the problem formulation times are quite expensive. I am looking for an efficient alternative.&lt;/p&gt;&#xA;&lt;p&gt;To this end, given that I only use MOSEK, I thought maybe I don't need CVXPY (&lt;em&gt;i.e.&lt;/em&gt;, I won't switch between solvers, happy just with MOSEK).&lt;/p&gt;&#xA;&lt;p&gt;Hence, I found the MOSEK API for Python, but it looks less intuitive than CVXPY to formulate disciplined optimization problems. There is also MOSEK Fusion, which looks simpler, but I don't really understand what the difference is.&lt;/p&gt;&#xA;&lt;p&gt;Hence, I am wondering: given that I need to only use MOSEK, cannot afford large problem-formulation times, and also do not know the MOSEK API but am familiar with CVXPY, what would you recommend me? Which option is the most reasonable one for me?&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2023-11-07T23:32:13.783" LastActivityDate="2023-11-07T23:32:13.783" Title="MOSEK via fusion vs API vs CVXPY" Tags="|python|solver|convex-optimization|cvxpy|mosek|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="11209" PostTypeId="2" ParentId="11206" CreationDate="2023-11-07T23:36:58.457" Score="2" Body="&lt;p&gt;No approximation is needed if you wish to minimize the expression.  For maximization, see the material after &amp;quot;Edit&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Due to cyclic permutation invariance of trace,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{trace}(X) = \text{trace}(xx^H) = \text{trace}(x^Hx) = x^Hx$$&lt;/span&gt; the latter two of which will be accepted by CVX, CVXPY, CVXR, and similar convex optimization tools.&lt;/p&gt;&#xA;&lt;p&gt;Presuming you want to minimize the expression, the CVX code is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin&#xA;variable x(N) complex&#xA;minimize(x'*x + sum(real(x)))&#xA;% add constraints&#xA;cvx_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you wish to maximize the expression, that would be a non-convex problem. Per your comment, you do wish to maximize, so I am adding the contents of my first answer, which I had deleted.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:  OP wants to maximize, per comment. So here is what can be done in that case.&lt;/p&gt;&#xA;&lt;p&gt;A convex SDP relaxation can be used which will provide an upper bound on the optimal objective value of the original maximization problem.&lt;/p&gt;&#xA;&lt;p&gt;Specifically, &lt;span class=&quot;math-container&quot;&gt;$X = xx^H$&lt;/span&gt; is relaxed to &lt;span class=&quot;math-container&quot;&gt;$X \succeq xx^H$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here is CVX code for this.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin sdp&#xA;variable X(N,N) hermitian&#xA;variable x(N) complex&#xA;maximize(trace(X) + sum(real(x)))&#xA;[X x;x' 1] &amp;gt;= 0&#xA;% add other constraints&#xA;cvx_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If the solution &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; is rank one, the solution to the relaxed problem is optimal for the original problem. Otherwise, the optimal objective value of the relaxed problem only constitutes an upper bound for the optimal objective value of the original maximization problem.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-11-08T10:45:31.680" LastActivityDate="2023-11-08T10:45:31.680" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="11212" PostTypeId="1" AcceptedAnswerId="11214" CreationDate="2023-11-09T02:52:42.100" Score="1" ViewCount="149" Body="&lt;p&gt;I'm familiar with solving VRPs in Google's &lt;code&gt;ortools&lt;/code&gt;. Has anybody used Google's new Cloud Fleet Routing capability (separate from &lt;code&gt;ortools&lt;/code&gt;) to solve VRPs and if so, know what types of VRPs can be solved on it? I may soon have a client with a very particular type of VRP that &lt;code&gt;ortools&lt;/code&gt; doesn't look like it readily covers. As such I'm looking for commercial options.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastActivityDate="2023-11-09T14:36:53.427" Title="Google Cloud Fleet Routing... what types of VRPs does it cover?" Tags="|vehicle-routing|or-tools|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11213" PostTypeId="2" ParentId="10085" CreationDate="2023-11-09T05:56:06.610" Score="0" Body="&lt;p&gt;There is no need for DGP rules - the problem can be formulated directly as a mixed integer DCP, and you were pretty close to it. I know you said you figured it out, but I'm adding this for future visits to this question (since neither give a CVXPY implementation).&lt;/p&gt;&#xA;&lt;p&gt;Somewhat in line with your code, I'm setting this up initially as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min \sum_{j=1}^n \prod_{i=1}^m q_{ij}^{x_{ij}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t. &lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^n x_{ij} \leq W_i \quad \forall i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{ij} \in \mathbb{Z}_+$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$q_{ij} = 1-p_{ij}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The objective function becomes&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^n \prod_{i=1}^m e^{ln(q_{ij})x_{ij}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and then&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j=1}^n e^{\sum_{i=1}^m ln(q_{ij})x_{ij}}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is the variable, we have the sum of exponentials of a linear function of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; -- it's a mixed integer DCP.&lt;/p&gt;&#xA;&lt;p&gt;Here's a quick script for it in CVXPY:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import cvxpy as cp&#xA;import numpy as np&#xA;&#xA;# Define the problem data&#xA;n = 5 # number of targets&#xA;m = 3 # number of weapon types&#xA;np.random.seed(1)&#xA;q = np.random.rand(n,m)*.9 + .1 # Survival probability&#xA;W = np.random.randint(1,10,m) # Number of weapons of each type&#xA;&#xA;# Define the CVXPY problem.&#xA;x = cp.Variable((n,m), integer=True)&#xA;weighted_weapons = cp.multiply(x, np.log(q)) # (n,m)&#xA;survival_probs = cp.exp(cp.sum(weighted_weapons, axis=1)) # (n,)&#xA;objective = cp.Minimize(cp.sum(survival_probs))&#xA;cons = [cp.sum(x, axis=0) &amp;lt;= W, x &amp;gt;= 0]&#xA;&#xA;# Solve&#xA;prob = cp.Problem(objective, cons)&#xA;prob.solve(verbose=True)&#xA;prob.status # Optimal&#xA;prob.value # 0.0785&#xA;np.set_printoptions(precision=3, suppress=True)&#xA;x.value&#xA;# array([[0., 0., 2.],&#xA;#        [0., 3., 0.],&#xA;#        [3., 0., 0.],&#xA;#        [1., 4., 0.],&#xA;#        [4., 0., 0.]])&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5219" LastActivityDate="2023-11-09T05:56:06.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11214" PostTypeId="2" ParentId="11212" CreationDate="2023-11-09T14:15:26.280" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://cloud.google.com/blog/products/ai-machine-learning/google-cloud-optimization-ai-cloud-fleet-routing-api&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cloud.google.com/blog/products/ai-machine-learning/google-cloud-optimization-ai-cloud-fleet-routing-api&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://cloud.google.com/optimization/docs/reference/rpc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cloud.google.com/optimization/docs/reference/rpc&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;may help. Generally, CFR can solve in addition to VRP with time windows, CFR supports pickup-and-deliveries, pickup alternatives, drivers, breaks, multiple capacity types, incompatibilities, traffic-awareness, auto-grouping of visits, customizable delays, heterogeneous vehicles, and more&lt;/p&gt;&#xA;" OwnerUserId="12803" LastEditorUserId="12803" LastEditDate="2023-11-09T14:36:53.427" LastActivityDate="2023-11-09T14:36:53.427" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11215" PostTypeId="2" ParentId="11212" CreationDate="2023-11-09T14:26:33.993" Score="0" Body="&lt;p&gt;You can solve many kinds of VRPs, with more modelling power than with OR-Tools: VRP, CVRP (capacities), PDP (pickup and delivery), VRPTW (time windows), with breaks, refueling, soft constraints, and probably a zillion others.&lt;/p&gt;&#xA;" OwnerUserId="156" LastActivityDate="2023-11-09T14:26:33.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11216" PostTypeId="1" CreationDate="2023-11-09T21:28:37.867" Score="0" ViewCount="92" Body="&lt;p&gt;I have the optimization problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\underset{\mathbf{x} \in \Bbb C^N}{\max} \left| \frac{\mathbf{x}a-b}{\mathbf{x}c+b} \right|^2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; are some scalars. I want to solve this optimization problem using semidefinite programming (SDP) but don't know how to handle this fraction in the objective function.&lt;/p&gt;&#xA;" OwnerUserId="11366" LastEditorUserId="8" LastEditDate="2023-11-10T14:23:40.240" LastActivityDate="2023-11-10T14:23:40.240" Title="Convex approximation of an expression with fraction for CVX" Tags="|optimization|convex-optimization|nonconvex-programming|cvxpy|approximation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11217" PostTypeId="2" ParentId="11216" CreationDate="2023-11-10T02:18:44.937" Score="2" Body="&lt;p&gt;I assume the given problem is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \frac{\|ax-b\|^2}{\|cx+b\|^2}, x \in \mathbb{C}^N&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I may try the following relaxation. The given problem is equivalent to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;&amp;amp;\max &amp;amp;\|ax-by\|^2\\&#xA;&amp;amp;\textrm{subject to} &amp;amp;\|cx+by\|^2 = 1\\&#xA;&amp;amp;&amp;amp;x \in \mathbb{C}^N, y\in \mathbb{C}&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Any solution of this problem &lt;span class=&quot;math-container&quot;&gt;$(x^\star, y^\star)$&lt;/span&gt; could be translated to a optimal solution of the given problem: &lt;span class=&quot;math-container&quot;&gt;$x = x^\star / y^\star$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(If an optimal solution gives &lt;span class=&quot;math-container&quot;&gt;$y^\star = 0$&lt;/span&gt;, it means the optimal value of the original problem is bounded below &lt;span class=&quot;math-container&quot;&gt;$|a/c|$&lt;/span&gt;, and is not reachable if &lt;span class=&quot;math-container&quot;&gt;$b \neq 0$&lt;/span&gt;.)&lt;/p&gt;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;&amp;amp;\max &amp;amp;\|Au\|^2\\&#xA;&amp;amp;\textrm{subject to} &amp;amp;\|Cu\|^2 = 1\\&#xA;&amp;amp;&amp;amp;u \in \mathbb{C}^{N+1}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;where&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;A = \begin{bmatrix}aI_N &amp;amp;-b\mathbf{1}_N \end{bmatrix} \in \mathbb{R}^{N \times (N+1)}&#xA;$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;C = \begin{bmatrix}aI_N &amp;amp;b\mathbf{1}_N \end{bmatrix} \in \mathbb{R}^{N \times (N+1)}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The relation is &lt;span class=&quot;math-container&quot;&gt;$u^\star = [x^\star, y^\star]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then it is equivalent to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;&amp;amp;\max &amp;amp;\langle A^HA, U\rangle\\&#xA;&amp;amp;\textrm{subject to} &amp;amp;\langle C^HC, U\rangle = 1\\&#xA;&amp;amp;&amp;amp;U \in \mathbb{S}_{N+1}^+\\&#xA;&amp;amp;&amp;amp;\mathop{\mathrm{rank}}(U) = 1&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\langle X, Y\rangle = \mathop{\mathrm{tr}}(X^H Y)$&lt;/span&gt; is matrix inner product. The relation is &lt;span class=&quot;math-container&quot;&gt;$U^\star = (u^\star)(u^\star)^H$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Drop the rank constraint to get the following SDP relaxation&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;&amp;amp;\max &amp;amp;\langle A^HA, U\rangle\\&#xA;&amp;amp;\textrm{subject to} &amp;amp;\langle C^HC, U\rangle = 1\\&#xA;&amp;amp;&amp;amp;U \in \mathbb{S}_{N+1}^+&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You may use the eigenvector corresponding the largest eigenvalue of &lt;span class=&quot;math-container&quot;&gt;$U^\star$&lt;/span&gt; or use some random sampling technique to find an approximate solution &lt;span class=&quot;math-container&quot;&gt;$\tilde u$&lt;/span&gt;, which may be further polished with first-order method (like gradient descent) on the original non-convex problem.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastEditorUserId="4569" LastEditDate="2023-11-10T02:25:54.887" LastActivityDate="2023-11-10T02:25:54.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11218" PostTypeId="1" CreationDate="2023-11-10T14:57:39.683" Score="1" ViewCount="79" Body="&lt;p&gt;Developing an &lt;strong&gt;OR&lt;/strong&gt; open-source Git repository empowers developers by providing a platform for&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;collaboration&lt;/li&gt;&#xA;&lt;li&gt;fostering transparency&lt;/li&gt;&#xA;&lt;li&gt;engaging with a broader&#xA;community&lt;/li&gt;&#xA;&lt;li&gt;building a positive reputation,&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;and contributing to continuous improvement in both individual skills and the software being developed.&lt;/p&gt;&#xA;&lt;p&gt;Would you like to share your personal experience in this regard ?&#xA;What did you get out of it? financially or reputation ?&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2023-11-10T16:12:22.240" Title="What is the benefit of developing opensource git-respository for the developer?" Tags="|optimization|open-source|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11219" PostTypeId="2" ParentId="11218" CreationDate="2023-11-10T16:12:22.240" Score="1" Body="&lt;p&gt;Another obvious benefit is that users will try many configurations and ideas, find possible bugs, thus making the library more robust.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2023-11-10T16:12:22.240" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11220" PostTypeId="1" CreationDate="2023-11-11T08:07:51.207" Score="0" ViewCount="42" Body="&lt;p&gt;There is an interesting data insight question that I want to solve using mathematical programming. I aim to find the combination of features that has the highest impact on the target indicators.&lt;/p&gt;&#xA;&lt;p&gt;We have collected N samples, each sample having F features (F1, F2, F3, etc.) and two indicators, I1 and I2. For example, if each sample represents a sales data, the features can be seller ID, seller's shipping city, buyer's delivery city, purchase time, shipping method, etc. The target indicator set consists of the total number of orders and the number of orders with negative reviews.&lt;/p&gt;&#xA;&lt;p&gt;From these samples, we want to analyze and determine the minimal combination of features that results in the highest proportion of orders with negative reviews.  The combinations that offer a finer level of granularity is prefer, which may provide more insight .&lt;/p&gt;&#xA;&lt;p&gt;For instance, if the identified feature combination is (seller's shipping city, buyer's delivery city, shipping method), it might indicate that the service quality for that shipping method in those cities is poor.&lt;/p&gt;&#xA;&lt;p&gt;I am looking to solve this problem using mathematical programming or tree search, but I don't have a clear approach. Tree search would require exhaustive traversal, leading to a high level of complexity.&lt;/p&gt;&#xA;" OwnerUserId="12326" LastEditorUserId="12326" LastEditDate="2023-11-12T01:18:28.547" LastActivityDate="2023-11-12T01:18:28.547" Title="Formulation for data insight" Tags="|mixed-integer-programming|supply-chain|local-search|data|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11221" PostTypeId="1" AcceptedAnswerId="11224" CreationDate="2023-11-11T21:30:06.943" Score="2" ViewCount="173" Body="&lt;p&gt;I have a simple infeasible problem as below.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Maximize z = 4x1 + 3x2&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;2x1 - x2 &amp;gt;= 6&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;x1 + x2 &amp;lt;= 2&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;x1 and x2 &amp;gt;= 0&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;After solving I see that the termination status says 'ok' rather than saying 'infeasible'. May I know if something is wrong with the formulation in code?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Create a concrete model&#xA;model = ConcreteModel()&#xA;&#xA;# Define variables with initialization and domain&#xA;model.x1 = Var(domain=NonNegativeReals, initialize=0.0)&#xA;model.x2 = Var(domain=NonNegativeReals, initialize=0.0)&#xA;&#xA;# Define the objective function&#xA;model.obj = Objective(expr=4 * model.x1 + 3 * model.x2, sense=maximize)&#xA;&#xA;# Define the constraints&#xA;model.constraint1 = Constraint(expr=2 * model.x1 - model.x2 &amp;gt;= 6)&#xA;model.constraint2 = Constraint(expr=model.x1 + model.x2 &amp;lt;= 2)&#xA;&#xA;# Solve the model using the GLPK solver&#xA;solver = SolverFactory('glpk')&#xA;results = solver.solve(model)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7qCpP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7qCpP.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12813" LastEditorUserId="12813" LastEditDate="2023-11-11T22:35:49.620" LastActivityDate="2023-11-12T07:02:28.330" Title="GLPK solver with Pyomo, not recognizing infeasibility" Tags="|pyomo|glpk|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11222" PostTypeId="1" CreationDate="2023-11-12T04:21:28.050" Score="1" ViewCount="111" Body="&lt;p&gt;Looking for some advice on how to approach this combo scheduling + routing problem. I am a supply chain OR consultant, and was recently approached by a potential client. Without giving too much away, they do preventative maintenance for commercial buildings. Some of their customers, they visit 1x a year; some 2x/3x/4x a year (at even spacing between visits), some weekly. All customers are on a defined visit cadence. Visits usually take about an hour so they can do several a day. A technician may be assigned an entire metropolitan area by himself/herself.&lt;/p&gt;&#xA;&lt;p&gt;Thing is, their visit cadence makes no sense geographically, as the client readily admits (and why they came to me). They may have six customers in a single neighborhood. Three clients are on a January &amp;amp; July visit schedule; two others on a March &amp;amp; September; and one other on an April &amp;amp; November schedule. So the technician could likely get all of them done in one day, twice a year; but instead has to visit this neighborhood six times over the year instead of two. This is destroying their route density and the technicians are doing a lot of unnecessary windshield time.&lt;/p&gt;&#xA;&lt;p&gt;I've been asked to recommend a &amp;quot;calibration&amp;quot; of when each customer is serviced, to improve route density and cut down on total hours necessary by reducing windshield time. This has a few challenging components that are different than most VRPs:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;For customers with more than one servicing a year, there needs to be a time linkage between the multiple services. e.g., whenever the first service is, the second service needs to be six months later (for a 2x annual customer). This isn't easily accounted for in TW settings.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After calibration, a customer can be next serviced sooner than previously planned, but not later. e.g., if they started new schedules on January 1 2024, it's OK for a customer that's currently on the March &amp;amp; September service schedule to be bumped up to February &amp;amp; August; but not pushed back to April &amp;amp; October.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;#1 and #2, at least to me, makes this different than a VRPTW and thus can't just be fed into a VRP solver.&lt;/p&gt;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Work hours need to be approximately equal by month... I can't just do everything in four months out of the year and nothing the other eight.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Initially, I'm thinking of making an MILP where the integer decision variables are, for each service call, what month to do it in (decision variable value options {1,2,3...12}). The MILP output would then be put through a CVRP solver to quantify total impact of the calibration.&lt;/p&gt;&#xA;&lt;p&gt;MILP constraints will ensure the even-spaced timing of service calls for customers with multiple visits per year. Constraints can also make the monthly total work roughly equal. What I'm struggling with is how to incorporate the geographic factor, so that each month has (more so than now) tight clusters of demand. I don't know if it's even possible to calculate intra-node distance as part of the objective function and keep the model linear.&lt;/p&gt;&#xA;" OwnerUserId="3958" LastEditorUserId="491" LastEditDate="2023-11-13T13:16:44.513" LastActivityDate="2023-11-13T13:16:44.513" Title="Scheduling &amp; Routing Problem" Tags="|scheduling|vehicle-routing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11223" PostTypeId="1" CreationDate="2023-11-12T05:29:08.047" Score="-2" ViewCount="83" Body="&lt;p&gt;The set partitioning formulation of routing problems is pretty well-accepted as perhaps the best exact method to solve routing problems.  However, these methods are difficult to implement as many people know.  I'm wondering is there some Python code out there that can solve these exact methods?  Ideally it would be some code that could solve resource-constrained shortest path problems &lt;a href=&quot;https://medien.umbreitkatalog.de/pdfzentrale/978/038/725/Leseprobe_9780387254852_Sonstige_Informationen_01.PDF&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.  I would imagine that would be the most difficult part.&lt;/p&gt;&#xA;&lt;p&gt;I did find &lt;a href=&quot;https://vrpy.readthedocs.io/en/latest/mathematical_background.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;, however it doesn't seem to solve these routing problems exactly - it just uses some heuristic.&lt;/p&gt;&#xA;&lt;p&gt;Any links to existing code/repositories would be appreciated, or any other ideas.&lt;/p&gt;&#xA;" OwnerUserId="12208" LastActivityDate="2023-11-12T15:35:07.830" Title="Is there existing code for the set partitioning formulation of routing problems?" Tags="|python|vehicle-routing|column-generation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11224" PostTypeId="2" ParentId="11221" CreationDate="2023-11-12T07:02:28.330" Score="5" Body="&lt;p&gt;This is indeed a little weird! When I run your example, I get the output from GLPK:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;GLPK Simplex Optimizer 5.0&#xA;3 rows, 3 columns, 5 non-zeros&#xA;Preprocessing...&#xA;2 rows, 2 columns, 4 non-zeros&#xA;Scaling...&#xA; A: min|aij| =  1.000e+00  max|aij| =  2.000e+00  ratio =  2.000e+00&#xA;Problem data seem to be well scaled&#xA;Constructing initial basis...&#xA;Size of triangular part is 2&#xA;      0: obj =  -0.000000000e+00 inf =   6.000e+00 (1)&#xA;      1: obj =   8.000000000e+00 inf =   2.000e+00 (1)&#xA;LP HAS NO PRIMAL FEASIBLE SOLUTION&#xA;glp_simplex: unable to recover undefined or non-optimal solution&#xA;If you need actual output for non-optimal solution, use --nopresol&#xA;Time used:   0.0 secs&#xA;Memory used: 0.0 Mb (40412 bytes)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;From this it is very clear that GLPK is well aware that there is no primal feasible solution, hence it knows that it is an infeasible problem.&lt;/p&gt;&#xA;&lt;p&gt;However, &lt;code&gt;results.solver.status&lt;/code&gt; says &lt;code&gt;ok&lt;/code&gt; and &lt;code&gt;results.solver.termination_condition&lt;/code&gt; says &lt;code&gt;other&lt;/code&gt;. I have tried to solve the problem with cplex, gurobi, and cbc as well. They report the following&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;&lt;/th&gt;&#xA;&lt;th&gt;GLPK&lt;/th&gt;&#xA;&lt;th&gt;CBC&lt;/th&gt;&#xA;&lt;th&gt;CPLEX&lt;/th&gt;&#xA;&lt;th&gt;Gurobi&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;status&lt;/td&gt;&#xA;&lt;td&gt;ok&lt;/td&gt;&#xA;&lt;td&gt;warning&lt;/td&gt;&#xA;&lt;td&gt;ok&lt;/td&gt;&#xA;&lt;td&gt;warning&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;termination_condition&lt;/td&gt;&#xA;&lt;td&gt;other&lt;/td&gt;&#xA;&lt;td&gt;infeasible&lt;/td&gt;&#xA;&lt;td&gt;infeasible&lt;/td&gt;&#xA;&lt;td&gt;infeasibleOrUnbounded&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;From this, it seems that there is something going on with what GLPK is returning as the termination condition to Pyomo. The other solvers are capable of conveying the message that your model does not have an optimal solution.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2023-11-12T07:02:28.330" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11225" PostTypeId="2" ParentId="11223" CreationDate="2023-11-12T08:17:31.840" Score="1" Body="&lt;p&gt;Python is not an efficient language, and solving the resource constrained shortest path is the bottleneck of the branch-and-cut-and-price algorithms for routing problems. Therefore, you won't find a state-of-the-art implementation where the resource constrained shortest path is solved in Python.&lt;/p&gt;&#xA;&lt;p&gt;The state-of-the-art branch-and-cut-and-price for routing problems is &lt;a href=&quot;https://vrpsolver.math.u-bordeaux.fr/&quot; rel=&quot;nofollow noreferrer&quot;&gt;VRPSolver&lt;/a&gt;. The code is available and written in C++.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-11-12T08:17:31.840" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11226" PostTypeId="2" ParentId="11223" CreationDate="2023-11-12T15:35:07.830" Score="0" Body="&lt;p&gt;There is a Python interface for the VRPSolver that can be installed using the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;python -m pip install VRPSolverEasy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;All the information is given in the Github page: &lt;a href=&quot;https://github.com/inria-UFF/VRPSolverEasy&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/inria-UFF/VRPSolverEasy&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="39" LastActivityDate="2023-11-12T15:35:07.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11227" PostTypeId="2" ParentId="11222" CreationDate="2023-11-12T16:33:13.957" Score="2" Body="&lt;p&gt;One possibility might be to start by constructing feasible one-day schedules for techs (service just A, service A and B in some order, service A, B and C in that order, ...). The MILP model would then select combinations of technician, schedule and month subject to constraints on how many days per month a tech can work, satisfying customer demands, and not scheduling the same customer too often or too close in time. If the number of one-day schedules proved too large, you could try column generation (either branch-price-and-cut or a heuristic column generation approach).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-11-12T16:33:13.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11228" PostTypeId="2" ParentId="9389" CreationDate="2023-11-12T17:36:42.527" Score="1" Body="&lt;h3&gt;Primal Problem&lt;/h3&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\text{maximize} \quad &amp;amp; \sum_{i=1}^n c_i x_i  \\\&#xA;\text{subject to} \quad &amp;amp; \sum_{i=1}^n x_i = 0 \\&#xA;&amp;amp; x_i \ge -1 \quad \forall i=1,\ldots,n \\&#xA;&amp;amp; x_i \le 1 \quad \forall i=1,\ldots,n&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The matrix formulation of the constraints is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \left\{ \begin{array}{l} &#xA;{\mathbf 1^t} \cdot {\mathbf x} = 0 \\&#xA;{-I}  {\mathbf x} \leq {\mathbf 1} \\&#xA;{ I} {\mathbf x} \leq {\mathbf 1} \\&#xA;\end{array} \right.$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf 1$&lt;/span&gt; is the column vector &lt;span class=&quot;math-container&quot;&gt;$(1, 1, \ldots, 1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; is the identity matrix of size &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;strong&gt;dual formulation&lt;/strong&gt; of the primal problem can be obtained by writing the &lt;em&gt;Lagrangian function&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$\mathcal{L}$&lt;/span&gt; of the primal problem and connecting heuristically such a function to the &lt;em&gt;minimax theorem&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$$\min_\mathbf y \max_{\mathbf x} \mathcal{L}(\mathbf x,\mathbf y) =\mathcal{L}(\mathbf{x}^{\ast},\mathbf{y}^{\ast})=\max_{\mathbf x} \min_\mathbf y  \mathcal{L}(\mathbf x,\mathbf y)$$&lt;/span&gt; proven by John von Neumann.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;em&gt;Lagrangian function&lt;/em&gt; to be considered is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\mathcal{L}(\mathbf x, \mathbf y) = \langle\mathbf c, \mathbf x\rangle  - \lambda\langle  \mathbf{1}, \mathbf x\rangle &#xA;+ \langle\mathbf{a}, {\mathbf 1} -(- I\mathbf x)\rangle + \langle\mathbf{b}, {\mathbf 1}-I\mathbf x\rangle$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where the notation &lt;span class=&quot;math-container&quot;&gt;$\langle\cdot,\cdot\rangle$&lt;/span&gt; indicates the scalar product between two vectors and &lt;span class=&quot;math-container&quot;&gt;$ \lambda$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ \mathbf{a} = (\alpha_1, \alpha_2, \ldots, \alpha_n)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$ \mathbf{b} = (\beta_1, \beta_2, \ldots, \beta_n)$&lt;/span&gt;  are components of &lt;em&gt;Lagrange multiplier &lt;span class=&quot;math-container&quot;&gt;$\mathbf y$&lt;/span&gt;&lt;/em&gt; that is &lt;span class=&quot;math-container&quot;&gt;$\mathbf y = ( \lambda,\alpha_1, \alpha_2, \ldots, \alpha_n,\beta_1, \beta_2, \ldots, \beta_n)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Recall the identity &lt;span class=&quot;math-container&quot;&gt;$\langle \mathbf v, A\mathbf w\rangle = \langle A^\top\mathbf v, \mathbf w\rangle$&lt;/span&gt;. Taking advantage of the linearity of the dot product, and putting in the evidence variable &lt;span class=&quot;math-container&quot;&gt;$\mathbf x$&lt;/span&gt;, we get&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\mathcal{L}(\mathbf x,\mathbf y) &amp;amp;= \langle\mathbf c,\mathbf x \rangle + \langle-\lambda\mathbf 1,\mathbf x \rangle + \langle\mathbf a,\mathbf 1\rangle + \langle\mathbf a,\mathbf x\rangle + \langle\mathbf b,\mathbf 1\rangle - \langle\mathbf b,\mathbf x\rangle\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Maximizing &lt;span class=&quot;math-container&quot;&gt;$\mathcal{L}(\mathbf x, \mathbf y)$&lt;/span&gt; with respect to variables &lt;span class=&quot;math-container&quot;&gt;$\mathbf x$&lt;/span&gt; is equivalent considering the maximum of &lt;span class=&quot;math-container&quot;&gt;$\langle \mathbf c -\lambda \mathbf 1 + \mathbf a - \mathbf b,\mathbf x\rangle$&lt;/span&gt;. This maximum is finite and equal to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$ \mathbf c -\lambda \mathbf 1 + \mathbf a - \mathbf b \le 0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\mathbf x\ge 0 $&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ \mathbf c -\lambda \mathbf 1 + \mathbf a - \mathbf b \ge 0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\mathbf x\le 0$&lt;/span&gt;. In conclusion, we get&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\mathbf c -\lambda \mathbf 1 + \mathbf a - \mathbf b = 0$$&lt;/span&gt;&#xA;The dual problem associated with the Lagrangian is by definition&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \min_\mathbf y \max_{\mathbf x} \mathcal{L}(\mathbf x,\mathbf y).$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In order to obtain an explicit description of the dual problem we maximize&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \max\limits_{\mathbf x} \mathcal{L}(\mathbf x,\mathbf y)$&lt;/span&gt;&#xA;with respect to  &lt;span class=&quot;math-container&quot;&gt;$\mathbf x $&lt;/span&gt;. Fixing &lt;span class=&quot;math-container&quot;&gt;$\mathbf y $&lt;/span&gt;, we get&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{\mathbf x} \mathcal{L}(\mathbf x,\mathbf y)=\langle\mathbf a, \mathbf 1\rangle + \langle\mathbf b, \mathbf 1\rangle  + \max_{\mathbf x} [ \langle \mathbf c -\lambda \mathbf 1 + \mathbf a - \mathbf b,\mathbf x\rangle]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and therefore&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max_{\mathbf x \ge 0,\mathbf x \le 0} \mathcal{L}(\mathbf x,\mathbf y) = &#xA;\left\{\begin{align}&#xA;\begin{matrix} &#xA;\langle\mathbf a, \mathbf 1\rangle + \langle\mathbf b, \mathbf 1\rangle&amp;amp;\mbox{ if } \mathbf c -\lambda \mathbf 1 + \mathbf a - \mathbf b \ge 0 \mbox{ and } \mathbf c -\lambda \mathbf 1 + \mathbf a - \mathbf b \le 0 \\&#xA;\infty&amp;amp;\mbox{otherwise} &#xA;\end{matrix}\end{align}&#xA;\right.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The dual objective function is therefore expressed as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{\mathbf y \ge 0} \mathcal{L}(\mathbf x,\mathbf y) = \min [\langle\mathbf a, \mathbf 1\rangle + \langle\mathbf b, \mathbf 1\rangle].$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Dual Problem&lt;/h3&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;\text{minimize} \quad &amp;amp; \sum_{j=1}^n (a_j + b_j) \\\&#xA;\text{subject to} \quad &amp;amp; \lambda - \mathbf a + \mathbf b = \mathbf c\\&#xA;&amp;amp; \lambda \ge 0 \\&#xA;&amp;amp; a_j \ge 0 \quad \forall j=1,\ldots,n \\&#xA;&amp;amp; b_j \ge 0 \quad \forall j=1,\ldots,n \\&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4114" LastEditorUserId="4114" LastEditDate="2023-11-12T17:53:01.330" LastActivityDate="2023-11-12T17:53:01.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11229" PostTypeId="1" CreationDate="2023-11-12T21:49:05.660" Score="1" ViewCount="79" Body="&lt;p&gt;I have been learning pyomo with glpk for a week now and I would like to know if pyomo team has developed a way to access &amp;quot;allowable increase&amp;quot; and &amp;quot;allowable decrease&amp;quot; values of the objective function coefficients in my model? Perhaps also the reduced costs?&lt;/p&gt;&#xA;&lt;p&gt;Also would like to know if there is a way to access the entire sensitivity report in one shot?&lt;/p&gt;&#xA;" OwnerUserId="12813" LastEditorUserId="491" LastEditDate="2023-11-13T13:15:32.300" LastActivityDate="2023-11-13T13:15:32.300" Title="Pyomo sensitivity report access" Tags="|pyomo|sensitivity-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11230" PostTypeId="2" ParentId="9389" CreationDate="2023-11-13T05:56:59.523" Score="2" Body="&lt;p&gt;The problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rcl}&#xA;\min      &amp;amp; \sum_{j=1}^n c_j x_j &amp;amp; \\&#xA;\mbox{st} &amp;amp; \sum_{j=1}^n x_j &amp;amp; = &amp;amp; b, \\&#xA;          &amp;amp; l \leq x \leq u. &amp;amp; &amp;amp; \\&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;br /&gt;&#xA;can be solved with the primal simplex algorithm in &lt;span class=&quot;math-container&quot;&gt;$O(n\ln(n))$&lt;/span&gt; complexity i.e.&#xA;&lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; has to be sorted with say quicksort.&lt;/p&gt;&#xA;&lt;p&gt;I am pretty sure somewhere in the literature of linear programming someone must have proved that before me. It should be noted that the @robpratt approach has better complexity than what I suggest.&lt;/p&gt;&#xA;&lt;p&gt;PS. Proving the above could be a good exercise for students of the primal simplex algorithm.&lt;/p&gt;&#xA;&lt;p&gt;PPS. Edited to take into account the comment of @robpratt.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2023-11-13T06:25:29.937" LastActivityDate="2023-11-13T06:25:29.937" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11231" PostTypeId="2" ParentId="11229" CreationDate="2023-11-13T07:07:09.100" Score="1" Body="&lt;p&gt;Here is a simple example of how one can access the suffix needed for printing the dual information of the constraints and also the reduced cost of the variables:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model = ConcreteModel()&#xA;&#xA;# for access to dual solution for constraints&#xA;model.dual = Suffix(direction=Suffix.IMPORT)&#xA;model.rc = Suffix(direction=Suffix.IMPORT)&#xA;&#xA;# declare decision variables&#xA;model.x = Var(domain=NonNegativeReals)&#xA;model.y = Var(domain=NonNegativeReals)&#xA;&#xA;# declare objective&#xA;model.profit = Objective(&#xA;    expr = 40*model.x + 30*model.y,&#xA;    sense = maximize)&#xA;&#xA;# declare constraints&#xA;model.demand = Constraint(expr = model.x &amp;lt;= 40)&#xA;model.laborA = Constraint(expr = model.x + model.y &amp;lt;= 80)&#xA;model.laborB = Constraint(expr = 2*model.x + model.y &amp;lt;= 100)&#xA;&#xA;# solve&#xA;SolverFactory('cbc').solve(model)&#xA;&#xA;print()&#xA;model.x.pprint()&#xA;&#xA;print(&amp;quot;\nSolution&amp;quot;)&#xA;print(f&amp;quot;x = {model.x()}&amp;quot;)&#xA;print(f&amp;quot;y = {model.y()}&amp;quot;)&#xA;&#xA;print(&amp;quot;\nSensitivity Analysis for constraints&amp;quot;)&#xA;print(f&amp;quot;y_demand = {-model.dual[model.demand]}&amp;quot;)&#xA;print(f&amp;quot;y_laborA = {-model.dual[model.laborA]}&amp;quot;)&#xA;print(f&amp;quot;y_laborB = {-model.dual[model.laborB]}&amp;quot;)&#xA;&#xA;print()&#xA;str = &amp;quot;{0:7.2f} {1:7.2f} {2:7.2f} {3:7.2f}&amp;quot;&#xA;print(&amp;quot;Constraint value lslack uslack dual&amp;quot;)&#xA;for c in [model.demand, model.laborA, model.laborB]:&#xA;    print(c, str.format(c(), c.lslack(), c.uslack(), model.dual[c]))&#xA;&#xA;print(&amp;quot;\nSensitivity Analysis for variables&amp;quot;)&#xA;print(f&amp;quot;x = {model.rc[model.x]}&amp;quot;)&#xA;print(f&amp;quot;x = {model.rc[model.y]}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and the results would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x : Size=1, Index=None&#xA;    Key  : Lower : Value : Upper : Fixed : Stale : Domain&#xA;    None :     0 :  20.0 :  None : False : False : NonNegativeReals&#xA;&#xA;Solution&#xA;x = 20.0&#xA;y = 60.0&#xA;&#xA;Sensitivity Analysis for constraints&#xA;y_demand = 0.0&#xA;y_laborA = -20.0&#xA;y_laborB = -10.0&#xA;&#xA;Constraint value lslack uslack dual&#xA;demand   20.00     inf   20.00   -0.00&#xA;laborA   80.00     inf    0.00   20.00&#xA;laborB  100.00     inf    0.00   10.00&#xA;&#xA;Sensitivity Analysis for variables&#xA;x = 0.0&#xA;x = 0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-11-13T07:07:09.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11232" PostTypeId="2" ParentId="8928" CreationDate="2023-11-13T20:53:31.047" Score="0" Body="&lt;p&gt;If in primal problem the variable &lt;span class=&quot;math-container&quot;&gt;$\mathbf x$&lt;/span&gt; was a vector of dimension &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; and constraints were made of &lt;span class=&quot;math-container&quot;&gt;$m+p$&lt;/span&gt; equations, in dual problem we should have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; equations in &lt;span class=&quot;math-container&quot;&gt;$m+p$&lt;/span&gt; variables.&#xA;It is common practice to solve the dual problem especially when its resolution is easier and quicker than the primary problem: it is the case when &lt;span class=&quot;math-container&quot;&gt;$ m+p &amp;gt; n $&lt;/span&gt; and Rocuhe-Capelli theorem holds so that there are more than one single solution.&lt;/p&gt;&#xA;&lt;p&gt;At the optimum, the equality of the values of the objective functions in primal and dual problems holds, so that it is possible to evaluate the quality of an admissible point in the primal problem without having to solve the last one exactly.&lt;/p&gt;&#xA;&lt;p&gt;In order to assess the goodness of an admissible point under examination &lt;span class=&quot;math-container&quot;&gt;$\mathbf x'$&lt;/span&gt; we can simply compare the value &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf x')=\sum_{i=1}^n c_i x'_i $&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf x^*)$&lt;/span&gt;, where  &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf x^*)$&lt;/span&gt; is equal to the optimal value of the objective function of the dual: &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf x^*)=h(\mathbf y^*)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In a minimum cost problem if it turns out that &lt;span class=&quot;math-container&quot;&gt;$ 0 &amp;lt; f(\mathbf x') - f(\mathbf x^*) \leq \varepsilon $&lt;/span&gt;, then we could be content with approximating &lt;span class=&quot;math-container&quot;&gt;$\mathbf x^*$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\mathbf x'$&lt;/span&gt; confident in the fact that the additional cost to be incurred for choosing a sub-optimal solution &lt;span class=&quot;math-container&quot;&gt;$\mathbf x'$&lt;/span&gt; is certainly not greater than &lt;span class=&quot;math-container&quot;&gt;$\varepsilon$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4114" LastActivityDate="2023-11-13T20:53:31.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11233" PostTypeId="1" CreationDate="2023-11-13T22:21:12.877" Score="1" ViewCount="55" Body="&lt;p&gt;I want to compare different methods for Set Covering problem. So I have 2 questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;what are the best methods for solving this problem (precise and not precise methods)&lt;/li&gt;&#xA;&lt;li&gt;what are the most common benchmark datasets for this problem?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="12663" LastActivityDate="2023-11-14T18:07:03.180" Title="Set covering SOTA methods and benchmarks" Tags="|benchmark|set-covering|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11234" PostTypeId="1" CreationDate="2023-11-14T10:12:48.450" Score="1" ViewCount="94" Body="&lt;p&gt;I'm currently working on a research project to optimize the recovery of space debris. We have to recover 50 pieces of space debris with the minimum number of missions possible. The missions are sent in parallel, so there are no planning problems to worry about. Obviously, a piece of debris has to be in a mission, and several missions can't contain the same piece of debris.&lt;/p&gt;&#xA;&lt;p&gt;We have all the code needed to calculate the energy that a mission can produce, taking into account the positions of the debris at time T and its orbital drift. However, we must respect certain constraints for these missions, delta V_max and delta T_max, which are respectively the maximum speed a mission can travel in km/s and the number of days a mission can last.&lt;/p&gt;&#xA;&lt;p&gt;I've implemented algorithms such as ACO, Genetic, NSGA-2 and 3. I've also optimized the function that gives the minimum energy a mission can produce, thanks to the Branch-and-bound algorithm, which permutes the debris list more efficiently to find the permutation with the minimum energy.&lt;/p&gt;&#xA;&lt;p&gt;Since I'm looking for algorithms with constraints, I'd like to ask you if you know of any, or if you have any papers or articles on algorithms that have worked on this type of problem.&lt;/p&gt;&#xA;&lt;p&gt;P.S : Here is an example of my problem but without scheduling : &lt;a href=&quot;https://sophia.estec.esa.int/gtoc_portal/wp-content/uploads/2017/05/gtoc9_problem_stmt.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://sophia.estec.esa.int/gtoc_portal/wp-content/uploads/2017/05/gtoc9_problem_stmt.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12825" LastEditorUserId="491" LastEditDate="2023-11-16T17:11:02.903" LastActivityDate="2023-11-16T17:11:02.903" Title="Optimization algorithm for space debris" Tags="|optimization|reference-request|vehicle-routing|algorithms|genetic-algorithm|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11236" PostTypeId="2" ParentId="11233" CreationDate="2023-11-14T18:07:03.180" Score="2" Body="&lt;p&gt;The instances from the literature are available here:&#xA;&lt;a href=&quot;http://people.brunel.ac.uk/%7Emastjjb/jeb/orlib/scpinfo.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://people.brunel.ac.uk/~mastjjb/jeb/orlib/scpinfo.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that the set covering problem is a quite fundamental problem that can appear in various contexts leading to very different instances. The instances from the literature might not represent well this diversity.&lt;/p&gt;&#xA;&lt;p&gt;Many set covering problems are well solved by basic integer linear programming.&lt;/p&gt;&#xA;&lt;p&gt;Other approaches from the literature are&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Lagrangian heuristics: A. Caprara, M. Fischetti, and P. Toth, “A Heuristic Method for the Set Covering Problem,” &lt;a href=&quot;https://doi.org/10.1287/opre.47.5.730&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Local search heuristics: M. Yagiura, M. Kishida, and T. Ibaraki, “A 3-flip neighborhood local search for the set covering problem” &lt;a href=&quot;https://doi.org/10.1016/j.ejor.2004.10.018&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-11-14T18:07:03.180" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11237" PostTypeId="1" CreationDate="2023-11-15T05:22:45.260" Score="0" ViewCount="62" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PVJHx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PVJHx.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can someone explain to me why are we doing the &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=1$&lt;/span&gt; and and the constraint &lt;span class=&quot;math-container&quot;&gt;$U_j \geq u_i+1-n(1-x_{ij})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also do you have any books or sources in mind from where I could learn in more detail from scratch about these problems.&lt;/p&gt;&#xA;" OwnerUserId="12648" LastEditorUserId="500" LastEditDate="2023-11-15T13:20:23.657" LastActivityDate="2023-11-15T13:20:23.657" Title="Travelling Salesman problem and Vehicle routing problems" Tags="|mixed-integer-programming|vehicle-routing|traveling-salesman|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11238" PostTypeId="1" AcceptedAnswerId="11239" CreationDate="2023-11-15T08:12:38.170" Score="2" ViewCount="79" Body="&lt;p&gt;I am trying to solve an optimization problem in which there is a set of tasks, &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e_i$&lt;/span&gt; are the starting and ending time of task &lt;span class=&quot;math-container&quot;&gt;$i \in S$&lt;/span&gt;. Each task &lt;span class=&quot;math-container&quot;&gt;$i $&lt;/span&gt; must be done within its own time window &lt;span class=&quot;math-container&quot;&gt;$[a_i, b_i]$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;a_i \le s_i, \forall i \in S&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;e_i \le b_i, \forall i \in S&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would like to compute the time between all the pairs of tasks. That is, &lt;span class=&quot;math-container&quot;&gt;$s_j-e_i$&lt;/span&gt; (if &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is scheduled before &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;) or &lt;span class=&quot;math-container&quot;&gt;$s_i-e_j$&lt;/span&gt; (if &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is scheduled before &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;The objective is to minimize the times between all the pairs of tasks. How can I define it?&lt;/p&gt;&#xA;" OwnerUserId="12282" LastEditorUserId="39" LastEditDate="2023-11-15T17:50:05.453" LastActivityDate="2023-11-15T17:50:05.453" Title="Compute time between tasks" Tags="|mixed-integer-programming|modeling|constraint|scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11239" PostTypeId="2" ParentId="11238" CreationDate="2023-11-15T08:41:51.150" Score="1" Body="&lt;p&gt;What you could do is the following: Introduce variable &lt;span class=&quot;math-container&quot;&gt;$t_{ij}$&lt;/span&gt; that is the time between tasks &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. This variable is only defined for once per pair &lt;span class=&quot;math-container&quot;&gt;$ij$&lt;/span&gt;, therefore the &lt;span class=&quot;math-container&quot;&gt;$j &amp;gt;i$&lt;/span&gt;. Then, you can write:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\&#xA;&amp;amp; \min \sum_{i \in S}\sum_{j \in S, j&amp;gt;i} t_{ij}  \; \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and adding the following two constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp; s_j - e_i \leq t_{ij} &amp;amp; \forall i,j \in S, j&amp;gt;i \tag1 \\ &#xA;&amp;amp; s_i - e_j \leq t_{ij} &amp;amp; \forall i,j \in S, j&amp;gt;i \tag2 \\  &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2023-11-15T08:41:51.150" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11241" PostTypeId="1" CreationDate="2023-11-15T14:09:32.387" Score="5" ViewCount="86" Body="&lt;p&gt;I am working on reducing the solving time of the optimization problem I am working on. One of the ideas I am exploring is the usage of Lazy constraints. As solver, I am using Gurobi, so &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/360013197972&quot; rel=&quot;noreferrer&quot;&gt;both&lt;/a&gt; pre-enumerated and callback lazy constraints are possible.&lt;/p&gt;&#xA;&lt;p&gt;In all examples of lazy constraints I could find on Gurobi's website, and also in this StackExchange, the TSP is mentioned and the classic example is the sub-tour elimination constraints. However, for different kind of problems, how can I identify good &amp;quot;candidates&amp;quot; to be lazy constraints that can speed up the optimization? I guess the more a specific type of constraint appears is in the problem the better candidate it is. For instance, the sub-tour elimination constraints in the TSP are exponential, and that makes them very good candidates for being lazy constraints. Is there any other criterion to choose them?&lt;/p&gt;&#xA;&lt;p&gt;And once I've identified them, assuming that I can enumerate all these constraints (which I can do for the problem that I am solving): is it better to use the callback approach or the enumeration one to add the lazy constraints?&lt;/p&gt;&#xA;" OwnerUserId="10208" LastActivityDate="2023-11-15T16:07:56.773" Title="How to identify constraints that are good candidates for being lazy constraints?" Tags="|constraint|gurobi|solver|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11242" PostTypeId="1" CreationDate="2023-11-15T14:29:23.570" Score="1" ViewCount="136" Body="&lt;p&gt;I am trying to get the complexity of the SDP problem for my specific problem, but I’m facing some problems.&lt;/p&gt;&#xA;&lt;p&gt;I found in the literature that the complexity of the SDP problem for an interior point per iteration is O(m * n^3 + m^2 * n^2 + m^3), where m is the number of constraints with (n x n) semidefinite matrix. It also implies that this (n x n) semidefinite matrix is the problem variable by saying there are n^2 variables.&lt;/p&gt;&#xA;&lt;p&gt;This is where my problem starts because I can not determine n and m in my problem. When many constraints include equalities, inequalities, and semidefinite ones, how can I calculate n and m?&lt;/p&gt;&#xA;&lt;p&gt;My problem in CVX format is as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cvx_begin SDP&#xA;    variable b(n+2,1) nonnegative&#xA;    variable B(n+2,n+2) nonnegative&#xA;    variable u(2,1) nonnegative&#xA;    variable r(n,1) nonnegative&#xA;    variable v&#xA;    &#xA;    minimize ( trace(W*(A*B*A.' - 2*A*b*c.' + c*c.')) + rho_c*sum(r.^2) + rho_n*(b(n+1)^2+b(n+2)^2) )&#xA;    subject to&#xA;        [B,b;b.',1] == semidefinite(n+3);&#xA;        [eye(2),u;u.',v] == semidefinite(3);&#xA;        for i = 1:n&#xA;            B(i,i) == [ai(:,i).', -1] * [eye(2),u;u.',v] * [ai(:,i); -1];&#xA;            b(i) &amp;gt;= 0;&#xA;            r(i) &amp;gt;= 0;&#xA;            vi(i) + r(i) &amp;gt;= norm(u-ai(:,i));&#xA;        end&#xA;cvx_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12832" LastEditorUserId="500" LastEditDate="2023-11-17T17:56:10.167" LastActivityDate="2023-12-17T23:07:20.950" Title="interior point computational complexity for SDP" Tags="|computational-complexity|interior-point-method|semidefinite-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11243" PostTypeId="2" ParentId="11241" CreationDate="2023-11-15T16:07:56.773" Score="1" Body="&lt;p&gt;Good candidates for lazy constraints are constraints which are not active in the optimal solutions of the relaxations. Thus, removing them speeds up the relaxation.&lt;/p&gt;&#xA;&lt;p&gt;For lazy constraints to be useful, there needs to be a significant difference in the sizes of the problem with all constraints and the problem without the lazy constraints.&lt;/p&gt;&#xA;&lt;p&gt;If you can enumerate all the (lazy) constraints, adding them all seems better since the solver has more information. But I'm not sure that it makes a large difference in the end.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2023-11-15T16:07:56.773" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11245" PostTypeId="2" ParentId="11234" CreationDate="2023-11-16T16:29:16.010" Score="1" Body="&lt;p&gt;ACO, genetic algorithms and other metaheuristics can be adapted to constrained problems by adding to the objective function penalties for constraint violations and then treating the problem as unconstrained (other than perhaps variable domains, e.g. &lt;span class=&quot;math-container&quot;&gt;$0 \le x \le U$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x\in \lbrace 0, 1\rbrace$&lt;/span&gt;). Also, there are versions of GAs called &amp;quot;random key&amp;quot; GAs, in which you choose a chromosome encoding and a function that maps each chromosome to a feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;For instance, the chromosome might be a permutation of the pieces of debris and the decoder function might scan the list in order and take as many pieces as the first mission can feasibly handle (skipping any that would &amp;quot;break&amp;quot; the mission), then scan the reduced list to fill the second mission and so on. I don't guarantee that approach would yield a feasible solution since I don't know all your constraints; it's just intended to give you an idea of the decoding process.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-11-16T16:29:16.010" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11246" PostTypeId="1" CreationDate="2023-11-16T18:05:38.070" Score="0" ViewCount="73" Body="&lt;p&gt;today I came across a paper that uses a type of model notation I have never come across before. These are the objective function and constraints I don't quite understand. I am specifically interested in what the dots in front of the capital letters mean. For example, for &lt;span class=&quot;math-container&quot;&gt;$i.NC=1$&lt;/span&gt;, does this mean that it only applies to all &lt;span class=&quot;math-container&quot;&gt;$NC$&lt;/span&gt; of index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Likewise, how do I understand the sum signs with the &lt;span class=&quot;math-container&quot;&gt;$\wedge$&lt;/span&gt; symbol?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;I)~\min\sum_{j,b}^{}j.W\cdot l_{jb}&#xA;\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;II)~\sum_{i:i.B}^{}p_{jit}\le l_{jb}~~~\forall j,t,b&#xA;\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;III)~\sum_{i,t:i.NC=1\wedge i.B=b}^{}p_{jit}\le 3~~~\forall j,b&#xA;\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;VI)~\sum_{i,t:i.SUN=1\wedge i.B=b}^{}p_{jit}\le 1~~~\forall j,b\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;V)~\sum_{i,t:i.B=b}^{}i.SAS\cdot p_{jit}\le j.AS\cdot l_{jb}~~~\forall j,b\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;VI)~p_{jit}+\sum_{k:k.B=b\wedge k.NC\neq1}^{}p_{jk(t+1)}\le 1~~~\forall j,t,i:i.NC=1\end{align}&lt;/span&gt;&#xA;\end{align}&lt;/p&gt;&#xA;" OwnerUserId="11887" LastActivityDate="2023-11-17T23:03:00.833" Title="Problems understanding model notation in LPs" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11247" PostTypeId="2" ParentId="11246" CreationDate="2023-11-16T18:58:03.460" Score="1" Body="&lt;p&gt;The &lt;span class=&quot;math-container&quot;&gt;$\wedge$&lt;/span&gt; simply means &amp;quot;and&amp;quot;. So for example, constraint III is telling you to sum over all pair of &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$i.NC = 1$&lt;/span&gt; &lt;em&gt;and&lt;/em&gt; &lt;span class=&quot;math-container&quot;&gt;$i.B=b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As for what the authors mean by the &amp;quot;.&amp;quot; notation itself (such as &lt;span class=&quot;math-container&quot;&gt;$i.NC$&lt;/span&gt;), that is impossible to say for certain without context; it is not a standard notation as far as I know. But I would be willing to wager that each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; comes from set, and for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; there are a bunch of related parameters, including &lt;span class=&quot;math-container&quot;&gt;$NC$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;. For example, in a minimum cost flow problem, each edge &lt;span class=&quot;math-container&quot;&gt;$e$&lt;/span&gt; has the parameters &amp;quot;cost&amp;quot; and &amp;quot;capacity&amp;quot;. Normally, we think of these as vectors/functions and write them as &lt;span class=&quot;math-container&quot;&gt;$c_e$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u_e$&lt;/span&gt; (or &lt;span class=&quot;math-container&quot;&gt;$c(e)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$u(e)$&lt;/span&gt;. However, if you wanted to emphasize that these are properties of the edge (NB: this has no mathematical meaning but could improve pedagogy) you could choose to write them as &lt;span class=&quot;math-container&quot;&gt;$e.c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e.u$&lt;/span&gt; (or even &lt;span class=&quot;math-container&quot;&gt;$e.cost$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$e.capacity$&lt;/span&gt;). The reason I think this is what the authors mean is that this is the syntax that many popular programming languages use if you want to access a property of a specific object.&lt;/p&gt;&#xA;" OwnerUserId="5812" LastEditorUserId="49" LastEditDate="2023-11-17T23:03:00.833" LastActivityDate="2023-11-17T23:03:00.833" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11248" PostTypeId="1" AcceptedAnswerId="11249" CreationDate="2023-11-16T21:08:57.457" Score="0" ViewCount="158" Body="&lt;p&gt;I have a Pyomo model where I want to formulate constraints:&lt;/p&gt;&#xA;&lt;p&gt;[Model.portrait.w, Model.portrait.l] OR [Model.landscape.w, Model.landscape.l]&lt;/p&gt;&#xA;&lt;p&gt;I can use BigM constraints to achieve this, but I want to try using Pyomo Generalized Disjunctive Programming (GDP) as an alternative.&lt;/p&gt;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;import pyomo.gdp as gdp&#xA;&#xA;def DefineModel(Model):&#xA;    Model.Select = pyo.Var(Model.Candidate, domain = pyo.Binary)&#xA;    Model.Allocation = pyo.Var(Model.Item, Model.Candidate, within = pyo.Binary, initialize = 0)&#xA;&#xA;    Model.portrait = gdp.Disjunct(Model.Item, Model.Candidate)&#xA;    Model.landscape = gdp.Disjunct(Model.Item, Model.Candidate)&#xA;    &#xA;    def rule_LBWidth1(Model, i):&#xA;        return sum(Model.Allocation[i, c] * Model.CandidateWidth[c] for c in Model.Candidate) &amp;gt;= Model.Width[i]&#xA;    Model.portrait.w = pyo.Constraint(Model.Item, rule = rule_LBWidth1)&#xA;&#xA;    def rule_LBLength1(Model, i):&#xA;        return sum(Model.Allocation[i, c] * Model.CandidateLength[c] for c in Model.Candidate) &amp;gt;= Model.Length[i]&#xA;    Model.portrait.l = pyo.Constraint(Model.Item, rule = rule_LBLength1)&#xA;&#xA;    def rule_LBWidth2(Model, i):&#xA;        return sum(Model.Allocation[i, c] * Model.CandidateWidth[c] for c in Model.Candidate) &amp;gt;= Model.Length[i]&#xA;    Model.landscape.w = pyo.Constraint(Model.Item, rule = rule_LBWidth2)&#xA;&#xA;    def rule_LBLength2(Model, i):&#xA;        return sum(Model.Allocation[i, c] * Model.CandidateLength[c] for c in Model.Candidate) &amp;gt;= Model.Width[i]&#xA;    Model.landscape.l = pyo.Constraint(Model.Item, rule = rule_LBLength2)&#xA;&#xA;    Model.rotate = gdp.Disjunction(expr = [Model.portrait, Model.landscape])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Error message:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ERROR: Constructing component 'rotate' from data=None failed: ValueError: Unexpected term for Disjunction rotate. Expected a Disjunct object, relational expression, or iterable of relational expressions but got &amp;lt;class 'tuple'&amp;gt; in &amp;lt;class 'pyomo.gdp.disjunct.IndexedDisjunct'&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The code follows the structure of the examples at &lt;a href=&quot;https://pyomo.readthedocs.io/en/latest/modeling_extensions/gdp/modeling.html#disjunctions&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pyomo.readthedocs.io/en/latest/modeling_extensions/gdp/modeling.html#disjunctions&lt;/a&gt;, except that it uses indexed functions - which seems to be a problem.&#xA;I'd appreciate suggestions for how to fix the code.&lt;/p&gt;&#xA;&lt;p&gt;-- EDIT with solution --&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def DefineModel(Model):&#xA;    Model.Select = pyo.Var(Model.Candidate, domain = pyo.Binary)&#xA;    Model.Allocation = pyo.Var(Model.Item, Model.Candidate, within = pyo.Binary, initialize = 0)&#xA;&#xA;    def portrait_rule(d, i):   # Original width|length order, as specified in the data&#xA;        d.w = pyo.Constraint(expr=sum(Model.Allocation[i, c] * Model.CandidateWidth[c] for c in Model.Candidate) &amp;gt;= Model.Width[i])&#xA;        d.l = pyo.Constraint(expr=sum(Model.Allocation[i, c] * Model.CandidateLength[c] for c in Model.Candidate) &amp;gt;= Model.Length[i])&#xA;    Model.portrait = gdp.Disjunct(Model.Item, rule = portrait_rule)&#xA;    &#xA;    def landscape_rule(d, i):   # Rotated width|length order&#xA;        d.w = pyo.Constraint(expr=sum(Model.Allocation[i, c] * Model.CandidateWidth[c] for c in Model.Candidate) &amp;gt;= Model.Length[i])&#xA;        d.l = pyo.Constraint(expr=sum(Model.Allocation[i, c] * Model.CandidateLength[c] for c in Model.Candidate) &amp;gt;= Model.Width[i])&#xA;    Model.landscape = gdp.Disjunct(Model.Item, rule = landscape_rule)&#xA;    &#xA;    def rotate_rule(Model, i):   # Use either portrait or landscape orientation for each item&#xA;        return [Model.portrait[i], Model.landscape[i]]&#xA;    Model.rotate = gdp.Disjunction(Model.Item, rule=rotate_rule)&#xA;&#xA;# ... other constraints and objective function...&#xA;    &#xA;    pyo.TransformationFactory('gdp.bigm').apply_to(Model)   # Transform the disjunction rules into a form that the solver can work with&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5128" LastEditorUserId="5128" LastEditDate="2023-11-17T17:20:40.170" LastActivityDate="2023-11-17T17:20:40.170" Title="Pyomo disjunction" Tags="|pyomo|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11249" PostTypeId="2" ParentId="11248" CreationDate="2023-11-17T01:48:26.960" Score="1" Body="&lt;p&gt;The error is because you are passing &lt;code&gt;IndexedDisjunct&lt;/code&gt;s to the &lt;code&gt;Model.rotate&lt;/code&gt; disjunction.  The &amp;quot;disjunction expression&amp;quot; should be a list of (scalar) Disjuncts, relational expressions, or iterables of relational expressions.  You can fix by declaring an indexed disjunction:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;def rotate_rule(m, i):&#xA;    return [m.portrait[i], m.landscape[i]]&#xA;Model.rotate = Disjunction(Model.Item, rule=rotate_rule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;@Model.Disjunction(Model.Item)&#xA;def rotate(m, i):&#xA;    return [m.portrait[i], m.landscape[i]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;-- EDIT --&lt;/p&gt;&#xA;&lt;p&gt;You also have a structural issue: you are assigning constraints to the &lt;code&gt;IndexedDisjunct&lt;/code&gt; containers &lt;code&gt;portrait&lt;/code&gt; and &lt;code&gt;landscape&lt;/code&gt;.  Those constraints are not attached to any block (Model, Block, or Disjunct) and will not be picked up by the transformations or the problem writers.  You can see this by &amp;quot;pretty printing&amp;quot; the model with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Model.pprint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and you should see that &amp;quot;&lt;code&gt;l&lt;/code&gt;&amp;quot; and &amp;quot;&lt;code&gt;w&lt;/code&gt;&amp;quot; are not printed as part of the model.&lt;/p&gt;&#xA;&lt;p&gt;I am not 100% certain what you are trying to accomplish, but looking back, I believe you want a disjunction for each Item?  If that is the case, then you might want something closer to:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;Model.Allocation = pyo.Var(Model.Item, Model.Candidate, within = pyo.Binary, initialize = 0)&#xA;&#xA;def portrait_rule(d, i):&#xA;    m = d.model()&#xA;    d.w = pyo.Constraint(&#xA;        expr=sum(m.Allocation[i, c] * m.CandidateWidth[c] for c in m.Candidate) &amp;gt;= m.Width[i]&#xA;    )&#xA;    d.l = pyo.Constraint(&#xA;        expr=sum(m.Allocation[i, c] * m.CandidateLength[c] for c in m.Candidate) &amp;gt;= m.Length[i]&#xA;    )&#xA;&#xA;Model.portrait = gdp.Disjunct(Model.Items, rule=portrait_rule)&#xA;&#xA;def landscape_rule(d, i):&#xA;    m = d.model()&#xA;    d.w = pyo.Constraint(&#xA;        expr=sum(m.Allocation[i, c] * m.CandidateWidth[c] for c in m.Candidate) &amp;gt;= m.Length[i]&#xA;    )&#xA;    d.l = pyo.Constraint(&#xA;        expr=sum(m.Allocation[i, c] * m.CandidateLength[c] for c in m.Candidate) &amp;gt;= m.Width[i]&#xA;    )&#xA;&#xA;Model.landscape = gdp.Disjunct(Model.Items, rule=landscape_rule)&#xA;&#xA;def rotate_rule(m, i):&#xA;    return [m.portrait[i], m.landscape[i]]&#xA;Model.rotate = gdp.Disjunction(expr=rotate_rule)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10026" LastEditorUserId="10026" LastEditDate="2023-11-17T07:43:55.877" LastActivityDate="2023-11-17T07:43:55.877" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11250" PostTypeId="1" AcceptedAnswerId="11258" CreationDate="2023-11-17T02:46:06.697" Score="1" ViewCount="79" Body="&lt;p&gt;I have implemented a column generation algorithm in Gurobi in Python. The most computationally expensive aspect of this algorithm is the reconstruction of the master problem when a column is added (or sometimes removed). For example, a sample constraint set for my master problem is as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mdl_master.addConstrs((gp.quicksum((A[s][i] - B[s][i]) * chi[s] for s in s_set) &amp;gt;= E[i] for i in i_set), name='cst')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;E&lt;/code&gt; represent parameters of the master problem, &lt;code&gt;chi&lt;/code&gt; is a continuous decision variable, and &lt;code&gt;s&lt;/code&gt; is the index of columns.&lt;/p&gt;&#xA;&lt;p&gt;Given that new columns can be added to the master problem or some unused columns can be eliminated, how do you suggest I reduce the computational cost of building such constraints in an iterative algorithm like column generation? Would it be possible and beneficial to partially modify the LHS of such a constraint set instead of building it from scratch? If so, how?&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="5598" LastEditDate="2023-11-17T02:54:26.890" LastActivityDate="2023-11-18T13:09:28.267" Title="Partially modify LHS of a constraint set?" Tags="|python|gurobi|column-generation|runtime|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11251" PostTypeId="1" AcceptedAnswerId="11252" CreationDate="2023-11-17T03:00:22.810" Score="1" ViewCount="93" Body="&lt;p&gt;I have a question about Ex 1.11 of &amp;quot;Linear Optimization&amp;quot; by Bertsimas, Tsitsiklis:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Suppose that there are &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; available currencies, and assume that one unit of currency &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; can be exchanged for &lt;span class=&quot;math-container&quot;&gt;$r_{ij}$&lt;/span&gt; units of currency &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. (Naturally, we assume that &lt;span class=&quot;math-container&quot;&gt;$r_{ij} &amp;gt; 0$&lt;/span&gt;.) There also certain regulations that impose a limit &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; on the total amount of currency &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; that can be exchanged on any given day. Suppose that we start with &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; units of currency &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and that we would like to maximize the number of units of currency &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; that we end up with at the end of the day, through a sequence of currency transactions. Provide&#xA;a linear programming formulation of this problem. Assume that for any sequence&#xA;&lt;span class=&quot;math-container&quot;&gt;$i_1, \dots, i_k$&lt;/span&gt; of currencies, we have  &lt;span class=&quot;math-container&quot;&gt;$r_{i_1 i_2} r_{i_2 i_3}  \dots r_{i_{k-1} i_k} r_{i_k i_1} \leq 1$&lt;/span&gt;, which means that&#xA;wealth cannot be multiplied by going through a cycle of currencies.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I think I am probably misunderstanding the question, but we have B units of currency 1 at the start and at most &lt;span class=&quot;math-container&quot;&gt;$u_1$&lt;/span&gt; of currency 1 can be exchanged so I think the most of currency N we can get is &lt;span class=&quot;math-container&quot;&gt;$min(u_1, B)*r_{1N}$&lt;/span&gt;. This is because if B &amp;gt; &lt;span class=&quot;math-container&quot;&gt;$u_1$&lt;/span&gt; then at most &lt;span class=&quot;math-container&quot;&gt;$u_1$&lt;/span&gt; can be exchanged and there is no point in converting to any other intermediate currency and then currency N because this leads to at most the same amount of currency N as without converting to intermediate currencies, as otherwise we are profitting by arbitrage. And if B &amp;lt;= &lt;span class=&quot;math-container&quot;&gt;$u_1$&lt;/span&gt; then we convert all B units of currency 1 to N in a single transaction. Can anyone tell me if I am missing something?&lt;/p&gt;&#xA;" OwnerUserId="11516" LastActivityDate="2023-11-17T16:39:41.180" Title="Optimal currency conversion Linear Programming" Tags="|linear-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11252" PostTypeId="2" ParentId="11251" CreationDate="2023-11-17T05:46:18.803" Score="2" Body="&lt;p&gt;The idea is that by converting via one or more intermediate currencies, you could end up with a larger amount of the target currency N than you would get if you were to convert directly from currency 1 to currency N.&#xA;If there was no limit &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; then there would exist exactly one chain that maximizes the total amount of currency N and you would use your full budget B to follow this chain. But because there's a limit you will have to split the money over multiple chains including chains with lower profits.&lt;/p&gt;&#xA;&lt;p&gt;Hint: there can never be more than N conversions in a single chain.&lt;/p&gt;&#xA;" OwnerUserId="49" LastEditorUserId="49" LastEditDate="2023-11-17T16:39:41.180" LastActivityDate="2023-11-17T16:39:41.180" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11254" PostTypeId="1" CreationDate="2023-11-17T16:20:07.223" Score="0" ViewCount="74" Body="&lt;p&gt;I have a binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$i\in\{1,\ldots,m\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j\in\{1,\ldots,n\}$&lt;/span&gt; and the constraint is to have at most one row that has ones. I wrote this as: &lt;span class=&quot;math-container&quot;&gt;$$x_{i,j}+x_{i',j'}\leqslant1,\forall i'\ne i,\forall i,j,j'$$&lt;/span&gt; which creates &lt;span class=&quot;math-container&quot;&gt;$O(m^2n^2)$&lt;/span&gt; constraints. Can I have a different and better formulation?&lt;/p&gt;&#xA;" OwnerUserId="12843" LastEditorUserId="500" LastEditDate="2023-11-17T17:56:34.613" LastActivityDate="2023-11-19T14:25:06.630" Title="What is the best way to constrain a binary matrix so that at most one row has positive values?" Tags="|integer-programming|constraint|binary-variable|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11255" PostTypeId="2" ParentId="11254" CreationDate="2023-11-17T17:16:05.483" Score="4" Body="&lt;p&gt;Introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i}$&lt;/span&gt; and then define these constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j} \le y_{i} \quad \forall i, j \tag{1}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i} y_i \le 1 \tag{2}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So, at most one of the &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; can be 1 and in that case, any of the elements in that row can be either 0 or 1.&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="36" LastEditDate="2023-11-17T20:05:24.360" LastActivityDate="2023-11-17T20:05:24.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11256" PostTypeId="2" ParentId="11242" CreationDate="2023-11-17T22:46:04.160" Score="0" Body="&lt;p&gt;Throughout, I will use &lt;span class=&quot;math-container&quot;&gt;$\texttt{n}$&lt;/span&gt; to refer to the &amp;quot;n&amp;quot; in your code, &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; to refer to the size of the semidefinite matrix variable (what the literature calls &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;), and &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; to be the number of constraints.&lt;/p&gt;&#xA;&lt;p&gt;Calculating &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; is fairly easy. We can see that your first two constraints are saying, &amp;quot;this first matrix of variables must be a &lt;span class=&quot;math-container&quot;&gt;$(\texttt{n}+3) \times (\texttt{n}+3)$&lt;/span&gt; positive semidefinite matrix, and this second matrix of variables must be a &lt;span class=&quot;math-container&quot;&gt;$3 \times 3$&lt;/span&gt; positive semidefinite matrix. You could combine these into a single &lt;span class=&quot;math-container&quot;&gt;$(\texttt{n}+6) \times (\texttt{n}+6)$&lt;/span&gt; positive semidefinite matrix of variables, where some (&lt;span class=&quot;math-container&quot;&gt;$3\texttt{n}+10$&lt;/span&gt;) variables are constrained to be 0. Thus &lt;span class=&quot;math-container&quot;&gt;$n = \texttt{n}+6$&lt;/span&gt;.&#xA;The constraints are also fairly easy, but requires knowing that usually nonnegativity and positive semidefiniteness  constraints are not counted. With that in mind you have 2 constraints for each &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$\texttt{n}$&lt;/span&gt; so &lt;span class=&quot;math-container&quot;&gt;$m = 2\texttt{n}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5812" LastActivityDate="2023-11-17T22:46:04.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11257" PostTypeId="1" CreationDate="2023-11-18T08:34:09.720" Score="0" ViewCount="100" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AnLwl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AnLwl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is a CVRP problem and I have difficulty understanding the constraints in the red box.&lt;/p&gt;&#xA;&lt;p&gt;For the sub-eliminator constraint (MTZ), my question is how can we make it on our own? I am sure there is some trick.&lt;/p&gt;&#xA;" OwnerUserId="12648" LastEditorUserId="491" LastEditDate="2024-01-25T13:14:50.747" LastActivityDate="2024-01-25T13:14:50.747" Title="Travelling salesman problem" Tags="|modeling|vehicle-routing|big-m|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11258" PostTypeId="2" ParentId="11250" CreationDate="2023-11-18T13:09:28.267" Score="1" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;The most computationally expensive aspect of this algorithm is the reconstruction of the master problem when a column is added (or sometimes removed)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;By &amp;quot;reconstruction&amp;quot;, do you mean that you build your restricted master problem (RMP) from scratch every time a variable is added (or removed)? One should not do that, as it takes to much time, as you have pointed out. Instead you can add the variable to the model and then set the variable coefficients afterwards. Like in this (very simple example):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Initiate RMP&#xA;rmp=Model()&#xA;artificialVariable = rmp.addVar(vtype=GRB.CONTINUOUS, obj =1000000)&#xA;constraint = rmp.addConstr(artificialVariable &amp;gt;= 1)&#xA;&#xA;#...&#xA;&#xA;#Find a new column&#xA;cost, coefficient = solveSubproblem()&#xA;newVariable = rmp.addVar(vtype=GRB.CONTINUOUS, obj = cost)&#xA;rmp.chgCoeff(constraint, newVariable, coefficient)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9151" LastActivityDate="2023-11-18T13:09:28.267" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11259" PostTypeId="2" ParentId="11257" CreationDate="2023-11-18T14:20:07.050" Score="2" Body="&lt;p&gt;The MTZ constraints are big-M constraints that enforce the logical implication&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{ij}=1\implies u_j\ge u_i+d_j.$$&lt;/span&gt;&#xA;That is, if you traverse arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt;, the cumulative demand at &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is at least the cumulative demand at &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; plus the demand at &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;. The basic form is &lt;span class=&quot;math-container&quot;&gt;$$u_i+d_j-u_j\le M_{ij}(1-x_{ij}).$$&lt;/span&gt;&#xA;To find a good value for &lt;span class=&quot;math-container&quot;&gt;$M_{ij} $&lt;/span&gt;, you want an upper bound on the LHS when &lt;span class=&quot;math-container&quot;&gt;$x_{ij}=0$&lt;/span&gt;.  Adding the bounds &lt;span class=&quot;math-container&quot;&gt;$u_i\le C$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$-u_j\le -d_j$&lt;/span&gt; yields &lt;span class=&quot;math-container&quot;&gt;$$u_i+d_j-u_j\le C+d_j-d_j=C,$$&lt;/span&gt; so take &lt;span class=&quot;math-container&quot;&gt;$M_{ij}=C$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-11-18T14:20:07.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11260" PostTypeId="2" ParentId="11125" CreationDate="2023-11-18T18:26:26.473" Score="0" Body="&lt;p&gt;With version 1.5.3 you should add constraints using the &lt;code&gt;addRow(...)&lt;/code&gt; method in the format &lt;code&gt;lhs &amp;lt;= constraint &amp;lt;= rhs&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m = highspy.Highs()&#xA;m.addRow(&#xA;  lhs,&#xA;  rhs,&#xA;  quantity of non-zero variables&#xA;  indexes of variables&#xA;  coefficients of the variables&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For instance, if you have a knapscack constraint like &lt;span class=&quot;math-container&quot;&gt;$\sum_{i} w_{i} * x_{ij} &amp;lt;= c * y_{j}, \forall j$&lt;/span&gt;, then the code should be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m = highspy.Highs()&#xA;for j in B:&#xA;  m.addRow(&#xA;    -highspy.kHighsInf,&#xA;    0,&#xA;    N+1,&#xA;    [idx_x[i,j] for i in range(N)]+[idx_y[j]],&#xA;    [w[i] for i in range(N)]+[-c]&#xA;  )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12638" LastActivityDate="2023-11-18T18:26:26.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11261" PostTypeId="1" CreationDate="2023-11-19T10:42:21.457" Score="0" ViewCount="79" Body="&lt;p&gt;I would like to adjust my constraint so that the x are only ever added for the weekend of a week, i.e. days 6,7 and then 13,14 and 20,21 etc.. That would be my previous formulation, but how can I formulate it more beautifully?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in I}^{}x_{jit}\le 2~~~\forall j\in J,b\in B,t\in\{6,7\}\cup\{13,14\}\\&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="11887" LastActivityDate="2023-12-19T13:01:30.200" Title="Sum only over weekend days" Tags="|linear-programming|constraint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11262" PostTypeId="2" ParentId="11261" CreationDate="2023-11-19T11:18:46.740" Score="1" Body="&lt;p&gt;I would just define another set, &lt;span class=&quot;math-container&quot;&gt;$T^{Weekends} = \{t \in T | t\mod 7 =6 \;\vee  t \mod 7=0\}$&lt;/span&gt;. Here I have assumed that you have a set &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; with all relevant days.&lt;/p&gt;&#xA;&lt;p&gt;Then you can write your constraint like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i\in I}^{}x_{jit}\le 2~~~\forall j\in J,t\in T^{Weekends}\\&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have removed &lt;span class=&quot;math-container&quot;&gt;$b\in B$&lt;/span&gt;, since &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is unused.&lt;/p&gt;&#xA;" OwnerUserId="9151" LastEditorUserId="9151" LastEditDate="2023-11-19T12:59:06.750" LastActivityDate="2023-11-19T12:59:06.750" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11263" PostTypeId="2" ParentId="11254" CreationDate="2023-11-19T14:25:06.630" Score="2" Body="&lt;p&gt;Adding to the solution provided by @EhsanK. By introducing a binary variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, which is 1 only if all &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; are equal to 0, and adding a constraint, potential symmetries in the branch-and-bound tree can be avoided.&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{i,j} \le y_{i} \quad \forall i, j \tag{1}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i} y_i  + z = 1 \tag{2}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_i \sum_j x_{i,j} \geq 1-z \tag{3}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If for example &lt;span class=&quot;math-container&quot;&gt;$y_1 =0.5$&lt;/span&gt; in the LP-solution, and one branches on &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;, then one wants to partition the solution space in two. However, if one does not have the variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and the additional constraint, then the solution where all &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}$&lt;/span&gt; equals 0 is contained in both partitions after branching on &lt;span class=&quot;math-container&quot;&gt;$y_1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To be clear, I am not saying including &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and the additional constraint is going to perform better, but in some cases it might.&lt;/p&gt;&#xA;" OwnerUserId="9151" LastActivityDate="2023-11-19T14:25:06.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11264" PostTypeId="1" AcceptedAnswerId="11265" CreationDate="2023-11-19T17:04:11.540" Score="2" ViewCount="227" Body="&lt;p&gt;I have been attempting to solve a maximization problem where there is a piecewise function in the objective. Something like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{n}(1-prob_{n})(1+x_n)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$prob_{n} = $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases} &#xA;      0.25, &amp;amp; x_n \geq 2 \\&#xA;      0, &amp;amp; 0 &amp;lt; x_n &amp;lt; 2 \\&#xA;    0.05, &amp;amp; x \leq 0 \\&#xA;\end{cases}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that this is just a toy example, I realise that this function can very easily be maximised but this is just for me to understand how one can linearise a piecewise function with several segments.&lt;/p&gt;&#xA;&lt;p&gt;I have not been able to linearise this piecewise function using big-M constraints but I came across &lt;a href=&quot;https://cklixx.people.wm.edu/teaching/math323/m323-09.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; (see page 9 and 10). Here they linearise a piecewise function without any big-M constraints. I have worked through the example and it makes sense to me. However, the piecewise function considered in the example does not have 'jumps' like mine does. There are kinks but at the break points the value is the same when going from one segment to another. In my piecewise function however, there are jumps. For example, at &lt;span class=&quot;math-container&quot;&gt;$x=2$&lt;/span&gt; we are at 0.25 but at &lt;span class=&quot;math-container&quot;&gt;$x - \epsilon$&lt;/span&gt; we are at 0.&lt;/p&gt;&#xA;&lt;p&gt;The function considered in the example looks like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c(x) = $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases} &#xA;      25x, &amp;amp;  0 \leq x_n \leq 500 \\&#xA;      20x + 2500, &amp;amp; 500 \leq x_n \leq 1000  \\&#xA;    15x + 7500, &amp;amp; 1000 \leq x_n \leq 1500 \\&#xA;\end{cases}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is then written as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_{1}c(0) + z_{2}c(500) + z_{3}c(1000) + z_{4} c(1500)$&lt;/span&gt; (1).&lt;/p&gt;&#xA;&lt;p&gt;Then the following constraints are added:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x = 0z_{1} + 500z_{2} + 1000z_3 + 1500z_4$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_1 \leq y_1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_2 \leq y_1 + y_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_3 \leq y_2 + y_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_4 \leq y_3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_1 + y_2 + y_3 = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z_1 + z_2 + z_3 + z_4 = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; are binary variables and &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; are positive reals.&lt;/p&gt;&#xA;&lt;p&gt;I tried this approach to my piecewise function but I am uncertain about how to deal with the 'jumps' when re-writing (1). Is it even possible to apply this approach to my function or do I have to figure out the big-M approach?&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&lt;p&gt;Thanks to @Ggouvine for the explanation. Here is my attempt at linearising the original problem (prob_n has been re-written for clarity).&lt;/p&gt;&#xA;&lt;p&gt;Objective:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{n}(1-prob_{n})(1+x_n)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$prob_{n} = $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{cases} &#xA;      0.05, &amp;amp; -5 \leq x_n \leq 2 \\&#xA;      0, &amp;amp; 0 &amp;lt; x_n &amp;lt; 2 \\&#xA;    0.25, &amp;amp; 2 \leq x \leq 5 \\&#xA;\end{cases}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So now I have added -5 and +5 as lower and upper bounds. I can then re-write the objective as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{n}(1-0.05y_{1} - 0 y_2 - 0.25 y_3)(1+x_n)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; are binary variables. Now the problem is non-linear. However, the multiplicative terms (i,e &lt;span class=&quot;math-container&quot;&gt;$y_{i}x_{n}$&lt;/span&gt;) can be linearised given the approach outlined here: &lt;a href=&quot;https://or.stackexchange.com/questions/6071/how-to-linearize-the-product-of-a-binary-and-a-continuous-variable&quot;&gt;How to linearize the product of a binary and a continuous variable?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So I will simply focus on the interval and prob_n constraints.&lt;/p&gt;&#xA;&lt;p&gt;For the interval we get:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;-5 &amp;amp;\leq x_n &amp;amp;&amp;amp;\leq 0 + M(1-y_1) \\&#xA;0 -  M(1-y_2) &amp;amp;\leq x_n &amp;amp;&amp;amp;\leq 2 + M(1-y_2) \\&#xA;2 -  M(1-y_3) &amp;amp;\leq x_n &amp;amp;&amp;amp;\leq 5&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And for prob_n we get:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0.05 - (1-y_1)M  &amp;amp;\leq prob_n &amp;amp;&amp;amp;\leq 0.05 + (1-y_1)M \\&#xA;0 - (1-y_2)M  &amp;amp;\leq prob_n &amp;amp;&amp;amp;\leq 0 + (1-y_2)M \\&#xA;0.25 - (1-y_3)M &amp;amp;\leq prob_n &amp;amp;&amp;amp;\leq 0.25 + (1-y_3)M \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have tried different values for &lt;span class=&quot;math-container&quot;&gt;$y_1, y_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_3$&lt;/span&gt; and it comes out as expected. So I suppose I just need to include the constraints for linearising the multiplicative terms and I should be able to solve this using a MILP solver.&lt;/p&gt;&#xA;" OwnerUserId="11074" LastEditorUserId="11074" LastEditDate="2023-11-19T19:11:20.013" LastActivityDate="2023-11-19T22:09:14.710" Title="Linearize piecewise function without big-M constraints" Tags="|mixed-integer-programming|big-m|reformulation-linearization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11265" PostTypeId="2" ParentId="11264" CreationDate="2023-11-19T18:05:26.630" Score="3" Body="&lt;p&gt;I don't see or remember a way around the big-M constraints. Thankfully they are not that hard to write. Or you may use indicator constraints which are even simpler.&lt;/p&gt;&#xA;&lt;p&gt;We add new binary variables, and depending on them some constraints are equality constraints, or ignored. Typically these conditional constraints are written &lt;span class=&quot;math-container&quot;&gt;$a - My \leq b \leq a + My$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here we use one binary variable per interval:&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_1 + y_2 + y_3 = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To constrain the intervals:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0 &amp;amp;\leq x &amp;amp;&amp;amp;\leq 500 + M(1-y_1) \\&#xA;500 -  M(1-y_2) &amp;amp;\leq x &amp;amp;&amp;amp;\leq 1000 + M(1-y_2) \\&#xA;1000 -  M(1-y_3) &amp;amp;\leq x &amp;amp;&amp;amp;\leq 1500&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To constrain the objective:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;25x - M(1-y_1)  &amp;amp;\leq prob &amp;amp;&amp;amp;\leq 25x + M(1-y_1) \\&#xA;20x + 2500 - M(1-y_2)  &amp;amp;\leq prob &amp;amp;&amp;amp;\leq 20x + 2500 + M(1-y_2) \\&#xA;15x + 7500 - M(1-y_3) &amp;amp;\leq prob &amp;amp;&amp;amp;\leq 15x + 7500 + M(1-y_3) \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Up to you to compute values for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; that are small but big enough to stay valid.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2023-11-19T22:09:14.710" LastActivityDate="2023-11-19T22:09:14.710" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11266" PostTypeId="1" CreationDate="2023-11-20T01:03:36.700" Score="0" ViewCount="36" Body="&lt;p&gt;I need to build a if-else constraint for this statement, where &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; are decision variables, and &lt;span class=&quot;math-container&quot;&gt;$m_i$&lt;/span&gt; is a constant:&lt;/p&gt;&#xA;&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$c_j$&lt;/span&gt; = &lt;span class=&quot;math-container&quot;&gt;$m_i$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt; = 1 else &lt;span class=&quot;math-container&quot;&gt;$x_{ij} = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Any help is greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="12774" LastActivityDate="2023-11-20T01:03:36.700" Title="Could you model this if -else statement" Tags="|modeling|logical-constraints|" AnswerCount="0" CommentCount="1" ClosedDate="2023-11-20T02:42:15.067" ContentLicense="CC BY-SA 4.0" />
  <row Id="11267" PostTypeId="1" CreationDate="2023-11-20T16:22:29.090" Score="1" ViewCount="56" Body="&lt;p&gt;I need to solve a convex minimization problem of the form: minimize &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$g_i(x)\leq 0$&lt;/span&gt;, where the &lt;span class=&quot;math-container&quot;&gt;$g_i$&lt;/span&gt; are convex functions given by a value oracle.&lt;/p&gt;&#xA;&lt;p&gt;As far as I know, to use the ellipsoid method, I need an initial ball of size &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; that contains the feasible region, and a positive number &lt;span class=&quot;math-container&quot;&gt;$r&amp;lt;R$&lt;/span&gt; such that, if the feasible region is not empty, then it contains a ball of radius &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;; then, the run-time complexity of the method is in &lt;span class=&quot;math-container&quot;&gt;$O(\log(R/r))$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My question is: what can be done if the second condition cannot be fulfilled, that is, &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; can be &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; (it is possible that the feasible region is a single point)?&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Are there other polynomial-time methods that can be used in this case?&lt;/li&gt;&#xA;&lt;li&gt;Alternatively, can it be proved that, without a guarantee that &lt;span class=&quot;math-container&quot;&gt;$r&amp;gt;0$&lt;/span&gt;, the problem is NP-hard?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;sub&gt;Note: I asked a &lt;a href=&quot;https://cs.stackexchange.com/q/162127/1342&quot;&gt;similar question in cs.SE&lt;/a&gt;, but about the initial ellipsoid (the ball of radius &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt;) rather than on the small radius &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2023-11-29T09:20:06.607" Title="Convex programming without a lower bound on the feasible region size" Tags="|convex-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11268" PostTypeId="1" CreationDate="2023-11-21T07:15:33.237" Score="0" ViewCount="73" Body="&lt;p&gt;In some iterations, when a new column is added to the master, it does not enter the base and a stop condition occurs, or a new column with a better objective function is found. is it correct?&lt;/p&gt;&#xA;" OwnerUserId="12849" LastEditorUserId="36" LastEditDate="2023-11-21T18:35:47.487" LastActivityDate="2023-11-21T18:35:47.487" Title="In column generation is it possible that a new column from sub problem doesn't enter master's base?" Tags="|column-generation|" AnswerCount="0" CommentCount="1" ClosedDate="2023-12-22T22:43:27.947" ContentLicense="CC BY-SA 4.0" />
  <row Id="11269" PostTypeId="1" CreationDate="2023-11-21T08:07:50.893" Score="2" ViewCount="143" Body="&lt;p&gt;Is it possible to specify an integer-constrained variable without any bounds in the MPS format?&lt;/p&gt;&#xA;&lt;p&gt;I am reading&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.ibm.com/docs/en/icos/22.1.0?topic=extensions-integer-variables-in-mps-files&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/22.1.0?topic=extensions-integer-variables-in-mps-files&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and cannot figure out the way to do it.&lt;/p&gt;&#xA;&lt;p&gt;Also the previously mentioned documentation states:&lt;/p&gt;&#xA;&lt;p&gt;To specify a general integer variable with no upper bounds, one must use the first way, that is, make certain that the variable's column is described within an INTORG/INTEND marker pair.&lt;/p&gt;&#xA;&lt;p&gt;I thought the bound key LI is used to specify an integer-constrained variable with no upper bound.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2023-12-23T08:02:25.250" Title="General integer variables in the MPS format" Tags="|mps|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11270" PostTypeId="1" CreationDate="2023-11-21T15:00:18.543" Score="1" ViewCount="114" Body="&lt;p&gt;We are implementing a scheduling model using Benders Decomposition. Does someone know of any existing implementation of Benders or any repositories that contain continuous or integer problems solved using Benders Decomposition?&lt;/p&gt;&#xA;" OwnerUserId="12855" LastEditorUserId="491" LastEditDate="2023-12-07T13:45:15.893" LastActivityDate="2023-12-07T13:45:15.893" Title="Benchmark problems for Benders Decomposition" Tags="|linear-programming|integer-programming|stochastic-programming|benders-decomposition|benchmark|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11271" PostTypeId="1" CreationDate="2023-11-21T16:37:18.427" Score="0" ViewCount="27" Body="&lt;p&gt;as I am trying to learn the Gurobi package, I did successfully try to implement some mathematical models. I want more and wish to have some exercises containing the Obj fun solution and the variables as well please.&lt;/p&gt;&#xA;" OwnerUserId="12856" LastActivityDate="2023-11-21T16:37:18.427" Title="Need exercises to learn the Gurobi python package syntax" Tags="|python|gurobipy|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11272" PostTypeId="1" CreationDate="2023-11-21T20:32:08.597" Score="0" ViewCount="62" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/94sbE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/94sbE.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Hi,&lt;/p&gt;&#xA;&lt;p&gt;Can someone explain to me how this works or refer to any page that tells how the single facility problem works step by step?&lt;/p&gt;&#xA;" OwnerUserId="12648" LastActivityDate="2023-12-22T03:02:55.340" Title="Single Facility Problem" Tags="|facility-location|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11273" PostTypeId="2" ParentId="11272" CreationDate="2023-11-22T01:48:26.727" Score="0" Body="&lt;p&gt;Looks like Weiszfeld's algorithm for the (weighted) geometric median.  See&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Geometric_median&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Geometric_median&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://blogs.sas.com/content/iml/2023/06/28/geometric-median-sas.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://blogs.sas.com/content/iml/2023/06/28/geometric-median-sas.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-11-22T01:48:26.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11274" PostTypeId="1" CreationDate="2023-11-22T06:52:49.740" Score="1" ViewCount="52" Body="&lt;p&gt;I am an electrical engineer who is currently learning about optimization. From this &lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;post&lt;/a&gt;, they have shown how to linearize the product of two binary variables.&lt;/p&gt;&#xA;&lt;p&gt;But in my case, I have a product &lt;span class=&quot;math-container&quot;&gt;$x \times y$&lt;/span&gt; and a ratio &lt;span class=&quot;math-container&quot;&gt;$\frac{x}{y}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is binary and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is a continuous non negative variable. Therefore, my question is how to linearize them ?&lt;/p&gt;&#xA;&lt;p&gt;Would you kindly help me with this problem ?&lt;/p&gt;&#xA;&lt;p&gt;Thank you very much for your enthusiasm !&lt;/p&gt;&#xA;" OwnerUserId="11163" LastActivityDate="2023-11-22T06:52:49.740" Title="How to linearize a product and ratio of $x$ and $y$ where $x$ is binary and $y$ is a continuous variable?" Tags="|linearization|binary-variable|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11275" PostTypeId="2" ParentId="11270" CreationDate="2023-11-22T08:11:49.497" Score="1" Body="&lt;p&gt;Some collections of testing instances for &lt;strong&gt;Stochastic Programming&lt;/strong&gt; which can be solved by the &lt;strong&gt;Benders Decomposition / L-shaped / SDDP&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MSPLib-Library &lt;a href=&quot;https://github.com/bonnkleiford/MSPLib-Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/bonnkleiford/MSPLib-Library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;SIPLIB: A Stochastic Integer Programming Test Problem Library &lt;a href=&quot;https://www2.isye.gatech.edu/%7Esahmed/siplib/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www2.isye.gatech.edu/~sahmed/siplib/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;A (PO)rtable (S)tochastic programming (T)est (S)et (POSTS) &lt;a href=&quot;https://users.iems.northwestern.edu/%7Ejrbirge/html/dholmes/post.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://users.iems.northwestern.edu/~jrbirge/html/dholmes/post.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Test-Problem Collection for Stochastic Linear Programming &lt;a href=&quot;https://www4.uwsp.edu/math/afelt/slptestset.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www4.uwsp.edu/math/afelt/slptestset.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2023-11-22T08:11:49.497" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11276" PostTypeId="1" AcceptedAnswerId="11325" CreationDate="2023-11-22T10:05:52.900" Score="4" ViewCount="155" Body="&lt;p&gt;Currently I am working on an implementation of Benders Decomposition that solves a stochastic vehicle routing problem with synchronisation constraints.&lt;/p&gt;&#xA;&lt;p&gt;Sadly, at the moment it is not performing fast enough to be a serviceable solution method.&lt;/p&gt;&#xA;&lt;p&gt;The main problem I think is, that in the first stage of the stochastic problem, we basically generate 99% of the time tours that are rendered infeasible by the subproblem because all the information on time windows and the needed synchronisation is part of the subproblem.&lt;/p&gt;&#xA;&lt;p&gt;So the number of feasibility cuts is extremely high.&lt;/p&gt;&#xA;&lt;p&gt;In order to fix this, I tried to add a subset of the scenarios to the master problem, meaning it gets extended with the complete set of constraints for this subset.&lt;/p&gt;&#xA;&lt;p&gt;It accelerated the method a little, but not enough.&lt;/p&gt;&#xA;&lt;p&gt;Do you have further recommendations how I could deal this with problem?&lt;/p&gt;&#xA;" OwnerUserId="12130" LastEditorUserId="12130" LastEditDate="2023-11-22T14:52:12.000" LastActivityDate="2023-12-29T20:05:05.737" Title="What's the best way to speed up Benders Decomposition for a stochastic vehicle routing problem?" Tags="|mixed-integer-programming|vehicle-routing|stochastic-programming|benders-decomposition|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11277" PostTypeId="1" CreationDate="2023-11-22T16:59:16.843" Score="1" ViewCount="40" Body="&lt;p&gt;Although I only heard about Contextual Stochastic Optimization (CSO) a few months ago, I know now the excitement has been going on for a while. I'm not sure if the idea of CSO has been around for long, but at least this latest iteration of excitement is often linked to &lt;a href=&quot;https://pubsonline.informs.org/doi/10.1287/mnsc.2018.3253&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bertsimas and Kallus &amp;quot;From predictive to prescriptive analytics&amp;quot; (2019)&lt;/a&gt;. Along with those names, two other authors that have been working on the area and finding some successful results for a while are &lt;a href=&quot;https://scholar.google.com/citations?user=Z-CFWPwAAAAJ&amp;amp;hl=en&quot; rel=&quot;nofollow noreferrer&quot;&gt;Elmachtoub&lt;/a&gt; and &lt;a href=&quot;https://scholar.google.com/citations?user=Kw1eyxAAAAAJ&amp;amp;hl=en&quot; rel=&quot;nofollow noreferrer&quot;&gt;Grigas&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In CSO, we are concerned with a prediction problem (PP) and optimization problem (OP) that happen in tandem. The prediction problem can be cast as the minimization of a loss (or cost) function. Once solved, the results are used by the optimization problem (OP). From what I understand, CSO has become popular lately because it allows the use of contextual/side/covariate information that might otherwise go unused in different modelling frameworks. With the data-rich environments we have nowadays, it seemed a waste of useful data. Another reason CSO might have become so popular is that it does not focus on finding the best prediction error; rather, it focus on finding the best optimization error. Under this framework, the prediction is an aid to the OP.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;But what happens when you have a bilevel contextual optimization problem (BCOP) and the prediction problem (PP) is part of the inner problem?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The way I know of solving bilevel problems is by re-writing the inner problem as constraints to the outer problem through the KKT conditions. If the PP is being used to estimate the parameters of the inner problem, then the PP itself is going to be re-written as an optimization problem, likely a loss-function minimization problem.&lt;/p&gt;&#xA;&lt;p&gt;If, for instance, I &lt;em&gt;assume&lt;/em&gt; my data follow an autoregressive model, I can estimate the parameters of the model by solving the Yule-Walker equations, which can be solved as a feasibility problem. Those are linear equations that can easily be &amp;quot;sent&amp;quot; to the outer problem through the KKT. Now, one thing that I can't seem to understand is how that approach will work if I chose to model the data using a ML approach, say a NN, for instance.&lt;/p&gt;&#xA;" OwnerUserId="1129" LastEditorUserId="491" LastEditDate="2023-11-28T01:52:31.803" LastActivityDate="2023-11-28T01:52:31.803" Title="How would the Contextual Stochastic Optimization framework be applied to a bilevel problem whose uncertain parameters lie in the inner problem?" Tags="|optimization|stochastic-programming|forecasting|parameters-tuning|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11278" PostTypeId="2" ParentId="4192" CreationDate="2023-11-22T17:37:01.167" Score="1" Body="&lt;p&gt;Look at case studies from LocalSolver:&#xA;&lt;a href=&quot;https://www.localsolver.com/docs/last/exampletour/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.localsolver.com/docs/last/exampletour/index.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4852" LastActivityDate="2023-11-22T17:37:01.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11279" PostTypeId="1" AcceptedAnswerId="11280" CreationDate="2023-11-22T19:13:38.007" Score="1" ViewCount="178" Body="&lt;p&gt;I am working on a employee scheduling problems (assigning shifts to temporary workers) by modeling it as a MIP. There is a one shift per day constraint for the employees. There are overnight shifts and need to take care of the day boundaries and employee rest periods -- for example an employee working between 8pm on a day till 2am the next day can not start their shift the next day without having a rest time of x hours. So in summary, there are overlapping shifts and need to choose a single shift from the set of overlapping shifts. There can be multiple such overlapping groups for a single employee. We have modeled it as mutual exclusive constraints (sum of all variables in an overlap group can be at most one). But the problem is that in certain cases,the number of variables in such constraints is quite big (1000+) and these are all binary variables. So the problem is getting hard to solve pretty fast. I wanted to know if there is any other way to model this or can we simplify in any way. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="12862" LastActivityDate="2023-11-23T12:20:59.783" Title="Workforce scheduling problem" Tags="|mixed-integer-programming|scheduling|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11280" PostTypeId="2" ParentId="11279" CreationDate="2023-11-22T19:52:35.407" Score="2" Body="&lt;p&gt;Consider a side-constrained network formulation in which you have a node for each employee-day-shift and a directed arc if the employees are the same, the days are consecutive, and the shifts do not overlap. You will also need for each employee a dummy source node and a dummy sink node. Now for each employee you want to find a directed source-sink path, which by construction of the network will visit each day exactly once.  So far, this is a pure network problem for each employee, but you presumably also have side constraints across employees so each day-shift has enough employees to cover the demand.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-11-22T20:00:27.577" LastActivityDate="2023-11-22T20:00:27.577" CommentCount="26" ContentLicense="CC BY-SA 4.0" />
  <row Id="11281" PostTypeId="1" CreationDate="2023-11-23T02:50:04.700" Score="1" ViewCount="58" Body="&lt;p&gt;For example, we have an optimization problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \sum_{i=1}^{n} |w_{i} - a_{i}| b_{i} \quad \text{s.t.} \quad \sum_{i=1}^{n} c_i w_i = 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and &lt;span class=&quot;math-container&quot;&gt;$a_i, b_i, c_i$&lt;/span&gt; are given. How to convert it into a linear program?&lt;/p&gt;&#xA;&lt;p&gt;I know that if we want to minimize &lt;span class=&quot;math-container&quot;&gt;$|x - a|$&lt;/span&gt;, we should let minimize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$z \ge x-a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z \ge -(x-a)$&lt;/span&gt;. However, in this case, we want to minimize the weighted sum of absolute value and do not know the sign of &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt;. Does anyone know how to do it?&lt;/p&gt;&#xA;" OwnerUserId="12860" LastEditorUserId="500" LastEditDate="2023-11-23T08:35:31.670" LastActivityDate="2023-11-23T08:35:31.670" Title="transform minimize weighted sum of absolute value into a linear optimization" Tags="|optimization|linear-programming|linearization|convex-optimization|absolute-value|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11282" PostTypeId="2" ParentId="11269" CreationDate="2023-11-23T07:11:45.683" Score="0" Body="&lt;p&gt;I used Gurobi to write out the following ILP in mps format:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{ll}&#xA;\min &amp;amp; 0 \\&#xA;s.t. &amp;amp; x + y = 1 \\&#xA;&amp;amp; x \geq 0 \\&#xA;&amp;amp; y \text{ free} \\&#xA;&amp;amp; x,y \text{ integer}&#xA;\end{array}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The corresponding result is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;NAME &#xA;ROWS&#xA; N  OBJ&#xA; E  R0      &#xA;COLUMNS&#xA;    MARKER    'MARKER'                 'INTORG'&#xA;    C0        R0        1&#xA;    C1        R0        1&#xA;    MARKER    'MARKER'                 'INTEND'&#xA;RHS&#xA;    RHS1      R0        1&#xA;BOUNDS&#xA; LI BND1      C0        0&#xA; FR BND1      C1      &#xA;ENDATA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So it seems that using &lt;code&gt;FR&lt;/code&gt; is the bound key here.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2023-11-23T07:11:45.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11283" PostTypeId="1" AcceptedAnswerId="11291" CreationDate="2023-11-23T08:28:57.080" Score="3" ViewCount="150" Body="&lt;p&gt;I am solving a maximization problem with  continuous variables &lt;span class=&quot;math-container&quot;&gt;$x,z\in \mathbb{R}^+$&lt;/span&gt; and binary variable &lt;span class=&quot;math-container&quot;&gt;$\delta \in \{0,1\}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am maximizing &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; subject to side constraints and would like to enforce &lt;span class=&quot;math-container&quot;&gt;$\delta = 1\implies x= z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\delta = 0\implies x= 0$&lt;/span&gt; which I model as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x &amp;amp;\le z \tag{1}\\&#xA;  0 \le  x &amp;amp;\le U \cdot \delta  \tag{2}&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; is an upper bound for variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&#xA;Since I am maximizing &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; this is sufficient. However, would it help the solver to add a lower bound to the above constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; ? Such as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA; z-U(1-\delta) \le  x \le z \tag{3}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In other words, does model &lt;span class=&quot;math-container&quot;&gt;$(2)-(3)$&lt;/span&gt; provide a tighter linear relaxation than model &lt;span class=&quot;math-container&quot;&gt;$(1)-(2)$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;h4&gt;Edit&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Note that it is important that the model remains linear. The above is a linearization of &lt;span class=&quot;math-container&quot;&gt;$x=z \delta$&lt;/span&gt;, which is not linear.&lt;/li&gt;&#xA;&lt;li&gt;Assume that &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; is the best constant upper bound for variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="12863" LastEditorUserId="12863" LastEditDate="2023-11-23T09:14:06.530" LastActivityDate="2023-11-25T13:08:17.687" Title="Will adding this constraint help my model?" Tags="|mixed-integer-programming|linear-programming|modeling|logical-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11285" PostTypeId="2" ParentId="11279" CreationDate="2023-11-23T12:20:59.783" Score="0" Body="&lt;p&gt;We typically handle &amp;quot;overlapping shifts&amp;quot;, &amp;quot;minimum X hours between two shifts&amp;quot; and/or &amp;quot;one shift per day&amp;quot; as separate constraints.&#xA;This is because in some cases they aren't always all hard constraints. Some of them can be soft constraints with a heavy weight.&lt;/p&gt;&#xA;&lt;p&gt;We &lt;strong&gt;avoid binary variables&lt;/strong&gt; by given each shift a variable to hold an employee, instead of creating a variable for each shift-employee combination. So if there are 1000 shifts and 200 employees, there are 1000 variables with 200 values. Not 200 000 variables with 2 values. That's a huge difference in search space (&lt;code&gt;200^1000&lt;/code&gt; ~ &lt;code&gt;2^8000&lt;/code&gt; versus &lt;code&gt;2^200000&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;For what it's worth, here's an implementation of those constraints in Timefold (not a MIP solver):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Constraint noOverlappingShifts(ConstraintFactory constraintFactory) {&#xA;    return constraintFactory.forEachUniquePair(Shift.class, &#xA;                    Joiners.equal(Shift::getEmployee),&#xA;                    Joiners.overlapping(Shift::getStart, Shift::getEnd))&#xA;            .penalize(HardSoftScore.ONE_HARD,&#xA;                    EmployeeSchedulingConstraintProvider::getMinuteOverlap)&#xA;            .asConstraint(&amp;quot;Overlapping shift&amp;quot;);&#xA;}&#xA;&#xA;Constraint atLeast10HoursBetweenTwoShifts(ConstraintFactory constraintFactory) {&#xA;    return constraintFactory.forEachUniquePair(Shift.class,&#xA;                    Joiners.equal(Shift::getEmployee),&#xA;                    Joiners.lessThanOrEqual(Shift::getEnd, Shift::getStart))&#xA;            .filter((firstShift, secondShift) -&amp;gt; Duration.between(firstShift.getEnd(), secondShift.getStart()).toHours() &amp;lt; 10)&#xA;            .penalize(HardSoftScore.ONE_HARD,&#xA;                    (firstShift, secondShift) -&amp;gt; {&#xA;                        int breakLength = (int) Duration.between(firstShift.getEnd(), secondShift.getStart()).toMinutes();&#xA;                        return (10 * 60) - breakLength;&#xA;                    })&#xA;            .asConstraint(&amp;quot;At least 10 hours between 2 shifts&amp;quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="350" LastActivityDate="2023-11-23T12:20:59.783" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11286" PostTypeId="1" CreationDate="2023-11-23T14:05:35.233" Score="1" ViewCount="295" Body="&lt;p&gt;There is NoRel (or No Relaxation) heuristic in the Gurobi solver which helps to find very good feasible solutions for Mixed Integer Programs. I couldn't find explanation of its idea. Perhaps anybody knows the details? Or it is a commercial secret and there is no paper describing it? I found out some information here: &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/9341291193745-NoRel-heuristics-is-this-adding-valid-inequalities-&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://support.gurobi.com/hc/en-us/community/posts/9341291193745-NoRel-heuristics-is-this-adding-valid-inequalities-&lt;/a&gt;, but it is not sufficient.&lt;/p&gt;&#xA;" OwnerUserId="12663" LastActivityDate="2023-12-23T15:00:55.120" Title="What is NoRel heuristic in GUROBI?" Tags="|mixed-integer-programming|gurobi|heuristics|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11287" PostTypeId="2" ParentId="11286" CreationDate="2023-11-23T14:26:59.507" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/9282521673745-What-is-phase-1-solution-&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://support.gurobi.com/hc/en-us/community/posts/9282521673745-What-is-phase-1-solution-&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can also read this one, might help you.&lt;/p&gt;&#xA;" OwnerUserId="12370" LastActivityDate="2023-11-23T14:26:59.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11288" PostTypeId="2" ParentId="4192" CreationDate="2023-11-23T14:43:22.320" Score="0" Body="&lt;p&gt;Manufacturing applications based on tailored versions of Product-Mix Optimization and Diet Problem Optimization are also used a lot, daily.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2023-11-23T14:43:22.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11289" PostTypeId="1" AcceptedAnswerId="11296" CreationDate="2023-11-23T17:53:05.690" Score="2" ViewCount="49" Body="&lt;p&gt;Does CPLEX OPL provides support for &lt;em&gt;info&lt;/em&gt; callback? By &lt;em&gt;info&lt;/em&gt; callback I am referring to callback allowing to retrieve information of the current solution at a given step of the optimization process.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="491" LastEditDate="2023-11-23T21:11:57.040" LastActivityDate="2023-11-25T09:01:12.140" Title="Info callback in CPLEX OPL" Tags="|cplex|callback|opl|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11290" PostTypeId="1" AcceptedAnswerId="11304" CreationDate="2023-11-24T02:55:07.967" Score="0" ViewCount="92" Body="&lt;p&gt;I'm working on a production scheduling problem with a MIP model somebody left to me.&#xA;This is a discrete-time model in which the constraints used to control the production and consumption of product &lt;em&gt;p&lt;/em&gt; are such that&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wamr6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wamr6.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;(I dont know how to input formula in StackExchange, so I use picture，hope this doesnt make reading difficult)&lt;/p&gt;&#xA;&lt;p&gt;You can see that the constraints do not actually indicate in detail which process's product goes to which process that consumes it, but only ensure that the production and consumption of good &lt;em&gt;p&lt;/em&gt; is balanced at each &lt;em&gt;t&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now the constraint I want to add is that the product of some specific production process can flow to the consuming process I specify. The flow transfer time t is not required to be fixed, the quantity is given by me. Colud give me some suggestions?&lt;/p&gt;&#xA;" OwnerUserId="12686" LastEditorUserId="491" LastEditDate="2023-11-28T01:53:16.663" LastActivityDate="2023-11-28T11:13:42.243" Title="How to design a constraint to control flow in a non-network optimization model" Tags="|optimization|mixed-integer-programming|gurobi|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11291" PostTypeId="2" ParentId="11283" CreationDate="2023-11-24T16:05:38.180" Score="2" Body="&lt;p&gt;I think the answer is a definitive &amp;quot;maybe&amp;quot;. Adding constraint (3) &lt;em&gt;might&lt;/em&gt; help the solver to recognize infeasible branches of the search tree sooner (branches with &lt;span class=&quot;math-container&quot;&gt;$\delta = 1$&lt;/span&gt; where side constraints would block &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; from equaling &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;), which &lt;em&gt;might&lt;/em&gt; help. On the other hand, it is also possible that the (3) would just be extra baggage that would slow the solver (slightly, if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; have dimension 1). It is easy enough to try.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-11-24T16:05:38.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11292" PostTypeId="1" CreationDate="2023-11-24T16:26:13.097" Score="0" ViewCount="161" Body="&lt;p&gt;Here is my problem:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There are five sewing lines.&lt;/li&gt;&#xA;&lt;li&gt;When sample orders arrive, we have to assign them to the available line which is more skilled on a particular garment.&lt;/li&gt;&#xA;&lt;li&gt;Each line is given a rank according to their skill level on styles.&lt;/li&gt;&#xA;&lt;li&gt;Line capacity should not be exceeded when assigning.&lt;/li&gt;&#xA;&lt;li&gt;Also, orders should be sent by the due date.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;What is the suitable optimization algorithm to apply for assigning sample orders to sewing lines?&lt;br /&gt;&#xA;If we use the transportation algorithm, what to do with dummy lines or dummy styles in real-world scenarios?&lt;/p&gt;&#xA;" OwnerUserId="12868" LastEditorUserId="36" LastEditDate="2023-11-24T17:55:22.790" LastActivityDate="2023-12-26T20:07:15.877" Title="Algorithms to use for an assignment problem" Tags="|optimization|assignment-problem|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="11293" PostTypeId="2" ParentId="11194" CreationDate="2023-11-24T20:40:00.587" Score="3" Body="&lt;p&gt;They are the same, with the caveat that the two sources are using slightly different notation. All symbols other than &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt; are the same in both places, but Hillier and Lieberman use &lt;span class=&quot;math-container&quot;&gt;$\rho = \frac{\lambda}{s\mu}$&lt;/span&gt; (page 154 in the edition I have) whereas in the linked tutorial they use &lt;span class=&quot;math-container&quot;&gt;$\rho=\frac{\lambda}{\mu}.$&lt;/span&gt; Substitute the respective fractions for &lt;span class=&quot;math-container&quot;&gt;$\rho$&lt;/span&gt; and both versions of &lt;span class=&quot;math-container&quot;&gt;$L_q$&lt;/span&gt; come out the same.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-11-24T20:40:00.587" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11294" PostTypeId="1" AcceptedAnswerId="11295" CreationDate="2023-11-24T22:41:46.577" Score="2" ViewCount="134" Body="&lt;p&gt;Consider the following problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \begin{aligned}&#xA;    \min_{x,y}&#xA;    \quad &amp;amp; f(x,y), \\&#xA;    \textrm{s.t.} \quad &amp;amp; \exp(x) + \exp(y) = 1&#xA;    \end{aligned} \tag{1}&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f : (-\infty,0) \times (-\infty,0) \to \mathbb [0,\infty)$&lt;/span&gt; is convex and monotone increasing in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; (in the sense that, if &lt;span class=&quot;math-container&quot;&gt;$x_1 \leq x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1 \leq y_2$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$f(x_1,y_1) \leq f(x_2,y_2)$&lt;/span&gt;). Also, note that the left-hand side of the constraint is non-linear, convex, and strictly monotone increasing in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; (in the sense that, if &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;lt; x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_1 &amp;lt; y_2$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\exp(x_1) + \exp(y_1) &amp;lt; \exp(x_2) + \exp(y_2)$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;The problem in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; is &lt;em&gt;almost&lt;/em&gt; convex. The challenge here is that the constraint defines a non-linear curve in &lt;span class=&quot;math-container&quot;&gt;$\mathbb R^2$&lt;/span&gt;. My initial attempt at making this problem convex was to relax this constraint into &lt;span class=&quot;math-container&quot;&gt;$\exp(x) + \exp(y) \leq 1$&lt;/span&gt; and then show that this relaxation is tight (that is, solving &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; with the constraint &lt;span class=&quot;math-container&quot;&gt;$\exp(x) + \exp(y) \leq 1$&lt;/span&gt; yields the same solution as solving &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; with the constraint &lt;span class=&quot;math-container&quot;&gt;$\exp(x) + \exp(y) = 1$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;However, this approach does not work here, since, in order to decrease &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, we would need to decrease &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; (because &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is monotone increasing in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;), but this would in-turn decrease &lt;span class=&quot;math-container&quot;&gt;$\exp(x) + \exp(y)$&lt;/span&gt; since it is strictly monotone increasing. This means that, starting at the point &lt;span class=&quot;math-container&quot;&gt;$(x_0,y_0)$&lt;/span&gt; that is inside the convex feasible set defined by the constraint &lt;span class=&quot;math-container&quot;&gt;$\exp(x) + \exp(y) \leq 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\exp(x) + \exp(y) = 1$&lt;/span&gt; would not be satisfied no matter how much &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are decreased in order to decrease &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Ideally, there should be some invertible function &lt;span class=&quot;math-container&quot;&gt;$g : (0,\infty) \to \mathbb R$&lt;/span&gt; that I can apply to both sides of the equality constraint such that the constraint becomes &lt;span class=&quot;math-container&quot;&gt;$g(\exp(x) + \exp(y)) = g(1)$&lt;/span&gt; and so that &lt;span class=&quot;math-container&quot;&gt;$g(\exp(x) + \exp(y))$&lt;/span&gt; is convex and strictly monotone decreasing in &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt; on the left-hand side and &lt;span class=&quot;math-container&quot;&gt;$g(1) = 1$&lt;/span&gt; on the right-hand side. This would mean that the new constraint is &lt;span class=&quot;math-container&quot;&gt;$g(\exp(x) + \exp(y)) = 1$&lt;/span&gt; and so I can apply the relaxation as before to get &lt;span class=&quot;math-container&quot;&gt;$g(\exp(x) + \exp(y)) \leq 1$&lt;/span&gt;. In this case, the relaxation should be tight, since the left-hand side of the inequality increases as &lt;span class=&quot;math-container&quot;&gt;$(x,y)$&lt;/span&gt; is decreased, which also decreases the objective &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;. However, I'm not sure of the following:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Which function &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; to choose that fits this case (I've thought about &lt;span class=&quot;math-container&quot;&gt;$g(x) = \frac{1}{x}$&lt;/span&gt;, but this didn't work).&lt;/li&gt;&#xA;&lt;li&gt;Whether there is a better approach than mine to relax the constraint in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; so that &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; becomes a convex optimization problem.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2023-11-24T22:46:56.977" LastActivityDate="2023-11-27T19:14:16.487" Title="How can I relax the equality constraint in this problem?" Tags="|convex-optimization|relaxation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11295" PostTypeId="2" ParentId="11294" CreationDate="2023-11-25T01:16:10.547" Score="2" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$g(x)=f(x, \log(1 - \exp(x))).$&lt;/span&gt; Try plotting that to see if it is unimodal and, if so, whether the min is attained in the interior or only approached (infimum) as &lt;span class=&quot;math-container&quot;&gt;$x\rightarrow -\infty$&lt;/span&gt; or as &lt;span class=&quot;math-container&quot;&gt;$x\rightarrow 0$&lt;/span&gt;. If it is unimodal with an interior minimum, you have a one-dimensional problem, which can be solved by bisection search or golden section search, or maybe by gradient descent if &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is smooth.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-11-25T01:16:10.547" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11296" PostTypeId="2" ParentId="11289" CreationDate="2023-11-25T09:01:12.140" Score="2" Body="&lt;p&gt;I am not aware of if &lt;em&gt;informational callbacks&lt;/em&gt; can be invoked directly via &lt;code&gt;OPl-CPLEX&lt;/code&gt; the same as the low-level programming language. For more details, you can check &lt;a href=&quot;https://www.ibm.com/docs/en/icos/12.9.0?topic=callbacks-what-informational-can-return&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;What informational callbacks can return&lt;/em&gt;&lt;/a&gt; on the IBM host. As far as I know, to access some low-level information in OPL, you have two ways.&lt;/p&gt;&#xA;&lt;p&gt;1- Using the &lt;code&gt;Main&lt;/code&gt; block to call some functions like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;main {         &#xA;opl.postProcess();        &#xA;writeln(&amp;quot;Current solution : &amp;quot;, cplex1.getObjValue()); &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;2- linking OPL with a low-level language like Java to call some functions:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;IloOplModel opl = oplF.createOplModel(def, cplex);&#xA;opl.generate();&#xA;cplex.solve();&#xA;System.out.println(&amp;quot;OBJECTIVE: &amp;quot; + opl.getCplex().getObjValue());&#xA;opl.postProcess();&#xA;opl.printSolution(System.out);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For the first way &lt;a href=&quot;https://github.com/AlexFleischerParis/howtowithopl/blob/master/tsp.mod&quot; rel=&quot;nofollow noreferrer&quot;&gt;TSP by adding a lazy constraint&lt;/a&gt; and for the second &lt;code&gt;distMIP&lt;/code&gt; example on the &lt;code&gt;C:\Program Files\IBM\ILOG\CPLEX_Studio201\opl\examples\opl_interfaces\java&lt;/code&gt; might be helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-11-25T09:01:12.140" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11297" PostTypeId="2" ParentId="11283" CreationDate="2023-11-25T13:08:17.687" Score="3" Body="&lt;p&gt;I tried to test a simple example of what you proposed. I am setting an upper and lower bound &lt;span class=&quot;math-container&quot;&gt;$[0,5]$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$[0,4]$&lt;/span&gt; to the variables &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; respectively. By turning off the pre-solving, heuristics, and cuts the following results are shown:&lt;/p&gt;&#xA;&lt;p&gt;1- the constraints &lt;span class=&quot;math-container&quot;&gt;$(1)-(2)$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Presolving Time: 0.00&#xA;&#xA; time | node  | left  |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr|  dualbound   | primalbound  |  gap   | compl.&#xA;  0.0s|     1 |     0 |     3 |     - |   653k |   0 |   4 |   4 |   4 |   0 |  0 |   0 |   0 |-4.000000e+00 |      --      |    Inf | unknown&#xA;  0.0s|     1 |     2 |     3 |     - |   655k |   0 |   4 |   4 |   4 |   0 |  1 |   0 |   0 |-4.000000e+00 |      --      |    Inf | unknown&#xA;* 0.0s|     2 |     0 |     4 |   1.0 |    LP  |   1 |   4 |   4 |   4 |   0 |  1 |   0 |   0 |-4.000000e+00 |-4.000000e+00 |   0.00%|  81.66%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;2- the constraint &lt;span class=&quot;math-container&quot;&gt;$(2)-(3)$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Presolving Time: 0.00&#xA;&#xA; time | node  | left  |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr|  dualbound   | primalbound  |  gap   | compl.&#xA;* 0.0s|     1 |     0 |     1 |     - |    LP  |   0 |   4 |   1 |   1 |   0 |  0 |   0 |   0 |-4.000000e+00 |-4.000000e+00 |   0.00%| unknown&#xA;  0.0s|     1 |     0 |     1 |     - |   651k |   0 |   4 |   1 |   1 |   0 |  0 |   0 |   0 |-4.000000e+00 |-4.000000e+00 |   0.00%| unknown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;3- Also, it seems in the second case, only the third constraint is sufficient. (At least in my tiny example). By that, the results are the same as in case two:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Presolving Time: 0.00&#xA;&#xA; time | node  | left  |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr|  dualbound   | primalbound  |  gap   | compl.&#xA;* 0.0s|     1 |     0 |     1 |     - |    LP  |   0 |   4 |   1 |   1 |   0 |  0 |   0 |   0 |-4.000000e+00 |-4.000000e+00 |   0.00%| unknown&#xA;  0.0s|     1 |     0 |     1 |     - |   651k |   0 |   4 |   1 |   1 |   0 |  0 |   0 |   0 |-4.000000e+00 |-4.000000e+00 |   0.00%| unknown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;it seems in cases &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; the solver needs a smaller number of branching to prove optimality.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-11-25T13:08:17.687" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11298" PostTypeId="2" ParentId="11292" CreationDate="2023-11-25T19:16:10.760" Score="0" Body="&lt;p&gt;You can approach this problem using either a mixed-integer linear program (MILP) or a constraint programming (CP) model (using a CP solver that supports global constraints designed for scheduling problems).&lt;/p&gt;&#xA;&lt;p&gt;For the MILP approach, you can start with binary variable &lt;span class=&quot;math-container&quot;&gt;$x_{o,\ell,d}$&lt;/span&gt; for each combination of order, line and start date, where &lt;span class=&quot;math-container&quot;&gt;$x_{o,\ell,d} = 1$&lt;/span&gt; if order &lt;span class=&quot;math-container&quot;&gt;$o$&lt;/span&gt; is assigned to line &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; starting on date &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; and zero otherwise. You will also have a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_o$&lt;/span&gt; for each order, where &lt;span class=&quot;math-container&quot;&gt;$y_o=1$&lt;/span&gt; if order &lt;span class=&quot;math-container&quot;&gt;$o$&lt;/span&gt; is never scheduled. The constraint &lt;span class=&quot;math-container&quot;&gt;$$\sum_{\ell, d}x_{o,\ell,d} + y_o = 1\quad\forall o$$&lt;/span&gt; says that every order is either assigned to exactly one line at exactly one starting time or else is skipped.&lt;/p&gt;&#xA;&lt;p&gt;Your objective function will blend maximizing the skill level of the line (if any) to which each order is assigned and penalizing skipping the order. The due dates are enforced by setting &lt;span class=&quot;math-container&quot;&gt;$x_{o,\ell,d}=0$&lt;/span&gt; if starting order &lt;span class=&quot;math-container&quot;&gt;$o$&lt;/span&gt; on line &lt;span class=&quot;math-container&quot;&gt;$\ell$&lt;/span&gt; on date &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; would result in the due date being missed.&lt;/p&gt;&#xA;&lt;p&gt;That leaves you with the task of enforcing the capacity limits on the lines. There are multiple ways to do that. You can search this site for questions containing the terms &amp;quot;schedule&amp;quot; (or &amp;quot;scheduling&amp;quot;) and &amp;quot;overlap&amp;quot; to find possibilities.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-11-25T19:16:10.760" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11299" PostTypeId="2" ParentId="11292" CreationDate="2023-11-25T22:27:10.607" Score="0" Body="&lt;p&gt;Say you've a set of sewing lines &lt;span class=&quot;math-container&quot;&gt;$ L = \{l_1,l_2,...l_5 \}$&lt;/span&gt;.&lt;br /&gt;&#xA;At the beginning of the week you have a set of orders &lt;span class=&quot;math-container&quot;&gt;$O$&lt;/span&gt;, a set of styles &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; &amp;amp; for each style &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; a set of lines in descending order of the rank in skill for that style, for e.g. &lt;span class=&quot;math-container&quot;&gt;$Z^s = \{l_5,l_4,l_3,l_2,l_1 \} \ \ \forall s \in S$&lt;/span&gt;&lt;br /&gt;&#xA;Assuming each order has a unique style &lt;span class=&quot;math-container&quot;&gt;$O_s$&lt;/span&gt; &amp;amp; is assigned to a line &amp;amp; remains assigned till completion.&lt;br /&gt;&#xA;Also assuming orders are completed by a line sequentially i.e. if an order of 2 day duration arrives with sufficient number of days left &amp;amp; a line available it is assumed to be completed on time, else it will not be.&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_o x_{o,l} \le C_ly_l \ \ \forall l \in L$&lt;/span&gt;: C is line capacity with assignment binary var &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ y_l \le C_l - \sum_o x_{o,l} \le C_ly_l$&lt;/span&gt;: if some capacity is left then line &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; is open as per binary &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \le \sum_l x_{o,l} \le \sum_l y_l \quad \forall o \in O$&lt;/span&gt;: this indicates if an order is assigned to available line or not&lt;/p&gt;&#xA;&lt;p&gt;If you've duration &amp;amp; due date(or day) of each order defined &lt;span class=&quot;math-container&quot;&gt;$ T_o$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$D_o$&lt;/span&gt; then using &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; start day as another dimension for assignment var &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, you can use\&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\lambda_o \le (T_o+d)\sum_lx_{o,l,d} - D_o \le D_o\lambda_o \quad \forall d \ \forall o$&lt;/span&gt;: where binary &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; can serve as indicator of delayed order.&lt;/p&gt;&#xA;&lt;p&gt;Now to assign the available line with max skill for a style &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ j = Z_{l}^s$&lt;/span&gt;: get the index of line &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; from set &lt;span class=&quot;math-container&quot;&gt;$Z^s$&lt;/span&gt;: this isn't a constraint, just an assignment&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ y_{l} \le x_{o,l} + (j-1)(\sum_{k=1}^{j-1} x_{o,k}) $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ \sum_{k=1}^{j-1} x_{o,k} + x_{o,l} \le 1 \ \ \forall l \in Z^s \ \ \forall o$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$s = O_s$&lt;/span&gt;&lt;br /&gt;&#xA;In the above constraints you are iterating through each of the lines &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; from the ordered set &lt;span class=&quot;math-container&quot;&gt;$Z_s$&lt;/span&gt; &amp;amp; determining the first available line.&lt;br /&gt;&#xA;There are other ways to determine the max of the rank but this may be the simplest-already using an ordered set in terms of order of computation&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-11-26T19:26:15.917" LastActivityDate="2023-11-26T19:26:15.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11300" PostTypeId="2" ParentId="8037" CreationDate="2023-11-26T15:55:52.860" Score="0" Body="&lt;p&gt;The following links refers to application of ellipsoidal algorithms with some variations to NLPs:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0305054803000455&quot; rel=&quot;nofollow noreferrer&quot;&gt;Paper&lt;/a&gt; by Drs. Rugenstein. E &amp;amp; Kupferschimd.M: presents results showing convergence by ellipsoidal algorithm to convex NLPs&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.cs.ubc.ca/%7Enickhar/W13/Lecture4.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lecture notes from Univ of British Columbia&lt;/a&gt;: application of ellipsoids with separation Oracle method for nonlinear objective&lt;/p&gt;&#xA;&lt;p&gt;Also helpful lecture notes from &lt;a href=&quot;https://www2.isye.gatech.edu/%7Enemirovs/InteriorPointalgorithmsforConvexProgrammingNestrov&amp;amp;Nemirovski2001.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Georgia Tech&lt;/a&gt;: discussion on Dr. N.Karmakar's interior points methods.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-11-26T15:55:52.860" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11302" PostTypeId="2" ParentId="11294" CreationDate="2023-11-27T19:14:16.487" Score="0" Body="&lt;p&gt;In addition to @prubin's answer, another approach, which may be useful when &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are high-dimensional, is to solve the problem in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; as a &lt;em&gt;difference-of-convex&lt;/em&gt; (DC) program. This approach is described in the paper&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Lipp, T., Boyd, S. Variations and extension of the convex–concave procedure. Optim Eng 17, 263–287 (2016).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The main idea is to re-write the equality constraint &lt;span class=&quot;math-container&quot;&gt;$\exp(x) + \exp(y) = 1$&lt;/span&gt; as the following two inequality constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\left[\exp\left(x\right) + \exp\left(y\right)\right] - 1 &amp;amp;\leq 0 \\&#xA;1 - \left[\exp\left(x\right) + \exp\left(y\right)\right] &amp;amp;\leq 0&#xA;\end{align}&lt;/span&gt;&#xA;The left-hand side of both inequality constraints is a difference of convex functions. In addition, since the objective function is convex, then &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; qualifies as a DC program. There is also a &lt;a href=&quot;https://github.com/cvxgrp/dccp&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python package&lt;/a&gt; that can be used to solve DC programs.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastActivityDate="2023-11-27T19:14:16.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11303" PostTypeId="1" CreationDate="2023-11-27T19:16:53.873" Score="1" ViewCount="31" Body="&lt;p&gt;Suppose I’m interested in modeling risk/volatility using the Cauchy distribution and I’d like to optimize some allocations using linear programming.&lt;/p&gt;&#xA;&lt;p&gt;The Cauchy distribution is quadratic in nature but its derivative is linear.&lt;/p&gt;&#xA;&lt;p&gt;Is this applicable and how can it be applied?&lt;/p&gt;&#xA;&lt;p&gt;For example, the derivative tells us about the change in some variable. So if we find the derivatives of mean and variance, we might be able to account for changes in volatility (increasing/decreasing.)&lt;/p&gt;&#xA;&lt;p&gt;A similar approach might use a Taylor series expansion. The terms should be additive and linear.&lt;/p&gt;&#xA;&lt;p&gt;I hear that these approaches are called Moment Based Linearization.&lt;/p&gt;&#xA;&lt;p&gt;This is quite a general question, so acceptable answers would include anything related to linearization of probability distributions using derivatives for purposes of optimizing risk decisions.&lt;/p&gt;&#xA;&lt;p&gt;Edit: Cauchy was bad example; let's reference an arbitrary distribution such as normal.&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="10326" LastEditDate="2023-11-27T19:43:48.510" LastActivityDate="2023-11-27T19:43:48.510" Title="Moment based linearization of PDF for LP based optimization" Tags="|linear-programming|linearization|probability-distributions|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11304" PostTypeId="2" ParentId="11290" CreationDate="2023-11-28T02:41:12.427" Score="1" Body="&lt;p&gt;Ok, suppose production process &lt;span class=&quot;math-container&quot;&gt;$i1$&lt;/span&gt; goes to consumption process &lt;span class=&quot;math-container&quot;&gt;$ i2$&lt;/span&gt;. You can create a map of &lt;span class=&quot;math-container&quot;&gt;$ i1 -&amp;gt; i2$&lt;/span&gt; &amp;amp; define parameters &lt;span class=&quot;math-container&quot;&gt;$z_{i1,i2}$&lt;/span&gt;such that if &lt;span class=&quot;math-container&quot;&gt;$ i1 -&amp;gt; i2$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$ z_{i1,i2} = 1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise&lt;br /&gt;&#xA;Then the above balance constraints become&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ z_{i1,i2}x_{i1,t} + w_{p,t}+u_{o,t} = z_{i1,i2}x_{i2,t}prop_{i2p} + w_{p,t+1}+ u_{o,t+1}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Another way is to again create mapping of production/consumption processes and create a set (or tuple in python) of them like &lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ S= \{(i1,i2),(i3,i4),...\}$&lt;/span&gt;&lt;br /&gt;&#xA;Your constraints turn to&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ x_{i1,t} + w_{p,t}+u_{o,t} = x_{i2,t}prop_{i2p} + w_{p,t+1}+ u_{o,t+1} \quad \forall (i1,i2) \in S$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2023-11-28T02:41:12.427" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11305" PostTypeId="1" CreationDate="2023-11-28T03:03:25.537" Score="0" ViewCount="37" Body="&lt;p&gt;I'm trying to solve this problem, but I'm not sure if it is possible to check the optimality of this problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{K,L} \quad Tr(L^\top L)\qquad\\&#xA;\text{s.t.} \quad K^\top L = A^\top Q\\&#xA;\qquad \qquad \qquad Q + A^\top Q A - K^\top K \succeq 0\\&#xA;\quad \quad Q - L^\top L \succeq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where A,Q are real &lt;span class=&quot;math-container&quot;&gt;$n\times n$&lt;/span&gt; matrix, and Q is PD. Is it possible to generate optimal solution (K,L) as functions of (A,Q)? Additionally, is there conditions of solutions to guarantee the optimality of certain solution?&lt;/p&gt;&#xA;" OwnerUserId="12882" LastActivityDate="2023-11-28T03:03:25.537" Title="How to check optimality of conic optimization problem" Tags="|optimality-conditions|semidefinite-programming|conic-optimization|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11307" PostTypeId="1" CreationDate="2023-11-28T05:15:49.310" Score="1" ViewCount="53" Body="&lt;p&gt;I have a linear system that is of the form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$My = b \\&#xA;L \leq y \leq U$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;i.e. all of the &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; are potentially bounded, and there are various linear relationships between them.&lt;/p&gt;&#xA;&lt;p&gt;I want to find the tightest possible upper and lower bounds for each &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;, meaning that I am running &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; maximisation and &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; minimisation problems with the same constraints but changing the objective each time. Obviously, these values are often going to be related to each other.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way of making this process more efficient? My first thought is to keep track of the generated solutions and use them to update the lower and upper bounds, i.e. something like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in [1..n]&#xA;  Find min(y_i) for the system&#xA;  set L[i] = min(y_i)&#xA;  Find max(y_i) for the system&#xA;  set U[i] = max(y_i)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My other thought is that if &lt;span class=&quot;math-container&quot;&gt;$y[j] = L[j]$&lt;/span&gt; in any given solution, then since we know a solution exists in which it reaches its lower bound then we don't need to minimise, and similarly if &lt;span class=&quot;math-container&quot;&gt;$y[j] = U[j]$&lt;/span&gt;, so I can set some flags to avoid running any unnecessary LPs.&lt;/p&gt;&#xA;&lt;p&gt;Are these reasonable ideas? Is there another way of improving the efficiency?&lt;/p&gt;&#xA;&lt;p&gt;In case it's relevant, I am likely to be setting these problems up in either R or python, using &lt;code&gt;cvxr&lt;/code&gt;/&lt;code&gt;cvxpy&lt;/code&gt;, and either a free solver or Gurobi.&lt;/p&gt;&#xA;" OwnerUserId="12883" LastActivityDate="2023-11-28T21:48:28.333" Title="Making a batch of related linear problems more efficient" Tags="|linear-programming|algorithms|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11308" PostTypeId="1" AcceptedAnswerId="11310" CreationDate="2023-11-28T08:51:16.053" Score="2" ViewCount="100" Body="&lt;p&gt;In lecture notes by Nemirovsky and BenTal (2023), I found the following definition of a convex optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/i3g4A.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/i3g4A.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;MY QUESTION: why do we need both the functions &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; and the domain &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt;? Apparently they serve exactly the same purpose: they define the domain in which &lt;span class=&quot;math-container&quot;&gt;$f_0$&lt;/span&gt; should be minimized. Why not just define a convex program simply as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min_{x} \{f_0(x): x\in H\}?$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2023-11-28T16:51:26.237" Title="Basic question about definition of a convex optimization problem" Tags="|convex-optimization|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="11309" PostTypeId="2" ParentId="11290" CreationDate="2023-11-28T11:13:42.243" Score="0" Body="&lt;p&gt;I actually solved this problem recently on my own, though my approach was not based entirely on operations research, &lt;strong&gt;but relied a bit on the logic of running the whole program. So if you are looking for an academic solution to a similar problem, please prioritize @Sutanu Majumdar's solution.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;First of all, this model is part of one of my work projects, which is used to calculate a suitable production schedule for factory production. The project is divided into a discrete modeling part, a distribution modeling part, and a continuous time modeling part， with the focus mainly on the discrete and distribution models.&lt;/p&gt;&#xA;&lt;p&gt;In operation, the production plan is first calculated in the discrete model for discrete time (the constraints I presented in the question come from the discrete model), and you can see from this flow balance constraints that the results from the discrete model don't actually know where the process products are going to flow, but only how much of each process will be produced at each t， and that's where the allocation model comes in handy. The allocation model connects the inputs of each process in the discrete model results to the outputs of another process, creating a process-to-process supply relationship.&lt;/p&gt;&#xA;&lt;p&gt;Note that the allocation model determines whether a process i1 that produces p can supply a process i2 that consumes p based on the fact that i1 is produced earlier than i2 and that the product produced by i1 has the same product id as the product demanded by i2. So I was wondering if there could be a way to get i1 production into i2 whenever it is produced.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;If i1 produces, its product can only go into the process that consumes it, or into inventory, according to the flow balance constraint. While I can't know exactly which process supplied the amount of inventory at each t at which previous t, conversely, the amount of inventory can be thought of as being produced by any of the production processes that produced before t, as long as it produced!&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thus, when i1 produces, I just have to make sure that the amount of inventory must be greater than i2's current total production, all the way up to the point when i1 starts to consume it, so that in the view of the allocation model, i1 and i2 can establish a supply relationship, and in between, even if some other consuming process tries to take away the inventory, a new production process will be induced to produce it, based on my constraints as well as on the flow balance!&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gguFV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gguFV.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here are the constraints I added.&#xA;Constraint (2) guarantees that, for all supply relationships I want to control, the production quantity of a preceding production process will &amp;quot;always&amp;quot; be held in inventory if its successor does not start consuming it when it starts producing; and constraint (3) makes it possible for each pair of successors in the controlled supply relationship to have a sufficient supply of supply &amp;quot;from i1&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;By working with the three constraints, the results obtained from the discrete model can then be processed by the preprocessing function of the assignment model into the supply relationship I want&lt;/p&gt;&#xA;" OwnerUserId="12686" LastActivityDate="2023-11-28T11:13:42.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11310" PostTypeId="2" ParentId="11308" CreationDate="2023-11-28T16:51:26.237" Score="0" Body="&lt;p&gt;In practice, it is often the case that you observe constraints of the form &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$f_i(x) \leq 0$&lt;/span&gt;&amp;quot; rather than &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$x \in G$&lt;/span&gt;&amp;quot;. The former constraint defines a convex set if &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; is convex, since every sublevel set of a convex function is convex. It is then from this former constraint that you can define the convex set &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; in the latter constraint.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastActivityDate="2023-11-28T16:51:26.237" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11311" PostTypeId="1" AcceptedAnswerId="11312" CreationDate="2023-11-28T18:20:21.747" Score="2" ViewCount="80" Body="&lt;p&gt;It is well-known that, given a linear program: minimize &lt;span class=&quot;math-container&quot;&gt;$c^T x$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$A x\leq b$&lt;/span&gt;, it is possible to reduce the program to deciding feasibility of the following set of constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$Ax \leq b, A^T y = c,  y\leq 0, c^T x = b^T y$&lt;/span&gt;. This follows from the duality theorem of linear programming.&lt;/p&gt;&#xA;&lt;p&gt;QUESTION: what other classes of optimization problems have this &amp;quot;reduction&amp;quot; property? For example: given a general convex program, can we reduce any optimality problem to a problem of deciding feasbility?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2023-11-28T18:34:41.070" Title="Reducing optimality to feasibility in non-linear programs" Tags="|linear-programming|nonconvex-programming|duality|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11312" PostTypeId="2" ParentId="11311" CreationDate="2023-11-28T18:34:41.070" Score="3" Body="&lt;p&gt;You displayed the &lt;a href=&quot;https://en.wikipedia.org/wiki/Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions&quot; rel=&quot;nofollow noreferrer&quot;&gt;KKT conditions&lt;/a&gt; of the LP.&lt;/p&gt;&#xA;&lt;p&gt;For any convex optimization problem in which the objective and constraint functions &lt;span class=&quot;math-container&quot;&gt;$f_i(x)$&lt;/span&gt; for constraints &lt;span class=&quot;math-container&quot;&gt;$f_i(x) \le 0$&lt;/span&gt;  are continuously differentiable and satisfy a constraint qualification, KKT conditions are necessary and sufficient; and therefore a point &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is optimal for the original optimization problem if and only if it satisfies the KKT conditions. I.e., feasibility of KKT.&lt;/p&gt;&#xA;&lt;p&gt;This can be extended, under appropriate continuous differentiability, to convex conic optimization problems (such as a Linear Semidefinite Program (SDP)), for which conic &amp;quot;KKT&amp;quot; conditions apply given a constraint qualification, such as the Slater condition. This extension is presented in &lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/bv_cvxbook.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Section 5.9.2 Optimality conditions of &amp;quot;Convex Optimization&amp;quot;, by Boyd and Vandenberghe&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2023-11-28T18:34:41.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11313" PostTypeId="2" ParentId="11307" CreationDate="2023-11-28T21:48:28.333" Score="1" Body="&lt;p&gt;Your idea to tighten lower/upper bounds after solving for the min/max of the corresponding variable is fine. It may or may not provide improvements in speed. Taking a bound off the list of things to tighten any time a feasible solution hits that bound is also a good idea.&lt;/p&gt;&#xA;&lt;p&gt;One other thing you can do that might help speed things up is to assure that hot-starts are turned on for whatever solver you are using. The optimal basis to the last LP you solved will be a valid starting basis for the next LP.&lt;/p&gt;&#xA;&lt;p&gt;Another thought: since the basis that maximizes &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; is likely much different from the one that minimizes &lt;span class=&quot;math-container&quot;&gt;$y_i,$&lt;/span&gt; you might want to do all the mins, then all the maxes rather than go variable by variable. Combined with hot starts, it might (or might not) save you a few pivots.&lt;/p&gt;&#xA;&lt;p&gt;You might also want to see if using an interior point method helps, especially if the solver will hot start from the previous interior point.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-11-28T21:48:28.333" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11314" PostTypeId="1" CreationDate="2023-11-28T22:37:17.267" Score="1" ViewCount="156" Body="&lt;p&gt;I'm looking for some advice for an optimization problem regarding scheduling jobs in a datacenter.&lt;/p&gt;&#xA;&lt;p&gt;So I have a list of jobs and each job has a required time for finishing and a number of cores it has to run on, e.g. job 1 needs 10 seconds and has to run on 4 cores.&#xA;The task is now to schedule all jobs on &lt;code&gt;n&lt;/code&gt; servers where each server has 8 cores and I have to optimize it such that the time until all jobs are finished is minimal.&lt;/p&gt;&#xA;&lt;p&gt;I also have an energy component, meaning the fictional data center has some photovoltaic support and for each minute we get some sort of energy input, which we need to run our servers. The more cores a server is currently using, the more energy it needs.&#xA;If the generate more energy then required we can store the rest in a battery and if we need more than it produces and the battery is empty, we can buy more energy from the state.&lt;/p&gt;&#xA;&lt;p&gt;The objective is now to optimize on the one hand the required time for all jobs but also to minimize the amount of bought energy.&lt;/p&gt;&#xA;&lt;p&gt;I tried to solve it with Gurobi and a Linear Programming Model. It works fine for small inputs, but for larger settings it needs to long to find a solution (I cancelled after 3 hours).&lt;/p&gt;&#xA;&lt;p&gt;Some more concrete information and my approach:&#xA;The size is relatively small: 5 servers, each with 8 cores and 70 tasks one has to schedule. Each task is between 1000 and 10000 seconds and needs either 1, 2, or 4 cores.&lt;/p&gt;&#xA;&lt;p&gt;For the photovoltaic energy, we get a specified number of watts each minute which we can use for our servers / store in a battery.&lt;/p&gt;&#xA;&lt;p&gt;I tried to model the problem with a fundamental 3D binary matrix &lt;code&gt;x[t][j][c]&lt;/code&gt;. So for each job &lt;code&gt;j&lt;/code&gt; I store if it is scheduled at time &lt;code&gt;t&lt;/code&gt; on the core &lt;code&gt;c&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This is probably excessive to have a variable &lt;code&gt;t&lt;/code&gt; for each time slot, but I can't find another way to keep the time in account to add the solar energy.&lt;/p&gt;&#xA;&lt;p&gt;Now I formulated all my constraints based on the scheduling matrix.&lt;/p&gt;&#xA;&lt;p&gt;I set &lt;code&gt;t&lt;/code&gt; to one minute each until 12 hours, so I have 720 time slots to schedule. In total &lt;code&gt;x&lt;/code&gt; has about 2 million entries / variables. I at first thought this would be fine for Gurobi but it does not finish in reasonable time.&lt;/p&gt;&#xA;&lt;p&gt;Do you have any other idea how I can model this problem without storing every time slot explicitly?&lt;/p&gt;&#xA;&lt;p&gt;This is my current approach:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;x = {}&#xA;for t in range(1, NUM_TIMESTAMPS + 1):&#xA;    for j in range(NUM_TASKS):&#xA;        for c in range(TOTAL_NUM_OF_CORES):&#xA;            x[(t, j, c)] = model.addVar(vtype=GRB.BINARY, name=f&amp;quot;x_{t}_{j}_{c}&amp;quot;)&#xA;&#xA;delta_energy = []&#xA;battery_status = []&#xA;&#xA;tmp_battery = []&#xA;tmp_min_battery = []&#xA;&#xA;buy_state_energy = []&#xA;energy_bought = []&#xA;&#xA;for t in range(NUM_TIMESTAMPS + 1):&#xA;    delta_energy.append(model.addVar(lb=-GRB.INFINITY, ub=GRB.INFINITY, vtype=GRB.CONTINUOUS, name=f&amp;quot;d_{t}&amp;quot;))&#xA;    battery_status.append(model.addVar(lb=-GRB.INFINITY, ub=GRB.INFINITY, vtype=GRB.CONTINUOUS, name=f&amp;quot;b_{t}&amp;quot;))&#xA;&#xA;    tmp_battery.append(model.addVar(lb=-GRB.INFINITY, ub=GRB.INFINITY, vtype=GRB.CONTINUOUS, name=f&amp;quot;tmp_battery&amp;quot;))&#xA;    tmp_min_battery.append(model.addVar(lb=-GRB.INFINITY, ub=GRB.INFINITY, vtype=GRB.CONTINUOUS, name=f&amp;quot;tmp_min_battery&amp;quot;))&#xA;&#xA;    buy_state_energy.append(model.addVar(vtype=GRB.BINARY, name=f&amp;quot;s_{t}&amp;quot;))&#xA;    energy_bought.append(model.addVar(lb=-GRB.INFINITY, ub=GRB.INFINITY, vtype=GRB.CONTINUOUS))&#xA;&#xA;model.addConstr(battery_status[0] == MAX_BATTERY_LEVEL)&#xA;model.addConstr(energy_bought[0] == 0)&#xA;&#xA;# Assure that jobs are actually running.&#xA;for j in range(NUM_TASKS):&#xA;    model.addConstr(sum([x[(t, j, c)] for t in range(1, NUM_TIMESTAMPS + 1) for c in range(TOTAL_NUM_OF_CORES)]) == tasks[j].time * tasks[j].num_cores,&#xA;        name=&amp;quot;constraint 1&amp;quot;)&#xA;&#xA;&#xA;# Check that the number of required cores are being used.&#xA;for t in range(1, NUM_TIMESTAMPS + 1):&#xA;    for j in range(NUM_TASKS):&#xA;        num_active_cores = sum([x[(t, j, c_prime)] for c_prime in range(TOTAL_NUM_OF_CORES)])&#xA;&#xA;        for c in range(TOTAL_NUM_OF_CORES):&#xA;            model.addConstr(tasks[j].num_cores * x[(t, j, c)] == x[(t, j, c)] * num_active_cores,&#xA;                name=&amp;quot;constraint 3&amp;quot;)&#xA;&#xA;&#xA;# Only one job per core.&#xA;for t in range(1, NUM_TIMESTAMPS + 1):&#xA;    for c in range(TOTAL_NUM_OF_CORES):&#xA;        model.addConstr(sum([x[(t, j, c)] for j in range(NUM_TASKS)]) &amp;lt;= 1,&#xA;            name=&amp;quot;constraint 4&amp;quot;)&#xA;&#xA;&#xA;# Store the free energy not needed by the solar panels.&#xA;for t in range(1, NUM_TIMESTAMPS + 1):&#xA;    model.addConstr(delta_energy[t] == solar_data[t] - get_server_energy_consumption(sum(x[t, j, c] for j in range(NUM_TASKS) for c in range(TOTAL_NUM_OF_CORES))))&#xA;    model.addConstr(tmp_battery[t] == battery_status[t - 1] + delta_energy[t])&#xA;&#xA;    # Set battery status at time t to max(min(tmp_battery, MAX_BATTERY), MIN_BATTERY) to ensure it is the maximum &#xA;    # but is in the interval [MIN_BATTERY_LEVEL, MAX_BATTERY_LEVEL]&#xA;    model.addConstr(tmp_min_battery[t] == gp.min_(MAX_BATTERY_LEVEL, tmp_battery[t]), name=&amp;quot;Reducing battery level to MAX_BATTERY_LEVEL&amp;quot;)&#xA;    model.addConstr(battery_status[t] == gp.max_(tmp_min_battery[t], MIN_BATTERY_LEVEL), name= &amp;quot;Keeping battery level above MIN_BATTERY_LEVEL&amp;quot;)&#xA;&#xA;&#xA;# Buy state energy if battery tmp battery is negative, e.g.&#xA;# buy_state_energy = 1 if tmp_battery &amp;lt; 0 else 0&#xA;for t in range(1, NUM_TIMESTAMPS + 1):&#xA;    model.addConstr(LARGE_CONSTANT * buy_state_energy[t] &amp;gt;= -tmp_battery[t])&#xA;&#xA;    # Buy the needed energy if necessary &#xA;    model.addConstr(energy_bought[t] == buy_state_energy[t] * -1 * tmp_battery[t])&#xA;&#xA;# Constraint 7:&#xA;# Battery has a lower and upper limit.&#xA;for t in range(NUM_TIMESTAMPS + 1):&#xA;    model.addConstr(battery_status[t] &amp;gt;= MIN_BATTERY_LEVEL)&#xA;    model.addConstr(battery_status[t] &amp;lt;= MAX_BATTERY_LEVEL)&#xA;&#xA;&#xA;# Store when the last job finishes.&#xA;# max t s.t. x[t, j, c] == true for all j, c&#xA;last_job = model.addVar(vtype=GRB.INTEGER, name=&amp;quot;last_job&amp;quot;)&#xA;for t in range(1, NUM_TIMESTAMPS + 1):&#xA;    for j in range(NUM_TASKS):&#xA;        for c in range(TOTAL_NUM_OF_CORES):&#xA;            model.addConstr(last_job &amp;gt;= t * x[(t, j, c)])&#xA;&#xA;&#xA;model.setObjectiveN(sum(buy_state_energy), 0, 99)&#xA;model.setObjectiveN(sum(energy_bought), 2, 5)&#xA;model.setObjectiveN(last_job, 1, 4)&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12889" LastActivityDate="2023-12-31T00:05:50.653" Title="Job Scheduling with Energy Consumption using Linear Programming" Tags="|optimization|linear-programming|modeling|scheduling|constraint-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11315" PostTypeId="2" ParentId="11314" CreationDate="2023-11-29T04:09:47.027" Score="0" Body="&lt;p&gt;Using this &lt;a href=&quot;https://math.stackexchange.com/questions/2641208/job-shop-optimization-minimize-total-completion-time&quot;&gt;link&lt;/a&gt; (kind of constraint programming), lets define &lt;span class=&quot;math-container&quot;&gt;$ s_{j}$&lt;/span&gt; as start time for task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; over a domain of &lt;span class=&quot;math-container&quot;&gt;$ T =\{1,2,...720 \}$&lt;/span&gt; mins on core &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$d_j$&lt;/span&gt; being the processing time for a task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, binary &lt;span class=&quot;math-container&quot;&gt;$x_{j}^c = 1$&lt;/span&gt; if task &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is assigned to core &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Obj &lt;span class=&quot;math-container&quot;&gt;$\min_{s} \sum_{j} (s_{j} + d_j)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ s_{j} + d_j \le 720$&lt;/span&gt;&lt;br /&gt;&#xA;You can avoid above constraint if you define &lt;span class=&quot;math-container&quot;&gt;$s_j$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$\{1,2,...T \}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$T=720 -$&lt;/span&gt; shortest task duration.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_c x_{j}^c = 1 \quad \forall j $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If each core &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; has only 1 task at a time then you'd need a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{t}^c$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; over &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; &amp;amp; constraints; in other words you'd need &lt;span class=&quot;math-container&quot;&gt;$720\times c$&lt;/span&gt; binaries.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ s_j + M(x_{j}^c - 1) \le ty_{t}^c \quad \forall c, t$&lt;/span&gt;: where &lt;span class=&quot;math-container&quot;&gt;$M = \max \{T,J,C \}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$J, C$&lt;/span&gt; being number of tasks &amp;amp; cores.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ d_j(y_{t}^c +x_{j}^c - 1) \le \sum_{k=t+1}^{t+d_j-1} y_{k}^c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also for power bought, you can straight away use continuous var (p) with&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$-tmp_t \le p_t$&lt;/span&gt; : Make power bought positive. Since power bought is to be minimized solver will make &lt;span class=&quot;math-container&quot;&gt;$ 0 \le \sum_t p_t$&lt;/span&gt; reduced to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; wherever it can.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-11-30T23:26:51.137" LastActivityDate="2023-11-30T23:26:51.137" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11316" PostTypeId="1" CreationDate="2023-11-29T04:17:51.677" Score="1" ViewCount="98" Body="&lt;p&gt;Suppose &lt;span class=&quot;math-container&quot;&gt;$\\{X_i\\}$&lt;/span&gt; are binary decision variables and &lt;span class=&quot;math-container&quot;&gt;$\\{A_j\\}$&lt;/span&gt; are Skellam random variables with &lt;span class=&quot;math-container&quot;&gt;$(\mu_1, \mu_2) = (\sum_i b_{i} X_i, c_j)$&lt;/span&gt;. Here, &lt;span class=&quot;math-container&quot;&gt;$b_i, c_j \in \mathbb{R}^{\geq 0}$&lt;/span&gt; are constants. The goal is to maximize the function &lt;span class=&quot;math-container&quot;&gt;$f(X_1, X_2, \dots, X_n) = \sum_j P(A_j &amp;gt; 0)$&lt;/span&gt; subject to certain linear constraints in the &lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt;.&#xA;What are some known computational methods for solving this problem?&lt;/p&gt;&#xA;&lt;p&gt;One possible approach is as follows: let &lt;span class=&quot;math-container&quot;&gt;$F_j(x)$&lt;/span&gt; be the CDF of a Skellam variable with &lt;span class=&quot;math-container&quot;&gt;$(\mu_1, \mu_2) = (x, c_j)$&lt;/span&gt;.&#xA;For each &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, we can approximate &lt;span class=&quot;math-container&quot;&gt;$F_j$&lt;/span&gt; by a piecewise linear function.&#xA;Then the original problem can be formulated as an integer linear programming problem.&#xA;However, this approach doesn't seem especially robust to me; for instance, I'm not sure how to determine the number of sample points to use for the linear approximation (given an error tolerance) nor how to space the sample points.&lt;/p&gt;&#xA;" OwnerUserId="12890" LastEditorUserId="36" LastEditDate="2023-11-29T13:42:22.480" LastActivityDate="2023-12-29T21:01:25.247" Title="Maximizing sum of probabilities with variable distributions" Tags="|optimization|integer-programming|nonlinear-programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11317" PostTypeId="1" AcceptedAnswerId="11319" CreationDate="2023-11-29T05:13:39.427" Score="0" ViewCount="60" Body="&lt;p&gt;Hi I have been reading about Dantzig-Wolfe decomposition from Bazaraa (Linear Programming and Network Flow).&lt;/p&gt;&#xA;&lt;p&gt;The master problem shown below. Why is it that &lt;span class=&quot;math-container&quot;&gt;$(w, \alpha) = c_B B^{-1}$&lt;/span&gt;  where &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; are the dual variables for equation 7.1 and 7.2 respectively?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wBz3C.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wBz3C.png&quot; alt=&quot;Master problem for Dantzig-Wolfe Decomposition&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9972" LastActivityDate="2023-11-29T08:29:12.740" Title="dantzig-wolfe decomposition" Tags="|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11318" PostTypeId="1" AcceptedAnswerId="11328" CreationDate="2023-11-29T06:38:28.183" Score="1" ViewCount="81" Body="&lt;p&gt;For a constraint as Ax &amp;lt;= b, the dual shows the change in the objective function if the RHS increases by 1 unit. Now my question is that how we can determine how the optimal values will change by 1 unit increase in the RHS. Is there any relation with other duals and/or reduced costs to determine it without actually resolving the LP?&lt;/p&gt;&#xA;" OwnerUserId="1094" LastActivityDate="2023-11-30T03:52:27.183" Title="The dual values and change in the variables values" Tags="|simplex|reduced-costs|dual|lp|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11319" PostTypeId="2" ParentId="11317" CreationDate="2023-11-29T08:29:12.740" Score="0" Body="&lt;p&gt;Because &lt;span class=&quot;math-container&quot;&gt;$c_BB^{-1}$&lt;/span&gt; represents the primal objective value and by strong duality theorem, if the solution is optimal then primal objective value must be equal to dual objective value.&lt;/p&gt;&#xA;" OwnerUserId="12370" LastActivityDate="2023-11-29T08:29:12.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11321" PostTypeId="2" ParentId="11318" CreationDate="2023-11-29T11:06:39.850" Score="0" Body="&lt;p&gt;I am unsure if I understand your last sentence as well. B.T.W, To improve the objective function, it is necessary to relax the binding/active constraints. By relaxing, I mean is by having a larger feasible space.&lt;/p&gt;&#xA;&lt;p&gt;Now, the constraints with the sign of (&lt;span class=&quot;math-container&quot;&gt;$\leq$&lt;/span&gt;) would be relaxed if the right-hand side is increased. Equivalently, the constraints with the sign of (&lt;span class=&quot;math-container&quot;&gt;$\geq$&lt;/span&gt;) would be relaxed if the right-hand side is decreased.&lt;/p&gt;&#xA;&lt;p&gt;From the algebraic point of view, dual is equivalent to &lt;span class=&quot;math-container&quot;&gt;$\pi = C_{b}B^{-1}$&lt;/span&gt; and its relation with the associated reduced cost of the variables would also be as &lt;span class=&quot;math-container&quot;&gt;$RC = C_{j} - \pi^{T}A_{j}$&lt;/span&gt;. These however can be achieved in each iteration of the simplex algorithm.&lt;/p&gt;&#xA;&lt;p&gt;As a simple example, suppose a transportation problem with an objective function equal to &lt;span class=&quot;math-container&quot;&gt;$153.675$&lt;/span&gt;. The demand satisfaction constraint has usually been written as a form of (&lt;span class=&quot;math-container&quot;&gt;$\geq$&lt;/span&gt;). Suppose, its corresponding dual is &lt;span class=&quot;math-container&quot;&gt;$0.225$&lt;/span&gt;. And it means that increasing the RHS value by one unit can increase the objective function to &lt;span class=&quot;math-container&quot;&gt;$153.9$&lt;/span&gt;. It obviously shows that by increasing the RHS value the value of the objective function would be worse.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-11-29T11:06:39.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11322" PostTypeId="1" CreationDate="2023-11-29T12:32:14.020" Score="0" ViewCount="62" Body="&lt;p&gt;In Python 3.10, is it possible to use docplex along with mpmath (&lt;a href=&quot;https://mpmath.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://mpmath.org/&lt;/a&gt;), e.g., to compute expressions in constraints and objectives with arbitrary precision?&lt;/p&gt;&#xA;" OwnerUserId="12899" LastActivityDate="2023-11-29T12:32:14.020" Title="Using docplex with mpmath" Tags="|mixed-integer-programming|linear-programming|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11324" PostTypeId="2" ParentId="11316" CreationDate="2023-11-29T19:15:09.543" Score="0" Body="&lt;p&gt;One possible way to do what you want is through the use of chance constraints, which are used to constrain probabilities to be greater than or less than some value. I'm not familiar with a Skellam random variable, but my hunch is that using chance constraints on this distribution will result in a non-convex optimization problem, which a solver such as Gurobi could solve using spatial branching. Below is a simple re-formulation that could use chance constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\underset{x, t}{\text{max}} \hspace{0.1in} t \\&#xA;\text{subject to} \\&#xA;t \leq \sum_{i} P(A_{i} &amp;gt; 0)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We want to make the new variable &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; as large as possible, but &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; must be smaller than the joint probability that you are interested in, which is obviously bounded above by 1. With chance constraints, you can reformulate the RHS of the constraint.&lt;/p&gt;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="12792" LastActivityDate="2023-11-29T19:15:09.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11325" PostTypeId="2" ParentId="11276" CreationDate="2023-11-29T19:23:22.893" Score="0" Body="&lt;p&gt;Without knowing much about the problem, there are several approaches (listed in increasing difficulty of implementation):&lt;/p&gt;&#xA;&lt;p&gt;1). Warm-start the model at a known feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;2). You could try modeling the problem with complete recourse and extremely large penalties for violating the constraints.&lt;/p&gt;&#xA;&lt;p&gt;3). You can study your problem to determine additional first-stage cuts that will eliminate candidate first-stage solutions that turn out to be infeasible.&lt;/p&gt;&#xA;&lt;p&gt;Are your first stage decision variables binary? If so, there are different forms for the cuts that will work better. What about second-stage? How many scenarios are you using? More information would help.&lt;/p&gt;&#xA;" OwnerUserId="12792" LastActivityDate="2023-11-29T19:23:22.893" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11326" PostTypeId="2" ParentId="11318" CreationDate="2023-11-29T19:30:46.383" Score="0" Body="&lt;p&gt;The allowable increase tells you the how much you can change the objective function coefficient without changing the optimal basis of the Simplex. If your objective function coefficients do not change at all, the optimal basis won't change. Then, what happens if you increase the RHS of a constraint that is binding by unit? How much would you increase the basic variable in the constraint by?&lt;/p&gt;&#xA;" OwnerUserId="12792" LastActivityDate="2023-11-29T19:30:46.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11327" PostTypeId="1" CreationDate="2023-11-29T22:26:59.990" Score="1" ViewCount="63" Body="&lt;p&gt;I have a relatively hard time understanding the Busacker &amp;amp; Gowen algorithm. I could not&#xA;find any resources on it, contrary to Ford-Fulkerson method that is described in Comen's &amp;quot;Introduction to algorithms&amp;quot; book.&lt;/p&gt;&#xA;&lt;p&gt;The only resource about it that I found was &lt;a href=&quot;https://www.youtube.com/watch?v=8ZXwIgE-ne8&quot; rel=&quot;nofollow noreferrer&quot;&gt;this YouTube video&lt;/a&gt; that is in French but at least it shows an example of using the method.&lt;/p&gt;&#xA;&lt;p&gt;Are there any other resources on the method like the one I mentioned?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Is Busacker &amp;amp; Gowen algorithm the same as Successive Shortest Path Algorithm?&lt;/p&gt;&#xA;" OwnerUserId="12722" LastEditorUserId="12722" LastEditDate="2023-12-13T12:13:19.507" LastActivityDate="2023-12-13T12:13:19.507" Title="Resources about Busacker &amp; Gowen algorithm" Tags="|optimization|algorithms|network-flow|literature-research|online-resources|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11328" PostTypeId="2" ParentId="11318" CreationDate="2023-11-30T03:52:27.183" Score="1" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\bar{A}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{x}$&lt;/span&gt; be &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; augmented by slack variables, so that the constraints become &lt;span class=&quot;math-container&quot;&gt;$\bar{A} \bar{x} = b.$&lt;/span&gt; The LP solution partitions &lt;span class=&quot;math-container&quot;&gt;$\bar{A} = [B N]$&lt;/span&gt; (after permuting columns if necessary) where &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; is the basis matrix and the optimal solution is partitioned into &lt;span class=&quot;math-container&quot;&gt;$\bar{x}_B = B^{-1} b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{x}_N = 0.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the increase &lt;span class=&quot;math-container&quot;&gt;$\Delta b$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; is small enough that the same basis remains optimal, then the new optimal solution is &lt;span class=&quot;math-container&quot;&gt;$\bar{x}_B = B^{-1} (b + \Delta b)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{x}_N = 0,$&lt;/span&gt; which can be computed without any pivoting if you have access to the basis matrix.&lt;/p&gt;&#xA;&lt;p&gt;If the change is big enough to result in a different basis becoming optimal, then pivoting is required. You can solve a new LP with the changed &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; vector or you can invoke the dual simplex algorithm starting from the optimal basis to the original problem.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-11-30T03:52:27.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11329" PostTypeId="1" AcceptedAnswerId="11333" CreationDate="2023-11-30T11:41:34.250" Score="-1" ViewCount="67" Body="&lt;p&gt;How can I formulate in mixed linear programming (a set of constraints) the following issue.&#xA;I have an objective function &lt;span class=&quot;math-container&quot;&gt;$\underset{x}{\max} g(x)$&lt;/span&gt;.&#xA;I need to convert a continuous linear function &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; real) such that when &lt;span class=&quot;math-container&quot;&gt;$f(x) &amp;lt; 0$&lt;/span&gt; it passes 0 to the objective function and when &lt;span class=&quot;math-container&quot;&gt;$f(x) \ge 0$&lt;/span&gt; it passes &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have the indicator constraints formulated as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;y \ge \frac{1}{M}f(x) \tag{1}&#xA;\end{equation}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;y \le 1 + \frac{1}{M}f(x) \tag{2}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; sufficiently big, but I am missing the link from &lt;span class=&quot;math-container&quot;&gt;$f(x$&lt;/span&gt;) to &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; such that when&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;f(x) &amp;lt; 0 \quad \text{then} \quad g(x) = 0&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;f(x) \ge 0 \quad \text{then} \quad g(x) = f(x)&#xA;\end{equation}&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$g(x) \ge 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Any guidance on this?&lt;/p&gt;&#xA;" OwnerUserId="12906" LastEditorUserId="491" LastEditDate="2023-11-30T15:37:20.860" LastActivityDate="2023-12-01T00:16:37.343" Title="MIP formulation for a lower semi-continuous function" Tags="|optimization|mixed-integer-programming|constraint|big-m|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11331" PostTypeId="1" AcceptedAnswerId="11334" CreationDate="2023-11-30T12:57:25.200" Score="1" ViewCount="71" Body="&lt;p&gt;To initialize column generation, I obtain a feasible set of columns via the following Phase 1 algorithm. The restricted master problem for this algorithm is formulated as follows.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;min \: \: F = \{w^0 +&#xA;\sum_{i,k,e} w^1_{ike} +&#xA;\sum_{k,e}w^2_{ke}\}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subjected to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;(1-\lambda) \times \sum_{s}\chi_s +w^0 = 1&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{s} (Y_{sike} \times \chi_s) +w^1_{ike} \geq a_{ike} \hspace{1cm} \forall i,k,e&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\sum_{s} (Z_{ske} \times \chi_s) +w^2_{ke} \geq b_{ke} \hspace{1cm} \forall k,e&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\chi_s, w^0, w^1_{ike}, w^2_{ke} \geq 0&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The restricted master problem is solved iteratively. I terminate the Phase 1 algorithm when the objective function of the restricted master problem reaches zero (slack variables are zero, indicating no constraint violations). Instead, I'd like to solve the dual of this model, which I have formulated as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;max \: \: F' = \{\phi^0 +&#xA;\sum_{i,k,e} \phi^1_{ike} +&#xA;\sum_{k,e} \phi^2_{ke}\}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subjected to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\phi^0 \leq 1&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\phi^1_{ike} \leq 1 \hspace{1cm} \forall i,k,e&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\phi^2_{ke} \leq 1 \hspace{1cm} \forall k,e&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\phi^0 \times (1-\lambda) +&#xA;\sum_{i,k,e} Y_{sike} \times \phi^1_{ike} +&#xA;\sum_{k,e} Z_{ske} \times \phi^2_{ke} \leq 0 \hspace{1cm} \forall s&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\phi^0 \in R&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\phi^1_{ike}, \phi^2_{ke} \geq 0&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If I solve the dual instead of the primal restricted master problem, what should be the termination criterion for the Phase 1 algorithm? Also, please let me know if the dual is not formulated correctly.&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="5598" LastEditDate="2023-11-30T16:48:26.220" LastActivityDate="2023-11-30T17:10:35.040" Title="Termination criterion for the Phase 1 algorithm in column generation" Tags="|column-generation|dual|phase-1|termination|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11333" PostTypeId="2" ParentId="11329" CreationDate="2023-11-30T15:44:31.357" Score="2" Body="&lt;p&gt;You want to maximize &lt;span class=&quot;math-container&quot;&gt;$\max(f(x),0)$&lt;/span&gt;.  Assume &lt;span class=&quot;math-container&quot;&gt;$L \le f(x) \le U$&lt;/span&gt; for constants &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt;.  Maximize &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;0 \le g(x) \le U y \\&#xA;0 \le g(x) - f(x) \le (0-L)(1-y) \\&#xA;y \in \{0,1\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-12-01T00:16:37.343" LastActivityDate="2023-12-01T00:16:37.343" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11334" PostTypeId="2" ParentId="11331" CreationDate="2023-11-30T17:10:35.040" Score="3" Body="&lt;p&gt;The termination criterion is the same because the primal objective value is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; if and only if the dual objective value is &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Your dual formulation is almost correct, but you are missing &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; in the objective.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-11-30T17:10:35.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11335" PostTypeId="1" CreationDate="2023-12-01T11:26:39.347" Score="1" ViewCount="109" Body="&lt;p&gt;I'm giving a seminar to PhD students in pure math, and one of the things I'd like to do is show that more applied optimization can also make its way into pure Mathematics. As for classical problems, I'll introduce knapsack and cutting stock (since I'll talk about column generation and DW decomposition).&lt;/p&gt;&#xA;&lt;p&gt;They're working in Dynamical Systems, Algebraic Geometry, Symplectic Geometry, and Category Theory. Examples in these fields would be perfect, but of course, any examples will be greatly appreciated.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: If knapsack and cutting-stock don't offer good applications, then other problems, that are easy to introduce (like min vertex cover), would also work.&lt;/p&gt;&#xA;" OwnerUserId="5352" LastEditorUserId="5352" LastEditDate="2023-12-02T17:22:04.003" LastActivityDate="2023-12-02T17:22:04.003" Title="Applications of Knapsack and Cutting Stock in Pure Math" Tags="|optimization|integer-programming|reference-request|knapsack|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11336" PostTypeId="2" ParentId="4224" CreationDate="2023-12-02T01:56:32.537" Score="1" Body="&lt;p&gt;There are serveral strategies.&#xA;I recomend Lagrangian and Surrogate relaxation.&lt;/p&gt;&#xA;&lt;p&gt;Look for James Davis video &amp;quot;2.6 lagrangian relaxation&amp;quot;. I guess it would help.&lt;/p&gt;&#xA;" OwnerUserId="12918" LastActivityDate="2023-12-02T01:56:32.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11337" PostTypeId="1" CreationDate="2023-12-03T19:35:49.393" Score="0" ViewCount="72" Body="&lt;p&gt;I would like to solve the following problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\text{ minimize }  &amp;amp;&amp;amp; t&#xA;\\&#xA;\text{ subject to } &amp;amp;&amp;amp; f_i(x) - t \leq 0 \text{ for all $i\in 1,\ldots,n$,}&#xA;\\&#xA;&amp;amp;&amp;amp; 0\leq x_j \leq 1 \text{ for all $j\in 1,\ldots,m$.}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The functions &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; are convex, so the entire problem is convex. I would like to solve it using interior point methods. From what I know, the first thing I need to do for this is to find an efficiently-computable self-concordant barrier for the domain:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$G := \{(x,t): f_i(x) - t \leq 0 \text{ for all } i\in 1,\ldots m, \text{ and } 0\leq x_j \leq 1  \text{ for all } j\in 1,\ldots,m$&lt;/span&gt; }.&lt;/p&gt;&#xA;&lt;p&gt;I know that, for linear functions &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt;, I can use the logarithmic barrier. But here the functions &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; are convex.&lt;/p&gt;&#xA;&lt;p&gt;Does there always exist a self-concordant barrier for &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; (for any convex functions &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt;)? If so, how can I find it? If no, what other conditions on &lt;span class=&quot;math-container&quot;&gt;$f_i$&lt;/span&gt; are needed?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="2576" LastEditDate="2023-12-04T11:35:51.463" LastActivityDate="2023-12-04T11:35:51.463" Title="Solving a max-min convex optimization problem with interior-point methods" Tags="|convex-optimization|interior-point-method|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11338" PostTypeId="1" AcceptedAnswerId="11340" CreationDate="2023-12-04T13:01:08.173" Score="4" ViewCount="320" Body="&lt;p&gt;I have an optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\text{ minimize } \sum_{i=1}^n H(x_i) &#xA;\\&#xA;\text{ subject to } Ax \geq b, x\geq 0, x\in \mathbb{Z}^n&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$H(n)$&lt;/span&gt; is the &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-th &lt;a href=&quot;https://en.wikipedia.org/wiki/Harmonic_number&quot; rel=&quot;nofollow noreferrer&quot;&gt;Harmonic number&lt;/a&gt;. How can I model this harmonic number in an ILP solver in an efficient way?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="500" LastEditDate="2023-12-04T16:55:06.153" LastActivityDate="2023-12-04T16:55:06.153" Title="Optimization problem with the Harmonic number" Tags="|modeling|integer-programming|linearization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11340" PostTypeId="2" ParentId="11338" CreationDate="2023-12-04T14:57:13.953" Score="4" Body="&lt;p&gt;Assume &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; has upper bound &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt;. Introduce binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; to indicate whether &lt;span class=&quot;math-container&quot;&gt;$x_i=j$&lt;/span&gt;, and minimize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^n \sum_{j=0}^{u_i} H(j)y_{ij}$$&lt;/span&gt;&#xA;subject to additional constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_j y_{ij} &amp;amp;= 1 &amp;amp;&amp;amp;\text{for all $i$} \\&#xA;\sum_j j y_{ij} &amp;amp;= x_i &amp;amp;&amp;amp;\text{for all $i$}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-12-04T14:57:13.953" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11341" PostTypeId="1" CreationDate="2023-12-05T02:28:20.727" Score="-1" ViewCount="153" Body="&lt;p&gt;This is an exercise from Wolsey that I can't solve. Show how to go from Equivalence (1) to (2) and from Equivalence (2) to (3):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ &#xA;\begin{align}&#xA;X &amp;amp;= \{ x \in \{0, 1\}^4~\mid~97x_1 + 32x_2 + 25x_3 + 20x_4 \le 139 \} \tag{1} \\&#xA;  &amp;amp;\equiv \{ x \in \{0, 1\}^4~\mid~2x_1 + x_2 + x_3 + x_4 \le 3 \} \tag{2} \\&#xA;  &amp;amp;\equiv \{ x \in \{0, 1\}^4~\mid~x_1+ x_2 + x_3 \le 2, \ x_1 + x_2 + x_4 \le 2, \ x_1 + x_3 + x_4 \le 2 \} \tag{3}&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="12926" LastEditorUserId="500" LastEditDate="2023-12-06T00:32:06.067" LastActivityDate="2023-12-06T00:32:06.067" Title="Need help with integer programming exercise" Tags="|optimization|integer-programming|binary-variable|knapsack|polyhedra|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11342" PostTypeId="1" AcceptedAnswerId="11347" CreationDate="2023-12-05T11:12:31.520" Score="1" ViewCount="96" Body="&lt;p&gt;I have a matrix which contains compatibility scores between objects. I have 56 objects, thus, the matrix dimensions are 56*56.&lt;/p&gt;&#xA;&lt;p&gt;I need to group said objects in groups of 8 to 10 elements.&lt;/p&gt;&#xA;&lt;p&gt;I have tried to use linear optimization to do that using a sample problem in Python:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;prob = LpProblem(&amp;quot;Grouping_Optimization&amp;quot;, LpMaximize)&#xA;# thing i in group j&#xA;x = {(i, j): LpVariable(cat=&amp;quot;Binary&amp;quot;, name=f&amp;quot;x_{i}_{j}&amp;quot;) for i in result_sum.index for j in result_sum.index}&#xA;&#xA;# group j exists&#xA;y = {j: LpVariable(cat=&amp;quot;Binary&amp;quot;, name=f&amp;quot;y_{j}&amp;quot;) for j in result_sum.index}&#xA;&#xA;# objectice function&#xA;obj_terms = []#auxiliary&#xA;for i in result_sum.index:#thing&#xA;    for j in result_sum.index:#thing&#xA;        for k in result_sum.index:#group&#xA;            if i != j:#don't compare the same thing&#xA;                z = LpVariable(cat=&amp;quot;Binary&amp;quot;, name=f&amp;quot;z_{i}_{j}_{k}&amp;quot;)&#xA;                prob += z &amp;lt;= x[i, k]  # z is only 1 if i is in group k&#xA;                prob += z &amp;lt;= x[j, k]  # z is only 1 if j is in group k&#xA;                obj_terms.append(score_matrix.loc[i, j] * z)# z is only 1 if i and j are in the same group&#xA;&#xA;prob += lpSum(obj_terms)&#xA;&#xA;&#xA;# each thing is in exactly one group&#xA;for i in result_sum.index:&#xA;    prob += lpSum(x[i, j] for j in result_sum.index) == 1&#xA;&#xA;# each group has at least 2 things and at most 3 things&#xA;for j in result_sum.index:&#xA;    prob += lpSum(x[i, j] for i in result_sum.index) &amp;gt;= 2 * y[j]&#xA;    prob += lpSum(x[i, j] for i in result_sum.index) &amp;lt;= 3 * y[j]&#xA;&#xA;# Solve the problem&#xA;prob.solve()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This code seems to work with sample data. However, with real data (56*56) it is taking too long. I need to use a metaheuristic algorithm instead to solve the problem. However, I have never used them.&lt;/p&gt;&#xA;&lt;p&gt;Can someone please give me a clue on how to do this?&lt;/p&gt;&#xA;&lt;p&gt;Edit: As an example, let's consider this matrix as the compatibility scores&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    A   B   C   D   E   F   G   H   I   J   K&#xA;A   0   1   5   3   7   8   9   5   3   4   5&#xA;B   1   0   2   8   9   0   2   7   5   3   9&#xA;C   5   2   0   2   8   7   3   5   9   9   8&#xA;D   3   8   2   0   5   1   4   7   9   5   1   &#xA;E   7   9   7   5   0   2   7   6   4   6   9&#xA;F   8   0   7   1   2   0   1   9   5   6   3&#xA;G   9   2   3   4   7   1   0   1   2   5   6&#xA;H   5   7   5   7   6   9   1   0   2   8   6&#xA;I   3   5   9   9   4   5   2   2   0   5   9   &#xA;J   4   3   9   5   6   6   5   8   5   0   2&#xA;K   5   9   8   1   9   3   6   6   9   2   0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then, if I were looking for grouping in groups of three to five elements, one group could be  ABC, whith a score of 1+5+2=8, this is the sum of the compatibilities between A and B, A and C and B and C.&lt;/p&gt;&#xA;" OwnerUserId="12929" LastEditorUserId="12929" LastEditDate="2023-12-05T13:11:32.410" LastActivityDate="2023-12-06T08:45:21.770" Title="Need help writing a metaheuristic problem" Tags="|optimization|metaheuristics|genetic-algorithm|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="11343" PostTypeId="2" ParentId="11341" CreationDate="2023-12-05T13:03:44.987" Score="1" Body="&lt;p&gt;Given the system you presented&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X = \{ x \in \{0, 1\}^4 : 97 x_1 + 32 x_2 + 25 x_3 + 20 x_4 \leqslant 139 \}$&lt;/span&gt; (1)&lt;/p&gt;&#xA;&lt;p&gt;We have that, if &lt;span class=&quot;math-container&quot;&gt;$x_1 = 1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_2 + x_3 + x_4 \leqslant 1$&lt;/span&gt;, since any solution where &lt;span class=&quot;math-container&quot;&gt;$x_2 + x_3 + x_4 &amp;gt; 1$&lt;/span&gt; leads to infeasibility.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$97 + 32 + 25 &amp;gt; 139$&lt;/span&gt;, for &lt;span class=&quot;math-container&quot;&gt;$x_1 = x_2 = x_3 = 1$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$97 + 32 + 20 &amp;gt; 139$&lt;/span&gt;, for &lt;span class=&quot;math-container&quot;&gt;$x_1 = x_2 = x_4 = 1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Therefore, suffices to say that &lt;span class=&quot;math-container&quot;&gt;$2 x_1 + x_2 + x_3 + x_4 \leqslant 3$&lt;/span&gt; (2), i.e., if &lt;span class=&quot;math-container&quot;&gt;$x_1 = 1$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$x_2 + x_3 + x_4 \leqslant 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The same above depicted reasoning can be made without the coefficient &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;, ending up with (3):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1 + x_2 + x_3 \leqslant 2$&lt;/span&gt;, since &lt;span class=&quot;math-container&quot;&gt;$97 + 32 + 25 &amp;gt; 139$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1 + x_2 + x_4 \leqslant 2$&lt;/span&gt;, since &lt;span class=&quot;math-container&quot;&gt;$97 + 32 + 20 &amp;gt; 139$&lt;/span&gt;; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1 + x_3 + x_4 \leqslant 2$&lt;/span&gt;, since &lt;span class=&quot;math-container&quot;&gt;$97 + 25 + 20 &amp;gt; 139$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I hope it helps, let me know of any doubt.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="2862" LastEditDate="2023-12-05T17:43:11.537" LastActivityDate="2023-12-05T17:43:11.537" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11344" PostTypeId="1" CreationDate="2023-12-05T13:14:51.900" Score="0" ViewCount="107" Body="&lt;p&gt;Let us assume I have an optimization problem as follows:&lt;br /&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/CGV8h.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CGV8h.gif&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first feasible region is an ellipsoid, meaning that a and b belong to a known ellipsoid. The second feasible region is polyhedral (a set of linear equation). If I merge the two maximization, then the objective function will become bilinear.&lt;/p&gt;&#xA;&lt;p&gt;How can I solve this problem at one shot?&lt;/p&gt;&#xA;&lt;p&gt;I mean is there a way to convert this special bilinear problem to a (mixed-integer) convex problem?&lt;/p&gt;&#xA;" OwnerUserId="12930" LastEditorUserId="491" LastEditDate="2024-01-25T13:16:18.297" LastActivityDate="2024-01-25T13:16:18.297" Title="Bilinear programming" Tags="|convex-optimization|quadratic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11345" PostTypeId="2" ParentId="11341" CreationDate="2023-12-05T13:19:02.050" Score="2" Body="&lt;p&gt;As the problem only contains four variables let's define &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; as the feasible solution space of the problem. Then &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; contains &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt; feasible solutions: &lt;span class=&quot;math-container&quot;&gt;$\{(1,0,0,0), (0,1,0,0), (0,0,1,0), (0,0,0,1), (1,1,0,0), (1,1,1,0), (1,0,1,0), (1,0,0,1), (0,1,1,0), (0,1,0,1), (0,0,1,1), (0,1,1,1) \}.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, we can drive the second inequality by multiplying the first constraint in an appropriate multiplier, e.g. &lt;span class=&quot;math-container&quot;&gt;$1/50$&lt;/span&gt;, and rounding the coefficients. Then, we can derive the third inequality as follows:&lt;/p&gt;&#xA;&lt;p&gt;A set &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is called a knapsack cover if &lt;span class=&quot;math-container&quot;&gt;$C = \sum_{j \in C} a_j - b$&lt;/span&gt; is positive. Each knapsack cover &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; defines the cover inequality:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j \in C} x_{j} \leq | \ C  \ | - 1 $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, by investigating which combination of the variables can violate the original constraint &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, the violated items would be of the form &lt;span class=&quot;math-container&quot;&gt;$ \sum_{j} a_{j} x_{j} \geq b$&lt;/span&gt;, we can derive &lt;span class=&quot;math-container&quot;&gt;$x_1 + x_2 + x_3 \leqslant 2$&lt;/span&gt; that means &lt;span class=&quot;math-container&quot;&gt;$ 97 + 32 + 25 \gt 139 $&lt;/span&gt;. To derive the remaining in the &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; the procedure is the same. If you check the derived inequalities neither of them violates the original solution space, but violates the excess values.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-12-05T13:19:02.050" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11346" PostTypeId="2" ParentId="11344" CreationDate="2023-12-05T13:50:24.897" Score="1" Body="&lt;p&gt;You can &amp;quot;merge&amp;quot; to a single maximization over all variables.&lt;/p&gt;&#xA;&lt;p&gt;Then use Gurobi (which can solve bilinear problems such as this to global optimality, given enough time and memory) or a general global nonlinear optimization solver, such as BARON. No need to reinvent the wheel.&lt;/p&gt;&#xA;&lt;p&gt;It's a very small problem, so I don't think it should be difficult for the solvers to handle. –&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: In response to the edited version of the question, which asks about converting the optimization problem to a mixed-integer convex optimization problem:&#xA;The answer is no, unless you perform binary expansions of two of the variables as an approximation to the original problem, and then use Big M to linearize the product terms. In my opinion that would be a terrible thing to do. Ut is much better to solve it as a bilinear problem with 4 variables - more accurate and likely faster.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-12-06T03:09:35.623" LastActivityDate="2023-12-06T03:09:35.623" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11347" PostTypeId="2" ParentId="11342" CreationDate="2023-12-05T19:47:33.603" Score="2" Body="&lt;p&gt;I would first try the mixed-integer linear programming approach, but if you want a metaheuristic, one possibility is a random key genetic algorithm. Given your minimum and maximum cluster sizes, you need either six or seven clusters. Moreover, there are only four possible size patterns: seven clusters of eight each; two clusters of eight and four clusters of ten; one cluster of eight, two clusters of nine and three clusters of ten; or four clusters of nine and two clusters of ten.&lt;/p&gt;&#xA;&lt;p&gt;The chromosome will be a permutation of the indices 1 through 56 plus a single integer with domain &lt;span class=&quot;math-container&quot;&gt;$\lbrace 1, 2, 3, 4\rbrace.$&lt;/span&gt; To decode the chromosome into a solution, you permute your 56 objects into the order specified by the permutation part of the chromosome. You then use the integer gene to select the group size pattern and create the groups from the permuted objects, assuming that smaller groups come first. The fitness function (to be maximized) is your objective function.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-12-05T19:47:33.603" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11350" PostTypeId="1" CreationDate="2023-12-06T06:59:52.097" Score="3" ViewCount="546" Body="&lt;p&gt;I am trying to solve Nurse scheduling problem using SCIP. The SCIP solve it in pre-solving stage itself and gives optimal solution. I don't want that to happen., because I want to use the branching data for further processing.&#xA;The problem is to maximize the shift requests by nurses given some constraints (can provide more data if needed). Please find some more details from SCIP summary below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Original problem: 13920 variables (all binary), 20400 constraints.&#xA;Presolving: 4011 deleted vars, 16778 deleted constraints, 182 added constraints, various changes.&#xA;Presolved problem: 9909 variables (all binary), 3804 constraints.&#xA;3622 constraints of type &amp;lt;setppc&amp;gt;.&#xA;182 constraints of type &amp;lt;orbitope&amp;gt;. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And after this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;SCIP Status        : problem is solved [optimal solution found]&#xA;Solving Time (sec) : 4.08&#xA;Solving Nodes      : 1&#xA;Primal Bound       : +3.00000000000000e+02 (3 solutions)&#xA;Dual Bound         : +3.00000000000000e+02&#xA;Gap                : 0.00 %&#xA;&#xA;B&amp;amp;B:&#xA;B&amp;amp;B Tree           :&#xA;  number of runs   :          1&#xA;  nodes            :          1 (0 internal, 1 leaves)&#xA;  feasible leaves  :          0&#xA;  infeas. leaves   :          0&#xA;  objective leaves :          1&#xA;  nodes (total)    :          1 (0 internal, 1 leaves)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Although I don't want the pre-solver to solve the problem and I want it to solve through branching. Any help is appreciated. Thank you&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I already tried turning off the pre-solvers but it did not work.&lt;/p&gt;&#xA;" OwnerUserId="12935" LastEditorUserId="12935" LastEditDate="2023-12-06T10:37:24.947" LastActivityDate="2023-12-06T10:37:24.947" Title="SCIP do not branch" Tags="|combinatorial-optimization|scip|presolve-preprocessing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11351" PostTypeId="2" ParentId="11350" CreationDate="2023-12-06T08:10:44.610" Score="5" Body="&lt;p&gt;In order to turn off the SCIP pre-solving, cuts, and heuristics you can set them by the following comments in the console run:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set presolving emphasis off&#xA;set heuristics emphasis off&#xA;set separation emphasis off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vhu4C.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vhu4C.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;These options can be implemented on the SCIP APIs by almost the same notation.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-12-06T08:10:44.610" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11352" PostTypeId="2" ParentId="11342" CreationDate="2023-12-06T08:38:33.290" Score="0" Body="&lt;p&gt;You can generate all &lt;span class=&quot;math-container&quot;&gt;$\binom{n}{8}+\binom{n}{9}+\binom{n}{10} \in \mathcal{O}(n^4)$&lt;/span&gt; subsets of &lt;span class=&quot;math-container&quot;&gt;$8,9,10$&lt;/span&gt; elements. Let &lt;span class=&quot;math-container&quot;&gt;$\Omega$&lt;/span&gt; denote the set of the indexes of these precomputed subsets. For each subset &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt;, you can also precompute its total value &lt;span class=&quot;math-container&quot;&gt;$C_i$&lt;/span&gt; by summing over each pairwise values. Then define a binary variable &lt;span class=&quot;math-container&quot;&gt;$\lambda_i$&lt;/span&gt; that takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if subset &lt;span class=&quot;math-container&quot;&gt;$S_i$&lt;/span&gt; is selected. Then solve the following:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \sum_{i\in \Omega}C_i \lambda_i&#xA;$$&lt;/span&gt;&#xA;subject to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each element &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; must be in one selected group exactly:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i\in \Omega, v\in S_i} \lambda_i = 1 \quad \forall v&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You can find a very similar problem solved with PuLP &lt;a href=&quot;https://coin-or.github.io/pulp/CaseStudies/a_set_partitioning_problem.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-12-06T08:45:21.770" LastActivityDate="2023-12-06T08:45:21.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11353" PostTypeId="1" CreationDate="2023-12-06T13:07:40.303" Score="0" ViewCount="84" Body="&lt;p&gt;Now I have a linear programming model, I have tried to formulate this model with or-tools, and then solve it with the GLOP but failed.&lt;/p&gt;&#xA;&lt;p&gt;After reaching the 15-minute time limit, the status of GLOP is reported as NOT_SOLVED and the log output is listed below. I would like to ask, during the GLOP solving process, if the Primal Objective and Dual Objective are already very close to each other, can the results be outputted by setting appropriate parameters?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Dual optimization phase, iteration # 7025615, objective = 8.254744303120898E+11 [check]&#xA;Dual optimization phase, iteration # 7025616, objective = 8.254744303120903E+11 [check]&#xA;Dual optimization phase, iteration # 7025617, objective = 8.254744303120898E+11 [check]&#xA;Current status: DUAL_FEASIBLE&#xA;Primal infeasibility (bounds) = 1.54972e-06&#xA;Primal residual |A.x - b| = 5.36442e-07&#xA;Dual infeasibility (reduced costs) = 0&#xA;Dual residual |c_B - y.B| = 7.10543e-15&#xA;&#xA;Final unscaled solution:&#xA;Primal objective (before moving primal/dual values) = 8.254744303120898E+11&#xA;Dual objective (before moving primal/dual values) = 8.254744303120900E+11&#xA;Primal objective (after moving primal/dual values) = 8.254744303120898E+11&#xA;Max. rhs perturbation = 2.38419e-06&#xA;Max. cost perturbation = 6.82121e-13&#xA;Max. primal infeasibility = 6.66827e-07&#xA;Max. dual infeasibility = 0&#xA;Objective error &amp;lt;= 825478&#xA;status: DUAL_FEASIBLE&#xA;objective: 8.25474e+11&#xA;iterations: 7025832&#xA;time: 900.001&#xA;deterministic_time: 1307.61&#xA;&#xA;completed solve, status = NOT_SOLVED&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12326" LastEditorUserId="981" LastEditDate="2024-01-15T14:08:55.743" LastActivityDate="2024-01-15T14:08:55.743" Title="How to set the parameters for GLOP for a DUAL_FEASIBLE case" Tags="|linear-programming|or-tools|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11354" PostTypeId="2" ParentId="11353" CreationDate="2023-12-06T13:24:38.100" Score="1" Body="&lt;p&gt;crossposted from &lt;a href=&quot;https://groups.google.com/g/or-tools-discuss/c/hBZU_l_BqnI&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://groups.google.com/g/or-tools-discuss/c/hBZU_l_BqnI&lt;/a&gt; and answered there.&lt;/p&gt;&#xA;" OwnerUserId="981" LastActivityDate="2023-12-06T13:24:38.100" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11356" PostTypeId="1" CreationDate="2023-12-06T13:58:53.180" Score="3" ViewCount="39" Body="&lt;p&gt;I'm curious about the current prevalence of Markov Decision Processes (MDPs) in medical decision-making. I've seen several research papers on this topic but was unable to find evidence of real-world implementations. Could you share examples of the widespread use of MDPs in the medical field (preferably with references)?&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="491" LastEditDate="2023-12-06T19:33:23.430" LastActivityDate="2023-12-06T19:33:23.430" Title="How Widespread Is the Application of MDPs in Medical Decision Making?" Tags="|reference-request|markov-decision-process|implementation|practical-or|medical-application|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11357" PostTypeId="1" CreationDate="2023-12-06T14:54:28.727" Score="1" ViewCount="75" Body="&lt;p&gt;I am solving a CVRPTWPD using Google ORTools. Here, objective is to minimize the travelled distance and not time.&lt;/p&gt;&#xA;&lt;p&gt;I have start locations for each vehicle but arbitrary end locations are possible. I have added dummy node for arbitrary end locations.&lt;/p&gt;&#xA;&lt;p&gt;Also, there are more than one type of vehicle and time matrix depends on the speed of type of vehicle.&#xA;I need to implement soft time window constraints for all orders.&#xA;Based on various sources on internet and my understanding of ortools, I'm implementing it as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;travel_time_callback_indices = []&#xA;&#xA;for _, row in driver_df.iterrows():&#xA;    speed = row[&amp;quot;speed_meter_per_sec&amp;quot;]&#xA;    vehicle_travel_time_callback = partial(travel_time_callback, speed_in_mps=speed)&#xA;    travel_time_callback_index = routing.RegisterTransitCallback(vehicle_travel_time_callback)&#xA;    travel_time_callback_indices.append(travel_time_callback_index)&#xA;&#xA;&#xA;dimension_name = 'Time'&#xA;routing.AddDimensionWithVehicleTransitAndCapacity(&#xA;    travel_time_callback_indices,&#xA;    7200,  # Max Slack&#xA;    [7200]*driver_df.shape[0],  # vehicle maximum travel time&#xA;    False,  # don't start cumul to zero&#xA;    dimension_name)&#xA;&#xA;time_dimension = routing.GetDimensionOrDie(dimension_name)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Till here, it works fine. As soon as I add TW constraints as follows, kernel dies.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;penalty = 1 # $1/second&#xA;# Add time window constraints for each location except depot.&#xA;for location_idx, time_window in enumerate(data['time_windows']):&#xA;    index = manager.NodeToIndex(location_idx)&#xA;    time_dimension.CumulVar(index).SetMin(time_window[0])&#xA;    time_dimension.SetCumulVarSoftUpperBound(index, time_window[1], penalty)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Please note that all the vehicle start locations and dummy node have been given the max possible time window.&lt;/p&gt;&#xA;&lt;p&gt;I need to understand why is kernel dying? Is there any better way to implement soft time window constraints?&lt;/p&gt;&#xA;" OwnerUserId="9609" LastActivityDate="2023-12-06T19:33:22.737" Title="Implementing soft time window constraints with time_matrix dependent on vehicle types" Tags="|vehicle-routing|or-tools|cvrptw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11360" PostTypeId="2" ParentId="11357" CreationDate="2023-12-06T19:26:05.473" Score="1" Body="&lt;p&gt;I was able to fix this. I checked on following points:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;time callback function must return an integer and not float.&lt;/li&gt;&#xA;&lt;li&gt;You can not add time window constraints on depots.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;penalty = 1 # $1/second&#xA;# Add time window constraints for each location except depot.&#xA;for location_idx, time_window in enumerate(data['time_windows']):&#xA;&#xA;    if location_idx in data[&amp;quot;depots&amp;quot;] + dummy_depot:&#xA;        continue    &#xA;&#xA;    index = manager.NodeToIndex(location_idx)&#xA;    time_dimension.CumulVar(index).SetMin(time_window[0])&#xA;    time_dimension.SetCumulVarSoftUpperBound(index, time_window[1], penalty)&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9609" LastEditorUserId="9609" LastEditDate="2023-12-06T19:33:22.737" LastActivityDate="2023-12-06T19:33:22.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11361" PostTypeId="1" CreationDate="2023-12-07T10:33:13.403" Score="1" ViewCount="80" Body="&lt;p&gt;I wanted to know whether the Automatic Benders Decomposition from C-plex allows us to solve the sub-problems in parallel over multiple cores. From what I know, one can set the number of threads in Cplex but one cannot assign specific sub-problems to specific cores.&lt;/p&gt;&#xA;" OwnerUserId="12855" LastEditorUserId="491" LastEditDate="2023-12-07T13:44:58.290" LastActivityDate="2023-12-12T16:02:54.683" Title="Benders Decomposition using Cplex" Tags="|cplex|benders-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11362" PostTypeId="2" ParentId="8625" CreationDate="2023-12-07T12:47:44.300" Score="0" Body="&lt;p&gt;To do this, I believe you need to create an event handler that gets called whenever a new feasible node is found. There are many kinds of events, see &lt;a href=&quot;https://scipopt.org/doc/html/type__event_8h_source.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for all the SCIP_EVENTTYPE's. For the feasible node, you would want &lt;code&gt;SCIP_EVENTTYPE_NODEFEASIBLE&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I don't know how to create custom events (like the every 10 nodes you mention), but you can always keep a tracker of the last time the parameter was changed and only execute the event handler whenever you want.&lt;/p&gt;&#xA;&lt;p&gt;When executing this event, you then just change the parameters. Here is a sample code that should hopefully help you out:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyscipopt import Model, SCIP_EVENTTYPE, Eventhdlr&#xA;&#xA;class changeParam(Eventhdlr):&#xA;&#xA;    def __init__(self, model):&#xA;        self.model = model&#xA;&#xA;    def eventinit(self):&#xA;        self.model.catchEvent(SCIP_EVENTTYPE.NODEFEASIBLE, self) # the LP/pseudo solution of the node was feasible&#xA;&#xA;    def eventexec(self, event):&#xA;        self.model.setParams(....)&#xA;&#xA;model = Model()&#xA;model.includeEventhdlr(changeParams, &amp;quot;Parameter changing Eventhdlr&amp;quot;, &amp;quot;Event Handler for changing parameters every feasible node.&amp;quot;) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Let me know if this helps!&lt;/p&gt;&#xA;" OwnerUserId="5352" LastEditorUserId="5352" LastEditDate="2023-12-07T12:55:00.663" LastActivityDate="2023-12-07T12:55:00.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11363" PostTypeId="1" CreationDate="2023-12-07T14:23:45.670" Score="0" ViewCount="164" Body="&lt;p&gt;I have a small model to optimize in Gurobi. The problem is that it takes a lot of time in presolve without removing any rows or variables. I tried to disable PreSolve parameter and reduce the number of Threads but the issue remains the same. Knowing that I working on solving CVRP. For 16 customers and 8 vehicles, it works very well (58 s) but when I switch to 19 customers with 2 vehicles it takes more than 1000 s without returning a solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt;&lt;br /&gt;&#xA;I changed these parameters:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    mdl.Params.Threads = 12&#xA;    mdl.Params.TimeLimit = 300&#xA;    mdl.Params.MIPGap = 0.05&#xA;    mdl.Params.MIPFocus=1&#xA;    mdl.Params.Presolve=2&#xA;    mdl.Params.PreSparsify=2&#xA;    mdl.Params.NoRelHeurTime=100&#xA;    mdl.Params.Heuristics=0.5&#xA;    mdl.Params.Method=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here is the log:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;CPU model: Intel(R) Xeon(R) Platinum 8276 CPU @ 2.20GHz, instruction set [SSE2|AVX|AVX2|AVX512]&#xA;Thread count: 112 physical cores, 112 logical processors, using up to 12 threads&#xA;&#xA;Optimize a model with 524310 rows, 684 columns and 40110732 nonzeros&#xA;Model fingerprint: 0xf11e235e&#xA;Variable types: 0 continuous, 684 integer (684 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [1e+00, 3e+01]&#xA;  Objective range  [3e-01, 5e+00]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [1e+00, 2e+02]&#xA;Found heuristic solution: objective 43.3769973&#xA;Presolve removed 0 rows and 0 columns (presolve time = 6s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 13s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 17s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 20s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 27s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 30s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 35s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 43s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 45s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 51s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 55s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 60s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 65s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 70s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 75s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 80s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 85s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 90s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 95s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 100s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 105s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 110s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 115s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 120s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 125s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 130s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 135s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 140s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 145s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 150s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 155s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 160s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 165s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 170s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 175s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 180s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 185s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 190s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 195s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 200s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 205s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 211s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 216s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 220s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 226s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 230s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 235s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 243s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 245s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 250s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 255s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 260s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 265s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 270s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 275s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 280s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 289s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 290s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 295s) ...&#xA;Presolve added 0 rows and 522620 columns&#xA;Presolve time: 297.21s&#xA;&#xA;Explored 0 nodes (0 simplex iterations) in 300.47 seconds (168.69 work units)&#xA;Thread count was 1 (of 112 available processors)&#xA;&#xA;Solution count 1: 43.377 &#xA;&#xA;Time limit reached&#xA;Best objective 4.337699734045e+01, best bound -, gap -&#xA;No optimal solution found&#xA;Gurobi Optimizer version 10.0.3 build v10.0.3rc0 (linux64)&#xA;&#xA;CPU model: Intel(R) Xeon(R) Platinum 8276 CPU @ 2.20GHz, instruction set [SSE2|AVX|AVX2|AVX512]&#xA;Thread count: 112 physical cores, 112 logical processors, using up to 12 threads&#xA;&#xA;Optimize a model with 524310 rows, 684 columns and 40110732 nonzeros&#xA;Model fingerprint: 0xf11e235e&#xA;Variable types: 0 continuous, 684 integer (684 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [1e+00, 3e+01]&#xA;  Objective range  [3e-01, 5e+00]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [1e+00, 2e+02]&#xA;&#xA;&#xA;Presolve removed 0 rows and 0 columns (presolve time = 6s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 13s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 17s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 20s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 27s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 30s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 35s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 43s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 45s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 51s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 55s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 60s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 65s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 70s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 75s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 80s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 85s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 90s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 95s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 100s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 105s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 110s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 115s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 120s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 125s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 130s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 135s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 140s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 145s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 150s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 155s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 160s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 165s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 170s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 175s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 180s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 185s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 190s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 196s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 201s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 206s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 210s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 215s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 220s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 225s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 230s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 235s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 242s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 245s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 250s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 255s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 260s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 265s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 270s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 275s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 289s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 290s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 295s) ...&#xA;Presolve removed 0 rows and 0 columns (presolve time = 300s) ...&#xA;Presolve added 0 rows and 522620 columns&#xA;Presolve time: 300.22s&#xA;&#xA;Explored 0 nodes (0 simplex iterations) in 300.68 seconds (168.33 work units)&#xA;Thread count was 1 (of 112 available processors)&#xA;&#xA;Solution count 1: 43.377 &#xA;&#xA;Time limit reached&#xA;Best objective 4.337699734045e+01, best bound -, gap -&#xA;No optimal solution found&#xA;run time average CVRP:  300.798810005188&#xA;IIS computation: initial model status unknown, solving to determine model status&#xA;Found heuristic solution: objective 0.0000000&#xA;&#xA;Explored 0 nodes (0 simplex iterations) in 3.13 seconds (0.78 work units)&#xA;Thread count was 1 (of 112 available processors)&#xA;&#xA;Solution count 1: 0 &#xA;&#xA;Optimal solution found (tolerance 5.00e-02)&#xA;Best objective 0.000000000000e+00, best bound 0.000000000000e+00, gap 0.0000%&#xA;IIS runtime: 3.24 seconds (0.78 work units)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10962" LastEditorUserId="36" LastEditDate="2023-12-08T15:02:30.383" LastActivityDate="2023-12-09T10:16:21.013" Title="Gurobi spend more time in presolve in small model without removing anything" Tags="|gurobi|vehicle-routing|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="11364" PostTypeId="1" AcceptedAnswerId="11365" CreationDate="2023-12-07T14:47:01.440" Score="2" ViewCount="53" Body="&lt;p&gt;I've been dealing with Benders Decomposition and I've been wondering, if I have an unbounded solution of the dual subproblem, is it possible to find out which constraint from the original problem is violated in that case?&lt;/p&gt;&#xA;&lt;p&gt;Obviously with the unboundedness we are able to generate the extreme rays of the dual subproblem, but from those can we make any inferences to which original constraints these correspond?&lt;/p&gt;&#xA;" OwnerUserId="12130" LastActivityDate="2023-12-07T19:16:05.177" Title="Is there a way to find out which original constraints are violated when a feasibility cut is generated in benders?" Tags="|mixed-integer-programming|duality|benders-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11365" PostTypeId="2" ParentId="11364" CreationDate="2023-12-07T19:16:05.177" Score="1" Body="&lt;p&gt;I assume that by &amp;quot;violated&amp;quot; you mean &amp;quot;cannot be satisfied&amp;quot;. It is not typically the case that a single constraint will be infeasible; rather, it is usually a subset of constraints that are collectively infeasible.&lt;/p&gt;&#xA;&lt;p&gt;The components of an extreme ray of the dual correspond to primal constraints in the same way that components of the dual correspond to primal constraints. The subset of primal constraints matched with nonzero components of the dual ray is collectively infeasible (but not guaranteed to be the only infeasible subset, nor even necessarily the smallest one).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-12-07T19:16:05.177" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11366" PostTypeId="2" ParentId="9041" CreationDate="2023-12-08T07:55:10.873" Score="-1" Body="&lt;p&gt;Take a look at &lt;a href=&quot;https://timefold.ai/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Timefold Solver&lt;/a&gt;, our open-source solver backed by our open core company.&lt;/p&gt;&#xA;&lt;p&gt;Timefold Solver is a fast and scalable solver that supports various metaheuristics, incremental score calculation and real-time planning.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2023-12-08T07:55:10.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11367" PostTypeId="1" AcceptedAnswerId="11370" CreationDate="2023-12-08T10:06:35.090" Score="2" ViewCount="131" Body="&lt;p&gt;I encountered a minimization problem involving the following function:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f(\mathbf{x})=\|\mathbf{x}\|_q^p$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, &lt;span class=&quot;math-container&quot;&gt;$q&amp;gt;1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0&amp;lt;p&amp;lt;1$&lt;/span&gt;. Naturally, each entry of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{x}$&lt;/span&gt; is greater than &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would like to determine the convexity (or concavity) of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, but I'm uncertain about how to do it. In my previous experience, I could demonstrate convexity by checking the definition or using rules of convexity, such as the convexity of the sum of two functions or certain composition rules. Or, I could prove the positive semi-definiteness of the Hessian. However, I haven't been able to apply any of these techniques to analyze &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12949" LastActivityDate="2023-12-08T21:03:53.033" Title="Convexity of p power of the q norm (0&lt;p&lt;1, q&gt;1)" Tags="|convex-optimization|convexity|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11368" PostTypeId="2" ParentId="11363" CreationDate="2023-12-08T10:12:36.243" Score="3" Body="&lt;p&gt;It is a general misconception that presolve reduces the size of the problem. While this is a typical side effect, the actual goal of the presolving step is to find an equivalent model that is more amendable to the techniques available to the solver.&lt;/p&gt;&#xA;&lt;p&gt;For example, this includes reformulating indicator constraints to big-M to strengthen the dual bound of the LP relaxation. Indicator constraints would otherwise just be ignored by the LP solver.&lt;/p&gt;&#xA;&lt;p&gt;Your model instance is a pretty extreme example, and you could try playing with the &lt;a href=&quot;https://www.gurobi.com/documentation/current/refman/presolve.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Presolve&lt;/a&gt; and other presolving parameters to see whether you can save some time there. It appears as if Gurobi spends time on (expensive) presolving routines that do not lead to a better or smaller model.&lt;/p&gt;&#xA;" OwnerUserId="141" LastEditorUserId="141" LastEditDate="2023-12-08T17:09:15.183" LastActivityDate="2023-12-08T17:09:15.183" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11370" PostTypeId="2" ParentId="11367" CreationDate="2023-12-08T12:16:12.710" Score="3" Body="&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$q &amp;gt; 1, 0 &amp;lt;p &amp;lt; 1$&lt;/span&gt;, as per the question:&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is a nonnegative scalar, &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf{x})=\|\mathbf{x}\|_q^p$&lt;/span&gt; is concave, not convex.&lt;/p&gt;&#xA;&lt;p&gt;For non-scalar &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f(\mathbf{x})=\|\mathbf{x}\|_q^p$&lt;/span&gt; is neither convex nor concave. For instance, for p = 0.5, q = 2, in 2D at &lt;span class=&quot;math-container&quot;&gt;$x = [1, 1]^T$&lt;/span&gt;, the Hessian of &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; has eigenvalues of 0.297 and -0.149; so the Hessian is indefinite there, and therefore &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is neither convex nor concave.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-12-08T21:03:53.033" LastActivityDate="2023-12-08T21:03:53.033" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11371" PostTypeId="1" CreationDate="2023-12-08T18:01:25.147" Score="1" ViewCount="72" Body="&lt;p&gt;I would like to package (using &lt;code&gt;pyinstaller&lt;/code&gt;) my optimizer program that uses &lt;code&gt;Pyomo&lt;/code&gt; and SCIP. I keep getting &lt;code&gt;pyomo.environ&lt;/code&gt; import errors and have been experimenting with hidden imports.&lt;/p&gt;&#xA;&lt;p&gt;I saw &lt;a href=&quot;https://groups.google.com/g/pyomo-forum/c/n1Hn8q7Qwmw&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; and was surprised, but I tried it anyway. It seems like it should go in a file. I tried it and as expected doesn't get everything and so the command just keeps getting bigger. I am using &lt;a href=&quot;https://anaconda.org/conda-forge/scip&quot; rel=&quot;nofollow noreferrer&quot;&gt;SCIP&lt;/a&gt; and so I will have problems there. I heard that you can add the executable to the optimizer, but I have no idea where &lt;code&gt;conda&lt;/code&gt; put that executable.&lt;/p&gt;&#xA;&lt;p&gt;Can we get a good solution to creating executables (with the extra folders and not just one file) using &lt;code&gt;pyinstaller&lt;/code&gt; and featuring &lt;code&gt;Pyomo&lt;/code&gt;? It needs an added focus on how to, exactly, add the optimizers (like SCIP)?&lt;/p&gt;&#xA;" OwnerUserId="12953" LastEditorUserId="199" LastEditDate="2023-12-08T18:53:38.703" LastActivityDate="2023-12-08T18:53:38.703" Title="pyinstaller and Pyomo and also SCIP" Tags="|python|pyomo|scip|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11372" PostTypeId="1" CreationDate="2023-12-09T03:52:26.353" Score="-1" ViewCount="106" Body="&lt;p&gt;I have an issue with my Excel function for a grocery store problem and I am not sure where I messed up the constraints. I have the value of the solution it should be (cost = 8,283).&lt;/p&gt;&#xA;&lt;p&gt;I need to make a stop in aisles  16, 18, 24, 8, 10, 14, 23, 17, 30, 1, 25, 2, 19, 22, 21, 20, and 29 to pick things up. There are 30 aisles.&lt;/p&gt;&#xA;&lt;p&gt;Here is my Excel spreadsheet: &lt;a href=&quot;https://1drv.ms/x/s!AnDJPWC5itDLhT021H3MEl2v2Pf1?e=CFDDfP&amp;amp;nav=MTVfezAwMDAwMDAwLTAwMDEtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMH0&quot; rel=&quot;nofollow noreferrer&quot;&gt;grocery store problem excel&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here is the network.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YeCOd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YeCOd.png&quot; alt=&quot;https://i.stack.imgur.com/YeCOd.png&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12955" LastEditorUserId="491" LastEditDate="2023-12-09T14:42:55.757" LastActivityDate="2023-12-09T14:42:55.757" Title="Grocery Store Problem" Tags="|optimization|network-flow|traveling-salesman|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11373" PostTypeId="2" ParentId="11372" CreationDate="2023-12-09T04:47:35.587" Score="1" Body="&lt;p&gt;You can solve the problem as follows.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Find all-pairs shortest path distances between the &lt;span class=&quot;math-container&quot;&gt;$17$&lt;/span&gt; &amp;quot;must-visit&amp;quot; nodes in the original directed network.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Introduce a dummy node &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;-cost arcs to node &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and from all other must-visit nodes.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Solve an asymmetric traveling salesman problem in a (complete, except for the dummy node) directed network on the must-visit nodes and the dummy node, where the arc costs are the shortest-path distances obtained in step 1.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The resulting optimal tour has the following costs, which sum to &lt;span class=&quot;math-container&quot;&gt;$8283$&lt;/span&gt;, as you claimed:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{matrix}&#xA;i&amp;amp;j&amp;amp;\text{cost}\\&#xA;\hline&#xA;0&amp;amp;1&amp;amp;0\\&#xA;1&amp;amp;2&amp;amp;1170\\&#xA;2&amp;amp;8&amp;amp;1020\\&#xA;8&amp;amp;10&amp;amp;300\\&#xA;10&amp;amp;14&amp;amp;1153\\&#xA;14&amp;amp;16&amp;amp;273\\&#xA;16&amp;amp;18&amp;amp;320\\&#xA;18&amp;amp;17&amp;amp;113\\&#xA;17&amp;amp;21&amp;amp;614\\&#xA;21&amp;amp;20&amp;amp;272\\&#xA;20&amp;amp;19&amp;amp;163\\&#xA;19&amp;amp;22&amp;amp;864\\&#xA;22&amp;amp;30&amp;amp;271\\&#xA;30&amp;amp;23&amp;amp;312\\&#xA;23&amp;amp;24&amp;amp;400\\&#xA;24&amp;amp;25&amp;amp;101\\&#xA;25&amp;amp;29&amp;amp;937\\&#xA;29&amp;amp;0&amp;amp;0\\&#xA;\end{matrix}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;By the way, if you are allowed to start anywhere and end anywhere, the optimal cost is instead &lt;span class=&quot;math-container&quot;&gt;$7174$&lt;/span&gt;, achieved by a path that starts at &lt;span class=&quot;math-container&quot;&gt;$29$&lt;/span&gt; and ends at &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; but is not quite the reverse of the path above.&lt;/p&gt;&#xA;&lt;p&gt;Related questions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/6193/how-to-visit-a-subset-of-network-nodes-in-a-single-trip&quot;&gt;How to visit a subset of network nodes in a single trip?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/10762/how-can-i-find-the-shortest-path-visiting-all-nodes-in-a-connected-graph-as-milp&quot;&gt;How can I find the shortest path visiting all nodes in a connected graph as MILP?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://math.stackexchange.com/questions/4466582/find-the-shortest-path-in-a-graph-which-must-pass-certain-nodes&quot;&gt;https://math.stackexchange.com/questions/4466582/find-the-shortest-path-in-a-graph-which-must-pass-certain-nodes&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-12-09T05:05:39.860" LastActivityDate="2023-12-09T05:05:39.860" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11374" PostTypeId="2" ParentId="11363" CreationDate="2023-12-09T10:16:21.013" Score="0" Body="&lt;p&gt;In the log you show, the &lt;a href=&quot;https://www.gurobi.com/documentation/11.0/refman/presolve.html#parameter:Presolve&quot; rel=&quot;nofollow noreferrer&quot;&gt;Presolve&lt;/a&gt; parameter was changed to 2. That value corresponds to an aggressive setting.  It can therefore be expected that presolve takes longer than when left at the default value.  Note that this setting doesn't guarantee that presolve will find more changes to do. It will try harder, but may not succeed...&lt;/p&gt;&#xA;&lt;p&gt;If presolve, whether using values 1 or 2, doesn't make the problem easier, you can remove it by using the value 0.&lt;/p&gt;&#xA;" OwnerUserId="295" LastActivityDate="2023-12-09T10:16:21.013" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11375" PostTypeId="2" ParentId="7343" CreationDate="2023-12-10T10:10:30.600" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://timefold.ai&quot; rel=&quot;nofollow noreferrer&quot;&gt;Timefold Solver&lt;/a&gt; and &lt;a href=&quot;https://github.com/TimefoldAI/timefold-quickstarts&quot; rel=&quot;nofollow noreferrer&quot;&gt;our quickstarts&lt;/a&gt; are open to external contributors, under the open-source Apache License.&lt;/p&gt;&#xA;&lt;p&gt;At the time of writing, we have &lt;a href=&quot;https://github.com/TimefoldAI/timefold-solver/pulls?q=is%3Apr%20&quot; rel=&quot;nofollow noreferrer&quot;&gt;more than 300 Pull Requests&lt;/a&gt; in less than a year, with a portion of those coming from outside contributors. If you don't know where to start, reach out to us on &lt;a href=&quot;https://github.com/TimefoldAI/timefold-solver/discussions&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub Discussions&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But you don't need to contribute code to participate. You can also &lt;a href=&quot;https://github.com/TimefoldAI/timefold-solver/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;raise an issue&lt;/a&gt; or improve the writing in &lt;a href=&quot;https://github.com/TimefoldAI/timefold-solver/tree/main/docs&quot; rel=&quot;nofollow noreferrer&quot;&gt;the docs&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Hint: &lt;strong&gt;Start small.&lt;/strong&gt; Less than 10 lines. It will be easier to finish for you and much easier/faster for our core team to review and approve. Just like in any other open source project, build trust and experience, before you submit a PR of 100+ lines.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2023-12-10T13:44:18.467" LastActivityDate="2023-12-10T13:44:18.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11376" PostTypeId="1" AcceptedAnswerId="11383" CreationDate="2023-12-10T13:10:03.733" Score="2" ViewCount="138" Body="&lt;p&gt;Consider the following problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \begin{aligned}&#xA;    \min_{x,y,z}&#xA;    \quad &amp;amp; \sum_{i=0}^1 \sum_{j=0}^1 \sum_{k=0}^1 a_{ijk} \cdot f_{ijk}(x,y,z), \\&#xA;    \textrm{s.t.} \quad &amp;amp; 0.1 \leq x \leq 1 \\&#xA;                  \quad &amp;amp; 0.1 \leq y \leq 1 \\&#xA;                  \quad &amp;amp; 0.1 \leq z \leq 1 \\&#xA;    \end{aligned} \tag{1}&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$a_{ijk} \geq 0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$(i,j,k) \in \{0,1\}^3$&lt;/span&gt; and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f_{ijk}(x,y,z) =&#xA;\begin{cases}&#xA;(1-x) \cdot (1-y) \cdot (1-z), &amp;amp;i = 0, j = 0, k = 0 \\&#xA;(1-x) \cdot (1-y) \cdot z, &amp;amp;i = 0, j = 0, k = 1 \\&#xA;(1-x) \cdot y \cdot (1-z), &amp;amp;i = 0, j = 1, k = 0 \\&#xA;(1-x) \cdot y \cdot z, &amp;amp;i = 0, j = 1, k = 1 \\&#xA;x \cdot (1-y) \cdot (1-z), &amp;amp;i = 1, j = 0, k = 0 \\&#xA;x \cdot (1-y) \cdot z, &amp;amp;i = 1, j = 0, k = 1 \\&#xA;x \cdot y \cdot (1-z), &amp;amp;i = 1, j = 1, k = 0 \\&#xA;x \cdot y \cdot z, &amp;amp;i = 1, j = 1, k = 1&#xA;\end{cases}&#xA;$$&lt;/span&gt;&#xA;I initially tried to solve the problem in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; as a geometric program using a change of variables, but the new feasible set is no longer convex. It is likely that &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; can be solved as a signomial program, but the challenge here is that &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; is in fact a small-scale version of a larger problem.&lt;/p&gt;&#xA;&lt;p&gt;That is, there are 3 decision variables in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and 8 summands. In the more general case, when there are &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; decision variables, there will be &lt;span class=&quot;math-container&quot;&gt;$2^M$&lt;/span&gt; summands. I'm interested in the case when &lt;span class=&quot;math-container&quot;&gt;$M &amp;gt; 100$&lt;/span&gt;, and so solving the signomial program when the objective function has more than &lt;span class=&quot;math-container&quot;&gt;$2^{100}$&lt;/span&gt; terms is likely to be difficult. Therefore, I'm considering the following recursive approach instead, but I'm not sure if it is solvable and would appreciate any feedback.&lt;/p&gt;&#xA;&lt;p&gt;Using some algebra, we can re-arrange the objective function in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; so that the problem becomes&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \begin{aligned}&#xA;    \min_{x,y,z}&#xA;    \quad &amp;amp; x \cdot g_2(y,z) + y \cdot g_1(z) + z \cdot c, \\&#xA;    \textrm{s.t.} \quad &amp;amp; 0.1 \leq x \leq 1 \\&#xA;                  \quad &amp;amp; 0.1 \leq y \leq 1 \\&#xA;                  \quad &amp;amp; 0.1 \leq z \leq 1 \\&#xA;    \end{aligned} \tag{2}&#xA;\end{equation}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$g_2$&lt;/span&gt; is a quadratic function of &lt;span class=&quot;math-container&quot;&gt;$(y,z)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$g_1$&lt;/span&gt; is a linear function of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$c \in \mathbb R$&lt;/span&gt;. Because &lt;span class=&quot;math-container&quot;&gt;$\min_{x,y,z} [\cdot]$&lt;/span&gt; is equivalent to &lt;span class=&quot;math-container&quot;&gt;$\min_z [\min_y [\min_x [\cdot]]]$&lt;/span&gt;, then the problem in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; can be re-written as a sequence of 3 sub-problems:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;    \begin{aligned}&#xA;    \min_{z} \quad &amp;amp; &#xA;    \left\{\begin{aligned}[t]&#xA;    \min_{y} \quad &amp;amp;&#xA;    \left\{\begin{aligned}[t]&#xA;    \min_{x} \quad &amp;amp; x \cdot g_2(y,z), \\&#xA;    \textrm{s.t.} \quad &amp;amp; 0.1 \leq x \leq 1&#xA;    \end{aligned}\right\}&#xA;    + y \cdot g_1(z), \\&#xA;    \textrm{s.t.} \quad &amp;amp; 0.1 \leq y \leq 1&#xA;    \end{aligned}\right\}&#xA;    + z \cdot c, \\&#xA;    \textrm{s.t.} \quad &amp;amp; 0.1 \leq z \leq 1&#xA;    \end{aligned} \tag{3}&#xA;\end{equation}&lt;/span&gt;&#xA;At this point, I'm not sure how &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; can be solved, since the solution to the inner-most problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{aligned}[t]&#xA;    \min_{x} \quad &amp;amp; x \cdot g_2(y,z), \\&#xA;    \textrm{s.t.} \quad &amp;amp; 0.1 \leq x \leq 1&#xA;    \end{aligned}&#xA;\end{equation}&lt;/span&gt;&#xA;will either be &lt;span class=&quot;math-container&quot;&gt;$x = 0.1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$x = 1$&lt;/span&gt; depending on the sign of &lt;span class=&quot;math-container&quot;&gt;$g_2(y,z)$&lt;/span&gt;. However, the sign of &lt;span class=&quot;math-container&quot;&gt;$g_2(y,z)$&lt;/span&gt; can only be determined by choosing &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, but choosing &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is part of the outer problems. This is similar to a chicken-or-egg problem, and I'm not sure how to proceed.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2023-12-10T13:16:25.093" LastActivityDate="2023-12-13T02:40:56.850" Title="Can the following problem be solved recursively?" Tags="|convex-optimization|dynamic-programming|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="11377" PostTypeId="1" CreationDate="2023-12-10T19:38:30.067" Score="3" ViewCount="124" Body="&lt;p&gt;I am trying to solve a problem of the form &lt;span class=&quot;math-container&quot;&gt;$$\min_{x_1,\dots,x_n} f(x_1,\dots,x_n)$$&lt;/span&gt; subject to a constraint that &lt;span class=&quot;math-container&quot;&gt;$\mathrm{length}(\mathrm{TSP}(x_1,\dots,x_n))\leq c$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$x_1,\dots,x_n$&lt;/span&gt; are all points in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a convex function, and &lt;span class=&quot;math-container&quot;&gt;$\mathrm{TSP}()$&lt;/span&gt; denotes the shortest TSP tour through the points.  There are obvious ways to formulate this as an IP or a QIP by introducing a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{ij}$&lt;/span&gt; representing the tour and doing the usual tricks (big &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; for IP, and taking products &lt;span class=&quot;math-container&quot;&gt;$y_{ij}\|x_i-x_j\|$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am wondering if anyone has had any experience with problems of this sort, and if there are additional tricks that could improve performance?  A reference would help too as I don't know what to google to find similar results.&lt;/p&gt;&#xA;" OwnerUserId="11042" LastEditorUserId="500" LastEditDate="2023-12-11T18:16:07.467" LastActivityDate="2023-12-11T18:16:07.467" Title="Continuous optimization with a Euclidean TSP objective" Tags="|mixed-integer-programming|integer-programming|quadratic-programming|traveling-salesman|multi-objective-optimization|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="11379" PostTypeId="2" ParentId="11376" CreationDate="2023-12-11T08:33:52.183" Score="2" Body="&lt;p&gt;As you actually have lots of multiplication of the variables, using any global solver can lead to the linearization of these terms and finally slow convergence. As an alternative, it would be worth trying the Lagrangian method. For that, this &lt;a href=&quot;https://math.stackexchange.com/a/1508536/595412&quot;&gt;link&lt;/a&gt; might be a good starting point. (Noted that it might lead to a sub-optimal solution).&lt;/p&gt;&#xA;&lt;p&gt;However, some global solvers can turn out the term like &lt;span class=&quot;math-container&quot;&gt;$(x.y.z)$&lt;/span&gt; into two bilinear terms internally. One &lt;span class=&quot;math-container&quot;&gt;$(x.w)$&lt;/span&gt;, and the second &lt;span class=&quot;math-container&quot;&gt;$(w=y.z)$&lt;/span&gt;. Then linearizing these bilinear terms by RLT or &lt;em&gt;Reformulation Linearization Technique&lt;/em&gt;. (E.g, McCormick envelope).&lt;/p&gt;&#xA;&lt;p&gt;As far as I know, many of the global NLP/MINLP/QCP/MIQCP solvers, support these kinds of linearization.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-12-11T08:33:52.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11380" PostTypeId="1" AcceptedAnswerId="11381" CreationDate="2023-12-11T09:08:04.307" Score="5" ViewCount="209" Body="&lt;p&gt;I am working on the scheduling problem in the class of parallel resource scheduling models. When I have studied some papers regarding that, I see the method that combines an MIP with a CP. The proposed procedure was:&lt;/p&gt;&#xA;&lt;p&gt;The formulation was divided into two parts. The first part, actually assigning parts, was solved by an MIP solver, and the second part, the disjunction part, was solved by a CP solver. And as far as I understand these parts work simultaneously in the branch and cut algorithm. (This is where I am interested in).&lt;/p&gt;&#xA;&lt;p&gt;Now, I would like to know if &lt;strong&gt;there is any resource, particularly, code source to see how this method works&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt; [1] &lt;em&gt;Ruslan Sadykov, Laurence Wolsey&lt;/em&gt;. &lt;a href=&quot;https://www.researchgate.net/publication/220669091_Integer_Programming_and_Constraint_Programming_in_Solving_a_Multimachine_Assignment_Scheduling_Problem_with_Deadlines_and_Release_Dates&quot; rel=&quot;noreferrer&quot;&gt;Integer Programming and Constraint Programming in Solving a Multimachine Assignment Scheduling Problem with Deadlines and Release Dates&lt;/a&gt;. &lt;em&gt;May 2006 - INFORMS Journal on Computing&lt;/em&gt;. 18(2):209-217 &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2023-12-12T17:37:09.580" Title="How to combine MIP solver with a CP one?" Tags="|mixed-integer-programming|solver|scheduling|constraint-programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11381" PostTypeId="2" ParentId="11380" CreationDate="2023-12-11T14:26:39.837" Score="2" Body="&lt;p&gt;I think they actually state it very clearly in the paper in the part they call &lt;strong&gt;Algorithm 3. IP/CP&lt;/strong&gt;: solve a relaxation of the original and then generate no-good cuts that remove infeasible solution. In order to separate no-good cuts, a CP model is used to check whether the current solution is feasible or not. The method is very similar to combinatorial benders’ where the sub problem is solved using a CP model.&lt;/p&gt;&#xA;" OwnerUserId="278" LastActivityDate="2023-12-11T14:26:39.837" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11382" PostTypeId="1" CreationDate="2023-12-11T15:12:33.317" Score="2" ViewCount="77" Body="&lt;p&gt;What are common uses of superscripts in mathematical optimization formulations? None of my optimization books start at the level of &amp;quot;proper&amp;quot; variable labeling.  When I ask ChatGPT, it recommends time, stages, levels, layers, scenarios, and exponentiation.  These cases track from what I have seen in papers, but are there other cases?  I am working on a paper that has subgraphs, paths, subsets, and other non-sequential objects that are used as variable identifiers.  Should these just be subscripts?&lt;/p&gt;&#xA;" OwnerUserId="12962" LastActivityDate="2023-12-11T15:12:33.317" Title="Superscript use in optimization formulations" Tags="|optimization|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11383" PostTypeId="2" ParentId="11376" CreationDate="2023-12-12T10:03:01.143" Score="1" Body="&lt;p&gt;As you noticed, the optimal &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; must be on the bound. By symmetry, &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; must also be on the bound.&lt;/p&gt;&#xA;&lt;p&gt;We can recursively evaluate the objective of all &lt;span class=&quot;math-container&quot;&gt;$2^M$&lt;/span&gt; vertices, and then choose the optimal one.&lt;/p&gt;&#xA;&lt;p&gt;Let's take &lt;span class=&quot;math-container&quot;&gt;$M=3$&lt;/span&gt; as an example. Given &lt;span class=&quot;math-container&quot;&gt;$a_{ijk}$&lt;/span&gt;, fix &lt;span class=&quot;math-container&quot;&gt;$k=0$&lt;/span&gt; and with &lt;span class=&quot;math-container&quot;&gt;$a_{ij0}$&lt;/span&gt;, we have an &lt;span class=&quot;math-container&quot;&gt;$M=2$&lt;/span&gt; subproblem, so we can calculate the objective values on 4 vertices &lt;span class=&quot;math-container&quot;&gt;$f^0_{x,y}$&lt;/span&gt;. Similarly, we can fix &lt;span class=&quot;math-container&quot;&gt;$k=1$&lt;/span&gt; and calculate another 4 values &lt;span class=&quot;math-container&quot;&gt;$f^1_{x,y}$&lt;/span&gt;. Then we have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;f_{x,y,z} = f^0_{x,y}(1-z)+f^1_{x,y}z&#xA;$$&lt;/span&gt;&#xA;for all vertices &lt;span class=&quot;math-container&quot;&gt;$(x,y,z)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The time complexity is exponential, but since the data size is exponential, the solution is not bad I think.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastEditorUserId="4569" LastEditDate="2023-12-13T02:40:56.850" LastActivityDate="2023-12-13T02:40:56.850" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11384" PostTypeId="2" ParentId="11361" CreationDate="2023-12-12T16:02:54.683" Score="1" Body="&lt;p&gt;To my best knowledge, there is not such option. What you can do, is to set the number of threads to be used, and to set the parallel mode (deterministic or opportunistic). CPLEX will figure out the best possible parallel implementation for you. Note that assigning each sub-problem to a unique core is not necessarily the best strategy.&lt;/p&gt;&#xA;" OwnerUserId="4969" LastActivityDate="2023-12-12T16:02:54.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11385" PostTypeId="2" ParentId="11380" CreationDate="2023-12-12T17:30:23.670" Score="2" Body="&lt;h2&gt;General&lt;/h2&gt;&#xA;&lt;p&gt;Many works combining MILP and CP are what's sometimes called &lt;strong&gt;logic-based benders decomposition&lt;/strong&gt; and there is even a book on the topic:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Hooker, John. &amp;quot;Logic-Based Benders Decomposition: Theory and Applications.&amp;quot; (2023).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Besides Hooker who probably coined the term, most of the work i read (scheduling/routing) was from &lt;a href=&quot;https://scholar.google.de/citations?user=y_pAyuQAAAAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Christopher Beck&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;For a good background (when shift from master to sub-problem solver: basically with primal feasible solution or only when reached an optimal one), the following might also be a worthwile read:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Beck, J. Christopher. &amp;quot;Checking-up on branch-and-check.&amp;quot; Principles and Practice of Constraint Programming–CP 2010: 16th International Conference, CP 2010, St. Andrews, Scotland, September 6-10, 2010. Proceedings 16. Springer Berlin Heidelberg, 2010.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h2&gt;Implementation&lt;/h2&gt;&#xA;&lt;p&gt;A high-quality implementation (linked to papers and a dissertation) which is a bit more far-reaching (and therefore introducing some complexity) would be:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/ed-lam/nutmeg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ed-lam/nutmeg&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This and some others howewer are using CP/SAT-Hybrids as their sub-problem solver component aka &amp;quot;CP&amp;quot; (or-tools cp-sat is also a CP/SAT/MILP-hybrid).&lt;/p&gt;&#xA;&lt;p&gt;Among other differences to pure CP, these hybrids are very good at efficiently inferring conflict-clauses (because of SAT-style conflict-analysis) which is a very good thing in LBBD because the cuts will be much more accurate.&lt;/p&gt;&#xA;&lt;p&gt;Imagine a vehicle-routing problem where a MILP does assign routes to vehicles and the sub-problem solver not only recognized that this tour of 11 stops isn't feasible (e.g. duration or time-windows) but efficiently infer that out of those 11 stops, those 3 alone are a source of infeasibility.&lt;/p&gt;&#xA;&lt;p&gt;Compare with some or-tools cp-sat &lt;a href=&quot;https://github.com/google/or-tools/blob/8768ed7a43f8899848effb71295a790f3ecbe2f2/ortools/sat/cp_model.proto#L659&quot; rel=&quot;nofollow noreferrer&quot;&gt;API&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-protobuf prettyprint-override&quot;&gt;&lt;code&gt;  // A list of literals. The model will be solved assuming all these literals&#xA;  // are true. Compared to just fixing the domain of these literals, using this&#xA;  // mechanism is slower but allows in case the model is INFEASIBLE to get a&#xA;  // potentially small subset of them that can be used to explain the&#xA;  // infeasibility.&#xA;  //&#xA;  // Think (IIS), except when you are only concerned by the provided&#xA;  // assumptions. This is powerful as it allows to group a set of logically&#xA;  // related constraint under only one enforcement literal which can potentially&#xA;  // give you a good and interpretable explanation for infeasiblity.&#xA;  //&#xA;  // Such infeasibility explanation will be available in the&#xA;  // sufficient_assumptions_for_infeasibility response field.&#xA;  repeated int32 assumptions = 7;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The paper linked to the implementation even claims, that this general-purpose conflict-analysis discovers the same cuts as specialized TSP/VRP ones developed specifically for these tasks.&lt;/p&gt;&#xA;" OwnerUserId="231" LastEditorUserId="231" LastEditDate="2023-12-12T17:37:09.580" LastActivityDate="2023-12-12T17:37:09.580" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11386" PostTypeId="1" CreationDate="2023-12-13T06:32:05.683" Score="0" ViewCount="74" Body="&lt;p&gt;How to derive the dual of a second order cone programming with both equality and inequality constraints?&#xA;Here is the optimization problem I want to handle:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{array}{rl}\min_{\mathbf{x},\mathbf{y}}&amp;amp;\frac{1}{2}\mathbf{x}^{{T}}\mathbf{P}_0\mathbf{x}+\mathbf{q}_0^{{T}}\mathbf{x}+\mathbf{r}_0\\ &#xA;\text{s.t.}&amp;amp;\mathbf{A}\mathbf{x}+\mathbf{B}\mathbf{y}=\mathbf{f}\\&#xA;&amp;amp;\mathbf{C}\mathbf{x}+\mathbf{D}\mathbf{y}\le\mathbf{g}\\&#xA;&amp;amp;\frac{1}{2}\mathbf{x}^{{T}}{\mathbf{P}}_{i}\mathbf{x}+\mathbf{q}_{{i}}^{{T}}\mathbf{x}+\mathbf{r}_{{i}}\leq0,{i}=1,\ldots,k\\&#xA;&amp;amp; \left\|\mathbf{S}_{i}\mathbf{y}+\mathbf{t}_{i}\right\|_2\leq\mathbf{u}_{i}^{T}\mathbf{y}+{v}_{i},{i}=1,\ldots,l\end{array}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\mathbf P_0,\ldots,\mathbf P_m$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$n\times n$&lt;/span&gt; matrices and &lt;span class=&quot;math-container&quot;&gt;$ \mathbf x \in \mathbb R^n, \mathbf y \in \mathbb R^m$&lt;/span&gt; is the optimization variable. The optimization variables are separated into &lt;span class=&quot;math-container&quot;&gt;$ \mathbf x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$ \mathbf y$&lt;/span&gt; as they follow different constraints.&lt;/p&gt;&#xA;&lt;p&gt;In my setting, &lt;span class=&quot;math-container&quot;&gt;$\mathbf P_0,\ldots,\mathbf P_m$&lt;/span&gt; are all positive semidefinite and thus the problem is convex. I wanna ask:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the dual of this problem?&lt;/li&gt;&#xA;&lt;li&gt;How to ensure strong duality?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="12970" LastActivityDate="2024-02-24T06:02:00.243" Title="Dual of second order cone programming with both equality and inequality constraints" Tags="|duality|conic-optimization|socp|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11387" PostTypeId="1" CreationDate="2023-12-13T15:05:13.173" Score="0" ViewCount="74" Body="&lt;p&gt;I have a math model as shown below, which I want to solve with cplex via docplex. In my model, the decision variables represent an assignment to different places. In my objective function, I call a function that calculates the distance between two places as a function of all other variables. Can I call the function in the target function without any problems and pass it all variables as arguments, as in the example?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;N = 6&#xA;X = 6&#xA;Y = 6&#xA;O = 4&#xA;flow = 2&#xA;M =3000&#xA;&#xA;def tc(P, n, m):&#xA;  #calculations  &#xA;  return something&#xA;&#xA;mod = Model(&amp;quot;mod&amp;quot;)&#xA;P = mod.var_hypercube(vartype_spec='B', seq_of_keys=[[0, 1, 2, 3, 4, 5],[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3]])&#xA;&#xA;gw_fkt = sum(sum(sum(sum(P[n, x_n, y_n, o_n]* tc(P, n,m) for n in range(N)) for x_n in range(X)) for o_n in range(O)) for y_n in range(Y))&#xA;#restrictions&#xA;for n in range(N):&#xA;    mod.add_constraint(sum(sum(sum(P[n, x, y, o] for x in range(X)) for y in range(Y)) for o in range(O)) == 1) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12942" LastEditorUserId="500" LastEditDate="2023-12-13T18:12:13.687" LastActivityDate="2023-12-13T18:12:13.687" Title="Can I call a function which depends on the decison variables in an objective function when using docplex?" Tags="|docplex|callback|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11388" PostTypeId="1" AcceptedAnswerId="11404" CreationDate="2023-12-13T16:09:20.073" Score="3" ViewCount="194" Body="&lt;p&gt;I have a set of many similar linear programs (LP). All these LPs have the same objective function, and almost all constraints are the same. The only difference is for one linear constraint &lt;span class=&quot;math-container&quot;&gt;$f(x)=a_{i}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$a_{i}$&lt;/span&gt; is a constant that changes from one LP to the next. Instead of solving each LP from scratch, I am trying to use the information from the first LP problem to solve the other LPs more quickly.&lt;/p&gt;&#xA;&lt;p&gt;Thanks to &lt;a href=&quot;https://math.stackexchange.com/questions/4824846/how-to-efficiently-solve-many-linear-programs-with-only-one-different-constraint/4824894&quot;&gt;this conversation&lt;/a&gt;, I was told that this kind of change preserves dual feasibility, so I should apply the dual simplex method with a warm start from the previous optimal basis.&lt;/p&gt;&#xA;&lt;p&gt;Based on this suggestion, I was trying to iteratively warm start LP number &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; with the optimal solution from LP number &lt;span class=&quot;math-container&quot;&gt;$(i-1)$&lt;/span&gt;.&#xA;Concretely, I was using the following steps using PuLP with Gurobi:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Update the only constraint that changes in the LP: &lt;code&gt;prob.constraints['cst_a'] += a[i-1] - a[i]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Set the initial value to all LP variables: &lt;code&gt;for t in ts: varProb[t].setInitialValue(optimalVarPreviousProb[t])&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Solve the new LP using warm start and dual simplex: &lt;code&gt;prob.solve(pulp.GUROBI_CMD(logPath=&amp;quot;LogFile.log&amp;quot;, warmStart=True, options=[(&amp;quot;method&amp;quot;,1)]))&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;However, I was surprised to see that the total computation time did not decrease. If anything, it actually increased slightly (certainly due to the extra time to set initial values).&lt;/p&gt;&#xA;&lt;p&gt;I compared the log files with and without warm starting the problem, and the number of dual simplex iterations for each LP is &lt;em&gt;&lt;strong&gt;exactly&lt;/strong&gt;&lt;/em&gt; the same. In other words, it looks like the warm starting did not do anything.&lt;/p&gt;&#xA;&lt;p&gt;Actually, the log file does not seem to acknowledge any warm starting. But when I use warm start with MILP problems, the log file does acknowledge the use of a &amp;quot;User MIP start&amp;quot;. Does that mean LP warm start does not work with PuLP and/or Gurobi?&lt;/p&gt;&#xA;&lt;p&gt;Any other idea what I could be doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="12972" LastEditorUserId="491" LastEditDate="2023-12-15T14:01:02.827" LastActivityDate="2023-12-18T14:05:55.580" Title="Warm starting a LP problem with PuLP and Gurobi" Tags="|linear-programming|gurobi|pulp|dual-simplex|warm-start|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11389" PostTypeId="5" CreationDate="2023-12-13T17:56:16.557" Score="0" Body="" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-12-13T17:56:16.557" LastActivityDate="2023-12-13T17:56:16.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11390" PostTypeId="4" CreationDate="2023-12-13T17:56:16.557" Score="0" Body="For questions about solving a problem faster by using an initial solution obtained from a related problem." OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-12-13T17:56:16.557" LastActivityDate="2023-12-13T17:56:16.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11391" PostTypeId="1" AcceptedAnswerId="11393" CreationDate="2023-12-13T21:14:48.917" Score="1" ViewCount="221" Body="&lt;p&gt;I have a sequence of binary variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and want to enforce consecutive &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;'s of length at least &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;. I have &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; formulations:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Model &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; (from &lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2018/03/production-scheduling-minimum-up-time.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_i \le x_{i-1}+x_{i+1} \tag{1}\\&#xA;x_i \le x_{i-1}+x_{i+2} \tag{2}\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Model &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; (from &lt;a href=&quot;https://math.stackexchange.com/questions/3008969/binary-variables-in-time-series-integer-linear-programming&quot;&gt;here&lt;/a&gt;):&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_i &amp;amp;\le x_{i-1}+x_{i+1} \tag{3}\\&#xA;x_i +x_{i+1} &amp;amp;\le x_{i-1}+x_{i+2}+1 \tag{4}\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I would like to know which of these formulations &lt;span class=&quot;math-container&quot;&gt;$(1)-(2)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$(3)-(4)$&lt;/span&gt; has the tightest linear relaxation?&lt;/p&gt;&#xA;" OwnerUserId="12863" LastEditorUserId="12863" LastEditDate="2023-12-14T07:52:57.030" LastActivityDate="2023-12-14T13:39:44.847" Title="Which of these formulations has the tightest linear relaxation?" Tags="|mixed-integer-programming|modeling|constraint|logical-constraints|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11392" PostTypeId="2" ParentId="11391" CreationDate="2023-12-13T21:48:54.927" Score="0" Body="&lt;p&gt;At the risk of not answering your &amp;quot;A vs. B&amp;quot; question i would claim, that a better approach would be based on creating the corresponding &lt;a href=&quot;https://en.wikipedia.org/wiki/Deterministic_finite_automaton&quot; rel=&quot;nofollow noreferrer&quot;&gt;deterministic finite automaton&#xA;&lt;/a&gt; followed by transforming it into a layered-graph (assuming an upper bound on the sequence-length) and modelling it through network-flow like models.&lt;/p&gt;&#xA;&lt;p&gt;This also generalizes well (e.g. some small changes / extensions later).&lt;/p&gt;&#xA;&lt;p&gt;I guess the following resources are a good reference:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Côté, Marie-Claude, Bernard Gendron, and Louis-Martin Rousseau. &amp;quot;Modeling the regular constraint with integer programming.&amp;quot; Integration of AI and OR Techniques in Constraint Programming for Combinatorial Optimization Problems: 4th International Conference, CPAIOR 2007, Brussels, Belgium, May 23-26, 2007. Proceedings 4. Springer Berlin Heidelberg, 2007.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Côté, Marie-Claude, et al. &amp;quot;Formal languages for integer programming modeling of shift scheduling problems.&amp;quot; Constraints 16 (2011): 54-76.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;While not much saying about LP/MILP, this DFA-based approach is also known to provide very powerful theoretically-supported propagators in constraint-programming:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Pesant, Gilles. &amp;quot;A regular language membership constraint for sequences of variables.&amp;quot; Workshop on modelling and reformulation constraint satisfaction problems. 2003.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="231" LastActivityDate="2023-12-13T21:48:54.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11393" PostTypeId="2" ParentId="11391" CreationDate="2023-12-13T21:57:07.560" Score="3" Body="&lt;p&gt;Constraints &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; are identical, and &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; is just an aggregation of &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; and the valid inequality &lt;span class=&quot;math-container&quot;&gt;$x_{i+1} \le 1$&lt;/span&gt; that is part of the definition of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; being binary.  So Model 1 is at least as tight.  To see that it is actually tighter, consider the fractional solution &lt;span class=&quot;math-container&quot;&gt;$(x_{i-1},x_i,x_{i+1},x_{i+2})=(0,1/2,1/2,0)$&lt;/span&gt;, which violates Model 1 but satisfies Model 2.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-12-14T13:39:44.847" LastActivityDate="2023-12-14T13:39:44.847" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11394" PostTypeId="1" CreationDate="2023-12-14T08:27:00.413" Score="1" ViewCount="108" Body="&lt;p&gt;What is the best optimization method to solve a large-scale problem (about 300 thousand variables)?&lt;/p&gt;&#xA;&lt;p&gt;The problem is nonlinear, nonconvex, involves only binary variables, and is unconstrained. The objective function is expressed as a large-scale neural network.&lt;/p&gt;&#xA;" OwnerUserId="10454" LastActivityDate="2023-12-14T08:27:00.413" Title="What is the suitable optimization method for this case?" Tags="|integer-programming|machine-learning|gurobipy|deep-learning|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="11395" PostTypeId="1" CreationDate="2023-12-14T14:34:37.077" Score="1" ViewCount="117" Body="&lt;p&gt;This is a follow up question of &lt;a href=&quot;https://or.stackexchange.com/questions/11391/which-of-these-formulations-has-the-tightest-linear-relaxation/11393?noredirect=1#comment24256_11393&quot;&gt;this question&lt;/a&gt;, in which it was asked to compare the &amp;quot;tightness&amp;quot; of two models:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I have a sequence of binary variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; and want to enforce&#xA;consecutive &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;'s of length at least &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;. I have &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; formulations:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Model &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;\begin{align} x_i \le x_{i-1}+x_{i+1} \tag{1}\\ x_i \le x_{i-1}+x_{i+2} \tag{2}\\ \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Model &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;: &lt;span class=&quot;math-container&quot;&gt;\begin{align} x_i &amp;amp;\le x_{i-1}+x_{i+1} \tag{3}\\ x_i +x_{i+1} &amp;amp;\le x_{i-1}+x_{i+2}+1 \tag{4}\\ \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;A third option (Model 3) would be to define a new binary variable &lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; to detect when the sequence starts:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;s_i \ge x_i -x_{i-1} \tag{5}&#xA;$$&lt;/span&gt;&#xA;and to enforce &lt;span class=&quot;math-container&quot;&gt;$s_i \implies x_i \wedge x_{i+1} \wedge x_{i+2}$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;s_i &amp;amp;\le x_i \tag{6}\\&#xA;s_i &amp;amp;\le x_{i+1} \tag{7}\\&#xA;s_i &amp;amp;\le x_{i+2} \tag{8}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My question is the same. How does model &lt;span class=&quot;math-container&quot;&gt;$(5)-(8)$&lt;/span&gt; compare to models &lt;span class=&quot;math-container&quot;&gt;$(1)-(2)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(3)-(4)$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;My try: the fractional solution &lt;span class=&quot;math-container&quot;&gt;$(s_i, x_{i-1}, x_{i},x_{i+1},x_{i+2})=(0.1,0,0.2,0.5,0.1)$&lt;/span&gt; is violated by model &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, but satisfies models &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;. Therefore model &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; is tighter than models &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;. And we already know that model &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; is tighter than model &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;. Not sure how models &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; compare.&lt;/p&gt;&#xA;" OwnerUserId="12863" LastActivityDate="2023-12-17T05:10:08.983" Title="Which of these formulations has the tightest linear relaxation ? (Part 2)" Tags="|mixed-integer-programming|modeling|logical-constraints|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11396" PostTypeId="1" CreationDate="2023-12-15T08:48:18.107" Score="0" ViewCount="81" Body="&lt;p&gt;I have a set of orders N, for which i have to determine an optimal sequence. I wrap this decision within a binary matrix x[i][j], meaning whether i is succeeded by j.&lt;/p&gt;&#xA;&lt;p&gt;For example&lt;/p&gt;&#xA;&lt;p&gt;[[0 1 0 0]&lt;/p&gt;&#xA;&lt;p&gt;[0 0 1 0]&lt;/p&gt;&#xA;&lt;p&gt;[0 0 0 1]&lt;/p&gt;&#xA;&lt;p&gt;[0 0 0 0]]&lt;/p&gt;&#xA;&lt;p&gt;where the 1st row is the start (evident from its lack of preceding elements) and the 4th row is the final one scheduled.&lt;/p&gt;&#xA;&lt;p&gt;I enforce that each element is preceded and succeeded exactly once, except for first and last. In addition, the total number of 'movements' is also constrained to N-1.&lt;/p&gt;&#xA;&lt;p&gt;Sometimes, the model generates solutions which satisfy these constraints, but are not feasible. In such case, there exists a closed loop. For example, with N = 15, i got 0 -&amp;gt; 1 -&amp;gt; 11 -&amp;gt; 10 -&amp;gt; 5 -&amp;gt; 6 -&amp;gt; 0, which does not interact with the start or end point of the schedule.&lt;/p&gt;&#xA;&lt;p&gt;Q: How can introduce a constraint or variable  that makes sure there is a single complete cycle, where each element can and is visited exactly once? Below is sample code.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;    # the decision variable is a succesion matrix of i by j, i.e. whether i is followed by j&#xA;    x = LpVariable.dicts(&amp;quot;transition&amp;quot;, (range(N), range(N)), 0, 1, cat='Binary')&#xA;&#xA;    # auxiliary variable to enforce a single starting point&#xA;    u = LpVariable.dicts(&amp;quot;position&amp;quot;, range(N), 1, N)&#xA;&#xA;&#xA;    # constraint 1: each product has exactly one sucessor&#xA;    # we do not enforce this hard, since the last scheduled has no successor&#xA;    for i in range(N):&#xA;        prob += lpSum(x[i][j] for j in range(N)) &amp;lt;= 1&#xA;&#xA;    # constraint 2: each product is preceded by exactly one other&#xA;    # we do not enforce this hard, since the first one does not have a predecessor&#xA;    for j in range(N):&#xA;        prob += lpSum(x[i][j] for i in range(N)) &amp;lt;= 1&#xA;&#xA;    # constraint 3: the total number of movements is at max N-1&#xA;    # this means every productis selected once, except the start product&#xA;    prob += lpSum(x[i][j] for i in range(N) for j in range(N)) == N - 1&#xA;&#xA;# constraint 4: avoid circular dependencies, i.e. 1 -&amp;gt; 2 -&amp;gt; 1 is not allowed&#xA;    for i in range(N):&#xA;        for j in range(N):&#xA;            if i != j:&#xA;                prob += x[i][j] + x[j][i] &amp;lt;= 1&#xA;&#xA;&#xA;    # constraint 5: a product cannot be succeeded by itself&#xA;    # diagonal axis of x is 0&#xA;    for i in range(N):&#xA;        for j in range(N):&#xA;            if i == j:&#xA;                prob += x[i][j] == 0&#xA;&#xA;    # constraint 6: ensure that there is only one starting point&#xA;    for i in range(N):&#xA;        for j in range(1,N):&#xA;            if i != j:&#xA;                prob += u[i] - u[j] + N * x[i][j] &amp;lt;= N - 1&#xA;&#xA;    # constraint 7: the start product has no predecessor&#xA;    prob+= lpSum(x[i][zero_j] for i in range(N)) == 0&#xA;    &#xA;    # constraint 8: the start product must have a successor&#xA;    prob+= lpSum(x[zero_j][j] for j in range(N)) == 1&#xA;&#xA;&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12983" LastEditorUserId="500" LastEditDate="2024-01-15T02:28:19.913" LastActivityDate="2024-02-14T03:02:45.490" Title="Ensure complete cycle in binary succession matrix LP [PuLP]" Tags="|linear-programming|traveling-salesman|pulp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11398" PostTypeId="2" ParentId="11396" CreationDate="2023-12-15T12:40:50.153" Score="0" Body="&lt;p&gt;I think i resolved this by introducing a new variable p_i, i.e. position i. This denotes the position of the assignment in the sequence.&#xA;I used the following constraints&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    # constraint 10: positional constraint&#xA;    # if i is in the sequence, its position must be smaller than j if j is present&#xA;    for i in range(N):&#xA;        for j in range(N):&#xA;            if i != j:&#xA;                prob += p[i] +1 &amp;lt;= p[j] + M * (1-x[i][j])&#xA;                &#xA;    # constraint 11: positional constraint&#xA;    # i and j cannot have the same position&#xA;    for i in range(N):&#xA;        for j in range(N):&#xA;            if i != j:&#xA;                prob += p[i] != p[j]&#xA;                &#xA;                &#xA;    # constraint 12&#xA;    # the sum of assigned positions should be equal to the sum of range N&#xA;    # i.e. each position is present once&#xA;    prob += lpSum(p[i] for i in range(N)) == sum_n&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12983" LastActivityDate="2023-12-15T12:40:50.153" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11399" PostTypeId="1" CreationDate="2023-12-16T02:12:07.907" Score="0" ViewCount="58" Body="&lt;p&gt;In many text books, I find that the variance of the lead-time demand, if the lead-time and demand are independent random variables is defined as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;{\mathrm{var}}[LTD] = \mu_{LT}\cdot\sigma_D^{2}+\mu_D^{2}\cdot\sigma_{LT}^{2}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with expected value:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\mathbb{E}[LT \cdot D] = \mu_{LT}\cdot\mu_{D}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The stated variance is only possible if the random variable is of the form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} {\mathrm{var}}[LTD]= {\mathrm{var}}[\sum_{i=1}^{LT} D_{i} + LT\cdot D] \end{align}&lt;/span&gt; and where in this term:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} \sum_{i=1}^{LT} D_{i} \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;LT&lt;/strong&gt; is a constant and in the term:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;LT\cdot D&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;D&lt;/strong&gt; is constant and if &lt;span class=&quot;math-container&quot;&gt;\begin{align} \sum_{i=1}^{LT} D_{i} \end{align}&lt;/span&gt; is independent from &lt;span class=&quot;math-container&quot;&gt;\begin{align} LT\cdot D \end{align}&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here I observe the first contradiction, the random varible defined for the expected value is different from the one defined for its variance:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;LT \cdot D \neq \sum_{i=1}^{LT} D_{i} + LT\cdot D&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If we continue to analyze this for the variance we obtain:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;{\mathrm{var}}[LTD] = {\mathrm{var}}[\sum_{i=1}^{LT} D_{i} + LT\cdot D] = {\mathrm{var}}[\sum_{i=1}^{LT} D_{i}]+{\mathrm{var}}[LT\cdot D] = \mu_{LT}\cdot\sigma_D^{2}+\mu_D^{2}\cdot\sigma_{LT}^{2}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This doesn´t seem right. The variable we are interested in is the demand during the lead-time period, where LT and D are independent from each other:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;{\mathrm{var}}[LTD] = {\mathrm{var}}[LT \cdot D]&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We already know, that for 2 independent random variables, the variance of their product is determined by:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;{\mathrm{var}}[X \cdot Y] = {\mathrm{var}}[X] \cdot {\mathrm{var}}[Y]+{\mathrm{var}}[X] \cdot \mathbb{E}[Y]^{2} + {\mathrm{Var}}[Y] \cdot \mathbb{E}[X]^{2}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Therefore the variance of the lead-time demand should be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;{\mathrm{var}}[LT \cdot D] =\sigma_{LT}^{2} \cdot \sigma_{D}^{2}+\sigma_{LT}^{2} \cdot \mu_{D}^{2} + \sigma_{D}^{2} \cdot \mu_{LT}^{2} \rightarrow days^{2} \cdot \frac{units^{2}}{days^{2}} + days^{2} \cdot \frac{units^{2}}{days^{2}} + \frac{units^{2}}{days^{2}} \cdot days^{2} = units^{2} \end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and not this where even the units of measure do not make any sense:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align} \mu_{LT}\cdot\sigma_D^{2}+\mu_D^{2}\cdot\sigma_{LT}^{2} \rightarrow days\cdot\frac{units^{2}}{days^{2}}+\frac{units^{2}}{days^{2}} \cdot days^{2} = \frac{units^{2}}{days}+units^{2}&#xA;\end{align}&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12985" LastEditorUserId="12985" LastEditDate="2024-01-02T16:24:18.613" LastActivityDate="2024-01-02T16:24:18.613" Title="Why the lead-time demand variance is not simply the variance of the product of two independent random variables?" Tags="|demand-distribution|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11400" PostTypeId="2" ParentId="11395" CreationDate="2023-12-16T12:37:43.713" Score="3" Body="&lt;p&gt;As a simple test, I tried solving the problem in the three states you mentioned. Also, the pre-solving, separating, and heuristics were all turned off in all cases to test the problem with only the &lt;span class=&quot;math-container&quot;&gt;$\text{B&amp;amp;B}$&lt;/span&gt; scheme.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;The first model:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;presolved problem has 11 variables (10 bin, 0 int, 0 impl, 1 cont) and 22 constraints&#xA;     22 constraints of type &amp;lt;linear&amp;gt;&#xA;Presolving Time: 0.00&#xA;&#xA; time | node  | left  |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr|  dualbound   | primalbound  |  gap   | compl.&#xA;  1.0s|     1 |     0 |     7 |     - |   654k |   0 |  11 |  22 |  22 |   0 |  0 |   0 |   0 |-3.000000e+00 |      --      |    Inf | unknown&#xA;  1.0s|     1 |     0 |     7 |     - |   654k |   0 |  11 |  22 |  22 |   0 |  0 |   0 |   0 |-3.000000e+00 |      --      |    Inf | unknown&#xA;* 1.0s|     1 |     0 |     7 |     - |strongbr|   0 |  11 |  22 |  22 |   0 |  1 |   0 |   0 |-3.000000e+00 |-3.000000e+00 |   0.00%| unknown&#xA;  1.0s|     1 |     0 |     7 |     - |   657k |   0 |  11 |  22 |  22 |   0 |  1 |   0 |   1 |-3.000000e+00 |-3.000000e+00 |   0.00%| unknown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;The second model:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;presolved problem has 11 variables (10 bin, 0 int, 0 impl, 1 cont) and 22 constraints&#xA;     22 constraints of type &amp;lt;linear&amp;gt;&#xA;Presolving Time: 0.00&#xA;&#xA; time | node  | left  |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr|  dualbound   | primalbound  |  gap   | compl.&#xA;* 0.0s|     1 |     0 |     8 |     - |    LP  |   0 |  11 |  21 |  21 |   0 |  0 |   0 |   0 |-3.000000e+00 |-3.000000e+00 |   0.00%| unknown&#xA;  0.0s|     1 |     0 |     8 |     - |   738k |   0 |  11 |  21 |  21 |   0 |  0 |   0 |   0 |-3.000000e+00 |-3.000000e+00 |   0.00%| unknown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;The third model:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;presolved problem has 21 variables (20 bin, 0 int, 0 impl, 1 cont) and 42 constraints&#xA;     42 constraints of type &amp;lt;linear&amp;gt;&#xA;Presolving Time: 0.00&#xA;&#xA; time | node  | left  |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr|  dualbound   | primalbound  |  gap   | compl.&#xA;  0.0s|     1 |     0 |    13 |     - |  1557k |   0 |  21 |  36 |  36 |   0 |  0 |   0 |   0 |-3.000000e+00 |      --      |    Inf | unknown&#xA;  0.0s|     1 |     0 |    13 |     - |  1557k |   0 |  21 |  36 |  36 |   0 |  0 |   0 |   0 |-3.000000e+00 |      --      |    Inf | unknown&#xA;* 0.0s|     1 |     0 |    13 |     - |strongbr|   0 |  21 |  36 |  36 |   0 |  1 |   0 |   0 |-3.000000e+00 |-3.000000e+00 |   0.00%| unknown&#xA;  0.0s|     1 |     0 |    13 |     - |  1569k |   0 |  21 |  36 |  36 |   0 |  1 |   0 |   1 |-3.000000e+00 |-3.000000e+00 |   0.00%| unknown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It seems the first and the third cases need strong branching (the syntax &lt;code&gt;strongbr&lt;/code&gt;) to achive the optimal solution, while in the second case, the solver finds the optimal solution in the first row. Also, in the third one adding the new binary variable leads to an increase in the variable around &lt;span class=&quot;math-container&quot;&gt;$2x$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="199" LastEditDate="2023-12-17T05:10:08.983" LastActivityDate="2023-12-17T05:10:08.983" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11401" PostTypeId="1" CreationDate="2023-12-16T13:53:52.640" Score="0" ViewCount="47" Body="&lt;p&gt;I am trying to develop an MPC. In this MPC, I predict the temperature and try to bring the sensor value to the desired setpoint temperature. I predict the temperature in the next 180 minutes for the fuel combinations that I will recommend to be used for 3 hours.&lt;/p&gt;&#xA;&lt;p&gt;For example, X cubic meters of fuel for the next 60 minutes &lt;span class=&quot;math-container&quot;&gt;$(t,t+60)$&lt;/span&gt;, then Y cubic meters of fuel for the next 60 minutes &lt;span class=&quot;math-container&quot;&gt;$(t+60,t+120)$&lt;/span&gt;, and Z cubic meters of fuel in the last 60 minutes &lt;span class=&quot;math-container&quot;&gt;$(t+120,t+180)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have 11 different fuel combinations for each 60 minutes. Since I want to predict the next three hours, I have &lt;span class=&quot;math-container&quot;&gt;$11*11*11=1331$&lt;/span&gt; different 3-hour fuel combination scenarios. For these 1331 different fuel combination scenarios, I estimate the target sensor temperature for the next 180 minutes using the last temperature data. Then, I try to select the most optimal 3-fuel combination using the cost function, whose equation is given below. The concept of optimal here is to achieve the minimum error distance between the set and the estimated temperatures for the next 180 minutes with the minimum fuel change. So I am trying to minimize the cost function.&lt;/p&gt;&#xA;&lt;p&gt;While everything is very good here, there is a subject that is stuck in my head, and that is that the square of the temperature errors and the square of the fuel changes in the cost function are composed of different units. While temperature errors are squared in Celsius, fuel changes are squared in cubic meters. Do you think the elements in this function should be normalized, and is it necessary?&lt;/p&gt;&#xA;&lt;p&gt;If I need to normalize, I have the following additional questions: &lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Should I normalize within each scenario? In other words, should I normalize the data of 180 rows for each of the 1331 different scenarios, or should I consider all scenarios as a single data set and normalize the data of 1331x180 = 239580 rows? Because I think I will use min-max normalization, since each scenario will have its own min-max values, how will I compare 1331 scenarios with each other in the last case? &lt;/li&gt;&#xA;&lt;li&gt;Also, should I do this normalization before squaring the values? &lt;/li&gt;&#xA;&lt;li&gt;Min-Max normalization is the first and simplest normalization that comes to my mind, but if there is a normalization form that you think would make more sense, please share it. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;My cost function is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{1}^{180} 0.8 \times E^{2} + \sum_{1}^{180} 0.2 \times U^{^{2}}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;E: difference between temperature set value and forecasted temperature (unit: Celsius)&lt;/p&gt;&#xA;&lt;p&gt;U: recommended fuel change amount  (unit: m3/h)&lt;/p&gt;&#xA;" OwnerUserId="12987" LastEditorUserId="491" LastEditDate="2024-01-25T13:15:53.653" LastActivityDate="2024-01-25T13:15:53.653" Title="Objective/Cost Function Normalization (MPC)" Tags="|linear-programming|constraint|multi-objective-optimization|loss-functions|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11402" PostTypeId="1" CreationDate="2023-12-17T19:06:33.740" Score="0" ViewCount="31" Body="&lt;p&gt;Problem0:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\displaystyle \min_{\mathbf{u} \in \mathbf{R}^L}\frac{1}{2}\mathbf{u}^TQ\mathbf{u}+\mathbf{p}^T\mathbf{u}$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\,$&lt;/span&gt; subject to  &lt;span class=&quot;math-container&quot;&gt;$\,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\mathbf{a}^T\mathbf{u} \ge c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Problem1:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\displaystyle \min_{\mathbf{u} \in \mathbf{R}^L}\bigg[\frac{1}{2}\mathbf{u}^TQ\mathbf{u}+&#xA;\mathbf{p}^T\mathbf{u}+\max_{\alpha \ge 0 }(c-\mathbf{a}^T\mathbf{u})\bigg]$&lt;/span&gt; (Lagrange dual)&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$\mathbf{u}_0$&lt;/span&gt; be optimal for Problem0 and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{u}_1$&lt;/span&gt; be optimal for Problem1.&lt;/p&gt;&#xA;&lt;p&gt;(a) Show that &lt;span class=&quot;math-container&quot;&gt;$\displaystyle \max_{\alpha \ge 0} \alpha (\mathbf{c}-\mathbf{a}^T\mathbf{u}_0)=0$&lt;/span&gt;. [Hint: &lt;span class=&quot;math-container&quot;&gt;$\mathbf{c}-\mathbf{a}^T\mathbf{u}_0 \le 0$&lt;/span&gt;].&lt;/p&gt;&#xA;&lt;p&gt;(b) Show that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{u}_1$&lt;/span&gt; is feasible for Problem0. To show this suppose on the contrary&#xA;that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{c}-\mathbf{a}^T\mathbf{u}_1 &amp;gt; 0$&lt;/span&gt;. Show that the objective function in Problem 1 is infinite (Why?), whereas &lt;span class=&quot;math-container&quot;&gt;$\mathbf{u}_0$&lt;/span&gt; attains a finite objective of&#xA;&lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2}\mathbf{u}_0^TQ\mathbf{u}_0+&#xA;\mathbf{p}^T\mathbf{u}_0$&lt;/span&gt;, which conradicts the optimality of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{u}_1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(c) Show that &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2}\mathbf{u}_1^TQ\mathbf{u}_1+&#xA;\mathbf{p}^T\mathbf{u}_1=\frac{1}{2}\mathbf{u}_0^TQ\mathbf{u}_0+&#xA;\mathbf{p}^T\mathbf{u}_0$&lt;/span&gt;, and hence that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{u}_1$&lt;/span&gt; is optimal for Problem0 and&#xA;&lt;span class=&quot;math-container&quot;&gt;$\mathbf{u}_0$&lt;/span&gt; is optimal for Problem1.&lt;/p&gt;&#xA;&lt;p&gt;My questions:&lt;/p&gt;&#xA;&lt;p&gt;1-) In part (b), what is the explanation for the &amp;quot;Why&amp;quot; in this part?&lt;/p&gt;&#xA;&lt;p&gt;2-) Why does &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{2}\mathbf{u}_1^TQ\mathbf{u}_1+&#xA;\mathbf{p}^T\mathbf{u}_1=\frac{1}{2}\mathbf{u}_0^TQ\mathbf{u}_0+&#xA;\mathbf{p}^T\mathbf{u}_0$&lt;/span&gt; enforces optimality of &lt;span class=&quot;math-container&quot;&gt;$\mathbf{u}_0$&lt;/span&gt; for Problem1?&lt;/p&gt;&#xA;" OwnerUserId="4735" LastActivityDate="2023-12-17T19:06:33.740" Title="Unclear points in derivation of Lagrange duality for a quadratic optimization problem" Tags="|quadratic-programming|duality|lagrange-multipliers|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11403" PostTypeId="1" AcceptedAnswerId="11405" CreationDate="2023-12-17T22:44:20.863" Score="2" ViewCount="97" Body="&lt;p&gt;I want to solve a variant of the &lt;a href=&quot;https://cs.stackexchange.com/questions/43956/is-weighted-xor-sat-np-hard&quot;&gt;weighted XOR-SAT problem&lt;/a&gt;. Concretely,&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Given &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; boolean variables &lt;span class=&quot;math-container&quot;&gt;$x_1,\ldots,x_n$&lt;/span&gt; each of which is assigned a non-negative cost &lt;span class=&quot;math-container&quot;&gt;$c_1,\ldots,c_n\in\mathbb{R}_{\ge 0}$&lt;/span&gt; and a boolean function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; on these variables given in the form &lt;span class=&quot;math-container&quot;&gt;$$f(x_1,\ldots,x_n)=\bigwedge_{i=1}^k\bigoplus_{j=1}^{l_i}x_{r_{ij}}$$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$\oplus$&lt;/span&gt; denoting XOR) with &lt;span class=&quot;math-container&quot;&gt;$k\in\mathbb{Z}_{&amp;gt;0}$&lt;/span&gt;, integers &lt;span class=&quot;math-container&quot;&gt;$1\leq l_i\leq n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1\leq r_{i1}&amp;lt;\cdots&amp;lt;r_{il_i}\leq n$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i=1,\ldots,k$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$j=1,\ldots,l_i$&lt;/span&gt;, the problem is to find an assignment of minimum cost for &lt;span class=&quot;math-container&quot;&gt;$x_1,\ldots,x_n$&lt;/span&gt; that satisfies &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, if such an assignment exists. The cost of an assignment is simply given by &lt;span class=&quot;math-container&quot;&gt;$$\sum_{\substack{i\in\{1,\ldots,n\}\\x_i\,\text{true}}}c_i.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This problem is essentially XOR-SAT with a linear objective.&#xA;The difference between my formulation and the one in the linked question above is that &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; can take values in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}_{\ge 0}$&lt;/span&gt; instead of &lt;span class=&quot;math-container&quot;&gt;$\mathbb{Z}_{&amp;gt; 0}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How do I solve it with an off-the-shelf solver, like OR-Tools or Gurobi? By &amp;quot;solve it&amp;quot;, I mean finding a solution that is good enough in a reasonable amount of time, not finding the optimal solution exactly. This problem is NP-complete after all.&lt;/p&gt;&#xA;" OwnerUserId="12989" LastEditorUserId="981" LastEditDate="2023-12-22T14:55:13.737" LastActivityDate="2023-12-22T14:55:13.737" Title="Solving a weighted XOR-SAT problem" Tags="|linear-programming|integer-programming|solver|binary-variable|or-tools|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11404" PostTypeId="2" ParentId="11388" CreationDate="2023-12-18T14:05:55.580" Score="2" Body="&lt;p&gt;You typically don't warmstart LPs by providing a start solution. This is mostly done for MIPs to get a quick incumbent solution.&#xA;For LPs, you need to provide the basis information and ideally have some more internal data structures available (like the basis factorization). When you don't throw away everything after one optimization and just alter some model data, all this is readily available and the solver should use this for warmstarting based on the previous optimization.&lt;/p&gt;&#xA;&lt;p&gt;With a third-party tool like PuLP, you need to be careful to preserve that information. It may happen that everything is discarded and every new optimization is treated as a completely new task without any information from previous runs. So, using gurobipy directly is a much better approach and provides much more control over what actually happens or should be happening.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2023-12-18T14:05:55.580" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11405" PostTypeId="2" ParentId="11403" CreationDate="2023-12-18T14:10:07.307" Score="1" Body="&lt;p&gt;Introduce a nonnegative integer variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; and minimize &lt;span class=&quot;math-container&quot;&gt;$\sum_j c_j x_j$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$Ax=2y+1$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$Ax=1$&lt;/span&gt; is the system of equality constraints defined in the linked question.  The role of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is to convert an equality in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{F}_2$&lt;/span&gt; to an equality in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}$&lt;/span&gt;, which is what an off-the-shelf MILP solver supports.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-12-18T14:10:07.307" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11406" PostTypeId="1" AcceptedAnswerId="11407" CreationDate="2023-12-18T19:02:01.193" Score="3" ViewCount="95" Body="&lt;p&gt;I have a problem that can be separated into a master problem and two subproblems, SP-A and SP-B. SP-B share some variables with SP-A, and the shared/overlapping variables from SP-A cannot be fixed for SP-B, otherwise it will lose coherence in its formulation. Can this still be addressed under the Benders decomposition framework without integrating the two subproblems?&lt;/p&gt;&#xA;" OwnerUserId="12994" LastEditorUserId="49" LastEditDate="2023-12-18T20:33:09.003" LastActivityDate="2023-12-18T20:42:22.567" Title="How to modify Benders decomposition to handle overlapping or shared variables among the subproblems" Tags="|optimization|mixed-integer-programming|reference-request|benders-decomposition|decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11407" PostTypeId="2" ParentId="11406" CreationDate="2023-12-18T20:42:22.567" Score="3" Body="&lt;p&gt;No not directly. Let's say that there's only one shared variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; between SP-A and SP-B, and that you create 2 subproblems SP-A and SP-B with a local copy of the shared variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, namely &lt;span class=&quot;math-container&quot;&gt;$y_A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_B$&lt;/span&gt;. Next you solve SP-A and SP-B. The optimal solutions to those 2 subproblems may have different values for &lt;span class=&quot;math-container&quot;&gt;$y_A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_B$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$y_A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_B$&lt;/span&gt; were forced to take the same values then the subproblems could return very different solutions as one value of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; might be feasible for one problem but not for the other and vice versa.&lt;/p&gt;&#xA;&lt;p&gt;Two alternatives to overcome this issue:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Fix shared variables in the master problem. As such, these variables become constants in the subproblem.&lt;/li&gt;&#xA;&lt;li&gt;Introduce local copies of the variables, e.g. &lt;span class=&quot;math-container&quot;&gt;$y_A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_B$&lt;/span&gt; in the above example, add the constraint &lt;span class=&quot;math-container&quot;&gt;$y_A=y_B$&lt;/span&gt; and dualize this constraint using a Lagrangian. This decouples your problem. For more details, refer to Lagrangian decomposition.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="49" LastActivityDate="2023-12-18T20:42:22.567" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11409" PostTypeId="1" AcceptedAnswerId="11417" CreationDate="2023-12-19T10:03:42.193" Score="3" ViewCount="911" Body="&lt;p&gt;It is known that a feasible bounded linear program with &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; constraints always has a solution with at most &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; non-zero variables (a &lt;a href=&quot;https://en.wikipedia.org/wiki/Basic_feasible_solution&quot; rel=&quot;nofollow noreferrer&quot;&gt;basic feasible solution&lt;/a&gt;). Since the number of constraints might be much smaller than the number of variables, this solution may be very sparse, which is useful in some applications.&lt;/p&gt;&#xA;&lt;p&gt;My question is whether an analogous result holds for convex &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadratic_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;quadratic programming&lt;/a&gt;?&#xA;I.e., does there always exist a solution in which the number of non-zero variables is bounded by some function of &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;, independently of the number of variables?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="2576" LastEditDate="2023-12-21T08:47:37.507" LastActivityDate="2023-12-21T08:47:37.507" Title="Do convex quadratic problems always have sparse solutions?" Tags="|convex-optimization|quadratic-programming|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11410" PostTypeId="2" ParentId="11409" CreationDate="2023-12-19T15:40:24.403" Score="7" Body="&lt;p&gt;Not in general. In quadratic programming (and in nonlinear programming, more general), we have basic, non-basic and super-basic variables. These superbasics can be interpreted as non-basic but between the bounds. We can end up with a solution with few non-basics (at bound) and many super-basics.&lt;/p&gt;&#xA;&lt;p&gt;Actually, that happens a lot in practice. QP-based portfolio models often have almost all instruments in the portfolio (many with small values). Creating sparse solutions requires binary variables (or something related), to implement a cardinality constrained model.&lt;/p&gt;&#xA;" OwnerUserId="907" LastActivityDate="2023-12-19T15:40:24.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11412" PostTypeId="2" ParentId="11409" CreationDate="2023-12-19T23:41:41.860" Score="14" Body="&lt;p&gt;Consider the convex QP &lt;span class=&quot;math-container&quot;&gt;$$\min \lbrace \sum_{i=1}^n x_i^2 : x\in \mathbb{R}^n, \sum_{i=1}^n x_i = 1\rbrace.$$&lt;/span&gt; The solution is &lt;span class=&quot;math-container&quot;&gt;$$x = (\frac{1}{n},\dots,\frac{1}{n}),$$&lt;/span&gt;which is fully dense.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-12-19T23:41:41.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11413" PostTypeId="2" ParentId="7453" CreationDate="2023-12-20T03:24:52.607" Score="0" Body="&lt;p&gt;Most of the formulas I have come across in queueing theory assume steady state, and I don't know of a purely mathematical approach for all cases. So let me show you a simple simulation approach.&lt;/p&gt;&#xA;&lt;p&gt;Using &lt;a href=&quot;https://ciw.readthedocs.io/en/latest/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ciw&lt;/a&gt;, let us simulate for &lt;span class=&quot;math-container&quot;&gt;$10^4$&lt;/span&gt; jobs.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import ciw&#xA;import pandas as pd&#xA;&#xA;ciw.seed(2018)&#xA;&#xA;&#xA;network = ciw.create_network(&#xA;    arrival_distributions = [ciw.dists.Exponential(1/70)],&#xA;    service_distributions = [ciw.dists.Exponential(1/35)],&#xA;    number_of_servers = [2]&#xA;    )&#xA;&#xA;simulation = ciw.Simulation(network)&#xA;&#xA;simulation.simulate_until_max_customers(10000)&#xA;&#xA;records = pd.DataFrame(simulation.get_all_records())&#xA;&#xA;&#xA;print(&#xA;    (&#xA;        records.waiting_time&#xA;        .describe()&#xA;        .to_markdown()&#xA;        )&#xA;    )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And here are the results.&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&quot;text-align: left;&quot;&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: right;&quot;&gt;waiting_time&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;count&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;10000&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;mean&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;2.14293&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;std&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;9.50576&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;min&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;25%&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;50%&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;75%&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;max&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;161.518&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;And here is a plot of the arrival time vs waiting time:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jZSy0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jZSy0.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10338" LastEditorUserId="10338" LastEditDate="2023-12-23T17:03:54.377" LastActivityDate="2023-12-23T17:03:54.377" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11414" PostTypeId="1" CreationDate="2023-12-20T10:57:48.097" Score="1" ViewCount="34" Body="&lt;p&gt;I have a working - and long - R code to generate a mps file to be read by cplex.&#xA;Because I work with large instances I am finding troubles (too much time) in producing a large mps file.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to take advantage on the mps file generator code to add directly (without need of file generation) the problem into Cplex through Rcplex, for example?&lt;/p&gt;&#xA;&lt;p&gt;This is because I would like to avoid a reprogramming of the problem to callback Cplex using other input styles.&lt;/p&gt;&#xA;" OwnerUserId="12906" LastEditorUserId="491" LastEditDate="2023-12-21T04:52:36.510" LastActivityDate="2023-12-21T04:52:36.510" Title="Calling Cplex from R through a MPS-like file" Tags="|mixed-integer-programming|linear-programming|cplex|r|mps|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11415" PostTypeId="1" CreationDate="2023-12-20T13:20:06.857" Score="3" ViewCount="108" Body="&lt;p&gt;The optimization model is defined as,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\min_{\bf x}\max_{\bf y}f_{0}(y)\\&#xA;s.t.\bf f_1(y)=0\\&#xA;\bf f_2(y)\leq0\\&#xA;\bf f_{3}(x,y)\leq0\\&#xA;\bf f_{4}(x)\leq0&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f_0(y)$&lt;/span&gt; is nonconvex with bilinear terms. &lt;span class=&quot;math-container&quot;&gt;$\bf f_1(y)$&lt;/span&gt; are linear equalities.  &lt;span class=&quot;math-container&quot;&gt;$\bf f_2(y)$&lt;/span&gt; are second order cone constraints.  &lt;span class=&quot;math-container&quot;&gt;$\bf f_3(x,y)$&lt;/span&gt; are linear inequalities.  &lt;span class=&quot;math-container&quot;&gt;$\bf f_4(x)$&lt;/span&gt; are nonconvex inequalities (including indicator function).&lt;/p&gt;&#xA;&lt;p&gt;How can I solve this problem using heuristic algorithms?&lt;/p&gt;&#xA;" OwnerUserId="13002" LastActivityDate="2023-12-20T15:31:28.500" Title="How to solve a min max problem?" Tags="|nonconvex-programming|heuristics|bilevel-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11416" PostTypeId="2" ParentId="11415" CreationDate="2023-12-20T15:31:28.500" Score="2" Body="&lt;p&gt;Do you want to solve it with a tailored heuristic?, or is using a metaheuristic fine? For the second, you could check these links:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A systematic review of metaheuristics: &lt;a href=&quot;https://link.springer.com/article/10.1007/s11831-023-10030-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/article/10.1007/s11831-023-10030-1&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Lectures for Metaheuristics optimization: &lt;a href=&quot;https://iao.hfuu.edu.cn/teaching/lectures/metaheuristic-optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://iao.hfuu.edu.cn/teaching/lectures/metaheuristic-optimization&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Constraint handling techniques for metaheuristics: a state-of-the-art review and new variants: &lt;a href=&quot;https://link.springer.com/article/10.1007/s11081-022-09782-9&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/article/10.1007/s11081-022-09782-9&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you want to code them in Python, check this: &lt;a href=&quot;https://medium.com/analytics-vidhya/optimization-modelling-in-python-metaheuristics-with-constraints-c22b08c487e8&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://medium.com/analytics-vidhya/optimization-modelling-in-python-metaheuristics-with-constraints-c22b08c487e8&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you are using Julia, check this package: &lt;a href=&quot;https://jmejia8.github.io/Metaheuristics.jl/stable/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://jmejia8.github.io/Metaheuristics.jl/stable/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2023-12-20T15:31:28.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11417" PostTypeId="2" ParentId="11409" CreationDate="2023-12-21T01:49:12.693" Score="6" Body="&lt;p&gt;Consider the unconstrained convex QP&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min \|x - x_0\|_2^2.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The solution is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x = x_0&#xA;$$&lt;/span&gt;&#xA;which is also fully dense for dense &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4569" LastActivityDate="2023-12-21T01:49:12.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11418" PostTypeId="1" CreationDate="2023-12-21T06:16:45.583" Score="2" ViewCount="95" Body="&lt;p&gt;I've got to deal with an optimization problem as follows,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\max_{x,y} &amp;amp; a^Tx+y^TKx\\&#xA;{s.t.}&amp;amp;Ax=b\\&#xA;&amp;amp;{Cx}\leq d\\&#xA;l&amp;amp;\leq y\leq u\end{aligned}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x \in \bf{R}^n$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y \in \bf{R}^m$&lt;/span&gt;. An intuitive is that as &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is bounded in &lt;span class=&quot;math-container&quot;&gt;$[l,u]$&lt;/span&gt;, the later term in the objective (&lt;span class=&quot;math-container&quot;&gt;$y^TKx$&lt;/span&gt;) can be rewritten as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{j=1}^{m}\{\max\{(Kx)_j,0\}u_j+\min\{(Kx)_j,0\}l_j\}&#xA;$$&lt;/span&gt;&#xA;How can I incorporate the above expression in the optimization problem to avoid bilinear term?&lt;/p&gt;&#xA;" OwnerUserId="13002" LastEditorUserId="500" LastEditDate="2023-12-22T18:00:13.153" LastActivityDate="2023-12-22T18:00:13.153" Title="How to transfer an objective with separate positive and negative parts into linear programming" Tags="|linear-programming|linearization|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11419" PostTypeId="1" AcceptedAnswerId="11422" CreationDate="2023-12-21T13:40:08.780" Score="6" ViewCount="676" Body="&lt;p&gt;Consider the function &lt;span class=&quot;math-container&quot;&gt;$f : \mathbb R \to \mathbb R$&lt;/span&gt;, which has a unique fixed point &lt;span class=&quot;math-container&quot;&gt;$x^* \in \mathbb R$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$x^* = f(x^*)$&lt;/span&gt; and there does not exist another &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb R$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$x = f(x)$&lt;/span&gt;. If we only knew that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; had a unique fixed point, but didn't know the value of &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt;, could we then compute &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; as the solution of the following optimization problem?&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\max_{x \in \mathcal X} \quad &amp;amp; x \\&#xA;\textrm{s.t.} \quad &amp;amp; x \leq f(x)&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;It seems that the answer is &amp;quot;yes&amp;quot; (but I'd like some feedback on my reasoning): let &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; be the solution to the problem above, such that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\forall x \in \mathbb R, x \leq x^* \tag{1} \\&#xA;x^* \leq f(x^*) \tag{2}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Suppose, for the sake of contradiction, that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is &lt;strong&gt;not&lt;/strong&gt; the unique fixed point of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$x^* \neq f(x^*)$&lt;/span&gt;. Then, from &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x^* &amp;lt; f(x^*) = v$&lt;/span&gt;. However, this contradicts &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, since &lt;span class=&quot;math-container&quot;&gt;$v &amp;gt; x^*$&lt;/span&gt;. Therefore, &lt;span class=&quot;math-container&quot;&gt;$x^* = f(x)$&lt;/span&gt;. Does this seem reasonable?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Update&lt;/h3&gt;&#xA;&lt;p&gt;Based on @ConnFus's answer, it must first be proven that there exists one and only one solution &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; to the optimization problem mentioned above. Otherwise, my proof above falls apart, since it rests on the assumption that &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; exists and is unique.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2023-12-27T10:45:40.807" LastActivityDate="2023-12-27T10:45:40.807" Title="Can determining the unique fixed point of a function be posed as an optimization problem?" Tags="|optimization|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11420" PostTypeId="2" ParentId="11419" CreationDate="2023-12-21T14:00:03.710" Score="4" Body="&lt;p&gt;This is a valid formulation if a global optimizer is used, and it succeeds in finding the global optimum.&lt;/p&gt;&#xA;&lt;p&gt;A local optimizer might fail to find the global optimum, in which case any solution found might not be a fixed point of the original problem.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, you could formulate the optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;max 0 subject to &lt;span class=&quot;math-container&quot;&gt;$x = f(x)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;whose solution, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, if found, is the fixed point you seek. It is possible that a local optimizer might fail to find the fixed point, even it it exists, although the local optimizer should not return a solution which is not a fixed point of the original problem.&lt;/p&gt;&#xA;&lt;p&gt;In summary, your formulation might produce a non-locally optimal solution which is not a fixed point of the original problem. The alternative formulation in my answer should not return a solution which is not a fixed point of the original problem, but if a global optimizer is not used, might fail to find a solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Note that even if &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is convex, the constraint &lt;span class=&quot;math-container&quot;&gt;$x = f(x)$&lt;/span&gt; is non-convex (unless &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; is affine (linear)). Optimization solvers would generally have an easier time dealing with the convex constraint, &lt;span class=&quot;math-container&quot;&gt;$x \le f(x)$&lt;/span&gt;, than the non-convex constraint, &lt;span class=&quot;math-container&quot;&gt;$x = f(x)$&lt;/span&gt;, even if it is known that &lt;span class=&quot;math-container&quot;&gt;$x = f(x)$&lt;/span&gt; is satisfied at the solution.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-12-21T16:52:03.030" LastActivityDate="2023-12-21T16:52:03.030" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11421" PostTypeId="2" ParentId="11419" CreationDate="2023-12-21T21:23:25.903" Score="0" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; be a real function of real variable defined as &lt;span class=&quot;math-container&quot;&gt;$f(x)=x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let consider &lt;span class=&quot;math-container&quot;&gt;$X_1=[0 , 0.5]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_2=[0.5 , 1]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$f:X_1 \rightarrow X_1$&lt;/span&gt; has as solution of the optimization problem &lt;span class=&quot;math-container&quot;&gt;$x_1=0$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$f:X_2 \rightarrow X_2$&lt;/span&gt; has as solution of the optimization problem &lt;span class=&quot;math-container&quot;&gt;$x_2=1$&lt;/span&gt;&#xA;In both cases, &lt;span class=&quot;math-container&quot;&gt;$x_1=0.5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2=1$&lt;/span&gt; are fixed points: &lt;span class=&quot;math-container&quot;&gt;$f(0.5)=0.5$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f(1)=1$&lt;/span&gt;. These two fixed points solve the optimization problem and are not unique! Now, take &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; as the Union of &lt;span class=&quot;math-container&quot;&gt;$X_1$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$X_2$&lt;/span&gt; ...&#xA;It comes out that &lt;span class=&quot;math-container&quot;&gt;$x_2=1$&lt;/span&gt; is the unique solution of the optimization problem in which we seek for the maximum fixed point. Actually, the function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; has more than one fixed point, so we have showed that the following proposition: &lt;em&gt;If &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is a solution of the optimal problem then &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; is the unique fixed point for &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;&lt;/em&gt; is false in general. As a consequence, the problem in finding fixed point is not equivalent to solve an optimization problem.&lt;/p&gt;&#xA;" OwnerUserId="4114" LastEditorUserId="4114" LastEditDate="2023-12-22T08:43:20.333" LastActivityDate="2023-12-22T08:43:20.333" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11422" PostTypeId="2" ParentId="11419" CreationDate="2023-12-22T07:13:16.230" Score="4" Body="&lt;p&gt;If we let &lt;span class=&quot;math-container&quot;&gt;$f(x):=e^x-1$&lt;/span&gt;, then it has the unique fixed point &lt;span class=&quot;math-container&quot;&gt;$x^*=0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However for all &lt;span class=&quot;math-container&quot;&gt;$x\in\mathbb R$&lt;/span&gt; it holds that &lt;span class=&quot;math-container&quot;&gt;$x\le f(x)$&lt;/span&gt;, so the the optimization problem&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\max_{x \in \mathcal X} \quad &amp;amp; x \\&#xA;\textrm{s.t.} \quad &amp;amp; x \leq f(x)&#xA;\end{aligned}&lt;/span&gt;&#xA;has no solution.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Addendum:&lt;/p&gt;&#xA;&lt;p&gt;Let's add the constraint that &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is continuous, because otherwise I think this is a lost cause. Now, let &lt;span class=&quot;math-container&quot;&gt;$x^*$&lt;/span&gt; be the unique fixed point. Then we have either &lt;span class=&quot;math-container&quot;&gt;$$\forall z&amp;gt;x^*:\quad z&amp;lt;f(z)\tag{1}$$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$$\forall z&amp;gt;x^*:\quad z&amp;gt;f(z)\tag{2}$$&lt;/span&gt;In case (2) we are indeed done, but in case (1) the optimization problem misses the fixed point.&lt;/p&gt;&#xA;&lt;p&gt;So let's look at case (1): In it, we have two subcases:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\forall z&amp;lt;x^*:\quad z&amp;lt;f(z)\tag{1.1}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\forall z&amp;lt;x^*:\quad z&amp;gt;f(z)\tag{1.2}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In subcase (1.2) we can change the optimization problem to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\min_{x \in \mathcal X} \quad &amp;amp; x \\&#xA;\textrm{s.t.} \quad &amp;amp; x \leq f(x)&#xA;\end{aligned}&lt;/span&gt;&#xA;and are done.&lt;/p&gt;&#xA;&lt;p&gt;In subcase (1.1) we have that &lt;span class=&quot;math-container&quot;&gt;$\forall z\in\mathbb R:\quad z\le f(z)$&lt;/span&gt; with equality only in &lt;span class=&quot;math-container&quot;&gt;$z=x^*$&lt;/span&gt;. So we can change the optimization problem to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{aligned}&#xA;\max_{x \in \mathcal X} \quad &amp;amp; x-f(x) \\&#xA;\end{aligned}&lt;/span&gt;&#xA;and are done.&lt;/p&gt;&#xA;&lt;p&gt;So, in the end you have to handle 3 cases, artificially restrict &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; to be one of those cases, or use a different optimization problem altogether.&lt;/p&gt;&#xA;" OwnerUserId="13010" LastEditorUserId="13010" LastEditDate="2023-12-23T06:56:13.723" LastActivityDate="2023-12-23T06:56:13.723" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="11423" PostTypeId="1" CreationDate="2023-12-22T10:52:16.717" Score="1" ViewCount="58" Body="&lt;p&gt;What are examples of problems for which the state-of-the-art approach is constraint programming? Considering either heuristic or exact approaches.&lt;/p&gt;&#xA;&lt;p&gt;I'm looking for specific problems, not just a class of problems like &amp;quot;scheduling&amp;quot; problems.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="278" LastEditDate="2023-12-22T12:08:33.423" LastActivityDate="2023-12-22T12:08:33.423" Title="Problems for which constraint programming is the state-of-the-art approach" Tags="|constraint-programming|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11424" PostTypeId="1" CreationDate="2023-12-22T14:24:56.363" Score="1" ViewCount="12" Body="&lt;p&gt;Can anybody point to examples of using open-source discrete event simulation packages (&lt;code&gt;simpy&lt;/code&gt;, &lt;code&gt;salabim&lt;/code&gt;, &lt;code&gt;simmer&lt;/code&gt;, etc.) to model inventory policies for perishable goods?&lt;/p&gt;&#xA;&lt;p&gt;I'm looking to make a proof-of-concept simulation to evaluate push-based stocking decisions under conditions of highly uncertain demand. I could probably code this as series of big if-loops, but wanted to see if there's anything out there to review. All I've seen in Google is academic papers recommending a new algorithm!&lt;/p&gt;&#xA;" OwnerUserId="3958" LastActivityDate="2023-12-22T14:24:56.363" Title="Open-Source DES for perishable goods" Tags="|simulation|supply-chain|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11425" PostTypeId="2" ParentId="11418" CreationDate="2023-12-22T16:50:53.137" Score="2" Body="&lt;p&gt;I'm going to assume that &lt;span class=&quot;math-container&quot;&gt;$\ell \ge 0.$&lt;/span&gt; We introduce nonnegative variables &lt;span class=&quot;math-container&quot;&gt;$0\le w,z \in \mathbb{R}^m$&lt;/span&gt; and binary variables &lt;span class=&quot;math-container&quot;&gt;$v\in \lbrace 0, 1 \rbrace^m$&lt;/span&gt; and convert the objective to maximizing &lt;span class=&quot;math-container&quot;&gt;$a^T x + u^T w - \ell^T z.$&lt;/span&gt; We also add the following constraints, where &lt;span class=&quot;math-container&quot;&gt;$M_j$&lt;/span&gt; is a valid upper bound on &lt;span class=&quot;math-container&quot;&gt;$\vert (Kx)_j \vert:$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Kx - w + z = 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w_j \le M_j v_j \quad\forall j$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_j \le M_j (1-v_j) \quad \forall j.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-12-22T16:50:53.137" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="11426" PostTypeId="1" CreationDate="2023-12-23T04:29:24.833" Score="0" ViewCount="19" Body="&lt;p&gt;I’m interested in understanding how one might design online auctions (think Google, Facebook, eBay, etc.)&lt;/p&gt;&#xA;&lt;p&gt;I’m curious how the price of a physical item, ad, NFT, etc might be a function of economic actors interests and behaviors.&lt;/p&gt;&#xA;&lt;p&gt;This seems to be both a statistical inference problem and an optimization problem (hence interested in the OR perspective.)&lt;/p&gt;&#xA;&lt;p&gt;Could you reference in relevant books or courses?&lt;/p&gt;&#xA;" OwnerUserId="10326" LastActivityDate="2023-12-23T04:29:24.833" Title="Online auction system design resources" Tags="|optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11428" PostTypeId="1" AcceptedAnswerId="11429" CreationDate="2023-12-23T09:37:43.287" Score="0" ViewCount="87" Body="&lt;p&gt;I'm currently reading the following paper&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;B. Sinopoli, L. Schenato, M. Franceschetti, K. Poolla, M. I. Jordan, and S. S. Sastry, “Kalman filtering with intermittent observations,” IEEE Transactions on Automatic Control, vol. 49, no. 9, pp. 1453–1464, Sep. 2004, doi: 10.1109/TAC.2004.834121.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In Corollary 1 of Theorem 5 on page 1456 (right column), the authors consider the following optimization problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;\begin{aligned}&#xA;\min_{\lambda,Y,Z} \quad &amp;amp; \lambda \\&#xA;\textrm{s.t.} \quad &amp;amp; 0 \leq \lambda \leq 1 \\&#xA;\quad &amp;amp; \Psi(\lambda,A,C,Y,Z) \succ 0 \\&#xA;\quad &amp;amp; 0 \preceq Y \preceq I&#xA;\end{aligned}&#xA;\end{equation}&lt;/span&gt;&#xA;where&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\Psi(\lambda,A,C,Y,Z) = \begin{bmatrix}Y &amp;amp; \sqrt{\lambda}(YA + ZC) &amp;amp; \sqrt{1-\lambda}YA \\ \sqrt{\lambda}(A^T Y + C^T Z^T) &amp;amp; Y &amp;amp; 0 \\ \sqrt{1-\lambda}A^T Y &amp;amp; 0 &amp;amp; Y\end{bmatrix}&#xA;$$&lt;/span&gt;&#xA;The matrices &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; are given as constant inputs and the matrices &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; are variables. The authors then write that this is a quasi-convex optimization problem in the variables &lt;span class=&quot;math-container&quot;&gt;$(\lambda,Y,Z)$&lt;/span&gt; and that the solution can be obtained by iterating linear matrix inequality (LMI) feasibility problems and using bisection for the variable &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;, as shown in the book &amp;quot;Linear Matrix Inequalities in System and Control Theory&amp;quot; by Boyd et al.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, the authors do not mention where in Boyd's book they are referring to. I'm also not sure why this is a quasi-convex problem, since the matrix variable &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; isn't necessarily positive semi-definite (so the feasible set does not consist only of the set of positive semi-definite matrices). I initially thought that this can be re-written as a generalized eigenvalue problem, but I'm not sure.&lt;/p&gt;&#xA;&lt;p&gt;Any suggestions on why this is a quasi-convex problem and how it can be solved?&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2023-12-23T12:58:59.727" LastActivityDate="2023-12-23T14:01:45.730" Title="How is this problem quasi-convex?" Tags="|convex-optimization|semidefinite-programming|disciplined-quasiconvex-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11429" PostTypeId="2" ParentId="11428" CreationDate="2023-12-23T13:48:43.507" Score="2" Body="&lt;p&gt;I won't prove the paper's claim that the optimization problem is quasiconvex. However, the problem is clearly a convex Linear SDP (LMI) for any fixed value of &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;. That does not require &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; to be positive semidefinite, or even symmetric or square (note the the transpose on the &amp;quot;transposed&amp;quot; occurrence of &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://web.stanford.edu/%7Eboyd/cvxbook/bv_cvxbook.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Algorithm 4.1 &amp;quot;Bisection method for quasiconvex optimization&amp;quot; in &amp;quot;Convex Optimization&amp;quot; by Boyd and Vandenberghe&lt;/a&gt; shows the bisection algorithm for solving quasiconvex optimization problems. It should be easy to implement the bisection algorithm for this problem in any DCP (Disciplined Convex Programming) convex optimization tool, such as CVX, CVXPY, CVXR, and YALMIP.  It can be handled even more easily using &lt;a href=&quot;https://www.cvxpy.org/tutorial/dqcp/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;CVXPY's Disciplined Quasiconvex Programming&lt;/a&gt; capability (DQCP), which implements the bisection algorithm for you under the hood.&lt;/p&gt;&#xA;&lt;p&gt;This reference may slightly post-date the finalization of the paper; hence why it was not provided in the paper.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2023-12-23T14:01:45.730" LastActivityDate="2023-12-23T14:01:45.730" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="11430" PostTypeId="1" AcceptedAnswerId="11431" CreationDate="2023-12-23T15:48:00.740" Score="0" ViewCount="128" Body="&lt;p&gt;I am implementing a Column Generation algorithm to solve a set partitioning problem. The master problem takes the form :&#xA;&lt;span class=&quot;math-container&quot;&gt;$\min \sum_{i \in I} c_i \lambda_i$&lt;/span&gt;&lt;br /&gt;&#xA;s.t&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in I} a_{ji} \lambda_i = 1, \forall j \in J, \text{(each element $j$ can be partitioned to exactly one partition $i$)}\\ \lambda_i \in \{0,1\}$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; is the set of elements to be partitioned, &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; set of all partitions, &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; the cost of partition &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, binary parameter &lt;span class=&quot;math-container&quot;&gt;$a_{ji} =1$&lt;/span&gt; if element &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is in partition &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, and each column &lt;span class=&quot;math-container&quot;&gt;$\lambda_i$&lt;/span&gt; is a binary variable equals 1 if partition &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is selected in the optimal solution.&lt;/p&gt;&#xA;&lt;p&gt;After relaxing the integrality constraint on &lt;span class=&quot;math-container&quot;&gt;$\lambda_i$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$\pi_j$&lt;/span&gt; be the dual variable of each partitioning constraint. Using this dual info, a pricing problem which is solved exactly through a MILP model to find one or more new columns with negative reduced cost : &lt;span class=&quot;math-container&quot;&gt;$\hat{c_i} = c_i - \sum_{j \in J} a_{ij} \pi_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However the problem I have, is that after comparing the solution of CG approach to a brute force method (full enumeration of all partitions for small instance), i found out that for example one column that was not added to the master problem because it has a positive reduced cost (&lt;span class=&quot;math-container&quot;&gt;$c_i &amp;gt; \sum_{j \in J} a_{ij} \pi_i$&lt;/span&gt;) appeared in the optimal solution of the SPP in the brute force method. Which is quite surprising.&lt;/p&gt;&#xA;&lt;p&gt;I would like to know if anyone has dealt with the same issue? or is there something I am overlooking here? If needed I can provide you with a small example.&lt;/p&gt;&#xA;" OwnerUserId="11022" LastEditorUserId="500" LastEditDate="2023-12-23T18:25:45.457" LastActivityDate="2023-12-23T18:25:45.457" Title="Question on Column generation" Tags="|optimization|mixed-integer-programming|linear-programming|column-generation|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11431" PostTypeId="2" ParentId="11430" CreationDate="2023-12-23T15:57:53.007" Score="1" Body="&lt;p&gt;I have seen such behavior when relaxing &lt;span class=&quot;math-container&quot;&gt;$\lambda_i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt;, because the reduced cost calculation does not include the dual variable that corresponds to the (redundant) upper bound &lt;span class=&quot;math-container&quot;&gt;$\lambda_i \le 1$&lt;/span&gt;.  Try relaxing to &lt;span class=&quot;math-container&quot;&gt;$\lambda_i \ge 0$&lt;/span&gt; instead.&lt;/p&gt;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://or.stackexchange.com/questions/608/variable-bounds-in-column-generation&quot;&gt;Variable bounds in column generation&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-12-23T15:57:53.007" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11432" PostTypeId="1" CreationDate="2023-12-24T15:06:49.163" Score="3" ViewCount="226" Body="&lt;p&gt;I am an electrical engineer who is working in network problem and I was trying to solve a multi objective function&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{array}{*{20}{c}}&#xA;{\min }&amp;amp;{{f_1}\left( x \right)}\\&#xA;\end{array}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{array}{*{20}{c}}&#xA;{\min }&amp;amp;{{f_2}\left( x \right)}\\&#xA;\end{array}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In my application, the complete pareto front is not needed and scalarization (weighted sum approximation) is the right way to go. That is, to solve this problem with two given weights &lt;span class=&quot;math-container&quot;&gt;$w_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;${w_2} = 1 - {w_1}$&lt;/span&gt; instead.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{array}{*{20}{c}}&#xA;{\min }&amp;amp;{{w_1}{f_1}\left( x \right) + {w_2}{f_2}\left( x \right)}&#xA;\end{array}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that the value of &lt;span class=&quot;math-container&quot;&gt;$w_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_2$&lt;/span&gt; are already given. What I am trying to do here is to minimize both the delay and the number of resource block in the network.&lt;/p&gt;&#xA;&lt;p&gt;Here &lt;span class=&quot;math-container&quot;&gt;${{f_1}\left( x \right)}$&lt;/span&gt; is some delay that is in nano or mili second. On the other hand &lt;span class=&quot;math-container&quot;&gt;${{f_2}\left( x \right)}$&lt;/span&gt; is some resource block so it may be 1,2,3,4....&lt;/p&gt;&#xA;&lt;p&gt;My problem is that if I convert &lt;span class=&quot;math-container&quot;&gt;${{f_1}\left( x \right)}$&lt;/span&gt; to second then this number will be very small compare to &lt;span class=&quot;math-container&quot;&gt;${{f_2}\left( x \right)}$&lt;/span&gt;. To be honest, I want to avoid the issue of &lt;span class=&quot;math-container&quot;&gt;${f_1}\left( x \right) \ll {f_2}\left( x \right)$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;${f_1}\left( x \right) \gg {f_2}\left( x \right)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;1/ Therefore, what should I do to choose a proper scaling for my scalarization problem so that it does not lean toward the larger &lt;span class=&quot;math-container&quot;&gt;${{f_2}\left( x \right)}$&lt;/span&gt; function.&lt;/p&gt;&#xA;&lt;p&gt;2/ Approximating the number &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$0 \le {f_1}\left( x \right) \le {\rm{N}}$&lt;/span&gt; is very difficult. In contrast, approximating the number &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$0 \le {f_2}\left( x \right) \le {\rm{M}}$&lt;/span&gt; is very easy due to my domain knowledge. Although the bound is not sharp but I can guess it very well.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, can I use this knowledge to scale the function &lt;span class=&quot;math-container&quot;&gt;${f_1}\left( x \right)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;${f_2}\left( x \right)$&lt;/span&gt; in question 1 so that the scalarization problem does not lean toward  &lt;span class=&quot;math-container&quot;&gt;${f_2}\left( x \right)$&lt;/span&gt; ?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{array}{*{20}{c}}&#xA;{\min }&amp;amp;{{w_1}\left[ {\underbrace {{\rm{scalin}}{{\rm{g}}_{\rm{1}}}}_?{f_1}\left( x \right)} \right] + {w_2}\left[ {\underbrace {{\rm{scalin}}{{\rm{g}}_{\rm{2}}}}_?{f_2}\left( x \right)} \right]}&#xA;\end{array}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that I want to scale &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt; first so that they are as big as another. The weight &lt;span class=&quot;math-container&quot;&gt;$w_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w_2$&lt;/span&gt; are given latter and currently are &lt;strong&gt;not important&lt;/strong&gt; at this moment.&lt;/p&gt;&#xA;&lt;p&gt;Thank you for your enthusiasm !&lt;/p&gt;&#xA;" OwnerUserId="11163" LastEditorUserId="11163" LastEditDate="2023-12-26T02:31:37.967" LastActivityDate="2024-01-03T14:08:34.413" Title="Problem of scaling or normalizing in multiobjective optimization problem when one objective function is much larger than the other?" Tags="|multi-objective-optimization|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11433" PostTypeId="2" ParentId="11432" CreationDate="2023-12-24T16:35:19.767" Score="4" Body="&lt;p&gt;I would suggest that you start by asking yourself (or the boss) &lt;em&gt;why&lt;/em&gt; you want to reduce delay and &lt;em&gt;why&lt;/em&gt; you want to reduce resource use. Ideally, these will translate into some sort of tangible costs. You can then scale so that tradeoffs in the objective make sense (i.e., the solver is indifferent between competing solutions that in fact have equivalent overall costs).&lt;/p&gt;&#xA;&lt;p&gt;If that cannot be done, another possibility is to explore tradeoffs with the person ultimately responsible for the decision. Ask questions like &amp;quot;how much additional use of this resource would you be comfortable with if it reduced this delay by 1 ms.?&amp;quot; Use the decision maker's preference for tradeoffs to scale the objective.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-12-24T16:35:19.767" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11434" PostTypeId="1" CreationDate="2023-12-25T11:48:40.010" Score="0" ViewCount="52" Body="&lt;p&gt;Why is the Lagrange multiplier associated to an active inequality constraint is positive.&#xA;How can we see this from the KKT conditions?&lt;/p&gt;&#xA;" OwnerUserId="4735" LastActivityDate="2023-12-25T16:29:40.823" Title="Lagrange multiplier associated to an active inequality constraint" Tags="|convex-optimization|duality|lagrange-multipliers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11435" PostTypeId="2" ParentId="11434" CreationDate="2023-12-25T12:25:38.060" Score="2" Body="&lt;p&gt;It is not true that the Lagrange multiplier, &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;, associated with constraint &lt;span class=&quot;math-container&quot;&gt;$g(x) \le 0$&lt;/span&gt; which is active (i.e., satisfies &lt;span class=&quot;math-container&quot;&gt;$g(x) = 0$&lt;/span&gt;) is necessarily positive at an optimum.&lt;/p&gt;&#xA;&lt;p&gt;Presuming a constraint qualification holds, as does the required continuous differentiability, and therefore that the KKT conditions are necessary for optimality, it is true that complementary slackness must hold at an optimum. That is, &lt;span class=&quot;math-container&quot;&gt;$\lambda g(x) = 0$&lt;/span&gt;. Complementary slackness does not force &lt;span class=&quot;math-container&quot;&gt;$g(x) = 0$&lt;/span&gt; (constraint is active) to require &lt;span class=&quot;math-container&quot;&gt;$\lambda = 0$&lt;/span&gt;. However, if the constraint is inactive,. i.e. &lt;span class=&quot;math-container&quot;&gt;$g(x) &amp;lt; 0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; must equal &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; at an optimum, otherwise, complementary slackness would be violated.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="67" LastEditDate="2023-12-25T16:29:40.823" LastActivityDate="2023-12-25T16:29:40.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11436" PostTypeId="1" AcceptedAnswerId="11437" CreationDate="2023-12-26T19:37:13.443" Score="0" ViewCount="62" Body="&lt;p&gt;In MIP, I have a constraint that is validated only if the demand &lt;span class=&quot;math-container&quot;&gt;$d_i\leq Q$&lt;/span&gt;:&#xA;C1 : &lt;span class=&quot;math-container&quot;&gt;$d_i \leq x_i \leq Q$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$x_i \geq 0$&lt;/span&gt;. I tried to introduce big M with binary variables as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$My \leq x_i \leq Q - d_i$&lt;/span&gt; Where &lt;span class=&quot;math-container&quot;&gt;$M=|Q-\min{(d_i)}|$&lt;/span&gt;&#xA;The problem where &lt;span class=&quot;math-container&quot;&gt;$d_i &amp;gt; Q$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is equal to zero but if &lt;span class=&quot;math-container&quot;&gt;$d_i \leq Q$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; should be between &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt;. Any help please to how formulate this constraint.&#xA;Thank you&lt;/p&gt;&#xA;" OwnerUserId="10962" LastEditorUserId="4569" LastEditDate="2023-12-27T09:15:45.210" LastActivityDate="2023-12-27T09:15:45.210" Title="MIP binary decision value under a condition if else" Tags="|mixed-integer-programming|big-m|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11437" PostTypeId="2" ParentId="11436" CreationDate="2023-12-26T22:50:40.407" Score="3" Body="&lt;p&gt;I'm going to drop the subscript &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to save a little typing, and I will assume that both &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; are nonnegative (which was not actually stated). I will also assume that &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is a constant. &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; can be either a constant or a variable. Given a valid upper bound &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; (presumably &lt;span class=&quot;math-container&quot;&gt;$\ge Q)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$d,$&lt;/span&gt; we introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; together with the constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$d \le Qy + M(1-y)\quad (1)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$d \ge Q(1-y)\quad (2)$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$0 \le x \le Qy \quad (3)$$&lt;/span&gt;&#xA;and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x \ge d-M(1-y). \quad (4)$$&lt;/span&gt;&#xA;If &lt;span class=&quot;math-container&quot;&gt;$y=1,$&lt;/span&gt; then (1) and (2) imply &lt;span class=&quot;math-container&quot;&gt;$0 \le d \le Q$&lt;/span&gt; and (3) and (4) imply &lt;span class=&quot;math-container&quot;&gt;$d \le x \le Q.$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$y=0,$&lt;/span&gt; then (1) and (2) imply &lt;span class=&quot;math-container&quot;&gt;$Q \le d \le M$&lt;/span&gt; and (3) and (4) imply &lt;span class=&quot;math-container&quot;&gt;$x = 0.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$d = Q$&lt;/span&gt; can occur with either value of &lt;span class=&quot;math-container&quot;&gt;$y,$&lt;/span&gt; meaning &lt;span class=&quot;math-container&quot;&gt;$d=Q$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x=0$&lt;/span&gt; is feasible (with &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt;). Depending on the objective function and the rest of the model, this many not be a problem. If it is, your best recourse is to change (2) to &lt;span class=&quot;math-container&quot;&gt;$$d \ge (Q+\epsilon)(1-y)\quad (2')$$&lt;/span&gt;for some small positive value of &lt;span class=&quot;math-container&quot;&gt;$\epsilon.$&lt;/span&gt; This will ensure that &lt;span class=&quot;math-container&quot;&gt;$y=0$&lt;/span&gt; (and thus &lt;span class=&quot;math-container&quot;&gt;$x=0)$&lt;/span&gt; occurs only when &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is strictly greater than &lt;span class=&quot;math-container&quot;&gt;$Q.$&lt;/span&gt; Unfortunately, it will also make any solution with &lt;span class=&quot;math-container&quot;&gt;$Q &amp;lt; d &amp;lt; Q+\epsilon$&lt;/span&gt; infeasible.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-12-26T22:50:40.407" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11438" PostTypeId="1" CreationDate="2023-12-27T09:13:38.153" Score="1" ViewCount="186" Body="&lt;p&gt;To provide a clear description of my problem, let me outline the scenario. I have a binary variable &lt;span class=&quot;math-container&quot;&gt;$\phi_{k,c}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is an index belonging to the set &lt;span class=&quot;math-container&quot;&gt;$\{1, 2, 3, ..., 9\}$&lt;/span&gt;. As an example, for a specific value of &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;, the variable &lt;span class=&quot;math-container&quot;&gt;$\phi_{k,c}$&lt;/span&gt; might take the following binary sequence: &lt;span class=&quot;math-container&quot;&gt;$0 0 0 1 0 0 1 0 1$&lt;/span&gt;. My objective is to formulate a constraint in AMPL that selects the minimum value of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$\phi_{k,c}$&lt;/span&gt; equals &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;. In the provided example, I would like to capture the fact that the first occurrence of &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in the array corresponds to &lt;span class=&quot;math-container&quot;&gt;$k = 4$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The expression I have in mind is &lt;span class=&quot;math-container&quot;&gt;$k_{min}(c) = \min\{k \; | \; \phi_{k,c} = 1\}$&lt;/span&gt;. However, this doesn't seem to be a well-defined mathematical formula.&lt;/p&gt;&#xA;&lt;p&gt;I am seeking your assistance in formulating a mathematical constraint in AMPL that accurately represents the selection of the minimum value of &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; when &lt;span class=&quot;math-container&quot;&gt;$\phi_{k,c}$&lt;/span&gt; equals &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10082" LastEditorUserId="36" LastEditDate="2023-12-27T13:40:02.680" LastActivityDate="2024-01-27T22:05:50.710" Title="Formulating a constraint to select the minimum value of an index" Tags="|mixed-integer-programming|modeling|ampl|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11439" PostTypeId="2" ParentId="11438" CreationDate="2023-12-27T10:45:33.210" Score="0" Body="&lt;p&gt;The index of the non zero &lt;span class=&quot;math-container&quot;&gt;$\phi_{k,c}$&lt;/span&gt; variable is given by a variable &lt;span class=&quot;math-container&quot;&gt;$x_{k,c} \in \mathbb{R}^+$&lt;/span&gt; with constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x_{k,c} = k \cdot \phi_{k,c} \quad \mbox{for each $k,c$} \tag{1}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You want the minimum of all (non zero) &lt;span class=&quot;math-container&quot;&gt;$x_{k,c}$&lt;/span&gt; variables. You can introduce variable &lt;span class=&quot;math-container&quot;&gt;$z_c \in \mathbb{R}^+$&lt;/span&gt; and add constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;z_c \le x_{k,c}+9(1-\phi_{k,c})  \quad \mbox{for each $k,c$} \tag{2}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can maximize &lt;span class=&quot;math-container&quot;&gt;$z_c$&lt;/span&gt; to make sure that &lt;span class=&quot;math-container&quot;&gt;$z_c$&lt;/span&gt; actually reaches one of the &lt;span class=&quot;math-container&quot;&gt;$x_{k,c}$&lt;/span&gt; variables.&lt;/p&gt;&#xA;&lt;p&gt;But this may not be possible (depending on the nature of your problem which is not explicitly described). In this case you can define extra binary variables &lt;span class=&quot;math-container&quot;&gt;$\delta_{k,c} \in \{0,1\}$&lt;/span&gt; that take value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$z_c$&lt;/span&gt; matches value &lt;span class=&quot;math-container&quot;&gt;$x_{k,c}$&lt;/span&gt; and add constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{k,c} - k(1-\delta_{k,c}) &amp;amp;\le z_c  \quad &amp;amp;\mbox{for each $k,c$} \tag{3} \\&#xA;\delta_{k,c} &amp;amp;\le \phi_{k,c} \quad &amp;amp;\mbox{for each $k,c$} \tag{4} \\&#xA;\sum_{k} \delta_{k,c} &amp;amp;= 1 \quad &amp;amp;\mbox{for each $c$}  \tag{5} \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Equation &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; enforces that exactly one of the &lt;span class=&quot;math-container&quot;&gt;$\delta_{k,c}$&lt;/span&gt; variables takes value &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, thus enforcing with &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; that exactly one index &lt;span class=&quot;math-container&quot;&gt;$x_{k,c}$&lt;/span&gt; is reached by &lt;span class=&quot;math-container&quot;&gt;$z_c$&lt;/span&gt;. Constraint &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; makes sure that &lt;span class=&quot;math-container&quot;&gt;$\phi_{k,c}=0 \implies \delta_{k,c} = 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here is small example of how to achieve this with &lt;a href=&quot;https://coin-or.github.io/pulp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PuLP&lt;/a&gt; (for a unique value &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; which is implicit in what follows):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pulp&#xA;import random&#xA;&#xA;# sequence length&#xA;N = 9&#xA;&#xA;# problem definition&#xA;prob = pulp.LpProblem(&amp;quot;first_one&amp;quot;, pulp.LpMaximize)&#xA;&#xA;# variables&#xA;phi = pulp.LpVariable.dicts(&amp;quot;sequence&amp;quot;, [k for k in range(1,N+1)], cat=pulp.LpBinary)&#xA;x = pulp.LpVariable.dicts(&amp;quot;index&amp;quot;, [k for k in range(1,N+1)], lowBound=0, cat=pulp.LpContinuous)&#xA;z = pulp.LpVariable(&amp;quot;z&amp;quot;, lowBound=0, cat=pulp.LpContinuous)&#xA;&#xA;# objective function&#xA;prob += z&#xA;&#xA;# constraints&#xA;for k in x:&#xA;    # define the index of non zero phi variables&#xA;    prob += x[k] == k*phi[k]&#xA;    # capture smallest index of non zero phi variable&#xA;    prob += z &amp;lt;= x[k] + N*(1-phi[k])&#xA;&#xA;# randomly force 3 phi variables to take value 1&#xA;for _ in range(3):&#xA;    k = random.choice([_ for _ in range(1, N+1)])&#xA;    prob += phi[k] == 1&#xA;&#xA;# solve problem&#xA;prob.solve()&#xA;&#xA;# display phi variables&#xA;for k in phi:&#xA;    print(k,pulp.value(phi[k]))&#xA;&#xA;# display smallest index of non zero phi variable&#xA;print(&amp;quot;smallest index: &amp;quot;,pulp.value(z))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2023-12-27T20:03:10.367" LastActivityDate="2023-12-27T20:03:10.367" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11440" PostTypeId="2" ParentId="11438" CreationDate="2023-12-27T15:03:21.033" Score="0" Body="&lt;p&gt;lets suppose &lt;span class=&quot;math-container&quot;&gt;$x_c$&lt;/span&gt; is the variable we need is an integer between [1,9]&lt;br /&gt;&#xA;assume &lt;span class=&quot;math-container&quot;&gt;$\beta_{kc}$&lt;/span&gt; is binary, this will start taking value 1 from the first occurance of &lt;span class=&quot;math-container&quot;&gt;$\Phi_{kc}=1$&lt;/span&gt; till end&lt;br /&gt;&#xA;cons 1:  &lt;span class=&quot;math-container&quot;&gt;$$ \beta_{kc}  \leq \sum_1^k\Phi_{kc} \hspace{1 cm} \forall k,c$$&lt;/span&gt;&lt;br /&gt;&#xA;cons 2:  &lt;span class=&quot;math-container&quot;&gt;$$   \Phi_{kc}\leq 9\beta_{kc} \hspace{1 cm} \forall k,c$$&lt;/span&gt;&lt;br /&gt;&#xA;cons 3:  &lt;span class=&quot;math-container&quot;&gt;$$ x_c  \leq k\beta_{kc} + 9(1-\beta_{kc}) \hspace{1 cm} \forall k,c$$&lt;/span&gt;&lt;br /&gt;&#xA;cons 4:  &lt;span class=&quot;math-container&quot;&gt;$$ 1+k(1-\beta_{kc}) \leq x_c \hspace{1 cm} \forall k,c$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for your example &lt;span class=&quot;math-container&quot;&gt;$\Phi_{kc}$&lt;/span&gt; taking values 000100101&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\beta_{kc}$&lt;/span&gt; will be 000111111&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_c$&lt;/span&gt; is forced to take 4 because of constraints 3,4&lt;/p&gt;&#xA;" OwnerUserId="13026" LastActivityDate="2023-12-27T15:03:21.033" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11441" PostTypeId="1" CreationDate="2023-12-28T00:13:07.350" Score="0" ViewCount="58" Body="&lt;p&gt;I am working on a workforce scheduling problem where we want to come up with an intelligent way to identify a set of shift candidates that is just enough to cover all labor demand but also flexible enough to avoid over coverages and adheres to worker preferences. So we have decided to use historical shifts data to predict such set. But it's not just a prediction problem; in addition to predicting the well suited candidates we need to get a smallest such set that covers the labor demand while adhering to other constraints. So was thinking of using the JANOS framework discussed in this paper &lt;a href=&quot;https://arxiv.org/abs/1911.09461&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/1911.09461&lt;/a&gt;. While formulating it as per this paper, I could only use the prediction output as the decision vars but not the features. My formulation looks like this:&lt;/p&gt;&#xA;&lt;p&gt;Minimize Sum(y_i)&lt;/p&gt;&#xA;&lt;p&gt;s.t.&lt;/p&gt;&#xA;&lt;p&gt;y_i = f(X) (X is the features vector)&lt;/p&gt;&#xA;&lt;p&gt;Sum(c_ij*y_i) = D_j (c_ij indicates if y_i qualifies for demand D_j)&lt;/p&gt;&#xA;&lt;p&gt;y_i: binary variable (prediction output from a ML model)&lt;/p&gt;&#xA;" OwnerUserId="12862" LastEditorUserId="12862" LastEditDate="2023-12-28T17:45:27.853" LastActivityDate="2023-12-28T17:45:27.853" Title="Workforce scheduling optimization using ML model output" Tags="|mixed-integer-programming|scheduling|machine-learning|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11442" PostTypeId="1" AcceptedAnswerId="11444" CreationDate="2023-12-28T00:51:48.560" Score="1" ViewCount="106" Body="&lt;p&gt;I'm working on an integer programming problem that's fundamentally a &lt;a href=&quot;https://en.wikipedia.org/wiki/Multi-commodity_flow_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;minimum cost multicommodity flow&lt;/a&gt; (MCMF) problem with additional constraints. I'm exploring the use of column generation to solve it, building upon the path-based formulation presented in &lt;a href=&quot;https://transp-or.epfl.ch/courses/Gendron2016/Papers/BarnhartHaneVance2000.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this open-access article&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$min \sum_{k \in K}\sum_{p \in P(k)} c_p^ky_p^k $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$s.t:$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{k \in K}\sum_{p \in P(k)} y_p^k\delta_{ij}^p \leqslant d_{ij}, \forall ij \in A $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$     \sum_{p \in P(k)} y_p^k = 1, \forall k \in K $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$     y_p^k \in \{0,1\}, \forall p \in P(k), \forall k \in K $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where &lt;span class=&quot;math-container&quot;&gt;$y_p^k$&lt;/span&gt; is a binary decision variable that equals &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if the commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; routed through path &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; whose cost is &lt;span class=&quot;math-container&quot;&gt;$c_p^k$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$P(k)$&lt;/span&gt; is the set of paths through which commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; can be routed. &lt;span class=&quot;math-container&quot;&gt;$\delta_{ij}^p$&lt;/span&gt; is equal to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if edge &lt;span class=&quot;math-container&quot;&gt;$ij$&lt;/span&gt; is on path &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;, otherwise is equal to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$d_{ij}$&lt;/span&gt; is the capacity of edge &lt;span class=&quot;math-container&quot;&gt;$ij$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My problem has the following unique characteristics:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Commodity types:&lt;/strong&gt; Commodities are partitioned into three distinct types: &lt;span class=&quot;math-container&quot;&gt;$K_{t_1}, K_{t_2}, K_{t_3}$&lt;/span&gt;, in other words: &lt;span class=&quot;math-container&quot;&gt;$K = K_{t_1} \cup K_{t_2}&#xA;    \cup K_{t_3}$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Type-exclusive edge usage:&lt;/strong&gt; Flows belonging to different types must not share edges.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To enforce this edge exclusivity, I've introduced binary variables &lt;span class=&quot;math-container&quot;&gt;$V_{ij}^t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$t \in \{t_1, t_2, t_3\}, \forall ij \in A$&lt;/span&gt;, indicating whether edge &lt;span class=&quot;math-container&quot;&gt;$ij$&lt;/span&gt; is assigned to type &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. The constraints are as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1. Edge assignment constraint:&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{t \in \{t_1, t_2, t_3\}} V_{ij}^t = 1, \forall ij \in A$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;2. Flow compatibility constraint:&lt;/strong&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{k \in K_t} \sum_{p \in P(k)} \delta_{ij}^k y_p^k \leqslant V_{ij}^t d_{ij}, \forall K_t \in \{K_{t_1}, K_{t_2}, K_{t_3}\}, \forall ij \in A$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My questions are:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is column generation still applicable to this modified problem structure?&lt;/li&gt;&#xA;&lt;li&gt;If so, how do these additional constraints, particularly the edge assignment constraint (1), impact the pricing problem and other aspects of the column generation procedure?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13028" LastEditorUserId="13028" LastEditDate="2023-12-28T08:07:38.953" LastActivityDate="2023-12-28T15:17:18.437" Title="Column generation for solving minimum cost multicommodity flow problem with additional edge disjoint constraints" Tags="|optimization|mixed-integer-programming|network-flow|column-generation|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11443" PostTypeId="1" CreationDate="2023-12-28T11:37:04.440" Score="0" ViewCount="91" Body="&lt;p&gt;I am solving a sequencing problem &lt;code&gt;x[i][j]&lt;/code&gt;, i.e. a binary matrix indicating that product &lt;code&gt;i&lt;/code&gt; is followed by &lt;code&gt;j&lt;/code&gt;. Each product is to be exactly scheduled once each, and &lt;code&gt;i&lt;/code&gt; must be before &lt;code&gt;j&lt;/code&gt; if &lt;code&gt;x[i][j] = 1&lt;/code&gt;, which is enforced by auxiliary variable &lt;code&gt;p[i]&lt;/code&gt;. This decision variable shows the index of the i-th element or row in the sequence. For the example below, &lt;code&gt;p[i]&lt;/code&gt;, would be [0  2  1  4  5], read as entity/row 1 is in the 0th index in the sequence, entity or row 2 is at the 2nd index in the sequence, entity or row 3 at the 1st  index of the sequence and so on. I wrote this optimization in PuLP / Python.&lt;/p&gt;&#xA;&lt;p&gt;So far, this problem works, but for some reason, I want to combine/integrate it into another problem. For this new problem, I need the exact sequence as in &lt;code&gt;x[i][j]&lt;/code&gt; as a decision variable.&lt;/p&gt;&#xA;&lt;p&gt;So, using constraints, I want to establish the produced sequence as another decision variable. Going by the example below (codeblock), this would be an array like [1 3 2 4 5] when counting from 1. This decision variable I want to call &lt;code&gt;o[i]&lt;/code&gt;.&#xA;I could not figure out how to establish &lt;code&gt;o[i]&lt;/code&gt; as a decision variable using only linear constraints on the given variables.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;example is below in the code block&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have excluded my initial solution and costs function for privacy reasons!&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# the decision variable is a succesion matrix of i by j, i.e. whether i is followed by j&#xA;    x = LpVariable.dicts(&amp;quot;transition&amp;quot;, (range(N), range(N)), 0, 1, cat='Binary')&#xA;    &#xA;    # example x[i][j], which is N by N&#xA;    # [0 0 1 0 0]&#xA;    # [0 0 0 1 0]&#xA;    # [0 1 0 0 0]&#xA;    # [0 0 0 0 1]&#xA;    # [0 0 0 0 0]&#xA;    #&#xA;    # read as (row) i is succeeded by (column) j&#xA;    # so, since the 1st column has no predecessor  (column sum 0) , it is the initial product&#xA;    # thus, starting in row 1, it can be observed that the sucessor is column 3, so product 3&#xA;    # so 1 -&amp;gt; 3, now do the same for row 3, 1 -&amp;gt; 3 -&amp;gt; 2&#xA;    # the order in this example is 1 -&amp;gt; 3 -&amp;gt; 2 -&amp;gt; 4 -&amp;gt; 5&#xA;    &#xA;    &#xA;    &#xA;    # auxiliary variable to enforce a single starting point&#xA;    #u = LpVariable.dicts(&amp;quot;position&amp;quot;, range(N), 1, N)&#xA;    &#xA;    # axuiliary variable to maintain position integrity&#xA;    # p[i] variables (integer: position of entity i in the loop)&#xA;    p = LpVariable.dicts(&amp;quot;position&amp;quot;, range(N), lowBound=0, upBound=N-1, cat='Integer')&#xA;    &#xA;&#xA;    prob.setObjective(costs)&#xA;    &#xA;    &#xA;    # constraint 1: each product has exactly one sucessor&#xA;    # we do not enforce this hard, since the last scheduled has no successor&#xA;    for i in range(N):&#xA;        prob += lpSum(x[i][j] for j in range(N)) &amp;lt;= 1&#xA;&#xA;    # constraint 2: each product is preceded by exactly one other&#xA;    # we do not enforce this hard, since the first one does not have a predecessor&#xA;    for j in range(N):&#xA;        prob += lpSum(x[i][j] for i in range(N)) &amp;lt;= 1&#xA;        &#xA;        &#xA;    # constraint 3: the total number of movements is at max N-1&#xA;    # this means every product is selected once, except the start product&#xA;    prob += lpSum(x[i][j] for i in range(N) for j in range(N)) == N - 1&#xA;    &#xA;    &#xA;    &#xA;    # constraint 4: avoid circular dependencies, i.e. 1 -&amp;gt; 2 -&amp;gt; 1 is not allowed&#xA;    # this means a sequence cannot loop back to a previously visited point&#xA;    for i in range(N):&#xA;        for j in range(N):&#xA;                prob += x[i][j] + x[j][i] &amp;lt;= 1&#xA;                &#xA;                &#xA;             &#xA;&#xA;    # constraint 7: the start product has no predecessor&#xA;    prob+= lpSum(x[i][zero_j] for i in range(N)) == 0&#xA;    &#xA;    # constraint 8: the start product must have a successor&#xA;    prob+= lpSum(x[zero_j][j] for j in range(N)) == 1&#xA;    &#xA;    # constraint 9: the upper bound for the costs is the baseline value&#xA;    # this baseline comes from warm_start&#xA;    prob += costs &amp;lt;= baseline&#xA;    &#xA;    # constraint 10: positional constraint&#xA;    # if i is in the sequence, its position must be smaller than j if j is after i&#xA;    for i in range(N):&#xA;        for j in range(N):&#xA;                prob += p[i] + 1 &amp;lt;= p[j] + M * (1-x[i][j])&#xA;                &#xA;        &#xA;                &#xA;    # constraint 11&#xA;    # the sum of assigned positions should be equal to the sum of range N&#xA;    # i.e. each position is present once&#xA;    prob += lpSum(p[i] for i in range(N)) == sum_n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13029" LastEditorUserId="36" LastEditDate="2023-12-28T14:28:23.547" LastActivityDate="2024-02-03T18:06:55.813" Title="Extracting a sequence as a decision variable from a matrix (PuLP)" Tags="|mixed-integer-programming|python|pulp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11444" PostTypeId="2" ParentId="11442" CreationDate="2023-12-28T15:17:18.437" Score="2" Body="&lt;p&gt;Yes, column generation still applies. The edge assignment constraints do not contain &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, so they do not directly affect the pricing problem for each commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, which is to find a negative reduced cost path for that commodity. The pricing problem is still a shortest path problem, but the arc costs should now be adjusted by the nonnegative dual value &lt;span class=&quot;math-container&quot;&gt;$-\beta_{ij}^{t_k}$&lt;/span&gt; of the flow compatibility constraint, where &lt;span class=&quot;math-container&quot;&gt;$t_k$&lt;/span&gt; is the type of commodity &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;. Explicitly, the cost of arc &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; for subproblem &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$c_{ij}^k+\pi_{ij}+\beta_{ij}^{t_k}$&lt;/span&gt;.  The variables &lt;span class=&quot;math-container&quot;&gt;$V_{ij}^t$&lt;/span&gt; are master-only, and the edge assignment constraint affect the subproblems indirectly through the duals on the other master constraints.&lt;/p&gt;&#xA;&lt;p&gt;But the way, for the restricted master LP, you should relax &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; to be nonnegative rather than &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt;, as discussed in this recent question: &lt;a href=&quot;https://or.stackexchange.com/questions/11430/question-on-column-generation&quot;&gt;Question on Column generation&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2023-12-28T15:17:18.437" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11445" PostTypeId="2" ParentId="11443" CreationDate="2023-12-28T16:29:24.203" Score="0" Body="&lt;p&gt;Let's assume that &lt;span class=&quot;math-container&quot;&gt;$i,j\in \lbrace 1,\dots,N\rbrace$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$o_i$&lt;/span&gt; is an integer variable with domain &lt;span class=&quot;math-container&quot;&gt;$\lbrace 1,\dots,N\rbrace$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i.$&lt;/span&gt; You can add the constraints &lt;span class=&quot;math-container&quot;&gt;$$o_i + x_{i,j} - N(1-x_{i,j}) \le o_j \le o_i + x_{i,j} + N(1-x_{i,j})$$&lt;/span&gt; for every index pair &lt;span class=&quot;math-container&quot;&gt;$i\neq j.$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=1,$&lt;/span&gt; this forces &lt;span class=&quot;math-container&quot;&gt;$o_j = o_i + 1.$&lt;/span&gt; If &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}=0,$&lt;/span&gt; the corresponding constraints are nonbinding.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-12-28T16:29:24.203" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11446" PostTypeId="2" ParentId="11438" CreationDate="2023-12-28T21:12:57.270" Score="0" Body="&lt;p&gt;Another way is to get a &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; series of binary variables, say &lt;span class=&quot;math-container&quot;&gt;$z_{k,c}$&lt;/span&gt; that will have &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; only for the smallest &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\phi_{k,c}=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ z_{k,c} \le \phi_{k,c}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$ \phi_{k,c} - \sum_{j \le k} \phi_{j,c} \le z_{k,c} \le 1 - \sum_{j \le k}z_{j,c}  \quad \forall k,c$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then &lt;span class=&quot;math-container&quot;&gt;$ \sum_k kz_{k,c} \quad \forall c$&lt;/span&gt; gives you the smallest &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-12-28T21:41:47.950" LastActivityDate="2023-12-28T21:41:47.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11448" PostTypeId="1" AcceptedAnswerId="11449" CreationDate="2023-12-29T15:32:09.670" Score="1" ViewCount="121" Body="&lt;p&gt;I'm trying to solve the CVRP based on flow-formulation. In such a model, we have a decision variable with two-index, &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt;, where I'm using the MTZ formula to eliminate sub-tours. We have then a continuous variable that represents the flow of the vehicle after visiting a customer. Let's say &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;. In the case of delivery, the constraints that I formulate is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_j \le y_i - d_j*x_{ij}+ Q*(1-x_{ij})$&lt;/span&gt;  , where  &lt;span class=&quot;math-container&quot;&gt;$(0 \le y_i \le Q - d_i$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;For this example with &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt; customers : &lt;span class=&quot;math-container&quot;&gt;$\{1:19;2:30;3:16;4:23;5:11\}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q=35$&lt;/span&gt;, the solution I got is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x : \{(0,3);(3,1);(1,0);(0,2);(2,0);(0,4);(4,5);(5,0)\}$&lt;/span&gt;&lt;br /&gt;&#xA;For the other variables, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is null.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y: \{1:0;2:0;3:16;4:11;5:0\}$&lt;/span&gt;.&lt;br /&gt;&#xA;I expected 12 for &lt;span class=&quot;math-container&quot;&gt;$y_4 = 35 - 23 = 12$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_5 = 12 - 11 = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ki57l.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ki57l.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But something is wrong that I can not identify.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mdl = Model('CVRP2')&#xA;arc_k = {(i, j) for i in nodes for j in nodes if i != j}&#xA;var = {(i) for i in customers}&#xA;xt = mdl.addVars(arc_k, vtype=GRB.BINARY, name='xt')&#xA;y =  mdl.addVars(var, vtype=GRB.CONTINUOUS, name='y')&#xA;mdl.modelSense = GRB.MINIMIZE&#xA;mdl.setObjective(grb.quicksum(time_truck[i][j] * xt[i, j] if i!=j else 0 &#xA;for i in nodes for j in nodes)) &#xA;#Constraint 1- Exactly the total number of vehicles leaves and return to &#xA; the depot &#xA;mdl.addConstr(grb.quicksum(xt[0, j] for j in customers) &amp;lt;= nT)&#xA;mdl.addConstr(grb.quicksum(xt[i, 0] for i in customers) &amp;lt;= nT)&#xA;# Constraint 2- Customer is only served once by only one vehicle&#xA;for j in customers:&#xA;    mdl.addConstr(grb.quicksum(xt[i, j] for i in nodes if i != j) == 1)&#xA;# Constraint 3- Only one vehicle enters and leaves each customer &#xA;for j in customers:&#xA;    mdl.addConstr(grb.quicksum(xt[i, j] if i != j else 0 for i in nodes) - grb.quicksum(xt[j, i] if i != j else 0 for i in nodes) == 0)&#xA;# Constraint 4: Subtour Elimination &#xA;for i in customers:&#xA;    for j in customers:&#xA;        if i != j:&#xA;            mdl.addConstr(y[j]&amp;lt;=y[i]-df.demand[j] + (truck_capacity) * &#xA;           (1- xt[i, j]))&#xA;#Constraint 5: Capacity Bounding Constraint&#xA;for i in customers:&#xA;    mdl.addConstr(y[i] &amp;gt;=0)&#xA;    mdl.addConstr(y[i] &amp;lt;= truck_capacity - df.demand[i])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10962" LastEditorUserId="10962" LastEditDate="2023-12-30T12:45:43.310" LastActivityDate="2023-12-30T18:15:32.583" Title="Capacited Vehicle Routing Problem with flow formulations" Tags="|mixed-integer-programming|vehicle-routing|network-flow|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11449" PostTypeId="2" ParentId="11448" CreationDate="2023-12-29T19:38:32.993" Score="1" Body="&lt;p&gt;Assuming that &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; is the load in the vehicle when exiting customer &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (after dropping of &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; units of goods there), then your first constraint has an incorrect middle term. It should be &lt;span class=&quot;math-container&quot;&gt;$$y_j \le y_i - d_j + Q(1 - x_{ij}).$$&lt;/span&gt; This enforces the constraint &lt;span class=&quot;math-container&quot;&gt;$$x_{ij} = 1 \implies y_j &amp;lt;= y_i - d_j,$$&lt;/span&gt; i.e., if the vehicle visits &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; immediately after &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; then the load when leaving &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; is the load when leaving &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; minus what is dropped off at &lt;span class=&quot;math-container&quot;&gt;$j.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-12-29T19:38:32.993" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11450" PostTypeId="1" AcceptedAnswerId="11451" CreationDate="2023-12-30T14:12:32.877" Score="0" ViewCount="32" Body="&lt;p&gt;We need to setup a more efficient quote system for prospective clients, but the logic is difficult to implement (I'm using VBA, but a formula or pseudocode is fine).  This seems to be a combinatorial optimization problem. The criteria is mostly uniform, but there are some edge cases that contradict the normal logic that I'll explain at the end.&lt;/p&gt;&#xA;&lt;p&gt;If the user sets a whole number perimeter and a whole number of zones, I need to determine the best combination of merchandise with attributes that equal the number of zones and meet or minimally exceed the perimeter. Note that the merchandise without any zones can be used once the zones have been accounted for with other merchandise and only perimeter is left to be satisfied. If I were to set my desired perimeter to 1000ft and zones to 2, the ideal merchandise combination would be RB-I2Z500, which is 1000ft and has 2 zones.  If I set the perimeter to 1100ft and 3 zones it would be RB-I2Z250, RB-I1Z500, and RB-I100 since they are (250 x 2) + 500 + 100 = 1100ft and 2 zones + 1 zone + 0 zone = 3 zones.&lt;/p&gt;&#xA;&lt;p&gt;You might notice that other combinations would also work, but the justification for one specific combination is that it would be the lowest price (not shown) to the client. You may notice the yellow highlighted rows in the table - these are not actual products, but I put them there to help facilitate my current partial solution. In conjunction with the Distance column (also added by me), I determine the distance between a perimeter quotient (the user's specified feet divided by the user's specified number of zones) and each product's total feet.  This has been helpful in coming up with the correct combination in most, but not all, situations. It just requires a lot of branching conditions to force the program to choose the combination with the lowest total price.&lt;/p&gt;&#xA;&lt;p&gt;If you think you understand everything above, there is one additional criteria, which is that the user must specify a minimum number of feet in relation to their number of zones since there are no possible combinations that satisfy the number of zones and feet under that minimum. This works out to be 250ft * zones, so if they choose 3 zones they need to set their perimeter to at least 750ft. Now the main edge case falls in the range between (250ft * zones) to (250ft * (zones + 1)), which in the former example of 3 zones would be 750 to 1000ft. Within this range there is a special condition called a split, which is allowed to convert one of the kits into an extra zone by cutting the cable and using a special item to join it as needed.&lt;/p&gt;&#xA;&lt;p&gt;For me at least, this has been an incredibly complex project, and I've left out a lot of complications in the hope that I don't scare anyone away. I will post my current code below the table. Note that some of the code deals with converting from feet to meters, so that can be safely ignored.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/w40Bq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/w40Bq.png&quot; alt=&quot;Merchandise Table&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Sub CalculateProductCodes()&#xA;Dim rngProduct As Range, rngMinDist As Range&#xA;Dim rngCodes As Range, rngFound As Range&#xA;Dim rngAdd As Range, rngZonesLeft As Range&#xA;Dim rngMinPerim As Range, rngSplit As Range&#xA;Dim rngMetrics As Range&#xA;Dim sSystem As String, sAbbr As String&#xA;Dim sCode As String, sProductCodes() As String&#xA;Dim bSplit As Boolean, bMult As Boolean&#xA;Dim bZero As Boolean&#xA;Dim dPerimeter As Double, dPerimeterLeft As Double&#xA;Dim dPerimeterQuotient As Double, dPerimeterMinus As Double&#xA;Dim dMinDistance As Double&#xA;Dim lMinPerim As Long, lBaseFeetOrMeters As Long&#xA;Dim lS As Long, lM As Long, lL As Long&#xA;Dim vFeetOrMeters() As Variant, vMetrics As Variant&#xA;Dim iZones As Integer, iZonesLeft As Integer&#xA;Dim iIndex As Integer, iMod As Integer&#xA;Dim iDualSingle As Integer, iProduct As Integer&#xA;Dim i As Integer, j As Integer&#xA;&#xA;Set rngMetrics = wksBOM.Range(&amp;quot;Metrics&amp;quot;)&#xA;Set rngProduct = wksCalc.Range(&amp;quot;Products&amp;quot;) ' From merchandise table&#xA;Set rngCodes = wksCalc.Range(&amp;quot;ResultCodes&amp;quot;) ' Not shown, output area&#xA;Set rngMinDist = wksCalc.Range(&amp;quot;MinDist&amp;quot;) ' This confines the possible results to a specific portion of the table depending on the chosen system.&#xA;Set rngAdd = wksCalc.Range(&amp;quot;AdditionalLine&amp;quot;) ' Special item used to join split cable&#xA;Set rngZonesLeft = wksCalc.Range(&amp;quot;ZonesLeft&amp;quot;)  ' Tracks zones left after each iteration of loop, which makes sense as you get further down&#xA;Set rngMinPerim = wksCalc.Range(&amp;quot;MinPerimeterSplit&amp;quot;) ' 250 * no of zones&#xA;Set rngSplit = wksCalc.Range(&amp;quot;Split&amp;quot;) ' Whether split condition is active or not&#xA;&#xA;rngAdd.Value = 0&#xA;rngZonesLeft.Value = wksBOM.Range(&amp;quot;Zones&amp;quot;).Value ' User specified no of zones&#xA;sSystem = wksBOM.Range(&amp;quot;System&amp;quot;).Value ' user specified system type&#xA;dPerimeter = wksBOM.Range(&amp;quot;Perimeter&amp;quot;).Value ' user specified perimeter&#xA;iZones = rngZonesLeft.Value&#xA;&#xA;' All of this block is used further down in the calculations&#xA;' some of it is for converting between feet and meters&#xA;' but other parts are for reducing the initial result from&#xA;' the Distance column to the preferred result&#xA;If rngMetrics.Value = &amp;quot;Feet&amp;quot; And sSystem = &amp;quot;IRON&amp;quot; Then&#xA;    vMetrics = Array(&amp;quot;100&amp;quot;, &amp;quot;250&amp;quot;, &amp;quot;375&amp;quot;, &amp;quot;500&amp;quot;, &amp;quot;750&amp;quot;, &amp;quot;1000&amp;quot;)&#xA;    lBaseFeetOrMeters = 250: iMod = 1&#xA;    lS = 100: lM = 250: lL = 500&#xA;ElseIf rngMetrics.Value = &amp;quot;Meters&amp;quot; And sSystem = &amp;quot;IRON&amp;quot; Then&#xA;    vMetrics = Array(&amp;quot;30&amp;quot;, &amp;quot;75&amp;quot;, &amp;quot;114&amp;quot;, &amp;quot;150&amp;quot;, &amp;quot;229&amp;quot;, &amp;quot;305&amp;quot;)&#xA;    lBaseFeetOrMeters = 75: iMod = 1&#xA;    lS = 30: lM = 75: lL = 152&#xA;ElseIf rngMetrics.Value = &amp;quot;Feet&amp;quot; And sSystem &amp;lt;&amp;gt; &amp;quot;IRON&amp;quot; Then&#xA;    vMetrics = Array(&amp;quot;250&amp;quot;, &amp;quot;375&amp;quot;, &amp;quot;500&amp;quot;, &amp;quot;750&amp;quot;, &amp;quot;1000&amp;quot;)&#xA;    lBaseFeetOrMeters = 250&#xA;    lS = 100: lM = 250: lL = 500&#xA;ElseIf rngMetrics.Value = &amp;quot;Meters&amp;quot; And sSystem &amp;lt;&amp;gt; &amp;quot;IRON&amp;quot; Then&#xA;    vMetrics = Array(&amp;quot;75&amp;quot;, &amp;quot;114&amp;quot;, &amp;quot;150&amp;quot;, &amp;quot;229&amp;quot;, &amp;quot;305&amp;quot;)&#xA;    lBaseFeetOrMeters = 75&#xA;    lS = 30: lM = 75: lL = 152&#xA;End If&#xA;&#xA;ReDim vFeetOrMeters(0 To UBound(vMetrics))&#xA;&#xA;' Converts ft to meters&#xA;For i = 0 To UBound(vMetrics)&#xA;    vFeetOrMeters(i) = vMetrics(i)&#xA;Next i&#xA;&#xA;' For use in creating product codes where necessary&#xA;If sSystem = &amp;quot;IRON&amp;quot; Then&#xA;    sAbbr = &amp;quot;I&amp;quot;&#xA;ElseIf sSystem = &amp;quot;MIKE&amp;quot; Then&#xA;    sAbbr = &amp;quot;M&amp;quot;&#xA;Else&#xA;    sAbbr = &amp;quot;W&amp;quot;&#xA;End If&#xA;&#xA;' Because the Iron system has a 100ft denomination, this helps check to see&#xA;' if the 100ft product code will need to be used in the final combination.&#xA;' If bMult = True then it will be used, otherwise no.&#xA;If sSystem = &amp;quot;IRON&amp;quot; And _&#xA;   (dPerimeter Mod lBaseFeetOrMeters) &amp;gt; 0 And _&#xA;   (dPerimeter Mod lBaseFeetOrMeters) &amp;lt;= 100 Then bMult = True&#xA;&#xA;' Determines if the split condition is in effect based on the users perimeter.&#xA;' If the users perimeter is lower than the min threshold, exit sub.&#xA;If dPerimeter &amp;gt;= rngMinPerim.Cells(1, 1).Value And dPerimeter &amp;lt; rngMinPerim.Cells(2, 1).Value Then&#xA;    bSplit = True&#xA;    rngSplit.Value = True&#xA;ElseIf dPerimeter &amp;lt; rngMinPerim.Cells(1, 1).Value Then&#xA;    rngCodes.Value = &amp;quot;None&amp;quot;&#xA;    Exit Sub&#xA;Else&#xA;    bSplit = False&#xA;    rngSplit.Value = False&#xA;End If&#xA;&#xA;dPerimeterLeft = dPerimeter&#xA;iZonesLeft = iZones: iProduct = 0&#xA;&#xA;' Early exit condition&#xA;If dPerimeter &amp;lt;= 0 Or iZones &amp;lt;= 0 Then&#xA;    rngCodes.Value = &amp;quot;None&amp;quot;&#xA;    Exit Sub&#xA;End If&#xA;&#xA;' Main loop that runs as long as the remaining perimeter to be assigned&#xA;' a product to is greater than zero.&#xA;Do While dPerimeterLeft &amp;gt; 0&#xA;    &#xA;    rngZonesLeft.Value = iZonesLeft&#xA;    bZero = False&#xA;&#xA;    Application.Calculate&#xA;    &#xA;    If iZonesLeft = 0 Or iZonesLeft = 1 Then&#xA;&#xA;        ' This is used to determine the Distance column values&#xA;        dPerimeterQuotient = dPerimeterLeft&#xA;        &#xA;        ' Sets the Distance column values with this formula.&#xA;        rngProduct.Offset(0, 6).Resize(rngProduct.Rows.Count, 1).Formula2 = &amp;quot;=&amp;quot; &amp;amp; rngProduct.Cells(1, 4).Address(False, False) &amp;amp; &amp;quot;-&amp;quot; &amp;amp; dPerimeterQuotient&#xA;    ElseIf iZonesLeft &amp;gt;= 2 Then&#xA;        &#xA;        ' dPerimeterQuotient is only different from dPerimeterLeft if iZonesLeft is &amp;gt;= 2&#xA;        dPerimeterQuotient = dPerimeterLeft / iZonesLeft&#xA;        rngProduct.Offset(0, 6).Resize(rngProduct.Rows.Count, 1).Formula2 = &amp;quot;=&amp;quot; &amp;amp; rngProduct.Cells(1, 4).Address(False, False) &amp;amp; &amp;quot;-&amp;quot; &amp;amp; dPerimeterQuotient&#xA;    End If&#xA;&#xA;    dMinDistance = rngMinDist.Value ' This is the value that is closest to zero while still being positive and that is within the correct table range determined by which system is chosen by the user.&#xA;    &#xA;    ' iDualSingle is used to determine (under most circumstances) whether the product is a dual-zone, single zone, or feet only product.&#xA;    If iZonesLeft &amp;gt;= 2 Then&#xA;        iDualSingle = 2&#xA;    ElseIf iZonesLeft = 1 Then&#xA;        iDualSingle = 1&#xA;    Else&#xA;        iDualSingle = 0&#xA;    End If&#xA;    &#xA;    ' Loops through all 39 products and return result that matches all of these criteria&#xA;    For i = 1 To 39&#xA;&#xA;        If rngProduct.Cells(i, 2).Value = sSystem And _&#xA;           rngProduct.Cells(i, 3).Value = iDualSingle And _&#xA;           rngProduct.Cells(i, 7).Value = dMinDistance Then&#xA;            &#xA;            ' stores current index in case the result needs to be reduced later&#xA;            iIndex = i&#xA;            &#xA;            ' Unless reduced, this will be one of the end results to be output&#xA;            sCode = rngProduct.Cells(i, 6).Value&#xA;&#xA;            ' Will be subtracted from dPerimeterLeft after each loop, but this value might change.&#xA;            dPerimeterMinus = rngProduct.Cells(i, 5).Value&#xA;        &#xA;            Exit For&#xA;            &#xA;        End If&#xA;            &#xA;    Next i&#xA;    &#xA;    If sCode = &amp;quot;&amp;quot; Then Exit Do&#xA;&#xA;    ' Special circumstance that will come into play further down.&#xA;    If iZonesLeft = 0 And dPerimeterLeft - dPerimeterMinus &amp;lt;= 0 Then bZero = True&#xA;    &#xA;    ' lBaseFeetOrMeters is typically 250 when using Feet.&#xA;    ' These next conditions will reduce the product code to the next one down in&#xA;    ' the table if condition is met in order to be most efficient.&#xA;    ' When this happens it will also adjust sCode, dPerimeterMinus, and iDualSingle &#xA;    ' where applicable.&#xA;    If (dPerimeterLeft - dPerimeterMinus) &amp;lt; -lBaseFeetOrMeters And _&#xA;       (iZonesLeft - iDualSingle) &amp;gt;= 0 Then&#xA;&#xA;        For i = iIndex To 1 Step -1&#xA;            If rngProduct.Cells(i, 5).Value &amp;lt; dPerimeterMinus And _&#xA;               rngProduct.Cells(i, 2).Value = sSystem Then&#xA;                sCode = rngProduct.Cells(i, 6).Value&#xA;                dPerimeterMinus = rngProduct.Cells(i, 5).Value&#xA;                iDualSingle = rngProduct.Cells(i, 3).Value&#xA;                Exit For&#xA;            End If&#xA;        Next i&#xA;        &#xA;    ElseIf (dPerimeterLeft - dPerimeterMinus) &amp;lt;= 0 And _&#xA;       (iZonesLeft - iDualSingle) &amp;gt; 0 Then&#xA;       &#xA;        For i = iIndex To 1 Step -1&#xA;            If rngProduct.Cells(i, 5).Value &amp;lt; dPerimeterMinus And _&#xA;               rngProduct.Cells(i, 2).Value = sSystem Then&#xA;                sCode = rngProduct.Cells(i, 6).Value&#xA;                dPerimeterMinus = rngProduct.Cells(i, 5).Value&#xA;                iDualSingle = rngProduct.Cells(i, 3).Value&#xA;                Exit For&#xA;            End If&#xA;        Next i&#xA;        &#xA;        ' If this is true, it adds the special product code to the output&#xA;        If bSplit Then rngAdd.Value = rngAdd.Value + iZonesLeft - 1&#xA;    &#xA;    ElseIf (dPerimeterLeft - dPerimeterMinus) &amp;lt;= 0 And _&#xA;       (iZonesLeft - iDualSingle) &amp;gt;= 0 And bSplit Then&#xA;       &#xA;        For i = iIndex To 1 Step -1&#xA;            If rngProduct.Cells(i, 5).Value &amp;lt; dPerimeterMinus And _&#xA;               rngProduct.Cells(i, 2).Value = sSystem Then&#xA;                sCode = rngProduct.Cells(i, 6).Value&#xA;                dPerimeterMinus = rngProduct.Cells(i, 5).Value&#xA;                iDualSingle = rngProduct.Cells(i, 3).Value&#xA;                Exit For&#xA;            End If&#xA;        Next i&#xA;        &#xA;        ' Also for the split condition, adds specified number of connector product&#xA;        rngAdd.Value = rngAdd.Value + iZonesLeft - 1&#xA;        &#xA;    ElseIf dPerimeterLeft &amp;lt;= 0 Then&#xA;    &#xA;        Exit Do&#xA;        &#xA;    End If&#xA;    &#xA;    ' Reduces dPerimeterLeft by dPerimeterMinus &amp;amp; iZonesLeft by iDualSingle        &#xA;    dPerimeterLeft = dPerimeterLeft - dPerimeterMinus&#xA;    iZonesLeft = iZonesLeft - iDualSingle&#xA;    &#xA;    ReDim Preserve sProductCodes(iProduct)&#xA;    &#xA;    ' These check what number of feet (or meters) are in the product code. &#xA;    ' For the rows highlighted in yellow, since they are not actual products&#xA;    ' they will be spun off into the two real products that it represents.&#xA;    If InStr(1, sCode, vFeetOrMeters(3 + iMod)) Then&#xA;        sCode = Replace(sCode, vFeetOrMeters(3 + iMod), vFeetOrMeters(2 + iMod))&#xA;        sProductCodes(iProduct) = sCode&#xA;        iProduct = iProduct + 1&#xA;        &#xA;        ReDim Preserve sProductCodes(iProduct)&#xA;&#xA;        If dPerimeterLeft &amp;lt;= -lS Then&#xA;            sProductCodes(iProduct) = &amp;quot;RB-&amp;quot; &amp;amp; sAbbr &amp;amp; lS&#xA;            dPerimeterLeft = dPerimeterLeft + 150&#xA;        Else&#xA;            sProductCodes(iProduct) = &amp;quot;RB-&amp;quot; &amp;amp; sAbbr &amp;amp; lM&#xA;        End If&#xA;&#xA;        iProduct = iProduct + 1&#xA;        &#xA;    ElseIf InStr(1, sCode, vFeetOrMeters(1 + iMod)) Then&#xA;        sCode = Replace(sCode, vFeetOrMeters(1 + iMod), vFeetOrMeters(iMod))&#xA;        sProductCodes(iProduct) = sCode&#xA;        iProduct = iProduct + 1&#xA;        &#xA;        ReDim Preserve sProductCodes(iProduct)&#xA;&#xA;        If dPerimeterLeft &amp;lt;= -lS Then&#xA;            sProductCodes(iProduct) = &amp;quot;RB-&amp;quot; &amp;amp; sAbbr &amp;amp; lS&#xA;        Else&#xA;            sProductCodes(iProduct) = &amp;quot;RB-&amp;quot; &amp;amp; sAbbr &amp;amp; lM&#xA;        End If&#xA;&#xA;        iProduct = iProduct + 1&#xA;    Else&#xA;        sProductCodes(iProduct) = sCode&#xA;        iProduct = iProduct + 1&#xA;    End If&#xA;    &#xA;    ' Similar to the above conditions, but only applies in a special edge case where&#xA;    ' both dPerimeterLeft and iZonesLeft are 0 (or less than 0 in case of perimeter).&#xA;    If bMult And bZero Then&#xA;        &#xA;        If InStr(1, sProductCodes(iProduct - 1), vFeetOrMeters(iMod)) Then&#xA;            sProductCodes(iProduct - 1) = &amp;quot;RB-&amp;quot; &amp;amp; sAbbr &amp;amp; lS&#xA;        ElseIf InStr(1, sProductCodes(iProduct - 1), vFeetOrMeters(1 + iMod)) Then&#xA;            sProductCodes(iProduct - 1) = &amp;quot;RB-&amp;quot; &amp;amp; sAbbr &amp;amp; lM&#xA;            &#xA;            ReDim Preserve sProductCodes(iProduct)&#xA;            &#xA;            sProductCodes(iProduct) = &amp;quot;RB-&amp;quot; &amp;amp; sAbbr &amp;amp; lS&#xA;            iProduct = iProduct + 1&#xA;        ElseIf InStr(1, sProductCodes(iProduct - 1), vFeetOrMeters(4 + iMod)) Then&#xA;            ReDim Preserve sProductCodes(iProduct + 1)&#xA;            sProductCodes(iProduct - 1) = &amp;quot;RB-&amp;quot; &amp;amp; sAbbr &amp;amp; lL&#xA;            sProductCodes(iProduct) = &amp;quot;RB-&amp;quot; &amp;amp; sAbbr &amp;amp; lM&#xA;            sProductCodes(iProduct + 1) = &amp;quot;RB-&amp;quot; &amp;amp; sAbbr &amp;amp; lS&#xA;            iProduct = iProduct + 2&#xA;        End If&#xA;        &#xA;    End If&#xA;    &#xA;Loop&#xA;&#xA;' sets all output cells to None so prior executions do not get included in results&#xA;rngCodes.Value = &amp;quot;None&amp;quot;&#xA;&#xA;For j = 0 To iProduct - 1&#xA;    rngCodes.Cells(j + 1, 1).Value = sProductCodes(j)&#xA;Next j&#xA;&#xA;If rngAdd.Value &amp;gt;= 2 Then rngAdd.Value = rngAdd.Value - 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;End Sub&lt;/p&gt;&#xA;" OwnerUserId="13034" LastEditorUserId="13034" LastEditDate="2023-12-30T15:59:13.170" LastActivityDate="2023-12-30T18:10:29.807" Title="Determine optimal method for choosing products based on perimeter and number of zones" Tags="|combinatorial-optimization|excel|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11451" PostTypeId="2" ParentId="11450" CreationDate="2023-12-30T17:26:33.333" Score="0" Body="&lt;p&gt;Without the splits, you want to solve a &lt;a href=&quot;https://en.wikipedia.org/wiki/Knapsack_problem#Multi-dimensional_knapsack_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;two-dimensional knapsack problem&lt;/a&gt; with equality constraints.  Let &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be the set of products.  For product &lt;span class=&quot;math-container&quot;&gt;$i\in P$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; be the cost, perimeter, and number of zones, respectively.  Let &lt;span class=&quot;math-container&quot;&gt;$\bar{p}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\bar{z}$&lt;/span&gt; be the required perimeter and number of zones.  Let nonnegative integer decision variable &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; be the number of times that product &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is selected.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i\in P} c_i x_i$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i\in P} p_i x_i &amp;amp;= \bar{p} \tag1\label1 \\&#xA;\sum_{i\in P} z_i x_i &amp;amp;= \bar{z} \tag2\label2&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2023-12-30T18:10:29.807" LastActivityDate="2023-12-30T18:10:29.807" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11452" PostTypeId="2" ParentId="11448" CreationDate="2023-12-30T17:32:39.227" Score="1" Body="&lt;p&gt;Assuming your customers are &lt;span class=&quot;math-container&quot;&gt;$N =\{1,2,...5 \}$&lt;/span&gt; while nodes &lt;span class=&quot;math-container&quot;&gt;$N+\{0\}$&lt;/span&gt;, subtour elimination constraint involves&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(3,1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(4,5)$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_1 + 16 \le y_3 \le 19 = (35-16)$&lt;/span&gt; and&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_5 + 11 \le y_4 \le 12$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_4 \le y_5 + 12$&lt;/span&gt;&#xA;since in your code you are still missing &lt;span class=&quot;math-container&quot;&gt;$x_{i,j}d_{j}$&lt;/span&gt;. you are using only &lt;span class=&quot;math-container&quot;&gt;$d_j$&lt;/span&gt; which is still ok.&lt;/p&gt;&#xA;&lt;p&gt;also all &lt;span class=&quot;math-container&quot;&gt;$y_s$&lt;/span&gt; are bounded by &lt;span class=&quot;math-container&quot;&gt;$\{1:14, 2:5,3:19,4:12,5:24 \}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since the model sense is 'min' &amp;amp; thogh it applies to the objective value that doesn't include &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; but since &lt;span class=&quot;math-container&quot;&gt;$y_5 =[0,1]$&lt;/span&gt; solver chooses &lt;span class=&quot;math-container&quot;&gt;$y_5 = 0$&lt;/span&gt; and that bounds &lt;span class=&quot;math-container&quot;&gt;$11 \le y_4 \le 12$&lt;/span&gt;, allowed min values for decision variables.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2023-12-30T18:15:32.583" LastActivityDate="2023-12-30T18:15:32.583" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11453" PostTypeId="1" AcceptedAnswerId="11454" CreationDate="2023-12-30T19:05:27.540" Score="1" ViewCount="140" Body="&lt;p&gt;I'm trying to represent the following problem with PuLP:&lt;br /&gt;&#xA;A car factory needs to maximize profit with an X amount of car models. Each car model has an individual profit and a manufacturing limit, and there is a limit on how many cars can be produced in total. They also sell a package with 3 cars of different models. The profit of a single package is bigger than the sum of the profit those 3 cars.&lt;/p&gt;&#xA;&lt;p&gt;My question is how can I represent those packages in the objetive function and constraints? Should I represent them as a new decision variable? How could I control the constraints?&lt;/p&gt;&#xA;&lt;p&gt;Example:&lt;br /&gt;&#xA;(car model, number of cars of that model that can be made, profit from 1 car of that model)&lt;br /&gt;&#xA;x1, 25, 45&lt;br /&gt;&#xA;x2, 32, 27&lt;br /&gt;&#xA;x3, 28, 43&lt;br /&gt;&#xA;x4, 35, 37&lt;br /&gt;&#xA;x5, 34, 33&lt;br /&gt;&#xA;Let's say there is a package that contains x2, x3, x4 and the profit of selling a single package is 125$.&lt;br /&gt;&#xA;The number of cars (total) that be produced are 140.&lt;/p&gt;&#xA;&lt;p&gt;The code below represents the example but without the packages&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import *&#xA;&#xA;# Problem&#xA;prob = LpProblem(&amp;quot;myProblem&amp;quot;, LpMaximize)&#xA;&#xA;# Decision variables&#xA;x1 = LpVariable(name=&amp;quot;x1&amp;quot;, lowBound=0, upBound=25, cat='Integer')&#xA;x2 = LpVariable(name=&amp;quot;x2&amp;quot;, lowBound=0, upBound=32, cat='Integer')&#xA;x3 = LpVariable(name=&amp;quot;x3&amp;quot;, lowBound=0, upBound=28, cat='Integer')&#xA;x4 = LpVariable(name=&amp;quot;x4&amp;quot;, lowBound=0, upBound=35, cat='Integer')&#xA;x5 = LpVariable(name=&amp;quot;x5&amp;quot;, lowBound=0, upBound=34, cat='Integer')&#xA;&#xA;# Objective function&#xA;prob += lpSum(&#xA;    + 45*x1&#xA;    + 27*x2&#xA;    + 43*x3&#xA;    + 37*x4&#xA;    + 33*x5&#xA;)&#xA;&#xA;# Restrictions&#xA;prob += x1 + x2 + x3 + x4 + x5 &amp;lt;= 140&#xA;&#xA;# Solution&#xA;status = prob.solve(PULP_CBC_CMD (msg=False))&#xA;print(value(prob.objective))&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'm new here so excuse me if this post isn't in the right format or was cryptic in any way.&lt;/p&gt;&#xA;" OwnerDisplayName="user13035" LastEditorDisplayName="user13035" LastEditDate="2024-01-01T12:57:29.557" LastActivityDate="2024-01-01T13:47:19.133" Title="Creating a decision variable that is the sum of other variables in PuLP" Tags="|optimization|linear-programming|modeling|python|pulp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11454" PostTypeId="2" ParentId="11453" CreationDate="2023-12-30T19:12:07.137" Score="1" Body="&lt;p&gt;Yes, you can model each package with a new decision variable.  For your example, introduce &lt;span class=&quot;math-container&quot;&gt;$x_{234}$&lt;/span&gt; with objective coefficient &lt;span class=&quot;math-container&quot;&gt;$125$&lt;/span&gt; and constraint coefficient &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; because that package uses &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; cars from the total allotment of &lt;span class=&quot;math-container&quot;&gt;$140$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_1 + x_2 + x_3 + x_4 + x_5 + 3 x_{234} \le 140$$&lt;/span&gt;&#xA;To account for packages, you also need an explicit constraint for each model, rather than just an upper bound on a variable.  For example, the constraint for model 2 becomes &lt;span class=&quot;math-container&quot;&gt;$x_2 + 3x_{234} \le 32$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorDisplayName="user13035" LastEditDate="2024-01-01T13:47:19.133" LastActivityDate="2024-01-01T13:47:19.133" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11455" PostTypeId="1" CreationDate="2023-12-30T19:13:33.660" Score="1" ViewCount="55" Body="&lt;p&gt;Having the following optimization problem that models &lt;span class=&quot;math-container&quot;&gt;$\sum_i\min(c_i, C)$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\min_{\mathbf{Y},\,\,\{x_i\}_i} \sum_i^{n} c_ix_i + C(1-x_i)&#xA;$$&lt;/span&gt;&#xA;and where&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is a positive constant,&lt;/li&gt;&#xA;&lt;li&gt;each &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; is a binary variable that can take values in &lt;span class=&quot;math-container&quot;&gt;$\{0, 1\}$&lt;/span&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c_i\in\mathbb{R}$&lt;/span&gt; is variable whose square &lt;span class=&quot;math-container&quot;&gt;$c_i^2$&lt;/span&gt; is constrained by the linear equality:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$c_i^2 = \text{trace}(\mathbf{A}_i\mathbf{Y}),$$&lt;/span&gt;&#xA;with &lt;span class=&quot;math-container&quot;&gt;$\mathbf{Y}$&lt;/span&gt; being a symmetric PSD matrix and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}_i$&lt;/span&gt; a symmetric real matrix.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Since the number of binary variables &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; can be quite large (more than 100), I have experimented with a semidefinite (SDP) relaxation that drops the binary constraint of each &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;. Specifically, I am optimizing &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; 3x3 PSD matrices &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}_i$&lt;/span&gt; that have the following desired rank-1 global optimum (which I am not currently achieving):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathbf{X}_i = \begin{bmatrix}&#xA;x_i^2 &amp;amp; x_ic_i &amp;amp; x_i \\&#xA;&amp;amp; c_i^2 &amp;amp; c_i \\&#xA;&amp;amp; &amp;amp; 1&#xA;\end{bmatrix}&#xA;$$&lt;/span&gt;&#xA;Besides the equality constraints that fix the values of &lt;span class=&quot;math-container&quot;&gt;$c_i^2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, I also impose the binary constraint &lt;span class=&quot;math-container&quot;&gt;$x_i^2 - x_i = 0$&lt;/span&gt;. However, these constraints are not enough since the trivial solution &lt;span class=&quot;math-container&quot;&gt;$c_ix_i=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i=x_i^2=1$&lt;/span&gt; remains feasible regardless of the value of &lt;span class=&quot;math-container&quot;&gt;$c_i^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Since my problem is bounded &lt;span class=&quot;math-container&quot;&gt;$c_i^2,C&amp;lt;M$&lt;/span&gt;, for any possible value of &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt;, a stronger relaxation can be achieved using the big-M method &lt;a href=&quot;https://or.stackexchange.com/a/1174/10934&quot;&gt;as explained here for a LP problem&lt;/a&gt;. However, I am still unable to achieve the desired rank-1 matrix solution &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}_i$&lt;/span&gt; of above.&lt;/p&gt;&#xA;&lt;p&gt;The result from &lt;a href=&quot;https://optimization-online.org/wp-content/uploads/2016/01/5279.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Exact SDP Relaxations with Truncated Moment Matrix for Binary Polynomial Optimization Problems&lt;/a&gt; states:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;For binary polynomial optimization problems (POPs) of degree &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; variables, we&#xA;prove that the &lt;span class=&quot;math-container&quot;&gt;$[(n + d − 1)/2]$&lt;/span&gt;th semidefinite (SDP) relaxation in Lasserre’s hierarchy&#xA;of the SDP relaxations provides the exact optimal value.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;seems relevant. However I think it is not applicable to my problem, since my problem also involves the continuous variable &lt;span class=&quot;math-container&quot;&gt;$c_i^2 = \text{trace}(\mathbf{A}_i\mathbf{Y})$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible that achieving the desired rank-1 matrices is impossible due to the strong non-convexity induced by the binary variables?&lt;/p&gt;&#xA;" OwnerUserId="13036" LastEditorUserId="13036" LastEditDate="2023-12-30T19:21:00.373" LastActivityDate="2023-12-30T19:21:00.373" Title="Strong relaxations for binary variables" Tags="|binary-variable|relaxation|semidefinite-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11456" PostTypeId="1" CreationDate="2023-12-31T00:20:23.120" Score="1" ViewCount="37" Body="&lt;p&gt;I am an electrical engineer who is currently working with some bench table placement problem, and suddenly my problem look pretty much like the set cover problem &lt;a href=&quot;https://optimization.cbe.cornell.edu/index.php?title=Set_covering_problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. After that, some of my colleague told me that most problem in engineering is quite sparse and this should be exploited.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, my question is:&lt;/p&gt;&#xA;&lt;p&gt;Can sparse set cover problem be solved or approximated more efficiently comparing to its non-sparse counter part ?&lt;/p&gt;&#xA;&lt;p&gt;Thank you for your enthusiasm !&lt;/p&gt;&#xA;" OwnerUserId="11163" LastActivityDate="2023-12-31T16:38:37.537" Title="Can sparse set cover problem be solved or approximated more efficiently comparing to its non-sparse counter part?" Tags="|solver|software|set-covering|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11457" PostTypeId="5" CreationDate="2023-12-31T12:26:11.843" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2023-12-31T12:26:11.843" LastActivityDate="2023-12-31T12:26:11.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11458" PostTypeId="4" CreationDate="2023-12-31T12:26:11.843" Score="0" Body="Questions relating to the Google CP-SAT solver, available through OR-Tools." OwnerUserId="981" LastEditorUserId="981" LastEditDate="2023-12-31T14:40:42.283" LastActivityDate="2023-12-31T14:40:42.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11459" PostTypeId="2" ParentId="11456" CreationDate="2023-12-31T16:38:37.537" Score="4" Body="&lt;p&gt;For a given set of dimensions, a sparse model is likely to be faster to solve than a dense one simply because fewer nonzero coefficients mean less arithmetic per iteration of whatever algorithm you are using. However, there is no guarantee that a specific sparse instance will solve faster than a specific dense instance of the same dimension.&lt;/p&gt;&#xA;&lt;p&gt;As for exploiting sparsity, if you are using an integer programming model and an IP solver, there is a good chance that the IP solver internally exploits sparsity (for instance, by using matrix factorization techniques that benefit from sparsity).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2023-12-31T16:38:37.537" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11460" PostTypeId="1" CreationDate="2024-01-01T15:17:52.677" Score="1" ViewCount="36" Body="&lt;p&gt;Im looking for a guide to install the Concorde TSP Solver on a M1 Mac. I have looked everywhere and haven't found a solution that worked for me. Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="13039" LastActivityDate="2024-01-01T15:17:52.677" Title="Installing Concorde on M1 Mac Guide for building ANN around TSP Problem" Tags="|traveling-salesman|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11461" PostTypeId="1" AcceptedAnswerId="11462" CreationDate="2024-01-01T16:13:51.653" Score="3" ViewCount="127" Body="&lt;p&gt;In &lt;a href=&quot;https://en.wikipedia.org/wiki/Convex_optimization#/media/File:Hierarchy_compact_convex.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;this image from Wikipedia&lt;/a&gt;, semidefinite programming is presented as a special case of convex programming. I do not see how this can be. Consider the following two constraints (where &lt;span class=&quot;math-container&quot;&gt;$\succeq$&lt;/span&gt; means positive-semidefinite):&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left(&#xA;\begin{matrix}&#xA;1 &amp;amp; x&#xA;\\ &#xA;x &amp;amp; 1&#xA;\end{matrix}&#xA;\right)  \succeq 0&#xA;,&#xA;~~~~~~~~~~~~~~~~&#xA;\left(&#xA;\begin{matrix}&#xA;x &amp;amp; 1&#xA;\\ &#xA;1 &amp;amp; x&#xA;\end{matrix}&#xA;\right)  \succeq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first is equivalent to &lt;span class=&quot;math-container&quot;&gt;$1-x^2\geq 0$&lt;/span&gt;, which is a convex constraint; but the second is equivalent to &lt;span class=&quot;math-container&quot;&gt;$x^2-1\geq 0$&lt;/span&gt;, which is not a convex constraint. I am probably misunderstanding something very basic here; but what?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2024-01-01T17:13:36.993" Title="How is semidefinite programming a special case of convex programming?" Tags="|convex-optimization|semidefinite-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11462" PostTypeId="2" ParentId="11461" CreationDate="2024-01-01T16:36:28.077" Score="4" Body="&lt;p&gt;The second of those is NOT equivalent to &lt;span class=&quot;math-container&quot;&gt;$x^2−1 \ge 0$&lt;/span&gt;.  That second semidefinite constraint not only implies &lt;span class=&quot;math-container&quot;&gt;$x^2 -1 \ge 0$&lt;/span&gt;, it also implies the diagonal elements are nonnegative, i.e., &lt;span class=&quot;math-container&quot;&gt;$x \ge 0$&lt;/span&gt;. Together, they are equivalent to &lt;span class=&quot;math-container&quot;&gt;$x \ge 1$&lt;/span&gt;, which is convex.&lt;/p&gt;&#xA;&lt;p&gt;The Wikipedia claim about Semidefintie Programs being convex is not really true either.  That Wikipedia article makes the implicit assumption that the SDP is linear (affine), in which case the statement is true. However, Semidefinite Programs can also be Bilinear (Bilinear Matrix Inequality, a.k.a., BMI), or more general Nonlinear Semidefinte Programs.&lt;/p&gt;&#xA;&lt;p&gt;In summary, Linear SDP (SDP in which variables appear only affinely) is convex. Nonlinear SDP (Bilinear and general nonlinear) is non-convex, and generally not so easy to solve to global optimality if the dimension is not very small.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2024-01-01T17:13:36.993" LastActivityDate="2024-01-01T17:13:36.993" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11463" PostTypeId="1" CreationDate="2024-01-01T21:14:53.110" Score="4" ViewCount="92" Body="&lt;p&gt;My knowledge on convex polyhedra and systems of linear inequalities (facets, edges, Farkas Lemma, projections, duality, etc.) is very scattered, and I'l like to go through a book to solidify it.&lt;/p&gt;&#xA;&lt;p&gt;I'm looking to something similar to chapters 3-4 in Integer Programming by Conforti, Cornuejols, and Zambelli, but with lots of good exercises.&lt;/p&gt;&#xA;&lt;p&gt;I have gone through some of Bertsimas' &lt;em&gt;Introduction to Linear Optimization&lt;/em&gt;, and I can't really put my finger on why, but I just don't like it.&lt;/p&gt;&#xA;&lt;p&gt;Do you have any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="4563" LastEditorUserId="491" LastEditDate="2024-01-19T13:29:06.283" LastActivityDate="2024-01-19T13:29:06.283" Title="Any recommendations for learning about polyhedra and integer programming?" Tags="|optimization|linear-programming|reference-request|polyhedra|books|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11464" PostTypeId="1" CreationDate="2024-01-02T10:55:01.563" Score="0" ViewCount="39" Body="&lt;p&gt;This question is related to this post where I was trying to understand how to formulate the CVRP based on flow formulation to eliminate sub-tours.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://or.stackexchange.com/questions/11448/capacited-vehicle-routing-problem-with-flow-formulations/11452#11452&quot;&gt;Capacited Vehicle Routing Problem with flow formulations&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, I'm trying to using different trucks. Basicaly, I suppose that I have two fleets with &lt;span class=&quot;math-container&quot;&gt;$Q_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q_2$&lt;/span&gt; as capacity where &lt;span class=&quot;math-container&quot;&gt;$Q_1 &amp;gt;= Q_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q_1&amp;gt;= max\{demand_i|i \in customers\}$&lt;/span&gt;. So, I defined a subset of customers that the trucks with &lt;span class=&quot;math-container&quot;&gt;$Q_2$&lt;/span&gt; can served. Let's assume: &lt;span class=&quot;math-container&quot;&gt;$customersD = \{demand_i &amp;lt;= Q_2 | i \in customers\}$&lt;/span&gt;. The problem that I got a disconnected cycle that I can't understand why (figure below). I use the same set of contraint for each type of fleet so I could not find where is the problem in my model (I'm using python with Gurobi).  Here is my code:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ute4C.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ute4C.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    arc_k = {(i, j) for i in nodes for j in nodes if i != j}&#xA;    var = {(i) for i in customers}&#xA;    const = {(i) for i in customersD}&#xA;    #---------------------------------------------------------&#xA;    xt1 = mdl.addVars(arc_k, vtype=GRB.BINARY)&#xA;    xt2 = mdl.addVars(arc_k, vtype=GRB.BINARY)&#xA;    y = mdl.addVars(var, vtype=GRB.CONTINUOUS, lb=0, ub=q1)&#xA;    z = mdl.addVars(const, vtype=GRB.CONTINUOUS,lb=0, ub=q2) &#xA;    #------------------------------------------------------------------&#xA;    mdl.modelSense = GRB.MINIMIZE&#xA;    mdl.setObjective(grb.quicksum(time_truck1[i][j] * xt1[i, j] for i in nodes &#xA;                    for j in nodes) + grb.quicksum(time_truck2[i][j] * xt2[i, j] &#xA;                    for i in nodes for j in nodes))&#xA;    mdl.addConstr(grb.quicksum(xt1[0, j] for j in customers)  &amp;lt;= nT1, name='C11')&#xA;    mdl.addConstr(grb.quicksum(xt2[0, j] for j in customersD)  &amp;lt;= nT2, name='C12')&#xA;    mdl.addConstr(grb.quicksum(xt1[i, 0] for i in customers) &amp;lt;= nT1, name='C21')&#xA;    mdl.addConstr(grb.quicksum(xt2[i, 0] for i in customersD) &amp;lt;= nT2, name='C22')&#xA;    for j in customers:&#xA;            mdl.addConstr(grb.quicksum(xt1[i, j] for i in nodes if i != j) &#xA;                          + grb.quicksum(xt2[i, j] for i in nodes if i != j) == 1, name='C3')&#xA;    for j in customers:&#xA;        mdl.addConstr(grb.quicksum(xt1[i, j] if i != j else 0 for i in nodes) &#xA;                       - (grb.quicksum(xt1[j, i] if i != j else 0 for i in nodes)) == 0) &#xA;    #-------------------------------------------------------------------------------  &#xA;    for j in customersD:&#xA;        mdl.addConstr(grb.quicksum(xt2[i, j] if i != j else 0 for i in nodes) &#xA;                       - (grb.quicksum(xt2[j, i] if i != j else 0 for i in nodes)) == 0) &#xA;    #------------------------------------------------------------------------    &#xA;    for i in customers:&#xA;        for j in customers:&#xA;            if i != j:  &#xA;                mdl.addConstr(y[j]&amp;lt;= y[i] - df.demand[j]*xt1[i,j] + q1 * (1- xt1[i, j]))&#xA;    for i in customersD:&#xA;        for j in customersD:&#xA;            if i != j:&#xA;                mdl.addConstr(z[j] &amp;lt;= z[i] - df.demand[j]*xt2[i,j] + q2 * (1 - xt2[i, j]))&#xA;    for i in customers:&#xA;        mdl.addConstr(y[i] &amp;gt;=0)&#xA;        mdl.addConstr(y[i] &amp;lt;= q1 - df.demand[i])&#xA;    for i in customersD:&#xA;        mdl.addConstr(z[i] &amp;gt;=0 )&#xA;        mdl.addConstr(z[i] &amp;lt;= q2 - df.demand[i])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;" OwnerUserId="10962" LastActivityDate="2024-01-02T10:55:01.563" Title="Capacited vehicle routing problem with heterogeneous fleet" Tags="|python|gurobi|vehicle-routing|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11465" PostTypeId="2" ParentId="10723" CreationDate="2024-01-03T04:41:23.640" Score="1" Body="&lt;p&gt;It's a while since I asked this question. I have now came across the answer which is as follows:&lt;/p&gt;&#xA;&lt;p&gt;Yes, if the stochastic problem is solved through the horizon based on the realized scenario, it provides a lower bound for (for a minimization problem). This is often called a &lt;strong&gt;posterior bound&lt;/strong&gt;, which is used in papers by &lt;a href=&quot;https://scholar.google.com/citations?user=vDw80QEAAAAJ&amp;amp;hl=en&quot; rel=&quot;nofollow noreferrer&quot;&gt;Warren B Powell&lt;/a&gt;. Indeed, it can be seen as a deterministic version of the problem. For more insights, one can look into:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Cheung, R.K. and Powell, W.B., 1996. An algorithm for multistage&#xA;dynamic networks with random arc capacities, with an application to&#xA;dynamic fleet management. &lt;em&gt;Operations Research&lt;/em&gt;, 44(6), pp.951-963.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Godfrey, G.A. and Powell, W.B., 2002. An adaptive dynamic programming&#xA;algorithm for dynamic fleet management, I: Single period travel&#xA;times. &lt;em&gt;Transportation Science&lt;/em&gt;, 36(1), pp.21-39.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="660" LastActivityDate="2024-01-03T04:41:23.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11466" PostTypeId="2" ParentId="9987" CreationDate="2024-01-03T07:12:37.950" Score="2" Body="&lt;p&gt;To supplement the answer by &lt;a href=&quot;https://or.stackexchange.com/a/9989/198&quot;&gt;Nikos Kazazakis&lt;/a&gt;, I will add that it is always good modeling practice to squeeze as much convexity out of your model as possible, as to reduce degree of nonconvexity. Hence, for a rational objective contribution &lt;span class=&quot;math-container&quot;&gt;$\frac{f(x)}{g(x)}$&lt;/span&gt; with polynomial numerator and denominator, &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g(x)$&lt;/span&gt;, I suggest you start by reducing it using long polynomial division.&lt;/p&gt;&#xA;&lt;p&gt;As example, given &lt;span class=&quot;math-container&quot;&gt;$f(x) = ax^2 + bx + c$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g(x) = gx + h$&lt;/span&gt;, you find that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\frac{f(x)}{g(x)} = rx + s + \frac{q}{gx+h},&#xA;$$&lt;/span&gt;&#xA;for some &lt;span class=&quot;math-container&quot;&gt;$r$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt;. In this simple case, the complexity has reduced from quadratic-over-linear to constant-over-linear, which is trivially representable using second-order cone programming on the convex part of the variable domain; see the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/cqo.html#rational-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;modeling cookbook&lt;/a&gt; maintained by MOSEK for more details.&lt;/p&gt;&#xA;" OwnerUserId="198" LastActivityDate="2024-01-03T07:12:37.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11467" PostTypeId="1" AcceptedAnswerId="11468" CreationDate="2024-01-03T08:25:07.273" Score="8" ViewCount="2067" Body="&lt;p&gt;When is it useful to solve an optimization problem inside a Jupyter Notebook?&#xA;When is it not?&lt;/p&gt;&#xA;&lt;p&gt;What are the advantages/disadvantages?&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2024-01-04T16:42:13.943" Title="When are Jupyter Notebooks used to solve optimization problems in Operations Research?" Tags="|python|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11468" PostTypeId="2" ParentId="11467" CreationDate="2024-01-03T08:56:48.000" Score="12" Body="&lt;p&gt;&lt;strong&gt;TLDR&lt;/strong&gt;: Jupyter Notebooks are a nice tool for proof of concepts (early stages of a project) + playing around + for teaching purposes (tutorials). They should not be used for industrial production. Another way of saying this is that they are good for calling code (I like the term &amp;quot;&lt;em&gt;interactive whitepaper&lt;/em&gt;&amp;quot; used by @Reinderien), not for coding.&lt;/p&gt;&#xA;&lt;p&gt;Jupyter Notebooks allow having your inputs (data), your model, your optimization algorithm and your outputs in one same ecosystem. This makes the whole modeling + solving process relatively smooth (if all these elements are not too big). It is nice to be able to see your raw data before optimization (e.g. a network), followed by the optimized solution (e.g. optimized vehicle routes over the network), without having to change tools/environments. With all the existing libraries, it is easy to plot the structured data with your favorite (or the most relevant) chart, with very little code. This is useful for comparing what if scenarios, changing assumptions, playing around with your model's parameters and visualizing the impact. Jupyter Notebooks are thus a good tool to play around with, to tell a story or for a proof of concept. Last but not least, notebooks are a nice tool for tutorials.&lt;/p&gt;&#xA;&lt;p&gt;Jupyter Notebooks are not suitable for production. Maintenance, testing etc. should be done in some other environment. If the code is too dense, the notebook becomes impractical, hard to read, and perhaps slow to run. Although programming in an object oriented fashion can be done in a notebook, it is not the environment to do so. The notebook is more of an interactive place where you call some other code from somewhere else (e.g. a library, or the core of your code).&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2024-01-04T16:42:13.943" LastActivityDate="2024-01-04T16:42:13.943" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="11469" PostTypeId="2" ParentId="11432" CreationDate="2024-01-03T11:18:42.663" Score="1" Body="&lt;p&gt;In my opinion, the problem could be addressed by defining an appropriate reference system or rather an &lt;strong&gt;appropriate measurement scale&lt;/strong&gt;. We can image &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt; to be the coordinate of two vectors: &lt;em&gt;delay&lt;/em&gt; and &lt;em&gt;resource block&lt;/em&gt;. Both of them belongs to a vector space where a positive scalar product is defined.&#xA;Once the origin of vector space has been established, it is possible to establish an orthogonal frame of reference &lt;span class=&quot;math-container&quot;&gt;$R = \{\mathbf t_1, \mathbf t_2\}$&lt;/span&gt; such that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&amp;lt; \mathbf t_i, \mathbf t_k &amp;gt; = \Delta f_i$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$i=k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&amp;lt; \mathbf t_i, \mathbf t_k &amp;gt; = 0$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$i=k$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that if all measuring devices had the same unit of measurement and the same base unit &lt;span class=&quot;math-container&quot;&gt;$ \Delta f_1=\Delta f_2=1$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; would constitute an orthonormal vector basis. But, this is not your case.&lt;/p&gt;&#xA;&lt;p&gt;You problem is that &lt;span class=&quot;math-container&quot;&gt;$\Delta f_1&amp;lt;&amp;lt;&amp;lt;\Delta f_2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;On the one hand, you could adopt the &lt;em&gt;Gram–Schmidt process&lt;/em&gt; or &lt;em&gt;Gram-Schmidt algorithm&lt;/em&gt; as method of constructing an orthonormal basis.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, you could simply choose an appropriate number &lt;span class=&quot;math-container&quot;&gt;$ \lambda$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$ \lambda \Delta f_1 = \Delta f_2$&lt;/span&gt; (or &lt;span class=&quot;math-container&quot;&gt;$ \lambda \Delta f_2 = \Delta f_1$&lt;/span&gt;) and finally you can replace every coordinate &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; by means of scalar moltiplication (&lt;em&gt;change of scale&lt;/em&gt;) &lt;span class=&quot;math-container&quot;&gt;$\lambda f_1$&lt;/span&gt; while &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt; remains the same.&lt;/p&gt;&#xA;&lt;p&gt;In conclusion, &lt;em&gt;delay&lt;/em&gt; is enlarged by &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and problem becomes&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ min $&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega _{1} \lambda f_1(x) + \omega _{2} f_2(x)$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4114" LastActivityDate="2024-01-03T11:18:42.663" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11470" PostTypeId="2" ParentId="11432" CreationDate="2024-01-03T12:49:04.887" Score="1" Body="&lt;p&gt;You write in a comment that &amp;quot;you want to scale &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt; so that they are as big as the others&amp;quot;. If I understand you correctly, this may be impossible if you do not know the range of values for the functions &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, if you do have knowledge of the two &lt;a href=&quot;https://en.wikipedia.org/wiki/Lexicographic_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;lexicographic&lt;/a&gt; solutions&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  x^{ul}&amp;amp;\in\mbox{arg }\mbox{lex}\min\{ \left(f_1(x),f_2(x)\right):x\text{ feasible}\}\\&#xA;  x^{lr}&amp;amp;\in\mbox{arg }\mbox{lex}\min\{ \left(f_2(x),f_1(x)\right):x\text{ feasible}\}&#xA;\end{align}&lt;/span&gt;&#xA;Then you can simply scale the functions so they take values in e.g. &lt;span class=&quot;math-container&quot;&gt;$[0,1]$&lt;/span&gt; by defining the following scaled functions&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;  \hat{f}_1(x)=\frac{f_1(x)-f_1(x^{ul})}{f_1(x^{lr})-f_1(x^{ul})}\\&#xA;  \hat{f}_2(x)=\frac{f_2(x)-f_2(x^{lr})}{f_2(x^{ul})-f_2(x^{lr})}\\&#xA;\end{align}&lt;/span&gt;&#xA;The idea is to perform a linear transformation that moves the Pareto front into the square &lt;span class=&quot;math-container&quot;&gt;$[0,1]\times[0,1]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Obtaining &lt;span class=&quot;math-container&quot;&gt;$x^{ul}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x^{lr}$&lt;/span&gt; can be done by solving two weighted sum scalarizations fo the form&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}&#xA;  \min w_1f_1(x)+w_2f_2(x)&#xA;\end{equation}&lt;/span&gt;&#xA;by appropriately choosing the weights (to get &lt;span class=&quot;math-container&quot;&gt;$x^{ul}$&lt;/span&gt; chose &lt;span class=&quot;math-container&quot;&gt;$w_1\gg w_2$&lt;/span&gt; and vice versa for &lt;span class=&quot;math-container&quot;&gt;$x^{lr}$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Additional info about lexicographic optimality. I will use Ehrgott notation, and define the ordering &lt;span class=&quot;math-container&quot;&gt;$&amp;lt;_{lex}$&lt;/span&gt; as follows: for two vectors &lt;span class=&quot;math-container&quot;&gt;$y^1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y^2$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$\mathbb{R}^p$&lt;/span&gt; we say that &lt;span class=&quot;math-container&quot;&gt;$y^1&amp;lt;_{lex}y^2$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$y^1_q&amp;lt;y^2_q$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$q=\min\{k\in\{1,...,p\}:y_k^1\neq y_k^2\}$&lt;/span&gt;. For a multi objective optimization problem with &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; objectives and where &lt;span class=&quot;math-container&quot;&gt;$f_1$&lt;/span&gt; is more important than &lt;span class=&quot;math-container&quot;&gt;$f_2$&lt;/span&gt;, which is more important than &lt;span class=&quot;math-container&quot;&gt;$f_3$&lt;/span&gt; and so on, we write a lexicographic optimization problem as &lt;span class=&quot;math-container&quot;&gt;$\mbox{lex}\min\{(f_1,...,f_p):x\text{ feasible}\}$&lt;/span&gt;. A feasible solution &lt;span class=&quot;math-container&quot;&gt;$\hat{x}$&lt;/span&gt; is lexicographically optimal if there exist no other feasible &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$x&amp;lt;_{lex}\hat{x}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="278" LastEditorUserId="278" LastEditDate="2024-01-03T14:08:34.413" LastActivityDate="2024-01-03T14:08:34.413" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11471" PostTypeId="1" CreationDate="2024-01-03T13:21:02.717" Score="1" ViewCount="57" Body="&lt;p&gt;Suppose we have a specific formulation in which contains a special structure. For example, the formulation has a block diagonal format with some linking constraints. As far as I know, this format would be suitable for the decomposition scheme. Now, I am interested to know, is there any benefit to using this special structure with the standard MILP solvers?&lt;/p&gt;&#xA;" OwnerUserId="199" LastEditorUserId="278" LastEditDate="2024-01-03T14:42:40.447" LastActivityDate="2024-01-03T14:42:40.447" Title="Dealing with a problem that contains a specific structure with a standard MILP solver" Tags="|mixed-integer-programming|modeling|solver|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11472" PostTypeId="2" ParentId="11443" CreationDate="2024-01-03T14:28:25.687" Score="0" Body="&lt;p&gt;I was able to solve it as follows&lt;/p&gt;&#xA;&lt;p&gt;Created &lt;span class=&quot;math-container&quot;&gt;$z_{ij}$&lt;/span&gt;, shaped similarly to &lt;span class=&quot;math-container&quot;&gt;$x_{ij}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# zij is auxaillary to determine oi&#xA;z = LpVariable.dicts(&amp;quot;auxiliary&amp;quot;, (range(N), range(N)), cat='Integer')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then, fill with 1's such that the column index multiplied with the '1' equals the position &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; of the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th element. Also enforce binary&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(N):&#xA;prob += lpSum(j*z[i][j] for j in range(N)) == p[i]&#xA;&#xA;for j in range(N):&#xA;    prob += z[i][j] &amp;lt;= 1&#xA;    prob += z[i][j] &amp;gt;= 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In addition, make sure no values are redundantly placed&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(N):&#xA;    prob += lpSum(z[i][j] for j in range(N)) == 1  &#xA;&#xA;&#xA;for j in range(N):&#xA;    prob += lpSum(z[i][j] for i in range(N)) == 1   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then, the exact order can be deduced by taking the index of the row and multiply it with the 1.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for j in range(N):&#xA;prob += o[j] == lpSum(i*z[i][j] for i in range(N))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13029" LastEditorUserId="36" LastEditDate="2024-01-04T15:21:45.920" LastActivityDate="2024-01-04T15:21:45.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11473" PostTypeId="1" CreationDate="2024-01-03T15:27:31.667" Score="1" ViewCount="43" Body="&lt;p&gt;Consider the following problem. I have two regions &lt;span class=&quot;math-container&quot;&gt;$X1=[a,b]$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X2=[b,c]$&lt;/span&gt;. Notice that they are disjoint except for point &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I have a continuous variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and two binary variables, &lt;span class=&quot;math-container&quot;&gt;$y_1,y_2$&lt;/span&gt; which indicate membership of the two sets. I want to model&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x\in X1\implies y_1=1$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x\in X2\implies y_2=1$$&lt;/span&gt;&#xA;So far so good.&lt;/p&gt;&#xA;&lt;p&gt;However, the two regions intersect at one end (point &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;). So, I want to enforce that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x=b\implies y_1=1,y_2=0$$&lt;/span&gt;&#xA;That is, if &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is at level &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; we consider region &lt;span class=&quot;math-container&quot;&gt;$X1$&lt;/span&gt; active instead of &lt;span class=&quot;math-container&quot;&gt;$X2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am finding this surprisingly difficult to model explicitly, without adding a tolerance to &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; in set &lt;span class=&quot;math-container&quot;&gt;$X2$&lt;/span&gt;. Any hints?&lt;/p&gt;&#xA;" OwnerUserId="766" LastEditorUserId="766" LastEditDate="2024-01-03T18:08:36.017" LastActivityDate="2024-01-03T18:08:36.017" Title="How to model membership to a set using MILP?" Tags="|mixed-integer-programming|modeling|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11474" PostTypeId="1" CreationDate="2024-01-03T17:11:29.817" Score="2" ViewCount="155" Body="&lt;p&gt;Currently, I am working on a scheduling problem and trying to approach it by the logic-based Benders decomposition method. Theoretically, I have everything, i.e., the master and sub problem(s), the feasibility and optimality cuts (or as in logic-based context: combinatorial cuts) and implemented the algorithm in a traditional way: solve the master problem [in my case by the CPLEX in Python API], find the cuts, add the cuts to the master problem, solve the master problem again and ... .&lt;/p&gt;&#xA;&lt;p&gt;I found out that there is a general trend in literature in using the Benders decomposition approach in &amp;quot;one tree&amp;quot; branch and cut structure. I have read several materials and grasped the general concept, but still have some questions. I would be grateful if anyone could please help me:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I still don’t get how the branch and cut with the lazy or user constraints procedure works. I especially can’t understand how the CPLEX expands the tree as it generates a new cut at each node and updates the constraints pool. For example, in my problem, at any incumbent node of the master problem, a specific type of cut can be inferred. This cut is supposed to be added to the cut pool and checked on the other nodes. My puzzlement is regarding the tree. Assume that one of the early nodes of the master is pruned/disregarded due to the fact that its lower bound is worse than the initial best bound (we have a min problem). However, later on and after adding several sets of cuts- and lifting the lower bound, it turns out that the node was actually the optimal solution. What would happen now? How the CPLEX treat this case?&#xA;&lt;strong&gt;For more clarification:&lt;/strong&gt;  I do understand the mechanism of the callbacks (and the difference between lazy and user cuts), but what I am struggling with is how the cuts are generated and put into the pool. Based on the algorithm, no cut is known at the beginning, but rather, the cut might be introduced as the master problem is solved and the solution checked in the subproblems.&#xA;Therefore, the pool starts empty, and grows dynamically, as a solution to the master problem is found. I can't see how it works in a single-tree structure. In my eyes, the CPLEX should work as follows: It generates the tree of the master problem, whenever it reaches an incumbent, the subproblems are checked and some cuts are generated and added to the pool. Then the new cuts must be checked also on the other [already visited] nodes and the tree gets updated anytime a cut is found. Do I understand it correctly? Have I misunderstood something?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I also face programming problems in implementing the algorithm on a single tree in Python using CPLEX. I face some nonsensical errors which can't debug effectively. Unfortunately, I can’t trace the errors from the IBM community, or find any simple but accurate implemented template or resource.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13043" LastEditorUserId="13045" LastEditDate="2024-01-04T15:21:07.037" LastActivityDate="2024-02-03T16:06:00.683" Title="Implementing Logic-based Benders decomposition on a single search tree" Tags="|python|cplex|benders-decomposition|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11475" PostTypeId="2" ParentId="11467" CreationDate="2024-01-03T20:40:14.237" Score="4" Body="&lt;p&gt;I want to expand on the point by @kuifje, based on your comments on their answer. I know your library (&lt;code&gt;OptaPlanner&lt;/code&gt;, now &lt;code&gt;Timefold&lt;/code&gt;) from back when I was working with &lt;code&gt;jsprit&lt;/code&gt; &lt;em&gt;a lot&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Notebooks might be basically &lt;em&gt;forced&lt;/em&gt; on individuals in environments like Databricks. In that case, I don't have a choice but to work with some kind of notebook, which is essentially &lt;code&gt;jupyter&lt;/code&gt;. However, I &lt;em&gt;hate&lt;/em&gt; them. As to when I would start a project in python &amp;quot;proper&amp;quot; (making it an installable package) -&amp;gt; immediately if possible.&lt;/p&gt;&#xA;&lt;p&gt;They work for POCs to some extent but there is an underlying ipython kernel that stores previous values in RAM and it can lead to really confusing bugs if things get re-named or transformed between cells. The continuity of the code is terrible to follow during development, and just laborious.&lt;/p&gt;&#xA;&lt;p&gt;When I wanted to draw on &lt;code&gt;jsprit&lt;/code&gt;, I wrapped the whole thing in &lt;code&gt;Spring Boot&lt;/code&gt; and made my own RESTful API with it self-hosted.&lt;/p&gt;&#xA;&lt;p&gt;Such things are not necessarily possible in corporate setups that use things like Databricks, but I'd take the API &lt;em&gt;any day&lt;/em&gt; if I could and just run the systems myself.&lt;/p&gt;&#xA;" OwnerUserId="7236" LastEditorUserId="350" LastEditDate="2024-01-04T10:14:03.553" LastActivityDate="2024-01-04T10:14:03.553" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11476" PostTypeId="2" ParentId="11474" CreationDate="2024-01-03T22:44:33.427" Score="0" Body="&lt;p&gt;The first thing to understand is that in CPLEX &amp;quot;lazy constraints&amp;quot; and &amp;quot;user cuts&amp;quot; are very different thing. Long ago I wrote about &lt;a href=&quot;https://orinanobworld.blogspot.com/2012/08/user-cuts-versus-lazy-constraints.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;the difference&lt;/a&gt;. The important thing here is that you use lazy constraints for the Benders cuts.&lt;/p&gt;&#xA;&lt;p&gt;The next thing to understand (expanding on the comment from @fontanf) is that the lazy constraint callback is triggered whenever CPLEX thinks it has a new incumbent. Before the incumbent takes effect, CPLEX calls the callback. If your callback introduces a cut violated by the incumbent, the incumbent is discarded. If your callback does not produce a violated cut, then you are telling CPLEX that the new incumbent is feasible. So CPLEX will never prune nodes based on an invalid incumbent, because the incumbent will not be an incumbent until it is validated by the lazy constraint callback.&lt;/p&gt;&#xA;&lt;p&gt;Finally, regarding your problems with the code, CPLEX ships with a number of examples of Benders decomposition. If X is the directory where CPLEX Studio is installed, then X/cplex/examples/src/python is where the Python examples are stored. The ones that implement Benders decomposition are bendersatsp2.py, bendersatsp.py, benders.py and facility.py.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-03T22:44:33.427" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11477" PostTypeId="2" ParentId="11467" CreationDate="2024-01-04T03:11:13.153" Score="7" Body="&lt;p&gt;The only use case where I find notebooks to be suitable is as an &amp;quot;interactive whitepaper&amp;quot; where explanatory formatted prose can be nicely interspersed with graphical content, equations, etc., and if you're lucky, easily rendered to HTML. If you intend on demonstrating a concept in academia, or as part of presenting a commercial design investigation, etc., then notebooks can be suitable.&lt;/p&gt;&#xA;&lt;p&gt;In all other cases - even (dare I say especially) for prototyping - stay far, far away. Typical - though not strictly necessary - in notebooks is a vast swamp of global state with no functions, no modules, and no scope. Surprise side-effects, symbol conflicts, scope pollution and poor memory management abound. Languages like Python offer functions and classes for a reason. Flattening out a script makes design and debugging a nightmare, even at the very beginning of a project. If I had to paint with a stereotypical brush the worst academic code I've ever seen, it's in a notebook-style single script with no scope, no functions, no tests, and a list of global variables as long as my arm.&lt;/p&gt;&#xA;" OwnerUserId="11118" LastActivityDate="2024-01-04T03:11:13.153" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11478" PostTypeId="1" CreationDate="2024-01-04T09:34:40.070" Score="0" ViewCount="118" Body="&lt;p&gt;I have the following constraints. The first ensures that in my shift plan there are always exactly two days off between blocks of working days and only then does the next block begin.&lt;/p&gt;&#xA;&lt;p&gt;It reads as follows.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; is the day index and &lt;span class=&quot;math-container&quot;&gt;$y_{it}$&lt;/span&gt; indicates whether a person &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; works on day &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$y_{i,t}=1$&lt;/span&gt;) or not (&lt;span class=&quot;math-container&quot;&gt;$y_{i,t}=0$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    1 \le y_{i,t-1} + y_{i,t+1} \le 1 + y_{i,t}~~~~\forall i\in I,t\in \{2,\ldots,\mid T\mid -1\}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I generalise this constraint so that it not only applies to two days? For example, that must always be at least three free days in a row. It should be possible to control the number arbitrarily via the parameter &lt;span class=&quot;math-container&quot;&gt;$Sec$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The second ones go as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\ &amp;amp;\sum_{t=1}^7y_{i,t} \geq 5 \forall i \in I\\&#xA;\ &amp;amp;\sum_{t=8}^{14}y_{i,t} \geq 5\forall i \in I&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;They are to ensure that in the period from &lt;span class=&quot;math-container&quot;&gt;$t=1-7$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t=8-14$&lt;/span&gt; the sum of &lt;span class=&quot;math-container&quot;&gt;$y_{i,t}$&lt;/span&gt; is at least &lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;. How can I combine these two constraints and also generalise them. So that it is not only for &lt;span class=&quot;math-container&quot;&gt;$T=14$&lt;/span&gt;, but also for all other multiples of &lt;span class=&quot;math-container&quot;&gt;$7$&lt;/span&gt;, for example?&lt;/p&gt;&#xA;" OwnerUserId="12086" LastEditorUserId="2556" LastEditDate="2024-01-04T15:46:24.627" LastActivityDate="2024-02-03T17:02:25.263" Title="Generalize working days constraints" Tags="|linear-programming|modeling|constraint|binary-variable|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11479" PostTypeId="2" ParentId="11478" CreationDate="2024-01-04T10:27:07.210" Score="0" Body="&lt;p&gt;I will drop index &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; in what follows.&lt;/p&gt;&#xA;&lt;p&gt;To enforce at least &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; free days in a row, you need to forbid patterns with &lt;code&gt;101&lt;/code&gt;, which translates in CNF as:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\neg (y_{t-1}\wedge \neg y_{t}\wedge y_{t+1}) &#xA;&amp;amp;\equiv &#xA;\neg y_{t-1} \vee y_{t} \vee \neg y_{t+1} \\&#xA;&amp;amp;\equiv (1-y_{t-1})+y_{t}+(1-y_{t+1}) \ge 1 \\&#xA;&amp;amp;\equiv 1+y_{t} \ge y_{t-1} +y_{t+1}&#xA;\end{align}&lt;/span&gt;&#xA;With &lt;span class=&quot;math-container&quot;&gt;$y_{t-1}+y_{t+1}\ge 1$&lt;/span&gt;, you are also enforcing &lt;span class=&quot;math-container&quot;&gt;$\neg y_{t-1} \implies y_{t+1}$&lt;/span&gt; which forbids you from having more than &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; free days in row (patterns &lt;code&gt;000&lt;/code&gt;). So your constraints are correct. Note however that this constraint also forbids patterns &lt;code&gt;010&lt;/code&gt;, which may be overly restrictive (?). You may want to consider instead:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_{t-1} \le y_t + y_{t+2}&#xA;$$&lt;/span&gt;&#xA;in order to enforce &lt;span class=&quot;math-container&quot;&gt;$y_{t-1}\wedge \neg y_t \implies y_{t+2}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Similarly, you can enforce at least &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; free days in a row by forbidding patterns with &lt;code&gt;1001&lt;/code&gt;, which translates in CNF as:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\neg (y_{t-1}\wedge \neg y_{t}\wedge \neg y_{t+1} \wedge y_{t+2}) &#xA;&amp;amp;\equiv &#xA;\neg y_{t-1} \vee y_{t} \vee  y_{t+1}  \vee \neg y_{t+2}\\&#xA;&amp;amp;\equiv (1-y_{t-1})+y_{t}+y_{t+1}+(1-y_{t+2}) \ge 1 \\&#xA;&amp;amp;\equiv 1+y_{t}+y_{t+1} \ge y_{t-1} +y_{t+2}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And to forbid more than &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; days in a row, you need to enforce &lt;span class=&quot;math-container&quot;&gt;$y_{t-1}\wedge \neg y_t \implies y_{t+3}$&lt;/span&gt; with:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_{t-1} \le y_t + y_{t+3}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;More generally, to have at least &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; free days in a row, you can enforce:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_{t-1} \wedge \neg y_{t} \implies \neg y_k \quad \forall k=t+1,...,t+n-1&#xA;$$&lt;/span&gt;&#xA;with:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\neg (y_{t-1}\wedge \neg y_{t})\vee \neg y_k &#xA;&amp;amp;\equiv &#xA;\neg y_{t-1} \vee y_{t} \vee  \neg y_{k}  \\&#xA;&amp;amp;\equiv (1-y_{t-1})+y_{t}+(1-y_{k}) \ge 1 \\&#xA;&amp;amp;\equiv 1+y_{t}\ge y_{t-1} +y_{k} \quad \quad \quad \quad \quad \quad \quad \forall k=t+1,...,t+n-1&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And to forbid more than &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; days in a row, you need to enforce &lt;span class=&quot;math-container&quot;&gt;$y_{t-1}\wedge \neg y_t \implies y_{t+n}$&lt;/span&gt; with:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;y_{t-1} \le y_t + y_{t+n}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the second part of your question, you can simply write&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{t=k}^{k+6}y_k \ge 5 \quad \forall  u=0,1,2,... \quad \forall k=7u+1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Some comments&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There is an excellent post by @ErwinKalvelagen on this topic &lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2018/03/production-scheduling-minimum-up-time.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;See also the very similar question answered by @RobPratt &lt;a href=&quot;https://or.stackexchange.com/questions/4013/how-to-enforce-this-specific-constraint-in-pulp?rq=1&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Since you want shifts which are quite well structured, it might be interesting to generate them beforehand and to select the best ones with a set covering formulation. A similar example is given &lt;a href=&quot;https://or.stackexchange.com/questions/3337/custom-nurse-rostering-problem?rq=1&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="231" LastEditDate="2024-01-04T13:41:32.507" LastActivityDate="2024-01-04T13:41:32.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11481" PostTypeId="1" AcceptedAnswerId="11485" CreationDate="2024-01-04T13:32:10.173" Score="2" ViewCount="82" Body="&lt;p&gt;I'm working on a MIP optimization problem where I'm trying to reorganize a list of purchases (negative integer numbers) and requests (positive integer number) to maximize the number of positive values in the cumulative_sum array, while minimizing the number of requests movements.&#xA;Only the requests can &amp;quot;jump&amp;quot;, the relative position of purchase should not change.&#xA;For ex:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;-1 cumsum: -1&#xA;-7 cumsum: -8&#xA;5  cumsum: -3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;cumsum array = [-1,-8,-3], number of positive values in the cumsum array = 0.&#xA;As I result I expect:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;5  cumsum: 5&#xA;-1 cumsum: 4&#xA;-7 cumsum: -3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;number of positive values in the cumsum array = 2&#xA;My issue is on the objective function. The first objective (number of positive values in the cumsum array) could be be even order of thousands, while the jump parts, provided a jump = 1, can be 10.&#xA;How to tackle this problem? Or maybe I can move the cumsum part in a constraint?&lt;/p&gt;&#xA;" OwnerUserId="12967" LastEditorUserId="500" LastEditDate="2024-01-05T13:36:10.193" LastActivityDate="2024-01-06T00:49:21.383" Title="Help with choosing the penalty parameters in the objective function" Tags="|mixed-integer-programming|multi-objective-optimization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11482" PostTypeId="2" ParentId="6301" CreationDate="2024-01-05T06:35:52.110" Score="2" Body="&lt;p&gt;As mentioned, both simplex method and barrier method don't suit GPUs. However, recently Google successfully gives a first-order method PDLP[1]. By using tricks like restarting, the performance of PDLP is improved but still not as good as other non-first-order-methods. But the difference is that this approach could be efficiently realized on GPU. With a little bit modification, a gpu version of PDLP in both Julia and C is given[2][3] and performance is compared. Sources are available at github[4][5].&lt;/p&gt;&#xA;&lt;p&gt;[1] &lt;a href=&quot;https://arxiv.org/abs/2106.04756&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/2106.04756&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[2] &lt;a href=&quot;https://arxiv.org/abs/2311.12180&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/2311.12180&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[3] &lt;a href=&quot;https://arxiv.org/abs/2312.14832&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/2312.14832&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[4] &lt;a href=&quot;https://github.com/jinwen-yang/cuPDLP.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/jinwen-yang/cuPDLP.jl&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;[5] &lt;a href=&quot;https://github.com/COPT-Public/cuPDLP-C&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/COPT-Public/cuPDLP-C&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4569" LastEditorUserId="231" LastEditDate="2024-01-05T13:47:35.100" LastActivityDate="2024-01-05T13:47:35.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11483" PostTypeId="1" CreationDate="2024-01-05T08:33:26.950" Score="1" ViewCount="86" Body="&lt;p&gt;I have the following constraints for my roster optimisation problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    &amp;amp;(1-r_{i,t})\le \sum_{j=t-\chi}^{t-1}sc_{i,j}\quad &amp;amp;\forall i\in I, t\in \{1+\chi,\ldots,T\}&#xA;\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;M\cdot (1-r_{i,t})\ge \sum_{j=t-\chi}^{t-1}sc_{i,j}\quad &amp;amp;\forall i\in I, t\in \{1+\chi,\dots,T\}&#xA;\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;r_{i,t}=0\quad &amp;amp;\forall i\in I, t\in \{1,\ldots,\chi\}&#xA;\end{align}&lt;/span&gt;&#xA;It is intended to ensure that the binary variable &lt;span class=&quot;math-container&quot;&gt;$r_{it}$&lt;/span&gt; assumes the value one if the binary variable &lt;span class=&quot;math-container&quot;&gt;$sc_{i,t}$&lt;/span&gt; was always zero in the previous &lt;span class=&quot;math-container&quot;&gt;$\chi$&lt;/span&gt; days (there was no shift change in the last &lt;span class=&quot;math-container&quot;&gt;$\chi$&lt;/span&gt; days). Otherwise, &lt;span class=&quot;math-container&quot;&gt;$r_{i,t}=0$&lt;/span&gt; should apply if there was such a shift change. The variable &lt;span class=&quot;math-container&quot;&gt;$r_{i,t}$&lt;/span&gt; is then used in the model to enable work performance to be restored. Now to my question / problem.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is it possible to improve / summarise the three constraints?&lt;/li&gt;&#xA;&lt;li&gt;Main problem: The variable &lt;span class=&quot;math-container&quot;&gt;$r_{i,t}$&lt;/span&gt; can also take the value of 1 in this modelling if, for example, there was no change on the first three days (&lt;span class=&quot;math-container&quot;&gt;$t=1-3$&lt;/span&gt;). However, I actually want to model that this possible assignment of &lt;span class=&quot;math-container&quot;&gt;$r_{i,t}$&lt;/span&gt; is only possible from the first shift change in the planning horizon. In other words, only once &lt;span class=&quot;math-container&quot;&gt;$sc_{i,t}=1$&lt;/span&gt; has applied.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Example 1:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\chi=2$&lt;/span&gt; applies. &lt;span class=&quot;math-container&quot;&gt;$sc_{i,t}=[0,0,0,1,1,0,0,0,0]$&lt;/span&gt;, then it currently follows that&lt;span class=&quot;math-container&quot;&gt;$r_{i,t}= [0,0,1,1,0,0,0,0,1]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Example 2 (as it should be): &lt;span class=&quot;math-container&quot;&gt;$\chi=2$&lt;/span&gt; applies.&#xA;&lt;span class=&quot;math-container&quot;&gt;$sc_{i,t}=[0,0,0,0,1,1,0,0,0]$&lt;/span&gt;, then it should follow:&#xA;&lt;span class=&quot;math-container&quot;&gt;$r_{i,t}= [0,0,0,0,0,0,0,0,1]$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12086" LastEditorUserId="500" LastEditDate="2024-01-05T13:36:56.717" LastActivityDate="2024-01-05T15:42:38.213" Title="Problems with Big-M Constraint" Tags="|modeling|integer-programming|constraint|logical-constraints|big-m|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11484" PostTypeId="2" ParentId="11483" CreationDate="2024-01-05T09:15:46.397" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;You are enforcing:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\lnot sc_{t-\chi}\land\dots\land \lnot sc_{t-1} \implies r_t &#xA;&amp;amp;\equiv \lnot (\lnot sc_{t-\chi}\land\dots\land \lnot sc_{t-1}) \lor r_t \\&#xA;&amp;amp;\equiv (sc_{t-\chi}\lor\dots\lor sc_{t-1}) \lor r_t \\&#xA;&amp;amp;\equiv sc_{t-\chi}+\dots+sc_{t-1}+r_t \ge 1 \\&#xA;&amp;amp;\equiv 1-r_t \le sc_{t-\chi}+\dots+sc_{t-1}&#xA;\end{align}&lt;/span&gt;&#xA;which is your first constraint.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;You are also enforcing:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA; sc_{t-\chi}\lor\dots\lor sc_{t-1} \implies \lnot r_t &#xA;&amp;amp;\equiv \lnot ( sc_{t-\chi}\lor\dots\lor  sc_{t-1}) \lor \lnot r_t \\&#xA;&amp;amp;\equiv (\lnot sc_{t-\chi}\land\dots\land \lnot sc_{t-1}) \lor \lnot r_t \\&#xA;&amp;amp;\equiv \land_{k=t-\chi}^{t-1} (\lnot sc_k \lor \lnot r_t) \\&#xA;&amp;amp;\equiv 1-sc_{k}+1-r_t \ge 1 &amp;amp;&amp;amp;\forall k=t-\chi,\dots,t-1\\&#xA;&amp;amp;\equiv sc_k \le 1-r_t &amp;amp;&amp;amp;\forall k=t-\chi,\dots,t-1\\&#xA;\end{align}&lt;/span&gt;&#xA;This is the disaggregated version of your second constraint (tighter), with &lt;span class=&quot;math-container&quot;&gt;$M=\chi$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;If my understanding is correct (?), you want to enforce:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(\lnot sc_{t-\chi}\land\dots\land \lnot sc_{t-1}) \land sc_t \implies r_t &#xA;$$&lt;/span&gt;&#xA;Using the same methodology:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\lnot sc_{t-\chi}\land\dots\land \lnot sc_{t-1} \land sc_t \implies r_t&#xA;&amp;amp;\equiv \lnot (\lnot sc_{t-\chi}\land\dots\land \lnot sc_{t-1} \land  sc_t) \lor r_t \\&#xA;&amp;amp;\equiv (sc_{t-\chi}\lor\dots\lor sc_{t-1} \lor \lnot sc_t) \lor r_t \\&#xA;&amp;amp;\equiv sc_{t-\chi}+\dots+sc_{t-1}+(1-sc_t)+r_t \ge 1 \\&#xA;&amp;amp;\equiv sc_t \le sc_{t-\chi}+\dots+sc_{t-1}+r_t&#xA;\end{align}&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="500" LastEditDate="2024-01-05T15:42:38.213" LastActivityDate="2024-01-05T15:42:38.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11485" PostTypeId="2" ParentId="11481" CreationDate="2024-01-06T00:49:21.383" Score="0" Body="&lt;p&gt;Based on comments, you might consider a &amp;quot;lexicographic&amp;quot; multiobjective model with two objectives: (1) maximize the number of cumulative sums that are positive; and (2) minimize the number of jumps. In the lexicographic approach, objective (1) has &amp;quot;preemptive&amp;quot; priority over objective (2), meaning no improvement in (2) justifies a sacrifice in (1).&lt;/p&gt;&#xA;&lt;p&gt;Once upon a time, solving a lexicographic bicriterion model meant solving a MIP to maximize (1), then locking in the optimal value of (1) as a constraint and solving the modified MIP to minimize (2). That is still an option, but some solvers (definitely CPLEX, I'm pretty sure Gurobi, and I think Xpress) have built-in support for lexicographic multiobjective models. My impression is that they modify the branch-and-bound approach so that a node that equals (to within tolerance) the incumbent value of the first objective is not pruned unless its second objective is worse than the incumbent (with this logic generalized when there are three or more objectives). So, basically, they solve a single MIP model, taking all objectives into consideration.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-06T00:49:21.383" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11487" PostTypeId="1" CreationDate="2024-01-06T22:12:29.713" Score="0" ViewCount="118" Body="&lt;p&gt;Based on the suggestion in the comment below. I edited my model by removing &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt;. Here is the context:&#xA;I'm dealing with the CVRP with two heterogeneous fleets with the following capacities &lt;span class=&quot;math-container&quot;&gt;$q_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q_2$&lt;/span&gt;. I'm using the model based on flow. I tried to sepearate constraints for each type of fleet but the result is a disconnected route. Thus, the following model consists in combining the constaints. When &lt;span class=&quot;math-container&quot;&gt;$x_1(i,j)=0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_2(i,j)=1$&lt;/span&gt; and when &lt;span class=&quot;math-container&quot;&gt;$x_1(i,j)=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_2(i,j)=0$&lt;/span&gt;. For the last constraint on capacity, I define &lt;span class=&quot;math-container&quot;&gt;$CL$&lt;/span&gt; the set of customers where demand doesn't exceed &lt;span class=&quot;math-container&quot;&gt;$q_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\min \sum_{i \in N, j \in N} {c_1(i,j)*x_1(i,j) + c_2(i,j)*x_2(i,j)}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in C} x_1(0,j) &amp;lt;= n$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{j \in C} x_2(0,j) &amp;lt;= m$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in C} x_1(i,0) &amp;lt;= n$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in C} x_2(i,0) &amp;lt;= m$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in N} x_1(i,j) + x_2(i,j) = 1 \quad \forall j \in C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in N} x_1(i,j) - x_1(j,i) = 0 \quad \forall j \in C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i \in N} x_2(i,j) - x_2(j,i) = 0 \quad \forall j \in C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y(j) + z(j) &amp;lt;= y(i) + z(i) -d_j*(x_1(i,j) + x_2(i,j)) + M*(1-(x_1(i,j) + x_2(i,j)) \quad \forall i \in C, j \in C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ 0 &amp;lt;= y(i) &amp;lt;= q_1 - d_i \quad \forall i \in C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ 0 &amp;lt;= z(i) &amp;lt;= q_2 - d_i \quad \forall i \in CL$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I run the code on the following data (&lt;span class=&quot;math-container&quot;&gt;$q_1=35$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$q_2=15$&lt;/span&gt;):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    lat  long  demand&#xA;0  30.0  40.0       0&#xA;1  37.0  52.0      19&#xA;2  49.0  49.0      30&#xA;3  52.0  64.0      16&#xA;4  31.0  62.0      23&#xA;5  52.0  33.0      11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The solution is wrong since the demand of the customer 4 is 23 &amp;gt;= q_2 = 15:&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_1 = [(0, 2), (2, 5), (1, 3), (3, 0), (5, 0), (0, 1)]&#xA;x_2 = [(4, 0), (0, 4)]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;y[1] = 16.0&#xA;y[2] = 0.0&#xA;y[3] = 0.0&#xA;y[4] = 0.0&#xA;y[5] = 0.0&#xA;z[1] = 7.615501519756847&#xA;z[2] = 11.0&#xA;z[3] = 7.615501519756847&#xA;z[4] = 0.7720364741641355&#xA;z[5] = 0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have doubt in the constraint 8 that assure the flow. When I seperate this type of constraint, I got disconnected routes. Someone can help me in this model? I'm not sure what is wrong in my model. Does anyone have any idea?&#xA;Thank you&lt;/p&gt;&#xA;" OwnerUserId="10962" LastEditorUserId="10962" LastEditDate="2024-01-07T18:58:38.753" LastActivityDate="2024-01-08T22:53:24.147" Title="Vehicle Routing Problem with Two fleets" Tags="|gurobi|vehicle-routing|gurobipy|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="11488" PostTypeId="1" AcceptedAnswerId="11490" CreationDate="2024-01-07T00:32:09.043" Score="3" ViewCount="375" Body="&lt;p&gt;I'm trying to create an optimization problem where one of my constraints represents a median of another decision variable. Suppose I have decision variables &lt;span class=&quot;math-container&quot;&gt;$\bf{y}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;. My problem will look something like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}\min &amp;amp;\quad f(z)\\\ \text{s.t.} &amp;amp;\quad\text{constraint that defines z to be the median value of y}\\\ &#xA;&amp;amp;\quad [\text{other constraints with y}]\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm not sure how to express this constraint. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="4229" LastActivityDate="2024-01-07T18:56:00.937" Title="How to set up a constraint that represents a median?" Tags="|constraint|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11489" PostTypeId="2" ParentId="11488" CreationDate="2024-01-07T17:17:28.110" Score="2" Body="&lt;p&gt;First you may need to sort your optimization variables. Taking idea from Dr. Kalvelagen (&lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2016/12/sorting-inside-mip-model.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;) &amp;amp; &lt;a href=&quot;https://yalmip.github.io/example/weightedsort/&quot; rel=&quot;nofollow noreferrer&quot;&gt;YALMIP&lt;/a&gt; define additional continuous variable &lt;span class=&quot;math-container&quot;&gt;$0 z$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; of same domain s &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; &amp;amp; &lt;span class=&quot;math-container&quot;&gt;$i \times i$&lt;/span&gt; matrix of binary variables &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Basically&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_i = p_{i,j}x_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_i z_{i,j} = y_j \quad \forall j$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_j z_{i,j} = x_i \quad \forall i$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_i p_{i,j} = 1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_j p_{i,j} = 1$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_i \le x_{i+1}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{i,j} \le Mp_{i,j}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Median = &lt;span class=&quot;math-container&quot;&gt;$x_{I+1\over2}$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; is odd, else &lt;span class=&quot;math-container&quot;&gt;${x_{k}+x_{k+1}}\over 2$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$k={{I}\over2}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2024-01-07T18:56:00.937" LastActivityDate="2024-01-07T18:56:00.937" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11490" PostTypeId="2" ParentId="11488" CreationDate="2024-01-07T17:44:53.690" Score="7" Body="&lt;p&gt;Suppose you have an odd number of variables &lt;span class=&quot;math-container&quot;&gt;$y_1,\dots,y_{2k+1}$&lt;/span&gt;.  Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$u_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$v_i$&lt;/span&gt; to indicate whether &lt;span class=&quot;math-container&quot;&gt;$z \ge y_i$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$z \le y_i$&lt;/span&gt;, respectively.  Now impose constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_i u_i &amp;amp;= k+1 \tag1\label1 \\&#xA;\sum_i v_i &amp;amp;= k+1 \tag2\label2 \\&#xA;u_i = 1 &amp;amp;\implies z \ge y_i &amp;amp;&amp;amp;\text{for all $i$} \tag3\label3 \\&#xA;v_i = 1 &amp;amp;\implies z \le y_i &amp;amp;&amp;amp;\text{for all $i$} \tag4\label4&#xA;\end{align}&lt;/span&gt;&#xA;You can linearize the indicator constraints \eqref{3} and \eqref{4} via big-M constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_i - z &amp;amp;\le M(1-u_i) &amp;amp;&amp;amp;\text{for all $i$} \tag{3'}\label{3'} \\&#xA;z - y_i &amp;amp;\le M(1-v_i) &amp;amp;&amp;amp;\text{for all $i$} \tag{4'}\label{4'}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-01-07T18:21:51.577" LastActivityDate="2024-01-07T18:21:51.577" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11491" PostTypeId="2" ParentId="11487" CreationDate="2024-01-07T22:53:53.637" Score="1" Body="&lt;p&gt;Also since depot &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; is not part of &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; so for arcs&lt;span class=&quot;math-container&quot;&gt;$(0,4),(4,0)$&lt;/span&gt; constraint 8 isn't applicable.&lt;br /&gt;&#xA;Together with bounds on counters &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; the solver finds &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; more feasible so long it meets constraints&lt;br /&gt;&#xA;If you want second type of vehicles to cover more routes try increasing the capacity &lt;span class=&quot;math-container&quot;&gt;$q_2$&lt;/span&gt; or reducing demand at the customer nodes.&lt;/p&gt;&#xA;&lt;p&gt;In case you'd want vehicle to serve a customer node only if &lt;span class=&quot;math-container&quot;&gt;$q_2 \le d_i$&lt;/span&gt; then you can add a constraint&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$q^k (\sum_jx_{j,i}^k - 1) \le d_i - q^k \quad \forall k=1,2 \ \ \forall i \in C$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or for depot specific constraint since constraint (8) is taking care&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$q^k (x_{0,i}^k+x_{i,0}^k - 1) \le d_i -q^k \quad \forall k=1,2 \ \ \forall i \in C$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2024-01-08T22:53:24.147" LastActivityDate="2024-01-08T22:53:24.147" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="11492" PostTypeId="1" CreationDate="2024-01-08T15:02:54.127" Score="2" ViewCount="318" Body="&lt;p&gt;I have the following problem. I have a Nurse rostering problem and want to model the following. I have the indices &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; (days), &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; (nurse), &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; (shift). My planning period &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; is 28 days. Now I want to include weekend work without having to introduce new indices.&lt;/p&gt;&#xA;&lt;p&gt;I would need the following constraints. In a period of 14 days, 1) one weekend must remain completely free and 2) once it must be completely occupied.&#xA;So for the period from &lt;span class=&quot;math-container&quot;&gt;$d=1-14$&lt;/span&gt; either a) work must be done on days 6-7 and not on 13-14 or b) the other way round. And the whole thing should be repeated every 14 days. Twice for 28 days. 3) In addition, after a weekend of work, Monday should be free. How do I get this modeled? I really have no idea how to start. The constraints should be compliant for an LP.&lt;/p&gt;&#xA;&lt;p&gt;I have the variable &lt;span class=&quot;math-container&quot;&gt;$y_{id}$&lt;/span&gt; which tells me whether nurse &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is working on day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_{ids}$&lt;/span&gt; whether a nurse is working shift &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; on day &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This would be my idea for question 3:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}y_{i(t-1)}+y_{it}\le 1 \forall i \in I, t \in T \{8,\ldots,\mid T \mid - 6\}\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="13061" LastEditorUserId="500" LastEditDate="2024-01-08T15:42:04.687" LastActivityDate="2024-01-08T16:28:02.953" Title="How to model weekend constraints in a nurse rostering problem?" Tags="|mixed-integer-programming|constraint|scheduling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11493" PostTypeId="2" ParentId="11492" CreationDate="2024-01-08T15:29:20.750" Score="0" Body="&lt;p&gt;In general for rotating periods a standard way to model (attributing to model by @Kuifje &lt;a href=&quot;https://or.stackexchange.com/questions/11478/generalize-working-days-constraints&quot;&gt;link&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{i,k}+y_{i,k+7} = 1 \quad \forall u=0,1,2 \ \ \forall d=6,7 \ \ \forall k =7u+d$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$y_{i,k} = y_{i,k+1} \ \ \forall u=0,1,2 \ \ \forall k =7u+6$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2024-01-08T16:24:21.817" LastActivityDate="2024-01-08T16:24:21.817" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11494" PostTypeId="2" ParentId="11492" CreationDate="2024-01-08T16:10:33.270" Score="4" Body="&lt;p&gt;You want to enforce&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(y_{i,6} \land y_{i,7} \land \lnot y_{i,13} \land \lnot y_{i,14})&#xA;\lor&#xA;(\lnot y_{i,6} \land \lnot y_{i,7} \land y_{i,13} \land y_{i,14}).$$&lt;/span&gt;&#xA;Rewriting in conjunctive normal form yields&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(y_{i,6} \lor \lnot y_{i,7}) &#xA;\land &#xA;(y_{i,7} \lor y_{i,13}) &#xA;\land &#xA;(\lnot y_{i,13} \lor y_{i,14})&#xA;\land &#xA;(\lnot y_{i,6} \lor \lnot y_{i,14})&#xA;,$$&lt;/span&gt;&#xA;from which we immediately obtain linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_{i,6} + (1 - y_{i,7}) &amp;amp;\ge 1 \\&#xA;y_{i,7} + y_{i,13} &amp;amp;\ge 1 \\&#xA;(1 - y_{i,13}) + y_{i,14} &amp;amp;\ge 1 \\&#xA;(1 - y_{i,6}) + (1 - y_{i,14}) &amp;amp;\ge 1&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This system simplifies to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{i,6} = y_{i,7} = 1 - y_{i,13} = 1 - y_{i,14}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-01-08T16:28:02.953" LastActivityDate="2024-01-08T16:28:02.953" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11495" PostTypeId="1" CreationDate="2024-01-09T07:31:12.057" Score="0" ViewCount="71" Body="&lt;p&gt;I am reading a &lt;a href=&quot;https://sites.pitt.edu/%7Ebzeng/opti/bi_level_reform_online1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt; where the authors made the following statement on page 16:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Vm4iD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Vm4iD.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I wonder why dropping the 'min' operator inside a 'max' objective function is a valid operation here. Any explanation with simple example will be highly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="13064" LastEditorUserId="13064" LastEditDate="2024-01-09T16:22:21.877" LastActivityDate="2024-01-09T16:22:21.877" Title="Removing min operator from max objective" Tags="|mixed-integer-programming|modeling|reformulation-linearization|bilevel-optimization|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11496" PostTypeId="1" CreationDate="2024-01-09T12:16:28.617" Score="2" ViewCount="233" Body="&lt;p&gt;I have the following question. I have the following physician problem with the indices &lt;span class=&quot;math-container&quot;&gt;$I$&lt;/span&gt; (doctor), &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; (days) and &lt;span class=&quot;math-container&quot;&gt;$J$&lt;/span&gt; (shifts). &lt;span class=&quot;math-container&quot;&gt;$x_{itj}$&lt;/span&gt; is the decision variable, &lt;span class=&quot;math-container&quot;&gt;$d_{tj}$&lt;/span&gt; is the demand and &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; is a fixed number. The model is as follows.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\min \sum_{i,t,j}^{}x_{i(\mod (t-1,14)+1)j}\cdot c_j\\&#xA;&amp;amp;\sum_{i}^{}x_{i(\mod (t-1,14)+1)j}\ge d_{tj} &amp;amp;&amp;amp;\forall t\in T, j\in J\\\&#xA;&amp;amp;\sum_{j}^{}x_{i(\mod (t-1,14)+1)j}\le1 &amp;amp;&amp;amp;\forall i\in I, t\in T\\\&#xA;&amp;amp;x_{i(\mod (t-1,14)+1)3}+x_{i(\mod (t,14)+1)1}\le 1 &amp;amp;&amp;amp;\forall I \in I, t\in \{1,\ldots,T-1\}\\\&#xA;&amp;amp;\sum_{l=t}^{t+g}\sum_{j}^{}x_{i(\mod (l-1,14)+1)j}\le g &amp;amp;&amp;amp;\forall i\in I, j\in J\\&#xA;&amp;amp;x_{i(\mod (t-1,14)+1)j}+x_{i(\mod (t,14)+1)j}+s_{i(t+1)}\le 2&amp;amp;&amp;amp; \forall i\in I,k\in K,t\in\{1,\ldots,T-1\}\\&#xA;&amp;amp;x_{i(\mod (t-1,14)+1)j}+\sum_{k\neq j}^{}x_{i(\mod (t,14)+1)k}\le1+s_{i(t+1)}&amp;amp;&amp;amp; \forall i\in I,k\in K,t\in\{1,\ldots,T-1\}\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now to my question. I currently have 28 days as the planning period. However, I would now like to create cyclical plans, so that after 28 days it starts again from the beginning. How do I have to extend/modify my model, especially with regard to linking the days with &lt;span class=&quot;math-container&quot;&gt;$t+1$&lt;/span&gt; etc.? And how can I introduce a parameter that controls the number of cycles?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: I updated the model, as suggested by @RobPratt. Now, i have a a 28 planing horizon, with two cycles a 14 days. Whenever i try to solve this model, i only get solutions for 14 days, regarding &lt;span class=&quot;math-container&quot;&gt;$x_{itj}$&lt;/span&gt;. Why is that?&lt;/p&gt;&#xA;" OwnerUserId="11884" LastEditorUserId="11884" LastEditDate="2024-01-15T10:13:55.683" LastActivityDate="2024-01-15T10:13:55.683" Title="How to modify a model to be cyclic?" Tags="|linear-programming|constraint|scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11497" PostTypeId="1" CreationDate="2024-01-09T13:20:13.300" Score="1" ViewCount="44" Body="&lt;p&gt;If the original problem contains the diagonal block structure property or other specific properties then we can apply column generation or other decomposition algorithms to solve it.&lt;/p&gt;&#xA;&lt;p&gt;However, if the problem with overlapping blocks (for example, a variable appears into two more blocks) instead of diagonal block. How could we use decomposition algorithms to solve it? Is any related literature recommended?&lt;/p&gt;&#xA;" OwnerUserId="12370" LastEditorUserId="12370" LastEditDate="2024-01-09T13:40:26.603" LastActivityDate="2024-01-09T13:40:26.603" Title="How to decompose the problem with overlapping blocks?" Tags="|linear-programming|reference-request|decomposition|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11498" PostTypeId="2" ParentId="11496" CreationDate="2024-01-09T13:47:56.693" Score="3" Body="&lt;p&gt;If you want to enforce that &lt;span class=&quot;math-container&quot;&gt;$x_{i,t,j}=x_{i,t+28,j}$&lt;/span&gt;, you can explicitly impose that constraint and let the presolver do the substitution.&lt;/p&gt;&#xA;&lt;p&gt;Or omit the explicit constraints and do the substitution yourself by replacing &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\mod(t,28)$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$x_{i,t,j}$&lt;/span&gt; variable (assuming &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; starts at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;).  It looks like your &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; starts at &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, so you can instead replace &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\mod(t-1,28)+1$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$x_{i,t,j}$&lt;/span&gt; variable.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-01-09T19:13:28.710" LastActivityDate="2024-01-09T19:13:28.710" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="11499" PostTypeId="1" CreationDate="2024-01-09T15:19:41.607" Score="2" ViewCount="46" Body="&lt;p&gt;I need to solve a hard MIP model using Gurobi.&#xA;There is a tool to set the best parameters combination to solve this problem called &amp;quot;Parameter Tunning&amp;quot;.&#xA;How can I find parameter tuning using Julia?&lt;/p&gt;&#xA;" OwnerUserId="4760" LastActivityDate="2024-01-09T15:19:41.607" Title="Parameter Tuning Tool in Gurobi using Julia" Tags="|gurobi|julia|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11500" PostTypeId="1" CreationDate="2024-01-09T19:51:05.733" Score="1" ViewCount="51" Body="&lt;p&gt;I am trying to express the constraints for the 'Tents and trees' puzzle in minizinc but I am a bit stuck...&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I can express that each tent must be attached to at least one tree&lt;/li&gt;&#xA;&lt;li&gt;That a tree must be attached to at least one tent&lt;/li&gt;&#xA;&lt;li&gt;That no tent can touch another tent&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;However, I cannot express that 'each tent/tree must be attached to only one tree/tent' and get incorrect solutions generated such as 'tent-tree-tent'&lt;/p&gt;&#xA;&lt;p&gt;Any help appreciated.&lt;/p&gt;&#xA;" OwnerUserId="13066" LastActivityDate="2024-01-09T19:51:05.733" Title="Tents and trees constraints" Tags="|constraint-programming|minizinc|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11501" PostTypeId="1" AcceptedAnswerId="11503" CreationDate="2024-01-09T22:06:27.607" Score="1" ViewCount="127" Body="&lt;p&gt;As I understand it, if a modeling library (pyomo, amplpy, cvxpy, etc.) allows one to define a logarithmic objective function a solver may not support it. And even if a solver &lt;em&gt;does&lt;/em&gt; support a logarithmic objective function then the modeling library may not support translation of the log function to the solver. So, which combinations of libraries and solvers support logarithmic objective functions?&lt;/p&gt;&#xA;" OwnerUserId="13067" LastActivityDate="2024-01-18T11:58:16.410" Title="Which combinations of python modeling libraries and solvers support logarithmic objective functions?" Tags="|solver|convex-optimization|modeling-languages|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11502" PostTypeId="1" AcceptedAnswerId="11610" CreationDate="2024-01-10T04:16:54.363" Score="2" ViewCount="97" Body="&lt;p&gt;Assume you have the following simple constrained optimization problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{equation}&#xA;\begin{split}&#xA;&amp;amp;\min_x f(x) \\&#xA;&amp;amp; s.t \quad g(x) = c&#xA;\end{split}&#xA;\end{equation}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$f,g$&lt;/span&gt; are both differentiable.&lt;/p&gt;&#xA;&lt;p&gt;What are the standard way to show that the problem solution (here I am referring to the objective minimum, and not the decision variable) is/is not differentiable with respect to &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;? I have run a few concrete examples and found that numerically the solution seems to be differentiable, but I have no idea how to show it more formally.&lt;/p&gt;&#xA;" OwnerUserId="13068" LastEditorUserId="491" LastEditDate="2024-01-19T13:28:52.293" LastActivityDate="2024-01-31T22:13:14.053" Title="Differentiability of solution of optimization problem with respect to constraint (properties, conditions etc)" Tags="|optimization|constraint|constraint-programming|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11503" PostTypeId="2" ParentId="11501" CreationDate="2024-01-10T07:14:58.550" Score="3" Body="&lt;p&gt;Assuming the model is convex, then you can easily state your problem on conic form using the exponential cone. The &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/expo.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek modeling cookbook&lt;/a&gt; discusses that topic.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.mosek.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mosek&lt;/a&gt; has 2 different Python interfaces that allow you to specify conic optimization problems with exponential cones and other cone types.&lt;/p&gt;&#xA;&lt;p&gt;Mosek can also be used from cvxpy and Pyomo to solve this class of problems.&lt;/p&gt;&#xA;&lt;p&gt;AMPL support tells me that they support the exponential cone too.&lt;/p&gt;&#xA;&lt;p&gt;If are you maximizing&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\ln{\prod x_j}&#xA;$$&lt;/span&gt;&#xA;then that corresponds to maximizing the geometric mean of the nonnegative variables i.e. maximizing&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left ( \prod_{j=1}^n x_j \right )^{1/n}.&#xA;$$&lt;/span&gt;&#xA;This can be formulated using the &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/powo.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;power cone&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="134" LastEditDate="2024-01-18T11:58:16.410" LastActivityDate="2024-01-18T11:58:16.410" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11504" PostTypeId="1" CreationDate="2024-01-10T20:52:26.300" Score="0" ViewCount="89" Body="&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt;: I am working on defining Target Days of Supply for a periodic review system with a review period of 1 week.  I have weekly demand data for the complete year. I can calculate Mean weekly demand and standard deviation of the weekly demand.&lt;br /&gt;&#xA;Target Days of Supply is setup such that during each weekly review we compare these Target Days of Supply with available inventory in days. If Target Days of Supply &amp;lt; Available Days on hand inventory then more units are ordered to bring the inventory level up to Target Days of Supply. The orders are placed in such a manner that system looks in future to analyze when Target Days of Supply will go below Available days on hand and create an advance order.&lt;/p&gt;&#xA;&lt;p&gt;For Example: Suppose we are reviewing in week &amp;quot;T&amp;quot;. Lead time to produce an item is 4 weeks. Review is carried out on last day of each week. The system will look in future i.e. T+1 week, T+2....... T+n weeks to see when Target Days of Supply &amp;lt; Available days of inventory. Suppose at T+5 weeks the inventory Target Days of Supply &amp;lt; Available Days of inventory. The system will create an advance order to produce more units in T+2 weeks so that the product hits the inventory at the end of T+5 and start of T+6 weeks.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: To define Target Days of Supply, I am trying to calculate the Target Inventory Level. I know that for a periodic review system where we place an order and wait for the order to arrive after lead time, target level should be = &lt;em&gt;&amp;quot;Mean Demand per week&lt;/em&gt;(Lead Time + Review Period in weeks) + Safety Stock (during lead time + review period)&amp;quot;*.&lt;/p&gt;&#xA;&lt;p&gt;In this specific case as we are looking in future and placing production order in advance considering the lead time, will the target level of units calculation change to = &lt;em&gt;&amp;quot;Mean Demand per week&lt;/em&gt;(review period) + Safety Stock (during lead time + review period)&amp;quot;?*&lt;/p&gt;&#xA;&lt;p&gt;Or the formula will remain unchanged as = &lt;em&gt;&amp;quot;Mean Demand per week&lt;/em&gt;(Lead Time + Review Period in weeks) + Safety Stock (during lead time + review period)&amp;quot;*.&lt;/p&gt;&#xA;" OwnerUserId="13071" LastActivityDate="2024-02-11T17:06:50.793" Title="Periodic Review System of Inventory to setup Target Days of Supply" Tags="|inventory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11505" PostTypeId="1" AcceptedAnswerId="11512" CreationDate="2024-01-11T08:55:37.897" Score="2" ViewCount="140" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\DeclareMathOperator{\Tr}{Tr}\DeclareMathOperator*{\argmax}{\arg\!\max}$&lt;/span&gt;Consider the following problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\min_x \quad &amp;amp; \Tr(WF(x)) \\&#xA;\textrm{s.t.} \quad &amp;amp; 0 &amp;lt; x \leq 1&#xA;\end{aligned} \tag{1}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\Tr(\cdot)$&lt;/span&gt; is the trace operator, &lt;span class=&quot;math-container&quot;&gt;$W$&lt;/span&gt; is positive semi-definite and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;F(x) = \argmax_V \quad &amp;amp; \Tr(V) \\&#xA;\textrm{s.t.} \quad &amp;amp; \begin{bmatrix} AVA^T + Q - V &amp;amp; \sqrt{x}(AVA^T + Q)C^T \\ \sqrt{x} C(AVA^T + Q) &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix} \succeq 0 \\&#xA;\quad &amp;amp; V \succeq 0&#xA;\end{aligned} \tag{2}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A \in \mathbb R^{n \times n}, C \in \mathbb R^{m \times n},Q \succeq 0,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R \succ 0$&lt;/span&gt;. Suppose that there exists a &lt;span class=&quot;math-container&quot;&gt;$V \succeq 0$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$AVA^T + Q - V \succeq 0$&lt;/span&gt;. Note that the positive semi-definiteness constraint in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; is equivalent to (via the Schur complement lemma) the following &amp;quot;modified&amp;quot; algebraic Riccati inequality:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;AVA^T + Q - V - x(AVA^T + Q)C^T(C(AVA^T + Q)C^T + R)^{-1}C(AVA^T + Q) \succeq 0&#xA;$$&lt;/span&gt;&#xA;&lt;strong&gt;Question&lt;/strong&gt;: Assuming that &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; has a unique solution for every value of &lt;span class=&quot;math-container&quot;&gt;$x \in (0,1]$&lt;/span&gt; (such that &lt;span class=&quot;math-container&quot;&gt;$F$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; is well-defined on &lt;span class=&quot;math-container&quot;&gt;$(0,1]$&lt;/span&gt;), is it possible to show that the problem in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; is convex? I'm trying to prove this by showing that &lt;span class=&quot;math-container&quot;&gt;$F(x)$&lt;/span&gt; is convex in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. However, given that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; appears in the constraint in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, I'm not sure how to go about this.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2024-01-14T18:26:18.150" LastActivityDate="2024-01-14T18:28:09.593" Title="Is it possible to show that this problem is convex?" Tags="|convex-optimization|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11506" PostTypeId="1" CreationDate="2024-01-11T21:59:46.107" Score="5" ViewCount="617" Body="&lt;p&gt;The python script depicted below generates the following toy data set.&lt;/p&gt;&#xA;&lt;p&gt;I need to determine the values for &lt;span class=&quot;math-container&quot;&gt;$x_{min}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$x_{max}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_{min}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_{max}$&lt;/span&gt; describing a rectangular area where the sum over all &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;s in that area is maximized. In other words: which area is the best compromise between negative values of &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; and positive &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; values.&lt;/p&gt;&#xA;&lt;p&gt;What would be the best approach to achieve this?&lt;/p&gt;&#xA;&lt;p&gt;Would it make sense to start with the whole area and then make the rectangular box smaller with each iteration?&#xA;E.g. take away a fraction of the area on the left side, then on the top, the right, and the bottom.&#xA;Whenever the sum over all &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;s is increased, that step was successful. Once a step does not increase the sum over all &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;s for that box, this step should not be executed but omitted (&lt;em&gt;variant a&lt;/em&gt;). Or the fraction with which the area was reduced should be set smaller (&lt;em&gt;variant b&lt;/em&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Would such an approach make sense?&lt;/p&gt;&#xA;&lt;p&gt;If somebody has an alternative idea: I am glad for any input.&lt;/p&gt;&#xA;&lt;p&gt;If somebody is even able to supply any coding hints/solutions, such input is very welcome, too.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ltIGG.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ltIGG.jpg&quot; alt=&quot;scatter plot of data&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;import pandas as pd&#xA;import plotly.express as px&#xA;&#xA;np.random.seed(1)&#xA;&#xA;# configuration for first array&#xA;mean0 = np.array([0., 0.])&#xA;cov0 = np.array([[1., 0.], [0., 1.]])&#xA;size0 = 10000&#xA;# configuration for second array&#xA;mean1 = np.array([1., 1.])&#xA;cov1 = np.array([[.5, 0.], [0., .5]])&#xA;size1 = 100&#xA;&#xA;# build first array&#xA;vals0 = np.random.multivariate_normal(mean0, cov0, size0)&#xA;# append another column to the right of the array&#xA;vals0 = np.append(vals0, [[-1] for x in range(size0)], axis=1)&#xA;# fill new column with randomized data (negative values)&#xA;vals0[:, 2] = -1.0 + 0.2 * np.random.random(size0)&#xA;&#xA;# build second array&#xA;vals1 = np.random.multivariate_normal(mean1, cov1, size1)&#xA;# append another column to the right of the array&#xA;vals1 = np.append(vals1, [[-1] for x in range(size1)], axis=1)&#xA;# fill new column with randomized data (positive values)&#xA;vals1[:, 2] = 100.0 - 0.2 * np.random.random(size1)&#xA;&#xA;# combine first and second array&#xA;vals2 = np.append(vals0, vals1, axis=0)&#xA;# convert numpy array to pandas DataFrame&#xA;df = pd.DataFrame(vals2, columns=['x', 'y', 'z'])&#xA;&#xA;# use plotly to visualize the data&#xA;fig = px.scatter_matrix(df.sort_values('z'),&#xA;                        dimensions=[&amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;],&#xA;                        color=&amp;quot;z&amp;quot;)&#xA;# do not show diagonal data&#xA;fig.update_traces(diagonal_visible=False)&#xA;fig.show()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13075" LastActivityDate="2024-01-14T06:52:23.513" Title="Algorithm needed to find optimum area of 2-dimensional data set" Tags="|optimization|python|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11507" PostTypeId="2" ParentId="11506" CreationDate="2024-01-11T22:31:59.510" Score="3" Body="&lt;p&gt;Let's say that &lt;span class=&quot;math-container&quot;&gt;$\hat{x}_1 \lt \cdots \lt \hat{x}_M$&lt;/span&gt; are the distinct values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in the data, sorted into ascending order, and similarly &lt;span class=&quot;math-container&quot;&gt;$\hat{y}_1 &amp;lt; \cdots \lt \hat{y}_N$&lt;/span&gt; are the sorted distinct values of &lt;span class=&quot;math-container&quot;&gt;$y.$&lt;/span&gt; Without loss of generality we can focus on boxes where each of the four edges contains at least one point. For your &amp;quot;shrink the box&amp;quot; approach, if you are bringing the left side in and the left side contains one or more points with &lt;span class=&quot;math-container&quot;&gt;$x=\hat{x}_i,$&lt;/span&gt; then you can increase the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; value of the left side to &lt;span class=&quot;math-container&quot;&gt;$\hat{x}_{i + 1},$&lt;/span&gt; and similarly for moving the other three edges inward.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-11T22:31:59.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11508" PostTypeId="1" CreationDate="2024-01-12T02:02:15.790" Score="1" ViewCount="36" Body="&lt;p&gt;Given a graph with a set of nodes and edges, the goal of the maximum independent set problem is to find the maximum number of vertices where no two vertices are adjacent. This is well-known NP-hard problem. It's weighted version is obviously NP-hard too, where each vertex is associated with a weight and the goal is to find the independent set with the maximum weight.&lt;/p&gt;&#xA;&lt;p&gt;I am wondering if there is any published result determining the computational complexity of the weighted version with a cardinality constraint. That is, finding the independent set of size at most &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; with the maximum weight.&lt;/p&gt;&#xA;" OwnerUserId="660" LastEditorUserId="660" LastEditDate="2024-01-13T00:13:58.267" LastActivityDate="2024-01-13T00:13:58.267" Title="Complexity of cardinality constrained maximum weight independent set problem" Tags="|graphs|computational-complexity|set-covering|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11509" PostTypeId="2" ParentId="11506" CreationDate="2024-01-12T03:03:41.747" Score="7" Body="&lt;p&gt;Expressed via &lt;a href=&quot;https://en.wikipedia.org/wiki/Iverson_bracket&quot; rel=&quot;noreferrer&quot;&gt;Iverson bracket&lt;/a&gt; notation, your problem is to maximize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i z_i [x_\min \le x_i \le x_\max][y_\min \le y_i \le y_\max].$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can linearize the problem as follows.  Introduce five binary decision variables for each point:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$s_i$&lt;/span&gt; indicates whether point &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is selected&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\ell_i$&lt;/span&gt; indicates whether point &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; lies to the left of &lt;span class=&quot;math-container&quot;&gt;$x_\min$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$r_i$&lt;/span&gt; indicates whether point &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; lies to the right of &lt;span class=&quot;math-container&quot;&gt;$x_\max$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; indicates whether point &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; lies below &lt;span class=&quot;math-container&quot;&gt;$y_\min$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; indicates whether point &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; lies above &lt;span class=&quot;math-container&quot;&gt;$y_\max$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_i z_i s_i$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;s_i + \ell_i &amp;amp;+ r_i + b_i + a_i \ge 1 \\&#xA;s_i = 1 &amp;amp;\implies x_\min \le x_i \\&#xA;s_i = 1 &amp;amp;\implies x_i \le x_\max \\&#xA;s_i = 1 &amp;amp;\implies y_\min \le y_i \\&#xA;s_i = 1 &amp;amp;\implies y_i \le y_\max \\&#xA;\ell_i = 1 &amp;amp;\implies x_\min \ge x_i \\&#xA;r_i = 1 &amp;amp;\implies x_i \ge x_\max \\&#xA;b_i = 1 &amp;amp;\implies y_\min \ge y_i \\&#xA;a_i = 1 &amp;amp;\implies y_i \ge y_\max&#xA;\end{align}&lt;/span&gt;&#xA;(These last four are really &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;$&lt;/span&gt;, which you can approximate with &lt;span class=&quot;math-container&quot;&gt;$\ge \epsilon +$&lt;/span&gt; for some small positive constant tolerance &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; or make exact by using the &amp;quot;neighboring&amp;quot; &lt;span class=&quot;math-container&quot;&gt;$x_j$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$y_j$&lt;/span&gt; value.)&lt;/p&gt;&#xA;&lt;p&gt;If your solver does not support indicator constraints, you can linearize via big-M.  For example, &lt;span class=&quot;math-container&quot;&gt;$x_\min - x_i \le M_i (1-s_i)$&lt;/span&gt; enforces &lt;span class=&quot;math-container&quot;&gt;$s_i = 1 \implies x_\min \le x_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An optimal solution turns out to be&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_\min = -0.12689, x_\max = 2.4819, y_\min = -0.29736, y_\max = 2.6423,$$&lt;/span&gt;&#xA;with optimal objective value &lt;span class=&quot;math-container&quot;&gt;$6332.619425$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oVydY.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oVydY.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-01-12T03:37:55.373" LastActivityDate="2024-01-12T03:37:55.373" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11510" PostTypeId="1" CreationDate="2024-01-12T13:16:45.670" Score="1" ViewCount="76" Body="&lt;p&gt;I have an alternative problem which I reckon can be solved using OR-tools. For this problem, apart from the distance between nodes within a solution, I also need the distance between the n-th node of each solution.&lt;/p&gt;&#xA;&lt;p&gt;For instance, my sample below yields:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;v1: 2 -&amp;gt;  1 -&amp;gt; 2&lt;/li&gt;&#xA;&lt;li&gt;v2: 4 -&amp;gt;  12 -&amp;gt;  11 -&amp;gt;  15 -&amp;gt;  3 -&amp;gt; 4&lt;/li&gt;&#xA;&lt;li&gt;v3: 6 -&amp;gt;  16  -&amp;gt;  10 -&amp;gt;  9 -&amp;gt;  5 -&amp;gt; 6&lt;/li&gt;&#xA;&lt;li&gt;v4: 8 -&amp;gt;  0 -&amp;gt;  7 -&amp;gt;  13 -&amp;gt;  14 -&amp;gt; 8&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Then, i would need the distance between all v[n] for each n, and 0 if nothing is planned on that index for one of the vehicles.&#xA;For the first n, this would be&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;distance from 2-4 i.e. distance from v1[n] to v2[n]&lt;/li&gt;&#xA;&lt;li&gt;distance from 2-6&lt;/li&gt;&#xA;&lt;li&gt;distance from 2-8&lt;/li&gt;&#xA;&lt;li&gt;distance from 4-6&lt;/li&gt;&#xA;&lt;li&gt;distance from 4-8&lt;/li&gt;&#xA;&lt;li&gt;distance from 6-8&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;These would be added to the total distance travelled within a solution. The overall objective is to minimze the total distance.&lt;/p&gt;&#xA;&lt;p&gt;Is something like that feasible and possible? Below is the standard OR-tools sample adjusted for start &amp;amp; end points per vehicle&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from ortools.constraint_solver import routing_enums_pb2&#xA;from ortools.constraint_solver import pywrapcp&#xA;&#xA;&#xA;def create_data_model():&#xA;    &amp;quot;&amp;quot;&amp;quot;Stores the data for the problem.&amp;quot;&amp;quot;&amp;quot;&#xA;    data = {}&#xA;    data[&amp;quot;distance_matrix&amp;quot;] = [&#xA;        # fmt: off&#xA;      [0, 548, 776, 696, 582, 274, 502, 194, 308, 194, 536, 502, 388, 354, 468, 776, 662],&#xA;      [548, 0, 684, 308, 194, 502, 730, 354, 696, 742, 1084, 594, 480, 674, 1016, 868, 1210],&#xA;      [776, 684, 0, 992, 878, 502, 274, 810, 468, 742, 400, 1278, 1164, 1130, 788, 1552, 754],&#xA;      [696, 308, 992, 0, 114, 650, 878, 502, 844, 890, 1232, 514, 628, 822, 1164, 560, 1358],&#xA;      [582, 194, 878, 114, 0, 536, 764, 388, 730, 776, 1118, 400, 514, 708, 1050, 674, 1244],&#xA;      [274, 502, 502, 650, 536, 0, 228, 308, 194, 240, 582, 776, 662, 628, 514, 1050, 708],&#xA;      [502, 730, 274, 878, 764, 228, 0, 536, 194, 468, 354, 1004, 890, 856, 514, 1278, 480],&#xA;      [194, 354, 810, 502, 388, 308, 536, 0, 342, 388, 730, 468, 354, 320, 662, 742, 856],&#xA;      [308, 696, 468, 844, 730, 194, 194, 342, 0, 274, 388, 810, 696, 662, 320, 1084, 514],&#xA;      [194, 742, 742, 890, 776, 240, 468, 388, 274, 0, 342, 536, 422, 388, 274, 810, 468],&#xA;      [536, 1084, 400, 1232, 1118, 582, 354, 730, 388, 342, 0, 878, 764, 730, 388, 1152, 354],&#xA;      [502, 594, 1278, 514, 400, 776, 1004, 468, 810, 536, 878, 0, 114, 308, 650, 274, 844],&#xA;      [388, 480, 1164, 628, 514, 662, 890, 354, 696, 422, 764, 114, 0, 194, 536, 388, 730],&#xA;      [354, 674, 1130, 822, 708, 628, 856, 320, 662, 388, 730, 308, 194, 0, 342, 422, 536],&#xA;      [468, 1016, 788, 1164, 1050, 514, 514, 662, 320, 274, 388, 650, 536, 342, 0, 764, 194],&#xA;      [776, 868, 1552, 560, 674, 1050, 1278, 742, 1084, 810, 1152, 274, 388, 422, 764, 0, 798],&#xA;      [662, 1210, 754, 1358, 1244, 708, 480, 856, 514, 468, 354, 844, 730, 536, 194, 798, 0],&#xA;        # fmt: on&#xA;    ]&#xA;    data[&amp;quot;num_vehicles&amp;quot;] = 4&#xA;    &#xA;    # custom start and end index, always return back&#xA;    data[&amp;quot;starts&amp;quot;] = [2,4,6,8]&#xA;    data[&amp;quot;ends&amp;quot;] = [2,4,6,8]&#xA;    return data&#xA;&#xA;&#xA;def print_solution(data, manager, routing, solution):&#xA;    &amp;quot;&amp;quot;&amp;quot;Prints solution on console.&amp;quot;&amp;quot;&amp;quot;&#xA;    print(f&amp;quot;Objective: {solution.ObjectiveValue()}&amp;quot;)&#xA;    max_route_distance = 0&#xA;    for vehicle_id in range(data[&amp;quot;num_vehicles&amp;quot;]):&#xA;        index = routing.Start(vehicle_id)&#xA;        plan_output = f&amp;quot;Route for vehicle {vehicle_id}:\n&amp;quot;&#xA;        route_distance = 0&#xA;        while not routing.IsEnd(index):&#xA;            plan_output += f&amp;quot; {manager.IndexToNode(index)} -&amp;gt; &amp;quot;&#xA;            previous_index = index&#xA;            index = solution.Value(routing.NextVar(index))&#xA;            route_distance += routing.GetArcCostForVehicle(&#xA;                previous_index, index, vehicle_id&#xA;            )&#xA;        plan_output += f&amp;quot;{manager.IndexToNode(index)}\n&amp;quot;&#xA;        plan_output += f&amp;quot;Distance of the route: {route_distance}m\n&amp;quot;&#xA;        print(plan_output)&#xA;        max_route_distance = max(route_distance, max_route_distance)&#xA;    print(f&amp;quot;Maximum of the route distances: {max_route_distance}m&amp;quot;)&#xA;&#xA;&#xA;&#xA;def main():&#xA;    &amp;quot;&amp;quot;&amp;quot;Entry point of the program.&amp;quot;&amp;quot;&amp;quot;&#xA;    # Instantiate the data problem.&#xA;    data = create_data_model()&#xA;&#xA;    # Create the routing index manager.&#xA;    manager = pywrapcp.RoutingIndexManager(&#xA;        len(data[&amp;quot;distance_matrix&amp;quot;]), data[&amp;quot;num_vehicles&amp;quot;], data[&amp;quot;starts&amp;quot;], data['ends']&#xA;    )&#xA;&#xA;    # Create Routing Model.&#xA;    routing = pywrapcp.RoutingModel(manager)&#xA;&#xA;    # Create and register a transit callback.&#xA;    def distance_callback(from_index, to_index):&#xA;        &amp;quot;&amp;quot;&amp;quot;Returns the distance between the two nodes.&amp;quot;&amp;quot;&amp;quot;&#xA;        # Convert from routing variable Index to distance matrix NodeIndex.&#xA;        from_node = manager.IndexToNode(from_index)&#xA;        to_node = manager.IndexToNode(to_index)&#xA;        return data[&amp;quot;distance_matrix&amp;quot;][from_node][to_node]&#xA;&#xA;    transit_callback_index = routing.RegisterTransitCallback(distance_callback)&#xA;&#xA;    # Define cost of each arc.&#xA;    routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)&#xA;&#xA;    # Add Distance constraint.&#xA;    dimension_name = &amp;quot;Distance&amp;quot;&#xA;    routing.AddDimension(&#xA;        transit_callback_index,&#xA;        0,  # no slack&#xA;        3000,  # vehicle maximum travel distance&#xA;        True,  # start cumul to zero&#xA;        dimension_name,&#xA;    )&#xA;    distance_dimension = routing.GetDimensionOrDie(dimension_name)&#xA;    distance_dimension.SetGlobalSpanCostCoefficient(100)&#xA;&#xA;    # Setting first solution heuristic.&#xA;    search_parameters = pywrapcp.DefaultRoutingSearchParameters()&#xA;    search_parameters.first_solution_strategy = (&#xA;        routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC&#xA;    )&#xA;&#xA;    # Solve the problem.&#xA;    solution = routing.SolveWithParameters(search_parameters)&#xA;&#xA;    # Print solution on console.&#xA;    if solution:&#xA;        print_solution(data, manager, routing, solution)&#xA;    else:&#xA;        print(&amp;quot;No solution found !&amp;quot;)&#xA;&#xA;&#xA;if __name__ == &amp;quot;__&#xA;&#xA;main__&amp;quot;:&#xA;    main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13029" LastEditorUserId="500" LastEditDate="2024-01-12T13:36:07.527" LastActivityDate="2024-01-12T13:36:07.527" Title="Vehicle Routing Problem OR-tools - Distance between solutions / vehicles" Tags="|or-tools|vehicle-routing|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11511" PostTypeId="2" ParentId="11504" CreationDate="2024-01-12T16:30:16.087" Score="0" Body="&lt;p&gt;The target level of inventory should be based on how many weeks of inventory you want on hand. Whether it is called lead time or review period, the safety stock plus mean demand should both be calculated based on the number of weeks you want on hand.&lt;/p&gt;&#xA;&lt;p&gt;If you want (lead time + review period) number of weeks of inventory on hand, then you should leave the calculation unchanged. If you want a different quantity on hand, then you might want a different change than the one you proposed.&lt;/p&gt;&#xA;" OwnerUserId="61" LastActivityDate="2024-01-12T16:30:16.087" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="11512" PostTypeId="2" ParentId="11505" CreationDate="2024-01-12T16:39:35.573" Score="0" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\DeclareMathOperator{\Tr}{Tr}\DeclareMathOperator*{\argmax}{\arg\!\max}$&lt;/span&gt;It seems that &lt;span class=&quot;math-container&quot;&gt;$x = 1$&lt;/span&gt; should solve &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;. My reasoning for this is as follows.&lt;/p&gt;&#xA;&lt;p&gt;Because &lt;span class=&quot;math-container&quot;&gt;$x \neq 0$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{x}$&lt;/span&gt; always exists, and so the constraint&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{bmatrix} AVA^T + Q - V &amp;amp; \sqrt{x}(AVA^T + Q)C^T \\ \sqrt{x} C(AVA^T + Q) &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix} \succeq 0&#xA;$$&lt;/span&gt;&#xA;in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; can be transformed as follows&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;&amp;amp;\begin{bmatrix} AVA^T + Q - V &amp;amp; \sqrt{x}(AVA^T + Q)C^T \\ \sqrt{x} C(AVA^T + Q) &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix} \succeq 0 \\&#xA;&amp;amp;\iff AVA^T + Q - V - x(AVA^T + Q)C^T(C(AVA^T + Q)C^T + R)^{-1}C(AVA^T + Q) \succeq 0 \\&#xA;&amp;amp;\iff AVA^T + Q - V - (AVA^T + Q)C^T\left(\frac{1}{x}[C(AVA^T + Q)C^T + R]\right)^{-1}C(AVA^T + Q) \succeq 0 \\&#xA;&amp;amp;\iff \begin{bmatrix} AVA^T + Q - V &amp;amp; (AVA^T + Q)C^T \\ C(AVA^T + Q) &amp;amp; \frac{1}{x}[C(AVA^T + Q)C^T + R] \end{bmatrix} \succeq 0 \\&#xA;&amp;amp;\iff \begin{bmatrix} AVA^T + Q - V &amp;amp; (AVA^T + Q)C^T \\ C(AVA^T + Q) &amp;amp; 0 \end{bmatrix} + \frac{1}{x}\begin{bmatrix} 0 &amp;amp; 0 \\ 0 &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix} \succeq 0 \\&#xA;&amp;amp;\iff \begin{bmatrix} AVA^T + Q - V &amp;amp; (AVA^T + Q)C^T \\ C(AVA^T + Q) &amp;amp; 0 \end{bmatrix} \succeq -\frac{1}{x}\begin{bmatrix} 0 &amp;amp; 0 \\ 0 &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Because &lt;span class=&quot;math-container&quot;&gt;$\frac{1}{x} \in [1,\infty)$&lt;/span&gt; and the matrix&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{bmatrix} 0 &amp;amp; 0 \\ 0 &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix}&#xA;$$&lt;/span&gt;&#xA;is positive semi-definite (since &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; is positive definite and &lt;span class=&quot;math-container&quot;&gt;$AVA^T + Q$&lt;/span&gt; is positive semi-definite), then the matrix&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;-\frac{1}{x}\begin{bmatrix} 0 &amp;amp; 0 \\ 0 &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix}&#xA;$$&lt;/span&gt;&#xA;is negative semi-definite for every &lt;span class=&quot;math-container&quot;&gt;$x \in (0,1]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, as &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; decreases from &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; towards &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, the feasible set in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; gets larger in the following sense. Fix any &lt;span class=&quot;math-container&quot;&gt;$x_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$(0,1]$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;lt; x_2$&lt;/span&gt;. Then,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;-\frac{1}{x_1}\begin{bmatrix} 0 &amp;amp; 0 \\ 0 &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix} \prec -\frac{1}{x_2}\begin{bmatrix} 0 &amp;amp; 0 \\ 0 &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix}&#xA;$$&lt;/span&gt;&#xA;and so&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;&amp;amp;\begin{bmatrix} AVA^T + Q - V &amp;amp; (AVA^T + Q)C^T \\ C(AVA^T + Q) &amp;amp; 0 \end{bmatrix} \succeq -\frac{1}{x_2}\begin{bmatrix} 0 &amp;amp; 0 \\ 0 &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix} \\&#xA;&amp;amp;\implies \begin{bmatrix} AVA^T + Q - V &amp;amp; (AVA^T + Q)C^T \\ C(AVA^T + Q) &amp;amp; 0 \end{bmatrix} \succeq -\frac{1}{x_1}\begin{bmatrix} 0 &amp;amp; 0 \\ 0 &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Therefore, the set&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathcal G(x_2) = \left\{V \succeq 0 \ \Bigg| \begin{bmatrix} AVA^T + Q - V &amp;amp; (AVA^T + Q)C^T \\ C(AVA^T + Q) &amp;amp; 0 \end{bmatrix} \succeq -\frac{1}{x_2}\begin{bmatrix} 0 &amp;amp; 0 \\ 0 &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix}\right\}&#xA;$$&lt;/span&gt;&#xA;is a subset of&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\mathcal G(x_1) = \left\{V \succeq 0 \ \Bigg| \begin{bmatrix} AVA^T + Q - V &amp;amp; (AVA^T + Q)C^T \\ C(AVA^T + Q) &amp;amp; 0 \end{bmatrix} \succeq -\frac{1}{x_1}\begin{bmatrix} 0 &amp;amp; 0 \\ 0 &amp;amp; C(AVA^T + Q)C^T + R \end{bmatrix}\right\}&#xA;$$&lt;/span&gt;&#xA;for every &lt;span class=&quot;math-container&quot;&gt;$x_1 &amp;lt; x_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_1,x_2 \in (0,1]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, because the objective function in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$\Tr(V)$&lt;/span&gt;, a linear and monotonically increasing function of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$\argmax_V \Tr(V)$&lt;/span&gt; should either increase or stay the same as the size of the feasible set increases, which occurs when &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; decreases.&lt;/p&gt;&#xA;&lt;p&gt;The rate of increase of the size of the feasible set, however, cannot be constant, as the map &lt;span class=&quot;math-container&quot;&gt;$x \mapsto -\frac{1}{x}$&lt;/span&gt; has a nonlinearly decreasing rate of increase. Therefore, &lt;span class=&quot;math-container&quot;&gt;$F(x)$&lt;/span&gt; cannot be a linear function of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To conclude, although some additional precision can be added to the preceding argument, one would expect &lt;span class=&quot;math-container&quot;&gt;$F(x)$&lt;/span&gt; to be a monotonically decreasing function of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$x = 1$&lt;/span&gt; solves the problem in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2024-01-14T18:28:09.593" LastActivityDate="2024-01-14T18:28:09.593" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11513" PostTypeId="1" CreationDate="2024-01-13T12:23:37.873" Score="2" ViewCount="70" Body="&lt;p&gt;I am working on a problem involving finding the shortest path in a Directed Acyclic Graph (DAG), where each edge's cost depends on multiple transportation modes, each with its own setup cost. I am looking for an algorithmic approach to solve this problem and would appreciate any guidance or suggestions.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem Description:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Consider a DAG with vertices &lt;span class=&quot;math-container&quot;&gt;$ V $&lt;/span&gt; and directed edges &lt;span class=&quot;math-container&quot;&gt;$ E $&lt;/span&gt;. Each edge &lt;span class=&quot;math-container&quot;&gt;$ e \in E $&lt;/span&gt; has a cost that depends on the transportation mode used. There are &lt;span class=&quot;math-container&quot;&gt;$ n $&lt;/span&gt; different transportation modes available. The cost of using mode &lt;span class=&quot;math-container&quot;&gt;$ i $&lt;/span&gt; on edge &lt;span class=&quot;math-container&quot;&gt;$ e $&lt;/span&gt; is denoted as &lt;span class=&quot;math-container&quot;&gt;$ cost(e, i) $&lt;/span&gt;. Each transportation mode &lt;span class=&quot;math-container&quot;&gt;$ i $&lt;/span&gt; has an associated setup cost &lt;span class=&quot;math-container&quot;&gt;$ setup\_cost(i) $&lt;/span&gt;, which is incurred if the mode is used at least once in the path.&lt;/p&gt;&#xA;&lt;p&gt;The objective is to find the shortest path from a designated start vertex &lt;span class=&quot;math-container&quot;&gt;$ s $&lt;/span&gt; to an end vertex &lt;span class=&quot;math-container&quot;&gt;$ t $&lt;/span&gt;, considering the costs of edges based on the transportation modes and the setup costs of these modes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Mathematical Model:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$ x_i $&lt;/span&gt; be a binary variable that represents whether transportation mode &lt;span class=&quot;math-container&quot;&gt;$ i $&lt;/span&gt; is used &lt;span class=&quot;math-container&quot;&gt;$ x_i = 1 $&lt;/span&gt; or not &lt;span class=&quot;math-container&quot;&gt;$x_i = 0 $&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Let &lt;span class=&quot;math-container&quot;&gt;$ y_{e,i} $&lt;/span&gt; be a binary variable that represents whether edge &lt;span class=&quot;math-container&quot;&gt;$ e $&lt;/span&gt; is traversed using mode &lt;span class=&quot;math-container&quot;&gt;$ i $&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Minimize the total cost, which includes the cost of traversing edges and the setup costs of the transportation modes:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\text{Minimize} \sum_{e \in E, i=1}^{n} cost(e, i) \cdot y_{e,i} + \sum_{i=1}^{n} setup\_cost(i) \cdot x_i&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Each edge can be traversed using at most one transportation mode:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;   \sum_{i=1}^{n} y_{e,i} \leq 1 \quad \forall e \in E&#xA;   $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A transportation mode incurs a setup cost only if it is used:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;   y_{e,i} \leq x_i \quad \forall e \in E, \forall i=1,2,...,n&#xA;  $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Path constraints to ensure a valid path from &lt;span class=&quot;math-container&quot;&gt;$ s $&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$ t $&lt;/span&gt; in the DAG.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there an existing algorithm or a known method that can efficiently solve this type of problem, especially considering the setup costs of different modes and the dependency of edge costs on these modes? Any pointers to algorithmic strategies or relevant literature would be highly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="13080" LastActivityDate="2024-02-12T19:01:25.227" Title="Algorithm for Shortest Path in a DAG with Multiple Transportation Modes and Associated Setup Costs" Tags="|mixed-integer-programming|graphs|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11514" PostTypeId="2" ParentId="11513" CreationDate="2024-01-13T12:24:43.930" Score="0" Body="&lt;p&gt;This problem appears to be an NP problem, and here's a proof for it. Considering the presence of fixed setup costs in the problem, it brings to mind the uncapacitated facility location problem. Notably, when the shortest path in the problem is determined, but the modes for each arc in the path are still unknown, this scenario can be regarded as an uncapacitated facility location problem. This similarity allows us to perform a reduction from the facility location problem to the problem at hand.&lt;/p&gt;&#xA;" OwnerUserId="13080" LastActivityDate="2024-01-13T12:24:43.930" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11515" PostTypeId="2" ParentId="11513" CreationDate="2024-01-13T16:15:43.350" Score="0" Body="&lt;p&gt;This can be solved using a labeling algorithm. The procedure is very well explained &lt;a href=&quot;https://link.springer.com/chapter/10.1007/0-387-25486-2_2&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://nabinkafle.medium.com/shortest-path-problem-with-resources-constraint-spprc-971ce9b9643e&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. I will let you read those sources for a better description of labeling algorithms than what I am able to provide here.&lt;/p&gt;&#xA;&lt;p&gt;In the following I will show how this specific problem can be solved using a labeling algorithm, and assume knowledge of labeling algorithms in general.&lt;/p&gt;&#xA;&lt;p&gt;Consider a label &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; = (*, i, c, S)$, where:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$∗$&lt;/span&gt; represents a pointer to the previous label,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the current node,&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is the accumulated cost, and&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; is a set containing the modes used.&#xA;The initial label is characterized by the values &lt;span class=&quot;math-container&quot;&gt;$(null, s, 0, \emptyset)$&lt;/span&gt;. Here &lt;span class=&quot;math-container&quot;&gt;$null$&lt;/span&gt; signifies the absence of a previous label, &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; denotes the current node, &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; is the accumulated cost, and &lt;span class=&quot;math-container&quot;&gt;$\emptyset$&lt;/span&gt; is the empty set of modes used.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The resource extension functions when extending a label &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; along arc &lt;span class=&quot;math-container&quot;&gt;$(i, j)$&lt;/span&gt;, using mode &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, producing label &lt;span class=&quot;math-container&quot;&gt;$L^*$&lt;/span&gt;, are as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;c(L^*) &amp;amp;= c(L) + cost(i,j,k) + \begin{cases} &#xA;setup\_cost(k) \text{ if } k \notin s(L) \\&#xA;0 \text{ otherwise}&#xA;\end{cases} \\&#xA;S(L^*) &amp;amp;= S(L)\cup \{k\} &#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Label &lt;span class=&quot;math-container&quot;&gt;$L_1$&lt;/span&gt; dominates label &lt;span class=&quot;math-container&quot;&gt;$L_2$&lt;/span&gt; iff:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    i(L_1) &amp;amp;= i(L_2) \\&#xA;    c(L_1) &amp;amp;\leq c(L_2) - \sum_{k\in S(L_2)\backslash S(L_1)} setup\_cost(k)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="9151" LastEditorUserId="9151" LastEditDate="2024-01-13T18:33:35.917" LastActivityDate="2024-01-13T18:33:35.917" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11516" PostTypeId="2" ParentId="11506" CreationDate="2024-01-14T06:52:23.513" Score="1" Body="&lt;p&gt;If you care about performance, I think it makes more sense to implement this in custom code rather than try to solve it with a solver.  There is a straightforward algorithm.  Let &lt;span class=&quot;math-container&quot;&gt;$x_1&amp;lt;\dots&amp;lt;x_m$&lt;/span&gt; denote the distinct values of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; in the data, and &lt;span class=&quot;math-container&quot;&gt;$y_1&amp;lt;\dots&amp;lt;y_n$&lt;/span&gt; the distinct values of &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; in the data.  Then we can use the following algorithm:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$i:=1,2,\dots,m-1$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$i':=i+1,\dots,m$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$j:=1,2,\dots,n$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$j':=j+1,\dots,n$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Compute the total &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;-value of all points in the box &lt;span class=&quot;math-container&quot;&gt;$[x_i,x_{i'}] \times [y_j,y_{j'}]$&lt;/span&gt;.  Remember the best seen so far.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The running time of this naive algorithm will be &lt;span class=&quot;math-container&quot;&gt;$O(m^2n^2N)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; counts the number of data points.&lt;/p&gt;&#xA;&lt;p&gt;You can speed up the algorithm by using standard data structures for storing data in the plane, such as a 2-dimensional k-d tree or a quadtree.  Augment each node in the tree with the sum of all &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;-values of points that fall within the rectangular region corresponding to that node.  Then, you can compute the total &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;-value of all points in the box &lt;span class=&quot;math-container&quot;&gt;$[x_i,x_{i'}] \times [y_j,y_{j'}]$&lt;/span&gt; by expressing it as the sum of some disjoint rectangles, each rectangle corresponding to a node in the tree.  Heuristically, we can expect each box to be decomposed into something like &lt;span class=&quot;math-container&quot;&gt;$O(\log N)$&lt;/span&gt; different rectangles.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, with this improved data structure, I expect the running time will be improved to something like &lt;span class=&quot;math-container&quot;&gt;$O(m^2n^2\log N)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am not aware of any algorithm that is guaranteed to give the correct answer and is faster than these algorithms (including the ones listed in other answers; solvers don't have any magic sauce that will speed this up).&lt;/p&gt;&#xA;" OwnerUserId="2415" LastActivityDate="2024-01-14T06:52:23.513" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11517" PostTypeId="1" CreationDate="2024-01-14T20:52:11.913" Score="1" ViewCount="59" Body="&lt;p&gt;H.P. Williams states in his book &amp;quot;Model Building in Mathematical Programming:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;An SOS1 is a set of variables (continuous or integer) within which exactly&#xA;one variable &lt;strong&gt;must&lt;/strong&gt; be non-zero.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;So, if I have two binary variables a, b which also form a SOS1 then the SOS1 property together with the constraint a + b = 1 impose integrality on a, b and therefore I don't need to require explicitely the integrality of a,b.&lt;/p&gt;&#xA;&lt;p&gt;CPLEX defines a SOS1 as:&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;SOS Type 1 is a set of variables where at most one variable &lt;strong&gt;may be&lt;/strong&gt; nonzero.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to avoid explicitely requiring the integrality of a,b as in the case of Williams?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2024-01-14T23:01:49.320" Title="Modelling set of binaries as SOS1" Tags="|mixed-integer-programming|modeling|sos1|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11518" PostTypeId="1" AcceptedAnswerId="11519" CreationDate="2024-01-14T21:13:02.053" Score="2" ViewCount="184" Body="&lt;p&gt;I have solved an integer programming problem using the price-and-branch (not branch-and-price) approach exactly as same as described in &lt;a href=&quot;https://or.stackexchange.com/questions/8594/integer-column-generation-without-branch-price&quot;&gt;this question&lt;/a&gt; and obtained a feasible solution. As this approach is heuristic, I would like to evaluate the quality of my solution or examine how far it is from the global optimum solution. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="13028" LastActivityDate="2024-01-14T21:36:10.483" Title="How to evaluate the quality of a solution obtained using the price-and-branch method for an IP problem?" Tags="|integer-programming|column-generation|branch-and-price|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11519" PostTypeId="2" ParentId="11518" CreationDate="2024-01-14T21:36:10.483" Score="3" Body="&lt;p&gt;Assuming your problem is minimization, the step of solving the master LP yields a global lower bound, from which you can compute an optimality gap for your integer feasible solution.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2024-01-14T21:36:10.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11520" PostTypeId="2" ParentId="11502" CreationDate="2024-01-14T22:12:47.393" Score="1" Body="&lt;p&gt;In general, the optimization problem you have stated may not have a unique optimum, i.e, there may exist multiple optimal solutions.&#xA;Consider, for instance, &lt;span class=&quot;math-container&quot;&gt;$\min_{x,y} \{ x | x=c, 0 \leq y \leq 1\}$&lt;/span&gt;: any solution &lt;span class=&quot;math-container&quot;&gt;$(c,y)$&lt;/span&gt; is optimal.&lt;/p&gt;&#xA;&lt;p&gt;In that case, the mapping from &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; to an optimal solution of the problem is one-to-many, and is therefore not differentiable.&#xA;This is often the case when &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and/or &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; are non-convex: the optimum may not be unique, or it may jump to a distant point even under small perturbation.&lt;/p&gt;&#xA;&lt;p&gt;There is a rich literature in the machine learning community on differentiating through an optimization problem.&#xA;As far as I know, they all rely (in some form or the other) on the KKT conditions. One of the most famous paper is&#xA;&lt;a href=&quot;https://proceedings.neurips.cc/paper/2019/hash/9ce3c52fc54362e22053399d3181c638-Abstract.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this NeurIPS 2019 paper&lt;/a&gt; for the convex case.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2024-01-14T22:12:47.393" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11521" PostTypeId="2" ParentId="11517" CreationDate="2024-01-14T23:01:49.320" Score="1" Body="&lt;p&gt;Using the CPLEX definition, the constraint &lt;span class=&quot;math-container&quot;&gt;$a+b=1$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt; forming a type 1 SOS still implies integrality of &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that avoiding an explicit integrality constraint is not necessarily a good thing. Solvers take integrality into consideration when doing presolve reductions and when computing cuts at nodes. If you do not specify integrality, the solver might or might not infer it from the SOS1 constraint, depending on the sophistication of the solver.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-14T23:01:49.320" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11522" PostTypeId="1" CreationDate="2024-01-15T06:36:36.240" Score="2" ViewCount="134" Body="&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I've written a solver that selects a subset of people from a larger pool such that the subset has at least X people per attribute (Gender/Job/Country etc. X differs per attribute).&lt;/p&gt;&#xA;&lt;p&gt;This involves two dataframes: 1st is a DF of people with columns corresponding to various attributes (Gender, Job, etc), 2nd is a DF of requirements. This DF has 3 columns: The column to reference in the first DF, the specific attribute and minimum people required ie [&amp;quot;Job&amp;quot;, &amp;quot;Doctor&amp;quot;, 10]. Then the desired subset size is given and the solver tries to find a subset that fulfils each requirement.&lt;/p&gt;&#xA;&lt;p&gt;My implementation currently has a boolVar AttributeSelectionMap[(i,j,k)] which is 1 if Person i, Column j, Attribute k is selected (Linearizations for Person i being selected and Person i has Attribute k on Column j are written as well but not included here).&lt;/p&gt;&#xA;&lt;p&gt;Then for each minimum target to meet, I have&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for j in columns:&#xA;    for k in columnAttributes:&#xA;        model.Add(sum(AttributeSelectionMap[(i,j,k)] for i in People) &amp;gt;= minimumtarget&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The solver works fine with all the linearizations etc solving for which person in the list of People to pick for the subset.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&#xA;I'm now trying to implement a way to figure out which constraints are causing Infeasible scenarios. The general idea is similar to the one laid out here: &lt;a href=&quot;https://github.com/google/or-tools/issues/973&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/issues/973&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Basically, I'd like to add a boolVar per minimum target constraint that is 1 when the constraint has been met, and 0 otherwise. Then I would have the solver maximize these boolVars such that even if it were Infeasible I could figure out from the 0s which constraints caused the Infeasible outcome.&lt;/p&gt;&#xA;&lt;p&gt;The intended implementation was as such:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;constraintgrid = {}&#xA;constraintcount = 1&#xA;&#xA;for j in columns:&#xA;    for k in columnAttributes:&#xA;        model.Add(sum(AttributeSelectionMap[(i,j,k)] for i in People) &amp;gt;= minimumtarget)&#xA;        constraintgrid[constraintcount] = model.NewBoolVar(f&amp;quot;Constraint {constraintcount}: {k} needs minimum {minimumtarget}&amp;quot;)&#xA;        model.Add(constraintgrid[constraintcount]).OnlyEnforceIf(sum(AttributeSelectionMap[(i,j,k)] for i in People) &amp;gt;= minimumtarget)&#xA;        constraintcount += 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The implementation above runs into the bug &amp;quot;&lt;strong&gt;NotImplementedError&lt;/strong&gt;: Evaluating a LinearExpr instance as a Boolean is not implemented.&amp;quot;, so the sum(target) &amp;gt;= minimumtarget part is causing the bug.&lt;/p&gt;&#xA;&lt;p&gt;Are there any existing workarounds for this where I could make this &amp;quot;constraint variable&amp;quot; work that doesn't involve using OnlyEnforceIf on a linear expression?&lt;/p&gt;&#xA;" OwnerUserId="12136" LastActivityDate="2024-01-15T07:47:58.890" Title="CP-SAT: Workarounds for OnlyEnforceIf with Linear Expressions" Tags="|or-tools|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11523" PostTypeId="2" ParentId="11522" CreationDate="2024-01-15T07:47:58.890" Score="4" Body="&lt;p&gt;This is a recurring question, and I have written a page of doc to solve it:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/google/or-tools/blob/stable/ortools/sat/docs/channeling.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/or-tools/blob/stable/ortools/sat/docs/channeling.md&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The idea is to create a Boolean variable that is equivalent to your linear condition, and use it in the OnlyEnforceIf as it accepts only one or more Boolean literals.&lt;/p&gt;&#xA;&lt;p&gt;in a nutshell:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  cond = model.NewBoolVar('cond')&#xA;&#xA;  # Link the condition with the linear expression.&#xA;  model.Add(my_sum &amp;gt;= minimum_target).OnlyEnforceIf(cond)&#xA;  model.Add(my_sum &amp;lt; minimum_target).OnlyEnforceIf(cond.Not())&#xA;&#xA;  # Use the condition variable. Use implications as this is shorter&#xA;  model.AddImplication(cond, constraintgrid[constraintcount])&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="981" LastActivityDate="2024-01-15T07:47:58.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11524" PostTypeId="1" CreationDate="2024-01-15T10:53:51.327" Score="2" ViewCount="51" Body="&lt;p&gt;I have just come across the topic of 'Rolling Horizon' in my literature research and would now like to apply it myself, but unfortunately I don't know where to start. This is my model, which is supposed to work with a rolling approach.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\min \sum_{t,s}^{}slack_{t,s}\\&#xA;&amp;amp;\sum_{s}^{}work_{j,t,s}+slack_{t,s}=demand_{t,s}\quad \forall j,t\\&#xA;&amp;amp;\sum_{l=t}^{t+5}\sum_{s}^{}work_{j,l,s}\le 5\quad \forall j,t\\&#xA;&amp;amp;\sum_{s}^{}work_{j,t,s}\le 1\quad \forall j,t&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How exactly do I need to extend/modify the model so that I can implement and run such an approach? Is there any good literature where I can read up further on the subject?&lt;/p&gt;&#xA;" OwnerUserId="12086" LastActivityDate="2024-01-15T10:53:51.327" Title="Implement a rolling horizon approach into a schedulig problem" Tags="|linear-programming|scheduling|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11526" PostTypeId="1" AcceptedAnswerId="11535" CreationDate="2024-01-15T22:20:55.797" Score="1" ViewCount="114" Body="&lt;p&gt;I’m working on an optimization problem and need help with correctly prioritizing the allocation of certain variables in a constraint. The rules are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Only one of the variables &lt;span class=&quot;math-container&quot;&gt;$y_{t}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_{t}$&lt;/span&gt; can be non-zero at a time.&lt;/li&gt;&#xA;&lt;li&gt;A prioritization rule is applied to the variables &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_{t}$&lt;/span&gt;. The model initially attempts to satisfy the constraint using &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt;. However, if &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; proves inadequate, the model then resorts to &lt;span class=&quot;math-container&quot;&gt;$z_{t}$&lt;/span&gt;, requiring &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; to be set to zero.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The variables are defined as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \leq x \leq 1$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;All the variables &lt;span class=&quot;math-container&quot;&gt;$y_{t}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_{t}$&lt;/span&gt; are continuous and bounded between 0 and 1.&lt;/li&gt;&#xA;&lt;li&gt;We define binary variables &lt;span class=&quot;math-container&quot;&gt;$b_{t}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$bz_{t}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$bzn_{t}$&lt;/span&gt; for enforcing some of the constraints.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The heart of this problem lies in the constraint, which is defined as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\begin{align}&#xA;&amp;amp; C_{t} \left( x - \sum_{j=1}^{t} z_{j} \right) +\sum_{i=2}^{t} CN_{i, t-i+1} \left( y_i - \sum_{j=i}^{t} zn_{j} \right) \nonumber \\&#xA;&amp;amp; + S_{t} \cdot z_{t} + SN_{t} \cdot zn_{t} - CO_{t} \cdot y_{t} - E_t = 0 \quad \forall t&#xA;\end{align}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$CN_{i, t-i+1}$&lt;/span&gt; represents values derived from a specific position, determined at the time &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and assessed at the later time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;At &lt;span class=&quot;math-container&quot;&gt;$t=1$&lt;/span&gt;, we can assume that all variables except &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; takes zero value or more conveniently define the constraint differently for &lt;span class=&quot;math-container&quot;&gt;$t=1$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$t&amp;gt;1$&lt;/span&gt;. For &lt;span class=&quot;math-container&quot;&gt;$t=1$&lt;/span&gt;, we can define this constraint as: &lt;span class=&quot;math-container&quot;&gt;$C_{1} \cdot x - E_{1} = 0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$C_{t} \left( x - \sum_{j=1}^{t} z_{j} \right) +\sum_{i=2}^{t} CN_{i, t-i+1} \left( y_i - \sum_{j=i}^{t} zn_{j} \right) \nonumber - E_t &amp;lt; 0$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$z_{t}$&lt;/span&gt; must take non-zero value. If it is greater than zero then &lt;span class=&quot;math-container&quot;&gt;$y_{t}$&lt;/span&gt; must take take non-zero value.&#xA;How can I ensure that these prioritization rules are consistently applied within the constraints of my model?&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\textbf{Other Constraints:}$&lt;/span&gt; These enforces some of the rules set out above, except priortisation. These can be ignored for the purpose of the question.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\begin{alignat}{2}&#xA;&amp;amp; \sum_{j=i}^{t} zn_{j} &amp;amp;&amp;amp; \leq y_i \quad &amp;amp;&amp;amp; \forall i \\&#xA;&amp;amp; \sum_{j=1}^{t} z_{j} &amp;amp;&amp;amp; \leq x \quad  &amp;amp;&amp;amp; \forall t \\&#xA;&amp;amp; y_{t} &amp;amp;&amp;amp; \leq b_{t} \quad &amp;amp;&amp;amp; \forall t \\&#xA;&amp;amp; zn_{t} &amp;amp;&amp;amp; \leq bzn_{t} \quad &amp;amp;&amp;amp; \forall t \\&#xA;&amp;amp; z_{t} &amp;amp;&amp;amp; \leq bz_{t} \quad &amp;amp;&amp;amp; \forall t \\&#xA;&amp;amp; b_{t} + bzn_{t} + bz_{t} &amp;amp;&amp;amp; \leq 1 \quad &amp;amp;&amp;amp; \forall t \\&#xA;\end{alignat}$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="13085" LastEditorUserId="13085" LastEditDate="2024-01-16T07:30:17.217" LastActivityDate="2024-01-18T00:44:39.573" Title="Priotization rules for variable allocation in linear programming" Tags="|mixed-integer-programming|combinatorial-optimization|binary-variable|big-m|indicator-constraints|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11527" PostTypeId="1" CreationDate="2024-01-15T23:11:51.553" Score="0" ViewCount="73" Body="&lt;p&gt;I have a minimization problem for which I am having some misunderstandings and confusions with regard to some results I am getting for an ILP and its LP relaxation.&lt;/p&gt;&#xA;&lt;p&gt;In the ILP I have two decision variables, one is binary while the other is continuous. There is a bilinear term involving the product of the binary variable in the ILP. I introduced the McCormick Envelopes to eliminate the bi-linear term in the relaxed version.&lt;/p&gt;&#xA;&lt;p&gt;What I do not understand is that after a deterministic rounding scheme I developed, the value of the cost function is less than or equal to the optimal cost function value.&#xA;Is that correct ? Am I missing something somehow ?&lt;/p&gt;&#xA;" OwnerUserId="13086" LastEditorUserId="13086" LastEditDate="2024-01-15T23:12:34.190" LastActivityDate="2024-01-15T23:12:34.190" Title="Cost function value of relaxed ILP after rounding is less than or equal to the optimal one" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|lp-relaxation|" AnswerCount="0" CommentCount="18" ContentLicense="CC BY-SA 4.0" />
  <row Id="11528" PostTypeId="1" CreationDate="2024-01-16T04:52:59.997" Score="1" ViewCount="262" Body="&lt;p&gt;I am looking for a heuristic/exact algorithm to model this problem related to airport standby. The goal here is to suggest different standby slots required to cover all the flights leaving an airport.&lt;/p&gt;&#xA;&lt;p&gt;Known data:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Number of standby needed for each day&lt;/li&gt;&#xA;&lt;li&gt;The timings of the flights for a week&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Constraints:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There will be some time constraints, like the rest between two duties, the duration of a duty etc.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;My goal is to plan the standby slots so that all the flights are covered and the number of slots created is optimal.&lt;/p&gt;&#xA;&lt;p&gt;Any idea how to approach this problem? Any links to articles/journals would also help.&lt;/p&gt;&#xA;" OwnerUserId="5532" LastActivityDate="2024-01-16T07:47:14.630" Title="Standby optimization in Aviation" Tags="|optimization|heuristics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11529" PostTypeId="2" ParentId="11528" CreationDate="2024-01-16T07:39:20.437" Score="1" Body="&lt;p&gt;There are multiple ways and technologies to model this. Given my bias, I 'll just show you how you would do it with Timefold (open source, java):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This sounds a lot like shift scheduling, but the starting time of a shift is an optimization variable. So I would turn the model inside out: create shifts per employee (possibly too many shifts) and assign those starting times.&lt;/li&gt;&#xA;&lt;li&gt;With the information available, I think &lt;a href=&quot;https://timefold.ai/docs/timefold-solver/latest/design-patterns/design-patterns#assigningTimeToPlanningEntities&quot; rel=&quot;nofollow noreferrer&quot;&gt;the time grain pattern&lt;/a&gt; best suits your needs.&lt;/li&gt;&#xA;&lt;li&gt;For each day, for each employee create 1 Shift instance.&lt;/li&gt;&#xA;&lt;li&gt;Not every Shift needs to be assigned, some can be assigned to null. As long as all flights are covered with the non-null assigned shifts, it's good.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Then your model looks something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@PlanningEntity class Shift {&#xA;   Employee employee;&#xA;   LocalDate date;&#xA;   Duration duration;&#xA;   @PlanningVariable(nullable=true) LocalTime start;&#xA;&#xA;   LocalTime getEnd() { return start.plus(duration); }&#xA;}&#xA;class Employee {&#xA;   String id;&#xA;}&#xA;class Flight {&#xA;   String id;&#xA;   LocalTime departureStart;&#xA;   LocalTime departureEnd;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And your constraints something like this (pseudo code):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// All flights need to be covered&#xA;.forEach(Flight)&#xA;.ifNotExists(Shift,&#xA;    overlapping(Flight::departureStart, Flight::departureEnd,&#xA;        Shift::start, Shift::end)&#xA;.penalize(HARD).asConstraint(&amp;quot;No shift to cover a flight&amp;quot;, ...)&#xA;&#xA;// Rest between two duties&#xA;.forEach(Shift)&#xA;.join(Shift, equals(Shift::employee))&#xA;.filter((shift1, shift2) -&amp;gt; Duration.between(shift1.end, shift2.end) &amp;gt; 0 &amp;amp;&amp;amp; &amp;lt; 10 hours)&#xA;.penalize(HARD).asConstraint(, &amp;quot;Not enough rest between two shifts&amp;quot;, ...)&#xA;&#xA;// Minimize shifts&#xA;.forEach(Shift)&#xA;.penalize(SOFT).asConstraint(&amp;quot;Minimize number of shifts&amp;quot;)&#xA;&#xA;// Optionally add a fairness constraint:&#xA;// loadBalance() the shifts across employees&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This problem naturally flows across multiple days, so you'll need to apply &lt;a href=&quot;https://www.youtube.com/shorts/p6V7VdAYFIc&quot; rel=&quot;nofollow noreferrer&quot;&gt;Continuous Planning&lt;/a&gt; for execution.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2024-01-16T07:47:14.630" LastActivityDate="2024-01-16T07:47:14.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11530" PostTypeId="1" AcceptedAnswerId="11533" CreationDate="2024-01-16T12:39:01.013" Score="1" ViewCount="93" Body="&lt;p&gt;This is similar to question I asked here: &lt;a href=&quot;https://or.stackexchange.com/questions/11526/priotization-rules-for-variable-allocation-in-linear-programming&quot;&gt;Priotization rules for variable allocation in linear programming&lt;/a&gt;. In an optimization problem, the goal is to manage the purchase and sale of items under specific conditions. We have the following rules:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Purchasing New Items&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the net value, calculated as &lt;span class=&quot;math-container&quot;&gt;$C_{t} \cdot x - E_{t} $&lt;/span&gt;, is positive, then new items should be purchased at price &lt;span class=&quot;math-container&quot;&gt;$CO_{t}$&lt;/span&gt;. This purchase is adjusted so that the net value after purchase becomes zero, formulated as &lt;span class=&quot;math-container&quot;&gt;$C_{t} \cdot x - E_{t} - CO_{t} \cdot y_{t} = 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Selling Items&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the net value is negative, there are two steps for selling items:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First, try selling new items at price &lt;span class=&quot;math-container&quot;&gt;$SN_{t}$&lt;/span&gt; to balance the net value, formulated as &lt;span class=&quot;math-container&quot;&gt;$C_{t} \cdot x - E_{t} + SN_{t} \cdot zn_{t} = 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If selling new items doesn't balance it, then sell initial items at price &lt;span class=&quot;math-container&quot;&gt;$S_{t}$&lt;/span&gt; to achieve &lt;span class=&quot;math-container&quot;&gt;$C_{t} \cdot x - E_{t} + S_{t} \cdot z_{t} = 0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Mutual Exclusivity of Transactions&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;At any given time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, only one type of transaction can occur – either buying new items, selling new items, or selling initial items. This means only one of the variables &lt;span class=&quot;math-container&quot;&gt;$y_{t}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z_{t}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; can be greater than zero at any time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The decision variables are defined as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat*}{2}&#xA;&amp;amp; x &amp;amp;&amp;amp; : \text{Represents initial allocation of items}, \quad 0 \leq x \leq 1. \\&#xA;&amp;amp; z_{t} &amp;amp;&amp;amp; : \text{Represents percentage of initial items sold in year } t, \quad 0 \leq z_{t} \leq 1. \\&#xA;&amp;amp; y_{t} &amp;amp;&amp;amp; : \text{Represents percentage of the new items purchased at time \( t \), \( 0 \leq y_t \leq 1 \)} \\&#xA;&amp;amp; zn_{t} &amp;amp;&amp;amp; : \text{Represents percentage of new items sold at time \( t \), \( 0 \leq zn_{t} \leq 1 \)} &#xA;\end{alignat*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can we formulate these conditions or prioritization rules in the optimization model? Additionally, is it possible to set a different prioritization rule where selling initial items &lt;span class=&quot;math-container&quot;&gt;$z_{t} &amp;gt; 0$&lt;/span&gt; is only allowed if the selling of new items &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; has reached its upper bound (i.e., &lt;span class=&quot;math-container&quot;&gt;$zn_{t} = 1$&lt;/span&gt;), and purchasing new items &lt;span class=&quot;math-container&quot;&gt;$y_{t}$&lt;/span&gt; is not permitted if either &lt;span class=&quot;math-container&quot;&gt;$z_{t}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; is positive?&lt;/p&gt;&#xA;" OwnerUserId="13085" LastActivityDate="2024-01-16T22:21:03.557" Title="Logical conditions" Tags="|mixed-integer-programming|logical-constraints|big-m|indicator-constraints|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11531" PostTypeId="2" ParentId="11526" CreationDate="2024-01-16T15:07:23.577" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A prioritization rule is applied to the variables &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_{t}$&lt;/span&gt;. The model initially attempts to satisfy the constraint using &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt;. However, if &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; proves inadequate, the model then resorts to &lt;span class=&quot;math-container&quot;&gt;$z_{t}$&lt;/span&gt;, requiring &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; to be set to zero.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is not a perfectly clear statement. if the primary objective is to maximize the number of &lt;span class=&quot;math-container&quot;&gt;$bzn_{t}$&lt;/span&gt; set to &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, that is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \max \sum_t bzn_{t} $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;then you should do a first optimization with this objective.&lt;/p&gt;&#xA;&lt;p&gt;If the objective value of this first problem is &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;, then you need to solve a second optimization problem with the original objective and the additional constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_t bzn_{t} = K $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The solution of the first problem is feasible for the second one, and thus can be provided as initial integer feasible solution to the solver for the second problem.&lt;/p&gt;&#xA;&lt;p&gt;If the solver supports lexicographic optimization, you can try to use this feature directly.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2024-01-16T16:32:45.313" LastActivityDate="2024-01-16T16:32:45.313" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="11532" PostTypeId="1" CreationDate="2024-01-16T19:34:44.143" Score="0" ViewCount="39" Body="&lt;p&gt;I have been trying to find proof of the ratio test for Dual Simplex, that is, selecting the variable that enters the base.&lt;/p&gt;&#xA;&lt;p&gt;Specifically, I was interested in knowing why by making that choice, reduced costs stay positive.&lt;/p&gt;&#xA;" OwnerUserId="13093" LastEditorUserId="36" LastEditDate="2024-01-16T23:08:24.393" LastActivityDate="2024-01-16T23:08:24.393" Title="Proof of Dual Simplex Ratio Test" Tags="|linear-programming|reference-request|simplex|dual-simplex|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11533" PostTypeId="2" ParentId="11530" CreationDate="2024-01-16T22:21:03.557" Score="1" Body="&lt;p&gt;I'm going to drop the subscript &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; to save clutter. Let &lt;span class=&quot;math-container&quot;&gt;$B = C\cdot x - E.$&lt;/span&gt; Introduce three binary variables &lt;span class=&quot;math-container&quot;&gt;$\omega_1,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_2,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\omega_3$&lt;/span&gt; together with the constraints &lt;span class=&quot;math-container&quot;&gt;$y \le \omega_1,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$zn \le \omega_2,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$z \le \omega_3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\omega_1 + \omega_2 + \omega_3 = 1.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We want to enforce is the following: &lt;span class=&quot;math-container&quot;&gt;$$\omega_1 = 1 \iff B \ge 0,$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$\omega_2 = 1 \iff 0 &amp;gt; B \ge -SN,$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$\omega_3 = 1\iff -SN &amp;gt; B \ge -S.$$&lt;/span&gt;  Since exactly one &lt;span class=&quot;math-container&quot;&gt;$\omega_i$&lt;/span&gt; will be 1 and the right hand sides form a disjoint partition of the feasible values of &lt;span class=&quot;math-container&quot;&gt;$B,$&lt;/span&gt; it suffices to enforce just the &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; direction.&lt;/p&gt;&#xA;&lt;p&gt;Strict inequalities are taboo in LP/IP models, so read &lt;span class=&quot;math-container&quot;&gt;$&amp;gt;$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; in the above. The good news is that if &lt;span class=&quot;math-container&quot;&gt;$B = 0$&lt;/span&gt; we don't care whether &lt;span class=&quot;math-container&quot;&gt;$y,$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$zn$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is used since any of them would take the value 0. The remaining weakness is that if &lt;span class=&quot;math-container&quot;&gt;$B=-SN,$&lt;/span&gt; either &lt;span class=&quot;math-container&quot;&gt;$\omega_2 = 1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\omega_3 = 1$&lt;/span&gt; would be feasible, meaning either &lt;span class=&quot;math-container&quot;&gt;$zn$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; could be used. If that is a problem, your only recourse is to change the third inequality to &lt;span class=&quot;math-container&quot;&gt;$-SN - \epsilon \ge B \ge -S$&lt;/span&gt; for some small positive &lt;span class=&quot;math-container&quot;&gt;$\epsilon,$&lt;/span&gt; the effect of which is to make any &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; for which &lt;span class=&quot;math-container&quot;&gt;$-SN - \epsilon &amp;lt; B &amp;lt; -SN$&lt;/span&gt; infeasible.&lt;/p&gt;&#xA;&lt;p&gt;Finally, we add the following inequalities, where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is an valid upper bound on &lt;span class=&quot;math-container&quot;&gt;$B:$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$B \ge -SN\cdot \omega_2 - S\cdot \omega_3$$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$$B \le M\cdot \omega_1 -SN\cdot \omega_3.$$&lt;/span&gt; These enforce the &lt;span class=&quot;math-container&quot;&gt;$\implies$&lt;/span&gt; directions of the three main inequalities.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-16T22:21:03.557" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11535" PostTypeId="2" ParentId="11526" CreationDate="2024-01-17T22:52:37.680" Score="0" Body="&lt;p&gt;This solution is adapted from an answer provided on the Operations Research Stack Exchange, accessible here: &lt;a href=&quot;https://or.stackexchange.com/questions/11530/logical-conditions/11533#11533&quot;&gt;Logical conditions&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The original constraint in the problem is given by:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;C_{t} \left( x - \sum_{j=1}^{t} z_{j} \right) &amp;amp;+ \sum_{i=2}^{t} CN_{i, t-i+1} \left( y_i - \sum_{j=i}^{t} zn_{j} \right) \\&#xA;&amp;amp;+ S_{t} \cdot z_{t} + SN_{t} \cdot zn_{t} - CO_{t} \cdot y_{t} - E_t = 0 \quad \forall t&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We define &lt;span class=&quot;math-container&quot;&gt;$B_{t}$&lt;/span&gt; as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$B_{t} = C_t \left( x - \sum_{j=1}^{t} z_j \right) + \sum_{i=2}^{t} CN_{i, t-i+1} \left( y_i - \sum_{j=i}^{t} zn_j \right)-E_{t}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We introduce three binary variables &lt;span class=&quot;math-container&quot;&gt;$b_{t}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$bzn_{t}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$bz_{t}$&lt;/span&gt;, along with their constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$y_{t} \le b_{t}, \quad zn_{t} \leq bzn_{t}, \quad z_{t} \leq bz_{t}, \quad b_{t} + bzn_{t} + bz_{t} = 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The logical conditions to be enforced are:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{alignat}{2}&#xA;&amp;amp; b_{t} &amp;amp;&amp;amp; = 1 &amp;amp;&amp;amp;\iff B_{t} \ge 0, \\&#xA;&amp;amp; bzn_{t} &amp;amp;&amp;amp; = 1 &amp;amp;&amp;amp;\iff 0 &amp;gt; B_{t} \ge -SN_{t}, \\&#xA;&amp;amp; bz_{t} &amp;amp;&amp;amp; = 1 &amp;amp;&amp;amp;\iff -SN_{t} &amp;gt; B_{t} \ge -S_{t}.&#xA;\end{alignat}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Each binary variable &lt;span class=&quot;math-container&quot;&gt;$b_{t}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$bzn_{t}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$bz_{t}$&lt;/span&gt; corresponds to a specific, non-overlapping range of &lt;span class=&quot;math-container&quot;&gt;$B_{t}$&lt;/span&gt;. This ensures that the ranges of &lt;span class=&quot;math-container&quot;&gt;$B_{t}$&lt;/span&gt; are mutually exclusive and cover all possible scenarios. Since only one binary variable can be active at a time, and each is linked to a distinct range of &lt;span class=&quot;math-container&quot;&gt;$B_{t}$&lt;/span&gt;, it's sufficient to enforce that if a binary variable is 1, &lt;span class=&quot;math-container&quot;&gt;$B_{t}$&lt;/span&gt; must fall within its respective range. The model's structure inherently handles the reverse implication.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$B_{t} = -SN_{t}$&lt;/span&gt;, the model allows for the possibility that either &lt;span class=&quot;math-container&quot;&gt;$bz_{t}=1$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$bzn_{t}=1$&lt;/span&gt;, which implies that either &lt;span class=&quot;math-container&quot;&gt;$zn_{t}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$z_{t}$&lt;/span&gt; could be non-zero. To address this issue, the third condition is modified to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$-SN_{t} - \epsilon \ge B_{t} \ge -S_{t}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is a small positive. This change effectively eliminates the overlap in the ranges, making the range &lt;span class=&quot;math-container&quot;&gt;$-SN_{t} - \epsilon &amp;lt; B_{t} &amp;lt; -SN_{t}$&lt;/span&gt; infeasible.&lt;/p&gt;&#xA;&lt;p&gt;Finally, the following inequalities enforce the logical conditions, where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a valid upper bound on &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;B_{t} &amp;amp;\ge -SN_{t} \cdot bzn_{t} - S_{t} \cdot bz_{t}, \\&#xA;B_{t} &amp;amp;\le M \cdot b_{t} - (SN_{t} + \epsilon) \cdot bz_{t}.&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;These constraints ensure that each binary variable's activation correctly reflects the intended range of &lt;span class=&quot;math-container&quot;&gt;$B_{t}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13085" LastEditorUserId="13085" LastEditDate="2024-01-18T00:44:39.573" LastActivityDate="2024-01-18T00:44:39.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11536" PostTypeId="1" AcceptedAnswerId="11537" CreationDate="2024-01-18T02:57:55.050" Score="0" ViewCount="53" Body="&lt;p&gt;I’m curious about the warehouse placement problem. Suppose N nodes exist, each with average demand across all products (or a single product for simplicity.) the problem is to position M warehouses that such that distances from each node to the closest warehouse is minimized.&lt;/p&gt;&#xA;&lt;p&gt;How can I model this problem with MILP?&lt;/p&gt;&#xA;&lt;p&gt;I’m more interested in an explanation of constraints, objective and relevant data than a specified model in a given framework (ex Gurobi).&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="500" LastEditDate="2024-01-18T03:13:03.003" LastActivityDate="2024-01-18T03:50:37.110" Title="Warehouse placement problem in" Tags="|mixed-integer-programming|facility-location|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11537" PostTypeId="2" ParentId="11536" CreationDate="2024-01-18T03:50:37.110" Score="1" Body="&lt;p&gt;For the problem described in the question, with the added assumption that a finite set of potential warehouse locations is specified, a MILP model would look as follows. There would be a binary variable for each location (place a warehouse there or not) and a constraint that those variables sum to &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; (or sum to less than or equal to &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; if you are not required to use the full quota of warehouses). For each pair of customer and potential location there would be a binary variable (assign that customer to that location) along with constraints that every customer be assigned once and every no assignment can be made to a location without a warehouse. The objective would be the weighted sum of the assignment variables, with the distances being the weights.&lt;/p&gt;&#xA;&lt;p&gt;Note that this is a rather bare-bones warehouse location problem. More common variants in supply chain management have capacity limits on warehouses, plus constraints that the total demand allocated to each warehouse not exceed its capacity. It is fairly common (though not universal) that client demands can be split across warehouses if desired. The objective function might combine the cost of fulfilling demands (which likely would depend on distances from warehouse to customer) plus possibly a construction/&amp;quot;setup&amp;quot; cost for placing a warehouse at a location, plus possibly a cost component dependent on the capacity of a warehouse (if it is possible to build various size warehouses at a site), plus possibly an operating cost for each warehouse (which again might be dependent on capacity).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-18T03:50:37.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11538" PostTypeId="1" CreationDate="2024-01-18T12:55:03.937" Score="0" ViewCount="86" Body="&lt;p&gt;I am studying a clustering problem. By reading the literature, I found that the clustering problem can be converted into an optimization problem, K-Medoids can be converted into an integer programming problem. I would like to ask if this kind of integer programming problem can be solved using an exact algorithm.&lt;/p&gt;&#xA;" OwnerUserId="12244" LastActivityDate="2024-02-07T13:46:10.373" Title="Turning K-Medoids into an optimization problem" Tags="|optimization|clustering|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11539" PostTypeId="1" CreationDate="2024-01-18T16:37:17.813" Score="2" ViewCount="157" Body="&lt;p&gt;I am trying to write an MILP to do a grouping (clustering) given one difference condition.&lt;/p&gt;&#xA;&lt;p&gt;Suppose, I have the following elements in a list: 1,2,3,4,6,8,9,10.&lt;/p&gt;&#xA;&lt;p&gt;My goal here is to group them so that the difference between two elements won't cross a given threshold for each group and the number of groups should be minimised. So, if I give a difference threshold of 6, my two groups should be: 1,2,3,4,6 and 8,9,10. (1 &amp;amp; 8 can't be in the same group because the difference is 7)&lt;/p&gt;&#xA;&lt;p&gt;To formulate the MILP, I am considering the following:&lt;/p&gt;&#xA;&lt;p&gt;Objective function:&#xA;Minimise the number of groups&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Each element must be in exactly one group&lt;/li&gt;&#xA;&lt;li&gt;If a group is used then it should be considered&lt;/li&gt;&#xA;&lt;li&gt;Two elements of the same group shouldn't have a difference greater than the given threshold.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I have modelled this in R like this but it is converging very slowly and often the output is not correct. Is there any more efficient way to model this?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;library(tidyverse)&#xA;library(ompr)&#xA;library(ompr.roi)&#xA;library(ROI.plugin.glpk)&#xA;&#xA;# Define your element ids and the difference&#xA;element_ids &amp;lt;- c(1, 2, 3, 4, 5, 6, 7, 9, 10, 12)&#xA;diff &amp;lt;- 5&#xA;&#xA;&#xA;model &amp;lt;- MIPModel() %&amp;gt;%&#xA;  # Binary variable for each element id and group&#xA;  add_variable(x[i, g], i = 1:length(element_ids), g = 1:length(element_ids), type = &amp;quot;binary&amp;quot;) %&amp;gt;%&#xA;  # Binary variable for each group&#xA;  add_variable(y[g], g = 1:length(element_ids), type = &amp;quot;binary&amp;quot;) %&amp;gt;%&#xA;  # Objective: minimize the number of groups&#xA;  set_objective(sum_expr(y[g], g = 1:length(element_ids)), &amp;quot;min&amp;quot;) %&amp;gt;%&#xA;  # Constraint: each element id must be in exactly one group&#xA;  add_constraint(sum_expr(x[i, g], g = 1:length(element_ids)) == 1, i = 1:length(element_ids)) %&amp;gt;%&#xA;  # Constraint: if a group is used, then y[g] = 1&#xA;  add_constraint(sum_expr(x[i, g], i = 1:length(element_ids)) &amp;lt;= length(element_ids) * y[g], g = 1:length(element_ids))&#xA;&#xA;# Constraint: no two element ids in the same group can have a difference equal to 'diff'&#xA;for (i in 1:(length(element_ids) - 1)) {&#xA;  for (j in (i + 1):length(element_ids)) {&#xA;    if (element_ids[j] - element_ids[i] &amp;gt; diff) {&#xA;      model &amp;lt;- model %&amp;gt;%&#xA;        add_constraint(x[i, g] + x[j, g] &amp;lt;= 1, g = 1:length(element_ids))&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;# Solve the model&#xA;result &amp;lt;- solve_model(model, with_ROI(solver = &amp;quot;glpk&amp;quot;, verbose = TRUE))&#xA;&#xA;# Print the solution&#xA;solution &amp;lt;- result %&amp;gt;% get_solution(x[i, g]) %&amp;gt;% filter(value &amp;gt; 0) %&amp;gt;% select(i, g, value)&#xA;print(solution)&#xA;&#xA;&#xA;i g value&#xA;1   1   1       &#xA;2   1   1       &#xA;3   1   1       &#xA;4   1   1       &#xA;5   1   1       &#xA;6   1   1       &#xA;7   10  1       &#xA;8   10  1       &#xA;9   10  1       &#xA;10  10  1   &#xA;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5532" LastActivityDate="2024-01-29T13:02:03.933" Title="Grouping values based on a difference constraint" Tags="|mixed-integer-programming|r|clustering|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11540" PostTypeId="2" ParentId="11538" CreationDate="2024-01-18T17:03:44.270" Score="3" Body="&lt;p&gt;Yes, the problem can be solved exactly using common IP algorithms such as branch-and-cut, with the usual qualification that there will be some limit on the size of the problems you can handle. (What that size limit is depends on the hardware and software you are using and how long you are willing to wait for a provably optimal solution.)&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-18T17:03:44.270" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11541" PostTypeId="2" ParentId="11539" CreationDate="2024-01-18T17:19:55.603" Score="3" Body="&lt;p&gt;Some of this may be solver dependent. I just ran your model with only one change -- switching the solver from glpk to CPLEX -- and got a valid solution (the same as yours, changing group 10 to group 2) in 0.06 seconds.&lt;/p&gt;&#xA;&lt;p&gt;There are tweaks you can make to your model that may or may not improve execution time. It contains a fair bit of symmetry, since group indexing is arbitrary. (Permuting group indices in a solution produces another valid solution.) You can reduce symmetry either by using a parameter setting (if one exists) telling your solver to work on symmetry reduction or by adding the following constraint.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;add_constraint(y[g] &amp;lt;= y[g - 1], g = 2:length(element_ids))&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also, your constraint &amp;quot;if a group is used, then y[g] = 1&amp;quot; can be disaggregated, leading to more but less dense constraints, by changing it to the following.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;add_constraint(x[i, g] &amp;lt;= y[g], i = 1:length(element_ids), g = 1:length(element_ids))&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Whether either of those tweaks helps is an empirical question.&lt;/p&gt;&#xA;&lt;p&gt;As to the output being incorrect, if you are referring to having group numbers 1 and 10 rather than 1 and 2, that is addressed above. If you mean that some instances produce infeasible or suboptimal solutions, I suggest you start a new question and post the source code for such an instance. Your model is mathematically correct, so infeasible/suboptimal solutions should not occur.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-18T17:19:55.603" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11542" PostTypeId="2" ParentId="11539" CreationDate="2024-01-18T17:22:30.727" Score="3" Body="&lt;p&gt;Since you've a threshold (diff) you may pre-define max of diff number of groups, not the full length of the list.&#xA;As for the if condition try this&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$L(x_{i,g}+x_{j,g}-1) \le d - (L_j - L_i)$&lt;/span&gt;&lt;br /&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; is the largest number is the sorted list.&lt;br /&gt;&#xA;Try sorting the list first (outside of the model)&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2024-01-18T17:22:30.727" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11544" PostTypeId="1" CreationDate="2024-01-19T05:48:12.350" Score="1" ViewCount="109" Body="&lt;p&gt;I have the following model the predict the log of volume:&lt;/p&gt;&#xA;&lt;p&gt;fixed_effect + day_of_week_effect + elasticity * (Price -&#xA;competitor_price).&lt;/p&gt;&#xA;&lt;p&gt;I want to formulate an optimization problem that maximize my profit such that:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$max$&lt;/span&gt; profit = &lt;span class=&quot;math-container&quot;&gt;$max$&lt;/span&gt; log of volume + log of unitary margin.&lt;/p&gt;&#xA;&lt;p&gt;With unitary margin being my price minus my costs.&lt;/p&gt;&#xA;&lt;p&gt;My problem is that given the fact that my decision variable is the price. The optimal price is the same for whatever day of week or fixed effect, since their derivative is equal to zero.&lt;/p&gt;&#xA;&lt;p&gt;How can I integrate the fact that I want to put higher prices when day effect leads to higher volumes and vice versa. I thought about having an interaction term between price and the fixed effects, or modifying elasticity by multiplying it by the day of week. But I would like to know if their is any other approach used for these kind of cases&lt;/p&gt;&#xA;" OwnerUserId="6016" LastEditorUserId="12370" LastEditDate="2024-01-19T10:46:29.803" LastActivityDate="2024-02-19T00:08:41.020" Title="Incorporate fixed effects in pricing decisions with linear models" Tags="|modeling|pricing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11545" PostTypeId="1" CreationDate="2024-01-19T09:28:13.953" Score="1" ViewCount="127" Body="&lt;p&gt;I was wondering, how one would linearize such a constraint, to make it applicable to LPs.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ a_{i}=(a_{i-1}+b_{i})(1-c_{i})-d_{i}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$a_i$&lt;/span&gt; gives information of the number of assigned jobs to machine &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. &lt;span class=&quot;math-container&quot;&gt;$b_i$&lt;/span&gt; if machine &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; performs a job. &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; indicates whether a machine breaks down. &lt;span class=&quot;math-container&quot;&gt;$d_i$&lt;/span&gt; if a job is finished.&lt;/p&gt;&#xA;" OwnerUserId="11884" LastEditorUserId="500" LastEditDate="2024-01-19T13:56:37.060" LastActivityDate="2024-01-19T14:20:52.317" Title="How do I linearize such a constraint?" Tags="|mixed-integer-programming|linear-programming|linearization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11546" PostTypeId="2" ParentId="11545" CreationDate="2024-01-19T10:05:38.300" Score="3" Body="&lt;p&gt;If I understand correctly, &lt;span class=&quot;math-container&quot;&gt;$c_i$&lt;/span&gt; is a binary decision variable that is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; if machine &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; breaks down and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; otherwise. Also, I assume that &lt;span class=&quot;math-container&quot;&gt;$(a_{i-1}+b_i)$&lt;/span&gt; is non-negative. You can introduce the decision variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; which takes the value of &lt;span class=&quot;math-container&quot;&gt;$(a_{i-1}+b_i)(1-c_i)$&lt;/span&gt;. You can then introduce the following constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;a_{i}=z-d_{i}\newline&#xA;0 \leq z \leq a_{i-1}+b_i \newline&#xA;z \geq (a_{i-1}+b_i)-c_iM \newline&#xA;z \leq M(1−c_i)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first two constraints are straightforward. In the third constraint, if the machine does not break down, i.e., &lt;span class=&quot;math-container&quot;&gt;$c_i = 0$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is forced to take value &lt;span class=&quot;math-container&quot;&gt;$a_{i-1}+b_i$&lt;/span&gt;. If the machine breaks down (&lt;span class=&quot;math-container&quot;&gt;$c_i = 1$&lt;/span&gt;), the RHS becomes negative (where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a large number) and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; will take value &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, because of the fourth constraint.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="3464" LastEditDate="2024-01-19T14:20:52.317" LastActivityDate="2024-01-19T14:20:52.317" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11547" PostTypeId="2" ParentId="11544" CreationDate="2024-01-19T23:29:08.800" Score="0" Body="&lt;p&gt;say price &lt;span class=&quot;math-container&quot;&gt;$p$&lt;/span&gt; is indexed by day of the week &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; &amp;amp; so is the effect &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;. Then a constraint like&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$E_d - E_{d+1} \le M(p_d - p_{d+1})$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$p_d - p_{d+1} \le M(E_d - E_{d+1})$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2024-01-19T23:29:08.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11548" PostTypeId="1" CreationDate="2024-01-20T16:31:16.220" Score="0" ViewCount="46" Body="&lt;p&gt;Let&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; be a set of &lt;em&gt;discretely interruptible&lt;/em&gt; processes/tasks;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$T_i \in \mathbb{N}$&lt;/span&gt; be the running time of process &lt;span class=&quot;math-container&quot;&gt;$i \in P$&lt;/span&gt;; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\tau \in \mathbb{N}$&lt;/span&gt; be the maximum amount of time a process can use the machine, per turn.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;We aim finding a &lt;em&gt;circular&lt;/em&gt; scheduling for &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;, satisfying the time limit &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; and completing the demanded time &lt;span class=&quot;math-container&quot;&gt;$T_i$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\forall i \in P$&lt;/span&gt;.&#xA;A &lt;em&gt;circular&lt;/em&gt; scheduling is given as a sequence &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; of tasks, in such a way that, if process &lt;span class=&quot;math-container&quot;&gt;$S_l$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;-th process in the sequence &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;) is placed to be executed at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, then at time &lt;span class=&quot;math-container&quot;&gt;$t + 1$&lt;/span&gt; the process to be executed must be the one indexed at:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\arg \min_{l \leqslant k \leqslant |P|: \text{ process $S_k$ wasn't completed till time $t$, and $\tau$ not exceeded}} \{ k - l \}$&lt;/span&gt;, i.e. the process after (or at) &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;, in the sequence, which still has pending execution time; Else&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$\arg \max_{1 \leqslant k \leqslant l - 1: \text{ process $S_k$ wasn't completed till time $t$, and $\tau$ not exceeded}} \{ l - k \}$&lt;/span&gt;, i.e. the process before (or at) &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt;, in the sequence, which still has pending execution time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Let's consider the example below:&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Let's assume, we have &lt;span class=&quot;math-container&quot;&gt;$\tau = 2$&lt;/span&gt;, and a scheduling for &lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt; given by the sequence &lt;span class=&quot;math-container&quot;&gt;$S = \{ 1, 2, 3, 4 \}$&lt;/span&gt;. Then we would have the following picture.&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$5$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$7$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$8$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$9$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$11$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt;&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$P$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;In time&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t = 2$&lt;/span&gt;, process &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; is chosen because it still have pending execution time, and the time limit &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; still being respected for this process;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t = 3$&lt;/span&gt;, process &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; is chosen because it comes right after process &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in the sequence, still have pending execution time, and the time limit &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; still being respected for this process;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t = 4$&lt;/span&gt;, process &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; is chosen because it still have pending execution time, and the time limit &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; still being respected for this process;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t = 5$&lt;/span&gt;, process &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; is chosen because it comes right after process &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; in the sequence, still have pending execution time, and the time limit &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; still being respected for this process;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t = 6$&lt;/span&gt;, process &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt; is chosen because it still have pending execution time, and the time limit &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; still being respected for this process;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t = 7$&lt;/span&gt;, process &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; is chosen because it comes right after process &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;, still have pending execution time, and the time limit &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; still being respected for this process;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t = 8$&lt;/span&gt;, process &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; is chosen because it still have pending execution time, and the time limit &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; still being respected for this process;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t = 9$&lt;/span&gt;, process &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; is chosen because it comes right after process &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; in the (circular) sequence, still have pending execution time, and the time limit &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; still being respected for this process;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t = 10$&lt;/span&gt;, process &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; is chosen because it comes right after process &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in the sequence, still have pending execution time, the time limit &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; still being respected for this process, and process &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; has no pending execution time;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t = 11$&lt;/span&gt;, process &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; is chosen because it still have pending execution time, and the time limit &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; still being respected for this process;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t = 12$&lt;/span&gt;, process &lt;span class=&quot;math-container&quot;&gt;$4$&lt;/span&gt; is chosen because, in the sequence, it is the process right after the previous process with pending execution time, and the time limit &lt;span class=&quot;math-container&quot;&gt;$\tau$&lt;/span&gt; still being respected for this process.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I would like to know how to model this problem through Constraint Programming.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="491" LastEditDate="2024-01-22T13:41:06.240" LastActivityDate="2024-01-22T13:41:06.240" Title="Circular queue modeling" Tags="|scheduling|constraint-programming|logical-constraints|queuing-theory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11549" PostTypeId="1" AcceptedAnswerId="11551" CreationDate="2024-01-20T16:44:09.053" Score="2" ViewCount="51" Body="&lt;p&gt;A graph &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; has nodes &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; and edges &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;. Let's say I have found the maximum clique or all the cliques in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; with any algorithm, such as the Bron-Kerbosch algorithm. After a while, &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; has been updated to &lt;span class=&quot;math-container&quot;&gt;$E'$&lt;/span&gt; by adding new edges to the graph, while &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; remains the same. I want to find all the cliques again in &lt;span class=&quot;math-container&quot;&gt;$G$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$E'$&lt;/span&gt;. Is there a way to use the cliques found earlier and update them in some way instead of finding the cliques from scratch again?&lt;/p&gt;&#xA;" OwnerUserId="3480" LastEditorUserId="500" LastEditDate="2024-01-20T19:30:45.073" LastActivityDate="2024-01-20T20:39:01.713" Title="updating cliques for an updated graph" Tags="|combinatorial-optimization|graphs|warm-start|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11551" PostTypeId="2" ParentId="11549" CreationDate="2024-01-20T20:39:01.713" Score="2" Body="&lt;p&gt;If the goal is to find all cliques, then we start with the fact that every clique in &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is also a clique in &lt;span class=&quot;math-container&quot;&gt;$E^\prime.$&lt;/span&gt; For each new edge &lt;span class=&quot;math-container&quot;&gt;$(a,b),$&lt;/span&gt; look at every pair of cliques &lt;span class=&quot;math-container&quot;&gt;$C,\hat{C}$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$a\in C$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b\in \hat{C}$&lt;/span&gt; and test whether the set of new edges makes &lt;span class=&quot;math-container&quot;&gt;$C \cup \hat{C}$&lt;/span&gt; a clique.&lt;/p&gt;&#xA;&lt;p&gt;If the goal is to find a maximum clique, do the above and update the maximum clique whenever a new incumbent is found.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-20T20:39:01.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11552" PostTypeId="2" ParentId="11548" CreationDate="2024-01-20T22:17:03.983" Score="1" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$0 \le x_{p,d} \le T' \quad \forall p \in P \ \forall d \le T$&lt;/span&gt;.&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt; is the index of slots covering required duration of each job as in column &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;.&lt;br /&gt;&#xA;For e.g. for job &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; d.v. will be &lt;span class=&quot;math-container&quot;&gt;$x_{1,1},x_{1,2},x_{1,3}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x \in Z$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$T'$&lt;/span&gt; is the max time available, here it will be &lt;span class=&quot;math-container&quot;&gt;$12$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constraints&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$x_{p,d+1} - x_{p,d} \ge 1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{q,d}-x_{p,d} \ge 1 \quad \forall q \in P \ \ \&amp;amp; q \neq p$&lt;/span&gt;&lt;br /&gt;&#xA;The above two pairs of constraints can be implemented using 'all-different' constraints&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1-z_{p,d} \le x_{p,d}-x_{p,d-1}-1 \le T(1-z_{p,d})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_d z_{p,d} \le \tau \quad \forall p$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; is a binary&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2024-01-20T22:17:03.983" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11553" PostTypeId="1" CreationDate="2024-01-21T08:05:01.103" Score="0" ViewCount="47" Body="&lt;p&gt;The following objective function is non-convex. How can we solve min&lt;span class=&quot;math-container&quot;&gt;$ \left|| A^{\dagger}A-I \right||_F $&lt;/span&gt;? Will adding an auxiliary matrix be helpful or not? I am trying to solve it using ADMM Any other suggestions?  the main equation is &lt;span class=&quot;math-container&quot;&gt;$y=Hx$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$H=A^†A$&lt;/span&gt; H is a transformation matrix that needs to be close to the identity matrix. And this is a part of the optimization problem which has other variables and constraints.&lt;/p&gt;&#xA;" OwnerUserId="13109" LastActivityDate="2024-01-21T08:05:01.103" Title="nonlinear least square" Tags="|optimization|nonconvex-programming|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11556" PostTypeId="1" AcceptedAnswerId="11557" CreationDate="2024-01-22T16:53:35.400" Score="2" ViewCount="250" Body="&lt;p&gt;I would like to know how to express the continuity constraint without using a decision variable in the conditional form. My challenge is to stay with &lt;strong&gt;a linear formulation&lt;/strong&gt;.&#xA;I will start to explain my model :&#xA;We would like to determine the optimal starting and finishing date of the project while respecting the human resource capacity available to execute the project.&lt;/p&gt;&#xA;&lt;p&gt;One of the assumptions is that &lt;strong&gt;the project could not be interrupted during its executing period,&lt;/strong&gt; means once it starts it should be executed continually. Thus, we would like to express this constraint using a linear formulation :&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;subject to continuityConstraint {j in P, t in T: t &amp;gt;= 2}:&#xA;t &amp;lt;= Fin[j]  ==&amp;gt;  Act[j,t] &amp;gt;= Act[j,t-1];&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;We are not with a linear model anymore&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Sets :&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;set P:= {1..n}; #set of projects&lt;/p&gt;&#xA;&lt;p&gt;set RType:={&amp;quot;Project manager&amp;quot;, &amp;quot;Technical Expert&amp;quot;, &amp;quot;Financial Analyst&amp;quot;, &amp;quot;Estimator&amp;quot;, &amp;quot;Contractual manager&amp;quot;}; #set of human resources&lt;/p&gt;&#xA;&lt;p&gt;set T:= {1..l}; #set of terms&lt;/p&gt;&#xA;&lt;p&gt;set S:= {&amp;quot;SP&amp;quot;, &amp;quot;MP&amp;quot;, &amp;quot;LP&amp;quot;, &amp;quot;XLP&amp;quot;};#set of project sizes : small, medium, large and major&lt;/p&gt;&#xA;&lt;p&gt;set PS within {P,S}; # Set of project-size combinations&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Parameters :&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;param ES{j in P}; # Earliest starting of the project&lt;/p&gt;&#xA;&lt;p&gt;param LF{j in P}; # Latest finishing of the project&lt;/p&gt;&#xA;&lt;p&gt;param Duration{j in P};# duration of project j&lt;/p&gt;&#xA;&lt;p&gt;param RDemand{s in S, r in RType}; # total number of required resource type r to be allocated to project j on any term within its duration&lt;/p&gt;&#xA;&lt;p&gt;param Av{r in RType, t in T}&amp;gt;=0; #avaialibility of each human resource type r at the period t&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Deicision variables :&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;var Act{j in P, t in T} binary; #=1 if the project j is executing durint period t and 0 otherwise&lt;/p&gt;&#xA;&lt;p&gt;var FinMax {j in P} integer;&lt;/p&gt;&#xA;&lt;p&gt;var Debut{j in P} integer; # starting date of the project j&lt;/p&gt;&#xA;&lt;p&gt;var Fin{j in P} integer; # Finishing date of the project j&lt;/p&gt;&#xA;&lt;p&gt;var Y{j in P, r in RType, t in T} integer;# number of human resource type r allocated to project j at period t&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints :&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to DurationConstraint {j in P}:&lt;/p&gt;&#xA;&lt;p&gt;sum{t in T} Act[j, t] = Duration[j];&lt;/p&gt;&#xA;&lt;p&gt;subject to AffectConstraint {r in RType, t in T}:&lt;/p&gt;&#xA;&lt;p&gt;sum {j in P, (j,s) in PS} RDemand[s,r]*Act[j,t]&amp;lt;= Av[r,t];&lt;/p&gt;&#xA;&lt;p&gt;subject to DemandConstraint {j in P, (j,s) in PS, (j, m) in PM, r in RType,t in T}:&lt;/p&gt;&#xA;&lt;p&gt;Y[j, r, t] =RDemand[s,m,r]*Act[j,t];&lt;/p&gt;&#xA;&lt;p&gt;subject to Max_Constraint{j in P, t in T}:&lt;/p&gt;&#xA;&lt;p&gt;t * Act[j, t] &amp;lt;= FinMax[j];&lt;/p&gt;&#xA;&lt;p&gt;subject to Define_Fin{j in P}:&lt;/p&gt;&#xA;&lt;p&gt;Fin[j] = FinMax[j];&lt;/p&gt;&#xA;&lt;p&gt;subject to ActConstraint {j in P}:&lt;/p&gt;&#xA;&lt;p&gt;(Fin[j]-Debut[j]) =(sum{t in T} Act[j,t])-1;&lt;/p&gt;&#xA;&lt;p&gt;subject to FinishConstraint {j in P, t in T: t &amp;gt; LF[j]}:&lt;/p&gt;&#xA;&lt;p&gt;Act[j,t]=0;&lt;/p&gt;&#xA;&lt;p&gt;subject to SConstraint {j in P, t in T: t &amp;lt; ES[j]}:&lt;/p&gt;&#xA;&lt;p&gt;Act[j,t]=0;&lt;/p&gt;&#xA;&lt;p&gt;subject to continuityConstraint {j in P, t in T: t &amp;gt;= 2}:&#xA;t &amp;lt;= Fin[j]  ==&amp;gt;  Act[j,t] &amp;gt;= Act[j,t-1];&lt;/p&gt;&#xA;" OwnerUserId="13115" LastEditorUserId="491" LastEditDate="2024-01-22T21:52:13.130" LastActivityDate="2024-01-22T21:52:13.130" Title="Replace the constraint using ==&gt; by a linear formulation" Tags="|linear-programming|cplex|linearization|scheduling|logical-constraints|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11557" PostTypeId="2" ParentId="11556" CreationDate="2024-01-22T17:06:13.883" Score="5" Body="&lt;p&gt;You want to enforce the logical implication&#xA;&lt;span class=&quot;math-container&quot;&gt;$$t \le \text{Fin}[j] \implies \text{Act}[j,t] \ge \text{Act}[j,t-1]$$&lt;/span&gt;&#xA;Equivalently, the contrapositive is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{Act}[j,t] &amp;lt; \text{Act}[j,t-1] \implies t &amp;gt; \text{Fin}[j]$$&lt;/span&gt;&#xA;Because Act is binary and Fin is integer, we can rewrite as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(\text{Act}[j,t] = 0 \land \text{Act}[j,t-1] = 1) \implies \text{Fin}[j] \le t-1$$&lt;/span&gt;&#xA;You can enforce this via a linear big-M constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{Fin}[j] - (t-1) \le M_{j,t}(1 + \text{Act}[j,t] - \text{Act}[j,t-1])$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2024-01-22T17:06:13.883" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11559" PostTypeId="1" CreationDate="2024-01-23T17:00:19.580" Score="1" ViewCount="64" Body="&lt;p&gt;I would like to formulate the following problem:&lt;/p&gt;&#xA;&lt;p&gt;Each state has multiple counties and each county has multiple municipalities. I have treatment cities and possible control cities (more possible control cities than treatment cities). I want to match each treatment city with the closest control cities (1:1) within the smallest administrative level possible.&lt;br /&gt;&#xA;So in the first iteration, we try to match each treated city to a control city within the same municipality so that the total distance of matches found is minimized. For the treated cities that could not be matched (as there was no possible control city in the same municipality), we repeat the step with possible control cities in the same county (second iteration). Finally, the remaining non-matching treated cities are matched with control cities in the same state (third iteration).&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, we restrict matches in each iteration to treat and control cities having the same urbanization status &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;. In the following, the assignment problem (&lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt;=treated, &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;=control) is shown without the iterative structure and the urbanization constraint. How can I adjust my formulation to take this into account? (I know how to code this but struggle to find the right formulation)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ex9F8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ex9F8.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13117" LastEditorUserId="36" LastEditDate="2024-01-23T17:42:05.070" LastActivityDate="2024-01-23T22:37:17.763" Title="iterative geographic assignment problem" Tags="|assignment-problem|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11560" PostTypeId="2" ParentId="11559" CreationDate="2024-01-23T20:17:02.123" Score="1" Body="&lt;p&gt;The urbanization part is easy. Fix &lt;span class=&quot;math-container&quot;&gt;$x_{vc}=0$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$(v,c)$&lt;/span&gt; combinations that do not satisfy the urbanization constraint (either by adding an equation or simply by not including those variables in the model).&lt;/p&gt;&#xA;&lt;p&gt;For the prioritization part, for each &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; define three (disjoint) sets. &lt;span class=&quot;math-container&quot;&gt;$M_v$&lt;/span&gt; is the set of control cities in the same municipality, &lt;span class=&quot;math-container&quot;&gt;$K_v$&lt;/span&gt; is the set of control cities in the same county, and &lt;span class=&quot;math-container&quot;&gt;$S_v$&lt;/span&gt; is the set of control cities in the same state. Rewrite your first constraint as &lt;span class=&quot;math-container&quot;&gt;$$\sum_v x_{vc} + y_c = 1 \quad\forall c$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$y_c$&lt;/span&gt; will equal 1 if &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; is unassigned and 0 if it is assigned. Now add the following constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x_{vc} + y_{c'} \le 1 \quad \forall v, c\in K_v, c'\in M_v$$&lt;/span&gt; and&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x_{vc} + y_{c'} \le 1 \quad \forall v, c\in S_v, c'\in M_v \cup K_v.$$&lt;/span&gt; The first says that you cannot assign &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; to a control &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; in the same county but not city if a there is an unassigned control in the same city. The second says that you cannot assign &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; to a control &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt; in the same state but not city or county if there is an unassigned control in either the city or county.&lt;/p&gt;&#xA;&lt;p&gt;I'm assuming here that out-of-state assignments are not allowed at all. If they are, you need one more constraint blocking out-of-state assignments when in-state assignments are possible.&lt;/p&gt;&#xA;&lt;p&gt;Note that this approach introduces a gaggle of sparse constraints. It is possible to alter them so that you add a smaller number of dense constraints, but I think most solvers prefer many sparse constraints to fewer dense constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;ADDENDUM&lt;/strong&gt; To address Rob's comment, I'll show what I have in mind for the &amp;quot;fewer, denser&amp;quot; option. Replace my first constraint with &lt;span class=&quot;math-container&quot;&gt;$$\sum_{c'\in M_v} y_{c'} \le \vert M_v \vert (1-x_{vc}) \quad \forall v, c\in K_v$$&lt;/span&gt; and the second with &lt;span class=&quot;math-container&quot;&gt;$$\sum_{c'\in M_v \cup K_v} y_{c'} \le \vert M_v \cup K_v \vert (1-x_{vc})\quad \forall v, c\in S_v.$$&lt;/span&gt; Note that the reduced set of constraints are not only denser but have a &amp;quot;big M&amp;quot; format and hence are likely looser.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2024-01-23T22:37:17.763" LastActivityDate="2024-01-23T22:37:17.763" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11561" PostTypeId="1" CreationDate="2024-01-24T11:49:41.067" Score="2" ViewCount="98" Body="&lt;p&gt;I am dealing with a benders decomposition problem, in which there are 100 sub-problems that need to be solved. During each iteration, 100 new optimal cuts will be added to the master problem. I would like to ask, as the number of iterations increases, There are a very large number of constraints in the master problem, which increases the solution time. Is there any way to deal with such a master problem?&lt;/p&gt;&#xA;" OwnerUserId="12244" LastEditorUserId="500" LastEditDate="2024-01-24T12:30:24.513" LastActivityDate="2024-01-29T06:35:20.167" Title="benders decomposition master problem scale large" Tags="|optimization|benders-decomposition|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11562" PostTypeId="1" AcceptedAnswerId="11564" CreationDate="2024-01-24T13:48:27.523" Score="5" ViewCount="173" Body="&lt;p&gt;Consider the simple problem of maximum likelihood estimation of the variance of a mean zero normal distribution. The expression to be minimised is:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$N \log{v}+\frac{1}{v}\sum_{n=1}^N{b_n^2},$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is the unknown variance, and &lt;span class=&quot;math-container&quot;&gt;$b_1,\dots,b_N$&lt;/span&gt; are the known observations.&lt;/p&gt;&#xA;&lt;p&gt;Obviously, this problem is trivial, but similar expressions appear in non-trivial problems, such as estimating the variance of shocks in a linear-Gaussian state space model. And in those other problems substituting in the optimal &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is less feasible.&lt;/p&gt;&#xA;&lt;p&gt;Simplifying even further, the question is the following:&lt;/p&gt;&#xA;&lt;p&gt;Is there a global optimizer (ideally supported by YALMIP) capable of finding the global minimum (&lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;) of the function:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\log{v}+\frac{1}{v}$$&lt;/span&gt;&#xA;for &lt;span class=&quot;math-container&quot;&gt;$v\in [c,d]$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$c\in(0,1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d\in(1,2)$&lt;/span&gt;, to ensure convexity. (Of course, any local optimizer like &lt;code&gt;fmincon&lt;/code&gt; will happily find the optimum, but while we know it is the global optimum in this trivial problem, in less trivial problems we do not.)&lt;/p&gt;&#xA;&lt;p&gt;Perhaps there is a trick for rewriting the problem?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Update: I have moved the multivariate version of this question to &lt;a href=&quot;https://or.stackexchange.com/questions/11588/global-optimizers-handling-minimization-of-an-expression-arising-from-the-likeli&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For the record, here is YALMIP's output on the original simple problem:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; v=sdpvar(1,1);&#xA;&amp;gt;&amp;gt; optimize([v&amp;gt;=0.9,v&amp;lt;=1.1],log(v)+1/v,sdpsettings('solver','mosek','verbose',1))&#xA;Warning: Solver not applicable (mosek does not support exponential cones)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Of course Mosek does support exponential cones, so this error message is wrong! I expect it's just the convexity issue. There's no problem with my install. &lt;code&gt;yalmiptest&lt;/code&gt; produces:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++&#xA;|                                     Test|    Status|    Solver|&#xA;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++&#xA;|                     Core functionalities|   Success|          |&#xA;|                  Linear programming (LP)|   Success|     MOSEK|&#xA;|               Quadratic programming (QP)|   Success|     MOSEK|&#xA;|     Second-order cone programming (SOCP)|   Success|     MOSEK|&#xA;|           Semidefinite programming (SDP)|   Success|     MOSEK|&#xA;|               Geometric programming (GP)|   Success|     MOSEK|&#xA;|              Nonlinear programming (NLP)|   Success|   FMINCON|&#xA;|                    Nonlinear SDP (NLSDP)|   Success|   FMINCON|&#xA;|       Exponential cone programming (ECP)|   Success|     MOSEK|&#xA;|                  Mixed-integer LP (MIQP)|   Success|     MOSEK|&#xA;|                  Mixed-integer QP (MIQP)|   Success|     MOSEK|&#xA;|              Mixed-integer SOCP (MISOCP)|   Success|     MOSEK|&#xA;|   Global nonconvex quadratic programming|   Success|    BMIBNB|&#xA;|             Global nonconvex programming|   Success|    BMIBNB|&#xA;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3830" LastEditorUserId="3830" LastEditDate="2024-01-29T18:12:08.053" LastActivityDate="2024-01-29T18:12:08.053" Title="Global optimizers handling minimization of expressions like $\log{v}+\frac{1}{v}$" Tags="|optimization|convex-optimization|disciplined-convex-programming|global-optimization|yalmip|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="11563" PostTypeId="2" ParentId="11561" CreationDate="2024-01-24T16:45:04.950" Score="0" Body="&lt;p&gt;Disclaimer: I've never actually done this myself. I would be tempted to list the subproblems in a circular queue. At each iteration, I would start solving subproblems with the next subproblem after the last one solved at the previous iteration, and continue solving only until a cut was generated or all subproblems had been solved. If all subproblems were solved without a new cut, I would declare victory. Otherwise, I would add the first new cut encountered, update the master solution, and repeat.&lt;/p&gt;&#xA;&lt;p&gt;So, for instance, if I had &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; subproblems and at generation &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; got a new cut from subproblem &lt;span class=&quot;math-container&quot;&gt;$N-k,$&lt;/span&gt; at generation &lt;span class=&quot;math-container&quot;&gt;$t+1$&lt;/span&gt; I would solve subproblems &lt;span class=&quot;math-container&quot;&gt;$N-k+1, N-k+2, \dots, N, 1, 2, 3, \dots$&lt;/span&gt; until I got a new cut.&lt;/p&gt;&#xA;&lt;p&gt;The reason I would try this is that solving all subproblems at each iteration and add all cuts found might result in the addition of cuts made redundant by other cuts. The one-at-a-time approach is guaranteed to work but not guaranteed to be faster than conventional Benders. It's just a gamble.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-24T16:45:04.950" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11564" PostTypeId="2" ParentId="11562" CreationDate="2024-01-24T19:07:59.900" Score="5" Body="&lt;p&gt;The logarithm is not a convex function, so even though the expression as a whole is convex on some subinterval &lt;span class=&quot;math-container&quot;&gt;$v \in [c,d]$&lt;/span&gt;, the expression is not in &lt;em&gt;disciplined convex form&lt;/em&gt; which might be why yalmip is failing (the error message looks like a software bug).&lt;/p&gt;&#xA;&lt;p&gt;If you want to cast it as disciplined convex program - which I would always recommend if possible - you will have to either transform the objective function somehow (any monotonic increasing mapping will preserve the global optimum), or make a variable substitution. One example of the latter is to substitute &lt;span class=&quot;math-container&quot;&gt;$v := \exp(u)$&lt;/span&gt; such that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$N \log{v}+\frac{1}{v}\sum_{n=1}^N{b_n^2} = N u + \exp(-u)\sum_{n=1}^N{b_n^2},$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;which is a disciplined convex expression in &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;. Will this work for your less trivial problems, or what exactly are different?&lt;/p&gt;&#xA;" OwnerUserId="198" LastEditorUserId="3830" LastEditDate="2024-01-26T15:07:41.117" LastActivityDate="2024-01-26T15:07:41.117" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11565" PostTypeId="1" CreationDate="2024-01-24T23:47:12.037" Score="0" ViewCount="25" Body="&lt;p&gt;I'm currently in the process of writing my bachelor's thesis and trying to deal with the theory behind the model in this paper &lt;a href=&quot;https://arxiv.org/abs/1610.00168&quot; rel=&quot;nofollow noreferrer&quot;&gt;Risk-calibrated Super-sparse Linear Integer Model&lt;/a&gt; (Berk Ustun and Cynthia Rudin).&lt;/p&gt;&#xA;&lt;p&gt;In this paper, the author stated that normal Cutting Plane Algorithm often &lt;strong&gt;stall&lt;/strong&gt; while solving a non-convex MINLP-Problem with an objective function (in easier form): &lt;span class=&quot;math-container&quot;&gt;$$ V(\lambda) = log(1 + exp(-\langle\lambda, y_i x_i \rangle) + C_0 \cdot \Vert \lambda \Vert_0$$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\lambda \in \mathcal{L}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathcal{L}\subset \mathbb{Z}^d$&lt;/span&gt; and users can specify for example &lt;span class=&quot;math-container&quot;&gt;$\lambda_j \in \{-5,\dots,5\},\forall j \in [d] $&lt;/span&gt;. I have read papers about the &lt;a href=&quot;https://hal.science/hal-01254856/document&quot; rel=&quot;nofollow noreferrer&quot;&gt;big-M-assumption&lt;/a&gt; and also have the idea of transforming the hard &lt;span class=&quot;math-container&quot;&gt;$\ell_0$&lt;/span&gt;-Norm into extra linear binary variables in the original MINLP-Problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$V(\lambda) = log(1 + exp(-\langle\lambda, y_i x_i \rangle) + C_0 \sum_{j = 1}^{d}\alpha_j$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$s.t. \lambda \in \mathcal{L}, \vert\lambda\vert \leq 5\cdot \alpha, \alpha \in \{0,1\} $$&lt;/span&gt;&#xA;Up to this point, I would expect that the MINLP is convex (since the objective function is now the sum of convex functions and the constraints are all linear), and by replacing the logistic loss function with a linear variable &lt;span class=&quot;math-container&quot;&gt;$l$&lt;/span&gt; and adding a new linear constraint &lt;span class=&quot;math-container&quot;&gt;$l \geq \hat{l}^k(\lambda)$&lt;/span&gt;, with &lt;span class=&quot;math-container&quot;&gt;$\hat{l}^k(\lambda)$&lt;/span&gt; as the cutting-plane approximation of the logistic loss with &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;-cuts, the approximated MILP would still be convex?&lt;/p&gt;&#xA;&lt;p&gt;I'm currently stuck at this point.&lt;/p&gt;&#xA;" OwnerUserId="13121" LastEditorUserId="36" LastEditDate="2024-01-24T23:51:51.330" LastActivityDate="2024-01-24T23:51:51.330" Title="Differences between non-convex and convex optimization problem with l0-Norm Regulization" Tags="|convex-optimization|nonconvex-programming|minlp|cutting-planes|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11566" PostTypeId="2" ParentId="11386" CreationDate="2024-01-25T03:13:19.273" Score="0" Body="&lt;p&gt;Variables: &lt;span class=&quot;math-container&quot;&gt;$\mathbf r_{u}, \mathbf r_{d},\mathbf q_{g}, \Delta, \mathbf c_{iing}, \mathbf c_{ij}, \mathbf s_{ij}, \mathbf p_{f}, \mathbf q_{f}, \mathbf p_{t}, \mathbf q_{t}, \mathbf S_f, \mathbf S_t, \mathbf D_{1}, \mathbf D_{2}, \mathbf D_{3}, \mathbf D_{4}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Known values: &lt;span class=&quot;math-container&quot;&gt;$\mathbf p_{g},\mathbf c_{iig}, \hat{\mathbf w}, \mathbf w$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Fixed coefficients: &lt;span class=&quot;math-container&quot;&gt;$\mathbf c_{ru}, \mathbf c_{rd}, \mathbf B_{g}, \mathbf{agc}, \mathbf C_{rp}, \dots$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now the model is as follows&#xA;&lt;a href=&quot;https://i.stack.imgur.com/dUPk9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dUPk9.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Take all the inequalities in the form of &lt;span class=&quot;math-container&quot;&gt;$g(\cdot)\leq0$&lt;/span&gt;. The Lagrange function is&#xA;&lt;a href=&quot;https://i.stack.imgur.com/0JkVF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0JkVF.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The dual problem is&#xA;&lt;a href=&quot;https://i.stack.imgur.com/qWAbi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qWAbi.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is anything wrong?&lt;/p&gt;&#xA;" OwnerUserId="13002" LastEditorUserId="13002" LastEditDate="2024-01-25T05:49:03.110" LastActivityDate="2024-01-25T05:49:03.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11567" PostTypeId="1" CreationDate="2024-01-25T11:14:30.627" Score="0" ViewCount="53" Body="&lt;p&gt;I am working on an optimization problem where I need to formulate a constraint that represents the total sales value under specific conditions. The challenge lies in creating an expression that involves bilinear terms, and I'm looking for guidance on whether there's a more efficient way to represent it.&lt;/p&gt;&#xA;&lt;h4&gt;Context and Conditions:&lt;/h4&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Item Purchase&lt;/strong&gt;: Each year, exactly one item is purchased.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Represented by variable &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;, the percentage of the item purchased in year &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$0 \leq y_i \leq 1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Item Sale&lt;/strong&gt;: Each year, the available items can be sold. The amount sold is a fixed percentage of all held items.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Represented by variable &lt;span class=&quot;math-container&quot;&gt;$z_{i,t}$&lt;/span&gt;, the percentage of an item sold in year &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; that was purchased in year &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$0 \leq z_{i,t} \leq 1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h4&gt;Current Expression:&lt;/h4&gt;&#xA;&lt;p&gt;The total amount sold at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is given by:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i} S_{i,t} \cdot \left( y_{i} - \sum_{k=i}^{t-1} z_{i,k} \right) \cdot z_{i,t}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$S_{i,t}$&lt;/span&gt; is the sale price of an item in year &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; that was purchased in year &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The term &lt;span class=&quot;math-container&quot;&gt;$\left( y_{i} - \sum_{k=i}^{t-1} z_{i,k} \right)$&lt;/span&gt; represents the amount of the item still available for sale at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, calculated by taking the initial percentage of the item purchased &lt;span class=&quot;math-container&quot;&gt;$y_{i}$&lt;/span&gt; and subtracting the cumulative percentage of the item sold in the previous years (from year &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to year &lt;span class=&quot;math-container&quot;&gt;$t-1$&lt;/span&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;Additional Constraints:&lt;/h4&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;To ensure the amount sold does not exceed the amount purchased:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum_{i=1}^{t} z_{i,t} \leq y_{i}, \quad \forall i$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;For a uniform sale percentage across all items:&#xA;&lt;span class=&quot;math-container&quot;&gt;$z_{i,t} = \alpha_{t}, \quad \forall i$&lt;/span&gt; where the item is available for sale at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;&#xA;and &lt;span class=&quot;math-container&quot;&gt;$\alpha_{t}$&lt;/span&gt; is an auxiliary variable.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h4&gt;Binary Variables:&lt;/h4&gt;&#xA;&lt;p&gt;The model includes binary variables to enforce logical conditions, such as allowing either a sale or a purchase in a given year. However, the focus here is on the expression mentioned above. The problem falls under Mixed-Integer Quadratic Programming (MIQP), which might be challenging to solve.&lt;/p&gt;&#xA;&lt;h4&gt;Question:&lt;/h4&gt;&#xA;&lt;p&gt;Is there a more streamlined way to represent this expression? For ease of understanding, I have expanded this expression below for the first three years, assuming a matrix &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; representing sale prices:&lt;/p&gt;&#xA;&lt;h4&gt;Sale Price Matrix:&lt;/h4&gt;&#xA;&lt;p&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{bmatrix}&#xA;S_{1,1} &amp;amp; S_{1,2} &amp;amp; S_{1,3} \\&#xA;0 &amp;amp; S_{2,2} &amp;amp; S_{2,3} \\&#xA;0 &amp;amp; 0 &amp;amp; S_{3,3} &#xA;\end{bmatrix}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h4&gt;Expanded Expression for Years ( t = 1, 2, 3 ):&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Year &lt;span class=&quot;math-container&quot;&gt;$t = 1$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\text{Total Sales Value at } t = 1: S_{1,1} \cdot y_{1} \cdot z_{1,1}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Year &lt;span class=&quot;math-container&quot;&gt;$t = 2$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\text{Total Sales Value at } t = 2: S_{1,2} \cdot \left( y_{1} - z_{1,1} \right) \cdot z_{1,2} + S_{2,2} \cdot y_{2} \cdot z_{2,2}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Year &lt;span class=&quot;math-container&quot;&gt;$t = 3$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$\text{Total Sales Value at } t = 3: S_{1,3} \cdot \left( y_{1} - z_{1,1} - z_{1,2} \right) \cdot z_{1,3} + S_{2,3} \cdot \left( y_{2} - z_{2,2} \right) \cdot z_{2,3} + S_{3,3} \cdot y_{3} \cdot z_{3,3}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13085" LastActivityDate="2024-01-25T11:14:30.627" Title="Better formulation of bilinear terms" Tags="|mixed-integer-programming|linearization|nonlinear-programming|quadratic-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11568" PostTypeId="1" CreationDate="2024-01-25T16:21:14.377" Score="0" ViewCount="43" Body="&lt;p&gt;I've been studying a paper where the authors employ the ADMM in a way that has left me somewhat perplexed. The paper focuses on addressing a robust principal component analysis (RPCA) problem, enhanced with an additional prior. This problem is formulated as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\underset{L,E}{\min} f_1(L) + f_2(L) + g(E) \quad \text{s.t.} \quad X = L + E$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To maintain focus on the central query, I've simplified the problem to avoid any unnecessary details. In this equation, &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; represents a constant matrix. All functions are convex.&lt;/p&gt;&#xA;&lt;p&gt;To separate the variables in the objective function, the authors introduced auxiliary variables &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;, reformulating the problem as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\underset{Z,E,Y}{\min} f_1(Z) + f_2(Y) + g(E) \quad \text{s.t.} \quad X = L + E, Z = L, Y = L$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subsequently, they presented the augmented Lagrange function as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;L(Z,E,Y,\Lambda_1,\Lambda_2, \Lambda_3) &amp;amp;= f_1(Z) + f_2(Y) + g(E) \\&#xA;&amp;amp;+ \langle L+E-X, \Lambda_1 \rangle + \lambda_1 \| L+E-X \| \\&#xA;&amp;amp;+ \langle Y - L, \Lambda_2 \rangle + \lambda_2 \| Y - L \| \\&#xA;&amp;amp;+ \langle Z - L, \Lambda_3 \rangle + \lambda_3 \| Z - L \|.&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&#xA;The paper details an iterative approach to solve the subproblems for &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;, followed by updating the dual variables.&lt;/p&gt;&#xA;&lt;p&gt;However, a point of confusion arises here. While &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; appear to be decoupled, &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;-&lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;-&lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; remain coupled. In other words, the variables are &amp;quot;latently coupled&amp;quot;. The authors assert that since &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; are decoupled, it's feasible to iteratively solve for &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt;, and then address the &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt;-subproblem (which is quite easy as what remains about &lt;span class=&quot;math-container&quot;&gt;$L$&lt;/span&gt; are norms and inner products). My problems are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is their solution reasonable, or does it lean more towards a heuristic approach?&lt;/li&gt;&#xA;&lt;li&gt;Could there be a more efficient method to tackle this problem?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="12949" LastEditorUserId="491" LastEditDate="2024-01-25T16:42:19.247" LastActivityDate="2024-01-25T16:42:19.247" Title="Can ADMM be applied to &quot;latently coupled&quot; variables?" Tags="|optimization|convex-optimization|machine-learning|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11569" PostTypeId="1" CreationDate="2024-01-25T17:31:05.510" Score="2" ViewCount="91" Body="&lt;p&gt;I am solving a 2D bin packing problem, however, there is an additional constraint where some items must be in the same bin. The problem is at industry scale (up to 1000 items and ~200 bins of different sizes) so I am looking to write a heuristic for it as ILP solvers won't be useful here.&lt;/p&gt;&#xA;&lt;p&gt;For example, the 1000 items really represent 500 orders where each order consists of 2 items, and the items in an order must go in the same bin.&lt;/p&gt;&#xA;&lt;p&gt;Has anyone come across a bin packing problem/heuristic with a similar constraint?&lt;/p&gt;&#xA;" OwnerUserId="13124" LastEditorUserId="491" LastEditDate="2024-01-25T18:31:27.177" LastActivityDate="2024-02-25T09:04:30.537" Title="2D bin packing where some items must be packed in the same bin?" Tags="|combinatorial-optimization|heuristics|packing|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11570" PostTypeId="2" ParentId="11569" CreationDate="2024-01-25T18:13:57.503" Score="0" Body="&lt;p&gt;You could try approaching this similarly to a cutting stock problem. The master problem will contain one binary variable for each of a fixed set of feasible bin loadings (where feasibility here includes the requirement that eith both halves or neither half of an order be in the loading). Master problem constraints include not using more loadings for each bin size than there are bins available and ensuring that for each order the number of selected loadings including that order equals 1.&lt;/p&gt;&#xA;&lt;p&gt;Then you need a subproblem to generate feasible loadings. This would be a 2D knapsack problem with the side constraint that you not include only half of an order.&lt;/p&gt;&#xA;&lt;p&gt;The solution process starts with you finding an initial set of loadings to populate the master problem. Relax the master problem to an LP, solve and use the shadow prices (dual variables) as the rewards for including orders in the loading-generating subproblem. Generate a new loading, add to the master problem, rinse and repeat. When you fail to find a new loading, restore the integrality restrictions in the master problem and solve it.&lt;/p&gt;&#xA;&lt;p&gt;If you have trouble generating the initial set of loadings, you might populate the master with a few to start, relax the &amp;quot;include every order once&amp;quot; constraint to &amp;quot;include very order at most once&amp;quot;, change the objective to minimizing the number of excluded orders, and apply the iteration scheme until  you have enough loadings that a feasible solution covering every order exists. Then revert to the original objective and forge ahead.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-25T18:13:57.503" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11571" PostTypeId="1" AcceptedAnswerId="11572" CreationDate="2024-01-25T19:54:38.707" Score="0" ViewCount="29" Body="&lt;p&gt;I'd like to ask about if there's an existing type of problems that fits to my question. (Searching it for a while but cannot get to the point)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Basic Problem Description:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Given a sequenced list (order fixed) of elements: &lt;code&gt;[4,5,10,5,2,4,5,3...]&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;I need to group them into several bins (like the img below) so that the sum of each group fits in certain constraints -- i.e. lower, upper bound&lt;/p&gt;&#xA;&lt;p&gt;The objective is to maximize the total return &lt;code&gt;V = SUM(v_i)&lt;/code&gt; of all groups -- each group will have value &lt;code&gt;v_i&lt;/code&gt; depends on the sum of all its sub-elements.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RlBmG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RlBmG.png&quot; alt=&quot;illustration of grouping&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Since the total number of groups is undefined, how to formulate this problem?&lt;/li&gt;&#xA;&lt;li&gt;Is there an existing type of OP or MIP problem like this to refer to?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Advanced Version&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;An additional requirement for the basic version of the question is, the center of some bins/groups need to locate at a serious of fixed location -- say, one need to center at the 5th element, another need to center at the 30th element, etc.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there a proper way to formulate it?&lt;/li&gt;&#xA;&lt;li&gt;Again, references will be appreciated.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13126" LastActivityDate="2024-01-25T21:36:27.693" Title="Grouping of a list of elements in fixed order to maximize the total return of all the groups" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|packing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11572" PostTypeId="2" ParentId="11571" CreationDate="2024-01-25T20:29:49.183" Score="2" Body="&lt;p&gt;You can formulate this as a shortest path problem in a directed acyclic network.  Each node corresponds to the start of a new bin.  The first element is the source node, and you will introduce a dummy sink node.  Each arc from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$i&amp;lt;j$&lt;/span&gt;) corresponds to a bin with items &lt;span class=&quot;math-container&quot;&gt;$\{i,i+1,\dots,j-1\}$&lt;/span&gt;, and the arc weight is &lt;span class=&quot;math-container&quot;&gt;$-v\left(\sum_{k=i}^{j-1} a_k\right)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$a_k$&lt;/span&gt; is the value of element &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; in your input list; the minus sign is because your original problem is maximization.  The presence or absence of an arc in the network is determined by the lower and upper bounds on the sum of a group.  The problem is to find a shortest path from source to sink.  The additional requirement in the advanced version can be enforced by omitting some arcs.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-01-25T21:36:27.693" LastActivityDate="2024-01-25T21:36:27.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11573" PostTypeId="1" AcceptedAnswerId="11580" CreationDate="2024-01-26T07:20:51.493" Score="0" ViewCount="85" Body="&lt;p&gt;There is a fulfillment problem in the e-commerce logistics field, where the fulfillment of each order is composed of a main transport (from City A to City B, referred to as a route) and an end transport (from City B to Site c, also referred to as a route).&lt;/p&gt;&#xA;&lt;p&gt;To solve for the optimal fulfillment days for main transport carriers on each route and for each end transport carrier on each route, in order to maximize the fulfillment accuracy of all orders.&lt;/p&gt;&#xA;&lt;p&gt;In constructing the mathematical model, we can introduce three sets of binary variables. If the main transport carrier has a fulfillment day of &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; on route &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$y_{it}$&lt;/span&gt; = 1. If the end transport carrier has a fulfillment day of &lt;span class=&quot;math-container&quot;&gt;$t'$&lt;/span&gt; on route &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$z_{jt'}$&lt;/span&gt; = 1. For each order, which is comprised of route &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and route &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; fulfilled by the main transport carrier and end transport carrier respectively, with a fulfillment day of &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, we have &lt;span class=&quot;math-container&quot;&gt;$x_{ijt}$&lt;/span&gt; = 1.&lt;/p&gt;&#xA;&lt;p&gt;For example, if the trajectory of a certain order is City A - City B - Site c, with a total fulfillment day of 4, then possible combinations for the fulfillment days of the main transport and end transport could be: 1 day for main transport and 3 days for end transport; 3 days for main transport and 1 day for end transport; or 2 days for both main and end transport.&lt;/p&gt;&#xA;&lt;p&gt;The possible formulation is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\max \sum\limits_{i,j}{\sum\limits_{t}{a_{ijt}x_{ijt}}}$$&lt;/span&gt;&#xA;s.t.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{i,j}{\sum\limits_{t}{b_{ijt}x_{ijt}}} \geq M$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{t}{x_{ijt}} = 1 \;\;\;\; \forall i,j$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{t}{y_{it}} = 1 \;\;\;\; \forall i$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum\limits_{t}{z_{jt}} = 1 \;\;\;\; \forall j$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;if &lt;span class=&quot;math-container&quot;&gt;$y_{it} = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z_{jt'}=1$&lt;/span&gt; then &lt;span class=&quot;math-container&quot;&gt;$x_{ij,t+t'}=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We can use the variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; to represent the overall accuracy, but how can we establish the relationship between variable &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and auxiliary variables &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="12326" LastEditorUserId="500" LastEditDate="2024-01-28T01:16:20.887" LastActivityDate="2024-01-28T01:16:20.887" Title="How to represent &quot;if $y_{it} = 1$ and $z_{jt'}=1$ then $x_{ij,t+t'}=1$&quot;" Tags="|linearization|logical-constraints|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11574" PostTypeId="2" ParentId="11569" CreationDate="2024-01-26T08:55:17.533" Score="0" Body="&lt;p&gt;@prubin suggested an approach based on a Dantig-Wolfe decomposition. Here is another idea based on a Benders decomposition.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Solve the one-dimensional version of the problem. In this case, each order might be merged into a single item which size is the sum of the sizes of each item from the order. It is a smaller and easier to solve one-dimensional bin packing problem. You can try the various classical methods to solve it (assignment MILP model, arc-flow MILP model, Dantzig-Wolfe decomposition, heuristics).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Check if the one-dimensional bins generated are feasible with the two-dimensional constraints. That is, solve multiple two-dimensional packing problems with a single bin where the goal is to pack all input items in the bin.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If all checks pass, then stop&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Otherwise, for each bin which check failed&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Either add a cut (constraint) to the one-dimensional problem to forbid the corresponding assignment. This will likely take a very long time to converge on large problems&lt;/li&gt;&#xA;&lt;li&gt;Or increase the size of the orders assigned to the bin in the one-dimensional packing problem such that this assignment just becomes infeasible&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2024-01-26T08:55:17.533" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11575" PostTypeId="2" ParentId="11562" CreationDate="2024-01-26T14:20:14.320" Score="0" Body="&lt;p&gt;There are various ways we do this in practice. For instance, assuming we treat &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; as a variable (and not as a function), &lt;span class=&quot;math-container&quot;&gt;$1/v$&lt;/span&gt; is piecewise convex/concave so it can be relaxed using an outer approximation and a secant. The logarithm is concave so we can use a secant. We then do branch-and-bound to find the global minimum of the expression, tightening the relaxations in every new node. We can also use various acceleration techniques such as adding cuts, domain reduction, and so on. If there are other expressions are present, sometimes we will combine terms/functions to get more favourable forms.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; is a function, we can use factorable decomposition where we set &lt;span class=&quot;math-container&quot;&gt;$c_1: w_1=v$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$c_2: w_2=1/v$&lt;/span&gt; and then e.g. do &lt;span class=&quot;math-container&quot;&gt;$\log(w_1)+w_2$&lt;/span&gt;, subject to &lt;span class=&quot;math-container&quot;&gt;$c_1,c_2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If we have more information the solver can choose to exploit more things, e.g. if &lt;span class=&quot;math-container&quot;&gt;$v&amp;gt;0$&lt;/span&gt; (or &lt;span class=&quot;math-container&quot;&gt;$w_2&amp;gt;0$&lt;/span&gt; for a function) we don't need to represent the concave part for the fraction, or we can use a nonlinear relaxation for it. Since it's convex in that domain, the function is its own relaxation.&lt;/p&gt;&#xA;&lt;p&gt;Any global solver you use will most likely do any one of these things (or something else in the solver's toolbox), some of them better than others.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2024-01-26T14:20:14.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11576" PostTypeId="1" AcceptedAnswerId="11577" CreationDate="2024-01-26T17:56:01.470" Score="2" ViewCount="63" Body="&lt;p&gt;I have a dataset that contains IDs along with their corresponding minimum and maximum values.&lt;/p&gt;&#xA;&lt;p&gt;Here’s a sample of the data:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;id    min_value max_value&#xA;   &amp;lt;fct&amp;gt;     &amp;lt;int&amp;gt;     &amp;lt;int&amp;gt;&#xA;   1             1         6&#xA;   2             8        12&#xA;   3            15        19&#xA;   4            22        27&#xA;   5            32        36&#xA;   6            39        43&#xA;   7            45        49&#xA;   8            51        56&#xA;   9            57        60&#xA;   10           63        66&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My goal is to group these IDs based on two conditions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;For a given group, the difference between the minimum and maximum values of group IDs should exceed a certain threshold.&lt;/li&gt;&#xA;&lt;li&gt;Even if two IDs satisfy the first condition, they cannot be in the same group if the difference between their min and max values falls within the same multiple of a given integer.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;To illustrate with an example:&lt;/p&gt;&#xA;&lt;p&gt;For instance, let’s say the threshold is 7, and the given integer is 24. IDs 1 and 3 could be grouped together based on the first condition because the difference between their values (15-6) is 9, which is greater than 7. However, according to the second condition, they cannot be grouped together because both are less than 24. It will go on similarly for the other multiples of 24. Say if there are two values such as 32 &amp;amp; 41 etc., they can't be in the same group.&lt;/p&gt;&#xA;&lt;p&gt;Only keeping the difference 24 is also not logical. Because, then say 22 and 33 can't be grouped.&lt;/p&gt;&#xA;&lt;p&gt;I have successfully written down the 1st constraint. But struggling to accommodate the 2nd.&lt;/p&gt;&#xA;&lt;p&gt;Here is a sample code in R:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;library(ompr)&#xA;library(ompr.roi)&#xA;library(ROI.plugin.glpk)&#xA;diff &amp;lt;- 36&#xA;&#xA;#dummy data&#xA;structure(list(id = structure(1:25, levels = c(&amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;3&amp;quot;, &#xA;&amp;quot;4&amp;quot;, &amp;quot;5&amp;quot;, &amp;quot;6&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;9&amp;quot;, &amp;quot;10&amp;quot;, &amp;quot;11&amp;quot;, &amp;quot;12&amp;quot;, &amp;quot;13&amp;quot;, &amp;quot;14&amp;quot;, &amp;quot;15&amp;quot;, &#xA;&amp;quot;16&amp;quot;, &amp;quot;17&amp;quot;, &amp;quot;18&amp;quot;, &amp;quot;19&amp;quot;, &amp;quot;20&amp;quot;, &amp;quot;21&amp;quot;, &amp;quot;22&amp;quot;, &amp;quot;23&amp;quot;, &amp;quot;24&amp;quot;, &amp;quot;25&amp;quot;), class = &amp;quot;factor&amp;quot;), &#xA;    min_value = c(1L, 8L, 15L, 22L, 32L, 39L, 45L, 51L, 57L, &#xA;    63L, 70L, 80L, 87L, 93L, 99L, 105L, 111L, 117L, 123L, 129L, &#xA;    135L, 142L, 152L, 159L, 165L), max_value = c(6L, 12L, 19L, &#xA;    27L, 36L, 43L, 49L, 56L, 60L, 66L, 75L, 84L, 91L, 98L, 104L, &#xA;    108L, 114L, 121L, 128L, 132L, 139L, 147L, 156L, 162L, 166L&#xA;    )), class = c(&amp;quot;tbl_df&amp;quot;, &amp;quot;tbl&amp;quot;, &amp;quot;data.frame&amp;quot;), row.names = c(NA, &#xA;-25L))-&amp;gt; slot_id_min_max&#xA;&#xA;&#xA;nrow(slot_id_min_max)-&amp;gt; number_of_groups&#xA;&#xA;# Define the model&#xA;model &amp;lt;- MIPModel() %&amp;gt;%&#xA;  # Binary variable x[i,j], 1 if id i is in group j&#xA;  add_variable(x[i, j], i = 1:number_of_groups, j = 1:number_of_groups, type = &amp;quot;binary&amp;quot;) %&amp;gt;%&#xA;  # Each id must be in exactly one group&#xA;  add_constraint(sum_expr(x[i, j], j = 1:number_of_groups) == 1, i = 1:number_of_groups)&#xA;&#xA;# Constraint: no two element ids in the same group can have a max min difference less than 'diff'&#xA;&#xA;for (i in 1:(number_of_groups - 1)) {&#xA;  for (j in (i + 1):number_of_groups) {&#xA;    if ((slot_id_min_max&lt;span class=&quot;math-container&quot;&gt;$min_value[j] - slot_id_min_max$&lt;/span&gt;max_value[i] &amp;lt; diff)) {&#xA;      model &amp;lt;- model %&amp;gt;%&#xA;        add_constraint(x[i, g] + x[j, g] &amp;lt;= 1, g = 1:number_of_groups)&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;&#xA;# Objective: minimize the number of groups&#xA;model &amp;lt;- model %&amp;gt;%&#xA;  set_objective(sum_expr(x[i, j], i = 1:number_of_groups, j = 1:number_of_groups), &amp;quot;min&amp;quot;)&#xA;&#xA;# Solve the model&#xA;result &amp;lt;- solve_model(model, with_ROI(solver = &amp;quot;glpk&amp;quot;, verbose = TRUE))&#xA;&#xA;# Get the solution&#xA;batch_merging_solution &amp;lt;- result %&amp;gt;% get_solution(x[i, j]) %&amp;gt;% filter(value&amp;gt;0)&#xA;&#xA;print(batch_merging_solution)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Any help or nudge is appreciated!&lt;/p&gt;&#xA;" OwnerUserId="5532" LastEditorUserId="500" LastEditDate="2024-01-26T18:48:04.130" LastActivityDate="2024-01-26T19:03:32.590" Title="How to Group IDs Based on the Difference of Each ID’s Min and Max Value?" Tags="|mixed-integer-programming|modeling|combinatorial-optimization|r|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11577" PostTypeId="2" ParentId="11576" CreationDate="2024-01-26T18:47:09.643" Score="3" Body="&lt;p&gt;Sounds like shift scheduling, where each id is a shift with start time equal to the min value and end time equal to the max value.  Your first condition requires at least a certain amount of rest between shifts.&#xA;Your second condition prevents more than one shift on the same day, and you can enforce it by imposing&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{ig} + x_{jg} \le 1 \quad \text{for all $g$ and all $i&amp;lt;j$ such that $\lfloor M_i/24 \rfloor = \lfloor m_j/24 \rfloor$},$$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$m_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$M_i$&lt;/span&gt; are the min and max, respectively, for id &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-01-26T19:03:32.590" LastActivityDate="2024-01-26T19:03:32.590" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11578" PostTypeId="1" CreationDate="2024-01-27T17:19:41.860" Score="2" ViewCount="83" Body="&lt;p&gt;I am trying to find the invertible matrix &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; satisfying:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$v_t'= MA_tM^{-1}v_t$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For a dataset of observed transformations &lt;span class=&quot;math-container&quot;&gt;$(v_t',A_t,v_t)_t$&lt;/span&gt;. Note, there is a different linear transformation &lt;span class=&quot;math-container&quot;&gt;$A_t$&lt;/span&gt; for each sample tuple.&lt;/p&gt;&#xA;&lt;p&gt;Basically I have two isomorphic vector spaces &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt;, where transformations on &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; are known but the space itself is not observed. I am trying to describe transformations on &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; from observing the transformations &lt;span class=&quot;math-container&quot;&gt;$A_t$&lt;/span&gt; on the space &lt;span class=&quot;math-container&quot;&gt;$U$&lt;/span&gt; and their effects on &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; through observed vectors &lt;span class=&quot;math-container&quot;&gt;$(v_t', v_t)_t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For now I am trying to solve it through Least squares:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$M = \underset{X}{argmin} \sum_t||v_t' - XA_tX^{-1}v_t||^2_2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But I was wondering if this is a known problem or if a closed solution exists.&lt;/p&gt;&#xA;&lt;p&gt;I would also be interested in any factorizations of &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; that could make it simpler, maybe orthogonal.&lt;/p&gt;&#xA;" OwnerUserId="13134" LastEditorUserId="13134" LastEditDate="2024-01-28T22:15:37.133" LastActivityDate="2024-02-22T13:50:46.367" Title="Optimizing for an unknown conjugation matrix" Tags="|optimization|linear-algebra|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11579" PostTypeId="1" CreationDate="2024-01-27T18:38:47.600" Score="1" ViewCount="36" Body="&lt;p&gt;I wasn't sure if I should put this question here, but I guess is as good as any.&lt;/p&gt;&#xA;&lt;p&gt;When we have a sequential process that has a number of tasks, were each task requires the previous one to be completed, and we have as many machines as tasks, and all machines execute each task in the same time (no difference in task time across machines, but each task time might be different), and can function simultaneously, but requiring subproducts from the previous machine in the process.&lt;/p&gt;&#xA;&lt;p&gt;The working time to generate a result/product will be more or less the maximum task time in the process among machines, at least after a cycle.&lt;/p&gt;&#xA;&lt;p&gt;But, If one machine could be assigned to each next task after finishing the previous one, that is, if each machine is assigned the whole process instead of a single task, the total time per process or product will be the sum of times for the tasks divided by the number of machines.&lt;/p&gt;&#xA;&lt;p&gt;Because in the second case there is no idle time, the second case is always the optimal time to complete processes, and the first one can only be as good if all the tasks have the same required time.&lt;/p&gt;&#xA;&lt;p&gt;Assuming no cost of switching, starting task, etc. Is this correct?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I started reading The Wealth of Nations by Adam Smith were it encourages the division of labor, based on 3 things:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Less requirements in skill and faster learning in workers for simpler tasks.&lt;/li&gt;&#xA;&lt;li&gt;Time saved by avoiding switching tasks.&lt;/li&gt;&#xA;&lt;li&gt;Simpler tasks increase focus on themselves and facilitate the creation of technology.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;But, if we ignore these points, when the workers are very skilled, and there are no switching costs, it is better optimized to assign each worker to the whole process instead of individual subtasks. As I just shown in my previous question.&lt;/p&gt;&#xA;&lt;p&gt;I just wanted to make this clear that actually, formally, division of labor is only beneficial because of certain constraints but its not the optimal strategy, although it might be the most efficient in a sense. Seems counterintuitive.&lt;/p&gt;&#xA;" OwnerUserId="13135" LastEditorUserId="13135" LastEditDate="2024-01-27T19:41:19.417" LastActivityDate="2024-01-27T19:41:19.417" Title="Execution time of sequential asynchronous process and division of labour" Tags="|scheduling|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11580" PostTypeId="2" ParentId="11573" CreationDate="2024-01-28T00:14:12.673" Score="1" Body="&lt;p&gt;You want to linearize the logical relationship&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(y_{it} = 1 \land z_{jt'} = 1) \iff x_{ij,t+t'} = 1.$$&lt;/span&gt;&#xA;Equivalently, you want to linearize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{it} z_{jt'} = x_{ij,t+t'}.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;See&#xA;&lt;a href=&quot;https://or.stackexchange.com/questions/37/how-to-linearize-the-product-of-two-binary-variables&quot;&gt;How to linearize the product of two binary variables?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;In your updated question, you want to linearize the logical relationship&#xA;&lt;span class=&quot;math-container&quot;&gt;$$(y_{it} = 1 \land z_{jt'} = 1) \implies x_{ij,t+t'} = 1.$$&lt;/span&gt;&#xA;Rewriting in conjunctive normal form somewhat automatically yields a linear constraint:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(y_{it} \land z_{jt'}) \implies x_{ij,t+t'} \\&#xA;\lnot (y_{it} \land z_{jt'}) \lor x_{ij,t+t'} \\&#xA;\lnot y_{it} \lor \lnot z_{jt'} \lor x_{ij,t+t'} \\&#xA;(1-y_{it}) + (1-z_{jt'}) + x_{ij,t+t'} \ge 1 \\&#xA;y_{it} + z_{jt'} - x_{ij,t+t'} \le 1 \\&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-01-28T00:56:58.953" LastActivityDate="2024-01-28T00:56:58.953" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11581" PostTypeId="1" CreationDate="2024-01-28T15:01:59.917" Score="1" ViewCount="96" Body="&lt;p&gt;i have a pretty basic question regarding column generation. I have the following scheduling problem i would like to solve with column generation:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\min\sum_{t}^{}\sum_{s}^{}slack_{ts}\\&#xA;&amp;amp;\sum_{i}^{}x_{its}=Demand_{ts}+slack_{ts}\forall t,s\\&#xA;&amp;amp;\sum_{s}^{}x_{its}\le 1\forall i,t\\&#xA;&amp;amp;x_{its}\in\left\{ 0,1 \right\}\\&#xA;&amp;amp;Demand_{ts},slack_{ts}\ge 0 \forall t,s\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would decompose the problem in the following master and subproblem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;MP: \min\sum_{t}^{}\sum_{s}^{}slack_{ts}\\&#xA;&amp;amp;\sum_{i}^{}\sum_{r}^{}\lambda_{ir}x^{r}_{its}=Demand_{ts}+slack_{ts}\forall t,s\\&#xA;&amp;amp;\sum_{r}^{}\lambda_{ir}=1 \forall i\\&#xA;&amp;amp;\lambda_{ir}\in\left\{ 0,1 \right\}\\&#xA;\\&#xA;&amp;amp;SP: \min 1-\sum_{t}^{}\sum_{s}^{}\pi_{ts}x_{its}-\mu_i\\&#xA;&amp;amp;\sum_{s}^{}x_{its}\le 1\forall i,t\\&#xA;&amp;amp;x_{its}\in\left\{ 0,1 \right\}\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My question now is whether I have formulated the subproblem (especially the objective function) correctly? I often read that the reduced costs are calculated with &lt;span class=&quot;math-container&quot;&gt;$c-yA$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;=duals and &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; = constraint matrix), but i dont have any cost vector. Is a &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; appropriate then?&lt;/p&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="500" LastEditDate="2024-02-02T20:49:57.770" LastActivityDate="2024-02-02T20:49:57.770" Title="Help with formulating the objective function of my subproblem" Tags="|linear-programming|column-generation|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11582" PostTypeId="2" ParentId="11581" CreationDate="2024-01-28T19:25:04.633" Score="2" Body="&lt;p&gt;Your original problem is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;\sum_t \sum_s \text{slack}_{ts} \\&#xA;&amp;amp;\text{subject to} &amp;amp;\sum_i x_{its} + \text{slack}_{ts} &amp;amp; = \text{Demand}_{ts} &amp;amp;&amp;amp;\forall t,s\\&#xA;&amp;amp;&amp;amp;\sum_s x_{its} &amp;amp;\le 1 &amp;amp;&amp;amp;\forall i,t\\&#xA;&amp;amp;&amp;amp;x_{its} &amp;amp;\in\left\{ 0,1 \right\} &amp;amp;&amp;amp;\forall i,t,s\\&#xA;&amp;amp;&amp;amp;\text{slack}_{ts} &amp;amp;\ge 0 &amp;amp;&amp;amp;\forall t,s&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the Dantzig-Wolfe reformulation, introduce &lt;span class=&quot;math-container&quot;&gt;$\lambda_{ir} \ge 0$&lt;/span&gt; and substitute &lt;span class=&quot;math-container&quot;&gt;$x_{its} = \sum_r x_{its}^r \lambda_{ir}$&lt;/span&gt; in the (objective and) complicating constraints to obtain the master problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;\sum_t \sum_s \text{slack}_{ts} \\&#xA;&amp;amp;\text{subject to} &amp;amp;\sum_i \sum_r x_{its}^r \lambda_{ir} + \text{slack}_{ts} &amp;amp; = \text{Demand}_{ts} &amp;amp;&amp;amp;\forall t,s &amp;amp;&amp;amp;\text(\text{$\pi_{ts}$ free})\\&#xA;&amp;amp;&amp;amp;\sum_r \lambda_{ir} &amp;amp;= 1 &amp;amp;&amp;amp;\forall i &amp;amp;&amp;amp;\text(\text{$\mu_i$ free})\\&#xA;&amp;amp;&amp;amp;\lambda_{ir} &amp;amp;\in\mathbb{Z}^+ &amp;amp;&amp;amp;\forall i,r\\&#xA;&amp;amp;&amp;amp;\text{slack}_{ts} &amp;amp;\ge 0 &amp;amp;&amp;amp;\forall t,s&#xA;\end{align}&lt;/span&gt;&#xA;The reduced cost of &lt;span class=&quot;math-container&quot;&gt;$\lambda_{ir}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$0-\sum_{t,s} \pi_{ts} x_{its}^r - \mu_i$&lt;/span&gt;,&#xA;so the subproblem for block &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;0-\sum_{t,s} \pi_{ts} x_{its} - \mu_i \\&#xA;&amp;amp;\text{subject to} &amp;amp;\sum_s x_{its} &amp;amp;\le 1 &amp;amp;&amp;amp;\forall t\\&#xA;&amp;amp;&amp;amp;x_{its} &amp;amp;\in\left\{ 0,1 \right\} &amp;amp;&amp;amp;\forall t,s&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;When you solve the LP relaxation of the restricted master problem, be sure to impose &lt;span class=&quot;math-container&quot;&gt;$\lambda_{ir} \ge 0$&lt;/span&gt; (instead of &lt;span class=&quot;math-container&quot;&gt;$\lambda_{ir} \in [0,1]$&lt;/span&gt;), as discussed in &lt;a href=&quot;https://or.stackexchange.com/questions/608/variable-bounds-in-column-generation&quot;&gt;Variable bounds in column generation&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-01-28T19:30:22.870" LastActivityDate="2024-01-28T19:30:22.870" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11583" PostTypeId="1" AcceptedAnswerId="11584" CreationDate="2024-01-28T21:23:42.003" Score="3" ViewCount="753" Body="&lt;p&gt;I'm encountering a puzzling issue with SciPy's &lt;code&gt;minimize&lt;/code&gt; function in a constrained optimization problem. My objective is to optimize a piecewise linear function with an equality constraint. However, the solution provided by the algorithm is different from what I logically expect. I would appreciate guidance on identifying the cause of this discrepancy and how to rectify it. Here's the relevant section of my Python code:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;from scipy.optimize import minimize&#xA;&#xA;def f(x):&#xA;    if 0 &amp;lt;= x &amp;lt;= 150:&#xA;        return x&#xA;    elif x &amp;gt;= 150:&#xA;        return 150&#xA;&#xA;def objective(x):&#xA;    x1, x2 = x&#xA;    return f(x1 + 350) + f(x2)&#xA;&#xA;def constraint(x):&#xA;    return x[0] + x[1] - 300&#xA;&#xA;x0 = [0, 900]&#xA;bounds = [(0, 300), (0, 300)]&#xA;con = {'type': 'eq', 'fun': constraint}&#xA;&#xA;result = minimize(objective, x0, bounds=bounds, constraints=con, options={'disp': True})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The output is&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Optimization terminated successfully    (Exit mode 0) Current function value: 300 Iterations: 1 Function evaluations: 3 Gradient evaluations: 1 (array([  0., 300.]), 300)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The optimizer returns &lt;code&gt;[0, 300]&lt;/code&gt; as the solution with a function value of 300. However, I was expecting &lt;code&gt;[300, 0]&lt;/code&gt; to be the correct solution. This is based on the logic that &lt;code&gt;f(x1 + 350)&lt;/code&gt; should max out first before &lt;code&gt;x2&lt;/code&gt; is increased, given the nature of the piecewise function &lt;code&gt;f(x)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13140" LastEditorUserId="500" LastEditDate="2024-01-28T23:30:20.613" LastActivityDate="2024-01-28T23:30:20.613" Title="Scipy.optimize can't get correct answer when objective is Piecewise Linear Function and Equality Constraint" Tags="|optimization|python|global-optimization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11584" PostTypeId="2" ParentId="11583" CreationDate="2024-01-28T22:17:01.770" Score="6" Body="&lt;p&gt;You are trying to minimize a concave function, and &lt;code&gt;minimize&lt;/code&gt; finds only a local minimum.  To find a global minimum, use one of the methods under &amp;quot;Global optimization&amp;quot; here: &lt;a href=&quot;https://docs.scipy.org/doc/scipy/reference/optimize.html#&quot; rel=&quot;noreferrer&quot;&gt;https://docs.scipy.org/doc/scipy/reference/optimize.html#&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2024-01-28T22:17:01.770" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11586" PostTypeId="2" ParentId="11561" CreationDate="2024-01-29T06:35:20.167" Score="1" Body="&lt;p&gt;There are two possible directions that worth trying:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Avoiding repetitively solving the master problem:&lt;/strong&gt; Instead of solving the master problem from the scratch each time cuts are added, you can use the &lt;code&gt;callback&lt;/code&gt; function provided by the modern solvers to search on a single branch-and-bound tree. A &lt;a href=&quot;https://orinanobworld.blogspot.com/2011/10/benders-decomposition-then-and-now.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;blog&lt;/a&gt; by @prubin, and &lt;a href=&quot;https://www.gurobi.com/documentation/current/examples/tsp_py.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;code&lt;/a&gt; using &lt;code&gt;callback&lt;/code&gt; for traveling sales man problem (TSP), can be useful.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reducing the number of cuts in the master problem:&lt;/strong&gt; When each of your subproblem corresponds to a scenario in stochastic programming, the 100 cuts can be aggregated by summing up the left hand sides and right hands sides, forming a single cut. Though the number of cut in each iteration is reduced from 100 to one, the master problem become weaker (poor lower bound). A trade-off is needed between the multi-cut and the single-cut implementation.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8718" LastActivityDate="2024-01-29T06:35:20.167" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11587" PostTypeId="2" ParentId="11539" CreationDate="2024-01-29T13:02:03.933" Score="0" Body="&lt;p&gt;Used the approach suggested in the comment to solve this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;element_ids &amp;lt;- c(1, 2, 3, 4, 5, 6, 7, 9, 10, 12)&#xA;diff &amp;lt;- 5&#xA;element_ids &amp;lt;- sort(element_ids)&#xA;&#xA;# Initialize an empty list to hold the groups&#xA;groups &amp;lt;- list()&#xA;&#xA;&#xA;&#xA;# While there are still elements left to assign&#xA;while (length(element_ids) &amp;gt; 0) {&#xA;  # The first element is the smallest one&#xA;  first_element &amp;lt;- element_ids[1]&#xA;  &#xA;  # Find all elements that are less than or equal to first_element + diff&#xA;  group &amp;lt;-&#xA;    element_ids[element_ids &amp;lt;= first_element + diff]&#xA;  &#xA;  # Add this group to the list of groups&#xA;  groups[[length(groups) + 1]] &amp;lt;- group&#xA;  &#xA;  # Remove the elements in this group from element_ids&#xA;  element_ids &amp;lt;- setdiff(element_ids, group)&#xA;}&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;groups&#xA;&#xA;[[1]]&#xA;[1] 1 2 3 4 5 6&#xA;&#xA;[[2]]&#xA;[1]  7  9 10 12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It is quite fast and gives &amp;quot;good enough&amp;quot; answer. Though the approach suggested by prubin also helped.&lt;/p&gt;&#xA;" OwnerUserId="5532" LastActivityDate="2024-01-29T13:02:03.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11588" PostTypeId="1" CreationDate="2024-01-29T18:11:41.950" Score="2" ViewCount="159" Body="&lt;p&gt;I am interested in converting the following optimisation problem into a form that an exponential cone and/or SDP solver such as MOSEK can handle. This is a multivariate version of the question I previously asked &lt;a href=&quot;https://or.stackexchange.com/questions/11562/global-optimizers-handling-minimization-of-expressions-like-logv-frac1v&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We are given the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$A\in\mathbb{R}^{M\times N}$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$N\ge M$&lt;/span&gt;), a full rank matrix.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b\in\mathbb{R}^M$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$C\in\mathbb{R}^{N\times K}$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$N\ge K$&lt;/span&gt;), a full rank matrix.&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$d\in\mathbb{R}^M$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;(If it makes the problem any easier, you may assume that all elements of &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; are either &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, with precisely one &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; per row.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z\in\mathbb{R}^K$&lt;/span&gt; is our optimisation variable.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$u:=Cz+d$&lt;/span&gt; and let &lt;span class=&quot;math-container&quot;&gt;$D\in\mathbb{R}^{N\times N}$&lt;/span&gt; be the diagonal matrix with diagonal &lt;span class=&quot;math-container&quot;&gt;$\exp(u_1),\dots,\exp(u_N)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We want to choose &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to minimize:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\log{\det{\left(ADA^\top\right)}}+b^\top{\left(ADA^\top\right)}^{-1}b.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$N=M$&lt;/span&gt;, then this problem is easy, as the objective simplifies to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\log{{\left(\det{A}\right)}^2}+\sum_{n=1}^N{u_n}+b^\top A^{-\top} D^{-1} A^{-1} b,$$&lt;/span&gt;&#xA;which is a standard exponential cone problem. YALMIP + MOSEK seems to handle it fine:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;z=sdpvar(3,1); C=randn(10,3); d=randn(10,1); u=C*z+d; A=randn(4,10); b=randn(4,1); InvAb2=(A\b).^2;&#xA;optimize([],sum(u)+sum(InvAb2.*exp(-u)),sdpsettings('solver','mosek','verbose',1))&#xA;...&#xA;info: 'Successfully solved (MOSEK-CONE)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;My question is whether we can convert the objective into a form MOSEK (or similar) can handle when &lt;span class=&quot;math-container&quot;&gt;$N&amp;gt;M$&lt;/span&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first term can be handled using the formula for the determinant &lt;a href=&quot;https://math.stackexchange.com/questions/4384890/determinant-of-a-matrix-in-the-form-of-x-sigma-x/4384974#4384974&quot;&gt;here&lt;/a&gt;. This implies (using notation from &lt;a href=&quot;https://en.wikipedia.org/wiki/Cauchy%E2%80%93Binet_formula&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, but with sets in bold):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\det{\left(ADA^\top\right)}=\sum_{\textbf{S} \in \binom{[N]}{M}} {\left[\det(A_{[M],\textbf{S}})^2\exp{\sum_{s \in \textbf{S}}{u_s}}\right]},$$&lt;/span&gt;&#xA;so &lt;span class=&quot;math-container&quot;&gt;$\log{\det{\left(ADA^\top\right)}}$&lt;/span&gt; can be written as a &lt;span class=&quot;math-container&quot;&gt;$\operatorname{logsumexp}$&lt;/span&gt; expression.&lt;/p&gt;&#xA;&lt;p&gt;Replacing the second term in the original objective with a dummy exponential, this seems to work fine:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;z=sdpvar(3,1); C=randn(10,3); d=randn(10,1); u=C*z+d; A=randn(4,10); b=randn(4,1); S=nchoosek(1:10,4); logdetADATerms=sdpvar(size(S,1),1);&#xA;for s = 1 : size(S,1); logdetADATerms(s)=log(det(A(:,S(s,:)))^2)+sum(u(S(s,:))); end;&#xA;optimize([],logsumexp(logdetADATerms)+sum(exp(-u)),sdpsettings('solver','mosek','verbose',1))&#xA;...&#xA;info: 'Successfully solved (MOSEK-CONE)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But of course this dummy exponential is not the original second term (&lt;span class=&quot;math-container&quot;&gt;$b^\top{\left(ADA^\top\right)}^{-1}b$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Idea 1:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;One idea to tackle the second term I had was to introduce a new auxiliary optimization variable &lt;span class=&quot;math-container&quot;&gt;$f\in\mathbb{R}^N$&lt;/span&gt;, with the constraint &lt;span class=&quot;math-container&quot;&gt;$Af=b$&lt;/span&gt;. Then the objective is equivalent to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\log{\det{\left(ADA^\top\right)}}+\sum_{n=1}^N{f_n^2 \exp{(-u_n)}}.$$&lt;/span&gt;&#xA;Perhaps unsurprisingly given the product term, this does not work though.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;z=sdpvar(3,1); f=sdpvar(10,1); C=randn(10,3); d=randn(10,1); u=C*z+d; A=randn(4,10); b=randn(4,1); S=nchoosek(1:10,4); logdetADATerms=sdpvar(size(S,1),1);&#xA;for s = 1 : size(S,1); logdetADATerms(s)=log(det(A(:,S(s,:)))^2)+sum(u(S(s,:))); end;&#xA;optimize([A*f==b],logsumexp(logdetADATerms)+sum(f.*f.*exp(-u)),sdpsettings('solver','mosek','verbose',1))&#xA;Warning: Solver not applicable (mosek does not support multi-term monomial equalities)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note though that with a (wrong!) modified objective without the &lt;code&gt;exp(-u)&lt;/code&gt; it will solve:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;z=sdpvar(3,1); f=sdpvar(10,1); C=randn(10,3); d=randn(10,1); u=C*z+d; A=randn(4,10); b=randn(4,1); S=nchoosek(1:10,4); logdetADATerms=sdpvar(size(S,1),1);&#xA;for s = 1 : size(S,1); logdetADATerms(s)=log(det(A(:,S(s,:)))^2)+sum(u(S(s,:))); end;&#xA;optimize([A*f==b],logsumexp(logdetADATerms)+sum(f.*f),sdpsettings('solver','mosek','verbose',1))&#xA;...&#xA;info: 'Successfully solved (MOSEK-CONE)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Idea 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Another idea I had to handle the second term was to combine the expression for the inverse of a matrix in terms of its minors, with the Cauchy-Binet formula. This produce a linear combination of exponentials, divided by the determinant we already found. See the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;z=sdpvar(3,1); C=randn(10,3); d=randn(10,1); u=C*z+d; A=randn(4,10); b=randn(4,1); S=nchoosek(1:10,4); logdetADATerms=sdpvar(size(S,1),1);&#xA;for s = 1 : size(S,1); logdetADATerms(s)=log(det(A(:,S(s,:)))^2)+sum(u(S(s,:))); end;&#xA;T=nchoosek(1:10,3); logdetbbTerms=sdpvar(size(T,1),1); for t = 1 : size(T,1); bbTerm=0; for m1 = 1 : 4; L=setdiff(1:4,m1); for m2 = 1 : 4; R=setdiff(1:4,m2); bbTerm=bbTerm+b(m1)*b(m2)*(-1)^(m1+m2)*det(A(L,T(t,:)))*det(A(R,T(t,:))); end; end; assert( bbTerm &amp;gt; 0 ); logdetbbTerms(t)=log(bbTerm)+sum(u(T(t,:))); end;&#xA;optimize([],logsumexp(logdetADATerms)+exp(logsumexp(logdetbbTerms)-logsumexp(logdetADATerms)),sdpsettings('solver','mosek','verbose',1))&#xA;...&#xA;info: 'Convexity requirements not met (MOSEK-CONE)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It is easy to produce a convex relaxation of this problem though by placing the logsumexp into constraints. This gives:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;z=sdpvar(3,1); C=randn(10,3); d=randn(10,1); u=C*z+d; A=randn(4,10); b=randn(4,1); S=nchoosek(1:10,4); logdetADATerms=sdpvar(size(S,1),1);&#xA;for s = 1 : size(S,1); logdetADATerms(s)=log(det(A(:,S(s,:)))^2)+sum(u(S(s,:))); end;&#xA;T=nchoosek(1:10,3); logdetbbTerms=sdpvar(size(T,1),1); for t = 1 : size(T,1); bbTerm=0; for m1 = 1 : 4; L=setdiff(1:4,m1); for m2 = 1 : 4; R=setdiff(1:4,m2); bbTerm=bbTerm+b(m1)*b(m2)*(-1)^(m1+m2)*det(A(L,T(t,:)))*det(A(R,T(t,:))); end; end; assert( bbTerm &amp;gt; 0 ); logdetbbTerms(t)=log(bbTerm)+sum(u(T(t,:))); end;&#xA;logdetADA=sdpvar(1,1); logbb=sdpvar(1,1);&#xA;optimize([logsumexp(logdetADATerms)&amp;lt;=logdetADA,logsumexp(logdetbbTerms)&amp;lt;=logbb],logdetADA+exp(logbb-logdetADA),sdpsettings('solver','mosek','verbose',1))&#xA;value( logdetADA-logsumexp(logdetADATerms) )&#xA;value( logbb-logsumexp(logdetbbTerms) )&#xA;...&#xA;             info: 'Successfully solved (MOSEK-CONE)'&#xA;          problem: 0&#xA;ans =&#xA;      0.56829&#xA;ans =&#xA;   7.9628e-09&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So MOSEK can handle this convex relaxation, but it is not equivalent to the original problem in general, as the bound is not tight. (With these random coefficients, it appears to be tight over half the time at least.)&lt;/p&gt;&#xA;&lt;p&gt;However, even if this was always tight, this would not really be a viable approach. This tiny problem ends up with 669 constraints, 331 cones and 1328 scalar variables. Plausible problems have &lt;span class=&quot;math-container&quot;&gt;$M\approx 400$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N\approx 1600$&lt;/span&gt;. This results in around &lt;span class=&quot;math-container&quot;&gt;${10}^{389}$&lt;/span&gt; variables!&lt;/p&gt;&#xA;&lt;p&gt;So perhaps my question ought to be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Can we can convert the objective into a form MOSEK (or similar) can handle when &lt;span class=&quot;math-container&quot;&gt;$N&amp;gt;M$&lt;/span&gt; with only polynomial in &lt;span class=&quot;math-container&quot;&gt;$N,M,K$&lt;/span&gt; variables?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Additional note:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the special case in which &lt;span class=&quot;math-container&quot;&gt;$C=I$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$d=0$&lt;/span&gt;, the first order condition states that the diagonal of the matrix &lt;span class=&quot;math-container&quot;&gt;$A^\top {\left(ADA^\top\right)}^{-1} {\left( ADA^\top - b b^\top \right)} {\left(ADA^\top\right)}^{-1} A$&lt;/span&gt; is zero.&lt;/p&gt;&#xA;" OwnerUserId="3830" LastEditorUserId="3830" LastEditDate="2024-02-01T15:22:54.707" LastActivityDate="2024-02-01T15:22:54.707" Title="Global optimizers handling minimization of an expression arising from the likelihood of a multivariate normal" Tags="|optimization|convex-optimization|disciplined-convex-programming|global-optimization|yalmip|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11590" PostTypeId="1" AcceptedAnswerId="11591" CreationDate="2024-01-30T08:11:52.920" Score="3" ViewCount="221" Body="&lt;p&gt;I have a constraint as follows in my MILP model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{e} (a_1(e) - a_2(e))^2 \leq M&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where, &lt;span class=&quot;math-container&quot;&gt;$a_1(e)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_2(e)$&lt;/span&gt; are binary variables. Would you please guide me how can I find the equivalent convex constraints to put in the model and solve it by GAMS/CPLEX?&lt;/p&gt;&#xA;" OwnerUserId="13146" LastEditorUserId="500" LastEditDate="2024-01-30T13:28:57.807" LastActivityDate="2024-01-30T13:28:57.807" Title="Convex equivalent of a constraint" Tags="|mixed-integer-programming|modeling|cplex|linearization|gams|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11591" PostTypeId="2" ParentId="11590" CreationDate="2024-01-30T09:02:24.840" Score="3" Body="&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$a_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$a_2$&lt;/span&gt; are binary, then &lt;span class=&quot;math-container&quot;&gt;$y=(a_1 - a_2)^2$&lt;/span&gt; is also binary.&lt;/p&gt;&#xA;&lt;p&gt;More precisely:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;a_1 \wedge a_2 \implies \neg y \quad \equiv \quad \neg(a_1 \wedge a_2) \vee \neg y   \quad \equiv \quad  \neg a_1 \vee \neg a_2 \vee \neg y\\&#xA;\neg a_1 \wedge a_2 \implies  y \quad \equiv \quad \neg(\neg a_1 \wedge a_2) \vee  y   \quad \equiv \quad   a_1 \vee \neg a_2 \vee  y\\&#xA;a_1 \wedge \neg a_2 \implies  y \quad \equiv \quad \neg(a_1 \wedge \neg a_2) \vee  y   \quad \equiv \quad  \neg a_1 \vee  a_2 \vee  y\\&#xA;\neg a_1 \wedge \neg a_2 \implies \neg y \quad \equiv \quad \neg(\neg a_1 \wedge \neg a_2) \vee \neg y   \quad \equiv \quad   a_1 \vee  a_2 \vee \neg y&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So you can replace your constraint with&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_e y(e) \le M \\&#xA;$$&lt;/span&gt;&#xA;and linear equations&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;1-a_1(e)+1-a_2(e)+1-y(e) &amp;amp;\ge 1 \\&#xA;a_1(e)+1-a_2(e)+y(e) &amp;amp;\ge 1 \\&#xA;1-a_1(e)+a_2(e)+y(e) &amp;amp;\ge 1 \\&#xA;a_1(e)+a_2(e)+1-y(e) &amp;amp;\ge 1 \\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2024-01-30T09:02:24.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11592" PostTypeId="2" ParentId="11590" CreationDate="2024-01-30T09:03:35.380" Score="2" Body="&lt;p&gt;Introduce &lt;span class=&quot;math-container&quot;&gt;$d(e) \in \{0, 1\}$&lt;/span&gt;(or &lt;span class=&quot;math-container&quot;&gt;$[0, 1]$&lt;/span&gt;), &lt;span class=&quot;math-container&quot;&gt;$\forall e$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;-d(e) \leq a_1(e) - a_2(e) &amp;amp;\leq d(e)\\&#xA;\sum_e d(e) &amp;amp;\leq M&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Notice that we only need &lt;span class=&quot;math-container&quot;&gt;$d(e) \geq (a_1(e)-a_2(e))^2$&lt;/span&gt; (rather than &amp;quot;&lt;span class=&quot;math-container&quot;&gt;$=$&lt;/span&gt;&amp;quot;). So logically we only need&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left((a_1 \wedge \neg a_2) \vee(\neg a_1 \wedge a_2)\right) \Rightarrow d&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="4569" LastEditorUserId="4569" LastEditDate="2024-01-30T09:11:51.450" LastActivityDate="2024-01-30T09:11:51.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11593" PostTypeId="1" CreationDate="2024-01-30T09:22:12.893" Score="1" ViewCount="74" Body="&lt;p&gt;I stumbled  upon this video while using OR-Tools CP-SAT solver&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=lmy1ddn4cyw&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=lmy1ddn4cyw&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;At around 12:10, the part of multithreaded solvers starts. I understand these solvers are distributed among the available cores (threads) of a CPU. At around 13:20, there is a slide of information shared among these workers / solvers.&lt;/p&gt;&#xA;&lt;p&gt;It displays&lt;/p&gt;&#xA;&lt;p&gt;• Propogate new variable bounds&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Including fixed variables&lt;/li&gt;&#xA;&lt;li&gt;Including literals&lt;/li&gt;&#xA;&lt;li&gt;Including objective&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Q: does this mean that, assuming 8 workers, when a worker, say the solver at thread 0, finds a new better solution, it informs threads 1-7, which subsequently use this as an upper bound for their new solutions' objective value?&lt;/p&gt;&#xA;&lt;p&gt;In addition, what other examples of information are shared that make this parallel computing &amp;quot;work&amp;quot;? E.g. fixed variables?&lt;/p&gt;&#xA;" OwnerUserId="12983" LastEditorUserId="981" LastEditDate="2024-01-30T10:11:45.697" LastActivityDate="2024-01-30T20:17:45.870" Title="Information shared among workers in OR-tools CP-SAT" Tags="|or-tools|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11594" PostTypeId="2" ParentId="11593" CreationDate="2024-01-30T09:38:47.353" Score="2" Body="&lt;p&gt;If you enable logging (parameter log_search_progress:true), the solver displays these stats at the end of the log:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Solutions (2)         Num   Rank        &#xA;            'fixed':    1  [2,2]                   &#xA;  'fj_long_default':    1  [1,1]   &#xA;&#xA;Objective bounds          Num                                                                          &#xA;       'initial_domain':    1                                                                          &#xA;  'objective_lb_search':    1                                                                          &#xA;                                                                                                       &#xA;Solution repositories    Added  Queried  Ignored  Synchro            &#xA;  'feasible solutions':     14      373        0       13            &#xA;        'lp solutions':      2       13        0        2            &#xA;                'pump':     24       12                                                                &#xA;                                                                                                       &#xA;Improving bounds shared    Num                                                                         &#xA;            'default_lp':    1                                                                         &#xA;                 'fixed':    9                                                                         &#xA;   'objective_lb_search':   80                                                                         &#xA;               'probing':   75                                                                         &#xA;         'quick_restart':  200                                                                         &#xA;   'quick_restart_no_lp':  155                                                                         &#xA;                                                                                                       &#xA;Clauses shared            Num                                                                          &#xA;           'default_lp':   15                                                                          &#xA;                'fixed':    9                                                                          &#xA;                'no_lp':    2                                                                          &#xA;  'objective_lb_search':   39                                                                          &#xA;              'probing':   31                                                                          &#xA;         'pseudo_costs':    4                                                                          &#xA;        'quick_restart':   12                                                                          &#xA;  'quick_restart_no_lp':    6                                                                          &#xA;        'reduced_costs':    2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here is what it shows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;solutions&lt;/strong&gt; : solutions found by workers. They are used by LNS workers, LS workers and the incumbent value is used by all workers.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;objective bounds&lt;/strong&gt; : an improving lower bound of the objective (when minimizing).&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;lp solutions&lt;/strong&gt; and &lt;strong&gt;pump&lt;/strong&gt; : These are LP values for each variables created either during search (when the simplex finds a optimal relaxed solution), and by the feasibility pump worker.  Can are used by the RINS and RENS LNS workers.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;improving bounds shared&lt;/strong&gt; : These are shared among workers. They represent reduced domains, and fixed variables.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;clauses shared&lt;/strong&gt; : These are root node binary clauses learned by workers. They are shared among workers.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There are subtleties all around (LNS workers cannot prove anything beyond finding a new solution, so they can only import information). But this is the gist of it.&lt;/p&gt;&#xA;&lt;p&gt;We also share the basic state of the global search like termination.&lt;/p&gt;&#xA;" OwnerUserId="981" LastEditorUserId="981" LastEditDate="2024-01-30T20:17:45.870" LastActivityDate="2024-01-30T20:17:45.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11595" PostTypeId="1" CreationDate="2024-01-30T11:12:53.480" Score="0" ViewCount="63" Body="&lt;p&gt;I am currently trying to solve an MILP in Gurobi. Unfortunately, Gurobi does not support non-linear functions and I would like to do the following. I currently have the following constraint. It calculates the residual power of a machine &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; is a parameter. Currently the relationship is linear:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$degneration_{jt}=1-\alpha\cdot age_{jt}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But I would like to model such a progression&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f(x)=e^{-x}$$&lt;/span&gt;&#xA;and would like to use a linear approximation for this. How would I have to model something like this, unfortunately I have no idea.&lt;/p&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="2556" LastEditDate="2024-01-30T15:47:05.237" LastActivityDate="2024-01-30T15:47:05.237" Title="Formulation of a stepwise linear approximation" Tags="|mixed-integer-programming|modeling|linearization|approximation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11596" PostTypeId="1" CreationDate="2024-01-30T12:39:07.440" Score="0" ViewCount="64" Body="&lt;p&gt;I would like to create a rota that repeats every 28 days and adheres to the usual rules. These include the minimum/maximum number of consecutive working days and the break days. I have created a model that adheres perfectly to these rules within the period, but has problems with the transitions from &lt;span class=&quot;math-container&quot;&gt;$t=28$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$t=1$&lt;/span&gt;. How do I need to adjust my constraints to make it work?&#xA;These are my constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{d=t-6}^{t}\sum_{k\in K}^{}x_{idk}\le 6\quad\forall i\in I,~t\in \left\{ 7,\ldots,T \right\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{d=t+1}^{t+4}y_{id}\ge 4\cdot(y_{i(t+1)}-y_{it})\quad\forall i\in I,~t\in \left\{ 1,\ldots,\mid T\mid -4\right\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$1+y_{it}\ge y_{i(t-1)}+y_{is}&#xA;        \quad\forall i\in I, s\in \left\{ t+1,\ldots,t+2 \right\},t\in\left\{ 2,\ldots,\mid T\mid-2 \right\}$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="12086" LastEditorUserId="12086" LastEditDate="2024-01-30T17:51:44.903" LastActivityDate="2024-02-29T20:02:10.250" Title="Scheduling: Connecting the end and the beginning of the planning horizon" Tags="|linear-programming|constraint|scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11597" PostTypeId="2" ParentId="11595" CreationDate="2024-01-30T12:54:28.243" Score="1" Body="&lt;p&gt;One approximation possible is to use the tangents of &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;. Assuming you are minimizing &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt;, introduce a new variable &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to approximate &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; over a given set &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and use constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z &amp;amp;\ge f'(a)(x-a)+f(a)\quad &amp;amp;\forall a \in A \\&#xA;&amp;amp;= -e^{-a}(x-a)+e^{-a} \quad &amp;amp;\forall a \in A\\&#xA;&amp;amp;=-e^{-a}x+e^{-a}(1+a) \quad &amp;amp;\forall a \in A&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2024-01-30T12:54:28.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11598" PostTypeId="2" ParentId="11115" CreationDate="2024-01-30T16:00:45.790" Score="0" Body="&lt;p&gt;Thank you Erwin Kalvelagen and Zayenz for the detailed and insightful responses. I was able to get the model coded in the .NET version of Google OR Tools, I'm pasting that below.&lt;/p&gt;&#xA;&lt;p&gt;One peculiarity was that the optimization for the individuals time slots had to be minimized for it to work - &lt;code&gt;model.Minimize(indTimeSlotVars);&lt;/code&gt;. I had expected this to be use &amp;quot;Maximize&amp;quot; based on the model, but that ends up assigning all teams to time slot one. I may be missing something still, but this way works.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    // Model.&#xA;    var model = new CpModel();&#xA;&#xA;    // Data&#xA;    int[,] m =&#xA;    {&#xA;        { 1, 0, 0, 0, 0, 1 }, // 1&#xA;        { 0, 0, 1, 0, 0, 0 }, // 2&#xA;        { 0, 0, 1, 0, 1, 0 }, // 3&#xA;        { 0, 0, 0, 0, 1, 1 }, // 4&#xA;        { 0, 0, 1, 0, 0, 0 }, // 5&#xA;        { 1, 0, 1, 0, 0, 0 }, // 6&#xA;        { 0, 0, 0, 0, 0, 1 }, // 7&#xA;        { 0, 1, 0, 1, 0, 0 }, // 8&#xA;        { 0, 0, 0, 0, 0, 0 }, // 9&#xA;        { 1, 1, 0, 0, 1, 0 }, // 10&#xA;        { 1, 1, 0, 0, 1, 1 }, // 11&#xA;        { 0, 0, 0, 0, 1, 1 }, // 12&#xA;        { 1, 0, 0, 0, 0, 1 }, // 13&#xA;        { 0, 1, 1, 1, 0, 0 }, // 14&#xA;        { 1, 1, 0, 0, 0, 0 }, // 15&#xA;        { 0, 0, 0, 0, 0, 0 }, // 16&#xA;        { 1, 0, 1, 0, 1, 1 }, // 17&#xA;        { 0, 0, 0, 1, 0, 0 }, // 18&#xA;        { 1, 0, 0, 1, 0, 0 }, // 19&#xA;        { 0, 0, 1, 0, 1, 0 }, // 20&#xA;    };&#xA;&#xA;    // Variables.&#xA;    int[] individuals = Enumerable.Range(0, 20).ToArray();&#xA;    int[] teams = Enumerable.Range(0, 6).ToArray();&#xA;    int[] timeSlots = Enumerable.Range(0, 3).ToArray();&#xA;&#xA;    // x - 1 if meeting of team t takes place at time slot s, else 0&#xA;    var x = new IntVar[teams.Length, timeSlots.Length];&#xA;    foreach (var t in teams)&#xA;    foreach (var s in timeSlots)&#xA;        x[t, s] = model.NewIntVar(0, 1,$&amp;quot;team time slots[{t},{s}]&amp;quot;);&#xA;&#xA;    // y - 1 if individual i has meetings at time slot s, 0 otherwise&#xA;    var y = new IntVar[individuals.Length, timeSlots.Length];&#xA;    foreach (var i in individuals)&#xA;    foreach (var s in timeSlots)&#xA;        y[i, s] = model.NewIntVar(0, 1, $&amp;quot;individual time slots[{i},{s}]&amp;quot;);&#xA;&#xA;    // each team meets exactly one time&#xA;    foreach (var t in teams)&#xA;        model.AddLinearConstraint(LinearExpr.Sum(timeSlots.Select(s =&amp;gt; x[t, s])), 1L, 1L);&#xA;&#xA;    //individual must have at least one team meeting at the given time slot to attend&#xA;    foreach (var i in individuals)&#xA;    foreach (var s in timeSlots)&#xA;        model.Add(&#xA;            new BoundedLinearExpression(&#xA;                y[i, s],&#xA;                LinearExpr.Sum(teams.Select(t =&amp;gt; m[i, t] * x[t, s])),&#xA;                false));&#xA;&#xA;    // maximize number of times individuals meet&#xA;    var indTimeSlotVars = LinearExpr.NewBuilder();&#xA;    foreach (var i in individuals)&#xA;    foreach (var s in timeSlots)&#xA;        indTimeSlotVars.Add(y[i, s]);&#xA;    model.Minimize(indTimeSlotVars);&#xA;&#xA;    var solver = new CpSolver();&#xA;    var cpSolverStatus = solver.Solve(model);&#xA;    Console.WriteLine($&amp;quot;Solver status: {cpSolverStatus}&amp;quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12657" LastActivityDate="2024-01-30T16:00:45.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11599" PostTypeId="2" ParentId="11596" CreationDate="2024-01-30T19:12:56.620" Score="0" Body="&lt;p&gt;You can take time indexes mod &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; to make it work. Rewrite the first constraint as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{d=t-6}^t \,\sum_{k\in K} x_{i,d\bmod T,k} \le 6 \quad \forall i\in I, t\in \lbrace 1,\dots, T\rbrace.$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So, for example, for &lt;span class=&quot;math-container&quot;&gt;$T=28$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$t=1$&lt;/span&gt; and each &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt; the left side contains &lt;span class=&quot;math-container&quot;&gt;$$x_{i,23,k} + x_{i,24,k}+\cdots + x_{i,28,k} + x_{i,1,k}.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-30T19:12:56.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11602" PostTypeId="1" AcceptedAnswerId="11607" CreationDate="2024-01-30T23:19:36.463" Score="1" ViewCount="114" Body="&lt;p&gt;I would like to model the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$B \le \alpha \implies \sum_i W(i) \ge \beta$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$B$&lt;/span&gt; a continuous variable, &lt;span class=&quot;math-container&quot;&gt;$W(i)$&lt;/span&gt; binary variables, &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt; a real constant number, &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; an integer constant number&lt;/p&gt;&#xA;&lt;p&gt;I could do this by introducing a new binary variable &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; and requiring&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$B \le \alpha \implies Z = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Z =1 \implies \sum_i W(i) \ge \beta$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;My question is, is there a possibility of avoiding the introduction of &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastEditorUserId="500" LastEditDate="2024-01-31T00:36:56.037" LastActivityDate="2024-01-31T22:44:03.243" Title="How to model the following Constraint" Tags="|mixed-integer-programming|modeling|logical-constraints|integer-variable|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="11603" PostTypeId="1" CreationDate="2024-01-30T23:31:41.090" Score="1" ViewCount="87" Body="&lt;p&gt;I have a problem that can be represented as an optimization problem.&#xA;Sometimes, solver engines report infeasible depending on the parameters I have at hand.&#xA;The root cause is numeric ranges.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Problem parameters consist of a set of nodes and edges. Each edge is bidirectional and there could be several edges between any two nodes.&lt;/p&gt;&#xA;&lt;p&gt;Each edge has two numbers associated with it.  Before explaining what these two numbers mean, let me explain what is concrete input parameter into the problem which varies and objective.&lt;/p&gt;&#xA;&lt;p&gt;Problem input tells that we have some number &lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt; on node &lt;span class=&quot;math-container&quot;&gt;$N_i$&lt;/span&gt;,&#xA;and we want to reach node &lt;span class=&quot;math-container&quot;&gt;$N_j$&lt;/span&gt; with maximal number possible &lt;span class=&quot;math-container&quot;&gt;$X_j$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Each move from any node to any specific node multiplies or divides number.&lt;/p&gt;&#xA;&lt;p&gt;But how? Recall edge has two numbers with it, &lt;span class=&quot;math-container&quot;&gt;$E_{i-&amp;gt;j}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$E_{j-i}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If we move number &lt;span class=&quot;math-container&quot;&gt;$X_a$&lt;/span&gt; from node to node, then the rule says what number &lt;span class=&quot;math-container&quot;&gt;$X_{b}$&lt;/span&gt; on the target node can be formed using the next formulas.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$(E_a+X_a) * (E_b{} - X_{b})=C_{a&amp;lt;-&amp;gt;b}$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; is specific constant equal to &lt;span class=&quot;math-container&quot;&gt;$E_{a}*E_{b}$&lt;/span&gt; in the edge.&lt;/p&gt;&#xA;&lt;p&gt;So &lt;span class=&quot;math-container&quot;&gt;$X_b = E_b - C/(E_a+X_a)$&lt;/span&gt; is number one gets from moving it from node to node.&lt;/p&gt;&#xA;&lt;p&gt;Moving the number in the other direction is calculated the same way.&lt;/p&gt;&#xA;&lt;p&gt;Movement of number reduces &lt;span class=&quot;math-container&quot;&gt;$E_b$&lt;/span&gt; amount and increases &lt;span class=&quot;math-container&quot;&gt;$E_a$&lt;/span&gt; amount in the edge.&lt;/p&gt;&#xA;&lt;p&gt;After playing with formula, it would be seen:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;edge multiplies or divides number&lt;/li&gt;&#xA;&lt;li&gt;maximal number of &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; cannot be bigger than the amounts in the edge.&lt;/li&gt;&#xA;&lt;li&gt;Each increase of &lt;span class=&quot;math-container&quot;&gt;$X_a$&lt;/span&gt; leads to an increase of &lt;span class=&quot;math-container&quot;&gt;$X_b$&lt;/span&gt;, but the amount of change of &lt;span class=&quot;math-container&quot;&gt;$X_b$&lt;/span&gt; obtained is smaller and smaller with for next same amount of increase in &lt;span class=&quot;math-container&quot;&gt;$X_a$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Edges amid nodes and their amounts form constraints.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; can be split into parts and moved along several routes.&#xA;For instance, moving &lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt; from &lt;span class=&quot;math-container&quot;&gt;$N_i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$N_j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$N_k$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$k≠j$&lt;/span&gt;. Ratio of split can be any.&lt;/p&gt;&#xA;&lt;p&gt;It is also possible to merge numbers.&#xA;For instance, moving from &lt;span class=&quot;math-container&quot;&gt;$X_i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$X_j$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$X_k$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$i \ne j \ne k$&lt;/span&gt;. After merge &lt;span class=&quot;math-container&quot;&gt;$X_k$&lt;/span&gt; can be propagated as one number.&#xA;Sometimes cannot merge, and 2 numbers will flow.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let's consider some cases where numerics go wild.&lt;/p&gt;&#xA;&lt;p&gt;We have 5 nodes, &lt;span class=&quot;math-container&quot;&gt;$N_1 .. N_5$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Each hop on multiplies by &lt;span class=&quot;math-container&quot;&gt;$10^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If we have number &lt;span class=&quot;math-container&quot;&gt;$10^3$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$N_1$&lt;/span&gt; and target is to reach &lt;span class=&quot;math-container&quot;&gt;$N_5$&lt;/span&gt; with maximum number, it will lead to &lt;span class=&quot;math-container&quot;&gt;$10^{13}$&lt;/span&gt;. If we start on &lt;span class=&quot;math-container&quot;&gt;$N_5$&lt;/span&gt; with a small number, it will lead to a really small number on &lt;span class=&quot;math-container&quot;&gt;$N_1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem complexity and size&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In our problem parameters, there are many nodes and many edges, there are more than one route from node to node. And numbers can get really low and then high on one route and be whatever on another route.&lt;/p&gt;&#xA;&lt;p&gt;We can have hundreds of nodes and hundreds of edges.&lt;/p&gt;&#xA;&lt;p&gt;Number may be split to move over several routes at the same time to reach the final node.&lt;/p&gt;&#xA;&lt;p&gt;Starting numbers can be as small as &lt;span class=&quot;math-container&quot;&gt;$10^3$&lt;/span&gt; and as big as &lt;span class=&quot;math-container&quot;&gt;$10^{18}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Edge amounts can be &lt;span class=&quot;math-container&quot;&gt;$10^6$&lt;/span&gt; up to &lt;span class=&quot;math-container&quot;&gt;$10^{24}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Additionally, we have some constant factors which are cut from &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; during move over edges, not obeying &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; formula, deduced after arrival on the target node.&lt;/p&gt;&#xA;&lt;p&gt;Also, nodes form clusters. Moving numbers from one cluster to another has some other constant factor removed from &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; when it travels along the edge connecting two nodes from different clusters, sometimes we do not want to leave the cluster.&lt;/p&gt;&#xA;&lt;p&gt;That leads solvers, SCIP and others, to detect Nonlinear problem and it solved in floating point arithmetics(not MILP).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;How to scale edge numbers and &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; numbers the way that will likely lead to problem feasibility?&lt;/p&gt;&#xA;&lt;p&gt;I have already did the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;found all routes from the start node to any other node, and produced a total approximated multiplier of each travel. It is an approximation because it does not consider the size of move, just spot number of minimal amount assuming edge amounts are infinite.&lt;/li&gt;&#xA;&lt;li&gt;in case of relatively big edge amounts, capped these to some smaller amount in comparison to &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt;. Comparison is done using the above heuristic.&lt;/li&gt;&#xA;&lt;li&gt;any edge with a really small amount against &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; eliminated.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I tried to scale up or scale down all amounts, but that does not work as need some scale in to put all numbers in the possible middle range.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I am searching for some algorithm/rule that tells how to scale edges numbers ensuring that routes are feasible.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What is the application?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Application of finding the best way to swap funds on crypto &lt;a href=&quot;https://arxiv.org/abs/2204.05238&quot; rel=&quot;nofollow noreferrer&quot;&gt;exchanges&lt;/a&gt; and move funds along bridges, paying fees and gas costs.&lt;/p&gt;&#xA;&lt;p&gt;User wants to give some assets and get another asset. Numerics can be wild because of the big difference in decimals used in assets and asset prices.&lt;/p&gt;&#xA;" OwnerUserId="12702" LastEditorUserId="12702" LastEditDate="2024-02-17T11:37:11.933" LastActivityDate="2024-02-17T11:37:11.933" Title="Numerical infeasibility for moving numbers along some specific conversion edges to get maximal number on target node from some starter node" Tags="|nonlinear-programming|network-flow|numerical-issues|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="11604" PostTypeId="1" AcceptedAnswerId="11605" CreationDate="2024-01-31T10:44:07.360" Score="3" ViewCount="184" Body="&lt;p&gt;&lt;strong&gt;Theoretical model&lt;/strong&gt;&#xA;Suppose that I have an input vector &lt;span class=&quot;math-container&quot;&gt;$E_{t}\in\mathbb R^n$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$n\in \mathbb N$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Suppose that I want to optimize &lt;span class=&quot;math-container&quot;&gt;$\displaystyle\max_{t,x} E_tx$&lt;/span&gt;.&#xA;That is, my decision variables are the vectors &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; of same dimension &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;. We optimize on the indexes of the input vector &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Subject to some linear constraints &lt;span class=&quot;math-container&quot;&gt;$Ax\le b_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Bt \le b_2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\quad (A,B)\in\mathcal M_{n,n}(\mathbb R)^2$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$(b_1,b_2)\in (\mathbb R^n)^2$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;and some domain constraints: &lt;span class=&quot;math-container&quot;&gt;$x\in \{0,1\}^n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t\in\{1,\dots,n\}^n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is such model exist in any Operations Research formulation? MILP, ILP, MQLP etc.? The fact that the input vector is indexed by a decision variable is something I have not met yet.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Numerical example&lt;/strong&gt; of such model would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$n = 3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$E = (5,-1,3),\quad \forall i \in \{1,2,3\}$&lt;/span&gt;. Note that &lt;span class=&quot;math-container&quot;&gt;$E_i$&lt;/span&gt; could be anything in &lt;span class=&quot;math-container&quot;&gt;$\mathbb R$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\displaystyle\max_{t,x} E_tx$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Without any constraint except domains constraints: &lt;span class=&quot;math-container&quot;&gt;$x\in \{0,1\}^3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t\in\{1,2,3\}^3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An optimal solution here would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x=(1,1,1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t=(1,1,1)$&lt;/span&gt; which would give an objective of &lt;span class=&quot;math-container&quot;&gt;$5\times 3 =15$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Numerical example with &lt;span class=&quot;math-container&quot;&gt;$Bt\le b_2$&lt;/span&gt;&lt;/strong&gt; of such model would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$n = 3$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$E = (5,-1,3),\quad \forall i \in \{1,2,3\}$&lt;/span&gt;. Note that &lt;span class=&quot;math-container&quot;&gt;$E_i$&lt;/span&gt; could be anything in &lt;span class=&quot;math-container&quot;&gt;$\mathbb R$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\displaystyle\max_{t,x} E_tx$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t_i\ge 2,\quad \forall i\in\{1,2,3\}$&lt;/span&gt;&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$\sum x \le 2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Domain constraints: &lt;span class=&quot;math-container&quot;&gt;$x\in \{0,1\}^3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t\in\{1,2,3\}^3$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An optimal solution here would be:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x=(1,0,1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t=(3,2,3)$&lt;/span&gt; which would give an objective of &lt;span class=&quot;math-container&quot;&gt;$3+3=6$&lt;/span&gt;.&#xA;There is another optimal solution of value &lt;span class=&quot;math-container&quot;&gt;$6$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;$x=(1,0,1)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t=(3,3,3)$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="35" LastEditDate="2024-02-02T15:20:55.110" LastActivityDate="2024-02-02T15:20:55.110" Title="Can an Operations Research model optimize on a vector's indexes?" Tags="|optimization|modeling|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11605" PostTypeId="2" ParentId="11604" CreationDate="2024-01-31T17:10:26.393" Score="4" Body="&lt;p&gt;You can do this with ILP/MILP by using a binary variable &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}$&lt;/span&gt; indexed over &lt;span class=&quot;math-container&quot;&gt;$\lbrace 1,\dots, n\rbrace \times \lbrace 1,\dots, n\rbrace,$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$y_{i,j}=1$&lt;/span&gt; if and only if the &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;-th component of &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt; is matched to the &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;-th component of &lt;span class=&quot;math-container&quot;&gt;$x.$&lt;/span&gt; Constraints on &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; are &lt;span class=&quot;math-container&quot;&gt;$\sum_i y_{i,j} = 1\, \forall j$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\sum_j y_{i,j} = 1\, \forall i.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Your objective function is &lt;span class=&quot;math-container&quot;&gt;$\sum_{i,j} E_i x_j y_{i,j}.$&lt;/span&gt; The second solution in your example would correspond to &lt;span class=&quot;math-container&quot;&gt;$y_{3,1}=y_{2,2}=y_{1,3}=1.$&lt;/span&gt; The objective is quadratic but easy to linearize (by introducing more variables). How to linearize the product of two binaries has been answered (a few thousand times, I think) elsewhere on this site.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-01-31T17:10:26.393" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11607" PostTypeId="2" ParentId="11602" CreationDate="2024-01-31T19:57:28.720" Score="3" Body="&lt;p&gt;As in &lt;a href=&quot;https://or.stackexchange.com/questions/10172/how-to-enforce-logical-implication-sum-j-a-j-x-j-le-b-implies-sum-j-c-j-x-j&quot;&gt;How to enforce logical implication $\sum_j a_j x_j \le b \implies \sum_j c_j x_j \le d$&lt;/a&gt;, (temporarily) introduce constant &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0$&lt;/span&gt; and binary variable &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt;, and impose linear big-M constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\alpha + \epsilon - B &amp;amp;\le (\alpha + \epsilon - 0) Z \tag1\label1 \\&#xA;\beta - \sum_i W_i &amp;amp;\le (\beta - 0) (1-Z) \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Now eliminate &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; by multiplying \eqref{1} by &lt;span class=&quot;math-container&quot;&gt;$\beta$&lt;/span&gt; and \eqref{2} by &lt;span class=&quot;math-container&quot;&gt;$\alpha + \epsilon$&lt;/span&gt; and adding them up to obtain the valid inequality&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\beta(\alpha + \epsilon - B) + (\alpha + \epsilon)\left(\beta - \sum_i W_i\right) &#xA;\le \beta(\alpha + \epsilon) Z + (\alpha + \epsilon) \beta (1-Z),$$&lt;/span&gt;&#xA;which simplifies to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$B + \frac{\alpha + \epsilon}{\beta}\sum_i W_i \ge \alpha + \epsilon. \tag3\label3$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;But this is too weak unless &lt;span class=&quot;math-container&quot;&gt;$B=0$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$\sum_i W_i = 0$&lt;/span&gt;.  The original disjunction &lt;span class=&quot;math-container&quot;&gt;$$B \ge \alpha + \epsilon \lor \sum_i W_i \ge \beta$$&lt;/span&gt; is nonconvex, and \eqref{3} is a convex relaxation.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-01-31T22:44:03.243" LastActivityDate="2024-01-31T22:44:03.243" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11608" PostTypeId="1" AcceptedAnswerId="11620" CreationDate="2024-01-31T20:20:26.433" Score="3" ViewCount="410" Body="&lt;p&gt;This is a follow-up post regarding this &lt;a href=&quot;https://or.stackexchange.com/questions/11581/help-with-formulating-the-objective-function-of-my-subproblem&quot;&gt;one&lt;/a&gt;. I deleted this new post once before, as I was unhappy with the formulation. I have the following basic nurse scheduling MILP, which tries to cover the daily demand &lt;span class=&quot;math-container&quot;&gt;$demand_{ts}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_t \sum_s slack_{ts}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{subject to} \sum_i x_{its} + slack_{ts}  = demand_{ts}\forall t,s$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_s x_{its} \le 1 \forall i,t$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{its} \in\left\{ 0,1 \right\} \forall i,t,s$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$slack_{ts} \ge 0 \forall t,s$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;After decomposing according to the Dantzig Decomposition, this yields the following Master problem &lt;span class=&quot;math-container&quot;&gt;$(MP)$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{minimize} \sum_t \sum_s \text{s}_{ts}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{subject to} \sum_i \sum_r x_{its}^r \lambda_{ir} + \text{s}_{ts}  = d_{ts} \forall t,s $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_r \lambda_{ir} = 1 \forall i $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lambda_{ir} \in\mathbb{Z}^+ \forall i,r$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{s}_{ts} \ge 0 \forall t,s$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and sub problem &lt;span class=&quot;math-container&quot;&gt;$(SP(i))$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{minimize } -\sum_{t,s} \pi_{ts} x_{its} - \mu_i $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\text{subject to} \sum_s x_{its} \le 1 \forall t$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{its} \in\left\{ 0,1 \right\} \forall t,s$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So far so good. Now, I want to incorporate individual motivation (&lt;span class=&quot;math-container&quot;&gt;$motivation_{its}$&lt;/span&gt;), which can be seen as the performance during each shift (&lt;span class=&quot;math-container&quot;&gt;$motivation_{its}$&lt;/span&gt; is influenced by the daily mood &lt;span class=&quot;math-container&quot;&gt;$mood_{it}$&lt;/span&gt;. If it is smaller than one, there is more &lt;span class=&quot;math-container&quot;&gt;$slack_{ts}$&lt;/span&gt;. This motivation should now be included in the demand constraint (instead of &lt;span class=&quot;math-container&quot;&gt;$x_{its}$&lt;/span&gt;). The new (full) problem looks like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{minimize} \sum_t \sum_s slack_{ts} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i}^{}motivation_{its}+slack_{ts}=demand_{ts}\forall t,s$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$mood_{it} + M\cdot (1-x_{its}) \geq motivation_{its} \geq mood_{it} - M\cdot (1-x_{its})\quad \forall i,t,s$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$motivation_{its} \leq x_{its}\quad \forall i,t,s$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$mood_{it}=1-\alpha_{it}\cdot \sum_s x_{its}\quad \forall i,t\\&#xA;\alpha_{it}\sim U(0,1)\quad \forall i,t$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{its}\in \{0,1\}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$mood_{it}, motivation_{its}\in[0,1]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now I have the following question. Can I still only include the demand constraint in the MP and move the other new ones to the SP(i) or is that not possible because they are &amp;quot;linked&amp;quot;? Especially about the initialization of the GC, where the SP(i) has not yet been solved and no solutions for &lt;span class=&quot;math-container&quot;&gt;$mood_{it}$&lt;/span&gt; and therefore also no &lt;span class=&quot;math-container&quot;&gt;$motivation_{its}$&lt;/span&gt; values are obtained. How do I have to adapt my CG model so that I still only have the demand constraint in the MP and the rest in the SP(i)?&lt;/p&gt;&#xA;&lt;p&gt;SAS Code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;proc optmodel;&#xA;   /* declare sets and parameters */&#xA;   set ISET, TSET, SSET;&#xA;   num demand {TSET, SSET};&#xA;&#xA;   /* read input data here */&#xA;    set ISET = {1, 2, 3};&#xA;    set SSET = {1, 2, 3};&#xA;    set TSET = {1, 2, 3, 4, 5, 6, 7};&#xA;    num demand{TSET, SSET} = {(1, 1): 2, (1, 2): 1, (1, 3): 0, (2, 1): 1, (2, 2): 2, (2, 3): 0, (3, 1): 1, (3, 2): 1, (3, 3): 1,&#xA;               (4, 1): 1, (4, 2): 2, (4, 3): 0, (5, 1): 2, (5, 2): 0, (5, 3): 1, (6, 1): 1, (6, 2): 1, (6, 3): 1,&#xA;               (7, 1): 0, (7, 2): 3, (7, 3): 0};&#xA;    /* Generate random values for alpha */&#xA;    execute INIT_RANDOM(123); /* Set a seed for reproducibility */&#xA;    alpha{i in ISET, t in TSET} = rand(&amp;quot;Uniform&amp;quot;, 0, 1);&#xA;               &#xA;&#xA;   /* declare decision variables */&#xA;   var motivation {ISET, TSET, SSET} &amp;gt;= 0 &amp;lt;= 1;&#xA;   var slack {TSET, SSET} &amp;gt;= 0;&#xA;   var mood {ISET, TSET} &amp;gt;= 0 &amp;lt;= 1;&#xA;   var x {ISET, TSET, SSET} binary;&#xA;&#xA;   /* declare objective */&#xA;   minimize z = sum {t in TSET, s in SSET} slack[t,s];&#xA;&#xA;   /* declare constraints */&#xA;   con SatisfyDemand {t in TSET, s in SSET}:&#xA;      sum {i in ISET} motivation[i,t,s] + slack[t,s] = demand[t,s];&#xA;&#xA;   con Indicator {i in ISET, t in TSET, s in SSET}:&#xA;      x[i,t,s] = 1 implies motivation[i,t,s] = mood[i,t]&#xA;   suffixes=(block=i);&#xA;&#xA;   con MotivationImpliesX {i in ISET, t in TSET, s in SSET}:&#xA;      motivation[i,t,s] &amp;lt;= x[i,t,s]&#xA;   suffixes=(block=i);&#xA;&#xA;   con AlphaMood {i in ISET, t in TSET}:&#xA;      alpha * sum {s in SSET} x[i,t,s] + mood[i,t] = 1&#xA;   suffixes=(block=i);&#xA;&#xA;   /* call MILP solver with Dantzig-Wolfe decomposition algorithm */&#xA;   solve with milp / decomp;&#xA;&#xA;   /* write output data here */&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="11914" LastEditDate="2024-03-04T10:38:58.870" LastActivityDate="2024-03-04T10:38:58.870" Title="How to modify master problem and individual sub problems in column generation?" Tags="|mixed-integer-programming|linear-programming|column-generation|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11609" PostTypeId="2" ParentId="11604" CreationDate="2024-01-31T21:51:21.467" Score="1" Body="&lt;p&gt;This is a complement to the answer given by @prubin.&lt;/p&gt;&#xA;&lt;p&gt;I will start by restating the definition you presented, just for conciseness.&lt;/p&gt;&#xA;&lt;p&gt;Let&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$E \in \mathbb{R}^{n^{n + 1}}$&lt;/span&gt; be a &amp;quot;matrix&amp;quot;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$t \in \mathbb{N}^{*n}_{\leqslant n}$&lt;/span&gt; be an index of &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;, thus &lt;span class=&quot;math-container&quot;&gt;$E_t \in \mathbb{R}^{n}$&lt;/span&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$A \in \mathcal{M}_{n,n}$&lt;/span&gt;; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$b_1, b_2, c \in \mathbb{R}^n$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The initial formulation was presented as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$E_t^T x$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t. &lt;span class=&quot;math-container&quot;&gt;$A x \leqslant b_1$&lt;/span&gt; (1)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c^i t^i \leqslant b_2^i \quad\quad \forall i \in \mathbb{N}^{*}_{\leqslant n}$&lt;/span&gt; (2)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$t \in \mathbb{N}^{*n}_{\leqslant n}\quad$&lt;/span&gt; (3)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb{B}^n$&lt;/span&gt; (4)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;MIQP formulation&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;Let's consider the following variables.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$e^i \in \mathbb{R}$&lt;/span&gt; be a variable standing for &lt;span class=&quot;math-container&quot;&gt;$E_t^i$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$t \in \mathbb{N}^{*n}_{\leqslant n}$&lt;/span&gt;; And&lt;/li&gt;&#xA;&lt;li&gt;&lt;span class=&quot;math-container&quot;&gt;$y_t \in \mathbb{B}$&lt;/span&gt; be a flag variable telling whether setting &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; is selected.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\sum_{i = 1}^{n} e^i x^i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t. (Constraints 1)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$e^i = \sum_{t \in \mathbb{N}^{*n}_{\leqslant n}} y_t E_t^i \quad\quad \forall i \in \mathbb{N}^{*}_{\leqslant n}$&lt;/span&gt; (5)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$c^i \sum_{t \in \mathbb{N}^{*n}_{\leqslant n}} y_t t^i \leqslant b_2^i \quad\quad \forall i \in \mathbb{N}^{*}_{\leqslant n}$&lt;/span&gt; (6)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum_{t \in \mathbb{N}^{*n}_{\leqslant n}} y_t = 1$&lt;/span&gt; (7)&lt;/p&gt;&#xA;&lt;p&gt;(Constraints 4)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;MILP formulation&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;Now, we will linearize the previous objective function, and propose a MILP.&#xA;Let's consider the variable &lt;span class=&quot;math-container&quot;&gt;$z^i \in \mathbb{R}$&lt;/span&gt; be a variable standing for &lt;span class=&quot;math-container&quot;&gt;$E_t^i x^i$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$t \in \mathbb{N}^{*n}_{\leqslant n}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$i \in \mathbb{N}^{*}_{\leqslant n}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\max$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$\sum_{i = 1}^{n} z^i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;s.t. (Constraints 1, 5, 6, and 7)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$e^i - (1 - x^i) M \leqslant z^i \leqslant x^i M \quad\quad \forall i \in \mathbb{N}^{*}_{\leqslant n}$&lt;/span&gt; (8)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\quad\quad\quad\quad\quad\quad\quad\quad z^i \leqslant e^i \quad\quad \forall i \in \mathbb{N}^{*}_{\leqslant n}$&lt;/span&gt; (9)&lt;/p&gt;&#xA;&lt;p&gt;(Constraints 4)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$z \in \mathbb{R}^n$&lt;/span&gt; (10)&lt;/p&gt;&#xA;&lt;p&gt;We can take the constant &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; as the largest entry of &lt;span class=&quot;math-container&quot;&gt;$E$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As a takeaway, I would say that the toughest part is on the number of variables &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;, since the scope &lt;span class=&quot;math-container&quot;&gt;$t \in \mathbb{N}^{*n}_{\leqslant n}$&lt;/span&gt; easily explodes.&lt;/p&gt;&#xA;&lt;p&gt;Let me know case there is any error.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastActivityDate="2024-01-31T21:51:21.467" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11610" PostTypeId="2" ParentId="11502" CreationDate="2024-01-31T22:13:14.053" Score="0" Body="&lt;p&gt;There is a rich literature on parametric optimization, which deals with questions of when the optimal value/solution of an optimization problem is (sub)differentiable with respect to its parameters.&lt;/p&gt;&#xA;&lt;p&gt;Classical references are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Fiacco's book &amp;quot;Introduction to Sensitivity and Stability Analysis in Nonlinear Programming&amp;quot;, available for purchase &lt;a href=&quot;https://shop.elsevier.com/books/introduction-to-sensitivity-and-stability-analysis-in-nonlinear-programming/fiacco/978-0-12-254450-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Bonnans and Shapiro's book &amp;quot;Perturbation Analysis of Optimization Problems&amp;quot;, available for download/purchase &lt;a href=&quot;https://link.springer.com/book/10.1007/978-1-4612-1394-9&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;A more approachable reference is:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Still's &amp;quot;Lectures on Parametric Optimization: An Introduction&amp;quot;, which can be downloaded for free &lt;a href=&quot;https://optimization-online.org/wp-content/uploads/2018/04/6587.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In particular, Theorem 4.4 in Still's lecture notes provides general conditions under which the optimal value function of your problem is differentiable with respect to the parameter &lt;span class=&quot;math-container&quot;&gt;$c$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="468" LastActivityDate="2024-01-31T22:13:14.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11611" PostTypeId="1" AcceptedAnswerId="11612" CreationDate="2024-01-31T23:13:06.547" Score="0" ViewCount="123" Body="&lt;p&gt;I have a multi-objective optimization problem I am trying to solve with competing objectives. I am trying to model a network of industrial businesses which can share wastewater rather than sending it all to wastewater treatment.&lt;/p&gt;&#xA;&lt;p&gt;I have set up one &lt;code&gt;LpProblem()&lt;/code&gt; and want to alternate between minimizing the economic cost and minimizing the environmental impact. If I can achieve this I will use the optimal values obtained to create a weighted objective function to find a balance of the two. Where I am stuck is when I run the problem to minimize environmental impact, it finds the optimum to be 0 and ignores my water balance constraint which states that for each plant, all water going in must equal the demand of the plant and all water leaving must equal its available supply. I followed the method provided by @Reinderien and have done my best to produce a minimum reproducible example below.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pulp import LpMinimize, LpProblem, LpStatus, LpStatusOptimal, lpSum, LpVariable, value, LpMaximize, lpDot&#xA;&#xA;# input data&#xA;D =[100, 20, 80, 60, 150, 100]          # Demand in&#xA;S = [100, 20, 80, 60, 150, 100]         # Supply out (D[i] = S[i] no leakage)&#xA;Cin = [10, 40, 20, 30, 50, 35]          # Cin is the maximum contaminant concentration that can be accepted by plant j&#xA;Cout = [100, 250, 80, 200, 150, 130]    # Cout is the contaminant concentration of water exiting plant i&#xA;Cfresh = 1                              # concentration of contaminants in fresh water&#xA;Ctreat = [65, 115]                      # output concentration of treated wastewater from process k&#xA;&#xA;plants = range(len(D))              # number of plants&#xA;treatments = range(len(Ctreat))     # number of treatment processes&#xA;&#xA;# define the decision variables&#xA;a = LpVariable.matrix(name=&amp;quot;TWW&amp;quot;, lowBound=0, indices=(plants, plants))&#xA;e = LpVariable.matrix(name=&amp;quot;UTWW&amp;quot;, lowBound=0, indices=(plants, plants))&#xA;f = LpVariable.matrix(name=&amp;quot;fresh&amp;quot;, lowBound=0, indices=(plants))&#xA;w = LpVariable.matrix(name=&amp;quot;waste&amp;quot;, lowBound=0, indices=(plants))&#xA;# t[i][k] is the binary decision variable (1 if plant i uses treatment process k) &#xA;t = LpVariable.matrix(name=&amp;quot;treatment&amp;quot;, cat=&amp;quot;Binary&amp;quot;, indices=(plants, treatments))&#xA;# b[i][j][k] is the flow of treated water from i to j using process k&#xA;# this is supposed to be linearised so that PuLP can solve this problem&#xA;b = [[[a[i][j] if value(t[i][k]) == 1 else t[i][k] for k in treatments] for j in plants] for i in plants]&#xA;&#xA;# defines the input flow into each plant&#xA;input_flow = [&#xA;    fresh + lpSum(&#xA;        a_row[j] + e_row[j]&#xA;        for a_row, e_row in zip(a, e)&#xA;    )&#xA;    for j, fresh in zip(plants, f)&#xA;]&#xA;&#xA;# defines the output flow from each plant&#xA;output_flow = [&#xA;    waste + lpSum(a_row) + lpSum(e_row)&#xA;    for a_row, e_row, waste in zip(a, e, w)&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have added my own input data and the additional variables I am working with. Specifically &lt;code&gt;t[i][k]&lt;/code&gt; which is a binary variable that is set to 1 if plant &lt;code&gt;i&lt;/code&gt; is using treatment process &lt;code&gt;k&lt;/code&gt;. I use &lt;code&gt;t&lt;/code&gt; to create a 3D array &lt;code&gt;b[i][j][k]&lt;/code&gt; which takes the value of treated flow &lt;code&gt;a[i][j]&lt;/code&gt; if the treatment process &lt;code&gt;k&lt;/code&gt; is used. Otherwise it takes the value of &lt;code&gt;t[i][k]&lt;/code&gt; which should be 0 if treatment &lt;code&gt;k&lt;/code&gt; is not used. The idea behind this was to make sure the problem is still a linear problem.&lt;/p&gt;&#xA;&lt;p&gt;Below, I calculate the contaminants as a product of the flow and concentration of each stream. These contaminants are used in the quality constraint and objective function. I also add the constraints and define the problem and objective function.&lt;/p&gt;&#xA;&lt;p&gt;The quality constraint states that the contaminants entering a plant cannot exceed the maximum acceptable contaminant concentration &lt;code&gt;Cin&lt;/code&gt;. It is taken from the case study I am following below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EfKW0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EfKW0.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Although there is a typo in this equation. The contaminants should be &lt;code&gt;&amp;lt;= Cin[j]*D[j]&lt;/code&gt; so that the units are consistent.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# calculates the contaminants from the freshwater in, wastewater out and untreated water out&#xA;fresh_contam = lpDot(f, Cfresh)&#xA;waste_contam = lpDot(w, Cout)&#xA;untreated_contam = [&#xA;    [&#xA;        e[i][j] * Cout[i]&#xA;        for j in plants&#xA;    ]&#xA;    for i in plants&#xA;]&#xA;&#xA;# calculate the sum of contaminants entering plant j from plant i&#xA;# turns a 3D array back into a 2D array&#xA;treated_contam = [&#xA;    [&#xA;        lpSum(&#xA;            b[i][j][k] * Ctreat[k] for k in treatments&#xA;            )&#xA;        for j in plants&#xA;    ]&#xA;    for i in plants&#xA;]&#xA;&#xA;# quality constraint value that sums the contaminants entering plant j&#xA;input_contam = [&#xA;    fresh + lpSum(&#xA;        untreated_contam[i][j] + treated_contam[i][j]&#xA;        for i in plants&#xA;    )&#xA;    for fresh, j in zip(fresh_contam, plants)&#xA;]&#xA;&#xA;&#xA;# define the problem and objective function&#xA;prob = LpProblem(name=&amp;quot;treatment_flow)&amp;quot;, sense=LpMinimize)&#xA;prob.setObjective(fresh_contam + waste_contam)&#xA;&#xA;&#xA;# add the constraints&#xA;# ensures plants do not connect to themselves&#xA;for i in plants:&#xA;    a[i][i] = 0&#xA;    e[i][i] = 0&#xA;&#xA;# the sum of all inputs to each destination plant must exactly equal its demand&#xA;for j, in_, in_target in zip(plants, input_flow, D):&#xA;    prob.addConstraint(name=f'in_{j}', constraint= in_ == in_target)&#xA;&#xA;# the sum of all outputs from each source plant must exactly equal its output flowrate&#xA;for i, out, out_target in zip(plants, output_flow, S):&#xA;    prob.addConstraint(name=f'out_{i}', constraint= out == out_target)&#xA;&#xA;# quality constraint ensures plant will only accept input water from sources as long as the max contaminant &#xA;# concentration Cin[j] is not exceeded&#xA;for j, contam, max_contam, demand in zip(plants, input_contam, Cin, D):&#xA;    prob.addConstraint(name=f'quality_{j}', constraint= contam &amp;lt;= max_contam*demand)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'm unsure if the following constraint is necessary as my output didn't change with or without it&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# additioanl constraint set regarding input_flow  and output_flow&#xA;for plant, in_, out in zip(plants, input_flow, output_flow):&#xA;    prob.addConstraint(name=f'sustain_{plant}', constraint= in_ &amp;gt;= out)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;# run problem and output results&#xA;prob.solve()&#xA;assert prob.status == LpStatusOptimal&#xA;&#xA;&#xA;print('Treated water flow rate (left to top):')&#xA;for arow in a:&#xA;    print([value(x) for x in arow])&#xA;print('Untreated water flow rate (left to top):')&#xA;for erow in e:&#xA;    print([value(x) for x in erow])&#xA;print(&amp;quot;Freshwater input rate:&amp;quot;, [value(x) for x in f])&#xA;print(&amp;quot;Wastewater output rate:&amp;quot;, [value(x) for x in w])&#xA;print(&amp;quot;Total input flow:&amp;quot;, [value(x) for x in input_flow])&#xA;print(&amp;quot;Total output flow:&amp;quot;, [value(x) for x in output_flow])&#xA;print(&amp;quot;Binary variable if plant i uses treatment process k&amp;quot;)&#xA;for trow in t:&#xA;    print([value(x) for x in trow])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I run the model, it is able to solve it but my main issue is that the freshwater in and wastewater out values are all 0 which is still wrong. These plants are in a system with input from the freshwater and output to the wastewater. Not every plant needs to be connected to the freshwater source or wastewater disposal site, but some need to be in order to bring water in and out of the system. Since there are no leaks in the system, the water in from freshwater should equal the water out through wastewater. Something is causing PuLP to disobey this water balance and I suspect it is a constraint I need to add but I am unsure as to what this constraint should be. It seems as if the plants are in a loop cycling their water together but ignoring the quality constraint as well.&lt;/p&gt;&#xA;" OwnerUserId="13155" LastEditorUserId="13155" LastEditDate="2024-02-02T02:05:33.060" LastActivityDate="2024-02-03T14:07:22.557" Title="PuLP is ignoring constraints, and setting everything to 0 for minimization problem" Tags="|optimization|mixed-integer-programming|linear-programming|python|pulp|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11612" PostTypeId="2" ParentId="11611" CreationDate="2024-02-01T13:45:36.617" Score="0" Body="&lt;p&gt;I don't think you should have binary constraints here at all. Infer &amp;quot;use&amp;quot; by a treatment-specific rate being non-zero. One obvious quirk is that, with no other constraints on available treatments, the treatment with the least contamination will always be used. Also, your treatments are all so low-contamination that no 'untreated' transfers are ever used; increase the treatment contamination to 200 to see the effect of mixed treated-untreated flows.&lt;/p&gt;&#xA;&lt;p&gt;Reformulate to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min C_{untreat} \cdot w$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$s.t.$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$a_{iik} = 0 \quad \forall i, k$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$e_{ii} = 0 \quad \forall i$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f_j + \sum_i \left(e_{ij} + \sum_k a_{ijk} \right) = d_j \quad\forall j $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$w_i + \sum_j \left(e_{ij} + \sum_k a_{ijk} \right) = s_i \quad\forall i $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$f_j C_{fresh} + \sum_i C_{treat} \cdot a_{ij}&#xA;+ C_{untreat} \cdot e_j \le C_{in(j)} \quad\forall j  $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h2&gt;Demo code&lt;/h2&gt;&#xA;&lt;p&gt;This works fine:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import graphviz&#xA;import pulp&#xA;&#xA;D = (100, 20, 80, 60, 150, 100)           # Demand into plant j&#xA;S = D                                     # Supply out of plant i (D[i] = S[i] no leakage)&#xA;Cin = (10, 40, 20, 30, 50, 35)            # contaminant concentration max accepted by plant j&#xA;Cuntreat = (100, 250, 80, 200, 150, 130)  # contaminant concentration of untreated water from plant i&#xA;Ctreat = (65, 115)                        # contaminant concentration of treated waste from process k&#xA;Cfresh = 1                                # contaminant concentration of fresh water&#xA;&#xA;plants = range(len(D))              # indices of plants&#xA;treatments = range(len(Ctreat))     # indices of treatment processes&#xA;&#xA;&#xA;def make_vars() -&amp;gt; tuple[&#xA;    list[list[list[pulp.LpVariable]]],  # a, treated water transfer&#xA;    list[list[pulp.LpVariable]],        # e, untreated water transfer&#xA;    list[pulp.LpVariable],              # f, fresh water in&#xA;    list[pulp.LpVariable],              # w, waste water out&#xA;]:&#xA;    a = pulp.LpVariable.matrix(&#xA;        name='TWW',  # treated water transfer, (source, dest, treatment)&#xA;        cat=pulp.LpContinuous, lowBound=0, indices=(plants, plants, treatments))&#xA;    e = pulp.LpVariable.matrix(&#xA;        name='UTWW',  # untreated water transfer, (source, dest)&#xA;        cat=pulp.LpContinuous, lowBound=0, indices=(plants, plants))&#xA;    f = pulp.LpVariable.matrix(&#xA;        name='fresh',  # freshwater in, (dest)&#xA;        cat=pulp.LpContinuous, lowBound=0, indices=plants)&#xA;    w = pulp.LpVariable.matrix(&#xA;        name='waste',  # wastewater out, (source)&#xA;        cat=pulp.LpContinuous, lowBound=0, indices=plants)&#xA;&#xA;    # ensures plants do not connect to themselves&#xA;    for i in plants:&#xA;        a[i][i] = (0.,) * len(treatments)&#xA;        e[i][i] = 0.&#xA;&#xA;    return a, e, f, w&#xA;&#xA;&#xA;def make_exprs(&#xA;    a: list[list[list[pulp.LpVariable]]],&#xA;    e: list[list[pulp.LpVariable]],&#xA;    f: list[pulp.LpVariable],&#xA;    w: list[pulp.LpVariable],&#xA;) -&amp;gt; tuple[&#xA;    list[pulp.LpAffineExpression],  # total input&#xA;    list[pulp.LpAffineExpression],  # total output&#xA;    list[pulp.LpAffineExpression],  # total input contamination&#xA;    pulp.LpAffineExpression,        # total waste contamination&#xA;]:&#xA;    # input flow into each plant&#xA;    input_flow = [&#xA;        + fresh&#xA;        + pulp.lpSum(&#xA;            pulp.lpSum(a_slice[j]) + e_row[j]&#xA;            for a_slice, e_row in zip(a, e)&#xA;        )&#xA;        for j, fresh in zip(plants, f)&#xA;    ]&#xA;&#xA;    # output flow from each plant&#xA;    output_flow = [&#xA;        + pulp.lpSum(a_slice)&#xA;        + pulp.lpSum(e_row)&#xA;        + waste&#xA;        for a_slice, e_row, waste in zip(a, e, w)&#xA;    ]&#xA;&#xA;    # total contaminants entering plant j&#xA;    input_contam = [&#xA;        + fresh*Cfresh&#xA;        + pulp.lpSum(&#xA;            pulp.lpDot(Ctreat, a[i][j])&#xA;            for i in plants&#xA;        )&#xA;        + pulp.lpDot(&#xA;            Cuntreat,&#xA;            [e[i][j] for i in plants],&#xA;        )&#xA;        for j, fresh in zip(plants, f)&#xA;    ]&#xA;&#xA;    # total wastewater contaminants exiting plant i&#xA;    waste_contam = pulp.lpDot(Cuntreat, w)&#xA;&#xA;    return input_flow, output_flow, input_contam, waste_contam&#xA;&#xA;&#xA;def set_constraints(&#xA;    prob: pulp.LpProblem,&#xA;    input_flow: list[pulp.LpAffineExpression],&#xA;    output_flow: list[pulp.LpAffineExpression],&#xA;    input_contam: list[pulp.LpAffineExpression],&#xA;) -&amp;gt; None:&#xA;    # the sum of all inputs to each destination plant must exactly equal its demand&#xA;    for j, in_, in_target in zip(plants, input_flow, D):&#xA;        prob.addConstraint(name=f'in_{j}', constraint= in_ == in_target)&#xA;&#xA;    # the sum of all outputs from each source plant must exactly equal its output flowrate&#xA;    for i, out, out_target in zip(plants, output_flow, S):&#xA;        prob.addConstraint(name=f'out_{i}', constraint= out == out_target)&#xA;&#xA;    # quality constraint ensures plant will only accept input water from sources as long as the max&#xA;    # contaminant concentration Cin[j] is not exceeded&#xA;    for j, contam, max_contam, demand in zip(plants, input_contam, Cin, D):&#xA;        prob.addConstraint(name=f'quality_{j}', constraint=contam &amp;lt;= max_contam*demand)&#xA;&#xA;&#xA;def dump_console(&#xA;    a: list[list[list[pulp.LpVariable]]],&#xA;    e: list[list[pulp.LpVariable]],&#xA;    f: list[pulp.LpVariable],&#xA;    w: list[pulp.LpVariable],&#xA;    input_flow: list[pulp.LpAffineExpression],&#xA;    output_flow: list[pulp.LpAffineExpression],&#xA;    input_contam: list[pulp.LpAffineExpression],&#xA;) -&amp;gt; None:&#xA;    print('Treated water rate (left to top):')&#xA;    for treat in treatments:&#xA;        print(f'  treatment {treat}:')&#xA;        for arow in a:&#xA;            print('    ', [pulp.value(x[treat]) for x in arow])&#xA;    print()&#xA;&#xA;    print('Untreated water rate (left to top):')&#xA;    for erow in e:&#xA;        print([pulp.value(x) for x in erow])&#xA;    print()&#xA;&#xA;    print('Fresh input rate:', [pulp.value(x) for x in f])&#xA;    print('Fresh contamination:', [pulp.value(x)*Cfresh for x in f])&#xA;    print('Total input rate:', [pulp.value(x) for x in input_flow])&#xA;    print('Total input contamination:', [pulp.value(x) for x in input_contam])&#xA;    print('Max input contamination:', [c*d for c, d in zip(Cin, D)])&#xA;    print('Waste output rate:', [pulp.value(x) for x in w])&#xA;    print('Waste contamination:', [pulp.value(x)*c for x, c in zip(w, Cuntreat)])&#xA;    print('Total output rate:', [pulp.value(x) for x in output_flow])&#xA;&#xA;&#xA;def dump_graph(&#xA;    a: list[list[list[pulp.LpVariable]]],&#xA;    e: list[list[pulp.LpVariable]],&#xA;    f: list[pulp.LpVariable],&#xA;    w: list[pulp.LpVariable],&#xA;):&#xA;    graph = graphviz.Digraph(&#xA;        name='treatment_flow', format='svg',&#xA;        graph_attr={&#xA;            'rankdir': 'LR', 'overlap': 'false',&#xA;            # 'nodesep': '1',&#xA;        },&#xA;    )&#xA;&#xA;    graph.node(name='fresh', label='Freshwater')&#xA;    graph.node(name='waste', label='Wastewater')&#xA;    for plant in plants:&#xA;        graph.node(&#xA;            name=str(plant),&#xA;            shape='Mrecord',&#xA;            label=&#xA;            '{'&#xA;                '{'&#xA;                    '&amp;lt;fresh_in&amp;gt; fresh|'&#xA;                    '&amp;lt;untreat_in&amp;gt; untreated|'&#xA;                    '&amp;lt;treat_in&amp;gt; treated'&#xA;                '}|'&#xA;                r'Plant \N|'&#xA;                '{'&#xA;                    '&amp;lt;waste_out&amp;gt; waste|'&#xA;                    '&amp;lt;untreat_out&amp;gt; untreated|'&#xA;                    + '|'.join(&#xA;                        f'&amp;lt;treat_{treatment}_out&amp;gt; treatment {treatment}'&#xA;                        for treatment in treatments&#xA;                    ) +&#xA;                '}'&#xA;            '}'&#xA;        )&#xA;&#xA;    for i, a_slice in enumerate(a):&#xA;        for j, a_row in enumerate(a_slice):&#xA;            for treatment, (contam, flow_var) in enumerate(zip(Ctreat, a_row)):&#xA;                flow = pulp.value(flow_var)&#xA;                if flow &amp;gt; 0:&#xA;                    graph.edge(&#xA;                        tail_name=f'{i}:treat_{treatment}_out',&#xA;                        head_name=f'{j}:treat_in',&#xA;                        label=f'{flow:.1f} ({contam*flow:.1f})',&#xA;                    )&#xA;    for i, e_row in enumerate(e):&#xA;        for j, flow_var in enumerate(e_row):&#xA;            flow = pulp.value(flow_var)&#xA;            if flow &amp;gt; 0:&#xA;                graph.edge(&#xA;                    tail_name=f'{i}:untreat_out',&#xA;                    head_name=f'{j}:untreat_in',&#xA;                    label=f'{flow:.1f}',&#xA;                )&#xA;    for j, flow_var in enumerate(f):&#xA;        flow = pulp.value(flow_var)&#xA;        if flow &amp;gt; 0:&#xA;            graph.edge(&#xA;                tail_name='fresh',&#xA;                head_name=f'{j}:fresh_in',&#xA;                label=f'{flow:.1f} ({Cfresh*flow:.1f})',&#xA;            )&#xA;    for i, (flow_var, contam) in enumerate(zip(w, Cuntreat)):&#xA;        flow = pulp.value(flow_var)&#xA;        if flow &amp;gt; 0:&#xA;            graph.edge(&#xA;                tail_name=f'{i}:waste_out',&#xA;                head_name='waste',&#xA;                label=f'{flow:.1f} ({contam*flow:.1f})',&#xA;            )&#xA;&#xA;&#xA;    graph.view()&#xA;&#xA;&#xA;def main() -&amp;gt; None:&#xA;    a, e, f, w = make_vars()&#xA;    input_flow, output_flow, input_contam, waste_contam = make_exprs(a=a, e=e, f=f, w=w)&#xA;    prob = pulp.LpProblem(name='treatment_flow', sense=pulp.LpMinimize)&#xA;    prob.setObjective(pulp.lpSum(waste_contam))&#xA;&#xA;    set_constraints(&#xA;        prob=prob,&#xA;        input_flow=input_flow, output_flow=output_flow, input_contam=input_contam)&#xA;&#xA;    print(prob)&#xA;    prob.solve()&#xA;    assert prob.status == pulp.LpStatusOptimal&#xA;&#xA;    dump_console(&#xA;        a=a, e=e, f=f, w=w, input_flow=input_flow,&#xA;        output_flow=output_flow, input_contam=input_contam)&#xA;    dump_graph(&#xA;        a=a, e=e, f=f, w=w)&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;treatment_flow:&#xA;MINIMIZE&#xA;100*waste_0 + 250*waste_1 + 80*waste_2 + 200*waste_3 + 150*waste_4 + 130*waste_5 + 0&#xA;SUBJECT TO&#xA;in_0: TWW_1_0_0 + TWW_1_0_1 + TWW_2_0_0 + TWW_2_0_1 + TWW_3_0_0 + TWW_3_0_1&#xA; + TWW_4_0_0 + TWW_4_0_1 + TWW_5_0_0 + TWW_5_0_1 + UTWW_1_0 + UTWW_2_0&#xA; + UTWW_3_0 + UTWW_4_0 + UTWW_5_0 + fresh_0 = 100&#xA;...&#xA;&#xA;Optimal - objective value 27823.438&#xA;Optimal objective 27823.4375 - 23 iterations time 0.002&#xA;Option for printingOptions changed from normal to all&#xA;Total time (CPU seconds):       0.01   (Wallclock seconds):       0.00&#xA;&#xA;Treated water rate (left to top):&#xA;  treatment 0:&#xA;     [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;     [0.0, 0.0, 0.0, 0.0, 20.0, 0.0]&#xA;     [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;     [0.0, 0.0, 0.0, 0.0, 60.0, 0.0]&#xA;     [14.0625, 12.1875, 23.75, 27.1875, 0.0, 53.125]&#xA;     [0.0, 0.0, 0.0, 0.0, 34.84375, 0.0]&#xA;  treatment 1:&#xA;     [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;     [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;     [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;     [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;     [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;     [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;&#xA;Untreated water rate (left to top):&#xA;[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]&#xA;&#xA;Fresh input rate: [85.9375, 7.8125, 56.25, 32.8125, 35.15625, 46.875]&#xA;Fresh contamination: [85.9375, 7.8125, 56.25, 32.8125, 35.15625, 46.875]&#xA;Total input rate: [100.0, 20.0, 80.0, 60.0, 150.0, 100.0]&#xA;Total input contamination: [1000.0, 800.0, 1600.0, 1800.0, 7500.0, 3500.0]&#xA;Max input contamination: [1000, 800, 1600, 1800, 7500, 3500]&#xA;Waste output rate: [100.0, 0.0, 80.0, 0.0, 19.6875, 65.15625]&#xA;Waste contamination: [10000.0, 0.0, 6400.0, 0.0, 2953.125, 8470.3125]&#xA;Total output rate: [100.0, 20.0, 80.0, 60.0, 150.0, 100.0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AeMlU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AeMlU.png&quot; alt=&quot;flow diagram&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11118" LastEditorUserId="11118" LastEditDate="2024-02-03T14:07:22.557" LastActivityDate="2024-02-03T14:07:22.557" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11613" PostTypeId="1" CreationDate="2024-02-01T23:54:31.677" Score="2" ViewCount="90" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\DeclareMathOperator{\Tr}{Tr}\DeclareMathOperator*{\argmax}{\arg\!\max}$&lt;/span&gt;Consider the following semidefinite program (SDP)&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\min_V \quad &amp;amp; -\Tr(V) \\&#xA;\textrm{s.t.} \quad &amp;amp; \begin{bmatrix} AVA^T + Q - V &amp;amp; \lambda AVC^T \\ \lambda CVA^T &amp;amp; CVC^T + R \end{bmatrix} \succeq 0 \\&#xA;\quad &amp;amp; V \succeq 0&#xA;\end{aligned} \tag{1}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$A,C,Q,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$R$&lt;/span&gt; are input matrices and &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; is a scalar parameter. The problem in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; is a lower-level problem in a bilevel program, so I'm trying to derive the sufficient Karush–Kuhn–Tucker (KKT) conditions such that some &lt;span class=&quot;math-container&quot;&gt;$V \succeq 0$&lt;/span&gt; solves &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, to eventually replace this lower-level problem with these conditions.&lt;/p&gt;&#xA;&lt;p&gt;According to section 14.1.4 in [1], for the following SDP,&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\min_x \quad &amp;amp; c^T x \\&#xA;\textrm{s.t.} \quad &amp;amp; F_0 + \sum_{i=1}^m x_iF_i \succeq 0&#xA;\end{aligned} \tag{2}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$F_0,\dots,F_m \succeq 0$&lt;/span&gt;, &lt;strong&gt;if&lt;/strong&gt; strong duality holds, then the sufficient KKT conditions are:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;F_0 + \sum_{i=1}^m x_iF_i &amp;amp;\succeq 0 \\&#xA;Y &amp;amp;\succeq 0 \\&#xA;\Tr(F_iY) &amp;amp;= c_i, i = 1,\dots,n \\&#xA;\left(F_0 + \sum_{i=1}^m x_iF_i\right)Y &amp;amp;= 0&#xA;\end{align} \tag{3}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$Y$&lt;/span&gt; is the Lagrange multiplier. These conditions were derived in [1] by first deriving the Lagrangian of &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, then the dual problem, and then extracting the primal feasibility, dual feasibility, and complementary slackness conditions.&lt;/p&gt;&#xA;&lt;p&gt;I have two questions:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It is not clear to me if I need to check if strong duality holds in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; before attempting to derive the KKT conditions, or if the KKT conditions are sufficient by themselves for optimality.&lt;/li&gt;&#xA;&lt;li&gt;Is there a straightforward way to relate the problem in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; to the problem in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; such that the KKT conditions for &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; are easily derived from the conditions given in &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;? Or will I need to derive the Lagrangian, then the dual problem, and then extract the conditions manually?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;[1] Lecture 14: Optimality Conditions for Conic Problems, Laurent El Ghaoui, EE 227A: Convex Optimization and Applications, March 6, 2012. Available: &lt;a href=&quot;https://people.eecs.berkeley.edu/%7Eelghaoui/Teaching/EE227A/lecture14.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://people.eecs.berkeley.edu/~elghaoui/Teaching/EE227A/lecture14.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7263" LastActivityDate="2024-02-13T15:42:48.197" Title="How can I derive the sufficient KKT conditions for an SDP?" Tags="|kkt-conditions|semidefinite-programming|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11614" PostTypeId="1" CreationDate="2024-02-02T02:01:08.900" Score="1" ViewCount="39" Body="&lt;p&gt;In most classical game theoretic problems (situations in which more than one decision maker impacts the state of the environment), we assume that the decision-makers optimize their objective function. However, in most real decision-making problems, people look for a satisfactory solution instead of an optimal solution. For example, when someone wants to decide to buy something, they may rarely optimize a cost function; rather, they choose a satisfactory option. In this regard, we should look for methodologies that find satisfactory solutions. This can be done when we have human interference in the decision-making process. Usually, in regular (less important) decision making, the human mind might look for a satisfactory solution because finding that does not have computational burden. I am thinking about how we can formulate such a thing.&lt;/p&gt;&#xA;&lt;p&gt;How can we analyze such games?&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to have a few satisfactory solution-finding approaches instead of optimization methods that mimic what really happens in the human mind during regular decision making?&lt;/p&gt;&#xA;" OwnerUserId="13146" LastEditorUserId="491" LastEditDate="2024-02-02T12:03:49.797" LastActivityDate="2024-02-02T12:03:49.797" Title="satisfactory vs optimal decision making" Tags="|optimization|multi-objective-optimization|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11615" PostTypeId="1" CreationDate="2024-02-02T09:49:40.290" Score="1" ViewCount="31" Body="&lt;p&gt;I'm trying to use the DFJ formulation to solve TSPLib problems using JuMP and Gurobi. I want to add a constraint to the starting point by fixing either the start or the end to the first node (because that's the assumption that TSPLib makes - at least for the symmetric TSP dataset). However, this results in an optimal solution not found, but removing this constraint yields a tour where the first node is visited in between the tour.&lt;/p&gt;&#xA;&lt;p&gt;I wondering how one can add such a constraint to the DFJ formulation, if fixing values doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="13160" LastEditorUserId="13160" LastEditDate="2024-02-02T09:50:55.490" LastActivityDate="2024-02-02T09:50:55.490" Title="Modeling start point constraint for TSP in the Dantzig-Fulkerson-Johnson formulation" Tags="|modeling|gurobi|traveling-salesman|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11616" PostTypeId="1" AcceptedAnswerId="11619" CreationDate="2024-02-02T10:25:17.687" Score="0" ViewCount="38" Body="&lt;p&gt;I want to solve an optimization problem using the CPLEX API in C++.&#xA;After solving the model, I then want to resolve it using a different objective function.&lt;/p&gt;&#xA;&lt;p&gt;For that purpose, I learned the functions &lt;code&gt;setLinearCoef(...)&lt;/code&gt; and &lt;code&gt;setLinearCoefs(...)&lt;/code&gt; exist.&lt;/p&gt;&#xA;&lt;p&gt;Here's my current code for a small reproducable example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;&#xA;#include &amp;lt;ilcplex/ilocplex.h&amp;gt;&#xA;&#xA;int main() {&#xA;&#xA;    int benefitOfZ = 7;&#xA;&#xA;    IloEnv env;&#xA;    IloModel Model2(env);&#xA;&#xA;    IloNumVarArray Z(env, 5, 0, IloInfinity, ILOFLOAT);&#xA;&#xA;    IloExpr expr_obj2(env);&#xA;    for (int i = 0; i &amp;lt; 5; i++) {&#xA;        expr_obj2 += benefitOfZ * Z[i];&#xA;    }&#xA;    IloObjective obj2 = (IloMaximize(env, expr_obj2));&#xA;    Model2.add(obj2);&#xA;&#xA;    // Constraint 3&#xA;    for (int i = 0; i &amp;lt; 5; i++) {&#xA;        Model2.add(Z[i] &amp;lt;= 2);&#xA;    }&#xA;  &#xA;    IloCplex cplex2(Model2);&#xA;    cplex2.solve();&#xA;&#xA;    std::cout &amp;lt;&amp;lt; &amp;quot;Objective Value of Model 2: &amp;quot; &amp;lt;&amp;lt; cplex2.getObjValue() &amp;lt;&amp;lt; std::endl;&#xA;&#xA;    benefitOfZ = 14;&#xA;&#xA;    for (int i = 0; i &amp;lt; 5; i++) {&#xA;        obj2.setLinearCoef(Z[i], benefitOfZ);&#xA;    }&#xA;    cplex2.solve();&#xA;    std::cout &amp;lt;&amp;lt; &amp;quot;Objective Value of Model 2 after change: &amp;quot; &amp;lt;&amp;lt; cplex2.getObjValue() &amp;lt;&amp;lt; std::endl;&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now this works how I intend it to. But I read in the documentation that &lt;code&gt;setLinearCoefs(...)&lt;/code&gt; is more efficient than &lt;code&gt;setLinearCoef(...)&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I tried changing the code accordingly but I can't get it work without errors.&#xA;The main problem is that I don't properly understand how I need to build the objective function so that I can use &lt;code&gt;setLinearCoefs(...)&lt;/code&gt; afterwards on it.&lt;/p&gt;&#xA;&lt;p&gt;Does someone know how I could reformulate my code to make it work?&lt;/p&gt;&#xA;" OwnerUserId="12130" LastActivityDate="2024-02-02T16:41:33.367" Title="Using CPLEX in C++, how can I efficiently alter the objective function and then resolve the problem?" Tags="|cplex|c++|api|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11617" PostTypeId="1" CreationDate="2024-02-02T12:57:58.423" Score="1" ViewCount="14" Body="&lt;p&gt;I hope the question is still clear as I'm a little bit over my head with the topic.&lt;/p&gt;&#xA;&lt;p&gt;I'm trying to measure a sustainability index/score for incoming project requests (alternatives). I'm using the weighted Sum model (WSM). I am considering using the Fibonacci scale (1,2,3,5,8,13,21) to estimate the value of each criterion, but I would like to use both positive and negative numbers to measure that so that the range is from -21 to 21.&lt;/p&gt;&#xA;&lt;p&gt;The reason is, taking for example &amp;quot;reduction of CO2 emissions&amp;quot; as a criterion, I want to be able to measure if for a specific alternative the CO2 emissions increase or decrease (higher score is better). Is that still possible? All the WSM models I have seen (on academic papers, etc) use a positive scale, as either a benefit or cost criterion.&lt;/p&gt;&#xA;&lt;p&gt;Also, since I'm technically directly assigning scores to each criterion, do I no longer need to normalise the criteria?&lt;/p&gt;&#xA;" OwnerUserId="13161" LastActivityDate="2024-02-02T12:57:58.423" Title="Can I use a positive and negative Fibonacci scale to measure sustainability for project requests using Weighted Sum (WSM/SAW)?" Tags="|multicriteria-decision-analysis|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11618" PostTypeId="1" AcceptedAnswerId="11622" CreationDate="2024-02-02T16:31:00.773" Score="3" ViewCount="112" Body="&lt;p&gt;I'm getting unexpected results from the HiGHS solver in scipy (scipy.optimize.linprog with integrality constraints).&lt;/p&gt;&#xA;&lt;p&gt;In my mixed integer program one of my constraints is that &lt;span class=&quot;math-container&quot;&gt;$x_0 \geq 100$&lt;/span&gt;.  I get a result where &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; is 100 and my cost function has a minimum of 220902.826196.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Running HiGHS 1.2.0 [date: 2021-07-09, git hash: n/a]&#xA;Copyright (c) 2022 ERGO-Code under MIT licence terms&#xA;Presolving model&#xA;813 rows, 1081 cols, 5815 nonzeros&#xA;643 rows, 911 cols, 5495 nonzeros&#xA;538 rows, 781 cols, 5440 nonzeros&#xA;&#xA;Solving MIP model with:&#xA;   538 rows&#xA;   781 cols (110 binary, 0 integer, 0 implied int., 671 continuous)&#xA;   5440 nonzeros&#xA;&#xA;        Nodes      |    B&amp;amp;B Tree     |            Objective Bounds              |  Dynamic Constraints |       Work      &#xA;     Proc. InQueue |  Leaves   Expl. | BestBound       BestSol              Gap |   Cuts   InLp Confl. | LpIters     Time&#xA;&#xA;         0       0         0   0.00%   -inf            inf                  inf        0      0      0         0     0.0s&#xA;&#xA;Solving report&#xA;  Status            Optimal&#xA;  Primal bound      220902.826196&#xA;  Dual bound        220902.826196&#xA;  Gap               0% (tolerance: 0.01%)&#xA;  Solution status   feasible&#xA;                    220902.826196 (objective)&#xA;                    0 (bound viol.)&#xA;                    3.7562287347e-17 (int. viol.)&#xA;                    0 (row viol.)&#xA;  Timing            0.02 (total)&#xA;                    0.01 (presolve)&#xA;                    0.00 (postsolve)&#xA;  Nodes             1&#xA;  LP iterations     297 (total)&#xA;                    0 (strong br.)&#xA;                    0 (separation)&#xA;                    0 (heuristics)&#xA;Optimization terminated successfully. (HiGHS Status 7: Optimal)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However if I change my constraint to be &lt;span class=&quot;math-container&quot;&gt;$x_0 = 100$&lt;/span&gt;, I get a result where &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; is 100 and my cost function has a minimum of 191817.038217.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Running HiGHS 1.2.0 [date: 2021-07-09, git hash: n/a]&#xA;Copyright (c) 2022 ERGO-Code under MIT licence terms&#xA;Presolving model&#xA;813 rows, 1080 cols, 5780 nonzeros&#xA;643 rows, 910 cols, 5460 nonzeros&#xA;538 rows, 780 cols, 5405 nonzeros&#xA;&#xA;Solving MIP model with:&#xA;   538 rows&#xA;   780 cols (110 binary, 0 integer, 0 implied int., 670 continuous)&#xA;   5405 nonzeros&#xA;&#xA;        Nodes      |    B&amp;amp;B Tree     |            Objective Bounds              |  Dynamic Constraints |       Work      &#xA;     Proc. InQueue |  Leaves   Expl. | BestBound       BestSol              Gap |   Cuts   InLp Confl. | LpIters     Time&#xA;&#xA;         0       0         0   0.00%   -3171485.384239 inf                  inf        0      0      0         0     0.0s&#xA; R       0       0         0   0.00%   170865.965397   220902.826196     22.65%        0      0      0       326     0.0s&#xA; L       0       0         0   0.00%   171141.068245   192959.352843     11.31%       10     10      0       347     0.4s&#xA;[...many logging lines here...]&#xA; B   23848     223     10070  98.90%   191059.243484   191842.696644      0.41%      130     16    725    337428    66.1s&#xA; B   23857     145     10072  98.93%   191059.243484   191817.038217      0.40%      124     16    721    337454    66.1s&#xA;&#xA;Solving report&#xA;  Status            Optimal&#xA;  Primal bound      191817.038217&#xA;  Dual bound        191797.945869&#xA;  Gap               0.00995% (tolerance: 0.01%)&#xA;  Solution status   feasible&#xA;                    191817.038217 (objective)&#xA;                    0 (bound viol.)&#xA;                    7.23311321847e-17 (int. viol.)&#xA;                    0 (row viol.)&#xA;  Timing            66.53 (total)&#xA;                    0.01 (presolve)&#xA;                    0.00 (postsolve)&#xA;  Nodes             24003&#xA;  LP iterations     344914 (total)&#xA;                    57769 (strong br.)&#xA;                    1023 (separation)&#xA;                    21044 (heuristics)&#xA;Optimization terminated successfully. (HiGHS Status 7: Optimal)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Shouldn't both formulations of the problem find the same cost minimum as the only constraint I'm changing is the constraint on &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_0$&lt;/span&gt; is found to have the same value in both cases.&lt;/p&gt;&#xA;&lt;p&gt;(In this program I'm also using binary decision variables and bigM formulations.  But I'm not changing those constraints between the two runs.)&lt;/p&gt;&#xA;&lt;p&gt;Edit:  Added log files and changed the cost numbers to my actual results.  The first one stops at 220902.  That number also appears in the second log file, but the solver finds something better by the time the next logging statement is printed.  At this point I feel like I'm asking how to read HiGHS log files, which might be what I really need to know.&lt;/p&gt;&#xA;&lt;p&gt;Edit2:  The comments here hinted that something might be going wrong in the presolve.  So I ran it again with &lt;code&gt;options={'presolve' : False}&lt;/code&gt; in both cases and got the answers of 191800 and 191808 both within the gap tolerance.&lt;/p&gt;&#xA;" OwnerUserId="13162" LastEditorUserId="13162" LastEditDate="2024-02-03T03:35:44.653" LastActivityDate="2024-02-03T12:43:52.857" Title="Equivalent constraints in MILP give different answers" Tags="|mixed-integer-programming|highs|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="11619" PostTypeId="2" ParentId="11616" CreationDate="2024-02-02T16:41:33.367" Score="2" Body="&lt;p&gt;In your current code, &lt;code&gt;benefitOfZ&lt;/code&gt; is a scalar constant and &lt;code&gt;Z[i]&lt;/code&gt; is a scalar variable. To use &lt;code&gt;setLinearCoefs&lt;/code&gt;, you would make &lt;code&gt;Z&lt;/code&gt; the first argument, and for the second argument you would need to create an instance of &lt;code&gt;IloNumArray&lt;/code&gt; containing the new objective coefficients.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-02-02T16:41:33.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11620" PostTypeId="2" ParentId="11608" CreationDate="2024-02-02T22:57:40.103" Score="3" Body="&lt;p&gt;Your problem is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;\sum_t \sum_s \text{slack}_{ts} \\&#xA;&amp;amp;\text{subject to} &amp;amp;\sum_i \text{motivation}_{its} + \text{slack}_{ts} &amp;amp;= \text{demand}_{ts} &amp;amp;&amp;amp;\forall t,s \\&#xA;&amp;amp;&amp;amp;-M(1-x_{its}) \le \text{motivation}_{its} - \text{mood}_{it} &amp;amp;\le M(1-x_{its}) &amp;amp;&amp;amp;\forall i,t,s \\&#xA;&amp;amp;&amp;amp;\text{motivation}_{its} &amp;amp;\le x_{its} &amp;amp;&amp;amp; \forall i,t,s \\&#xA;&amp;amp;&amp;amp;\alpha_{it} \sum_s x_{its} + \text{mood}_{it} &amp;amp;= 1 &amp;amp;&amp;amp;\forall i,t\\&#xA;&amp;amp;&amp;amp;\text{motivation}_{its} &amp;amp;\in[0,1] &amp;amp;&amp;amp;\forall i,t,s \\&#xA;&amp;amp;&amp;amp;\text{slack}_{ts} &amp;amp;\ge 0 &amp;amp;&amp;amp;\forall t,s \\&#xA;&amp;amp;&amp;amp;\text{mood}_{it} &amp;amp;\in[0,1] &amp;amp;&amp;amp;\forall i,t \\&#xA;&amp;amp;&amp;amp;x_{its}&amp;amp;\in \{0,1\} &amp;amp;&amp;amp;\forall i,t,s\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the Dantzig-Wolfe reformulation, introduce &lt;span class=&quot;math-container&quot;&gt;$\lambda_{ir} \ge 0$&lt;/span&gt; and substitute &lt;span class=&quot;math-container&quot;&gt;$\text{motivation}_{its} = \sum_r \text{motivation}_{its}^r \lambda_{ir}$&lt;/span&gt; in the (objective and) complicating constraints to obtain the master problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;\sum_t \sum_s \text{slack}_{ts} \\&#xA;&amp;amp;\text{subject to} &amp;amp;\sum_i \sum_r \text{motivation}_{its}^r \lambda_{ir} + \text{slack}_{ts} &amp;amp; = \text{demand}_{ts} &amp;amp;&amp;amp;\forall t,s &amp;amp;&amp;amp;\text(\text{$\pi_{ts}$ free})\\&#xA;&amp;amp;&amp;amp;\sum_r \lambda_{ir} &amp;amp;= 1 &amp;amp;&amp;amp;\forall i &amp;amp;&amp;amp;\text(\text{$\mu_i$ free})\\&#xA;&amp;amp;&amp;amp;\lambda_{ir} &amp;amp;\in\mathbb{Z}^+ &amp;amp;&amp;amp;\forall i,r\\&#xA;&amp;amp;&amp;amp;\text{slack}_{ts} &amp;amp;\ge 0 &amp;amp;&amp;amp;\forall t,s&#xA;\end{align}&lt;/span&gt;&#xA;The reduced cost of &lt;span class=&quot;math-container&quot;&gt;$\lambda_{ir}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$0-\sum_{t,s} \pi_{ts} \text{motivation}_{its}^r - \mu_i$&lt;/span&gt;,&#xA;so the subproblem for block &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;0-\sum_{t,s} \pi_{ts} \text{motivation}_{its} - \mu_i \\&#xA;&amp;amp;\text{subject to} &amp;amp;-M(1-x_{its}) \le \text{motivation}_{its} - \text{mood}_{it} &amp;amp;\le M(1-x_{its}) &amp;amp;&amp;amp;\forall t,s \\&#xA;&amp;amp;&amp;amp;\text{motivation}_{its} &amp;amp;\le x_{its} &amp;amp;&amp;amp; \forall t,s \\\&#xA;&amp;amp;&amp;amp;\alpha_{it} \sum_s x_{its} + \text{mood}_{it} &amp;amp;= 1 &amp;amp;&amp;amp;\forall t\\&#xA;&amp;amp;&amp;amp;\text{motivation}_{its} &amp;amp;\in[0,1] &amp;amp;&amp;amp;\forall t,s \\&#xA;&amp;amp;&amp;amp;\text{mood}_{it} &amp;amp;\in[0,1] &amp;amp;&amp;amp;\forall t \\&#xA;&amp;amp;&amp;amp;x_{its}&amp;amp;\in \{0,1\} &amp;amp;&amp;amp;\forall t,s\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;When you solve the LP relaxation of the restricted master problem, be sure to impose &lt;span class=&quot;math-container&quot;&gt;$\lambda_{ir} \ge 0$&lt;/span&gt; (instead of &lt;span class=&quot;math-container&quot;&gt;$\lambda_{ir} \in [0,1]$&lt;/span&gt;), as discussed in &lt;a href=&quot;https://or.stackexchange.com/questions/608/variable-bounds-in-column-generation&quot;&gt;Variable bounds in column generation&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can initialize with trivial columns (one per block &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;) that correspond to &lt;span class=&quot;math-container&quot;&gt;$\text{motivation}_{its}=x_{its}=0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\text{mood}_{it}=1$&lt;/span&gt;.  The first master solve will thus yield &lt;span class=&quot;math-container&quot;&gt;$\text{slack}_{ts}=\text{demand}_{ts}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda_{ir}=1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;By request, here is SAS code that uses automated Dantzig-Wolfe decomposition:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;proc optmodel;&#xA;   /* declare sets and parameters */&#xA;   set ISET, TSET, SSET;&#xA;   num alpha {ISET, TSET};&#xA;   num demand {TSET, SSET};&#xA;&#xA;   /* read input data here */&#xA;&#xA;   /* declare decision variables */&#xA;   var motivation {ISET, TSET, SSET} &amp;gt;= 0 &amp;lt;= 1;&#xA;   var slack {TSET, SSET} &amp;gt;= 0;&#xA;   var mood {ISET, TSET} &amp;gt;= 0 &amp;lt;= 1;&#xA;   var x {ISET, TSET, SSET} binary;&#xA;&#xA;   /* declare objective */&#xA;   minimize z = sum {t in TSET, s in SSET} slack[t,s];&#xA;&#xA;   /* declare constraints */&#xA;   con SatisfyDemand {t in TSET, s in SSET}:&#xA;      sum {i in ISET} motivation[i,t,s] + slack[t,s] = demand[t,s];&#xA;&#xA;   con Indicator {i in ISET, t in TSET, s in SSET}:&#xA;      x[i,t,s] = 1 implies motivation[i,t,s] = mood[i,t]&#xA;   suffixes=(block=i);&#xA;&#xA;   con MotivationImpliesX {i in ISET, t in TSET, s in SSET}:&#xA;      motivation[i,t,s] &amp;lt;= x[i,t,s]&#xA;   suffixes=(block=i);&#xA;&#xA;   con AlphaMood {i in ISET, t in TSET}:&#xA;      alpha[i,t] * sum {s in SSET} x[i,t,s] + mood[i,t] = 1&#xA;   suffixes=(block=i);&#xA;&#xA;   /* call MILP solver with Dantzig-Wolfe decomposition algorithm */&#xA;   solve with milp / decomp;&#xA;&#xA;   /* write output data here */&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-02-09T16:08:09.757" LastActivityDate="2024-02-09T16:08:09.757" CommentCount="45" ContentLicense="CC BY-SA 4.0" />
  <row Id="11621" PostTypeId="1" CreationDate="2024-02-03T00:30:32.950" Score="2" ViewCount="86" Body="&lt;p&gt;I have an LP of the structure below (omitting some constraints that are not directly applicable for this question).&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{min } c'x$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Ax + By \geq d$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for a given &lt;span class=&quot;math-container&quot;&gt;$A \in R^{m \times a}_{&amp;gt;0}, B \in R^{m \times b}_{&amp;gt;0}, d \in R^m_{&amp;gt;0}, c \in R^a_{&amp;gt;0}$&lt;/span&gt; and decision variables and bounds of &lt;span class=&quot;math-container&quot;&gt;$x \geq 0$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$-M \leq y \leq 0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The open-source solver I am using to solve this LP finds the solution very quickly.  However, I would like to re-formulate the constraint set to only enforce a percentage &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; of the total &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; constraints, where the other &lt;span class=&quot;math-container&quot;&gt;$(1-T)$&lt;/span&gt; constraints would be bound by 0 on the right-hand side as opposed to &lt;span class=&quot;math-container&quot;&gt;$d$&lt;/span&gt;.  By introducing a set of binary variables &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, I can re-formulate the problem as a MILP.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{min } c'x$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Ax + By \geq d'z$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_i z_i \geq mT$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For a smaller subset of my original problem, the solver finds the optimal solution.  However, it struggles to find optimality for the full problem.  One thought I had to remedy the issue was to relax the constraints by introducing slack variables &lt;span class=&quot;math-container&quot;&gt;$s$&lt;/span&gt; instead to preserve the LP.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\text{min } c'x - \lambda s$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$Ax + By = d - s$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$s \leq d$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;One difficulty here is that it is not obvious what to set the penalty &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; term to target a specific &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt;, and I would assume a poor choice of &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; would allow the model to target solutions that maximize slack variables rather than minimize the original objective function.&lt;/p&gt;&#xA;&lt;p&gt;Another thought I had was to iteratively add the constraints up to &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; to the model in the order of how binding they are in the original LP.  However, the other constraints the model has that I have not included would seem to make this not trivial as well.&lt;/p&gt;&#xA;&lt;p&gt;In general, are there other re-formulations or heuristic methods for LPs that feature a toggle on how many constraints are picked to be &amp;quot;forced&amp;quot;?&lt;/p&gt;&#xA;" OwnerUserId="3255" LastEditorUserId="3255" LastEditDate="2024-02-04T00:12:37.353" LastActivityDate="2024-02-04T00:12:37.353" Title="Re-formulating an LP where a subset of constraints can be loosened?" Tags="|mixed-integer-programming|linear-programming|solver|heuristics|lp-relaxation|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11622" PostTypeId="2" ParentId="11618" CreationDate="2024-02-03T12:43:52.857" Score="2" Body="&lt;p&gt;The primal bound of one problem should not be less than dual bound of the other problem.  This suggests a bug somewhere.&lt;/p&gt;&#xA;&lt;p&gt;In a comment, @Hubcity wrote &amp;quot;For the x[0] &amp;gt;= 100 it reports a primal bound and dual bound of 6.5 with a gap of 0%. In the logging it does not show any Branch &amp;amp; Bound exploration. It returns an answer almost immediately.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Combining these two paragraphs, this suggests there might be a bug in the solver's presolve, and the solver incorrectly solved the problem in presolve. Bugs in presolve exist even in &amp;quot;mature&amp;quot; solvers. As confirmed by the OP's edits in response to my comment suggesting this possibility, a bug in presolve does appear to be the culprit in this case, because the discrepancy disappeared when presolve was turned off.&lt;/p&gt;&#xA;" OwnerUserId="68" LastActivityDate="2024-02-03T12:43:52.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11623" PostTypeId="2" ParentId="9064" CreationDate="2024-02-03T16:47:00.087" Score="0" Body="&lt;p&gt;CPLEX ships with sample source code in multiple languages. If you go to /cplex/examples/src/python, you four examples doing Benders decomposition: benders.py; bendersatsp.py; bendersatsp2.py; and facility.py.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-02-03T16:47:00.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11624" PostTypeId="1" AcceptedAnswerId="11625" CreationDate="2024-02-03T19:27:13.057" Score="2" ViewCount="95" Body="&lt;p&gt;I am working on a problem that I think can be solved as an extension to the assignment problem, but am open to hear about other ways to solve.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;&lt;strong&gt;PROBLEM&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are a lot of colored boxes. For each color there are many different boxes that contain different number of items (some may contain 0 items, in which case we ignore this box). The goal is combine the different colored boxes into groups so that each group contains 1 box of each available color and when we remove the same number of items from each box in each group (so there will be at least 1 box with 0 items in it in each group) we minimize the number of items still in the boxes.&lt;/p&gt;&#xA;&lt;p&gt;for example, using the following example:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{bmatrix}90 &amp;amp; 80 &amp;amp; 75 &amp;amp; 70\\55 &amp;amp; 85 &amp;amp; 35 &amp;amp; 65\\125 &amp;amp; 95 &amp;amp; 90 &amp;amp; 95\\45 &amp;amp; 110 &amp;amp; 95 &amp;amp; 115\\50 &amp;amp; 100 &amp;amp; 90 &amp;amp; 100\end{bmatrix}$$&lt;/span&gt;&#xA;Where each row represents boxes of a particular color and each column represents the number of items in each of the boxes. Here we have 5 different colors and 4 different boxes in each color. While in this example there are no empty boxes, there could be empty boxes. Basically I want to permute the rows in such a way that a number of groups are formed (4 in this case) such that each group contains only 1 box of each color and for each group we subtract the number of items in each box from the box with the minimum number of items (giving us the remaining items) and sum those remaining items up. Do this for each group, then sum up the remaining items from every group. The goal is to minimize this total remaining items count.&lt;/p&gt;&#xA;&lt;p&gt;So for the above matrix one of several optimal solutions would be:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{bmatrix}75 &amp;amp; 70 &amp;amp; 80 &amp;amp; 90\\55 &amp;amp; 65 &amp;amp; 35 &amp;amp; 85\\125 &amp;amp; 90 &amp;amp; 95 &amp;amp; 95\\115 &amp;amp; 110 &amp;amp; 45 &amp;amp; 95\\100 &amp;amp; 100 &amp;amp; 50 &amp;amp; 900\end{bmatrix}$$&lt;/span&gt;&#xA;Where the sum of each element in a column - min element of each column and the sum of those differences &lt;span class=&quot;math-container&quot;&gt;$$\begin{bmatrix}195 &amp;amp; 110 &amp;amp; 130 &amp;amp; 30\end{bmatrix} = \begin{bmatrix}465\end{bmatrix}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I get optimal solutions to small problems like this, but I need to be able to go up to 24x24 size matrices and when I get to larger matrices my model will run forever. I have let it run up to 48 hours with the following problem without finding an optimal solution:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{bmatrix}90 &amp;amp; 76 &amp;amp; 75 &amp;amp; 70 &amp;amp; 50 &amp;amp; 74 &amp;amp; 12 &amp;amp; 68 &amp;amp; 70\\35 &amp;amp; 85 &amp;amp; 55 &amp;amp; 65 &amp;amp; 48 &amp;amp; 101 &amp;amp; 70 &amp;amp; 83 &amp;amp; 0\\125 &amp;amp; 95 &amp;amp; 90 &amp;amp; 105 &amp;amp; 59 &amp;amp; 120 &amp;amp; 36 &amp;amp; 73 &amp;amp; 59\\45 &amp;amp; 110 &amp;amp; 95 &amp;amp; 115 &amp;amp; 104 &amp;amp; 83 &amp;amp; 37 &amp;amp; 71 &amp;amp; 0\\60 &amp;amp; 105 &amp;amp; 80 &amp;amp; 75 &amp;amp; 59 &amp;amp; 62 &amp;amp; 93 &amp;amp; 88 &amp;amp; 59\\45 &amp;amp; 65 &amp;amp; 110 &amp;amp; 95 &amp;amp; 47 &amp;amp; 31 &amp;amp; 81 &amp;amp; 34 &amp;amp; 0\\38 &amp;amp; 51 &amp;amp; 107 &amp;amp; 41 &amp;amp; 69 &amp;amp; 99 &amp;amp; 115 &amp;amp; 48 &amp;amp; 51\\47 &amp;amp; 85 &amp;amp; 57 &amp;amp; 71 &amp;amp; 92 &amp;amp; 77 &amp;amp; 109 &amp;amp; 36 &amp;amp; 0\\39 &amp;amp; 63 &amp;amp; 97 &amp;amp; 49 &amp;amp; 118 &amp;amp; 56 &amp;amp; 92 &amp;amp; 61 &amp;amp; 56\\47 &amp;amp; 101 &amp;amp; 71 &amp;amp; 60 &amp;amp; 88 &amp;amp; 109 &amp;amp; 52 &amp;amp; 90 &amp;amp; 52\end{bmatrix}$$&lt;/span&gt;&#xA;It will find a feasible solution within a minute, but make no progress the rest of the time. It may be that I need to run it with an early stopping routine and take the best feasible solution, but I am hoping to get some feedback on how to improve constraints to improve the solution finding.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;&lt;strong&gt;WHAT I HAVE TRIED&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have coded this using ortools CP-SAT solver. The code is shown below, but I have let this run for over 48 hours without finding an optimal solution. It finds a good feasible solution within 1 minute and then no further updates for the remaining 48 hours. I realize that there are &lt;span class=&quot;math-container&quot;&gt;$(8!)^{10}$&lt;/span&gt; combinations (my math may be wrong but you get the point), but I was hoping the solver could find an optimal solution quicker than 48 hours, so I feel I may be missing a critical constraint in my model or some symmetry breaking constraint or some hint that may speed the solver.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from ortools.sat.python import cp_model&#xA;import pandas as pd&#xA;from threading import Timer, Lock&#xA;&#xA;def solve_assignment(cost, groups):&#xA;&amp;quot;&amp;quot;&amp;quot;&#xA;Solve assignment problem of reducing cost of assigning boxwe to groups&#xA;Arguments:  cost: cost matrix of assigning item&#xA;            groups: list of groups&#xA;&#xA;Returns:    solution_list: list of dictionaries [Box, Color, Group, Cost] minimizing the costs,&#xA;            status:  status of solver - string (OPTIMAL, FEASIBLE, INFEASIBLE)&#xA;&amp;quot;&amp;quot;&amp;quot;&#xA;maxL = max([max(map(int, i)) for i in cost]) + 1&#xA;num_colors = len(cost)&#xA;num_boxes = len(cost[1])&#xA;num_groups = len(groups)&#xA;all_colors = range(num_colors)&#xA;all_boxes = range(num_boxes)&#xA;all_groups = range(num_groups)&#xA;&#xA;# _____________________&#xA;# Create Model Object&#xA;# ---------------------&#xA;model = cp_model.CpModel()&#xA;&#xA;# -----------------------&#xA;# Create Model Variables&#xA;# -----------------------&#xA;# objective is our objective variable&#xA;objective = model.NewIntVar(0, 1000000, 'objective')&#xA;&#xA;# Minimum length in each group&#xA;min_length = [model.NewIntVar(0, 200000, f'min_length_{g}') for g in all_groups]&#xA;&#xA;# Helper variables to find minimum non-zero value&#xA;smallest = [[[model.NewBoolVar(f'smallest_{g}{c}{b}') for b in all_boxes] for c in all_colors] for g in all_groups]&#xA;yi = [[[model.NewIntVar(0, 200000, f'yi_{g}{c}{b}') for b in all_boxes] for c in all_colors] for g in all_groups]&#xA;&#xA;# min_length[g] * M (length of group[g] (used for objective)&#xA;mmin_length = [model.NewIntVar(0, 200000, f'max_length_{g}') for g in all_groups]&#xA;sum_g = [model.NewIntVar(0, 2000000, f'sum_{g}') for g in all_groups]&#xA;&#xA;# Indicator Variables for color/reel in a group x[group, color, reel]&#xA;X = [[[model.NewBoolVar(f'x[{g},{c},{b}]') for b in all_boxes] for c in all_colors] for g in all_groups]&#xA;&#xA;# -------------------------&#xA;# Create Model Constraints&#xA;# -------------------------&#xA;# Each group is assigned at most one box from each color (0 length reels don't need to be assigned).&#xA;for g in all_groups:&#xA;    [model.Add(sum(X[g][c][b] for b in all_boxes) &amp;lt;= 1) for c in all_colors]&#xA;&#xA;# Each box from every color is assigned to at most one group&#xA;for b in all_boxes:&#xA;    [model.Add(sum(X[g][c][b] for g in all_groups) &amp;lt;= 1) for c in all_colors]&#xA;&#xA;# Must have the correct number of boxes in each group&#xA;for g in all_groups:&#xA;    model.Add(sum(X[g][c][b] for b in all_boxes for c in all_colors) == groups[g])&#xA;&#xA;# Don't use boxes that have 0 items&#xA;for g in all_groups:&#xA;    for b in all_boxes:&#xA;        for c in all_colors:&#xA;            if cost[c][b] == 0:&#xA;                model.Add(X[g][c][b] == 0)&#xA;&#xA;# Determine smallest non-zero item count in group - Because some X[g][c][r]'s will be zero&#xA;for g in all_groups:&#xA;    for c in all_colors:&#xA;        for b in all_boxes:&#xA;            # smallest[g][c][r] == True if X[g][c][r] == 1&#xA;            model.Add(X[g][c][b] &amp;gt; 0).OnlyEnforceIf(smallest[g][c][b])&#xA;&#xA;            # smallest[g][c][r] == False if X[g][c][r] == 0&#xA;            model.Add(X[g][c][b] == 0).OnlyEnforceIf(smallest[g][c][b].Not())&#xA;&#xA;            # yi[g][c][r] == cost[c][r] if smallest[g][c][r] == True&#xA;            model.Add(yi[g][c][b] == cost[c][b]).OnlyEnforceIf(smallest[g][c][b])&#xA;&#xA;            # Set yi[g][c][r] to a large enough value that it can't be min if smallest[g][c][r] == False&#xA;            model.Add(yi[g][c][b] == maxL).OnlyEnforceIf(smallest[g][c][b].Not())&#xA;&#xA;    # min_length[g] = min(yi[g][c][r] for c in all_colors for r in all_reels)&#xA;    model.AddMinEquality(min_length[g], [yi[g][c][b] for c in all_colors for b in all_boxes])&#xA;&#xA;# Determine M*min_length in a group (to use in cost function)&#xA;# sum(C[g][c][b] - min_length[g]) is same as sum(sum_g[g] - group_length[g]*min_length[g])&#xA;for g in all_groups:&#xA;    model.Add(sum_g[g] == sum(cost[c][b]*X[g][c][b] for c in all_colors for b in all_boxes))&#xA;    model.AddMultiplicationEquality(mmin_length[g], min_length[g], groups[g])&#xA;&#xA;# --------------&#xA;# Break symmetry&#xA;# --------------&#xA;# TODO - Find ways to break symmetry&#xA;# Can swap if y[g1][c1][r1] - y[g2][c2][r2] &amp;lt;= y[g2][c2][r2]-min_g[2] and y[g1][c1][r1]-min_g[1]&#xA;&#xA;# Objective cost - Minimize the differences between box item counts in each group (same as min(sum_g-m*min))&#xA;model.Add(objective == sum(sum_g[g] - mmin_length[g] for g in all_groups))&#xA;model.Minimize(objective)&#xA;&#xA;# ---------&#xA;# Add Hint&#xA;# ---------&#xA;&#xA;&#xA;# Setup Early Stopping when solutions don't improve within time limit (s)&#xA;#solution_printer = PrintLogger([objective], early_stopping)&#xA;&#xA;# -------------------------------------&#xA;# Create a solver and solve the model&#xA;# -------------------------------------&#xA;solver = cp_model.CpSolver()&#xA;solver.parameters.num_search_workers = 8&#xA;&#xA;# Sets a time limit of approx 48 hours.&#xA;solver.parameters.max_time_in_seconds = 173000.0&#xA;# solver.parameters.search_branching = cp_model.AUTOMATIC_SEARCH&#xA;&#xA;# Solve the Model&#xA;status = solver.Solve(model)&#xA;#status = solver.SolveWithSolutionCallback(model, solution_printer)&#xA;#solution_printer.clean()&#xA;&#xA;solution_list = []&#xA;print(solver.StatusName(status))&#xA;if status == cp_model.OPTIMAL or status == cp_model.FEASIBLE:&#xA;    for g in all_groups:&#xA;        for c in all_colors:&#xA;            for b in all_boxes:&#xA;                if solver.Value(X[g][c][b]) == 1:&#xA;                    solution_row = {'Box': b, 'Color': c, 'Group': g, 'Cost': cost[c][b]}&#xA;                    solution_list.append(solution_row)&#xA;print('Statistics')&#xA;print(&amp;quot;Min Length: &amp;quot;, [solver.Value(min_length[i]) for i in range(len(min_length))])&#xA;print('  - conflicts : %i' % solver.NumConflicts())&#xA;print('  - branches  : %i' % solver.NumBranches())&#xA;print('  - wall time : %f s' % solver.WallTime())&#xA;&#xA;return solution_list, solver.StatusName()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And it can be run with the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if __name__ == '__main__':&#xA;&#xA;'''&#xA;cost =  [[90, 76, 75, 70, 50, 74, 12, 68, 70],&#xA;         [35, 85, 55, 65, 48, 101, 70, 83, 0],&#xA;         [125, 95, 90, 105, 59, 120, 36, 73, 59],&#xA;         [45, 110, 95, 115, 104, 83, 37, 71, 0],&#xA;         [60, 105, 80, 75, 59, 62, 93, 88, 59],&#xA;         [45, 65, 110, 95, 47, 31, 81, 34, 0],&#xA;         [38, 51, 107, 41, 69, 99, 115, 48, 51],&#xA;         [47, 85, 57, 71, 92, 77, 109, 36, 0],&#xA;         [39, 63, 97, 49, 118, 56, 92, 61, 56],&#xA;         [47, 101, 71, 60, 88, 109, 52, 90, 52]]&#xA;&#xA;groups = [10, 10, 10, 10, 10, 10, 10, 10, 6]&#xA;'''&#xA;&#xA;cost = [&#xA;    [70, 75, 80, 90],&#xA;    [35, 55, 65, 85],&#xA;    [90, 95, 95, 125],&#xA;    [45, 95, 110, 115],&#xA;    [50, 90, 100, 100],&#xA;]&#xA;&#xA;groups = [5, 5, 5, 5]&#xA;&#xA;solution, sol = solve_assignment(cost, groups)&#xA;d = pd.DataFrame(solution)&#xA;&#xA;# Calculate the remnant associated with each reel (length - min of group)&#xA;d['Remnant'] = d['Cost'] - d.groupby('Group')['Cost'].transform('min')&#xA;print(sum(d['Remnant']))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I realize there are a lot of combinations to search through and it maybe that this is just a difficult problem, but I'm hoping someone can help me crack this.&lt;/p&gt;&#xA;" OwnerUserId="13158" LastEditorUserId="981" LastEditDate="2024-02-03T22:08:44.603" LastActivityDate="2024-02-03T23:06:22.453" Title="Assignment of colored boxes to groups" Tags="|combinatorial-optimization|or-tools|assignment-problem|cp-sat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11625" PostTypeId="2" ParentId="11624" CreationDate="2024-02-03T23:06:22.453" Score="2" Body="&lt;p&gt;Here's a mixed integer linear programming formulation that I used to find an optimal solution with objective value &lt;span class=&quot;math-container&quot;&gt;$1506$&lt;/span&gt; for your &lt;span class=&quot;math-container&quot;&gt;$10 \times 9$&lt;/span&gt; instance.  Let &lt;span class=&quot;math-container&quot;&gt;$(c_{ij})$&lt;/span&gt; be the given (sparse) cost matrix.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$x_{ijg}$&lt;/span&gt; indicate whether cell &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; (with &lt;span class=&quot;math-container&quot;&gt;$c_{ij} \not= 0$&lt;/span&gt;) is assigned to group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;.  Let decision variable &lt;span class=&quot;math-container&quot;&gt;$y_g$&lt;/span&gt; represent &lt;span class=&quot;math-container&quot;&gt;$\min\limits_{i,j:x_{ijg}=1} c_{ij}$&lt;/span&gt;.  The problem is to minimize&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\sum_g \left(\sum_{i,j} c_{ij} x_{ijg} - n_g y_g\right)$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_g x_{ijg} &amp;amp;=1 &amp;amp;&amp;amp;\text{for all $i,j$} \tag1\label1\\&#xA;\sum_{i,j} x_{ijg} &amp;amp;=n_g &amp;amp;&amp;amp;\text{for all $g$} \tag2\label2\\&#xA;\sum_j x_{ijg} &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for all $i,g$} \tag3\label3\\&#xA;x_{ijg} = 1 &amp;amp;\implies y_g \le c_{ij} &amp;amp;&amp;amp;\text{for all $i,j,g$} \tag4\label4&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} assigns each cell to exactly one group.&#xA;Constraint \eqref{2} assigns exactly &lt;span class=&quot;math-container&quot;&gt;$n_g$&lt;/span&gt; cells to group &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt;.&#xA;Constraint \eqref{3} prevents assigning more than one cell from each row to the same group.&#xA;Indicator constraint \eqref{4} enforces &lt;span class=&quot;math-container&quot;&gt;$y_g \le \min\limits_{i,j:x_{ijg}=1} c_{ij}$&lt;/span&gt;.  For solvers that do not support indicator constraints, you can replace \eqref{4} with a big-M constraint &lt;span class=&quot;math-container&quot;&gt;$y_g - c_{ij} \le M(1-x_{ijg})$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;An optimal solution is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;70  68  50  90  76  75  70  12  74 &#xA;48  70  55 101  85  83  65  35   &#xA;36 125 105  95 120  90  59  73  59 &#xA;45  71  83 104 115  95 110  37   &#xA;62  75  59  93 105  80  88  59  60 &#xA;34  65  47  95 110  81  45  31   &#xA;38  69  48 115 107  99  51  41  51 &#xA;71  85  47  92 109  77  57  36   &#xA;49  63  61  92  97 118  56  39  56 &#xA;60  88  47  90 109 101  52  52  71 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; part of the objective is constant because of \eqref{1}, so you could equivalently maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_g n_g y_g$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2024-02-03T23:06:22.453" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11627" PostTypeId="1" CreationDate="2024-02-05T22:26:00.437" Score="1" ViewCount="168" Body="&lt;p&gt;I'm trying to minimize an MIP model employing a Lagrangian relaxation approach. However, I've encountered an issue where, in certain instances, the lower bound (resulting from the Lagrangian sub-problems) surpasses both the upper bound (resulting from the Master problem) and the optimal solution of the original problem. Consequently, no Lagrangian bound is obtained, as the lower bound continues to outpace the upper bound, while the upper bound steadily decrease. I tried to enhance the accuracy of the models, the issue is still there. The MIP model is attached, I relaxed the second constraint which gives me two subproblems one in x (binary) and z (binary) and one in y (continuous). I use a random multiplier to solve the subproblems, then I use their solutions to add cuts to the master problem and update the Lagrangian multipliers and solve the subproblems again and go on like that. The lower bound is obtained by adding the optimal solutions of the subproblems while the upper bound is obtained by solving the master problem.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/0j871.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0j871.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13171" LastEditorUserId="13171" LastEditDate="2024-02-06T02:59:07.223" LastActivityDate="2024-02-06T04:52:08.977" Title="Lagrangian Relaxation Lower Bound exceeds the Upper bound and the Optimal solution" Tags="|modeling|network-flow|bounds|lagrangian-relaxation|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11628" PostTypeId="2" ParentId="11627" CreationDate="2024-02-06T04:29:24.707" Score="3" Body="&lt;p&gt;That sounds like a good choice for a relaxation, but you haven't explicitly shown how you compute the bounds.  From your description so far, I suspect that you have two errors.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First, the objective value of the master problem does not provide an upper bound.  Instead, an upper bound for a minimization problem comes from a feasible solution.  That is, you must satisfy all of the original constraints, even the complicating constraints that link &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Second, the sum of the subproblem objective values does not provide a lower bound.  Instead, you must compute the Lagrangian function &lt;span class=&quot;math-container&quot;&gt;$L(\pi)$&lt;/span&gt; for the given master dual variables (also known as Lagrange multipliers) &lt;span class=&quot;math-container&quot;&gt;$\pi$&lt;/span&gt;, which are free here because you are relaxing equality constraints.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-02-06T04:52:08.977" LastActivityDate="2024-02-06T04:52:08.977" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11629" PostTypeId="1" CreationDate="2024-02-06T10:27:58.917" Score="1" ViewCount="113" Body="&lt;p&gt;trying to solve a very large problem , using heuremphasis as 3 , cutfreq=0 , scaling =4, run time reduced significantly however ,  solver spends 400 seconds in tree search , but couldn't see any improvement in the solution , so looking for ways to turn it off&lt;/p&gt;&#xA;" OwnerUserId="2958" LastEditorUserId="1228" LastEditDate="2024-02-07T09:24:58.090" LastActivityDate="2024-02-07T09:24:58.090" Title="How to turn off tree search in fico xpress ? Couldn't see relevant documentation" Tags="|optimization|mixed-integer-programming|cplex|gurobi|solver|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11630" PostTypeId="2" ParentId="11629" CreationDate="2024-02-06T14:35:30.377" Score="4" Body="&lt;p&gt;Use &lt;a href=&quot;https://www.fico.com/fico-xpress-optimization/docs/latest/solver/optimizer/HTML/MAXNODE.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;MAXNODE&lt;/a&gt; option to limit the tree search.&lt;/p&gt;&#xA;&lt;p&gt;You might also try setting &lt;a href=&quot;https://www.fico.com/fico-xpress-optimization/docs/latest/solver/optimizer/HTML/HEURSEARCHROOTCUTFREQ.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;HEURSEARCHROOTCUTFREQ&lt;/a&gt; to 1 to run heuristics between each cutting plane round.&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2024-02-06T14:35:30.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11632" PostTypeId="1" CreationDate="2024-02-06T19:59:11.467" Score="1" ViewCount="63" Body="&lt;p&gt;I am working on my actual model.&lt;/p&gt;&#xA;&lt;p&gt;The objective function aims to maximize &lt;strong&gt;the preferences related to each criterion pc&lt;/strong&gt; to select the best contract that fits with the project characteristics( &lt;strong&gt;c1= size, c2= design complexity, c3= construction complexity, c4= flexibility, c5 = site conditions, etc.&lt;/strong&gt;). Totally I have 10 criteria.&#xA;The objective function is as follows :&#xA;maximize sum (alpha(k)*pc(i)*X(i,j))&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;alpha(k) is the weight affected to the criteria c(i),&lt;/li&gt;&#xA;&lt;li&gt;c(i) is the criterion that depends on other parameters, I set of projects&lt;/li&gt;&#xA;&lt;li&gt;X(i,j) binary decision   variable = 1 if the contract i is assigned to the project j and 0&#xA;otherwise, J set of contracts&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Actually, I would like to evaluate the impact of each criterion on the results and the decision variables, that is why I am adding the weights alpha (i) to the objective function.&lt;/p&gt;&#xA;&lt;p&gt;I started by putting the following values : alpha1 = 0.91 and the other ones = 0.01 to test the results of c1, such as sum of alpha(i) = 1, i=1..10&lt;/p&gt;&#xA;&lt;p&gt;I would like to know if there is any method to help me choose the right weights, or it is correct to make my own choice as I did.&lt;/p&gt;&#xA;" OwnerUserId="13115" LastEditorUserId="500" LastEditDate="2024-02-06T20:00:30.320" LastActivityDate="2024-02-08T13:00:29.547" Title="Weighted sum in the objective function" Tags="|linear-programming|multi-objective-optimization|multicriteria-decision-analysis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11634" PostTypeId="1" CreationDate="2024-02-07T03:31:09.820" Score="0" ViewCount="66" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;An airline wants to conduct a given set of scheduled flights with as few airplanes as possible. All&#xA;available airplanes are of the same type. For each flight we know the departure time and the flight&#xA;time. We also know, for any pair of flights i and j, how much time an airplane needs after finishing&#xA;flight i until it can begin flight j (this time will depend in particular on where i ends and where j&#xA;begins).&#xA;Show how to compute efficiently a feasible schedule with as few airplanes as possible.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I feel a greedy approach combined with a priority queue here may be the way to go. Essentially, we:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Sort all flights by their departure time. If two flights have the same departure time, sort them by their arrival time.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Initialize a priority queue to store the arrival time of each flight. The priority queue will always return the smallest arrival time.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For each flight in the sorted list, check if the departure time of the current flight is later than the arrival time of the earliest finished flight (which can be obtained from the priority queue). If it is, then the current flight can be assigned to the airplane that finished the earliest flight. In this case, update the arrival time of the earliest finished flight in the priority queue.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the departure time of the current flight is not later than the arrival time of the earliest finished flight, then the current flight needs a new airplane. In this case, add the arrival time of the current flight to the priority queue.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The minimum number of airplanes needed is the size of the priority queue after all flights have been processed.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;However I'm not sure whether this works or if there's a more ideal way for the problem. I would appreciate any advice.&lt;/p&gt;&#xA;" OwnerUserId="11234" LastEditorUserId="500" LastEditDate="2024-02-07T18:21:44.647" LastActivityDate="2024-02-07T18:21:44.647" Title="Problem 8.17 of Korte and Vygen" Tags="|optimization|combinatorial-optimization|scheduling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11635" PostTypeId="2" ParentId="11634" CreationDate="2024-02-07T04:12:06.920" Score="2" Body="&lt;p&gt;Hints:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;This exercise comes from a chapter on network flow.&lt;/li&gt;&#xA;&lt;li&gt;Source and sink&lt;/li&gt;&#xA;&lt;li&gt;Directed arcs&lt;/li&gt;&#xA;&lt;li&gt;Split node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and replace with arc from &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$i’$&lt;/span&gt; with lower bound &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Minimize cost.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;A few links that tie together the solution approaches discussed in your question and the two current answers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://math.stackexchange.com/questions/4653921/scheduling-jobs-with-fixed-start-and-end-time-on-limited-machines/4654550#4654550&quot;&gt;https://math.stackexchange.com/questions/4653921/scheduling-jobs-with-fixed-start-and-end-time-on-limited-machines/4654550#4654550&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://yetanothermathprogrammingconsultant.blogspot.com/2023/02/assigning-jobs-to-machines-without.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://yetanothermathprogrammingconsultant.blogspot.com/2023/02/assigning-jobs-to-machines-without.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Interval_graph#Applications&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Interval_graph#Applications&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-02-07T18:05:02.260" LastActivityDate="2024-02-07T18:05:02.260" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11636" PostTypeId="1" AcceptedAnswerId="11637" CreationDate="2024-02-07T08:48:11.663" Score="0" ViewCount="99" Body="&lt;p&gt;In recent years, we experience an explosion in the publication of metaheuristics. They claim finding the &lt;strong&gt;global&lt;/strong&gt; optimum of the optimization problems they are applied on.&lt;/p&gt;&#xA;&lt;p&gt;Is that claim correct? Can metaheuristics, they are after all heuristics, determine global optima?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2024-02-07T17:23:10.290" Title="Are Metaheuristics Global Optimizer?" Tags="|optimization|metaheuristics|global|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11637" PostTypeId="2" ParentId="11636" CreationDate="2024-02-07T09:24:04.743" Score="5" Body="&lt;p&gt;Like any heuristic they can locate global optima, but they can't prove that they are global.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2024-02-07T09:24:04.743" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11638" PostTypeId="2" ParentId="11538" CreationDate="2024-02-07T10:44:16.523" Score="1" Body="&lt;p&gt;sure, K-medoids could be expressed as an optimization problem, I recommend you read the paper: Clustering by a means of medoids, Leonard kaufman, peter rousseeuw&#xA;&lt;a href=&quot;https://i.stack.imgur.com/91FmP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/91FmP.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/gYHOR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gYHOR.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13178" LastEditorUserId="36" LastEditDate="2024-02-07T13:46:10.373" LastActivityDate="2024-02-07T13:46:10.373" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11640" PostTypeId="2" ParentId="11636" CreationDate="2024-02-07T17:23:10.290" Score="2" Body="&lt;p&gt;The other answer is correct. From all of the papers I have read on metaheuristics, if they claim that they have found a globally optimum solution, then they are either running it on an known benchmark instance, or they solved it with an exact method for comparison. Sometimes you test your metaheursitic on toy instances, prove it can at least find a global optima there (by calculating the exact answer with your favourite solver), and then test it on instances where we only have approximate lower or upper bounds.&lt;/p&gt;&#xA;&lt;p&gt;If any decent optimization algorithm can explore the &lt;strong&gt;entire&lt;/strong&gt; search space, then it will eventually find a global optima, given enough time. The problem with metaheuristics and heuristics is that they limit the search space in order to find a good solution quickly (which could still be optimal). It is this &amp;quot;hole&amp;quot; in the search that means whatever local solution they give you is not necessarily globally optimal.&lt;/p&gt;&#xA;" OwnerUserId="13181" LastActivityDate="2024-02-07T17:23:10.290" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11641" PostTypeId="2" ParentId="11634" CreationDate="2024-02-07T17:33:26.700" Score="1" Body="&lt;p&gt;This could be seen as a graph coloring problem. The nodes are the possible flights. Draw an edge between two nodes if they are incompatible (how would they be incompatible?)&lt;/p&gt;&#xA;&lt;p&gt;Then find an optimal coloring for the graph. What does the chromatic number give you?&lt;/p&gt;&#xA;" OwnerUserId="13181" LastActivityDate="2024-02-07T17:33:26.700" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11642" PostTypeId="1" CreationDate="2024-02-07T18:17:20.280" Score="2" ViewCount="98" Body="&lt;p&gt;I am working on a workforce scheduling MIP -- given a set of shift candidates (different shapes and sizes of shifts created out of labor demand) and a set of workers, optimally assign the shifts under some hard and soft constraints (demand coverage, worker min weekly/daily hours, etc.). The worker-shift matching is done based on worker and shift tag sets (location, roles like cashier, clerk, etc., department, suborn, etc.). From my observation some instances of this MIP become pretty hard (many times takes a very long time in proving optimality) to solve while some others with similar configuration are quite easy. Is there a way to find out if a problem instance is going to be hard to solve beforehand? I suspect the tag interactions between workers and shifts and/or tag layout (worker having several conflicting tags and shifts having a large permutation set of tags) makes it easier or harder but not sure if there is a way to find that out or derive from the data.&lt;/p&gt;&#xA;" OwnerUserId="12862" LastEditorUserId="12862" LastEditDate="2024-02-07T18:41:02.150" LastActivityDate="2024-03-09T13:06:05.717" Title="Workforce scheduling problem difficulty" Tags="|mixed-integer-programming|scheduling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11643" PostTypeId="2" ParentId="11642" CreationDate="2024-02-08T12:45:00.760" Score="1" Body="&lt;p&gt;You could run a solver for a short time, to evaluate the score of that output on feasibility (broken hard constraints) or unassigned shifts, but even that will take solving time.&lt;/p&gt;&#xA;&lt;p&gt;In practice, when scaling out in size or complexity, &lt;strong&gt;time-bound is typically better than score-bound&lt;/strong&gt;: it's better to switch your mindset from &lt;em&gt;&amp;quot;find the optimal solution&amp;quot;&lt;/em&gt; to &lt;em&gt;&amp;quot;find the best solution in the available time&amp;quot;&lt;/em&gt;, regardless if it's a 1 hour batch job at night or a 2-minute solving while a user is waiting for it (including real-time replanning for workforce scheduling). In the later case, make sure you show the intermediate score to the user that is waiting in front of the screen while it is solving.&lt;/p&gt;&#xA;&lt;p&gt;Once you have that mindset in place, the next question becomes: How long should I solve? To answer that, create a &lt;em&gt;score graph&lt;/em&gt; to &lt;strong&gt;plot the score (fitness function objective) versus time&lt;/strong&gt;. Here's an example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/maoLf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/maoLf.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;With that graph in hand, for a number of datasets, you can have a meaningful conversation with your business people (and those who pay for the cloud hardware costs) on how long it should solve. Is solving another 15 minutes for a 1% improvement worth it? It depends. And that's a business decision!&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2024-02-08T12:45:00.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11644" PostTypeId="2" ParentId="11632" CreationDate="2024-02-08T13:00:29.547" Score="1" Body="&lt;p&gt;We typically &lt;strong&gt;normalize&lt;/strong&gt; on seconds, minutes xor dollars, for as far as that is possible. And then leave it to a &lt;em&gt;business stakeholder alignment meeting&lt;/em&gt; to tweak the weights. But normalization is not always possible.&lt;/p&gt;&#xA;&lt;p&gt;For example, a &amp;quot;shift overtime work&amp;quot; can be measured in number of seconds of overtime. A &amp;quot;travel time minimization&amp;quot; can be measured in seconds of travel time. But it's fundamentally hard to measure and normalize a &amp;quot;rejected day off request&amp;quot; - a form of employee happiness - in seconds or dollars.&lt;/p&gt;&#xA;&lt;p&gt;Just know, there is no &amp;quot;optimal weight&amp;quot; for the constraints. It depends to who you talk too. The financial stakeholder will see a very different weight tuning than the operations stakeholder.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2024-02-08T13:00:29.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11645" PostTypeId="1" CreationDate="2024-02-08T14:54:54.587" Score="0" ViewCount="46" Body="&lt;p&gt;What type of Monte Carlo simulation is suitable for solving this problem? Also, how can we select results after simulation to guarantee feasibility?&lt;a href=&quot;https://i.stack.imgur.com/Vam30.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Vam30.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13146" LastEditorUserId="39" LastEditDate="2024-02-09T15:21:04.337" LastActivityDate="2024-02-09T15:21:04.337" Title="monte carlo for a selection problem" Tags="|optimization|mixed-integer-programming|stochastic-programming|simulation|stochastic-process|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11646" PostTypeId="1" CreationDate="2024-02-08T20:21:24.560" Score="0" ViewCount="40" Body="&lt;p&gt;Can someone guide me on how to utilize the FICO Xpress Python API to invoke Knitro or Xpress SLP, specifically for choosing between local and global optimization methods? I am referring to the version of Knitro that is bundled with FICO Xpress. Previously, I attempted to switch the NLP solver using the following command, but it appears to no longer be effective:&#xA;&lt;code&gt;p.controls.nlpsolver = 1&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Has there been a change in how to properly configure this setting, or is there an alternative approach to select the solver and specify the solve method (local vs. global) within the current version of the FICO Xpress Python API?&lt;/p&gt;&#xA;" OwnerUserId="13085" LastActivityDate="2024-02-08T20:21:24.560" Title="Using Knitro or Xpress SLP via FICO Xpress Python API for Local and Global Solve Methods" Tags="|nonlinear-programming|nonconvex-programming|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11647" PostTypeId="1" CreationDate="2024-02-09T01:43:04.190" Score="0" ViewCount="84" Body="&lt;p&gt;I have developed an inventory optimization model for my warehouse and I want to know, how to validate this model, perform User acceptance testing and deploy it to production environment?&lt;/p&gt;&#xA;" OwnerUserId="12774" LastEditorUserId="500" LastEditDate="2024-02-09T13:46:21.157" LastActivityDate="2024-02-09T13:46:21.157" Title="Deploying optimization model to production environment" Tags="|modeling|inventory|software|industry|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11648" PostTypeId="2" ParentId="11647" CreationDate="2024-02-09T08:10:51.563" Score="1" Body="&lt;p&gt;To validate your model, you need to make sure it captures the dynamics of your system correctly. To do so, you can constrain the model with your historical data (e.g. one month, or one year depending on the nature of your model), and check that it outputs what actually happened in the &amp;quot;real world&amp;quot;. You can check aggregated values of variables (such as monthly flows), KPIs (costs), and more detailed values (inventory level of given product at given hour). Determining how close the details have to be to reality is an empirical question. Aiming for 100% accuracy is neither necessary nor a good idea, as you do not want to replicate noise, data errors, etc.&lt;/p&gt;&#xA;&lt;p&gt;This way you have a baseline or a reference model, on top of which you can safely optimize by removing baseline constraints, or perhaps adding new variables to expand the search space.&lt;/p&gt;&#xA;&lt;p&gt;This will help validate that your model is indeed correct, and make comparisons between optimizations sensible.&lt;/p&gt;&#xA;&lt;p&gt;For user acceptance, I think you need to show them that whatever optimization you are performing are useful. So show them that for example new KPIs with respect to baseline are better.&lt;/p&gt;&#xA;" OwnerUserId="2556" LastActivityDate="2024-02-09T08:10:51.563" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11649" PostTypeId="1" CreationDate="2024-02-10T00:38:16.303" Score="1" ViewCount="101" Body="&lt;p&gt;I have a constraint given as&#xA;&lt;span class=&quot;math-container&quot;&gt;$&#xA;\left|x_n+\beta x_{n+ 1}\right|-\varepsilon_{ky}\left|x_{n}\right|\leq0\hspace{1em}\forall n=1,2...,N&#xA;$&lt;/span&gt; I need to convert this into a convex form to implement in CVX. &lt;span class=&quot;math-container&quot;&gt;$x_n \in \mathcal{C}$&lt;/span&gt; is optimization variable &lt;span class=&quot;math-container&quot;&gt;$\forall n=1,2...,N-1$&lt;/span&gt;,&lt;/p&gt;&#xA;" OwnerUserId="11366" LastEditorUserId="11366" LastEditDate="2024-02-11T19:42:06.603" LastActivityDate="2024-02-11T19:42:06.603" Title="Convex approximation of a constraint" Tags="|mixed-integer-programming|linearization|cvxpy|disciplined-convex-programming|complex-numbers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11650" PostTypeId="2" ParentId="11649" CreationDate="2024-02-10T01:31:13.493" Score="1" Body="&lt;p&gt;The first absolute value appears in a convex manner, so can be left as is in CVX or other convex optimization modeling tool.&lt;/p&gt;&#xA;&lt;p&gt;The second absolute value appears in a non-convex manner. It can be handled exactly (i.e., without approximation) as shown in &lt;a href=&quot;https://docs.mosek.com/modeling-cookbook/mio.html#integer-modeling&quot; rel=&quot;nofollow noreferrer&quot;&gt;section 9.1.6 “Exact absolute value” of Mosek Modeling Cookbook&lt;/a&gt;. I modified that to allow lower and upper bounds on the &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt; to not necessarily have the same absolute value. That might make the formulation tighter and better performing.&lt;/p&gt;&#xA;&lt;p&gt;Introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$b_n$&lt;/span&gt; and continuous variables &lt;span class=&quot;math-container&quot;&gt;$t_n, xPositive_n, xNegative_n$&lt;/span&gt; for each n from 1 to N-2. Let &lt;span class=&quot;math-container&quot;&gt;$-L_n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$U_n$&lt;/span&gt; be lower and upper bounds respectively on those &lt;span class=&quot;math-container&quot;&gt;$x_n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then replace &lt;span class=&quot;math-container&quot;&gt;$|x_n|$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$t_n$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Add the constraints for n from 1 to N-2:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$xPositve_n \ge 0, xNegative_n \ge 0$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_n = xPositive_n - xNegative_n$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$t_n = xPositive_n + xNegative_n$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$xPositive_n \le U_n b_n$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$xNegative_n \le L_n (1 - b_n)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;These constraints force at least one of &lt;span class=&quot;math-container&quot;&gt;$xNegative_n$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$xPositive_n$&lt;/span&gt; to be zero for each n from 1 to N-2, which is what makes the formulation work.&lt;/p&gt;&#xA;&lt;p&gt;To implement this in CVX, you will need to use a Mixed-Integer capable solver.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: I just noticed &lt;span class=&quot;math-container&quot;&gt;$x_n \in \mathcal{C}$&lt;/span&gt;. My formulation assumed the variables are real. If they are complex, I am not aware of any exact formulation compatible with CVX, nor any approximation which would necessarily be good.&lt;/p&gt;&#xA;" OwnerUserId="68" LastEditorUserId="68" LastEditDate="2024-02-10T12:16:24.440" LastActivityDate="2024-02-10T12:16:24.440" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11651" PostTypeId="1" CreationDate="2024-02-10T15:38:01.623" Score="4" ViewCount="134" Body="&lt;p&gt;I am reading these &lt;a href=&quot;https://web.stanford.edu/class/ee364b/lectures/robust_notes.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;notes&lt;/a&gt; from Stanford called &amp;quot;Optimization with uncertain data&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;In section 2.2, Example 2 (page 7), the author mentions the following portfolio problem &lt;span class=&quot;math-container&quot;&gt;$(P)$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max \; t&#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\text{Prob}\left(\sum_i R_i x_i \ge t\right) &amp;amp;\ge 1-\epsilon \\&#xA;\sum_i x_i &amp;amp;= 1 \\&#xA;x_i &amp;amp;\ge 0 \quad \forall i&#xA;\end{align*}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$R_i$&lt;/span&gt; (the random return of each asset &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;) and &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; (the value at risk) are given parameters.&lt;/p&gt;&#xA;&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$R_i \in [\mu_i -\text{u}_i,\mu_i +\text{u}_i]$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$\text{E}(R_i)=\mu_i$&lt;/span&gt;, the author shows that the problem is equivalent to maximizing&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_i \mu_i x_i -\sqrt{2 \log \frac{1}{\epsilon}} \lVert\text{diag}(\text{u})x \rVert_2 &#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\sum_i x_i &amp;amp;= 1 \\&#xA;x_i &amp;amp;\ge 0 \quad \forall i&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And states:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This corresponds to the uncertainty set given by the scaled &lt;span class=&quot;math-container&quot;&gt;$\ell_2$&lt;/span&gt;&#xA;ball&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \mathcal{U}=\{u \in \mathbb{R}^n , \lVert\text{diag}(u)^{-1/2}u \rVert_2 \le \sqrt{2 \log \frac{1}{\epsilon}}\} $$&lt;/span&gt;&#xA;in the robust inequality &lt;span class=&quot;math-container&quot;&gt;$\sum_i (\mu_i+u_i)x_i \le t$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$u\in \mathcal{U}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I don't understand the last quoted part (&lt;span class=&quot;math-container&quot;&gt;$\text{diag}(u)^{-1/2}u$&lt;/span&gt;?) and suspect there is at least one typo (&lt;span class=&quot;math-container&quot;&gt;$\sum_i (\mu_i+u_i)x_i \color{red}{\ge} t$&lt;/span&gt;?). In the end, if I want to solve the initial problem, what formulation do I use ?&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2024-02-12T16:37:05.223" LastActivityDate="2024-03-14T08:08:41.097" Title="Need help understanding robust optimization formulation" Tags="|modeling|robust-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11652" PostTypeId="1" CreationDate="2024-02-10T20:57:17.437" Score="1" ViewCount="153" Body="&lt;p&gt;I'm implementing some algorithms in C++ and I need to solve some linear programs as an intermediate step within the algorithm.&lt;/p&gt;&#xA;&lt;p&gt;I've managed to get the &lt;code&gt;linear_solver&lt;/code&gt; from &lt;a href=&quot;https://developers.google.com/optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;google or-ools&lt;/a&gt; working, as well as &lt;a href=&quot;https://www.gnu.org/software/glpk/&quot; rel=&quot;nofollow noreferrer&quot;&gt;glpk&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My issue is that I need to work with and solve LPs with very high precision integer types - more than 256 bits - in order for the algorithm to be correct (it's complicated but the algorithm can give very incorrect answers if less precision is used). At the moment I'm using &lt;code&gt;mpz_class&lt;/code&gt; and &lt;code&gt;mpf_class&lt;/code&gt; from &lt;a href=&quot;https://gmplib.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;gmp&lt;/a&gt; to store my numbers.&lt;/p&gt;&#xA;" OwnerUserId="13189" LastEditorUserId="491" LastEditDate="2024-02-12T22:13:05.807" LastActivityDate="2024-03-14T04:09:06.093" Title="Multi-precision linear programming solver in C++" Tags="|solver|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11653" PostTypeId="1" CreationDate="2024-02-11T19:27:36.310" Score="0" ViewCount="112" Body="&lt;p&gt;As suggested, this is a new post. I have the following column generation model. The notation is as follows: &lt;span class=&quot;math-container&quot;&gt;$i\in I$&lt;/span&gt; refers to the nurses, &lt;span class=&quot;math-container&quot;&gt;$t\in T$&lt;/span&gt; to the days and &lt;span class=&quot;math-container&quot;&gt;$s\in S$&lt;/span&gt; for the shifts. With the following master problem &lt;span class=&quot;math-container&quot;&gt;$MP$&lt;/span&gt; and the index &lt;span class=&quot;math-container&quot;&gt;$r\in R$&lt;/span&gt; which refers to the roster to be worked:&lt;/p&gt;&#xA;&lt;p&gt;Concerning the variables, &lt;span class=&quot;math-container&quot;&gt;$motivation_{its}$&lt;/span&gt; is the (continuous) shift specific motivation which, together with the slack &lt;span class=&quot;math-container&quot;&gt;$slack_{ts}$&lt;/span&gt; must fulfill the &lt;span class=&quot;math-container&quot;&gt;$demand_{ts}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the subproblem, the shift assignment &lt;span class=&quot;math-container&quot;&gt;$x_{its}$&lt;/span&gt; and the random (with &lt;span class=&quot;math-container&quot;&gt;$\alpha_{it}$&lt;/span&gt;) daily mood &lt;span class=&quot;math-container&quot;&gt;$mood_{it}$&lt;/span&gt;, are used to determine the shift specific motivation &lt;span class=&quot;math-container&quot;&gt;$motivation_{its}$&lt;/span&gt;.&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;\sum_t \sum_s \text{slack}_{ts} \\&#xA;&amp;amp;\text{subject to} &amp;amp;\sum_i \sum_r \text{motivation}_{its}^r \lambda_{ir} + \text{slack}_{ts} &amp;amp; = \text{demand}_{ts} &amp;amp;&amp;amp;\forall t,s &amp;amp;&amp;amp;\text(\text{$\pi_{ts}$ free})\\&#xA;&amp;amp;&amp;amp;\sum_r \lambda_{ir} &amp;amp;= 1 &amp;amp;&amp;amp;\forall i &amp;amp;&amp;amp;\text(\text{$\mu_i$ free})\\&#xA;&amp;amp;&amp;amp;\lambda_{ir} &amp;amp;\in\mathbb{Z}^+ &amp;amp;&amp;amp;\forall i,r\\&#xA;&amp;amp;&amp;amp;\text{slack}_{ts} &amp;amp;\ge 0 &amp;amp;&amp;amp;\forall t,s&#xA;\end{align}&lt;/span&gt;&#xA;And the individual subproblems &lt;span class=&quot;math-container&quot;&gt;$SP(i)$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;-\sum_{t,s} \pi_{ts} \text{motivation}_{its} - \mu_i \\&#xA;&amp;amp;\text{subject to} &amp;amp;-M(1-x_{its}) \le \text{motivation}_{its} - \text{mood}_{it} &amp;amp;\le M(1-x_{its}) &amp;amp;&amp;amp;\forall t,s \\&#xA;&amp;amp;&amp;amp;\text{motivation}_{its} &amp;amp;\le x_{its} &amp;amp;&amp;amp; \forall t,s \\\&#xA;&amp;amp;&amp;amp;\alpha_{it} \sum_s x_{its} + \text{mood}_{it} &amp;amp;= 1 &amp;amp;&amp;amp;\forall t\\&#xA;&amp;amp;&amp;amp;\text{motivation}_{its} &amp;amp;\in[0,1] &amp;amp;&amp;amp;\forall t,s \\&#xA;&amp;amp;&amp;amp;\text{mood}_{it} &amp;amp;\in[0,1] &amp;amp;&amp;amp;\forall t \\&#xA;&amp;amp;&amp;amp;x_{its}&amp;amp;\in \{0,1\} &amp;amp;&amp;amp;\forall t,s\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;This assumes individual nurses, with different regulatory requirements or preferences f.e. However, if this assumption is relaxed, that every nurse is the same, how would this change the model formulation and why should the model be changed?&#xA;For example, as done by &lt;em&gt;&lt;a href=&quot;https://doi.org/10.1002/nav.20201&quot; rel=&quot;nofollow noreferrer&quot;&gt;Purnomo and Bard (2007)&lt;/a&gt;&lt;/em&gt;, they translated the decision variable to be an integer, rather than being binary. Is the necessary as &lt;span class=&quot;math-container&quot;&gt;$motivation^r_{its}$&lt;/span&gt; is continuous&lt;/p&gt;&#xA;&lt;p&gt;EDIT: The new objective function looks like this.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$-\sum_{t,s}^{}\pi_{ts}motivation_{ts}-\min \mu_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;EDIT 2:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;\sum_t \sum_s \text{slack}_{ts} \\&#xA;&amp;amp;\text{subject to} &amp;amp;\sum_r \text{motivation}_{ts}^r \lambda_{r} + \text{slack}_{ts} &amp;amp; = \text{demand}_{ts} &amp;amp;&amp;amp;\forall t,s &amp;amp;&amp;amp;\\&#xA;&amp;amp;&amp;amp;\sum_r \lambda_{r} &amp;amp;= \mid I \mid &amp;amp;&amp;amp; &amp;amp;&amp;amp;\\&#xA;&amp;amp;&amp;amp;\lambda_{r} &amp;amp;\in\mathbb{Z}^+ &amp;amp;&amp;amp;\forall r\\&#xA;&amp;amp;&amp;amp;\text{slack}_{ts} &amp;amp;\ge 0 &amp;amp;&amp;amp;\forall t,s&#xA;\end{align}&lt;/span&gt;&#xA;And the generic subproblems &lt;span class=&quot;math-container&quot;&gt;$SP$&lt;/span&gt;:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\text{minimize} &amp;amp;-\sum_{t,s} \pi_{ts} \text{motivation}_{ts} - \mu \\&#xA;&amp;amp;\text{subject to} &amp;amp;-M(1-x_{ts}) \le \text{motivation}_{ts} - \text{mood}_{t} &amp;amp;\le M(1-x_{ts}) &amp;amp;&amp;amp;\forall t,s \\&#xA;&amp;amp;&amp;amp;\text{motivation}_{ts} &amp;amp;\le x_{ts} &amp;amp;&amp;amp; \forall t,s \\\&#xA;&amp;amp;&amp;amp;\alpha_{t} \sum_s x_{ts} + \text{mood}_{t} &amp;amp;= 1 &amp;amp;&amp;amp;\forall t\\&#xA;&amp;amp;&amp;amp;\text{motivation}_{ts} &amp;amp;\in[0,1] &amp;amp;&amp;amp;\forall t,s \\&#xA;&amp;amp;&amp;amp;\text{mood}_{t} &amp;amp;\in[0,1] &amp;amp;&amp;amp;\forall t \\&#xA;&amp;amp;&amp;amp;x_{ts}&amp;amp;\in \{0,1\} &amp;amp;&amp;amp;\forall t,s\\&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="11914" LastEditDate="2024-04-02T11:47:51.743" LastActivityDate="2024-04-02T11:47:51.743" Title="Exploiting identical subproblems in column generation" Tags="|mixed-integer-programming|column-generation|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11654" PostTypeId="2" ParentId="11653" CreationDate="2024-02-11T19:43:37.513" Score="1" Body="&lt;p&gt;With individual nurses, you generate columns specific to each nurse, use binary variables to indicate which column is used for each nurse, and constraints on the binary variables saying that exactly (or at most, depending on your problem) one column is selected for each nurse.&lt;/p&gt;&#xA;&lt;p&gt;With generic nurses, you generate columns usable by any nurse (so likely fewer columns) and replace the binary variables with nonnegative integer variables indicating how many nurses match to each column. The constraint that exactly/at most one column is used for each individual nurse changes to a single constraint saying that the number of times each column is used totals to exactly/at most the number of nurses available.&lt;/p&gt;&#xA;&lt;p&gt;This is irrespective of whether subproblem variables are binary, general integer or continuous.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-02-11T19:43:37.513" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="11655" PostTypeId="2" ParentId="11652" CreationDate="2024-02-12T09:20:27.403" Score="0" Body="&lt;p&gt;A similar question has been asked &lt;a href=&quot;https://or.stackexchange.com/questions/5167/is-there-a-linear-programming-library-that-natively-supports-fractions-instead-o/5177#5177&quot;&gt;here&lt;/a&gt;. The answers reference a number of exact solvers. I don't know if any solver supports higher but limited precision instead of exact.&lt;/p&gt;&#xA;&lt;p&gt;GLPK itself supports exact arithmetic. It may be more difficult to use from the C++ interface than the command line, but &lt;a href=&quot;https://en.wikibooks.org/wiki/GLPK/Using_the_GLPK_callable_library&quot; rel=&quot;nofollow noreferrer&quot;&gt;is documented in the API&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2024-02-12T09:20:27.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11657" PostTypeId="2" ParentId="11651" CreationDate="2024-02-12T16:46:41.730" Score="0" Body="&lt;p&gt;I believe there is a typo in the document, and perhaps some confusion between parameters &lt;span class=&quot;math-container&quot;&gt;$\text{u}$&lt;/span&gt; and variables &lt;span class=&quot;math-container&quot;&gt;$u$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My understanding is that the initial problem &lt;span class=&quot;math-container&quot;&gt;$(P)$&lt;/span&gt; is equivalent to:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max_x \; \sum_i \mu_i x_i -\sqrt{2 \log \frac{1}{\epsilon}} \lVert\text{diag}(\text{u})x \rVert_2 &#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\sum_i x_i &amp;amp;= 1 \\&#xA;x_i &amp;amp;\ge 0 \quad \forall i&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\max_{x,t,u} \; t&#xA;$$&lt;/span&gt;&#xA;subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\sum_i x_i &amp;amp;= 1 \\&#xA;x_i &amp;amp;\ge 0 \quad \forall i \\&#xA;\sum_i (\mu_i + u_i\text{u}_i)x_i &amp;amp;\ge t \\&#xA;\lVert u  \rVert_2 &amp;amp;\le \sqrt{2 \log \frac{1}{\epsilon}}&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2024-02-13T08:06:23.270" LastActivityDate="2024-02-13T08:06:23.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11658" PostTypeId="2" ParentId="11652" CreationDate="2024-02-13T03:26:07.280" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;https://soplex.zib.de/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Soplex solver&lt;/a&gt; is a simplex-based LP solver, available as a C++ library. It supports regular (double precision) input, quad precision computation, and can provide exact solutions using iterative refinement and rational exact arithmetic.&lt;/p&gt;&#xA;&lt;p&gt;While I have never used it myself directly, it is the default LP solver in SCIP. I would recommend checking the documentation to see how you can use the higher-precision functionality.&lt;/p&gt;&#xA;" OwnerUserId="3598" LastActivityDate="2024-02-13T03:26:07.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11659" PostTypeId="1" CreationDate="2024-02-13T07:59:04.830" Score="1" ViewCount="76" Body="&lt;p&gt;Can you suggest good books to refer regarding coding operation research algorithms like transportation algorithm, assignment algorithm etc&#xA;What are the best practices for coding those algorithms&lt;/p&gt;&#xA;" OwnerUserId="12868" LastEditorUserId="36" LastEditDate="2024-02-13T14:14:39.533" LastActivityDate="2024-02-13T14:14:39.533" Title="Coding Operation research algorithms" Tags="|linear-programming|reference-request|books|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11660" PostTypeId="1" CreationDate="2024-02-13T08:48:45.587" Score="0" ViewCount="69" Body="&lt;p&gt;What are the algorithms used to assign orders to sewing lines based on order priority, line capacity, time taken to sew garments, due dates, specialization  of lines etc.&lt;/p&gt;&#xA;" OwnerUserId="12868" LastActivityDate="2024-02-14T19:08:17.273" Title="Sewing lines orders assignment" Tags="|optimization|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11661" PostTypeId="2" ParentId="11660" CreationDate="2024-02-13T09:03:06.330" Score="2" Body="&lt;p&gt;This is kind of scheduling problem. Depending on the exact problem, the characteristics of the inputs, and the reason of the resolution, many and different optimization methods might be relevant.&lt;/p&gt;&#xA;&lt;p&gt;A good starting point is:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Scheduling (Pinedo, 2015) &lt;a href=&quot;https://link.springer.com/book/10.1007/978-3-319-26580-3&quot; rel=&quot;nofollow noreferrer&quot;&gt;DOI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2024-02-13T09:03:06.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11662" PostTypeId="1" CreationDate="2024-02-13T12:47:41.107" Score="-1" ViewCount="61" Body="&lt;p&gt;i have this constraint right here, which is not linear. How would i linearize such a product. &lt;span class=&quot;math-container&quot;&gt;$number_t$&lt;/span&gt; is a positive integer and &lt;span class=&quot;math-container&quot;&gt;$new_t$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$reset_t$&lt;/span&gt; are binary.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$number_t = (number_{t-1}+new_t)\cdot (1-reset_t)$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="13061" LastEditorUserId="500" LastEditDate="2024-02-13T13:46:27.790" LastActivityDate="2024-02-13T13:46:27.790" Title="How to linearize a product of an integer and a binary variable" Tags="|linear-programming|integer-programming|linearization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11664" PostTypeId="2" ParentId="11662" CreationDate="2024-02-13T13:17:45.797" Score="0" Body="&lt;p&gt;Some comments already hinted at questions that give you the answer. In your specific example, this translates to the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0 \leq number_t \leq (number_{t−1}+new_t) \newline&#xA;number_t \geq (number_{t−1}+new_t)-reset_tM \newline&#xA;number_t \leq M(1−reset_t)&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$reset_t = 0$&lt;/span&gt;, through the first and second constraint we force &lt;span class=&quot;math-container&quot;&gt;$number_t$&lt;/span&gt; to take value &lt;span class=&quot;math-container&quot;&gt;$number_{t-1}+new_t$&lt;/span&gt;. If &lt;span class=&quot;math-container&quot;&gt;$reset_t=1$&lt;/span&gt;, through the first and third constraint, we force &lt;span class=&quot;math-container&quot;&gt;$number_t$&lt;/span&gt; to be 0. Where &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; is a large enough number.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2024-02-13T13:17:45.797" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11666" PostTypeId="1" CreationDate="2024-02-13T14:42:24.730" Score="2" ViewCount="99" Body="&lt;p&gt;I am running a QCQP model in the following setup&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;AMPL;&lt;/li&gt;&#xA;&lt;li&gt;MUMPS 5.6.2; And&lt;/li&gt;&#xA;&lt;li&gt;Ipopt 3.14.14, with the following parameters (cf. &lt;a href=&quot;https://coin-or.github.io/Ipopt/OPTIONS.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://coin-or.github.io/Ipopt/OPTIONS.html&lt;/a&gt;):&#xA;&lt;ul&gt;&#xA;&lt;li&gt;check_derivatives_for_naninf=yes;&lt;/li&gt;&#xA;&lt;li&gt;hessian_approximation=limited-memory;&lt;/li&gt;&#xA;&lt;li&gt;hessian_approximation_space=nonlinear-variables;&lt;/li&gt;&#xA;&lt;li&gt;inf_pr_output=internal;&lt;/li&gt;&#xA;&lt;li&gt;line_search_method=cg-penalty;&lt;/li&gt;&#xA;&lt;li&gt;max_iter=10000000;&lt;/li&gt;&#xA;&lt;li&gt;mu_strategy=adaptive.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;With the following Ipopt header.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Number of nonzeros in equality constraint Jacobian...:     3072&#xA;Number of nonzeros in inequality constraint Jacobian.:        0&#xA;Number of nonzeros in Lagrangian Hessian.............:        0&#xA;Total number of variables............................:     1024&#xA;                     variables with only lower bounds:        0&#xA;                variables with lower and upper bounds:     1024&#xA;                     variables with only upper bounds:        0&#xA;Total number of equality constraints.................:       65&#xA;Total number of inequality constraints...............:        0&#xA;        inequality constraints with only lower bounds:        0&#xA;   inequality constraints with lower and upper bounds:        0&#xA;        inequality constraints with only upper bounds:        0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And the following iteration log.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls&#xA;33480  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;33481  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;33482  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;33483  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;33484  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;33485  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;33486  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;33487  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;33488  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;33489  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls&#xA;33490  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;33491  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;33492  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;33493  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;33494  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;33495  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;33496  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;33497  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;33498  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;33499  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls&#xA;33500  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;33501  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;33502  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;33503  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;33504  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;33505  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;33506  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;33507  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;33508  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;33509  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls&#xA;(REPEATS) 33510  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33511  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33512  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;(REPEATS) 33513  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33514  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33515  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;(REPEATS) 33516  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33517  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33518  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;(REPEATS) 33519  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls&#xA;(REPEATS) 33520  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33521  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;(REPEATS) 33522  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33523  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33524  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;(REPEATS) 33525  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33526  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33527  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;(REPEATS) 33528  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33529  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls&#xA;(REPEATS) 33530  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;(REPEATS) 33531  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33532  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33533  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;(REPEATS) 33534  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33535  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33536  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;(REPEATS) 33537  3.1818420e-01 9.96e-01 3.36e-02  -1.2 3.24e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33538  3.1812523e-01 9.96e-01 3.12e-02  -1.2 3.00e-07    -  1.00e+00 1.00e+00c  1&#xA;(REPEATS) 33539  3.1799341e-01 9.96e-01 5.23e+04  -1.2 1.21e-06    -  1.00e+00 4.96e-01c  2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that, the first 30 log entries keep repeating. In my execution, this behavior keeps up for hours. Unfortunately, I am too naive in the realms of Interior Point Methods (IPM), thus I am not that keen in what regards conjecturing the possible reason for this. I would like to know if someone has any suggestion of what may be the reason.&lt;/p&gt;&#xA;&lt;p&gt;By the way, the inputted problem is feasible.&lt;/p&gt;&#xA;" OwnerUserId="2862" LastEditorUserId="491" LastEditDate="2024-02-15T19:59:09.990" LastActivityDate="2024-02-15T19:59:09.990" Title="Cycling in Ipopt" Tags="|ampl|interior-point-method|ipopt|" AnswerCount="0" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="11667" PostTypeId="1" AcceptedAnswerId="11668" CreationDate="2024-02-13T19:25:12.277" Score="3" ViewCount="122" Body="&lt;p&gt;From what I understand, most solvers use a user provided solution by first detecting if it feasible.&lt;/p&gt;&#xA;&lt;p&gt;If it is feasible, its objective value is used as a first bound for the branch and cut tree, this bound will be used to prune nodes.&lt;/p&gt;&#xA;&lt;p&gt;I would like to know if the (commercial) solvers use this heuristic provided solution for other means? For instance, does it use the solution to help choosing a branching strategy? Is it not used at all appart from its objective value if feasible?&lt;/p&gt;&#xA;" OwnerUserId="35" LastActivityDate="2024-02-13T20:37:32.933" Title="What does a solver do with a MIP warmstart solution?" Tags="|mixed-integer-programming|cplex|gurobi|solver|warm-start|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11668" PostTypeId="2" ParentId="11667" CreationDate="2024-02-13T20:37:32.933" Score="3" Body="&lt;p&gt;Besides getting the initial primal bound provided by the (feasible) starting solution, one possible use for a warm start is to seed a heuristic that looks for an even better feasible solution.&lt;/p&gt;&#xA;&lt;p&gt;Given a warm start that is not feasible, some solvers will attempt to improve the starting solution to get a feasible incumbent.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-02-13T20:37:32.933" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11669" PostTypeId="2" ParentId="5645" CreationDate="2024-02-14T03:37:14.010" Score="0" Body="&lt;p&gt;Kendall notation is okay up until a point for simple queueing systems. I have found that when I have a network of queues each having substantially different properties that the notation gets awkward. Here is a post: &lt;a href=&quot;https://stats.stackexchange.com/questions/638810/kendalls-notation-for-kelly-networks&quot;&gt;Kendall's Notation for Kelly Networks?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As Chrisoph mentioned in the chat (+1), you could consider &lt;a href=&quot;https://en.wikipedia.org/wiki/Business_Process_Model_and_Notation&quot; rel=&quot;nofollow noreferrer&quot;&gt;BPMN&lt;/a&gt; as a diagrammatic way to symbolize your DES. Although it is possible to throw too much detail in for clients to quickly understand, such a diagrammatic approach to communicating discrete event simulation can be very effective.&lt;/p&gt;&#xA;&lt;p&gt;However, if you want something more familiar to a mathematician I suggest you look into &lt;a href=&quot;https://en.wikipedia.org/wiki/DEVS&quot; rel=&quot;nofollow noreferrer&quot;&gt;Discrete Event System Specification (DEVS)&lt;/a&gt;. There are actually some variants of this notation, but I am unfamiliar with their differences at this time. Pick whatever helps you clearly understand and communicate.&lt;/p&gt;&#xA;&lt;p&gt;Even more generality can be obtained, if needed, by considering your DES as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Timed_event_system&quot; rel=&quot;nofollow noreferrer&quot;&gt;timed event system (TES)&lt;/a&gt;. But this may be more general than needed for your purposes.&lt;/p&gt;&#xA;" OwnerUserId="10338" LastActivityDate="2024-02-14T03:37:14.010" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11670" PostTypeId="1" CreationDate="2024-02-14T03:58:55.833" Score="2" ViewCount="27" Body="&lt;p&gt;I have occasionally heard the terms &amp;quot;process-based DES&amp;quot; and &amp;quot;event-based DES&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;For example, from &lt;a href=&quot;https://simpy.readthedocs.io/en/latest/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SimPy&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;SimPy is a process-based discrete-event simulation framework based on standard Python.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Discrete-event_simulation#Three-Phased_Approach&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The three-phase approach is a refinement of the event-based approach in which simultaneous events are ordered so as to make the most efficient use of computer resources.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://ciw.readthedocs.io/en/latest/Background/mechanisms.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ciw&lt;/a&gt; also mentions something that I would infer to be potentially event-based:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Ciw uses the event scheduling approach [SW14], similar to the three-phase approach. In the event scheduling approach, three types of events take place: A Events move the clock forward, B Events are prescheduled events, and C Events are events that arise because a B Event has happened.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The citation above, [SW14], is&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Robinson. Simulation: the practice of model development and use. Palgrave Macmillan, 2014.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I got my hands on that book. I've implemented the three-phase approach described there. But I am still not 100% confident in my understanding of the distinction between &amp;quot;event-based&amp;quot; vs &amp;quot;process-based&amp;quot; DES.&lt;/p&gt;&#xA;&lt;p&gt;I have also implemented some simulations using SimPy, but again not sure why exactly it is &amp;quot;process-based&amp;quot;. It also keeps a min heap of events as did the three-phase approach implementation.&lt;/p&gt;&#xA;&lt;p&gt;Can the distinction be made explicit (and formal, if possible)?&lt;/p&gt;&#xA;" OwnerUserId="10338" LastEditorUserId="36" LastEditDate="2024-02-14T13:27:20.373" LastActivityDate="2024-02-14T13:27:20.373" Title="What are process-based DES and event-based DES, exactly?" Tags="|terminology|simulation|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11671" PostTypeId="1" AcceptedAnswerId="11672" CreationDate="2024-02-14T15:47:36.907" Score="2" ViewCount="149" Body="&lt;p&gt;I understand how exploring the Branch-and-cut tree would help improve the best bound known and the incumbent of a MILP, however, on some instances that I deal with, my solver (Gurobi) seems to keep improving the best bound and the incumbent without exploring any node and on staying on node 0. It looks like it does not start the tree exploration.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Nodes    |    Current Node    |     Objective Bounds      |     Work&#xA;Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time&#xA;&#xA; 0     0 94578.3526    0  822 566233.300 94578.3526  83.3%     -  272s&#xA; 0     0 94578.3526    0  822 566233.300 94578.3526  83.3%     -  297s&#xA; 0     0 94578.3526    0  822 566233.300 94578.3526  83.3%     -  305s&#xA; H     0     0                373429.30000 94578.3526  74.7%     -  314s&#xA; 0     0 97103.0161    0  896 373429.300 97103.0161  74.0%     -  352s&#xA;&#xA;[...] One hour later&#xA;&#xA; H    0     0                 141739.31000 112400.671  20.7%     - 3239s&#xA; 0     0 112419.982    0 1143 141739.310 112419.982  20.7%     - 3249s&#xA; 0     0 112474.328    0 1156 141739.310 112474.328  20.6%     - 3266s&#xA; 0     0 112474.728    0 1146 141739.310 112474.728  20.6%     - 3277s&#xA; 0     0 112502.990    0 1159 141739.310 112502.990  20.6%     - 3313s&#xA; 0     0 112510.428    0 1168 141739.310 112510.428  20.6%     - 3335s&#xA; 0     0 112511.150    0 1169 141739.310 112511.150  20.6%     - 3347s&#xA; 0     0 112511.150    0 1182 141739.310 112511.150  20.6%     - 3378s&#xA; H    0     0                 141433.66000 112511.150  20.4%     - 3402s&#xA; 0     0 112511.150    0 1181 141433.660 112511.150  20.4%     - 3407s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How is that explained? For which instances would that happen?&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="35" LastEditDate="2024-02-14T16:21:38.510" LastActivityDate="2024-02-14T16:28:31.280" Title="Why would a solver stay on node 0 and still improve the gap?" Tags="|mixed-integer-programming|gurobi|solver|branch-and-bound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11672" PostTypeId="2" ParentId="11671" CreationDate="2024-02-14T16:28:31.280" Score="3" Body="&lt;p&gt;The solver generates and applies cuts at the root node. The cuts are designed to tighten the LP relaxation, which results (hopefully) in the best bound tightening. The solver also applies heuristics at the root node. The heuristics hopefully find new incumbents that improve the primal bound.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-02-14T16:28:31.280" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11673" PostTypeId="2" ParentId="11660" CreationDate="2024-02-14T19:08:17.273" Score="0" Body="&lt;p&gt;This sounds like a j&lt;a href=&quot;https://en.wikipedia.org/wiki/Job-shop_scheduling&quot; rel=&quot;nofollow noreferrer&quot;&gt;ob shop scheduling problem&lt;/a&gt;. It is most commonly formulated as either a mixed integer linear program (MILP) or a constraint programming (CP) problem. You can attempt to solve a MILP formulation using pretty much any integer programming solver. For a CP formulation, you will want a solver that supports scheduling-related global constraints, such as no-overlap constraints and precedence constraints.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-02-14T19:08:17.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11674" PostTypeId="2" ParentId="4925" CreationDate="2024-02-15T10:05:22.740" Score="2" Body="&lt;p&gt;The recent FJSP overview paper by &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S037722172300382X&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dauzère-Pérès et al. (2024)&lt;/a&gt; has a list of best-known solutions for classical FJSP instances in their supplementary materials. However, they did not include results from the new FJSP instances of &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/ijoo.2021.0056&quot; rel=&quot;nofollow noreferrer&quot;&gt;Naderi and Roshanaei (2022)&lt;/a&gt;. The latter also includes results from CP Optimizer on classic FJSP benchmark instances, which may also be of interest to you :-)&lt;/p&gt;&#xA;" OwnerUserId="2886" LastEditorUserId="2886" LastEditDate="2024-02-15T10:12:30.653" LastActivityDate="2024-02-15T10:12:30.653" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11675" PostTypeId="1" CreationDate="2024-02-15T14:16:20.453" Score="4" ViewCount="141" Body="&lt;p&gt;In numeric algorithms, an important parameter is the accuracy.  Usually, the run-time of such algorithms, when they are required to return an &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-approximate solution, is a function of &lt;span class=&quot;math-container&quot;&gt;$1/\epsilon$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In order to better understand the importance of this parameter, I am looking for real-life applications in which a very high accuracy is required (e.g. 10 or 20 or even 30 significant decimal digits). Ideally, I will be happy to know what is the &lt;em&gt;highest&lt;/em&gt; accuracy required in realistic applications.&lt;/p&gt;&#xA;&lt;p&gt;What are real-life applications, using numeric approximation algorithms, that require an &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-approximate solution with a very small &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: I am particularly interested in solving non-linear equations of the form: &lt;span class=&quot;math-container&quot;&gt;$f(x)=0$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$f: \mathbb{R}^d\to \mathbb{R}^d$&lt;/span&gt;. Often, an exact solution cannot be found, but there are numeric methods that can find an &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$f(x)&amp;lt;\epsilon$&lt;/span&gt;, for some small &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;. I am interested in settings in which we need this &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; to be very small.&lt;/p&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="2576" LastEditDate="2024-02-25T09:12:05.950" LastActivityDate="2024-02-25T09:12:05.950" Title="Applications where a very high numeric accuracy is required" Tags="|applications|approximation-algorithms|numerical-issues|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11676" PostTypeId="1" AcceptedAnswerId="11677" CreationDate="2024-02-16T17:09:20.527" Score="1" ViewCount="115" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wipbZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wipbZ.jpg&quot; alt=&quot;knapsack problem&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Can anyone explain how the writer rewrite the objective function in (7) to be written as (8)?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="13204" LastEditorUserId="491" LastEditDate="2024-02-19T17:32:31.003" LastActivityDate="2024-02-19T17:32:31.003" Title="0-1 Knapsack optimization problem" Tags="|optimization|knapsack|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11677" PostTypeId="2" ParentId="11676" CreationDate="2024-02-16T18:14:51.423" Score="2" Body="&lt;p&gt;Just consider the two cases:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$z_i=0$&lt;/span&gt;, the LHS and RHS are both &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;span class=&quot;math-container&quot;&gt;$z_i=1$&lt;/span&gt;, the LHS and RHS are both &lt;span class=&quot;math-container&quot;&gt;$p_i$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Explicit calculations for the RHS:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\theta_i \left(1 - \left(\frac{\theta_i-p_i}{\theta_i}\right)^0 \right)&#xA;&amp;amp;= \theta_i \left(1 - 1\right) = 0 \\&#xA;\theta_i \left(1 - \left(\frac{\theta_i-p_i}{\theta_i}\right)^1 \right)&#xA;&amp;amp;= \theta_i \left(1 - 1 + \frac{p_i}{\theta_i}\right) = \theta_i \cdot \frac{p_i}{\theta_i} = p_i&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-02-17T17:52:00.553" LastActivityDate="2024-02-17T17:52:00.553" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11680" PostTypeId="1" CreationDate="2024-02-18T03:47:29.647" Score="1" ViewCount="41" Body="&lt;p&gt;We are currently solving a hard MILP problem on optimality. Once it has been solved, several times (from 5 to 10 times), we change one coefficient of the objective function and reoptimize. Thus the feasible solutions are the same, the optimal solutions change.&lt;/p&gt;&#xA;&lt;p&gt;During each solve we generate subtour elimination constraints as lazy constraints by callbacks as a part of the MILP problem consists of a ring.&#xA;We decided to store these constraints and reuse them between each reoptimization, with the idea that it would speed up the whole process.&lt;/p&gt;&#xA;&lt;p&gt;However, the performances are totally worse when reusing the lazy constraints (generated as callbacks) as lazy constraints, not generated by callbacks but put at the very beginning of each reoptimization model.&lt;/p&gt;&#xA;&lt;p&gt;What could cause such performance degradation? The total CPU times shift from approximately 3500 seconds to 4500 seconds when storing the lazy constraints.&lt;/p&gt;&#xA;" OwnerUserId="35" LastActivityDate="2024-02-18T03:47:29.647" Title="What reasons would cause lazy constraints to degrade the performances when reoptimizing with a different objective?" Tags="|mixed-integer-programming|constraint|combinatorial-optimization|subtour-elimination|cpu|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11681" PostTypeId="1" CreationDate="2024-02-18T17:11:12.130" Score="0" ViewCount="69" Body="&lt;p&gt;I have one last question about my column generation model. I am currently trying to implement it in code, and I am successfully solving the subproblem. So I can solve the dual values of the master problem, then pass them to the individual SP and these then minimize the SP target functions. Unfortunately, I fail when adding the columns to my master problem, which is probably also due to the fact that I don't quite understand what exactly should be passed from the individual subproblems to the master problem and how the assignment to the &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; variable is done. And what exactly is a roster in this context?&#xA;Do I simply have to pass the optimal values of &lt;span class=&quot;math-container&quot;&gt;$motivation$&lt;/span&gt; from the super problem to the master problem? When I try this in Gurobi for example, there is an error that the array length does not match. For &lt;span class=&quot;math-container&quot;&gt;$I=3$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$S=3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$T=7$&lt;/span&gt; I have &lt;span class=&quot;math-container&quot;&gt;$21$&lt;/span&gt; values of &lt;span class=&quot;math-container&quot;&gt;$motivation$&lt;/span&gt; for each doctor, but there are &lt;span class=&quot;math-container&quot;&gt;$24$&lt;/span&gt; constraints in the MP (21 for the Demand Constraint and 3 of the Integrality constraint). So what exactly do I add from the SPs to the MP?&#xA;This is the model:&lt;/p&gt;&#xA;&lt;p&gt;Master Problem:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;&amp;amp;(MP)\quad \min &amp;amp;\sum_t \sum_s \text{slack}_{ts} \\&#xA;\end{align}$$&lt;/span&gt;&#xA;subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    &amp;amp;&amp;amp;\sum_i \sum_r \text{motivation}_{its}^r \lambda_{ir} + \text{slack}_{ts} &amp;amp; \ge \text{demand}_{ts} &amp;amp;&amp;amp;\forall t,s &amp;amp;&amp;amp;\label{eins}\\&#xA;&amp;amp;&amp;amp;\sum_r \lambda_{ir} &amp;amp;= 1 &amp;amp;&amp;amp;\forall i &amp;amp;&amp;amp;\\&#xA;&amp;amp;&amp;amp;\lambda_{ir} &amp;amp;\in\mathbb{Z}^+ &amp;amp;&amp;amp;\forall i,r\\&#xA;&amp;amp;&amp;amp;\text{slack}_{ts} &amp;amp;\ge 0 &amp;amp;&amp;amp;\forall t,s&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subproblems (i)&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;&amp;amp;SP(i)\quad \min -\sum_{t,s} \pi_{ts} \text{motivation}_{ts} - \mu_i\\&#xA;\end{align}$$&lt;/span&gt;&#xA;subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\begin{align}&#xA;&amp;amp;mood_{it} + M\cdot (1-x_{its}) \geq motivation_{its}&amp;amp;\forall i,t,s \\&#xA;&amp;amp;motivation_{its} \geq mood_{it} - M\cdot (1-x_{its}) &amp;amp;\forall i,t,s \\&#xA;&amp;amp;motivation_{its} \le x_{its} &amp;amp; \forall t,s \\ &amp;amp;\sum_{s}^{}x_{its}\le 1&amp;amp; \forall i,t \\&#xA;&amp;amp;\alpha \sum_s x_{its} + \text{mood}_{it} = 1 &amp;amp;\forall i,t\\&#xA;&amp;amp;motivation_{its} \in[0,1] &amp;amp;\forall t,s \\&#xA;&amp;amp;mood_{it} \in[0,1] &amp;amp;\forall t \\&#xA;&amp;amp;x_{its}\in \{0,1\} &amp;amp;\forall t,s\\&#xA;\end{align}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Gere is my Gurobi implementation, in case anyone here is familiar with it: &lt;a href=&quot;https://github.com/carlobb23/cg/tree/main&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="491" LastEditDate="2024-02-19T17:34:07.467" LastActivityDate="2024-03-20T19:04:50.567" Title="How can I add columns from the subproblem to the master problem in my column generation model?" Tags="|gurobi|column-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11682" PostTypeId="2" ParentId="11681" CreationDate="2024-02-18T21:08:14.417" Score="0" Body="&lt;p&gt;The values of the variables in your subproblem solution become the constraint coefficients in the new column in your master problem. Lets say that, prior to solving the subproblem, your master columns are numbered &lt;span class=&quot;math-container&quot;&gt;$r=1,\dots, R.$&lt;/span&gt; Your new subproblem solution will be used to create master problem column &lt;span class=&quot;math-container&quot;&gt;$R+1.$&lt;/span&gt; The coefficient &lt;span class=&quot;math-container&quot;&gt;$$\text{motivation}_{its}^{R+1}$$&lt;/span&gt; in the master problem will be the value of &lt;span class=&quot;math-container&quot;&gt;$$motivation_{its}$$&lt;/span&gt; in the subproblem solution. For each &lt;span class=&quot;math-container&quot;&gt;$i,$&lt;/span&gt; in the master problem row &lt;span class=&quot;math-container&quot;&gt;$\sum_r \lambda_{i,r} = 1$&lt;/span&gt; the coefficient in the new column will be 1.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-02-18T21:08:14.417" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11683" PostTypeId="1" AcceptedAnswerId="11686" CreationDate="2024-02-18T22:11:11.687" Score="2" ViewCount="92" Body="&lt;p&gt;I'm looking for advice on solving ILP problems with a relatively small number of constraints and variables, but very large coefficients. I have less than 500 variables and constraints, but my coefficients are all greater than 1000 bits. I'm concerned about numerical stability issues for the solver when dealing with such large coefficients.&lt;/p&gt;&#xA;&lt;p&gt;My problem has purely linear constraints and I am trying to minimize a linear objective. The problem domain is cryptanalysis. The constraint matrix is extremely dense.&lt;/p&gt;&#xA;&lt;p&gt;Are there any solvers in particular that excel in this domain? Are there particular settings or algorithms I should use to prevent numerical stability issues?&lt;/p&gt;&#xA;&lt;p&gt;I would also be interested in LP solvers that can handle huge coefficients if the support is better there, as I can likely use rounding to obtain a pretty good solution for the ILP from a solution to the LP.&lt;/p&gt;&#xA;" OwnerUserId="13210" LastEditorUserId="491" LastEditDate="2024-02-19T17:33:09.197" LastActivityDate="2024-02-19T17:33:09.197" Title="Small number of constraints, but very large coefficients" Tags="|integer-programming|numerical-stability|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11684" PostTypeId="1" AcceptedAnswerId="11687" CreationDate="2024-02-19T05:01:18.873" Score="4" ViewCount="239" Body="&lt;p&gt;Suppose I have a matrix &lt;span class=&quot;math-container&quot;&gt;$A\in \{-1, 0, 1\}^{m\times n}$&lt;/span&gt; which is Totally Unimodular (TU), and a vector &lt;span class=&quot;math-container&quot;&gt;$b^T \in \{-1, 0, 1\}^{1\times n}$&lt;/span&gt; which has exactly one entry which is &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; and exactly one entry which is &lt;span class=&quot;math-container&quot;&gt;$-1$&lt;/span&gt;, and the rest of its entries are &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&#xA;If I add &lt;span class=&quot;math-container&quot;&gt;$b^T$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; to get the following matrix:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;C =&#xA;\begin{bmatrix}&#xA;A \\&#xA;b^T&#xA;\end{bmatrix}.&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Will &lt;span class=&quot;math-container&quot;&gt;$C$&lt;/span&gt; be TU as well? I believe it should be, but I am having difficulty proving it. I tried working directly from the determinant definition of Total Unimodularity, but to no success&lt;/p&gt;&#xA;" OwnerUserId="11000" LastEditorUserId="11000" LastEditDate="2024-02-19T15:08:12.153" LastActivityDate="2024-02-19T15:28:35.380" Title="Can we add a certain binary row to a matrix which preserves total unimodularity?" Tags="|mixed-integer-programming|integer-programming|network-flow|totally-unimodular|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11685" PostTypeId="2" ParentId="11683" CreationDate="2024-02-19T12:40:28.080" Score="1" Body="&lt;p&gt;Classical MILP solvers work with floating-point numbers. Therefore, if you need more accuracy than what a double might store, they won't fit. Otherwise, what is important first for numerical stability is the range of the coefficients. So if you can scale your coefficients to fit in &lt;span class=&quot;math-container&quot;&gt;$[10^{-4}, 10^4]$&lt;/span&gt;, numerical stability might not be an issue.&lt;/p&gt;&#xA;&lt;p&gt;For problems with numerical issues, some solvers provide dedicated options to mitigate them. For example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.fico.com/fico-xpress-optimization/docs/latest/solver/optimizer/HTML/NUMERICALEMPHASIS.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;NUMERICALEMPHASIS&lt;/a&gt; in Xpress&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gurobi.com/documentation/current/refman/numericfocus.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;NumericFocus&lt;/a&gt; in Gurobi&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If this is not enough, then you will need a truly exact MILP solver such as the ones mentioned in &lt;a href=&quot;https://or.stackexchange.com/questions/5167/is-there-a-linear-programming-library-that-natively-supports-fractions-instead-o&quot;&gt;this question&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4551" LastActivityDate="2024-02-19T12:40:28.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11686" PostTypeId="2" ParentId="11683" CreationDate="2024-02-19T13:25:39.000" Score="1" Body="&lt;p&gt;If you can make it work with &lt;span class=&quot;math-container&quot;&gt;$10^{-6}$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$10^{-8}$&lt;/span&gt; relative precision, just use an off-the-shelf solver with more precision-oriented options.&#xA;You will need to rescale your problem so that the coefficients are &amp;quot;reasonable&amp;quot; for the solver (&lt;span class=&quot;math-container&quot;&gt;$10^{10}$&lt;/span&gt; should be safe-ish).&lt;/p&gt;&#xA;&lt;p&gt;You mention cryptanalysis, so I'm assuming from now that you actually need an exact solution.&#xA;If you need a solution with 1000 bits of accuracy, the accuracy of a typical solver is not going to be sufficienthis doesn't even fit in a floating-point number.&lt;/p&gt;&#xA;&lt;p&gt;Depending on your use case, you need one of the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For continuous or mixed integer problem, an exact linear solver as mentioned by the other answer, such as &lt;a href=&quot;https://www.gnu.org/software/glpk/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GLPK&lt;/a&gt; in exact mode or &lt;a href=&quot;https://www.math.uwaterloo.ca/%7Ebico/qsopt/ex/&quot; rel=&quot;nofollow noreferrer&quot;&gt;QSOPT_ex&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For pure binary or integer problems, a pseudoboolean solver such as &lt;a href=&quot;http://minisat.se/MiniSat+.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Minisat+&lt;/a&gt; or &lt;a href=&quot;https://gitlab.com/MIAOresearch/software/roundingsat&quot; rel=&quot;nofollow noreferrer&quot;&gt;RoundingSat&lt;/a&gt; may be a better choice. They are more similar to SAT solvers, and would probably give better results than a MIP solver for anything related to cryptanalysis.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2024-02-19T15:56:48.090" LastActivityDate="2024-02-19T15:56:48.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11687" PostTypeId="2" ParentId="11684" CreationDate="2024-02-19T15:28:35.380" Score="5" Body="&lt;p&gt;Your conjecture is wrong as the following counterexample demonstrates. Consider&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;A = \begin{pmatrix} 1 &amp;amp; 0 &amp;amp; -1 \\ 1 &amp;amp; 1 &amp;amp; 0 \end{pmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;b^\top = \begin{pmatrix} -1 &amp;amp; 1 &amp;amp; 0 \end{pmatrix}.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then,&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;C = \begin{pmatrix} 1 &amp;amp; 0 &amp;amp; -1 \\ 1 &amp;amp; 1 &amp;amp; 0 \\ -1 &amp;amp; 1 &amp;amp; 0\end{pmatrix}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is &lt;strong&gt;not&lt;/strong&gt; totally unimodular since &lt;span class=&quot;math-container&quot;&gt;$\det \begin{pmatrix} 1 &amp;amp; 1 \\ -1 &amp;amp; 1 \end{pmatrix} = 2 \notin \{-1, 0, 1\}$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3696" LastActivityDate="2024-02-19T15:28:35.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11688" PostTypeId="1" CreationDate="2024-02-20T01:33:38.237" Score="1" ViewCount="92" Body="&lt;p&gt;I'm currently working on a large Mixed Integer Program (MIP) where the constraint matrix is Totally Unimodular (TU), allowing me to model it as a Linear Program (LP) for efficiency, as total unimodularity ensures an integer solution at optimality. However, I need to incorporate an additional constraint that disrupts the TU property of the matrix. To avoid losing the TU advantage, I'm considering reformulating the objective function to preserve integrality without directly adding the problematic constraint. This reformulation would change the objective function of my model into a nonlinear convex function, which is of the form like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\min \sum_{i\in I} c_i x_i + \sum_{i\in I, j\in J} (x_i - x_j)^2 &#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have limited practical experience with nonlinear convex optimization and am uncertain about the performance of modern solvers for such problems. Specifically, can optimization solvers handle nonlinear convex models with similar efficiency to LPs for most practical cases?&lt;/p&gt;&#xA;" OwnerUserId="11000" LastEditorUserId="500" LastEditDate="2024-02-20T02:19:48.400" LastActivityDate="2024-02-20T02:19:48.400" Title="Converting a Linear Program with TU Constraint Matrix to a Nonlinear Convex Model: Solver Performance?" Tags="|mixed-integer-programming|linear-programming|nonlinear-programming|convex-optimization|totally-unimodular|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="11690" PostTypeId="1" CreationDate="2024-02-20T09:26:46.930" Score="0" ViewCount="117" Body="&lt;p&gt;I am trying to build a MILP model. In this model, I have a dependent variable (alpha) that its value depends on the value of some other variables (or different combination of some other variables). In fact, one option will be selected as the final value of alpha given the values of other variables. Please see an example below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\alpha=\left\{\begin{array}{ccc}&#xA;10 &amp;amp; \text { if } &amp;amp; x=1 ; \\&#xA;12 &amp;amp; \text { els if } &amp;amp; x+y=2 ; \\&#xA;\vdots &amp;amp; &amp;amp; \vdots \\&#xA;25 &amp;amp; \text { else if } &amp;amp; x+\cdots+z=4 ;&#xA;\end{array}\right.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know how I can come up with a standard equations to formulate this function in order to obtain the value of alpha. Please note that the &amp;quot;if statements&amp;quot; and their variables are just an example.&lt;/p&gt;&#xA;" OwnerUserId="5008" LastEditorUserId="12223" LastEditDate="2024-03-22T13:21:36.427" LastActivityDate="2024-03-22T13:21:36.427" Title="Converting a piecewise function to linear equations" Tags="|mixed-integer-programming|linear-programming|modeling|linearization|indicator-constraints|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11691" PostTypeId="1" CreationDate="2024-02-20T10:22:19.683" Score="0" ViewCount="56" Body="&lt;p&gt;I am looking for guidance on a solution to the problem of picking the best special offers that can be applied to a given basket of items.&lt;/p&gt;&#xA;&lt;p&gt;In the system, a special offer has N collections of qualifying items, to satisfy the offer an item from the basket must match an item from each of the collections. If a special offer is satisfied then a type of discount is applied. Each product in a basket can only be used once to qualify a special offer.&lt;/p&gt;&#xA;&lt;p&gt;Some deals and some products could look like this&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// deals&#xA;{&#xA;  Id: 1,&#xA;  Name: &amp;quot;Bogof 1&amp;quot;,&#xA;  Items: [&#xA;    [1,2,3], // Item ID's in this group&#xA;    [1,2],&#xA;    [1]&#xA;  ],&#xA;  Price: 2.6&#xA;},&#xA;&#xA;{&#xA;  Id: 2,&#xA;  Name: &amp;quot;Bogof 2&amp;quot;,&#xA;  Items: [&#xA;    [1,2], // Item ID's in this group&#xA;    [1,2],&#xA;    [1,2]&#xA;  ],&#xA;  Price: 2.5&#xA;},&#xA;&#xA;{&#xA;  Id: 3&#xA;  Name: &amp;quot;Buy 5 get 1 Free&amp;quot;,&#xA;  Items: [&#xA;    [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],&#xA;    [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],&#xA;    [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],&#xA;    [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],&#xA;    [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],&#xA;  ],&#xA;  Price: 4&#xA;}&#xA;&#xA;// Products&#xA;&#xA;[{&#xA;  Id: 1,&#xA;  Price: 1,&#xA;},{&#xA;  Id: 2,&#xA;  Price: 1.2,&#xA;},{&#xA;  Id: 3,&#xA;  Price: 1.5,&#xA;},&#xA;]&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have simplified the offers here with an absolute price, but there could be something more dynamic like cheapest free.&lt;/p&gt;&#xA;&lt;p&gt;If I have the basket&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;[1,2,3] // Item ID's&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;and I was to naively iterate the item groups in the deal, &lt;strong&gt;1&lt;/strong&gt; would match the first row (of deal 1) and &lt;strong&gt;2&lt;/strong&gt; would match the second, but &lt;strong&gt;3&lt;/strong&gt; would not match the third row, which means really I would need to generate all the permutations and iterate those instead, however, now imagine an offer with 50 items, the same 50 in each group, but 10 groups, if I was to apply that same logic to the 50*10 scenario that is 50&lt;sup&gt;10&lt;/sup&gt; permutations.&lt;/p&gt;&#xA;&lt;p&gt;Now if I have the basket&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;[1,1,1,2,3]&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The code also needs to be able to pick the optimal offer which would give the best discount, which in this case would be offer 1, not 2, because offer 1 offers the largest discount of the items.&lt;/p&gt;&#xA;&lt;p&gt;From reading about similar problems it seems like Integer programming might offer a solution, but I am looking at the Knapsack or Bin packing vs assignment and trying to figure out where to start. Should I have a binary variable for each item in a basket multiplied by each meal deal item collection, or can I just have variables for the meal deals and their item collections and set constraints using the products? I am also not sure which Solver would be best. I am using C# and have been having a play with Google Or Tools.&lt;/p&gt;&#xA;&lt;p&gt;Maybe there is another way to reduce the problem.&lt;/p&gt;&#xA;" OwnerUserId="13216" LastEditorUserId="13216" LastEditDate="2024-02-21T11:23:49.813" LastActivityDate="2024-02-21T11:23:49.813" Title="Shopping Basket Deal Optimization" Tags="|integer-programming|combinatorial-optimization|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11692" PostTypeId="2" ParentId="11690" CreationDate="2024-02-20T12:19:59.777" Score="1" Body="&lt;p&gt;Judging by the additional remarks in the comments, it seems like you want to linearize:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\alpha = &#xA;\begin{cases}&#xA;\alpha_1, \quad \text{if} \quad \sum_{i \in J_1} x_i = |J_1| = 1 \\&#xA;\alpha_2, \quad \text{if} \quad \sum_{i \in J_2} x_i = |J_2| = 2 \\&#xA;\vdots \\&#xA;\alpha_k, \quad \text{if} \quad \sum_{i \in J_k} x_i = |J_k| = k \\&#xA;\vdots \\&#xA;\alpha_N, \quad \text{if} \quad \sum_{i \in J_N} x_i = |J_N| = N \\&#xA;\end{cases}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;for given constants &lt;span class=&quot;math-container&quot;&gt;$\alpha_1, \ldots, \alpha_N$&lt;/span&gt;, given binary variables &lt;span class=&quot;math-container&quot;&gt;$x_1, \ldots, x_N$&lt;/span&gt;, and given sets &lt;span class=&quot;math-container&quot;&gt;$J_k \subseteq I = \{1, \ldots, N \}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$|J_k| = k$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$k = 1, \ldots, N$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;By adding extra binary variables &lt;span class=&quot;math-container&quot;&gt;$b_1, \ldots, b_N$&lt;/span&gt;, you can represent the above using the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\alpha &amp;amp;= \sum_{k=1}^{N} \alpha_k b_k \\&#xA;\sum_{k=1}^{N} b_k &amp;amp;= 1 \\&#xA;b_k   &amp;amp;\geq 1 - |J_k| + \sum_{i \in J_k} x_i \quad \forall k = 1, \ldots, N.&#xA;\end{align}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this case, the last constraint ensures that&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i \in J_k} x_i = |J_k| = k \implies b_k = 1 \quad \forall k = 1, \ldots, N.&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="3696" LastEditorUserId="500" LastEditDate="2024-02-20T13:36:51.627" LastActivityDate="2024-02-20T13:36:51.627" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11693" PostTypeId="2" ParentId="11675" CreationDate="2024-02-21T09:43:15.983" Score="1" Body="&lt;p&gt;Curious to see if anyone knows of some better examples, but I wanted to pitch in with my experience on this in real-life scenarios.&lt;/p&gt;&#xA;&lt;p&gt;I should start by saying that in my experience this is rarely an issue for experienced modellers using well written solvers. It is exceedingly rare that we'd &lt;em&gt;need&lt;/em&gt; that level of accuracy in practice, i.e., that the only to get the job done is to achieve that level of accuracy.&lt;/p&gt;&#xA;&lt;p&gt;Fundamentally, the &lt;em&gt;need&lt;/em&gt; for high levels of numerical accuracy arises in situations where we have numbers of significantly different orders of magnitude in our calculations, or significant accumulation of error. Sometimes that's ok and we can work with imprecisions, and sometimes it's not.&lt;/p&gt;&#xA;&lt;p&gt;In general, we try to scale/formulate our models such that these large variations are not present, control the error using different algorithms, keep track of it using e.g. interval arithmetic, and so on. However, in certain cases this can't be easily worked around.&lt;/p&gt;&#xA;&lt;p&gt;One algorithmic case where we encounter this is when generating convex relaxations of non-convex functions. Even if the solution is at &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;, the coefficients of the constraints we generate can easily be in the order of &lt;span class=&quot;math-container&quot;&gt;$1.e50$&lt;/span&gt; or higher. In such cases we often can't trust the result of solving the relaxation, and we can easily fathom the global solution by accident if we do. The techniques we use to handle this could easily fill a few books, but we do handle it without actually achieving that level of accuracy.&lt;/p&gt;&#xA;&lt;p&gt;One academic example of a physical case that I remember from back in the day is the minimisation of the Gibbs free energy of Lennard-Jones clusters, where the potential is given by the following formula:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$V_{LJ}(r) = 4\epsilon[(\frac{\sigma}{r})^{12}-(\frac{\sigma}{r})^6]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Numerically, there's all sorts of nasty in that formula. Note however that, while academically interesting, the model itself is pretty crude to begin with, hence the garbage-in garbage-out rule applies. Even if we did solve this with perfect accuracy, it's a poor representation of the physical system, hence the solution would not be very useful to describe anything interesting at macro-scale.&lt;/p&gt;&#xA;&lt;p&gt;In other words, in a modelling context we always keep in mind that high accuracy can only ever be meaningful if the model itself is highly accurate to begin with.&lt;/p&gt;&#xA;&lt;p&gt;In practice, we tend to trust calculations in ranges where floating point numbers are fairly well represented within &lt;span class=&quot;math-container&quot;&gt;$6-9$&lt;/span&gt; orders of magnitude (e.g. &lt;span class=&quot;math-container&quot;&gt;$0-1.e6$&lt;/span&gt; is a good range, &lt;span class=&quot;math-container&quot;&gt;$1.e302-1.e308$&lt;/span&gt; is bad), and flag calculations which are potentially not trustworthy to be handled in other ways, if we need to, or avoid them entirely.&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2024-02-21T09:43:15.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11694" PostTypeId="1" CreationDate="2024-02-21T10:27:04.360" Score="1" ViewCount="23" Body="&lt;p&gt;Are there still reasons to create MILPs manually from the ground up, or is it more suitable to rely on certain frameworks translating requirements and elements into proper MILPs using a set of rules, e.g. &lt;a href=&quot;https://www.fico.com/fico-xpress-optimization/docs/latest/mipform/dhtml/chap2s1.html?scroll=ssecabsval&quot; rel=&quot;nofollow noreferrer&quot;&gt;example rules&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Those translators/compilers can of course become as sophisticated as necessary with enough work and complex rule sets, I guess, like any compiler.&lt;/p&gt;&#xA;&lt;p&gt;I stumbled across multiple DSE concepts in publications and was wondering, how do their MILPs actually look like until I noticed they never created MILPs themselves. However, I realized that they never actually constructed MILPs themselves; rather, they input their problems into existing frameworks.&lt;/p&gt;&#xA;&lt;p&gt;What are the advantages and disadvantages of relying on DSE frameworks automatically deriving MILPs? Is it possible for frameworks allowing a highly complex expressiveness while ensuring the existence of a convex relaxation for resulting MILPs?&lt;/p&gt;&#xA;" OwnerUserId="2989" LastActivityDate="2024-02-21T10:27:04.360" Title="(Dis-)Advantages of Design Space Exploration Frameworks generating MILPs (e.g. DeSyDe, ArchEx, ...)" Tags="|mixed-integer-programming|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11695" PostTypeId="5" CreationDate="2024-02-21T11:13:16.633" Score="0" Body="&lt;p&gt;Some of the mathematics behind the cutting stock problem are described at:&lt;/p&gt;&#xA;&lt;p&gt;Wikipedia: &lt;a href=&quot;https://en.wikipedia.org/wiki/Cutting_stock_problem#Mathematical_formulation_and_solution_approaches&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cutting Stock Problem&lt;/a&gt;&lt;br /&gt;&#xA;NEOS Guide: &lt;a href=&quot;https://neos-guide.org/case-studies/sc/mfg/the-cutting-stock-problem/&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Cutting Stock Problem&lt;/a&gt; (with AMPL example)&lt;br /&gt;&#xA;MathWorks: &lt;a href=&quot;https://www.mathworks.com/help/optim/ug/cutting-stock-problem-solver-based.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Cutting Stock Problem: &lt;strong&gt;Solver&lt;/strong&gt; Based&lt;/a&gt; and &lt;a href=&quot;https://www.mathworks.com/help/optim/ug/cutting-stock-problem-based.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Problem&lt;/strong&gt; Based&lt;/a&gt;&lt;br /&gt;&#xA;SCIP: &lt;a href=&quot;https://scipbook.readthedocs.io/en/latest/bpp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bin packing and cutting stock problems&lt;/a&gt;&lt;br /&gt;&#xA;IBM: &lt;a href=&quot;https://www.ibm.com/docs/en/icos/22.1.0?topic=columngeneration-cutting-stock-problem&quot; rel=&quot;nofollow noreferrer&quot;&gt;ILOG CPLEX Optimization Studio: The Cutting Stock Problem&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2024-02-21T13:41:30.137" LastActivityDate="2024-02-21T13:41:30.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11696" PostTypeId="4" CreationDate="2024-02-21T11:13:16.633" Score="0" Body="The cutting stock problem is the optimization problem of cutting standard sized pieces of stock (EG: paper, metal, fabric) into various sized pieces while reducing wastage." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2024-02-21T13:41:20.903" LastActivityDate="2024-02-21T13:41:20.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11697" PostTypeId="1" CreationDate="2024-02-21T11:21:44.163" Score="1" ViewCount="78" Body="&lt;p&gt;I'm working on a complex VRP problem. I'm working on the generic case, but for you to understand better I've created a small instance....&lt;/p&gt;&#xA;&lt;p&gt;Assume that there are 3 demand (D1-D2-D3) and 3 supply nodes (S1-S2-S3) all with its own time windows (WLOG in increasing order, so TW of D1 is earlier than TW of D2). Time windows are valid only when entering to a node. Each node should be visited at least once. There are 2 vehicles and they are parked in one of these 6 nodes (both cannot be at the same node at the same time). And there are no additional starting or ending depots. Starting point of the vehicle is where it is parked initially and in later routes it is on the node where it has visited last. The objective is minimizing the total distance travelled. You can assign random distances between nodes and random service times for each node. Each vehicle can do multiple visits.&lt;/p&gt;&#xA;&lt;p&gt;Let's say initially vehicle-1 is in S2 and vehicle-2 is in D3. So a feasible solution can be vehicle-1 can do like route-1: S2-S1-D1-D2 and route-2: D2-S2-D3 and for vehicle-2 -&amp;gt; route-3: D3-S3... One crucial rule is before visiting a demand node in each route, the vehicle should visit a supply point, because vehicles are assumed to be empty initially and at the end of each route. Now here in route-1, the first visit from S2 to S1 is kind of forced and we should ignore S2's TW as it just leaving and we are obliged to obey only &lt;a href=&quot;https://i.stack.imgur.com/RlCk5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RlCk5.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;S1,D1,D2's TWs.&lt;/p&gt;&#xA;&lt;p&gt;How can we model this as a MILP?&lt;/p&gt;&#xA;" OwnerUserId="632" LastActivityDate="2024-02-22T17:00:56.643" Title="A hard VRP with Time Windows + Multi Routes" Tags="|vehicle-routing|vrptw|multi-routevrp|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="11698" PostTypeId="1" CreationDate="2024-02-21T11:30:50.607" Score="3" ViewCount="170" Body="&lt;p&gt;I am very new to OR. I am trying to find the minimum cost sequence for a set of tasks that need to be executed. These tasks (at least some of them) have precedence constraints. For example, task T1 has to be completed before task T2 can be executed. I am planning to use TSP to solve this problem. But I am unable to find a solver that will accept precedence constraints to a TSP problem or at least I don't know how to set precedence constraints for a TSP problem. I have looked at Google OR tools. Can someone suggest a solver (preferably open source) that will accept precedence constraints or tell me how I can set precedence constraints in Google OR tools?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit 1:&lt;/strong&gt;&#xA;Context:&#xA;OK let me try to explain why I am looking at TSP and why I am solving the problem I have using a multi-optimization algorithm. I have resources/agents that have to execute the tasks in a given time window. The task is to visit various locations in a contained area and do one of many operations in that location. I can/have to group these tasks based on a few parameters and assign them to an agent.  The combinatorial search space is huge (as I am sure it is the case with most OR problems). So I have decomposed the problem into 3 parts- first find an initial batching of tasks that can be assigned to a unique agent based on various parameters, the second will solve for the shortest path (in terms of total completion times) that the agent would take to execute the tasks within each batch and the third part will assign the batch of tasks to an appropriate agent taking into account the deadline for each batch (minimizes weighted tardiness). This is done iteratively to get to the optimal batching,route &amp;amp; assignment without tardiness.&lt;/p&gt;&#xA;" OwnerUserId="13222" LastEditorUserId="491" LastEditDate="2024-03-23T19:52:37.130" LastActivityDate="2024-03-23T19:52:37.130" Title="solver for Travelling Salesman Problem (TSP) with precedence constraints" Tags="|solver|traveling-salesman|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="11699" PostTypeId="2" ParentId="11578" CreationDate="2024-02-21T12:47:40.027" Score="2" Body="&lt;p&gt;I am not sure a unique solution exists (consider the one-dimensional case for example), nor a closed-form one.&lt;/p&gt;&#xA;&lt;p&gt;An approach to (approximately) solving your problem is to first reformulate it as:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min_{\mathbf{X} \in \mathbb{R}^d} \sum_{t} \|\mathbf{X} \mathbf{v}_t' - \mathbf{A}_t \mathbf{X} \mathbf{v}_t\|_2^2,$$&lt;/span&gt;&#xA;assuming that &lt;span class=&quot;math-container&quot;&gt;$\mathbf{v}_t,\mathbf{v}_t' \in \mathbb{R}^d$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\mathbf{A}_t \in \mathbb{R}^{d \times d}$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Thus, inverting the solution to the above solves OP's problem.&#xA;The benefit is that it is easier to differentiate the objective now wrt. &lt;span class=&quot;math-container&quot;&gt;$\mathbf{X}$&lt;/span&gt; (see The Matrix Cookbook for details):&#xA;&lt;span class=&quot;math-container&quot;&gt;$$2\sum_t \mathbf{X} \mathbf{v}_t' \mathbf{v}_t'^\top + \mathbf{A}_t^\top \mathbf{A}_t \mathbf{X}\mathbf{v}_t \mathbf{v}_t^\top -(\mathbf{A}_t^\top\mathbf{X} \mathbf{v}_t' \mathbf{v}_t^\top+\mathbf{A}_t\mathbf{X} \mathbf{v}_t \mathbf{v}_t'^\top).$$&lt;/span&gt;&#xA;Then using gradient descent with the derivative above should solve the problem. Also, looking at the expression above, it seems to me that finding a matrix with zero derivative is as hard as the original matrix problem, so I doubt that a closed-form can be obtained this way.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: the proposed reformulation only yields an admissible solution to the original problem if we additionally constrain the solution to be invertible, as pointed out in the comments. In this case, the gradient descent method probably won't work in practice. But I guess that the solution above should be good enough, by somehow excluding/penalizing the zero solution, or if it's fine to have pseudo-inverses in the original equation.&lt;/p&gt;&#xA;" OwnerUserId="13223" LastEditorUserId="13223" LastEditDate="2024-02-22T13:50:46.367" LastActivityDate="2024-02-22T13:50:46.367" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11700" PostTypeId="2" ParentId="11698" CreationDate="2024-02-21T14:49:47.920" Score="0" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Can someone suggest a solver (preferably open source) that will accept precedence constraints?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://timefold.ai/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Timefold&lt;/a&gt; is an open source solver that can handle TSP with precedence constraints.&lt;/p&gt;&#xA;&lt;p&gt;Your model would look like this in Java (similar for Kotlin and soon Python):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@PlanningEntity&#xA;class Salesman {&#xA;&#xA;    // Decided by the solver&#xA;    @PlanningListVariable&#xA;    List&amp;lt;Task&amp;gt; tasks;&#xA;&#xA;}&#xA;&#xA;@PlanningEntity&#xA;class Task {&#xA;&#xA;   String id;&#xA;   List&amp;lt;task&amp;gt; precedenceTasks;&#xA;&#xA;   // Automatically filled in based on the decisions by the solver&#xA;   @InverseRelationShadowVariable&#xA;   Salesman salesman;&#xA;&#xA;   // Automatically filled in based on the decisions by the solver&#xA;   @IndexShadowVariable&#xA;   Integer salesmanTasksIndex;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The constraint would look like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;.forEach(Task.class)&#xA;.join(Task.class,&#xA;     // Same salesman (optional)&#xA;     equal(Task::salesman),&#xA;     // Task 1 is before task 2&#xA;     lessThan(Task::salesmanTasksIndex))&#xA;// Task1 has task2 as a precedence&#xA;.filter((task1, task2) -&amp;gt; task1.precedenceTasks.contains(task2))&#xA;// Stop doing this!&#xA;.penalize(HardSoftScore.ofHard(1))&#xA;.asConstraint(&amp;quot;Precedence tasks&amp;quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The Vehicle Routing and Food Packaging &lt;a href=&quot;https://github.com/TimefoldAI/timefold-quickstarts&quot; rel=&quot;nofollow noreferrer&quot;&gt;quickstarts source code&lt;/a&gt; can also give inspiration.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2024-02-21T19:33:40.130" LastActivityDate="2024-02-21T19:33:40.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11701" PostTypeId="1" CreationDate="2024-02-21T15:33:17.447" Score="0" ViewCount="28" Body="&lt;p&gt;I have dived into &lt;a href=&quot;https://en.wikipedia.org/wiki/Theory_of_constraints&quot; rel=&quot;nofollow noreferrer&quot;&gt;Theory of Constraints&lt;/a&gt; by reading &lt;a href=&quot;https://en.wikipedia.org/wiki/The_Goal_(novel)&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;The Goal&lt;/em&gt;&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/It%27s_Not_Luck&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;It's Not Luck&lt;/em&gt;&lt;/a&gt;, &lt;a href=&quot;https://www.amazon.ca/Isnt-Obvious-Revised-Eliyahu-Goldratt-ebook/dp/B00408ALES&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Isn't it Obvious&lt;/em&gt;&lt;/a&gt;, and &lt;a href=&quot;https://en.wikipedia.org/wiki/Critical_Chain_(novel)&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Critical Chain&lt;/em&gt;&lt;/a&gt;. I am currently reading &lt;a href=&quot;https://www.amazon.ca/Goldratts-Rules-Flow-Efrat-Goldratt-Ashlag-ebook/dp/B0B9VH7TTZ&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Goldratt's Rules of Flow&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;While I enjoy these short novels, they do not serve as a concise technical reference. Is there a comprehensive reference for Theory of Constraints?&lt;/p&gt;&#xA;" OwnerUserId="10338" LastActivityDate="2024-02-21T15:33:17.447" Title="Theory of Contraints Technical Reference" Tags="|constraint|reference-request|production-planning|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11702" PostTypeId="1" CreationDate="2024-02-21T16:25:09.263" Score="0" ViewCount="19" Body="&lt;p&gt;In many systems the completion of an activity takes an amount of time that is not perfectly predictable. In statistics we would consider these to be &lt;a href=&quot;https://en.wikipedia.org/wiki/Random_variable&quot; rel=&quot;nofollow noreferrer&quot;&gt;random variables&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For two measurements of time &lt;span class=&quot;math-container&quot;&gt;$t_1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$t_2$&lt;/span&gt; I can readily evaluate &lt;span class=&quot;math-container&quot;&gt;$\mathbb{1} [t_1 \leq t_2]$&lt;/span&gt;. When I consider the ensemble of measurement outcomes I have to consider &lt;span class=&quot;math-container&quot;&gt;$\mathbb{1} [T_1 \leq T_2]$&lt;/span&gt; which compares random variables.&lt;/p&gt;&#xA;&lt;p&gt;Considering ordering on random quantities like this is termed &lt;a href=&quot;https://en.wikipedia.org/wiki/Stochastic_ordering&quot; rel=&quot;nofollow noreferrer&quot;&gt;stochastic ordering&lt;/a&gt;, with particular notions of &lt;a href=&quot;https://en.wikipedia.org/wiki/Stochastic_dominance&quot; rel=&quot;nofollow noreferrer&quot;&gt;stochastic dominance&lt;/a&gt; coming to mind.&lt;/p&gt;&#xA;&lt;p&gt;In &lt;a href=&quot;https://en.wikipedia.org/wiki/Theory_of_constraints&quot; rel=&quot;nofollow noreferrer&quot;&gt;ToC&lt;/a&gt; we would like to identity which activities in a sequence is the slowest step, termed a &amp;quot;bottleneck&amp;quot;. But knowing that different notions of stochastic ordering raises a question of what form of stochastic dominance is the most relevant in order to make ToC work?&lt;/p&gt;&#xA;" OwnerUserId="10338" LastActivityDate="2024-02-21T16:25:09.263" Title="What notion of ordering is the important for identifying bottlenecks in Theory of Constraints?" Tags="|constraint|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11703" PostTypeId="1" CreationDate="2024-02-21T20:37:25.353" Score="1" ViewCount="17" Body="&lt;p&gt;I have a modelling project using a &lt;a href=&quot;https://en.wikipedia.org/wiki/Kelly_network&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kelly network&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;An observation I have made is that the bottlenecks based on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Marginal_distribution&quot; rel=&quot;nofollow noreferrer&quot;&gt;marginal distributions&lt;/a&gt; of service times is not always the same as the bottlenecks based the &lt;a href=&quot;https://en.wikipedia.org/wiki/Conditional_probability_distribution&quot; rel=&quot;nofollow noreferrer&quot;&gt;conditional distribution&lt;/a&gt; of service times where the conditioning event is the customer class.&lt;/p&gt;&#xA;&lt;p&gt;It is an analogous problem to &lt;a href=&quot;https://en.wikipedia.org/wiki/Simpson%27s_paradox&quot; rel=&quot;nofollow noreferrer&quot;&gt;Simpson's paradox&lt;/a&gt; except we're considering the set of bottlenecks instead of the reversing of trends.&lt;/p&gt;&#xA;&lt;p&gt;There may exist a &lt;a href=&quot;https://en.wikipedia.org/wiki/Pareto_front&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pareto front&lt;/a&gt; of allocation options that involve either exploiting the marginal vs conditional constraints of a system.&lt;/p&gt;&#xA;&lt;p&gt;Does &lt;a href=&quot;https://en.wikipedia.org/wiki/Theory_of_constraints&quot; rel=&quot;nofollow noreferrer&quot;&gt;TOC&lt;/a&gt; weigh in on how I should consider marginal bottlenecks vs conditional bottlenecks?&lt;/p&gt;&#xA;" OwnerUserId="10338" LastActivityDate="2024-02-21T20:37:25.353" Title="Does Theory of Constraints weigh in on marginal vs conditional bottlenecks?" Tags="|constraint|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11705" PostTypeId="1" AcceptedAnswerId="11710" CreationDate="2024-02-22T03:32:03.020" Score="-1" ViewCount="139" Body="&lt;h1&gt;The optimization task&lt;/h1&gt;&#xA;&lt;p&gt;The optimization task concerned here is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A square matrix &lt;span class=&quot;math-container&quot;&gt;$A\in \mathbb{R^{5\times 5}}$&lt;/span&gt; satisfies the condition: the elements of the first row all are 1, the elements of the second row are 1,-1,1,-1,1, from left to right. &lt;span class=&quot;math-container&quot;&gt;$\text{trace}(A A^{\mathsf{T}}) =28$&lt;/span&gt;. Find maximum value of &lt;span class=&quot;math-container&quot;&gt;$\det(A)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h1&gt;Key points&lt;/h1&gt;&#xA;&lt;p&gt;Gurobi version 11.0&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Accroding to &lt;a href=&quot;https://or.stackexchange.com/a/5908/12223&quot;&gt;this answer&lt;/a&gt;, we can transform the problem to a bilinear problem by introducing new variables and corresponding constraints. What's the fastest way to convert the problem to bilnear optimize-objective? Any automation tool?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;del&gt;&lt;code&gt;gurobipy.GurobiError: Unable to convert argument to an expression&lt;/code&gt; How to convert sympy expression to gurobi expression?&lt;/del&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;gurobipy.GurobiError: Invalid argument to QuadExpr multiplication&lt;/code&gt;. Does gurobi support up to degree-2 polynomial optimize-objective? Does YALMIP suport it?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;Description&lt;/h1&gt;&#xA;&lt;p&gt;I was trying to use gurobi for optimization.&lt;/p&gt;&#xA;&lt;p&gt;But it error &lt;code&gt;gurobipy.GurobiError: Unable to convert argument to an expression&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Set parameter NonConvex to value 2&#xA;objective=2*x31*x42*x53 - 2*x31*x42*x55 - 2*x31*x43*x52 + 2*x31*x43*x54 - 2*x31*x44*x53 + 2*x31*x44*x55 + 2*x31*x45*x52 - 2*x31*x45*x54 - 2*x32*x41*x53 + 2*x32*x41*x55 + 2*x32*x43*x51 - 2*x32*x43*x55 - 2*x32*x45*x51 + 2*x32*x45*x53 + 2*x33*x41*x52 - 2*x33*x41*x54 - 2*x33*x42*x51 + 2*x33*x42*x55 + 2*x33*x44*x51 - 2*x33*x44*x55 - 2*x33*x45*x52 + 2*x33*x45*x54 + 2*x34*x41*x53 - 2*x34*x41*x55 - 2*x34*x43*x51 + 2*x34*x43*x55 + 2*x34*x45*x51 - 2*x34*x45*x53 - 2*x35*x41*x52 + 2*x35*x41*x54 + 2*x35*x42*x51 - 2*x35*x42*x53 + 2*x35*x43*x52 - 2*x35*x43*x54 - 2*x35*x44*x51 + 2*x35*x44*x53&#xA;constraint=x31**2 + x32**2 + x33**2 + x34**2 + x35**2 + x41**2 + x42**2 + x43**2 + x44**2 + x45**2 + x51**2 + x52**2 + x53**2 + x54**2 + x55**2 + 10&#xA;Traceback (most recent call last):&#xA;  File &amp;quot;E:\Desktop\gurobipy_demo\gurobi_py_example.py&amp;quot;, line 272, in &amp;lt;module&amp;gt;&#xA;    m.setObjective(objective, GRB.MAXIMIZE)&#xA;  File &amp;quot;src\\gurobipy\\model.pxi&amp;quot;, line 1488, in gurobipy.Model.setObjective&#xA;  File &amp;quot;src\\gurobipy\\util.pxi&amp;quot;, line 44, in gurobipy._simpleexpr&#xA;gurobipy.GurobiError: Unable to convert argument to an expression&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import gurobipy as gp&#xA;from gurobipy import GRB&#xA;from sympy import symbols, Matrix, det&#xA;&#xA;# Define the size of the matrix&#xA;n = 5&#xA;&#xA;# Create a symbolic matrix&#xA;x = symbols('x1:6(1:6)')&#xA;matrixA = Matrix(n, n, lambda i,j: x[n*i + j])&#xA;&#xA;# Replace the first two rows with the given arrays&#xA;# print(f&amp;quot;{matrixA[0, :]=}&amp;quot;)&#xA;matrixA[0, :] = Matrix([[1]*n])&#xA;matrixA[1, :] = Matrix([[1, -1, 1, -1, 1]])&#xA;&#xA;# Calculate the determinant using sympy&#xA;detA = det(matrixA)&#xA;&#xA;# Create a new model&#xA;m = gp.Model(&amp;quot;max_det&amp;quot;)&#xA;m.setParam('nonconvex', 2)&#xA;&#xA;&#xA;# Define the variables&#xA;gurobi_vars = matrixA[2:, :].reshape(3*n,1)&#xA;vars = m.addVars(len(gurobi_vars), lb=-GRB.INFINITY, ub=GRB.INFINITY)&#xA;&#xA;# Update model to integrate new variables&#xA;m.update()&#xA;&#xA;# Define the objective to maximize the determinant&#xA;objective = detA.subs({sym: var for sym, var in zip(gurobi_vars, vars.values())})&#xA;print(f&amp;quot;{objective=}&amp;quot;)&#xA;&#xA;# Add the constraint for the trace&#xA;AmultTransposeA = matrixA@(matrixA.T)&#xA;trace = sum(AmultTransposeA[i, i] for i in range(n))&#xA;constraint = trace.subs({sym: var for sym, var in zip(gurobi_vars, vars.values())})&#xA;print(f&amp;quot;{constraint=}&amp;quot;)&#xA;&#xA;m.setObjective(objective, GRB.MAXIMIZE)&#xA;m.addConstr(constraint == 28, &amp;quot;trace_constraint&amp;quot;)&#xA;&#xA;# Optimize the model&#xA;m.optimize()&#xA;&#xA;# Output the solution&#xA;if m.status == GRB.OPTIMAL:&#xA;    solution = m.getAttr('x', vars)&#xA;    print(&amp;quot;The optimized determinant is: &amp;quot;, m.objVal)&#xA;    for v in vars.values():&#xA;        print(f&amp;quot;{v.VarName} = {solution[v]}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;# Assuming you have already initialized your Gurobi model 'm' and added variables&#xA;&#xA;# Define your variables in Gurobi&#xA;x = m.addVars([(i,j) for i in range(3, 6) for j in range(1, 6)], lb=-GRB.INFINITY, name=&amp;quot;x&amp;quot;)&#xA;&#xA;# Update the model to integrate new variables&#xA;m.update()&#xA;&#xA;# Now, build the objective function using Gurobi's quicksum and the provided expression&#xA;objective = (2*x[3,1]*x[4,2]*x[5,3] - 2*x[3,1]*x[4,2]*x[5,5] - 2*x[3,1]*x[4,3]*x[5,2] +&#xA;             2*x[3,1]*x[4,3]*x[5,4] - 2*x[3,1]*x[4,4]*x[5,3] + 2*x[3,1]*x[4,4]*x[5,5] +&#xA;             2*x[3,1]*x[4,5]*x[5,2] - 2*x[3,1]*x[4,5]*x[5,4] - 2*x[3,2]*x[4,1]*x[5,3] +&#xA;             2*x[3,2]*x[4,1]*x[5,5] + 2*x[3,2]*x[4,3]*x[5,1] - 2*x[3,2]*x[4,3]*x[5,5] -&#xA;             2*x[3,2]*x[4,5]*x[5,1] + 2*x[3,2]*x[4,5]*x[5,3] + 2*x[3,3]*x[4,1]*x[5,2] -&#xA;             2*x[3,3]*x[4,1]*x[5,4] - 2*x[3,3]*x[4,2]*x[5,1] + 2*x[3,3]*x[4,2]*x[5,5] +&#xA;             2*x[3,3]*x[4,4]*x[5,1] - 2*x[3,3]*x[4,4]*x[5,5] - 2*x[3,3]*x[4,5]*x[5,2] +&#xA;             2*x[3,3]*x[4,5]*x[5,4] + 2*x[3,4]*x[4,1]*x[5,3] - 2*x[3,4]*x[4,1]*x[5,5] -&#xA;             2*x[3,4]*x[4,3]*x[5,1] + 2*x[3,4]*x[4,3]*x[5,5] + 2*x[3,4]*x[4,5]*x[5,1] -&#xA;             2*x[3,4]*x[4,5]*x[5,3] - 2*x[3,5]*x[4,1]*x[5,2] + 2*x[3,5]*x[4,1]*x[5,4] +&#xA;             2*x[3,5]*x[4,2]*x[5,1] - 2*x[3,5]*x[4,2]*x[5,3] + 2*x[3,5]*x[4,3]*x[5,2] -&#xA;             2*x[3,5]*x[4,3]*x[5,4] - 2*x[3,5]*x[4,4]*x[5,1] + 2*x[3,5]*x[4,4]*x[5,3])&#xA;&#xA;# Set the objective&#xA;m.setObjective(objective, GRB.MAXIMIZE)&#xA;&#xA;# Similarly for the constraint&#xA;constraint = (x[3,1]**2 + x[3,2]**2 + x[3,3]**2 + x[3,4]**2 + x[3,5]**2 +&#xA;              x[4,1]**2 + x[4,2]**2 + x[4,3]**2 + x[4,4]**2 + x[4,5]**2 +&#xA;              x[5,1]**2 + x[5,2]**2 + x[5,3]**2 + x[5,4]**2 + x[5,5]**2 + 10)&#xA;&#xA;# Add the constraint to the model&#xA;m.addConstr(constraint == 28, &amp;quot;trace_constraint&amp;quot;)&#xA;&#xA;# Optimize the model&#xA;m.optimize()&#xA;&#xA;# Output the solution&#xA;if m.status == GRB.OPTIMAL:&#xA;    solution = m.getAttr('x', x)&#xA;    print(&amp;quot;The optimized determinant is: &amp;quot;, m.objVal)&#xA;    for var in x.values():&#xA;        print(f&amp;quot;{var.VarName} = {var.X}&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12223" LastEditorUserId="12223" LastEditDate="2024-02-22T13:20:44.253" LastActivityDate="2024-02-29T02:04:24.687" Title="How to describe nonlinear programming in gurobipy?" Tags="|python|gurobi|nonlinear-programming|nonconvex-programming|gurobipy|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11706" PostTypeId="1" CreationDate="2024-02-22T08:00:17.377" Score="4" ViewCount="2458" Body="&lt;p&gt;I have found so many tools that can solve optimization problems (wikipedia also has one page &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_optimization_software&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;List of optimization software&amp;quot;&lt;/a&gt;), I want to know which workflow is the best or &lt;span class=&quot;math-container&quot;&gt;$\color{blue}{\text{the most practical}}$&lt;/span&gt;? Any preference?&lt;/p&gt;&#xA;&lt;h1&gt;Minor&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://docs.qaekwy.io/docs/what-is-qaekwy/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Qaekwy&lt;/a&gt; is a powerful and flexible constraint-based modelling and optimization framework designed to tackle complex problem-solving scenarios.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;Miscelleous&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Wolfram Mathematica built-in close-source functions. See &lt;a href=&quot;https://reference.wolfram.com/language/guide/Optimization.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this guide&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;MiniZinc IDE &lt;a href=&quot;https://minizinc-ide.netlify.app/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Try it online.&lt;/a&gt;  model file name example: model.mzn&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://developers.google.com/optimization/introduction?hl=zh-cn&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google OR-Tools&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.lindo.com/index.php/products/lingo-and-optimization-modeling&quot; rel=&quot;nofollow noreferrer&quot;&gt;LINGO&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.coin-or.org/Bonmin/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bonmin&lt;/a&gt; (free, open-source) and &lt;a href=&quot;https://www.artelys.com/fr/solveurs/knitro/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Knitro&lt;/a&gt; (commercial) are the best suited solvers to solve problems with black box functions with derivatives and integer (and possibly continuous) variables.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;Abbreviations&lt;/h1&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;Abbreviations&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Linear programming (LP)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Quadratic programming (QP)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Second-order cone programming (SOCP)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Semidefinite programming (SDP)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Geometric programming (GP)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Nonlinear programming (NLP)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Nonlinear SDP (NLSDP)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Exponential cone programming (ECP)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Mixed-integer LP (MIQP)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Mixed-integer QP (MIQP)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Mixed-integer SOCP (MISOCP)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&lt;/div&gt;&#xA;&lt;h1&gt;DSL(Domain Specific Language)&lt;/h1&gt;&#xA;&lt;h3&gt;Programming Language&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Python&lt;/li&gt;&#xA;&lt;li&gt;MATLAB&lt;/li&gt;&#xA;&lt;li&gt;Wolfram Language&lt;/li&gt;&#xA;&lt;li&gt;Julia&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt; &lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Java&lt;/li&gt;&#xA;&lt;li&gt;C++&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;model file in different format&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;AMPL syntax (&lt;a href=&quot;https://topaz.github.io/paste/#XQAAAQCQAQAAAAAAAAARiASmyXF0442c/ScERTiKuvG0PJe6GXpE+IpoFEPR8Dh/E+7CoYmSYwpsYhD+h3a31OidcJhxFA3JBusUAV07nSPtexrVVOnzLCON7D3Sv9w1kmzLOKE371+VM+diA9MIuKYPzA3CyI7prGFtp30Rg739pucJ0+Roc8FRmb3KTHDdsscyH1IVtzn1SOAWqsD3QzNAvW42MhGSPn9M97S3kvS8XIbY1L1xBE7tORYge1xU7sVc5VTkFk65vJCurBwPFSUQ/wORuufiZlcZ8DbFtrA4LEDgArYqrL6CaD9RHx8+vE8LS/4n0tUpPo+pW7iRcV/XPsDPN0lpVbl/DBtH+m3/yUtS4A==&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt;). File Format: AMPL model files typically use .mod for model definitions and .dat for data files. The solution or command files often use the .run extension.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;GAMS syntax (&lt;a href=&quot;https://topaz.github.io/paste/#XQAAAQCVAgAAAAAAAAASG8nHd4zIGbSjHuTHO28kFRYM09F09+qDmQBtk/dZHd3GFS+Inf/Ujol93edSXK+YHx6RWY45RMkRG00r9jO3L+scuCXe0/oMjOehgGpqdWTKK9OzSBPWfwrXp2FEfwuhC51LjRaqtWx9ixNtz22yO4pGTvv+XGvg4AfXCYZLZQWwuP6u/CSGww4QaXfNVrddi89bsXx87h/w9JIqlYXnpV3oX8txKDVkAeOoHhZp9FUqMeWSriFXhq0yKsm2kZiYF0vctY5Xl734VNPsvLbX9NohQZVzdv9VTHYaSTmaDjVXNhLFEZibxKjLyNTKn4wD6J+GPyadlt55SmcmXaeSuTXFVh9v3BYPNcvoS45r+N+5xIIAE81/se3QyZwrfFkzxS4mONKdCzzRat4mPMvDw7Qpm90sJIRXWTMNet3KtZMT2zrxRBH35NK1vOPwOrrF1S//q5Nb+DzLqtF3ozEmSKQKJ5daDCV0+is4+5VNF57nXPyyBwqwMeFTmgDGaDXIe6Sl+/0v280=&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt;). File Format: GAMS uses .gms for its model files.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;MOSEL syntax (&lt;a href=&quot;https://topaz.github.io/paste/#XQAAAQA+AgAAAAAAAAAmk8SPDD3iuSx/pFZbIJr/idrV5WoCUL+lU904YrkQNAfgETmnCKQWbk7AetD/4LtYEpI5ol3QVjzI4qxj/xrEafKIWN0bOkH01R8X7iXZ+VcvqFi/lRI352K4ZwzdatmLOnhR6wNr8FDZ2WiuMY9AvXD4JENQtLdV+9ASca3Wwo1ZqBXrQ/BmThfTt1SycfIUvWXhA099W/b0p5aFkl9Ygkc5iN0HiyZNDlVBMC61f6tqBr0DpPr6wikNWFxg0MdyZm4fRBycoeyl9Qw/2HwQUZpSwF9zCr2NoOO4iL+tUe2XsZnqBZBE7/QVE9NSy7mf8Utl9q8lgjjLtuxQQtO4VUvg0cz8Augzbi6r6fm9spwcv70BzyydPj0V2re0FjGhESgmajy1wcvJGMjLH0ADVLOPM3nxz8LtRjS62a4QGmBWCW1l0r1FQGrC5nmAERKJf1roCLnt3XORa3fVafS/miNp6xBSwc9A+udcTLF9vPunhC6b+/afaw==&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt;). File Format: MOSEL models are usually saved with the .mos file extension.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;MPS syntax (&lt;a href=&quot;https://topaz.github.io/paste/#XQAAAQB5BAAAAAAAAAARiAQ4rwlCtXhVmyJp2mWYOXFTolHFoBO7/7rsYkEKDDaS6q1LMa36gLh+2X3My72+RMdvWVFZihxPHNR/EcZB3adVAKcLLVRBbQCx8oa+7PyDMHCdV2TDqh6AMnwWuUlIwfMhYBCfHeLYqmobbrbCj5wImu4gpT5rXwNtRYdSuN4rgsgy3Yhby86opcuuVI1rD70d63bbErthCR6F433q2wtuLo8o+Im4xGDJgspjY9c8FD54KX5Q6CuF+Zra5dOlIdnF7Uz7ZSBLFz8tFOd7UqMvTdYPZGYZ4OOwXEFGFAhCtcpz6iPyZysNfchD7gPx+qp19z5NMWJ+Ap6qzBkaA+MziE8M+pSpFIOG20zmnTeb1ozssUDKFNxSKxUJTViLamy5ThscSvW5FPfGyxq/2R2gxsLnpD+FJZW/RJLHpeR9VTP2yI9ppQ7nZKFSeT6+N2T4GuiSbuCVxpdLtcCHGXqkrfb2VFpSDYo6R6TWpukVLHRtQDesGA86wlhvItLu175Q/T8LKXSgnrSaSm9Zf46cykCwZZLs5YxcRKXhttlHmOqrtbv3XmG4urE1BhJaXjrg7Q/zE7IorU0vosLO/vd5jJOVZ2BqVytXoNulBl1+wvGdbYa/+ZbBixGnied2eVt0eeRoRsi4k04XBPpVrJdVRa6CPKOusfhUU9uEws1OxeHZifzomAt2+WcSfKiDbRRYgIINj9PB4RySevBYFND2apfvJVc+aEnYcHWG0f58DpA=&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt;). File Format: MPS (Mathematical Programming System) is a file format for representing linear programming (LP) and mixed-integer programming (MIP) models. The standard file extension for MPS files is .mps.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;NL File Format: The NL file format is used by the AMPL solver library. It represents nonlinear program structures. The file extension for NL files is .nl.  The NL file format is a &lt;strong&gt;binary format&lt;/strong&gt; used by the AMPL solver library to represent nonlinear programming problems. If you need to work with NL files directly, you would typically use a specialized tool or library capable of reading and writing this format, such as the AMPL Solver Library (ASL)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;OSIL syntax (&lt;a href=&quot;https://topaz.github.io/paste/#XQAAAQBlBgAAAAAAAAAeD8uHEdjOZpEPgx7K/Xsz1H/pt9ooMXYlZiBNKgltavcpcDgw58wdVhdR2zUlS66bQ9RHWciFKPqz2pY3VfVjx/u/zoq3OeMQ8E4VSOQ01UgGxi86qkcDO2RSW7wd1wTayj/83yZZ10t0/WNA55+xhZX87sdcr4rVvzQIIVfaPPe0j0+f2lh9zKnFrc7X/QH1591LyaROZrWmUoof7tMJUYDUvDR2GkD2g3+MJ2uS4QE/SaN6UPu2+AyVaaDCfCo7TUtXPpnxzkdKZyHYMOw0ZGlAaOPmI1xaoz74gDwhwpHPyWcN1cneu7gE6OqWnRrp5iYKu+iAt3V5tyYz6XRRlBGvBdja6c7Y+pzL/RpdjE5rfMUvMxxeNhayKOgktj8cEIcEijeFXMHz5Pi7J/gGJUFYTS8TWLoAnZsSHNRYtgAsOlNfY3sjljmtt6UCTRvZgMn77cYzFqse0VBfVO3gA5oR+p3M2mztYeQ4kxfdj27ml3pjnq5xwjQn9i9WWi5AKSgDXMPzW7XNBjrPAKkpNahdRAaboN9yptELKRjCjfBedd9/V7fuEhjz80d2YJ7myXaE1S5wBk0foKMdVwU0HMfbtr/to6yXcD8z+22FYNRSL8Vv8vFSBP6+KPF6bfVarEJh3MTsEjiTIvHCKvP3KT9S31hMB1ZCwEVf2XmdwLQJHtTK0d8WJhIMnWapP5Fcwb7yR60EpuA7H4PliHHb9vguE8BD/Yz2rtHV353FPlSDu5gHvvWp+s8tvcwGM6hTUVE32lp2/EPwVa7osLQ2JqfvRft7HrECioSfrWaMiHAXGoEby6djF3S5w/8CG49L0F9Ev1EhCQRqfA+IDZzfh+/Xj8i2vorik+zjoXknz/tUlNA=&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt;). File Format: OSIL (Optimization Services Instance Language) is an XML-based file format for representing optimization problems. The file extension for OSIL files is .osil.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;ZIMPL syntax (&lt;a href=&quot;https://topaz.github.io/paste/#XQAAAQDEAQAAAAAAAAARiAkoWUlu4lan+EjKZApQkgB/zLlo7vveV0ALX8XknrbOyzS5S6LuwAmQrGDcVWa7ipTb1Y6iZaZKTya2UuJ3gUyDqxIFfVXo9a31M87+ozLFAxXe1d1OZF8vGbMLO64wcscIURP5k/fQoUhCgK0TQOxKeV3X/2d0aRnF2TlSOS9P0LEkWOaz6wSQrXwGwUYccykSRVBiafIALxcCvpWmgo+dXZyJ9ldbzTsPL+8XbqYOmWmqtM0wF+vk2ZkMbxL55421BXxHjhDpikjDsu3TmBRFX3xKJ6TNMAlMgmBCBW59HgmjC5Chk0A00hy78RH4W8UjmzDLCYFUtYVpMartVZmzKfqLk9sJbuuwKAjl/WwCGuVj6s7+b+Wevr/6M1o9&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt;). File Format: ZIMPL (Zuse Institute Mathematical Programming Language) is a modeling language used to generate LP and MIP models that can be read by a variety of solvers. ZIMPL models typically use the .zpl extension.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;SDPA syntax (&lt;a href=&quot;https://topaz.github.io/paste/#XQAAAQDMAAAAAAAAAAAREUsGE5vI5Ngbr1s7fXdcAkscgyPwnrRg6KH7U32tZag8vklCRHi1q5Sh48lA2qDJZkBNy4WlQHYZtxS065C+VQ9BkiyK39RMs59eydG6E+OYQP/d42Gl7ijpzl8+BOKUphXC5XemSriP0OmgyFyHDABicx9jYGlx82cEVGPwisxWQ6z88sXnVfoyA/sDJAA=&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt;). File Format: SDPA (Semidefinite Program Algorithm) files are used for semidefinite programming. They typically have the .dat-s extension for data files, with corresponding .sdpa for problem description files.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Glue?&lt;/h1&gt;&#xA;&lt;p&gt;Python-based&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;cvxpy&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;gurobipy&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.pyomo.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pyomo&lt;/a&gt; is a Python-based open-source software package that supports a diverse set of optimization capabilities for formulating, solving, and analyzing optimization models.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://coin-or.github.io/pulp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PuLp&lt;/a&gt; is a free open source software written in Python. It is used to describe optimisation problems as mathematical models.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://pyvrp.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PyVRP&lt;/a&gt; is an open-source, state-of-the-art vehicle routing problem (VRP) solver.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://gekko.readthedocs.io/en/latest/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GEKKO&lt;/a&gt; is a Python package for machine learning and optimization of mixed-integer and differential algebraic equations.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;MATLAB-based&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt; &lt;a href=&quot;https://yalmip.github.io/download/&quot; rel=&quot;nofollow noreferrer&quot;&gt;YALMIP&lt;/a&gt;, a tool that can use different optimization solver with MATLAB DSL&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://cvxr.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;CVX: a Matlab-based convex modeling framework&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/sqlp/sdpt3&quot; rel=&quot;nofollow noreferrer&quot;&gt;SDPT3&lt;/a&gt; is a Matlab package for solving convex optimization problems involving linear equations and inequalities, second-order cone constraints, and semidefinite constraints (linear matrix inequalities).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Julia-based&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://jump.dev/JuMP.jl/stable/&quot; rel=&quot;nofollow noreferrer&quot;&gt;JuMP&lt;/a&gt; is a domain-specific modeling language for mathematical optimization embedded in Julia.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Cpp-based&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://www.gnu.org/software/glpk/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GLPK (GNU Linear Programming Kit) package&lt;/a&gt; is intended for solving large-scale linear programming (LP), mixed integer programming (MIP), and other related problems. It is a set of routines written in ANSI C and organized in the form of a callable library.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\cdots$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Solver&lt;/h1&gt;&#xA;&lt;h3&gt;&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gurobi.com/downloads/gurobi-software/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi Optimizer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://sedumi.ie.lehigh.edu/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SeDuMi&lt;/a&gt;, a great piece of software for optimization over symmetric cones.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.ibm.com/products/ilog-cplex-optimization-studio/cplex-optimizer&quot; rel=&quot;nofollow noreferrer&quot;&gt;IBM CPLEX&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;XPRESS&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.scipopt.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SCIP&lt;/a&gt;, is currently one of the fastest non-commercial solvers for mixed integer programming (MIP) and mixed integer nonlinear programming (MINLP).&lt;/li&gt;&#xA;&lt;li&gt;CBC&lt;/li&gt;&#xA;&lt;li&gt;FMINCON&lt;/li&gt;&#xA;&lt;li&gt;FICO-Xpress&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.mosek.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;mosek&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://yalmip.github.io/solver/bmibnb/&quot; rel=&quot;nofollow noreferrer&quot;&gt;BMIBNB&lt;/a&gt;, support Global nonconvex programming, YALMIP built-in solver&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://timefold.ai/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Timefold&lt;/a&gt; is the open source AI solver to optimize operations and scheduling in Java, Python or Kotlin.&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Nonlinear optimization specific?&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.artelys.com/solvers/knitro/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Knitro&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://ccom.ucsd.edu/%7Eoptimizers/solvers/snopt/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SNOPT&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://coin-or.github.io/Ipopt/&quot; rel=&quot;nofollow noreferrer&quot;&gt;IPOPT&lt;/a&gt; is an open source software package for large-scale nonlinear optimization.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h4&gt;SAT solver (specific)?&lt;/h4&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;a href=&quot;https://fmv.jku.at/kissat/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kissat&lt;/a&gt; SAT solver is a condensed and improved reimplementation of CaDiCaL in C.&lt;/li&gt;&#xA;&lt;li&gt;The goal of &lt;a href=&quot;https://fmv.jku.at/cadical/&quot; rel=&quot;nofollow noreferrer&quot;&gt;CaDiCaL&lt;/a&gt; is to provide a clean and efficient state-of-the-art CDCL solver, which is also easy to understand and change.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;Cloud Platform&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://neos-server.org/neos/solvers/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;NEOS Solvers&lt;/a&gt;, a free internet-based service for solving numerical optimization problems.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="12223" LastEditorUserId="12223" LastEditDate="2024-03-17T10:15:24.117" LastActivityDate="2024-03-17T10:15:24.117" Title="I have found so many tools that can solve optimization problems, I want to know which workflow is the best or the most practical?" Tags="|optimization|software|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11707" PostTypeId="2" ParentId="11706" CreationDate="2024-02-22T08:31:18.930" Score="1" Body="&lt;p&gt;Here is my workflow, maybe not the best:&lt;/p&gt;&#xA;&lt;p&gt;For simple optmization tasks, I'd like to use Mathematica &lt;code&gt;Minimize&lt;/code&gt;/&lt;code&gt;NMinimize&lt;/code&gt; or &lt;code&gt;Maximize&lt;/code&gt;/&lt;code&gt;NMaximize&lt;/code&gt; function, use it as a downstream of some previous Mathematica calculations. So convient.&lt;/p&gt;&#xA;&lt;p&gt;For special types of problems (like VRP, scheduling, 2-SAT, etc.), I'd like to use Google OR-Tools module/submodule &lt;code&gt;ortools.sat.python&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In Python language, I'd like to use &lt;code&gt;cvxpy&lt;/code&gt;, &lt;code&gt;gurobipy&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In MATLAB language, I'd like to use Optmization Toolbox, CVX, YALMIP&lt;/p&gt;&#xA;&lt;p&gt;For one new machine, I'd like to submit jobs(AMPL syntax: .mod file, etc.) to NEOS Solvers.&lt;/p&gt;&#xA;" OwnerUserId="12223" LastEditorUserId="12223" LastEditDate="2024-02-29T02:18:35.840" LastActivityDate="2024-02-29T02:18:35.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11708" PostTypeId="2" ParentId="11706" CreationDate="2024-02-22T08:59:21.413" Score="5" Body="&lt;p&gt;The strategy is very dependent on the nature of the optimization problem. Step 1 is creating the mathematical model. If it is an unconstrained optimization problem (including non-linear ones) then equation-solving tools would be a better idea. If it is a more classical optimization model with lots of constraints then the second decision point is the size of the instance. If it is a very small toy problem (less than 200 variables) even Excel Solver can be used. If it is larger, then the third decision point comes. Here, you need to check if it is a very standard optimization problem or not. If it is, then you can prefer Google OR Tools. It has many generic solvers specific to special types of problems (like VRP, scheduling, etc.). Of course your problem &amp;amp; data structure should be fitting GORT standards. If your problem is very unique with lots of custom stuff, data manipulation, etc, then I prefer a more strong programming language (Python, C++, etc.) and a stronger solver (Gurobi, CPLEX, SCIP, etc.).&lt;/p&gt;&#xA;" OwnerUserId="632" LastEditorUserId="-1" LastEditDate="2024-02-26T13:44:38.680" LastActivityDate="2024-02-26T13:44:38.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11709" PostTypeId="2" ParentId="11705" CreationDate="2024-02-22T09:17:45.040" Score="0" Body="&lt;p&gt;My final plan is using MATLAB, YALMIP&lt;/p&gt;&#xA;&lt;p&gt;The plan really does work.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The optimization task is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A square matrix &lt;span class=&quot;math-container&quot;&gt;$A\in \mathbb{R^{5\times 5}}$&lt;/span&gt; satisfies the condition: the elements of the first row all are 1, the elements of the second row are 1,-1,1,-1,1, from left to right. &lt;span class=&quot;math-container&quot;&gt;$\text{trace}(A A^{\mathsf{T}}) =28$&lt;/span&gt;. Find maximum value of &lt;span class=&quot;math-container&quot;&gt;$\det(A)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;pre class=&quot;lang-matlab prettyprint-override&quot;&gt;&lt;code&gt;clear all;close all;clc;&#xA;&#xA;% Define the size of the matrix&#xA;n = 5;&#xA;&#xA;% Create the symbolic matrix A with YALMIP variables&#xA;A = sdpvar(n,n,'full');&#xA;&#xA;% Set the first row to all ones&#xA;A(1,:) = ones(1, n);&#xA;&#xA;% Set the second row to the specified pattern&#xA;A(2,:) = [1, -1, 1, -1, 1];&#xA;&#xA;% Define the constraint for the trace of A * A'&#xA;Constraint = (trace(A * A.') == 28);&#xA;&#xA;% Objective function is the determinant of A&#xA;Objective = for_loop_implemented_det(A);   % Directly replacing det(A) here doesn't work, YALMIP can't analyze it&#xA;&#xA;% Options for the solver (optional, depending on the solver you use)&#xA;% Define solver settings with increased maximum iterations&#xA;options = sdpsettings('verbose', 1, 'solver', 'BMIBNB', 'debug', 1, 'bmibnb.maxiter', 10000, 'bmibnb.maxtime', 3600);&#xA;&#xA;% Run the optimization to maximize the determinant of A subject to the constraint&#xA;sol = optimize(Constraint, -Objective, options); % The `optmize` function wants the second entry objective to be as small as possible, so it takes a negative sign and wants to find the maximum value of the determinant of the matrix A&#xA;&#xA;% Check if the solution is successful&#xA;if sol.problem == 0&#xA;    % Solution is found&#xA;    disp('The optimized matrix A is:');&#xA;    A_value = value(A);&#xA;    disp(A_value);&#xA;    fprintf(&amp;quot;det(A)=%g\n&amp;quot;,det(A_value));&#xA;else&#xA;    % No solution found&#xA;    disp('Failed to optimize the determinant subject to the constraint.');&#xA;    disp(yalmiperror(sol.problem));&#xA;end&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;%% function definition&#xA;function det_A = for_loop_implemented_det(A)&#xA;    % Check if A is a square matrix&#xA;    [m, n] = size(A);&#xA;    if m ~= n&#xA;        error('Input must be a square matrix.');&#xA;    end&#xA;&#xA;    % Initialize the determinant to zero&#xA;    det_A = 0;&#xA;    &#xA;    % Generate all permutations of the indices&#xA;    permsMatrix = perms(1:n);&#xA;    nPerms = size(permsMatrix, 1);&#xA;    &#xA;    % Construct the determinant calculation&#xA;    for i = 1:nPerms&#xA;        % Get current permutation&#xA;        currentPerm = permsMatrix(i, :);&#xA;        &#xA;        % Calculate the sign of the permutation (Levi-Civita symbol)&#xA;        inversions = 0;&#xA;        for j = 1:n&#xA;            for k = j+1:n&#xA;                if currentPerm(j) &amp;gt; currentPerm(k)&#xA;                    inversions = inversions + 1;&#xA;                end&#xA;            end&#xA;        end&#xA;        sign = (-1) ^ inversions;&#xA;        &#xA;        % Create product of elements as per the permutation&#xA;        productOfElements = 1;&#xA;        for j = 1:n&#xA;            productOfElements = productOfElements * A(j, currentPerm(j));&#xA;        end&#xA;        &#xA;        % Add to the determinant sum&#xA;        det_A = det_A + sign * productOfElements;&#xA;    end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12223" LastEditorUserId="12223" LastEditDate="2024-02-22T09:38:15.990" LastActivityDate="2024-02-22T09:38:15.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11710" PostTypeId="2" ParentId="11705" CreationDate="2024-02-22T11:29:19.243" Score="1" Body="&lt;p&gt;You can apply gurobipy, you just need to approach it differently.  How would you code this up for a 100x100 matrix?  The current approach using a hardcoded formula is impractical.  Instead use the power of recursion:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import gurobipy as gp&#xA;import numpy as np&#xA;&#xA;def det(A):&#xA;    v = m.addVar(lb=-float(&amp;quot;inf&amp;quot;))&#xA;    if A.shape == (2,2):&#xA;        m.addConstr(v == A[0,0]*A[1,1]-A[1,0]*A[0,1])&#xA;        return v&#xA;    expr = gp.QuadExpr()&#xA;    cofactor = 1&#xA;    for i in range(A.shape[1]):&#xA;        cols = [c for c in range(A.shape[1]) if c != i]&#xA;        expr += cofactor*A[0,i]*det(A[1:][:,cols])&#xA;        cofactor = -cofactor&#xA;    m.addConstr(v == expr)&#xA;    return v&#xA;&#xA;def trace_of_A_mult_TransposeA(A):&#xA;    expr = gp.QuadExpr()&#xA;    for i in range(A.shape[0]):&#xA;        expr += A[i]@A[i]&#xA;    return expr&#xA;&#xA;m = gp.Model()&#xA;x = m.addMVar((5,5), lb=-float(&amp;quot;inf&amp;quot;))&#xA;m.addConstr(x[0] == np.array([1]*5))&#xA;m.addConstr(x[1] == np.array([1,-1,1,-1,1]))&#xA;m.addConstr(trace_of_A_mult_TransposeA(x) == 28)&#xA;m.setObjective(det(x), gp.GRB.MAXIMIZE)&#xA;&#xA;m.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10108" LastEditorUserId="12223" LastEditDate="2024-02-29T02:04:24.687" LastActivityDate="2024-02-29T02:04:24.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11712" PostTypeId="2" ParentId="11697" CreationDate="2024-02-22T17:00:56.643" Score="1" Body="&lt;p&gt;Your problem is a form of multi-vehicle routing problem with time windows (frequently abbreviated m-VRPTW, although I believe I've also seen MVRPTW). Searching for that will turn up a variety of references. One problem is that the &amp;quot;multi&amp;quot; part is ambiguous. Here it would mean both multiple vehicles and multiple &amp;quot;depots&amp;quot; (source nodes), but other people use it for just one or the other, or possible something else entirely. Some of those references may suggest MILP models.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-02-22T17:00:56.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11713" PostTypeId="1" CreationDate="2024-02-23T00:11:57.193" Score="0" ViewCount="99" Body="&lt;p&gt;How can I find the optimal or close to optimal way to allocate a budget if I have revenue and spending data?&lt;/p&gt;&#xA;&lt;p&gt;I was thinking of using linear programming, but I'm assuming it wouldn't work as the relationship between revenue and spending isn't constant and there aren't really any constants aside from the amount being spent having to be positive.&lt;/p&gt;&#xA;&lt;p&gt;Would a multivariate time-series analysis work?&lt;/p&gt;&#xA;" OwnerUserId="13229" LastEditorUserId="491" LastEditDate="2024-02-26T12:30:31.210" LastActivityDate="2024-02-26T12:30:31.210" Title="How to Find Optimal Way to Allocate a Budget?" Tags="|optimization|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ClosedDate="2024-03-06T23:50:52.453" ContentLicense="CC BY-SA 4.0" />
  <row Id="11714" PostTypeId="1" AcceptedAnswerId="11716" CreationDate="2024-02-23T10:14:56.600" Score="2" ViewCount="51" Body="&lt;p&gt;In general, I can compute an MILP using a solver of my choice (Gurobi, ...) and stop it at any time, change parameters/constraints add variables. Take the so far best solution computed based on the last run and model as initial guess for the variables and start again.&lt;/p&gt;&#xA;&lt;p&gt;Is it also possible to do those (or some of those) changes during computation and dynamically add changed parameters, does it have advantages?&lt;/p&gt;&#xA;&lt;p&gt;E.g. computing some partitioning on a graph and adding or removing edges during computation, fixing variables to desired variables without stopping the optimization process.&lt;/p&gt;&#xA;" OwnerUserId="2989" LastEditorUserId="491" LastEditDate="2024-02-26T12:26:56.287" LastActivityDate="2024-02-26T12:26:56.287" Title="Temporal changing model parameters/constraints/variables in MILPs" Tags="|mixed-integer-programming|warm-start|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11715" PostTypeId="1" CreationDate="2024-02-23T16:27:06.560" Score="1" ViewCount="59" Body="&lt;p&gt;I am working on a problem relating to what is known as the &amp;quot;Good Deal risk measure&amp;quot; for production valuation in incomplete markets. I have created the following primal optimization problem, and I am wondering how it can be converted to its dual formulation. I am mainly curios since this is a quadratic conic program, and so I am unsure how the quadratic constraint is handled.&lt;/p&gt;&#xA;&lt;p&gt;Note that &lt;span class=&quot;math-container&quot;&gt;$N_{(t-1)}$&lt;/span&gt; can be viewed as the nodes in a scenario tree at time step &lt;span class=&quot;math-container&quot;&gt;$t-1$&lt;/span&gt;, whilst &lt;span class=&quot;math-container&quot;&gt;$N_{(t-1)m}$&lt;/span&gt; are the nodes at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; which are descendant of node &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t-1$&lt;/span&gt;. The &lt;span class=&quot;math-container&quot;&gt;$\delta_{tmn}$&lt;/span&gt; term is the probability of reaching node &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; from node m at time &lt;span class=&quot;math-container&quot;&gt;$t-1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\min _{\beta_{t n}} &amp;amp; \sum_{m \in \mathcal{N}_{t-1}} \sum_{n \in \mathcal{N}_{(t-1) m}} \delta_{t m n} \cdot \beta_{t n} \cdot\left(P_{t n}-C\right) \cdot \mathbf{x}_{t n} \\&#xA;\text { s.t. } &amp;amp; \sum_{n \in \mathcal{N}_{(t-1) m}} \delta_{t m n} \cdot \beta_{t n} \cdot f_{t n}^i=f_{(t-1) m}^i \quad i \in \mathcal{I}, m \in \mathcal{N}_{t-1} \\&#xA;&amp;amp; \sum_{n \in \mathcal{N}_{(t-1) m}} \delta_{t m n} \cdot \beta_{t n}^2 \leq A_{(t-1) m}^2 \quad m \in \mathcal{N}_{t-1} \\&#xA;&amp;amp; \beta_{t n} \geq 0 \quad n \in \mathcal{N}_t&#xA;\end{aligned}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&#xA;" OwnerUserId="13237" LastEditorUserId="12223" LastEditDate="2024-02-29T13:20:05.147" LastActivityDate="2024-02-29T13:20:05.147" Title="Quadratic conic program duality" Tags="|quadratic-programming|duality|conic-optimization|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11716" PostTypeId="2" ParentId="11714" CreationDate="2024-02-23T16:53:50.920" Score="1" Body="&lt;p&gt;Some solvers will allow you to add constraints on the fly, possibly with some restrictions. I don't think any would allow you to add variables mid-solve. Column generation techniques allow you to add variables, but between solves, not during a solve.&lt;/p&gt;&#xA;&lt;p&gt;A key limitation to what you have in mind is that the solver would require that any change you made not invalidate decisions made earlier in the solution process. In your graph partitioning example, if you remove an edge then a previously encountered feasible solution might become infeasible. If that solution was used to prune nodes, then it would be possible some of those nodes were pruned in error, and in fact might contain the true optimum. If you add a variable, conceivably a node previously pruned for infeasibility would now become feasible (and, again, potentially contain the optimum).&lt;/p&gt;&#xA;&lt;p&gt;If a solver lets you add constraints via a callback, reducing the feasible region, then it in effect binds you &amp;quot;contractually&amp;quot; to add those constraints as soon as it encounters a candidate solution that violates them. In other words, it is on you to ensure that a solution feasible in the current problem but violating a constraint you have not yet added is not accepted as an incumbent, because accepting it could result in pruning portions of the tree that should not be pruned.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-02-23T16:53:50.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11717" PostTypeId="1" CreationDate="2024-02-23T18:37:20.787" Score="0" ViewCount="73" Body="&lt;p&gt;I have implemented the following Column Generation &lt;a href=&quot;https://or.stackexchange.com/questions/11608/how-to-modify-master-problem-and-individual-sub-problems-in-column-generation&quot;&gt;model&lt;/a&gt; in Gurobi. Unfortunately, I currently have the problem that the constraint in the master problem is not linear and therefore I cannot add the column by default. I have tried to linearize the constraint, but unfortunately I can't get it to be considered in the &lt;strong&gt;Column()&lt;/strong&gt; object. This is error i get:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;NameError: name 'newcon' is not defined&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I know that the &lt;em&gt;newcon&lt;/em&gt; doesn't gets passed, but how would I need to modify my code in order to accomplish a successful &amp;quot;passing&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;And this is my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from gurobipy import *&#xA;import gurobipy as gu&#xA;import pandas as pd&#xA;import itertools&#xA;import time&#xA;import matplotlib.pyplot as plt&#xA;&#xA;# Create DF out of Sets&#xA;I_list = [1, 2, 3]&#xA;T_list = [1, 2, 3, 4, 5, 6, 7]&#xA;K_list = [1, 2, 3]&#xA;I_list1 = pd.DataFrame(I_list, columns=['I'])&#xA;T_list1 = pd.DataFrame(T_list, columns=['T'])&#xA;K_list1 = pd.DataFrame(K_list, columns=['K'])&#xA;DataDF = pd.concat([I_list1, T_list1, K_list1], axis=1)&#xA;Demand_Dict = {(1, 1): 2, (1, 2): 1, (1, 3): 0, (2, 1): 1, (2, 2): 2, (2, 3): 0, (3, 1): 1, (3, 2): 1, (3, 3): 1,&#xA;               (4, 1): 1, (4, 2): 2, (4, 3): 0, (5, 1): 2, (5, 2): 0, (5, 3): 1, (6, 1): 1, (6, 2): 1, (6, 3): 1,&#xA;               (7, 1): 0, (7, 2): 3, (7, 3): 0}&#xA;&#xA;&#xA;class MasterProblem:&#xA;    def __init__(self, dfData, DemandDF, iteration):&#xA;        self.iteration = iteration&#xA;        self.physicians = dfData['I'].dropna().astype(int).unique().tolist()&#xA;        self.days = dfData['T'].dropna().astype(int).unique().tolist()&#xA;        self.shifts = dfData['K'].dropna().astype(int).unique().tolist()&#xA;        self.roster = list(range(1, self.iteration + 2))&#xA;        self.demand = DemandDF&#xA;        self.model = gu.Model(&amp;quot;MasterProblem&amp;quot;)&#xA;        self.cons_demand = {}&#xA;        self.newvar = {}&#xA;        self.cons_lmbda = {}&#xA;&#xA;    def buildModel(self):&#xA;        self.generateVariables()&#xA;        self.generateConstraints()&#xA;        self.model.update()&#xA;        self.generateObjective()&#xA;        self.setStartSolution()&#xA;        self.model.update()&#xA;&#xA;    def generateVariables(self):&#xA;        self.slack = self.model.addVars(self.days, self.shifts, vtype=gu.GRB.CONTINUOUS, lb=0, name='slack')&#xA;        self.motivation_i = self.model.addVars(self.physicians, self.days, self.shifts, self.roster,&#xA;                                               vtype=gu.GRB.CONTINUOUS, lb=0, ub=1, name='motivation_i')&#xA;        self.lmbda = self.model.addVars(self.physicians, self.roster, vtype=gu.GRB.BINARY, lb=0, name='lmbda')&#xA;&#xA;    def generateConstraints(self):&#xA;        for i in self.physicians:&#xA;            self.cons_lmbda[i] = self.model.addConstr(gu.quicksum(self.lmbda[i, r] for r in self.roster) == 1)&#xA;        for t in self.days:&#xA;            for s in self.shifts:&#xA;                self.cons_demand[t, s] = self.model.addConstr(&#xA;                    gu.quicksum(self.motivation_i[i, t, s, r]*self.lmbda[i, r] for i in self.physicians for r in self.roster) +&#xA;                    self.slack[t, s] &amp;gt;= self.demand[t, s])&#xA;        return self.cons_lmbda, self.cons_demand&#xA;&#xA;    def generateObjective(self):&#xA;        self.model.setObjective(gu.quicksum(self.slack[t, s] for t in self.days for s in self.shifts),&#xA;                                sense=gu.GRB.MINIMIZE)&#xA;&#xA;    def solveRelaxModel(self):&#xA;        self.model.Params.QCPDual = 1&#xA;        for v in self.model.getVars():&#xA;            v.setAttr('vtype', 'C')&#xA;        self.model.optimize()&#xA;&#xA;    def getDuals_i(self):&#xA;        Pi_cons_lmbda = self.model.getAttr(&amp;quot;Pi&amp;quot;, self.cons_lmbda)&#xA;        return Pi_cons_lmbda&#xA;&#xA;    def getDuals_ts(self):&#xA;        Pi_cons_demand = self.model.getAttr(&amp;quot;QCPi&amp;quot;, self.cons_demand)&#xA;        return Pi_cons_demand&#xA;&#xA;    def getObjValues(self):&#xA;        obj = self.model.objVal&#xA;        return obj&#xA;&#xA;    def updateModel(self):&#xA;        self.model.update()&#xA;&#xA;    def addColumn(self, newSchedule, iter, index):&#xA;        self.newvar = {}&#xA;        colName = f&amp;quot;ScheduleUsed[{index},{iter}]&amp;quot;&#xA;        newScheduleList = []&#xA;        cons_demandList = []&#xA;        for i, t, s, r in newSchedule:&#xA;            newScheduleList.append(newSchedule[i, t, s, r])&#xA;        rounded_ScheduleList = ['%.2f' % elem for elem in newScheduleList]&#xA;        Column = gu.Column(rounded_ScheduleList, newcon)&#xA;        self.newvar = self.model.addVar(vtype=gu.GRB.CONTINUOUS, lb=0, column=Column, name=colName)&#xA;        self.model.update()&#xA;&#xA;    def setStartSolution(self):&#xA;        startValues = {}&#xA;        for i, t, s, r in itertools.product(self.physicians, self.days, self.shifts, self.roster):&#xA;            startValues[(i, t, s, r)] = 0&#xA;        for i, t, s, r in startValues:&#xA;            self.motivation_i[i, t, s, r].Start = startValues[i, t, s, r]&#xA;&#xA;    def solveModel(self, timeLimit, EPS):&#xA;        self.model.setParam('TimeLimit', timeLimit)&#xA;        self.model.setParam('MIPGap', EPS)&#xA;        self.model.Params.QCPDual = 1&#xA;        self.model.Params.OutputFlag = 0&#xA;        self.model.optimize()&#xA;        self.model.write(&amp;quot;d.lp&amp;quot;)&#xA;&#xA;&#xA;    def writeModel(self):&#xA;        self.model.write(&amp;quot;master.lp&amp;quot;)&#xA;&#xA;    def File2Log(self):&#xA;        self.model.Params.LogToConsole = 1&#xA;        self.model.Params.LogFile = &amp;quot;./log.txt&amp;quot;&#xA;&#xA;    def getObjVal(self):&#xA;        obj = self.model.getObjective()&#xA;        value = obj.getValue()&#xA;        return value&#xA;&#xA;    def finalSolve(self, timeLimit, EPS):&#xA;        self.model.setParam('TimeLimit', timeLimit)&#xA;        self.model.setParam('MIPGap', EPS)&#xA;        self.model.setAttr(&amp;quot;vType&amp;quot;, self.lmbda, gu.GRB.INTEGER)&#xA;        self.model.update()&#xA;        self.model.optimize()&#xA;        self.model.write(&amp;quot;dd.lp&amp;quot;)&#xA;        if self.model.status == GRB.OPTIMAL:&#xA;            print(&amp;quot;Optimal solution found&amp;quot;)&#xA;            for i in self.physicians:&#xA;                for t in self.days:&#xA;                    for s in self.shifts:&#xA;                        for r in self.roster:&#xA;                            print(f&amp;quot;Nurse {i}: Motivation {self.motivation_i[i, t, s, r].x} in Shift {s} on day {t}&amp;quot;)&#xA;        else:&#xA;            print(&amp;quot;No optimal solution found.&amp;quot;)&#xA;&#xA;&#xA;    def modifyConstraint(self):&#xA;        for t in self.days:&#xA;            for s in self.shifts:&#xA;                self.newcoef = 1.0&#xA;                current_cons = self.cons_demand[t, s]&#xA;                qexpr = self.model.getQCRow(current_cons)&#xA;                new_var = self.newvar&#xA;                new_coef = self.newcoef&#xA;                qexpr.add(new_var, new_coef)&#xA;                rhs = current_cons.getAttr('RHS')&#xA;                sense = current_cons.getAttr('Sense')&#xA;                name = current_cons.getAttr('ConstrName')&#xA;                newcon = self.model.addQConstr(qexpr, sense, rhs, name)&#xA;                self.model.removeConstr(current_cons)&#xA;                self.cons_demand[t, s] = newcon&#xA;                return newcon&#xA;class Subproblem:&#xA;    def __init__(self, duals_i, duals_ts, dfData, i, M, iteration):&#xA;        self.days = dfData['T'].dropna().astype(int).unique().tolist()&#xA;        self.shifts = dfData['K'].dropna().astype(int).unique().tolist()&#xA;        self.duals_i = duals_i&#xA;        self.duals_ts = duals_ts&#xA;        self.Max = 5&#xA;        self.Min = 2&#xA;        self.M = M&#xA;        self.alpha = 0.5&#xA;        self.model = gu.Model(&amp;quot;Subproblem&amp;quot;)&#xA;        self.index = i&#xA;        self.it = iteration&#xA;&#xA;    def buildModel(self):&#xA;        self.generateVariables()&#xA;        self.generateConstraints()&#xA;        self.generateObjective()&#xA;        print(f&amp;quot;Index: {self.index}&amp;quot;)&#xA;        self.model.update()&#xA;&#xA;    def generateVariables(self):&#xA;        self.x = self.model.addVars([self.index], self.days, self.shifts, vtype=GRB.BINARY, name='x')&#xA;        self.y = self.model.addVars([self.index], self.days, vtype=GRB.BINARY, name='y')&#xA;        self.mood = self.model.addVars([self.index], self.days, vtype=GRB.CONTINUOUS, lb=0, name='mood')&#xA;        self.motivation = self.model.addVars([self.index], self.days, self.shifts, [self.it], vtype=GRB.CONTINUOUS, lb=0, name='motivation')&#xA;&#xA;    def generateConstraints(self):&#xA;        for i in [self.index]:&#xA;            for t in self.days:&#xA;                self.model.addConstr(self.mood[i, t] == 1 - self.alpha * self.y[i, t])&#xA;                self.model.addConstr(quicksum(self.x[i, t, s] for s in self.shifts) == self.y[i, t])&#xA;                self.model.addConstr(gu.quicksum(self.x[i, t, s] for s in self.shifts) &amp;lt;= 1)&#xA;&#xA;            for t in range(1, len(self.days) - self.Max + 1):&#xA;                self.model.addConstr(gu.quicksum(self.y[i, u] for u in range(t, t + 1 + self.Max)) &amp;lt;= self.Max)&#xA;            self.model.addLConstr(quicksum(self.y[i, t] for t in self.days) &amp;gt;= self.Min)&#xA;            for t in self.days:&#xA;                for s in self.shifts:&#xA;                    self.model.addLConstr(self.motivation[i, t, s, self.it] &amp;gt;= self.mood[i, t] - self.M * (1 - self.x[i, t, s]))&#xA;                    self.model.addLConstr(self.motivation[i, t, s, self.it] &amp;lt;= self.mood[i, t] + self.M * (1 - self.x[i, t, s]))&#xA;                    self.model.addLConstr(self.motivation[i, t, s, self.it] &amp;lt;= self.x[i, t, s])&#xA;&#xA;    def generateObjective(self):&#xA;        self.model.setObjective(&#xA;            0 - gu.quicksum(self.motivation[i, t, s, self.it] * self.duals_ts[t, s] for i in [self.index] for t in self.days for s in self.shifts) -&#xA;            self.duals_i[self.index], sense=gu.GRB.MINIMIZE)&#xA;&#xA;    def getNewSchedule(self):&#xA;        return self.model.getAttr(&amp;quot;X&amp;quot;, self.motivation)&#xA;&#xA;    def getObjVal(self):&#xA;        obj = self.model.getObjective()&#xA;        value = obj.getValue()&#xA;        return value&#xA;&#xA;    def getStatus(self):&#xA;        return self.model.status&#xA;&#xA;    def solveModel(self, timeLimit, EPS):&#xA;        self.model.setParam('TimeLimit', timeLimit)&#xA;        self.model.setParam('MIPGap', EPS)&#xA;        self.model.Params.OutputFlag = 0&#xA;        self.model.optimize()&#xA;        if self.model.status == GRB.OPTIMAL:&#xA;            print(&amp;quot;Optimal solution found&amp;quot;)&#xA;            for i in [self.index]:&#xA;                for t in self.days:&#xA;                    for s in self.shifts:&#xA;                        print(f&amp;quot;Physician {self.index}: Motivation {self.x[i, t, s].x} in Shift {s} on day {t}&amp;quot;)&#xA;        else:&#xA;            print(&amp;quot;No optimal solution found.&amp;quot;)&#xA;&#xA;&#xA;#### Column Generation&#xA;# CG Prerequisites&#xA;modelImprovable = True&#xA;t0 = time.time()&#xA;max_itr = 2&#xA;itr = 0&#xA;&#xA;# Lists&#xA;objValHistSP = []&#xA;objValHistRMP = []&#xA;&#xA;# Build &amp;amp; Solve MP&#xA;master = MasterProblem(DataDF, Demand_Dict, itr)&#xA;master.buildModel()&#xA;master.File2Log()&#xA;master.updateModel()&#xA;master.solveRelaxModel()&#xA;&#xA;# Get Duals from MP&#xA;duals_i = master.getDuals_i()&#xA;duals_ts = master.getDuals_ts()&#xA;&#xA;print('*         *****Column Generation Iteration*****          \n*')&#xA;while (modelImprovable) and itr &amp;lt; max_itr:&#xA;    # Start&#xA;    itr += 1&#xA;    print('*Current CG iteration: ', itr)&#xA;&#xA;    # Solve RMP&#xA;    master.solveRelaxModel()&#xA;    objValHistRMP.append(master.getObjValues())&#xA;    print('*Current RMP ObjVal: ', objValHistRMP)&#xA;&#xA;&#xA;    # Get Duals&#xA;    duals_i = master.getDuals_i()&#xA;    duals_ts = master.getDuals_ts()&#xA;&#xA;    # Solve SPs&#xA;    modelImprovable = False&#xA;    for index in I_list:&#xA;        subproblem = Subproblem(duals_i, duals_ts, DataDF, index, 1e6, itr)&#xA;        subproblem.buildModel()&#xA;        subproblem.solveModel(3600, 1e-6)&#xA;        status = subproblem.getStatus()&#xA;        if status != 2:&#xA;            raise Exception(&amp;quot;Pricing-Problem can not reach optimality!&amp;quot;)&#xA;        reducedCost = subproblem.getObjVal()&#xA;        objValHistSP.append(reducedCost)&#xA;        print('*Reduced cost', reducedCost)&#xA;        if reducedCost &amp;lt; 1e-6:&#xA;            ScheduleCuts = subproblem.getNewSchedule()&#xA;            master.addColumn(ScheduleCuts, itr, index)&#xA;            master.modifyConstraints()&#xA;            master.updateModel()&#xA;            modelImprovable = True&#xA;    master.updateModel()&#xA;&#xA;# Solve MP&#xA;master.finalSolve(3600, 0.01)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How can i fix this problem?&lt;/p&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="11914" LastEditDate="2024-02-24T19:50:28.090" LastActivityDate="2024-03-25T20:05:30.640" Title="Gurobi - Problem with adding a non-linear constraint to a column object" Tags="|gurobi|column-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11718" PostTypeId="1" CreationDate="2024-02-23T20:40:17.407" Score="1" ViewCount="73" Body="&lt;p&gt;The basic form of my problem is as follows. Let &lt;span class=&quot;math-container&quot;&gt;$S = \{ 1, 2, ..., 30 \}$&lt;/span&gt;. I have an integer-valued function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt;, whose argument is an integer-valued vector &lt;span class=&quot;math-container&quot;&gt;$\vec{x} \in S^{200}$&lt;/span&gt;. I also know that this function is non-decreasing in &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;. I also have access to a function &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; which returns the derivative of the function &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; at a given point &lt;span class=&quot;math-container&quot;&gt;$x \in S^{200}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My first question is: what is the right formulation of this problem, in particular, what are the trade-offs of the various ways to express the decision variables? e.g. integer valued variables &lt;span class=&quot;math-container&quot;&gt;$\vec{x} = \{ x_1, x_2, ..., x_{200} \}$&lt;/span&gt; taking on values from &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; versus binary variables &lt;span class=&quot;math-container&quot;&gt;$x_{i, j}$&lt;/span&gt; for each &lt;span class=&quot;math-container&quot;&gt;$i = 1 \to 200$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j = 1 \to 30$&lt;/span&gt;, as well as a set of constraints enforcing that only one such variable can be set for each &lt;span class=&quot;math-container&quot;&gt;$i = 1 \to 200$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Secondly, I then want to model more complex constraints in addition to the above, what possible approaches should I consider? For example, I would like to introduce an additional set of variables &lt;span class=&quot;math-container&quot;&gt;$\vec{y} = \{ y_1, y_2, ..., y_{1000} \}$&lt;/span&gt; also taking on values from &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, such that each variable &lt;span class=&quot;math-container&quot;&gt;$x_i \in \vec{x}$&lt;/span&gt; is a linear function of the variables &lt;span class=&quot;math-container&quot;&gt;$\vec{y}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How does this change the classification of my problem and which approaches should I consider?&lt;/p&gt;&#xA;&lt;p&gt;I have only a high-level understanding of operations research and numerical optimization (my background is in combinatorics, so please go easy on me). I am working in Python, and would also like to know which libraries and/or solvers would be suitable for solving my problem. As I understand, it could be possible to run gradient descent given access to the derivative of this function to obtain a solution. I am also considering exploring derivative-free approaches such as genetic algorithms and so on.&lt;/p&gt;&#xA;" OwnerUserId="13239" LastEditorUserId="491" LastEditDate="2024-02-26T12:26:05.557" LastActivityDate="2024-02-26T12:26:05.557" Title="How to maximise black-box function defined on a subset of integers, with access to its derivative?" Tags="|optimization|python|nonlinear-programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11719" PostTypeId="1" AcceptedAnswerId="11721" CreationDate="2024-02-23T22:24:22.217" Score="2" ViewCount="577" Body="&lt;p&gt;Based on my on-again-off-again internet search of optimization problems over the past few years, the two terms seem to cover largely the same way of representing problems, if not the identically.  I'm not talking about solver engines in the back end, but rather, the mathematical representation.&lt;/p&gt;&#xA;&lt;p&gt;P.S. Both terms seem to also overlap with AMPL's model-based optimization, but I'm cautious about using that term because all decision aid methods are based on a model.&lt;/p&gt;&#xA;" OwnerUserId="4015" LastEditorUserId="500" LastEditDate="2024-02-24T00:43:23.747" LastActivityDate="2024-02-24T00:43:23.747" Title="Is mathematical programming synonymous with algebraic modelling?" Tags="|optimization|terminology|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11720" PostTypeId="2" ParentId="11717" CreationDate="2024-02-23T23:29:45.400" Score="0" Body="&lt;p&gt;On line 91, in the function &lt;code&gt;AddColumn&lt;/code&gt; you use newcon without defining it first.&lt;/p&gt;&#xA;" OwnerUserId="5812" LastActivityDate="2024-02-23T23:29:45.400" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11721" PostTypeId="2" ParentId="11719" CreationDate="2024-02-24T00:26:28.907" Score="4" Body="&lt;p&gt;&amp;quot;Algebraic modeling&amp;quot; can presumably mean algebraic models of any sort of system for any purpose. I see it used primarily if not exclusively for optimization problems, but that's largely because I tend to look at only optimization problems. I would think that, for example, formulas for expected waiting times in queuing systems could be considered algebraic modeling.&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;Mathematical programming&amp;quot; refers to algebraic models specifically for optimization. So I would consider it a narrower, more precise phrase than &amp;quot;algebraic modeling&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;AMPL is a platform built around an algebraic modeling language for mathematical programming.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-02-24T00:26:28.907" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11722" PostTypeId="2" ParentId="11718" CreationDate="2024-02-24T11:11:39.820" Score="2" Body="&lt;p&gt;For the modelling question, I would say that if there is really more difference between &lt;span class=&quot;math-container&quot;&gt;$x_i = 1$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i = 20$&lt;/span&gt; than between &lt;span class=&quot;math-container&quot;&gt;$x_i = 19$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_i = 20$&lt;/span&gt;, then using integers might be more relevant.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand, solvers work better with binary variables. For example, a MINLP solver can deduce new bounds for variables but cannot remove a specific value from its domain. Therefore, with integer variables, if the solver deduces than &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; cannot be equal to &lt;span class=&quot;math-container&quot;&gt;$19$&lt;/span&gt;, it won't take advantage of the information. While with binary variables, it can just set the upper bound of &lt;span class=&quot;math-container&quot;&gt;$x_{i,19}$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Using binary variables might also increase significantly the size of the model and slow down the resolution.&lt;/p&gt;&#xA;&lt;p&gt;In the end, you should experiment with both.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.coin-or.org/Bonmin/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bonmin&lt;/a&gt; (free, open-source) and &lt;a href=&quot;https://www.artelys.com/fr/solveurs/knitro/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Knitro&lt;/a&gt; (commercial) are the best suited solvers to solve problems with black box functions with derivatives and integer (and possibly continuous) variables.&lt;/p&gt;&#xA;&lt;p&gt;Another alternative could be to look at derivative-free optimization solvers such as &lt;a href=&quot;https://www.gerad.ca/en/software/nomad/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nomad&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4551" LastEditorUserId="4551" LastEditDate="2024-02-24T13:35:05.130" LastActivityDate="2024-02-24T13:35:05.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11723" PostTypeId="2" ParentId="11718" CreationDate="2024-02-24T19:03:17.693" Score="1" Body="&lt;p&gt;Let me start with a bit of terminology: we will say &lt;span class=&quot;math-container&quot;&gt;$x^{(1)}$&lt;/span&gt; dominates &lt;span class=&quot;math-container&quot;&gt;$x^{(2)}$&lt;/span&gt; if &lt;span class=&quot;math-container&quot;&gt;$x^{(1)}_i \ge x^{(2)}_i$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x^{(1)}_i \gt x^{(2)}_i$&lt;/span&gt; for some value of &lt;span class=&quot;math-container&quot;&gt;$i.$&lt;/span&gt; Since &lt;span class=&quot;math-container&quot;&gt;$f()$&lt;/span&gt; is nondecreasing and you are maximizing, at least one optimal solution will occur at a point &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; nondominated in &lt;span class=&quot;math-container&quot;&gt;$S^{200}.$&lt;/span&gt; (There may also be one or more optimal solutions at dominated points.)&lt;/p&gt;&#xA;&lt;p&gt;I can propose a heuristic, but I cannot predict how well it will work. Consider the integer linear program &lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;\max w^{\prime}x\\&#xA;\textrm{s.t. }x &amp;amp; =h(y)\\&#xA;x &amp;amp; \in S^{200}\\&#xA;y &amp;amp; \in S^{1000}&#xA;\end{align*}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$h()$&lt;/span&gt; is your linear transform from &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; to &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$w&amp;gt;&amp;gt;0$&lt;/span&gt; is a strictly positive randomly generated weight vector. The optimal solution to the problem is a nondominated point in &lt;span class=&quot;math-container&quot;&gt;$S^{200}.$&lt;/span&gt; Evaluate &lt;span class=&quot;math-container&quot;&gt;$f()$&lt;/span&gt; at that point and declare the point the initial incumbent. Now draw a new random &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; and repeat the process. If the new solution &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; produces a larger value of &lt;span class=&quot;math-container&quot;&gt;$f(),$&lt;/span&gt; record it as the new incumbent and repeat ad nauseum. It might (or might not) be useful to hot-start each IP solution either from the previous solution &lt;span class=&quot;math-container&quot;&gt;$(x, y)$&lt;/span&gt; or from the incumbent solution, both of which remain feasible since we never alter the constraints.&lt;/p&gt;&#xA;&lt;p&gt;How well this might work would clearly depend in large part on how quickly the ILPs could be solved. On the bright side, it avoids having to deal directly with the nonlinearity of &lt;span class=&quot;math-container&quot;&gt;$f().$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-02-24T19:03:17.693" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11725" PostTypeId="1" AcceptedAnswerId="11726" CreationDate="2024-02-25T10:37:28.010" Score="2" ViewCount="153" Body="&lt;p&gt;I am working on a scheduling problem which is NP-hard problem. Therefore, I decided to implement  two-stage strategy to speed up the solution process. I need to pass the values of a variable from the first stage to a parameter in the second stage. I visited this &lt;a href=&quot;https://stackoverflow.com/questions/65375150/passing-a-variable-as-a-parameter-for-a-new-model-in-gams&quot;&gt;link&lt;/a&gt; to do so. But it returned to me the error of dimension different. I appreciate any suggestion.&lt;/p&gt;&#xA;&lt;p&gt;The variable R(t,l) has to pass its values to the parameter RR(t,l).&lt;/p&gt;&#xA;&lt;p&gt;Since the model is very large, I am going to bring two simple models that are not real models:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Sets&#xA;&#xA;T     SET OF TIME POINTS   /T1*T15/&#xA;L     INPUT NODES   /L1*L2/&#xA;I     BATCHES      /I1*I7/&#xA;      ;&#xA;&#xA;parameter  RR(t,l)   It is going to be replaced by the vriable R of the first stage model  ;&#xA;&#xA;&#xA;&#xA;POSITIVE VARIABLES&#xA;&#xA;&#xA;R(T,L)    THE VOLUME OF BATCH I INJECTED FROM INPUT S DURING RUN T&#xA;RP(T,L)   THE VOLUME P IN BATCH I INJECTED FROM INPUT L DURING RUN T&#xA;VD(T,L)   THE VOLUME OF BATCH I DIVERTED TO OUTPUT D DURING TIMESLOT T&#xA;SD(I)        THE VOLUME OF I DELIVERED FROM PART L-1 TO L DURING T&#xA;&#xA;&#xA;;&#xA;&#xA;VARIABLES COST;&#xA;&#xA;&#xA;&#xA;EQUATIONS&#xA;OBJ1&#xA;OBJ2&#xA;eq1&#xA;eq2&#xA;eq3&#xA; ;&#xA;&#xA;obj1 ..  R('t1','l1') =e=cost;&#xA;obj2 ..  R('t1','l1') =e=cost;&#xA;eq1 (t,l)..  VD(t,l)=e=7;&#xA;&#xA;&#xA;eq2 (i)     ..  SD(i)=e= 8;&#xA;eq3 (t,l)..   RR(t,l)*RP(t,l)=e=5;&#xA;&#xA;OPTION LIMROW=500;&#xA;OPTION LIMCOL=100;&#xA;OPTION OPTCR=1E-3;&#xA;OPTION RESLIM=7200;&#xA;OPTION THREADS=0;&#xA;OPTION ITERLIM=90000000;&#xA;OPTION MIP=CPLEX;&#xA;&#xA;MODEL AMIRPIP /OBJ1,eq1/&#xA;      AMIR /OBJ2,eq2,eq3/;&#xA;SOLVE AMIRPIP USING MIP MINIMIZING cost;&#xA;&#xA;RR(t,l)=VD.l;&#xA;SOLVE AMIR USING MIP MINIMIZING cost;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10239" LastEditorUserId="10239" LastEditDate="2024-02-25T13:09:29.740" LastActivityDate="2024-02-25T13:42:26.847" Title="How to pass the values of a variable of the first model to a parameter of the second model?" Tags="|optimization|linear-programming|stochastic-programming|gams|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11726" PostTypeId="2" ParentId="11725" CreationDate="2024-02-25T13:42:26.847" Score="4" Body="&lt;p&gt;First of all, I assume that the mentioned model is just to reflect what you want to do otherwise, it needs more attention as the problem is infeasible. To capture a variable value and store that into a parameter, the following should work:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;RR(T,L) = R.L(T,L);&#xA;DISPLAY RR;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also, the value of &lt;span class=&quot;math-container&quot;&gt;$R_{t,l}$&lt;/span&gt; from the first model is equal to zero. Since the parameter is already equal to zero.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;----     24 VARIABLE R.L  THE VOLUME OF BATCH I INJECTED FROM INPUT S DURING RUN&#xA;                          T&#xA;&#xA;                      ( ALL       0.000 )&#xA;----     27 PARAMETER RR  It is going to be replaced by the vriable R of the fir&#xA;                          st stage model&#xA;&#xA;                      ( ALL       0.000 )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, you can change the &lt;span class=&quot;math-container&quot;&gt;$solve$&lt;/span&gt; section somewhat for better readability.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;EQUATIONS OBJ1, OBJ2, eq1, eq2, eq3&#xA;;&#xA;obj1..      R('t1','l1') =e= cost;&#xA;eq1(t,l)..  VD(t,l) =e= 7;&#xA;;&#xA;MODEL AMIRPIP /OBJ1, eq1/;&#xA;SOLVE AMIRPIP USING MIP MINIMIZING cost;&#xA;DISPLAY COST.L, R.L, VD.L;&#xA;;&#xA;RR(T,L) = R.L(T,L);&#xA;DISPLAY RR;&#xA;;&#xA;obj2..      R('t1','l1') =e= cost;&#xA;eq2 (i)..   SD(i) =e= 8;&#xA;eq3 (t,l).. RR(t,l)*RP(t,l) =L= 5;&#xA;;&#xA;MODEL AMIR    /OBJ2, eq2, eq3/;&#xA;SOLVE AMIR USING MIP MINIMIZING cost;&#xA;DISPLAY COST.L, R.L, VD.L, SD.L, RP.L; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastActivityDate="2024-02-25T13:42:26.847" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11727" PostTypeId="1" AcceptedAnswerId="11729" CreationDate="2024-02-25T16:48:57.673" Score="1" ViewCount="95" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\DeclareMathOperator{\Tr}{Tr}\DeclareMathOperator*{\argmax}{\arg\!\max}$&lt;/span&gt;Consider the following semidefinite program (SDP)&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\min_V \quad &amp;amp; \Tr(V) \\&#xA;\textrm{s.t.} \quad &amp;amp; AVB + CVD + Q \succeq 0 \\&#xA;\quad &amp;amp; V \succeq 0&#xA;\end{aligned} \tag{1}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$V \in \mathbb R^{n \times n}, A \in \mathbb R^{m \times n}, B \in \mathbb R^{n \times m}, C \in \mathbb R^{m \times n},D \in \mathbb R^{n \times m}$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$Q \in \mathbb R^{m \times m} \succeq 0$&lt;/span&gt;. The solution to this problem is trivial, but this is a minimal example of a larger and more complex problem that I have a question about. More specifically, how can I convert the problem in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; into the following equivalent standard form of an SDP?&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\min_x \quad &amp;amp; c^Tx \\&#xA;\textrm{s.t.} \quad &amp;amp; F_0 + x_1F_1 + \cdots + x_mF_m \succeq 0&#xA;\end{aligned} \tag{2}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$F_0,\dots,F_m$&lt;/span&gt; are symmetric matrices, &lt;span class=&quot;math-container&quot;&gt;$c \in \mathbb R^m$&lt;/span&gt;, and &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb R^m$&lt;/span&gt;. That is, how can I relate &lt;span class=&quot;math-container&quot;&gt;$x, c,$&lt;/span&gt; and the matrices &lt;span class=&quot;math-container&quot;&gt;$F_0,\dots,F_m$&lt;/span&gt; in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; to the matrices &lt;span class=&quot;math-container&quot;&gt;$V, A, B, C, D,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; given in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;? The reason I'm interested in this conversion is that the standard form in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; is more amenable to further analysis than the form given in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2024-02-26T19:32:04.047" LastActivityDate="2024-02-26T19:32:04.047" Title="How can I convert this semidefinite program into standard form?" Tags="|convex-optimization|semidefinite-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11728" PostTypeId="1" AcceptedAnswerId="11740" CreationDate="2024-02-25T23:57:14.837" Score="3" ViewCount="120" Body="&lt;p&gt;Suppose I want to optimize some function of continuous variables and the objective is nonlinear; in this context, gradient-based methods are quite popular. To my knowledge, soft constraints can be added with a Lagrangian Multiplier, which would essentially add a penalty proportionate to the degree that the constraint was violated.&lt;/p&gt;&#xA;&lt;p&gt;Suppose one constraint was that &lt;span class=&quot;math-container&quot;&gt;$x \ge 0$&lt;/span&gt;. In the context of a minimization problem, we could presumably add &lt;span class=&quot;math-container&quot;&gt;$e^{-(x-n)}$&lt;/span&gt; to the objective (or &lt;span class=&quot;math-container&quot;&gt;$-e^{-(x-n)}$&lt;/span&gt; in the context of a maximization problem) where &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; could be dialed up to create some arbitrarily painful penalty.&lt;/p&gt;&#xA;&lt;p&gt;Is this considered a fairly standard practice in industry or are there different, preferred ways to enforce constraints in non-linear optimization?&lt;/p&gt;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$e^{-m(x-n)}$&lt;/span&gt; is the appropriate definition, where m defines the steepness of the curve and n defines the &amp;quot;elbow&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fPFAf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fPFAf.png&quot; alt=&quot;Elbow plot&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10326" LastEditorUserId="10326" LastEditDate="2024-02-26T14:42:45.003" LastActivityDate="2024-03-06T22:06:00.303" Title="Lagrangian Multipliers for constraints in nonlinear optimization problems?" Tags="|nonlinear-programming|lagrange-multipliers|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11729" PostTypeId="2" ParentId="11727" CreationDate="2024-02-26T00:48:36.830" Score="0" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\DeclareMathOperator{\Tr}{Tr}\DeclareMathOperator*{\argmax}{\arg\!\max}$&lt;/span&gt;We transform the problem in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; into the problem in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; as follows. First, for &lt;span class=&quot;math-container&quot;&gt;$(i,j) \in \{(k,\ell) \mid (k,\ell) \in \{1,\dots,n\}^2, k \leq \ell\}$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$E_{ij} \in \mathbb R^{n \times n}$&lt;/span&gt; be the matrix with a &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in the &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(j,i)$&lt;/span&gt; positions and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;'s everywhere else. When &lt;span class=&quot;math-container&quot;&gt;$i = j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$E_{ii}$&lt;/span&gt; is the matrix with a &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; in the &lt;span class=&quot;math-container&quot;&gt;$(i,i)$&lt;/span&gt; position and &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;'s everywhere else. For example, when &lt;span class=&quot;math-container&quot;&gt;$n = 2$&lt;/span&gt;, we have the following 3 matrices&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;E_{11} &amp;amp;= \begin{bmatrix}1 &amp;amp; 0 \\ 0 &amp;amp; 0\end{bmatrix} \\&#xA;E_{12} &amp;amp;= \begin{bmatrix}0 &amp;amp; 1 \\ 1 &amp;amp; 0\end{bmatrix} \\&#xA;E_{22} &amp;amp;= \begin{bmatrix}0 &amp;amp; 0 \\ 0 &amp;amp; 1\end{bmatrix}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Note that these 3 matrices form a basis for the vector space of &lt;span class=&quot;math-container&quot;&gt;$2 \times 2$&lt;/span&gt; symmetric positive semi-definite matrices. More generally, for arbitrary &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, the &lt;span class=&quot;math-container&quot;&gt;$n + \frac{n(n-1)}{2} = \frac{n(n+1)}{2}$&lt;/span&gt; matrices &lt;span class=&quot;math-container&quot;&gt;$E_{11},E_{12},\dots,E_{1n},E_{22},E_{23},\dots,E_{2n},\dots,E_{(n-1)(n-1)},E_{(n-1)n},E_{nn}$&lt;/span&gt; form a basis for the vector space of &lt;span class=&quot;math-container&quot;&gt;$n \times n$&lt;/span&gt; symmetric positive semi-definite matrices. Therefore, every &lt;span class=&quot;math-container&quot;&gt;$V \succeq 0 \in \mathbb R^{n \times n}$&lt;/span&gt; can be decomposed as&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;V &amp;amp;= \sum_{i=1}^n \sum_{j=i}^n v_{ij}E_{ij} \tag{3} \\&#xA;&amp;amp;= \sum_{j=1}^n v_{1j}E_{1j} + \sum_{j=2}^n v_{2j}E_{2j} + \cdots + \sum_{j=n-1}^n v_{(n-1)j}E_{(n-1)j} + \sum_{j=n}^n v_{nj}E_{nj}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$v_{ij}$&lt;/span&gt; is the element of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; in the &lt;span class=&quot;math-container&quot;&gt;$(i,j)$&lt;/span&gt; position. We first substitute this expression for &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; into the objective function in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; to get&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\Tr(V) &amp;amp;= \Tr\left(\sum_{i=1}^n \sum_{j=i}^n v_{ij}E_{ij}\right) \\&#xA;&amp;amp;= \sum_{i=1}^n \sum_{j=i}^n v_{ij}\Tr\left(E_{ij}\right) \tag{4}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Note that, when &lt;span class=&quot;math-container&quot;&gt;$i \neq j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\Tr(E_{ij}) = 0$&lt;/span&gt;, and when &lt;span class=&quot;math-container&quot;&gt;$i = j$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$\Tr(E_{ij}) = 1$&lt;/span&gt;. So, the expression in &lt;span class=&quot;math-container&quot;&gt;$(4)$&lt;/span&gt; above simplifies to&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\Tr(V) &amp;amp;= \sum_{i=1}^n v_{ii}\Tr\left(E_{ii}\right) \\&#xA;&amp;amp;= \sum_{i=1}^n v_{ii}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Therefore, to relate the objective function in the problem in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; to the objective function in the problem in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, we let&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;x = \begin{bmatrix}v_{11} \\ v_{12} \\ \vdots \\ v_{1n} \\ v_{22} \\ v_{23} \\ \vdots \\ v_{2n} \\ \vdots \\ v_{(n-1)(n-1)} \\ v_{(n-1)n} \\ v_{nn}\end{bmatrix}, \quad c = \begin{bmatrix}1 \\ 0 \\ \vdots \\ 0 \\ 1 \\ 0 \\ \vdots \\ 0 \\ \vdots \\ 1 \\ 0 \\ 1\end{bmatrix}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Note that &lt;span class=&quot;math-container&quot;&gt;$x \in \mathbb R^{\frac{n(n+1)}{2}}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c \in \mathbb R^{\frac{n(n+1)}{2}}$&lt;/span&gt;. Next, we relate the constraints in the problem in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; to the constraint in the problem in &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; as follows. We substitute the expression for &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; given in &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt; into the first constraint in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; to get&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;AVB + CVD + Q &amp;amp;\succeq 0 \\&#xA;A\left(\sum_{i=1}^n \sum_{j=i}^n v_{ij}E_{ij}\right)B + C\left(\sum_{i=1}^n \sum_{j=i}^n v_{ij}E_{ij}\right)D + Q &amp;amp;\succeq 0 \\&#xA;\left(\sum_{i=1}^n \sum_{j=i}^n v_{ij}AE_{ij}B\right) + \left(\sum_{i=1}^n \sum_{j=i}^n v_{ij}CE_{ij}D\right) + Q &amp;amp;\succeq 0 \\&#xA;\sum_{i=1}^n \sum_{j=i}^n v_{ij}\left(AE_{ij}B + CE_{ij}D\right) + Q &amp;amp;\succeq 0 \tag{5}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;Similarly, we apply this process to the second constraint in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; to get&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;V &amp;amp;\succeq 0 \\&#xA;\sum_{i=1}^n \sum_{j=i}^n v_{ij}E_{ij} &amp;amp;\succeq 0 \tag{6}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;We can combine the constraints in &lt;span class=&quot;math-container&quot;&gt;$(5)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$(6)$&lt;/span&gt; together into one constraint as follows.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;\sum_{i=1}^n \sum_{j=i}^n v_{ij}\left(AE_{ij}B + CE_{ij}D\right) + Q \succeq 0 \  \wedge \ \sum_{i=1}^n \sum_{j=i}^n v_{ij}E_{ij} \succeq 0 &amp;amp;\iff \begin{bmatrix}\sum_{i=1}^n \sum_{j=i}^n v_{ij}\left(AE_{ij}B + CE_{ij}D\right) + Q &amp;amp; 0 \\ 0 &amp;amp; \sum_{i=1}^n \sum_{j=i}^n v_{ij}E_{ij} \end{bmatrix} \succeq 0 \\&#xA;&amp;amp;\iff \sum_{i=1}^n \sum_{j=i}^n v_{ij} \begin{bmatrix}AE_{ij}B + CE_{ij}D &amp;amp; 0 \\ 0 &amp;amp; E_{ij} \end{bmatrix} + \begin{bmatrix}Q &amp;amp; 0 \\ 0 &amp;amp; 0\end{bmatrix} \succeq 0 \tag{7}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;We then let&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;F_0 = \begin{bmatrix}Q &amp;amp; 0 \\ 0 &amp;amp; 0\end{bmatrix}&#xA;$$&lt;/span&gt;&#xA;and for &lt;span class=&quot;math-container&quot;&gt;$(i,j) \in \{(k,\ell) \mid (k,\ell) \in \{1,\dots,n\}^2, k \leq \ell\}$&lt;/span&gt;, we let&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;F_{ij} = \begin{bmatrix}AE_{ij}B + CE_{ij}D &amp;amp; 0 \\ 0 &amp;amp; E_{ij} \end{bmatrix}&#xA;$$&lt;/span&gt;&#xA;such that the constraint in &lt;span class=&quot;math-container&quot;&gt;$(7)$&lt;/span&gt; becomes&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_{i=1}^n \sum_{j=i}^n v_{ij} F_{ij} + F_0 \succeq 0&#xA;$$&lt;/span&gt;&#xA;as desired.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The decomposition of &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; into its constituent basis matrices was adapted from section 2.1.2, titled &amp;quot;Linear equality constraints&amp;quot;, in the book&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;S. Boyd, L. El Ghaoui, E. Feron, and V. Balakrishnan, Linear matrix inequalities in system and control theory. Society for Industrial and Applied Mathematics, 1994. doi: 10.1137/1.9781611970777.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;A similar decomposition can be found in remark 1.24 in section 1.4.1 in the lecture notes titled &amp;quot;Linear Matrix Inequalities in Control&amp;quot; by Carsten Scherer and Siep Weiland (2015) (available &lt;a href=&quot;https://www.imng.uni-stuttgart.de/mst/files/LectureNotes.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2024-02-26T15:59:48.060" LastActivityDate="2024-02-26T15:59:48.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11730" PostTypeId="1" AcceptedAnswerId="11735" CreationDate="2024-02-26T05:30:29.320" Score="0" ViewCount="58" Body="&lt;p&gt;For a minimization problem, SDDP obtains a statistical UB in the forward pass. Can the statistical UB of SDDP be smaller than LB? I observed this phenomenon in the experiment, yet I'm not sure if it's possible or if it's just a bug.&lt;/p&gt;&#xA;" OwnerUserId="13245" LastActivityDate="2024-02-27T06:28:38.360" Title="Can UB of SDDP be smaller than LB?" Tags="|sddp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11731" PostTypeId="1" CreationDate="2024-02-26T15:42:37.970" Score="0" ViewCount="35" Body="&lt;p&gt;I am trying to find an example where the 1-steiner algorithm (local search algorithm for Steiner Minimum Tree) does not output the optimal solution, but each instance I find seems to be optimal.&lt;/p&gt;&#xA;" OwnerUserId="13249" LastEditorUserId="13249" LastEditDate="2024-02-26T16:02:03.923" LastActivityDate="2024-02-29T08:51:25.190" Title="When does local search algorithm for SMT (1-Steiner algorithm) not output the optimal solution?" Tags="|optimization|heuristics|local-search|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11733" PostTypeId="2" ParentId="3450" CreationDate="2024-02-26T17:01:56.103" Score="1" Body="&lt;p&gt;You can express this objective using AMPL's builtin if-then-else expression. I think the following corresponds to what you want to write:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;param n;&#xA;&#xA;set A;&#xA;set N {A} within A;&#xA;&#xA;var x {1..n, A};&#xA;&#xA;maximize ObjFunc:&#xA;   sum {a in A} (&#xA;      if (1/n) * sum {i in 1..n} (&#xA;         if sum {b in N[a]} x[i,b] &amp;gt;= 1 then 1 else 0 )&#xA;      &amp;gt;= 1 then 1 else 0 );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;General support for if-then-else is present in current AMPL MIP solver distributions (except that for CPLEX this feature is still in beta and it's necessary to use &lt;code&gt;cplexmp&lt;/code&gt; rather than &lt;code&gt;cplex&lt;/code&gt; to get it).&lt;/p&gt;&#xA;" OwnerUserId="52" LastActivityDate="2024-02-26T17:01:56.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11734" PostTypeId="1" CreationDate="2024-02-27T05:02:35.670" Score="0" ViewCount="43" Body="&lt;p&gt;I am learning Robust Optimization and been stuck on this example. I've brushed up on my knowledge of Lagrange duality and referred to a couple of textbooks on Linear Programming but not able to understand how the author arrived at the following robust counterpart.&lt;/p&gt;&#xA;&lt;p&gt;Here's the link to the complete description of the robust optimization example:&lt;a href=&quot;https://mobook.github.io/MO-book/notebooks/08/01-bim-robust-optimization.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hands-On Mathematical Optimization&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Original problem:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{split}&#xA;\begin{array}{rrcrcl}&#xA;\max    &amp;amp;  12 x_1 &amp;amp; + &amp;amp;   9 x_2               \\&#xA;\text{s.t.}    &amp;amp;     x_1 &amp;amp;   &amp;amp;         &amp;amp; \leq &amp;amp; 1000 \\&#xA;        &amp;amp;         &amp;amp;   &amp;amp;     x_2 &amp;amp; \leq &amp;amp; 1500 \\&#xA;        &amp;amp;     x_1 &amp;amp; + &amp;amp;     x_2 &amp;amp; \leq &amp;amp; 1750 \\&#xA;        &amp;amp; z_1 x_1 &amp;amp; + &amp;amp; z_2 x_2 &amp;amp; \leq &amp;amp; 4800 &amp;amp; \forall \, y \in \mathbb{R}^2 \,:\, z_j=\bar{z}_j+\delta y_j, \, \|y\|_\infty \leq 1, \, \|y\|_1\leq \Gamma \\&#xA;        &amp;amp;     x_1 &amp;amp; , &amp;amp;     x_2 &amp;amp; \geq &amp;amp; 0    \\&#xA;\end{array}&#xA;\end{split}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Robust Counterpart:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{split}&#xA;\begin{array}{rrcrcrcrcrcrcl}&#xA;\max    &amp;amp;  12 x_1 &amp;amp; + &amp;amp;   9 x_2               \\&#xA;\text{s.t.}    &amp;amp;     x_1 &amp;amp;   &amp;amp;         &amp;amp; &amp;amp; &amp;amp; &amp;amp; &amp;amp; &amp;amp; &amp;amp; \leq &amp;amp; 1000 \\&#xA;        &amp;amp;         &amp;amp;   &amp;amp;     x_2 &amp;amp; &amp;amp; &amp;amp; &amp;amp; &amp;amp; &amp;amp; &amp;amp; \leq &amp;amp; 1500 \\&#xA;        &amp;amp;     x_1 &amp;amp; + &amp;amp;     x_2 &amp;amp; &amp;amp; &amp;amp; &amp;amp; &amp;amp; &amp;amp; &amp;amp; \leq &amp;amp; 1750 \\&#xA;        &amp;amp; \bar{z}_1 x_1 &amp;amp; + &amp;amp; \bar{z}_2 x_2 &amp;amp; + &amp;amp; \lambda\Gamma &amp;amp; + &amp;amp; t_1 &amp;amp; + &amp;amp; t_2 &amp;amp; \leq &amp;amp; 4800 \\&#xA;        &amp;amp;-\delta x_1 &amp;amp;   &amp;amp;         &amp;amp; + &amp;amp; \lambda &amp;amp; + &amp;amp; t_1 &amp;amp;   &amp;amp;     &amp;amp; \geq &amp;amp; 0 \\&#xA;        &amp;amp;         &amp;amp;   &amp;amp;-\delta x_2 &amp;amp; + &amp;amp; \lambda &amp;amp;   &amp;amp;     &amp;amp; + &amp;amp; t_2 &amp;amp; \geq &amp;amp; 0 \\&#xA;        &amp;amp;\delta x_1 &amp;amp;   &amp;amp;         &amp;amp; + &amp;amp; \lambda &amp;amp; + &amp;amp; t_1 &amp;amp;   &amp;amp;     &amp;amp; \geq &amp;amp; 0 \\&#xA;        &amp;amp;         &amp;amp;   &amp;amp;\delta x_2 &amp;amp; + &amp;amp; \lambda &amp;amp;   &amp;amp;     &amp;amp; + &amp;amp; t_2 &amp;amp; \geq &amp;amp; 0 \\&#xA;        &amp;amp;     x_1 &amp;amp; , &amp;amp;     x_2 &amp;amp; , &amp;amp; \lambda &amp;amp; , &amp;amp; t_1 &amp;amp; , &amp;amp; t_2 &amp;amp; \geq &amp;amp; 0    \\&#xA;\end{array}&#xA;\end{split}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="13247" LastEditorUserId="491" LastEditDate="2024-02-27T12:10:37.367" LastActivityDate="2024-02-27T12:10:37.367" Title="Lagrange Duality in Robust Optimization" Tags="|optimization|duality|robust-optimization|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11735" PostTypeId="2" ParentId="11730" CreationDate="2024-02-27T06:28:38.360" Score="1" Body="&lt;p&gt;Yes. The upper bound is a confidence interval for the mean of the Monte Carlo simulation. You should expect that the confidence interval of a &amp;quot;lucky&amp;quot; Monte Carlo simulation that sampled only low-cost scenarios could be below the deterministic lower bound.&lt;/p&gt;&#xA;" OwnerUserId="804" LastActivityDate="2024-02-27T06:28:38.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11737" PostTypeId="1" CreationDate="2024-02-27T10:19:24.867" Score="1" ViewCount="82" Body="&lt;p&gt;I recently tried to solve a primal minimization problem using its maximization dual. In the optimal simplex tableau of the dual, there was a slack variable and only one dual variable in the basis.&lt;/p&gt;&#xA;&lt;p&gt;So, am I right to interpret that since one of the dual variables is zero, therefore one of the constraint's limits of the primal is zero or is it that the value of the slack in dual's basis corresponds to the primal constraint?&lt;/p&gt;&#xA;&lt;p&gt;The problem was solvable using the Big-M method, but I was unable to achieve the same result via dual. The original problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{l}&#xA;\text{Minimize } z = 60 x_1 + 80 x_2\\&#xA;\text{subject to:} \\&#xA;20x_1 + 30x_2 \geq 900\\&#xA;40x_1 + 30x_2 \geq 1200\\&#xA;x_1, x_2 \in \mathbb{R}^+\\&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="13127" LastEditorUserId="500" LastEditDate="2024-03-03T14:07:39.687" LastActivityDate="2024-03-03T14:07:39.687" Title="Dual to Primal conversion" Tags="|linear-programming|dual|dual-simplex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11738" PostTypeId="2" ParentId="9789" CreationDate="2024-02-29T07:01:17.353" Score="1" Body="&lt;p&gt;You can use Mathematica to solve the optimization problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \min\limits_{x} f(x) = (C + mx + \frac{s}{x + t})^p &#xA;\\&#xA;\text{ where } C = 1,m = 1,s = 1,t = 0.1,p = 3&#xA;\\&#xA;\\&#xA;\text{s.t.  }\quad 0 \leq x \leq 1&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Clear[&amp;quot;Global`*&amp;quot;];&#xA;(*Define the parameters*)&#xA;C1 = 1; m = 1; s = 1; t = 0.1; p = 3;&#xA;&#xA;(*Define the objective function*)&#xA;objectiveFunction[x_] := (C1 + m*x + s/(x + t))^p;&#xA;&#xA;(*Perform the optimization*)&#xA;solution = NMinimize[{objectiveFunction[x], 0 &amp;lt;= x &amp;lt;= 1}, x]&#xA;&#xA;(*Extract the optimal value of x*)&#xA;optimalX = x /. Last[solution]&#xA;&#xA;(*Calculate the objective function value at the optimal point*)&#xA;objectiveValue = First[solution]&#xA;&#xA;(*Optionally,verify the objective function value by direct \&#xA;substitution*)&#xA;verificationValue = objectiveFunction[optimalX]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;{24.389, {x -&amp;gt; 0.9}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12223" LastActivityDate="2024-02-29T07:01:17.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11740" PostTypeId="2" ParentId="11728" CreationDate="2024-02-29T20:51:40.013" Score="2" Body="&lt;p&gt;Let's assume that you want to minimize &lt;span class=&quot;math-container&quot;&gt;$f:\mathbb{R}^n \rightarrow \mathbb{R}$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$g(x)\ge 0$&lt;/span&gt; (&lt;span class=&quot;math-container&quot;&gt;$g:\mathbb{R}^n \rightarrow \mathbb{R}^m$&lt;/span&gt;) with no particular assumptions on &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g.$&lt;/span&gt; Heuristics aside, the three most common approaches would be the following.&lt;/p&gt;&#xA;&lt;h2&gt;Penalty Method&lt;/h2&gt;&#xA;&lt;p&gt;Minimize &lt;span class=&quot;math-container&quot;&gt;$f(x) + h(g(x))$&lt;/span&gt; (unconstrained) where &lt;span class=&quot;math-container&quot;&gt;$h:\mathbb{R}^m \rightarrow \mathbb{R}^+$&lt;/span&gt; is positive when &lt;span class=&quot;math-container&quot;&gt;$g(x) \not\ge 0$&lt;/span&gt; and 0 when &lt;span class=&quot;math-container&quot;&gt;$g(x) \ge 0.$&lt;/span&gt; You want the penalty term large enough to &amp;quot;discourage&amp;quot; accepting an infeasible solution in order to artificially reduce the value of &lt;span class=&quot;math-container&quot;&gt;$f(x).$&lt;/span&gt; This approach does not require knowing a feasible solution.&lt;/p&gt;&#xA;&lt;h2&gt;Barrier Method&lt;/h2&gt;&#xA;&lt;p&gt;Similar to the penalty method, you minimize &lt;span class=&quot;math-container&quot;&gt;$f(x) + h(g(x))$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; a penalty function. In this case, though, you want &lt;span class=&quot;math-container&quot;&gt;$h(z)=0$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$z \ge (\epsilon, \dots, \epsilon)$&lt;/span&gt; (for some positive &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;), and &lt;span class=&quot;math-container&quot;&gt;$h(z)\rightarrow \infty$&lt;/span&gt; as &lt;span class=&quot;math-container&quot;&gt;$z\downarrow 0.$&lt;/span&gt; In other words, the penalty is 0 for most feasible solutions but blows up as you get close to violating any of the constraints. You need to know a strictly feasible (zero penalty) starting solution for the barrier method, and you may not find the true optimum if it lies too close to the boundary of the feasible region. &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; is called a &amp;quot;barrier function&amp;quot;, because it serves as a barrier to keep you from escaping the feasible region.&lt;/p&gt;&#xA;&lt;h2&gt;Lagrangian Relaxation&lt;/h2&gt;&#xA;&lt;p&gt;In the LR approach, you solve two nested problems: &lt;span class=&quot;math-container&quot;&gt;$$\max_{\lambda \ge 0} \min_x (f(x) - \lambda^\prime g(x)).$$&lt;/span&gt; The inner problem resembles the penalty method, where the penalty function is a weighted sum of the constraint violations. This is an iterative scheme. You pick penalty weights &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; and solve the inner (minimization) problem. You then tweak the weights and try again. The outer (maximization) problem encourages selection of weights that penalize constraint violations without encouraging overachievement of constraints (&lt;span class=&quot;math-container&quot;&gt;$g_i(x) &amp;gt; 0$&lt;/span&gt;) too much ... hopefully.&lt;/p&gt;&#xA;&lt;p&gt;Depending on what the properties of &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g$&lt;/span&gt; are (convexity, smoothness, steepness) you may not be guaranteed a global optimum with any of these methods.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-02-29T20:51:40.013" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11741" PostTypeId="1" AcceptedAnswerId="11836" CreationDate="2024-03-01T00:27:30.217" Score="-1" ViewCount="58" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\DeclareMathOperator{\Tr}{Tr}\DeclareMathOperator*{\argmax}{\arg\!\max}$&lt;/span&gt;Consider the following semidefinite program (SDP)&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\max_V \quad &amp;amp; \Tr(V) \\&#xA;\textrm{s.t.} \quad &amp;amp; \begin{bmatrix} AVA^T + Q - V &amp;amp; \sqrt{\lambda}AVC^T \\ \sqrt{\lambda}CVA^T &amp;amp; CVC^T + R \end{bmatrix} \succeq 0 \\&#xA;\quad &amp;amp; V \succeq 0&#xA;\end{aligned} \tag{1}&#xA;$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$V \in \mathbb R^{n \times n}, A \in \mathbb R^{n \times n}, C \in \mathbb R^{n \times m}, Q \in \mathbb R^{n \times n} \succeq 0, R \in \mathbb R^{m \times m} \succ 0,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda \in [0,1]$&lt;/span&gt;. This SDP shows up in Theorem 6 in the paper&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;B. Sinopoli, L. Schenato, M. Franceschetti, K. Poolla, M. I. Jordan, and S. S. Sastry, “Kalman filtering with intermittent observations,” IEEE Transactions on Automatic Control, vol. 49, no. 9, pp. 1453–1464, Sep. 2004, doi: 10.1109/TAC.2004.834121.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Suppose that the input parameters &lt;span class=&quot;math-container&quot;&gt;$A,C,Q,R,$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; are always chosen such that a solution for &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; exists. Does strong duality hold for &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="7263" LastEditDate="2024-03-25T16:57:29.387" LastActivityDate="2024-03-25T22:56:57.550" Title="Does strong duality hold for this semidefinite program?" Tags="|convex-optimization|duality|semidefinite-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11744" PostTypeId="1" CreationDate="2024-03-01T17:31:57.257" Score="0" ViewCount="33" Body="&lt;p&gt;Traditionally, our notation has separated out a set and values associated with said set. We'll say something like the state is a tuple of &lt;span class=&quot;math-container&quot;&gt;$(V, f)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is a set of control values and &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; is a vector of their corresponding costs. We then write their union as &lt;span class=&quot;math-container&quot;&gt;$(V \cup V', max(f_i, f_i')~\forall i)$&lt;/span&gt;. Instead, I want to write it like this:&#xA;&lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is a dictionary of control values to cost. It's union is&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;V \bigcup_{max} V'&#xA;$$&lt;/span&gt;&#xA;Is that so bad? Or is there some other standard way of doing this that I should be aware of?&lt;/p&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2024-03-01T17:31:57.257" Title="proper notation for union of dictionary" Tags="|modeling|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11745" PostTypeId="1" CreationDate="2024-03-01T19:16:17.987" Score="1" ViewCount="59" Body="&lt;p&gt;I have a min-cost multicommodity flow problem with the following characteristics:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Flows can be fractional (integer flows not required)&lt;/li&gt;&#xA;&lt;li&gt;Set of commodity types is &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;, set of demand nodes is &lt;span class=&quot;math-container&quot;&gt;$\\{ d_k : k\in K \\}$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;A supply node &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; can supply supply up to &lt;span class=&quot;math-container&quot;&gt;$b_{v, k}$&lt;/span&gt; amount of commodity &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;A demand node &lt;span class=&quot;math-container&quot;&gt;$d_k$&lt;/span&gt; has demand for &lt;span class=&quot;math-container&quot;&gt;$\overline{d}_k$&lt;/span&gt; units of commodity &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt;, and nothing else (i.e. only commodities of type &lt;span class=&quot;math-container&quot;&gt;$k\in K$&lt;/span&gt; are demanded)&lt;/li&gt;&#xA;&lt;li&gt;Each demand-node &lt;span class=&quot;math-container&quot;&gt;$d_k$&lt;/span&gt; has exactly one outgoing arc &lt;span class=&quot;math-container&quot;&gt;$(d_k, d'_k)$&lt;/span&gt;, which has cost &lt;span class=&quot;math-container&quot;&gt;$+\infty$&lt;/span&gt; and capacity &lt;span class=&quot;math-container&quot;&gt;$+\infty$&lt;/span&gt;. The node &lt;span class=&quot;math-container&quot;&gt;$d'_k$&lt;/span&gt; is only incident to &lt;span class=&quot;math-container&quot;&gt;$d_k$&lt;/span&gt; (it does not have any other incoming arcs, and does not have any outgoing arcs).&lt;/li&gt;&#xA;&lt;li&gt;Every arc &lt;span class=&quot;math-container&quot;&gt;$(v, w)\in E$&lt;/span&gt; has cost 0, unless &lt;span class=&quot;math-container&quot;&gt;$v$&lt;/span&gt; or &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is a demand-node, in which case there is a strictly positive cost.&lt;/li&gt;&#xA;&lt;li&gt;Costs are per-unit of flow on the arc, and are the same regardless of which commodity is flowing across it.&lt;/li&gt;&#xA;&lt;li&gt;For each arc &lt;span class=&quot;math-container&quot;&gt;$(v, w)\in E\setminus \{(d_k, d'_k)) : k\in K\}$&lt;/span&gt;, there is a finite capacity.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Given this structure of most of the arcs having zero (homogeneous) cost, are any algorithms or results which are particularly well-suited to my problem? Exact or approximation algorithms are both valued.&lt;/p&gt;&#xA;" OwnerUserId="11000" LastEditorUserId="11000" LastEditDate="2024-03-02T18:35:55.107" LastActivityDate="2024-04-01T19:00:55.113" Title="Fast Algorithms for Min-cost Multicommodity Flow Problem with Most Arcs Having 0 cost" Tags="|linear-programming|network-flow|benders-decomposition|maxflow|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11747" PostTypeId="1" CreationDate="2024-03-02T09:00:52.400" Score="0" ViewCount="53" Body="&lt;p&gt;I am working on a two stage approach in order to reduce the complexity of a scheduling model which is an NP-hard problem. I have to implement a while loop in order to repeat solving the models in case the solution achieved from the second stage model is not feasible for the first stage model.&lt;/p&gt;&#xA;&lt;p&gt;The problem is that I need to use a parameter whose value realizes after solving the second stage model (that shows whether the solution of the second stage model is feasible for the first stage model or not). Therefore, I have to initialize the first stage model within which I have to use this parameter.&lt;/p&gt;&#xA;&lt;p&gt;The hardness is where that the parameter is multi-dimensional, preventing me from initializing it by my own. This parameter is &lt;code&gt;SD(i,d,l,t)&lt;/code&gt;. Moreover, I have to pass the values of the first stage variables into the parameters of the second stage model. It is like being stuck in an unsolvable loop :)&lt;/p&gt;&#xA;&lt;p&gt;Here is a simplified scheme:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Parameter SD(i,t,d,l);&#xA;&#xA;While (conditional statement, &#xA;&#xA;&#xA;*****Initialize SD(i,t,d,l) from the second stage model*****&#xA;if( SD(i,t,d,l) GT 0,&#xA;&#xA;****Add cut EQ to the first stage model and solve it****&#xA;MODEL First /OBJ1,EQ/;          &#xA;SOLVE First USING MIP MINIMIZING cost;      &#xA;);&#xA;&#xA; &#xA;else (&#xA;****Add cut EQ' to the first stage model and solve it****&#xA;MODEL First /OBJ1,EQ'/;          &#xA;SOLVE First USING MIP MINIMIZING cost; &#xA;);&#xA;&#xA; **** Form the second stage model  ****&#xA;Model Second /OBJ2,eq1, eq3,.../;  &#xA;SOLVE Second USING MIP MINIMIZING cost;&#xA;&#xA;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10239" LastActivityDate="2024-03-02T09:00:52.400" Title="How to initialize a parameter (belonging to the first stage model) in a two stage model, taking its value from second stage model?" Tags="|linear-programming|modeling|stochastic-programming|gams|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="11748" PostTypeId="1" AcceptedAnswerId="11754" CreationDate="2024-03-02T14:54:20.233" Score="2" ViewCount="102" Body="&lt;p&gt;I'm developing a solution to optimize a vehicle routing problem where each stop has an associated score (priority), specific geo coordinates, and a required stop duration. The goal is to maximize the total score of stops visited within a day, considering travel time between stops and a fixed start/end time, ensuring each stop is visited no more than once.&lt;/p&gt;&#xA;&lt;p&gt;In another words - &lt;strong&gt;I need to find a route that will maximize score collected on the route from start location and ending in end location, we can skip nodes that would not fit into the day schedu&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Objectives:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Maximize total value of selected stops.&lt;/li&gt;&#xA;&lt;li&gt;Optimize route to minimize travel time.&lt;/li&gt;&#xA;&lt;li&gt;Fit travel within a day's schedule.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;What algorithms or mathematical optimization techniques are recommended for this scenario?&#xA;What libraries would you recommend for solving this problem? I have some school experience with ILP modeling and Gurobi, now I was trying OR-tools with no success.&#xA;How should I model this problem to efficiently find an optimal or near-optimal solution? Should I rather look for some heuristic approach? I was thinking of some kind of greedy shortest-path algorithm with incorporating the scores and travel distances between stops (for example difference between the node's score and the cost of visiting the node.).&lt;/p&gt;&#xA;" OwnerUserId="13274" LastActivityDate="2024-03-03T15:12:16.917" Title="Optimizing a Route Selection Problem with Multiple Constraints and Objectives" Tags="|optimization|mixed-integer-programming|or-tools|vehicle-routing|traveling-salesman|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11749" PostTypeId="2" ParentId="11745" CreationDate="2024-03-02T18:57:42.490" Score="0" Body="&lt;p&gt;I'm not sure what to make of the infinite cost arcs and associated endpoints, but as the problem is stated they can be ignored. There is no reason for them to have any flow.&lt;/p&gt;&#xA;&lt;p&gt;Given the presence of capacity limits, I do not see any way to exploit the zero cost on most arcs. The problem can be formulated as a linear program, and LPs are generally easy to solve. Were there no capacity limits on arcs, I think the zero cost aspect might be exploited to generate a smaller LP model.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-03-02T18:57:42.490" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11750" PostTypeId="1" CreationDate="2024-03-02T20:44:38.527" Score="0" ViewCount="76" Body="&lt;h1&gt;Class Scheduling Optimization for a Trade School&lt;/h1&gt;&#xA;&lt;p&gt;We are exploring ways to model, simulate, and optimize class scheduling for a trade school, focusing on addressing the complex dynamics of managing class schedules for apprentices. Below is an overview of the context, rules, and challenges involved. I am hoping for some direction to solve the puzzle described below.&lt;/p&gt;&#xA;&lt;p&gt;Originally posted this to Mathematics Stack Overflow, but it was closed for being too unfocused. Looking for any advice on how to begin to solve a problem like this. Thanks in advance.&#xA;&lt;a href=&quot;https://math.stackexchange.com/questions/4873603/given-these-constraints-is-class-scheduling-forecasting-impossible&quot;&gt;https://math.stackexchange.com/questions/4873603/given-these-constraints-is-class-scheduling-forecasting-impossible&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2&gt;Context&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We have approximately 1000 active apprentices at any time, distributed across four levels:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Level 1&lt;/strong&gt;: 250 apprentices&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Level 2&lt;/strong&gt;: 250 apprentices&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Level 3&lt;/strong&gt;: 250 apprentices&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Level 4&lt;/strong&gt;: 250 apprentices&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;New apprentices are added at irregular intervals, in varying numbers (e.g., 25 or 15).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Rules of Apprentice Scheduling&lt;/h2&gt;&#xA;&lt;h3&gt;Adding New Apprentices&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Apprentices can start the program at any time, allowing for continuous enrollment.&lt;/li&gt;&#xA;&lt;li&gt;New apprentices immediately take 1 or 2 introductory classes.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Progressing Through the Program&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Classes are available 52 weeks of the year.&lt;/li&gt;&#xA;&lt;li&gt;Each apprentice must complete 4 classes each year, with classes spaced 3 months apart.&lt;/li&gt;&#xA;&lt;li&gt;Each class lasts one week, Monday to Friday, totaling 35 hours.&lt;/li&gt;&#xA;&lt;li&gt;Classes within a level can be completed in any order.&lt;/li&gt;&#xA;&lt;li&gt;Ideally, each class section accommodates exactly 12 students.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Advancement&lt;/h3&gt;&#xA;&lt;p&gt;Apprentices advance to the next pay level/grade (1 through 4) upon meeting three criteria:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Passing their anniversary (12 months from initiation or last upgrade date).&lt;/li&gt;&#xA;&lt;li&gt;Completing the required 4 on-level classes.&lt;/li&gt;&#xA;&lt;li&gt;Meeting a minimum number of work hours. (Levels: 1=Freshman, 2=Sophomore, 3=Junior, 4=Senior)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h3&gt;Graduation&lt;/h3&gt;&#xA;&lt;p&gt;Apprentices graduate after completing approximately 16 classes over 4 years.&lt;/p&gt;&#xA;&lt;h2&gt;Example Curriculum&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Level 1&lt;/strong&gt;: GC101, GC102, GC103, GC104&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Level 2&lt;/strong&gt;: GC201, GC202, GC203, GC204&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Level 3&lt;/strong&gt;: GC301, GC302, GC303, GC304&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Level 4&lt;/strong&gt;: GC401, GC402, GC403, GC404&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Classes can be taken in any order within a level, but apprentices should generally complete all classes at their current level before advancing.&lt;/p&gt;&#xA;&lt;h2&gt;Scheduling Challenge&lt;/h2&gt;&#xA;&lt;p&gt;The main question is determining how many sections of each course to offer annually and scheduling each section to meet all students' progression needs while optimizing instructor allocation.&lt;/p&gt;&#xA;&lt;h3&gt;Real-life Problem&lt;/h3&gt;&#xA;&lt;p&gt;Offering two 35-hour classes with 6 students each requires 70 instructor hours, whereas one 12-student class requires only 35 instructor hours. We aim to mitigate such inefficiencies.&lt;/p&gt;&#xA;&lt;h3&gt;Additional Consideration&lt;/h3&gt;&#xA;&lt;p&gt;Given the fluid progression of apprentices through levels, it's challenging to determine a precise count of apprentices at each level for a given year, complicating the scheduling of appropriate numbers of class sections.&lt;/p&gt;&#xA;&lt;h2&gt;Objective&lt;/h2&gt;&#xA;&lt;p&gt;Our goal is to develop a scheduling model that accommodates the dynamic nature of apprentice enrollment and progression, ensuring efficient allocation of resources and meeting educational requirements.&lt;/p&gt;&#xA;" OwnerUserId="13269" LastActivityDate="2024-03-07T07:57:54.123" Title="Scheduling optimization problem - Where to begin?" Tags="|optimization|linear-programming|scheduling|applications|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11752" PostTypeId="2" ParentId="11737" CreationDate="2024-03-03T07:29:29.890" Score="2" Body="&lt;p&gt;As the problem contains only two decision variables, it would always be worth to investigate its schematic form. The feasible solution to the primal problem is as follows:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dQzZd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dQzZd.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And the optimal solution to the problem is &lt;span class=&quot;math-container&quot;&gt;$2500$&lt;/span&gt; with respect to &lt;span class=&quot;math-container&quot;&gt;$x_1 = 15$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$x_2 = 20$&lt;/span&gt;. Also, the dual values are &lt;span class=&quot;math-container&quot;&gt;$c_1 = 2.33$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c_2 = 0.33$&lt;/span&gt; respectively.&lt;/p&gt;&#xA;&lt;p&gt;Now, consider its dual form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jo2jI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jo2jI.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Again, the value of the objective function would be &lt;span class=&quot;math-container&quot;&gt;$2500$&lt;/span&gt; corresponding to &lt;span class=&quot;math-container&quot;&gt;$y_1 = 2.33$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_2 = 0.33$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, if you have achieved any other solutions, you will need to get back on your formulation and/or how to iterate pivoting in your tableau. Also, this &lt;a href=&quot;https://lpdual.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt; to show the relation between the primal and dual can be helpful.&lt;/p&gt;&#xA;" OwnerUserId="199" LastActivityDate="2024-03-03T07:29:29.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11753" PostTypeId="1" CreationDate="2024-03-03T12:54:22.557" Score="1" ViewCount="46" Body="&lt;p&gt;I am solving a problem using benders decomposition. The master problem is solved by cplex.The subproblems are logic and can be solved without using cplex solver. The scale for subproblem is large. About 3000 cuts will add to master problem in each iteration. My problem is: after 8-9 iteration, is the final converage stage, cplex shows no solution for the master problem. I try to use conflict detection function in cplex to print the conflicted constraints. But it shows that &amp;quot;No conflict is available..&amp;quot;. The master problem is LP and it's werid that it cannot be solved. The problem can be solved in many small scale.&lt;/p&gt;&#xA;" OwnerUserId="12244" LastEditorUserId="500" LastEditDate="2024-03-03T13:55:22.543" LastActivityDate="2024-03-04T04:18:23.807" Title="Cplex no solution but no conflict" Tags="|linear-programming|cplex|benders-decomposition|irreducible-infeasible-subset|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11754" PostTypeId="2" ParentId="11748" CreationDate="2024-03-03T15:10:59.387" Score="0" Body="&lt;p&gt;Thanks to @Nelewout and his work on library &lt;a href=&quot;https://pyvrp.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;PyVRP&lt;/a&gt; it super easy to setup and solve this Vehicle Routing Problem with prize collection (scores) and even with time windows, using heuristics.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;DURATION_MATRIX = [...]&#xA;PRIZES = [...]&#xA;PRIZES[0] = 0  # starting point has no prize&#xA;COORDS = [...]&#xA;START_INDEX = 0&#xA;&#xA;m = Model()&#xA;&#xA;depots = [ # We are going to have only one depot&#xA;    m.add_depot(&#xA;        x=COORDS[START_INDEX][0],&#xA;        y=COORDS[START_INDEX][1],&#xA;        tw_early=TIME_WINDOWS[START_INDEX][0],&#xA;        tw_late=TIME_WINDOWS[START_INDEX][1],&#xA;    )&#xA;]&#xA;&#xA;# We are going to have only one vehicle type &#xA;m.add_vehicle_type(1, depot=depots[START_INDEX], max_duration=10)&#xA;&#xA;clients = [&#xA;    m.add_client(&#xA;        x=COORDS[idx][0],&#xA;        y=COORDS[idx][1],&#xA;        tw_early=TIME_WINDOWS[idx][0],&#xA;        tw_late=TIME_WINDOWS[idx][1],&#xA;        prize=PRIZES[idx],&#xA;        required=False,&#xA;    )&#xA;    for idx in range(1, len(COORDS)) # the first one is the depot&#xA;]&#xA;&#xA;locations = depots + clients&#xA;for frm_idx, frm in enumerate(locations):&#xA;    for to_idx, to in enumerate(locations):&#xA;        distance = abs(frm.x - to.x) + abs(frm.y - to.y)  # Manhattan&#xA;        duration = DURATION_MATRIX[frm_idx][to_idx]&#xA;        m.add_edge(frm, to, distance=distance, duration=duration)&#xA;&#xA;res = m.solve(stop=MaxRuntime(5))  # in second&#xA;print(res)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is just amazingly easy to setup and use. Thank you for your time and help.&lt;/p&gt;&#xA;" OwnerUserId="13274" LastEditorUserId="500" LastEditDate="2024-03-03T15:12:16.917" LastActivityDate="2024-03-03T15:12:16.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11755" PostTypeId="2" ParentId="11753" CreationDate="2024-03-04T04:18:23.807" Score="1" Body="&lt;p&gt;Finding a conflict in CPLEX is a two step process. First you have to instruct CPLEX to &amp;quot;refine&amp;quot; the conflict; then you have to ask it for the results (the constraints and variable bounds that collectively make the problem infeasible). If you attempt to access the conflict before giving the &amp;quot;refine&amp;quot; instruction, CPLEX will say that there is no conflict available.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-03-04T04:18:23.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11756" PostTypeId="1" CreationDate="2024-03-04T05:56:12.447" Score="1" ViewCount="68" Body="&lt;p&gt;Pyomo does not allow to use if statements that involves variables. I want to create a new dictionary, model.Excess1, which uses the values from &lt;code&gt;model.Excess&lt;/code&gt; to return the original value if &lt;code&gt;model.Excess&amp;gt;=0&lt;/code&gt; and return 0 if negative.&lt;/p&gt;&#xA;&lt;p&gt;I tried using the Big M method, but I am not able to get the results I want.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.Excess = pyo.Var(model.Years, within = pyo.Reals)&#xA;model.Excess1 = pyo.Var(model.Years, within = pyo.Reals)&#xA;model.NegZero = pyo.Var(model.Years, domain = pyo.Binary)&#xA;model.bigM = pyo.Param(initialize=1000000)&#xA;&#xA;model.C16 = pyo.ConstraintList()&#xA;for year in model.Years:&#xA;        model.C16.add(expr = model.Excess[year] == model.Target[year] - model.Actual[year] )&#xA;        &#xA;        model.C16.add(expr = model.Excess1[year] &amp;lt;= model.NegZero[year] * model.bigM)&#xA;        model.C16.add(expr = model.Excess1[year] &amp;gt;= model.Excess[year])&#xA;        model.C16.add(expr = model.Excess1[year] &amp;lt;= model.Excess[year] - (1 -   model.NegZero[year]) * model.bigM)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13279" LastEditorUserId="491" LastEditDate="2024-03-04T14:36:20.830" LastActivityDate="2024-03-05T06:00:26.250" Title="In Pyomo, how do I modify the Variable if the value is less than 0?" Tags="|optimization|pyomo|binary-variable|logical-constraints|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="11758" PostTypeId="1" CreationDate="2024-03-04T14:53:05.300" Score="1" ViewCount="36" Body="&lt;p&gt;I am working on a problem that can be modeled as a minimum-cost network flow problem where the capacity of edges is 1.&lt;/p&gt;&#xA;&lt;p&gt;I found Exercise 3.8, Chapter 5 of &lt;em&gt;Parallel and Distributed Computation: Numerical Methods&lt;/em&gt; (D. P. Bertsekas and J. N. Tsitsiklis), which says the linear network flow problem for the case where the feasible flow range of each arc is &lt;span class=&quot;math-container&quot;&gt;$[0, 1]$&lt;/span&gt; can be converted into a transportation problem, but I cannot come up with a construction or find references to this problem.&lt;/p&gt;&#xA;&lt;p&gt;To clarify, a transportation problem is in the form of&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\min \sum_{(i,j)\in A} a_{ij}x_{ij},$$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$$\sum_{j|(i,j)\in A}x_{ij}=\alpha_i, \forall\ i=1,\dots,m,$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$\sum_{i|(i,j)\in A}x_{ij}=\beta_j,\forall\ j=1,\dots,n,$$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$$x_{ij}\ge 0,\forall\ (i,j)\in A.$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="13264" LastActivityDate="2024-03-04T14:53:05.300" Title="How to convert unit-capacity network flow into transportation problems?" Tags="|optimization|linear-programming|network-flow|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11759" PostTypeId="1" CreationDate="2024-03-04T18:45:34.373" Score="0" ViewCount="58" Body="&lt;p&gt;I have a binary variable &lt;span class=&quot;math-container&quot;&gt;$\bf x$&lt;/span&gt; of size &lt;span class=&quot;math-container&quot;&gt;$12\times 1$&lt;/span&gt;, such as &lt;span class=&quot;math-container&quot;&gt;${\bf x} =[x_1\hspace{1mm} x_2\hspace{1mm} x_3\hspace{1mm} x_4\hspace{1mm} x_5\hspace{1mm} x_6\hspace{1mm} x_7\hspace{1mm} x_8\hspace{1mm} x_9\hspace{1mm} x_{10}\hspace{1mm} x_{11}\hspace{1mm} x_{12} ]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, they are grouped in 3 groups.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\bf x} =[\{x_1\hspace{1mm} x_2\hspace{1mm} x_3\hspace{1mm} x_4\}\hspace{1mm} \{x_5\hspace{1mm} x_6\hspace{1mm} x_7\hspace{1mm} x_8\}\hspace{1mm} \{x_9\hspace{1mm} x_{10}\hspace{1mm} x_{11}\hspace{1mm} x_{12}\} ]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The constraints I have are&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Sum of all variables in each group is less than or equal to 2&#xA;so,&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1+x_2+x_3+x_4\le 2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_5+x_6+x_7+x_8\le 2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_9+x_{10}+x_{11}+x_{12}\le 2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;variables with same index in each group are equal. so&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1=x_5=x_9$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_2=x_6=x_{10}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_3=x_7=x_{11}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_4=x_8=x_{12}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I can model the first set of constraints as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bf Bx\le2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$\bf B=[1\hspace{1mm} 1\hspace{1mm} 1\hspace{1mm} 1\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0;0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 1\hspace{1mm} 1\hspace{1mm} 1\hspace{1mm} 1\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0;0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 0\hspace{1mm} 1\hspace{1mm} 1\hspace{1mm} 1\hspace{1mm} 1]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How to model the second set of constraints without introducing additional variable?&lt;/p&gt;&#xA;&lt;p&gt;I am looking for similar technique as used for the first set of constraints.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="500" LastEditDate="2024-03-05T12:45:37.987" LastActivityDate="2024-03-05T12:45:37.987" Title="How to model constraints without introducing additional variables?" Tags="|mixed-integer-programming|combinatorial-optimization|binary-variable|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11760" PostTypeId="1" CreationDate="2024-03-04T19:23:20.090" Score="0" ViewCount="34" Body="&lt;p&gt;I am currently trying to implement &lt;a href=&quot;https://or.stackexchange.com/questions/11608/how-to-modify-master-problem-and-individual-sub-problems-in-column-generation/11620?noredirect=1#comment25135_11620&quot;&gt;this model&lt;/a&gt; in SAS. Unfortunately, I always get this error. How can I solve this and finally get the final roster &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; and the total value of &lt;span class=&quot;math-container&quot;&gt;$slack_{ts}$&lt;/span&gt; (preferably in an Excel list)?&lt;/p&gt;&#xA;&lt;p&gt;This is the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  /* declare sets and parameters */&#xA;   set ISET, TSET, SSET;&#xA;   num demand {TSET, SSET};&#xA;&#xA;   /* read input data here */&#xA;    set ISET = {1, 2, 3};&#xA;    set SSET = {1, 2, 3};&#xA;    set TSET = {1, 2, 3, 4, 5, 6, 7};&#xA;    num demand{TSET, SSET} = {(1, 1): 2, (1, 2): 1, (1, 3): 0, (2, 1): 1, (2, 2): 2, (2, 3): 0, (3, 1): 1, (3, 2): 1, (3, 3): 1,&#xA;               (4, 1): 1, (4, 2): 2, (4, 3): 0, (5, 1): 2, (5, 2): 0, (5, 3): 1, (6, 1): 1, (6, 2): 1, (6, 3): 1,&#xA;               (7, 1): 0, (7, 2): 3, (7, 3): 0};&#xA;    /* Generate random values for alpha */&#xA;    execute INIT_RANDOM(123); /* Set a seed for reproducibility */&#xA;    alpha{i in ISET, t in TSET} = rand(&amp;quot;Uniform&amp;quot;, 0, 1);&#xA;               &#xA;&#xA;   /* declare decision variables */&#xA;   var motivation {ISET, TSET, SSET} &amp;gt;= 0 &amp;lt;= 1;&#xA;   var slack {TSET, SSET} &amp;gt;= 0;&#xA;   var mood {ISET, TSET} &amp;gt;= 0 &amp;lt;= 1;&#xA;   var x {ISET, TSET, SSET} binary;&#xA;&#xA;   /* declare objective */&#xA;   minimize z = sum {t in TSET, s in SSET} slack[t,s];&#xA;&#xA;   /* declare constraints */&#xA;   con SatisfyDemand {t in TSET, s in SSET}:&#xA;      sum {i in ISET} motivation[i,t,s] + slack[t,s] = demand[t,s];&#xA;&#xA;   con Indicator {i in ISET, t in TSET, s in SSET}:&#xA;      x[i,t,s] = 1 implies motivation[i,t,s] = mood[i,t]&#xA;   suffixes=(block=i);&#xA;&#xA;   con MotivationImpliesX {i in ISET, t in TSET, s in SSET}:&#xA;      motivation[i,t,s] &amp;lt;= x[i,t,s]&#xA;   suffixes=(block=i);&#xA;&#xA;   con AlphaMood {i in ISET, t in TSET}:&#xA;      alpha * sum {s in SSET} x[i,t,s] + mood[i,t] = 1&#xA;   suffixes=(block=i);&#xA;&#xA;   /* call MILP solver with Dantzig-Wolfe decomposition algorithm */&#xA;   solve with milp / decomp;&#xA;&#xA;   /* write output data here */&#xA;quit;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="491" LastEditDate="2024-03-04T20:30:59.263" LastActivityDate="2024-04-03T21:04:35.673" Title="Implementing column generation in SAS" Tags="|column-generation|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11761" PostTypeId="2" ParentId="11760" CreationDate="2024-03-04T20:28:54.240" Score="1" Body="&lt;p&gt;Here is correct SAS code.  You need only one SOLVE statement, but I provided three for illustration.  You can also read from data sets by using the READ DATA statement.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;proc optmodel;&#xA;   /* declare sets and parameters */&#xA;   set ISET = 1..3, TSET = 1..3, SSET = 1..7;&#xA;   num demand{TSET, SSET} = [&#xA;      2, 1, 0,&#xA;      1, 2, 0,&#xA;      1, 1, 1,&#xA;      1, 2, 0,&#xA;      2, 0, 1,&#xA;      1, 1, 1,&#xA;      0, 3, 0&#xA;   ];&#xA;   /* Generate random values for alpha */&#xA;   call streaminit(123); /* Set a seed for reproducibility */&#xA;   num alpha{ISET, TSET};&#xA;   for {i in ISET, t in TSET} alpha[i,t] = rand(&amp;quot;Uniform&amp;quot;, 0, 1);&#xA;               &#xA;   /* declare decision variables */&#xA;   var motivation {ISET, TSET, SSET} &amp;gt;= 0 &amp;lt;= 1;&#xA;   var slack {TSET, SSET} &amp;gt;= 0;&#xA;   var mood {ISET, TSET} &amp;gt;= 0 &amp;lt;= 1;&#xA;   var x {ISET, TSET, SSET} binary;&#xA;&#xA;   /* declare objective */&#xA;   minimize z = sum {t in TSET, s in SSET} slack[t,s];&#xA;&#xA;   /* declare constraints */&#xA;   con SatisfyDemand {t in TSET, s in SSET}:&#xA;      sum {i in ISET} motivation[i,t,s] + slack[t,s] = demand[t,s];&#xA;&#xA;   con Indicator {i in ISET, t in TSET, s in SSET}:&#xA;      x[i,t,s] = 1 implies motivation[i,t,s] = mood[i,t]&#xA;   suffixes=(block=i);&#xA;&#xA;   con MotivationImpliesX {i in ISET, t in TSET, s in SSET}:&#xA;      motivation[i,t,s] &amp;lt;= x[i,t,s]&#xA;   suffixes=(block=i);&#xA;&#xA;   con AlphaMood {i in ISET, t in TSET}:&#xA;      alpha[i,t] * sum {s in SSET} x[i,t,s] + mood[i,t] = 1&#xA;   suffixes=(block=i);&#xA;&#xA;   /* call MILP solver with (default) branch-and-cut algorithm */&#xA;   solve;&#xA;&#xA;   /* call MILP solver with Dantzig-Wolfe decomposition algorithm and connected components as blocks */&#xA;   solve with milp / decomp=(method=concomp);&#xA;&#xA;   /* call MILP solver with Dantzig-Wolfe decomposition algorithm and user-defined blocks */&#xA;   solve with milp / decomp;&#xA;&#xA;   /* write output data */&#xA;   create data SolutionData_its from [i t s] x;&#xA;   create data SolutionData_ts from [t s] slack;&#xA;quit;&#xA;&#xA;proc export data=SolutionData_its dbms=xlsx&#xA;   outfile=&amp;quot;myoutfile1.xlsx&amp;quot;&#xA;   replace;&#xA;run;&#xA;&#xA;proc export data=SolutionData_ts dbms=xlsx&#xA;   outfile=&amp;quot;myoutfile2.xlsx&amp;quot;&#xA;   replace;&#xA;run;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastActivityDate="2024-03-04T20:28:54.240" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11762" PostTypeId="2" ParentId="11756" CreationDate="2024-03-05T06:00:26.250" Score="1" Body="&lt;p&gt;Suppose, the variables (&lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;) &lt;span class=&quot;math-container&quot;&gt;$\in \mathbb{R}^+$&lt;/span&gt;. To enforce the first conditional expression, you have to define an auxiliary binary variable &lt;span class=&quot;math-container&quot;&gt;$w_1$&lt;/span&gt; and the following constraints:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x \leq Mw_1 - \epsilon \quad (1) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x - z \geq m(1-w_1) \quad (2) $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ x - z \leq M(1-w_1) \quad (3) $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;For the second conditional expression, you will need to use another auxiliary binary variable &lt;span class=&quot;math-container&quot;&gt;$w_2$&lt;/span&gt; and enforce what you want whether it depends on the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; or not. Also, Pyomo has a built-in tool, &lt;em&gt;Generalized Disjunctive Programming&lt;/em&gt;, which somehow makes these kinds of modeling automatically under the hood. The sample code would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyomo.environ as pyo&#xA;import pyomo.gdp as gdp&#xA;&#xA;model = pyo.ConcreteModel()&#xA;&#xA;model.x = pyo.Var(bounds=(0, 10))&#xA;model.z = pyo.Var(bounds=(0, 10))&#xA;&#xA;@model.Disjunction()&#xA;def rule(model):&#xA;    disjunct_A = [&#xA;        model.x &amp;gt;= 0,&#xA;        model.x == model.z&#xA;    ]&#xA;    disjunct_B = [&#xA;        model.x &amp;lt;= 0,&#xA;        model.z == 0&#xA;    ]&#xA;    return [disjunct_A, disjunct_B]&#xA;&#xA;pyo.TransformationFactory('gdp.bigm').apply_to(model)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastActivityDate="2024-03-05T06:00:26.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11763" PostTypeId="1" CreationDate="2024-03-05T07:18:08.347" Score="0" ViewCount="17" Body="&lt;p&gt;There is a proof of how to derive distributionally robust chance constraints with ellipsoid bound.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\inf_{\mathbb{P}\in\mathcal{D}^{WD}} \mathbb{P}\{\|\mathbf{A\zeta-b}\|_2 \leq 1\} \geq 1-\epsilon$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;leads to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sup_{\mathbb{P}\in\mathcal{D}^{WD}}\mathrm{CVaR}_\epsilon (\|\mathbf{A\zeta-b}\|_2-1) \leq 0$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here, the Wasserstein ambituity set &lt;span class=&quot;math-container&quot;&gt;${\mathcal{D}_{\rho}^{DW}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;is centered around&#xA;&lt;span class=&quot;math-container&quot;&gt;${\mathbb{\hat{P}}^M=\frac{1}{M}\sum\delta_{\zeta_i}}$&lt;/span&gt; with radius &lt;span class=&quot;math-container&quot;&gt;${\rho}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \mathbb{P}:\{ d_{WD} (\mathbb{P},\mathbb{\hat{P}}^M) \leq\rho\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Based on the definition of CVaR and min-max theorem in &lt;a href=&quot;https://ieeexplore.ieee.org/document/8814677/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ref&lt;/a&gt;, the right-hand side of CVaR can be written as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sup_{\mathbb{P}\in\mathcal{D}^{DW}} \inf_{t \in \mathbb{R}} \mathbb{E}_{\mathbb{P}} [\max(\|\mathbf{A\zeta-b}\|_2-1+t,0) -t\epsilon] \leq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Which is furthur derived as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\inf_{t \in \mathbb{R}} \sup_{\mathbb{P}\in\mathcal{D}^{DW}} \mathbb{E}_{\mathbb{P}} [\max(\|\mathbf{A\zeta-b}\|_2-1+t,0) -t\epsilon] \leq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;And&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\inf_{t \in \mathbb{R}} \sup_{\mathbb{P}\in\mathcal{D}^{DW}} \mathbb{E}_{\mathbb{P}} [\max(\|\mathbf{A\zeta-b}\|_2-1+t,0) -t\epsilon]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \leq \sup_{\mathbb{P}\in\mathcal{D}^{DW}} \mathbb{E}_{\mathbb{P}} [\max(\|\mathbf{A\zeta-b}\|_2-1+t,0) -t\epsilon]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\leq \rho \|\mathbf{A}\|_{2} + \frac{1}{M} \sum[\max(\|\mathbf{A\zeta-b}\|_2-1+t,0) - t\epsilon]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would like to learn how to perform the transformation using the polyhedra function, not the ellipsoid one.&#xA;That is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sup_{\mathbb{P}\in\mathcal{D}^{DW}} \mathbb{E}_{\mathbb{P}} [\max(\mathbf{D\zeta-q}+t,0) -t\epsilon]$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="13002" LastActivityDate="2024-03-05T07:18:08.347" Title="Supremum of a probabilistic function with ambiguity distribution set using Wasserstein metric" Tags="|stochastic-programming|robust-optimization|polyhedra|probability-theory|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11764" PostTypeId="1" CreationDate="2024-03-05T09:40:45.017" Score="0" ViewCount="66" Body="&lt;p&gt;I've made a CP Model of an hospital in ILOG CPLEX and I want to test the performance of the CPLEX version of it.&lt;/p&gt;&#xA;&lt;p&gt;In my CP model, I have the following constraint :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;forall(c in Chirurgiens, o1 in Operations, o2 in Operations : o1 != o2){&#xA;    (zeta[o1][o2]==1 ) =&amp;gt; psi[o1]+TP[o1]+TC[o1]+ max_time &amp;gt;= psi[o2]+TP[o2];}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where &lt;em&gt;zeta&lt;/em&gt; is a boolean and all other variable are Integers.&lt;/p&gt;&#xA;&lt;p&gt;I've tried to linearize it using a &lt;strong&gt;big M&lt;/strong&gt; and it gave me the following thing :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   forall(c in Chirurgiens, o1 in Operations, o2 in Operations : o1 != o2){&#xA;    (psi[o1]+TP[o1]+TC[o1]+ max_time) &amp;gt;= psi[o2]+TP[o2] -M*(1-zeta[o1,o2]);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;These two constraint gave me the same result.&lt;/p&gt;&#xA;&lt;p&gt;But now, I was cleaning my code a little bit and transformed this constraint into the following one :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;forall(c in Chirurgiens, o1 in Operations, o2 in Operations : o1 != o2){&#xA;    (psi[o1]+TP[o1]+TC[o1]+ max_time) - psi[o2]+TP[o2] &amp;gt;= 0 - M*(1-zeta[o1,o2]);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But now this give me a &lt;strong&gt;different result&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The only thing that I've changed is that I've moved the &lt;code&gt;psi[o2]+TP[o2]&lt;/code&gt; on the other side of the inequality. Isn't this supposed to be a legal move in math ?&lt;/p&gt;&#xA;" OwnerUserId="13283" LastEditorUserId="491" LastEditDate="2024-03-05T14:05:24.137" LastActivityDate="2024-03-05T14:05:24.137" Title="Why are these two constraint equations not equivalent?" Tags="|optimization|cplex|linearization|big-m|indicator-constraints|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11765" PostTypeId="1" AcceptedAnswerId="11781" CreationDate="2024-03-05T11:15:03.893" Score="1" ViewCount="75" Body="&lt;p&gt;Some problems in operations research have (1+ε) approximation algorithms which run in polynomial time. So we have an algorihm that produces a solution which is whose objective is within that factor (1+ε).&lt;/p&gt;&#xA;&lt;p&gt;If the objective can only assume discrete values there might be no feasible solution but an optimal solution with an objective in [global_opt, global_opt * (1+ε)].&lt;/p&gt;&#xA;&lt;p&gt;Since approximation algorithms return a feasible solution to the problem they always find an optimal solution for instances where objectives can only assume discrete values and the second best discrete value is sufficiently far (atleast ε*global_opt) apart from the global optimium. Is that reasoning correct?&lt;/p&gt;&#xA;" OwnerUserId="4777" LastActivityDate="2024-03-08T17:24:50.020" Title="Understanding (1+ ε) approximation when objective is discrete" Tags="|optimization|algorithms|approximation-algorithms|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="11766" PostTypeId="1" CreationDate="2024-03-05T15:48:05.000" Score="0" ViewCount="114" Body="&lt;p&gt;I'm trying to linearize a CP in ILOG CPLEX.&lt;/p&gt;&#xA;&lt;p&gt;I have the following constraint that I want to linearize (I already simplified it with the big M) :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; forall(o1 in Operations){&#xA;      sum (o2 in Operations : o1!= o2)(zeta[o1][o2])&amp;lt;=1+M*(1- sum (o2 in Operations : o1!= o2)(Path_zeta[o1][o2])&amp;gt;=1);&#xA;    } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So I created a new boolean decision variable &lt;code&gt;x1&lt;/code&gt; for each operations, &lt;code&gt;x1[o]&lt;/code&gt; is equals to 1 iif there is at least one 1 for that operation o in the boolean matrix &lt;code&gt;Path_zeta&lt;/code&gt; :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dvar int x1[Operations] in 0..1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and in the constraint :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;//we make sure that if there are no 1 for that operation, x1[o1] is equals to 0&#xA;forall(o1 in Operations){&#xA;    x1[o1] &amp;lt;= sum(o2 in Operations: o1 != o2)(Path_zeta[o1][o2]);}&#xA;&#xA;// we make sure that if there is at least one 1 for that operation, x1[o1] is equals to 1&#xA;forall(o1 in Operations,o2 in Operations){&#xA;    x1[o1] &amp;gt;= (Path_zeta[o1][o2]);&#xA;  }&#xA;//and we can now rewrite the constraint with x1 &#xA;forall(o1 in Operations){&#xA;   sum (o2 in Operations : o1!= o2)(zeta[o1][o2])&amp;lt;=1+M*(1- x1[o1]);;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;when I launch my program with these new contraint, &lt;strong&gt;i get a different optimal value&lt;/strong&gt; that changed the values of &lt;code&gt;Path_zeta&lt;/code&gt; (it's not a valid affectation anymore).&lt;/p&gt;&#xA;&lt;p&gt;In fact, with some debugging, I noticed that if I leave the non linear constraint as it is and I only add this one constraint to my program :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;//we make sure that if there are no 1 for that operation, x1[o1] is equals to 0&#xA;forall(o1 in Operations){&#xA;    x1[o1] &amp;lt;= sum(o2 in Operations: o1 != o2)(Path_zeta[o1][o2]);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I also have the same different result.&lt;/p&gt;&#xA;&lt;p&gt;I don't understand how adding this only constraint change the result of my program : this is only supposed to change &lt;code&gt;x1&lt;/code&gt;, not &lt;code&gt;Path_zeta&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13283" LastEditorUserId="13283" LastEditDate="2024-03-06T15:14:24.287" LastActivityDate="2024-03-06T15:14:24.287" Title="why this little constraint changes my whole program?" Tags="|optimization|mixed-integer-programming|cplex|linearization|big-m|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11769" PostTypeId="2" ParentId="11728" CreationDate="2024-03-06T22:06:00.303" Score="0" Body="&lt;p&gt;You use penalty methods when the constraints considered for penalization are complex and cannot be handled directly. More precisely, if the projection map on your constraints has a closed form, there is no need to penalize them, as you can use projected gradient descent. In the case of minimizing &lt;span class=&quot;math-container&quot;&gt;$f(x)$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$x \ge 0$&lt;/span&gt;, after calculating the term &lt;span class=&quot;math-container&quot;&gt;$x_k - \alpha_k\nabla f(x_k)$&lt;/span&gt;, project it onto the set &lt;span class=&quot;math-container&quot;&gt;$\{x \; | \; x \ge 0\}$&lt;/span&gt;. The resulting projection is then your &lt;span class=&quot;math-container&quot;&gt;$x_{k+1}$&lt;/span&gt;. Note that penalty methods usually provide an approximate solution, which may not even be feasible. To address this issue, people consider &amp;quot;Exact&amp;quot; penalty terms. The price to pay is that your obtained objective function is no longer differentiable across the entire space. For example, Lasso is the result of the exact penalty method. If you are interested in delving into the mathematics of these techniques, you can read a draft of the paper I am writing: &lt;a href=&quot;https://arxiv.org/abs/2206.04020&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arxiv.org/abs/2206.04020&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11566" LastActivityDate="2024-03-06T22:06:00.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11770" PostTypeId="2" ParentId="11750" CreationDate="2024-03-07T07:57:54.123" Score="1" Body="&lt;p&gt;Track 2 in the &lt;a href=&quot;https://www.unitime.org/itc2007/&quot; rel=&quot;nofollow noreferrer&quot;&gt;International Timetabling Competition 2007&lt;/a&gt; was similar if I recall correctly: &lt;strong&gt;Post Enrollment based Course Timetabling&lt;/strong&gt;. You might be able to find some papers around that.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I've heard public mentions of US Navy pilot training and NATO school scheduling implementations based our &lt;a href=&quot;https://github.com/TimefoldAI/timefold-quickstarts/tree/stable?tab=readme-ov-file#school-timetabling&quot; rel=&quot;nofollow noreferrer&quot;&gt;school-scheduling quickstart&lt;/a&gt;, but that requires customization because that quickstart does not assign students to lessons out-of-the-box - only lessons to rooms and timeslots.&lt;/p&gt;&#xA;&lt;p&gt;Also, because your case is more likely to work on dates than on day-of-week or date offsets, you might be better off with a time grain pattern, as used in the maintenance scheduling quickstart. Each pattern has a trade-off:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bceLf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bceLf.png&quot; alt=&quot;patterns&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2024-03-07T07:57:54.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11771" PostTypeId="1" AcceptedAnswerId="11772" CreationDate="2024-03-07T09:06:42.577" Score="2" ViewCount="205" Body="&lt;p&gt;I have a binary quadratic problem with objective &lt;span class=&quot;math-container&quot;&gt;${\bf{x}}^T{\bf{Qx}}+{\bf{c}}^T{\bf{x}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\bf{A}}{\bf{x}}\le{\bf{b}}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\bf{A}}_{eq}{\bf{x}}={\bf{b}}_{eq}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;here &lt;span class=&quot;math-container&quot;&gt;${\bf{x}}$&lt;/span&gt; is binary.&lt;/p&gt;&#xA;&lt;p&gt;From &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/7015136566801-Binary-Quadratic-Programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://support.gurobi.com/hc/en-us/community/posts/7015136566801-Binary-Quadratic-Programming&lt;/a&gt;, we know that&#xA;we can transform this binary QP into a binary linear problem.&lt;/p&gt;&#xA;&lt;p&gt;For my QP problem, then what will be objective function for the binary linear problem?&lt;/p&gt;&#xA;&lt;p&gt;is it&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\sum{\bf{Qy}}+{\bf{c}}^T{\bf{y}}$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;${\bf{y}}$&lt;/span&gt; is new variable for linearizing the multiplication of binary variables.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="500" LastEditDate="2024-03-07T13:44:09.607" LastActivityDate="2024-03-08T09:01:42.000" Title="How to transform a binary QP into an MILP?" Tags="|linearization|nonlinear-programming|convex-optimization|binary-variable|quadratic-programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11772" PostTypeId="2" ParentId="11771" CreationDate="2024-03-07T09:30:29.253" Score="5" Body="&lt;p&gt;For simplicity, lets assume &lt;span class=&quot;math-container&quot;&gt;$Q$&lt;/span&gt; is a &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; dimensional matrix:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;x^TQx = &#xA;\begin{pmatrix}&#xA;x_1 &amp;amp; x_2 \\&#xA;\end{pmatrix}&#xA;\begin{pmatrix}&#xA;q_{11} &amp;amp; q_{12} \\&#xA;q_{12} &amp;amp; q_{22}&#xA;\end{pmatrix}&#xA;\begin{pmatrix}&#xA;x_1 \\&#xA;x_2&#xA;\end{pmatrix}&#xA;=q_{11}x_1^2+q_{22}x_2^2+2q_{12}x_1x_2&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So your objective function looks like:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;q_{11}x_1^2+q_{22}x_2^2+2q_{12}x_1x_2 +c_1x_1 +c_2x_2&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; are binaries, you can simplify to:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;q_{11}x_1+q_{22}x_2+2q_{12}x_1x_2 +c_1x_1 +c_2x_2&#xA;= (q_{11}+c_1)x_1 + (q_{22}+c_2)x_2 + 2q_{12}x_1x_2&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The last step is to use the linearization trick described in the link your provided for &lt;span class=&quot;math-container&quot;&gt;$x_1x_2$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;(q_{11}+c_1)x_1 + (q_{22}+c_2)x_2 + 2q_{12}z_{12}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;z_{12} &amp;amp;\le x_1 \\&#xA;z_{12} &amp;amp;\le x_2 \\&#xA;z_{12} &amp;amp;\ge x_1 +x_2-1&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;More generally, the objective function can be written as follows:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\sum_i(q_{ii}+c_i)x_i + \sum_{i,j|i&amp;lt;j} 2q_{ij}z_{ij}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="2556" LastEditorUserId="2556" LastEditDate="2024-03-08T09:01:42.000" LastActivityDate="2024-03-08T09:01:42.000" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11773" PostTypeId="1" CreationDate="2024-03-07T10:41:34.200" Score="1" ViewCount="42" Body="&lt;p&gt;Does anyone have an idea how to create a custom B&amp;amp;B on CPLEX or GAMS? In my work, I need to add custom cuts on integer solutions in certain conditions by adding only one branch. Also, I need to get the optimal tableau of simplex of the relaxed problem to detect this conditions.&lt;/p&gt;&#xA;&lt;p&gt;Is there any way to do that without going to do it manually?&lt;/p&gt;&#xA;&lt;p&gt;I'm using C++.&lt;/p&gt;&#xA;" OwnerUserId="13295" LastEditorUserId="491" LastEditDate="2024-03-07T23:55:35.400" LastActivityDate="2024-03-07T23:55:35.400" Title="custom branch and bound on cplex or GAMS" Tags="|cplex|c++|gams|callback|branch-and-cut|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11774" PostTypeId="2" ParentId="11773" CreationDate="2024-03-07T16:47:44.957" Score="1" Body="&lt;p&gt;It seems BranchCallback function in cplex. I provide the introduction about BranchCallback on the official website and I did a very simple example by using VS C++ as well.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Cplex website&#xA;&lt;a href=&quot;https://www.ibm.com/docs/pt/icos/20.1.0?topic=classes-cplexcallbacksbranchcallback&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/pt/icos/20.1.0?topic=classes-cplexcallbacksbranchcallback&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;my github link&#xA;&lt;a href=&quot;https://github.com/ytsao/MyBranchAndCut/blob/master/MyBranchAndCut/MyBranchAndCut.cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ytsao/MyBranchAndCut/blob/master/MyBranchAndCut/MyBranchAndCut.cpp&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="12370" LastActivityDate="2024-03-07T16:47:44.957" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11775" PostTypeId="1" CreationDate="2024-03-07T17:09:09.970" Score="0" ViewCount="45" Body="&lt;p&gt;Is it somehow possible to apply local branching in branch-and-price?&lt;/p&gt;&#xA;&lt;p&gt;In branch-and-bound it is easy to add a constraint that allows at most k decision variables to change compared to a given solution.&lt;/p&gt;&#xA;&lt;p&gt;However, in branch-and-price we have to deal with fractional solutions. I don't know how to add a constraint in the master and pricing problem such that at most k decision variables differ compared to the given solution due to fractional solutions.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible at all? Or is the master and pricing problem the wrong place and including such a constraint somehow in the branching rule is more reasonable?&lt;/p&gt;&#xA;&lt;p&gt;Does anyone successfully integrated local branching into branch-and-price? It would be nice to see some approaches or at least to have a fruitful discussion about this topic!&lt;/p&gt;&#xA;&lt;p&gt;Lets consider the Cutting Stock Problem.&lt;/p&gt;&#xA;&lt;p&gt;Gilmore &amp;amp; Gomory formulation of the restricted master problem is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ min\sum_{p\in P'}\lambda_p$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ s.t. \quad \sum_{p\in P'}a_{ip}\lambda_p = d_i \quad [\pi_i] \quad i \in [n]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \lambda_p \geq 0 \quad\quad\quad p\in P'$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ P' \subseteq P=\{(a_1,\ldots,a_n)^t \in \mathbb{Z}_+^n | \sum\limits_{i=1}^n l_ia_i \leq L\}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;a subset of variables.&lt;/p&gt;&#xA;&lt;p&gt;Optimal dual&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\pi^t = (\pi_1,\ldots,\pi_n)$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Pricing problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ z = \min_{p \in P} \bar{c}_p = \min_{p \in P} 1 - (\pi_1,\ldots,\pi_n)\cdot (a_{1p},a_{2p},\ldots,a_{np})^t$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ = 1 - max\sum\limits_{i=1}^n \pi_i x_i$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ s.t. \quad \sum\limits_{i=1}^n l_i x_i \leq L $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ x_i \in \mathbb{Z}_+ \quad i\in [n]$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$a^* = (a^*_1,\ldots,a^*_n)^t$&lt;/span&gt;&#xA;be a solution to the master problem.&lt;/p&gt;&#xA;&lt;p&gt;What constraint (if possible and reasonable?) to add such that at most k variables differ from a*?&lt;/p&gt;&#xA;" OwnerUserId="13296" LastActivityDate="2024-03-07T17:09:09.970" Title="Local Branching in Branch-And-Price" Tags="|mixed-integer-programming|combinatorial-optimization|branch-and-bound|branch-and-price|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11776" PostTypeId="1" CreationDate="2024-03-07T19:36:07.010" Score="1" ViewCount="23" Body="&lt;p&gt;It is well-known that linear programs always have sparse solutions -- solutions in which only at most &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; variables are nonzero, where &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt; is the number of constraints.&lt;/p&gt;&#xA;&lt;p&gt;In &lt;a href=&quot;https://or.stackexchange.com/q/11409/2576&quot;&gt;the answers to this question&lt;/a&gt;, it is shown that the same does not hold for quadratic convex programs, as there may be quadratic programs in which all solutions are dense.&lt;/p&gt;&#xA;&lt;p&gt;QUESTION: are there other classes of mathematical programs (besides linear programs) in which all problems are guaranteed to have sparse solutions?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastActivityDate="2024-03-07T19:36:07.010" Title="Are there classes of non-linear programs that always have sparse solutions?" Tags="|nonlinear-programming|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11777" PostTypeId="1" CreationDate="2024-03-08T01:46:30.723" Score="0" ViewCount="72" Body="&lt;p&gt;I have a problem under investigation which requires if, elseif and else conditions to implement as a constraint in a mixed integer program. Any leads will be appreciated. Thanks a lot.&lt;/p&gt;&#xA;&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$x_t$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$y_t$&lt;/span&gt; be continuous variables.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;if y[t] == 0:&#xA;   x[t] = 1 &#xA;elif y[t] == y[t-1]: &#xA;   x[t] = x[t-1] * K #(constant) &#xA;else: &#xA;   y[t] = 1 - x[t]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13299" LastEditorUserId="12370" LastEditDate="2024-03-08T14:27:15.853" LastActivityDate="2024-03-08T21:09:13.113" Title="How to write a If then else constraint with continuous variables" Tags="|mixed-integer-programming|linear-programming|integer-programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11778" PostTypeId="1" CreationDate="2024-03-08T15:41:49.010" Score="2" ViewCount="35" Body="&lt;p&gt;What are some use cases, with high dollar value impact, of OR and optimization in the financial services industry like life insurance, annuity business?&lt;/p&gt;&#xA;&lt;p&gt;I have seen common use cases of queuing theory for call center, generalized assignment problem, etc.&lt;/p&gt;&#xA;" OwnerUserId="1219" LastActivityDate="2024-03-08T21:11:35.617" Title="use case OR in financial service industry" Tags="|optimization|finance|operations|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11779" PostTypeId="2" ParentId="11778" CreationDate="2024-03-08T17:16:21.813" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Portfolio_optimization&quot; rel=&quot;nofollow noreferrer&quot;&gt;Portfolio optimization&lt;/a&gt; seems to use mathematical programming extensively. Whether is has &amp;quot;high dollar value impact&amp;quot; probably depends on the size of the portfolio you are optimizing.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-03-08T17:16:21.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11780" PostTypeId="2" ParentId="11777" CreationDate="2024-03-08T17:18:21.793" Score="0" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$1-y_t-Mz_t \le x_t \le 1-y_t+Mz_t$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ M(z_t-1) \le y_t - y_{t-1} \le M(1-z_t)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$ L(1-z_t)+ y_{t-1}-Mz_t \le z_t +y_t \le y_{t-1} +M (1-z_t)+Lz_t $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$Kx_{t-1}+M(z_t-1) \le x_t \le Kx_{t-1} + M(1-z_t)$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With &lt;span class=&quot;math-container&quot;&gt;$z_t \in \{0,1 \}$&lt;/span&gt;, binary, &lt;span class=&quot;math-container&quot;&gt;$x_t,y_t = [L,M]$&lt;/span&gt; and&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2024-03-08T18:45:04.470" LastActivityDate="2024-03-08T18:45:04.470" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11781" PostTypeId="2" ParentId="11765" CreationDate="2024-03-08T17:24:50.020" Score="1" Body="&lt;p&gt;As requested, this answer is a combination of comments I made.&lt;/p&gt;&#xA;&lt;p&gt;I agree that if a &lt;span class=&quot;math-container&quot;&gt;$(1+\epsilon)$&lt;/span&gt; approximate algorithm returns a feasible solution to a problem where the second best feasible solution (if there is one) has objective value differing from the optimum by a factor greater than &lt;span class=&quot;math-container&quot;&gt;$\epsilon,$&lt;/span&gt; the algorithm's solution is optimal.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, given a problem where the second best objective value differs from optimum by less than a factor of &lt;span class=&quot;math-container&quot;&gt;$\epsilon,$&lt;/span&gt; there is no way to &amp;quot;tweak&amp;quot; the model to increase the spacing in objective values without altering the feasible region (hence fundamentally changing the model). In particular, scaling the objective does not help since &lt;span class=&quot;math-container&quot;&gt;$f' \le (1+\epsilon)f \implies \alpha f' \le \alpha (1+\epsilon)f$&lt;/span&gt; for any positive factor &lt;span class=&quot;math-container&quot;&gt;$\alpha$&lt;/span&gt;. Here I assume for convenience a minimization problem with optimal value &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; and feasible value &lt;span class=&quot;math-container&quot;&gt;$f'.$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-03-08T17:24:50.020" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11782" PostTypeId="2" ParentId="11777" CreationDate="2024-03-08T19:27:18.740" Score="1" Body="&lt;p&gt;Introduce three binary variables &lt;span class=&quot;math-container&quot;&gt;$z_{1t},z_{2t},z_{3t}$&lt;/span&gt; corresponding&#xA;to the three conditions, along with the constraint &lt;span class=&quot;math-container&quot;&gt;$z_{1t}+z_{2t}+z_{3t}=1$&lt;/span&gt;&#xA;(exactly one condition must apply).&lt;/p&gt;&#xA;&lt;p&gt;We want to enforce the following implications:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$z_{1t}=1\implies\left(y_{t}=0\right)\wedge\left(x_{t}=1\right)&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_{2t}=1\implies\left(y_{t}&amp;gt;0\right)\wedge\left(y_{t}=y_{t-1}\right)\wedge\left(x_{t}=Kx_{t-1}\right)&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$z_{3t}=1\implies\left(y_{t}&amp;gt;0\right)\wedge\left(y_{t}\neq y_{t-1}\right)\wedge\left(y_{t}=1-x_{t}\right)&#xA;$$&lt;/span&gt;&#xA;Unfortunately, strict inequality (&lt;span class=&quot;math-container&quot;&gt;$&amp;gt;$&lt;/span&gt;) and &amp;quot;not equals&amp;quot; (&lt;span class=&quot;math-container&quot;&gt;$\neq$&lt;/span&gt;)&#xA;cannot be used in a mathematical program, so the best we can do is&#xA;an approximation using some small &lt;span class=&quot;math-container&quot;&gt;$\epsilon&amp;gt;0.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the following, &lt;span class=&quot;math-container&quot;&gt;$M_{1},\dots,M_{6}$&lt;/span&gt; are sufficiently large positive&#xA;constants. The first implication can be expressed as follows.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{t}\le M_{1}\left(1-z_{1t}\right)&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{t}\le1+M_{2}\left(1-z_{1t}\right)&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{t}\ge z_{1t}&#xA;$$&lt;/span&gt;&#xA;The second implication is approximated as follows.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{t}\ge\epsilon z_{2t}&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{t}-y_{t-1}\le M_{3}\left(1-z_{2t}\right)&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{t-1}-y_{t}\le M_{3}\left(1-z_{2t}\right)&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_{t}-Kx_{t-1}\le M_{4}\left(1-z_{2t}\right)&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$Kx_{t-1}-x_{t}\le M_{4}\left(1-z_{2t}\right)&#xA;$$&lt;/span&gt;&#xA;To handle the &lt;span class=&quot;math-container&quot;&gt;$\neq$&lt;/span&gt; element of the third implication, we need yet&#xA;another binary variable &lt;span class=&quot;math-container&quot;&gt;$w_{t}.$&lt;/span&gt; The following approximates the third&#xA;implication.&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{t}\ge\epsilon z_{3t}&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{t}-y_{t-1}\ge\epsilon z_{3t}-M_{5}w_{t}&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{t-1}-y_{t}\ge\epsilon z_{3t}-M_{5}\left(1-w_{t}\right)&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$y_{t}-\left(1-x_{t}\right)\le M_{6}\left(1-z_{3t}\right)&#xA;$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\left(1-x_{t}\right)-y_{t}\le M_{6}\left(1-z_{3t}\right)&#xA;$$&lt;/span&gt;&#xA;This necessarily eliminates some solutions that might&#xA;otherwise be feasible in the original model, such as &lt;span class=&quot;math-container&quot;&gt;$y_{t}=y_{t-1}$&lt;/span&gt;&#xA;and &lt;span class=&quot;math-container&quot;&gt;$x_{t}=Kx_{t-1}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$y_{t}\in\left(0,\epsilon\right)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: As pointed out by Rob Pratt in a comment, replacing &lt;span class=&quot;math-container&quot;&gt;$y_{t}\ge\epsilon z_{2t}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y_{t}\ge\epsilon z_{3t}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$y_{t}\ge\epsilon (1 - z_{1t})$&lt;/span&gt; is conceptually equivalent and yields a tighter relaxation.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2024-03-08T21:09:13.113" LastActivityDate="2024-03-08T21:09:13.113" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11783" PostTypeId="2" ParentId="11778" CreationDate="2024-03-08T21:11:35.617" Score="1" Body="&lt;p&gt;You can find in this &lt;a href=&quot;https://www.andrew.cmu.edu/user/gc0v/webpub/book.pdf&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Optimization Methods in Finance&quot;&gt;book&lt;/a&gt; several problems that you search.&lt;/p&gt;&#xA;" OwnerUserId="13295" LastActivityDate="2024-03-08T21:11:35.617" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11784" PostTypeId="1" AcceptedAnswerId="11785" CreationDate="2024-03-08T21:15:19.373" Score="0" ViewCount="78" Body="&lt;p&gt;I have a system with 100 users. There are 6 resources.&#xA;At any point of time, only 2 resources are made available and those resources can be shared among the users.&lt;/p&gt;&#xA;&lt;p&gt;Some users may not get any resource, e.g., it may not have any demand or other users may have higher priority. As resources are shared among more users, the efficiency of the resources is reduced.&lt;/p&gt;&#xA;&lt;p&gt;I have defined a variable x as follows.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\bf x}=[x_1\hspace{1mm} x_2\hspace{1mm} x_3\hspace{1mm} x_4\hspace{1mm} x_5\hspace{1mm} x_6\hspace{3mm}x_7\hspace{1mm} x_8\hspace{1mm} x_9\hspace{1mm} x_{10}\hspace{1mm} x_{11}\hspace{1mm} x_{12}\cdots \hspace{1mm} \cdots \hspace{1mm}x_{595}\hspace{1mm} x_{596}\hspace{1mm} x_{597}\hspace{1mm} x_{598}\hspace{1mm} x_{599}\hspace{1mm} x_{600} ]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here the tuples are defines as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\bf x}=[\lbrace u,r \rbrace,\hspace{1mm}u=1,2,\cdots, 100, r=1,2,\cdots, 6]$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The tuples are ordered as&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1=\lbrace u=1,r=1 \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_2=\lbrace u=1,r=2 \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_3=\lbrace u=1,r=3 \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_4=\lbrace u=1,r=4 \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_5=\lbrace u=1,r=5 \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_6=\lbrace u=1,r=6 \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;then&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_7=\lbrace u=2,r=1 \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_8=\lbrace u=2,r=2 \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_9=\lbrace u=2,r=3 \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{10}=\lbrace u=2,r=4 \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{11}=\lbrace u=2,r=5 \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_{12}=\lbrace u=2,r=6 \rbrace$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;and so on...&lt;/p&gt;&#xA;&lt;p&gt;Now, I want model the constraint as a linear inequality constraint in the form&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\bf Ax \le b$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;So, &lt;span class=&quot;math-container&quot;&gt;$x_1=1,\hspace{1mm}x_8=1$&lt;/span&gt; is a valid case. Resource 1 and resource 2 {&amp;lt;=2} are activated&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_3=1,\hspace{1mm}x_9=1$&lt;/span&gt; is a valid case. Only Resource 3 (&amp;lt;=2) activated&lt;/p&gt;&#xA;&lt;p&gt;but&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$x_1=1,\hspace{1mm}x_8=1,\hspace{1mm}x_{15}=1$&lt;/span&gt; is not a valid case. Resource 1, resource 2 and resource 3 (&amp;gt;2) are activated.&lt;/p&gt;&#xA;&lt;p&gt;How can I model this constraint for a QP problem.&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="500" LastEditDate="2024-03-08T22:09:25.547" LastActivityDate="2024-03-10T15:20:44.793" Title="How to model this constraint for a QP problem?" Tags="|optimization|mixed-integer-programming|modeling|combinatorial-optimization|quadratic-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11785" PostTypeId="2" ParentId="11784" CreationDate="2024-03-08T22:02:03.280" Score="4" Body="&lt;p&gt;I assume that &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is binary.  A more natural indexing would be &lt;span class=&quot;math-container&quot;&gt;$x_{ur}$&lt;/span&gt;, in which case you can introduce binary decision variables &lt;span class=&quot;math-container&quot;&gt;$y_r$&lt;/span&gt; and impose linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x_{ur} &amp;amp;\le y_r &amp;amp;&amp;amp;\text{for all $u$ and $r$} \tag1\label1 \\&#xA;\sum_r y_r &amp;amp;\le 2 \tag2\label2&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} enforces &lt;span class=&quot;math-container&quot;&gt;$x_{ur} \implies y_r$&lt;/span&gt;, and constraint \eqref{2} allows at most &lt;span class=&quot;math-container&quot;&gt;$2$&lt;/span&gt; resources to be activated.&lt;/p&gt;&#xA;&lt;p&gt;If you really need your original indexing, replace &lt;span class=&quot;math-container&quot;&gt;$x_{ur}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$x_{6(u-1)+r}$&lt;/span&gt; in \eqref{1}.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;You can also avoid introducing new variables, but at the cost of imposing more constraints.  For each ordered triple &lt;span class=&quot;math-container&quot;&gt;$(u_1,u_2,u_3)$&lt;/span&gt; of distinct users and ordered triple &lt;span class=&quot;math-container&quot;&gt;$(r_1,r_2,r_3)$&lt;/span&gt; of distinct resources, you want to enforce the following logical proposition:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\lnot(x_{u_1 r_1} \land x_{u_2 r_2} \land x_{u_3 r_3})$$&lt;/span&gt;&#xA;Rewriting in conjunctive normal form somewhat automatically yields linear constraints:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\lnot x_{u_1 r_1} \lor \lnot x_{u_2 r_2} \lor \lnot x_{u_3 r_3} \\&#xA;(1-x_{u_1 r_1}) + (1-x_{u_2 r_2}) + (1-x_{u_3 r_3}) \ge 1 \\&#xA;x_{u_1 r_1} + x_{u_2 r_2} + x_{u_3 r_3} \le 2&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-03-10T15:20:44.793" LastActivityDate="2024-03-10T15:20:44.793" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11786" PostTypeId="1" CreationDate="2024-03-08T22:37:56.837" Score="0" ViewCount="42" Body="&lt;p&gt;Could someone help me convert these OPL constraints into equivalent Pyomo ConstraintList constraints for a concrete model:&lt;/p&gt;&#xA;&lt;p&gt;opl code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ct_b:&#xA;    sum(i in items)cost[i][&amp;quot;s3&amp;quot;] &amp;lt;= 0.4*sum(i in items, j in suppliers)cost[i][j]*q[i][j];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    model.b_constr = ConstraintList()&#xA;    model.b_constr.add(sum (model.cost[i, 'S3'] for i in items) &amp;lt;=  0.4*(sum(model.cost[i,j]*model.q[i,j] for i in items for j in suppliers ))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;opl code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    forall(i in items: i!=&amp;quot;B&amp;quot; &amp;amp;&amp;amp; i!=&amp;quot;C&amp;quot;){&#xA;      ct_d_3:&#xA;      sum(j in suppliers)x[i][j]==4;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;model.ct_d_3 = ConstraintList()&#xA;model.ct_d_3.add(for i in items if i!=&amp;quot;B&amp;quot; &amp;amp;&amp;amp; i!=&amp;quot;C&amp;quot;:&#xA;        model.d_constr_3.add(sum (model.q[i,j] for j in suppliers) ==4))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am getting syntax error in formulating above code in Pyomo.&lt;/p&gt;&#xA;&lt;p&gt;Any help would be greatly appreciated.&lt;/p&gt;&#xA;&lt;p&gt;NOTE: Already tried ChatGPT! Satisfactory result not obtained.&lt;/p&gt;&#xA;" OwnerUserId="10745" LastEditorUserId="10745" LastEditDate="2024-03-09T19:18:52.987" LastActivityDate="2024-03-09T19:18:52.987" Title="OPL Constraint to pyomo ConstraintList constraint for concrete model" Tags="|pyomo|opl|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11787" PostTypeId="2" ParentId="11786" CreationDate="2024-03-09T07:33:46.530" Score="1" Body="&lt;p&gt;I think this is a perfect task for e.g. chatGPT:&lt;/p&gt;&#xA;&lt;p&gt;Prompt: Could you translate the following OPL constraints to Pyomo using pyomo’s ConstraintList: forall(j in suppliers){&#xA;ct_c_f1:&#xA;x[&amp;quot;F&amp;quot;][j]&amp;gt;=q[&amp;quot;F&amp;quot;][j]/M;&#xA;ct_c_f2:&#xA;q[&amp;quot;F&amp;quot;][j]&amp;gt;=x[&amp;quot;F&amp;quot;][j]/M;&#xA;}&lt;/p&gt;&#xA;&lt;p&gt;Answer: Certainly! Here's how you can translate those OPL constraints to Pyomo using pyomo's ConstraintList:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from pyomo.environ import &#xA;&#xA;ConcreteModel, Var, Constraint, Param, ConstraintList&#xA;&#xA;# Assuming you have already defined 'suppliers', 'M', 'x', and 'q'&#xA;&#xA;model = ConcreteModel()&#xA;&#xA;# Define variables&#xA;model.x = Var([&amp;quot;F&amp;quot;, &amp;quot;other_indices&amp;quot;], suppliers)&#xA;model.q = Var([&amp;quot;F&amp;quot;, &amp;quot;other_indices&amp;quot;], suppliers)&#xA;&#xA;# Define parameter M&#xA;model.M = Param(initialize=M)&#xA;&#xA;# Create a ConstraintList&#xA;model.constraints = ConstraintList()&#xA;&#xA;# Add constraints to the ConstraintList&#xA;for j in suppliers:&#xA;    model.constraints.add(expr=model.x[&amp;quot;F&amp;quot;, j] &amp;gt;= model.q[&amp;quot;F&amp;quot;, j] / model.M)&#xA;    model.constraints.add(expr=model.q[&amp;quot;F&amp;quot;, j] &amp;gt;= model.x[&amp;quot;F&amp;quot;, j] / model.M)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="278" LastActivityDate="2024-03-09T07:33:46.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11788" PostTypeId="1" CreationDate="2024-03-10T02:45:47.753" Score="1" ViewCount="26" Body="&lt;p&gt;Let's consider the following deterministic constrained optimisation problem, where &lt;span class=&quot;math-container&quot;&gt;$c(t)$&lt;/span&gt; is the control, and &lt;span class=&quot;math-container&quot;&gt;$x(t)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y(t)$&lt;/span&gt; are the state variables:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;J(t) = \inf_{c(t)} \ &amp;amp;\int_0^\infty e^{-\delta u} \left( x(u)^2 + \lambda y(u)^2 \right) du \\&#xA;s.t. \ &amp;amp;c(t) \geq - \xi&#xA;\end{align}&lt;/span&gt;&#xA;The dynamics of the states are:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x'(t) &amp;amp;= c(t) - y(t) - a \\&#xA;y'(t) &amp;amp;= \delta y(t) - b x(t)&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$x(0)=x_0$&lt;/span&gt; and where the following transversality condition holds: &lt;span class=&quot;math-container&quot;&gt;$\lim_{T \to \infty} E_t [e^{-\delta T} y(T)]=0$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;To solve this problem, I write the extended Hamiltonian:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\mathcal{H} = x(t)^2 + \lambda y(t)^2 + J_{x}(t) ( c(t) - y(t) - a ) + J_{y}(t) \left( \delta y(t) - b x(t) \right) - \mu_{c}(t) (c(t) + \xi)&#xA;\end{align}&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$J_{x}(t)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$J_{y}(t)$&lt;/span&gt; denote the derivatives of the value function with respect to the states (i.e. the co-state variables), and &lt;span class=&quot;math-container&quot;&gt;$\mu_{c}(t)$&lt;/span&gt; is the Lagrange multiplier.&lt;/p&gt;&#xA;&lt;p&gt;Next, I write the three optimality conditions:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0 &amp;amp;= \mathcal{H}_{c}(t) \rightarrow J_{x}(t) = \mu_{c}(t) \nonumber&#xA;\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0 &amp;amp;= \mathcal{H}_{x}(t) + \frac{dJ_{x}(t)}{dt} - \delta J_{x}(t) \rightarrow 0 = 2 x(t) - J_{y}(t) b + \frac{dJ_{x}(t)}{dt}  - \delta J_{x}(t) \nonumber&#xA;\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0 &amp;amp;= \mathcal{H}_{y}(t) + \frac{dJ_{y}(t)}{dt} - \delta J_{y}(t) \rightarrow 0 = 2 \lambda y(t) - J_{x}(t) + \frac{dJ_{y}(t)}{dt} \nonumber &#xA;\end{align}&lt;/span&gt;&#xA;with the complementary slackness conditions:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0 &amp;amp;= \mu_{c}(t) (c(t) + \xi) \rightarrow 0 = J_{x}(t) (c(t) + \xi) \nonumber&#xA;\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;0 \leq \mu_{c}(t) \rightarrow 0 \leq J_{x}(t) \nonumber&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I proceed to solve the problem as follows:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I postulate the existence of a value of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;, called &lt;span class=&quot;math-container&quot;&gt;$\hat{x}$&lt;/span&gt;, below which the constraint on the control is binding and above which it is not binding. This is reasonable given the context of the problem.&lt;/li&gt;&#xA;&lt;li&gt;I express &lt;span class=&quot;math-container&quot;&gt;$y(t)$&lt;/span&gt; as a function of &lt;span class=&quot;math-container&quot;&gt;$x(t)$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;I solve the problem in the region where the constraint is not binding (i.e. where &lt;span class=&quot;math-container&quot;&gt;$J_x(t)=0$&lt;/span&gt;) finding a solution for &lt;span class=&quot;math-container&quot;&gt;$x(t)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y(t)$&lt;/span&gt; (it turns out &lt;span class=&quot;math-container&quot;&gt;$y(t) = k_1 x(t)$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$k_1$&lt;/span&gt; is a constant). In this region, the optimal control is a function of &lt;span class=&quot;math-container&quot;&gt;$x(t)$&lt;/span&gt;, i.e. &lt;span class=&quot;math-container&quot;&gt;$c(t) = f(x(t))$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;I solve the problem in the region where the constraint is binding (i.e. where &lt;span class=&quot;math-container&quot;&gt;$J_x(t) &amp;gt; 0$&lt;/span&gt;) finding a solution for &lt;span class=&quot;math-container&quot;&gt;$x(t)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$y(t)$&lt;/span&gt; (it turns out &lt;span class=&quot;math-container&quot;&gt;$y(t) = k_2 + k_3 x(t)$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$k_2$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$k_3$&lt;/span&gt; are constants). In this region, the optimal control is simply &lt;span class=&quot;math-container&quot;&gt;$c(t) = - \xi$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Can you suggest how I can determine the value of &lt;span class=&quot;math-container&quot;&gt;$\hat{x}$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Attempts:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I argue that since &lt;span class=&quot;math-container&quot;&gt;$c(t)$&lt;/span&gt; is a regular control, there cannot be a jump in the state variables, so that:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\lim_{x_t \to \hat{x}^-} y(x(t)) &amp;amp;= \lim_{x_t \to \hat{x}^+} y(x(t)) \\&#xA;\lim_{x_t \to \hat{x}^-} k_2 + k_3 x_t &amp;amp;= \lim_{x_t \to \hat{x}^+} k_1 x_t \\&#xA;\hat{x} &amp;amp;= \frac{k_2}{k_1 - k_3}&#xA;\end{align}&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;Alternatively, I argue that there cannot be a jump in the control, so that:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;- \xi &amp;amp;= \lim_{x_t \to \hat{x}^+} c(t) \\&#xA;- \xi &amp;amp;= \lim_{x_t \to \hat{x}^+} f(x(t)) \\&#xA;\hat{x} &amp;amp;= f^{-1}(-\xi)&#xA;\end{align}&lt;/span&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;However, these two approaches give different values of &lt;span class=&quot;math-container&quot;&gt;$\hat{x}$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I understand that without seeing the full solution it is hard to give an answer to this question, but I would appreciate also links to examples that show how to solve a problem of this type.&lt;/p&gt;&#xA;" OwnerUserId="13310" LastActivityDate="2024-03-10T02:45:47.753" Title="Optimal control problem with bounded control" Tags="|constrained-optimization|optimal-control|hamiltonian-path|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11789" PostTypeId="1" CreationDate="2024-03-10T11:49:36.280" Score="0" ViewCount="34" Body="&lt;p&gt;Lets say we have a QP problem as shown below&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\min {\bf x}^T {\bf R}{\bf x}+{\bf c}^T{\bf x}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$${\bf A_{eq}x}={\bf e}_{eq}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$${\bf Ax}\le {\bf e}$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$${\bf x}\in \lbrace 0,1\rbrace$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;${\bf x}$&lt;/span&gt; is of very large size, e.g., 40000.&lt;/p&gt;&#xA;&lt;p&gt;I can solve it with gradient descent method. Then how can I do the projection heuristically based on the equality and inequality constraints?&lt;/p&gt;&#xA;&lt;p&gt;After solving the QP with gradient descent we get some continuous values for &lt;span class=&quot;math-container&quot;&gt;${\bf x}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I map them back to binary heuristically based on the constraints?&lt;/p&gt;&#xA;&lt;p&gt;Note: Both &lt;span class=&quot;math-container&quot;&gt;${\bf A}_{eq}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;${\bf A}$&lt;/span&gt; are binary matrices&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="836" LastEditDate="2024-03-11T08:52:52.400" LastActivityDate="2024-03-11T08:52:52.400" Title="Projection of QP problem solved with Gradient Descent" Tags="|mixed-integer-programming|constraint|convex-optimization|quadratic-programming|heuristics|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11790" PostTypeId="1" CreationDate="2024-03-10T13:59:19.210" Score="2" ViewCount="112" Body="&lt;p&gt;I have a binary variable &lt;span class=&quot;math-container&quot;&gt;$\bf x$&lt;/span&gt; of length 4000.  Let&#xA;&lt;span class=&quot;math-container&quot;&gt;${\bf x}=[x_1,x_2,\cdots, x_{4000}]$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let's say we have &lt;span class=&quot;math-container&quot;&gt;${\bf y}=[y_1,y_2,y_3,y_4]$&lt;/span&gt;, where&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;y_1&amp;amp;=x_1+x_5+x_{9}+\cdots+x_{3997} \\&#xA;y_2&amp;amp;=x_2+x_{6}+x_{10}+\cdots+x_{3998} \\&#xA;y_3&amp;amp;=x_3+x_{7}+x_{11}+\cdots+x_{3999} \\&#xA;y_4&amp;amp;=x_4+x_{8}+x_{12}+\cdots+x_{4000}&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now, the constraint I have is: the number of nonzero elements in &lt;span class=&quot;math-container&quot;&gt;${\bf y}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$\le 2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;In other words, the &lt;span class=&quot;math-container&quot;&gt;$l_0$&lt;/span&gt; norm of vector &lt;span class=&quot;math-container&quot;&gt;${\bf y}$&lt;/span&gt; is &lt;span class=&quot;math-container&quot;&gt;$\le 2$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;How to model this constraint with and without (if possible) introducing new variables?&lt;/p&gt;&#xA;&lt;p&gt;With new variables &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$y_i \leq M \cdot z_i \quad \text{for } i = 1, 2, 3, 4$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i=1}^{4} z_i \leq 2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is it correct? If yes, what would be a good value for &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="500" LastEditDate="2024-03-10T14:56:28.023" LastActivityDate="2024-03-10T14:56:28.023" Title="Modelling L-0 norm of a vector" Tags="|optimization|mixed-integer-programming|combinatorial-optimization|binary-variable|big-m|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11791" PostTypeId="2" ParentId="11790" CreationDate="2024-03-10T14:29:31.547" Score="3" Body="&lt;p&gt;Yes, this is correct and is the standard approach. You want &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to be a small upper bound on the left hand side when &lt;span class=&quot;math-container&quot;&gt;$z_i=1$&lt;/span&gt;, so take &lt;span class=&quot;math-container&quot;&gt;$M$&lt;/span&gt; to be the number of &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; variables on the right hand side of the equality constraint for &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt;. In your example, that would be &lt;span class=&quot;math-container&quot;&gt;$M=1000$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; does not appear anywhere else in your model, you can eliminate it by substitution, yielding constraints of the form &lt;span class=&quot;math-container&quot;&gt;$\sum_j x_j \le M z_i$&lt;/span&gt;, which you can optionally strengthen by disaggregating to &lt;span class=&quot;math-container&quot;&gt;$x_j \le z_i$&lt;/span&gt;.  The resulting formulation is essentially the same as in &lt;a href=&quot;https://or.stackexchange.com/a/11785/500&quot;&gt;https://or.stackexchange.com/a/11785/500&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-03-10T14:36:38.880" LastActivityDate="2024-03-10T14:36:38.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11792" PostTypeId="1" CreationDate="2024-03-10T14:55:30.817" Score="1" ViewCount="61" Body="&lt;p&gt;we are currently learning about MIP/MILP minimization at university and have become familiar with the branch-and-bound algorithm. Unfortunately, the relationship between upper bound, lower bound and dual bound (as shown &lt;a href=&quot;https://support.gurobi.com/hc/en-us/articles/8265539575953-What-is-the-MIPGap&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;) is not clear to me, nor what the optimality gap is, or when a MIP can be solved optimally.&lt;/p&gt;&#xA;" OwnerUserId="13311" LastEditorUserId="500" LastEditDate="2024-03-10T15:02:34.683" LastActivityDate="2024-03-10T15:22:09.837" Title="Connections between Bounds in MIPs" Tags="|mixed-integer-programming|linear-programming|integer-programming|branch-and-bound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11793" PostTypeId="2" ParentId="11792" CreationDate="2024-03-10T15:11:09.313" Score="4" Body="&lt;p&gt;For a minimization problem, the &lt;strong&gt;lower&lt;/strong&gt; bound arises from the linear programming relaxation and is also called a &lt;em&gt;dual bound&lt;/em&gt;, and the &lt;strong&gt;upper&lt;/strong&gt; bound arises from a feasible solution and is also called a &lt;em&gt;primal bound&lt;/em&gt;.  That situation matches the linked picture.&lt;/p&gt;&#xA;&lt;p&gt;For a maximization problem, the &lt;strong&gt;upper&lt;/strong&gt; bound arises from the linear programming relaxation and is also called a &lt;em&gt;dual bound&lt;/em&gt;, and the &lt;strong&gt;lower&lt;/strong&gt; bound arises from a feasible solution and is also called a &lt;em&gt;primal bound&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The definition of optimality gap varies by solver and can be confusing to interpret when the bounds have opposite sign, but the general metric is a nonnegative ratio:&#xA;&lt;span class=&quot;math-container&quot;&gt;$$\frac{\text{upper bound} - \text{lower bound}}{\epsilon+\text{absolute value of either lower bound or upper bound}},$$&lt;/span&gt;&#xA;where &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; is a small positive constant to avoid division by &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt;.  The idea is that the gap decreases to &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; as the solver finds better bounds, so it is a measure of progress toward optimally solving the problem.  Most solvers allow you to set an optimality tolerance as a termination criterion so the solver will stop when it finds a feasible solution that is provably within that optimality gap.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-03-10T15:22:09.837" LastActivityDate="2024-03-10T15:22:09.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11794" PostTypeId="1" CreationDate="2024-03-10T22:19:30.743" Score="2" ViewCount="61" Body="&lt;p&gt;I have read several times now that with a column generation approach in the subproblem you do not necessarily have to look for the column with the lowest negative reduced cost, but only one with negative reduced costs. And that it is often worthwhile to add several columns with negative reduced costs to the master problem. I am now wondering if there is a guideline on how many to add and how to find several of these reduced columns at once&lt;/p&gt;&#xA;" OwnerUserId="11884" LastActivityDate="2024-03-13T11:35:36.267" Title="Add multiple columns to the Master Problem in a column generation approach" Tags="|column-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11795" PostTypeId="1" CreationDate="2024-03-11T08:57:02.093" Score="2" ViewCount="56" Body="&lt;p&gt;As I understand it, &amp;quot;approximating&amp;quot; a convex program usually refers to finding a solution that is &lt;em&gt;approximately-feasible&lt;/em&gt; approximately-optimal.&lt;/p&gt;&#xA;&lt;p&gt;For example, in the book &amp;quot;&lt;a href=&quot;https://link.springer.com/book/10.1007/978-3-642-78240-4&quot; rel=&quot;nofollow noreferrer&quot;&gt;Geometric Algorithms and Combinatorial Optimization&lt;/a&gt;&amp;quot; by Grötschel, Lovász and Schrijver the &lt;em&gt;strong optimization problem&lt;/em&gt; is defined as follows (page 47):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Given a vective &lt;span class=&quot;math-container&quot;&gt;$c \in \mathbb{R}^n$&lt;/span&gt;, find a vector &lt;span class=&quot;math-container&quot;&gt;$y \in K$&lt;/span&gt; that maximizes &lt;span class=&quot;math-container&quot;&gt;$c^Tx$&lt;/span&gt; on &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;, or assert that &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; is empty.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;while the &lt;em&gt;weak optimization problem&lt;/em&gt; is defined as follows (page 50):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Given a vector &lt;span class=&quot;math-container&quot;&gt;$c \in \mathbb{Q}^n$&lt;/span&gt; and a rational number &lt;span class=&quot;math-container&quot;&gt;$\epsilon &amp;gt;0$&lt;/span&gt; either&lt;/p&gt;&#xA;&lt;p&gt;(i) find a vector &lt;span class=&quot;math-container&quot;&gt;$y \in \mathbb{Q}^n$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$y \in S(K,\epsilon)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$c^Tx \leq c^T y + \epsilon$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$x \in S(K, - \epsilon)$&lt;/span&gt;&#xA;(i.e., &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; is almost in &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; and almost maximizes &lt;span class=&quot;math-container&quot;&gt;$c^Tx$&lt;/span&gt; over the points deep in &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;), or&lt;/p&gt;&#xA;&lt;p&gt;(ii) assert that &lt;span class=&quot;math-container&quot;&gt;$S(K, - \epsilon)$&lt;/span&gt; is empty.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;[where &lt;span class=&quot;math-container&quot;&gt;$S(K,\epsilon) = \{x \in \mathbb{R}^n \mid ||x-y|| \leq \epsilon \text{ for some } y \in K\}$&lt;/span&gt; is called the ball of radius &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt; around &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$S(K, -\epsilon) = \{x \in K \mid S(x, \epsilon) \subseteq K\}$&lt;/span&gt; is called the interior &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-ball of &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; (page 6)]&lt;/p&gt;&#xA;&lt;p&gt;Another example can be found in the book &amp;quot;&lt;a href=&quot;https://www2.isye.gatech.edu/%7Enemirovs/Lect_IPM.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Interior point polynomial time methods in convex programming&lt;/a&gt;&amp;quot; by Nemirovski, in which a family of convex programs of the following form is considered (page 11):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*} maximize \quad f(x) \quad s.t. \quad g_j(x) \leq 0,&#xA; \quad i = 1,\ldots, m, \quad x \in G \end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;And it seems that the goal is to find an &lt;span class=&quot;math-container&quot;&gt;$\epsilon$&lt;/span&gt;-solution to the problem that is defined as any &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt; that satisfies the following (page 11):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*} f(x_i) - f^* \leq \epsilon, \quad g_j(x_i) \leq&#xA; \epsilon, \quad i = 1,\ldots, m, \quad x_i \in G \end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;where &lt;span class=&quot;math-container&quot;&gt;$f^*$&lt;/span&gt; is the optimal objective value.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;My question is:&lt;/p&gt;&#xA;&lt;p&gt;Are there any general special cases for the domain &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt; in which the strong optimization problem is NP-hard but there is a polynomial time algorithm that achieves a &amp;quot;regular&amp;quot; approximation --- that is, an algorithm that finds a (feasible) solution &lt;span class=&quot;math-container&quot;&gt;$x \in K$&lt;/span&gt; with approximatly-optimal objective value?&lt;/p&gt;&#xA;" OwnerUserId="9927" LastEditorUserId="9927" LastEditDate="2024-03-14T06:48:53.847" LastActivityDate="2024-03-14T06:48:53.847" Title="Approximating a convex program" Tags="|optimization|convex-optimization|approximation-algorithms|approximation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11796" PostTypeId="1" AcceptedAnswerId="11797" CreationDate="2024-03-11T12:35:37.893" Score="0" ViewCount="46" Body="&lt;p&gt;I have an QP optimization problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bf x$&lt;/span&gt; is the binary optimizaion variable of size &lt;span class=&quot;math-container&quot;&gt;$12\times 1$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;One of the constraints is non-linear/non-convex.&lt;/p&gt;&#xA;&lt;p&gt;The constraint is L0 constraint.&lt;/p&gt;&#xA;&lt;p&gt;The constraint I have is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$[{\bf Ux}]_{l0}\le 2$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;here &lt;span class=&quot;math-container&quot;&gt;${l0}$&lt;/span&gt; denotes the L0 norm of the resulting vector.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\bf U$&lt;/span&gt; is given by&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{bmatrix}&#xA;1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0\\&#xA;0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0\\&#xA;0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1&#xA;\end{bmatrix}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We can linearize the constraint by introducing new variables and adding big_M constraints.&lt;/p&gt;&#xA;&lt;p&gt;But I need some solution that does not introduce new variables, but uses the matrix &lt;span class=&quot;math-container&quot;&gt;$\bf U$&lt;/span&gt; structure.&lt;/p&gt;&#xA;&lt;p&gt;RobPratt gave some solution here...https://or.stackexchange.com/questions/11784/how-to-model-this-constraint-for-a-qp-problem/11785#11785&lt;/p&gt;&#xA;&lt;p&gt;How can we model this particular constraint?&lt;/p&gt;&#xA;&lt;p&gt;Can we define some Matrix that utilizes the characteristics of &lt;span class=&quot;math-container&quot;&gt;$\bf U$&lt;/span&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Any solution?&lt;/p&gt;&#xA;" OwnerUserId="836" LastEditorUserId="500" LastEditDate="2024-03-11T13:49:14.340" LastActivityDate="2024-03-11T14:15:00.250" Title="How to linearize this L0 norm of a vector?" Tags="|optimization|mixed-integer-programming|linearization|combinatorial-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11797" PostTypeId="2" ParentId="11796" CreationDate="2024-03-11T13:48:09.873" Score="4" Body="&lt;p&gt;For each &lt;span class=&quot;math-container&quot;&gt;$3$&lt;/span&gt;-subset &lt;span class=&quot;math-container&quot;&gt;$\{x_i,x_j,x_k\}$&lt;/span&gt; of variables that appear in three different rows, you want to enforce &lt;span class=&quot;math-container&quot;&gt;$$\lnot(x_i \land x_j \land x_k).$$&lt;/span&gt;  As in the linked answer, conjunctive normal form yields (&lt;span class=&quot;math-container&quot;&gt;$4^3=64$&lt;/span&gt;) linear constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;$$x_i + x_j + x_k \le 2.$$&lt;/span&gt;&#xA;PORTA verifies that this formulation (including the bounds on &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt;) is ideal.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-03-11T14:15:00.250" LastActivityDate="2024-03-11T14:15:00.250" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11798" PostTypeId="1" CreationDate="2024-03-11T18:17:56.957" Score="2" ViewCount="124" Body="&lt;p&gt;I will start an optimization project in a bottlenecked bottling and filling line of a brewery. The goal is to produce the maximum number of cans and bottles of beer with minimum downtime and slowdowns. My managers want this project to be done with a combination of AI + Optimization, according to them, this artificial intelligence system should constantly update its decisions and plan according to the data coming from MES, IoT, ERP and dynamically optimize the process itself without leaving the optimization to planners and operators. I guess classical optimization and machine learning methods will not work here, but I can't think of any other method other than Reinforcement Learning. I am waiting for your recommendations.&lt;/p&gt;&#xA;" OwnerUserId="13315" LastActivityDate="2024-03-12T23:53:32.750" Title="AI based Optimization" Tags="|reinforcement-learning|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11799" PostTypeId="2" ParentId="11798" CreationDate="2024-03-12T08:28:30.770" Score="1" Body="&lt;p&gt;Before you can decide the solution for a problem, you need to have a good understanding of the problem.&lt;/p&gt;&#xA;&lt;p&gt;When you understand the problem better, it is much easier to see which approaches can work and then weigh them against each other to find the one best suited.&lt;/p&gt;&#xA;&lt;p&gt;Here is an approach you can use:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;1. Formulate a clear problem description&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What are the decisions you need to impact?&lt;/li&gt;&#xA;&lt;li&gt;What are the constraints around them?&lt;/li&gt;&#xA;&lt;li&gt;How often can you change decisions?&lt;/li&gt;&#xA;&lt;li&gt;What is driving the data updates that require decisions to be changed?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;2. Collect data&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do you have all the data needed?&lt;/li&gt;&#xA;&lt;li&gt;What is the quality of the data?&lt;/li&gt;&#xA;&lt;li&gt;Is there data available at the right time or do you need to predict some of it?&lt;/li&gt;&#xA;&lt;li&gt;How often will data be updated?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;3. Define requirements for solution method&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Who will use the solution?&lt;/li&gt;&#xA;&lt;li&gt;How big will the problem be?&lt;/li&gt;&#xA;&lt;li&gt;How often will it need to run?&lt;/li&gt;&#xA;&lt;li&gt;How will it be used? Should someone be able to overwrite decisions?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;4. Evaluate solution methods&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Come in with a fresh mind (including your managers). When you have a common understanding of the problem it is much easier to discuss the pros and cons. Then, you can decide if classical optimization and machine learning methods might be a better fit than, e.g., reinforcement learning.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;5. Start small and be agile&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Building a full system that continuously updates from various sources and directly makes changes is complicated. Consider how you can build a minimum version (proof-of-concept / Minimum-viable-product). This will also help you learn about the problem and the requirements for the solution. The biggest challenge is often around data collection and processing, so I wouldn't be too concerned about picking the &amp;quot;wrong&amp;quot; optimization method as it is easy to change when you have the data. It might make sense to start with something super simple (e.g. like a greedy heuristic), that is more similar to how the problem is being solved today. Then you have a baseline to improve from.&lt;/p&gt;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="140" LastActivityDate="2024-03-12T08:28:30.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11800" PostTypeId="2" ParentId="11795" CreationDate="2024-03-12T21:16:19.117" Score="0" Body="&lt;p&gt;Basically &lt;span class=&quot;math-container&quot;&gt;$S(K, \epsilon) = K + \epsilon  B$&lt;/span&gt;. Thus optimizing a function on  &lt;span class=&quot;math-container&quot;&gt;$S(K, \epsilon)$&lt;/span&gt; is not easier than optimization over &lt;span class=&quot;math-container&quot;&gt;$K$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Those approximate optimality definitions are used to measure the suboptimality of the solution that comes out of an algorithm. For instance, if you solve an optimization problem using a penalty method, the solution that you stop at is likely not optimal, in most cases not even feasible. So what can you say about the quality of this solution which is not even feasible? One way to describe their quality is by using approximated definitions.&lt;/p&gt;&#xA;" OwnerUserId="11566" LastActivityDate="2024-03-12T21:16:19.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11801" PostTypeId="2" ParentId="11798" CreationDate="2024-03-12T23:53:32.750" Score="0" Body="&lt;p&gt;To add to @Michael Lindahl's answer one classic area of combination of ML/MO (Machine learning &amp;amp; mathematical optimization) is ML enumerates the functions for the objective while MO performs the mini/maximization or closes the gap with a target. ML may also help in identifying influencing parameters or their values, like feature engineering.&lt;/p&gt;&#xA;&lt;p&gt;AI comes in handy when defining constraints - like based on rewards/low risk-&#xA;-what should be the RHS value for a constraint?&#xA;-does the constraint need to be binding?&#xA;-Are any of the constraints complementary to each other (Complementarity)&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2024-03-12T23:53:32.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11802" PostTypeId="1" CreationDate="2024-03-13T06:37:18.590" Score="2" ViewCount="28" Body="&lt;p&gt;I am working on a multi-commodity flow problem to conduct tactical harvesting planning. The idea is to model the crop and the machinery as commodities. Crop move from field to being harvested and harvesters move between depot and fields. The flow and cost of the crop is dependent on the integer flow of the machinery. I present a more formal description of the problem below. I am trying to figure out a way to model this problem and appreciate any help. In this regard, I have two questions regarding the problem:&lt;/p&gt;&#xA;&lt;p&gt; 1. How do you call the network problem I describe when commodity flows are interdependent and used to plan sequential commodity flow? In addition, how do you call it when adding more &amp;quot;stages&amp;quot; e.g. transportation from field to factory?&lt;/p&gt;&#xA;&lt;p&gt; &#xA; 2. How do I define the harvester flow in a way that harvesters move correctly and efficiently through the network? (I have problems in setting the harvesters up, make them move, meeting the demand constraint, while complying with the crop flow.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Model Formulation:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;For a basic multi-commodity flow formulation of the crop harvesting problem, suppose the two commodities are beets and harvesters. The beets are given as &lt;span class=&quot;math-container&quot;&gt;$b_{irrt}$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$r\in \{f,h\}$&lt;/span&gt; with &lt;span class=&quot;math-container&quot;&gt;$f$&lt;/span&gt; for on the field, &lt;span class=&quot;math-container&quot;&gt;$h$&lt;/span&gt; for harvested, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; indicates the field and &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt; the time-period. We assume &lt;span class=&quot;math-container&quot;&gt;$b_{iff0}$&lt;/span&gt; is the given total quantity on field &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$b_{irr0}=0$&lt;/span&gt; for all other &lt;span class=&quot;math-container&quot;&gt;$irr$&lt;/span&gt;. The harvester flows are given as &lt;span class=&quot;math-container&quot;&gt;$h_{ijt}$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt; for beginning and ending locations (can include) &lt;span class=&quot;math-container&quot;&gt;$i=j$&lt;/span&gt; at time &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;. Harvesters start moving from a depot. &lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Objective Function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Suppose the operating costs are &lt;span class=&quot;math-container&quot;&gt;$c^h_{ij}$&lt;/span&gt; and harvester movement &lt;span class=&quot;math-container&quot;&gt;$h^h_{ijt}$&lt;/span&gt;, then the deterministic model is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{equation}\label{obj}&#xA;\min \sum_{t=1}^T\sum_{i}\sum_j\ \sum_{h}c^h_{ijt} h^h_{ijt}&#xA;\end{equation}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Crop Flow&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;  b_{ifft} &amp;amp;=&amp;amp; b_{iff,t-1}-b_{ifht}, \label{eq1}\\&#xA;  b_{ihht} &amp;amp;=&amp;amp; b_{ihh,t-1}+b_{ifht}. \label{eq2}\\&#xA;\end{eqnarray}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Harvester Flow&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Suppose the depot is at position 0. Then all harvesters starting at the depot is given by:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;   h_{000} &amp;amp;=&amp;amp; 1 \label{eq3}&#xA;\end{eqnarray}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;All harvesters leave to one field at &lt;span class=&quot;math-container&quot;&gt;$t=1$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;  \sum_{i} h_{0i1} &amp;amp;=&amp;amp; 1 \label{eq4}&#xA;\end{eqnarray}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Demand Constraint&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In total, we need at least &lt;span class=&quot;math-container&quot;&gt;$D$&lt;/span&gt; harvested beets per &lt;span class=&quot;math-container&quot;&gt;$t$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;  \sum_{i \in I} b_{ifht} &amp;amp;\geq&amp;amp; D \quad \forall t &amp;gt; 1 \label{eq5}&#xA;\end{eqnarray}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Relationships Between Commodities&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The commodities are related by the following constraints where &lt;span class=&quot;math-container&quot;&gt;$\bar{H}_i$&lt;/span&gt; is the max harvesting rate of a harvester.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{eqnarray}&#xA;% \nonumber to remove numbering (before each equation)&#xA; b_{ifht} &amp;amp;=&amp;amp; \bar{H}h_{iit}\label{eq6} &#xA;\end{eqnarray}&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="13320" LastEditorUserId="491" LastEditDate="2024-03-13T12:57:45.713" LastActivityDate="2024-03-13T12:57:45.713" Title="How to formulate / solve a multi-commodity flow problem with dependent flow between commodities to plan harvesting operations" Tags="|network-flow|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11803" PostTypeId="1" CreationDate="2024-03-13T07:09:05.643" Score="5" ViewCount="287" Body="&lt;p&gt;I came across the term &amp;quot;Delayed Column Generation&amp;quot; yesterday and am wondering how this differs from classic Column Generation, or whether the terms are used synonymously.&lt;/p&gt;&#xA;" OwnerUserId="11967" LastActivityDate="2024-03-14T13:00:51.810" Title="What is delayed column generation?" Tags="|column-generation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11804" PostTypeId="2" ParentId="11794" CreationDate="2024-03-13T11:35:36.267" Score="2" Body="&lt;p&gt;Usually, you should add as many columns as you can generate. It is better if columns are diversified, i.e., &amp;quot;cover&amp;quot; different constraints in the master. The best is to add sets of columns forming a complete solution of your problem, but this may be tricky to do and/or more time-consuming. Also, when you add many columns, you should definitely clean up master from non-promising columns, for example those with a high reduced cost.&lt;/p&gt;&#xA;&lt;p&gt;The question how to generate many columns is problem-dependent, and this may be a research question for new problems. For example, if your pricing problem is solved by dynamic programming (DP), one way is to apply bidirectional search, thus you will have a lot of candidates when you perform the concatenation phase of the DP algorithm. In this view, solving the pricing problem by a MIP solver is not usually a good choice, partly because MIP solvers will not give you a lot of solutions.&lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2024-03-13T11:35:36.267" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11805" PostTypeId="2" ParentId="11803" CreationDate="2024-03-13T13:23:09.757" Score="6" Body="&lt;p&gt;To my knowledge, originally &amp;quot;column generation&amp;quot; meant &amp;quot;adding columns to the simplex tableau by inspection of available variables which are all explicitly available.&amp;quot; This was a special implementation of the simplex algorithm to deal with the limited memory in old computers. &amp;quot;Delayed column generation&amp;quot; means that not all variables (columns) are available from the start and their generation is delayed. The original column generation approach is probably not used at all nowadays, so people use the term &amp;quot;column generation&amp;quot; as a shortcut for &amp;quot;delayed column generation&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="835" LastEditorUserId="12415" LastEditDate="2024-03-14T13:00:51.810" LastActivityDate="2024-03-14T13:00:51.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11806" PostTypeId="1" CreationDate="2024-03-14T05:28:48.760" Score="0" ViewCount="36" Body="&lt;p&gt;This is an extention to the workforce scheduling problem discussed in this thread &lt;a href=&quot;https://or.stackexchange.com/questions/11279/workforce-scheduling-problem/11280?noredirect=1#comment25090_11280&quot;&gt;Workforce scheduling problem&lt;/a&gt;. Adding a new post to discuss an important new requirement in this model. So the new constraint is as follows: for a given worker, they can work multiple consecutive shifts (with min and max daily hours limits) where each shift has a different role (for example a worker can work 10am-12pm as cashier, then noon to 3 as a manager, 3pm to 5pm as a barista, and so on). After getting an excellent advice from @RobPratt, I tried to formulate oneshiftperday as a network formulation problem. I am trying to extend this to the new requirement of multiple shifts per day and I could model the consecutive and K shift per day requirement but am struggling with all distinct roles.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to model this without adding too many mutual exclusivity side constraints?&lt;/p&gt;&#xA;" OwnerUserId="12862" LastEditorUserId="491" LastEditDate="2024-03-14T17:38:41.880" LastActivityDate="2024-03-14T18:54:42.587" Title="multiple shifts per day constraint for a workforce scheduling problem" Tags="|mixed-integer-programming|scheduling|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11807" PostTypeId="1" CreationDate="2024-03-14T18:06:12.577" Score="0" ViewCount="70" Body="&lt;p&gt;Good afternoon.&#xA;I have a very difficult to a MIP model. I have tried several different strategies to reduce the gap. I am using Gurobi and in this case, I already have an incumbent solution.&#xA;I've set &amp;quot;Cuts&amp;quot; to 3 (aggressive cut generation), &amp;quot;heuristics&amp;quot; to 0.5, (50% of the time for heuristics) and &amp;quot;MIPfocus&amp;quot; to focus on optimality.&#xA;Do you have any suggestions for other parameters I can change to alter this performance?&#xA;Below is gurobi's report for this problem (here I set a maximum time of 180 seconds, but this behaviour would be identical if I left it for 2,3,4 hours).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Academic license - for non-commercial use only - expires 2024-12-10&#xA;Gurobi Optimizer version 9.1.1 build v9.1.1rc0 (win64)&#xA;Thread count: 6 physical cores, 12 logical processors, using up to 12 threads&#xA;Optimize a model with 16566 rows, 109106 columns and 635490 nonzeros&#xA;Model fingerprint: 0xea69df7b&#xA;Variable types: 108002 continuous, 1104 integer (1104 binary)&#xA;Coefficient statistics:&#xA;  Matrix range     [7e-02, 2e+05]&#xA;  Objective range  [1e+00, 1e+00]&#xA;  Bounds range     [1e+00, 1e+00]&#xA;  RHS range        [1e+00, 3e+04]&#xA;&#xA;User MIP start produced solution with objective 937.846 (0.09s)&#xA;Loaded user MIP start with objective 937.846&#xA;&#xA;Presolve removed 6649 rows and 6530 columns&#xA;Presolve time: 0.60s&#xA;Presolved: 9917 rows, 102576 columns, 386928 nonzeros&#xA;Variable types: 102000 continuous, 576 integer (576 binary)&#xA;&#xA;Root relaxation: objective 5.272822e+02, 16932 iterations, 0.65 seconds&#xA;Total elapsed time = 5.30s&#xA;&#xA;    Nodes    |    Current Node    |     Objective Bounds      |     Work&#xA; Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time&#xA;&#xA;     0     0  527.28222    0   95  937.84556  527.28222  43.8%     -    6s&#xA;     0     0  527.28222    0  277  937.84556  527.28222  43.8%     -   17s&#xA;     0     0  527.28222    0  310  937.84556  527.28222  43.8%     -   32s&#xA;     0     0  527.28222    0  339  937.84556  527.28222  43.8%     -   87s&#xA;     0     0  527.28222    0  339  937.84556  527.28222  43.8%     -  102s&#xA;     0     2  527.28222    0  339  937.84556  527.28222  43.8%     -  159s&#xA;     1     4  527.28222    1  335  937.84556  527.28222  43.8% 33460  165s&#xA;&#xA;Cutting planes:&#xA;  Implied bound: 1713&#xA;  MIR: 644&#xA;  Flow cover: 1300&#xA;  Relax-and-lift: 43&#xA;&#xA;Explored 3 nodes (174099 simplex iterations) in 180.04 seconds&#xA;Thread count was 12 (of 12 available processors)&#xA;&#xA;Solution count 1: 937.846&#xA;&#xA;Time limit reached&#xA;Best objective 9.378455555555e+02, best bound 5.272822222221e+02, gap 43.7773%&#xA;&#xA;User-callback calls 4853, time in user-callback 0.00 sec&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The model is presented below: We need to localize supliers (z1) and (z2), the facilities (yr and yu) and the flux between the supliers and facilities (u's) and from facilities to clients (x's), allowing delays, over the scenario s.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/AoH3d.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AoH3d.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4760" LastEditorUserId="67" LastEditDate="2024-03-15T03:09:31.320" LastActivityDate="2024-03-15T03:09:31.320" Title="Improving the lower bound" Tags="|mixed-integer-programming|integer-programming|gurobi|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="11808" PostTypeId="2" ParentId="11806" CreationDate="2024-03-14T18:54:42.587" Score="2" Body="&lt;p&gt;For the requirement that the roles performed by a single worker in a day must be distinct, here are two alternative approaches. One way is to augment the node definitions to include all roles that have been active so far that day. So in your example you would also have s3c and s3m nodes to indicate that the previous role was cashier or manager. Another way is to have a node for each possible shift combination in a day, so your s1-&amp;gt;s3-&amp;gt;s5 sequence would be a single node, and s2-&amp;gt;s3-&amp;gt;s4 would be another node.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2024-03-14T18:54:42.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11809" PostTypeId="1" CreationDate="2024-03-14T19:51:03.717" Score="0" ViewCount="38" Body="&lt;p&gt;In multiobjective optimization, by using exact methods, we need to find the set of efficient solutions in the decision space or the set of non-dominated solutions in the criteria space. So, we must provide a set of several solutions for the decision maker (which can be 100, 1000 or even more) which is not efficient for the decision maker. Another approach was proposed, is to fix a new objective function which we must optimize on the set of efficient solutions. This approach provide one efficient solutions depending on the added objective function. This approach is also biaised directly by the added objective function and is not necessary giving a good solution if the added solution is not good enough or it deberatly miss some directions.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My question:&lt;/strong&gt; Is there another approach where we can provide a subset of the efficient solutions set (we can say 3 to 5 solutions max) that take in consideration all the criteria but without providing all the efficient set.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Propositions:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Using metaheuristics to get efficient solutions: This is not a good approach because we will not be sure if the provided solution is efficient.&lt;/li&gt;&#xA;&lt;li&gt;Using exact approach to get 3 to 5 efficent solutions then stop: This is a possible alternative but we will never know if is there another efficient solution which may be better for the decision maker.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;What I search is an approach that provide a subset of the efficient solutions but it will take the other efficient solutions in consideration, and this subset can be seen as an representative of the efficicent solutions set.&lt;/p&gt;&#xA;" OwnerUserId="13295" LastActivityDate="2024-03-14T20:41:20.233" Title="New considerations for efficient solutions in multiobjective optimization" Tags="|multi-objective-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11810" PostTypeId="2" ParentId="11809" CreationDate="2024-03-14T20:41:20.233" Score="1" Body="&lt;p&gt;Years ago two of my colleagues proposed an interactive approach. (This was for LPs, but should generalize to MIPs.) It requires reasonably fast solution time for the model. The gist was to optimize a weighted combination of objective functions, show the solution to the decision maker, and ask if they were happy with it. If the expressed a desire for a better outcome on some criterion, you asked them what the would be willing to trade (for instance, allow an extra 30 minutes of production time to save $100 in production cost), used that information to adjust the objective weights, solved again, and asked the decision maker about the new solution. The process repeated until the decision maker was satisfied (or exhausted, which I suspect would be the more frequent outcome).&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-03-14T20:41:20.233" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11813" PostTypeId="1" AcceptedAnswerId="11818" CreationDate="2024-03-15T14:21:18.583" Score="2" ViewCount="57" Body="&lt;p&gt;I've been working on solving a stochastic vehicle routing problem using Benders' decomposition with CPLEX in C++. Initially, my implementation struggled with larger instances, but I've made significant progress by implementing enhancement strategies such as reformulation of the subproblems according to &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-010-0365-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fischetti et al.&lt;/a&gt; (2010) and partial Benders' decomposition as described by &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.2020.1022&quot; rel=&quot;nofollow noreferrer&quot;&gt;Crainic et al.&lt;/a&gt; (2021).&lt;/p&gt;&#xA;&lt;p&gt;However, I've encountered a bottleneck in my approach. When using partial Benders' decomposition, the master problem becomes complex, leading to longer solve times of the CPLEX solver for each iteration of the master problem. On the other hand, if I don't use partial Benders' decomposition, the master problem lacks scenario information, resulting in a high number of feasibility cuts and iterations, until feasible solutions are found.&lt;/p&gt;&#xA;&lt;p&gt;In general, the one with partial Benders' decomposition seems more promising though, having better performance so far. The only problem is, due to the exponential complexity of VRPs, it reaches a threshold where it needs 20–30 minutes to solve each master problem instead of seconds, like before.&lt;/p&gt;&#xA;&lt;p&gt;I'm seeking advice on how to overcome this issue. Has anyone faced a similar problem? At this point, small improvements would be enough for our practical use case, since I am not far off the instance sizes that we aim to solve.&lt;/p&gt;&#xA;&lt;p&gt;Since with partial Benders' decomposition, the solver taking too long to solve the master problem is the bottleneck, could maybe Gurobi work better? Or are there general methods to speed up the solver?&lt;/p&gt;&#xA;&lt;p&gt;Fischetti et al. (2010): &lt;a href=&quot;https://link.springer.com/article/10.1007/s10107-010-0365-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://link.springer.com/article/10.1007/s10107-010-0365-7&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Crainic et al. (2021): &lt;a href=&quot;https://pubsonline.informs.org/doi/abs/10.1287/trsc.2020.1022&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pubsonline.informs.org/doi/abs/10.1287/trsc.2020.1022&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12130" LastEditorUserId="491" LastEditDate="2024-03-15T14:29:53.900" LastActivityDate="2024-03-16T20:36:36.390" Title="How to deal with performance bottlenecks in Stochastic Vehicle Routing Problem with Benders' decomposition?" Tags="|mixed-integer-programming|cplex|stochastic-programming|benders-decomposition|c++|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11814" PostTypeId="1" CreationDate="2024-03-15T16:06:06.497" Score="1" ViewCount="41" Body="&lt;p&gt;What type of algorithm should I be researching to solve the following problem?&lt;/p&gt;&#xA;&lt;p&gt;Each node has a potential that is a function (linear or non linear) of the net flow in/out of that node.&lt;/p&gt;&#xA;&lt;p&gt;Nodes are connected by a directed graph.&lt;/p&gt;&#xA;&lt;p&gt;The objective is to minimize the differential across all nodes.&lt;/p&gt;&#xA;&lt;p&gt;As a new comer to OR I feel this should be a common problem but have struggled to find an example in the literature. It feels somewhere close to a min cost problem, but there is no cost applied on the flows along the arcs.&lt;/p&gt;&#xA;" OwnerUserId="4903" LastEditorUserId="491" LastEditDate="2024-03-15T19:20:45.043" LastActivityDate="2024-03-15T19:20:45.043" Title="Network flow problem to minimize differences between nodes" Tags="|network-flow|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="11815" PostTypeId="1" CreationDate="2024-03-16T08:24:37.100" Score="2" ViewCount="107" Body="&lt;p&gt;I have been busy the last few weeks implementing &lt;a href=&quot;https://or.stackexchange.com/questions/11608/how-to-modify-master-problem-and-individual-sub-problems-in-column-generation/11620&quot;&gt;this model&lt;/a&gt; with Column Generation in Gurobi and then solving it. The whole thing is now working quite well and I have also run a few calculation studies and noticed the following. It should be noted that I did the whole thing for a more complex model than shown in the post. I noticed two things.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;In about 65% of the cases, the model delivers an optimal solution. The optimality gap of the non-optimal solutions is about 2% on average.&lt;/li&gt;&#xA;&lt;li&gt;The runtime improvements are sometimes very high. In some cases, a model instance that can be solved with the normal solver in one hour can be solved in less than one minute. The median of the time improvements is about a 20-fold time improvement.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Now to my question. How can the algorithm be improved, especially with regard to the optimality gap, without having to implement branch-n-price? Are there other ways to improve the runtime? In this context, I noticed in my computational study that, as with all other column generation approaches, convergence is very slow at the higher iterations (I add columns in my model where the reduced cost is &lt;span class=&quot;math-container&quot;&gt;$&amp;lt;10^{-6}$&lt;/span&gt;).&lt;/p&gt;&#xA;&lt;p&gt;I initially thought of dual price smoothing as a way out. In this context, I noticed that the non-negative dual values &lt;span class=&quot;math-container&quot;&gt;$\pi_{ds}$&lt;/span&gt; fluctuate greatly. They are either exactly &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; or very close to &lt;span class=&quot;math-container&quot;&gt;$\sim 1$&lt;/span&gt; or exactly &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt;, but never anything in between. The unrestricted dual values &lt;span class=&quot;math-container&quot;&gt;$\mu_i$&lt;/span&gt; are also subject to strong fluctuations, whereby they become more and more negative with each iteration. Based on this, I now use these smoothed dual values:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;    &amp;amp;\hat{\pi}_{ds}^t = (1-\alpha_1) \pi_{ds}^t +\alpha_1 \hat{\pi}_{ds}^{t-1}\label{smooth1}\\&#xA;    &amp;amp;\hat{\mu}_i^t = (1-\alpha_2) \mu_i^t + \alpha_2 \hat{\mu}_i^{t-1}\label{smooth2}&#xA;\end{align}&lt;/span&gt;&#xA;Which of course also changes the objective function of the subproblems &lt;span class=&quot;math-container&quot;&gt;$\mathcal{SP}(i)$&lt;/span&gt; accordingly. Unfortunately, I don't know exactly how to parameterise &lt;span class=&quot;math-container&quot;&gt;$\alpha_{1,2}$&lt;/span&gt;.&#xA;I have also thought about dual stabilisation, but there is also the problem of parameterisation.&#xA;Are there any other possibilities that might be easier to implement (possibly without parameterisation) that would improve the calculation time but also the quality of the solution?&lt;/p&gt;&#xA;&lt;p&gt;If you are interested in providing gurobi specific soutions I will gladly link my code.&lt;/p&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="136" LastEditDate="2024-03-17T05:07:20.483" LastActivityDate="2024-03-17T05:07:20.483" Title="How to improve a column generation algorithm" Tags="|duality|column-generation|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="11816" PostTypeId="1" AcceptedAnswerId="11817" CreationDate="2024-03-16T18:51:22.117" Score="1" ViewCount="59" Body="&lt;p&gt;Consider this example with set A={100,50,150}. Min value in this set is 50. How to find out that the index of 50 is 2 in this set?&#xA;I need 2 as the answer to put it in another constraint&lt;/p&gt;&#xA;" OwnerUserId="13331" LastEditorUserId="36" LastEditDate="2024-03-16T23:31:12.713" LastActivityDate="2024-03-16T23:31:12.713" Title="How to write a constraint to find the index of the min value in a set?" Tags="|linear-programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11817" PostTypeId="2" ParentId="11816" CreationDate="2024-03-16T20:26:37.183" Score="1" Body="&lt;p&gt;I think it likely would be an algorithmic way rather than being an optimization model. B.T.W, you can do what you want by the following MIP model:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{array}{l}&#xA;\text{Min} \ z = \sum_{i} A.val_i*x_i\\&#xA;\text{subject to:} \\&#xA;\sum_i x_i = 1\\&#xA;y_i = i .x_i \quad i=1, \ldots, m\\&#xA;x_{i} \in\{0,1\}, y_{i} \in \mathbb{Z}^+ \quad i\in m\\&#xA;\end{array}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;As a simple example, with your data, the results are:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;----     15 VARIABLE min_.L                =       50.000  &#xA;&#xA;----     15 VARIABLE x.L  &#xA;&#xA;50 1.000&#xA;&#xA;&#xA;----     15 VARIABLE y.L  &#xA;&#xA;50 2.000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="199" LastActivityDate="2024-03-16T20:26:37.183" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11818" PostTypeId="2" ParentId="11813" CreationDate="2024-03-16T20:36:36.390" Score="1" Body="&lt;p&gt;Calling cplex.solve() after modifying the model restarts the solver from the root node. Using callbacks would allow you to modify the model and then pick up from where you left off, so long as the changes to the model did not alter the feasibility of previously found incumbents.&lt;/p&gt;&#xA;&lt;p&gt;You can do Benders with either legacy or generic callbacks, but the newer generic callbacks are generally preferable (albeit a bit trickier to implement, due to thread safety concerns). I believe there's at least one Benders example shipping with CPLEX that uses callbacks, and I wrote a &lt;a href=&quot;https://orinanobworld.blogspot.com/2017/11/benders-decomposition-with-generic.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;blog post&lt;/a&gt; quite a while back providing an example (including Java source code). Using generic callbacks allows CPLEX to continue to use dynamic search (disabled when using legacy callbacks), which typically helps.&lt;/p&gt;&#xA;&lt;p&gt;If using the one tree approach (solve MP, solve subproblem, add cut(s), repeat), you might want to consider adding the Benders cuts as lazy constraints rather than standard constraints. It will allow CPLEX to set them aside if they have not been binding for a while, which might speed up the master solve if you are piling up zillions of cuts.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-03-16T20:36:36.390" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="11819" PostTypeId="2" ParentId="11815" CreationDate="2024-03-17T05:05:19.650" Score="2" Body="&lt;p&gt;An extremely simple thing that has worked for me in the past is the following. Instead of implementing &lt;a href=&quot;https://link.springer.com/chapter/10.1007/978-3-642-38527-8_31&quot; rel=&quot;nofollow noreferrer&quot;&gt;dual stabilisation explicitly&lt;/a&gt;, change a single solver parameter: &lt;strong&gt;use the Barrier instead of the Simplex algorithm&lt;/strong&gt; when solving the reduced relaxed master problem. When applied to the dual, it makes it much more likely that the optimal dual solution lies midface rather than on a vertex, performing some implicit dual stabilisation. Depending on the solver you use, you might also have to disable the crossover procedure explicitly. I cannot guarantee it works in all cases, but it takes no effort to implement, and, in a paper I am working on, it reduced the runtime from ~4600 seconds to 52 seconds on a class of instances. (On other classes, the improvements were more modest.)&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2024-03-17T05:05:19.650" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11820" PostTypeId="1" CreationDate="2024-03-17T06:30:59.677" Score="-2" ViewCount="79" Body="&lt;p&gt;At a computerized Rail Reservation window, the customer arrivals are considered to be Poisson with an average inter-arrival time of ten minutes. The railway clerk's time for serving the customer (examination of reservation slip, making reservation, collecting cash and issuing reservation ticket) may be assumed to be distributed negative exponentially with an average of 6 minutes.&lt;/p&gt;&#xA;&lt;p&gt;(a)What is the chance the customer will straightaway get a ticket without having to wait in line?&lt;/p&gt;&#xA;&lt;p&gt;(b)For what part of time will the railway clerk be busy?&lt;/p&gt;&#xA;&lt;p&gt;(c)Find the average queue  length, average number of customers in the system, average waiting time of a customer and the average time a customer spends in the system.&lt;/p&gt;&#xA;&lt;p&gt;(d)There is a complaint the waiting time of an arrival exceeds 45 minutes and an additional clerk is required. Determine how large the new arrival rate should be to justify a second clerk?&lt;/p&gt;&#xA;&lt;p&gt;How can we answer these questions? I am working on these questions. If any member knowing the correct answers to all of these question, may reply.&lt;/p&gt;&#xA;" OwnerUserId="13332" LastActivityDate="2024-03-19T03:07:55.073" Title="Queuing theory question" Tags="|queuing-theory|probability-distributions|" AnswerCount="1" CommentCount="3" ClosedDate="2024-03-28T22:14:52.907" ContentLicense="CC BY-SA 4.0" />
  <row Id="11821" PostTypeId="2" ParentId="11820" CreationDate="2024-03-18T01:34:09.820" Score="1" Body="&lt;p&gt;This is &lt;span class=&quot;math-container&quot;&gt;$\ M/M/1/\infty/\infty\ $&lt;/span&gt; queue model.&lt;/p&gt;&#xA;&lt;p&gt;The symbols in turn represent:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The distribution of the time between successive customer arrivals is negatively exponential&lt;/li&gt;&#xA;&lt;li&gt;The distribution of hours of service is negatively exponential&lt;/li&gt;&#xA;&lt;li&gt;Number of service desks is 1&lt;/li&gt;&#xA;&lt;li&gt;The system capacity limit is infinity&lt;/li&gt;&#xA;&lt;li&gt;The number of customer sources is infinity&lt;/li&gt;&#xA;&lt;li&gt;(Default) FCFS, first-come, first-served&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;Solution&lt;/h1&gt;&#xA;&lt;p&gt;Write &lt;span class=&quot;math-container&quot;&gt;$\rho=\lambda /\mu$&lt;/span&gt; for the utilization of the buffer.&lt;/p&gt;&#xA;&lt;p&gt;Assuming &lt;span class=&quot;math-container&quot;&gt;$\rho=\lambda /\mu&amp;lt;1$&lt;/span&gt; to ensure the convergence of the subsequent derivation.&lt;/p&gt;&#xA;&lt;p&gt;We have &lt;span class=&quot;math-container&quot;&gt;$\sum\limits_{i=0}^{\infty} \pi_i =1 \quad \text{     and  }\quad  \pi_i=\rho^i \pi_0\text{ for } i=1,2,\cdots  $&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$&#xA; \quad \text{     thus     }\quad \sum\limits_{i=0}^{\infty} \pi_0 \rho^i =1&#xA;$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The probability that the stationary process is in state &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; (contains &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; customers, including those in service) is &lt;span class=&quot;math-container&quot;&gt;$\pi_i = (1-\rho) \rho^i$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt; &lt;/p&gt;&#xA;&lt;p&gt;(a) The probability that the customer will straightaway get a ticket without having to wait in line, &lt;span class=&quot;math-container&quot;&gt;$\pi_0=1-\rho=1-\frac{\lambda}{\mu}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(b) For what part of time will the railway clerk be busy? &lt;span class=&quot;math-container&quot;&gt;$1-\pi_0=\frac{\lambda}{\mu}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(c)&lt;/p&gt;&#xA;&lt;p&gt;The average queue length, &lt;span class=&quot;math-container&quot;&gt;$L_q= \sum\limits_{n=c}^{\infty} (n-c)\pi_n = \sum\limits_{n=1}^{\infty} (n-1)\pi_n = \sum\limits_{n=1}^{\infty}(n-1) (1-\rho)\rho^n =\frac{{\rho}^2}{1-{\rho}}=\frac{\lambda ^2}{\mu (\mu -\lambda)}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The average number of customers in the system, &lt;span class=&quot;math-container&quot;&gt;$L_s=\sum\limits_{n=0}^{\infty} n \pi _n =  \sum\limits_{n=0}^{\infty} n (1-\rho) \rho^n=\frac{\rho}{1-\rho}=&#xA;  \frac{\lambda}{\mu -\lambda}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt; &#xA; &#xA; &#xA; &lt;/p&gt;&#xA;&lt;p&gt;The time &lt;span class=&quot;math-container&quot;&gt;$T$&lt;/span&gt; that a customer spends in the system, is distributed accroding to negatively&#xA;exponential distribution with parameter &lt;span class=&quot;math-container&quot;&gt;$\mu-\lambda$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;P(T&amp;gt;t) =e^{-(\mu-\lambda)t} , \quad t\geq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The average time a customer spends in the system, &lt;span class=&quot;math-container&quot;&gt;$W_s=\mathbb{E} [T]=\frac{1}{\mu-\lambda}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;The average waiting time of a customer, &lt;span class=&quot;math-container&quot;&gt;$W_q=W_s-\frac{1}{\mu}=  \frac{\lambda}{ \mu (\mu -\lambda)}$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;(d)&lt;/p&gt;&#xA;&lt;p&gt;MeanQueueSize of &lt;span class=&quot;math-container&quot;&gt;$M/M/c/\infty/\infty$&lt;/span&gt; is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;W_q=&#xA;\frac{c \lambda  \mu  \Gamma (c) \left(\frac{\lambda }{\mu }\right)^c}{c! e^{\lambda /\mu } (\lambda -c \mu )^2 \Gamma \left(c,\frac{\lambda }{\mu }\right)+c \mu  \Gamma (c) (c \mu -\lambda ) \left(\frac{\lambda }{\mu }\right)^c}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;When &lt;span class=&quot;math-container&quot;&gt;$c=2$&lt;/span&gt;, MeanQueueSize of &lt;span class=&quot;math-container&quot;&gt;$M/M/2/\infty/\infty$&lt;/span&gt; is&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;W_q=\frac{\lambda ^3}{4 \mu ^3-\lambda ^2 \mu }&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We want to solve the equation &lt;span class=&quot;math-container&quot;&gt;$W_q\operatorname{|}\limits_{\mu \rightarrow \frac{1}{6}}=45$&lt;/span&gt; for variable &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\[ScriptCapitalQ] = QueueingProcess[\[Lambda], \[Mu], 2];&#xA;\[Lambda] /. &#xA;  NSolve[QueueProperties[\[ScriptCapitalQ], &amp;quot;MeanQueueSize&amp;quot;] == &#xA;     45 /. {\[Mu] -&amp;gt; 1/6}, \[Lambda]] // Select[#, # &amp;gt; 0 &amp;amp;] &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The new arrival rate should be &lt;code&gt;0.32631 services per minute&lt;/code&gt; to justify a second clerk.&lt;/p&gt;&#xA;&lt;h1&gt;Mathematica code&lt;/h1&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://reference.wolfram.com/language/ref/QueueingProcess.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;some Mathematica APIs&lt;/a&gt; store the famous properties.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(* M/M/2/∞/∞ queue*)&#xA;\[ScriptCapitalQ] = QueueingProcess[\[Lambda], \[Mu], 2];&#xA;QueueProperties[\[ScriptCapitalQ]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12223" LastEditorUserId="12223" LastEditDate="2024-03-19T03:07:55.073" LastActivityDate="2024-03-19T03:07:55.073" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11823" PostTypeId="1" CreationDate="2024-03-18T11:44:12.797" Score="-1" ViewCount="40" Body="&lt;p&gt;I've made two model that are supposed to represent the same thing but written in two different way in IBM ILOG CPLEX (one in CP and the other in MILP with CPLEX).&lt;/p&gt;&#xA;&lt;p&gt;They give me different optimal value (both with optimal gap of 0) so I would like to know which constraint is not respected in one of the model&lt;/p&gt;&#xA;&lt;p&gt;They both output solution in the following way :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;alpha = [0 16 23 54 78];&#xA;beta = [1 0 1 0 0 0 0];&#xA;...&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;both models share almost all variables name (except for some intermediate variables that i had to create in the MILP)&lt;/p&gt;&#xA;&lt;p&gt;So I would like to give the outputs values of a model as inputs for the other model to know what are the constraint that are not respected with that values.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to do that ?&lt;/p&gt;&#xA;" OwnerUserId="13283" LastActivityDate="2024-03-18T11:44:12.797" Title="Checking if a solution is correct in another model in ILOG CPLEX" Tags="|mixed-integer-programming|constraint|cplex|constraint-programming|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11826" PostTypeId="1" CreationDate="2024-03-19T10:35:01.360" Score="2" ViewCount="112" Body="&lt;p&gt;I am currently working on a machine scheduling problem formulated as MILP and trying to solve it with Column Generation. Since I do not use Branch-n-Price, but only Column Generation as heuristic, it can happen that the heuristic solves the model globally optimal, but often not. How can I determine whether the model has been solved optimally without having to solve the entire model to optimality? And how do I then calculate the optimality gap?&lt;/p&gt;&#xA;" OwnerUserId="13342" LastEditorUserId="491" LastEditDate="2024-03-19T11:59:08.057" LastActivityDate="2024-03-19T12:21:24.327" Title="Determine whether column generation heuristic is optimal?" Tags="|column-generation|dantzig-wolfe-decomposition|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11827" PostTypeId="1" CreationDate="2024-03-19T11:08:07.847" Score="1" ViewCount="65" Body="&lt;p&gt;During solving my problem using generic lazy cuts (in Benders decomposition fashion), the solver gets stuck logging out &amp;quot;Performing restart 2&amp;quot; for several hours (while the time limit is 30 min), till I quit it manually .&lt;/p&gt;&#xA;&lt;p&gt;Based on my searches this situation roots in &amp;quot;Dynamic search&amp;quot; parameter (&lt;a href=&quot;https://www.ibm.com/docs/en/icos/20.1.0?topic=parameters-mip-dynamic-search-switch&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.ibm.com/docs/en/icos/20.1.0?topic=parameters-mip-dynamic-search-switch&lt;/a&gt;), so I turned it off, but the problem still exists.&lt;/p&gt;&#xA;" OwnerUserId="13343" LastEditorUserId="491" LastEditDate="2024-03-19T11:58:43.483" LastActivityDate="2024-03-19T11:58:43.483" Title="CPLEX gets stuck in &quot;Performing restart&quot;" Tags="|cplex|benders-decomposition|branch-and-cut|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="11828" PostTypeId="2" ParentId="11826" CreationDate="2024-03-19T12:21:24.327" Score="1" Body="&lt;p&gt;In any iteration of Column Generation, you can calculate the Lagrangian bound, provided that you solve the pricing problem to optimality (you can easily find on Internet how to calculate such bound). If the maximum value (for a minimization problem) of this Lagrangian bound (over all col.gen. iterations) coincides with the value of your heuristic solution, the latter is optimal. Optimality gap is the difference between the two.&lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2024-03-19T12:21:24.327" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="11829" PostTypeId="2" ParentId="11181" CreationDate="2024-03-20T07:25:37.807" Score="0" Body="&lt;p&gt;Below analysis use the server selection criteria:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If a customer arrives and both Able and Baker are free, he preferentially chooses Able;&lt;/p&gt;&#xA;&lt;p&gt;If one and only one is free, he choose the avaiable one;&lt;/p&gt;&#xA;&lt;p&gt;If none is free, he quit/wait.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;The system capacity limit is just the number of the servers&lt;/h1&gt;&#xA;&lt;p&gt;The transition diagram looks like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u6SXYm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u6SXYm.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-mathematica prettyprint-override&quot;&gt;&lt;code&gt;Clear[&amp;quot;Global`*&amp;quot;];&#xA;(transferMatrix = &#xA;    Normal@SparseArray[{{1, 2} -&amp;gt; \[Lambda], {2, 1} -&amp;gt; &#xA;        Subscript[\[Mu], 1], {2, 3} -&amp;gt; \[Lambda], {3, 2} -&amp;gt; &#xA;        Subscript[\[Mu], 2], {3, 4} -&amp;gt; &#xA;        Subscript[\[Mu], 1], {4, 3} -&amp;gt; \[Lambda], {4, 1} -&amp;gt; &#xA;        Subscript[\[Mu], 2]}, {4, 4}]) // MatrixForm;&#xA;modifiedTransferMatrix = &#xA;  transferMatrix - DiagonalMatrix[Total[transferMatrix, {2}]];&#xA;modifiedTransferMatrix // MatrixForm&#xA;&#xA;\[ScriptCapitalP] = &#xA;  ContinuousMarkovProcess[{1, 0, 0, 0}, modifiedTransferMatrix];&#xA;MarkovProcessProperties[\[ScriptCapitalP]]&#xA;\[ScriptCapitalD] = &#xA; StationaryDistribution[\[ScriptCapitalP]] // FullSimplify&#xA;Table[Probability[x == n, x \[Distributed] \[ScriptCapitalD]], {n, 1, &#xA;   4}] // Together&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre class=&quot;lang-mathematica prettyprint-override&quot;&gt;&lt;code&gt;(* Verification *)&#xA;Solve[{lambda*p00 == mu2*p01 + mu1*p10, (lambda + mu2)*p01 == &#xA;     mu1*p11, (lambda + mu1)*p10 == lambda*p00 + mu2*p11, &#xA;    p00 + p11 + p01 + p10 == 1}, {p00, p01, p10, p11}] // &#xA;  FullSimplify // Together&#xA;% /. {lambda -&amp;gt; \[Lambda], mu1 -&amp;gt; Subscript[\[Mu], 1], &#xA;  mu2 -&amp;gt; Subscript[\[Mu], 2]}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The stationary probability of [Able free, Baker free], [Able busy, Baker free], [Able busy, Baker busy], [Able free, Baker busy] respectively are:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left\{\frac{\mu _1 \mu _2 \left(2 \lambda +\mu _1+\mu _2\right)}{\left(\lambda +\mu _1\right) \left(\lambda ^2+2 \lambda  \mu _2+\mu _2^2+\mu _1 \mu _2\right)},\frac{\lambda  \mu _2 \left(\lambda +\mu _1+\mu _2\right)}{\left(\lambda +\mu _1\right) \left(\lambda ^2+2 \lambda  \mu _2+\mu _2^2+\mu _1 \mu _2\right)},\frac{\lambda ^2 \left(\lambda +\mu _2\right)}{\left(\lambda +\mu _1\right) \left(\lambda ^2+2 \lambda  \mu _2+\mu _2^2+\mu _1 \mu _2\right)},\frac{\lambda ^2 \mu _1}{\left(\lambda +\mu _1\right) \left(\lambda ^2+2 \lambda  \mu _2+\mu _2^2+\mu _1 \mu _2\right)}\right\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h1&gt;The system capacity limit is &lt;span class=&quot;math-container&quot;&gt;$\infty$&lt;/span&gt;&lt;/h1&gt;&#xA;&lt;p&gt;It's a little more difficult than the former case. The transition diagram looks like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/g5IUW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/g5IUW.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-mathematica prettyprint-override&quot;&gt;&lt;code&gt;Solve[{lambda*p00 == mu2*p01 + mu1*p10, (lambda + mu2)*p01 == &#xA;    mu1*p11, (lambda + mu1)*p10 == &#xA;    lambda*p00 + mu2*p11, (mu1 + mu2 + lambda)*p11 == &#xA;    lambda*p01 + lambda*p10 + (mu1 + mu2)*p111, (mu1 + mu2 + lambda)*&#xA;     p111 == lambda*p11 + (mu1 + mu2)*p112, (mu1 + mu2 + lambda)*&#xA;     p112 == lambda*p111 + (mu1 + mu2)*p113}, {p01, p10, p11, p111, &#xA;   p112, p113}];&#xA;sol = % /. {lambda -&amp;gt; \[Lambda], mu1 -&amp;gt; Subscript[\[Mu], 1], &#xA;   mu2 -&amp;gt; Subscript[\[Mu], 2]}&#xA;&#xA;&#xA;&#xA;lhs = p01 + p10 + p11 + &#xA;   Sum[(p00 \[Lambda]^n (\[Lambda] + Subscript[\[Mu], 2]))/(&#xA;    Subscript[\[Mu], 1] Subscript[\[Mu], &#xA;     2] (Subscript[\[Mu], 1] + Subscript[\[Mu], 2])^(&#xA;     n - 2) (2 \[Lambda] + Subscript[\[Mu], 1] + Subscript[\[Mu], &#xA;       2])), {n, 3, Infinity}] /. sol&#xA;Solve[lhs == 1, p00]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\left\{\left\{\text{p01}\to \frac{\lambda ^2 \text{p00}}{\mu _2 \left(2 \lambda +\mu _1+\mu _2\right)},\text{p10}\to \frac{\text{p00} \left(\lambda ^2+\lambda  \mu _1+\lambda  \mu _2\right)}{\mu _1 \left(2 \lambda +\mu _1+\mu _2\right)},\text{p11}\to \frac{\lambda ^2 \text{p00} \left(\lambda +\mu _2\right)}{\mu _1 \mu _2 \left(2 \lambda +\mu _1+\mu _2\right)},\text{p111}\to \frac{\lambda ^3 \text{p00} \left(\lambda +\mu _2\right)}{\mu _1 \mu _2 \left(\mu _1+\mu _2\right) \left(2 \lambda +\mu _1+\mu _2\right)},\text{p112}\to \frac{\lambda ^4 \text{p00} \left(\lambda +\mu _2\right)}{\mu _1 \mu _2 \left(\mu _1+\mu _2\right){}^2 \left(2 \lambda +\mu _1+\mu _2\right)},\text{p113}\to \frac{\lambda ^5 \text{p00} \left(\lambda +\mu _2\right)}{\mu _1 \mu _2 \left(\mu _1+\mu _2\right){}^3 \left(2 \lambda +\mu _1+\mu _2\right)}, \cdots \right\}\right\}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\text{p00}\to \frac{1}{\frac{\lambda ^2}{\mu _2 \left(2 \lambda +\mu _1+\mu _2\right)}+\frac{\lambda ^2 \left(\lambda +\mu _2\right)}{\mu _1 \mu _2 \left(2 \lambda +\mu _1+\mu _2\right)}+\frac{\lambda ^2+\lambda  \mu _1+\lambda  \mu _2}{\mu _1 \left(2 \lambda +\mu _1+\mu _2\right)}+\frac{\lambda ^4+\lambda ^3 \mu _2}{\mu _1 \mu _2 \left(-\lambda +\mu _1+\mu _2\right) \left(2 \lambda +\mu _1+\mu _2\right)}}&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Reference&lt;/h1&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://reference.wolfram.com/language/ref/ContinuousMarkovProcess.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;ContinuousMarkovProcess&lt;/code&gt;&lt;/a&gt; documentation&lt;/p&gt;&#xA;" OwnerUserId="12223" LastEditorUserId="12223" LastEditDate="2024-03-20T08:40:17.107" LastActivityDate="2024-03-20T08:40:17.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11830" PostTypeId="1" CreationDate="2024-03-20T19:17:10.747" Score="2" ViewCount="79" Body="&lt;p&gt;I am looking for the name of the parameter in SCIP, which instructs the solver NOT to transform the &lt;span class=&quot;math-container&quot;&gt;$Abs(x)$&lt;/span&gt;, &lt;span class=&quot;math-container&quot;&gt;$Max(x_1,x_2,x_3,...)$&lt;/span&gt; functions into a set a linear constraints (using additional binaries).&lt;/p&gt;&#xA;&lt;p&gt;A second question is, how can I pass to the solver the constraint &lt;span class=&quot;math-container&quot;&gt;$Max(x_1,x_2,x_3,...)$&lt;/span&gt; using the Osil format?&lt;/p&gt;&#xA;" OwnerUserId="1269" LastActivityDate="2024-03-20T19:17:10.747" Title="SCIP optimizer parameter" Tags="|scip|parameter|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11831" PostTypeId="2" ParentId="11690" CreationDate="2024-03-21T20:58:44.447" Score="0" Body="&lt;p&gt;I guess the last constraint needs to be as below&lt;br /&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$N(b_k-1) \le 1 - k + \sum_{i=1}^{N} x_i   \le b_k +N(1-b_k) \quad \forall k = 1...n $&lt;/span&gt;&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="10602" LastEditDate="2024-03-22T00:59:44.640" LastActivityDate="2024-03-22T00:59:44.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11832" PostTypeId="1" CreationDate="2024-03-22T15:26:15.050" Score="0" ViewCount="60" Body="&lt;p&gt;I am currently trying to speed up my column generation approach to reduce the tailing-off effect. I have modified my master problem as follows. For this I have introduced &lt;span class=&quot;math-container&quot;&gt;$\phi_{ts}^+,\phi_{ts}^-,\chi_{ts}^+,\chi_{ts}^-,\varrho_{ts}^+\text{ and }\varrho_{ts}^-$&lt;/span&gt;. This results in the following master problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\min \sum_{t\in T}^{}\sum_{k\in K}^{}slack_{tk}+\sum_{t\in T}^{}\sum_{k\in K}^{}\phi_{tk}^+\chi_{tk}^+ -\sum_{t\in T}^{}\sum_{k\in K}^{}\phi_{tk}^-\chi_{tk}^-&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;subject to:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\sum_{i\in I}^{}\sum_{r\in R_i} \lambda_{ir} motivation_{itk}^r+slack_{tk}+\chi_{ds}^+-\chi_{tk}^-\ge Demand_{tk}\quad &amp;amp;\forall t\in T, k\in K&#xA;\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\chi_{tk}^+\le \varrho_{tk}^+&amp;amp;\quad\forall t\in T,k\in K&#xA;\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;&amp;amp;\chi_{tk}^-\le \varrho_{tk}^-&amp;amp;\quad\forall t\in T,k\in K&#xA;\end{align}&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;        &amp;amp;\sum_{r\in R_i}^{}\lambda _{ir}=1&amp;amp;\quad \forall i\in I&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;With &lt;span class=&quot;math-container&quot;&gt;$slack_{tk}, \chi_{tk}^+,\chi_{tk}^-\ge 0 t\in T, k\in K$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\lambda_{ir}\in \mathbb{Z}^+\forall i\in I, r\in R_i$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As I understand stabilization, nothing should change in the optimal objective function value, only the number of iterations should possibly be reduced. However, when I implement and calculate it, the objective function value is lower than without stabilization, but &lt;span class=&quot;math-container&quot;&gt;$slack_{tk}$&lt;/span&gt; is higher than in the initial model, since &lt;span class=&quot;math-container&quot;&gt;$\chi_{tk}^-$&lt;/span&gt; takes values &lt;span class=&quot;math-container&quot;&gt;$\ge0$&lt;/span&gt;, while &lt;span class=&quot;math-container&quot;&gt;$\chi_{tk}^+$&lt;/span&gt; in the final solution &lt;span class=&quot;math-container&quot;&gt;$=0\forall t \in T, k\in K$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What could be the reason for this? Have I initialized the model incorrectly?&lt;/p&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="491" LastEditDate="2024-03-22T19:42:08.493" LastActivityDate="2024-03-22T19:42:08.493" Title="Dual stabilization doesnt work properly" Tags="|duality|column-generation|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11833" PostTypeId="2" ParentId="11028" CreationDate="2024-03-24T04:58:50.380" Score="1" Body="&lt;p&gt;This can be done in Simio, but some assumptions must be made. For example, depending on where one lives, there are average times when it is most likely to rain. In my location, it is most likely to rain starting at 6 a.m. and 8 p.m. Therefore, the model will assume those are the times it needs to check if it will start raining.&lt;/p&gt;&#xA;&lt;h2&gt;Events&lt;/h2&gt;&#xA;&lt;p&gt;Events are useful in Simio because they tell the objects attached to them to start or stop their operations. In this model, we're looking to tell cars to either slow down or not. Therefore, we'll need to create a &lt;em&gt;Raining&lt;/em&gt; event like so:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cScre.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Processes&lt;/h2&gt;&#xA;&lt;p&gt;Once the &lt;em&gt;Raining&lt;/em&gt; event has been made, all that needs to be done is deciding if it will rain on that day and if cars will or will not slow down. This can be done with two decision processes: one that points to itself in a forever loop, always checking what time it is, and another one that decides if it's raining. Structurally, they both will look like this:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Lh7Zs.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;One may notice that all the outputs are pointing back into the input of the first deciding node. This is done to ensure the processes, which will be initialized and called upon during the start of the model, will always be checking what time it is in the day via this condition:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;DateTime.Hour(TimeNow) == 6 || DateTime.Hour(TimeNow) == 20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The probability of rain on a given day can be derived from the average percentage chance in a location during a particular time &lt;a href=&quot;https://www.weather.gov/oax/monthly_climate_records&quot; rel=&quot;nofollow noreferrer&quot;&gt;historically&lt;/a&gt;. For explanatory purposes, we'll say there's a 2.34% it will rain on any given day. Once this chance is hit in the second deciding node, it will fire the &lt;em&gt;Raining&lt;/em&gt; event mentioned earlier.&lt;/p&gt;&#xA;&lt;p&gt;To have the cars decide to slow down or not, one has to have a process initialized upon the car entity's creation that waits for the &amp;quot;Raining&amp;quot; event and then calls the 50% probability of where they slow down by changing their speed state variable. This can be done with the following processes:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/q0EOO.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, this only accounts for if it &lt;em&gt;just&lt;/em&gt; starts raining and hasn't been the full six hours. Therefore, we will need to adjust the model to account for this. There are multiple ways to do this, but the simplest way is to check the time after the firing event if it is 12 p.m. or 2 a.m. and stop raining like so:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/GlnkA.png&quot; alt=&quot;5&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;via the following condition:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;DateTime.Hour(TimeNow) == 12 || DateTime.Hour(TimeNow) == 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Another way to do this is by having a process condition on the source object producing the cars and calling the slowdown process per entity creation period. However, this, in practice, was complicated to create and produced unsatisfactory results. Thus, this is the simplest way to represent the weather in Simio for this roadway model.&lt;/p&gt;&#xA;" OwnerUserId="10807" LastActivityDate="2024-03-24T04:58:50.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11834" PostTypeId="1" CreationDate="2024-03-24T23:32:41.093" Score="-1" ViewCount="61" Body="&lt;p&gt;I have &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; points in an &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;-dimensional space (more specifically, the points are basis vectors with small random perturbations).&#xA;I want to embed the points into a smaller-dimensional space: i.e. for &lt;span class=&quot;math-container&quot;&gt;$d \le n$&lt;/span&gt; I want to find a mapping &lt;span class=&quot;math-container&quot;&gt;$f\colon \mathbb{R}^n \to \mathbb{R}^d$&lt;/span&gt; while preserving the following property.&lt;/p&gt;&#xA;&lt;p&gt;For any three distinct points &lt;span class=&quot;math-container&quot;&gt;$x,y,z$&lt;/span&gt;, we know whether &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is closer to &lt;span class=&quot;math-container&quot;&gt;$y$&lt;/span&gt; or to &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;, i.e. is &lt;span class=&quot;math-container&quot;&gt;$\|x - y\|$&lt;/span&gt; greater or less than &lt;span class=&quot;math-container&quot;&gt;$\|x - z\|$&lt;/span&gt;.&#xA;For a selected set of triplets &lt;span class=&quot;math-container&quot;&gt;$(x_1, y_1, z_1), \ldots, (x_m, y_m, z_m)$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\|x_i - y_i\| &amp;lt; \|x_i - z_i\|$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;, we want to preserve this property in the embedding, i.e. we must also have&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;    \|f(x_i) - f(y_i)\| &amp;lt; \|f(x_i) - f(z_i)\|&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My solution&lt;/strong&gt;, I wrote a quadratic program in Gurobi which finds such an embedding.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m = gp.Model()&#xA;# Variables: for each of n original point, we want to find a d-dimensional vector&#xA;vars = [m.addMVar(shape=dim) for i in range(n)]&#xA;&#xA;# Constraint: x is closer to y than to z&#xA;for const in constraints:&#xA;    x, y, z = [vars[i] for i in const]&#xA;    m.addConstr((y - z) @ (2 * x - (y + z)) &amp;gt;= 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The above is true since&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\|f(x) - f(y)\|^2 &amp;lt; \|f(x) - f(z)\|^2&#xA;\iff \left\langle f(y) - f(z), f(x) - (f(y) + f(z)) / 2 \right\rangle &amp;gt; 0&#xA;$$&lt;/span&gt;&#xA;(Intuitively, we look at the hyperplane in the middle between &lt;span class=&quot;math-container&quot;&gt;$f(y)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$f(z)$&lt;/span&gt;. This hyperplane has the normal vector &lt;span class=&quot;math-container&quot;&gt;$f(y) - f(z)$&lt;/span&gt; and goes through the point &lt;span class=&quot;math-container&quot;&gt;$(f(y) + f(z)) / 2$&lt;/span&gt;. I add &lt;span class=&quot;math-container&quot;&gt;$1$&lt;/span&gt; ion the RHS to guarantees strong inequality)&lt;/p&gt;&#xA;&lt;p&gt;I just want to find any embedding, so I set the objective to constant &lt;span class=&quot;math-container&quot;&gt;$0$&lt;/span&gt; and run &lt;code&gt;m.optimize()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem 1&lt;/strong&gt;: If I run it as is, I have problems with large numbers: for some reason, the model tends to consider very large numbers, even when there exist single-digit integer solutions. Sometimes it affects convergence. To counter this, I bound the numbers, either by norm:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for v in vars:&#xA;    m.addConstr(v @ v &amp;lt;= bound * bound)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or by coordinates:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for v in vars:&#xA;    m.addConstr(v &amp;lt;= bound)&#xA;    m.addConstr(v &amp;gt;= -bound)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Both approaches seem to perform the same.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: Is it a standard approach? My main issues are: 1) I don't know how to select the bound (I just try different values), 2) it feels weird that I need to do anything like this in the first place, 3) it introduces additional constraints, which also might affect performance.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem 2&lt;/strong&gt;: The model doesn't converge even for moderately-sizes instances.&#xA;E.g. if I have &lt;span class=&quot;math-container&quot;&gt;$n=20$&lt;/span&gt; points, even taking &lt;span class=&quot;math-container&quot;&gt;$d=n$&lt;/span&gt; (so the solution is guaranteed to exist), I randomly select &lt;span class=&quot;math-container&quot;&gt;$100$&lt;/span&gt; triplets, it doesn't converge within &lt;span class=&quot;math-container&quot;&gt;$10$&lt;/span&gt; minutes (for this size,I want it to finish in seconds).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: Is there a way to improve the performance? My experience with Gurobi is 1 day, so there might be very simple tricks I'm not aware of. In particular, maybe there exists a way to rewrite the constraints to make the program faster?&lt;/p&gt;&#xA;&lt;p&gt;The constraints must be satisfied.&lt;/p&gt;&#xA;" OwnerUserId="13362" LastActivityDate="2024-03-24T23:32:41.093" Title="Improving performance of gurobi program" Tags="|optimization|gurobi|quadratic-programming|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11835" PostTypeId="1" AcceptedAnswerId="11837" CreationDate="2024-03-25T17:58:56.447" Score="1" ViewCount="47" Body="&lt;p&gt;This question pertains to the Conic Benchmark Format (CBF) for specifying a convex optimization problem. &lt;a href=&quot;https://docs.mosek.com/latest/capi/cbf-format.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here's a link to the specification.&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In the CBF specification, there are separate areas for positive semidefinite (psd) constraints and psd variables. But why should there be two separate areas? This seems completely redundant. No other convex cone is treated separately like this--variables are declared and then later constrained to be in a specific cone.&lt;/p&gt;&#xA;&lt;p&gt;Are there any benefits (other than a shortcut for declaring variables subject to a psd constraint) that justify why the PSDVAR section should exist? I'm thinking specifically about benefits to the solver. Could any solvers be expected to take advantage of the fact that a variable was declared psd instead of a symmetric matrix later being constrained psd?&lt;/p&gt;&#xA;" OwnerUserId="3066" LastEditorUserId="3066" LastEditDate="2024-04-03T14:10:18.190" LastActivityDate="2024-04-03T14:10:18.190" Title="Why is there a separate area for PSD constraints and PSD variables in the Conic Benchmark Format?" Tags="|convex-optimization|convexity|mosek|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11836" PostTypeId="2" ParentId="11741" CreationDate="2024-03-25T22:56:57.550" Score="0" Body="&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$\DeclareMathOperator{\Tr}{Tr}\DeclareMathOperator*{\argmax}{\arg\!\max}$&lt;/span&gt;It turns out that strong duality holds for a slightly different but equivalent SDP. We prove this using the following three steps:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We show that a matrix &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; solves &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; if and only if &lt;span class=&quot;math-container&quot;&gt;$V \succeq 0$&lt;/span&gt; and it solves the following &amp;quot;modified&amp;quot; algebraic Riccati equation&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{align}&#xA;V &amp;amp;= AVA^T + Q - \lambda AVC^T (CVC^T + R)^{-1}CVA^T \\&#xA;&amp;amp;= g_\lambda(V) \tag{2}&#xA;\end{align}&#xA;$$&lt;/span&gt;&#xA;where we have defined the function&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;g_\lambda(V) = AVA^T + Q - \lambda AVC^T (CVC^T + R)^{-1}CVA^T&#xA;$$&lt;/span&gt;&#xA;as given in equation (16) in the paper.&lt;/li&gt;&#xA;&lt;li&gt;We show that a matrix &lt;span class=&quot;math-container&quot;&gt;$V \succeq 0$&lt;/span&gt; solves &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt; if and only if the same matrix &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; solves the problem&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{aligned}&#xA;\min_V \quad &amp;amp; \Tr(V) \\&#xA;\textrm{s.t.} \quad &amp;amp; \begin{bmatrix} AVA^T + Q - V &amp;amp; \sqrt{\lambda}AVC^T \\ \sqrt{\lambda}CVA^T &amp;amp; CVC^T + R \end{bmatrix} \preceq 0 \\&#xA;\quad &amp;amp; V \succeq 0&#xA;\end{aligned} \tag{3}&#xA;$$&lt;/span&gt;&lt;/li&gt;&#xA;&lt;li&gt;We invoke Slater's condition to show that that there exists a &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; that is strictly feasible for the problem in &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;, which implies that strong duality holds for &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Note that there is a typo in Theorem 6 in the paper, where the condition&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{bmatrix} AVA^T - V &amp;amp; \sqrt{\lambda}AVC^T \\ \sqrt{\lambda}CVA^T &amp;amp; CVC^T + R \end{bmatrix} \succeq 0&#xA;$$&lt;/span&gt;&#xA;should instead be&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{bmatrix} AVA^T + Q - V &amp;amp; \sqrt{\lambda}AVC^T \\ \sqrt{\lambda}CVA^T &amp;amp; CVC^T + R \end{bmatrix} \succeq 0&#xA;$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h2&gt;Step 1&lt;/h2&gt;&#xA;&lt;p&gt;Although a proof of the statement given in step 1 is given in part (b) of Theorem 6 in the paper, we repeat it here with some additional commentary for convenience (and to avoid repetition in step 2).&lt;/p&gt;&#xA;&lt;p&gt;First, we show that if &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; solves &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; solves &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;. Suppose that &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; solves &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt; and suppose that, for the sake of contradiction, &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; does not solve &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Because &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is feasible in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, then&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{bmatrix} AVA^T + Q - V &amp;amp; \sqrt{\lambda}AVC^T \\ \sqrt{\lambda}CVA^T &amp;amp; CVC^T + R \end{bmatrix} \succeq 0&#xA;$$&lt;/span&gt;&#xA;Then, using the Schur complement lemma, &lt;span class=&quot;math-container&quot;&gt;$V \preceq g_\lambda(V)$&lt;/span&gt;. Next, because &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; does not solve &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$V \neq g_\lambda(V)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Because &lt;span class=&quot;math-container&quot;&gt;$V \preceq g_\lambda(V)$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$V \neq g_\lambda(V)$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$V \prec g_\lambda(V)$&lt;/span&gt;. This implies that &lt;span class=&quot;math-container&quot;&gt;$\Tr(V) \prec \Tr(g_\lambda(V))$&lt;/span&gt;. However, because &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; solves &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, such that for every &lt;span class=&quot;math-container&quot;&gt;$\tilde V$&lt;/span&gt; in the feasible set of &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;, we have that &lt;span class=&quot;math-container&quot;&gt;$\Tr(V) \succeq \Tr(\tilde V)$&lt;/span&gt;, then there is a contradiction. Therefore, &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; solves &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Next, we show that if &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; solves &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; solves &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;. Suppose that &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; solves &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;, such that &lt;span class=&quot;math-container&quot;&gt;$V = g_\lambda(V)$&lt;/span&gt;. This implies that &lt;span class=&quot;math-container&quot;&gt;$V \preceq g_\lambda(V)$&lt;/span&gt;. By the Schur complement lemma, this implies that&#xA;&lt;span class=&quot;math-container&quot;&gt;$$&#xA;\begin{bmatrix} AVA^T + Q - V &amp;amp; \sqrt{\lambda}AVC^T \\ \sqrt{\lambda}CVA^T &amp;amp; CVC^T + R \end{bmatrix} \succeq 0&#xA;$$&lt;/span&gt;&#xA;Hence, &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is feasible in &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;. It remains to show that &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is also maximal, in the sense that &lt;span class=&quot;math-container&quot;&gt;$\forall \tilde V \succeq 0, V \succeq \tilde V$&lt;/span&gt;. In corollary 13.1.2 in the book&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;P. Lancaster and L. Rodman, Algebraic Riccati equations. in Oxford science publications. Oxford : New York: Clarendon Press ; Oxford University Press, 1995.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;it was shown that, if the pair &lt;span class=&quot;math-container&quot;&gt;$(C,A)$&lt;/span&gt; is detectable, then there exists a unique maximal solution to &lt;span class=&quot;math-container&quot;&gt;$(2)$&lt;/span&gt;. We will make this assumption to conclude that &lt;span class=&quot;math-container&quot;&gt;$V$&lt;/span&gt; is maximal, and hence solves &lt;span class=&quot;math-container&quot;&gt;$(1)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Step 2&lt;/h2&gt;&#xA;&lt;p&gt;We can employ a proof similar to the one given in step 1 to complete step 2. We omit this proof for brevity.&lt;/p&gt;&#xA;&lt;h2&gt;Step 3&lt;/h2&gt;&#xA;&lt;p&gt;We now invoke &lt;a href=&quot;https://en.wikipedia.org/wiki/Slater%27s_condition&quot; rel=&quot;nofollow noreferrer&quot;&gt;Slater's condition&lt;/a&gt; to conclude that strong duality holds for &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;. First, suppose that &lt;span class=&quot;math-container&quot;&gt;$(A,Q)$&lt;/span&gt; is controllable and &lt;span class=&quot;math-container&quot;&gt;$(C,A)$&lt;/span&gt; is detectable, and let &lt;span class=&quot;math-container&quot;&gt;$\lambda &amp;gt; \overline{\lambda}$&lt;/span&gt; as given in Theorem 6 in the paper by Sinopoli et al. given in the question.&lt;/p&gt;&#xA;&lt;p&gt;Then, from theorem 5 (corollary 1) in the paper, there exists a &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0 \prec Y \preceq I$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\Psi_\lambda(Y,Z) \succ 0$&lt;/span&gt;. Next, from theorem 5 in the paper, because there exists a &lt;span class=&quot;math-container&quot;&gt;$Z$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$0 \prec Y \preceq I$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$\Psi_\lambda(Y,Z) \succ 0$&lt;/span&gt;, then there exists an &lt;span class=&quot;math-container&quot;&gt;$X$&lt;/span&gt; such that &lt;span class=&quot;math-container&quot;&gt;$X \succ g_\lambda(X)$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Finally, from lemma 1(g) in Appendix A in the paper, because &lt;span class=&quot;math-container&quot;&gt;$X \succ g_\lambda(X)$&lt;/span&gt;, then &lt;span class=&quot;math-container&quot;&gt;$X \succ 0$&lt;/span&gt;. Note that the condition &lt;span class=&quot;math-container&quot;&gt;$X \succ 0$&lt;/span&gt; is the strict version of the second constraint in &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;, and the condition &lt;span class=&quot;math-container&quot;&gt;$X \succ g_\lambda(X)$&lt;/span&gt; is the strict version of the first constraint in &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;. Therefore, by Slater's condition, strong duality holds for &lt;span class=&quot;math-container&quot;&gt;$(3)$&lt;/span&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7263" LastActivityDate="2024-03-25T22:56:57.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11837" PostTypeId="2" ParentId="11835" CreationDate="2024-03-26T06:57:00.153" Score="3" Body="&lt;p&gt;We have included PSDCON and PSDVAR because&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;in some cases, it is more natural/convenient to use one over the other.&lt;/li&gt;&#xA;&lt;li&gt;for instance, Mosek can only handle PSDVAR and must convert PSDCON to the PSDVAR form which often results in a significant loss in efficiency. (LMIs should be dualized.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;PS: There is a lot of redundancy in the CBF format. A scalar linear variable is a matrix variable of dimension 1.&lt;/p&gt;&#xA;" OwnerUserId="134" LastActivityDate="2024-03-26T06:57:00.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11838" PostTypeId="1" CreationDate="2024-03-26T10:19:37.500" Score="1" ViewCount="102" Body="&lt;p&gt;I'm new in CP. Want to start preparing for my upcoming interviews. What are the questions and topics should I study in CP to get my myself confident?&lt;/p&gt;&#xA;" OwnerUserId="12839" LastEditorUserId="491" LastEditDate="2024-03-26T12:14:55.727" LastActivityDate="2024-03-26T13:05:22.730" Title="Constraint Programming Interview" Tags="|constraint-programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11839" PostTypeId="1" CreationDate="2024-03-26T12:07:39.857" Score="0" ViewCount="33" Body="&lt;p&gt;I am currently solving a scheduling optimization problem regarding the fleet management of AGV/AMR. I always get the same error and I don't know where to start to solve it. Here's the code snippet for the objective function and the constraints.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Objective Function&#xA;&#xA;minimize&#xA;  sum(m in M, i in T, r in R) (alpha * M_T[m][i] * X[i][m][r] +&#xA;                                   beta * Consumption_M_T_R[m][i][r] * X[i][m][r] -&#xA;                                   gamma * Y[m][r]);&#xA;&#xA;// Constraints&#xA;&#xA;subject to {&#xA;&#xA;  // Resource Assigned to One Mission&#xA;&#xA;  forall(r in R)&#xA;    sum(m in M) Y[m][r] &amp;lt;= 1;&#xA;&#xA;  // All Tasks Performed (Regardless of Resource)&#xA;&#xA;  forall(m in M, i in T)&#xA;    sum(r in R) X[i][m][r] == 1;&#xA;&#xA;  // Task Succession within Missions&#xA;&#xA;  forall(m in M, i1 in T, i2 in T : i1 != i2)&#xA;    sum(r in R) X[i1][m][r] &amp;lt;= sum(r in R) X[i2][m][r];&#xA;&#xA;  // Mission-Resource Compatibility&#xA;&#xA;  forall(m in M, r in R)&#xA;    Y[m][r] &amp;lt;= Compat_M_R[m][r];&#xA;&#xA;  // Segment Compatibility&#xA;&#xA;  forall(m in M, i in T, s1 in S, s2 in S)&#xA;    sum(r in R) M_T_Segments[m][i][s1] * M_T_Segments[m][i][s2] * NonExecParalleleSegments[s1][s2] * X[i][m][r] &amp;lt;= 1;&#xA;&#xA;  // Resource Availability&#xA;&#xA;  forall(j in R, r in R : j != r)&#xA;    sum(m in M) Y[m][r] &amp;lt;= Z[j];&#xA;&#xA;  // Energy Constraint&#xA;&#xA;  forall(r in R, m in M, i in T)&#xA;    W[m][r][i] &amp;gt;= sum(m in M, i in T) Consumption_M_T_R[m][i][r] * X[i][m][r];&#xA;&#xA;  // Calculating Start and End time&#xA;&#xA;  forall(m in M, i in T)&#xA;    C[i][m] &amp;gt;= sum(r in R) (St[i][m] * Y[m][r] + M_T[m][i] * X[i][m][r]);&#xA;  &#xA;  forall(m in M, i in T, s in S)&#xA;    sum(s in S) St[i][m] * M_T_Segments[m][i][s] &amp;gt;= sum(s in S, m in M, i in T) C[i][m] * M_T_Segments[m][i][s];&#xA;}&#xA;&lt;span class=&quot;math-container&quot;&gt;```&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13368" LastEditorUserId="491" LastEditDate="2024-03-26T12:14:43.857" LastActivityDate="2024-03-26T15:40:51.007" Title="Exception from IBM ILOG CPLEX: CPLEX Error 5002: 'q1' is not convex.-&gt;" Tags="|constraint|cplex|nonconvex-programming|multi-objective-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11840" PostTypeId="1" CreationDate="2024-03-26T12:26:02.543" Score="1" ViewCount="75" Body="&lt;p&gt;I have the following optimization objective function for a dynamic pricing problem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;sum\_profit = \sum_{i \in sales\_point} \Bigg(  constant[i] + {elasticity[i]} \cdot (movement[i] + actual\_prices[i] - comp\_price[i]) &#xA;+ \log\left({price[i]} - costs[i]\right)&#xA;- \lambda[i]\cdot \left(1 - e^{alpha \cdot {exceed[i]^2}}\right) \Bigg)&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;with&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*} exceed[i] = max(0,movement[i] + actual\_prices[i] - comp\_price[i] ) \end{align*}&lt;/span&gt;&#xA;represent a penalty on surpassing the competitor price.&#xA;and my volume model&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;volume[i] = constant[i] + {elasticity[i]} \cdot (movement[i] + actual\_prices[i] - comp\_price[i])&#xA;\end{align*}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;I want to add a constraint that is the volume weighted mean of price movements needs to be equal to a given user input. However, adding this constraints&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align*}&#xA;weighted\_volume\_mean = \frac{\sum_{i \in sales\_point} (mouvement[i] \cdot volume[i])}{\sum_{i \in sales\_point} (volume[i])} = user\_input&#xA;\end{align*}&lt;/span&gt;&#xA;Tends to de-optimize lot of sales points that have little volume by lowering massively the prices on high sales point. I dont want my sales points related to each other. I currently achieve what i want by lowering all competitor prices aritifically until i achieve the wanted mean price. Is there a way to be able to do that without artifically lowering all competitor prices.&lt;/p&gt;&#xA;" OwnerUserId="6016" LastActivityDate="2024-04-02T21:01:40.733" Title="volume-weighted mean equality constraints" Tags="|modeling|nonlinear-programming|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11841" PostTypeId="2" ParentId="11838" CreationDate="2024-03-26T13:05:22.730" Score="1" Body="&lt;p&gt;&lt;em&gt;Assuming, one is also interested in what's happening internally aka &amp;quot;not only black-box view&amp;quot;.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I like the materials related to MiniCP, mostly:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.minicp.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Webpage | Link to Course materials&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007/s12532-020-00190-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;Paper&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The papers abstract:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This paper introduces MiniCP, a lightweight, open-source solver for constraint programming. MiniCP is motivated by educational purposes and, in particular, the desire to provide&#xA;the core implementation of a constraint-programming solver for students in computer science and&#xA;industrial engineering. The design of MiniCP provides a one-to-one mapping between the theoretical and implementation concepts and its compositional abstractions favor extensibility and&#xA;flexibility. MiniCP obviously does not support all available constraint-programming features and&#xA;implementation techniques, but these could be implemented as future extensions or exploratory&#xA;projects. MiniCP also comes with a full set of exercises, unit tests, and development projects.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It seems to try to replicate what &lt;a href=&quot;http://minisat.se/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Minisat&lt;/a&gt; did to the SAT-community:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;MiniSat&#xA;has a neat, minimalist, and well-documented architecture that has enabled several generations&#xA;of students and researchers to enter the field and make significant contributions&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Those materials of course, have some bias towards some design-decisions which you will need to learn about from other sources if needed, an example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;trail-based state-restoration (opposed to copy-based like gecode does)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="231" LastActivityDate="2024-03-26T13:05:22.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11842" PostTypeId="1" CreationDate="2024-03-26T14:29:09.340" Score="0" ViewCount="45" Body="&lt;p&gt;The following is based on my understanding, which may have flaws, so please correct me if I claim something wrong.&lt;/p&gt;&#xA;&lt;p&gt;When solving VRPs with Branch-and-Price, one can enforce integrality by branching on arcs.&#xA;When doing that, enforcing branching on arcs can be done either by adding constraints in the restricted master problem, or by removing infeasible columns and remove arc(s) from the graph used when solving the pricing problem.&lt;/p&gt;&#xA;&lt;p&gt;In my Branch-and-Price implementation, I have used the former approach to enforce branching on arcs. I know that by doing that I miss a potential speedup that can be gained by reducing the number of arcs in the subproblem graph. Someone told me that I can remove arcs from the graph, even if I enforce branching by adding constraints to the restricted master problem. I find that a bit strange, since the dual variables from the added constraints then do not matter.&lt;/p&gt;&#xA;&lt;p&gt;So my question is: can you reduce the graph by removing arcs if branching on arcs is enforced by adding constraints to the reduced master problem?&lt;/p&gt;&#xA;&lt;p&gt;Additionally, what are the pros and cons of the two different approaches to enforce branching on arcs?&lt;/p&gt;&#xA;" OwnerUserId="9151" LastEditorUserId="500" LastEditDate="2024-03-26T17:20:19.960" LastActivityDate="2024-03-26T17:20:19.960" Title="Branch-and-Price for VRPs: Enforcing branching on arcs" Tags="|column-generation|branch-and-price|vrptw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11843" PostTypeId="2" ParentId="11839" CreationDate="2024-03-26T15:40:51.007" Score="0" Body="&lt;p&gt;You did not identify the variables in your model. Presumably X is a variable. If either M_T or Consumption_M_T_R is a variable, then your objective function is a nonconvex quadratic function. If any of the other matrices in the code snippet are variables, then you may have nonconvex quadratic functions in the constraints as well.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-03-26T15:40:51.007" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11844" PostTypeId="1" CreationDate="2024-03-26T15:48:12.377" Score="1" ViewCount="32" Body="&lt;p&gt;I am currently trying to implement the &amp;quot;Smoothing with a Self-Adjusting Parameter&amp;quot; methodology (on the right in Table 1) from &lt;a href=&quot;https://doi.org/10.1287/ijoc.2017.0784&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pessoa et. al (2018)&lt;/a&gt; in my MILP. Unfortunately, I am not quite sure how to perform the individual steps. In my MILP there are the two dual vectors &lt;span class=&quot;math-container&quot;&gt;$\pi_{ij}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\eta_{q}$&lt;/span&gt;, for which I would like to implement the presented self-adjusting method. I understand the initialization in step 0.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Now I have to determine &lt;span class=&quot;math-container&quot;&gt;$\pi_{ij}^{sep}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\eta_{q}^{sep}$&lt;/span&gt; (in the following I will only present the specific questions for &lt;span class=&quot;math-container&quot;&gt;$\pi_{ij}$&lt;/span&gt;, since the procedure for &lt;span class=&quot;math-container&quot;&gt;$\eta_{q}$&lt;/span&gt; is equivalent). For this I need &lt;span class=&quot;math-container&quot;&gt;$\pi_{ij}^{in}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\pi_{ij}^{out}$&lt;/span&gt;. The values of &lt;span class=&quot;math-container&quot;&gt;$\pi_{ij}^{out}$&lt;/span&gt; corresponds to &lt;span class=&quot;math-container&quot;&gt;$\pi_{ij}^{t}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\pi_{ij}^{in}$&lt;/span&gt; corresponds to &lt;span class=&quot;math-container&quot;&gt;$\hat{\pi_{ij}}$&lt;/span&gt;, which is the current imcumbent solution. Here is my first question. How do I determine this imcumbent solution &lt;span class=&quot;math-container&quot;&gt;$\hat{\pi_{ij}}$&lt;/span&gt;, i.e. what calculations do I have to do?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; How can I determine whether mispricing has occurred?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; How do I determine the subgradient of &lt;span class=&quot;math-container&quot;&gt;$g^{sep}(\pi_{ij}^{out}-\pi_{ij}^{in})$&lt;/span&gt;?&lt;/p&gt;&#xA;" OwnerUserId="11967" LastEditorUserId="491" LastEditDate="2024-03-26T16:25:21.920" LastActivityDate="2024-03-26T16:32:39.310" Title="How to implement self-adjusting smoothing in column generation?" Tags="|heuristics|duality|column-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11845" PostTypeId="2" ParentId="11842" CreationDate="2024-03-26T16:23:38.833" Score="1" Body="&lt;p&gt;Removing arcs in the graph is effective only for one branch (arc &amp;lt;= 0). You can certainly impose this constraint in the master and also remove the arc from the graph. Although removing an arc can still be useful to speed up pricing, the impact is minimal because the number of arcs removed (which is no greater than the current tree depth) is much smaller than the total number of arcs. For removing arcs from the graph, using reduced cost fixing (i.e., arc elimination using reduced costs) is much more efficient.&lt;/p&gt;&#xA;&lt;p&gt;The other branch (arc &amp;gt;= 1) poses a significant challenge when imposing it in the pricing; it increases the complexity of the pricing problem. Simply removing corresponding columns from the master is not sufficient, as these columns might be generated again. Therefore, I prefer branching by adding constraints in the master.&lt;/p&gt;&#xA;" OwnerUserId="835" LastActivityDate="2024-03-26T16:23:38.833" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11846" PostTypeId="2" ParentId="11844" CreationDate="2024-03-26T16:26:50.763" Score="0" Body="&lt;p&gt;Smoothing with self-adjusting parameter is implemented in BaPCod (&lt;a href=&quot;https://bapcod.math.u-bordeaux.fr/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://bapcod.math.u-bordeaux.fr/&lt;/a&gt;) and in Coluna (&lt;a href=&quot;https://github.com/atoptima/Coluna.jl&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/atoptima/Coluna.jl&lt;/a&gt;). You can check those codes for implementation details. Concerning your questions, I do not think that it is possible to explain here better than it is already explained in the paper.&lt;/p&gt;&#xA;" OwnerUserId="835" LastEditorUserId="835" LastEditDate="2024-03-26T16:32:39.310" LastActivityDate="2024-03-26T16:32:39.310" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11847" PostTypeId="1" AcceptedAnswerId="11848" CreationDate="2024-03-26T16:28:33.790" Score="2" ViewCount="70" Body="&lt;p&gt;I'm currently reviewing literature on the Open Vehicle Routing Problem (Open VRP), which characterizes scenarios where trucks do not return to the depot after serving the last customer. In this context, I've observed that several papers apply conventional flow conservation constraints as part of their formulations. For instance, the constraint &lt;span class=&quot;math-container&quot;&gt;$\sum_{i=0}^{n} x_{i j k}-\sum_{i=0}^{n} x_{j i k}=0, \quad j=0,1, \ldots, n, k=1, \ldots, \overline{k}$&lt;/span&gt;, which includes the depot as node '0', is used in &lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0957417409006988&quot; rel=&quot;nofollow noreferrer&quot;&gt;this paper&lt;/a&gt;. Similar formulations can be seen in:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Li, F., Golden, B., &amp;amp; Wasil, E. (2007). &amp;quot;The open vehicle routing problem: Algorithms, large-scale test problems, and computational results.&amp;quot; Computers &amp;amp; Operations Research, 34(10), 2918-2930.&lt;/li&gt;&#xA;&lt;li&gt;Repoussis, P. P., Tarantilis, C. D., &amp;amp; Ioannou, G. (2007). &amp;quot;The open vehicle routing problem with time windows.&amp;quot; Journal of the Operational Research Society, 58(3), 355-367.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;These formulations don't appear to make a distinction for the final node visited by a truck, where logically, flow conservation doesn't apply due to the absence of an outbound trip.&lt;/p&gt;&#xA;&lt;p&gt;Here is my personal take on formulating this aspect, assuming a set of nodes &lt;span class=&quot;math-container&quot;&gt;$N$&lt;/span&gt; excluding the depot, and &lt;span class=&quot;math-container&quot;&gt;$N_0$&lt;/span&gt; including the depot, with &lt;span class=&quot;math-container&quot;&gt;$x_{i,j,k}=1$&lt;/span&gt; if and only if truck &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt; travels from node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; to node &lt;span class=&quot;math-container&quot;&gt;$j$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Relax the flow conservation constraint for all nodes, except for the depot, using the &lt;span class=&quot;math-container&quot;&gt;$\ge$&lt;/span&gt; inequality:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \sum_{j \in N_0, j \neq i} x_{j,i,k} \geq \sum_{j \in N, j \neq i} x_{i,j,k} \quad \forall i \in N, \forall k \in K $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Ensure that for each vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;, exactly one node has a higher number of vehicles entering than leaving, indicating the terminating node. To represent this, I introduce a binary variable &lt;span class=&quot;math-container&quot;&gt;$t_{i,k}$&lt;/span&gt;, which is 1 if node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is the terminating node for vehicle &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{i \in N} t_{i,k} = 1 \quad \forall k \in K $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect the binary variables &lt;span class=&quot;math-container&quot;&gt;$t_{i,k}$&lt;/span&gt; with the relaxed flow conservation constraint:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$\sum_{j \in N_0, j \neq i} x_{j,i,k} - \sum_{j \in N, j \neq i} x_{i,j,k} = t_{i,k} \quad \forall i \in N, \forall k \in K$$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Could there be an aspect I'm overlooking in the published models, or is there an explanation for the absence of explicit differentiation for the terminating node in these papers on Open VRP?&lt;/p&gt;&#xA;" OwnerUserId="9613" LastActivityDate="2024-03-26T18:06:12.567" Title="Flow conservation constraints for an Open Vehicle Routing Problem" Tags="|constraint|vehicle-routing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11848" PostTypeId="2" ParentId="11847" CreationDate="2024-03-26T18:06:12.567" Score="2" Body="&lt;p&gt;I'm not familiar with the published literature, but a simple fix is to create an artificial terminating node to which all vehicles must go, along with zero-length arcs from every node to the terminating node (but no arcs out of the terminating node). You enforce flow conservation everywhere except the origin depot and the terminating node.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-03-26T18:06:12.567" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11849" PostTypeId="1" AcceptedAnswerId="11851" CreationDate="2024-03-27T09:13:15.593" Score="1" ViewCount="60" Body="&lt;p&gt;There are &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; jobs with different processing times, and they should be scheduled on &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;&#xA;identical machines such that the average (of all jobs, of all machines) maximum completion time (makespan) is minimized and under a certain time &lt;span class=&quot;math-container&quot;&gt;$T_{\max}$&lt;/span&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;$$ \min_{\mathbf{y}}\;  \frac{1}{N}  \sum_{i \in \mathcal{N}} \sum_{j\in \mathcal{M}} y_{ij} \cdot \max_{\ell \in \mathcal{N}} \{ y_{\ell j} \}$$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$ \text{s.t.} \sum_{i\in \mathcal{N}} \sum_{j\in \mathcal{M}} y_{ij} \cdot \max_{\ell \in \mathcal{N}} \{y_{\ell j}\} \leq T_{\max} $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$  \sum_{j\in \mathcal{M}} y_{ij} =1 , \forall i \in \mathcal{N}  $$&lt;/span&gt;&#xA;&lt;span class=&quot;math-container&quot;&gt;$$  y_{ij} \in \{0,1\}, \;  \forall i \in \mathcal{N}, j\in \mathcal{M}. $$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;We came up with this problem as we want to schedule (offload) tasks generated by users to servers for processing. Does anyone know the complexity of this problem?&lt;/p&gt;&#xA;" OwnerUserId="13372" LastEditorUserId="500" LastEditDate="2024-03-27T19:05:48.770" LastActivityDate="2024-03-27T21:05:20.370" Title="Complexity of average maximum completion time" Tags="|scheduling|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11850" PostTypeId="1" CreationDate="2024-03-27T13:11:34.297" Score="-1" ViewCount="67" Body="&lt;p&gt;I have a general square matrix &lt;code&gt;[[1,1,0],[1,1,0],[0,0,0]]&lt;/code&gt; (the element is on a binary field--Galois Fields) I want to find the rank of this matrix (like the function: &lt;code&gt;np.linalg.matrix_rank&lt;/code&gt;). How can I describe this process using gurobi?&lt;/p&gt;&#xA;&lt;p&gt;Due to the elements in the matrix being related to the variables in gurobi model, I can't use the function of Numpy directly.&lt;/p&gt;&#xA;&lt;p&gt;I tried asking a question in the &lt;a href=&quot;https://support.gurobi.com/hc/en-us/community/posts/21492875907857-How-to-use-gurobi-to-describe-the-process-of-finding-the-rank-of-matrix&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gurobi community&lt;/a&gt; before and got a small model that worked. This model has an objective function to get the rank.&lt;/p&gt;&#xA;&lt;p&gt;When I embedded it in my original big model (which already has an objective function), the original model affected the optimization process of the rank-finding process. That is, in this multi-objective optimization problem, the rank is always wrong.&lt;/p&gt;&#xA;&lt;p&gt;This would render the entire model unusable since the rank should be a deterministic property of the matrix. But now because the optimization process can't get the best, the rank property becomes uncertain.&lt;/p&gt;&#xA;&lt;p&gt;My original goal was to maximize a &amp;quot;GObj&amp;quot; that is &amp;gt;= 0. If this value equals 1, it means the model has a solution. In the big model, the rank is required several times (several rank-finding processes are also related to each other).&lt;/p&gt;&#xA;&lt;p&gt;For the rank process to be optimal, I tried to adjust the priority of the object, but even though I set the priority of the rank-finding very high, I still got a lot of wrong ranks. Similarly, I try not to optimize the &amp;quot;GObj&amp;quot;, just limit it to &amp;gt;=1 so that the model can have a solution. I still got a lot of wrong ranks. I also tried to make a lot of small adjustments, but nothing worked.&lt;/p&gt;&#xA;&lt;p&gt;I think an easy-to-understand solution is to figure out how to describe the process of finding the rank of matrix &lt;strong&gt;without objective function&lt;/strong&gt;. So how can I describe it without objective function?&lt;/p&gt;&#xA;&lt;p&gt;If I don't change the way the rank is found, how can the modeling be done so that the rank-finding procedure is optimal while maximizing &amp;quot;GObj&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;To describe my problem in detail, I wrote a demo and uploaded it to Github: &lt;a href=&quot;https://github.com/wenny-kiki/test_math&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/wenny-kiki/test_math&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13373" LastEditorUserId="36" LastEditDate="2024-03-28T13:56:48.113" LastActivityDate="2024-04-02T10:56:56.330" Title="How to use gurobi to describe the process of finding the rank of matrix without objective function？" Tags="|optimization|gurobi|binary-variable|multi-objective-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11851" PostTypeId="2" ParentId="11849" CreationDate="2024-03-27T21:05:20.370" Score="1" Body="&lt;p&gt;I suspect that your model should instead be expressed as follows.  For job &lt;span class=&quot;math-container&quot;&gt;$i\in\mathcal{N}$&lt;/span&gt; and machine &lt;span class=&quot;math-container&quot;&gt;$j\in\mathcal{M}$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$p_{ij}$&lt;/span&gt; be the processing time.  The problem is to minimize &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; subject to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i\in \mathcal{N}} p_{ij} y_{ij} &amp;amp;\le z &amp;amp;&amp;amp; \forall j\in \mathcal{M} \tag1\label1 \\&#xA;\sum_{i\in \mathcal{N}} p_{ij} y_{ij} &amp;amp;\le T_{\max} &amp;amp;&amp;amp; \forall j\in \mathcal{M} \tag2\label2 \\&#xA;\sum_{j\in \mathcal{M}} y_{ij} &amp;amp;= 1 &amp;amp;&amp;amp; \forall i \in \mathcal{N} \tag3\label3 \\&#xA;y_{ij} &amp;amp;\in \{0,1\} &amp;amp;&amp;amp; \forall i \in \mathcal{N}, j\in \mathcal{M}&#xA;\end{align}&lt;/span&gt;&#xA;Constraint \eqref{1} defines the makespan &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt;.&#xA;Constraint \eqref{2} enforces the total processing time limit on machine &lt;span class=&quot;math-container&quot;&gt;$m$&lt;/span&gt;.&#xA;Constraint \eqref{3} assigns each job to exactly one machine.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2024-03-27T21:05:20.370" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11852" PostTypeId="1" AcceptedAnswerId="11853" CreationDate="2024-03-28T12:19:23.590" Score="1" ViewCount="57" Body="&lt;p&gt;I am working on a quadratic conic optimization problem, but I have discovered that it would be preferable if the quadratic constraint is linearly approximated. In other words, I need some way to make the quadratic beta variable linear. Is there any good way to do this? The only decision variable here is the beta, everything else is given as inputs to the problem.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/p4YRS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/p4YRS.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13236" LastEditorUserId="500" LastEditDate="2024-03-28T12:57:41.257" LastActivityDate="2024-03-28T19:05:21.733" Title="Linearizing a quadratic constraint" Tags="|linear-programming|linearization|quadratic-programming|conic-optimization|socp|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11853" PostTypeId="2" ParentId="11852" CreationDate="2024-03-28T19:05:21.733" Score="0" Body="&lt;p&gt;Linearization comes with one of two trade-offs, depending on how you do it: maintaining feasibility but perhaps accepting a slightly (?) suboptimal solution; or maintaining optimality (perhaps superoptimality) while perhaps accepting a slightly (?) infeasible solution. I'll assume you prefer the former.&lt;/p&gt;&#xA;&lt;p&gt;We will need upper bounds &lt;span class=&quot;math-container&quot;&gt;$B_n$&lt;/span&gt; for the &lt;span class=&quot;math-container&quot;&gt;$\beta_n$&lt;/span&gt; variables. Introduce new variables &lt;span class=&quot;math-container&quot;&gt;$z_n \ge 0$&lt;/span&gt; to act as surrogates for &lt;span class=&quot;math-container&quot;&gt;$\delta_n \beta_n^2$&lt;/span&gt; and rewrite the quadratic constraint as &lt;span class=&quot;math-container&quot;&gt;$\sum_n z_n \le A^2.$&lt;/span&gt; For each &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt;, let &lt;span class=&quot;math-container&quot;&gt;$f_n(\beta_n) = \delta_n \beta_n^2.$&lt;/span&gt; Pick breakpoints &lt;span class=&quot;math-container&quot;&gt;$b_{n,0}=0 &amp;lt; b_{n,1} &amp;lt; \dots &amp;lt; b_{n, K_n} = B_n$&lt;/span&gt; for the domain of &lt;span class=&quot;math-container&quot;&gt;$\beta_n$&lt;/span&gt; and compute linear secant functions &lt;span class=&quot;math-container&quot;&gt;$f_{n,k}$&lt;/span&gt; &lt;span class=&quot;math-container&quot;&gt;$(k=0,\dots, K_n - 1),$&lt;/span&gt; where &lt;span class=&quot;math-container&quot;&gt;$f_{n,k}(\beta_n) = f_n(\beta_n)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\beta_n = b_{n,k}$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$\beta_n = b_{n, k+1}.$&lt;/span&gt; Finally, for each &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; add the constraints &lt;span class=&quot;math-container&quot;&gt;$z_n \ge f_{n,k}(\beta_n)$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$k.$&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Since &lt;span class=&quot;math-container&quot;&gt;$f_n$&lt;/span&gt; is strictly convex, &lt;span class=&quot;math-container&quot;&gt;$f_{n,k}(\beta_n) \ge f_n(\beta_n)$&lt;/span&gt; for &lt;span class=&quot;math-container&quot;&gt;$\beta_n \in [b_{n,k}, b_{n, k+1}],$&lt;/span&gt; which ensures that &lt;span class=&quot;math-container&quot;&gt;$z_n \ge f_n(\beta_n)$&lt;/span&gt; for any feasible &lt;span class=&quot;math-container&quot;&gt;$\beta_n.$&lt;/span&gt; So the resulting LP is guaranteed to produce a solution feasible in the original problem ... but it might miss an optimal solution if the optimal value of any &lt;span class=&quot;math-container&quot;&gt;$\beta_n$&lt;/span&gt; falls in the gap between &lt;span class=&quot;math-container&quot;&gt;$f_n$&lt;/span&gt; and the relevant secant. One thing you might consider is solving the approximate LP and then refine the approximation near the optimal solution (add more interpolation points for each &lt;span class=&quot;math-container&quot;&gt;$n$&lt;/span&gt; near the &amp;quot;optimal&amp;quot; value of &lt;span class=&quot;math-container&quot;&gt;$\beta_n$&lt;/span&gt;), then repeat.&lt;/p&gt;&#xA;&lt;p&gt;If pictures would help, you might want to refer to &lt;a href=&quot;https://orinanobworld.blogspot.com/2020/03/approximating-nonlinear-functions.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this blog post&lt;/a&gt;. Figure 2 demonstrates what I am proposing (though only the positive part of the &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; axis is relevant here, where the post's &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; is your &lt;span class=&quot;math-container&quot;&gt;$\beta_n$&lt;/span&gt;). Figure 7 shows how a feasible (potentially optimal) point might be excluded by the approximation.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2024-03-28T19:05:21.733" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11855" PostTypeId="1" AcceptedAnswerId="11857" CreationDate="2024-03-29T09:38:39.567" Score="4" ViewCount="308" Body="&lt;p&gt;Given a matrix &lt;span class=&quot;math-container&quot;&gt;$A$&lt;/span&gt; and a vector &lt;span class=&quot;math-container&quot;&gt;$b$&lt;/span&gt;, I would like to find a vector &lt;span class=&quot;math-container&quot;&gt;$x$&lt;/span&gt; satisfying the set of linear constraints &lt;span class=&quot;math-container&quot;&gt;$A x \leq b$&lt;/span&gt;, and subject to that, contains as many variables as possible with nonnegative value.&lt;/p&gt;&#xA;&lt;p&gt;An obvious solution is to loop over all subsets of variables. For every subset &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt;, check if the following set of constraints is feasible:&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;A x &amp;amp;\leq b;&#xA;\\&#xA;x_i &amp;amp;\geq 0 &amp;amp;&amp;amp; \forall i\in S&#xA;\end{align}&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, return the solution for the largest set &lt;span class=&quot;math-container&quot;&gt;$S$&lt;/span&gt; for which the constraints are feasible.&#xA;But this solution takes time exponential in the number of variables.&lt;/p&gt;&#xA;&lt;p&gt;Is there a polynomial-time solution?&lt;/p&gt;&#xA;" OwnerUserId="2576" LastEditorUserId="500" LastEditDate="2024-03-29T12:27:56.167" LastActivityDate="2024-04-05T06:53:05.823" Title="How to maximize the number of variables with value at least 0?" Tags="|optimization|linear-programming|modeling|logical-constraints|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11856" PostTypeId="2" ParentId="11850" CreationDate="2024-03-29T12:19:28.877" Score="1" Body="&lt;p&gt;In theory we can use the fact that rank = the number of non-zero singular values in a &lt;a href=&quot;https://en.wikipedia.org/wiki/Singular_value_decomposition&quot; rel=&quot;nofollow noreferrer&quot;&gt;singular value decomposition&lt;/a&gt; (SVD).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import gurobipy as gp&#xA;import numpy as np&#xA;&#xA;m = gp.Model()&#xA;&#xA;p,q = 4,3 # as an example, overwritten for testing&#xA;&#xA;# The matrix we want to calculate rank of&#xA;M = m.addMVar((p,q), lb=-float(&amp;quot;inf&amp;quot;), name=&amp;quot;M&amp;quot;)&#xA;&#xA;# # uncomment the following lines for testing&#xA;# A = np.random.randint(-2,2, size=(p,q))&#xA;# m.addConstr(M == A)&#xA;&#xA;U = m.addMVar((p,p), lb=-float(&amp;quot;inf&amp;quot;), name=&amp;quot;U&amp;quot;)&#xA;&#xA;ub = np.zeros((p,q))&#xA;np.fill_diagonal(ub, np.inf)&#xA;lb = np.zeros((p,q))&#xA;np.fill_diagonal(lb, -np.inf)&#xA;S = m.addMVar((p,q), lb=lb, ub=ub, name=&amp;quot;S&amp;quot;)&#xA;&#xA;V = m.addMVar((q,q), lb=-float(&amp;quot;inf&amp;quot;), name=&amp;quot;V&amp;quot;)&#xA;&#xA;m.addConstr(U@U.T == np.eye(p))&#xA;m.addConstr(V@V.T == np.eye(q))&#xA;&#xA;aux = m.addMVar((p,q), lb=-float(&amp;quot;inf&amp;quot;), name=&amp;quot;aux&amp;quot;)&#xA;m.addConstr(U@S == aux)&#xA;m.addConstr(aux@V == M)&#xA;&#xA;nzpos = m.addVars(min(p,q), vtype=&amp;quot;B&amp;quot;)&#xA;nzneg = m.addVars(min(p,q), vtype=&amp;quot;B&amp;quot;)&#xA;for i in range(min(p,q)):&#xA;    m.addConstr((nzpos[i]==1)&amp;gt;&amp;gt;(S[i,i] &amp;gt;= 0.0001))&#xA;    m.addConstr((nzpos[i]==0)&amp;gt;&amp;gt;(S[i,i] &amp;lt;= 0.00009))&#xA;    m.addConstr((nzneg[i]==1)&amp;gt;&amp;gt;(S[i,i] &amp;lt;= -0.0001))&#xA;    m.addConstr((nzneg[i]==0)&amp;gt;&amp;gt;(S[i,i] &amp;gt;= -0.00009))&#xA;&#xA;rank = m.addVar()&#xA;m.addConstr(rank == nzpos.sum() + nzneg.sum())&#xA;m.optimize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In practice this is not going to work though, and Gurobi will complain that &amp;quot;Model contains variables with very large bounds participating in product terms&amp;quot;.  We can introduce bounds on U (and V) but in doing so requires &lt;span class=&quot;math-container&quot;&gt;$UU^T = I$&lt;/span&gt; to be replaced with &lt;span class=&quot;math-container&quot;&gt;$UU^T = aI$&lt;/span&gt; for some non-zero scalar &lt;span class=&quot;math-container&quot;&gt;$a$&lt;/span&gt; (and similarly for V). What you get is a model which will probably only be solvable for tiny matrices - not to mention be prone to numerical issues and hence incorrect results.&lt;/p&gt;&#xA;" OwnerUserId="10108" LastEditorUserId="10108" LastEditDate="2024-04-02T10:56:56.330" LastActivityDate="2024-04-02T10:56:56.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11857" PostTypeId="2" ParentId="11855" CreationDate="2024-03-29T12:26:00.580" Score="6" Body="&lt;p&gt;Let &lt;span class=&quot;math-container&quot;&gt;$L_i$&lt;/span&gt; be a constant lower bound on &lt;span class=&quot;math-container&quot;&gt;$x_i$&lt;/span&gt;. Introduce binary variables &lt;span class=&quot;math-container&quot;&gt;$y_i$&lt;/span&gt; and maximize &lt;span class=&quot;math-container&quot;&gt;$\sum_i y_i$&lt;/span&gt; subject to &lt;span class=&quot;math-container&quot;&gt;$Ax\le b$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$L_i (1-y_i)\le x_i$&lt;/span&gt; for all &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt;. The new constraints enforce the logical implications &lt;span class=&quot;math-container&quot;&gt;$y_i=1 \implies x_i\ge 0$&lt;/span&gt;, which you could alternatively enforce via indicator constraints.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For the NP-hardness, here's a reduction from independent set.  Explicitly, you are given graph &lt;span class=&quot;math-container&quot;&gt;$G=(N,E)$&lt;/span&gt; and positive integer &lt;span class=&quot;math-container&quot;&gt;$k$&lt;/span&gt;.  Let binary decision variable &lt;span class=&quot;math-container&quot;&gt;$z_i$&lt;/span&gt; indicate whether node &lt;span class=&quot;math-container&quot;&gt;$i$&lt;/span&gt; is selected.  You want to determine whether there is a solution to&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;\sum_{i\in N} z_i &amp;amp;\ge k \\&#xA;z_i + z_j &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for $(i,j)\in E$} \\&#xA;z_i &amp;amp;\in \{0,1\} &amp;amp;&amp;amp;\text{for $i \in N$} &#xA;\end{align}&lt;/span&gt;&#xA;Now take &lt;span class=&quot;math-container&quot;&gt;$x_i = z_i-1$&lt;/span&gt; (so that &lt;span class=&quot;math-container&quot;&gt;$x_i \ge 0$&lt;/span&gt; corresponds to &lt;span class=&quot;math-container&quot;&gt;$z_i = 1$&lt;/span&gt;) and rewrite the constraints as&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;-\sum_{i\in N} x_i &amp;amp;\le |N|-k \\&#xA;x_i + x_j &amp;amp;\le -1 &amp;amp;&amp;amp;\text{for $(i,j)\in E$} \\&#xA;-x_i &amp;amp;\le 1 &amp;amp;&amp;amp;\text{for $i \in N$} \\&#xA;x_i &amp;amp;\le 0 &amp;amp;&amp;amp;\text{for $i \in N$} &#xA;\end{align}&lt;/span&gt;&#xA;This is in the form of your original problem, which is therefore at least as hard as independent set.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2024-04-04T20:36:59.447" LastActivityDate="2024-04-04T20:36:59.447" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11859" PostTypeId="1" CreationDate="2024-03-29T15:41:25.657" Score="1" ViewCount="62" Body="&lt;p&gt;I have recently read a text which deals with the dual variables attached to constraints. In an economic sense, one can interpret them as shadow variables indicating market clearing for resource constraint and zero-profits for cost equations. But I could not really follow the discussion.&lt;/p&gt;&#xA;&lt;p&gt;So from my understanding, the variables attached to the constraints in LP are used as coefficient to build a linear combination in order to get from the primal to the dual problem. If a constraint is binding, then this coefficient will be positive, and zero if non-binding.&lt;/p&gt;&#xA;&lt;p&gt;Thus I conclude that people economically interpret those coefficients which relate to binding constraints. I can imagine that if we have a demand problem, then the shadow price is (maybe?) some sort of market clearing price of the constraint. And if we are in a cost scenario, then a binding constraint would indicate that costs equal profit and thus output is positive but economic profit is zero?&lt;/p&gt;&#xA;&lt;p&gt;I am also a bit puzzled since I know shadow variables in the context of Lagrangian multipliers. Is that just another approach of solving LP's and its interpretation is therefore similar to the dual variable (as both are called shadow variables)?&lt;/p&gt;&#xA;&lt;p&gt;Any input is appreciated!&lt;/p&gt;&#xA;" OwnerUserId="13380" LastEditorUserId="13380" LastEditDate="2024-03-29T15:54:50.990" LastActivityDate="2024-03-29T16:02:11.293" Title="Economic interpretation of shadow/dual variables in LP" Tags="|linear-programming|duality|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11860" PostTypeId="2" ParentId="11859" CreationDate="2024-03-29T16:02:11.293" Score="3" Body="&lt;p&gt;The expression &lt;strong&gt;shadow price&lt;/strong&gt; usually refers to the price of a good or service calculated by an economic mathematical model (&lt;em&gt;mathematical programming&lt;/em&gt;). The shadow price, also known as the accounting price, indicates the value of the goods which derives from their scarcity, i.e. from the limited availability of the quantities of goods compared to needs. In a technical sense, the shadow price is the term used to call &lt;strong&gt;Lagrange multipliers&lt;/strong&gt; in &lt;em&gt;economics&lt;/em&gt;. In economic optimization problems, the notion of scarcity is reflected in the constraint equations of productive resources or a basket of goods where a function of revenues, costs or a utility function constitutes the function to be optimized.&lt;/p&gt;&#xA;&lt;p&gt;Today, the expression shadow price finds a wider use than that originally attributed by mathematical programming. In economic evaluations, &lt;em&gt;the shadow price of a good, be it an input or an output, constitutes its economic value whenever the market is not able to incorporate into the price the true opportunity cost of the good itself to which it is connected&lt;/em&gt;. In perfectly competitive and efficient markets or in conditions of optimal planning, &lt;em&gt;market prices and shadow prices coincide&lt;/em&gt;, however in reality it is observed that markets can be distorted by taxes, duties, subsidies, rigid exchange rates, production or consumption, regulated tariffs, oligopoly or monopoly price setting and imperfect information. These elements mean that there is a difference between the market price and the shadow price. The main reasons for the distortion are: the absence of perfect competition following the presence of monopolies or oligopolies and imperfect information between economic agents; state intervention or other factors external to the economic sphere that disrupt the economic process (taxes, regulations, quotas and all types of economic policy measures).&lt;/p&gt;&#xA;&lt;p&gt;The goal of using shadow prices is to correct distortions between market prices and true economic value.&lt;/p&gt;&#xA;&lt;p&gt;Economic operators interested in evaluating and deciding on the optimal use of factors may find themselves faced with monetary prices recorded on the market which are poorly suited to being used as a decision-making tool. Since a good decision-making process requires measuring the value of goods/services in commensurable units, whenever the market price is inadequate or absent, the concept of shadow price is used with the aim of carrying out assessments of economic convenience between different purchasing decisions, investment.&lt;/p&gt;&#xA;" OwnerUserId="4114" LastActivityDate="2024-03-29T16:02:11.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11861" PostTypeId="1" AcceptedAnswerId="11862" CreationDate="2024-03-30T21:12:19.827" Score="0" ViewCount="67" Body="&lt;p&gt;I would like to know what is the best way to linearize a constraint involving an absolute function. More precisely, imagine I have three binary variables and their relationships is as follows:&lt;/p&gt;&#xA;&lt;p&gt;|x-y| = z.&lt;/p&gt;&#xA;&lt;p&gt;I have so many z variables that it's value depends on x and y (all binary). That's why I am looking for an efficient way (bigM or any other way) to model efficiently this constraint.&lt;/p&gt;&#xA;" OwnerUserId="5008" LastActivityDate="2024-04-01T19:10:42.660" Title="linearizing a constraint involving an absolute function" Tags="|optimization|constraint|linearization|combinatorial-optimization|absolute-value|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11862" PostTypeId="2" ParentId="11861" CreationDate="2024-03-30T21:49:31.760" Score="6" Body="&lt;p&gt;Note that this is the same relationship as &lt;span class=&quot;math-container&quot;&gt;$x \text{ xor } y=z$&lt;/span&gt;. You want to enforce four logical implications:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;x \land y &amp;amp;\implies \lnot z \\&#xA;x \land \lnot y &amp;amp;\implies z \\&#xA;\lnot x \land y &amp;amp;\implies z \\&#xA;\lnot x \land \lnot y &amp;amp;\implies \lnot z&#xA;\end{align}&lt;/span&gt;&#xA;Via conjunctive normal form or otherwise, the resulting linear constraints are:&#xA;&lt;span class=&quot;math-container&quot;&gt;\begin{align}&#xA;(1-x)+(1-y)+(1-z) &amp;amp;\ge 1 \\&#xA;(1-x)+y+z &amp;amp;\ge 1 \\&#xA;x+(1-y)+z &amp;amp;\ge 1 \\&#xA;x+y+(1-z) &amp;amp;\ge 1&#xA;\end{align}&lt;/span&gt;&#xA;You can optionally relax &lt;span class=&quot;math-container&quot;&gt;$z$&lt;/span&gt; to be nonnegative, and it will automatically take binary values.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, you can think of the desired relationship as &lt;span class=&quot;math-container&quot;&gt;$x+y\mod 2=z$&lt;/span&gt; and impose a single equality constraint &lt;span class=&quot;math-container&quot;&gt;$x+y=z+2w$&lt;/span&gt;, where &lt;span class=&quot;math-container&quot;&gt;$w$&lt;/span&gt; is binary.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2024-03-30T21:49:31.760" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11863" PostTypeId="1" CreationDate="2024-03-31T14:50:13.500" Score="0" ViewCount="41" Body="&lt;p&gt;In my engineering application, all decision variables are non-negative and everything is convex separable. In addition to that, the only function that I am trying to approximate with grid point are &lt;span class=&quot;math-container&quot;&gt;$f(x)=x^3$&lt;/span&gt; and &lt;span class=&quot;math-container&quot;&gt;$g(y)=y^4$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am having this strange feeling about solving separable programming problem. Particularly for imposing the following requirement on the &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt;.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;At most 2 &lt;span class=&quot;math-container&quot;&gt;$\lambda$&lt;/span&gt; are positive&lt;/li&gt;&#xA;&lt;li&gt;They must be adjacent&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BuK21.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BuK21.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;From what I know, this can be done by modifying the entering and leaving variable of the simplex tableu. However, if I am using an interior point method solver like MOSEK then how can I impose these constraint ?&lt;/p&gt;&#xA;" OwnerUserId="11163" LastEditorUserId="491" LastEditDate="2024-04-01T12:07:57.107" LastActivityDate="2024-04-01T12:07:57.107" Title="Solving convex separable programming problem using interior point method?" Tags="|linear-programming|nonlinear-programming|simplex|approximation-algorithms|interior-point-method|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11864" PostTypeId="1" AcceptedAnswerId="11865" CreationDate="2024-03-31T17:59:29.117" Score="2" ViewCount="119" Body="&lt;p&gt;I know that it is common to branch on the flow on arcs to ensure intergrality when solving VRPs, but in which circumstances is valid to branch on the flow on edges instead of arcs? References to papers discussing this are welcome.&lt;/p&gt;&#xA;" OwnerUserId="9151" LastEditorUserId="9151" LastEditDate="2024-03-31T18:05:59.890" LastActivityDate="2024-03-31T23:46:59.960" Title="In which circumstances is it sufficient to branch on the flow on edges to ensure integrality in VRPs?" Tags="|reference-request|vehicle-routing|branch-and-bound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11865" PostTypeId="2" ParentId="11864" CreationDate="2024-03-31T23:38:23.750" Score="3" Body="&lt;p&gt;It really depends on the problem and on the formulation that is used. For example, in the following paper the authors compare different formulations for the CVRP, some of which are defined on arcs and some of which are defined on edges:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An Exact Algorithm for the Capacitated Vehicle Routing Problem Based on a Two-Commodity Network Flow Formulation. R. Baldacci, E. Hadjiconstantinou, and A. Mingozzi, Operations Research 2004 52:5, 723-738. &lt;a href=&quot;https://doi.org/10.1287/opre.1040.0111&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/opre.1040.0111&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In general, to justify branching on edges, you need to prove the following: when you obtain your final &lt;em&gt;edge&lt;/em&gt; solution, you can turn it into a feasible &lt;em&gt;arc&lt;/em&gt; solution with the same cost. In the case of symmetric VRP this is trivial: just traverse all your edges in the same direction. In the case of CVRP this is already tricky: the multi-commodity formulation, for example, propagates load based on the direction of the arc, so the constraint may not work correctly for edges, making it impossible to convert back into a feasible arc solution.&lt;/p&gt;&#xA;&lt;p&gt;If it is not justified to branch on edges, but you really want to anyways, there are ways to deal with that. For example, I wrote a paper where we branch on edges to avoid symmetry to make the search more efficient. When an edge solution is found, we try to turn it into an arc solution. If that fails, we add a constraint to eliminate this edge solution, and continue the search.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Addressing Orientation Symmetry in the Time Window Assignment Vehicle Routing Problem. Kevin Dalmeijer and Guy Desaulniers. INFORMS Journal on Computing 2021 33:2, 495-510. &lt;a href=&quot;https://doi.org/10.1287/ijoc.2020.0974&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://doi.org/10.1287/ijoc.2020.0974&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="145" LastEditorUserId="145" LastEditDate="2024-03-31T23:46:59.960" LastActivityDate="2024-03-31T23:46:59.960" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
</posts>